diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 06abfad5862f8451d449bb1e8152ddd376557807..3f54a423fc751a2308f6d28188ad9cb3df22b1c4 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -269,20 +269,6 @@ config GENERIC_BUG def_bool y depends on BUG -config GENERIC_TIME_VSYSCALL - bool "Enable gettimeofday updates" - depends on CPU_V7 - help - Enables updating the kernel user helper area with the xtime struct - data for gettimeofday via kernel user helpers. - -config ARM_USE_USER_ACCESSIBLE_TIMERS - bool "Enables mapping a timer counter page to user space" - depends on USE_USER_ACCESSIBLE_TIMERS && GENERIC_TIME_VSYSCALL - help - Enables ARM-specific user-accessible timers via a shared - memory page containing the cycle counter. - config ARM_USER_ACCESSIBLE_TIMER_BASE hex "Base address of user-accessible timer counter page" default 0xfffef000 diff --git a/arch/arm/include/asm/archrandom.h b/arch/arm/include/asm/archrandom.h deleted file mode 100644 index 5530d450a098dbe23cc5ca125cfd5d635ddd7239..0000000000000000000000000000000000000000 --- a/arch/arm/include/asm/archrandom.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2013, 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 ARM_ASM_ARCHRANDOM_H -#define ARM_ASM_ARCHRANDOM_H - -extern int arch_get_random_long(unsigned long *v); -extern int arch_get_random_int(unsigned int *v); - -#endif diff --git a/arch/arm/include/asm/user_accessible_timer.h b/arch/arm/include/asm/user_accessible_timer.h index c6d7bd4b4f74862896cc0310f86a23f79a08cd21..811ccae8f01eaaac84e349cd2a3508fe7f1933cb 100644 --- a/arch/arm/include/asm/user_accessible_timer.h +++ b/arch/arm/include/asm/user_accessible_timer.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2013, 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 @@ -17,18 +17,6 @@ extern unsigned long zero_pfn; -#ifdef CONFIG_ARM_USE_USER_ACCESSIBLE_TIMERS -#ifndef CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE -#define CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE 0xfffef000 -#endif -extern void setup_user_timer_offset(unsigned long addr); -extern int get_timer_page_address(void); -static inline int get_user_accessible_timers_base(void) -{ - return CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE; -} -extern void set_user_accessible_timer_flag(bool flag); -#else #define CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE 0 static inline void setup_user_timer_offset(unsigned long addr) { @@ -44,6 +32,5 @@ static inline int get_user_accessible_timers_base(void) static inline void set_user_accessible_timer_flag(bool flag) { } -#endif #endif diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index a5d5f1aeb0730d9a18c147d91b84542d640d99da..5f3338eacad21024a75d7b1e7480f3fc58e804b8 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -63,7 +63,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_SWP_EMULATE) += swp_emulate.o CFLAGS_swp_emulate.o := -Wa,-march=armv7-a obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o -obj-$(CONFIG_GENERIC_TIME_VSYSCALL) += update_vsyscall_arm.o obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o @@ -73,7 +72,6 @@ obj-$(CONFIG_IWMMXT) += iwmmxt.o obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o perf_event_cpu.o AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o -obj-$(CONFIG_ARM_USE_USER_ACCESSIBLE_TIMERS) += user_accessible_timer.o ifneq ($(CONFIG_ARCH_EBSA110),y) obj-y += io.o diff --git a/arch/arm/kernel/perf_event_msm.c b/arch/arm/kernel/perf_event_msm.c deleted file mode 100644 index b969bf767db6e2d94894a80cac591740e9ee19dc..0000000000000000000000000000000000000000 --- a/arch/arm/kernel/perf_event_msm.c +++ /dev/null @@ -1,756 +0,0 @@ -/* - * Copyright (c) 2011-2013, 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 -#include -#include -#include "../vfp/vfpinstr.h" - -#ifdef CONFIG_CPU_V7 -#define SCORPION_EVT_PREFIX 1 -#define SCORPION_MAX_L1_REG 4 - -#define SCORPION_EVTYPE_EVENT 0xfffff - -static u32 scorpion_evt_type_base[] = {0x4c, 0x50, 0x54, 0x58, 0x5c}; - -enum scorpion_perf_common { - SCORPION_EVT_START_IDX = 0x4c, - SCORPION_ICACHE_EXPL_INV = 0x4c, - SCORPION_ICACHE_MISS = 0x4d, - SCORPION_ICACHE_ACCESS = 0x4e, - SCORPION_ICACHE_CACHEREQ_L2 = 0x4f, - SCORPION_ICACHE_NOCACHE_L2 = 0x50, - SCORPION_HIQUP_NOPED = 0x51, - SCORPION_DATA_ABORT = 0x52, - SCORPION_IRQ = 0x53, - SCORPION_FIQ = 0x54, - SCORPION_ALL_EXCPT = 0x55, - SCORPION_UNDEF = 0x56, - SCORPION_SVC = 0x57, - SCORPION_SMC = 0x58, - SCORPION_PREFETCH_ABORT = 0x59, - SCORPION_INDEX_CHECK = 0x5a, - SCORPION_NULL_CHECK = 0x5b, - SCORPION_ICIMVAU_IMPL_ICIALLU = 0x5c, - SCORPION_NONICIALLU_BTAC_INV = 0x5d, - SCORPION_IMPL_ICIALLU = 0x5e, - SCORPION_EXPL_ICIALLU = 0x5f, - SCORPION_SPIPE_ONLY_CYCLES = 0x60, - SCORPION_XPIPE_ONLY_CYCLES = 0x61, - SCORPION_DUAL_CYCLES = 0x62, - SCORPION_DISPATCH_ANY_CYCLES = 0x63, - SCORPION_FIFO_FULLBLK_CMT = 0x64, - SCORPION_FAIL_COND_INST = 0x65, - SCORPION_PASS_COND_INST = 0x66, - SCORPION_ALLOW_VU_CLK = 0x67, - SCORPION_VU_IDLE = 0x68, - SCORPION_ALLOW_L2_CLK = 0x69, - SCORPION_L2_IDLE = 0x6a, - SCORPION_DTLB_IMPL_INV_SCTLR_DACR = 0x6b, - SCORPION_DTLB_EXPL_INV = 0x6c, - SCORPION_DTLB_MISS = 0x6d, - SCORPION_DTLB_ACCESS = 0x6e, - SCORPION_ITLB_MISS = 0x6f, - SCORPION_ITLB_IMPL_INV = 0x70, - SCORPION_ITLB_EXPL_INV = 0x71, - SCORPION_UTLB_D_MISS = 0x72, - SCORPION_UTLB_D_ACCESS = 0x73, - SCORPION_UTLB_I_MISS = 0x74, - SCORPION_UTLB_I_ACCESS = 0x75, - SCORPION_UTLB_INV_ASID = 0x76, - SCORPION_UTLB_INV_MVA = 0x77, - SCORPION_UTLB_INV_ALL = 0x78, - SCORPION_S2_HOLD_RDQ_UNAVAIL = 0x79, - SCORPION_S2_HOLD = 0x7a, - SCORPION_S2_HOLD_DEV_OP = 0x7b, - SCORPION_S2_HOLD_ORDER = 0x7c, - SCORPION_S2_HOLD_BARRIER = 0x7d, - SCORPION_VIU_DUAL_CYCLE = 0x7e, - SCORPION_VIU_SINGLE_CYCLE = 0x7f, - SCORPION_VX_PIPE_WAR_STALL_CYCLES = 0x80, - SCORPION_VX_PIPE_WAW_STALL_CYCLES = 0x81, - SCORPION_VX_PIPE_RAW_STALL_CYCLES = 0x82, - SCORPION_VX_PIPE_LOAD_USE_STALL = 0x83, - SCORPION_VS_PIPE_WAR_STALL_CYCLES = 0x84, - SCORPION_VS_PIPE_WAW_STALL_CYCLES = 0x85, - SCORPION_VS_PIPE_RAW_STALL_CYCLES = 0x86, - SCORPION_EXCEPTIONS_INV_OPERATION = 0x87, - SCORPION_EXCEPTIONS_DIV_BY_ZERO = 0x88, - SCORPION_COND_INST_FAIL_VX_PIPE = 0x89, - SCORPION_COND_INST_FAIL_VS_PIPE = 0x8a, - SCORPION_EXCEPTIONS_OVERFLOW = 0x8b, - SCORPION_EXCEPTIONS_UNDERFLOW = 0x8c, - SCORPION_EXCEPTIONS_DENORM = 0x8d, -}; - -enum scorpion_perf_smp { - SCORPIONMP_NUM_BARRIERS = 0x8e, - SCORPIONMP_BARRIER_CYCLES = 0x8f, -}; - -enum scorpion_perf_up { - SCORPION_BANK_AB_HIT = 0x8e, - SCORPION_BANK_AB_ACCESS = 0x8f, - SCORPION_BANK_CD_HIT = 0x90, - SCORPION_BANK_CD_ACCESS = 0x91, - SCORPION_BANK_AB_DSIDE_HIT = 0x92, - SCORPION_BANK_AB_DSIDE_ACCESS = 0x93, - SCORPION_BANK_CD_DSIDE_HIT = 0x94, - SCORPION_BANK_CD_DSIDE_ACCESS = 0x95, - SCORPION_BANK_AB_ISIDE_HIT = 0x96, - SCORPION_BANK_AB_ISIDE_ACCESS = 0x97, - SCORPION_BANK_CD_ISIDE_HIT = 0x98, - SCORPION_BANK_CD_ISIDE_ACCESS = 0x99, - SCORPION_ISIDE_RD_WAIT = 0x9a, - SCORPION_DSIDE_RD_WAIT = 0x9b, - SCORPION_BANK_BYPASS_WRITE = 0x9c, - SCORPION_BANK_AB_NON_CASTOUT = 0x9d, - SCORPION_BANK_AB_L2_CASTOUT = 0x9e, - SCORPION_BANK_CD_NON_CASTOUT = 0x9f, - SCORPION_BANK_CD_L2_CASTOUT = 0xa0, -}; - -static const unsigned armv7_scorpion_perf_map[PERF_COUNT_HW_MAX] = { - [PERF_COUNT_HW_CPU_CYCLES] = ARMV7_PERFCTR_CPU_CYCLES, - [PERF_COUNT_HW_INSTRUCTIONS] = ARMV7_PERFCTR_INSTR_EXECUTED, - [PERF_COUNT_HW_CACHE_REFERENCES] = HW_OP_UNSUPPORTED, - [PERF_COUNT_HW_CACHE_MISSES] = HW_OP_UNSUPPORTED, - [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = ARMV7_PERFCTR_PC_WRITE, - [PERF_COUNT_HW_BRANCH_MISSES] = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED, - [PERF_COUNT_HW_BUS_CYCLES] = ARMV7_PERFCTR_CLOCK_CYCLES, -}; - -static unsigned armv7_scorpion_perf_cache_map[PERF_COUNT_HW_CACHE_MAX] - [PERF_COUNT_HW_CACHE_OP_MAX] - [PERF_COUNT_HW_CACHE_RESULT_MAX] = { - [C(L1D)] = { - /* - * The performance counters don't differentiate between read - * and write accesses/misses so this isn't strictly correct, - * but it's the best we can do. Writes and reads get - * combined. - */ - [C(OP_READ)] = { - [C(RESULT_ACCESS)] - = ARMV7_PERFCTR_L1_DCACHE_ACCESS, - [C(RESULT_MISS)] - = ARMV7_PERFCTR_L1_DCACHE_REFILL, - }, - [C(OP_WRITE)] = { - [C(RESULT_ACCESS)] - = ARMV7_PERFCTR_L1_DCACHE_ACCESS, - [C(RESULT_MISS)] - = ARMV7_PERFCTR_L1_DCACHE_REFILL, - }, - [C(OP_PREFETCH)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - }, - [C(L1I)] = { - [C(OP_READ)] = { - [C(RESULT_ACCESS)] = SCORPION_ICACHE_ACCESS, - [C(RESULT_MISS)] = SCORPION_ICACHE_MISS, - }, - [C(OP_WRITE)] = { - [C(RESULT_ACCESS)] = SCORPION_ICACHE_ACCESS, - [C(RESULT_MISS)] = SCORPION_ICACHE_MISS, - }, - [C(OP_PREFETCH)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - }, - [C(LL)] = { - [C(OP_READ)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - [C(OP_WRITE)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - [C(OP_PREFETCH)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - }, - [C(DTLB)] = { - /* - * Only ITLB misses and DTLB refills are supported. - * If users want the DTLB refills misses a raw counter - * must be used. - */ - [C(OP_READ)] = { - [C(RESULT_ACCESS)] = SCORPION_DTLB_ACCESS, - [C(RESULT_MISS)] = SCORPION_DTLB_MISS, - }, - [C(OP_WRITE)] = { - [C(RESULT_ACCESS)] = SCORPION_DTLB_ACCESS, - [C(RESULT_MISS)] = SCORPION_DTLB_MISS, - }, - [C(OP_PREFETCH)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - }, - [C(ITLB)] = { - [C(OP_READ)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = SCORPION_ITLB_MISS, - }, - [C(OP_WRITE)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = SCORPION_ITLB_MISS, - }, - [C(OP_PREFETCH)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - }, - [C(BPU)] = { - [C(OP_READ)] = { - [C(RESULT_ACCESS)] - = ARMV7_PERFCTR_PC_BRANCH_PRED, - [C(RESULT_MISS)] - = ARMV7_PERFCTR_PC_BRANCH_PRED, - }, - [C(OP_WRITE)] = { - [C(RESULT_ACCESS)] - = ARMV7_PERFCTR_PC_BRANCH_PRED, - [C(RESULT_MISS)] - = ARMV7_PERFCTR_PC_BRANCH_PRED, - }, - [C(OP_PREFETCH)] = { - [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED, - [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED, - }, - }, -}; - -static int msm_scorpion_map_event(struct perf_event *event) -{ - return armpmu_map_event(event, &armv7_scorpion_perf_map, - &armv7_scorpion_perf_cache_map, 0xfffff); -} - - -struct scorpion_evt { - /* - * The scorpion_evt_type field corresponds to the actual Scorpion - * event codes. These map many-to-one to the armv7 defined codes - */ - u32 scorpion_evt_type; - - /* - * The group_setval field corresponds to the value that the group - * register needs to be set to. This value is deduced from the row - * and column that the event belongs to in the event table - */ - u32 group_setval; - - /* - * The groupcode corresponds to the group that the event belongs to. - * Scorpion has 5 groups of events LPM0, LPM1, LPM2, L2LPM and VLPM - * going from 0 to 4 in terms of the codes used - */ - u8 groupcode; - - /* - * The armv7_evt_type field corresponds to the armv7 defined event - * code that the Scorpion events map to - */ - u32 armv7_evt_type; -}; - -static const struct scorpion_evt scorpion_event[] = { - {SCORPION_ICACHE_EXPL_INV, 0x80000500, 0, 0x4d}, - {SCORPION_ICACHE_MISS, 0x80050000, 0, 0x4e}, - {SCORPION_ICACHE_ACCESS, 0x85000000, 0, 0x4f}, - {SCORPION_ICACHE_CACHEREQ_L2, 0x86000000, 0, 0x4f}, - {SCORPION_ICACHE_NOCACHE_L2, 0x87000000, 0, 0x4f}, - {SCORPION_HIQUP_NOPED, 0x80080000, 0, 0x4e}, - {SCORPION_DATA_ABORT, 0x8000000a, 0, 0x4c}, - {SCORPION_IRQ, 0x80000a00, 0, 0x4d}, - {SCORPION_FIQ, 0x800a0000, 0, 0x4e}, - {SCORPION_ALL_EXCPT, 0x8a000000, 0, 0x4f}, - {SCORPION_UNDEF, 0x8000000b, 0, 0x4c}, - {SCORPION_SVC, 0x80000b00, 0, 0x4d}, - {SCORPION_SMC, 0x800b0000, 0, 0x4e}, - {SCORPION_PREFETCH_ABORT, 0x8b000000, 0, 0x4f}, - {SCORPION_INDEX_CHECK, 0x8000000c, 0, 0x4c}, - {SCORPION_NULL_CHECK, 0x80000c00, 0, 0x4d}, - {SCORPION_ICIMVAU_IMPL_ICIALLU, 0x8000000d, 0, 0x4c}, - {SCORPION_NONICIALLU_BTAC_INV, 0x80000d00, 0, 0x4d}, - {SCORPION_IMPL_ICIALLU, 0x800d0000, 0, 0x4e}, - {SCORPION_EXPL_ICIALLU, 0x8d000000, 0, 0x4f}, - - {SCORPION_SPIPE_ONLY_CYCLES, 0x80000600, 1, 0x51}, - {SCORPION_XPIPE_ONLY_CYCLES, 0x80060000, 1, 0x52}, - {SCORPION_DUAL_CYCLES, 0x86000000, 1, 0x53}, - {SCORPION_DISPATCH_ANY_CYCLES, 0x89000000, 1, 0x53}, - {SCORPION_FIFO_FULLBLK_CMT, 0x8000000d, 1, 0x50}, - {SCORPION_FAIL_COND_INST, 0x800d0000, 1, 0x52}, - {SCORPION_PASS_COND_INST, 0x8d000000, 1, 0x53}, - {SCORPION_ALLOW_VU_CLK, 0x8000000e, 1, 0x50}, - {SCORPION_VU_IDLE, 0x80000e00, 1, 0x51}, - {SCORPION_ALLOW_L2_CLK, 0x800e0000, 1, 0x52}, - {SCORPION_L2_IDLE, 0x8e000000, 1, 0x53}, - - {SCORPION_DTLB_IMPL_INV_SCTLR_DACR, 0x80000001, 2, 0x54}, - {SCORPION_DTLB_EXPL_INV, 0x80000100, 2, 0x55}, - {SCORPION_DTLB_MISS, 0x80010000, 2, 0x56}, - {SCORPION_DTLB_ACCESS, 0x81000000, 2, 0x57}, - {SCORPION_ITLB_MISS, 0x80000200, 2, 0x55}, - {SCORPION_ITLB_IMPL_INV, 0x80020000, 2, 0x56}, - {SCORPION_ITLB_EXPL_INV, 0x82000000, 2, 0x57}, - {SCORPION_UTLB_D_MISS, 0x80000003, 2, 0x54}, - {SCORPION_UTLB_D_ACCESS, 0x80000300, 2, 0x55}, - {SCORPION_UTLB_I_MISS, 0x80030000, 2, 0x56}, - {SCORPION_UTLB_I_ACCESS, 0x83000000, 2, 0x57}, - {SCORPION_UTLB_INV_ASID, 0x80000400, 2, 0x55}, - {SCORPION_UTLB_INV_MVA, 0x80040000, 2, 0x56}, - {SCORPION_UTLB_INV_ALL, 0x84000000, 2, 0x57}, - {SCORPION_S2_HOLD_RDQ_UNAVAIL, 0x80000800, 2, 0x55}, - {SCORPION_S2_HOLD, 0x88000000, 2, 0x57}, - {SCORPION_S2_HOLD_DEV_OP, 0x80000900, 2, 0x55}, - {SCORPION_S2_HOLD_ORDER, 0x80090000, 2, 0x56}, - {SCORPION_S2_HOLD_BARRIER, 0x89000000, 2, 0x57}, - - {SCORPION_VIU_DUAL_CYCLE, 0x80000001, 4, 0x5c}, - {SCORPION_VIU_SINGLE_CYCLE, 0x80000100, 4, 0x5d}, - {SCORPION_VX_PIPE_WAR_STALL_CYCLES, 0x80000005, 4, 0x5c}, - {SCORPION_VX_PIPE_WAW_STALL_CYCLES, 0x80000500, 4, 0x5d}, - {SCORPION_VX_PIPE_RAW_STALL_CYCLES, 0x80050000, 4, 0x5e}, - {SCORPION_VX_PIPE_LOAD_USE_STALL, 0x80000007, 4, 0x5c}, - {SCORPION_VS_PIPE_WAR_STALL_CYCLES, 0x80000008, 4, 0x5c}, - {SCORPION_VS_PIPE_WAW_STALL_CYCLES, 0x80000800, 4, 0x5d}, - {SCORPION_VS_PIPE_RAW_STALL_CYCLES, 0x80080000, 4, 0x5e}, - {SCORPION_EXCEPTIONS_INV_OPERATION, 0x8000000b, 4, 0x5c}, - {SCORPION_EXCEPTIONS_DIV_BY_ZERO, 0x80000b00, 4, 0x5d}, - {SCORPION_COND_INST_FAIL_VX_PIPE, 0x800b0000, 4, 0x5e}, - {SCORPION_COND_INST_FAIL_VS_PIPE, 0x8b000000, 4, 0x5f}, - {SCORPION_EXCEPTIONS_OVERFLOW, 0x8000000c, 4, 0x5c}, - {SCORPION_EXCEPTIONS_UNDERFLOW, 0x80000c00, 4, 0x5d}, - {SCORPION_EXCEPTIONS_DENORM, 0x8c000000, 4, 0x5f}, - -#ifdef CONFIG_MSM_SMP - {SCORPIONMP_NUM_BARRIERS, 0x80000e00, 3, 0x59}, - {SCORPIONMP_BARRIER_CYCLES, 0x800e0000, 3, 0x5a}, -#else - {SCORPION_BANK_AB_HIT, 0x80000001, 3, 0x58}, - {SCORPION_BANK_AB_ACCESS, 0x80000100, 3, 0x59}, - {SCORPION_BANK_CD_HIT, 0x80010000, 3, 0x5a}, - {SCORPION_BANK_CD_ACCESS, 0x81000000, 3, 0x5b}, - {SCORPION_BANK_AB_DSIDE_HIT, 0x80000002, 3, 0x58}, - {SCORPION_BANK_AB_DSIDE_ACCESS, 0x80000200, 3, 0x59}, - {SCORPION_BANK_CD_DSIDE_HIT, 0x80020000, 3, 0x5a}, - {SCORPION_BANK_CD_DSIDE_ACCESS, 0x82000000, 3, 0x5b}, - {SCORPION_BANK_AB_ISIDE_HIT, 0x80000003, 3, 0x58}, - {SCORPION_BANK_AB_ISIDE_ACCESS, 0x80000300, 3, 0x59}, - {SCORPION_BANK_CD_ISIDE_HIT, 0x80030000, 3, 0x5a}, - {SCORPION_BANK_CD_ISIDE_ACCESS, 0x83000000, 3, 0x5b}, - {SCORPION_ISIDE_RD_WAIT, 0x80000009, 3, 0x58}, - {SCORPION_DSIDE_RD_WAIT, 0x80090000, 3, 0x5a}, - {SCORPION_BANK_BYPASS_WRITE, 0x8000000a, 3, 0x58}, - {SCORPION_BANK_AB_NON_CASTOUT, 0x8000000c, 3, 0x58}, - {SCORPION_BANK_AB_L2_CASTOUT, 0x80000c00, 3, 0x59}, - {SCORPION_BANK_CD_NON_CASTOUT, 0x800c0000, 3, 0x5a}, - {SCORPION_BANK_CD_L2_CASTOUT, 0x8c000000, 3, 0x5b}, -#endif -}; - -static unsigned int get_scorpion_evtinfo(unsigned int scorpion_evt_type, - struct scorpion_evt *evtinfo) -{ - u32 idx; - u8 prefix; - u8 reg; - u8 code; - u8 group; - - prefix = (scorpion_evt_type & 0xF0000) >> 16; - if (prefix == SCORPION_EVT_PREFIX) { - reg = (scorpion_evt_type & 0x0F000) >> 12; - code = (scorpion_evt_type & 0x00FF0) >> 4; - group = scorpion_evt_type & 0x0000F; - - if ((group > 3) || (reg > SCORPION_MAX_L1_REG)) - return -EINVAL; - - evtinfo->group_setval = 0x80000000 | (code << (group * 8)); - evtinfo->groupcode = reg; - evtinfo->armv7_evt_type = scorpion_evt_type_base[reg] | group; - - return evtinfo->armv7_evt_type; - } - - if (scorpion_evt_type < SCORPION_EVT_START_IDX || scorpion_evt_type >= - (ARRAY_SIZE(scorpion_event) + SCORPION_EVT_START_IDX)) - return -EINVAL; - - idx = scorpion_evt_type - SCORPION_EVT_START_IDX; - if (scorpion_event[idx].scorpion_evt_type == scorpion_evt_type) { - evtinfo->group_setval = scorpion_event[idx].group_setval; - evtinfo->groupcode = scorpion_event[idx].groupcode; - evtinfo->armv7_evt_type = scorpion_event[idx].armv7_evt_type; - return scorpion_event[idx].armv7_evt_type; - } - return -EINVAL; -} - -static u32 scorpion_read_lpm0(void) -{ - u32 val; - - asm volatile("mrc p15, 0, %0, c15, c0, 0" : "=r" (val)); - return val; -} - -static void scorpion_write_lpm0(u32 val) -{ - asm volatile("mcr p15, 0, %0, c15, c0, 0" : : "r" (val)); -} - -static u32 scorpion_read_lpm1(void) -{ - u32 val; - - asm volatile("mrc p15, 1, %0, c15, c0, 0" : "=r" (val)); - return val; -} - -static void scorpion_write_lpm1(u32 val) -{ - asm volatile("mcr p15, 1, %0, c15, c0, 0" : : "r" (val)); -} - -static u32 scorpion_read_lpm2(void) -{ - u32 val; - - asm volatile("mrc p15, 2, %0, c15, c0, 0" : "=r" (val)); - return val; -} - -static void scorpion_write_lpm2(u32 val) -{ - asm volatile("mcr p15, 2, %0, c15, c0, 0" : : "r" (val)); -} - -static u32 scorpion_read_l2lpm(void) -{ - u32 val; - - asm volatile("mrc p15, 3, %0, c15, c2, 0" : "=r" (val)); - return val; -} - -static void scorpion_write_l2lpm(u32 val) -{ - asm volatile("mcr p15, 3, %0, c15, c2, 0" : : "r" (val)); -} - -static u32 scorpion_read_vlpm(void) -{ - u32 val; - - asm volatile("mrc p10, 7, %0, c11, c0, 0" : "=r" (val)); - return val; -} - -static void scorpion_write_vlpm(u32 val) -{ - asm volatile("mcr p10, 7, %0, c11, c0, 0" : : "r" (val)); -} - -/* - * The Scorpion processor supports performance monitoring for Venum unit. - * In order to access the performance monitor registers corresponding to - * VFP, CPACR and FPEXC registers need to be set up beforehand. - * Also, they need to be recovered once the access is done. - * This is the reason for having pre and post functions - */ - -static DEFINE_PER_CPU(u32, venum_orig_val); -static DEFINE_PER_CPU(u32, fp_orig_val); - -static void scorpion_pre_vlpm(void) -{ - u32 venum_new_val; - u32 fp_new_val; - u32 v_orig_val; - u32 f_orig_val; - - /* CPACR Enable CP10 and CP11 access */ - v_orig_val = get_copro_access(); - venum_new_val = v_orig_val | CPACC_SVC(10) | CPACC_SVC(11); - set_copro_access(venum_new_val); - /* Store orig venum val */ - __get_cpu_var(venum_orig_val) = v_orig_val; - - /* Enable FPEXC */ - f_orig_val = fmrx(FPEXC); - fp_new_val = f_orig_val | FPEXC_EN; - fmxr(FPEXC, fp_new_val); - /* Store orig fp val */ - __get_cpu_var(fp_orig_val) = f_orig_val; -} - -static void scorpion_post_vlpm(void) -{ - /* Restore FPEXC */ - fmxr(FPEXC, __get_cpu_var(fp_orig_val)); - isb(); - /* Restore CPACR */ - set_copro_access(__get_cpu_var(venum_orig_val)); -} - -struct scorpion_access_funcs { - u32 (*read) (void); - void (*write) (u32); - void (*pre) (void); - void (*post) (void); -}; - -/* - * The scorpion_functions array is used to set up the event register codes - * based on the group to which an event belongs to. - * Having the following array modularizes the code for doing that. - */ -struct scorpion_access_funcs scorpion_functions[] = { - {scorpion_read_lpm0, scorpion_write_lpm0, NULL, NULL}, - {scorpion_read_lpm1, scorpion_write_lpm1, NULL, NULL}, - {scorpion_read_lpm2, scorpion_write_lpm2, NULL, NULL}, - {scorpion_read_l2lpm, scorpion_write_l2lpm, NULL, NULL}, - {scorpion_read_vlpm, scorpion_write_vlpm, scorpion_pre_vlpm, - scorpion_post_vlpm}, -}; - -static inline u32 scorpion_get_columnmask(u32 evt_code) -{ - const u32 columnmasks[] = {0xffffff00, 0xffff00ff, 0xff00ffff, - 0x80ffffff}; - - return columnmasks[evt_code & 0x3]; -} - -static void scorpion_evt_setup(u32 gr, u32 setval, u32 evt_code) -{ - u32 val; - - if (scorpion_functions[gr].pre) - scorpion_functions[gr].pre(); - val = scorpion_get_columnmask(evt_code) & scorpion_functions[gr].read(); - val = val | setval; - scorpion_functions[gr].write(val); - if (scorpion_functions[gr].post) - scorpion_functions[gr].post(); -} - -static void scorpion_clear_pmuregs(void) -{ - scorpion_write_lpm0(0); - scorpion_write_lpm1(0); - scorpion_write_lpm2(0); - scorpion_write_l2lpm(0); - scorpion_pre_vlpm(); - scorpion_write_vlpm(0); - scorpion_post_vlpm(); -} - -static void scorpion_clearpmu(u32 grp, u32 val, u32 evt_code) -{ - u32 orig_pmuval, new_pmuval; - - if (scorpion_functions[grp].pre) - scorpion_functions[grp].pre(); - orig_pmuval = scorpion_functions[grp].read(); - val = val & ~scorpion_get_columnmask(evt_code); - new_pmuval = orig_pmuval & ~val; - scorpion_functions[grp].write(new_pmuval); - if (scorpion_functions[grp].post) - scorpion_functions[grp].post(); -} - -static void scorpion_pmu_disable_event(struct hw_perf_event *hwc, int idx) -{ - unsigned long flags; - u32 val = 0; - u32 gr; - unsigned long event; - struct scorpion_evt evtinfo; - struct pmu_hw_events *events = cpu_pmu->get_hw_events(); - - - /* Disable counter and interrupt */ - raw_spin_lock_irqsave(&events->pmu_lock, flags); - - /* Disable counter */ - armv7_pmnc_disable_counter(idx); - - /* - * Clear lpm code (if destined for PMNx counters) - * We don't need to set the event if it's a cycle count - */ - if (idx != ARMV7_IDX_CYCLE_COUNTER) { - val = hwc->config_base; - val &= SCORPION_EVTYPE_EVENT; - - if (val > 0x40) { - event = get_scorpion_evtinfo(val, &evtinfo); - if (event == -EINVAL) - goto scorpion_dis_out; - val = evtinfo.group_setval; - gr = evtinfo.groupcode; - scorpion_clearpmu(gr, val, evtinfo.armv7_evt_type); - } - } - /* Disable interrupt for this counter */ - armv7_pmnc_disable_intens(idx); - -scorpion_dis_out: - raw_spin_unlock_irqrestore(&events->pmu_lock, flags); -} - -static void scorpion_pmu_enable_event(struct hw_perf_event *hwc, - int idx, int cpu) -{ - unsigned long flags; - u32 val = 0; - u32 gr; - unsigned long event; - struct scorpion_evt evtinfo; - unsigned long long prev_count = local64_read(&hwc->prev_count); - struct pmu_hw_events *events = cpu_pmu->get_hw_events(); - - /* - * Enable counter and interrupt, and set the counter to count - * the event that we're interested in. - */ - raw_spin_lock_irqsave(&events->pmu_lock, flags); - - /* Disable counter */ - armv7_pmnc_disable_counter(idx); - - /* - * Set event (if destined for PMNx counters) - * We don't need to set the event if it's a cycle count - */ - if (idx != ARMV7_IDX_CYCLE_COUNTER) { - val = hwc->config_base; - val &= SCORPION_EVTYPE_EVENT; - - if (val < 0x40) { - armv7_pmnc_write_evtsel(idx, hwc->config_base); - } else { - event = get_scorpion_evtinfo(val, &evtinfo); - - if (event == -EINVAL) - goto scorpion_out; - /* - * Set event (if destined for PMNx counters) - * We don't need to set the event if it's a cycle count - */ - armv7_pmnc_write_evtsel(idx, event); - val = 0x0; - asm volatile("mcr p15, 0, %0, c9, c15, 0" : : - "r" (val)); - val = evtinfo.group_setval; - gr = evtinfo.groupcode; - scorpion_evt_setup(gr, val, evtinfo.armv7_evt_type); - } - } - - /* Enable interrupt for this counter */ - armv7_pmnc_enable_intens(idx); - - /* Restore prev val */ - armv7pmu_write_counter(idx, prev_count & COUNT_MASK); - - /* Enable counter */ - armv7_pmnc_enable_counter(idx); - -scorpion_out: - raw_spin_unlock_irqrestore(&events->pmu_lock, flags); -} - -static void scorpion_pmu_reset(void *info) -{ - u32 idx, nb_cnt = cpu_pmu->num_events; - - /* Stop all counters and their interrupts */ - for (idx = 1; idx < nb_cnt; ++idx) { - armv7_pmnc_disable_counter(idx); - armv7_pmnc_disable_intens(idx); - } - - /* Clear all pmresrs */ - scorpion_clear_pmuregs(); - - /* Reset irq stat reg */ - armv7_pmnc_getreset_flags(); - - /* Reset all ctrs to 0 */ - armv7_pmnc_write(ARMV7_PMNC_P | ARMV7_PMNC_C); -} - -static struct arm_pmu scorpion_pmu = { - .handle_irq = armv7pmu_handle_irq, - .enable = scorpion_pmu_enable_event, - .disable = scorpion_pmu_disable_event, - .read_counter = armv7pmu_read_counter, - .write_counter = armv7pmu_write_counter, - .map_event = msm_scorpion_map_event, - .get_event_idx = armv7pmu_get_event_idx, - .start = armv7pmu_start, - .stop = armv7pmu_stop, - .reset = scorpion_pmu_reset, - .test_set_event_constraints = msm_test_set_ev_constraint, - .clear_event_constraints = msm_clear_ev_constraint, - .max_period = (1LLU << 32) - 1, -}; - -static struct arm_pmu *__init armv7_scorpion_pmu_init(void) -{ - scorpion_pmu.name = "ARMv7 Scorpion"; - scorpion_pmu.num_events = armv7_read_num_pmnc_events(); - scorpion_pmu.pmu.attr_groups = msm_l1_pmu_attr_grps; - /* Unicore can't use the percpu IRQ API. */ - scorpion_pmu.request_pmu_irq = armpmu_generic_request_irq; - scorpion_pmu.free_pmu_irq = armpmu_generic_free_irq; - scorpion_clear_pmuregs(); - return &scorpion_pmu; -} - -static struct arm_pmu *__init armv7_scorpionmp_pmu_init(void) -{ - scorpion_pmu.name = "ARMv7 Scorpion-MP"; - scorpion_pmu.num_events = armv7_read_num_pmnc_events(); - scorpion_pmu.pmu.attr_groups = msm_l1_pmu_attr_grps; - scorpion_pmu.request_pmu_irq = msm_request_irq; - scorpion_pmu.free_pmu_irq = msm_free_irq; - scorpion_clear_pmuregs(); - return &scorpion_pmu; -} -#else -static struct arm_pmu *__init armv7_scorpion_pmu_init(void) -{ - return NULL; -} -static struct arm_pmu *__init armv7_scorpionmp_pmu_init(void) -{ - return NULL; -} -#endif /* CONFIG_CPU_V7 */ diff --git a/arch/arm/kernel/update_vsyscall_arm.c b/arch/arm/kernel/update_vsyscall_arm.c deleted file mode 100644 index cc4e475329c89b6129b142e10a677cab53b4ac5d..0000000000000000000000000000000000000000 --- a/arch/arm/kernel/update_vsyscall_arm.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include "update_vsyscall_arm.h" -/* - * See entry-armv.S for the offsets into the kernel user helper for - * these fields. - */ -#define ARM_VSYSCALL_TIMER_TZ 0xf20 -#define ARM_VSYSCALL_TIMER_SEQ 0xf28 -#define ARM_VSYSCALL_TIMER_OFFSET 0xf30 -#define ARM_VSYSCALL_TIMER_WTM_TV_SEC 0xf38 -#define ARM_VSYSCALL_TIMER_WTM_TV_NSEC 0xf3c -#define ARM_VSYSCALL_TIMER_CYCLE_LAST 0xf40 -#define ARM_VSYSCALL_TIMER_MASK 0xf48 -#define ARM_VSYSCALL_TIMER_MULT 0xf50 -#define ARM_VSYSCALL_TIMER_SHIFT 0xf54 -#define ARM_VSYSCALL_TIMER_TV_SEC 0xf58 -#define ARM_VSYSCALL_TIMER_TV_NSEC 0xf5c - -struct kernel_gtod_t { - u64 cycle_last; - u64 mask; - u32 mult; - u32 shift; - u32 tv_sec; - u32 tv_nsec; -}; - -struct kernel_tz_t { - u32 tz_minuteswest; - u32 tz_dsttime; -}; - -struct kernel_wtm_t { - u32 tv_sec; - u32 tv_nsec; -}; - -/* - * Updates the kernel user helper area with the current timespec - * data, as well as additional fields needed to calculate - * gettimeofday, clock_gettime, etc. - */ -void -update_vsyscall(struct timekeeper *tk) -{ - unsigned long vectors = (unsigned long)vectors_page; - unsigned long flags; - unsigned *seqnum = (unsigned *)(vectors + ARM_VSYSCALL_TIMER_SEQ); - struct kernel_gtod_t *dgtod = (struct kernel_gtod_t *)(vectors + - ARM_VSYSCALL_TIMER_CYCLE_LAST); - struct kernel_wtm_t *dgwtm = (struct kernel_wtm_t *)(vectors + - ARM_VSYSCALL_TIMER_WTM_TV_SEC); - - write_seqlock_irqsave(&kuh_time_lock, flags); - *seqnum = kuh_time_lock.seqcount.sequence; - dgtod->cycle_last = tk->clock->cycle_last; - dgtod->mask = tk->clock->mask; - dgtod->mult = tk->mult; - dgtod->shift = tk->shift; - dgtod->tv_sec = tk->xtime_sec; - dgtod->tv_nsec = tk->xtime_nsec; - dgwtm->tv_sec = tk->wall_to_monotonic.tv_sec; - dgwtm->tv_nsec = tk->wall_to_monotonic.tv_nsec; - *seqnum = kuh_time_lock.seqcount.sequence + 1; - write_sequnlock_irqrestore(&kuh_time_lock, flags); -} -EXPORT_SYMBOL(update_vsyscall); - -void -update_vsyscall_tz(void) -{ - unsigned long vectors = (unsigned long)vectors_page; - unsigned long flags; - unsigned *seqnum = (unsigned *)(vectors + ARM_VSYSCALL_TIMER_SEQ); - struct kernel_tz_t *dgtod = (struct kernel_tz_t *)(vectors + - ARM_VSYSCALL_TIMER_TZ); - - write_seqlock_irqsave(&kuh_time_lock, flags); - *seqnum = kuh_time_lock.seqcount.sequence; - dgtod->tz_minuteswest = sys_tz.tz_minuteswest; - dgtod->tz_dsttime = sys_tz.tz_dsttime; - *seqnum = kuh_time_lock.seqcount.sequence + 1; - write_sequnlock_irqrestore(&kuh_time_lock, flags); -} -EXPORT_SYMBOL(update_vsyscall_tz); diff --git a/arch/arm/kernel/update_vsyscall_arm.h b/arch/arm/kernel/update_vsyscall_arm.h deleted file mode 100644 index d06ca561605b41b4b98e58836a7bb744939464d1..0000000000000000000000000000000000000000 --- a/arch/arm/kernel/update_vsyscall_arm.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include - -extern void *vectors_page; -extern struct timezone sys_tz; - -/* - * This read-write spinlock protects us from races in SMP while - * updating the kernel user helper-embedded time. - */ -__cacheline_aligned_in_smp DEFINE_SEQLOCK(kuh_time_lock); diff --git a/arch/arm/kernel/user_accessible_timer.c b/arch/arm/kernel/user_accessible_timer.c deleted file mode 100644 index c550c0371d84ebcf6f9af64e61afe3e765356319..0000000000000000000000000000000000000000 --- a/arch/arm/kernel/user_accessible_timer.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include - -#define USER_ACCESS_TIMER_OFFSET 0xf30 -#define USER_ACCESS_FEATURE_OFFSET 0xf34 -#define USER_ACCESS_FEATURE_FLAG 0xffff0f20 - -static struct vm_area_struct user_timers_vma; -static int __init user_timers_vma_init(void) -{ - user_timers_vma.vm_start = CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE; - user_timers_vma.vm_end = CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE - + PAGE_SIZE; - user_timers_vma.vm_page_prot = PAGE_READONLY; - user_timers_vma.vm_flags = VM_READ | VM_MAYREAD; - return 0; -} -arch_initcall(user_timers_vma_init); - -int in_user_timers_area(struct mm_struct *mm, unsigned long addr) -{ - return (addr >= user_timers_vma.vm_start) && - (addr < user_timers_vma.vm_end); -} -EXPORT_SYMBOL(in_user_timers_area); - -struct vm_area_struct *get_user_timers_vma(struct mm_struct *mm) -{ - return &user_timers_vma; -} -EXPORT_SYMBOL(get_user_timers_vma); - -int get_user_timer_page(struct vm_area_struct *vma, - struct mm_struct *mm, unsigned long start, unsigned int gup_flags, - struct page **pages, int idx, int *goto_next_page) -{ - /* Replicates the earlier work done in mm/memory.c */ - unsigned long pg = start & PAGE_MASK; - pgd_t *pgd; - pud_t *pud; - pmd_t *pmd; - pte_t *pte; - - /* Unset this flag -- this only gets activated if the - * caller should go straight to the next_page label on - * return. - */ - *goto_next_page = 0; - - /* user gate pages are read-only */ - if (gup_flags & FOLL_WRITE) - return idx ? : -EFAULT; - if (pg > TASK_SIZE) - pgd = pgd_offset_k(pg); - else - pgd = pgd_offset_gate(mm, pg); - BUG_ON(pgd_none(*pgd)); - pud = pud_offset(pgd, pg); - BUG_ON(pud_none(*pud)); - pmd = pmd_offset(pud, pg); - if (pmd_none(*pmd)) - return idx ? : -EFAULT; - VM_BUG_ON(pmd_trans_huge(*pmd)); - pte = pte_offset_map(pmd, pg); - if (pte_none(*pte)) { - pte_unmap(pte); - return idx ? : -EFAULT; - } - vma = get_user_timers_vma(mm); - if (pages) { - struct page *page; - - page = vm_normal_page(vma, start, *pte); - if (!page) { - if (!(gup_flags & FOLL_DUMP) && - zero_pfn == pte_pfn(*pte)) - page = pte_page(*pte); - else { - pte_unmap(pte); - return idx ? : -EFAULT; - } - } - pages[idx] = page; - get_page(page); - } - pte_unmap(pte); - /* In this case, set the next page */ - *goto_next_page = 1; - return 0; -} -EXPORT_SYMBOL(get_user_timer_page); - -void setup_user_timer_offset(unsigned long addr) -{ -#if defined(CONFIG_CPU_USE_DOMAINS) - unsigned long vectors = CONFIG_VECTORS_BASE; -#else - unsigned long vectors = (unsigned long)vectors_page; -#endif - unsigned long *timer_offset = (unsigned long *)(vectors + - USER_ACCESS_TIMER_OFFSET); - *timer_offset = addr; -} -EXPORT_SYMBOL(setup_user_timer_offset); - -void set_user_accessible_timer_flag(bool flag) -{ -#if defined(CONFIG_CPU_USE_DOMAINS) - unsigned long vectors = CONFIG_VECTORS_BASE; -#else - unsigned long vectors = (unsigned long)vectors_page; -#endif - unsigned long *timer_offset = (unsigned long *)(vectors + - USER_ACCESS_FEATURE_OFFSET); - *timer_offset = (flag ? USER_ACCESS_FEATURE_FLAG : 0); -} -EXPORT_SYMBOL(set_user_accessible_timer_flag); diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig index d96d513541f65840d8474401d14fda518ceb0190..504e8f62dc393d8c4c5868510c1792d2580892db 100644 --- a/arch/arm/mach-msm/Kconfig +++ b/arch/arm/mach-msm/Kconfig @@ -312,10 +312,6 @@ config MSM_RESTART_V2 config ARCH_MSM_CORTEX_A5 bool -config MSM_RPM - bool "Resource Power Manager" - select MSM_MPM - config MSM_RPM_SMD depends on MSM_SMD select MSM_MPM_OF @@ -327,14 +323,6 @@ config MSM_RPM_SMD the MSM_MPM config that programs the MPM module to monitor interrupts during sleep modes. -config MSM_MPM - bool "Modem Power Manager" - help - MPM is a dedicated hardware resource responsible for entering and - waking up from a system wide low power mode. The MPM driver tracks - the wakeup interrupts and configures the MPM to monitor the wakeup - interrupts when going to a system wide sleep mode. - config MSM_MPM_OF bool "Modem Power Manager" depends on OF @@ -619,20 +607,6 @@ config CPU_HAS_L2_PMU help Select this if the L2 cache controller has a Performance Monitoring Unit. -config MSM_FIQ_SUPPORT - default y - bool "Enable installation of an FIQ handler." - -config MSM_SERIAL_DEBUGGER - select MSM_FIQ_SUPPORT - select KERNEL_DEBUGGER_CORE - default n - bool "FIQ Mode Serial Debugger" - help - The FIQ serial debugger can accept commands even when the - kernel is unresponsive due to being stuck with interrupts - disabled. Depends on the kernel debugger core in drivers/misc. - config MSM_SERIAL_DEBUGGER_CONSOLE depends on MSM_SERIAL_DEBUGGER default n @@ -772,14 +746,6 @@ config MSM_SMD_PKT If in doubt, say yes. -config MSM_ONCRPCROUTER - depends on MSM_SMD - default n - bool "MSM ONCRPC router support" - help - Support for the MSM ONCRPC router for communication between - the ARM9 and ARM11 - config MSM_IPC_ROUTER depends on NET default n @@ -853,50 +819,6 @@ config MSM_RPC_LOOPBACK_XPRT Support for routing RPC messages between APPS clients and APPS servers. Helps in testing APPS RPC framework. -config MSM_RPCSERVER_TIME_REMOTE - depends on MSM_ONCRPCROUTER && RTC_HCTOSYS - default y - bool "Time remote RPC server" - help - The time remote server receives notification of time bases and - reports these events to registered callback functions. - -config MSM_RPCSERVER_WATCHDOG - depends on MSM_ONCRPCROUTER - default y - bool "Watchdog RPC server" - help - The dog_keepalive server handles watchdog events. - -config MSM_RPC_WATCHDOG - depends on MSM_ONCRPCROUTER - default n - bool "Watchdog RPC client" - help - The dog_keepalive client module. - -config MSM_RPC_PING - depends on MSM_ONCRPCROUTER && DEBUG_FS - default m - bool "MSM rpc ping" - help - Implements MSM rpc ping test module. - -config MSM_RPC_OEM_RAPI - depends on MSM_ONCRPCROUTER - default m - bool "MSM oem rapi" - help - Implements MSM oem rapi client module. - -config MSM_RPCSERVER_HANDSET - depends on MSM_ONCRPCROUTER - default y - bool "Handset events RPC server" - help - Support for receiving handset events like headset detect, - headset switch and clamshell state. - config MSM_RMT_STORAGE_CLIENT depends on (ARCH_MSM && MSM_ONCRPCROUTER) default n @@ -1118,39 +1040,6 @@ config MSM_PIL Say yes to support these devices. -config MSM_PIL_MODEM - tristate "Modem (ARM11) Boot Support" - depends on MSM_PIL && MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down ARM11 Modem processors. - -config MSM_PIL_QDSP6V3 - tristate "QDSP6v3 (Hexagon) Boot Support" - depends on MSM_PIL && MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down QDSP6v3 processors (hexagon). - The QDSP6 is a low power DSP used in audio software applications. - -config MSM_PIL_LPASS_QDSP6V4 - tristate "LPASS QDSP6v4 (Hexagon) Boot Support" - depends on MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down QDSP6v4 processors (hexagon) - in low power audio subsystems. If you would like to record or - play audio then say Y here. - - If unsure, say N. - -config MSM_PIL_MODEM_QDSP6V4 - tristate "Modem QDSP6v4 (Hexagon) Boot Support" - depends on MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down QDSP6v4 processors (hexagon) - in modem subsystems. If you would like to make or receive phone - calls then say Y here. - - If unsure, say N. - config MSM_PIL_LPASS_QDSP6V5 tristate "LPASS QDSP6v5 (Hexagon) Boot Support" depends on MSM_PIL && MSM_SUBSYSTEM_RESTART @@ -1170,39 +1059,6 @@ config MSM_PIL_MSS_QDSP6V5 If unsure, say N. -config MSM_PIL_RIVA - tristate "RIVA (WCNSS) Boot Support" - depends on MSM_PIL && MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down the RIVA processor (WCNSS). - Riva is the wireless subsystem processor used in bluetooth, wireless - LAN, and FM software applications. - -config MSM_PIL_TZAPPS - tristate "TZApps Boot Support" - depends on MSM_PIL && MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down TZApps. - - TZApps is an image that runs in the secure processor state. It is - used to decrypt data and perform secure operations on the behalf of - the kernel. - -config MSM_PIL_DSPS - tristate "DSPS Boot Support" - depends on MSM_PIL && MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down ARM7 DSPS processors. - - DSPS is a sensors offloading processor used for applications such - as rotation detection, temperature, etc. - -config MSM_PIL_VIDC - tristate "Video Core Secure Boot Support" - depends on MSM_PIL && MSM_SUBSYSTEM_RESTART - help - Support for authenticating the video core image. - config MSM_PIL_VENUS tristate "VENUS (Video) Boot Support" depends on MSM_PIL && MSM_SUBSYSTEM_RESTART @@ -1229,13 +1085,6 @@ config MSM_PIL_BCSS BCSS is the Broadcast subsystem processor to receive and process the Analog/Digital broadcast data from tuners / external demodulator. -config MSM_PIL_GSS - tristate "GSS (Cortex A5) Boot Support" - depends on MSM_PIL && MSM_SUBSYSTEM_RESTART - help - Support for booting and shutting down Cortex A5 processors which run - GPS subsystem firmware. - config MSM_PIL_PRONTO tristate "PRONTO (WCNSS) Boot Support" depends on MSM_PIL && MSM_SUBSYSTEM_RESTART @@ -1297,16 +1146,6 @@ config MSM_RPM_STATS_LOG the low power modes that RPM enters. The drivers outputs the message via a debugfs node. -config MSM_RPM_RBCPR_STATS_LOG - tristate "MSM Resource Power Manager RPBCPR Stat Driver" - depends on DEBUG_FS - depends on MSM_RPM - help - This option enables a driver which reads RPM messages from a shared - memory location. These messages provide statistical information about - RBCPR (Rapid Bridge Core Power Reduction) information . The drivers - outputs the message via a debugfs node. - config MSM_RPM_RBCPR_STATS_V2_LOG tristate "MSM Resource Power Manager RPBCPR Stat Driver" depends on DEBUG_FS @@ -1326,9 +1165,6 @@ config IOMMU_API config MSM_GPIOMUX bool -config MSM_SECURE_IO - bool - config MSM_NATIVE_RESTART bool @@ -1406,9 +1242,6 @@ config MSM_JTAG_MM If unsure, say 'N' here to avoid potential power, performance and memory penalty. -config MSM_SLEEP_STATS_DEVICE - bool "Enable exporting of MSM sleep device stats to userspace" - config MSM_RUN_QUEUE_STATS bool "Enable collection and exporting of MSM Run Queue stats to userspace" default n @@ -1437,13 +1270,6 @@ config MSM_SHOW_RESUME_IRQ the resume loop unrolls. Say Y if you want to debug why the system resumed. -config MSM_FAKE_BATTERY - depends on POWER_SUPPLY - default n - bool "MSM Fake Battery" - help - Enables MSM fake battery driver. - config MSM_QDSP6_APRV2 bool "Audio QDSP6 APRv2 support" depends on MSM_SMD @@ -1493,14 +1319,6 @@ config MSM_ULTRASOUND_B HW and services, calculating input events upon the ultrasound data. -config MSM_RPC_VIBRATOR - bool "RPC based MSM Vibrator Support" - depends on MSM_ONCRPCROUTER - help - Enable the vibrator support on MSM over RPC. The vibrator - is connected on the PMIC. Say Y if you want to enable this - feature. - config PM8XXX_RPC_VIBRATOR bool "RPC based Vibrator on PM8xxx PMICs" depends on MSM_RPC_VIBRATOR @@ -1613,16 +1431,6 @@ config USE_PINCTRL_IRQ attributes to be configured, prior to configuring them as interrupt triggers. -config MSM_EBI_ERP - bool "External Bus Interface (EBI) error reporting" - help - Say 'Y' here to enable reporting of external bus interface errors to - the kernel log. Information such as the offending address and - transaction type will be logged. This may be useful for debugging - seemingly broken memory accesses. - - For production builds, you should probably say 'N' here. - config MSM_CACHE_ERP bool "Cache / CPU error reporting" depends on ARCH_MSM_KRAIT @@ -1717,15 +1525,6 @@ config MSM_L2_ERP_2BIT_PANIC For production builds, it may be acceptable to say 'N' here, since an uncorrectable error might not necessarily cause further problems. -config MSM_DCVS - bool "Use MSM DCVS for CPU/GPU Frequency control" - depends on MSM_SCM - help - Enable support for MSM DCVS to control all CPU and GPU core frequencies. - The DCVS manager allows idle driver to feed the idle information to the - algorithm and the algorithm returns a frequency for the core which is - passed to the frequency change driver. - config MSM_CPR tristate "Use MSM CPR in S/W mode" help @@ -1768,15 +1567,6 @@ config MSM_HSIC_SYSMON_TEST can be read and written to send character data to the sysmon port of the modem over USB. -config MSM_RPC_PMIC - tristate "MSM RPC PMIC driver" - depends on MSM_ONCRPCROUTER - help - This driver supports the PMIC functionality over RPC for those MSM's - which do not have a direct access to PMIC. It supports ability to - configure MPP, GPIO and all the other supported peripherals of the - PMIC. - config MSM_RPC_USB tristate "MSM RPC USB driver" depends on MSM_ONCRPCROUTER @@ -1787,15 +1577,6 @@ config MSM_RPC_USB required for MSMs on which the APPS does not have a direct access to the PMIC. -config MSM_RPC_PMAPP - tristate "MSM RPC PMIC APP driver" - depends on MSM_ONCRPCROUTER - help - This driver supports the configuration of various PMIC APP modules - such as display backlight, vreg pin-ctrl, smps clock over the RPC - interface. This support is required for MSMs on which the APPS - does not have a direct access to the PMIC. - config MSM_ENABLE_WDOG_DEBUG_CONTROL bool "Enable control of watchdog debug and boot partition select" help diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile index d86a3af359c34ceee80dba6b7e8fee823552bf82..4fe4d328aa038239714015750ed6476f4f709d61 100644 --- a/arch/arm/mach-msm/Makefile +++ b/arch/arm/mach-msm/Makefile @@ -8,7 +8,6 @@ obj-y += clock.o clock-voter.o clock-dummy.o clock-generic.o obj-y += modem_notifier.o obj-$(CONFIG_USE_OF) += board-dt.o obj-$(CONFIG_DEBUG_FS) += nohlt.o clock-debug.o -obj-$(CONFIG_KEXEC) += msm_kexec.o obj-y += acpuclock.o obj-$(CONFIG_ARCH_MSM_KRAIT) += clock-krait.o @@ -22,7 +21,6 @@ obj-$(CONFIG_SMP) += headsmp.o platsmp.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o obj-$(CONFIG_MSM_AVS_HW) += avs.o -obj-$(CONFIG_CPU_V6) += idle-v6.o obj-$(CONFIG_CPU_V7) += idle-v7.o obj-$(CONFIG_MSM_JTAG) += jtag-fuse.o jtag.o obj-$(CONFIG_MSM_JTAG_MM) += jtag-fuse.o jtag-mm.o @@ -39,26 +37,15 @@ obj-$(CONFIG_MSM_SMP2P) += smp2p.o smp2p_debug.o smp2p_gpio.o obj-$(CONFIG_MSM_SMP2P_TEST) += smp2p_loopback.o smp2p_test.o smp2p_gpio_test.o smp2p_spinlock_test.o obj-$(CONFIG_MSM_SCM) += scm.o scm-boot.o obj-$(CONFIG_MSM_XPU_ERR_FATAL) += scm-xpu.o -obj-$(CONFIG_MSM_SECURE_IO) += scm-io.o obj-$(CONFIG_MSM_PIL) += peripheral-loader.o obj-$(CONFIG_MSM_PIL) += scm-pas.o -obj-$(CONFIG_MSM_PIL_QDSP6V3) += pil-q6v3.o -obj-$(CONFIG_MSM_PIL_LPASS_QDSP6V4) += pil-q6v4.o pil-q6v4-lpass.o -obj-$(CONFIG_MSM_PIL_MODEM_QDSP6V4) += pil-q6v4.o pil-q6v4-mss.o obj-$(CONFIG_MSM_PIL_LPASS_QDSP6V5) += pil-q6v5.o pil-q6v5-lpass.o obj-$(CONFIG_MSM_PIL_MSS_QDSP6V5) += pil-q6v5.o pil-msa.o pil-q6v5-mss.o -obj-$(CONFIG_MSM_PIL_RIVA) += pil-riva.o -obj-$(CONFIG_MSM_PIL_TZAPPS) += pil-tzapps.o -obj-$(CONFIG_MSM_PIL_VIDC) += pil-vidc.o -obj-$(CONFIG_MSM_PIL_MODEM) += pil-modem.o -obj-$(CONFIG_MSM_PIL_DSPS) += pil-dsps.o -obj-$(CONFIG_MSM_PIL_GSS) += pil-gss.o obj-$(CONFIG_MSM_PIL_PRONTO) += pil-pronto.o obj-$(CONFIG_MSM_PIL_VENUS) += pil-venus.o obj-$(CONFIG_MSM_PIL_VPU) += pil-vpu.o obj-$(CONFIG_MSM_PIL_FEMTO) += pil-q6v5.o pil-msa.o pil-femto-modem.o obj-$(CONFIG_MSM_PIL_BCSS) += pil-bcss.o -obj-$(CONFIG_MSM_FIQ_SUPPORT) += fiq_glue.o obj-$(CONFIG_MSM_BAM_DMUX) += bam_dmux.o obj-$(CONFIG_MSM_SMD_LOGGING) += smem_log.o obj-$(CONFIG_MSM_IPC_LOGGING) += ipc_logging.o @@ -70,25 +57,12 @@ obj-$(CONFIG_MSM_SMD_TTY) += smd_tty.o obj-$(CONFIG_MSM_SMD_PKT) += smd_pkt.o obj-$(CONFIG_MSM_IPC_ROUTER_SMD_XPRT) += ipc_router_smd_xprt.o obj-$(CONFIG_MSM_IPC_ROUTER_HSIC_XPRT) += ipc_router_hsic_xprt.o -obj-$(CONFIG_MSM_ONCRPCROUTER) += smd_rpcrouter.o -obj-$(CONFIG_MSM_ONCRPCROUTER) += smd_rpcrouter_device.o obj-$(CONFIG_MSM_IPC_ROUTER) += ipc_router.o obj-$(CONFIG_MSM_IPC_ROUTER)+= ipc_socket.o obj-$(CONFIG_MSM_IPC_ROUTER_SECURITY)+= msm_ipc_router_security.o obj-$(CONFIG_MSM_QMI_INTERFACE) += msm_qmi_interface.o obj-$(CONFIG_MSM_TEST_QMI_CLIENT) += kernel_test_service_v01.o test_qmi_client.o obj-$(CONFIG_DEBUG_FS) += smd_rpc_sym.o -obj-$(CONFIG_MSM_ONCRPCROUTER) += smd_rpcrouter_servers.o -obj-$(CONFIG_MSM_ONCRPCROUTER) += smd_rpcrouter_clients.o -obj-$(CONFIG_MSM_ONCRPCROUTER) += smd_rpcrouter_xdr.o -obj-$(CONFIG_MSM_ONCRPCROUTER) += rpcrouter_smd_xprt.o -obj-$(CONFIG_MSM_RPC_PING) += ping_mdm_rpc_client.o -obj-$(CONFIG_MSM_RPC_PING) += ping_mdm_rpc_client.o ping_apps_server.o -obj-$(CONFIG_MSM_RPC_OEM_RAPI) += oem_rapi_client.o -obj-$(CONFIG_MSM_RPC_WATCHDOG) += rpc_dog_keepalive.o -obj-$(CONFIG_MSM_RPCSERVER_WATCHDOG) += rpc_server_dog_keepalive.o -obj-$(CONFIG_MSM_RPCSERVER_TIME_REMOTE) += rpc_server_time_remote.o -obj-$(CONFIG_MSM_RPCSERVER_HANDSET) += rpc_server_handset.o obj-$(CONFIG_MSM_AUDIO_QDSP6V2) += qdsp6v2/ obj-$(CONFIG_PM) += pm-boot.o obj-$(CONFIG_MSM_IDLE_STATS) += pm-stats.o @@ -156,13 +130,10 @@ obj-$(CONFIG_MSM_PM8X60) += pm-8x60.o pm-data.o CFLAGS_msm_vibrator.o += -Idrivers/staging/android obj-$(CONFIG_MSM_RMT_STORAGE_CLIENT) += rmt_storage_client.o -obj-$(CONFIG_MSM_RPM) += rpm.o rpm_resources.o obj-$(CONFIG_MSM_LPM_TEST) += test-lpm.o obj-$(CONFIG_MSM_RPM_SMD) += rpm-smd.o lpm_levels.o obj-$(CONFIG_MSM_MPM_OF) += mpm-of.o -obj-$(CONFIG_MSM_MPM) += mpm.o obj-$(CONFIG_MSM_RPM_STATS_LOG) += rpm_stats.o rpm_master_stat.o -obj-$(CONFIG_MSM_RPM_RBCPR_STATS_LOG) += rpm_rbcpr_stats.o obj-$(CONFIG_MSM_RPM_RBCPR_STATS_V2_LOG) += rpm_rbcpr_stats_v2.o obj-$(CONFIG_MSM_RPM_LOG) += rpm_log.o obj-$(CONFIG_MSM_TZ_LOG) += tz_log.o @@ -186,34 +157,22 @@ obj-$(CONFIG_ARCH_MSM8610) += gpiomux-v2.o gpiomux.o obj-$(CONFIG_ARCH_APQ8084) += gpiomux-v2.o gpiomux.o obj-$(CONFIG_ARCH_FSM9900) += gpiomux-v2.o gpiomux.o -obj-$(CONFIG_MSM_SLEEP_STATS_DEVICE) += idle_stats_device.o -obj-$(CONFIG_MSM_DCVS) += msm_dcvs_scm.o msm_dcvs.o msm_mpdecision.o obj-$(CONFIG_MSM_RUN_QUEUE_STATS) += msm_rq_stats.o obj-$(CONFIG_MSM_SHOW_RESUME_IRQ) += msm_show_resume_irq.o -obj-$(CONFIG_MSM_FAKE_BATTERY) += fish_battery.o -obj-$(CONFIG_MSM_RPC_VIBRATOR) += msm_vibrator.o obj-$(CONFIG_MSM_NATIVE_RESTART) += restart.o obj-$(CONFIG_EXTERNAL_MDM) += mdm2.o mdm_common.o obj-$(CONFIG_MSM_CACHE_ERP) += cache_erp.o -obj-$(CONFIG_MSM_EBI_ERP) += ebi_erp.o obj-$(CONFIG_MSM_CACHE_DUMP) += msm_cache_dump.o obj-$(CONFIG_MSM_HSIC_SYSMON) += hsic_sysmon.o obj-$(CONFIG_MSM_HSIC_SYSMON_TEST) += hsic_sysmon_test.o obj-$(CONFIG_MSM_RPM_SMD) += rpm-smd.o -obj-$(CONFIG_MSM_CPR) += msm_cpr.o -obj-$(CONFIG_MSM_RPC_PMIC) += pmic.o obj-$(CONFIG_MSM_RPC_USB) += rpc_hsusb.o rpc_fsusb.o -obj-$(CONFIG_MSM_RPC_PMAPP) += rpc_pmapp.o obj-$(CONFIG_MSM_ENABLE_WDOG_DEBUG_CONTROL) += wdog_debug.o -ifdef CONFIG_MSM_CPR -obj-$(CONFIG_DEBUG_FS) += msm_cpr-debug.o -endif - obj-$(CONFIG_MEMORY_HOLE_CARVEOUT) += msm_mem_hole.o obj-$(CONFIG_MSM_SMCMOD) += smcmod.o diff --git a/arch/arm/mach-msm/clock-pll.c b/arch/arm/mach-msm/clock-pll.c index f6e77426430ae53f7a7a3a94fc2435248bd7d17d..2c730dde5688b3071d59d7fbdd763751d0fdb9ef 100644 --- a/arch/arm/mach-msm/clock-pll.c +++ b/arch/arm/mach-msm/clock-pll.c @@ -25,12 +25,6 @@ #include "clock.h" #include "clock-pll.h" -#ifdef CONFIG_MSM_SECURE_IO -#undef readl_relaxed -#undef writel_relaxed -#define readl_relaxed secure_readl -#define writel_relaxed secure_writel -#endif #define PLL_OUTCTRL BIT(0) #define PLL_BYPASSNL BIT(1) diff --git a/arch/arm/mach-msm/devices.h b/arch/arm/mach-msm/devices.h index eb12383347a4bdc13cdbdf6498de0f613e825e92..8c3124bdaa3e059f3a9317063a54ae468c468c24 100644 --- a/arch/arm/mach-msm/devices.h +++ b/arch/arm/mach-msm/devices.h @@ -32,11 +32,6 @@ void __init msm_rotator_set_split_iommu_domain(void); extern struct platform_device asoc_msm_pcm; extern struct platform_device asoc_msm_dai0; extern struct platform_device asoc_msm_dai1; -#if defined (CONFIG_SND_MSM_MVS_DAI_SOC) -extern struct platform_device asoc_msm_mvs; -extern struct platform_device asoc_mvs_dai0; -extern struct platform_device asoc_mvs_dai1; -#endif extern struct platform_device msm_ebi0_thermal; extern struct platform_device msm_ebi1_thermal; @@ -195,9 +190,6 @@ extern struct platform_device msm_device_nand; extern struct platform_device msm_device_tssc; extern struct platform_device msm_rotator_device; -#ifdef CONFIG_MSM_VCAP -extern struct platform_device msm8064_device_vcap; -#endif #ifdef CONFIG_MSM_BUS_SCALING extern struct msm_bus_scale_pdata rotator_bus_scale_pdata; diff --git a/arch/arm/mach-msm/ebi_erp.c b/arch/arm/mach-msm/ebi_erp.c deleted file mode 100644 index 3ff0516a8cd56d6e70595b315857254eef54e5be..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/ebi_erp.c +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -DEFINE_TRACE(usb_daytona_invalid_access); - -#define MODULE_NAME "msm_ebi_erp" - -#define EBI_ERR_ADDR 0x100 -#define SLV_ERR_APACKET_0 0x108 -#define SLV_ERR_APACKET_1 0x10C -#define SLV_ERR_CNTL 0x114 - -#define CNTL_ERR_OCCURRED BIT(4) -#define CNTL_CLEAR_ERR BIT(8) -#define CNTL_IRQ_EN BIT(12) - -#define AMID_MASK 0xFFFF -#define ERR_AWRITE BIT(0) -#define ERR_AOOOWR BIT(1) -#define ERR_AOOORD BIT(2) -#define ERR_APTORNS BIT(3) -#define ERR_ALOCK_SHIFT 6 -#define ERR_ALOCK_MASK 0x3 -#define ERR_ATYPE_SHIFT 8 -#define ERR_ATYPE_MASK 0xF -#define ERR_ABURST BIT(12) -#define ERR_ASIZE_SHIFT 13 -#define ERR_ASIZE_MASK 0x7 -#define ERR_ATID_SHIFT 16 -#define ERR_ATID_MASK 0xFF -#define ERR_ALEN_SHIFT 24 -#define ERR_ALEN_MASK 0xF - -#define ERR_CODE_DECODE_ERROR BIT(0) -#define ERR_CODE_MPU_ERROR BIT(1) - -struct msm_ebi_erp_data { - void __iomem *base; - struct device *dev; -}; - -static const char *err_lock_types[4] = { - "normal", - "exclusive", - "locked", - "barrier", -}; - -static const char *err_sizes[8] = { - "byte", - "half word", - "word", - "double word", - "reserved_4", - "reserved_5", - "reserved_6", - "reserved_7", -}; - -static irqreturn_t msm_ebi_irq(int irq, void *dev_id) -{ - struct msm_ebi_erp_data *drvdata = dev_id; - void __iomem *base = drvdata->base; - unsigned int err_addr, err_apacket0, err_apacket1, err_cntl; - - err_addr = readl_relaxed(base + EBI_ERR_ADDR); - err_apacket0 = readl_relaxed(base + SLV_ERR_APACKET_0); - err_apacket1 = readl_relaxed(base + SLV_ERR_APACKET_1); - err_cntl = readl_relaxed(base + SLV_ERR_CNTL); - - if (!(err_cntl & CNTL_ERR_OCCURRED)) - return IRQ_NONE; - - pr_alert("EBI error detected!\n"); - pr_alert("\tDevice = %s\n", dev_name(drvdata->dev)); - pr_alert("\tERR_ADDR = 0x%08x\n", err_addr); - pr_alert("\tAPACKET0 = 0x%08x\n", err_apacket0); - pr_alert("\tAPACKET1 = 0x%08x\n", err_apacket1); - pr_alert("\tERR_CNTL = 0x%08x\n", err_cntl); - - pr_alert("\tAMID = 0x%08x\n", err_apacket0 & AMID_MASK); - pr_alert("\tType = %s, %s, %s\n", - err_apacket1 & ERR_AWRITE ? "write" : "read", - err_sizes[(err_apacket1 >> ERR_ASIZE_SHIFT) & ERR_ASIZE_MASK], - err_apacket1 & ERR_APTORNS ? "non-secure" : "secure"); - - pr_alert("\tALOCK = %s\n", - err_lock_types[(err_apacket1 >> ERR_ALOCK_SHIFT) & ERR_ALOCK_MASK]); - - pr_alert("\tABURST = %s\n", err_apacket1 & ERR_ABURST ? - "increment" : "wrap"); - - pr_alert("\tCODE = %s %s\n", err_cntl & ERR_CODE_DECODE_ERROR ? - "decode error" : "", - err_cntl & ERR_CODE_MPU_ERROR ? - "mpu error" : ""); - err_cntl |= CNTL_CLEAR_ERR; - writel_relaxed(err_cntl, base + SLV_ERR_CNTL); - mb(); /* Ensure interrupt is cleared before returning */ - - if ((err_apacket0 & AMID_MASK) == 0x00000102) - trace_usb_daytona_invalid_access(err_addr, err_apacket0, - err_apacket1); - - return IRQ_HANDLED; -} - -static int msm_ebi_erp_probe(struct platform_device *pdev) -{ - struct resource *r; - struct msm_ebi_erp_data *drvdata; - int ret, irq; - unsigned int err_cntl; - - drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) - return -ENOMEM; - - drvdata->dev = &pdev->dev; - platform_set_drvdata(pdev, drvdata); - - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) - return -EINVAL; - - drvdata->base = devm_ioremap(&pdev->dev, r->start, resource_size(r)); - if (!drvdata->base) - return -ENOMEM; - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - ret = devm_request_irq(&pdev->dev, irq, msm_ebi_irq, IRQF_TRIGGER_HIGH, - dev_name(&pdev->dev), drvdata); - if (ret) - return ret; - - /* Enable the interrupt */ - err_cntl = readl_relaxed(drvdata->base + SLV_ERR_CNTL); - err_cntl |= CNTL_IRQ_EN; - writel_relaxed(err_cntl, drvdata->base + SLV_ERR_CNTL); - mb(); /* Ensure interrupt is enabled before returning */ - return 0; -} - -static int msm_ebi_erp_remove(struct platform_device *pdev) -{ - struct msm_ebi_erp_data *drvdata = platform_get_drvdata(pdev); - unsigned int err_cntl; - - /* Disable the interrupt */ - err_cntl = readl_relaxed(drvdata->base + SLV_ERR_CNTL); - err_cntl &= ~CNTL_IRQ_EN; - writel_relaxed(err_cntl, drvdata->base + SLV_ERR_CNTL); - mb(); /* Ensure interrupt is disabled before returning */ - return 0; -} - -static struct platform_driver msm_ebi_erp_driver = { - .probe = msm_ebi_erp_probe, - .remove = msm_ebi_erp_remove, - .driver = { - .name = MODULE_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init msm_ebi_erp_init(void) -{ - return platform_driver_register(&msm_ebi_erp_driver); -} - -static void __exit msm_ebi_erp_exit(void) -{ - platform_driver_unregister(&msm_ebi_erp_driver); -} - - -module_init(msm_ebi_erp_init); -module_exit(msm_ebi_erp_exit); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("MSM cache error reporting driver"); diff --git a/arch/arm/mach-msm/fiq.h b/arch/arm/mach-msm/fiq.h deleted file mode 100644 index cd903908c0878c90d0cf50c25cd8b08eb4ba3de9..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/fiq.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2007 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _ARCH_ARM_MACH_MSM_FIQ_H -#define _ARCH_ARM_MACH_MSM_FIQ_H - -extern unsigned char fiq_glue, fiq_glue_end; -void fiq_glue_setup(void *func, void *data, void *sp); - -#endif diff --git a/arch/arm/mach-msm/fiq_glue.S b/arch/arm/mach-msm/fiq_glue.S deleted file mode 100644 index df1c7084fe115076b9a3436ef7d6b94f4adf3f5e..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/fiq_glue.S +++ /dev/null @@ -1,112 +0,0 @@ -/* arch/arm/mach-msm/fiq_glue.S - * - * Copyright (C) 2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include - - .text - - .global fiq_glue_end - - /* fiq stack: r0-r15,cpsr,spsr of interrupted mode */ - -ENTRY(fiq_glue) - /* store pc, cpsr from previous mode */ - mrs r12, spsr - sub r11, lr, #4 - subs r10, #1 - bne nested_fiq - - stmfd sp!, {r11-r12, lr} - - /* store r8-r14 from previous mode */ - sub sp, sp, #(7 * 4) - stmia sp, {r8-r14}^ - nop - - /* store r0-r7 from previous mode */ - stmfd sp!, {r0-r7} - - /* setup func(data,regs) arguments */ - mov r0, r9 - mov r1, sp - mov r3, r8 - - mov r7, sp - - /* Get sp and lr from non-user modes */ - and r4, r12, #MODE_MASK - cmp r4, #USR_MODE - beq fiq_from_usr_mode - - mov r7, sp - orr r4, r4, #(PSR_I_BIT | PSR_F_BIT) - msr cpsr_c, r4 - str sp, [r7, #(4 * 13)] - str lr, [r7, #(4 * 14)] - mrs r5, spsr - str r5, [r7, #(4 * 17)] - - cmp r4, #(SVC_MODE | PSR_I_BIT | PSR_F_BIT) - /* use fiq stack if we reenter this mode */ - subne sp, r7, #(4 * 3) - -fiq_from_usr_mode: - msr cpsr_c, #(SVC_MODE | PSR_I_BIT | PSR_F_BIT) - mov r2, sp - sub sp, r7, #12 - stmfd sp!, {r2, ip, lr} - /* call func(data,regs) */ - blx r3 - ldmfd sp, {r2, ip, lr} - mov sp, r2 - - /* restore/discard saved state */ - cmp r4, #USR_MODE - beq fiq_from_usr_mode_exit - - msr cpsr_c, r4 - ldr sp, [r7, #(4 * 13)] - ldr lr, [r7, #(4 * 14)] - msr spsr_cxsf, r5 - -fiq_from_usr_mode_exit: - msr cpsr_c, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT) - - ldmfd sp!, {r0-r7} - add sp, sp, #(7 * 4) - ldmfd sp!, {r11-r12, lr} -exit_fiq: - msr spsr_cxsf, r12 - add r10, #1 - movs pc, r11 - -nested_fiq: - orr r12, r12, #(PSR_F_BIT) - b exit_fiq - -fiq_glue_end: - -ENTRY(fiq_glue_setup) /* func, data, sp */ - mrs r3, cpsr - msr cpsr_c, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT) - movs r8, r0 - mov r9, r1 - mov sp, r2 - moveq r10, #0 - movne r10, #1 - msr cpsr_c, r3 - bx lr - diff --git a/arch/arm/mach-msm/fish_battery.c b/arch/arm/mach-msm/fish_battery.c deleted file mode 100644 index 19fbb91fe83ae6f43aa2927cd74389817c1e37f7..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/fish_battery.c +++ /dev/null @@ -1,145 +0,0 @@ -/* arch/arm/mach-msm/fish_battery.c - * - * Copyright (C) 2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - * based on: arch/arm/mach-msm/htc_battery.c - */ - -#include -#include -#include -#include -#include -#include - -static enum power_supply_property fish_battery_properties[] = { - POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_HEALTH, - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_TECHNOLOGY, - POWER_SUPPLY_PROP_CAPACITY, -}; - -static enum power_supply_property fish_power_properties[] = { - POWER_SUPPLY_PROP_ONLINE, -}; - -static char *supply_list[] = { - "battery", -}; - -static int fish_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val); - -static int fish_battery_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val); - -static struct power_supply fish_power_supplies[] = { - { - .name = "battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = fish_battery_properties, - .num_properties = ARRAY_SIZE(fish_battery_properties), - .get_property = fish_battery_get_property, - }, - { - .name = "ac", - .type = POWER_SUPPLY_TYPE_MAINS, - .supplied_to = supply_list, - .num_supplicants = ARRAY_SIZE(supply_list), - .properties = fish_power_properties, - .num_properties = ARRAY_SIZE(fish_power_properties), - .get_property = fish_power_get_property, - }, -}; - -static int fish_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - if (psy->type == POWER_SUPPLY_TYPE_MAINS) - val->intval = 1; - else - val->intval = 0; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int fish_battery_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - switch (psp) { - case POWER_SUPPLY_PROP_STATUS: - val->intval = POWER_SUPPLY_STATUS_FULL; - break; - case POWER_SUPPLY_PROP_HEALTH: - val->intval = POWER_SUPPLY_HEALTH_GOOD; - break; - case POWER_SUPPLY_PROP_PRESENT: - val->intval = 1; - break; - case POWER_SUPPLY_PROP_TECHNOLOGY: - val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; - break; - case POWER_SUPPLY_PROP_CAPACITY: - val->intval = 100; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int fish_battery_probe(struct platform_device *pdev) -{ - int i; - int rc; - - /* init power supplier framework */ - for (i = 0; i < ARRAY_SIZE(fish_power_supplies); i++) { - rc = power_supply_register(&pdev->dev, &fish_power_supplies[i]); - if (rc) - pr_err("%s: Failed to register power supply (%d)\n", - __func__, rc); - } - - return 0; -} - -static struct platform_driver fish_battery_driver = { - .probe = fish_battery_probe, - .driver = { - .name = "fish_battery", - .owner = THIS_MODULE, - }, -}; - -static int __init fish_battery_init(void) -{ - platform_driver_register(&fish_battery_driver); - return 0; -} - -module_init(fish_battery_init); -MODULE_DESCRIPTION("Qualcomm fish battery driver"); -MODULE_LICENSE("GPL"); - diff --git a/arch/arm/mach-msm/gpio.h b/arch/arm/mach-msm/gpio.h deleted file mode 100644 index 397be6e20030c17b0a2e739989a8e39e93b24321..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/gpio.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2008-2009, 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 _ARCH_ARM_MACH_MSM_GPIO_H_ -#define _ARCH_ARM_MACH_MSM_GPIO_H_ - -void msm_gpio_enter_sleep(int from_idle); -void msm_gpio_exit_sleep(void); - -/* Locate the GPIO_OUT register for the given GPIO and return its address - * and the bit position of the gpio's bit within the register. - * - * This function is used by gpiomux-v1 in order to support output transitions. - */ -void msm_gpio_find_out(const unsigned gpio, void __iomem **out, - unsigned *offset); - -#endif diff --git a/arch/arm/mach-msm/idle-v6.S b/arch/arm/mach-msm/idle-v6.S deleted file mode 100644 index 35db96c2257753080372e6515f953afd612bd3ec..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/idle-v6.S +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Idle processing for ARMv6-based Qualcomm SoCs. - * Work around bugs with SWFI. - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2007-2009, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include - -.extern write_to_strongly_ordered_memory - -ENTRY(msm_arch_idle) - mrs r2, cpsr /* save the CPSR state */ - cpsid iaf /* explictly disable I,A and F */ - -#if defined(CONFIG_ARCH_MSM7X27) - mov r0, #0 - mcr p15, 0, r0, c7, c10, 0 /* flush entire data cache */ - mcr p15, 0, r0, c7, c10, 4 /* dsb */ - stmfd sp!, {r2, lr} /* preserve r2, thus CPSR and LR */ - bl write_to_strongly_ordered_memory /* flush AXI bus buffer */ - ldmfd sp!, {r2, lr} - mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */ -#else - mrc p15, 0, r1, c1, c0, 0 /* read current CR */ - bic r0, r1, #(1 << 2) /* clear dcache bit */ - bic r0, r0, #(1 << 12) /* clear icache bit */ - mcr p15, 0, r0, c1, c0, 0 /* disable d/i cache */ - - mov r0, #0 - mcr p15, 0, r0, c7, c5, 0 /* invalidate icache and flush */ - /* branch target cache */ - mcr p15, 0, r0, c7, c14, 0 /* clean and invalidate dcache */ - - mcr p15, 0, r0, c7, c10, 4 /* dsb */ - mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */ - - mcr p15, 0, r1, c1, c0, 0 /* restore d/i cache */ - mcr p15, 0, r0, c7, c5, 4 /* isb */ -#endif - - msr cpsr_c, r2 /* restore the CPSR state */ - mov pc, lr - -ENTRY(msm_pm_collapse) - ldr r0, =saved_state - stmia r0!, {r4-r14} - - cpsid f - - mrc p15, 0, r1, c1, c0, 0 /* MMU control */ - mrc p15, 0, r2, c2, c0, 0 /* ttb */ - mrc p15, 0, r3, c3, c0, 0 /* dacr */ - mrc p15, 0, ip, c13, c0, 1 /* context ID */ - stmia r0!, {r1-r3, ip} -#if defined(CONFIG_OPROFILE) - mrc p15, 0, r1, c15, c12, 0 /* pmnc */ - mrc p15, 0, r2, c15, c12, 1 /* ccnt */ - mrc p15, 0, r3, c15, c12, 2 /* pmn0 */ - mrc p15, 0, ip, c15, c12, 3 /* pmn1 */ - stmia r0!, {r1-r3, ip} -#endif - mrc p15, 0, r1, c1, c0, 2 /* read CACR */ - stmia r0!, {r1} - - mrc p15, 0, r1, c1, c0, 0 /* read current CR */ - bic r0, r1, #(1 << 2) /* clear dcache bit */ - bic r0, r0, #(1 << 12) /* clear icache bit */ - mcr p15, 0, r0, c1, c0, 0 /* disable d/i cache */ - - mov r0, #0 - mcr p15, 0, r0, c7, c5, 0 /* invalidate icache and flush */ - /* branch target cache */ - mcr p15, 0, r0, c7, c14, 0 /* clean and invalidate dcache */ - - mcr p15, 0, r0, c7, c10, 4 /* dsb */ - mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */ - - mcr p15, 0, r1, c1, c0, 0 /* restore d/i cache */ - mcr p15, 0, r0, c7, c5, 4 /* isb */ - - cpsie f - - ldr r0, =saved_state /* restore registers */ - ldmfd r0, {r4-r14} - mov r0, #0 /* return power collapse failed */ - mov pc, lr - -ENTRY(msm_pm_collapse_exit) -#if 0 /* serial debug */ - mov r0, #0x80000016 - mcr p15, 0, r0, c15, c2, 4 - mov r0, #0xA9000000 - add r0, r0, #0x00A00000 /* UART1 */ - /*add r0, r0, #0x00C00000*/ /* UART3 */ - mov r1, #'A' - str r1, [r0, #0x00C] -#endif - ldr r1, =saved_state_end - ldr r2, =msm_pm_collapse_exit - adr r3, msm_pm_collapse_exit - add r1, r1, r3 - sub r1, r1, r2 - - ldmdb r1!, {r2} - mcr p15, 0, r2, c1, c0, 2 /* restore CACR */ -#if defined(CONFIG_OPROFILE) - ldmdb r1!, {r2-r5} - mcr p15, 0, r3, c15, c12, 1 /* ccnt */ - mcr p15, 0, r4, c15, c12, 2 /* pmn0 */ - mcr p15, 0, r5, c15, c12, 3 /* pmn1 */ - mcr p15, 0, r2, c15, c12, 0 /* pmnc */ -#endif - ldmdb r1!, {r2-r5} - mcr p15, 0, r4, c3, c0, 0 /* dacr */ - mcr p15, 0, r3, c2, c0, 0 /* ttb */ - mcr p15, 0, r5, c13, c0, 1 /* context ID */ - mov r0, #0 - mcr p15, 0, r0, c7, c5, 4 /* isb */ - ldmdb r1!, {r4-r14} - - /* Add 1:1 map in the PMD to allow smooth switch when turning on MMU */ - and r3, r3, #~0x7F /* mask off lower 7 bits of TTB */ - adr r0, msm_pm_mapped_pa /* get address of the mapped instr */ - lsr r1, r0, #20 /* get the addr range of addr in MB */ - lsl r1, r1, #2 /* multiply by 4 to get to the pg index */ - add r3, r3, r1 /* pgd + pgd_index(addr) */ - ldr r1, [r3] /* save current entry to r1 */ - lsr r0, #20 /* align current addr to 1MB boundary */ - lsl r0, #20 - /* Create new entry for this 1MB page */ - orr r0, r0, #0x400 /* PMD_SECT_AP_WRITE */ - orr r0, r0, #0x2 /* PMD_TYPE_SECT|PMD_DOMAIN(DOMAIN_KERNEL) */ - str r0, [r3] /* put new entry into the MMU table */ - mov r0, #0 - mcr p15, 0, r0, c7, c10, 4 /* dsb */ - mcr p15, 0, r2, c1, c0, 0 /* MMU control */ - mcr p15, 0, r0, c7, c5, 4 /* isb */ -msm_pm_mapped_pa: - /* Switch to virtual */ - adr r2, msm_pm_pa_to_va - ldr r0, =msm_pm_pa_to_va - mov pc, r0 -msm_pm_pa_to_va: - sub r0, r0, r2 - /* Restore r1 in MMU table */ - add r3, r3, r0 - str r1, [r3] - - mov r0, #0 - mcr p15, 0, r0, c7, c10, 0 /* flush entire data cache */ - mcr p15, 0, r0, c7, c10, 4 /* dsb */ - mcr p15, 0, r0, c7, c5, 4 /* isb */ - mcr p15, 0, r0, c8, c7, 0 /* invalidate entire unified TLB */ - mcr p15, 0, r0, c7, c5, 6 /* invalidate entire branch target - * cache */ - mcr p15, 0, r0, c7, c7, 0 /* invalidate both data and instruction - * cache */ - mcr p15, 0, r0, c7, c10, 4 /* dsb */ - mcr p15, 0, r0, c7, c5, 4 /* isb */ - - mov r0, #1 - mov pc, lr - nop - nop - nop - nop - nop -1: b 1b - - - .data - -saved_state: - .space 4 * 11 /* r4-14 */ - .space 4 * 4 /* cp15 - MMU control, ttb, dacr, context ID */ -#if defined(CONFIG_OPROFILE) - .space 4 * 4 /* more cp15 - pmnc, ccnt, pmn0, pmn1 */ -#endif - .space 4 /* cacr */ -saved_state_end: - diff --git a/arch/arm/mach-msm/idle_stats_device.c b/arch/arm/mach-msm/idle_stats_device.c deleted file mode 100644 index 54b8382d15831c54864c14d6cd427cf039b75cb6..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/idle_stats_device.c +++ /dev/null @@ -1,378 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include -#include -#include -#include -#include -#include - -DEFINE_MUTEX(device_list_lock); -LIST_HEAD(device_list); - -static ktime_t us_to_ktime(__u32 us) -{ - return ns_to_ktime((u64)us * NSEC_PER_USEC); -} - -static struct msm_idle_stats_device *_device_from_minor(unsigned int minor) -{ - struct msm_idle_stats_device *device, *ret = NULL; - - - mutex_lock(&device_list_lock); - list_for_each_entry(device, &device_list, list) { - if (minor == device->miscdev.minor) { - ret = device; - break; - } - } - mutex_unlock(&device_list_lock); - return ret; -} - -void msm_idle_stats_update_event(struct msm_idle_stats_device *device, - __u32 event) -{ - __u32 wake_up = !device->stats->event; - - device->stats->event |= event; - if (wake_up) - wake_up_interruptible(&device->wait); -} -EXPORT_SYMBOL(msm_idle_stats_update_event); - -static enum hrtimer_restart msm_idle_stats_busy_timer(struct hrtimer *timer) -{ - struct msm_idle_stats_device *device = - container_of(timer, struct msm_idle_stats_device, busy_timer); - - - /* This is the only case that the event is modified without a device - * lock. However, since the timer is cancelled in the other cases we are - * assured that we have exclusive access to the event at this time. - */ - hrtimer_set_expires(&device->busy_timer, us_to_ktime(0)); - msm_idle_stats_update_event(device, - MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED); - return HRTIMER_NORESTART; -} - -static void start_busy_timer(struct msm_idle_stats_device *device, - ktime_t relative_time) -{ - hrtimer_cancel(&device->busy_timer); - hrtimer_set_expires(&device->busy_timer, us_to_ktime(0)); - if (!((device->stats->event & - MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED) || - (device->stats->event & MSM_IDLE_STATS_EVENT_COLLECTION_FULL))) { - if (ktime_to_us(relative_time) > 0) { - hrtimer_start(&device->busy_timer, - relative_time, - HRTIMER_MODE_REL); - } - } -} - -static unsigned int msm_idle_stats_device_poll(struct file *file, - poll_table *wait) -{ - struct msm_idle_stats_device *device = file->private_data; - unsigned int mask = 0; - - poll_wait(file, &device->wait, wait); - if (device->stats->event) - mask = POLLIN | POLLRDNORM; - return mask; -} - -static void msm_idle_stats_add_sample(struct msm_idle_stats_device *device, - struct msm_idle_pulse *pulse) -{ - hrtimer_cancel(&device->busy_timer); - hrtimer_set_expires(&device->busy_timer, us_to_ktime(0)); - if (device->stats->nr_collected >= MSM_IDLE_STATS_NR_MAX_INTERVALS) { - pr_warning("idle_stats_device: Overwriting samples\n"); - device->stats->nr_collected = 0; - } - device->stats->pulse_chain[device->stats->nr_collected] = *pulse; - device->stats->nr_collected++; - - if (device->stats->nr_collected == device->max_samples) { - msm_idle_stats_update_event(device, - MSM_IDLE_STATS_EVENT_COLLECTION_FULL); - } else if (device->stats->nr_collected == - ((device->max_samples * 3) / 4)) { - msm_idle_stats_update_event(device, - MSM_IDLE_STATS_EVENT_COLLECTION_NEARLY_FULL); - } -} - -static long ioctl_read_stats(struct msm_idle_stats_device *device, - unsigned long arg) -{ - int remaining; - int requested; - struct msm_idle_pulse pulse; - struct msm_idle_read_stats *stats; - __s64 remaining_time = - ktime_to_us(hrtimer_get_remaining(&device->busy_timer)); - - device->get_sample(device, &pulse); - spin_lock(&device->lock); - hrtimer_cancel(&device->busy_timer); - stats = device->stats; - if (stats == &device->stats_vector[0]) - device->stats = &device->stats_vector[1]; - else - device->stats = &device->stats_vector[0]; - device->stats->event = 0; - device->stats->nr_collected = 0; - spin_unlock(&device->lock); - if (stats->nr_collected >= device->max_samples) { - stats->nr_collected = device->max_samples; - } else { - stats->pulse_chain[stats->nr_collected] = pulse; - stats->nr_collected++; - if (stats->nr_collected == device->max_samples) - stats->event |= MSM_IDLE_STATS_EVENT_COLLECTION_FULL; - else if (stats->nr_collected == - ((device->max_samples * 3) / 4)) - stats->event |= - MSM_IDLE_STATS_EVENT_COLLECTION_NEARLY_FULL; - } - if (remaining_time < 0) { - stats->busy_timer_remaining = 0; - } else { - stats->busy_timer_remaining = remaining_time; - if ((__s64)stats->busy_timer_remaining != remaining_time) - stats->busy_timer_remaining = -1; - } - stats->return_timestamp = ktime_to_us(ktime_get()); - requested = - ((sizeof(*stats) - sizeof(stats->pulse_chain)) + - (sizeof(stats->pulse_chain[0]) * stats->nr_collected)); - remaining = copy_to_user((void __user *)arg, stats, requested); - if (remaining > 0) - return -EFAULT; - - return 0; -} - -static long ioctl_write_stats(struct msm_idle_stats_device *device, - unsigned long arg) -{ - struct msm_idle_write_stats stats; - int remaining; - int ret = 0; - - remaining = copy_from_user(&stats, (void __user *) arg, sizeof(stats)); - if (remaining > 0) { - ret = -EFAULT; - } else { - spin_lock(&device->lock); - device->busy_timer_interval = us_to_ktime(stats.next_busy_timer); - if (ktime_to_us(device->idle_start) == 0) - start_busy_timer(device, us_to_ktime(stats.busy_timer)); - if ((stats.max_samples > 0) && - (stats.max_samples <= MSM_IDLE_STATS_NR_MAX_INTERVALS)) - device->max_samples = stats.max_samples; - spin_unlock(&device->lock); - } - return ret; -} - -void msm_idle_stats_prepare_idle_start(struct msm_idle_stats_device *device) -{ - spin_lock(&device->lock); - hrtimer_cancel(&device->busy_timer); - spin_unlock(&device->lock); -} -EXPORT_SYMBOL(msm_idle_stats_prepare_idle_start); - -void msm_idle_stats_abort_idle_start(struct msm_idle_stats_device *device) -{ - spin_lock(&device->lock); - if (ktime_to_us(hrtimer_get_expires(&device->busy_timer)) > 0) - hrtimer_restart(&device->busy_timer); - spin_unlock(&device->lock); -} -EXPORT_SYMBOL(msm_idle_stats_abort_idle_start); - -void msm_idle_stats_idle_start(struct msm_idle_stats_device *device) -{ - spin_lock(&device->lock); - hrtimer_cancel(&device->busy_timer); - device->idle_start = ktime_get(); - if (ktime_to_us(hrtimer_get_expires(&device->busy_timer)) > 0) { - device->remaining_time = - hrtimer_get_remaining(&device->busy_timer); - if (ktime_to_us(device->remaining_time) <= 0) - device->remaining_time = us_to_ktime(0); - } else { - device->remaining_time = us_to_ktime(0); - } - spin_unlock(&device->lock); -} -EXPORT_SYMBOL(msm_idle_stats_idle_start); - -void msm_idle_stats_idle_end(struct msm_idle_stats_device *device, - struct msm_idle_pulse *pulse) -{ - int tmp; - u32 idle_time = 0; - spin_lock(&device->lock); - if (ktime_to_us(device->idle_start) != 0) { - idle_time = ktime_to_us(ktime_get()) - - ktime_to_us(device->idle_start); - device->idle_start = us_to_ktime(0); - msm_idle_stats_add_sample(device, pulse); - if (device->stats->event & - MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED) { - device->stats->event &= - ~MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED; - msm_idle_stats_update_event(device, - MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED_RESET); - } else if (ktime_to_us(device->busy_timer_interval) > 0) { - ktime_t busy_timer = device->busy_timer_interval; - /* if it is serialized, it would be full busy, - * checking 80% - */ - if ((pulse->wait_interval*5 >= idle_time*4) && - (ktime_to_us(device->remaining_time) > 0) && - (ktime_to_us(device->remaining_time) < - ktime_to_us(busy_timer))) - busy_timer = device->remaining_time; - start_busy_timer(device, busy_timer); - /* If previous busy interval exceeds the current submit, - * raise a busy timer expired event intentionally. - */ - tmp = device->stats->nr_collected - 1; - if (tmp > 0) { - if ((device->stats->pulse_chain[tmp - 1].busy_start_time - + device->stats->pulse_chain[tmp - 1].busy_interval) > - device->stats->pulse_chain[tmp].busy_start_time) - msm_idle_stats_update_event(device, - MSM_IDLE_STATS_EVENT_BUSY_TIMER_EXPIRED); - } - } - } - spin_unlock(&device->lock); -} -EXPORT_SYMBOL(msm_idle_stats_idle_end); - -static long msm_idle_stats_device_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct msm_idle_stats_device *device = file->private_data; - int ret; - - switch (cmd) { - case MSM_IDLE_STATS_IOC_READ_STATS: - ret = ioctl_read_stats(device, arg); - break; - case MSM_IDLE_STATS_IOC_WRITE_STATS: - ret = ioctl_write_stats(device, arg); - break; - default: - ret = -EINVAL; - } - - return ret; -} - -static int msm_idle_stats_device_release - (struct inode *inode, struct file *filep) -{ - return 0; -} - -static int msm_idle_stats_device_open(struct inode *inode, struct file *filep) -{ - struct msm_idle_stats_device *device; - - - device = _device_from_minor(iminor(inode)); - - if (device == NULL) - return -EPERM; - - filep->private_data = device; - return 0; -} - -static const struct file_operations msm_idle_stats_fops = { - .open = msm_idle_stats_device_open, - .release = msm_idle_stats_device_release, - .unlocked_ioctl = msm_idle_stats_device_ioctl, - .poll = msm_idle_stats_device_poll, -}; - -int msm_idle_stats_register_device(struct msm_idle_stats_device *device) -{ - int ret = -ENOMEM; - - spin_lock_init(&device->lock); - init_waitqueue_head(&device->wait); - hrtimer_init(&device->busy_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - device->busy_timer.function = msm_idle_stats_busy_timer; - - device->stats_vector[0].event = 0; - device->stats_vector[0].nr_collected = 0; - device->stats_vector[1].event = 0; - device->stats_vector[1].nr_collected = 0; - device->stats = &device->stats_vector[0]; - device->busy_timer_interval = us_to_ktime(0); - device->max_samples = MSM_IDLE_STATS_NR_MAX_INTERVALS; - - mutex_lock(&device_list_lock); - list_add(&device->list, &device_list); - mutex_unlock(&device_list_lock); - - device->miscdev.minor = MISC_DYNAMIC_MINOR; - device->miscdev.name = device->name; - device->miscdev.fops = &msm_idle_stats_fops; - - ret = misc_register(&device->miscdev); - - if (ret) - goto err_list; - - return ret; - -err_list: - mutex_lock(&device_list_lock); - list_del(&device->list); - mutex_unlock(&device_list_lock); - return ret; -} -EXPORT_SYMBOL(msm_idle_stats_register_device); - -int msm_idle_stats_deregister_device(struct msm_idle_stats_device *device) -{ - if (device == NULL) - return 0; - - mutex_lock(&device_list_lock); - spin_lock(&device->lock); - hrtimer_cancel(&device->busy_timer); - list_del(&device->list); - spin_unlock(&device->lock); - mutex_unlock(&device_list_lock); - - return misc_deregister(&device->miscdev); -} -EXPORT_SYMBOL(msm_idle_stats_deregister_device); diff --git a/arch/arm/mach-msm/include/mach/audio_dma_msm8k.h b/arch/arm/mach-msm/include/mach/audio_dma_msm8k.h deleted file mode 100644 index bbe49617706e40e27b674fd2afaa3521fbc79f5e..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/audio_dma_msm8k.h +++ /dev/null @@ -1,221 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __ASM_ARCH_MSM_AUDIO_DMA_H - - -#define BANK_OFFSET 0x1000 - -#define LPAIF_PCM_CTL_OFFSET 0x0000 - #define CTRL_DATA_OE (1 << 18) - #define RATE_8KHZ (0 << 15) - #define RATE_16KHZ (1 << 15) - #define RATE_32KHZ (2 << 15) - #define RATE_64KHZ (4 << 15) - #define RATE_128KHZ (8 << 15) - #define RATE_256KHZ (9 << 15) - #define PCM_LOOPBACK (1 << 14) - #define SYNC_SRC_INT (0 << 13) - #define SYNC_SRC_EXT (1 << 13) - #define PCM_MODE (0 << 12) - #define AUX_MODE (1 << 12) - #define RPCM_WIDTH_8 (0 << 11) - #define RPCM_WIDTH_16 (1 << 11) - #define TPCM_WIDTH_8 (0 << 10) - #define TPCM_WIDTH_16 (1 << 10) - #define RPCM_SLOT(x) (x << 5) - #define TPCM_SLOT(x) x - -#define LPAIF_I2S_CTL_OFFSET(x) (0x0004 + (0x4 * x)) - #define I2S_LOOPBACK (1 << 15) - #define SPK_EN_DISABLE (0 << 14) - #define SPK_EN_ENABLE (1 << 14) - #define SPK_MODE_NONE (0 << 10) - #define SPK_MODE_SD0 (1 << 10) - #define SPK_MODE_SD1 (2 << 10) - #define SPK_MODE_SD2 (3 << 10) - #define SPK_MODE_SD3 (4 << 10) - #define SPK_MODE_QUAD01 (5 << 10) - #define SPK_MODE_QUAD23 (6 << 10) - #define SPK_MODE_6CH (7 << 10) - #define SPK_MODE_8CH (8 << 10) - #define SPK_MONO_STEREO (0 << 9) - #define SPK_MONO_MONO (1 << 9) - #define MIC_EN_DISABLE (0 << 8) - #define MIC_EN_ENABLE (1 << 8) - #define MIC_MODE_NONE (0 << 4) - #define MIC_MODE_SD0 (1 << 4) - #define MIC_MODE_SD1 (2 << 4) - #define MIC_MODE_SD2 (3 << 4) - #define MIC_MODE_SD3 (4 << 4) - #define MIC_MODE_QUAD01 (5 << 4) - #define MIC_MODE_QUAD23 (6 << 4) - #define MIC_MODE_6CH (7 << 4) - #define MIC_MODE_8CH (8 << 4) - #define MIC_MONO_STEREO (0 << 3) - #define MIC_MONO_MONO (1 << 3) - #define WS_SRC_INT (0 << 2) - #define WS_SRC_EXT (1 << 2) - #define BIT_WIDTH_16 (0 << 0) - #define BIT_WIDTH_24 (1 << 0) - #define BIT_WIDTH_32 (2 << 0) - -#define LPAIF_DMIC_CTL 0x0018 - #define DMIC_EN_DISABLE (0 << 4) - #define DMIC_EN_ENABLE (1 << 4) - #define DMIC_MODE_NONE (0 << 1) - #define DMIC_MODE_LEFT0 (1 << 1) - #define DMIC_MODE_RIGHT0 (2 << 1) - #define DMIC_MODE_LEFT1 (3 << 1) - #define DMIC_MODE_RIGHT1 (4 << 1) - #define DMIC_MODE_STEREO0 (5 << 1) - #define DMIC_MODE_STEREO1 (6 << 1) - #define DMIC_MODE_QUAD (7 << 1) - #define BIT_WIDTH_DMIC_16 (0 << 0) - #define BIT_WIDTH_DMIC_20 (1 << 0) - -#define LPAIF_DMIC_VOL_CTL(x) (0x001c + (0x4 * x)) - #define UPDATE_STATUS_COMP (0 << 20) - #define UPDATE_STATUS_PEND (1 << 20) /* Timeout or Zero Crossing */ - #define UPDATE_GAIN_NO (0 << 19) - #define UPDATE_GAIN_YES (1 << 19) - #define TX_HPF_BP_DC_BLOCK (0 << 18) - #define TX_HPF_BP_BYPASS_DC_BLOCK (1 << 18) - #define DMIC_GAIN_BP_GAIN (0 << 17) - #define DMIC_GAIN_BP_BYPASS_GAIN (1 << 17) - #define MUTE_EN_NORMAL (0 << 16) - #define MUTE_EN_MUTE (1 << 16) - #define TIMEOUT_VAL(x) (x << 8) - #define DMIC_GAIN_MUL(x) (x << 0) - -#define LPAIF_SPARE 0x0030 - -#define LPAIF_WRDMA_LPBK_MIX 0x1000 - #define WRDMA_LPBK_MIX_BLOCK(x) (0 << (x - 5)) - #define WRDMA_LPBK_MIX_ALLOW(x) (1 << (x - 5)) - -#define LPAIF_DEBUG_CTL 0x1004 - #define TESTMODE_OFF (0 << 4) - #define TESTMODE_ON (1 << 4) - #define TESTSEL_CH0 (0 << 0) - #define TESTSEL_CH1 (1 << 0) - #define TESTSEL_CH2 (2 << 0) - #define TESTSEL_CH3 (3 << 0) - #define TESTSEL_CH4 (4 << 0) - #define TESTSEL_CH5 (5 << 0) - #define TESTSEL_CH6 (6 << 0) - #define TESTSEL_CH7 (7 << 0) - #define TESTSEL_CH8 (8 << 0) - #define TESTSEL_MIXER (9 << 0) - #define TESTSEL_CODEC_SPKR (10 << 0) - #define TESTSEL_CODEC_MIC (11 << 0) - #define TESTSEL_MI2S (12 << 0) - #define TESTSEL_SEC_SPKR (13 << 0) - #define TESTSEL_SEC_MIC (14 << 0) - #define TESTSEL_DMIC (15 << 0) - -#define LPAIF_MIXER_CTL 0x2000 - #define OVR_DETECTED_NO (0 << 10) - #define OVR_DETECTED_YES (1 << 10) - #define OVR_CLR_NO (0 << 9) - #define OVR_CLR_YES (1 << 9) - #define SAT_EN_DISABLE (0 << 8) - #define SAT_EN_ENABLE (1 << 8) - #define MIXER_BIT_WIDTH_8 (0 << 6) - #define MIXER_BIT_WIDTH_16 (1 << 6) - #define MIXER_BIT_WIDTH_24 (2 << 6) - #define MIXER_BIT_WIDTH_32 (3 << 6) - #define PORT1_CH_NONE (0 << 3) - #define PORT1_CH_0 (1 << 3) - #define PORT1_CH_1 (2 << 3) - #define PORT1_CH_2 (3 << 3) - #define PORT1_CH_3 (4 << 3) - #define PORT1_CH_4 (5 << 3) - #define PORT0_CH_NONE (0 << 0) - #define PORT0_CH_0 (1 << 0) - #define PORT0_CH_1 (2 << 0) - #define PORT0_CH_2 (3 << 0) - #define PORT0_CH_3 (4 << 0) - #define PORT0_CH_4 (5 << 0) - -#define DMA_IRQ_BASE 0x3000 -#define DMA_IRQ_INDEX(x) (BANK_OFFSET * x) -#define DMA_IRQ_ADDR(irq, addr) (DMA_IRQ_BASE \ - + DMA_IRQ_INDEX(irq) + addr) - -/* Audio Interrupt registers for DMA channel confuguration */ -#define LPAIF_IRQ_EN(x) DMA_IRQ_ADDR(x, 0x00) -#define LPAIF_IRQ_STAT(x) DMA_IRQ_ADDR(x, 0x04) -#define LPAIF_IRQ_RAW_STAT(x) DMA_IRQ_ADDR(x, 0x08) -#define LPAIF_IRQ_CLEAR(x) DMA_IRQ_ADDR(x, 0x0c) -#define LPAIF_IRQ_FORCE(x) DMA_IRQ_ADDR(x, 0x10) - #define PER_CH(x) (1 << (3 * x)) - #define UNDER_CH(x) (2 << (3 * x)) - #define ERR_CH(x) (4 << (3 * x)) - -/* Audio DMA registers for DMA channel confuguration */ -#define DMA_CH_CTL_BASE 0x6000 -#define DMA_CH_INDEX(ch) (BANK_OFFSET * ch) - -#define DMA_CTRL_ADDR(ch, addr) (DMA_CH_CTL_BASE \ - + (DMA_CH_INDEX(ch) + addr)) - -#define LPAIF_DMA_CTL(x) DMA_CTRL_ADDR(x, 0x00) - #define BURST_EN (1 << 11) - #define WPSCNT_ONE (0 << 8) - #define WPSCNT_TWO (1 << 8) - #define WPSCNT_THREE (2 << 8) - #define WPSCNT_FOUR (3 << 8) - #define WPSCNT_SIX (5 << 8) - #define WPSCNT_EIGHT (7 << 8) - #define AUDIO_INTF_NONE (0 << 4) - #define AUDIO_INTF_CODEC (1 << 4) - #define AUDIO_INTF_PCM (2 << 4) - #define AUDIO_INTF_SEC_I2S (3 << 4) - #define AUDIO_INTF_MI2S (4 << 4) - #define AUDIO_INTF_HDMI (5 << 4) - #define AUDIO_INTF_MIXOUT (6 << 4) - #define AUDIO_INTF_LOOPBACK1 (7 << 4) - #define AUDIO_INTF_LOOPBACK2 (8 << 4) - #define FIFO_WATERMRK(x) ((x & 0x7) << 1) - #define ENABLE (1 << 0) - -#define LPAIF_DMA_BASE(x) DMA_CTRL_ADDR(x, 0x04) - #define BASE_ADDR (0xFFFFFFFF << 4) - -#define LPAIF_DMA_BUFF_LEN(x) DMA_CTRL_ADDR(x, 0x08) -#define LPAIF_DMA_CURR_ADDR(x) DMA_CTRL_ADDR(x, 0x0c) -#define LPAIF_DMA_PER_LEN(x) DMA_CTRL_ADDR(x, 0x10) -#define LPAIF_DMA_PER_CNT(x) DMA_CTRL_ADDR(x, 0x14) -#define LPAIF_DMA_FRM(x) DMA_CTRL_ADDR(x, 0x18) -#define LPAIF_DMA_FRMCLR(x) DMA_CTRL_ADDR(x, 0x1c) -#define LPAIF_DMA_SET_BUFF_CNT(x) DMA_CTRL_ADDR(x, 0x20) -#define LPAIF_DMA_SET_PER_CNT(x) DMA_CTRL_ADDR(x, 0x24) - -#define LPAIF_DMA_PER_CNT_PER_CNT_MASK 0x000FFFFF -#define LPAIF_DMA_PER_CNT_PER_CNT_SHIFT 0 -#define LPAIF_DMA_PER_CNT_FIFO_WORDCNT_MASK 0x00F00000 -#define LPAIF_DMA_PER_CNT_FIFO_WORDCNT_SHIFT 20 - -/* channel assignments */ - -#define DMA_CH_0 0 -#define DMA_CH_1 1 -#define DMA_CH_2 2 -#define DMA_CH_3 3 -#define DMA_CH_4 4 -#define DMA_CH_5 5 -#define DMA_CH_6 6 -#define DMA_CH_7 7 - -#endif diff --git a/arch/arm/mach-msm/include/mach/barriers.h b/arch/arm/mach-msm/include/mach/barriers.h deleted file mode 100644 index 89734addc36de4e3acd1f50a7fc74d4dd08bba97..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/barriers.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (c) 2010-2011, 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 - -#define mb() do \ - { \ - dsb();\ - outer_sync(); \ - write_to_strongly_ordered_memory(); \ - } while (0) -#define rmb() do { dmb(); write_to_strongly_ordered_memory(); } while (0) -#define wmb() mb() diff --git a/arch/arm/mach-msm/include/mach/board-msm8660.h b/arch/arm/mach-msm/include/mach/board-msm8660.h deleted file mode 100644 index e1e1b173bce321999625fc7d352025f0a42a8ee4..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/board-msm8660.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2011, 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 __ARCH_ARM_MACH_MSM_BOARD_MSM8660_H -#define __ARCH_ARM_MACH_MSM_BOARD_MSM8660_H - -#include -#include -#include - -/* Macros assume PMIC GPIOs start at 0 */ -#define PM8058_GPIO_BASE NR_MSM_GPIOS -#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_GPIO_BASE) -#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - PM8058_GPIO_BASE) -#define PM8058_MPP_BASE (PM8058_GPIO_BASE + PM8058_GPIOS) -#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE) -#define PM8058_MPP_SYS_TO_PM(sys_gpio) (sys_gpio - PM8058_MPP_BASE) -#define PM8058_IRQ_BASE (NR_MSM_IRQS + NR_GPIO_IRQS) - -#define PM8901_MPP_BASE (PM8058_GPIO_BASE + \ - PM8058_GPIOS + PM8058_MPPS) -#define PM8901_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8901_MPP_BASE) -#define PM8901_MPP_SYS_TO_PM(sys_gpio) (sys_gpio - PM901_MPP_BASE) -#define PM8901_IRQ_BASE (PM8058_IRQ_BASE + \ - NR_PMIC8058_IRQS) - -#ifdef CONFIG_MSM_CAMERA_V4L2 -extern struct msm_camera_board_info msm8x60_camera_board_info; -void msm8x60_init_cam(void); -#endif - -#endif diff --git a/arch/arm/mach-msm/include/mach/dal_axi.h b/arch/arm/mach-msm/include/mach/dal_axi.h deleted file mode 100644 index 94310608a54e1400d71d6fe6b04dab9c433130e5..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/dal_axi.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (c) 2010-2011, 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 _DAL_AXI_H -#define _DAL_AXI_H - -#include - -int set_grp2d_async(void); -int set_grp3d_async(void); -int set_grp_xbar_async(void); -int axi_allocate(int mode); -int axi_free(int mode); -#define AXI_FLOW_VIEWFINDER_HI 243 -#endif /* _DAL_AXI_H */ diff --git a/arch/arm/mach-msm/include/mach/dma-fsm9xxx.h b/arch/arm/mach-msm/include/mach/dma-fsm9xxx.h deleted file mode 100644 index c8c6cdff770ee4b5c0e7ae03f2388251a86f7924..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/dma-fsm9xxx.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2011, 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 __ASM_ARCH_MSM_DMA_FSM9XXX_H -#define __ASM_ARCH_MSM_DMA_FSM9XXX_H - -/* DMA channels allocated to Scorpion */ -#define DMOV_GP_CHAN 4 -#define DMOV_CE1_IN_CHAN 5 -#define DMOV_CE1_OUT_CHAN 6 -#define DMOV_NAND_CHAN 7 -#define DMOV_SDC1_CHAN 8 -#define DMOV_GP2_CHAN 10 -#define DMOV_CE2_IN_CHAN 12 -#define DMOV_CE2_OUT_CHAN 13 -#define DMOV_CE3_IN_CHAN 14 -#define DMOV_CE3_OUT_CHAN 15 - -/* CRCIs */ -#define DMOV_CE1_IN_CRCI 1 -#define DMOV_CE1_OUT_CRCI 2 -#define DMOV_CE1_HASH_CRCI 3 - -#define DMOV_NAND_CRCI_DATA 4 -#define DMOV_NAND_CRCI_CMD 5 - -#define DMOV_SDC1_CRCI 6 - -#define DMOV_HSUART_TX_CRCI 7 -#define DMOV_HSUART_RX_CRCI 8 - -#define DMOV_CE2_IN_CRCI 9 -#define DMOV_CE2_OUT_CRCI 10 -#define DMOV_CE2_HASH_CRCI 11 - -#define DMOV_CE3_IN_CRCI 12 -#define DMOV_CE3_OUT_CRCI 13 -#define DMOV_CE3_HASH_DONE_CRCI 14 - -/* Following CRCIs are not defined in FSM9XXX, but these are added to keep - * the existing SDCC host controller driver compatible with FSM9XXX. - */ -#define DMOV_SDC2_CRCI DMOV_SDC1_CRCI -#define DMOV_SDC3_CRCI DMOV_SDC1_CRCI -#define DMOV_SDC4_CRCI DMOV_SDC1_CRCI - -#endif /* __ASM_ARCH_MSM_DMA_FSM9XXX_H */ diff --git a/arch/arm/mach-msm/include/mach/dma.h b/arch/arm/mach-msm/include/mach/dma.h index 0f27f883084dd5341a4bb2692a698689accdc870..31dde30d8582ee3bd97571e48e45cc5e5db8ca4e 100644 --- a/arch/arm/mach-msm/include/mach/dma.h +++ b/arch/arm/mach-msm/include/mach/dma.h @@ -1,7 +1,7 @@ /* linux/include/asm-arm/arch-msm/dma.h * * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved. + * Copyright (c) 2008-2013, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -170,36 +170,6 @@ int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr); #define DMOV_HSUART2_RX_CHAN 8 #define DMOV_HSUART2_RX_CRCI 14 -#elif defined(CONFIG_ARCH_MSM8960) -#define DMOV_GP_CHAN 9 - -#define DMOV_CE_IN_CHAN 0 -#define DMOV_CE_IN_CRCI 2 - -#define DMOV_CE_OUT_CHAN 1 -#define DMOV_CE_OUT_CRCI 3 - -#define DMOV_TSIF_CHAN 2 -#define DMOV_TSIF_CRCI 11 - -#define DMOV_HSUART_GSBI6_TX_CHAN 7 -#define DMOV_HSUART_GSBI6_TX_CRCI 6 - -#define DMOV_HSUART_GSBI6_RX_CHAN 8 -#define DMOV_HSUART_GSBI6_RX_CRCI 11 - -#define DMOV_HSUART_GSBI8_TX_CHAN 7 -#define DMOV_HSUART_GSBI8_TX_CRCI 10 - -#define DMOV_HSUART_GSBI8_RX_CHAN 8 -#define DMOV_HSUART_GSBI8_RX_CRCI 9 - -#define DMOV_HSUART_GSBI9_TX_CHAN 4 -#define DMOV_HSUART_GSBI9_TX_CRCI 13 - -#define DMOV_HSUART_GSBI9_RX_CHAN 3 -#define DMOV_HSUART_GSBI9_RX_CRCI 12 - #elif defined(CONFIG_ARCH_MSM9615) #define DMOV_GP_CHAN 4 diff --git a/arch/arm/mach-msm/include/mach/fiq.h b/arch/arm/mach-msm/include/mach/fiq.h deleted file mode 100644 index 29a3ba1f33f3ecbe9c7c7bb38cd4999cf9e1c87e..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/fiq.h +++ /dev/null @@ -1,33 +0,0 @@ -/* linux/include/asm-arm/arch-msm/irqs.h - * - * Copyright (C) 2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __ASM_ARCH_MSM_FIQ_H -#define __ASM_ARCH_MSM_FIQ_H - -/* cause an interrupt to be an FIQ instead of a regular IRQ */ -void msm_fiq_select(int number); -void msm_fiq_unselect(int number); - -/* enable/disable an interrupt that is an FIQ (not safe from FIQ context) */ -void msm_fiq_enable(int number); -void msm_fiq_disable(int number); - -/* install an FIQ handler */ -int msm_fiq_set_handler(void (*func)(void *data, void *regs), void *data); - -/* cause an edge triggered interrupt to fire (safe from FIQ context */ -void msm_trigger_irq(int number); - -#endif diff --git a/arch/arm/mach-msm/include/mach/htc_35mm_jack.h b/arch/arm/mach-msm/include/mach/htc_35mm_jack.h deleted file mode 100644 index 5ce1e2a1e47804659b9b841a736c57bb42d14438..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/htc_35mm_jack.h +++ /dev/null @@ -1,31 +0,0 @@ -/* arch/arm/mach-msm/include/mach/htc_35mm_jack.h - * - * Copyright (C) 2009 HTC, Inc. - * Author: Arec Kao - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 HTC_35MM_REMOTE_H -#define HTC_35MM_REMOTE_H - -/* Driver interfaces */ -int htc_35mm_jack_plug_event(int insert, int *hpin_stable); -int htc_35mm_key_event(int key, int *hpin_stable); - -/* Platform Specific Callbacks */ -struct h35mm_platform_data { - int (*plug_event_enable)(void); - int (*headset_has_mic)(void); - int (*key_event_enable)(void); - int (*key_event_disable)(void); -}; -#endif diff --git a/arch/arm/mach-msm/include/mach/htc_acoustic_qsd.h b/arch/arm/mach-msm/include/mach/htc_acoustic_qsd.h deleted file mode 100644 index 2139bf9f903a5601ee0b82bb2ad5b3127b6e0530..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/htc_acoustic_qsd.h +++ /dev/null @@ -1,29 +0,0 @@ -/* include/asm/mach-msm/htc_acoustic_qsd.h - * - * Copyright (C) 2009 HTC Corporation. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _ARCH_ARM_MACH_MSM_HTC_ACOUSTIC_QSD_H_ -#define _ARCH_ARM_MACH_MSM_HTC_ACOUSTIC_QSD_H_ - -struct qsd_acoustic_ops { - void (*enable_mic_bias)(int en); -}; - -void acoustic_register_ops(struct qsd_acoustic_ops *ops); - -int turn_mic_bias_on(int on); -int force_headset_speaker_on(int enable); -int enable_aux_loopback(uint32_t enable); - -#endif - diff --git a/arch/arm/mach-msm/include/mach/htc_pwrsink.h b/arch/arm/mach-msm/include/mach/htc_pwrsink.h deleted file mode 100644 index c7a91f1d906cf1c643ad2f13ce76155e655b13d1..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/htc_pwrsink.h +++ /dev/null @@ -1,87 +0,0 @@ -/* include/asm/mach-msm/htc_pwrsink.h - * - * Copyright (C) 2007 Google, Inc. - * Copyright (C) 2008 HTC Corporation. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _ARCH_ARM_MACH_MSM_HTC_PWRSINK_H_ -#define _ARCH_ARM_MACH_MSM_HTC_PWRSINK_H_ - -#include -#include - -typedef enum { - PWRSINK_AUDIO_PCM = 0, - PWRSINK_AUDIO_MP3, - PWRSINK_AUDIO_AAC, - - PWRSINK_AUDIO_LAST = PWRSINK_AUDIO_AAC, - PWRSINK_AUDIO_INVALID -} pwrsink_audio_id_type; - -struct pwr_sink_audio { - unsigned volume; - unsigned percent; -}; - -typedef enum { - PWRSINK_SYSTEM_LOAD = 0, - PWRSINK_AUDIO, - PWRSINK_BACKLIGHT, - PWRSINK_LED_BUTTON, - PWRSINK_LED_KEYBOARD, - PWRSINK_GP_CLK, - PWRSINK_BLUETOOTH, - PWRSINK_CAMERA, - PWRSINK_SDCARD, - PWRSINK_VIDEO, - PWRSINK_WIFI, - - PWRSINK_LAST = PWRSINK_WIFI, - PWRSINK_INVALID -} pwrsink_id_type; - -struct pwr_sink { - pwrsink_id_type id; - unsigned ua_max; - unsigned percent_util; -}; - -struct pwr_sink_platform_data { - unsigned num_sinks; - struct pwr_sink *sinks; - int (*suspend_late)(struct platform_device *, pm_message_t state); - int (*resume_early)(struct platform_device *); - void (*suspend_early)(struct early_suspend *); - void (*resume_late)(struct early_suspend *); -}; - -#ifndef CONFIG_HTC_PWRSINK -static inline int htc_pwrsink_set(pwrsink_id_type id, unsigned percent) -{ - return 0; -} -static inline int htc_pwrsink_audio_set(pwrsink_audio_id_type id, - unsigned percent_utilized) { return 0; } -static inline int htc_pwrsink_audio_volume_set( - pwrsink_audio_id_type id, unsigned volume) { return 0; } -static inline int htc_pwrsink_audio_path_set(unsigned path) { return 0; } -#else -extern int htc_pwrsink_set(pwrsink_id_type id, unsigned percent); -extern int htc_pwrsink_audio_set(pwrsink_audio_id_type id, - unsigned percent_utilized); -extern int htc_pwrsink_audio_volume_set(pwrsink_audio_id_type id, - unsigned volume); -extern int htc_pwrsink_audio_path_set(unsigned path); -#endif - -#endif diff --git a/arch/arm/mach-msm/include/mach/irqs-7xxx.h b/arch/arm/mach-msm/include/mach/irqs-7xxx.h deleted file mode 100644 index f4f894dacf8d50930f0f1a483f45dcc8ec874d60..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/irqs-7xxx.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved. - * Author: Brian Swetland - */ - -#ifndef __ASM_ARCH_MSM_IRQS_7XXX_H -#define __ASM_ARCH_MSM_IRQS_7XXX_H - -/* MSM ARM11 Interrupt Numbers */ -/* See 80-VE113-1 A, pp219-221 */ - -#define INT_A9_M2A_0 0 -#define INT_A9_M2A_1 1 -#define INT_A9_M2A_2 2 -#define INT_A9_M2A_3 3 -#define INT_A9_M2A_4 4 -#define INT_A9_M2A_5 5 -#define INT_A9_M2A_6 6 -#define INT_GP_TIMER_EXP 7 -#define INT_DEBUG_TIMER_EXP 8 -#define INT_UART1 9 -#define INT_UART2 10 -#define INT_UART3 11 -#define INT_UART1_RX 12 -#define INT_UART2_RX 13 -#define INT_UART3_RX 14 -#define INT_USB_OTG 15 -#if defined(CONFIG_ARCH_MSM7X27A) -#define INT_DSI_IRQ 16 -#define INT_CSI_IRQ_1 17 -#define INT_CSI_IRQ_0 18 -#else -#define INT_MDDI_PRI 16 -#define INT_MDDI_EXT 17 -#define INT_MDDI_CLIENT 18 -#endif -#define INT_MDP 19 -#define INT_GRAPHICS 20 -#define INT_ADM_AARM 21 -#define INT_ADSP_A11 22 -#define INT_ADSP_A9_A11 23 -#define INT_SDC1_0 24 -#define INT_SDC1_1 25 -#define INT_SDC2_0 26 -#define INT_SDC2_1 27 -#define INT_KEYSENSE 28 -#define INT_TCHSCRN_SSBI 29 -#define INT_TCHSCRN1 30 -#define INT_TCHSCRN2 31 - -#define INT_GPIO_GROUP1 (32 + 0) -#define INT_GPIO_GROUP2 (32 + 1) -#define INT_PWB_I2C (32 + 2) -#define INT_SOFTRESET (32 + 3) -#define INT_NAND_WR_ER_DONE (32 + 4) -#define INT_NAND_OP_DONE (32 + 5) -#define INT_PBUS_ARM11 (32 + 6) -#define INT_AXI_MPU_SMI (32 + 7) -#define INT_AXI_MPU_EBI1 (32 + 8) -#define INT_AD_HSSD (32 + 9) -#define INT_ARMQC_PERFMON (32 + 10) -#define INT_ARM11_DMA (32 + 11) -#define INT_TSIF_IRQ (32 + 12) -#define INT_UART1DM_IRQ (32 + 13) -#define INT_UART1DM_RX (32 + 14) -#define INT_USB_HS (32 + 15) -#define INT_SDC3_0 (32 + 16) -#define INT_SDC3_1 (32 + 17) -#define INT_SDC4_0 (32 + 18) -#define INT_SDC4_1 (32 + 19) -#define INT_UART2DM_IRQ (32 + 20) -#define INT_UART2DM_RX (32 + 21) - -/* 22-31 are reserved except 7x27a*/ -#if defined(CONFIG_ARCH_MSM7X27A) -#define INT_L2CC_EM (32 + 22) -#define INT_L2CC_INTR (32 + 23) -#define INT_CE_IRQ (32 + 24) -#endif - -#define INT_ADSP_A11_SMSM INT_ADSP_A11 -#endif diff --git a/arch/arm/mach-msm/include/mach/irqs-8064.h b/arch/arm/mach-msm/include/mach/irqs-8064.h deleted file mode 100644 index f604a6ed6e55d397c63d3032a70e5b66bc62f1bc..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/irqs-8064.h +++ /dev/null @@ -1,304 +0,0 @@ -/* Copyright (c) 2011-2012, 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 __ASM_ARCH_MSM_IRQS_8064_H -#define __ASM_ARCH_MSM_IRQS_8064_H - -/* MSM ACPU Interrupt Numbers */ - -#define INT_VGIC (GIC_PPI_START + 0) -#define INT_DEBUG_TIMER_EXP (GIC_PPI_START + 1) -#define INT_GP_TIMER_EXP (GIC_PPI_START + 2) -#define INT_GP_TIMER2_EXP (GIC_PPI_START + 3) -#define WDT0_ACCSCSSNBARK_INT (GIC_PPI_START + 4) -#define WDT1_ACCSCSSNBARK_INT (GIC_PPI_START + 5) -#define AVS_SVICINT (GIC_PPI_START + 6) -#define AVS_SVICINTSWDONE (GIC_PPI_START + 7) -#define CPU_DBGCPUXCOMMRXFULL (GIC_PPI_START + 8) -#define CPU_DBGCPUXCOMMTXEMPTY (GIC_PPI_START + 9) -#define INT_ARMQC_PERFMON (GIC_PPI_START + 10) -#define SC_AVSCPUXDOWN (GIC_PPI_START + 11) -#define SC_AVSCPUXUP (GIC_PPI_START + 12) -#define SC_SICCPUXACGIRPTREQ (GIC_PPI_START + 13) -#define SC_SICCPUXEXTFAULTIRPTREQ (GIC_PPI_START + 14) -/* PPI 15 is unused */ - -#define APCC_QGICACGIRPTREQ (GIC_SPI_START + 0) -#define APCC_QGICL2PERFMONIRPTREQ (GIC_SPI_START + 1) -#define SC_SICL2PERFMONIRPTREQ APCC_QGICL2PERFMONIRPTREQ -#define APCC_QGICL2IRPTREQ (GIC_SPI_START + 2) -#define APCC_QGICMPUIRPTREQ (GIC_SPI_START + 3) -#define TLMM_MSM_DIR_CONN_IRQ_0 (GIC_SPI_START + 4) -#define TLMM_MSM_DIR_CONN_IRQ_1 (GIC_SPI_START + 5) -#define TLMM_MSM_DIR_CONN_IRQ_2 (GIC_SPI_START + 6) -#define TLMM_MSM_DIR_CONN_IRQ_3 (GIC_SPI_START + 7) -#define TLMM_MSM_DIR_CONN_IRQ_4 (GIC_SPI_START + 8) -#define TLMM_MSM_DIR_CONN_IRQ_5 (GIC_SPI_START + 9) -#define TLMM_MSM_DIR_CONN_IRQ_6 (GIC_SPI_START + 10) -#define TLMM_MSM_DIR_CONN_IRQ_7 (GIC_SPI_START + 11) -#define TLMM_MSM_DIR_CONN_IRQ_8 (GIC_SPI_START + 12) -#define TLMM_MSM_DIR_CONN_IRQ_9 (GIC_SPI_START + 13) -#define PM8921_SEC_IRQ_N (GIC_SPI_START + 14) -#define PM8821_SEC_IRQ_N (GIC_SPI_START + 15) -#define TLMM_MSM_SUMMARY_IRQ (GIC_SPI_START + 16) -#define SPDM_RT_1_IRQ (GIC_SPI_START + 17) -#define SPDM_DIAG_IRQ (GIC_SPI_START + 18) -#define RPM_APCC_CPU0_GP_HIGH_IRQ (GIC_SPI_START + 19) -#define RPM_APCC_CPU0_GP_MEDIUM_IRQ (GIC_SPI_START + 20) -#define RPM_APCC_CPU0_GP_LOW_IRQ (GIC_SPI_START + 21) -#define RPM_APCC_CPU0_WAKE_UP_IRQ (GIC_SPI_START + 22) -#define RPM_APCC_CPU1_GP_HIGH_IRQ (GIC_SPI_START + 23) -#define RPM_APCC_CPU1_GP_MEDIUM_IRQ (GIC_SPI_START + 24) -#define RPM_APCC_CPU1_GP_LOW_IRQ (GIC_SPI_START + 25) -#define RPM_APCC_CPU1_WAKE_UP_IRQ (GIC_SPI_START + 26) -#define SSBI2_2_SC_CPU0_SECURE_IRQ (GIC_SPI_START + 27) -#define SSBI2_2_SC_CPU0_NON_SECURE_IRQ (GIC_SPI_START + 28) -#define SSBI2_1_SC_CPU0_SECURE_IRQ (GIC_SPI_START + 29) -#define SSBI2_1_SC_CPU0_NON_SECURE_IRQ (GIC_SPI_START + 30) -#define MSMC_SC_SEC_CE_IRQ (GIC_SPI_START + 31) -#define MSMC_SC_PRI_CE_IRQ (GIC_SPI_START + 32) -#define SLIMBUS0_CORE_EE1_IRQ (GIC_SPI_START + 33) -#define SLIMBUS0_BAM_EE1_IRQ (GIC_SPI_START + 34) -#define KPSS_SPARE_0 (GIC_SPI_START + 35) -#define GSS_A5_WDOG_EXPIRED (GIC_SPI_START + 36) -#define GSS_TO_APPS_IRQ_0 (GIC_SPI_START + 37) -#define GSS_TO_APPS_IRQ_1 (GIC_SPI_START + 38) -#define GSS_TO_APPS_IRQ_2 (GIC_SPI_START + 39) -#define GSS_TO_APPS_IRQ_3 (GIC_SPI_START + 40) -#define GSS_TO_APPS_IRQ_4 (GIC_SPI_START + 41) -#define GSS_TO_APPS_IRQ_5 (GIC_SPI_START + 42) -#define GSS_TO_APPS_IRQ_6 (GIC_SPI_START + 43) -#define GSS_TO_APPS_IRQ_7 (GIC_SPI_START + 44) -#define GSS_TO_APPS_IRQ_8 (GIC_SPI_START + 45) -#define GSS_TO_APPS_IRQ_9 (GIC_SPI_START + 46) -#define VPE_IRQ (GIC_SPI_START + 47) -#define VFE_IRQ (GIC_SPI_START + 48) -#define VCODEC_IRQ (GIC_SPI_START + 49) -#define KPSS_SPARE_1 (GIC_SPI_START + 50) -#define SMMU_VPE_CB_SC_SECURE_IRQ (GIC_SPI_START + 51) -#define SMMU_VPE_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 52) -#define SMMU_VFE_CB_SC_SECURE_IRQ (GIC_SPI_START + 53) -#define SMMU_VFE_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 54) -#define SMMU_VCODEC_B_CB_SC_SECURE_IRQ (GIC_SPI_START + 55) -#define SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 56) -#define SMMU_VCODEC_A_CB_SC_SECURE_IRQ (GIC_SPI_START + 57) -#define SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 58) -#define SMMU_ROT_CB_SC_SECURE_IRQ (GIC_SPI_START + 59) -#define SMMU_ROT_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 60) -#define SMMU_MDP1_CB_SC_SECURE_IRQ (GIC_SPI_START + 61) -#define SMMU_MDP1_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 62) -#define SMMU_MDP0_CB_SC_SECURE_IRQ (GIC_SPI_START + 63) -#define SMMU_MDP0_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 64) -#define SMMU_JPEGD_CB_SC_SECURE_IRQ (GIC_SPI_START + 65) -#define SMMU_JPEGD_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 66) -#define SMMU_IJPEG_CB_SC_SECURE_IRQ (GIC_SPI_START + 67) -#define SMMU_IJPEG_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 68) -#define SMMU_GFX3D_CB_SC_SECURE_IRQ (GIC_SPI_START + 69) -#define SMMU_GFX3D_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 70) -#define VCAP_VP (GIC_SPI_START + 71) -#define VCAP_VC (GIC_SPI_START + 72) -#define ROT_IRQ (GIC_SPI_START + 73) -#define MMSS_FABRIC_IRQ (GIC_SPI_START + 74) -#define MDP_IRQ (GIC_SPI_START + 75) -#define JPEGD_IRQ (GIC_SPI_START + 76) -#define JPEG_IRQ (GIC_SPI_START + 77) -#define MMSS_IMEM_IRQ (GIC_SPI_START + 78) -#define HDMI_IRQ (GIC_SPI_START + 79) -#define GFX3D_IRQ (GIC_SPI_START + 80) -#define GFX3d_VBIF_IRQ (GIC_SPI_START + 81) -#define DSI1_IRQ (GIC_SPI_START + 82) -#define CSI_1_IRQ (GIC_SPI_START + 83) -#define CSI_0_IRQ (GIC_SPI_START + 84) -#define LPASS_SCSS_AUDIO_IF_OUT0_IRQ (GIC_SPI_START + 85) -#define LPASS_SCSS_MIDI_IRQ (GIC_SPI_START + 86) -#define LPASS_Q6SS_WDOG_EXPIRED (GIC_SPI_START + 87) -#define LPASS_SCSS_GP_LOW_IRQ (GIC_SPI_START + 88) -#define LPASS_SCSS_GP_MEDIUM_IRQ (GIC_SPI_START + 89) -#define LPASS_SCSS_GP_HIGH_IRQ (GIC_SPI_START + 90) -#define TOP_IMEM_IRQ (GIC_SPI_START + 91) -#define FABRIC_SYS_IRQ (GIC_SPI_START + 92) -#define FABRIC_APPS_IRQ (GIC_SPI_START + 93) -#define USB1_HS_BAM_IRQ (GIC_SPI_START + 94) -#define SDC4_BAM_IRQ (GIC_SPI_START + 95) -#define SDC3_BAM_IRQ (GIC_SPI_START + 96) -#define SDC2_BAM_IRQ (GIC_SPI_START + 97) -#define SDC1_BAM_IRQ (GIC_SPI_START + 98) -#define FABRIC_SPS_IRQ (GIC_SPI_START + 99) -#define USB1_HS_IRQ (GIC_SPI_START + 100) -#define SDC4_IRQ_0 (GIC_SPI_START + 101) -#define SDC3_IRQ_0 (GIC_SPI_START + 102) -#define SDC2_IRQ_0 (GIC_SPI_START + 103) -#define SDC1_IRQ_0 (GIC_SPI_START + 104) -#define SPS_BAM_DMA_IRQ (GIC_SPI_START + 105) -#define SPS_SEC_VIOL_IRQ (GIC_SPI_START + 106) -#define SPS_MTI_0 (GIC_SPI_START + 107) -#define SPS_MTI_1 (GIC_SPI_START + 108) -#define SPS_MTI_2 (GIC_SPI_START + 109) -#define SPS_MTI_3 (GIC_SPI_START + 110) -#define SPS_MTI_4 (GIC_SPI_START + 111) -#define SPS_MTI_5 (GIC_SPI_START + 112) -#define SPS_MTI_6 (GIC_SPI_START + 113) -#define SPS_MTI_7 (GIC_SPI_START + 114) -#define SPS_MTI_8 (GIC_SPI_START + 115) -#define SPS_MTI_9 (GIC_SPI_START + 116) -#define SPS_MTI_10 (GIC_SPI_START + 117) -#define SPS_MTI_11 (GIC_SPI_START + 118) -#define SPS_MTI_12 (GIC_SPI_START + 119) -#define SPS_MTI_13 (GIC_SPI_START + 120) -#define SPS_MTI_14 (GIC_SPI_START + 121) -#define SPS_MTI_15 (GIC_SPI_START + 122) -#define SPS_MTI_16 (GIC_SPI_START + 123) -#define SPS_MTI_17 (GIC_SPI_START + 124) -#define SPS_MTI_18 (GIC_SPI_START + 125) -#define SPS_MTI_19 (GIC_SPI_START + 126) -#define SPS_MTI_20 (GIC_SPI_START + 127) -#define SPS_MTI_21 (GIC_SPI_START + 128) -#define SPS_MTI_22 (GIC_SPI_START + 129) -#define SPS_MTI_23 (GIC_SPI_START + 130) -#define SPS_MTI_24 (GIC_SPI_START + 131) -#define SPS_MTI_25 (GIC_SPI_START + 132) -#define SPS_MTI_26 (GIC_SPI_START + 133) -#define SPS_MTI_27 (GIC_SPI_START + 134) -#define SPS_MTI_28 (GIC_SPI_START + 135) -#define SPS_MTI_29 (GIC_SPI_START + 136) -#define SPS_MTI_30 (GIC_SPI_START + 137) -#define SPS_MTI_31 (GIC_SPI_START + 138) -#define CSIPHY_0_4LN_IRQ (GIC_SPI_START + 139) -#define CSIPHY_1_2LN_IRQ (GIC_SPI_START + 140) -#define KPSS_SPARE_2 (GIC_SPI_START + 141) -#define USB1_IRQ (GIC_SPI_START + 142) -#define TSSC_SSBI_IRQ (GIC_SPI_START + 143) -#define TSSC_SAMPLE_IRQ (GIC_SPI_START + 144) -#define TSSC_PENUP_IRQ (GIC_SPI_START + 145) -#define KPSS_SPARE_3 (GIC_SPI_START + 146) -#define KPSS_SPARE_4 (GIC_SPI_START + 147) -#define KPSS_SPARE_5 (GIC_SPI_START + 148) -#define KPSS_SPARE_6 (GIC_SPI_START + 149) -#define GSBI3_UARTDM_IRQ (GIC_SPI_START + 150) -#define GSBI3_QUP_IRQ (GIC_SPI_START + 151) -#define GSBI4_UARTDM_IRQ (GIC_SPI_START + 152) -#define GSBI4_QUP_IRQ (GIC_SPI_START + 153) -#define GSBI5_UARTDM_IRQ (GIC_SPI_START + 154) -#define GSBI5_QUP_IRQ (GIC_SPI_START + 155) -#define GSBI6_UARTDM_IRQ (GIC_SPI_START + 156) -#define GSBI6_QUP_IRQ (GIC_SPI_START + 157) -#define GSBI7_UARTDM_IRQ (GIC_SPI_START + 158) -#define GSBI7_QUP_IRQ (GIC_SPI_START + 159) -#define KPSS_SPARE_7 (GIC_SPI_START + 160) -#define KPSS_SPARE_8 (GIC_SPI_START + 161) -#define TSIF_TSPP_IRQ (GIC_SPI_START + 162) -#define TSIF_BAM_IRQ (GIC_SPI_START + 163) -#define TSIF2_IRQ (GIC_SPI_START + 164) -#define TSIF1_IRQ (GIC_SPI_START + 165) -#define DSI2_IRQ (GIC_SPI_START + 166) -#define ISPIF_IRQ (GIC_SPI_START + 167) -#define MSMC_SC_SEC_TMR_IRQ (GIC_SPI_START + 168) -#define MSMC_SC_SEC_WDOG_BARK_IRQ (GIC_SPI_START + 169) -#define ADM_0_SCSS_0_IRQ (GIC_SPI_START + 170) -#define ADM_0_SCSS_1_IRQ (GIC_SPI_START + 171) -#define ADM_0_SCSS_2_IRQ (GIC_SPI_START + 172) -#define ADM_0_SCSS_3_IRQ (GIC_SPI_START + 173) -#define CC_SCSS_WDT1CPU1BITEEXPIRED (GIC_SPI_START + 174) -#define CC_SCSS_WDT1CPU0BITEEXPIRED (GIC_SPI_START + 175) -#define CC_SCSS_WDT0CPU1BITEEXPIRED (GIC_SPI_START + 176) -#define CC_SCSS_WDT0CPU0BITEEXPIRED (GIC_SPI_START + 177) -#define TSENS_UPPER_LOWER_INT (GIC_SPI_START + 178) -#define SSBI2_2_SC_CPU1_SECURE_INT (GIC_SPI_START + 179) -#define SSBI2_2_SC_CPU1_NON_SECURE_INT (GIC_SPI_START + 180) -#define SSBI2_1_SC_CPU1_SECURE_INT (GIC_SPI_START + 181) -#define SSBI2_1_SC_CPU1_NON_SECURE_INT (GIC_SPI_START + 182) -#define XPU_SUMMARY_IRQ (GIC_SPI_START + 183) -#define BUS_EXCEPTION_SUMMARY_IRQ (GIC_SPI_START + 184) -#define HSDDRX_EBI1CH0_IRQ (GIC_SPI_START + 185) -#define HSDDRX_EBI1CH1_IRQ (GIC_SPI_START + 186) -#define USB3_HS_BAM_IRQ (GIC_SPI_START + 187) -#define USB3_HS_IRQ (GIC_SPI_START + 188) -#define CC_SCSS_WDT1CPU3BITEEXPIRED (GIC_SPI_START + 189) -#define CC_SCSS_WDT1CPU2BITEEXPIRED (GIC_SPI_START + 190) -#define CC_SCSS_WDT0CPU3BITEEXPIRED (GIC_SPI_START + 191) -#define CC_SCSS_WDT0CPU2BITEEXPIRED (GIC_SPI_START + 192) -#define APQ8064_GSBI1_UARTDM_IRQ (GIC_SPI_START + 193) -#define APQ8064_GSBI1_QUP_IRQ (GIC_SPI_START + 194) -#define APQ8064_GSBI2_UARTDM_IRQ (GIC_SPI_START + 195) -#define APQ8064_GSBI2_QUP_IRQ (GIC_SPI_START + 196) -#define RIVA_APSS_LTECOEX_IRQ (GIC_SPI_START + 197) -#define RIVA_APSS_SPARE_IRQ (GIC_SPI_START + 198) -#define RIVA_APSS_WDOG_BITE_RESET_RDY_IRQ (GIC_SPI_START + 199) -#define RIVA_APSS_RESET_DONE_IRQ (GIC_SPI_START + 200) -#define RIVA_APSS_ASIC_IRQ (GIC_SPI_START + 201) -#define RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ (GIC_SPI_START + 202) -#define RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ (GIC_SPI_START + 203) -#define RIVA_APPS_WLAN_SMSM_IRQ (GIC_SPI_START + 204) -#define RIVA_APPS_LOG_CTRL_IRQ (GIC_SPI_START + 205) -#define RIVA_APPS_FM_CTRL_IRQ (GIC_SPI_START + 206) -#define RIVA_APPS_HCI_IRQ (GIC_SPI_START + 207) -#define RIVA_APPS_WLAN_CTRL_IRQ (GIC_SPI_START + 208) -#define SATA_CONTROLLER_IRQ (GIC_SPI_START + 209) -#define SMMU_GFX3D1_CB_SC_SECURE_IRQ (GIC_SPI_START + 210) -#define SMMU_GFX3D1_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 211) -#define KPSS_SPARE_9 (GIC_SPI_START + 212) -#define PPSS_WDOG_TIMER_IRQ (GIC_SPI_START + 213) -#define USB4_HS_BAM_IRQ (GIC_SPI_START + 214) -#define USB4_HS_IRQ (GIC_SPI_START + 215) -#define QDSS_ETB_IRQ (GIC_SPI_START + 216) -#define QDSS_CTI2KPSS_CPU1_IRQ (GIC_SPI_START + 217) -#define QDSS_CTI2KPSS_CPU0_IRQ (GIC_SPI_START + 218) -#define TLMM_MSM_DIR_CONN_IRQ_16 (GIC_SPI_START + 219) -#define TLMM_MSM_DIR_CONN_IRQ_17 (GIC_SPI_START + 220) -#define TLMM_MSM_DIR_CONN_IRQ_18 (GIC_SPI_START + 221) -#define TLMM_MSM_DIR_CONN_IRQ_19 (GIC_SPI_START + 222) -#define TLMM_MSM_DIR_CONN_IRQ_20 (GIC_SPI_START + 223) -#define TLMM_MSM_DIR_CONN_IRQ_21 (GIC_SPI_START + 224) -#define PM8921_USR_IRQ_N (GIC_SPI_START + 225) -#define PM8821_USR_IRQ_N (GIC_SPI_START + 226) - -#define CSI_2_IRQ (GIC_SPI_START + 227) -#define APQ8064_CSIPHY_2LN_IRQ (GIC_SPI_START + 228) -#define USB2_HSIC_IRQ (GIC_SPI_START + 229) -#define CE2_BAM_XPU_IRQ (GIC_SPI_START + 230) -#define CE1_BAM_XPU_IRQ (GIC_SPI_START + 231) -#define RPM_SCSS_CPU2_WAKE_UP_IRQ (GIC_SPI_START + 232) -#define RPM_SCSS_CPU3_WAKE_UP_IRQ (GIC_SPI_START + 233) -#define CS3_BAM_XPU_IRQ (GIC_SPI_START + 234) -#define CE3_IRQ (GIC_SPI_START + 235) -#define SMMU_VCAP_CB_SC_SECURE_IRQ (GIC_SPI_START + 236) -#define SMMU_VCAP_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 237) -#define PCIE20_INT_MSI (GIC_SPI_START + 238) -#define PCIE20_INTA (GIC_SPI_START + 239) -#define PCIE20_INTB (GIC_SPI_START + 240) -#define PCIE20_INTC (GIC_SPI_START + 241) -#define PCIE20_INTD (GIC_SPI_START + 242) -#define PCIE20_INT_PLS_HP (GIC_SPI_START + 243) -#define PCIE20_INT_PLS_ERR (GIC_SPI_START + 244) -#define PCIE20_INT_PLS_PME (GIC_SPI_START + 245) -#define PCIE20_INT_LINK_UP (GIC_SPI_START + 246) -#define PCIE20_INT_LINK_DOWN (GIC_SPI_START + 247) -#define PCIE20_INT_HP_LEGACY (GIC_SPI_START + 248) -#define PCIE20_INT_AER_LEGACY (GIC_SPI_START + 249) -#define PCIE20_INT_PME_LEGACY (GIC_SPI_START + 250) -#define PCIE20_INT_BRIDGE_FLUSH_N (GIC_SPI_START + 251) - -/* Backwards compatible IRQ macros. */ -#define INT_ADM_AARM ADM_0_SCSS_0_IRQ - -/* smd/smsm interrupts */ -#define INT_A9_M2A_0 (GIC_SPI_START + 37) /*GSS_TO_APPS_IRQ_0*/ -#define INT_A9_M2A_5 (GIC_SPI_START + 38) /*GSS_TO_APPS_IRQ_1*/ -#define INT_ADSP_A11 LPASS_SCSS_GP_HIGH_IRQ -#define INT_ADSP_A11_SMSM LPASS_SCSS_GP_MEDIUM_IRQ -#define INT_DSPS_A11 SPS_MTI_31 -#define INT_DSPS_A11_SMSM SPS_MTI_30 -#define INT_WCNSS_A11 RIVA_APSS_SPARE_IRQ -#define INT_WCNSS_A11_SMSM RIVA_APPS_WLAN_SMSM_IRQ - -#endif - diff --git a/arch/arm/mach-msm/include/mach/irqs-8625.h b/arch/arm/mach-msm/include/mach/irqs-8625.h deleted file mode 100644 index 73451ffaba355e1304ad52db2368807acd3aaebb..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/irqs-8625.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (c) 2012, 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 __ASM_ARCH_MSM_IRQS_8625_H -#define __ASM_ARCH_MSM_IRQS_8625_H - -#ifdef CONFIG_MSM_FIQ -#define FIQ_START 0 -#endif - -/* As per QGIC2 PPI 16 aka 0 is reserved */ -#define MSM8625_INT_A5_PMU_IRQ (GIC_PPI_START + 1) -#define MSM8625_INT_DEBUG_TIMER_EXP (GIC_PPI_START + 2) -#define MSM8625_INT_GP_TIMER_EXP (GIC_PPI_START + 3) -#define MSM8625_INT_COMMRX (GIC_PPI_START + 4) -#define MSM8625_INT_COMMTX (GIC_PPI_START + 5) - -/* rest of the PPI's not used - */ - -#define MSM8625_INT_A9_M2A_0 (GIC_SPI_START + 0) -#define MSM8625_INT_A9_M2A_1 (GIC_SPI_START + 1) -#define MSM8625_INT_A9_M2A_2 (GIC_SPI_START + 2) -#define MSM8625_INT_A9_M2A_3 (GIC_SPI_START + 3) -#define MSM8625_INT_A9_M2A_4 (GIC_SPI_START + 4) -#define MSM8625_INT_A9_M2A_5 (GIC_SPI_START + 5) -#define MSM8625_INT_A9_M2A_6 (GIC_SPI_START + 6) -#define MSM8625_INT_ACSR_MP_CORE_IPC0 (GIC_SPI_START + 7) -#define MSM8625_INT_ACSR_MP_CORE_IPC1 (GIC_SPI_START + 8) -#define MSM8625_INT_UART1 (GIC_SPI_START + 9) -#define MSM8625_INT_UART2 (GIC_SPI_START + 10) -#define MSM8625_INT_UART3 (GIC_SPI_START + 11) -#define MSM8625_INT_UART1_RX (GIC_SPI_START + 12) -#define MSM8625_INT_UART2_RX (GIC_SPI_START + 13) -#define MSM8625_INT_UART3_RX (GIC_SPI_START + 14) -#define MSM8625_INT_USB_OTG (GIC_SPI_START + 15) -#define MSM8625_INT_DSI_IRQ (GIC_SPI_START + 16) -#define MSM8625_INT_CSI_IRQ_1 (GIC_SPI_START + 17) -#define MSM8625_INT_CSI_IRQ_0 (GIC_SPI_START + 18) -#define MSM8625_INT_MDP (GIC_SPI_START + 19) -#define MSM8625_INT_GRAPHICS (GIC_SPI_START + 20) -#define MSM8625_INT_ADM_AARM (GIC_SPI_START + 21) -#define MSM8625_INT_ADSP_A11 (GIC_SPI_START + 22) -#define MSM8625_INT_ADSP_A9_A11 (GIC_SPI_START + 23) -#define MSM8625_INT_SDC1_0 (GIC_SPI_START + 24) -#define MSM8625_INT_SDC1_1 (GIC_SPI_START + 25) -#define MSM8625_INT_SDC2_0 (GIC_SPI_START + 26) -#define MSM8625_INT_SDC2_1 (GIC_SPI_START + 27) -#define MSM8625_INT_KEYSENSE (GIC_SPI_START + 28) -#define MSM8625_INT_TCHSCRN_SSBI (GIC_SPI_START + 29) -#define MSM8625_INT_TCHSCRN1 (GIC_SPI_START + 30) -#define MSM8625_INT_TCHSCRN2 (GIC_SPI_START + 31) - -#define MSM8625_INT_GPIO_GROUP1 (GIC_SPI_START + 32 + 0) -#define MSM8625_INT_GPIO_GROUP2 (GIC_SPI_START + 32 + 1) -#define MSM8625_INT_PWB_I2C (GIC_SPI_START + 32 + 2) -#define MSM8625_INT_SOFTRESET (GIC_SPI_START + 32 + 3) -#define MSM8625_INT_NAND_WR_ER_DONE (GIC_SPI_START + 32 + 4) -#define MSM8625_INT_NAND_OP_DONE (GIC_SPI_START + 32 + 5) -#define MSM8625_INT_PBUS_ARM11 (GIC_SPI_START + 32 + 6) -#define MSM8625_INT_AXI_MPU_SMI (GIC_SPI_START + 32 + 7) -#define MSM8625_INT_AXI_MPU_EBI1 (GIC_SPI_START + 32 + 8) -#define MSM8625_INT_AD_HSSD (GIC_SPI_START + 32 + 9) -#define MSM8625_INT_NOTUSED (GIC_SPI_START + 32 + 10) -#define MSM8625_INT_ARM11_DMA (GIC_SPI_START + 32 + 11) -#define MSM8625_INT_TSIF_IRQ (GIC_SPI_START + 32 + 12) -#define MSM8625_INT_UART1DM_IRQ (GIC_SPI_START + 32 + 13) -#define MSM8625_INT_UART1DM_RX (GIC_SPI_START + 32 + 14) -#define MSM8625_INT_USB_HS (GIC_SPI_START + 32 + 15) -#define MSM8625_INT_SDC3_0 (GIC_SPI_START + 32 + 16) -#define MSM8625_INT_SDC3_1 (GIC_SPI_START + 32 + 17) -#define MSM8625_INT_SDC4_0 (GIC_SPI_START + 32 + 18) -#define MSM8625_INT_SDC4_1 (GIC_SPI_START + 32 + 19) -#define MSM8625_INT_UART2DM_IRQ (GIC_SPI_START + 32 + 20) -#define MSM8625_INT_UART2DM_RX (GIC_SPI_START + 32 + 21) -#define MSM8625_INT_L2CC_EM (GIC_SPI_START + 32 + 22) -#define MSM8625_INT_L2CC_INTR (GIC_SPI_START + 32 + 23) -#define MSM8625_INT_CE_IRQ (GIC_SPI_START + 32 + 24) -#define MSM8625_INT_CPR_IRQ0 (GIC_SPI_START + 32 + 25) -#define MSM8625_INT_CPR_IRQ1 (GIC_SPI_START + 32 + 26) -#define MSM8625_INT_CPR_IRQ2 (GIC_SPI_START + 32 + 27) -#define MSM8625_INT_ACSR_MP_CORE_IPC2 (GIC_SPI_START + 32 + 28) -#define MSM8625_INT_ACSR_MP_CORE_IPC3 (GIC_SPI_START + 32 + 29) - -#define MSM8625_INT_ADSP_A11_SMSM MSM8625_INT_ADSP_A11 -#endif diff --git a/arch/arm/mach-msm/include/mach/irqs-8930.h b/arch/arm/mach-msm/include/mach/irqs-8930.h deleted file mode 100644 index b6c7257af65bf40127058e9e50fb2afbdcb2a428..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/irqs-8930.h +++ /dev/null @@ -1,285 +0,0 @@ -/* Copyright (c) 2011, 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 __ASM_ARCH_MSM_IRQS_8930_H -#define __ASM_ARCH_MSM_IRQS_8930_H - -/* MSM ACPU Interrupt Numbers */ - -#define INT_VGIC (GIC_PPI_START + 0) -#define INT_DEBUG_TIMER_EXP (GIC_PPI_START + 1) -#define INT_GP_TIMER_EXP (GIC_PPI_START + 2) -#define INT_GP_TIMER2_EXP (GIC_PPI_START + 3) -#define WDT0_ACCSCSSNBARK_INT (GIC_PPI_START + 4) -#define WDT1_ACCSCSSNBARK_INT (GIC_PPI_START + 5) -#define AVS_SVICINT (GIC_PPI_START + 6) -#define AVS_SVICINTSWDONE (GIC_PPI_START + 7) -#define CPU_DBGCPUXCOMMRXFULL (GIC_PPI_START + 8) -#define CPU_DBGCPUXCOMMTXEMPTY (GIC_PPI_START + 9) -#define INT_ARMQC_PERFMON (GIC_PPI_START + 10) -#define SC_AVSCPUXDOWN (GIC_PPI_START + 11) -#define SC_AVSCPUXUP (GIC_PPI_START + 12) -#define SC_SICCPUXACGIRPTREQ (GIC_PPI_START + 13) -#define SC_SICCPUXEXTFAULTIRPTREQ (GIC_PPI_START + 14) -/* PPI 15 is unused */ - -#define APCC_QGICACGIRPTREQ (GIC_SPI_START + 0) -#define APCC_QGICL2PERFMONIRPTREQ (GIC_SPI_START + 1) -#define SC_SICL2PERFMONIRPTREQ APCC_QGICL2PERFMONIRPTREQ -#define APCC_QGICL2IRPTREQ (GIC_SPI_START + 2) -#define APCC_QGICMPUIRPTREQ (GIC_SPI_START + 3) -#define TLMM_MSM_DIR_CONN_IRQ_0 (GIC_SPI_START + 4) -#define TLMM_MSM_DIR_CONN_IRQ_1 (GIC_SPI_START + 5) -#define TLMM_MSM_DIR_CONN_IRQ_2 (GIC_SPI_START + 6) -#define TLMM_MSM_DIR_CONN_IRQ_3 (GIC_SPI_START + 7) -#define TLMM_MSM_DIR_CONN_IRQ_4 (GIC_SPI_START + 8) -#define TLMM_MSM_DIR_CONN_IRQ_5 (GIC_SPI_START + 9) -#define TLMM_MSM_DIR_CONN_IRQ_6 (GIC_SPI_START + 10) -#define TLMM_MSM_DIR_CONN_IRQ_7 (GIC_SPI_START + 11) -#define TLMM_MSM_DIR_CONN_IRQ_8 (GIC_SPI_START + 12) -#define TLMM_MSM_DIR_CONN_IRQ_9 (GIC_SPI_START + 13) -#define PM8921_SEC_IRQ_103 (GIC_SPI_START + 14) -#define PM8018_SEC_IRQ_106 (GIC_SPI_START + 15) -#define TLMM_MSM_SUMMARY_IRQ (GIC_SPI_START + 16) -#define SPDM_RT_1_IRQ (GIC_SPI_START + 17) -#define SPDM_DIAG_IRQ (GIC_SPI_START + 18) -#define RPM_APCC_CPU0_GP_HIGH_IRQ (GIC_SPI_START + 19) -#define RPM_APCC_CPU0_GP_MEDIUM_IRQ (GIC_SPI_START + 20) -#define RPM_APCC_CPU0_GP_LOW_IRQ (GIC_SPI_START + 21) -#define RPM_APCC_CPU0_WAKE_UP_IRQ (GIC_SPI_START + 22) -#define RPM_APCC_CPU1_GP_HIGH_IRQ (GIC_SPI_START + 23) -#define RPM_APCC_CPU1_GP_MEDIUM_IRQ (GIC_SPI_START + 24) -#define RPM_APCC_CPU1_GP_LOW_IRQ (GIC_SPI_START + 25) -#define RPM_APCC_CPU1_WAKE_UP_IRQ (GIC_SPI_START + 26) -#define SSBI2_2_SC_CPU0_SECURE_IRQ (GIC_SPI_START + 27) -#define SSBI2_2_SC_CPU0_NON_SECURE_IRQ (GIC_SPI_START + 28) -#define SSBI2_1_SC_CPU0_SECURE_IRQ (GIC_SPI_START + 29) -#define SSBI2_1_SC_CPU0_NON_SECURE_IRQ (GIC_SPI_START + 30) -#define MSMC_SC_SEC_CE_IRQ (GIC_SPI_START + 31) -#define MSMC_SC_PRI_CE_IRQ (GIC_SPI_START + 32) -#define SLIMBUS0_CORE_EE1_IRQ (GIC_SPI_START + 33) -#define SLIMBUS0_BAM_EE1_IRQ (GIC_SPI_START + 34) -#define Q6FW_WDOG_EXPIRED_IRQ (GIC_SPI_START + 35) -#define Q6SW_WDOG_EXPIRED_IRQ (GIC_SPI_START + 36) -#define MSS_TO_APPS_IRQ_0 (GIC_SPI_START + 37) -#define MSS_TO_APPS_IRQ_1 (GIC_SPI_START + 38) -#define MSS_TO_APPS_IRQ_2 (GIC_SPI_START + 39) -#define MSS_TO_APPS_IRQ_3 (GIC_SPI_START + 40) -#define MSS_TO_APPS_IRQ_4 (GIC_SPI_START + 41) -#define MSS_TO_APPS_IRQ_5 (GIC_SPI_START + 42) -#define MSS_TO_APPS_IRQ_6 (GIC_SPI_START + 43) -#define MSS_TO_APPS_IRQ_7 (GIC_SPI_START + 44) -#define MSS_TO_APPS_IRQ_8 (GIC_SPI_START + 45) -#define MSS_TO_APPS_IRQ_9 (GIC_SPI_START + 46) -#define VPE_IRQ (GIC_SPI_START + 47) -#define VFE_IRQ (GIC_SPI_START + 48) -#define VCODEC_IRQ (GIC_SPI_START + 49) -/* SPI IRQ 50 is unused */ -#define SMMU_VPE_CB_SC_SECURE_IRQ (GIC_SPI_START + 51) -#define SMMU_VPE_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 52) -#define SMMU_VFE_CB_SC_SECURE_IRQ (GIC_SPI_START + 53) -#define SMMU_VFE_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 54) -#define SMMU_VCODEC_B_CB_SC_SECURE_IRQ (GIC_SPI_START + 55) -#define SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 56) -#define SMMU_VCODEC_A_CB_SC_SECURE_IRQ (GIC_SPI_START + 57) -#define SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 58) -#define SMMU_ROT_CB_SC_SECURE_IRQ (GIC_SPI_START + 59) -#define SMMU_ROT_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 60) -#define SMMU_MDP1_CB_SC_SECURE_IRQ (GIC_SPI_START + 61) -#define SMMU_MDP1_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 62) -#define SMMU_MDP0_CB_SC_SECURE_IRQ (GIC_SPI_START + 63) -#define SMMU_MDP0_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 64) -/* SPI IRQ 65 is unused */ -/* SPI IRQ 66 is unused */ -#define SMMU_IJPEG_CB_SC_SECURE_IRQ (GIC_SPI_START + 67) -#define SMMU_IJPEG_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 68) -#define SMMU_GFX3D_CB_SC_SECURE_IRQ (GIC_SPI_START + 69) -#define SMMU_GFX3D_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 70) -/* SPI IRQ 71 is unused */ -/* SPI IRQ 72 is unused */ -#define ROT_IRQ (GIC_SPI_START + 73) -#define MMSS_FABRIC_IRQ (GIC_SPI_START + 74) -#define MDP_IRQ (GIC_SPI_START + 75) -/* SPI IRQ 76 is unused */ -#define JPEG_IRQ (GIC_SPI_START + 77) -#define MMSS_IMEM_IRQ (GIC_SPI_START + 78) -#define HDMI_IRQ (GIC_SPI_START + 79) -#define GFX3D_IRQ (GIC_SPI_START + 80) -/* SPI IRQ 81 is unused */ -#define DSI1_IRQ (GIC_SPI_START + 82) -#define CSI_1_IRQ (GIC_SPI_START + 83) -#define CSI_0_IRQ (GIC_SPI_START + 84) -#define LPASS_SCSS_AUDIO_IF_OUT0_IRQ (GIC_SPI_START + 85) -#define LPASS_SCSS_MIDI_IRQ (GIC_SPI_START + 86) -#define LPASS_Q6SS_WDOG_EXPIRED (GIC_SPI_START + 87) -#define LPASS_SCSS_GP_LOW_IRQ (GIC_SPI_START + 88) -#define LPASS_SCSS_GP_MEDIUM_IRQ (GIC_SPI_START + 89) -#define LPASS_SCSS_GP_HIGH_IRQ (GIC_SPI_START + 90) -#define TOP_IMEM_IRQ (GIC_SPI_START + 91) -#define FABRIC_SYS_IRQ (GIC_SPI_START + 92) -#define FABRIC_APPS_IRQ (GIC_SPI_START + 93) -#define USB1_HS_BAM_IRQ (GIC_SPI_START + 94) -#define SDC4_BAM_IRQ (GIC_SPI_START + 95) -#define SDC3_BAM_IRQ (GIC_SPI_START + 96) -#define SDC2_BAM_IRQ (GIC_SPI_START + 97) -#define SDC1_BAM_IRQ (GIC_SPI_START + 98) -#define FABRIC_SPS_IRQ (GIC_SPI_START + 99) -#define USB1_HS_IRQ (GIC_SPI_START + 100) -#define SDC4_IRQ_0 (GIC_SPI_START + 101) -#define SDC3_IRQ_0 (GIC_SPI_START + 102) -#define SDC2_IRQ_0 (GIC_SPI_START + 103) -#define SDC1_IRQ_0 (GIC_SPI_START + 104) -#define SPS_BAM_DMA_IRQ (GIC_SPI_START + 105) -#define SPS_SEC_VIOL_IRQ (GIC_SPI_START + 106) -#define SPS_MTI_0 (GIC_SPI_START + 107) -#define SPS_MTI_1 (GIC_SPI_START + 108) -#define SPS_MTI_2 (GIC_SPI_START + 109) -#define SPS_MTI_3 (GIC_SPI_START + 110) -#define GPS_PPS_OUT (GIC_SPI_START + 111) -/* SPI IRQ 112 is unused */ -/* SPI IRQ 113 is unused */ -/* SPI IRQ 114 is unused */ -/* SPI IRQ 115 is unused */ -#define TLMM_MSM_DIR_CONN_IRQ_11 (GIC_SPI_START + 116) -#define TLMM_MSM_DIR_CONN_IRQ_10 (GIC_SPI_START + 117) -#define BAM_DMA1 (GIC_SPI_START + 118) -#define BAM_DMA2 (GIC_SPI_START + 119) -#define SDC1_IRQ (GIC_SPI_START + 120) -#define SDC2_IRQ (GIC_SPI_START + 121) -#define SDC3_IRQ (GIC_SPI_START + 122) -#define SPS_MTI_16 (GIC_SPI_START + 123) -#define SPS_MTI_17 (GIC_SPI_START + 124) -#define SPS_MTI_18 (GIC_SPI_START + 125) -#define SPS_MTI_19 (GIC_SPI_START + 126) -#define SPS_MTI_20 (GIC_SPI_START + 127) -#define SPS_MTI_21 (GIC_SPI_START + 128) -#define SPS_MTI_22 (GIC_SPI_START + 129) -#define SPS_MTI_23 (GIC_SPI_START + 130) -#define SPS_MTI_24 (GIC_SPI_START + 131) -#define SPS_MTI_25 (GIC_SPI_START + 132) -#define SPS_MTI_26 (GIC_SPI_START + 133) -#define SPS_MTI_27 (GIC_SPI_START + 134) -#define SPS_MTI_28 (GIC_SPI_START + 135) -#define SPS_MTI_29 (GIC_SPI_START + 136) -#define SPS_MTI_30 (GIC_SPI_START + 137) -#define SPS_MTI_31 (GIC_SPI_START + 138) -#define CSIPHY_4LN_IRQ (GIC_SPI_START + 139) -#define MSM8930_CSIPHY_2LN_IRQ (GIC_SPI_START + 140) -#define USB2_IRQ (GIC_SPI_START + 141) -#define USB1_IRQ (GIC_SPI_START + 142) -#define TSSC_SSBI_IRQ (GIC_SPI_START + 143) -#define TSSC_SAMPLE_IRQ (GIC_SPI_START + 144) -#define TSSC_PENUP_IRQ (GIC_SPI_START + 145) -#define MSM8930_GSBI1_UARTDM_IRQ (GIC_SPI_START + 146) -#define MSM8930_GSBI1_QUP_IRQ (GIC_SPI_START + 147) -#define MSM8930_GSBI2_UARTDM_IRQ (GIC_SPI_START + 148) -#define MSM8930_GSBI2_QUP_IRQ (GIC_SPI_START + 149) -#define GSBI3_UARTDM_IRQ (GIC_SPI_START + 150) -#define GSBI3_QUP_IRQ (GIC_SPI_START + 151) -#define GSBI4_UARTDM_IRQ (GIC_SPI_START + 152) -#define GSBI4_QUP_IRQ (GIC_SPI_START + 153) -#define GSBI5_UARTDM_IRQ (GIC_SPI_START + 154) -#define GSBI5_QUP_IRQ (GIC_SPI_START + 155) -#define GSBI6_UARTDM_IRQ (GIC_SPI_START + 156) -#define GSBI6_QUP_IRQ (GIC_SPI_START + 157) -#define GSBI7_UARTDM_IRQ (GIC_SPI_START + 158) -#define GSBI7_QUP_IRQ (GIC_SPI_START + 159) -#define GSBI8_UARTDM_IRQ (GIC_SPI_START + 160) -#define GSBI8_QUP_IRQ (GIC_SPI_START + 161) -#define TSIF_TSPP_IRQ (GIC_SPI_START + 162) -#define TSIF_BAM_IRQ (GIC_SPI_START + 163) -#define TSIF2_IRQ (GIC_SPI_START + 164) -#define TSIF1_IRQ (GIC_SPI_START + 165) -/* SPI IRQ 166 is unused */ -#define ISPIF_IRQ (GIC_SPI_START + 167) -#define MSMC_SC_SEC_TMR_IRQ (GIC_SPI_START + 168) -#define MSMC_SC_SEC_WDOG_BARK_IRQ (GIC_SPI_START + 169) -#define ADM_0_SCSS_0_IRQ (GIC_SPI_START + 170) -#define ADM_0_SCSS_1_IRQ (GIC_SPI_START + 171) -#define ADM_0_SCSS_2_IRQ (GIC_SPI_START + 172) -#define ADM_0_SCSS_3_IRQ (GIC_SPI_START + 173) -#define CC_SCSS_WDT1CPU1BITEEXPIRED (GIC_SPI_START + 174) -#define CC_SCSS_WDT1CPU0BITEEXPIRED (GIC_SPI_START + 175) -#define CC_SCSS_WDT0CPU1BITEEXPIRED (GIC_SPI_START + 176) -#define CC_SCSS_WDT0CPU0BITEEXPIRED (GIC_SPI_START + 177) -#define TSENS_UPPER_LOWER_INT (GIC_SPI_START + 178) -#define SSBI2_2_SC_CPU1_SECURE_INT (GIC_SPI_START + 179) -#define SSBI2_2_SC_CPU1_NON_SECURE_INT (GIC_SPI_START + 180) -#define SSBI2_1_SC_CPU1_SECURE_INT (GIC_SPI_START + 181) -#define SSBI2_1_SC_CPU1_NON_SECURE_INT (GIC_SPI_START + 182) -#define XPU_SUMMARY_IRQ (GIC_SPI_START + 183) -#define BUS_EXCEPTION_SUMMARY_IRQ (GIC_SPI_START + 184) -#define HSDDRX_EBI1CH0_IRQ (GIC_SPI_START + 185) -/* SPI IRQ 186 is unused */ -#define SDC5_BAM_IRQ (GIC_SPI_START + 187) -#define SDC5_IRQ_0 (GIC_SPI_START + 188) -#define GSBI9_UARTDM_IRQ (GIC_SPI_START + 189) -#define GSBI9_QUP_IRQ (GIC_SPI_START + 190) -#define GSBI10_UARTDM_IRQ (GIC_SPI_START + 191) -#define GSBI10_QUP_IRQ (GIC_SPI_START + 192) -#define GSBI11_UARTDM_IRQ (GIC_SPI_START + 193) -#define GSBI11_QUP_IRQ (GIC_SPI_START + 194) -#define GSBI12_UARTDM_IRQ (GIC_SPI_START + 195) -#define GSBI12_QUP_IRQ (GIC_SPI_START + 196) -#define RIVA_APSS_LTECOEX_IRQ (GIC_SPI_START + 197) -#define RIVA_APSS_SPARE_IRQ (GIC_SPI_START + 198) -#define RIVA_APSS_WDOG_BITE_RESET_RDY_IRQ (GIC_SPI_START + 199) -#define RIVA_APSS_RESET_DONE_IRQ (GIC_SPI_START + 200) -#define RIVA_APSS_ASIC_IRQ (GIC_SPI_START + 201) -#define RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ (GIC_SPI_START + 202) -#define RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ (GIC_SPI_START + 203) -#define RIVA_APPS_WLAN_SMSM_IRQ (GIC_SPI_START + 204) -#define RIVA_APPS_LOG_CTRL_IRQ (GIC_SPI_START + 205) -#define RIVA_APPS_FM_CTRL_IRQ (GIC_SPI_START + 206) -#define RIVA_APPS_HCI_IRQ (GIC_SPI_START + 207) -#define RIVA_APPS_WLAN_CTRL_IRQ (GIC_SPI_START + 208) -#define A2_BAM_IRQ (GIC_SPI_START + 209) -/* SPI IRQ 210 is unused */ -/* SPI IRQ 211 is unused */ -/* SPI IRQ 212 is unused */ -#define PPSS_WDOG_TIMER_IRQ (GIC_SPI_START + 213) -#define SPS_SLIMBUS_CORE_EE0_IRQ (GIC_SPI_START + 214) -#define SPS_SLIMBUS_BAM_EE0_IRQ (GIC_SPI_START + 215) -#define QDSS_ETB_IRQ (GIC_SPI_START + 216) -#define QDSS_CTI2KPSS_CPU1_IRQ (GIC_SPI_START + 217) -#define QDSS_CTI2KPSS_CPU0_IRQ (GIC_SPI_START + 218) -#define TLMM_MSM_DIR_CONN_IRQ_16 (GIC_SPI_START + 219) -#define TLMM_MSM_DIR_CONN_IRQ_17 (GIC_SPI_START + 220) -#define TLMM_MSM_DIR_CONN_IRQ_18 (GIC_SPI_START + 221) -#define TLMM_MSM_DIR_CONN_IRQ_19 (GIC_SPI_START + 222) -#define TLMM_MSM_DIR_CONN_IRQ_20 (GIC_SPI_START + 223) -#define TLMM_MSM_DIR_CONN_IRQ_21 (GIC_SPI_START + 224) -#define PM8921_SEC_IRQ_104 (GIC_SPI_START + 225) -#define PM8018_SEC_IRQ_107 (GIC_SPI_START + 226) -#define USB_HSIC_IRQ (GIC_SPI_START + 229) -#define CE2_BAM_XPU_IRQ (GIC_SPI_START + 230) -#define CE1_BAM_XPU_IRQ (GIC_SPI_START + 231) -#define GFX3D_VBIF_IRPT (GIC_SPI_START + 232) -#define RBIF_IRQ_0 (GIC_SPI_START + 233) -#define RBIF_IRQ_1 (GIC_SPI_START + 234) -#define RBIF_IRQ_2 (GIC_SPI_START + 235) - -/* Backwards compatible IRQ macros. */ -#define INT_ADM_AARM ADM_0_SCSS_0_IRQ - -/* smd/smsm interrupts */ -#define INT_A9_M2A_0 (GIC_SPI_START + 37) /*MSS_TO_APPS_IRQ_0*/ -#define INT_A9_M2A_5 (GIC_SPI_START + 38) /*MSS_TO_APPS_IRQ_1*/ -#define INT_ADSP_A11 LPASS_SCSS_GP_HIGH_IRQ -#define INT_ADSP_A11_SMSM LPASS_SCSS_GP_MEDIUM_IRQ -#define INT_DSPS_A11 SPS_MTI_31 -#define INT_DSPS_A11_SMSM SPS_MTI_30 -#define INT_WCNSS_A11 RIVA_APSS_SPARE_IRQ -#define INT_WCNSS_A11_SMSM RIVA_APPS_WLAN_SMSM_IRQ - -#endif - diff --git a/arch/arm/mach-msm/include/mach/irqs-9615.h b/arch/arm/mach-msm/include/mach/irqs-9615.h deleted file mode 100644 index 285fce4fc49ea834fe21bc364059803ce63eef38..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/irqs-9615.h +++ /dev/null @@ -1,195 +0,0 @@ -/* Copyright (c) 2011-2012, 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 __ASM_ARCH_MSM_IRQS_9615_H -#define __ASM_ARCH_MSM_IRQS_9615_H - -/* MSM ACPU Interrupt Numbers */ - -#define FIQ_START 16 - -#define INT_DEBUG_TIMER_EXP (GIC_PPI_START + 1) -#define INT_GP_TIMER_EXP (GIC_PPI_START + 2) -#define INT_GP_TIMER2_EXP (GIC_PPI_START + 3) -#define WDT0_ACCSCSSNBARK_INT (GIC_PPI_START + 4) -#define WDT1_ACCSCSSNBARK_INT (GIC_PPI_START + 5) -#define AVS_SVICINT (GIC_PPI_START + 6) -#define AVS_SVICINTSWDONE (GIC_PPI_START + 7) -#define CPU_DBGCPUXCOMMRXFULL (GIC_PPI_START + 8) -#define CPU_DBGCPUXCOMMTXEMPTY (GIC_PPI_START + 9) -#define INT_ARMQC_PERFMON (GIC_PPI_START + 10) -#define SC_AVSCPUXDOWN (GIC_PPI_START + 11) -#define SC_AVSCPUXUP (GIC_PPI_START + 12) -#define SC_SICCPUXACGIRPTREQ (GIC_PPI_START + 13) -#define SC_SICCPUXEXTFAULTIRPTREQ (GIC_PPI_START + 14) -/* PPI 15 is unused */ - -#define APCC_QGICACGIRPTREQ (GIC_SPI_START + 0) -#define APCC_QGICL2PERFMONIRPTREQ (GIC_SPI_START + 1) -#define SC_SICL2PERFMONIRPTREQ APCC_QGICL2PERFMONIRPTREQ -#define APCC_QGICL2IRPTREQ (GIC_SPI_START + 2) -#define APCC_QGICMPUIRPTREQ (GIC_SPI_START + 3) -#define TLMM_MSM_DIR_CONN_IRQ_0 (GIC_SPI_START + 4) -#define TLMM_MSM_DIR_CONN_IRQ_1 (GIC_SPI_START + 5) -#define TLMM_MSM_DIR_CONN_IRQ_2 (GIC_SPI_START + 6) -#define TLMM_MSM_DIR_CONN_IRQ_3 (GIC_SPI_START + 7) -#define TLMM_MSM_DIR_CONN_IRQ_4 (GIC_SPI_START + 8) -#define TLMM_MSM_DIR_CONN_IRQ_5 (GIC_SPI_START + 9) -#define TLMM_MSM_DIR_CONN_IRQ_6 (GIC_SPI_START + 10) -#define TLMM_MSM_DIR_CONN_IRQ_7 (GIC_SPI_START + 11) -#define TLMM_MSM_DIR_CONN_IRQ_8 (GIC_SPI_START + 12) -#define TLMM_MSM_DIR_CONN_IRQ_9 (GIC_SPI_START + 13) -/* 14 Reserved */ -#define PM8018_SEC_IRQ_N (GIC_SPI_START + 15) -#define TLMM_MSM_SUMMARY_IRQ (GIC_SPI_START + 16) -#define SPDM_RT_1_IRQ (GIC_SPI_START + 17) -#define SPDM_DIAG_IRQ (GIC_SPI_START + 18) -#define RPM_APCC_CPU0_GP_HIGH_IRQ (GIC_SPI_START + 19) -#define RPM_APCC_CPU0_GP_MEDIUM_IRQ (GIC_SPI_START + 20) -#define RPM_APCC_CPU0_GP_LOW_IRQ (GIC_SPI_START + 21) -#define RPM_APCC_CPU0_WAKE_UP_IRQ (GIC_SPI_START + 22) -/* 23-28 Reserved */ -#define SSBI2_1_SC_CPU0_SECURE_IRQ (GIC_SPI_START + 29) -#define SSBI2_1_SC_CPU0_NON_SECURE_IRQ (GIC_SPI_START + 30) -/* 31 Reserved */ -#define MSMC_SC_PRI_CE_IRQ (GIC_SPI_START + 32) -#define SLIMBUS0_CORE_EE1_IRQ (GIC_SPI_START + 33) -#define SLIMBUS0_BAM_EE1_IRQ (GIC_SPI_START + 34) -#define Q6FW_WDOG_EXPIRED_IRQ (GIC_SPI_START + 35) -#define Q6SW_WDOG_EXPIRED_IRQ (GIC_SPI_START + 36) -#define MSS_TO_APPS_IRQ_0 (GIC_SPI_START + 37) -#define MSS_TO_APPS_IRQ_1 (GIC_SPI_START + 38) -#define MSS_TO_APPS_IRQ_2 (GIC_SPI_START + 39) -#define MSS_TO_APPS_IRQ_3 (GIC_SPI_START + 40) -#define MSS_TO_APPS_IRQ_4 (GIC_SPI_START + 41) -#define MSS_TO_APPS_IRQ_5 (GIC_SPI_START + 42) -#define MSS_TO_APPS_IRQ_6 (GIC_SPI_START + 43) -#define MSS_TO_APPS_IRQ_7 (GIC_SPI_START + 44) -#define MSS_TO_APPS_IRQ_8 (GIC_SPI_START + 45) -#define MSS_TO_APPS_IRQ_9 (GIC_SPI_START + 46) -/* 47-84 Reserved */ -#define LPASS_SCSS_AUDIO_IF_OUT0_IRQ (GIC_SPI_START + 85) -#define LPASS_SCSS_MIDI_IRQ (GIC_SPI_START + 86) -#define LPASS_Q6SS_WDOG_EXPIRED (GIC_SPI_START + 87) -#define LPASS_SCSS_GP_LOW_IRQ (GIC_SPI_START + 88) -#define LPASS_SCSS_GP_MEDIUM_IRQ (GIC_SPI_START + 89) -#define LPASS_SCSS_GP_HIGH_IRQ (GIC_SPI_START + 90) -#define TOP_IMEM_IRQ (GIC_SPI_START + 91) -#define FABRIC_SYS_IRQ (GIC_SPI_START + 92) -/* 93 Reserved */ -#define USB1_HS_BAM_IRQ (GIC_SPI_START + 94) -/* 95,96 unnamed */ -#define SDC2_BAM_IRQ (GIC_SPI_START + 97) -#define SDC1_BAM_IRQ (GIC_SPI_START + 98) -#define FABRIC_SPS_IRQ (GIC_SPI_START + 99) -#define USB1_HS_IRQ (GIC_SPI_START + 100) -/* 101,102 unnamed */ -#define SDC2_IRQ_0 (GIC_SPI_START + 103) -#define SDC1_IRQ_0 (GIC_SPI_START + 104) -#define SPS_BAM_DMA_IRQ (GIC_SPI_START + 105) -#define SPS_SEC_VIOL_IRQ (GIC_SPI_START + 106) -#define SPS_MTI_0 (GIC_SPI_START + 107) -#define SPS_MTI_1 (GIC_SPI_START + 108) -#define SPS_MTI_2 (GIC_SPI_START + 109) -#define SPS_MTI_3 (GIC_SPI_START + 110) -#define SPS_MTI_4 (GIC_SPI_START + 111) -#define SPS_MTI_5 (GIC_SPI_START + 112) -#define SPS_MTI_6 (GIC_SPI_START + 113) -#define SPS_MTI_7 (GIC_SPI_START + 114) -#define SPS_MTI_8 (GIC_SPI_START + 115) -#define SPS_MTI_9 (GIC_SPI_START + 116) -#define SPS_MTI_10 (GIC_SPI_START + 117) -#define SPS_MTI_11 (GIC_SPI_START + 118) -#define SPS_MTI_12 (GIC_SPI_START + 119) -#define SPS_MTI_13 (GIC_SPI_START + 120) -#define SPS_MTI_14 (GIC_SPI_START + 121) -#define SPS_MTI_15 (GIC_SPI_START + 122) -#define SPS_MTI_16 (GIC_SPI_START + 123) -#define SPS_MTI_17 (GIC_SPI_START + 124) -#define SPS_MTI_18 (GIC_SPI_START + 125) -#define SPS_MTI_19 (GIC_SPI_START + 126) -#define SPS_MTI_20 (GIC_SPI_START + 127) -#define SPS_MTI_21 (GIC_SPI_START + 128) -#define SPS_MTI_22 (GIC_SPI_START + 129) -#define SPS_MTI_23 (GIC_SPI_START + 130) -#define SPS_MTI_24 (GIC_SPI_START + 131) -#define SPS_MTI_25 (GIC_SPI_START + 132) -#define SPS_MTI_26 (GIC_SPI_START + 133) -#define SPS_MTI_27 (GIC_SPI_START + 134) -#define SPS_MTI_28 (GIC_SPI_START + 135) -#define SPS_MTI_29 (GIC_SPI_START + 136) -#define SPS_MTI_30 (GIC_SPI_START + 137) -#define SPS_MTI_31 (GIC_SPI_START + 138) -#define CSIPHY_0_4LN_IRQ (GIC_SPI_START + 139) -#define CSIPHY_1_2LN_IRQ (GIC_SPI_START + 140) -/* 141-145 Reserved */ -#define GSBI1_UARTDM_IRQ (GIC_SPI_START + 146) -#define GSBI1_QUP_IRQ (GIC_SPI_START + 147) -#define GSBI2_UARTDM_IRQ (GIC_SPI_START + 148) -#define GSBI2_QUP_IRQ (GIC_SPI_START + 149) -#define GSBI3_UARTDM_IRQ (GIC_SPI_START + 150) -#define GSBI3_QUP_IRQ (GIC_SPI_START + 151) -#define GSBI4_UARTDM_IRQ (GIC_SPI_START + 152) -#define GSBI4_QUP_IRQ (GIC_SPI_START + 153) -#define GSBI5_UARTDM_IRQ (GIC_SPI_START + 154) -#define GSBI5_QUP_IRQ (GIC_SPI_START + 155) -/* 156-167 Reserved */ -#define MSMC_SC_SEC_TMR_IRQ (GIC_SPI_START + 168) -#define MSMC_SC_SEC_WDOG_BARK_IRQ (GIC_SPI_START + 169) -#define ADM_0_SCSS_0_IRQ (GIC_SPI_START + 170) -#define ADM_0_SCSS_1_IRQ (GIC_SPI_START + 171) -#define ADM_0_SCSS_2_IRQ (GIC_SPI_START + 172) -#define ADM_0_SCSS_3_IRQ (GIC_SPI_START + 173) -/* 174 Reserved */ -#define CC_SCSS_WDT1CPU0BITEEXPIRED (GIC_SPI_START + 175) -/* 176 Reserved */ -#define CC_SCSS_WDT0CPU0BITEEXPIRED (GIC_SPI_START + 177) -#define TSENS_UPPER_LOWER_INT (GIC_SPI_START + 178) -/* 179-182 Reserved */ -#define XPU_SUMMARY_IRQ (GIC_SPI_START + 183) -#define BUS_EXCEPTION_SUMMARY_IRQ (GIC_SPI_START + 184) -#define HSDDRX_EBI1CH0_IRQ (GIC_SPI_START + 185) -/* 186-208 Reserved */ -#define A2_BAM_IRQ (GIC_SPI_START + 209) -/* 210-215 Reserved */ -#define QDSS_ETB_IRQ (GIC_SPI_START + 216) -/* 216 Reserved */ -#define QDSS_CTI2KPSS_CPU0_IRQ (GIC_SPI_START + 218) -#define TLMM_MSM_DIR_CONN_IRQ_16 (GIC_SPI_START + 219) -#define TLMM_MSM_DIR_CONN_IRQ_17 (GIC_SPI_START + 220) -#define TLMM_MSM_DIR_CONN_IRQ_18 (GIC_SPI_START + 221) -#define TLMM_MSM_DIR_CONN_IRQ_19 (GIC_SPI_START + 222) -#define TLMM_MSM_DIR_CONN_IRQ_20 (GIC_SPI_START + 223) -#define TLMM_MSM_DIR_CONN_IRQ_21 (GIC_SPI_START + 224) -#define MSM_SPARE0_IRQ (GIC_SPI_START + 225) -#define PMIC_SEC_IRQ_N (GIC_SPI_START + 226) -#define USB_HSIC_BAM_IRQ (GIC_SPI_START + 231) -#define USB_HSIC_IRQ (GIC_SPI_START + 232) - -#define NR_MSM_IRQS 288 -#define NR_GPIO_IRQS 88 -#define NR_PM8018_IRQS 256 -#define NR_WCD9XXX_IRQS 49 -#define NR_TABLA_IRQS NR_WCD9XXX_IRQS -#define NR_BOARD_IRQS (NR_PM8018_IRQS + NR_WCD9XXX_IRQS) -#define NR_MSM_GPIOS NR_GPIO_IRQS - -/* Backwards compatible IRQ macros. */ -#define INT_ADM_AARM ADM_0_SCSS_0_IRQ - -/* smd/smsm interrupts */ -#define INT_A9_M2A_0 MSS_TO_APPS_IRQ_0 -#define INT_A9_M2A_5 MSS_TO_APPS_IRQ_1 -#define INT_ADSP_A11 LPASS_SCSS_GP_HIGH_IRQ -#define INT_ADSP_A11_SMSM LPASS_SCSS_GP_MEDIUM_IRQ - -#endif diff --git a/arch/arm/mach-msm/include/mach/irqs-9625.h b/arch/arm/mach-msm/include/mach/irqs-9625.h deleted file mode 100644 index 81f22188d5e144949ac823c178fdd185642f8e1a..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/irqs-9625.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (c) 2012, 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 __ASM_ARCH_MSM_IRQS_9625_H -#define __ASM_ARCH_MSM_IRQS_9625_H - -/* MSM ACPU Interrupt Numbers */ - -#define APCC_QGICL2PERFMONIRPTREQ (GIC_SPI_START + 1) -#define SC_SICL2PERFMONIRPTREQ APCC_QGICL2PERFMONIRPTREQ - -#define NR_TLMM_MSM_DIR_CONN_IRQ 8 /*Need to Verify this Count*/ - -#endif diff --git a/arch/arm/mach-msm/include/mach/irqs-fsm9xxx.h b/arch/arm/mach-msm/include/mach/irqs-fsm9xxx.h deleted file mode 100644 index 5b36bdea197e55b6e461ef34645cef5e2fde8040..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/irqs-fsm9xxx.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 2010-2012, 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 __ASM_ARCH_MSM_IRQS_FSM9XXX_H -#define __ASM_ARCH_MSM_IRQS_FSM9XXX_H - -/* MSM ACPU Interrupt Numbers */ - -#define INT_DEBUG_TIMER_EXP 0 -#define INT_GPT0_TIMER_EXP 1 -#define INT_GPT1_TIMER_EXP 2 -#define INT_WDT0_ACCSCSSBARK 3 -#define INT_WDT1_ACCSCSSBARK 4 -#define INT_AVS_SVIC 5 -#define INT_AVS_SVIC_SW_DONE 6 -#define INT_SC_DBG_RX_FULL 7 -#define INT_SC_DBG_TX_EMPTY 8 -#define INT_ARMQC_PERFMON 9 -#define INT_AVS_REQ_DOWN 10 -#define INT_AVS_REQ_UP 11 -#define INT_SC_ACG 12 -/* SCSS_VICFIQSTS0[13:15] are RESERVED */ -#define INT_BPU_CPU 16 -#define INT_L2_SVICDMANSIRPTREQ 17 -#define INT_L2_SVICDMASIRPTREQ 18 -#define INT_L2_SVICSLVIRPTREQ 19 -#define INT_SEAWOLF_IRQ0 20 -#define INT_SEAWOLF_IRQ1 21 -#define INT_SEAWOLF_IRQ2 22 -#define INT_SEAWOLF_IRQ3 23 -#define INT_CARIBE_SUPSS_IRQ 24 -#define INT_ADM_SEC0_IRQ 25 -/* SCSS_VICFIQSTS0[26] is RESERVED */ -#define INT_GMII_PHY 27 -#define INT_SBD_IRQ 28 -#define INT_HH_SUPSS_IRQ 29 -#define INT_EMAC_SBD_IRQ 30 -#define INT_PERPH_SUPSS_IRQ 31 - -#define INT_Q6_SW_IRQ_0 (32 + 0) -#define INT_Q6_SW_IRQ_1 (32 + 1) -#define INT_Q6_SW_IRQ_2 (32 + 2) -#define INT_Q6_SW_IRQ_3 (32 + 3) -#define INT_Q6_SW_IRQ_4 (32 + 4) -#define INT_Q6_SW_IRQ_5 (32 + 5) -#define INT_Q6_SW_IRQ_6 (32 + 6) -#define INT_Q6_SW_IRQ_7 (32 + 7) -#define INT_IMEM_IRQ (32 + 8) -#define INT_IMEM_ECC_IRQ (32 + 9) -#define INT_HSDDRX_IRQ (32 + 10) -#define INT_BUFMEM_XPU_IRQ (32 + 11) -#define INT_A9_M2A_0 (32 + 12) -#define INT_A9_M2A_1 (32 + 13) -#define INT_A9_M2A_2 (32 + 14) -#define INT_A9_M2A_3 (32 + 15) -#define INT_A9_M2A_4 (32 + 16) -#define INT_A9_M2A_5 (32 + 17) -#define INT_A9_M2A_6 (32 + 18) -#define INT_A9_M2A_7 (32 + 19) -#define INT_SC_PRI_IRQ (32 + 20) -#define INT_SC_SEC_IRQ (32 + 21) -#define INT_Q6_WDOG_IRQ (32 + 22) -#define INT_ADM_SEC3_IRQ (32 + 23) -#define INT_ARM_WAKE_IRQ (32 + 24) -#define INT_ARM_WDOG_IRQ (32 + 25) -#define INT_SUPSS_CFG_XPU_IRQ (32 + 26) -#define INT_SPB_XPU_IRQ (32 + 27) -#define INT_FPB_XPU_IRQ (32 + 28) -#define INT_Q6_XPU_IRQ (32 + 29) -/* SCSS_VICFIQSTS1[30:31] are RESERVED */ -/* SCSS_VICFIQSTS2[0:31] are RESERVED */ -/* SCSS_VICFIQSTS3[0:31] are RESERVED */ - -/* Retrofit universal macro names */ -#define INT_ADM_AARM INT_ADM_SEC3_IRQ -#define INT_GP_TIMER_EXP INT_GPT0_TIMER_EXP -#define INT_ADSP_A11 INT_Q6_SW_IRQ_0 -#define INT_ADSP_A11_SMSM INT_ADSP_A11 -#define INT_SIRC_0 INT_PERPH_SUPSS_IRQ -#define WDT0_ACCSCSSNBARK_INT INT_WDT0_ACCSCSSBARK - -#define NR_MSM_IRQS 128 -#define NR_GPIO_IRQS 0 -#define PMIC8058_IRQ_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_SIRC_IRQS) -#define NR_PMIC8058_IRQS 256 -#define NR_BOARD_IRQS (NR_SIRC_IRQS + NR_PMIC8058_IRQS) - -#define NR_MSM_GPIOS 168 - -#endif /* __ASM_ARCH_MSM_IRQS_FSM9XXX_H */ diff --git a/arch/arm/mach-msm/include/mach/irqs.h b/arch/arm/mach-msm/include/mach/irqs.h index 65d5d02863279a8d28f950719507e4447450c568..85e2d0bd8b4ae54ab936232a42a617bf0af820f1 100644 --- a/arch/arm/mach-msm/include/mach/irqs.h +++ b/arch/arm/mach-msm/include/mach/irqs.h @@ -37,19 +37,14 @@ #include "irqs-8092.h" #endif -#elif defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_APQ8064) || \ +#elif defined(CONFIG_ARCH_APQ8064) || \ defined(CONFIG_ARCH_MSM8930) -#ifdef CONFIG_ARCH_MSM8960 -#include "irqs-8960.h" -#endif #ifdef CONFIG_ARCH_MSM8930 -#include "irqs-8930.h" #endif #ifdef CONFIG_ARCH_APQ8064 -#include "irqs-8064.h" #endif /* For now, use the maximum number of interrupts until a pending GIC issue @@ -74,28 +69,21 @@ #else #if defined(CONFIG_ARCH_MSM9615) -#include "irqs-9615.h" #elif defined(CONFIG_ARCH_MSM9625) -#include "irqs-9625.h" #elif defined(CONFIG_ARCH_MSM7X30) #include "irqs-7x30.h" #elif defined(CONFIG_ARCH_QSD8X50) #include "irqs-8x50.h" -#include "sirc.h" #elif defined(CONFIG_ARCH_MSM8X60) #include "irqs-8x60.h" #elif defined(CONFIG_ARCH_MSM7X01A) || defined(CONFIG_ARCH_MSM7X25) \ || defined(CONFIG_ARCH_MSM7X27) || defined(CONFIG_ARCH_MSM8625) -#include "irqs-8625.h" -#include "irqs-7xxx.h" #define NR_GPIO_IRQS 133 #define NR_MSM_IRQS 256 #define NR_BOARD_IRQS 256 #define NR_MSM_GPIOS NR_GPIO_IRQS #elif defined(CONFIG_ARCH_FSM9XXX) -#include "irqs-fsm9xxx.h" -#include "sirc.h" #endif #endif diff --git a/arch/arm/mach-msm/include/mach/kgsl.h b/arch/arm/mach-msm/include/mach/kgsl.h deleted file mode 100644 index 2d7e8df5d5631594ab360f6a7c18cab49fa87ec7..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/kgsl.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2012-2013, 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 _ARCH_ARM_MACH_KGSL_H -#define _ARCH_ARM_MACH_KGSL_H - -/* Clock flags to show which clocks should be controled by a given platform */ -#define KGSL_CLK_SRC 0x00000001 -#define KGSL_CLK_CORE 0x00000002 -#define KGSL_CLK_IFACE 0x00000004 -#define KGSL_CLK_MEM 0x00000008 -#define KGSL_CLK_MEM_IFACE 0x00000010 -#define KGSL_CLK_AXI 0x00000020 -#define KGSL_CLK_ALT_MEM_IFACE 0x00000040 - -#define KGSL_MAX_PWRLEVELS 10 - -#define KGSL_CONVERT_TO_MBPS(val) \ - (val*1000*1000U) - -#define KGSL_3D0_REG_MEMORY "kgsl_3d0_reg_memory" -#define KGSL_3D0_SHADER_MEMORY "kgsl_3d0_shader_memory" -#define KGSL_3D0_IRQ "kgsl_3d0_irq" -#define KGSL_2D0_REG_MEMORY "kgsl_2d0_reg_memory" -#define KGSL_2D0_IRQ "kgsl_2d0_irq" -#define KGSL_2D1_REG_MEMORY "kgsl_2d1_reg_memory" -#define KGSL_2D1_IRQ "kgsl_2d1_irq" - -#define ADRENO_CHIPID(_co, _ma, _mi, _pa) \ - ((((_co) & 0xFF) << 24) | \ - (((_ma) & 0xFF) << 16) | \ - (((_mi) & 0xFF) << 8) | \ - ((_pa) & 0xFF)) - -enum kgsl_iommu_context_id { - KGSL_IOMMU_CONTEXT_USER = 0, - KGSL_IOMMU_CONTEXT_PRIV = 1, -}; - -struct kgsl_iommu_ctx { - const char *iommu_ctx_name; - enum kgsl_iommu_context_id ctx_id; -}; - -/* - * struct kgsl_device_iommu_data - Struct holding iommu context data obtained - * from dtsi file - * @iommu_ctxs: Pointer to array of struct hoding context name and id - * @iommu_ctx_count: Number of contexts defined in the dtsi file - * @iommu_halt_enable: Indicated if smmu halt h/w feature is supported - * @physstart: Start of iommu registers physical address - * @physend: End of iommu registers physical address - */ -struct kgsl_device_iommu_data { - const struct kgsl_iommu_ctx *iommu_ctxs; - int iommu_ctx_count; - int iommu_halt_enable; - unsigned int physstart; - unsigned int physend; -}; - -struct kgsl_pwrlevel { - unsigned int gpu_freq; - unsigned int bus_freq; - unsigned int io_fraction; -}; - -struct kgsl_device_platform_data { - struct kgsl_pwrlevel pwrlevel[KGSL_MAX_PWRLEVELS]; - int init_level; - int num_levels; - int (*set_grp_async)(void); - unsigned int idle_timeout; - bool strtstp_sleepwake; - unsigned int clk_map; - unsigned int idle_needed; - unsigned int step_mul; - struct msm_bus_scale_pdata *bus_scale_table; - struct kgsl_device_iommu_data *iommu_data; - int iommu_count; - struct msm_dcvs_core_info *core_info; - struct coresight_device *csdev; - struct coresight_platform_data *coresight_pdata; - unsigned int chipid; -}; - -#endif diff --git a/arch/arm/mach-msm/include/mach/mdm.h b/arch/arm/mach-msm/include/mach/mdm.h deleted file mode 100644 index 9757d31c0bac1fef4f8d7c0a0af8081bdba688cc..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/mdm.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2010-2011, 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 _ARCH_ARM_MACH_MSM_MDM_H -#define _ARXH_ARM_MACH_MSM_MDM_H - - -struct charm_platform_data { - void (*charm_modem_on)(void); - void (*charm_modem_off)(void); -}; - -#define AP2MDM_STATUS 136 -#define MDM2AP_STATUS 134 -#define MDM2AP_WAKEUP 40 -#define MDM2AP_ERRFATAL 133 -#define AP2MDM_ERRFATAL 93 - -#define AP2MDM_PMIC_RESET_N 131 -#define AP2MDM_KPDPWR_N 132 -#define AP2PMIC_TMPNI_CKEN 141 -#define AP2MDM_WAKEUP 135 - -extern void (*charm_intentional_reset)(void); - -#endif diff --git a/arch/arm/mach-msm/include/mach/mpm.h b/arch/arm/mach-msm/include/mach/mpm.h index e76a6a91fff280bb0340ad48ca29007c0d40df62..8c0387ed71e6392d1fc455420f45577323a4fca3 100644 --- a/arch/arm/mach-msm/include/mach/mpm.h +++ b/arch/arm/mach-msm/include/mach/mpm.h @@ -38,7 +38,7 @@ extern struct msm_mpm_device_data apq8064_mpm_dev_data; void msm_mpm_irq_extn_init(struct msm_mpm_device_data *mpm_data); -#if defined(CONFIG_MSM_MPM) || defined(CONFIG_MSM_MPM_OF) +#if defined(CONFIG_MSM_MPM_OF) /** * msm_mpm_enable_pin() - Enable/Disable a MPM pin for idle wakeups. * diff --git a/arch/arm/mach-msm/include/mach/mpp.h b/arch/arm/mach-msm/include/mach/mpp.h index 040312c8492fb351745a8881c8502b0600a6fda9..1198fd3c972ee8ef95da5a1feee3e8440df27598 100644 --- a/arch/arm/mach-msm/include/mach/mpp.h +++ b/arch/arm/mach-msm/include/mach/mpp.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2010, The Linux Foundation. All rights reserved. +/* Copyright (c) 2008-2013, 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 @@ -14,11 +14,7 @@ #ifndef __ARCH_ARM_MACH_MSM_MPP_H #define __ARCH_ARM_MACH_MSM_MPP_H -#ifdef CONFIG_PMIC8058 -#define MPPS 12 -#else #define MPPS 22 -#endif /* Digital Logical Output Level */ enum { @@ -57,27 +53,17 @@ int mpp_config_digital_in(unsigned mpp, unsigned config); /* PM8058/PM8901 definitions */ /* APIs */ -#ifdef CONFIG_PMIC8058 -int pm8058_mpp_config(unsigned mpp, unsigned type, unsigned level, - unsigned control); -#else static inline int pm8058_mpp_config(unsigned mpp, unsigned type, unsigned level, unsigned control) { return -EINVAL; } -#endif -#ifdef CONFIG_PMIC8901 -int pm8901_mpp_config(unsigned mpp, unsigned type, unsigned level, - unsigned control); -#else static inline int pm8901_mpp_config(unsigned mpp, unsigned type, unsigned level, unsigned control) { return -EINVAL; } -#endif /* MPP Type: type */ #define PM_MPP_TYPE_D_INPUT 0 diff --git a/arch/arm/mach-msm/include/mach/msm_adsp.h b/arch/arm/mach-msm/include/mach/msm_adsp.h deleted file mode 100644 index 07974471b80e2fc6546b51b75da5081700aecc3d..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_adsp.h +++ /dev/null @@ -1,112 +0,0 @@ -/* include/asm-arm/arch-msm/msm_adsp.h - * - * Copyright (C) 2008 Google, Inc. - * Copyright (c) 2009-2010, 2012 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __ASM__ARCH_MSM_ADSP_H -#define __ASM__ARCH_MSM_ADSP_H - -struct msm_adsp_module; - -struct msm_adsp_ops { - /* event is called from interrupt context when a message - * arrives from the DSP. Use the provided function pointer - * to copy the message into a local buffer. Do NOT call - * it multiple times. - */ - void (*event)(void *driver_data, unsigned id, size_t len, - void (*getevent)(void *ptr, size_t len)); -}; - -/* Get, Put, Enable, and Disable are synchronous and must only - * be called from thread context. Enable and Disable will block - * up to one second in the event of a fatal DSP error but are - * much faster otherwise. - */ -int msm_adsp_get(const char *name, struct msm_adsp_module **module, - struct msm_adsp_ops *ops, void *driver_data); -void msm_adsp_put(struct msm_adsp_module *module); -int msm_adsp_enable(struct msm_adsp_module *module); -int msm_adsp_disable(struct msm_adsp_module *module); -int msm_adsp_dump(struct msm_adsp_module *module); -int adsp_set_clkrate(struct msm_adsp_module *module, unsigned long clk_rate); -int msm_adsp_disable_event_rsp(struct msm_adsp_module *module); -int32_t get_adsp_resource(unsigned short client_idx, - void *cmd_buf, size_t cmd_size); -int32_t put_adsp_resource(unsigned short client_idx, - void *cmd_buf, size_t cmd_size); - -/* Write is safe to call from interrupt context. - */ -int msm_adsp_write(struct msm_adsp_module *module, - unsigned queue_id, - void *data, size_t len); - -/*Explicitly gererate adsp event */ -int msm_adsp_generate_event(void *data, - struct msm_adsp_module *mod, - unsigned event_id, - unsigned event_length, - unsigned event_size, - void *msg); - -#define ADSP_MESSAGE_ID 0xFFFF - -/* Command Queue Indexes */ -#define QDSP_lpmCommandQueue 0 -#define QDSP_mpuAfeQueue 1 -#define QDSP_mpuGraphicsCmdQueue 2 -#define QDSP_mpuModmathCmdQueue 3 -#define QDSP_mpuVDecCmdQueue 4 -#define QDSP_mpuVDecPktQueue 5 -#define QDSP_mpuVEncCmdQueue 6 -#define QDSP_rxMpuDecCmdQueue 7 -#define QDSP_rxMpuDecPktQueue 8 -#define QDSP_txMpuEncQueue 9 -#define QDSP_uPAudPPCmd1Queue 10 -#define QDSP_uPAudPPCmd2Queue 11 -#define QDSP_uPAudPPCmd3Queue 12 -#define QDSP_uPAudPlay0BitStreamCtrlQueue 13 -#define QDSP_uPAudPlay1BitStreamCtrlQueue 14 -#define QDSP_uPAudPlay2BitStreamCtrlQueue 15 -#define QDSP_uPAudPlay3BitStreamCtrlQueue 16 -#define QDSP_uPAudPlay4BitStreamCtrlQueue 17 -#define QDSP_uPAudPreProcCmdQueue 18 -#define QDSP_uPAudRecBitStreamQueue 19 -#define QDSP_uPAudRecCmdQueue 20 -#define QDSP_uPDiagQueue 21 -#define QDSP_uPJpegActionCmdQueue 22 -#define QDSP_uPJpegCfgCmdQueue 23 -#define QDSP_uPVocProcQueue 24 -#define QDSP_vfeCommandQueue 25 -#define QDSP_vfeCommandScaleQueue 26 -#define QDSP_vfeCommandTableQueue 27 -#define QDSP_vfeFtmCmdQueue 28 -#define QDSP_vfeFtmCmdScaleQueue 29 -#define QDSP_vfeFtmCmdTableQueue 30 -#define QDSP_uPJpegFtmCfgCmdQueue 31 -#define QDSP_uPJpegFtmActionCmdQueue 32 -#define QDSP_apuAfeQueue 33 -#define QDSP_mpuRmtQueue 34 -#define QDSP_uPAudPreProcAudRecCmdQueue 35 -#define QDSP_uPAudRec0BitStreamQueue 36 -#define QDSP_uPAudRec0CmdQueue 37 -#define QDSP_uPAudRec1BitStreamQueue 38 -#define QDSP_uPAudRec1CmdQueue 39 -#define QDSP_apuRmtQueue 40 -#define QDSP_uPAudRec2BitStreamQueue 41 -#define QDSP_uPAudRec2CmdQueue 42 -#define QDSP_MAX_NUM_QUEUES 43 - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_audio_aac.h b/arch/arm/mach-msm/include/mach/msm_audio_aac.h deleted file mode 100644 index ac541738232dceea160e7e102835cd0e6db43ee9..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_audio_aac.h +++ /dev/null @@ -1,71 +0,0 @@ -/* arch/arm/mach-msm/include/mach/msm_audio_aac.h - * - * Copyright (c) 2009 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 __MSM_AUDIO_AAC_H -#define __MSM_AUDIO_AAC_H - -#include - -#define AUDIO_SET_AAC_CONFIG _IOW(AUDIO_IOCTL_MAGIC, \ - (AUDIO_MAX_COMMON_IOCTL_NUM+0), unsigned) -#define AUDIO_GET_AAC_CONFIG _IOR(AUDIO_IOCTL_MAGIC, \ - (AUDIO_MAX_COMMON_IOCTL_NUM+1), unsigned) - -#define AUDIO_AAC_FORMAT_ADTS -1 -#define AUDIO_AAC_FORMAT_RAW 0x0000 -#define AUDIO_AAC_FORMAT_PSUEDO_RAW 0x0001 -#define AUDIO_AAC_FORMAT_LOAS 0x0002 - -#define AUDIO_AAC_OBJECT_LC 0x0002 -#define AUDIO_AAC_OBJECT_LTP 0x0004 -#define AUDIO_AAC_OBJECT_ERLC 0x0011 - -#define AUDIO_AAC_SEC_DATA_RES_ON 0x0001 -#define AUDIO_AAC_SEC_DATA_RES_OFF 0x0000 - -#define AUDIO_AAC_SCA_DATA_RES_ON 0x0001 -#define AUDIO_AAC_SCA_DATA_RES_OFF 0x0000 - -#define AUDIO_AAC_SPEC_DATA_RES_ON 0x0001 -#define AUDIO_AAC_SPEC_DATA_RES_OFF 0x0000 - -#define AUDIO_AAC_SBR_ON_FLAG_ON 0x0001 -#define AUDIO_AAC_SBR_ON_FLAG_OFF 0x0000 - -#define AUDIO_AAC_SBR_PS_ON_FLAG_ON 0x0001 -#define AUDIO_AAC_SBR_PS_ON_FLAG_OFF 0x0000 - -/* Primary channel on both left and right channels */ -#define AUDIO_AAC_DUAL_MONO_PL_PR 0 -/* Secondary channel on both left and right channels */ -#define AUDIO_AAC_DUAL_MONO_SL_SR 1 -/* Primary channel on right channel and 2nd on left channel */ -#define AUDIO_AAC_DUAL_MONO_SL_PR 2 -/* 2nd channel on right channel and primary on left channel */ -#define AUDIO_AAC_DUAL_MONO_PL_SR 3 - -struct msm_audio_aac_config { - signed short format; - unsigned short audio_object; - unsigned short ep_config; /* 0 ~ 3 useful only obj = ERLC */ - unsigned short aac_section_data_resilience_flag; - unsigned short aac_scalefactor_data_resilience_flag; - unsigned short aac_spectral_data_resilience_flag; - unsigned short sbr_on_flag; - unsigned short sbr_ps_on_flag; - unsigned short dual_mono_mode; - unsigned short channel_configuration; -}; - -#endif /* __MSM_AUDIO_AAC_H */ diff --git a/arch/arm/mach-msm/include/mach/msm_battery.h b/arch/arm/mach-msm/include/mach/msm_battery.h deleted file mode 100644 index 959d8a877e5fe0cffc444bebf2e3b9b8f5627042..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_battery.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2009, 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 __MSM_BATTERY_H__ -#define __MSM_BATTERY_H__ - -#define AC_CHG 0x00000001 -#define USB_CHG 0x00000002 - -struct msm_psy_batt_pdata { - u32 voltage_max_design; - u32 voltage_min_design; - u32 voltage_fail_safe; - u32 avail_chg_sources; - u32 batt_technology; - u32 (*calculate_capacity)(u32 voltage); -}; - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_dcvs.h b/arch/arm/mach-msm/include/mach/msm_dcvs.h deleted file mode 100644 index 2ad7d22f7212448092d58f3923afd17391f02e9c..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_dcvs.h +++ /dev/null @@ -1,177 +0,0 @@ -/* Copyright (c) 2012, 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 _ARCH_ARM_MACH_MSM_MSM_DCVS_H -#define _ARCH_ARM_MACH_MSM_MSM_DCVS_H - -#include - -#define CORE_NAME_MAX (32) -#define CORES_MAX (10) - -#define CPU_OFFSET 1 /* used to notify TZ the core number */ -#define GPU_OFFSET (CORES_MAX * 2/3) /* there will be more cpus than gpus, - * let the GPU be assigned fewer core - * elements and start later - */ - -enum msm_core_idle_state { - MSM_DCVS_IDLE_ENTER, - MSM_DCVS_IDLE_EXIT, -}; - -enum msm_core_control_event { - MSM_DCVS_ENABLE_IDLE_PULSE, - MSM_DCVS_DISABLE_IDLE_PULSE, - MSM_DCVS_ENABLE_HIGH_LATENCY_MODES, - MSM_DCVS_DISABLE_HIGH_LATENCY_MODES, -}; - -struct msm_dcvs_sync_rule { - unsigned long cpu_khz; - unsigned long gpu_floor_khz; -}; - -struct msm_dcvs_platform_data { - struct msm_dcvs_sync_rule *sync_rules; - unsigned num_sync_rules; - unsigned long gpu_max_nom_khz; -}; - -struct msm_gov_platform_data { - struct msm_dcvs_core_info *info; - int latency; -}; - -/** - * msm_dcvs_register_cpu_freq - * @freq: the frequency value to register - * @voltage: the operating voltage (in mV) associated with the above frequency - * - * Register a cpu frequency and its operating voltage with dcvs. - */ -#ifdef CONFIG_MSM_DCVS -void msm_dcvs_register_cpu_freq(uint32_t freq, uint32_t voltage); -#else -static inline void msm_dcvs_register_cpu_freq(uint32_t freq, uint32_t voltage) -{} -#endif - -/** - * msm_dcvs_idle - * @dcvs_core_id: The id returned by msm_dcvs_register_core - * @state: The enter/exit idle state the core is in - * @iowaited: iowait in us - * on iMSM_DCVS_IDLE_EXIT. - * @return: - * 0 on success, - * -ENOSYS, - * -EINVAL, - * SCM return values - * - * Send idle state notifications to the msm_dcvs driver - */ -int msm_dcvs_idle(int dcvs_core_id, enum msm_core_idle_state state, - uint32_t iowaited); - -/** - * struct msm_dcvs_core_info - * - * Core specific information used by algorithm. Need to provide this - * before the sink driver can be registered. - */ -struct msm_dcvs_core_info { - int num_cores; - int *sensors; - int thermal_poll_ms; - struct msm_dcvs_freq_entry *freq_tbl; - struct msm_dcvs_core_param core_param; - struct msm_dcvs_algo_param algo_param; - struct msm_dcvs_energy_curve_coeffs energy_coeffs; - struct msm_dcvs_power_params power_param; -}; - -/** - * msm_dcvs_register_core - * @type: whether this is a CPU or a GPU - * @type_core_num: The number of the core for a type - * @info: The core specific algorithm parameters. - * @sensor: The thermal sensor number of the core in question - * @return : - * 0 on success, - * -ENOSYS, - * -ENOMEM - * - * Register the core with msm_dcvs driver. Done once at init before calling - * msm_dcvs_freq_sink_register - * Cores that need to run synchronously must share the same group id. - */ -extern int msm_dcvs_register_core( - enum msm_dcvs_core_type type, - int type_core_num, - struct msm_dcvs_core_info *info, - int (*set_frequency)(int type_core_num, unsigned int freq), - unsigned int (*get_frequency)(int type_core_num), - int (*idle_enable)(int type_core_num, - enum msm_core_control_event event), - int (*set_floor_frequency)(int type_core_num, unsigned int freq), - int sensor); - -/** - * msm_dcvs_freq_sink_start - * @drv: The sink driver - * @return: Handle unique to the core. - * - * Register the clock driver code with the msm_dvs driver to get notified about - * frequency change requests. - */ -extern int msm_dcvs_freq_sink_start(int dcvs_core_id); - -/** - * msm_dcvs_freq_sink_stop - * @drv: The sink driver - * @return: - * 0 on success, - * -EINVAL - * - * Unregister the sink driver for the core. This will cause the source driver - * for the core to stop sending idle pulses. - */ -extern int msm_dcvs_freq_sink_stop(int dcvs_core_id); - -/** - * msm_dcvs_update_limits - * @drv: The sink driver - * - * Update the frequency known to dcvs when the limits are changed. - */ -extern void msm_dcvs_update_limits(int dcvs_core_id); - -/** - * msm_dcvs_apply_gpu_floor - * @cpu_freq: CPU frequency to compare to GPU sync rules - * - * Apply a GPU floor frequency if the corresponding CPU frequency, - * or the number of CPUs online, requires it. - */ -extern void msm_dcvs_apply_gpu_floor(unsigned long cpu_freq); - -/** - * msm_dcvs_update_algo_params - * @return: - * 0 on success, < 0 on error - * - * Updates the DCVS algorithm with parameters depending on the - * number of CPUs online. - */ -extern int msm_dcvs_update_algo_params(void); -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_dcvs_scm.h b/arch/arm/mach-msm/include/mach/msm_dcvs_scm.h deleted file mode 100644 index 7eefd549051b5e5466c7b82eb165a2b2d91230b0..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_dcvs_scm.h +++ /dev/null @@ -1,262 +0,0 @@ -/* Copyright (c) 2012, 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 _ARCH_ARM_MACH_MSM_MSM_DCVS_SCM_H -#define _ARCH_ARM_MACH_MSM_MSM_DCVS_SCM_H - -enum msm_dcvs_core_type { - MSM_DCVS_CORE_TYPE_CPU = 0, - MSM_DCVS_CORE_TYPE_GPU = 1, -}; - -enum msm_dcvs_algo_param_type { - MSM_DCVS_ALGO_DCVS_PARAM = 0, - MSM_DCVS_ALGO_MPD_PARAM = 1, -}; - -enum msm_dcvs_scm_event { - MSM_DCVS_SCM_IDLE_ENTER = 0, /* Core enters idle */ - MSM_DCVS_SCM_IDLE_EXIT = 1, /* Core exits idle */ - MSM_DCVS_SCM_QOS_TIMER_EXPIRED = 2, /* Core slack timer expired */ - MSM_DCVS_SCM_CLOCK_FREQ_UPDATE = 3, /* Core freq change complete */ - MSM_DCVS_SCM_CORE_ONLINE = 4, /* Core is online */ - MSM_DCVS_SCM_CORE_OFFLINE = 5, /* Core is offline */ - MSM_DCVS_SCM_CORE_UNAVAILABLE = 6, /* Core is offline + unavailable */ - MSM_DCVS_SCM_DCVS_ENABLE = 7, /* DCVS is enabled/disabled for core */ - MSM_DCVS_SCM_MPD_ENABLE = 8, /* Enable/disable MP Decision */ - MSM_DCVS_SCM_RUNQ_UPDATE = 9, /* Update running threads */ - MSM_DCVS_SCM_MPD_QOS_TIMER_EXPIRED = 10, /* MPDecision slack timer */ -}; - -struct msm_dcvs_algo_param { - uint32_t disable_pc_threshold; - uint32_t em_win_size_min_us; - uint32_t em_win_size_max_us; - uint32_t em_max_util_pct; - uint32_t group_id; - uint32_t max_freq_chg_time_us; - uint32_t slack_mode_dynamic; - uint32_t slack_time_min_us; - uint32_t slack_time_max_us; - uint32_t slack_weight_thresh_pct; - uint32_t ss_no_corr_below_freq; - uint32_t ss_win_size_min_us; - uint32_t ss_win_size_max_us; - uint32_t ss_util_pct; -}; - -struct msm_dcvs_freq_entry { - uint32_t freq; - uint32_t voltage; - uint32_t is_trans_level; - uint32_t active_energy_offset; - uint32_t leakage_energy_offset; -}; - -struct msm_dcvs_energy_curve_coeffs { - int32_t active_coeff_a; - int32_t active_coeff_b; - int32_t active_coeff_c; - - int32_t leakage_coeff_a; - int32_t leakage_coeff_b; - int32_t leakage_coeff_c; - int32_t leakage_coeff_d; -}; - -struct msm_dcvs_power_params { - uint32_t current_temp; - uint32_t num_freq; /* number of msm_dcvs_freq_entry passed */ -}; - -struct msm_dcvs_core_param { - uint32_t core_type; - uint32_t core_bitmask_id; -}; - -struct msm_mpd_algo_param { - uint32_t em_win_size_min_us; - uint32_t em_win_size_max_us; - uint32_t em_max_util_pct; - uint32_t mp_em_rounding_point_min; - uint32_t mp_em_rounding_point_max; - uint32_t online_util_pct_min; - uint32_t online_util_pct_max; - uint32_t slack_time_min_us; - uint32_t slack_time_max_us; -}; - -#ifdef CONFIG_MSM_DCVS -/** - * Initialize DCVS algorithm in TrustZone. - * Must call before invoking any other DCVS call into TZ. - * - * @size: Size of buffer in bytes - * - * @return: - * 0 on success. - * -EEXIST: DCVS algorithm already initialized. - * -EINVAL: Invalid args. - */ -extern int msm_dcvs_scm_init(size_t size); - -/** - * Registers cores with the DCVS algo. - * - * @core_id: The core identifier that will be used for communication with DCVS - * @param: The core parameters - * @freq: Array of frequency and energy values - * - * @return: - * 0 on success. - * -ENOMEM: Insufficient memory. - * -EINVAL: Invalid args. - */ -extern int msm_dcvs_scm_register_core(uint32_t core_id, - struct msm_dcvs_core_param *param); - -/** - * Set DCVS algorithm parameters - * - * @core_id: The algorithm parameters specific for the core - * @param: The param data structure - * - * @return: - * 0 on success. - * -EINVAL: Invalid args. - */ -extern int msm_dcvs_scm_set_algo_params(uint32_t core_id, - struct msm_dcvs_algo_param *param); - -/** - * Set MPDecision algorithm parameters - * - * @param: The param data structure - * 0 on success. - * -EINVAL: Invalid args. - */ -extern int msm_mpd_scm_set_algo_params(struct msm_mpd_algo_param *param); - -/** - * Set frequency and power characteristics for the core. - * - * @param core_id: The core identifier that will be used to interace with the - * DCVS algo. - * @param pwr_param: power params - * @param freq_entry: frequency characteristics desired - * @param coeffs: Coefficients that will describe the power curve - * - * @return int - * 0 on success. - * -EINVAL: Invalid args. - */ -extern int msm_dcvs_scm_set_power_params(uint32_t core_id, - struct msm_dcvs_power_params *pwr_param, - struct msm_dcvs_freq_entry *freq_entry, - struct msm_dcvs_energy_curve_coeffs *coeffs); - -/** - * Do an SCM call. - * - * @core_id: The core identifier. - * @event_id: The event that occured. - * Possible values: - * MSM_DCVS_SCM_IDLE_ENTER - * @param0: unused - * @param1: unused - * @ret0: unused - * @ret1: unused - * MSM_DCVS_SCM_IDLE_EXIT - * @param0: Did the core iowait - * @param1: unused - * @ret0: New clock frequency for the core in KHz - * @ret1: New QoS timer value for the core in usec - * MSM_DCVS_SCM_QOS_TIMER_EXPIRED - * @param0: unused - * @param1: unused - * @ret0: New clock frequency for the core in KHz - * @ret1: unused - * MSM_DCVS_SCM_CLOCK_FREQ_UPDATE - * @param0: active clock frequency of the core in KHz - * @param1: time taken in usec to switch to the frequency - * @ret0: New QoS timer value for the core in usec - * @ret1: unused - * MSM_DCVS_SCM_CORE_ONLINE - * @param0: active clock frequency of the core in KHz - * @param1: time taken to online the core - * @ret0: unused - * @ret1: unused - * MSM_DCVS_SCM_CORE_OFFLINE - * @param0: time taken to offline the core - * @param1: unused - * @ret0: unused - * @ret1: unused - * MSM_DCVS_SCM_CORE_UNAVAILABLE - * @param0: TODO:bitmask - * @param1: unused - * @ret0: Bitmask of cores to bring online/offline. - * @ret1: Mp Decision slack time. Common to all cores. - * MSM_DCVS_SCM_DCVS_ENABLE - * @param0: 1 to enable; 0 to disable DCVS - * @param1: unused - * @ret0: New clock frequency for the core in KHz - * @ret1: unused - * MSM_DCVS_SCM_MPD_ENABLE - * @param0: 1 to enable; 0 to disable MP Decision - * @param1: unused - * @ret0: unused - * @ret1: unused - * MSM_DCVS_SCM_RUNQ_UPDATE - * @param0: run q value - * @param1: unused - * @ret0: Bitmask of cores online - * @ret1: New QoS timer for MP Decision (usec) - * MSM_DCVS_SCM_MPD_QOS_TIMER_EXPIRED - * @param0: unused - * @param1: unused - * @ret0: Bitmask of cores online - * @ret1: New QoS timer for MP Decision (usec) - * @return: - * 0 on success, - * SCM return values - */ -extern int msm_dcvs_scm_event(uint32_t core_id, - enum msm_dcvs_scm_event event_id, - uint32_t param0, uint32_t param1, - uint32_t *ret0, uint32_t *ret1); - -#else -static inline int msm_dcvs_scm_init(uint32_t phy, size_t bytes) -{ return -ENOSYS; } -static inline int msm_dcvs_scm_register_core(uint32_t core_id, - struct msm_dcvs_core_param *param, - struct msm_dcvs_freq_entry *freq) -{ return -ENOSYS; } -static inline int msm_dcvs_scm_set_algo_params(uint32_t core_id, - struct msm_dcvs_algo_param *param) -{ return -ENOSYS; } -static inline int msm_mpd_scm_set_algo_params( - struct msm_mpd_algo_param *param) -{ return -ENOSYS; } -static inline int msm_dcvs_set_power_params(uint32_t core_id, - struct msm_dcvs_power_params *pwr_param, - struct msm_dcvs_freq_entry *freq_entry, - struct msm_dcvs_energy_curve_coeffs *coeffs) -{ return -ENOSYS; } -static inline int msm_dcvs_scm_event(uint32_t core_id, - enum msm_dcvs_scm_event event_id, - uint32_t param0, uint32_t param1, - uint32_t *ret0, uint32_t *ret1) -{ return -ENOSYS; } -#endif - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_dsps.h b/arch/arm/mach-msm/include/mach/msm_dsps.h deleted file mode 100644 index 8e77f0748f053df83c0d9be3cbe9259ecd9ade5b..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_dsps.h +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) 2011-2012, 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 _MSM_DSPS_H_ -#define _MSM_DSPS_H_ - -#include -#include -#include - -#define DSPS_SIGNATURE 0x12345678 - -/** - * DSPS Clocks Platform data. - * - * @name - clock name. - * @rate - rate to set. zero if not relevant. - * @clock - clock handle, reserved for the driver. - */ -struct dsps_clk_info { - const char *name; - u32 rate; - struct clk *clock; -}; - -/** - * DSPS GPIOs Platform data. - * - * @name - clock name. - * @num - GPIO number. - * @on_val - value to ouptput for ON (depends on polarity). - * @off_val - value to ouptput for OFF (depends on polarity). - * @is_owner - reserved for the driver. - */ -struct dsps_gpio_info { - const char *name; - int num; - int on_val; - int off_val; - int is_owner; -}; - -/** - * DSPS Power regulators Platform data. - * - * @name - regulator name. - * @volt - required voltage (in uV). - * @reg - reserved for the driver. - */ -struct dsps_regulator_info { - const char *name; - int volt; - struct regulator *reg; -}; - -/** - * DSPS Platform data. - * - * @pil_name - peripheral image name - * @clks - array of clocks. - * @clks_num - number of clocks in array. - * @gpios - array of gpios. - * @gpios_num - number of gpios. - * @regs - array of regulators. - * @regs_num - number of regulators. - * @dsps_pwr_ctl_en - to enable DSPS to do power control if set 1 - * otherwise the apps will do power control - * @ppss_pause_reg - Offset to the PPSS_PAUSE register - * @ppss_wdog_unmasked_int_en_reg - Offset to PPSS_WDOG_UNMASKED_INT_EN register - * @signature - signature for validity check. - */ -struct msm_dsps_platform_data { - const char *pil_name; - struct dsps_clk_info *clks; - int clks_num; - struct dsps_gpio_info *gpios; - int gpios_num; - struct dsps_regulator_info *regs; - int regs_num; - int dsps_pwr_ctl_en; - void (*init)(struct msm_dsps_platform_data *data); - int ppss_pause_reg; - int ppss_wdog_unmasked_int_en_reg; - u32 signature; -}; - -#endif /* _MSM_DSPS_H_ */ diff --git a/arch/arm/mach-msm/include/mach/msm_fast_timer.h b/arch/arm/mach-msm/include/mach/msm_fast_timer.h deleted file mode 100644 index e1660c192a3cab583fb683b80d7e6e5272c8f552..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_fast_timer.h +++ /dev/null @@ -1,19 +0,0 @@ -/* arch/arm/mach-msm/include/mach/msm_fast_timer.h - * - * Copyright (C) 2009 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -void msm_enable_fast_timer(void); -void msm_disable_fast_timer(void); -u32 msm_read_fast_timer(void); - diff --git a/arch/arm/mach-msm/include/mach/msm_hdmi_audio.h b/arch/arm/mach-msm/include/mach/msm_hdmi_audio.h deleted file mode 100644 index 9a35c73db5dfe558e3861a816f1b500f4d048654..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_hdmi_audio.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2011-2012, 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 __MSM_HDMI_AUDIO_H -#define __MSM_HDMI_AUDIO_H - -/* Supported HDMI Audio channels */ -#define MSM_HDMI_AUDIO_CHANNEL_2 0 -#define MSM_HDMI_AUDIO_CHANNEL_4 1 -#define MSM_HDMI_AUDIO_CHANNEL_6 2 -#define MSM_HDMI_AUDIO_CHANNEL_8 3 - -#define TRUE 1 -#define FALSE 0 - -enum hdmi_supported_sample_rates { - HDMI_SAMPLE_RATE_32KHZ, - HDMI_SAMPLE_RATE_44_1KHZ, - HDMI_SAMPLE_RATE_48KHZ, - HDMI_SAMPLE_RATE_88_2KHZ, - HDMI_SAMPLE_RATE_96KHZ, - HDMI_SAMPLE_RATE_176_4KHZ, - HDMI_SAMPLE_RATE_192KHZ, - HDMI_SAMPLE_RATE_MAX -}; - -int hdmi_audio_enable(bool on , u32 fifo_water_mark); -int hdmi_audio_packet_enable(bool on); -void hdmi_msm_audio_sample_rate_reset(int rate); -int hdmi_msm_audio_get_sample_rate(void); - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL -int hdmi_msm_audio_info_setup(bool enabled, u32 num_of_channels, - u32 channel_allocation, u32 level_shift, bool down_mix); -#else -static inline int hdmi_msm_audio_info_setup(bool enabled, - u32 num_of_channels, u32 channel_allocation, u32 level_shift, - bool down_mix) -{ - return 0; -} -#endif -#endif /* __MSM_HDMI_AUDIO_H*/ diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-fsm9xxx.h b/arch/arm/mach-msm/include/mach/msm_iomap-fsm9xxx.h deleted file mode 100644 index 9b4204d87e5b48f7f15b0c4249b6f698bf19f5dd..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_iomap-fsm9xxx.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (c) 2010-2012, 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 __ASM_ARCH_MSM_IOMAP_FSM9XXX_H -#define __ASM_ARCH_MSM_IOMAP_FSM9XXX_H - -/* Physical base address and size of peripherals. - * Ordered by the virtual base addresses they will be mapped at. - * - * If you add or remove entries here, you'll want to edit the - * msm_io_desc array in arch/arm/mach-msm/io.c to reflect your - * changes. - * - */ - -#define MSM_VIC_BASE IOMEM(0xFA000000) -#define MSM_VIC_PHYS 0x9C080000 -#define MSM_VIC_SIZE SZ_4K - -#define MSM_SIRC_BASE IOMEM(0xFA001000) -#define MSM_SIRC_PHYS 0x94190000 -#define MSM_SIRC_SIZE SZ_4K - -#define MSM_CSR_BASE IOMEM(0xFA002000) -#define MSM_CSR_PHYS 0x9C000000 -#define MSM_CSR_SIZE SZ_4K - -#define MSM_TMR_BASE MSM_CSR_BASE - -#define MSM_TLMM_BASE IOMEM(0xFA003000) -#define MSM_TLMM_PHYS 0x94040000 -#define MSM_TLMM_SIZE SZ_4K - -#define MSM_TCSR_BASE IOMEM(0xFA004000) -#define MSM_TCSR_PHYS 0x94030000 -#define MSM_TCSR_SIZE SZ_4K - -#define MSM_CLK_CTL_BASE IOMEM(0xFA005000) -#define MSM_CLK_CTL_PHYS 0x94020000 -#define MSM_CLK_CTL_SIZE SZ_4K - -#define MSM_ACC_BASE IOMEM(0xFA006000) -#define MSM_ACC_PHYS 0x9C001000 -#define MSM_ACC_SIZE SZ_4K - -#define MSM_SAW_BASE IOMEM(0xFA007000) -#define MSM_SAW_PHYS 0x9C002000 -#define MSM_SAW_SIZE SZ_4K - -#define MSM_GCC_BASE IOMEM(0xFA008000) -#define MSM_GCC_PHYS 0x9C082000 -#define MSM_GCC_SIZE SZ_4K - -#define MSM_GRFC_BASE IOMEM(0xFA009000) -#define MSM_GRFC_PHYS 0x94038000 -#define MSM_GRFC_SIZE SZ_4K - -#define MSM_QFP_FUSE_BASE IOMEM(0xFA010000) -#define MSM_QFP_FUSE_PHYS 0x80000000 -#define MSM_QFP_FUSE_SIZE SZ_32K - -#define MSM_HH_BASE IOMEM(0xFA100000) -#define MSM_HH_PHYS 0x94200000 -#define MSM_HH_SIZE SZ_1M - -#define MSM_SHARED_RAM_BASE IOMEM(0xFA200000) -#define MSM_SHARED_RAM_SIZE SZ_1M - -#define MSM_UART1_PHYS 0x94000000 -#define MSM_UART1_SIZE SZ_4K - -#define MSM_UART2_PHYS 0x94010000 -#define MSM_UART2_SIZE SZ_4K - -#define MSM_UART3_PHYS 0x94100000 -#define MSM_UART3_SIZE SZ_4K - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_iomap.h b/arch/arm/mach-msm/include/mach/msm_iomap.h index c1f37d63f0d8512aa0c80d12e923af381a867c77..28560a03759e93a609971351065064d9ab1f4657 100644 --- a/arch/arm/mach-msm/include/mach/msm_iomap.h +++ b/arch/arm/mach-msm/include/mach/msm_iomap.h @@ -52,8 +52,6 @@ #include "msm_iomap-8x50.h" #elif defined(CONFIG_ARCH_MSM8X60) #include "msm_iomap-8x60.h" -#elif defined(CONFIG_ARCH_FSM9XXX) -#include "msm_iomap-fsm9xxx.h" #else /* Unified iomap */ diff --git a/arch/arm/mach-msm/include/mach/msm_migrate_pages.h b/arch/arm/mach-msm/include/mach/msm_migrate_pages.h deleted file mode 100644 index 51d98ba35e34f753d78fa24b11dc2affc278e743..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_migrate_pages.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2010, 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 _MACH_MSM_MIGRATE_PAGES_H_ -#define _MACH_MSM_MIGRATE_PAGES_H_ - -unsigned long get_msm_migrate_pages_status(void); -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_qdsp6_audio.h b/arch/arm/mach-msm/include/mach/msm_qdsp6_audio.h deleted file mode 100644 index da2abe2413aef9608666966da3fa6d3864680407..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_qdsp6_audio.h +++ /dev/null @@ -1,120 +0,0 @@ -/* arch/arm/mach-msm/include/mach/msm_qdsp6_audio.h - * - * Copyright (C) 2009 Google, Inc. - * Author: Brian Swetland - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _MACH_MSM_QDSP6_Q6AUDIO_ -#define _MACH_MSM_QDSP6_Q6AUDIO_ - -#define AUDIO_FLAG_READ 0 -#define AUDIO_FLAG_WRITE 1 -#define AUDIO_FLAG_INCALL_MIXED 2 - -#include - -enum { - DEVICE_UNMUTE = 0, - DEVICE_MUTE, - STREAM_UNMUTE, - STREAM_MUTE, -}; - -struct audio_buffer { - dma_addr_t phys; - void *data; - uint32_t size; - uint32_t used; /* 1 = CPU is waiting for DSP to consume this buf */ - uint32_t actual_size; /* actual number of bytes read by DSP */ -}; - -struct audio_client { - struct audio_buffer buf[2]; - int cpu_buf; /* next buffer the CPU will touch */ - int dsp_buf; /* next buffer the DSP will touch */ - int running; - int session; - - wait_queue_head_t wait; - struct dal_client *client; - - int cb_status; - uint32_t flags; -}; - -/* Obtain a 16bit signed, interleaved audio channel of the specified - * rate (Hz) and channels (1 or 2), with two buffers of bufsz bytes. - */ -struct audio_client *q6audio_open_pcm(uint32_t bufsz, uint32_t rate, - uint32_t channels, uint32_t flags, - uint32_t acdb_id); - -struct audio_client *q6audio_open_auxpcm(uint32_t rate, uint32_t channels, - uint32_t flags, uint32_t acdb_id); - -struct audio_client *q6voice_open(uint32_t flags); - -struct audio_client *q6audio_open_mp3(uint32_t bufsz, uint32_t rate, - uint32_t channels, uint32_t acdb_id); - -struct audio_client *q6audio_open_dtmf(uint32_t rate, uint32_t channels, - uint32_t acdb_id); -int q6audio_play_dtmf(struct audio_client *ac, uint16_t dtmf_hi, - uint16_t dtmf_low, uint16_t duration, uint16_t rx_gain); - -struct audio_client *q6audio_open_aac(uint32_t bufsz, uint32_t samplerate, - uint32_t channels, uint32_t bitrate, - uint32_t stream_format, uint32_t flags, - uint32_t acdb_id); - -struct audio_client *q6audio_open_qcp(uint32_t bufsz, uint32_t min_rate, - uint32_t max_rate, uint32_t flags, - uint32_t format, uint32_t acdb_id); - -struct audio_client *q6audio_open_amrnb(uint32_t bufsz, uint32_t enc_mode, - uint32_t dtx_enable, uint32_t flags, - uint32_t acdb_id); - -int q6audio_close(struct audio_client *ac); -int q6audio_auxpcm_close(struct audio_client *ac); -int q6voice_close(struct audio_client *ac); -int q6audio_mp3_close(struct audio_client *ac); - -int q6audio_read(struct audio_client *ac, struct audio_buffer *ab); -int q6audio_write(struct audio_client *ac, struct audio_buffer *ab); -int q6audio_async(struct audio_client *ac); - -int q6audio_do_routing(uint32_t route, uint32_t acdb_id); -int q6audio_set_tx_mute(int mute); -int q6audio_reinit_acdb(char* filename); -int q6audio_update_acdb(uint32_t id_src, uint32_t id_dst); -int q6audio_set_rx_volume(int level); -int q6audio_set_stream_volume(struct audio_client *ac, int vol); -int q6audio_set_stream_eq_pcm(struct audio_client *ac, void *eq_config); - -struct q6audio_analog_ops { - void (*init)(void); - void (*speaker_enable)(int en); - void (*headset_enable)(int en); - void (*receiver_enable)(int en); - void (*bt_sco_enable)(int en); - void (*int_mic_enable)(int en); - void (*ext_mic_enable)(int en); -}; - -void q6audio_register_analog_ops(struct q6audio_analog_ops *ops); - -/* signal non-recoverable DSP error so we can log and/or panic */ -void q6audio_dsp_not_responding(void); - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_rotator_imem.h b/arch/arm/mach-msm/include/mach/msm_rotator_imem.h deleted file mode 100644 index c027ab766a1d406f157b1fa8660878fcb38aa69f..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_rotator_imem.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2009, 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 __MSM_ROTATOR_IMEM_H__ - -enum { - ROTATOR_REQUEST, - JPEG_REQUEST -}; - -/* Allocates imem for the requested owner. - Aquires a mutex, so DO NOT call from isr context */ -int msm_rotator_imem_allocate(int requestor); -/* Frees imem if currently owned by requestor. - Unlocks a mutex, so DO NOT call from isr context */ -void msm_rotator_imem_free(int requestor); - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_rpcrouter.h b/arch/arm/mach-msm/include/mach/msm_rpcrouter.h deleted file mode 100644 index b055e9497aed027b3a7afe490920c86f164373d0..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_rpcrouter.h +++ /dev/null @@ -1,376 +0,0 @@ -/** include/asm-arm/arch-msm/msm_rpcrouter.h - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2007-2011, The Linux Foundation. All rights reserved. - * Author: San Mehat - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __ASM__ARCH_MSM_RPCROUTER_H -#define __ASM__ARCH_MSM_RPCROUTER_H - -#include -#include -#include - -/* RPC API version structure - * Version bit 31 : 1->hashkey versioning, - * 0->major-minor (backward compatible) versioning - * hashkey versioning: - * Version bits 31-0 hashkey - * major-minor (backward compatible) versioning - * Version bits 30-28 reserved (no match) - * Version bits 27-16 major (must match) - * Version bits 15-0 minor (greater or equal) - */ -#define RPC_VERSION_MODE_MASK 0x80000000 -#define RPC_VERSION_MAJOR_MASK 0x0fff0000 -#define RPC_VERSION_MINOR_MASK 0x0000ffff - -/* callback ID for NULL callback function is -1 */ -#define MSM_RPC_CLIENT_NULL_CB_ID 0xffffffff - -struct msm_rpc_endpoint; - -struct rpcsvr_platform_device -{ - struct platform_device base; - uint32_t prog; - uint32_t vers; -}; - -#define RPC_DATA_IN 0 -/* - * Structures for sending / receiving direct RPC requests - * XXX: Any cred/verif lengths > 0 not supported - */ - -struct rpc_request_hdr -{ - uint32_t xid; - uint32_t type; /* 0 */ - uint32_t rpc_vers; /* 2 */ - uint32_t prog; - uint32_t vers; - uint32_t procedure; - uint32_t cred_flavor; - uint32_t cred_length; - uint32_t verf_flavor; - uint32_t verf_length; -}; - -typedef struct -{ - uint32_t low; - uint32_t high; -} rpc_reply_progmismatch_data; - -typedef struct -{ -} rpc_denied_reply_hdr; - -typedef struct -{ - uint32_t verf_flavor; - uint32_t verf_length; - uint32_t accept_stat; -#define RPC_ACCEPTSTAT_SUCCESS 0 -#define RPC_ACCEPTSTAT_PROG_UNAVAIL 1 -#define RPC_ACCEPTSTAT_PROG_MISMATCH 2 -#define RPC_ACCEPTSTAT_PROC_UNAVAIL 3 -#define RPC_ACCEPTSTAT_GARBAGE_ARGS 4 -#define RPC_ACCEPTSTAT_SYSTEM_ERR 5 -#define RPC_ACCEPTSTAT_PROG_LOCKED 6 - /* - * Following data is dependant on accept_stat - * If ACCEPTSTAT == PROG_MISMATCH then there is a - * 'rpc_reply_progmismatch_data' structure following the header. - * Otherwise the data is procedure specific - */ -} rpc_accepted_reply_hdr; - -struct rpc_reply_hdr -{ - uint32_t xid; - uint32_t type; - uint32_t reply_stat; -#define RPCMSG_REPLYSTAT_ACCEPTED 0 -#define RPCMSG_REPLYSTAT_DENIED 1 - union { - rpc_accepted_reply_hdr acc_hdr; - rpc_denied_reply_hdr dny_hdr; - } data; -}; - -struct rpc_board_dev { - uint32_t prog; - struct platform_device pdev; -}; - -/* flags for msm_rpc_connect() */ -#define MSM_RPC_UNINTERRUPTIBLE 0x0001 - -/* use IS_ERR() to check for failure */ -struct msm_rpc_endpoint *msm_rpc_open(void); -/* Connect with the specified server version */ -struct msm_rpc_endpoint *msm_rpc_connect(uint32_t prog, uint32_t vers, unsigned flags); -/* Connect with a compatible server version */ -struct msm_rpc_endpoint *msm_rpc_connect_compatible(uint32_t prog, - uint32_t vers, unsigned flags); -/* check if server version can handle client requested version */ -int msm_rpc_is_compatible_version(uint32_t server_version, - uint32_t client_version); - -int msm_rpc_close(struct msm_rpc_endpoint *ept); -int msm_rpc_write(struct msm_rpc_endpoint *ept, - void *data, int len); -int msm_rpc_read(struct msm_rpc_endpoint *ept, - void **data, unsigned len, long timeout); -void msm_rpc_read_wakeup(struct msm_rpc_endpoint *ept); -void msm_rpc_setup_req(struct rpc_request_hdr *hdr, - uint32_t prog, uint32_t vers, uint32_t proc); -int msm_rpc_register_server(struct msm_rpc_endpoint *ept, - uint32_t prog, uint32_t vers); -int msm_rpc_unregister_server(struct msm_rpc_endpoint *ept, - uint32_t prog, uint32_t vers); - -int msm_rpc_add_board_dev(struct rpc_board_dev *board_dev, int num); - -int msm_rpc_clear_netreset(struct msm_rpc_endpoint *ept); - -int msm_rpc_get_curr_pkt_size(struct msm_rpc_endpoint *ept); -/* simple blocking rpc call - * - * request is mandatory and must have a rpc_request_hdr - * at the start. The header will be filled out for you. - * - * reply provides a buffer for replies of reply_max_size - */ -int msm_rpc_call_reply(struct msm_rpc_endpoint *ept, uint32_t proc, - void *request, int request_size, - void *reply, int reply_max_size, - long timeout); -int msm_rpc_call(struct msm_rpc_endpoint *ept, uint32_t proc, - void *request, int request_size, - long timeout); - -struct msm_rpc_xdr { - void *in_buf; - uint32_t in_size; - uint32_t in_index; - wait_queue_head_t in_buf_wait_q; - - void *out_buf; - uint32_t out_size; - uint32_t out_index; - struct mutex out_lock; - - struct msm_rpc_endpoint *ept; -}; - -int xdr_send_int8(struct msm_rpc_xdr *xdr, const int8_t *value); -int xdr_send_uint8(struct msm_rpc_xdr *xdr, const uint8_t *value); -int xdr_send_int16(struct msm_rpc_xdr *xdr, const int16_t *value); -int xdr_send_uint16(struct msm_rpc_xdr *xdr, const uint16_t *value); -int xdr_send_int32(struct msm_rpc_xdr *xdr, const int32_t *value); -int xdr_send_uint32(struct msm_rpc_xdr *xdr, const uint32_t *value); -int xdr_send_bytes(struct msm_rpc_xdr *xdr, const void **data, uint32_t *size); - -int xdr_recv_int8(struct msm_rpc_xdr *xdr, int8_t *value); -int xdr_recv_uint8(struct msm_rpc_xdr *xdr, uint8_t *value); -int xdr_recv_int16(struct msm_rpc_xdr *xdr, int16_t *value); -int xdr_recv_uint16(struct msm_rpc_xdr *xdr, uint16_t *value); -int xdr_recv_int32(struct msm_rpc_xdr *xdr, int32_t *value); -int xdr_recv_uint32(struct msm_rpc_xdr *xdr, uint32_t *value); -int xdr_recv_bytes(struct msm_rpc_xdr *xdr, void **data, uint32_t *size); - -struct msm_rpc_server -{ - struct list_head list; - uint32_t flags; - - uint32_t prog; - uint32_t vers; - - struct mutex cb_req_lock; - - struct msm_rpc_endpoint *cb_ept; - - struct msm_rpc_xdr cb_xdr; - - uint32_t version; - - int (*rpc_call)(struct msm_rpc_server *server, - struct rpc_request_hdr *req, unsigned len); - - int (*rpc_call2)(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr); -}; - -int msm_rpc_create_server(struct msm_rpc_server *server); -int msm_rpc_create_server2(struct msm_rpc_server *server); - -#define MSM_RPC_MSGSIZE_MAX 8192 - -struct msm_rpc_client; - -struct msm_rpc_client { - struct task_struct *read_thread; - struct task_struct *cb_thread; - - struct msm_rpc_endpoint *ept; - wait_queue_head_t reply_wait; - - uint32_t prog, ver; - - void *buf; - - struct msm_rpc_xdr xdr; - struct msm_rpc_xdr cb_xdr; - - uint32_t version; - - int (*cb_func)(struct msm_rpc_client *, void *, int); - int (*cb_func2)(struct msm_rpc_client *, struct rpc_request_hdr *req, - struct msm_rpc_xdr *); - void *cb_buf; - int cb_size; - - struct list_head cb_item_list; - struct mutex cb_item_list_lock; - - wait_queue_head_t cb_wait; - int cb_avail; - - atomic_t next_cb_id; - spinlock_t cb_list_lock; - struct list_head cb_list; - - uint32_t exit_flag; - struct completion complete; - struct completion cb_complete; - - struct mutex req_lock; - - void (*cb_restart_teardown)(struct msm_rpc_client *client); - void (*cb_restart_setup)(struct msm_rpc_client *client); - int in_reset; -}; - -struct msm_rpc_client_info { - uint32_t pid; - uint32_t cid; - uint32_t prog; - uint32_t vers; -}; - - -int msm_rpc_client_in_reset(struct msm_rpc_client *client); - -struct msm_rpc_client *msm_rpc_register_client( - const char *name, - uint32_t prog, uint32_t ver, - uint32_t create_cb_thread, - int (*cb_func)(struct msm_rpc_client *, void *, int)); - -struct msm_rpc_client *msm_rpc_register_client2( - const char *name, - uint32_t prog, uint32_t ver, - uint32_t create_cb_thread, - int (*cb_func)(struct msm_rpc_client *, struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr)); - -int msm_rpc_unregister_client(struct msm_rpc_client *client); - -int msm_rpc_client_req(struct msm_rpc_client *client, uint32_t proc, - int (*arg_func)(struct msm_rpc_client *, - void *, void *), void *arg_data, - int (*result_func)(struct msm_rpc_client *, - void *, void *), void *result_data, - long timeout); - -int msm_rpc_client_req2(struct msm_rpc_client *client, uint32_t proc, - int (*arg_func)(struct msm_rpc_client *, - struct msm_rpc_xdr *, void *), - void *arg_data, - int (*result_func)(struct msm_rpc_client *, - struct msm_rpc_xdr *, void *), - void *result_data, - long timeout); - -int msm_rpc_register_reset_callbacks( - struct msm_rpc_client *client, - void (*teardown)(struct msm_rpc_client *client), - void (*setup)(struct msm_rpc_client *client) - ); - -void *msm_rpc_start_accepted_reply(struct msm_rpc_client *client, - uint32_t xid, uint32_t accept_status); - -int msm_rpc_send_accepted_reply(struct msm_rpc_client *client, uint32_t size); - -void *msm_rpc_server_start_accepted_reply(struct msm_rpc_server *server, - uint32_t xid, uint32_t accept_status); - -int msm_rpc_server_send_accepted_reply(struct msm_rpc_server *server, - uint32_t size); - -int msm_rpc_add_cb_func(struct msm_rpc_client *client, void *cb_func); - -void *msm_rpc_get_cb_func(struct msm_rpc_client *client, uint32_t cb_id); - -void msm_rpc_remove_cb_func(struct msm_rpc_client *client, void *cb_func); - -int msm_rpc_server_cb_req(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - uint32_t cb_proc, - int (*arg_func)(struct msm_rpc_server *server, - void *buf, void *data), - void *arg_data, - int (*ret_func)(struct msm_rpc_server *server, - void *buf, void *data), - void *ret_data, long timeout); - -int msm_rpc_server_cb_req2(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - uint32_t cb_proc, - int (*arg_func)(struct msm_rpc_server *server, - struct msm_rpc_xdr *xdr, void *data), - void *arg_data, - int (*ret_func)(struct msm_rpc_server *server, - struct msm_rpc_xdr *xdr, void *data), - void *ret_data, long timeout); - -void msm_rpc_server_get_requesting_client( - struct msm_rpc_client_info *clnt_info); - -int xdr_send_pointer(struct msm_rpc_xdr *xdr, void **obj, - uint32_t obj_size, void *xdr_op); - -int xdr_recv_pointer(struct msm_rpc_xdr *xdr, void **obj, - uint32_t obj_size, void *xdr_op); - -int xdr_send_array(struct msm_rpc_xdr *xdr, void **addr, uint32_t *size, - uint32_t maxsize, uint32_t elm_size, void *xdr_op); - -int xdr_recv_array(struct msm_rpc_xdr *xdr, void **addr, uint32_t *size, - uint32_t maxsize, uint32_t elm_size, void *xdr_op); - -int xdr_recv_req(struct msm_rpc_xdr *xdr, struct rpc_request_hdr *req); -int xdr_recv_reply(struct msm_rpc_xdr *xdr, struct rpc_reply_hdr *reply); -int xdr_start_request(struct msm_rpc_xdr *xdr, uint32_t prog, - uint32_t ver, uint32_t proc); -int xdr_start_accepted_reply(struct msm_rpc_xdr *xdr, uint32_t accept_status); -int xdr_send_msg(struct msm_rpc_xdr *xdr); - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_touch.h b/arch/arm/mach-msm/include/mach/msm_touch.h deleted file mode 100644 index cd895d4e003e22f270a3fdf355a0de01d10e1f97..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_touch.h +++ /dev/null @@ -1,26 +0,0 @@ -/* arch/arm/mach-msm/include/mach/msm_touch.h - * - * Platform data for MSM touchscreen driver. - * - * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _MACH_MSM_TOUCH_H_ -#define _MACH_MSM_TOUCH_H_ - -struct msm_ts_platform_data { - unsigned int x_max; - unsigned int y_max; - unsigned int pressure_max; -}; - -#endif diff --git a/arch/arm/mach-msm/include/mach/msm_tsif.h b/arch/arm/mach-msm/include/mach/msm_tsif.h deleted file mode 100644 index d260ec1efc328ff0aefb1295b75f1573b7bd8a79..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/msm_tsif.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) 2009, 2011, 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 _MSM_TSIF_H_ -#define _MSM_TSIF_H_ - -struct msm_tsif_platform_data { - int num_gpios; - const struct msm_gpio *gpios; - const char *tsif_clk; - const char *tsif_pclk; - const char *tsif_ref_clk; - void (*init)(struct msm_tsif_platform_data *); -}; - -#endif /* _MSM_TSIF_H_ */ - diff --git a/arch/arm/mach-msm/include/mach/oem_rapi_client.h b/arch/arm/mach-msm/include/mach/oem_rapi_client.h deleted file mode 100644 index 374124f53ce6c86ed047116560838c527afe64ee..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/oem_rapi_client.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) 2009, 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 __ASM__ARCH_OEM_RAPI_CLIENT_H -#define __ASM__ARCH_OEM_RAPI_CLIENT_H - -/* - * OEM RAPI CLIENT Driver header file - */ - -#include -#include - -enum { - OEM_RAPI_CLIENT_EVENT_NONE = 0, - - /* - * list of oem rapi client events - */ - - OEM_RAPI_CLIENT_EVENT_MAX - -}; - -struct oem_rapi_client_streaming_func_cb_arg { - uint32_t event; - void *handle; - uint32_t in_len; - char *input; - uint32_t out_len_valid; - uint32_t output_valid; - uint32_t output_size; -}; - -struct oem_rapi_client_streaming_func_cb_ret { - uint32_t *out_len; - char *output; -}; - -struct oem_rapi_client_streaming_func_arg { - uint32_t event; - int (*cb_func)(struct oem_rapi_client_streaming_func_cb_arg *, - struct oem_rapi_client_streaming_func_cb_ret *); - void *handle; - uint32_t in_len; - char *input; - uint32_t out_len_valid; - uint32_t output_valid; - uint32_t output_size; -}; - -struct oem_rapi_client_streaming_func_ret { - uint32_t *out_len; - char *output; -}; - -int oem_rapi_client_streaming_function( - struct msm_rpc_client *client, - struct oem_rapi_client_streaming_func_arg *arg, - struct oem_rapi_client_streaming_func_ret *ret); - -int oem_rapi_client_close(void); - -struct msm_rpc_client *oem_rapi_client_init(void); - -#endif diff --git a/arch/arm/mach-msm/include/mach/pmic.h b/arch/arm/mach-msm/include/mach/pmic.h deleted file mode 100644 index 03b523b39d3d8a6fa34e4bda9f7e52b2120d65d7..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/pmic.h +++ /dev/null @@ -1,748 +0,0 @@ -/* Copyright (c) 2009-2011, 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 __ARCH_ARM_MACH_PMIC_H -#define __ARCH_ARM_MACH_PMIC_H - -#include - -enum spkr_ldo_v_sel { - VOLT_LEVEL_1_1V, - VOLT_LEVEL_1_2V, - VOLT_LEVEL_2_0V, -}; - -enum hp_spkr_left_right { - LEFT_HP_SPKR, - RIGHT_HP_SPKR, -}; - -enum spkr_left_right { - LEFT_SPKR, - RIGHT_SPKR, -}; - -enum spkr_gain { - SPKR_GAIN_MINUS16DB, /* -16 db */ - SPKR_GAIN_MINUS12DB, /* -12 db */ - SPKR_GAIN_MINUS08DB, /* -08 db */ - SPKR_GAIN_MINUS04DB, /* -04 db */ - SPKR_GAIN_00DB, /* 00 db */ - SPKR_GAIN_PLUS04DB, /* +04 db */ - SPKR_GAIN_PLUS08DB, /* +08 db */ - SPKR_GAIN_PLUS12DB, /* +12 db */ -}; - -enum spkr_dly { - SPKR_DLY_10MS, /* ~10 ms delay */ - SPKR_DLY_100MS, /* ~100 ms delay */ -}; - -enum spkr_hpf_corner_freq { - SPKR_FREQ_1_39KHZ, /* 1.39 kHz */ - SPKR_FREQ_0_64KHZ, /* 0.64 kHz */ - SPKR_FREQ_0_86KHZ, /* 0.86 kHz */ - SPKR_FREQ_0_51KHZ, /* 0.51 kHz */ - SPKR_FREQ_1_06KHZ, /* 1.06 kHz */ - SPKR_FREQ_0_57KHZ, /* 0.57 kHz */ - SPKR_FREQ_0_73KHZ, /* 0.73 kHz */ - SPKR_FREQ_0_47KHZ, /* 0.47 kHz */ - SPKR_FREQ_1_20KHZ, /* 1.20 kHz */ - SPKR_FREQ_0_60KHZ, /* 0.60 kHz */ - SPKR_FREQ_0_76KHZ, /* 0.76 kHz */ - SPKR_FREQ_0_49KHZ, /* 0.49 kHz */ - SPKR_FREQ_0_95KHZ, /* 0.95 kHz */ - SPKR_FREQ_0_54KHZ, /* 0.54 kHz */ - SPKR_FREQ_0_68KHZ, /* 0.68 kHz */ - SPKR_FREQ_0_45KHZ, /* 0.45 kHz */ -}; - -/* Turn the speaker on or off and enables or disables mute.*/ -enum spkr_cmd { - SPKR_DISABLE, /* Enable Speaker */ - SPKR_ENABLE, /* Disable Speaker */ - SPKR_MUTE_OFF, /* turn speaker mute off, SOUND ON */ - SPKR_MUTE_ON, /* turn speaker mute on, SOUND OFF */ - SPKR_OFF, /* turn speaker OFF (speaker disable and mute on) */ - SPKR_ON, /* turn speaker ON (speaker enable and mute off) */ - SPKR_SET_FREQ_CMD, /* set speaker frequency */ - SPKR_GET_FREQ_CMD, /* get speaker frequency */ - SPKR_SET_GAIN_CMD, /* set speaker gain */ - SPKR_GET_GAIN_CMD, /* get speaker gain */ - SPKR_SET_DELAY_CMD, /* set speaker delay */ - SPKR_GET_DELAY_CMD, /* get speaker delay */ - SPKR_SET_PDM_MODE, - SPKR_SET_PWM_MODE, -}; - -struct spkr_config_mode { - uint32_t is_right_chan_en; - uint32_t is_left_chan_en; - uint32_t is_right_left_chan_added; - uint32_t is_stereo_en; - uint32_t is_usb_with_hpf_20hz; - uint32_t is_mux_bypassed; - uint32_t is_hpf_en; - uint32_t is_sink_curr_from_ref_volt_cir_en; -}; - -enum mic_volt { - MIC_VOLT_2_00V, /* 2.00 V */ - MIC_VOLT_1_93V, /* 1.93 V */ - MIC_VOLT_1_80V, /* 1.80 V */ - MIC_VOLT_1_73V, /* 1.73 V */ -}; - -enum ledtype { - LED_LCD, - LED_KEYPAD, -}; - -enum flash_led_mode { - FLASH_LED_MODE__MANUAL, - FLASH_LED_MODE__DBUS1, - FLASH_LED_MODE__DBUS2, - FLASH_LED_MODE__DBUS3, -}; - -enum flash_led_pol { - FLASH_LED_POL__ACTIVE_HIGH, - FLASH_LED_POL__ACTIVE_LOW, -}; - -enum switch_cmd { - OFF_CMD, - ON_CMD -}; - -enum vreg_lp_id { - PM_VREG_LP_MSMA_ID, - PM_VREG_LP_MSMP_ID, - PM_VREG_LP_MSME1_ID, - PM_VREG_LP_GP3_ID, - PM_VREG_LP_MSMC_ID, - PM_VREG_LP_MSME2_ID, - PM_VREG_LP_GP4_ID, - PM_VREG_LP_GP1_ID, - PM_VREG_LP_RFTX_ID, - PM_VREG_LP_RFRX1_ID, - PM_VREG_LP_RFRX2_ID, - PM_VREG_LP_WLAN_ID, - PM_VREG_LP_MMC_ID, - PM_VREG_LP_RUIM_ID, - PM_VREG_LP_MSMC0_ID, - PM_VREG_LP_GP2_ID, - PM_VREG_LP_GP5_ID, - PM_VREG_LP_GP6_ID, - PM_VREG_LP_MPLL_ID, - PM_VREG_LP_RFUBM_ID, - PM_VREG_LP_RFA_ID, - PM_VREG_LP_CDC2_ID, - PM_VREG_LP_RFTX2_ID, - PM_VREG_LP_USIM_ID, - PM_VREG_LP_USB2P6_ID, - PM_VREG_LP_TCXO_ID, - PM_VREG_LP_USB3P3_ID, - - PM_VREG_LP_MSME_ID = PM_VREG_LP_MSME1_ID, - /* backward compatible enums only */ - PM_VREG_LP_CAM_ID = PM_VREG_LP_GP1_ID, - PM_VREG_LP_MDDI_ID = PM_VREG_LP_GP2_ID, - PM_VREG_LP_RUIM2_ID = PM_VREG_LP_GP3_ID, - PM_VREG_LP_AUX_ID = PM_VREG_LP_GP4_ID, - PM_VREG_LP_AUX2_ID = PM_VREG_LP_GP5_ID, - PM_VREG_LP_BT_ID = PM_VREG_LP_GP6_ID, - PM_VREG_LP_MSMC_LDO_ID = PM_VREG_LP_MSMC_ID, - PM_VREG_LP_MSME1_LDO_ID = PM_VREG_LP_MSME1_ID, - PM_VREG_LP_MSME2_LDO_ID = PM_VREG_LP_MSME2_ID, - PM_VREG_LP_RFA1_ID = PM_VREG_LP_RFRX2_ID, - PM_VREG_LP_RFA2_ID = PM_VREG_LP_RFTX2_ID, - PM_VREG_LP_XO_ID = PM_VREG_LP_TCXO_ID -}; - -enum vreg_id { - PM_VREG_MSMA_ID = 0, - PM_VREG_MSMP_ID, - PM_VREG_MSME1_ID, - PM_VREG_MSMC1_ID, - PM_VREG_MSMC2_ID, - PM_VREG_GP3_ID, - PM_VREG_MSME2_ID, - PM_VREG_GP4_ID, - PM_VREG_GP1_ID, - PM_VREG_TCXO_ID, - PM_VREG_PA_ID, - PM_VREG_RFTX_ID, - PM_VREG_RFRX1_ID, - PM_VREG_RFRX2_ID, - PM_VREG_SYNT_ID, - PM_VREG_WLAN_ID, - PM_VREG_USB_ID, - PM_VREG_BOOST_ID, - PM_VREG_MMC_ID, - PM_VREG_RUIM_ID, - PM_VREG_MSMC0_ID, - PM_VREG_GP2_ID, - PM_VREG_GP5_ID, - PM_VREG_GP6_ID, - PM_VREG_RF_ID, - PM_VREG_RF_VCO_ID, - PM_VREG_MPLL_ID, - PM_VREG_S2_ID, - PM_VREG_S3_ID, - PM_VREG_RFUBM_ID, - PM_VREG_NCP_ID, - PM_VREG_RF2_ID, - PM_VREG_RFA_ID, - PM_VREG_CDC2_ID, - PM_VREG_RFTX2_ID, - PM_VREG_USIM_ID, - PM_VREG_USB2P6_ID, - PM_VREG_USB3P3_ID, - PM_VREG_EXTCDC1_ID, - PM_VREG_EXTCDC2_ID, - - /* backward compatible enums only */ - PM_VREG_MSME_ID = PM_VREG_MSME1_ID, - PM_VREG_MSME_BUCK_SMPS_ID = PM_VREG_MSME1_ID, - PM_VREG_MSME1_LDO_ID = PM_VREG_MSME1_ID, - PM_VREG_MSMC_ID = PM_VREG_MSMC1_ID, - PM_VREG_MSMC_LDO_ID = PM_VREG_MSMC1_ID, - PM_VREG_MSMC1_BUCK_SMPS_ID = PM_VREG_MSMC1_ID, - PM_VREG_MSME2_LDO_ID = PM_VREG_MSME2_ID, - PM_VREG_CAM_ID = PM_VREG_GP1_ID, - PM_VREG_MDDI_ID = PM_VREG_GP2_ID, - PM_VREG_RUIM2_ID = PM_VREG_GP3_ID, - PM_VREG_AUX_ID = PM_VREG_GP4_ID, - PM_VREG_AUX2_ID = PM_VREG_GP5_ID, - PM_VREG_BT_ID = PM_VREG_GP6_ID, - PM_VREG_RF1_ID = PM_VREG_RF_ID, - PM_VREG_S1_ID = PM_VREG_RF1_ID, - PM_VREG_5V_ID = PM_VREG_BOOST_ID, - PM_VREG_RFA1_ID = PM_VREG_RFRX2_ID, - PM_VREG_RFA2_ID = PM_VREG_RFTX2_ID, - PM_VREG_XO_ID = PM_VREG_TCXO_ID -}; - -enum vreg_pdown_id { - PM_VREG_PDOWN_MSMA_ID, - PM_VREG_PDOWN_MSMP_ID, - PM_VREG_PDOWN_MSME1_ID, - PM_VREG_PDOWN_MSMC1_ID, - PM_VREG_PDOWN_MSMC2_ID, - PM_VREG_PDOWN_GP3_ID, - PM_VREG_PDOWN_MSME2_ID, - PM_VREG_PDOWN_GP4_ID, - PM_VREG_PDOWN_GP1_ID, - PM_VREG_PDOWN_TCXO_ID, - PM_VREG_PDOWN_PA_ID, - PM_VREG_PDOWN_RFTX_ID, - PM_VREG_PDOWN_RFRX1_ID, - PM_VREG_PDOWN_RFRX2_ID, - PM_VREG_PDOWN_SYNT_ID, - PM_VREG_PDOWN_WLAN_ID, - PM_VREG_PDOWN_USB_ID, - PM_VREG_PDOWN_MMC_ID, - PM_VREG_PDOWN_RUIM_ID, - PM_VREG_PDOWN_MSMC0_ID, - PM_VREG_PDOWN_GP2_ID, - PM_VREG_PDOWN_GP5_ID, - PM_VREG_PDOWN_GP6_ID, - PM_VREG_PDOWN_RF_ID, - PM_VREG_PDOWN_RF_VCO_ID, - PM_VREG_PDOWN_MPLL_ID, - PM_VREG_PDOWN_S2_ID, - PM_VREG_PDOWN_S3_ID, - PM_VREG_PDOWN_RFUBM_ID, - /* new for HAN */ - PM_VREG_PDOWN_RF1_ID, - PM_VREG_PDOWN_RF2_ID, - PM_VREG_PDOWN_RFA_ID, - PM_VREG_PDOWN_CDC2_ID, - PM_VREG_PDOWN_RFTX2_ID, - PM_VREG_PDOWN_USIM_ID, - PM_VREG_PDOWN_USB2P6_ID, - PM_VREG_PDOWN_USB3P3_ID, - - /* backward compatible enums only */ - PM_VREG_PDOWN_CAM_ID = PM_VREG_PDOWN_GP1_ID, - PM_VREG_PDOWN_MDDI_ID = PM_VREG_PDOWN_GP2_ID, - PM_VREG_PDOWN_RUIM2_ID = PM_VREG_PDOWN_GP3_ID, - PM_VREG_PDOWN_AUX_ID = PM_VREG_PDOWN_GP4_ID, - PM_VREG_PDOWN_AUX2_ID = PM_VREG_PDOWN_GP5_ID, - PM_VREG_PDOWN_BT_ID = PM_VREG_PDOWN_GP6_ID, - PM_VREG_PDOWN_MSME_ID = PM_VREG_PDOWN_MSME1_ID, - PM_VREG_PDOWN_MSMC_ID = PM_VREG_PDOWN_MSMC1_ID, - PM_VREG_PDOWN_RFA1_ID = PM_VREG_PDOWN_RFRX2_ID, - PM_VREG_PDOWN_RFA2_ID = PM_VREG_PDOWN_RFTX2_ID, - PM_VREG_PDOWN_XO_ID = PM_VREG_PDOWN_TCXO_ID -}; - -enum mpp_which { - PM_MPP_1, - PM_MPP_2, - PM_MPP_3, - PM_MPP_4, - PM_MPP_5, - PM_MPP_6, - PM_MPP_7, - PM_MPP_8, - PM_MPP_9, - PM_MPP_10, - PM_MPP_11, - PM_MPP_12, - PM_MPP_13, - PM_MPP_14, - PM_MPP_15, - PM_MPP_16, - PM_MPP_17, - PM_MPP_18, - PM_MPP_19, - PM_MPP_20, - PM_MPP_21, - PM_MPP_22, - - PM_NUM_MPP_HAN = PM_MPP_4 + 1, - PM_NUM_MPP_KIP = PM_MPP_4 + 1, - PM_NUM_MPP_EPIC = PM_MPP_4 + 1, - PM_NUM_MPP_PM7500 = PM_MPP_22 + 1, - PM_NUM_MPP_PM6650 = PM_MPP_12 + 1, - PM_NUM_MPP_PM6658 = PM_MPP_12 + 1, - PM_NUM_MPP_PANORAMIX = PM_MPP_2 + 1, - PM_NUM_MPP_PM6640 = PM_NUM_MPP_PANORAMIX, - PM_NUM_MPP_PM6620 = PM_NUM_MPP_PANORAMIX -}; - -enum mpp_dlogic_level { - PM_MPP__DLOGIC__LVL_MSME, - PM_MPP__DLOGIC__LVL_MSMP, - PM_MPP__DLOGIC__LVL_RUIM, - PM_MPP__DLOGIC__LVL_MMC, - PM_MPP__DLOGIC__LVL_VDD, -}; - -enum mpp_dlogic_in_dbus { - PM_MPP__DLOGIC_IN__DBUS_NONE, - PM_MPP__DLOGIC_IN__DBUS1, - PM_MPP__DLOGIC_IN__DBUS2, - PM_MPP__DLOGIC_IN__DBUS3, -}; - -enum mpp_dlogic_out_ctrl { - PM_MPP__DLOGIC_OUT__CTRL_LOW, - PM_MPP__DLOGIC_OUT__CTRL_HIGH, - PM_MPP__DLOGIC_OUT__CTRL_MPP, - PM_MPP__DLOGIC_OUT__CTRL_NOT_MPP, -}; - -enum mpp_i_sink_level { - PM_MPP__I_SINK__LEVEL_5mA, - PM_MPP__I_SINK__LEVEL_10mA, - PM_MPP__I_SINK__LEVEL_15mA, - PM_MPP__I_SINK__LEVEL_20mA, - PM_MPP__I_SINK__LEVEL_25mA, - PM_MPP__I_SINK__LEVEL_30mA, - PM_MPP__I_SINK__LEVEL_35mA, - PM_MPP__I_SINK__LEVEL_40mA, -}; - -enum mpp_i_sink_switch { - PM_MPP__I_SINK__SWITCH_DIS, - PM_MPP__I_SINK__SWITCH_ENA, - PM_MPP__I_SINK__SWITCH_ENA_IF_MPP_HIGH, - PM_MPP__I_SINK__SWITCH_ENA_IF_MPP_LOW, -}; - -enum pm_vib_mot_mode { - PM_VIB_MOT_MODE__MANUAL, - PM_VIB_MOT_MODE__DBUS1, - PM_VIB_MOT_MODE__DBUS2, - PM_VIB_MOT_MODE__DBUS3, -}; - -enum pm_vib_mot_pol { - PM_VIB_MOT_POL__ACTIVE_HIGH, - PM_VIB_MOT_POL__ACTIVE_LOW, -}; - -struct rtc_time { - uint sec; -}; - -enum rtc_alarm { - PM_RTC_ALARM_1, -}; - -enum hsed_controller { - PM_HSED_CONTROLLER_0, - PM_HSED_CONTROLLER_1, - PM_HSED_CONTROLLER_2, -}; - -enum hsed_switch { - PM_HSED_SC_SWITCH_TYPE, - PM_HSED_OC_SWITCH_TYPE, -}; - -enum hsed_enable { - PM_HSED_ENABLE_OFF, - PM_HSED_ENABLE_TCXO, - PM_HSED_ENABLE_PWM_TCXO, - PM_HSED_ENABLE_ALWAYS, -}; - -enum hsed_hyst_pre_div { - PM_HSED_HYST_PRE_DIV_1, - PM_HSED_HYST_PRE_DIV_2, - PM_HSED_HYST_PRE_DIV_4, - PM_HSED_HYST_PRE_DIV_8, - PM_HSED_HYST_PRE_DIV_16, - PM_HSED_HYST_PRE_DIV_32, - PM_HSED_HYST_PRE_DIV_64, - PM_HSED_HYST_PRE_DIV_128, -}; - -enum hsed_hyst_time { - PM_HSED_HYST_TIME_1_CLK_CYCLES, - PM_HSED_HYST_TIME_2_CLK_CYCLES, - PM_HSED_HYST_TIME_3_CLK_CYCLES, - PM_HSED_HYST_TIME_4_CLK_CYCLES, - PM_HSED_HYST_TIME_5_CLK_CYCLES, - PM_HSED_HYST_TIME_6_CLK_CYCLES, - PM_HSED_HYST_TIME_7_CLK_CYCLES, - PM_HSED_HYST_TIME_8_CLK_CYCLES, - PM_HSED_HYST_TIME_9_CLK_CYCLES, - PM_HSED_HYST_TIME_10_CLK_CYCLES, - PM_HSED_HYST_TIME_11_CLK_CYCLES, - PM_HSED_HYST_TIME_12_CLK_CYCLES, - PM_HSED_HYST_TIME_13_CLK_CYCLES, - PM_HSED_HYST_TIME_14_CLK_CYCLES, - PM_HSED_HYST_TIME_15_CLK_CYCLES, - PM_HSED_HYST_TIME_16_CLK_CYCLES, -}; - -enum hsed_period_pre_div { - PM_HSED_PERIOD_PRE_DIV_2, - PM_HSED_PERIOD_PRE_DIV_4, - PM_HSED_PERIOD_PRE_DIV_8, - PM_HSED_PERIOD_PRE_DIV_16, - PM_HSED_PERIOD_PRE_DIV_32, - PM_HSED_PERIOD_PRE_DIV_64, - PM_HSED_PERIOD_PRE_DIV_128, - PM_HSED_PERIOD_PRE_DIV_256, -}; - -enum hsed_period_time { - PM_HSED_PERIOD_TIME_1_CLK_CYCLES, - PM_HSED_PERIOD_TIME_2_CLK_CYCLES, - PM_HSED_PERIOD_TIME_3_CLK_CYCLES, - PM_HSED_PERIOD_TIME_4_CLK_CYCLES, - PM_HSED_PERIOD_TIME_5_CLK_CYCLES, - PM_HSED_PERIOD_TIME_6_CLK_CYCLES, - PM_HSED_PERIOD_TIME_7_CLK_CYCLES, - PM_HSED_PERIOD_TIME_8_CLK_CYCLES, - PM_HSED_PERIOD_TIME_9_CLK_CYCLES, - PM_HSED_PERIOD_TIME_10_CLK_CYCLES, - PM_HSED_PERIOD_TIME_11_CLK_CYCLES, - PM_HSED_PERIOD_TIME_12_CLK_CYCLES, - PM_HSED_PERIOD_TIME_13_CLK_CYCLES, - PM_HSED_PERIOD_TIME_14_CLK_CYCLES, - PM_HSED_PERIOD_TIME_15_CLK_CYCLES, - PM_HSED_PERIOD_TIME_16_CLK_CYCLES, -}; - -enum vreg_lpm_id { - VREG_GP1_ID, - VREG_GP2_ID, - VREG_GP3_ID, - VREG_GP4_ID, - VREG_GP5_ID, - VREG_GP6_ID, - VREG_GP7_ID, - VREG_GP8_ID, - VREG_GP9_ID, - VREG_GP10_ID, - VREG_GP11_ID, - VREG_GP12_ID, - VREG_GP13_ID, - VREG_GP14_ID, - VREG_GP15_ID, - VREG_GP16_ID, - VREG_GP17_ID, - VREG_MDDI_ID, - VREG_MPLL_ID, - VREG_MSMC1_ID, - VREG_MSMC2_ID, - VREG_MSME_ID, - VREG_RF_ID, - VREG_RF1_ID, - VREG_RF2_ID, - VREG_RFA_ID, - VREG_SDCC1_ID, - VREG_TCXO_ID, - VREG_USB1P8_ID, - VREG_USB3P3_ID, - VREG_USIM_ID, - VREG_WLAN1_ID, - VREG_WLAN2_ID, - VREG_XO_OUT_D0_ID, - VREG_NCP_ID, - VREG_LVSW0_ID, - VREG_LVSW1_ID, -}; - -enum low_current_led { - LOW_CURRENT_LED_DRV0, - LOW_CURRENT_LED_DRV1, - LOW_CURRENT_LED_DRV2, -}; - -enum ext_signal { - EXT_SIGNAL_CURRENT_SINK_MANUAL_MODE, - EXT_SIGNAL_CURRENT_SINK_PWM1, - EXT_SIGNAL_CURRENT_SINK_PWM2, - EXT_SIGNAL_CURRENT_SINK_PWM3, - EXT_SIGNAL_CURRENT_SINK_DTEST1, - EXT_SIGNAL_CURRENT_SINK_DTEST2, - EXT_SIGNAL_CURRENT_SINK_DTEST3, - EXT_SIGNAL_CURRENT_SINK_DTEST4, -}; - -enum high_current_led { - HIGH_CURRENT_LED_FLASH_DRV0, - HIGH_CURRENT_LED_FLASH_DRV1, - HIGH_CURRENT_LED_KBD_DRV, -}; - -/* PMIC GPIO */ -enum pmic_gpio { - PMIC_GPIO_1, - PMIC_GPIO_2, - PMIC_GPIO_3, - PMIC_GPIO_4, - PMIC_GPIO_5, - PMIC_GPIO_6, - PMIC_GPIO_7, - PMIC_GPIO_8, - PMIC_GPIO_9, - PMIC_GPIO_10, - PMIC_GPIO_11, -}; - -enum pmic_voltage_src { - PMIC_GPIO_VIN0, - PMIC_GPIO_VIN1, - PMIC_GPIO_VIN2, - PMIC_GPIO_VIN3, - PMIC_GPIO_VIN4, - PMIC_GPIO_VIN5, - PMIC_GPIO_VIN6, - PMIC_GPIO_VIN7, -}; - -enum pmic_io_mode { - INPUT_ON, - INPUT_OUTPUT_ON, - OUTPUT_ON, - INPUT_OUTPUT_OFF, -}; - -enum pmic_current_pull_up { - PULL_UP_30uA, - PULL_UP_1_5uA, - PULL_UP_31_5uA, - PULL_UP_1_5uA_PLUS_30uA_BOOST, - PULL_DOWN_10uA, - PULL_NO_PULL, -}; - -enum pmic_op_buf_drv_strength { - BUFFER_OFF, - BUFFER_HIGH, - BUFFER_MEDIUM, - BUFFER_LOW, -}; - -enum pmic_output_buffer_config { - CONFIG_CMOS, - CONFIG_OPEN_DRAIN, -}; - -enum pmic_dtest_buf_onoff { - DTEST_DISABLE, - DTEST_ENABLE, -}; - -enum pmic_ext_pin_config { - EXT_PIN_ENABLE, - /*! Puts EXT_PIN at high Z state & disables the block */ - EXT_PIN_DISABLE, -}; - -enum pmic_source_config { - SOURCE_GND, - SOURCE_PAIRED_GPIO, - SOURCE_SPECIAL_FUNCTION1, - SOURCE_SPECIAL_FUNCTION2, - SOURCE_DTEST1, - SOURCE_DTEST2, - SOURCE_DTEST3, - SOURCE_DTEST4, -}; - -enum pmic_direction_mode { - MODE_INPUT, - MODE_OTPUT_AND_INPUT_ON, - MODE_OUTPUT, - MODE_INPUT_AND_OUTPUT_OFF, -}; - -struct pm8xxx_gpio_rpc_cfg { - enum pmic_gpio gpio; - bool config_gpio; - enum pmic_voltage_src volt_src; - bool mode_on; - enum pmic_io_mode mode; - enum pmic_output_buffer_config buf_config; - bool invert_ext_pin; - enum pmic_current_pull_up src_pull; - enum pmic_op_buf_drv_strength drv_strength; - enum pmic_dtest_buf_onoff dtest_on; - enum pmic_ext_pin_config ext_config; - enum pmic_source_config src_config; - bool int_polarity; -}; - -int pmic_lp_mode_control(enum switch_cmd cmd, enum vreg_lp_id id); -int pmic_vreg_set_level(enum vreg_id vreg, int level); -int pmic_vreg_pull_down_switch(enum switch_cmd cmd, enum vreg_pdown_id id); -int pmic_secure_mpp_control_digital_output(enum mpp_which which, - enum mpp_dlogic_level level, enum mpp_dlogic_out_ctrl out); -int pmic_secure_mpp_config_i_sink(enum mpp_which which, - enum mpp_i_sink_level level, enum mpp_i_sink_switch onoff); -int pmic_secure_mpp_config_digital_input(enum mpp_which which, - enum mpp_dlogic_level level, enum mpp_dlogic_in_dbus dbus); -int pmic_rtc_start(struct rtc_time *time); -int pmic_rtc_stop(void); -int pmic_rtc_get_time(struct rtc_time *time); -int pmic_rtc_enable_alarm(enum rtc_alarm alarm, - struct rtc_time *time); -int pmic_rtc_disable_alarm(enum rtc_alarm alarm); -int pmic_rtc_get_alarm_time(enum rtc_alarm alarm, - struct rtc_time *time); -int pmic_rtc_get_alarm_status(uint *status); -int pmic_rtc_set_time_adjust(uint adjust); -int pmic_rtc_get_time_adjust(uint *adjust); -int pmic_speaker_cmd(const enum spkr_cmd cmd); -int pmic_set_spkr_configuration(struct spkr_config_mode *cfg); -int pmic_get_spkr_configuration(struct spkr_config_mode *cfg); -int pmic_spkr_en_right_chan(uint enable); -int pmic_spkr_is_right_chan_en(uint *enabled); -int pmic_spkr_en_left_chan(uint enable); -int pmic_spkr_is_left_chan_en(uint *enabled); -int pmic_spkr_en(enum spkr_left_right left_right, uint enabled); -int pmic_spkr_is_en(enum spkr_left_right left_right, uint *enabled); -int pmic_spkr_set_gain(enum spkr_left_right left_right, enum spkr_gain gain); -int pmic_spkr_get_gain(enum spkr_left_right left_right, enum spkr_gain *gain); -int pmic_set_speaker_gain(enum spkr_gain gain); -int pmic_set_speaker_delay(enum spkr_dly delay); -int pmic_speaker_1k6_zin_enable(uint enable); -int pmic_spkr_set_mux_hpf_corner_freq(enum spkr_hpf_corner_freq freq); -int pmic_spkr_get_mux_hpf_corner_freq(enum spkr_hpf_corner_freq *freq); -int pmic_spkr_select_usb_with_hpf_20hz(uint enable); -int pmic_spkr_is_usb_with_hpf_20hz(uint *enabled); -int pmic_spkr_bypass_mux(uint enable); -int pmic_spkr_is_mux_bypassed(uint *enabled); -int pmic_spkr_en_hpf(uint enable); -int pmic_spkr_is_hpf_en(uint *enabled); -int pmic_spkr_en_sink_curr_from_ref_volt_cir(uint enable); -int pmic_spkr_is_sink_curr_from_ref_volt_cir_en(uint *enabled); -int pmic_spkr_set_delay(enum spkr_left_right left_right, enum spkr_dly delay); -int pmic_spkr_get_delay(enum spkr_left_right left_right, enum spkr_dly *delay); -int pmic_spkr_en_mute(enum spkr_left_right left_right, uint enabled); -int pmic_spkr_is_mute_en(enum spkr_left_right left_right, uint *enabled); -int pmic_mic_en(uint enable); -int pmic_mic_is_en(uint *enabled); -int pmic_mic_set_volt(enum mic_volt vol); -int pmic_mic_get_volt(enum mic_volt *voltage); -int pmic_set_led_intensity(enum ledtype type, int level); -int pmic_flash_led_set_current(uint16_t milliamps); -int pmic_flash_led_set_mode(enum flash_led_mode mode); -int pmic_flash_led_set_polarity(enum flash_led_pol pol); -int pmic_spkr_add_right_left_chan(uint enable); -int pmic_spkr_is_right_left_chan_added(uint *enabled); -int pmic_spkr_en_stereo(uint enable); -int pmic_spkr_is_stereo_en(uint *enabled); -int pmic_vib_mot_set_volt(uint vol); -int pmic_vib_mot_set_mode(enum pm_vib_mot_mode mode); -int pmic_vib_mot_set_polarity(enum pm_vib_mot_pol pol); -int pmic_vid_en(uint enable); -int pmic_vid_is_en(uint *enabled); -int pmic_vid_load_detect_en(uint enable); - -int pmic_hsed_set_period( - enum hsed_controller controller, - enum hsed_period_pre_div period_pre_div, - enum hsed_period_time period_time -); - -int pmic_hsed_set_hysteresis( - enum hsed_controller controller, - enum hsed_hyst_pre_div hyst_pre_div, - enum hsed_hyst_time hyst_time -); - -int pmic_hsed_set_current_threshold( - enum hsed_controller controller, - enum hsed_switch switch_hsed, - uint32_t current_threshold -); - -int pmic_hsed_enable( - enum hsed_controller controller, - enum hsed_enable enable -); - -int pmic_high_current_led_set_current(enum high_current_led led, - uint16_t milliamps); -int pmic_high_current_led_set_polarity(enum high_current_led led, - enum flash_led_pol polarity); -int pmic_high_current_led_set_mode(enum high_current_led led, - enum flash_led_mode mode); -int pmic_lp_force_lpm_control(enum switch_cmd cmd, - enum vreg_lpm_id vreg); -int pmic_low_current_led_set_ext_signal(enum low_current_led led, - enum ext_signal sig); -int pmic_low_current_led_set_current(enum low_current_led led, - uint16_t milliamps); - -int pmic_spkr_set_vsel_ldo(enum spkr_left_right left_right, - enum spkr_ldo_v_sel vlt_cntrl); -int pmic_spkr_set_boost(enum spkr_left_right left_right, uint enable); -int pmic_spkr_bypass_en(enum spkr_left_right left_right, uint enable); -int pmic_hp_spkr_mstr_en(enum hp_spkr_left_right left_right, uint enable); -int pmic_hp_spkr_mute_en(enum hp_spkr_left_right left_right, uint enable); -int pmic_hp_spkr_prm_in_en(enum hp_spkr_left_right left_right, uint enable); -int pmic_hp_spkr_aux_in_en(enum hp_spkr_left_right left_right, uint enable); -int pmic_hp_spkr_ctrl_prm_gain_input(enum hp_spkr_left_right left_right, - uint prm_gain_ctl); -int pmic_hp_spkr_ctrl_aux_gain_input(enum hp_spkr_left_right left_right, - uint aux_gain_ctl); -int pmic_xo_core_force_enable(uint enable); -int pmic_gpio_direction_input(unsigned gpio); -int pmic_gpio_direction_output(unsigned gpio); -int pmic_gpio_set_value(unsigned gpio, int value); -int pmic_gpio_get_value(unsigned gpio); -int pmic_gpio_get_direction(unsigned gpio); -int pmic_gpio_config(struct pm8xxx_gpio_rpc_cfg *); -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpp.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpp.h deleted file mode 100644 index 5fa36d6b3341fad853e0db95981b35c0d23e80bc..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpp.h +++ /dev/null @@ -1,93 +0,0 @@ -/*arch/arm/mach-msm/qdsp5audpp.h - * - * Copyright (C) 2008 Google, Inc. - * Copyright (c) 2012, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _MACH_QDSP5_AUDPP_H -#define _MACH_QDSP5_AUDPP_H - -#include - -typedef void (*audpp_event_func)(void *private, unsigned id, uint16_t *msg); - -/* worst case delay of 1sec for response */ -#define MSM_AUD_DECODER_WAIT_MS 1000 -#define MSM_AUD_MODE_TUNNEL 0x00000100 -#define MSM_AUD_MODE_NONTUNNEL 0x00000200 -#define MSM_AUD_DECODER_MASK 0x0000FFFF -#define MSM_AUD_OP_MASK 0xFFFF0000 - -/*Playback mode*/ -#define NON_TUNNEL_MODE_PLAYBACK 1 -#define TUNNEL_MODE_PLAYBACK 0 - -enum msm_aud_decoder_state { - MSM_AUD_DECODER_STATE_NONE = 0, - MSM_AUD_DECODER_STATE_FAILURE = 1, - MSM_AUD_DECODER_STATE_SUCCESS = 2, - MSM_AUD_DECODER_STATE_CLOSE = 3, -}; - -int audpp_adec_alloc(unsigned dec_attrb, const char **module_name, - unsigned *queueid); -void audpp_adec_free(int decid); - -struct audpp_event_callback { - audpp_event_func fn; - void *private; -}; - -int audpp_register_event_callback(struct audpp_event_callback *eh); -int audpp_unregister_event_callback(struct audpp_event_callback *eh); -int is_audpp_enable(void); - -int audpp_enable(int id, audpp_event_func func, void *private); -void audpp_disable(int id, void *private); - -int audpp_send_queue1(void *cmd, unsigned len); -int audpp_send_queue2(void *cmd, unsigned len); -int audpp_send_queue3(void *cmd, unsigned len); - -int audpp_set_volume_and_pan(unsigned id, unsigned volume, int pan); -int audpp_pause(unsigned id, int pause); -int audpp_flush(unsigned id); -void audpp_avsync(int id, unsigned rate); -unsigned audpp_avsync_sample_count(int id); -unsigned audpp_avsync_byte_count(int id); -int audpp_dsp_set_mbadrc(unsigned id, unsigned enable, - audpp_cmd_cfg_object_params_mbadrc *mbadrc); -int audpp_dsp_set_eq(unsigned id, unsigned enable, - audpp_cmd_cfg_object_params_eqalizer *eq); -int audpp_dsp_set_rx_iir(unsigned id, unsigned enable, - audpp_cmd_cfg_object_params_pcm *iir); - -int audpp_dsp_set_rx_srs_trumedia_g - (struct audpp_cmd_cfg_object_params_srstm_g *srstm); -int audpp_dsp_set_rx_srs_trumedia_w - (struct audpp_cmd_cfg_object_params_srstm_w *srstm); -int audpp_dsp_set_rx_srs_trumedia_c - (struct audpp_cmd_cfg_object_params_srstm_c *srstm); -int audpp_dsp_set_rx_srs_trumedia_h - (struct audpp_cmd_cfg_object_params_srstm_h *srstm); -int audpp_dsp_set_rx_srs_trumedia_p - (struct audpp_cmd_cfg_object_params_srstm_p *srstm); -int audpp_dsp_set_rx_srs_trumedia_l - (struct audpp_cmd_cfg_object_params_srstm_l *srstm); - -int audpp_dsp_set_vol_pan(unsigned id, - audpp_cmd_cfg_object_params_volume *vol_pan); -int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable, - audpp_cmd_cfg_object_params_qconcert *qconcert_plus); - -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h deleted file mode 100644 index 93b77f4ee22208d18fa59dfcf0e9796e920692f0..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h +++ /dev/null @@ -1,1079 +0,0 @@ -#ifndef QDSP5AUDPPCMDI_H -#define QDSP5AUDPPCMDI_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - - A U D I O P O S T P R O C E S S I N G I N T E R N A L C O M M A N D S - -GENERAL DESCRIPTION - This file contains defintions of format blocks of commands - that are accepted by AUDPP Task - -REFERENCES - None - -EXTERNALIZED FUNCTIONS - None - -Copyright(c) 1992-2009, 2012-2013 The Linux Foundation. All rights reserved. - -This software is licensed under the terms of the GNU General Public -License version 2, as published by the Free Software Foundation, and -may be copied, distributed, and modified under those terms. - -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. - -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ -/*=========================================================================== - - EDIT HISTORY FOR FILE - -This section contains comments describing changes made to this file. -Notice that changes are listed in reverse chronological order. - -$Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audppcmdi.h#2 $ - -===========================================================================*/ - -/* - * ARM to AUDPPTASK Commands - * - * ARM uses three command queues to communicate with AUDPPTASK - * 1)uPAudPPCmd1Queue : Used for more frequent and shorter length commands - * Location : MEMA - * Buffer Size : 6 words - * No of buffers in a queue : 20 for gaming audio and 5 for other images - * 2)uPAudPPCmd2Queue : Used for commands which are not much lengthier - * Location : MEMA - * Buffer Size : 23 - * No of buffers in a queue : 2 - * 3)uPAudOOCmd3Queue : Used for lengthier and more frequent commands - * Location : MEMA - * Buffer Size : 145 - * No of buffers in a queue : 3 - */ - -/* - * Commands Related to uPAudPPCmd1Queue - */ - -/* - * Command Structure to enable or disable the active decoders - */ - -#define AUDPP_CMD_CFG_DEC_TYPE 0x0001 -#define AUDPP_CMD_CFG_DEC_TYPE_LEN sizeof(audpp_cmd_cfg_dec_type) - -/* Enable the decoder */ -#define AUDPP_CMD_DEC_TYPE_M 0x000F - -#define AUDPP_CMD_ENA_DEC_V 0x4000 -#define AUDPP_CMD_DIS_DEC_V 0x0000 -#define AUDPP_CMD_DEC_STATE_M 0x4000 -#define AUDPP_CMD_LPA_MODE 0x2000 - -#define AUDPP_CMD_UPDATDE_CFG_DEC 0x8000 -#define AUDPP_CMD_DONT_UPDATE_CFG_DEC 0x0000 - - -/* Type specification of cmd_cfg_dec */ - -typedef struct { - unsigned short cmd_id; - unsigned short dec0_cfg; - unsigned short dec1_cfg; - unsigned short dec2_cfg; - unsigned short dec3_cfg; - unsigned short dec4_cfg; -} __attribute__((packed)) audpp_cmd_cfg_dec_type; - -/* - * Command Structure to Pause , Resume and flushes the selected audio decoders - */ - -#define AUDPP_CMD_DEC_CTRL 0x0002 -#define AUDPP_CMD_DEC_CTRL_LEN sizeof(audpp_cmd_dec_ctrl) - -/* Decoder control commands for pause, resume and flush */ -#define AUDPP_CMD_FLUSH_V 0x2000 - -#define AUDPP_CMD_PAUSE_V 0x4000 -#define AUDPP_CMD_RESUME_V 0x0000 - -#define AUDPP_CMD_UPDATE_V 0x8000 -#define AUDPP_CMD_IGNORE_V 0x0000 - - -/* Type Spec for decoder control command*/ - -typedef struct { - unsigned short cmd_id; - unsigned short dec0_ctrl; - unsigned short dec1_ctrl; - unsigned short dec2_ctrl; - unsigned short dec3_ctrl; - unsigned short dec4_ctrl; -} __attribute__((packed)) audpp_cmd_dec_ctrl; - -/* - * Command Structure to Configure the AVSync FeedBack Mechanism - */ - -#define AUDPP_CMD_AVSYNC 0x0003 -#define AUDPP_CMD_AVSYNC_LEN sizeof(audpp_cmd_avsync) - -typedef struct { - unsigned short cmd_id; - unsigned short object_number; - unsigned short interrupt_interval_lsw; - unsigned short interrupt_interval_msw; -} __attribute__((packed)) audpp_cmd_avsync; - -/* - * Command Structure to enable or disable(sleep) the AUDPPTASK - */ - -#define AUDPP_CMD_CFG 0x0004 -#define AUDPP_CMD_CFG_LEN sizeof(audpp_cmd_cfg) - -#define AUDPP_CMD_CFG_SLEEP 0x0000 -#define AUDPP_CMD_CFG_ENABLE 0xFFFF - -typedef struct { - unsigned short cmd_id; - unsigned short cfg; -} __attribute__((packed)) audpp_cmd_cfg; - -/* - * Command Structure to Inject or drop the specified no of samples - */ - -#define AUDPP_CMD_ADJUST_SAMP 0x0005 -#define AUDPP_CMD_ADJUST_SAMP_LEN sizeof(audpp_cmd_adjust_samp) - -#define AUDPP_CMD_SAMP_DROP -1 -#define AUDPP_CMD_SAMP_INSERT 0x0001 - -#define AUDPP_CMD_NUM_SAMPLES 0x0001 - -typedef struct { - unsigned short cmd_id; - unsigned short object_no; - signed short sample_insert_or_drop; - unsigned short num_samples; -} __attribute__((packed)) audpp_cmd_adjust_samp; - -/* - * Command Structure to Configure AVSync Feedback Mechanism - */ - -#define AUDPP_CMD_AVSYNC_CMD_2 0x0006 -#define AUDPP_CMD_AVSYNC_CMD_2_LEN sizeof(audpp_cmd_avsync_cmd_2) - -typedef struct { - unsigned short cmd_id; - unsigned short object_number; - unsigned short interrupt_interval_lsw; - unsigned short interrupt_interval_msw; - unsigned short sample_counter_dlsw; - unsigned short sample_counter_dmsw; - unsigned short sample_counter_msw; - unsigned short byte_counter_dlsw; - unsigned short byte_counter_dmsw; - unsigned short byte_counter_msw; -} __attribute__((packed)) audpp_cmd_avsync_cmd_2; - -/* - * Command Structure to Configure AVSync Feedback Mechanism - */ - -#define AUDPP_CMD_AVSYNC_CMD_3 0x0007 -#define AUDPP_CMD_AVSYNC_CMD_3_LEN sizeof(audpp_cmd_avsync_cmd_3) - -typedef struct { - unsigned short cmd_id; - unsigned short object_number; - unsigned short interrupt_interval_lsw; - unsigned short interrupt_interval_msw; - unsigned short sample_counter_dlsw; - unsigned short sample_counter_dmsw; - unsigned short sample_counter_msw; - unsigned short byte_counter_dlsw; - unsigned short byte_counter_dmsw; - unsigned short byte_counter_msw; -} __attribute__((packed)) audpp_cmd_avsync_cmd_3; - -#define AUDPP_CMD_ROUTING_MODE 0x0008 -#define AUDPP_CMD_ROUTING_MODE_LEN \ -sizeof(struct audpp_cmd_routing_mode) - -struct audpp_cmd_routing_mode { - unsigned short cmd_id; - unsigned short object_number; - unsigned short routing_mode; -} __attribute__((packed)); - -/* - * Commands Related to uPAudPPCmd2Queue - */ - -/* - * Command Structure to configure Per decoder Parameters (Common) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS 0x0000 -#define AUDPP_CMD_CFG_ADEC_PARAMS_COMMON_LEN \ - sizeof(audpp_cmd_cfg_adec_params_common) - -#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_FCM 0x4000 -#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_FCM 0x0000 - -#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_DCM 0x8000 -#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_DCM 0x0000 - -/* Sampling frequency*/ -#define AUDPP_CMD_SAMP_RATE_96000 0x0000 -#define AUDPP_CMD_SAMP_RATE_88200 0x0001 -#define AUDPP_CMD_SAMP_RATE_64000 0x0002 -#define AUDPP_CMD_SAMP_RATE_48000 0x0003 -#define AUDPP_CMD_SAMP_RATE_44100 0x0004 -#define AUDPP_CMD_SAMP_RATE_32000 0x0005 -#define AUDPP_CMD_SAMP_RATE_24000 0x0006 -#define AUDPP_CMD_SAMP_RATE_22050 0x0007 -#define AUDPP_CMD_SAMP_RATE_16000 0x0008 -#define AUDPP_CMD_SAMP_RATE_12000 0x0009 -#define AUDPP_CMD_SAMP_RATE_11025 0x000A -#define AUDPP_CMD_SAMP_RATE_8000 0x000B - - -/* - * Type specification of cmd_adec_cfg sent to all decoder - */ - -typedef struct { - unsigned short cmd_id; - unsigned short length; - unsigned short dec_id; - unsigned short status_msg_flag; - unsigned short decoder_frame_counter_msg_period; - unsigned short input_sampling_frequency; -} __attribute__((packed)) audpp_cmd_cfg_adec_params_common; - -/* - * Command Structure to configure Per decoder Parameters (Wav) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN \ - sizeof(audpp_cmd_cfg_adec_params_wav) - - -#define AUDPP_CMD_WAV_STEREO_CFG_MONO 0x0001 -#define AUDPP_CMD_WAV_STEREO_CFG_STEREO 0x0002 - -#define AUDPP_CMD_WAV_PCM_WIDTH_8 0x0000 -#define AUDPP_CMD_WAV_PCM_WIDTH_16 0x0001 -#define AUDPP_CMD_WAV_PCM_WIDTH_24 0x0002 - -typedef struct { - audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; - unsigned short pcm_width; - unsigned short sign; -} __attribute__((packed)) audpp_cmd_cfg_adec_params_wav; - -/* - * Command Structure to configure Per decoder Parameters (ADPCM) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_ADPCM_LEN \ - sizeof(audpp_cmd_cfg_adec_params_adpcm) - - -#define AUDPP_CMD_ADPCM_STEREO_CFG_MONO 0x0001 -#define AUDPP_CMD_ADPCM_STEREO_CFG_STEREO 0x0002 - -typedef struct { - audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; - unsigned short block_size; -} __attribute__((packed)) audpp_cmd_cfg_adec_params_adpcm; - -/* - * Command Structure to configure Per decoder Parameters (WMA) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_WMA_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_wma) - -struct audpp_cmd_cfg_adec_params_wma { - audpp_cmd_cfg_adec_params_common common; - unsigned short armdatareqthr; - unsigned short channelsdecoded; - unsigned short wmabytespersec; - unsigned short wmasamplingfreq; - unsigned short wmaencoderopts; -} __attribute__((packed)); - -/* - * Command Structure to configure Per decoder Parameters (WMAPRO) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_WMAPRO_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_wmapro) - -struct audpp_cmd_cfg_adec_params_wmapro { - audpp_cmd_cfg_adec_params_common common; - unsigned short armdatareqthr; - uint8_t validbitspersample; - uint8_t numchannels; - unsigned short formattag; - unsigned short samplingrate; - unsigned short avgbytespersecond; - unsigned short asfpacketlength; - unsigned short channelmask; - unsigned short encodeopt; - unsigned short advancedencodeopt; - uint32_t advancedencodeopt2; -} __attribute__((packed)); - -/* - * Command Structure to configure Per decoder Parameters (MP3) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_MP3_LEN \ - sizeof(audpp_cmd_cfg_adec_params_mp3) - -typedef struct { - audpp_cmd_cfg_adec_params_common common; -} __attribute__((packed)) audpp_cmd_cfg_adec_params_mp3; - - -/* - * Command Structure to configure Per decoder Parameters (AAC) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_AAC_LEN \ - sizeof(audpp_cmd_cfg_adec_params_aac) - - -#define AUDPP_CMD_AAC_FORMAT_ADTS -1 -#define AUDPP_CMD_AAC_FORMAT_RAW 0x0000 -#define AUDPP_CMD_AAC_FORMAT_PSUEDO_RAW 0x0001 -#define AUDPP_CMD_AAC_FORMAT_LOAS 0x0002 - -#define AUDPP_CMD_AAC_AUDIO_OBJECT_LC 0x0002 -#define AUDPP_CMD_AAC_AUDIO_OBJECT_LTP 0x0004 -#define AUDPP_CMD_AAC_AUDIO_OBJECT_ERLC 0x0011 - -#define AUDPP_CMD_AAC_SBR_ON_FLAG_ON 0x0001 -#define AUDPP_CMD_AAC_SBR_ON_FLAG_OFF 0x0000 - -#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_ON 0x0001 -#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_OFF 0x0000 - -typedef struct { - audpp_cmd_cfg_adec_params_common common; - signed short format; - unsigned short audio_object; - unsigned short ep_config; - unsigned short aac_section_data_resilience_flag; - unsigned short aac_scalefactor_data_resilience_flag; - unsigned short aac_spectral_data_resilience_flag; - unsigned short sbr_on_flag; - unsigned short sbr_ps_on_flag; - unsigned short channel_configuration; -} __attribute__((packed)) audpp_cmd_cfg_adec_params_aac; - -/* - * Command Structure to configure Per decoder Parameters (V13K) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_v13k) - - -#define AUDPP_CMD_STEREO_CFG_MONO 0x0001 -#define AUDPP_CMD_STEREO_CFG_STEREO 0x0002 - -struct audpp_cmd_cfg_adec_params_v13k { - audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; -} __attribute__((packed)); - -#define AUDPP_CMD_CFG_ADEC_PARAMS_EVRC_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_evrc) - -struct audpp_cmd_cfg_adec_params_evrc { - audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; -} __attribute__ ((packed)); - -/* - * Command Structure to configure Per decoder Parameters (AMRWB) - */ -#define ADEC_PARAMS_AC3_INDEX 14 - -struct audpp_cmd_cfg_adec_params_amrwb { - audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; -} __attribute__((packed)) ; - -#define AUDPP_CMD_CFG_ADEC_PARAMS_AMRWB_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_amrwb) - -/* - * Command Structure to configure Per decoder Parameters (AC3) - */ - -struct audpp_cmd_cfg_adec_params_ac3 { - audpp_cmd_cfg_adec_params_common common; - unsigned short index[ADEC_PARAMS_AC3_INDEX]; -} __packed; - -#define AUDPP_CMD_CFG_ADEC_PARAMS_AC3_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_ac3) - -/* - * Command Structure to configure the HOST PCM interface - */ - -#define AUDPP_CMD_PCM_INTF 0x0001 -#define AUDPP_CMD_PCM_INTF_2 0x0002 -#define AUDPP_CMD_PCM_INTF_LEN sizeof(audpp_cmd_pcm_intf) - -#define AUDPP_CMD_PCM_INTF_MONO_V 0x0001 -#define AUDPP_CMD_PCM_INTF_STEREO_V 0x0002 - -/* These two values differentiate the two types of commands that could be issued - * Interface configuration command and Buffer update command */ - -#define AUDPP_CMD_PCM_INTF_CONFIG_CMD_V 0x0000 -#define AUDPP_CMD_PCM_INTF_BUFFER_CMD_V -1 - -#define AUDPP_CMD_PCM_INTF_RX_ENA_M 0x000F -#define AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V 0x0008 -#define AUDPP_CMD_PCM_INTF_RX_ENA_DSPTOARM_V 0x0004 - -/* These flags control the enabling and disabling of the interface together - * with host interface bit mask. */ - -#define AUDPP_CMD_PCM_INTF_ENA_V -1 -#define AUDPP_CMD_PCM_INTF_DIS_V 0x0000 - - -#define AUDPP_CMD_PCM_INTF_FULL_DUPLEX 0x0 -#define AUDPP_CMD_PCM_INTF_HALF_DUPLEX_TODSP 0x1 - - -#define AUDPP_CMD_PCM_INTF_OBJECT_NUM 0x5 -#define AUDPP_CMD_PCM_INTF_COMMON_OBJECT_NUM 0x6 - - -typedef struct { - unsigned short cmd_id; - unsigned short object_num; - signed short config; - unsigned short intf_type; - - /* DSP -> ARM Configuration */ - unsigned short read_buf1LSW; - unsigned short read_buf1MSW; - unsigned short read_buf1_len; - - unsigned short read_buf2LSW; - unsigned short read_buf2MSW; - unsigned short read_buf2_len; - /* 0:HOST_PCM_INTF disable - ** 0xFFFF: HOST_PCM_INTF enable - */ - signed short dsp_to_arm_flag; - unsigned short partition_number; - - /* ARM -> DSP Configuration */ - unsigned short write_buf1LSW; - unsigned short write_buf1MSW; - unsigned short write_buf1_len; - - unsigned short write_buf2LSW; - unsigned short write_buf2MSW; - unsigned short write_buf2_len; - - /* 0:HOST_PCM_INTF disable - ** 0xFFFF: HOST_PCM_INTF enable - */ - signed short arm_to_rx_flag; - unsigned short weight_decoder_to_rx; - unsigned short weight_arm_to_rx; - - unsigned short partition_number_arm_to_dsp; - unsigned short sample_rate; - unsigned short channel_mode; -} __attribute__((packed)) audpp_cmd_pcm_intf; - -/* - ** BUFFER UPDATE COMMAND - */ -#define AUDPP_CMD_PCM_INTF_SEND_BUF_PARAMS_LEN \ - sizeof(audpp_cmd_pcm_intf_send_buffer) - -typedef struct { - unsigned short cmd_id; - unsigned short host_pcm_object; - /* set config = 0xFFFF for configuration*/ - signed short config; - unsigned short intf_type; - unsigned short dsp_to_arm_buf_id; - unsigned short arm_to_dsp_buf_id; - unsigned short arm_to_dsp_buf_len; -} __attribute__((packed)) audpp_cmd_pcm_intf_send_buffer; - -#define AUDPP_CMD_PP_FEAT_QUERY_PARAMS 0x0003 - -struct rtc_audpp_read_data { - unsigned short cmd_id; - unsigned short obj_id; - unsigned short feature_id; - unsigned short extbufsizemsw; - unsigned short extbufsizelsw; - unsigned short extpart; - unsigned short extbufstartmsw; - unsigned short extbufstartlsw; -} __packed ; - -/* - * Commands Related to uPAudPPCmd3Queue - */ - -/* - * Command Structure to configure post processing params (Commmon) - */ - -#define AUDPP_CMD_CFG_OBJECT_PARAMS 0x0000 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN \ - sizeof(audpp_cmd_cfg_object_params_common) - -#define AUDPP_CMD_OBJ0_UPDATE 0x8000 -#define AUDPP_CMD_OBJ0_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_OBJ1_UPDATE 0x8000 -#define AUDPP_CMD_OBJ1_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_OBJ2_UPDATE 0x8000 -#define AUDPP_CMD_OBJ2_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_OBJ3_UPDATE 0x8000 -#define AUDPP_CMD_OBJ3_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_OBJ4_UPDATE 0x8000 -#define AUDPP_CMD_OBJ4_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_HPCM_UPDATE 0x8000 -#define AUDPP_CMD_HPCM_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_COMMON_CFG_UPDATE 0x8000 -#define AUDPP_CMD_COMMON_CFG_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_COPP_STREAM 0x0006 - -typedef struct { - unsigned short cmd_id; - unsigned short obj0_cfg; - unsigned short obj1_cfg; - unsigned short obj2_cfg; - unsigned short obj3_cfg; - unsigned short obj4_cfg; - unsigned short host_pcm_obj_cfg; - unsigned short comman_cfg; - unsigned short command_type; -} __attribute__((packed)) audpp_cmd_cfg_object_params_common; - -/* - * Command Structure to configure post processing params (Volume) - */ - -#define AUDPP_CMD_VOLUME_PAN 0 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_VOLUME_LEN \ - sizeof(audpp_cmd_cfg_object_params_volume) - -typedef struct { - audpp_cmd_cfg_object_params_common common; - unsigned short volume; - unsigned short pan; -} __attribute__((packed)) audpp_cmd_cfg_object_params_volume; - -/* - * Command Structure to configure post processing params (PCM Filter) --DOUBT - */ - -typedef struct { - unsigned short numerator_b0_filter_lsw; - unsigned short numerator_b0_filter_msw; - unsigned short numerator_b1_filter_lsw; - unsigned short numerator_b1_filter_msw; - unsigned short numerator_b2_filter_lsw; - unsigned short numerator_b2_filter_msw; -} __attribute__((packed)) numerator; - -typedef struct { - unsigned short denominator_a0_filter_lsw; - unsigned short denominator_a0_filter_msw; - unsigned short denominator_a1_filter_lsw; - unsigned short denominator_a1_filter_msw; -} __attribute__((packed)) denominator; - -typedef struct { - unsigned short shift_factor_0; -} __attribute__((packed)) shift_factor; - -typedef struct { - unsigned short pan_filter_0; -} __attribute__((packed)) pan; - -typedef struct { - numerator numerator_filter; - denominator denominator_filter; - shift_factor shift_factor_filter; - pan pan_filter; -} __attribute__((packed)) filter_1; - -typedef struct { - numerator numerator_filter[2]; - denominator denominator_filter[2]; - shift_factor shift_factor_filter[2]; - pan pan_filter[2]; -} __attribute__((packed)) filter_2; - -typedef struct { - numerator numerator_filter[3]; - denominator denominator_filter[3]; - shift_factor shift_factor_filter[3]; - pan pan_filter[3]; -} __attribute__((packed)) filter_3; - -typedef struct { - numerator numerator_filter[4]; - denominator denominator_filter[4]; - shift_factor shift_factor_filter[4]; - pan pan_filter[4]; -} __attribute__((packed)) filter_4; - -#define AUDPP_CMD_IIR_TUNING_FILTER 1 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_PCM_LEN \ - sizeof(audpp_cmd_cfg_object_params_pcm) - - -typedef struct { - audpp_cmd_cfg_object_params_common common; - unsigned short active_flag; - unsigned short num_bands; - union { - filter_1 filter_1_params; - filter_2 filter_2_params; - filter_3 filter_3_params; - filter_4 filter_4_params; - } __attribute__((packed)) params_filter; -} __attribute__((packed)) audpp_cmd_cfg_object_params_pcm; - - -/* - * Command Structure to configure post processing parameters (equalizer) - */ - -#define AUDPP_CMD_EQUALIZER 2 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_EQALIZER_LEN \ - sizeof(audpp_cmd_cfg_object_params_eqalizer) - -typedef struct { - unsigned short numerator_coeff_0_lsw; - unsigned short numerator_coeff_0_msw; - unsigned short numerator_coeff_1_lsw; - unsigned short numerator_coeff_1_msw; - unsigned short numerator_coeff_2_lsw; - unsigned short numerator_coeff_2_msw; -} __attribute__((packed)) eq_numerator; - -typedef struct { - unsigned short denominator_coeff_0_lsw; - unsigned short denominator_coeff_0_msw; - unsigned short denominator_coeff_1_lsw; - unsigned short denominator_coeff_1_msw; -} __attribute__((packed)) eq_denominator; - -typedef struct { - unsigned short shift_factor; -} __attribute__((packed)) eq_shiftfactor; - -typedef struct { - eq_numerator numerator; - eq_denominator denominator; - eq_shiftfactor shiftfactor; -} __attribute__((packed)) eq_coeff_1; - -typedef struct { - eq_numerator numerator[2]; - eq_denominator denominator[2]; - eq_shiftfactor shiftfactor[2]; -} __attribute__((packed)) eq_coeff_2; - -typedef struct { - eq_numerator numerator[3]; - eq_denominator denominator[3]; - eq_shiftfactor shiftfactor[3]; -} __attribute__((packed)) eq_coeff_3; - -typedef struct { - eq_numerator numerator[4]; - eq_denominator denominator[4]; - eq_shiftfactor shiftfactor[4]; -} __attribute__((packed)) eq_coeff_4; - -typedef struct { - eq_numerator numerator[5]; - eq_denominator denominator[5]; - eq_shiftfactor shiftfactor[5]; -} __attribute__((packed)) eq_coeff_5; - -typedef struct { - eq_numerator numerator[6]; - eq_denominator denominator[6]; - eq_shiftfactor shiftfactor[6]; -} __attribute__((packed)) eq_coeff_6; - -typedef struct { - eq_numerator numerator[7]; - eq_denominator denominator[7]; - eq_shiftfactor shiftfactor[7]; -} __attribute__((packed)) eq_coeff_7; - -typedef struct { - eq_numerator numerator[8]; - eq_denominator denominator[8]; - eq_shiftfactor shiftfactor[8]; -} __attribute__((packed)) eq_coeff_8; - -typedef struct { - eq_numerator numerator[9]; - eq_denominator denominator[9]; - eq_shiftfactor shiftfactor[9]; -} __attribute__((packed)) eq_coeff_9; - -typedef struct { - eq_numerator numerator[10]; - eq_denominator denominator[10]; - eq_shiftfactor shiftfactor[10]; -} __attribute__((packed)) eq_coeff_10; - -typedef struct { - eq_numerator numerator[11]; - eq_denominator denominator[11]; - eq_shiftfactor shiftfactor[11]; -} __attribute__((packed)) eq_coeff_11; - -typedef struct { - eq_numerator numerator[12]; - eq_denominator denominator[12]; - eq_shiftfactor shiftfactor[12]; -} __attribute__((packed)) eq_coeff_12; - - -typedef struct { - audpp_cmd_cfg_object_params_common common; - unsigned short eq_flag; - unsigned short num_bands; - union { - eq_coeff_1 eq_coeffs_1; - eq_coeff_2 eq_coeffs_2; - eq_coeff_3 eq_coeffs_3; - eq_coeff_4 eq_coeffs_4; - eq_coeff_5 eq_coeffs_5; - eq_coeff_6 eq_coeffs_6; - eq_coeff_7 eq_coeffs_7; - eq_coeff_8 eq_coeffs_8; - eq_coeff_9 eq_coeffs_9; - eq_coeff_10 eq_coeffs_10; - eq_coeff_11 eq_coeffs_11; - eq_coeff_12 eq_coeffs_12; - } __attribute__((packed)) eq_coeff; -} __attribute__((packed)) audpp_cmd_cfg_object_params_eqalizer; - - -/* - * Command Structure to configure post processing parameters (ADRC) - */ - -#define AUDPP_CMD_ADRC 3 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_ADRC_LEN \ - sizeof(audpp_cmd_cfg_object_params_adrc) - - -#define AUDPP_CMD_ADRC_FLAG_DIS 0x0000 -#define AUDPP_CMD_ADRC_FLAG_ENA -1 - -#define AUDPP_CMD_MBADRC 10 -#define AUDPP_MAX_MBADRC_BANDS 5 -#define AUDPP_MBADRC_EXTERNAL_BUF_SIZE 196 - -struct adrc_config { - uint16_t subband_enable; - uint16_t adrc_sub_mute; - uint16_t rms_time; - uint16_t compression_th; - uint16_t compression_slope; - uint16_t attack_const_lsw; - uint16_t attack_const_msw; - uint16_t release_const_lsw; - uint16_t release_const_msw; - uint16_t makeup_gain; -}; - -typedef struct { - audpp_cmd_cfg_object_params_common common; - uint16_t enable; - uint16_t num_bands; - uint16_t down_samp_level; - uint16_t adrc_delay; - uint16_t ext_buf_size; - uint16_t ext_partition; - uint16_t ext_buf_msw; - uint16_t ext_buf_lsw; - struct adrc_config adrc_band[AUDPP_MAX_MBADRC_BANDS]; -} __attribute__((packed)) audpp_cmd_cfg_object_params_mbadrc; - -struct audpp_cmd_cfg_object_params_adrc { - unsigned short adrc_flag; - unsigned short compression_th; - unsigned short compression_slope; - unsigned short rms_time; - unsigned short attack_const_lsw; - unsigned short attack_const_msw; - unsigned short release_const_lsw; - unsigned short release_const_msw; - unsigned short adrc_delay; -}; - -/* - * Command Structure to configure post processing parameters(Spectrum Analizer) - */ - -#define AUDPP_CMD_SPECTROGRAM 4 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_SPECTRAM_LEN \ - sizeof(audpp_cmd_cfg_object_params_spectram) - - -typedef struct { - audpp_cmd_cfg_object_params_common common; - unsigned short sample_interval; - unsigned short num_coeff; -} __attribute__((packed)) audpp_cmd_cfg_object_params_spectram; - -/* - * Command Structure to configure post processing parameters (QConcert) - */ - -#define AUDPP_CMD_QCONCERT 5 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_QCONCERT_LEN \ - sizeof(audpp_cmd_cfg_object_params_qconcert) - - -#define AUDPP_CMD_QCON_ENA_FLAG_ENA -1 -#define AUDPP_CMD_QCON_ENA_FLAG_DIS 0x0000 - -#define AUDPP_CMD_QCON_OP_MODE_HEADPHONE -1 -#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_FRONT 0x0000 -#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_SIDE 0x0001 -#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_DESKTOP 0x0002 - -#define AUDPP_CMD_QCON_GAIN_UNIT 0x7FFF -#define AUDPP_CMD_QCON_GAIN_SIX_DB 0x4027 - - -#define AUDPP_CMD_QCON_EXPANSION_MAX 0x7FFF - - -typedef struct { - audpp_cmd_cfg_object_params_common common; - signed short enable_flag; - signed short op_mode; - signed short gain; - signed short expansion; - signed short delay; - unsigned short stages_per_mode; - unsigned short reverb_enable; - unsigned short decay_msw; - unsigned short decay_lsw; - unsigned short decay_time_ratio_msw; - unsigned short decay_time_ratio_lsw; - unsigned short reflection_delay_time; - unsigned short late_reverb_gain; - unsigned short late_reverb_delay; - unsigned short delay_buff_size_msw; - unsigned short delay_buff_size_lsw; - unsigned short partition_num; - unsigned short delay_buff_start_msw; - unsigned short delay_buff_start_lsw; -} __attribute__((packed)) audpp_cmd_cfg_object_params_qconcert; - -/* - * Command Structure to configure post processing parameters (Side Chain) - */ - -#define AUDPP_CMD_SIDECHAIN_TUNING_FILTER 6 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_SIDECHAIN_LEN \ - sizeof(audpp_cmd_cfg_object_params_sidechain) - - -#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_DIS 0x0000 -#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_ENA -1 - -typedef struct { - audpp_cmd_cfg_object_params_common common; - signed short active_flag; - unsigned short num_bands; - union { - filter_1 filter_1_params; - filter_2 filter_2_params; - filter_3 filter_3_params; - filter_4 filter_4_params; - } __attribute__((packed)) params_filter; -} __attribute__((packed)) audpp_cmd_cfg_object_params_sidechain; - - -/* - * Command Structure to configure post processing parameters (QAFX) - */ - -#define AUDPP_CMD_QAFX 8 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_QAFX_LEN \ - sizeof(audpp_cmd_cfg_object_params_qafx) - -#define AUDPP_CMD_QAFX_ENA_DISA 0x0000 -#define AUDPP_CMD_QAFX_ENA_ENA_CFG -1 -#define AUDPP_CMD_QAFX_ENA_DIS_CFG 0x0001 - -#define AUDPP_CMD_QAFX_CMD_TYPE_ENV 0x0100 -#define AUDPP_CMD_QAFX_CMD_TYPE_OBJ 0x0010 -#define AUDPP_CMD_QAFX_CMD_TYPE_QUERY 0x1000 - -#define AUDPP_CMD_QAFX_CMDS_ENV_OP_MODE 0x0100 -#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_POS 0x0101 -#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_ORI 0x0102 -#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_VEL 0X0103 -#define AUDPP_CMD_QAFX_CMDS_ENV_ENV_RES 0x0107 - -#define AUDPP_CMD_QAFX_CMDS_OBJ_SAMP_FREQ 0x0010 -#define AUDPP_CMD_QAFX_CMDS_OBJ_VOL 0x0011 -#define AUDPP_CMD_QAFX_CMDS_OBJ_DIST 0x0012 -#define AUDPP_CMD_QAFX_CMDS_OBJ_POS 0x0013 -#define AUDPP_CMD_QAFX_CMDS_OBJ_VEL 0x0014 - - -typedef struct { - audpp_cmd_cfg_object_params_common common; - signed short enable; - unsigned short command_type; - unsigned short num_commands; - unsigned short commands; -} __attribute__((packed)) audpp_cmd_cfg_object_params_qafx; - -/* - * Command Structure to enable , disable or configure the reverberation effect - * (Common) - */ - -#define AUDPP_CMD_REVERB_CONFIG 0x0001 -#define AUDPP_CMD_REVERB_CONFIG_COMMON_LEN \ - sizeof(audpp_cmd_reverb_config_common) - -#define AUDPP_CMD_ENA_ENA 0xFFFF -#define AUDPP_CMD_ENA_DIS 0x0000 -#define AUDPP_CMD_ENA_CFG 0x0001 - -#define AUDPP_CMD_CMD_TYPE_ENV 0x0104 -#define AUDPP_CMD_CMD_TYPE_OBJ 0x0015 -#define AUDPP_CMD_CMD_TYPE_QUERY 0x1000 - -#define SRS_PARAMS_MAX_G 8 -#define SRS_PARAMS_MAX_W 55 -#define SRS_PARAMS_MAX_C 51 -#define SRS_PARAMS_MAX_H 53 -#define SRS_PARAMS_MAX_P 116 -#define SRS_PARAMS_MAX_L 8 - -typedef struct { - unsigned short cmd_id; - unsigned short enable; - unsigned short cmd_type; -} __attribute__((packed)) audpp_cmd_reverb_config_common; - -/* - * Command Structure to enable , disable or configure the reverberation effect - * (ENV-0x0104) - */ - -#define AUDPP_CMD_REVERB_CONFIG_ENV_104_LEN \ - sizeof(audpp_cmd_reverb_config_env_104) - -typedef struct { - audpp_cmd_reverb_config_common common; - unsigned short env_gain; - unsigned short decay_msw; - unsigned short decay_lsw; - unsigned short decay_timeratio_msw; - unsigned short decay_timeratio_lsw; - unsigned short delay_time; - unsigned short reverb_gain; - unsigned short reverb_delay; -} __attribute__((packed)) audpp_cmd_reverb_config_env_104; - -/* - * Command Structure to enable , disable or configure the reverberation effect - * (ENV-0x0015) - */ - -#define AUDPP_CMD_REVERB_CONFIG_ENV_15_LEN \ - sizeof(audpp_cmd_reverb_config_env_15) - -typedef struct { - audpp_cmd_reverb_config_common common; - unsigned short object_num; - unsigned short absolute_gain; -} __attribute__((packed)) audpp_cmd_reverb_config_env_15; - -/* - * Command Structure to configure post processing params (SRS TruMedia) - */ -struct audpp_cmd_cfg_object_params_srstm_g { - audpp_cmd_cfg_object_params_common common; - unsigned short v[SRS_PARAMS_MAX_G]; -} __packed; -struct audpp_cmd_cfg_object_params_srstm_w { - audpp_cmd_cfg_object_params_common common; - unsigned short v[SRS_PARAMS_MAX_W]; -} __packed; -struct audpp_cmd_cfg_object_params_srstm_c { - audpp_cmd_cfg_object_params_common common; - unsigned short v[SRS_PARAMS_MAX_C]; -} __packed; -struct audpp_cmd_cfg_object_params_srstm_h { - audpp_cmd_cfg_object_params_common common; - unsigned short v[SRS_PARAMS_MAX_H]; -} __packed; -struct audpp_cmd_cfg_object_params_srstm_p { - audpp_cmd_cfg_object_params_common common; - unsigned short v[SRS_PARAMS_MAX_P]; -} __packed; -struct audpp_cmd_cfg_object_params_srstm_l { - audpp_cmd_cfg_object_params_common common; - unsigned short v[SRS_PARAMS_MAX_L]; -} __packed; -#define AUDPP_CMD_SAMPLING_FREQUENCY 7 -#define AUDPP_CMD_QRUMBLE 9 -#define AUDPP_CMD_SRS 18 -#define AUDPP_DISABLE_FEATS_LSW 2 -#define AUDPP_DISABLE_FEATS_MSW 3 - -#endif /* QDSP5AUDPPCMDI_H */ - diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppmsg.h deleted file mode 100644 index 664e246f30eea02e55d87263dda1ed58a214ec12..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppmsg.h +++ /dev/null @@ -1,336 +0,0 @@ -#ifndef QDSP5AUDPPMSG_H -#define QDSP5AUDPPMSG_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - - Q D S P 5 A U D I O P O S T P R O C E S S I N G M S G - - GENERAL DESCRIPTION - Messages sent by AUDPPTASK to ARM - - REFERENCES - None - - EXTERNALIZED FUNCTIONS - None - - Copyright (c) 1992-2009, 2012-2013 The Linux Foundation. All rights reserved. - - This software is licensed under the terms of the GNU General Public - License version 2, as published by the Free Software Foundation, and - may be copied, distributed, and modified under those terms. - - 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. - -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ -/*=========================================================================== - - EDIT HISTORY FOR FILE - -This section contains comments describing changes made to this file. -Notice that changes are listed in reverse chronological order. - - $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audppmsg.h#4 $ - -===========================================================================*/ - -/* - * AUDPPTASK uses audPPuPRlist to send messages to the ARM - * Location : MEMA - * Buffer Size : 45 - * No of Buffers in a queue : 5 for gaming audio and 1 for other images - */ - -/* - * MSG to Informs the ARM os Success/Failure of bringing up the decoder - */ - -#define AUDPP_MSG_STATUS_MSG 0x0001 -#define AUDPP_MSG_STATUS_MSG_LEN \ - sizeof(audpp_msg_status_msg) - -#define AUDPP_MSG_STATUS_SLEEP 0x0000 -#define AUDPP_MSG_STATUS_INIT 0x0001 -#define AUDPP_MSG_STATUS_CFG 0x0002 -#define AUDPP_MSG_STATUS_PLAY 0x0003 - -#define AUDPP_MSG_REASON_NONE 0x0000 -#define AUDPP_MSG_REASON_MEM 0x0001 -#define AUDPP_MSG_REASON_NODECODER 0x0002 - -typedef struct{ - unsigned short dec_id; - unsigned short status; - unsigned short reason; -} __attribute__((packed)) audpp_msg_status_msg; - -/* - * MSG to communicate the spectrum analyzer output bands to the ARM - */ -#define AUDPP_MSG_SPA_BANDS 0x0002 -#define AUDPP_MSG_SPA_BANDS_LEN \ - sizeof(audpp_msg_spa_bands) - -typedef struct { - unsigned short current_object; - unsigned short spa_band_1; - unsigned short spa_band_2; - unsigned short spa_band_3; - unsigned short spa_band_4; - unsigned short spa_band_5; - unsigned short spa_band_6; - unsigned short spa_band_7; - unsigned short spa_band_8; - unsigned short spa_band_9; - unsigned short spa_band_10; - unsigned short spa_band_11; - unsigned short spa_band_12; - unsigned short spa_band_13; - unsigned short spa_band_14; - unsigned short spa_band_15; - unsigned short spa_band_16; - unsigned short spa_band_17; - unsigned short spa_band_18; - unsigned short spa_band_19; - unsigned short spa_band_20; - unsigned short spa_band_21; - unsigned short spa_band_22; - unsigned short spa_band_23; - unsigned short spa_band_24; - unsigned short spa_band_25; - unsigned short spa_band_26; - unsigned short spa_band_27; - unsigned short spa_band_28; - unsigned short spa_band_29; - unsigned short spa_band_30; - unsigned short spa_band_31; - unsigned short spa_band_32; -} __attribute__((packed)) audpp_msg_spa_bands; - -/* - * MSG to communicate the PCM I/O buffer status to ARM - */ -#define AUDPP_MSG_HOST_PCM_INTF_MSG 0x0003 -#define AUDPP_MSG_HOST_PCM_INTF_MSG_LEN \ - sizeof(audpp_msg_host_pcm_intf_msg) - -#define AUDPP_MSG_HOSTPCM_ID_TX_ARM 0x0000 -#define AUDPP_MSG_HOSTPCM_ID_ARM_TX 0x0001 -#define AUDPP_MSG_HOSTPCM_ID_RX_ARM 0x0002 -#define AUDPP_MSG_HOSTPCM_ID_ARM_RX 0x0003 - -#define AUDPP_MSG_SAMP_FREQ_INDX_96000 0x0000 -#define AUDPP_MSG_SAMP_FREQ_INDX_88200 0x0001 -#define AUDPP_MSG_SAMP_FREQ_INDX_64000 0x0002 -#define AUDPP_MSG_SAMP_FREQ_INDX_48000 0x0003 -#define AUDPP_MSG_SAMP_FREQ_INDX_44100 0x0004 -#define AUDPP_MSG_SAMP_FREQ_INDX_32000 0x0005 -#define AUDPP_MSG_SAMP_FREQ_INDX_24000 0x0006 -#define AUDPP_MSG_SAMP_FREQ_INDX_22050 0x0007 -#define AUDPP_MSG_SAMP_FREQ_INDX_16000 0x0008 -#define AUDPP_MSG_SAMP_FREQ_INDX_12000 0x0009 -#define AUDPP_MSG_SAMP_FREQ_INDX_11025 0x000A -#define AUDPP_MSG_SAMP_FREQ_INDX_8000 0x000B - -#define AUDPP_MSG_CHANNEL_MODE_MONO 0x0001 -#define AUDPP_MSG_CHANNEL_MODE_STEREO 0x0002 - -typedef struct{ - unsigned short obj_num; - unsigned short numbers_of_samples; - unsigned short host_pcm_id; - unsigned short buf_indx; - unsigned short samp_freq_indx; - unsigned short channel_mode; -} __attribute__((packed)) audpp_msg_host_pcm_intf_msg; - - -/* - * MSG to communicate 3D position of the source and listener , source volume - * source rolloff, source orientation - */ - -#define AUDPP_MSG_QAFX_POS 0x0004 -#define AUDPP_MSG_QAFX_POS_LEN \ - sizeof(audpp_msg_qafx_pos) - -typedef struct { - unsigned short current_object; - unsigned short x_pos_lis_msw; - unsigned short x_pos_lis_lsw; - unsigned short y_pos_lis_msw; - unsigned short y_pos_lis_lsw; - unsigned short z_pos_lis_msw; - unsigned short z_pos_lis_lsw; - unsigned short x_fwd_msw; - unsigned short x_fwd_lsw; - unsigned short y_fwd_msw; - unsigned short y_fwd_lsw; - unsigned short z_fwd_msw; - unsigned short z_fwd_lsw; - unsigned short x_up_msw; - unsigned short x_up_lsw; - unsigned short y_up_msw; - unsigned short y_up_lsw; - unsigned short z_up_msw; - unsigned short z_up_lsw; - unsigned short x_vel_lis_msw; - unsigned short x_vel_lis_lsw; - unsigned short y_vel_lis_msw; - unsigned short y_vel_lis_lsw; - unsigned short z_vel_lis_msw; - unsigned short z_vel_lis_lsw; - unsigned short threed_enable_flag; - unsigned short volume; - unsigned short x_pos_source_msw; - unsigned short x_pos_source_lsw; - unsigned short y_pos_source_msw; - unsigned short y_pos_source_lsw; - unsigned short z_pos_source_msw; - unsigned short z_pos_source_lsw; - unsigned short max_dist_0_msw; - unsigned short max_dist_0_lsw; - unsigned short min_dist_0_msw; - unsigned short min_dist_0_lsw; - unsigned short roll_off_factor; - unsigned short mute_after_max_flag; - unsigned short x_vel_source_msw; - unsigned short x_vel_source_lsw; - unsigned short y_vel_source_msw; - unsigned short y_vel_source_lsw; - unsigned short z_vel_source_msw; - unsigned short z_vel_source_lsw; -} __attribute__((packed)) audpp_msg_qafx_pos; - -/* - * MSG to provide AVSYNC feedback from DSP to ARM - */ - -#define AUDPP_MSG_AVSYNC_MSG 0x0005 -#define AUDPP_MSG_AVSYNC_MSG_LEN \ - sizeof(audpp_msg_avsync_msg) - -typedef struct { - unsigned short active_flag; - unsigned short num_samples_counter0_HSW; - unsigned short num_samples_counter0_MSW; - unsigned short num_samples_counter0_LSW; - unsigned short num_bytes_counter0_HSW; - unsigned short num_bytes_counter0_MSW; - unsigned short num_bytes_counter0_LSW; - unsigned short samp_freq_obj_0; - unsigned short samp_freq_obj_1; - unsigned short samp_freq_obj_2; - unsigned short samp_freq_obj_3; - unsigned short samp_freq_obj_4; - unsigned short samp_freq_obj_5; - unsigned short samp_freq_obj_6; - unsigned short samp_freq_obj_7; - unsigned short samp_freq_obj_8; - unsigned short samp_freq_obj_9; - unsigned short samp_freq_obj_10; - unsigned short samp_freq_obj_11; - unsigned short samp_freq_obj_12; - unsigned short samp_freq_obj_13; - unsigned short samp_freq_obj_14; - unsigned short samp_freq_obj_15; - unsigned short num_samples_counter4_HSW; - unsigned short num_samples_counter4_MSW; - unsigned short num_samples_counter4_LSW; - unsigned short num_bytes_counter4_HSW; - unsigned short num_bytes_counter4_MSW; - unsigned short num_bytes_counter4_LSW; -} __attribute__((packed)) audpp_msg_avsync_msg; - -/* - * MSG to provide PCM DMA Missed feedback from the DSP to ARM - */ - -#define AUDPP_MSG_PCMDMAMISSED 0x0006 -#define AUDPP_MSG_PCMDMAMISSED_LEN \ - sizeof(audpp_msg_pcmdmamissed); - -typedef struct{ - /* - ** Bit 0 0 = PCM DMA not missed for object 0 - ** 1 = PCM DMA missed for object0 - ** Bit 1 0 = PCM DMA not missed for object 1 - ** 1 = PCM DMA missed for object1 - ** Bit 2 0 = PCM DMA not missed for object 2 - ** 1 = PCM DMA missed for object2 - ** Bit 3 0 = PCM DMA not missed for object 3 - ** 1 = PCM DMA missed for object3 - ** Bit 4 0 = PCM DMA not missed for object 4 - ** 1 = PCM DMA missed for object4 - */ - unsigned short pcmdmamissed; -} __attribute__((packed)) audpp_msg_pcmdmamissed; - -/* - * MSG to AUDPP enable or disable feedback form DSP to ARM - */ - -#define AUDPP_MSG_CFG_MSG 0x0007 -#define AUDPP_MSG_CFG_MSG_LEN \ - sizeof(audpp_msg_cfg_msg) - -#define AUDPP_MSG_ENA_ENA 0xFFFF -#define AUDPP_MSG_ENA_DIS 0x0000 - -typedef struct{ - /* Enabled - 0xffff - ** Disabled - 0 - */ - unsigned short enabled; -} __attribute__((packed)) audpp_msg_cfg_msg; - -/* - * MSG to communicate the reverb per object volume - */ - -#define AUDPP_MSG_QREVERB_VOLUME 0x0008 -#define AUDPP_MSG_QREVERB_VOLUME_LEN \ - sizeof(audpp_msg_qreverb_volume) - - -typedef struct { - unsigned short obj_0_gain; - unsigned short obj_1_gain; - unsigned short obj_2_gain; - unsigned short obj_3_gain; - unsigned short obj_4_gain; - unsigned short hpcm_obj_volume; -} __attribute__((packed)) audpp_msg_qreverb_volume; - -#define AUDPP_MSG_ROUTING_ACK 0x0009 -#define AUDPP_MSG_ROUTING_ACK_LEN \ - sizeof(struct audpp_msg_routing_ack) - -struct audpp_msg_routing_ack { - unsigned short dec_id; - unsigned short routing_mode; -} __attribute__((packed)); - -#define AUDPP_MSG_FLUSH_ACK 0x000A - -#define ADSP_MESSAGE_ID 0xFFFF - -#define AUDPP_MSG_FEAT_QUERY_DM_DONE 0x000b - -/* - * ADSP sends this message when a PP feature is disabled - * due to ADSP resource limitation. - */ -#define AUDPP_MSG_PP_DISABLE_FEEDBACK 0x000C - -/* - * This message is sent by ADSP if any PP features is disabled - * due to video and audio concurrency due to MIPS limitation and - * the video session is ended in ADSP. - */ -#define AUDPP_MSG_PP_FEATS_RE_ENABLE 0x000D - -#endif /* QDSP5AUDPPMSG_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproccmdi.h deleted file mode 100644 index 0fc1e4684f02673f5780973227c1380ed83c6bb8..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproccmdi.h +++ /dev/null @@ -1,268 +0,0 @@ -#ifndef QDSP5AUDPREPROCCMDI_H -#define QDSP5AUDPREPROCCMDI_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* -* -* A U D I O P R E P R O C E S S I N G I N T E R N A L C O M M A N D S -* -* GENERAL DESCRIPTION -* This file contains defintions of format blocks of commands -* that are accepted by AUDPREPROC Task -* -* REFERENCES -* None -* -* EXTERNALIZED FUNCTIONS -* None -* -* Copyright (c) 1992-2009, 2012 The Linux Foundation. All rights reserved. -* -* This software is licensed under the terms of the GNU General Public -* License version 2, as published by the Free Software Foundation, and -* may be copied, distributed, and modified under those terms. -* -* 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. -* -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ -/*=========================================================================== - - EDIT HISTORY FOR FILE - -This section contains comments describing changes made to this file. -Notice that changes are listed in reverse chronological order. - -$Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audpreproccmdi.h#2 $ - -===========================================================================*/ - -/* - * AUDIOPREPROC COMMANDS: - * ARM uses uPAudPreProcCmdQueue to communicate with AUDPREPROCTASK - * Location : MEMB - * Buffer size : 51 - * Number of buffers in a queue : 3 - */ - -/* - * Command to configure the parameters of AGC - */ - -#define AUDPREPROC_CMD_CFG_AGC_PARAMS 0x0000 -#define AUDPREPROC_CMD_CFG_AGC_PARAMS_LEN \ - sizeof(audpreproc_cmd_cfg_agc_params) - -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_SLOPE 0x0009 -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_TH 0x000A -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_SLOPE 0x000B -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_TH 0x000C -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_AIG_FLAG 0x000D -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_STATIC_GAIN 0x000E -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG 0x000F - -#define AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA -1 -#define AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS 0x0000 - -#define AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_ADP_GAIN -1 -#define AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_STATIC_GAIN 0x0000 - -#define AUDPREPROC_CMD_PARAM_MASK_RMS_TAY 0x0004 -#define AUDPREPROC_CMD_PARAM_MASK_RELEASEK 0x0005 -#define AUDPREPROC_CMD_PARAM_MASK_DELAY 0x0006 -#define AUDPREPROC_CMD_PARAM_MASK_ATTACKK 0x0007 -#define AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_SLOW 0x0008 -#define AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_FAST 0x0009 -#define AUDPREPROC_CMD_PARAM_MASK_AIG_RELEASEK 0x000A -#define AUDPREPROC_CMD_PARAM_MASK_AIG_MIN 0x000B -#define AUDPREPROC_CMD_PARAM_MASK_AIG_MAX 0x000C -#define AUDPREPROC_CMD_PARAM_MASK_LEAK_UP 0x000D -#define AUDPREPROC_CMD_PARAM_MASK_LEAK_DOWN 0x000E -#define AUDPREPROC_CMD_PARAM_MASK_AIG_ATTACKK 0x000F - -typedef struct { - unsigned short cmd_id; - unsigned short tx_agc_param_mask; - signed short tx_agc_enable_flag; - unsigned short comp_rlink_static_gain; - signed short comp_rlink_aig_flag; - unsigned short expander_rlink_th; - unsigned short expander_rlink_slope; - unsigned short compressor_rlink_th; - unsigned short compressor_rlink_slope; - unsigned short tx_adc_agc_param_mask; - unsigned short comp_rlink_aig_attackk; - unsigned short comp_rlink_aig_leak_down; - unsigned short comp_rlink_aig_leak_up; - unsigned short comp_rlink_aig_max; - unsigned short comp_rlink_aig_min; - unsigned short comp_rlink_aig_releasek; - unsigned short comp_rlink_aig_leakrate_fast; - unsigned short comp_rlink_aig_leakrate_slow; - unsigned short comp_rlink_attackk_msw; - unsigned short comp_rlink_attackk_lsw; - unsigned short comp_rlink_delay; - unsigned short comp_rlink_releasek_msw; - unsigned short comp_rlink_releasek_lsw; - unsigned short comp_rlink_rms_tav; -} __packed audpreproc_cmd_cfg_agc_params; - - -/* - * Command to configure the params of Advanved AGC - */ - -#define AUDPREPROC_CMD_CFG_AGC_PARAMS_2 0x0001 -#define AUDPREPROC_CMD_CFG_AGC_PARAMS_2_LEN \ - sizeof(audpreproc_cmd_cfg_agc_params_2) - -#define AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_ENA -1; -#define AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_DIS 0x0000; - -typedef struct { - unsigned short cmd_id; - unsigned short agc_param_mask; - signed short tx_agc_enable_flag; - unsigned short comp_static_gain; - unsigned short exp_th; - unsigned short exp_slope; - unsigned short comp_th; - unsigned short comp_slope; - unsigned short comp_rms_tav; - unsigned short comp_samp_mask; - unsigned short comp_attackk_msw; - unsigned short comp_attackk_lsw; - unsigned short comp_releasek_msw; - unsigned short comp_releasek_lsw; - unsigned short comp_delay; - unsigned short comp_makeup_gain; -} __attribute__((packed)) audpreproc_cmd_cfg_agc_params_2; - -/* - * Command to configure params for ns - */ - -#define AUDPREPROC_CMD_CFG_NS_PARAMS 0x0002 -#define AUDPREPROC_CMD_CFG_NS_PARAMS_LEN \ - sizeof(audpreproc_cmd_cfg_ns_params) - -#define AUDPREPROC_CMD_EC_MODE_NEW_NLMS_ENA 0x0001 -#define AUDPREPROC_CMD_EC_MODE_NEW_NLMS_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_DES_ENA 0x0002 -#define AUDPREPROC_CMD_EC_MODE_NEW_DES_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_NS_ENA 0x0004 -#define AUDPREPROC_CMD_EC_MODE_NEW_NS_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_CNI_ENA 0x0008 -#define AUDPREPROC_CMD_EC_MODE_NEW_CNI_DIS 0x0000 - -#define AUDPREPROC_CMD_EC_MODE_NEW_NLES_ENA 0x0010 -#define AUDPREPROC_CMD_EC_MODE_NEW_NLES_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_HB_ENA 0x0020 -#define AUDPREPROC_CMD_EC_MODE_NEW_HB_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_VA_ENA 0x0040 -#define AUDPREPROC_CMD_EC_MODE_NEW_VA_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_PCD_ENA 0x0080 -#define AUDPREPROC_CMD_EC_MODE_NEW_PCD_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_FEHI_ENA 0x0100 -#define AUDPREPROC_CMD_EC_MODE_NEW_FEHI_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_NEHI_ENA 0x0200 -#define AUDPREPROC_CMD_EC_MODE_NEW_NEHI_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_NLPP_ENA 0x0400 -#define AUDPREPROC_CMD_EC_MODE_NEW_NLPP_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_FNE_ENA 0x0800 -#define AUDPREPROC_CMD_EC_MODE_NEW_FNE_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEW_PRENLMS_ENA 0x1000 -#define AUDPREPROC_CMD_EC_MODE_NEW_PRENLMS_DIS 0x0000 - -typedef struct { - unsigned short cmd_id; - unsigned short ec_mode_new; - unsigned short dens_gamma_n; - unsigned short dens_nfe_block_size; - unsigned short dens_limit_ns; - unsigned short dens_limit_ns_d; - unsigned short wb_gamma_e; - unsigned short wb_gamma_n; -} __attribute__((packed)) audpreproc_cmd_cfg_ns_params; - -/* - * Command to configure parameters for IIR tuning filter - */ - -#define AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS 0x0003 -#define AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS_LEN \ - sizeof(audpreproc_cmd_cfg_iir_tuning_filter_params) - -#define AUDPREPROC_CMD_IIR_ACTIVE_FLAG_DIS 0x0000 -#define AUDPREPROC_CMD_IIR_ACTIVE_FLAG_ENA 0x0001 - -typedef struct { - unsigned short cmd_id; - unsigned short active_flag; - unsigned short num_bands; - unsigned short numerator_coeff_b0_filter0_lsw; - unsigned short numerator_coeff_b0_filter0_msw; - unsigned short numerator_coeff_b1_filter0_lsw; - unsigned short numerator_coeff_b1_filter0_msw; - unsigned short numerator_coeff_b2_filter0_lsw; - unsigned short numerator_coeff_b2_filter0_msw; - unsigned short numerator_coeff_b0_filter1_lsw; - unsigned short numerator_coeff_b0_filter1_msw; - unsigned short numerator_coeff_b1_filter1_lsw; - unsigned short numerator_coeff_b1_filter1_msw; - unsigned short numerator_coeff_b2_filter1_lsw; - unsigned short numerator_coeff_b2_filter1_msw; - unsigned short numerator_coeff_b0_filter2_lsw; - unsigned short numerator_coeff_b0_filter2_msw; - unsigned short numerator_coeff_b1_filter2_lsw; - unsigned short numerator_coeff_b1_filter2_msw; - unsigned short numerator_coeff_b2_filter2_lsw; - unsigned short numerator_coeff_b2_filter2_msw; - unsigned short numerator_coeff_b0_filter3_lsw; - unsigned short numerator_coeff_b0_filter3_msw; - unsigned short numerator_coeff_b1_filter3_lsw; - unsigned short numerator_coeff_b1_filter3_msw; - unsigned short numerator_coeff_b2_filter3_lsw; - unsigned short numerator_coeff_b2_filter3_msw; - unsigned short denominator_coeff_a0_filter0_lsw; - unsigned short denominator_coeff_a0_filter0_msw; - unsigned short denominator_coeff_a1_filter0_lsw; - unsigned short denominator_coeff_a1_filter0_msw; - unsigned short denominator_coeff_a0_filter1_lsw; - unsigned short denominator_coeff_a0_filter1_msw; - unsigned short denominator_coeff_a1_filter1_lsw; - unsigned short denominator_coeff_a1_filter1_msw; - unsigned short denominator_coeff_a0_filter2_lsw; - unsigned short denominator_coeff_a0_filter2_msw; - unsigned short denominator_coeff_a1_filter2_lsw; - unsigned short denominator_coeff_a1_filter2_msw; - unsigned short denominator_coeff_a0_filter3_lsw; - unsigned short denominator_coeff_a0_filter3_msw; - unsigned short denominator_coeff_a1_filter3_lsw; - unsigned short denominator_coeff_a1_filter3_msw; - - unsigned short shift_factor_filter0; - unsigned short shift_factor_filter1; - unsigned short shift_factor_filter2; - unsigned short shift_factor_filter3; - - unsigned short channel_selected0; - unsigned short channel_selected1; - unsigned short channel_selected2; - unsigned short channel_selected3; -} __attribute__((packed))audpreproc_cmd_cfg_iir_tuning_filter_params; - -#define AUDPREPROC_CMD_FEAT_QUERY_PARAMS 0x0004 - -struct rtc_audpreproc_read_data { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short feature_id; - unsigned short extbufsizemsw; - unsigned short extbufsizelsw; - unsigned short extpart; - unsigned short extbufstartmsw; - unsigned short extbufstartlsw; -} __packed ; -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreprocmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreprocmsg.h deleted file mode 100644 index 6a93279cb6b49da8b68aa02310f6bac781e46c59..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreprocmsg.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef QDSP5AUDPREPROCMSG_H -#define QDSP5AUDPREPROCMSG_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* -* -* A U D I O P R E P R O C E S S I N G M E S S A G E S -* -* GENERAL DESCRIPTION -* This file contains defintions of format blocks of messages -* that are rcvd by AUDPREPROC Task -* -* REFERENCES -* None -* -* EXTERNALIZED FUNCTIONS -* None -* -* Copyright (c) 1992-2009, 2012 The Linux Foundation. All rights reserved. -* -* This software is licensed under the terms of the GNU General Public -* License version 2, as published by the Free Software Foundation, and -* may be copied, distributed, and modified under those terms. -* -* 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. -* -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ -/*=========================================================================== - - EDIT HISTORY FOR FILE - -This section contains comments describing changes made to this file. -Notice that changes are listed in reverse chronological order. - - $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audpreprocmsg.h#3 $ - -===========================================================================*/ - -/* - * ADSPREPROCTASK Messages - * AUDPREPROCTASK uses audPreProcUpRlist to communicate with ARM - * Location : MEMA - * Message Length : 2 - */ - -/* - * Message to indicate particular feature has been enabled or disabled - */ - - -#define AUDPREPROC_MSG_CMD_CFG_DONE_MSG 0x0001 -#define AUDPREPROC_MSG_CMD_CFG_DONE_MSG_LEN \ - sizeof(audpreproc_msg_cmd_cfg_done_msg) - -#define AUDPREPROC_MSG_TYPE_AGC 0x0000 -#define AUDPREPROC_MSG_TYPE_NOISE_REDUCTION 0x0001 -#define AUDPREPROC_MSG_TYPE_IIR_FILTER 0x0002 - - -#define AUDPREPROC_MSG_STATUS_FLAG_ENA -1 -#define AUDPREPROC_MSG_STATUS_FLAG_DIS 0x0000 - -typedef struct { - unsigned short type; - signed short status_flag; -} __attribute__((packed)) audpreproc_msg_cmd_cfg_done_msg; - - -/* - * Message to indicate particular feature has selected for wrong samp freq - */ - -#define AUDPREPROC_MSG_ERROR_MSG_ID 0x0002 -#define AUDPREPROC_MSG_ERROR_MSG_ID_LEN \ - sizeof(audpreproc_msg_error_msg_id) - -#define AUDPREPROC_MSG_ERR_INDEX_NS 0x0000 - -typedef struct { - unsigned short err_index; -} __attribute__((packed)) audpreproc_msg_error_msg_id; - -#define AUDPREPROC_MSG_FEAT_QUERY_DM_DONE 0x0003 -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audreccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audreccmdi.h deleted file mode 100644 index 72f12c955fd8a9596290acbfee675069873c394f..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audreccmdi.h +++ /dev/null @@ -1,401 +0,0 @@ -#ifndef QDSP5AUDRECCMDI_H -#define QDSP5AUDRECCMDI_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - * - * A U D I O R E C O R D I N T E R N A L C O M M A N D S - * - * GENERAL DESCRIPTION - * This file contains defintions of format blocks of commands - * that are accepted by AUDREC Task - * - * REFERENCES - * None - * - * EXTERNALIZED FUNCTIONS - * None - * - * Copyright (c) 1992-2009, 2011 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - *====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ - -/*=========================================================================== - - EDIT HISTORY FOR FILE - -This section contains comments describing changes made to this file. -Notice that changes are listed in reverse chronological order. - - $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audreccmdi.h#3 $ - -============================================================================*/ - -/* - * AUDRECTASK COMMANDS - * ARM uses 2 queues to communicate with the AUDRECTASK - * 1.uPAudRecCmdQueue - * Location :MEMC - * Buffer Size : 8 - * No of Buffers in a queue : 3 - * 2.audRecUpBitStreamQueue - * Location : MEMC - * Buffer Size : 4 - * No of buffers in a queue : 2 - */ - -/* - * Commands on uPAudRecCmdQueue - */ - -/* - * Command to initiate and terminate the audio recording section - */ - -#define AUDREC_CMD_CFG 0x0000 -#define AUDREC_CMD_CFG_LEN sizeof(audrec_cmd_cfg) - -#define AUDREC_CMD_TYPE_0_INDEX_WAV 0x0000 -#define AUDREC_CMD_TYPE_0_INDEX_AAC 0x0001 -#define AUDREC_CMD_TYPE_0_INDEX_AMRNB 0x000A -#define AUDREC_CMD_TYPE_0_INDEX_EVRC 0x000B -#define AUDREC_CMD_TYPE_0_INDEX_QCELP 0x000C - -#define AUDREC_CMD_TYPE_0_ENA 0x4000 -#define AUDREC_CMD_TYPE_0_DIS 0x0000 - -#define AUDREC_CMD_TYPE_0_NOUPDATE 0x0000 -#define AUDREC_CMD_TYPE_0_UPDATE 0x8000 - -#define AUDREC_CMD_TYPE_1_INDEX_SBC 0x0002 - -#define AUDREC_CMD_TYPE_1_ENA 0x4000 -#define AUDREC_CMD_TYPE_1_DIS 0x0000 - -#define AUDREC_CMD_TYPE_1_NOUPDATE 0x0000 -#define AUDREC_CMD_TYPE_1_UPDATE 0x8000 - -typedef struct { - unsigned short cmd_id; - unsigned short type_0; - unsigned short type_1; -} __attribute__((packed)) audrec_cmd_cfg; - - -/* - * Command to configure the recording parameters for RecType0(AAC/WAV) encoder - */ - -#define AUDREC_CMD_AREC0PARAM_CFG 0x0001 -#define AUDREC_CMD_AREC0PARAM_CFG_LEN \ - sizeof(audrec_cmd_arec0param_cfg) - -#define AUDREC_CMD_SAMP_RATE_INDX_8000 0x000B -#define AUDREC_CMD_SAMP_RATE_INDX_11025 0x000A -#define AUDREC_CMD_SAMP_RATE_INDX_12000 0x0009 -#define AUDREC_CMD_SAMP_RATE_INDX_16000 0x0008 -#define AUDREC_CMD_SAMP_RATE_INDX_22050 0x0007 -#define AUDREC_CMD_SAMP_RATE_INDX_24000 0x0006 -#define AUDREC_CMD_SAMP_RATE_INDX_32000 0x0005 -#define AUDREC_CMD_SAMP_RATE_INDX_44100 0x0004 -#define AUDREC_CMD_SAMP_RATE_INDX_48000 0x0003 - -#define AUDREC_CMD_STEREO_MODE_MONO 0x0000 -#define AUDREC_CMD_STEREO_MODE_STEREO 0x0001 - -typedef struct { - unsigned short cmd_id; - unsigned short ptr_to_extpkt_buffer_msw; - unsigned short ptr_to_extpkt_buffer_lsw; - unsigned short buf_len; - unsigned short samp_rate_index; - unsigned short stereo_mode; - unsigned short rec_quality; -} __attribute__((packed)) audrec_cmd_arec0param_cfg; - -/* - * Command to configure the recording parameters for RecType1(SBC) encoder - */ - -#define AUDREC_CMD_AREC1PARAM_CFG 0x0002 -#define AUDREC_CMD_AREC1PARAM_CFG_LEN \ - sizeof(audrec_cmd_arec1param_cfg) - -#define AUDREC_CMD_PARAM_BUF_BLOCKS_4 0x0000 -#define AUDREC_CMD_PARAM_BUF_BLOCKS_8 0x0001 -#define AUDREC_CMD_PARAM_BUF_BLOCKS_12 0x0002 -#define AUDREC_CMD_PARAM_BUF_BLOCKS_16 0x0003 - -#define AUDREC_CMD_PARAM_BUF_SUB_BANDS_8 0x0010 -#define AUDREC_CMD_PARAM_BUF_MODE_MONO 0x0000 -#define AUDREC_CMD_PARAM_BUF_MODE_DUAL 0x0040 -#define AUDREC_CMD_PARAM_BUF_MODE_STEREO 0x0050 -#define AUDREC_CMD_PARAM_BUF_MODE_JSTEREO 0x0060 -#define AUDREC_CMD_PARAM_BUF_LOUDNESS 0x0000 -#define AUDREC_CMD_PARAM_BUF_SNR 0x0100 -#define AUDREC_CMD_PARAM_BUF_BASIC_VER 0x0000 - -typedef struct { - unsigned short cmd_id; - unsigned short ptr_to_extpkt_buffer_msw; - unsigned short ptr_to_extpkt_buffer_lsw; - unsigned short buf_len; - unsigned short param_buf; - unsigned short bit_rate_0; - unsigned short bit_rate_1; -} __attribute__((packed)) audrec_cmd_arec1param_cfg; - -/* - * Command to enable encoder for the recording - */ - -#define AUDREC_CMD_ENC_CFG 0x0003 -#define AUDREC_CMD_ENC_CFG_LEN \ - sizeof(struct audrec_cmd_enc_cfg) - - -#define AUDREC_CMD_ENC_ENA 0x8000 -#define AUDREC_CMD_ENC_DIS 0x0000 - -#define AUDREC_CMD_ENC_TYPE_MASK 0x001F - -struct audrec_cmd_enc_cfg { - unsigned short cmd_id; - unsigned short audrec_enc_type; - unsigned short audrec_obj_idx; -} __attribute__((packed)); - -/* - * Command to set external memory config for the selected encoder - */ - -#define AUDREC_CMD_ARECMEM_CFG 0x0004 -#define AUDREC_CMD_ARECMEM_CFG_LEN \ - sizeof(struct audrec_cmd_arecmem_cfg) - - -struct audrec_cmd_arecmem_cfg { - unsigned short cmd_id; - unsigned short audrec_obj_idx; - unsigned short audrec_up_pkt_intm_cnt; - unsigned short audrec_extpkt_buffer_msw; - unsigned short audrec_extpkt_buffer_lsw; - unsigned short audrec_extpkt_buffer_num; -} __attribute__((packed)); - -/* - * Command to configure the recording parameters for selected encoder - */ - -#define AUDREC_CMD_ARECPARAM_CFG 0x0005 -#define AUDREC_CMD_ARECPARAM_COMMON_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_common_cfg) - - -struct audrec_cmd_arecparam_common_cfg { - unsigned short cmd_id; - unsigned short audrec_obj_idx; -} __attribute__((packed)); - -#define AUDREC_CMD_ARECPARAM_WAV_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_wav_cfg) - - -struct audrec_cmd_arecparam_wav_cfg { - struct audrec_cmd_arecparam_common_cfg common; - unsigned short samp_rate_idx; - unsigned short stereo_mode; -} __attribute__((packed)); - -#define AUDREC_CMD_ARECPARAM_AAC_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_aac_cfg) - - -struct audrec_cmd_arecparam_aac_cfg { - struct audrec_cmd_arecparam_common_cfg common; - unsigned short samp_rate_idx; - unsigned short stereo_mode; - unsigned short rec_quality; -} __attribute__((packed)); - -#define AUDREC_CMD_ARECPARAM_SBC_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_sbc_cfg) - - -struct audrec_cmd_arecparam_sbc_cfg { - struct audrec_cmd_arecparam_common_cfg common; - unsigned short param_buf; - unsigned short bit_rate_0; - unsigned short bit_rate_1; -} __attribute__((packed)); - -#define AUDREC_CMD_ARECPARAM_AMRNB_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_amrnb_cfg) - - -struct audrec_cmd_arecparam_amrnb_cfg { - struct audrec_cmd_arecparam_common_cfg common; - unsigned short samp_rate_idx; - unsigned short voicememoencweight1; - unsigned short voicememoencweight2; - unsigned short voicememoencweight3; - unsigned short voicememoencweight4; - unsigned short update_mode; - unsigned short dtx_mode; - unsigned short test_mode; - unsigned short used_mode; -} __attribute__((packed)); - -#define AUDREC_CMD_ARECPARAM_EVRC_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_evrc_cfg) - - -struct audrec_cmd_arecparam_evrc_cfg { - struct audrec_cmd_arecparam_common_cfg common; - unsigned short samp_rate_idx; - unsigned short voicememoencweight1; - unsigned short voicememoencweight2; - unsigned short voicememoencweight3; - unsigned short voicememoencweight4; - unsigned short update_mode; - unsigned short enc_min_rate; - unsigned short enc_max_rate; - unsigned short rate_modulation_cmd; -} __attribute__((packed)); - -#define AUDREC_CMD_ARECPARAM_QCELP_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_qcelp_cfg) - - -struct audrec_cmd_arecparam_qcelp_cfg { - struct audrec_cmd_arecparam_common_cfg common; - unsigned short samp_rate_idx; - unsigned short voicememoencweight1; - unsigned short voicememoencweight2; - unsigned short voicememoencweight3; - unsigned short voicememoencweight4; - unsigned short update_mode; - unsigned short enc_min_rate; - unsigned short enc_max_rate; - unsigned short rate_modulation_cmd; - unsigned short reduced_rate_level; -} __attribute__((packed)); - -#define AUDREC_CMD_ARECPARAM_FGVNB_CFG_LEN \ - sizeof(struct audrec_cmd_arecparam_fgvnb_cfg) - - -struct audrec_cmd_arecparam_fgvnb_cfg { - struct audrec_cmd_arecparam_common_cfg common; - unsigned short samp_rate_idx; - unsigned short voicememoencweight1; - unsigned short voicememoencweight2; - unsigned short voicememoencweight3; - unsigned short voicememoencweight4; - unsigned short update_mode; - unsigned short fgv_min_rate; - unsigned short fgv_max_rate; - unsigned short reduced_rate_level; -} __attribute__((packed)); - -/* - * Command to configure Tunnel(RT) or Non-Tunnel(FTRT) mode - */ - -#define AUDREC_CMD_ROUTING_MODE 0x0006 -#define AUDREC_CMD_ROUTING_MODE_LEN \ - sizeof(struct audpreproc_audrec_cmd_routing_mode) - -#define AUDIO_ROUTING_MODE_FTRT 0x0001 -#define AUDIO_ROUTING_MODE_RT 0x0002 - -struct audrec_cmd_routing_mode { - unsigned short cmd_id; - unsigned short routing_mode; -} __packed; - -/* - * Command to configure pcm input memory - */ - -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC 0x0007 -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_LEN \ - sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc) - -struct audrec_cmd_pcm_cfg_arm_to_enc { - unsigned short cmd_id; - unsigned short config_update_flag; - unsigned short enable_flag; - unsigned short sampling_freq; - unsigned short channels; - unsigned short frequency_of_intimation; - unsigned short max_number_of_buffers; -} __packed; - -#define AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE -1 -#define AUDREC_PCM_CONFIG_UPDATE_FLAG_DISABLE 0 - -#define AUDREC_ENABLE_FLAG_VALUE -1 -#define AUDREC_DISABLE_FLAG_VALUE 0 - -/* - * Command to intimate available pcm buffer - */ - -#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC 0x0008 -#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC_LEN \ - sizeof(struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc) - -struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc { - unsigned short cmd_id; - unsigned short num_buffers; - unsigned short buffer_write_cnt_msw; - unsigned short buffer_write_cnt_lsw; - unsigned short buf_address_length[8];/*this array holds address - and length details of - two buffers*/ -} __packed; - -/* - * Command to flush - */ - -#define AUDREC_CMD_FLUSH 0x009 -#define AUDREC_CMD_FLUSH_LEN \ - sizeof(struct audrec_cmd_flush) - -struct audrec_cmd_flush { - unsigned short cmd_id; -} __packed; - -/* - * Commands on audRecUpBitStreamQueue - */ - -/* - * Command to indicate the current packet read count - */ - -#define AUDREC_CMD_PACKET_EXT_PTR 0x0000 -#define AUDREC_CMD_PACKET_EXT_PTR_LEN \ - sizeof(audrec_cmd_packet_ext_ptr) - -#define AUDREC_CMD_TYPE_0 0x0000 -#define AUDREC_CMD_TYPE_1 0x0001 - -typedef struct { - unsigned short cmd_id; - unsigned short type; /* audrec_obj_idx */ - unsigned short curr_rec_count_msw; - unsigned short curr_rec_count_lsw; -} __attribute__((packed)) audrec_cmd_packet_ext_ptr; - -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audrecmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audrecmsg.h deleted file mode 100644 index 22bdaa23ad39fd8585858e54952e94616ce0282b..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audrecmsg.h +++ /dev/null @@ -1,223 +0,0 @@ -#ifndef QDSP5AUDRECMSGI_H -#define QDSP5AUDRECMSGI_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - * - * A U D I O R E C O R D M E S S A G E S - * - * GENERAL DESCRIPTION - * This file contains defintions of format blocks of messages - * that are sent by AUDREC Task - * - * REFERENCES - * None - * - * EXTERNALIZED FUNCTIONS - * None - * - * Copyright (c) 1992-2009, 2011 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - *====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ - -/*=========================================================================== - - EDIT HISTORY FOR FILE - -This section contains comments describing changes made to this file. -Notice that changes are listed in reverse chronological order. - - $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audrecmsg.h#3 $ - -============================================================================*/ - -/* - * AUDRECTASK MESSAGES - * AUDRECTASK uses audRecUpRlist to communicate with ARM - * Location : MEMC - * Buffer size : 4 - * No of buffers in a queue : 2 - */ - -/* - * Message to notify that config command is done - */ - -#define AUDREC_MSG_CMD_CFG_DONE_MSG 0x0002 -#define AUDREC_MSG_CMD_CFG_DONE_MSG_LEN \ - sizeof(struct audrec_msg_cmd_cfg_done_msg) - - -#define AUDREC_MSG_CFG_DONE_TYPE_0_ENA 0x4000 -#define AUDREC_MSG_CFG_DONE_TYPE_0_DIS 0x0000 - -#define AUDREC_MSG_CFG_DONE_TYPE_0_NO_UPDATE 0x0000 -#define AUDREC_MSG_CFG_DONE_TYPE_0_UPDATE 0x8000 - -#define AUDREC_MSG_CFG_DONE_TYPE_1_ENA 0x4000 -#define AUDREC_MSG_CFG_DONE_TYPE_1_DIS 0x0000 - -#define AUDREC_MSG_CFG_DONE_TYPE_1_NO_UPDATE 0x0000 -#define AUDREC_MSG_CFG_DONE_TYPE_1_UPDATE 0x8000 - -#define AUDREC_MSG_CFG_DONE_ENC_ENA 0x8000 -#define AUDREC_MSG_CFG_DONE_ENC_DIS 0x0000 - -struct audrec_msg_cmd_cfg_done_msg { - unsigned short audrec_enc_type; - unsigned short audrec_obj_idx; -} __attribute__((packed)); - -/* - * Message to notify arec0/1 or concurrent encoder cfg done - * and recording params recieved by task - */ - -#define AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG 0x0003 -#define AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG_LEN \ - sizeof(struct audrec_msg_cmd_arec_param_cfg_done_msg) - - -#define AUDREC_MSG_AREC_PARAM_TYPE_0 0x0000 -#define AUDREC_MSG_AREC_PARAM_TYPE_1 0x0001 - -struct audrec_msg_cmd_arec_param_cfg_done_msg { - unsigned short audrec_obj_idx; -} __attribute__((packed)); - -/* - * Message to notify no more buffers are available in ext mem to DME - * Or no concurrent encoder supported - */ -/* for 7x27 */ -#define AUDREC_MSG_FATAL_ERR_MSG 0x0004 -#define AUDREC_MSG_FATAL_ERR_MSG_LEN \ - sizeof(struct audrec_msg_fatal_err_msg) - - -#define AUDREC_MSG_FATAL_ERR_TYPE_0 0x0000 -#define AUDREC_MSG_FATAL_ERR_TYPE_1 0x0001 - -struct audrec_msg_fatal_err_msg { - unsigned short audrec_obj_idx; - unsigned short audrec_err_id; -} __attribute__((packed)); - -/* for 7x27A */ -#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG 0x0004 -#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG_LEN \ - sizeof(struct audrec_msg_no_ext_pkt_avail_msg) - -#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_TYPE_0 0x0000 -#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_TYPE_1 0x0001 - -struct audrec_msg_no_ext_pkt_avail_msg { - unsigned short audrec_obj_idx; - unsigned short audrec_err_id; -} __packed; - -/* - * Message to notify DME deliverd the encoded pkt to ext pkt buffer - */ - -#define AUDREC_MSG_PACKET_READY_MSG 0x0005 -#define AUDREC_MSG_PACKET_READY_MSG_LEN \ - sizeof(struct audrec_msg_packet_ready_msg) - - -#define AUDREC_MSG_PACKET_READY_TYPE_0 0x0000 -#define AUDREC_MSG_PACKET_READY_TYPE_1 0x0001 - -struct audrec_msg_packet_ready_msg { - unsigned short audrec_obj_idx; - unsigned short pkt_counter_msw; - unsigned short pkt_counter_lsw; - unsigned short pkt_read_cnt_msw; - unsigned short pkt_read_cnt_lsw; -} __attribute__((packed)); - -/* - * Message to notify external memory cfg done and recieved by task - */ - -#define AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG 0x0006 -#define AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG_LEN \ - sizeof(struct audrec_msg_cmd_arec_mem_cfg_done_msg) - - -struct audrec_msg_cmd_arec_mem_cfg_done_msg { - unsigned short audrec_obj_idx; -} __attribute__((packed)); - -/* - * Message to indicate Routing mode - * configuration success or failure - */ - -#define AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG 0x0007 -#define AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG_LEN \ - sizeof(struct audrec_msg_cmd_routing_mode_done_msg) - -struct audrec_msg_cmd_routing_mode_done_msg { - unsigned short configuration; -} __packed; - -/* - * Message to indicate pcm buffer configured - */ - -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG 0x0008 -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG_LEN \ - sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc_msg) - -struct audrec_cmd_pcm_cfg_arm_to_enc_msg { - unsigned short configuration; -} __packed; - -/* - * Message to indicate encoded packet is delivered to external buffer in FTRT - */ - -#define AUDREC_UP_NT_PACKET_READY_MSG 0x0009 -#define AUDREC_UP_NT_PACKET_READY_MSG_LEN \ - sizeof(struct audrec_up_nt_packet_ready_msg) - -struct audrec_up_nt_packet_ready_msg { - unsigned short audrec_packetwrite_cnt_lsw; - unsigned short audrec_packetwrite_cnt_msw; - unsigned short audrec_upprev_readcount_lsw; - unsigned short audrec_upprev_readcount_msw; -} __packed; - -/* - * Message to indicate pcm buffer is consumed - */ - -#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG 0x000A -#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG_LEN \ - sizeof(struct audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg) - -struct audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg { - unsigned short buffer_readcnt_msw; - unsigned short buffer_readcnt_lsw; - unsigned short number_of_buffers; - unsigned short buffer_address_length[]; -} __packed; - -/* - * Message to indicate flush acknowledgement - */ - -#define AUDREC_CMD_FLUSH_DONE_MSG 0x000B - -#define ADSP_MESSAGE_ID 0xFFFF - -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/adie_marimba.h b/arch/arm/mach-msm/include/mach/qdsp5v2/adie_marimba.h deleted file mode 100644 index 1851322881eba0f177ad0eb2741c4943fe1919d3..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/adie_marimba.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (c) 2009-2010, 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 __MACH_QDSP5_V2_ADIE_MARIMBA_H -#define __MACH_QDSP5_V2_ADIE_MARIMBA_H - -#include - -/* Value Represents a entry */ -#define ADIE_CODEC_ACTION_ENTRY 0x1 -/* Value representing a delay wait */ -#define ADIE_CODEC_ACTION_DELAY_WAIT 0x2 -/* Value representing a stage reached */ -#define ADIE_CODEC_ACTION_STAGE_REACHED 0x3 - -/* This value is the state after the client sets the path */ -#define ADIE_CODEC_PATH_OFF 0x0050 - -/* State to which client asks the drv to proceed to where it can - * set up the clocks and 0-fill PCM buffers - */ -#define ADIE_CODEC_DIGITAL_READY 0x0100 - -/* State to which client asks the drv to proceed to where it can - * start sending data after internal steady state delay - */ -#define ADIE_CODEC_DIGITAL_ANALOG_READY 0x1000 - - -/* Client Asks adie to switch off the Analog portion of the - * the internal codec. After the use of this path - */ -#define ADIE_CODEC_ANALOG_OFF 0x0750 - - -/* Client Asks adie to switch off the digital portion of the - * the internal codec. After switching off the analog portion. - * - * 0-fill PCM may or maynot be sent at this point - * - */ -#define ADIE_CODEC_DIGITAL_OFF 0x0600 - -/* State to which client asks the drv to write the default values - * to the registers */ -#define ADIE_CODEC_FLASH_IMAGE 0x0001 - -/* Path type */ -#define ADIE_CODEC_RX 0 -#define ADIE_CODEC_TX 1 -#define ADIE_CODEC_LB 3 -#define ADIE_CODEC_MAX 4 - -#define ADIE_CODEC_PACK_ENTRY(reg, mask, val) ((val)|(mask << 8)|(reg << 16)) - -#define ADIE_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \ - do { \ - ((reg) = ((packed >> 16) & (0xff))); \ - ((mask) = ((packed >> 8) & (0xff))); \ - ((val) = ((packed) & (0xff))); \ - } while (0); - -struct adie_codec_action_unit { - u32 type; - u32 action; -}; - -struct adie_codec_hwsetting_entry{ - struct adie_codec_action_unit *actions; - u32 action_sz; - u32 freq_plan; - u32 osr; - /* u32 VolMask; - * u32 SidetoneMask; - */ -}; - -struct adie_codec_dev_profile { - u32 path_type; /* RX or TX */ - u32 setting_sz; - struct adie_codec_hwsetting_entry *settings; -}; - -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/afe.h b/arch/arm/mach-msm/include/mach/qdsp5v2/afe.h deleted file mode 100644 index e4e29335f3da71e2abffdad9c1e6939d9fa58365..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/afe.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2009-2011, 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 _MACH_QDSP5_V2_AFE_H -#define _MACH_QDSP5_V2_AFE_H - -#include -#include - -#define AFE_HW_PATH_CODEC_RX 1 -#define AFE_HW_PATH_CODEC_TX 2 -#define AFE_HW_PATH_AUXPCM_RX 3 -#define AFE_HW_PATH_AUXPCM_TX 4 -#define AFE_HW_PATH_MI2S_RX 5 -#define AFE_HW_PATH_MI2S_TX 6 - -#define AFE_VOLUME_UNITY 0x4000 /* Based on Q14 */ - -struct msm_afe_config { - u16 sample_rate; - u16 channel_mode; - u16 volume; - /* To be expaned for AUX CODEC */ -}; - -int afe_enable(u8 path_id, struct msm_afe_config *config); - -int afe_disable(u8 path_id); - -int afe_config_aux_codec(int pcm_ctl_value, int aux_codec_intf_value, - int data_format_pad); -int afe_config_fm_codec(int fm_enable, uint16_t source); - -int afe_config_fm_volume(uint16_t volume); -int afe_config_fm_calibration_gain(uint16_t device_id, - uint16_t calibration_gain); -void afe_loopback(int enable); -void afe_ext_loopback(int enable, int rx_copp_id, int tx_copp_id); - -void afe_device_volume_ctrl(u16 device_id, u16 device_volume); - -int afe_config_rmc_block(struct acdb_rmc_block *acdb_rmc); -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdbi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdbi.h deleted file mode 100644 index f05ebaa112921e7acca8246010ac14796c49ac8e..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdbi.h +++ /dev/null @@ -1,303 +0,0 @@ -/* Copyright (c) 2009-2011, 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 _MACH_QDSP5_V2_AUDIO_ACDBI_H -#define _MACH_QDSP5_V2_AUDIO_ACDBI_H - -#define DBOR_SIGNATURE 0x524F4244 - -#ifdef CONFIG_DEBUG_FS -void acdb_rtc_set_err(u32 ErrCode); -#endif - - -struct header { - u32 dbor_signature; - u32 abid; - u32 iid; - u32 data_len; -}; - -enum { - ACDB_AGC_BLOCK = 197, - ACDB_IIR_BLOCK = 245, - ACDB_MBADRC_BLOCK = 343 -}; - -/* Structure to query for acdb parameter */ -struct acdb_get_block { - u32 acdb_id; - u32 sample_rate_id; /* Actual sample rate value */ - u32 interface_id; /* Interface id's */ - u32 algorithm_block_id; /* Algorithm block id */ - u32 total_bytes; /* Length in bytes used by buffer for - configuration */ - u32 *buf_ptr; /* Address for storing configuration - data */ -}; - -struct acdb_agc_block { - u16 enable_status; - u16 comp_rlink_static_gain; - u16 comp_rlink_aig_flag; - u16 exp_rlink_threshold; - u16 exp_rlink_slope; - u16 comp_rlink_threshold; - u16 comp_rlink_slope; - u16 comp_rlink_aig_attack_k; - u16 comp_rlink_aig_leak_down; - u16 comp_rlink_aig_leak_up; - u16 comp_rlink_aig_max; - u16 comp_rlink_aig_min; - u16 comp_rlink_aig_release_k; - u16 comp_rlink_aig_sm_leak_rate_fast; - u16 comp_rlink_aig_sm_leak_rate_slow; - u16 comp_rlink_attack_k_msw; - u16 comp_rlink_attack_k_lsw; - u16 comp_rlink_delay; - u16 comp_rlink_release_k_msw; - u16 comp_rlink_release_k_lsw; - u16 comp_rlink_rms_trav; -}; - - -struct iir_coeff_type { - u16 b0_lo; - u16 b0_hi; - u16 b1_lo; - u16 b1_hi; - u16 b2_lo; - u16 b2_hi; -}; - -struct iir_coeff_stage_a { - u16 a1_lo; - u16 a1_hi; - u16 a2_lo; - u16 a2_hi; -}; - -struct acdb_iir_block { - u16 enable_flag; - u16 stage_count; - struct iir_coeff_type stages[4]; - struct iir_coeff_stage_a stages_a[4]; - u16 shift_factor[4]; - u16 pan[4]; -}; - - - -struct mbadrc_band_config_type { - u16 mbadrc_sub_band_enable; - u16 mbadrc_sub_mute; - u16 mbadrc_comp_rms_tav; - u16 mbadrc_comp_threshold; - u16 mbadrc_comp_slop; - u16 mbadrc_comp_attack_msw; - u16 mbadrc_comp_attack_lsw; - u16 mbadrc_comp_release_msw; - u16 mbadrc_comp_release_lsw; - u16 mbadrc_make_up_gain; -}; - -struct mbadrc_parameter { - u16 mbadrc_enable; - u16 mbadrc_num_bands; - u16 mbadrc_down_sample_level; - u16 mbadrc_delay; -}; - -struct acdb_mbadrc_block { - u16 ext_buf[196]; - struct mbadrc_band_config_type band_config[5]; - struct mbadrc_parameter parameters; -}; - -struct acdb_calib_gain_rx { - u16 audppcalgain; - u16 reserved; -}; - -struct acdb_calib_gain_tx { - u16 audprecalgain; - u16 reserved; -}; - -struct acdb_pbe_block { - s16 realbassmix; - s16 basscolorcontrol; - u16 mainchaindelay; - u16 xoverfltorder; - u16 bandpassfltorder; - s16 adrcdelay; - u16 downsamplelevel; - u16 comprmstav; - s16 expthreshold; - u16 expslope; - u16 compthreshold; - u16 compslope; - u16 cpmpattack_lsw; - u16 compattack_msw; - u16 comprelease_lsw; - u16 comprelease_msw; - u16 compmakeupgain; - s16 baselimthreshold; - s16 highlimthreshold; - s16 basslimmakeupgain; - s16 highlimmakeupgain; - s16 limbassgrc; - s16 limhighgrc; - s16 limdelay; - u16 filter_coeffs[90]; -}; - -struct acdb_rmc_block { - s16 rmc_enable; - u16 rmc_ipw_length_ms; - u16 rmc_detect_start_threshdb; - u16 rmc_peak_length_ms; - s16 rmc_init_pulse_threshdb; - u16 rmc_init_pulse_length_ms; - u16 rmc_total_int_length_ms; - u16 rmc_rampupdn_length_ms; - u16 rmc_delay_length_ms; - u16 reserved00; - u16 reserved01; - s16 reserved02; - s16 reserved03; - s16 reserved04; -}; - -struct acdb_fluence_block { - u16 csmode; - u16 cs_tuningMode; - u16 cs_echo_path_delay_by_80; - u16 cs_echo_path_delay; - u16 af1_twoalpha; - u16 af1_erl; - u16 af1_taps; - u16 af1_preset_coefs; - u16 af1_offset; - u16 af2_twoalpha; - u16 af2_erl; - u16 af2_taps; - u16 af2_preset_coefs; - u16 af2_offset; - u16 pcd_twoalpha; - u16 pcd_offset; - u16 cspcd_threshold; - u16 wgthreshold; - u16 mpthreshold; - u16 sf_init_table_0[8]; - u16 sf_init_table_1[8]; - u16 sf_taps; - u16 sf_twoalpha; - u16 dnns_echoalpharev; - u16 dnns_echoycomp; - u16 dnns_wbthreshold; - u16 dnns_echogammahi; - u16 dnns_echogammalo; - u16 dnns_noisegammas; - u16 dnns_noisegamman; - u16 dnns_noisegainmins; - u16 dnns_noisegainminn; - u16 dnns_noisebiascomp; - u16 dnns_acthreshold; - u16 wb_echo_ratio_2mic; - u16 wb_gamma_e; - u16 wb_gamma_nn; - u16 wb_gamma_sn; - u16 vcodec_delay0; - u16 vcodec_delay1; - u16 vcodec_len0; - u16 vcodec_len1; - u16 vcodec_thr0; - u16 vcodec_thr1; - u16 fixcalfactorleft; - u16 fixcalfactorright; - u16 csoutputgain; - u16 enh_meu_1; - u16 enh_meu_2; - u16 fixed_over_est; - u16 rx_nlpp_limit; - u16 rx_nlpp_gain; - u16 wnd_threshold; - u16 wnd_ns_hover; - u16 wnd_pwr_smalpha; - u16 wnd_det_esmalpha; - u16 wnd_ns_egoffset; - u16 wnd_sm_ratio; - u16 wnd_det_coefs[5]; - u16 wnd_th1; - u16 wnd_th2; - u16 wnd_fq; - u16 wnd_dfc; - u16 wnd_sm_alphainc; - u16 wnd_sm_alphsdec; - u16 lvnv_spdet_far; - u16 lvnv_spdet_mic; - u16 lvnv_spdet_xclip; - u16 dnns_nl_atten; - u16 dnns_cni_level; - u16 dnns_echogammaalpha; - u16 dnns_echogammarescue; - u16 dnns_echogammadt; - u16 mf_noisegammafac; - u16 e_noisegammafac; - u16 dnns_noisegammainit; - u16 sm_noisegammas; - u16 wnd_noisegamman; - u16 af_taps_bg_spkr; - u16 af_erl_bg_spkr; - u16 minimum_erl_bg; - u16 erl_step_bg; - u16 upprisecalpha; - u16 upprisecthresh; - u16 uppriwindbias; - u16 e_pcd_threshold; - u16 nv_maxvadcount; - u16 crystalspeechreserved[38]; - u16 cs_speaker[7]; - u16 ns_fac; - u16 ns_blocksize; - u16 is_bias; - u16 is_bias_inp; - u16 sc_initb; - u16 ac_resetb; - u16 sc_avar; - u16 is_hover[5]; - u16 is_cf_level; - u16 is_cf_ina; - u16 is_cf_inb; - u16 is_cf_a; - u16 is_cf_b; - u16 sc_th; - u16 sc_pscale; - u16 sc_nc; - u16 sc_hover; - u16 sc_alphas; - u16 sc_cfac; - u16 sc_sdmax; - u16 sc_sdmin; - u16 sc_initl; - u16 sc_maxval; - u16 sc_spmin; - u16 is_ec_th; - u16 is_fx_dl; - u16 coeffs_iva_filt_0[32]; - u16 coeffs_iva_filt_1[32]; -}; - -s32 acdb_get_calibration_data(struct acdb_get_block *get_block); -void fluence_feature_update(int enable, int stream_id); -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_def.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_def.h deleted file mode 100644 index 35a4d5c2f794761d3fcac17d4205cf2861e38d5e..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_def.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2009,2011, 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 _MACH_QDSP5_V2_AUDIO_DEF_H -#define _MACH_QDSP5_V2_AUDIO_DEF_H - -/* Define sound device capability */ -#define SNDDEV_CAP_RX 0x1 /* RX direction */ -#define SNDDEV_CAP_TX 0x2 /* TX direction */ -#define SNDDEV_CAP_VOICE 0x4 /* Support voice call */ -#define SNDDEV_CAP_PLAYBACK 0x8 /* Support playback */ -#define SNDDEV_CAP_FM 0x10 /* Support FM radio */ -#define SNDDEV_CAP_TTY 0x20 /* Support TTY */ -#define SNDDEV_CAP_ANC 0x40 /* Support ANC */ -#define SNDDEV_CAP_LB 0x80 /* Loopback */ -#define VOC_NB_INDEX 0 -#define VOC_WB_INDEX 1 -#define VOC_RX_VOL_ARRAY_NUM 2 - -/* Device volume types . In Current deisgn only one of these are supported. */ -#define SNDDEV_DEV_VOL_DIGITAL 0x1 /* Codec Digital volume control */ -#define SNDDEV_DEV_VOL_ANALOG 0x2 /* Codec Analog volume control */ - -#define SIDE_TONE_MASK 0x01 - -#endif /* _MACH_QDSP5_V2_AUDIO_DEF_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_dev_ctl.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_dev_ctl.h deleted file mode 100644 index 976d9ae2bc205d3ab5204221257dddda0e372e46..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_dev_ctl.h +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright (c) 2009-2011, 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 __MACH_QDSP5_V2_SNDDEV_H -#define __MACH_QDSP5_V2_SNDDEV_H -#include - -#define AUDIO_DEV_CTL_MAX_DEV 64 -#define DIR_TX 2 -#define DIR_RX 1 - -#define DEVICE_IGNORE 0xff -#define SESSION_IGNORE 0x00000000 - -#define VOICE_STATE_INVALID 0x0 -#define VOICE_STATE_INCALL 0x1 -#define VOICE_STATE_OFFCALL 0x2 -#define MAX_COPP_NODE_SUPPORTED 6 -#define MAX_AUDREC_SESSIONS 3 - -#define REAL_STEREO_CHANNEL_MODE 9 - -struct msm_snddev_info { - const char *name; - u32 capability; - u32 copp_id; - u32 acdb_id; - u32 dev_volume; - struct msm_snddev_ops { - int (*open)(struct msm_snddev_info *); - int (*close)(struct msm_snddev_info *); - int (*set_freq)(struct msm_snddev_info *, u32); - int (*enable_sidetone)(struct msm_snddev_info *, u32); - int (*set_device_volume)(struct msm_snddev_info *, u32); - } dev_ops; - u8 opened; - void *private_data; - bool state; - u32 sample_rate; - u32 set_sample_rate; - u32 sessions; - int usage_count; - s32 max_voc_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* [0] is for NB,[1] for WB */ - s32 min_voc_rx_vol[VOC_RX_VOL_ARRAY_NUM]; -}; - -struct msm_volume { - int volume; /* Volume parameter, in % Scale */ - int pan; -}; - -extern struct msm_volume msm_vol_ctl; - -int msm_get_dual_mic_config(int enc_session_id); -int msm_set_dual_mic_config(int enc_session_id, int config); -int msm_reset_all_device(void); -void msm_snddev_register(struct msm_snddev_info *); -void msm_snddev_unregister(struct msm_snddev_info *); -int msm_snddev_devcount(void); -int msm_snddev_query(int dev_id); -unsigned short msm_snddev_route_dec(int popp_id); -unsigned short msm_snddev_route_enc(int enc_id); -int msm_snddev_set_dec(int popp_id, int copp_id, int set); -int msm_snddev_set_enc(int popp_id, int copp_id, int set); -int msm_snddev_is_set(int popp_id, int copp_id); -int msm_get_voc_route(u32 *rx_id, u32 *tx_id); -int msm_set_voc_route(struct msm_snddev_info *dev_info, int stream_type, - int dev_id); -int msm_snddev_enable_sidetone(u32 dev_id, u32 enable); - -struct msm_snddev_info *audio_dev_ctrl_find_dev(u32 dev_id); - -void msm_release_voc_thread(void); - -int snddev_voice_set_volume(int vol, int path); - -struct auddev_evt_voc_devinfo { - u32 dev_type; /* Rx or Tx */ - u32 acdb_dev_id; /* acdb id of device */ - u32 dev_sample; /* Sample rate of device */ - s32 max_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* unit is mb (milibel), - [0] is for NB, other for WB */ - s32 min_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* unit is mb */ - u32 dev_id; /* registered device id */ -}; - -struct auddev_evt_audcal_info { - u32 dev_id; - u32 acdb_id; - u32 sample_rate; - u32 dev_type; - u32 sessions; -}; - -struct auddev_evt_devinfo { - u32 dev_id; - u32 acdb_id; - u32 sample_rate; - u32 dev_type; - u32 sessions; -}; - -union msm_vol_mute { - int vol; - bool mute; -}; - -struct auddev_evt_voc_mute_info { - u32 dev_type; - u32 acdb_dev_id; - union msm_vol_mute dev_vm_val; -}; - -struct auddev_evt_freq_info { - u32 dev_type; - u32 acdb_dev_id; - u32 sample_rate; -}; - -union auddev_evt_data { - struct auddev_evt_voc_devinfo voc_devinfo; - struct auddev_evt_voc_mute_info voc_vm_info; - struct auddev_evt_freq_info freq_info; - u32 routing_id; - s32 session_vol; - s32 voice_state; - struct auddev_evt_audcal_info audcal_info; - struct auddev_evt_devinfo devinfo; -}; - -struct message_header { - uint32_t id; - uint32_t data_len; -}; - -#define AUDDEV_EVT_DEV_CHG_VOICE 0x01 /* device change event */ -#define AUDDEV_EVT_DEV_RDY 0x02 /* device ready event */ -#define AUDDEV_EVT_DEV_RLS 0x04 /* device released event */ -#define AUDDEV_EVT_REL_PENDING 0x08 /* device release pending */ -#define AUDDEV_EVT_DEVICE_VOL_MUTE_CHG 0x10 /* device volume changed */ -#define AUDDEV_EVT_START_VOICE 0x20 /* voice call start */ -#define AUDDEV_EVT_END_VOICE 0x40 /* voice call end */ -#define AUDDEV_EVT_STREAM_VOL_CHG 0x80 /* device volume changed */ -#define AUDDEV_EVT_FREQ_CHG 0x100 /* Change in freq */ -#define AUDDEV_EVT_VOICE_STATE_CHG 0x200 /* Change in voice state */ -#define AUDDEV_EVT_DEVICE_INFO 0x400 /* routed device information - event */ - -#define AUDDEV_CLNT_VOC 0x1 /* Vocoder clients */ -#define AUDDEV_CLNT_DEC 0x2 /* Decoder clients */ -#define AUDDEV_CLNT_ENC 0x3 /* Encoder clients */ -#define AUDDEV_CLNT_AUDIOCAL 0x4 /* AudioCalibration client */ - -#define AUDIO_DEV_CTL_MAX_LISTNER 20 /* Max Listeners Supported */ - -struct msm_snd_evt_listner { - uint32_t evt_id; - uint32_t clnt_type; - uint32_t clnt_id; - void *private_data; - void (*auddev_evt_listener)(u32 evt_id, - union auddev_evt_data *evt_payload, - void *private_data); - struct msm_snd_evt_listner *cb_next; - struct msm_snd_evt_listner *cb_prev; -}; - -struct event_listner { - struct msm_snd_evt_listner *cb; - u32 num_listner; - int state; /* Call state */ /* TODO remove this if not req*/ -}; - -extern struct event_listner event; -int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id, - void (*listner)(u32 evt_id, - union auddev_evt_data *evt_payload, - void *private_data), - void *private_data); -int auddev_unregister_evt_listner(u32 clnt_type, u32 clnt_id); -void mixer_post_event(u32 evt_id, u32 dev_id); -void broadcast_event(u32 evt_id, u32 dev_id, u32 session_id); -int msm_snddev_request_freq(int *freq, u32 session_id, - u32 capability, u32 clnt_type); -int msm_snddev_withdraw_freq(u32 session_id, - u32 capability, u32 clnt_type); -int msm_device_is_voice(int dev_id); -int msm_get_voc_freq(int *tx_freq, int *rx_freq); -int msm_snddev_get_enc_freq(int session_id); -int msm_set_voice_vol(int dir, s32 volume); -int msm_set_voice_mute(int dir, int mute); -int msm_get_voice_state(void); -#ifdef CONFIG_DEBUG_FS -bool is_dev_opened(u32 acdb_id); -#endif - -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audpp.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audpp.h deleted file mode 100644 index 763a6516d9f0a23dc98f93b7c1c91b0e1824cd5f..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/audpp.h +++ /dev/null @@ -1,129 +0,0 @@ -/*arch/arm/mach-msm/qdsp5iv2/audpp.h - * - * Copyright (C) 2008 Google, Inc. - * Copyright (c) 2008-2011, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _MACH_QDSP5_V2_AUDPP_H -#define _MACH_QDSP5_V2_AUDPP_H - -#include - -typedef void (*audpp_event_func)(void *private, unsigned id, uint16_t *msg); - -/* worst case delay of 1sec for response */ -#define MSM_AUD_DECODER_WAIT_MS 1000 -#define MSM_AUD_MODE_TUNNEL 0x00000100 -#define MSM_AUD_MODE_NONTUNNEL 0x00000200 -#define MSM_AUD_MODE_LP 0x00000400 -#define MSM_AUD_DECODER_MASK 0x0000FFFF -#define MSM_AUD_OP_MASK 0xFFFF0000 - -/* read call timeout for error cases */ -#define MSM_AUD_BUFFER_UPDATE_WAIT_MS 2000 - -/* stream info error message mask */ -#define AUDPLAY_STREAM_INFO_MSG_MASK 0xFFFF0000 -#define AUDPLAY_ERROR_THRESHOLD_ENABLE 0xFFFFFFFF - -#define NON_TUNNEL_MODE_PLAYBACK 1 -#define TUNNEL_MODE_PLAYBACK 0 - -#define AUDPP_MIXER_ICODEC AUDPP_CMD_CFG_DEV_MIXER_DEV_0 -#define AUDPP_MIXER_1 AUDPP_CMD_CFG_DEV_MIXER_DEV_1 -#define AUDPP_MIXER_2 AUDPP_CMD_CFG_DEV_MIXER_DEV_2 -#define AUDPP_MIXER_3 AUDPP_CMD_CFG_DEV_MIXER_DEV_3 -#define AUDPP_MIXER_HLB AUDPP_CMD_CFG_DEV_MIXER_DEV_4 -#define AUDPP_MIXER_NONHLB (AUDPP_CMD_CFG_DEV_MIXER_DEV_0 | \ - AUDPP_CMD_CFG_DEV_MIXER_DEV_1 | \ - AUDPP_CMD_CFG_DEV_MIXER_DEV_2 | \ - AUDPP_CMD_CFG_DEV_MIXER_DEV_3) -#define AUDPP_MIXER_UPLINK_RX AUDPP_CMD_CFG_DEV_MIXER_DEV_5 -#define AUDPP_MAX_COPP_DEVICES 6 - -enum obj_type { - COPP, - POPP -}; - -enum msm_aud_decoder_state { - MSM_AUD_DECODER_STATE_NONE = 0, - MSM_AUD_DECODER_STATE_FAILURE = 1, - MSM_AUD_DECODER_STATE_SUCCESS = 2, - MSM_AUD_DECODER_STATE_CLOSE = 3, -}; - -int audpp_adec_alloc(unsigned dec_attrb, const char **module_name, - unsigned *queueid); -void audpp_adec_free(int decid); - -struct audpp_event_callback { - audpp_event_func fn; - void *private; -}; - -int audpp_register_event_callback(struct audpp_event_callback *eh); -int audpp_unregister_event_callback(struct audpp_event_callback *eh); -int is_audpp_enable(void); - -int audpp_enable(int id, audpp_event_func func, void *private); -void audpp_disable(int id, void *private); - -int audpp_send_queue1(void *cmd, unsigned len); -int audpp_send_queue2(void *cmd, unsigned len); -int audpp_send_queue3(void *cmd, unsigned len); - -void audpp_route_stream(unsigned short dec_id, unsigned short mixer_mask); - -int audpp_set_volume_and_pan(unsigned id, unsigned volume, int pan, - enum obj_type objtype); -int audpp_pause(unsigned id, int pause); -int audpp_flush(unsigned id); -int audpp_query_avsync(int id); -int audpp_restore_avsync(int id, uint16_t *avsync); - -int audpp_dsp_set_eq(unsigned id, unsigned enable, - struct audpp_cmd_cfg_object_params_eqalizer *eq, - enum obj_type objtype); - -int audpp_dsp_set_spa(unsigned id, - struct audpp_cmd_cfg_object_params_spectram *spa, - enum obj_type objtype); - -int audpp_dsp_set_stf(unsigned id, unsigned enable, - struct audpp_cmd_cfg_object_params_sidechain *stf, - enum obj_type objtype); - -int audpp_dsp_set_vol_pan(unsigned id, - struct audpp_cmd_cfg_object_params_volume *vol_pan, - enum obj_type objtype); - -int audpp_dsp_set_mbadrc(unsigned id, unsigned enable, - struct audpp_cmd_cfg_object_params_mbadrc *mbadrc, - enum obj_type objtype); - -int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable, - struct audpp_cmd_cfg_object_params_qconcert *qconcert_plus, - enum obj_type objtype); - -int audpp_dsp_set_rx_iir(unsigned id, unsigned enable, - struct audpp_cmd_cfg_object_params_pcm *iir, - enum obj_type objtype); - -int audpp_dsp_set_gain_rx(unsigned id, - struct audpp_cmd_cfg_cal_gain *calib_gain_rx, - enum obj_type objtype); -int audpp_dsp_set_pbe(unsigned id, unsigned enable, - struct audpp_cmd_cfg_pbe *pbe_block, - enum obj_type objtype); -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audpreproc.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audpreproc.h deleted file mode 100644 index 16a0a8fb227df8501692bd156fe0fc7bcd519db4..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/audpreproc.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2009-2011, 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 _MACH_QDSP5_V2_AUDPREPROC_H -#define _MACH_QDSP5_V2_AUDPREPROC_H - -#include -#include - -#define MAX_ENC_COUNT 3 - -#define MSM_ADSP_ENC_CODEC_WAV 0 -#define MSM_ADSP_ENC_CODEC_AAC 1 -#define MSM_ADSP_ENC_CODEC_SBC 2 -#define MSM_ADSP_ENC_CODEC_AMRNB 3 -#define MSM_ADSP_ENC_CODEC_EVRC 4 -#define MSM_ADSP_ENC_CODEC_QCELP 5 -#define MSM_ADSP_ENC_CODEC_EXT_WAV (15) - -#define MSM_ADSP_ENC_MODE_TUNNEL 24 -#define MSM_ADSP_ENC_MODE_NON_TUNNEL 25 - -#define AUDPREPROC_CODEC_MASK 0x00FF -#define AUDPREPROC_MODE_MASK 0xFF00 - -#define MSM_AUD_ENC_MODE_TUNNEL 0x00000100 -#define MSM_AUD_ENC_MODE_NONTUNNEL 0x00000200 - -#define SOURCE_PIPE_1 0x0001 -#define SOURCE_PIPE_0 0x0000 - -/* event callback routine prototype*/ -typedef void (*audpreproc_event_func)(void *private, unsigned id, void *msg); - -struct audpreproc_event_callback { - audpreproc_event_func fn; - void *private; -}; - -/*holds audrec information*/ -struct audrec_session_info { - int session_id; - int sampling_freq; -}; - -/* Exported common api's from audpreproc layer */ -int audpreproc_aenc_alloc(unsigned enc_type, const char **module_name, - unsigned *queue_id); -void audpreproc_aenc_free(int enc_id); - -int audpreproc_enable(int enc_id, audpreproc_event_func func, void *private); -void audpreproc_disable(int enc_id, void *private); - -int audpreproc_send_audreccmdqueue(void *cmd, unsigned len); - -int audpreproc_send_preproccmdqueue(void *cmd, unsigned len); - -int audpreproc_dsp_set_agc(struct audpreproc_cmd_cfg_agc_params *agc, - unsigned len); -int audpreproc_dsp_set_agc2(struct audpreproc_cmd_cfg_agc_params_2 *agc2, - unsigned len); -int audpreproc_dsp_set_ns(struct audpreproc_cmd_cfg_ns_params *ns, - unsigned len); -int audpreproc_dsp_set_iir( -struct audpreproc_cmd_cfg_iir_tuning_filter_params *iir, unsigned len); - -int audpreproc_dsp_set_agc(struct audpreproc_cmd_cfg_agc_params *agc, - unsigned int len); - -int audpreproc_dsp_set_iir( -struct audpreproc_cmd_cfg_iir_tuning_filter_params *iir, unsigned int len); - -int audpreproc_update_audrec_info(struct audrec_session_info - *audrec_session_info); -int audpreproc_unregister_event_callback(struct audpreproc_event_callback *ecb); - -int audpreproc_register_event_callback(struct audpreproc_event_callback *ecb); - -int audpreproc_dsp_set_gain_tx( - struct audpreproc_cmd_cfg_cal_gain *calib_gain_tx, unsigned len); - -void get_audrec_session_info(int id, struct audrec_session_info *info); - -int audpreproc_dsp_set_lvnv( - struct audpreproc_cmd_cfg_lvnv_param *preproc_lvnv, unsigned len); -#endif /* _MACH_QDSP5_V2_AUDPREPROC_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaycmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaycmdi.h deleted file mode 100644 index dad7fabbf2cc0567334d1678fc45e7586ef033d1..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaycmdi.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef QDSP5AUDPLAYCMDI_H -#define QDSP5AUDPLAYCMDI_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - Q D S P 5 A U D I O P L A Y T A S K C O M M A N D S - -GENERAL DESCRIPTION - Command Interface for AUDPLAYTASK on QDSP5 - -REFERENCES - None - -EXTERNALIZED FUNCTIONS - - audplay_cmd_dec_data_avail - Send buffer to AUDPLAY task - - -Copyright (c) 1992-2009, The Linux Foundation. All rights reserved. - -This software is licensed under the terms of the GNU General Public -License version 2, as published by the Free Software Foundation, and -may be copied, distributed, and modified under those terms. - -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. - -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ - -#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL 0x0000 -#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_LEN \ - sizeof(struct audplay_cmd_bitstream_data_avail) - -/* Type specification of dec_data_avail message sent to AUDPLAYTASK -*/ -struct audplay_cmd_bitstream_data_avail{ - /*command ID*/ - unsigned int cmd_id; - - /* Decoder ID for which message is being sent */ - unsigned int decoder_id; - - /* Start address of data in ARM global memory */ - unsigned int buf_ptr; - - /* Number of 16-bit words of bit-stream data contiguously - * available at the above-mentioned address - */ - unsigned int buf_size; - - /* Partition number used by audPlayTask to communicate with DSP's RTOS - * kernel - */ - unsigned int partition_number; - -} __attribute__((packed)); - -#define AUDPLAY_CMD_CHANNEL_INFO 0x0001 -#define AUDPLAY_CMD_CHANNEL_INFO_LEN \ - sizeof(struct audplay_cmd_channel_info) - -struct audplay_cmd_channel_select { - unsigned int cmd_id; - unsigned int stream_id; - unsigned int channel_select; -} __attribute__((packed)); - -struct audplay_cmd_threshold_update { - unsigned int cmd_id; - unsigned int threshold_update; - unsigned int threshold_value; -} __attribute__((packed)); - -union audplay_cmd_channel_info { - struct audplay_cmd_channel_select ch_select; - struct audplay_cmd_threshold_update thr_update; -}; - -#define AUDPLAY_CMD_HPCM_BUF_CFG 0x0003 -#define AUDPLAY_CMD_HPCM_BUF_CFG_LEN \ - sizeof(struct audplay_cmd_hpcm_buf_cfg) - -struct audplay_cmd_hpcm_buf_cfg { - unsigned int cmd_id; - unsigned int hostpcm_config; - unsigned int feedback_frequency; - unsigned int byte_swap; - unsigned int max_buffers; - unsigned int partition_number; -} __attribute__((packed)); - -#define AUDPLAY_CMD_BUFFER_REFRESH 0x0004 -#define AUDPLAY_CMD_BUFFER_REFRESH_LEN \ - sizeof(struct audplay_cmd_buffer_update) - -struct audplay_cmd_buffer_refresh { - unsigned int cmd_id; - unsigned int num_buffers; - unsigned int buf_read_count; - unsigned int buf0_address; - unsigned int buf0_length; - unsigned int buf1_address; - unsigned int buf1_length; -} __attribute__((packed)); - -#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2 0x0005 -#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2_LEN \ - sizeof(struct audplay_cmd_bitstream_data_avail_nt2) - -/* Type specification of dec_data_avail message sent to AUDPLAYTASK - * for NT2 */ -struct audplay_cmd_bitstream_data_avail_nt2 { - /*command ID*/ - unsigned int cmd_id; - - /* Decoder ID for which message is being sent */ - unsigned int decoder_id; - - /* Start address of data in ARM global memory */ - unsigned int buf_ptr; - - /* Number of 16-bit words of bit-stream data contiguously - * available at the above-mentioned address - */ - unsigned int buf_size; - - /* Partition number used by audPlayTask to communicate with DSP's RTOS - * kernel - */ - unsigned int partition_number; - - /* bitstream write pointer */ - unsigned int dspBitstreamWritePtr; - -} __attribute__((packed)); - -#define AUDPLAY_CMD_OUTPORT_FLUSH 0x0006 - -struct audplay_cmd_outport_flush { - unsigned int cmd_id; -} __attribute__((packed)); - -#endif /* QDSP5AUDPLAYCMD_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaymsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaymsg.h deleted file mode 100644 index 653f0e715fbd10df68026be7a4e07c7a6ace15f7..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaymsg.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef QDSP5AUDPLAYMSG_H -#define QDSP5AUDPLAYMSG_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - Q D S P 5 A U D I O P L A Y T A S K M S G - -GENERAL DESCRIPTION - Message sent by AUDPLAY task - -REFERENCES - None - - -Copyright (c) 1992-2009, The Linux Foundation. All rights reserved. - -This software is licensed under the terms of the GNU General Public -License version 2, as published by the Free Software Foundation, and -may be copied, distributed, and modified under those terms. - -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. -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ - -#define AUDPLAY_MSG_DEC_NEEDS_DATA 0x0001 -#define AUDPLAY_MSG_DEC_NEEDS_DATA_MSG_LEN \ - sizeof(audplay_msg_dec_needs_data) - -struct audplay_msg_dec_needs_data { - /* reserved*/ - unsigned int dec_id; - - /*The read pointer offset of external memory till which bitstream - has been dmed in*/ - unsigned int adecDataReadPtrOffset; - - /*The buffer size of external memory. */ - unsigned int adecDataBufSize; - - unsigned int bitstream_free_len; - unsigned int bitstream_write_ptr; - unsigned int bitstarem_buf_start; - unsigned int bitstream_buf_len; -} __attribute__((packed)); - -#define AUDPLAY_UP_STREAM_INFO 0x0003 -#define AUDPLAY_UP_STREAM_INFO_LEN \ - sizeof(struct audplay_msg_stream_info) - -struct audplay_msg_stream_info { - unsigned int decoder_id; - unsigned int channel_info; - unsigned int sample_freq; - unsigned int bitstream_info; - unsigned int bit_rate; -} __attribute__((packed)); - -#define AUDPLAY_MSG_BUFFER_UPDATE 0x0004 -#define AUDPLAY_MSG_BUFFER_UPDATE_LEN \ - sizeof(struct audplay_msg_buffer_update) - -struct audplay_msg_buffer_update { - unsigned int buffer_write_count; - unsigned int num_of_buffer; - unsigned int buf0_address; - unsigned int buf0_length; - unsigned int buf1_address; - unsigned int buf1_length; -} __attribute__((packed)); - -#define AUDPLAY_UP_OUTPORT_FLUSH_ACK 0x0005 - -#endif /* QDSP5AUDPLAYMSG_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppcmdi.h deleted file mode 100644 index bdcf5d8eae2b66ea4aacfaf7e1b33af7df1da211..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppcmdi.h +++ /dev/null @@ -1,1088 +0,0 @@ -#ifndef __MACH_QDSP5_V2_QDSP5AUDPPCMDI_H -#define __MACH_QDSP5_V2_QDSP5AUDPPCMDI_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - - A U D I O P O S T P R O C E S S I N G I N T E R N A L C O M M A N D S - -GENERAL DESCRIPTION - This file contains defintions of format blocks of commands - that are accepted by AUDPP Task - -REFERENCES - None - -EXTERNALIZED FUNCTIONS - None - -Copyright(c) 1992-2011, The Linux Foundation. All rights reserved. - -This software is licensed under the terms of the GNU General Public -License version 2, as published by the Free Software Foundation, and -may be copied, distributed, and modified under those terms. - -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. - -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ - -/* - * ARM to AUDPPTASK Commands - * - * ARM uses three command queues to communicate with AUDPPTASK - * 1)uPAudPPCmd1Queue : Used for more frequent and shorter length commands - * Location : MEMA - * Buffer Size : 6 words - * No of buffers in a queue : 20 for gaming audio and 5 for other images - * 2)uPAudPPCmd2Queue : Used for commands which are not much lengthier - * Location : MEMA - * Buffer Size : 23 - * No of buffers in a queue : 2 - * 3)uPAudOOCmd3Queue : Used for lengthier and more frequent commands - * Location : MEMA - * Buffer Size : 145 - * No of buffers in a queue : 3 - */ - -/* - * Commands Related to uPAudPPCmd1Queue - */ - -/* - * Command Structure to enable or disable the active decoders - */ - -#define AUDPP_CMD_CFG_DEC_TYPE 0x0001 -#define AUDPP_CMD_CFG_DEC_TYPE_LEN sizeof(struct audpp_cmd_cfg_dec_type) - -/* Enable the decoder */ -#define AUDPP_CMD_DEC_TYPE_M 0x000F - -#define AUDPP_CMD_ENA_DEC_V 0x4000 -#define AUDPP_CMD_DIS_DEC_V 0x0000 -#define AUDPP_CMD_DEC_STATE_M 0x4000 - -#define AUDPP_CMD_UPDATDE_CFG_DEC 0x8000 -#define AUDPP_CMD_DONT_UPDATE_CFG_DEC 0x0000 - - -/* Type specification of cmd_cfg_dec */ - -struct audpp_cmd_cfg_dec_type { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short dec_cfg; - unsigned short dm_mode; -} __attribute__((packed)); - -/* - * Command Structure to Pause , Resume and flushes the selected audio decoders - */ - -#define AUDPP_CMD_DEC_CTRL 0x0002 -#define AUDPP_CMD_DEC_CTRL_LEN sizeof(struct audpp_cmd_dec_ctrl) - -/* Decoder control commands for pause, resume and flush */ -#define AUDPP_CMD_FLUSH_V 0x2000 - -#define AUDPP_CMD_PAUSE_V 0x4000 -#define AUDPP_CMD_RESUME_V 0x0000 - -#define AUDPP_CMD_UPDATE_V 0x8000 -#define AUDPP_CMD_IGNORE_V 0x0000 - - -/* Type Spec for decoder control command*/ - -struct audpp_cmd_dec_ctrl{ - unsigned short cmd_id; - unsigned short stream_id; - unsigned short dec_ctrl; -} __attribute__((packed)); - -/* - * Command Structure to Configure the AVSync FeedBack Mechanism - */ - -#define AUDPP_CMD_AVSYNC 0x0003 -#define AUDPP_CMD_AVSYNC_LEN sizeof(struct audpp_cmd_avsync) - -struct audpp_cmd_avsync{ - unsigned short cmd_id; - unsigned short stream_id; - unsigned short interrupt_interval; - unsigned short sample_counter_dlsw; - unsigned short sample_counter_dmsw; - unsigned short sample_counter_msw; - unsigned short byte_counter_dlsw; - unsigned short byte_counter_dmsw; - unsigned short byte_counter_msw; -} __attribute__((packed)); - -/* - * Macros used to store the AV Sync Info from DSP - */ - -#define AUDPP_AVSYNC_CH_COUNT 1 -#define AUDPP_AVSYNC_NUM_WORDS 6 -/* Timeout of 3000ms for AV Sync Query response */ -#define AUDPP_AVSYNC_EVENT_TIMEOUT 3000 - -/* - * Command Structure to Query AVSync Info from DSP - */ - -#define AUDPP_CMD_QUERY_AVSYNC 0x0006 - -struct audpp_cmd_query_avsync{ - unsigned short cmd_id; - unsigned short stream_id; -} __attribute__((packed)); - -/* - * Command Structure to enable or disable(sleep) the AUDPPTASK - */ - -#define AUDPP_CMD_CFG 0x0004 -#define AUDPP_CMD_CFG_LEN sizeof(struct audpp_cmd_cfg) - -#define AUDPP_CMD_CFG_SLEEP 0x0000 -#define AUDPP_CMD_CFG_ENABLE 0xFFFF - -struct audpp_cmd_cfg { - unsigned short cmd_id; - unsigned short cfg; -} __attribute__((packed)); - -/* - * Command Structure to Inject or drop the specified no of samples - */ - -#define AUDPP_CMD_ADJUST_SAMP 0x0005 -#define AUDPP_CMD_ADJUST_SAMP_LEN sizeof(struct audpp_cmd_adjust_samp) - -#define AUDPP_CMD_SAMP_DROP -1 -#define AUDPP_CMD_SAMP_INSERT 0x0001 - -#define AUDPP_CMD_NUM_SAMPLES 0x0001 - -struct audpp_cmd_adjust_samp { - unsigned short cmd_id; - unsigned short object_no; - signed short sample_insert_or_drop; - unsigned short num_samples; -} __attribute__((packed)); - -/* - * Command Structure to Configure AVSync Feedback Mechanism - */ - -#define AUDPP_CMD_ROUTING_MODE 0x0007 -#define AUDPP_CMD_ROUTING_MODE_LEN \ -sizeof(struct audpp_cmd_routing_mode) - -struct audpp_cmd_routing_mode { - unsigned short cmd_id; - unsigned short object_number; - unsigned short routing_mode; -} __attribute__((packed)); - -/* - * Commands Related to uPAudPPCmd2Queue - */ - -/* - * Command Structure to configure Per decoder Parameters (Common) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS 0x0000 -#define AUDPP_CMD_CFG_ADEC_PARAMS_COMMON_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_common) - -#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_FCM 0x4000 -#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_FCM 0x0000 - -#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_DCM 0x8000 -#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_DCM 0x0000 - -/* Sampling frequency*/ -#define AUDPP_CMD_SAMP_RATE_96000 0x0000 -#define AUDPP_CMD_SAMP_RATE_88200 0x0001 -#define AUDPP_CMD_SAMP_RATE_64000 0x0002 -#define AUDPP_CMD_SAMP_RATE_48000 0x0003 -#define AUDPP_CMD_SAMP_RATE_44100 0x0004 -#define AUDPP_CMD_SAMP_RATE_32000 0x0005 -#define AUDPP_CMD_SAMP_RATE_24000 0x0006 -#define AUDPP_CMD_SAMP_RATE_22050 0x0007 -#define AUDPP_CMD_SAMP_RATE_16000 0x0008 -#define AUDPP_CMD_SAMP_RATE_12000 0x0009 -#define AUDPP_CMD_SAMP_RATE_11025 0x000A -#define AUDPP_CMD_SAMP_RATE_8000 0x000B - - -/* - * Type specification of cmd_adec_cfg sent to all decoder - */ - -struct audpp_cmd_cfg_adec_params_common { - unsigned short cmd_id; - unsigned short dec_id; - unsigned short length; - unsigned short reserved; - unsigned short input_sampling_frequency; -} __attribute__((packed)); - -/* - * Command Structure to configure Per decoder Parameters (Wav) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_wav) - - -#define AUDPP_CMD_WAV_STEREO_CFG_MONO 0x0001 -#define AUDPP_CMD_WAV_STEREO_CFG_STEREO 0x0002 - -#define AUDPP_CMD_WAV_PCM_WIDTH_8 0x0000 -#define AUDPP_CMD_WAV_PCM_WIDTH_16 0x0001 -#define AUDPP_CMD_WAV_PCM_WIDTH_24 0x0002 - -struct audpp_cmd_cfg_adec_params_wav { - struct audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; - unsigned short pcm_width; - unsigned short sign; -} __attribute__((packed)); - -/* - * Command Structure for CMD_CFG_DEV_MIXER - */ - -#define AUDPP_CMD_CFG_DEV_MIXER_PARAMS_LEN \ - sizeof(struct audpp_cmd_cfg_dev_mixer_params) - -#define AUDPP_CMD_CFG_DEV_MIXER 0x0008 - -#define AUDPP_CMD_CFG_DEV_MIXER_ID_0 0 -#define AUDPP_CMD_CFG_DEV_MIXER_ID_1 1 -#define AUDPP_CMD_CFG_DEV_MIXER_ID_2 2 -#define AUDPP_CMD_CFG_DEV_MIXER_ID_3 3 -#define AUDPP_CMD_CFG_DEV_MIXER_ID_4 4 -#define AUDPP_CMD_CFG_DEV_MIXER_ID_5 5 - -#define AUDPP_CMD_CFG_DEV_MIXER_DEV_NONE 0x0000 -#define AUDPP_CMD_CFG_DEV_MIXER_DEV_0 \ - (0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_0) -#define AUDPP_CMD_CFG_DEV_MIXER_DEV_1 \ - (0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_1) -#define AUDPP_CMD_CFG_DEV_MIXER_DEV_2 \ - (0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_2) -#define AUDPP_CMD_CFG_DEV_MIXER_DEV_3 \ - (0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_3) -#define AUDPP_CMD_CFG_DEV_MIXER_DEV_4 \ - (0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_4) -#define AUDPP_CMD_CFG_DEV_MIXER_DEV_5 \ - (0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_5) - -struct audpp_cmd_cfg_dev_mixer_params { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short mixer_cmd; -} __attribute__((packed)); - - -/* - * Command Structure to configure Per decoder Parameters (ADPCM) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_ADPCM_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_adpcm) - - -#define AUDPP_CMD_ADPCM_STEREO_CFG_MONO 0x0001 -#define AUDPP_CMD_ADPCM_STEREO_CFG_STEREO 0x0002 - -struct audpp_cmd_cfg_adec_params_adpcm { - struct audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; - unsigned short block_size; -} __attribute__((packed)); - -/* - * Command Structure to configure Per decoder Parameters (WMA) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_WMA_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_wma) - -struct audpp_cmd_cfg_adec_params_wma { - struct audpp_cmd_cfg_adec_params_common common; - unsigned short armdatareqthr; - unsigned short channelsdecoded; - unsigned short wmabytespersec; - unsigned short wmasamplingfreq; - unsigned short wmaencoderopts; -} __attribute__((packed)); - - -/* - * Command Structure to configure Per decoder Parameters (MP3) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_MP3_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_mp3) - -struct audpp_cmd_cfg_adec_params_mp3 { - struct audpp_cmd_cfg_adec_params_common common; -} __attribute__((packed)); - - -/* - * Command Structure to configure Per decoder Parameters (AAC) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_AAC_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_aac) - - -#define AUDPP_CMD_AAC_FORMAT_ADTS -1 -#define AUDPP_CMD_AAC_FORMAT_RAW 0x0000 -#define AUDPP_CMD_AAC_FORMAT_PSUEDO_RAW 0x0001 -#define AUDPP_CMD_AAC_FORMAT_LOAS 0x0002 - -#define AUDPP_CMD_AAC_AUDIO_OBJECT_LC 0x0002 -#define AUDPP_CMD_AAC_AUDIO_OBJECT_LTP 0x0004 -#define AUDPP_CMD_AAC_AUDIO_OBJECT_ERLC 0x0011 - -#define AUDPP_CMD_AAC_SBR_ON_FLAG_ON 0x0001 -#define AUDPP_CMD_AAC_SBR_ON_FLAG_OFF 0x0000 - -#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_ON 0x0001 -#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_OFF 0x0000 - -struct audpp_cmd_cfg_adec_params_aac { - struct audpp_cmd_cfg_adec_params_common common; - signed short format; - unsigned short audio_object; - unsigned short ep_config; - unsigned short aac_section_data_resilience_flag; - unsigned short aac_scalefactor_data_resilience_flag; - unsigned short aac_spectral_data_resilience_flag; - unsigned short sbr_on_flag; - unsigned short sbr_ps_on_flag; - unsigned short channel_configuration; -} __attribute__((packed)); - -/* - * Command Structure to configure Per decoder Parameters (V13K) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_v13k) - - -#define AUDPP_CMD_STEREO_CFG_MONO 0x0001 -#define AUDPP_CMD_STEREO_CFG_STEREO 0x0002 - -struct audpp_cmd_cfg_adec_params_v13k { - struct audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; -} __attribute__((packed)); - -#define AUDPP_CMD_CFG_ADEC_PARAMS_EVRC_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_evrc) - -struct audpp_cmd_cfg_adec_params_evrc { - struct audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; -} __attribute__ ((packed)); - -/* - * Command Structure to configure Per decoder Parameters (AMRWB) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_AMRWB_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_amrwb) - -struct audpp_cmd_cfg_adec_params_amrwb { - struct audpp_cmd_cfg_adec_params_common common; - unsigned short stereo_cfg; -} __attribute__((packed)); - -/* - * Command Structure to configure Per decoder Parameters (WMAPRO) - */ - -#define AUDPP_CMD_CFG_ADEC_PARAMS_WMAPRO_LEN \ - sizeof(struct audpp_cmd_cfg_adec_params_wmapro) - -struct audpp_cmd_cfg_adec_params_wmapro { - struct audpp_cmd_cfg_adec_params_common common; - unsigned short armdatareqthr; - uint8_t validbitspersample; - uint8_t numchannels; - unsigned short formattag; - unsigned short samplingrate; - unsigned short avgbytespersecond; - unsigned short asfpacketlength; - unsigned short channelmask; - unsigned short encodeopt; - unsigned short advancedencodeopt; - uint32_t advancedencodeopt2; -} __attribute__((packed)); - -/* - * Command Structure to configure the HOST PCM interface - */ - -#define AUDPP_CMD_PCM_INTF 0x0001 -#define AUDPP_CMD_PCM_INTF_2 0x0002 -#define AUDPP_CMD_PCM_INTF_LEN sizeof(struct audpp_cmd_pcm_intf) - -#define AUDPP_CMD_PCM_INTF_MONO_V 0x0001 -#define AUDPP_CMD_PCM_INTF_STEREO_V 0x0002 - -/* These two values differentiate the two types of commands that could be issued - * Interface configuration command and Buffer update command */ - -#define AUDPP_CMD_PCM_INTF_CONFIG_CMD_V 0x0000 -#define AUDPP_CMD_PCM_INTF_BUFFER_CMD_V -1 - -#define AUDPP_CMD_PCM_INTF_RX_ENA_M 0x000F -#define AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V 0x0008 -#define AUDPP_CMD_PCM_INTF_RX_ENA_DSPTOARM_V 0x0004 - -/* These flags control the enabling and disabling of the interface together - * with host interface bit mask. */ - -#define AUDPP_CMD_PCM_INTF_ENA_V -1 -#define AUDPP_CMD_PCM_INTF_DIS_V 0x0000 - - -#define AUDPP_CMD_PCM_INTF_FULL_DUPLEX 0x0 -#define AUDPP_CMD_PCM_INTF_HALF_DUPLEX_TODSP 0x1 - - -#define AUDPP_CMD_PCM_INTF_OBJECT_NUM 0x5 -#define AUDPP_CMD_PCM_INTF_COMMON_OBJECT_NUM 0x6 - -struct audpp_cmd_pcm_intf { - unsigned short cmd_id; - unsigned short stream; - unsigned short stream_id; - signed short config; - unsigned short intf_type; - - /* DSP -> ARM Configuration */ - unsigned short read_buf1LSW; - unsigned short read_buf1MSW; - unsigned short read_buf1_len; - - unsigned short read_buf2LSW; - unsigned short read_buf2MSW; - unsigned short read_buf2_len; - /* 0:HOST_PCM_INTF disable - ** 0xFFFF: HOST_PCM_INTF enable - */ - signed short dsp_to_arm_flag; - unsigned short partition_number; - - /* ARM -> DSP Configuration */ - unsigned short write_buf1LSW; - unsigned short write_buf1MSW; - unsigned short write_buf1_len; - - unsigned short write_buf2LSW; - unsigned short write_buf2MSW; - unsigned short write_buf2_len; - - /* 0:HOST_PCM_INTF disable - ** 0xFFFF: HOST_PCM_INTF enable - */ - signed short arm_to_rx_flag; - unsigned short weight_decoder_to_rx; - unsigned short weight_arm_to_rx; - - unsigned short partition_number_arm_to_dsp; - unsigned short sample_rate; - unsigned short channel_mode; -} __attribute__((packed)); - -/* - ** BUFFER UPDATE COMMAND - */ -#define AUDPP_CMD_PCM_INTF_SEND_BUF_PARAMS_LEN \ - sizeof(struct audpp_cmd_pcm_intf_send_buffer) - -struct audpp_cmd_pcm_intf_send_buffer { - unsigned short cmd_id; - unsigned short stream; - unsigned short stream_id; - /* set config = 0xFFFF for configuration*/ - signed short config; - unsigned short intf_type; - unsigned short dsp_to_arm_buf_id; - unsigned short arm_to_dsp_buf_id; - unsigned short arm_to_dsp_buf_len; -} __attribute__((packed)); - - -/* - * Commands Related to uPAudPPCmd3Queue - */ - -/* - * Command Structure to configure post processing params (Commmon) - */ - -#define AUDPP_CMD_CFG_OBJECT_PARAMS 0x0000 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_common) - -#define AUDPP_CMD_OBJ0_UPDATE 0x8000 -#define AUDPP_CMD_OBJ0_DONT_UPDATE 0x0000 - - -#define AUDPP_CMD_OBJ2_UPDATE 0x8000 -#define AUDPP_CMD_OBJ2_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_OBJ3_UPDATE 0x8000 -#define AUDPP_CMD_OBJ3_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_OBJ4_UPDATE 0x8000 -#define AUDPP_CMD_OBJ4_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_HPCM_UPDATE 0x8000 -#define AUDPP_CMD_HPCM_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_COMMON_CFG_UPDATE 0x8000 -#define AUDPP_CMD_COMMON_CFG_DONT_UPDATE 0x0000 - -#define AUDPP_CMD_POPP_STREAM 0xFFFF -#define AUDPP_CMD_COPP_STREAM 0x0000 - -struct audpp_cmd_cfg_object_params_common{ - unsigned short cmd_id; - unsigned short stream; - unsigned short stream_id; - unsigned short obj_cfg; - unsigned short command_type; -} __attribute__((packed)); - -/* - * Command Structure to configure post processing params (Volume) - */ -#define AUDPP_CMD_VOLUME_PAN 0 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_VOLUME_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_volume) - -struct audpp_cmd_cfg_object_params_volume { - struct audpp_cmd_cfg_object_params_common common; - unsigned short volume; - unsigned short pan; -} __attribute__((packed)); - -/* - * Command Structure to configure post processing params (PCM Filter) - */ - -struct numerator { - unsigned short numerator_b0_filter_lsw; - unsigned short numerator_b0_filter_msw; - unsigned short numerator_b1_filter_lsw; - unsigned short numerator_b1_filter_msw; - unsigned short numerator_b2_filter_lsw; - unsigned short numerator_b2_filter_msw; -} __attribute__((packed)); - -struct denominator { - unsigned short denominator_a0_filter_lsw; - unsigned short denominator_a0_filter_msw; - unsigned short denominator_a1_filter_lsw; - unsigned short denominator_a1_filter_msw; -} __attribute__((packed)); - -struct shift_factor { - unsigned short shift_factor_0; -} __attribute__((packed)); - -struct pan { - unsigned short pan_filter_0; -} __attribute__((packed)); - -struct filter_1 { - struct numerator numerator_filter; - struct denominator denominator_filter; - struct shift_factor shift_factor_filter; - struct pan pan_filter; -} __attribute__((packed)); - -struct filter_2 { - struct numerator numerator_filter[2]; - struct denominator denominator_filter[2]; - struct shift_factor shift_factor_filter[2]; - struct pan pan_filter[2]; -} __attribute__((packed)); - -struct filter_3 { - struct numerator numerator_filter[3]; - struct denominator denominator_filter[3]; - struct shift_factor shift_factor_filter[3]; - struct pan pan_filter[3]; -} __attribute__((packed)); - -struct filter_4 { - struct numerator numerator_filter[4]; - struct denominator denominator_filter[4]; - struct shift_factor shift_factor_filter[4]; - struct pan pan_filter[4]; -} __attribute__((packed)); - -#define AUDPP_CMD_IIR_TUNING_FILTER 1 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_PCM_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_pcm) - - -struct audpp_cmd_cfg_object_params_pcm { - struct audpp_cmd_cfg_object_params_common common; - signed short active_flag; - unsigned short num_bands; - union { - struct filter_1 filter_1_params; - struct filter_2 filter_2_params; - struct filter_3 filter_3_params; - struct filter_4 filter_4_params; - } __attribute__((packed)) params_filter; -} __attribute__((packed)); - -#define AUDPP_CMD_CALIB_GAIN_RX 15 -#define AUDPP_CMD_CFG_CAL_GAIN_LEN sizeof(struct audpp_cmd_cfg_cal_gain) - - -struct audpp_cmd_cfg_cal_gain { - struct audpp_cmd_cfg_object_params_common common; - unsigned short audppcalgain; - unsigned short reserved; -} __attribute__((packed)); - - -/* - * Command Structure to configure post processing parameters (equalizer) - */ -#define AUDPP_CMD_EQUALIZER 2 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_EQALIZER_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_eqalizer) - -struct eq_numerator { - unsigned short numerator_coeff_0_lsw; - unsigned short numerator_coeff_0_msw; - unsigned short numerator_coeff_1_lsw; - unsigned short numerator_coeff_1_msw; - unsigned short numerator_coeff_2_lsw; - unsigned short numerator_coeff_2_msw; -} __attribute__((packed)); - -struct eq_denominator { - unsigned short denominator_coeff_0_lsw; - unsigned short denominator_coeff_0_msw; - unsigned short denominator_coeff_1_lsw; - unsigned short denominator_coeff_1_msw; -} __attribute__((packed)); - -struct eq_shiftfactor { - unsigned short shift_factor; -} __attribute__((packed)); - -struct eq_coeff_1 { - struct eq_numerator numerator; - struct eq_denominator denominator; - struct eq_shiftfactor shiftfactor; -} __attribute__((packed)); - -struct eq_coeff_2 { - struct eq_numerator numerator[2]; - struct eq_denominator denominator[2]; - struct eq_shiftfactor shiftfactor[2]; -} __attribute__((packed)); - -struct eq_coeff_3 { - struct eq_numerator numerator[3]; - struct eq_denominator denominator[3]; - struct eq_shiftfactor shiftfactor[3]; -} __attribute__((packed)); - -struct eq_coeff_4 { - struct eq_numerator numerator[4]; - struct eq_denominator denominator[4]; - struct eq_shiftfactor shiftfactor[4]; -} __attribute__((packed)); - -struct eq_coeff_5 { - struct eq_numerator numerator[5]; - struct eq_denominator denominator[5]; - struct eq_shiftfactor shiftfactor[5]; -} __attribute__((packed)); - -struct eq_coeff_6 { - struct eq_numerator numerator[6]; - struct eq_denominator denominator[6]; - struct eq_shiftfactor shiftfactor[6]; -} __attribute__((packed)); - -struct eq_coeff_7 { - struct eq_numerator numerator[7]; - struct eq_denominator denominator[7]; - struct eq_shiftfactor shiftfactor[7]; -} __attribute__((packed)); - -struct eq_coeff_8 { - struct eq_numerator numerator[8]; - struct eq_denominator denominator[8]; - struct eq_shiftfactor shiftfactor[8]; -} __attribute__((packed)); - -struct eq_coeff_9 { - struct eq_numerator numerator[9]; - struct eq_denominator denominator[9]; - struct eq_shiftfactor shiftfactor[9]; -} __attribute__((packed)); - -struct eq_coeff_10 { - struct eq_numerator numerator[10]; - struct eq_denominator denominator[10]; - struct eq_shiftfactor shiftfactor[10]; -} __attribute__((packed)); - -struct eq_coeff_11 { - struct eq_numerator numerator[11]; - struct eq_denominator denominator[11]; - struct eq_shiftfactor shiftfactor[11]; -} __attribute__((packed)); - -struct eq_coeff_12 { - struct eq_numerator numerator[12]; - struct eq_denominator denominator[12]; - struct eq_shiftfactor shiftfactor[12]; -} __attribute__((packed)); - - -struct audpp_cmd_cfg_object_params_eqalizer { - struct audpp_cmd_cfg_object_params_common common; - signed short eq_flag; - unsigned short num_bands; - union { - struct eq_coeff_1 eq_coeffs_1; - struct eq_coeff_2 eq_coeffs_2; - struct eq_coeff_3 eq_coeffs_3; - struct eq_coeff_4 eq_coeffs_4; - struct eq_coeff_5 eq_coeffs_5; - struct eq_coeff_6 eq_coeffs_6; - struct eq_coeff_7 eq_coeffs_7; - struct eq_coeff_8 eq_coeffs_8; - struct eq_coeff_9 eq_coeffs_9; - struct eq_coeff_10 eq_coeffs_10; - struct eq_coeff_11 eq_coeffs_11; - struct eq_coeff_12 eq_coeffs_12; - } __attribute__((packed)) eq_coeff; -} __attribute__((packed)); - -/* - * Command Structure to configure post processing parameters (ADRC) - */ -#define AUDPP_CMD_ADRC 3 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_ADRC_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_adrc) - - -#define AUDPP_CMD_ADRC_FLAG_DIS 0x0000 -#define AUDPP_CMD_ADRC_FLAG_ENA -1 -#define AUDPP_CMD_PBE_FLAG_DIS 0x0000 -#define AUDPP_CMD_PBE_FLAG_ENA -1 - -struct audpp_cmd_cfg_object_params_adrc { - struct audpp_cmd_cfg_object_params_common common; - signed short adrc_flag; - unsigned short compression_th; - unsigned short compression_slope; - unsigned short rms_time; - unsigned short attack_const_lsw; - unsigned short attack_const_msw; - unsigned short release_const_lsw; - unsigned short release_const_msw; - unsigned short adrc_delay; -}; - -/* - * Command Structure to configure post processing parameters (MB - ADRC) - */ -#define AUDPP_CMD_MBADRC 10 -#define AUDPP_MAX_MBADRC_BANDS 5 - -struct adrc_config { - uint16_t subband_enable; - uint16_t adrc_sub_mute; - uint16_t rms_time; - uint16_t compression_th; - uint16_t compression_slope; - uint16_t attack_const_lsw; - uint16_t attack_const_msw; - uint16_t release_const_lsw; - uint16_t release_const_msw; - uint16_t makeup_gain; -}; - -struct audpp_cmd_cfg_object_params_mbadrc { - struct audpp_cmd_cfg_object_params_common common; - uint16_t enable; - uint16_t num_bands; - uint16_t down_samp_level; - uint16_t adrc_delay; - uint16_t ext_buf_size; - uint16_t ext_partition; - uint16_t ext_buf_msw; - uint16_t ext_buf_lsw; - struct adrc_config adrc_band[AUDPP_MAX_MBADRC_BANDS]; -} __attribute__((packed)); - -/* - * Command Structure to configure post processing parameters(Spectrum Analizer) - */ -#define AUDPP_CMD_SPECTROGRAM 4 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_SPECTRAM_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_spectram) - - -struct audpp_cmd_cfg_object_params_spectram { - struct audpp_cmd_cfg_object_params_common common; - unsigned short sample_interval; - unsigned short num_coeff; -} __attribute__((packed)); - -/* - * Command Structure to configure post processing parameters (QConcert) - */ -#define AUDPP_CMD_QCONCERT 5 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_QCONCERT_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_qconcert) - - -#define AUDPP_CMD_QCON_ENA_FLAG_ENA -1 -#define AUDPP_CMD_QCON_ENA_FLAG_DIS 0x0000 - -#define AUDPP_CMD_QCON_OP_MODE_HEADPHONE -1 -#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_FRONT 0x0000 -#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_SIDE 0x0001 -#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_DESKTOP 0x0002 - -#define AUDPP_CMD_QCON_GAIN_UNIT 0x7FFF -#define AUDPP_CMD_QCON_GAIN_SIX_DB 0x4027 - - -#define AUDPP_CMD_QCON_EXPANSION_MAX 0x7FFF - - -struct audpp_cmd_cfg_object_params_qconcert { - struct audpp_cmd_cfg_object_params_common common; - signed short enable_flag; - signed short op_mode; - signed short gain; - signed short expansion; - signed short delay; - unsigned short stages_per_mode; - unsigned short reverb_enable; - unsigned short decay_msw; - unsigned short decay_lsw; - unsigned short decay_time_ratio_msw; - unsigned short decay_time_ratio_lsw; - unsigned short reflection_delay_time; - unsigned short late_reverb_gain; - unsigned short late_reverb_delay; - unsigned short delay_buff_size_msw; - unsigned short delay_buff_size_lsw; - unsigned short partition_num; - unsigned short delay_buff_start_msw; - unsigned short delay_buff_start_lsw; -} __attribute__((packed)); - -/* - * Command Structure to configure post processing parameters (Side Chain) - */ -#define AUDPP_CMD_SIDECHAIN_TUNING_FILTER 6 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_SIDECHAIN_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_sidechain) - - -#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_DIS 0x0000 -#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_ENA -1 - -struct audpp_cmd_cfg_object_params_sidechain { - struct audpp_cmd_cfg_object_params_common common; - signed short active_flag; - unsigned short num_bands; - union { - struct filter_1 filter_1_params; - struct filter_2 filter_2_params; - struct filter_3 filter_3_params; - struct filter_4 filter_4_params; - } __attribute__((packed)) params_filter; -} __attribute__((packed)); - - -/* - * Command Structure to configure post processing parameters (QAFX) - */ -#define AUDPP_CMD_QAFX 8 -#define AUDPP_CMD_CFG_OBJECT_PARAMS_QAFX_LEN \ - sizeof(struct audpp_cmd_cfg_object_params_qafx) - -#define AUDPP_CMD_QAFX_ENA_DISA 0x0000 -#define AUDPP_CMD_QAFX_ENA_ENA_CFG -1 -#define AUDPP_CMD_QAFX_ENA_DIS_CFG 0x0001 - -#define AUDPP_CMD_QAFX_CMD_TYPE_ENV 0x0100 -#define AUDPP_CMD_QAFX_CMD_TYPE_OBJ 0x0010 -#define AUDPP_CMD_QAFX_CMD_TYPE_QUERY 0x1000 - -#define AUDPP_CMD_QAFX_CMDS_ENV_OP_MODE 0x0100 -#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_POS 0x0101 -#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_ORI 0x0102 -#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_VEL 0X0103 -#define AUDPP_CMD_QAFX_CMDS_ENV_ENV_RES 0x0107 - -#define AUDPP_CMD_QAFX_CMDS_OBJ_SAMP_FREQ 0x0010 -#define AUDPP_CMD_QAFX_CMDS_OBJ_VOL 0x0011 -#define AUDPP_CMD_QAFX_CMDS_OBJ_DIST 0x0012 -#define AUDPP_CMD_QAFX_CMDS_OBJ_POS 0x0013 -#define AUDPP_CMD_QAFX_CMDS_OBJ_VEL 0x0014 - - -struct audpp_cmd_cfg_object_params_qafx { - struct audpp_cmd_cfg_object_params_common common; - signed short enable; - unsigned short command_type; - unsigned short num_commands; - unsigned short commands; -} __attribute__((packed)); - -/* - * Command Structure to enable , disable or configure the reverberation effect - * (REVERB) (Common) - */ - -#define AUDPP_CMD_REVERB_CONFIG 0x0001 -#define AUDPP_CMD_REVERB_CONFIG_COMMON_LEN \ - sizeof(struct audpp_cmd_reverb_config_common) - -#define AUDPP_CMD_ENA_ENA 0xFFFF -#define AUDPP_CMD_ENA_DIS 0x0000 -#define AUDPP_CMD_ENA_CFG 0x0001 - -#define AUDPP_CMD_CMD_TYPE_ENV 0x0104 -#define AUDPP_CMD_CMD_TYPE_OBJ 0x0015 -#define AUDPP_CMD_CMD_TYPE_QUERY 0x1000 - - -struct audpp_cmd_reverb_config_common { - unsigned short cmd_id; - unsigned short enable; - unsigned short cmd_type; -} __attribute__((packed)); - -/* - * Command Structure to enable , disable or configure the reverberation effect - * (ENV-0x0104) - */ - -#define AUDPP_CMD_REVERB_CONFIG_ENV_104_LEN \ - sizeof(struct audpp_cmd_reverb_config_env_104) - -struct audpp_cmd_reverb_config_env_104 { - struct audpp_cmd_reverb_config_common common; - unsigned short env_gain; - unsigned short decay_msw; - unsigned short decay_lsw; - unsigned short decay_timeratio_msw; - unsigned short decay_timeratio_lsw; - unsigned short delay_time; - unsigned short reverb_gain; - unsigned short reverb_delay; -} __attribute__((packed)); - -/* - * Command Structure to enable , disable or configure the reverberation effect - * (ENV-0x0015) - */ - -#define AUDPP_CMD_REVERB_CONFIG_ENV_15_LEN \ - sizeof(struct audpp_cmd_reverb_config_env_15) - -struct audpp_cmd_reverb_config_env_15 { - struct audpp_cmd_reverb_config_common common; - unsigned short object_num; - unsigned short absolute_gain; -} __attribute__((packed)); - -#define AUDPP_CMD_PBE 16 -#define AUDPP_CMD_CFG_PBE_LEN sizeof(struct audpp_cmd_cfg_pbe) - -struct audpp_cmd_cfg_pbe { - struct audpp_cmd_cfg_object_params_common common; - unsigned short pbe_enable; - signed short realbassmix; - signed short basscolorcontrol; - unsigned short mainchaindelay; - unsigned short xoverfltorder; - unsigned short bandpassfltorder; - signed short adrcdelay; - unsigned short downsamplelevel; - unsigned short comprmstav; - signed short expthreshold; - unsigned short expslope; - unsigned short compthreshold; - unsigned short compslope; - unsigned short cpmpattack_lsw; - unsigned short compattack_msw; - unsigned short comprelease_lsw; - unsigned short comprelease_msw; - unsigned short compmakeupgain; - signed short baselimthreshold; - signed short highlimthreshold; - signed short basslimmakeupgain; - signed short highlimmakeupgain; - signed short limbassgrc; - signed short limhighgrc; - signed short limdelay; - unsigned short filter_coeffs[90]; - unsigned short extbuffsize_lsw; - unsigned short extbuffsize_msw; - unsigned short extpartition; - unsigned short extbuffstart_lsw; - unsigned short extbuffstart_msw; -} __attribute__((packed)); - -#define AUDPP_CMD_PP_FEAT_QUERY_PARAMS 0x0002 - -struct audpp_cmd_cfg_object_params_volpan { - struct audpp_cmd_cfg_object_params_common common; - u16 volume ; - u16 pan; -}; - -struct rtc_audpp_read_data { - unsigned short cmd_id; - unsigned short obj_id; - unsigned short route_id; - unsigned short feature_id; - unsigned short extbufsizemsw; - unsigned short extbufsizelsw; - unsigned short extpart; - unsigned short extbufstartmsw; - unsigned short extbufstartlsw; -} __attribute__((packed)) ; - -#define AUDPP_CMD_SAMPLING_FREQUENCY 7 -#define AUDPP_CMD_QRUMBLE 9 - -#endif /* __MACH_QDSP5_V2_QDSP5AUDPPCMDI_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppmsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppmsg.h deleted file mode 100644 index 300232df53297968bb16408fcc4419af6cad3105..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppmsg.h +++ /dev/null @@ -1,311 +0,0 @@ -#ifndef QDSP5AUDPPMSG_H -#define QDSP5AUDPPMSG_H - -/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====* - - Q D S P 5 A U D I O P O S T P R O C E S S I N G M S G - -GENERAL DESCRIPTION - Messages sent by AUDPPTASK to ARM - -REFERENCES - None - -EXTERNALIZED FUNCTIONS - None - -Copyright (c) 1992-2009, The Linux Foundation. All rights reserved. - -This software is licensed under the terms of the GNU General Public -License version 2, as published by the Free Software Foundation, and -may be copied, distributed, and modified under those terms. - -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. - -*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/ - -/* - * AUDPPTASK uses audPPuPRlist to send messages to the ARM - * Location : MEMA - * Buffer Size : 45 - * No of Buffers in a queue : 5 for gaming audio and 1 for other images - */ - -/* - * MSG to Informs the ARM os Success/Failure of bringing up the decoder - */ - -#define AUDPP_MSG_FEAT_QUERY_DM_DONE 0x000b - -#define AUDPP_MSG_STATUS_MSG 0x0001 -#define AUDPP_MSG_STATUS_MSG_LEN \ - sizeof(struct audpp_msg_status_msg) - -#define AUDPP_MSG_STATUS_SLEEP 0x0000 -#define AUDPP_MSG_STATUS_INIT 0x0001 -#define AUDPP_MSG_STATUS_CFG 0x0002 -#define AUDPP_MSG_STATUS_PLAY 0x0003 - -#define AUDPP_MSG_REASON_NONE 0x0000 -#define AUDPP_MSG_REASON_MEM 0x0001 -#define AUDPP_MSG_REASON_NODECODER 0x0002 - -struct audpp_msg_status_msg { - unsigned short dec_id; - unsigned short status; - unsigned short reason; -} __attribute__((packed)); - -/* - * MSG to communicate the spectrum analyzer output bands to the ARM - */ -#define AUDPP_MSG_SPA_BANDS 0x0002 -#define AUDPP_MSG_SPA_BANDS_LEN \ - sizeof(struct audpp_msg_spa_bands) - -struct audpp_msg_spa_bands { - unsigned short current_object; - unsigned short spa_band_1; - unsigned short spa_band_2; - unsigned short spa_band_3; - unsigned short spa_band_4; - unsigned short spa_band_5; - unsigned short spa_band_6; - unsigned short spa_band_7; - unsigned short spa_band_8; - unsigned short spa_band_9; - unsigned short spa_band_10; - unsigned short spa_band_11; - unsigned short spa_band_12; - unsigned short spa_band_13; - unsigned short spa_band_14; - unsigned short spa_band_15; - unsigned short spa_band_16; - unsigned short spa_band_17; - unsigned short spa_band_18; - unsigned short spa_band_19; - unsigned short spa_band_20; - unsigned short spa_band_21; - unsigned short spa_band_22; - unsigned short spa_band_23; - unsigned short spa_band_24; - unsigned short spa_band_25; - unsigned short spa_band_26; - unsigned short spa_band_27; - unsigned short spa_band_28; - unsigned short spa_band_29; - unsigned short spa_band_30; - unsigned short spa_band_31; - unsigned short spa_band_32; -} __attribute__((packed)); - -/* - * MSG to communicate the PCM I/O buffer status to ARM - */ -#define AUDPP_MSG_HOST_PCM_INTF_MSG 0x0003 -#define AUDPP_MSG_HOST_PCM_INTF_MSG_LEN \ - sizeof(struct audpp_msg_host_pcm_intf_msg) - -#define AUDPP_MSG_HOSTPCM_ID_TX_ARM 0x0000 -#define AUDPP_MSG_HOSTPCM_ID_ARM_TX 0x0001 -#define AUDPP_MSG_HOSTPCM_ID_RX_ARM 0x0002 -#define AUDPP_MSG_HOSTPCM_ID_ARM_RX 0x0003 - -#define AUDPP_MSG_SAMP_FREQ_INDX_96000 0x0000 -#define AUDPP_MSG_SAMP_FREQ_INDX_88200 0x0001 -#define AUDPP_MSG_SAMP_FREQ_INDX_64000 0x0002 -#define AUDPP_MSG_SAMP_FREQ_INDX_48000 0x0003 -#define AUDPP_MSG_SAMP_FREQ_INDX_44100 0x0004 -#define AUDPP_MSG_SAMP_FREQ_INDX_32000 0x0005 -#define AUDPP_MSG_SAMP_FREQ_INDX_24000 0x0006 -#define AUDPP_MSG_SAMP_FREQ_INDX_22050 0x0007 -#define AUDPP_MSG_SAMP_FREQ_INDX_16000 0x0008 -#define AUDPP_MSG_SAMP_FREQ_INDX_12000 0x0009 -#define AUDPP_MSG_SAMP_FREQ_INDX_11025 0x000A -#define AUDPP_MSG_SAMP_FREQ_INDX_8000 0x000B - -#define AUDPP_MSG_CHANNEL_MODE_MONO 0x0001 -#define AUDPP_MSG_CHANNEL_MODE_STEREO 0x0002 - -struct audpp_msg_host_pcm_intf_msg { - unsigned short obj_num; - unsigned short numbers_of_samples; - unsigned short host_pcm_id; - unsigned short buf_indx; - unsigned short samp_freq_indx; - unsigned short channel_mode; -} __attribute__((packed)); - - -/* - * MSG to communicate 3D position of the source and listener , source volume - * source rolloff, source orientation - */ - -#define AUDPP_MSG_QAFX_POS 0x0004 -#define AUDPP_MSG_QAFX_POS_LEN \ - sizeof(struct audpp_msg_qafx_pos) - -struct audpp_msg_qafx_pos { - unsigned short current_object; - unsigned short x_pos_lis_msw; - unsigned short x_pos_lis_lsw; - unsigned short y_pos_lis_msw; - unsigned short y_pos_lis_lsw; - unsigned short z_pos_lis_msw; - unsigned short z_pos_lis_lsw; - unsigned short x_fwd_msw; - unsigned short x_fwd_lsw; - unsigned short y_fwd_msw; - unsigned short y_fwd_lsw; - unsigned short z_fwd_msw; - unsigned short z_fwd_lsw; - unsigned short x_up_msw; - unsigned short x_up_lsw; - unsigned short y_up_msw; - unsigned short y_up_lsw; - unsigned short z_up_msw; - unsigned short z_up_lsw; - unsigned short x_vel_lis_msw; - unsigned short x_vel_lis_lsw; - unsigned short y_vel_lis_msw; - unsigned short y_vel_lis_lsw; - unsigned short z_vel_lis_msw; - unsigned short z_vel_lis_lsw; - unsigned short threed_enable_flag; - unsigned short volume; - unsigned short x_pos_source_msw; - unsigned short x_pos_source_lsw; - unsigned short y_pos_source_msw; - unsigned short y_pos_source_lsw; - unsigned short z_pos_source_msw; - unsigned short z_pos_source_lsw; - unsigned short max_dist_0_msw; - unsigned short max_dist_0_lsw; - unsigned short min_dist_0_msw; - unsigned short min_dist_0_lsw; - unsigned short roll_off_factor; - unsigned short mute_after_max_flag; - unsigned short x_vel_source_msw; - unsigned short x_vel_source_lsw; - unsigned short y_vel_source_msw; - unsigned short y_vel_source_lsw; - unsigned short z_vel_source_msw; - unsigned short z_vel_source_lsw; -} __attribute__((packed)); - -/* - * MSG to provide AVSYNC feedback from DSP to ARM - */ - -#define AUDPP_MSG_AVSYNC_MSG 0x0005 -#define AUDPP_MSG_AVSYNC_MSG_LEN \ - sizeof(struct audpp_msg_avsync_msg) - -struct audpp_msg_avsync_msg { - unsigned short active_flag; - unsigned short num_samples_counter0_HSW; - unsigned short num_samples_counter0_MSW; - unsigned short num_samples_counter0_LSW; - unsigned short num_bytes_counter0_HSW; - unsigned short num_bytes_counter0_MSW; - unsigned short num_bytes_counter0_LSW; - unsigned short samp_freq_obj_0; - unsigned short samp_freq_obj_1; - unsigned short samp_freq_obj_2; - unsigned short samp_freq_obj_3; - unsigned short samp_freq_obj_4; - unsigned short samp_freq_obj_5; - unsigned short samp_freq_obj_6; - unsigned short samp_freq_obj_7; - unsigned short samp_freq_obj_8; - unsigned short samp_freq_obj_9; - unsigned short samp_freq_obj_10; - unsigned short samp_freq_obj_11; - unsigned short samp_freq_obj_12; - unsigned short samp_freq_obj_13; - unsigned short samp_freq_obj_14; - unsigned short samp_freq_obj_15; - unsigned short num_samples_counter4_HSW; - unsigned short num_samples_counter4_MSW; - unsigned short num_samples_counter4_LSW; - unsigned short num_bytes_counter4_HSW; - unsigned short num_bytes_counter4_MSW; - unsigned short num_bytes_counter4_LSW; -} __attribute__((packed)); - -/* - * MSG to provide PCM DMA Missed feedback from the DSP to ARM - */ - -#define AUDPP_MSG_PCMDMAMISSED 0x0006 -#define AUDPP_MSG_PCMDMAMISSED_LEN \ - sizeof(struct audpp_msg_pcmdmamissed); - -struct audpp_msg_pcmdmamissed { - /* - ** Bit 0 0 = PCM DMA not missed for object 0 - ** 1 = PCM DMA missed for object0 - ** Bit 1 0 = PCM DMA not missed for object 1 - ** 1 = PCM DMA missed for object1 - ** Bit 2 0 = PCM DMA not missed for object 2 - ** 1 = PCM DMA missed for object2 - ** Bit 3 0 = PCM DMA not missed for object 3 - ** 1 = PCM DMA missed for object3 - ** Bit 4 0 = PCM DMA not missed for object 4 - ** 1 = PCM DMA missed for object4 - */ - unsigned short pcmdmamissed; -} __attribute__((packed)); - -/* - * MSG to AUDPP enable or disable feedback form DSP to ARM - */ - -#define AUDPP_MSG_CFG_MSG 0x0007 -#define AUDPP_MSG_CFG_MSG_LEN \ - sizeof(struct audpp_msg_cfg_msg) - -#define AUDPP_MSG_ENA_ENA 0xFFFF -#define AUDPP_MSG_ENA_DIS 0x0000 - -struct audpp_msg_cfg_msg { - /* Enabled - 0xffff - ** Disabled - 0 - */ - unsigned short enabled; -} __attribute__((packed)); - -/* - * MSG to communicate the reverb per object volume - */ - -#define AUDPP_MSG_QREVERB_VOLUME 0x0008 -#define AUDPP_MSG_QREVERB_VOLUME_LEN \ - sizeof(struct audpp_msg_qreverb_volume) - - -struct audpp_msg_qreverb_volume { - unsigned short obj_0_gain; - unsigned short obj_1_gain; - unsigned short obj_2_gain; - unsigned short obj_3_gain; - unsigned short obj_4_gain; - unsigned short hpcm_obj_volume; -} __attribute__((packed)); - -#define AUDPP_MSG_ROUTING_ACK 0x0009 -#define AUDPP_MSG_ROUTING_ACK_LEN \ - sizeof(struct audpp_msg_routing_ack) - -struct audpp_msg_routing_ack { - unsigned short dec_id; - unsigned short routing_mode; -} __attribute__((packed)); - -#define AUDPP_MSG_FLUSH_ACK 0x000A - -#endif /* QDSP5AUDPPMSG_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreproccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreproccmdi.h deleted file mode 100644 index 3d5cf845d8644cc54dfbc91c4006365d6b2c4f72..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreproccmdi.h +++ /dev/null @@ -1,519 +0,0 @@ -/* Copyright (c) 2009-2011, 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 QDSP5AUDPREPROCCMDI_H -#define QDSP5AUDPREPROCCMDI_H - -/* - * AUDIOPREPROC COMMANDS: - * ARM uses uPAudPreProcAudRecCmdQueue to communicate with AUDPREPROCTASK - * Location : MEMB - * Buffer size : 7 - * Number of buffers in a queue : 4 - */ - -/* - * Command to enable or disable particular encoder for new interface - */ - -#define AUDPREPROC_AUDREC_CMD_ENC_CFG 0x0000 -#define AUDPREPROC_AUDREC_CMD_ENC_CFG_LEN \ - sizeof(struct audpreproc_audrec_cmd_enc_cfg) -#define AUDREC_TASK_0 0x00 /* SBC / PCM */ -#define AUDREC_TASK_1 0x01 /* AAC / PCM / VOICE ENC */ - -#define ENCODE_ENABLE 0x8000 - -/* encoder type supported */ -#define ENC_TYPE_WAV 0x00 -#define ENC_TYPE_AAC 0x01 -#define ENC_TYPE_SBC 0x02 -#define ENC_TYPE_AMRNB 0x03 -#define ENC_TYPE_EVRC 0x04 -#define ENC_TYPE_V13K 0x05 -#define ENC_TYPE_EXT_WAV 0x0F /* to dynamically configure frame size */ - -/* structure definitions according to - * command description of ARM-DSP interface specifications - */ -struct audpreproc_audrec_cmd_enc_cfg { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short audrec_enc_type; -} __attribute__((packed)); - -/* - * Command to configure parameters of selected Encoder - */ - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG 0x0001 - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_COMMON_LEN \ - sizeof(struct audpreproc_audrec_cmd_param_cfg_common) - -#define DUAL_MIC_STEREO_RECORDING 2 - -struct audpreproc_audrec_cmd_param_cfg_common { - unsigned short cmd_id; - unsigned short stream_id; -} __attribute__((packed)); - -/* - * Command Structure to configure WAV Encoder - */ - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_WAV_LEN \ - sizeof(struct audpreproc_audrec_cmd_parm_cfg_wav) - -#define AUDREC_CMD_MODE_MONO 0 -#define AUDREC_CMD_MODE_STEREO 1 - -struct audpreproc_audrec_cmd_parm_cfg_wav { - struct audpreproc_audrec_cmd_param_cfg_common common; - unsigned short aud_rec_samplerate_idx; - unsigned short aud_rec_stereo_mode; - unsigned short aud_rec_frame_size; -} __attribute__((packed)); - -/* - * Command Structure to configure AAC Encoder - */ - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_AAC_LEN \ - sizeof(struct audpreproc_audrec_cmd_parm_cfg_aac) - -struct audpreproc_audrec_cmd_parm_cfg_aac { - struct audpreproc_audrec_cmd_param_cfg_common common; - unsigned short aud_rec_samplerate_idx; - unsigned short aud_rec_stereo_mode; - signed short recording_quality; -} __attribute__((packed)); - -/* - * Command Structure to configure SBC Encoder - */ - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_SBC_LEN \ - sizeof(struct audpreproc_audrec_cmd_parm_cfg_sbc) - -/* encoder parameters mask definitions*/ - -#define AUDREC_SBC_ENC_PARAM_VER_MASK 0x000A -#define AUDREC_SBC_ENC_PARAM_ENAHANCED_SBC_BASELINE_VERSION 0x0000 -#define AUDREC_SBC_ENC_PARAM_ENAHANCED_SBC_NA_MASK 0x0400 -#define AUDREC_SBC_ENC_PARAM_BIT_ALLOC_MASK 0x0008 -#define AUDREC_SBC_ENC_PARAM_SNR_MASK 0x0100 -#define AUDREC_SBC_ENC_PARAM_MODE_MASK 0x0006 -#define AUDREC_SBC_ENC_PARAM_MODE_DUAL_MASK 0x0040 -#define AUDREC_SBC_ENC_PARAM_MODE_STEREO_MASK 0x0080 -#define AUDREC_SBC_ENC_PARAM_MODE_JOINT_STEREO_MASK 0x00C0 -#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BANDS_MASK 0x0004 -#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BANDS_8_MASK 0x0001 -#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_MASK 0x0000 -#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_4_MASK 0x0000 -#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_8_MASK 0x0001 -#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_12_MASK 0x0002 -#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_16_MASK 0x0003 - -struct audpreproc_audrec_cmd_parm_cfg_sbc { - struct audpreproc_audrec_cmd_param_cfg_common common; - unsigned short aud_rec_sbc_enc_param; - unsigned short aud_rec_sbc_bit_rate_msw; - unsigned short aud_rec_sbc_bit_rate_lsw; -} __attribute__((packed)); - -/* - * Command Structure to configure AMRNB Encoder - */ - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_AMRNB_LEN \ - sizeof(struct audpreproc_audrec_cmd_parm_cfg_amrnb) - -#define AMRNB_DTX_MODE_ENABLE -1 -#define AMRNB_DTX_MODE_DISABLE 0 - -#define AMRNB_TEST_MODE_ENABLE -1 -#define AMRNB_TEST_MODE_DISABLE 0 - -#define AMRNB_USED_MODE_MR475 0x0 -#define AMRNB_USED_MODE_MR515 0x1 -#define AMRNB_USED_MODE_MR59 0x2 -#define AMRNB_USED_MODE_MR67 0x3 -#define AMRNB_USED_MODE_MR74 0x4 -#define AMRNB_USED_MODE_MR795 0x5 -#define AMRNB_USED_MODE_MR102 0x6 -#define AMRNB_USED_MODE_MR122 0x7 - -struct audpreproc_audrec_cmd_parm_cfg_amrnb { - struct audpreproc_audrec_cmd_param_cfg_common common; - signed short dtx_mode; - signed short test_mode; - unsigned short used_mode; -} __attribute__((packed)) ; - -/* - * Command Structure to configure EVRC Encoder - */ - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_EVRC_LEN \ - sizeof(struct audpreproc_audrec_cmd_parm_cfg_evrc) - -struct audpreproc_audrec_cmd_parm_cfg_evrc { - struct audpreproc_audrec_cmd_param_cfg_common common; - unsigned short enc_min_rate; - unsigned short enc_max_rate; - unsigned short rate_modulation_cmd; -} __attribute__((packed)); - -/* - * Command Structure to configure QCELP_13K Encoder - */ - -#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_QCELP13K_LEN \ - sizeof(struct audpreproc_audrec_cmd_parm_cfg_qcelp13k) - -struct audpreproc_audrec_cmd_parm_cfg_qcelp13k { - struct audpreproc_audrec_cmd_param_cfg_common common; - unsigned short enc_min_rate; - unsigned short enc_max_rate; - unsigned short rate_modulation_cmd; - unsigned short reduced_rate_level; -} __attribute__((packed)); - -/* - * Command to configure AFE for recording paths - */ -#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG 0x0002 - -#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_LEN \ - sizeof(struct audpreproc_afe_cmd_audio_record_cfg) - -#define AUDIO_RECORDING_TURN_ON 0xFFFF -#define AUDIO_RECORDING_TURN_OFF 0x0000 - -#define AUDPP_A2DP_PIPE_SOURCE_MIX_MASK 0x0020 -#define VOICE_DL_SOURCE_MIX_MASK 0x0010 -#define VOICE_UL_SOURCE_MIX_MASK 0x0008 -#define FM_SOURCE_MIX_MASK 0x0004 -#define AUX_CODEC_TX_SOURCE_MIX_MASK 0x0002 -#define INTERNAL_CODEC_TX_SOURCE_MIX_MASK 0x0001 - -struct audpreproc_afe_cmd_audio_record_cfg { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short destination_activity; - unsigned short source_mix_mask; - unsigned short pipe_id; - unsigned short reserved; -} __attribute__((packed)); - -/* - * Command to configure Tunnel(RT) or Non-Tunnel(FTRT) mode - */ -#define AUDPREPROC_AUDREC_CMD_ROUTING_MODE 0x0003 -#define AUDPREPROC_AUDREC_CMD_ROUTING_MODE_LEN \ - sizeof(struct audpreproc_audrec_cmd_routing_mode) - -#define AUDIO_ROUTING_MODE_FTRT 0x0001 -#define AUDIO_ROUTING_MODE_RT 0x0002 - -struct audpreproc_audrec_cmd_routing_mode { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short routing_mode; -} __attribute__((packed)); - -/* - * Command to configure DSP for topology where resampler moved - * in front of pre processing chain - */ -#define AUDPREPROC_AUDREC_CMD_ENC_CFG_2 0x0004 -#define AUDPREPROC_AUDREC_CMD_ENC_CFG_2_LEN \ - sizeof(struct audpreproc_audrec_cmd_enc_cfg_2) - - -struct audpreproc_audrec_cmd_enc_cfg_2 { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short audrec_enc_type; -} __attribute__((packed)); - -/* - * AUDIOPREPROC COMMANDS: - * ARM uses uPAudPreProcCmdQueue to communicate with AUDPREPROCTASK - * Location : MEMB - * Buffer size : 52 - * Number of buffers in a queue : 3 - */ - -/* - * Command to configure the parameters of AGC - */ - -#define AUDPREPROC_CMD_CFG_AGC_PARAMS 0x0000 -#define AUDPREPROC_CMD_CFG_AGC_PARAMS_LEN \ - sizeof(struct audpreproc_cmd_cfg_agc_params) - -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_SLOPE 0x0200 -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_TH 0x0400 -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_SLOPE 0x0800 -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_TH 0x1000 -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_AIG_FLAG 0x2000 -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_STATIC_GAIN 0x4000 -#define AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG 0x8000 - -#define AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA -1 -#define AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS 0x0000 - -#define AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_ADP_GAIN -1 -#define AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_STATIC_GAIN 0x0000 - -#define AUDPREPROC_CMD_PARAM_MASK_RMS_TAY 0x0010 -#define AUDPREPROC_CMD_PARAM_MASK_RELEASEK 0x0020 -#define AUDPREPROC_CMD_PARAM_MASK_DELAY 0x0040 -#define AUDPREPROC_CMD_PARAM_MASK_ATTACKK 0x0080 -#define AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_SLOW 0x0100 -#define AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_FAST 0x0200 -#define AUDPREPROC_CMD_PARAM_MASK_AIG_RELEASEK 0x0400 -#define AUDPREPROC_CMD_PARAM_MASK_AIG_MIN 0x0800 -#define AUDPREPROC_CMD_PARAM_MASK_AIG_MAX 0x1000 -#define AUDPREPROC_CMD_PARAM_MASK_LEAK_UP 0x2000 -#define AUDPREPROC_CMD_PARAM_MASK_LEAK_DOWN 0x4000 -#define AUDPREPROC_CMD_PARAM_MASK_AIG_ATTACKK 0x8000 - -struct audpreproc_cmd_cfg_agc_params { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short tx_agc_param_mask; - signed short tx_agc_enable_flag; - unsigned short comp_rlink_static_gain; - signed short comp_rlink_aig_flag; - unsigned short expander_rlink_th; - unsigned short expander_rlink_slope; - unsigned short compressor_rlink_th; - unsigned short compressor_rlink_slope; - unsigned short tx_adc_agc_param_mask; - unsigned short comp_rlink_aig_attackk; - unsigned short comp_rlink_aig_leak_down; - unsigned short comp_rlink_aig_leak_up; - unsigned short comp_rlink_aig_max; - unsigned short comp_rlink_aig_min; - unsigned short comp_rlink_aig_releasek; - unsigned short comp_rlink_aig_leakrate_fast; - unsigned short comp_rlink_aig_leakrate_slow; - unsigned short comp_rlink_attackk_msw; - unsigned short comp_rlink_attackk_lsw; - unsigned short comp_rlink_delay; - unsigned short comp_rlink_releasek_msw; - unsigned short comp_rlink_releasek_lsw; - unsigned short comp_rlink_rms_tav; -} __attribute__((packed)); - -/* - * Command to configure the params of Advanved AGC - */ - -#define AUDPREPROC_CMD_CFG_AGC_PARAMS_2 0x0001 -#define AUDPREPROC_CMD_CFG_AGC_PARAMS_2_LEN \ - sizeof(struct audpreproc_cmd_cfg_agc_params_2) - -#define AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_ENA -1; -#define AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_DIS 0x0000; - -struct audpreproc_cmd_cfg_agc_params_2 { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short agc_param_mask; - signed short tx_agc_enable_flag; - unsigned short comp_rlink_static_gain; - unsigned short exp_rlink_th; - unsigned short exp_rlink_slope; - unsigned short comp_rlink_th; - unsigned short comp_rlink_slope; - unsigned short comp_rlink_rms_tav; - unsigned short comp_rlink_down_samp_mask; - unsigned short comp_rlink_attackk_msw; - unsigned short comp_rlink_attackk_lsw; - unsigned short comp_rlink_releasek_msw; - unsigned short comp_rlink_releasek_lsw; - unsigned short comp_rlink_delay; - unsigned short comp_rlink_makeup_gain; -} __attribute__((packed)); - -/* - * Command to configure params for ns - */ - -#define AUDPREPROC_CMD_CFG_NS_PARAMS 0x0002 -#define AUDPREPROC_CMD_CFG_NS_PARAMS_LEN \ - sizeof(struct audpreproc_cmd_cfg_ns_params) - -#define AUDPREPROC_CMD_EC_MODE_NLMS_ENA 0x0001 -#define AUDPREPROC_CMD_EC_MODE_NLMS_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_DES_ENA 0x0002 -#define AUDPREPROC_CMD_EC_MODE_DES_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NS_ENA 0x0004 -#define AUDPREPROC_CMD_EC_MODE_NS_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_CNI_ENA 0x0008 -#define AUDPREPROC_CMD_EC_MODE_CNI_DIS 0x0000 - -#define AUDPREPROC_CMD_EC_MODE_NLES_ENA 0x0010 -#define AUDPREPROC_CMD_EC_MODE_NLES_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_HB_ENA 0x0020 -#define AUDPREPROC_CMD_EC_MODE_HB_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_VA_ENA 0x0040 -#define AUDPREPROC_CMD_EC_MODE_VA_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_PCD_ENA 0x0080 -#define AUDPREPROC_CMD_EC_MODE_PCD_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_FEHI_ENA 0x0100 -#define AUDPREPROC_CMD_EC_MODE_FEHI_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NEHI_ENA 0x0200 -#define AUDPREPROC_CMD_EC_MODE_NEHI_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_NLPP_ENA 0x0400 -#define AUDPREPROC_CMD_EC_MODE_NLPP_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_FNE_ENA 0x0800 -#define AUDPREPROC_CMD_EC_MODE_FNE_DIS 0x0000 -#define AUDPREPROC_CMD_EC_MODE_PRENLMS_ENA 0x1000 -#define AUDPREPROC_CMD_EC_MODE_PRENLMS_DIS 0x0000 - -struct audpreproc_cmd_cfg_ns_params { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short ec_mode_new; - unsigned short dens_gamma_n; - unsigned short dens_nfe_block_size; - unsigned short dens_limit_ns; - unsigned short dens_limit_ns_d; - unsigned short wb_gamma_e; - unsigned short wb_gamma_n; -} __attribute__((packed)); - -/* - * Command to configure parameters for IIR tuning filter - */ - -#define AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS 0x0003 -#define AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS_LEN \ - sizeof(struct audpreproc_cmd_cfg_iir_tuning_filter_params) - -#define AUDPREPROC_CMD_IIR_ACTIVE_FLAG_DIS 0x0000 -#define AUDPREPROC_CMD_IIR_ACTIVE_FLAG_ENA 0x0001 - -struct audpreproc_cmd_cfg_iir_tuning_filter_params { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short active_flag; - unsigned short num_bands; - - unsigned short numerator_coeff_b0_filter0_lsw; - unsigned short numerator_coeff_b0_filter0_msw; - unsigned short numerator_coeff_b1_filter0_lsw; - unsigned short numerator_coeff_b1_filter0_msw; - unsigned short numerator_coeff_b2_filter0_lsw; - unsigned short numerator_coeff_b2_filter0_msw; - - unsigned short numerator_coeff_b0_filter1_lsw; - unsigned short numerator_coeff_b0_filter1_msw; - unsigned short numerator_coeff_b1_filter1_lsw; - unsigned short numerator_coeff_b1_filter1_msw; - unsigned short numerator_coeff_b2_filter1_lsw; - unsigned short numerator_coeff_b2_filter1_msw; - - unsigned short numerator_coeff_b0_filter2_lsw; - unsigned short numerator_coeff_b0_filter2_msw; - unsigned short numerator_coeff_b1_filter2_lsw; - unsigned short numerator_coeff_b1_filter2_msw; - unsigned short numerator_coeff_b2_filter2_lsw; - unsigned short numerator_coeff_b2_filter2_msw; - - unsigned short numerator_coeff_b0_filter3_lsw; - unsigned short numerator_coeff_b0_filter3_msw; - unsigned short numerator_coeff_b1_filter3_lsw; - unsigned short numerator_coeff_b1_filter3_msw; - unsigned short numerator_coeff_b2_filter3_lsw; - unsigned short numerator_coeff_b2_filter3_msw; - - unsigned short denominator_coeff_a0_filter0_lsw; - unsigned short denominator_coeff_a0_filter0_msw; - unsigned short denominator_coeff_a1_filter0_lsw; - unsigned short denominator_coeff_a1_filter0_msw; - - unsigned short denominator_coeff_a0_filter1_lsw; - unsigned short denominator_coeff_a0_filter1_msw; - unsigned short denominator_coeff_a1_filter1_lsw; - unsigned short denominator_coeff_a1_filter1_msw; - - unsigned short denominator_coeff_a0_filter2_lsw; - unsigned short denominator_coeff_a0_filter2_msw; - unsigned short denominator_coeff_a1_filter2_lsw; - unsigned short denominator_coeff_a1_filter2_msw; - - unsigned short denominator_coeff_a0_filter3_lsw; - unsigned short denominator_coeff_a0_filter3_msw; - unsigned short denominator_coeff_a1_filter3_lsw; - unsigned short denominator_coeff_a1_filter3_msw; - - unsigned short shift_factor_filter0; - unsigned short shift_factor_filter1; - unsigned short shift_factor_filter2; - unsigned short shift_factor_filter3; - - unsigned short pan_of_filter0; - unsigned short pan_of_filter1; - unsigned short pan_of_filter2; - unsigned short pan_of_filter3; -} __attribute__((packed)); - -/* - * Command to configure parameters for calibration gain rx - */ - -#define AUDPREPROC_CMD_CFG_CAL_GAIN_PARAMS 0x0004 -#define AUDPREPROC_CMD_CFG_CAL_GAIN_LEN \ - sizeof(struct audpreproc_cmd_cfg_cal_gain) - -struct audpreproc_cmd_cfg_cal_gain { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short audprecalgain; - unsigned short reserved; -} __attribute__((packed)); - -#define AUDPREPROC_CMD_CFG_LVNV_PARMS 0x0006 -#define AUDPREPROC_CMD_CFG_LVNV_PARMS_LEN \ - sizeof(struct audpreproc_cmd_cfg_lvnv_param) - -struct audpreproc_cmd_cfg_lvnv_param { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short cs_mode; - unsigned short lvnv_ext_buf_size; - unsigned short lvnv_ext_partition; - unsigned short lvnv_ext_buf_start_lsw; - unsigned short lvnv_ext_buf_start_msw; -}; - -#define AUDPREPROC_CMD_FEAT_QUERY_PARAMS 0x0005 - -struct rtc_audpreproc_read_data { - unsigned short cmd_id; - unsigned short stream_id; - unsigned short feature_id; - unsigned short extbufsizemsw; - unsigned short extbufsizelsw; - unsigned short extpart; - unsigned short extbufstartmsw; - unsigned short extbufstartlsw; -} __attribute__((packed)) ; - -#endif /* QDSP5AUDPREPROCCMDI_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreprocmsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreprocmsg.h deleted file mode 100644 index d3efbcd2f68d0ece9e56f5f71127adcc63b40918..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreprocmsg.h +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright (c) 2009-2010, 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 QDSP5AUDPREPROCMSG_H -#define QDSP5AUDPREPROCMSG_H - -#define AUDPREPROC_MSG_FEAT_QUERY_DM_DONE 0x0006 - -/* - * ADSPREPROCTASK Messages - * AUDPREPROCTASK uses audPreProcUpRlist to communicate with ARM - * Location : MEMB - * Buffer size : 6 - * No of buffers in queue : 4 - */ - -/* - * Message to indicate Pre processing config command is done - */ - -#define AUDPREPROC_CMD_CFG_DONE_MSG 0x0001 -#define AUDPREPROC_CMD_CFG_DONE_MSG_LEN \ - sizeof(struct audpreproc_cmd_cfg_done_msg) - -#define AUD_PREPROC_TYPE_AGC 0x0 -#define AUD_PREPROC_NOISE_REDUCTION 0x1 -#define AUD_PREPROC_IIR_TUNNING_FILTER 0x2 - -#define AUD_PREPROC_CONFIG_ENABLED -1 -#define AUD_PREPROC_CONFIG_DISABLED 0 - -struct audpreproc_cmd_cfg_done_msg { - unsigned short stream_id; - unsigned short aud_preproc_type; - signed short aud_preproc_status_flag; -} __attribute__((packed)); - -/* - * Message to indicate Pre processing error messages - */ - -#define AUDPREPROC_ERROR_MSG 0x0002 -#define AUDPREPROC_ERROR_MSG_LEN \ - sizeof(struct audpreproc_err_msg) - -#define AUD_PREPROC_ERR_IDX_WRONG_SAMPLING_FREQUENCY 0x00 -#define AUD_PREPROC_ERR_IDX_ENC_NOT_SUPPORTED 0x01 - -struct audpreproc_err_msg { - unsigned short stream_id; - signed short aud_preproc_err_idx; -} __attribute__((packed)); - -/* - * Message to indicate encoder config command - */ - -#define AUDPREPROC_CMD_ENC_CFG_DONE_MSG 0x0003 -#define AUDPREPROC_CMD_ENC_CFG_DONE_MSG_LEN \ - sizeof(struct audpreproc_cmd_enc_cfg_done_msg) - -struct audpreproc_cmd_enc_cfg_done_msg { - unsigned short stream_id; - unsigned short rec_enc_type; -} __attribute__((packed)); - -/* - * Message to indicate encoder param config command - */ - -#define AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG 0x0004 -#define AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG_LEN \ - sizeof(struct audpreproc_cmd_enc_param_cfg_done_msg) - -struct audpreproc_cmd_enc_param_cfg_done_msg { - unsigned short stream_id; -} __attribute__((packed)); - - -/* - * Message to indicate AFE config cmd for - * audio recording is successfully recieved - */ - -#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG 0x0005 -#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG_LEN \ - sizeof(struct audpreproc_afe_cmd_audio_record_cfg_done) - -struct audpreproc_afe_cmd_audio_record_cfg_done { - unsigned short stream_id; -} __attribute__((packed)); - -/* - * Message to indicate Routing mode - * configuration success or failure - */ - -#define AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG 0x0007 -#define AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG_LEN \ - sizeof(struct audpreproc_cmd_routing_mode_done) - -struct audpreproc_cmd_routing_mode_done { - unsigned short stream_id; - unsigned short configuration; -} __attribute__((packed)); - - -#define AUDPREPROC_CMD_PCM_CFG_ARM_TO_PREPROC_DONE_MSG 0x0008 -#define AUDPREPROC_CMD_PCM_CFG_ARM_TO_PREPROC_DONE_MSG_LEN \ - sizeof(struct audreproc_cmd_pcm_cfg_arm_to_preproc_done) - -struct audreproc_cmd_pcm_cfg_arm_to_preproc_done { - unsigned short stream_id; - unsigned short configuration; -} __attribute__((packed)); - -#endif /* QDSP5AUDPREPROCMSG_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audreccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audreccmdi.h deleted file mode 100644 index 49642df182c64d017332bdd350457345b93c1ecc..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audreccmdi.h +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (c) 2009-2011, 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 QDSP5AUDRECCMDI_H -#define QDSP5AUDRECCMDI_H - -/* - * AUDRECTASK COMMANDS - * ARM uses 2 queues to communicate with the AUDRECTASK - * 1.uPAudRec[i]CmdQueue, where i=0,1,2 - * Location :MEMC - * Buffer Size : 5 - * No of Buffers in a queue : 2 - * 2.uPAudRec[i]BitstreamQueue, where i=0,1,2 - * Location : MEMC - * Buffer Size : 5 - * No of buffers in a queue : 3 - */ - -/* - * Commands on uPAudRec[i]CmdQueue, where i=0,1,2 - */ - -/* - * Command to configure memory for enabled encoder - */ - -#define AUDREC_CMD_MEM_CFG_CMD 0x0000 -#define AUDREC_CMD_ARECMEM_CFG_LEN \ - sizeof(struct audrec_cmd_arecmem_cfg) - -struct audrec_cmd_arecmem_cfg { - unsigned short cmd_id; - unsigned short audrec_up_pkt_intm_count; - unsigned short audrec_ext_pkt_start_addr_msw; - unsigned short audrec_ext_pkt_start_addr_lsw; - unsigned short audrec_ext_pkt_buf_number; -} __attribute__((packed)); - -/* - * Command to configure pcm input memory - */ - -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC 0x0001 -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_LEN \ - sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc) - -struct audrec_cmd_pcm_cfg_arm_to_enc { - unsigned short cmd_id; - unsigned short config_update_flag; - unsigned short enable_flag; - unsigned short sampling_freq; - unsigned short channels; - unsigned short frequency_of_intimation; - unsigned short max_number_of_buffers; -} __attribute__((packed)); - -#define AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE -1 -#define AUDREC_PCM_CONFIG_UPDATE_FLAG_DISABLE 0 - -#define AUDREC_ENABLE_FLAG_VALUE -1 -#define AUDREC_DISABLE_FLAG_VALUE 0 - -/* - * Command to intimate available pcm buffer - */ - -#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC 0x0002 -#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC_LEN \ - sizeof(struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc) - -struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc { - unsigned short cmd_id; - unsigned short num_buffers; - unsigned short buffer_write_cnt_msw; - unsigned short buffer_write_cnt_lsw; - unsigned short buf_address_length[8];/*this array holds address - and length details of - two buffers*/ -} __attribute__((packed)); - -/* - * Command to flush - */ - -#define AUDREC_CMD_FLUSH 0x0003 -#define AUDREC_CMD_FLUSH_LEN \ - sizeof(struct audrec_cmd_flush) - -struct audrec_cmd_flush { - unsigned short cmd_id; -} __attribute__((packed)); - -/* - * Commands on uPAudRec[i]BitstreamQueue, where i=0,1,2 - */ - -/* - * Command to indicate current packet read count - */ - -#define UP_AUDREC_PACKET_EXT_PTR 0x0000 -#define UP_AUDREC_PACKET_EXT_PTR_LEN \ - sizeof(up_audrec_packet_ext_ptr) - -struct up_audrec_packet_ext_ptr { - unsigned short cmd_id; - unsigned short audrec_up_curr_read_count_lsw; - unsigned short audrec_up_curr_read_count_msw; -} __attribute__((packed)); - -#endif /* QDSP5AUDRECCMDI_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audrecmsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audrecmsg.h deleted file mode 100644 index eb4623585845990b43eb4e553ab011af5e79a041..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audrecmsg.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (c) 2009-2010, 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 QDSP5AUDRECMSG_H -#define QDSP5AUDRECMSG_H - -/* - * AUDRECTASK MESSAGES - * AUDRECTASK uses audRec[i]UpRlist, where i=0,1,2 to communicate with ARM - * Location : MEMC - * Buffer size : 5 - * No of buffers in a queue : 10 - */ - -/* - * Message to notify 2 error conditions - */ - -#define AUDREC_FATAL_ERR_MSG 0x0001 -#define AUDREC_FATAL_ERR_MSG_LEN \ - sizeof(struct audrec_fatal_err_msg) - -#define AUDREC_FATAL_ERR_MSG_NO_PKT 0x00 - -struct audrec_fatal_err_msg { - unsigned short audrec_err_id; -} __attribute__((packed)); - -/* - * Message to indicate encoded packet is delivered to external buffer - */ - -#define AUDREC_UP_PACKET_READY_MSG 0x0002 -#define AUDREC_UP_PACKET_READY_MSG_LEN \ - sizeof(struct audrec_up_pkt_ready_msg) - -struct audrec_up_pkt_ready_msg { - unsigned short audrec_packet_write_cnt_lsw; - unsigned short audrec_packet_write_cnt_msw; - unsigned short audrec_up_prev_read_cnt_lsw; - unsigned short audrec_up_prev_read_cnt_msw; -} __attribute__((packed)); - -/* - * Message indicates arecmem cfg done - */ -#define AUDREC_CMD_MEM_CFG_DONE_MSG 0x0003 - -/* buffer conntents are nill only message id is required */ - -/* - * Message to indicate pcm buffer configured - */ - -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG 0x0004 -#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG_LEN \ - sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc_msg) - -struct audrec_cmd_pcm_cfg_arm_to_enc_msg { - unsigned short configuration; -} __attribute__((packed)); - -/* - * Message to indicate encoded packet is delivered to external buffer in FTRT - */ - -#define AUDREC_UP_NT_PACKET_READY_MSG 0x0005 -#define AUDREC_UP_NT_PACKET_READY_MSG_LEN \ - sizeof(struct audrec_up_nt_packet_ready_msg) - -struct audrec_up_nt_packet_ready_msg { - unsigned short audrec_packetwrite_cnt_lsw; - unsigned short audrec_packetwrite_cnt_msw; - unsigned short audrec_upprev_readcount_lsw; - unsigned short audrec_upprev_readcount_msw; -} __attribute__((packed)); - -/* - * Message to indicate pcm buffer is consumed - */ - -#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG 0x0006 -#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG_LEN \ - sizeof(struct audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg) - -struct audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg { - unsigned short buffer_readcnt_msw; - unsigned short buffer_readcnt_lsw; - unsigned short number_of_buffers; - unsigned short buffer_address_length[]; -} __attribute__((packed)); - -/* - * Message to indicate flush acknowledgement - */ - -#define AUDREC_CMD_FLUSH_DONE_MSG 0x0007 - -/* - * Message to indicate End of Stream acknowledgement - */ - -#define AUDREC_CMD_EOS_ACK_MSG 0x0008 - -#endif /* QDSP5AUDRECMSG_H */ diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_acdb.h b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_acdb.h deleted file mode 100644 index 31dd582ba21f813fe100e0c47d34fc15d05fa825..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_acdb.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (c) 2010-2013, 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 _AUDIO_ACDB_H -#define _AUDIO_ACDB_H - -#include -#include - -enum { - RX_CAL, - TX_CAL, - MAX_AUDPROC_TYPES -}; - -enum { - VOCPROC_CAL, - VOCSTRM_CAL, - VOCVOL_CAL, - MAX_VOCPROC_TYPES -}; - -struct acdb_cal_block { - uint32_t cal_size; - uint32_t cal_kvaddr; - uint32_t cal_paddr; -}; - -struct acdb_atomic_cal_block { - atomic_t cal_size; - atomic_t cal_kvaddr; - atomic_t cal_paddr; -}; - -struct acdb_cal_data { - uint32_t num_cal_blocks; - struct acdb_atomic_cal_block *cal_blocks; -}; - -uint32_t get_voice_rx_topology(void); -uint32_t get_voice_tx_topology(void); -uint32_t get_adm_rx_topology(void); -uint32_t get_adm_tx_topology(void); -uint32_t get_asm_topology(void); -void get_voice_cal_allocation(struct acdb_cal_block *cal_block); -void get_all_voice_cal(struct acdb_cal_block *cal_block); -void get_all_cvp_cal(struct acdb_cal_block *cal_block); -void get_all_vocproc_cal(struct acdb_cal_block *cal_block); -void get_all_vocstrm_cal(struct acdb_cal_block *cal_block); -void get_all_vocvol_cal(struct acdb_cal_block *cal_block); -void get_anc_cal(struct acdb_cal_block *cal_block); -void get_afe_cal(int32_t path, struct acdb_cal_block *cal_block); -void get_audproc_cal(int32_t path, struct acdb_cal_block *cal_block); -void get_audstrm_cal(int32_t path, struct acdb_cal_block *cal_block); -void get_audvol_cal(int32_t path, struct acdb_cal_block *cal_block); -void get_vocproc_cal(struct acdb_cal_data *cal_data); -void get_vocstrm_cal(struct acdb_cal_data *cal_data); -void get_vocvol_cal(struct acdb_cal_data *cal_data); -void get_sidetone_cal(struct sidetone_cal *cal_data); - -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h b/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h deleted file mode 100644 index 6b2d7ccf52ad710eab8be7ef74b62651ac27617b..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp6v2/audio_dev_ctl.h +++ /dev/null @@ -1,221 +0,0 @@ -/* Copyright (c) 2009-2012, 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 __MACH_QDSP6_V2_SNDDEV_H -#define __MACH_QDSP6_V2_SNDDEV_H -#include -#include - -#define AUDIO_DEV_CTL_MAX_DEV 64 -#define DIR_TX 2 -#define DIR_RX 1 - -#define DEVICE_IGNORE 0xffff -#define COPP_IGNORE 0xffffffff -#define SESSION_IGNORE 0x0UL - -/* 8 concurrent sessions with Q6 possible, session:0 - reserved in DSP */ -#define MAX_SESSIONS 0x09 - -/* This represents Maximum bit needed for representing sessions - per clients, MAX_BIT_PER_CLIENT >= MAX_SESSIONS */ -#define MAX_BIT_PER_CLIENT 16 - -#define VOICE_STATE_INVALID 0x0 -#define VOICE_STATE_INCALL 0x1 -#define VOICE_STATE_OFFCALL 0x2 -#define ONE_TO_MANY 1 -#define MANY_TO_ONE 2 - -struct msm_snddev_info { - const char *name; - u32 capability; - u32 copp_id; - u32 acdb_id; - u32 dev_volume; - struct msm_snddev_ops { - int (*open)(struct msm_snddev_info *); - int (*close)(struct msm_snddev_info *); - int (*set_freq)(struct msm_snddev_info *, u32); - int (*enable_sidetone)(struct msm_snddev_info *, u32, uint16_t); - int (*set_device_volume)(struct msm_snddev_info *, u32); - int (*enable_anc)(struct msm_snddev_info *, u32); - } dev_ops; - u8 opened; - void *private_data; - bool state; - u32 sample_rate; - u32 channel_mode; - u32 set_sample_rate; - u64 sessions; - int usage_count; - s32 max_voc_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* [0] is for NB,[1] for WB */ - s32 min_voc_rx_vol[VOC_RX_VOL_ARRAY_NUM]; -}; - -struct msm_volume { - int volume; /* Volume parameter, in % Scale */ - int pan; -}; - -extern struct msm_volume msm_vol_ctl; - -void msm_snddev_register(struct msm_snddev_info *); -void msm_snddev_unregister(struct msm_snddev_info *); -int msm_snddev_devcount(void); -int msm_snddev_query(int dev_id); -unsigned short msm_snddev_route_dec(int popp_id); -unsigned short msm_snddev_route_enc(int enc_id); - -int msm_snddev_set_dec(int popp_id, int copp_id, int set, - int rate, int channel_mode); -int msm_snddev_set_enc(int popp_id, int copp_id, int set, - int rate, int channel_mode); - -int msm_snddev_is_set(int popp_id, int copp_id); -int msm_get_voc_route(u32 *rx_id, u32 *tx_id); -int msm_set_voc_route(struct msm_snddev_info *dev_info, int stream_type, - int dev_id); -int msm_snddev_enable_sidetone(u32 dev_id, u32 enable, uint16_t gain); - -int msm_set_copp_id(int session_id, int copp_id); - -int msm_clear_copp_id(int session_id, int copp_id); - -int msm_clear_session_id(int session_id); - -int msm_reset_all_device(void); - -int reset_device(void); - -int msm_clear_all_session(void); - -struct msm_snddev_info *audio_dev_ctrl_find_dev(u32 dev_id); - -void msm_release_voc_thread(void); - -int snddev_voice_set_volume(int vol, int path); - -struct auddev_evt_voc_devinfo { - u32 dev_type; /* Rx or Tx */ - u32 acdb_dev_id; /* acdb id of device */ - u32 dev_sample; /* Sample rate of device */ - s32 max_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* unit is mb (milibel), - [0] is for NB, other for WB */ - s32 min_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* unit is mb */ - u32 dev_id; /* registered device id */ - u32 dev_port_id; -}; - -struct auddev_evt_audcal_info { - u32 dev_id; - u32 acdb_id; - u32 sample_rate; - u32 dev_type; - u32 sessions; -}; - -union msm_vol_mute { - int vol; - bool mute; -}; - -struct auddev_evt_voc_mute_info { - u32 dev_type; - u32 acdb_dev_id; - u32 voice_session_id; - union msm_vol_mute dev_vm_val; -}; - -struct auddev_evt_freq_info { - u32 dev_type; - u32 acdb_dev_id; - u32 sample_rate; -}; - -union auddev_evt_data { - struct auddev_evt_voc_devinfo voc_devinfo; - struct auddev_evt_voc_mute_info voc_vm_info; - struct auddev_evt_freq_info freq_info; - u32 routing_id; - s32 session_vol; - s32 voice_state; - struct auddev_evt_audcal_info audcal_info; - u32 voice_session_id; -}; - -struct message_header { - uint32_t id; - uint32_t data_len; -}; - -#define AUDDEV_EVT_DEV_CHG_VOICE 0x01 /* device change event */ -#define AUDDEV_EVT_DEV_RDY 0x02 /* device ready event */ -#define AUDDEV_EVT_DEV_RLS 0x04 /* device released event */ -#define AUDDEV_EVT_REL_PENDING 0x08 /* device release pending */ -#define AUDDEV_EVT_DEVICE_VOL_MUTE_CHG 0x10 /* device volume changed */ -#define AUDDEV_EVT_START_VOICE 0x20 /* voice call start */ -#define AUDDEV_EVT_END_VOICE 0x40 /* voice call end */ -#define AUDDEV_EVT_STREAM_VOL_CHG 0x80 /* device volume changed */ -#define AUDDEV_EVT_FREQ_CHG 0x100 /* Change in freq */ -#define AUDDEV_EVT_VOICE_STATE_CHG 0x200 /* Change in voice state */ - -#define AUDDEV_CLNT_VOC 0x1 /*Vocoder clients*/ -#define AUDDEV_CLNT_DEC 0x2 /*Decoder clients*/ -#define AUDDEV_CLNT_ENC 0x3 /* Encoder clients */ -#define AUDDEV_CLNT_AUDIOCAL 0x4 /* AudioCalibration client */ - -#define AUDIO_DEV_CTL_MAX_LISTNER 20 /* Max Listeners Supported */ - -struct msm_snd_evt_listner { - uint32_t evt_id; - uint32_t clnt_type; - uint32_t clnt_id; - void *private_data; - void (*auddev_evt_listener)(u32 evt_id, - union auddev_evt_data *evt_payload, - void *private_data); - struct msm_snd_evt_listner *cb_next; - struct msm_snd_evt_listner *cb_prev; -}; - -struct event_listner { - struct msm_snd_evt_listner *cb; - u32 num_listner; - int state; /* Call state */ /* TODO remove this if not req*/ -}; - -extern struct event_listner event; -int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id, - void (*listner)(u32 evt_id, - union auddev_evt_data *evt_payload, - void *private_data), - void *private_data); -int auddev_unregister_evt_listner(u32 clnt_type, u32 clnt_id); -void mixer_post_event(u32 evt_id, u32 dev_id); -void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id); -int auddev_cfg_tx_copp_topology(int session_id, int cfg); -int msm_snddev_request_freq(int *freq, u32 session_id, - u32 capability, u32 clnt_type); -int msm_snddev_withdraw_freq(u32 session_id, - u32 capability, u32 clnt_type); -int msm_device_is_voice(int dev_id); -int msm_get_voc_freq(int *tx_freq, int *rx_freq); -int msm_snddev_get_enc_freq(int session_id); -int msm_set_voice_vol(int dir, s32 volume, u32 session_id); -int msm_set_voice_mute(int dir, int mute, u32 session_id); -int msm_get_voice_state(void); -int msm_enable_incall_recording(int popp_id, int rec_mode, int rate, - int channel_mode); -int msm_disable_incall_recording(uint32_t popp_id, uint32_t rec_mode); -#endif diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/q6core.h b/arch/arm/mach-msm/include/mach/qdsp6v2/q6core.h deleted file mode 100644 index ea345fbd92baeab175c6020cf2f93a343e45d500..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp6v2/q6core.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2011-2012, 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 __Q6CORE_H__ -#define __Q6CORE_H__ -#include - - -#define ADSP_CMD_REMOTE_BUS_BW_REQUEST 0x0001115D -#define AUDIO_IF_BUS_ID 1 - -struct adsp_cmd_remote_bus_bw_request { - struct apr_hdr hdr; - u16 bus_identifier; - u16 reserved; - u32 ab_bps; - u32 ib_bps; -} __packed; - -#define ADSP_GET_VERSION 0x00011152 -#define ADSP_GET_VERSION_RSP 0x00011153 - -struct adsp_get_version { - uint32_t build_id; - uint32_t svc_cnt; -}; - -struct adsp_service_info { - uint32_t svc_id; - uint32_t svc_ver; -}; - -#define ADSP_CMD_SET_POWER_COLLAPSE_STATE 0x0001115C -struct adsp_power_collapse { - struct apr_hdr hdr; - uint32_t power_collapse; -}; - -#define ADSP_CMD_SET_DTS_MODEL_ID 0x00012917 - -struct adsp_dts_modelid { - struct apr_hdr hdr; - uint32_t model_ID_size; - uint8_t model_ID[128]; -}; - -int core_req_bus_bandwith(u16 bus_id, u32 ab_bps, u32 ib_bps); - -uint32_t core_get_adsp_version(void); - -uint32_t core_set_dts_model_id(uint32_t id_size, uint8_t *id); - -#endif /* __Q6CORE_H__ */ diff --git a/arch/arm/mach-msm/include/mach/qdsp6v2/q6voice.h b/arch/arm/mach-msm/include/mach/qdsp6v2/q6voice.h deleted file mode 100644 index 7165998e2efaec330bdeb04607f3587b6382f062..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/qdsp6v2/q6voice.h +++ /dev/null @@ -1,778 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __QDSP6VOICE_H__ -#define __QDSP6VOICE_H__ - -#include - -/* Device Event */ -#define DEV_CHANGE_READY 0x1 - -#define VOICE_CALL_START 0x1 -#define VOICE_CALL_END 0 - -#define VOICE_DEV_ENABLED 0x1 -#define VOICE_DEV_DISABLED 0 - -#define MAX_VOC_PKT_SIZE 642 - -#define SESSION_NAME_LEN 20 - -struct voice_header { - uint32_t id; - uint32_t data_len; -}; - -struct voice_init { - struct voice_header hdr; - void *cb_handle; -}; - - -/* Device information payload structure */ - -struct device_data { - uint32_t dev_acdb_id; - uint32_t volume; /* in percentage */ - uint32_t mute; - uint32_t sample; - uint32_t enabled; - uint32_t dev_id; - uint32_t dev_port_id; -}; - -enum { - VOC_INIT = 0, - VOC_RUN, - VOC_CHANGE, - VOC_RELEASE, -}; - -/* TO MVM commands */ -#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x000110FF -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110FE -/* Create a new full control MVM session. */ - -#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IMVM_CMD_ATTACH_STREAM 0x0001123C -/* Attach a stream to the MVM. */ - -#define VSS_IMVM_CMD_DETACH_STREAM 0x0001123D -/* Detach a stream from the MVM. */ - -#define VSS_IMVM_CMD_ATTACH_VOCPROC 0x0001123E -/* Attach a vocproc to the MVM. The MVM will symmetrically connect this vocproc - * to all the streams currently attached to it. - */ - -#define VSS_IMVM_CMD_DETACH_VOCPROC 0x0001123F -/* Detach a vocproc from the MVM. The MVM will symmetrically disconnect this - * vocproc from all the streams to which it is currently attached. - */ - -#define VSS_IMVM_CMD_START_VOICE 0x00011190 -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IMVM_CMD_STOP_VOICE 0x00011192 -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ISTREAM_CMD_ATTACH_VOCPROC 0x000110F8 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ISTREAM_CMD_DETACH_VOCPROC 0x000110F9 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - - -#define VSS_ISTREAM_CMD_SET_TTY_MODE 0x00011196 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ICOMMON_CMD_SET_NETWORK 0x0001119C -/* Set the network type. */ - -#define VSS_ICOMMON_CMD_SET_VOICE_TIMING 0x000111E0 -/* Set the voice timing parameters. */ - -struct vss_imvm_cmd_create_control_session_t { - char name[SESSION_NAME_LEN]; - /* - * A variable-sized stream name. - * - * The stream name size is the payload size minus the size of the other - * fields. - */ -} __packed; - -struct vss_istream_cmd_set_tty_mode_t { - uint32_t mode; - /**< - * TTY mode. - * - * 0 : TTY disabled - * 1 : HCO - * 2 : VCO - * 3 : FULL - */ -} __attribute__((packed)); - -struct vss_istream_cmd_attach_vocproc_t { - uint16_t handle; - /**< Handle of vocproc being attached. */ -} __attribute__((packed)); - -struct vss_istream_cmd_detach_vocproc_t { - uint16_t handle; - /**< Handle of vocproc being detached. */ -} __attribute__((packed)); - -struct vss_imvm_cmd_attach_stream_t { - uint16_t handle; - /* The stream handle to attach. */ -} __attribute__((packed)); - -struct vss_imvm_cmd_detach_stream_t { - uint16_t handle; - /* The stream handle to detach. */ -} __attribute__((packed)); - -struct vss_icommon_cmd_set_network_t { - uint32_t network_id; - /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */ -} __attribute__((packed)); - -struct vss_icommon_cmd_set_voice_timing_t { - uint16_t mode; - /* - * The vocoder frame synchronization mode. - * - * 0 : No frame sync. - * 1 : Hard VFR (20ms Vocoder Frame Reference interrupt). - */ - uint16_t enc_offset; - /* - * The offset in microseconds from the VFR to deliver a Tx vocoder - * packet. The offset should be less than 20000us. - */ - uint16_t dec_req_offset; - /* - * The offset in microseconds from the VFR to request for an Rx vocoder - * packet. The offset should be less than 20000us. - */ - uint16_t dec_offset; - /* - * The offset in microseconds from the VFR to indicate the deadline to - * receive an Rx vocoder packet. The offset should be less than 20000us. - * Rx vocoder packets received after this deadline are not guaranteed to - * be processed. - */ -} __attribute__((packed)); - -struct mvm_attach_vocproc_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_attach_vocproc_t mvm_attach_cvp_handle; -} __attribute__((packed)); - -struct mvm_detach_vocproc_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_detach_vocproc_t mvm_detach_cvp_handle; -} __attribute__((packed)); - -struct mvm_create_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_imvm_cmd_create_control_session_t mvm_session; -} __packed; - -struct mvm_set_tty_mode_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_tty_mode_t tty_mode; -} __attribute__((packed)); - -struct mvm_attach_stream_cmd { - struct apr_hdr hdr; - struct vss_imvm_cmd_attach_stream_t attach_stream; -} __attribute__((packed)); - -struct mvm_detach_stream_cmd { - struct apr_hdr hdr; - struct vss_imvm_cmd_detach_stream_t detach_stream; -} __attribute__((packed)); - -struct mvm_set_network_cmd { - struct apr_hdr hdr; - struct vss_icommon_cmd_set_network_t network; -} __attribute__((packed)); - -struct mvm_set_voice_timing_cmd { - struct apr_hdr hdr; - struct vss_icommon_cmd_set_voice_timing_t timing; -} __attribute__((packed)); - -/* TO CVS commands */ -#define VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x00011140 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110F7 -/* Create a new full control stream session. */ - -#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C - -#define VSS_ISTREAM_CMD_CACHE_CALIBRATION_DATA 0x000110FB - -#define VSS_ISTREAM_CMD_SET_MUTE 0x00011022 - -#define VSS_ISTREAM_CMD_SET_MEDIA_TYPE 0x00011186 -/* Set media type on the stream. */ - -#define VSS_ISTREAM_EVT_SEND_ENC_BUFFER 0x00011015 -/* Event sent by the stream to its client to provide an encoded packet. */ - -#define VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER 0x00011017 -/* Event sent by the stream to its client requesting for a decoder packet. - * The client should respond with a VSS_ISTREAM_EVT_SEND_DEC_BUFFER event. - */ - -#define VSS_ISTREAM_EVT_SEND_DEC_BUFFER 0x00011016 -/* Event sent by the client to the stream in response to a - * VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER event, providing a decoder packet. - */ - -#define VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE 0x0001113E -/* Set AMR encoder rate. */ - -#define VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE 0x0001113F -/* Set AMR-WB encoder rate. */ - -#define VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE 0x00011019 -/* Set encoder minimum and maximum rate. */ - -#define VSS_ISTREAM_CMD_SET_ENC_DTX_MODE 0x0001101D -/* Set encoder DTX mode. */ - -#define VSS_ISTREAM_CMD_START_RECORD 0x00011236 -/* Start in-call conversation recording. */ - -#define VSS_ISTREAM_CMD_STOP_RECORD 0x00011237 -/* Stop in-call conversation recording. */ - -#define VSS_ISTREAM_CMD_START_PLAYBACK 0x00011238 -/* Start in-call music delivery on the Tx voice path. */ - -#define VSS_ISTREAM_CMD_STOP_PLAYBACK 0x00011239 -/* Stop the in-call music delivery on the Tx voice path. */ - -struct vss_istream_cmd_create_passive_control_session_t { - char name[SESSION_NAME_LEN]; - /**< - * A variable-sized stream name. - * - * The stream name size is the payload size minus the size of the other - * fields. - */ -} __attribute__((packed)); - -struct vss_istream_cmd_set_mute_t { - uint16_t direction; - /**< - * 0 : TX only - * 1 : RX only - * 2 : TX and Rx - */ - uint16_t mute_flag; - /**< - * Mute, un-mute. - * - * 0 : Silence disable - * 1 : Silence enable - * 2 : CNG enable. Applicable to TX only. If set on RX behavior - * will be the same as 1 - */ -} __attribute__((packed)); - -struct vss_istream_cmd_create_full_control_session_t { - uint16_t direction; - /* - * Stream direction. - * - * 0 : TX only - * 1 : RX only - * 2 : TX and RX - * 3 : TX and RX loopback - */ - uint32_t enc_media_type; - /* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ - uint32_t dec_media_type; - /* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ - uint32_t network_id; - /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */ - char name[SESSION_NAME_LEN]; - /* - * A variable-sized stream name. - * - * The stream name size is the payload size minus the size of the other - * fields. - */ -} __attribute__((packed)); - -struct vss_istream_cmd_set_media_type_t { - uint32_t rx_media_id; - /* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ - uint32_t tx_media_id; - /* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ -} __attribute__((packed)); - -struct vss_istream_evt_send_enc_buffer_t { - uint32_t media_id; - /* Media ID of the packet. */ - uint8_t packet_data[MAX_VOC_PKT_SIZE]; - /* Packet data buffer. */ -} __attribute__((packed)); - -struct vss_istream_evt_send_dec_buffer_t { - uint32_t media_id; - /* Media ID of the packet. */ - uint8_t packet_data[MAX_VOC_PKT_SIZE]; - /* Packet data. */ -} __attribute__((packed)); - -struct vss_istream_cmd_voc_amr_set_enc_rate_t { - uint32_t mode; - /* Set the AMR encoder rate. - * - * 0x00000000 : 4.75 kbps - * 0x00000001 : 5.15 kbps - * 0x00000002 : 5.90 kbps - * 0x00000003 : 6.70 kbps - * 0x00000004 : 7.40 kbps - * 0x00000005 : 7.95 kbps - * 0x00000006 : 10.2 kbps - * 0x00000007 : 12.2 kbps - */ -} __attribute__((packed)); - -struct vss_istream_cmd_voc_amrwb_set_enc_rate_t { - uint32_t mode; - /* Set the AMR-WB encoder rate. - * - * 0x00000000 : 6.60 kbps - * 0x00000001 : 8.85 kbps - * 0x00000002 : 12.65 kbps - * 0x00000003 : 14.25 kbps - * 0x00000004 : 15.85 kbps - * 0x00000005 : 18.25 kbps - * 0x00000006 : 19.85 kbps - * 0x00000007 : 23.05 kbps - * 0x00000008 : 23.85 kbps - */ -} __attribute__((packed)); - -struct vss_istream_cmd_cdma_set_enc_minmax_rate_t { - uint16_t min_rate; - /* Set the lower bound encoder rate. - * - * 0x0000 : Blank frame - * 0x0001 : Eighth rate - * 0x0002 : Quarter rate - * 0x0003 : Half rate - * 0x0004 : Full rate - */ - uint16_t max_rate; - /* Set the upper bound encoder rate. - * - * 0x0000 : Blank frame - * 0x0001 : Eighth rate - * 0x0002 : Quarter rate - * 0x0003 : Half rate - * 0x0004 : Full rate - */ -} __attribute__((packed)); - -struct vss_istream_cmd_set_enc_dtx_mode_t { - uint32_t enable; - /* Toggle DTX on or off. - * - * 0 : Disables DTX - * 1 : Enables DTX - */ -} __attribute__((packed)); - -#define VSS_TAP_POINT_NONE 0x00010F78 -/* Indicates no tapping for specified path. */ - -#define VSS_TAP_POINT_STREAM_END 0x00010F79 -/* Indicates that specified path should be tapped at the end of the stream. */ - -struct vss_istream_cmd_start_record_t { - uint32_t rx_tap_point; - /* Tap point to use on the Rx path. Supported values are: - * VSS_TAP_POINT_NONE : Do not record Rx path. - * VSS_TAP_POINT_STREAM_END : Rx tap point is at the end of the stream. - */ - uint32_t tx_tap_point; - /* Tap point to use on the Tx path. Supported values are: - * VSS_TAP_POINT_NONE : Do not record tx path. - * VSS_TAP_POINT_STREAM_END : Tx tap point is at the end of the stream. - */ -} __attribute__((packed)); - -struct cvs_create_passive_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_create_passive_control_session_t cvs_session; -} __attribute__((packed)); - -struct cvs_create_full_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_create_full_control_session_t cvs_session; -} __attribute__((packed)); - -struct cvs_destroy_session_cmd { - struct apr_hdr hdr; -} __attribute__((packed)); - -struct cvs_cache_calibration_data_cmd { - struct apr_hdr hdr; -} __attribute__ ((packed)); - -struct cvs_set_mute_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_mute_t cvs_set_mute; -} __attribute__((packed)); - -struct cvs_set_media_type_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_media_type_t media_type; -} __attribute__((packed)); - -struct cvs_send_dec_buf_cmd { - struct apr_hdr hdr; - struct vss_istream_evt_send_dec_buffer_t dec_buf; -} __attribute__((packed)); - -struct cvs_set_amr_enc_rate_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate; -} __attribute__((packed)); - -struct cvs_set_amrwb_enc_rate_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate; -} __attribute__((packed)); - -struct cvs_set_cdma_enc_minmax_rate_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate; -} __attribute__((packed)); - -struct cvs_set_enc_dtx_mode_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode; -} __attribute__((packed)); - -struct cvs_start_record_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_start_record_t rec_mode; -} __attribute__((packed)); - -/* TO CVP commands */ - -#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION 0x000100C3 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C - -#define VSS_IVOCPROC_CMD_SET_DEVICE 0x000100C4 - -#define VSS_IVOCPROC_CMD_CACHE_CALIBRATION_DATA 0x000110E3 - -#define VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE 0x000110E4 - -#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB - -#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE - -#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6 -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1 -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70 -#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71 -#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72 - -#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77 - -/* Newtwork IDs */ -#define VSS_NETWORK_ID_DEFAULT 0x00010037 -#define VSS_NETWORK_ID_VOIP_NB 0x00011240 -#define VSS_NETWORK_ID_VOIP_WB 0x00011241 -#define VSS_NETWORK_ID_VOIP_WV 0x00011242 - -/* Media types */ -#define VSS_MEDIA_ID_13K_MODEM 0x00010FC1 -/* Qcelp vocoder modem format */ -#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2 -/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */ -#define VSS_MEDIA_ID_4GV_NB_MODEM 0x00010FC3 -/* 4GV Narrowband modem format */ -#define VSS_MEDIA_ID_4GV_WB_MODEM 0x00010FC4 -/* 4GV Wideband modem format */ -#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6 -/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */ -#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7 -/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */ -#define VSS_MEDIA_ID_EFR_MODEM 0x00010FC8 -/*EFR modem format */ -#define VSS_MEDIA_ID_FR_MODEM 0x00010FC9 -/*FR modem format */ -#define VSS_MEDIA_ID_HR_MODEM 0x00010FCA -/*HR modem format */ -#define VSS_MEDIA_ID_PCM_NB 0x00010FCB -/* Linear PCM (16-bit, little-endian). */ -#define VSS_MEDIA_ID_PCM_WB 0x00010FCC -/* Linear wideband PCM vocoder modem format (16 bits, little endian). */ -#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD -/* G.711 a-law (contains two 10ms vocoder frames). */ -#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE -/* G.711 mu-law (contains two 10ms vocoder frames). */ -#define VSS_MEDIA_ID_G729 0x00010FD0 -/* G.729AB (contains two 10ms vocoder frames. */ - -#define VOICE_CMD_SET_PARAM 0x00011006 -#define VOICE_CMD_GET_PARAM 0x00011007 -#define VOICE_EVT_GET_PARAM_ACK 0x00011008 - -struct vss_ivocproc_cmd_create_full_control_session_t { - uint16_t direction; - /* - * stream direction. - * 0 : TX only - * 1 : RX only - * 2 : TX and RX - */ - uint32_t tx_port_id; - /* - * TX device port ID which vocproc will connect to. If not supplying a - * port ID set to VSS_IVOCPROC_PORT_ID_NONE. - */ - uint32_t tx_topology_id; - /* - * Tx leg topology ID. If not supplying a topology ID set to - * VSS_IVOCPROC_TOPOLOGY_ID_NONE. - */ - uint32_t rx_port_id; - /* - * RX device port ID which vocproc will connect to. If not supplying a - * port ID set to VSS_IVOCPROC_PORT_ID_NONE. - */ - uint32_t rx_topology_id; - /* - * Rx leg topology ID. If not supplying a topology ID set to - * VSS_IVOCPROC_TOPOLOGY_ID_NONE. - */ - int32_t network_id; - /* - * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network - * ID set to VSS_NETWORK_ID_DEFAULT. - */ -} __attribute__((packed)); - -struct vss_ivocproc_cmd_set_device_t { - uint32_t tx_port_id; - /**< - * TX device port ID which vocproc will connect to. - * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port. - */ - uint32_t tx_topology_id; - /**< - * TX leg topology ID. - * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any - * pre/post-processing blocks and is pass-through. - */ - int32_t rx_port_id; - /**< - * RX device port ID which vocproc will connect to. - * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port. - */ - uint32_t rx_topology_id; - /**< - * RX leg topology ID. - * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any - * pre/post-processing blocks and is pass-through. - */ -} __attribute__((packed)); - -struct vss_ivocproc_cmd_set_volume_index_t { - uint16_t vol_index; - /**< - * Volume index utilized by the vocproc to index into the volume table - * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set - * volume on the VDSP. - */ -} __attribute__((packed)); - -struct cvp_create_full_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_create_full_control_session_t cvp_session; -} __attribute__ ((packed)); - -struct cvp_command { - struct apr_hdr hdr; -} __attribute__((packed)); - -struct cvp_set_device_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_set_device_t cvp_set_device; -} __attribute__ ((packed)); - -struct cvp_cache_calibration_data_cmd { - struct apr_hdr hdr; -} __attribute__((packed)); - -struct cvp_cache_volume_calibration_table_cmd { - struct apr_hdr hdr; -} __attribute__((packed)); - -struct cvp_set_vp3_data_cmd { - struct apr_hdr hdr; -} __attribute__((packed)); - -struct cvp_set_rx_volume_index_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx; -} __attribute__((packed)); - -/* CB for up-link packets. */ -typedef void (*ul_cb_fn)(uint8_t *voc_pkt, - uint32_t pkt_len, - void *private_data); - -/* CB for down-link packets. */ -typedef void (*dl_cb_fn)(uint8_t *voc_pkt, - uint32_t *pkt_len, - void *private_data); - -struct q_min_max_rate { - uint32_t min_rate; - uint32_t max_rate; -}; - -struct mvs_driver_info { - uint32_t media_type; - uint32_t rate; - uint32_t network_type; - uint32_t dtx_mode; - struct q_min_max_rate q_min_max_rate; - ul_cb_fn ul_cb; - dl_cb_fn dl_cb; - void *private_data; -}; - -struct incall_rec_info { - uint32_t pending; - uint32_t rec_mode; -}; - -struct incall_music_info { - uint32_t pending; - uint32_t playing; -}; - -struct voice_data { - int voc_state;/*INIT, CHANGE, RELEASE, RUN */ - - wait_queue_head_t mvm_wait; - wait_queue_head_t cvs_wait; - wait_queue_head_t cvp_wait; - - /* cache the values related to Rx and Tx */ - struct device_data dev_rx; - struct device_data dev_tx; - - /* call status */ - int v_call_status; /* Start or End */ - - u32 mvm_state; - u32 cvs_state; - u32 cvp_state; - - /* Handle to MVM */ - u16 mvm_handle; - /* Handle to CVS */ - u16 cvs_handle; - /* Handle to CVP */ - u16 cvp_handle; - - struct mutex lock; - - struct incall_rec_info rec_info; - - struct incall_music_info music_info; - - u16 session_id; -}; - -#define MAX_VOC_SESSIONS 2 -#define SESSION_ID_BASE 0xFFF0 - -struct common_data { - uint32_t voc_path; - uint32_t adsp_version; - uint32_t device_events; - - /* These default values are for all devices */ - uint32_t default_mute_val; - uint32_t default_vol_val; - uint32_t default_sample_val; - - /* APR to MVM in the modem */ - void *apr_mvm; - /* APR to CVS in the modem */ - void *apr_cvs; - /* APR to CVP in the modem */ - void *apr_cvp; - - /* APR to MVM in the Q6 */ - void *apr_q6_mvm; - /* APR to CVS in the Q6 */ - void *apr_q6_cvs; - /* APR to CVP in the Q6 */ - void *apr_q6_cvp; - - struct mutex common_lock; - - struct mvs_driver_info mvs_info; - - struct voice_data voice[MAX_VOC_SESSIONS]; -}; - -int voice_set_voc_path_full(uint32_t set); - -void voice_register_mvs_cb(ul_cb_fn ul_cb, - dl_cb_fn dl_cb, - void *private_data); - -void voice_config_vocoder(uint32_t media_type, - uint32_t rate, - uint32_t network_type, - uint32_t dtx_mode, - struct q_min_max_rate q_min_max_rate); - -int voice_start_record(uint32_t rec_mode, uint32_t set); - -int voice_start_playback(uint32_t set); - -u16 voice_get_session_id(const char *name); -#endif diff --git a/arch/arm/mach-msm/include/mach/rndis_ipa.h b/arch/arm/mach-msm/include/mach/rndis_ipa.h deleted file mode 100644 index 3fc205124cd48ddb59106ef71122316ff0f3801d..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/rndis_ipa.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (c) 2013, 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 _RNDIS_IPA_H_ -#define _RNDIS_IPA_H_ - -#include - -/* - * @priv: private data given upon ipa_connect - * @evt: event enum, should be IPA_WRITE_DONE - * @data: for tx path the data field is the sent socket buffer. - */ -typedef void (*ipa_callback)(void *priv, - enum ipa_dp_evt_type evt, - unsigned long data); - -/* - * struct ipa_usb_init_params - parameters for driver initialization API - * - * @ipa_rx_notify: The network driver will set this callback (out parameter). - * this callback shall be supplied for ipa_connect upon pipe - * connection (USB->IPA), once IPA driver receive data packets - * from USB pipe destined for Apps this callback will be called. - * @ipa_tx_notify: The network driver will set this callback (out parameter). - * this callback shall be supplied for ipa_connect upon pipe - * connection (IPA->USB), once IPA driver send packets destined - * for USB, IPA BAM will notify for Tx-complete. - * @host_ethaddr: host Ethernet address in network order - * @device_ethaddr: device Ethernet address in network order - * @private: The network driver will set this pointer (out parameter). - * This pointer will hold the network device for later interaction - * with between USB driver and the network driver. - */ -struct ipa_usb_init_params { - ipa_callback ipa_rx_notify; - ipa_callback ipa_tx_notify; - u8 host_ethaddr[ETH_ALEN]; - u8 device_ethaddr[ETH_ALEN]; - void *private; -}; - -#ifdef CONFIG_RNDIS_IPA - -int rndis_ipa_init(struct ipa_usb_init_params *params); - -int rndis_ipa_pipe_connect_notify(u32 usb_to_ipa_hdl, - u32 ipa_to_usb_hdl, - u32 max_transfer_size, - u32 max_packet_number, - void *private); - -int rndis_ipa_pipe_disconnect_notify(void *private); - -void rndis_ipa_cleanup(void *private); - -#else /* CONFIG_RNDIS_IPA*/ - -int rndis_ipa_init(struct ipa_usb_init_params *params) -{ - return 0; -} - -int rndis_ipa_pipe_connect_notify(u32 usb_to_ipa_hdl, - u32 ipa_to_usb_hdl, - u32 max_transfer_size, - u32 max_packet_number, - void *private) -{ - return 0; -} - -static inline int rndis_ipa_pipe_disconnect_notify(void *private) -{ - return 0; -} - -static inline void rndis_ipa_cleanup(void *private) -{ - -} -#endif /* CONFIG_RNDIS_IPA */ - -#endif /* _RNDIS_IPA_H_ */ diff --git a/arch/arm/mach-msm/include/mach/rpc_pmapp.h b/arch/arm/mach-msm/include/mach/rpc_pmapp.h deleted file mode 100644 index 5a62f1d6a9479578b9f5efbc7f6230d5927dbf2a..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/rpc_pmapp.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) 2009-2010, 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 __ASM_ARCH_MSM_RPC_PMAPP_H -#define __ASM_ARCH_MSM_RPC_PMAPP_H - -#include - -/* Clock voting ids */ -enum { - PMAPP_CLOCK_ID_DO = 0, - PMAPP_CLOCK_ID_D1, - PMAPP_CLOCK_ID_A0, - PMAPP_CLOCK_ID_A1, -}; - -/* Clock voting types */ -enum { - PMAPP_CLOCK_VOTE_OFF = 0, - PMAPP_CLOCK_VOTE_ON, - PMAPP_CLOCK_VOTE_PIN_CTRL, -}; - -/* vreg ids */ -enum { - PMAPP_VREG_LDO22 = 14, - PMAPP_VREG_S3 = 21, - PMAPP_VREG_S2 = 23, - PMAPP_VREG_S4 = 24, -}; - -/* SMPS clock voting types */ -enum { - PMAPP_SMPS_CLK_VOTE_DONTCARE = 0, - PMAPP_SMPS_CLK_VOTE_2P74, /* 2.74 MHz */ - PMAPP_SMPS_CLK_VOTE_1P6, /* 1.6 MHz */ -}; - -/* SMPS mode voting types */ -enum { - PMAPP_SMPS_MODE_VOTE_DONTCARE = 0, - PMAPP_SMPS_MODE_VOTE_PWM, - PMAPP_SMPS_MODE_VOTE_PFM, - PMAPP_SMPS_MODE_VOTE_AUTO -}; - -int msm_pm_app_rpc_init(void(*callback)(int online)); -void msm_pm_app_rpc_deinit(void(*callback)(int online)); -int msm_pm_app_register_vbus_sn(void (*callback)(int online)); -void msm_pm_app_unregister_vbus_sn(void (*callback)(int online)); -int msm_pm_app_enable_usb_ldo(int); -int pmic_vote_3p3_pwr_sel_switch(int boost); - -int pmapp_display_clock_config(uint enable); - -int pmapp_clock_vote(const char *voter_id, uint clock_id, uint vote); -int pmapp_smps_clock_vote(const char *voter_id, uint vreg_id, uint vote); -int pmapp_vreg_level_vote(const char *voter_id, uint vreg_id, uint level); -int pmapp_smps_mode_vote(const char *voter_id, uint vreg_id, uint mode); -int pmapp_vreg_pincntrl_vote(const char *voter_id, uint vreg_id, - uint clock_id, uint vote); -int pmapp_disp_backlight_set_brightness(int value); -void pmapp_disp_backlight_init(void); -int pmapp_vreg_lpm_pincntrl_vote(const char *voter_id, uint vreg_id, - uint clock_id, uint vote); -#endif diff --git a/arch/arm/mach-msm/include/mach/rpc_server_handset.h b/arch/arm/mach-msm/include/mach/rpc_server_handset.h deleted file mode 100644 index fad38cc6ffcace0f7479b5e195d949b9fed2ebd4..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/rpc_server_handset.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) 2009-2010, 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 __ASM_ARCH_MSM_RPC_SERVER_HANDSET_H -#define __ASM_ARCH_MSM_RPC_SERVER_HANDSET_H - -struct msm_handset_platform_data { - const char *hs_name; - uint32_t pwr_key_delay_ms; /* default 500ms */ - bool ignore_end_key; -}; - -void report_headset_status(bool connected); - -#endif diff --git a/arch/arm/mach-msm/include/mach/rpm.h b/arch/arm/mach-msm/include/mach/rpm.h index 0adb453bd202685e24887e8b59343e287bf9d83f..e4f96fd8c1d67ed1c03f5c0a49bcd18ff659dfcf 100644 --- a/arch/arm/mach-msm/include/mach/rpm.h +++ b/arch/arm/mach-msm/include/mach/rpm.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2010-2013, 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 @@ -1125,48 +1125,6 @@ extern struct msm_rpm_platform_data msm8930_rpm_data; extern struct msm_rpm_platform_data msm8930_rpm_data_pm8917; extern struct msm_rpm_platform_data apq8064_rpm_data; -#if defined(CONFIG_MSM_RPM) - -int msm_rpm_local_request_is_outstanding(void); -int msm_rpm_get_status(struct msm_rpm_iv_pair *status, int count); -int msm_rpm_set(int ctx, struct msm_rpm_iv_pair *req, int count); -int msm_rpm_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); - -static inline int msm_rpm_set_nosleep( - int ctx, struct msm_rpm_iv_pair *req, int count) -{ - unsigned long flags; - int rc; - - local_irq_save(flags); - rc = msm_rpm_set_noirq(ctx, req, count); - local_irq_restore(flags); - - return rc; -} - -int msm_rpm_clear(int ctx, struct msm_rpm_iv_pair *req, int count); -int msm_rpm_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); - -static inline int msm_rpm_clear_nosleep( - int ctx, struct msm_rpm_iv_pair *req, int count) -{ - unsigned long flags; - int rc; - - local_irq_save(flags); - rc = msm_rpm_clear_noirq(ctx, req, count); - local_irq_restore(flags); - - return rc; -} - -int msm_rpm_register_notification(struct msm_rpm_notification *n, - struct msm_rpm_iv_pair *req, int count); -int msm_rpm_unregister_notification(struct msm_rpm_notification *n); -int msm_rpm_init(struct msm_rpm_platform_data *data); - -#else static inline int msm_rpm_local_request_is_outstanding(void) { @@ -1230,6 +1188,5 @@ static inline int msm_rpm_init(struct msm_rpm_platform_data *data) return -ENODEV; } -#endif /* CONFIG_RPM */ #endif /* __ARCH_ARM_MACH_MSM_RPM_H */ diff --git a/arch/arm/mach-msm/include/mach/scm-io.h b/arch/arm/mach-msm/include/mach/scm-io.h index a5c36cbd04cc3f31adf2435b7afdf79011559bf1..46e3964c16af9836e0b1269b63182ad0ac7b500d 100644 --- a/arch/arm/mach-msm/include/mach/scm-io.h +++ b/arch/arm/mach-msm/include/mach/scm-io.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, 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 @@ -14,16 +14,9 @@ #include -#ifdef CONFIG_MSM_SECURE_IO - -extern u32 secure_readl(void __iomem *c); -extern void secure_writel(u32 v, void __iomem *c); - -#else #define secure_readl(c) readl(c) #define secure_writel(v, c) writel(v, c) -#endif #endif diff --git a/arch/arm/mach-msm/include/mach/sdio_smem.h b/arch/arm/mach-msm/include/mach/sdio_smem.h deleted file mode 100644 index eed067150ffaf69c92ee971a251d99f3085777f1..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/sdio_smem.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __SDIO_SMEM_H -#define __SDIO_SMEM_H - -#include -#include - -#define SDIO_SMEM_EVENT_READ_DONE 0 -#define SDIO_SMEM_EVENT_READ_ERR 1 - -int sdio_smem_register_client(void); -int sdio_smem_unregister_client(void); - -struct sdio_smem_client { - void *buf; - int size; - struct platform_device plat_dev; - int (*cb_func)(int event); -}; - -#endif /* __SDIO_SMEM_H */ diff --git a/arch/arm/mach-msm/include/mach/sirc-fsm9xxx.h b/arch/arm/mach-msm/include/mach/sirc-fsm9xxx.h deleted file mode 100644 index ddbfd0286ba3142573e9bfecb75a114bac783a8f..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/sirc-fsm9xxx.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2011, 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 __ASM_ARCH_MSM_SIRC_FSM9XXX_H -#define __ASM_ARCH_MSM_SIRC_FSM9XXX_H - -/* Group A */ -#define INT_EBI2_WR_ER_DONE (FIRST_SIRC_IRQ + 0) -#define INT_EBI2_OP_DONE (FIRST_SIRC_IRQ + 1) -#define INT_SDC1_0 (FIRST_SIRC_IRQ + 2) -#define INT_SDC1_1 (FIRST_SIRC_IRQ + 3) -#define INT_UARTDM (FIRST_SIRC_IRQ + 4) -#define INT_UART1 (FIRST_SIRC_IRQ + 5) -/* RESERVED 6 */ -#define INT_CE (FIRST_SIRC_IRQ + 7) -#define INT_SYS_ENZO_IEQ (FIRST_SIRC_IRQ + 8) -#define INT_PERPH_ENZO (FIRST_SIRC_IRQ + 9) -#define INT_MXBAR_ENZO (FIRST_SIRC_IRQ + 10) -#define INT_AXIAGG_ENZO (FIRST_SIRC_IRQ + 11) -#define INT_UART3 (FIRST_SIRC_IRQ + 12) -#define INT_UART2 (FIRST_SIRC_IRQ + 13) -#define INT_PORT0_SSBI2 (FIRST_SIRC_IRQ + 14) -#define INT_PORT1_SSBI2 (FIRST_SIRC_IRQ + 15) -#define INT_PORT2_SSBI2 (FIRST_SIRC_IRQ + 16) -#define INT_PORT3_SSBI2 (FIRST_SIRC_IRQ + 17) -#define INT_GSBI_QUP_INBUF (FIRST_SIRC_IRQ + 18) -#define INT_GSBI_QUP_OUTBUF (FIRST_SIRC_IRQ + 19) -#define INT_GSBI_QUP_ERROR (FIRST_SIRC_IRQ + 20) -#define INT_SPB_DECODER (FIRST_SIRC_IRQ + 21) -#define INT_FPB_DEC (FIRST_SIRC_IRQ + 22) -#define INT_BPM_HW (FIRST_SIRC_IRQ + 23) -#define INT_GPIO_167 (FIRST_SIRC_IRQ + 24) - -/* Group B */ -#define INT_GPIO_166 (FIRST_SIRC_IRQ + 25) -#define INT_GPIO_165 (FIRST_SIRC_IRQ + 26) -#define INT_GPIO_164 (FIRST_SIRC_IRQ + 27) -#define INT_GPIO_163 (FIRST_SIRC_IRQ + 28) -#define INT_GPIO_162 (FIRST_SIRC_IRQ + 29) -#define INT_GPIO_161 (FIRST_SIRC_IRQ + 30) -#define INT_GPIO_160 (FIRST_SIRC_IRQ + 31) -#define INT_GPIO_159 (FIRST_SIRC_IRQ + 32) -#define INT_GPIO_158 (FIRST_SIRC_IRQ + 33) -#define INT_GPIO_157 (FIRST_SIRC_IRQ + 34) -#define INT_GPIO_156 (FIRST_SIRC_IRQ + 35) -#define INT_GPIO_155 (FIRST_SIRC_IRQ + 36) -#define INT_GPIO_154 (FIRST_SIRC_IRQ + 37) -#define INT_GPIO_153 (FIRST_SIRC_IRQ + 38) -#define INT_GPIO_152 (FIRST_SIRC_IRQ + 39) -#define INT_GPIO_151 (FIRST_SIRC_IRQ + 40) -#define INT_GPIO_150 (FIRST_SIRC_IRQ + 41) -#define INT_GPIO_149 (FIRST_SIRC_IRQ + 42) -#define INT_GPIO_148 (FIRST_SIRC_IRQ + 43) -#define INT_GPIO_147 (FIRST_SIRC_IRQ + 44) -#define INT_GPIO_146 (FIRST_SIRC_IRQ + 45) -#define INT_GPIO_145 (FIRST_SIRC_IRQ + 46) -#define INT_GPIO_144 (FIRST_SIRC_IRQ + 47) -/* RESERVED 48 */ - -#define NR_SIRC_IRQS_GROUPA 25 -#define NR_SIRC_IRQS_GROUPB 24 -#define NR_SIRC_IRQS 49 -#define SIRC_MASK_GROUPA 0x01ffffff -#define SIRC_MASK_GROUPB 0x00ffffff - -#define SPSS_SIRC_INT_CLEAR (MSM_SIRC_BASE + 0x00) -#define SPSS_SIRC_INT_POLARITY (MSM_SIRC_BASE + 0x5C) -#define SPSS_SIRC_INT_SET (MSM_SIRC_BASE + 0x18) -#define SPSS_SIRC_INT_ENABLE (MSM_SIRC_BASE + 0x20) -#define SPSS_SIRC_IRQ_STATUS (MSM_SIRC_BASE + 0x38) -#define SPSS_SIRC_INT_TYPE (MSM_SIRC_BASE + 0x30) -#define SPSS_SIRC_VEC_INDEX_RD (MSM_SIRC_BASE + 0x48) - -#endif /* __ASM_ARCH_MSM_SIRC_FSM9XXX_H */ diff --git a/arch/arm/mach-msm/include/mach/socinfo.h b/arch/arm/mach-msm/include/mach/socinfo.h index f704d15ab37242c73e406c293660fcaf1f286f1f..c86f2f5ad8b9eda77ae22899e00daf43d66c5ce2 100644 --- a/arch/arm/mach-msm/include/mach/socinfo.h +++ b/arch/arm/mach-msm/include/mach/socinfo.h @@ -313,20 +313,12 @@ static inline int cpu_is_msm8x60(void) static inline int cpu_is_msm8960(void) { -#ifdef CONFIG_ARCH_MSM8960 - return read_msm_cpu_type() == MSM_CPU_8960; -#else return 0; -#endif } static inline int cpu_is_msm8960ab(void) { -#ifdef CONFIG_ARCH_MSM8960 - return read_msm_cpu_type() == MSM_CPU_8960AB; -#else return 0; -#endif } static inline int cpu_is_apq8064(void) diff --git a/arch/arm/mach-msm/include/mach/tpm_st_i2c.h b/arch/arm/mach-msm/include/mach/tpm_st_i2c.h deleted file mode 100644 index e1d9bc17e77f790d7e7552d79135b58535d463d7..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/include/mach/tpm_st_i2c.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) 2010, 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 _TPM_ST_I2C_H_ -#define _TPM_ST_I2C_H_ - -struct tpm_st_i2c_platform_data { - int accept_cmd_gpio; - int data_avail_gpio; - int accept_cmd_irq; - int data_avail_irq; - int (*gpio_setup)(void); - void (*gpio_release)(void); -}; - -#endif diff --git a/arch/arm/mach-msm/irq.h b/arch/arm/mach-msm/irq.h deleted file mode 100644 index 67ff4467ac1004f44dc76e7147fdc951096aa2e0..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/irq.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2008-2009, 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 _ARCH_ARM_MACH_MSM_IRQ_H_ -#define _ARCH_ARM_MACH_MSM_IRQ_H_ - -int msm_irq_idle_sleep_allowed(void); -unsigned int msm_irq_pending(void); -void msm_irq_enter_sleep1(bool arm9_wake, int from_idle, uint32_t *irq_mask); -int msm_irq_enter_sleep2(bool arm9_wake, int from_idle); -void msm_irq_exit_sleep1 - (uint32_t irq_mask, uint32_t wakeup_reason, uint32_t pending_irqs); -void msm_irq_exit_sleep2 - (uint32_t irq_mask, uint32_t wakeup_reason, uint32_t pending); -void msm_irq_exit_sleep3 - (uint32_t irq_mask, uint32_t wakeup_reason, uint32_t pending_irqs); - -#endif diff --git a/arch/arm/mach-msm/mpm.c b/arch/arm/mach-msm/mpm.c deleted file mode 100644 index c134482995abf7076606c099d64367d907d2e161..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/mpm.c +++ /dev/null @@ -1,549 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/****************************************************************************** - * Debug Definitions - *****************************************************************************/ - -enum { - MSM_MPM_DEBUG_NON_DETECTABLE_IRQ = BIT(0), - MSM_MPM_DEBUG_PENDING_IRQ = BIT(1), - MSM_MPM_DEBUG_WRITE = BIT(2), - MSM_MPM_DEBUG_NON_DETECTABLE_IRQ_IDLE = BIT(3), -}; - -static int msm_mpm_debug_mask = 1; -module_param_named( - debug_mask, msm_mpm_debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP -); - -/****************************************************************************** - * Request and Status Definitions - *****************************************************************************/ - -enum { - MSM_MPM_REQUEST_REG_ENABLE, - MSM_MPM_REQUEST_REG_DETECT_CTL, - MSM_MPM_REQUEST_REG_POLARITY, - MSM_MPM_REQUEST_REG_CLEAR, -}; - -enum { - MSM_MPM_STATUS_REG_PENDING, -}; - -/****************************************************************************** - * IRQ Mapping Definitions - *****************************************************************************/ - -#define MSM_MPM_NR_APPS_IRQS (NR_MSM_IRQS + NR_GPIO_IRQS) - -#define MSM_MPM_REG_WIDTH DIV_ROUND_UP(MSM_MPM_NR_MPM_IRQS, 32) -#define MSM_MPM_IRQ_INDEX(irq) (irq / 32) -#define MSM_MPM_IRQ_MASK(irq) BIT(irq % 32) - -static struct msm_mpm_device_data msm_mpm_dev_data; -static uint8_t msm_mpm_irqs_a2m[MSM_MPM_NR_APPS_IRQS]; - -static DEFINE_SPINLOCK(msm_mpm_lock); - -/* - * Note: the following two bitmaps only mark irqs that are _not_ - * mappable to MPM. - */ -static DECLARE_BITMAP(msm_mpm_enabled_apps_irqs, MSM_MPM_NR_APPS_IRQS); -static DECLARE_BITMAP(msm_mpm_wake_apps_irqs, MSM_MPM_NR_APPS_IRQS); - -static DECLARE_BITMAP(msm_mpm_gpio_irqs_mask, MSM_MPM_NR_APPS_IRQS); - -static uint32_t msm_mpm_enabled_irq[MSM_MPM_REG_WIDTH]; -static uint32_t msm_mpm_wake_irq[MSM_MPM_REG_WIDTH]; -static uint32_t msm_mpm_detect_ctl[MSM_MPM_REG_WIDTH]; -static uint32_t msm_mpm_polarity[MSM_MPM_REG_WIDTH]; - - -/****************************************************************************** - * Low Level Functions for Accessing MPM - *****************************************************************************/ - -static inline uint32_t msm_mpm_read( - unsigned int reg, unsigned int subreg_index) -{ - unsigned int offset = reg * MSM_MPM_REG_WIDTH + subreg_index; - return __raw_readl(msm_mpm_dev_data.mpm_status_reg_base + offset * 4); -} - -static inline void msm_mpm_write( - unsigned int reg, unsigned int subreg_index, uint32_t value) -{ - unsigned int offset = reg * MSM_MPM_REG_WIDTH + subreg_index; - __raw_writel(value, msm_mpm_dev_data.mpm_request_reg_base + offset * 4); - - if (MSM_MPM_DEBUG_WRITE & msm_mpm_debug_mask) - pr_info("%s: reg %u.%u: 0x%08x\n", - __func__, reg, subreg_index, value); -} - -static inline void msm_mpm_send_interrupt(void) -{ - __raw_writel(msm_mpm_dev_data.mpm_apps_ipc_val, - msm_mpm_dev_data.mpm_apps_ipc_reg); - /* Ensure the write is complete before returning. */ - mb(); -} - -static irqreturn_t msm_mpm_irq(int irq, void *dev_id) -{ - return IRQ_HANDLED; -} - -/****************************************************************************** - * MPM Access Functions - *****************************************************************************/ - -static void msm_mpm_set(bool wakeset) -{ - uint32_t *irqs; - unsigned int reg; - int i; - - irqs = wakeset ? msm_mpm_wake_irq : msm_mpm_enabled_irq; - for (i = 0; i < MSM_MPM_REG_WIDTH; i++) { - reg = MSM_MPM_REQUEST_REG_ENABLE; - msm_mpm_write(reg, i, irqs[i]); - - reg = MSM_MPM_REQUEST_REG_DETECT_CTL; - msm_mpm_write(reg, i, msm_mpm_detect_ctl[i]); - - reg = MSM_MPM_REQUEST_REG_POLARITY; - msm_mpm_write(reg, i, msm_mpm_polarity[i]); - - reg = MSM_MPM_REQUEST_REG_CLEAR; - msm_mpm_write(reg, i, 0xffffffff); - } - - /* Ensure that the set operation is complete before sending the - * interrupt - */ - mb(); - msm_mpm_send_interrupt(); -} - -static void msm_mpm_clear(void) -{ - int i; - - for (i = 0; i < MSM_MPM_REG_WIDTH; i++) { - msm_mpm_write(MSM_MPM_REQUEST_REG_ENABLE, i, 0); - msm_mpm_write(MSM_MPM_REQUEST_REG_CLEAR, i, 0xffffffff); - } - - /* Ensure the clear is complete before sending the interrupt */ - mb(); - msm_mpm_send_interrupt(); -} - -/****************************************************************************** - * Interrupt Mapping Functions - *****************************************************************************/ - -static inline bool msm_mpm_is_valid_apps_irq(unsigned int irq) -{ - return irq < ARRAY_SIZE(msm_mpm_irqs_a2m); -} - -static inline uint8_t msm_mpm_get_irq_a2m(unsigned int irq) -{ - return msm_mpm_irqs_a2m[irq]; -} - -static inline void msm_mpm_set_irq_a2m(unsigned int apps_irq, - unsigned int mpm_irq) -{ - msm_mpm_irqs_a2m[apps_irq] = (uint8_t) mpm_irq; -} - -static inline bool msm_mpm_is_valid_mpm_irq(unsigned int irq) -{ - return irq < msm_mpm_dev_data.irqs_m2a_size; -} - -static inline uint16_t msm_mpm_get_irq_m2a(unsigned int irq) -{ - return msm_mpm_dev_data.irqs_m2a[irq]; -} - -static bool msm_mpm_bypass_apps_irq(unsigned int irq) -{ - int i; - - for (i = 0; i < msm_mpm_dev_data.bypassed_apps_irqs_size; i++) - if (irq == msm_mpm_dev_data.bypassed_apps_irqs[i]) - return true; - - return false; -} - -static int msm_mpm_enable_irq_exclusive( - unsigned int irq, bool enable, bool wakeset) -{ - uint32_t mpm_irq; - - if (!msm_mpm_is_valid_apps_irq(irq)) - return -EINVAL; - - if (msm_mpm_bypass_apps_irq(irq)) - return 0; - - mpm_irq = msm_mpm_get_irq_a2m(irq); - if (mpm_irq) { - uint32_t *mpm_irq_masks = wakeset ? - msm_mpm_wake_irq : msm_mpm_enabled_irq; - uint32_t index = MSM_MPM_IRQ_INDEX(mpm_irq); - uint32_t mask = MSM_MPM_IRQ_MASK(mpm_irq); - - if (enable) - mpm_irq_masks[index] |= mask; - else - mpm_irq_masks[index] &= ~mask; - } else { - unsigned long *apps_irq_bitmap = wakeset ? - msm_mpm_wake_apps_irqs : msm_mpm_enabled_apps_irqs; - - if (enable) - __set_bit(irq, apps_irq_bitmap); - else - __clear_bit(irq, apps_irq_bitmap); - } - - return 0; -} - -static int msm_mpm_set_irq_type_exclusive( - unsigned int irq, unsigned int flow_type) -{ - uint32_t mpm_irq; - - if (!msm_mpm_is_valid_apps_irq(irq)) - return -EINVAL; - - if (msm_mpm_bypass_apps_irq(irq)) - return 0; - - mpm_irq = msm_mpm_get_irq_a2m(irq); - if (mpm_irq) { - uint32_t index = MSM_MPM_IRQ_INDEX(mpm_irq); - uint32_t mask = MSM_MPM_IRQ_MASK(mpm_irq); - - if (index >= MSM_MPM_REG_WIDTH) - return -EFAULT; - - if (flow_type & IRQ_TYPE_EDGE_BOTH) - msm_mpm_detect_ctl[index] |= mask; - else - msm_mpm_detect_ctl[index] &= ~mask; - - if (flow_type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) - msm_mpm_polarity[index] |= mask; - else - msm_mpm_polarity[index] &= ~mask; - } - - return 0; -} - -static int __msm_mpm_enable_irq(unsigned int irq, unsigned int enable) -{ - unsigned long flags; - int rc; - - spin_lock_irqsave(&msm_mpm_lock, flags); - rc = msm_mpm_enable_irq_exclusive(irq, (bool)enable, false); - spin_unlock_irqrestore(&msm_mpm_lock, flags); - - return rc; -} - -static void msm_mpm_enable_irq(struct irq_data *d) -{ - __msm_mpm_enable_irq(d->irq, 1); -} - -static void msm_mpm_disable_irq(struct irq_data *d) -{ - __msm_mpm_enable_irq(d->irq, 0); -} - -static int msm_mpm_set_irq_wake(struct irq_data *d, unsigned int on) -{ - unsigned long flags; - int rc; - - spin_lock_irqsave(&msm_mpm_lock, flags); - rc = msm_mpm_enable_irq_exclusive(d->irq, (bool)on, true); - spin_unlock_irqrestore(&msm_mpm_lock, flags); - - return rc; -} - -static int msm_mpm_set_irq_type(struct irq_data *d, unsigned int flow_type) -{ - unsigned long flags; - int rc; - - spin_lock_irqsave(&msm_mpm_lock, flags); - rc = msm_mpm_set_irq_type_exclusive(d->irq, flow_type); - spin_unlock_irqrestore(&msm_mpm_lock, flags); - - return rc; -} - -/****************************************************************************** - * Public functions - *****************************************************************************/ -int msm_mpm_enable_pin(unsigned int pin, unsigned int enable) -{ - uint32_t index = MSM_MPM_IRQ_INDEX(pin); - uint32_t mask = MSM_MPM_IRQ_MASK(pin); - unsigned long flags; - - spin_lock_irqsave(&msm_mpm_lock, flags); - - if (enable) - msm_mpm_enabled_irq[index] |= mask; - else - msm_mpm_enabled_irq[index] &= ~mask; - - spin_unlock_irqrestore(&msm_mpm_lock, flags); - return 0; -} - -int msm_mpm_set_pin_wake(unsigned int pin, unsigned int on) -{ - uint32_t index = MSM_MPM_IRQ_INDEX(pin); - uint32_t mask = MSM_MPM_IRQ_MASK(pin); - unsigned long flags; - - spin_lock_irqsave(&msm_mpm_lock, flags); - - if (on) - msm_mpm_wake_irq[index] |= mask; - else - msm_mpm_wake_irq[index] &= ~mask; - - spin_unlock_irqrestore(&msm_mpm_lock, flags); - return 0; -} - -int msm_mpm_set_pin_type(unsigned int pin, unsigned int flow_type) -{ - uint32_t index = MSM_MPM_IRQ_INDEX(pin); - uint32_t mask = MSM_MPM_IRQ_MASK(pin); - unsigned long flags; - - spin_lock_irqsave(&msm_mpm_lock, flags); - - if (flow_type & IRQ_TYPE_EDGE_BOTH) - msm_mpm_detect_ctl[index] |= mask; - else - msm_mpm_detect_ctl[index] &= ~mask; - - if (flow_type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) - msm_mpm_polarity[index] |= mask; - else - msm_mpm_polarity[index] &= ~mask; - - spin_unlock_irqrestore(&msm_mpm_lock, flags); - return 0; -} - -bool msm_mpm_irqs_detectable(bool from_idle) -{ - unsigned long *apps_irq_bitmap; - int debug_mask; - int i = 0; - - if (from_idle) { - apps_irq_bitmap = msm_mpm_enabled_apps_irqs; - debug_mask = msm_mpm_debug_mask & - MSM_MPM_DEBUG_NON_DETECTABLE_IRQ_IDLE; - } else { - apps_irq_bitmap = msm_mpm_wake_apps_irqs; - debug_mask = msm_mpm_debug_mask & - MSM_MPM_DEBUG_NON_DETECTABLE_IRQ; - } - - if (debug_mask) { - i = find_first_bit(apps_irq_bitmap, MSM_MPM_NR_APPS_IRQS); - while (i < MSM_MPM_NR_APPS_IRQS) { - struct irq_desc *desc = i ? - irq_to_desc(i) : NULL; - pr_info("%s: cannot monitor irq=%d %s\n", - __func__, i, desc->name); - i = find_next_bit(apps_irq_bitmap, - MSM_MPM_NR_APPS_IRQS, i + 1); - } - - } - return (bool)__bitmap_empty(apps_irq_bitmap, MSM_MPM_NR_APPS_IRQS); -} - -bool msm_mpm_gpio_irqs_detectable(bool from_idle) -{ - unsigned long *apps_irq_bitmap = from_idle ? - msm_mpm_enabled_apps_irqs : msm_mpm_wake_apps_irqs; - - return !__bitmap_intersects(msm_mpm_gpio_irqs_mask, apps_irq_bitmap, - MSM_MPM_NR_APPS_IRQS); -} - -void msm_mpm_enter_sleep(uint32_t sclk_count, bool from_idle) -{ - msm_mpm_set(!from_idle); -} - -void msm_mpm_exit_sleep(bool from_idle) -{ - unsigned long pending; - int i; - int k; - - for (i = 0; i < MSM_MPM_REG_WIDTH; i++) { - pending = msm_mpm_read(MSM_MPM_STATUS_REG_PENDING, i); - - if (MSM_MPM_DEBUG_PENDING_IRQ & msm_mpm_debug_mask) - pr_info("%s: pending.%d: 0x%08lx", __func__, - i, pending); - - k = find_first_bit(&pending, 32); - while (k < 32) { - unsigned int mpm_irq = 32 * i + k; - unsigned int apps_irq = msm_mpm_get_irq_m2a(mpm_irq); - struct irq_desc *desc = apps_irq ? - irq_to_desc(apps_irq) : NULL; - - if (desc && !irqd_is_level_type(&desc->irq_data)) { - irq_set_pending(apps_irq); - if (from_idle) - check_irq_resend(desc, apps_irq); - } - - k = find_next_bit(&pending, 32, k + 1); - } - } - - msm_mpm_clear(); -} - -static int __init msm_mpm_early_init(void) -{ - uint8_t mpm_irq; - uint16_t apps_irq; - - for (mpm_irq = 0; msm_mpm_is_valid_mpm_irq(mpm_irq); mpm_irq++) { - apps_irq = msm_mpm_get_irq_m2a(mpm_irq); - if (apps_irq && msm_mpm_is_valid_apps_irq(apps_irq)) - msm_mpm_set_irq_a2m(apps_irq, mpm_irq); - } - - return 0; -} -core_initcall(msm_mpm_early_init); - -void __init msm_mpm_irq_extn_init(struct msm_mpm_device_data *mpm_data) -{ - gic_arch_extn.irq_mask = msm_mpm_disable_irq; - gic_arch_extn.irq_unmask = msm_mpm_enable_irq; - gic_arch_extn.irq_disable = msm_mpm_disable_irq; - gic_arch_extn.irq_set_type = msm_mpm_set_irq_type; - gic_arch_extn.irq_set_wake = msm_mpm_set_irq_wake; - - msm_gpio_irq_extn.irq_mask = msm_mpm_disable_irq; - msm_gpio_irq_extn.irq_unmask = msm_mpm_enable_irq; - msm_gpio_irq_extn.irq_disable = msm_mpm_disable_irq; - msm_gpio_irq_extn.irq_set_type = msm_mpm_set_irq_type; - msm_gpio_irq_extn.irq_set_wake = msm_mpm_set_irq_wake; - - bitmap_set(msm_mpm_gpio_irqs_mask, NR_MSM_IRQS, NR_GPIO_IRQS); - - if (!mpm_data) { -#ifdef CONFIG_MSM_MPM - BUG(); -#endif - return; - } - - memcpy(&msm_mpm_dev_data, mpm_data, sizeof(struct msm_mpm_device_data)); - - msm_mpm_dev_data.irqs_m2a = - kzalloc(msm_mpm_dev_data.irqs_m2a_size * sizeof(uint16_t), - GFP_KERNEL); - BUG_ON(!msm_mpm_dev_data.irqs_m2a); - memcpy(msm_mpm_dev_data.irqs_m2a, mpm_data->irqs_m2a, - msm_mpm_dev_data.irqs_m2a_size * sizeof(uint16_t)); - msm_mpm_dev_data.bypassed_apps_irqs = - kzalloc(msm_mpm_dev_data.bypassed_apps_irqs_size * - sizeof(uint16_t), GFP_KERNEL); - BUG_ON(!msm_mpm_dev_data.bypassed_apps_irqs); - memcpy(msm_mpm_dev_data.bypassed_apps_irqs, - mpm_data->bypassed_apps_irqs, - msm_mpm_dev_data.bypassed_apps_irqs_size * sizeof(uint16_t)); -} - -static int __init msm_mpm_init(void) -{ - unsigned int irq = msm_mpm_dev_data.mpm_ipc_irq; - int rc; - - rc = request_irq(irq, msm_mpm_irq, - IRQF_TRIGGER_RISING, "mpm_drv", msm_mpm_irq); - - if (rc) { - pr_err("%s: failed to request irq %u: %d\n", - __func__, irq, rc); - goto init_bail; - } - - rc = irq_set_irq_wake(irq, 1); - if (rc) { - pr_err("%s: failed to set wakeup irq %u: %d\n", - __func__, irq, rc); - goto init_free_bail; - } - - return 0; - -init_free_bail: - free_irq(irq, msm_mpm_irq); - -init_bail: - return rc; -} -device_initcall(msm_mpm_init); diff --git a/arch/arm/mach-msm/msm_bus/Makefile b/arch/arm/mach-msm/msm_bus/Makefile index 8da4079da658f295c978c15d74a7e489780acc12..f148aab8866b7267d87782539975f53e802bcc67 100644 --- a/arch/arm/mach-msm/msm_bus/Makefile +++ b/arch/arm/mach-msm/msm_bus/Makefile @@ -5,7 +5,6 @@ obj-y += msm_bus_core.o msm_bus_fabric.o msm_bus_config.o msm_bus_arb.o obj-y += msm_bus_bimc.o msm_bus_noc.o obj-$(CONFIG_CORESIGHT) += msm_buspm_coresight.o obj-$(CONFIG_OF) += msm_bus_of.o -obj-$(CONFIG_MSM_RPM) += msm_bus_rpm.o obj-$(CONFIG_MSM_RPM_SMD) += msm_bus_rpm_smd.o ifdef CONFIG_ARCH_MSM8974 diff --git a/arch/arm/mach-msm/msm_bus/msm_bus_core.h b/arch/arm/mach-msm/msm_bus/msm_bus_core.h index ede92876039aecb5714ed1bed6fd3ca7058cc46b..2fc04de6986935d1b795aa885aad69327197cf0b 100644 --- a/arch/arm/mach-msm/msm_bus/msm_bus_core.h +++ b/arch/arm/mach-msm/msm_bus/msm_bus_core.h @@ -230,7 +230,7 @@ int msm_bus_hw_fab_init(struct msm_bus_fabric_registration *pdata, void msm_bus_board_init(struct msm_bus_fabric_registration *pdata); void msm_bus_board_set_nfab(struct msm_bus_fabric_registration *pdata, int nfab); -#if defined(CONFIG_MSM_RPM) || defined(CONFIG_MSM_RPM_SMD) +#if defined(CONFIG_MSM_RPM_SMD) int msm_bus_rpm_hw_init(struct msm_bus_fabric_registration *pdata, struct msm_bus_hw_algorithm *hw_algo); int msm_bus_remote_hw_commit(struct msm_bus_fabric_registration diff --git a/arch/arm/mach-msm/msm_bus/msm_bus_rpm.c b/arch/arm/mach-msm/msm_bus/msm_bus_rpm.c deleted file mode 100644 index fd1aacdfe97c27efa49dd158df1625d07df0b5c2..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_bus/msm_bus_rpm.c +++ /dev/null @@ -1,974 +0,0 @@ -/* Copyright (c) 2011-2012, 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. - * - */ - -#define pr_fmt(fmt) "AXI: %s(): " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm_bus_core.h" -#include "../rpm_resources.h" - -void msm_bus_rpm_set_mt_mask() -{ -#ifdef CONFIG_MSM_BUS_RPM_MULTI_TIER_ENABLED - struct msm_rpm_iv_pair mt[1]; - int mask = MSM_RPMRS_MASK_RPM_CTL_MULTI_TIER; - mt[0].id = MSM_RPM_ID_RPM_CTL; - mt[0].value = 2; - msm_rpmrs_set_bits_noirq(MSM_RPM_CTX_SET_0, mt, 1, - &mask); -#endif -} - -bool msm_bus_rpm_is_mem_interleaved(void) -{ - int status = 0; - struct msm_rpm_iv_pair il[2]; - uint16_t id[2]; - - il[0].value = 0; - il[1].value = 0; - status = msm_bus_board_rpm_get_il_ids(id); - if (status) { - MSM_BUS_DBG("Dynamic check not supported, " - "default: Interleaved memory\n"); - goto inter; - } - - il[0].id = id[0]; - il[1].id = id[1]; - status = msm_rpm_get_status(il, ARRAY_SIZE(il)); - if (status) { - MSM_BUS_ERR("Status read for interleaving returned: %d\n" - "Using interleaved memory by default\n", - status); - goto inter; - } - - /* - * If the start address of EBI1-CH0 is the same as - * the start address of EBI1-CH1, the memory is interleaved. - * The start addresses are stored in the 16 MSBs of the status - * register - */ - if ((il[0].value & 0xFFFF0000) != (il[1].value & 0xFFFF0000)) { - MSM_BUS_DBG("Non-interleaved memory\n"); - return false; - } - -inter: - MSM_BUS_DBG("Interleaved memory\n"); - return true; -} - -#ifndef CONFIG_MSM_BUS_RPM_MULTI_TIER_ENABLED -struct commit_data { - uint16_t *bwsum; - uint16_t *arb; - unsigned long *actarb; -}; - -/* - * The following macros are used for various operations on commit data. - * Commit data is an array of 32 bit integers. The size of arrays is unique - * to the fabric. Commit arrays are allocated at run-time based on the number - * of masters, slaves and tiered-slaves registered. - */ - -#define MSM_BUS_GET_BW_INFO(val, type, bw) \ - do { \ - (type) = MSM_BUS_GET_BW_TYPE(val); \ - (bw) = MSM_BUS_GET_BW(val); \ - } while (0) - - -#define MSM_BUS_GET_BW_INFO_BYTES (val, type, bw) \ - do { \ - (type) = MSM_BUS_GET_BW_TYPE(val); \ - (bw) = msm_bus_get_bw_bytes(val); \ - } while (0) - -#define ROUNDED_BW_VAL_FROM_BYTES(bw) \ - ((((bw) >> 17) + 1) & 0x8000 ? 0x7FFF : (((bw) >> 17) + 1)) - -#define BW_VAL_FROM_BYTES(bw) \ - ((((bw) >> 17) & 0x8000) ? 0x7FFF : ((bw) >> 17)) - -static uint32_t msm_bus_set_bw_bytes(unsigned long bw) -{ - return ((((bw) & 0x1FFFF) && (((bw) >> 17) == 0)) ? - ROUNDED_BW_VAL_FROM_BYTES(bw) : BW_VAL_FROM_BYTES(bw)); - -} - -uint64_t msm_bus_get_bw_bytes(unsigned long val) -{ - return ((val) & 0x7FFF) << 17; -} - -uint16_t msm_bus_get_bw(unsigned long val) -{ - return (val)&0x7FFF; -} - -static uint16_t msm_bus_create_bw_tier_pair_bytes(uint8_t type, - unsigned long bw) -{ - return ((((type) == MSM_BUS_BW_TIER1 ? 1 : 0) << 15) | - (msm_bus_set_bw_bytes(bw))); -}; - -uint16_t msm_bus_create_bw_tier_pair(uint8_t type, unsigned long bw) -{ - return (((type) == MSM_BUS_BW_TIER1 ? 1 : 0) << 15) | ((bw) & 0x7FFF); -} - -void msm_bus_rpm_fill_cdata_buffer(int *curr, char *buf, const int max_size, - void *cdata, int nmasters, int nslaves, int ntslaves) -{ - int j, c; - struct commit_data *cd = (struct commit_data *)cdata; - - *curr += scnprintf(buf + *curr, max_size - *curr, "BWSum:\n"); - for (c = 0; c < nslaves; c++) - *curr += scnprintf(buf + *curr, max_size - *curr, - "0x%x\t", cd->bwsum[c]); - *curr += scnprintf(buf + *curr, max_size - *curr, "\nArb:"); - for (c = 0; c < ntslaves; c++) { - *curr += scnprintf(buf + *curr, max_size - *curr, - "\nTSlave %d:\n", c); - for (j = 0; j < nmasters; j++) - *curr += scnprintf(buf + *curr, max_size - *curr, - " 0x%x\t", cd->arb[(c * nmasters) + j]); - } -} - -/** - * allocate_commit_data() - Allocate the data for commit array in the - * format specified by RPM - * @fabric: Fabric device for which commit data is allocated - */ -static int msm_bus_rpm_allocate_commit_data(struct msm_bus_fabric_registration - *fab_pdata, void **cdata, int ctx) -{ - struct commit_data **cd = (struct commit_data **)cdata; - *cd = kzalloc(sizeof(struct commit_data), GFP_KERNEL); - if (!*cd) { - MSM_BUS_DBG("Couldn't alloc mem for cdata\n"); - return -ENOMEM; - } - (*cd)->bwsum = kzalloc((sizeof(uint16_t) * fab_pdata->nslaves), - GFP_KERNEL); - if (!(*cd)->bwsum) { - MSM_BUS_DBG("Couldn't alloc mem for slaves\n"); - kfree(*cd); - return -ENOMEM; - } - (*cd)->arb = kzalloc(((sizeof(uint16_t *)) * - (fab_pdata->ntieredslaves * fab_pdata->nmasters) + 1), - GFP_KERNEL); - if (!(*cd)->arb) { - MSM_BUS_DBG("Couldn't alloc memory for" - " slaves\n"); - kfree((*cd)->bwsum); - kfree(*cd); - return -ENOMEM; - } - (*cd)->actarb = kzalloc(((sizeof(unsigned long *)) * - (fab_pdata->ntieredslaves * fab_pdata->nmasters) + 1), - GFP_KERNEL); - if (!(*cd)->actarb) { - MSM_BUS_DBG("Couldn't alloc memory for" - " slaves\n"); - kfree((*cd)->bwsum); - kfree((*cd)->arb); - kfree(*cd); - return -ENOMEM; - } - - return 0; -} - -static void free_commit_data(void *cdata) -{ - struct commit_data *cd = (struct commit_data *)cdata; - - kfree(cd->bwsum); - kfree(cd->arb); - kfree(cd->actarb); - kfree(cd); -} - -/** - * allocate_rpm_data() - Allocate the id-value pairs to be - * sent to RPM - */ -static void *msm_bus_rpm_allocate_rpm_data(struct platform_device *pdev, - struct msm_bus_fabric_registration *fab_pdata) -{ - struct msm_rpm_iv_pair *rpm_data; - uint16_t count = ((fab_pdata->nmasters * fab_pdata->ntieredslaves) + - fab_pdata->nslaves + 1)/2; - - rpm_data = kmalloc((sizeof(struct msm_rpm_iv_pair) * count), - GFP_KERNEL); - return (void *)rpm_data; -} - -#define BWMASK 0x7FFF -#define TIERMASK 0x8000 -#define GET_TIER(n) (((n) & TIERMASK) >> 15) - -static void msm_bus_rpm_update_bw(struct msm_bus_inode_info *hop, - struct msm_bus_inode_info *info, - struct msm_bus_fabric_registration *fab_pdata, - void *sel_cdata, int *master_tiers, - int64_t add_bw) -{ - int index, i, j, tiers, ports; - struct commit_data *sel_cd = (struct commit_data *)sel_cdata; - - add_bw = INTERLEAVED_BW(fab_pdata, add_bw, info->node_info->num_mports); - ports = INTERLEAVED_VAL(fab_pdata, info->node_info->num_mports); - tiers = INTERLEAVED_VAL(fab_pdata, hop->node_info->num_tiers); - for (i = 0; i < tiers; i++) { - for (j = 0; j < ports; j++) { - uint16_t hop_tier; - /* - * For interleaved gateway ports and slave ports, - * there is one-one mapping between gateway port and - * the slave port - */ - if (info->node_info->gateway && i != j && - (hop->node_info->num_sports > 1)) - continue; - - if (!hop->node_info->tier) - hop_tier = MSM_BUS_BW_TIER2 - 1; - else - hop_tier = hop->node_info->tier[i] - 1; - index = ((hop_tier * fab_pdata->nmasters) + - (info->node_info->masterp[j])); - /* If there is tier, calculate arb for commit */ - if (hop->node_info->tier) { - uint16_t tier; - unsigned long tieredbw = sel_cd->actarb[index]; - if (GET_TIER(sel_cd->arb[index])) - tier = MSM_BUS_BW_TIER1; - else if (master_tiers) - /* - * By default master is only in the - * tier specified by default. - * To change the default tier, client - * needs to explicitly request for a - * different supported tier */ - tier = master_tiers[0]; - else - tier = MSM_BUS_BW_TIER2; - - /* - * Make sure gateway to slave port bandwidth - * is not divided when slave is interleaved - */ - if (info->node_info->gateway - && hop->node_info->num_sports > 1) - tieredbw += add_bw; - else - tieredbw += INTERLEAVED_BW(fab_pdata, - add_bw, hop->node_info-> - num_sports); - - /* If bw is 0, update tier to default */ - if (!tieredbw) - tier = MSM_BUS_BW_TIER2; - /* Update Arb for fab,get HW Mport from enum */ - sel_cd->arb[index] = - msm_bus_create_bw_tier_pair_bytes(tier, - tieredbw); - sel_cd->actarb[index] = tieredbw; - MSM_BUS_DBG("tr:%d mpor:%d tbw:%ld bws: %lld\n", - hop_tier, info->node_info->masterp[i], - tieredbw, *hop->link_info.sel_bw); - } - } - } - - /* Update bwsum for slaves on fabric */ - ports = INTERLEAVED_VAL(fab_pdata, hop->node_info->num_sports); - for (i = 0; i < ports; i++) { - sel_cd->bwsum[hop->node_info->slavep[i]] - = (uint16_t)msm_bus_create_bw_tier_pair_bytes(0, - (uint32_t)msm_bus_div64(hop->node_info->num_sports, - *hop->link_info.sel_bw)); - MSM_BUS_DBG("slavep:%d, link_bw: %u\n", - hop->node_info->slavep[i], (uint32_t) - msm_bus_div64(hop->node_info->num_sports, - *hop->link_info.sel_bw)); - } -} - -#define RPM_SHIFT_VAL 16 -#define RPM_SHIFT(n) ((n) << RPM_SHIFT_VAL) -static int msm_bus_rpm_compare_cdata( - struct msm_bus_fabric_registration *fab_pdata, - struct commit_data *cd1, struct commit_data *cd2) -{ - size_t n; - int ret; - n = sizeof(uint16_t) * fab_pdata->nslaves; - ret = memcmp(cd1->bwsum, cd2->bwsum, n); - if (ret) { - MSM_BUS_DBG("Commit Data bwsum not equal\n"); - return ret; - } - - n = sizeof(uint16_t *) * ((fab_pdata->ntieredslaves * - fab_pdata->nmasters) + 1); - ret = memcmp(cd1->arb, cd2->arb, n); - if (ret) { - MSM_BUS_DBG("Commit Data arb[%d] not equal\n", n); - return ret; - } - - return 0; -} - -static int msm_bus_rpm_commit_arb(struct msm_bus_fabric_registration - *fab_pdata, int ctx, struct msm_rpm_iv_pair *rpm_data, - struct commit_data *cd, bool valid) -{ - int i, j, offset = 0, status = 0, count, index = 0; - /* - * count is the number of 2-byte words required to commit the - * data to rpm. This is calculated by the following formula. - * Commit data is split into two arrays: - * 1. arb[nmasters * ntieredslaves] - * 2. bwsum[nslaves] - */ - count = ((fab_pdata->nmasters * fab_pdata->ntieredslaves) - + (fab_pdata->nslaves) + 1)/2; - - offset = fab_pdata->offset; - - /* - * Copy bwsum to rpm data - * Since bwsum is uint16, the values need to be adjusted to - * be copied to value field of rpm-data, which is 32 bits. - */ - for (i = 0; i < (fab_pdata->nslaves - 1); i += 2) { - rpm_data[index].id = offset + index; - rpm_data[index].value = RPM_SHIFT(*(cd->bwsum + i + 1)) | - *(cd->bwsum + i); - index++; - } - /* Account for odd number of slaves */ - if (fab_pdata->nslaves & 1) { - rpm_data[index].id = offset + index; - rpm_data[index].value = *(cd->arb); - rpm_data[index].value = RPM_SHIFT(rpm_data[index].value) | - *(cd->bwsum + i); - index++; - i = 1; - } else - i = 0; - - /* Copy arb values to rpm data */ - for (; i < (fab_pdata->ntieredslaves * fab_pdata->nmasters); - i += 2) { - rpm_data[index].id = offset + index; - rpm_data[index].value = RPM_SHIFT(*(cd->arb + i + 1)) | - *(cd->arb + i); - index++; - } - - MSM_BUS_DBG("rpm data for fab: %d\n", fab_pdata->id); - for (i = 0; i < count; i++) - MSM_BUS_DBG("%d %x\n", rpm_data[i].id, rpm_data[i].value); - - MSM_BUS_DBG("Commit Data: Fab: %d BWSum:\n", fab_pdata->id); - for (i = 0; i < fab_pdata->nslaves; i++) - MSM_BUS_DBG("fab_slaves:0x%x\n", cd->bwsum[i]); - MSM_BUS_DBG("Commit Data: Fab: %d Arb:\n", fab_pdata->id); - for (i = 0; i < fab_pdata->ntieredslaves; i++) { - MSM_BUS_DBG("tiered-slave: %d\n", i); - for (j = 0; j < fab_pdata->nmasters; j++) - MSM_BUS_DBG(" 0x%x\n", - cd->arb[(i * fab_pdata->nmasters) + j]); - } - - MSM_BUS_DBG("calling msm_rpm_set: %d\n", status); - msm_bus_dbg_commit_data(fab_pdata->name, cd, fab_pdata-> - nmasters, fab_pdata->nslaves, fab_pdata->ntieredslaves, - MSM_BUS_DBG_OP); - if (fab_pdata->rpm_enabled) { - if (valid) { - if (ctx == ACTIVE_CTX) { - status = msm_rpm_set(MSM_RPM_CTX_SET_0, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_set returned: %d\n", - status); - } else if (ctx == DUAL_CTX) { - status = msm_rpm_set(MSM_RPM_CTX_SET_SLEEP, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_set returned: %d\n", - status); - } - } else { - if (ctx == ACTIVE_CTX) { - status = msm_rpm_clear(MSM_RPM_CTX_SET_0, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_clear returned: %d\n", - status); - } else if (ctx == DUAL_CTX) { - status = msm_rpm_clear(MSM_RPM_CTX_SET_SLEEP, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_clear returned: %d\n", - status); - } - } - } - - return status; -} - -#else - -#define NUM_TIERS 2 -#define RPM_SHIFT24(n) ((n) << 24) -#define RPM_SHIFT16(n) ((n) << 16) -#define RPM_SHIFT8(n) ((n) << 8) -struct commit_data { - uint16_t *bwsum; - uint8_t *arb[NUM_TIERS]; - unsigned long *actarb[NUM_TIERS]; -}; - -#define MODE_BIT(val) ((val) & 0x80) -#define MODE0_IMM(val) ((val) & 0xF) -#define MODE0_SHIFT(val) (((val) & 0x70) >> 4) -#define MODE1_STEP 48 /* 48 MB */ -#define MODE1_OFFSET 512 /* 512 MB */ -#define MODE1_IMM(val) ((val) & 0x7F) -#define __CLZ(x) ((8 * sizeof(uint32_t)) - 1 - __fls(x)) - -static uint8_t msm_bus_set_bw_bytes(unsigned long val) -{ - unsigned int shift; - unsigned int intVal; - unsigned char result; - - /* Convert to MB */ - intVal = (unsigned int)((val + ((1 << 20) - 1)) >> 20); - /** - * Divide by 2^20 and round up - * A value graeter than 0x1E0 will round up to 512 and overflow - * Mode 0 so it should be made Mode 1 - */ - if (0x1E0 > intVal) { - /** - * MODE 0 - * Compute the shift value - * Shift value is 32 - the number of leading zeroes - - * 4 to save the most significant 4 bits of the value - */ - shift = 32 - 4 - min((uint8_t)28, (uint8_t)__CLZ(intVal)); - - /* Add min value - 1 to force a round up when shifting right */ - intVal += (1 << shift) - 1; - - /* Recompute the shift value in case there was an overflow */ - shift = 32 - 4 - min((uint8_t)28, (uint8_t)__CLZ(intVal)); - - /* Clear the mode bit (msb) and fill in the fields */ - result = ((0x70 & (shift << 4)) | - (0x0F & (intVal >> shift))); - } else { - /* MODE 1 */ - result = (unsigned char)(0x80 | - ((intVal - MODE1_OFFSET + MODE1_STEP - 1) / - MODE1_STEP)); - } - - return result; -} - -uint64_t msm_bus_get_bw(unsigned long val) -{ - return MODE_BIT(val) ? - /* Mode 1 */ - (MODE1_IMM(val) * MODE1_STEP + MODE1_OFFSET) : - /* Mode 0 */ - (MODE0_IMM(val) << MODE0_SHIFT(val)); -} - -uint64_t msm_bus_get_bw_bytes(unsigned long val) -{ - return msm_bus_get_bw(val) << 20; -} - -static uint8_t msm_bus_create_bw_tier_pair_bytes(uint8_t type, - unsigned long bw) -{ - return msm_bus_set_bw_bytes(bw); -}; - -uint8_t msm_bus_create_bw_tier_pair(uint8_t type, unsigned long bw) -{ - return msm_bus_create_bw_tier_pair_bytes(type, bw); -}; - -static int msm_bus_rpm_allocate_commit_data(struct msm_bus_fabric_registration - *fab_pdata, void **cdata, int ctx) -{ - struct commit_data **cd = (struct commit_data **)cdata; - int i; - - *cd = kzalloc(sizeof(struct commit_data), GFP_KERNEL); - if (!*cd) { - MSM_BUS_DBG("Couldn't alloc mem for cdata\n"); - goto cdata_err; - } - - (*cd)->bwsum = kzalloc((sizeof(uint16_t) * fab_pdata->nslaves), - GFP_KERNEL); - if (!(*cd)->bwsum) { - MSM_BUS_DBG("Couldn't alloc mem for slaves\n"); - goto bwsum_err; - } - - for (i = 0; i < NUM_TIERS; i++) { - (*cd)->arb[i] = kzalloc(((sizeof(uint8_t *)) * - (fab_pdata->ntieredslaves * fab_pdata->nmasters) + 1), - GFP_KERNEL); - if (!(*cd)->arb[i]) { - MSM_BUS_DBG("Couldn't alloc memory for" - " slaves\n"); - goto arb_err; - } - - (*cd)->actarb[i] = kzalloc(((sizeof(unsigned long *)) * - (fab_pdata->ntieredslaves * fab_pdata->nmasters) + 1), - GFP_KERNEL); - if (!(*cd)->actarb[i]) { - MSM_BUS_DBG("Couldn't alloc memory for" - " slaves\n"); - kfree((*cd)->arb[i]); - goto arb_err; - } - } - - - return 0; - -arb_err: - for (i = i - 1; i >= 0; i--) { - kfree((*cd)->arb[i]); - kfree((*cd)->actarb[i]); - } -bwsum_err: - kfree((*cd)->bwsum); -cdata_err: - kfree(*cd); - return -ENOMEM; -} - -static void free_commit_data(void *cdata) -{ - int i; - struct commit_data *cd = (struct commit_data *)cdata; - kfree(cd->bwsum); - for (i = 0; i < NUM_TIERS; i++) { - kfree(cd->arb[i]); - kfree(cd->actarb[i]); - } - kfree(cd); -} - -static void *msm_bus_rpm_allocate_rpm_data(struct platform_device *pdev, - struct msm_bus_fabric_registration *fab_pdata) -{ - struct msm_rpm_iv_pair *rpm_data; - uint16_t count = (((fab_pdata->nmasters * fab_pdata->ntieredslaves * - NUM_TIERS)/2) + fab_pdata->nslaves + 1)/2; - - rpm_data = kmalloc((sizeof(struct msm_rpm_iv_pair) * count), - GFP_KERNEL); - return (void *)rpm_data; -} - -static int msm_bus_rpm_compare_cdata( - struct msm_bus_fabric_registration *fab_pdata, - struct commit_data *cd1, struct commit_data *cd2) -{ - size_t n; - int i, ret; - n = sizeof(uint16_t) * fab_pdata->nslaves; - ret = memcmp(cd1->bwsum, cd2->bwsum, n); - if (ret) { - MSM_BUS_DBG("Commit Data bwsum not equal\n"); - return ret; - } - - n = sizeof(uint8_t *) * ((fab_pdata->ntieredslaves * - fab_pdata->nmasters) + 1); - for (i = 0; i < NUM_TIERS; i++) { - ret = memcmp(cd1->arb[i], cd2->arb[i], n); - if (ret) { - MSM_BUS_DBG("Commit Data arb[%d] not equal\n", i); - return ret; - } - } - - return 0; -} - -static int msm_bus_rpm_commit_arb(struct msm_bus_fabric_registration - *fab_pdata, int ctx, struct msm_rpm_iv_pair *rpm_data, - struct commit_data *cd, bool valid) -{ - int i, j, k, offset = 0, status = 0, count, index = 0; - /* - * count is the number of 2-byte words required to commit the - * data to rpm. This is calculated by the following formula. - * Commit data is split into two arrays: - * 1. arb[nmasters * ntieredslaves][num_tiers] - * 2. bwsum[nslaves] - */ - count = (((fab_pdata->nmasters * fab_pdata->ntieredslaves * NUM_TIERS) - /2) + fab_pdata->nslaves + 1)/2; - - offset = fab_pdata->offset; - - /* - * Copy bwsum to rpm data - * Since bwsum is uint16, the values need to be adjusted to - * be copied to value field of rpm-data, which is 32 bits. - */ - for (i = 0; i < (fab_pdata->nslaves - 1); i += 2) { - rpm_data[index].id = offset + index; - rpm_data[index].value = RPM_SHIFT16(*(cd->bwsum + i + 1)) | - *(cd->bwsum + i); - index++; - } - /* Account for odd number of slaves */ - if (fab_pdata->nslaves & 1) { - rpm_data[index].id = offset + index; - rpm_data[index].value = RPM_SHIFT8(*cd->arb[1]) | - *(cd->arb[0]); - rpm_data[index].value = RPM_SHIFT16(rpm_data[index].value) | - *(cd->bwsum + i); - index++; - i = 1; - } else - i = 0; - - /* Copy arb values to rpm data */ - for (; i < (fab_pdata->ntieredslaves * fab_pdata->nmasters); - i += 2) { - uint16_t tv1, tv0; - rpm_data[index].id = offset + index; - tv0 = RPM_SHIFT8(*(cd->arb[1] + i)) | (*(cd->arb[0] + i)); - tv1 = RPM_SHIFT8(*(cd->arb[1] + i + 1)) | (*(cd->arb[0] + i - + 1)); - rpm_data[index].value = RPM_SHIFT16(tv1) | tv0; - index++; - } - - MSM_BUS_DBG("rpm data for fab: %d\n", fab_pdata->id); - for (i = 0; i < count; i++) - MSM_BUS_DBG("%d %x\n", rpm_data[i].id, rpm_data[i].value); - - MSM_BUS_DBG("Commit Data: Fab: %d BWSum:\n", fab_pdata->id); - for (i = 0; i < fab_pdata->nslaves; i++) - MSM_BUS_DBG("fab_slaves:0x%x\n", cd->bwsum[i]); - MSM_BUS_DBG("Commit Data: Fab: %d Arb:\n", fab_pdata->id); - for (k = 0; k < NUM_TIERS; k++) { - MSM_BUS_DBG("Tier: %d\n", k); - for (i = 0; i < fab_pdata->ntieredslaves; i++) { - MSM_BUS_DBG("tiered-slave: %d\n", i); - for (j = 0; j < fab_pdata->nmasters; j++) - MSM_BUS_DBG(" 0x%x\n", - cd->arb[k][(i * fab_pdata->nmasters) - + j]); - } - } - - MSM_BUS_DBG("calling msm_rpm_set: %d\n", status); - msm_bus_dbg_commit_data(fab_pdata->name, (void *)cd, fab_pdata-> - nmasters, fab_pdata->nslaves, fab_pdata->ntieredslaves, - MSM_BUS_DBG_OP); - if (fab_pdata->rpm_enabled) { - if (valid) { - if (ctx == ACTIVE_CTX) { - status = msm_rpm_set(MSM_RPM_CTX_SET_0, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_set returned: %d\n", - status); - } else if (ctx == DUAL_CTX) { - status = msm_rpm_set(MSM_RPM_CTX_SET_SLEEP, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_set returned: %d\n", - status); - } - } else { - if (ctx == ACTIVE_CTX) { - status = msm_rpm_clear(MSM_RPM_CTX_SET_0, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_clear returned: %d\n", - status); - } else if (ctx == DUAL_CTX) { - status = msm_rpm_clear(MSM_RPM_CTX_SET_SLEEP, - rpm_data, count); - MSM_BUS_DBG("msm_rpm_clear returned: %d\n", - status); - } - } - } - - return status; -} - -#define FORMAT_BW(x) \ - ((x < 0) ? \ - -(msm_bus_get_bw_bytes(msm_bus_create_bw_tier_pair_bytes(0, -(x)))) : \ - (msm_bus_get_bw_bytes(msm_bus_create_bw_tier_pair_bytes(0, x)))) - -static uint16_t msm_bus_pack_bwsum_bytes(unsigned long bw) -{ - return (bw + ((1 << 20) - 1)) >> 20; -}; - -static void msm_bus_rpm_update_bw(struct msm_bus_inode_info *hop, - struct msm_bus_inode_info *info, - struct msm_bus_fabric_registration *fab_pdata, - void *sel_cdata, int *master_tiers, - int64_t add_bw) -{ - int index, i, j, tiers, ports; - struct commit_data *sel_cd = (struct commit_data *)sel_cdata; - - add_bw = INTERLEAVED_BW(fab_pdata, add_bw, info->node_info->num_mports); - ports = INTERLEAVED_VAL(fab_pdata, info->node_info->num_mports); - tiers = INTERLEAVED_VAL(fab_pdata, hop->node_info->num_tiers); - for (i = 0; i < tiers; i++) { - for (j = 0; j < ports; j++) { - uint16_t hop_tier; - /* - * For interleaved gateway ports and slave ports, - * there is one-one mapping between gateway port and - * the slave port - */ - if (info->node_info->gateway && i != j - && hop->node_info->num_sports > 1) - continue; - - if (!hop->node_info->tier) - hop_tier = MSM_BUS_BW_TIER2 - 1; - else - hop_tier = hop->node_info->tier[i] - 1; - index = ((hop_tier * fab_pdata->nmasters) + - (info->node_info->masterp[j])); - /* If there is tier, calculate arb for commit */ - if (hop->node_info->tier) { - uint16_t tier; - unsigned long tieredbw; - if (master_tiers) - tier = master_tiers[0] - 1; - else - tier = MSM_BUS_BW_TIER2 - 1; - - tieredbw = sel_cd->actarb[tier][index]; - /* - * Make sure gateway to slave port bandwidth - * is not divided when slave is interleaved - */ - if (info->node_info->gateway - && hop->node_info->num_sports > 1) - tieredbw += add_bw; - else - tieredbw += INTERLEAVED_BW(fab_pdata, - add_bw, hop->node_info-> - num_sports); - - /* Update Arb for fab,get HW Mport from enum */ - sel_cd->arb[tier][index] = - msm_bus_create_bw_tier_pair_bytes(0, tieredbw); - sel_cd->actarb[tier][index] = tieredbw; - MSM_BUS_DBG("tr:%d mpor:%d tbw:%lu bws: %lld\n", - hop_tier, info->node_info->masterp[i], tieredbw, - *hop->link_info.sel_bw); - } - } - } - - /* Update bwsum for slaves on fabric */ - - ports = INTERLEAVED_VAL(fab_pdata, hop->node_info->num_sports); - for (i = 0; i < ports; i++) { - sel_cd->bwsum[hop->node_info->slavep[i]] - = msm_bus_pack_bwsum_bytes((uint32_t) - msm_bus_div64(hop->node_info->num_sports, - *hop->link_info.sel_bw)); - MSM_BUS_DBG("slavep:%d, link_bw: %lld\n", - hop->node_info->slavep[i], - msm_bus_div64(hop->node_info->num_sports, - *hop->link_info.sel_bw)); - } -} - - -void msm_bus_rpm_fill_cdata_buffer(int *curr, char *buf, const int max_size, - void *cdata, int nmasters, int nslaves, int ntslaves) -{ - int j, k, c; - struct commit_data *cd = (struct commit_data *)cdata; - - *curr += scnprintf(buf + *curr, max_size - *curr, "BWSum:\n"); - for (c = 0; c < nslaves; c++) - *curr += scnprintf(buf + *curr, max_size - *curr, - "0x%x\t", cd->bwsum[c]); - *curr += scnprintf(buf + *curr, max_size - *curr, "\nArb:"); - for (k = 0; k < NUM_TIERS; k++) { - *curr += scnprintf(buf + *curr, max_size - *curr, - "\nTier %d:\n", k); - for (c = 0; c < ntslaves; c++) { - *curr += scnprintf(buf + *curr, max_size - *curr, - "TSlave %d:\n", c); - for (j = 0; j < nmasters; j++) - *curr += scnprintf(buf + *curr, max_size - - *curr, " 0x%x\t", - cd->arb[k][(c * nmasters) + j]); - } - } -} -#endif - -/** -* msm_bus_rpm_commit() - Commit the arbitration data to RPM -* @fabric: Fabric for which the data should be committed -**/ -static int msm_bus_rpm_commit(struct msm_bus_fabric_registration - *fab_pdata, void *hw_data, void **cdata) -{ - - int ret; - bool valid; - struct commit_data *dual_cd, *act_cd; - struct msm_rpm_iv_pair *rpm_data = (struct msm_rpm_iv_pair *)hw_data; - dual_cd = (struct commit_data *)cdata[DUAL_CTX]; - act_cd = (struct commit_data *)cdata[ACTIVE_CTX]; - - /* - * If the arb data for active set and sleep set is - * different, commit both sets. - * If the arb data for active set and sleep set is - * the same, invalidate the sleep set. - */ - ret = msm_bus_rpm_compare_cdata(fab_pdata, act_cd, dual_cd); - if (!ret) - /* Invalidate sleep set.*/ - valid = false; - else - valid = true; - - ret = msm_bus_rpm_commit_arb(fab_pdata, DUAL_CTX, rpm_data, - dual_cd, valid); - if (ret) - MSM_BUS_ERR("Error comiting fabric:%d in %d ctx\n", - fab_pdata->id, DUAL_CTX); - - valid = true; - ret = msm_bus_rpm_commit_arb(fab_pdata, ACTIVE_CTX, rpm_data, act_cd, - valid); - if (ret) - MSM_BUS_ERR("Error comiting fabric:%d in %d ctx\n", - fab_pdata->id, ACTIVE_CTX); - - return ret; -} - -static int msm_bus_rpm_port_halt(uint32_t haltid, uint8_t mport) -{ - int status = 0; - struct msm_bus_halt_vector hvector = {0, 0}; - struct msm_rpm_iv_pair rpm_data[2]; - - MSM_BUS_MASTER_HALT(hvector.haltmask, hvector.haltval, mport); - rpm_data[0].id = haltid; - rpm_data[0].value = hvector.haltval; - rpm_data[1].id = haltid + 1; - rpm_data[1].value = hvector.haltmask; - - MSM_BUS_DBG("ctx: %d, id: %d, value: %d\n", - MSM_RPM_CTX_SET_0, rpm_data[0].id, rpm_data[0].value); - MSM_BUS_DBG("ctx: %d, id: %d, value: %d\n", - MSM_RPM_CTX_SET_0, rpm_data[1].id, rpm_data[1].value); - - status = msm_rpm_set(MSM_RPM_CTX_SET_0, rpm_data, 2); - if (status) - MSM_BUS_DBG("msm_rpm_set returned: %d\n", status); - return status; -} - -static int msm_bus_rpm_port_unhalt(uint32_t haltid, uint8_t mport) -{ - int status = 0; - struct msm_bus_halt_vector hvector = {0, 0}; - struct msm_rpm_iv_pair rpm_data[2]; - - MSM_BUS_MASTER_UNHALT(hvector.haltmask, hvector.haltval, - mport); - rpm_data[0].id = haltid; - rpm_data[0].value = hvector.haltval; - rpm_data[1].id = haltid + 1; - rpm_data[1].value = hvector.haltmask; - - MSM_BUS_DBG("unalt: ctx: %d, id: %d, value: %d\n", - MSM_RPM_CTX_SET_SLEEP, rpm_data[0].id, rpm_data[0].value); - MSM_BUS_DBG("unhalt: ctx: %d, id: %d, value: %d\n", - MSM_RPM_CTX_SET_SLEEP, rpm_data[1].id, rpm_data[1].value); - - status = msm_rpm_set(MSM_RPM_CTX_SET_0, rpm_data, 2); - if (status) - MSM_BUS_DBG("msm_rpm_set returned: %d\n", status); - return status; -} - -int msm_bus_remote_hw_commit(struct msm_bus_fabric_registration - *fab_pdata, void *hw_data, void **cdata) -{ - return 0; -} - -int msm_bus_rpm_hw_init(struct msm_bus_fabric_registration *pdata, - struct msm_bus_hw_algorithm *hw_algo) -{ - pdata->il_flag = msm_bus_rpm_is_mem_interleaved(); - hw_algo->allocate_commit_data = msm_bus_rpm_allocate_commit_data; - hw_algo->allocate_hw_data = msm_bus_rpm_allocate_rpm_data; - hw_algo->node_init = NULL; - hw_algo->free_commit_data = free_commit_data; - hw_algo->update_bw = msm_bus_rpm_update_bw; - hw_algo->commit = msm_bus_rpm_commit; - hw_algo->port_halt = msm_bus_rpm_port_halt; - hw_algo->port_unhalt = msm_bus_rpm_port_unhalt; - if (!pdata->ahb) - pdata->rpm_enabled = 1; - return 0; -} diff --git a/arch/arm/mach-msm/msm_cpr-debug.c b/arch/arm/mach-msm/msm_cpr-debug.c deleted file mode 100644 index 3564bbeeb2e81fcb9030e60b13b6242a1740d817..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_cpr-debug.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2012, 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. - * - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include - -struct msm_cpr_debug_device { - struct mutex debug_mutex; - struct dentry *dir; - int addr_offset; - void __iomem *base; -}; - -static inline -void write_reg(struct msm_cpr_debug_device *cpr, u32 value) -{ - writel_relaxed(value, cpr->base + cpr->addr_offset); -} - -static inline u32 read_reg(struct msm_cpr_debug_device *cpr) -{ - return readl_relaxed(cpr->base + cpr->addr_offset); -} - -static bool msm_cpr_debug_addr_is_valid(int addr) -{ - if (addr < 0 || addr > 0x15C) { - pr_err("CPR register address is invalid: %d\n", addr); - return false; - } - return true; -} - -static int msm_cpr_debug_data_set(void *data, u64 val) -{ - struct msm_cpr_debug_device *debugdev = data; - uint32_t reg = val; - - mutex_lock(&debugdev->debug_mutex); - - if (msm_cpr_debug_addr_is_valid(debugdev->addr_offset)) - write_reg(debugdev, reg); - - mutex_unlock(&debugdev->debug_mutex); - return 0; -} - -static int msm_cpr_debug_data_get(void *data, u64 *val) -{ - struct msm_cpr_debug_device *debugdev = data; - uint32_t reg; - - mutex_lock(&debugdev->debug_mutex); - - if (msm_cpr_debug_addr_is_valid(debugdev->addr_offset)) { - reg = read_reg(debugdev); - *val = reg; - } - mutex_unlock(&debugdev->debug_mutex); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debug_data_fops, msm_cpr_debug_data_get, - msm_cpr_debug_data_set, "0x%02llX\n"); - -static int msm_cpr_debug_addr_set(void *data, u64 val) -{ - struct msm_cpr_debug_device *debugdev = data; - - if (msm_cpr_debug_addr_is_valid(val)) { - mutex_lock(&debugdev->debug_mutex); - debugdev->addr_offset = val; - mutex_unlock(&debugdev->debug_mutex); - } - - return 0; -} - -static int msm_cpr_debug_addr_get(void *data, u64 *val) -{ - struct msm_cpr_debug_device *debugdev = data; - - mutex_lock(&debugdev->debug_mutex); - - if (msm_cpr_debug_addr_is_valid(debugdev->addr_offset)) - *val = debugdev->addr_offset; - - mutex_unlock(&debugdev->debug_mutex); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debug_addr_fops, msm_cpr_debug_addr_get, - msm_cpr_debug_addr_set, "0x%03llX\n"); - -int msm_cpr_debug_init(void *data) -{ - char *name = "cpr-debug"; - struct msm_cpr_debug_device *debugdev; - struct dentry *dir; - struct dentry *temp; - int rc; - - debugdev = kzalloc(sizeof(struct msm_cpr_debug_device), GFP_KERNEL); - if (debugdev == NULL) { - pr_err("kzalloc failed\n"); - return -ENOMEM; - } - - dir = debugfs_create_dir(name, NULL); - if (dir == NULL || IS_ERR(dir)) { - pr_err("debugfs_create_dir failed: rc=%ld\n", PTR_ERR(dir)); - rc = PTR_ERR(dir); - goto dir_error; - } - - temp = debugfs_create_file("address", S_IRUGO | S_IWUSR, dir, debugdev, - &debug_addr_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("debugfs_create_file failed: rc=%ld\n", PTR_ERR(temp)); - rc = PTR_ERR(temp); - goto file_error; - } - - temp = debugfs_create_file("data", S_IRUGO | S_IWUSR, dir, debugdev, - &debug_data_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("debugfs_create_file failed: rc=%ld\n", PTR_ERR(temp)); - rc = PTR_ERR(temp); - goto file_error; - } - debugdev->base = data; - debugdev->addr_offset = -1; - debugdev->dir = dir; - mutex_init(&debugdev->debug_mutex); - - return 0; - -file_error: - debugfs_remove_recursive(dir); -dir_error: - kfree(debugdev); - - return rc; -} diff --git a/arch/arm/mach-msm/msm_cpr.c b/arch/arm/mach-msm/msm_cpr.c deleted file mode 100644 index 3f0617522fa15b4e72896373af869bc7717f0e78..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_cpr.c +++ /dev/null @@ -1,1084 +0,0 @@ -/* Copyright (c) 2012, 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. - * - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "msm_cpr.h" - -#define MODULE_NAME "msm-cpr" - -/** - * Convert the Delay time to Timer Count Register - * e.g if frequency is 19200 kHz and delay required is - * 20000us, so timer count will be 19200 * 20000 / 1000 - */ -#define TIMER_COUNT(freq, delay) ((freq * delay) / 1000) -#define ALL_CPR_IRQ 0x3F -#define STEP_QUOT_MAX 25 -#define STEP_QUOT_MIN 12 - -/* Need platform device handle for suspend and resume APIs */ -static struct platform_device *cpr_pdev; - -static bool enable = 1; -static bool disable_cpr; -module_param(enable, bool, 0644); -MODULE_PARM_DESC(enable, "CPR Enable"); - -static int msm_cpr_debug_mask; -module_param_named( - debug_mask, msm_cpr_debug_mask, int, S_IRUGO | S_IWUSR -); - -enum { - /* configuration log */ - MSM_CPR_DEBUG_CONFIG = BIT(0), - /* step up/down interrupt log */ - MSM_CPR_DEBUG_STEPS = BIT(1), - /* cpu frequency notification log */ - MSM_CPR_DEBUG_FREQ_TRANS = BIT(2), -};\ - -#define msm_cpr_debug(mask, message, ...) \ - do { \ - if ((mask) & msm_cpr_debug_mask) \ - pr_info(message, ##__VA_ARGS__); \ - } while (0) - -struct msm_cpr { - int curr_osc; - int cpr_mode; - int prev_mode; - uint32_t floor; - uint32_t ceiling; - bool max_volt_set; - void __iomem *base; - unsigned int irq; - uint32_t cur_Vmin; - uint32_t cur_Vmax; - uint32_t prev_volt_uV; - struct mutex cpr_mutex; - spinlock_t cpr_lock; - struct regulator *vreg_cx; - const struct msm_cpr_config *config; - struct notifier_block freq_transition; - uint32_t step_size; -}; - -/* Need to maintain state data for suspend and resume APIs */ -static struct msm_cpr_reg cpr_save_state; - -static inline -void cpr_write_reg(struct msm_cpr *cpr, u32 offset, u32 value) -{ - writel_relaxed(value, cpr->base + offset); -} - -static inline u32 cpr_read_reg(struct msm_cpr *cpr, u32 offset) -{ - return readl_relaxed(cpr->base + offset); -} - -static -void cpr_modify_reg(struct msm_cpr *cpr, u32 offset, u32 mask, u32 value) -{ - u32 reg_val; - - reg_val = readl_relaxed(cpr->base + offset); - reg_val &= ~mask; - reg_val |= value; - writel_relaxed(reg_val, cpr->base + offset); -} - -#ifdef DEBUG -static void cpr_regs_dump_all(struct msm_cpr *cpr) -{ - pr_debug("RBCPR_GCNT_TARGET(%d): 0x%x\n", - cpr->curr_osc, readl_relaxed(cpr->base + - RBCPR_GCNT_TARGET(cpr->curr_osc))); - pr_debug("RBCPR_TIMER_INTERVAL: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_TIMER_INTERVAL)); - pr_debug("RBIF_TIMER_ADJUST: 0x%x\n", - readl_relaxed(cpr->base + RBIF_TIMER_ADJUST)); - pr_debug("RBIF_LIMIT: 0x%x\n", - readl_relaxed(cpr->base + RBIF_LIMIT)); - pr_debug("RBCPR_STEP_QUOT: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_STEP_QUOT)); - pr_debug("RBIF_SW_VLEVEL: 0x%x\n", - readl_relaxed(cpr->base + RBIF_SW_VLEVEL)); - pr_debug("RBCPR_DEBUG1: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_DEBUG1)); - pr_debug("RBCPR_RESULT_0: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_RESULT_0)); - pr_debug("RBCPR_RESULT_1: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_RESULT_1)); - pr_debug("RBCPR_QUOT_AVG: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_QUOT_AVG)); - pr_debug("RBCPR_CTL: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_CTL)); - pr_debug("RBIF_IRQ_EN(0): 0x%x\n", - cpr_read_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line))); - pr_debug("RBIF_IRQ_STATUS: 0x%x\n", - cpr_read_reg(cpr, RBIF_IRQ_STATUS)); -} -#endif - -/* Enable the CPR H/W Block */ -static void cpr_enable(struct msm_cpr *cpr) -{ - spin_lock(&cpr->cpr_lock); - cpr_modify_reg(cpr, RBCPR_CTL, LOOP_EN_M, ENABLE_CPR); - spin_unlock(&cpr->cpr_lock); -} - -/* Disable the CPR H/W Block */ -static void cpr_disable(struct msm_cpr *cpr) -{ - spin_lock(&cpr->cpr_lock); - cpr_modify_reg(cpr, RBCPR_CTL, LOOP_EN_M, DISABLE_CPR); - spin_unlock(&cpr->cpr_lock); -} - -static int32_t cpr_poll_result(struct msm_cpr *cpr) -{ - uint32_t val = 0; - int8_t rc = 0; - - rc = readl_poll_timeout(cpr->base + RBCPR_RESULT_0, val, ~val & BUSY_M, - 10, 1000); - if (rc) - pr_err("RBCPR_RESULT_0 read error: %d\n", rc); - return rc; -} - -static int32_t cpr_poll_result_done(struct msm_cpr *cpr) -{ - uint32_t val = 0; - int8_t rc = 0; - - rc = readl_poll_timeout(cpr->base + RBIF_IRQ_STATUS, val, val & 0x1, - 10, 1000); - if (rc) - pr_err("RBCPR_IRQ_STATUS read error: %d\n", rc); - return rc; -} - -static void -cpr_2pt_kv_analysis(struct msm_cpr *cpr, struct msm_cpr_mode *chip_data) -{ - int32_t level_uV = 0, rc; - uint32_t quot1, quot2; - - /** - * 2 Point KV Analysis to calculate Step Quot - * STEP_QUOT is number of QUOT units per PMIC step - * STEP_QUOT = (quot1 - quot2) / 4 - * - * The step quot is calculated once for every mode and stored for - * later use. - */ - if (chip_data->step_quot != ~0) - goto out_2pt_kv; - - /** - * Using the value from chip_data->tgt_volt_offset - * calculate the new PMIC adjusted voltages and set - * the PMIC to provide this value. - * - * Assuming default voltage is the highest value of safe boot up - * voltage, offset is always subtracted from it. - * - */ - level_uV = chip_data->turbo_Vmax - - (chip_data->tgt_volt_offset * cpr->step_size); - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "tgt_volt_uV = %d\n", level_uV); - - /* Call the PMIC specific routine to set the voltage */ - rc = regulator_set_voltage(cpr->vreg_cx, level_uV, level_uV); - if (rc) { - pr_err("Initial voltage set at %duV failed\n", level_uV); - return; - } - - rc = regulator_enable(cpr->vreg_cx); - if (rc) { - pr_err("failed to enable %s, rc=%d\n", "vdd_cx", rc); - return; - } - - /* First CPR measurement at a higher voltage to get QUOT1 */ - - /* Enable the Software mode of operation */ - cpr_modify_reg(cpr, RBCPR_CTL, HW_TO_PMIC_EN_M, SW_MODE); - - /* Enable the cpr measurement */ - cpr_modify_reg(cpr, RBCPR_CTL, LOOP_EN_M, ENABLE_CPR); - - /* IRQ is already disabled */ - rc = cpr_poll_result_done(cpr); - if (rc) { - pr_err("Quot1: Exiting due to INT_DONE poll timeout\n"); - return; - } - - rc = cpr_poll_result(cpr); - if (rc) { - pr_err("Quot1: Exiting due to BUSY poll timeout\n"); - return; - } - - quot1 = (cpr_read_reg(cpr, RBCPR_DEBUG1) & QUOT_SLOW_M) >> 12; - - /* Take second CPR measurement at a lower voltage to get QUOT2 */ - level_uV -= 4 * cpr->step_size; - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "tgt_volt_uV = %d\n", level_uV); - - cpr_modify_reg(cpr, RBCPR_CTL, LOOP_EN_M, DISABLE_CPR); - /* Call the PMIC specific routine to set the voltage */ - rc = regulator_set_voltage(cpr->vreg_cx, level_uV, level_uV); - if (rc) { - pr_err("Voltage set at %duV failed\n", level_uV); - return; - } - - cpr_modify_reg(cpr, RBCPR_CTL, HW_TO_PMIC_EN_M, SW_MODE); - cpr_modify_reg(cpr, RBCPR_CTL, LOOP_EN_M, ENABLE_CPR); - - /* cpr_write_reg(cpr, RBIF_CONT_NACK_CMD, 0x1); */ - rc = cpr_poll_result_done(cpr); - if (rc) { - pr_err("Quot2: Exiting due to INT_DONE poll timeout\n"); - goto err_poll_result_done; - } - /* IRQ is already disabled */ - rc = cpr_poll_result(cpr); - if (rc) { - pr_err("Quot2: Exiting due to BUSY poll timeout\n"); - goto err_poll_result; - } - quot2 = (cpr_read_reg(cpr, RBCPR_DEBUG1) & QUOT_SLOW_M) >> 12; - /* - * Based on chip characterization data, it is good to add some - * margin on top of calculated step quot to help reduce the - * number of CPR interrupts. The present value suggested is 3. - * Further, if the step quot is outside range, clamp it to the - * maximum permitted value. - */ - chip_data->step_quot = ((quot1 - quot2) / 4) + 3; - if (chip_data->step_quot < STEP_QUOT_MIN || - chip_data->step_quot > STEP_QUOT_MAX) - chip_data->step_quot = STEP_QUOT_MAX; - - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "Step Quot is %d\n", chip_data->step_quot); - /* Disable the cpr */ - cpr_modify_reg(cpr, RBCPR_CTL, LOOP_EN_M, DISABLE_CPR); - -out_2pt_kv: - /* Program the step quot */ - cpr_write_reg(cpr, RBCPR_STEP_QUOT, (chip_data->step_quot & 0xFF)); - return; -err_poll_result: -err_poll_result_done: - regulator_disable(cpr->vreg_cx); -} - -static inline -void cpr_irq_clr_and_ack(struct msm_cpr *cpr, uint32_t mask) -{ - /* Clear the interrupt */ - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - /* Acknowledge the Recommendation */ - cpr_write_reg(cpr, RBIF_CONT_ACK_CMD, 0x1); -} - -static inline -void cpr_irq_clr_and_nack(struct msm_cpr *cpr, uint32_t mask) -{ - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - cpr_write_reg(cpr, RBIF_CONT_NACK_CMD, 0x1); -} - -static void cpr_irq_set(struct msm_cpr *cpr, uint32_t irq, bool enable_irq) -{ - uint32_t irq_enabled; - - irq_enabled = cpr_read_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line)); - if (enable_irq == 1) - irq_enabled |= irq; - else - irq_enabled &= ~irq; - cpr_modify_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line), - INT_MASK, irq_enabled); -} - -static void -cpr_up_event_handler(struct msm_cpr *cpr, uint32_t new_volt) -{ - int set_volt_uV, rc; - struct msm_cpr_mode *chip_data; - - chip_data = &cpr->config->cpr_mode_data[cpr->cpr_mode]; - - /* Set New PMIC voltage */ - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "current Vmin=%d Vmax=%d\n", cpr->cur_Vmin, cpr->cur_Vmax); - set_volt_uV = (new_volt < cpr->cur_Vmax ? new_volt - : cpr->cur_Vmax); - - if (cpr->prev_volt_uV == set_volt_uV) - rc = regulator_sync_voltage(cpr->vreg_cx); - else - rc = regulator_set_voltage(cpr->vreg_cx, set_volt_uV, - set_volt_uV); - if (rc) { - pr_err("Unable to set_voltage = %d, rc(%d)\n", set_volt_uV, rc); - cpr_irq_clr_and_nack(cpr, BIT(4) | BIT(0)); - return; - } - - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "(railway_voltage: %d uV)\n", set_volt_uV); - cpr->prev_volt_uV = set_volt_uV; - - cpr->max_volt_set = (set_volt_uV == cpr->cur_Vmax) ? 1 : 0; - - /* Clear all the interrupts */ - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - - /* Disable Auto ACK for Down interrupts */ - cpr_modify_reg(cpr, RBCPR_CTL, SW_AUTO_CONT_NACK_DN_EN_M, 0); - - /* Enable down interrupts to App as it might have got disabled if CPR - * hit Vmin earlier. Voltage set is above Vmin now. - */ - cpr_irq_set(cpr, DOWN_INT, 1); - - /* Acknowledge the Recommendation */ - cpr_write_reg(cpr, RBIF_CONT_ACK_CMD, 0x1); -} - -static void -cpr_dn_event_handler(struct msm_cpr *cpr, uint32_t new_volt) -{ - int set_volt_uV, rc; - struct msm_cpr_mode *chip_data; - - chip_data = &cpr->config->cpr_mode_data[cpr->cpr_mode]; - - /* Set New PMIC volt */ - set_volt_uV = (new_volt > cpr->cur_Vmin ? new_volt - : cpr->cur_Vmin); - - if (cpr->prev_volt_uV == set_volt_uV) - rc = regulator_sync_voltage(cpr->vreg_cx); - else - rc = regulator_set_voltage(cpr->vreg_cx, set_volt_uV, - set_volt_uV); - if (rc) { - pr_err("Unable to set_voltage = %d, rc(%d)\n", set_volt_uV, rc); - cpr_irq_clr_and_nack(cpr, BIT(2) | BIT(0)); - return; - } - - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "(railway_voltage: %d uV)\n", set_volt_uV); - cpr->prev_volt_uV = set_volt_uV; - - cpr->max_volt_set = 0; - - /* Clear all the interrupts */ - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - - if (new_volt <= cpr->cur_Vmin) { - /* - * Disable down interrupt to App after we hit Vmin - * It shall be enabled after we service an up interrupt - * - * A race condition between freq switch handler and CPR - * interrupt handler is possible. So, do not disable - * interrupt if a freq switch already caused a mode - * change since we need this interrupt in the new mode. - */ - if (cpr->cpr_mode == cpr->prev_mode) { - /* Enable Auto ACK for CPR Down Flags - * while DOWN_INT to App is disabled */ - cpr_modify_reg(cpr, RBCPR_CTL, - SW_AUTO_CONT_NACK_DN_EN_M, - SW_AUTO_CONT_NACK_DN_EN); - cpr_irq_set(cpr, DOWN_INT, 0); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "DOWN_INT disabled\n"); - } - } - /* Acknowledge the Recommendation */ - cpr_write_reg(cpr, RBIF_CONT_ACK_CMD, 0x1); -} - -static void cpr_set_vdd(struct msm_cpr *cpr, enum cpr_action action) -{ - uint32_t curr_volt, new_volt, error_step; - struct msm_cpr_mode *chip_data; - - chip_data = &cpr->config->cpr_mode_data[cpr->cpr_mode]; - error_step = cpr_read_reg(cpr, RBCPR_RESULT_0) >> 2; - - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "RBCPR_RESULT_0 17:6=%d\n", (cpr_read_reg(cpr, - RBCPR_RESULT_0) >> 6) & 0xFFF); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "RBCPR_RESULT_0 Busy_b19=%d\n", (cpr_read_reg(cpr, - RBCPR_RESULT_0) >> 19) & 0x1); - - error_step &= 0xF; - curr_volt = regulator_get_voltage(cpr->vreg_cx); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "Current voltage=%d\n", curr_volt); - - if (action == UP) { - /* Clear IRQ, ACK and return if Vdd already at Vmax */ - if (cpr->max_volt_set == 1) { - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - cpr_write_reg(cpr, RBIF_CONT_NACK_CMD, 0x1); - return; - } - - /** - * Using up margin in the comparison helps avoid having to - * change up threshold values in chip register. - */ - if (error_step < (cpr->config->up_threshold + - cpr->config->up_margin)) { - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "UP_INT error step too small to set\n"); - cpr_irq_clr_and_nack(cpr, BIT(4) | BIT(0)); - return; - } - - /** - * As per chip characterization recommendation, add a step - * to up error steps to increase system stability - */ - error_step += 1; - - /* Calculte new PMIC voltage */ - new_volt = curr_volt + (error_step * cpr->step_size); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "UP_INT: new_volt: %d, error_step=%d\n", - new_volt, error_step); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "Current RBCPR_GCNT_TARGET(%d): = 0x%x\n", - cpr->curr_osc, readl_relaxed(cpr->base + - RBCPR_GCNT_TARGET(cpr->curr_osc)) & TARGET_M); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "(UP Voltage recommended by CPR: %d uV)\n", new_volt); - cpr_up_event_handler(cpr, new_volt); - - } else if (action == DOWN) { - /** - * Using down margin in the comparison helps avoid having to - * change down threshold values in chip register. - */ - if (error_step < (cpr->config->dn_threshold + - cpr->config->dn_margin)) { - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "DOWN_INT error_step=%d is too small to set\n", - error_step); - cpr_irq_clr_and_nack(cpr, BIT(2) | BIT(0)); - return; - } - - /** - * As per chip characterization recommendation, deduct 2 steps - * from down error steps to decrease chances of getting closer - * to the system level Vmin, thereby improving stability - */ - error_step -= 2; - - /* Keep down step upto two per interrupt to avoid any spike */ - if (error_step > 2) - error_step = 2; - - /* Calculte new PMIC voltage */ - new_volt = curr_volt - (error_step * cpr->step_size); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "DOWN_INT: new_volt: %d, error_step=%d\n", - new_volt, error_step); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "Current RBCPR_GCNT_TARGET(%d): = 0x%x\n", - cpr->curr_osc, readl_relaxed(cpr->base + - RBCPR_GCNT_TARGET(cpr->curr_osc)) & TARGET_M); - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "(DN Voltage recommended by CPR: %d uV)\n", new_volt); - cpr_dn_event_handler(cpr, new_volt); - } -} - -static irqreturn_t cpr_irq0_handler(int irq, void *dev_id) -{ - struct msm_cpr *cpr = dev_id; - uint32_t reg_val, ctl_reg; - - reg_val = cpr_read_reg(cpr, RBIF_IRQ_STATUS); - ctl_reg = cpr_read_reg(cpr, RBCPR_CTL); - - /* Following sequence of handling is as per each IRQ's priority */ - if (reg_val & BIT(4)) { - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "CPR:IRQ %d occured for UP Flag\n", irq); - cpr_set_vdd(cpr, UP); - - } else if ((reg_val & BIT(2)) && !(ctl_reg & SW_AUTO_CONT_NACK_DN_EN)) { - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "CPR:IRQ %d occured for Down Flag\n", irq); - cpr_set_vdd(cpr, DOWN); - - } else if (reg_val & BIT(1)) { - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "CPR:IRQ %d occured for Min Flag\n", irq); - cpr_irq_clr_and_nack(cpr, BIT(1) | BIT(0)); - - } else if (reg_val & BIT(5)) { - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "CPR:IRQ %d occured for MAX Flag\n", irq); - cpr_irq_clr_and_nack(cpr, BIT(5) | BIT(0)); - - } else if (reg_val & BIT(3)) { - /* SW_AUTO_CONT_ACK_EN is enabled */ - msm_cpr_debug(MSM_CPR_DEBUG_STEPS, - "CPR:IRQ %d occured for Mid Flag\n", irq); - } - return IRQ_HANDLED; -} - -static void cpr_config(struct msm_cpr *cpr) -{ - uint32_t delay_count, cnt = 0, rc; - struct msm_cpr_mode *chip_data; - - chip_data = &cpr->config->cpr_mode_data[cpr->cpr_mode]; - - /* Program the SW vlevel */ - cpr_modify_reg(cpr, RBIF_SW_VLEVEL, SW_VLEVEL_M, - cpr->config->sw_vlevel); - - /* Set the floor and ceiling values */ - cpr->floor = cpr->config->floor; - cpr->ceiling = cpr->config->ceiling; - - /* Program the Ceiling & Floor values */ - cpr_modify_reg(cpr, RBIF_LIMIT, (CEILING_M | FLOOR_M), - ((cpr->ceiling << 6) | cpr->floor)); - - /* Program the Up and Down Threshold values */ - cpr_modify_reg(cpr, RBCPR_CTL, UP_THRESHOLD_M | DN_THRESHOLD_M, - cpr->config->up_threshold << 24 | - cpr->config->dn_threshold << 28); - - cpr->curr_osc = chip_data->ring_osc; - chip_data->ring_osc_data[cpr->curr_osc].quot = - cpr->config->max_quot; - - /** - * Program the gate count and target values - * for all the ring oscilators - */ - while (cnt < NUM_OSC) { - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "Prog:cnt(%d) gcnt=0x%x quot=0x%x\n", cnt, - chip_data->ring_osc_data[cnt].gcnt, - chip_data->ring_osc_data[cnt].quot); - cpr_modify_reg(cpr, RBCPR_GCNT_TARGET(cnt), - (GCNT_M | TARGET_M), - (chip_data->ring_osc_data[cnt].gcnt << 12 | - chip_data->ring_osc_data[cnt].quot)); - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "RBCPR_GCNT_TARGET(%d): = 0x%x\n", cnt, - readl_relaxed(cpr->base + RBCPR_GCNT_TARGET(cnt))); - cnt++; - } - - /* Configure the step quot */ - cpr_2pt_kv_analysis(cpr, chip_data); - - /* Call the PMIC specific routine to set the voltage */ - rc = regulator_set_voltage(cpr->vreg_cx, chip_data->calibrated_uV, - chip_data->calibrated_uV); - if (rc) - pr_err("Voltage set failed %d\n", rc); - - /* - * Program the Timer Register for delay between CPR measurements - * This is required to allow the device sufficient time for idle - * power collapse. - */ - delay_count = TIMER_COUNT(cpr->config->ref_clk_khz, - cpr->config->delay_us); - cpr_write_reg(cpr, RBCPR_TIMER_INTERVAL, delay_count); - - /* Use Consecutive Down to avoid any interrupt due to spike */ - cpr_write_reg(cpr, RBIF_TIMER_ADJUST, (0x2 << RBIF_CONS_DN_SHIFT)); - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, "RBIF_TIMER_ADJUST: 0x%x\n", - readl_relaxed(cpr->base + RBIF_TIMER_ADJUST)); - - /* Enable the Timer */ - cpr_modify_reg(cpr, RBCPR_CTL, TIMER_M, ENABLE_TIMER); - - /* Enable Auto ACK for Mid interrupts */ - cpr_modify_reg(cpr, RBCPR_CTL, SW_AUTO_CONT_ACK_EN_M, - SW_AUTO_CONT_ACK_EN); -} - -static int -cpr_freq_transition(struct notifier_block *nb, unsigned long val, - void *data) -{ - struct msm_cpr *cpr = container_of(nb, struct msm_cpr, freq_transition); - struct cpufreq_freqs *freqs = data; - uint32_t quot, new_freq, ctl_reg; - - switch (val) { - case CPUFREQ_PRECHANGE: - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "pre freq change notification to cpr\n"); - /* Disable Measurement to stop generation of CPR IRQs */ - cpr_disable(cpr); - /* Disable routing of IRQ to App */ - cpr_irq_set(cpr, INT_MASK & ~MID_INT, 0); - disable_irq(cpr->irq); - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "RBCPR_CTL: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_CTL)); - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "RBIF_IRQ_STATUS: 0x%x\n", - cpr_read_reg(cpr, RBIF_IRQ_STATUS)); - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "RBIF_IRQ_EN(0): 0x%x\n", - cpr_read_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line))); - - cpr->prev_mode = cpr->cpr_mode; - break; - - case CPUFREQ_POSTCHANGE: - pr_debug("post freq change notification to cpr\n"); - ctl_reg = cpr_read_reg(cpr, RBCPR_CTL); - /** - * As per chip characterization data, use max nominal freq - * to calculate quot for all lower frequencies too - */ - if (freqs->new > cpr->config->max_nom_freq) { - new_freq = freqs->new; - cpr->cur_Vmin = cpr->config->cpr_mode_data[1].turbo_Vmin; - cpr->cur_Vmax = cpr->config->cpr_mode_data[1].turbo_Vmax; - } else { - new_freq = cpr->config->max_nom_freq; - cpr->cur_Vmin = cpr->config->cpr_mode_data[1].nom_Vmin; - cpr->cur_Vmax = cpr->config->cpr_mode_data[1].nom_Vmax; - } - - /* Configure CPR for the new frequency */ - quot = cpr->config->get_quot(cpr->config->max_quot, - cpr->config->max_freq / 1000, - new_freq / 1000); - cpr_modify_reg(cpr, RBCPR_GCNT_TARGET(cpr->curr_osc), TARGET_M, - quot); - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "RBCPR_GCNT_TARGET(%d): = 0x%x\n", cpr->curr_osc, - readl_relaxed(cpr->base + - RBCPR_GCNT_TARGET(cpr->curr_osc))); - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "new_freq: %d, quot_freq: %d, quot: %d\n", - freqs->new, new_freq, quot); - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "PVS Voltage setting is: %d\n", - regulator_get_voltage(cpr->vreg_cx)); - - enable_irq(cpr->irq); - /** - * Enable all interrupts. One of them could be in a disabled - * state if vdd had hit Vmax / Vmin earlier - */ - cpr_irq_set(cpr, INT_MASK & ~MID_INT, 1); - - /** - * Clear the auto NACK down bit if enabled in the freq. - * transition phase. - */ - if (ctl_reg & SW_AUTO_CONT_NACK_DN_EN) - cpr_modify_reg(cpr, RBCPR_CTL, - SW_AUTO_CONT_NACK_DN_EN_M, 0); - if (cpr->max_volt_set) - cpr->max_volt_set = 0; - - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "RBIF_IRQ_EN(0): 0x%x\n", - cpr_read_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line))); - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "RBCPR_CTL: 0x%x\n", - readl_relaxed(cpr->base + RBCPR_CTL)); - msm_cpr_debug(MSM_CPR_DEBUG_FREQ_TRANS, - "RBIF_IRQ_STATUS: 0x%x\n", - cpr_read_reg(cpr, RBIF_IRQ_STATUS)); - - /* Clear all the interrupts */ - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - - cpr_enable(cpr); - break; - default: - break; - } - return NOTIFY_OK; -} - -#ifdef CONFIG_PM -static int msm_cpr_resume(struct device *dev) -{ - struct msm_cpr *cpr = dev_get_drvdata(dev); - int osc_num = cpr->config->cpr_mode_data->ring_osc; - - cpr->config->clk_enable(); - - cpr_write_reg(cpr, RBCPR_TIMER_INTERVAL, - cpr_save_state.rbif_timer_interval); - cpr_write_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line), - cpr_save_state.rbif_int_en); - cpr_write_reg(cpr, RBIF_LIMIT, - cpr_save_state.rbif_limit); - cpr_write_reg(cpr, RBIF_TIMER_ADJUST, - cpr_save_state.rbif_timer_adjust); - cpr_write_reg(cpr, RBCPR_GCNT_TARGET(osc_num), - cpr_save_state.rbcpr_gcnt_target); - cpr_write_reg(cpr, RBCPR_STEP_QUOT, - cpr_save_state.rbcpr_step_quot); - cpr_write_reg(cpr, RBIF_SW_VLEVEL, - cpr_save_state.rbif_sw_level); - cpr_write_reg(cpr, RBCPR_CTL, - cpr_save_state.rbcpr_ctl); - - /* Clear all the interrupts */ - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - - enable_irq(cpr->irq); - cpr_enable(cpr); - - return 0; -} - -static int msm_cpr_suspend(struct device *dev) - -{ - struct msm_cpr *cpr = dev_get_drvdata(dev); - int osc_num = cpr->config->cpr_mode_data->ring_osc; - - /* Disable CPR measurement before IRQ to avoid pending interrupts */ - cpr_disable(cpr); - disable_irq(cpr->irq); - - /* Clear all the interrupts */ - cpr_write_reg(cpr, RBIF_IRQ_CLEAR, ALL_CPR_IRQ); - - cpr_save_state.rbif_timer_interval = - cpr_read_reg(cpr, RBCPR_TIMER_INTERVAL); - cpr_save_state.rbif_int_en = - cpr_read_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line)); - cpr_save_state.rbif_limit = - cpr_read_reg(cpr, RBIF_LIMIT); - cpr_save_state.rbif_timer_adjust = - cpr_read_reg(cpr, RBIF_TIMER_ADJUST); - cpr_save_state.rbcpr_gcnt_target = - cpr_read_reg(cpr, RBCPR_GCNT_TARGET(osc_num)); - cpr_save_state.rbcpr_step_quot = - cpr_read_reg(cpr, RBCPR_STEP_QUOT); - cpr_save_state.rbif_sw_level = - cpr_read_reg(cpr, RBIF_SW_VLEVEL); - cpr_save_state.rbcpr_ctl = - cpr_read_reg(cpr, RBCPR_CTL); - - return 0; -} - -void msm_cpr_pm_resume(void) -{ - if (!enable || disable_cpr) - return; - - msm_cpr_resume(&cpr_pdev->dev); -} -EXPORT_SYMBOL(msm_cpr_pm_resume); - -void msm_cpr_pm_suspend(void) -{ - if (!enable || disable_cpr) - return; - - msm_cpr_suspend(&cpr_pdev->dev); -} -EXPORT_SYMBOL(msm_cpr_pm_suspend); -#endif - -void msm_cpr_disable(void) -{ - struct msm_cpr *cpr; - - if (!enable || disable_cpr) - return; - - cpr = platform_get_drvdata(cpr_pdev); - - cpr_disable(cpr); -} -EXPORT_SYMBOL(msm_cpr_disable); - -void msm_cpr_enable(void) -{ - struct msm_cpr *cpr; - - if (!enable || disable_cpr) - return; - - cpr = platform_get_drvdata(cpr_pdev); - - cpr_enable(cpr); -} -EXPORT_SYMBOL(msm_cpr_enable); - -static int msm_cpr_probe(struct platform_device *pdev) -{ - int res, irqn, irq_enabled; - struct msm_cpr *cpr; - const struct msm_cpr_config *pdata = pdev->dev.platform_data; - void __iomem *base; - struct resource *mem; - struct msm_cpr_mode *chip_data; - - if (!enable) - return -EPERM; - - if (!pdata) { - pr_err("CPR: Platform data is not available\n"); - enable = false; - return -EIO; - } - - if (pdata->disable_cpr == true) { - pr_err("CPR disabled by modem\n"); - disable_cpr = true; - return -EPERM; - } - - cpr = devm_kzalloc(&pdev->dev, sizeof(struct msm_cpr), GFP_KERNEL); - if (!cpr) { - enable = false; - return -ENOMEM; - } - - /* enable clk for cpr */ - if (!pdata->clk_enable) { - pr_err("CPR: Invalid clk_enable hook\n"); - return -EFAULT; - } - - pdata->clk_enable(); - - /* Initialize platform_data */ - cpr->config = pdata; - - /* Set initial Vmin,Vmax equal to turbo */ - cpr->cur_Vmin = cpr->config->cpr_mode_data[1].turbo_Vmin; - cpr->cur_Vmax = cpr->config->cpr_mode_data[1].turbo_Vmax; - - cpr_pdev = pdev; - - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem || !mem->start) { - pr_err("CPR: get resource failed\n"); - res = -ENXIO; - goto out; - } - - base = ioremap_nocache(mem->start, resource_size(mem)); - if (!base) { - pr_err("CPR: ioremap failed\n"); - res = -ENOMEM; - goto out; - } - - if (cpr->config->irq_line < 0) { - pr_err("CPR: Invalid IRQ line specified\n"); - res = -ENXIO; - goto err_ioremap; - } - irqn = platform_get_irq(pdev, cpr->config->irq_line); - if (irqn < 0) { - pr_err("CPR: Unable to get irq\n"); - res = -ENXIO; - goto err_ioremap; - } - - cpr->irq = irqn; - - cpr->base = base; - - cpr->step_size = pdata->step_size; - - spin_lock_init(&cpr->cpr_lock); - - /* Initialize the Voltage domain for CPR */ - cpr->vreg_cx = regulator_get(&pdev->dev, "vddx_cx"); - if (IS_ERR(cpr->vreg_cx)) { - res = PTR_ERR(cpr->vreg_cx); - pr_err("could not get regulator: %d\n", res); - goto err_reg_get; - } - - /* Assume current mode is TURBO Mode */ - cpr->cpr_mode = TURBO_MODE; - cpr->prev_mode = TURBO_MODE; - - /* Initial configuration of CPR */ - cpr_config(cpr); - - platform_set_drvdata(pdev, cpr); - - chip_data = &cpr->config->cpr_mode_data[cpr->cpr_mode]; - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "CPR Platform Data (upside_steps: %d) (downside_steps: %d))", - cpr->config->up_threshold, cpr->config->dn_threshold); - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "(nominal_voltage: %duV) (turbo_voltage: %duV)\n", - cpr->config->cpr_mode_data[NORMAL_MODE].calibrated_uV, - cpr->config->cpr_mode_data[TURBO_MODE].calibrated_uV); - msm_cpr_debug(MSM_CPR_DEBUG_CONFIG, - "(Current corner: TURBO) (gcnt_target: %d) (quot: %d)\n", - chip_data->ring_osc_data[chip_data->ring_osc].gcnt, - chip_data->ring_osc_data[chip_data->ring_osc].quot); - - /* Initialze the Debugfs Entry for cpr */ - res = msm_cpr_debug_init(cpr->base); - if (res) { - pr_err("CPR: Debugfs Creation Failed\n"); - goto err_ioremap; - } - - /* Register the interrupt handler for IRQ 0 */ - res = request_threaded_irq(irqn, NULL, cpr_irq0_handler, - IQRF_ONESHOT | IRQF_TRIGGER_RISING, "msm-cpr-irq0", - cpr); - if (res) { - pr_err("CPR: request irq failed for IRQ %d\n", irqn); - goto err_ioremap; - } - - /** - * Enable the requested interrupt lines. - * Do not enable MID_INT since we shall use - * SW_AUTO_CONT_ACK_EN bit. - */ - irq_enabled = INT_MASK & ~MID_INT; - cpr_modify_reg(cpr, RBIF_IRQ_EN(cpr->config->irq_line), - INT_MASK, irq_enabled); - - /* Enable the cpr */ - cpr_modify_reg(cpr, RBCPR_CTL, LOOP_EN_M, ENABLE_CPR); - - cpr->freq_transition.notifier_call = cpr_freq_transition; - cpufreq_register_notifier(&cpr->freq_transition, - CPUFREQ_TRANSITION_NOTIFIER); - - pr_info("MSM CPR driver successfully registered!\n"); - - return res; - -err_reg_get: - free_irq(irqn, cpr); -err_ioremap: - iounmap(base); -out: - enable = false; - return res; -} - -static int msm_cpr_remove(struct platform_device *pdev) -{ - struct msm_cpr *cpr = platform_get_drvdata(pdev); - - cpufreq_unregister_notifier(&cpr->freq_transition, - CPUFREQ_TRANSITION_NOTIFIER); - - regulator_disable(cpr->vreg_cx); - regulator_put(cpr->vreg_cx); - free_irq(cpr->irq, cpr); - iounmap(cpr->base); - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static const struct dev_pm_ops msm_cpr_dev_pm_ops = { - .suspend = msm_cpr_suspend, - .resume = msm_cpr_resume, -}; - -static struct platform_driver msm_cpr_driver = { - .probe = msm_cpr_probe, - .remove = msm_cpr_remove, - .driver = { - .name = MODULE_NAME, - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &msm_cpr_dev_pm_ops, -#endif - }, -}; - -static int __init msm_init_cpr(void) -{ - return platform_driver_register(&msm_cpr_driver); -} - -module_init(msm_init_cpr); - -static void __exit msm_exit_cpr(void) -{ - platform_driver_unregister(&msm_cpr_driver); -} - -module_exit(msm_exit_cpr); - -MODULE_DESCRIPTION("MSM CPR Driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/msm_cpr.h b/arch/arm/mach-msm/msm_cpr.h deleted file mode 100644 index e9416c309a59bad7a79b33532f7bd8a9bfc44002..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_cpr.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2012, 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 __ARCH_ARM_MACH_MSM_CPR_H -#define __ARCH_ARM_MACH_MSM_CPR_H - -/* Register Offsets for RBCPR */ - -/* RBCPR Gate Count and Target Registers */ -#define RBCPR_GCNT_TARGET(n) (0x60 + 4 * n) - -/* RBCPR Timer Control */ -#define RBCPR_TIMER_INTERVAL 0x44 -#define RBIF_TIMER_ADJUST 0x4C - -/* RBCPR Config Register */ -#define RBIF_LIMIT 0x48 -#define RBCPR_STEP_QUOT 0X80 -#define RBCPR_CTL 0x90 -#define RBIF_SW_VLEVEL 0x94 -#define RBIF_CONT_ACK_CMD 0x98 -#define RBIF_CONT_NACK_CMD 0x9C - -/* RBCPR Result status Register */ -#define RBCPR_RESULT_0 0xA0 -#define RBCPR_RESULT_1 0xA4 -#define RBCPR_QUOT_AVG 0x118 - -/* RBCPR DEBUG Register */ -#define RBCPR_DEBUG1 0x120 - -/* RBCPR Interrupt Control Register */ -#define RBIF_IRQ_EN(n) (0x100 + 4 * n) -#define RBIF_IRQ_CLEAR 0x110 -#define RBIF_IRQ_STATUS 0x114 - -/* Bit Mask Values */ -#define GCNT_M 0x003FF000 -#define TARGET_M 0x00000FFF -#define SW_VLEVEL_M 0x0000003F -#define UP_FLAG_M 0x00000010 -#define DOWN_FLAG_M 0x00000004 -#define CEILING_M 0x00000FC0 -#define FLOOR_M 0x0000003F -#define LOOP_EN_M 0x00000001 -#define TIMER_M 0x00000008 -#define SW_AUTO_CONT_ACK_EN_M 0x00000020 -#define SW_AUTO_CONT_NACK_DN_EN_M 0x00000040 -#define HW_TO_PMIC_EN_M BIT(4) -#define BUSY_M BIT(19) -#define QUOT_SLOW_M 0x00FFF000 -#define UP_THRESHOLD_M 0x0F000000 -#define DN_THRESHOLD_M 0xF0000000 - -/* Bit Values */ -#define ENABLE_CPR BIT(0) -#define DISABLE_CPR 0x0 -#define ENABLE_TIMER BIT(3) -#define DISABLE_TIMER 0x0 -#define SW_MODE 0x0 -#define SW_AUTO_CONT_ACK_EN BIT(5) -#define SW_AUTO_CONT_NACK_DN_EN BIT(6) - -/* Shift Values */ -#define RBIF_CONS_DN_SHIFT (0x4) - -/* Test values for RBCPR RUMI Testing */ -#define GNT_CNT 0xC0 -#define TARGET 0xEFF - -#define CEILING_V 0x30 -#define FLOOR_V 0x15 - -#define SW_LEVEL 0x20 - -/* Interrupt Mask for All interrupt flags */ -#define INT_MASK (MIN_INT | DOWN_INT | MID_INT | UP_INT | MAX_INT) - -/* Number of oscilator in each sensor */ -#define NUM_OSC 8 - -#define CPR_MODE 2 - -/** - * enum cpr_mode - Modes in which cpr is used - */ -enum cpr_mode { - NORMAL_MODE = 0, - TURBO_MODE, - SVS_MODE, -}; - -/** - * enum cpr_action - Cpr actions to be taken - */ -enum cpr_action { - DOWN = 0, - UP, -}; - -/** - * enum cpr_interrupt - */ -enum cpr_interrupt { - DONE_INT = BIT(0), - MIN_INT = BIT(1), - DOWN_INT = BIT(2), - MID_INT = BIT(3), - UP_INT = BIT(4), - MAX_INT = BIT(5), -}; - -/** - * struct msm_cpr_osc - Data for CPR ring oscillator - * @gcnt: gate count value for the oscillator - * @quot: target value for ring oscillator - */ -struct msm_cpr_osc { - int gcnt; - uint32_t quot; -}; - -/** - * struct msm_cpr_mode - Data for CPR modes of operation - * @msm_cpr_osc: structure for oscillator data - * @ring_osc: ring oscillator of the sensor - * @tgt_volt_offset: inital voltage offset from default value - * @step_quot: step Quot for CPR calcuation - */ -struct msm_cpr_mode { - struct msm_cpr_osc ring_osc_data[NUM_OSC]; - int ring_osc; - int32_t tgt_volt_offset; - uint32_t step_quot; - uint32_t turbo_Vmax; - uint32_t turbo_Vmin; - uint32_t nom_Vmax; - uint32_t nom_Vmin; - uint32_t calibrated_uV; -}; - -/** - * struct msm_cpr_config - Platform data for CPR configuration - * @ref_clk_khz: clock value of CPR in KHz - * @delay_us: timer delay in micro second - * @irq_line: irq line to be use (0 or 1 or 2) - * @msm_cpr_mode: structure for CPR mode data - */ -struct msm_cpr_config { - unsigned long ref_clk_khz; - unsigned long delay_us; - int irq_line; - struct msm_cpr_mode *cpr_mode_data; - int min_down_step; - uint32_t tgt_count_div_N; /* Target Cnt(Nom) = Target Cnt(Turbo) / N */ - uint32_t floor; - uint32_t ceiling; - uint32_t sw_vlevel; - uint32_t up_threshold; - uint32_t dn_threshold; - uint32_t up_margin; - uint32_t dn_margin; - uint32_t max_nom_freq; - uint32_t max_freq; - uint32_t max_quot; - bool disable_cpr; - uint32_t step_size; - uint32_t (*get_quot)(uint32_t max_quot, uint32_t max_freq, - uint32_t new_freq); - void (*clk_enable)(void); -}; - -/** -* struct msm_cpr_config - CPR Registers -*/ -struct msm_cpr_reg { - uint32_t rbif_timer_interval; - uint32_t rbif_int_en; - uint32_t rbif_limit; - uint32_t rbif_timer_adjust; - uint32_t rbcpr_gcnt_target; - uint32_t rbcpr_step_quot; - uint32_t rbif_sw_level; - uint32_t rbcpr_ctl; -}; - -#if defined(CONFIG_MSM_CPR) || defined(CONFIG_MSM_CPR_MODULE) -/* msm_cpr_pm_resume: Used by Power Manager for Idle Power Collapse */ -void msm_cpr_pm_resume(void); -/* msm_cpr_pm_suspend: Used by Power Manager for Idle Power Collapse */ -void msm_cpr_pm_suspend(void); -/* msm_cpr_enable: Used by Power Manager for GDFS */ -void msm_cpr_enable(void); -/* msm_cpr_disable: Used by Power Manager for GDFS */ -void msm_cpr_disable(void); -#else -/* msm_cpr_pm_resume: Used by Power Manager for Idle Power Collapse */ -void msm_cpr_pm_resume(void) { } -/* msm_cpr_pm_suspend: Used by Power Manager for Idle Power Collapse */ -void msm_cpr_pm_suspend(void) { } -/* msm_cpr_enable: Used by Power Manager for GDFS */ -void msm_cpr_enable(void) { } -/* msm_cpr_disable: Used by Power Manager for GDFS */ -void msm_cpr_disable(void) { } -#endif - -#ifdef CONFIG_DEBUG_FS -int msm_cpr_debug_init(void *); -#else -static inline int msm_cpr_debug_init(void *) { return 0; } -#endif -#endif /* __ARCH_ARM_MACH_MSM_CPR_H */ diff --git a/arch/arm/mach-msm/msm_dcvs.c b/arch/arm/mach-msm/msm_dcvs.c deleted file mode 100644 index 600d636a6c699c8b858cb6db33ef91a9876e878b..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_dcvs.c +++ /dev/null @@ -1,1363 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CORE_HANDLE_OFFSET (0xA0) -#define __err(f, ...) pr_err("MSM_DCVS: %s: " f, __func__, __VA_ARGS__) -#define __info(f, ...) pr_info("MSM_DCVS: %s: " f, __func__, __VA_ARGS__) -#define MAX_PENDING (5) - -#define CORE_FLAG_TEMP_UPDATE 0x1 - -struct core_attribs { - struct kobj_attribute freq_change_us; - - struct kobj_attribute disable_pc_threshold; - struct kobj_attribute em_win_size_min_us; - struct kobj_attribute em_win_size_max_us; - struct kobj_attribute em_max_util_pct; - struct kobj_attribute group_id; - struct kobj_attribute max_freq_chg_time_us; - struct kobj_attribute slack_mode_dynamic; - struct kobj_attribute slack_time_min_us; - struct kobj_attribute slack_time_max_us; - struct kobj_attribute slack_weight_thresh_pct; - struct kobj_attribute ss_no_corr_below_freq; - struct kobj_attribute ss_win_size_min_us; - struct kobj_attribute ss_win_size_max_us; - struct kobj_attribute ss_util_pct; - - struct kobj_attribute active_coeff_a; - struct kobj_attribute active_coeff_b; - struct kobj_attribute active_coeff_c; - struct kobj_attribute leakage_coeff_a; - struct kobj_attribute leakage_coeff_b; - struct kobj_attribute leakage_coeff_c; - struct kobj_attribute leakage_coeff_d; - - struct kobj_attribute thermal_poll_ms; - - struct kobj_attribute freq_tbl; - struct kobj_attribute offset_tbl; - - struct attribute_group attrib_group; -}; - -enum pending_freq_state { - /* - * used by the thread to check if pending_freq was updated while it was - * setting previous frequency - this is written to and used by the - * freq updating thread - */ - NO_OUTSTANDING_FREQ_CHANGE = 0, - - /* - * This request is set to indicate that the governor is stopped and no - * more frequency change requests are accepted untill it starts again. - * This is checked/used by the threads that want to change the freq - */ - STOP_FREQ_CHANGE = -1, - - /* - * Any other +ve value means that a freq change was requested and the - * thread has not gotten around to update it - * - * Any other -ve value means that this is the last freq change i.e. a - * freq change was requested but the thread has not run yet and - * meanwhile the governor was stopped. - */ -}; - -struct dcvs_core { - spinlock_t idle_state_change_lock; - /* 0 when not idle (busy) 1 when idle and -1 when governor starts and - * we dont know whether the next call is going to be idle enter or exit - */ - int idle_entered; - - enum msm_dcvs_core_type type; - /* this is the number in each type for example cpu 0,1,2 and gpu 0,1 */ - int type_core_num; - char core_name[CORE_NAME_MAX]; - uint32_t actual_freq; - uint32_t freq_change_us; - - uint32_t max_time_us; /* core param */ - - struct msm_dcvs_algo_param algo_param; - struct msm_dcvs_energy_curve_coeffs coeffs; - - /* private */ - ktime_t time_start; - struct task_struct *task; - struct core_attribs attrib; - uint32_t dcvs_core_id; - struct msm_dcvs_core_info *info; - int sensor; - wait_queue_head_t wait_q; - - int (*set_frequency)(int type_core_num, unsigned int freq); - unsigned int (*get_frequency)(int type_core_num); - int (*idle_enable)(int type_core_num, - enum msm_core_control_event event); - int (*set_floor_frequency)(int type_core_num, unsigned int freq); - - spinlock_t pending_freq_lock; - int pending_freq; - - struct hrtimer slack_timer; - struct delayed_work temperature_work; - int flags; -}; - -static int msm_dcvs_enabled = 1; -module_param_named(enable, msm_dcvs_enabled, int, S_IRUGO | S_IWUSR | S_IWGRP); - -static struct dentry *debugfs_base; - -static struct dcvs_core core_list[CORES_MAX]; - -static struct kobject *cores_kobj; - -#define DCVS_MAX_NUM_FREQS 15 -static struct msm_dcvs_freq_entry cpu_freq_tbl[DCVS_MAX_NUM_FREQS]; -static unsigned num_cpu_freqs; -static struct msm_dcvs_platform_data *dcvs_pdata; - -static DEFINE_MUTEX(param_update_mutex); -static DEFINE_MUTEX(gpu_floor_mutex); - -static void force_stop_slack_timer(struct dcvs_core *core) -{ - unsigned long flags; - - spin_lock_irqsave(&core->idle_state_change_lock, flags); - hrtimer_cancel(&core->slack_timer); - spin_unlock_irqrestore(&core->idle_state_change_lock, flags); -} - -static void force_start_slack_timer(struct dcvs_core *core, int slack_us) -{ - unsigned long flags; - int ret; - - spin_lock_irqsave(&core->idle_state_change_lock, flags); - - /* - * only start the timer if governor is not stopped - */ - if (slack_us != 0) { - ret = hrtimer_start(&core->slack_timer, - ktime_set(0, slack_us * 1000), - HRTIMER_MODE_REL_PINNED); - if (ret) { - pr_err("%s Failed to start timer ret = %d\n", - core->core_name, ret); - } - } - - spin_unlock_irqrestore(&core->idle_state_change_lock, flags); -} - -static void stop_slack_timer(struct dcvs_core *core) -{ - unsigned long flags; - - spin_lock_irqsave(&core->idle_state_change_lock, flags); - /* err only for cpu type's GPU's can do idle exit consecutively */ - if (core->idle_entered == 1 && !(core->dcvs_core_id >= GPU_OFFSET)) - __err("%s trying to reenter idle", core->core_name); - core->idle_entered = 1; - hrtimer_cancel(&core->slack_timer); - core->idle_entered = 1; - spin_unlock_irqrestore(&core->idle_state_change_lock, flags); -} - -static void start_slack_timer(struct dcvs_core *core, int slack_us) -{ - unsigned long flags1, flags2; - int ret; - - spin_lock_irqsave(&core->idle_state_change_lock, flags2); - - spin_lock_irqsave(&core->pending_freq_lock, flags1); - - /* err only for cpu type's GPU's can do idle enter consecutively */ - if (core->idle_entered == 0 && !(core->dcvs_core_id >= GPU_OFFSET)) - __err("%s trying to reexit idle", core->core_name); - core->idle_entered = 0; - /* - * only start the timer if governor is not stopped - */ - if (slack_us != 0 - && !(core->pending_freq < NO_OUTSTANDING_FREQ_CHANGE)) { - ret = hrtimer_start(&core->slack_timer, - ktime_set(0, slack_us * 1000), - HRTIMER_MODE_REL_PINNED); - if (ret) { - pr_err("%s Failed to start timer ret = %d\n", - core->core_name, ret); - } - } - spin_unlock_irqrestore(&core->pending_freq_lock, flags1); - - spin_unlock_irqrestore(&core->idle_state_change_lock, flags2); -} - -static void restart_slack_timer(struct dcvs_core *core, int slack_us) -{ - unsigned long flags1, flags2; - int ret; - - spin_lock_irqsave(&core->idle_state_change_lock, flags2); - - hrtimer_cancel(&core->slack_timer); - - spin_lock_irqsave(&core->pending_freq_lock, flags1); - - /* - * only start the timer if idle is not entered - * and governor is not stopped - */ - if (slack_us != 0 && (core->idle_entered != 1) - && !(core->pending_freq < NO_OUTSTANDING_FREQ_CHANGE)) { - ret = hrtimer_start(&core->slack_timer, - ktime_set(0, slack_us * 1000), - HRTIMER_MODE_REL_PINNED); - if (ret) { - pr_err("%s Failed to start timer ret = %d\n", - core->core_name, ret); - } - } - spin_unlock_irqrestore(&core->pending_freq_lock, flags1); - spin_unlock_irqrestore(&core->idle_state_change_lock, flags2); -} - -void msm_dcvs_apply_gpu_floor(unsigned long cpu_freq) -{ - static unsigned long curr_cpu0_freq; - unsigned long gpu_floor_freq = 0; - struct dcvs_core *gpu; - int i; - - if (!dcvs_pdata) - return; - - mutex_lock(&gpu_floor_mutex); - - if (cpu_freq) - curr_cpu0_freq = cpu_freq; - - for (i = 0; i < dcvs_pdata->num_sync_rules; i++) - if (curr_cpu0_freq > dcvs_pdata->sync_rules[i].cpu_khz) { - gpu_floor_freq = - dcvs_pdata->sync_rules[i].gpu_floor_khz; - break; - } - - if (num_online_cpus() > 1) - gpu_floor_freq = max(gpu_floor_freq, - dcvs_pdata->gpu_max_nom_khz); - - if (!gpu_floor_freq) { - mutex_unlock(&gpu_floor_mutex); - return; - } - - for (i = GPU_OFFSET; i < CORES_MAX; i++) { - gpu = &core_list[i]; - if (gpu->dcvs_core_id == -1) - continue; - - if (gpu->pending_freq != STOP_FREQ_CHANGE && - gpu->set_floor_frequency) { - gpu->set_floor_frequency(gpu->type_core_num, - gpu_floor_freq); - /* TZ will know about a freq change (if any) - * at next idle exit. */ - gpu->actual_freq = - gpu->get_frequency(gpu->type_core_num); - } - } - - mutex_unlock(&gpu_floor_mutex); -} - -static void check_power_collapse_modes(struct dcvs_core *core) -{ - struct msm_dcvs_algo_param *params; - - params = &core_list[CPU_OFFSET + num_online_cpus() - 1].algo_param; - - if (core->actual_freq >= params->disable_pc_threshold) - core->idle_enable(core->type_core_num, - MSM_DCVS_DISABLE_HIGH_LATENCY_MODES); - else - core->idle_enable(core->type_core_num, - MSM_DCVS_ENABLE_HIGH_LATENCY_MODES); -} - -static int __msm_dcvs_change_freq(struct dcvs_core *core) -{ - int ret = 0; - unsigned long flags = 0; - int requested_freq = 0; - ktime_t time_start; - uint32_t slack_us = 0; - uint32_t ret1 = 0; - - spin_lock_irqsave(&core->pending_freq_lock, flags); - if (core->pending_freq == STOP_FREQ_CHANGE) - goto out; -repeat: - BUG_ON(!core->pending_freq); - - requested_freq = core->pending_freq; - time_start = core->time_start; - core->time_start = ns_to_ktime(0); - - core->pending_freq = NO_OUTSTANDING_FREQ_CHANGE; - - if (requested_freq == core->actual_freq) - goto out; - - spin_unlock_irqrestore(&core->pending_freq_lock, flags); - - if (core->type == MSM_DCVS_CORE_TYPE_CPU && - core->type_core_num == 0) - msm_dcvs_apply_gpu_floor(requested_freq); - - /** - * Call the frequency sink driver to change the frequency - * We will need to get back the actual frequency in KHz and - * the record the time taken to change it. - */ - ret = core->set_frequency(core->type_core_num, requested_freq); - if (ret <= 0) - __err("Core %s failed to set freq %u\n", - core->core_name, requested_freq); - /* continue to call TZ to get updated slack timer */ - else - core->actual_freq = ret; - - core->freq_change_us = (uint32_t)ktime_to_us( - ktime_sub(ktime_get(), time_start)); - - if (core->type == MSM_DCVS_CORE_TYPE_CPU && - core->type_core_num == 0) { - mutex_lock(¶m_update_mutex); - check_power_collapse_modes(core); - mutex_unlock(¶m_update_mutex); - } - - /** - * Update algorithm with new freq and time taken to change - * to this frequency and that will get us the new slack - * timer - */ - ret = msm_dcvs_scm_event(core->dcvs_core_id, - MSM_DCVS_SCM_CLOCK_FREQ_UPDATE, - core->actual_freq, core->freq_change_us, - &slack_us, &ret1); - if (ret) { - __err("Error sending core (%s) dcvs_core_id = %d freq change (%u) reqfreq = %d slack_us=%d ret = %d\n", - core->core_name, core->dcvs_core_id, - core->actual_freq, requested_freq, - slack_us, ret); - } - - /* TODO confirm that we get a valid freq from SM even when the above - * FREQ_UPDATE fails - */ - restart_slack_timer(core, slack_us); - spin_lock_irqsave(&core->pending_freq_lock, flags); - - /** - * By the time we are done with freq changes, we could be asked to - * change again. Check before exiting. - */ - if (core->pending_freq != NO_OUTSTANDING_FREQ_CHANGE - && core->pending_freq != STOP_FREQ_CHANGE) { - goto repeat; - } - -out: /* should always be jumped to with the spin_lock held */ - spin_unlock_irqrestore(&core->pending_freq_lock, flags); - - return ret; -} - -static void msm_dcvs_report_temp_work(struct work_struct *work) -{ - struct dcvs_core *core = container_of(work, - struct dcvs_core, - temperature_work.work); - struct msm_dcvs_core_info *info = core->info; - struct tsens_device tsens_dev; - int ret; - unsigned long temp = 0; - int interval_ms; - - if (!(core->flags & CORE_FLAG_TEMP_UPDATE)) - return; - - tsens_dev.sensor_num = core->sensor; - ret = tsens_get_temp(&tsens_dev, &temp); - if (!temp) { - tsens_dev.sensor_num = 0; - ret = tsens_get_temp(&tsens_dev, &temp); - if (!temp) - goto out; - } - - if (temp == info->power_param.current_temp) - goto out; - info->power_param.current_temp = temp; - - ret = msm_dcvs_scm_set_power_params(core->dcvs_core_id, - &info->power_param, - &info->freq_tbl[0], &core->coeffs); -out: - if (info->thermal_poll_ms == 0) - interval_ms = 60000; - else if (info->thermal_poll_ms < 1000) - interval_ms = 1000; - else - interval_ms = info->thermal_poll_ms; - - schedule_delayed_work(&core->temperature_work, - msecs_to_jiffies(interval_ms)); -} - -static int msm_dcvs_do_freq(void *data) -{ - struct dcvs_core *core = (struct dcvs_core *)data; - - while (!kthread_should_stop()) { - wait_event(core->wait_q, !(core->pending_freq == 0 || - core->pending_freq == -1) || - kthread_should_stop()); - - if (kthread_should_stop()) - break; - - __msm_dcvs_change_freq(core); - } - - return 0; -} - -/* freq_pending_lock should be held */ -static void request_freq_change(struct dcvs_core *core, int new_freq) -{ - if (new_freq == NO_OUTSTANDING_FREQ_CHANGE) { - if (core->pending_freq != STOP_FREQ_CHANGE) { - __err("%s gov started with earlier pending freq %d\n", - core->core_name, core->pending_freq); - } - core->pending_freq = NO_OUTSTANDING_FREQ_CHANGE; - return; - } - - if (new_freq == STOP_FREQ_CHANGE) { - core->pending_freq = STOP_FREQ_CHANGE; - return; - } - - if (core->pending_freq < 0) { - /* a value less than 0 means that the governor has stopped - * and no more freq changes should be requested - */ - return; - } - - if (core->actual_freq != new_freq && core->pending_freq != new_freq) { - core->pending_freq = new_freq; - core->time_start = ktime_get(); - wake_up(&core->wait_q); - } -} - -static int msm_dcvs_update_freq(struct dcvs_core *core, - enum msm_dcvs_scm_event event, uint32_t param0, - uint32_t *ret1) -{ - int ret = 0; - unsigned long flags = 0; - uint32_t new_freq = -EINVAL; - - spin_lock_irqsave(&core->pending_freq_lock, flags); - - ret = msm_dcvs_scm_event(core->dcvs_core_id, event, param0, - core->actual_freq, &new_freq, ret1); - if (ret) { - if (ret == -13) - ret = 0; - else - __err("Error (%d) sending SCM event %d for core %s\n", - ret, event, core->core_name); - goto out; - } - - if (new_freq == 0) { - /* - * sometimes TZ gives us a 0 freq back, - * do not queue up a request - */ - goto out; - } - - request_freq_change(core, new_freq); - -out: - spin_unlock_irqrestore(&core->pending_freq_lock, flags); - - return ret; -} - -static enum hrtimer_restart msm_dcvs_core_slack_timer(struct hrtimer *timer) -{ - int ret = 0; - struct dcvs_core *core = container_of(timer, - struct dcvs_core, slack_timer); - uint32_t ret1; - - trace_printk("dcvs: Slack timer fired for core=%s\n", core->core_name); - /** - * Timer expired, notify TZ - * Dont care about the third arg. - */ - ret = msm_dcvs_update_freq(core, MSM_DCVS_SCM_QOS_TIMER_EXPIRED, 0, - &ret1); - if (ret) - __err("Timer expired for core %s but failed to notify.\n", - core->core_name); - - return HRTIMER_NORESTART; -} - -int msm_dcvs_update_algo_params(void) -{ - static struct msm_dcvs_algo_param curr_params; - struct msm_dcvs_algo_param *new_params; - int cpu, ret = 0; - - mutex_lock(¶m_update_mutex); - new_params = &core_list[CPU_OFFSET + num_online_cpus() - 1].algo_param; - - if (memcmp(&curr_params, new_params, - sizeof(struct msm_dcvs_algo_param))) { - for_each_possible_cpu(cpu) { - struct dcvs_core *core = &core_list[CPU_OFFSET + cpu]; - ret = msm_dcvs_scm_set_algo_params(CPU_OFFSET + cpu, - new_params); - if (ret) { - pr_err("scm set algo params failed on cpu %d, ret %d\n", - cpu, ret); - mutex_unlock(¶m_update_mutex); - return ret; - } - if (cpu == 0) - check_power_collapse_modes(core); - } - memcpy(&curr_params, new_params, - sizeof(struct msm_dcvs_algo_param)); - } - - mutex_unlock(¶m_update_mutex); - return ret; -} - -/* Helper functions and macros for sysfs nodes for a core */ -#define CORE_FROM_ATTRIBS(attr, name) \ - container_of(container_of(attr, struct core_attribs, name), \ - struct dcvs_core, attrib); - -#define DCVS_PARAM_SHOW(_name, v) \ -static ssize_t msm_dcvs_attr_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ -{ \ - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, _name); \ - return snprintf(buf, PAGE_SIZE, "%d\n", v); \ -} - -#define DCVS_PARAM_STORE(_name) \ -static ssize_t msm_dcvs_attr_##_name##_show(struct kobject *kobj,\ - struct kobj_attribute *attr, char *buf) \ -{ \ - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, _name); \ - return snprintf(buf, PAGE_SIZE, "%d\n", core->info->_name); \ -} \ -static ssize_t msm_dcvs_attr_##_name##_store(struct kobject *kobj, \ - struct kobj_attribute *attr, const char *buf, size_t count) \ -{ \ - int ret = 0; \ - uint32_t val = 0; \ - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, _name); \ - ret = kstrtouint(buf, 10, &val); \ - if (ret) { \ - __err("Invalid input %s for %s\n", buf, __stringify(_name));\ - } else { \ - core->info->_name = val; \ - } \ - return count; \ -} - -#define DCVS_ALGO_PARAM(_name) \ -static ssize_t msm_dcvs_attr_##_name##_show(struct kobject *kobj,\ - struct kobj_attribute *attr, char *buf) \ -{ \ - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, _name); \ - return snprintf(buf, PAGE_SIZE, "%d\n", core->algo_param._name); \ -} \ -static ssize_t msm_dcvs_attr_##_name##_store(struct kobject *kobj, \ - struct kobj_attribute *attr, const char *buf, size_t count) \ -{ \ - int ret = 0; \ - uint32_t val = 0; \ - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, _name); \ - ret = kstrtouint(buf, 10, &val); \ - if (ret) { \ - __err("Invalid input %s for %s\n", buf, __stringify(_name));\ - } else { \ - uint32_t old_val = core->algo_param._name; \ - core->algo_param._name = val; \ - ret = msm_dcvs_update_algo_params(); \ - if (ret) { \ - core->algo_param._name = old_val; \ - } \ - } \ - return count; \ -} - -#define DCVS_ENERGY_PARAM(_name) \ -static ssize_t msm_dcvs_attr_##_name##_show(struct kobject *kobj,\ - struct kobj_attribute *attr, char *buf) \ -{ \ - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, _name); \ - return snprintf(buf, PAGE_SIZE, "%d\n", core->coeffs._name); \ -} \ -static ssize_t msm_dcvs_attr_##_name##_store(struct kobject *kobj, \ - struct kobj_attribute *attr, const char *buf, size_t count) \ -{ \ - int ret = 0; \ - int32_t val = 0; \ - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, _name); \ - ret = kstrtoint(buf, 10, &val); \ - if (ret) { \ - __err("Invalid input %s for %s\n", buf, __stringify(_name));\ - } else { \ - int32_t old_val = core->coeffs._name; \ - core->coeffs._name = val; \ - ret = msm_dcvs_scm_set_power_params(core->dcvs_core_id, \ - &core->info->power_param, &core->info->freq_tbl[0], \ - &core->coeffs); \ - if (ret) { \ - core->coeffs._name = old_val; \ - __err("Error(%d) in setting %d for coeffs param %s\n",\ - ret, val, __stringify(_name)); \ - } \ - } \ - return count; \ -} - -#define DCVS_RO_ATTRIB(i, _name) \ - core->attrib._name.attr.name = __stringify(_name); \ - core->attrib._name.attr.mode = S_IRUGO; \ - core->attrib._name.show = msm_dcvs_attr_##_name##_show; \ - core->attrib._name.store = NULL; \ - core->attrib.attrib_group.attrs[i] = &core->attrib._name.attr; - -#define DCVS_RW_ATTRIB(i, _name) \ - core->attrib._name.attr.name = __stringify(_name); \ - core->attrib._name.attr.mode = S_IRUGO | S_IWUSR; \ - core->attrib._name.show = msm_dcvs_attr_##_name##_show; \ - core->attrib._name.store = msm_dcvs_attr_##_name##_store; \ - core->attrib.attrib_group.attrs[i] = &core->attrib._name.attr; - -/** - * Function declarations for different attributes. - * Gets used when setting the attribute show and store parameters. - */ -DCVS_PARAM_SHOW(freq_change_us, (core->freq_change_us)) - -DCVS_ALGO_PARAM(disable_pc_threshold) -DCVS_ALGO_PARAM(em_win_size_min_us) -DCVS_ALGO_PARAM(em_win_size_max_us) -DCVS_ALGO_PARAM(em_max_util_pct) -DCVS_ALGO_PARAM(group_id) -DCVS_ALGO_PARAM(max_freq_chg_time_us) -DCVS_ALGO_PARAM(slack_mode_dynamic) -DCVS_ALGO_PARAM(slack_time_min_us) -DCVS_ALGO_PARAM(slack_time_max_us) -DCVS_ALGO_PARAM(slack_weight_thresh_pct) -DCVS_ALGO_PARAM(ss_no_corr_below_freq) -DCVS_ALGO_PARAM(ss_win_size_min_us) -DCVS_ALGO_PARAM(ss_win_size_max_us) -DCVS_ALGO_PARAM(ss_util_pct) - -DCVS_ENERGY_PARAM(active_coeff_a) -DCVS_ENERGY_PARAM(active_coeff_b) -DCVS_ENERGY_PARAM(active_coeff_c) -DCVS_ENERGY_PARAM(leakage_coeff_a) -DCVS_ENERGY_PARAM(leakage_coeff_b) -DCVS_ENERGY_PARAM(leakage_coeff_c) -DCVS_ENERGY_PARAM(leakage_coeff_d) - -DCVS_PARAM_STORE(thermal_poll_ms) - -static ssize_t msm_dcvs_attr_offset_tbl_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf) -{ - struct msm_dcvs_freq_entry *freq_tbl; - char *buf_idx = buf; - int i, len; - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, offset_tbl); - - freq_tbl = core->info->freq_tbl; - *buf_idx = '\0'; - - /* limit the number of frequencies we will print into - * the PAGE_SIZE sysfs show buffer. */ - if (core->info->power_param.num_freq > 64) - return 0; - - for (i = 0; i < core->info->power_param.num_freq; i++) { - len = snprintf(buf_idx, 30, "%7d %7d %7d\n", - freq_tbl[i].freq, - freq_tbl[i].active_energy_offset, - freq_tbl[i].leakage_energy_offset); - /* buf_idx always points at terminating null */ - buf_idx += len; - } - return buf_idx - buf; -} - -static ssize_t msm_dcvs_attr_offset_tbl_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, - size_t count) -{ - struct msm_dcvs_freq_entry *freq_tbl; - uint32_t freq, active_energy_offset, leakage_energy_offset; - int i, ret; - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, offset_tbl); - - freq_tbl = core->info->freq_tbl; - - ret = sscanf(buf, "%u %u %u", - &freq, &active_energy_offset, &leakage_energy_offset); - if (ret != 3) { - __err("Invalid input %s for offset_tbl\n", buf); - return count; - } - - for (i = 0; i < core->info->power_param.num_freq; i++) - if (freq_tbl[i].freq == freq) { - freq_tbl[i].active_energy_offset = - active_energy_offset; - freq_tbl[i].leakage_energy_offset = - leakage_energy_offset; - break; - } - - if (i >= core->info->power_param.num_freq) { - __err("Invalid frequency for offset_tbl: %d\n", freq); - return count; - } - - ret = msm_dcvs_scm_set_power_params(core->dcvs_core_id, - &core->info->power_param, - &core->info->freq_tbl[0], - &core->coeffs); - if (ret) - __err("Error %d in updating active/leakage energy\n", ret); - - return count; -} - -static ssize_t msm_dcvs_attr_freq_tbl_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf) -{ - struct msm_dcvs_freq_entry *freq_tbl; - char *buf_idx = buf; - int i, len; - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, freq_tbl); - - freq_tbl = core->info->freq_tbl; - *buf_idx = '\0'; - - /* limit the number of frequencies we will print into - * the PAGE_SIZE sysfs show buffer. */ - if (core->info->power_param.num_freq > 64) - return 0; - - for (i = 0; i < core->info->power_param.num_freq; i++) { - if (freq_tbl[i].is_trans_level) { - len = snprintf(buf_idx, 10, "%7d ", freq_tbl[i].freq); - /* buf_idx always points at terminating null */ - buf_idx += len; - } - } - /* overwrite final trailing space with newline */ - if (buf_idx > buf) - *(buf_idx - 1) = '\n'; - - return buf_idx - buf; -} - -static ssize_t msm_dcvs_attr_freq_tbl_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, - size_t count) -{ - struct msm_dcvs_freq_entry *freq_tbl; - uint32_t freq; - int i, ret; - struct dcvs_core *core = CORE_FROM_ATTRIBS(attr, freq_tbl); - - freq_tbl = core->info->freq_tbl; - - ret = kstrtouint(buf, 10, &freq); - if (ret) { - __err("Invalid input %s for freq_tbl\n", buf); - return count; - } - - for (i = 0; i < core->info->power_param.num_freq; i++) - if (freq_tbl[i].freq == freq) { - freq_tbl[i].is_trans_level ^= 1; - break; - } - - if (i >= core->info->power_param.num_freq) { - __err("Invalid frequency for freq_tbl: %d\n", freq); - return count; - } - - ret = msm_dcvs_scm_set_power_params(core->dcvs_core_id, - &core->info->power_param, - &core->info->freq_tbl[0], - &core->coeffs); - if (ret) { - freq_tbl[i].is_trans_level ^= 1; - __err("Error %d in toggling freq %d (orig enable val %d)\n", - ret, freq_tbl[i].freq, freq_tbl[i].is_trans_level); - } - return count; -} - -static int msm_dcvs_setup_core_sysfs(struct dcvs_core *core) -{ - int ret = 0; - struct kobject *core_kobj = NULL; - const int attr_count = 26; - - BUG_ON(!cores_kobj); - - core->attrib.attrib_group.attrs = - kzalloc(attr_count * sizeof(struct attribute *), GFP_KERNEL); - - if (!core->attrib.attrib_group.attrs) { - ret = -ENOMEM; - goto done; - } - - DCVS_RO_ATTRIB(0, freq_change_us); - - DCVS_RW_ATTRIB(1, disable_pc_threshold); - DCVS_RW_ATTRIB(2, em_win_size_min_us); - DCVS_RW_ATTRIB(3, em_win_size_max_us); - DCVS_RW_ATTRIB(4, em_max_util_pct); - DCVS_RW_ATTRIB(5, group_id); - DCVS_RW_ATTRIB(6, max_freq_chg_time_us); - DCVS_RW_ATTRIB(7, slack_mode_dynamic); - DCVS_RW_ATTRIB(8, slack_weight_thresh_pct); - DCVS_RW_ATTRIB(9, slack_time_min_us); - DCVS_RW_ATTRIB(10, slack_time_max_us); - DCVS_RW_ATTRIB(11, ss_no_corr_below_freq); - DCVS_RW_ATTRIB(12, ss_win_size_min_us); - DCVS_RW_ATTRIB(13, ss_win_size_max_us); - DCVS_RW_ATTRIB(14, ss_util_pct); - - DCVS_RW_ATTRIB(15, active_coeff_a); - DCVS_RW_ATTRIB(16, active_coeff_b); - DCVS_RW_ATTRIB(17, active_coeff_c); - DCVS_RW_ATTRIB(18, leakage_coeff_a); - DCVS_RW_ATTRIB(19, leakage_coeff_b); - DCVS_RW_ATTRIB(20, leakage_coeff_c); - DCVS_RW_ATTRIB(21, leakage_coeff_d); - DCVS_RW_ATTRIB(22, thermal_poll_ms); - - DCVS_RW_ATTRIB(23, freq_tbl); - DCVS_RW_ATTRIB(24, offset_tbl); - - core->attrib.attrib_group.attrs[25] = NULL; - - core_kobj = kobject_create_and_add(core->core_name, cores_kobj); - if (!core_kobj) { - ret = -ENOMEM; - goto done; - } - - ret = sysfs_create_group(core_kobj, &core->attrib.attrib_group); - if (ret) - __err("Cannot create core %s attr group\n", core->core_name); - -done: - if (ret) { - kfree(core->attrib.attrib_group.attrs); - kobject_del(core_kobj); - } - - return ret; -} - -static int get_core_offset(enum msm_dcvs_core_type type, int num) -{ - int offset = -EINVAL; - - switch (type) { - case MSM_DCVS_CORE_TYPE_CPU: - offset = CPU_OFFSET + num; - BUG_ON(offset >= GPU_OFFSET); - break; - case MSM_DCVS_CORE_TYPE_GPU: - offset = GPU_OFFSET + num; - BUG_ON(offset >= CORES_MAX); - break; - default: - BUG(); - } - - return offset; -} - -/* Return the core and initialize non platform data specific numbers in it */ -static struct dcvs_core *msm_dcvs_add_core(enum msm_dcvs_core_type type, - int num) -{ - struct dcvs_core *core = NULL; - int i; - char name[CORE_NAME_MAX]; - - i = get_core_offset(type, num); - if (i < 0) - return NULL; - - if (type == MSM_DCVS_CORE_TYPE_CPU) - snprintf(name, CORE_NAME_MAX, "cpu%d", num); - else - snprintf(name, CORE_NAME_MAX, "gpu%d", num); - - core = &core_list[i]; - core->dcvs_core_id = i; - strlcpy(core->core_name, name, CORE_NAME_MAX); - spin_lock_init(&core->pending_freq_lock); - spin_lock_init(&core->idle_state_change_lock); - hrtimer_init(&core->slack_timer, - CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); - core->slack_timer.function = msm_dcvs_core_slack_timer; - return core; -} - -/* Return the core if found or add to list if @add_to_list is true */ -static struct dcvs_core *msm_dcvs_get_core(int offset) -{ - /* if the handle is still not set bug */ - BUG_ON(core_list[offset].dcvs_core_id == -1); - return &core_list[offset]; -} - -void msm_dcvs_register_cpu_freq(uint32_t freq, uint32_t voltage) -{ - BUG_ON(freq == 0 || voltage == 0 || - num_cpu_freqs == DCVS_MAX_NUM_FREQS); - - cpu_freq_tbl[num_cpu_freqs].freq = freq; - cpu_freq_tbl[num_cpu_freqs].voltage = voltage; - - num_cpu_freqs++; -} - -int msm_dcvs_register_core( - enum msm_dcvs_core_type type, - int type_core_num, - struct msm_dcvs_core_info *info, - int (*set_frequency)(int type_core_num, unsigned int freq), - unsigned int (*get_frequency)(int type_core_num), - int (*idle_enable)(int type_core_num, - enum msm_core_control_event event), - int (*set_floor_frequency)(int type_core_num, unsigned int freq), - int sensor) -{ - int ret = -EINVAL; - int offset; - struct dcvs_core *core = NULL; - uint32_t ret1; - uint32_t ret2; - - if (!msm_dcvs_enabled) - return ret; - - offset = get_core_offset(type, type_core_num); - if (offset < 0) - return ret; - if (core_list[offset].dcvs_core_id != -1) - return core_list[offset].dcvs_core_id; - - core = msm_dcvs_add_core(type, type_core_num); - if (!core) - return ret; - - core->type = type; - core->type_core_num = type_core_num; - core->set_frequency = set_frequency; - core->get_frequency = get_frequency; - core->idle_enable = idle_enable; - core->set_floor_frequency = set_floor_frequency; - - core->info = info; - if (type == MSM_DCVS_CORE_TYPE_CPU) { - BUG_ON(num_cpu_freqs == 0); - info->freq_tbl = cpu_freq_tbl; - info->power_param.num_freq = num_cpu_freqs; - } - - memcpy(&core->algo_param, &info->algo_param, - sizeof(struct msm_dcvs_algo_param)); - - memcpy(&core->coeffs, &info->energy_coeffs, - sizeof(struct msm_dcvs_energy_curve_coeffs)); - - /* - * The tz expects cpu0 to represent bit 0 in the mask, however the - * dcvs_core_id needs to start from 1, dcvs_core_id = 0 is used to - * indicate that this request is not associated with any core. - * mpdecision - */ - info->core_param.core_bitmask_id - = 1 << (core->dcvs_core_id - CPU_OFFSET); - core->sensor = sensor; - - ret = msm_dcvs_scm_register_core(core->dcvs_core_id, &info->core_param); - if (ret) { - __err("%s: scm register core fail handle = %d ret = %d\n", - __func__, core->dcvs_core_id, ret); - goto bail; - } - - ret = msm_dcvs_scm_set_algo_params(core->dcvs_core_id, - &info->algo_param); - if (ret) { - __err("%s: scm algo params failed ret = %d\n", __func__, ret); - goto bail; - } - - ret = msm_dcvs_scm_set_power_params(core->dcvs_core_id, - &info->power_param, - &info->freq_tbl[0], &core->coeffs); - if (ret) { - __err("%s: scm power params failed ret = %d\n", __func__, ret); - goto bail; - } - - ret = msm_dcvs_scm_event(core->dcvs_core_id, MSM_DCVS_SCM_CORE_ONLINE, - core->actual_freq, 0, &ret1, &ret2); - if (ret) - goto bail; - - ret = msm_dcvs_setup_core_sysfs(core); - if (ret) { - __err("Unable to setup core %s sysfs\n", core->core_name); - goto bail; - } - core->idle_entered = -1; - init_waitqueue_head(&core->wait_q); - core->task = kthread_run(msm_dcvs_do_freq, (void *)core, - "msm_dcvs/%d", core->dcvs_core_id); - ret = core->dcvs_core_id; - return ret; -bail: - core->dcvs_core_id = -1; - return -EINVAL; -} -EXPORT_SYMBOL(msm_dcvs_register_core); - -void msm_dcvs_update_limits(int dcvs_core_id) -{ - struct dcvs_core *core; - - if (dcvs_core_id < CPU_OFFSET || dcvs_core_id > CORES_MAX) { - __err("%s invalid dcvs_core_id = %d returning -EINVAL\n", - __func__, dcvs_core_id); - return; - } - - core = msm_dcvs_get_core(dcvs_core_id); - core->actual_freq = core->get_frequency(core->type_core_num); -} - -int msm_dcvs_freq_sink_start(int dcvs_core_id) -{ - int ret = -EINVAL; - struct dcvs_core *core = NULL; - uint32_t ret1; - unsigned long flags; - int new_freq; - int timer_interval_us; - - if (dcvs_core_id < CPU_OFFSET || dcvs_core_id > CORES_MAX) { - __err("%s invalid dcvs_core_id = %d returning -EINVAL\n", - __func__, dcvs_core_id); - return -EINVAL; - } - - core = msm_dcvs_get_core(dcvs_core_id); - if (!core) - return ret; - - core->actual_freq = core->get_frequency(core->type_core_num); - - spin_lock_irqsave(&core->pending_freq_lock, flags); - /* mark that we are ready to accept new frequencies */ - request_freq_change(core, NO_OUTSTANDING_FREQ_CHANGE); - spin_unlock_irqrestore(&core->pending_freq_lock, flags); - - spin_lock_irqsave(&core->idle_state_change_lock, flags); - core->idle_entered = -1; - spin_unlock_irqrestore(&core->idle_state_change_lock, flags); - - /* Notify TZ to start receiving idle info for the core */ - ret = msm_dcvs_update_freq(core, MSM_DCVS_SCM_DCVS_ENABLE, 1, &ret1); - - ret = msm_dcvs_scm_event( - core->dcvs_core_id, MSM_DCVS_SCM_CORE_ONLINE, core->actual_freq, - 0, &new_freq, &timer_interval_us); - if (ret) - __err("Error (%d) DCVS sending online for %s\n", - ret, core->core_name); - - if (new_freq != 0) { - spin_lock_irqsave(&core->pending_freq_lock, flags); - request_freq_change(core, new_freq); - spin_unlock_irqrestore(&core->pending_freq_lock, flags); - } - force_start_slack_timer(core, timer_interval_us); - - core->flags |= CORE_FLAG_TEMP_UPDATE; - INIT_DELAYED_WORK(&core->temperature_work, msm_dcvs_report_temp_work); - schedule_delayed_work(&core->temperature_work, - msecs_to_jiffies(core->info->thermal_poll_ms)); - - core->idle_enable(core->type_core_num, MSM_DCVS_ENABLE_IDLE_PULSE); - return 0; -} -EXPORT_SYMBOL(msm_dcvs_freq_sink_start); - -int msm_dcvs_freq_sink_stop(int dcvs_core_id) -{ - int ret = -EINVAL; - struct dcvs_core *core = NULL; - uint32_t ret1; - uint32_t freq; - unsigned long flags; - - if (dcvs_core_id < 0 || dcvs_core_id > CORES_MAX) { - pr_err("%s invalid dcvs_core_id = %d returning -EINVAL\n", - __func__, dcvs_core_id); - return -EINVAL; - } - - core = msm_dcvs_get_core(dcvs_core_id); - if (!core) { - __err("couldn't find core for coreid = %d\n", dcvs_core_id); - return ret; - } - - core->flags &= ~CORE_FLAG_TEMP_UPDATE; - cancel_delayed_work(&core->temperature_work); - - core->idle_enable(core->type_core_num, MSM_DCVS_DISABLE_IDLE_PULSE); - /* Notify TZ to stop receiving idle info for the core */ - ret = msm_dcvs_scm_event(core->dcvs_core_id, MSM_DCVS_SCM_DCVS_ENABLE, - 0, core->actual_freq, &freq, &ret1); - core->idle_enable(core->type_core_num, - MSM_DCVS_ENABLE_HIGH_LATENCY_MODES); - - if (core->type == MSM_DCVS_CORE_TYPE_GPU) - mutex_lock(&gpu_floor_mutex); - - spin_lock_irqsave(&core->pending_freq_lock, flags); - /* flush out all the pending freq changes */ - request_freq_change(core, STOP_FREQ_CHANGE); - spin_unlock_irqrestore(&core->pending_freq_lock, flags); - - if (core->type == MSM_DCVS_CORE_TYPE_GPU) - mutex_unlock(&gpu_floor_mutex); - - force_stop_slack_timer(core); - - return 0; -} -EXPORT_SYMBOL(msm_dcvs_freq_sink_stop); - -int msm_dcvs_idle(int dcvs_core_id, enum msm_core_idle_state state, - uint32_t iowaited) -{ - int ret = 0; - struct dcvs_core *core = NULL; - uint32_t timer_interval_us = 0; - uint32_t r0, r1; - - if (dcvs_core_id < CPU_OFFSET || dcvs_core_id > CORES_MAX) { - pr_err("invalid dcvs_core_id = %d ret -EINVAL\n", dcvs_core_id); - return -EINVAL; - } - - core = msm_dcvs_get_core(dcvs_core_id); - - switch (state) { - case MSM_DCVS_IDLE_ENTER: - stop_slack_timer(core); - ret = msm_dcvs_scm_event(core->dcvs_core_id, - MSM_DCVS_SCM_IDLE_ENTER, 0, 0, &r0, &r1); - if (ret < 0 && ret != -13) - __err("Error (%d) sending idle enter for %s\n", - ret, core->core_name); - trace_msm_dcvs_idle("idle_enter_exit", core->core_name, 1); - break; - - case MSM_DCVS_IDLE_EXIT: - ret = msm_dcvs_update_freq(core, MSM_DCVS_SCM_IDLE_EXIT, - iowaited, &timer_interval_us); - if (ret) - __err("Error (%d) sending idle exit for %s\n", - ret, core->core_name); - start_slack_timer(core, timer_interval_us); - trace_msm_dcvs_idle("idle_enter_exit", core->core_name, 0); - trace_msm_dcvs_iowait("iowait", core->core_name, iowaited); - trace_msm_dcvs_slack_time("slack_timer_dcvs", core->core_name, - timer_interval_us); - break; - } - - return ret; -} -EXPORT_SYMBOL(msm_dcvs_idle); - -static int __init msm_dcvs_late_init(void) -{ - struct kobject *module_kobj = NULL; - int ret = 0; - - if (!msm_dcvs_enabled) - return ret; - - module_kobj = kset_find_obj(module_kset, KBUILD_MODNAME); - if (!module_kobj) { - pr_err("%s: cannot find kobject for module %s\n", - __func__, KBUILD_MODNAME); - ret = -ENOENT; - goto err; - } - - cores_kobj = kobject_create_and_add("cores", module_kobj); - if (!cores_kobj) { - __err("Cannot create %s kobject\n", "cores"); - ret = -ENOMEM; - goto err; - } - - debugfs_base = debugfs_create_dir("msm_dcvs", NULL); - if (!debugfs_base) { - __err("Cannot create debugfs base %s\n", "msm_dcvs"); - ret = -ENOENT; - goto err; - } - -err: - if (ret) { - kobject_del(cores_kobj); - cores_kobj = NULL; - debugfs_remove(debugfs_base); - } - - return ret; -} -late_initcall(msm_dcvs_late_init); - -static int dcvs_probe(struct platform_device *pdev) -{ - if (pdev->dev.platform_data) - dcvs_pdata = pdev->dev.platform_data; - - return 0; -} - -static struct platform_driver dcvs_driver = { - .probe = dcvs_probe, - .driver = { - .name = "dcvs", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_dcvs_early_init(void) -{ - int ret = 0; - int i; - - platform_driver_register(&dcvs_driver); - - if (!msm_dcvs_enabled) { - __info("Not enabled (%d)\n", msm_dcvs_enabled); - return 0; - } - - - /* Only need about 32kBytes for normal operation */ - ret = msm_dcvs_scm_init(SZ_32K); - if (ret) { - __err("Unable to initialize DCVS err=%d\n", ret); - msm_dcvs_enabled = 0; - goto done; - } - - for (i = 0; i < CORES_MAX; i++) { - core_list[i].dcvs_core_id = -1; - core_list[i].pending_freq = STOP_FREQ_CHANGE; - } -done: - return ret; -} -postcore_initcall(msm_dcvs_early_init); diff --git a/arch/arm/mach-msm/msm_dcvs_scm.c b/arch/arm/mach-msm/msm_dcvs_scm.c deleted file mode 100644 index e03ac647bd1ff25f937ee173d2636147a47207ab..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_dcvs_scm.c +++ /dev/null @@ -1,253 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DCVS_CMD_REGISTER_CORE 2 -#define DCVS_CMD_SET_ALGO_PARAM 3 -#define DCVS_CMD_EVENT 4 -#define DCVS_CMD_INIT 5 -#define DCVS_CMD_SET_POWER_PARAM 6 - -struct scm_register_core { - uint32_t core_id; - phys_addr_t core_param_phy; -}; - -struct scm_algo { - uint32_t core_id; - phys_addr_t algo_phy; -}; - -struct scm_init { - uint32_t phy; - uint32_t size; -}; - -struct scm_pwr_param { - uint32_t core_id; - phys_addr_t pwr_param_phy; - phys_addr_t freq_phy; - phys_addr_t coeffs_phy; -}; - -struct msm_algo_param { - enum msm_dcvs_algo_param_type type; - union { - struct msm_dcvs_algo_param dcvs_param; - struct msm_mpd_algo_param mpd_param; - } u; -}; - -int msm_dcvs_scm_init(size_t size) -{ - int ret = 0; - struct scm_init init; - uint32_t p = 0; - - /* Allocate word aligned non-cacheable memory */ - p = allocate_contiguous_ebi_nomap(size, 4); - if (!p) - return -ENOMEM; - - init.phy = p; - init.size = size; - - ret = scm_call(SCM_SVC_DCVS, DCVS_CMD_INIT, - &init, sizeof(init), NULL, 0); - - /* Not freed if the initialization succeeds */ - if (ret) - free_contiguous_memory_by_paddr(p); - - return ret; -} -EXPORT_SYMBOL(msm_dcvs_scm_init); - -static void __msm_dcvs_flush_cache(void *v, size_t size) -{ - __cpuc_flush_dcache_area(v, size); - outer_flush_range(virt_to_phys(v), virt_to_phys(v) + size); -} - -int msm_dcvs_scm_register_core(uint32_t core_id, - struct msm_dcvs_core_param *param) -{ - int ret = 0; - struct scm_register_core reg_data; - struct msm_dcvs_core_param *p = NULL; - - p = kzalloc(PAGE_ALIGN(sizeof(struct msm_dcvs_core_param)), GFP_KERNEL); - if (!p) - return -ENOMEM; - - memcpy(p, param, sizeof(struct msm_dcvs_core_param)); - - reg_data.core_id = core_id; - reg_data.core_param_phy = virt_to_phys(p); - - __msm_dcvs_flush_cache(p, sizeof(struct msm_dcvs_core_param)); - - ret = scm_call(SCM_SVC_DCVS, DCVS_CMD_REGISTER_CORE, - ®_data, sizeof(reg_data), NULL, 0); - - kfree(p); - - return ret; -} -EXPORT_SYMBOL(msm_dcvs_scm_register_core); - -int msm_dcvs_scm_set_algo_params(uint32_t core_id, - struct msm_dcvs_algo_param *param) -{ - int ret = 0; - struct scm_algo algo; - struct msm_algo_param *p = NULL; - - p = kzalloc(PAGE_ALIGN(sizeof(struct msm_algo_param)), GFP_KERNEL); - if (!p) - return -ENOMEM; - - p->type = MSM_DCVS_ALGO_DCVS_PARAM; - memcpy(&p->u.dcvs_param, param, sizeof(struct msm_dcvs_algo_param)); - - algo.core_id = core_id; - algo.algo_phy = virt_to_phys(p); - - __msm_dcvs_flush_cache(p, sizeof(struct msm_algo_param)); - - ret = scm_call(SCM_SVC_DCVS, DCVS_CMD_SET_ALGO_PARAM, - &algo, sizeof(algo), NULL, 0); - - kfree(p); - - return ret; -} -EXPORT_SYMBOL(msm_dcvs_scm_set_algo_params); - -int msm_mpd_scm_set_algo_params(struct msm_mpd_algo_param *param) -{ - int ret = 0; - struct scm_algo algo; - struct msm_algo_param *p = NULL; - - p = kzalloc(PAGE_ALIGN(sizeof(struct msm_algo_param)), GFP_KERNEL); - if (!p) - return -ENOMEM; - - p->type = MSM_DCVS_ALGO_MPD_PARAM; - memcpy(&p->u.mpd_param, param, sizeof(struct msm_mpd_algo_param)); - - algo.core_id = 0; - algo.algo_phy = virt_to_phys(p); - - __msm_dcvs_flush_cache(p, sizeof(struct msm_algo_param)); - - ret = scm_call(SCM_SVC_DCVS, DCVS_CMD_SET_ALGO_PARAM, - &algo, sizeof(algo), NULL, 0); - - kfree(p); - - return ret; -} -EXPORT_SYMBOL(msm_mpd_scm_set_algo_params); - -int msm_dcvs_scm_set_power_params(uint32_t core_id, - struct msm_dcvs_power_params *pwr_param, - struct msm_dcvs_freq_entry *freq_entry, - struct msm_dcvs_energy_curve_coeffs *coeffs) -{ - int ret = 0; - struct scm_pwr_param pwr; - struct msm_dcvs_power_params *pwrt = NULL; - struct msm_dcvs_freq_entry *freqt = NULL; - struct msm_dcvs_energy_curve_coeffs *coefft = NULL; - - pwrt = kzalloc(PAGE_ALIGN(sizeof(struct msm_dcvs_power_params)), - GFP_KERNEL); - if (!pwrt) - return -ENOMEM; - - freqt = kzalloc(PAGE_ALIGN(sizeof(struct msm_dcvs_freq_entry) - * pwr_param->num_freq), - GFP_KERNEL); - if (!freqt) { - kfree(pwrt); - return -ENOMEM; - } - - coefft = kzalloc(PAGE_ALIGN( - sizeof(struct msm_dcvs_energy_curve_coeffs)), - GFP_KERNEL); - if (!coefft) { - kfree(pwrt); - kfree(freqt); - return -ENOMEM; - } - - memcpy(pwrt, pwr_param, sizeof(struct msm_dcvs_power_params)); - memcpy(freqt, freq_entry, - sizeof(struct msm_dcvs_freq_entry)*pwr_param->num_freq); - memcpy(coefft, coeffs, sizeof(struct msm_dcvs_energy_curve_coeffs)); - - __msm_dcvs_flush_cache(pwrt, sizeof(struct msm_dcvs_power_params)); - __msm_dcvs_flush_cache(freqt, - sizeof(struct msm_dcvs_freq_entry) * pwr_param->num_freq); - __msm_dcvs_flush_cache(coefft, - sizeof(struct msm_dcvs_energy_curve_coeffs)); - - pwr.core_id = core_id; - pwr.pwr_param_phy = virt_to_phys(pwrt); - pwr.freq_phy = virt_to_phys(freqt); - pwr.coeffs_phy = virt_to_phys(coefft); - - ret = scm_call(SCM_SVC_DCVS, DCVS_CMD_SET_POWER_PARAM, - &pwr, sizeof(pwr), NULL, 0); - - kfree(pwrt); - kfree(freqt); - kfree(coefft); - - return ret; -} -EXPORT_SYMBOL(msm_dcvs_scm_set_power_params); - -int msm_dcvs_scm_event(uint32_t core_id, - enum msm_dcvs_scm_event event_id, - uint32_t param0, uint32_t param1, - uint32_t *ret0, uint32_t *ret1) -{ - int ret = -EINVAL; - - if (!ret0 || !ret1) - return ret; - - ret = scm_call_atomic4_3(SCM_SVC_DCVS, DCVS_CMD_EVENT, - core_id, event_id, param0, param1, ret0, ret1); - - trace_msm_dcvs_scm_event(core_id, (int)event_id, param0, param1, - *ret0, *ret1); - - return ret; -} -EXPORT_SYMBOL(msm_dcvs_scm_event); diff --git a/arch/arm/mach-msm/msm_kexec.c b/arch/arm/mach-msm/msm_kexec.c deleted file mode 100644 index a1b19ff85fca9f98866962b86bae3471ac8d52dc..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_kexec.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2010, 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 -#include - -#ifdef CONFIG_MSM_WATCHDOG -#include - -#define WDT0_EN (MSM_TMR_BASE + 0x40) -#endif - -void arch_kexec(void) -{ -#ifdef CONFIG_MSM_WATCHDOG - /* Prevent watchdog from resetting SoC */ - writel(0, WDT0_EN); - pr_crit("KEXEC: MSM Watchdog Exit - Deactivated\n"); -#endif - return; -} diff --git a/arch/arm/mach-msm/msm_mpdecision.c b/arch/arm/mach-msm/msm_mpdecision.c deleted file mode 100644 index ecc49de7a2befd50ee917f1f7c2d2d18abf8ef33..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_mpdecision.c +++ /dev/null @@ -1,726 +0,0 @@ - /* Copyright (c) 2012, 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. - */ - -#define pr_fmt(fmt) "mpd %s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define CREATE_TRACE_POINTS -#include - -#define DEFAULT_RQ_AVG_POLL_MS (1) -#define DEFAULT_RQ_AVG_DIVIDE (25) - -struct mpd_attrib { - struct kobj_attribute enabled; - struct kobj_attribute rq_avg_poll_ms; - struct kobj_attribute iowait_threshold_pct; - - struct kobj_attribute rq_avg_divide; - struct kobj_attribute em_win_size_min_us; - struct kobj_attribute em_win_size_max_us; - struct kobj_attribute em_max_util_pct; - struct kobj_attribute mp_em_rounding_point_min; - struct kobj_attribute mp_em_rounding_point_max; - struct kobj_attribute online_util_pct_min; - struct kobj_attribute online_util_pct_max; - struct kobj_attribute slack_time_min_us; - struct kobj_attribute slack_time_max_us; - struct kobj_attribute hp_up_max_ms; - struct kobj_attribute hp_up_ms; - struct kobj_attribute hp_up_count; - struct kobj_attribute hp_dw_max_ms; - struct kobj_attribute hp_dw_ms; - struct kobj_attribute hp_dw_count; - struct attribute_group attrib_group; -}; - -struct msm_mpd_scm_data { - enum msm_dcvs_scm_event event; - int nr; -}; - -struct mpdecision { - uint32_t enabled; - atomic_t algo_cpu_mask; - uint32_t rq_avg_poll_ms; - uint32_t iowait_threshold_pct; - uint32_t rq_avg_divide; - ktime_t next_update; - uint32_t slack_us; - struct msm_mpd_algo_param mp_param; - struct mpd_attrib attrib; - struct mutex lock; - struct task_struct *task; - struct task_struct *hptask; - struct hrtimer slack_timer; - struct msm_mpd_scm_data data; - int hpupdate; - wait_queue_head_t wait_q; - wait_queue_head_t wait_hpq; -}; - -struct hp_latency { - int hp_up_max_ms; - int hp_up_ms; - int hp_up_count; - int hp_dw_max_ms; - int hp_dw_ms; - int hp_dw_count; -}; - -static DEFINE_PER_CPU(struct hrtimer, rq_avg_poll_timer); -static DEFINE_SPINLOCK(rq_avg_lock); - -enum { - MSM_MPD_DEBUG_NOTIFIER = BIT(0), - MSM_MPD_CORE_STATUS = BIT(1), - MSM_MPD_SLACK_TIMER = BIT(2), -}; - -enum { - HPUPDATE_WAITING = 0, /* we are waiting for cpumask update */ - HPUPDATE_SCHEDULED = 1, /* we are in the process of hotplugging */ - HPUPDATE_IN_PROGRESS = 2, /* we are in the process of hotplugging */ -}; - -static int msm_mpd_enabled = 1; -module_param_named(enabled, msm_mpd_enabled, int, S_IRUGO | S_IWUSR | S_IWGRP); - -static struct dentry *debugfs_base; -static struct mpdecision msm_mpd; - -static struct hp_latency hp_latencies; - -static unsigned long last_nr; -static int num_present_hundreds; -static ktime_t last_down_time; - -static bool ok_to_update_tz(int nr, int last_nr) -{ - /* - * Exclude unnecessary TZ reports if run queue haven't changed much from - * the last reported value. The divison by rq_avg_divide is to - * filter out small changes in the run queue average which won't cause - * a online cpu mask change. Also if the cpu online count does not match - * the count requested by TZ and we are not in the process of bringing - * cpus online as indicated by a HPUPDATE_IN_PROGRESS in msm_mpd.hpdata - */ - return - (((nr / msm_mpd.rq_avg_divide) - != (last_nr / msm_mpd.rq_avg_divide)) - || ((hweight32(atomic_read(&msm_mpd.algo_cpu_mask)) - != num_online_cpus()) - && (msm_mpd.hpupdate != HPUPDATE_IN_PROGRESS))); -} - -static enum hrtimer_restart msm_mpd_rq_avg_poll_timer(struct hrtimer *timer) -{ - int nr, nr_iowait; - ktime_t curr_time = ktime_get(); - unsigned long flags; - int cpu = smp_processor_id(); - enum hrtimer_restart restart = HRTIMER_RESTART; - - spin_lock_irqsave(&rq_avg_lock, flags); - /* If running on the wrong cpu, don't restart */ - if (&per_cpu(rq_avg_poll_timer, cpu) != timer) - restart = HRTIMER_NORESTART; - - if (ktime_to_ns(ktime_sub(curr_time, msm_mpd.next_update)) < 0) - goto out; - - msm_mpd.next_update = ktime_add_ns(curr_time, - (msm_mpd.rq_avg_poll_ms * NSEC_PER_MSEC)); - - sched_get_nr_running_avg(&nr, &nr_iowait); - - if ((nr_iowait >= msm_mpd.iowait_threshold_pct) && (nr < last_nr)) - nr = last_nr; - - if (nr > num_present_hundreds) - nr = num_present_hundreds; - - trace_msm_mp_runq("nr_running", nr); - - if (ok_to_update_tz(nr, last_nr)) { - hrtimer_try_to_cancel(&msm_mpd.slack_timer); - msm_mpd.data.nr = nr; - msm_mpd.data.event = MSM_DCVS_SCM_RUNQ_UPDATE; - wake_up(&msm_mpd.wait_q); - last_nr = nr; - } - -out: - hrtimer_set_expires(timer, msm_mpd.next_update); - spin_unlock_irqrestore(&rq_avg_lock, flags); - /* set next expiration */ - return restart; -} - -static void bring_up_cpu(int cpu) -{ - int cpu_action_time_ms; - int time_taken_ms; - int ret, ret1, ret2; - - cpu_action_time_ms = ktime_to_ms(ktime_get()); - ret = cpu_up(cpu); - if (ret) { - pr_debug("Error %d online core %d\n", ret, cpu); - } else { - time_taken_ms = ktime_to_ms(ktime_get()) - cpu_action_time_ms; - if (time_taken_ms > hp_latencies.hp_up_max_ms) - hp_latencies.hp_up_max_ms = time_taken_ms; - hp_latencies.hp_up_ms += time_taken_ms; - hp_latencies.hp_up_count++; - ret = msm_dcvs_scm_event( - CPU_OFFSET + cpu, - MSM_DCVS_SCM_CORE_ONLINE, - cpufreq_get(cpu), - (uint32_t) time_taken_ms * USEC_PER_MSEC, - &ret1, &ret2); - if (ret) - pr_err("Error sending hotplug scm event err=%d\n", ret); - } -} - -static void bring_down_cpu(int cpu) -{ - int cpu_action_time_ms; - int time_taken_ms; - int ret, ret1, ret2; - - BUG_ON(cpu == 0); - cpu_action_time_ms = ktime_to_ms(ktime_get()); - ret = cpu_down(cpu); - if (ret) { - pr_debug("Error %d offline" "core %d\n", ret, cpu); - } else { - time_taken_ms = ktime_to_ms(ktime_get()) - cpu_action_time_ms; - if (time_taken_ms > hp_latencies.hp_dw_max_ms) - hp_latencies.hp_dw_max_ms = time_taken_ms; - hp_latencies.hp_dw_ms += time_taken_ms; - hp_latencies.hp_dw_count++; - ret = msm_dcvs_scm_event( - CPU_OFFSET + cpu, - MSM_DCVS_SCM_CORE_OFFLINE, - (uint32_t) time_taken_ms * USEC_PER_MSEC, - 0, - &ret1, &ret2); - if (ret) - pr_err("Error sending hotplug scm event err=%d\n", ret); - } -} - -static int __ref msm_mpd_update_scm(enum msm_dcvs_scm_event event, int nr) -{ - int ret = 0; - uint32_t req_cpu_mask = 0; - uint32_t slack_us = 0; - uint32_t param0 = 0; - - if (event == MSM_DCVS_SCM_RUNQ_UPDATE) - param0 = nr; - - ret = msm_dcvs_scm_event(0, event, param0, 0, - &req_cpu_mask, &slack_us); - - if (ret) { - pr_err("Error (%d) sending event %d, param %d\n", ret, event, - param0); - return ret; - } - - trace_msm_mp_cpusonline("cpu_online_mp", req_cpu_mask); - trace_msm_mp_slacktime("slack_time_mp", slack_us); - msm_mpd.slack_us = slack_us; - atomic_set(&msm_mpd.algo_cpu_mask, req_cpu_mask); - msm_mpd.hpupdate = HPUPDATE_SCHEDULED; - wake_up(&msm_mpd.wait_hpq); - - /* Start MP Decision slack timer */ - if (slack_us) { - hrtimer_cancel(&msm_mpd.slack_timer); - ret = hrtimer_start(&msm_mpd.slack_timer, - ktime_set(0, slack_us * NSEC_PER_USEC), - HRTIMER_MODE_REL_PINNED); - if (ret) - pr_err("Failed to register slack timer (%d) %d\n", - slack_us, ret); - } - - return ret; -} - -static enum hrtimer_restart msm_mpd_slack_timer(struct hrtimer *timer) -{ - unsigned long flags; - - trace_printk("mpd:slack_timer_fired!\n"); - - spin_lock_irqsave(&rq_avg_lock, flags); - if (msm_mpd.data.event == MSM_DCVS_SCM_RUNQ_UPDATE) - goto out; - - msm_mpd.data.nr = 0; - msm_mpd.data.event = MSM_DCVS_SCM_MPD_QOS_TIMER_EXPIRED; - wake_up(&msm_mpd.wait_q); -out: - spin_unlock_irqrestore(&rq_avg_lock, flags); - return HRTIMER_NORESTART; -} - -static int msm_mpd_idle_notifier(struct notifier_block *self, - unsigned long cmd, void *v) -{ - int cpu = smp_processor_id(); - unsigned long flags; - - switch (cmd) { - case CPU_PM_EXIT: - spin_lock_irqsave(&rq_avg_lock, flags); - hrtimer_start(&per_cpu(rq_avg_poll_timer, cpu), - msm_mpd.next_update, - HRTIMER_MODE_ABS_PINNED); - spin_unlock_irqrestore(&rq_avg_lock, flags); - break; - case CPU_PM_ENTER: - hrtimer_cancel(&per_cpu(rq_avg_poll_timer, cpu)); - break; - default: - break; - } - - return NOTIFY_OK; -} - -static int msm_mpd_hotplug_notifier(struct notifier_block *self, - unsigned long action, void *hcpu) -{ - int cpu = (int)hcpu; - unsigned long flags; - - switch (action & (~CPU_TASKS_FROZEN)) { - case CPU_STARTING: - spin_lock_irqsave(&rq_avg_lock, flags); - hrtimer_start(&per_cpu(rq_avg_poll_timer, cpu), - msm_mpd.next_update, - HRTIMER_MODE_ABS_PINNED); - spin_unlock_irqrestore(&rq_avg_lock, flags); - break; - default: - break; - } - - return NOTIFY_OK; -} - -static struct notifier_block msm_mpd_idle_nb = { - .notifier_call = msm_mpd_idle_notifier, -}; - -static struct notifier_block msm_mpd_hotplug_nb = { - .notifier_call = msm_mpd_hotplug_notifier, -}; - -static int __cpuinit msm_mpd_do_hotplug(void *data) -{ - int *event = (int *)data; - int cpu; - - while (1) { - msm_dcvs_update_algo_params(); - wait_event(msm_mpd.wait_hpq, *event || kthread_should_stop()); - if (kthread_should_stop()) - break; - - msm_mpd.hpupdate = HPUPDATE_IN_PROGRESS; - /* - * Bring online any offline cores, then offline any online - * cores. Whenever a core is off/onlined restart the procedure - * in case a new core is desired to be brought online in the - * mean time. - */ -restart: - for_each_possible_cpu(cpu) { - if ((atomic_read(&msm_mpd.algo_cpu_mask) & (1 << cpu)) - && !cpu_online(cpu)) { - bring_up_cpu(cpu); - if (cpu_online(cpu)) - goto restart; - } - } - - if (ktime_to_ns(ktime_sub(ktime_get(), last_down_time)) > - 100 * NSEC_PER_MSEC) - for_each_possible_cpu(cpu) - if (!(atomic_read(&msm_mpd.algo_cpu_mask) & - (1 << cpu)) && cpu_online(cpu)) { - bring_down_cpu(cpu); - last_down_time = ktime_get(); - break; - } - msm_mpd.hpupdate = HPUPDATE_WAITING; - msm_dcvs_apply_gpu_floor(0); - } - - return 0; -} - -static int msm_mpd_do_update_scm(void *data) -{ - struct msm_mpd_scm_data *scm_data = (struct msm_mpd_scm_data *)data; - unsigned long flags; - enum msm_dcvs_scm_event event; - int nr; - - while (1) { - wait_event(msm_mpd.wait_q, - msm_mpd.data.event == MSM_DCVS_SCM_MPD_QOS_TIMER_EXPIRED - || msm_mpd.data.event == MSM_DCVS_SCM_RUNQ_UPDATE - || kthread_should_stop()); - - if (kthread_should_stop()) - break; - - spin_lock_irqsave(&rq_avg_lock, flags); - event = scm_data->event; - nr = scm_data->nr; - scm_data->event = 0; - scm_data->nr = 0; - spin_unlock_irqrestore(&rq_avg_lock, flags); - - msm_mpd_update_scm(event, nr); - } - return 0; -} - -static int __ref msm_mpd_set_enabled(uint32_t enable) -{ - int ret = 0; - int ret0 = 0; - int ret1 = 0; - int cpu; - static uint32_t last_enable; - - enable = (enable > 0) ? 1 : 0; - if (last_enable == enable) - return ret; - - if (enable) { - ret = msm_mpd_scm_set_algo_params(&msm_mpd.mp_param); - if (ret) { - pr_err("Error(%d): msm_mpd_scm_set_algo_params failed\n", - ret); - return ret; - } - } - - ret = msm_dcvs_scm_event(0, MSM_DCVS_SCM_MPD_ENABLE, enable, 0, - &ret0, &ret1); - if (ret) { - pr_err("Error(%d) %s MP Decision\n", - ret, (enable ? "enabling" : "disabling")); - } else { - last_enable = enable; - last_nr = 0; - } - if (enable) { - msm_mpd.next_update = ktime_add_ns(ktime_get(), - (msm_mpd.rq_avg_poll_ms * NSEC_PER_MSEC)); - msm_mpd.task = kthread_run(msm_mpd_do_update_scm, - &msm_mpd.data, "msm_mpdecision"); - if (IS_ERR(msm_mpd.task)) - return -EFAULT; - - msm_mpd.hptask = kthread_run(msm_mpd_do_hotplug, - &msm_mpd.hpupdate, "msm_hp"); - if (IS_ERR(msm_mpd.hptask)) - return -EFAULT; - - for_each_online_cpu(cpu) - hrtimer_start(&per_cpu(rq_avg_poll_timer, cpu), - msm_mpd.next_update, - HRTIMER_MODE_ABS_PINNED); - cpu_pm_register_notifier(&msm_mpd_idle_nb); - register_cpu_notifier(&msm_mpd_hotplug_nb); - msm_mpd.enabled = 1; - } else { - for_each_online_cpu(cpu) - hrtimer_cancel(&per_cpu(rq_avg_poll_timer, cpu)); - kthread_stop(msm_mpd.hptask); - kthread_stop(msm_mpd.task); - cpu_pm_unregister_notifier(&msm_mpd_idle_nb); - unregister_cpu_notifier(&msm_mpd_hotplug_nb); - msm_mpd.enabled = 0; - } - - return ret; -} - -static int msm_mpd_set_rq_avg_poll_ms(uint32_t val) -{ - /* - * No need to do anything. Just let the timer set its own next poll - * interval when it next fires. - */ - msm_mpd.rq_avg_poll_ms = val; - return 0; -} - -static int msm_mpd_set_iowait_threshold_pct(uint32_t val) -{ - /* - * No need to do anything. Just let the timer set its own next poll - * interval when it next fires. - */ - msm_mpd.iowait_threshold_pct = val; - return 0; -} - -static int msm_mpd_set_rq_avg_divide(uint32_t val) -{ - /* - * No need to do anything. New value will be used next time - * the decision is made as to whether to update tz. - */ - - if (val == 0) - return -EINVAL; - - msm_mpd.rq_avg_divide = val; - return 0; -} - -#define MPD_ALGO_PARAM(_name, _param) \ -static ssize_t msm_mpd_attr_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ -{ \ - return snprintf(buf, PAGE_SIZE, "%d\n", _param); \ -} \ -static ssize_t msm_mpd_attr_##_name##_store(struct kobject *kobj, \ - struct kobj_attribute *attr, const char *buf, size_t count) \ -{ \ - int ret = 0; \ - uint32_t val; \ - uint32_t old_val; \ - mutex_lock(&msm_mpd.lock); \ - ret = kstrtouint(buf, 10, &val); \ - if (ret) { \ - pr_err("Invalid input %s for %s %d\n", \ - buf, __stringify(_name), ret);\ - return 0; \ - } \ - old_val = _param; \ - _param = val; \ - ret = msm_mpd_scm_set_algo_params(&msm_mpd.mp_param); \ - if (ret) { \ - pr_err("Error %d returned when setting algo param %s to %d\n",\ - ret, __stringify(_name), val); \ - _param = old_val; \ - } \ - mutex_unlock(&msm_mpd.lock); \ - return count; \ -} - -#define MPD_PARAM(_name, _param) \ -static ssize_t msm_mpd_attr_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ -{ \ - return snprintf(buf, PAGE_SIZE, "%d\n", _param); \ -} \ -static ssize_t msm_mpd_attr_##_name##_store(struct kobject *kobj, \ - struct kobj_attribute *attr, const char *buf, size_t count) \ -{ \ - int ret = 0; \ - uint32_t val; \ - uint32_t old_val; \ - mutex_lock(&msm_mpd.lock); \ - ret = kstrtouint(buf, 10, &val); \ - if (ret) { \ - pr_err("Invalid input %s for %s %d\n", \ - buf, __stringify(_name), ret);\ - return 0; \ - } \ - old_val = _param; \ - ret = msm_mpd_set_##_name(val); \ - if (ret) { \ - pr_err("Error %d returned when setting algo param %s to %d\n",\ - ret, __stringify(_name), val); \ - _param = old_val; \ - } \ - mutex_unlock(&msm_mpd.lock); \ - return count; \ -} - -#define MPD_RW_ATTRIB(i, _name) \ - msm_mpd.attrib._name.attr.name = __stringify(_name); \ - msm_mpd.attrib._name.attr.mode = S_IRUGO | S_IWUSR; \ - msm_mpd.attrib._name.show = msm_mpd_attr_##_name##_show; \ - msm_mpd.attrib._name.store = msm_mpd_attr_##_name##_store; \ - msm_mpd.attrib.attrib_group.attrs[i] = &msm_mpd.attrib._name.attr; - -MPD_PARAM(enabled, msm_mpd.enabled); -MPD_PARAM(rq_avg_poll_ms, msm_mpd.rq_avg_poll_ms); -MPD_PARAM(iowait_threshold_pct, msm_mpd.iowait_threshold_pct); -MPD_PARAM(rq_avg_divide, msm_mpd.rq_avg_divide); -MPD_ALGO_PARAM(em_win_size_min_us, msm_mpd.mp_param.em_win_size_min_us); -MPD_ALGO_PARAM(em_win_size_max_us, msm_mpd.mp_param.em_win_size_max_us); -MPD_ALGO_PARAM(em_max_util_pct, msm_mpd.mp_param.em_max_util_pct); -MPD_ALGO_PARAM(mp_em_rounding_point_min, - msm_mpd.mp_param.mp_em_rounding_point_min); -MPD_ALGO_PARAM(mp_em_rounding_point_max, - msm_mpd.mp_param.mp_em_rounding_point_max); -MPD_ALGO_PARAM(online_util_pct_min, msm_mpd.mp_param.online_util_pct_min); -MPD_ALGO_PARAM(online_util_pct_max, msm_mpd.mp_param.online_util_pct_max); -MPD_ALGO_PARAM(slack_time_min_us, msm_mpd.mp_param.slack_time_min_us); -MPD_ALGO_PARAM(slack_time_max_us, msm_mpd.mp_param.slack_time_max_us); -MPD_ALGO_PARAM(hp_up_max_ms, hp_latencies.hp_up_max_ms); -MPD_ALGO_PARAM(hp_up_ms, hp_latencies.hp_up_ms); -MPD_ALGO_PARAM(hp_up_count, hp_latencies.hp_up_count); -MPD_ALGO_PARAM(hp_dw_max_ms, hp_latencies.hp_dw_max_ms); -MPD_ALGO_PARAM(hp_dw_ms, hp_latencies.hp_dw_ms); -MPD_ALGO_PARAM(hp_dw_count, hp_latencies.hp_dw_count); - -static int msm_mpd_probe(struct platform_device *pdev) -{ - struct kobject *module_kobj = NULL; - int ret = 0; - const int attr_count = 20; - struct msm_mpd_algo_param *param = NULL; - - param = pdev->dev.platform_data; - - module_kobj = kset_find_obj(module_kset, KBUILD_MODNAME); - if (!module_kobj) { - pr_err("Cannot find kobject for module %s\n", KBUILD_MODNAME); - ret = -ENOENT; - goto done; - } - - msm_mpd.attrib.attrib_group.attrs = - kzalloc(attr_count * sizeof(struct attribute *), GFP_KERNEL); - if (!msm_mpd.attrib.attrib_group.attrs) { - ret = -ENOMEM; - goto done; - } - - MPD_RW_ATTRIB(0, enabled); - MPD_RW_ATTRIB(1, rq_avg_poll_ms); - MPD_RW_ATTRIB(2, iowait_threshold_pct); - MPD_RW_ATTRIB(3, rq_avg_divide); - MPD_RW_ATTRIB(4, em_win_size_min_us); - MPD_RW_ATTRIB(5, em_win_size_max_us); - MPD_RW_ATTRIB(6, em_max_util_pct); - MPD_RW_ATTRIB(7, mp_em_rounding_point_min); - MPD_RW_ATTRIB(8, mp_em_rounding_point_max); - MPD_RW_ATTRIB(9, online_util_pct_min); - MPD_RW_ATTRIB(10, online_util_pct_max); - MPD_RW_ATTRIB(11, slack_time_min_us); - MPD_RW_ATTRIB(12, slack_time_max_us); - MPD_RW_ATTRIB(13, hp_up_max_ms); - MPD_RW_ATTRIB(14, hp_up_ms); - MPD_RW_ATTRIB(15, hp_up_count); - MPD_RW_ATTRIB(16, hp_dw_max_ms); - MPD_RW_ATTRIB(17, hp_dw_ms); - MPD_RW_ATTRIB(18, hp_dw_count); - - msm_mpd.attrib.attrib_group.attrs[19] = NULL; - ret = sysfs_create_group(module_kobj, &msm_mpd.attrib.attrib_group); - if (ret) - pr_err("Unable to create sysfs objects :%d\n", ret); - - msm_mpd.rq_avg_poll_ms = DEFAULT_RQ_AVG_POLL_MS; - msm_mpd.rq_avg_divide = DEFAULT_RQ_AVG_DIVIDE; - - memcpy(&msm_mpd.mp_param, param, sizeof(struct msm_mpd_algo_param)); - - debugfs_base = debugfs_create_dir("msm_mpdecision", NULL); - if (!debugfs_base) { - pr_err("Cannot create debugfs base msm_mpdecision\n"); - ret = -ENOENT; - goto done; - } - -done: - if (ret && debugfs_base) - debugfs_remove(debugfs_base); - - return ret; -} - -static int msm_mpd_remove(struct platform_device *pdev) -{ - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver msm_mpd_driver = { - .probe = msm_mpd_probe, - .remove = msm_mpd_remove, - .driver = { - .name = "msm_mpdecision", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_mpdecision_init(void) -{ - int cpu; - if (!msm_mpd_enabled) { - pr_info("Not enabled\n"); - return 0; - } - - num_present_hundreds = 100 * num_present_cpus(); - - hrtimer_init(&msm_mpd.slack_timer, CLOCK_MONOTONIC, - HRTIMER_MODE_REL_PINNED); - msm_mpd.slack_timer.function = msm_mpd_slack_timer; - - for_each_possible_cpu(cpu) { - hrtimer_init(&per_cpu(rq_avg_poll_timer, cpu), - CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED); - per_cpu(rq_avg_poll_timer, cpu).function - = msm_mpd_rq_avg_poll_timer; - } - mutex_init(&msm_mpd.lock); - init_waitqueue_head(&msm_mpd.wait_q); - init_waitqueue_head(&msm_mpd.wait_hpq); - return platform_driver_register(&msm_mpd_driver); -} -late_initcall(msm_mpdecision_init); diff --git a/arch/arm/mach-msm/msm_vibrator.c b/arch/arm/mach-msm/msm_vibrator.c deleted file mode 100644 index 9f811ac217228d11c08e389ce74f677fb5ecdb4c..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/msm_vibrator.c +++ /dev/null @@ -1,162 +0,0 @@ -/* include/asm/mach-msm/htc_pwrsink.h - * - * Copyright (C) 2008 HTC Corporation. - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2011 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include "pmic.h" -#include "timed_output.h" - -#include - -#define PM_LIBPROG 0x30000061 -#if (CONFIG_MSM_AMSS_VERSION == 6220) || (CONFIG_MSM_AMSS_VERSION == 6225) -#define PM_LIBVERS 0xfb837d0b -#else -#define PM_LIBVERS 0x10001 -#endif - -#define HTC_PROCEDURE_SET_VIB_ON_OFF 21 -#define PMIC_VIBRATOR_LEVEL (3000) - -static struct work_struct work_vibrator_on; -static struct work_struct work_vibrator_off; -static struct hrtimer vibe_timer; - -#ifdef CONFIG_PM8XXX_RPC_VIBRATOR -static void set_pmic_vibrator(int on) -{ - int rc; - - rc = pmic_vib_mot_set_mode(PM_VIB_MOT_MODE__MANUAL); - if (rc) { - pr_err("%s: Vibrator set mode failed", __func__); - return; - } - - if (on) - rc = pmic_vib_mot_set_volt(PMIC_VIBRATOR_LEVEL); - else - rc = pmic_vib_mot_set_volt(0); - - if (rc) - pr_err("%s: Vibrator set voltage level failed", __func__); -} -#else -static void set_pmic_vibrator(int on) -{ - static struct msm_rpc_endpoint *vib_endpoint; - struct set_vib_on_off_req { - struct rpc_request_hdr hdr; - uint32_t data; - } req; - - if (!vib_endpoint) { - vib_endpoint = msm_rpc_connect(PM_LIBPROG, PM_LIBVERS, 0); - if (IS_ERR(vib_endpoint)) { - printk(KERN_ERR "init vib rpc failed!\n"); - vib_endpoint = 0; - return; - } - } - - - if (on) - req.data = cpu_to_be32(PMIC_VIBRATOR_LEVEL); - else - req.data = cpu_to_be32(0); - - msm_rpc_call(vib_endpoint, HTC_PROCEDURE_SET_VIB_ON_OFF, &req, - sizeof(req), 5 * HZ); -} -#endif - -static void pmic_vibrator_on(struct work_struct *work) -{ - set_pmic_vibrator(1); -} - -static void pmic_vibrator_off(struct work_struct *work) -{ - set_pmic_vibrator(0); -} - -static void timed_vibrator_on(struct timed_output_dev *sdev) -{ - schedule_work(&work_vibrator_on); -} - -static void timed_vibrator_off(struct timed_output_dev *sdev) -{ - schedule_work(&work_vibrator_off); -} - -static void vibrator_enable(struct timed_output_dev *dev, int value) -{ - hrtimer_cancel(&vibe_timer); - - if (value == 0) - timed_vibrator_off(dev); - else { - value = (value > 15000 ? 15000 : value); - - timed_vibrator_on(dev); - - hrtimer_start(&vibe_timer, - ktime_set(value / 1000, (value % 1000) * 1000000), - HRTIMER_MODE_REL); - } -} - -static int vibrator_get_time(struct timed_output_dev *dev) -{ - if (hrtimer_active(&vibe_timer)) { - ktime_t r = hrtimer_get_remaining(&vibe_timer); - struct timeval t = ktime_to_timeval(r); - return t.tv_sec * 1000 + t.tv_usec / 1000; - } - return 0; -} - -static enum hrtimer_restart vibrator_timer_func(struct hrtimer *timer) -{ - timed_vibrator_off(NULL); - return HRTIMER_NORESTART; -} - -static struct timed_output_dev pmic_vibrator = { - .name = "vibrator", - .get_time = vibrator_get_time, - .enable = vibrator_enable, -}; - -void __init msm_init_pmic_vibrator(void) -{ - INIT_WORK(&work_vibrator_on, pmic_vibrator_on); - INIT_WORK(&work_vibrator_off, pmic_vibrator_off); - - hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - vibe_timer.function = vibrator_timer_func; - - timed_output_dev_register(&pmic_vibrator); -} - -MODULE_DESCRIPTION("timed output pmic vibrator device"); -MODULE_LICENSE("GPL"); - diff --git a/arch/arm/mach-msm/oem_rapi_client.c b/arch/arm/mach-msm/oem_rapi_client.c deleted file mode 100644 index 2e1e74102d26afe19883baaa6b7c3f03b995e46d..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/oem_rapi_client.c +++ /dev/null @@ -1,357 +0,0 @@ -/* Copyright (c) 2009-2010, 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. - * - */ - -/* - * OEM RAPI CLIENT Driver source file - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define OEM_RAPI_PROG 0x3000006B -#define OEM_RAPI_VERS 0x00010001 - -#define OEM_RAPI_NULL_PROC 0 -#define OEM_RAPI_RPC_GLUE_CODE_INFO_REMOTE_PROC 1 -#define OEM_RAPI_STREAMING_FUNCTION_PROC 2 - -#define OEM_RAPI_CLIENT_MAX_OUT_BUFF_SIZE 128 - -static struct msm_rpc_client *rpc_client; -static uint32_t open_count; -static DEFINE_MUTEX(oem_rapi_client_lock); - -/* TODO: check where to allocate memory for return */ -static int oem_rapi_client_cb(struct msm_rpc_client *client, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - uint32_t cb_id, accept_status; - int rc; - void *cb_func; - uint32_t temp; - - struct oem_rapi_client_streaming_func_cb_arg arg; - struct oem_rapi_client_streaming_func_cb_ret ret; - - arg.input = NULL; - ret.out_len = NULL; - ret.output = NULL; - - xdr_recv_uint32(xdr, &cb_id); /* cb_id */ - xdr_recv_uint32(xdr, &arg.event); /* enum */ - xdr_recv_uint32(xdr, (uint32_t *)(&arg.handle)); /* handle */ - xdr_recv_uint32(xdr, &arg.in_len); /* in_len */ - xdr_recv_bytes(xdr, (void **)&arg.input, &temp); /* input */ - xdr_recv_uint32(xdr, &arg.out_len_valid); /* out_len */ - if (arg.out_len_valid) { - ret.out_len = kmalloc(sizeof(*ret.out_len), GFP_KERNEL); - if (!ret.out_len) { - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - goto oem_rapi_send_ack; - } - } - - xdr_recv_uint32(xdr, &arg.output_valid); /* out */ - if (arg.output_valid) { - xdr_recv_uint32(xdr, &arg.output_size); /* ouput_size */ - - ret.output = kmalloc(arg.output_size, GFP_KERNEL); - if (!ret.output) { - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - goto oem_rapi_send_ack; - } - } - - cb_func = msm_rpc_get_cb_func(client, cb_id); - if (cb_func) { - rc = ((int (*)(struct oem_rapi_client_streaming_func_cb_arg *, - struct oem_rapi_client_streaming_func_cb_ret *)) - cb_func)(&arg, &ret); - if (rc) - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - else - accept_status = RPC_ACCEPTSTAT_SUCCESS; - } else - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - - oem_rapi_send_ack: - xdr_start_accepted_reply(xdr, accept_status); - - if (accept_status == RPC_ACCEPTSTAT_SUCCESS) { - uint32_t temp = sizeof(uint32_t); - xdr_send_pointer(xdr, (void **)&(ret.out_len), temp, - xdr_send_uint32); - - /* output */ - if (ret.output && ret.out_len) - xdr_send_bytes(xdr, (const void **)&ret.output, - ret.out_len); - else { - temp = 0; - xdr_send_uint32(xdr, &temp); - } - } - rc = xdr_send_msg(xdr); - if (rc) - pr_err("%s: sending reply failed: %d\n", __func__, rc); - - kfree(arg.input); - kfree(ret.out_len); - kfree(ret.output); - - return 0; -} - -static int oem_rapi_client_streaming_function_arg(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, - void *data) -{ - int cb_id; - struct oem_rapi_client_streaming_func_arg *arg = data; - - cb_id = msm_rpc_add_cb_func(client, (void *)arg->cb_func); - if ((cb_id < 0) && (cb_id != MSM_RPC_CLIENT_NULL_CB_ID)) - return cb_id; - - xdr_send_uint32(xdr, &arg->event); /* enum */ - xdr_send_uint32(xdr, &cb_id); /* cb_id */ - xdr_send_uint32(xdr, (uint32_t *)(&arg->handle)); /* handle */ - xdr_send_uint32(xdr, &arg->in_len); /* in_len */ - xdr_send_bytes(xdr, (const void **)&arg->input, - &arg->in_len); /* input */ - xdr_send_uint32(xdr, &arg->out_len_valid); /* out_len */ - xdr_send_uint32(xdr, &arg->output_valid); /* output */ - - /* output_size */ - if (arg->output_valid) - xdr_send_uint32(xdr, &arg->output_size); - - return 0; -} - -static int oem_rapi_client_streaming_function_ret(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, - void *data) -{ - struct oem_rapi_client_streaming_func_ret *ret = data; - uint32_t temp; - - /* out_len */ - xdr_recv_pointer(xdr, (void **)&(ret->out_len), sizeof(uint32_t), - xdr_recv_uint32); - - /* output */ - if (ret->out_len && *ret->out_len) - xdr_recv_bytes(xdr, (void **)&ret->output, &temp); - - return 0; -} - -int oem_rapi_client_streaming_function( - struct msm_rpc_client *client, - struct oem_rapi_client_streaming_func_arg *arg, - struct oem_rapi_client_streaming_func_ret *ret) -{ - return msm_rpc_client_req2(client, - OEM_RAPI_STREAMING_FUNCTION_PROC, - oem_rapi_client_streaming_function_arg, arg, - oem_rapi_client_streaming_function_ret, - ret, -1); -} -EXPORT_SYMBOL(oem_rapi_client_streaming_function); - -int oem_rapi_client_close(void) -{ - mutex_lock(&oem_rapi_client_lock); - if (--open_count == 0) { - msm_rpc_unregister_client(rpc_client); - pr_info("%s: disconnected from remote oem rapi server\n", - __func__); - } - mutex_unlock(&oem_rapi_client_lock); - return 0; -} -EXPORT_SYMBOL(oem_rapi_client_close); - -struct msm_rpc_client *oem_rapi_client_init(void) -{ - mutex_lock(&oem_rapi_client_lock); - if (open_count == 0) { - rpc_client = msm_rpc_register_client2("oemrapiclient", - OEM_RAPI_PROG, - OEM_RAPI_VERS, 0, - oem_rapi_client_cb); - if (!IS_ERR(rpc_client)) - open_count++; - } - mutex_unlock(&oem_rapi_client_lock); - return rpc_client; -} -EXPORT_SYMBOL(oem_rapi_client_init); - -#if defined(CONFIG_DEBUG_FS) - -static struct dentry *dent; -static int oem_rapi_client_test_res; - -static int oem_rapi_client_null(struct msm_rpc_client *client, - void *arg, void *ret) -{ - return msm_rpc_client_req2(client, OEM_RAPI_NULL_PROC, - NULL, NULL, NULL, NULL, -1); -} - -static int oem_rapi_client_test_streaming_cb_func( - struct oem_rapi_client_streaming_func_cb_arg *arg, - struct oem_rapi_client_streaming_func_cb_ret *ret) -{ - uint32_t size; - - size = (arg->in_len < OEM_RAPI_CLIENT_MAX_OUT_BUFF_SIZE) ? - arg->in_len : OEM_RAPI_CLIENT_MAX_OUT_BUFF_SIZE; - - if (ret->out_len != 0) - *ret->out_len = size; - - if (ret->output != 0) - memcpy(ret->output, arg->input, size); - - return 0; -} - -static ssize_t debug_read(struct file *fp, char __user *buf, - size_t count, loff_t *pos) -{ - char _buf[16]; - - snprintf(_buf, sizeof(_buf), "%i\n", oem_rapi_client_test_res); - - return simple_read_from_buffer(buf, count, pos, _buf, strlen(_buf)); -} - -static ssize_t debug_write(struct file *fp, const char __user *buf, - size_t count, loff_t *pos) -{ - char input[OEM_RAPI_CLIENT_MAX_OUT_BUFF_SIZE]; - struct oem_rapi_client_streaming_func_arg arg; - struct oem_rapi_client_streaming_func_ret ret; - - unsigned char cmd[64]; - int len; - - if (count < 1) - return 0; - - len = count > 63 ? 63 : count; - - if (copy_from_user(cmd, buf, len)) - return -EFAULT; - - cmd[len] = 0; - - if (cmd[len-1] == '\n') { - cmd[len-1] = 0; - len--; - } - - if (!strncmp(cmd, "null", 64)) { - oem_rapi_client_test_res = oem_rapi_client_null(rpc_client, - NULL, NULL); - } else if (!strncmp(cmd, "streaming_func", 64)) { - memset(input, 5, 16); - arg.event = 0; - arg.cb_func = oem_rapi_client_test_streaming_cb_func; - arg.handle = (void *)20; - arg.in_len = 16; - arg.input = input; - arg.out_len_valid = 1; - arg.output_valid = 1; - arg.output_size = OEM_RAPI_CLIENT_MAX_OUT_BUFF_SIZE; - ret.out_len = NULL; - ret.output = NULL; - - oem_rapi_client_test_res = oem_rapi_client_streaming_function( - rpc_client, &arg, &ret); - - kfree(ret.out_len); - kfree(ret.output); - - } else - oem_rapi_client_test_res = -EINVAL; - - if (oem_rapi_client_test_res) - pr_err("oem rapi client test fail %d\n", - oem_rapi_client_test_res); - else - pr_info("oem rapi client test passed\n"); - - return count; -} - -static int debug_release(struct inode *ip, struct file *fp) -{ - return oem_rapi_client_close(); -} - -static int debug_open(struct inode *ip, struct file *fp) -{ - struct msm_rpc_client *client; - client = oem_rapi_client_init(); - if (IS_ERR(client)) { - pr_err("%s: couldn't open oem rapi client\n", __func__); - return PTR_ERR(client); - } else - pr_info("%s: connected to remote oem rapi server\n", __func__); - - return 0; -} - -static const struct file_operations debug_ops = { - .owner = THIS_MODULE, - .open = debug_open, - .release = debug_release, - .read = debug_read, - .write = debug_write, -}; - -static void __exit oem_rapi_client_mod_exit(void) -{ - debugfs_remove(dent); -} - -static int __init oem_rapi_client_mod_init(void) -{ - dent = debugfs_create_file("oem_rapi", 0444, 0, NULL, &debug_ops); - open_count = 0; - oem_rapi_client_test_res = -1; - return 0; -} - -module_init(oem_rapi_client_mod_init); -module_exit(oem_rapi_client_mod_exit); - -#endif - -MODULE_DESCRIPTION("OEM RAPI CLIENT Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-dsps.c b/arch/arm/mach-msm/pil-dsps.c deleted file mode 100644 index 465edaae660cab33a6fe4f11ec12920428e29fc4..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-dsps.c +++ /dev/null @@ -1,380 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "peripheral-loader.h" -#include "scm-pas.h" - -#define PPSS_RESET 0x2594 -#define PPSS_RESET_PROC_RESET 0x2 -#define PPSS_RESET_RESET 0x1 -#define PPSS_PROC_CLK_CTL 0x2588 -#define CLK_BRANCH_ENA 0x10 -#define PPSS_HCLK_CTL 0x2580 -#define CLK_HALT_DFAB_STATE 0x2FC8 - -#define PPSS_WDOG_UNMASKED_INT_EN 0x1808 - -struct dsps_data { - void __iomem *base; - struct pil_desc desc; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; - int crash; - int wdog_irq; - atomic_t wd_crash; - atomic_t crash_in_progress; - void __iomem *ppss_base; - - void *ramdump_dev; - - void *smem_ramdump_dev; - struct ramdump_segment smem_ramdump_segments[1]; -}; - -#define desc_to_drv(d) container_of(d, struct dsps_data, subsys_desc) -#define pil_to_drv(d) container_of(d, struct dsps_data, desc) - -static int init_image_dsps(struct pil_desc *pil, const u8 *metadata, - size_t size) -{ - struct dsps_data *drv = pil_to_drv(pil); - - /* Bring memory and bus interface out of reset */ - writel_relaxed(PPSS_RESET_PROC_RESET, drv->base + PPSS_RESET); - writel_relaxed(CLK_BRANCH_ENA, drv->base + PPSS_HCLK_CTL); - mb(); - return 0; -} - -static int reset_dsps(struct pil_desc *pil) -{ - struct dsps_data *drv = pil_to_drv(pil); - - writel_relaxed(CLK_BRANCH_ENA, drv->base + PPSS_PROC_CLK_CTL); - while (readl_relaxed(drv->base + CLK_HALT_DFAB_STATE) & BIT(18)) - cpu_relax(); - /* Bring DSPS out of reset */ - writel_relaxed(0x0, drv->base + PPSS_RESET); - return 0; -} - -static int shutdown_dsps(struct pil_desc *pil) -{ - struct dsps_data *drv = pil_to_drv(pil); - - writel_relaxed(PPSS_RESET_PROC_RESET | PPSS_RESET_RESET, - drv->base + PPSS_RESET); - usleep_range(1000, 2000); - writel_relaxed(PPSS_RESET_PROC_RESET, drv->base + PPSS_RESET); - writel_relaxed(0x0, drv->base + PPSS_PROC_CLK_CTL); - return 0; -} - -struct pil_reset_ops pil_dsps_ops = { - .init_image = init_image_dsps, - .auth_and_reset = reset_dsps, - .shutdown = shutdown_dsps, -}; - -static int init_image_dsps_trusted(struct pil_desc *pil, const u8 *metadata, - size_t size) -{ - return pas_init_image(PAS_DSPS, metadata, size); -} - -static int reset_dsps_trusted(struct pil_desc *pil) -{ - return pas_auth_and_reset(PAS_DSPS); -} - -static int shutdown_dsps_trusted(struct pil_desc *pil) -{ - return pas_shutdown(PAS_DSPS); -} - -struct pil_reset_ops pil_dsps_ops_trusted = { - .init_image = init_image_dsps_trusted, - .auth_and_reset = reset_dsps_trusted, - .shutdown = shutdown_dsps_trusted, -}; - -static void dsps_log_sfr(void) -{ - const char dflt_reason[] = "Died too early due to unknown reason"; - char *smem_reset_reason; - unsigned smem_reset_size; - - smem_reset_reason = smem_get_entry(SMEM_SSR_REASON_DSPS0, - &smem_reset_size); - if (smem_reset_reason != NULL && smem_reset_reason[0] != 0) { - smem_reset_reason[smem_reset_size-1] = 0; - pr_err("%s: DSPS failure: %s\nResetting DSPS\n", - __func__, smem_reset_reason); - memset(smem_reset_reason, 0, smem_reset_size); - wmb(); - } else - pr_err("%s: DSPS failure: %s\nResetting DSPS\n", - __func__, dflt_reason); -} - - -static void dsps_restart_handler(struct dsps_data *drv) -{ - if (atomic_add_return(1, &drv->crash_in_progress) > 1) { - pr_err("%s: DSPS already resetting. Count %d\n", __func__, - atomic_read(&drv->crash_in_progress)); - } else { - subsystem_restart_dev(drv->subsys); - } -} - -static void dsps_smsm_state_cb(void *data, uint32_t old_state, - uint32_t new_state) -{ - struct dsps_data *drv = data; - - if (drv->crash == 1) { - pr_debug("SMSM_RESET state change ignored\n"); - drv->crash = 0; - } else if (new_state & SMSM_RESET) { - dsps_log_sfr(); - dsps_restart_handler(drv); - } -} - -static int dsps_shutdown(const struct subsys_desc *desc, bool force_stop) -{ - struct dsps_data *drv = desc_to_drv(desc); - - if (force_stop) { - if (drv->ppss_base) { - writel_relaxed(0, drv->ppss_base + - PPSS_WDOG_UNMASKED_INT_EN); - /* Make sure wdog is disabled before shutting down */ - mb(); - } - } - disable_irq_nosync(drv->wdog_irq); - pil_shutdown(&drv->desc); - return 0; -} - -static int dsps_powerup(const struct subsys_desc *desc) -{ - struct dsps_data *drv = desc_to_drv(desc); - - pil_boot(&drv->desc); - atomic_set(&drv->crash_in_progress, 0); - enable_irq(drv->wdog_irq); - - return 0; -} - -static int dsps_ramdump(int enable, const struct subsys_desc *desc) -{ - int ret; - struct dsps_data *drv = desc_to_drv(desc); - - if (!enable) - return 0; - - ret = pil_do_ramdump(&drv->desc, drv->ramdump_dev); - if (ret < 0) { - pr_err("%s: Unable to dump DSPS memory (rc = %d).\n", - __func__, ret); - return ret; - } - ret = do_elf_ramdump(drv->smem_ramdump_dev, drv->smem_ramdump_segments, - ARRAY_SIZE(drv->smem_ramdump_segments)); - if (ret < 0) { - pr_err("%s: Unable to dump smem memory (rc = %d).\n", - __func__, ret); - return ret; - } - return 0; -} - -static void dsps_crash_shutdown(const struct subsys_desc *desc) -{ - struct dsps_data *drv = desc_to_drv(desc); - - disable_irq_nosync(drv->wdog_irq); - drv->crash = 1; - smsm_change_state(SMSM_DSPS_STATE, SMSM_RESET, SMSM_RESET); -} - -static irqreturn_t dsps_wdog_bite_irq(int irq, void *dev_id) -{ - struct dsps_data *drv = dev_id; - - atomic_set(&drv->wd_crash, 1); - dsps_log_sfr(); - dsps_restart_handler(drv); - return IRQ_HANDLED; -} - -static int pil_dsps_driver_probe(struct platform_device *pdev) -{ - struct dsps_data *drv; - struct pil_desc *desc; - struct resource *res; - int ret; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -EINVAL; - drv->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!drv->base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (res) { - drv->ppss_base = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); - if (!drv->ppss_base) - return -ENOMEM; - } - - desc = &drv->desc; - desc->name = pdev->dev.platform_data; - desc->dev = &pdev->dev; - desc->owner = THIS_MODULE; - desc->flags = PIL_SKIP_ENTRY_CHECK; - if (pas_supported(PAS_DSPS) > 0) { - desc->ops = &pil_dsps_ops_trusted; - dev_info(&pdev->dev, "using secure boot\n"); - } else { - desc->ops = &pil_dsps_ops; - dev_info(&pdev->dev, "using non-secure boot\n"); - } - ret = pil_desc_init(desc); - if (ret) - return ret; - - drv->ramdump_dev = create_ramdump_device("dsps", &pdev->dev); - if (!drv->ramdump_dev) { - ret = -ENOMEM; - goto err_ramdump; - } - - drv->smem_ramdump_segments[0].address = PHYS_OFFSET - SZ_2M; - drv->smem_ramdump_segments[0].size = SZ_2M; - drv->smem_ramdump_dev = create_ramdump_device("smem-dsps", &pdev->dev); - if (!drv->smem_ramdump_dev) { - ret = -ENOMEM; - goto err_smem_ramdump; - } - - drv->subsys_desc.name = "dsps"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.shutdown = dsps_shutdown; - drv->subsys_desc.powerup = dsps_powerup; - drv->subsys_desc.ramdump = dsps_ramdump, - drv->subsys_desc.crash_shutdown = dsps_crash_shutdown; - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - ret = PTR_ERR(drv->subsys); - goto err_subsys; - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - ret = smsm_state_cb_register(SMSM_DSPS_STATE, SMSM_RESET, - dsps_smsm_state_cb, drv); - if (ret) - goto err_smsm; - - drv->wdog_irq = platform_get_irq(pdev, 0); - if (drv->wdog_irq >= 0) { - ret = devm_request_irq(&pdev->dev, drv->wdog_irq, - dsps_wdog_bite_irq, IRQF_TRIGGER_RISING, - "dsps_wdog", drv); - if (ret) { - dev_err(&pdev->dev, "request_irq failed\n"); - goto err_smsm; - } - disable_irq(drv->wdog_irq); - } else { - drv->wdog_irq = -1; - dev_dbg(&pdev->dev, "ppss_wdog not supported\n"); - } - - return 0; - -err_smsm: - subsys_unregister(drv->subsys); -err_subsys: - destroy_ramdump_device(drv->smem_ramdump_dev); -err_smem_ramdump: - destroy_ramdump_device(drv->ramdump_dev); -err_ramdump: - pil_desc_release(desc); - return ret; -} - -static int pil_dsps_driver_exit(struct platform_device *pdev) -{ - struct dsps_data *drv = platform_get_drvdata(pdev); - smsm_state_cb_deregister(SMSM_DSPS_STATE, SMSM_RESET, - dsps_smsm_state_cb, drv); - subsys_unregister(drv->subsys); - destroy_ramdump_device(drv->smem_ramdump_dev); - destroy_ramdump_device(drv->ramdump_dev); - pil_desc_release(&drv->desc); - return 0; -} - -static struct platform_driver pil_dsps_driver = { - .probe = pil_dsps_driver_probe, - .remove = pil_dsps_driver_exit, - .driver = { - .name = "pil_dsps", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_dsps_init(void) -{ - return platform_driver_register(&pil_dsps_driver); -} -module_init(pil_dsps_init); - -static void __exit pil_dsps_exit(void) -{ - platform_driver_unregister(&pil_dsps_driver); -} -module_exit(pil_dsps_exit); - -MODULE_DESCRIPTION("Support for booting sensors (DSPS) images"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-gss.c b/arch/arm/mach-msm/pil-gss.c deleted file mode 100644 index 772a7fe9e444bcd1269da9a561f5d28058b7394d..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-gss.c +++ /dev/null @@ -1,611 +0,0 @@ -/* - * Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "peripheral-loader.h" -#include "scm-pas.h" - -#define GSS_CSR_AHB_CLK_SEL 0x0 -#define GSS_CSR_RESET 0x4 -#define GSS_CSR_CLK_BLK_CONFIG 0x8 -#define GSS_CSR_CLK_ENABLE 0xC -#define GSS_CSR_BOOT_REMAP 0x14 -#define GSS_CSR_POWER_UP_DOWN 0x18 -#define GSS_CSR_CFG_HID 0x2C - -#define GSS_SLP_CLK_CTL 0x2C60 -#define GSS_RESET 0x2C64 -#define GSS_CLAMP_ENA 0x2C68 -#define GSS_CXO_SRC_CTL 0x2C74 - -#define PLL5_STATUS 0x30F8 -#define PLL_ENA_GSS 0x3480 - -#define PLL5_VOTE BIT(5) -#define PLL_STATUS BIT(16) -#define REMAP_ENABLE BIT(16) -#define A5_POWER_STATUS BIT(4) -#define A5_POWER_ENA BIT(0) -#define NAV_POWER_ENA BIT(1) -#define XO_CLK_BRANCH_ENA BIT(0) -#define SLP_CLK_BRANCH_ENA BIT(4) -#define A5_RESET BIT(0) - -struct gss_data { - void __iomem *base; - void __iomem *qgic2_base; - void __iomem *cbase; - struct clk *xo; - struct pil_desc pil_desc; - struct miscdevice misc_dev; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; - int crash_shutdown; - int irq; - void *subsys_handle; - struct ramdump_device *ramdump_dev; - struct ramdump_device *smem_ramdump_dev; -}; - -static int make_gss_proxy_votes(struct pil_desc *pil) -{ - int ret; - struct gss_data *drv = dev_get_drvdata(pil->dev); - - ret = clk_prepare_enable(drv->xo); - if (ret) { - dev_err(pil->dev, "Failed to enable XO\n"); - return ret; - } - return 0; -} - -static void remove_gss_proxy_votes(struct pil_desc *pil) -{ - struct gss_data *drv = dev_get_drvdata(pil->dev); - clk_disable_unprepare(drv->xo); -} - -static void gss_init(struct gss_data *drv) -{ - void __iomem *base = drv->base; - void __iomem *cbase = drv->cbase; - - /* Supply clocks to GSS. */ - writel_relaxed(XO_CLK_BRANCH_ENA, cbase + GSS_CXO_SRC_CTL); - writel_relaxed(SLP_CLK_BRANCH_ENA, cbase + GSS_SLP_CLK_CTL); - - /* Deassert GSS reset and clamps. */ - writel_relaxed(0x0, cbase + GSS_RESET); - writel_relaxed(0x0, cbase + GSS_CLAMP_ENA); - mb(); - - /* - * Configure clock source and dividers for 288MHz core, 144MHz AXI and - * 72MHz AHB, all derived from the 288MHz PLL. - */ - writel_relaxed(0x341, base + GSS_CSR_CLK_BLK_CONFIG); - writel_relaxed(0x1, base + GSS_CSR_AHB_CLK_SEL); - - /* Assert all GSS resets. */ - writel_relaxed(0x7F, base + GSS_CSR_RESET); - - /* Enable all bus clocks and wait for resets to propagate. */ - writel_relaxed(0x1F, base + GSS_CSR_CLK_ENABLE); - mb(); - udelay(1); - - /* Release subsystem from reset, but leave A5 in reset. */ - writel_relaxed(A5_RESET, base + GSS_CSR_RESET); -} - -static void cfg_qgic2_bus_access(void *data) -{ - struct gss_data *drv = data; - int i; - - /* - * Apply a 8064 v1.0 workaround to configure QGIC bus access. - * This must be done from Krait 0 to configure the Master ID - * correctly. - */ - writel_relaxed(0x2, drv->base + GSS_CSR_CFG_HID); - for (i = 0; i <= 3; i++) - readl_relaxed(drv->qgic2_base); -} - -static int pil_gss_shutdown(struct pil_desc *pil) -{ - struct gss_data *drv = dev_get_drvdata(pil->dev); - void __iomem *base = drv->base; - void __iomem *cbase = drv->cbase; - u32 regval; - int ret; - - ret = clk_prepare_enable(drv->xo); - if (ret) { - dev_err(pil->dev, "Failed to enable XO\n"); - return ret; - } - - /* Make sure bus port is halted. */ - msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV); - - /* - * Vote PLL on in GSS's voting register and wait for it to enable. - * The PLL must be enable to switch the GFMUX to a low-power source. - */ - writel_relaxed(PLL5_VOTE, cbase + PLL_ENA_GSS); - while ((readl_relaxed(cbase + PLL5_STATUS) & PLL_STATUS) == 0) - cpu_relax(); - - /* Perform one-time GSS initialization. */ - gss_init(drv); - - /* Assert A5 reset. */ - regval = readl_relaxed(base + GSS_CSR_RESET); - regval |= A5_RESET; - writel_relaxed(regval, base + GSS_CSR_RESET); - - /* Power down A5 and NAV. */ - regval = readl_relaxed(base + GSS_CSR_POWER_UP_DOWN); - regval &= ~(A5_POWER_ENA|NAV_POWER_ENA); - writel_relaxed(regval, base + GSS_CSR_POWER_UP_DOWN); - - /* Select XO clock source and increase dividers to save power. */ - regval = readl_relaxed(base + GSS_CSR_CLK_BLK_CONFIG); - regval |= 0x3FF; - writel_relaxed(regval, base + GSS_CSR_CLK_BLK_CONFIG); - - /* Disable bus clocks. */ - writel_relaxed(0x1F, base + GSS_CSR_CLK_ENABLE); - - /* Clear GSS PLL votes. */ - writel_relaxed(0, cbase + PLL_ENA_GSS); - mb(); - - clk_disable_unprepare(drv->xo); - - return 0; -} - -static int pil_gss_reset(struct pil_desc *pil) -{ - struct gss_data *drv = dev_get_drvdata(pil->dev); - void __iomem *base = drv->base; - phys_addr_t start_addr = pil_get_entry_addr(pil); - void __iomem *cbase = drv->cbase; - int ret; - - /* Unhalt bus port. */ - ret = msm_bus_axi_portunhalt(MSM_BUS_MASTER_GSS_NAV); - if (ret) { - dev_err(pil->dev, "Failed to unhalt bus port\n"); - return ret; - } - - /* Vote PLL on in GSS's voting register and wait for it to enable. */ - writel_relaxed(PLL5_VOTE, cbase + PLL_ENA_GSS); - while ((readl_relaxed(cbase + PLL5_STATUS) & PLL_STATUS) == 0) - cpu_relax(); - - /* Perform GSS initialization. */ - gss_init(drv); - - /* Configure boot address and enable remap. */ - writel_relaxed(REMAP_ENABLE | (start_addr >> 16), - base + GSS_CSR_BOOT_REMAP); - - /* Power up A5 core. */ - writel_relaxed(A5_POWER_ENA, base + GSS_CSR_POWER_UP_DOWN); - while (!(readl_relaxed(base + GSS_CSR_POWER_UP_DOWN) & A5_POWER_STATUS)) - cpu_relax(); - - if (cpu_is_apq8064() && - ((SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1) && - (SOCINFO_VERSION_MINOR(socinfo_get_version()) == 0))) { - ret = smp_call_function_single(0, cfg_qgic2_bus_access, drv, 1); - if (ret) { - pr_err("Failed to configure QGIC2 bus access\n"); - pil_gss_shutdown(pil); - return ret; - } - } - - /* Release A5 from reset. */ - writel_relaxed(0x0, base + GSS_CSR_RESET); - - return 0; -} - -static struct pil_reset_ops pil_gss_ops = { - .auth_and_reset = pil_gss_reset, - .shutdown = pil_gss_shutdown, - .proxy_vote = make_gss_proxy_votes, - .proxy_unvote = remove_gss_proxy_votes, -}; - -static int pil_gss_init_image_trusted(struct pil_desc *pil, - const u8 *metadata, size_t size) -{ - return pas_init_image(PAS_GSS, metadata, size); -} - -static int pil_gss_shutdown_trusted(struct pil_desc *pil) -{ - struct gss_data *drv = dev_get_drvdata(pil->dev); - int ret; - - /* - * CXO is used in the secure shutdown code to configure the processor - * for low power mode. - */ - ret = clk_prepare_enable(drv->xo); - if (ret) { - dev_err(pil->dev, "Failed to enable XO\n"); - return ret; - } - - msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV); - ret = pas_shutdown(PAS_GSS); - clk_disable_unprepare(drv->xo); - - return ret; -} - -static int pil_gss_reset_trusted(struct pil_desc *pil) -{ - int err; - - err = msm_bus_axi_portunhalt(MSM_BUS_MASTER_GSS_NAV); - if (err) { - dev_err(pil->dev, "Failed to unhalt bus port\n"); - goto out; - } - - err = pas_auth_and_reset(PAS_GSS); - if (err) - goto halt_port; - - return 0; - -halt_port: - msm_bus_axi_porthalt(MSM_BUS_MASTER_GSS_NAV); -out: - return err; -} - -static struct pil_reset_ops pil_gss_ops_trusted = { - .init_image = pil_gss_init_image_trusted, - .auth_and_reset = pil_gss_reset_trusted, - .shutdown = pil_gss_shutdown_trusted, - .proxy_vote = make_gss_proxy_votes, - .proxy_unvote = remove_gss_proxy_votes, -}; - -#define MAX_SSR_REASON_LEN 81U - -static void log_gss_sfr(void) -{ - u32 size; - char *smem_reason, reason[MAX_SSR_REASON_LEN]; - - smem_reason = smem_get_entry(SMEM_SSR_REASON_MSS0, &size); - if (!smem_reason || !size) { - pr_err("GSS subsystem failure reason: (unknown, smem_get_entry failed).\n"); - return; - } - if (!smem_reason[0]) { - pr_err("GSS subsystem failure reason: (unknown, init string found).\n"); - return; - } - - size = min(size, MAX_SSR_REASON_LEN-1); - memcpy(reason, smem_reason, size); - reason[size] = '\0'; - pr_err("GSS subsystem failure reason: %s.\n", reason); - - smem_reason[0] = '\0'; - wmb(); -} - -static void restart_gss(struct gss_data *drv) -{ - log_gss_sfr(); - subsystem_restart_dev(drv->subsys); -} - -static void smsm_state_cb(void *data, uint32_t old_state, uint32_t new_state) -{ - struct gss_data *drv = data; - - /* Ignore if we're the one that set SMSM_RESET */ - if (drv->crash_shutdown) - return; - - if (new_state & SMSM_RESET) { - pr_err("GSS SMSM state changed to SMSM_RESET.\n" - "Probable err_fatal on the GSS. " - "Calling subsystem restart...\n"); - restart_gss(drv); - } -} - -static int gss_shutdown(const struct subsys_desc *desc, bool force_stop) -{ - struct gss_data *drv = container_of(desc, struct gss_data, subsys_desc); - - pil_shutdown(&drv->pil_desc); - disable_irq_nosync(drv->irq); - return 0; -} - -static int gss_powerup(const struct subsys_desc *desc) -{ - struct gss_data *drv = container_of(desc, struct gss_data, subsys_desc); - - pil_boot(&drv->pil_desc); - enable_irq(drv->irq); - return 0; -} - -void gss_crash_shutdown(const struct subsys_desc *desc) -{ - struct gss_data *drv = container_of(desc, struct gss_data, subsys_desc); - - drv->crash_shutdown = 1; - smsm_reset_modem(SMSM_RESET); -} - -static struct ramdump_segment smem_segments[] = { - {0x80000000, 0x00200000}, -}; - -static int gss_ramdump(int enable, const struct subsys_desc *desc) -{ - int ret; - struct gss_data *drv = container_of(desc, struct gss_data, subsys_desc); - - if (!enable) - return 0; - - ret = pil_do_ramdump(&drv->pil_desc, drv->ramdump_dev); - if (ret < 0) { - pr_err("Unable to dump gss memory\n"); - return ret; - } - - ret = do_elf_ramdump(drv->smem_ramdump_dev, smem_segments, - ARRAY_SIZE(smem_segments)); - if (ret < 0) { - pr_err("Unable to dump smem memory (rc = %d).\n", ret); - return ret; - } - - return 0; -} - -static irqreturn_t gss_wdog_bite_irq(int irq, void *dev_id) -{ - struct gss_data *drv = dev_id; - - pr_err("Watchdog bite received from GSS!\n"); - restart_gss(drv); - - return IRQ_HANDLED; -} - -static int gss_open(struct inode *inode, struct file *filp) -{ - struct miscdevice *c = filp->private_data; - struct gss_data *drv = container_of(c, struct gss_data, misc_dev); - - drv->subsys_handle = subsystem_get("gss"); - if (IS_ERR(drv->subsys_handle)) { - pr_debug("%s - subsystem_get returned error\n", __func__); - return PTR_ERR(drv->subsys_handle); - } - - return 0; -} - -static int gss_release(struct inode *inode, struct file *filp) -{ - struct miscdevice *c = filp->private_data; - struct gss_data *drv = container_of(c, struct gss_data, misc_dev); - - subsystem_put(drv->subsys_handle); - pr_debug("%s subsystem_put called on GSS\n", __func__); - - return 0; -} - -const struct file_operations gss_file_ops = { - .open = gss_open, - .release = gss_release, - .owner = THIS_MODULE, -}; - -static int pil_gss_probe(struct platform_device *pdev) -{ - struct gss_data *drv; - struct resource *res; - struct pil_desc *desc; - int ret; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - drv->base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - drv->qgic2_base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->qgic2_base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 2); - if (!res) - return -EINVAL; - drv->cbase = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!drv->cbase) - return -ENOMEM; - - drv->xo = devm_clk_get(&pdev->dev, "xo"); - if (IS_ERR(drv->xo)) - return PTR_ERR(drv->xo); - - drv->irq = platform_get_irq(pdev, 0); - if (drv->irq < 0) - return drv->irq; - - desc = &drv->pil_desc; - desc->name = "gss"; - desc->dev = &pdev->dev; - desc->owner = THIS_MODULE; - desc->proxy_timeout = 10000; - - if (pas_supported(PAS_GSS) > 0) { - desc->ops = &pil_gss_ops_trusted; - dev_info(&pdev->dev, "using secure boot\n"); - } else { - desc->ops = &pil_gss_ops; - dev_info(&pdev->dev, "using non-secure boot\n"); - } - ret = pil_desc_init(desc); - if (ret) - return ret; - - /* Force into low power mode because hardware doesn't do this */ - desc->ops->shutdown(desc); - - ret = smsm_state_cb_register(SMSM_MODEM_STATE, SMSM_RESET, - smsm_state_cb, drv); - if (ret < 0) - dev_warn(&pdev->dev, "Unable to register SMSM callback\n"); - - drv->subsys_desc.name = "gss"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.shutdown = gss_shutdown; - drv->subsys_desc.powerup = gss_powerup; - drv->subsys_desc.ramdump = gss_ramdump; - drv->subsys_desc.crash_shutdown = gss_crash_shutdown; - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - ret = PTR_ERR(drv->subsys); - goto err_subsys; - } - - drv->misc_dev.minor = MISC_DYNAMIC_MINOR; - drv->misc_dev.name = "gss"; - drv->misc_dev.fops = &gss_file_ops; - ret = misc_register(&drv->misc_dev); - if (ret) - goto err_misc; - - drv->ramdump_dev = create_ramdump_device("gss", &pdev->dev); - if (!drv->ramdump_dev) { - ret = -ENOMEM; - goto err_ramdump; - } - - drv->smem_ramdump_dev = create_ramdump_device("smem-gss", &pdev->dev); - if (!drv->smem_ramdump_dev) { - ret = -ENOMEM; - goto err_smem; - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - ret = devm_request_irq(&pdev->dev, drv->irq, gss_wdog_bite_irq, - IRQF_TRIGGER_RISING, "gss_a5_wdog", drv); - if (ret < 0) - goto err; - disable_irq(drv->irq); - return 0; -err: - destroy_ramdump_device(drv->smem_ramdump_dev); -err_smem: - destroy_ramdump_device(drv->ramdump_dev); -err_ramdump: - misc_deregister(&drv->misc_dev); -err_misc: - subsys_unregister(drv->subsys); -err_subsys: - pil_desc_release(desc); - return ret; -} - -static int pil_gss_remove(struct platform_device *pdev) -{ - struct gss_data *drv = platform_get_drvdata(pdev); - - destroy_ramdump_device(drv->smem_ramdump_dev); - destroy_ramdump_device(drv->ramdump_dev); - misc_deregister(&drv->misc_dev); - subsys_unregister(drv->subsys); - pil_desc_release(&drv->pil_desc); - - return 0; -} - -static struct platform_driver pil_gss_driver = { - .probe = pil_gss_probe, - .remove = pil_gss_remove, - .driver = { - .name = "pil_gss", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_gss_init(void) -{ - return platform_driver_register(&pil_gss_driver); -} -module_init(pil_gss_init); - -static void __exit pil_gss_exit(void) -{ - platform_driver_unregister(&pil_gss_driver); -} -module_exit(pil_gss_exit); - -MODULE_DESCRIPTION("Support for booting the GSS processor"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-modem.c b/arch/arm/mach-msm/pil-modem.c deleted file mode 100644 index 8dcc609213d5f113e3b7c8014e34ed6386942d68..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-modem.c +++ /dev/null @@ -1,533 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "modem_notifier.h" -#include "peripheral-loader.h" -#include "scm-pas.h" - -#define MARM_BOOT_CONTROL 0x0010 -#define MARM_RESET 0x2BD4 -#define MAHB0_SFAB_PORT_RESET 0x2304 -#define MARM_CLK_BRANCH_ENA_VOTE 0x3000 -#define MARM_CLK_SRC0_NS 0x2BC0 -#define MARM_CLK_SRC1_NS 0x2BC4 -#define MARM_CLK_SRC_CTL 0x2BC8 -#define MARM_CLK_CTL 0x2BCC -#define SFAB_MSS_S_HCLK_CTL 0x2C00 -#define MSS_MODEM_CXO_CLK_CTL 0x2C44 -#define MSS_SLP_CLK_CTL 0x2C60 -#define MSS_MARM_SYS_REF_CLK_CTL 0x2C64 -#define MAHB0_CLK_CTL 0x2300 -#define MAHB1_CLK_CTL 0x2BE4 -#define MAHB2_CLK_CTL 0x2C20 -#define MAHB1_NS 0x2BE0 -#define MARM_CLK_FS 0x2BD0 -#define MAHB2_CLK_FS 0x2C24 -#define PLL_ENA_MARM 0x3500 -#define PLL8_STATUS 0x3158 -#define CLK_HALT_MSS_SMPSS_MISC_STATE 0x2FDC -#define MSS_MODEM_RESET 0x2C48 - -struct modem_data { - void __iomem *base; - void __iomem *wdog; - void __iomem *cbase; - struct pil_device *pil; - struct clk *xo; - struct notifier_block notifier; - int ignore_smsm_ack; - int irq; - struct pil_desc pil_desc; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; - struct delayed_work unlock_work; - struct work_struct fatal_work; - struct ramdump_device *ramdump_dev; -}; - -static int make_modem_proxy_votes(struct pil_desc *pil) -{ - int ret; - struct modem_data *drv = dev_get_drvdata(pil->dev); - - ret = clk_prepare_enable(drv->xo); - if (ret) { - dev_err(pil->dev, "Failed to enable XO\n"); - return ret; - } - return 0; -} - -static void remove_modem_proxy_votes(struct pil_desc *pil) -{ - struct modem_data *drv = dev_get_drvdata(pil->dev); - clk_disable_unprepare(drv->xo); -} - -static int modem_reset(struct pil_desc *pil) -{ - u32 reg; - const struct modem_data *drv = dev_get_drvdata(pil->dev); - phys_addr_t start_addr = pil_get_entry_addr(pil); - - /* Put modem AHB0,1,2 clocks into reset */ - writel_relaxed(BIT(0) | BIT(1), drv->cbase + MAHB0_SFAB_PORT_RESET); - writel_relaxed(BIT(7), drv->cbase + MAHB1_CLK_CTL); - writel_relaxed(BIT(7), drv->cbase + MAHB2_CLK_CTL); - - /* Vote for pll8 on behalf of the modem */ - reg = readl_relaxed(drv->cbase + PLL_ENA_MARM); - reg |= BIT(8); - writel_relaxed(reg, drv->cbase + PLL_ENA_MARM); - - /* Wait for PLL8 to enable */ - while (!(readl_relaxed(drv->cbase + PLL8_STATUS) & BIT(16))) - cpu_relax(); - - /* Set MAHB1 divider to Div-5 to run MAHB1,2 and sfab at 79.8 Mhz*/ - writel_relaxed(0x4, drv->cbase + MAHB1_NS); - - /* Vote for modem AHB1 and 2 clocks to be on on behalf of the modem */ - reg = readl_relaxed(drv->cbase + MARM_CLK_BRANCH_ENA_VOTE); - reg |= BIT(0) | BIT(1); - writel_relaxed(reg, drv->cbase + MARM_CLK_BRANCH_ENA_VOTE); - - /* Source marm_clk off of PLL8 */ - reg = readl_relaxed(drv->cbase + MARM_CLK_SRC_CTL); - if ((reg & 0x1) == 0) { - writel_relaxed(0x3, drv->cbase + MARM_CLK_SRC1_NS); - reg |= 0x1; - } else { - writel_relaxed(0x3, drv->cbase + MARM_CLK_SRC0_NS); - reg &= ~0x1; - } - writel_relaxed(reg | 0x2, drv->cbase + MARM_CLK_SRC_CTL); - - /* - * Force core on and periph on signals to remain active during halt - * for marm_clk and mahb2_clk - */ - writel_relaxed(0x6F, drv->cbase + MARM_CLK_FS); - writel_relaxed(0x6F, drv->cbase + MAHB2_CLK_FS); - - /* - * Enable all of the marm_clk branches, cxo sourced marm branches, - * and sleep clock branches - */ - writel_relaxed(0x10, drv->cbase + MARM_CLK_CTL); - writel_relaxed(0x10, drv->cbase + MAHB0_CLK_CTL); - writel_relaxed(0x10, drv->cbase + SFAB_MSS_S_HCLK_CTL); - writel_relaxed(0x10, drv->cbase + MSS_MODEM_CXO_CLK_CTL); - writel_relaxed(0x10, drv->cbase + MSS_SLP_CLK_CTL); - writel_relaxed(0x10, drv->cbase + MSS_MARM_SYS_REF_CLK_CTL); - - /* Wait for above clocks to be turned on */ - while (readl_relaxed(drv->cbase + CLK_HALT_MSS_SMPSS_MISC_STATE) & - (BIT(7) | BIT(8) | BIT(9) | BIT(10) | BIT(4) | BIT(6))) - cpu_relax(); - - /* Take MAHB0,1,2 clocks out of reset */ - writel_relaxed(0x0, drv->cbase + MAHB2_CLK_CTL); - writel_relaxed(0x0, drv->cbase + MAHB1_CLK_CTL); - writel_relaxed(0x0, drv->cbase + MAHB0_SFAB_PORT_RESET); - mb(); - - /* Setup exception vector table base address */ - writel_relaxed(start_addr | 0x1, drv->base + MARM_BOOT_CONTROL); - - /* Wait for vector table to be setup */ - mb(); - - /* Bring modem out of reset */ - writel_relaxed(0x0, drv->cbase + MARM_RESET); - - return 0; -} - -static int modem_pil_shutdown(struct pil_desc *pil) -{ - u32 reg; - const struct modem_data *drv = dev_get_drvdata(pil->dev); - - /* Put modem into reset */ - writel_relaxed(0x1, drv->cbase + MARM_RESET); - mb(); - - /* Put modem AHB0,1,2 clocks into reset */ - writel_relaxed(BIT(0) | BIT(1), drv->cbase + MAHB0_SFAB_PORT_RESET); - writel_relaxed(BIT(7), drv->cbase + MAHB1_CLK_CTL); - writel_relaxed(BIT(7), drv->cbase + MAHB2_CLK_CTL); - mb(); - - /* - * Disable all of the marm_clk branches, cxo sourced marm branches, - * and sleep clock branches - */ - writel_relaxed(0x0, drv->cbase + MARM_CLK_CTL); - writel_relaxed(0x0, drv->cbase + MAHB0_CLK_CTL); - writel_relaxed(0x0, drv->cbase + SFAB_MSS_S_HCLK_CTL); - writel_relaxed(0x0, drv->cbase + MSS_MODEM_CXO_CLK_CTL); - writel_relaxed(0x0, drv->cbase + MSS_SLP_CLK_CTL); - writel_relaxed(0x0, drv->cbase + MSS_MARM_SYS_REF_CLK_CTL); - - /* Disable marm_clk */ - reg = readl_relaxed(drv->cbase + MARM_CLK_SRC_CTL); - reg &= ~0x2; - writel_relaxed(reg, drv->cbase + MARM_CLK_SRC_CTL); - - /* Clear modem's votes for ahb clocks */ - writel_relaxed(0x0, drv->cbase + MARM_CLK_BRANCH_ENA_VOTE); - - /* Clear modem's votes for PLLs */ - writel_relaxed(0x0, drv->cbase + PLL_ENA_MARM); - - return 0; -} - -static struct pil_reset_ops pil_modem_ops = { - .auth_and_reset = modem_reset, - .shutdown = modem_pil_shutdown, - .proxy_vote = make_modem_proxy_votes, - .proxy_unvote = remove_modem_proxy_votes, -}; - -static int modem_init_image_trusted(struct pil_desc *pil, const u8 *metadata, - size_t size) -{ - return pas_init_image(PAS_MODEM, metadata, size); -} - -static int modem_reset_trusted(struct pil_desc *pil) -{ - return pas_auth_and_reset(PAS_MODEM); -} - -static int modem_shutdown_trusted(struct pil_desc *pil) -{ - return pas_shutdown(PAS_MODEM); -} - -static struct pil_reset_ops pil_modem_ops_trusted = { - .init_image = modem_init_image_trusted, - .auth_and_reset = modem_reset_trusted, - .shutdown = modem_shutdown_trusted, - .proxy_vote = make_modem_proxy_votes, - .proxy_unvote = remove_modem_proxy_votes, -}; - -static void modem_crash_shutdown(const struct subsys_desc *subsys) -{ - struct modem_data *drv; - - /* If modem hasn't already crashed, send SMSM_RESET. */ - drv = container_of(subsys, struct modem_data, subsys_desc); - if (!(smsm_get_state(SMSM_MODEM_STATE) & SMSM_RESET)) { - modem_unregister_notifier(&drv->notifier); - smsm_reset_modem(SMSM_RESET); - } - - /* Wait to allow the modem to clean up caches etc. */ - mdelay(5); -} - -static irqreturn_t modem_wdog_bite_irq(int irq, void *dev_id) -{ - struct modem_data *drv = dev_id; - - schedule_work(&drv->fatal_work); - disable_irq_nosync(drv->irq); - - return IRQ_HANDLED; -} - -static void modem_unlock_timeout(struct work_struct *work) -{ - struct modem_data *drv; - struct delayed_work *dwork = to_delayed_work(work); - - pr_crit("Timeout waiting for modem to unlock.\n"); - - drv = container_of(dwork, struct modem_data, unlock_work); - /* The unlock didn't work, clear the reset */ - writel_relaxed(0x0, drv->cbase + MSS_MODEM_RESET); - mb(); - - subsystem_restart_dev(drv->subsys); - enable_irq(drv->irq); -} - -static void modem_fatal_fn(struct work_struct *work) -{ - u32 modem_state; - u32 panic_smsm_states = SMSM_RESET | SMSM_SYSTEM_DOWNLOAD; - u32 reset_smsm_states = SMSM_SYSTEM_REBOOT_USR | SMSM_SYSTEM_PWRDWN_USR; - struct modem_data *drv; - - drv = container_of(work, struct modem_data, fatal_work); - - pr_err("Watchdog bite received from modem!\n"); - - modem_state = smsm_get_state(SMSM_MODEM_STATE); - pr_err("Modem SMSM state = 0x%x!\n", modem_state); - - if (modem_state == 0 || modem_state & panic_smsm_states) { - subsystem_restart_dev(drv->subsys); - enable_irq(drv->irq); - } else if (modem_state & reset_smsm_states) { - pr_err("User-invoked system reset/powerdown."); - kernel_restart(NULL); - } else { - unsigned long timeout = msecs_to_jiffies(6000); - - pr_err("Modem AHB locked up. Trying to free up modem!\n"); - - writel_relaxed(0x3, drv->cbase + MSS_MODEM_RESET); - /* - * If we are still alive (allowing for the 5 second - * delayed-panic-reboot), the modem is either still wedged or - * SMSM didn't come through. Force panic in that case. - */ - schedule_delayed_work(&drv->unlock_work, timeout); - } -} - -static int modem_notif_handler(struct notifier_block *nb, unsigned long code, - void *p) -{ - struct modem_data *drv = container_of(nb, struct modem_data, notifier); - - if (code == MODEM_NOTIFIER_START_RESET) { - if (drv->ignore_smsm_ack) { - drv->ignore_smsm_ack = 0; - } else { - pr_err("Modem error fatal'ed."); - subsystem_restart_dev(drv->subsys); - } - } - return NOTIFY_DONE; -} - -static int modem_shutdown(const struct subsys_desc *subsys, bool force_stop) -{ - struct modem_data *drv; - - drv = container_of(subsys, struct modem_data, subsys_desc); - - if (force_stop) { - /* - * If the modem didn't already crash, setting SMSM_RESET here - * will help flush caches etc. The ignore_smsm_ack flag is set - * to ignore the SMSM_RESET notification that is generated due - * to the modem settings its own SMSM_RESET bit in response to - * the apps setting the apps SMSM_RESET bit. - */ - if (!(smsm_get_state(SMSM_MODEM_STATE) & SMSM_RESET)) { - drv->ignore_smsm_ack = 1; - smsm_reset_modem(SMSM_RESET); - } - - /* Disable the modem watchdog to allow clean modem bootup */ - writel_relaxed(0x0, drv->wdog + 0x8); - /* - * The write above needs to go through before the modem is - * powered up again. - */ - mb(); - /* Wait here to allow the modem to clean up caches, etc. */ - msleep(20); - } - - pil_shutdown(&drv->pil_desc); - disable_irq_nosync(drv->irq); - - return 0; -} - -static int modem_powerup(const struct subsys_desc *subsys) -{ - struct modem_data *drv; - int ret; - - drv = container_of(subsys, struct modem_data, subsys_desc); - ret = pil_boot(&drv->pil_desc); - enable_irq(drv->irq); - - return ret; -} - -static int modem_ramdump(int enable, const struct subsys_desc *subsys) -{ - struct modem_data *drv; - - drv = container_of(subsys, struct modem_data, subsys_desc); - if (!enable) - return 0; - - return pil_do_ramdump(&drv->pil_desc, drv->ramdump_dev); -} - -static int pil_modem_driver_probe(struct platform_device *pdev) -{ - struct modem_data *drv; - struct resource *res; - struct pil_desc *desc; - int ret; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - drv->irq = platform_get_irq(pdev, 0); - if (drv->irq < 0) - return drv->irq; - - drv->xo = devm_clk_get(&pdev->dev, "xo"); - if (IS_ERR(drv->xo)) - return PTR_ERR(drv->xo); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - drv->base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - drv->wdog = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->wdog) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 2); - if (!res) - return -EINVAL; - - drv->cbase = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!drv->cbase) - return -ENOMEM; - - desc = &drv->pil_desc; - desc->name = "modem"; - desc->dev = &pdev->dev; - desc->owner = THIS_MODULE; - desc->proxy_timeout = 10000; - - if (pas_supported(PAS_MODEM) > 0) { - desc->ops = &pil_modem_ops_trusted; - dev_info(&pdev->dev, "using secure boot\n"); - } else { - desc->ops = &pil_modem_ops; - dev_info(&pdev->dev, "using non-secure boot\n"); - } - ret = pil_desc_init(desc); - if (ret) - return ret; - - drv->notifier.notifier_call = modem_notif_handler, - ret = modem_register_notifier(&drv->notifier); - if (ret) - goto err_notify; - - drv->subsys_desc.name = "modem"; - drv->subsys_desc.depends_on = "adsp"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.shutdown = modem_shutdown; - drv->subsys_desc.powerup = modem_powerup; - drv->subsys_desc.ramdump = modem_ramdump; - drv->subsys_desc.crash_shutdown = modem_crash_shutdown; - - INIT_WORK(&drv->fatal_work, modem_fatal_fn); - INIT_DELAYED_WORK(&drv->unlock_work, modem_unlock_timeout); - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - ret = PTR_ERR(drv->subsys); - goto err_subsys; - } - - drv->ramdump_dev = create_ramdump_device("modem", &pdev->dev); - if (!drv->ramdump_dev) { - ret = -ENOMEM; - goto err_ramdump; - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - ret = devm_request_irq(&pdev->dev, drv->irq, modem_wdog_bite_irq, - IRQF_TRIGGER_RISING, "modem_watchdog", drv); - if (ret) - goto err_irq; - disable_irq(drv->irq); - return 0; - -err_irq: - destroy_ramdump_device(drv->ramdump_dev); -err_ramdump: - subsys_unregister(drv->subsys); -err_subsys: - modem_unregister_notifier(&drv->notifier); -err_notify: - pil_desc_release(desc); - return ret; -} - -static int pil_modem_driver_exit(struct platform_device *pdev) -{ - struct modem_data *drv = platform_get_drvdata(pdev); - - destroy_ramdump_device(drv->ramdump_dev); - subsys_unregister(drv->subsys); - modem_unregister_notifier(&drv->notifier); - pil_desc_release(&drv->pil_desc); - - return 0; -} - -static struct platform_driver pil_modem_driver = { - .probe = pil_modem_driver_probe, - .remove = pil_modem_driver_exit, - .driver = { - .name = "pil_modem", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_modem_init(void) -{ - return platform_driver_register(&pil_modem_driver); -} -module_init(pil_modem_init); - -static void __exit pil_modem_exit(void) -{ - platform_driver_unregister(&pil_modem_driver); -} -module_exit(pil_modem_exit); - -MODULE_DESCRIPTION("Support for booting modem processors"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-q6v3.c b/arch/arm/mach-msm/pil-q6v3.c deleted file mode 100644 index 901a7c51d02776299ab026d7531b3cb640ecde66..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-q6v3.c +++ /dev/null @@ -1,429 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "peripheral-loader.h" -#include "scm-pas.h" - -#define QDSP6SS_RST_EVB 0x0000 -#define QDSP6SS_STRAP_TCM 0x001C -#define QDSP6SS_STRAP_AHB 0x0020 - -#define LCC_Q6_FUNC 0x001C -#define LV_EN BIT(27) -#define STOP_CORE BIT(26) -#define CLAMP_IO BIT(25) -#define Q6SS_PRIV_ARES BIT(24) -#define Q6SS_SS_ARES BIT(23) -#define Q6SS_ISDB_ARES BIT(22) -#define Q6SS_ETM_ARES BIT(21) -#define Q6_JTAG_CRC_EN BIT(20) -#define Q6_JTAG_INV_EN BIT(19) -#define Q6_JTAG_CXC_EN BIT(18) -#define Q6_PXO_CRC_EN BIT(17) -#define Q6_PXO_INV_EN BIT(16) -#define Q6_PXO_CXC_EN BIT(15) -#define Q6_PXO_SLEEP_EN BIT(14) -#define Q6_SLP_CRC_EN BIT(13) -#define Q6_SLP_INV_EN BIT(12) -#define Q6_SLP_CXC_EN BIT(11) -#define CORE_ARES BIT(10) -#define CORE_L1_MEM_CORE_EN BIT(9) -#define CORE_TCM_MEM_CORE_EN BIT(8) -#define CORE_TCM_MEM_PERPH_EN BIT(7) -#define CORE_GFM4_CLK_EN BIT(2) -#define CORE_GFM4_RES BIT(1) -#define RAMP_PLL_SRC_SEL BIT(0) - -#define Q6_STRAP_AHB_UPPER (0x290 << 12) -#define Q6_STRAP_AHB_LOWER 0x280 -#define Q6_STRAP_TCM_BASE (0x28C << 15) -#define Q6_STRAP_TCM_CONFIG 0x28B - -#define SCM_Q6_NMI_CMD 0x1 - -/** - * struct q6v3_data - LPASS driver data - * @base: register base - * @cbase: clock base - * @wk_base: wakeup register base - * @wd_base: watchdog register base - * @irq: watchdog irq - * @pil: peripheral handle - * @subsys: subsystem restart handle - * @subsys_desc: subsystem restart descriptor - * @fatal_wrk: fatal error workqueue - * @pll: pll clock handle - * @ramdump_dev: ramdump device - */ -struct q6v3_data { - void __iomem *base; - void __iomem *cbase; - void __iomem *wk_base; - void __iomem *wd_base; - int irq; - struct pil_desc pil_desc; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; - struct work_struct fatal_wrk; - struct clk *pll; - struct ramdump_device *ramdump_dev; -}; - -static void pil_q6v3_remove_proxy_votes(struct pil_desc *pil) -{ - struct q6v3_data *drv = dev_get_drvdata(pil->dev); - clk_disable_unprepare(drv->pll); -} - -static int pil_q6v3_make_proxy_votes(struct pil_desc *pil) -{ - int ret; - struct q6v3_data *drv = dev_get_drvdata(pil->dev); - - ret = clk_prepare_enable(drv->pll); - if (ret) { - dev_err(pil->dev, "Failed to enable PLL\n"); - return ret; - } - return 0; -} - -static int pil_q6v3_reset(struct pil_desc *pil) -{ - u32 reg; - struct q6v3_data *drv = dev_get_drvdata(pil->dev); - phys_addr_t start_addr = pil_get_entry_addr(pil); - - /* Put Q6 into reset */ - reg = readl_relaxed(drv->cbase + LCC_Q6_FUNC); - reg |= Q6SS_SS_ARES | Q6SS_ISDB_ARES | Q6SS_ETM_ARES | STOP_CORE | - CORE_ARES; - reg &= ~CORE_GFM4_CLK_EN; - writel_relaxed(reg, drv->cbase + LCC_Q6_FUNC); - - /* Wait 8 AHB cycles for Q6 to be fully reset (AHB = 1.5Mhz) */ - usleep_range(20, 30); - - /* Turn on Q6 memory */ - reg |= CORE_GFM4_CLK_EN | CORE_L1_MEM_CORE_EN | CORE_TCM_MEM_CORE_EN | - CORE_TCM_MEM_PERPH_EN; - writel_relaxed(reg, drv->cbase + LCC_Q6_FUNC); - - /* Turn on Q6 core clocks and take core out of reset */ - reg &= ~(CLAMP_IO | Q6SS_SS_ARES | Q6SS_ISDB_ARES | Q6SS_ETM_ARES | - CORE_ARES); - writel_relaxed(reg, drv->cbase + LCC_Q6_FUNC); - - /* Wait for clocks to be enabled */ - mb(); - /* Program boot address */ - writel_relaxed((start_addr >> 12) & 0xFFFFF, - drv->base + QDSP6SS_RST_EVB); - - writel_relaxed(Q6_STRAP_TCM_CONFIG | Q6_STRAP_TCM_BASE, - drv->base + QDSP6SS_STRAP_TCM); - writel_relaxed(Q6_STRAP_AHB_UPPER | Q6_STRAP_AHB_LOWER, - drv->base + QDSP6SS_STRAP_AHB); - - /* Wait for addresses to be programmed before starting Q6 */ - mb(); - - /* Start Q6 instruction execution */ - reg &= ~STOP_CORE; - writel_relaxed(reg, drv->cbase + LCC_Q6_FUNC); - - return 0; -} - -static int pil_q6v3_shutdown(struct pil_desc *pil) -{ - u32 reg; - struct q6v3_data *drv = dev_get_drvdata(pil->dev); - - /* Put Q6 into reset */ - reg = readl_relaxed(drv->cbase + LCC_Q6_FUNC); - reg |= Q6SS_SS_ARES | Q6SS_ISDB_ARES | Q6SS_ETM_ARES | STOP_CORE | - CORE_ARES; - reg &= ~CORE_GFM4_CLK_EN; - writel_relaxed(reg, drv->cbase + LCC_Q6_FUNC); - - /* Wait 8 AHB cycles for Q6 to be fully reset (AHB = 1.5Mhz) */ - usleep_range(20, 30); - - /* Turn off Q6 memory */ - reg &= ~(CORE_L1_MEM_CORE_EN | CORE_TCM_MEM_CORE_EN | - CORE_TCM_MEM_PERPH_EN); - writel_relaxed(reg, drv->cbase + LCC_Q6_FUNC); - - reg |= CLAMP_IO; - writel_relaxed(reg, drv->cbase + LCC_Q6_FUNC); - - return 0; -} - -static struct pil_reset_ops pil_q6v3_ops = { - .auth_and_reset = pil_q6v3_reset, - .shutdown = pil_q6v3_shutdown, - .proxy_vote = pil_q6v3_make_proxy_votes, - .proxy_unvote = pil_q6v3_remove_proxy_votes, -}; - -static int pil_q6v3_init_image_trusted(struct pil_desc *pil, - const u8 *metadata, size_t size) -{ - return pas_init_image(PAS_Q6, metadata, size); -} - -static int pil_q6v3_reset_trusted(struct pil_desc *pil) -{ - return pas_auth_and_reset(PAS_Q6); -} - -static int pil_q6v3_shutdown_trusted(struct pil_desc *pil) -{ - return pas_shutdown(PAS_Q6); -} - -static struct pil_reset_ops pil_q6v3_ops_trusted = { - .init_image = pil_q6v3_init_image_trusted, - .auth_and_reset = pil_q6v3_reset_trusted, - .shutdown = pil_q6v3_shutdown_trusted, - .proxy_vote = pil_q6v3_make_proxy_votes, - .proxy_unvote = pil_q6v3_remove_proxy_votes, -}; - -static void q6_fatal_fn(struct work_struct *work) -{ - struct q6v3_data *drv = container_of(work, struct q6v3_data, fatal_wrk); - - pr_err("Watchdog bite received from Q6!\n"); - subsystem_restart_dev(drv->subsys); -} - -static void send_q6_nmi(struct q6v3_data *drv) -{ - /* Send NMI to QDSP6 via an SCM call. */ - scm_call_atomic1(SCM_SVC_UTIL, SCM_Q6_NMI_CMD, 0x1); - - /* Wakeup the Q6 */ - writel_relaxed(0x2000, drv->wk_base + 0x1c); - /* Q6 requires atleast 100ms to dump caches etc.*/ - mdelay(100); - pr_info("Q6 NMI was sent.\n"); -} - -static int lpass_q6_shutdown(const struct subsys_desc *subsys, bool force_stop) -{ - struct q6v3_data *drv; - - drv = container_of(subsys, struct q6v3_data, subsys_desc); - if (force_stop) { - send_q6_nmi(drv); - writel_relaxed(0x0, drv->wd_base + 0x24); - mb(); - } - - pil_shutdown(&drv->pil_desc); - disable_irq_nosync(drv->irq); - - return 0; -} - -static int lpass_q6_powerup(const struct subsys_desc *subsys) -{ - struct q6v3_data *drv; - int ret; - - drv = container_of(subsys, struct q6v3_data, subsys_desc); - ret = pil_boot(&drv->pil_desc); - enable_irq(drv->irq); - return ret; -} - -static int lpass_q6_ramdump(int enable, const struct subsys_desc *subsys) -{ - struct q6v3_data *drv; - - drv = container_of(subsys, struct q6v3_data, subsys_desc); - if (!enable) - return 0; - - return pil_do_ramdump(&drv->pil_desc, drv->ramdump_dev); -} - -static void lpass_q6_crash_shutdown(const struct subsys_desc *subsys) -{ - struct q6v3_data *drv; - - drv = container_of(subsys, struct q6v3_data, subsys_desc); - send_q6_nmi(drv); -} - -static irqreturn_t lpass_wdog_bite_irq(int irq, void *dev_id) -{ - int ret; - struct q6v3_data *drv = dev_id; - - ret = schedule_work(&drv->fatal_wrk); - return IRQ_HANDLED; -} - -static int pil_q6v3_driver_probe(struct platform_device *pdev) -{ - struct q6v3_data *drv; - struct resource *res; - struct pil_desc *desc; - int ret; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - drv->base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - drv->wk_base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->wk_base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 2); - drv->wd_base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->wd_base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 3); - if (!res) - return -EINVAL; - drv->cbase = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!drv->cbase) - return -ENOMEM; - - drv->irq = platform_get_irq(pdev, 0); - if (drv->irq < 0) - return drv->irq; - - drv->pll = devm_clk_get(&pdev->dev, "pll4"); - if (IS_ERR(drv->pll)) - return PTR_ERR(drv->pll); - - desc = &drv->pil_desc; - desc->name = "q6"; - desc->dev = &pdev->dev; - desc->owner = THIS_MODULE; - desc->proxy_timeout = 10000; - - if (pas_supported(PAS_Q6) > 0) { - desc->ops = &pil_q6v3_ops_trusted; - dev_info(&pdev->dev, "using secure boot\n"); - } else { - desc->ops = &pil_q6v3_ops; - dev_info(&pdev->dev, "using non-secure boot\n"); - } - - ret = pil_desc_init(desc); - if (ret) - return ret; - - drv->subsys_desc.name = "adsp"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.shutdown = lpass_q6_shutdown; - drv->subsys_desc.powerup = lpass_q6_powerup; - drv->subsys_desc.ramdump = lpass_q6_ramdump; - drv->subsys_desc.crash_shutdown = lpass_q6_crash_shutdown; - - INIT_WORK(&drv->fatal_wrk, q6_fatal_fn); - - drv->ramdump_dev = create_ramdump_device("lpass", &pdev->dev); - if (!drv->ramdump_dev) { - ret = -ENOMEM; - goto err_ramdump; - } - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - ret = PTR_ERR(drv->subsys); - goto err_subsys; - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - ret = devm_request_irq(&pdev->dev, drv->irq, lpass_wdog_bite_irq, - IRQF_TRIGGER_RISING, "lpass_wdog", drv); - if (ret) { - dev_err(&pdev->dev, "Unable to request wdog irq.\n"); - goto err_irq; - } - disable_irq(drv->irq); - - return 0; -err_irq: - subsys_unregister(drv->subsys); -err_subsys: - destroy_ramdump_device(drv->ramdump_dev); -err_ramdump: - pil_desc_release(desc); - return ret; -} - -static int pil_q6v3_driver_exit(struct platform_device *pdev) -{ - struct q6v3_data *drv = platform_get_drvdata(pdev); - subsys_unregister(drv->subsys); - destroy_ramdump_device(drv->ramdump_dev); - pil_desc_release(&drv->pil_desc); - return 0; -} - -static struct platform_driver pil_q6v3_driver = { - .probe = pil_q6v3_driver_probe, - .remove = pil_q6v3_driver_exit, - .driver = { - .name = "pil_qdsp6v3", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_q6v3_init(void) -{ - return platform_driver_register(&pil_q6v3_driver); -} -module_init(pil_q6v3_init); - -static void __exit pil_q6v3_exit(void) -{ - platform_driver_unregister(&pil_q6v3_driver); -} -module_exit(pil_q6v3_exit); - -MODULE_DESCRIPTION("Support for booting QDSP6v3 (Hexagon) processors"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-q6v4-lpass.c b/arch/arm/mach-msm/pil-q6v4-lpass.c deleted file mode 100644 index 3e8928acb4aeb5902475306b4c2d190e2a7b1233..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-q6v4-lpass.c +++ /dev/null @@ -1,401 +0,0 @@ -/* Copyright (c) 2012,2013 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "peripheral-loader.h" -#include "pil-q6v4.h" -#include "scm-pas.h" - -struct lpass_q6v4 { - struct q6v4_data q6; - void *riva_notif_hdle; - void *modem_notif_hdle; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; - int crash_shutdown; - void *ramdump_dev; - struct work_struct work; - int loadable; -}; - -static int pil_q6v4_lpass_boot(struct pil_desc *pil) -{ - struct q6v4_data *drv = pil_to_q6v4_data(pil); - int err; - - err = pil_q6v4_power_up(drv); - if (err) - return err; - - return pil_q6v4_boot(pil); -} - -static int pil_q6v4_lpass_shutdown(struct pil_desc *pil) -{ - struct q6v4_data *drv = pil_to_q6v4_data(pil); - int ret; - - ret = pil_q6v4_shutdown(pil); - if (ret) - return ret; - pil_q6v4_power_down(drv); - return 0; -} - -static struct pil_reset_ops pil_q6v4_lpass_ops = { - .auth_and_reset = pil_q6v4_lpass_boot, - .shutdown = pil_q6v4_lpass_shutdown, - .proxy_vote = pil_q6v4_make_proxy_votes, - .proxy_unvote = pil_q6v4_remove_proxy_votes, -}; - -static struct pil_reset_ops pil_q6v4_lpass_ops_trusted = { - .init_image = pil_q6v4_init_image_trusted, - .auth_and_reset = pil_q6v4_boot_trusted, - .shutdown = pil_q6v4_shutdown_trusted, - .proxy_vote = pil_q6v4_make_proxy_votes, - .proxy_unvote = pil_q6v4_remove_proxy_votes, -}; - -static int riva_notifier_cb(struct notifier_block *this, unsigned long code, - void *ss_handle) -{ - int ret; - switch (code) { - case SUBSYS_BEFORE_SHUTDOWN: - pr_debug("%s: R-Notify: Shutdown started\n", __func__); - ret = sysmon_send_event(SYSMON_SS_LPASS, "wcnss", - SUBSYS_BEFORE_SHUTDOWN); - if (ret < 0) - pr_err("%s: sysmon_send_event error %d", __func__, ret); - break; - } - return NOTIFY_DONE; -} - -static struct notifier_block rnb = { - .notifier_call = riva_notifier_cb, -}; - -static int modem_notifier_cb(struct notifier_block *this, unsigned long code, - void *ss_handle) -{ - int ret; - switch (code) { - case SUBSYS_BEFORE_SHUTDOWN: - pr_debug("%s: M-Notify: Shutdown started\n", __func__); - ret = sysmon_send_event(SYSMON_SS_LPASS, "modem", - SUBSYS_BEFORE_SHUTDOWN); - if (ret < 0) - pr_err("%s: sysmon_send_event error %d", __func__, ret); - break; - } - return NOTIFY_DONE; -} - -static struct notifier_block mnb = { - .notifier_call = modem_notifier_cb, -}; - -static void lpass_log_failure_reason(void) -{ - char *reason; - char buffer[81]; - unsigned size; - - reason = smem_get_entry(SMEM_SSR_REASON_LPASS0, &size); - - if (!reason) { - pr_err("LPASS subsystem failure reason: (unknown, smem_get_entry failed)."); - return; - } - - if (reason[0] == '\0') { - pr_err("LPASS subsystem failure reason: (unknown, init value found)"); - return; - } - - size = min(size, sizeof(buffer) - 1); - memcpy(buffer, reason, size); - buffer[size] = '\0'; - pr_err("LPASS subsystem failure reason: %s", buffer); - memset((void *)reason, 0x0, size); - wmb(); -} - -static void lpass_fatal_fn(struct work_struct *work) -{ - pr_err("Watchdog bite received from lpass Q6!\n"); - lpass_log_failure_reason(); - panic("Q6 Resetting the SoC"); -} - -static void lpass_smsm_state_cb(void *data, uint32_t old_state, - uint32_t new_state) -{ - struct lpass_q6v4 *drv = data; - - /* Ignore if we're the one that set SMSM_RESET */ - if (drv->crash_shutdown) - return; - - if (new_state & SMSM_RESET) { - pr_err("%s: LPASS SMSM state changed to SMSM_RESET, new_state = %#x, old_state = %#x\n", - __func__, new_state, old_state); - lpass_log_failure_reason(); - panic("Q6 Resetting the SoC"); - } -} - -#define SCM_Q6_NMI_CMD 0x1 - -static void send_q6_nmi(void) -{ - /* Send NMI to QDSP6 via an SCM call. */ - uint32_t cmd = 0x1; - - scm_call(SCM_SVC_UTIL, SCM_Q6_NMI_CMD, - &cmd, sizeof(cmd), NULL, 0); - - /* Q6 requires worstcase 100ms to dump caches etc.*/ - mdelay(100); - pr_debug("%s: Q6 NMI was sent.\n", __func__); -} - -#define subsys_to_lpass(d) container_of(d, struct lpass_q6v4, subsys_desc) - -static int lpass_shutdown(const struct subsys_desc *subsys, bool force_stop) -{ - struct lpass_q6v4 *drv = subsys_to_lpass(subsys); - - if (force_stop) - send_q6_nmi(); - if (drv->loadable) - pil_shutdown(&drv->q6.desc); - disable_irq_nosync(drv->q6.wdog_irq); - - return 0; -} - -static int lpass_powerup(const struct subsys_desc *subsys) -{ - struct lpass_q6v4 *drv = subsys_to_lpass(subsys); - int ret = 0; - - if (drv->loadable) - ret = pil_boot(&drv->q6.desc); - enable_irq(drv->q6.wdog_irq); - - return ret; -} - -static int lpass_ramdump(int enable, const struct subsys_desc *subsys) -{ - struct lpass_q6v4 *drv = subsys_to_lpass(subsys); - - if (!enable) - return 0; - - return pil_do_ramdump(&drv->q6.desc, drv->ramdump_dev); -} - -static void lpass_crash_shutdown(const struct subsys_desc *subsys) -{ - struct lpass_q6v4 *drv = subsys_to_lpass(subsys); - - drv->crash_shutdown = 1; - send_q6_nmi(); -} - -static irqreturn_t lpass_wdog_bite_irq(int irq, void *dev_id) -{ - struct lpass_q6v4 *drv = dev_id; - - schedule_work(&drv->work); - return IRQ_HANDLED; -} - -static int pil_q6v4_lpass_driver_probe(struct platform_device *pdev) -{ - const struct pil_q6v4_pdata *pdata = pdev->dev.platform_data; - struct lpass_q6v4 *drv; - struct q6v4_data *q6; - struct pil_desc *desc; - struct resource *res; - int ret; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - q6 = &drv->q6; - desc = &q6->desc; - - q6->wdog_irq = platform_get_irq(pdev, 0); - if (q6->wdog_irq < 0) - return q6->wdog_irq; - - drv->loadable = !!pdata; /* No pdata = don't use PIL */ - if (drv->loadable) { - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - q6->base = devm_request_and_ioremap(&pdev->dev, res); - if (!q6->base) - return -ENOMEM; - - q6->vreg = devm_regulator_get(&pdev->dev, "core_vdd"); - if (IS_ERR(q6->vreg)) - return PTR_ERR(q6->vreg); - - q6->xo = devm_clk_get(&pdev->dev, "xo"); - if (IS_ERR(q6->xo)) - return PTR_ERR(q6->xo); - - desc->name = pdata->name; - desc->dev = &pdev->dev; - desc->owner = THIS_MODULE; - desc->proxy_timeout = 10000; - pil_q6v4_init(q6, pdata); - - if (pas_supported(pdata->pas_id) > 0) { - desc->ops = &pil_q6v4_lpass_ops_trusted; - dev_info(&pdev->dev, "using secure boot\n"); - } else { - desc->ops = &pil_q6v4_lpass_ops; - dev_info(&pdev->dev, "using non-secure boot\n"); - } - - ret = pil_desc_init(desc); - if (ret) - return ret; - } - - drv->subsys_desc.name = "adsp"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.shutdown = lpass_shutdown; - drv->subsys_desc.powerup = lpass_powerup; - drv->subsys_desc.ramdump = lpass_ramdump; - drv->subsys_desc.crash_shutdown = lpass_crash_shutdown; - - INIT_WORK(&drv->work, lpass_fatal_fn); - - drv->ramdump_dev = create_ramdump_device("lpass", &pdev->dev); - if (!drv->ramdump_dev) { - ret = -ENOMEM; - goto err_ramdump; - } - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - ret = PTR_ERR(drv->subsys); - goto err_subsys; - } - if (!drv->loadable) - subsys_default_online(drv->subsys); - - ret = devm_request_irq(&pdev->dev, q6->wdog_irq, lpass_wdog_bite_irq, - IRQF_TRIGGER_RISING, dev_name(&pdev->dev), drv); - if (ret) - goto err_irq; - disable_irq(q6->wdog_irq); - - ret = smsm_state_cb_register(SMSM_Q6_STATE, SMSM_RESET, - lpass_smsm_state_cb, drv); - if (ret < 0) - goto err_smsm; - - drv->riva_notif_hdle = subsys_notif_register_notifier("riva", &rnb); - if (IS_ERR(drv->riva_notif_hdle)) { - ret = PTR_ERR(drv->riva_notif_hdle); - goto err_notif_riva; - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - drv->modem_notif_hdle = subsys_notif_register_notifier("modem", &mnb); - if (IS_ERR(drv->modem_notif_hdle)) { - ret = PTR_ERR(drv->modem_notif_hdle); - goto err_notif_modem; - } - return 0; -err_notif_modem: - subsys_notif_unregister_notifier(drv->riva_notif_hdle, &rnb); -err_notif_riva: - smsm_state_cb_deregister(SMSM_Q6_STATE, SMSM_RESET, - lpass_smsm_state_cb, drv); -err_smsm: -err_irq: - subsys_unregister(drv->subsys); -err_subsys: - destroy_ramdump_device(drv->ramdump_dev); -err_ramdump: - if (drv->loadable) - pil_desc_release(desc); - return ret; -} - -static int pil_q6v4_lpass_driver_exit(struct platform_device *pdev) -{ - struct lpass_q6v4 *drv = platform_get_drvdata(pdev); - subsys_notif_unregister_notifier(drv->riva_notif_hdle, &rnb); - subsys_notif_unregister_notifier(drv->modem_notif_hdle, &mnb); - smsm_state_cb_deregister(SMSM_Q6_STATE, SMSM_RESET, - lpass_smsm_state_cb, drv); - subsys_unregister(drv->subsys); - destroy_ramdump_device(drv->ramdump_dev); - if (drv->loadable) - pil_desc_release(&drv->q6.desc); - return 0; -} - -static struct platform_driver pil_q6v4_lpass_driver = { - .probe = pil_q6v4_lpass_driver_probe, - .remove = pil_q6v4_lpass_driver_exit, - .driver = { - .name = "pil-q6v4-lpass", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_q6v4_lpass_init(void) -{ - return platform_driver_register(&pil_q6v4_lpass_driver); -} -module_init(pil_q6v4_lpass_init); - -static void __exit pil_q6v4_lpass_exit(void) -{ - platform_driver_unregister(&pil_q6v4_lpass_driver); -} -module_exit(pil_q6v4_lpass_exit); - -MODULE_DESCRIPTION("Support for booting QDSP6v4 (Hexagon) processors"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-q6v4-mss.c b/arch/arm/mach-msm/pil-q6v4-mss.c deleted file mode 100644 index 30bc98d60aec1761a36673e5cb96245f1ba1e2be..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-q6v4-mss.c +++ /dev/null @@ -1,508 +0,0 @@ -/* Copyright (c) 2012,2013 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "peripheral-loader.h" -#include "pil-q6v4.h" -#include "scm-pas.h" - -#define MSS_S_HCLK_CTL 0x2C70 -#define MSS_SLP_CLK_CTL 0x2C60 -#define SFAB_MSS_M_ACLK_CTL 0x2340 -#define SFAB_MSS_S_HCLK_CTL 0x2C00 -#define MSS_RESET 0x2C64 - -struct q6v4_modem { - struct q6v4_data q6_fw; - struct q6v4_data q6_sw; - void __iomem *modem_base; - void __iomem *cbase; - void *fw_ramdump_dev; - void *sw_ramdump_dev; - void *smem_ramdump_dev; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; - int crash_shutdown; - int loadable; - void *pil; -}; - -static DEFINE_MUTEX(pil_q6v4_modem_lock); -static unsigned pil_q6v4_modem_count; - -/* Bring modem subsystem out of reset */ -static void pil_q6v4_init_modem(void __iomem *base, void __iomem *cbase, - void __iomem *jtag_clk) -{ - mutex_lock(&pil_q6v4_modem_lock); - if (!pil_q6v4_modem_count) { - /* Enable MSS clocks */ - writel_relaxed(0x10, cbase + SFAB_MSS_M_ACLK_CTL); - writel_relaxed(0x10, cbase + SFAB_MSS_S_HCLK_CTL); - writel_relaxed(0x10, cbase + MSS_S_HCLK_CTL); - writel_relaxed(0x10, cbase + MSS_SLP_CLK_CTL); - /* Wait for clocks to enable */ - mb(); - udelay(10); - - /* De-assert MSS reset */ - writel_relaxed(0x0, cbase + MSS_RESET); - mb(); - udelay(10); - /* Enable MSS */ - writel_relaxed(0x7, base); - } - - /* Enable JTAG clocks */ - /* TODO: Remove if/when Q6 software enables them? */ - writel_relaxed(0x10, jtag_clk); - - pil_q6v4_modem_count++; - mutex_unlock(&pil_q6v4_modem_lock); -} - -/* Put modem subsystem back into reset */ -static void pil_q6v4_shutdown_modem(struct q6v4_modem *mdm) -{ - mutex_lock(&pil_q6v4_modem_lock); - if (pil_q6v4_modem_count) - pil_q6v4_modem_count--; - if (pil_q6v4_modem_count == 0) - writel_relaxed(0x1, mdm->cbase + MSS_RESET); - mutex_unlock(&pil_q6v4_modem_lock); -} - -static int pil_q6v4_modem_boot(struct pil_desc *pil) -{ - struct q6v4_data *drv = pil_to_q6v4_data(pil); - struct q6v4_modem *mdm = dev_get_drvdata(pil->dev); - int err; - - err = pil_q6v4_power_up(drv); - if (err) - return err; - - pil_q6v4_init_modem(mdm->modem_base, mdm->cbase, drv->jtag_clk_reg); - return pil_q6v4_boot(pil); -} - -static int pil_q6v4_modem_shutdown(struct pil_desc *pil) -{ - struct q6v4_data *drv = pil_to_q6v4_data(pil); - struct q6v4_modem *mdm = dev_get_drvdata(pil->dev); - int ret; - - ret = pil_q6v4_shutdown(pil); - if (ret) - return ret; - pil_q6v4_shutdown_modem(mdm); - pil_q6v4_power_down(drv); - return 0; -} - -static struct pil_reset_ops pil_q6v4_modem_ops = { - .auth_and_reset = pil_q6v4_modem_boot, - .shutdown = pil_q6v4_modem_shutdown, - .proxy_vote = pil_q6v4_make_proxy_votes, - .proxy_unvote = pil_q6v4_remove_proxy_votes, -}; - -static struct pil_reset_ops pil_q6v4_modem_ops_trusted = { - .init_image = pil_q6v4_init_image_trusted, - .auth_and_reset = pil_q6v4_boot_trusted, - .shutdown = pil_q6v4_shutdown_trusted, - .proxy_vote = pil_q6v4_make_proxy_votes, - .proxy_unvote = pil_q6v4_remove_proxy_votes, -}; - -static void log_modem_sfr(void) -{ - u32 size; - char *smem_reason, reason[81]; - - smem_reason = smem_get_entry(SMEM_SSR_REASON_MSS0, &size); - if (!smem_reason || !size) { - pr_err("modem subsystem failure reason: (unknown, smem_get_entry failed).\n"); - return; - } - if (!smem_reason[0]) { - pr_err("modem subsystem failure reason: (unknown, init string found).\n"); - return; - } - - size = min(size, sizeof(reason)-1); - memcpy(reason, smem_reason, size); - reason[size] = '\0'; - pr_err("modem subsystem failure reason: %s.\n", reason); - - smem_reason[0] = '\0'; - wmb(); -} - -static void restart_modem(struct q6v4_modem *drv) -{ - log_modem_sfr(); - subsystem_restart_dev(drv->subsys); -} - -#define desc_to_modem(d) container_of(d, struct q6v4_modem, subsys_desc) - -static int modem_shutdown(const struct subsys_desc *subsys, bool force_stop) -{ - struct q6v4_modem *drv = desc_to_modem(subsys); - - if (force_stop) { - /* - * The watchdogs keep running even after the modem - * is shutdown. - */ - writel_relaxed(0x0, drv->q6_fw.wdog_base + 0x24); - writel_relaxed(0x0, drv->q6_sw.wdog_base + 0x24); - mb(); - } - - if (drv->loadable) { - pil_shutdown(&drv->q6_sw.desc); - pil_shutdown(&drv->q6_fw.desc); - } - - disable_irq_nosync(drv->q6_fw.wdog_irq); - disable_irq_nosync(drv->q6_sw.wdog_irq); - - return 0; -} - -static int modem_powerup(const struct subsys_desc *subsys) -{ - struct q6v4_modem *drv = desc_to_modem(subsys); - int ret; - - if (drv->loadable) { - ret = pil_boot(&drv->q6_fw.desc); - if (ret) - return ret; - ret = pil_boot(&drv->q6_sw.desc); - if (ret) { - pil_shutdown(&drv->q6_fw.desc); - return ret; - } - } - enable_irq(drv->q6_fw.wdog_irq); - enable_irq(drv->q6_sw.wdog_irq); - return 0; -} - -void modem_crash_shutdown(const struct subsys_desc *subsys) -{ - struct q6v4_modem *drv = desc_to_modem(subsys); - - drv->crash_shutdown = 1; - smsm_reset_modem(SMSM_RESET); -} - -static struct ramdump_segment smem_segments[] = { - {0x80000000, 0x00200000}, -}; - -static int modem_ramdump(int enable, const struct subsys_desc *subsys) -{ - struct q6v4_modem *drv = desc_to_modem(subsys); - int ret; - - if (!enable) - return 0; - - ret = pil_do_ramdump(&drv->q6_sw.desc, drv->sw_ramdump_dev); - if (ret < 0) - return ret; - - ret = pil_do_ramdump(&drv->q6_fw.desc, drv->fw_ramdump_dev); - if (ret < 0) - return ret; - - ret = do_elf_ramdump(drv->smem_ramdump_dev, smem_segments, - ARRAY_SIZE(smem_segments)); - if (ret < 0) - return ret; - - return 0; -} - -static void smsm_state_cb(void *data, uint32_t old_state, uint32_t new_state) -{ - struct q6v4_modem *drv = data; - - /* Ignore if we're the one that set SMSM_RESET */ - if (drv->crash_shutdown) - return; - - if (new_state & SMSM_RESET) { - pr_err("Probable fatal error on the modem.\n"); - restart_modem(drv); - } -} - -static irqreturn_t modem_wdog_bite_irq(int irq, void *dev_id) -{ - struct q6v4_modem *drv = dev_id; - restart_modem(drv); - return IRQ_HANDLED; -} - -static int -pil_q6v4_proc_init(struct q6v4_data *drv, struct platform_device *pdev, int i) -{ - static const char *name[2] = { "fw", "sw" }; - const struct pil_q6v4_pdata *pdata_p = pdev->dev.platform_data; - const struct pil_q6v4_pdata *pdata = pdata_p + i; - char reg_name[12]; - struct pil_desc *desc; - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 2 + (i * 2)); - drv->base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 3 + (i * 2)); - drv->wdog_base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->wdog_base) - return -ENOMEM; - - snprintf(reg_name, sizeof(reg_name), "%s_core_vdd", name[i]); - drv->vreg = devm_regulator_get(&pdev->dev, reg_name); - if (IS_ERR(drv->vreg)) - return PTR_ERR(drv->vreg); - - drv->xo = devm_clk_get(&pdev->dev, "xo"); - if (IS_ERR(drv->xo)) - return PTR_ERR(drv->xo); - - desc = &drv->desc; - desc->name = pdata->name; - desc->dev = &pdev->dev; - desc->owner = THIS_MODULE; - desc->proxy_timeout = 10000; - pil_q6v4_init(drv, pdata); - - if (pas_supported(pdata->pas_id) > 0) { - desc->ops = &pil_q6v4_modem_ops_trusted; - dev_info(&pdev->dev, "using secure boot for %s\n", name[i]); - } else { - desc->ops = &pil_q6v4_modem_ops; - dev_info(&pdev->dev, "using non-secure boot for %s\n", name[i]); - } - return 0; -} - -static int pil_q6v4_modem_driver_probe(struct platform_device *pdev) -{ - struct q6v4_data *drv_fw, *drv_sw; - struct q6v4_modem *drv; - struct resource *res; - struct regulator *pll_supply; - int ret; - const struct pil_q6v4_pdata *pdata = pdev->dev.platform_data; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - drv_fw = &drv->q6_fw; - drv_sw = &drv->q6_sw; - - drv_fw->wdog_irq = platform_get_irq(pdev, 0); - if (drv_fw->wdog_irq < 0) - return drv_fw->wdog_irq; - - drv_sw->wdog_irq = platform_get_irq(pdev, 1); - if (drv_sw->wdog_irq < 0) - return drv_sw->wdog_irq; - - drv->loadable = !!pdata; /* No pdata = don't use PIL */ - if (drv->loadable) { - ret = pil_q6v4_proc_init(drv_fw, pdev, 0); - if (ret) - return ret; - - ret = pil_q6v4_proc_init(drv_sw, pdev, 1); - if (ret) - return ret; - - pll_supply = devm_regulator_get(&pdev->dev, "pll_vdd"); - drv_fw->pll_supply = drv_sw->pll_supply = pll_supply; - if (IS_ERR(pll_supply)) - return PTR_ERR(pll_supply); - - ret = regulator_set_voltage(pll_supply, 1800000, 1800000); - if (ret) { - dev_err(&pdev->dev, "failed to set pll voltage\n"); - return ret; - } - - ret = regulator_set_optimum_mode(pll_supply, 100000); - if (ret < 0) { - dev_err(&pdev->dev, "failed to set pll optimum mode\n"); - return ret; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - drv->modem_base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->modem_base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!res) - return -EINVAL; - drv->cbase = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); - if (!drv->cbase) - return -ENOMEM; - - ret = pil_desc_init(&drv_fw->desc); - if (ret) - return ret; - - ret = pil_desc_init(&drv_sw->desc); - if (ret) - goto err_pil_sw; - } - - drv->subsys_desc.name = "modem"; - drv->subsys_desc.depends_on = "adsp"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.shutdown = modem_shutdown; - drv->subsys_desc.powerup = modem_powerup; - drv->subsys_desc.ramdump = modem_ramdump; - drv->subsys_desc.crash_shutdown = modem_crash_shutdown; - - drv->fw_ramdump_dev = create_ramdump_device("modem_fw", &pdev->dev); - if (!drv->fw_ramdump_dev) { - ret = -ENOMEM; - goto err_fw_ramdump; - } - - drv->sw_ramdump_dev = create_ramdump_device("modem_sw", &pdev->dev); - if (!drv->sw_ramdump_dev) { - ret = -ENOMEM; - goto err_sw_ramdump; - } - - drv->smem_ramdump_dev = create_ramdump_device("smem-modem", &pdev->dev); - if (!drv->smem_ramdump_dev) { - ret = -ENOMEM; - goto err_smem_ramdump; - } - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - ret = PTR_ERR(drv->subsys); - goto err_subsys; - } - if (!drv->loadable) - subsys_default_online(drv->subsys); - - ret = devm_request_irq(&pdev->dev, drv_fw->wdog_irq, - modem_wdog_bite_irq, IRQF_TRIGGER_RISING, - dev_name(&pdev->dev), drv); - if (ret) - goto err_irq; - disable_irq(drv_fw->wdog_irq); - - ret = devm_request_irq(&pdev->dev, drv_sw->wdog_irq, - modem_wdog_bite_irq, IRQF_TRIGGER_RISING, - dev_name(&pdev->dev), drv); - if (ret) - goto err_irq; - disable_irq(drv_sw->wdog_irq); - - scm_pas_init(MSM_BUS_MASTER_SPS); - - ret = smsm_state_cb_register(SMSM_MODEM_STATE, SMSM_RESET, - smsm_state_cb, drv); - if (ret) - goto err_irq; - return 0; - -err_irq: - subsys_unregister(drv->subsys); -err_subsys: - destroy_ramdump_device(drv->smem_ramdump_dev); -err_smem_ramdump: - destroy_ramdump_device(drv->sw_ramdump_dev); -err_sw_ramdump: - destroy_ramdump_device(drv->fw_ramdump_dev); -err_fw_ramdump: - if (drv->loadable) - pil_desc_release(&drv_sw->desc); -err_pil_sw: - pil_desc_release(&drv_fw->desc); - return ret; -} - -static int pil_q6v4_modem_driver_exit(struct platform_device *pdev) -{ - struct q6v4_modem *drv = platform_get_drvdata(pdev); - - smsm_state_cb_deregister(SMSM_MODEM_STATE, SMSM_RESET, - smsm_state_cb, drv); - subsys_unregister(drv->subsys); - destroy_ramdump_device(drv->smem_ramdump_dev); - destroy_ramdump_device(drv->sw_ramdump_dev); - destroy_ramdump_device(drv->fw_ramdump_dev); - if (drv->loadable) { - pil_desc_release(&drv->q6_sw.desc); - pil_desc_release(&drv->q6_fw.desc); - } - return 0; -} - -static struct platform_driver pil_q6v4_modem_driver = { - .probe = pil_q6v4_modem_driver_probe, - .remove = pil_q6v4_modem_driver_exit, - .driver = { - .name = "pil-q6v4-modem", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_q6v4_modem_init(void) -{ - return platform_driver_register(&pil_q6v4_modem_driver); -} -module_init(pil_q6v4_modem_init); - -static void __exit pil_q6v4_modem_exit(void) -{ - platform_driver_unregister(&pil_q6v4_modem_driver); -} -module_exit(pil_q6v4_modem_exit); - -MODULE_DESCRIPTION("Support for booting QDSP6v4 (Hexagon) processors"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-q6v4.c b/arch/arm/mach-msm/pil-q6v4.c deleted file mode 100644 index 47e3bad66f833decdd47143a68d5504a0c3de5f4..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-q6v4.c +++ /dev/null @@ -1,279 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "peripheral-loader.h" -#include "pil-q6v4.h" -#include "scm-pas.h" - -#define QDSP6SS_RST_EVB 0x0 -#define QDSP6SS_RESET 0x04 -#define QDSP6SS_STRAP_TCM 0x1C -#define QDSP6SS_STRAP_AHB 0x20 -#define QDSP6SS_GFMUX_CTL 0x30 -#define QDSP6SS_PWR_CTL 0x38 - -#define Q6SS_SS_ARES BIT(0) -#define Q6SS_CORE_ARES BIT(1) -#define Q6SS_ISDB_ARES BIT(2) -#define Q6SS_ETM_ARES BIT(3) -#define Q6SS_STOP_CORE_ARES BIT(4) -#define Q6SS_PRIV_ARES BIT(5) - -#define Q6SS_L2DATA_SLP_NRET_N BIT(0) -#define Q6SS_SLP_RET_N BIT(1) -#define Q6SS_L1TCM_SLP_NRET_N BIT(2) -#define Q6SS_L2TAG_SLP_NRET_N BIT(3) -#define Q6SS_ETB_SLEEP_NRET_N BIT(4) -#define Q6SS_ARR_STBY_N BIT(5) -#define Q6SS_CLAMP_IO BIT(6) - -#define Q6SS_CLK_ENA BIT(1) -#define Q6SS_SRC_SWITCH_CLK_OVR BIT(8) - -int pil_q6v4_make_proxy_votes(struct pil_desc *pil) -{ - const struct q6v4_data *drv = pil_to_q6v4_data(pil); - int ret; - - ret = clk_prepare_enable(drv->xo); - if (ret) { - dev_err(pil->dev, "Failed to enable XO\n"); - goto err; - } - if (drv->pll_supply) { - ret = regulator_enable(drv->pll_supply); - if (ret) { - dev_err(pil->dev, "Failed to enable pll supply\n"); - goto err_regulator; - } - } - return 0; -err_regulator: - clk_disable_unprepare(drv->xo); -err: - return ret; -} -EXPORT_SYMBOL(pil_q6v4_make_proxy_votes); - -void pil_q6v4_remove_proxy_votes(struct pil_desc *pil) -{ - const struct q6v4_data *drv = pil_to_q6v4_data(pil); - if (drv->pll_supply) - regulator_disable(drv->pll_supply); - clk_disable_unprepare(drv->xo); -} -EXPORT_SYMBOL(pil_q6v4_remove_proxy_votes); - -int pil_q6v4_power_up(struct q6v4_data *drv) -{ - int err; - struct device *dev = drv->desc.dev; - - err = regulator_set_voltage(drv->vreg, 743750, 743750); - if (err) { - dev_err(dev, "Failed to set regulator's voltage step.\n"); - return err; - } - err = regulator_enable(drv->vreg); - if (err) { - dev_err(dev, "Failed to enable regulator.\n"); - return err; - } - - /* - * Q6 hardware requires a two step voltage ramp-up. - * Delay between the steps. - */ - udelay(100); - - err = regulator_set_voltage(drv->vreg, 1050000, 1050000); - if (err) { - dev_err(dev, "Failed to set regulator's voltage.\n"); - return err; - } - drv->vreg_enabled = true; - return 0; -} -EXPORT_SYMBOL(pil_q6v4_power_up); - -void pil_q6v4_power_down(struct q6v4_data *drv) -{ - if (drv->vreg_enabled) { - regulator_disable(drv->vreg); - drv->vreg_enabled = false; - } -} -EXPORT_SYMBOL(pil_q6v4_power_down); - -int pil_q6v4_boot(struct pil_desc *pil) -{ - u32 reg, err; - const struct q6v4_data *drv = pil_to_q6v4_data(pil); - phys_addr_t start_addr = pil_get_entry_addr(pil); - - /* Enable Q6 ACLK */ - writel_relaxed(0x10, drv->aclk_reg); - - /* Unhalt bus port */ - err = msm_bus_axi_portunhalt(drv->bus_port); - if (err) - dev_err(pil->dev, "Failed to unhalt bus port\n"); - - /* Deassert Q6SS_SS_ARES */ - reg = readl_relaxed(drv->base + QDSP6SS_RESET); - reg &= ~(Q6SS_SS_ARES); - writel_relaxed(reg, drv->base + QDSP6SS_RESET); - - /* Program boot address */ - writel_relaxed((start_addr >> 8) & 0xFFFFFF, - drv->base + QDSP6SS_RST_EVB); - - /* Program TCM and AHB address ranges */ - writel_relaxed(drv->strap_tcm_base, drv->base + QDSP6SS_STRAP_TCM); - writel_relaxed(drv->strap_ahb_upper | drv->strap_ahb_lower, - drv->base + QDSP6SS_STRAP_AHB); - - /* Turn off Q6 core clock */ - writel_relaxed(Q6SS_SRC_SWITCH_CLK_OVR, - drv->base + QDSP6SS_GFMUX_CTL); - - /* Put memories to sleep */ - writel_relaxed(Q6SS_CLAMP_IO, drv->base + QDSP6SS_PWR_CTL); - - /* Assert resets */ - reg = readl_relaxed(drv->base + QDSP6SS_RESET); - reg |= (Q6SS_CORE_ARES | Q6SS_ISDB_ARES | Q6SS_ETM_ARES - | Q6SS_STOP_CORE_ARES); - writel_relaxed(reg, drv->base + QDSP6SS_RESET); - - /* Wait 8 AHB cycles for Q6 to be fully reset (AHB = 1.5Mhz) */ - mb(); - usleep_range(20, 30); - - /* Turn on Q6 memories */ - reg = Q6SS_L2DATA_SLP_NRET_N | Q6SS_SLP_RET_N | Q6SS_L1TCM_SLP_NRET_N - | Q6SS_L2TAG_SLP_NRET_N | Q6SS_ETB_SLEEP_NRET_N | Q6SS_ARR_STBY_N - | Q6SS_CLAMP_IO; - writel_relaxed(reg, drv->base + QDSP6SS_PWR_CTL); - - /* Turn on Q6 core clock */ - reg = Q6SS_CLK_ENA | Q6SS_SRC_SWITCH_CLK_OVR; - writel_relaxed(reg, drv->base + QDSP6SS_GFMUX_CTL); - - /* Remove Q6SS_CLAMP_IO */ - reg = readl_relaxed(drv->base + QDSP6SS_PWR_CTL); - reg &= ~Q6SS_CLAMP_IO; - writel_relaxed(reg, drv->base + QDSP6SS_PWR_CTL); - - /* Bring Q6 core out of reset and start execution. */ - writel_relaxed(0x0, drv->base + QDSP6SS_RESET); - - return 0; -} -EXPORT_SYMBOL(pil_q6v4_boot); - -int pil_q6v4_shutdown(struct pil_desc *pil) -{ - u32 reg; - struct q6v4_data *drv = pil_to_q6v4_data(pil); - - /* Make sure bus port is halted */ - msm_bus_axi_porthalt(drv->bus_port); - - /* Turn off Q6 core clock */ - writel_relaxed(Q6SS_SRC_SWITCH_CLK_OVR, - drv->base + QDSP6SS_GFMUX_CTL); - - /* Assert resets */ - reg = (Q6SS_SS_ARES | Q6SS_CORE_ARES | Q6SS_ISDB_ARES - | Q6SS_ETM_ARES | Q6SS_STOP_CORE_ARES | Q6SS_PRIV_ARES); - writel_relaxed(reg, drv->base + QDSP6SS_RESET); - - /* Turn off Q6 memories */ - writel_relaxed(Q6SS_CLAMP_IO, drv->base + QDSP6SS_PWR_CTL); - - return 0; -} -EXPORT_SYMBOL(pil_q6v4_shutdown); - -int pil_q6v4_init_image_trusted(struct pil_desc *pil, - const u8 *metadata, size_t size) -{ - struct q6v4_data *drv = pil_to_q6v4_data(pil); - return pas_init_image(drv->pas_id, metadata, size); -} -EXPORT_SYMBOL(pil_q6v4_init_image_trusted); - -int pil_q6v4_boot_trusted(struct pil_desc *pil) -{ - struct q6v4_data *drv = pil_to_q6v4_data(pil); - int err; - - err = pil_q6v4_power_up(drv); - if (err) - return err; - - /* Unhalt bus port */ - err = msm_bus_axi_portunhalt(drv->bus_port); - if (err) - dev_err(pil->dev, "Failed to unhalt bus port\n"); - return pas_auth_and_reset(drv->pas_id); -} -EXPORT_SYMBOL(pil_q6v4_boot_trusted); - -int pil_q6v4_shutdown_trusted(struct pil_desc *pil) -{ - int ret; - struct q6v4_data *drv = pil_to_q6v4_data(pil); - - /* Make sure bus port is halted */ - msm_bus_axi_porthalt(drv->bus_port); - - ret = pas_shutdown(drv->pas_id); - if (ret) - return ret; - - pil_q6v4_power_down(drv); - - return ret; -} -EXPORT_SYMBOL(pil_q6v4_shutdown_trusted); - -void -pil_q6v4_init(struct q6v4_data *drv, const struct pil_q6v4_pdata *pdata) -{ - drv->strap_tcm_base = pdata->strap_tcm_base; - drv->strap_ahb_upper = pdata->strap_ahb_upper; - drv->strap_ahb_lower = pdata->strap_ahb_lower; - drv->aclk_reg = pdata->aclk_reg; - drv->jtag_clk_reg = pdata->jtag_clk_reg; - drv->pas_id = pdata->pas_id; - drv->bus_port = pdata->bus_port; - - regulator_set_optimum_mode(drv->vreg, 100000); -} -EXPORT_SYMBOL(pil_q6v4_init); - -MODULE_DESCRIPTION("Support for booting QDSP6v4 (Hexagon) processors"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-q6v4.h b/arch/arm/mach-msm/pil-q6v4.h deleted file mode 100644 index 70fd3342f45bb6de65deee3cd61c411344f450ef..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-q6v4.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2011-2012, 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 __MSM_PIL_Q6V4_H -#define __MSM_PIL_Q6V4_H - -#include "peripheral-loader.h" - -struct pil_q6v4_pdata { - const unsigned long strap_tcm_base; - const unsigned long strap_ahb_upper; - const unsigned long strap_ahb_lower; - void __iomem *aclk_reg; - void __iomem *jtag_clk_reg; - const char *name; - const unsigned pas_id; - int bus_port; -}; - -struct clk; -struct pil_device; -struct regulator; - -/** - * struct q6v4_data - Q6 processor - */ -struct q6v4_data { - void __iomem *base; - void __iomem *wdog_base; - unsigned long strap_tcm_base; - unsigned long strap_ahb_upper; - unsigned long strap_ahb_lower; - void __iomem *aclk_reg; - void __iomem *jtag_clk_reg; - unsigned pas_id; - int bus_port; - int wdog_irq; - - struct regulator *vreg; - struct regulator *pll_supply; - bool vreg_enabled; - struct clk *xo; - - struct pil_desc desc; -}; - -#define pil_to_q6v4_data(p) container_of(p, struct q6v4_data, desc) - -extern int pil_q6v4_make_proxy_votes(struct pil_desc *pil); -extern void pil_q6v4_remove_proxy_votes(struct pil_desc *pil); -extern int pil_q6v4_power_up(struct q6v4_data *drv); -extern void pil_q6v4_power_down(struct q6v4_data *drv); -extern int pil_q6v4_boot(struct pil_desc *pil); -extern int pil_q6v4_shutdown(struct pil_desc *pil); - -extern int pil_q6v4_init_image_trusted(struct pil_desc *pil, - const u8 *metadata, size_t size); -extern int pil_q6v4_boot_trusted(struct pil_desc *pil); -extern int pil_q6v4_shutdown_trusted(struct pil_desc *pil); -extern void -pil_q6v4_init(struct q6v4_data *drv, const struct pil_q6v4_pdata *p); - -#endif diff --git a/arch/arm/mach-msm/pil-riva.c b/arch/arm/mach-msm/pil-riva.c deleted file mode 100644 index b0ca80d2f92f5281eacd7f296020796494360d09..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-riva.c +++ /dev/null @@ -1,577 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "peripheral-loader.h" -#include "scm-pas.h" - -#define RIVA_PMU_A2XB_CFG 0xB8 -#define RIVA_PMU_A2XB_CFG_EN BIT(0) - -#define RIVA_PMU_CFG 0x28 -#define RIVA_PMU_CFG_WARM_BOOT BIT(0) -#define RIVA_PMU_CFG_IRIS_XO_MODE 0x6 -#define RIVA_PMU_CFG_IRIS_XO_MODE_48 (3 << 1) - -#define RIVA_PMU_OVRD_EN 0x2C -#define RIVA_PMU_OVRD_EN_CCPU_RESET BIT(0) -#define RIVA_PMU_OVRD_EN_CCPU_CLK BIT(1) - -#define RIVA_PMU_OVRD_VAL 0x30 -#define RIVA_PMU_OVRD_VAL_CCPU_RESET BIT(0) -#define RIVA_PMU_OVRD_VAL_CCPU_CLK BIT(1) - -#define RIVA_PMU_CCPU_CTL 0x9C -#define RIVA_PMU_CCPU_CTL_HIGH_IVT BIT(0) -#define RIVA_PMU_CCPU_CTL_REMAP_EN BIT(2) - -#define RIVA_PMU_CCPU_BOOT_REMAP_ADDR 0xA0 - -#define RIVA_PLL_MODE 0x31A0 -#define PLL_MODE_OUTCTRL BIT(0) -#define PLL_MODE_BYPASSNL BIT(1) -#define PLL_MODE_RESET_N BIT(2) -#define PLL_MODE_REF_XO_SEL 0x30 -#define PLL_MODE_REF_XO_SEL_CXO (2 << 4) -#define PLL_MODE_REF_XO_SEL_RF (3 << 4) -#define RIVA_PLL_L_VAL 0x31A4 -#define RIVA_PLL_M_VAL 0x31A8 -#define RIVA_PLL_N_VAL 0x31Ac -#define RIVA_PLL_CONFIG 0x31B4 -#define RIVA_RESET 0x35E0 - -#define RIVA_PMU_ROOT_CLK_SEL 0xC8 -#define RIVA_PMU_ROOT_CLK_SEL_3 BIT(2) - -#define RIVA_PMU_CLK_ROOT3 0x78 -#define RIVA_PMU_CLK_ROOT3_ENA BIT(0) -#define RIVA_PMU_CLK_ROOT3_SRC0_DIV 0x3C -#define RIVA_PMU_CLK_ROOT3_SRC0_DIV_2 (1 << 2) -#define RIVA_PMU_CLK_ROOT3_SRC0_SEL 0x1C0 -#define RIVA_PMU_CLK_ROOT3_SRC0_SEL_RIVA (1 << 6) -#define RIVA_PMU_CLK_ROOT3_SRC1_DIV 0x1E00 -#define RIVA_PMU_CLK_ROOT3_SRC1_DIV_2 (1 << 9) -#define RIVA_PMU_CLK_ROOT3_SRC1_SEL 0xE000 -#define RIVA_PMU_CLK_ROOT3_SRC1_SEL_RIVA (1 << 13) - -struct riva_data { - void __iomem *base; - void __iomem *cbase; - struct clk *xo; - struct regulator *pll_supply; - struct pil_desc pil_desc; - int irq; - int crash; - int rst_in_progress; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; - struct ramdump_device *ramdump_dev; - int xo_mode; -}; - -static bool cxo_is_needed(struct riva_data *drv) -{ - u32 reg = readl_relaxed(drv->base + RIVA_PMU_CFG); - return (reg & RIVA_PMU_CFG_IRIS_XO_MODE) - != RIVA_PMU_CFG_IRIS_XO_MODE_48; -} - -static int pil_riva_make_proxy_vote(struct pil_desc *pil) -{ - struct riva_data *drv = dev_get_drvdata(pil->dev); - struct platform_device *pdev = wcnss_get_platform_device(); - struct wcnss_wlan_config *pwlanconfig = wcnss_get_wlan_config(); - int ret; - - ret = regulator_enable(drv->pll_supply); - if (ret) { - dev_err(pil->dev, "failed to enable pll supply\n"); - goto err; - } - ret = clk_prepare_enable(drv->xo); - if (ret) { - dev_err(pil->dev, "failed to enable xo\n"); - goto err_clk; - } - if (pdev && pwlanconfig) { - ret = wcnss_wlan_power(&pdev->dev, pwlanconfig, - WCNSS_WLAN_SWITCH_ON, &drv->xo_mode); - wcnss_set_iris_xo_mode(drv->xo_mode); - if (ret) - pr_err("Failed to execute wcnss_wlan_power\n"); - } - - return 0; -err_clk: - regulator_disable(drv->pll_supply); -err: - return ret; -} - -static void pil_riva_remove_proxy_vote(struct pil_desc *pil) -{ - struct riva_data *drv = dev_get_drvdata(pil->dev); - struct platform_device *pdev = wcnss_get_platform_device(); - struct wcnss_wlan_config *pwlanconfig = wcnss_get_wlan_config(); - - regulator_disable(drv->pll_supply); - clk_disable_unprepare(drv->xo); - if (pdev && pwlanconfig) { - /* Temporary workaround as riva sends interrupt that - * it is capable of voting for it's resources too early. */ - msleep(20); - wcnss_wlan_power(&pdev->dev, pwlanconfig, - WCNSS_WLAN_SWITCH_OFF, NULL); - } -} - -static int pil_riva_reset(struct pil_desc *pil) -{ - u32 reg, sel; - struct riva_data *drv = dev_get_drvdata(pil->dev); - void __iomem *base = drv->base; - phys_addr_t start_addr = pil_get_entry_addr(pil); - void __iomem *cbase = drv->cbase; - bool use_cxo = cxo_is_needed(drv); - - /* Enable A2XB bridge */ - reg = readl_relaxed(base + RIVA_PMU_A2XB_CFG); - reg |= RIVA_PMU_A2XB_CFG_EN; - writel_relaxed(reg, base + RIVA_PMU_A2XB_CFG); - - /* Program PLL 13 to 960 MHz */ - reg = readl_relaxed(cbase + RIVA_PLL_MODE); - reg &= ~(PLL_MODE_BYPASSNL | PLL_MODE_OUTCTRL | PLL_MODE_RESET_N); - writel_relaxed(reg, cbase + RIVA_PLL_MODE); - - if (use_cxo) - writel_relaxed(0x40000C00 | 50, cbase + RIVA_PLL_L_VAL); - else - writel_relaxed(0x40000C00 | 40, cbase + RIVA_PLL_L_VAL); - writel_relaxed(0, cbase + RIVA_PLL_M_VAL); - writel_relaxed(1, cbase + RIVA_PLL_N_VAL); - writel_relaxed(0x01495227, cbase + RIVA_PLL_CONFIG); - - reg = readl_relaxed(cbase + RIVA_PLL_MODE); - reg &= ~(PLL_MODE_REF_XO_SEL); - reg |= use_cxo ? PLL_MODE_REF_XO_SEL_CXO : PLL_MODE_REF_XO_SEL_RF; - writel_relaxed(reg, cbase + RIVA_PLL_MODE); - - /* Enable PLL 13 */ - reg |= PLL_MODE_BYPASSNL; - writel_relaxed(reg, cbase + RIVA_PLL_MODE); - - /* - * H/W requires a 5us delay between disabling the bypass and - * de-asserting the reset. Delay 10us just to be safe. - */ - mb(); - usleep_range(10, 20); - - reg |= PLL_MODE_RESET_N; - writel_relaxed(reg, cbase + RIVA_PLL_MODE); - reg |= PLL_MODE_OUTCTRL; - writel_relaxed(reg, cbase + RIVA_PLL_MODE); - - /* Wait for PLL to settle */ - mb(); - usleep_range(50, 100); - - /* Configure cCPU for 240 MHz */ - sel = readl_relaxed(base + RIVA_PMU_ROOT_CLK_SEL); - reg = readl_relaxed(base + RIVA_PMU_CLK_ROOT3); - if (sel & RIVA_PMU_ROOT_CLK_SEL_3) { - reg &= ~(RIVA_PMU_CLK_ROOT3_SRC0_SEL | - RIVA_PMU_CLK_ROOT3_SRC0_DIV); - reg |= RIVA_PMU_CLK_ROOT3_SRC0_SEL_RIVA | - RIVA_PMU_CLK_ROOT3_SRC0_DIV_2; - } else { - reg &= ~(RIVA_PMU_CLK_ROOT3_SRC1_SEL | - RIVA_PMU_CLK_ROOT3_SRC1_DIV); - reg |= RIVA_PMU_CLK_ROOT3_SRC1_SEL_RIVA | - RIVA_PMU_CLK_ROOT3_SRC1_DIV_2; - } - writel_relaxed(reg, base + RIVA_PMU_CLK_ROOT3); - reg |= RIVA_PMU_CLK_ROOT3_ENA; - writel_relaxed(reg, base + RIVA_PMU_CLK_ROOT3); - reg = readl_relaxed(base + RIVA_PMU_ROOT_CLK_SEL); - reg ^= RIVA_PMU_ROOT_CLK_SEL_3; - writel_relaxed(reg, base + RIVA_PMU_ROOT_CLK_SEL); - - /* Use the high vector table */ - reg = readl_relaxed(base + RIVA_PMU_CCPU_CTL); - reg |= RIVA_PMU_CCPU_CTL_HIGH_IVT | RIVA_PMU_CCPU_CTL_REMAP_EN; - writel_relaxed(reg, base + RIVA_PMU_CCPU_CTL); - - /* Set base memory address */ - writel_relaxed(start_addr >> 16, base + RIVA_PMU_CCPU_BOOT_REMAP_ADDR); - - /* Clear warmboot bit indicating this is a cold boot */ - reg = readl_relaxed(base + RIVA_PMU_CFG); - reg &= ~(RIVA_PMU_CFG_WARM_BOOT); - writel_relaxed(reg, base + RIVA_PMU_CFG); - - /* Enable the cCPU clock */ - reg = readl_relaxed(base + RIVA_PMU_OVRD_VAL); - reg |= RIVA_PMU_OVRD_VAL_CCPU_CLK; - writel_relaxed(reg, base + RIVA_PMU_OVRD_VAL); - - /* Take cCPU out of reset */ - reg |= RIVA_PMU_OVRD_VAL_CCPU_RESET; - writel_relaxed(reg, base + RIVA_PMU_OVRD_VAL); - - return 0; -} - -static int pil_riva_shutdown(struct pil_desc *pil) -{ - struct riva_data *drv = dev_get_drvdata(pil->dev); - void __iomem *cbase = drv->cbase; - - /* Assert reset to Riva */ - writel_relaxed(1, cbase + RIVA_RESET); - mb(); - usleep_range(1000, 2000); - - /* Deassert reset to Riva */ - writel_relaxed(0, cbase + RIVA_RESET); - mb(); - - return 0; -} - -static struct pil_reset_ops pil_riva_ops = { - .auth_and_reset = pil_riva_reset, - .shutdown = pil_riva_shutdown, - .proxy_vote = pil_riva_make_proxy_vote, - .proxy_unvote = pil_riva_remove_proxy_vote, -}; - -static int pil_riva_init_image_trusted(struct pil_desc *pil, - const u8 *metadata, size_t size) -{ - return pas_init_image(PAS_WCNSS, metadata, size); -} - -static int pil_riva_reset_trusted(struct pil_desc *pil) -{ - return pas_auth_and_reset(PAS_WCNSS); -} - -static int pil_riva_shutdown_trusted(struct pil_desc *pil) -{ - return pas_shutdown(PAS_WCNSS); -} - -static struct pil_reset_ops pil_riva_ops_trusted = { - .init_image = pil_riva_init_image_trusted, - .auth_and_reset = pil_riva_reset_trusted, - .shutdown = pil_riva_shutdown_trusted, - .proxy_vote = pil_riva_make_proxy_vote, - .proxy_unvote = pil_riva_remove_proxy_vote, -}; - -static int enable_riva_ssr; - -static int enable_riva_ssr_set(const char *val, struct kernel_param *kp) -{ - int ret; - - ret = param_set_int(val, kp); - if (ret) - return ret; - - if (enable_riva_ssr) - pr_info("Subsystem restart activated for riva.\n"); - - return 0; -} -module_param_call(enable_riva_ssr, enable_riva_ssr_set, param_get_int, - &enable_riva_ssr, S_IRUGO | S_IWUSR); - -static void smsm_state_cb_hdlr(void *data, uint32_t old_state, - uint32_t new_state) -{ - struct riva_data *drv = data; - char *smem_reset_reason; - char buffer[81]; - unsigned smem_reset_size; - unsigned size; - - drv->crash = true; - if (!(new_state & SMSM_RESET)) - return; - - if (drv->rst_in_progress) { - pr_err("riva: Ignoring smsm reset req, restart in progress\n"); - return; - } - - pr_err("riva: smsm state changed to smsm reset\n"); - wcnss_riva_dump_pmic_regs(); - - smem_reset_reason = smem_get_entry(SMEM_SSR_REASON_WCNSS0, - &smem_reset_size); - - if (!smem_reset_reason || !smem_reset_size) { - pr_err("wcnss subsystem failure reason:\n" - "(unknown, smem_get_entry failed)"); - } else if (!smem_reset_reason[0]) { - pr_err("wcnss subsystem failure reason:\n" - "(unknown, init string found)"); - } else { - size = smem_reset_size < sizeof(buffer) ? smem_reset_size : - (sizeof(buffer) - 1); - memcpy(buffer, smem_reset_reason, size); - buffer[size] = '\0'; - pr_err("wcnss subsystem failure reason: %s\n", buffer); - memset(smem_reset_reason, 0, smem_reset_size); - wmb(); - } - - drv->rst_in_progress = 1; - subsystem_restart_dev(drv->subsys); -} - -static irqreturn_t riva_wdog_bite_irq_hdlr(int irq, void *dev_id) -{ - struct riva_data *drv = dev_id; - - drv->crash = true; - if (drv->rst_in_progress) { - pr_err("Ignoring riva bite irq, restart in progress\n"); - return IRQ_HANDLED; - } - if (!enable_riva_ssr) - panic("Watchdog bite received from Riva"); - - drv->rst_in_progress = 1; - wcnss_riva_log_debug_regs(); - subsystem_restart_dev(drv->subsys); - - return IRQ_HANDLED; -} - -static int riva_shutdown(const struct subsys_desc *desc, bool force_stop) -{ - struct riva_data *drv; - - drv = container_of(desc, struct riva_data, subsys_desc); - pil_shutdown(&drv->pil_desc); - disable_irq_nosync(drv->irq); - return 0; -} - -static int riva_powerup(const struct subsys_desc *desc) -{ - struct riva_data *drv; - int ret; - - drv = container_of(desc, struct riva_data, subsys_desc); - ret = pil_boot(&drv->pil_desc); - if (ret) - return ret; - - drv->rst_in_progress = 0; - enable_irq(drv->irq); - return ret; -} - -static int riva_ramdump(int enable, const struct subsys_desc *desc) -{ - struct riva_data *drv; - - drv = container_of(desc, struct riva_data, subsys_desc); - - if (!enable) - return 0; - - return pil_do_ramdump(&drv->pil_desc, drv->ramdump_dev); -} - -/* Riva crash handler */ -static void riva_crash_shutdown(const struct subsys_desc *desc) -{ - struct riva_data *drv; - - drv = container_of(desc, struct riva_data, subsys_desc); - pr_err("riva crash shutdown %d\n", drv->crash); - if (drv->crash != true) - smsm_change_state(SMSM_APPS_STATE, SMSM_RESET, SMSM_RESET); -} - -static int pil_riva_probe(struct platform_device *pdev) -{ - struct riva_data *drv; - struct resource *res; - struct pil_desc *desc; - int ret; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - drv->base = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->base) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - drv->cbase = devm_request_and_ioremap(&pdev->dev, res); - if (!drv->cbase) - return -ENOMEM; - - drv->pll_supply = devm_regulator_get(&pdev->dev, "pll_vdd"); - if (IS_ERR(drv->pll_supply)) { - dev_err(&pdev->dev, "failed to get pll supply\n"); - return PTR_ERR(drv->pll_supply); - } - if (regulator_count_voltages(drv->pll_supply) > 0) { - ret = regulator_set_voltage(drv->pll_supply, 1800000, 1800000); - if (ret) { - dev_err(&pdev->dev, - "failed to set pll supply voltage\n"); - return ret; - } - - ret = regulator_set_optimum_mode(drv->pll_supply, 100000); - if (ret < 0) { - dev_err(&pdev->dev, - "failed to set pll supply optimum mode\n"); - return ret; - } - } - - drv->irq = platform_get_irq(pdev, 0); - if (drv->irq < 0) - return drv->irq; - - drv->xo = devm_clk_get(&pdev->dev, "cxo"); - if (IS_ERR(drv->xo)) - return PTR_ERR(drv->xo); - - desc = &drv->pil_desc; - desc->name = "wcnss"; - desc->dev = &pdev->dev; - desc->owner = THIS_MODULE; - desc->proxy_timeout = 10000; - - if (pas_supported(PAS_WCNSS) > 0) { - desc->ops = &pil_riva_ops_trusted; - dev_info(&pdev->dev, "using secure boot\n"); - } else { - desc->ops = &pil_riva_ops; - dev_info(&pdev->dev, "using non-secure boot\n"); - } - ret = pil_desc_init(desc); - - ret = smsm_state_cb_register(SMSM_WCNSS_STATE, SMSM_RESET, - smsm_state_cb_hdlr, drv); - if (ret < 0) - goto err_smsm; - - drv->subsys_desc.name = "wcnss"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.shutdown = riva_shutdown; - drv->subsys_desc.powerup = riva_powerup; - drv->subsys_desc.ramdump = riva_ramdump; - drv->subsys_desc.crash_shutdown = riva_crash_shutdown; - - drv->ramdump_dev = create_ramdump_device("riva", &pdev->dev); - if (!drv->ramdump_dev) { - ret = -ENOMEM; - goto err_ramdump; - } - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - ret = PTR_ERR(drv->subsys); - goto err_subsys; - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - ret = devm_request_irq(&pdev->dev, drv->irq, riva_wdog_bite_irq_hdlr, - IRQF_TRIGGER_RISING, "riva_wdog", drv); - if (ret < 0) - goto err; - disable_irq(drv->irq); - - return 0; -err: - subsys_unregister(drv->subsys); -err_subsys: - destroy_ramdump_device(drv->ramdump_dev); -err_ramdump: - smsm_state_cb_deregister(SMSM_WCNSS_STATE, SMSM_RESET, - smsm_state_cb_hdlr, drv); -err_smsm: - pil_desc_release(desc); - return ret; -} - -static int pil_riva_remove(struct platform_device *pdev) -{ - struct riva_data *drv = platform_get_drvdata(pdev); - - subsys_unregister(drv->subsys); - destroy_ramdump_device(drv->ramdump_dev); - smsm_state_cb_deregister(SMSM_WCNSS_STATE, SMSM_RESET, - smsm_state_cb_hdlr, drv); - pil_desc_release(&drv->pil_desc); - - return 0; -} - -static struct platform_driver pil_riva_driver = { - .probe = pil_riva_probe, - .remove = pil_riva_remove, - .driver = { - .name = "pil_riva", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_riva_init(void) -{ - return platform_driver_register(&pil_riva_driver); -} -module_init(pil_riva_init); - -static void __exit pil_riva_exit(void) -{ - platform_driver_unregister(&pil_riva_driver); -} -module_exit(pil_riva_exit); - -MODULE_DESCRIPTION("Support for booting RIVA (WCNSS) processors"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-tzapps.c b/arch/arm/mach-msm/pil-tzapps.c deleted file mode 100644 index 4ced51b7934ed78ee14ffc79d338692ad8e07d2d..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-tzapps.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include - -#include -#include - -#include "peripheral-loader.h" -#include "scm-pas.h" - -struct tzapps_data { - struct pil_desc pil_desc; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; -}; - -static int pil_tzapps_init_image(struct pil_desc *pil, const u8 *metadata, - size_t size) -{ - return pas_init_image(PAS_TZAPPS, metadata, size); -} - -static int pil_tzapps_reset(struct pil_desc *pil) -{ - return pas_auth_and_reset(PAS_TZAPPS); -} - -static int pil_tzapps_shutdown(struct pil_desc *pil) -{ - return pas_shutdown(PAS_TZAPPS); -} - -static struct pil_reset_ops pil_tzapps_ops = { - .init_image = pil_tzapps_init_image, - .auth_and_reset = pil_tzapps_reset, - .shutdown = pil_tzapps_shutdown, -}; - -#define subsys_to_drv(d) container_of(d, struct tzapps_data, subsys_desc) - -static int tzapps_powerup(const struct subsys_desc *desc) -{ - struct tzapps_data *drv = subsys_to_drv(desc); - - return pil_boot(&drv->pil_desc); -} - -static int tzapps_shutdown(const struct subsys_desc *desc, bool force_stop) -{ - struct tzapps_data *drv = subsys_to_drv(desc); - pil_shutdown(&drv->pil_desc); - return 0; -} - -static int pil_tzapps_driver_probe(struct platform_device *pdev) -{ - struct pil_desc *desc; - struct tzapps_data *drv; - int ret; - - if (pas_supported(PAS_TZAPPS) < 0) - return -ENOSYS; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - desc = &drv->pil_desc; - desc->name = "tzapps"; - desc->dev = &pdev->dev; - desc->ops = &pil_tzapps_ops; - desc->owner = THIS_MODULE; - ret = pil_desc_init(desc); - if (ret) - return ret; - - drv->subsys_desc.name = "tzapps"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.powerup = tzapps_powerup; - drv->subsys_desc.shutdown = tzapps_shutdown; - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - pil_desc_release(desc); - return PTR_ERR(drv->subsys); - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - return 0; -} - -static int pil_tzapps_driver_exit(struct platform_device *pdev) -{ - struct tzapps_data *drv = platform_get_drvdata(pdev); - subsys_unregister(drv->subsys); - pil_desc_release(&drv->pil_desc); - return 0; -} - -static struct platform_driver pil_tzapps_driver = { - .probe = pil_tzapps_driver_probe, - .remove = pil_tzapps_driver_exit, - .driver = { - .name = "pil_tzapps", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_tzapps_init(void) -{ - return platform_driver_register(&pil_tzapps_driver); -} -module_init(pil_tzapps_init); - -static void __exit pil_tzapps_exit(void) -{ - platform_driver_unregister(&pil_tzapps_driver); -} -module_exit(pil_tzapps_exit); - -MODULE_DESCRIPTION("Support for booting TZApps images"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pil-vidc.c b/arch/arm/mach-msm/pil-vidc.c deleted file mode 100644 index aed9b354afd8d061ca1a4efc62d8ee0ec2bd7c48..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pil-vidc.c +++ /dev/null @@ -1,163 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include - -#include -#include - -#include "peripheral-loader.h" -#include "scm-pas.h" - -struct vidc_data { - struct clk *smmu_iface; - struct clk *core; - struct pil_desc pil_desc; - struct subsys_device *subsys; - struct subsys_desc subsys_desc; -}; - -static int pil_vidc_init_image(struct pil_desc *pil, const u8 *metadata, - size_t size) -{ - return pas_init_image(PAS_VIDC, metadata, size); -} - -static int pil_vidc_reset(struct pil_desc *pil) -{ - int ret; - struct vidc_data *drv = dev_get_drvdata(pil->dev); - - ret = clk_prepare_enable(drv->smmu_iface); - if (ret) - goto err_smmu; - ret = clk_prepare_enable(drv->core); - if (ret) - goto err_core; - ret = pas_auth_and_reset(PAS_VIDC); - - clk_disable_unprepare(drv->core); -err_core: - clk_disable_unprepare(drv->smmu_iface); -err_smmu: - return ret; -} - -static int pil_vidc_shutdown(struct pil_desc *pil) -{ - return pas_shutdown(PAS_VIDC); -} - -static struct pil_reset_ops pil_vidc_ops = { - .init_image = pil_vidc_init_image, - .auth_and_reset = pil_vidc_reset, - .shutdown = pil_vidc_shutdown, -}; - -#define subsys_to_drv(d) container_of(d, struct vidc_data, subsys_desc) - -static int vidc_powerup(const struct subsys_desc *desc) -{ - struct vidc_data *drv = subsys_to_drv(desc); - return pil_boot(&drv->pil_desc); -} - -static int vidc_shutdown(const struct subsys_desc *desc, bool force_stop) -{ - struct vidc_data *drv = subsys_to_drv(desc); - pil_shutdown(&drv->pil_desc); - return 0; -} - -static int pil_vidc_driver_probe(struct platform_device *pdev) -{ - struct pil_desc *desc; - struct vidc_data *drv; - int ret; - - if (pas_supported(PAS_VIDC) < 0) - return -ENOSYS; - - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (!drv) - return -ENOMEM; - platform_set_drvdata(pdev, drv); - - drv->smmu_iface = devm_clk_get(&pdev->dev, "smmu_iface_clk"); - if (IS_ERR(drv->smmu_iface)) - return PTR_ERR(drv->smmu_iface); - - drv->core = devm_clk_get(&pdev->dev, "core_clk"); - if (IS_ERR(drv->core)) - return PTR_ERR(drv->core); - - desc = &drv->pil_desc; - desc->name = "vidc"; - desc->dev = &pdev->dev; - desc->ops = &pil_vidc_ops; - desc->owner = THIS_MODULE; - ret = pil_desc_init(desc); - if (ret) - return ret; - - drv->subsys_desc.name = "vidc"; - drv->subsys_desc.dev = &pdev->dev; - drv->subsys_desc.owner = THIS_MODULE; - drv->subsys_desc.powerup = vidc_powerup; - drv->subsys_desc.shutdown = vidc_shutdown; - - drv->subsys = subsys_register(&drv->subsys_desc); - if (IS_ERR(drv->subsys)) { - pil_desc_release(desc); - return PTR_ERR(drv->subsys); - } - - scm_pas_init(MSM_BUS_MASTER_SPS); - - return 0; -} - -static int pil_vidc_driver_exit(struct platform_device *pdev) -{ - struct vidc_data *drv = platform_get_drvdata(pdev); - subsys_unregister(drv->subsys); - pil_desc_release(&drv->pil_desc); - return 0; -} - -static struct platform_driver pil_vidc_driver = { - .probe = pil_vidc_driver_probe, - .remove = pil_vidc_driver_exit, - .driver = { - .name = "pil_vidc", - .owner = THIS_MODULE, - }, -}; - -static int __init pil_vidc_init(void) -{ - return platform_driver_register(&pil_vidc_driver); -} -module_init(pil_vidc_init); - -static void __exit pil_vidc_exit(void) -{ - platform_driver_unregister(&pil_vidc_driver); -} -module_exit(pil_vidc_exit); - -MODULE_DESCRIPTION("Support for secure booting vidc images"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/ping_apps_server.c b/arch/arm/mach-msm/ping_apps_server.c deleted file mode 100644 index 4499f7637ec24b60653513ffccaaa469af47eb53..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/ping_apps_server.c +++ /dev/null @@ -1,605 +0,0 @@ -/* Copyright (c) 2010, 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. - * - */ - -/* - * PING APPS SERVER Driver - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* ping server definitions */ - -#define PING_APPS_PROG 0x30000082 -#define PING_APPS_VERS 0x00010001 - -#define PING_APPS_NULL 0 -#define PING_APPS_DATA 4 -#define PING_APPS_REG 2 -#define PING_APPS_UNREG 3 -#define PING_APPS_DATA_CB_REG 6 -#define PING_APPS_DATA_CB_UNREG 5 - -#define PING_APPS_REG_CB 2 -#define PING_APPS_DATA_CB 1 - -static LIST_HEAD(cb_entry_list); -static DEFINE_MUTEX(cb_entry_list_lock); - -static struct task_struct *server_thread; - -struct ping_apps_register_arg { - uint32_t cb_id; - int32_t num; -}; - -struct ping_apps_unregister_arg { - uint32_t cb_id; -}; - -struct ping_apps_register_cb_arg { - uint32_t cb_id; - int32_t num; -}; - -struct ping_apps_register_ret { - uint32_t result; -}; - -struct ping_apps_unregister_ret { - uint32_t result; -}; - -struct ping_apps_data_cb_reg_arg { - uint32_t cb_id; - uint32_t num; - uint32_t size; - uint32_t interval_ms; - uint32_t num_tasks; -}; - -struct ping_apps_data_cb_unreg_arg { - uint32_t cb_id; -}; - -struct ping_apps_data_cb_arg { - uint32_t cb_id; - uint32_t *data; - uint32_t size; - uint32_t sum; -}; - -struct ping_apps_data_cb_reg_ret { - uint32_t result; -}; - -struct ping_apps_data_cb_unreg_ret { - uint32_t result; -}; - -struct ping_apps_data_cb_ret { - uint32_t result; -}; - -struct ping_apps_data_arg { - uint32_t *data; - uint32_t size; -}; - -struct ping_apps_data_ret { - uint32_t result; -}; - -struct ping_apps_data_cb_info { - void *cb_func; - uint32_t size; - uint32_t num_tasks; -}; - -struct ping_apps_cb_entry { - struct list_head list; - - struct msm_rpc_client_info clnt_info; - void *cb_info; - uint32_t cb_id; - int32_t num; - uint32_t interval_ms; - uint32_t time_to_next_cb; - void (*cb_func)(struct ping_apps_cb_entry *); -}; - -static int handle_rpc_call(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr); - -static int ping_apps_data_cb(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - struct ping_apps_data_cb_arg *arg, - struct ping_apps_data_cb_ret *ret); - -static int ping_apps_register_cb(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - struct ping_apps_register_cb_arg *arg, - void *ret); - -static struct msm_rpc_server rpc_server = { - .prog = PING_APPS_PROG, - .vers = PING_APPS_VERS, - .rpc_call2 = handle_rpc_call, -}; - -static void handle_ping_apps_data_cb(struct ping_apps_cb_entry *cb_entry) -{ - struct ping_apps_data_cb_arg arg; - struct ping_apps_data_cb_ret ret; - uint32_t my_sum = 0; - uint32_t *my_data; - int i; - - if (cb_entry->num > 0) { - cb_entry->num--; - arg.cb_id = cb_entry->cb_id; - arg.size = ((struct ping_apps_data_cb_info *) - (cb_entry->cb_info))->size; - - my_data = kmalloc((arg.size * sizeof(uint32_t)), GFP_KERNEL); - if (!my_data) - return; - - for (i = 0; i < arg.size; i++) { - my_data[i] = (42 + i); - my_sum ^= (42 + i); - } - arg.data = my_data; - arg.sum = my_sum; - - ((int (*)(struct msm_rpc_server *, - struct msm_rpc_client_info *, - struct ping_apps_data_cb_arg *, - struct ping_apps_data_cb_ret *)) - ((struct ping_apps_data_cb_info *) - (cb_entry->cb_info))->cb_func)(&rpc_server, - &cb_entry->clnt_info, - &arg, &ret); - pr_info("%s: cb_id = %d, ret = %d\n", - __func__, arg.cb_id, ret.result); - kfree(my_data); - } -} - -static void handle_ping_apps_register_cb(struct ping_apps_cb_entry *cb_entry) -{ - struct ping_apps_register_cb_arg arg; - - if (cb_entry->num > 0) { - cb_entry->num--; - arg.cb_id = cb_entry->cb_id; - arg.num = cb_entry->num; - - pr_info("%s: cb_id = %d, num = %d\n", - __func__, arg.cb_id, arg.num); - ((int (*)(struct msm_rpc_server *, - struct msm_rpc_client_info *, - struct ping_apps_register_cb_arg *, - void *))cb_entry->cb_info)(&rpc_server, - &cb_entry->clnt_info, - &arg, NULL); - } - -} - -static int ping_apps_cb_process_thread(void *data) -{ - struct ping_apps_cb_entry *cb_entry; - uint32_t sleep_time; - uint32_t time_slept = 0; - - pr_info("%s: thread started\n", __func__); - for (;;) { - sleep_time = 1000; - mutex_lock(&cb_entry_list_lock); - list_for_each_entry(cb_entry, &cb_entry_list, list) { - if (cb_entry->time_to_next_cb <= time_slept) { - cb_entry->cb_func(cb_entry); - cb_entry->time_to_next_cb = - cb_entry->interval_ms; - } else - cb_entry->time_to_next_cb -= time_slept; - - if (cb_entry->time_to_next_cb < sleep_time) - sleep_time = cb_entry->time_to_next_cb; - } - mutex_unlock(&cb_entry_list_lock); - - msleep(sleep_time); - time_slept = sleep_time; - } - - do_exit(0); -} - -static int ping_apps_data_register(struct ping_apps_data_arg *arg, - struct ping_apps_data_ret *ret) -{ - int i; - - ret->result = 0; - for (i = 0; i < arg->size; i++) - ret->result ^= arg->data[i]; - - return 0; -} - -static int ping_apps_data_cb_reg(struct ping_apps_data_cb_reg_arg *arg, - struct ping_apps_data_cb_reg_ret *ret) -{ - struct ping_apps_cb_entry *cb_entry; - struct ping_apps_data_cb_info *cb_info; - - cb_entry = kmalloc(sizeof(*cb_entry), GFP_KERNEL); - if (!cb_entry) - return -ENOMEM; - - cb_entry->cb_info = kmalloc(sizeof(struct ping_apps_data_cb_info), - GFP_KERNEL); - if (!cb_entry->cb_info) { - kfree(cb_entry); - return -ENOMEM; - } - cb_info = (struct ping_apps_data_cb_info *)cb_entry->cb_info; - - INIT_LIST_HEAD(&cb_entry->list); - cb_entry->cb_func = handle_ping_apps_data_cb; - cb_entry->cb_id = arg->cb_id; - cb_entry->num = arg->num; - cb_entry->interval_ms = arg->interval_ms; - cb_entry->time_to_next_cb = arg->interval_ms; - cb_info->cb_func = ping_apps_data_cb; - cb_info->size = arg->size; - cb_info->num_tasks = arg->num_tasks; - - mutex_lock(&cb_entry_list_lock); - list_add_tail(&cb_entry->list, &cb_entry_list); - mutex_unlock(&cb_entry_list_lock); - - msm_rpc_server_get_requesting_client(&cb_entry->clnt_info); - - if (IS_ERR(server_thread)) - server_thread = kthread_run(ping_apps_cb_process_thread, - NULL, "kpingrpccbprocessd"); - if (IS_ERR(server_thread)) { - kfree(cb_entry); - return PTR_ERR(server_thread); - } - - ret->result = 1; - return 0; -} - -static int ping_apps_data_cb_unreg(struct ping_apps_data_cb_unreg_arg *arg, - struct ping_apps_data_cb_unreg_ret *ret) -{ - struct ping_apps_cb_entry *cb_entry, *tmp_cb_entry; - - mutex_lock(&cb_entry_list_lock); - list_for_each_entry_safe(cb_entry, tmp_cb_entry, - &cb_entry_list, list) { - if (cb_entry->cb_id == arg->cb_id) { - list_del(&cb_entry->list); - kfree(cb_entry->cb_info); - kfree(cb_entry); - break; - } - } - mutex_unlock(&cb_entry_list_lock); - - ret->result = 1; - return 0; -} - -static int ping_apps_register(struct ping_apps_register_arg *arg, - struct ping_apps_register_ret *ret) -{ - struct ping_apps_cb_entry *cb_entry; - - cb_entry = kmalloc(sizeof(*cb_entry), GFP_KERNEL); - if (!cb_entry) - return -ENOMEM; - - INIT_LIST_HEAD(&cb_entry->list); - cb_entry->cb_func = handle_ping_apps_register_cb; - cb_entry->cb_info = ping_apps_register_cb; - cb_entry->cb_id = arg->cb_id; - cb_entry->num = arg->num; - cb_entry->interval_ms = 100; - cb_entry->time_to_next_cb = 100; - - mutex_lock(&cb_entry_list_lock); - list_add_tail(&cb_entry->list, &cb_entry_list); - mutex_unlock(&cb_entry_list_lock); - - msm_rpc_server_get_requesting_client(&cb_entry->clnt_info); - - if (IS_ERR(server_thread)) - server_thread = kthread_run(ping_apps_cb_process_thread, - NULL, "kpingrpccbprocessd"); - if (IS_ERR(server_thread)) { - kfree(cb_entry); - return PTR_ERR(server_thread); - } - - ret->result = 1; - return 0; -} - -static int ping_apps_unregister(struct ping_apps_unregister_arg *arg, - struct ping_apps_unregister_ret *ret) -{ - struct ping_apps_cb_entry *cb_entry, *tmp_cb_entry; - - mutex_lock(&cb_entry_list_lock); - list_for_each_entry_safe(cb_entry, tmp_cb_entry, - &cb_entry_list, list) { - if (cb_entry->cb_id == arg->cb_id) { - list_del(&cb_entry->list); - kfree(cb_entry); - break; - } - } - mutex_unlock(&cb_entry_list_lock); - - ret->result = 1; - return 0; -} - -static int ping_apps_data_cb_arg_func(struct msm_rpc_server *server, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_apps_data_cb_arg *arg = data; - - xdr_send_uint32(xdr, &arg->cb_id); - xdr_send_array(xdr, (void **)&arg->data, &arg->size, 64, - sizeof(uint32_t), (void *)xdr_send_uint32); - xdr_send_uint32(xdr, &arg->size); - xdr_send_uint32(xdr, &arg->sum); - - return 0; -} - -static int ping_apps_data_cb_ret_func(struct msm_rpc_server *server, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_apps_data_cb_ret *ret = data; - - xdr_recv_uint32(xdr, &ret->result); - - return 0; -} - -static int ping_apps_data_cb(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - struct ping_apps_data_cb_arg *arg, - struct ping_apps_data_cb_ret *ret) -{ - return msm_rpc_server_cb_req2(server, clnt_info, - PING_APPS_DATA_CB, - ping_apps_data_cb_arg_func, arg, - ping_apps_data_cb_ret_func, ret, -1); -} - -static int ping_apps_register_cb_arg(struct msm_rpc_server *server, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_apps_register_cb_arg *arg = data; - - xdr_send_uint32(xdr, &arg->cb_id); - xdr_send_int32(xdr, &arg->num); - - return 0; -} - -static int ping_apps_register_cb(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - struct ping_apps_register_cb_arg *arg, - void *ret) -{ - return msm_rpc_server_cb_req2(server, clnt_info, - PING_APPS_REG_CB, - ping_apps_register_cb_arg, - arg, NULL, NULL, -1); -} - -static int handle_ping_apps_data_register(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - uint32_t rc; - struct ping_apps_data_arg arg; - struct ping_apps_data_ret ret; - - pr_info("%s: request received\n", __func__); - - xdr_recv_array(xdr, (void **)&arg.data, &arg.size, 64, - sizeof(uint32_t), (void *)xdr_recv_uint32); - xdr_recv_uint32(xdr, &arg.size); - - rc = ping_apps_data_register(&arg, &ret); - if (rc < 0) - goto free_and_return; - - xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_SUCCESS); - xdr_send_uint32(xdr, &ret.result); - rc = xdr_send_msg(xdr); - if (rc < 0) - pr_info("%s: sending reply failed\n", __func__); - else - rc = 1; - - free_and_return: - kfree(arg.data); - return rc; -} - -static int handle_ping_apps_data_cb_reg(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - uint32_t rc; - struct ping_apps_data_cb_reg_arg arg; - struct ping_apps_data_cb_reg_ret ret; - - pr_info("%s: request received\n", __func__); - - xdr_recv_uint32(xdr, &arg.cb_id); - xdr_recv_uint32(xdr, &arg.num); - xdr_recv_uint32(xdr, &arg.size); - xdr_recv_uint32(xdr, &arg.interval_ms); - xdr_recv_uint32(xdr, &arg.num_tasks); - - rc = ping_apps_data_cb_reg(&arg, &ret); - if (rc < 0) - return rc; - - xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_SUCCESS); - xdr_send_uint32(xdr, &ret.result); - rc = xdr_send_msg(xdr); - if (rc < 0) - pr_info("%s: sending reply failed\n", __func__); - else - rc = 1; - - return rc; -} - -static int handle_ping_apps_data_cb_unreg(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - uint32_t rc; - struct ping_apps_data_cb_unreg_arg arg; - struct ping_apps_data_cb_unreg_ret ret; - - pr_info("%s: request received\n", __func__); - - xdr_recv_uint32(xdr, &arg.cb_id); - - rc = ping_apps_data_cb_unreg(&arg, &ret); - if (rc < 0) - return rc; - - xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_SUCCESS); - xdr_send_uint32(xdr, &ret.result); - rc = xdr_send_msg(xdr); - if (rc < 0) - pr_info("%s: sending reply failed\n", __func__); - else - rc = 1; - - return rc; -} - -static int handle_ping_apps_register(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - uint32_t rc; - struct ping_apps_register_arg arg; - struct ping_apps_register_ret ret; - - pr_info("%s: request received\n", __func__); - - xdr_recv_uint32(xdr, &arg.cb_id); - xdr_recv_int32(xdr, &arg.num); - - rc = ping_apps_register(&arg, &ret); - if (rc < 0) - return rc; - - xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_SUCCESS); - xdr_send_uint32(xdr, &ret.result); - rc = xdr_send_msg(xdr); - if (rc < 0) - pr_info("%s: sending reply failed\n", __func__); - else - rc = 1; - - return rc; -} - -static int handle_ping_apps_unregister(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - uint32_t rc; - struct ping_apps_unregister_arg arg; - struct ping_apps_unregister_ret ret; - - pr_info("%s: request received\n", __func__); - - xdr_recv_uint32(xdr, &arg.cb_id); - - rc = ping_apps_unregister(&arg, &ret); - if (rc < 0) - return rc; - - xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_SUCCESS); - xdr_send_uint32(xdr, &ret.result); - rc = xdr_send_msg(xdr); - if (rc < 0) - pr_info("%s: sending reply failed\n", __func__); - else - rc = 1; - - return rc; -} - -static int handle_rpc_call(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - switch (req->procedure) { - case PING_APPS_NULL: - pr_info("%s: null procedure request received\n", __func__); - return 0; - case PING_APPS_DATA: - return handle_ping_apps_data_register(server, req, xdr); - case PING_APPS_REG: - return handle_ping_apps_register(server, req, xdr); - case PING_APPS_UNREG: - return handle_ping_apps_unregister(server, req, xdr); - case PING_APPS_DATA_CB_REG: - return handle_ping_apps_data_cb_reg(server, req, xdr); - case PING_APPS_DATA_CB_UNREG: - return handle_ping_apps_data_cb_unreg(server, req, xdr); - default: - return -ENODEV; - } -} - -static int __init ping_apps_server_init(void) -{ - INIT_LIST_HEAD(&cb_entry_list); - server_thread = ERR_PTR(-1); - return msm_rpc_create_server2(&rpc_server); -} - -module_init(ping_apps_server_init); - -MODULE_DESCRIPTION("PING APPS SERVER Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/ping_mdm_rpc_client.c b/arch/arm/mach-msm/ping_mdm_rpc_client.c deleted file mode 100644 index 4044836cb4a612b235bb8124a17c1b0c7f22e3a9..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/ping_mdm_rpc_client.c +++ /dev/null @@ -1,814 +0,0 @@ -/* Copyright (c) 2009-2011, 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. - * - */ - -/* - * SMD RPC PING MODEM Driver - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PING_TEST_BASE 0x31 - -#define PTIOC_NULL_TEST _IO(PING_TEST_BASE, 1) -#define PTIOC_REG_TEST _IO(PING_TEST_BASE, 2) -#define PTIOC_DATA_REG_TEST _IO(PING_TEST_BASE, 3) -#define PTIOC_DATA_CB_REG_TEST _IO(PING_TEST_BASE, 4) - -#define PING_MDM_PROG 0x30000081 -#define PING_MDM_VERS 0x00010001 -#define PING_MDM_CB_PROG 0x31000081 -#define PING_MDM_CB_VERS 0x00010001 - -#define PING_MDM_NULL_PROC 0 -#define PING_MDM_RPC_GLUE_CODE_INFO_REMOTE_PROC 1 -#define PING_MDM_REGISTER_PROC 2 -#define PING_MDM_UNREGISTER_PROC 3 -#define PING_MDM_REGISTER_DATA_PROC 4 -#define PING_MDM_UNREGISTER_DATA_CB_PROC 5 -#define PING_MDM_REGISTER_DATA_CB_PROC 6 - -#define PING_MDM_DATA_CB_PROC 1 -#define PING_MDM_CB_PROC 2 - -#define PING_MAX_RETRY 5 - -static struct msm_rpc_client *rpc_client; -static uint32_t open_count; -static DEFINE_MUTEX(ping_mdm_lock); - -struct ping_mdm_register_cb_arg { - uint32_t cb_id; - int val; -}; - -struct ping_mdm_register_data_cb_cb_arg { - uint32_t cb_id; - uint32_t *data; - uint32_t size; - uint32_t sum; -}; - -struct ping_mdm_register_data_cb_cb_ret { - uint32_t result; -}; - -static struct dentry *dent; -static uint32_t test_res; -static int reg_cb_num, reg_cb_num_req; -static int data_cb_num, data_cb_num_req; -static int reg_done_flag, data_cb_done_flag; -static DECLARE_WAIT_QUEUE_HEAD(reg_test_wait); -static DECLARE_WAIT_QUEUE_HEAD(data_cb_test_wait); - -enum { - PING_MODEM_NOT_IN_RESET = 0, - PING_MODEM_IN_RESET, - PING_LEAVING_RESET, - PING_MODEM_REGISTER_CB -}; -static int fifo_event; -static DEFINE_MUTEX(event_fifo_lock); -static DEFINE_KFIFO(event_fifo, int, sizeof(int)*16); - -static int ping_mdm_register_cb(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr) -{ - int rc; - uint32_t accept_status; - struct ping_mdm_register_cb_arg arg; - void *cb_func; - - xdr_recv_uint32(xdr, &arg.cb_id); /* cb_id */ - xdr_recv_int32(xdr, &arg.val); /* val */ - - cb_func = msm_rpc_get_cb_func(client, arg.cb_id); - if (cb_func) { - rc = ((int (*)(struct ping_mdm_register_cb_arg *, void *)) - cb_func)(&arg, NULL); - if (rc) - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - else - accept_status = RPC_ACCEPTSTAT_SUCCESS; - } else - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - - xdr_start_accepted_reply(xdr, accept_status); - rc = xdr_send_msg(xdr); - if (rc) - pr_err("%s: send accepted reply failed: %d\n", __func__, rc); - - return rc; -} - -static int ping_mdm_data_cb(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr) -{ - int rc; - void *cb_func; - uint32_t size, accept_status; - struct ping_mdm_register_data_cb_cb_arg arg; - struct ping_mdm_register_data_cb_cb_ret ret; - - xdr_recv_uint32(xdr, &arg.cb_id); /* cb_id */ - - /* data */ - xdr_recv_array(xdr, (void **)(&(arg.data)), &size, 64, - sizeof(uint32_t), (void *)xdr_recv_uint32); - - xdr_recv_uint32(xdr, &arg.size); /* size */ - xdr_recv_uint32(xdr, &arg.sum); /* sum */ - - cb_func = msm_rpc_get_cb_func(client, arg.cb_id); - if (cb_func) { - rc = ((int (*) - (struct ping_mdm_register_data_cb_cb_arg *, - struct ping_mdm_register_data_cb_cb_ret *)) - cb_func)(&arg, &ret); - if (rc) - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - else - accept_status = RPC_ACCEPTSTAT_SUCCESS; - } else - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - - xdr_start_accepted_reply(xdr, accept_status); - - if (accept_status == RPC_ACCEPTSTAT_SUCCESS) - xdr_send_uint32(xdr, &ret.result); /* result */ - - rc = xdr_send_msg(xdr); - if (rc) - pr_err("%s: send accepted reply failed: %d\n", __func__, rc); - - kfree(arg.data); - return rc; -} - -static int ping_mdm_cb_func(struct msm_rpc_client *client, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - int rc = 0; - - switch (req->procedure) { - case PING_MDM_CB_PROC: - rc = ping_mdm_register_cb(client, xdr); - break; - case PING_MDM_DATA_CB_PROC: - rc = ping_mdm_data_cb(client, xdr); - break; - default: - pr_err("%s: procedure not supported %d\n", - __func__, req->procedure); - xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_PROC_UNAVAIL); - rc = xdr_send_msg(xdr); - if (rc) - pr_err("%s: sending reply failed: %d\n", __func__, rc); - break; - } - return rc; -} - -struct ping_mdm_unregister_data_cb_arg { - int (*cb_func)( - struct ping_mdm_register_data_cb_cb_arg *arg, - struct ping_mdm_register_data_cb_cb_ret *ret); -}; - -struct ping_mdm_register_data_cb_arg { - int (*cb_func)( - struct ping_mdm_register_data_cb_cb_arg *arg, - struct ping_mdm_register_data_cb_cb_ret *ret); - uint32_t num; - uint32_t size; - uint32_t interval_ms; - uint32_t num_tasks; -}; - -struct ping_mdm_register_data_cb_ret { - uint32_t result; -}; - -struct ping_mdm_unregister_data_cb_ret { - uint32_t result; -}; - -static int ping_mdm_data_cb_register_arg(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_register_data_cb_arg *arg = data; - int cb_id; - - cb_id = msm_rpc_add_cb_func(client, (void *)arg->cb_func); - if ((cb_id < 0) && (cb_id != MSM_RPC_CLIENT_NULL_CB_ID)) - return cb_id; - - xdr_send_uint32(xdr, &cb_id); /* cb_id */ - xdr_send_uint32(xdr, &arg->num); /* num */ - xdr_send_uint32(xdr, &arg->size); /* size */ - xdr_send_uint32(xdr, &arg->interval_ms); /* interval_ms */ - xdr_send_uint32(xdr, &arg->num_tasks); /* num_tasks */ - - return 0; -} - -static int ping_mdm_data_cb_unregister_arg(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_unregister_data_cb_arg *arg = data; - int cb_id; - - cb_id = msm_rpc_add_cb_func(client, (void *)arg->cb_func); - if ((cb_id < 0) && (cb_id != MSM_RPC_CLIENT_NULL_CB_ID)) - return cb_id; - - xdr_send_uint32(xdr, &cb_id); /* cb_id */ - - return 0; -} - -static int ping_mdm_data_cb_register_ret(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_register_data_cb_ret *ret = data; - - xdr_recv_uint32(xdr, &ret->result); /* result */ - - return 0; -} - -static int ping_mdm_register_data_cb( - struct msm_rpc_client *client, - struct ping_mdm_register_data_cb_arg *arg, - struct ping_mdm_register_data_cb_ret *ret) -{ - return msm_rpc_client_req2(client, - PING_MDM_REGISTER_DATA_CB_PROC, - ping_mdm_data_cb_register_arg, arg, - ping_mdm_data_cb_register_ret, ret, -1); -} - -static int ping_mdm_unregister_data_cb( - struct msm_rpc_client *client, - struct ping_mdm_unregister_data_cb_arg *arg, - struct ping_mdm_unregister_data_cb_ret *ret) -{ - return msm_rpc_client_req2(client, - PING_MDM_UNREGISTER_DATA_CB_PROC, - ping_mdm_data_cb_unregister_arg, arg, - ping_mdm_data_cb_register_ret, ret, -1); -} - -struct ping_mdm_data_arg { - uint32_t *data; - uint32_t size; -}; - -struct ping_mdm_data_ret { - uint32_t result; -}; - -static int ping_mdm_data_register_arg(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_data_arg *arg = data; - - /* data */ - xdr_send_array(xdr, (void **)&arg->data, &arg->size, 64, - sizeof(uint32_t), (void *)xdr_send_uint32); - - xdr_send_uint32(xdr, &arg->size); /* size */ - - return 0; -} - -static int ping_mdm_data_register_ret(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_data_ret *ret = data; - - xdr_recv_uint32(xdr, &ret->result); /* result */ - - return 0; -} - -static int ping_mdm_data_register( - struct msm_rpc_client *client, - struct ping_mdm_data_arg *arg, - struct ping_mdm_data_ret *ret) -{ - return msm_rpc_client_req2(client, - PING_MDM_REGISTER_DATA_PROC, - ping_mdm_data_register_arg, arg, - ping_mdm_data_register_ret, ret, -1); -} - -struct ping_mdm_register_arg { - int (*cb_func)(struct ping_mdm_register_cb_arg *, void *); - int num; -}; - -struct ping_mdm_unregister_arg { - int (*cb_func)(struct ping_mdm_register_cb_arg *, void *); -}; - -struct ping_mdm_register_ret { - uint32_t result; -}; - -struct ping_mdm_unregister_ret { - uint32_t result; -}; - -static int ping_mdm_register_arg(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_register_arg *arg = data; - int cb_id; - - cb_id = msm_rpc_add_cb_func(client, (void *)arg->cb_func); - if ((cb_id < 0) && (cb_id != MSM_RPC_CLIENT_NULL_CB_ID)) - return cb_id; - - xdr_send_uint32(xdr, &cb_id); /* cb_id */ - xdr_send_uint32(xdr, &arg->num); /* num */ - - return 0; -} - -static int ping_mdm_unregister_arg(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_unregister_arg *arg = data; - int cb_id; - - cb_id = msm_rpc_add_cb_func(client, (void *)arg->cb_func); - if ((cb_id < 0) && (cb_id != MSM_RPC_CLIENT_NULL_CB_ID)) - return cb_id; - - xdr_send_uint32(xdr, &cb_id); /* cb_id */ - - return 0; -} - -static int ping_mdm_register_ret(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct ping_mdm_register_ret *ret = data; - - xdr_recv_uint32(xdr, &ret->result); /* result */ - - return 0; -} - -static int ping_mdm_register( - struct msm_rpc_client *client, - struct ping_mdm_register_arg *arg, - struct ping_mdm_register_ret *ret) -{ - return msm_rpc_client_req2(client, - PING_MDM_REGISTER_PROC, - ping_mdm_register_arg, arg, - ping_mdm_register_ret, ret, -1); -} - -static int ping_mdm_unregister( - struct msm_rpc_client *client, - struct ping_mdm_unregister_arg *arg, - struct ping_mdm_unregister_ret *ret) -{ - return msm_rpc_client_req2(client, - PING_MDM_UNREGISTER_PROC, - ping_mdm_unregister_arg, arg, - ping_mdm_register_ret, ret, -1); -} - -static int ping_mdm_null(struct msm_rpc_client *client, - void *arg, void *ret) -{ - return msm_rpc_client_req2(client, PING_MDM_NULL_PROC, - NULL, NULL, NULL, NULL, -1); -} - -static int ping_mdm_close(void) -{ - mutex_lock(&ping_mdm_lock); - if (--open_count == 0) { - msm_rpc_unregister_client(rpc_client); - pr_info("%s: disconnected from remote ping server\n", - __func__); - } - mutex_unlock(&ping_mdm_lock); - return 0; -} - -static void handle_restart_teardown(struct msm_rpc_client *client) -{ - int event = PING_MODEM_IN_RESET; - - pr_info("%s: modem in reset\n", __func__); - - mutex_lock(&event_fifo_lock); - kfifo_in(&event_fifo, &event, sizeof(event)); - fifo_event = 1; - mutex_unlock(&event_fifo_lock); - - wake_up(&data_cb_test_wait); -} - -static void handle_restart_setup(struct msm_rpc_client *client) -{ - int event = PING_LEAVING_RESET; - - pr_info("%s: modem leaving reset\n", __func__); - - mutex_lock(&event_fifo_lock); - kfifo_in(&event_fifo, &event, sizeof(event)); - fifo_event = 1; - mutex_unlock(&event_fifo_lock); - - wake_up(&data_cb_test_wait); -} - -static struct msm_rpc_client *ping_mdm_init(void) -{ - mutex_lock(&ping_mdm_lock); - if (open_count == 0) { - rpc_client = msm_rpc_register_client2("pingdef", - PING_MDM_PROG, - PING_MDM_VERS, 1, - ping_mdm_cb_func); - if (!IS_ERR(rpc_client)) { - open_count++; - msm_rpc_register_reset_callbacks(rpc_client, - handle_restart_teardown, - handle_restart_setup); - } - } - mutex_unlock(&ping_mdm_lock); - return rpc_client; -} - -static int ping_mdm_data_register_test(void) -{ - int i, rc = 0; - uint32_t my_data[64]; - uint32_t my_sum = 0; - struct ping_mdm_data_arg data_arg; - struct ping_mdm_data_ret data_ret; - - for (i = 0; i < 64; i++) { - my_data[i] = (42 + i); - my_sum ^= (42 + i); - } - - data_arg.data = my_data; - data_arg.size = 64; - - rc = ping_mdm_data_register(rpc_client, &data_arg, &data_ret); - if (rc) - return rc; - - if (my_sum != data_ret.result) { - pr_err("%s: sum mismatch %d %d\n", - __func__, my_sum, data_ret.result); - rc = -1; - } - - return rc; -} - -static int ping_mdm_test_register_data_cb( - struct ping_mdm_register_data_cb_cb_arg *arg, - struct ping_mdm_register_data_cb_cb_ret *ret) -{ - uint32_t i, sum = 0; - - data_cb_num++; - - pr_info("%s: received cb_id %d, size = %d, sum = %u, num = %u of %u\n", - __func__, arg->cb_id, arg->size, arg->sum, data_cb_num, - data_cb_num_req); - - if (arg->data) - for (i = 0; i < arg->size; i++) - sum ^= arg->data[i]; - - if (sum != arg->sum) - pr_err("%s: sum mismatch %u %u\n", __func__, sum, arg->sum); - - if (data_cb_num == data_cb_num_req) { - data_cb_done_flag = 1; - wake_up(&data_cb_test_wait); - } - - ret->result = 1; - return 0; -} - -static int ping_mdm_data_cb_register( - struct ping_mdm_register_data_cb_ret *reg_ret) -{ - int rc; - struct ping_mdm_register_data_cb_arg reg_arg; - - reg_arg.cb_func = ping_mdm_test_register_data_cb; - reg_arg.num = data_cb_num_req - data_cb_num; - reg_arg.size = 64; - reg_arg.interval_ms = 10; - reg_arg.num_tasks = 1; - - pr_info("%s: registering callback\n", __func__); - rc = ping_mdm_register_data_cb(rpc_client, ®_arg, reg_ret); - if (rc) - pr_err("%s: failed to register callback %d\n", __func__, rc); - - return rc; -} - - -static void retry_timer_cb(unsigned long data) -{ - int event = (int)data; - - pr_info("%s: retry timer triggered\n", __func__); - - mutex_lock(&event_fifo_lock); - kfifo_in(&event_fifo, &event, sizeof(event)); - fifo_event = 1; - mutex_unlock(&event_fifo_lock); - - wake_up(&data_cb_test_wait); -} - -static int ping_mdm_data_cb_register_test(void) -{ - int rc; - int event; - int retry_count = 0; - struct ping_mdm_register_data_cb_ret reg_ret; - struct ping_mdm_unregister_data_cb_arg unreg_arg; - struct ping_mdm_unregister_data_cb_ret unreg_ret; - struct timer_list retry_timer; - - mutex_init(&event_fifo_lock); - init_timer(&retry_timer); - - data_cb_done_flag = 0; - data_cb_num = 0; - if (!data_cb_num_req) - data_cb_num_req = 10; - - rc = ping_mdm_data_cb_register(®_ret); - if (rc) - return rc; - - pr_info("%s: data_cb_register result: 0x%x\n", - __func__, reg_ret.result); - - while (!data_cb_done_flag) { - wait_event(data_cb_test_wait, data_cb_done_flag || fifo_event); - fifo_event = 0; - - for (;;) { - mutex_lock(&event_fifo_lock); - - if (kfifo_is_empty(&event_fifo)) { - mutex_unlock(&event_fifo_lock); - break; - } - rc = kfifo_out(&event_fifo, &event, sizeof(event)); - mutex_unlock(&event_fifo_lock); - BUG_ON(rc != sizeof(event)); - - pr_info("%s: processing event data_cb_done_flag=%d,event=%d\n", - __func__, data_cb_done_flag, event); - - if (event == PING_MODEM_IN_RESET) { - pr_info("%s: modem entering reset\n", __func__); - retry_count = 0; - } else if (event == PING_LEAVING_RESET) { - pr_info("%s: modem exiting reset - " - "re-registering cb\n", __func__); - - rc = ping_mdm_data_cb_register(®_ret); - if (rc) { - retry_count++; - if (retry_count < PING_MAX_RETRY) { - pr_info("%s: retry %d failed\n", - __func__, retry_count); - - retry_timer.expires = jiffies + - msecs_to_jiffies(1000); - retry_timer.data = - PING_LEAVING_RESET; - retry_timer.function = - retry_timer_cb; - add_timer(&retry_timer); - } else { - pr_err("%s: max retries exceeded, aborting\n", - __func__); - return -ENETRESET; - } - } else - pr_info("%s: data_cb_register result: 0x%x\n", - __func__, reg_ret.result); - } - } - } - - while (del_timer(&retry_timer)) - ; - - unreg_arg.cb_func = ping_mdm_test_register_data_cb; - rc = ping_mdm_unregister_data_cb(rpc_client, &unreg_arg, &unreg_ret); - if (rc) - return rc; - - pr_info("%s: data_cb_unregister result: 0x%x\n", - __func__, unreg_ret.result); - - pr_info("%s: Test completed\n", __func__); - - return 0; -} - -static int ping_mdm_test_register_cb( - struct ping_mdm_register_cb_arg *arg, void *ret) -{ - pr_info("%s: received cb_id %d, val = %d\n", - __func__, arg->cb_id, arg->val); - - reg_cb_num++; - if (reg_cb_num == reg_cb_num_req) { - reg_done_flag = 1; - wake_up(®_test_wait); - } - return 0; -} - -static int ping_mdm_register_test(void) -{ - int rc = 0; - struct ping_mdm_register_arg reg_arg; - struct ping_mdm_unregister_arg unreg_arg; - struct ping_mdm_register_ret reg_ret; - struct ping_mdm_unregister_ret unreg_ret; - - reg_cb_num = 0; - reg_cb_num_req = 10; - reg_done_flag = 0; - - reg_arg.num = 10; - reg_arg.cb_func = ping_mdm_test_register_cb; - - rc = ping_mdm_register(rpc_client, ®_arg, ®_ret); - if (rc) - return rc; - - pr_info("%s: register result: 0x%x\n", - __func__, reg_ret.result); - - wait_event(reg_test_wait, reg_done_flag); - - unreg_arg.cb_func = ping_mdm_test_register_cb; - rc = ping_mdm_unregister(rpc_client, &unreg_arg, &unreg_ret); - if (rc) - return rc; - - pr_info("%s: unregister result: 0x%x\n", - __func__, unreg_ret.result); - - return 0; -} - -static int ping_mdm_null_test(void) -{ - return ping_mdm_null(rpc_client, NULL, NULL); -} - -static int ping_test_release(struct inode *ip, struct file *fp) -{ - return ping_mdm_close(); -} - -static int ping_test_open(struct inode *ip, struct file *fp) -{ - struct msm_rpc_client *client; - - client = ping_mdm_init(); - if (IS_ERR(client)) { - pr_err("%s: couldn't open ping client\n", __func__); - return PTR_ERR(client); - } else - pr_info("%s: connected to remote ping server\n", - __func__); - - return 0; -} - -static ssize_t ping_test_read(struct file *fp, char __user *buf, - size_t count, loff_t *pos) -{ - char _buf[16]; - - snprintf(_buf, sizeof(_buf), "%i\n", test_res); - - return simple_read_from_buffer(buf, count, pos, _buf, strlen(_buf)); -} - -static ssize_t ping_test_write(struct file *fp, const char __user *buf, - size_t count, loff_t *pos) -{ - unsigned char cmd[64]; - int len; - - if (count < 1) - return 0; - - len = count > 63 ? 63 : count; - - if (copy_from_user(cmd, buf, len)) - return -EFAULT; - - cmd[len] = 0; - - /* lazy */ - if (cmd[len-1] == '\n') { - cmd[len-1] = 0; - len--; - } - - if (!strncmp(cmd, "null_test", 64)) - test_res = ping_mdm_null_test(); - else if (!strncmp(cmd, "reg_test", 64)) - test_res = ping_mdm_register_test(); - else if (!strncmp(cmd, "data_reg_test", 64)) - test_res = ping_mdm_data_register_test(); - else if (!strncmp(cmd, "data_cb_reg_test", 64)) - test_res = ping_mdm_data_cb_register_test(); - else if (!strncmp(cmd, "count=", 6)) { - long tmp; - - if (strict_strtol(cmd + 6, 0, &tmp) == 0) { - data_cb_num_req = tmp; - pr_info("Set repetition count to %d\n", - data_cb_num_req); - } else { - data_cb_num_req = 10; - pr_err("invalid number %s, defaulting to %d\n", - cmd + 6, data_cb_num_req); - } - } - else - test_res = -EINVAL; - - return count; -} - -static const struct file_operations debug_ops = { - .owner = THIS_MODULE, - .open = ping_test_open, - .read = ping_test_read, - .write = ping_test_write, - .release = ping_test_release, -}; - -static void __exit ping_test_exit(void) -{ - debugfs_remove(dent); -} - -static int __init ping_test_init(void) -{ - dent = debugfs_create_file("ping_mdm", 0444, 0, NULL, &debug_ops); - test_res = 0; - open_count = 0; - return 0; -} - -module_init(ping_test_init); -module_exit(ping_test_exit); - -MODULE_DESCRIPTION("PING TEST Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/pmic.c b/arch/arm/mach-msm/pmic.c deleted file mode 100644 index dc0f7bf5bdfb1075230a14f7f680a49be9e36124..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pmic.c +++ /dev/null @@ -1,1286 +0,0 @@ -/* Copyright (c) 2009, 2011 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 -#include -#include -#include -#include -#include -#include - -#include - -#include "smd_rpcrouter.h" - -#define TRACE_PMIC 0 - -#if TRACE_PMIC -#define PMIC(x...) printk(KERN_INFO "[PMIC] " x) -#else -#define PMIC(x...) do {} while (0) -#endif - - -#define LIB_NULL_PROC 0 -#define LIB_RPC_GLUE_CODE_INFO_REMOTE_PROC 1 -#define LP_MODE_CONTROL_PROC 2 -#define VREG_SET_LEVEL_PROC 3 -#define VREG_PULL_DOWN_SWITCH_PROC 4 -#define SECURE_MPP_CONFIG_DIGITAL_OUTPUT_PROC 5 -#define SECURE_MPP_CONFIG_I_SINK_PROC 6 -#define RTC_START_PROC 7 -#define RTC_STOP_PROC 8 -#define RTC_GET_TIME_PROC 9 -#define RTC_ENABLE_ALARM_PROC 10 -#define RTC_DISABLE_ALARM_PROC 11 -#define RTC_GET_ALARM_TIME_PROC 12 -#define RTC_GET_ALARM_STATUS_PROC 13 -#define RTC_SET_TIME_ADJUST_PROC 14 -#define RTC_GET_TIME_ADJUST_PROC 15 -#define SET_LED_INTENSITY_PROC 16 -#define FLASH_LED_SET_CURRENT_PROC 17 -#define FLASH_LED_SET_MODE_PROC 18 -#define FLASH_LED_SET_POLARITY_PROC 19 -#define SPEAKER_CMD_PROC 20 -#define SET_SPEAKER_GAIN_PROC 21 -#define VIB_MOT_SET_VOLT_PROC 22 -#define VIB_MOT_SET_MODE_PROC 23 -#define VIB_MOT_SET_POLARITY_PROC 24 -#define VID_EN_PROC 25 -#define VID_IS_EN_PROC 26 -#define VID_LOAD_DETECT_EN_PROC 27 -#define MIC_EN_PROC 28 -#define MIC_IS_EN_PROC 29 -#define MIC_SET_VOLT_PROC 30 -#define MIC_GET_VOLT_PROC 31 -#define SPKR_EN_RIGHT_CHAN_PROC 32 -#define SPKR_IS_RIGHT_CHAN_EN_PROC 33 -#define SPKR_EN_LEFT_CHAN_PROC 34 -#define SPKR_IS_LEFT_CHAN_EN_PROC 35 -#define SET_SPKR_CONFIGURATION_PROC 36 -#define GET_SPKR_CONFIGURATION_PROC 37 -#define SPKR_GET_GAIN_PROC 38 -#define SPKR_IS_EN_PROC 39 -#define SPKR_EN_MUTE_PROC 40 -#define SPKR_IS_MUTE_EN_PROC 41 -#define SPKR_SET_DELAY_PROC 42 -#define SPKR_GET_DELAY_PROC 43 -#define SECURE_MPP_CONFIG_DIGITAL_INPUT_PROC 44 -#define SET_SPEAKER_DELAY_PROC 45 -#define SPEAKER_1K6_ZIN_ENABLE_PROC 46 -#define SPKR_SET_MUX_HPF_CORNER_FREQ_PROC 47 -#define SPKR_GET_MUX_HPF_CORNER_FREQ_PROC 48 -#define SPKR_IS_RIGHT_LEFT_CHAN_ADDED_PROC 49 -#define SPKR_EN_STEREO_PROC 50 -#define SPKR_IS_STEREO_EN_PROC 51 -#define SPKR_SELECT_USB_WITH_HPF_20HZ_PROC 52 -#define SPKR_IS_USB_WITH_HPF_20HZ_PROC 53 -#define SPKR_BYPASS_MUX_PROC 54 -#define SPKR_IS_MUX_BYPASSED_PROC 55 -#define SPKR_EN_HPF_PROC 56 -#define SPKR_IS_HPF_EN_PROC 57 -#define SPKR_EN_SINK_CURR_FROM_REF_VOLT_CIR_PROC 58 -#define SPKR_IS_SINK_CURR_FROM_REF_VOLT_CIR_EN_PROC 59 -#define SPKR_ADD_RIGHT_LEFT_CHAN_PROC 60 -#define SPKR_SET_GAIN_PROC 61 -#define SPKR_EN_PROC 62 -#define HSED_SET_PERIOD_PROC 63 -#define HSED_SET_HYSTERESIS_PROC 64 -#define HSED_SET_CURRENT_THRESHOLD_PROC 65 -#define HSED_ENABLE_PROC 66 -#define HIGH_CURRENT_LED_SET_CURRENT_PROC 67 -#define HIGH_CURRENT_LED_SET_POLARITY_PROC 68 -#define HIGH_CURRENT_LED_SET_MODE_PROC 69 -#define LP_FORCE_LPM_CONTROL_PROC 70 -#define LOW_CURRENT_LED_SET_EXT_SIGNAL_PROC 71 -#define LOW_CURRENT_LED_SET_CURRENT_PROC 72 -#define SPKR_SET_VSEL_LDO_PROC 86 -#define HP_SPKR_CTRL_AUX_GAIN_INPUT_PROC 87 -#define HP_SPKR_MSTR_EN_PROC 88 -#define SPKR_SET_BOOST_PROC 89 -#define HP_SPKR_PRM_IN_EN_PROC 90 -#define HP_SPKR_CTRL_PRM_GAIN_INPUT_PROC 91 -#define HP_SPKR_MUTE_EN_PROC 92 -#define SPKR_BYPASS_EN_PROC 93 -#define HP_SPKR_AUX_IN_EN_PROC 94 -#define XO_CORE_FORCE_ENABLE 96 -#define GPIO_SET_CURRENT_SOURCE_PULLS_PROC 97 -#define GPIO_SET_GPIO_DIRECTION_INPUT_PROC 98 -#define GPIO_SET_EXT_PIN_CONFIG_PROC 99 -#define GPIO_SET_GPIO_CONFIG_PROC 100 -#define GPIO_CONFIG_DIGITAL_OUTPUT_PROC 101 -#define GPIO_GET_GPIO_DIRECTION_PROC 102 -#define GPIO_SET_SLEEP_CLK_CONFIG_PROC 103 -#define GPIO_CONFIG_DIGITAL_INPUT_PROC 104 -#define GPIO_SET_OUTPUT_BUFFER_CONFIGURATION_PROC 105 -#define GPIO_SET_PROC 106 -#define GPIO_CONFIG_MODE_SELECTION_PROC 107 -#define GPIO_SET_INVERSION_CONFIGURATION_PROC 108 -#define GPIO_SET_GPIO_DIRECTION_OUTPUT_PROC 109 -#define GPIO_SET_SOURCE_CONFIGURATION_PROC 110 -#define GPIO_GET_PROC 111 -#define GPIO_SET_VOLTAGE_SOURCE_PROC 112 -#define GPIO_SET_OUTPUT_BUFFER_DRIVE_STRENGTH_PROC 113 - -/* rpc related */ -#define PMIC_RPC_TIMEOUT (5*HZ) - -#define PMIC_PDEV_NAME "rs00010001:00000000" -#define PMIC_RPC_PROG 0x30000061 -#define PMIC_RPC_VER_1_1 0x00010001 -#define PMIC_RPC_VER_2_1 0x00020001 -#define PMIC_RPC_VER_3_1 0x00030001 -#define PMIC_RPC_VER_5_1 0x00050001 -#define PMIC_RPC_VER_6_1 0x00060001 - -/* error bit flags defined by modem side */ -#define PM_ERR_FLAG__PAR1_OUT_OF_RANGE (0x0001) -#define PM_ERR_FLAG__PAR2_OUT_OF_RANGE (0x0002) -#define PM_ERR_FLAG__PAR3_OUT_OF_RANGE (0x0004) -#define PM_ERR_FLAG__PAR4_OUT_OF_RANGE (0x0008) -#define PM_ERR_FLAG__PAR5_OUT_OF_RANGE (0x0010) - -#define PM_ERR_FLAG__ALL_PARMS_OUT_OF_RANGE (0x001F) /* all 5 previous */ - -#define PM_ERR_FLAG__SBI_OPT_ERR (0x0080) -#define PM_ERR_FLAG__FEATURE_NOT_SUPPORTED (0x0100) - -#define PMIC_BUFF_SIZE 256 - -struct pmic_buf { - char *start; /* buffer start addr */ - char *end; /* buffer end addr */ - int size; /* buffer size */ - char *data; /* payload begin addr */ - int len; /* payload len */ -}; - -static DEFINE_MUTEX(pmic_mtx); - -struct pmic_ctrl { - int inited; - struct pmic_buf tbuf; - struct pmic_buf rbuf; - struct msm_rpc_endpoint *endpoint; -}; - -static struct pmic_ctrl pmic_ctrl = { - .inited = -1, -}; - -/* Add newer versions at the top of array */ -static const unsigned int rpc_vers[] = { - PMIC_RPC_VER_6_1, - PMIC_RPC_VER_5_1, - PMIC_RPC_VER_3_1, - PMIC_RPC_VER_2_1, - PMIC_RPC_VER_1_1, -}; - -static int pmic_rpc_req_reply(struct pmic_buf *tbuf, - struct pmic_buf *rbuf, int proc); -static int pmic_rpc_set_only(uint data0, uint data1, uint data2, - uint data3, int num, int proc); -static int pmic_rpc_set_struct(int, uint, uint *data, uint size, int proc); -static int pmic_rpc_set_get(uint setdata, uint *getdata, int size, int proc); -static int pmic_rpc_get_only(uint *getdata, int size, int proc); - -static int pmic_buf_init(void) -{ - struct pmic_ctrl *pm = &pmic_ctrl; - - memset(&pmic_ctrl, 0, sizeof(pmic_ctrl)); - - pm->tbuf.start = kmalloc(PMIC_BUFF_SIZE, GFP_KERNEL); - if (pm->tbuf.start == NULL) { - printk(KERN_ERR "%s:%u\n", __func__, __LINE__); - return -ENOMEM; - } - - pm->tbuf.data = pm->tbuf.start; - pm->tbuf.size = PMIC_BUFF_SIZE; - pm->tbuf.end = pm->tbuf.start + PMIC_BUFF_SIZE; - pm->tbuf.len = 0; - - pm->rbuf.start = kmalloc(PMIC_BUFF_SIZE, GFP_KERNEL); - if (pm->rbuf.start == NULL) { - kfree(pm->tbuf.start); - printk(KERN_ERR "%s:%u\n", __func__, __LINE__); - return -ENOMEM; - } - pm->rbuf.data = pm->rbuf.start; - pm->rbuf.size = PMIC_BUFF_SIZE; - pm->rbuf.end = pm->rbuf.start + PMIC_BUFF_SIZE; - pm->rbuf.len = 0; - - pm->inited = 1; - - return 0; -} - -static inline void pmic_buf_reserve(struct pmic_buf *bp, int len) -{ - bp->data += len; - bp->len += len; -} - -static inline void pmic_buf_reset(struct pmic_buf *bp) -{ - bp->data = bp->start; - bp->len = 0; -} - -static int modem_to_linux_err(uint err) -{ - if (err == 0) - return 0; - - if (err & PM_ERR_FLAG__ALL_PARMS_OUT_OF_RANGE) - return -EINVAL; /* PM_ERR_FLAG__PAR[1..5]_OUT_OF_RANGE */ - - if (err & PM_ERR_FLAG__SBI_OPT_ERR) - return -EIO; - - if (err & PM_ERR_FLAG__FEATURE_NOT_SUPPORTED) - return -ENOSYS; - - return -EPERM; -} - -static int pmic_put_tx_data(struct pmic_buf *tp, uint datav) -{ - uint *lp; - - if ((tp->size - tp->len) < sizeof(datav)) { - printk(KERN_ERR "%s: OVERFLOW size=%d len=%d\n", - __func__, tp->size, tp->len); - return -1; - } - - lp = (uint *)tp->data; - *lp = cpu_to_be32(datav); - tp->data += sizeof(datav); - tp->len += sizeof(datav); - - return sizeof(datav); -} - -static int pmic_pull_rx_data(struct pmic_buf *rp, uint *datap) -{ - uint *lp; - - if (rp->len < sizeof(*datap)) { - printk(KERN_ERR "%s: UNDERRUN len=%d\n", __func__, rp->len); - return -1; - } - lp = (uint *)rp->data; - *datap = be32_to_cpu(*lp); - rp->data += sizeof(*datap); - rp->len -= sizeof(*datap); - - return sizeof(*datap); -} - - -/* - * - * +-------------------+ - * | PROC cmd layer | - * +-------------------+ - * | RPC layer | - * +-------------------+ - * - * 1) network byte order - * 2) RPC request header(40 bytes) and RPC reply header (24 bytes) - * 3) each transaction consists of a request and reply - * 3) PROC (comamnd) layer has its own sub-protocol defined - * 4) sub-protocol can be grouped to follwoing 7 cases: - * a) set one argument, no get - * b) set two argument, no get - * c) set three argument, no get - * d) set a struct, no get - * e) set a argument followed by a struct, no get - * f) set a argument, get a argument - * g) no set, get either a argument or a struct - */ - -/** - * pmic_rpc_req_reply() - send request and wait for reply - * @tbuf: buffer contains arguments - * @rbuf: buffer to be filled with arguments at reply - * @proc: command/request id - * - * This function send request to modem and wait until reply received - */ -static int pmic_rpc_req_reply(struct pmic_buf *tbuf, struct pmic_buf *rbuf, - int proc) -{ - struct pmic_ctrl *pm = &pmic_ctrl; - int ans, len, i; - - - if ((pm->endpoint == NULL) || IS_ERR(pm->endpoint)) { - for (i = 0; i < ARRAY_SIZE(rpc_vers); i++) { - pm->endpoint = msm_rpc_connect_compatible(PMIC_RPC_PROG, - rpc_vers[i], MSM_RPC_UNINTERRUPTIBLE); - - if (IS_ERR(pm->endpoint)) { - ans = PTR_ERR(pm->endpoint); - printk(KERN_ERR "%s: init rpc failed! ans = %d" - " for 0x%x version, fallback\n", - __func__, ans, rpc_vers[i]); - } else { - printk(KERN_DEBUG "%s: successfully connected" - " to 0x%x rpc version\n", - __func__, rpc_vers[i]); - break; - } - } - } - - if (IS_ERR(pm->endpoint)) { - ans = PTR_ERR(pm->endpoint); - return ans; - } - - /* - * data is point to next available space at this moment, - * move it back to beginning of request header and increase - * the length - */ - tbuf->data = tbuf->start; - - len = msm_rpc_call_reply(pm->endpoint, proc, - tbuf->data, tbuf->len, - rbuf->data, rbuf->size, - PMIC_RPC_TIMEOUT); - - if (len <= 0) { - printk(KERN_ERR "%s: rpc failed! len = %d\n", __func__, len); - pm->endpoint = NULL; /* re-connect later ? */ - return len; - } - - rbuf->len = len; - /* strip off rpc_reply_hdr */ - rbuf->data += sizeof(struct rpc_reply_hdr); - rbuf->len -= sizeof(struct rpc_reply_hdr); - - return rbuf->len; -} - -/** - * pmic_rpc_set_only() - set arguments and no get - * @data0: first argumrnt - * @data1: second argument - * @data2: third argument - * @data3: fourth argument - * @num: number of argument - * @proc: command/request id - * - * This function covers case a, b, and c - */ -static int pmic_rpc_set_only(uint data0, uint data1, uint data2, uint data3, - int num, int proc) -{ - struct pmic_ctrl *pm = &pmic_ctrl; - struct pmic_buf *tp; - struct pmic_buf *rp; - int stat; - - - if (mutex_lock_interruptible(&pmic_mtx)) - return -ERESTARTSYS; - - if (pm->inited <= 0) { - stat = pmic_buf_init(); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - } - - tp = &pm->tbuf; - rp = &pm->rbuf; - - pmic_buf_reset(tp); - pmic_buf_reserve(tp, sizeof(struct rpc_request_hdr)); - pmic_buf_reset(rp); - - if (num > 0) - pmic_put_tx_data(tp, data0); - - if (num > 1) - pmic_put_tx_data(tp, data1); - - if (num > 2) - pmic_put_tx_data(tp, data2); - - if (num > 3) - pmic_put_tx_data(tp, data3); - - stat = pmic_rpc_req_reply(tp, rp, proc); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - - pmic_pull_rx_data(rp, &stat); /* result from server */ - - mutex_unlock(&pmic_mtx); - - return modem_to_linux_err(stat); -} - -/** - * pmic_rpc_set_struct() - set the whole struct - * @xflag: indicates an extra argument - * @xdata: the extra argument - * @*data: starting address of struct - * @size: size of struct - * @proc: command/request id - * - * This fucntion covers case d and e - */ -static int pmic_rpc_set_struct(int xflag, uint xdata, uint *data, uint size, - int proc) -{ - struct pmic_ctrl *pm = &pmic_ctrl; - struct pmic_buf *tp; - struct pmic_buf *rp; - int i, stat, more_data; - - - if (mutex_lock_interruptible(&pmic_mtx)) - return -ERESTARTSYS; - - if (pm->inited <= 0) { - stat = pmic_buf_init(); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - } - - tp = &pm->tbuf; - rp = &pm->rbuf; - - pmic_buf_reset(tp); - pmic_buf_reserve(tp, sizeof(struct rpc_request_hdr)); - pmic_buf_reset(rp); - - if (xflag) - pmic_put_tx_data(tp, xdata); - - more_data = 1; /* tell server there have more data followed */ - pmic_put_tx_data(tp, more_data); - - size >>= 2; - for (i = 0; i < size; i++) { - pmic_put_tx_data(tp, *data); - data++; - } - - stat = pmic_rpc_req_reply(tp, rp, proc); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - - pmic_pull_rx_data(rp, &stat); /* result from server */ - - mutex_unlock(&pmic_mtx); - - return modem_to_linux_err(stat); -} - -/** - * pmic_rpc_set_get() - set one argument and get one argument - * @setdata: set argument - * @*getdata: memory to store argumnet - * @size: size of memory - * @proc: command/request id - * - * This function covers case f - */ -static int pmic_rpc_set_get(uint setdata, uint *getdata, int size, int proc) -{ - struct pmic_ctrl *pm = &pmic_ctrl; - struct pmic_buf *tp; - struct pmic_buf *rp; - unsigned int *lp; - int i, stat, more_data; - - - if (mutex_lock_interruptible(&pmic_mtx)) - return -ERESTARTSYS; - - if (pm->inited <= 0) { - stat = pmic_buf_init(); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - } - - tp = &pm->tbuf; - rp = &pm->rbuf; - - pmic_buf_reset(tp); - pmic_buf_reserve(tp, sizeof(struct rpc_request_hdr)); - pmic_buf_reset(rp); - - pmic_put_tx_data(tp, setdata); - - /* - * more_data = TRUE to ask server reply with requested datum - * otherwise, server will reply without datum - */ - more_data = (getdata != NULL); - pmic_put_tx_data(tp, more_data); - - stat = pmic_rpc_req_reply(tp, rp, proc); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - - pmic_pull_rx_data(rp, &stat); /* result from server */ - pmic_pull_rx_data(rp, &more_data); - - if (more_data) { /* more data followed */ - size >>= 2; - lp = getdata; - for (i = 0; i < size; i++) { - if (pmic_pull_rx_data(rp, lp++) < 0) - break; /* not supposed to happen */ - } - } - - mutex_unlock(&pmic_mtx); - - return modem_to_linux_err(stat); -} - -/** - * pmic_rpc_get_only() - get one or more than one arguments - * @*getdata: memory to store arguments - * @size: size of mmory - * @proc: command/request id - * - * This function covers case g - */ -static int pmic_rpc_get_only(uint *getdata, int size, int proc) -{ - struct pmic_ctrl *pm = &pmic_ctrl; - struct pmic_buf *tp; - struct pmic_buf *rp; - unsigned int *lp; - int i, stat, more_data; - - - if (mutex_lock_interruptible(&pmic_mtx)) - return -ERESTARTSYS; - - if (pm->inited <= 0) { - stat = pmic_buf_init(); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - } - - tp = &pm->tbuf; - rp = &pm->rbuf; - - pmic_buf_reset(tp); - pmic_buf_reserve(tp, sizeof(struct rpc_request_hdr)); - pmic_buf_reset(rp); - - /* - * more_data = TRUE to ask server reply with requested datum - * otherwise, server will reply without datum - */ - more_data = (getdata != NULL); - pmic_put_tx_data(tp, more_data); - - stat = pmic_rpc_req_reply(tp, rp, proc); - if (stat < 0) { - mutex_unlock(&pmic_mtx); - return stat; - } - - pmic_pull_rx_data(rp, &stat); /* result from server */ - pmic_pull_rx_data(rp, &more_data); - - if (more_data) { /* more data followed */ - size >>= 2; - lp = getdata; - for (i = 0; i < size; i++) { - if (pmic_pull_rx_data(rp, lp++) < 0) - break; /* not supposed to happen */ - } - } - - mutex_unlock(&pmic_mtx); - - return modem_to_linux_err(stat); -} - - -int pmic_lp_mode_control(enum switch_cmd cmd, enum vreg_lp_id id) -{ - return pmic_rpc_set_only(cmd, id, 0, 0, 2, LP_MODE_CONTROL_PROC); -} -EXPORT_SYMBOL(pmic_lp_mode_control); - -int pmic_vreg_set_level(enum vreg_id vreg, int level) -{ - return pmic_rpc_set_only(vreg, level, 0, 0, 2, VREG_SET_LEVEL_PROC); -} -EXPORT_SYMBOL(pmic_vreg_set_level); - -int pmic_vreg_pull_down_switch(enum switch_cmd cmd, enum vreg_pdown_id id) -{ - return pmic_rpc_set_only(cmd, id, 0, 0, 2, VREG_PULL_DOWN_SWITCH_PROC); -} -EXPORT_SYMBOL(pmic_vreg_pull_down_switch); - -int pmic_secure_mpp_control_digital_output(enum mpp_which which, - enum mpp_dlogic_level level, - enum mpp_dlogic_out_ctrl out) -{ - return pmic_rpc_set_only(which, level, out, 0, 3, - SECURE_MPP_CONFIG_DIGITAL_OUTPUT_PROC); -} -EXPORT_SYMBOL(pmic_secure_mpp_control_digital_output); - -int pmic_secure_mpp_config_i_sink(enum mpp_which which, - enum mpp_i_sink_level level, - enum mpp_i_sink_switch onoff) -{ - return pmic_rpc_set_only(which, level, onoff, 0, 3, - SECURE_MPP_CONFIG_I_SINK_PROC); -} -EXPORT_SYMBOL(pmic_secure_mpp_config_i_sink); - -int pmic_secure_mpp_config_digital_input(enum mpp_which which, - enum mpp_dlogic_level level, - enum mpp_dlogic_in_dbus dbus) -{ - return pmic_rpc_set_only(which, level, dbus, 0, 3, - SECURE_MPP_CONFIG_DIGITAL_INPUT_PROC); -} -EXPORT_SYMBOL(pmic_secure_mpp_config_digital_input); - -int pmic_rtc_start(struct rtc_time *time) -{ - return pmic_rpc_set_struct(0, 0, (uint *)time, sizeof(*time), - RTC_START_PROC); -} -EXPORT_SYMBOL(pmic_rtc_start); - -int pmic_rtc_stop(void) -{ - return pmic_rpc_set_only(0, 0, 0, 0, 0, RTC_STOP_PROC); -} -EXPORT_SYMBOL(pmic_rtc_stop); - -int pmic_rtc_get_time(struct rtc_time *time) -{ - return pmic_rpc_get_only((uint *)time, sizeof(*time), - RTC_GET_TIME_PROC); -} -EXPORT_SYMBOL(pmic_rtc_get_time); - -int pmic_rtc_enable_alarm(enum rtc_alarm alarm, - struct rtc_time *time) -{ - return pmic_rpc_set_struct(1, alarm, (uint *)time, sizeof(*time), - RTC_ENABLE_ALARM_PROC); -} -EXPORT_SYMBOL(pmic_rtc_enable_alarm); - -int pmic_rtc_disable_alarm(enum rtc_alarm alarm) -{ - return pmic_rpc_set_only(alarm, 0, 0, 0, 1, RTC_DISABLE_ALARM_PROC); -} -EXPORT_SYMBOL(pmic_rtc_disable_alarm); - -int pmic_rtc_get_alarm_time(enum rtc_alarm alarm, - struct rtc_time *time) -{ - return pmic_rpc_set_get(alarm, (uint *)time, sizeof(*time), - RTC_GET_ALARM_TIME_PROC); -} -EXPORT_SYMBOL(pmic_rtc_get_alarm_time); - -int pmic_rtc_get_alarm_status(uint *status) -{ - return pmic_rpc_get_only(status, sizeof(*status), - RTC_GET_ALARM_STATUS_PROC); -} -EXPORT_SYMBOL(pmic_rtc_get_alarm_status); - -int pmic_rtc_set_time_adjust(uint adjust) -{ - return pmic_rpc_set_only(adjust, 0, 0, 0, 1, - RTC_SET_TIME_ADJUST_PROC); -} -EXPORT_SYMBOL(pmic_rtc_set_time_adjust); - -int pmic_rtc_get_time_adjust(uint *adjust) -{ - return pmic_rpc_get_only(adjust, sizeof(*adjust), - RTC_GET_TIME_ADJUST_PROC); -} -EXPORT_SYMBOL(pmic_rtc_get_time_adjust); - -/* - * generic speaker - */ -int pmic_speaker_cmd(const enum spkr_cmd cmd) -{ - return pmic_rpc_set_only(cmd, 0, 0, 0, 1, SPEAKER_CMD_PROC); -} -EXPORT_SYMBOL(pmic_speaker_cmd); - -int pmic_set_spkr_configuration(struct spkr_config_mode *cfg) -{ - return pmic_rpc_set_struct(0, 0, (uint *)cfg, sizeof(*cfg), - SET_SPKR_CONFIGURATION_PROC); -} -EXPORT_SYMBOL(pmic_set_spkr_configuration); - -int pmic_get_spkr_configuration(struct spkr_config_mode *cfg) -{ - return pmic_rpc_get_only((uint *)cfg, sizeof(*cfg), - GET_SPKR_CONFIGURATION_PROC); -} -EXPORT_SYMBOL(pmic_get_spkr_configuration); - -int pmic_spkr_en_right_chan(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, SPKR_EN_RIGHT_CHAN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_en_right_chan); - -int pmic_spkr_is_right_chan_en(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_RIGHT_CHAN_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_right_chan_en); - -int pmic_spkr_en_left_chan(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, SPKR_EN_LEFT_CHAN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_en_left_chan); - -int pmic_spkr_is_left_chan_en(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_LEFT_CHAN_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_left_chan_en); - -int pmic_set_speaker_gain(enum spkr_gain gain) -{ - return pmic_rpc_set_only(gain, 0, 0, 0, 1, SET_SPEAKER_GAIN_PROC); -} -EXPORT_SYMBOL(pmic_set_speaker_gain); - -int pmic_set_speaker_delay(enum spkr_dly delay) -{ - return pmic_rpc_set_only(delay, 0, 0, 0, 1, SET_SPEAKER_DELAY_PROC); -} -EXPORT_SYMBOL(pmic_set_speaker_delay); - -int pmic_speaker_1k6_zin_enable(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, - SPEAKER_1K6_ZIN_ENABLE_PROC); -} -EXPORT_SYMBOL(pmic_speaker_1k6_zin_enable); - -int pmic_spkr_set_mux_hpf_corner_freq(enum spkr_hpf_corner_freq freq) -{ - return pmic_rpc_set_only(freq, 0, 0, 0, 1, - SPKR_SET_MUX_HPF_CORNER_FREQ_PROC); -} -EXPORT_SYMBOL(pmic_spkr_set_mux_hpf_corner_freq); - -int pmic_spkr_get_mux_hpf_corner_freq(enum spkr_hpf_corner_freq *freq) -{ - return pmic_rpc_get_only(freq, sizeof(*freq), - SPKR_GET_MUX_HPF_CORNER_FREQ_PROC); -} -EXPORT_SYMBOL(pmic_spkr_get_mux_hpf_corner_freq); - -int pmic_spkr_select_usb_with_hpf_20hz(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, - SPKR_SELECT_USB_WITH_HPF_20HZ_PROC); -} -EXPORT_SYMBOL(pmic_spkr_select_usb_with_hpf_20hz); - -int pmic_spkr_is_usb_with_hpf_20hz(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_USB_WITH_HPF_20HZ_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_usb_with_hpf_20hz); - -int pmic_spkr_bypass_mux(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, SPKR_BYPASS_MUX_PROC); -} -EXPORT_SYMBOL(pmic_spkr_bypass_mux); - -int pmic_spkr_is_mux_bypassed(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_MUX_BYPASSED_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_mux_bypassed); - -int pmic_spkr_en_hpf(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, SPKR_EN_HPF_PROC); -} -EXPORT_SYMBOL(pmic_spkr_en_hpf); - -int pmic_spkr_is_hpf_en(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_HPF_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_hpf_en); - -int pmic_spkr_en_sink_curr_from_ref_volt_cir(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, - SPKR_EN_SINK_CURR_FROM_REF_VOLT_CIR_PROC); -} -EXPORT_SYMBOL(pmic_spkr_en_sink_curr_from_ref_volt_cir); - -int pmic_spkr_is_sink_curr_from_ref_volt_cir_en(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_SINK_CURR_FROM_REF_VOLT_CIR_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_sink_curr_from_ref_volt_cir_en); - -/* - * speaker indexed by left_right - */ -int pmic_spkr_en(enum spkr_left_right left_right, uint enable) -{ - return pmic_rpc_set_only(left_right, enable, 0, 0, 2, SPKR_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_en); - -int pmic_spkr_is_en(enum spkr_left_right left_right, uint *enabled) -{ - return pmic_rpc_set_get(left_right, enabled, sizeof(*enabled), - SPKR_IS_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_en); - -int pmic_spkr_set_gain(enum spkr_left_right left_right, enum spkr_gain gain) -{ - return pmic_rpc_set_only(left_right, gain, 0, 0, 2, SPKR_SET_GAIN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_set_gain); - -int pmic_spkr_get_gain(enum spkr_left_right left_right, enum spkr_gain *gain) -{ - return pmic_rpc_set_get(left_right, gain, sizeof(*gain), - SPKR_GET_GAIN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_get_gain); - -int pmic_spkr_set_delay(enum spkr_left_right left_right, enum spkr_dly delay) -{ - return pmic_rpc_set_only(left_right, delay, 0, 0, 2, - SPKR_SET_DELAY_PROC); -} -EXPORT_SYMBOL(pmic_spkr_set_delay); - -int pmic_spkr_get_delay(enum spkr_left_right left_right, enum spkr_dly *delay) -{ - return pmic_rpc_set_get(left_right, delay, sizeof(*delay), - SPKR_GET_DELAY_PROC); -} -EXPORT_SYMBOL(pmic_spkr_get_delay); - -int pmic_spkr_en_mute(enum spkr_left_right left_right, uint enabled) -{ - return pmic_rpc_set_only(left_right, enabled, 0, 0, 2, - SPKR_EN_MUTE_PROC); -} -EXPORT_SYMBOL(pmic_spkr_en_mute); - -int pmic_spkr_is_mute_en(enum spkr_left_right left_right, uint *enabled) -{ - return pmic_rpc_set_get(left_right, enabled, sizeof(*enabled), - SPKR_IS_MUTE_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_mute_en); - -int pmic_spkr_set_vsel_ldo(enum spkr_left_right left_right, - enum spkr_ldo_v_sel vlt_cntrl) -{ - return pmic_rpc_set_only(left_right, vlt_cntrl, 0, 0, 2, - SPKR_SET_VSEL_LDO_PROC); -} -EXPORT_SYMBOL(pmic_spkr_set_vsel_ldo); - -int pmic_spkr_set_boost(enum spkr_left_right left_right, uint enable) -{ - return pmic_rpc_set_only(left_right, enable, 0, 0, 2, - SPKR_SET_BOOST_PROC); -} -EXPORT_SYMBOL(pmic_spkr_set_boost); - -int pmic_spkr_bypass_en(enum spkr_left_right left_right, uint enable) -{ - return pmic_rpc_set_only(left_right, enable, 0, 0, 2, - SPKR_BYPASS_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_bypass_en); - -/* - * mic - */ -int pmic_mic_en(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, MIC_EN_PROC); -} -EXPORT_SYMBOL(pmic_mic_en); - -int pmic_mic_is_en(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), MIC_IS_EN_PROC); -} -EXPORT_SYMBOL(pmic_mic_is_en); - -int pmic_mic_set_volt(enum mic_volt vol) -{ - return pmic_rpc_set_only(vol, 0, 0, 0, 1, MIC_SET_VOLT_PROC); -} -EXPORT_SYMBOL(pmic_mic_set_volt); - -int pmic_mic_get_volt(enum mic_volt *voltage) -{ - return pmic_rpc_get_only(voltage, sizeof(*voltage), MIC_GET_VOLT_PROC); -} -EXPORT_SYMBOL(pmic_mic_get_volt); - -int pmic_vib_mot_set_volt(uint vol) -{ - return pmic_rpc_set_only(vol, 0, 0, 0, 1, VIB_MOT_SET_VOLT_PROC); -} -EXPORT_SYMBOL(pmic_vib_mot_set_volt); - -int pmic_vib_mot_set_mode(enum pm_vib_mot_mode mode) -{ - return pmic_rpc_set_only(mode, 0, 0, 0, 1, VIB_MOT_SET_MODE_PROC); -} -EXPORT_SYMBOL(pmic_vib_mot_set_mode); - -int pmic_vib_mot_set_polarity(enum pm_vib_mot_pol pol) -{ - return pmic_rpc_set_only(pol, 0, 0, 0, 1, VIB_MOT_SET_POLARITY_PROC); -} -EXPORT_SYMBOL(pmic_vib_mot_set_polarity); - -int pmic_vid_en(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, VID_EN_PROC); -} -EXPORT_SYMBOL(pmic_vid_en); - -int pmic_vid_is_en(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), VID_IS_EN_PROC); -} -EXPORT_SYMBOL(pmic_vid_is_en); - -int pmic_vid_load_detect_en(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, VID_LOAD_DETECT_EN_PROC); -} -EXPORT_SYMBOL(pmic_vid_load_detect_en); - -int pmic_set_led_intensity(enum ledtype type, int level) -{ - return pmic_rpc_set_only(type, level, 0, 0, 2, SET_LED_INTENSITY_PROC); -} -EXPORT_SYMBOL(pmic_set_led_intensity); - -int pmic_flash_led_set_current(const uint16_t milliamps) -{ - return pmic_rpc_set_only(milliamps, 0, 0, 0, 1, - FLASH_LED_SET_CURRENT_PROC); -} -EXPORT_SYMBOL(pmic_flash_led_set_current); - -int pmic_flash_led_set_mode(enum flash_led_mode mode) -{ - return pmic_rpc_set_only((int)mode, 0, 0, 0, 1, - FLASH_LED_SET_MODE_PROC); -} -EXPORT_SYMBOL(pmic_flash_led_set_mode); - -int pmic_flash_led_set_polarity(enum flash_led_pol pol) -{ - return pmic_rpc_set_only((int)pol, 0, 0, 0, 1, - FLASH_LED_SET_POLARITY_PROC); -} -EXPORT_SYMBOL(pmic_flash_led_set_polarity); - -int pmic_spkr_add_right_left_chan(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, - SPKR_ADD_RIGHT_LEFT_CHAN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_add_right_left_chan); - -int pmic_spkr_is_right_left_chan_added(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_RIGHT_LEFT_CHAN_ADDED_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_right_left_chan_added); - -int pmic_spkr_en_stereo(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, SPKR_EN_STEREO_PROC); -} -EXPORT_SYMBOL(pmic_spkr_en_stereo); - -int pmic_spkr_is_stereo_en(uint *enabled) -{ - return pmic_rpc_get_only(enabled, sizeof(*enabled), - SPKR_IS_STEREO_EN_PROC); -} -EXPORT_SYMBOL(pmic_spkr_is_stereo_en); - -int pmic_hsed_set_period( - enum hsed_controller controller, - enum hsed_period_pre_div period_pre_div, - enum hsed_period_time period_time -) -{ - return pmic_rpc_set_only(controller, period_pre_div, period_time, 0, - 3, - HSED_SET_PERIOD_PROC); -} -EXPORT_SYMBOL(pmic_hsed_set_period); - -int pmic_hsed_set_hysteresis( - enum hsed_controller controller, - enum hsed_hyst_pre_div hyst_pre_div, - enum hsed_hyst_time hyst_time -) -{ - return pmic_rpc_set_only(controller, hyst_pre_div, hyst_time, 0, - 3, - HSED_SET_HYSTERESIS_PROC); -} -EXPORT_SYMBOL(pmic_hsed_set_hysteresis); - -int pmic_hsed_set_current_threshold( - enum hsed_controller controller, - enum hsed_switch switch_hsed, - uint32_t current_threshold -) -{ - return pmic_rpc_set_only(controller, switch_hsed, current_threshold, 0, - 3, - HSED_SET_CURRENT_THRESHOLD_PROC); -} -EXPORT_SYMBOL(pmic_hsed_set_current_threshold); - -int pmic_hsed_enable( - enum hsed_controller controller, - enum hsed_enable enable_hsed -) -{ - return pmic_rpc_set_only(controller, enable_hsed, 0, 0, - 2, - HSED_ENABLE_PROC); -} -EXPORT_SYMBOL(pmic_hsed_enable); - -int pmic_high_current_led_set_current(enum high_current_led led, - uint16_t milliamps) -{ - return pmic_rpc_set_only(led, milliamps, 0, 0, - 2, - HIGH_CURRENT_LED_SET_CURRENT_PROC); -} -EXPORT_SYMBOL(pmic_high_current_led_set_current); - -int pmic_high_current_led_set_polarity(enum high_current_led led, - enum flash_led_pol polarity) -{ - return pmic_rpc_set_only(led, polarity, 0, 0, - 2, - HIGH_CURRENT_LED_SET_POLARITY_PROC); -} -EXPORT_SYMBOL(pmic_high_current_led_set_polarity); - -int pmic_high_current_led_set_mode(enum high_current_led led, - enum flash_led_mode mode) -{ - return pmic_rpc_set_only(led, mode, 0, 0, - 2, - HIGH_CURRENT_LED_SET_MODE_PROC); -} -EXPORT_SYMBOL(pmic_high_current_led_set_mode); - -int pmic_lp_force_lpm_control(enum switch_cmd cmd, - enum vreg_lpm_id vreg) -{ - return pmic_rpc_set_only(cmd, vreg, 0, 0, - 2, - LP_FORCE_LPM_CONTROL_PROC); -} -EXPORT_SYMBOL(pmic_lp_force_lpm_control); - -int pmic_low_current_led_set_ext_signal(enum low_current_led led, - enum ext_signal sig) -{ - return pmic_rpc_set_only(led, sig, 0, 0, - 2, - LOW_CURRENT_LED_SET_EXT_SIGNAL_PROC); -} -EXPORT_SYMBOL(pmic_low_current_led_set_ext_signal); - -int pmic_low_current_led_set_current(enum low_current_led led, - uint16_t milliamps) -{ - return pmic_rpc_set_only(led, milliamps, 0, 0, - 2, - LOW_CURRENT_LED_SET_CURRENT_PROC); -} -EXPORT_SYMBOL(pmic_low_current_led_set_current); - -/* - * Head phone speaker - */ -int pmic_hp_spkr_mstr_en(enum hp_spkr_left_right left_right, uint enable) -{ - return pmic_rpc_set_only(left_right, enable, 0, 0, 2, - HP_SPKR_MSTR_EN_PROC); -} -EXPORT_SYMBOL(pmic_hp_spkr_mstr_en); - -int pmic_hp_spkr_mute_en(enum hp_spkr_left_right left_right, uint enable) -{ - return pmic_rpc_set_only(left_right, enable, 0, 0, 2, - HP_SPKR_MUTE_EN_PROC); -} -EXPORT_SYMBOL(pmic_hp_spkr_mute_en); - -int pmic_hp_spkr_prm_in_en(enum hp_spkr_left_right left_right, uint enable) -{ - return pmic_rpc_set_only(left_right, enable, 0, 0, 2, - HP_SPKR_PRM_IN_EN_PROC); -} -EXPORT_SYMBOL(pmic_hp_spkr_prm_in_en); - -int pmic_hp_spkr_aux_in_en(enum hp_spkr_left_right left_right, uint enable) -{ - return pmic_rpc_set_only(left_right, enable, 0, 0, 2, - HP_SPKR_AUX_IN_EN_PROC); -} -EXPORT_SYMBOL(pmic_hp_spkr_aux_in_en); - -int pmic_hp_spkr_ctrl_prm_gain_input(enum hp_spkr_left_right left_right, - uint prm_gain_ctl) -{ - return pmic_rpc_set_only(left_right, prm_gain_ctl, 0, 0, 2, - HP_SPKR_CTRL_PRM_GAIN_INPUT_PROC); -} -EXPORT_SYMBOL(pmic_hp_spkr_ctrl_prm_gain_input); - -int pmic_hp_spkr_ctrl_aux_gain_input(enum hp_spkr_left_right left_right, - uint aux_gain_ctl) -{ - return pmic_rpc_set_only(left_right, aux_gain_ctl, 0, 0, 2, - HP_SPKR_CTRL_AUX_GAIN_INPUT_PROC); -} -EXPORT_SYMBOL(pmic_hp_spkr_ctrl_aux_gain_input); - -int pmic_xo_core_force_enable(uint enable) -{ - return pmic_rpc_set_only(enable, 0, 0, 0, 1, XO_CORE_FORCE_ENABLE); -} -EXPORT_SYMBOL(pmic_xo_core_force_enable); - -int pmic_gpio_direction_input(unsigned gpio) -{ - return pmic_rpc_set_only(gpio, 0, 0, 0, 1, - GPIO_SET_GPIO_DIRECTION_INPUT_PROC); -} -EXPORT_SYMBOL(pmic_gpio_direction_input); - -int pmic_gpio_direction_output(unsigned gpio) -{ - return pmic_rpc_set_only(gpio, 0, 0, 0, 1, - GPIO_SET_GPIO_DIRECTION_OUTPUT_PROC); -} -EXPORT_SYMBOL(pmic_gpio_direction_output); - -int pmic_gpio_set_value(unsigned gpio, int value) -{ - return pmic_rpc_set_only(gpio, value, 0, 0, 2, GPIO_SET_PROC); -} -EXPORT_SYMBOL(pmic_gpio_set_value); - -int pmic_gpio_get_value(unsigned gpio) -{ - uint value; - int ret; - - ret = pmic_rpc_set_get(gpio, &value, sizeof(value), GPIO_GET_PROC); - if (ret < 0) - return ret; - return value ? 1 : 0; -} -EXPORT_SYMBOL(pmic_gpio_get_value); - -int pmic_gpio_get_direction(unsigned gpio) -{ - enum pmic_direction_mode dir; - int ret; - - ret = pmic_rpc_set_get(gpio, &dir, sizeof(dir), - GPIO_GET_GPIO_DIRECTION_PROC); - if (ret < 0) - return ret; - return dir; -} -EXPORT_SYMBOL(pmic_gpio_get_direction); - -int pmic_gpio_config(struct pm8xxx_gpio_rpc_cfg *param) -{ - return pmic_rpc_set_struct(0, 0, (uint *)param, sizeof(*param), - GPIO_SET_GPIO_CONFIG_PROC); -} -EXPORT_SYMBOL(pmic_gpio_config); diff --git a/arch/arm/mach-msm/pmic.h b/arch/arm/mach-msm/pmic.h deleted file mode 100644 index b73e6542b1814f297cfa01e8978d812e0093b8a8..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/pmic.h +++ /dev/null @@ -1,295 +0,0 @@ -/* Copyright (c) 2009, 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 __ARCH_ARM_MACH_PMIC_H -#define __ARCH_ARM_MACH_PMIC_H - -#include - -enum spkr_left_right { - LEFT_SPKR, - RIGHT_SPKR, -}; - -enum spkr_gain { - SPKR_GAIN_MINUS16DB, /* -16 db */ - SPKR_GAIN_MINUS12DB, /* -12 db */ - SPKR_GAIN_MINUS08DB, /* -08 db */ - SPKR_GAIN_MINUS04DB, /* -04 db */ - SPKR_GAIN_00DB, /* 00 db */ - SPKR_GAIN_PLUS04DB, /* +04 db */ - SPKR_GAIN_PLUS08DB, /* +08 db */ - SPKR_GAIN_PLUS12DB, /* +12 db */ -}; - -enum spkr_dly { - SPKR_DLY_10MS, /* ~10 ms delay */ - SPKR_DLY_100MS, /* ~100 ms delay */ -}; - -enum spkr_hpf_corner_freq { - SPKR_FREQ_1_39KHZ, /* 1.39 kHz */ - SPKR_FREQ_0_64KHZ, /* 0.64 kHz */ - SPKR_FREQ_0_86KHZ, /* 0.86 kHz */ - SPKR_FREQ_0_51KHZ, /* 0.51 kHz */ - SPKR_FREQ_1_06KHZ, /* 1.06 kHz */ - SPKR_FREQ_0_57KHZ, /* 0.57 kHz */ - SPKR_FREQ_0_73KHZ, /* 0.73 kHz */ - SPKR_FREQ_0_47KHZ, /* 0.47 kHz */ - SPKR_FREQ_1_20KHZ, /* 1.20 kHz */ - SPKR_FREQ_0_60KHZ, /* 0.60 kHz */ - SPKR_FREQ_0_76KHZ, /* 0.76 kHz */ - SPKR_FREQ_0_49KHZ, /* 0.49 kHz */ - SPKR_FREQ_0_95KHZ, /* 0.95 kHz */ - SPKR_FREQ_0_54KHZ, /* 0.54 kHz */ - SPKR_FREQ_0_68KHZ, /* 0.68 kHz */ - SPKR_FREQ_0_45KHZ, /* 0.45 kHz */ -}; - -/* Turn the speaker on or off and enables or disables mute.*/ -enum spkr_cmd { - SPKR_DISABLE, /* Enable Speaker */ - SPKR_ENABLE, /* Disable Speaker */ - SPKR_MUTE_OFF, /* turn speaker mute off, SOUND ON */ - SPKR_MUTE_ON, /* turn speaker mute on, SOUND OFF */ - SPKR_OFF, /* turn speaker OFF (speaker disable and mute on) */ - SPKR_ON, /* turn speaker ON (speaker enable and mute off) */ - SPKR_SET_FREQ_CMD, /* set speaker frequency */ - SPKR_GET_FREQ_CMD, /* get speaker frequency */ - SPKR_SET_GAIN_CMD, /* set speaker gain */ - SPKR_GET_GAIN_CMD, /* get speaker gain */ - SPKR_SET_DELAY_CMD, /* set speaker delay */ - SPKR_GET_DELAY_CMD, /* get speaker delay */ - SPKR_SET_PDM_MODE, - SPKR_SET_PWM_MODE, -}; - -struct spkr_config_mode { - uint32_t is_right_chan_en; - uint32_t is_left_chan_en; - uint32_t is_right_left_chan_added; - uint32_t is_stereo_en; - uint32_t is_usb_with_hpf_20hz; - uint32_t is_mux_bypassed; - uint32_t is_hpf_en; - uint32_t is_sink_curr_from_ref_volt_cir_en; -}; - -enum mic_volt { - MIC_VOLT_2_00V, /* 2.00 V */ - MIC_VOLT_1_93V, /* 1.93 V */ - MIC_VOLT_1_80V, /* 1.80 V */ - MIC_VOLT_1_73V, /* 1.73 V */ -}; - -enum ledtype { - LED_LCD, - LED_KEYPAD, -}; - -enum flash_led_mode { - FLASH_LED_MODE__MANUAL, - FLASH_LED_MODE__DBUS1, - FLASH_LED_MODE__DBUS2, - FLASH_LED_MODE__DBUS3, -}; - -enum flash_led_pol { - FLASH_LED_POL__ACTIVE_HIGH, - FLASH_LED_POL__ACTIVE_LOW, -}; - -enum switch_cmd { - OFF_CMD, - ON_CMD -}; - -enum vreg_lp_id { - PM_VREG_LP_MSMA_ID, - PM_VREG_LP_MSMP_ID, - PM_VREG_LP_MSME1_ID, - PM_VREG_LP_GP3_ID, - PM_VREG_LP_MSMC_ID, - PM_VREG_LP_MSME2_ID, - PM_VREG_LP_GP4_ID, - PM_VREG_LP_GP1_ID, - PM_VREG_LP_RFTX_ID, - PM_VREG_LP_RFRX1_ID, - PM_VREG_LP_RFRX2_ID, - PM_VREG_LP_WLAN_ID, - PM_VREG_LP_MMC_ID, - PM_VREG_LP_RUIM_ID, - PM_VREG_LP_MSMC0_ID, - PM_VREG_LP_GP2_ID, - PM_VREG_LP_GP5_ID, - PM_VREG_LP_GP6_ID, - PM_VREG_LP_MPLL_ID, - PM_VREG_LP_RFUBM_ID, - PM_VREG_LP_RFA_ID, - PM_VREG_LP_CDC2_ID, - PM_VREG_LP_RFTX2_ID, - PM_VREG_LP_USIM_ID, - PM_VREG_LP_USB2P6_ID, - PM_VREG_LP_TCXO_ID, - PM_VREG_LP_USB3P3_ID, - - PM_VREG_LP_MSME_ID = PM_VREG_LP_MSME1_ID, - /* backward compatible enums only */ - PM_VREG_LP_CAM_ID = PM_VREG_LP_GP1_ID, - PM_VREG_LP_MDDI_ID = PM_VREG_LP_GP2_ID, - PM_VREG_LP_RUIM2_ID = PM_VREG_LP_GP3_ID, - PM_VREG_LP_AUX_ID = PM_VREG_LP_GP4_ID, - PM_VREG_LP_AUX2_ID = PM_VREG_LP_GP5_ID, - PM_VREG_LP_BT_ID = PM_VREG_LP_GP6_ID, - PM_VREG_LP_MSMC_LDO_ID = PM_VREG_LP_MSMC_ID, - PM_VREG_LP_MSME1_LDO_ID = PM_VREG_LP_MSME1_ID, - PM_VREG_LP_MSME2_LDO_ID = PM_VREG_LP_MSME2_ID, - PM_VREG_LP_RFA1_ID = PM_VREG_LP_RFRX2_ID, - PM_VREG_LP_RFA2_ID = PM_VREG_LP_RFTX2_ID, - PM_VREG_LP_XO_ID = PM_VREG_LP_TCXO_ID -}; - -enum mpp_which { - PM_MPP_1, - PM_MPP_2, - PM_MPP_3, - PM_MPP_4, - PM_MPP_5, - PM_MPP_6, - PM_MPP_7, - PM_MPP_8, - PM_MPP_9, - PM_MPP_10, - PM_MPP_11, - PM_MPP_12, - PM_MPP_13, - PM_MPP_14, - PM_MPP_15, - PM_MPP_16, - PM_MPP_17, - PM_MPP_18, - PM_MPP_19, - PM_MPP_20, - PM_MPP_21, - PM_MPP_22, - - PM_NUM_MPP_HAN = PM_MPP_4 + 1, - PM_NUM_MPP_KIP = PM_MPP_4 + 1, - PM_NUM_MPP_EPIC = PM_MPP_4 + 1, - PM_NUM_MPP_PM7500 = PM_MPP_22 + 1, - PM_NUM_MPP_PM6650 = PM_MPP_12 + 1, - PM_NUM_MPP_PM6658 = PM_MPP_12 + 1, - PM_NUM_MPP_PANORAMIX = PM_MPP_2 + 1, - PM_NUM_MPP_PM6640 = PM_NUM_MPP_PANORAMIX, - PM_NUM_MPP_PM6620 = PM_NUM_MPP_PANORAMIX -}; - -enum mpp_dlogic_level { - PM_MPP__DLOGIC__LVL_MSME, - PM_MPP__DLOGIC__LVL_MSMP, - PM_MPP__DLOGIC__LVL_RUIM, - PM_MPP__DLOGIC__LVL_MMC, - PM_MPP__DLOGIC__LVL_VDD, -}; - -enum mpp_dlogic_in_dbus { - PM_MPP__DLOGIC_IN__DBUS_NONE, - PM_MPP__DLOGIC_IN__DBUS1, - PM_MPP__DLOGIC_IN__DBUS2, - PM_MPP__DLOGIC_IN__DBUS3, -}; - -enum mpp_dlogic_out_ctrl { - PM_MPP__DLOGIC_OUT__CTRL_LOW, - PM_MPP__DLOGIC_OUT__CTRL_HIGH, - PM_MPP__DLOGIC_OUT__CTRL_MPP, - PM_MPP__DLOGIC_OUT__CTRL_NOT_MPP, -}; - -enum mpp_i_sink_level { - PM_MPP__I_SINK__LEVEL_5mA, - PM_MPP__I_SINK__LEVEL_10mA, - PM_MPP__I_SINK__LEVEL_15mA, - PM_MPP__I_SINK__LEVEL_20mA, - PM_MPP__I_SINK__LEVEL_25mA, - PM_MPP__I_SINK__LEVEL_30mA, - PM_MPP__I_SINK__LEVEL_35mA, - PM_MPP__I_SINK__LEVEL_40mA, -}; - -enum mpp_i_sink_switch { - PM_MPP__I_SINK__SWITCH_DIS, - PM_MPP__I_SINK__SWITCH_ENA, - PM_MPP__I_SINK__SWITCH_ENA_IF_MPP_HIGH, - PM_MPP__I_SINK__SWITCH_ENA_IF_MPP_LOW, -}; - -enum pm_vib_mot_mode { - PM_VIB_MOT_MODE__MANUAL, - PM_VIB_MOT_MODE__DBUS1, - PM_VIB_MOT_MODE__DBUS2, - PM_VIB_MOT_MODE__DBUS3, -}; - -enum pm_vib_mot_pol { - PM_VIB_MOT_POL__ACTIVE_HIGH, - PM_VIB_MOT_POL__ACTIVE_LOW, -}; - -struct rtc_time { - uint sec; -}; - -enum rtc_alarm { - PM_RTC_ALARM_1, -}; - - -int pmic_lp_mode_control(enum switch_cmd cmd, enum vreg_lp_id id); -int pmic_secure_mpp_control_digital_output(enum mpp_which which, - enum mpp_dlogic_level level, enum mpp_dlogic_out_ctrl out); -int pmic_secure_mpp_config_i_sink(enum mpp_which which, - enum mpp_i_sink_level level, enum mpp_i_sink_switch onoff); -int pmic_secure_mpp_config_digital_input(enum mpp_which which, - enum mpp_dlogic_level level, enum mpp_dlogic_in_dbus dbus); -int pmic_speaker_cmd(const enum spkr_cmd cmd); -int pmic_set_spkr_configuration(struct spkr_config_mode *cfg); -int pmic_spkr_en_right_chan(uint enable); -int pmic_spkr_en_left_chan(uint enable); -int pmic_spkr_en(enum spkr_left_right left_right, uint enabled); -int pmic_spkr_set_gain(enum spkr_left_right left_right, enum spkr_gain gain); -int pmic_set_speaker_gain(enum spkr_gain gain); -int pmic_set_speaker_delay(enum spkr_dly delay); -int pmic_speaker_1k6_zin_enable(uint enable); -int pmic_spkr_set_mux_hpf_corner_freq(enum spkr_hpf_corner_freq freq); -int pmic_spkr_select_usb_with_hpf_20hz(uint enable); -int pmic_spkr_bypass_mux(uint enable); -int pmic_spkr_en_hpf(uint enable); -int pmic_spkr_en_sink_curr_from_ref_volt_cir(uint enable); -int pmic_spkr_set_delay(enum spkr_left_right left_right, enum spkr_dly delay); -int pmic_spkr_en_mute(enum spkr_left_right left_right, uint enabled); -int pmic_mic_en(uint enable); -int pmic_mic_set_volt(enum mic_volt vol); -int pmic_set_led_intensity(enum ledtype type, int level); -int pmic_flash_led_set_current(uint16_t milliamps); -int pmic_flash_led_set_mode(enum flash_led_mode mode); -int pmic_flash_led_set_polarity(enum flash_led_pol pol); -int pmic_spkr_add_right_left_chan(uint enable); -int pmic_spkr_en_stereo(uint enable); -int pmic_vib_mot_set_volt(uint vol); -int pmic_vib_mot_set_mode(enum pm_vib_mot_mode mode); -int pmic_vib_mot_set_polarity(enum pm_vib_mot_pol pol); -int pmic_vid_en(uint enable); -int pmic_vid_load_detect_en(uint enable); - -#endif diff --git a/arch/arm/mach-msm/qdsp6v2/Makefile b/arch/arm/mach-msm/qdsp6v2/Makefile index 40620bd21f77aa1cd5ebb13c28e322904928a54a..6d42be5d70d53621b23276262d1d9c20a8410f8a 100644 --- a/arch/arm/mach-msm/qdsp6v2/Makefile +++ b/arch/arm/mach-msm/qdsp6v2/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_MSM_QDSP6_APRV2) += apr.o apr_v2.o apr_tal.o dsp_debug.o -obj-$(CONFIG_MSM_QDSP6_APRV3) += apr.o apr_v3.o apr_tal.o +obj-$(CONFIG_MSM_QDSP6_APRV3) += apr.o apr_tal.o obj-$(CONFIG_MSM_QDSP6V2_CODECS) += aac_in.o qcelp_in.o evrc_in.o amrnb_in.o audio_utils.o obj-$(CONFIG_MSM_QDSP6V2_CODECS) += audio_wma.o audio_wmapro.o audio_aac.o audio_multi_aac.o audio_utils_aio.o obj-$(CONFIG_MSM_QDSP6V2_CODECS) += q6audio_v2.o q6audio_v2_aio.o msm_audio_ion.o diff --git a/arch/arm/mach-msm/qdsp6v2/apr_v3.c b/arch/arm/mach-msm/qdsp6v2/apr_v3.c deleted file mode 100644 index bbef6a5af809dd5c04e08c8797542b2ae42d8ff3..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/apr_v3.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013, 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 -#include -#include -#include -#include -#include -#include - -#define DEST_ID APR_DEST_MODEM - -void apr_set_subsys_state(void) -{ - apr_set_modem_state(APR_SUBSYS_UP); -} - -uint16_t apr_get_data_src(struct apr_hdr *hdr) -{ - return DEST_ID; -} - -int apr_get_dest_id(char *dest) -{ - return DEST_ID; -} - -void subsys_notif_register(struct notifier_block *mod_notif, - struct notifier_block *lp_notif) -{ - subsys_notif_register_notifier("modem", mod_notif); -} - diff --git a/arch/arm/mach-msm/qdsp6v2/audio_lpa.c b/arch/arm/mach-msm/qdsp6v2/audio_lpa.c deleted file mode 100644 index f6dd9fab2c5583ec1b5d87c6e01270b863743f85..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/audio_lpa.c +++ /dev/null @@ -1,1480 +0,0 @@ -/* low power audio output device - * - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "audio_lpa.h" - -#include -#include -#include - -#include -#include - -#define MAX_BUF 4 -#define BUFSZ (524288) - -#define AUDDEC_DEC_PCM 0 - -#define AUDLPA_EVENT_NUM 10 /* Default number of pre-allocated event packets */ - -#define __CONTAINS(r, v, l) ({ \ - typeof(r) __r = r; \ - typeof(v) __v = v; \ - typeof(v) __e = __v + l; \ - int res = ((__v >= __r->vaddr) && \ - (__e <= __r->vaddr + __r->len)); \ - res; \ -}) - -#define CONTAINS(r1, r2) ({ \ - typeof(r2) __r2 = r2; \ - __CONTAINS(r1, __r2->vaddr, __r2->len); \ -}) - -#define IN_RANGE(r, v) ({ \ - typeof(r) __r = r; \ - typeof(v) __vv = v; \ - int res = ((__vv >= __r->vaddr) && \ - (__vv < (__r->vaddr + __r->len))); \ - res; \ -}) - -#define OVERLAPS(r1, r2) ({ \ - typeof(r1) __r1 = r1; \ - typeof(r2) __r2 = r2; \ - typeof(__r2->vaddr) __v = __r2->vaddr; \ - typeof(__v) __e = __v + __r2->len - 1; \ - int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e)); \ - res; \ -}) - -struct audlpa_event { - struct list_head list; - int event_type; - union msm_audio_event_payload payload; -}; -struct audlpa_ion_region { - struct list_head list; - struct ion_handle *handle; - int fd; - void *vaddr; - unsigned long paddr; - unsigned long kvaddr; - unsigned long len; - unsigned ref_cnt; -}; - -struct audlpa_buffer_node { - struct list_head list; - struct msm_audio_aio_buf buf; - unsigned long paddr; -}; - -struct audlpa_dec { - char *name; - int dec_attrb; - long (*ioctl)(struct file *, unsigned int, unsigned long); - int (*set_params)(void *); -}; - -static void audlpa_post_event(struct audio *audio, int type, - union msm_audio_event_payload payload); - -static unsigned long audlpa_ion_fixup(struct audio *audio, void *addr, - unsigned long len, int ref_up); -static void audlpa_unmap_ion_region(struct audio *audio); -static void audlpa_async_send_data(struct audio *audio, unsigned needed, - uint32_t token); -static int audlpa_pause(struct audio *audio); -static long pcm_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -static int audlpa_set_pcm_params(void *data); - -struct audlpa_dec audlpa_decs[] = { - {"msm_pcm_lp_dec", AUDDEC_DEC_PCM, &pcm_ioctl, - &audlpa_set_pcm_params}, -}; - -static void lpa_listner(u32 evt_id, union auddev_evt_data *evt_payload, - void *private_data) -{ - struct audio *audio = (struct audio *) private_data; - int rc = 0; - - switch (evt_id) { - case AUDDEV_EVT_STREAM_VOL_CHG: - audio->volume = evt_payload->session_vol; - pr_debug("%s: AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d, " - "enabled = %d\n", __func__, audio->volume, - audio->out_enabled); - if (audio->out_enabled == 1) { - if (audio->ac) { - rc = q6asm_set_volume(audio->ac, audio->volume); - if (rc < 0) { - pr_err("%s: Send Volume command failed" - " rc=%d\n", __func__, rc); - } - } - } - break; - default: - pr_err("%s:ERROR:wrong event\n", __func__); - break; - } -} - -static void audlpa_prevent_sleep(struct audio *audio) -{ - pr_debug("%s:\n", __func__); - wake_lock(&audio->wakelock); -} - -static void audlpa_allow_sleep(struct audio *audio) -{ - pr_debug("%s:\n", __func__); - wake_unlock(&audio->wakelock); -} - -/* must be called with audio->lock held */ -static int audio_enable(struct audio *audio) -{ - pr_debug("%s\n", __func__); - - return q6asm_run(audio->ac, 0, 0, 0); - -} - -static void audlpa_async_flush(struct audio *audio) -{ - struct audlpa_buffer_node *buf_node; - struct list_head *ptr, *next; - union msm_audio_event_payload payload; - int rc = 0; - - pr_debug("%s:out_enabled = %d, drv_status = 0x%x\n", __func__, - audio->out_enabled, audio->drv_status); - if (audio->out_enabled) { - list_for_each_safe(ptr, next, &audio->out_queue) { - buf_node = list_entry(ptr, struct audlpa_buffer_node, - list); - list_del(&buf_node->list); - payload.aio_buf = buf_node->buf; - audlpa_post_event(audio, AUDIO_EVENT_WRITE_DONE, - payload); - kfree(buf_node); - } - /* Implicitly issue a pause to the decoder before flushing if - it is not in pause state */ - if (!(audio->drv_status & ADRV_STATUS_PAUSE)) { - rc = audlpa_pause(audio); - if (rc < 0) - pr_err("%s: pause cmd failed rc=%d\n", __func__, - rc); - } - - rc = q6asm_cmd(audio->ac, CMD_FLUSH); - if (rc < 0) - pr_err("%s: flush cmd failed rc=%d\n", __func__, rc); - - audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN; - audio->out_needed = 0; - - if (audio->stopped == 0) { - rc = audio_enable(audio); - if (rc < 0) - pr_err("%s: audio enable failed\n", __func__); - else { - audio->out_enabled = 1; - audio->out_needed = 1; - if (audio->drv_status & ADRV_STATUS_PAUSE) - audio->drv_status &= ~ADRV_STATUS_PAUSE; - } - } - wake_up(&audio->write_wait); - } -} - -/* must be called with audio->lock held */ -static int audio_disable(struct audio *audio) -{ - int rc = 0; - - pr_debug("%s:%d %d\n", __func__, audio->opened, audio->out_enabled); - - if (audio->opened) { - audio->out_enabled = 0; - audio->opened = 0; - rc = q6asm_cmd(audio->ac, CMD_CLOSE); - if (rc < 0) - pr_err("%s: CLOSE cmd failed\n", __func__); - else - pr_debug("%s: rxed CLOSE resp\n", __func__); - audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN; - wake_up(&audio->write_wait); - audio->out_needed = 0; - } - return rc; -} -static int audlpa_pause(struct audio *audio) -{ - int rc = 0; - - pr_debug("%s, enabled = %d\n", __func__, - audio->out_enabled); - if (audio->out_enabled) { - rc = q6asm_cmd(audio->ac, CMD_PAUSE); - if (rc < 0) - pr_err("%s: pause cmd failed rc=%d\n", __func__, rc); - - } else - pr_err("%s: Driver not enabled\n", __func__); - return rc; -} - -/* ------------------- dsp --------------------- */ -static void audlpa_async_send_data(struct audio *audio, unsigned needed, - uint32_t token) -{ - unsigned long flags; - struct audio_client *ac; - int rc = 0; - - pr_debug("%s:\n", __func__); - spin_lock_irqsave(&audio->dsp_lock, flags); - - pr_debug("%s: needed = %d, out_needed = %d, token = 0x%x\n", - __func__, needed, audio->out_needed, token); - if (needed && !audio->wflush) { - audio->out_needed = 1; - if (audio->drv_status & ADRV_STATUS_OBUF_GIVEN) { - /* pop one node out of queue */ - union msm_audio_event_payload evt_payload; - struct audlpa_buffer_node *used_buf; - - used_buf = list_first_entry(&audio->out_queue, - struct audlpa_buffer_node, list); - if (token == used_buf->paddr) { - pr_debug("%s, Release: addr: %lx," - " token = 0x%x\n", __func__, - used_buf->paddr, token); - list_del(&used_buf->list); - evt_payload.aio_buf = used_buf->buf; - audlpa_post_event(audio, AUDIO_EVENT_WRITE_DONE, - evt_payload); - kfree(used_buf); - audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN; - } - } - } - pr_debug("%s: out_needed = %d, stopped = %d, drv_status = 0x%x\n", - __func__, audio->out_needed, audio->stopped, - audio->drv_status); - if (audio->out_needed && (audio->stopped == 0)) { - struct audlpa_buffer_node *next_buf; - struct audio_aio_write_param param; - if (!list_empty(&audio->out_queue)) { - pr_debug("%s: list not empty\n", __func__); - next_buf = list_first_entry(&audio->out_queue, - struct audlpa_buffer_node, list); - if (next_buf) { - pr_debug("%s: Send: addr: %lx\n", __func__, - next_buf->paddr); - ac = audio->ac; - param.paddr = next_buf->paddr; - param.len = next_buf->buf.data_len; - param.msw_ts = 0; - param.lsw_ts = 0; - /* No time stamp valid */ - param.flags = NO_TIMESTAMP; - param.uid = next_buf->paddr; - rc = q6asm_async_write(ac, ¶m); - if (rc < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - audio->out_needed = 0; - audio->drv_status |= ADRV_STATUS_OBUF_GIVEN; - } - } else if (list_empty(&audio->out_queue) && - (audio->drv_status & ADRV_STATUS_FSYNC)) { - pr_debug("%s: list is empty, reached EOS\n", __func__); - wake_up(&audio->write_wait); - } - } - - spin_unlock_irqrestore(&audio->dsp_lock, flags); -} - -static int audlpa_events_pending(struct audio *audio) -{ - int empty; - - spin_lock(&audio->event_queue_lock); - empty = !list_empty(&audio->event_queue); - spin_unlock(&audio->event_queue_lock); - return empty || audio->event_abort; -} - -static void audlpa_reset_event_queue(struct audio *audio) -{ - struct audlpa_event *drv_evt; - struct list_head *ptr, *next; - - spin_lock(&audio->event_queue_lock); - list_for_each_safe(ptr, next, &audio->event_queue) { - drv_evt = list_first_entry(&audio->event_queue, - struct audlpa_event, list); - list_del(&drv_evt->list); - kfree(drv_evt); - } - list_for_each_safe(ptr, next, &audio->free_event_queue) { - drv_evt = list_first_entry(&audio->free_event_queue, - struct audlpa_event, list); - list_del(&drv_evt->list); - kfree(drv_evt); - } - spin_unlock(&audio->event_queue_lock); - - return; -} - -static long audlpa_process_event_req(struct audio *audio, void __user *arg) -{ - long rc; - struct msm_audio_event usr_evt; - struct audlpa_event *drv_evt = NULL; - int timeout; - - if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event))) - return -EFAULT; - - timeout = (int) usr_evt.timeout_ms; - - if (timeout > 0) { - rc = wait_event_interruptible_timeout( - audio->event_wait, audlpa_events_pending(audio), - msecs_to_jiffies(timeout)); - if (rc == 0) - return -ETIMEDOUT; - } else { - rc = wait_event_interruptible( - audio->event_wait, audlpa_events_pending(audio)); - } - - if (rc < 0) - return rc; - - if (audio->event_abort) { - audio->event_abort = 0; - return -ENODEV; - } - - rc = 0; - - spin_lock(&audio->event_queue_lock); - if (!list_empty(&audio->event_queue)) { - drv_evt = list_first_entry(&audio->event_queue, - struct audlpa_event, list); - list_del(&drv_evt->list); - } - if (drv_evt) { - usr_evt.event_type = drv_evt->event_type; - usr_evt.event_payload = drv_evt->payload; - list_add_tail(&drv_evt->list, &audio->free_event_queue); - } else - rc = -1; - spin_unlock(&audio->event_queue_lock); - - if (drv_evt && (drv_evt->event_type == AUDIO_EVENT_WRITE_DONE || - drv_evt->event_type == AUDIO_EVENT_READ_DONE)) { - pr_debug("%s: AUDIO_EVENT_WRITE_DONE completing\n", __func__); - mutex_lock(&audio->lock); - audlpa_ion_fixup(audio, drv_evt->payload.aio_buf.buf_addr, - drv_evt->payload.aio_buf.buf_len, 0); - mutex_unlock(&audio->lock); - } - if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt))) - rc = -EFAULT; - - return rc; -} - -static int audlpa_ion_check(struct audio *audio, - void *vaddr, unsigned long len) -{ - struct audlpa_ion_region *region_elt; - struct audlpa_ion_region t = {.vaddr = vaddr, .len = len }; - - list_for_each_entry(region_elt, &audio->ion_region_queue, list) { - if (CONTAINS(region_elt, &t) || CONTAINS(&t, region_elt) || - OVERLAPS(region_elt, &t)) { - pr_err("%s[%p]:region (vaddr %p len %ld)" - " clashes with registered region" - " (vaddr %p paddr %p len %ld)\n", - __func__, audio, vaddr, len, - region_elt->vaddr, - (void *)region_elt->paddr, region_elt->len); - return -EINVAL; - } - } - - return 0; -} -static int audlpa_ion_add(struct audio *audio, - struct msm_audio_ion_info *info) -{ - ion_phys_addr_t paddr; - size_t len; - unsigned long kvaddr; - struct audlpa_ion_region *region; - int rc = -EINVAL; - struct ion_handle *handle; - unsigned long ionflag; - void *temp_ptr; - - pr_debug("%s[%p]:\n", __func__, audio); - region = kmalloc(sizeof(*region), GFP_KERNEL); - - if (!region) { - rc = -ENOMEM; - goto end; - } - - - handle = ion_import_dma_buf(audio->client, info->fd); - if (IS_ERR_OR_NULL(handle)) { - pr_err("%s: could not get handle of the given fd\n", __func__); - goto import_error; - } - - rc = ion_handle_get_flags(audio->client, handle, &ionflag); - if (rc) { - pr_err("%s: could not get flags for the handle\n", __func__); - goto flag_error; - } - - temp_ptr = ion_map_kernel(audio->client, handle); - if (IS_ERR_OR_NULL(temp_ptr)) { - pr_err("%s: could not get virtual address\n", __func__); - goto map_error; - } - kvaddr = (unsigned long) temp_ptr; - - rc = ion_phys(audio->client, handle, &paddr, &len); - if (rc) { - pr_err("%s: could not get physical address\n", __func__); - goto ion_error; - } - - rc = audlpa_ion_check(audio, info->vaddr, len); - if (rc < 0) { - pr_err("%s: audlpa_ion_check failed\n", __func__); - goto ion_error; - } - - region->handle = handle; - region->vaddr = info->vaddr; - region->fd = info->fd; - region->paddr = paddr; - region->kvaddr = kvaddr; - region->len = len; - region->ref_cnt = 0; - pr_debug("%s[%p]:add region paddr %lx vaddr %p, len %lu kvaddr %lx\n", - __func__, audio, - region->paddr, region->vaddr, region->len, region->kvaddr); - list_add_tail(®ion->list, &audio->ion_region_queue); - - rc = q6asm_memory_map(audio->ac, (uint32_t)paddr, IN, (uint32_t)len, 1); - if (rc < 0) { - pr_err("%s[%p]: memory map failed\n", __func__, audio); - goto ion_error; - } else { - goto end; - } - -ion_error: - ion_unmap_kernel(audio->client, handle); -map_error: -flag_error: - ion_free(audio->client, handle); -import_error: - kfree(region); -end: - return rc; -} - -static int audlpa_ion_remove(struct audio *audio, - struct msm_audio_ion_info *info) -{ - struct audlpa_ion_region *region; - struct list_head *ptr, *next; - int rc = -EINVAL; - - list_for_each_safe(ptr, next, &audio->ion_region_queue) { - region = list_entry(ptr, struct audlpa_ion_region, list); - - if (region != NULL && (region->fd == info->fd) && - (region->vaddr == info->vaddr)) { - if (region->ref_cnt) { - pr_debug("%s[%p]:region %p in use ref_cnt %d\n", - __func__, audio, region, - region->ref_cnt); - break; - } - rc = q6asm_memory_unmap(audio->ac, - (uint32_t) region->paddr, IN); - if (rc < 0) - pr_err("%s[%p]: memory unmap failed\n", - __func__, audio); - - list_del(®ion->list); - ion_unmap_kernel(audio->client, region->handle); - ion_free(audio->client, region->handle); - kfree(region); - rc = 0; - break; - } - } - - return rc; -} - -static int audlpa_ion_lookup_vaddr(struct audio *audio, void *addr, - unsigned long len, struct audlpa_ion_region **region) -{ - struct audlpa_ion_region *region_elt; - int match_count = 0; - *region = NULL; - - /* returns physical address or zero */ - list_for_each_entry(region_elt, &audio->ion_region_queue, list) { - if (addr >= region_elt->vaddr && - addr < region_elt->vaddr + region_elt->len && - addr + len <= region_elt->vaddr + region_elt->len) { - /* offset since we could pass vaddr inside a registerd - * ion buffer - */ - - match_count++; - if (!*region) - *region = region_elt; - } - } - - if (match_count > 1) { - pr_err("%s[%p]:multiple hits for vaddr %p, len %ld\n", - __func__, audio, addr, len); - list_for_each_entry(region_elt, &audio->ion_region_queue, - list) { - if (addr >= region_elt->vaddr && - addr < region_elt->vaddr + region_elt->len && - addr + len <= region_elt->vaddr + region_elt->len) - pr_err("\t%s[%p]:%p, %ld --> %p\n", - __func__, audio, - region_elt->vaddr, - region_elt->len, - (void *)region_elt->paddr); - } - } - return *region ? 0 : -1; -} -static unsigned long audlpa_ion_fixup(struct audio *audio, void *addr, - unsigned long len, int ref_up) -{ - struct audlpa_ion_region *region; - unsigned long paddr; - int ret; - - ret = audlpa_ion_lookup_vaddr(audio, addr, len, ®ion); - if (ret) { - pr_err("%s[%p]:lookup (%p, %ld) failed\n", - __func__, audio, addr, len); - return 0; - } - if (ref_up) - region->ref_cnt++; - else - region->ref_cnt--; - paddr = region->paddr + (addr - region->vaddr); - return paddr; -} - -/* audio -> lock must be held at this point */ -static int audlpa_aio_buf_add(struct audio *audio, unsigned dir, - void __user *arg) -{ - struct audlpa_buffer_node *buf_node; - - buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL); - - if (!buf_node) - return -ENOMEM; - - if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) { - kfree(buf_node); - return -EFAULT; - } - - buf_node->paddr = audlpa_ion_fixup( - audio, buf_node->buf.buf_addr, - buf_node->buf.buf_len, 1); - if (dir) { - /* write */ - if (!buf_node->paddr || - (buf_node->paddr & 0x1) || - (buf_node->buf.data_len & 0x1)) { - kfree(buf_node); - return -EINVAL; - } - list_add_tail(&buf_node->list, &audio->out_queue); - pr_debug("%s, Added to list: addr: %lx, length = %d\n", - __func__, buf_node->paddr, buf_node->buf.data_len); - audlpa_async_send_data(audio, 0, 0); - } else { - /* read */ - kfree(buf_node); - } - return 0; -} - -static int config(struct audio *audio) -{ - int rc = 0; - if (!audio->out_prefill) { - if (audio->codec_ops.set_params != NULL) { - rc = audio->codec_ops.set_params(audio); - audio->out_prefill = 1; - } - } - return rc; -} - -void q6_audlpa_out_cb(uint32_t opcode, uint32_t token, - uint32_t *payload, void *priv) -{ - struct audio *audio = (struct audio *) priv; - - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: - pr_debug("%s: ASM_DATA_EVENT_WRITE_DONE, token = 0x%x\n", - __func__, token); - audlpa_async_send_data(audio, 1, token); - break; - case ASM_DATA_EVENT_EOS: - case ASM_DATA_CMDRSP_EOS: - pr_debug("%s: ASM_DATA_CMDRSP_EOS, teos = %d\n", __func__, - audio->teos); - if (audio->teos == 0) { - audio->teos = 1; - wake_up(&audio->write_wait); - } - break; - case ASM_SESSION_CMDRSP_GET_SESSION_TIME: - break; - case RESET_EVENTS: - reset_device(); - break; - default: - break; - } -} - -static long pcm_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - pr_debug("%s: cmd = %d\n", __func__, cmd); - return -EINVAL; -} - -static int audlpa_set_pcm_params(void *data) -{ - struct audio *audio = (struct audio *)data; - int rc; - - rc = q6asm_media_format_block_pcm(audio->ac, audio->out_sample_rate, - audio->out_channel_mode); - if (rc < 0) - pr_err("%s: Format block pcm failed\n", __func__); - return rc; -} - -static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct audio *audio = file->private_data; - int rc = -EINVAL; - uint64_t timestamp; - uint64_t temp; - - pr_debug("%s: audio_ioctl() cmd = %d\n", __func__, cmd); - - if (cmd == AUDIO_GET_STATS) { - struct msm_audio_stats stats; - - pr_debug("%s: AUDIO_GET_STATS cmd\n", __func__); - memset(&stats, 0, sizeof(stats)); - rc = q6asm_get_session_time(audio->ac, ×tamp); - if (rc < 0) { - pr_err("%s: Get Session Time return value =%lld\n", - __func__, timestamp); - return -EAGAIN; - } - temp = (timestamp * 2 * audio->out_channel_mode); - temp = temp * (audio->out_sample_rate/1000); - temp = div_u64(temp, 1000); - audio->bytes_consumed = (uint32_t)(temp & 0xFFFFFFFF); - stats.byte_count = audio->bytes_consumed; - stats.unused[0] = (uint32_t)((temp >> 32) & 0xFFFFFFFF); - pr_debug("%s: bytes_consumed:lsb = %d, msb = %d," - "timestamp = %lld\n", __func__, - audio->bytes_consumed, stats.unused[0], timestamp); - if (copy_to_user((void *) arg, &stats, sizeof(stats))) - return -EFAULT; - return 0; - } - - switch (cmd) { - case AUDIO_ENABLE_AUDPP: - break; - - case AUDIO_SET_VOLUME: - break; - - case AUDIO_SET_PAN: - break; - - case AUDIO_SET_EQ: - break; - } - - if (cmd == AUDIO_GET_EVENT) { - pr_debug("%s: AUDIO_GET_EVENT\n", __func__); - if (mutex_trylock(&audio->get_event_lock)) { - rc = audlpa_process_event_req(audio, - (void __user *) arg); - mutex_unlock(&audio->get_event_lock); - } else - rc = -EBUSY; - return rc; - } - - if (cmd == AUDIO_ABORT_GET_EVENT) { - audio->event_abort = 1; - wake_up(&audio->event_wait); - return 0; - } - - mutex_lock(&audio->lock); - switch (cmd) { - case AUDIO_START: - pr_info("%s: AUDIO_START: Session %d\n", __func__, - audio->ac->session); - if (!audio->opened) { - pr_err("%s: Driver not opened\n", __func__); - rc = -EFAULT; - goto fail; - } - rc = config(audio); - if (rc) { - pr_err("%s: Out Configuration failed\n", __func__); - rc = -EFAULT; - goto fail; - } - - rc = audio_enable(audio); - if (rc) { - pr_err("%s: audio enable failed\n", __func__); - rc = -EFAULT; - goto fail; - } else { - struct asm_softpause_params softpause = { - .enable = SOFT_PAUSE_ENABLE, - .period = SOFT_PAUSE_PERIOD, - .step = SOFT_PAUSE_STEP, - .rampingcurve = SOFT_PAUSE_CURVE_LINEAR, - }; - struct asm_softvolume_params softvol = { - .period = SOFT_VOLUME_PERIOD, - .step = SOFT_VOLUME_STEP, - .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, - }; - if (softpause.rampingcurve == SOFT_PAUSE_CURVE_LINEAR) - softpause.step = SOFT_PAUSE_STEP_LINEAR; - if (softvol.rampingcurve == SOFT_VOLUME_CURVE_LINEAR) - softvol.step = SOFT_VOLUME_STEP_LINEAR; - audio->out_enabled = 1; - audio->out_needed = 1; - rc = q6asm_set_volume(audio->ac, audio->volume); - if (rc < 0) - pr_err("%s: Send Volume command failed rc=%d\n", - __func__, rc); - rc = q6asm_set_softpause(audio->ac, &softpause); - if (rc < 0) - pr_err("%s: Send SoftPause Param failed rc=%d\n", - __func__, rc); - rc = q6asm_set_softvolume(audio->ac, &softvol); - if (rc < 0) - pr_err("%s: Send SoftVolume Param failed rc=%d\n", - __func__, rc); - rc = q6asm_set_lrgain(audio->ac, 0x2000, 0x2000); - if (rc < 0) - pr_err("%s: Send channel gain failed rc=%d\n", - __func__, rc); - /* disable mute by default */ - rc = q6asm_set_mute(audio->ac, 0); - if (rc < 0) - pr_err("%s: Send mute command failed rc=%d\n", - __func__, rc); - if (!list_empty(&audio->out_queue)) - pr_err("%s: write_list is not empty!!!\n", - __func__); - if (audio->stopped == 1) - audio->stopped = 0; - audlpa_prevent_sleep(audio); - } - break; - - case AUDIO_STOP: - pr_info("%s: AUDIO_STOP: session_id:%d\n", __func__, - audio->ac->session); - audio->stopped = 1; - audlpa_async_flush(audio); - audio->out_enabled = 0; - audio->out_needed = 0; - audio->drv_status &= ~ADRV_STATUS_PAUSE; - audlpa_allow_sleep(audio); - break; - - case AUDIO_FLUSH: - pr_debug("%s: AUDIO_FLUSH: session_id:%d\n", __func__, - audio->ac->session); - audio->wflush = 1; - if (audio->out_enabled) - audlpa_async_flush(audio); - else - audio->wflush = 0; - audio->wflush = 0; - break; - - case AUDIO_SET_CONFIG:{ - struct msm_audio_config config; - pr_debug("%s: AUDIO_SET_CONFIG\n", __func__); - if (copy_from_user(&config, (void *) arg, sizeof(config))) { - rc = -EFAULT; - pr_err("%s: ERROR: copy from user\n", __func__); - break; - } - if (!((config.channel_count == 1) || - (config.channel_count == 2))) { - rc = -EINVAL; - pr_err("%s: ERROR: config.channel_count == %d\n", - __func__, config.channel_count); - break; - } - - if (!((config.bits == 8) || (config.bits == 16) || - (config.bits == 24))) { - rc = -EINVAL; - pr_err("%s: ERROR: config.bits = %d\n", __func__, - config.bits); - break; - } - audio->out_sample_rate = config.sample_rate; - audio->out_channel_mode = config.channel_count; - audio->out_bits = config.bits; - audio->buffer_count = config.buffer_count; - audio->buffer_size = config.buffer_size; - rc = 0; - break; - } - - case AUDIO_GET_CONFIG:{ - struct msm_audio_config config; - config.buffer_count = audio->buffer_count; - config.buffer_size = audio->buffer_size; - config.sample_rate = audio->out_sample_rate; - config.channel_count = audio->out_channel_mode; - config.bits = audio->out_bits; - - config.meta_field = 0; - config.unused[0] = 0; - config.unused[1] = 0; - config.unused[2] = 0; - if (copy_to_user((void *) arg, &config, sizeof(config))) - rc = -EFAULT; - else - rc = 0; - break; - } - - case AUDIO_PAUSE: - pr_debug("%s: AUDIO_PAUSE %ld\n", __func__, arg); - if (arg == 1) { - rc = audlpa_pause(audio); - if (rc < 0) - pr_err("%s: pause FAILED rc=%d\n", __func__, - rc); - audio->drv_status |= ADRV_STATUS_PAUSE; - } else if (arg == 0) { - if (audio->drv_status & ADRV_STATUS_PAUSE) { - rc = audio_enable(audio); - if (rc) - pr_err("%s: audio enable failed\n", - __func__); - else { - audio->drv_status &= ~ADRV_STATUS_PAUSE; - audio->out_enabled = 1; - } - } - } - break; - - case AUDIO_REGISTER_ION: { - struct msm_audio_ion_info info; - pr_debug("%s: AUDIO_REGISTER_ION\n", __func__); - if (copy_from_user(&info, (void *)arg, sizeof(info))) - rc = -EFAULT; - else - rc = audlpa_ion_add(audio, &info); - break; - } - - case AUDIO_DEREGISTER_ION: { - struct msm_audio_ion_info info; - pr_debug("%s: AUDIO_DEREGISTER_ION\n", __func__); - if (copy_from_user(&info, (void *)arg, sizeof(info))) - rc = -EFAULT; - else - rc = audlpa_ion_remove(audio, &info); - break; - } - - case AUDIO_ASYNC_WRITE: - pr_debug("%s: AUDIO_ASYNC_WRITE\n", __func__); - if (audio->drv_status & ADRV_STATUS_FSYNC) - rc = -EBUSY; - else - rc = audlpa_aio_buf_add(audio, 1, (void __user *) arg); - break; - - case AUDIO_GET_SESSION_ID: - if (copy_to_user((void *) arg, &audio->ac->session, - sizeof(unsigned short))) - return -EFAULT; - rc = 0; - break; - - default: - rc = audio->codec_ops.ioctl(file, cmd, arg); - } -fail: - mutex_unlock(&audio->lock); - return rc; -} - -/* Only useful in tunnel-mode */ -int audlpa_async_fsync(struct audio *audio) -{ - int rc = 0; - - pr_info("%s:Session %d\n", __func__, audio->ac->session); - - /* Blocking client sends more data */ - mutex_lock(&audio->lock); - audio->drv_status |= ADRV_STATUS_FSYNC; - mutex_unlock(&audio->lock); - - mutex_lock(&audio->write_lock); - audio->teos = 0; - - rc = wait_event_interruptible(audio->write_wait, - ((list_empty(&audio->out_queue)) || - audio->wflush || audio->stopped)); - - if (audio->wflush || audio->stopped) - goto flush_event; - - if (rc < 0) { - pr_err("%s: wait event for list_empty failed, rc = %d\n", - __func__, rc); - goto done; - } - - rc = q6asm_cmd(audio->ac, CMD_EOS); - - if (rc < 0) { - pr_err("%s: q6asm_cmd failed, rc = %d", __func__, rc); - goto done; - } - rc = wait_event_interruptible_timeout(audio->write_wait, - (audio->teos || audio->wflush || - audio->stopped), 5*HZ); - - if (rc < 0) { - pr_err("%s: wait event for teos failed, rc = %d\n", __func__, - rc); - goto done; - } - - if (audio->teos == 1) { - rc = audio_enable(audio); - if (rc) - pr_err("%s: audio enable failed\n", __func__); - else { - audio->drv_status &= ~ADRV_STATUS_PAUSE; - audio->out_enabled = 1; - audio->out_needed = 1; - } - } - -flush_event: - if (audio->stopped || audio->wflush) - rc = -EBUSY; - -done: - mutex_unlock(&audio->write_lock); - mutex_lock(&audio->lock); - audio->drv_status &= ~ADRV_STATUS_FSYNC; - mutex_unlock(&audio->lock); - - return rc; -} - -int audlpa_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync) -{ - struct audio *audio = file->private_data; - - return audlpa_async_fsync(audio); -} - -void audlpa_reset_ion_region(struct audio *audio) -{ - struct audlpa_ion_region *region; - struct list_head *ptr, *next; - - list_for_each_safe(ptr, next, &audio->ion_region_queue) { - region = list_entry(ptr, struct audlpa_ion_region, list); - list_del(®ion->list); - ion_unmap_kernel(audio->client, region->handle); - ion_free(audio->client, region->handle); - kfree(region); - } - - return; -} - -static void audlpa_unmap_ion_region(struct audio *audio) -{ - struct audlpa_ion_region *region; - struct list_head *ptr, *next; - int rc = -EINVAL; - - pr_debug("%s[%p]:\n", __func__, audio); - list_for_each_safe(ptr, next, &audio->ion_region_queue) { - region = list_entry(ptr, struct audlpa_ion_region, list); - pr_debug("%s[%p]: phy_address = 0x%lx\n", - __func__, audio, region->paddr); - if (region != NULL) { - rc = q6asm_memory_unmap(audio->ac, - (uint32_t)region->paddr, IN); - if (rc < 0) - pr_err("%s: memory unmap failed\n", __func__); - } - } -} - -static int audio_release(struct inode *inode, struct file *file) -{ - struct audio *audio = file->private_data; - - pr_info("%s: audio instance 0x%08x freeing, session %d\n", __func__, - (int)audio, audio->ac->session); - - mutex_lock(&audio->lock); - audio->wflush = 1; - if (audio->out_enabled) - audlpa_async_flush(audio); - audio->wflush = 0; - audio_disable(audio); - audlpa_unmap_ion_region(audio); - msm_clear_session_id(audio->ac->session); - auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->ac->session); - q6asm_audio_client_free(audio->ac); - audlpa_reset_ion_region(audio); - ion_client_destroy(audio->client); -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&audio->suspend_ctl.node); -#endif - audio->opened = 0; - audio->out_enabled = 0; - audio->out_prefill = 0; - audio->event_abort = 1; - wake_up(&audio->event_wait); - audlpa_reset_event_queue(audio); - if (audio->stopped == 0) - audlpa_allow_sleep(audio); - wake_lock_destroy(&audio->wakelock); - - mutex_unlock(&audio->lock); -#ifdef CONFIG_DEBUG_FS - if (audio->dentry) - debugfs_remove(audio->dentry); -#endif - kfree(audio); - return 0; -} - -static void audlpa_post_event(struct audio *audio, int type, - union msm_audio_event_payload payload) -{ - struct audlpa_event *e_node = NULL; - - spin_lock(&audio->event_queue_lock); - - pr_debug("%s:\n", __func__); - if (!list_empty(&audio->free_event_queue)) { - e_node = list_first_entry(&audio->free_event_queue, - struct audlpa_event, list); - list_del(&e_node->list); - } else { - e_node = kmalloc(sizeof(struct audlpa_event), GFP_ATOMIC); - if (!e_node) { - pr_err("%s: No mem to post event %d\n", __func__, type); - return; - } - } - - e_node->event_type = type; - e_node->payload = payload; - - list_add_tail(&e_node->list, &audio->event_queue); - spin_unlock(&audio->event_queue_lock); - wake_up(&audio->event_wait); -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void audlpa_suspend(struct early_suspend *h) -{ - struct audlpa_suspend_ctl *ctl = - container_of(h, struct audlpa_suspend_ctl, node); - union msm_audio_event_payload payload; - - pr_debug("%s:\n", __func__); - audlpa_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload); -} - -static void audlpa_resume(struct early_suspend *h) -{ - struct audlpa_suspend_ctl *ctl = - container_of(h, struct audlpa_suspend_ctl, node); - union msm_audio_event_payload payload; - - pr_debug("%s:\n", __func__); - audlpa_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload); -} -#endif - -#ifdef CONFIG_DEBUG_FS -static ssize_t audlpa_debug_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static ssize_t audlpa_debug_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - const int debug_bufmax = 4096; - static char buffer[4096]; - int n = 0; - struct audio *audio = file->private_data; - - mutex_lock(&audio->lock); - n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened); - n += scnprintf(buffer + n, debug_bufmax - n, - "out_enabled %d\n", audio->out_enabled); - n += scnprintf(buffer + n, debug_bufmax - n, - "stopped %d\n", audio->stopped); - n += scnprintf(buffer + n, debug_bufmax - n, - "volume %x\n", audio->volume); - n += scnprintf(buffer + n, debug_bufmax - n, - "sample rate %d\n", - audio->out_sample_rate); - n += scnprintf(buffer + n, debug_bufmax - n, - "channel mode %d\n", - audio->out_channel_mode); - mutex_unlock(&audio->lock); - /* Following variables are only useful for debugging when - * when playback halts unexpectedly. Thus, no mutual exclusion - * enforced - */ - n += scnprintf(buffer + n, debug_bufmax - n, - "wflush %d\n", audio->wflush); - n += scnprintf(buffer + n, debug_bufmax - n, - "running %d\n", audio->running); - n += scnprintf(buffer + n, debug_bufmax - n, - "out_needed %d\n", audio->out_needed); - buffer[n] = 0; - return simple_read_from_buffer(buf, count, ppos, buffer, n); -} - -static const struct file_operations audlpa_debug_fops = { - .read = audlpa_debug_read, - .open = audlpa_debug_open, -}; -#endif - -static int audio_open(struct inode *inode, struct file *file) -{ - struct audio *audio = NULL; - int rc, i, dec_attrb = 0; - struct audlpa_event *e_node = NULL; -#ifdef CONFIG_DEBUG_FS - /* 4 bytes represents decoder number, 1 byte for terminate string */ - char name[sizeof "msm_lpa_" + 5]; -#endif - char wake_lock_name[24]; - - /* Allocate audio instance, set to zero */ - audio = kzalloc(sizeof(struct audio), GFP_KERNEL); - if (!audio) { - pr_err("%s: no memory to allocate audio instance\n", __func__); - rc = -ENOMEM; - goto done; - } - - if ((file->f_mode & FMODE_WRITE) && !(file->f_mode & FMODE_READ)) { - pr_debug("%s: Tunnel Mode playback\n", __func__); - } else { - kfree(audio); - rc = -EACCES; - goto done; - } - - /* Allocate the decoder based on inode minor number*/ - audio->minor_no = iminor(inode); - dec_attrb |= audlpa_decs[audio->minor_no].dec_attrb; - audio->codec_ops.ioctl = audlpa_decs[audio->minor_no].ioctl; - audio->codec_ops.set_params = audlpa_decs[audio->minor_no].set_params; - audio->buffer_size = BUFSZ; - audio->buffer_count = MAX_BUF; - - audio->ac = q6asm_audio_client_alloc((app_cb)q6_audlpa_out_cb, - (void *)audio); - if (!audio->ac) { - pr_err("%s: Could not allocate memory for lpa client\n", - __func__); - rc = -ENOMEM; - goto err; - } - rc = q6asm_open_write(audio->ac, FORMAT_LINEAR_PCM); - if (rc < 0) { - pr_err("%s: lpa out open failed\n", __func__); - goto err; - } - - pr_debug("%s: Set mode to AIO session[%d]\n", - __func__, - audio->ac->session); - rc = q6asm_set_io_mode(audio->ac, ASYNC_IO_MODE); - if (rc < 0) - pr_err("%s: Set IO mode failed\n", __func__); - - - /* Initialize all locks of audio instance */ - mutex_init(&audio->lock); - mutex_init(&audio->write_lock); - mutex_init(&audio->get_event_lock); - spin_lock_init(&audio->dsp_lock); - init_waitqueue_head(&audio->write_wait); - INIT_LIST_HEAD(&audio->out_queue); - INIT_LIST_HEAD(&audio->ion_region_queue); - INIT_LIST_HEAD(&audio->free_event_queue); - INIT_LIST_HEAD(&audio->event_queue); - init_waitqueue_head(&audio->wait); - init_waitqueue_head(&audio->event_wait); - spin_lock_init(&audio->event_queue_lock); - snprintf(wake_lock_name, sizeof wake_lock_name, "audio_lpa_%x", - audio->ac->session); - wake_lock_init(&audio->wakelock, WAKE_LOCK_SUSPEND, wake_lock_name); - - audio->out_sample_rate = 44100; - audio->out_channel_mode = 2; - audio->out_bits = 16; - audio->volume = 0x2000; - - file->private_data = audio; - audio->opened = 1; - audio->out_enabled = 0; - audio->out_prefill = 0; - audio->bytes_consumed = 0; - - audio->device_events = AUDDEV_EVT_STREAM_VOL_CHG; - audio->drv_status &= ~ADRV_STATUS_PAUSE; - - rc = auddev_register_evt_listner(audio->device_events, - AUDDEV_CLNT_DEC, - audio->ac->session, - lpa_listner, - (void *)audio); - if (rc) { - pr_err("%s: failed to register listner\n", __func__); - goto err; - } - -#ifdef CONFIG_DEBUG_FS - snprintf(name, sizeof name, "msm_lpa_%04x", audio->ac->session); - audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, - NULL, (void *) audio, &audlpa_debug_fops); - - if (IS_ERR(audio->dentry)) - pr_err("%s: debugfs_create_file failed\n", __func__); -#endif -#ifdef CONFIG_HAS_EARLYSUSPEND - audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; - audio->suspend_ctl.node.resume = audlpa_resume; - audio->suspend_ctl.node.suspend = audlpa_suspend; - audio->suspend_ctl.audio = audio; - register_early_suspend(&audio->suspend_ctl.node); -#endif - for (i = 0; i < AUDLPA_EVENT_NUM; i++) { - e_node = kmalloc(sizeof(struct audlpa_event), GFP_KERNEL); - if (e_node) - list_add_tail(&e_node->list, &audio->free_event_queue); - else { - pr_err("%s: event pkt alloc failed\n", __func__); - break; - } - } - pr_info("%s: audio instance 0x%08x created session[%d]\n", __func__, - (int)audio, - audio->ac->session); - audio->client = msm_ion_client_create(UINT_MAX, "Audio_LPA_Client"); - if (IS_ERR_OR_NULL(audio->client)) { - pr_err("Unable to create ION client\n"); - goto err; - } - pr_debug("Allocating ION clinet in audio_open %p", audio->client); -done: - return rc; -err: - q6asm_audio_client_free(audio->ac); - kfree(audio); - return rc; -} - -static const struct file_operations audio_lpa_fops = { - .owner = THIS_MODULE, - .open = audio_open, - .release = audio_release, - .unlocked_ioctl = audio_ioctl, - .fsync = audlpa_fsync, -}; - -static dev_t audlpa_devno; -static struct class *audlpa_class; -struct audlpa_device { - const char *name; - struct device *device; - struct cdev cdev; -}; - -static struct audlpa_device *audlpa_devices; - -static void audlpa_create(struct audlpa_device *adev, const char *name, - struct device *parent, dev_t devt) -{ - struct device *dev; - int rc; - - dev = device_create(audlpa_class, parent, devt, "%s", name); - if (IS_ERR(dev)) - return; - - cdev_init(&adev->cdev, &audio_lpa_fops); - adev->cdev.owner = THIS_MODULE; - - rc = cdev_add(&adev->cdev, devt, 1); - if (rc < 0) { - device_destroy(audlpa_class, devt); - } else { - adev->device = dev; - adev->name = name; - } -} - -static int __init audio_init(void) -{ - int rc; - int n = ARRAY_SIZE(audlpa_decs); - - audlpa_devices = kzalloc(sizeof(struct audlpa_device) * n, GFP_KERNEL); - if (!audlpa_devices) - return -ENOMEM; - - audlpa_class = class_create(THIS_MODULE, "audlpa"); - if (IS_ERR(audlpa_class)) - goto fail_create_class; - - rc = alloc_chrdev_region(&audlpa_devno, 0, n, "msm_audio_lpa"); - if (rc < 0) - goto fail_alloc_region; - - for (n = 0; n < ARRAY_SIZE(audlpa_decs); n++) { - audlpa_create(audlpa_devices + n, - audlpa_decs[n].name, NULL, - MKDEV(MAJOR(audlpa_devno), n)); - } - - return 0; - -fail_alloc_region: - class_unregister(audlpa_class); - return rc; -fail_create_class: - kfree(audlpa_devices); - return -ENOMEM; -} - -static void __exit audio_exit(void) -{ - class_unregister(audlpa_class); - kfree(audlpa_devices); -} - -module_init(audio_init); -module_exit(audio_exit); - -MODULE_DESCRIPTION("MSM LPA driver"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/audio_lpa.h b/arch/arm/mach-msm/qdsp6v2/audio_lpa.h deleted file mode 100644 index c305967cf9defa0f9ae09a398b550837b5849ad4..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/audio_lpa.h +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (c) 2010-2012, 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 AUDIO_LPA_H -#define AUDIO_LPA_H - -#include -#include - -#define ADRV_STATUS_OBUF_GIVEN 0x00000001 -#define ADRV_STATUS_IBUF_GIVEN 0x00000002 -#define ADRV_STATUS_FSYNC 0x00000004 -#define ADRV_STATUS_PAUSE 0x00000008 - -struct buffer { - void *data; - unsigned size; - unsigned used; /* Input usage actual DSP produced PCM size */ - unsigned addr; -}; - -#ifdef CONFIG_HAS_EARLYSUSPEND -struct audlpa_suspend_ctl { - struct early_suspend node; - struct audio *audio; -}; -#endif - -struct codec_operations { - long (*ioctl)(struct file *, unsigned int, unsigned long); - int (*set_params)(void *); -}; - -struct audio { - spinlock_t dsp_lock; - - uint8_t out_needed; /* number of buffers the dsp is waiting for */ - struct list_head out_queue; /* queue to retain output buffers */ - - struct mutex lock; - struct mutex write_lock; - wait_queue_head_t write_wait; - - struct audio_client *ac; - - /* configuration to use on next enable */ - uint32_t out_sample_rate; - uint32_t out_channel_mode; - uint32_t out_bits; /* bits per sample (used by PCM decoder) */ - - int32_t phys; /* physical address of write buffer */ - - uint32_t drv_status; - int wflush; /* Write flush */ - int opened; - int out_enabled; - int out_prefill; - int running; - int stopped; /* set when stopped, cleared on flush */ - int buf_refresh; - int teos; /* valid only if tunnel mode & no data left for decoder */ - -#ifdef CONFIG_HAS_EARLYSUSPEND - struct audlpa_suspend_ctl suspend_ctl; -#endif - - struct wake_lock wakelock; -#ifdef CONFIG_DEBUG_FS - struct dentry *dentry; -#endif - - wait_queue_head_t wait; - struct list_head free_event_queue; - struct list_head event_queue; - wait_queue_head_t event_wait; - spinlock_t event_queue_lock; - struct mutex get_event_lock; - int event_abort; - - uint32_t device_events; - - struct list_head ion_region_queue; /* protected by lock */ - struct ion_client *client; - - int eq_enable; - int eq_needs_commit; - uint32_t volume; - - unsigned int minor_no; - struct codec_operations codec_ops; - uint32_t buffer_size; - uint32_t buffer_count; - uint32_t bytes_consumed; -}; - -#endif /* !AUDIO_LPA_H */ diff --git a/arch/arm/mach-msm/qdsp6v2/audio_mvs.c b/arch/arm/mach-msm/qdsp6v2/audio_mvs.c deleted file mode 100644 index f64e5eac89c2f9c9df1548bb4bd2d67a05b5d999..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/audio_mvs.c +++ /dev/null @@ -1,1170 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* Each buffer is 20 ms, queue holds 200 ms of data. */ -#define MVS_MAX_Q_LEN 10 - -/* Length of the DSP frame info header added to the voc packet. */ -#define DSP_FRAME_HDR_LEN 1 - -enum audio_mvs_state_type { - AUDIO_MVS_CLOSED, - AUDIO_MVS_STARTED, - AUDIO_MVS_STOPPED -}; - -struct audio_mvs_buf_node { - struct list_head list; - struct q6_msm_audio_mvs_frame frame; -}; - -struct audio_mvs_info_type { - enum audio_mvs_state_type state; - - uint32_t mvs_mode; - uint32_t rate_type; - uint32_t dtx_mode; - struct q_min_max_rate min_max_rate; - - struct list_head in_queue; - struct list_head free_in_queue; - - struct list_head out_queue; - struct list_head free_out_queue; - - wait_queue_head_t in_wait; - wait_queue_head_t out_wait; - - struct mutex lock; - struct mutex in_lock; - struct mutex out_lock; - - spinlock_t dsp_lock; - - struct wake_lock suspend_lock; - struct pm_qos_request pm_qos_req; - - void *memory_chunk; -}; - -static struct audio_mvs_info_type audio_mvs_info; - -static uint32_t audio_mvs_get_rate(uint32_t mvs_mode, uint32_t rate_type) -{ - uint32_t cvs_rate; - - if (mvs_mode == MVS_MODE_AMR_WB) - cvs_rate = rate_type - MVS_AMR_MODE_0660; - else - cvs_rate = rate_type; - - pr_debug("%s: CVS rate is %d for MVS mode %d\n", - __func__, cvs_rate, mvs_mode); - - return cvs_rate; -} - -static void audio_mvs_process_ul_pkt(uint8_t *voc_pkt, - uint32_t pkt_len, - void *private_data) -{ - struct audio_mvs_buf_node *buf_node = NULL; - struct audio_mvs_info_type *audio = private_data; - unsigned long dsp_flags; - - /* Copy up-link packet into out_queue. */ - spin_lock_irqsave(&audio->dsp_lock, dsp_flags); - - if (!list_empty(&audio->free_out_queue)) { - buf_node = list_first_entry(&audio->free_out_queue, - struct audio_mvs_buf_node, - list); - list_del(&buf_node->list); - - switch (audio->mvs_mode) { - case MVS_MODE_AMR: - case MVS_MODE_AMR_WB: { - /* Remove the DSP frame info header. Header format: - * Bits 0-3: Frame rate - * Bits 4-7: Frame type - */ - buf_node->frame.header.frame_type = - ((*voc_pkt) & 0xF0) >> 4; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->out_queue); - break; - } - - case MVS_MODE_IS127: { - buf_node->frame.header.packet_rate = (*voc_pkt) & 0x0F; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->out_queue); - break; - } - - case MVS_MODE_G729A: { - /* G729 frames are 10ms each, but the DSP works with - * 20ms frames and sends two 10ms frames per buffer. - * Extract the two frames and put them in separate - * buffers. - */ - /* Remove the first DSP frame info header. - * Header format: - * Bits 0-1: Frame type - */ - buf_node->frame.header.frame_type = (*voc_pkt) & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - /* There are two frames in the buffer. Length of the - * first frame: - */ - buf_node->frame.len = (pkt_len - - 2 * DSP_FRAME_HDR_LEN) / 2; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - voc_pkt = voc_pkt + buf_node->frame.len; - - list_add_tail(&buf_node->list, &audio->out_queue); - - /* Get another buffer from the free Q and fill in the - * second frame. - */ - if (!list_empty(&audio->free_out_queue)) { - buf_node = - list_first_entry(&audio->free_out_queue, - struct audio_mvs_buf_node, - list); - list_del(&buf_node->list); - - /* Remove the second DSP frame info header. - * Header format: - * Bits 0-1: Frame type - */ - buf_node->frame.header.frame_type = - (*voc_pkt) & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - /* There are two frames in the buffer. Length - * of the first frame: - */ - buf_node->frame.len = (pkt_len - - 2 * DSP_FRAME_HDR_LEN) / 2; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, - &audio->out_queue); - - } else { - /* Drop the second frame. */ - pr_err("%s: UL data dropped, read is slow\n", - __func__); - } - - break; - } - - case MVS_MODE_G711: - case MVS_MODE_G711A: { - /* G711 frames are 10ms each, but the DSP works with - * 20ms frames and sends two 10ms frames per buffer. - * Extract the two frames and put them in separate - * buffers. - */ - /* Remove the first DSP frame info header. - * Header format: G711A - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - * - * Header format: G711 - * Bits 2-3: Frame rate - */ - if (audio->mvs_mode == MVS_MODE_G711A) - buf_node->frame.header.frame_type = - (*voc_pkt) & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - /* There are two frames in the buffer. Length of the - * first frame: - */ - buf_node->frame.len = (pkt_len - - 2 * DSP_FRAME_HDR_LEN) / 2; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - voc_pkt = voc_pkt + buf_node->frame.len; - - list_add_tail(&buf_node->list, &audio->out_queue); - - /* Get another buffer from the free Q and fill in the - * second frame. - */ - if (!list_empty(&audio->free_out_queue)) { - buf_node = - list_first_entry(&audio->free_out_queue, - struct audio_mvs_buf_node, - list); - list_del(&buf_node->list); - - /* Remove the second DSP frame info header. - * Header format: - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - */ - if (audio->mvs_mode == MVS_MODE_G711A) - buf_node->frame.header.frame_type = - (*voc_pkt) & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - /* There are two frames in the buffer. Length - * of the second frame: - */ - buf_node->frame.len = (pkt_len - - 2 * DSP_FRAME_HDR_LEN) / 2; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, - &audio->out_queue); - } else { - /* Drop the second frame. */ - pr_err("%s: UL data dropped, read is slow\n", - __func__); - } - break; - } - - case MVS_MODE_IS733: - case MVS_MODE_4GV_NB: - case MVS_MODE_4GV_WB: { - /* Remove the DSP frame info header. - * Header format: - * Bits 0-3: frame rate - */ - buf_node->frame.header.packet_rate = (*voc_pkt) & 0x0F; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->out_queue); - break; - } - - case MVS_MODE_EFR: - case MVS_MODE_FR: - case MVS_MODE_HR: { - /* - * Remove the DSP frame info header - * Header Format - * Bit 0: bfi unused for uplink - * Bit 1-2: sid applies to both uplink and downlink - * Bit 3: taf unused for uplink - * MVS_MODE_HR - * Bit 4: ufi unused for uplink - */ - buf_node->frame.header.gsm_frame_type.sid = - ((*voc_pkt) & 0x06) >> 1; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->out_queue); - break; - } - - default: { - buf_node->frame.header.frame_type = 0; - - buf_node->frame.len = pkt_len; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->out_queue); - } - } - } else { - pr_err("%s: UL data dropped, read is slow\n", __func__); - } - - spin_unlock_irqrestore(&audio->dsp_lock, dsp_flags); - - wake_up(&audio->out_wait); -} - -static void audio_mvs_process_dl_pkt(uint8_t *voc_pkt, - uint32_t *pkt_len, - void *private_data) -{ - struct audio_mvs_buf_node *buf_node = NULL; - struct audio_mvs_info_type *audio = private_data; - unsigned long dsp_flags; - - spin_lock_irqsave(&audio->dsp_lock, dsp_flags); - - if (!list_empty(&audio->in_queue)) { - uint32_t rate_type = audio_mvs_get_rate(audio->mvs_mode, - audio->rate_type); - - buf_node = list_first_entry(&audio->in_queue, - struct audio_mvs_buf_node, - list); - list_del(&buf_node->list); - - switch (audio->mvs_mode) { - case MVS_MODE_AMR: - case MVS_MODE_AMR_WB: { - /* Add the DSP frame info header. Header format: - * Bits 0-3: Frame rate - * Bits 4-7: Frame type - */ - *voc_pkt = - ((buf_node->frame.header.frame_type & 0x0F) << 4) | - (rate_type & 0x0F); - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->free_in_queue); - break; - } - - case MVS_MODE_IS127: { - /* Add the DSP frame info header. Header format: - * Bits 0-3: Frame rate - */ - *voc_pkt = buf_node->frame.header.packet_rate & 0x0F; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->free_in_queue); - break; - } - - case MVS_MODE_G729A: { - /* G729 frames are 10ms each but the DSP expects 20ms - * worth of data, so send two 10ms frames per buffer. - */ - /* Add the first DSP frame info header. Header format: - * Bits 0-1: Frame type - */ - *voc_pkt = buf_node->frame.header.frame_type & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - voc_pkt = voc_pkt + buf_node->frame.len; - - list_add_tail(&buf_node->list, &audio->free_in_queue); - - if (!list_empty(&audio->in_queue)) { - /* Get the second buffer. */ - buf_node = list_first_entry(&audio->in_queue, - struct audio_mvs_buf_node, - list); - list_del(&buf_node->list); - - /* Add the second DSP frame info header. - * Header format: - * Bits 0-1: Frame type - */ - *voc_pkt = buf_node->frame.header.frame_type - & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = *pkt_len + - buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, - &audio->free_in_queue); - } else { - /* Only 10ms worth of data is available, signal - * erasure frame. - */ - *voc_pkt = MVS_G729A_ERASURE & 0x03; - - *pkt_len = *pkt_len + DSP_FRAME_HDR_LEN; - } - - break; - } - - case MVS_MODE_G711: - case MVS_MODE_G711A: { - /* G711 frames are 10ms each but the DSP expects 20ms - * worth of data, so send two 10ms frames per buffer. - */ - /* Add the first DSP frame info header. Header format: - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - */ - *voc_pkt = ((rate_type & 0x0F) << 2) | - (buf_node->frame.header.frame_type & 0x03); - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - voc_pkt = voc_pkt + buf_node->frame.len; - - list_add_tail(&buf_node->list, &audio->free_in_queue); - - if (!list_empty(&audio->in_queue)) { - /* Get the second buffer. */ - buf_node = list_first_entry(&audio->in_queue, - struct audio_mvs_buf_node, - list); - list_del(&buf_node->list); - - /* Add the second DSP frame info header. - * Header format: - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - */ - *voc_pkt = ((rate_type & 0x0F) << 2) | - (buf_node->frame.header.frame_type & 0x03); - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = *pkt_len + - buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, - &audio->free_in_queue); - } else { - /* Only 10ms worth of data is available, signal - * erasure frame. - */ - *voc_pkt = ((rate_type & 0x0F) << 2) | - (MVS_G711A_ERASURE & 0x03); - - *pkt_len = *pkt_len + DSP_FRAME_HDR_LEN; - } - break; - } - - case MVS_MODE_IS733: - case MVS_MODE_4GV_NB: - case MVS_MODE_4GV_WB: { - /* Add the DSP frame info header. Header format: - * Bits 0-3 : Frame rate - */ - *voc_pkt = buf_node->frame.header.packet_rate & 0x0F; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->free_in_queue); - break; - } - - case MVS_MODE_EFR: - case MVS_MODE_FR: - case MVS_MODE_HR: { - /* - * Remove the DSP frame info header - * Header Format - * Bit 0: bfi applies only for downlink - * Bit 1-2: sid applies for downlink and uplink - * Bit 3: taf applies only for downlink - * MVS_MODE_HR - * Bit 4: ufi applies only for downlink - */ - *voc_pkt = - ((buf_node->frame.header.gsm_frame_type.bfi - & 0x01) | - ((buf_node->frame.header.gsm_frame_type.sid - & 0x03) << 1) | - ((buf_node->frame.header.gsm_frame_type.taf - & 0x01) << 3)); - - if (audio->mvs_mode == MVS_MODE_HR) { - *voc_pkt = (*voc_pkt | - ((buf_node->frame.header.gsm_frame_type.ufi - & 0x01) << 4) | - ((0 & 0x07) << 5)); - } else { - *voc_pkt = (*voc_pkt | - ((0 & 0x0F) << 4)); - } - - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->free_in_queue); - - break; - } - - default: { - *pkt_len = buf_node->frame.len; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &audio->free_in_queue); - } - } - } else { - *pkt_len = 0; - - pr_info("%s: No DL data available to send to MVS\n", __func__); - } - - spin_unlock_irqrestore(&audio->dsp_lock, dsp_flags); - wake_up(&audio->in_wait); -} - -static uint32_t audio_mvs_get_media_type(uint32_t mvs_mode, uint32_t rate_type) -{ - uint32_t media_type; - - switch (mvs_mode) { - case MVS_MODE_IS733: - media_type = VSS_MEDIA_ID_13K_MODEM; - break; - - case MVS_MODE_IS127: - media_type = VSS_MEDIA_ID_EVRC_MODEM; - break; - - case MVS_MODE_4GV_NB: - media_type = VSS_MEDIA_ID_4GV_NB_MODEM; - break; - - case MVS_MODE_4GV_WB: - media_type = VSS_MEDIA_ID_4GV_WB_MODEM; - break; - - case MVS_MODE_AMR: - media_type = VSS_MEDIA_ID_AMR_NB_MODEM; - break; - - case MVS_MODE_EFR: - media_type = VSS_MEDIA_ID_EFR_MODEM; - break; - - case MVS_MODE_FR: - media_type = VSS_MEDIA_ID_FR_MODEM; - break; - - case MVS_MODE_HR: - media_type = VSS_MEDIA_ID_HR_MODEM; - break; - - case MVS_MODE_LINEAR_PCM: - media_type = VSS_MEDIA_ID_PCM_NB; - break; - - case MVS_MODE_PCM: - media_type = VSS_MEDIA_ID_PCM_NB; - break; - - case MVS_MODE_AMR_WB: - media_type = VSS_MEDIA_ID_AMR_WB_MODEM; - break; - - case MVS_MODE_G729A: - media_type = VSS_MEDIA_ID_G729; - break; - - case MVS_MODE_G711: - case MVS_MODE_G711A: - if (rate_type == MVS_G711A_MODE_MULAW) - media_type = VSS_MEDIA_ID_G711_MULAW; - else - media_type = VSS_MEDIA_ID_G711_ALAW; - break; - - case MVS_MODE_PCM_WB: - media_type = VSS_MEDIA_ID_PCM_WB; - break; - - default: - media_type = VSS_MEDIA_ID_PCM_NB; - } - - pr_debug("%s: media_type is 0x%x\n", __func__, media_type); - - return media_type; -} - -static uint32_t audio_mvs_get_network_type(uint32_t mvs_mode) -{ - uint32_t network_type; - - switch (mvs_mode) { - case MVS_MODE_IS733: - case MVS_MODE_IS127: - case MVS_MODE_4GV_NB: - case MVS_MODE_AMR: - case MVS_MODE_EFR: - case MVS_MODE_FR: - case MVS_MODE_HR: - case MVS_MODE_LINEAR_PCM: - case MVS_MODE_G711: - case MVS_MODE_PCM: - case MVS_MODE_G729A: - case MVS_MODE_G711A: - network_type = VSS_NETWORK_ID_VOIP_NB; - break; - - case MVS_MODE_4GV_WB: - case MVS_MODE_AMR_WB: - case MVS_MODE_PCM_WB: - network_type = VSS_NETWORK_ID_VOIP_WB; - break; - - default: - network_type = VSS_NETWORK_ID_DEFAULT; - } - - pr_debug("%s: network_type is 0x%x\n", __func__, network_type); - - return network_type; -} - -static int audio_mvs_start(struct audio_mvs_info_type *audio) -{ - int rc = 0; - - pr_info("%s\n", __func__); - - /* Prevent sleep. */ - wake_lock(&audio->suspend_lock); - pm_qos_update_request(&audio->pm_qos_req, - msm_cpuidle_get_deep_idle_latency()); - - rc = voice_set_voc_path_full(1); - - if (rc == 0) { - voice_register_mvs_cb(audio_mvs_process_ul_pkt, - audio_mvs_process_dl_pkt, - audio); - - voice_config_vocoder( - audio_mvs_get_media_type(audio->mvs_mode, audio->rate_type), - audio_mvs_get_rate(audio->mvs_mode, audio->rate_type), - audio_mvs_get_network_type(audio->mvs_mode), - audio->dtx_mode, - audio->min_max_rate); - - audio->state = AUDIO_MVS_STARTED; - } else { - pr_err("%s: Error %d setting voc path to full\n", __func__, rc); - } - - return rc; -} - -static int audio_mvs_stop(struct audio_mvs_info_type *audio) -{ - int rc = 0; - - pr_info("%s\n", __func__); - - voice_set_voc_path_full(0); - - audio->state = AUDIO_MVS_STOPPED; - - /* Allow sleep. */ - pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); - wake_unlock(&audio->suspend_lock); - - return rc; -} - -static int audio_mvs_open(struct inode *inode, struct file *file) -{ - int rc = 0; - int i; - int offset = 0; - struct audio_mvs_buf_node *buf_node = NULL; - - pr_info("%s\n", __func__); - - mutex_lock(&audio_mvs_info.lock); - - /* Allocate input and output buffers. */ - audio_mvs_info.memory_chunk = kmalloc(2 * MVS_MAX_Q_LEN * - sizeof(struct audio_mvs_buf_node), - GFP_KERNEL); - - if (audio_mvs_info.memory_chunk != NULL) { - for (i = 0; i < MVS_MAX_Q_LEN; i++) { - buf_node = audio_mvs_info.memory_chunk + offset; - - list_add_tail(&buf_node->list, - &audio_mvs_info.free_in_queue); - - offset = offset + sizeof(struct audio_mvs_buf_node); - } - - for (i = 0; i < MVS_MAX_Q_LEN; i++) { - buf_node = audio_mvs_info.memory_chunk + offset; - - list_add_tail(&buf_node->list, - &audio_mvs_info.free_out_queue); - - offset = offset + sizeof(struct audio_mvs_buf_node); - } - - audio_mvs_info.state = AUDIO_MVS_STOPPED; - - file->private_data = &audio_mvs_info; - - } else { - pr_err("%s: No memory for IO buffers\n", __func__); - - rc = -ENOMEM; - } - - mutex_unlock(&audio_mvs_info.lock); - - return rc; -} - -static int audio_mvs_release(struct inode *inode, struct file *file) -{ - struct list_head *ptr = NULL; - struct list_head *next = NULL; - struct audio_mvs_buf_node *buf_node = NULL; - struct audio_mvs_info_type *audio = file->private_data; - - pr_info("%s\n", __func__); - - mutex_lock(&audio->lock); - - if (audio->state == AUDIO_MVS_STARTED) - audio_mvs_stop(audio); - - /* Free input and output memory. */ - mutex_lock(&audio->in_lock); - - list_for_each_safe(ptr, next, &audio->in_queue) { - buf_node = list_entry(ptr, struct audio_mvs_buf_node, list); - list_del(&buf_node->list); - } - - list_for_each_safe(ptr, next, &audio->free_in_queue) { - buf_node = list_entry(ptr, struct audio_mvs_buf_node, list); - list_del(&buf_node->list); - } - - mutex_unlock(&audio->in_lock); - - - mutex_lock(&audio->out_lock); - - list_for_each_safe(ptr, next, &audio->out_queue) { - buf_node = list_entry(ptr, struct audio_mvs_buf_node, list); - list_del(&buf_node->list); - } - - list_for_each_safe(ptr, next, &audio->free_out_queue) { - buf_node = list_entry(ptr, struct audio_mvs_buf_node, list); - list_del(&buf_node->list); - } - - mutex_unlock(&audio->out_lock); - - kfree(audio->memory_chunk); - audio->memory_chunk = NULL; - - audio->state = AUDIO_MVS_CLOSED; - - mutex_unlock(&audio->lock); - - return 0; -} - -static ssize_t audio_mvs_read(struct file *file, - char __user *buf, - size_t count, - loff_t *pos) -{ - int rc = 0; - struct audio_mvs_buf_node *buf_node = NULL; - struct audio_mvs_info_type *audio = file->private_data; - - pr_debug("%s:\n", __func__); - - rc = wait_event_interruptible_timeout(audio->out_wait, - (!list_empty(&audio->out_queue) || - audio->state == AUDIO_MVS_STOPPED), - 1 * HZ); - - if (rc > 0) { - mutex_lock(&audio->out_lock); - - if ((audio->state == AUDIO_MVS_STARTED) && - (!list_empty(&audio->out_queue))) { - - if (count >= sizeof(struct q6_msm_audio_mvs_frame)) { - buf_node = list_first_entry(&audio->out_queue, - struct audio_mvs_buf_node, - list); - list_del(&buf_node->list); - - rc = copy_to_user(buf, - &buf_node->frame, - sizeof(struct q6_msm_audio_mvs_frame)); - - if (rc == 0) { - rc = buf_node->frame.len + - sizeof(buf_node->frame.header) + - sizeof(buf_node->frame.len); - } else { - pr_err("%s: Copy to user retuned %d", - __func__, rc); - - rc = -EFAULT; - } - - list_add_tail(&buf_node->list, - &audio->free_out_queue); - } else { - pr_err("%s: Read count %d < sizeof(frame) %d", - __func__, count, - sizeof(struct q6_msm_audio_mvs_frame)); - - rc = -ENOMEM; - } - } else { - pr_err("%s: Read performed in state %d\n", - __func__, audio->state); - - rc = -EPERM; - } - - mutex_unlock(&audio->out_lock); - - } else if (rc == 0) { - pr_err("%s: No UL data available\n", __func__); - - rc = -ETIMEDOUT; - } else { - pr_err("%s: Read was interrupted\n", __func__); - - rc = -ERESTARTSYS; - } - - return rc; -} - -static ssize_t audio_mvs_write(struct file *file, - const char __user *buf, - size_t count, - loff_t *pos) -{ - int rc = 0; - struct audio_mvs_buf_node *buf_node = NULL; - struct audio_mvs_info_type *audio = file->private_data; - - pr_debug("%s:\n", __func__); - - rc = wait_event_interruptible_timeout(audio->in_wait, - (!list_empty(&audio->free_in_queue) || - audio->state == AUDIO_MVS_STOPPED), 1 * HZ); - if (rc > 0) { - mutex_lock(&audio->in_lock); - - if (audio->state == AUDIO_MVS_STARTED) { - if (count <= sizeof(struct q6_msm_audio_mvs_frame)) { - if (!list_empty(&audio->free_in_queue)) { - buf_node = - list_first_entry(&audio->free_in_queue, - struct audio_mvs_buf_node, list); - list_del(&buf_node->list); - rc = copy_from_user(&buf_node->frame, - buf, - count); - - list_add_tail(&buf_node->list, - &audio->in_queue); - } else { - pr_err("%s: No free DL buffs\n", - __func__); - } - } else { - pr_err("%s: Write count %d < sizeof(frame) %d", - __func__, count, - sizeof(struct q6_msm_audio_mvs_frame)); - - rc = -ENOMEM; - } - } else { - pr_err("%s: Write performed in invalid state %d\n", - __func__, audio->state); - - rc = -EPERM; - } - - mutex_unlock(&audio->in_lock); - } else if (rc == 0) { - pr_err("%s: No free DL buffs\n", __func__); - - rc = -ETIMEDOUT; - } else { - pr_err("%s: write was interrupted\n", __func__); - - rc = -ERESTARTSYS; - } - - return rc; -} - -static long audio_mvs_ioctl(struct file *file, - unsigned int cmd, - unsigned long arg) -{ - int rc = 0; - struct audio_mvs_info_type *audio = file->private_data; - - pr_info("%s:\n", __func__); - - switch (cmd) { - case AUDIO_GET_MVS_CONFIG: { - struct msm_audio_mvs_config config; - - pr_info("%s: IOCTL GET_MVS_CONFIG\n", __func__); - - mutex_lock(&audio->lock); - - config.mvs_mode = audio->mvs_mode; - config.rate_type = audio->rate_type; - config.dtx_mode = audio->dtx_mode; - config.min_max_rate.min_rate = audio->min_max_rate.min_rate; - config.min_max_rate.max_rate = audio->min_max_rate.max_rate; - mutex_unlock(&audio->lock); - - rc = copy_to_user((void *)arg, &config, sizeof(config)); - if (rc == 0) - rc = sizeof(config); - else - pr_err("%s: Config copy failed %d\n", __func__, rc); - - break; - } - - case AUDIO_SET_MVS_CONFIG: { - struct msm_audio_mvs_config config; - - pr_info("%s: IOCTL SET_MVS_CONFIG\n", __func__); - - rc = copy_from_user(&config, (void *)arg, sizeof(config)); - if (rc == 0) { - mutex_lock(&audio->lock); - - if (audio->state == AUDIO_MVS_STOPPED) { - audio->mvs_mode = config.mvs_mode; - audio->rate_type = config.rate_type; - audio->dtx_mode = config.dtx_mode; - audio->min_max_rate.min_rate = - config.min_max_rate.min_rate; - audio->min_max_rate.max_rate = - config.min_max_rate.max_rate; - } else { - pr_err("%s: Set confg called in state %d\n", - __func__, audio->state); - - rc = -EPERM; - } - - mutex_unlock(&audio->lock); - } else { - pr_err("%s: Config copy failed %d\n", __func__, rc); - } - - break; - } - - case AUDIO_START: { - pr_info("%s: IOCTL START\n", __func__); - - mutex_lock(&audio->lock); - - if (audio->state == AUDIO_MVS_STOPPED) { - rc = audio_mvs_start(audio); - - if (rc != 0) - audio_mvs_stop(audio); - } else { - pr_err("%s: Start called in invalid state %d\n", - __func__, audio->state); - - rc = -EPERM; - } - - mutex_unlock(&audio->lock); - - break; - } - - case AUDIO_STOP: { - pr_info("%s: IOCTL STOP\n", __func__); - - mutex_lock(&audio->lock); - - if (audio->state == AUDIO_MVS_STARTED) { - rc = audio_mvs_stop(audio); - } else { - pr_err("%s: Stop called in invalid state %d\n", - __func__, audio->state); - - rc = -EPERM; - } - - mutex_unlock(&audio->lock); - - break; - } - - default: { - pr_err("%s: Unknown IOCTL %d\n", __func__, cmd); - } - } - - return rc; -} - -static const struct file_operations audio_mvs_fops = { - .owner = THIS_MODULE, - .open = audio_mvs_open, - .release = audio_mvs_release, - .read = audio_mvs_read, - .write = audio_mvs_write, - .unlocked_ioctl = audio_mvs_ioctl -}; - -struct miscdevice audio_mvs_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = "msm_mvs", - .fops = &audio_mvs_fops -}; - -static int __init audio_mvs_init(void) -{ - int rc = 0; - - memset(&audio_mvs_info, 0, sizeof(audio_mvs_info)); - - init_waitqueue_head(&audio_mvs_info.in_wait); - init_waitqueue_head(&audio_mvs_info.out_wait); - - mutex_init(&audio_mvs_info.lock); - mutex_init(&audio_mvs_info.in_lock); - mutex_init(&audio_mvs_info.out_lock); - - spin_lock_init(&audio_mvs_info.dsp_lock); - - INIT_LIST_HEAD(&audio_mvs_info.in_queue); - INIT_LIST_HEAD(&audio_mvs_info.free_in_queue); - INIT_LIST_HEAD(&audio_mvs_info.out_queue); - INIT_LIST_HEAD(&audio_mvs_info.free_out_queue); - - wake_lock_init(&audio_mvs_info.suspend_lock, - WAKE_LOCK_SUSPEND, - "audio_mvs_suspend"); - pm_qos_add_request(&audio_mvs_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); - - rc = misc_register(&audio_mvs_misc); - - return rc; -} - -static void __exit audio_mvs_exit(void){ - pr_info("%s:\n", __func__); - - misc_deregister(&audio_mvs_misc); -} - -module_init(audio_mvs_init); -module_exit(audio_mvs_exit); - -MODULE_DESCRIPTION("MSM MVS driver"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/fm.c b/arch/arm/mach-msm/qdsp6v2/fm.c deleted file mode 100644 index 23bb716db640c079f6422a50d213651fe1737c11..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/fm.c +++ /dev/null @@ -1,261 +0,0 @@ -/* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - * - * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5v2/audio_mp3.c - * - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * - * All source code in this file is licensed under the following license except - * where indicated. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SESSION_ID_FM (MAX_SESSIONS + 1) -#define FM_ENABLE 0x1 -#define FM_DISABLE 0x0 -#define FM_COPP 0x7 - -struct audio { - struct mutex lock; - - int opened; - int enabled; - int running; - - uint16_t fm_source; - uint16_t fm_src_copp_id; - uint16_t fm_dest; - uint16_t fm_dst_copp_id; - uint16_t dec_id; - uint32_t device_events; - uint16_t volume; -}; - - -static struct audio fm_audio; -static int fm_audio_enable(struct audio *audio) -{ - if (audio->enabled) - return 0; - - pr_info("%s: fm dest= %08x fm_source = %08x\n", __func__, - audio->fm_dst_copp_id, audio->fm_src_copp_id); - - /* do afe loopback here */ - - if (audio->fm_dest && audio->fm_source) { - if (afe_loopback(FM_ENABLE, audio->fm_dst_copp_id, - audio->fm_src_copp_id) < 0) { - pr_err("%s: afe_loopback failed\n", __func__); - } - - audio->running = 1; - } - - audio->enabled = 1; - return 0; -} - -static void fm_audio_listner(u32 evt_id, union auddev_evt_data *evt_payload, - void *private_data) -{ - struct audio *audio = (struct audio *) private_data; - switch (evt_id) { - case AUDDEV_EVT_DEV_RDY: - pr_info("%s :AUDDEV_EVT_DEV_RDY\n", __func__); - if (evt_payload->routing_id == FM_COPP) { - audio->fm_source = 1; - audio->fm_src_copp_id = FM_COPP; - } else { - audio->fm_dest = 1; - audio->fm_dst_copp_id = evt_payload->routing_id; - } - - if (audio->enabled && - audio->fm_dest && - audio->fm_source) { - - afe_loopback_gain(audio->fm_src_copp_id, - audio->volume); - afe_loopback(FM_ENABLE, audio->fm_dst_copp_id, - audio->fm_src_copp_id); - audio->running = 1; - } - break; - case AUDDEV_EVT_DEV_RLS: - pr_info("%s: AUDDEV_EVT_DEV_RLS\n", __func__); - if (evt_payload->routing_id == audio->fm_src_copp_id) - audio->fm_source = 0; - else - audio->fm_dest = 0; - if (audio->running - && (!audio->fm_dest || !audio->fm_source)) { - afe_loopback(FM_DISABLE, audio->fm_dst_copp_id, - audio->fm_src_copp_id); - audio->running = 0; - } else { - pr_err("%s: device switch happened\n", __func__); - } - break; - case AUDDEV_EVT_STREAM_VOL_CHG: - pr_debug("%s: AUDDEV_EVT_STREAM_VOL_CHG\n", __func__); - if (audio->fm_source) { - audio->volume = evt_payload->session_vol; - afe_loopback_gain(audio->fm_src_copp_id, - audio->volume); - } - break; - - default: - pr_err("%s: ERROR:wrong event %08x\n", __func__, evt_id); - break; - } -} - -static int fm_audio_disable(struct audio *audio) -{ - - /* break the AFE loopback here */ - afe_loopback(FM_DISABLE, audio->fm_dst_copp_id, audio->fm_src_copp_id); - return 0; -} - -static long fm_audio_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct audio *audio = file->private_data; - int rc = -EINVAL; - - - mutex_lock(&audio->lock); - switch (cmd) { - case AUDIO_START: - pr_info("%s: AUDIO_START\n", __func__); - rc = fm_audio_enable(audio); - break; - case AUDIO_STOP: - pr_info("%s: AUDIO_STOP\n", __func__); - rc = fm_audio_disable(audio); - audio->running = 0; - audio->enabled = 0; - break; - case AUDIO_GET_SESSION_ID: - if (copy_to_user((void *) arg, &audio->dec_id, - sizeof(unsigned short))) - rc = -EFAULT; - else - rc = 0; - break; - default: - rc = -EINVAL; - pr_err("%s: Un supported IOCTL\n", __func__); - } - mutex_unlock(&audio->lock); - return rc; -} - -static int fm_audio_release(struct inode *inode, struct file *file) -{ - struct audio *audio = file->private_data; - - pr_debug("audio instance 0x%08x freeing\n", (int)audio); - mutex_lock(&audio->lock); - auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id); - fm_audio_disable(audio); - audio->running = 0; - audio->enabled = 0; - audio->opened = 0; - mutex_unlock(&audio->lock); - return 0; -} - -static int fm_audio_open(struct inode *inode, struct file *file) -{ - struct audio *audio = &fm_audio; - int rc = 0; - - - if (audio->opened) - return -EPERM; - - /* Allocate the decoder */ - audio->dec_id = SESSION_ID_FM; - - audio->running = 0; - audio->fm_source = 0; - audio->fm_dest = 0; - - audio->device_events = AUDDEV_EVT_DEV_RDY - |AUDDEV_EVT_DEV_RLS| - AUDDEV_EVT_STREAM_VOL_CHG; - - rc = auddev_register_evt_listner(audio->device_events, - AUDDEV_CLNT_DEC, - audio->dec_id, - fm_audio_listner, - (void *)audio); - - if (rc) { - pr_err("%s: failed to register listnet\n", __func__); - goto event_err; - } - - audio->opened = 1; - file->private_data = audio; - -event_err: - return rc; -} - -static const struct file_operations audio_fm_fops = { - .owner = THIS_MODULE, - .open = fm_audio_open, - .release = fm_audio_release, - .unlocked_ioctl = fm_audio_ioctl, -}; - -struct miscdevice audio_fm_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = "msm_fm", - .fops = &audio_fm_fops, -}; - -static int __init fm_audio_init(void) -{ - struct audio *audio = &fm_audio; - - mutex_init(&audio->lock); - return misc_register(&audio_fm_misc); -} - -device_initcall(fm_audio_init); - -MODULE_DESCRIPTION("MSM FM driver"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/msm_qdsp6_audio.h b/arch/arm/mach-msm/qdsp6v2/msm_qdsp6_audio.h deleted file mode 100644 index 3890816c3d862a0086750179e182d4eb5c834417..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/msm_qdsp6_audio.h +++ /dev/null @@ -1,52 +0,0 @@ -/* arch/arm/mach-msm/include/mach/msm_qdsp6_audio.h - * - * Copyright (C) 2009 Google, Inc. - * Author: Brian Swetland - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _MACH_MSM_QDSP6_Q6AUDIO_ -#define _MACH_MSM_QDSP6_Q6AUDIO_ - -#define AUDIO_FLAG_READ 0 -#define AUDIO_FLAG_WRITE 1 -#define AUDIO_FLAG_INCALL_MIXED 2 - -struct audio_buffer { - dma_addr_t phys; - void *data; - uint32_t size; - uint32_t used; /* 1 = CPU is waiting for DSP to consume this buf */ - uint32_t actual_size; /* actual number of bytes read by DSP */ -}; - -struct audio_client { - struct audio_buffer buf[2]; - int cpu_buf; /* next buffer the CPU will touch */ - int dsp_buf; /* next buffer the DSP will touch */ - int running; - int session; - - int state; - - wait_queue_head_t wait; - wait_queue_head_t cmd_wait; - - struct dal_client *client; - - int cb_status; - uint32_t flags; - void *apr; - int ref_count; -}; - -#endif diff --git a/arch/arm/mach-msm/qdsp6v2/pcm_in.c b/arch/arm/mach-msm/qdsp6v2/pcm_in.c deleted file mode 100644 index cf7548d9347969fdddea65449424cbc989a2a454..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/pcm_in.c +++ /dev/null @@ -1,495 +0,0 @@ -/* - * Copyright (C) 2009 Google, Inc. - * Copyright (C) 2009 HTC Corporation - * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define MAX_BUF 4 -#define BUFSZ (480 * 8) -#define BUFFER_SIZE_MULTIPLE 4 -#define MIN_BUFFER_SIZE 160 - -#define VOC_REC_NONE 0xFF - -struct pcm { - struct mutex lock; - struct mutex read_lock; - wait_queue_head_t wait; - spinlock_t dsp_lock; - struct audio_client *ac; - uint32_t sample_rate; - uint32_t channel_count; - uint32_t buffer_size; - uint32_t buffer_count; - uint32_t rec_mode; - uint32_t in_frame_info[MAX_BUF][2]; - atomic_t in_count; - atomic_t in_enabled; - atomic_t in_opened; - atomic_t in_stopped; - struct wake_lock wakelock; - struct pm_qos_request pm_qos_req; -}; - -static void pcm_in_get_dsp_buffers(struct pcm*, - uint32_t token, uint32_t *payload); - -void pcm_in_cb(uint32_t opcode, uint32_t token, - uint32_t *payload, void *priv) -{ - struct pcm *pcm = (struct pcm *) priv; - unsigned long flags; - - spin_lock_irqsave(&pcm->dsp_lock, flags); - switch (opcode) { - case ASM_DATA_EVENT_READ_DONE: - pcm_in_get_dsp_buffers(pcm, token, payload); - break; - case RESET_EVENTS: - reset_device(); - break; - default: - break; - } - spin_unlock_irqrestore(&pcm->dsp_lock, flags); -} -static void pcm_in_prevent_sleep(struct pcm *audio) -{ - pr_debug("%s:\n", __func__); - wake_lock(&audio->wakelock); - pm_qos_update_request(&audio->pm_qos_req, - msm_cpuidle_get_deep_idle_latency()); -} - -static void pcm_in_allow_sleep(struct pcm *audio) -{ - pr_debug("%s:\n", __func__); - pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); - wake_unlock(&audio->wakelock); -} - -static void pcm_in_get_dsp_buffers(struct pcm *pcm, - uint32_t token, uint32_t *payload) -{ - pcm->in_frame_info[token][0] = payload[7]; - pcm->in_frame_info[token][1] = payload[3]; - if (atomic_read(&pcm->in_count) <= pcm->buffer_count) - atomic_inc(&pcm->in_count); - wake_up(&pcm->wait); -} - -static int pcm_in_enable(struct pcm *pcm) -{ - if (atomic_read(&pcm->in_enabled)) - return 0; - return q6asm_run(pcm->ac, 0, 0, 0); -} - -static int pcm_in_disable(struct pcm *pcm) -{ - int rc = 0; - - if (atomic_read(&pcm->in_opened)) { - atomic_set(&pcm->in_enabled, 0); - atomic_set(&pcm->in_opened, 0); - rc = q6asm_cmd(pcm->ac, CMD_CLOSE); - - atomic_set(&pcm->in_stopped, 1); - memset(pcm->in_frame_info, 0, - sizeof(char) * pcm->buffer_count * 2); - wake_up(&pcm->wait); - } - return rc; -} - -static int config(struct pcm *pcm) -{ - int rc = 0; - - pr_debug("%s: pcm prefill, buffer_size = %d\n", __func__, - pcm->buffer_size); - rc = q6asm_audio_client_buf_alloc(OUT, pcm->ac, - pcm->buffer_size, pcm->buffer_count); - if (rc < 0) { - pr_err("Audio Start: Buffer Allocation failed \ - rc = %d\n", rc); - goto fail; - } - - rc = q6asm_enc_cfg_blk_pcm(pcm->ac, pcm->sample_rate, - pcm->channel_count); - if (rc < 0) { - pr_err("%s: cmd media format block failed", __func__); - goto fail; - } -fail: - return rc; -} - -static long pcm_in_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct pcm *pcm = file->private_data; - int rc = 0; - - mutex_lock(&pcm->lock); - switch (cmd) { - case AUDIO_SET_VOLUME: - break; - case AUDIO_GET_STATS: { - struct msm_audio_stats stats; - memset(&stats, 0, sizeof(stats)); - if (copy_to_user((void *) arg, &stats, sizeof(stats))) - rc = -EFAULT; - break; - } - case AUDIO_START: { - int cnt = 0; - if (atomic_read(&pcm->in_enabled)) { - pr_info("%s:AUDIO_START already over\n", __func__); - rc = 0; - break; - } - rc = config(pcm); - if (rc) { - pr_err("%s: IN Configuration failed\n", __func__); - rc = -EFAULT; - break; - } - - rc = pcm_in_enable(pcm); - if (rc) { - pr_err("%s: In Enable failed\n", __func__); - rc = -EFAULT; - break; - } - pcm_in_prevent_sleep(pcm); - atomic_set(&pcm->in_enabled, 1); - - while (cnt++ < pcm->buffer_count) - q6asm_read(pcm->ac); - pr_info("%s: AUDIO_START session id[%d]\n", __func__, - pcm->ac->session); - - if (pcm->rec_mode != VOC_REC_NONE) - msm_enable_incall_recording(pcm->ac->session, - pcm->rec_mode, pcm->sample_rate, pcm->channel_count); - - break; - } - case AUDIO_GET_SESSION_ID: { - if (copy_to_user((void *) arg, &pcm->ac->session, - sizeof(unsigned short))) - rc = -EFAULT; - break; - } - case AUDIO_STOP: - break; - case AUDIO_FLUSH: - break; - case AUDIO_SET_CONFIG: { - struct msm_audio_config config; - - if (copy_from_user(&config, (void *) arg, sizeof(config))) { - rc = -EFAULT; - break; - } - pr_debug("%s: SET_CONFIG: buffer_size:%d channel_count:%d" - "sample_rate:%d, buffer_count:%d\n", __func__, - config.buffer_size, config.channel_count, - config.sample_rate, config.buffer_count); - - if (!config.channel_count || config.channel_count > 2) { - rc = -EINVAL; - break; - } - - if (config.sample_rate < 8000 || config.sample_rate > 48000) { - rc = -EINVAL; - break; - } - - if ((config.buffer_size % (config.channel_count * - BUFFER_SIZE_MULTIPLE)) || - (config.buffer_size < MIN_BUFFER_SIZE)) { - pr_err("%s: Buffer Size should be multiple of " - "[4 * no. of channels] and greater than 160\n", - __func__); - rc = -EINVAL; - break; - } - - pcm->sample_rate = config.sample_rate; - pcm->channel_count = config.channel_count; - pcm->buffer_size = config.buffer_size; - pcm->buffer_count = config.buffer_count; - break; - } - case AUDIO_GET_CONFIG: { - struct msm_audio_config config; - memset(&config, 0, sizeof(config)); - config.buffer_size = pcm->buffer_size; - config.buffer_count = pcm->buffer_count; - config.sample_rate = pcm->sample_rate; - config.channel_count = pcm->channel_count; - config.unused[0] = 0; - config.unused[1] = 0; - config.unused[2] = 0; - if (copy_to_user((void *) arg, &config, sizeof(config))) - rc = -EFAULT; - break; - } - case AUDIO_ENABLE_AUDPRE: { - - uint16_t enable_mask; - - if (copy_from_user(&enable_mask, (void *) arg, - sizeof(enable_mask))) { - rc = -EFAULT; - break; - } - if (enable_mask & FLUENCE_ENABLE) - rc = auddev_cfg_tx_copp_topology(pcm->ac->session, - VPM_TX_DM_FLUENCE_COPP_TOPOLOGY); - else - rc = auddev_cfg_tx_copp_topology(pcm->ac->session, - DEFAULT_COPP_TOPOLOGY); - break; - } - - case AUDIO_SET_INCALL: { - if (copy_from_user(&pcm->rec_mode, - (void *) arg, - sizeof(pcm->rec_mode))) { - rc = -EFAULT; - pr_err("%s: Error copying in-call mode\n", __func__); - break; - } - - if (pcm->rec_mode != VOC_REC_UPLINK && - pcm->rec_mode != VOC_REC_DOWNLINK && - pcm->rec_mode != VOC_REC_BOTH) { - rc = -EINVAL; - pcm->rec_mode = VOC_REC_NONE; - - pr_err("%s: Invalid %d in-call rec_mode\n", - __func__, pcm->rec_mode); - break; - } - - pr_debug("%s: In-call rec_mode %d\n", __func__, pcm->rec_mode); - break; - } - - default: - rc = -EINVAL; - break; - } - mutex_unlock(&pcm->lock); - return rc; -} - -static int pcm_in_open(struct inode *inode, struct file *file) -{ - struct pcm *pcm; - int rc = 0; - char name[24]; - - pcm = kzalloc(sizeof(struct pcm), GFP_KERNEL); - if (!pcm) - return -ENOMEM; - - pcm->channel_count = 1; - pcm->sample_rate = 8000; - pcm->buffer_size = BUFSZ; - pcm->buffer_count = MAX_BUF; - - pcm->ac = q6asm_audio_client_alloc((app_cb)pcm_in_cb, (void *)pcm); - if (!pcm->ac) { - pr_err("%s: Could not allocate memory\n", __func__); - rc = -ENOMEM; - goto fail; - } - - mutex_init(&pcm->lock); - mutex_init(&pcm->read_lock); - spin_lock_init(&pcm->dsp_lock); - init_waitqueue_head(&pcm->wait); - - rc = q6asm_open_read(pcm->ac, FORMAT_LINEAR_PCM); - if (rc < 0) { - pr_err("%s: Cmd Open Failed\n", __func__); - goto fail; - } - - atomic_set(&pcm->in_stopped, 0); - atomic_set(&pcm->in_enabled, 0); - atomic_set(&pcm->in_count, 0); - atomic_set(&pcm->in_opened, 1); - snprintf(name, sizeof name, "pcm_in_%x", pcm->ac->session); - wake_lock_init(&pcm->wakelock, WAKE_LOCK_SUSPEND, name); - snprintf(name, sizeof name, "pcm_in_idle_%x", pcm->ac->session); - pm_qos_add_request(&pcm->pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); - - pcm->rec_mode = VOC_REC_NONE; - - file->private_data = pcm; - pr_info("%s: pcm in open session id[%d]\n", __func__, pcm->ac->session); - return 0; -fail: - if (pcm->ac) - q6asm_audio_client_free(pcm->ac); - kfree(pcm); - return rc; -} - -static ssize_t pcm_in_read(struct file *file, char __user *buf, - size_t count, loff_t *pos) -{ - struct pcm *pcm = file->private_data; - const char __user *start = buf; - void *data; - uint32_t offset = 0; - uint32_t size = 0; - uint32_t idx; - int rc = 0; - int len = 0; - - if (!atomic_read(&pcm->in_enabled)) - return -EFAULT; - mutex_lock(&pcm->read_lock); - while (count > 0) { - rc = wait_event_timeout(pcm->wait, - (atomic_read(&pcm->in_count) || - atomic_read(&pcm->in_stopped)), 5 * HZ); - if (!rc) { - pr_err("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - - if (atomic_read(&pcm->in_stopped) && - !atomic_read(&pcm->in_count)) { - mutex_unlock(&pcm->read_lock); - return 0; - } - - data = q6asm_is_cpu_buf_avail(OUT, pcm->ac, &size, &idx); - if (count >= size) - len = size; - else { - len = count; - pr_err("%s: short read data[%p]bytesavail[%d]" - "bytesrequest[%d]" - "bytesrejected%d]\n",\ - __func__, data, size, - count, (size - count)); - } - if ((len) && data) { - offset = pcm->in_frame_info[idx][1]; - if (copy_to_user(buf, data+offset, len)) { - pr_err("%s copy_to_user failed len[%d]\n", - __func__, len); - rc = -EFAULT; - goto fail; - } - count -= len; - buf += len; - } - atomic_dec(&pcm->in_count); - memset(&pcm->in_frame_info[idx], 0, - sizeof(uint32_t) * 2); - - rc = q6asm_read(pcm->ac); - if (rc < 0) { - pr_err("%s q6asm_read fail\n", __func__); - goto fail; - } - rmb(); - break; - } - rc = buf-start; -fail: - mutex_unlock(&pcm->read_lock); - return rc; -} - -static int pcm_in_release(struct inode *inode, struct file *file) -{ - int rc = 0; - struct pcm *pcm = file->private_data; - - pr_info("[%s:%s] release session id[%d]\n", __MM_FILE__, - __func__, pcm->ac->session); - mutex_lock(&pcm->lock); - - if ((pcm->rec_mode != VOC_REC_NONE) && atomic_read(&pcm->in_enabled)) { - msm_disable_incall_recording(pcm->ac->session, pcm->rec_mode); - - pcm->rec_mode = VOC_REC_NONE; - } - - /* remove this session from topology list */ - auddev_cfg_tx_copp_topology(pcm->ac->session, - DEFAULT_COPP_TOPOLOGY); - mutex_unlock(&pcm->lock); - - rc = pcm_in_disable(pcm); - msm_clear_session_id(pcm->ac->session); - q6asm_audio_client_free(pcm->ac); - pcm_in_allow_sleep(pcm); - wake_lock_destroy(&pcm->wakelock); - pm_qos_remove_request(&pcm->pm_qos_req); - kfree(pcm); - return rc; -} - -static const struct file_operations pcm_in_fops = { - .owner = THIS_MODULE, - .open = pcm_in_open, - .read = pcm_in_read, - .release = pcm_in_release, - .unlocked_ioctl = pcm_in_ioctl, -}; - -struct miscdevice pcm_in_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = "msm_pcm_in", - .fops = &pcm_in_fops, -}; - -static int __init pcm_in_init(void) -{ - return misc_register(&pcm_in_misc); -} - -device_initcall(pcm_in_init); diff --git a/arch/arm/mach-msm/qdsp6v2/pcm_in_proxy.c b/arch/arm/mach-msm/qdsp6v2/pcm_in_proxy.c deleted file mode 100644 index f7bf1ae9622f4e7227cc4b7ab847f361669fe1a5..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/pcm_in_proxy.c +++ /dev/null @@ -1,602 +0,0 @@ - -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define MAX_BUF 4 - -struct dma_buf { - uint32_t addr; - uint32_t v_addr; - uint32_t used; -}; -struct pcm { - struct mutex lock; - struct mutex read_lock; - wait_queue_head_t wait; - spinlock_t dsp_lock; - struct audio_client *ac; - uint32_t sample_rate; - uint32_t channel_count; - uint32_t buffer_size; - uint32_t buffer_count; - uint32_t cpu_idx; - uint32_t dsp_idx; - uint32_t start; - uint32_t dma_addr; - uint32_t dma_virt; - struct dma_buf dma_buf[MAX_BUF]; - atomic_t in_count; - atomic_t in_enabled; - atomic_t in_opened; - atomic_t in_stopped; - int poll_time; - struct hrtimer hrt; -}; - -static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt); - -static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt) -{ - struct pcm *pcm = - container_of(hrt, struct pcm, hrt); - int rc = 0; - if (pcm->start) { - if (pcm->dsp_idx == pcm->buffer_count) - pcm->dsp_idx = 0; - if (pcm->dma_buf[pcm->dsp_idx].used == 0) { - if (atomic_read(&pcm->in_stopped)) { - pr_err("%s: Driver closed - return\n", - __func__); - return HRTIMER_NORESTART; - } - rc = afe_rt_proxy_port_read( - pcm->dma_buf[pcm->dsp_idx].addr, - pcm->buffer_size); - if (rc < 0) { - pr_err("%s afe_rt_proxy_port_read fail\n", - __func__); - goto fail; - } - pcm->dma_buf[pcm->dsp_idx].used = 1; - pcm->dsp_idx++; - pr_debug("sending frame rec to DSP: poll_time: %d\n", - pcm->poll_time); - } else { - pr_err("Qcom: Used flag not reset retry after %d msec\n", - (pcm->poll_time/10)); - goto fail_timer; - } -fail: - hrtimer_forward_now(hrt, ns_to_ktime(pcm->poll_time - * 1000)); - return HRTIMER_RESTART; -fail_timer: - hrtimer_forward_now(hrt, ns_to_ktime((pcm->poll_time/10) - * 1000)); - - return HRTIMER_RESTART; - } else { - return HRTIMER_NORESTART; - } -} - -static void pcm_afe_callback(uint32_t opcode, - uint32_t token, uint32_t *payload, - void *priv) -{ - struct pcm *pcm = (struct pcm *)priv; - unsigned long dsp_flags; - uint16_t event; - - if (pcm == NULL) - return; - pr_debug("%s\n", __func__); - spin_lock_irqsave(&pcm->dsp_lock, dsp_flags); - switch (opcode) { - case AFE_EVENT_RT_PROXY_PORT_STATUS: { - event = (uint16_t)((0xFFFF0000 & payload[0]) >> 0x10); - switch (event) { - case AFE_EVENT_RTPORT_START: { - pcm->dsp_idx = 0; - pcm->cpu_idx = 0; - pcm->poll_time = (unsigned long) - (((pcm->buffer_size*1000)/ - (pcm->channel_count * - pcm->sample_rate * 2))*1000); - pr_debug("%s: poll_time:%d\n", __func__, - pcm->poll_time); - pcm->start = 1; - wake_up(&pcm->wait); - break; - } - case AFE_EVENT_RTPORT_STOP: - pr_debug("%s: event!=0\n", __func__); - pcm->start = 0; - atomic_set(&pcm->in_stopped, 1); - break; - case AFE_EVENT_RTPORT_LOW_WM: - pr_debug("%s: Underrun\n", __func__); - break; - case AFE_EVENT_RTPORT_HI_WM: - pr_debug("%s: Overrun\n", __func__); - break; - default: - break; - } - break; - } - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case AFE_SERVICE_CMD_RTPORT_RD: - pr_debug("%s: Read done\n", __func__); - atomic_inc(&pcm->in_count); - wake_up(&pcm->wait); - break; - default: - break; - } - break; - } - default: - break; - } - spin_unlock_irqrestore(&pcm->dsp_lock, dsp_flags); -} - -static uint32_t getbuffersize(uint32_t samplerate) -{ - if (samplerate == 8000) - return 480*8; - else if (samplerate == 16000) - return 480*16; - else if (samplerate == 48000) - return 480*48; - return 0; -} - -static int pcm_in_open(struct inode *inode, struct file *file) -{ - struct pcm *pcm; - int rc = 0; - - pr_debug("%s: pcm proxy in open session\n", __func__); - pcm = kzalloc(sizeof(struct pcm), GFP_KERNEL); - if (!pcm) - return -ENOMEM; - - pcm->channel_count = 1; - pcm->sample_rate = 8000; - pcm->buffer_size = getbuffersize(pcm->sample_rate); - pcm->buffer_count = MAX_BUF; - - pcm->ac = q6asm_audio_client_alloc(NULL, (void *)pcm); - if (!pcm->ac) { - pr_err("%s: Could not allocate memory\n", __func__); - rc = -ENOMEM; - goto fail; - } - - mutex_init(&pcm->lock); - mutex_init(&pcm->read_lock); - spin_lock_init(&pcm->dsp_lock); - init_waitqueue_head(&pcm->wait); - - hrtimer_init(&pcm->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - pcm->hrt.function = afe_hrtimer_callback; - - atomic_set(&pcm->in_stopped, 0); - atomic_set(&pcm->in_enabled, 0); - atomic_set(&pcm->in_count, 0); - atomic_set(&pcm->in_opened, 1); - - file->private_data = pcm; - pr_debug("%s: pcm proxy open success session id:%d\n", - __func__, pcm->ac->session); - return 0; -fail: - if (pcm->ac) - q6asm_audio_client_free(pcm->ac); - kfree(pcm); - return rc; -} - -static int pcm_in_disable(struct pcm *pcm) -{ - int rc = 0; - - if (atomic_read(&pcm->in_opened)) { - atomic_set(&pcm->in_enabled, 0); - atomic_set(&pcm->in_opened, 0); - atomic_set(&pcm->in_stopped, 1); - wake_up(&pcm->wait); - } - return rc; -} - -static int config(struct pcm *pcm) -{ - - int ret = 0, i; - struct audio_buffer *buf; - - pr_debug("%s\n", __func__); - - ret = q6asm_audio_client_buf_alloc_contiguous(OUT, - pcm->ac, - pcm->buffer_size, - pcm->buffer_count); - if (ret < 0) { - pr_err("%s: Audio Start: Buffer Allocation failed rc = %d\n", - __func__, ret); - return -ENOMEM; - } - buf = pcm->ac->port[OUT].buf; - - if (buf == NULL || buf[0].data == NULL) - return -ENOMEM; - - memset(buf[0].data, 0, pcm->buffer_size * pcm->buffer_count); - pcm->dma_addr = (u32) buf[0].phys; - pcm->dma_virt = (u32) buf[0].data; - - for (i = 0; i < pcm->buffer_count; i++) { - pcm->dma_buf[i].addr = (u32) (buf[i].phys); - pcm->dma_buf[i].v_addr = (u32) (buf[i].data); - pcm->dma_buf[i].used = 0; - } - - ret = afe_register_get_events(RT_PROXY_DAI_001_TX, - pcm_afe_callback, pcm); - if (ret < 0) { - pr_err("%s: afe-pcm:register for events failed\n", __func__); - return ret; - } - ret = afe_cmd_memory_map(pcm->dma_addr, - pcm->buffer_size * pcm->buffer_count); - if (ret < 0) { - pr_err("%s: fail to map memory to DSP\n", __func__); - return ret; - } - - pr_debug("%s:success\n", __func__); - return ret; -} -static bool is_dma_buf_avail(struct pcm *pcm) -{ - return (pcm->dma_buf[pcm->cpu_idx].used == 1); -} -static ssize_t pcm_in_read(struct file *file, char __user *buf, - size_t count, loff_t *pos) -{ - struct pcm *pcm = file->private_data; - const char __user *start = buf; - int rc = 0; - bool rc1 = false; - int len = 0; - - if (!atomic_read(&pcm->in_enabled)) - return -EFAULT; - mutex_lock(&pcm->read_lock); - while (count > 0) { - rc = wait_event_timeout(pcm->wait, - (atomic_read(&pcm->in_count) || - atomic_read(&pcm->in_stopped)), 2 * HZ); - if (!rc) { - pr_err("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - if (atomic_read(&pcm->in_stopped) && - !atomic_read(&pcm->in_count)) { - pr_err("%s: count:%d/stopped:%d failed\n", __func__, - atomic_read(&pcm->in_count), - atomic_read(&pcm->in_stopped)); - mutex_unlock(&pcm->read_lock); - return 0; - } - - rc1 = is_dma_buf_avail(pcm); - if (!rc1) { - pr_err("%s: DMA buf not ready-returning from read\n", - __func__); - goto fail; - } - if (count >= pcm->buffer_size) - len = pcm->buffer_size; - else { - len = count; - pr_err("%s: short bytesavail[%d]"\ - "bytesrequest[%d]"\ - "bytesrejected%d]\n",\ - __func__, pcm->buffer_size, - count, (pcm->buffer_size - count)); - } - if (len) { - if (copy_to_user(buf, - (char *)(pcm->dma_buf[pcm->cpu_idx].v_addr), - len)) { - pr_err("%s copy_to_user failed len[%d]\n", - __func__, len); - rc = -EFAULT; - goto fail; - } - count -= len; - buf += len; - } - atomic_dec(&pcm->in_count); - memset((char *)(pcm->dma_buf[pcm->cpu_idx].v_addr), - 0, pcm->buffer_size); - pcm->dma_buf[pcm->cpu_idx].used = 0; - wake_up(&pcm->wait); - pcm->cpu_idx++; - if (pcm->cpu_idx == pcm->buffer_count) - pcm->cpu_idx = 0; - - } - rc = buf-start; - pr_debug("%s: pcm_in_read:rc:%d\n", __func__, rc); - -fail: - mutex_unlock(&pcm->read_lock); - return rc; -} - -static int afe_start(struct pcm *pcm) -{ - union afe_port_config port_config; - port_config.rtproxy.num_ch = - pcm->channel_count; - - pr_debug("%s: channel %d entered,port: %d,rate: %d\n", __func__, - port_config.rtproxy.num_ch, RT_PROXY_DAI_001_TX, pcm->sample_rate); - - port_config.rtproxy.bitwidth = 16; /* Q6 only supports 16 */ - port_config.rtproxy.interleaved = 1; - port_config.rtproxy.frame_sz = pcm->buffer_size; - port_config.rtproxy.jitter = - port_config.rtproxy.frame_sz/2; - port_config.rtproxy.lw_mark = 0; - port_config.rtproxy.hw_mark = 0; - port_config.rtproxy.rsvd = 0; - afe_open(RT_PROXY_DAI_001_TX, &port_config, pcm->sample_rate); - return 0; - -} - -static long pcm_in_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct pcm *pcm = file->private_data; - int rc = 0; - - mutex_lock(&pcm->lock); - switch (cmd) { - case AUDIO_START: { - pr_debug("%s: AUDIO_START\n", __func__); - if (atomic_read(&pcm->in_enabled)) { - pr_info("%s:AUDIO_START already over\n", __func__); - rc = 0; - break; - } - rc = config(pcm); - if (rc) { - pr_err("%s: IN Configuration failed\n", __func__); - rc = -EFAULT; - break; - } - pr_debug("%s: call config done\n", __func__); - atomic_set(&pcm->in_enabled, 1); - afe_start(pcm); - rc = wait_event_timeout(pcm->wait, - ((pcm->start == 1) || - atomic_read(&pcm->in_stopped)), 5 * HZ); - if (!rc) { - pr_err("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - pr_debug("%s: afe start done\n", __func__); - if (atomic_read(&pcm->in_stopped)) { - pr_err("%s: stopped unexpected before start!!\n", - __func__); - mutex_unlock(&pcm->lock); - return 0; - } - - hrtimer_start(&pcm->hrt, ns_to_ktime(0), - HRTIMER_MODE_REL); - break; - } - case AUDIO_STOP: - break; - case AUDIO_FLUSH: - break; - case AUDIO_SET_CONFIG: { - struct msm_audio_config config; - - if (copy_from_user(&config, (void *) arg, sizeof(config))) { - rc = -EFAULT; - break; - } - pr_debug("%s: SET_CONFIG: channel_count:%d"\ - "sample_rate:%d\n", __func__, - config.channel_count, - config.sample_rate); - - if (!config.channel_count || config.channel_count > 2) { - pr_err("%s: Channels(%d) not supported\n", - __func__, config.channel_count); - rc = -EINVAL; - break; - } - - if (config.sample_rate != 8000 && - config.sample_rate != 16000 && - config.sample_rate != 48000) { - pr_err("%s: Sample rate(%d) not supported\n", - __func__, config.sample_rate); - rc = -EINVAL; - break; - } - - pcm->sample_rate = config.sample_rate; - pcm->channel_count = config.channel_count; - pcm->buffer_size = getbuffersize(pcm->sample_rate); - - pr_debug("%s: Calculated buff size %d", __func__, - pcm->buffer_size); - break; - } - case AUDIO_GET_CONFIG: { - struct msm_audio_config config; - memset(&config, 0, sizeof(config)); - config.buffer_size = pcm->buffer_size; - config.buffer_count = pcm->buffer_count; - config.sample_rate = pcm->sample_rate; - config.channel_count = pcm->channel_count; - config.unused[0] = 0; - config.unused[1] = 0; - config.unused[2] = 0; - if (copy_to_user((void *) arg, &config, sizeof(config))) - rc = -EFAULT; - break; - } - case AUDIO_PAUSE: - pr_debug("%s: AUDIO_PAUSE %ld\n", __func__, arg); - if (arg == 1) { - pcm->start = 0; - } else if (arg == 0) { - pcm->start = 1; - hrtimer_start(&pcm->hrt, ns_to_ktime(0), - HRTIMER_MODE_REL); - } - break; - - default: - rc = -EINVAL; - break; - } -fail: - mutex_unlock(&pcm->lock); - return rc; -} - -static int pcm_in_release(struct inode *inode, struct file *file) -{ - int rc = 0; - struct pcm *pcm = file->private_data; - - pr_debug("[%s:%s] release session id[%d]\n", __MM_FILE__, - __func__, pcm->ac->session); - mutex_lock(&pcm->lock); - - - /* remove this session from topology list */ - auddev_cfg_tx_copp_topology(pcm->ac->session, - DEFAULT_COPP_TOPOLOGY); - - rc = pcm_in_disable(pcm); - hrtimer_cancel(&pcm->hrt); - rc = afe_cmd_memory_unmap(pcm->dma_addr); - if (rc < 0) - pr_err("%s: AFE memory unmap failed\n", __func__); - rc = afe_unregister_get_events(RT_PROXY_DAI_001_TX); - if (rc < 0) - pr_err("%s: AFE unregister for events failed\n", __func__); - - afe_close(RT_PROXY_DAI_001_TX); - pr_debug("%s: release all buffer\n", __func__); - q6asm_audio_client_buf_free_contiguous(OUT, - pcm->ac); - msm_clear_session_id(pcm->ac->session); - q6asm_audio_client_free(pcm->ac); - mutex_unlock(&pcm->lock); - mutex_destroy(&pcm->lock); - mutex_destroy(&pcm->read_lock); - kfree(pcm); - return rc; -} - -static const struct file_operations pcm_in_proxy_fops = { - .owner = THIS_MODULE, - .open = pcm_in_open, - .read = pcm_in_read, - .release = pcm_in_release, - .unlocked_ioctl = pcm_in_ioctl, -}; - -struct miscdevice pcm_in_proxy_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = "msm_pcm_in_proxy", - .fops = &pcm_in_proxy_fops, -}; - -static int snddev_rtproxy_open(struct msm_snddev_info *dev_info) -{ - return 0; -} - -static int snddev_rtproxy_close(struct msm_snddev_info *dev_info) -{ - return 0; -} - -static int snddev_rtproxy_set_freq(struct msm_snddev_info *dev_info, - u32 req_freq) -{ - return 48000; -} - -static int __init pcm_in_proxy_init(void) -{ - struct msm_snddev_info *dev_info; - - dev_info = kzalloc(sizeof(struct msm_snddev_info), GFP_KERNEL); - if (!dev_info) { - pr_err("unable to allocate memeory for msm_snddev_info\n"); - return -ENOMEM; - } - dev_info->name = "rtproxy_rx"; - dev_info->copp_id = RT_PROXY_PORT_001_RX; - dev_info->acdb_id = 0; - dev_info->private_data = NULL; - dev_info->dev_ops.open = snddev_rtproxy_open; - dev_info->dev_ops.close = snddev_rtproxy_close; - dev_info->dev_ops.set_freq = snddev_rtproxy_set_freq; - dev_info->capability = SNDDEV_CAP_RX; - dev_info->opened = 0; - msm_snddev_register(dev_info); - dev_info->sample_rate = 48000; - - pr_debug("%s: init done for proxy\n", __func__); - - return misc_register(&pcm_in_proxy_misc); -} - -device_initcall(pcm_in_proxy_init); diff --git a/arch/arm/mach-msm/qdsp6v2/pcm_out.c b/arch/arm/mach-msm/qdsp6v2/pcm_out.c deleted file mode 100644 index c6ae427aa6098a4ab26302c39a06018cb1ca577c..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/pcm_out.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright (C) 2009 Google, Inc. - * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. - * Author: Brian Swetland - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_BUF 2 -#define BUFSZ (4800) - -struct pcm { - struct mutex lock; - struct mutex write_lock; - spinlock_t dsp_lock; - wait_queue_head_t write_wait; - struct audio_client *ac; - uint32_t sample_rate; - uint32_t channel_count; - uint32_t buffer_size; - uint32_t buffer_count; - uint32_t rec_mode; - uint32_t stream_event; - uint32_t volume; - atomic_t out_count; - atomic_t out_enabled; - atomic_t out_opened; - atomic_t out_stopped; - atomic_t out_prefill; - struct wake_lock wakelock; -}; - -void pcm_out_cb(uint32_t opcode, uint32_t token, - uint32_t *payload, void *priv) -{ - struct pcm *pcm = (struct pcm *) priv; - unsigned long flags; - - spin_lock_irqsave(&pcm->dsp_lock, flags); - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: - atomic_inc(&pcm->out_count); - wake_up(&pcm->write_wait); - break; - case RESET_EVENTS: - reset_device(); - break; - default: - break; - } - spin_unlock_irqrestore(&pcm->dsp_lock, flags); -} - -static void audio_prevent_sleep(struct pcm *audio) -{ - pr_debug("%s:\n", __func__); - wake_lock(&audio->wakelock); -} - -static void audio_allow_sleep(struct pcm *audio) -{ - pr_debug("%s:\n", __func__); - wake_unlock(&audio->wakelock); -} - -static int pcm_out_enable(struct pcm *pcm) -{ - if (atomic_read(&pcm->out_enabled)) - return 0; - return q6asm_run(pcm->ac, 0, 0, 0); -} - -static int pcm_out_disable(struct pcm *pcm) -{ - int rc = 0; - - if (atomic_read(&pcm->out_opened)) { - atomic_set(&pcm->out_enabled, 0); - atomic_set(&pcm->out_opened, 0); - rc = q6asm_cmd(pcm->ac, CMD_CLOSE); - - atomic_set(&pcm->out_stopped, 1); - wake_up(&pcm->write_wait); - } - return rc; -} - -static int config(struct pcm *pcm) -{ - int rc = 0; - if (!atomic_read(&pcm->out_prefill)) { - pr_debug("%s: pcm prefill\n", __func__); - rc = q6asm_audio_client_buf_alloc(IN, pcm->ac, - pcm->buffer_size, pcm->buffer_count); - if (rc < 0) { - pr_err("Audio Start: Buffer Allocation failed \ - rc = %d\n", rc); - goto fail; - } - - rc = q6asm_media_format_block_pcm(pcm->ac, pcm->sample_rate, - pcm->channel_count); - if (rc < 0) - pr_err("%s: CMD Format block failed\n", __func__); - - atomic_set(&pcm->out_prefill, 1); - atomic_set(&pcm->out_count, pcm->buffer_count); - } -fail: - return rc; -} - -static void pcm_event_listner(u32 evt_id, union auddev_evt_data *evt_payload, - void *private_data) -{ - struct pcm *pcm = (struct pcm *) private_data; - int rc = 0; - - switch (evt_id) { - case AUDDEV_EVT_STREAM_VOL_CHG: - pcm->volume = evt_payload->session_vol; - pr_debug("%s: AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d, " - "enabled = %d\n", __func__, pcm->volume, - atomic_read(&pcm->out_enabled)); - if (atomic_read(&pcm->out_enabled)) { - if (pcm->ac) { - rc = q6asm_set_volume(pcm->ac, pcm->volume); - if (rc < 0) - pr_err("%s: Send Volume command" - "failed rc=%d\n", __func__, rc); - } - } - break; - default: - pr_err("%s:ERROR:wrong event\n", __func__); - break; - } -} - -static long pcm_out_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct pcm *pcm = file->private_data; - int rc = 0; - - if (cmd == AUDIO_GET_STATS) { - struct msm_audio_stats stats; - memset(&stats, 0, sizeof(stats)); - if (copy_to_user((void *) arg, &stats, sizeof(stats))) - return -EFAULT; - return 0; - } - - mutex_lock(&pcm->lock); - switch (cmd) { - case AUDIO_SET_VOLUME: { - int vol; - if (copy_from_user(&vol, (void *) arg, sizeof(vol))) { - rc = -EFAULT; - break; - } - break; - } - case AUDIO_START: { - pr_info("%s: AUDIO_START\n", __func__); - rc = config(pcm); - if (rc) { - pr_err("%s: Out Configuration failed\n", __func__); - rc = -EFAULT; - break; - } - - rc = pcm_out_enable(pcm); - if (rc) { - pr_err("Out enable failed\n"); - rc = -EFAULT; - break; - } - audio_prevent_sleep(pcm); - atomic_set(&pcm->out_enabled, 1); - - rc = q6asm_set_volume(pcm->ac, pcm->volume); - if (rc < 0) - pr_err("%s: Send Volume command failed rc=%d\n", - __func__, rc); - rc = q6asm_set_lrgain(pcm->ac, 0x2000, 0x2000); - if (rc < 0) - pr_err("%s: Send channel gain failed rc=%d\n", - __func__, rc); - /* disable mute by default */ - rc = q6asm_set_mute(pcm->ac, 0); - if (rc < 0) - pr_err("%s: Send mute command failed rc=%d\n", - __func__, rc); - break; - } - case AUDIO_GET_SESSION_ID: { - if (copy_to_user((void *) arg, &pcm->ac->session, - sizeof(unsigned short))) - rc = -EFAULT; - break; - } - case AUDIO_STOP: - break; - case AUDIO_FLUSH: - break; - case AUDIO_SET_CONFIG: { - struct msm_audio_config config; - pr_debug("%s: AUDIO_SET_CONFIG\n", __func__); - if (copy_from_user(&config, (void *) arg, sizeof(config))) { - rc = -EFAULT; - break; - } - if (config.channel_count < 1 || config.channel_count > 2) { - rc = -EINVAL; - break; - } - if (config.sample_rate < 8000 || config.sample_rate > 48000) { - rc = -EINVAL; - break; - } - if (config.buffer_size < 128) { - rc = -EINVAL; - break; - } - pcm->sample_rate = config.sample_rate; - pcm->channel_count = config.channel_count; - pcm->buffer_size = config.buffer_size; - pcm->buffer_count = config.buffer_count; - pr_debug("%s:buffer_size:%d buffer_count:%d sample_rate:%d \ - channel_count:%d\n", __func__, pcm->buffer_size, - pcm->buffer_count, pcm->sample_rate, - pcm->channel_count); - break; - } - case AUDIO_GET_CONFIG: { - struct msm_audio_config config; - pr_debug("%s: AUDIO_GET_CONFIG\n", __func__); - memset(&config, 0, sizeof(config)); - config.buffer_size = pcm->buffer_size; - config.buffer_count = pcm->buffer_count; - config.sample_rate = pcm->sample_rate; - config.channel_count = pcm->channel_count; - config.unused[0] = 0; - config.unused[1] = 0; - config.unused[2] = 0; - if (copy_to_user((void *) arg, &config, sizeof(config))) - rc = -EFAULT; - break; - } - case AUDIO_SET_EQ: { - struct msm_audio_eq_stream_config eq_config; - if (copy_from_user(&eq_config, (void *) arg, - sizeof(eq_config))) { - rc = -EFAULT; - break; - } - rc = q6asm_equalizer(pcm->ac, (void *) &eq_config); - if (rc < 0) - pr_err("%s: EQUALIZER FAILED\n", __func__); - break; - } - default: - rc = -EINVAL; - } - mutex_unlock(&pcm->lock); - return rc; -} - -static int pcm_out_open(struct inode *inode, struct file *file) -{ - struct pcm *pcm; - int rc = 0; - char name[24]; - - pr_info("[%s:%s] open\n", __MM_FILE__, __func__); - pcm = kzalloc(sizeof(struct pcm), GFP_KERNEL); - if (!pcm) { - pr_err("%s: Failed to allocated memory\n", __func__); - return -ENOMEM; - } - - pcm->channel_count = 2; - pcm->sample_rate = 44100; - pcm->buffer_size = BUFSZ; - pcm->buffer_count = MAX_BUF; - pcm->stream_event = AUDDEV_EVT_STREAM_VOL_CHG; - pcm->volume = 0x2000; - - pcm->ac = q6asm_audio_client_alloc((app_cb)pcm_out_cb, (void *)pcm); - if (!pcm->ac) { - pr_err("%s: Could not allocate memory\n", __func__); - rc = -ENOMEM; - goto fail; - } - - rc = q6asm_open_write(pcm->ac, FORMAT_LINEAR_PCM); - if (rc < 0) { - pr_err("%s: pcm out open failed for session %d\n", __func__, - pcm->ac->session); - rc = -EINVAL; - goto fail; - } - - mutex_init(&pcm->lock); - mutex_init(&pcm->write_lock); - init_waitqueue_head(&pcm->write_wait); - spin_lock_init(&pcm->dsp_lock); - atomic_set(&pcm->out_enabled, 0); - atomic_set(&pcm->out_stopped, 0); - atomic_set(&pcm->out_count, pcm->buffer_count); - atomic_set(&pcm->out_prefill, 0); - atomic_set(&pcm->out_opened, 1); - snprintf(name, sizeof name, "audio_pcm_%x", pcm->ac->session); - wake_lock_init(&pcm->wakelock, WAKE_LOCK_SUSPEND, name); - - rc = auddev_register_evt_listner(pcm->stream_event, - AUDDEV_CLNT_DEC, - pcm->ac->session, - pcm_event_listner, - (void *)pcm); - if (rc < 0) { - pr_err("%s: failed to register listner\n", __func__); - goto fail; - } - - file->private_data = pcm; - pr_info("[%s:%s] open session id[%d]\n", __MM_FILE__, - __func__, pcm->ac->session); - return 0; -fail: - if (pcm->ac) - q6asm_audio_client_free(pcm->ac); - kfree(pcm); - return rc; -} - -static ssize_t pcm_out_write(struct file *file, const char __user *buf, - size_t count, loff_t *pos) -{ - struct pcm *pcm = file->private_data; - const char __user *start = buf; - int xfer; - char *bufptr; - uint32_t idx; - void *data; - int rc = 0; - uint32_t size; - - if (!pcm->ac) - return -ENODEV; - - if (!atomic_read(&pcm->out_enabled)) { - rc = config(pcm); - if (rc < 0) - return rc; - } - - mutex_lock(&pcm->write_lock); - while (count > 0) { - rc = wait_event_timeout(pcm->write_wait, - (atomic_read(&pcm->out_count) || - atomic_read(&pcm->out_stopped)), 1 * HZ); - if (!rc) { - pr_err("%s: wait_event_timeout failed for session %d\n", - __func__, pcm->ac->session); - goto fail; - } - - if (atomic_read(&pcm->out_stopped) && - !atomic_read(&pcm->out_count)) { - pr_info("%s: pcm stopped out_count 0\n", __func__); - mutex_unlock(&pcm->write_lock); - return 0; - } - - data = q6asm_is_cpu_buf_avail(IN, pcm->ac, &size, &idx); - bufptr = data; - if (bufptr) { - xfer = count; - if (xfer > BUFSZ) - xfer = BUFSZ; - - if (copy_from_user(bufptr, buf, xfer)) { - rc = -EFAULT; - goto fail; - } - buf += xfer; - count -= xfer; - rc = q6asm_write(pcm->ac, xfer, 0, 0, NO_TIMESTAMP); - wmb(); - if (rc < 0) { - rc = -EFAULT; - goto fail; - } - } - atomic_dec(&pcm->out_count); - } - - rc = buf - start; -fail: - mutex_unlock(&pcm->write_lock); - return rc; -} - -static int pcm_out_release(struct inode *inode, struct file *file) -{ - struct pcm *pcm = file->private_data; - - pr_info("[%s:%s] release session id[%d]\n", __MM_FILE__, - __func__, pcm->ac->session); - if (pcm->ac) - pcm_out_disable(pcm); - msm_clear_session_id(pcm->ac->session); - auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, pcm->ac->session); - q6asm_audio_client_free(pcm->ac); - audio_allow_sleep(pcm); - wake_lock_destroy(&pcm->wakelock); - mutex_destroy(&pcm->lock); - mutex_destroy(&pcm->write_lock); - kfree(pcm); - return 0; -} - -static const struct file_operations pcm_out_fops = { - .owner = THIS_MODULE, - .open = pcm_out_open, - .write = pcm_out_write, - .release = pcm_out_release, - .unlocked_ioctl = pcm_out_ioctl, -}; - -struct miscdevice pcm_out_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = "msm_pcm_out", - .fops = &pcm_out_fops, -}; - -static int __init pcm_out_init(void) -{ - return misc_register(&pcm_out_misc); -} - -device_initcall(pcm_out_init); diff --git a/arch/arm/mach-msm/qdsp6v2/q6voice.c b/arch/arm/mach-msm/qdsp6v2/q6voice.c deleted file mode 100644 index b0eeb52107b605f9adf1f4dbc5695a39e25997f3..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/q6voice.c +++ /dev/null @@ -1,2948 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - - -#define TIMEOUT_MS 3000 -#define SNDDEV_CAP_TTY 0x20 -#define CMD_STATUS_SUCCESS 0 -#define CMD_STATUS_FAIL 1 - -/* Voice session creates passive control sessions for MVM and CVS. */ -#define VOC_PATH_PASSIVE 0 - -/* VoIP session creates full control sessions for MVM and CVS. */ -#define VOC_PATH_FULL 1 - -#define ADSP_VERSION_CVD 0x60300000 - -#define BUFFER_PAYLOAD_SIZE 4000 - -#define VOC_REC_NONE 0xFF - -struct common_data common; - -static bool is_adsp_support_cvd(void) -{ - return (common.adsp_version >= ADSP_VERSION_CVD); -} -static int voice_send_enable_vocproc_cmd(struct voice_data *v); -static int voice_send_netid_timing_cmd(struct voice_data *v); - -static void *voice_get_apr_mvm(void) -{ - void *apr_mvm = NULL; - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) - apr_mvm = common.apr_mvm; - else - apr_mvm = common.apr_q6_mvm; - - pr_debug("%s: apr_mvm 0x%x\n", __func__, (unsigned int)apr_mvm); - - return apr_mvm; -} - -static void voice_set_apr_mvm(void *apr_mvm) -{ - pr_debug("%s: apr_mvm 0x%x\n", __func__, (unsigned int)apr_mvm); - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) - common.apr_mvm = apr_mvm; - else - common.apr_q6_mvm = apr_mvm; -} - -static void *voice_get_apr_cvs(void) -{ - void *apr_cvs = NULL; - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) - apr_cvs = common.apr_cvs; - else - apr_cvs = common.apr_q6_cvs; - - pr_debug("%s: apr_cvs 0x%x\n", __func__, (unsigned int)apr_cvs); - - return apr_cvs; -} - -static void voice_set_apr_cvs(void *apr_cvs) -{ - pr_debug("%s: apr_cvs 0x%x\n", __func__, (unsigned int)apr_cvs); - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) - common.apr_cvs = apr_cvs; - else - common.apr_q6_cvs = apr_cvs; - rtac_set_voice_handle(RTAC_CVS, apr_cvs); -} - -static void *voice_get_apr_cvp(void) -{ - void *apr_cvp = NULL; - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) - apr_cvp = common.apr_cvp; - else - apr_cvp = common.apr_q6_cvp; - - pr_debug("%s: apr_cvp 0x%x\n", __func__, (unsigned int)apr_cvp); - - return apr_cvp; -} - -static void voice_set_apr_cvp(void *apr_cvp) -{ - pr_debug("%s: apr_cvp 0x%x\n", __func__, (unsigned int)apr_cvp); - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) - common.apr_cvp = apr_cvp; - else - common.apr_q6_cvp = apr_cvp; - rtac_set_voice_handle(RTAC_CVP, apr_cvp); -} - -static u16 voice_get_mvm_handle(struct voice_data *v) -{ - pr_debug("%s: mvm_handle %d\n", __func__, v->mvm_handle); - - return v->mvm_handle; -} - -static void voice_set_mvm_handle(struct voice_data *v, u16 mvm_handle) -{ - pr_debug("%s: session 0x%x, mvm_handle %d\n", - __func__, (unsigned int)v, mvm_handle); - - v->mvm_handle = mvm_handle; -} - -static u16 voice_get_cvs_handle(struct voice_data *v) -{ - pr_debug("%s: cvs_handle %d\n", __func__, v->cvs_handle); - - return v->cvs_handle; -} - -static void voice_set_cvs_handle(struct voice_data *v, u16 cvs_handle) -{ - pr_debug("%s: session 0x%x, cvs_handle %d\n", - __func__, (unsigned int)v, cvs_handle); - - v->cvs_handle = cvs_handle; -} - -static u16 voice_get_cvp_handle(struct voice_data *v) -{ - pr_debug("%s: cvp_handle %d\n", __func__, v->cvp_handle); - - return v->cvp_handle; -} - -static void voice_set_cvp_handle(struct voice_data *v, u16 cvp_handle) -{ - pr_debug("%s: session 0x%x, cvp_handle %d\n", - __func__, (unsigned int)v, cvp_handle); - - v->cvp_handle = cvp_handle; -} - -u16 voice_get_session_id(const char *name) -{ - u16 session_id = 0; - - if (name != NULL) { - if (!strncmp(name, "Voice session", 13)) - session_id = common.voice[VOC_PATH_PASSIVE].session_id; - else - session_id = common.voice[VOC_PATH_FULL].session_id; - } - - pr_debug("%s: %s has session id 0x%x\n", __func__, name, session_id); - - return session_id; -} - -static struct voice_data *voice_get_session(u16 session_id) -{ - struct voice_data *v = NULL; - - if (session_id == 0) { - mutex_lock(&common.common_lock); - - pr_debug("%s: NULL id, voc_path is %d\n", - __func__, common.voc_path); - - if (common.voc_path == VOC_PATH_PASSIVE) - v = &common.voice[VOC_PATH_PASSIVE]; - else - v = &common.voice[VOC_PATH_FULL]; - - mutex_unlock(&common.common_lock); - } else if ((session_id >= SESSION_ID_BASE) && - (session_id < SESSION_ID_BASE + MAX_VOC_SESSIONS)) { - v = &common.voice[session_id - SESSION_ID_BASE]; - } else { - pr_err("%s: Invalid session_id 0x%x\n", __func__, session_id); - } - - pr_debug("%s: session_id 0x%x session handle 0x%x\n", - __func__, session_id, (unsigned int)v); - - return v; -} - -static bool is_voice_session(u16 session_id) -{ - return (session_id == common.voice[VOC_PATH_PASSIVE].session_id); -} - -static bool is_voip_session(u16 session_id) -{ - return (session_id == common.voice[VOC_PATH_FULL].session_id); -} - -static void voice_auddev_cb_function(u32 evt_id, - union auddev_evt_data *evt_payload, - void *private_data); - -static int32_t modem_mvm_callback(struct apr_client_data *data, void *priv); -static int32_t modem_cvs_callback(struct apr_client_data *data, void *priv); -static int32_t modem_cvp_callback(struct apr_client_data *data, void *priv); - -static int voice_apr_register(void) -{ - int rc = 0; - void *apr_mvm; - void *apr_cvs; - void *apr_cvp; - - if (common.adsp_version == 0) { - common.adsp_version = core_get_adsp_version(); - pr_info("adsp_ver fetched:%x\n", common.adsp_version); - } - - mutex_lock(&common.common_lock); - - apr_mvm = voice_get_apr_mvm(); - apr_cvs = voice_get_apr_cvs(); - apr_cvp = voice_get_apr_cvp(); - - - pr_debug("into voice_apr_register_callback\n"); - /* register callback to APR */ - if (apr_mvm == NULL) { - pr_debug("start to register MVM callback\n"); - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) { - apr_mvm = apr_register("MODEM", "MVM", - modem_mvm_callback, 0xFFFFFFFF, - &common); - } else { - apr_mvm = apr_register("ADSP", "MVM", - modem_mvm_callback, 0xFFFFFFFF, - &common); - } - - if (apr_mvm == NULL) { - pr_err("Unable to register MVM %d\n", - is_adsp_support_cvd()); - rc = -ENODEV; - goto done; - } - - voice_set_apr_mvm(apr_mvm); - } - - if (apr_cvs == NULL) { - pr_debug("start to register CVS callback\n"); - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) { - apr_cvs = apr_register("MODEM", "CVS", - modem_cvs_callback, 0xFFFFFFFF, - &common); - } else { - apr_cvs = apr_register("ADSP", "CVS", - modem_cvs_callback, 0xFFFFFFFF, - &common); - } - - if (apr_cvs == NULL) { - pr_err("Unable to register CVS %d\n", - is_adsp_support_cvd()); - rc = -ENODEV; - goto err; - } - - voice_set_apr_cvs(apr_cvs); - } - - if (apr_cvp == NULL) { - pr_debug("start to register CVP callback\n"); - - if (common.voc_path == VOC_PATH_PASSIVE && - !(is_adsp_support_cvd())) { - apr_cvp = apr_register("MODEM", "CVP", - modem_cvp_callback, 0xFFFFFFFF, - &common); - } else { - apr_cvp = apr_register("ADSP", "CVP", - modem_cvp_callback, 0xFFFFFFFF, - &common); - } - - if (apr_cvp == NULL) { - pr_err("Unable to register CVP %d\n", - is_adsp_support_cvd()); - rc = -ENODEV; - goto err1; - } - - voice_set_apr_cvp(apr_cvp); - } - - mutex_unlock(&common.common_lock); - - return 0; - -err1: - apr_deregister(apr_cvs); - apr_cvs = NULL; - voice_set_apr_cvs(apr_cvs); -err: - apr_deregister(apr_mvm); - apr_mvm = NULL; - voice_set_apr_mvm(apr_mvm); - -done: - mutex_unlock(&common.common_lock); - - return rc; -} - -static int voice_create_mvm_cvs_session(struct voice_data *v) -{ - int ret = 0; - struct mvm_create_ctl_session_cmd mvm_session_cmd; - struct cvs_create_passive_ctl_session_cmd cvs_session_cmd; - struct cvs_create_full_ctl_session_cmd cvs_full_ctl_cmd; - struct mvm_attach_stream_cmd attach_stream_cmd; - void *apr_mvm = voice_get_apr_mvm(); - void *apr_cvs = voice_get_apr_cvs(); - void *apr_cvp = voice_get_apr_cvp(); - u16 mvm_handle = voice_get_mvm_handle(v); - u16 cvs_handle = voice_get_cvs_handle(v); - u16 cvp_handle = voice_get_cvp_handle(v); - - pr_info("%s:\n", __func__); - - /* start to ping if modem service is up */ - pr_debug("in voice_create_mvm_cvs_session, mvm_hdl=%d, cvs_hdl=%d\n", - mvm_handle, cvs_handle); - /* send cmd to create mvm session and wait for response */ - - if (!mvm_handle) { - if (is_voice_session(v->session_id)) { - mvm_session_cmd.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_session_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_session_cmd) - APR_HDR_SIZE); - pr_debug("Send mvm create session pkt size = %d\n", - mvm_session_cmd.hdr.pkt_size); - mvm_session_cmd.hdr.src_port = v->session_id; - mvm_session_cmd.hdr.dest_port = 0; - mvm_session_cmd.hdr.token = 0; - pr_debug("%s: Creating MVM passive ctrl\n", __func__); - mvm_session_cmd.hdr.opcode = - VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION; - strncpy(mvm_session_cmd.mvm_session.name, - "default modem voice", SESSION_NAME_LEN); - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, - (uint32_t *) &mvm_session_cmd); - if (ret < 0) { - pr_err("Error sending MVM_CONTROL_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - } else { - mvm_session_cmd.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_session_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_session_cmd) - APR_HDR_SIZE); - pr_debug("Send mvm create session pkt size = %d\n", - mvm_session_cmd.hdr.pkt_size); - mvm_session_cmd.hdr.src_port = v->session_id; - mvm_session_cmd.hdr.dest_port = 0; - mvm_session_cmd.hdr.token = 0; - pr_debug("%s: Creating MVM full ctrl\n", __func__); - mvm_session_cmd.hdr.opcode = - VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION; - strncpy(mvm_session_cmd.mvm_session.name, - "default voip", SESSION_NAME_LEN); - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, - (uint32_t *) &mvm_session_cmd); - if (ret < 0) { - pr_err("Error sending MVM_FULL_CTL_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - } - - /* Get the created MVM handle. */ - mvm_handle = voice_get_mvm_handle(v); - } - - /* send cmd to create cvs session */ - if (!cvs_handle) { - if (is_voice_session(v->session_id)) { - pr_info("%s:creating CVS passive session\n", __func__); - - cvs_session_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_session_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_session_cmd) - APR_HDR_SIZE); - pr_info("send stream create session pkt size = %d\n", - cvs_session_cmd.hdr.pkt_size); - cvs_session_cmd.hdr.src_port = v->session_id; - cvs_session_cmd.hdr.dest_port = 0; - cvs_session_cmd.hdr.token = 0; - cvs_session_cmd.hdr.opcode = - VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION; - strncpy(cvs_session_cmd.cvs_session.name, - "default modem voice", SESSION_NAME_LEN); - - v->cvs_state = CMD_STATUS_FAIL; - - pr_info("%s: CVS create\n", __func__); - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_session_cmd); - if (ret < 0) { - pr_err("Fail in sending STREAM_CONTROL_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* Get the created CVS handle. */ - cvs_handle = voice_get_cvs_handle(v); - } else { - pr_info("%s:creating CVS full session\n", __func__); - - cvs_full_ctl_cmd.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - - cvs_full_ctl_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_full_ctl_cmd) - APR_HDR_SIZE); - - cvs_full_ctl_cmd.hdr.src_port = v->session_id; - cvs_full_ctl_cmd.hdr.dest_port = 0; - cvs_full_ctl_cmd.hdr.token = 0; - cvs_full_ctl_cmd.hdr.opcode = - VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION; - cvs_full_ctl_cmd.cvs_session.direction = 2; - - cvs_full_ctl_cmd.cvs_session.enc_media_type = - common.mvs_info.media_type; - cvs_full_ctl_cmd.cvs_session.dec_media_type = - common.mvs_info.media_type; - cvs_full_ctl_cmd.cvs_session.network_id = - common.mvs_info.network_type; - strncpy(cvs_full_ctl_cmd.cvs_session.name, - "default voip", SESSION_NAME_LEN); - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, - (uint32_t *) &cvs_full_ctl_cmd); - - if (ret < 0) { - pr_err("%s: Err %d sending CREATE_FULL_CTRL\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* Get the created CVS handle. */ - cvs_handle = voice_get_cvs_handle(v); - - /* Attach MVM to CVS. */ - pr_info("%s: Attach MVM to stream\n", __func__); - - attach_stream_cmd.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - - attach_stream_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(attach_stream_cmd) - APR_HDR_SIZE); - attach_stream_cmd.hdr.src_port = v->session_id; - attach_stream_cmd.hdr.dest_port = mvm_handle; - attach_stream_cmd.hdr.token = 0; - attach_stream_cmd.hdr.opcode = - VSS_IMVM_CMD_ATTACH_STREAM; - attach_stream_cmd.attach_stream.handle = cvs_handle; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, - (uint32_t *) &attach_stream_cmd); - if (ret < 0) { - pr_err("%s: Error %d sending ATTACH_STREAM\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - } - } - - return 0; - -fail: - apr_deregister(apr_mvm); - apr_mvm = NULL; - voice_set_apr_mvm(apr_mvm); - - apr_deregister(apr_cvs); - apr_cvs = NULL; - voice_set_apr_cvs(apr_cvs); - - apr_deregister(apr_cvp); - apr_cvp = NULL; - voice_set_apr_cvp(apr_cvp); - - cvp_handle = 0; - voice_set_cvp_handle(v, cvp_handle); - - cvs_handle = 0; - voice_set_cvs_handle(v, cvs_handle); - - return -EINVAL; -} - -static int voice_destroy_mvm_cvs_session(struct voice_data *v) -{ - int ret = 0; - struct mvm_detach_stream_cmd detach_stream; - struct apr_hdr mvm_destroy; - struct apr_hdr cvs_destroy; - void *apr_mvm = voice_get_apr_mvm(); - void *apr_cvs = voice_get_apr_cvs(); - u16 mvm_handle = voice_get_mvm_handle(v); - u16 cvs_handle = voice_get_cvs_handle(v); - - /* MVM, CVS sessions are destroyed only for Full control sessions. */ - if (is_voip_session(v->session_id)) { - pr_info("%s: MVM detach stream\n", __func__); - - /* Detach voice stream. */ - detach_stream.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - detach_stream.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(detach_stream) - APR_HDR_SIZE); - detach_stream.hdr.src_port = v->session_id; - detach_stream.hdr.dest_port = mvm_handle; - detach_stream.hdr.token = 0; - detach_stream.hdr.opcode = VSS_IMVM_CMD_DETACH_STREAM; - detach_stream.detach_stream.handle = cvs_handle; - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, (uint32_t *) &detach_stream); - if (ret < 0) { - pr_err("%s: Error %d sending DETACH_STREAM\n", - __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait event timeout\n", __func__); - goto fail; - } - - /* Destroy CVS. */ - pr_info("%s: CVS destroy session\n", __func__); - - cvs_destroy.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_destroy.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_destroy) - APR_HDR_SIZE); - cvs_destroy.src_port = v->session_id; - cvs_destroy.dest_port = cvs_handle; - cvs_destroy.token = 0; - cvs_destroy.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_destroy); - if (ret < 0) { - pr_err("%s: Error %d sending CVS DESTROY\n", - __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait event timeout\n", __func__); - - goto fail; - } - cvs_handle = 0; - voice_set_cvs_handle(v, cvs_handle); - - /* Destroy MVM. */ - pr_info("%s: MVM destroy session\n", __func__); - - mvm_destroy.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_destroy.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_destroy) - APR_HDR_SIZE); - mvm_destroy.src_port = v->session_id; - mvm_destroy.dest_port = mvm_handle; - mvm_destroy.token = 0; - mvm_destroy.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION; - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_destroy); - if (ret < 0) { - pr_err("%s: Error %d sending MVM DESTROY\n", - __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait event timeout\n", __func__); - - goto fail; - } - mvm_handle = 0; - voice_set_mvm_handle(v, mvm_handle); - } - -fail: - return 0; -} - -static int voice_send_tty_mode_to_modem(struct voice_data *v) -{ - struct msm_snddev_info *dev_tx_info; - struct msm_snddev_info *dev_rx_info; - int tty_mode = 0; - int ret = 0; - struct mvm_set_tty_mode_cmd mvm_tty_mode_cmd; - void *apr_mvm = voice_get_apr_mvm(); - u16 mvm_handle = voice_get_mvm_handle(v); - - dev_rx_info = audio_dev_ctrl_find_dev(v->dev_rx.dev_id); - if (IS_ERR(dev_rx_info)) { - pr_err("bad dev_id %d\n", v->dev_rx.dev_id); - goto done; - } - - dev_tx_info = audio_dev_ctrl_find_dev(v->dev_tx.dev_id); - if (IS_ERR(dev_tx_info)) { - pr_err("bad dev_id %d\n", v->dev_tx.dev_id); - goto done; - } - - if ((dev_rx_info->capability & SNDDEV_CAP_TTY) && - (dev_tx_info->capability & SNDDEV_CAP_TTY)) - tty_mode = 3; /* FULL */ - else if (!(dev_tx_info->capability & SNDDEV_CAP_TTY) && - (dev_rx_info->capability & SNDDEV_CAP_TTY)) - tty_mode = 2; /* VCO */ - else if ((dev_tx_info->capability & SNDDEV_CAP_TTY) && - !(dev_rx_info->capability & SNDDEV_CAP_TTY)) - tty_mode = 1; /* HCO */ - - if (tty_mode) { - /* send tty mode cmd to mvm */ - mvm_tty_mode_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_tty_mode_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_tty_mode_cmd) - APR_HDR_SIZE); - pr_debug("pkt size = %d\n", mvm_tty_mode_cmd.hdr.pkt_size); - mvm_tty_mode_cmd.hdr.src_port = v->session_id; - mvm_tty_mode_cmd.hdr.dest_port = mvm_handle; - mvm_tty_mode_cmd.hdr.token = 0; - mvm_tty_mode_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_TTY_MODE; - mvm_tty_mode_cmd.tty_mode.mode = tty_mode; - pr_info("tty mode =%d\n", mvm_tty_mode_cmd.tty_mode.mode); - - v->mvm_state = CMD_STATUS_FAIL; - pr_info("%s: MVM set tty\n", __func__); - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_tty_mode_cmd); - if (ret < 0) { - pr_err("Fail: sending VSS_ISTREAM_CMD_SET_TTY_MODE\n"); - goto done; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto done; - } - } - return 0; -done: - return -EINVAL; -} - -static int voice_send_cvs_cal_to_modem(struct voice_data *v) -{ - struct apr_hdr cvs_cal_cmd_hdr; - uint32_t *cmd_buf; - struct acdb_cal_data cal_data; - struct acdb_atomic_cal_block *cal_blk; - int32_t cal_size_per_network; - uint32_t *cal_data_per_network; - int index = 0; - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - - /* fill the header */ - cvs_cal_cmd_hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_cal_cmd_hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_cal_cmd_hdr) - APR_HDR_SIZE); - cvs_cal_cmd_hdr.src_port = v->session_id; - cvs_cal_cmd_hdr.dest_port = cvs_handle; - cvs_cal_cmd_hdr.token = 0; - cvs_cal_cmd_hdr.opcode = - VSS_ISTREAM_CMD_CACHE_CALIBRATION_DATA; - - pr_debug("voice_send_cvs_cal_to_modem\n"); - /* get the cvs cal data */ - get_vocstrm_cal(&cal_data); - if (cal_data.num_cal_blocks == 0) { - pr_err("%s: No calibration data to send!\n", __func__); - goto done; - } - - /* send cvs cal to modem */ - cmd_buf = kzalloc((sizeof(struct apr_hdr) + BUFFER_PAYLOAD_SIZE), - GFP_KERNEL); - if (!cmd_buf) { - pr_err("No memory is allocated.\n"); - return -ENOMEM; - } - pr_debug("----- num_cal_blocks=%d\n", (s32)cal_data.num_cal_blocks); - cal_blk = cal_data.cal_blocks; - pr_debug("cal_blk =%x\n", (uint32_t)cal_data.cal_blocks); - - for (; index < cal_data.num_cal_blocks; index++) { - cal_size_per_network = atomic_read(&cal_blk[index].cal_size); - pr_debug(" cal size =%d\n", cal_size_per_network); - if (cal_size_per_network >= BUFFER_PAYLOAD_SIZE) - pr_err("Cal size is too big\n"); - cal_data_per_network = - (u32 *)atomic_read(&cal_blk[index].cal_kvaddr); - pr_debug(" cal data=%x\n", (uint32_t)cal_data_per_network); - cvs_cal_cmd_hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - cal_size_per_network); - pr_debug("header size =%d, pkt_size =%d\n", - APR_HDR_SIZE, cvs_cal_cmd_hdr.pkt_size); - memcpy(cmd_buf, &cvs_cal_cmd_hdr, APR_HDR_SIZE); - memcpy(cmd_buf + (APR_HDR_SIZE / sizeof(uint32_t)), - cal_data_per_network, cal_size_per_network); - pr_debug("send cvs cal: index =%d\n", index); - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, cmd_buf); - if (ret < 0) { - pr_err("Fail: sending cvs cal, idx=%d\n", index); - continue; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - } - kfree(cmd_buf); -done: - return 0; -} - -static int voice_send_cvp_cal_to_modem(struct voice_data *v) -{ - struct apr_hdr cvp_cal_cmd_hdr; - uint32_t *cmd_buf; - struct acdb_cal_data cal_data; - struct acdb_atomic_cal_block *cal_blk; - int32_t cal_size_per_network; - uint32_t *cal_data_per_network; - int index = 0; - int ret = 0; - void *apr_cvp = voice_get_apr_cvp(); - u16 cvp_handle = voice_get_cvp_handle(v); - - - /* fill the header */ - cvp_cal_cmd_hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_cal_cmd_hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_cal_cmd_hdr) - APR_HDR_SIZE); - cvp_cal_cmd_hdr.src_port = v->session_id; - cvp_cal_cmd_hdr.dest_port = cvp_handle; - cvp_cal_cmd_hdr.token = 0; - cvp_cal_cmd_hdr.opcode = - VSS_IVOCPROC_CMD_CACHE_CALIBRATION_DATA; - - /* get cal data */ - get_vocproc_cal(&cal_data); - if (cal_data.num_cal_blocks == 0) { - pr_err("%s: No calibration data to send!\n", __func__); - goto done; - } - - /* send cal to modem */ - cmd_buf = kzalloc((sizeof(struct apr_hdr) + BUFFER_PAYLOAD_SIZE), - GFP_KERNEL); - if (!cmd_buf) { - pr_err("No memory is allocated.\n"); - return -ENOMEM; - } - pr_debug("----- num_cal_blocks=%d\n", (s32)cal_data.num_cal_blocks); - cal_blk = cal_data.cal_blocks; - pr_debug(" cal_blk =%x\n", (uint32_t)cal_data.cal_blocks); - - for (; index < cal_data.num_cal_blocks; index++) { - cal_size_per_network = atomic_read(&cal_blk[index].cal_size); - if (cal_size_per_network >= BUFFER_PAYLOAD_SIZE) - pr_err("Cal size is too big\n"); - pr_debug(" cal size =%d\n", cal_size_per_network); - cal_data_per_network = - (u32 *)atomic_read(&cal_blk[index].cal_kvaddr); - pr_debug(" cal data=%x\n", (uint32_t)cal_data_per_network); - - cvp_cal_cmd_hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - cal_size_per_network); - memcpy(cmd_buf, &cvp_cal_cmd_hdr, APR_HDR_SIZE); - memcpy(cmd_buf + (APR_HDR_SIZE / sizeof(*cmd_buf)), - cal_data_per_network, cal_size_per_network); - pr_debug("Send cvp cal\n"); - v->cvp_state = CMD_STATUS_FAIL; - pr_info("%s: CVP calib\n", __func__); - ret = apr_send_pkt(apr_cvp, cmd_buf); - if (ret < 0) { - pr_err("Fail: sending cvp cal, idx=%d\n", index); - continue; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - } - kfree(cmd_buf); -done: - return 0; -} - -static int voice_send_cvp_vol_tbl_to_modem(struct voice_data *v) -{ - struct apr_hdr cvp_vol_cal_cmd_hdr; - uint32_t *cmd_buf; - struct acdb_cal_data cal_data; - struct acdb_atomic_cal_block *cal_blk; - int32_t cal_size_per_network; - uint32_t *cal_data_per_network; - int index = 0; - int ret = 0; - void *apr_cvp = voice_get_apr_cvp(); - u16 cvp_handle = voice_get_cvp_handle(v); - - - /* fill the header */ - cvp_vol_cal_cmd_hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_vol_cal_cmd_hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_vol_cal_cmd_hdr) - APR_HDR_SIZE); - cvp_vol_cal_cmd_hdr.src_port = v->session_id; - cvp_vol_cal_cmd_hdr.dest_port = cvp_handle; - cvp_vol_cal_cmd_hdr.token = 0; - cvp_vol_cal_cmd_hdr.opcode = - VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE; - - /* get cal data */ - get_vocvol_cal(&cal_data); - if (cal_data.num_cal_blocks == 0) { - pr_err("%s: No calibration data to send!\n", __func__); - goto done; - } - - /* send cal to modem */ - cmd_buf = kzalloc((sizeof(struct apr_hdr) + BUFFER_PAYLOAD_SIZE), - GFP_KERNEL); - if (!cmd_buf) { - pr_err("No memory is allocated.\n"); - return -ENOMEM; - } - pr_debug("----- num_cal_blocks=%d\n", (s32)cal_data.num_cal_blocks); - cal_blk = cal_data.cal_blocks; - pr_debug("Cal_blk =%x\n", (uint32_t)cal_data.cal_blocks); - - for (; index < cal_data.num_cal_blocks; index++) { - cal_size_per_network = atomic_read(&cal_blk[index].cal_size); - cal_data_per_network = - (u32 *)atomic_read(&cal_blk[index].cal_kvaddr); - - pr_debug("Cal size =%d, index=%d\n", cal_size_per_network, - index); - pr_debug("Cal data=%x\n", (uint32_t)cal_data_per_network); - cvp_vol_cal_cmd_hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - cal_size_per_network); - memcpy(cmd_buf, &cvp_vol_cal_cmd_hdr, APR_HDR_SIZE); - memcpy(cmd_buf + (APR_HDR_SIZE / sizeof(uint32_t)), - cal_data_per_network, cal_size_per_network); - pr_debug("Send vol table\n"); - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, cmd_buf); - if (ret < 0) { - pr_err("Fail: sending cvp vol cal, idx=%d\n", index); - continue; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - } - kfree(cmd_buf); -done: - return 0; -} - -static int voice_set_dtx(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - - /* Set DTX */ - struct cvs_set_enc_dtx_mode_cmd cvs_set_dtx = { - .hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER), - .hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_dtx) - APR_HDR_SIZE), - .hdr.src_port = v->session_id, - .hdr.dest_port = cvs_handle, - .hdr.token = 0, - .hdr.opcode = VSS_ISTREAM_CMD_SET_ENC_DTX_MODE, - .dtx_mode.enable = common.mvs_info.dtx_mode, - }; - - pr_debug("%s: Setting DTX %d\n", __func__, common.mvs_info.dtx_mode); - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_dtx); - if (ret < 0) { - pr_err("%s: Error %d sending SET_DTX\n", __func__, ret); - - goto done; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - ret = -EINVAL; - } - -done: - return ret; -} - -static int voice_config_cvs_vocoder(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - - /* Set media type. */ - struct cvs_set_media_type_cmd cvs_set_media_cmd; - - pr_info("%s: Setting media type\n", __func__); - - cvs_set_media_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_media_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_media_cmd) - APR_HDR_SIZE); - cvs_set_media_cmd.hdr.src_port = v->session_id; - cvs_set_media_cmd.hdr.dest_port = cvs_handle; - cvs_set_media_cmd.hdr.token = 0; - cvs_set_media_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_MEDIA_TYPE; - cvs_set_media_cmd.media_type.tx_media_id = common.mvs_info.media_type; - cvs_set_media_cmd.media_type.rx_media_id = common.mvs_info.media_type; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_media_cmd); - if (ret < 0) { - pr_err("%s: Error %d sending SET_MEDIA_TYPE\n", - __func__, ret); - - goto done; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - ret = -EINVAL; - goto done; - } - - /* Set encoder properties. */ - switch (common.mvs_info.media_type) { - case VSS_MEDIA_ID_13K_MODEM: - case VSS_MEDIA_ID_4GV_NB_MODEM: - case VSS_MEDIA_ID_4GV_WB_MODEM: - case VSS_MEDIA_ID_EVRC_MODEM: { - struct cvs_set_cdma_enc_minmax_rate_cmd cvs_set_cdma_rate; - - pr_info("%s: Setting CDMA min-max rate\n", __func__); - - cvs_set_cdma_rate.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_cdma_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_cdma_rate) - APR_HDR_SIZE); - cvs_set_cdma_rate.hdr.src_port = v->session_id; - cvs_set_cdma_rate.hdr.dest_port = cvs_handle; - cvs_set_cdma_rate.hdr.token = 0; - cvs_set_cdma_rate.hdr.opcode = - VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE; - cvs_set_cdma_rate.cdma_rate.min_rate = - common.mvs_info.q_min_max_rate.min_rate; - cvs_set_cdma_rate.cdma_rate.max_rate = - common.mvs_info.q_min_max_rate.max_rate; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_cdma_rate); - if (ret < 0) { - pr_err("%s: Error %d sending CDMA_SET_ENC_MINMAX_RATE\n", - __func__, ret); - - goto done; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - ret = -EINVAL; - goto done; - } - - if ((common.mvs_info.media_type == VSS_MEDIA_ID_4GV_NB_MODEM) || - (common.mvs_info.media_type == VSS_MEDIA_ID_4GV_WB_MODEM)) - ret = voice_set_dtx(v); - - break; - } - - case VSS_MEDIA_ID_AMR_NB_MODEM: { - struct cvs_set_amr_enc_rate_cmd cvs_set_amr_rate; - - pr_info("%s: Setting AMR rate\n", __func__); - - cvs_set_amr_rate.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_amr_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_amr_rate) - APR_HDR_SIZE); - cvs_set_amr_rate.hdr.src_port = v->session_id; - cvs_set_amr_rate.hdr.dest_port = cvs_handle; - cvs_set_amr_rate.hdr.token = 0; - cvs_set_amr_rate.hdr.opcode = - VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE; - cvs_set_amr_rate.amr_rate.mode = common.mvs_info.rate; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_amr_rate); - if (ret < 0) { - pr_err("%s: Error %d sending SET_AMR_RATE\n", - __func__, ret); - - goto done; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - ret = -EINVAL; - goto done; - } - - ret = voice_set_dtx(v); - - break; - } - - case VSS_MEDIA_ID_AMR_WB_MODEM: { - struct cvs_set_amrwb_enc_rate_cmd cvs_set_amrwb_rate; - - pr_info("%s: Setting AMR WB rate\n", __func__); - - cvs_set_amrwb_rate.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_amrwb_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_amrwb_rate) - APR_HDR_SIZE); - cvs_set_amrwb_rate.hdr.src_port = v->session_id; - cvs_set_amrwb_rate.hdr.dest_port = cvs_handle; - cvs_set_amrwb_rate.hdr.token = 0; - cvs_set_amrwb_rate.hdr.opcode = - VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE; - cvs_set_amrwb_rate.amrwb_rate.mode = common.mvs_info.rate; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_amrwb_rate); - if (ret < 0) { - pr_err("%s: Error %d sending SET_AMRWB_RATE\n", - __func__, ret); - - goto done; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - ret = -EINVAL; - goto done; - } - - ret = voice_set_dtx(v); - - break; - } - - case VSS_MEDIA_ID_EFR_MODEM: - case VSS_MEDIA_ID_FR_MODEM: - case VSS_MEDIA_ID_HR_MODEM: - case VSS_MEDIA_ID_G729: - case VSS_MEDIA_ID_G711_ALAW: - case VSS_MEDIA_ID_G711_MULAW: { - ret = voice_set_dtx(v); - - break; - } - - default: { - /* Do nothing. */ - } - } - -done: - return ret; -} - -static int voice_send_start_voice_cmd(struct voice_data *v) -{ - struct apr_hdr mvm_start_voice_cmd; - int ret = 0; - void *apr_mvm = voice_get_apr_mvm(); - u16 mvm_handle = voice_get_mvm_handle(v); - - mvm_start_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_start_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_start_voice_cmd) - APR_HDR_SIZE); - pr_info("send mvm_start_voice_cmd pkt size = %d\n", - mvm_start_voice_cmd.pkt_size); - mvm_start_voice_cmd.src_port = v->session_id; - mvm_start_voice_cmd.dest_port = mvm_handle; - mvm_start_voice_cmd.token = 0; - mvm_start_voice_cmd.opcode = VSS_IMVM_CMD_START_VOICE; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_start_voice_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_START_VOICE\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_disable_vocproc(struct voice_data *v) -{ - struct apr_hdr cvp_disable_cmd; - int ret = 0; - void *apr_cvp = voice_get_apr_cvp(); - u16 cvp_handle = voice_get_cvp_handle(v); - - /* disable vocproc and wait for respose */ - cvp_disable_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_disable_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_disable_cmd) - APR_HDR_SIZE); - pr_debug("cvp_disable_cmd pkt size = %d, cvp_handle=%d\n", - cvp_disable_cmd.pkt_size, cvp_handle); - cvp_disable_cmd.src_port = v->session_id; - cvp_disable_cmd.dest_port = cvp_handle; - cvp_disable_cmd.token = 0; - cvp_disable_cmd.opcode = VSS_IVOCPROC_CMD_DISABLE; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_disable_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IVOCPROC_CMD_DISABLE\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - rtac_remove_voice(v->cvs_handle); - - return 0; -fail: - return -EINVAL; -} - -static int voice_set_device(struct voice_data *v) -{ - struct cvp_set_device_cmd cvp_setdev_cmd; - struct msm_snddev_info *dev_tx_info; - int ret = 0; - void *apr_cvp = voice_get_apr_cvp(); - u16 cvp_handle = voice_get_cvp_handle(v); - - - /* set device and wait for response */ - cvp_setdev_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_setdev_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_setdev_cmd) - APR_HDR_SIZE); - pr_debug(" send create cvp setdev, pkt size = %d\n", - cvp_setdev_cmd.hdr.pkt_size); - cvp_setdev_cmd.hdr.src_port = v->session_id; - cvp_setdev_cmd.hdr.dest_port = cvp_handle; - cvp_setdev_cmd.hdr.token = 0; - cvp_setdev_cmd.hdr.opcode = VSS_IVOCPROC_CMD_SET_DEVICE; - - dev_tx_info = audio_dev_ctrl_find_dev(v->dev_tx.dev_id); - if (IS_ERR(dev_tx_info)) { - pr_err("bad dev_id %d\n", v->dev_tx.dev_id); - goto fail; - } - - cvp_setdev_cmd.cvp_set_device.tx_topology_id = - get_voice_tx_topology(); - if (cvp_setdev_cmd.cvp_set_device.tx_topology_id == 0) { - if (dev_tx_info->channel_mode > 1) - cvp_setdev_cmd.cvp_set_device.tx_topology_id = - VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE; - else - cvp_setdev_cmd.cvp_set_device.tx_topology_id = - VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS; - } - - /* Use default topology if invalid value in ACDB */ - cvp_setdev_cmd.cvp_set_device.rx_topology_id = - get_voice_rx_topology(); - if (cvp_setdev_cmd.cvp_set_device.rx_topology_id == 0) - cvp_setdev_cmd.cvp_set_device.rx_topology_id = - VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT; - cvp_setdev_cmd.cvp_set_device.tx_port_id = v->dev_tx.dev_port_id; - cvp_setdev_cmd.cvp_set_device.rx_port_id = v->dev_rx.dev_port_id; - pr_info("topology=%d , tx_port_id=%d, rx_port_id=%d\n", - cvp_setdev_cmd.cvp_set_device.tx_topology_id, - cvp_setdev_cmd.cvp_set_device.tx_port_id, - cvp_setdev_cmd.cvp_set_device.rx_port_id); - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_setdev_cmd); - if (ret < 0) { - pr_err("Fail in sending VOCPROC_FULL_CONTROL_SESSION\n"); - goto fail; - } - pr_debug("wait for cvp create session event\n"); - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* send cvs cal */ - voice_send_cvs_cal_to_modem(v); - - /* send cvp cal */ - voice_send_cvp_cal_to_modem(v); - - /* send cvp vol table cal */ - voice_send_cvp_vol_tbl_to_modem(v); - - /* enable vocproc and wait for respose */ - voice_send_enable_vocproc_cmd(v); - - /* send tty mode if tty device is used */ - voice_send_tty_mode_to_modem(v); - - if (is_voip_session(v->session_id)) - voice_send_netid_timing_cmd(v); - - rtac_add_voice(v->cvs_handle, v->cvp_handle, - v->dev_rx.dev_port_id, v->dev_tx.dev_port_id, - v->session_id); - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_stop_voice_cmd(struct voice_data *v) -{ - struct apr_hdr mvm_stop_voice_cmd; - int ret = 0; - void *apr_mvm = voice_get_apr_mvm(); - u16 mvm_handle = voice_get_mvm_handle(v); - - mvm_stop_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_stop_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_stop_voice_cmd) - APR_HDR_SIZE); - pr_info("send mvm_stop_voice_cmd pkt size = %d\n", - mvm_stop_voice_cmd.pkt_size); - mvm_stop_voice_cmd.src_port = v->session_id; - mvm_stop_voice_cmd.dest_port = mvm_handle; - mvm_stop_voice_cmd.token = 0; - mvm_stop_voice_cmd.opcode = VSS_IMVM_CMD_STOP_VOICE; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_stop_voice_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_STOP_VOICE\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_setup_modem_voice(struct voice_data *v) -{ - struct cvp_create_full_ctl_session_cmd cvp_session_cmd; - int ret = 0; - struct msm_snddev_info *dev_tx_info; - void *apr_cvp = voice_get_apr_cvp(); - - /* create cvp session and wait for response */ - cvp_session_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_session_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_session_cmd) - APR_HDR_SIZE); - pr_info(" send create cvp session, pkt size = %d\n", - cvp_session_cmd.hdr.pkt_size); - cvp_session_cmd.hdr.src_port = v->session_id; - cvp_session_cmd.hdr.dest_port = 0; - cvp_session_cmd.hdr.token = 0; - cvp_session_cmd.hdr.opcode = - VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION; - - dev_tx_info = audio_dev_ctrl_find_dev(v->dev_tx.dev_id); - if (IS_ERR(dev_tx_info)) { - pr_err("bad dev_id %d\n", v->dev_tx.dev_id); - goto fail; - } - - /* Use default topology if invalid value in ACDB */ - cvp_session_cmd.cvp_session.tx_topology_id = - get_voice_tx_topology(); - if (cvp_session_cmd.cvp_session.tx_topology_id == 0) { - if (dev_tx_info->channel_mode > 1) - cvp_session_cmd.cvp_session.tx_topology_id = - VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE; - else - cvp_session_cmd.cvp_session.tx_topology_id = - VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS; - } - - cvp_session_cmd.cvp_session.rx_topology_id = - get_voice_rx_topology(); - if (cvp_session_cmd.cvp_session.rx_topology_id == 0) - cvp_session_cmd.cvp_session.rx_topology_id = - VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT; - - cvp_session_cmd.cvp_session.direction = 2; /*tx and rx*/ - cvp_session_cmd.cvp_session.network_id = VSS_NETWORK_ID_DEFAULT; - cvp_session_cmd.cvp_session.tx_port_id = v->dev_tx.dev_port_id; - cvp_session_cmd.cvp_session.rx_port_id = v->dev_rx.dev_port_id; - pr_info("topology=%d net_id=%d, dir=%d tx_port_id=%d, rx_port_id=%d\n", - cvp_session_cmd.cvp_session.tx_topology_id, - cvp_session_cmd.cvp_session.network_id, - cvp_session_cmd.cvp_session.direction, - cvp_session_cmd.cvp_session.tx_port_id, - cvp_session_cmd.cvp_session.rx_port_id); - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_session_cmd); - if (ret < 0) { - pr_err("Fail in sending VOCPROC_FULL_CONTROL_SESSION\n"); - goto fail; - } - pr_debug("wait for cvp create session event\n"); - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* send cvs cal */ - voice_send_cvs_cal_to_modem(v); - - /* send cvp cal */ - voice_send_cvp_cal_to_modem(v); - - /* send cvp vol table cal */ - voice_send_cvp_vol_tbl_to_modem(v); - - return 0; - -fail: - return -EINVAL; -} - -static int voice_send_enable_vocproc_cmd(struct voice_data *v) -{ - int ret = 0; - struct apr_hdr cvp_enable_cmd; - - u16 cvp_handle = voice_get_cvp_handle(v); - void *apr_cvp = voice_get_apr_cvp(); - - /* enable vocproc and wait for respose */ - cvp_enable_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_enable_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_enable_cmd) - APR_HDR_SIZE); - pr_debug("cvp_enable_cmd pkt size = %d, cvp_handle=%d\n", - cvp_enable_cmd.pkt_size, cvp_handle); - cvp_enable_cmd.src_port = v->session_id; - cvp_enable_cmd.dest_port = cvp_handle; - cvp_enable_cmd.token = 0; - cvp_enable_cmd.opcode = VSS_IVOCPROC_CMD_ENABLE; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_enable_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IVOCPROC_CMD_ENABLE\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_netid_timing_cmd(struct voice_data *v) -{ - int ret = 0; - void *apr_mvm = voice_get_apr_mvm(); - struct mvm_set_network_cmd mvm_set_network; - struct mvm_set_voice_timing_cmd mvm_set_voice_timing; - u16 mvm_handle = voice_get_mvm_handle(v); - - ret = voice_config_cvs_vocoder(v); - if (ret < 0) { - pr_err("%s: Error %d configuring CVS voc", - __func__, ret); - goto fail; - } - /* Set network ID. */ - pr_debug("%s: Setting network ID\n", __func__); - - mvm_set_network.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_set_network.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_set_network) - APR_HDR_SIZE); - mvm_set_network.hdr.src_port = v->session_id; - mvm_set_network.hdr.dest_port = mvm_handle; - mvm_set_network.hdr.token = 0; - mvm_set_network.hdr.opcode = VSS_ICOMMON_CMD_SET_NETWORK; - mvm_set_network.network.network_id = common.mvs_info.network_type; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_network); - if (ret < 0) { - pr_err("%s: Error %d sending SET_NETWORK\n", __func__, ret); - goto fail; - } - - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* Set voice timing. */ - pr_debug("%s: Setting voice timing\n", __func__); - - mvm_set_voice_timing.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_set_voice_timing.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_set_voice_timing) - APR_HDR_SIZE); - mvm_set_voice_timing.hdr.src_port = v->session_id; - mvm_set_voice_timing.hdr.dest_port = mvm_handle; - mvm_set_voice_timing.hdr.token = 0; - mvm_set_voice_timing.hdr.opcode = - VSS_ICOMMON_CMD_SET_VOICE_TIMING; - mvm_set_voice_timing.timing.mode = 0; - mvm_set_voice_timing.timing.enc_offset = 8000; - mvm_set_voice_timing.timing.dec_req_offset = 3300; - mvm_set_voice_timing.timing.dec_offset = 8300; - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_voice_timing); - if (ret < 0) { - pr_err("%s: Error %d sending SET_TIMING\n", __func__, ret); - goto fail; - } - - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_attach_vocproc(struct voice_data *v) -{ - int ret = 0; - struct mvm_attach_vocproc_cmd mvm_a_vocproc_cmd; - void *apr_mvm = voice_get_apr_mvm(); - u16 mvm_handle = voice_get_mvm_handle(v); - u16 cvp_handle = voice_get_cvp_handle(v); - - /* send enable vocproc */ - voice_send_enable_vocproc_cmd(v); - - /* attach vocproc and wait for response */ - mvm_a_vocproc_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_a_vocproc_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_a_vocproc_cmd) - APR_HDR_SIZE); - pr_info("send mvm_a_vocproc_cmd pkt size = %d\n", - mvm_a_vocproc_cmd.hdr.pkt_size); - mvm_a_vocproc_cmd.hdr.src_port = v->session_id; - mvm_a_vocproc_cmd.hdr.dest_port = mvm_handle; - mvm_a_vocproc_cmd.hdr.token = 0; - mvm_a_vocproc_cmd.hdr.opcode = VSS_ISTREAM_CMD_ATTACH_VOCPROC; - mvm_a_vocproc_cmd.mvm_attach_cvp_handle.handle = cvp_handle; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_a_vocproc_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_ISTREAM_CMD_ATTACH_VOCPROC\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* send tty mode if tty device is used */ - voice_send_tty_mode_to_modem(v); - - if (is_voip_session(v->session_id)) - voice_send_netid_timing_cmd(v); - - rtac_add_voice(v->cvs_handle, v->cvp_handle, - v->dev_rx.dev_port_id, v->dev_tx.dev_port_id, - v->session_id); - - return 0; -fail: - return -EINVAL; -} - -static int voice_destroy_modem_voice(struct voice_data *v) -{ - struct mvm_detach_vocproc_cmd mvm_d_vocproc_cmd; - struct apr_hdr cvp_destroy_session_cmd; - int ret = 0; - void *apr_mvm = voice_get_apr_mvm(); - void *apr_cvp = voice_get_apr_cvp(); - u16 mvm_handle = voice_get_mvm_handle(v); - u16 cvp_handle = voice_get_cvp_handle(v); - - /* detach VOCPROC and wait for response from mvm */ - mvm_d_vocproc_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_d_vocproc_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_d_vocproc_cmd) - APR_HDR_SIZE); - pr_info("mvm_d_vocproc_cmd pkt size = %d\n", - mvm_d_vocproc_cmd.hdr.pkt_size); - mvm_d_vocproc_cmd.hdr.src_port = v->session_id; - mvm_d_vocproc_cmd.hdr.dest_port = mvm_handle; - mvm_d_vocproc_cmd.hdr.token = 0; - mvm_d_vocproc_cmd.hdr.opcode = VSS_ISTREAM_CMD_DETACH_VOCPROC; - mvm_d_vocproc_cmd.mvm_detach_cvp_handle.handle = cvp_handle; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_d_vocproc_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_ISTREAM_CMD_DETACH_VOCPROC\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* destrop cvp session */ - cvp_destroy_session_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_destroy_session_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_destroy_session_cmd) - APR_HDR_SIZE); - pr_info("cvp_destroy_session_cmd pkt size = %d\n", - cvp_destroy_session_cmd.pkt_size); - cvp_destroy_session_cmd.src_port = v->session_id; - cvp_destroy_session_cmd.dest_port = cvp_handle; - cvp_destroy_session_cmd.token = 0; - cvp_destroy_session_cmd.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_destroy_session_cmd); - if (ret < 0) { - pr_err("Fail in sending APRV2_IBASIC_CMD_DESTROY_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - rtac_remove_voice(v->cvs_handle); - cvp_handle = 0; - voice_set_cvp_handle(v, cvp_handle); - - return 0; - -fail: - return -EINVAL; -} - -static int voice_send_mute_cmd_to_modem(struct voice_data *v) -{ - struct cvs_set_mute_cmd cvs_mute_cmd; - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - - /* send mute/unmute to cvs */ - cvs_mute_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_mute_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_mute_cmd) - APR_HDR_SIZE); - cvs_mute_cmd.hdr.src_port = v->session_id; - cvs_mute_cmd.hdr.dest_port = cvs_handle; - cvs_mute_cmd.hdr.token = 0; - cvs_mute_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_MUTE; - cvs_mute_cmd.cvs_set_mute.direction = 0; /*tx*/ - cvs_mute_cmd.cvs_set_mute.mute_flag = v->dev_tx.mute; - - pr_info(" mute value =%d\n", cvs_mute_cmd.cvs_set_mute.mute_flag); - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_mute_cmd); - if (ret < 0) { - pr_err("Fail: send STREAM SET MUTE\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) - pr_err("%s: wait_event timeout\n", __func__); - -fail: - return 0; -} - -static int voice_send_vol_index_to_modem(struct voice_data *v) -{ - struct cvp_set_rx_volume_index_cmd cvp_vol_cmd; - int ret = 0; - void *apr_cvp = voice_get_apr_cvp(); - u16 cvp_handle = voice_get_cvp_handle(v); - - /* send volume index to cvp */ - cvp_vol_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_vol_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_vol_cmd) - APR_HDR_SIZE); - cvp_vol_cmd.hdr.src_port = v->session_id; - cvp_vol_cmd.hdr.dest_port = cvp_handle; - cvp_vol_cmd.hdr.token = 0; - cvp_vol_cmd.hdr.opcode = - VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX; - cvp_vol_cmd.cvp_set_vol_idx.vol_index = v->dev_rx.volume; - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_vol_cmd); - if (ret < 0) { - pr_err("Fail in sending RX VOL INDEX\n"); - return -EINVAL; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - return 0; -} - -static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode) -{ - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - struct cvs_start_record_cmd cvs_start_record; - - pr_debug("%s: Start record %d\n", __func__, rec_mode); - - cvs_start_record.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_start_record.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_start_record) - APR_HDR_SIZE); - cvs_start_record.hdr.src_port = v->session_id; - cvs_start_record.hdr.dest_port = cvs_handle; - cvs_start_record.hdr.token = 0; - cvs_start_record.hdr.opcode = VSS_ISTREAM_CMD_START_RECORD; - - if (rec_mode == VOC_REC_UPLINK) { - cvs_start_record.rec_mode.rx_tap_point = VSS_TAP_POINT_NONE; - cvs_start_record.rec_mode.tx_tap_point = - VSS_TAP_POINT_STREAM_END; - } else if (rec_mode == VOC_REC_DOWNLINK) { - cvs_start_record.rec_mode.rx_tap_point = - VSS_TAP_POINT_STREAM_END; - cvs_start_record.rec_mode.tx_tap_point = VSS_TAP_POINT_NONE; - } else if (rec_mode == VOC_REC_BOTH) { - cvs_start_record.rec_mode.rx_tap_point = - VSS_TAP_POINT_STREAM_END; - cvs_start_record.rec_mode.tx_tap_point = - VSS_TAP_POINT_STREAM_END; - } else { - pr_err("%s: Invalid in-call rec_mode %d\n", __func__, rec_mode); - - ret = -EINVAL; - goto fail; - } - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_start_record); - if (ret < 0) { - pr_err("%s: Error %d sending START_RECORD\n", __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - - return 0; - -fail: - return ret; -} - -static int voice_cvs_stop_record(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - struct apr_hdr cvs_stop_record; - - pr_debug("%s: Stop record\n", __func__); - - cvs_stop_record.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_stop_record.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_stop_record) - APR_HDR_SIZE); - cvs_stop_record.src_port = v->session_id; - cvs_stop_record.dest_port = cvs_handle; - cvs_stop_record.token = 0; - cvs_stop_record.opcode = VSS_ISTREAM_CMD_STOP_RECORD; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_stop_record); - if (ret < 0) { - pr_err("%s: Error %d sending STOP_RECORD\n", __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - - return 0; - -fail: - return ret; -} - -int voice_start_record(uint32_t rec_mode, uint32_t set) -{ - int ret = 0, i; - u16 cvs_handle; - - pr_debug("%s: rec_mode %d, set %d\n", __func__, rec_mode, set); - - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - struct voice_data *v = &common.voice[i]; - - mutex_lock(&v->lock); - - cvs_handle = voice_get_cvs_handle(v); - - if (cvs_handle != 0) { - if (set) - ret = voice_cvs_start_record(v, rec_mode); - else - ret = voice_cvs_stop_record(v); - } else { - /* Cache the value for later. */ - v->rec_info.pending = set; - v->rec_info.rec_mode = rec_mode; - } - - mutex_unlock(&v->lock); - } - - return ret; -} - -static int voice_cvs_start_playback(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - struct apr_hdr cvs_start_playback; - - pr_debug("%s: Start playback\n", __func__); - - cvs_start_playback.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_start_playback.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_start_playback) - APR_HDR_SIZE); - cvs_start_playback.src_port = v->session_id; - cvs_start_playback.dest_port = cvs_handle; - cvs_start_playback.token = 0; - cvs_start_playback.opcode = VSS_ISTREAM_CMD_START_PLAYBACK; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_start_playback); - if (ret < 0) { - pr_err("%s: Error %d sending START_PLAYBACK\n", - __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - - v->music_info.playing = 1; - - return 0; - -fail: - return ret; -} - -static int voice_cvs_stop_playback(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs = voice_get_apr_cvs(); - u16 cvs_handle = voice_get_cvs_handle(v); - struct apr_hdr cvs_stop_playback; - - pr_debug("%s: Stop playback\n", __func__); - - if (v->music_info.playing) { - cvs_stop_playback.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_stop_playback.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_stop_playback) - APR_HDR_SIZE); - cvs_stop_playback.src_port = v->session_id; - cvs_stop_playback.dest_port = cvs_handle; - cvs_stop_playback.token = 0; - - cvs_stop_playback.opcode = VSS_ISTREAM_CMD_STOP_PLAYBACK; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_stop_playback); - if (ret < 0) { - pr_err("%s: Error %d sending STOP_PLAYBACK\n", - __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - - v->music_info.playing = 0; - } else { - pr_err("%s: Stop playback already sent\n", __func__); - } - - return 0; - -fail: - return ret; -} - -int voice_start_playback(uint32_t set) -{ - int ret = 0, i; - u16 cvs_handle; - - pr_debug("%s: Start playback %d\n", __func__, set); - - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - struct voice_data *v = &common.voice[i]; - - mutex_lock(&v->lock); - - cvs_handle = voice_get_cvs_handle(v); - - if (cvs_handle != 0) { - if (set) - ret = voice_cvs_start_playback(v); - else - ret = voice_cvs_stop_playback(v); - } else { - /* Cache the value for later. */ - pr_debug("%s: Caching ICP value", __func__); - - v->music_info.pending = set; - } - - mutex_unlock(&v->lock); - } - - return ret; -} - -static void voice_auddev_cb_function(u32 evt_id, - union auddev_evt_data *evt_payload, - void *private_data) -{ - struct common_data *c = private_data; - struct voice_data *v = NULL; - - struct sidetone_cal sidetone_cal_data; - int rc = 0, i = 0; - int rc1 = 0; - - pr_info("auddev_cb_function, evt_id=%d,\n", evt_id); - - if (evt_payload == NULL) { - pr_err("%s: evt_payload is NULL pointer\n", __func__); - return; - } - - switch (evt_id) { - case AUDDEV_EVT_START_VOICE: - v = voice_get_session(evt_payload->voice_session_id); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return; - } - - mutex_lock(&v->lock); - - if ((v->voc_state == VOC_INIT) || - (v->voc_state == VOC_RELEASE)) { - v->v_call_status = VOICE_CALL_START; - if ((v->dev_rx.enabled == VOICE_DEV_ENABLED) - && (v->dev_tx.enabled == VOICE_DEV_ENABLED)) { - rc = voice_apr_register(); - if (rc < 0) { - pr_err("%s: voice apr registration" - "failed\n", __func__); - mutex_unlock(&v->lock); - return; - } - rc1 = voice_create_mvm_cvs_session(v); - if (rc1 < 0) { - pr_err("%s: create mvm-cvs failed\n", - __func__); - msleep(100); - rc = voice_apr_register(); - if (rc < 0) { - mutex_unlock(&v->lock); - pr_err("%s: voice apr regn" - "failed\n", __func__); - return; - } - rc1 = voice_create_mvm_cvs_session(v); - if (rc1 < 0) { - mutex_unlock(&v->lock); - pr_err("%s:Retry mvmcvs " - "failed\n", - __func__); - return; - } - } - voice_setup_modem_voice(v); - voice_attach_vocproc(v); - voice_send_start_voice_cmd(v); - get_sidetone_cal(&sidetone_cal_data); - msm_snddev_enable_sidetone( - v->dev_rx.dev_id, - sidetone_cal_data.enable, - sidetone_cal_data.gain); - v->voc_state = VOC_RUN; - - /* Start in-call recording if command was - * pending. */ - if (v->rec_info.pending) { - voice_cvs_start_record(v, - v->rec_info.rec_mode); - - v->rec_info.pending = 0; - } - - /* Start in-call music delivery if command was - * pending. */ - if (v->music_info.pending) { - voice_cvs_start_playback(v); - - v->music_info.pending = 0; - } - } - } - - mutex_unlock(&v->lock); - break; - case AUDDEV_EVT_DEV_CHG_VOICE: - /* Device change is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - v = &c->voice[i]; - - if (v->dev_rx.enabled == VOICE_DEV_ENABLED) - msm_snddev_enable_sidetone(v->dev_rx.dev_id, - 0, 0); - - v->dev_rx.enabled = VOICE_DEV_DISABLED; - v->dev_tx.enabled = VOICE_DEV_DISABLED; - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_RUN) { - /* send cmd to modem to do voice device - * change */ - voice_disable_vocproc(v); - v->voc_state = VOC_CHANGE; - } - - mutex_unlock(&v->lock); - } - break; - case AUDDEV_EVT_DEV_RDY: - /* Device change is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - v = &c->voice[i]; - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_CHANGE) { - /* get port Ids */ - if (evt_payload->voc_devinfo.dev_type == - DIR_RX) { - v->dev_rx.dev_port_id = - evt_payload->voc_devinfo.dev_port_id; - v->dev_rx.sample = - evt_payload->voc_devinfo.dev_sample; - v->dev_rx.dev_id = - evt_payload->voc_devinfo.dev_id; - v->dev_rx.enabled = VOICE_DEV_ENABLED; - } else { - v->dev_tx.dev_port_id = - evt_payload->voc_devinfo.dev_port_id; - v->dev_tx.sample = - evt_payload->voc_devinfo.dev_sample; - v->dev_tx.enabled = VOICE_DEV_ENABLED; - v->dev_tx.dev_id = - evt_payload->voc_devinfo.dev_id; - } - if ((v->dev_rx.enabled == VOICE_DEV_ENABLED) && - (v->dev_tx.enabled == VOICE_DEV_ENABLED)) { - voice_set_device(v); - get_sidetone_cal(&sidetone_cal_data); - msm_snddev_enable_sidetone( - v->dev_rx.dev_id, - sidetone_cal_data.enable, - sidetone_cal_data.gain); - v->voc_state = VOC_RUN; - } - } else if ((v->voc_state == VOC_INIT) || - (v->voc_state == VOC_RELEASE)) { - /* get AFE ports */ - if (evt_payload->voc_devinfo.dev_type == - DIR_RX) { - /* get rx port id */ - v->dev_rx.dev_port_id = - evt_payload->voc_devinfo.dev_port_id; - v->dev_rx.sample = - evt_payload->voc_devinfo.dev_sample; - v->dev_rx.dev_id = - evt_payload->voc_devinfo.dev_id; - v->dev_rx.enabled = VOICE_DEV_ENABLED; - } else { - /* get tx port id */ - v->dev_tx.dev_port_id = - evt_payload->voc_devinfo.dev_port_id; - v->dev_tx.sample = - evt_payload->voc_devinfo.dev_sample; - v->dev_tx.dev_id = - evt_payload->voc_devinfo.dev_id; - v->dev_tx.enabled = VOICE_DEV_ENABLED; - } - if ((v->dev_rx.enabled == VOICE_DEV_ENABLED) && - (v->dev_tx.enabled == VOICE_DEV_ENABLED) && - (v->v_call_status == VOICE_CALL_START)) { - rc = voice_apr_register(); - if (rc < 0) { - pr_err("%s: voice apr" - "registration failed\n", - __func__); - mutex_unlock(&v->lock); - return; - } - voice_create_mvm_cvs_session(v); - voice_setup_modem_voice(v); - voice_attach_vocproc(v); - voice_send_start_voice_cmd(v); - get_sidetone_cal(&sidetone_cal_data); - msm_snddev_enable_sidetone( - v->dev_rx.dev_id, - sidetone_cal_data.enable, - sidetone_cal_data.gain); - v->voc_state = VOC_RUN; - - /* Start in-call recording if command - * was pending. */ - if (v->rec_info.pending) { - voice_cvs_start_record(v, - v->rec_info.rec_mode); - - v->rec_info.pending = 0; - } - - /* Start in-call music delivery if - * command was pending. */ - if (v->music_info.pending) { - voice_cvs_start_playback(v); - - v->music_info.pending = 0; - } - } - } - - mutex_unlock(&v->lock); - } - break; - case AUDDEV_EVT_DEVICE_VOL_MUTE_CHG: - v = voice_get_session( - evt_payload->voc_vm_info.voice_session_id); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return; - } - - /* cache the mute and volume index value */ - if (evt_payload->voc_vm_info.dev_type == DIR_TX) { - v->dev_tx.mute = - evt_payload->voc_vm_info.dev_vm_val.mute; - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_RUN) - voice_send_mute_cmd_to_modem(v); - - mutex_unlock(&v->lock); - } else { - v->dev_rx.volume = - evt_payload->voc_vm_info.dev_vm_val.vol; - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_RUN) - voice_send_vol_index_to_modem(v); - - mutex_unlock(&v->lock); - } - break; - case AUDDEV_EVT_REL_PENDING: - /* Device change is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - v = &c->voice[i]; - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_RUN) { - voice_disable_vocproc(v); - v->voc_state = VOC_CHANGE; - } - - mutex_unlock(&v->lock); - - if (evt_payload->voc_devinfo.dev_type == DIR_RX) - v->dev_rx.enabled = VOICE_DEV_DISABLED; - else - v->dev_tx.enabled = VOICE_DEV_DISABLED; - } - - break; - case AUDDEV_EVT_END_VOICE: - v = voice_get_session(evt_payload->voice_session_id); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return; - } - - /* recover the tx mute and rx volume to the default values */ - v->dev_tx.mute = c->default_mute_val; - v->dev_rx.volume = c->default_vol_val; - if (v->dev_rx.enabled == VOICE_DEV_ENABLED) - msm_snddev_enable_sidetone(v->dev_rx.dev_id, 0, 0); - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_RUN) { - /* call stop modem voice */ - voice_send_stop_voice_cmd(v); - voice_destroy_modem_voice(v); - voice_destroy_mvm_cvs_session(v); - v->voc_state = VOC_RELEASE; - } else if (v->voc_state == VOC_CHANGE) { - voice_send_stop_voice_cmd(v); - voice_destroy_mvm_cvs_session(v); - v->voc_state = VOC_RELEASE; - } - - mutex_unlock(&v->lock); - - v->v_call_status = VOICE_CALL_END; - - break; - default: - pr_err("UNKNOWN EVENT\n"); - } - return; -} -EXPORT_SYMBOL(voice_auddev_cb_function); - -int voice_set_voc_path_full(uint32_t set) -{ - pr_info("%s: %d\n", __func__, set); - - mutex_lock(&common.common_lock); - - if (set) - common.voc_path = VOC_PATH_FULL; - else - common.voc_path = VOC_PATH_PASSIVE; - - mutex_unlock(&common.common_lock); - - return 0; -} -EXPORT_SYMBOL(voice_set_voc_path_full); - -void voice_register_mvs_cb(ul_cb_fn ul_cb, - dl_cb_fn dl_cb, - void *private_data) -{ - common.mvs_info.ul_cb = ul_cb; - common.mvs_info.dl_cb = dl_cb; - common.mvs_info.private_data = private_data; -} - -void voice_config_vocoder(uint32_t media_type, - uint32_t rate, - uint32_t network_type, - uint32_t dtx_mode, - struct q_min_max_rate q_min_max_rate) -{ - common.mvs_info.media_type = media_type; - common.mvs_info.rate = rate; - common.mvs_info.network_type = network_type; - common.mvs_info.dtx_mode = dtx_mode; - common.mvs_info.q_min_max_rate = q_min_max_rate; -} - -static int32_t modem_mvm_callback(struct apr_client_data *data, void *priv) -{ - uint32_t *ptr; - struct common_data *c = priv; - struct voice_data *v = NULL; - int i = 0; - - pr_debug("%s: session_id 0x%x\n", __func__, data->dest_port); - - if (data->opcode == RESET_EVENTS) { - pr_debug("%s:Reset event received in Voice service\n", - __func__); - apr_reset(c->apr_mvm); - c->apr_mvm = NULL; - apr_reset(c->apr_q6_mvm); - c->apr_q6_mvm = NULL; - - /* Sub-system restart is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) - c->voice[i].mvm_handle = 0; - - return 0; - } - - v = voice_get_session(data->dest_port); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - - pr_debug("%s: common data 0x%x, session 0x%x\n", - __func__, (unsigned int)c, (unsigned int)v); - pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__, - data->payload_size, data->opcode); - - if (data->opcode == APR_BASIC_RSP_RESULT) { - if (data->payload_size) { - ptr = data->payload; - - pr_info("%x %x\n", ptr[0], ptr[1]); - /* ping mvm service ACK */ - - if (ptr[0] == - VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION || - ptr[0] == - VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION) { - /* Passive session is used for voice call - * through modem. Full session is used for voice - * call through Q6. */ - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - if (!ptr[1]) { - pr_debug("%s: MVM handle is %d\n", - __func__, data->src_port); - - voice_set_mvm_handle(v, data->src_port); - } else - pr_info("got NACK for sending \ - MVM create session \n"); - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_IMVM_CMD_START_VOICE) { - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_ATTACH_VOCPROC) { - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_IMVM_CMD_STOP_VOICE) { - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_DETACH_VOCPROC) { - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_SET_TTY_MODE) { - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == APRV2_IBASIC_CMD_DESTROY_SESSION) { - pr_debug("%s: DESTROY resp\n", __func__); - - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_IMVM_CMD_ATTACH_STREAM) { - pr_debug("%s: ATTACH_STREAM resp 0x%x\n", - __func__, ptr[1]); - - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_IMVM_CMD_DETACH_STREAM) { - pr_debug("%s: DETACH_STREAM resp 0x%x\n", - __func__, ptr[1]); - - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_ICOMMON_CMD_SET_NETWORK) { - pr_debug("%s: SET_NETWORK resp 0x%x\n", - __func__, ptr[1]); - - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else if (ptr[0] == VSS_ICOMMON_CMD_SET_VOICE_TIMING) { - pr_debug("%s: SET_VOICE_TIMING resp 0x%x\n", - __func__, ptr[1]); - - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - } else - pr_debug("%s: not match cmd = 0x%x\n", - __func__, ptr[0]); - } - } - - return 0; -} - -static int32_t modem_cvs_callback(struct apr_client_data *data, void *priv) -{ - uint32_t *ptr; - struct common_data *c = priv; - struct voice_data *v = NULL; - int i = 0; - - pr_debug("%s: session_id 0x%x\n", __func__, data->dest_port); - - if (data->opcode == RESET_EVENTS) { - pr_debug("%s:Reset event received in Voice service\n", - __func__); - apr_reset(c->apr_cvs); - c->apr_cvs = NULL; - apr_reset(c->apr_q6_cvs); - c->apr_q6_cvs = NULL; - - /* Sub-system restart is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) - c->voice[i].cvs_handle = 0; - - return 0; - } - - v = voice_get_session(data->dest_port); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - - pr_debug("%s: common data 0x%x, session 0x%x\n", - __func__, (unsigned int)c, (unsigned int)v); - pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__, - data->payload_size, data->opcode); - - if (data->opcode == APR_BASIC_RSP_RESULT) { - if (data->payload_size) { - ptr = data->payload; - - pr_info("%x %x\n", ptr[0], ptr[1]); - /*response from modem CVS */ - if (ptr[0] == - VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION || - ptr[0] == - VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION) { - if (!ptr[1]) { - pr_debug("%s: CVS handle is %d\n", - __func__, data->src_port); - voice_set_cvs_handle(v, data->src_port); - } else - pr_info("got NACK for sending \ - CVS create session \n"); - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == - VSS_ISTREAM_CMD_CACHE_CALIBRATION_DATA) { - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == - VSS_ISTREAM_CMD_SET_MUTE) { - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_SET_MEDIA_TYPE) { - pr_debug("%s: SET_MEDIA resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == - VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE) { - pr_debug("%s: SET_AMR_RATE resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == - VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE) { - pr_debug("%s: SET_AMR_WB_RATE resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_SET_ENC_DTX_MODE) { - pr_debug("%s: SET_DTX resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == - VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE) { - pr_debug("%s: SET_CDMA_RATE resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == APRV2_IBASIC_CMD_DESTROY_SESSION) { - pr_debug("%s: DESTROY resp\n", __func__); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_START_RECORD) { - pr_debug("%s: START_RECORD resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_STOP_RECORD) { - pr_debug("%s: STOP_RECORD resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == VOICE_CMD_SET_PARAM) { - rtac_make_voice_callback(RTAC_CVS, ptr, - data->payload_size); - } else if (ptr[0] == VSS_ISTREAM_CMD_START_PLAYBACK) { - pr_debug("%s: START_PLAYBACK resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else if (ptr[0] == VSS_ISTREAM_CMD_STOP_PLAYBACK) { - pr_debug("%s: STOP_PLAYBACK resp 0x%x\n", - __func__, ptr[1]); - - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - } else - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - } - } else if (data->opcode == VSS_ISTREAM_EVT_SEND_ENC_BUFFER) { - uint32_t *voc_pkt = data->payload; - uint32_t pkt_len = data->payload_size; - - if (voc_pkt != NULL && c->mvs_info.ul_cb != NULL) { - pr_debug("%s: Media type is 0x%x\n", - __func__, voc_pkt[0]); - - /* Remove media ID from payload. */ - voc_pkt++; - pkt_len = pkt_len - 4; - - c->mvs_info.ul_cb((uint8_t *)voc_pkt, - pkt_len, - c->mvs_info.private_data); - } else { - pr_err("%s: voc_pkt is 0x%x ul_cb is 0x%x\n", - __func__, (unsigned int)voc_pkt, - (unsigned int)c->mvs_info.ul_cb); - } - } else if (data->opcode == VSS_ISTREAM_EVT_SEND_DEC_BUFFER) { - pr_debug("%s: Send dec buf resp\n", __func__); - } else if (data->opcode == VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER) { - struct cvs_send_dec_buf_cmd send_dec_buf; - int ret = 0; - uint32_t pkt_len = 0; - - if (c->mvs_info.dl_cb != NULL) { - send_dec_buf.dec_buf.media_id = c->mvs_info.media_type; - - c->mvs_info.dl_cb( - (uint8_t *)&send_dec_buf.dec_buf.packet_data, - &pkt_len, - c->mvs_info.private_data); - - send_dec_buf.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - send_dec_buf.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(send_dec_buf.dec_buf.media_id) + pkt_len); - send_dec_buf.hdr.src_port = v->session_id; - send_dec_buf.hdr.dest_port = voice_get_cvs_handle(v); - send_dec_buf.hdr.token = 0; - send_dec_buf.hdr.opcode = - VSS_ISTREAM_EVT_SEND_DEC_BUFFER; - - ret = apr_send_pkt(voice_get_apr_cvs(), - (uint32_t *) &send_dec_buf); - if (ret < 0) { - pr_err("%s: Error %d sending DEC_BUF\n", - __func__, ret); - goto fail; - } - } else { - pr_err("%s: ul_cb is NULL\n", __func__); - } - } else if (data->opcode == VOICE_EVT_GET_PARAM_ACK) { - rtac_make_voice_callback(RTAC_CVS, data->payload, - data->payload_size); - } else { - pr_debug("%s: Unknown opcode 0x%x\n", __func__, data->opcode); - } - -fail: - return 0; -} - -static int32_t modem_cvp_callback(struct apr_client_data *data, void *priv) -{ - uint32_t *ptr; - struct common_data *c = priv; - struct voice_data *v = NULL; - int i = 0; - - pr_debug("%s: session_id 0x%x\n", __func__, data->dest_port); - - if (data->opcode == RESET_EVENTS) { - pr_debug("%s:Reset event received in Voice service\n", - __func__); - apr_reset(c->apr_cvp); - c->apr_cvp = NULL; - apr_reset(c->apr_q6_cvp); - c->apr_q6_cvp = NULL; - - /* Sub-system restart is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) - c->voice[i].cvp_handle = 0; - - return 0; - } - - v = voice_get_session(data->dest_port); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - - pr_debug("%s: common data 0x%x, session 0x%x\n", - __func__, (unsigned int)c, (unsigned int)v); - pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__, - data->payload_size, data->opcode); - - if (data->opcode == APR_BASIC_RSP_RESULT) { - if (data->payload_size) { - ptr = data->payload; - - pr_info("%x %x\n", ptr[0], ptr[1]); - /*response from modem CVP */ - if (ptr[0] == - VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION) { - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - if (!ptr[1]) { - voice_set_cvp_handle(v, data->src_port); - pr_debug("cvphdl=%d\n", data->src_port); - } else - pr_info("got NACK from CVP create \ - session response\n"); - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == - VSS_IVOCPROC_CMD_CACHE_CALIBRATION_DATA) { - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == VSS_IVOCPROC_CMD_SET_DEVICE) { - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == - VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX) { - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == VSS_IVOCPROC_CMD_ENABLE) { - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == VSS_IVOCPROC_CMD_DISABLE) { - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == APRV2_IBASIC_CMD_DESTROY_SESSION) { - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == - VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE - ) { - - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - } else if (ptr[0] == VOICE_CMD_SET_PARAM) { - rtac_make_voice_callback(RTAC_CVP, ptr, - data->payload_size); - } else - pr_debug("%s: not match cmd = 0x%x\n", - __func__, ptr[0]); - } - } else if (data->opcode == VOICE_EVT_GET_PARAM_ACK) { - rtac_make_voice_callback(RTAC_CVP, data->payload, - data->payload_size); - } - return 0; -} - - -static int __init voice_init(void) -{ - int rc = 0, i = 0; - - memset(&common, 0, sizeof(struct common_data)); - - /* set default value */ - common.default_mute_val = 1; /* default is mute */ - common.default_vol_val = 0; - common.default_sample_val = 8000; - - common.voc_path = VOC_PATH_PASSIVE; - - /* Initialize MVS info. */ - common.mvs_info.network_type = VSS_NETWORK_ID_DEFAULT; - - mutex_init(&common.common_lock); - - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - common.voice[i].session_id = SESSION_ID_BASE + i; - - common.voice[i].dev_rx.volume = common.default_vol_val; - common.voice[i].dev_tx.mute = common.default_mute_val; - - common.voice[i].voc_state = VOC_INIT; - - common.voice[i].rec_info.rec_mode = VOC_REC_NONE; - - init_waitqueue_head(&common.voice[i].mvm_wait); - init_waitqueue_head(&common.voice[i].cvs_wait); - init_waitqueue_head(&common.voice[i].cvp_wait); - - mutex_init(&common.voice[i].lock); - - } - - common.device_events = AUDDEV_EVT_DEV_CHG_VOICE | - AUDDEV_EVT_DEV_RDY | - AUDDEV_EVT_REL_PENDING | - AUDDEV_EVT_START_VOICE | - AUDDEV_EVT_END_VOICE | - AUDDEV_EVT_DEVICE_VOL_MUTE_CHG | - AUDDEV_EVT_FREQ_CHG; - - pr_debug("to register call back\n"); - /* register callback to auddev */ - auddev_register_evt_listner(common.device_events, AUDDEV_CLNT_VOC, - 0, voice_auddev_cb_function, &common); - - return rc; -} - -device_initcall(voice_init); diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_ecodec.c b/arch/arm/mach-msm/qdsp6v2/snddev_ecodec.c deleted file mode 100644 index 804fa14a9fc9af8b87478febc0d9f0cdf0c681c3..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_ecodec.c +++ /dev/null @@ -1,382 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "snddev_ecodec.h" - -#define ECODEC_SAMPLE_RATE 8000 - -/* Context for each external codec device */ -struct snddev_ecodec_state { - struct snddev_ecodec_data *data; - u32 sample_rate; -}; - -/* Global state for the driver */ -struct snddev_ecodec_drv_state { - struct mutex dev_lock; - int ref_cnt; /* ensure one rx device at a time */ - struct clk *ecodec_clk; -}; - -static struct snddev_ecodec_drv_state snddev_ecodec_drv; - -struct aux_pcm_state { - unsigned int dout; - unsigned int din; - unsigned int syncout; - unsigned int clkin_a; -}; - -static struct aux_pcm_state the_aux_pcm_state; - -static int aux_pcm_gpios_request(void) -{ - int rc = 0; - - pr_debug("%s\n", __func__); - rc = gpio_request(the_aux_pcm_state.dout, "AUX PCM DOUT"); - if (rc < 0) { - pr_err("%s: GPIO request for AUX PCM DOUT failed\n", __func__); - return rc; - } - - rc = gpio_request(the_aux_pcm_state.din, "AUX PCM DIN"); - if (rc < 0) { - pr_err("%s: GPIO request for AUX PCM DIN failed\n", __func__); - gpio_free(the_aux_pcm_state.dout); - return rc; - } - - rc = gpio_request(the_aux_pcm_state.syncout, "AUX PCM SYNC OUT"); - if (rc < 0) { - pr_err("%s: GPIO request for AUX PCM SYNC OUT failed\n", - __func__); - gpio_free(the_aux_pcm_state.dout); - gpio_free(the_aux_pcm_state.din); - return rc; - } - - rc = gpio_request(the_aux_pcm_state.clkin_a, "AUX PCM CLKIN A"); - if (rc < 0) { - pr_err("%s: GPIO request for AUX PCM CLKIN A failed\n", - __func__); - gpio_free(the_aux_pcm_state.dout); - gpio_free(the_aux_pcm_state.din); - gpio_free(the_aux_pcm_state.syncout); - return rc; - } - - return rc; -} - -static void aux_pcm_gpios_free(void) -{ - pr_debug("%s\n", __func__); - gpio_free(the_aux_pcm_state.dout); - gpio_free(the_aux_pcm_state.din); - gpio_free(the_aux_pcm_state.syncout); - gpio_free(the_aux_pcm_state.clkin_a); -} - -static int get_aux_pcm_gpios(struct platform_device *pdev) -{ - int rc = 0; - struct resource *res; - - /* Claim all of the GPIOs. */ - res = platform_get_resource_byname(pdev, IORESOURCE_IO, "aux_pcm_dout"); - if (!res) { - pr_err("%s: failed to get gpio AUX PCM DOUT\n", __func__); - return -ENODEV; - } - - the_aux_pcm_state.dout = res->start; - - res = platform_get_resource_byname(pdev, IORESOURCE_IO, "aux_pcm_din"); - if (!res) { - pr_err("%s: failed to get gpio AUX PCM DIN\n", __func__); - return -ENODEV; - } - - the_aux_pcm_state.din = res->start; - - res = platform_get_resource_byname(pdev, IORESOURCE_IO, - "aux_pcm_syncout"); - if (!res) { - pr_err("%s: failed to get gpio AUX PCM SYNC OUT\n", __func__); - return -ENODEV; - } - - the_aux_pcm_state.syncout = res->start; - - res = platform_get_resource_byname(pdev, IORESOURCE_IO, - "aux_pcm_clkin_a"); - if (!res) { - pr_err("%s: failed to get gpio AUX PCM CLKIN A\n", __func__); - return -ENODEV; - } - - the_aux_pcm_state.clkin_a = res->start; - - return rc; -} - -static int aux_pcm_probe(struct platform_device *pdev) -{ - int rc = 0; - - rc = get_aux_pcm_gpios(pdev); - if (rc < 0) { - pr_err("%s: GPIO configuration failed\n", __func__); - return -ENODEV; - } - return rc; -} - -static struct platform_driver aux_pcm_driver = { - .probe = aux_pcm_probe, - .driver = { .name = "msm_aux_pcm"} -}; - -static int snddev_ecodec_open(struct msm_snddev_info *dev_info) -{ - int rc; - struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv; - union afe_port_config afe_config; - - pr_debug("%s\n", __func__); - - mutex_lock(&drv->dev_lock); - - if (dev_info->opened) { - pr_err("%s: ERROR: %s already opened\n", __func__, - dev_info->name); - mutex_unlock(&drv->dev_lock); - return -EBUSY; - } - - if (drv->ref_cnt != 0) { - pr_debug("%s: opened %s\n", __func__, dev_info->name); - drv->ref_cnt++; - mutex_unlock(&drv->dev_lock); - return 0; - } - - pr_info("%s: opening %s\n", __func__, dev_info->name); - - rc = aux_pcm_gpios_request(); - if (rc < 0) { - pr_err("%s: GPIO request failed\n", __func__); - return rc; - } - - clk_reset(drv->ecodec_clk, CLK_RESET_ASSERT); - - afe_config.pcm.mode = AFE_PCM_CFG_MODE_PCM; - afe_config.pcm.sync = AFE_PCM_CFG_SYNC_INT; - afe_config.pcm.frame = AFE_PCM_CFG_FRM_256BPF; - afe_config.pcm.quant = AFE_PCM_CFG_QUANT_LINEAR_NOPAD; - afe_config.pcm.slot = 0; - afe_config.pcm.data = AFE_PCM_CFG_CDATAOE_MASTER; - - rc = afe_open(PCM_RX, &afe_config, ECODEC_SAMPLE_RATE); - if (rc < 0) { - pr_err("%s: afe open failed for PCM_RX\n", __func__); - goto err_rx_afe; - } - - rc = afe_open(PCM_TX, &afe_config, ECODEC_SAMPLE_RATE); - if (rc < 0) { - pr_err("%s: afe open failed for PCM_TX\n", __func__); - goto err_tx_afe; - } - - rc = clk_set_rate(drv->ecodec_clk, 2048000); - if (rc < 0) { - pr_err("%s: clk_set_rate failed\n", __func__); - goto err_clk; - } - - clk_prepare_enable(drv->ecodec_clk); - - clk_reset(drv->ecodec_clk, CLK_RESET_DEASSERT); - - drv->ref_cnt++; - mutex_unlock(&drv->dev_lock); - - return 0; - -err_clk: - afe_close(PCM_TX); -err_tx_afe: - afe_close(PCM_RX); -err_rx_afe: - aux_pcm_gpios_free(); - mutex_unlock(&drv->dev_lock); - return -ENODEV; -} - -int snddev_ecodec_close(struct msm_snddev_info *dev_info) -{ - struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv; - - pr_debug("%s: closing %s\n", __func__, dev_info->name); - - mutex_lock(&drv->dev_lock); - - if (!dev_info->opened) { - pr_err("%s: ERROR: %s is not opened\n", __func__, - dev_info->name); - mutex_unlock(&drv->dev_lock); - return -EPERM; - } - - drv->ref_cnt--; - - if (drv->ref_cnt == 0) { - - pr_info("%s: closing all devices\n", __func__); - - clk_disable_unprepare(drv->ecodec_clk); - aux_pcm_gpios_free(); - - afe_close(PCM_RX); - afe_close(PCM_TX); - } - - mutex_unlock(&drv->dev_lock); - - return 0; -} - -int snddev_ecodec_set_freq(struct msm_snddev_info *dev_info, u32 rate) -{ - int rc = 0; - - if (!dev_info) { - rc = -EINVAL; - goto error; - } - return ECODEC_SAMPLE_RATE; - -error: - return rc; -} - -static int snddev_ecodec_probe(struct platform_device *pdev) -{ - int rc = 0; - struct snddev_ecodec_data *pdata; - struct msm_snddev_info *dev_info; - struct snddev_ecodec_state *ecodec; - - if (!pdev || !pdev->dev.platform_data) { - printk(KERN_ALERT "Invalid caller\n"); - rc = -1; - goto error; - } - pdata = pdev->dev.platform_data; - - ecodec = kzalloc(sizeof(struct snddev_ecodec_state), GFP_KERNEL); - if (!ecodec) { - rc = -ENOMEM; - goto error; - } - - dev_info = kzalloc(sizeof(struct msm_snddev_info), GFP_KERNEL); - if (!dev_info) { - kfree(ecodec); - rc = -ENOMEM; - goto error; - } - - dev_info->name = pdata->name; - dev_info->copp_id = pdata->copp_id; - dev_info->private_data = (void *)ecodec; - dev_info->dev_ops.open = snddev_ecodec_open; - dev_info->dev_ops.close = snddev_ecodec_close; - dev_info->dev_ops.set_freq = snddev_ecodec_set_freq; - dev_info->dev_ops.enable_sidetone = NULL; - dev_info->capability = pdata->capability; - dev_info->opened = 0; - - msm_snddev_register(dev_info); - - ecodec->data = pdata; - ecodec->sample_rate = ECODEC_SAMPLE_RATE; /* Default to 8KHz */ -error: - return rc; -} - -struct platform_driver snddev_ecodec_driver = { - .probe = snddev_ecodec_probe, - .driver = {.name = "msm_snddev_ecodec"} -}; - -int __init snddev_ecodec_init(void) -{ - int rc = 0; - struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv; - - mutex_init(&drv->dev_lock); - drv->ref_cnt = 0; - - drv->ecodec_clk = clk_get_sys(NULL, "pcm_clk"); - if (IS_ERR(drv->ecodec_clk)) { - pr_err("%s: could not get pcm_clk\n", __func__); - return PTR_ERR(drv->ecodec_clk); - } - - rc = platform_driver_register(&aux_pcm_driver); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: platform_driver_register for aux pcm failed\n", - __func__); - goto error_aux_pcm_platform_driver; - } - - rc = platform_driver_register(&snddev_ecodec_driver); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: platform_driver_register for ecodec failed\n", - __func__); - goto error_ecodec_platform_driver; - } - - return 0; - -error_ecodec_platform_driver: - platform_driver_unregister(&aux_pcm_driver); -error_aux_pcm_platform_driver: - clk_put(drv->ecodec_clk); - - pr_err("%s: encounter error\n", __func__); - return -ENODEV; -} - -device_initcall(snddev_ecodec_init); - -MODULE_DESCRIPTION("ECodec Sound Device driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_ecodec.h b/arch/arm/mach-msm/qdsp6v2/snddev_ecodec.h deleted file mode 100644 index 6eb67513992df76f2966d32927d40d9ad16cd77c..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_ecodec.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) 2010, 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 __MACH_QDSP6V2_SNDDEV_ECODEC_H -#define __MACH_QDSP6V2_SNDDEV_ECODEC_H -#include - -struct snddev_ecodec_data { - u32 capability; /* RX or TX */ - const char *name; - u32 copp_id; /* audpp routing */ - u8 channel_mode; - u32 conf_pcm_ctl_val; - u32 conf_aux_codec_intf; - u32 conf_data_format_padding_val; -}; -#endif diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_hdmi.c b/arch/arm/mach-msm/qdsp6v2/snddev_hdmi.c deleted file mode 100644 index f6af0ee811a9ef33ee7004a39176618734dd2d24..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_hdmi.c +++ /dev/null @@ -1,198 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "snddev_hdmi.h" - -static DEFINE_MUTEX(snddev_hdmi_lock); -static int snddev_hdmi_active; - -static int snddev_hdmi_open(struct msm_snddev_info *dev_info) -{ - int rc = 0; - union afe_port_config afe_config; - struct snddev_hdmi_data *snddev_hdmi_data; - - if (!dev_info) { - pr_err("msm_snddev_info is null\n"); - return -EINVAL; - } - - snddev_hdmi_data = dev_info->private_data; - - mutex_lock(&snddev_hdmi_lock); - - if (snddev_hdmi_active) { - pr_err("HDMI snddev already active\n"); - mutex_unlock(&snddev_hdmi_lock); - return -EBUSY; - } - - if (snddev_hdmi_data->on_apps) { - snddev_hdmi_active = 1; - pr_debug("%s open done\n", dev_info->name); - mutex_unlock(&snddev_hdmi_lock); - return 0; - } - - afe_config.hdmi.channel_mode = snddev_hdmi_data->channel_mode; - afe_config.hdmi.bitwidth = 16; - afe_config.hdmi.data_type = 0; - rc = afe_open(snddev_hdmi_data->copp_id, &afe_config, - dev_info->sample_rate); - - if (rc < 0) { - pr_err("afe_open failed\n"); - mutex_unlock(&snddev_hdmi_lock); - return -EINVAL; - } - snddev_hdmi_active = 1; - - pr_debug("%s open done\n", dev_info->name); - - mutex_unlock(&snddev_hdmi_lock); - - return 0; -} - -static int snddev_hdmi_close(struct msm_snddev_info *dev_info) -{ - - struct snddev_hdmi_data *snddev_hdmi_data; - - if (!dev_info) { - pr_err("msm_snddev_info is null\n"); - return -EINVAL; - } - - snddev_hdmi_data = dev_info->private_data; - - if (!dev_info->opened) { - pr_err("calling close device with out opening the" - " device\n"); - return -EPERM; - } - mutex_lock(&snddev_hdmi_lock); - - if (!snddev_hdmi_active) { - pr_err("HDMI snddev not active\n"); - mutex_unlock(&snddev_hdmi_lock); - return -EPERM; - } - snddev_hdmi_active = 0; - - if (snddev_hdmi_data->on_apps) { - pr_debug("%s Closed\n", dev_info->name); - - mutex_unlock(&snddev_hdmi_lock); - return 0; - } - - - afe_close(HDMI_RX); - - pr_debug("%s closed\n", dev_info->name); - mutex_unlock(&snddev_hdmi_lock); - - return 0; -} - -static int snddev_hdmi_set_freq(struct msm_snddev_info *dev_info, u32 req_freq) -{ - if (req_freq != 48000) { - pr_debug("Unsupported Frequency:%d\n", req_freq); - return -EINVAL; - } - return 48000; -} - -static int snddev_hdmi_probe(struct platform_device *pdev) -{ - int rc = 0; - struct snddev_hdmi_data *pdata; - struct msm_snddev_info *dev_info; - - if (!pdev || !pdev->dev.platform_data) { - printk(KERN_ALERT "Invalid caller\n"); - return -ENODEV; - } - - pdata = pdev->dev.platform_data; - if (!(pdata->capability & SNDDEV_CAP_RX)) { - pr_err("invalid device data either RX or TX\n"); - return -ENODEV; - } - - dev_info = kzalloc(sizeof(struct msm_snddev_info), GFP_KERNEL); - if (!dev_info) { - pr_err("unable to allocate memeory for msm_snddev_info\n"); - return -ENOMEM; - } - - dev_info->name = pdata->name; - dev_info->copp_id = pdata->copp_id; - dev_info->acdb_id = pdata->acdb_id; - dev_info->private_data = (void *)pdata; - dev_info->dev_ops.open = snddev_hdmi_open; - dev_info->dev_ops.close = snddev_hdmi_close; - dev_info->dev_ops.set_freq = snddev_hdmi_set_freq; - dev_info->capability = pdata->capability; - dev_info->opened = 0; - msm_snddev_register(dev_info); - dev_info->sample_rate = pdata->default_sample_rate; - - pr_debug("probe done for %s\n", pdata->name); - return rc; -} - -static struct platform_driver snddev_hdmi_driver = { - .probe = snddev_hdmi_probe, - .driver = {.name = "snddev_hdmi"} -}; - -static int __init snddev_hdmi_init(void) -{ - s32 rc; - - rc = platform_driver_register(&snddev_hdmi_driver); - if (IS_ERR_VALUE(rc)) { - - pr_err("platform_driver_register failed.\n"); - goto error_platform_driver; - } - - pr_debug("snddev_hdmi_init : done\n"); - - return 0; - -error_platform_driver: - - pr_err("encounterd error\n"); - return -ENODEV; -} - -module_init(snddev_hdmi_init); - -MODULE_DESCRIPTION("HDMI Sound Device driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_hdmi.h b/arch/arm/mach-msm/qdsp6v2/snddev_hdmi.h deleted file mode 100644 index 672bfa66a7dd4c666aec08d4a4b921a3d76accc6..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_hdmi.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __MACH_QDSP6_V2_SNDDEV_HDMI_H -#define __MACH_QDSP6_V2_SNDDEV_HDMI_H - -struct snddev_hdmi_data { - u32 capability; /* RX or TX */ - const char *name; - u32 copp_id; /* audpp routing */ - u32 acdb_id; /* Audio Cal purpose */ - u8 channel_mode; - u32 default_sample_rate; - u32 on_apps; -}; -#endif diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_icodec.c b/arch/arm/mach-msm/qdsp6v2/snddev_icodec.c deleted file mode 100644 index 38bb65ab38f600e53fe91dc27f37317452f4aa56..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_icodec.c +++ /dev/null @@ -1,1121 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "snddev_icodec.h" - -#define SNDDEV_ICODEC_PCM_SZ 32 /* 16 bit / sample stereo mode */ -#define SNDDEV_ICODEC_MUL_FACTOR 3 /* Multi by 8 Shift by 3 */ -#define SNDDEV_ICODEC_CLK_RATE(freq) \ - (((freq) * (SNDDEV_ICODEC_PCM_SZ)) << (SNDDEV_ICODEC_MUL_FACTOR)) -#define SNDDEV_LOW_POWER_MODE 0 -#define SNDDEV_HIGH_POWER_MODE 1 -/* Voltage required for S4 in microVolts, 2.2V or 2200000microvolts */ -#define SNDDEV_VREG_8058_S4_VOLTAGE (2200000) -/* Load Current required for S4 in microAmps, - 36mA - 56mA */ -#define SNDDEV_VREG_LOW_POWER_LOAD (36000) -#define SNDDEV_VREG_HIGH_POWER_LOAD (56000) - -bool msm_codec_i2s_slave_mode; - -/* Context for each internal codec sound device */ -struct snddev_icodec_state { - struct snddev_icodec_data *data; - struct adie_codec_path *adie_path; - u32 sample_rate; - u32 enabled; -}; - -/* Global state for the driver */ -struct snddev_icodec_drv_state { - struct mutex rx_lock; - struct mutex lb_lock; - struct mutex tx_lock; - u32 rx_active; /* ensure one rx device at a time */ - u32 tx_active; /* ensure one tx device at a time */ - struct clk *rx_osrclk; - struct clk *rx_bitclk; - struct clk *tx_osrclk; - struct clk *tx_bitclk; - - struct pm_qos_request rx_pm_qos_req; - struct pm_qos_request tx_pm_qos_req; - - /* handle to pmic8058 regulator smps4 */ - struct regulator *snddev_vreg; -}; - -static struct snddev_icodec_drv_state snddev_icodec_drv; - -struct regulator *vreg_init(void) -{ - int rc; - struct regulator *vreg_ptr; - - vreg_ptr = regulator_get(NULL, "8058_s4"); - if (IS_ERR(vreg_ptr)) { - pr_err("%s: regulator_get 8058_s4 failed\n", __func__); - return NULL; - } - - rc = regulator_set_voltage(vreg_ptr, SNDDEV_VREG_8058_S4_VOLTAGE, - SNDDEV_VREG_8058_S4_VOLTAGE); - if (rc == 0) - return vreg_ptr; - else - return NULL; -} - -static void vreg_deinit(struct regulator *vreg) -{ - regulator_put(vreg); -} - -static void vreg_mode_vote(struct regulator *vreg, int enable, int mode) -{ - int rc; - if (enable) { - rc = regulator_enable(vreg); - if (rc != 0) - pr_err("%s:Enabling regulator failed\n", __func__); - else { - if (mode) - regulator_set_optimum_mode(vreg, - SNDDEV_VREG_HIGH_POWER_LOAD); - else - regulator_set_optimum_mode(vreg, - SNDDEV_VREG_LOW_POWER_LOAD); - } - } else { - rc = regulator_disable(vreg); - if (rc != 0) - pr_err("%s:Disabling regulator failed\n", __func__); - } -} - -struct msm_cdcclk_ctl_state { - unsigned int rx_mclk; - unsigned int rx_mclk_requested; - unsigned int tx_mclk; - unsigned int tx_mclk_requested; -}; - -static struct msm_cdcclk_ctl_state the_msm_cdcclk_ctl_state; - -static int msm_snddev_rx_mclk_request(void) -{ - int rc = 0; - - rc = gpio_request(the_msm_cdcclk_ctl_state.rx_mclk, - "MSM_SNDDEV_RX_MCLK"); - if (rc < 0) { - pr_err("%s: GPIO request for MSM SNDDEV RX failed\n", __func__); - return rc; - } - the_msm_cdcclk_ctl_state.rx_mclk_requested = 1; - return rc; -} -static int msm_snddev_tx_mclk_request(void) -{ - int rc = 0; - - rc = gpio_request(the_msm_cdcclk_ctl_state.tx_mclk, - "MSM_SNDDEV_TX_MCLK"); - if (rc < 0) { - pr_err("%s: GPIO request for MSM SNDDEV TX failed\n", __func__); - return rc; - } - the_msm_cdcclk_ctl_state.tx_mclk_requested = 1; - return rc; -} -static void msm_snddev_rx_mclk_free(void) -{ - if (the_msm_cdcclk_ctl_state.rx_mclk_requested) { - gpio_free(the_msm_cdcclk_ctl_state.rx_mclk); - the_msm_cdcclk_ctl_state.rx_mclk_requested = 0; - } -} -static void msm_snddev_tx_mclk_free(void) -{ - if (the_msm_cdcclk_ctl_state.tx_mclk_requested) { - gpio_free(the_msm_cdcclk_ctl_state.tx_mclk); - the_msm_cdcclk_ctl_state.tx_mclk_requested = 0; - } -} -static int get_msm_cdcclk_ctl_gpios(struct platform_device *pdev) -{ - int rc = 0; - struct resource *res; - - /* Claim all of the GPIOs. */ - res = platform_get_resource_byname(pdev, IORESOURCE_IO, - "msm_snddev_rx_mclk"); - if (!res) { - pr_err("%s: failed to get gpio MSM SNDDEV RX\n", __func__); - return -ENODEV; - } - the_msm_cdcclk_ctl_state.rx_mclk = res->start; - the_msm_cdcclk_ctl_state.rx_mclk_requested = 0; - - res = platform_get_resource_byname(pdev, IORESOURCE_IO, - "msm_snddev_tx_mclk"); - if (!res) { - pr_err("%s: failed to get gpio MSM SNDDEV TX\n", __func__); - return -ENODEV; - } - the_msm_cdcclk_ctl_state.tx_mclk = res->start; - the_msm_cdcclk_ctl_state.tx_mclk_requested = 0; - - return rc; -} -static int msm_cdcclk_ctl_probe(struct platform_device *pdev) -{ - int rc = 0; - - rc = get_msm_cdcclk_ctl_gpios(pdev); - if (rc < 0) { - pr_err("%s: GPIO configuration failed\n", __func__); - return -ENODEV; - } - return rc; -} -static struct platform_driver msm_cdcclk_ctl_driver = { - .probe = msm_cdcclk_ctl_probe, - .driver = { .name = "msm_cdcclk_ctl"} -}; - -static int snddev_icodec_open_lb(struct snddev_icodec_state *icodec) -{ - int trc; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - /* Voting for low power is ok here as all use cases are - * supported in low power mode. - */ - if (drv->snddev_vreg) - vreg_mode_vote(drv->snddev_vreg, 1, - SNDDEV_LOW_POWER_MODE); - - if (icodec->data->voltage_on) - icodec->data->voltage_on(); - - trc = adie_codec_open(icodec->data->profile, &icodec->adie_path); - if (IS_ERR_VALUE(trc)) - pr_err("%s: adie codec open failed\n", __func__); - else - adie_codec_setpath(icodec->adie_path, - icodec->sample_rate, 256); - - if (icodec->adie_path) - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_ANALOG_READY); - - if (icodec->data->pamp_on) - icodec->data->pamp_on(); - - icodec->enabled = 1; - - return 0; -} -static int initialize_msm_icodec_gpios(struct platform_device *pdev) -{ - int rc = 0; - struct resource *res; - int i = 0; - int *reg_defaults = pdev->dev.platform_data; - - while ((res = platform_get_resource(pdev, IORESOURCE_IO, i))) { - rc = gpio_request(res->start, res->name); - if (rc) { - pr_err("%s: icodec gpio %d request failed\n", __func__, - res->start); - goto err; - } else { - /* This platform data structure only works if all gpio - * resources are to be used only in output mode. - * If gpio resources are added which are to be used in - * input mode, then the platform data structure will - * have to be changed. - */ - - gpio_direction_output(res->start, reg_defaults[i]); - gpio_free(res->start); - } - i++; - } -err: - return rc; -} -static int msm_icodec_gpio_probe(struct platform_device *pdev) -{ - int rc = 0; - - rc = initialize_msm_icodec_gpios(pdev); - if (rc < 0) { - pr_err("%s: GPIO configuration failed\n", __func__); - return -ENODEV; - } - return rc; -} -static struct platform_driver msm_icodec_gpio_driver = { - .probe = msm_icodec_gpio_probe, - .driver = { .name = "msm_icodec_gpio"} -}; - -static int snddev_icodec_open_rx(struct snddev_icodec_state *icodec) -{ - int trc; - int afe_channel_mode; - union afe_port_config afe_config; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - pm_qos_update_request(&drv->rx_pm_qos_req, - msm_cpuidle_get_deep_idle_latency()); - - if (drv->snddev_vreg) { - if (!strcmp(icodec->data->name, "headset_stereo_rx")) - vreg_mode_vote(drv->snddev_vreg, 1, - SNDDEV_LOW_POWER_MODE); - else - vreg_mode_vote(drv->snddev_vreg, 1, - SNDDEV_HIGH_POWER_MODE); - } - msm_snddev_rx_mclk_request(); - - drv->rx_osrclk = clk_get_sys(NULL, "i2s_spkr_osr_clk"); - if (IS_ERR(drv->rx_osrclk)) - pr_err("%s master clock Error\n", __func__); - - trc = clk_set_rate(drv->rx_osrclk, - SNDDEV_ICODEC_CLK_RATE(icodec->sample_rate)); - if (IS_ERR_VALUE(trc)) { - pr_err("ERROR setting m clock1\n"); - goto error_invalid_freq; - } - - clk_prepare_enable(drv->rx_osrclk); - drv->rx_bitclk = clk_get_sys(NULL, "i2s_spkr_bit_clk"); - if (IS_ERR(drv->rx_bitclk)) - pr_err("%s clock Error\n", __func__); - - /* Master clock = Sample Rate * OSR rate bit clock - * OSR Rate bit clock = bit/sample * channel master - * clock / bit clock = divider value = 8 - */ - if (msm_codec_i2s_slave_mode) { - pr_info("%s: configuring bit clock for slave mode\n", - __func__); - trc = clk_set_rate(drv->rx_bitclk, 0); - } else - trc = clk_set_rate(drv->rx_bitclk, 8); - - if (IS_ERR_VALUE(trc)) { - pr_err("ERROR setting m clock1\n"); - goto error_adie; - } - clk_prepare_enable(drv->rx_bitclk); - - if (icodec->data->voltage_on) - icodec->data->voltage_on(); - - /* Configure ADIE */ - trc = adie_codec_open(icodec->data->profile, &icodec->adie_path); - if (IS_ERR_VALUE(trc)) - pr_err("%s: adie codec open failed\n", __func__); - else - adie_codec_setpath(icodec->adie_path, - icodec->sample_rate, 256); - /* OSR default to 256, can be changed for power optimization - * If OSR is to be changed, need clock API for setting the divider - */ - - switch (icodec->data->channel_mode) { - case 2: - afe_channel_mode = MSM_AFE_STEREO; - break; - case 1: - default: - afe_channel_mode = MSM_AFE_MONO; - break; - } - afe_config.mi2s.channel = afe_channel_mode; - afe_config.mi2s.bitwidth = 16; - afe_config.mi2s.line = 1; - afe_config.mi2s.format = MSM_AFE_I2S_FORMAT_LPCM; - if (msm_codec_i2s_slave_mode) - afe_config.mi2s.ws = 0; - else - afe_config.mi2s.ws = 1; - - trc = afe_open(icodec->data->copp_id, &afe_config, icodec->sample_rate); - - if (trc < 0) - pr_err("%s: afe open failed, trc = %d\n", __func__, trc); - - /* Enable ADIE */ - if (icodec->adie_path) { - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_READY); - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_ANALOG_READY); - } - - if (msm_codec_i2s_slave_mode) - adie_codec_set_master_mode(icodec->adie_path, 1); - else - adie_codec_set_master_mode(icodec->adie_path, 0); - - /* Enable power amplifier */ - if (icodec->data->pamp_on) { - if (icodec->data->pamp_on()) { - pr_err("%s: Error turning on rx power\n", __func__); - goto error_pamp; - } - } - - icodec->enabled = 1; - - pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); - return 0; - -error_pamp: -error_adie: - clk_disable_unprepare(drv->rx_osrclk); -error_invalid_freq: - - pr_err("%s: encounter error\n", __func__); - - pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); - return -ENODEV; -} - -static int snddev_icodec_open_tx(struct snddev_icodec_state *icodec) -{ - int trc; - int afe_channel_mode; - union afe_port_config afe_config; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;; - - pm_qos_update_request(&drv->tx_pm_qos_req, - msm_cpuidle_get_deep_idle_latency()); - - if (drv->snddev_vreg) - vreg_mode_vote(drv->snddev_vreg, 1, SNDDEV_HIGH_POWER_MODE); - - /* Reuse pamp_on for TX platform-specific setup */ - if (icodec->data->pamp_on) { - if (icodec->data->pamp_on()) { - pr_err("%s: Error turning on tx power\n", __func__); - goto error_pamp; - } - } - - msm_snddev_tx_mclk_request(); - - drv->tx_osrclk = clk_get_sys(NULL, "i2s_mic_osr_clk"); - if (IS_ERR(drv->tx_osrclk)) - pr_err("%s master clock Error\n", __func__); - - trc = clk_set_rate(drv->tx_osrclk, - SNDDEV_ICODEC_CLK_RATE(icodec->sample_rate)); - if (IS_ERR_VALUE(trc)) { - pr_err("ERROR setting m clock1\n"); - goto error_invalid_freq; - } - - clk_prepare_enable(drv->tx_osrclk); - drv->tx_bitclk = clk_get_sys(NULL, "i2s_mic_bit_clk"); - if (IS_ERR(drv->tx_bitclk)) - pr_err("%s clock Error\n", __func__); - - /* Master clock = Sample Rate * OSR rate bit clock - * OSR Rate bit clock = bit/sample * channel master - * clock / bit clock = divider value = 8 - */ - if (msm_codec_i2s_slave_mode) { - pr_info("%s: configuring bit clock for slave mode\n", - __func__); - trc = clk_set_rate(drv->tx_bitclk, 0); - } else - trc = clk_set_rate(drv->tx_bitclk, 8); - - clk_prepare_enable(drv->tx_bitclk); - - /* Enable ADIE */ - trc = adie_codec_open(icodec->data->profile, &icodec->adie_path); - if (IS_ERR_VALUE(trc)) - pr_err("%s: adie codec open failed\n", __func__); - else - adie_codec_setpath(icodec->adie_path, - icodec->sample_rate, 256); - - switch (icodec->data->channel_mode) { - case 2: - afe_channel_mode = MSM_AFE_STEREO; - break; - case 1: - default: - afe_channel_mode = MSM_AFE_MONO; - break; - } - afe_config.mi2s.channel = afe_channel_mode; - afe_config.mi2s.bitwidth = 16; - afe_config.mi2s.line = 1; - afe_config.mi2s.format = MSM_AFE_I2S_FORMAT_LPCM; - if (msm_codec_i2s_slave_mode) - afe_config.mi2s.ws = 0; - else - afe_config.mi2s.ws = 1; - - trc = afe_open(icodec->data->copp_id, &afe_config, icodec->sample_rate); - - if (icodec->adie_path) { - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_READY); - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_ANALOG_READY); - } - - if (msm_codec_i2s_slave_mode) - adie_codec_set_master_mode(icodec->adie_path, 1); - else - adie_codec_set_master_mode(icodec->adie_path, 0); - - icodec->enabled = 1; - - pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); - return 0; - -error_invalid_freq: - - if (icodec->data->pamp_off) - icodec->data->pamp_off(); - - pr_err("%s: encounter error\n", __func__); -error_pamp: - pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); - return -ENODEV; -} - -static int snddev_icodec_close_lb(struct snddev_icodec_state *icodec) -{ - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - /* Disable power amplifier */ - if (icodec->data->pamp_off) - icodec->data->pamp_off(); - - if (drv->snddev_vreg) - vreg_mode_vote(drv->snddev_vreg, 0, SNDDEV_LOW_POWER_MODE); - - if (icodec->adie_path) { - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_OFF); - adie_codec_close(icodec->adie_path); - icodec->adie_path = NULL; - } - - if (icodec->data->voltage_off) - icodec->data->voltage_off(); - - return 0; -} - -static int snddev_icodec_close_rx(struct snddev_icodec_state *icodec) -{ - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - pm_qos_update_request(&drv->rx_pm_qos_req, - msm_cpuidle_get_deep_idle_latency()); - - if (drv->snddev_vreg) - vreg_mode_vote(drv->snddev_vreg, 0, SNDDEV_HIGH_POWER_MODE); - - /* Disable power amplifier */ - if (icodec->data->pamp_off) - icodec->data->pamp_off(); - - /* Disable ADIE */ - if (icodec->adie_path) { - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_OFF); - adie_codec_close(icodec->adie_path); - icodec->adie_path = NULL; - } - - afe_close(icodec->data->copp_id); - - if (icodec->data->voltage_off) - icodec->data->voltage_off(); - - clk_disable_unprepare(drv->rx_bitclk); - clk_disable_unprepare(drv->rx_osrclk); - - msm_snddev_rx_mclk_free(); - - icodec->enabled = 0; - - pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE); - return 0; -} - -static int snddev_icodec_close_tx(struct snddev_icodec_state *icodec) -{ - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - pm_qos_update_request(&drv->tx_pm_qos_req, - msm_cpuidle_get_deep_idle_latency()); - - if (drv->snddev_vreg) - vreg_mode_vote(drv->snddev_vreg, 0, SNDDEV_HIGH_POWER_MODE); - - /* Disable ADIE */ - if (icodec->adie_path) { - adie_codec_proceed_stage(icodec->adie_path, - ADIE_CODEC_DIGITAL_OFF); - adie_codec_close(icodec->adie_path); - icodec->adie_path = NULL; - } - - afe_close(icodec->data->copp_id); - - clk_disable_unprepare(drv->tx_bitclk); - clk_disable_unprepare(drv->tx_osrclk); - - msm_snddev_tx_mclk_free(); - - /* Reuse pamp_off for TX platform-specific setup */ - if (icodec->data->pamp_off) - icodec->data->pamp_off(); - - icodec->enabled = 0; - - pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE); - return 0; -} - -static int snddev_icodec_set_device_volume_impl( - struct msm_snddev_info *dev_info, u32 volume) -{ - struct snddev_icodec_state *icodec; - - int rc = 0; - - icodec = dev_info->private_data; - - if (icodec->data->dev_vol_type & SNDDEV_DEV_VOL_DIGITAL) { - - rc = adie_codec_set_device_digital_volume(icodec->adie_path, - icodec->data->channel_mode, volume); - if (rc < 0) { - pr_err("%s: unable to set_device_digital_volume for" - "%s volume in percentage = %u\n", - __func__, dev_info->name, volume); - return rc; - } - - } else if (icodec->data->dev_vol_type & SNDDEV_DEV_VOL_ANALOG) { - rc = adie_codec_set_device_analog_volume(icodec->adie_path, - icodec->data->channel_mode, volume); - if (rc < 0) { - pr_err("%s: unable to set_device_analog_volume for" - "%s volume in percentage = %u\n", - __func__, dev_info->name, volume); - return rc; - } - } else { - pr_err("%s: Invalid device volume control\n", __func__); - return -EPERM; - } - return rc; -} - -static int snddev_icodec_open(struct msm_snddev_info *dev_info) -{ - int rc = 0; - struct snddev_icodec_state *icodec; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - if (!dev_info) { - rc = -EINVAL; - goto error; - } - - icodec = dev_info->private_data; - - if (icodec->data->capability & SNDDEV_CAP_RX) { - mutex_lock(&drv->rx_lock); - if (drv->rx_active) { - mutex_unlock(&drv->rx_lock); - pr_err("%s: rx_active is set, return EBUSY\n", - __func__); - rc = -EBUSY; - goto error; - } - rc = snddev_icodec_open_rx(icodec); - - if (!IS_ERR_VALUE(rc)) { - if ((icodec->data->dev_vol_type & ( - SNDDEV_DEV_VOL_DIGITAL | - SNDDEV_DEV_VOL_ANALOG))) - rc = snddev_icodec_set_device_volume_impl( - dev_info, dev_info->dev_volume); - if (!IS_ERR_VALUE(rc)) - drv->rx_active = 1; - else - pr_err("%s: set_device_volume_impl" - " error(rx) = %d\n", __func__, rc); - } - mutex_unlock(&drv->rx_lock); - } else if (icodec->data->capability & SNDDEV_CAP_LB) { - mutex_lock(&drv->lb_lock); - rc = snddev_icodec_open_lb(icodec); - - if (!IS_ERR_VALUE(rc)) { - if ((icodec->data->dev_vol_type & ( - SNDDEV_DEV_VOL_DIGITAL | - SNDDEV_DEV_VOL_ANALOG))) - rc = snddev_icodec_set_device_volume_impl( - dev_info, dev_info->dev_volume); - } - - mutex_unlock(&drv->lb_lock); - } else { - mutex_lock(&drv->tx_lock); - if (drv->tx_active) { - mutex_unlock(&drv->tx_lock); - pr_err("%s: tx_active is set, return EBUSY\n", - __func__); - rc = -EBUSY; - goto error; - } - rc = snddev_icodec_open_tx(icodec); - - if (!IS_ERR_VALUE(rc)) { - if ((icodec->data->dev_vol_type & ( - SNDDEV_DEV_VOL_DIGITAL | - SNDDEV_DEV_VOL_ANALOG))) - rc = snddev_icodec_set_device_volume_impl( - dev_info, dev_info->dev_volume); - if (!IS_ERR_VALUE(rc)) - drv->tx_active = 1; - else - pr_err("%s: set_device_volume_impl" - " error(tx) = %d\n", __func__, rc); - } - mutex_unlock(&drv->tx_lock); - } -error: - return rc; -} - -static int snddev_icodec_close(struct msm_snddev_info *dev_info) -{ - int rc = 0; - struct snddev_icodec_state *icodec; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - if (!dev_info) { - rc = -EINVAL; - goto error; - } - - icodec = dev_info->private_data; - - if (icodec->data->capability & SNDDEV_CAP_RX) { - mutex_lock(&drv->rx_lock); - if (!drv->rx_active) { - mutex_unlock(&drv->rx_lock); - pr_err("%s: rx_active not set, return\n", __func__); - rc = -EPERM; - goto error; - } - rc = snddev_icodec_close_rx(icodec); - if (!IS_ERR_VALUE(rc)) - drv->rx_active = 0; - else - pr_err("%s: close rx failed, rc = %d\n", __func__, rc); - mutex_unlock(&drv->rx_lock); - } else if (icodec->data->capability & SNDDEV_CAP_LB) { - mutex_lock(&drv->lb_lock); - rc = snddev_icodec_close_lb(icodec); - mutex_unlock(&drv->lb_lock); - } else { - mutex_lock(&drv->tx_lock); - if (!drv->tx_active) { - mutex_unlock(&drv->tx_lock); - pr_err("%s: tx_active not set, return\n", __func__); - rc = -EPERM; - goto error; - } - rc = snddev_icodec_close_tx(icodec); - if (!IS_ERR_VALUE(rc)) - drv->tx_active = 0; - else - pr_err("%s: close tx failed, rc = %d\n", __func__, rc); - mutex_unlock(&drv->tx_lock); - } - -error: - return rc; -} - -static int snddev_icodec_check_freq(u32 req_freq) -{ - int rc = -EINVAL; - - if ((req_freq != 0) && (req_freq >= 8000) && (req_freq <= 48000)) { - if ((req_freq == 8000) || (req_freq == 11025) || - (req_freq == 12000) || (req_freq == 16000) || - (req_freq == 22050) || (req_freq == 24000) || - (req_freq == 32000) || (req_freq == 44100) || - (req_freq == 48000)) { - rc = 0; - } else - pr_info("%s: Unsupported Frequency:%d\n", __func__, - req_freq); - } - return rc; -} - -static int snddev_icodec_set_freq(struct msm_snddev_info *dev_info, u32 rate) -{ - int rc; - struct snddev_icodec_state *icodec; - - if (!dev_info) { - rc = -EINVAL; - goto error; - } - - icodec = dev_info->private_data; - if (adie_codec_freq_supported(icodec->data->profile, rate) != 0) { - pr_err("%s: adie_codec_freq_supported() failed\n", __func__); - rc = -EINVAL; - goto error; - } else { - if (snddev_icodec_check_freq(rate) != 0) { - pr_err("%s: check_freq failed\n", __func__); - rc = -EINVAL; - goto error; - } else - icodec->sample_rate = rate; - } - - if (icodec->enabled) { - snddev_icodec_close(dev_info); - snddev_icodec_open(dev_info); - } - - return icodec->sample_rate; - -error: - return rc; -} - -static int snddev_icodec_enable_sidetone(struct msm_snddev_info *dev_info, - u32 enable, uint16_t gain) -{ - int rc = 0; - struct snddev_icodec_state *icodec; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - if (!dev_info) { - pr_err("invalid dev_info\n"); - rc = -EINVAL; - goto error; - } - - icodec = dev_info->private_data; - - if (icodec->data->capability & SNDDEV_CAP_RX) { - mutex_lock(&drv->rx_lock); - if (!drv->rx_active || !dev_info->opened) { - pr_err("dev not active\n"); - rc = -EPERM; - mutex_unlock(&drv->rx_lock); - goto error; - } - rc = afe_sidetone(PRIMARY_I2S_TX, PRIMARY_I2S_RX, enable, gain); - if (rc < 0) - pr_err("%s: AFE command sidetone failed\n", __func__); - mutex_unlock(&drv->rx_lock); - } else { - rc = -EINVAL; - pr_err("rx device only\n"); - } - -error: - return rc; - -} -static int snddev_icodec_enable_anc(struct msm_snddev_info *dev_info, - u32 enable) -{ - int rc = 0; - struct adie_codec_anc_data *reg_writes; - struct acdb_cal_block cal_block; - struct snddev_icodec_state *icodec; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - - pr_info("%s: enable=%d\n", __func__, enable); - - if (!dev_info) { - pr_err("invalid dev_info\n"); - rc = -EINVAL; - goto error; - } - icodec = dev_info->private_data; - - if ((icodec->data->capability & SNDDEV_CAP_RX) && - (icodec->data->capability & SNDDEV_CAP_ANC)) { - mutex_lock(&drv->rx_lock); - - if (!drv->rx_active || !dev_info->opened) { - pr_err("dev not active\n"); - rc = -EPERM; - mutex_unlock(&drv->rx_lock); - goto error; - } - if (enable) { - get_anc_cal(&cal_block); - reg_writes = (struct adie_codec_anc_data *) - cal_block.cal_kvaddr; - - if (reg_writes == NULL) { - pr_err("error, no calibration data\n"); - rc = -1; - mutex_unlock(&drv->rx_lock); - goto error; - } - - rc = adie_codec_enable_anc(icodec->adie_path, - 1, reg_writes); - } else { - rc = adie_codec_enable_anc(icodec->adie_path, - 0, NULL); - } - mutex_unlock(&drv->rx_lock); - } else { - rc = -EINVAL; - pr_err("rx and ANC device only\n"); - } - -error: - return rc; - -} - -int snddev_icodec_set_device_volume(struct msm_snddev_info *dev_info, - u32 volume) -{ - struct snddev_icodec_state *icodec; - struct mutex *lock; - struct snddev_icodec_drv_state *drv = &snddev_icodec_drv; - int rc = -EPERM; - - if (!dev_info) { - pr_info("%s : device not intilized.\n", __func__); - return -EINVAL; - } - - icodec = dev_info->private_data; - - if (!(icodec->data->dev_vol_type & (SNDDEV_DEV_VOL_DIGITAL - | SNDDEV_DEV_VOL_ANALOG))) { - - pr_info("%s : device %s does not support device volume " - "control.", __func__, dev_info->name); - return -EPERM; - } - dev_info->dev_volume = volume; - - if (icodec->data->capability & SNDDEV_CAP_RX) - lock = &drv->rx_lock; - else if (icodec->data->capability & SNDDEV_CAP_LB) - lock = &drv->lb_lock; - else - lock = &drv->tx_lock; - - mutex_lock(lock); - - rc = snddev_icodec_set_device_volume_impl(dev_info, - dev_info->dev_volume); - mutex_unlock(lock); - return rc; -} - -static int snddev_icodec_probe(struct platform_device *pdev) -{ - int rc = 0; - struct snddev_icodec_data *pdata; - struct msm_snddev_info *dev_info; - struct snddev_icodec_state *icodec; - - if (!pdev || !pdev->dev.platform_data) { - printk(KERN_ALERT "Invalid caller\n"); - rc = -1; - goto error; - } - pdata = pdev->dev.platform_data; - if ((pdata->capability & SNDDEV_CAP_RX) && - (pdata->capability & SNDDEV_CAP_TX)) { - pr_err("%s: invalid device data either RX or TX\n", __func__); - goto error; - } - icodec = kzalloc(sizeof(struct snddev_icodec_state), GFP_KERNEL); - if (!icodec) { - rc = -ENOMEM; - goto error; - } - dev_info = kmalloc(sizeof(struct msm_snddev_info), GFP_KERNEL); - if (!dev_info) { - kfree(icodec); - rc = -ENOMEM; - goto error; - } - - dev_info->name = pdata->name; - dev_info->copp_id = pdata->copp_id; - dev_info->private_data = (void *) icodec; - dev_info->dev_ops.open = snddev_icodec_open; - dev_info->dev_ops.close = snddev_icodec_close; - dev_info->dev_ops.set_freq = snddev_icodec_set_freq; - dev_info->dev_ops.set_device_volume = snddev_icodec_set_device_volume; - dev_info->capability = pdata->capability; - dev_info->opened = 0; - msm_snddev_register(dev_info); - icodec->data = pdata; - icodec->sample_rate = pdata->default_sample_rate; - dev_info->sample_rate = pdata->default_sample_rate; - dev_info->channel_mode = pdata->channel_mode; - if (pdata->capability & SNDDEV_CAP_RX) - dev_info->dev_ops.enable_sidetone = - snddev_icodec_enable_sidetone; - else - dev_info->dev_ops.enable_sidetone = NULL; - - if (pdata->capability & SNDDEV_CAP_ANC) { - dev_info->dev_ops.enable_anc = - snddev_icodec_enable_anc; - } else { - dev_info->dev_ops.enable_anc = NULL; - } -error: - return rc; -} - -static int snddev_icodec_remove(struct platform_device *pdev) -{ - return 0; -} - -static struct platform_driver snddev_icodec_driver = { - .probe = snddev_icodec_probe, - .remove = snddev_icodec_remove, - .driver = { .name = "snddev_icodec" } -}; - -module_param(msm_codec_i2s_slave_mode, bool, 0); -MODULE_PARM_DESC(msm_codec_i2s_slave_mode, "Set MSM to I2S slave clock mode"); - -static int __init snddev_icodec_init(void) -{ - s32 rc; - struct snddev_icodec_drv_state *icodec_drv = &snddev_icodec_drv; - - rc = platform_driver_register(&snddev_icodec_driver); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: platform_driver_register for snddev icodec failed\n", - __func__); - goto error_snddev_icodec_driver; - } - - rc = platform_driver_register(&msm_cdcclk_ctl_driver); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: platform_driver_register for msm snddev failed\n", - __func__); - goto error_msm_cdcclk_ctl_driver; - } - - rc = platform_driver_register(&msm_icodec_gpio_driver); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: platform_driver_register for msm snddev gpio failed\n", - __func__); - goto error_msm_icodec_gpio_driver; - } - - mutex_init(&icodec_drv->rx_lock); - mutex_init(&icodec_drv->lb_lock); - mutex_init(&icodec_drv->tx_lock); - icodec_drv->rx_active = 0; - icodec_drv->tx_active = 0; - icodec_drv->snddev_vreg = vreg_init(); - - pm_qos_add_request(&icodec_drv->tx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); - pm_qos_add_request(&icodec_drv->rx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); - return 0; -error_msm_icodec_gpio_driver: - platform_driver_unregister(&msm_cdcclk_ctl_driver); -error_msm_cdcclk_ctl_driver: - platform_driver_unregister(&snddev_icodec_driver); -error_snddev_icodec_driver: - return -ENODEV; -} - -static void __exit snddev_icodec_exit(void) -{ - struct snddev_icodec_drv_state *icodec_drv = &snddev_icodec_drv; - - platform_driver_unregister(&snddev_icodec_driver); - platform_driver_unregister(&msm_cdcclk_ctl_driver); - platform_driver_unregister(&msm_icodec_gpio_driver); - - clk_put(icodec_drv->rx_osrclk); - clk_put(icodec_drv->tx_osrclk); - if (icodec_drv->snddev_vreg) { - vreg_deinit(icodec_drv->snddev_vreg); - icodec_drv->snddev_vreg = NULL; - } - return; -} - -module_init(snddev_icodec_init); -module_exit(snddev_icodec_exit); - -MODULE_DESCRIPTION("ICodec Sound Device driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_icodec.h b/arch/arm/mach-msm/qdsp6v2/snddev_icodec.h deleted file mode 100644 index 3efa84b1da23ecb64d9b1605f8c19ba92b8f08ae..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_icodec.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __MACH_QDSP6V2_SNDDEV_ICODEC_H -#define __MACH_QDSP6V2_SNDDEV_ICODEC_H -#include -#include -#include - -struct snddev_icodec_data { - u32 capability; /* RX or TX */ - const char *name; - u32 copp_id; /* audpp routing */ - /* Adie profile */ - struct adie_codec_dev_profile *profile; - /* Afe setting */ - u8 channel_mode; - u32 default_sample_rate; - int (*pamp_on) (void); - void (*pamp_off) (void); - int (*voltage_on) (void); - void (*voltage_off) (void); - u32 dev_vol_type; -}; - -#endif diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_mi2s.c b/arch/arm/mach-msm/qdsp6v2/snddev_mi2s.c deleted file mode 100644 index f5b073a1be98d9d00e599086486bef77791cfbd0..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_mi2s.c +++ /dev/null @@ -1,464 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "snddev_mi2s.h" - -#define SNDDEV_MI2S_PCM_SZ 32 /* 16 bit / sample stereo mode */ -#define SNDDEV_MI2S_MUL_FACTOR 3 /* Multi by 8 Shift by 3 */ -#define SNDDEV_MI2S_CLK_RATE(freq) \ - (((freq) * (SNDDEV_MI2S_PCM_SZ)) << (SNDDEV_MI2S_MUL_FACTOR)) - - -/* Global state for the driver */ -struct snddev_mi2s_drv_state { - - struct clk *tx_osrclk; - struct clk *tx_bitclk; - int mi2s_ws; - int mi2s_mclk; - int mi2s_sclk; - int fm_mi2s_sd; -}; - -static struct snddev_mi2s_drv_state snddev_mi2s_drv; - -static struct msm_mi2s_gpio_data *mi2s_gpio; - -static int mi2s_gpios_request(void) -{ - int rc = 0; - - pr_debug("%s\n", __func__); - rc = gpio_request(snddev_mi2s_drv.mi2s_ws, "MI2S_WS"); - if (rc < 0) { - pr_err("%s: GPIO request for MI2S_WS failed\n", __func__); - return rc; - } - - rc = gpio_request(snddev_mi2s_drv.mi2s_sclk, "MI2S_SCLK"); - if (rc < 0) { - pr_err("%s: GPIO request for MI2S_SCLK failed\n", __func__); - gpio_free(snddev_mi2s_drv.mi2s_sclk); - return rc; - } - - rc = gpio_request(snddev_mi2s_drv.mi2s_mclk, "MI2S_MCLK"); - if (rc < 0) { - pr_err("%s: GPIO request for MI2S_MCLK failed\n", - __func__); - gpio_free(snddev_mi2s_drv.mi2s_ws); - gpio_free(snddev_mi2s_drv.mi2s_sclk); - return rc; - } - - rc = gpio_request(snddev_mi2s_drv.fm_mi2s_sd, "FM_MI2S_SD"); - if (rc < 0) { - pr_err("%s: GPIO request for FM_MI2S_SD failed\n", - __func__); - gpio_free(snddev_mi2s_drv.mi2s_ws); - gpio_free(snddev_mi2s_drv.mi2s_sclk); - gpio_free(snddev_mi2s_drv.mi2s_mclk); - return rc; - } - - return rc; -} - -static void mi2s_gpios_free(void) -{ - pr_debug("%s\n", __func__); - gpio_free(snddev_mi2s_drv.mi2s_ws); - gpio_free(snddev_mi2s_drv.mi2s_sclk); - gpio_free(snddev_mi2s_drv.mi2s_mclk); - gpio_free(snddev_mi2s_drv.fm_mi2s_sd); -} - -static int mi2s_get_gpios(struct platform_device *pdev) -{ - int rc = 0; - struct resource *res; - - /* Claim all of the GPIOs. */ - res = platform_get_resource_byname(pdev, IORESOURCE_IO, "mi2s_ws"); - if (!res) { - pr_err("%s: failed to get gpio MI2S_WS\n", __func__); - return -ENODEV; - } - - snddev_mi2s_drv.mi2s_ws = res->start; - - res = platform_get_resource_byname(pdev, IORESOURCE_IO, "mi2s_sclk"); - if (!res) { - pr_err("%s: failed to get gpio MI2S_SCLK\n", __func__); - return -ENODEV; - } - - snddev_mi2s_drv.mi2s_sclk = res->start; - - res = platform_get_resource_byname(pdev, IORESOURCE_IO, - "mi2s_mclk"); - if (!res) { - pr_err("%s: failed to get gpio MI2S_MCLK\n", __func__); - return -ENODEV; - } - - snddev_mi2s_drv.mi2s_mclk = res->start; - - res = platform_get_resource_byname(pdev, IORESOURCE_IO, - "fm_mi2s_sd"); - if (!res) { - pr_err("%s: failed to get gpio FM_MI2S_SD\n", __func__); - return -ENODEV; - } - - snddev_mi2s_drv.fm_mi2s_sd = res->start; - - return rc; -} - -static int mi2s_fm_probe(struct platform_device *pdev) -{ - int rc = 0; - - rc = mi2s_get_gpios(pdev); - if (rc < 0) { - pr_err("%s: GPIO configuration failed\n", __func__); - return rc; - } - - mi2s_gpio = (struct msm_mi2s_gpio_data *)(pdev->dev.platform_data); - return rc; -} - -static struct platform_driver mi2s_fm_driver = { - .probe = mi2s_fm_probe, - .driver = { .name = "msm_mi2s"} -}; - -static u8 num_of_bits_set(u8 sd_line_mask) -{ - u8 num_bits_set = 0; - - while (sd_line_mask) { - - if (sd_line_mask & 1) - num_bits_set++; - sd_line_mask = sd_line_mask >> 1; - } - return num_bits_set; -} - -static int snddev_mi2s_open(struct msm_snddev_info *dev_info) -{ - int rc = 0; - union afe_port_config afe_config; - u8 channels; - u8 num_of_sd_lines = 0; - struct snddev_mi2s_drv_state *drv = &snddev_mi2s_drv; - struct snddev_mi2s_data *snddev_mi2s_data = dev_info->private_data; - - if (!dev_info) { - pr_err("%s: msm_snddev_info is null\n", __func__); - return -EINVAL; - } - - /* set up osr clk */ - drv->tx_osrclk = clk_get_sys(NULL, "mi2s_osr_clk"); - if (IS_ERR(drv->tx_osrclk)) - pr_err("%s master clock Error\n", __func__); - - rc = clk_set_rate(drv->tx_osrclk, - SNDDEV_MI2S_CLK_RATE(dev_info->sample_rate)); - if (IS_ERR_VALUE(rc)) { - pr_err("ERROR setting osr clock\n"); - return -ENODEV; - } - clk_prepare_enable(drv->tx_osrclk); - - /* set up bit clk */ - drv->tx_bitclk = clk_get_sys(NULL, "mi2s_bit_clk"); - if (IS_ERR(drv->tx_bitclk)) - pr_err("%s clock Error\n", __func__); - - rc = clk_set_rate(drv->tx_bitclk, 8); - if (IS_ERR_VALUE(rc)) { - pr_err("ERROR setting bit clock\n"); - clk_disable_unprepare(drv->tx_osrclk); - return -ENODEV; - } - clk_prepare_enable(drv->tx_bitclk); - - afe_config.mi2s.bitwidth = 16; - - if (snddev_mi2s_data->channel_mode == 1) - channels = AFE_MI2S_MONO; - else if (snddev_mi2s_data->channel_mode == 2) - channels = AFE_MI2S_STEREO; - else if (snddev_mi2s_data->channel_mode == 4) - channels = AFE_MI2S_4CHANNELS; - else if (snddev_mi2s_data->channel_mode == 6) - channels = AFE_MI2S_6CHANNELS; - else if (snddev_mi2s_data->channel_mode == 8) - channels = AFE_MI2S_8CHANNELS; - else { - pr_err("ERROR: Invalid MI2S channel mode\n"); - goto error_invalid_data; - } - - num_of_sd_lines = num_of_bits_set(snddev_mi2s_data->sd_lines); - - switch (num_of_sd_lines) { - case 1: - switch (snddev_mi2s_data->sd_lines) { - case MI2S_SD0: - afe_config.mi2s.line = AFE_I2S_SD0; - break; - case MI2S_SD1: - afe_config.mi2s.line = AFE_I2S_SD1; - break; - case MI2S_SD2: - afe_config.mi2s.line = AFE_I2S_SD2; - break; - case MI2S_SD3: - afe_config.mi2s.line = AFE_I2S_SD3; - break; - default: - pr_err("%s: invalid SD line\n", - __func__); - goto error_invalid_data; - } - if (channels != AFE_MI2S_STEREO && - channels != AFE_MI2S_MONO) { - pr_err("%s: for one SD line, channel " - "must be 1 or 2\n", __func__); - goto error_invalid_data; - } - afe_config.mi2s.channel = channels; - break; - case 2: - switch (snddev_mi2s_data->sd_lines) { - case MI2S_SD0 | MI2S_SD1: - afe_config.mi2s.line = AFE_I2S_QUAD01; - break; - case MI2S_SD2 | MI2S_SD3: - afe_config.mi2s.line = AFE_I2S_QUAD23; - break; - default: - pr_err("%s: invalid SD line\n", - __func__); - goto error_invalid_data; - } - if (channels != AFE_MI2S_4CHANNELS) { - pr_err("%s: for two SD lines, channel " - "must be 1 and 2 or 3 and 4\n", __func__); - goto error_invalid_data; - } - break; - case 3: - switch (snddev_mi2s_data->sd_lines) { - case MI2S_SD0 | MI2S_SD1 | MI2S_SD2: - afe_config.mi2s.line = AFE_I2S_6CHS; - break; - default: - pr_err("%s: invalid SD lines\n", - __func__); - goto error_invalid_data; - } - if (channels != AFE_MI2S_6CHANNELS) { - pr_err("%s: for three SD lines, lines " - "must be 1, 2, and 3\n", __func__); - goto error_invalid_data; - } - break; - case 4: - switch (snddev_mi2s_data->sd_lines) { - case MI2S_SD0 | MI2S_SD1 | MI2S_SD2 | MI2S_SD3: - afe_config.mi2s.line = AFE_I2S_8CHS; - break; - default: - pr_err("%s: invalid SD lines\n", - __func__); - goto error_invalid_data; - } - - if (channels != AFE_MI2S_8CHANNELS) { - pr_err("%s: for four SD lines, lines " - "must be 1, 2, 3, and 4\n", __func__); - goto error_invalid_data; - } - break; - default: - pr_err("%s: invalid SD lines\n", __func__); - goto error_invalid_data; - } - afe_config.mi2s.ws = 1; - afe_config.mi2s.format = MSM_AFE_I2S_FORMAT_LPCM; - - rc = afe_open(snddev_mi2s_data->copp_id, &afe_config, - dev_info->sample_rate); - - if (rc < 0) { - pr_err("%s: afe_open failed\n", __func__); - goto error_invalid_data; - } - - /*enable fm gpio here*/ - rc = mi2s_gpios_request(); - if (rc < 0) { - pr_err("%s: GPIO request failed\n", __func__); - return rc; - } - - pr_info("%s: afe_open done\n", __func__); - - return rc; - -error_invalid_data: - - clk_disable_unprepare(drv->tx_bitclk); - clk_disable_unprepare(drv->tx_osrclk); - return -EINVAL; -} - -static int snddev_mi2s_close(struct msm_snddev_info *dev_info) -{ - - struct snddev_mi2s_drv_state *mi2s_drv = &snddev_mi2s_drv; - struct snddev_mi2s_data *snddev_mi2s_data = dev_info->private_data; - - if (!dev_info) { - pr_err("%s: msm_snddev_info is null\n", __func__); - return -EINVAL; - } - - if (!dev_info->opened) { - pr_err(" %s: calling close device with out opening the" - " device\n", __func__); - return -EIO; - } - afe_close(snddev_mi2s_data->copp_id); - clk_disable_unprepare(mi2s_drv->tx_bitclk); - clk_disable_unprepare(mi2s_drv->tx_osrclk); - - mi2s_gpios_free(); - - pr_info("%s:\n", __func__); - - return 0; -} - -static int snddev_mi2s_set_freq(struct msm_snddev_info *dev_info, u32 req_freq) -{ - if (req_freq != 48000) { - pr_info("%s: Unsupported Frequency:%d\n", __func__, req_freq); - return -EINVAL; - } - return 48000; -} - - -static int snddev_mi2s_probe(struct platform_device *pdev) -{ - int rc = 0; - struct snddev_mi2s_data *pdata; - struct msm_snddev_info *dev_info; - - if (!pdev || !pdev->dev.platform_data) { - printk(KERN_ALERT "Invalid caller\n"); - return -ENODEV; - } - - pdata = pdev->dev.platform_data; - - dev_info = kzalloc(sizeof(struct msm_snddev_info), GFP_KERNEL); - if (!dev_info) { - pr_err("%s: uneable to allocate memeory for msm_snddev_info\n", - __func__); - - return -ENOMEM; - } - - dev_info->name = pdata->name; - dev_info->copp_id = pdata->copp_id; - dev_info->dev_ops.open = snddev_mi2s_open; - dev_info->dev_ops.close = snddev_mi2s_close; - dev_info->private_data = (void *)pdata; - dev_info->dev_ops.set_freq = snddev_mi2s_set_freq; - dev_info->capability = pdata->capability; - dev_info->opened = 0; - dev_info->sample_rate = pdata->sample_rate; - msm_snddev_register(dev_info); - - return rc; -} - -static struct platform_driver snddev_mi2s_driver = { - .probe = snddev_mi2s_probe, - .driver = {.name = "snddev_mi2s"} -}; - -static int __init snddev_mi2s_init(void) -{ - s32 rc = 0; - - rc = platform_driver_register(&mi2s_fm_driver); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: platform_driver_register for mi2s_fm_driver failed\n", - __func__); - goto error_mi2s_fm_platform_driver; - } - - rc = platform_driver_register(&snddev_mi2s_driver); - if (IS_ERR_VALUE(rc)) { - - pr_err("%s: platform_driver_register failed\n", __func__); - goto error_platform_driver; - } - - return rc; - -error_platform_driver: - platform_driver_unregister(&mi2s_fm_driver); -error_mi2s_fm_platform_driver: - pr_err("%s: encounter error\n", __func__); - return -ENODEV; -} - -static void __exit snddev_mi2s_exit(void) -{ - struct snddev_mi2s_drv_state *mi2s_drv = &snddev_mi2s_drv; - - platform_driver_unregister(&snddev_mi2s_driver); - clk_put(mi2s_drv->tx_osrclk); - clk_put(mi2s_drv->tx_bitclk); - return; -} - - -module_init(snddev_mi2s_init); -module_exit(snddev_mi2s_exit); - -MODULE_DESCRIPTION("MI2S Sound Device driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_mi2s.h b/arch/arm/mach-msm/qdsp6v2/snddev_mi2s.h deleted file mode 100644 index 8ae45cdb00eab5d84b3ba0f7178d32af961055ec..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_mi2s.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2010, 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 __MACH_QDSP6_V2_SNDDEV_MI2S_H -#define __MACH_QDSP6_V2_SNDDEV_MI2S_H - -struct snddev_mi2s_data { - u32 capability; /* RX or TX */ - const char *name; - u32 copp_id; /* audpp routing */ - u16 channel_mode; - u16 sd_lines; - u32 sample_rate; -}; - -#define MI2S_SD0 (1 << 0) -#define MI2S_SD1 (1 << 1) -#define MI2S_SD2 (1 << 2) -#define MI2S_SD3 (1 << 3) - -#endif diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_virtual.c b/arch/arm/mach-msm/qdsp6v2/snddev_virtual.c deleted file mode 100644 index 5ad49fe0670e46b460b6fcc5067d04ddc4aa9f0d..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_virtual.c +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (c) 2011, 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 -#include -#include -#include -#include -#include -#include "snddev_virtual.h" - -static DEFINE_MUTEX(snddev_virtual_lock); - -static int snddev_virtual_open(struct msm_snddev_info *dev_info) -{ - int rc = 0; - - pr_debug("%s\n", __func__); - - mutex_lock(&snddev_virtual_lock); - - if (!dev_info) { - pr_err("%s: NULL dev_info\n", __func__); - - rc = -EINVAL; - goto done; - } - - if (!dev_info->opened) { - rc = afe_start_pseudo_port(dev_info->copp_id); - } else { - pr_err("%s: Pseudo port 0x%x is already open\n", - __func__, dev_info->copp_id); - - rc = -EBUSY; - } - -done: - mutex_unlock(&snddev_virtual_lock); - - return rc; -} - -static int snddev_virtual_close(struct msm_snddev_info *dev_info) -{ - int rc = 0; - - pr_debug("%s\n", __func__); - - mutex_lock(&snddev_virtual_lock); - - if (!dev_info) { - pr_err("%s: NULL dev_info\n", __func__); - - rc = -EINVAL; - goto done; - } - - if (dev_info->opened) { - rc = afe_stop_pseudo_port(dev_info->copp_id); - } else { - pr_err("%s: Pseudo port 0x%x is not open\n", - __func__, dev_info->copp_id); - - rc = -EPERM; - } - -done: - mutex_unlock(&snddev_virtual_lock); - - return rc; -} - -static int snddev_virtual_set_freq(struct msm_snddev_info *dev_info, u32 rate) -{ - int rc = 0; - - if (!dev_info) - rc = -EINVAL; - - return rate; -} - -static int snddev_virtual_probe(struct platform_device *pdev) -{ - int rc = 0; - struct snddev_virtual_data *pdata; - struct msm_snddev_info *dev_info; - - pr_debug("%s\n", __func__); - - if (!pdev || !pdev->dev.platform_data) { - pr_err("%s: Invalid caller\n", __func__); - - rc = -EPERM; - goto done; - } - - pdata = pdev->dev.platform_data; - - dev_info = kmalloc(sizeof(struct msm_snddev_info), GFP_KERNEL); - if (!dev_info) { - pr_err("%s: Out of memory\n", __func__); - - rc = -ENOMEM; - goto done; - } - - dev_info->name = pdata->name; - dev_info->copp_id = pdata->copp_id; - dev_info->private_data = (void *) NULL; - dev_info->dev_ops.open = snddev_virtual_open; - dev_info->dev_ops.close = snddev_virtual_close; - dev_info->dev_ops.set_freq = snddev_virtual_set_freq; - dev_info->capability = pdata->capability; - dev_info->sample_rate = 48000; - dev_info->opened = 0; - dev_info->sessions = 0; - - msm_snddev_register(dev_info); - -done: - return rc; -} - -static int snddev_virtual_remove(struct platform_device *pdev) -{ - return 0; -} - -static struct platform_driver snddev_virtual_driver = { - .probe = snddev_virtual_probe, - .remove = snddev_virtual_remove, - .driver = { .name = "snddev_virtual" } -}; - -static int __init snddev_virtual_init(void) -{ - int rc = 0; - - pr_debug("%s\n", __func__); - - rc = platform_driver_register(&snddev_virtual_driver); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: Platform driver register failure\n", __func__); - - return -ENODEV; - } - - return 0; -} - -static void __exit snddev_virtual_exit(void) -{ - platform_driver_unregister(&snddev_virtual_driver); - - return; -} - -module_init(snddev_virtual_init); -module_exit(snddev_virtual_exit); - -MODULE_DESCRIPTION("Virtual Sound Device driver"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/qdsp6v2/snddev_virtual.h b/arch/arm/mach-msm/qdsp6v2/snddev_virtual.h deleted file mode 100644 index e6da25fe9261dfa1ecf4656cf14866e43d80b212..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/snddev_virtual.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2011, 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 __MACH_QDSP6V2_SNDDEV_VIRTUAL_H -#define __MACH_QDSP6V2_SNDDEV_VIRTUAL_H - -struct snddev_virtual_data { - u32 capability; /* RX or TX */ - const char *name; - u32 copp_id; /* Audpp routing */ -}; -#endif diff --git a/arch/arm/mach-msm/qdsp6v2/timpani_profile_8x60.h b/arch/arm/mach-msm/qdsp6v2/timpani_profile_8x60.h deleted file mode 100644 index 34109943c79a541ac3ef998d90dae6a997d70460..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/qdsp6v2/timpani_profile_8x60.h +++ /dev/null @@ -1,3225 +0,0 @@ -/* Copyright (c) 2010-2012, 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 __MACH_QDSP6V2_TIMPANI_PROFILE_H -#define __MACH_QDSP6V2_TIMPANI_PROFILE_H - -/* - * TX Device Profiles - */ - -/* Analog MIC */ -/* AMIC Primary mono */ -#define AMIC_PRI_MONO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xD0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x3A98}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - - - -/* AMIC Secondary mono */ -#define AMIC_SEC_MONO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xA8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAC, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x3A98 },\ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAC, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* AMIC dual */ -#define AMIC_DUAL_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xB0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xA8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAC, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAC, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* Fluid AMIC dual */ -#define FLUID_AMIC_DUAL_8000_OSR_256 \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xD0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xC8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* Fluid AMIC dual broadside */ -#define FLUID_AMIC_DUAL_BROADSIDE_8000_OSR_256 \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - /* AUX-IN to TxFE LEFT */ \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xC1)}, \ - /* MIC1 to TxFE RIGHT */ \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xD0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* - * Digital MIC - */ -/* DMIC1 Primary (DMIC 1 - TX1) */ -#define DMIC1_PRI_MONO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x21)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* DMIC1 Secondary - (DMIC 2 - TX1) */ -#define DMIC1_SEC_MONO_OSR_64 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x12)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* DMIC Dual Primary (DMIC 1/2 - TX1) */ -#define DMIC1_PRI_STEREO_OSR_256 \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x19)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)} } - -/* DMIC2 Dual Primary (DMIC 3/4 - TX2 - Left/Right) */ -#define DMIC2_SEC_DUAL_OSR_64 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x22)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x96, 0xFF, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0xF0, 0xE0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0xC0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HS_DMIC2_STEREO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x19)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* - * LINE IN - */ -#define LINEIN_PRI_MONO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEIN_PRI_STEREO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xA2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEIN_SEC_MONO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x2E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x96, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0xF0, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0xA2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0xC0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEIN_SEC_STEREO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x2E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x96, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0xF0, 0xE0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0xA2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x19, 0xFF, 0xA2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0xC0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x19, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEIN_SEC_STEREO_OSR_64 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x22)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x96, 0xFF, 0x18)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0xF0, 0xE0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0xA2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x19, 0xFF, 0xA2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0xC0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA6, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA7, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x19, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* - * AUX IN - */ -#define AUXIN_MONO_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xA1)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* Headset MIC */ -#define HEADSET_AMIC2_TX_MONO_PRI_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xC8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x3A98 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* - * RX Device Profiles - */ - -/* RX EAR */ -#define EAR_PRI_MONO_8000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x01, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define EAR_SEC_8000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xCA)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* ANC Headset: Speakers on Primary Rx, Noise Microphones on Secondary Tx */ - -#define ANC_HEADSET_CPLS_AMIC1_AUXL_RX1_48000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x95, 0xFF, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9A, 0xFF, 0x8C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9B, 0x01, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0xD0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x19, 0xFF, 0xC1)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xC0, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xD0, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x18, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x19, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x09, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0A, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define FLUID_SPEAKER_PRI_STEREO_48000_OSR_256 \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* - * RX HPH PRIMARY - */ - -/* RX HPH CLASS AB CAPLESS */ - -#define HEADSET_AB_CPLS_48000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HPH_PRI_AB_CPLS_MONO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on HEADSET_AB_CPLS_48000_OSR_256, change 0x83 */ -/* change 0x31 */ -#define HPH_PRI_AB_CPLS_MONO_LEFT \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xC5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xC5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on HEADSET_AB_CPLS_48000_OSR_256 */ -/* add 0x8A to mute rx1 left 0x01 */ -/* change 0x31 */ -#define HPH_PRI_AB_CPLS_MONO_RIGHT \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0D)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x35)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define FTM_HPH_PRI_AB_CPLS_MONO_LB_LEFT \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xC5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x3C)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define FTM_HPH_PRI_AB_CPLS_MONO_LB_RIGHT \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0D)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x35)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* This is for differential signaling, which is a test mode. */ -#define HPH_PRI_AB_CPLS_DIFF \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x06)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HPH_PRI_AB_CPLS_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* RX HPH CLASS AB LEGACY */ - -#define HPH_PRI_AB_LEG_MONO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0xF9)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HP_PRI_AB_LEG_DIFF \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0xF9)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HPH_PRI_AB_LEG_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x09)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF9)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x27)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* RX HPH CLASS D LEGACY */ - -#define HPH_PRI_D_LEG_DIFF \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0x90, 0x90)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0A, 0x0A)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HPH_PRI_D_LEG_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x21, 0xFF, 0x60)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x22, 0xFF, 0xE1)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xFF, 0xD0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2D, 0xFF, 0x6F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2E, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xBB)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xF2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xF7, 0x37)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xFF)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xF2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xF7, 0x37)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xFF)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4A, 0xFF, 0x77)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0x8C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x0A)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* - * RX HPH SECONDARY - */ - -/* RX HPH CLASS AB CAPLESS */ -#define HPH_SEC_AB_CPLS_MONO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - - -#define HPH_SEC_AB_CPLS_DIFF \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HPH_SEC_AB_CPLS_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA5, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x48)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA5, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* RX HPH CLASS AB LEGACY */ -#define HPH_SEC_AB_LEG_MONO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0xF9)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HPH_SEC_AB_LEG_DIFF \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0xF9)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - - -#define HPH_SEC_AB_LEG_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA5, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x48)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0xF9)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA5, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* RX HPH CLASS D LEGACY */ - -#define HPH_SEC_D_LEG_DIFF \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0x50, 0x50)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0A, 0x0A)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000},\ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HPH_SEC_D_LEG_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA5, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0x50, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0A, 0x0A)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* RX LINE OUT PRIMARY */ -/* spkr phone mono rx */ -#define LINEOUT_PRI_MONO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEOUT_PRI_DIFF \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x06)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x24, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0x10)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEOUT_PRI_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0c)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* RX LINE OUT SECONDARY */ -#define LINEOUT_SEC_MONO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEOUT_SEC_DIFF \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x48, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x48, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LINEOUT_SEC_STEREO \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA5, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xFF, 0xC2)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x48, 0x48)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA5, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x48, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define SPEAKER_PRI_STEREO_48000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x4E1F}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* RX AUX */ -#define AUXOUT_PRI_MONO_8000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x20, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 50000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x07)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x20, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define AUXOUT_SEC_MONO_8000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA1, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x98, 0xFF, 0x02)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xFF, 0xCA)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 50000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x07)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x30, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA4, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAA, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_AUXPGA_HPH_AB_CPLS_STEREO \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2F, 0xFF, 0x44)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x30, 0xFF, 0x92)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x90, 0x90)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - - -#define LB_AUXPGA_LO_STEREO \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2F, 0xFF, 0x44)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x30, 0xFF, 0x92)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x90, 0x90)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x90, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - - -/* - * LB Device Profiles - */ - -/* EAR */ -#define LB_EAR_PRI_MONO \ - {{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x04, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x04, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* HPH CLASS AB CAPLESS */ -#define LB_HPH_AB_CPLS_PRI_MONO \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x80, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x80, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_HPH_AB_CPLS_PRI_DIFF \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x10, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define SPEAKER_HPH_AB_CPL_PRI_STEREO_48000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_HPH_AB_CPLS_PRI_STEREO \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x90, 0x90)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x90, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* HPH CLASS AB LEGACY */ -#define LB_HPH_AB_LEG_PRI_MONO \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xFC)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x80, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x80, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_PHP_AB_LEG_PRI_DIFF \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x10, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xFC)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x08, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_HPH_AB_LEG_PRI_STEREO \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x90, 0x90)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x59)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xFC)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x90, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* HPH CLASS D LEGACY */ -#define LB_HPH_D_LEG_PRI_DIFF \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x3A, 0x2A)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x3F, 0x2F)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_HPH_D_LEG_PRI_STEREO \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0xA6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x3A, 0x3A)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x3F, 0x3F)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* LINE OUT */ -#define LB_LINEOUT_PRI_MONO \ - {{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x80, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x80, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_LINEOUT_PRI_DIFF \ - {{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x80, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x10, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x80, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x10, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define LB_LINEOUT_PRI_STEREO \ - {{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x90, 0x90)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x58, 0x58)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 100000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFF, 0xA4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x90, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* AUX OUT */ -#define LB_AUXOUT_PRI_MONO \ - {{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0xE0, 0x80)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xA0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 50000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x07)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0xE0, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* TTY RX */ -#define TTY_HEADSET_MONO_RX_8000_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x06)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x45)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xC5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x08)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* TTY TX */ -#define TTY_HEADSET_MONO_TX_OSR_256 \ - {{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xA8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* FTM devices */ -/* from HPH_PRI_AB_CPLS_DIFF */ -#define HEADSET_MONO_DIFF_RX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x06)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFC, 0xF5)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3D, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on SPEAKER_PRI_STEREO_48000_OSR_256 */ -/* change 0x8A */ -#define FTM_SPKR_L_RX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on SPEAKER_PRI_STEREO_48000_OSR_256 */ -/* change 0x8A */ -#define SPKR_R_RX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0x24, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on SPEAKER_PRI_STEREO_48000_OSR_256 */ -#define FTM_SPKR_RX_LB \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x06)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0x30, 0x30)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - - -#define SPKR_MONO_DIFF_RX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* from AMIC_PRI_MONO_OSR_256, change TxFE (reg 0x0D) */ -#define LINEIN_MONO_L_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xD4)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x3A98}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* from AMIC_PRI_MONO_OSR_256, change TxFE (reg 0x0D) */ -#define LINEIN_MONO_R_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xD6)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x3A98}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* from AMIC_PRI_MONO_OSR_256 */ -#define AUX_IN_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xC1)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x3A98}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* AUXOUT_PRI_MONO_8000_OSR_256 */ -#define AUX_OUT_RX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x20, 0x20)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 50000}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x07)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0x07, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x20, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* from DMIC1_PRI_MONO_OSR_256 */ -#define DMIC1_LEFT_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x21)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define DMIC1_RIGHT_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x21)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x06)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define DMIC1_LEFT_AND_RIGHT_TX DMIC1_PRI_STEREO_OSR_256 - -#define DMIC2_LEFT_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x21)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x0A)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define DMIC2_RIGHT_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x21)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define DMIC2_LEFT_AND_RIGHT_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x21)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#define HANDSET_MIC1_AUX_IN \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xB0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xA1)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on AMIC_PRI_MONO_OSR_256 */ -#define FTM_HANDSET_LB_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xD0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x00)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0x3A98}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8B, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8C, 0x07, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA0, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on HEADSET_AMIC2_TX_MONO_PRI_OSR_256 */ -#define FTM_HEADSET_LB_TX \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xC8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8B, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8C, 0x07, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA0, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on EAR_PRI_MONO_8000_OSR_256 */ -#define EAR_PRI_MONO_LB \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0x60, 0x60)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x3C)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x01, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -/* based on AMIC_DUAL_OSR_256 */ -#define FTM_AMIC_DUAL_HANDSET_TX_LB \ - {{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x04)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xB0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xA8)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \ - {ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA0, 0x03, 0x03)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \ - {ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} } - -#endif diff --git a/arch/arm/mach-msm/rpc_dog_keepalive.c b/arch/arm/mach-msm/rpc_dog_keepalive.c deleted file mode 100644 index 0f5b217f91a564db66e1e770c5dd194d8b9c2223..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpc_dog_keepalive.c +++ /dev/null @@ -1,240 +0,0 @@ -/* Copyright (c) 2010, 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. - * - */ - -/* - * DOG KEEPALIVE RPC CLIENT MODULE - */ - -#include -#include -#include -#include -#include - -#define DOG_KEEPALIVE_PROG 0x300000A2 -#define DOG_KEEPALIVE_VERS 0x00010001 - -#define DOG_KEEPALIVE_REGISTER_PROC 2 -#define DOG_KEEPALIVE_UNREGISTER_PROC 3 - -#define DOG_KEEPALIVE_CB_PROC 1 - -static int dog_keepalive_debug; -module_param_named(debug, dog_keepalive_debug, - int, S_IRUGO | S_IWUSR | S_IWGRP); - -#if defined(DEBUG) -#define DBG(x...) do { \ - if (dog_keepalive_debug) \ - printk(KERN_INFO x); \ - } while (0) -#else -#define DBG(x...) do { } while (0) -#endif - -static struct msm_rpc_client *dog_keepalive_rpc_client; -static int32_t dog_clnt_id = -1; - -struct dog_keepalive_cb_arg { - uint32_t cb_id; -}; - -struct dog_keepalive_cb_ret { - uint32_t result; -}; - -static int dog_keepalive_cb(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr) -{ - int rc; - void *cb_func; - uint32_t accept_status; - struct dog_keepalive_cb_arg arg; - struct dog_keepalive_cb_ret ret; - - xdr_recv_uint32(xdr, &arg.cb_id); /* cb_id */ - - cb_func = msm_rpc_get_cb_func(client, arg.cb_id); - if (cb_func) { - rc = ((int (*) - (struct dog_keepalive_cb_arg *, - struct dog_keepalive_cb_ret *)) - cb_func)(&arg, &ret); - if (rc) - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - else - accept_status = RPC_ACCEPTSTAT_SUCCESS; - } else - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - - xdr_start_accepted_reply(xdr, accept_status); - - if (accept_status == RPC_ACCEPTSTAT_SUCCESS) - xdr_send_uint32(xdr, &ret.result); /* result */ - - rc = xdr_send_msg(xdr); - if (rc) - pr_err("%s: send accepted reply failed: %d\n", __func__, rc); - - return rc; -} - -static int dog_keepalive_cb_func(struct msm_rpc_client *client, - struct rpc_request_hdr *req, - struct msm_rpc_xdr *xdr) -{ - int rc = 0; - - switch (req->procedure) { - case DOG_KEEPALIVE_CB_PROC: - rc = dog_keepalive_cb(client, xdr); - break; - default: - pr_err("%s: procedure not supported %d\n", - __func__, req->procedure); - xdr_start_accepted_reply(xdr, RPC_ACCEPTSTAT_PROC_UNAVAIL); - rc = xdr_send_msg(xdr); - if (rc) - pr_err("%s: sending reply failed: %d\n", __func__, rc); - break; - } - return rc; -} - -struct dog_keepalive_register_arg { - int (*cb_func)( - struct dog_keepalive_cb_arg *arg, - struct dog_keepalive_cb_ret *ret); - uint32_t response_msec; - uint32_t clnt_id_valid; -}; - -struct dog_keepalive_register_ret { - uint32_t *clnt_id; - uint32_t result; -}; - -static int dog_keepalive_register_arg_func(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct dog_keepalive_register_arg *arg = data; - int cb_id; - - /* cb_func */ - cb_id = msm_rpc_add_cb_func(client, (void *)arg->cb_func); - if ((cb_id < 0) && (cb_id != MSM_RPC_CLIENT_NULL_CB_ID)) - return cb_id; - - xdr_send_uint32(xdr, &cb_id); - xdr_send_uint32(xdr, &arg->response_msec); /* response_msec */ - xdr_send_uint32(xdr, &arg->clnt_id_valid); /* clnt_id valid */ - return 0; -} - -static int dog_keepalive_register_ret_func(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data) -{ - struct dog_keepalive_register_ret *ret = data; - - /* clnt_id */ - xdr_recv_pointer(xdr, (void **)&(ret->clnt_id), sizeof(uint32_t), - xdr_recv_uint32); - - /* result */ - xdr_recv_uint32(xdr, &ret->result); - return 0; -} - -static int dog_keepalive_register_func(struct msm_rpc_client *client, - struct dog_keepalive_register_arg *arg, - struct dog_keepalive_register_ret *ret) -{ - return msm_rpc_client_req2(client, - DOG_KEEPALIVE_REGISTER_PROC, - dog_keepalive_register_arg_func, arg, - dog_keepalive_register_ret_func, ret, -1); -} - -static int dog_keepalive_cb_proc_func(struct dog_keepalive_cb_arg *arg, - struct dog_keepalive_cb_ret *ret) -{ - DBG("%s: received, client %d \n", __func__, dog_clnt_id); - ret->result = 1; - return 0; -} - -static void dog_keepalive_register(void) -{ - struct dog_keepalive_register_arg arg; - struct dog_keepalive_register_ret ret; - int rc; - - arg.cb_func = dog_keepalive_cb_proc_func; - arg.response_msec = 1000; - arg.clnt_id_valid = 1; - ret.clnt_id = NULL; - rc = dog_keepalive_register_func(dog_keepalive_rpc_client, - &arg, &ret); - if (rc) - pr_err("%s: register request failed\n", __func__); - else - dog_clnt_id = *ret.clnt_id; - - kfree(ret.clnt_id); - DBG("%s: register complete\n", __func__); -} - -/* Registration with the platform driver for notification on the availability - * of the DOG_KEEPALIVE remote server - */ -static int dog_keepalive_init_probe(struct platform_device *pdev) -{ - DBG("%s: probe called\n", __func__); - dog_keepalive_rpc_client = msm_rpc_register_client2( - "dog-keepalive", - DOG_KEEPALIVE_PROG, - DOG_KEEPALIVE_VERS, - 0, dog_keepalive_cb_func); - - if (IS_ERR(dog_keepalive_rpc_client)) { - pr_err("%s: RPC client creation failed\n", __func__); - return PTR_ERR(dog_keepalive_rpc_client); - } - - /* Send RPC call to register for callbacks */ - dog_keepalive_register(); - - return 0; -} - -static char dog_keepalive_driver_name[] = "rs00000000"; - -static struct platform_driver dog_keepalive_init_driver = { - .probe = dog_keepalive_init_probe, - .driver = { - .owner = THIS_MODULE, - }, -}; - -static int __init rpc_dog_keepalive_init(void) -{ - snprintf(dog_keepalive_driver_name, sizeof(dog_keepalive_driver_name), - "rs%08x", DOG_KEEPALIVE_PROG); - dog_keepalive_init_driver.driver.name = dog_keepalive_driver_name; - - return platform_driver_register(&dog_keepalive_init_driver); -} - -late_initcall(rpc_dog_keepalive_init); -MODULE_DESCRIPTION("DOG KEEPALIVE RPC CLIENT"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/rpc_pmapp.c b/arch/arm/mach-msm/rpc_pmapp.c deleted file mode 100644 index 04dc8a82ebfd1284a57dbdd3756a070b6df4b1c1..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpc_pmapp.c +++ /dev/null @@ -1,576 +0,0 @@ -/* Copyright (c) 2009-2011, 2013, 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 -#include -#include -#include -#include -#include -#include - -#define PMAPP_RPC_PROG 0x30000060 -#define PMAPP_RPC_VER_1_1 0x00010001 -#define PMAPP_RPC_VER_1_2 0x00010002 -#define PMAPP_RPC_VER_2_1 0x00020001 -#define PMAPP_RPC_VER_3_1 0x00030001 -#define PMAPP_RPC_VER_5_1 0x00050001 -#define PMAPP_RPC_VER_6_1 0x00060001 -#define PMAPP_RPC_VER_7_1 0x00070001 - -#define VBUS_SESS_VALID_CB_PROC 1 -#define PM_VOTE_USB_PWR_SEL_SWITCH_APP__HSUSB (1 << 2) -#define PM_USB_PWR_SEL_SWITCH_ID 0 - -#define PMAPP_RPC_TIMEOUT (5*HZ) - -#define PMAPP_DISPLAY_CLOCK_CONFIG_PROC 21 -#define PMAPP_VREG_LEVEL_VOTE_PROC 23 -#define PMAPP_SMPS_CLOCK_VOTE_PROC 26 -#define PMAPP_CLOCK_VOTE_PROC 27 -#define PMAPP_SMPS_MODE_VOTE_PROC 28 -#define PMAPP_VREG_PINCNTRL_VOTE_PROC 30 -#define PMAPP_DISP_BACKLIGHT_SET_PROC 31 -#define PMAPP_DISP_BACKLIGHT_INIT_PROC 32 -#define PMAPP_VREG_LPM_PINCNTRL_VOTE_PROC 34 - -/* Clock voter name max length */ -#define PMAPP_CLOCK_VOTER_ID_LEN 4 - -struct rpc_pmapp_ids { - unsigned long reg_for_vbus_valid; - unsigned long vote_for_vbus_valid_switch; -}; - -static struct rpc_pmapp_ids rpc_ids; -static struct msm_rpc_client *client; - -/* Add newer versions at the top of array */ -static const unsigned int rpc_vers[] = { - PMAPP_RPC_VER_7_1, - PMAPP_RPC_VER_6_1, - PMAPP_RPC_VER_5_1, - PMAPP_RPC_VER_3_1, - PMAPP_RPC_VER_2_1, -}; - -static void rpc_pmapp_init_rpc_ids(unsigned long vers) -{ - if (vers == PMAPP_RPC_VER_1_1) { - rpc_ids.reg_for_vbus_valid = 5; - rpc_ids.vote_for_vbus_valid_switch = 6; - } else if (vers == PMAPP_RPC_VER_1_2) { - rpc_ids.reg_for_vbus_valid = 16; - rpc_ids.vote_for_vbus_valid_switch = 17; - } else if (vers == PMAPP_RPC_VER_2_1) { - rpc_ids.reg_for_vbus_valid = 0; /* NA */ - rpc_ids.vote_for_vbus_valid_switch = 0; /* NA */ - } -} - -struct usb_pwr_sel_switch_args { - uint32_t cmd; - uint32_t switch_id; - uint32_t app_mask; -}; - -static int usb_pwr_sel_switch_arg_cb(struct msm_rpc_client *client, - void *buf, void *data) -{ - struct usb_pwr_sel_switch_args *args = buf; - - args->cmd = cpu_to_be32(*(uint32_t *)data); - args->switch_id = cpu_to_be32(PM_USB_PWR_SEL_SWITCH_ID); - args->app_mask = cpu_to_be32(PM_VOTE_USB_PWR_SEL_SWITCH_APP__HSUSB); - return sizeof(struct usb_pwr_sel_switch_args); -} - -static int msm_pm_app_vote_usb_pwr_sel_switch(uint32_t cmd) -{ - return msm_rpc_client_req(client, - rpc_ids.vote_for_vbus_valid_switch, - usb_pwr_sel_switch_arg_cb, - &cmd, NULL, NULL, -1); -} - -struct vbus_sess_valid_args { - uint32_t cb_id; -}; - -static int vbus_sess_valid_arg_cb(struct msm_rpc_client *client, - void *buf, void *data) -{ - struct vbus_sess_valid_args *args = buf; - - args->cb_id = cpu_to_be32(*(uint32_t *)data); - return sizeof(struct vbus_sess_valid_args); -} - - -int pmic_vote_3p3_pwr_sel_switch(int boost) -{ - int ret; - - ret = msm_pm_app_vote_usb_pwr_sel_switch(boost); - - return ret; -} -EXPORT_SYMBOL(pmic_vote_3p3_pwr_sel_switch); - -struct vbus_sn_notification_args { - uint32_t cb_id; - uint32_t vbus; /* vbus = 0 if VBUS is present */ -}; - -static int vbus_notification_cb(struct msm_rpc_client *client, - void *buffer, int in_size) -{ - struct vbus_sn_notification_args *args; - struct rpc_request_hdr *req = buffer; - int rc; - uint32_t accept_status; - void (*cb_func)(int); - uint32_t cb_id; - int vbus; - - args = (struct vbus_sn_notification_args *) (req + 1); - cb_id = be32_to_cpu(args->cb_id); - vbus = be32_to_cpu(args->vbus); - - cb_func = msm_rpc_get_cb_func(client, cb_id); - if (cb_func) { - cb_func(!vbus); - accept_status = RPC_ACCEPTSTAT_SUCCESS; - } else - accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - - msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), - accept_status); - rc = msm_rpc_send_accepted_reply(client, 0); - if (rc) - pr_err("%s: send accepted reply failed: %d\n", __func__, rc); - - return rc; -} - -static int pm_app_usb_cb_func(struct msm_rpc_client *client, - void *buffer, int in_size) -{ - int rc; - struct rpc_request_hdr *req = buffer; - - switch (be32_to_cpu(req->procedure)) { - case VBUS_SESS_VALID_CB_PROC: - rc = vbus_notification_cb(client, buffer, in_size); - break; - default: - pr_err("%s: procedure not supported %d\n", __func__, - be32_to_cpu(req->procedure)); - msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid), - RPC_ACCEPTSTAT_PROC_UNAVAIL); - rc = msm_rpc_send_accepted_reply(client, 0); - if (rc) - pr_err("%s: sending reply failed: %d\n", __func__, rc); - break; - } - return rc; -} - -int msm_pm_app_rpc_init(void (*callback)(int online)) -{ - uint32_t cb_id, rc; - - if (!machine_is_qsd8x50_ffa() && !machine_is_msm7x27_ffa()) - return -ENOTSUPP; - - client = msm_rpc_register_client("pmapp_usb", - PMAPP_RPC_PROG, - PMAPP_RPC_VER_2_1, 1, - pm_app_usb_cb_func); - if (!IS_ERR(client)) { - rpc_pmapp_init_rpc_ids(PMAPP_RPC_VER_2_1); - goto done; - } - - client = msm_rpc_register_client("pmapp_usb", - PMAPP_RPC_PROG, - PMAPP_RPC_VER_1_2, 1, - pm_app_usb_cb_func); - if (!IS_ERR(client)) { - rpc_pmapp_init_rpc_ids(PMAPP_RPC_VER_1_2); - goto done; - } - - client = msm_rpc_register_client("pmapp_usb", - PMAPP_RPC_PROG, - PMAPP_RPC_VER_1_1, 1, - pm_app_usb_cb_func); - if (!IS_ERR(client)) - rpc_pmapp_init_rpc_ids(PMAPP_RPC_VER_1_1); - else - return PTR_ERR(client); - -done: - cb_id = msm_rpc_add_cb_func(client, (void *)callback); - /* In case of NULL callback funtion, cb_id would be -1 */ - if ((int) cb_id < -1) - return cb_id; - rc = msm_rpc_client_req(client, - rpc_ids.reg_for_vbus_valid, - vbus_sess_valid_arg_cb, - &cb_id, NULL, NULL, -1); - return rc; -} -EXPORT_SYMBOL(msm_pm_app_rpc_init); - -void msm_pm_app_rpc_deinit(void(*callback)(int online)) -{ - if (client) { - msm_rpc_remove_cb_func(client, (void *)callback); - msm_rpc_unregister_client(client); - } -} -EXPORT_SYMBOL(msm_pm_app_rpc_deinit); - -/* error bit flags defined by modem side */ -#define PM_ERR_FLAG__PAR1_OUT_OF_RANGE (0x0001) -#define PM_ERR_FLAG__PAR2_OUT_OF_RANGE (0x0002) -#define PM_ERR_FLAG__PAR3_OUT_OF_RANGE (0x0004) -#define PM_ERR_FLAG__PAR4_OUT_OF_RANGE (0x0008) -#define PM_ERR_FLAG__PAR5_OUT_OF_RANGE (0x0010) - -#define PM_ERR_FLAG__ALL_PARMS_OUT_OF_RANGE (0x001F) /* all 5 previous */ - -#define PM_ERR_FLAG__SBI_OPT_ERR (0x0080) -#define PM_ERR_FLAG__FEATURE_NOT_SUPPORTED (0x0100) - -#define PMAPP_BUFF_SIZE 256 - -struct pmapp_buf { - char *start; /* buffer start addr */ - char *end; /* buffer end addr */ - int size; /* buffer size */ - char *data; /* payload begin addr */ - int len; /* payload len */ -}; - -static DEFINE_MUTEX(pmapp_mtx); - -struct pmapp_ctrl { - int inited; - struct pmapp_buf tbuf; - struct pmapp_buf rbuf; - struct msm_rpc_endpoint *endpoint; -}; - -static struct pmapp_ctrl pmapp_ctrl = { - .inited = -1, -}; - - -static int pmapp_rpc_set_only(uint data0, uint data1, uint data2, - uint data3, int num, int proc); - -static int pmapp_buf_init(void) -{ - struct pmapp_ctrl *pm = &pmapp_ctrl; - - memset(&pmapp_ctrl, 0, sizeof(pmapp_ctrl)); - - pm->tbuf.start = kmalloc(PMAPP_BUFF_SIZE, GFP_KERNEL); - if (pm->tbuf.start == NULL) { - printk(KERN_ERR "%s:%u\n", __func__, __LINE__); - return -ENOMEM; - } - - pm->tbuf.data = pm->tbuf.start; - pm->tbuf.size = PMAPP_BUFF_SIZE; - pm->tbuf.end = pm->tbuf.start + PMAPP_BUFF_SIZE; - pm->tbuf.len = 0; - - pm->rbuf.start = kmalloc(PMAPP_BUFF_SIZE, GFP_KERNEL); - if (pm->rbuf.start == NULL) { - kfree(pm->tbuf.start); - printk(KERN_ERR "%s:%u\n", __func__, __LINE__); - return -ENOMEM; - } - pm->rbuf.data = pm->rbuf.start; - pm->rbuf.size = PMAPP_BUFF_SIZE; - pm->rbuf.end = pm->rbuf.start + PMAPP_BUFF_SIZE; - pm->rbuf.len = 0; - - pm->inited = 1; - - return 0; -} - -static inline void pmapp_buf_reserve(struct pmapp_buf *bp, int len) -{ - bp->data += len; -} - -static inline void pmapp_buf_reset(struct pmapp_buf *bp) -{ - bp->data = bp->start; - bp->len = 0; -} - -static int modem_to_linux_err(uint err) -{ - if (err == 0) - return 0; - - if (err & PM_ERR_FLAG__ALL_PARMS_OUT_OF_RANGE) - return -EINVAL; /* PM_ERR_FLAG__PAR[1..5]_OUT_OF_RANGE */ - - if (err & PM_ERR_FLAG__SBI_OPT_ERR) - return -EIO; - - if (err & PM_ERR_FLAG__FEATURE_NOT_SUPPORTED) - return -ENOSYS; - - return -EPERM; -} - -static int pmapp_put_tx_data(struct pmapp_buf *tp, uint datav) -{ - uint *lp; - - if ((tp->size - tp->len) < sizeof(datav)) { - printk(KERN_ERR "%s: OVERFLOW size=%d len=%d\n", - __func__, tp->size, tp->len); - return -1; - } - - lp = (uint *)tp->data; - *lp = cpu_to_be32(datav); - tp->data += sizeof(datav); - tp->len += sizeof(datav); - - return sizeof(datav); -} - -static int pmapp_pull_rx_data(struct pmapp_buf *rp, uint *datap) -{ - uint *lp; - - if (rp->len < sizeof(*datap)) { - printk(KERN_ERR "%s: UNDERRUN len=%d\n", __func__, rp->len); - return -1; - } - lp = (uint *)rp->data; - *datap = be32_to_cpu(*lp); - rp->data += sizeof(*datap); - rp->len -= sizeof(*datap); - - return sizeof(*datap); -} - - -static int pmapp_rpc_req_reply(struct pmapp_buf *tbuf, struct pmapp_buf *rbuf, - int proc) -{ - struct pmapp_ctrl *pm = &pmapp_ctrl; - int ans, len, i; - - - if ((pm->endpoint == NULL) || IS_ERR(pm->endpoint)) { - for (i = 0; i < ARRAY_SIZE(rpc_vers); i++) { - pm->endpoint = msm_rpc_connect_compatible( - PMAPP_RPC_PROG, rpc_vers[i], 0); - - if (IS_ERR(pm->endpoint)) { - ans = PTR_ERR(pm->endpoint); - printk(KERN_ERR "%s: init rpc failed! ans = %d" - " for 0x%x version, fallback\n", - __func__, ans, rpc_vers[i]); - } else { - printk(KERN_DEBUG "%s: successfully connected" - " to 0x%x rpc version\n", - __func__, rpc_vers[i]); - break; - } - } - } - - if (IS_ERR(pm->endpoint)) { - ans = PTR_ERR(pm->endpoint); - return ans; - } - - /* - * data is point to next available space at this moment, - * move it back to beginning of request header and increase - * the length - */ - tbuf->data = tbuf->start; - tbuf->len += sizeof(struct rpc_request_hdr); - - len = msm_rpc_call_reply(pm->endpoint, proc, - tbuf->data, tbuf->len, - rbuf->data, rbuf->size, - PMAPP_RPC_TIMEOUT); - - if (len <= 0) { - printk(KERN_ERR "%s: rpc failed! len = %d\n", __func__, len); - pm->endpoint = NULL; /* re-connect later ? */ - return len; - } - - rbuf->len = len; - /* strip off rpc_reply_hdr */ - rbuf->data += sizeof(struct rpc_reply_hdr); - rbuf->len -= sizeof(struct rpc_reply_hdr); - - return rbuf->len; -} - -static int pmapp_rpc_set_only(uint data0, uint data1, uint data2, uint data3, - int num, int proc) -{ - struct pmapp_ctrl *pm = &pmapp_ctrl; - struct pmapp_buf *tp; - struct pmapp_buf *rp; - int stat; - - - if (mutex_lock_interruptible(&pmapp_mtx)) - return -ERESTARTSYS; - - if (pm->inited <= 0) { - stat = pmapp_buf_init(); - if (stat < 0) { - mutex_unlock(&pmapp_mtx); - return stat; - } - } - - tp = &pm->tbuf; - rp = &pm->rbuf; - - pmapp_buf_reset(tp); - pmapp_buf_reserve(tp, sizeof(struct rpc_request_hdr)); - pmapp_buf_reset(rp); - - if (num > 0) - pmapp_put_tx_data(tp, data0); - - if (num > 1) - pmapp_put_tx_data(tp, data1); - - if (num > 2) - pmapp_put_tx_data(tp, data2); - - if (num > 3) - pmapp_put_tx_data(tp, data3); - - stat = pmapp_rpc_req_reply(tp, rp, proc); - if (stat < 0) { - mutex_unlock(&pmapp_mtx); - return stat; - } - - pmapp_pull_rx_data(rp, &stat); /* result from server */ - - mutex_unlock(&pmapp_mtx); - - return modem_to_linux_err(stat); -} - -int pmapp_display_clock_config(uint enable) -{ - return pmapp_rpc_set_only(enable, 0, 0, 0, 1, - PMAPP_DISPLAY_CLOCK_CONFIG_PROC); -} -EXPORT_SYMBOL(pmapp_display_clock_config); - -int pmapp_clock_vote(const char *voter_id, uint clock_id, uint vote) -{ - if (strlen(voter_id) != PMAPP_CLOCK_VOTER_ID_LEN) - return -EINVAL; - - return pmapp_rpc_set_only(*((uint *) voter_id), clock_id, vote, 0, 3, - PMAPP_CLOCK_VOTE_PROC); -} -EXPORT_SYMBOL(pmapp_clock_vote); - -int pmapp_smps_clock_vote(const char *voter_id, uint vreg_id, uint vote) -{ - if (strlen(voter_id) != PMAPP_CLOCK_VOTER_ID_LEN) - return -EINVAL; - - return pmapp_rpc_set_only(*((uint *) voter_id), vreg_id, vote, 0, 3, - PMAPP_SMPS_CLOCK_VOTE_PROC); -} -EXPORT_SYMBOL(pmapp_smps_clock_vote); - -int pmapp_vreg_level_vote(const char *voter_id, uint vreg_id, uint level) -{ - if (strlen(voter_id) != PMAPP_CLOCK_VOTER_ID_LEN) - return -EINVAL; - - return pmapp_rpc_set_only(*((uint *) voter_id), vreg_id, level, 0, 3, - PMAPP_VREG_LEVEL_VOTE_PROC); -} -EXPORT_SYMBOL(pmapp_vreg_level_vote); - -int pmapp_smps_mode_vote(const char *voter_id, uint vreg_id, uint mode) -{ - if (strlen(voter_id) != PMAPP_CLOCK_VOTER_ID_LEN) - return -EINVAL; - - return pmapp_rpc_set_only(*((uint *) voter_id), vreg_id, mode, 0, 3, - PMAPP_SMPS_MODE_VOTE_PROC); -} -EXPORT_SYMBOL(pmapp_smps_mode_vote); - -int pmapp_vreg_pincntrl_vote(const char *voter_id, uint vreg_id, - uint clock_id, uint vote) -{ - if (strlen(voter_id) != PMAPP_CLOCK_VOTER_ID_LEN) - return -EINVAL; - - return pmapp_rpc_set_only(*((uint *) voter_id), vreg_id, clock_id, - vote, 4, - PMAPP_VREG_PINCNTRL_VOTE_PROC); -} -EXPORT_SYMBOL(pmapp_vreg_pincntrl_vote); - -int pmapp_disp_backlight_set_brightness(int value) -{ - if (value < 0 || value > 255) - return -EINVAL; - - return pmapp_rpc_set_only(value, 0, 0, 0, 1, - PMAPP_DISP_BACKLIGHT_SET_PROC); -} -EXPORT_SYMBOL(pmapp_disp_backlight_set_brightness); - -void pmapp_disp_backlight_init(void) -{ - pmapp_rpc_set_only(0, 0, 0, 0, 0, PMAPP_DISP_BACKLIGHT_INIT_PROC); -} -EXPORT_SYMBOL(pmapp_disp_backlight_init); - -int pmapp_vreg_lpm_pincntrl_vote(const char *voter_id, uint vreg_id, - uint clock_id, uint vote) -{ - if (strnlen(voter_id, PMAPP_CLOCK_VOTER_ID_LEN) - != PMAPP_CLOCK_VOTER_ID_LEN) - return -EINVAL; - - return pmapp_rpc_set_only(*((uint *) voter_id), vreg_id, clock_id, - vote, 4, - PMAPP_VREG_LPM_PINCNTRL_VOTE_PROC); -} -EXPORT_SYMBOL(pmapp_vreg_lpm_pincntrl_vote); diff --git a/arch/arm/mach-msm/rpc_server_dog_keepalive.c b/arch/arm/mach-msm/rpc_server_dog_keepalive.c deleted file mode 100644 index 24b3b33f26dcdbc77d115120cbdec1af0e95d4c2..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpc_server_dog_keepalive.c +++ /dev/null @@ -1,77 +0,0 @@ -/* arch/arm/mach-msm/rpc_server_dog_keepalive.c - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2009, The Linux Foundation. All rights reserved. - * Author: Iliyan Malchev - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include - -/* dog_keepalive server definitions */ - -#define DOG_KEEPALIVE_PROG 0x30000015 -#if CONFIG_MSM_AMSS_VERSION==6210 -#define DOG_KEEPALIVE_VERS 0 -#define RPC_DOG_KEEPALIVE_BEACON 1 -#elif (CONFIG_MSM_AMSS_VERSION==6220) || (CONFIG_MSM_AMSS_VERSION==6225) -#define DOG_KEEPALIVE_VERS 0x731fa727 -#define RPC_DOG_KEEPALIVE_BEACON 2 -#else -#error "Unsupported AMSS version" -#endif -#define DOG_KEEPALIVE_VERS_COMP 0x00010001 -#define RPC_DOG_KEEPALIVE_NULL 0 - - -/* TODO: Remove server registration with _VERS when modem is upated with _COMP*/ - -static int handle_rpc_call(struct msm_rpc_server *server, - struct rpc_request_hdr *req, unsigned len) -{ - switch (req->procedure) { - case RPC_DOG_KEEPALIVE_NULL: - return 0; - case RPC_DOG_KEEPALIVE_BEACON: - return 0; - default: - return -ENODEV; - } -} - -static struct msm_rpc_server rpc_server[] = { - { - .prog = DOG_KEEPALIVE_PROG, - .vers = DOG_KEEPALIVE_VERS, - .rpc_call = handle_rpc_call, - }, - { - .prog = DOG_KEEPALIVE_PROG, - .vers = DOG_KEEPALIVE_VERS_COMP, - .rpc_call = handle_rpc_call, - }, -}; - -static int __init rpc_server_init(void) -{ - /* Dual server registration to support backwards compatibility vers */ - int ret; - ret = msm_rpc_create_server(&rpc_server[1]); - if (ret < 0) - return ret; - return msm_rpc_create_server(&rpc_server[0]); -} - - -module_init(rpc_server_init); diff --git a/arch/arm/mach-msm/rpc_server_handset.c b/arch/arm/mach-msm/rpc_server_handset.c deleted file mode 100644 index 821e921d3b0e64ea3b2fbf7e0a5a6e81a8c2a5d6..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpc_server_handset.c +++ /dev/null @@ -1,712 +0,0 @@ -/* arch/arm/mach-msm/rpc_server_handset.c - * - * Copyright (c) 2008-2010,2012-2013 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 -#include -#include -#include -#include -#include - -#include -#include -#include - -#define DRIVER_NAME "msm-handset" - -#define HS_SERVER_PROG 0x30000062 -#define HS_SERVER_VERS 0x00010001 - -#define HS_RPC_PROG 0x30000091 - -#define HS_PROCESS_CMD_PROC 0x02 -#define HS_SUBSCRIBE_SRVC_PROC 0x03 -#define HS_REPORT_EVNT_PROC 0x05 -#define HS_EVENT_CB_PROC 1 -#define HS_EVENT_DATA_VER 1 - -#define RPC_KEYPAD_NULL_PROC 0 -#define RPC_KEYPAD_PASS_KEY_CODE_PROC 2 -#define RPC_KEYPAD_SET_PWR_KEY_STATE_PROC 3 - -#define HS_PWR_K 0x6F /* Power key */ -#define HS_END_K 0x51 /* End key or Power key */ -#define HS_STEREO_HEADSET_K 0x82 -#define HS_HEADSET_SWITCH_K 0x84 -#define HS_HEADSET_SWITCH_2_K 0xF0 -#define HS_HEADSET_SWITCH_3_K 0xF1 -#define HS_HEADSET_HEADPHONE_K 0xF6 -#define HS_HEADSET_MICROPHONE_K 0xF7 -#define HS_REL_K 0xFF /* key release */ - -#define SW_HEADPHONE_INSERT_W_MIC 1 /* HS with mic */ - -#define KEY(hs_key, input_key) ((hs_key << 24) | input_key) - -enum hs_event { - HS_EVNT_EXT_PWR = 0, /* External Power status */ - HS_EVNT_HSD, /* Headset Detection */ - HS_EVNT_HSTD, /* Headset Type Detection */ - HS_EVNT_HSSD, /* Headset Switch Detection */ - HS_EVNT_KPD, - HS_EVNT_FLIP, /* Flip / Clamshell status (open/close) */ - HS_EVNT_CHARGER, /* Battery is being charged or not */ - HS_EVNT_ENV, /* Events from runtime environment like DEM */ - HS_EVNT_REM, /* Events received from HS counterpart on a - remote processor*/ - HS_EVNT_DIAG, /* Diag Events */ - HS_EVNT_LAST, /* Should always be the last event type */ - HS_EVNT_MAX /* Force enum to be an 32-bit number */ -}; - -enum hs_src_state { - HS_SRC_STATE_UNKWN = 0, - HS_SRC_STATE_LO, - HS_SRC_STATE_HI, -}; - -struct hs_event_data { - uint32_t ver; /* Version number */ - enum hs_event event_type; /* Event Type */ - enum hs_event enum_disc; /* discriminator */ - uint32_t data_length; /* length of the next field */ - enum hs_src_state data; /* Pointer to data */ - uint32_t data_size; /* Elements to be processed in data */ -}; - -enum hs_return_value { - HS_EKPDLOCKED = -2, /* Operation failed because keypad is locked */ - HS_ENOTSUPPORTED = -1, /* Functionality not supported */ - HS_FALSE = 0, /* Inquired condition is not true */ - HS_FAILURE = 0, /* Requested operation was not successful */ - HS_TRUE = 1, /* Inquired condition is true */ - HS_SUCCESS = 1, /* Requested operation was successful */ - HS_MAX_RETURN = 0x7FFFFFFF/* Force enum to be a 32 bit number */ -}; - -struct hs_key_data { - uint32_t ver; /* Version number to track sturcture changes */ - uint32_t code; /* which key? */ - uint32_t parm; /* key status. Up/down or pressed/released */ -}; - -enum hs_subs_srvc { - HS_SUBS_SEND_CMD = 0, /* Subscribe to send commands to HS */ - HS_SUBS_RCV_EVNT, /* Subscribe to receive Events from HS */ - HS_SUBS_SRVC_MAX -}; - -enum hs_subs_req { - HS_SUBS_REGISTER, /* Subscribe */ - HS_SUBS_CANCEL, /* Unsubscribe */ - HS_SUB_STATUS_MAX -}; - -enum hs_event_class { - HS_EVNT_CLASS_ALL = 0, /* All HS events */ - HS_EVNT_CLASS_LAST, /* Should always be the last class type */ - HS_EVNT_CLASS_MAX -}; - -enum hs_cmd_class { - HS_CMD_CLASS_LCD = 0, /* Send LCD related commands */ - HS_CMD_CLASS_KPD, /* Send KPD related commands */ - HS_CMD_CLASS_LAST, /* Should always be the last class type */ - HS_CMD_CLASS_MAX -}; - -/* - * Receive events or send command - */ -union hs_subs_class { - enum hs_event_class evnt; - enum hs_cmd_class cmd; -}; - -struct hs_subs { - uint32_t ver; - enum hs_subs_srvc srvc; /* commands or events */ - enum hs_subs_req req; /* subscribe or unsubscribe */ - uint32_t host_os; - enum hs_subs_req disc; /* discriminator */ - union hs_subs_class id; -}; - -struct hs_event_cb_recv { - uint32_t cb_id; - uint32_t hs_key_data_ptr; - struct hs_key_data key; -}; -enum hs_ext_cmd_type { - HS_EXT_CMD_KPD_SEND_KEY = 0, /* Send Key */ - HS_EXT_CMD_KPD_BKLT_CTRL, /* Keypad backlight intensity */ - HS_EXT_CMD_LCD_BKLT_CTRL, /* LCD Backlight intensity */ - HS_EXT_CMD_DIAG_KEYMAP, /* Emulating a Diag key sequence */ - HS_EXT_CMD_DIAG_LOCK, /* Device Lock/Unlock */ - HS_EXT_CMD_GET_EVNT_STATUS, /* Get the status for one of the drivers */ - HS_EXT_CMD_KPD_GET_KEYS_STATUS,/* Get a list of keys status */ - HS_EXT_CMD_KPD_SET_PWR_KEY_RST_THOLD, /* PWR Key HW Reset duration */ - HS_EXT_CMD_KPD_SET_PWR_KEY_THOLD, /* Set pwr key threshold duration */ - HS_EXT_CMD_LAST, /* Should always be the last command type */ - HS_EXT_CMD_MAX = 0x7FFFFFFF /* Force enum to be an 32-bit number */ -}; - -struct hs_cmd_data_type { - uint32_t hs_cmd_data_type_ptr; /* hs_cmd_data_type ptr length */ - uint32_t ver; /* version */ - enum hs_ext_cmd_type id; /* command id */ - uint32_t handle; /* handle returned from subscribe proc */ - enum hs_ext_cmd_type disc_id1; /* discriminator id */ - uint32_t input_ptr; /* input ptr length */ - uint32_t input_val; /* command specific data */ - uint32_t input_len; /* length of command input */ - enum hs_ext_cmd_type disc_id2; /* discriminator id */ - uint32_t output_len; /* length of output data */ - uint32_t delayed; /* execution context for modem - true - caller context - false - hs task context*/ -}; - -static const uint32_t hs_key_map[] = { - KEY(HS_PWR_K, KEY_POWER), - KEY(HS_END_K, KEY_END), - KEY(HS_STEREO_HEADSET_K, SW_HEADPHONE_INSERT_W_MIC), - KEY(HS_HEADSET_HEADPHONE_K, SW_HEADPHONE_INSERT), - KEY(HS_HEADSET_MICROPHONE_K, SW_MICROPHONE_INSERT), - KEY(HS_HEADSET_SWITCH_K, KEY_MEDIA), - KEY(HS_HEADSET_SWITCH_2_K, KEY_VOLUMEUP), - KEY(HS_HEADSET_SWITCH_3_K, KEY_VOLUMEDOWN), - 0 -}; - -enum { - NO_DEVICE = 0, - MSM_HEADSET = 1, -}; -/* Add newer versions at the top of array */ -static const unsigned int rpc_vers[] = { - 0x00030001, - 0x00020001, - 0x00010001, -}; -/* hs subscription request parameters */ -struct hs_subs_rpc_req { - uint32_t hs_subs_ptr; - struct hs_subs hs_subs; - uint32_t hs_cb_id; - uint32_t hs_handle_ptr; - uint32_t hs_handle_data; -}; - -static struct hs_subs_rpc_req *hs_subs_req; - -struct msm_handset { - struct input_dev *ipdev; - struct switch_dev sdev; - struct msm_handset_platform_data *hs_pdata; - bool mic_on, hs_on; -}; - -static struct msm_rpc_client *rpc_client; -static struct msm_handset *hs; - -static int hs_find_key(uint32_t hscode) -{ - int i, key; - - key = KEY(hscode, 0); - - for (i = 0; hs_key_map[i] != 0; i++) { - if ((hs_key_map[i] & 0xff000000) == key) - return hs_key_map[i] & 0x00ffffff; - } - return -1; -} - -static void update_state(void) -{ - int state; - - if (hs->mic_on && hs->hs_on) - state = 1 << 0; - else if (hs->hs_on) - state = 1 << 1; - else if (hs->mic_on) - state = 1 << 2; - else - state = 0; - - switch_set_state(&hs->sdev, state); -} - -/* - * tuple format: (key_code, key_param) - * - * old-architecture: - * key-press = (key_code, 0) - * key-release = (0xff, key_code) - * - * new-architecutre: - * key-press = (key_code, 0) - * key-release = (key_code, 0xff) - */ -static void report_hs_key(uint32_t key_code, uint32_t key_parm) -{ - int key, temp_key_code; - - if (key_code == HS_REL_K) - key = hs_find_key(key_parm); - else - key = hs_find_key(key_code); - - temp_key_code = key_code; - - if (key_parm == HS_REL_K) - key_code = key_parm; - - switch (key) { - case KEY_POWER: - case KEY_END: - if (hs->hs_pdata->ignore_end_key) - input_report_key(hs->ipdev, KEY_POWER, - (key_code != HS_REL_K)); - else - input_report_key(hs->ipdev, key, - (key_code != HS_REL_K)); - break; - case KEY_MEDIA: - case KEY_VOLUMEUP: - case KEY_VOLUMEDOWN: - input_report_key(hs->ipdev, key, (key_code != HS_REL_K)); - break; - case SW_HEADPHONE_INSERT_W_MIC: - hs->mic_on = hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; - input_report_switch(hs->ipdev, SW_HEADPHONE_INSERT, - hs->hs_on); - input_report_switch(hs->ipdev, SW_MICROPHONE_INSERT, - hs->mic_on); - update_state(); - break; - - case SW_HEADPHONE_INSERT: - hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; - input_report_switch(hs->ipdev, key, hs->hs_on); - update_state(); - break; - case SW_MICROPHONE_INSERT: - hs->mic_on = (key_code != HS_REL_K) ? 1 : 0; - input_report_switch(hs->ipdev, key, hs->mic_on); - update_state(); - break; - case -1: - printk(KERN_ERR "%s: No mapping for remote handset event %d\n", - __func__, temp_key_code); - return; - } - input_sync(hs->ipdev); -} - -static int handle_hs_rpc_call(struct msm_rpc_server *server, - struct rpc_request_hdr *req, unsigned len) -{ - struct rpc_keypad_pass_key_code_args { - uint32_t key_code; - uint32_t key_parm; - }; - - switch (req->procedure) { - case RPC_KEYPAD_NULL_PROC: - return 0; - - case RPC_KEYPAD_PASS_KEY_CODE_PROC: { - struct rpc_keypad_pass_key_code_args *args; - - args = (struct rpc_keypad_pass_key_code_args *)(req + 1); - args->key_code = be32_to_cpu(args->key_code); - args->key_parm = be32_to_cpu(args->key_parm); - - report_hs_key(args->key_code, args->key_parm); - - return 0; - } - - case RPC_KEYPAD_SET_PWR_KEY_STATE_PROC: - /* This RPC function must be available for the ARM9 - * to function properly. This function is redundant - * when RPC_KEYPAD_PASS_KEY_CODE_PROC is handled. So - * input_report_key is not needed. - */ - return 0; - default: - return -ENODEV; - } -} - -static struct msm_rpc_server hs_rpc_server = { - .prog = HS_SERVER_PROG, - .vers = HS_SERVER_VERS, - .rpc_call = handle_hs_rpc_call, -}; - -static int process_subs_srvc_callback(struct hs_event_cb_recv *recv) -{ - if (!recv) - return -ENODATA; - - report_hs_key(be32_to_cpu(recv->key.code), be32_to_cpu(recv->key.parm)); - - return 0; -} - -static void process_hs_rpc_request(uint32_t proc, void *data) -{ - if (proc == HS_EVENT_CB_PROC) - process_subs_srvc_callback(data); - else - pr_err("%s: unknown rpc proc %d\n", __func__, proc); -} - -static int hs_rpc_report_event_arg(struct msm_rpc_client *client, - void *buffer, void *data) -{ - struct hs_event_rpc_req { - uint32_t hs_event_data_ptr; - struct hs_event_data data; - }; - - struct hs_event_rpc_req *req = buffer; - - req->hs_event_data_ptr = cpu_to_be32(0x1); - req->data.ver = cpu_to_be32(HS_EVENT_DATA_VER); - req->data.event_type = cpu_to_be32(HS_EVNT_HSD); - req->data.enum_disc = cpu_to_be32(HS_EVNT_HSD); - req->data.data_length = cpu_to_be32(0x1); - req->data.data = cpu_to_be32(*(enum hs_src_state *)data); - req->data.data_size = cpu_to_be32(sizeof(enum hs_src_state)); - - return sizeof(*req); -} - -static int hs_rpc_report_event_res(struct msm_rpc_client *client, - void *buffer, void *data) -{ - enum hs_return_value result; - - result = be32_to_cpu(*(enum hs_return_value *)buffer); - pr_debug("%s: request completed: 0x%x\n", __func__, result); - - if (result == HS_SUCCESS) - return 0; - - return 1; -} - -void report_headset_status(bool connected) -{ - int rc = -1; - enum hs_src_state status; - - if (connected == true) - status = HS_SRC_STATE_HI; - else - status = HS_SRC_STATE_LO; - - rc = msm_rpc_client_req(rpc_client, HS_REPORT_EVNT_PROC, - hs_rpc_report_event_arg, &status, - hs_rpc_report_event_res, NULL, -1); - - if (rc) - pr_err("%s: couldn't send rpc client request\n", __func__); -} -EXPORT_SYMBOL(report_headset_status); - -static int hs_rpc_pwr_cmd_arg(struct msm_rpc_client *client, - void *buffer, void *data) -{ - struct hs_cmd_data_type *hs_pwr_cmd = buffer; - - hs_pwr_cmd->hs_cmd_data_type_ptr = cpu_to_be32(0x01); - - hs_pwr_cmd->ver = cpu_to_be32(0x03); - hs_pwr_cmd->id = cpu_to_be32(HS_EXT_CMD_KPD_SET_PWR_KEY_THOLD); - hs_pwr_cmd->handle = cpu_to_be32(hs_subs_req->hs_handle_data); - hs_pwr_cmd->disc_id1 = cpu_to_be32(HS_EXT_CMD_KPD_SET_PWR_KEY_THOLD); - hs_pwr_cmd->input_ptr = cpu_to_be32(0x01); - hs_pwr_cmd->input_val = cpu_to_be32(hs->hs_pdata->pwr_key_delay_ms); - hs_pwr_cmd->input_len = cpu_to_be32(0x01); - hs_pwr_cmd->disc_id2 = cpu_to_be32(HS_EXT_CMD_KPD_SET_PWR_KEY_THOLD); - hs_pwr_cmd->output_len = cpu_to_be32(0x00); - hs_pwr_cmd->delayed = cpu_to_be32(0x00); - - return sizeof(*hs_pwr_cmd); -} - -static int hs_rpc_pwr_cmd_res(struct msm_rpc_client *client, - void *buffer, void *data) -{ - uint32_t result; - - result = be32_to_cpu(*((uint32_t *)buffer)); - pr_debug("%s: request completed: 0x%x\n", __func__, result); - - return 0; -} - -static int hs_rpc_register_subs_arg(struct msm_rpc_client *client, - void *buffer, void *data) -{ - hs_subs_req = buffer; - - hs_subs_req->hs_subs_ptr = cpu_to_be32(0x1); - hs_subs_req->hs_subs.ver = cpu_to_be32(0x1); - hs_subs_req->hs_subs.srvc = cpu_to_be32(HS_SUBS_RCV_EVNT); - hs_subs_req->hs_subs.req = cpu_to_be32(HS_SUBS_REGISTER); - hs_subs_req->hs_subs.host_os = cpu_to_be32(0x4); /* linux */ - hs_subs_req->hs_subs.disc = cpu_to_be32(HS_SUBS_RCV_EVNT); - hs_subs_req->hs_subs.id.evnt = cpu_to_be32(HS_EVNT_CLASS_ALL); - - hs_subs_req->hs_cb_id = cpu_to_be32(0x1); - - hs_subs_req->hs_handle_ptr = cpu_to_be32(0x1); - hs_subs_req->hs_handle_data = cpu_to_be32(0x0); - - return sizeof(*hs_subs_req); -} - -static int hs_rpc_register_subs_res(struct msm_rpc_client *client, - void *buffer, void *data) -{ - uint32_t result; - - result = be32_to_cpu(*((uint32_t *)buffer)); - pr_debug("%s: request completed: 0x%x\n", __func__, result); - - return 0; -} - -static int hs_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) -{ - int rc = -1; - - struct rpc_request_hdr *hdr = buffer; - - hdr->type = be32_to_cpu(hdr->type); - hdr->xid = be32_to_cpu(hdr->xid); - hdr->rpc_vers = be32_to_cpu(hdr->rpc_vers); - hdr->prog = be32_to_cpu(hdr->prog); - hdr->vers = be32_to_cpu(hdr->vers); - hdr->procedure = be32_to_cpu(hdr->procedure); - - process_hs_rpc_request(hdr->procedure, - (void *) (hdr + 1)); - - msm_rpc_start_accepted_reply(client, hdr->xid, - RPC_ACCEPTSTAT_SUCCESS); - rc = msm_rpc_send_accepted_reply(client, 0); - if (rc) { - pr_err("%s: sending reply failed: %d\n", __func__, rc); - return rc; - } - - return 0; -} - -static int hs_rpc_cb_init(void) -{ - int rc = 0, i, num_vers; - - num_vers = ARRAY_SIZE(rpc_vers); - - for (i = 0; i < num_vers; i++) { - rpc_client = msm_rpc_register_client("hs", - HS_RPC_PROG, rpc_vers[i], 0, hs_cb_func); - - if (IS_ERR(rpc_client)) - pr_debug("%s: RPC Client version %d failed, fallback\n", - __func__, rpc_vers[i]); - else - break; - } - - if (IS_ERR(rpc_client)) { - pr_err("%s: Incompatible RPC version error %ld\n", - __func__, PTR_ERR(rpc_client)); - return PTR_ERR(rpc_client); - } - - rc = msm_rpc_client_req(rpc_client, HS_SUBSCRIBE_SRVC_PROC, - hs_rpc_register_subs_arg, NULL, - hs_rpc_register_subs_res, NULL, -1); - if (rc) { - pr_err("%s: RPC client request failed for subscribe services\n", - __func__); - goto err_client_req; - } - - rc = msm_rpc_client_req(rpc_client, HS_PROCESS_CMD_PROC, - hs_rpc_pwr_cmd_arg, NULL, - hs_rpc_pwr_cmd_res, NULL, -1); - if (rc) - pr_err("%s: RPC client request failed for pwr key" - " delay cmd, using normal mode\n", __func__); - return 0; -err_client_req: - msm_rpc_unregister_client(rpc_client); - return rc; -} - -static int hs_rpc_init(void) -{ - int rc; - - rc = hs_rpc_cb_init(); - if (rc) { - pr_err("%s: failed to initialize rpc client, try server...\n", - __func__); - - rc = msm_rpc_create_server(&hs_rpc_server); - if (rc) { - pr_err("%s: failed to create rpc server\n", __func__); - return rc; - } - } - - return rc; -} - -static void hs_rpc_deinit(void) -{ - if (rpc_client) - msm_rpc_unregister_client(rpc_client); -} - -static ssize_t msm_headset_print_name(struct switch_dev *sdev, char *buf) -{ - switch (switch_get_state(&hs->sdev)) { - case NO_DEVICE: - return sprintf(buf, "No Device\n"); - case MSM_HEADSET: - return sprintf(buf, "Headset\n"); - } - return -EINVAL; -} - -static int hs_probe(struct platform_device *pdev) -{ - int rc = 0; - struct input_dev *ipdev; - - hs = kzalloc(sizeof(struct msm_handset), GFP_KERNEL); - if (!hs) - return -ENOMEM; - - hs->sdev.name = "h2w"; - hs->sdev.print_name = msm_headset_print_name; - - rc = switch_dev_register(&hs->sdev); - if (rc) - goto err_switch_dev_register; - - ipdev = input_allocate_device(); - if (!ipdev) { - rc = -ENOMEM; - goto err_alloc_input_dev; - } - input_set_drvdata(ipdev, hs); - - hs->ipdev = ipdev; - - if (pdev->dev.platform_data) - hs->hs_pdata = pdev->dev.platform_data; - - if (hs->hs_pdata->hs_name) - ipdev->name = hs->hs_pdata->hs_name; - else - ipdev->name = DRIVER_NAME; - - ipdev->id.vendor = 0x0001; - ipdev->id.product = 1; - ipdev->id.version = 1; - - input_set_capability(ipdev, EV_KEY, KEY_MEDIA); - input_set_capability(ipdev, EV_KEY, KEY_VOLUMEUP); - input_set_capability(ipdev, EV_KEY, KEY_VOLUMEDOWN); - input_set_capability(ipdev, EV_SW, SW_HEADPHONE_INSERT); - input_set_capability(ipdev, EV_SW, SW_MICROPHONE_INSERT); - input_set_capability(ipdev, EV_KEY, KEY_POWER); - input_set_capability(ipdev, EV_KEY, KEY_END); - - rc = input_register_device(ipdev); - if (rc) { - dev_err(&ipdev->dev, - "hs_probe: input_register_device rc=%d\n", rc); - goto err_reg_input_dev; - } - - platform_set_drvdata(pdev, hs); - - rc = hs_rpc_init(); - if (rc) { - dev_err(&ipdev->dev, "rpc init failure\n"); - goto err_hs_rpc_init; - } - - return 0; - -err_hs_rpc_init: - input_unregister_device(ipdev); - ipdev = NULL; -err_reg_input_dev: - input_free_device(ipdev); -err_alloc_input_dev: - switch_dev_unregister(&hs->sdev); -err_switch_dev_register: - kfree(hs); - return rc; -} - -static int hs_remove(struct platform_device *pdev) -{ - struct msm_handset *hs = platform_get_drvdata(pdev); - - input_unregister_device(hs->ipdev); - switch_dev_unregister(&hs->sdev); - kfree(hs); - hs_rpc_deinit(); - return 0; -} - -static struct platform_driver hs_driver = { - .probe = hs_probe, - .remove = hs_remove, - .driver = { - .name = DRIVER_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init hs_init(void) -{ - return platform_driver_register(&hs_driver); -} -late_initcall(hs_init); - -static void __exit hs_exit(void) -{ - platform_driver_unregister(&hs_driver); -} -module_exit(hs_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:msm-handset"); diff --git a/arch/arm/mach-msm/rpc_server_time_remote.c b/arch/arm/mach-msm/rpc_server_time_remote.c deleted file mode 100644 index df2af6fbc61604bcf3d8bbf28f88fecb7272a459..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpc_server_time_remote.c +++ /dev/null @@ -1,168 +0,0 @@ -/* arch/arm/mach-msm/rpc_server_time_remote.c - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2009-2011 The Linux Foundation. All rights reserved. - * Author: Iliyan Malchev - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include "rpc_server_time_remote.h" -#include -#include -#include - -/* time_remote_mtoa server definitions. */ - -#define TIME_REMOTE_MTOA_PROG 0x3000005d -#define TIME_REMOTE_MTOA_VERS_OLD 0 -#define TIME_REMOTE_MTOA_VERS 0x9202a8e4 -#define TIME_REMOTE_MTOA_VERS_COMP 0x00010002 -#define RPC_TIME_REMOTE_MTOA_NULL 0 -#define RPC_TIME_TOD_SET_APPS_BASES 2 -#define RPC_TIME_GET_APPS_USER_TIME 3 - -struct rpc_time_tod_set_apps_bases_args { - uint32_t tick; - uint64_t stamp; -}; - -static int read_rtc0_time(struct msm_rpc_server *server, - struct rpc_request_hdr *req, - unsigned len) -{ - int err; - unsigned long tm_sec; - uint32_t size = 0; - void *reply; - uint32_t output_valid; - uint32_t rpc_status = RPC_ACCEPTSTAT_SYSTEM_ERR; - struct rtc_time tm; - struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); - - if (rtc == NULL) { - pr_err("%s: unable to open rtc device (%s)\n", - __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); - goto send_reply; - } - - err = rtc_read_time(rtc, &tm); - if (err) { - pr_err("%s: Error reading rtc device (%s) : %d\n", - __FILE__, CONFIG_RTC_HCTOSYS_DEVICE, err); - goto close_dev; - } - - err = rtc_valid_tm(&tm); - if (err) { - pr_err("%s: Invalid RTC time (%s)\n", - __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); - goto close_dev; - } - - rtc_tm_to_time(&tm, &tm_sec); - rpc_status = RPC_ACCEPTSTAT_SUCCESS; - -close_dev: - rtc_class_close(rtc); - -send_reply: - reply = msm_rpc_server_start_accepted_reply(server, req->xid, - rpc_status); - if (rpc_status == RPC_ACCEPTSTAT_SUCCESS) { - output_valid = *((uint32_t *)(req + 1)); - *(uint32_t *)reply = output_valid; - size = sizeof(uint32_t); - if (be32_to_cpu(output_valid)) { - reply += sizeof(uint32_t); - *(uint32_t *)reply = cpu_to_be32(tm_sec); - size += sizeof(uint32_t); - } - } - err = msm_rpc_server_send_accepted_reply(server, size); - if (err) - pr_err("%s: send accepted reply failed: %d\n", __func__, err); - - return 1; -} - -static int handle_rpc_call(struct msm_rpc_server *server, - struct rpc_request_hdr *req, unsigned len) -{ - struct timespec ts, tv; - - switch (req->procedure) { - case RPC_TIME_REMOTE_MTOA_NULL: - return 0; - - case RPC_TIME_TOD_SET_APPS_BASES: { - struct rpc_time_tod_set_apps_bases_args *args; - args = (struct rpc_time_tod_set_apps_bases_args *)(req + 1); - args->tick = be32_to_cpu(args->tick); - args->stamp = be64_to_cpu(args->stamp); - printk(KERN_INFO "RPC_TIME_TOD_SET_APPS_BASES:\n" - "\ttick = %d\n" - "\tstamp = %lld\n", - args->tick, args->stamp); - getnstimeofday(&ts); - msmrtc_updateatsuspend(&ts); - rtc_hctosys(); - getnstimeofday(&tv); - /* Update the alarm information with the new time info. */ - alarm_update_timedelta(ts, tv); - return 0; - } - - case RPC_TIME_GET_APPS_USER_TIME: - return read_rtc0_time(server, req, len); - - default: - return -ENODEV; - } -} - -static struct msm_rpc_server rpc_server[] = { - { - .prog = TIME_REMOTE_MTOA_PROG, - .vers = TIME_REMOTE_MTOA_VERS_OLD, - .rpc_call = handle_rpc_call, - }, - { - .prog = TIME_REMOTE_MTOA_PROG, - .vers = TIME_REMOTE_MTOA_VERS, - .rpc_call = handle_rpc_call, - }, - { - .prog = TIME_REMOTE_MTOA_PROG, - .vers = TIME_REMOTE_MTOA_VERS_COMP, - .rpc_call = handle_rpc_call, - }, -}; - -static int __init rpc_server_init(void) -{ - /* Dual server registration to support backwards compatibility vers */ - int ret; - ret = msm_rpc_create_server(&rpc_server[2]); - if (ret < 0) - return ret; - ret = msm_rpc_create_server(&rpc_server[1]); - if (ret < 0) - return ret; - return msm_rpc_create_server(&rpc_server[0]); -} - - -module_init(rpc_server_init); diff --git a/arch/arm/mach-msm/rpc_server_time_remote.h b/arch/arm/mach-msm/rpc_server_time_remote.h deleted file mode 100644 index ee97de78db67b881fd67bac2bf3a7cd3884d7a72..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpc_server_time_remote.h +++ /dev/null @@ -1,21 +0,0 @@ -/* arch/arm/mach-msm/rpc_server_time_remote.h - * - * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __ARCH_ARM_MACH_MSM_RPC_SERVER_TIME_REMOTE_H -#define __ARCH_ARM_MACH_MSM_RPC_SERVER_TIME_REMOTE_H - -int rtc_hctosys(void); - -#endif diff --git a/arch/arm/mach-msm/rpcrouter_smd_xprt.c b/arch/arm/mach-msm/rpcrouter_smd_xprt.c deleted file mode 100644 index 931bc76a1f843819475714ef20ce1119ea1278f3..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpcrouter_smd_xprt.c +++ /dev/null @@ -1,334 +0,0 @@ -/* Copyright (c) 2010-2011, 2013 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. - * - */ - -/* - * RPCROUTER SMD XPRT module. - */ - -#include -#include -#include -#include - -#include -#include -#include "smd_rpcrouter.h" - -struct rpcrouter_smd_xprt { - struct rpcrouter_xprt xprt; - - smd_channel_t *channel; -}; - -static struct rpcrouter_smd_xprt smd_remote_xprt; -#ifdef CONFIG_ARCH_FSM9XXX -static struct rpcrouter_smd_xprt smd_remote_qdsp_xprt; -#endif - -static int rpcrouter_smd_remote_read_avail(void) -{ - return smd_read_avail(smd_remote_xprt.channel); -} - -static int rpcrouter_smd_remote_read(void *data, uint32_t len) -{ - return smd_read(smd_remote_xprt.channel, data, len); -} - -static int rpcrouter_smd_remote_write_avail(void) -{ - return smd_write_avail(smd_remote_xprt.channel); -} - -static int rpcrouter_smd_remote_write(void *data, uint32_t len, uint32_t type) -{ - return smd_write(smd_remote_xprt.channel, data, len); -} - -static int rpcrouter_smd_remote_close(void) -{ - smsm_change_state(SMSM_APPS_STATE, SMSM_RPCINIT, 0); - return smd_close(smd_remote_xprt.channel); -} - -static void rpcrouter_smd_remote_notify(void *_dev, unsigned event) -{ - switch (event) { - case SMD_EVENT_DATA: - msm_rpcrouter_xprt_notify(&smd_remote_xprt.xprt, - RPCROUTER_XPRT_EVENT_DATA); - break; - - case SMD_EVENT_OPEN: - pr_info("%s: smd opened 0x%p\n", __func__, _dev); - - msm_rpcrouter_xprt_notify(&smd_remote_xprt.xprt, - RPCROUTER_XPRT_EVENT_OPEN); - break; - - case SMD_EVENT_CLOSE: - pr_info("%s: smd closed 0x%p\n", __func__, _dev); - - msm_rpcrouter_xprt_notify(&smd_remote_xprt.xprt, - RPCROUTER_XPRT_EVENT_CLOSE); - break; - } -} - -#ifdef CONFIG_ARCH_FSM9XXX -static int rpcrouter_smd_remote_qdsp_read_avail(void) -{ - return smd_read_avail(smd_remote_qdsp_xprt.channel); -} - -static int rpcrouter_smd_remote_qdsp_read(void *data, uint32_t len) -{ - return smd_read(smd_remote_qdsp_xprt.channel, data, len); -} - -static int rpcrouter_smd_remote_qdsp_write_avail(void) -{ - return smd_write_avail(smd_remote_qdsp_xprt.channel); -} - -static int rpcrouter_smd_remote_qdsp_write(void *data, - uint32_t len, uint32_t type) -{ - return smd_write(smd_remote_qdsp_xprt.channel, data, len); -} - -static int rpcrouter_smd_remote_qdsp_close(void) -{ - /* - * TBD: Implement when we have N way SMSM ported - * smsm_change_state(SMSM_APPS_STATE, SMSM_RPCINIT, 0); - */ - return smd_close(smd_remote_qdsp_xprt.channel); -} - -static void rpcrouter_smd_remote_qdsp_notify(void *_dev, unsigned event) -{ - switch (event) { - case SMD_EVENT_DATA: - msm_rpcrouter_xprt_notify(&smd_remote_qdsp_xprt.xprt, - RPCROUTER_XPRT_EVENT_DATA); - break; - - case SMD_EVENT_OPEN: - /* Print log info */ - pr_debug("%s: smd opened\n", __func__); - - msm_rpcrouter_xprt_notify(&smd_remote_qdsp_xprt.xprt, - RPCROUTER_XPRT_EVENT_OPEN); - break; - - case SMD_EVENT_CLOSE: - /* Print log info */ - pr_debug("%s: smd closed\n", __func__); - - msm_rpcrouter_xprt_notify(&smd_remote_qdsp_xprt.xprt, - RPCROUTER_XPRT_EVENT_CLOSE); - break; - } -} - -static int rpcrouter_smd_remote_qdsp_probe(struct platform_device *pdev) -{ - int rc; - - smd_remote_qdsp_xprt.xprt.name = "rpcrotuer_smd_qdsp_xprt"; - smd_remote_qdsp_xprt.xprt.read_avail = - rpcrouter_smd_remote_qdsp_read_avail; - smd_remote_qdsp_xprt.xprt.read = rpcrouter_smd_remote_qdsp_read; - smd_remote_qdsp_xprt.xprt.write_avail = - rpcrouter_smd_remote_qdsp_write_avail; - smd_remote_qdsp_xprt.xprt.write = rpcrouter_smd_remote_qdsp_write; - smd_remote_qdsp_xprt.xprt.close = rpcrouter_smd_remote_qdsp_close; - smd_remote_qdsp_xprt.xprt.priv = NULL; - - /* Open up SMD channel */ - rc = smd_named_open_on_edge("RPCCALL_QDSP", SMD_APPS_QDSP, - &smd_remote_qdsp_xprt.channel, NULL, - rpcrouter_smd_remote_qdsp_notify); - if (rc < 0) - return rc; - - smd_disable_read_intr(smd_remote_qdsp_xprt.channel); - - return 0; -} - -static struct platform_driver rpcrouter_smd_remote_qdsp_driver = { - .probe = rpcrouter_smd_remote_qdsp_probe, - .driver = { - .name = "RPCCALL_QDSP", - .owner = THIS_MODULE, - }, -}; - -static inline int register_smd_remote_qpsp_driver(void) -{ - return platform_driver_register(&rpcrouter_smd_remote_qdsp_driver); -} -#else /* CONFIG_ARCH_FSM9XXX */ -static inline int register_smd_remote_qpsp_driver(void) -{ - return 0; -} -#endif - -#if defined(CONFIG_MSM_RPC_LOOPBACK_XPRT) - -static struct rpcrouter_smd_xprt smd_loopback_xprt; - -static int rpcrouter_smd_loopback_read_avail(void) -{ - return smd_read_avail(smd_loopback_xprt.channel); -} - -static int rpcrouter_smd_loopback_read(void *data, uint32_t len) -{ - return smd_read(smd_loopback_xprt.channel, data, len); -} - -static int rpcrouter_smd_loopback_write_avail(void) -{ - return smd_write_avail(smd_loopback_xprt.channel); -} - -static int rpcrouter_smd_loopback_write(void *data, uint32_t len, uint32 type) -{ - return smd_write(smd_loopback_xprt.channel, data, len); -} - -static int rpcrouter_smd_loopback_close(void) -{ - return smd_close(smd_loopback_xprt.channel); -} - -static void rpcrouter_smd_loopback_notify(void *_dev, unsigned event) -{ - switch (event) { - case SMD_EVENT_DATA: - msm_rpcrouter_xprt_notify(&smd_loopback_xprt.xprt, - RPCROUTER_XPRT_EVENT_DATA); - break; - - case SMD_EVENT_OPEN: - pr_debug("%s: smd loopback opened 0x%p\n", __func__, _dev); - - msm_rpcrouter_xprt_notify(&smd_loopback_xprt.xprt, - RPCROUTER_XPRT_EVENT_OPEN); - break; - - case SMD_EVENT_CLOSE: - pr_debug("%s: smd loopback closed 0x%p\n", __func__, _dev); - - msm_rpcrouter_xprt_notify(&smd_loopback_xprt.xprt, - RPCROUTER_XPRT_EVENT_CLOSE); - break; - } -} - -static int rpcrouter_smd_loopback_probe(struct platform_device *pdev) -{ - int rc; - - smd_loopback_xprt.xprt.name = "rpcrouter_loopback_xprt"; - smd_loopback_xprt.xprt.read_avail = rpcrouter_smd_loopback_read_avail; - smd_loopback_xprt.xprt.read = rpcrouter_smd_loopback_read; - smd_loopback_xprt.xprt.write_avail = rpcrouter_smd_loopback_write_avail; - smd_loopback_xprt.xprt.write = rpcrouter_smd_loopback_write; - smd_loopback_xprt.xprt.close = rpcrouter_smd_loopback_close; - smd_loopback_xprt.xprt.priv = NULL; - - /* Open up SMD LOOPBACK channel */ - rc = smd_named_open_on_edge("local_loopback", SMD_LOOPBACK_TYPE, - &smd_loopback_xprt.channel, NULL, - rpcrouter_smd_loopback_notify); - if (rc < 0) - return rc; - - smd_disable_read_intr(smd_remote_xprt.channel); - return 0; -} - -static struct platform_driver rpcrouter_smd_loopback_driver = { - .probe = rpcrouter_smd_loopback_probe, - .driver = { - .name = "local_loopback", - .owner = THIS_MODULE, - }, -}; - -static inline int register_smd_loopback_driver(void) -{ - return platform_driver_register(&rpcrouter_smd_loopback_driver); -} -#else /* CONFIG_MSM_RPC_LOOPBACK_XPRT */ -static inline int register_smd_loopback_driver(void) -{ - return 0; -} -#endif - -static int rpcrouter_smd_remote_probe(struct platform_device *pdev) -{ - int rc; - - smd_remote_xprt.xprt.name = "rpcrotuer_smd_xprt"; - smd_remote_xprt.xprt.read_avail = rpcrouter_smd_remote_read_avail; - smd_remote_xprt.xprt.read = rpcrouter_smd_remote_read; - smd_remote_xprt.xprt.write_avail = rpcrouter_smd_remote_write_avail; - smd_remote_xprt.xprt.write = rpcrouter_smd_remote_write; - smd_remote_xprt.xprt.close = rpcrouter_smd_remote_close; - smd_remote_xprt.xprt.priv = NULL; - - /* Open up SMD channel */ - rc = smd_named_open_on_edge("RPCCALL", SMD_APPS_MODEM, - &smd_remote_xprt.channel, NULL, - rpcrouter_smd_remote_notify); - if (rc < 0) - return rc; - - smd_disable_read_intr(smd_remote_xprt.channel); - - return 0; -} - -static struct platform_driver rpcrouter_smd_remote_driver = { - .probe = rpcrouter_smd_remote_probe, - .driver = { - .name = "RPCCALL", - .owner = THIS_MODULE, - }, -}; - -static int __init rpcrouter_smd_init(void) -{ - int rc; - - rc = register_smd_loopback_driver(); - if (rc < 0) - return rc; - - rc = register_smd_remote_qpsp_driver(); - if (rc < 0) - return rc; - - return platform_driver_register(&rpcrouter_smd_remote_driver); -} - -module_init(rpcrouter_smd_init); -MODULE_DESCRIPTION("RPC Router SMD XPRT"); -MODULE_LICENSE("GPL v2"); diff --git a/arch/arm/mach-msm/rpm-regulator-private.h b/arch/arm/mach-msm/rpm-regulator-private.h deleted file mode 100644 index 9836907f168215d8a325cd88a2972a0bf97af66a..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpm-regulator-private.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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 __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H -#define __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H - -#include -#include -#include - -/* Possible RPM regulator request types */ -enum rpm_regulator_type { - RPM_REGULATOR_TYPE_LDO, - RPM_REGULATOR_TYPE_SMPS, - RPM_REGULATOR_TYPE_VS, - RPM_REGULATOR_TYPE_NCP, - RPM_REGULATOR_TYPE_CORNER, - RPM_REGULATOR_TYPE_MAX = RPM_REGULATOR_TYPE_CORNER, -}; - -struct request_member { - int word; - unsigned int mask; - int shift; -}; - -/* Possible RPM regulator request members */ -struct rpm_vreg_parts { - struct request_member mV; /* voltage: used if voltage is in mV */ - struct request_member uV; /* voltage: used if voltage is in uV */ - struct request_member ip; /* peak current in mA */ - struct request_member pd; /* pull down enable */ - struct request_member ia; /* average current in mA */ - struct request_member fm; /* force mode */ - struct request_member pm; /* power mode */ - struct request_member pc; /* pin control */ - struct request_member pf; /* pin function */ - struct request_member enable_state; /* NCP and switch */ - struct request_member comp_mode; /* NCP */ - struct request_member freq; /* frequency: NCP and SMPS */ - struct request_member freq_clk_src; /* clock source: SMPS */ - struct request_member hpm; /* switch: control OCP and SS */ - int request_len; -}; - -struct vreg_range { - int min_uV; - int max_uV; - int step_uV; - unsigned n_voltages; -}; - -struct vreg_set_points { - struct vreg_range *range; - int count; - unsigned n_voltages; -}; - -struct vreg { - struct msm_rpm_iv_pair req[2]; - struct msm_rpm_iv_pair prev_active_req[2]; - struct msm_rpm_iv_pair prev_sleep_req[2]; - struct rpm_regulator_init_data pdata; - struct regulator_desc rdesc; - struct regulator_desc rdesc_pc; - struct regulator_dev *rdev; - struct regulator_dev *rdev_pc; - struct vreg_set_points *set_points; - struct rpm_vreg_parts *part; - int type; - int id; - bool requires_cxo; - struct mutex pc_lock; - int save_uV; - int mode; - bool is_enabled; - bool is_enabled_pc; - const int hpm_min_load; - int active_min_uV_vote[RPM_VREG_VOTER_COUNT]; - int sleep_min_uV_vote[RPM_VREG_VOTER_COUNT]; -}; - -struct vreg_config { - struct vreg *vregs; - int vregs_len; - - int vreg_id_min; - int vreg_id_max; - - int pin_func_none; - int pin_func_sleep_b; - - unsigned int mode_lpm; - unsigned int mode_hpm; - - struct vreg_set_points **set_points; - int set_points_len; - - const char **label_pin_ctrl; - int label_pin_ctrl_len; - const char **label_pin_func; - int label_pin_func_len; - const char **label_force_mode; - int label_force_mode_len; - const char **label_power_mode; - int label_power_mode_len; - - int (*is_real_id) (int vreg_id); - int (*pc_id_to_real_id) (int vreg_id); - - /* Legacy options to be used with MSM8660 */ - int use_legacy_optimum_mode; - int ia_follows_ip; -}; - -#define REQUEST_MEMBER(_word, _mask, _shift) \ - { \ - .word = _word, \ - .mask = _mask, \ - .shift = _shift, \ - } - -#define VOLTAGE_RANGE(_min_uV, _max_uV, _step_uV) \ - { \ - .min_uV = _min_uV, \ - .max_uV = _max_uV, \ - .step_uV = _step_uV, \ - } - -#define SET_POINTS(_ranges) \ -{ \ - .range = _ranges, \ - .count = ARRAY_SIZE(_ranges), \ -}; - -#define MICRO_TO_MILLI(uV) ((uV) / 1000) -#define MILLI_TO_MICRO(mV) ((mV) * 1000) - -#if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8X60) -struct vreg_config *get_config_8660(void); -#else -static inline struct vreg_config *get_config_8660(void) -{ - return NULL; -} -#endif - -#if defined(CONFIG_MSM_RPM_REGULATOR) && \ - (defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_APQ8064)) -struct vreg_config *get_config_8960(void); -struct vreg_config *get_config_8960_pm8917(void); -#else -static inline struct vreg_config *get_config_8960(void) -{ - return NULL; -} -static inline struct vreg_config *get_config_8960_pm8917(void) -{ - return NULL; -} -#endif - -#if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM9615) -struct vreg_config *get_config_9615(void); -#else -static inline struct vreg_config *get_config_9615(void) -{ - return NULL; -} -#endif - -#if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8930) -struct vreg_config *get_config_8930(void); -struct vreg_config *get_config_8930_pm8917(void); -#else -static inline struct vreg_config *get_config_8930(void) -{ - return NULL; -} -static inline struct vreg_config *get_config_8930_pm8917(void) -{ - return NULL; -} -#endif - -#endif diff --git a/arch/arm/mach-msm/rpm.c b/arch/arm/mach-msm/rpm.c deleted file mode 100644 index 02c856da962807ce348c93c011d3b641f1819371..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpm.c +++ /dev/null @@ -1,1023 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/****************************************************************************** - * Data type and structure definitions - *****************************************************************************/ - -struct msm_rpm_request { - struct msm_rpm_iv_pair *req; - int count; - uint32_t *ctx_mask_ack; - uint32_t *sel_masks_ack; - struct completion *done; -}; - -struct msm_rpm_notif_config { - struct msm_rpm_iv_pair iv[SEL_MASK_SIZE * 2]; -}; - -#define configured_iv(notif_cfg) ((notif_cfg)->iv) -#define registered_iv(notif_cfg) ((notif_cfg)->iv + msm_rpm_sel_mask_size) - -static uint32_t msm_rpm_sel_mask_size; -static struct msm_rpm_platform_data msm_rpm_data; - -static DEFINE_MUTEX(msm_rpm_mutex); -static DEFINE_SPINLOCK(msm_rpm_lock); -static DEFINE_SPINLOCK(msm_rpm_irq_lock); - -static struct msm_rpm_request *msm_rpm_request; -static struct msm_rpm_request msm_rpm_request_irq_mode; -static struct msm_rpm_request msm_rpm_request_poll_mode; - -static LIST_HEAD(msm_rpm_notifications); -static struct msm_rpm_notif_config msm_rpm_notif_cfgs[MSM_RPM_CTX_SET_COUNT]; -static bool msm_rpm_init_notif_done; -/****************************************************************************** - * Internal functions - *****************************************************************************/ - -static inline unsigned int target_enum(unsigned int id) -{ - BUG_ON(id >= MSM_RPM_ID_LAST); - return msm_rpm_data.target_id[id].id; -} - -static inline unsigned int target_status(unsigned int id) -{ - BUG_ON(id >= MSM_RPM_STATUS_ID_LAST); - return msm_rpm_data.target_status[id]; -} - -static inline unsigned int target_ctrl(unsigned int id) -{ - BUG_ON(id >= MSM_RPM_CTRL_LAST); - return msm_rpm_data.target_ctrl_id[id]; -} - -static inline uint32_t msm_rpm_read(unsigned int page, unsigned int reg) -{ - return __raw_readl(msm_rpm_data.reg_base_addrs[page] + reg * 4); -} - -static inline void msm_rpm_write( - unsigned int page, unsigned int reg, uint32_t value) -{ - __raw_writel(value, - msm_rpm_data.reg_base_addrs[page] + reg * 4); -} - -static inline void msm_rpm_read_contiguous( - unsigned int page, unsigned int reg, uint32_t *values, int count) -{ - int i; - - for (i = 0; i < count; i++) - values[i] = msm_rpm_read(page, reg + i); -} - -static inline void msm_rpm_write_contiguous( - unsigned int page, unsigned int reg, uint32_t *values, int count) -{ - int i; - - for (i = 0; i < count; i++) - msm_rpm_write(page, reg + i, values[i]); -} - -static inline void msm_rpm_write_contiguous_zeros( - unsigned int page, unsigned int reg, int count) -{ - int i; - - for (i = 0; i < count; i++) - msm_rpm_write(page, reg + i, 0); -} - -static inline uint32_t msm_rpm_map_id_to_sel(uint32_t id) -{ - return (id >= MSM_RPM_ID_LAST) ? msm_rpm_data.sel_last + 1 : - msm_rpm_data.target_id[id].sel; -} - -/* - * Note: the function does not clear the masks before filling them. - * - * Return value: - * 0: success - * -EINVAL: invalid id in array - */ -static int msm_rpm_fill_sel_masks( - uint32_t *sel_masks, struct msm_rpm_iv_pair *req, int count) -{ - uint32_t sel; - int i; - - for (i = 0; i < count; i++) { - sel = msm_rpm_map_id_to_sel(req[i].id); - - if (sel > msm_rpm_data.sel_last) { - pr_err("%s(): RPM ID %d not defined for target\n", - __func__, req[i].id); - return -EINVAL; - } - - sel_masks[msm_rpm_get_sel_mask_reg(sel)] |= - msm_rpm_get_sel_mask(sel); - } - - return 0; -} - -static inline void msm_rpm_send_req_interrupt(void) -{ - __raw_writel(msm_rpm_data.ipc_rpm_val, - msm_rpm_data.ipc_rpm_reg); -} - -/* - * Note: assumes caller has acquired . - * - * Return value: - * 0: request acknowledgement - * 1: notification - * 2: spurious interrupt - */ -static int msm_rpm_process_ack_interrupt(void) -{ - uint32_t ctx_mask_ack; - uint32_t sel_masks_ack[SEL_MASK_SIZE] = {0}; - - ctx_mask_ack = msm_rpm_read(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_ACK_CTX_0)); - msm_rpm_read_contiguous(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_ACK_SEL_0), - sel_masks_ack, msm_rpm_sel_mask_size); - - if (ctx_mask_ack & msm_rpm_get_ctx_mask(MSM_RPM_CTX_NOTIFICATION)) { - struct msm_rpm_notification *n; - int i; - - list_for_each_entry(n, &msm_rpm_notifications, list) - for (i = 0; i < msm_rpm_sel_mask_size; i++) - if (sel_masks_ack[i] & n->sel_masks[i]) { - up(&n->sem); - break; - } - - msm_rpm_write_contiguous_zeros(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_ACK_SEL_0), - msm_rpm_sel_mask_size); - msm_rpm_write(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_ACK_CTX_0), 0); - /* Ensure the write is complete before return */ - mb(); - - return 1; - } - - if (msm_rpm_request) { - int i; - - *(msm_rpm_request->ctx_mask_ack) = ctx_mask_ack; - memcpy(msm_rpm_request->sel_masks_ack, sel_masks_ack, - sizeof(sel_masks_ack)); - - for (i = 0; i < msm_rpm_request->count; i++) - msm_rpm_request->req[i].value = - msm_rpm_read(MSM_RPM_PAGE_ACK, - target_enum(msm_rpm_request->req[i].id)); - - msm_rpm_write_contiguous_zeros(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_ACK_SEL_0), - msm_rpm_sel_mask_size); - msm_rpm_write(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_ACK_CTX_0), 0); - /* Ensure the write is complete before return */ - mb(); - - if (msm_rpm_request->done) - complete_all(msm_rpm_request->done); - - msm_rpm_request = NULL; - return 0; - } - - return 2; -} - -static void msm_rpm_err_fatal(void) -{ - /* Tell RPM that we're handling the interrupt */ - __raw_writel(0x1, msm_rpm_data.ipc_rpm_reg); - panic("RPM error fataled"); -} - -static irqreturn_t msm_rpm_err_interrupt(int irq, void *dev_id) -{ - msm_rpm_err_fatal(); - return IRQ_HANDLED; -} - -static irqreturn_t msm_rpm_ack_interrupt(int irq, void *dev_id) -{ - unsigned long flags; - int rc; - - if (dev_id != &msm_rpm_ack_interrupt) - return IRQ_NONE; - - spin_lock_irqsave(&msm_rpm_irq_lock, flags); - rc = msm_rpm_process_ack_interrupt(); - spin_unlock_irqrestore(&msm_rpm_irq_lock, flags); - - return IRQ_HANDLED; -} - -/* - * Note: assumes caller has acquired . - */ -static void msm_rpm_busy_wait_for_request_completion( - bool allow_async_completion) -{ - int rc; - - do { - while (!gic_is_irq_pending(msm_rpm_data.irq_ack) && - msm_rpm_request) { - if (allow_async_completion) - spin_unlock(&msm_rpm_irq_lock); - if (gic_is_irq_pending(msm_rpm_data.irq_err)) - msm_rpm_err_fatal(); - gic_clear_irq_pending(msm_rpm_data.irq_err); - udelay(1); - if (allow_async_completion) - spin_lock(&msm_rpm_irq_lock); - } - - if (!msm_rpm_request) - break; - - rc = msm_rpm_process_ack_interrupt(); - gic_clear_irq_pending(msm_rpm_data.irq_ack); - } while (rc); -} - -/* Upon return, the array will contain values from the ack page. - * - * Note: assumes caller has acquired . - * - * Return value: - * 0: success - * -ENOSPC: request rejected - */ -static int msm_rpm_set_exclusive(int ctx, - uint32_t *sel_masks, struct msm_rpm_iv_pair *req, int count) -{ - DECLARE_COMPLETION_ONSTACK(ack); - unsigned long flags; - uint32_t ctx_mask = msm_rpm_get_ctx_mask(ctx); - uint32_t ctx_mask_ack = 0; - uint32_t sel_masks_ack[SEL_MASK_SIZE] = {0}; - int i; - - msm_rpm_request_irq_mode.req = req; - msm_rpm_request_irq_mode.count = count; - msm_rpm_request_irq_mode.ctx_mask_ack = &ctx_mask_ack; - msm_rpm_request_irq_mode.sel_masks_ack = sel_masks_ack; - msm_rpm_request_irq_mode.done = &ack; - - spin_lock_irqsave(&msm_rpm_lock, flags); - spin_lock(&msm_rpm_irq_lock); - - BUG_ON(msm_rpm_request); - msm_rpm_request = &msm_rpm_request_irq_mode; - - for (i = 0; i < count; i++) { - BUG_ON(target_enum(req[i].id) >= MSM_RPM_ID_LAST); - msm_rpm_write(MSM_RPM_PAGE_REQ, - target_enum(req[i].id), req[i].value); - } - - msm_rpm_write_contiguous(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_REQ_SEL_0), - sel_masks, msm_rpm_sel_mask_size); - msm_rpm_write(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_REQ_CTX_0), ctx_mask); - - /* Ensure RPM data is written before sending the interrupt */ - mb(); - msm_rpm_send_req_interrupt(); - - spin_unlock(&msm_rpm_irq_lock); - spin_unlock_irqrestore(&msm_rpm_lock, flags); - - wait_for_completion(&ack); - - BUG_ON((ctx_mask_ack & ~(msm_rpm_get_ctx_mask(MSM_RPM_CTX_REJECTED))) - != ctx_mask); - BUG_ON(memcmp(sel_masks, sel_masks_ack, sizeof(sel_masks_ack))); - - return (ctx_mask_ack & msm_rpm_get_ctx_mask(MSM_RPM_CTX_REJECTED)) - ? -ENOSPC : 0; -} - -/* Upon return, the array will contain values from the ack page. - * - * Note: assumes caller has acquired . - * - * Return value: - * 0: success - * -ENOSPC: request rejected - */ -static int msm_rpm_set_exclusive_noirq(int ctx, - uint32_t *sel_masks, struct msm_rpm_iv_pair *req, int count) -{ - unsigned int irq = msm_rpm_data.irq_ack; - unsigned long flags; - uint32_t ctx_mask = msm_rpm_get_ctx_mask(ctx); - uint32_t ctx_mask_ack = 0; - uint32_t sel_masks_ack[SEL_MASK_SIZE] = {0}; - struct irq_chip *irq_chip, *err_chip; - int i; - - msm_rpm_request_poll_mode.req = req; - msm_rpm_request_poll_mode.count = count; - msm_rpm_request_poll_mode.ctx_mask_ack = &ctx_mask_ack; - msm_rpm_request_poll_mode.sel_masks_ack = sel_masks_ack; - msm_rpm_request_poll_mode.done = NULL; - - spin_lock_irqsave(&msm_rpm_irq_lock, flags); - irq_chip = irq_get_chip(irq); - if (!irq_chip) { - spin_unlock_irqrestore(&msm_rpm_irq_lock, flags); - return -ENOSPC; - } - irq_chip->irq_mask(irq_get_irq_data(irq)); - err_chip = irq_get_chip(msm_rpm_data.irq_err); - if (!err_chip) { - irq_chip->irq_unmask(irq_get_irq_data(irq)); - spin_unlock_irqrestore(&msm_rpm_irq_lock, flags); - return -ENOSPC; - } - err_chip->irq_mask(irq_get_irq_data(msm_rpm_data.irq_err)); - - if (msm_rpm_request) { - msm_rpm_busy_wait_for_request_completion(true); - BUG_ON(msm_rpm_request); - } - - msm_rpm_request = &msm_rpm_request_poll_mode; - - for (i = 0; i < count; i++) { - BUG_ON(target_enum(req[i].id) >= MSM_RPM_ID_LAST); - msm_rpm_write(MSM_RPM_PAGE_REQ, - target_enum(req[i].id), req[i].value); - } - - msm_rpm_write_contiguous(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_REQ_SEL_0), - sel_masks, msm_rpm_sel_mask_size); - msm_rpm_write(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_REQ_CTX_0), ctx_mask); - - /* Ensure RPM data is written before sending the interrupt */ - mb(); - msm_rpm_send_req_interrupt(); - - msm_rpm_busy_wait_for_request_completion(false); - BUG_ON(msm_rpm_request); - - err_chip->irq_unmask(irq_get_irq_data(msm_rpm_data.irq_err)); - irq_chip->irq_unmask(irq_get_irq_data(irq)); - spin_unlock_irqrestore(&msm_rpm_irq_lock, flags); - - BUG_ON((ctx_mask_ack & ~(msm_rpm_get_ctx_mask(MSM_RPM_CTX_REJECTED))) - != ctx_mask); - BUG_ON(memcmp(sel_masks, sel_masks_ack, sizeof(sel_masks_ack))); - - return (ctx_mask_ack & msm_rpm_get_ctx_mask(MSM_RPM_CTX_REJECTED)) - ? -ENOSPC : 0; -} - -/* Upon return, the array will contain values from the ack page. - * - * Return value: - * 0: success - * -EINVAL: invalid or invalid id in array - * -ENOSPC: request rejected - * -ENODEV: RPM driver not initialized - */ -static int msm_rpm_set_common( - int ctx, struct msm_rpm_iv_pair *req, int count, bool noirq) -{ - uint32_t sel_masks[SEL_MASK_SIZE] = {}; - int rc; - - if (ctx >= MSM_RPM_CTX_SET_COUNT) { - rc = -EINVAL; - goto set_common_exit; - } - - rc = msm_rpm_fill_sel_masks(sel_masks, req, count); - if (rc) - goto set_common_exit; - - if (noirq) { - unsigned long flags; - - spin_lock_irqsave(&msm_rpm_lock, flags); - rc = msm_rpm_set_exclusive_noirq(ctx, sel_masks, req, count); - spin_unlock_irqrestore(&msm_rpm_lock, flags); - } else { - mutex_lock(&msm_rpm_mutex); - rc = msm_rpm_set_exclusive(ctx, sel_masks, req, count); - mutex_unlock(&msm_rpm_mutex); - } - -set_common_exit: - return rc; -} - -/* - * Return value: - * 0: success - * -EINVAL: invalid or invalid id in array - * -ENODEV: RPM driver not initialized. - */ -static int msm_rpm_clear_common( - int ctx, struct msm_rpm_iv_pair *req, int count, bool noirq) -{ - uint32_t sel_masks[SEL_MASK_SIZE] = {}; - struct msm_rpm_iv_pair r[SEL_MASK_SIZE]; - int rc; - int i; - - if (ctx >= MSM_RPM_CTX_SET_COUNT) { - rc = -EINVAL; - goto clear_common_exit; - } - - rc = msm_rpm_fill_sel_masks(sel_masks, req, count); - if (rc) - goto clear_common_exit; - - for (i = 0; i < ARRAY_SIZE(r); i++) { - r[i].id = MSM_RPM_ID_INVALIDATE_0 + i; - r[i].value = sel_masks[i]; - } - - memset(sel_masks, 0, sizeof(sel_masks)); - sel_masks[msm_rpm_get_sel_mask_reg(msm_rpm_data.sel_invalidate)] |= - msm_rpm_get_sel_mask(msm_rpm_data.sel_invalidate); - - if (noirq) { - unsigned long flags; - - spin_lock_irqsave(&msm_rpm_lock, flags); - rc = msm_rpm_set_exclusive_noirq(ctx, sel_masks, r, - ARRAY_SIZE(r)); - spin_unlock_irqrestore(&msm_rpm_lock, flags); - BUG_ON(rc); - } else { - mutex_lock(&msm_rpm_mutex); - rc = msm_rpm_set_exclusive(ctx, sel_masks, r, ARRAY_SIZE(r)); - mutex_unlock(&msm_rpm_mutex); - BUG_ON(rc); - } - -clear_common_exit: - return rc; -} - -/* - * Note: assumes caller has acquired . - */ -static void msm_rpm_update_notification(uint32_t ctx, - struct msm_rpm_notif_config *curr_cfg, - struct msm_rpm_notif_config *new_cfg) -{ - unsigned int sel_notif = msm_rpm_data.sel_notification; - - if (memcmp(curr_cfg, new_cfg, sizeof(*new_cfg))) { - uint32_t sel_masks[SEL_MASK_SIZE] = {}; - int rc; - - sel_masks[msm_rpm_get_sel_mask_reg(sel_notif)] - |= msm_rpm_get_sel_mask(sel_notif); - - rc = msm_rpm_set_exclusive(ctx, - sel_masks, new_cfg->iv, ARRAY_SIZE(new_cfg->iv)); - BUG_ON(rc); - - memcpy(curr_cfg, new_cfg, sizeof(*new_cfg)); - } -} - -/* - * Note: assumes caller has acquired . - */ -static void msm_rpm_initialize_notification(void) -{ - struct msm_rpm_notif_config cfg; - unsigned int ctx; - int i; - - for (ctx = MSM_RPM_CTX_SET_0; ctx <= MSM_RPM_CTX_SET_SLEEP; ctx++) { - cfg = msm_rpm_notif_cfgs[ctx]; - - for (i = 0; i < msm_rpm_sel_mask_size; i++) { - configured_iv(&cfg)[i].id = - MSM_RPM_ID_NOTIFICATION_CONFIGURED_0 + i; - configured_iv(&cfg)[i].value = ~0UL; - - registered_iv(&cfg)[i].id = - MSM_RPM_ID_NOTIFICATION_REGISTERED_0 + i; - registered_iv(&cfg)[i].value = 0; - } - - msm_rpm_update_notification(ctx, - &msm_rpm_notif_cfgs[ctx], &cfg); - } -} - -/****************************************************************************** - * Public functions - *****************************************************************************/ - -int msm_rpm_local_request_is_outstanding(void) -{ - unsigned long flags; - int outstanding = 0; - - if (!spin_trylock_irqsave(&msm_rpm_lock, flags)) - goto local_request_is_outstanding_exit; - - if (!spin_trylock(&msm_rpm_irq_lock)) - goto local_request_is_outstanding_unlock; - - outstanding = (msm_rpm_request != NULL); - spin_unlock(&msm_rpm_irq_lock); - -local_request_is_outstanding_unlock: - spin_unlock_irqrestore(&msm_rpm_lock, flags); - -local_request_is_outstanding_exit: - return outstanding; -} - -/* - * Read the specified status registers and return their values. - * - * status: array of id-value pairs. Each specifies a status register, - * i.e, one of MSM_RPM_STATUS_ID_xxxx. Upon return, each will - * contain the value of the status register. - * count: number of id-value pairs in the array - * - * Return value: - * 0: success - * -EBUSY: RPM is updating the status page; values across different registers - * may not be consistent - * -EINVAL: invalid id in array - * -ENODEV: RPM driver not initialized - */ -int msm_rpm_get_status(struct msm_rpm_iv_pair *status, int count) -{ - uint32_t seq_begin; - uint32_t seq_end; - int rc; - int i; - - seq_begin = msm_rpm_read(MSM_RPM_PAGE_STATUS, - target_status(MSM_RPM_STATUS_ID_SEQUENCE)); - - for (i = 0; i < count; i++) { - int target_status_id; - - if (status[i].id >= MSM_RPM_STATUS_ID_LAST) { - pr_err("%s(): Status ID beyond limits\n", __func__); - rc = -EINVAL; - goto get_status_exit; - } - - target_status_id = target_status(status[i].id); - if (target_status_id >= MSM_RPM_STATUS_ID_LAST) { - pr_err("%s(): Status id %d not defined for target\n", - __func__, - target_status_id); - rc = -EINVAL; - goto get_status_exit; - } - - status[i].value = msm_rpm_read(MSM_RPM_PAGE_STATUS, - target_status_id); - } - - seq_end = msm_rpm_read(MSM_RPM_PAGE_STATUS, - target_status(MSM_RPM_STATUS_ID_SEQUENCE)); - - rc = (seq_begin != seq_end || (seq_begin & 0x01)) ? -EBUSY : 0; - -get_status_exit: - return rc; -} -EXPORT_SYMBOL(msm_rpm_get_status); - -/* - * Issue a resource request to RPM to set resource values. - * - * Note: the function may sleep and must be called in a task context. - * - * ctx: the request's context. - * There two contexts that a RPM driver client can use: - * MSM_RPM_CTX_SET_0 and MSM_RPM_CTX_SET_SLEEP. For resource values - * that are intended to take effect when the CPU is active, - * MSM_RPM_CTX_SET_0 should be used. For resource values that are - * intended to take effect when the CPU is not active, - * MSM_RPM_CTX_SET_SLEEP should be used. - * req: array of id-value pairs. Each specifies a RPM resource, - * i.e, one of MSM_RPM_ID_xxxx. Each specifies the requested - * resource value. - * count: number of id-value pairs in the array - * - * Return value: - * 0: success - * -EINVAL: invalid or invalid id in array - * -ENOSPC: request rejected - * -ENODEV: RPM driver not initialized - */ -int msm_rpm_set(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - return msm_rpm_set_common(ctx, req, count, false); -} -EXPORT_SYMBOL(msm_rpm_set); - -/* - * Issue a resource request to RPM to set resource values. - * - * Note: the function is similar to msm_rpm_set() except that it must be - * called with interrupts masked. If possible, use msm_rpm_set() - * instead, to maximize CPU throughput. - */ -int msm_rpm_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - WARN(!irqs_disabled(), "msm_rpm_set_noirq can only be called " - "safely when local irqs are disabled. Consider using " - "msm_rpm_set or msm_rpm_set_nosleep instead."); - return msm_rpm_set_common(ctx, req, count, true); -} -EXPORT_SYMBOL(msm_rpm_set_noirq); - -/* - * Issue a resource request to RPM to clear resource values. Once the - * values are cleared, the resources revert back to their default values - * for this RPM master. - * - * Note: the function may sleep and must be called in a task context. - * - * ctx: the request's context. - * req: array of id-value pairs. Each specifies a RPM resource, - * i.e, one of MSM_RPM_ID_xxxx. 's are ignored. - * count: number of id-value pairs in the array - * - * Return value: - * 0: success - * -EINVAL: invalid or invalid id in array - */ -int msm_rpm_clear(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - return msm_rpm_clear_common(ctx, req, count, false); -} -EXPORT_SYMBOL(msm_rpm_clear); - -/* - * Issue a resource request to RPM to clear resource values. - * - * Note: the function is similar to msm_rpm_clear() except that it must be - * called with interrupts masked. If possible, use msm_rpm_clear() - * instead, to maximize CPU throughput. - */ -int msm_rpm_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - WARN(!irqs_disabled(), "msm_rpm_clear_noirq can only be called " - "safely when local irqs are disabled. Consider using " - "msm_rpm_clear or msm_rpm_clear_nosleep instead."); - return msm_rpm_clear_common(ctx, req, count, true); -} -EXPORT_SYMBOL(msm_rpm_clear_noirq); - -/* - * Register for RPM notification. When the specified resources - * change their status on RPM, RPM sends out notifications and the - * driver will "up" the semaphore in struct msm_rpm_notification. - * - * Note: the function may sleep and must be called in a task context. - * - * Memory for must not be freed until the notification is - * unregistered. Memory for can be freed after this - * function returns. - * - * n: the notifcation object. Caller should initialize only the - * semaphore field. When a notification arrives later, the - * semaphore will be "up"ed. - * req: array of id-value pairs. Each specifies a status register, - * i.e, one of MSM_RPM_STATUS_ID_xxxx. 's are ignored. - * count: number of id-value pairs in the array - * - * Return value: - * 0: success - * -EINVAL: invalid id in array - * -ENODEV: RPM driver not initialized - */ -int msm_rpm_register_notification(struct msm_rpm_notification *n, - struct msm_rpm_iv_pair *req, int count) -{ - unsigned long flags; - unsigned int ctx; - struct msm_rpm_notif_config cfg; - int rc; - int i; - - INIT_LIST_HEAD(&n->list); - rc = msm_rpm_fill_sel_masks(n->sel_masks, req, count); - if (rc) - goto register_notification_exit; - - mutex_lock(&msm_rpm_mutex); - - if (!msm_rpm_init_notif_done) { - msm_rpm_initialize_notification(); - msm_rpm_init_notif_done = true; - } - - spin_lock_irqsave(&msm_rpm_irq_lock, flags); - list_add(&n->list, &msm_rpm_notifications); - spin_unlock_irqrestore(&msm_rpm_irq_lock, flags); - - ctx = MSM_RPM_CTX_SET_0; - cfg = msm_rpm_notif_cfgs[ctx]; - - for (i = 0; i < msm_rpm_sel_mask_size; i++) - registered_iv(&cfg)[i].value |= n->sel_masks[i]; - - msm_rpm_update_notification(ctx, &msm_rpm_notif_cfgs[ctx], &cfg); - mutex_unlock(&msm_rpm_mutex); - -register_notification_exit: - return rc; -} -EXPORT_SYMBOL(msm_rpm_register_notification); - -/* - * Unregister a notification. - * - * Note: the function may sleep and must be called in a task context. - * - * n: the notifcation object that was registered previously. - * - * Return value: - * 0: success - * -ENODEV: RPM driver not initialized - */ -int msm_rpm_unregister_notification(struct msm_rpm_notification *n) -{ - unsigned long flags; - unsigned int ctx; - struct msm_rpm_notif_config cfg; - int rc = 0; - int i; - - mutex_lock(&msm_rpm_mutex); - ctx = MSM_RPM_CTX_SET_0; - cfg = msm_rpm_notif_cfgs[ctx]; - - for (i = 0; i < msm_rpm_sel_mask_size; i++) - registered_iv(&cfg)[i].value = 0; - - spin_lock_irqsave(&msm_rpm_irq_lock, flags); - list_del(&n->list); - list_for_each_entry(n, &msm_rpm_notifications, list) - for (i = 0; i < msm_rpm_sel_mask_size; i++) - registered_iv(&cfg)[i].value |= n->sel_masks[i]; - spin_unlock_irqrestore(&msm_rpm_irq_lock, flags); - - msm_rpm_update_notification(ctx, &msm_rpm_notif_cfgs[ctx], &cfg); - mutex_unlock(&msm_rpm_mutex); - - return rc; -} -EXPORT_SYMBOL(msm_rpm_unregister_notification); - -static uint32_t fw_major, fw_minor, fw_build; - -static ssize_t driver_version_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%u.%u.%u\n", - msm_rpm_data.ver[0], msm_rpm_data.ver[1], msm_rpm_data.ver[2]); -} - -static ssize_t fw_version_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%u.%u.%u\n", - fw_major, fw_minor, fw_build); -} - -static struct kobj_attribute driver_version_attr = __ATTR_RO(driver_version); -static struct kobj_attribute fw_version_attr = __ATTR_RO(fw_version); - -static struct attribute *driver_attributes[] = { - &driver_version_attr.attr, - &fw_version_attr.attr, - NULL -}; - -static struct attribute_group driver_attr_group = { - .attrs = driver_attributes, -}; - -static int msm_rpm_probe(struct platform_device *pdev) -{ - return sysfs_create_group(&pdev->dev.kobj, &driver_attr_group); -} - -static int msm_rpm_remove(struct platform_device *pdev) -{ - sysfs_remove_group(&pdev->dev.kobj, &driver_attr_group); - return 0; -} - -static struct platform_driver msm_rpm_platform_driver = { - .probe = msm_rpm_probe, - .remove = msm_rpm_remove, - .driver = { - .name = "msm_rpm", - .owner = THIS_MODULE, - }, -}; - -static void __init msm_rpm_populate_map(struct msm_rpm_platform_data *data) -{ - int i, j; - struct msm_rpm_map_data *src = NULL; - struct msm_rpm_map_data *dst = NULL; - - for (i = 0; i < MSM_RPM_ID_LAST;) { - src = &data->target_id[i]; - dst = &msm_rpm_data.target_id[i]; - - dst->id = MSM_RPM_ID_LAST; - dst->sel = msm_rpm_data.sel_last + 1; - - /* - * copy the target specific id of the current and also of - * all the #count id's that follow the current. - * [MSM_RPM_ID_PM8921_S1_0] = { MSM_RPM_8960_ID_PM8921_S1_0, - * MSM_RPM_8960_SEL_PM8921_S1, - * 2}, - * [MSM_RPM_ID_PM8921_S1_1] = { 0, 0, 0 }, - * should translate to - * [MSM_RPM_ID_PM8921_S1_0] = { MSM_RPM_8960_ID_PM8921_S1_0, - * MSM_RPM_8960_SEL_PM8921, - * 2 }, - * [MSM_RPM_ID_PM8921_S1_1] = { MSM_RPM_8960_ID_PM8921_S1_0 + 1, - * MSM_RPM_8960_SEL_PM8921, - * 0 }, - */ - for (j = 0; j < src->count; j++) { - dst = &msm_rpm_data.target_id[i + j]; - dst->id = src->id + j; - dst->sel = src->sel; - } - - i += (src->count) ? src->count : 1; - } - - for (i = 0; i < MSM_RPM_STATUS_ID_LAST; i++) { - if (data->target_status[i] & MSM_RPM_STATUS_ID_VALID) - msm_rpm_data.target_status[i] &= - ~MSM_RPM_STATUS_ID_VALID; - else - msm_rpm_data.target_status[i] = MSM_RPM_STATUS_ID_LAST; - } -} - -static irqreturn_t msm_pm_rpm_wakeup_interrupt(int irq, void *dev_id) -{ - if (dev_id != &msm_pm_rpm_wakeup_interrupt) - return IRQ_NONE; - - return IRQ_HANDLED; -} - -int __init msm_rpm_init(struct msm_rpm_platform_data *data) -{ - int rc; - - memcpy(&msm_rpm_data, data, sizeof(struct msm_rpm_platform_data)); - msm_rpm_sel_mask_size = msm_rpm_data.sel_last / 32 + 1; - BUG_ON(SEL_MASK_SIZE < msm_rpm_sel_mask_size); - - fw_major = msm_rpm_read(MSM_RPM_PAGE_STATUS, - target_status(MSM_RPM_STATUS_ID_VERSION_MAJOR)); - fw_minor = msm_rpm_read(MSM_RPM_PAGE_STATUS, - target_status(MSM_RPM_STATUS_ID_VERSION_MINOR)); - fw_build = msm_rpm_read(MSM_RPM_PAGE_STATUS, - target_status(MSM_RPM_STATUS_ID_VERSION_BUILD)); - pr_info("%s: RPM firmware %u.%u.%u\n", __func__, - fw_major, fw_minor, fw_build); - - if (fw_major != msm_rpm_data.ver[0]) { - pr_err("%s: RPM version %u.%u.%u incompatible with " - "this driver version %u.%u.%u\n", __func__, - fw_major, fw_minor, fw_build, - msm_rpm_data.ver[0], - msm_rpm_data.ver[1], - msm_rpm_data.ver[2]); - return -EFAULT; - } - - msm_rpm_write(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_VERSION_MAJOR), msm_rpm_data.ver[0]); - msm_rpm_write(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_VERSION_MINOR), msm_rpm_data.ver[1]); - msm_rpm_write(MSM_RPM_PAGE_CTRL, - target_ctrl(MSM_RPM_CTRL_VERSION_BUILD), msm_rpm_data.ver[2]); - - rc = request_irq(data->irq_ack, msm_rpm_ack_interrupt, - IRQF_TRIGGER_RISING | IRQF_NO_SUSPEND, - "rpm_drv", msm_rpm_ack_interrupt); - if (rc) { - pr_err("%s: failed to request irq %d: %d\n", - __func__, data->irq_ack, rc); - return rc; - } - - rc = irq_set_irq_wake(data->irq_ack, 1); - if (rc) { - pr_err("%s: failed to set wakeup irq %u: %d\n", - __func__, data->irq_ack, rc); - return rc; - } - - rc = request_irq(data->irq_err, msm_rpm_err_interrupt, - IRQF_TRIGGER_RISING, "rpm_err", NULL); - if (rc) { - pr_err("%s: failed to request error interrupt: %d\n", - __func__, rc); - return rc; - } - - rc = request_irq(data->irq_wakeup, - msm_pm_rpm_wakeup_interrupt, IRQF_TRIGGER_RISING, - "pm_drv", msm_pm_rpm_wakeup_interrupt); - if (rc) { - pr_err("%s: failed to request irq %u: %d\n", - __func__, data->irq_wakeup, rc); - return rc; - } - - rc = irq_set_irq_wake(data->irq_wakeup, 1); - if (rc) { - pr_err("%s: failed to set wakeup irq %u: %d\n", - __func__, data->irq_wakeup, rc); - return rc; - } - - msm_rpm_populate_map(data); - - return platform_driver_register(&msm_rpm_platform_driver); -} diff --git a/arch/arm/mach-msm/rpm_rbcpr_stats.c b/arch/arm/mach-msm/rpm_rbcpr_stats.c deleted file mode 100644 index a7967c6af561cd636c3facb5222d876f53a0931a..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpm_rbcpr_stats.c +++ /dev/null @@ -1,415 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "timer.h" -#include "rpm_rbcpr_stats.h" - -#define RBCPR_USER_BUF (2000) -#define STR(a) (#a) -#define GETFIELD(a) ((strnstr(STR(a), "->", 80) + 2)) -#define PRINTFIELD(buf, buf_size, pos, format, ...) \ - ((pos < buf_size) ? snprintf((buf + pos), (buf_size - pos), format,\ - ## __VA_ARGS__) : 0) - -enum { - RBCPR_CORNER_SVS = 0, - RBCPR_CORNER_NOMINAL, - RBCPR_CORNER_TURBO, - RBCPR_CORNERS_COUNT, - RBCPR_CORNER_INVALID = 0x7FFFFFFF, -}; - -struct msm_rpmrbcpr_recmnd { - uint32_t voltage; - uint32_t timestamp; -}; - -struct msm_rpmrbcpr_corners { - int efuse_adjustment; - struct msm_rpmrbcpr_recmnd *rpm_rcmnd; - uint32_t programmed_voltage; - uint32_t isr_counter; - uint32_t min_counter; - uint32_t max_counter; -}; - -struct msm_rpmrbcpr_stats { - uint32_t status_count; - uint32_t num_corners; - uint32_t num_latest_recommends; - struct msm_rpmrbcpr_corners *rbcpr_corners; - uint32_t current_corner; - uint32_t railway_voltage; - uint32_t enable; -}; - -struct msm_rpmrbcpr_stats_internal { - void __iomem *regbase; - uint32_t len; - char buf[RBCPR_USER_BUF]; -}; - -static DEFINE_SPINLOCK(rpm_rbcpr_lock); -static struct msm_rpmrbcpr_design_data rbcpr_design_data; -static struct msm_rpmrbcpr_stats rbcpr_stats; -static struct msm_rpmrbcpr_stats_internal pvtdata; - -static inline unsigned long msm_rpmrbcpr_read_data(void __iomem *regbase, - int offset) -{ - return readl_relaxed(regbase + (offset * 4)); -} - -static int msm_rpmrbcpr_cmp_func(const void *a, const void *b) -{ - struct msm_rpmrbcpr_recmnd *pa = (struct msm_rpmrbcpr_recmnd *)(a); - struct msm_rpmrbcpr_recmnd *pb = (struct msm_rpmrbcpr_recmnd *)(b); - return pa->timestamp - pb->timestamp; -} - -static char *msm_rpmrbcpr_corner_string(uint32_t corner) -{ - switch (corner) { - case RBCPR_CORNER_SVS: - return STR(RBCPR_CORNER_SVS); - break; - case RBCPR_CORNER_NOMINAL: - return STR(RBCPR_CORNER_NOMINAL); - break; - case RBCPR_CORNER_TURBO: - return STR(RBCPR_CORNER_TURBO); - break; - case RBCPR_CORNERS_COUNT: - case RBCPR_CORNER_INVALID: - default: - return STR(RBCPR_CORNER_INVALID); - break; - } -} - -static int msm_rpmrbcpr_print_buf(struct msm_rpmrbcpr_stats *pdata, - struct msm_rpmrbcpr_design_data *pdesdata, - char *buf) -{ - int pos = 0; - struct msm_rpmrbcpr_corners *corners; - struct msm_rpmrbcpr_recmnd *rcmnd; - int i, j; - int current_timestamp = msm_timer_get_sclk_ticks(); - - if (!pdata->enable) { - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - "RBCPR Stats not enabled at RPM"); - return pos; - } - - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - ":RBCPR Platform Data"); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %u)", GETFIELD(pdesdata->upside_steps), - pdesdata->upside_steps); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s:%u)", GETFIELD(pdesdata->downside_steps), - pdesdata->downside_steps); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %d)", GETFIELD(pdesdata->svs_voltage), - pdesdata->svs_voltage); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %d)", GETFIELD(pdesdata->nominal_voltage), - pdesdata->nominal_voltage); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %d)\n", GETFIELD(pdesdata->turbo_voltage), - pdesdata->turbo_voltage); - - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - ":RBCPR Stats"); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %u)", GETFIELD(pdata->status_counter), - pdata->status_count); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %s)", GETFIELD(pdata->current_corner), - msm_rpmrbcpr_corner_string(pdata->current_corner)); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (current_timestamp: 0x%x)", - current_timestamp); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %u)\n", GETFIELD(pdata->railway_voltage), - pdata->railway_voltage); - - for (i = 0; i < pdata->num_corners; i++) { - corners = &pdata->rbcpr_corners[i]; - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - ":\tRBCPR Corner Data"); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (name: %s)", msm_rpmrbcpr_corner_string(i)); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %d)", GETFIELD(corners->efuse_adjustment), - corners->efuse_adjustment); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %u)", GETFIELD(corners->programmed_voltage), - corners->programmed_voltage); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %u)", GETFIELD(corners->isr_counter), - corners->isr_counter); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - "(%s: %u)", GETFIELD(corners->min_counter), - corners->min_counter); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - "(%s:%u)\n", GETFIELD(corners->max_counter), - corners->max_counter); - for (j = 0; j < pdata->num_latest_recommends; j++) { - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - ":\t\tVoltage History[%d]", j); - rcmnd = &corners->rpm_rcmnd[j]; - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: %u)", GETFIELD(rcmnd->voltage), - rcmnd->voltage); - pos += PRINTFIELD(buf, RBCPR_USER_BUF, pos, - " (%s: 0x%x)\n", GETFIELD(rcmnd->timestamp), - rcmnd->timestamp); - } - } - return pos; -} - - -static void msm_rpmrbcpr_copy_data(struct msm_rpmrbcpr_stats_internal *pdata, - struct msm_rpmrbcpr_stats *prbcpr_stats) -{ - struct msm_rpmrbcpr_corners *corners; - struct msm_rpmrbcpr_recmnd *rcmnd; - int i, j; - int offset = (offsetof(struct msm_rpmrbcpr_stats, rbcpr_corners) / 4); - - if (!prbcpr_stats) - return; - - for (i = 0; i < prbcpr_stats->num_corners; i++) { - corners = &prbcpr_stats->rbcpr_corners[i]; - corners->efuse_adjustment = msm_rpmrbcpr_read_data( - pdata->regbase, offset++); - for (j = 0; j < prbcpr_stats->num_latest_recommends; j++) { - rcmnd = &corners->rpm_rcmnd[j]; - rcmnd->voltage = msm_rpmrbcpr_read_data( - pdata->regbase, offset++); - rcmnd->timestamp = msm_rpmrbcpr_read_data( - pdata->regbase, offset++); - } - sort(&corners->rpm_rcmnd[0], - prbcpr_stats->num_latest_recommends, - sizeof(struct msm_rpmrbcpr_recmnd), - msm_rpmrbcpr_cmp_func, NULL); - corners->programmed_voltage = msm_rpmrbcpr_read_data( - pdata->regbase, offset++); - corners->isr_counter = msm_rpmrbcpr_read_data(pdata->regbase, - offset++); - corners->min_counter = msm_rpmrbcpr_read_data(pdata->regbase, - offset++); - corners->max_counter = msm_rpmrbcpr_read_data(pdata->regbase, - offset++); - } - prbcpr_stats->current_corner = msm_rpmrbcpr_read_data(pdata->regbase, - offset++); - prbcpr_stats->railway_voltage = msm_rpmrbcpr_read_data - (pdata->regbase, offset++); - prbcpr_stats->enable = msm_rpmrbcpr_read_data(pdata->regbase, offset++); -} - -static int msm_rpmrbcpr_file_read(struct file *file, char __user *bufu, - size_t count, loff_t *ppos) -{ - struct msm_rpmrbcpr_stats_internal *pdata = file->private_data; - int ret; - int status_counter; - - if (!pdata) { - pr_info("%s pdata is null", __func__); - return -EINVAL; - } - - if (!bufu || count < 0) { - pr_info("%s count %d ", __func__, count); - return -EINVAL; - } - - if (*ppos > pdata->len || !pdata->len) { - /* Read RPM stats */ - status_counter = readl_relaxed(pdata->regbase + - offsetof(struct msm_rpmrbcpr_stats, status_count)); - if (status_counter != rbcpr_stats.status_count) { - spin_lock(&rpm_rbcpr_lock); - msm_rpmrbcpr_copy_data(pdata, &rbcpr_stats); - rbcpr_stats.status_count = status_counter; - spin_unlock(&rpm_rbcpr_lock); - } - pdata->len = msm_rpmrbcpr_print_buf(&rbcpr_stats, - &rbcpr_design_data, pdata->buf); - *ppos = 0; - } - /* copy to user data */ - ret = simple_read_from_buffer(bufu, count, ppos, pdata->buf, - pdata->len); - return ret; -} - -static void msm_rpmrbcpr_free_mem(struct msm_rpmrbcpr_stats_internal *pvtdata, - struct msm_rpmrbcpr_stats *prbcpr_stats) -{ - int i; - if (pvtdata->regbase) - iounmap(pvtdata->regbase); - - - if (prbcpr_stats) { - for (i = 0; i < prbcpr_stats->num_corners; i++) { - kfree(prbcpr_stats->rbcpr_corners[i].rpm_rcmnd); - prbcpr_stats->rbcpr_corners[i].rpm_rcmnd = NULL; - } - - kfree(prbcpr_stats->rbcpr_corners); - prbcpr_stats->rbcpr_corners = NULL; - } -} - -static int msm_rpmrbcpr_allocate_mem(struct msm_rpmrbcpr_platform_data *pdata, - struct resource *res) -{ - int i; - - pvtdata.regbase = ioremap(res->start, (res->end - res->start + 1)); - memcpy(&rbcpr_design_data, &pdata->rbcpr_data, - sizeof(struct msm_rpmrbcpr_design_data)); - - - rbcpr_stats.num_corners = readl_relaxed(pvtdata.regbase + - offsetof(struct msm_rpmrbcpr_stats, num_corners)); - rbcpr_stats.num_latest_recommends = readl_relaxed(pvtdata.regbase + - offsetof(struct msm_rpmrbcpr_stats, - num_latest_recommends)); - - rbcpr_stats.rbcpr_corners = kzalloc( - sizeof(struct msm_rpmrbcpr_corners) - * rbcpr_stats.num_corners, GFP_KERNEL); - - if (!rbcpr_stats.rbcpr_corners) { - msm_rpmrbcpr_free_mem(&pvtdata, &rbcpr_stats); - return -ENOMEM; - } - - for (i = 0; i < rbcpr_stats.num_corners; i++) { - rbcpr_stats.rbcpr_corners[i].rpm_rcmnd = - kzalloc(sizeof(struct msm_rpmrbcpr_corners) - * rbcpr_stats.num_latest_recommends, - GFP_KERNEL); - - if (!rbcpr_stats.rbcpr_corners[i].rpm_rcmnd) { - msm_rpmrbcpr_free_mem(&pvtdata, &rbcpr_stats); - return -ENOMEM; - } - } - return 0; -} - -static int msm_rpmrbcpr_file_open(struct inode *inode, struct file *file) -{ - file->private_data = &pvtdata; - pvtdata.len = 0; - - if (!pvtdata.regbase) - return -EBUSY; - - return 0; -} - -static int msm_rpmrbcpr_file_close(struct inode *inode, struct file *file) -{ - return 0; -} - -static const struct file_operations msm_rpmrbcpr_fops = { - .owner = THIS_MODULE, - .open = msm_rpmrbcpr_file_open, - .read = msm_rpmrbcpr_file_read, - .release = msm_rpmrbcpr_file_close, - .llseek = no_llseek, -}; - -static int msm_rpmrbcpr_probe(struct platform_device *pdev) -{ - struct dentry *dent; - struct msm_rpmrbcpr_platform_data *pdata; - int ret = 0; - - pdata = pdev->dev.platform_data; - if (!pdata) - return -EINVAL; - dent = debugfs_create_file("rpm_rbcpr", S_IRUGO, NULL, - pdev->dev.platform_data, &msm_rpmrbcpr_fops); - - if (!dent) { - pr_err("%s: ERROR debugfs_create_file failed\n", __func__); - return -ENOMEM; - } - platform_set_drvdata(pdev, dent); - ret = msm_rpmrbcpr_allocate_mem(pdata, pdev->resource); - return ret; -} - -static int msm_rpmrbcpr_remove(struct platform_device *pdev) -{ - struct dentry *dent; - - msm_rpmrbcpr_free_mem(&pvtdata, &rbcpr_stats); - dent = platform_get_drvdata(pdev); - debugfs_remove(dent); - platform_set_drvdata(pdev, NULL); - return 0; -} - -static struct platform_driver msm_rpmrbcpr_driver = { - .probe = msm_rpmrbcpr_probe, - .remove = msm_rpmrbcpr_remove, - .driver = { - .name = "msm_rpm_rbcpr", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_rpmrbcpr_init(void) -{ - return platform_driver_register(&msm_rpmrbcpr_driver); -} - -static void __exit msm_rpmrbcpr_exit(void) -{ - platform_driver_unregister(&msm_rpmrbcpr_driver); -} - -module_init(msm_rpmrbcpr_init); -module_exit(msm_rpmrbcpr_exit); diff --git a/arch/arm/mach-msm/rpm_rbcpr_stats.h b/arch/arm/mach-msm/rpm_rbcpr_stats.h deleted file mode 100644 index 2ceb4a00712ba6b7aafdb4bd6f78c1a2c9c1c844..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpm_rbcpr_stats.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2012, 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 __ARCH_ARM_MACH_MSM_RPM_RBCPR_STATS_H -#define __ARCH_ARM_MACH_MSM_RPM_RBCPR_STATS_H - -#include - -struct msm_rpmrbcpr_design_data { - u32 upside_steps; - u32 downside_steps; - int svs_voltage; - int nominal_voltage; - int turbo_voltage; -}; - -struct msm_rpmrbcpr_platform_data { - struct msm_rpmrbcpr_design_data rbcpr_data; -}; -#endif diff --git a/arch/arm/mach-msm/rpm_resources.c b/arch/arm/mach-msm/rpm_resources.c deleted file mode 100644 index e24795abbbbaaf36ac2538d493bf2fb8867e70ef..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/rpm_resources.c +++ /dev/null @@ -1,1240 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rpm_resources.h" -#include "spm.h" -#include "idle.h" - -/****************************************************************************** - * Debug Definitions - *****************************************************************************/ - -enum { - MSM_RPMRS_DEBUG_OUTPUT = BIT(0), - MSM_RPMRS_DEBUG_BUFFER = BIT(1), - MSM_RPMRS_DEBUG_EVENT_TIMER = BIT(2), -}; - -static int msm_rpmrs_debug_mask; -module_param_named( - debug_mask, msm_rpmrs_debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP -); - -static struct msm_rpmrs_level *msm_rpmrs_levels; -static int msm_rpmrs_level_count; - -static bool msm_rpmrs_pxo_beyond_limits(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_aggregate_pxo(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_restore_pxo(void); -static bool msm_rpmrs_l2_cache_beyond_limits(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_aggregate_l2_cache(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_restore_l2_cache(void); -static bool msm_rpmrs_vdd_mem_beyond_limits(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_aggregate_vdd_mem(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_restore_vdd_mem(void); -static bool msm_rpmrs_vdd_dig_beyond_limits(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_aggregate_vdd_dig(struct msm_rpmrs_limits *limits); -static void msm_rpmrs_restore_vdd_dig(void); - -static ssize_t msm_rpmrs_resource_attr_show( - struct kobject *kobj, struct kobj_attribute *attr, char *buf); -static ssize_t msm_rpmrs_resource_attr_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count); - -static int vdd_dig_vlevels[MSM_RPMRS_VDD_DIG_LAST]; -static int vdd_mem_vlevels[MSM_RPMRS_VDD_MEM_LAST]; -static int vdd_mask; - -static DEFINE_PER_CPU(uint32_t , msm_lpm_sleep_time); -static DEFINE_PER_CPU(int , lpm_permitted_level); -static DEFINE_PER_CPU(struct atomic_notifier_head, lpm_notify_head); - -#define MSM_RPMRS_MAX_RS_REGISTER_COUNT 2 - -#define RPMRS_ATTR(_name) \ - __ATTR(_name, S_IRUGO|S_IWUSR, \ - msm_rpmrs_resource_attr_show, msm_rpmrs_resource_attr_store) - -struct msm_rpmrs_resource { - struct msm_rpm_iv_pair rs[MSM_RPMRS_MAX_RS_REGISTER_COUNT]; - uint32_t size; - char *name; - - uint32_t enable_low_power; - - bool (*beyond_limits)(struct msm_rpmrs_limits *limits); - void (*aggregate)(struct msm_rpmrs_limits *limits); - void (*restore)(void); - - struct kobj_attribute ko_attr; -}; - -static struct msm_rpmrs_resource msm_rpmrs_pxo = { - .size = 1, - .name = "pxo", - .beyond_limits = msm_rpmrs_pxo_beyond_limits, - .aggregate = msm_rpmrs_aggregate_pxo, - .restore = msm_rpmrs_restore_pxo, - .ko_attr = RPMRS_ATTR(pxo), -}; - -static struct msm_rpmrs_resource msm_rpmrs_l2_cache = { - .size = 1, - .name = "L2_cache", - .beyond_limits = msm_rpmrs_l2_cache_beyond_limits, - .aggregate = msm_rpmrs_aggregate_l2_cache, - .restore = msm_rpmrs_restore_l2_cache, - .ko_attr = RPMRS_ATTR(L2_cache), -}; - -static struct msm_rpmrs_resource msm_rpmrs_vdd_mem = { - .size = 2, - .name = "vdd_mem", - .beyond_limits = msm_rpmrs_vdd_mem_beyond_limits, - .aggregate = msm_rpmrs_aggregate_vdd_mem, - .restore = msm_rpmrs_restore_vdd_mem, - .ko_attr = RPMRS_ATTR(vdd_mem), -}; - -static struct msm_rpmrs_resource msm_rpmrs_vdd_dig = { - .size = 2, - .name = "vdd_dig", - .beyond_limits = msm_rpmrs_vdd_dig_beyond_limits, - .aggregate = msm_rpmrs_aggregate_vdd_dig, - .restore = msm_rpmrs_restore_vdd_dig, - .ko_attr = RPMRS_ATTR(vdd_dig), -}; - -static struct msm_rpmrs_resource msm_rpmrs_rpm_ctl = { - .size = 1, - .name = "rpm_ctl", - .beyond_limits = NULL, - .aggregate = NULL, - .restore = NULL, - .ko_attr = RPMRS_ATTR(rpm_ctl), -}; - -static struct msm_rpmrs_resource *msm_rpmrs_resources[] = { - &msm_rpmrs_pxo, - &msm_rpmrs_l2_cache, - &msm_rpmrs_vdd_mem, - &msm_rpmrs_vdd_dig, - &msm_rpmrs_rpm_ctl, -}; - -static uint32_t msm_rpmrs_buffer[MSM_RPM_ID_LAST]; -static DECLARE_BITMAP(msm_rpmrs_buffered, MSM_RPM_ID_LAST); -static DECLARE_BITMAP(msm_rpmrs_listed, MSM_RPM_ID_LAST); -static DEFINE_SPINLOCK(msm_rpmrs_lock); - -#define MSM_RPMRS_VDD(v) ((v) & (vdd_mask)) - -/****************************************************************************** - * Attribute Definitions - *****************************************************************************/ -static struct attribute *msm_rpmrs_attributes[] = { - &msm_rpmrs_pxo.ko_attr.attr, - &msm_rpmrs_l2_cache.ko_attr.attr, - &msm_rpmrs_vdd_mem.ko_attr.attr, - &msm_rpmrs_vdd_dig.ko_attr.attr, - NULL, -}; -static struct attribute *msm_rpmrs_mode_attributes[] = { - &msm_rpmrs_rpm_ctl.ko_attr.attr, - NULL, -}; - -static struct attribute_group msm_rpmrs_attribute_group = { - .attrs = msm_rpmrs_attributes, -}; - -static struct attribute_group msm_rpmrs_mode_attribute_group = { - .attrs = msm_rpmrs_mode_attributes, -}; - -#define GET_RS_FROM_ATTR(attr) \ - (container_of(attr, struct msm_rpmrs_resource, ko_attr)) - - -/****************************************************************************** - * Resource Specific Functions - *****************************************************************************/ - -static void msm_rpmrs_aggregate_sclk(uint32_t sclk_count) -{ - msm_rpmrs_buffer[MSM_RPM_ID_TRIGGER_TIMED_TO] = 0; - set_bit(MSM_RPM_ID_TRIGGER_TIMED_TO, msm_rpmrs_buffered); - msm_rpmrs_buffer[MSM_RPM_ID_TRIGGER_TIMED_SCLK_COUNT] = sclk_count; - set_bit(MSM_RPM_ID_TRIGGER_TIMED_SCLK_COUNT, msm_rpmrs_buffered); -} - -static void msm_rpmrs_restore_sclk(void) -{ - clear_bit(MSM_RPM_ID_TRIGGER_TIMED_SCLK_COUNT, msm_rpmrs_buffered); - msm_rpmrs_buffer[MSM_RPM_ID_TRIGGER_TIMED_SCLK_COUNT] = 0; - clear_bit(MSM_RPM_ID_TRIGGER_TIMED_TO, msm_rpmrs_buffered); - msm_rpmrs_buffer[MSM_RPM_ID_TRIGGER_TIMED_TO] = 0; -} - -static bool msm_rpmrs_pxo_beyond_limits(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_pxo; - uint32_t pxo; - - if (rs->enable_low_power && test_bit(rs->rs[0].id, msm_rpmrs_buffered)) - pxo = msm_rpmrs_buffer[rs->rs[0].id]; - else - pxo = MSM_RPMRS_PXO_ON; - - return pxo > limits->pxo; -} - -static void msm_rpmrs_aggregate_pxo(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_pxo; - uint32_t *buf = &msm_rpmrs_buffer[rs->rs[0].id]; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) { - rs->rs[0].value = *buf; - if (limits->pxo > *buf) - *buf = limits->pxo; - if (MSM_RPMRS_DEBUG_OUTPUT & msm_rpmrs_debug_mask) - pr_info("%s: %d (0x%x)\n", __func__, *buf, *buf); - } -} - -static void msm_rpmrs_restore_pxo(void) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_pxo; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) - msm_rpmrs_buffer[rs->rs[0].id] = rs->rs[0].value; -} - -static bool msm_rpmrs_l2_cache_beyond_limits(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_l2_cache; - uint32_t l2_cache; - - if (rs->enable_low_power && test_bit(rs->rs[0].id, msm_rpmrs_buffered)) - l2_cache = msm_rpmrs_buffer[rs->rs[0].id]; - else - l2_cache = MSM_RPMRS_L2_CACHE_ACTIVE; - - return l2_cache > limits->l2_cache; -} - -static void msm_rpmrs_aggregate_l2_cache(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_l2_cache; - uint32_t *buf = &msm_rpmrs_buffer[rs->rs[0].id]; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) { - rs->rs[0].value = *buf; - if (limits->l2_cache > *buf) - *buf = limits->l2_cache; - - if (MSM_RPMRS_DEBUG_OUTPUT & msm_rpmrs_debug_mask) - pr_info("%s: %d (0x%x)\n", __func__, *buf, *buf); - } -} - -static bool msm_spm_l2_cache_beyond_limits(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_l2_cache; - uint32_t l2_cache = rs->rs[0].value; - - if (!rs->enable_low_power) - l2_cache = MSM_RPMRS_L2_CACHE_ACTIVE; - - return l2_cache > limits->l2_cache; -} - -static void msm_rpmrs_restore_l2_cache(void) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_l2_cache; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) - msm_rpmrs_buffer[rs->rs[0].id] = rs->rs[0].value; -} - -static bool msm_rpmrs_vdd_mem_beyond_limits(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_vdd_mem; - uint32_t vdd_mem; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) { - uint32_t buffered_value = msm_rpmrs_buffer[rs->rs[0].id]; - - if (rs->enable_low_power == 0) - vdd_mem = vdd_mem_vlevels[MSM_RPMRS_VDD_MEM_ACTIVE]; - else if (rs->enable_low_power == 1) - vdd_mem = vdd_mem_vlevels[MSM_RPMRS_VDD_MEM_RET_HIGH]; - else - vdd_mem = vdd_mem_vlevels[MSM_RPMRS_VDD_MEM_RET_LOW]; - - if (MSM_RPMRS_VDD(buffered_value) > MSM_RPMRS_VDD(vdd_mem)) - vdd_mem = MSM_RPMRS_VDD(buffered_value); - } else { - vdd_mem = vdd_mem_vlevels[MSM_RPMRS_VDD_MEM_ACTIVE]; - } - - return vdd_mem > vdd_mem_vlevels[limits->vdd_mem_upper_bound]; -} - -static void msm_rpmrs_aggregate_vdd_mem(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_vdd_mem; - uint32_t *buf = &msm_rpmrs_buffer[rs->rs[0].id]; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) { - rs->rs[0].value = *buf; - if (vdd_mem_vlevels[limits->vdd_mem] > MSM_RPMRS_VDD(*buf)) { - *buf &= ~vdd_mask; - *buf |= vdd_mem_vlevels[limits->vdd_mem]; - } - - if (MSM_RPMRS_DEBUG_OUTPUT & msm_rpmrs_debug_mask) - pr_info("%s: vdd %d (0x%x)\n", __func__, - MSM_RPMRS_VDD(*buf), MSM_RPMRS_VDD(*buf)); - } -} - -static void msm_rpmrs_restore_vdd_mem(void) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_vdd_mem; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) - msm_rpmrs_buffer[rs->rs[0].id] = rs->rs[0].value; -} - -static bool msm_rpmrs_vdd_dig_beyond_limits(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_vdd_dig; - uint32_t vdd_dig; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) { - uint32_t buffered_value = msm_rpmrs_buffer[rs->rs[0].id]; - - if (rs->enable_low_power == 0) - vdd_dig = vdd_dig_vlevels[MSM_RPMRS_VDD_DIG_ACTIVE]; - else if (rs->enable_low_power == 1) - vdd_dig = vdd_dig_vlevels[MSM_RPMRS_VDD_DIG_RET_HIGH]; - else - vdd_dig = vdd_dig_vlevels[MSM_RPMRS_VDD_DIG_RET_LOW]; - - if (MSM_RPMRS_VDD(buffered_value) > MSM_RPMRS_VDD(vdd_dig)) - vdd_dig = MSM_RPMRS_VDD(buffered_value); - } else { - vdd_dig = vdd_dig_vlevels[MSM_RPMRS_VDD_DIG_ACTIVE]; - } - - return vdd_dig > vdd_dig_vlevels[limits->vdd_dig_upper_bound]; -} - -static void msm_rpmrs_aggregate_vdd_dig(struct msm_rpmrs_limits *limits) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_vdd_dig; - uint32_t *buf = &msm_rpmrs_buffer[rs->rs[0].id]; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) { - rs->rs[0].value = *buf; - if (vdd_dig_vlevels[limits->vdd_dig] > MSM_RPMRS_VDD(*buf)) { - *buf &= ~vdd_mask; - *buf |= vdd_dig_vlevels[limits->vdd_dig]; - } - - - if (MSM_RPMRS_DEBUG_OUTPUT & msm_rpmrs_debug_mask) - pr_info("%s: vdd %d (0x%x)\n", __func__, - MSM_RPMRS_VDD(*buf), MSM_RPMRS_VDD(*buf)); - } -} - -static void msm_rpmrs_restore_vdd_dig(void) -{ - struct msm_rpmrs_resource *rs = &msm_rpmrs_vdd_dig; - - if (test_bit(rs->rs[0].id, msm_rpmrs_buffered)) - msm_rpmrs_buffer[rs->rs[0].id] = rs->rs[0].value; -} - -/****************************************************************************** - * Buffering Functions - *****************************************************************************/ - -static bool msm_rpmrs_irqs_detectable(struct msm_rpmrs_limits *limits, - bool irqs_detect, bool gpio_detect) -{ - - if (vdd_dig_vlevels[limits->vdd_dig_upper_bound] <= - vdd_dig_vlevels[MSM_RPMRS_VDD_DIG_RET_HIGH]) - return irqs_detect; - - if (limits->pxo == MSM_RPMRS_PXO_OFF) - return gpio_detect; - - return true; -} - -static bool msm_rpmrs_use_mpm(struct msm_rpmrs_limits *limits) -{ - return (limits->pxo == MSM_RPMRS_PXO_OFF) || - (vdd_dig_vlevels[limits->vdd_dig] <= - vdd_dig_vlevels[MSM_RPMRS_VDD_DIG_RET_HIGH]); -} - -static void msm_rpmrs_update_levels(void) -{ - int i, k; - - for (i = 0; i < msm_rpmrs_level_count; i++) { - struct msm_rpmrs_level *level = &msm_rpmrs_levels[i]; - - if (level->sleep_mode != MSM_PM_SLEEP_MODE_POWER_COLLAPSE) - continue; - - level->available = true; - - for (k = 0; k < ARRAY_SIZE(msm_rpmrs_resources); k++) { - struct msm_rpmrs_resource *rs = msm_rpmrs_resources[k]; - - if (rs->beyond_limits && - rs->beyond_limits(&level->rs_limits)) { - level->available = false; - break; - } - } - - } -} - -/* - * Return value: - * 0: no entries in is on our resource list - * 1: one or more entries in is on our resource list - * -EINVAL: invalid id in array - */ -static int msm_rpmrs_buffer_request(struct msm_rpm_iv_pair *req, int count) -{ - bool listed; - int i; - - for (i = 0; i < count; i++) - if (req[i].id >= MSM_RPM_ID_LAST) - return -EINVAL; - - for (i = 0, listed = false; i < count; i++) { - msm_rpmrs_buffer[req[i].id] = req[i].value; - set_bit(req[i].id, msm_rpmrs_buffered); - - if (MSM_RPMRS_DEBUG_BUFFER & msm_rpmrs_debug_mask) - pr_info("%s: reg %d: 0x%x\n", - __func__, req[i].id, req[i].value); - - if (listed) - continue; - - if (test_bit(req[i].id, msm_rpmrs_listed)) - listed = true; - } - - return listed ? 1 : 0; -} - -/* - * Return value: - * 0: no entries in is on our resource list - * 1: one or more entries in is on our resource list - * -EINVAL: invalid id in array - */ -static int msm_rpmrs_clear_buffer(struct msm_rpm_iv_pair *req, int count) -{ - bool listed; - int i; - - for (i = 0; i < count; i++) - if (req[i].id >= MSM_RPM_ID_LAST) - return -EINVAL; - - for (i = 0, listed = false; i < count; i++) { - msm_rpmrs_buffer[req[i].id] = 0; - clear_bit(req[i].id, msm_rpmrs_buffered); - - if (MSM_RPMRS_DEBUG_BUFFER & msm_rpmrs_debug_mask) - pr_info("%s: reg %d\n", __func__, req[i].id); - - if (listed) - continue; - - if (test_bit(req[i].id, msm_rpmrs_listed)) - listed = true; - } - - return listed ? 1 : 0; -} - -#ifdef CONFIG_MSM_L2_SPM -static int msm_rpmrs_flush_L2(struct msm_rpmrs_limits *limits, int notify_rpm) -{ - int rc = 0; - int lpm; - - switch (limits->l2_cache) { - case MSM_RPMRS_L2_CACHE_HSFS_OPEN: - lpm = MSM_SPM_L2_MODE_POWER_COLLAPSE; - msm_pm_set_l2_flush_flag(1); - break; - case MSM_RPMRS_L2_CACHE_GDHS: - lpm = MSM_SPM_L2_MODE_GDHS; - break; - case MSM_RPMRS_L2_CACHE_RETENTION: - lpm = MSM_SPM_L2_MODE_RETENTION; - break; - default: - case MSM_RPMRS_L2_CACHE_ACTIVE: - lpm = MSM_SPM_L2_MODE_DISABLED; - break; - } - - rc = msm_spm_l2_set_low_power_mode(lpm, notify_rpm); - if (MSM_RPMRS_DEBUG_BUFFER & msm_rpmrs_debug_mask) - pr_info("%s: Requesting low power mode %d returned %d\n", - __func__, lpm, rc); - - return rc; -} -static void msm_rpmrs_L2_restore(struct msm_rpmrs_limits *limits, - bool notify_rpm, bool collapsed) -{ - msm_spm_l2_set_low_power_mode(MSM_SPM_MODE_DISABLED, notify_rpm); - msm_pm_set_l2_flush_flag(0); -} -#else -static int msm_rpmrs_flush_L2(struct msm_rpmrs_limits *limits, int notify_rpm) -{ - return 0; -} -static void msm_rpmrs_L2_restore(struct msm_rpmrs_limits *limits, - bool notify_rpm, bool collapsed) -{ -} -#endif - -static int msm_rpmrs_flush_buffer( - uint32_t sclk_count, struct msm_rpmrs_limits *limits, int from_idle) -{ - struct msm_rpm_iv_pair *req; - int count; - int rc; - int i; - - msm_rpmrs_aggregate_sclk(sclk_count); - for (i = 0; i < ARRAY_SIZE(msm_rpmrs_resources); i++) { - if (msm_rpmrs_resources[i]->aggregate) - msm_rpmrs_resources[i]->aggregate(limits); - } - - count = bitmap_weight(msm_rpmrs_buffered, MSM_RPM_ID_LAST); - - req = kmalloc(sizeof(*req) * count, GFP_ATOMIC); - if (!req) { - rc = -ENOMEM; - goto flush_buffer_restore; - } - - count = 0; - i = find_first_bit(msm_rpmrs_buffered, MSM_RPM_ID_LAST); - - while (i < MSM_RPM_ID_LAST) { - if (MSM_RPMRS_DEBUG_OUTPUT & msm_rpmrs_debug_mask) - pr_info("%s: reg %d: 0x%x\n", - __func__, i, msm_rpmrs_buffer[i]); - - req[count].id = i; - req[count].value = msm_rpmrs_buffer[i]; - count++; - - i = find_next_bit(msm_rpmrs_buffered, MSM_RPM_ID_LAST, i + 1); - } - - rc = msm_rpm_set_noirq(MSM_RPM_CTX_SET_SLEEP, req, count); - kfree(req); - - if (rc) - goto flush_buffer_restore; - - bitmap_and(msm_rpmrs_buffered, - msm_rpmrs_buffered, msm_rpmrs_listed, MSM_RPM_ID_LAST); - -flush_buffer_restore: - for (i = 0; i < ARRAY_SIZE(msm_rpmrs_resources); i++) { - if (msm_rpmrs_resources[i]->restore) - msm_rpmrs_resources[i]->restore(); - } - msm_rpmrs_restore_sclk(); - - if (rc) - pr_err("%s: failed: %d\n", __func__, rc); - return rc; -} - -static int msm_rpmrs_set_common( - int ctx, struct msm_rpm_iv_pair *req, int count, bool noirq) -{ - if (ctx == MSM_RPM_CTX_SET_SLEEP) { - unsigned long flags; - int rc; - - spin_lock_irqsave(&msm_rpmrs_lock, flags); - rc = msm_rpmrs_buffer_request(req, count); - if (rc > 0) { - msm_rpmrs_update_levels(); - rc = 0; - } - spin_unlock_irqrestore(&msm_rpmrs_lock, flags); - - return rc; - } - - if (noirq) - return msm_rpm_set_noirq(ctx, req, count); - else - return msm_rpm_set(ctx, req, count); -} - -static int msm_rpmrs_clear_common( - int ctx, struct msm_rpm_iv_pair *req, int count, bool noirq) -{ - if (ctx == MSM_RPM_CTX_SET_SLEEP) { - unsigned long flags; - int rc; - - spin_lock_irqsave(&msm_rpmrs_lock, flags); - rc = msm_rpmrs_clear_buffer(req, count); - if (rc > 0) { - msm_rpmrs_update_levels(); - rc = 0; - } - spin_unlock_irqrestore(&msm_rpmrs_lock, flags); - - if (rc < 0) - return rc; - } - - if (noirq) - return msm_rpm_clear_noirq(ctx, req, count); - else - return msm_rpm_clear(ctx, req, count); -} - -/****************************************************************************** - * Attribute Functions - *****************************************************************************/ - -static ssize_t msm_rpmrs_resource_attr_show( - struct kobject *kobj, struct kobj_attribute *attr, char *buf) -{ - struct kernel_param kp; - unsigned long flags; - unsigned int temp; - int rc; - - spin_lock_irqsave(&msm_rpmrs_lock, flags); - /* special case active-set signal for MSM_RPMRS_ID_RPM_CTL */ - if (GET_RS_FROM_ATTR(attr)->rs[0].id == - msm_rpmrs_rpm_ctl.rs[0].id) - temp = GET_RS_FROM_ATTR(attr)->rs[0].value; - else - temp = GET_RS_FROM_ATTR(attr)->enable_low_power; - spin_unlock_irqrestore(&msm_rpmrs_lock, flags); - - kp.arg = &temp; - rc = param_get_uint(buf, &kp); - - if (rc > 0) { - strlcat(buf, "\n", PAGE_SIZE); - rc++; - } - - return rc; -} - -static ssize_t msm_rpmrs_resource_attr_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) -{ - struct kernel_param kp; - unsigned long flags; - unsigned int temp; - int rc; - - kp.arg = &temp; - rc = param_set_uint(buf, &kp); - if (rc) - return rc; - - spin_lock_irqsave(&msm_rpmrs_lock, flags); - GET_RS_FROM_ATTR(attr)->enable_low_power = temp; - - /* special case active-set signal for MSM_RPMRS_ID_RPM_CTL */ - if (GET_RS_FROM_ATTR(attr)->rs[0].id == - msm_rpmrs_rpm_ctl.rs[0].id) { - struct msm_rpm_iv_pair req; - req.id = msm_rpmrs_rpm_ctl.rs[0].id; - req.value = GET_RS_FROM_ATTR(attr)->enable_low_power; - GET_RS_FROM_ATTR(attr)->rs[0].value = req.value; - - rc = msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &req, 1); - if (rc) { - pr_err("%s: failed to request RPM_CTL to %d: %d\n", - __func__, req.value, rc); - } - } - - msm_rpmrs_update_levels(); - spin_unlock_irqrestore(&msm_rpmrs_lock, flags); - - return count; -} - -static int __init msm_rpmrs_resource_sysfs_add(void) -{ - struct kobject *module_kobj = NULL; - struct kobject *low_power_kobj = NULL; - struct kobject *mode_kobj = NULL; - int rc = 0; - - module_kobj = kset_find_obj(module_kset, KBUILD_MODNAME); - if (!module_kobj) { - pr_err("%s: cannot find kobject for module %s\n", - __func__, KBUILD_MODNAME); - rc = -ENOENT; - goto resource_sysfs_add_exit; - } - - low_power_kobj = kobject_create_and_add( - "enable_low_power", module_kobj); - if (!low_power_kobj) { - pr_err("%s: cannot create kobject\n", __func__); - rc = -ENOMEM; - goto resource_sysfs_add_exit; - } - - mode_kobj = kobject_create_and_add( - "mode", module_kobj); - if (!mode_kobj) { - pr_err("%s: cannot create kobject\n", __func__); - rc = -ENOMEM; - goto resource_sysfs_add_exit; - } - - rc = sysfs_create_group(low_power_kobj, &msm_rpmrs_attribute_group); - if (rc) { - pr_err("%s: cannot create kobject attribute group\n", __func__); - goto resource_sysfs_add_exit; - } - - rc = sysfs_create_group(mode_kobj, &msm_rpmrs_mode_attribute_group); - if (rc) { - pr_err("%s: cannot create kobject attribute group\n", __func__); - goto resource_sysfs_add_exit; - } - - rc = 0; -resource_sysfs_add_exit: - if (rc) { - if (low_power_kobj) - sysfs_remove_group(low_power_kobj, - &msm_rpmrs_attribute_group); - kobject_del(low_power_kobj); - kobject_del(mode_kobj); - } - - return rc; -} - -/****************************************************************************** - * Public Functions - *****************************************************************************/ - -int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - return msm_rpmrs_set_common(ctx, req, count, false); -} - -int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - WARN(!irqs_disabled(), "msm_rpmrs_set_noirq can only be called " - "safely when local irqs are disabled. Consider using " - "msm_rpmrs_set or msm_rpmrs_set_nosleep instead."); - return msm_rpmrs_set_common(ctx, req, count, true); -} - -/* Allow individual bits of an rpm resource be set, currently used only for - * active context resource viz. RPM_CTL. The API is generic enough to possibly - * extend it to other resources as well in the future. - */ -int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, int count, - int *mask) -{ - unsigned long flags; - int i, j; - int rc = -1; - struct msm_rpmrs_resource *rs; - - if (ctx != MSM_RPM_CTX_SET_0) - return -ENOSYS; - - spin_lock_irqsave(&msm_rpmrs_lock, flags); - for (i = 0; i < ARRAY_SIZE(msm_rpmrs_resources); i++) { - rs = msm_rpmrs_resources[i]; - if (rs->rs[0].id == req[0].id && rs->size == count) { - for (j = 0; j < rs->size; j++) { - rs->rs[j].value &= ~mask[j]; - rs->rs[j].value |= req[j].value & mask[j]; - } - break; - } - } - - if (i != ARRAY_SIZE(msm_rpmrs_resources)) { - rc = msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &rs->rs[0], rs->size); - if (rc) { - for (j = 0; j < rs->size; j++) { - pr_err("%s: failed to request %d to %d: %d\n", - __func__, - rs->rs[j].id, rs->rs[j].value, rc); - } - } - } - spin_unlock_irqrestore(&msm_rpmrs_lock, flags); - - return rc; - -} - -int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - return msm_rpmrs_clear_common(ctx, req, count, false); -} - -int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count) -{ - WARN(!irqs_disabled(), "msm_rpmrs_clear_noirq can only be called " - "safely when local irqs are disabled. Consider using " - "msm_rpmrs_clear or msm_rpmrs_clear_nosleep instead."); - return msm_rpmrs_clear_common(ctx, req, count, true); -} - -void msm_rpmrs_show_resources(void) -{ - struct msm_rpmrs_resource *rs; - unsigned long flags; - int i; - - spin_lock_irqsave(&msm_rpmrs_lock, flags); - for (i = 0; i < ARRAY_SIZE(msm_rpmrs_resources); i++) { - rs = msm_rpmrs_resources[i]; - if (rs->rs[0].id < MSM_RPM_ID_LAST) - pr_info("%s: resource %s: buffered %d, value 0x%x\n", - __func__, rs->name, - test_bit(rs->rs[0].id, msm_rpmrs_buffered), - msm_rpmrs_buffer[rs->rs[0].id]); - else - pr_info("%s: resource %s: value %d\n", - __func__, rs->name, rs->rs[0].value); - } - spin_unlock_irqrestore(&msm_rpmrs_lock, flags); -} - -static bool lpm_level_permitted(int cur_level_count) -{ - if (__get_cpu_var(lpm_permitted_level) == msm_rpmrs_level_count + 1) - return true; - return (__get_cpu_var(lpm_permitted_level) == cur_level_count); -} - -s32 msm_cpuidle_get_deep_idle_latency(void) -{ - int i; - struct msm_rpmrs_level *level = msm_rpmrs_levels, *best = level; - - if (!level) - return 0; - - for (i = 0; i < msm_rpmrs_level_count; i++, level++) { - if (!level->available) - continue; - if (level->sleep_mode != MSM_PM_SLEEP_MODE_POWER_COLLAPSE) - continue; - /* Pick the first power collapse mode by default */ - if (best->sleep_mode != MSM_PM_SLEEP_MODE_POWER_COLLAPSE) - best = level; - /* Find the lowest latency for power collapse */ - if (level->latency_us < best->latency_us) - best = level; - } - return best->latency_us - 1; -} - -static void *msm_rpmrs_lowest_limits(bool from_idle, - enum msm_pm_sleep_mode sleep_mode, - struct msm_pm_time_params *time_param, uint32_t *power) -{ - unsigned int cpu = smp_processor_id(); - struct msm_rpmrs_level *best_level = NULL; - bool irqs_detectable = false; - bool gpio_detectable = false; - int i; - uint32_t pwr; - uint32_t next_wakeup_us = time_param->sleep_us; - bool modify_event_timer; - int best_level_iter = msm_rpmrs_level_count + 1; - - if (sleep_mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE) { - irqs_detectable = msm_mpm_irqs_detectable(from_idle); - gpio_detectable = msm_mpm_gpio_irqs_detectable(from_idle); - } - - for (i = 0; i < msm_rpmrs_level_count; i++) { - struct msm_rpmrs_level *level = &msm_rpmrs_levels[i]; - - modify_event_timer = false; - - if (!level->available) - continue; - - if (sleep_mode != level->sleep_mode) - continue; - - if (time_param->latency_us < level->latency_us) - continue; - - if (time_param->next_event_us && - time_param->next_event_us < level->latency_us) - continue; - - if (time_param->next_event_us) { - if ((time_param->next_event_us < time_param->sleep_us) - || ((time_param->next_event_us - level->latency_us) < - time_param->sleep_us)) { - modify_event_timer = true; - next_wakeup_us = time_param->next_event_us - - level->latency_us; - } - } - - if (next_wakeup_us <= level->time_overhead_us) - continue; - - if (!msm_rpmrs_irqs_detectable(&level->rs_limits, - irqs_detectable, gpio_detectable)) - continue; - - if ((MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE == sleep_mode) - || (MSM_PM_SLEEP_MODE_POWER_COLLAPSE == sleep_mode)) - if (!cpu && msm_rpm_local_request_is_outstanding()) - break; - - if (next_wakeup_us <= 1) { - pwr = level->energy_overhead; - } else if (next_wakeup_us <= level->time_overhead_us) { - pwr = level->energy_overhead / next_wakeup_us; - } else if ((next_wakeup_us >> 10) > level->time_overhead_us) { - pwr = level->steady_state_power; - } else { - pwr = level->steady_state_power; - pwr -= (level->time_overhead_us * - level->steady_state_power)/next_wakeup_us; - pwr += level->energy_overhead / next_wakeup_us; - } - - if (!best_level || - best_level->rs_limits.power[cpu] >= pwr) { - level->rs_limits.latency_us[cpu] = level->latency_us; - level->rs_limits.power[cpu] = pwr; - best_level = level; - best_level_iter = i; - if (power) - *power = pwr; - if (modify_event_timer && best_level->latency_us > 1) - time_param->modified_time_us = - time_param->next_event_us - - best_level->latency_us; - else - time_param->modified_time_us = 0; - } - } - if (best_level && !lpm_level_permitted(best_level_iter)) - best_level = NULL; - else - per_cpu(msm_lpm_sleep_time, cpu) = - time_param->modified_time_us ? - time_param->modified_time_us : time_param->sleep_us; - - return best_level ? &best_level->rs_limits : NULL; -} - -static int msm_rpmrs_enter_sleep(uint32_t sclk_count, void *limits, - bool from_idle, bool notify_rpm) -{ - int rc = 0; - struct msm_lpm_sleep_data sleep_data; - - sleep_data.limits = limits; - sleep_data.kernel_sleep = __get_cpu_var(msm_lpm_sleep_time); - atomic_notifier_call_chain(&__get_cpu_var(lpm_notify_head), - MSM_LPM_STATE_ENTER, &sleep_data); - - if (notify_rpm) { - rc = msm_rpmrs_flush_buffer(sclk_count, limits, from_idle); - if (rc) - return rc; - - if (msm_rpmrs_use_mpm(limits)) - msm_mpm_enter_sleep(sclk_count, from_idle); - } - - rc = msm_rpmrs_flush_L2(limits, notify_rpm); - return rc; -} - -static void msm_rpmrs_exit_sleep(void *limits, bool from_idle, - bool notify_rpm, bool collapsed) -{ - - /* Disable L2 for now, we dont want L2 to do retention by default */ - msm_rpmrs_L2_restore(limits, notify_rpm, collapsed); - - if (msm_rpmrs_use_mpm(limits)) - msm_mpm_exit_sleep(from_idle); - - atomic_notifier_call_chain(&__get_cpu_var(lpm_notify_head), - MSM_LPM_STATE_EXIT, NULL); -} - -static int rpmrs_cpu_callback(struct notifier_block *nfb, - unsigned long action, void *hcpu) -{ - switch (action) { - case CPU_ONLINE_FROZEN: - case CPU_ONLINE: - if (num_online_cpus() > 1) - msm_rpmrs_l2_cache.rs[0].value = - MSM_RPMRS_L2_CACHE_ACTIVE; - break; - case CPU_DEAD_FROZEN: - case CPU_DEAD: - if (num_online_cpus() == 1) - msm_rpmrs_l2_cache.rs[0].value = - MSM_RPMRS_L2_CACHE_HSFS_OPEN; - break; - } - - msm_rpmrs_update_levels(); - return NOTIFY_OK; -} - -static struct lpm_test_platform_data lpm_test_pdata; - -static struct platform_device msm_lpm_test_device = { - .name = "lpm_test", - .id = -1, - .dev = { - .platform_data = &lpm_test_pdata, - }, -}; - -static struct notifier_block __refdata rpmrs_cpu_notifier = { - .notifier_call = rpmrs_cpu_callback, -}; - -int __init msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data) -{ - int i, k; - struct msm_rpmrs_level *levels = data->levels; - unsigned int m_cpu = 0; - - msm_rpmrs_level_count = data->num_levels; - - msm_rpmrs_levels = kzalloc(sizeof(struct msm_rpmrs_level) * - msm_rpmrs_level_count, GFP_KERNEL); - if (!msm_rpmrs_levels) - return -ENOMEM; - - memcpy(msm_rpmrs_levels, levels, - msm_rpmrs_level_count * sizeof(struct msm_rpmrs_level)); - - lpm_test_pdata.use_qtimer = 0; - lpm_test_pdata.msm_lpm_test_levels = msm_rpmrs_levels, - lpm_test_pdata.msm_lpm_test_level_count = msm_rpmrs_level_count; - - for_each_possible_cpu(m_cpu) - per_cpu(lpm_permitted_level, m_cpu) = - msm_rpmrs_level_count + 1; - - platform_device_register(&msm_lpm_test_device); - - memcpy(vdd_dig_vlevels, data->vdd_dig_levels, - (MSM_RPMRS_VDD_DIG_MAX + 1) * sizeof(vdd_dig_vlevels[0])); - - memcpy(vdd_mem_vlevels, data->vdd_mem_levels, - (MSM_RPMRS_VDD_MEM_MAX + 1) * sizeof(vdd_mem_vlevels[0])); - vdd_mask = data->vdd_mask; - - msm_rpmrs_pxo.rs[0].id = data->rpmrs_target_id[MSM_RPMRS_ID_PXO_CLK]; - msm_rpmrs_l2_cache.rs[0].id = - data->rpmrs_target_id[MSM_RPMRS_ID_L2_CACHE_CTL]; - msm_rpmrs_vdd_mem.rs[0].id = - data->rpmrs_target_id[MSM_RPMRS_ID_VDD_MEM_0]; - msm_rpmrs_vdd_mem.rs[1].id = - data->rpmrs_target_id[MSM_RPMRS_ID_VDD_MEM_1]; - msm_rpmrs_vdd_dig.rs[0].id = - data->rpmrs_target_id[MSM_RPMRS_ID_VDD_DIG_0]; - msm_rpmrs_vdd_dig.rs[1].id = - data->rpmrs_target_id[MSM_RPMRS_ID_VDD_DIG_1]; - msm_rpmrs_rpm_ctl.rs[0].id = - data->rpmrs_target_id[MSM_RPMRS_ID_RPM_CTL]; - - /* Initialize listed bitmap for valid resource IDs */ - for (i = 0; i < ARRAY_SIZE(msm_rpmrs_resources); i++) { - for (k = 0; k < msm_rpmrs_resources[i]->size; k++) { - if (msm_rpmrs_resources[i]->rs[k].id >= - MSM_RPM_ID_LAST) - continue; - set_bit(msm_rpmrs_resources[i]->rs[k].id, - msm_rpmrs_listed); - } - } - - return 0; -} - -uint32_t msm_pm_get_pxo(struct msm_rpmrs_limits *limits) -{ - return limits->pxo; -} - -uint32_t msm_pm_get_l2_cache(struct msm_rpmrs_limits *limits) -{ - return limits->l2_cache; -} - -uint32_t msm_pm_get_vdd_mem(struct msm_rpmrs_limits *limits) -{ - return limits->vdd_mem; -} - -uint32_t msm_pm_get_vdd_dig(struct msm_rpmrs_limits *limits) -{ - return limits->vdd_dig; -} - -int msm_lpm_register_notifier(int cpu, int level_iter, - struct notifier_block *nb, bool is_latency_measure) -{ - per_cpu(lpm_permitted_level, cpu) = level_iter; - return atomic_notifier_chain_register(&per_cpu(lpm_notify_head, - cpu), nb); -} - -int msm_lpm_unregister_notifier(int cpu, struct notifier_block *nb) -{ - per_cpu(lpm_permitted_level, cpu) = msm_rpmrs_level_count + 1; - return atomic_notifier_chain_unregister(&per_cpu(lpm_notify_head, cpu), - nb); -} - -static int __init msm_rpmrs_init(void) -{ - struct msm_rpm_iv_pair req; - int rc; - - BUG_ON(!msm_rpmrs_levels); - - if (cpu_is_msm8x60()) { - req.id = msm_rpmrs_l2_cache.rs[0].id; - req.value = 1; - - rc = msm_rpm_set(MSM_RPM_CTX_SET_0, &req, 1); - if (rc) { - pr_err("%s: failed to request L2 cache: %d\n", - __func__, rc); - goto init_exit; - } - - req.id = msm_rpmrs_l2_cache.rs[0].id; - req.value = 0; - - rc = msm_rpmrs_set(MSM_RPM_CTX_SET_SLEEP, &req, 1); - if (rc) { - pr_err("%s: failed to initialize L2 cache for sleep: " - "%d\n", __func__, rc); - goto init_exit; - } - } - - rc = msm_rpmrs_resource_sysfs_add(); - -init_exit: - return rc; -} -device_initcall(msm_rpmrs_init); - -static struct msm_pm_sleep_ops msm_rpmrs_ops = { - .lowest_limits = msm_rpmrs_lowest_limits, - .enter_sleep = msm_rpmrs_enter_sleep, - .exit_sleep = msm_rpmrs_exit_sleep, -}; - -static int __init msm_rpmrs_l2_init(void) -{ - if (soc_class_is_msm8960() || soc_class_is_msm8930() || - soc_class_is_apq8064()) { - - msm_pm_set_l2_flush_flag(0); - - msm_rpmrs_l2_cache.beyond_limits = - msm_spm_l2_cache_beyond_limits; - msm_rpmrs_l2_cache.aggregate = NULL; - msm_rpmrs_l2_cache.restore = NULL; - - register_hotcpu_notifier(&rpmrs_cpu_notifier); - - } else if (cpu_is_msm9615()) { - msm_rpmrs_l2_cache.beyond_limits = NULL; - msm_rpmrs_l2_cache.aggregate = NULL; - msm_rpmrs_l2_cache.restore = NULL; - } - - msm_pm_set_sleep_ops(&msm_rpmrs_ops); - - return 0; -} -early_initcall(msm_rpmrs_l2_init); diff --git a/arch/arm/mach-msm/rpm_resources.h b/arch/arm/mach-msm/rpm_resources.h index 0a180fb5689e85888e2bf0bad9945d43d1722bac..ae9a78e9272d2a9ff6d75e9229b643c35705ff1f 100644 --- a/arch/arm/mach-msm/rpm_resources.h +++ b/arch/arm/mach-msm/rpm_resources.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2010-2013, 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 @@ -192,46 +192,6 @@ int msm_lpm_register_notifier(int cpu, int level_iter, int msm_lpm_unregister_notifier(int cpu, struct notifier_block *nb); -#if defined(CONFIG_MSM_RPM) - -int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count); -int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); -int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, int count, - int *mask); - -static inline int msm_rpmrs_set_nosleep( - int ctx, struct msm_rpm_iv_pair *req, int count) -{ - unsigned long flags; - int rc; - - local_irq_save(flags); - rc = msm_rpmrs_set_noirq(ctx, req, count); - local_irq_restore(flags); - - return rc; -} - -int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count); -int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); - -static inline int msm_rpmrs_clear_nosleep( - int ctx, struct msm_rpm_iv_pair *req, int count) -{ - unsigned long flags; - int rc; - - local_irq_save(flags); - rc = msm_rpmrs_clear_noirq(ctx, req, count); - local_irq_restore(flags); - - return rc; -} - -void msm_rpmrs_show_resources(void); -int msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data); - -#else static inline int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count) @@ -299,6 +259,5 @@ static inline int msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data) return -ENODEV; } -#endif /* CONFIG_MSM_RPM */ #endif /* __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H */ diff --git a/arch/arm/mach-msm/scm-io.c b/arch/arm/mach-msm/scm-io.c deleted file mode 100644 index a21ec36990a75fcaee04df9852f8fd9551903667..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/scm-io.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2011, 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 -#include -#include - -#include -#include -#include - -#define SCM_IO_READ 0x1 -#define SCM_IO_WRITE 0x2 - -#define BETWEEN(p, st, sz) ((p) >= (void __iomem *)(st) && \ - (p) < ((void __iomem *)(st) + (sz))) -#define XLATE(p, pst, vst) ((u32)((p) - (vst)) + (pst)) - -static u32 __secure_readl(u32 addr) -{ - u32 r; - r = scm_call_atomic1(SCM_SVC_IO, SCM_IO_READ, addr); - __iormb(); - return r; -} - -u32 secure_readl(void __iomem *c) -{ - if (BETWEEN(c, MSM_MMSS_CLK_CTL_BASE, MSM_MMSS_CLK_CTL_SIZE)) - return __secure_readl(XLATE(c, MSM_MMSS_CLK_CTL_PHYS, - MSM_MMSS_CLK_CTL_BASE)); - else if (BETWEEN(c, MSM_TCSR_BASE, MSM_TCSR_SIZE)) - return __secure_readl(XLATE(c, MSM_TCSR_PHYS, MSM_TCSR_BASE)); - return readl(c); -} -EXPORT_SYMBOL(secure_readl); - -static void __secure_writel(u32 v, u32 addr) -{ - __iowmb(); - scm_call_atomic2(SCM_SVC_IO, SCM_IO_WRITE, addr, v); -} - -void secure_writel(u32 v, void __iomem *c) -{ - if (BETWEEN(c, MSM_MMSS_CLK_CTL_BASE, MSM_MMSS_CLK_CTL_SIZE)) - __secure_writel(v, XLATE(c, MSM_MMSS_CLK_CTL_PHYS, - MSM_MMSS_CLK_CTL_BASE)); - else if (BETWEEN(c, MSM_TCSR_BASE, MSM_TCSR_SIZE)) - __secure_writel(v, XLATE(c, MSM_TCSR_PHYS, MSM_TCSR_BASE)); - else - writel(v, c); -} -EXPORT_SYMBOL(secure_writel); diff --git a/arch/arm/mach-msm/sirc.h b/arch/arm/mach-msm/sirc.h deleted file mode 100644 index 8f5f83fffcd32ffdc260449bbd988bd3f70e9a5c..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/sirc.h +++ /dev/null @@ -1,36 +0,0 @@ -/* arch/arm/mach-msm/sirc.h - * - * Copyright (C) 2009 Google, Inc. - * Copyright (c) 2011, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _ARCH_ARM_MACH_MSM_SIRC_H -#define _ARCH_ARM_MACH_MSM_SIRC_H - -#if defined(CONFIG_ARCH_MSM_SCORPION) && !defined(CONFIG_MSM_SMP) -void sirc_fiq_select(int irq, bool enable); -#else -static inline void sirc_fiq_select(int irq, bool enable) {} -#endif - -#if defined(CONFIG_ARCH_QSD8X50) || defined(CONFIG_ARCH_FSM9XXX) -void __init msm_init_sirc(void); -void msm_sirc_enter_sleep(void); -void msm_sirc_exit_sleep(void); -#else -static inline void __init msm_init_sirc(void) {} -static inline void msm_sirc_enter_sleep(void) { } -static inline void msm_sirc_exit_sleep(void) { } -#endif - -#endif diff --git a/arch/arm/mach-msm/smd_init_plat.c b/arch/arm/mach-msm/smd_init_plat.c index c58b150a5856cb91c4d39ce9dd230a28890810bc..e5195188de027ac5cc2e102957a90e2550ca0eab 100644 --- a/arch/arm/mach-msm/smd_init_plat.c +++ b/arch/arm/mach-msm/smd_init_plat.c @@ -47,21 +47,16 @@ #endif #if defined(CONFIG_ARCH_QSD8X50) || defined(CONFIG_ARCH_MSM8X60) \ - || defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_FSM9XXX) \ + || defined(CONFIG_ARCH_FSM9XXX) \ || defined(CONFIG_ARCH_MSM9615) || defined(CONFIG_ARCH_APQ8064) #define CONFIG_QDSP6 1 #endif -#if defined(CONFIG_ARCH_MSM8X60) || defined(CONFIG_ARCH_MSM8960) \ +#if defined(CONFIG_ARCH_MSM8X60) \ || defined(CONFIG_ARCH_APQ8064) #define CONFIG_DSPS 1 #endif -#if defined(CONFIG_ARCH_MSM8960) \ - || defined(CONFIG_ARCH_APQ8064) -#define CONFIG_WCNSS 1 -#define CONFIG_DSPS_SMSM 1 -#endif #if defined(CONFIG_ARCH_MSM7X30) #define MSM_CFG_A2M_SMD_INT \ diff --git a/arch/arm/mach-msm/smd_rpcrouter.c b/arch/arm/mach-msm/smd_rpcrouter.c deleted file mode 100644 index 7fa8d52aac783fad721262f9c0c20c8e6b1ac436..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/smd_rpcrouter.c +++ /dev/null @@ -1,2564 +0,0 @@ -/* arch/arm/mach-msm/smd_rpcrouter.c - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2007-2013, The Linux Foundation. All rights reserved. - * Author: San Mehat - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -/* TODO: handle cases where smd_write() will tempfail due to full fifo */ -/* TODO: thread priority? schedule a work to bump it? */ -/* TODO: maybe make server_list_lock a mutex */ -/* TODO: pool fragments to avoid kmalloc/kfree churn */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include "smd_rpcrouter.h" -#include "modem_notifier.h" -#include "smd_rpc_sym.h" - -enum { - SMEM_LOG = 1U << 0, - RTR_DBG = 1U << 1, - R2R_MSG = 1U << 2, - R2R_RAW = 1U << 3, - RPC_MSG = 1U << 4, - NTFY_MSG = 1U << 5, - RAW_PMR = 1U << 6, - RAW_PMW = 1U << 7, - R2R_RAW_HDR = 1U << 8, -}; -static int msm_rpc_connect_timeout_ms; -module_param_named(connect_timeout, msm_rpc_connect_timeout_ms, - int, S_IRUGO | S_IWUSR | S_IWGRP); - -static int smd_rpcrouter_debug_mask; -module_param_named(debug_mask, smd_rpcrouter_debug_mask, - int, S_IRUGO | S_IWUSR | S_IWGRP); - -#define DIAG(x...) printk(KERN_ERR "[RR] ERROR " x) - -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) -#define D(x...) do { \ -if (smd_rpcrouter_debug_mask & RTR_DBG) \ - printk(KERN_ERR x); \ -} while (0) - -#define RR(x...) do { \ -if (smd_rpcrouter_debug_mask & R2R_MSG) \ - printk(KERN_ERR "[RR] "x); \ -} while (0) - -#define RAW(x...) do { \ -if (smd_rpcrouter_debug_mask & R2R_RAW) \ - printk(KERN_ERR "[RAW] "x); \ -} while (0) - -#define RAW_HDR(x...) do { \ -if (smd_rpcrouter_debug_mask & R2R_RAW_HDR) \ - printk(KERN_ERR "[HDR] "x); \ -} while (0) - -#define RAW_PMR(x...) do { \ -if (smd_rpcrouter_debug_mask & RAW_PMR) \ - printk(KERN_ERR "[PMR] "x); \ -} while (0) - -#define RAW_PMR_NOMASK(x...) do { \ - printk(KERN_ERR "[PMR] "x); \ -} while (0) - -#define RAW_PMW(x...) do { \ -if (smd_rpcrouter_debug_mask & RAW_PMW) \ - printk(KERN_ERR "[PMW] "x); \ -} while (0) - -#define RAW_PMW_NOMASK(x...) do { \ - printk(KERN_ERR "[PMW] "x); \ -} while (0) - -#define IO(x...) do { \ -if (smd_rpcrouter_debug_mask & RPC_MSG) \ - printk(KERN_ERR "[RPC] "x); \ -} while (0) - -#define NTFY(x...) do { \ -if (smd_rpcrouter_debug_mask & NTFY_MSG) \ - printk(KERN_ERR "[NOTIFY] "x); \ -} while (0) -#else -#define D(x...) do { } while (0) -#define RR(x...) do { } while (0) -#define RAW(x...) do { } while (0) -#define RAW_HDR(x...) do { } while (0) -#define RAW_PMR(x...) do { } while (0) -#define RAW_PMR_NO_MASK(x...) do { } while (0) -#define RAW_PMW(x...) do { } while (0) -#define RAW_PMW_NO_MASK(x...) do { } while (0) -#define IO(x...) do { } while (0) -#define NTFY(x...) do { } while (0) -#endif - - -static LIST_HEAD(local_endpoints); -static LIST_HEAD(remote_endpoints); - -static LIST_HEAD(server_list); - -static wait_queue_head_t newserver_wait; -static wait_queue_head_t subsystem_restart_wait; - -static DEFINE_SPINLOCK(local_endpoints_lock); -static DEFINE_SPINLOCK(remote_endpoints_lock); -static DEFINE_SPINLOCK(server_list_lock); - -static LIST_HEAD(rpc_board_dev_list); -static DEFINE_SPINLOCK(rpc_board_dev_list_lock); - -static struct workqueue_struct *rpcrouter_workqueue; - -static atomic_t next_xid = ATOMIC_INIT(1); -static atomic_t pm_mid = ATOMIC_INIT(1); - -static void do_read_data(struct work_struct *work); -static void do_create_pdevs(struct work_struct *work); -static void do_create_rpcrouter_pdev(struct work_struct *work); -static int msm_rpcrouter_close(void); - -static DECLARE_WORK(work_create_pdevs, do_create_pdevs); -static DECLARE_WORK(work_create_rpcrouter_pdev, do_create_rpcrouter_pdev); - -#define RR_STATE_IDLE 0 -#define RR_STATE_HEADER 1 -#define RR_STATE_BODY 2 -#define RR_STATE_ERROR 3 - -/* State for remote ep following restart */ -#define RESTART_QUOTA_ABORT 1 - -struct rr_context { - struct rr_packet *pkt; - uint8_t *ptr; - uint32_t state; /* current assembly state */ - uint32_t count; /* bytes needed in this state */ -}; - -struct rr_context the_rr_context; - -struct rpc_board_dev_info { - struct list_head list; - - struct rpc_board_dev *dev; -}; - -static struct platform_device rpcrouter_pdev = { - .name = "oncrpc_router", - .id = -1, -}; - -struct rpcrouter_xprt_info { - struct list_head list; - - struct rpcrouter_xprt *xprt; - - int remote_pid; - uint32_t initialized; - wait_queue_head_t read_wait; - struct wake_lock wakelock; - spinlock_t lock; - uint32_t need_len; - struct work_struct read_data; - struct workqueue_struct *workqueue; - int abort_data_read; - unsigned char r2r_buf[RPCROUTER_MSGSIZE_MAX]; -}; - -static LIST_HEAD(xprt_info_list); -static DEFINE_MUTEX(xprt_info_list_lock); - -DECLARE_COMPLETION(rpc_remote_router_up); -static atomic_t pending_close_count = ATOMIC_INIT(0); - -static int msm_rpc_reboot_call(struct notifier_block *this, - unsigned long code, void *_cmd) -{ - switch (code) { - case SYS_RESTART: - case SYS_HALT: - case SYS_POWER_OFF: - msm_rpcrouter_close(); - break; - } - return NOTIFY_DONE; -} - -static struct notifier_block msm_rpc_reboot_notifier = { - .notifier_call = msm_rpc_reboot_call, - .priority = 100 -}; - -/* - * Search for transport (xprt) that matches the provided PID. - * - * Note: The calling function must ensure that the mutex - * xprt_info_list_lock is locked when this function - * is called. - * - * @remote_pid Remote PID for the transport - * - * @returns Pointer to transport or NULL if not found - */ -static struct rpcrouter_xprt_info *rpcrouter_get_xprt_info(uint32_t remote_pid) -{ - struct rpcrouter_xprt_info *xprt_info; - - list_for_each_entry(xprt_info, &xprt_info_list, list) { - if (xprt_info->remote_pid == remote_pid) - return xprt_info; - } - return NULL; -} - -static int rpcrouter_send_control_msg(struct rpcrouter_xprt_info *xprt_info, - union rr_control_msg *msg) -{ - struct rr_header hdr; - unsigned long flags = 0; - int need; - - if (xprt_info->remote_pid == RPCROUTER_PID_LOCAL) - return 0; - - if (!(msg->cmd == RPCROUTER_CTRL_CMD_HELLO) && - !xprt_info->initialized) { - printk(KERN_ERR "rpcrouter_send_control_msg(): Warning, " - "router not initialized\n"); - return -EINVAL; - } - - hdr.version = RPCROUTER_VERSION; - hdr.type = msg->cmd; - hdr.src_pid = RPCROUTER_PID_LOCAL; - hdr.src_cid = RPCROUTER_ROUTER_ADDRESS; - hdr.confirm_rx = 0; - hdr.size = sizeof(*msg); - hdr.dst_pid = xprt_info->remote_pid; - hdr.dst_cid = RPCROUTER_ROUTER_ADDRESS; - - /* TODO: what if channel is full? */ - - need = sizeof(hdr) + hdr.size; - spin_lock_irqsave(&xprt_info->lock, flags); - while (xprt_info->xprt->write_avail() < need) { - spin_unlock_irqrestore(&xprt_info->lock, flags); - msleep(250); - spin_lock_irqsave(&xprt_info->lock, flags); - } - xprt_info->xprt->write(&hdr, sizeof(hdr), HEADER); - xprt_info->xprt->write(msg, hdr.size, PAYLOAD); - spin_unlock_irqrestore(&xprt_info->lock, flags); - - return 0; -} - -static void modem_reset_cleanup(struct rpcrouter_xprt_info *xprt_info) -{ - struct msm_rpc_endpoint *ept; - struct rr_remote_endpoint *r_ept; - struct rr_packet *pkt, *tmp_pkt; - struct rr_fragment *frag, *next; - struct msm_rpc_reply *reply, *reply_tmp; - unsigned long flags; - - if (!xprt_info) { - pr_err("%s: Invalid xprt_info\n", __func__); - return; - } - spin_lock_irqsave(&local_endpoints_lock, flags); - /* remove all partial packets received */ - list_for_each_entry(ept, &local_endpoints, list) { - RR("%s EPT DST PID %x, remote_pid:%d\n", __func__, - ept->dst_pid, xprt_info->remote_pid); - - if (xprt_info->remote_pid != ept->dst_pid) - continue; - - D("calling teardown cb %p\n", ept->cb_restart_teardown); - if (ept->cb_restart_teardown) - ept->cb_restart_teardown(ept->client_data); - ept->do_setup_notif = 1; - - /* remove replies */ - spin_lock(&ept->reply_q_lock); - list_for_each_entry_safe(reply, reply_tmp, - &ept->reply_pend_q, list) { - list_del(&reply->list); - kfree(reply); - } - list_for_each_entry_safe(reply, reply_tmp, - &ept->reply_avail_q, list) { - list_del(&reply->list); - kfree(reply); - } - ept->reply_cnt = 0; - spin_unlock(&ept->reply_q_lock); - - /* Set restart state for local ep */ - RR("EPT:0x%p, State %d RESTART_PEND_NTFY_SVR " - "PROG:0x%08x VERS:0x%08x\n", - ept, ept->restart_state, - be32_to_cpu(ept->dst_prog), - be32_to_cpu(ept->dst_vers)); - spin_lock(&ept->restart_lock); - ept->restart_state = RESTART_PEND_NTFY_SVR; - - /* remove incomplete packets */ - spin_lock(&ept->incomplete_lock); - list_for_each_entry_safe(pkt, tmp_pkt, - &ept->incomplete, list) { - list_del(&pkt->list); - frag = pkt->first; - while (frag != NULL) { - next = frag->next; - kfree(frag); - frag = next; - } - kfree(pkt); - } - spin_unlock(&ept->incomplete_lock); - - /* remove all completed packets waiting to be read */ - spin_lock(&ept->read_q_lock); - list_for_each_entry_safe(pkt, tmp_pkt, &ept->read_q, - list) { - list_del(&pkt->list); - frag = pkt->first; - while (frag != NULL) { - next = frag->next; - kfree(frag); - frag = next; - } - kfree(pkt); - } - spin_unlock(&ept->read_q_lock); - - spin_unlock(&ept->restart_lock); - wake_up(&ept->wait_q); - } - - spin_unlock_irqrestore(&local_endpoints_lock, flags); - - /* Unblock endpoints waiting for quota ack*/ - spin_lock_irqsave(&remote_endpoints_lock, flags); - list_for_each_entry(r_ept, &remote_endpoints, list) { - spin_lock(&r_ept->quota_lock); - r_ept->quota_restart_state = RESTART_QUOTA_ABORT; - RR("Set STATE_PENDING PID:0x%08x CID:0x%08x \n", r_ept->pid, - r_ept->cid); - spin_unlock(&r_ept->quota_lock); - wake_up(&r_ept->quota_wait); - } - spin_unlock_irqrestore(&remote_endpoints_lock, flags); -} - -static void modem_reset_startup(struct rpcrouter_xprt_info *xprt_info) -{ - struct msm_rpc_endpoint *ept; - unsigned long flags; - - spin_lock_irqsave(&local_endpoints_lock, flags); - - /* notify all endpoints that we are coming back up */ - list_for_each_entry(ept, &local_endpoints, list) { - RR("%s EPT DST PID %x, remote_pid:%d\n", __func__, - ept->dst_pid, xprt_info->remote_pid); - - if (xprt_info->remote_pid != ept->dst_pid) - continue; - - D("calling setup cb %d:%p\n", ept->do_setup_notif, - ept->cb_restart_setup); - if (ept->do_setup_notif && ept->cb_restart_setup) - ept->cb_restart_setup(ept->client_data); - ept->do_setup_notif = 0; - } - - spin_unlock_irqrestore(&local_endpoints_lock, flags); -} - -/* - * Blocks and waits for endpoint if a reset is in progress. - * - * @returns - * ENETRESET Reset is in progress and a notification needed - * ERESTARTSYS Signal occurred - * 0 Reset is not in progress - */ -static int wait_for_restart_and_notify(struct msm_rpc_endpoint *ept) -{ - unsigned long flags; - int ret = 0; - DEFINE_WAIT(__wait); - - for (;;) { - prepare_to_wait(&ept->restart_wait, &__wait, - TASK_INTERRUPTIBLE); - - spin_lock_irqsave(&ept->restart_lock, flags); - if (ept->restart_state == RESTART_NORMAL) { - spin_unlock_irqrestore(&ept->restart_lock, flags); - break; - } else if (ept->restart_state & RESTART_PEND_NTFY) { - ept->restart_state &= ~RESTART_PEND_NTFY; - spin_unlock_irqrestore(&ept->restart_lock, flags); - ret = -ENETRESET; - break; - } - if (signal_pending(current) && - ((!(ept->flags & MSM_RPC_UNINTERRUPTIBLE)))) { - spin_unlock_irqrestore(&ept->restart_lock, flags); - ret = -ERESTARTSYS; - break; - } - spin_unlock_irqrestore(&ept->restart_lock, flags); - schedule(); - } - finish_wait(&ept->restart_wait, &__wait); - return ret; -} - -static struct rr_server *rpcrouter_create_server(uint32_t pid, - uint32_t cid, - uint32_t prog, - uint32_t ver) -{ - struct rr_server *server; - unsigned long flags; - int rc; - - server = kmalloc(sizeof(struct rr_server), GFP_KERNEL); - if (!server) - return ERR_PTR(-ENOMEM); - - memset(server, 0, sizeof(struct rr_server)); - server->pid = pid; - server->cid = cid; - server->prog = prog; - server->vers = ver; - - spin_lock_irqsave(&server_list_lock, flags); - list_add_tail(&server->list, &server_list); - spin_unlock_irqrestore(&server_list_lock, flags); - - rc = msm_rpcrouter_create_server_cdev(server); - if (rc < 0) - goto out_fail; - - return server; -out_fail: - spin_lock_irqsave(&server_list_lock, flags); - list_del(&server->list); - spin_unlock_irqrestore(&server_list_lock, flags); - kfree(server); - return ERR_PTR(rc); -} - -static void rpcrouter_destroy_server(struct rr_server *server) -{ - unsigned long flags; - - spin_lock_irqsave(&server_list_lock, flags); - list_del(&server->list); - spin_unlock_irqrestore(&server_list_lock, flags); - device_destroy(msm_rpcrouter_class, server->device_number); - kfree(server); -} - -int msm_rpc_add_board_dev(struct rpc_board_dev *devices, int num) -{ - unsigned long flags; - struct rpc_board_dev_info *board_info; - int i; - - for (i = 0; i < num; i++) { - board_info = kzalloc(sizeof(struct rpc_board_dev_info), - GFP_KERNEL); - if (!board_info) - return -ENOMEM; - - board_info->dev = &devices[i]; - D("%s: adding program %x\n", __func__, board_info->dev->prog); - spin_lock_irqsave(&rpc_board_dev_list_lock, flags); - list_add_tail(&board_info->list, &rpc_board_dev_list); - spin_unlock_irqrestore(&rpc_board_dev_list_lock, flags); - } - - return 0; -} -EXPORT_SYMBOL(msm_rpc_add_board_dev); - -static void rpcrouter_register_board_dev(struct rr_server *server) -{ - struct rpc_board_dev_info *board_info; - unsigned long flags; - int rc; - - spin_lock_irqsave(&rpc_board_dev_list_lock, flags); - list_for_each_entry(board_info, &rpc_board_dev_list, list) { - if (server->prog == board_info->dev->prog) { - D("%s: registering device %x\n", - __func__, board_info->dev->prog); - list_del(&board_info->list); - spin_unlock_irqrestore(&rpc_board_dev_list_lock, flags); - rc = platform_device_register(&board_info->dev->pdev); - if (rc) - pr_err("%s: board dev register failed %d\n", - __func__, rc); - kfree(board_info); - return; - } - } - spin_unlock_irqrestore(&rpc_board_dev_list_lock, flags); -} - -static struct rr_server *rpcrouter_lookup_server(uint32_t prog, uint32_t ver) -{ - struct rr_server *server; - unsigned long flags; - - spin_lock_irqsave(&server_list_lock, flags); - list_for_each_entry(server, &server_list, list) { - if (server->prog == prog - && server->vers == ver) { - spin_unlock_irqrestore(&server_list_lock, flags); - return server; - } - } - spin_unlock_irqrestore(&server_list_lock, flags); - return NULL; -} - -static struct rr_server *rpcrouter_lookup_server_by_dev(dev_t dev) -{ - struct rr_server *server; - unsigned long flags; - - spin_lock_irqsave(&server_list_lock, flags); - list_for_each_entry(server, &server_list, list) { - if (server->device_number == dev) { - spin_unlock_irqrestore(&server_list_lock, flags); - return server; - } - } - spin_unlock_irqrestore(&server_list_lock, flags); - return NULL; -} - -struct msm_rpc_endpoint *msm_rpcrouter_create_local_endpoint(dev_t dev) -{ - struct msm_rpc_endpoint *ept; - unsigned long flags; - - ept = kmalloc(sizeof(struct msm_rpc_endpoint), GFP_KERNEL); - if (!ept) - return NULL; - memset(ept, 0, sizeof(struct msm_rpc_endpoint)); - ept->cid = (uint32_t) ept; - ept->pid = RPCROUTER_PID_LOCAL; - ept->dev = dev; - - if ((dev != msm_rpcrouter_devno) && (dev != MKDEV(0, 0))) { - struct rr_server *srv; - /* - * This is a userspace client which opened - * a program/ver devicenode. Bind the client - * to that destination - */ - srv = rpcrouter_lookup_server_by_dev(dev); - /* TODO: bug? really? */ - BUG_ON(!srv); - - ept->dst_pid = srv->pid; - ept->dst_cid = srv->cid; - ept->dst_prog = cpu_to_be32(srv->prog); - ept->dst_vers = cpu_to_be32(srv->vers); - } else { - /* mark not connected */ - ept->dst_pid = 0xffffffff; - } - - init_waitqueue_head(&ept->wait_q); - INIT_LIST_HEAD(&ept->read_q); - spin_lock_init(&ept->read_q_lock); - INIT_LIST_HEAD(&ept->reply_avail_q); - INIT_LIST_HEAD(&ept->reply_pend_q); - spin_lock_init(&ept->reply_q_lock); - spin_lock_init(&ept->restart_lock); - init_waitqueue_head(&ept->restart_wait); - ept->restart_state = RESTART_NORMAL; - wake_lock_init(&ept->read_q_wake_lock, WAKE_LOCK_SUSPEND, "rpc_read"); - wake_lock_init(&ept->reply_q_wake_lock, WAKE_LOCK_SUSPEND, "rpc_reply"); - INIT_LIST_HEAD(&ept->incomplete); - spin_lock_init(&ept->incomplete_lock); - - spin_lock_irqsave(&local_endpoints_lock, flags); - list_add_tail(&ept->list, &local_endpoints); - spin_unlock_irqrestore(&local_endpoints_lock, flags); - return ept; -} - -int msm_rpcrouter_destroy_local_endpoint(struct msm_rpc_endpoint *ept) -{ - int rc; - union rr_control_msg msg = { 0 }; - struct msm_rpc_reply *reply, *reply_tmp; - unsigned long flags; - struct rpcrouter_xprt_info *xprt_info; - - /* Endpoint with dst_pid = 0xffffffff corresponds to that of - ** router port. So don't send a REMOVE CLIENT message while - ** destroying it.*/ - spin_lock_irqsave(&local_endpoints_lock, flags); - list_del(&ept->list); - spin_unlock_irqrestore(&local_endpoints_lock, flags); - if (ept->dst_pid != 0xffffffff) { - msg.cmd = RPCROUTER_CTRL_CMD_REMOVE_CLIENT; - msg.cli.pid = ept->pid; - msg.cli.cid = ept->cid; - - RR("x REMOVE_CLIENT id=%d:%08x\n", ept->pid, ept->cid); - mutex_lock(&xprt_info_list_lock); - list_for_each_entry(xprt_info, &xprt_info_list, list) { - rc = rpcrouter_send_control_msg(xprt_info, &msg); - if (rc < 0) { - mutex_unlock(&xprt_info_list_lock); - return rc; - } - } - mutex_unlock(&xprt_info_list_lock); - } - - /* Free replies */ - spin_lock_irqsave(&ept->reply_q_lock, flags); - list_for_each_entry_safe(reply, reply_tmp, &ept->reply_pend_q, list) { - list_del(&reply->list); - kfree(reply); - } - list_for_each_entry_safe(reply, reply_tmp, &ept->reply_avail_q, list) { - list_del(&reply->list); - kfree(reply); - } - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - - wake_lock_destroy(&ept->read_q_wake_lock); - wake_lock_destroy(&ept->reply_q_wake_lock); - kfree(ept); - return 0; -} - -static int rpcrouter_create_remote_endpoint(uint32_t pid, uint32_t cid) -{ - struct rr_remote_endpoint *new_c; - unsigned long flags; - - new_c = kmalloc(sizeof(struct rr_remote_endpoint), GFP_KERNEL); - if (!new_c) - return -ENOMEM; - memset(new_c, 0, sizeof(struct rr_remote_endpoint)); - - new_c->cid = cid; - new_c->pid = pid; - init_waitqueue_head(&new_c->quota_wait); - spin_lock_init(&new_c->quota_lock); - - spin_lock_irqsave(&remote_endpoints_lock, flags); - list_add_tail(&new_c->list, &remote_endpoints); - new_c->quota_restart_state = RESTART_NORMAL; - spin_unlock_irqrestore(&remote_endpoints_lock, flags); - return 0; -} - -static struct msm_rpc_endpoint *rpcrouter_lookup_local_endpoint(uint32_t cid) -{ - struct msm_rpc_endpoint *ept; - - list_for_each_entry(ept, &local_endpoints, list) { - if (ept->cid == cid) - return ept; - } - return NULL; -} - -static struct rr_remote_endpoint *rpcrouter_lookup_remote_endpoint(uint32_t pid, - uint32_t cid) -{ - struct rr_remote_endpoint *ept; - unsigned long flags; - - spin_lock_irqsave(&remote_endpoints_lock, flags); - list_for_each_entry(ept, &remote_endpoints, list) { - if ((ept->pid == pid) && (ept->cid == cid)) { - spin_unlock_irqrestore(&remote_endpoints_lock, flags); - return ept; - } - } - spin_unlock_irqrestore(&remote_endpoints_lock, flags); - return NULL; -} - -static void handle_server_restart(struct rr_server *server, - uint32_t pid, uint32_t cid, - uint32_t prog, uint32_t vers) -{ - struct rr_remote_endpoint *r_ept; - struct msm_rpc_endpoint *ept; - unsigned long flags; - r_ept = rpcrouter_lookup_remote_endpoint(pid, cid); - if (r_ept && (r_ept->quota_restart_state != - RESTART_NORMAL)) { - spin_lock_irqsave(&r_ept->quota_lock, flags); - r_ept->tx_quota_cntr = 0; - r_ept->quota_restart_state = - RESTART_NORMAL; - spin_unlock_irqrestore(&r_ept->quota_lock, flags); - D(KERN_INFO "rpcrouter: Remote EPT Reset %0x\n", - (unsigned int)r_ept); - wake_up(&r_ept->quota_wait); - } - spin_lock_irqsave(&local_endpoints_lock, flags); - list_for_each_entry(ept, &local_endpoints, list) { - if ((be32_to_cpu(ept->dst_prog) == prog) && - (be32_to_cpu(ept->dst_vers) == vers) && - (ept->restart_state & RESTART_PEND_SVR)) { - spin_lock(&ept->restart_lock); - ept->restart_state &= ~RESTART_PEND_SVR; - spin_unlock(&ept->restart_lock); - D("rpcrouter: Local EPT Reset %08x:%08x \n", - prog, vers); - wake_up(&ept->restart_wait); - wake_up(&ept->wait_q); - } - } - spin_unlock_irqrestore(&local_endpoints_lock, flags); -} - -static int process_control_msg(struct rpcrouter_xprt_info *xprt_info, - union rr_control_msg *msg, int len) -{ - union rr_control_msg ctl = { 0 }; - struct rr_server *server; - struct rr_remote_endpoint *r_ept; - int rc = 0; - unsigned long flags; - static int first = 1; - - if (len != sizeof(*msg)) { - RR(KERN_ERR "rpcrouter: r2r msg size %d != %d\n", - len, sizeof(*msg)); - return -EINVAL; - } - - switch (msg->cmd) { - case RPCROUTER_CTRL_CMD_HELLO: - RR("o HELLO PID %d\n", xprt_info->remote_pid); - memset(&ctl, 0, sizeof(ctl)); - ctl.cmd = RPCROUTER_CTRL_CMD_HELLO; - rpcrouter_send_control_msg(xprt_info, &ctl); - - xprt_info->initialized = 1; - - /* Send list of servers one at a time */ - ctl.cmd = RPCROUTER_CTRL_CMD_NEW_SERVER; - - /* TODO: long time to hold a spinlock... */ - spin_lock_irqsave(&server_list_lock, flags); - list_for_each_entry(server, &server_list, list) { - if (server->pid != RPCROUTER_PID_LOCAL) - continue; - ctl.srv.pid = server->pid; - ctl.srv.cid = server->cid; - ctl.srv.prog = server->prog; - ctl.srv.vers = server->vers; - - RR("x NEW_SERVER id=%d:%08x prog=%08x:%08x\n", - server->pid, server->cid, - server->prog, server->vers); - - rpcrouter_send_control_msg(xprt_info, &ctl); - } - spin_unlock_irqrestore(&server_list_lock, flags); - - if (first) { - first = 0; - queue_work(rpcrouter_workqueue, - &work_create_rpcrouter_pdev); - } - break; - - case RPCROUTER_CTRL_CMD_RESUME_TX: - RR("o RESUME_TX id=%d:%08x\n", msg->cli.pid, msg->cli.cid); - - r_ept = rpcrouter_lookup_remote_endpoint(msg->cli.pid, - msg->cli.cid); - if (!r_ept) { - printk(KERN_ERR - "rpcrouter: Unable to resume client\n"); - break; - } - spin_lock_irqsave(&r_ept->quota_lock, flags); - r_ept->tx_quota_cntr = 0; - spin_unlock_irqrestore(&r_ept->quota_lock, flags); - wake_up(&r_ept->quota_wait); - break; - - case RPCROUTER_CTRL_CMD_NEW_SERVER: - if (msg->srv.vers == 0) { - pr_err( - "rpcrouter: Server create rejected, version = 0, " - "program = %08x\n", msg->srv.prog); - break; - } - - RR("o NEW_SERVER id=%d:%08x prog=%08x:%08x\n", - msg->srv.pid, msg->srv.cid, msg->srv.prog, msg->srv.vers); - - server = rpcrouter_lookup_server(msg->srv.prog, msg->srv.vers); - - if (!server) { - server = rpcrouter_create_server( - msg->srv.pid, msg->srv.cid, - msg->srv.prog, msg->srv.vers); - if (!server) - return -ENOMEM; - /* - * XXX: Verify that its okay to add the - * client to our remote client list - * if we get a NEW_SERVER notification - */ - if (!rpcrouter_lookup_remote_endpoint(msg->srv.pid, - msg->srv.cid)) { - rc = rpcrouter_create_remote_endpoint( - msg->srv.pid, msg->srv.cid); - if (rc < 0) - printk(KERN_ERR - "rpcrouter:Client create" - "error (%d)\n", rc); - } - rpcrouter_register_board_dev(server); - schedule_work(&work_create_pdevs); - wake_up(&newserver_wait); - } else { - if ((server->pid == msg->srv.pid) && - (server->cid == msg->srv.cid)) { - handle_server_restart(server, - msg->srv.pid, - msg->srv.cid, - msg->srv.prog, - msg->srv.vers); - } else { - server->pid = msg->srv.pid; - server->cid = msg->srv.cid; - } - } - break; - - case RPCROUTER_CTRL_CMD_REMOVE_SERVER: - RR("o REMOVE_SERVER prog=%08x:%d\n", - msg->srv.prog, msg->srv.vers); - server = rpcrouter_lookup_server(msg->srv.prog, msg->srv.vers); - if (server) - rpcrouter_destroy_server(server); - break; - - case RPCROUTER_CTRL_CMD_REMOVE_CLIENT: - RR("o REMOVE_CLIENT id=%d:%08x\n", msg->cli.pid, msg->cli.cid); - if (msg->cli.pid == RPCROUTER_PID_LOCAL) { - printk(KERN_ERR - "rpcrouter: Denying remote removal of " - "local client\n"); - break; - } - r_ept = rpcrouter_lookup_remote_endpoint(msg->cli.pid, - msg->cli.cid); - if (r_ept) { - spin_lock_irqsave(&remote_endpoints_lock, flags); - list_del(&r_ept->list); - spin_unlock_irqrestore(&remote_endpoints_lock, flags); - kfree(r_ept); - } - - /* Notify local clients of this event */ - printk(KERN_ERR "rpcrouter: LOCAL NOTIFICATION NOT IMP\n"); - rc = -ENOSYS; - - break; - case RPCROUTER_CTRL_CMD_PING: - /* No action needed for ping messages received */ - RR("o PING\n"); - break; - default: - RR("o UNKNOWN(%08x)\n", msg->cmd); - rc = -ENOSYS; - } - - return rc; -} - -static void do_create_rpcrouter_pdev(struct work_struct *work) -{ - D("%s: modem rpc router up\n", __func__); - platform_device_register(&rpcrouter_pdev); - complete_all(&rpc_remote_router_up); -} - -static void do_create_pdevs(struct work_struct *work) -{ - unsigned long flags; - struct rr_server *server; - - /* TODO: race if destroyed while being registered */ - spin_lock_irqsave(&server_list_lock, flags); - list_for_each_entry(server, &server_list, list) { - if (server->pid != RPCROUTER_PID_LOCAL) { - if (server->pdev_name[0] == 0) { - sprintf(server->pdev_name, "rs%.8x", - server->prog); - spin_unlock_irqrestore(&server_list_lock, - flags); - msm_rpcrouter_create_server_pdev(server); - schedule_work(&work_create_pdevs); - return; - } - } - } - spin_unlock_irqrestore(&server_list_lock, flags); -} - -static void *rr_malloc(unsigned sz) -{ - void *ptr = kmalloc(sz, GFP_KERNEL); - if (ptr) - return ptr; - - printk(KERN_ERR "rpcrouter: kmalloc of %d failed, retrying...\n", sz); - do { - ptr = kmalloc(sz, GFP_KERNEL); - } while (!ptr); - - return ptr; -} - -static int rr_read(struct rpcrouter_xprt_info *xprt_info, - void *data, uint32_t len) -{ - int rc; - unsigned long flags; - - while (!xprt_info->abort_data_read) { - spin_lock_irqsave(&xprt_info->lock, flags); - if (xprt_info->xprt->read_avail() >= len) { - rc = xprt_info->xprt->read(data, len); - spin_unlock_irqrestore(&xprt_info->lock, flags); - if (rc == len && !xprt_info->abort_data_read) - return 0; - else - return -EIO; - } - xprt_info->need_len = len; - wake_unlock(&xprt_info->wakelock); - spin_unlock_irqrestore(&xprt_info->lock, flags); - - wait_event(xprt_info->read_wait, - xprt_info->xprt->read_avail() >= len - || xprt_info->abort_data_read); - } - return -EIO; -} - -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) -static char *type_to_str(int i) -{ - switch (i) { - case RPCROUTER_CTRL_CMD_DATA: - return "data "; - case RPCROUTER_CTRL_CMD_HELLO: - return "hello "; - case RPCROUTER_CTRL_CMD_BYE: - return "bye "; - case RPCROUTER_CTRL_CMD_NEW_SERVER: - return "new_srvr"; - case RPCROUTER_CTRL_CMD_REMOVE_SERVER: - return "rmv_srvr"; - case RPCROUTER_CTRL_CMD_REMOVE_CLIENT: - return "rmv_clnt"; - case RPCROUTER_CTRL_CMD_RESUME_TX: - return "resum_tx"; - case RPCROUTER_CTRL_CMD_EXIT: - return "cmd_exit"; - default: - return "invalid"; - } -} -#endif - -static void do_read_data(struct work_struct *work) -{ - struct rr_header hdr; - struct rr_packet *pkt; - struct rr_fragment *frag; - struct msm_rpc_endpoint *ept; -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) - struct rpc_request_hdr *rq; -#endif - uint32_t pm, mid; - unsigned long flags; - - struct rpcrouter_xprt_info *xprt_info = - container_of(work, - struct rpcrouter_xprt_info, - read_data); - - if (rr_read(xprt_info, &hdr, sizeof(hdr))) - goto fail_io; - - RR("- ver=%d type=%d src=%d:%08x crx=%d siz=%d dst=%d:%08x\n", - hdr.version, hdr.type, hdr.src_pid, hdr.src_cid, - hdr.confirm_rx, hdr.size, hdr.dst_pid, hdr.dst_cid); - RAW_HDR("[r rr_h] " - "ver=%i,type=%s,src_pid=%08x,src_cid=%08x," - "confirm_rx=%i,size=%3i,dst_pid=%08x,dst_cid=%08x\n", - hdr.version, type_to_str(hdr.type), hdr.src_pid, hdr.src_cid, - hdr.confirm_rx, hdr.size, hdr.dst_pid, hdr.dst_cid); - - if (hdr.version != RPCROUTER_VERSION) { - DIAG("version %d != %d\n", hdr.version, RPCROUTER_VERSION); - goto fail_data; - } - if (hdr.size > RPCROUTER_MSGSIZE_MAX) { - DIAG("msg size %d > max %d\n", hdr.size, RPCROUTER_MSGSIZE_MAX); - goto fail_data; - } - - if (hdr.dst_cid == RPCROUTER_ROUTER_ADDRESS) { - if (xprt_info->remote_pid == -1) { - xprt_info->remote_pid = hdr.src_pid; - - /* do restart notification */ - modem_reset_startup(xprt_info); - } - - if (rr_read(xprt_info, xprt_info->r2r_buf, hdr.size)) - goto fail_io; - process_control_msg(xprt_info, - (void *) xprt_info->r2r_buf, hdr.size); - goto done; - } - - if (hdr.size < sizeof(pm)) { - DIAG("runt packet (no pacmark)\n"); - goto fail_data; - } - if (rr_read(xprt_info, &pm, sizeof(pm))) - goto fail_io; - - hdr.size -= sizeof(pm); - - frag = rr_malloc(sizeof(*frag)); - frag->next = NULL; - frag->length = hdr.size; - if (rr_read(xprt_info, frag->data, hdr.size)) { - kfree(frag); - goto fail_io; - } - -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) - if ((smd_rpcrouter_debug_mask & RAW_PMR) && - ((pm >> 30 & 0x1) || (pm >> 31 & 0x1))) { - uint32_t xid = 0; - if (pm >> 30 & 0x1) { - rq = (struct rpc_request_hdr *) frag->data; - xid = ntohl(rq->xid); - } - if ((pm >> 31 & 0x1) || (pm >> 30 & 0x1)) - RAW_PMR_NOMASK("xid:0x%03x first=%i,last=%i,mid=%3i," - "len=%3i,dst_cid=%08x\n", - xid, - pm >> 30 & 0x1, - pm >> 31 & 0x1, - pm >> 16 & 0xFF, - pm & 0xFFFF, hdr.dst_cid); - } - - if (smd_rpcrouter_debug_mask & SMEM_LOG) { - rq = (struct rpc_request_hdr *) frag->data; - if (rq->xid == 0) - smem_log_event(SMEM_LOG_PROC_ID_APPS | - RPC_ROUTER_LOG_EVENT_MID_READ, - PACMARK_MID(pm), - hdr.dst_cid, - hdr.src_cid); - else - smem_log_event(SMEM_LOG_PROC_ID_APPS | - RPC_ROUTER_LOG_EVENT_MSG_READ, - ntohl(rq->xid), - hdr.dst_cid, - hdr.src_cid); - } -#endif - - spin_lock_irqsave(&local_endpoints_lock, flags); - ept = rpcrouter_lookup_local_endpoint(hdr.dst_cid); - if (!ept) { - spin_unlock_irqrestore(&local_endpoints_lock, flags); - DIAG("no local ept for cid %08x\n", hdr.dst_cid); - kfree(frag); - goto done; - } - - /* See if there is already a partial packet that matches our mid - * and if so, append this fragment to that packet. - */ - mid = PACMARK_MID(pm); - spin_lock(&ept->incomplete_lock); - list_for_each_entry(pkt, &ept->incomplete, list) { - if (pkt->mid == mid) { - pkt->last->next = frag; - pkt->last = frag; - pkt->length += frag->length; - if (PACMARK_LAST(pm)) { - list_del(&pkt->list); - spin_unlock(&ept->incomplete_lock); - goto packet_complete; - } - spin_unlock(&ept->incomplete_lock); - spin_unlock_irqrestore(&local_endpoints_lock, flags); - goto done; - } - } - spin_unlock(&ept->incomplete_lock); - spin_unlock_irqrestore(&local_endpoints_lock, flags); - /* This mid is new -- create a packet for it, and put it on - * the incomplete list if this fragment is not a last fragment, - * otherwise put it on the read queue. - */ - pkt = rr_malloc(sizeof(struct rr_packet)); - pkt->first = frag; - pkt->last = frag; - memcpy(&pkt->hdr, &hdr, sizeof(hdr)); - pkt->mid = mid; - pkt->length = frag->length; - - spin_lock_irqsave(&local_endpoints_lock, flags); - ept = rpcrouter_lookup_local_endpoint(hdr.dst_cid); - if (!ept) { - spin_unlock_irqrestore(&local_endpoints_lock, flags); - DIAG("no local ept for cid %08x\n", hdr.dst_cid); - kfree(frag); - kfree(pkt); - goto done; - } - if (!PACMARK_LAST(pm)) { - spin_lock(&ept->incomplete_lock); - list_add_tail(&pkt->list, &ept->incomplete); - spin_unlock(&ept->incomplete_lock); - spin_unlock_irqrestore(&local_endpoints_lock, flags); - goto done; - } - -packet_complete: - spin_lock(&ept->read_q_lock); - D("%s: take read lock on ept %p\n", __func__, ept); - wake_lock(&ept->read_q_wake_lock); - list_add_tail(&pkt->list, &ept->read_q); - wake_up(&ept->wait_q); - spin_unlock(&ept->read_q_lock); - spin_unlock_irqrestore(&local_endpoints_lock, flags); -done: - - if (hdr.confirm_rx) { - union rr_control_msg msg = { 0 }; - - msg.cmd = RPCROUTER_CTRL_CMD_RESUME_TX; - msg.cli.pid = hdr.dst_pid; - msg.cli.cid = hdr.dst_cid; - - RR("x RESUME_TX id=%d:%08x\n", msg.cli.pid, msg.cli.cid); - rpcrouter_send_control_msg(xprt_info, &msg); - -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) - if (smd_rpcrouter_debug_mask & SMEM_LOG) - smem_log_event(SMEM_LOG_PROC_ID_APPS | - RPC_ROUTER_LOG_EVENT_MSG_CFM_SNT, - RPCROUTER_PID_LOCAL, - hdr.dst_cid, - hdr.src_cid); -#endif - - } - - /* don't requeue if we should be shutting down */ - if (!xprt_info->abort_data_read) { - queue_work(xprt_info->workqueue, &xprt_info->read_data); - return; - } - - D("rpc_router terminating for '%s'\n", - xprt_info->xprt->name); - -fail_io: -fail_data: - D(KERN_ERR "rpc_router has died for '%s'\n", - xprt_info->xprt->name); -} - -void msm_rpc_setup_req(struct rpc_request_hdr *hdr, uint32_t prog, - uint32_t vers, uint32_t proc) -{ - memset(hdr, 0, sizeof(struct rpc_request_hdr)); - hdr->xid = cpu_to_be32(atomic_add_return(1, &next_xid)); - hdr->rpc_vers = cpu_to_be32(2); - hdr->prog = cpu_to_be32(prog); - hdr->vers = cpu_to_be32(vers); - hdr->procedure = cpu_to_be32(proc); -} -EXPORT_SYMBOL(msm_rpc_setup_req); - -struct msm_rpc_endpoint *msm_rpc_open(void) -{ - struct msm_rpc_endpoint *ept; - - ept = msm_rpcrouter_create_local_endpoint(MKDEV(0, 0)); - if (ept == NULL) - return ERR_PTR(-ENOMEM); - - return ept; -} - -void msm_rpc_read_wakeup(struct msm_rpc_endpoint *ept) -{ - ept->forced_wakeup = 1; - wake_up(&ept->wait_q); -} - -int msm_rpc_close(struct msm_rpc_endpoint *ept) -{ - if (!ept) - return -EINVAL; - return msm_rpcrouter_destroy_local_endpoint(ept); -} -EXPORT_SYMBOL(msm_rpc_close); - -static int msm_rpc_write_pkt( - struct rr_header *hdr, - struct msm_rpc_endpoint *ept, - struct rr_remote_endpoint *r_ept, - void *buffer, - int count, - int first, - int last, - uint32_t mid - ) -{ -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) - struct rpc_request_hdr *rq = buffer; - uint32_t event_id; -#endif - uint32_t pacmark; - unsigned long flags = 0; - int rc; - struct rpcrouter_xprt_info *xprt_info; - int needed; - - DEFINE_WAIT(__wait); - - /* Create routing header */ - hdr->type = RPCROUTER_CTRL_CMD_DATA; - hdr->version = RPCROUTER_VERSION; - hdr->src_pid = ept->pid; - hdr->src_cid = ept->cid; - hdr->confirm_rx = 0; - hdr->size = count + sizeof(uint32_t); - - rc = wait_for_restart_and_notify(ept); - if (rc) - return rc; - - if (r_ept) { - for (;;) { - prepare_to_wait(&r_ept->quota_wait, &__wait, - TASK_INTERRUPTIBLE); - spin_lock_irqsave(&r_ept->quota_lock, flags); - if ((r_ept->tx_quota_cntr < - RPCROUTER_DEFAULT_RX_QUOTA) || - (r_ept->quota_restart_state != RESTART_NORMAL)) - break; - if (signal_pending(current) && - (!(ept->flags & MSM_RPC_UNINTERRUPTIBLE))) - break; - spin_unlock_irqrestore(&r_ept->quota_lock, flags); - schedule(); - } - finish_wait(&r_ept->quota_wait, &__wait); - - if (r_ept->quota_restart_state != RESTART_NORMAL) { - spin_lock(&ept->restart_lock); - ept->restart_state &= ~RESTART_PEND_NTFY; - spin_unlock(&ept->restart_lock); - spin_unlock_irqrestore(&r_ept->quota_lock, flags); - return -ENETRESET; - } - - if (signal_pending(current) && - (!(ept->flags & MSM_RPC_UNINTERRUPTIBLE))) { - spin_unlock_irqrestore(&r_ept->quota_lock, flags); - return -ERESTARTSYS; - } - r_ept->tx_quota_cntr++; - if (r_ept->tx_quota_cntr == RPCROUTER_DEFAULT_RX_QUOTA) { - hdr->confirm_rx = 1; - -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) - if (smd_rpcrouter_debug_mask & SMEM_LOG) { - event_id = (rq->xid == 0) ? - RPC_ROUTER_LOG_EVENT_MID_CFM_REQ : - RPC_ROUTER_LOG_EVENT_MSG_CFM_REQ; - - smem_log_event(SMEM_LOG_PROC_ID_APPS | event_id, - hdr->dst_pid, - hdr->dst_cid, - hdr->src_cid); - } -#endif - - } - } - pacmark = PACMARK(count, mid, first, last); - - if (r_ept) - spin_unlock_irqrestore(&r_ept->quota_lock, flags); - - mutex_lock(&xprt_info_list_lock); - xprt_info = rpcrouter_get_xprt_info(hdr->dst_pid); - if (!xprt_info) { - mutex_unlock(&xprt_info_list_lock); - return -ENETRESET; - } - spin_lock_irqsave(&xprt_info->lock, flags); - mutex_unlock(&xprt_info_list_lock); - spin_lock(&ept->restart_lock); - if (ept->restart_state != RESTART_NORMAL) { - ept->restart_state &= ~RESTART_PEND_NTFY; - spin_unlock(&ept->restart_lock); - spin_unlock_irqrestore(&xprt_info->lock, flags); - return -ENETRESET; - } - - needed = sizeof(*hdr) + hdr->size; - while ((ept->restart_state == RESTART_NORMAL) && - (xprt_info->xprt->write_avail() < needed)) { - spin_unlock(&ept->restart_lock); - spin_unlock_irqrestore(&xprt_info->lock, flags); - msleep(250); - - /* refresh xprt pointer to ensure that it hasn't - * been deleted since our last retrieval */ - mutex_lock(&xprt_info_list_lock); - xprt_info = rpcrouter_get_xprt_info(hdr->dst_pid); - if (!xprt_info) { - mutex_unlock(&xprt_info_list_lock); - return -ENETRESET; - } - spin_lock_irqsave(&xprt_info->lock, flags); - mutex_unlock(&xprt_info_list_lock); - spin_lock(&ept->restart_lock); - } - if (ept->restart_state != RESTART_NORMAL) { - ept->restart_state &= ~RESTART_PEND_NTFY; - spin_unlock(&ept->restart_lock); - spin_unlock_irqrestore(&xprt_info->lock, flags); - return -ENETRESET; - } - - /* TODO: deal with full fifo */ - xprt_info->xprt->write(hdr, sizeof(*hdr), HEADER); - RAW_HDR("[w rr_h] " - "ver=%i,type=%s,src_pid=%08x,src_cid=%08x," - "confirm_rx=%i,size=%3i,dst_pid=%08x,dst_cid=%08x\n", - hdr->version, type_to_str(hdr->type), - hdr->src_pid, hdr->src_cid, - hdr->confirm_rx, hdr->size, hdr->dst_pid, hdr->dst_cid); - xprt_info->xprt->write(&pacmark, sizeof(pacmark), PACKMARK); - -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) - if ((smd_rpcrouter_debug_mask & RAW_PMW) && - ((pacmark >> 30 & 0x1) || (pacmark >> 31 & 0x1))) { - uint32_t xid = 0; - if (pacmark >> 30 & 0x1) - xid = ntohl(rq->xid); - if ((pacmark >> 31 & 0x1) || (pacmark >> 30 & 0x1)) - RAW_PMW_NOMASK("xid:0x%03x first=%i,last=%i,mid=%3i," - "len=%3i,src_cid=%x\n", - xid, - pacmark >> 30 & 0x1, - pacmark >> 31 & 0x1, - pacmark >> 16 & 0xFF, - pacmark & 0xFFFF, hdr->src_cid); - } -#endif - - xprt_info->xprt->write(buffer, count, PAYLOAD); - spin_unlock(&ept->restart_lock); - spin_unlock_irqrestore(&xprt_info->lock, flags); - -#if defined(CONFIG_MSM_ONCRPCROUTER_DEBUG) - if (smd_rpcrouter_debug_mask & SMEM_LOG) { - if (rq->xid == 0) - smem_log_event(SMEM_LOG_PROC_ID_APPS | - RPC_ROUTER_LOG_EVENT_MID_WRITTEN, - PACMARK_MID(pacmark), - hdr->dst_cid, - hdr->src_cid); - else - smem_log_event(SMEM_LOG_PROC_ID_APPS | - RPC_ROUTER_LOG_EVENT_MSG_WRITTEN, - ntohl(rq->xid), - hdr->dst_cid, - hdr->src_cid); - } -#endif - - return needed; -} - -static struct msm_rpc_reply *get_pend_reply(struct msm_rpc_endpoint *ept, - uint32_t xid) -{ - unsigned long flags; - struct msm_rpc_reply *reply; - spin_lock_irqsave(&ept->reply_q_lock, flags); - list_for_each_entry(reply, &ept->reply_pend_q, list) { - if (reply->xid == xid) { - list_del(&reply->list); - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - return reply; - } - } - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - return NULL; -} - -void get_requesting_client(struct msm_rpc_endpoint *ept, uint32_t xid, - struct msm_rpc_client_info *clnt_info) -{ - unsigned long flags; - struct msm_rpc_reply *reply; - - if (!clnt_info) - return; - - spin_lock_irqsave(&ept->reply_q_lock, flags); - list_for_each_entry(reply, &ept->reply_pend_q, list) { - if (reply->xid == xid) { - clnt_info->pid = reply->pid; - clnt_info->cid = reply->cid; - clnt_info->prog = reply->prog; - clnt_info->vers = reply->vers; - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - return; - } - } - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - return; -} - -static void set_avail_reply(struct msm_rpc_endpoint *ept, - struct msm_rpc_reply *reply) -{ - unsigned long flags; - spin_lock_irqsave(&ept->reply_q_lock, flags); - list_add_tail(&reply->list, &ept->reply_avail_q); - spin_unlock_irqrestore(&ept->reply_q_lock, flags); -} - -static struct msm_rpc_reply *get_avail_reply(struct msm_rpc_endpoint *ept) -{ - struct msm_rpc_reply *reply; - unsigned long flags; - if (list_empty(&ept->reply_avail_q)) { - if (ept->reply_cnt >= RPCROUTER_PEND_REPLIES_MAX) { - printk(KERN_ERR - "exceeding max replies of %d \n", - RPCROUTER_PEND_REPLIES_MAX); - return 0; - } - reply = kmalloc(sizeof(struct msm_rpc_reply), GFP_KERNEL); - if (!reply) - return 0; - D("Adding reply 0x%08x \n", (unsigned int)reply); - memset(reply, 0, sizeof(struct msm_rpc_reply)); - spin_lock_irqsave(&ept->reply_q_lock, flags); - ept->reply_cnt++; - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - } else { - spin_lock_irqsave(&ept->reply_q_lock, flags); - reply = list_first_entry(&ept->reply_avail_q, - struct msm_rpc_reply, - list); - list_del(&reply->list); - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - } - return reply; -} - -static void set_pend_reply(struct msm_rpc_endpoint *ept, - struct msm_rpc_reply *reply) -{ - unsigned long flags; - spin_lock_irqsave(&ept->reply_q_lock, flags); - D("%s: take reply lock on ept %p\n", __func__, ept); - wake_lock(&ept->reply_q_wake_lock); - list_add_tail(&reply->list, &ept->reply_pend_q); - spin_unlock_irqrestore(&ept->reply_q_lock, flags); -} - -int msm_rpc_write(struct msm_rpc_endpoint *ept, void *buffer, int count) -{ - struct rr_header hdr; - struct rpc_request_hdr *rq = buffer; - struct rr_remote_endpoint *r_ept; - struct msm_rpc_reply *reply = NULL; - int max_tx; - int tx_cnt; - char *tx_buf; - int rc; - int first_pkt = 1; - uint32_t mid; - unsigned long flags; - - /* snoop the RPC packet and enforce permissions */ - - /* has to have at least the xid and type fields */ - if (count < (sizeof(uint32_t) * 2)) { - printk(KERN_ERR "rr_write: rejecting runt packet\n"); - return -EINVAL; - } - - if (rq->type == 0) { - /* RPC CALL */ - if (count < (sizeof(uint32_t) * 6)) { - printk(KERN_ERR - "rr_write: rejecting runt call packet\n"); - return -EINVAL; - } - if (ept->dst_pid == 0xffffffff) { - printk(KERN_ERR "rr_write: not connected\n"); - return -ENOTCONN; - } - if ((ept->dst_prog != rq->prog) || - ((be32_to_cpu(ept->dst_vers) & 0x0fff0000) != - (be32_to_cpu(rq->vers) & 0x0fff0000))) { - printk(KERN_ERR - "rr_write: cannot write to %08x:%08x " - "(bound to %08x:%08x)\n", - be32_to_cpu(rq->prog), be32_to_cpu(rq->vers), - be32_to_cpu(ept->dst_prog), - be32_to_cpu(ept->dst_vers)); - return -EINVAL; - } - hdr.dst_pid = ept->dst_pid; - hdr.dst_cid = ept->dst_cid; - IO("CALL to %08x:%d @ %d:%08x (%d bytes)\n", - be32_to_cpu(rq->prog), be32_to_cpu(rq->vers), - ept->dst_pid, ept->dst_cid, count); - } else { - /* RPC REPLY */ - reply = get_pend_reply(ept, rq->xid); - if (!reply) { - printk(KERN_ERR - "rr_write: rejecting, reply not found \n"); - return -EINVAL; - } - hdr.dst_pid = reply->pid; - hdr.dst_cid = reply->cid; - IO("REPLY to xid=%d @ %d:%08x (%d bytes)\n", - be32_to_cpu(rq->xid), hdr.dst_pid, hdr.dst_cid, count); - } - - r_ept = rpcrouter_lookup_remote_endpoint(hdr.dst_pid, hdr.dst_cid); - - if ((!r_ept) && (hdr.dst_pid != RPCROUTER_PID_LOCAL)) { - printk(KERN_ERR - "msm_rpc_write(): No route to ept " - "[PID %x CID %x]\n", hdr.dst_pid, hdr.dst_cid); - count = -EHOSTUNREACH; - goto write_release_lock; - } - - tx_cnt = count; - tx_buf = buffer; - mid = atomic_add_return(1, &pm_mid) & 0xFF; - /* The modem's router can only take 500 bytes of data. The - first 8 bytes it uses on the modem side for addressing, - the next 4 bytes are for the pacmark header. */ - max_tx = RPCROUTER_MSGSIZE_MAX - 8 - sizeof(uint32_t); - IO("Writing %d bytes, max pkt size is %d\n", - tx_cnt, max_tx); - while (tx_cnt > 0) { - if (tx_cnt > max_tx) { - rc = msm_rpc_write_pkt(&hdr, ept, r_ept, - tx_buf, max_tx, - first_pkt, 0, mid); - if (rc < 0) { - count = rc; - goto write_release_lock; - } - IO("Wrote %d bytes First %d, Last 0 mid %d\n", - rc, first_pkt, mid); - tx_cnt -= max_tx; - tx_buf += max_tx; - } else { - rc = msm_rpc_write_pkt(&hdr, ept, r_ept, - tx_buf, tx_cnt, - first_pkt, 1, mid); - if (rc < 0) { - count = rc; - goto write_release_lock; - } - IO("Wrote %d bytes First %d Last 1 mid %d\n", - rc, first_pkt, mid); - break; - } - first_pkt = 0; - } - - write_release_lock: - /* if reply, release wakelock after writing to the transport */ - if (rq->type != 0) { - /* Upon failure, add reply tag to the pending list. - ** Else add reply tag to the avail/free list. */ - if (count < 0) - set_pend_reply(ept, reply); - else - set_avail_reply(ept, reply); - - spin_lock_irqsave(&ept->reply_q_lock, flags); - if (list_empty(&ept->reply_pend_q)) { - D("%s: release reply lock on ept %p\n", __func__, ept); - wake_unlock(&ept->reply_q_wake_lock); - } - spin_unlock_irqrestore(&ept->reply_q_lock, flags); - } - - return count; -} -EXPORT_SYMBOL(msm_rpc_write); - -/* - * NOTE: It is the responsibility of the caller to kfree buffer - */ -int msm_rpc_read(struct msm_rpc_endpoint *ept, void **buffer, - unsigned user_len, long timeout) -{ - struct rr_fragment *frag, *next; - char *buf; - int rc; - - rc = __msm_rpc_read(ept, &frag, user_len, timeout); - if (rc <= 0) - return rc; - - /* single-fragment messages conveniently can be - * returned as-is (the buffer is at the front) - */ - if (frag->next == 0) { - *buffer = (void*) frag; - return rc; - } - - /* multi-fragment messages, we have to do it the - * hard way, which is rather disgusting right now - */ - buf = rr_malloc(rc); - *buffer = buf; - - while (frag != NULL) { - memcpy(buf, frag->data, frag->length); - next = frag->next; - buf += frag->length; - kfree(frag); - frag = next; - } - - return rc; -} -EXPORT_SYMBOL(msm_rpc_read); - -int msm_rpc_call(struct msm_rpc_endpoint *ept, uint32_t proc, - void *_request, int request_size, - long timeout) -{ - return msm_rpc_call_reply(ept, proc, - _request, request_size, - NULL, 0, timeout); -} -EXPORT_SYMBOL(msm_rpc_call); - -int msm_rpc_call_reply(struct msm_rpc_endpoint *ept, uint32_t proc, - void *_request, int request_size, - void *_reply, int reply_size, - long timeout) -{ - struct rpc_request_hdr *req = _request; - struct rpc_reply_hdr *reply; - int rc; - - if (request_size < sizeof(*req)) - return -ETOOSMALL; - - if (ept->dst_pid == 0xffffffff) - return -ENOTCONN; - - memset(req, 0, sizeof(*req)); - req->xid = cpu_to_be32(atomic_add_return(1, &next_xid)); - req->rpc_vers = cpu_to_be32(2); - req->prog = ept->dst_prog; - req->vers = ept->dst_vers; - req->procedure = cpu_to_be32(proc); - - rc = msm_rpc_write(ept, req, request_size); - if (rc < 0) - return rc; - - for (;;) { - rc = msm_rpc_read(ept, (void*) &reply, -1, timeout); - if (rc < 0) - return rc; - if (rc < (3 * sizeof(uint32_t))) { - rc = -EIO; - break; - } - /* we should not get CALL packets -- ignore them */ - if (reply->type == 0) { - kfree(reply); - continue; - } - /* If an earlier call timed out, we could get the (no - * longer wanted) reply for it. Ignore replies that - * we don't expect - */ - if (reply->xid != req->xid) { - kfree(reply); - continue; - } - if (reply->reply_stat != 0) { - rc = -EPERM; - break; - } - if (reply->data.acc_hdr.accept_stat != 0) { - rc = -EINVAL; - break; - } - if (_reply == NULL) { - rc = 0; - break; - } - if (rc > reply_size) { - rc = -ENOMEM; - } else { - memcpy(_reply, reply, rc); - } - break; - } - kfree(reply); - return rc; -} -EXPORT_SYMBOL(msm_rpc_call_reply); - - -static inline int ept_packet_available(struct msm_rpc_endpoint *ept) -{ - unsigned long flags; - int ret; - spin_lock_irqsave(&ept->read_q_lock, flags); - ret = !list_empty(&ept->read_q); - spin_unlock_irqrestore(&ept->read_q_lock, flags); - return ret; -} - -int __msm_rpc_read(struct msm_rpc_endpoint *ept, - struct rr_fragment **frag_ret, - unsigned len, long timeout) -{ - struct rr_packet *pkt; - struct rpc_request_hdr *rq; - struct msm_rpc_reply *reply; - unsigned long flags; - int rc; - - rc = wait_for_restart_and_notify(ept); - if (rc) - return rc; - - IO("READ on ept %p\n", ept); - if (ept->flags & MSM_RPC_UNINTERRUPTIBLE) { - if (timeout < 0) { - wait_event(ept->wait_q, (ept_packet_available(ept) || - ept->forced_wakeup || - ept->restart_state)); - if (!msm_rpc_clear_netreset(ept)) - return -ENETRESET; - } else { - rc = wait_event_timeout( - ept->wait_q, - (ept_packet_available(ept) || - ept->forced_wakeup || - ept->restart_state), - timeout); - if (!msm_rpc_clear_netreset(ept)) - return -ENETRESET; - if (rc == 0) - return -ETIMEDOUT; - } - } else { - if (timeout < 0) { - rc = wait_event_interruptible( - ept->wait_q, (ept_packet_available(ept) || - ept->forced_wakeup || - ept->restart_state)); - if (!msm_rpc_clear_netreset(ept)) - return -ENETRESET; - if (rc < 0) - return rc; - } else { - rc = wait_event_interruptible_timeout( - ept->wait_q, - (ept_packet_available(ept) || - ept->forced_wakeup || - ept->restart_state), - timeout); - if (!msm_rpc_clear_netreset(ept)) - return -ENETRESET; - if (rc == 0) - return -ETIMEDOUT; - } - } - - if (ept->forced_wakeup) { - ept->forced_wakeup = 0; - return 0; - } - - spin_lock_irqsave(&ept->read_q_lock, flags); - if (list_empty(&ept->read_q)) { - spin_unlock_irqrestore(&ept->read_q_lock, flags); - return -EAGAIN; - } - pkt = list_first_entry(&ept->read_q, struct rr_packet, list); - if (pkt->length > len) { - spin_unlock_irqrestore(&ept->read_q_lock, flags); - return -ETOOSMALL; - } - list_del(&pkt->list); - spin_unlock_irqrestore(&ept->read_q_lock, flags); - - rc = pkt->length; - - *frag_ret = pkt->first; - rq = (void*) pkt->first->data; - if ((rc >= (sizeof(uint32_t) * 3)) && (rq->type == 0)) { - /* RPC CALL */ - reply = get_avail_reply(ept); - if (!reply) { - rc = -ENOMEM; - goto read_release_lock; - } - reply->cid = pkt->hdr.src_cid; - reply->pid = pkt->hdr.src_pid; - reply->xid = rq->xid; - reply->prog = rq->prog; - reply->vers = rq->vers; - set_pend_reply(ept, reply); - } - - kfree(pkt); - - IO("READ on ept %p (%d bytes)\n", ept, rc); - - read_release_lock: - - /* release read wakelock after taking reply wakelock */ - spin_lock_irqsave(&ept->read_q_lock, flags); - if (list_empty(&ept->read_q)) { - D("%s: release read lock on ept %p\n", __func__, ept); - wake_unlock(&ept->read_q_wake_lock); - } - spin_unlock_irqrestore(&ept->read_q_lock, flags); - - return rc; -} - -int msm_rpc_is_compatible_version(uint32_t server_version, - uint32_t client_version) -{ - - if ((server_version & RPC_VERSION_MODE_MASK) != - (client_version & RPC_VERSION_MODE_MASK)) - return 0; - - if (server_version & RPC_VERSION_MODE_MASK) - return server_version == client_version; - - return ((server_version & RPC_VERSION_MAJOR_MASK) == - (client_version & RPC_VERSION_MAJOR_MASK)) && - ((server_version & RPC_VERSION_MINOR_MASK) >= - (client_version & RPC_VERSION_MINOR_MASK)); -} -EXPORT_SYMBOL(msm_rpc_is_compatible_version); - -static struct rr_server *msm_rpc_get_server(uint32_t prog, uint32_t vers, - uint32_t accept_compatible, - uint32_t *found_prog) -{ - struct rr_server *server; - unsigned long flags; - - if (found_prog == NULL) - return NULL; - - *found_prog = 0; - spin_lock_irqsave(&server_list_lock, flags); - list_for_each_entry(server, &server_list, list) { - if (server->prog == prog) { - *found_prog = 1; - spin_unlock_irqrestore(&server_list_lock, flags); - if (accept_compatible) { - if (msm_rpc_is_compatible_version(server->vers, - vers)) { - return server; - } else { - return NULL; - } - } else if (server->vers == vers) { - return server; - } else - return NULL; - } - } - spin_unlock_irqrestore(&server_list_lock, flags); - return NULL; -} - -static struct msm_rpc_endpoint *__msm_rpc_connect(uint32_t prog, uint32_t vers, - uint32_t accept_compatible, - unsigned flags) -{ - struct msm_rpc_endpoint *ept; - struct rr_server *server; - uint32_t found_prog; - int rc = 0; - - DEFINE_WAIT(__wait); - - for (;;) { - prepare_to_wait(&newserver_wait, &__wait, - TASK_INTERRUPTIBLE); - - server = msm_rpc_get_server(prog, vers, accept_compatible, - &found_prog); - if (server) - break; - - if (found_prog) { - pr_info("%s: server not found %x:%x\n", - __func__, prog, vers); - rc = -EHOSTUNREACH; - break; - } - - if (msm_rpc_connect_timeout_ms == 0) { - rc = -EHOSTUNREACH; - break; - } - - if (signal_pending(current)) { - rc = -ERESTARTSYS; - break; - } - - rc = schedule_timeout( - msecs_to_jiffies(msm_rpc_connect_timeout_ms)); - if (!rc) { - rc = -ETIMEDOUT; - break; - } - } - finish_wait(&newserver_wait, &__wait); - - if (!server) - return ERR_PTR(rc); - - if (accept_compatible && (server->vers != vers)) { - D("RPC Using new version 0x%08x(0x%08x) prog 0x%08x", - vers, server->vers, prog); - D(" ... Continuing\n"); - } - - ept = msm_rpc_open(); - if (IS_ERR(ept)) - return ept; - - ept->flags = flags; - ept->dst_pid = server->pid; - ept->dst_cid = server->cid; - ept->dst_prog = cpu_to_be32(prog); - ept->dst_vers = cpu_to_be32(server->vers); - - return ept; -} - -struct msm_rpc_endpoint *msm_rpc_connect_compatible(uint32_t prog, - uint32_t vers, unsigned flags) -{ - return __msm_rpc_connect(prog, vers, 1, flags); -} -EXPORT_SYMBOL(msm_rpc_connect_compatible); - -struct msm_rpc_endpoint *msm_rpc_connect(uint32_t prog, - uint32_t vers, unsigned flags) -{ - return __msm_rpc_connect(prog, vers, 0, flags); -} -EXPORT_SYMBOL(msm_rpc_connect); - -/* TODO: permission check? */ -int msm_rpc_register_server(struct msm_rpc_endpoint *ept, - uint32_t prog, uint32_t vers) -{ - int rc; - union rr_control_msg msg = { 0 }; - struct rr_server *server; - struct rpcrouter_xprt_info *xprt_info; - - server = rpcrouter_create_server(ept->pid, ept->cid, - prog, vers); - if (!server) - return -ENODEV; - - msg.srv.cmd = RPCROUTER_CTRL_CMD_NEW_SERVER; - msg.srv.pid = ept->pid; - msg.srv.cid = ept->cid; - msg.srv.prog = prog; - msg.srv.vers = vers; - - RR("x NEW_SERVER id=%d:%08x prog=%08x:%08x\n", - ept->pid, ept->cid, prog, vers); - - mutex_lock(&xprt_info_list_lock); - list_for_each_entry(xprt_info, &xprt_info_list, list) { - rc = rpcrouter_send_control_msg(xprt_info, &msg); - if (rc < 0) { - mutex_unlock(&xprt_info_list_lock); - return rc; - } - } - mutex_unlock(&xprt_info_list_lock); - return 0; -} - -int msm_rpc_clear_netreset(struct msm_rpc_endpoint *ept) -{ - unsigned long flags; - int rc = 1; - spin_lock_irqsave(&ept->restart_lock, flags); - if (ept->restart_state != RESTART_NORMAL) { - ept->restart_state &= ~RESTART_PEND_NTFY; - rc = 0; - } - spin_unlock_irqrestore(&ept->restart_lock, flags); - return rc; -} - -/* TODO: permission check -- disallow unreg of somebody else's server */ -int msm_rpc_unregister_server(struct msm_rpc_endpoint *ept, - uint32_t prog, uint32_t vers) -{ - struct rr_server *server; - server = rpcrouter_lookup_server(prog, vers); - - if (!server) - return -ENOENT; - rpcrouter_destroy_server(server); - return 0; -} - -int msm_rpc_get_curr_pkt_size(struct msm_rpc_endpoint *ept) -{ - unsigned long flags; - struct rr_packet *pkt; - int rc = 0; - - if (!ept) - return -EINVAL; - - if (!msm_rpc_clear_netreset(ept)) - return -ENETRESET; - - spin_lock_irqsave(&ept->read_q_lock, flags); - if (!list_empty(&ept->read_q)) { - pkt = list_first_entry(&ept->read_q, struct rr_packet, list); - rc = pkt->length; - } - spin_unlock_irqrestore(&ept->read_q_lock, flags); - - return rc; -} - -static int msm_rpcrouter_close(void) -{ - struct rpcrouter_xprt_info *xprt_info; - union rr_control_msg ctl = { 0 }; - - ctl.cmd = RPCROUTER_CTRL_CMD_BYE; - mutex_lock(&xprt_info_list_lock); - while (!list_empty(&xprt_info_list)) { - xprt_info = list_first_entry(&xprt_info_list, - struct rpcrouter_xprt_info, list); - modem_reset_cleanup(xprt_info); - xprt_info->abort_data_read = 1; - wake_up(&xprt_info->read_wait); - rpcrouter_send_control_msg(xprt_info, &ctl); - xprt_info->xprt->close(); - list_del(&xprt_info->list); - mutex_unlock(&xprt_info_list_lock); - - flush_workqueue(xprt_info->workqueue); - destroy_workqueue(xprt_info->workqueue); - wake_lock_destroy(&xprt_info->wakelock); - /*free memory*/ - xprt_info->xprt->priv = 0; - kfree(xprt_info); - - mutex_lock(&xprt_info_list_lock); - } - mutex_unlock(&xprt_info_list_lock); - return 0; -} - -#if defined(CONFIG_DEBUG_FS) -static int dump_servers(char *buf, int max) -{ - int i = 0; - unsigned long flags; - struct rr_server *svr; - const char *sym; - - spin_lock_irqsave(&server_list_lock, flags); - list_for_each_entry(svr, &server_list, list) { - i += scnprintf(buf + i, max - i, "pdev_name: %s\n", - svr->pdev_name); - i += scnprintf(buf + i, max - i, "pid: 0x%08x\n", svr->pid); - i += scnprintf(buf + i, max - i, "cid: 0x%08x\n", svr->cid); - i += scnprintf(buf + i, max - i, "prog: 0x%08x", svr->prog); - sym = smd_rpc_get_sym(svr->prog); - if (sym) - i += scnprintf(buf + i, max - i, " (%s)\n", sym); - else - i += scnprintf(buf + i, max - i, "\n"); - i += scnprintf(buf + i, max - i, "vers: 0x%08x\n", svr->vers); - i += scnprintf(buf + i, max - i, "\n"); - } - spin_unlock_irqrestore(&server_list_lock, flags); - - return i; -} - -static int dump_remote_endpoints(char *buf, int max) -{ - int i = 0; - unsigned long flags; - struct rr_remote_endpoint *ept; - - spin_lock_irqsave(&remote_endpoints_lock, flags); - list_for_each_entry(ept, &remote_endpoints, list) { - i += scnprintf(buf + i, max - i, "pid: 0x%08x\n", ept->pid); - i += scnprintf(buf + i, max - i, "cid: 0x%08x\n", ept->cid); - i += scnprintf(buf + i, max - i, "tx_quota_cntr: %i\n", - ept->tx_quota_cntr); - i += scnprintf(buf + i, max - i, "quota_restart_state: %i\n", - ept->quota_restart_state); - i += scnprintf(buf + i, max - i, "\n"); - } - spin_unlock_irqrestore(&remote_endpoints_lock, flags); - - return i; -} - -static int dump_msm_rpc_endpoint(char *buf, int max) -{ - int i = 0; - unsigned long flags; - struct msm_rpc_reply *reply; - struct msm_rpc_endpoint *ept; - struct rr_packet *pkt; - const char *sym; - - spin_lock_irqsave(&local_endpoints_lock, flags); - list_for_each_entry(ept, &local_endpoints, list) { - i += scnprintf(buf + i, max - i, "pid: 0x%08x\n", ept->pid); - i += scnprintf(buf + i, max - i, "cid: 0x%08x\n", ept->cid); - i += scnprintf(buf + i, max - i, "dst_pid: 0x%08x\n", - ept->dst_pid); - i += scnprintf(buf + i, max - i, "dst_cid: 0x%08x\n", - ept->dst_cid); - i += scnprintf(buf + i, max - i, "dst_prog: 0x%08x", - be32_to_cpu(ept->dst_prog)); - sym = smd_rpc_get_sym(be32_to_cpu(ept->dst_prog)); - if (sym) - i += scnprintf(buf + i, max - i, " (%s)\n", sym); - else - i += scnprintf(buf + i, max - i, "\n"); - i += scnprintf(buf + i, max - i, "dst_vers: 0x%08x\n", - be32_to_cpu(ept->dst_vers)); - i += scnprintf(buf + i, max - i, "reply_cnt: %i\n", - ept->reply_cnt); - i += scnprintf(buf + i, max - i, "restart_state: %i\n", - ept->restart_state); - - i += scnprintf(buf + i, max - i, "outstanding xids:\n"); - spin_lock(&ept->reply_q_lock); - list_for_each_entry(reply, &ept->reply_pend_q, list) - i += scnprintf(buf + i, max - i, " xid = %u\n", - ntohl(reply->xid)); - spin_unlock(&ept->reply_q_lock); - - i += scnprintf(buf + i, max - i, "complete unread packets:\n"); - spin_lock(&ept->read_q_lock); - list_for_each_entry(pkt, &ept->read_q, list) { - i += scnprintf(buf + i, max - i, " mid = %i\n", - pkt->mid); - i += scnprintf(buf + i, max - i, " length = %i\n", - pkt->length); - } - spin_unlock(&ept->read_q_lock); - i += scnprintf(buf + i, max - i, "\n"); - } - spin_unlock_irqrestore(&local_endpoints_lock, flags); - - return i; -} - -#define DEBUG_BUFMAX 4096 -static char debug_buffer[DEBUG_BUFMAX]; - -static ssize_t debug_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - int (*fill)(char *buf, int max) = file->private_data; - int bsize = fill(debug_buffer, DEBUG_BUFMAX); - return simple_read_from_buffer(buf, count, ppos, debug_buffer, bsize); -} - -static int debug_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static const struct file_operations debug_ops = { - .read = debug_read, - .open = debug_open, -}; - -static void debug_create(const char *name, mode_t mode, - struct dentry *dent, - int (*fill)(char *buf, int max)) -{ - debugfs_create_file(name, mode, dent, fill, &debug_ops); -} - -static void debugfs_init(void) -{ - struct dentry *dent; - - dent = debugfs_create_dir("smd_rpcrouter", 0); - if (IS_ERR(dent)) - return; - - debug_create("dump_msm_rpc_endpoints", 0444, dent, - dump_msm_rpc_endpoint); - debug_create("dump_remote_endpoints", 0444, dent, - dump_remote_endpoints); - debug_create("dump_servers", 0444, dent, - dump_servers); - -} - -#else -static void debugfs_init(void) {} -#endif - -static int msm_rpcrouter_add_xprt(struct rpcrouter_xprt *xprt) -{ - struct rpcrouter_xprt_info *xprt_info; - - D("Registering xprt %s to RPC Router\n", xprt->name); - - xprt_info = kmalloc(sizeof(struct rpcrouter_xprt_info), GFP_KERNEL); - if (!xprt_info) - return -ENOMEM; - - xprt_info->xprt = xprt; - xprt_info->initialized = 0; - xprt_info->remote_pid = -1; - init_waitqueue_head(&xprt_info->read_wait); - spin_lock_init(&xprt_info->lock); - wake_lock_init(&xprt_info->wakelock, - WAKE_LOCK_SUSPEND, xprt->name); - xprt_info->need_len = 0; - xprt_info->abort_data_read = 0; - INIT_WORK(&xprt_info->read_data, do_read_data); - INIT_LIST_HEAD(&xprt_info->list); - - xprt_info->workqueue = create_singlethread_workqueue(xprt->name); - if (!xprt_info->workqueue) { - kfree(xprt_info); - return -ENOMEM; - } - - if (!strcmp(xprt->name, "rpcrouter_loopback_xprt")) { - xprt_info->remote_pid = RPCROUTER_PID_LOCAL; - xprt_info->initialized = 1; - } else { - smsm_change_state(SMSM_APPS_STATE, 0, SMSM_RPCINIT); - } - - mutex_lock(&xprt_info_list_lock); - list_add_tail(&xprt_info->list, &xprt_info_list); - mutex_unlock(&xprt_info_list_lock); - - queue_work(xprt_info->workqueue, &xprt_info->read_data); - - xprt->priv = xprt_info; - - return 0; -} - -static void msm_rpcrouter_remove_xprt(struct rpcrouter_xprt *xprt) -{ - struct rpcrouter_xprt_info *xprt_info; - unsigned long flags; - - if (xprt && xprt->priv) { - xprt_info = xprt->priv; - - /* abort rr_read thread */ - xprt_info->abort_data_read = 1; - wake_up(&xprt_info->read_wait); - - /* remove xprt from available xprts */ - mutex_lock(&xprt_info_list_lock); - spin_lock_irqsave(&xprt_info->lock, flags); - list_del(&xprt_info->list); - - /* unlock the spinlock last to avoid a race - * condition with rpcrouter_get_xprt_info - * in msm_rpc_write_pkt in which the - * xprt is returned from rpcrouter_get_xprt_info - * and then deleted here. */ - mutex_unlock(&xprt_info_list_lock); - spin_unlock_irqrestore(&xprt_info->lock, flags); - - /* cleanup workqueues and wakelocks */ - flush_workqueue(xprt_info->workqueue); - destroy_workqueue(xprt_info->workqueue); - wake_lock_destroy(&xprt_info->wakelock); - - - /* free memory */ - xprt->priv = 0; - kfree(xprt_info); - } -} - -struct rpcrouter_xprt_work { - struct rpcrouter_xprt *xprt; - struct work_struct work; -}; - -static void xprt_open_worker(struct work_struct *work) -{ - struct rpcrouter_xprt_work *xprt_work = - container_of(work, struct rpcrouter_xprt_work, work); - - msm_rpcrouter_add_xprt(xprt_work->xprt); - - kfree(xprt_work); -} - -static void xprt_close_worker(struct work_struct *work) -{ - struct rpcrouter_xprt_work *xprt_work = - container_of(work, struct rpcrouter_xprt_work, work); - - modem_reset_cleanup(xprt_work->xprt->priv); - msm_rpcrouter_remove_xprt(xprt_work->xprt); - - if (atomic_dec_return(&pending_close_count) == 0) - wake_up(&subsystem_restart_wait); - - kfree(xprt_work); -} - -void msm_rpcrouter_xprt_notify(struct rpcrouter_xprt *xprt, unsigned event) -{ - struct rpcrouter_xprt_info *xprt_info; - struct rpcrouter_xprt_work *xprt_work; - unsigned long flags; - - /* Workqueue is created in init function which works for all existing - * clients. If this fails in the future, then it will need to be - * created earlier. */ - BUG_ON(!rpcrouter_workqueue); - - switch (event) { - case RPCROUTER_XPRT_EVENT_OPEN: - D("open event for '%s'\n", xprt->name); - xprt_work = kmalloc(sizeof(struct rpcrouter_xprt_work), - GFP_ATOMIC); - xprt_work->xprt = xprt; - INIT_WORK(&xprt_work->work, xprt_open_worker); - queue_work(rpcrouter_workqueue, &xprt_work->work); - break; - - case RPCROUTER_XPRT_EVENT_CLOSE: - D("close event for '%s'\n", xprt->name); - - atomic_inc(&pending_close_count); - - xprt_work = kmalloc(sizeof(struct rpcrouter_xprt_work), - GFP_ATOMIC); - xprt_work->xprt = xprt; - INIT_WORK(&xprt_work->work, xprt_close_worker); - queue_work(rpcrouter_workqueue, &xprt_work->work); - break; - } - - xprt_info = xprt->priv; - if (xprt_info) { - spin_lock_irqsave(&xprt_info->lock, flags); - /* Check read_avail even for OPEN event to handle missed - DATA events while processing the OPEN event*/ - if (xprt->read_avail() >= xprt_info->need_len) - wake_lock(&xprt_info->wakelock); - wake_up(&xprt_info->read_wait); - spin_unlock_irqrestore(&xprt_info->lock, flags); - } -} - -static int modem_restart_notifier_cb(struct notifier_block *this, - unsigned long code, - void *data); -static struct notifier_block nb = { - .notifier_call = modem_restart_notifier_cb, -}; - -static int modem_restart_notifier_cb(struct notifier_block *this, - unsigned long code, - void *data) -{ - switch (code) { - case SUBSYS_BEFORE_SHUTDOWN: - D("%s: SUBSYS_BEFORE_SHUTDOWN\n", __func__); - break; - - case SUBSYS_BEFORE_POWERUP: - D("%s: waiting for RPC restart to complete\n", __func__); - wait_event(subsystem_restart_wait, - atomic_read(&pending_close_count) == 0); - D("%s: finished restart wait\n", __func__); - break; - - default: - break; - } - - return NOTIFY_DONE; -} - -static void *restart_notifier_handle; -static __init int modem_restart_late_init(void) -{ - restart_notifier_handle = subsys_notif_register_notifier("modem", &nb); - return 0; -} -late_initcall(modem_restart_late_init); - -static int __init rpcrouter_init(void) -{ - int ret; - - msm_rpc_connect_timeout_ms = 0; - smd_rpcrouter_debug_mask |= SMEM_LOG; - debugfs_init(); - ret = register_reboot_notifier(&msm_rpc_reboot_notifier); - if (ret) - pr_err("%s: Failed to register reboot notifier", __func__); - - /* Initialize what we need to start processing */ - rpcrouter_workqueue = - create_singlethread_workqueue("rpcrouter"); - if (!rpcrouter_workqueue) { - msm_rpcrouter_exit_devices(); - return -ENOMEM; - } - - init_waitqueue_head(&newserver_wait); - init_waitqueue_head(&subsystem_restart_wait); - - ret = msm_rpcrouter_init_devices(); - if (ret < 0) - return ret; - - return ret; -} - -module_init(rpcrouter_init); -MODULE_DESCRIPTION("MSM RPC Router"); -MODULE_AUTHOR("San Mehat "); -MODULE_LICENSE("GPL"); diff --git a/arch/arm/mach-msm/smd_rpcrouter.h b/arch/arm/mach-msm/smd_rpcrouter.h deleted file mode 100644 index 2ad85a4dee1d95c4b157dbf8113cdd6e6e4d1a0e..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/smd_rpcrouter.h +++ /dev/null @@ -1,265 +0,0 @@ -/** arch/arm/mach-msm/smd_rpcrouter.h - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2007-2012, The Linux Foundation. All rights reserved. - * Author: San Mehat - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _ARCH_ARM_MACH_MSM_SMD_RPCROUTER_H -#define _ARCH_ARM_MACH_MSM_SMD_RPCROUTER_H - -#include -#include -#include -#include -#include -#include - -#include -#include - -/* definitions for the R2R wire protcol */ - -#define RPCROUTER_VERSION 1 -#define RPCROUTER_PROCESSORS_MAX 4 -#define RPCROUTER_MSGSIZE_MAX 512 -#define RPCROUTER_PEND_REPLIES_MAX 32 - -#define RPCROUTER_CLIENT_BCAST_ID 0xffffffff -#define RPCROUTER_ROUTER_ADDRESS 0xfffffffe - -#define RPCROUTER_PID_LOCAL 1 - -#define RPCROUTER_CTRL_CMD_DATA 1 -#define RPCROUTER_CTRL_CMD_HELLO 2 -#define RPCROUTER_CTRL_CMD_BYE 3 -#define RPCROUTER_CTRL_CMD_NEW_SERVER 4 -#define RPCROUTER_CTRL_CMD_REMOVE_SERVER 5 -#define RPCROUTER_CTRL_CMD_REMOVE_CLIENT 6 -#define RPCROUTER_CTRL_CMD_RESUME_TX 7 -#define RPCROUTER_CTRL_CMD_EXIT 8 -#define RPCROUTER_CTRL_CMD_PING 9 - -#define RPCROUTER_DEFAULT_RX_QUOTA 5 - -#define RPCROUTER_XPRT_EVENT_DATA 1 -#define RPCROUTER_XPRT_EVENT_OPEN 2 -#define RPCROUTER_XPRT_EVENT_CLOSE 3 - -/* Restart states for endpoint. - * - * Two different bits are specified here, one for - * the remote server notification (RESTART_PEND_SVR) - * and one for client notification (RESTART_PEND_NTFY). - * The client notification is used to ensure that - * the client gets notified by an ENETRESET return - * code at least once, even if they miss the actual - * reset event. The server notification is used to - * properly handle the reset state of the endpoint. - */ -#define RESTART_NORMAL 0x0 -#define RESTART_PEND_SVR 0x1 -#define RESTART_PEND_NTFY 0x2 -#define RESTART_PEND_NTFY_SVR (RESTART_PEND_SVR | RESTART_PEND_NTFY) - -union rr_control_msg { - uint32_t cmd; - struct { - uint32_t cmd; - uint32_t prog; - uint32_t vers; - uint32_t pid; - uint32_t cid; - } srv; - struct { - uint32_t cmd; - uint32_t pid; - uint32_t cid; - } cli; -}; - -struct rr_header { - uint32_t version; - uint32_t type; - uint32_t src_pid; - uint32_t src_cid; - uint32_t confirm_rx; - uint32_t size; - uint32_t dst_pid; - uint32_t dst_cid; -}; - -/* internals */ - -#define RPCROUTER_MAX_REMOTE_SERVERS 100 - -struct rr_fragment { - unsigned char data[RPCROUTER_MSGSIZE_MAX]; - uint32_t length; - struct rr_fragment *next; -}; - -struct rr_packet { - struct list_head list; - struct rr_fragment *first; - struct rr_fragment *last; - struct rr_header hdr; - uint32_t mid; - uint32_t length; -}; - -#define PACMARK_LAST(n) ((n) & 0x80000000) -#define PACMARK_MID(n) (((n) >> 16) & 0xFF) -#define PACMARK_LEN(n) ((n) & 0xFFFF) - -static inline uint32_t PACMARK(uint32_t len, uint32_t mid, uint32_t first, - uint32_t last) -{ - return (len & 0xFFFF) | - ((mid & 0xFF) << 16) | - ((!!first) << 30) | - ((!!last) << 31); -} - -struct rr_server { - struct list_head list; - - uint32_t pid; - uint32_t cid; - uint32_t prog; - uint32_t vers; - - dev_t device_number; - struct cdev cdev; - struct device *device; - struct rpcsvr_platform_device p_device; - char pdev_name[32]; -}; - -struct rr_remote_endpoint { - uint32_t pid; - uint32_t cid; - - int tx_quota_cntr; - int quota_restart_state; - spinlock_t quota_lock; - wait_queue_head_t quota_wait; - - struct list_head list; -}; - -struct msm_rpc_reply { - struct list_head list; - uint32_t pid; - uint32_t cid; - uint32_t prog; /* be32 */ - uint32_t vers; /* be32 */ - uint32_t xid; /* be32 */ -}; - -struct msm_rpc_endpoint { - struct list_head list; - - /* incomplete packets waiting for assembly */ - struct list_head incomplete; - spinlock_t incomplete_lock; - - /* complete packets waiting to be read */ - struct list_head read_q; - spinlock_t read_q_lock; - struct wake_lock read_q_wake_lock; - wait_queue_head_t wait_q; - unsigned flags; - uint32_t forced_wakeup; - - /* restart handling */ - int restart_state; - spinlock_t restart_lock; - wait_queue_head_t restart_wait; - - /* modem restart notifications */ - int do_setup_notif; - void *client_data; - void (*cb_restart_teardown)(void *client_data); - void (*cb_restart_setup)(void *client_data); - - /* endpoint address */ - uint32_t pid; - uint32_t cid; - - /* bound remote address - * if not connected (dst_pid == 0xffffffff) RPC_CALL writes fail - * RPC_CALLs must be to the prog/vers below or they will fail - */ - uint32_t dst_pid; - uint32_t dst_cid; - uint32_t dst_prog; /* be32 */ - uint32_t dst_vers; /* be32 */ - - /* reply queue for inbound messages */ - struct list_head reply_pend_q; - struct list_head reply_avail_q; - spinlock_t reply_q_lock; - uint32_t reply_cnt; - struct wake_lock reply_q_wake_lock; - - /* device node if this endpoint is accessed via userspace */ - dev_t dev; -}; - -enum write_data_type { - HEADER = 1, - PACKMARK, - PAYLOAD, -}; - -struct rpcrouter_xprt { - char *name; - void *priv; - - int (*read_avail)(void); - int (*read)(void *data, uint32_t len); - int (*write_avail)(void); - int (*write)(void *data, uint32_t len, enum write_data_type type); - int (*close)(void); -}; - -/* shared between smd_rpcrouter*.c */ -void msm_rpcrouter_xprt_notify(struct rpcrouter_xprt *xprt, unsigned event); -int __msm_rpc_read(struct msm_rpc_endpoint *ept, - struct rr_fragment **frag, - unsigned len, long timeout); - -struct msm_rpc_endpoint *msm_rpcrouter_create_local_endpoint(dev_t dev); -int msm_rpcrouter_destroy_local_endpoint(struct msm_rpc_endpoint *ept); - -int msm_rpcrouter_create_server_cdev(struct rr_server *server); -int msm_rpcrouter_create_server_pdev(struct rr_server *server); - -int msm_rpcrouter_init_devices(void); -void msm_rpcrouter_exit_devices(void); - -void get_requesting_client(struct msm_rpc_endpoint *ept, uint32_t xid, - struct msm_rpc_client_info *clnt_info); - -extern dev_t msm_rpcrouter_devno; -extern struct completion rpc_remote_router_up; -extern struct class *msm_rpcrouter_class; - -void xdr_init(struct msm_rpc_xdr *xdr); -void xdr_init_input(struct msm_rpc_xdr *xdr, void *buf, uint32_t size); -void xdr_init_output(struct msm_rpc_xdr *xdr, void *buf, uint32_t size); -void xdr_clean_input(struct msm_rpc_xdr *xdr); -void xdr_clean_output(struct msm_rpc_xdr *xdr); -uint32_t xdr_read_avail(struct msm_rpc_xdr *xdr); -#endif diff --git a/arch/arm/mach-msm/smd_rpcrouter_clients.c b/arch/arm/mach-msm/smd_rpcrouter_clients.c deleted file mode 100644 index 653784614fddc9a82385c1e0076fd2053994175c..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/smd_rpcrouter_clients.c +++ /dev/null @@ -1,922 +0,0 @@ -/* Copyright (c) 2009-2011, 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. - * - */ - -/* - * SMD RPCROUTER CLIENTS module. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include "smd_rpcrouter.h" - -struct msm_rpc_client_cb_item { - struct list_head list; - - void *buf; - int size; -}; - -struct msm_rpc_cb_table_item { - struct list_head list; - - uint32_t cb_id; - void *cb_func; -}; - -static int rpc_clients_cb_thread(void *data) -{ - struct msm_rpc_client_cb_item *cb_item; - struct msm_rpc_client *client; - struct rpc_request_hdr req; - int ret; - - client = data; - for (;;) { - wait_event(client->cb_wait, client->cb_avail); - if (client->exit_flag) - break; - - client->cb_avail = 0; - mutex_lock(&client->cb_item_list_lock); - while (!list_empty(&client->cb_item_list)) { - cb_item = list_first_entry( - &client->cb_item_list, - struct msm_rpc_client_cb_item, - list); - list_del(&cb_item->list); - mutex_unlock(&client->cb_item_list_lock); - xdr_init_input(&client->cb_xdr, cb_item->buf, - cb_item->size); - ret = xdr_recv_req(&client->cb_xdr, &req); - if (ret) - goto bad_rpc; - - if (req.type != 0) - goto bad_rpc; - if (req.rpc_vers != 2) - goto bad_rpc; - if (req.prog != - (client->prog | 0x01000000)) - goto bad_rpc; - - if (client->version == 2) - client->cb_func2(client, &req, &client->cb_xdr); - else - client->cb_func(client, client->cb_xdr.in_buf, - client->cb_xdr.in_size); - bad_rpc: - xdr_clean_input(&client->cb_xdr); - kfree(cb_item); - mutex_lock(&client->cb_item_list_lock); - } - mutex_unlock(&client->cb_item_list_lock); - } - complete_and_exit(&client->cb_complete, 0); -} - -static int rpc_clients_thread(void *data) -{ - void *buffer; - uint32_t type; - struct msm_rpc_client *client; - int rc = 0; - struct msm_rpc_client_cb_item *cb_item; - struct rpc_request_hdr req; - - client = data; - for (;;) { - buffer = NULL; - rc = msm_rpc_read(client->ept, &buffer, -1, -1); - - if (client->exit_flag) { - kfree(buffer); - break; - } - - if (rc < 0) { - /* wakeup any pending requests */ - wake_up(&client->reply_wait); - kfree(buffer); - continue; - } - - if (rc < ((int)(sizeof(uint32_t) * 2))) { - kfree(buffer); - continue; - } - - type = be32_to_cpu(*((uint32_t *)buffer + 1)); - if (type == 1) { - xdr_init_input(&client->xdr, buffer, rc); - wake_up(&client->reply_wait); - } else if (type == 0) { - if (client->cb_thread == NULL) { - xdr_init_input(&client->cb_xdr, buffer, rc); - xdr_recv_req(&client->cb_xdr, &req); - - if ((req.rpc_vers == 2) && - (req.prog == (client->prog | 0x01000000))) { - if (client->version == 2) - client->cb_func2(client, &req, - &client->cb_xdr); - else - client->cb_func(client, - client->cb_xdr.in_buf, rc); - } - xdr_clean_input(&client->cb_xdr); - } else { - cb_item = kmalloc(sizeof(*cb_item), GFP_KERNEL); - if (!cb_item) { - pr_err("%s: no memory for cb item\n", - __func__); - continue; - } - - INIT_LIST_HEAD(&cb_item->list); - cb_item->buf = buffer; - cb_item->size = rc; - mutex_lock(&client->cb_item_list_lock); - list_add_tail(&cb_item->list, - &client->cb_item_list); - mutex_unlock(&client->cb_item_list_lock); - client->cb_avail = 1; - wake_up(&client->cb_wait); - } - } - } - complete_and_exit(&client->complete, 0); -} - -static struct msm_rpc_client *msm_rpc_create_client(void) -{ - struct msm_rpc_client *client; - void *buf; - - client = kmalloc(sizeof(struct msm_rpc_client), GFP_KERNEL); - if (!client) - return ERR_PTR(-ENOMEM); - - xdr_init(&client->xdr); - xdr_init(&client->cb_xdr); - - buf = kmalloc(MSM_RPC_MSGSIZE_MAX, GFP_KERNEL); - if (!buf) { - kfree(client); - return ERR_PTR(-ENOMEM); - } - xdr_init_output(&client->xdr, buf, MSM_RPC_MSGSIZE_MAX); - - buf = kmalloc(MSM_RPC_MSGSIZE_MAX, GFP_KERNEL); - if (!buf) { - xdr_clean_output(&client->xdr); - kfree(client); - return ERR_PTR(-ENOMEM); - } - xdr_init_output(&client->cb_xdr, buf, MSM_RPC_MSGSIZE_MAX); - - init_waitqueue_head(&client->reply_wait); - mutex_init(&client->req_lock); - client->buf = NULL; - client->cb_buf = NULL; - client->cb_size = 0; - client->exit_flag = 0; - client->cb_restart_teardown = NULL; - client->cb_restart_setup = NULL; - client->in_reset = 0; - - init_completion(&client->complete); - init_completion(&client->cb_complete); - INIT_LIST_HEAD(&client->cb_item_list); - mutex_init(&client->cb_item_list_lock); - client->cb_avail = 0; - init_waitqueue_head(&client->cb_wait); - INIT_LIST_HEAD(&client->cb_list); - spin_lock_init(&client->cb_list_lock); - atomic_set(&client->next_cb_id, 1); - - return client; -} - -static void msm_rpc_destroy_client(struct msm_rpc_client *client) -{ - xdr_clean_output(&client->xdr); - xdr_clean_output(&client->cb_xdr); - - kfree(client); -} - -void msm_rpc_remove_all_cb_func(struct msm_rpc_client *client) -{ - struct msm_rpc_cb_table_item *cb_item, *tmp_cb_item; - unsigned long flags; - - spin_lock_irqsave(&client->cb_list_lock, flags); - list_for_each_entry_safe(cb_item, tmp_cb_item, - &client->cb_list, list) { - list_del(&cb_item->list); - kfree(cb_item); - } - spin_unlock_irqrestore(&client->cb_list_lock, flags); -} - -static void cb_restart_teardown(void *client_data) -{ - struct msm_rpc_client *client; - - client = (struct msm_rpc_client *)client_data; - if (client) { - client->in_reset = 1; - msm_rpc_remove_all_cb_func(client); - client->xdr.out_index = 0; - - if (client->cb_restart_teardown) - client->cb_restart_teardown(client); - } -} - -static void cb_restart_setup(void *client_data) -{ - struct msm_rpc_client *client; - - client = (struct msm_rpc_client *)client_data; - - if (client) { - client->in_reset = 0; - if (client->cb_restart_setup) - client->cb_restart_setup(client); - } -} - -/* Returns the reset state of the client. - * - * Return Value: - * 0 if client isn't in reset, >0 otherwise. - */ -int msm_rpc_client_in_reset(struct msm_rpc_client *client) -{ - int ret = 1; - - if (client) - ret = client->in_reset; - - return ret; -} -EXPORT_SYMBOL(msm_rpc_client_in_reset); - -/* - * Interface to be used to register the client. - * - * name: string representing the client - * - * prog: program number of the client - * - * ver: version number of the client - * - * create_cb_thread: if set calls the callback function from a seprate thread - * which helps the client requests to be processed without - * getting loaded by callback handling. - * - * cb_func: function to be called if callback request is received. - * unmarshaling should be handled by the user in callback function - * - * Return Value: - * Pointer to initialized client data sturcture - * Or, the error code if registration fails. - * - */ -struct msm_rpc_client *msm_rpc_register_client( - const char *name, - uint32_t prog, uint32_t ver, - uint32_t create_cb_thread, - int (*cb_func)(struct msm_rpc_client *, void *, int)) -{ - struct msm_rpc_client *client; - struct msm_rpc_endpoint *ept; - int rc; - - client = msm_rpc_create_client(); - if (IS_ERR(client)) - return client; - - ept = msm_rpc_connect_compatible(prog, ver, MSM_RPC_UNINTERRUPTIBLE); - if (IS_ERR(ept)) { - msm_rpc_destroy_client(client); - return (struct msm_rpc_client *)ept; - } - - ept->client_data = client; - ept->cb_restart_teardown = cb_restart_teardown; - ept->cb_restart_setup = cb_restart_setup; - - client->prog = prog; - client->ver = ver; - client->ept = client->xdr.ept = client->cb_xdr.ept = ept; - client->cb_func = cb_func; - client->version = 1; - - /* start the read thread */ - client->read_thread = kthread_run(rpc_clients_thread, client, - "k%sclntd", name); - if (IS_ERR(client->read_thread)) { - rc = PTR_ERR(client->read_thread); - msm_rpc_close(client->ept); - msm_rpc_destroy_client(client); - return ERR_PTR(rc); - } - - if (!create_cb_thread || (cb_func == NULL)) { - client->cb_thread = NULL; - return client; - } - - /* start the callback thread */ - client->cb_thread = kthread_run(rpc_clients_cb_thread, client, - "k%sclntcbd", name); - if (IS_ERR(client->cb_thread)) { - rc = PTR_ERR(client->cb_thread); - client->exit_flag = 1; - msm_rpc_read_wakeup(client->ept); - wait_for_completion(&client->complete); - msm_rpc_close(client->ept); - msm_rpc_destroy_client(client); - return ERR_PTR(rc); - } - - return client; -} -EXPORT_SYMBOL(msm_rpc_register_client); - -/* - * Interface to be used to register the client. - * - * name: string representing the client - * - * prog: program number of the client - * - * ver: version number of the client - * - * create_cb_thread: if set calls the callback function from a seprate thread - * which helps the client requests to be processed without - * getting loaded by callback handling. - * - * cb_func: function to be called if callback request is received. - * unmarshaling should be handled by the user in callback function - * - * Return Value: - * Pointer to initialized client data sturcture - * Or, the error code if registration fails. - * - */ -struct msm_rpc_client *msm_rpc_register_client2( - const char *name, - uint32_t prog, uint32_t ver, - uint32_t create_cb_thread, - int (*cb_func)(struct msm_rpc_client *, - struct rpc_request_hdr *req, struct msm_rpc_xdr *)) -{ - struct msm_rpc_client *client; - struct msm_rpc_endpoint *ept; - int rc; - - client = msm_rpc_create_client(); - if (IS_ERR(client)) - return client; - - ept = msm_rpc_connect_compatible(prog, ver, MSM_RPC_UNINTERRUPTIBLE); - if (IS_ERR(ept)) { - msm_rpc_destroy_client(client); - return (struct msm_rpc_client *)ept; - } - - client->prog = prog; - client->ver = ver; - client->ept = client->xdr.ept = client->cb_xdr.ept = ept; - client->cb_func2 = cb_func; - client->version = 2; - - ept->client_data = client; - ept->cb_restart_teardown = cb_restart_teardown; - ept->cb_restart_setup = cb_restart_setup; - - /* start the read thread */ - client->read_thread = kthread_run(rpc_clients_thread, client, - "k%sclntd", name); - if (IS_ERR(client->read_thread)) { - rc = PTR_ERR(client->read_thread); - msm_rpc_close(client->ept); - msm_rpc_destroy_client(client); - return ERR_PTR(rc); - } - - if (!create_cb_thread || (cb_func == NULL)) { - client->cb_thread = NULL; - return client; - } - - /* start the callback thread */ - client->cb_thread = kthread_run(rpc_clients_cb_thread, client, - "k%sclntcbd", name); - if (IS_ERR(client->cb_thread)) { - rc = PTR_ERR(client->cb_thread); - client->exit_flag = 1; - msm_rpc_read_wakeup(client->ept); - wait_for_completion(&client->complete); - msm_rpc_close(client->ept); - msm_rpc_destroy_client(client); - return ERR_PTR(rc); - } - - return client; -} -EXPORT_SYMBOL(msm_rpc_register_client2); - -/* - * Register callbacks for modem state changes. - * - * Teardown is called when the modem is going into reset. - * Setup is called after the modem has come out of reset (but may not - * be available, yet). - * - * client: pointer to client data structure. - * - * Return Value: - * 0 (success) - * 1 (client pointer invalid) - */ -int msm_rpc_register_reset_callbacks( - struct msm_rpc_client *client, - void (*teardown)(struct msm_rpc_client *client), - void (*setup)(struct msm_rpc_client *client) - ) -{ - int rc = 1; - - if (client) { - client->cb_restart_teardown = teardown; - client->cb_restart_setup = setup; - rc = 0; - } - - return rc; -} -EXPORT_SYMBOL(msm_rpc_register_reset_callbacks); - -/* - * Interface to be used to unregister the client - * No client operations should be done once the unregister function - * is called. - * - * client: pointer to client data structure. - * - * Return Value: - * Always returns 0 (success). - */ -int msm_rpc_unregister_client(struct msm_rpc_client *client) -{ - pr_info("%s: stopping client...\n", __func__); - client->exit_flag = 1; - if (client->cb_thread) { - client->cb_avail = 1; - wake_up(&client->cb_wait); - wait_for_completion(&client->cb_complete); - } - - msm_rpc_read_wakeup(client->ept); - wait_for_completion(&client->complete); - - msm_rpc_close(client->ept); - msm_rpc_remove_all_cb_func(client); - xdr_clean_output(&client->xdr); - xdr_clean_output(&client->cb_xdr); - kfree(client); - return 0; -} -EXPORT_SYMBOL(msm_rpc_unregister_client); - -/* - * Interface to be used to send a client request. - * If the request takes any arguments or expects any return, the user - * should handle it in 'arg_func' and 'ret_func' respectively. - * Marshaling and Unmarshaling should be handled by the user in argument - * and return functions. - * - * client: pointer to client data sturcture - * - * proc: procedure being requested - * - * arg_func: argument function pointer. 'buf' is where arguments needs to - * be filled. 'data' is arg_data. - * - * ret_func: return function pointer. 'buf' is where returned data should - * be read from. 'data' is ret_data. - * - * arg_data: passed as an input parameter to argument function. - * - * ret_data: passed as an input parameter to return function. - * - * timeout: timeout for reply wait in jiffies. If negative timeout is - * specified a default timeout of 10s is used. - * - * Return Value: - * 0 on success, otherwise an error code is returned. - */ -int msm_rpc_client_req(struct msm_rpc_client *client, uint32_t proc, - int (*arg_func)(struct msm_rpc_client *client, - void *buf, void *data), - void *arg_data, - int (*ret_func)(struct msm_rpc_client *client, - void *buf, void *data), - void *ret_data, long timeout) -{ - struct rpc_reply_hdr *rpc_rsp; - int rc = 0; - uint32_t req_xid; - - mutex_lock(&client->req_lock); - - msm_rpc_setup_req((struct rpc_request_hdr *)client->xdr.out_buf, - client->prog, client->ver, proc); - client->xdr.out_index = sizeof(struct rpc_request_hdr); - req_xid = *(uint32_t *)client->xdr.out_buf; - if (arg_func) { - rc = arg_func(client, - (void *)((struct rpc_request_hdr *) - client->xdr.out_buf + 1), - arg_data); - if (rc < 0) - goto release_locks; - else - client->xdr.out_index += rc; - } - - rc = msm_rpc_write(client->ept, client->xdr.out_buf, - client->xdr.out_index); - if (rc < 0) { - pr_err("%s: couldn't send RPC request:%d\n", __func__, rc); - goto release_locks; - } else - rc = 0; - - if (timeout < 0) - timeout = msecs_to_jiffies(10000); - - do { - rc = wait_event_timeout(client->reply_wait, - xdr_read_avail(&client->xdr) || client->in_reset, - timeout); - - if (client->in_reset) { - rc = -ENETRESET; - goto release_locks; - } - - if (rc == 0) { - pr_err("%s: request timeout\n", __func__); - rc = -ETIMEDOUT; - goto release_locks; - } - - rpc_rsp = (struct rpc_reply_hdr *)client->xdr.in_buf; - if (req_xid != rpc_rsp->xid) { - pr_info("%s: xid mismatch, req %d reply %d\n", - __func__, be32_to_cpu(req_xid), - be32_to_cpu(rpc_rsp->xid)); - timeout = rc; - xdr_clean_input(&client->xdr); - } else - rc = 0; - } while (rc); - - if (be32_to_cpu(rpc_rsp->reply_stat) != RPCMSG_REPLYSTAT_ACCEPTED) { - pr_err("%s: RPC call was denied! %d\n", __func__, - be32_to_cpu(rpc_rsp->reply_stat)); - rc = -EPERM; - goto free_and_release; - } - - if (be32_to_cpu(rpc_rsp->data.acc_hdr.accept_stat) != - RPC_ACCEPTSTAT_SUCCESS) { - pr_err("%s: RPC call was not successful (%d)\n", __func__, - be32_to_cpu(rpc_rsp->data.acc_hdr.accept_stat)); - rc = -EINVAL; - goto free_and_release; - } - - if (ret_func) - rc = ret_func(client, (void *)(rpc_rsp + 1), ret_data); - - free_and_release: - xdr_clean_input(&client->xdr); - client->xdr.out_index = 0; - release_locks: - mutex_unlock(&client->req_lock); - return rc; -} -EXPORT_SYMBOL(msm_rpc_client_req); - -/* - * Interface to be used to send a client request. - * If the request takes any arguments or expects any return, the user - * should handle it in 'arg_func' and 'ret_func' respectively. - * Marshaling and Unmarshaling should be handled by the user in argument - * and return functions. - * - * client: pointer to client data sturcture - * - * proc: procedure being requested - * - * arg_func: argument function pointer. 'xdr' is the xdr being used. - * 'data' is arg_data. - * - * ret_func: return function pointer. 'xdr' is the xdr being used. - * 'data' is ret_data. - * - * arg_data: passed as an input parameter to argument function. - * - * ret_data: passed as an input parameter to return function. - * - * timeout: timeout for reply wait in jiffies. If negative timeout is - * specified a default timeout of 10s is used. - * - * Return Value: - * 0 on success, otherwise an error code is returned. - */ -int msm_rpc_client_req2(struct msm_rpc_client *client, uint32_t proc, - int (*arg_func)(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data), - void *arg_data, - int (*ret_func)(struct msm_rpc_client *client, - struct msm_rpc_xdr *xdr, void *data), - void *ret_data, long timeout) -{ - struct rpc_reply_hdr rpc_rsp; - int rc = 0; - uint32_t req_xid; - - mutex_lock(&client->req_lock); - - if (client->in_reset) { - rc = -ENETRESET; - goto release_locks; - } - - xdr_start_request(&client->xdr, client->prog, client->ver, proc); - req_xid = be32_to_cpu(*(uint32_t *)client->xdr.out_buf); - if (arg_func) { - rc = arg_func(client, &client->xdr, arg_data); - if (rc < 0) { - mutex_unlock(&client->xdr.out_lock); - goto release_locks; - } - } - - rc = xdr_send_msg(&client->xdr); - if (rc < 0) { - pr_err("%s: couldn't send RPC request:%d\n", __func__, rc); - goto release_locks; - } else - rc = 0; - - if (timeout < 0) - timeout = msecs_to_jiffies(10000); - - do { - rc = wait_event_timeout(client->reply_wait, - xdr_read_avail(&client->xdr) || client->in_reset, - timeout); - - if (client->in_reset) { - rc = -ENETRESET; - goto release_locks; - } - - if (rc == 0) { - pr_err("%s: request timeout\n", __func__); - rc = -ETIMEDOUT; - goto release_locks; - } - - xdr_recv_reply(&client->xdr, &rpc_rsp); - /* TODO: may be this check should be a xdr function */ - if (req_xid != rpc_rsp.xid) { - pr_info("%s: xid mismatch, req %d reply %d\n", - __func__, req_xid, rpc_rsp.xid); - timeout = rc; - xdr_clean_input(&client->xdr); - } else - rc = 0; - } while (rc); - - if (rpc_rsp.reply_stat != RPCMSG_REPLYSTAT_ACCEPTED) { - pr_err("%s: RPC call was denied! %d\n", - __func__, rpc_rsp.reply_stat); - rc = -EPERM; - goto free_and_release; - } - - if (rpc_rsp.data.acc_hdr.accept_stat != RPC_ACCEPTSTAT_SUCCESS) { - pr_err("%s: RPC call was not successful (%d)\n", __func__, - rpc_rsp.data.acc_hdr.accept_stat); - rc = -EINVAL; - goto free_and_release; - } - - if (ret_func) - rc = ret_func(client, &client->xdr, ret_data); - - free_and_release: - xdr_clean_input(&client->xdr); - /* TODO: put it in xdr_reset_output */ - client->xdr.out_index = 0; - release_locks: - mutex_unlock(&client->req_lock); - return rc; -} -EXPORT_SYMBOL(msm_rpc_client_req2); - -/* - * Interface to be used to start accepted reply message required in - * callback handling. Returns the buffer pointer to attach any - * payload. Should call msm_rpc_send_accepted_reply to complete - * sending reply. Marshaling should be handled by user for the payload. - * - * client: pointer to client data structure - * - * xid: transaction id. Has to be same as the one in callback request. - * - * accept_status: acceptance status - * - * Return Value: - * pointer to buffer to attach the payload. - */ -void *msm_rpc_start_accepted_reply(struct msm_rpc_client *client, - uint32_t xid, uint32_t accept_status) -{ - struct rpc_reply_hdr *reply; - - mutex_lock(&client->cb_xdr.out_lock); - - reply = (struct rpc_reply_hdr *)client->cb_xdr.out_buf; - - reply->xid = cpu_to_be32(xid); - reply->type = cpu_to_be32(1); /* reply */ - reply->reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED); - - reply->data.acc_hdr.accept_stat = cpu_to_be32(accept_status); - reply->data.acc_hdr.verf_flavor = 0; - reply->data.acc_hdr.verf_length = 0; - - client->cb_xdr.out_index = sizeof(*reply); - return reply + 1; -} -EXPORT_SYMBOL(msm_rpc_start_accepted_reply); - -/* - * Interface to be used to send accepted reply required in callback handling. - * msm_rpc_start_accepted_reply should have been called before. - * Marshaling should be handled by user for the payload. - * - * client: pointer to client data structure - * - * size: additional payload size - * - * Return Value: - * 0 on success, otherwise returns an error code. - */ -int msm_rpc_send_accepted_reply(struct msm_rpc_client *client, uint32_t size) -{ - int rc = 0; - - client->cb_xdr.out_index += size; - rc = msm_rpc_write(client->ept, client->cb_xdr.out_buf, - client->cb_xdr.out_index); - if (rc > 0) - rc = 0; - - mutex_unlock(&client->cb_xdr.out_lock); - return rc; -} -EXPORT_SYMBOL(msm_rpc_send_accepted_reply); - -/* - * Interface to be used to add a callback function. - * If the call back function is already in client's 'cb_id - cb_func' - * table, then that cb_id is returned. otherwise, new entry - * is added to the above table and corresponding cb_id is returned. - * - * client: pointer to client data structure - * - * cb_func: callback function - * - * Return Value: - * callback ID on success, otherwise returns an error code. - * If cb_func is NULL, the callback Id returned is 0xffffffff. - * This tells the other processor that no callback is reqested. - */ -int msm_rpc_add_cb_func(struct msm_rpc_client *client, void *cb_func) -{ - struct msm_rpc_cb_table_item *cb_item; - unsigned long flags; - - if (cb_func == NULL) - return MSM_RPC_CLIENT_NULL_CB_ID; - - spin_lock_irqsave(&client->cb_list_lock, flags); - list_for_each_entry(cb_item, &client->cb_list, list) { - if (cb_item->cb_func == cb_func) { - spin_unlock_irqrestore(&client->cb_list_lock, flags); - return cb_item->cb_id; - } - } - spin_unlock_irqrestore(&client->cb_list_lock, flags); - - cb_item = kmalloc(sizeof(struct msm_rpc_cb_table_item), GFP_KERNEL); - if (!cb_item) - return -ENOMEM; - - INIT_LIST_HEAD(&cb_item->list); - cb_item->cb_id = atomic_add_return(1, &client->next_cb_id); - cb_item->cb_func = cb_func; - - spin_lock_irqsave(&client->cb_list_lock, flags); - list_add_tail(&cb_item->list, &client->cb_list); - spin_unlock_irqrestore(&client->cb_list_lock, flags); - - return cb_item->cb_id; -} -EXPORT_SYMBOL(msm_rpc_add_cb_func); - -/* - * Interface to be used to get a callback function from a callback ID. - * If no entry is found, NULL is returned. - * - * client: pointer to client data structure - * - * cb_id: callback ID - * - * Return Value: - * callback function pointer if entry with given cb_id is found, - * otherwise returns NULL. - */ -void *msm_rpc_get_cb_func(struct msm_rpc_client *client, uint32_t cb_id) -{ - struct msm_rpc_cb_table_item *cb_item; - unsigned long flags; - - spin_lock_irqsave(&client->cb_list_lock, flags); - list_for_each_entry(cb_item, &client->cb_list, list) { - if (cb_item->cb_id == cb_id) { - spin_unlock_irqrestore(&client->cb_list_lock, flags); - return cb_item->cb_func; - } - } - spin_unlock_irqrestore(&client->cb_list_lock, flags); - return NULL; -} -EXPORT_SYMBOL(msm_rpc_get_cb_func); - -/* - * Interface to be used to remove a callback function. - * - * client: pointer to client data structure - * - * cb_func: callback function - * - */ -void msm_rpc_remove_cb_func(struct msm_rpc_client *client, void *cb_func) -{ - struct msm_rpc_cb_table_item *cb_item, *tmp_cb_item; - unsigned long flags; - - if (cb_func == NULL) - return; - - spin_lock_irqsave(&client->cb_list_lock, flags); - list_for_each_entry_safe(cb_item, tmp_cb_item, - &client->cb_list, list) { - if (cb_item->cb_func == cb_func) { - list_del(&cb_item->list); - kfree(cb_item); - spin_unlock_irqrestore(&client->cb_list_lock, flags); - return; - } - } - spin_unlock_irqrestore(&client->cb_list_lock, flags); -} -EXPORT_SYMBOL(msm_rpc_remove_cb_func); diff --git a/arch/arm/mach-msm/smd_rpcrouter_device.c b/arch/arm/mach-msm/smd_rpcrouter_device.c deleted file mode 100644 index 052537944eea8bc7973a76284cfebb031ea2a6f0..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/smd_rpcrouter_device.c +++ /dev/null @@ -1,476 +0,0 @@ -/* arch/arm/mach-msm/smd_rpcrouter_device.c - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2007-2012, The Linux Foundation. All rights reserved. - * Author: San Mehat - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include "smd_rpcrouter.h" - -/* Support 64KB of data plus some space for headers */ -#define SAFETY_MEM_SIZE (65536 + sizeof(struct rpc_request_hdr)) - -/* modem load timeout */ -#define MODEM_LOAD_TIMEOUT (10 * HZ) - -/* Next minor # available for a remote server */ -static int next_minor = 1; -static DEFINE_SPINLOCK(server_cdev_lock); - -struct class *msm_rpcrouter_class; -dev_t msm_rpcrouter_devno; - -static struct cdev rpcrouter_cdev; -static struct device *rpcrouter_device; - -struct rpcrouter_file_info { - struct msm_rpc_endpoint *ept; - void *modem_pil; -}; - -static void msm_rpcrouter_unload_modem(void *pil) -{ - if (pil) - subsystem_put(pil); -} - -static void *msm_rpcrouter_load_modem(void) -{ - void *pil; - int rc; - - pil = subsystem_get("modem"); - if (IS_ERR(pil)) - pr_err("%s: modem load failed\n", __func__); - else { - rc = wait_for_completion_interruptible_timeout( - &rpc_remote_router_up, - MODEM_LOAD_TIMEOUT); - if (!rc) - rc = -ETIMEDOUT; - if (rc < 0) { - pr_err("%s: wait for remote router failed %d\n", - __func__, rc); - msm_rpcrouter_unload_modem(pil); - pil = ERR_PTR(rc); - } - } - - return pil; -} - -static int rpcrouter_open(struct inode *inode, struct file *filp) -{ - int rc; - void *pil; - struct msm_rpc_endpoint *ept; - struct rpcrouter_file_info *file_info; - - rc = nonseekable_open(inode, filp); - if (rc < 0) - return rc; - - file_info = kzalloc(sizeof(*file_info), GFP_KERNEL); - if (!file_info) - return -ENOMEM; - - ept = msm_rpcrouter_create_local_endpoint(inode->i_rdev); - if (!ept) { - kfree(file_info); - return -ENOMEM; - } - file_info->ept = ept; - - /* if router device, load the modem */ - if (inode->i_rdev == msm_rpcrouter_devno) { - pil = msm_rpcrouter_load_modem(); - if (IS_ERR(pil)) { - kfree(file_info); - msm_rpcrouter_destroy_local_endpoint(ept); - return PTR_ERR(pil); - } - file_info->modem_pil = pil; - } - - filp->private_data = file_info; - return 0; -} - -static int rpcrouter_release(struct inode *inode, struct file *filp) -{ - struct rpcrouter_file_info *file_info = filp->private_data; - struct msm_rpc_endpoint *ept; - static unsigned int rpcrouter_release_cnt; - - ept = (struct msm_rpc_endpoint *) file_info->ept; - - /* A user program with many files open when ends abruptly, - * will cause a flood of REMOVE_CLIENT messages to the - * remote processor. This will cause remote processors - * internal queue to overflow. Inserting a sleep here - * regularly is the effecient option. - */ - if (rpcrouter_release_cnt++ % 2) - msleep(1); - - /* if router device, unload the modem */ - if (inode->i_rdev == msm_rpcrouter_devno) - msm_rpcrouter_unload_modem(file_info->modem_pil); - - kfree(file_info); - return msm_rpcrouter_destroy_local_endpoint(ept); -} - -static ssize_t rpcrouter_read(struct file *filp, char __user *buf, - size_t count, loff_t *ppos) -{ - struct rpcrouter_file_info *file_info = filp->private_data; - struct msm_rpc_endpoint *ept; - struct rr_fragment *frag, *next; - int rc; - - ept = (struct msm_rpc_endpoint *) file_info->ept; - - rc = __msm_rpc_read(ept, &frag, count, -1); - if (rc < 0) - return rc; - - count = rc; - - while (frag != NULL) { - if (copy_to_user(buf, frag->data, frag->length)) { - printk(KERN_ERR - "rpcrouter: could not copy all read data to user!\n"); - rc = -EFAULT; - } - buf += frag->length; - next = frag->next; - kfree(frag); - frag = next; - } - - return rc; -} - -static ssize_t rpcrouter_write(struct file *filp, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct rpcrouter_file_info *file_info = filp->private_data; - struct msm_rpc_endpoint *ept; - int rc = 0; - void *k_buffer; - - ept = (struct msm_rpc_endpoint *) file_info->ept; - - /* A check for safety, this seems non-standard */ - if (count > SAFETY_MEM_SIZE) - return -EINVAL; - - k_buffer = kmalloc(count, GFP_KERNEL); - if (!k_buffer) - return -ENOMEM; - - if (copy_from_user(k_buffer, buf, count)) { - rc = -EFAULT; - goto write_out_free; - } - - rc = msm_rpc_write(ept, k_buffer, count); - if (rc < 0) - goto write_out_free; - - rc = count; -write_out_free: - kfree(k_buffer); - return rc; -} - -/* RPC VFS Poll Implementation - * - * POLLRDHUP - restart in progress - * POLLOUT - writes accepted (without blocking) - * POLLIN - data ready to read - * - * The restart state consists of several different phases including a client - * notification and a server restart. If the server has been restarted, then - * reads and writes can be performed and the POLLOUT bit will be set. If a - * restart is in progress, but the server hasn't been restarted, then only the - * POLLRDHUP is active and reads and writes will block. See the table - * below for a summary. POLLRDHUP is cleared once a call to msm_rpc_write_pkt - * or msm_rpc_read_pkt returns ENETRESET. - * - * POLLOUT POLLRDHUP - * 1 0 Normal operation - * 0 1 Restart in progress and server hasn't restarted yet - * 1 1 Server has been restarted, but client has - * not been notified of a restart by a return code - * of ENETRESET from msm_rpc_write_pkt or - * msm_rpc_read_pkt. - */ -static unsigned int rpcrouter_poll(struct file *filp, - struct poll_table_struct *wait) -{ - struct rpcrouter_file_info *file_info = filp->private_data; - struct msm_rpc_endpoint *ept; - unsigned mask = 0; - - ept = (struct msm_rpc_endpoint *) file_info->ept; - - poll_wait(filp, &ept->wait_q, wait); - poll_wait(filp, &ept->restart_wait, wait); - - if (!list_empty(&ept->read_q)) - mask |= POLLIN; - if (!(ept->restart_state & RESTART_PEND_SVR)) - mask |= POLLOUT; - if (ept->restart_state != 0) - mask |= POLLRDHUP; - - return mask; -} - -static long rpcrouter_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - struct rpcrouter_file_info *file_info = filp->private_data; - struct msm_rpc_endpoint *ept; - struct rpcrouter_ioctl_server_args server_args; - int rc = 0; - uint32_t n; - - ept = (struct msm_rpc_endpoint *) file_info->ept; - switch (cmd) { - - case RPC_ROUTER_IOCTL_GET_VERSION: - n = RPC_ROUTER_VERSION_V1; - rc = put_user(n, (unsigned int *) arg); - break; - - case RPC_ROUTER_IOCTL_GET_MTU: - /* the pacmark word reduces the actual payload - * possible per message - */ - n = RPCROUTER_MSGSIZE_MAX - sizeof(uint32_t); - rc = put_user(n, (unsigned int *) arg); - break; - - case RPC_ROUTER_IOCTL_REGISTER_SERVER: - rc = copy_from_user(&server_args, (void *) arg, - sizeof(server_args)); - if (rc < 0) - break; - msm_rpc_register_server(ept, - server_args.prog, - server_args.vers); - break; - - case RPC_ROUTER_IOCTL_UNREGISTER_SERVER: - rc = copy_from_user(&server_args, (void *) arg, - sizeof(server_args)); - if (rc < 0) - break; - - msm_rpc_unregister_server(ept, - server_args.prog, - server_args.vers); - break; - - case RPC_ROUTER_IOCTL_CLEAR_NETRESET: - msm_rpc_clear_netreset(ept); - break; - - case RPC_ROUTER_IOCTL_GET_CURR_PKT_SIZE: - rc = msm_rpc_get_curr_pkt_size(ept); - break; - - default: - rc = -EINVAL; - break; - } - - return rc; -} - -static struct file_operations rpcrouter_server_fops = { - .owner = THIS_MODULE, - .open = rpcrouter_open, - .release = rpcrouter_release, - .read = rpcrouter_read, - .write = rpcrouter_write, - .poll = rpcrouter_poll, - .unlocked_ioctl = rpcrouter_ioctl, -}; - -static struct file_operations rpcrouter_router_fops = { - .owner = THIS_MODULE, - .open = rpcrouter_open, - .release = rpcrouter_release, - .read = rpcrouter_read, - .write = rpcrouter_write, - .poll = rpcrouter_poll, - .unlocked_ioctl = rpcrouter_ioctl, -}; - -int msm_rpcrouter_create_server_cdev(struct rr_server *server) -{ - int rc; - uint32_t dev_vers; - unsigned long flags; - - spin_lock_irqsave(&server_cdev_lock, flags); - if (next_minor == RPCROUTER_MAX_REMOTE_SERVERS) { - spin_unlock_irqrestore(&server_cdev_lock, flags); - printk(KERN_ERR - "rpcrouter: Minor numbers exhausted - Increase " - "RPCROUTER_MAX_REMOTE_SERVERS\n"); - return -ENOBUFS; - } - - /* Servers with bit 31 set are remote msm servers with hashkey version. - * Servers with bit 31 not set are remote msm servers with - * backwards compatible version type in which case the minor number - * (lower 16 bits) is set to zero. - * - */ - if ((server->vers & 0x80000000)) - dev_vers = server->vers; - else - dev_vers = server->vers & 0xffff0000; - - server->device_number = - MKDEV(MAJOR(msm_rpcrouter_devno), next_minor++); - spin_unlock_irqrestore(&server_cdev_lock, flags); - - server->device = - device_create(msm_rpcrouter_class, rpcrouter_device, - server->device_number, NULL, "%.8x:%.8x", - server->prog, dev_vers); - if (IS_ERR(server->device)) { - printk(KERN_ERR - "rpcrouter: Unable to create device (%ld)\n", - PTR_ERR(server->device)); - return PTR_ERR(server->device);; - } - - cdev_init(&server->cdev, &rpcrouter_server_fops); - server->cdev.owner = THIS_MODULE; - - rc = cdev_add(&server->cdev, server->device_number, 1); - if (rc < 0) { - printk(KERN_ERR - "rpcrouter: Unable to add chrdev (%d)\n", rc); - device_destroy(msm_rpcrouter_class, server->device_number); - return rc; - } - return 0; -} - -/* for backward compatible version type (31st bit cleared) - * clearing minor number (lower 16 bits) in device name - * is neccessary for driver binding - */ -int msm_rpcrouter_create_server_pdev(struct rr_server *server) -{ - server->p_device.base.id = (server->vers & RPC_VERSION_MODE_MASK) ? - server->vers : - (server->vers & RPC_VERSION_MAJOR_MASK); - server->p_device.base.name = server->pdev_name; - - server->p_device.prog = server->prog; - server->p_device.vers = server->vers; - - platform_device_register(&server->p_device.base); - return 0; -} - -int msm_rpcrouter_init_devices(void) -{ - int rc; - int major; - - /* Create the device nodes */ - msm_rpcrouter_class = class_create(THIS_MODULE, "oncrpc"); - if (IS_ERR(msm_rpcrouter_class)) { - rc = -ENOMEM; - printk(KERN_ERR - "rpcrouter: failed to create oncrpc class\n"); - goto fail; - } - - rc = alloc_chrdev_region(&msm_rpcrouter_devno, 0, - RPCROUTER_MAX_REMOTE_SERVERS + 1, - "oncrpc"); - if (rc < 0) { - printk(KERN_ERR - "rpcrouter: Failed to alloc chardev region (%d)\n", rc); - goto fail_destroy_class; - } - - major = MAJOR(msm_rpcrouter_devno); - rpcrouter_device = device_create(msm_rpcrouter_class, NULL, - msm_rpcrouter_devno, NULL, "%.8x:%d", - 0, 0); - if (IS_ERR(rpcrouter_device)) { - rc = -ENOMEM; - goto fail_unregister_cdev_region; - } - - cdev_init(&rpcrouter_cdev, &rpcrouter_router_fops); - rpcrouter_cdev.owner = THIS_MODULE; - - rc = cdev_add(&rpcrouter_cdev, msm_rpcrouter_devno, 1); - if (rc < 0) - goto fail_destroy_device; - - return 0; - -fail_destroy_device: - device_destroy(msm_rpcrouter_class, msm_rpcrouter_devno); -fail_unregister_cdev_region: - unregister_chrdev_region(msm_rpcrouter_devno, - RPCROUTER_MAX_REMOTE_SERVERS + 1); -fail_destroy_class: - class_destroy(msm_rpcrouter_class); -fail: - return rc; -} - -void msm_rpcrouter_exit_devices(void) -{ - cdev_del(&rpcrouter_cdev); - device_destroy(msm_rpcrouter_class, msm_rpcrouter_devno); - unregister_chrdev_region(msm_rpcrouter_devno, - RPCROUTER_MAX_REMOTE_SERVERS + 1); - class_destroy(msm_rpcrouter_class); -} - diff --git a/arch/arm/mach-msm/smd_rpcrouter_servers.c b/arch/arm/mach-msm/smd_rpcrouter_servers.c deleted file mode 100644 index 478eb1fabd95c043ac33f6c2cd0819d71dc4d883..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/smd_rpcrouter_servers.c +++ /dev/null @@ -1,618 +0,0 @@ -/* arch/arm/mach-msm/rpc_servers.c - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2009-2010, The Linux Foundation. All rights reserved. - * Author: Iliyan Malchev - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include "smd_rpcrouter.h" - -static struct msm_rpc_endpoint *endpoint; - -#define FLAG_REGISTERED 0x0001 - -static LIST_HEAD(rpc_server_list); -static DEFINE_MUTEX(rpc_server_list_lock); -static int rpc_servers_active; -static struct wake_lock rpc_servers_wake_lock; -static struct msm_rpc_xdr server_xdr; -static uint32_t current_xid; - -static void rpc_server_register(struct msm_rpc_server *server) -{ - int rc; - rc = msm_rpc_register_server(endpoint, server->prog, server->vers); - if (rc < 0) - printk(KERN_ERR "[rpcserver] error registering %p @ %08x:%d\n", - server, server->prog, server->vers); -} - -static struct msm_rpc_server *rpc_server_find(uint32_t prog, uint32_t vers) -{ - struct msm_rpc_server *server; - - mutex_lock(&rpc_server_list_lock); - list_for_each_entry(server, &rpc_server_list, list) { - if ((server->prog == prog) && - msm_rpc_is_compatible_version(server->vers, vers)) { - mutex_unlock(&rpc_server_list_lock); - return server; - } - } - mutex_unlock(&rpc_server_list_lock); - return NULL; -} - -static void rpc_server_register_all(void) -{ - struct msm_rpc_server *server; - - mutex_lock(&rpc_server_list_lock); - list_for_each_entry(server, &rpc_server_list, list) { - if (!(server->flags & FLAG_REGISTERED)) { - rpc_server_register(server); - server->flags |= FLAG_REGISTERED; - } - } - mutex_unlock(&rpc_server_list_lock); -} - -int msm_rpc_create_server(struct msm_rpc_server *server) -{ - void *buf; - - /* make sure we're in a sane state first */ - server->flags = 0; - INIT_LIST_HEAD(&server->list); - mutex_init(&server->cb_req_lock); - - server->version = 1; - - xdr_init(&server->cb_xdr); - buf = kmalloc(MSM_RPC_MSGSIZE_MAX, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - xdr_init_output(&server->cb_xdr, buf, MSM_RPC_MSGSIZE_MAX); - - server->cb_ept = server->cb_xdr.ept = msm_rpc_open(); - if (IS_ERR(server->cb_ept)) { - xdr_clean_output(&server->cb_xdr); - return PTR_ERR(server->cb_ept); - } - - server->cb_ept->flags = MSM_RPC_UNINTERRUPTIBLE; - server->cb_ept->dst_prog = cpu_to_be32(server->prog | 0x01000000); - server->cb_ept->dst_vers = cpu_to_be32(server->vers); - - mutex_lock(&rpc_server_list_lock); - list_add(&server->list, &rpc_server_list); - if (rpc_servers_active) { - rpc_server_register(server); - server->flags |= FLAG_REGISTERED; - } - mutex_unlock(&rpc_server_list_lock); - - return 0; -} -EXPORT_SYMBOL(msm_rpc_create_server); - -int msm_rpc_create_server2(struct msm_rpc_server *server) -{ - int rc; - - rc = msm_rpc_create_server(server); - server->version = 2; - - return rc; -} -EXPORT_SYMBOL(msm_rpc_create_server2); - -static int rpc_send_accepted_void_reply(struct msm_rpc_endpoint *client, - uint32_t xid, uint32_t accept_status) -{ - int rc = 0; - uint8_t reply_buf[sizeof(struct rpc_reply_hdr)]; - struct rpc_reply_hdr *reply = (struct rpc_reply_hdr *)reply_buf; - - reply->xid = cpu_to_be32(xid); - reply->type = cpu_to_be32(1); /* reply */ - reply->reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED); - - reply->data.acc_hdr.accept_stat = cpu_to_be32(accept_status); - reply->data.acc_hdr.verf_flavor = 0; - reply->data.acc_hdr.verf_length = 0; - - rc = msm_rpc_write(client, reply_buf, sizeof(reply_buf)); - if (rc == -ENETRESET) { - /* Modem restarted, drop reply, clear state */ - msm_rpc_clear_netreset(client); - } - if (rc < 0) - printk(KERN_ERR - "%s: could not write response: %d\n", - __FUNCTION__, rc); - - return rc; -} - -/* - * Interface to be used to start accepted reply message for a - * request. Returns the buffer pointer to attach any payload. - * Should call msm_rpc_server_send_accepted_reply to complete sending - * reply. Marshaling should be handled by user for the payload. - * - * server: pointer to server data structure - * - * xid: transaction id. Has to be same as the one in request. - * - * accept_status: acceptance status - * - * Return Value: - * pointer to buffer to attach the payload. - */ -void *msm_rpc_server_start_accepted_reply(struct msm_rpc_server *server, - uint32_t xid, uint32_t accept_status) -{ - struct rpc_reply_hdr *reply; - - mutex_lock(&server_xdr.out_lock); - - reply = (struct rpc_reply_hdr *)server_xdr.out_buf; - - reply->xid = cpu_to_be32(xid); - reply->type = cpu_to_be32(1); /* reply */ - reply->reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED); - - reply->data.acc_hdr.accept_stat = cpu_to_be32(accept_status); - reply->data.acc_hdr.verf_flavor = 0; - reply->data.acc_hdr.verf_length = 0; - - server_xdr.out_index += sizeof(*reply); - - return reply + 1; -} -EXPORT_SYMBOL(msm_rpc_server_start_accepted_reply); - -/* - * Interface to be used to send accepted reply for a request. - * msm_rpc_server_start_accepted_reply should have been called before. - * Marshaling should be handled by user for the payload. - * - * server: pointer to server data structure - * - * size: additional payload size - * - * Return Value: - * 0 on success, otherwise returns an error code. - */ -int msm_rpc_server_send_accepted_reply(struct msm_rpc_server *server, - uint32_t size) -{ - int rc = 0; - - server_xdr.out_index += size; - rc = msm_rpc_write(endpoint, server_xdr.out_buf, - server_xdr.out_index); - if (rc > 0) - rc = 0; - - mutex_unlock(&server_xdr.out_lock); - return rc; -} -EXPORT_SYMBOL(msm_rpc_server_send_accepted_reply); - -/* - * Interface to be used to send a server callback request. - * If the request takes any arguments or expects any return, the user - * should handle it in 'arg_func' and 'ret_func' respectively. - * Marshaling and Unmarshaling should be handled by the user in argument - * and return functions. - * - * server: pointer to server data sturcture - * - * clnt_info: pointer to client information data structure. - * callback will be sent to this client. - * - * cb_proc: callback procedure being requested - * - * arg_func: argument function pointer. 'buf' is where arguments needs to - * be filled. 'data' is arg_data. - * - * ret_func: return function pointer. 'buf' is where returned data should - * be read from. 'data' is ret_data. - * - * arg_data: passed as an input parameter to argument function. - * - * ret_data: passed as an input parameter to return function. - * - * timeout: timeout for reply wait in jiffies. If negative timeout is - * specified a default timeout of 10s is used. - * - * Return Value: - * 0 on success, otherwise an error code is returned. - */ -int msm_rpc_server_cb_req(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - uint32_t cb_proc, - int (*arg_func)(struct msm_rpc_server *server, - void *buf, void *data), - void *arg_data, - int (*ret_func)(struct msm_rpc_server *server, - void *buf, void *data), - void *ret_data, long timeout) -{ - struct rpc_reply_hdr *rpc_rsp; - void *buffer; - int rc = 0; - uint32_t req_xid; - - if (!clnt_info) - return -EINVAL; - - mutex_lock(&server->cb_req_lock); - - msm_rpc_setup_req((struct rpc_request_hdr *)server->cb_xdr.out_buf, - (server->prog | 0x01000000), - be32_to_cpu(clnt_info->vers), cb_proc); - server->cb_xdr.out_index = sizeof(struct rpc_request_hdr); - req_xid = *(uint32_t *)server->cb_xdr.out_buf; - - if (arg_func) { - rc = arg_func(server, (void *)((struct rpc_request_hdr *) - server->cb_xdr.out_buf + 1), - arg_data); - if (rc < 0) - goto release_locks; - else - server->cb_xdr.out_index += rc; - } - - server->cb_ept->dst_pid = clnt_info->pid; - server->cb_ept->dst_cid = clnt_info->cid; - rc = msm_rpc_write(server->cb_ept, server->cb_xdr.out_buf, - server->cb_xdr.out_index); - if (rc < 0) { - pr_err("%s: couldn't send RPC CB request:%d\n", __func__, rc); - goto release_locks; - } else - rc = 0; - - if (timeout < 0) - timeout = msecs_to_jiffies(10000); - - do { - buffer = NULL; - rc = msm_rpc_read(server->cb_ept, &buffer, -1, timeout); - xdr_init_input(&server->cb_xdr, buffer, rc); - if ((rc < ((int)(sizeof(uint32_t) * 2))) || - (be32_to_cpu(*((uint32_t *)buffer + 1)) != 1)) { - printk(KERN_ERR "%s: Invalid reply: %d\n", - __func__, rc); - goto free_and_release; - } - - rpc_rsp = (struct rpc_reply_hdr *)server->cb_xdr.in_buf; - if (req_xid != rpc_rsp->xid) { - pr_info("%s: xid mismatch, req %d reply %d\n", - __func__, be32_to_cpu(req_xid), - be32_to_cpu(rpc_rsp->xid)); - xdr_clean_input(&server->cb_xdr); - rc = timeout; - /* timeout is not adjusted, but it is not critical */ - } else - rc = 0; - } while (rc); - - if (be32_to_cpu(rpc_rsp->reply_stat) != RPCMSG_REPLYSTAT_ACCEPTED) { - pr_err("%s: RPC cb req was denied! %d\n", __func__, - be32_to_cpu(rpc_rsp->reply_stat)); - rc = -EPERM; - goto free_and_release; - } - - if (be32_to_cpu(rpc_rsp->data.acc_hdr.accept_stat) != - RPC_ACCEPTSTAT_SUCCESS) { - pr_err("%s: RPC cb req was not successful (%d)\n", __func__, - be32_to_cpu(rpc_rsp->data.acc_hdr.accept_stat)); - rc = -EINVAL; - goto free_and_release; - } - - if (ret_func) - rc = ret_func(server, (void *)(rpc_rsp + 1), ret_data); - -free_and_release: - xdr_clean_input(&server->cb_xdr); - server->cb_xdr.out_index = 0; -release_locks: - mutex_unlock(&server->cb_req_lock); - return rc; -} -EXPORT_SYMBOL(msm_rpc_server_cb_req); - -/* - * Interface to be used to send a server callback request. - * If the request takes any arguments or expects any return, the user - * should handle it in 'arg_func' and 'ret_func' respectively. - * Marshaling and Unmarshaling should be handled by the user in argument - * and return functions. - * - * server: pointer to server data sturcture - * - * clnt_info: pointer to client information data structure. - * callback will be sent to this client. - * - * cb_proc: callback procedure being requested - * - * arg_func: argument function pointer. 'xdr' is the xdr being used. - * 'data' is arg_data. - * - * ret_func: return function pointer. 'xdr' is the xdr being used. - * 'data' is ret_data. - * - * arg_data: passed as an input parameter to argument function. - * - * ret_data: passed as an input parameter to return function. - * - * timeout: timeout for reply wait in jiffies. If negative timeout is - * specified a default timeout of 10s is used. - * - * Return Value: - * 0 on success, otherwise an error code is returned. - */ -int msm_rpc_server_cb_req2(struct msm_rpc_server *server, - struct msm_rpc_client_info *clnt_info, - uint32_t cb_proc, - int (*arg_func)(struct msm_rpc_server *server, - struct msm_rpc_xdr *xdr, void *data), - void *arg_data, - int (*ret_func)(struct msm_rpc_server *server, - struct msm_rpc_xdr *xdr, void *data), - void *ret_data, long timeout) -{ - int size = 0; - struct rpc_reply_hdr rpc_rsp; - void *buffer; - int rc = 0; - uint32_t req_xid; - - if (!clnt_info) - return -EINVAL; - - mutex_lock(&server->cb_req_lock); - - xdr_start_request(&server->cb_xdr, (server->prog | 0x01000000), - be32_to_cpu(clnt_info->vers), cb_proc); - req_xid = be32_to_cpu(*(uint32_t *)server->cb_xdr.out_buf); - if (arg_func) { - rc = arg_func(server, &server->cb_xdr, arg_data); - if (rc < 0) - goto release_locks; - else - size += rc; - } - - server->cb_ept->dst_pid = clnt_info->pid; - server->cb_ept->dst_cid = clnt_info->cid; - rc = xdr_send_msg(&server->cb_xdr); - if (rc < 0) { - pr_err("%s: couldn't send RPC CB request:%d\n", __func__, rc); - goto release_locks; - } else - rc = 0; - - if (timeout < 0) - timeout = msecs_to_jiffies(10000); - - do { - buffer = NULL; - rc = msm_rpc_read(server->cb_ept, &buffer, -1, timeout); - if (rc < 0) { - server->cb_xdr.out_index = 0; - goto release_locks; - } - - xdr_init_input(&server->cb_xdr, buffer, rc); - rc = xdr_recv_reply(&server->cb_xdr, &rpc_rsp); - if (rc || (rpc_rsp.type != 1)) { - printk(KERN_ERR "%s: Invalid reply :%d\n", - __func__, rc); - rc = -EINVAL; - goto free_and_release; - } - - if (req_xid != rpc_rsp.xid) { - pr_info("%s: xid mismatch, req %d reply %d\n", - __func__, req_xid, rpc_rsp.xid); - xdr_clean_input(&server->cb_xdr); - rc = timeout; - /* timeout is not adjusted, but it is not critical */ - } else - rc = 0; - - } while (rc); - - if (rpc_rsp.reply_stat != RPCMSG_REPLYSTAT_ACCEPTED) { - pr_err("%s: RPC cb req was denied! %d\n", __func__, - rpc_rsp.reply_stat); - rc = -EPERM; - goto free_and_release; - } - - if (rpc_rsp.data.acc_hdr.accept_stat != RPC_ACCEPTSTAT_SUCCESS) { - pr_err("%s: RPC cb req was not successful (%d)\n", __func__, - rpc_rsp.data.acc_hdr.accept_stat); - rc = -EINVAL; - goto free_and_release; - } - - if (ret_func) - rc = ret_func(server, &server->cb_xdr, ret_data); - -free_and_release: - xdr_clean_input(&server->cb_xdr); - server->cb_xdr.out_index = 0; -release_locks: - mutex_unlock(&server->cb_req_lock); - return rc; -} -EXPORT_SYMBOL(msm_rpc_server_cb_req2); - -void msm_rpc_server_get_requesting_client(struct msm_rpc_client_info *clnt_info) -{ - if (!clnt_info) - return; - - get_requesting_client(endpoint, current_xid, clnt_info); -} - -static int rpc_servers_thread(void *data) -{ - void *buffer, *buf; - struct rpc_request_hdr req; - struct rpc_request_hdr *req1; - struct msm_rpc_server *server; - int rc; - - xdr_init(&server_xdr); - server_xdr.ept = endpoint; - - buf = kmalloc(MSM_RPC_MSGSIZE_MAX, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - xdr_init_output(&server_xdr, buf, MSM_RPC_MSGSIZE_MAX); - - for (;;) { - wake_unlock(&rpc_servers_wake_lock); - rc = wait_event_interruptible(endpoint->wait_q, - !list_empty(&endpoint->read_q)); - wake_lock(&rpc_servers_wake_lock); - - rc = msm_rpc_read(endpoint, &buffer, -1, -1); - if (rc < 0) { - printk(KERN_ERR "%s: could not read: %d\n", - __FUNCTION__, rc); - break; - } - - req1 = (struct rpc_request_hdr *)buffer; - current_xid = req1->xid; - - xdr_init_input(&server_xdr, buffer, rc); - xdr_recv_req(&server_xdr, &req); - - server = rpc_server_find(req.prog, req.vers); - - if (req.rpc_vers != 2) - goto free_buffer; - if (req.type != 0) - goto free_buffer; - if (!server) { - rpc_send_accepted_void_reply( - endpoint, req.xid, - RPC_ACCEPTSTAT_PROG_UNAVAIL); - goto free_buffer; - } - - if (server->version == 2) - rc = server->rpc_call2(server, &req, &server_xdr); - else { - req1->type = be32_to_cpu(req1->type); - req1->xid = be32_to_cpu(req1->xid); - req1->rpc_vers = be32_to_cpu(req1->rpc_vers); - req1->prog = be32_to_cpu(req1->prog); - req1->vers = be32_to_cpu(req1->vers); - req1->procedure = be32_to_cpu(req1->procedure); - - rc = server->rpc_call(server, req1, rc); - } - - if (rc == 0) { - msm_rpc_server_start_accepted_reply( - server, req.xid, - RPC_ACCEPTSTAT_SUCCESS); - msm_rpc_server_send_accepted_reply(server, 0); - } else if (rc < 0) { - msm_rpc_server_start_accepted_reply( - server, req.xid, - RPC_ACCEPTSTAT_PROC_UNAVAIL); - msm_rpc_server_send_accepted_reply(server, 0); - } - free_buffer: - xdr_clean_input(&server_xdr); - server_xdr.out_index = 0; - } - do_exit(0); -} - -static int rpcservers_probe(struct platform_device *pdev) -{ - struct task_struct *server_thread; - - endpoint = msm_rpc_open(); - if (IS_ERR(endpoint)) - return PTR_ERR(endpoint); - - /* we're online -- register any servers installed beforehand */ - rpc_servers_active = 1; - current_xid = 0; - rpc_server_register_all(); - - /* start the kernel thread */ - server_thread = kthread_run(rpc_servers_thread, NULL, "krpcserversd"); - if (IS_ERR(server_thread)) - return PTR_ERR(server_thread); - - return 0; -} - -static struct platform_driver rpcservers_driver = { - .probe = rpcservers_probe, - .driver = { - .name = "oncrpc_router", - .owner = THIS_MODULE, - }, -}; - -static int __init rpc_servers_init(void) -{ - wake_lock_init(&rpc_servers_wake_lock, WAKE_LOCK_SUSPEND, "rpc_server"); - return platform_driver_register(&rpcservers_driver); -} - -module_init(rpc_servers_init); - -MODULE_DESCRIPTION("MSM RPC Servers"); -MODULE_AUTHOR("Iliyan Malchev "); -MODULE_LICENSE("GPL"); diff --git a/arch/arm/mach-msm/smd_rpcrouter_xdr.c b/arch/arm/mach-msm/smd_rpcrouter_xdr.c deleted file mode 100644 index 107271c63cf37eb096db5d681b8da79e46920b3e..0000000000000000000000000000000000000000 --- a/arch/arm/mach-msm/smd_rpcrouter_xdr.c +++ /dev/null @@ -1,415 +0,0 @@ -/* Copyright (c) 2010, 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. - * - */ - -/* - * SMD RPCROUTER XDR module. - */ - -#include -#include -#include -#include -#include -#include - -#include - -int xdr_send_uint32(struct msm_rpc_xdr *xdr, const uint32_t *value) -{ - if ((xdr->out_index + sizeof(uint32_t)) > xdr->out_size) { - pr_err("%s: xdr out buffer full\n", __func__); - return -1; - } - - *(uint32_t *)(xdr->out_buf + xdr->out_index) = cpu_to_be32(*value); - xdr->out_index += sizeof(uint32_t); - return 0; -} - -int xdr_send_int8(struct msm_rpc_xdr *xdr, const int8_t *value) -{ - return xdr_send_uint32(xdr, (uint32_t *)value); -} - -int xdr_send_uint8(struct msm_rpc_xdr *xdr, const uint8_t *value) -{ - return xdr_send_uint32(xdr, (uint32_t *)value); -} - -int xdr_send_int16(struct msm_rpc_xdr *xdr, const int16_t *value) -{ - return xdr_send_uint32(xdr, (uint32_t *)value); -} - -int xdr_send_uint16(struct msm_rpc_xdr *xdr, const uint16_t *value) -{ - return xdr_send_uint32(xdr, (uint32_t *)value); -} - -int xdr_send_int32(struct msm_rpc_xdr *xdr, const int32_t *value) -{ - return xdr_send_uint32(xdr, (uint32_t *)value); -} - -int xdr_send_bytes(struct msm_rpc_xdr *xdr, const void **data, - uint32_t *size) -{ - void *buf = xdr->out_buf + xdr->out_index; - uint32_t temp; - - if (!size || !data || !*data) - return -1; - - temp = *size; - if (temp & 0x3) - temp += 4 - (temp & 0x3); - - temp += sizeof(uint32_t); - if ((xdr->out_index + temp) > xdr->out_size) { - pr_err("%s: xdr out buffer full\n", __func__); - return -1; - } - - *((uint32_t *)buf) = cpu_to_be32(*size); - buf += sizeof(uint32_t); - memcpy(buf, *data, *size); - buf += *size; - if (*size & 0x3) { - memset(buf, 0, 4 - (*size & 0x3)); - buf += 4 - (*size & 0x3); - } - - xdr->out_index = buf - xdr->out_buf; - return 0; -} - -int xdr_recv_uint32(struct msm_rpc_xdr *xdr, uint32_t *value) -{ - if ((xdr->in_index + sizeof(uint32_t)) > xdr->in_size) { - pr_err("%s: xdr in buffer full\n", __func__); - return -1; - } - - *value = be32_to_cpu(*(uint32_t *)(xdr->in_buf + xdr->in_index)); - xdr->in_index += sizeof(uint32_t); - return 0; -} - -int xdr_recv_int8(struct msm_rpc_xdr *xdr, int8_t *value) -{ - return xdr_recv_uint32(xdr, (uint32_t *)value); -} - -int xdr_recv_uint8(struct msm_rpc_xdr *xdr, uint8_t *value) -{ - return xdr_recv_uint32(xdr, (uint32_t *)value); -} - -int xdr_recv_int16(struct msm_rpc_xdr *xdr, int16_t *value) -{ - return xdr_recv_uint32(xdr, (uint32_t *)value); -} - -int xdr_recv_uint16(struct msm_rpc_xdr *xdr, uint16_t *value) -{ - return xdr_recv_uint32(xdr, (uint32_t *)value); -} - -int xdr_recv_int32(struct msm_rpc_xdr *xdr, int32_t *value) -{ - return xdr_recv_uint32(xdr, (uint32_t *)value); -} - -int xdr_recv_bytes(struct msm_rpc_xdr *xdr, void **data, - uint32_t *size) -{ - void *buf = xdr->in_buf + xdr->in_index; - uint32_t temp; - - if (!size || !data) - return -1; - - *size = be32_to_cpu(*(uint32_t *)buf); - buf += sizeof(uint32_t); - - temp = *size; - if (temp & 0x3) - temp += 4 - (temp & 0x3); - - temp += sizeof(uint32_t); - if ((xdr->in_index + temp) > xdr->in_size) { - pr_err("%s: xdr in buffer full\n", __func__); - return -1; - } - - if (*size) { - *data = kmalloc(*size, GFP_KERNEL); - if (!*data) - return -1; - - memcpy(*data, buf, *size); - - buf += *size; - if (*size & 0x3) - buf += 4 - (*size & 0x3); - } else - *data = NULL; - - xdr->in_index = buf - xdr->in_buf; - return 0; -} - -int xdr_send_pointer(struct msm_rpc_xdr *xdr, void **obj, - uint32_t obj_size, void *xdr_op) -{ - uint32_t ptr_valid, rc; - - ptr_valid = (*obj != NULL); - - rc = xdr_send_uint32(xdr, &ptr_valid); - if (rc) - return rc; - - if (!ptr_valid) - return 0; - - return ((int (*) (struct msm_rpc_xdr *, void *))xdr_op)(xdr, *obj); -} - -int xdr_recv_pointer(struct msm_rpc_xdr *xdr, void **obj, - uint32_t obj_size, void *xdr_op) -{ - uint32_t rc, ptr_valid = 0; - - rc = xdr_recv_uint32(xdr, &ptr_valid); - if (rc) - return rc; - - if (!ptr_valid) { - *obj = NULL; - return 0; - } - - *obj = kmalloc(obj_size, GFP_KERNEL); - if (!*obj) - return -1; - - rc = ((int (*) (struct msm_rpc_xdr *, void *))xdr_op)(xdr, *obj); - if (rc) - kfree(*obj); - - return rc; -} - -int xdr_send_array(struct msm_rpc_xdr *xdr, void **addr, uint32_t *size, - uint32_t maxsize, uint32_t elm_size, void *xdr_op) -{ - int i, rc; - void *tmp_addr = *addr; - - if (!size || !tmp_addr || (*size > maxsize) || !xdr_op) - return -1; - - rc = xdr_send_uint32(xdr, size); - if (rc) - return rc; - - for (i = 0; i < *size; i++) { - rc = ((int (*) (struct msm_rpc_xdr *, void *))xdr_op) - (xdr, tmp_addr); - if (rc) - return rc; - - tmp_addr += elm_size; - } - - return 0; -} - -int xdr_recv_array(struct msm_rpc_xdr *xdr, void **addr, uint32_t *size, - uint32_t maxsize, uint32_t elm_size, void *xdr_op) -{ - int i, rc; - void *tmp_addr; - - if (!size || !xdr_op) - return -1; - - rc = xdr_recv_uint32(xdr, size); - if (rc) - return rc; - - if (*size > maxsize) - return -1; - - tmp_addr = kmalloc((*size * elm_size), GFP_KERNEL); - if (!tmp_addr) - return -1; - - *addr = tmp_addr; - for (i = 0; i < *size; i++) { - rc = ((int (*) (struct msm_rpc_xdr *, void *))xdr_op) - (xdr, tmp_addr); - if (rc) { - kfree(*addr); - *addr = NULL; - return rc; - } - - tmp_addr += elm_size; - } - - return 0; -} - -int xdr_recv_req(struct msm_rpc_xdr *xdr, struct rpc_request_hdr *req) -{ - int rc = 0; - if (!req) - return -1; - - rc |= xdr_recv_uint32(xdr, &req->xid); /* xid */ - rc |= xdr_recv_uint32(xdr, &req->type); /* type */ - rc |= xdr_recv_uint32(xdr, &req->rpc_vers); /* rpc_vers */ - rc |= xdr_recv_uint32(xdr, &req->prog); /* prog */ - rc |= xdr_recv_uint32(xdr, &req->vers); /* vers */ - rc |= xdr_recv_uint32(xdr, &req->procedure); /* procedure */ - rc |= xdr_recv_uint32(xdr, &req->cred_flavor); /* cred_flavor */ - rc |= xdr_recv_uint32(xdr, &req->cred_length); /* cred_length */ - rc |= xdr_recv_uint32(xdr, &req->verf_flavor); /* verf_flavor */ - rc |= xdr_recv_uint32(xdr, &req->verf_length); /* verf_length */ - - return rc; -} - -int xdr_recv_reply(struct msm_rpc_xdr *xdr, struct rpc_reply_hdr *reply) -{ - int rc = 0; - - if (!reply) - return -1; - - rc |= xdr_recv_uint32(xdr, &reply->xid); /* xid */ - rc |= xdr_recv_uint32(xdr, &reply->type); /* type */ - rc |= xdr_recv_uint32(xdr, &reply->reply_stat); /* reply_stat */ - - /* acc_hdr */ - if (reply->reply_stat == RPCMSG_REPLYSTAT_ACCEPTED) { - rc |= xdr_recv_uint32(xdr, &reply->data.acc_hdr.verf_flavor); - rc |= xdr_recv_uint32(xdr, &reply->data.acc_hdr.verf_length); - rc |= xdr_recv_uint32(xdr, &reply->data.acc_hdr.accept_stat); - } - - return rc; -} - -int xdr_start_request(struct msm_rpc_xdr *xdr, uint32_t prog, - uint32_t ver, uint32_t proc) -{ - mutex_lock(&xdr->out_lock); - - /* TODO: replace below function with its implementation */ - msm_rpc_setup_req((struct rpc_request_hdr *)xdr->out_buf, - prog, ver, proc); - - xdr->out_index = sizeof(struct rpc_request_hdr); - return 0; -} - -int xdr_start_accepted_reply(struct msm_rpc_xdr *xdr, uint32_t accept_status) -{ - struct rpc_reply_hdr *reply; - - mutex_lock(&xdr->out_lock); - - /* TODO: err if xdr is not cb xdr */ - reply = (struct rpc_reply_hdr *)xdr->out_buf; - - /* TODO: use xdr functions instead */ - reply->xid = ((struct rpc_request_hdr *)(xdr->in_buf))->xid; - reply->type = cpu_to_be32(1); /* reply */ - reply->reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED); - - reply->data.acc_hdr.accept_stat = cpu_to_be32(accept_status); - reply->data.acc_hdr.verf_flavor = 0; - reply->data.acc_hdr.verf_length = 0; - - xdr->out_index = sizeof(*reply); - return 0; -} - -int xdr_send_msg(struct msm_rpc_xdr *xdr) -{ - int rc = 0; - - rc = msm_rpc_write(xdr->ept, xdr->out_buf, - xdr->out_index); - if (rc > 0) - rc = 0; - - mutex_unlock(&xdr->out_lock); - return rc; -} - -void xdr_init(struct msm_rpc_xdr *xdr) -{ - mutex_init(&xdr->out_lock); - init_waitqueue_head(&xdr->in_buf_wait_q); - - xdr->in_buf = NULL; - xdr->in_size = 0; - xdr->in_index = 0; - - xdr->out_buf = NULL; - xdr->out_size = 0; - xdr->out_index = 0; -} - -void xdr_init_input(struct msm_rpc_xdr *xdr, void *buf, uint32_t size) -{ - wait_event(xdr->in_buf_wait_q, !(xdr->in_buf)); - - xdr->in_buf = buf; - xdr->in_size = size; - xdr->in_index = 0; -} - -void xdr_init_output(struct msm_rpc_xdr *xdr, void *buf, uint32_t size) -{ - xdr->out_buf = buf; - xdr->out_size = size; - xdr->out_index = 0; -} - -void xdr_clean_input(struct msm_rpc_xdr *xdr) -{ - kfree(xdr->in_buf); - xdr->in_size = 0; - xdr->in_index = 0; - xdr->in_buf = NULL; - - wake_up(&xdr->in_buf_wait_q); -} - -void xdr_clean_output(struct msm_rpc_xdr *xdr) -{ - kfree(xdr->out_buf); - xdr->out_buf = NULL; - xdr->out_size = 0; - xdr->out_index = 0; -} - -uint32_t xdr_read_avail(struct msm_rpc_xdr *xdr) -{ - return xdr->in_size; -} diff --git a/arch/arm/mach-msm/test-lpm.c b/arch/arm/mach-msm/test-lpm.c index 3c20fb02a44aeeedcc1f0dc619d9368551651b11..3db681c14d65fa27e1c3fcb9e5dbe0d1396ca5f2 100644 --- a/arch/arm/mach-msm/test-lpm.c +++ b/arch/arm/mach-msm/test-lpm.c @@ -23,9 +23,6 @@ #include #include #include -#if defined(CONFIG_MSM_RPM) -#include "rpm_resources.h" -#endif #if defined(CONFIG_MSM_RPM_SMD) #include "lpm_resources.h" #endif diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index 99f0e06c1046a8aa0fa4bdbb76f2d6fd050aa23e..9ae83d881f55f66b1e686a855a0760ae1474b7fb 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig @@ -878,16 +878,6 @@ config CACHE_PL310 This option enables optimisations for the PL310 cache controller. -config CACHE_PL310_ERP - tristate "PL310 CACHE Error Reporting" - depends on CACHE_PL310 - help - Say 'Y' here to enable reporting of external L2 cache errors. - This feature can be used as a system debugging technique if cache - corruption is suspected. - Cache error statistics will also be reported in sysfs - /sys/devices/platform/pl310_erp/cache_erp - config CACHE_TAUROS2 bool "Enable the Tauros2 L2 cache controller" depends on (ARCH_DOVE || ARCH_MMP || CPU_PJ4) diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile index 5b7241d63014231dba09efdb5f07bf6d80e6986f..9e51be96f635b5945b978bed2c6978fd3d2b61ba 100644 --- a/arch/arm/mm/Makefile +++ b/arch/arm/mm/Makefile @@ -93,6 +93,5 @@ AFLAGS_proc-v7.o :=-Wa,-march=armv7-a obj-$(CONFIG_CACHE_FEROCEON_L2) += cache-feroceon-l2.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o -obj-$(CONFIG_CACHE_PL310_ERP) += cache-pl310-erp.o obj-$(CONFIG_CACHE_XSC3L2) += cache-xsc3l2.o obj-$(CONFIG_CACHE_TAUROS2) += cache-tauros2.o diff --git a/arch/arm/mm/cache-pl310-erp.c b/arch/arm/mm/cache-pl310-erp.c deleted file mode 100644 index e012a9be83749eb4841b21d5bafba71eff7c0f51..0000000000000000000000000000000000000000 --- a/arch/arm/mm/cache-pl310-erp.c +++ /dev/null @@ -1,315 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#define MODULE_NAME "pl310_erp" - -struct pl310_drv_data { - unsigned int irq; - unsigned int ecntr; - unsigned int parrt; - unsigned int parrd; - unsigned int errwd; - unsigned int errwt; - unsigned int errrt; - unsigned int errrd; - unsigned int slverr; - unsigned int decerr; - void __iomem *base; - unsigned int intr_mask_reg; -}; - -#define ECNTR BIT(0) -#define PARRT BIT(1) -#define PARRD BIT(2) -#define ERRWT BIT(3) -#define ERRWD BIT(4) -#define ERRRT BIT(5) -#define ERRRD BIT(6) -#define SLVERR BIT(7) -#define DECERR BIT(8) - -static irqreturn_t pl310_erp_irq(int irq, void *dev_id) -{ - struct pl310_drv_data *p = platform_get_drvdata(dev_id); - uint16_t mask_int_stat, int_clear = 0, error = 0; - - mask_int_stat = readl_relaxed(p->base + L2X0_MASKED_INTR_STAT); - - if (mask_int_stat & ECNTR) { - pr_alert("Event Counter1/0 Overflow Increment error\n"); - p->ecntr++; - int_clear = mask_int_stat & ECNTR; - } - - if (mask_int_stat & PARRT) { - pr_alert("Read parity error on L2 Tag RAM\n"); - p->parrt++; - error = 1; - int_clear = mask_int_stat & PARRT; - } - - if (mask_int_stat & PARRD) { - pr_alert("Read parity error on L2 Tag RAM\n"); - p->parrd++; - error = 1; - int_clear = mask_int_stat & PARRD; - } - - if (mask_int_stat & ERRWT) { - pr_alert("Write error on L2 Tag RAM\n"); - p->errwt++; - int_clear = mask_int_stat & ERRWT; - } - - if (mask_int_stat & ERRWD) { - pr_alert("Write error on L2 Data RAM\n"); - p->errwd++; - int_clear = mask_int_stat & ERRWD; - } - - if (mask_int_stat & ERRRT) { - pr_alert("Read error on L2 Tag RAM\n"); - p->errrt++; - int_clear = mask_int_stat & ERRRT; - } - - if (mask_int_stat & ERRRD) { - pr_alert("Read error on L2 Data RAM\n"); - p->errrd++; - int_clear = mask_int_stat & ERRRD; - } - - if (mask_int_stat & DECERR) { - pr_alert("L2 master port decode error\n"); - p->decerr++; - int_clear = mask_int_stat & DECERR; - } - - if (mask_int_stat & SLVERR) { - pr_alert("L2 slave port error\n"); - p->slverr++; - int_clear = mask_int_stat & SLVERR; - } - - writel_relaxed(int_clear, p->base + L2X0_INTR_CLEAR); - - /* Make sure the interrupts are cleared */ - mb(); - - /* WARNING will be thrown whenever we receive any L2 interrupt. - * Other than parity on tag/data ram, irrespective of the bits - * set we will throw a warning. - */ - WARN_ON(!error); - - /* Panic in case we encounter parity error in TAG/DATA Ram */ - BUG_ON(error); - - return IRQ_HANDLED; -} - -static void pl310_mask_int(struct pl310_drv_data *p, bool enable) -{ - /* L2CC register contents needs to be saved - * as it's power rail will be removed during suspend - */ - if (enable) - p->intr_mask_reg = 0x1FF; - else - p->intr_mask_reg = 0x0; - - writel_relaxed(p->intr_mask_reg, p->base + L2X0_INTR_MASK); - - /* Make sure Mask is updated */ - mb(); - - pr_debug("Mask interrupt 0%x\n", - readl_relaxed(p->base + L2X0_INTR_MASK)); -} - -static int pl310_erp_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct pl310_drv_data *p = dev_get_drvdata(dev); - - return snprintf(buf, PAGE_SIZE, - "L2CC Interrupt Number:\t\t\t%d\n"\ - "Event Counter1/0 Overflow Increment:\t%u\n"\ - "Parity Error on L2 Tag RAM (Read):\t%u\n"\ - "Parity Error on L2 Data RAM (Read):\t%u\n"\ - "Error on L2 Tag RAM (Write):\t\t%u\n"\ - "Error on L2 Data RAM (Write):\t\t%u\n"\ - "Error on L2 Tag RAM (Read):\t\t%u\n"\ - "Error on L2 Data RAM (Read):\t\t%u\n"\ - "SLave Error from L3 Port:\t\t%u\n"\ - "Decode Error from L3 Port:\t\t%u\n", - p->irq, p->ecntr, p->parrt, p->parrd, p->errwt, p->errwd, - p->errrt, p->errrd, p->slverr, p->decerr); -} - -static DEVICE_ATTR(cache_erp, 0664, pl310_erp_show, NULL); - -static int __init pl310_create_sysfs(struct device *dev) -{ - /* create a sysfs entry at - * /sys/devices/platform/pl310_erp/cache_erp - */ - return device_create_file(dev, &dev_attr_cache_erp); -} - -static int pl310_cache_erp_probe(struct platform_device *pdev) -{ - struct resource *r; - struct pl310_drv_data *drv_data; - int ret; - - drv_data = devm_kzalloc(&pdev->dev, sizeof(struct pl310_drv_data), - GFP_KERNEL); - if (drv_data == NULL) { - dev_err(&pdev->dev, "cannot allocate memory\n"); - ret = -ENOMEM; - goto error; - } - - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) { - dev_err(&pdev->dev, "No L2 base address\n"); - ret = -ENODEV; - goto error; - } - - if (!devm_request_mem_region(&pdev->dev, r->start, resource_size(r), - "erp")) { - ret = -EBUSY; - goto error; - } - - drv_data->base = devm_ioremap_nocache(&pdev->dev, r->start, - resource_size(r)); - if (!drv_data->base) { - dev_err(&pdev->dev, "errored to ioremap 0x%x\n", r->start); - ret = -ENOMEM; - goto error; - } - dev_dbg(&pdev->dev, "L2CC base 0x%p\n", drv_data->base); - - r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "l2_irq"); - if (!r) { - dev_err(&pdev->dev, "No L2 IRQ resource\n"); - ret = -ENODEV; - goto error; - } - - drv_data->irq = r->start; - - ret = devm_request_irq(&pdev->dev, drv_data->irq, pl310_erp_irq, - IRQF_TRIGGER_RISING, "l2cc_intr", pdev); - if (ret) { - dev_err(&pdev->dev, "request irq for L2 interrupt failed\n"); - goto error; - } - - platform_set_drvdata(pdev, drv_data); - - pl310_mask_int(drv_data, true); - - ret = pl310_create_sysfs(&pdev->dev); - if (ret) { - dev_err(&pdev->dev, "Failed to create sysfs entry\n"); - goto sysfs_err; - } - - return 0; - -sysfs_err: - platform_set_drvdata(pdev, NULL); - pl310_mask_int(drv_data, false); -error: - return ret; -} - -static int pl310_cache_erp_remove(struct platform_device *pdev) -{ - struct pl310_drv_data *p = platform_get_drvdata(pdev); - - pl310_mask_int(p, false); - - device_remove_file(&pdev->dev, &dev_attr_cache_erp); - - platform_set_drvdata(pdev, NULL); - - return 0; -} - -#ifdef CONFIG_PM -static int pl310_suspend(struct device *dev) -{ - struct pl310_drv_data *p = dev_get_drvdata(dev); - - disable_irq(p->irq); - - return 0; -} - -static int pl310_resume_early(struct device *dev) -{ - struct pl310_drv_data *p = dev_get_drvdata(dev); - - pl310_mask_int(p, true); - - enable_irq(p->irq); - - return 0; -} - -static const struct dev_pm_ops pl310_cache_pm_ops = { - .suspend = pl310_suspend, - .resume_early = pl310_resume_early, -}; -#endif - -static struct platform_driver pl310_cache_erp_driver = { - .probe = pl310_cache_erp_probe, - .remove = pl310_cache_erp_remove, - .driver = { - .name = MODULE_NAME, - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &pl310_cache_pm_ops, -#endif - }, -}; - -static int __init pl310_cache_erp_init(void) -{ - return platform_driver_register(&pl310_cache_erp_driver); -} -module_init(pl310_cache_erp_init); - -static void __exit pl310_cache_erp_exit(void) -{ - platform_driver_unregister(&pl310_cache_erp_driver); -} -module_exit(pl310_cache_erp_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PL310 cache error reporting driver"); diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index f1c208986fd2e14456ed674c5c1c6dfb71f9c417..5e07b329301fd2c612ab0eae8a89c8ed0819560c 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -846,9 +846,6 @@ void __init mem_init(void) printk(KERN_NOTICE "Virtual kernel memory layout:\n" " vector : 0x%08lx - 0x%08lx (%4ld kB)\n" -#ifdef CONFIG_ARM_USE_USER_ACCESSIBLE_TIMERS - " timers : 0x%08lx - 0x%08lx (%4ld kB)\n" -#endif #ifdef CONFIG_HAVE_TCM " DTCM : 0x%08lx - 0x%08lx (%4ld kB)\n" " ITCM : 0x%08lx - 0x%08lx (%4ld kB)\n" @@ -856,11 +853,6 @@ void __init mem_init(void) " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n", MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) + (PAGE_SIZE)), -#ifdef CONFIG_ARM_USE_USER_ACCESSIBLE_TIMERS - MLK(UL(CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE), - UL(CONFIG_ARM_USER_ACCESSIBLE_TIMER_BASE) - + (PAGE_SIZE)), -#endif #ifdef CONFIG_HAVE_TCM MLK(DTCM_OFFSET, (unsigned long) dtcm_end), MLK(ITCM_OFFSET, (unsigned long) itcm_end), diff --git a/drivers/Makefile b/drivers/Makefile index d01aa057b563589deaa8762da211a0f0fe733423..a19cf4a6b7a282f9b67ec43b9285301957f30744 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -160,7 +160,6 @@ obj-$(CONFIG_NTB) += ntb/ obj-$(CONFIG_MOBICORE_SUPPORT) += gud/ obj-$(CONFIG_CORESIGHT) += coresight/ -obj-$(CONFIG_ESOC) += esoc/ obj-$(CONFIG_BIF) += bif/ obj-$(CONFIG_SENSORS) += sensors/ diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 54c3a467998915724099acb68439dcd6aede0470..a5a3ebcbdd2cf6295028f62d0fe1d3bb21397633 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -97,17 +97,6 @@ config SATA_AHCI_PLATFORM If unsure, say N. -config SATA_AHCI_MSM - tristate "Qualcomm MSM AHCI SATA support" - depends on ARCH_MSM - select SATA_AHCI_PLATFORM - help - This option enables support for AHCI SATA controller - integrated into Qualcomm MSM chipsets. For more - information please refer to http://www.qualcomm.com/chipsets. - - If unsure, say N. - config SATA_FSL tristate "Freescale 3.0Gbps SATA support" depends on FSL_SOC diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 34f1b73ed3e35cc858e0df6de970fdbb89f94d19..c04d0fd038a312485712ed2be8a42d77b32df5c9 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile @@ -10,7 +10,6 @@ obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o obj-$(CONFIG_SATA_SIL24) += sata_sil24.o obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o -obj-$(CONFIG_SATA_AHCI_MSM) += ahci_msm.o # SFF w/ custom DMA obj-$(CONFIG_PDC_ADMA) += pdc_adma.o diff --git a/drivers/ata/ahci_msm.c b/drivers/ata/ahci_msm.c deleted file mode 100644 index fe9ee7346fe73e0f0a3a51d5992f864ce054e2d9..0000000000000000000000000000000000000000 --- a/drivers/ata/ahci_msm.c +++ /dev/null @@ -1,778 +0,0 @@ -/* - * Copyright (c) 2012-2013, 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. - */ - -/* - * SATA init module. - * To be used with SATA interface on MSM targets. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* PHY registers */ -#define UNIPHY_PLL_REFCLK_CFG 0x000 -#define UNIPHY_PLL_POSTDIV1_CFG 0x004 -#define UNIPHY_PLL_CHGPUMP_CFG 0x008 -#define UNIPHY_PLL_VCOLPF_CFG 0x00C -#define UNIPHY_PLL_VREG_CFG 0x010 -#define UNIPHY_PLL_PWRGEN_CFG 0x014 -#define UNIPHY_PLL_DMUX_CFG 0x018 -#define UNIPHY_PLL_AMUX_CFG 0x01C -#define UNIPHY_PLL_GLB_CFG 0x020 -#define UNIPHY_PLL_POSTDIV2_CFG 0x024 -#define UNIPHY_PLL_POSTDIV3_CFG 0x028 -#define UNIPHY_PLL_LPFR_CFG 0x02C -#define UNIPHY_PLL_LPFC1_CFG 0x030 -#define UNIPHY_PLL_LPFC2_CFG 0x034 -#define UNIPHY_PLL_SDM_CFG0 0x038 -#define UNIPHY_PLL_SDM_CFG1 0x03C -#define UNIPHY_PLL_SDM_CFG2 0x040 -#define UNIPHY_PLL_SDM_CFG3 0x044 -#define UNIPHY_PLL_SDM_CFG4 0x048 -#define UNIPHY_PLL_SSC_CFG0 0x04C -#define UNIPHY_PLL_SSC_CFG1 0x050 -#define UNIPHY_PLL_SSC_CFG2 0x054 -#define UNIPHY_PLL_SSC_CFG3 0x058 -#define UNIPHY_PLL_LKDET_CFG0 0x05C -#define UNIPHY_PLL_LKDET_CFG1 0x060 -#define UNIPHY_PLL_LKDET_CFG2 0x064 -#define UNIPHY_PLL_TEST_CFG 0x068 -#define UNIPHY_PLL_CAL_CFG0 0x06C -#define UNIPHY_PLL_CAL_CFG1 0x070 -#define UNIPHY_PLL_CAL_CFG2 0x074 -#define UNIPHY_PLL_CAL_CFG3 0x078 -#define UNIPHY_PLL_CAL_CFG4 0x07C -#define UNIPHY_PLL_CAL_CFG5 0x080 -#define UNIPHY_PLL_CAL_CFG6 0x084 -#define UNIPHY_PLL_CAL_CFG7 0x088 -#define UNIPHY_PLL_CAL_CFG8 0x08C -#define UNIPHY_PLL_CAL_CFG9 0x090 -#define UNIPHY_PLL_CAL_CFG10 0x094 -#define UNIPHY_PLL_CAL_CFG11 0x098 -#define UNIPHY_PLL_EFUSE_CFG 0x09C -#define UNIPHY_PLL_DEBUG_BUS_SEL 0x0A0 -#define UNIPHY_PLL_CTRL_42 0x0A4 -#define UNIPHY_PLL_CTRL_43 0x0A8 -#define UNIPHY_PLL_CTRL_44 0x0AC -#define UNIPHY_PLL_CTRL_45 0x0B0 -#define UNIPHY_PLL_CTRL_46 0x0B4 -#define UNIPHY_PLL_CTRL_47 0x0B8 -#define UNIPHY_PLL_CTRL_48 0x0BC -#define UNIPHY_PLL_STATUS 0x0C0 -#define UNIPHY_PLL_DEBUG_BUS0 0x0C4 -#define UNIPHY_PLL_DEBUG_BUS1 0x0C8 -#define UNIPHY_PLL_DEBUG_BUS2 0x0CC -#define UNIPHY_PLL_DEBUG_BUS3 0x0D0 -#define UNIPHY_PLL_CTRL_54 0x0D4 - -#define SATA_PHY_SER_CTRL 0x100 -#define SATA_PHY_TX_DRIV_CTRL0 0x104 -#define SATA_PHY_TX_DRIV_CTRL1 0x108 -#define SATA_PHY_TX_DRIV_CTRL2 0x10C -#define SATA_PHY_TX_DRIV_CTRL3 0x110 -#define SATA_PHY_TX_RESV0 0x114 -#define SATA_PHY_TX_RESV1 0x118 -#define SATA_PHY_TX_IMCAL0 0x11C -#define SATA_PHY_TX_IMCAL1 0x120 -#define SATA_PHY_TX_IMCAL2 0x124 -#define SATA_PHY_RX_IMCAL0 0x128 -#define SATA_PHY_RX_IMCAL1 0x12C -#define SATA_PHY_RX_IMCAL2 0x130 -#define SATA_PHY_RX_TERM 0x134 -#define SATA_PHY_RX_TERM_RESV 0x138 -#define SATA_PHY_EQUAL 0x13C -#define SATA_PHY_EQUAL_RESV 0x140 -#define SATA_PHY_OOB_TERM 0x144 -#define SATA_PHY_CDR_CTRL0 0x148 -#define SATA_PHY_CDR_CTRL1 0x14C -#define SATA_PHY_CDR_CTRL2 0x150 -#define SATA_PHY_CDR_CTRL3 0x154 -#define SATA_PHY_CDR_CTRL4 0x158 -#define SATA_PHY_FA_LOAD0 0x15C -#define SATA_PHY_FA_LOAD1 0x160 -#define SATA_PHY_CDR_CTRL_RESV 0x164 -#define SATA_PHY_PI_CTRL0 0x168 -#define SATA_PHY_PI_CTRL1 0x16C -#define SATA_PHY_DESER_RESV 0x170 -#define SATA_PHY_RX_RESV0 0x174 -#define SATA_PHY_AD_TPA_CTRL 0x178 -#define SATA_PHY_REFCLK_CTRL 0x17C -#define SATA_PHY_POW_DWN_CTRL0 0x180 -#define SATA_PHY_POW_DWN_CTRL1 0x184 -#define SATA_PHY_TX_DATA_CTRL 0x188 -#define SATA_PHY_BIST_GEN0 0x18C -#define SATA_PHY_BIST_GEN1 0x190 -#define SATA_PHY_BIST_GEN2 0x194 -#define SATA_PHY_BIST_GEN3 0x198 -#define SATA_PHY_LBK_CTRL 0x19C -#define SATA_PHY_TEST_DEBUG_CTRL 0x1A0 -#define SATA_PHY_ALIGNP 0x1A4 -#define SATA_PHY_PRBS_CFG0 0x1A8 -#define SATA_PHY_PRBS_CFG1 0x1AC -#define SATA_PHY_PRBS_CFG2 0x1B0 -#define SATA_PHY_PRBS_CFG3 0x1B4 -#define SATA_PHY_CHAN_COMP_CHK_CNT 0x1B8 -#define SATA_PHY_RESET_CTRL 0x1BC -#define SATA_PHY_RX_CLR 0x1C0 -#define SATA_PHY_RX_EBUF_CTRL 0x1C4 -#define SATA_PHY_ID0 0x1C8 -#define SATA_PHY_ID1 0x1CC -#define SATA_PHY_ID2 0x1D0 -#define SATA_PHY_ID3 0x1D4 -#define SATA_PHY_RX_CHK_ERR_CNT0 0x1D8 -#define SATA_PHY_RX_CHK_ERR_CNT1 0x1DC -#define SATA_PHY_RX_CHK_STAT 0x1E0 -#define SATA_PHY_TX_IMCAL_STAT 0x1E4 -#define SATA_PHY_RX_IMCAL_STAT 0x1E8 -#define SATA_PHY_RX_EBUF_STAT 0x1EC -#define SATA_PHY_DEBUG_BUS_STAT0 0x1F0 -#define SATA_PHY_DEBUG_BUS_STAT1 0x1F4 -#define SATA_PHY_DEBUG_BUS_STAT2 0x1F8 -#define SATA_PHY_DEBUG_BUS_STAT3 0x1FC - -#define AHCI_HOST_CAP 0x00 -#define AHCI_HOST_CAP_MASK 0x1F -#define AHCI_HOST_CAP_PMP (1 << 17) - -struct msm_sata_hba { - struct platform_device *ahci_pdev; - struct clk *slave_iface_clk; - struct clk *bus_clk; - struct clk *iface_clk; - struct clk *src_clk; - struct clk *rxoob_clk; - struct clk *pmalive_clk; - struct clk *cfg_clk; - struct regulator *clk_pwr; - struct regulator *pmp_pwr; - void __iomem *phy_base; - void __iomem *ahci_base; -}; - -static inline void msm_sata_delay_us(unsigned int delay) -{ - /* sleep for max. 50us more to combine processor wakeups */ - usleep_range(delay, delay + 50); -} - -static int msm_sata_clk_get_prepare_enable_set_rate(struct device *dev, - const char *name, struct clk **out_clk, int rate) -{ - int ret = 0; - struct clk *clk; - - clk = devm_clk_get(dev, name); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - dev_err(dev, "failed to get clk: %s err = %d\n", name, ret); - goto out; - } - - if (rate >= 0) { - ret = clk_set_rate(clk, rate); - if (ret) { - dev_err(dev, "failed to set rate: %d clk: %s err = %d\n", - rate, name, ret); - goto out; - } - } - - ret = clk_prepare_enable(clk); - if (ret) - dev_err(dev, "failed to enable clk: %s err = %d\n", name, ret); -out: - if (!ret) - *out_clk = clk; - - return ret; -} - -static int msm_sata_clk_get_prepare_enable(struct device *dev, - const char *name, struct clk **out_clk) -{ - return msm_sata_clk_get_prepare_enable_set_rate(dev, name, out_clk, -1); -} - -static void msm_sata_clk_put_unprepare_disable(struct clk **clk) -{ - if (*clk) { - clk_disable_unprepare(*clk); - clk_put(*clk); - *clk = NULL; - } -} - -static int msm_sata_hard_reset(struct device *dev) -{ - int ret; - struct msm_sata_hba *hba = dev_get_drvdata(dev); - - ret = clk_reset(hba->iface_clk, CLK_RESET_ASSERT); - if (ret) { - dev_err(dev, "iface_clk assert failed %d\n", ret); - goto out; - } - - ret = clk_reset(hba->iface_clk, CLK_RESET_DEASSERT); - if (ret) { - dev_err(dev, "iface_clk de-assert failed %d\n", ret); - goto out; - } -out: - return ret; -} - -static int msm_sata_clk_init(struct device *dev) -{ - int ret = 0; - struct msm_sata_hba *hba = dev_get_drvdata(dev); - - /* Enable AHB clock for system fabric slave port connected to SATA */ - ret = msm_sata_clk_get_prepare_enable(dev, - "slave_iface_clk", &hba->slave_iface_clk); - if (ret) - goto out; - - /* Enable AHB clock for system fabric and SATA core interface */ - ret = msm_sata_clk_get_prepare_enable(dev, - "iface_clk", &hba->iface_clk); - if (ret) - goto put_dis_slave_iface_clk; - - /* Enable AXI clock for SATA AXI master and slave interfaces */ - ret = msm_sata_clk_get_prepare_enable(dev, - "bus_clk", &hba->bus_clk); - if (ret) - goto put_dis_iface_clk; - - /* Enable the source clock for pmalive, rxoob and phy ref clocks */ - ret = msm_sata_clk_get_prepare_enable_set_rate(dev, - "src_clk", &hba->src_clk, 100000000); - if (ret) - goto put_dis_bus_clk; - - /* - * Enable RX OOB detection clock. The clock rate is - * same as PHY reference clock (100MHz). - */ - ret = msm_sata_clk_get_prepare_enable(dev, - "core_rxoob_clk", &hba->rxoob_clk); - if (ret) - goto put_dis_src_clk; - - /* - * Enable power management always-on clock. The clock rate - * is same as PHY reference clock (100MHz). - */ - ret = msm_sata_clk_get_prepare_enable(dev, - "core_pmalive_clk", &hba->pmalive_clk); - if (ret) - goto put_dis_rxoob_clk; - - /* Enable PHY configuration AHB clock, fixed 64MHz clock */ - ret = msm_sata_clk_get_prepare_enable(dev, - "cfg_clk", &hba->cfg_clk); - if (ret) - goto put_dis_pmalive_clk; - - return ret; - -put_dis_pmalive_clk: - msm_sata_clk_put_unprepare_disable(&hba->pmalive_clk); -put_dis_rxoob_clk: - msm_sata_clk_put_unprepare_disable(&hba->rxoob_clk); -put_dis_src_clk: - msm_sata_clk_put_unprepare_disable(&hba->src_clk); -put_dis_bus_clk: - msm_sata_clk_put_unprepare_disable(&hba->bus_clk); -put_dis_iface_clk: - msm_sata_clk_put_unprepare_disable(&hba->iface_clk); -put_dis_slave_iface_clk: - msm_sata_clk_put_unprepare_disable(&hba->slave_iface_clk); -out: - return ret; -} - -static void msm_sata_clk_deinit(struct device *dev) -{ - struct msm_sata_hba *hba = dev_get_drvdata(dev); - - msm_sata_clk_put_unprepare_disable(&hba->cfg_clk); - msm_sata_clk_put_unprepare_disable(&hba->pmalive_clk); - msm_sata_clk_put_unprepare_disable(&hba->rxoob_clk); - msm_sata_clk_put_unprepare_disable(&hba->src_clk); - msm_sata_clk_put_unprepare_disable(&hba->bus_clk); - msm_sata_clk_put_unprepare_disable(&hba->iface_clk); - msm_sata_clk_put_unprepare_disable(&hba->slave_iface_clk); -} - -static int msm_sata_vreg_get_enable_set_vdd(struct device *dev, - const char *name, struct regulator **out_vreg, - int min_uV, int max_uV, int hpm_uA) -{ - int ret = 0; - struct regulator *vreg; - - vreg = devm_regulator_get(dev, name); - if (IS_ERR(vreg)) { - ret = PTR_ERR(vreg); - dev_err(dev, "Regulator: %s get failed, err=%d\n", name, ret); - goto out; - } - - if (regulator_count_voltages(vreg) > 0) { - ret = regulator_set_voltage(vreg, min_uV, max_uV); - if (ret) { - dev_err(dev, "Regulator: %s set voltage failed, err=%d\n", - name, ret); - goto err; - } - - ret = regulator_set_optimum_mode(vreg, hpm_uA); - if (ret < 0) { - dev_err(dev, "Regulator: %s set optimum mode(uA_load=%d) failed, err=%d\n", - name, hpm_uA, ret); - goto err; - } else { - /* - * regulator_set_optimum_mode() can return non zero - * value even for success case. - */ - ret = 0; - } - } - - ret = regulator_enable(vreg); - if (ret) - dev_err(dev, "Regulator: %s enable failed, err=%d\n", - name, ret); -err: - if (!ret) - *out_vreg = vreg; - else - devm_regulator_put(vreg); -out: - return ret; -} - -static int msm_sata_vreg_put_disable(struct device *dev, - struct regulator *reg, const char *name, int max_uV) -{ - int ret; - - if (!reg) - return 0; - - ret = regulator_disable(reg); - if (ret) { - dev_err(dev, "Regulator: %s disable failed err=%d\n", - name, ret); - goto err; - } - - if (regulator_count_voltages(reg) > 0) { - ret = regulator_set_voltage(reg, 0, max_uV); - if (ret < 0) { - dev_err(dev, "Regulator: %s set voltage to 0 failed, err=%d\n", - name, ret); - goto err; - } - - ret = regulator_set_optimum_mode(reg, 0); - if (ret < 0) { - dev_err(dev, "Regulator: %s set optimum mode(uA_load = 0) failed, err=%d\n", - name, ret); - goto err; - } else { - /* - * regulator_set_optimum_mode() can return non zero - * value even for success case. - */ - ret = 0; - } - } - -err: - devm_regulator_put(reg); - return ret; -} - -static int msm_sata_vreg_init(struct device *dev) -{ - int ret = 0; - struct msm_sata_hba *hba = dev_get_drvdata(dev); - - /* - * The SATA clock generator needs 3.3V supply and can consume - * max. 850mA during functional mode. - */ - ret = msm_sata_vreg_get_enable_set_vdd(dev, "sata_ext_3p3v", - &hba->clk_pwr, 3300000, 3300000, 850000); - if (ret) - goto out; - - /* Add 1ms regulator ramp-up delay */ - msm_sata_delay_us(1000); - - /* Read AHCI capability register to check if PMP is supported.*/ - if (readl_relaxed(hba->ahci_base + - AHCI_HOST_CAP) & AHCI_HOST_CAP_PMP) { - /* Power up port-multiplier */ - ret = msm_sata_vreg_get_enable_set_vdd(dev, "sata_pmp_pwr", - &hba->pmp_pwr, 1800000, 1800000, 200000); - if (ret) { - msm_sata_vreg_put_disable(dev, hba->clk_pwr, - "sata_ext_3p3v", 3300000); - goto out; - } - - /* Add 1ms regulator ramp-up delay */ - msm_sata_delay_us(1000); - } - -out: - return ret; -} - -static void msm_sata_vreg_deinit(struct device *dev) -{ - struct msm_sata_hba *hba = dev_get_drvdata(dev); - - msm_sata_vreg_put_disable(dev, hba->clk_pwr, - "sata_ext_3p3v", 3300000); - - if (hba->pmp_pwr) - msm_sata_vreg_put_disable(dev, hba->pmp_pwr, - "sata_pmp_pwr", 1800000); -} - -static void msm_sata_phy_deinit(struct device *dev) -{ - struct msm_sata_hba *hba = dev_get_drvdata(dev); - - /* Power down PHY */ - writel_relaxed(0xF8, hba->phy_base + SATA_PHY_POW_DWN_CTRL0); - writel_relaxed(0xFE, hba->phy_base + SATA_PHY_POW_DWN_CTRL1); - - /* Power down PLL block */ - writel_relaxed(0x00, hba->phy_base + UNIPHY_PLL_GLB_CFG); - mb(); - - devm_iounmap(dev, hba->phy_base); -} - -static int msm_sata_phy_init(struct device *dev) -{ - int ret = 0; - u32 reg = 0; - struct platform_device *pdev = to_platform_device(dev); - struct msm_sata_hba *hba = dev_get_drvdata(dev); - struct resource *mem; - - mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy_mem"); - if (!mem) { - dev_err(dev, "no mmio space\n"); - return -EINVAL; - } - - hba->phy_base = devm_ioremap(dev, mem->start, resource_size(mem)); - if (!hba->phy_base) { - dev_err(dev, "failed to allocate memory for SATA PHY\n"); - return -ENOMEM; - } - - /* SATA phy initialization */ - - writel_relaxed(0x01, hba->phy_base + SATA_PHY_SER_CTRL); - - writel_relaxed(0xB1, hba->phy_base + SATA_PHY_POW_DWN_CTRL0); - mb(); - msm_sata_delay_us(10); - - writel_relaxed(0x01, hba->phy_base + SATA_PHY_POW_DWN_CTRL0); - writel_relaxed(0x3E, hba->phy_base + SATA_PHY_POW_DWN_CTRL1); - writel_relaxed(0x01, hba->phy_base + SATA_PHY_RX_IMCAL0); - writel_relaxed(0x01, hba->phy_base + SATA_PHY_TX_IMCAL0); - writel_relaxed(0x02, hba->phy_base + SATA_PHY_TX_IMCAL2); - - /* Write UNIPHYPLL registers to configure PLL */ - writel_relaxed(0x04, hba->phy_base + UNIPHY_PLL_REFCLK_CFG); - writel_relaxed(0x00, hba->phy_base + UNIPHY_PLL_PWRGEN_CFG); - - writel_relaxed(0x0A, hba->phy_base + UNIPHY_PLL_CAL_CFG0); - writel_relaxed(0xF3, hba->phy_base + UNIPHY_PLL_CAL_CFG8); - writel_relaxed(0x01, hba->phy_base + UNIPHY_PLL_CAL_CFG9); - writel_relaxed(0xED, hba->phy_base + UNIPHY_PLL_CAL_CFG10); - writel_relaxed(0x02, hba->phy_base + UNIPHY_PLL_CAL_CFG11); - - writel_relaxed(0x36, hba->phy_base + UNIPHY_PLL_SDM_CFG0); - writel_relaxed(0x0D, hba->phy_base + UNIPHY_PLL_SDM_CFG1); - writel_relaxed(0xA3, hba->phy_base + UNIPHY_PLL_SDM_CFG2); - writel_relaxed(0xF0, hba->phy_base + UNIPHY_PLL_SDM_CFG3); - writel_relaxed(0x00, hba->phy_base + UNIPHY_PLL_SDM_CFG4); - - writel_relaxed(0x19, hba->phy_base + UNIPHY_PLL_SSC_CFG0); - writel_relaxed(0xE1, hba->phy_base + UNIPHY_PLL_SSC_CFG1); - writel_relaxed(0x00, hba->phy_base + UNIPHY_PLL_SSC_CFG2); - writel_relaxed(0x11, hba->phy_base + UNIPHY_PLL_SSC_CFG3); - - writel_relaxed(0x04, hba->phy_base + UNIPHY_PLL_LKDET_CFG0); - writel_relaxed(0xFF, hba->phy_base + UNIPHY_PLL_LKDET_CFG1); - - writel_relaxed(0x02, hba->phy_base + UNIPHY_PLL_GLB_CFG); - mb(); - msm_sata_delay_us(40); - - writel_relaxed(0x03, hba->phy_base + UNIPHY_PLL_GLB_CFG); - mb(); - msm_sata_delay_us(400); - - writel_relaxed(0x05, hba->phy_base + UNIPHY_PLL_LKDET_CFG2); - mb(); - - /* poll for ready status, timeout after 1 sec */ - ret = readl_poll_timeout(hba->phy_base + UNIPHY_PLL_STATUS, reg, - (reg & 1 << 0), 100, 1000000); - if (ret) { - dev_err(dev, "poll timeout UNIPHY_PLL_STATUS\n"); - goto out; - } - - ret = readl_poll_timeout(hba->phy_base + SATA_PHY_TX_IMCAL_STAT, reg, - (reg & 1 << 0), 100, 1000000); - if (ret) { - dev_err(dev, "poll timeout SATA_PHY_TX_IMCAL_STAT\n"); - goto out; - } - - ret = readl_poll_timeout(hba->phy_base + SATA_PHY_RX_IMCAL_STAT, reg, - (reg & 1 << 0), 100, 1000000); - if (ret) { - dev_err(dev, "poll timeout SATA_PHY_RX_IMCAL_STAT\n"); - goto out; - } - - /* SATA phy calibrated succesfully, power up to functional mode */ - writel_relaxed(0x3E, hba->phy_base + SATA_PHY_POW_DWN_CTRL1); - writel_relaxed(0x01, hba->phy_base + SATA_PHY_RX_IMCAL0); - writel_relaxed(0x01, hba->phy_base + SATA_PHY_TX_IMCAL0); - - writel_relaxed(0x00, hba->phy_base + SATA_PHY_POW_DWN_CTRL1); - writel_relaxed(0x59, hba->phy_base + SATA_PHY_CDR_CTRL0); - writel_relaxed(0x04, hba->phy_base + SATA_PHY_CDR_CTRL1); - writel_relaxed(0x00, hba->phy_base + SATA_PHY_CDR_CTRL2); - writel_relaxed(0x00, hba->phy_base + SATA_PHY_PI_CTRL0); - writel_relaxed(0x00, hba->phy_base + SATA_PHY_CDR_CTRL3); - writel_relaxed(0x01, hba->phy_base + SATA_PHY_POW_DWN_CTRL0); - - writel_relaxed(0x11, hba->phy_base + SATA_PHY_TX_DATA_CTRL); - writel_relaxed(0x43, hba->phy_base + SATA_PHY_ALIGNP); - writel_relaxed(0x04, hba->phy_base + SATA_PHY_OOB_TERM); - - writel_relaxed(0x01, hba->phy_base + SATA_PHY_EQUAL); - writel_relaxed(0x09, hba->phy_base + SATA_PHY_TX_DRIV_CTRL0); - writel_relaxed(0x09, hba->phy_base + SATA_PHY_TX_DRIV_CTRL1); - mb(); - - dev_dbg(dev, "SATA PHY powered up in functional mode\n"); - -out: - /* power down PHY in case of failure */ - if (ret) - msm_sata_phy_deinit(dev); - - return ret; -} - -int msm_sata_init(struct device *ahci_dev, void __iomem *mmio) -{ - int ret; - struct device *dev = ahci_dev->parent; - struct msm_sata_hba *hba = dev_get_drvdata(dev); - - /* Save ahci mmio to access vendor specific registers */ - hba->ahci_base = mmio; - - ret = msm_sata_clk_init(dev); - if (ret) { - dev_err(dev, "SATA clk init failed with err=%d\n", ret); - goto out; - } - - ret = msm_sata_vreg_init(dev); - if (ret) { - dev_err(dev, "SATA vreg init failed with err=%d\n", ret); - msm_sata_clk_deinit(dev); - goto out; - } - - ret = msm_sata_phy_init(dev); - if (ret) { - dev_err(dev, "SATA PHY init failed with err=%d\n", ret); - msm_sata_vreg_deinit(dev); - msm_sata_clk_deinit(dev); - goto out; - } - -out: - return ret; -} - -void msm_sata_deinit(struct device *ahci_dev) -{ - struct device *dev = ahci_dev->parent; - - msm_sata_phy_deinit(dev); - msm_sata_vreg_deinit(dev); - msm_sata_clk_deinit(dev); -} - -static int msm_sata_suspend(struct device *ahci_dev) -{ - msm_sata_deinit(ahci_dev); - - return 0; -} - -static int msm_sata_resume(struct device *ahci_dev) -{ - int ret; - struct device *dev = ahci_dev->parent; - - ret = msm_sata_clk_init(dev); - if (ret) { - dev_err(dev, "SATA clk init failed with err=%d\n", ret); - /* - * If clock initialization failed, that means ahci driver - * cannot access any register going further. Since there is - * no check within ahci driver to check for clock failures, - * panic here instead of making an unclocked register access. - */ - BUG(); - } - - /* Issue asynchronous reset to reset PHY */ - ret = msm_sata_hard_reset(dev); - if (ret) - goto out; - - ret = msm_sata_vreg_init(dev); - if (ret) { - dev_err(dev, "SATA vreg init failed with err=%d\n", ret); - /* Do not turn off clks, AHCI driver might do register access */ - goto out; - } - - ret = msm_sata_phy_init(dev); - if (ret) { - dev_err(dev, "SATA PHY init failed with err=%d\n", ret); - /* Do not turn off clks, AHCI driver might do register access */ - msm_sata_vreg_deinit(dev); - goto out; - } -out: - return ret; -} - -static struct ahci_platform_data msm_ahci_pdata = { - .init = msm_sata_init, - .exit = msm_sata_deinit, - .suspend = msm_sata_suspend, - .resume = msm_sata_resume, -}; - -static int msm_sata_probe(struct platform_device *pdev) -{ - struct platform_device *ahci; - struct msm_sata_hba *hba; - int ret = 0; - - hba = devm_kzalloc(&pdev->dev, sizeof(struct msm_sata_hba), GFP_KERNEL); - if (!hba) { - dev_err(&pdev->dev, "no memory\n"); - ret = -ENOMEM; - goto err; - } - - platform_set_drvdata(pdev, hba); - - ahci = platform_device_alloc("ahci", pdev->id); - if (!ahci) { - dev_err(&pdev->dev, "couldn't allocate ahci device\n"); - ret = -ENOMEM; - goto err_free; - } - - dma_set_coherent_mask(&ahci->dev, pdev->dev.coherent_dma_mask); - - ahci->dev.parent = &pdev->dev; - ahci->dev.dma_mask = pdev->dev.dma_mask; - ahci->dev.dma_parms = pdev->dev.dma_parms; - hba->ahci_pdev = ahci; - - ret = platform_device_add_resources(ahci, pdev->resource, - pdev->num_resources); - if (ret) { - dev_err(&pdev->dev, "couldn't add resources to ahci device\n"); - goto err_put_device; - } - - ahci->dev.platform_data = &msm_ahci_pdata; - ret = platform_device_add(ahci); - if (ret) { - dev_err(&pdev->dev, "failed to register ahci device\n"); - goto err_put_device; - } - - return 0; - -err_put_device: - platform_device_put(ahci); -err_free: - devm_kfree(&pdev->dev, hba); -err: - return ret; -} - -static int msm_sata_remove(struct platform_device *pdev) -{ - struct msm_sata_hba *hba = platform_get_drvdata(pdev); - - platform_device_unregister(hba->ahci_pdev); - - return 0; -} - -static struct platform_driver msm_sata_driver = { - .probe = msm_sata_probe, - .remove = msm_sata_remove, - .driver = { - .name = "msm_sata", - }, -}; - -module_platform_driver(msm_sata_driver); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("AHCI platform MSM Glue Layer"); diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig index 856b67e698c053a9fb8ea16b918cad2e4e9d67c6..96f8cad0e9a4170e9e99fd572e055c9aa9a00280 100644 --- a/drivers/bluetooth/Kconfig +++ b/drivers/bluetooth/Kconfig @@ -2,16 +2,6 @@ menu "Bluetooth device drivers" depends on BT -config BT_HCISMD - tristate "HCI SMD driver" - help - Bluetooth HCI SMD driver. - This driver is required if you want to use Bluetoth device with - SMD interface. - - Say Y here to compile support for Bluetooth USB devices into the - kernel or say M to compile is as a module (hci_smd). - config BT_HCIBTUSB tristate "HCI USB driver" depends on USB diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile index 59206683c6e332c1e4e38990212d8a26ea8d48ab..9e5ebbd310014bcf00ea70ad0585e62086df076e 100644 --- a/drivers/bluetooth/Makefile +++ b/drivers/bluetooth/Makefile @@ -2,7 +2,6 @@ # Makefile for the Linux Bluetooth HCI device drivers. # -obj-$(CONFIG_BT_HCISMD) += hci_smd.o obj-$(CONFIG_BT_HCIVHCI) += hci_vhci.o obj-$(CONFIG_BT_HCIUART) += hci_uart.o obj-$(CONFIG_BT_HCIBCM203X) += bcm203x.o diff --git a/drivers/bluetooth/hci_smd.c b/drivers/bluetooth/hci_smd.c deleted file mode 100644 index 90e7263d9089aa60f85ea30ea9e40ad1b15f38d5..0000000000000000000000000000000000000000 --- a/drivers/bluetooth/hci_smd.c +++ /dev/null @@ -1,680 +0,0 @@ -/* - * HCI_SMD (HCI Shared Memory Driver) is Qualcomm's Shared memory driver - * for the BT HCI protocol. - * - * Copyright (c) 2000-2001, 2011-2012 The Linux Foundation. All rights reserved. - * Copyright (C) 2002-2003 Maxim Krasnyansky - * Copyright (C) 2004-2006 Marcel Holtmann - * - * This file is based on drivers/bluetooth/hci_vhci.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define EVENT_CHANNEL "APPS_RIVA_BT_CMD" -#define DATA_CHANNEL "APPS_RIVA_BT_ACL" -/* release wakelock in 500ms, not immediately, because higher layers - * don't always take wakelocks when they should - * This is derived from the implementation for UART transport - */ - -#define RX_Q_MONITOR (500) /* 500 milli second */ -#define HCI_REGISTER_SET 0 - -/* SSR state machine to take care of back to back SSR requests - * and handling the incomming BT on/off,Airplane mode toggling and - * also spuriour SMD open notification while one SSr is in progress - */ -#define STATE_SSR_ON 0x1 -#define STATE_SSR_START 0x02 -#define STATE_SSR_CHANNEL_OPEN_PENDING 0x04 -#define STATE_SSR_PENDING_INIT 0x08 -#define STATE_SSR_COMPLETE 0x00 -#define STATE_SSR_OFF STATE_SSR_COMPLETE - -static int ssr_state = STATE_SSR_OFF; - - -static int hcismd_set; -static DEFINE_SEMAPHORE(hci_smd_enable); - -static int restart_in_progress; - -static int hcismd_set_enable(const char *val, struct kernel_param *kp); -module_param_call(hcismd_set, hcismd_set_enable, NULL, &hcismd_set, 0644); - -static void hci_dev_smd_open(struct work_struct *worker); -static void hci_dev_restart(struct work_struct *worker); - -struct hci_smd_data { - struct hci_dev *hdev; - unsigned long flags; - struct smd_channel *event_channel; - struct smd_channel *data_channel; - struct wake_lock wake_lock_tx; - struct wake_lock wake_lock_rx; - struct timer_list rx_q_timer; - struct tasklet_struct rx_task; -}; -static struct hci_smd_data hs; - -/* Rx queue monitor timer function */ -static int is_rx_q_empty(unsigned long arg) -{ - struct hci_dev *hdev = (struct hci_dev *) arg; - struct sk_buff_head *list_ = &hdev->rx_q; - struct sk_buff *list = ((struct sk_buff *)list_)->next; - BT_DBG("%s Rx timer triggered", hdev->name); - - if (list == (struct sk_buff *)list_) { - BT_DBG("%s RX queue empty", hdev->name); - return 1; - } else{ - BT_DBG("%s RX queue not empty", hdev->name); - return 0; - } -} - -static void release_lock(void) -{ - struct hci_smd_data *hsmd = &hs; - BT_DBG("Releasing Rx Lock"); - if (is_rx_q_empty((unsigned long)hsmd->hdev) && - wake_lock_active(&hs.wake_lock_rx)) - wake_unlock(&hs.wake_lock_rx); -} - -/* Rx timer callback function */ -static void schedule_timer(unsigned long arg) -{ - struct hci_dev *hdev = (struct hci_dev *) arg; - struct hci_smd_data *hsmd = &hs; - BT_DBG("%s Schedule Rx timer", hdev->name); - - if (is_rx_q_empty(arg) && wake_lock_active(&hs.wake_lock_rx)) { - BT_DBG("%s RX queue empty", hdev->name); - /* - * Since the queue is empty, its ideal - * to release the wake lock on Rx - */ - wake_unlock(&hs.wake_lock_rx); - } else{ - BT_DBG("%s RX queue not empty", hdev->name); - /* - * Restart the timer to monitor whether the Rx queue is - * empty for releasing the Rx wake lock - */ - mod_timer(&hsmd->rx_q_timer, - jiffies + msecs_to_jiffies(RX_Q_MONITOR)); - } -} - -static int hci_smd_open(struct hci_dev *hdev) -{ - set_bit(HCI_RUNNING, &hdev->flags); - return 0; -} - - -static int hci_smd_close(struct hci_dev *hdev) -{ - if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) - return 0; - else - return -EPERM; -} - - -static void hci_smd_destruct(struct hci_dev *hdev) -{ - if (NULL != hdev->driver_data) - kfree(hdev->driver_data); -} - -static void hci_smd_recv_data(void) -{ - int len = 0; - int rc = 0; - struct sk_buff *skb = NULL; - struct hci_smd_data *hsmd = &hs; - wake_lock(&hs.wake_lock_rx); - - len = smd_read_avail(hsmd->data_channel); - if (len > HCI_MAX_FRAME_SIZE) { - BT_ERR("Frame larger than the allowed size, flushing frame"); - smd_read(hsmd->data_channel, NULL, len); - goto out_data; - } - - if (len <= 0) - goto out_data; - - skb = bt_skb_alloc(len, GFP_ATOMIC); - if (!skb) { - BT_ERR("Error in allocating socket buffer"); - smd_read(hsmd->data_channel, NULL, len); - goto out_data; - } - - rc = smd_read(hsmd->data_channel, skb_put(skb, len), len); - if (rc < len) { - BT_ERR("Error in reading from the channel"); - goto out_data; - } - - skb->dev = (void *)hsmd->hdev; - bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; - skb_orphan(skb); - - rc = hci_recv_frame(skb); - if (rc < 0) { - BT_ERR("Error in passing the packet to HCI Layer"); - /* - * skb is getting freed in hci_recv_frame, making it - * to null to avoid multiple access - */ - skb = NULL; - goto out_data; - } - - /* - * Start the timer to monitor whether the Rx queue is - * empty for releasing the Rx wake lock - */ - BT_DBG("Rx Timer is starting"); - mod_timer(&hsmd->rx_q_timer, - jiffies + msecs_to_jiffies(RX_Q_MONITOR)); - -out_data: - release_lock(); - if (rc) - kfree_skb(skb); -} - -static void hci_smd_recv_event(void) -{ - int len = 0; - int rc = 0; - struct sk_buff *skb = NULL; - struct hci_smd_data *hsmd = &hs; - wake_lock(&hs.wake_lock_rx); - - len = smd_read_avail(hsmd->event_channel); - if (len > HCI_MAX_FRAME_SIZE) { - BT_ERR("Frame larger than the allowed size, flushing frame"); - rc = smd_read(hsmd->event_channel, NULL, len); - goto out_event; - } - - while (len > 0) { - skb = bt_skb_alloc(len, GFP_ATOMIC); - if (!skb) { - BT_ERR("Error in allocating socket buffer"); - smd_read(hsmd->event_channel, NULL, len); - goto out_event; - } - - rc = smd_read(hsmd->event_channel, skb_put(skb, len), len); - if (rc < len) { - BT_ERR("Error in reading from the event channel"); - goto out_event; - } - - skb->dev = (void *)hsmd->hdev; - bt_cb(skb)->pkt_type = HCI_EVENT_PKT; - - skb_orphan(skb); - - rc = hci_recv_frame(skb); - if (rc < 0) { - BT_ERR("Error in passing the packet to HCI Layer"); - /* - * skb is getting freed in hci_recv_frame, making it - * to null to avoid multiple access - */ - skb = NULL; - goto out_event; - } - - len = smd_read_avail(hsmd->event_channel); - /* - * Start the timer to monitor whether the Rx queue is - * empty for releasing the Rx wake lock - */ - BT_DBG("Rx Timer is starting"); - mod_timer(&hsmd->rx_q_timer, - jiffies + msecs_to_jiffies(RX_Q_MONITOR)); - } -out_event: - release_lock(); - if (rc) - kfree_skb(skb); -} - -static int hci_smd_send_frame(struct sk_buff *skb) -{ - int len; - int avail; - int ret = 0; - wake_lock(&hs.wake_lock_tx); - - switch (bt_cb(skb)->pkt_type) { - case HCI_COMMAND_PKT: - avail = smd_write_avail(hs.event_channel); - if (!avail) { - BT_ERR("No space available for smd frame"); - ret = -ENOSPC; - } - len = smd_write(hs.event_channel, skb->data, skb->len); - if (len < skb->len) { - BT_ERR("Failed to write Command %d", len); - ret = -ENODEV; - } - break; - case HCI_ACLDATA_PKT: - case HCI_SCODATA_PKT: - avail = smd_write_avail(hs.data_channel); - if (!avail) { - BT_ERR("No space available for smd frame"); - ret = -ENOSPC; - } - len = smd_write(hs.data_channel, skb->data, skb->len); - if (len < skb->len) { - BT_ERR("Failed to write Data %d", len); - ret = -ENODEV; - } - break; - default: - BT_ERR("Uknown packet type"); - ret = -ENODEV; - break; - } - - kfree_skb(skb); - wake_unlock(&hs.wake_lock_tx); - return ret; -} - -static void hci_smd_rx(unsigned long arg) -{ - struct hci_smd_data *hsmd = &hs; - - while ((smd_read_avail(hsmd->event_channel) > 0) || - (smd_read_avail(hsmd->data_channel) > 0)) { - hci_smd_recv_event(); - hci_smd_recv_data(); - } -} - -static void hci_smd_notify_event(void *data, unsigned int event) -{ - struct hci_dev *hdev = hs.hdev; - struct hci_smd_data *hsmd = &hs; - struct work_struct *reset_worker; - struct work_struct *open_worker; - - int len = 0; - - if (!hdev) { - BT_ERR("Frame for unknown HCI device (hdev=NULL)"); - return; - } - - switch (event) { - case SMD_EVENT_DATA: - len = smd_read_avail(hsmd->event_channel); - if (len > 0) - tasklet_hi_schedule(&hs.rx_task); - else if (len < 0) - BT_ERR("Failed to read event from smd %d", len); - - break; - case SMD_EVENT_OPEN: - BT_INFO("opening HCI-SMD channel :%s", EVENT_CHANNEL); - BT_DBG("SSR state is : %x", ssr_state); - if ((ssr_state == STATE_SSR_OFF) || - (ssr_state == STATE_SSR_CHANNEL_OPEN_PENDING)) { - - hci_smd_open(hdev); - open_worker = kzalloc(sizeof(*open_worker), GFP_ATOMIC); - if (!open_worker) { - BT_ERR("Out of memory"); - break; - } - if (ssr_state == STATE_SSR_CHANNEL_OPEN_PENDING) { - ssr_state = STATE_SSR_PENDING_INIT; - BT_INFO("SSR state is : %x", ssr_state); - } - INIT_WORK(open_worker, hci_dev_smd_open); - schedule_work(open_worker); - - } - break; - case SMD_EVENT_CLOSE: - BT_INFO("Closing HCI-SMD channel :%s", EVENT_CHANNEL); - BT_DBG("SSR state is : %x", ssr_state); - if ((ssr_state == STATE_SSR_OFF) || - (ssr_state == (STATE_SSR_PENDING_INIT))) { - - hci_smd_close(hdev); - reset_worker = kzalloc(sizeof(*reset_worker), - GFP_ATOMIC); - if (!reset_worker) { - BT_ERR("Out of memory"); - break; - } - ssr_state = STATE_SSR_ON; - BT_INFO("SSR state is : %x", ssr_state); - INIT_WORK(reset_worker, hci_dev_restart); - schedule_work(reset_worker); - - } else if (ssr_state & STATE_SSR_ON) { - BT_ERR("SSR state is : %x", ssr_state); - } - - break; - default: - break; - } -} - -static void hci_smd_notify_data(void *data, unsigned int event) -{ - struct hci_dev *hdev = hs.hdev; - struct hci_smd_data *hsmd = &hs; - int len = 0; - - if (!hdev) { - BT_ERR("Frame for unknown HCI device (hdev=NULL)"); - return; - } - - switch (event) { - case SMD_EVENT_DATA: - len = smd_read_avail(hsmd->data_channel); - if (len > 0) - tasklet_hi_schedule(&hs.rx_task); - else if (len < 0) - BT_ERR("Failed to read data from smd %d", len); - break; - case SMD_EVENT_OPEN: - BT_INFO("opening HCI-SMD channel :%s", DATA_CHANNEL); - hci_smd_open(hdev); - break; - case SMD_EVENT_CLOSE: - BT_INFO("Closing HCI-SMD channel :%s", DATA_CHANNEL); - hci_smd_close(hdev); - break; - default: - break; - } - -} - -static int hci_smd_hci_register_dev(struct hci_smd_data *hsmd) -{ - struct hci_dev *hdev; - - if (hsmd->hdev) - hdev = hsmd->hdev; - else { - BT_ERR("hdev is NULL"); - return 0; - } - /* Allow the incomming SSR even the prev one at PENDING INIT STATE - * since clenup need to be started again from the beging and ignore - * or bypass the prev one - */ - if ((ssr_state == STATE_SSR_OFF) || - (ssr_state == STATE_SSR_PENDING_INIT)) { - - if (test_and_set_bit(HCI_REGISTER_SET, &hsmd->flags)) { - BT_ERR("HCI device registered already"); - return 0; - } else - BT_INFO("HCI device registration is starting"); - if (hci_register_dev(hdev) < 0) { - BT_ERR("Can't register HCI device"); - hci_free_dev(hdev); - hsmd->hdev = NULL; - clear_bit(HCI_REGISTER_SET, &hsmd->flags); - return -ENODEV; - } - if (ssr_state == STATE_SSR_PENDING_INIT) { - ssr_state = STATE_SSR_COMPLETE; - BT_INFO("SSR state is : %x", ssr_state); - } - } else if (ssr_state) - BT_ERR("Registration called in invalid context"); - return 0; -} - -static int hci_smd_register_smd(struct hci_smd_data *hsmd) -{ - struct hci_dev *hdev; - int rc; - - /* Initialize and register HCI device */ - hdev = hci_alloc_dev(); - if (!hdev) { - BT_ERR("Can't allocate HCI device"); - return -ENOMEM; - } - - hsmd->hdev = hdev; - hdev->bus = HCI_SMD; - hdev->driver_data = NULL; - hdev->open = hci_smd_open; - hdev->close = hci_smd_close; - hdev->send = hci_smd_send_frame; - hdev->destruct = hci_smd_destruct; - hdev->owner = THIS_MODULE; - - - tasklet_init(&hsmd->rx_task, - hci_smd_rx, (unsigned long) hsmd); - /* - * Setup the timer to monitor whether the Rx queue is empty, - * to control the wake lock release - */ - setup_timer(&hsmd->rx_q_timer, schedule_timer, - (unsigned long) hsmd->hdev); - if (ssr_state == STATE_SSR_START) { - ssr_state = STATE_SSR_CHANNEL_OPEN_PENDING; - BT_INFO("SSR state is : %x", ssr_state); - } - /* Open the SMD Channel and device and register the callback function */ - rc = smd_named_open_on_edge(EVENT_CHANNEL, SMD_APPS_WCNSS, - &hsmd->event_channel, hdev, hci_smd_notify_event); - if (rc < 0) { - BT_ERR("Cannot open the command channel"); - hci_free_dev(hdev); - hsmd->hdev = NULL; - return -ENODEV; - } - - rc = smd_named_open_on_edge(DATA_CHANNEL, SMD_APPS_WCNSS, - &hsmd->data_channel, hdev, hci_smd_notify_data); - if (rc < 0) { - BT_ERR("Failed to open the Data channel"); - hci_free_dev(hdev); - hsmd->hdev = NULL; - return -ENODEV; - } - - /* Disable the read interrupts on the channel */ - smd_disable_read_intr(hsmd->event_channel); - smd_disable_read_intr(hsmd->data_channel); - return 0; -} - -static void hci_smd_deregister_dev(struct hci_smd_data *hsmd) -{ - tasklet_kill(&hs.rx_task); - if (ssr_state) - BT_DBG("SSR state is : %x", ssr_state); - /* Though the hci_smd driver is not registered with the hci - * need to close the opened channels as a part of cleaup - */ - if (!test_and_clear_bit(HCI_REGISTER_SET, &hsmd->flags)) { - BT_ERR("HCI device un-registered already"); - } else { - BT_INFO("HCI device un-registration going on"); - - if (hsmd->hdev) { - if (hci_unregister_dev(hsmd->hdev) < 0) - BT_ERR("Can't unregister HCI device %s", - hsmd->hdev->name); - - hci_free_dev(hsmd->hdev); - hsmd->hdev = NULL; - } - } - smd_close(hs.event_channel); - smd_close(hs.data_channel); - - if (wake_lock_active(&hs.wake_lock_rx)) - wake_unlock(&hs.wake_lock_rx); - if (wake_lock_active(&hs.wake_lock_tx)) - wake_unlock(&hs.wake_lock_tx); - - /*Destroy the timer used to monitor the Rx queue for emptiness */ - if (hs.rx_q_timer.function) { - del_timer_sync(&hs.rx_q_timer); - hs.rx_q_timer.function = NULL; - hs.rx_q_timer.data = 0; - } -} - -static void hci_dev_restart(struct work_struct *worker) -{ - down(&hci_smd_enable); - restart_in_progress = 1; - BT_DBG("SSR state is : %x", ssr_state); - - if (ssr_state == STATE_SSR_ON) { - ssr_state = STATE_SSR_START; - BT_INFO("SSR state is : %x", ssr_state); - } else { - BT_ERR("restart triggered in wrong context"); - up(&hci_smd_enable); - kfree(worker); - return; - } - hci_smd_deregister_dev(&hs); - hci_smd_register_smd(&hs); - up(&hci_smd_enable); - kfree(worker); - -} - -static void hci_dev_smd_open(struct work_struct *worker) -{ - down(&hci_smd_enable); - if (ssr_state) - BT_DBG("SSR state is : %x", ssr_state); - - if ((ssr_state != STATE_SSR_OFF) && - (ssr_state != (STATE_SSR_PENDING_INIT))) { - up(&hci_smd_enable); - kfree(worker); - return; - } - - if (restart_in_progress == 1) { - /* Allow wcnss to initialize */ - restart_in_progress = 0; - msleep(10000); - } - - hci_smd_hci_register_dev(&hs); - up(&hci_smd_enable); - kfree(worker); - -} - -static int hcismd_set_enable(const char *val, struct kernel_param *kp) -{ - int ret = 0; - - pr_err("hcismd_set_enable %d", hcismd_set); - - down(&hci_smd_enable); - - ret = param_set_int(val, kp); - - if (ret) - goto done; - - /* Ignore the all incomming register de-register requests in case of - * SSR is in-progress - */ - switch (hcismd_set) { - - case 1: - if ((hs.hdev == NULL) && (ssr_state == STATE_SSR_OFF)) - hci_smd_register_smd(&hs); - else if (ssr_state) - BT_ERR("SSR is in progress,state is : %x", ssr_state); - - break; - case 0: - if (ssr_state == STATE_SSR_OFF) - hci_smd_deregister_dev(&hs); - else if (ssr_state) - BT_ERR("SSR is in progress,state is : %x", ssr_state); - break; - default: - ret = -EFAULT; - } - -done: - up(&hci_smd_enable); - return ret; -} -static int __init hci_smd_init(void) -{ - wake_lock_init(&hs.wake_lock_rx, WAKE_LOCK_SUSPEND, - "msm_smd_Rx"); - wake_lock_init(&hs.wake_lock_tx, WAKE_LOCK_SUSPEND, - "msm_smd_Tx"); - restart_in_progress = 0; - ssr_state = STATE_SSR_OFF; - hs.hdev = NULL; - return 0; -} -module_init(hci_smd_init); - -static void __exit hci_smd_exit(void) -{ - wake_lock_destroy(&hs.wake_lock_rx); - wake_lock_destroy(&hs.wake_lock_tx); -} -module_exit(hci_smd_exit); - -MODULE_AUTHOR("Ankur Nandwani "); -MODULE_DESCRIPTION("Bluetooth SMD driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 0084332b7c8797bae7c7ab71957f7522fa859cf5..2b870dfacb8a009e04f6ff1299c2a7238906b6bb 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -620,14 +620,6 @@ config TILE_SROM device appear much like a simple EEPROM, and knows how to partition a single ROM for multiple purposes. -config MSM_ROTATOR - tristate "MSM Offline Image Rotator Driver" - depends on (ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_MSM8960) - default y - help - This driver provides support for the image rotator HW block in the - MSM 7x30 SoC. - config MSM_ROTATOR_USE_IMEM bool "Enable rotator driver to use iMem" depends on ARCH_MSM7X30 && MSM_ROTATOR @@ -647,13 +639,6 @@ config MSM_ADSPRPC applications DSP processor. Say M if you want to enable this module. -config MMC_GENERIC_CSDIO - tristate "Generic sdio driver" - default n - help - SDIO function driver that extends SDIO card as character device - in user space. - config CSDIO_VENDOR_ID hex "Card VendorId" depends on MMC_GENERIC_CSDIO diff --git a/drivers/char/Makefile b/drivers/char/Makefile index dfb5b5ed740adeab21c7c137ce17dc1f0d457462..ca2b4fb51043c38841db19f2656d4b98a599291e 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -61,8 +61,6 @@ obj-$(CONFIG_JS_RTC) += js-rtc.o js-rtc-y = rtc.o obj-$(CONFIG_TILE_SROM) += tile-srom.o -obj-$(CONFIG_MSM_ROTATOR) += msm_rotator.o -obj-$(CONFIG_MMC_GENERIC_CSDIO) += csdio.o obj-$(CONFIG_DIAG_CHAR) += diag/ obj-$(CONFIG_MSM_ADSPRPC) += adsprpc.o obj-$(CONFIG_MSM_RDBG) += rdbg.o diff --git a/drivers/char/csdio.c b/drivers/char/csdio.c deleted file mode 100644 index 85306d35fe07d9932c506c2e179091cdda537ed9..0000000000000000000000000000000000000000 --- a/drivers/char/csdio.c +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * Copyright (c) 2010, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Char device */ -#include -#include - -/* Sdio device */ -#include -#include -#include -#include -#include -#include - -#include - -#define FALSE 0 -#define TRUE 1 - -#define VERSION "0.5" -#define CSDIO_NUM_OF_SDIO_FUNCTIONS 7 -#define CSDIO_DEV_NAME "csdio" -#define TP_DEV_NAME CSDIO_DEV_NAME"f" -#define CSDIO_DEV_PERMISSIONS 0666 - -#define CSDIO_SDIO_BUFFER_SIZE (64*512) - -int csdio_major; -int csdio_minor; -int csdio_transport_nr_devs = CSDIO_NUM_OF_SDIO_FUNCTIONS; -static uint csdio_vendor_id; -static uint csdio_device_id; -static char *host_name; - -static struct csdio_func_t { - struct sdio_func *m_func; - int m_enabled; - struct cdev m_cdev; /* char device structure */ - struct device *m_device; - u32 m_block_size; -} *g_csdio_func_table[CSDIO_NUM_OF_SDIO_FUNCTIONS] = {0}; - -struct csdio_t { - struct cdev m_cdev; - struct device *m_device; - struct class *m_driver_class; - struct fasync_struct *m_async_queue; - unsigned char m_current_irq_mask; /* currently enabled irqs */ - struct mmc_host *m_host; - unsigned int m_num_of_func; -} g_csdio; - -struct csdio_file_descriptor { - struct csdio_func_t *m_port; - u32 m_block_mode;/* data tran. byte(0)/block(1) */ - u32 m_op_code; /* address auto increment flag */ - u32 m_address; -}; - -static void *g_sdio_buffer; - -/* - * Open and release - */ -static int csdio_transport_open(struct inode *inode, struct file *filp) -{ - int ret = 0; - struct csdio_func_t *port = NULL; /* device information */ - struct sdio_func *func = NULL; - struct csdio_file_descriptor *descriptor = NULL; - - port = container_of(inode->i_cdev, struct csdio_func_t, m_cdev); - func = port->m_func; - descriptor = kzalloc(sizeof(struct csdio_file_descriptor), GFP_KERNEL); - if (!descriptor) { - ret = -ENOMEM; - goto exit; - } - - pr_info(TP_DEV_NAME"%d: open: func=%p, port=%p\n", - func->num, func, port); - sdio_claim_host(func); - ret = sdio_enable_func(func); - if (ret) { - pr_err(TP_DEV_NAME"%d:Enable func failed (%d)\n", - func->num, ret); - ret = -EIO; - goto free_descriptor; - } - descriptor->m_port = port; - filp->private_data = descriptor; - goto release_host; - -free_descriptor: - kfree(descriptor); -release_host: - sdio_release_host(func); -exit: - return ret; -} - -static int csdio_transport_release(struct inode *inode, struct file *filp) -{ - int ret = 0; - struct csdio_file_descriptor *descriptor = filp->private_data; - struct csdio_func_t *port = descriptor->m_port; - struct sdio_func *func = port->m_func; - - pr_info(TP_DEV_NAME"%d: release\n", func->num); - sdio_claim_host(func); - ret = sdio_disable_func(func); - if (ret) { - pr_err(TP_DEV_NAME"%d:Disable func failed(%d)\n", - func->num, ret); - ret = -EIO; - } - sdio_release_host(func); - kfree(descriptor); - return ret; -} - -/* - * Data management: read and write - */ -static ssize_t csdio_transport_read(struct file *filp, - char __user *buf, - size_t count, - loff_t *f_pos) -{ - ssize_t ret = 0; - struct csdio_file_descriptor *descriptor = filp->private_data; - struct csdio_func_t *port = descriptor->m_port; - struct sdio_func *func = port->m_func; - size_t t_count = count; - - if (descriptor->m_block_mode) { - pr_info(TP_DEV_NAME "%d: CMD53 read, Md:%d, Addr:0x%04X," - " Un:%d (Bl:%d, BlSz:%d)\n", func->num, - descriptor->m_block_mode, - descriptor->m_address, - count*port->m_block_size, - count, port->m_block_size); - /* recalculate size */ - count *= port->m_block_size; - } - sdio_claim_host(func); - if (descriptor->m_op_code) { - /* auto increment */ - ret = sdio_memcpy_fromio(func, g_sdio_buffer, - descriptor->m_address, count); - } else { /* FIFO */ - ret = sdio_readsb(func, g_sdio_buffer, - descriptor->m_address, count); - } - sdio_release_host(func); - if (!ret) { - if (copy_to_user(buf, g_sdio_buffer, count)) - ret = -EFAULT; - else - ret = t_count; - } - if (ret < 0) { - pr_err(TP_DEV_NAME "%d: CMD53 read failed (%d)" - "(Md:%d, Addr:0x%04X, Sz:%d)\n", - func->num, ret, - descriptor->m_block_mode, - descriptor->m_address, count); - } - return ret; -} - -static ssize_t csdio_transport_write(struct file *filp, - const char __user *buf, - size_t count, - loff_t *f_pos) -{ - ssize_t ret = 0; - struct csdio_file_descriptor *descriptor = filp->private_data; - struct csdio_func_t *port = descriptor->m_port; - struct sdio_func *func = port->m_func; - size_t t_count = count; - - if (descriptor->m_block_mode) - count *= port->m_block_size; - - if (copy_from_user(g_sdio_buffer, buf, count)) { - pr_err(TP_DEV_NAME"%d:copy_from_user failed\n", func->num); - ret = -EFAULT; - } else { - sdio_claim_host(func); - if (descriptor->m_op_code) { - /* auto increment */ - ret = sdio_memcpy_toio(func, descriptor->m_address, - g_sdio_buffer, count); - } else { - /* FIFO */ - ret = sdio_writesb(func, descriptor->m_address, - g_sdio_buffer, count); - } - sdio_release_host(func); - if (!ret) { - ret = t_count; - } else { - pr_err(TP_DEV_NAME "%d: CMD53 write failed (%d)" - "(Md:%d, Addr:0x%04X, Sz:%d)\n", - func->num, ret, descriptor->m_block_mode, - descriptor->m_address, count); - } - } - return ret; -} - -/* disable interrupt for sdio client */ -static int disable_sdio_client_isr(struct sdio_func *func) -{ - int ret; - - /* disable for all functions, to restore interrupts - * use g_csdio.m_current_irq_mask */ - sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &ret); - if (ret) - pr_err(CSDIO_DEV_NAME" Can't sdio_f0_writeb (%d)\n", ret); - - return ret; -} - -/* - * This handles the interrupt from SDIO. - */ -static void csdio_sdio_irq(struct sdio_func *func) -{ - int ret; - - pr_info(CSDIO_DEV_NAME" csdio_sdio_irq: func=%d\n", func->num); - ret = disable_sdio_client_isr(func); - if (ret) { - pr_err(CSDIO_DEV_NAME" Can't disable client isr(%d)\n", ret); - return; - } - /* signal asynchronous readers */ - if (g_csdio.m_async_queue) - kill_fasync(&g_csdio.m_async_queue, SIGIO, POLL_IN); -} - -/* - * The ioctl() implementation - */ -static int csdio_transport_ioctl(struct inode *inode, - struct file *filp, - unsigned int cmd, - unsigned long arg) -{ - int err = 0; - int ret = 0; - struct csdio_file_descriptor *descriptor = filp->private_data; - struct csdio_func_t *port = descriptor->m_port; - struct sdio_func *func = port->m_func; - - /* extract the type and number bitfields - sanity check: return ENOTTY (inappropriate ioctl) before - access_ok() - */ - if ((_IOC_TYPE(cmd) != CSDIO_IOC_MAGIC) || - (_IOC_NR(cmd) > CSDIO_IOC_MAXNR)) { - pr_err(TP_DEV_NAME "Wrong ioctl command parameters\n"); - ret = -ENOTTY; - goto exit; - } - - /* the direction is a bitmask, and VERIFY_WRITE catches R/W - * transfers. `Type' is user-oriented, while access_ok is - kernel-oriented, so the concept of "read" and "write" is reversed - */ - if (_IOC_DIR(cmd) & _IOC_READ) { - err = !access_ok(VERIFY_WRITE, (void __user *)arg, - _IOC_SIZE(cmd)); - } else { - if (_IOC_DIR(cmd) & _IOC_WRITE) { - err = !access_ok(VERIFY_READ, (void __user *)arg, - _IOC_SIZE(cmd)); - } - } - if (err) { - pr_err(TP_DEV_NAME "Wrong ioctl access direction\n"); - ret = -EFAULT; - goto exit; - } - - switch (cmd) { - case CSDIO_IOC_SET_OP_CODE: - { - pr_info(TP_DEV_NAME"%d:SET_OP_CODE=%d\n", - func->num, descriptor->m_op_code); - ret = get_user(descriptor->m_op_code, - (unsigned char __user *)arg); - if (ret) { - pr_err(TP_DEV_NAME"%d:SET_OP_CODE get data" - " from user space failed(%d)\n", - func->num, ret); - ret = -ENOTTY; - break; - } - } - break; - case CSDIO_IOC_FUNCTION_SET_BLOCK_SIZE: - { - unsigned block_size; - - ret = get_user(block_size, (unsigned __user *)arg); - if (ret) { - pr_err(TP_DEV_NAME"%d:SET_BLOCK_SIZE get data" - " from user space failed(%d)\n", - func->num, ret); - ret = -ENOTTY; - break; - } - pr_info(TP_DEV_NAME"%d:SET_BLOCK_SIZE=%d\n", - func->num, block_size); - sdio_claim_host(func); - ret = sdio_set_block_size(func, block_size); - if (!ret) { - port->m_block_size = block_size; - } else { - pr_err(TP_DEV_NAME"%d:SET_BLOCK_SIZE set block" - " size to %d failed (%d)\n", - func->num, block_size, ret); - ret = -ENOTTY; - break; - } - sdio_release_host(func); - } - break; - case CSDIO_IOC_SET_BLOCK_MODE: - { - pr_info(TP_DEV_NAME"%d:SET_BLOCK_MODE=%d\n", - func->num, descriptor->m_block_mode); - ret = get_user(descriptor->m_block_mode, - (unsigned char __user *)arg); - if (ret) { - pr_err(TP_DEV_NAME"%d:SET_BLOCK_MODE get data" - " from user space failed\n", - func->num); - ret = -ENOTTY; - break; - } - } - break; - case CSDIO_IOC_CMD52: - { - struct csdio_cmd52_ctrl_t cmd52ctrl; - int cmd52ret; - - if (copy_from_user(&cmd52ctrl, - (const unsigned char __user *)arg, - sizeof(cmd52ctrl))) { - pr_err(TP_DEV_NAME"%d:IOC_CMD52 get data" - " from user space failed\n", - func->num); - ret = -ENOTTY; - break; - } - sdio_claim_host(func); - if (cmd52ctrl.m_write) - sdio_writeb(func, cmd52ctrl.m_data, - cmd52ctrl.m_address, &cmd52ret); - else - cmd52ctrl.m_data = sdio_readb(func, - cmd52ctrl.m_address, &cmd52ret); - - cmd52ctrl.m_ret = cmd52ret; - sdio_release_host(func); - if (cmd52ctrl.m_ret) - pr_err(TP_DEV_NAME"%d:IOC_CMD52 failed (%d)\n", - func->num, cmd52ctrl.m_ret); - - if (copy_to_user((unsigned char __user *)arg, - &cmd52ctrl, - sizeof(cmd52ctrl))) { - pr_err(TP_DEV_NAME"%d:IOC_CMD52 put data" - " to user space failed\n", - func->num); - ret = -ENOTTY; - break; - } - } - break; - case CSDIO_IOC_CMD53: - { - struct csdio_cmd53_ctrl_t csdio_cmd53_ctrl; - - if (copy_from_user(&csdio_cmd53_ctrl, - (const char __user *)arg, - sizeof(csdio_cmd53_ctrl))) { - ret = -EPERM; - pr_err(TP_DEV_NAME"%d:" - "Get data from user space failed\n", - func->num); - break; - } - descriptor->m_block_mode = - csdio_cmd53_ctrl.m_block_mode; - descriptor->m_op_code = csdio_cmd53_ctrl.m_op_code; - descriptor->m_address = csdio_cmd53_ctrl.m_address; - } - break; - case CSDIO_IOC_CONNECT_ISR: - { - pr_info(CSDIO_DEV_NAME" SDIO_CONNECT_ISR" - " func=%d, csdio_sdio_irq=%x\n", - func->num, (unsigned int)csdio_sdio_irq); - sdio_claim_host(func); - ret = sdio_claim_irq(func, csdio_sdio_irq); - sdio_release_host(func); - if (ret) { - pr_err(CSDIO_DEV_NAME" SDIO_CONNECT_ISR" - " claim irq failed(%d)\n", ret); - } else { - /* update current irq mask for disable/enable */ - g_csdio.m_current_irq_mask |= (1 << func->num); - } - } - break; - case CSDIO_IOC_DISCONNECT_ISR: - { - pr_info(CSDIO_DEV_NAME " SDIO_DISCONNECT_ISR func=%d\n", - func->num); - sdio_claim_host(func); - sdio_release_irq(func); - sdio_release_host(func); - /* update current irq mask for disable/enable */ - g_csdio.m_current_irq_mask &= ~(1 << func->num); - } - break; - default: /* redundant, as cmd was checked against MAXNR */ - pr_warning(TP_DEV_NAME"%d: Redundant IOCTL\n", - func->num); - ret = -ENOTTY; - } -exit: - return ret; -} - -static const struct file_operations csdio_transport_fops = { - .owner = THIS_MODULE, - .read = csdio_transport_read, - .write = csdio_transport_write, - .ioctl = csdio_transport_ioctl, - .open = csdio_transport_open, - .release = csdio_transport_release, -}; - -static void csdio_transport_cleanup(struct csdio_func_t *port) -{ - int devno = MKDEV(csdio_major, csdio_minor + port->m_func->num); - device_destroy(g_csdio.m_driver_class, devno); - port->m_device = NULL; - cdev_del(&port->m_cdev); -} - -#if defined(CONFIG_DEVTMPFS) -static inline int csdio_cdev_update_permissions( - const char *devname, int dev_minor) -{ - return 0; -} -#else -static int csdio_cdev_update_permissions( - const char *devname, int dev_minor) -{ - int ret = 0; - mm_segment_t fs; - struct file *file; - struct inode *inode; - struct iattr newattrs; - int mode = CSDIO_DEV_PERMISSIONS; - char dev_file[64]; - - fs = get_fs(); - set_fs(get_ds()); - - snprintf(dev_file, sizeof(dev_file), "/dev/%s%d", - devname, dev_minor); - file = filp_open(dev_file, O_RDWR, 0); - if (IS_ERR(file)) { - ret = -EFAULT; - goto exit; - } - - inode = file->f_path.dentry->d_inode; - - mutex_lock(&inode->i_mutex); - newattrs.ia_mode = - (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; - ret = notify_change(file->f_path.dentry, &newattrs); - mutex_unlock(&inode->i_mutex); - - filp_close(file, NULL); - -exit: - set_fs(fs); - return ret; -} -#endif - -static struct device *csdio_cdev_init(struct cdev *char_dev, - const struct file_operations *file_op, int dev_minor, - const char *devname, struct device *parent) -{ - int ret = 0; - struct device *new_device = NULL; - dev_t devno = MKDEV(csdio_major, dev_minor); - - /* Initialize transport device */ - cdev_init(char_dev, file_op); - char_dev->owner = THIS_MODULE; - char_dev->ops = file_op; - ret = cdev_add(char_dev, devno, 1); - - /* Fail gracefully if need be */ - if (ret) { - pr_warning("Error %d adding CSDIO char device '%s%d'", - ret, devname, dev_minor); - goto exit; - } - pr_info("'%s%d' char driver registered\n", devname, dev_minor); - - /* create a /dev entry for transport drivers */ - new_device = device_create(g_csdio.m_driver_class, parent, devno, NULL, - "%s%d", devname, dev_minor); - if (!new_device) { - pr_err("Can't create device node '/dev/%s%d'\n", - devname, dev_minor); - goto cleanup; - } - /* no irq attached */ - g_csdio.m_current_irq_mask = 0; - - if (csdio_cdev_update_permissions(devname, dev_minor)) { - pr_warning("%s%d: Unable to update access permissions of the" - " '/dev/%s%d'\n", - devname, dev_minor, devname, dev_minor); - } - - pr_info("%s%d: Device node '/dev/%s%d' created successfully\n", - devname, dev_minor, devname, dev_minor); - goto exit; -cleanup: - cdev_del(char_dev); -exit: - return new_device; -} - -/* Looks for first non empty function, returns NULL otherwise */ -static struct sdio_func *get_active_func(void) -{ - int i; - - for (i = 0; i < CSDIO_NUM_OF_SDIO_FUNCTIONS; i++) { - if (g_csdio_func_table[i]) - return g_csdio_func_table[i]->m_func; - } - return NULL; -} - -static ssize_t -show_vdd(struct device *dev, struct device_attribute *attr, char *buf) -{ - if (NULL == g_csdio.m_host) - return snprintf(buf, PAGE_SIZE, "N/A\n"); - return snprintf(buf, PAGE_SIZE, "%d\n", - g_csdio.m_host->ios.vdd); -} - -static int -set_vdd_helper(int value) -{ - struct mmc_ios *ios = NULL; - - if (NULL == g_csdio.m_host) { - pr_err("%s0: Set VDD, no MMC host assigned\n", CSDIO_DEV_NAME); - return -ENXIO; - } - - mmc_claim_host(g_csdio.m_host); - ios = &g_csdio.m_host->ios; - ios->vdd = value; - g_csdio.m_host->ops->set_ios(g_csdio.m_host, ios); - mmc_release_host(g_csdio.m_host); - return 0; -} - -static ssize_t -set_vdd(struct device *dev, struct device_attribute *att, - const char *buf, size_t count) -{ - int value = 0; - - sscanf(buf, "%d", &value); - if (set_vdd_helper(value)) - return -ENXIO; - return count; -} - -static DEVICE_ATTR(vdd, S_IRUGO | S_IWUSR, - show_vdd, set_vdd); - -static struct attribute *dev_attrs[] = { - &dev_attr_vdd.attr, - NULL, -}; - -static struct attribute_group dev_attr_grp = { - .attrs = dev_attrs, -}; - -/* - * The ioctl() implementation for control device - */ -static int csdio_ctrl_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - int err = 0; - int ret = 0; - - pr_info("CSDIO ctrl ioctl.\n"); - - /* extract the type and number bitfields - sanity check: return ENOTTY (inappropriate ioctl) before - access_ok() - */ - if ((_IOC_TYPE(cmd) != CSDIO_IOC_MAGIC) || - (_IOC_NR(cmd) > CSDIO_IOC_MAXNR)) { - pr_err(CSDIO_DEV_NAME "Wrong ioctl command parameters\n"); - ret = -ENOTTY; - goto exit; - } - - /* the direction is a bitmask, and VERIFY_WRITE catches R/W - transfers. `Type' is user-oriented, while access_ok is - kernel-oriented, so the concept of "read" and "write" is reversed - */ - if (_IOC_DIR(cmd) & _IOC_READ) { - err = !access_ok(VERIFY_WRITE, (void __user *)arg, - _IOC_SIZE(cmd)); - } else { - if (_IOC_DIR(cmd) & _IOC_WRITE) - err = !access_ok(VERIFY_READ, (void __user *)arg, - _IOC_SIZE(cmd)); - } - if (err) { - pr_err(CSDIO_DEV_NAME "Wrong ioctl access direction\n"); - ret = -EFAULT; - goto exit; - } - - switch (cmd) { - case CSDIO_IOC_ENABLE_HIGHSPEED_MODE: - pr_info(CSDIO_DEV_NAME" ENABLE_HIGHSPEED_MODE\n"); - break; - case CSDIO_IOC_SET_DATA_TRANSFER_CLOCKS: - { - struct mmc_host *host = g_csdio.m_host; - struct mmc_ios *ios = NULL; - - if (NULL == host) { - pr_err("%s0: " - "CSDIO_IOC_SET_DATA_TRANSFER_CLOCKS," - " no MMC host assigned\n", - CSDIO_DEV_NAME); - ret = -EFAULT; - goto exit; - } - ios = &host->ios; - - mmc_claim_host(host); - ret = get_user(host->ios.clock, - (unsigned int __user *)arg); - if (ret) { - pr_err(CSDIO_DEV_NAME - " get data from user space failed\n"); - } else { - pr_err(CSDIO_DEV_NAME - "SET_DATA_TRANSFER_CLOCKS(%d-%d)(%d)\n", - host->f_min, host->f_max, - host->ios.clock); - host->ops->set_ios(host, ios); - } - mmc_release_host(host); - } - break; - case CSDIO_IOC_ENABLE_ISR: - { - int ret; - unsigned char reg; - struct sdio_func *func = get_active_func(); - - if (!func) { - pr_err(CSDIO_DEV_NAME " CSDIO_IOC_ENABLE_ISR" - " no active sdio function\n"); - ret = -EFAULT; - goto exit; - } - pr_info(CSDIO_DEV_NAME - " CSDIO_IOC_ENABLE_ISR func=%d\n", - func->num); - reg = g_csdio.m_current_irq_mask | 1; - - sdio_claim_host(func); - sdio_f0_writeb(func, reg, SDIO_CCCR_IENx, &ret); - sdio_release_host(func); - if (ret) { - pr_err(CSDIO_DEV_NAME - " Can't sdio_f0_writeb (%d)\n", - ret); - goto exit; - } - } - break; - case CSDIO_IOC_DISABLE_ISR: - { - int ret; - struct sdio_func *func = get_active_func(); - if (!func) { - pr_err(CSDIO_DEV_NAME " CSDIO_IOC_ENABLE_ISR" - " no active sdio function\n"); - ret = -EFAULT; - goto exit; - } - pr_info(CSDIO_DEV_NAME - " CSDIO_IOC_DISABLE_ISR func=%p\n", - func); - - sdio_claim_host(func); - ret = disable_sdio_client_isr(func); - sdio_release_host(func); - if (ret) { - pr_err("%s0: Can't disable client isr (%d)\n", - CSDIO_DEV_NAME, ret); - goto exit; - } - } - break; - case CSDIO_IOC_SET_VDD: - { - unsigned int vdd = 0; - - ret = get_user(vdd, (unsigned int __user *)arg); - if (ret) { - pr_err("%s0: CSDIO_IOC_SET_VDD," - " get data from user space failed\n", - CSDIO_DEV_NAME); - goto exit; - } - pr_info(CSDIO_DEV_NAME" CSDIO_IOC_SET_VDD - %d\n", vdd); - - ret = set_vdd_helper(vdd); - if (ret) - goto exit; - } - break; - case CSDIO_IOC_GET_VDD: - { - if (NULL == g_csdio.m_host) { - pr_err("%s0: CSDIO_IOC_GET_VDD," - " no MMC host assigned\n", - CSDIO_DEV_NAME); - ret = -EFAULT; - goto exit; - } - ret = put_user(g_csdio.m_host->ios.vdd, - (unsigned short __user *)arg); - if (ret) { - pr_err("%s0: CSDIO_IOC_GET_VDD, put data" - " to user space failed\n", - CSDIO_DEV_NAME); - goto exit; - } - } - break; - default: /* redundant, as cmd was checked against MAXNR */ - pr_warning(CSDIO_DEV_NAME" Redundant IOCTL\n"); - ret = -ENOTTY; - } -exit: - return ret; -} - -static int csdio_ctrl_fasync(int fd, struct file *filp, int mode) -{ - pr_info(CSDIO_DEV_NAME - " csdio_ctrl_fasync: fd=%d, filp=%p, mode=%d\n", - fd, filp, mode); - return fasync_helper(fd, filp, mode, &g_csdio.m_async_queue); -} - -/* - * Open and close - */ -static int csdio_ctrl_open(struct inode *inode, struct file *filp) -{ - int ret = 0; - struct csdio_t *csdio_ctrl_drv = NULL; /* device information */ - - pr_info("CSDIO ctrl open.\n"); - csdio_ctrl_drv = container_of(inode->i_cdev, struct csdio_t, m_cdev); - filp->private_data = csdio_ctrl_drv; /* for other methods */ - return ret; -} - -static int csdio_ctrl_release(struct inode *inode, struct file *filp) -{ - pr_info("CSDIO ctrl release.\n"); - /* remove this filp from the asynchronously notified filp's */ - csdio_ctrl_fasync(-1, filp, 0); - return 0; -} - -static const struct file_operations csdio_ctrl_fops = { - .owner = THIS_MODULE, - .ioctl = csdio_ctrl_ioctl, - .open = csdio_ctrl_open, - .release = csdio_ctrl_release, - .fasync = csdio_ctrl_fasync, -}; - -static int csdio_probe(struct sdio_func *func, - const struct sdio_device_id *id) -{ - struct csdio_func_t *port; - int ret = 0; - struct mmc_host *host = func->card->host; - - if (NULL != g_csdio.m_host && g_csdio.m_host != host) { - pr_info("%s: Device is on unexpected host\n", - CSDIO_DEV_NAME); - ret = -ENODEV; - goto exit; - } - - /* enforce single instance policy */ - if (g_csdio_func_table[func->num-1]) { - pr_err("%s - only single SDIO device supported", - sdio_func_id(func)); - ret = -EEXIST; - goto exit; - } - - port = kzalloc(sizeof(struct csdio_func_t), GFP_KERNEL); - if (!port) { - pr_err("Can't allocate memory\n"); - ret = -ENOMEM; - goto exit; - } - - /* initialize SDIO side */ - port->m_func = func; - sdio_set_drvdata(func, port); - - pr_info("%s - SDIO device found. Function %d\n", - sdio_func_id(func), func->num); - - port->m_device = csdio_cdev_init(&port->m_cdev, &csdio_transport_fops, - csdio_minor + port->m_func->num, - TP_DEV_NAME, &port->m_func->dev); - - /* create appropriate char device */ - if (!port->m_device) - goto free; - - if (0 == g_csdio.m_num_of_func && NULL == host_name) - g_csdio.m_host = host; - g_csdio.m_num_of_func++; - g_csdio_func_table[func->num-1] = port; - port->m_enabled = TRUE; - goto exit; -free: - kfree(port); -exit: - return ret; -} - -static void csdio_remove(struct sdio_func *func) -{ - struct csdio_func_t *port = sdio_get_drvdata(func); - - csdio_transport_cleanup(port); - sdio_claim_host(func); - sdio_release_irq(func); - sdio_disable_func(func); - sdio_release_host(func); - kfree(port); - g_csdio_func_table[func->num-1] = NULL; - g_csdio.m_num_of_func--; - if (0 == g_csdio.m_num_of_func && NULL == host_name) - g_csdio.m_host = NULL; - pr_info("%s%d: Device removed (%s). Function %d\n", - CSDIO_DEV_NAME, func->num, sdio_func_id(func), func->num); -} - -/* CONFIG_CSDIO_VENDOR_ID and CONFIG_CSDIO_DEVICE_ID are defined in Kconfig. - * Use kernel configuration to change the values or overwrite them through - * module parameters */ -static struct sdio_device_id csdio_ids[] = { - { SDIO_DEVICE(CONFIG_CSDIO_VENDOR_ID, CONFIG_CSDIO_DEVICE_ID) }, - { /* end: all zeroes */}, -}; - -MODULE_DEVICE_TABLE(sdio, csdio_ids); - -static struct sdio_driver csdio_driver = { - .probe = csdio_probe, - .remove = csdio_remove, - .name = "csdio", - .id_table = csdio_ids, -}; - -static void __exit csdio_exit(void) -{ - dev_t devno = MKDEV(csdio_major, csdio_minor); - - sdio_unregister_driver(&csdio_driver); - sysfs_remove_group(&g_csdio.m_device->kobj, &dev_attr_grp); - kfree(g_sdio_buffer); - device_destroy(g_csdio.m_driver_class, devno); - cdev_del(&g_csdio.m_cdev); - class_destroy(g_csdio.m_driver_class); - unregister_chrdev_region(devno, csdio_transport_nr_devs); - pr_info("%s: Exit driver module\n", CSDIO_DEV_NAME); -} - -static char *csdio_devnode(struct device *dev, mode_t *mode) -{ - *mode = CSDIO_DEV_PERMISSIONS; - return NULL; -} - -static int __init csdio_init(void) -{ - int ret = 0; - dev_t devno = 0; - - pr_info("Init CSDIO driver module.\n"); - - /* Get a range of minor numbers to work with, asking for a dynamic */ - /* major unless directed otherwise at load time. */ - if (csdio_major) { - devno = MKDEV(csdio_major, csdio_minor); - ret = register_chrdev_region(devno, csdio_transport_nr_devs, - CSDIO_DEV_NAME); - } else { - ret = alloc_chrdev_region(&devno, csdio_minor, - csdio_transport_nr_devs, CSDIO_DEV_NAME); - csdio_major = MAJOR(devno); - } - if (ret < 0) { - pr_err("CSDIO: can't get major %d\n", csdio_major); - goto exit; - } - pr_info("CSDIO char driver major number is %d\n", csdio_major); - - /* kernel module got parameters: overwrite vendor and device id's */ - if ((csdio_vendor_id != 0) && (csdio_device_id != 0)) { - csdio_ids[0].vendor = (u16)csdio_vendor_id; - csdio_ids[0].device = (u16)csdio_device_id; - } - - /* prepare create /dev/... instance */ - g_csdio.m_driver_class = class_create(THIS_MODULE, CSDIO_DEV_NAME); - if (IS_ERR(g_csdio.m_driver_class)) { - ret = -ENOMEM; - pr_err(CSDIO_DEV_NAME " class_create failed\n"); - goto unregister_region; - } - g_csdio.m_driver_class->devnode = csdio_devnode; - - /* create CSDIO ctrl driver */ - g_csdio.m_device = csdio_cdev_init(&g_csdio.m_cdev, - &csdio_ctrl_fops, csdio_minor, CSDIO_DEV_NAME, NULL); - if (!g_csdio.m_device) { - pr_err("%s: Unable to create ctrl driver\n", - CSDIO_DEV_NAME); - goto destroy_class; - } - - g_sdio_buffer = kmalloc(CSDIO_SDIO_BUFFER_SIZE, GFP_KERNEL); - if (!g_sdio_buffer) { - pr_err("Unable to allocate %d bytes\n", CSDIO_SDIO_BUFFER_SIZE); - ret = -ENOMEM; - goto destroy_cdev; - } - - ret = sysfs_create_group(&g_csdio.m_device->kobj, &dev_attr_grp); - if (ret) { - pr_err("%s: Unable to create device attribute\n", - CSDIO_DEV_NAME); - goto free_sdio_buff; - } - - g_csdio.m_num_of_func = 0; - g_csdio.m_host = NULL; - - if (NULL != host_name) { - struct device *dev = bus_find_device_by_name(&platform_bus_type, - NULL, host_name); - if (NULL != dev) { - g_csdio.m_host = dev_get_drvdata(dev); - } else { - pr_err("%s: Host '%s' doesn't exist!\n", CSDIO_DEV_NAME, - host_name); - } - } - - pr_info("%s: Match with VendorId=0x%X, DeviceId=0x%X, Host = %s\n", - CSDIO_DEV_NAME, csdio_device_id, csdio_vendor_id, - (NULL == host_name) ? "Any" : host_name); - - /* register sdio driver */ - ret = sdio_register_driver(&csdio_driver); - if (ret) { - pr_err("%s: Unable to register as SDIO driver\n", - CSDIO_DEV_NAME); - goto remove_group; - } - - goto exit; - -remove_group: - sysfs_remove_group(&g_csdio.m_device->kobj, &dev_attr_grp); -free_sdio_buff: - kfree(g_sdio_buffer); -destroy_cdev: - cdev_del(&g_csdio.m_cdev); -destroy_class: - class_destroy(g_csdio.m_driver_class); -unregister_region: - unregister_chrdev_region(devno, csdio_transport_nr_devs); -exit: - return ret; -} -module_param(csdio_vendor_id, uint, S_IRUGO); -module_param(csdio_device_id, uint, S_IRUGO); -module_param(host_name, charp, S_IRUGO); - -module_init(csdio_init); -module_exit(csdio_exit); - -MODULE_AUTHOR("The Linux Foundation"); -MODULE_DESCRIPTION("CSDIO device driver version " VERSION); -MODULE_VERSION(VERSION); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/char/msm_rotator.c b/drivers/char/msm_rotator.c deleted file mode 100644 index 027f212e2ac8a397b1b2c3300908132ece00e7b3..0000000000000000000000000000000000000000 --- a/drivers/char/msm_rotator.c +++ /dev/null @@ -1,1852 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_MSM_BUS_SCALING -#include -#include -#endif -#include - -#define DRIVER_NAME "msm_rotator" - -#define MSM_ROTATOR_BASE (msm_rotator_dev->io_base) -#define MSM_ROTATOR_INTR_ENABLE (MSM_ROTATOR_BASE+0x0020) -#define MSM_ROTATOR_INTR_STATUS (MSM_ROTATOR_BASE+0x0024) -#define MSM_ROTATOR_INTR_CLEAR (MSM_ROTATOR_BASE+0x0028) -#define MSM_ROTATOR_START (MSM_ROTATOR_BASE+0x0030) -#define MSM_ROTATOR_MAX_BURST_SIZE (MSM_ROTATOR_BASE+0x0050) -#define MSM_ROTATOR_HW_VERSION (MSM_ROTATOR_BASE+0x0070) -#define MSM_ROTATOR_SW_RESET (MSM_ROTATOR_BASE+0x0074) -#define MSM_ROTATOR_SRC_SIZE (MSM_ROTATOR_BASE+0x1108) -#define MSM_ROTATOR_SRCP0_ADDR (MSM_ROTATOR_BASE+0x110c) -#define MSM_ROTATOR_SRCP1_ADDR (MSM_ROTATOR_BASE+0x1110) -#define MSM_ROTATOR_SRCP2_ADDR (MSM_ROTATOR_BASE+0x1114) -#define MSM_ROTATOR_SRC_YSTRIDE1 (MSM_ROTATOR_BASE+0x111c) -#define MSM_ROTATOR_SRC_YSTRIDE2 (MSM_ROTATOR_BASE+0x1120) -#define MSM_ROTATOR_SRC_FORMAT (MSM_ROTATOR_BASE+0x1124) -#define MSM_ROTATOR_SRC_UNPACK_PATTERN1 (MSM_ROTATOR_BASE+0x1128) -#define MSM_ROTATOR_SUB_BLOCK_CFG (MSM_ROTATOR_BASE+0x1138) -#define MSM_ROTATOR_OUT_PACK_PATTERN1 (MSM_ROTATOR_BASE+0x1154) -#define MSM_ROTATOR_OUTP0_ADDR (MSM_ROTATOR_BASE+0x1168) -#define MSM_ROTATOR_OUTP1_ADDR (MSM_ROTATOR_BASE+0x116c) -#define MSM_ROTATOR_OUTP2_ADDR (MSM_ROTATOR_BASE+0x1170) -#define MSM_ROTATOR_OUT_YSTRIDE1 (MSM_ROTATOR_BASE+0x1178) -#define MSM_ROTATOR_OUT_YSTRIDE2 (MSM_ROTATOR_BASE+0x117c) -#define MSM_ROTATOR_SRC_XY (MSM_ROTATOR_BASE+0x1200) -#define MSM_ROTATOR_SRC_IMAGE_SIZE (MSM_ROTATOR_BASE+0x1208) - -#define MSM_ROTATOR_MAX_ROT 0x07 -#define MSM_ROTATOR_MAX_H 0x1fff -#define MSM_ROTATOR_MAX_W 0x1fff - -/* from lsb to msb */ -#define GET_PACK_PATTERN(a, x, y, z, bit) \ - (((a)<<((bit)*3))|((x)<<((bit)*2))|((y)<<(bit))|(z)) -#define CLR_G 0x0 -#define CLR_B 0x1 -#define CLR_R 0x2 -#define CLR_ALPHA 0x3 - -#define CLR_Y CLR_G -#define CLR_CB CLR_B -#define CLR_CR CLR_R - -#define ROTATIONS_TO_BITMASK(r) ((((r) & MDP_ROT_90) ? 1 : 0) | \ - (((r) & MDP_FLIP_LR) ? 2 : 0) | \ - (((r) & MDP_FLIP_UD) ? 4 : 0)) - -#define IMEM_NO_OWNER -1; - -#define MAX_SESSIONS 16 -#define INVALID_SESSION -1 -#define VERSION_KEY_MASK 0xFFFFFF00 -#define MAX_DOWNSCALE_RATIO 3 - -#define ROTATOR_REVISION_V0 0 -#define ROTATOR_REVISION_V1 1 -#define ROTATOR_REVISION_V2 2 -#define ROTATOR_REVISION_NONE 0xffffffff - -uint32_t rotator_hw_revision; -static char rot_iommu_split_domain; - -/* - * rotator_hw_revision: - * 0 == 7x30 - * 1 == 8x60 - * 2 == 8960 - * - */ -struct tile_parm { - unsigned int width; /* tile's width */ - unsigned int height; /* tile's height */ - unsigned int row_tile_w; /* tiles per row's width */ - unsigned int row_tile_h; /* tiles per row's height */ -}; - -struct msm_rotator_mem_planes { - unsigned int num_planes; - unsigned int plane_size[4]; - unsigned int total_size; -}; - -#define checkoffset(offset, size, max_size) \ - ((size) > (max_size) || (offset) > ((max_size) - (size))) - -struct msm_rotator_fd_info { - int pid; - int ref_cnt; - struct list_head list; -}; - -struct msm_rotator_dev { - void __iomem *io_base; - int irq; - struct msm_rotator_img_info *img_info[MAX_SESSIONS]; - struct clk *core_clk; - struct msm_rotator_fd_info *fd_info[MAX_SESSIONS]; - struct list_head fd_list; - struct clk *pclk; - int rot_clk_state; - struct regulator *regulator; - struct delayed_work rot_clk_work; - struct clk *imem_clk; - int imem_clk_state; - struct delayed_work imem_clk_work; - struct platform_device *pdev; - struct cdev cdev; - struct device *device; - struct class *class; - dev_t dev_num; - int processing; - int last_session_idx; - struct mutex rotator_lock; - struct mutex imem_lock; - int imem_owner; - wait_queue_head_t wq; - struct ion_client *client; - #ifdef CONFIG_MSM_BUS_SCALING - uint32_t bus_client_handle; - #endif -}; - -#define COMPONENT_5BITS 1 -#define COMPONENT_6BITS 2 -#define COMPONENT_8BITS 3 - -static struct msm_rotator_dev *msm_rotator_dev; - -enum { - CLK_EN, - CLK_DIS, - CLK_SUSPEND, -}; - -int msm_rotator_iommu_map_buf(int mem_id, int domain, - unsigned long *start, unsigned long *len, - struct ion_handle **pihdl, unsigned int secure) -{ - if (!msm_rotator_dev->client) - return -EINVAL; - - *pihdl = ion_import_dma_buf(msm_rotator_dev->client, mem_id); - if (IS_ERR_OR_NULL(*pihdl)) { - pr_err("ion_import_dma_buf() failed\n"); - return PTR_ERR(*pihdl); - } - pr_debug("%s(): ion_hdl %p, ion_fd %d\n", __func__, *pihdl, mem_id); - - if (rot_iommu_split_domain) { - if (secure) { - if (ion_phys(msm_rotator_dev->client, - *pihdl, (ion_phys_addr_t *)start, - (unsigned *)len)) { - pr_err("%s:%d: ion_phys map failed\n", - __func__, __LINE__); - return -ENOMEM; - } - } else { - if (ion_map_iommu(msm_rotator_dev->client, - *pihdl, domain, GEN_POOL, - SZ_4K, 0, (dma_addr_t *)start, len, 0, - ION_IOMMU_UNMAP_DELAYED)) { - pr_err("ion_map_iommu() failed\n"); - return -EINVAL; - } - } - } else { - if (ion_map_iommu(msm_rotator_dev->client, - *pihdl, ROTATOR_SRC_DOMAIN, GEN_POOL, - SZ_4K, 0, (dma_addr_t *)start, len, 0, - ION_IOMMU_UNMAP_DELAYED)) { - pr_err("ion_map_iommu() failed\n"); - return -EINVAL; - } - } - - pr_debug("%s(): mem_id %d, start 0x%lx, len 0x%lx\n", - __func__, mem_id, *start, *len); - return 0; -} - -int msm_rotator_imem_allocate(int requestor) -{ - int rc = 0; - -#ifdef CONFIG_MSM_ROTATOR_USE_IMEM - switch (requestor) { - case ROTATOR_REQUEST: - if (mutex_trylock(&msm_rotator_dev->imem_lock)) { - msm_rotator_dev->imem_owner = ROTATOR_REQUEST; - rc = 1; - } else - rc = 0; - break; - case JPEG_REQUEST: - mutex_lock(&msm_rotator_dev->imem_lock); - msm_rotator_dev->imem_owner = JPEG_REQUEST; - rc = 1; - break; - default: - rc = 0; - } -#else - if (requestor == JPEG_REQUEST) - rc = 1; -#endif - if (rc == 1) { - cancel_delayed_work(&msm_rotator_dev->imem_clk_work); - if (msm_rotator_dev->imem_clk_state != CLK_EN - && msm_rotator_dev->imem_clk) { - clk_prepare_enable(msm_rotator_dev->imem_clk); - msm_rotator_dev->imem_clk_state = CLK_EN; - } - } - - return rc; -} -EXPORT_SYMBOL(msm_rotator_imem_allocate); - -void msm_rotator_imem_free(int requestor) -{ -#ifdef CONFIG_MSM_ROTATOR_USE_IMEM - if (msm_rotator_dev->imem_owner == requestor) { - schedule_delayed_work(&msm_rotator_dev->imem_clk_work, HZ); - mutex_unlock(&msm_rotator_dev->imem_lock); - } -#else - if (requestor == JPEG_REQUEST) - schedule_delayed_work(&msm_rotator_dev->imem_clk_work, HZ); -#endif -} -EXPORT_SYMBOL(msm_rotator_imem_free); - -static void msm_rotator_imem_clk_work_f(struct work_struct *work) -{ -#ifdef CONFIG_MSM_ROTATOR_USE_IMEM - if (mutex_trylock(&msm_rotator_dev->imem_lock)) { - if (msm_rotator_dev->imem_clk_state == CLK_EN - && msm_rotator_dev->imem_clk) { - clk_disable_unprepare(msm_rotator_dev->imem_clk); - msm_rotator_dev->imem_clk_state = CLK_DIS; - } else if (msm_rotator_dev->imem_clk_state == CLK_SUSPEND) - msm_rotator_dev->imem_clk_state = CLK_DIS; - mutex_unlock(&msm_rotator_dev->imem_lock); - } -#endif -} - -/* enable clocks needed by rotator block */ -static void enable_rot_clks(void) -{ - if (msm_rotator_dev->regulator) - regulator_enable(msm_rotator_dev->regulator); - if (msm_rotator_dev->core_clk != NULL) - clk_prepare_enable(msm_rotator_dev->core_clk); - if (msm_rotator_dev->pclk != NULL) - clk_prepare_enable(msm_rotator_dev->pclk); -} - -/* disable clocks needed by rotator block */ -static void disable_rot_clks(void) -{ - if (msm_rotator_dev->core_clk != NULL) - clk_disable_unprepare(msm_rotator_dev->core_clk); - if (msm_rotator_dev->pclk != NULL) - clk_disable_unprepare(msm_rotator_dev->pclk); - if (msm_rotator_dev->regulator) - regulator_disable(msm_rotator_dev->regulator); -} - -static void msm_rotator_rot_clk_work_f(struct work_struct *work) -{ - if (mutex_trylock(&msm_rotator_dev->rotator_lock)) { - if (msm_rotator_dev->rot_clk_state == CLK_EN) { - disable_rot_clks(); - msm_rotator_dev->rot_clk_state = CLK_DIS; - } else if (msm_rotator_dev->rot_clk_state == CLK_SUSPEND) - msm_rotator_dev->rot_clk_state = CLK_DIS; - mutex_unlock(&msm_rotator_dev->rotator_lock); - } -} - -static irqreturn_t msm_rotator_isr(int irq, void *dev_id) -{ - if (msm_rotator_dev->processing) { - msm_rotator_dev->processing = 0; - wake_up(&msm_rotator_dev->wq); - } else - printk(KERN_WARNING "%s: unexpected interrupt\n", DRIVER_NAME); - - return IRQ_HANDLED; -} - -static unsigned int tile_size(unsigned int src_width, - unsigned int src_height, - const struct tile_parm *tp) -{ - unsigned int tile_w, tile_h; - unsigned int row_num_w, row_num_h; - tile_w = tp->width * tp->row_tile_w; - tile_h = tp->height * tp->row_tile_h; - row_num_w = (src_width + tile_w - 1) / tile_w; - row_num_h = (src_height + tile_h - 1) / tile_h; - return ((row_num_w * row_num_h * tile_w * tile_h) + 8191) & ~8191; -} - -static int get_bpp(int format) -{ - switch (format) { - case MDP_RGB_565: - case MDP_BGR_565: - return 2; - - case MDP_XRGB_8888: - case MDP_ARGB_8888: - case MDP_RGBA_8888: - case MDP_BGRA_8888: - case MDP_RGBX_8888: - case MDP_BGRX_8888: - return 4; - - case MDP_Y_CBCR_H2V2: - case MDP_Y_CRCB_H2V2: - case MDP_Y_CB_CR_H2V2: - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CRCB_H2V2_TILE: - case MDP_Y_CBCR_H2V2_TILE: - return 1; - - case MDP_RGB_888: - case MDP_YCBCR_H1V1: - case MDP_YCRCB_H1V1: - return 3; - - case MDP_YCRYCB_H2V1: - return 2;/* YCrYCb interleave */ - - case MDP_Y_CRCB_H2V1: - case MDP_Y_CBCR_H2V1: - return 1; - - default: - return -1; - } - -} - -static int msm_rotator_get_plane_sizes(uint32_t format, uint32_t w, uint32_t h, - struct msm_rotator_mem_planes *p) -{ - /* - * each row of samsung tile consists of two tiles in height - * and two tiles in width which means width should align to - * 64 x 2 bytes and height should align to 32 x 2 bytes. - * video decoder generate two tiles in width and one tile - * in height which ends up height align to 32 X 1 bytes. - */ - const struct tile_parm tile = {64, 32, 2, 1}; - int i; - - if (p == NULL) - return -EINVAL; - - if ((w > MSM_ROTATOR_MAX_W) || (h > MSM_ROTATOR_MAX_H)) - return -ERANGE; - - memset(p, 0, sizeof(*p)); - - switch (format) { - case MDP_XRGB_8888: - case MDP_ARGB_8888: - case MDP_RGBA_8888: - case MDP_BGRA_8888: - case MDP_RGBX_8888: - case MDP_BGRX_8888: - case MDP_RGB_888: - case MDP_RGB_565: - case MDP_BGR_565: - case MDP_YCRYCB_H2V1: - case MDP_YCBCR_H1V1: - case MDP_YCRCB_H1V1: - p->num_planes = 1; - p->plane_size[0] = w * h * get_bpp(format); - break; - case MDP_Y_CRCB_H2V1: - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H1V2: - case MDP_Y_CBCR_H1V2: - p->num_planes = 2; - p->plane_size[0] = w * h; - p->plane_size[1] = w * h; - break; - case MDP_Y_CBCR_H2V2: - case MDP_Y_CRCB_H2V2: - p->num_planes = 2; - p->plane_size[0] = w * h; - p->plane_size[1] = w * h / 2; - break; - case MDP_Y_CRCB_H2V2_TILE: - case MDP_Y_CBCR_H2V2_TILE: - p->num_planes = 2; - p->plane_size[0] = tile_size(w, h, &tile); - p->plane_size[1] = tile_size(w, h/2, &tile); - break; - case MDP_Y_CB_CR_H2V2: - case MDP_Y_CR_CB_H2V2: - p->num_planes = 3; - p->plane_size[0] = w * h; - p->plane_size[1] = (w / 2) * (h / 2); - p->plane_size[2] = (w / 2) * (h / 2); - break; - case MDP_Y_CR_CB_GH2V2: - p->num_planes = 3; - p->plane_size[0] = ALIGN(w, 16) * h; - p->plane_size[1] = ALIGN(w / 2, 16) * (h / 2); - p->plane_size[2] = ALIGN(w / 2, 16) * (h / 2); - break; - default: - return -EINVAL; - } - - for (i = 0; i < p->num_planes; i++) - p->total_size += p->plane_size[i]; - - return 0; -} - -static int msm_rotator_ycxcx_h2v1(struct msm_rotator_img_info *info, - unsigned int in_paddr, - unsigned int out_paddr, - unsigned int use_imem, - int new_session, - unsigned int in_chroma_paddr, - unsigned int out_chroma_paddr) -{ - int bpp; - uint32_t dst_format; - switch (info->src.format) { - case MDP_Y_CRCB_H2V1: - if (info->rotations & MDP_ROT_90) - dst_format = MDP_Y_CRCB_H1V2; - else - dst_format = info->src.format; - break; - case MDP_Y_CBCR_H2V1: - if (info->rotations & MDP_ROT_90) - dst_format = MDP_Y_CBCR_H1V2; - else - dst_format = info->src.format; - break; - default: - return -EINVAL; - } - if (info->dst.format != dst_format) - return -EINVAL; - - bpp = get_bpp(info->src.format); - if (bpp < 0) - return -ENOTTY; - - iowrite32(in_paddr, MSM_ROTATOR_SRCP0_ADDR); - iowrite32(in_chroma_paddr, MSM_ROTATOR_SRCP1_ADDR); - iowrite32(out_paddr + - ((info->dst_y * info->dst.width) + info->dst_x), - MSM_ROTATOR_OUTP0_ADDR); - iowrite32(out_chroma_paddr + - ((info->dst_y * info->dst.width) + info->dst_x), - MSM_ROTATOR_OUTP1_ADDR); - - if (new_session) { - iowrite32(info->src.width | - info->src.width << 16, - MSM_ROTATOR_SRC_YSTRIDE1); - if (info->rotations & MDP_ROT_90) - iowrite32(info->dst.width | - info->dst.width*2 << 16, - MSM_ROTATOR_OUT_YSTRIDE1); - else - iowrite32(info->dst.width | - info->dst.width << 16, - MSM_ROTATOR_OUT_YSTRIDE1); - if (info->src.format == MDP_Y_CBCR_H2V1) { - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - } else { - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - } - iowrite32((1 << 18) | /* chroma sampling 1=H2V1 */ - (ROTATIONS_TO_BITMASK(info->rotations) << 9) | - 1 << 8 | /* ROT_EN */ - info->downscale_ratio << 2 | /* downscale v ratio */ - info->downscale_ratio, /* downscale h ratio */ - MSM_ROTATOR_SUB_BLOCK_CFG); - iowrite32(0 << 29 | /* frame format 0 = linear */ - (use_imem ? 0 : 1) << 22 | /* tile size */ - 2 << 19 | /* fetch planes 2 = pseudo */ - 0 << 18 | /* unpack align */ - 1 << 17 | /* unpack tight */ - 1 << 13 | /* unpack count 0=1 component */ - (bpp-1) << 9 | /* src Bpp 0=1 byte ... */ - 0 << 8 | /* has alpha */ - 0 << 6 | /* alpha bits 3=8bits */ - 3 << 4 | /* R/Cr bits 1=5 2=6 3=8 */ - 3 << 2 | /* B/Cb bits 1=5 2=6 3=8 */ - 3 << 0, /* G/Y bits 1=5 2=6 3=8 */ - MSM_ROTATOR_SRC_FORMAT); - } - - return 0; -} - -static int msm_rotator_ycxcx_h2v2(struct msm_rotator_img_info *info, - unsigned int in_paddr, - unsigned int out_paddr, - unsigned int use_imem, - int new_session, - unsigned int in_chroma_paddr, - unsigned int out_chroma_paddr, - unsigned int in_chroma2_paddr) -{ - uint32_t dst_format; - int is_tile = 0; - - switch (info->src.format) { - case MDP_Y_CRCB_H2V2_TILE: - is_tile = 1; - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CRCB_H2V2: - dst_format = MDP_Y_CRCB_H2V2; - break; - case MDP_Y_CBCR_H2V2_TILE: - is_tile = 1; - case MDP_Y_CB_CR_H2V2: - case MDP_Y_CBCR_H2V2: - dst_format = MDP_Y_CBCR_H2V2; - break; - default: - return -EINVAL; - } - if (info->dst.format != dst_format) - return -EINVAL; - - /* rotator expects YCbCr for planar input format */ - if ((info->src.format == MDP_Y_CR_CB_H2V2 || - info->src.format == MDP_Y_CR_CB_GH2V2) && - rotator_hw_revision < ROTATOR_REVISION_V2) - swap(in_chroma_paddr, in_chroma2_paddr); - - iowrite32(in_paddr, MSM_ROTATOR_SRCP0_ADDR); - iowrite32(in_chroma_paddr, MSM_ROTATOR_SRCP1_ADDR); - iowrite32(in_chroma2_paddr, MSM_ROTATOR_SRCP2_ADDR); - - iowrite32(out_paddr + - ((info->dst_y * info->dst.width) + info->dst_x), - MSM_ROTATOR_OUTP0_ADDR); - iowrite32(out_chroma_paddr + - ((info->dst_y * info->dst.width)/2 + info->dst_x), - MSM_ROTATOR_OUTP1_ADDR); - - if (new_session) { - if (in_chroma2_paddr) { - if (info->src.format == MDP_Y_CR_CB_GH2V2) { - iowrite32(ALIGN(info->src.width, 16) | - ALIGN((info->src.width / 2), 16) << 16, - MSM_ROTATOR_SRC_YSTRIDE1); - iowrite32(ALIGN((info->src.width / 2), 16), - MSM_ROTATOR_SRC_YSTRIDE2); - } else { - iowrite32(info->src.width | - (info->src.width / 2) << 16, - MSM_ROTATOR_SRC_YSTRIDE1); - iowrite32((info->src.width / 2), - MSM_ROTATOR_SRC_YSTRIDE2); - } - } else { - iowrite32(info->src.width | - info->src.width << 16, - MSM_ROTATOR_SRC_YSTRIDE1); - } - iowrite32(info->dst.width | - info->dst.width << 16, - MSM_ROTATOR_OUT_YSTRIDE1); - - if (dst_format == MDP_Y_CBCR_H2V2) { - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CB, CLR_CR, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - } else { - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - } - iowrite32((3 << 18) | /* chroma sampling 3=4:2:0 */ - (ROTATIONS_TO_BITMASK(info->rotations) << 9) | - 1 << 8 | /* ROT_EN */ - info->downscale_ratio << 2 | /* downscale v ratio */ - info->downscale_ratio, /* downscale h ratio */ - MSM_ROTATOR_SUB_BLOCK_CFG); - - iowrite32((is_tile ? 2 : 0) << 29 | /* frame format */ - (use_imem ? 0 : 1) << 22 | /* tile size */ - (in_chroma2_paddr ? 1 : 2) << 19 | /* fetch planes */ - 0 << 18 | /* unpack align */ - 1 << 17 | /* unpack tight */ - 1 << 13 | /* unpack count 0=1 component */ - 0 << 9 | /* src Bpp 0=1 byte ... */ - 0 << 8 | /* has alpha */ - 0 << 6 | /* alpha bits 3=8bits */ - 3 << 4 | /* R/Cr bits 1=5 2=6 3=8 */ - 3 << 2 | /* B/Cb bits 1=5 2=6 3=8 */ - 3 << 0, /* G/Y bits 1=5 2=6 3=8 */ - MSM_ROTATOR_SRC_FORMAT); - } - return 0; -} - -static int msm_rotator_ycrycb(struct msm_rotator_img_info *info, - unsigned int in_paddr, - unsigned int out_paddr, - unsigned int use_imem, - int new_session, - unsigned int out_chroma_paddr) -{ - int bpp; - uint32_t dst_format; - - if (info->src.format == MDP_YCRYCB_H2V1) { - if (info->rotations & MDP_ROT_90) - dst_format = MDP_Y_CRCB_H1V2; - else - dst_format = MDP_Y_CRCB_H2V1; - } else - return -EINVAL; - - if (info->dst.format != dst_format) - return -EINVAL; - - bpp = get_bpp(info->src.format); - if (bpp < 0) - return -ENOTTY; - - iowrite32(in_paddr, MSM_ROTATOR_SRCP0_ADDR); - iowrite32(out_paddr + - ((info->dst_y * info->dst.width) + info->dst_x), - MSM_ROTATOR_OUTP0_ADDR); - iowrite32(out_chroma_paddr + - ((info->dst_y * info->dst.width)/2 + info->dst_x), - MSM_ROTATOR_OUTP1_ADDR); - - if (new_session) { - iowrite32(info->src.width * bpp, - MSM_ROTATOR_SRC_YSTRIDE1); - if (info->rotations & MDP_ROT_90) - iowrite32(info->dst.width | - (info->dst.width*2) << 16, - MSM_ROTATOR_OUT_YSTRIDE1); - else - iowrite32(info->dst.width | - (info->dst.width) << 16, - MSM_ROTATOR_OUT_YSTRIDE1); - - iowrite32(GET_PACK_PATTERN(CLR_Y, CLR_CR, CLR_Y, CLR_CB, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, 0, CLR_CR, CLR_CB, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - iowrite32((1 << 18) | /* chroma sampling 1=H2V1 */ - (ROTATIONS_TO_BITMASK(info->rotations) << 9) | - 1 << 8 | /* ROT_EN */ - info->downscale_ratio << 2 | /* downscale v ratio */ - info->downscale_ratio, /* downscale h ratio */ - MSM_ROTATOR_SUB_BLOCK_CFG); - iowrite32(0 << 29 | /* frame format 0 = linear */ - (use_imem ? 0 : 1) << 22 | /* tile size */ - 0 << 19 | /* fetch planes 0=interleaved */ - 0 << 18 | /* unpack align */ - 1 << 17 | /* unpack tight */ - 3 << 13 | /* unpack count 0=1 component */ - (bpp-1) << 9 | /* src Bpp 0=1 byte ... */ - 0 << 8 | /* has alpha */ - 0 << 6 | /* alpha bits 3=8bits */ - 3 << 4 | /* R/Cr bits 1=5 2=6 3=8 */ - 3 << 2 | /* B/Cb bits 1=5 2=6 3=8 */ - 3 << 0, /* G/Y bits 1=5 2=6 3=8 */ - MSM_ROTATOR_SRC_FORMAT); - } - - return 0; -} - -static int msm_rotator_rgb_types(struct msm_rotator_img_info *info, - unsigned int in_paddr, - unsigned int out_paddr, - unsigned int use_imem, - int new_session) -{ - int bpp, abits, rbits, gbits, bbits; - - if (info->src.format != info->dst.format) - return -EINVAL; - - bpp = get_bpp(info->src.format); - if (bpp < 0) - return -ENOTTY; - - iowrite32(in_paddr, MSM_ROTATOR_SRCP0_ADDR); - iowrite32(out_paddr + - ((info->dst_y * info->dst.width) + info->dst_x) * bpp, - MSM_ROTATOR_OUTP0_ADDR); - - if (new_session) { - iowrite32(info->src.width * bpp, MSM_ROTATOR_SRC_YSTRIDE1); - iowrite32(info->dst.width * bpp, MSM_ROTATOR_OUT_YSTRIDE1); - iowrite32((0 << 18) | /* chroma sampling 0=rgb */ - (ROTATIONS_TO_BITMASK(info->rotations) << 9) | - 1 << 8 | /* ROT_EN */ - info->downscale_ratio << 2 | /* downscale v ratio */ - info->downscale_ratio, /* downscale h ratio */ - MSM_ROTATOR_SUB_BLOCK_CFG); - switch (info->src.format) { - case MDP_RGB_565: - iowrite32(GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - abits = 0; - rbits = COMPONENT_5BITS; - gbits = COMPONENT_6BITS; - bbits = COMPONENT_5BITS; - break; - - case MDP_BGR_565: - iowrite32(GET_PACK_PATTERN(0, CLR_B, CLR_G, CLR_R, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, CLR_B, CLR_G, CLR_R, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - abits = 0; - rbits = COMPONENT_5BITS; - gbits = COMPONENT_6BITS; - bbits = COMPONENT_5BITS; - break; - - case MDP_RGB_888: - case MDP_YCBCR_H1V1: - case MDP_YCRCB_H1V1: - iowrite32(GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(0, CLR_R, CLR_G, CLR_B, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - abits = 0; - rbits = COMPONENT_8BITS; - gbits = COMPONENT_8BITS; - bbits = COMPONENT_8BITS; - break; - - case MDP_ARGB_8888: - case MDP_RGBA_8888: - case MDP_XRGB_8888: - case MDP_RGBX_8888: - iowrite32(GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, - CLR_B, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(CLR_ALPHA, CLR_R, CLR_G, - CLR_B, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - abits = COMPONENT_8BITS; - rbits = COMPONENT_8BITS; - gbits = COMPONENT_8BITS; - bbits = COMPONENT_8BITS; - break; - - case MDP_BGRA_8888: - case MDP_BGRX_8888: - iowrite32(GET_PACK_PATTERN(CLR_ALPHA, CLR_B, CLR_G, - CLR_R, 8), - MSM_ROTATOR_SRC_UNPACK_PATTERN1); - iowrite32(GET_PACK_PATTERN(CLR_ALPHA, CLR_B, CLR_G, - CLR_R, 8), - MSM_ROTATOR_OUT_PACK_PATTERN1); - abits = COMPONENT_8BITS; - rbits = COMPONENT_8BITS; - gbits = COMPONENT_8BITS; - bbits = COMPONENT_8BITS; - break; - - default: - return -EINVAL; - } - iowrite32(0 << 29 | /* frame format 0 = linear */ - (use_imem ? 0 : 1) << 22 | /* tile size */ - 0 << 19 | /* fetch planes 0=interleaved */ - 0 << 18 | /* unpack align */ - 1 << 17 | /* unpack tight */ - (abits ? 3 : 2) << 13 | /* unpack count 0=1 comp */ - (bpp-1) << 9 | /* src Bpp 0=1 byte ... */ - (abits ? 1 : 0) << 8 | /* has alpha */ - abits << 6 | /* alpha bits 3=8bits */ - rbits << 4 | /* R/Cr bits 1=5 2=6 3=8 */ - bbits << 2 | /* B/Cb bits 1=5 2=6 3=8 */ - gbits << 0, /* G/Y bits 1=5 2=6 3=8 */ - MSM_ROTATOR_SRC_FORMAT); - } - - return 0; -} - -static int get_img(struct msmfb_data *fbd, int domain, - unsigned long *start, unsigned long *len, struct file **p_file, - int *p_need, struct ion_handle **p_ihdl, unsigned int secure) -{ - int ret = 0; -#ifdef CONFIG_FB - struct file *file = NULL; - int put_needed, fb_num; -#endif - *p_need = 0; - -#ifdef CONFIG_FB - if (fbd->flags & MDP_MEMORY_ID_TYPE_FB) { - file = fget_light(fbd->memory_id, &put_needed); - if (file == NULL) { - pr_err("fget_light returned NULL\n"); - return -EINVAL; - } - - if (MAJOR(file->f_dentry->d_inode->i_rdev) == FB_MAJOR) { - fb_num = MINOR(file->f_dentry->d_inode->i_rdev); - if (get_fb_phys_info(start, len, fb_num, - ROTATOR_SUBSYSTEM_ID)) { - pr_err("get_fb_phys_info() failed\n"); - ret = -1; - } else { - *p_file = file; - *p_need = put_needed; - } - } else { - pr_err("invalid FB_MAJOR failed\n"); - ret = -1; - } - if (ret) - fput_light(file, put_needed); - return ret; - } -#endif - - return msm_rotator_iommu_map_buf(fbd->memory_id, domain, start, - len, p_ihdl, secure); - -} - -static void put_img(struct file *p_file, struct ion_handle *p_ihdl, - int domain, unsigned int secure) -{ -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - if (!IS_ERR_OR_NULL(p_ihdl)) { - pr_debug("%s(): p_ihdl %p\n", __func__, p_ihdl); - if (rot_iommu_split_domain) { - if (!secure) - ion_unmap_iommu(msm_rotator_dev->client, - p_ihdl, domain, GEN_POOL); - } else { - ion_unmap_iommu(msm_rotator_dev->client, - p_ihdl, ROTATOR_SRC_DOMAIN, GEN_POOL); - } - - ion_free(msm_rotator_dev->client, p_ihdl); - } -#endif -} -static int msm_rotator_do_rotate(unsigned long arg) -{ - unsigned int status, format; - struct msm_rotator_data_info info; - unsigned int in_paddr, out_paddr; - unsigned long src_len, dst_len; - int use_imem = 0, rc = 0, s; - struct file *srcp0_file = NULL, *dstp0_file = NULL; - struct file *srcp1_file = NULL, *dstp1_file = NULL; - struct ion_handle *srcp0_ihdl = NULL, *dstp0_ihdl = NULL; - struct ion_handle *srcp1_ihdl = NULL, *dstp1_ihdl = NULL; - int ps0_need, p_need; - unsigned int in_chroma_paddr = 0, out_chroma_paddr = 0; - unsigned int in_chroma2_paddr = 0; - struct msm_rotator_img_info *img_info; - struct msm_rotator_mem_planes src_planes, dst_planes; - - if (copy_from_user(&info, (void __user *)arg, sizeof(info))) - return -EFAULT; - - mutex_lock(&msm_rotator_dev->rotator_lock); - for (s = 0; s < MAX_SESSIONS; s++) - if ((msm_rotator_dev->img_info[s] != NULL) && - (info.session_id == - (unsigned int)msm_rotator_dev->img_info[s] - )) - break; - - if (s == MAX_SESSIONS) { - pr_err("%s() : Attempt to use invalid session_id %d\n", - __func__, s); - rc = -EINVAL; - goto do_rotate_unlock_mutex; - } - - if (msm_rotator_dev->img_info[s]->enable == 0) { - dev_dbg(msm_rotator_dev->device, - "%s() : Session_id %d not enabled \n", - __func__, s); - rc = -EINVAL; - goto do_rotate_unlock_mutex; - } - - img_info = msm_rotator_dev->img_info[s]; - if (msm_rotator_get_plane_sizes(img_info->src.format, - img_info->src.width, - img_info->src.height, - &src_planes)) { - pr_err("%s: invalid src format\n", __func__); - rc = -EINVAL; - goto do_rotate_unlock_mutex; - } - if (msm_rotator_get_plane_sizes(img_info->dst.format, - img_info->dst.width, - img_info->dst.height, - &dst_planes)) { - pr_err("%s: invalid dst format\n", __func__); - rc = -EINVAL; - goto do_rotate_unlock_mutex; - } - - rc = get_img(&info.src, ROTATOR_SRC_DOMAIN, (unsigned long *)&in_paddr, - (unsigned long *)&src_len, &srcp0_file, &ps0_need, - &srcp0_ihdl, 0); - if (rc) { - pr_err("%s: in get_img() failed id=0x%08x\n", - DRIVER_NAME, info.src.memory_id); - goto do_rotate_unlock_mutex; - } - - rc = get_img(&info.dst, ROTATOR_DST_DOMAIN, (unsigned long *)&out_paddr, - (unsigned long *)&dst_len, &dstp0_file, &p_need, - &dstp0_ihdl, img_info->secure); - if (rc) { - pr_err("%s: out get_img() failed id=0x%08x\n", - DRIVER_NAME, info.dst.memory_id); - goto do_rotate_unlock_mutex; - } - - format = msm_rotator_dev->img_info[s]->src.format; - if (((info.version_key & VERSION_KEY_MASK) == 0xA5B4C300) && - ((info.version_key & ~VERSION_KEY_MASK) > 0) && - (src_planes.num_planes == 2)) { - if (checkoffset(info.src.offset, - src_planes.plane_size[0], - src_len)) { - pr_err("%s: invalid src buffer (len=%lu offset=%x)\n", - __func__, src_len, info.src.offset); - rc = -ERANGE; - goto do_rotate_unlock_mutex; - } - if (checkoffset(info.dst.offset, - dst_planes.plane_size[0], - dst_len)) { - pr_err("%s: invalid dst buffer (len=%lu offset=%x)\n", - __func__, dst_len, info.dst.offset); - rc = -ERANGE; - goto do_rotate_unlock_mutex; - } - - rc = get_img(&info.src_chroma, ROTATOR_SRC_DOMAIN, - (unsigned long *)&in_chroma_paddr, - (unsigned long *)&src_len, &srcp1_file, &p_need, - &srcp1_ihdl, 0); - if (rc) { - pr_err("%s: in chroma get_img() failed id=0x%08x\n", - DRIVER_NAME, info.src_chroma.memory_id); - goto do_rotate_unlock_mutex; - } - - rc = get_img(&info.dst_chroma, ROTATOR_DST_DOMAIN, - (unsigned long *)&out_chroma_paddr, - (unsigned long *)&dst_len, &dstp1_file, &p_need, - &dstp1_ihdl, img_info->secure); - if (rc) { - pr_err("%s: out chroma get_img() failed id=0x%08x\n", - DRIVER_NAME, info.dst_chroma.memory_id); - goto do_rotate_unlock_mutex; - } - - if (checkoffset(info.src_chroma.offset, - src_planes.plane_size[1], - src_len)) { - pr_err("%s: invalid chr src buf len=%lu offset=%x\n", - __func__, src_len, info.src_chroma.offset); - rc = -ERANGE; - goto do_rotate_unlock_mutex; - } - - if (checkoffset(info.dst_chroma.offset, - src_planes.plane_size[1], - dst_len)) { - pr_err("%s: invalid chr dst buf len=%lu offset=%x\n", - __func__, dst_len, info.dst_chroma.offset); - rc = -ERANGE; - goto do_rotate_unlock_mutex; - } - - in_chroma_paddr += info.src_chroma.offset; - out_chroma_paddr += info.dst_chroma.offset; - } else { - if (checkoffset(info.src.offset, - src_planes.total_size, - src_len)) { - pr_err("%s: invalid src buffer (len=%lu offset=%x)\n", - __func__, src_len, info.src.offset); - rc = -ERANGE; - goto do_rotate_unlock_mutex; - } - if (checkoffset(info.dst.offset, - dst_planes.total_size, - dst_len)) { - pr_err("%s: invalid dst buffer (len=%lu offset=%x)\n", - __func__, dst_len, info.dst.offset); - rc = -ERANGE; - goto do_rotate_unlock_mutex; - } - } - - in_paddr += info.src.offset; - out_paddr += info.dst.offset; - - if (!in_chroma_paddr && src_planes.num_planes >= 2) - in_chroma_paddr = in_paddr + src_planes.plane_size[0]; - if (!out_chroma_paddr && dst_planes.num_planes >= 2) - out_chroma_paddr = out_paddr + dst_planes.plane_size[0]; - if (src_planes.num_planes >= 3) - in_chroma2_paddr = in_chroma_paddr + src_planes.plane_size[1]; - - cancel_delayed_work(&msm_rotator_dev->rot_clk_work); - if (msm_rotator_dev->rot_clk_state != CLK_EN) { - enable_rot_clks(); - msm_rotator_dev->rot_clk_state = CLK_EN; - } - enable_irq(msm_rotator_dev->irq); - -#ifdef CONFIG_MSM_ROTATOR_USE_IMEM - use_imem = msm_rotator_imem_allocate(ROTATOR_REQUEST); -#else - use_imem = 0; -#endif - /* - * workaround for a hardware bug. rotator hardware hangs when we - * use write burst beat size 16 on 128X128 tile fetch mode. As a - * temporary fix use 0x42 for BURST_SIZE when imem used. - */ - if (use_imem) - iowrite32(0x42, MSM_ROTATOR_MAX_BURST_SIZE); - - iowrite32(((msm_rotator_dev->img_info[s]->src_rect.h & 0x1fff) - << 16) | - (msm_rotator_dev->img_info[s]->src_rect.w & 0x1fff), - MSM_ROTATOR_SRC_SIZE); - iowrite32(((msm_rotator_dev->img_info[s]->src_rect.y & 0x1fff) - << 16) | - (msm_rotator_dev->img_info[s]->src_rect.x & 0x1fff), - MSM_ROTATOR_SRC_XY); - iowrite32(((msm_rotator_dev->img_info[s]->src.height & 0x1fff) - << 16) | - (msm_rotator_dev->img_info[s]->src.width & 0x1fff), - MSM_ROTATOR_SRC_IMAGE_SIZE); - - switch (format) { - case MDP_RGB_565: - case MDP_BGR_565: - case MDP_RGB_888: - case MDP_ARGB_8888: - case MDP_RGBA_8888: - case MDP_XRGB_8888: - case MDP_BGRA_8888: - case MDP_RGBX_8888: - case MDP_BGRX_8888: - case MDP_YCBCR_H1V1: - case MDP_YCRCB_H1V1: - rc = msm_rotator_rgb_types(msm_rotator_dev->img_info[s], - in_paddr, out_paddr, - use_imem, - msm_rotator_dev->last_session_idx - != s); - break; - case MDP_Y_CBCR_H2V2: - case MDP_Y_CRCB_H2V2: - case MDP_Y_CB_CR_H2V2: - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CRCB_H2V2_TILE: - case MDP_Y_CBCR_H2V2_TILE: - rc = msm_rotator_ycxcx_h2v2(msm_rotator_dev->img_info[s], - in_paddr, out_paddr, use_imem, - msm_rotator_dev->last_session_idx - != s, - in_chroma_paddr, - out_chroma_paddr, - in_chroma2_paddr); - break; - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H2V1: - rc = msm_rotator_ycxcx_h2v1(msm_rotator_dev->img_info[s], - in_paddr, out_paddr, use_imem, - msm_rotator_dev->last_session_idx - != s, - in_chroma_paddr, - out_chroma_paddr); - break; - case MDP_YCRYCB_H2V1: - rc = msm_rotator_ycrycb(msm_rotator_dev->img_info[s], - in_paddr, out_paddr, use_imem, - msm_rotator_dev->last_session_idx != s, - out_chroma_paddr); - break; - default: - rc = -EINVAL; - pr_err("%s(): Unsupported format %u\n", __func__, format); - goto do_rotate_exit; - } - - if (rc != 0) { - msm_rotator_dev->last_session_idx = INVALID_SESSION; - pr_err("%s(): Invalid session error\n", __func__); - goto do_rotate_exit; - } - - iowrite32(3, MSM_ROTATOR_INTR_ENABLE); - - msm_rotator_dev->processing = 1; - iowrite32(0x1, MSM_ROTATOR_START); - - wait_event(msm_rotator_dev->wq, - (msm_rotator_dev->processing == 0)); - status = (unsigned char)ioread32(MSM_ROTATOR_INTR_STATUS); - if ((status & 0x03) != 0x01) { - pr_err("%s(): AXI Bus Error, issuing SW_RESET\n", __func__); - iowrite32(0x1, MSM_ROTATOR_SW_RESET); - rc = -EFAULT; - } - iowrite32(0, MSM_ROTATOR_INTR_ENABLE); - iowrite32(3, MSM_ROTATOR_INTR_CLEAR); - -do_rotate_exit: - disable_irq(msm_rotator_dev->irq); -#ifdef CONFIG_MSM_ROTATOR_USE_IMEM - msm_rotator_imem_free(ROTATOR_REQUEST); -#endif - schedule_delayed_work(&msm_rotator_dev->rot_clk_work, HZ); -do_rotate_unlock_mutex: - put_img(dstp1_file, dstp1_ihdl, ROTATOR_DST_DOMAIN, - msm_rotator_dev->img_info[s]->secure); - put_img(srcp1_file, srcp1_ihdl, ROTATOR_SRC_DOMAIN, 0); - put_img(dstp0_file, dstp0_ihdl, ROTATOR_DST_DOMAIN, - msm_rotator_dev->img_info[s]->secure); - - /* only source may use frame buffer */ - if (info.src.flags & MDP_MEMORY_ID_TYPE_FB) - fput_light(srcp0_file, ps0_need); - else - put_img(srcp0_file, srcp0_ihdl, ROTATOR_SRC_DOMAIN, 0); - mutex_unlock(&msm_rotator_dev->rotator_lock); - dev_dbg(msm_rotator_dev->device, "%s() returning rc = %d\n", - __func__, rc); - return rc; -} - -static void msm_rotator_set_perf_level(u32 wh, u32 is_rgb) -{ - u32 perf_level; - - if (is_rgb) - perf_level = 1; - else if (wh <= (640 * 480)) - perf_level = 2; - else if (wh <= (736 * 1280)) - perf_level = 3; - else - perf_level = 4; - -#ifdef CONFIG_MSM_BUS_SCALING - msm_bus_scale_client_update_request(msm_rotator_dev->bus_client_handle, - perf_level); -#endif - -} - -static int msm_rotator_start(unsigned long arg, - struct msm_rotator_fd_info *fd_info) -{ - struct msm_rotator_img_info info; - int rc = 0; - int s, is_rgb = 0; - int first_free_index = INVALID_SESSION; - unsigned int dst_w, dst_h; - - if (copy_from_user(&info, (void __user *)arg, sizeof(info))) - return -EFAULT; - - if ((info.rotations > MSM_ROTATOR_MAX_ROT) || - (info.src.height > MSM_ROTATOR_MAX_H) || - (info.src.width > MSM_ROTATOR_MAX_W) || - (info.dst.height > MSM_ROTATOR_MAX_H) || - (info.dst.width > MSM_ROTATOR_MAX_W) || - (info.downscale_ratio > MAX_DOWNSCALE_RATIO)) { - pr_err("%s: Invalid parameters\n", __func__); - return -EINVAL; - } - - if (info.rotations & MDP_ROT_90) { - dst_w = info.src_rect.h >> info.downscale_ratio; - dst_h = info.src_rect.w >> info.downscale_ratio; - } else { - dst_w = info.src_rect.w >> info.downscale_ratio; - dst_h = info.src_rect.h >> info.downscale_ratio; - } - - if (checkoffset(info.src_rect.x, info.src_rect.w, info.src.width) || - checkoffset(info.src_rect.y, info.src_rect.h, info.src.height) || - checkoffset(info.dst_x, dst_w, info.dst.width) || - checkoffset(info.dst_y, dst_h, info.dst.height)) { - pr_err("%s: Invalid src or dst rect\n", __func__); - return -ERANGE; - } - - switch (info.src.format) { - case MDP_RGB_565: - case MDP_BGR_565: - case MDP_RGB_888: - case MDP_ARGB_8888: - case MDP_RGBA_8888: - case MDP_XRGB_8888: - case MDP_RGBX_8888: - case MDP_BGRA_8888: - case MDP_BGRX_8888: - is_rgb = 1; - info.dst.format = info.src.format; - break; - case MDP_Y_CBCR_H2V1: - if (info.rotations & MDP_ROT_90) { - info.dst.format = MDP_Y_CBCR_H1V2; - break; - } - case MDP_Y_CRCB_H2V1: - if (info.rotations & MDP_ROT_90) { - info.dst.format = MDP_Y_CRCB_H1V2; - break; - } - case MDP_Y_CBCR_H2V2: - case MDP_Y_CRCB_H2V2: - case MDP_YCBCR_H1V1: - case MDP_YCRCB_H1V1: - info.dst.format = info.src.format; - break; - case MDP_YCRYCB_H2V1: - if (info.rotations & MDP_ROT_90) - info.dst.format = MDP_Y_CRCB_H1V2; - else - info.dst.format = MDP_Y_CRCB_H2V1; - break; - case MDP_Y_CB_CR_H2V2: - case MDP_Y_CBCR_H2V2_TILE: - info.dst.format = MDP_Y_CBCR_H2V2; - break; - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CRCB_H2V2_TILE: - info.dst.format = MDP_Y_CRCB_H2V2; - break; - default: - return -EINVAL; - } - - mutex_lock(&msm_rotator_dev->rotator_lock); - - msm_rotator_set_perf_level((info.src.width*info.src.height), is_rgb); - - for (s = 0; s < MAX_SESSIONS; s++) { - if ((msm_rotator_dev->img_info[s] != NULL) && - (info.session_id == - (unsigned int)msm_rotator_dev->img_info[s] - )) { - *(msm_rotator_dev->img_info[s]) = info; - msm_rotator_dev->fd_info[s] = fd_info; - - if (msm_rotator_dev->last_session_idx == s) - msm_rotator_dev->last_session_idx = - INVALID_SESSION; - break; - } - - if ((msm_rotator_dev->img_info[s] == NULL) && - (first_free_index == - INVALID_SESSION)) - first_free_index = s; - } - - if ((s == MAX_SESSIONS) && (first_free_index != INVALID_SESSION)) { - /* allocate a session id */ - msm_rotator_dev->img_info[first_free_index] = - kzalloc(sizeof(struct msm_rotator_img_info), - GFP_KERNEL); - if (!msm_rotator_dev->img_info[first_free_index]) { - printk(KERN_ERR "%s : unable to alloc mem\n", - __func__); - rc = -ENOMEM; - goto rotator_start_exit; - } - info.session_id = (unsigned int) - msm_rotator_dev->img_info[first_free_index]; - *(msm_rotator_dev->img_info[first_free_index]) = info; - msm_rotator_dev->fd_info[first_free_index] = fd_info; - } else if (s == MAX_SESSIONS) { - dev_dbg(msm_rotator_dev->device, "%s: all sessions in use\n", - __func__); - rc = -EBUSY; - } - - if (rc == 0 && copy_to_user((void __user *)arg, &info, sizeof(info))) - rc = -EFAULT; - -rotator_start_exit: - mutex_unlock(&msm_rotator_dev->rotator_lock); - - return rc; -} - -static int msm_rotator_finish(unsigned long arg) -{ - int rc = 0; - int s; - unsigned int session_id; - - if (copy_from_user(&session_id, (void __user *)arg, sizeof(s))) - return -EFAULT; - - mutex_lock(&msm_rotator_dev->rotator_lock); - for (s = 0; s < MAX_SESSIONS; s++) { - if ((msm_rotator_dev->img_info[s] != NULL) && - (session_id == - (unsigned int)msm_rotator_dev->img_info[s])) { - if (msm_rotator_dev->last_session_idx == s) - msm_rotator_dev->last_session_idx = - INVALID_SESSION; - kfree(msm_rotator_dev->img_info[s]); - msm_rotator_dev->img_info[s] = NULL; - msm_rotator_dev->fd_info[s] = NULL; - break; - } - } - - if (s == MAX_SESSIONS) - rc = -EINVAL; -#ifdef CONFIG_MSM_BUS_SCALING - msm_bus_scale_client_update_request(msm_rotator_dev->bus_client_handle, - 0); -#endif - mutex_unlock(&msm_rotator_dev->rotator_lock); - return rc; -} - -static int -msm_rotator_open(struct inode *inode, struct file *filp) -{ - struct msm_rotator_fd_info *tmp, *fd_info = NULL; - int i; - - if (filp->private_data) - return -EBUSY; - - mutex_lock(&msm_rotator_dev->rotator_lock); - for (i = 0; i < MAX_SESSIONS; i++) { - if (msm_rotator_dev->fd_info[i] == NULL) - break; - } - - if (i == MAX_SESSIONS) { - mutex_unlock(&msm_rotator_dev->rotator_lock); - return -EBUSY; - } - - list_for_each_entry(tmp, &msm_rotator_dev->fd_list, list) { - if (tmp->pid == current->pid) { - fd_info = tmp; - break; - } - } - - if (!fd_info) { - fd_info = kzalloc(sizeof(*fd_info), GFP_KERNEL); - if (!fd_info) { - mutex_unlock(&msm_rotator_dev->rotator_lock); - pr_err("%s: insufficient memory to alloc resources\n", - __func__); - return -ENOMEM; - } - list_add(&fd_info->list, &msm_rotator_dev->fd_list); - fd_info->pid = current->pid; - } - fd_info->ref_cnt++; - mutex_unlock(&msm_rotator_dev->rotator_lock); - - filp->private_data = fd_info; - - return 0; -} - -static int -msm_rotator_close(struct inode *inode, struct file *filp) -{ - struct msm_rotator_fd_info *fd_info; - int s; - - fd_info = (struct msm_rotator_fd_info *)filp->private_data; - - mutex_lock(&msm_rotator_dev->rotator_lock); - if (--fd_info->ref_cnt > 0) { - mutex_unlock(&msm_rotator_dev->rotator_lock); - return 0; - } - - for (s = 0; s < MAX_SESSIONS; s++) { - if (msm_rotator_dev->img_info[s] != NULL && - msm_rotator_dev->fd_info[s] == fd_info) { - pr_debug("%s: freeing rotator session %p (pid %d)\n", - __func__, msm_rotator_dev->img_info[s], - fd_info->pid); - kfree(msm_rotator_dev->img_info[s]); - msm_rotator_dev->img_info[s] = NULL; - msm_rotator_dev->fd_info[s] = NULL; - if (msm_rotator_dev->last_session_idx == s) - msm_rotator_dev->last_session_idx = - INVALID_SESSION; - } - } - list_del(&fd_info->list); - kfree(fd_info); - mutex_unlock(&msm_rotator_dev->rotator_lock); - - return 0; -} - -static long msm_rotator_ioctl(struct file *file, unsigned cmd, - unsigned long arg) -{ - struct msm_rotator_fd_info *fd_info; - - if (_IOC_TYPE(cmd) != MSM_ROTATOR_IOCTL_MAGIC) - return -ENOTTY; - - fd_info = (struct msm_rotator_fd_info *)file->private_data; - - switch (cmd) { - case MSM_ROTATOR_IOCTL_START: - return msm_rotator_start(arg, fd_info); - case MSM_ROTATOR_IOCTL_ROTATE: - return msm_rotator_do_rotate(arg); - case MSM_ROTATOR_IOCTL_FINISH: - return msm_rotator_finish(arg); - - default: - dev_dbg(msm_rotator_dev->device, - "unexpected IOCTL %d\n", cmd); - return -ENOTTY; - } -} - -static const struct file_operations msm_rotator_fops = { - .owner = THIS_MODULE, - .open = msm_rotator_open, - .release = msm_rotator_close, - .unlocked_ioctl = msm_rotator_ioctl, -}; - -static int msm_rotator_probe(struct platform_device *pdev) -{ - int rc = 0; - struct resource *res; - struct msm_rotator_platform_data *pdata = NULL; - int i, number_of_clks; - uint32_t ver; - - msm_rotator_dev = kzalloc(sizeof(struct msm_rotator_dev), GFP_KERNEL); - if (!msm_rotator_dev) { - printk(KERN_ERR "%s Unable to allocate memory for struct\n", - __func__); - return -ENOMEM; - } - for (i = 0; i < MAX_SESSIONS; i++) - msm_rotator_dev->img_info[i] = NULL; - msm_rotator_dev->last_session_idx = INVALID_SESSION; - - pdata = pdev->dev.platform_data; - number_of_clks = pdata->number_of_clocks; - rot_iommu_split_domain = pdata->rot_iommu_split_domain; - - msm_rotator_dev->imem_owner = IMEM_NO_OWNER; - mutex_init(&msm_rotator_dev->imem_lock); - INIT_LIST_HEAD(&msm_rotator_dev->fd_list); - msm_rotator_dev->imem_clk_state = CLK_DIS; - INIT_DELAYED_WORK(&msm_rotator_dev->imem_clk_work, - msm_rotator_imem_clk_work_f); - msm_rotator_dev->imem_clk = NULL; - msm_rotator_dev->pdev = pdev; - - msm_rotator_dev->core_clk = NULL; - msm_rotator_dev->pclk = NULL; - -#ifdef CONFIG_MSM_BUS_SCALING - if (!msm_rotator_dev->bus_client_handle && pdata && - pdata->bus_scale_table) { - msm_rotator_dev->bus_client_handle = - msm_bus_scale_register_client( - pdata->bus_scale_table); - if (!msm_rotator_dev->bus_client_handle) { - pr_err("%s not able to get bus scale handle\n", - __func__); - } - } -#endif - - for (i = 0; i < number_of_clks; i++) { - if (pdata->rotator_clks[i].clk_type == ROTATOR_IMEM_CLK) { - msm_rotator_dev->imem_clk = - clk_get(&msm_rotator_dev->pdev->dev, - pdata->rotator_clks[i].clk_name); - if (IS_ERR(msm_rotator_dev->imem_clk)) { - rc = PTR_ERR(msm_rotator_dev->imem_clk); - msm_rotator_dev->imem_clk = NULL; - printk(KERN_ERR "%s: cannot get imem_clk " - "rc=%d\n", DRIVER_NAME, rc); - goto error_imem_clk; - } - if (pdata->rotator_clks[i].clk_rate) - clk_set_rate(msm_rotator_dev->imem_clk, - pdata->rotator_clks[i].clk_rate); - } - if (pdata->rotator_clks[i].clk_type == ROTATOR_PCLK) { - msm_rotator_dev->pclk = - clk_get(&msm_rotator_dev->pdev->dev, - pdata->rotator_clks[i].clk_name); - if (IS_ERR(msm_rotator_dev->pclk)) { - rc = PTR_ERR(msm_rotator_dev->pclk); - msm_rotator_dev->pclk = NULL; - printk(KERN_ERR "%s: cannot get pclk rc=%d\n", - DRIVER_NAME, rc); - goto error_pclk; - } - - if (pdata->rotator_clks[i].clk_rate) - clk_set_rate(msm_rotator_dev->pclk, - pdata->rotator_clks[i].clk_rate); - } - - if (pdata->rotator_clks[i].clk_type == ROTATOR_CORE_CLK) { - msm_rotator_dev->core_clk = - clk_get(&msm_rotator_dev->pdev->dev, - pdata->rotator_clks[i].clk_name); - if (IS_ERR(msm_rotator_dev->core_clk)) { - rc = PTR_ERR(msm_rotator_dev->core_clk); - msm_rotator_dev->core_clk = NULL; - printk(KERN_ERR "%s: cannot get core clk " - "rc=%d\n", DRIVER_NAME, rc); - goto error_core_clk; - } - - if (pdata->rotator_clks[i].clk_rate) - clk_set_rate(msm_rotator_dev->core_clk, - pdata->rotator_clks[i].clk_rate); - } - } - - msm_rotator_dev->regulator = regulator_get(&msm_rotator_dev->pdev->dev, - "vdd"); - if (IS_ERR(msm_rotator_dev->regulator)) - msm_rotator_dev->regulator = NULL; - - msm_rotator_dev->rot_clk_state = CLK_DIS; - INIT_DELAYED_WORK(&msm_rotator_dev->rot_clk_work, - msm_rotator_rot_clk_work_f); - - mutex_init(&msm_rotator_dev->rotator_lock); -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - msm_rotator_dev->client = msm_ion_client_create(-1, pdev->name); -#endif - platform_set_drvdata(pdev, msm_rotator_dev); - - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - printk(KERN_ALERT - "%s: could not get IORESOURCE_MEM\n", DRIVER_NAME); - rc = -ENODEV; - goto error_get_resource; - } - msm_rotator_dev->io_base = ioremap(res->start, - resource_size(res)); - -#ifdef CONFIG_MSM_ROTATOR_USE_IMEM - if (msm_rotator_dev->imem_clk) - clk_prepare_enable(msm_rotator_dev->imem_clk); -#endif - enable_rot_clks(); - ver = ioread32(MSM_ROTATOR_HW_VERSION); - disable_rot_clks(); - -#ifdef CONFIG_MSM_ROTATOR_USE_IMEM - if (msm_rotator_dev->imem_clk) - clk_disable_unprepare(msm_rotator_dev->imem_clk); -#endif - if (ver != pdata->hardware_version_number) - pr_debug("%s: invalid HW version ver 0x%x\n", - DRIVER_NAME, ver); - - rotator_hw_revision = ver; - rotator_hw_revision >>= 16; /* bit 31:16 */ - rotator_hw_revision &= 0xff; - - pr_info("%s: rotator_hw_revision=%x\n", - __func__, rotator_hw_revision); - - msm_rotator_dev->irq = platform_get_irq(pdev, 0); - if (msm_rotator_dev->irq < 0) { - printk(KERN_ALERT "%s: could not get IORESOURCE_IRQ\n", - DRIVER_NAME); - rc = -ENODEV; - goto error_get_irq; - } - rc = request_irq(msm_rotator_dev->irq, msm_rotator_isr, - IRQF_TRIGGER_RISING, DRIVER_NAME, NULL); - if (rc) { - printk(KERN_ERR "%s: request_irq() failed\n", DRIVER_NAME); - goto error_get_irq; - } - /* we enable the IRQ when we need it in the ioctl */ - disable_irq(msm_rotator_dev->irq); - - rc = alloc_chrdev_region(&msm_rotator_dev->dev_num, 0, 1, DRIVER_NAME); - if (rc < 0) { - printk(KERN_ERR "%s: alloc_chrdev_region Failed rc = %d\n", - __func__, rc); - goto error_get_irq; - } - - msm_rotator_dev->class = class_create(THIS_MODULE, DRIVER_NAME); - if (IS_ERR(msm_rotator_dev->class)) { - rc = PTR_ERR(msm_rotator_dev->class); - printk(KERN_ERR "%s: couldn't create class rc = %d\n", - DRIVER_NAME, rc); - goto error_class_create; - } - - msm_rotator_dev->device = device_create(msm_rotator_dev->class, NULL, - msm_rotator_dev->dev_num, NULL, - DRIVER_NAME); - if (IS_ERR(msm_rotator_dev->device)) { - rc = PTR_ERR(msm_rotator_dev->device); - printk(KERN_ERR "%s: device_create failed %d\n", - DRIVER_NAME, rc); - goto error_class_device_create; - } - - cdev_init(&msm_rotator_dev->cdev, &msm_rotator_fops); - rc = cdev_add(&msm_rotator_dev->cdev, - MKDEV(MAJOR(msm_rotator_dev->dev_num), 0), - 1); - if (rc < 0) { - printk(KERN_ERR "%s: cdev_add failed %d\n", __func__, rc); - goto error_cdev_add; - } - - init_waitqueue_head(&msm_rotator_dev->wq); - - dev_dbg(msm_rotator_dev->device, "probe successful\n"); - return rc; - -error_cdev_add: - device_destroy(msm_rotator_dev->class, msm_rotator_dev->dev_num); -error_class_device_create: - class_destroy(msm_rotator_dev->class); -error_class_create: - unregister_chrdev_region(msm_rotator_dev->dev_num, 1); -error_get_irq: - iounmap(msm_rotator_dev->io_base); -error_get_resource: - mutex_destroy(&msm_rotator_dev->rotator_lock); - if (msm_rotator_dev->regulator) - regulator_put(msm_rotator_dev->regulator); - clk_put(msm_rotator_dev->core_clk); -error_core_clk: - clk_put(msm_rotator_dev->pclk); -error_pclk: - if (msm_rotator_dev->imem_clk) - clk_put(msm_rotator_dev->imem_clk); -error_imem_clk: - mutex_destroy(&msm_rotator_dev->imem_lock); - kfree(msm_rotator_dev); - return rc; -} - -static int msm_rotator_remove(struct platform_device *plat_dev) -{ - int i; - -#ifdef CONFIG_MSM_BUS_SCALING - msm_bus_scale_unregister_client(msm_rotator_dev->bus_client_handle); -#endif - free_irq(msm_rotator_dev->irq, NULL); - mutex_destroy(&msm_rotator_dev->rotator_lock); - cdev_del(&msm_rotator_dev->cdev); - device_destroy(msm_rotator_dev->class, msm_rotator_dev->dev_num); - class_destroy(msm_rotator_dev->class); - unregister_chrdev_region(msm_rotator_dev->dev_num, 1); - iounmap(msm_rotator_dev->io_base); - if (msm_rotator_dev->imem_clk) { - if (msm_rotator_dev->imem_clk_state == CLK_EN) - clk_disable_unprepare(msm_rotator_dev->imem_clk); - clk_put(msm_rotator_dev->imem_clk); - msm_rotator_dev->imem_clk = NULL; - } - if (msm_rotator_dev->rot_clk_state == CLK_EN) - disable_rot_clks(); - clk_put(msm_rotator_dev->core_clk); - clk_put(msm_rotator_dev->pclk); - if (msm_rotator_dev->regulator) - regulator_put(msm_rotator_dev->regulator); - msm_rotator_dev->core_clk = NULL; - msm_rotator_dev->pclk = NULL; - mutex_destroy(&msm_rotator_dev->imem_lock); - for (i = 0; i < MAX_SESSIONS; i++) - if (msm_rotator_dev->img_info[i] != NULL) - kfree(msm_rotator_dev->img_info[i]); - kfree(msm_rotator_dev); - return 0; -} - -#ifdef CONFIG_PM -static int msm_rotator_suspend(struct platform_device *dev, pm_message_t state) -{ - mutex_lock(&msm_rotator_dev->imem_lock); - if (msm_rotator_dev->imem_clk_state == CLK_EN - && msm_rotator_dev->imem_clk) { - clk_disable_unprepare(msm_rotator_dev->imem_clk); - msm_rotator_dev->imem_clk_state = CLK_SUSPEND; - } - mutex_unlock(&msm_rotator_dev->imem_lock); - mutex_lock(&msm_rotator_dev->rotator_lock); - if (msm_rotator_dev->rot_clk_state == CLK_EN) { - disable_rot_clks(); - msm_rotator_dev->rot_clk_state = CLK_SUSPEND; - } - mutex_unlock(&msm_rotator_dev->rotator_lock); - return 0; -} - -static int msm_rotator_resume(struct platform_device *dev) -{ - mutex_lock(&msm_rotator_dev->imem_lock); - if (msm_rotator_dev->imem_clk_state == CLK_SUSPEND - && msm_rotator_dev->imem_clk) { - clk_prepare_enable(msm_rotator_dev->imem_clk); - msm_rotator_dev->imem_clk_state = CLK_EN; - } - mutex_unlock(&msm_rotator_dev->imem_lock); - mutex_lock(&msm_rotator_dev->rotator_lock); - if (msm_rotator_dev->rot_clk_state == CLK_SUSPEND) { - enable_rot_clks(); - msm_rotator_dev->rot_clk_state = CLK_EN; - } - mutex_unlock(&msm_rotator_dev->rotator_lock); - return 0; -} -#endif - -static struct platform_driver msm_rotator_platform_driver = { - .probe = msm_rotator_probe, - .remove = msm_rotator_remove, -#ifdef CONFIG_PM - .suspend = msm_rotator_suspend, - .resume = msm_rotator_resume, -#endif - .driver = { - .owner = THIS_MODULE, - .name = DRIVER_NAME - } -}; - -static int __init msm_rotator_init(void) -{ - return platform_driver_register(&msm_rotator_platform_driver); -} - -static void __exit msm_rotator_exit(void) -{ - return platform_driver_unregister(&msm_rotator_platform_driver); -} - -module_init(msm_rotator_init); -module_exit(msm_rotator_exit); - -MODULE_DESCRIPTION("MSM Offline Image Rotator driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index e70aae4378d41178794daa604ba108b4369b9a3f..64bc106197c4d03e9ab6d008cf7e215bb2e2e9ef 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig @@ -91,14 +91,6 @@ config TCG_ST33_I2C To compile this driver as a module, choose M here; the module will be called tpm_stm_st33_i2c. -config TCG_ST_I2C - tristate "ST Micro ST19NP18-TPM-I2C TPM interface" - depends on I2C - default n - ---help--- - If you have a ST19NP18-TPM-I2C TPM security chip from ST Micro - say Yes and it will be accessible from Linux. - config TCG_TPMD_DEV tristate "tpmd_dev TPM Emulator driver" default n diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile index 1a8f3455507fe74a6bf0272ba08cf1403edc4f8b..95e07728177fdc8b57a6a7ae360b91f11b0600fe 100644 --- a/drivers/char/tpm/Makefile +++ b/drivers/char/tpm/Makefile @@ -14,10 +14,8 @@ endif endif obj-$(CONFIG_TCG_TIS) += tpm_tis.o obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o -obj-$(CONFIG_TCG_ST_I2C) += tpm_st_i2c.o obj-$(CONFIG_TCG_NSC) += tpm_nsc.o obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o obj-$(CONFIG_TCG_ST33_I2C) += tpm_i2c_stm_st33.o -obj-$(CONFIG_TCG_TPMD_DEV) += tpmd_dev/ diff --git a/drivers/char/tpm/tpm_st_i2c.c b/drivers/char/tpm/tpm_st_i2c.c deleted file mode 100644 index 333548e2f3a5d4c62654d902124584365c8f8fe9..0000000000000000000000000000000000000000 --- a/drivers/char/tpm/tpm_st_i2c.c +++ /dev/null @@ -1,361 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include -#include -#include -#include -#include "tpm.h" - -#define DEVICE_NAME "tpm_st_i2c" - -#define TPM_HEADER_LEN sizeof(struct tpm_input_header) -#define TPM_ST_I2C_BLOCK_MAX 40 - -struct tpm_st_i2c_dev { - struct i2c_client *client; - struct tpm_st_i2c_platform_data *pd; - struct completion com[2]; -}; - -/* for completion array */ -#define ACCEPT_CMD_INDEX 0 -#define DATA_AVAIL_INDEX 1 - -static struct tpm_st_i2c_dev *tpm_st_i2c_dev; - -#define TPM_ST_I2C_REQ_COMPLETE_MASK 1 - -static u8 tpm_st_i2c_status(struct tpm_chip *chip) -{ - int gpio = tpm_st_i2c_dev->pd->data_avail_gpio; - return gpio_get_value(gpio); -} - -static void tpm_st_i2c_cancel(struct tpm_chip *chip) -{ - /* not supported */ - return; -} - -static int tpm_st_i2c_transfer_buf(struct tpm_chip *chip, u8 *buf, size_t count, - int recv) -{ - struct i2c_msg msg = { - .addr = tpm_st_i2c_dev->client->addr, - .flags = 0, - .buf = buf, - .len = TPM_HEADER_LEN, /* must read/write header first */ - }; - int gpio; - int irq; - struct completion *com; - __be32 *native_size; - int read_header = 0; - int rc = 0; - int len = count; - uint32_t size = count; - int tmp; - - if (recv) { - msg.flags |= I2C_M_RD; - read_header = 1; - gpio = tpm_st_i2c_dev->pd->data_avail_gpio; - irq = tpm_st_i2c_dev->pd->data_avail_irq; - com = &tpm_st_i2c_dev->com[DATA_AVAIL_INDEX]; - } else { - gpio = tpm_st_i2c_dev->pd->accept_cmd_gpio; - irq = tpm_st_i2c_dev->pd->accept_cmd_irq; - com = &tpm_st_i2c_dev->com[ACCEPT_CMD_INDEX]; - } - - if (len < TPM_HEADER_LEN) { - dev_dbg(chip->dev, "%s: invalid len\n", __func__); - return -EINVAL; - } - - do { - if (!gpio_get_value(gpio)) { - /* reset the completion in case the irq fired - * during the probe - */ - init_completion(com); - enable_irq(irq); - tmp = wait_for_completion_interruptible_timeout( - com, HZ/2); - if (!tmp) { - dev_dbg(chip->dev, "%s timeout\n", - __func__); - return -EBUSY; - } - } - rc = i2c_transfer(tpm_st_i2c_dev->client->adapter, - &msg, 1); - if (rc < 0) { - dev_dbg(chip->dev, "Error in I2C transfer\n"); - return rc; - } - if (read_header) { - read_header = 0; - native_size = (__force __be32 *) (buf + 2); - size = be32_to_cpu(*native_size); - if (count < size) { - dev_dbg(chip->dev, - "%s: invalid count\n", - __func__); - rc = -EIO; - } - len = size; - } - len -= msg.len; - if (len) { - buf += msg.len; - msg.buf = buf; - if (len > TPM_ST_I2C_BLOCK_MAX) - msg.len = TPM_ST_I2C_BLOCK_MAX; - else - msg.len = len; - } - } while (len > 0); - - if (rc >= 0) - return size; - else - return rc; -} - -static int tpm_st_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count) -{ - return tpm_st_i2c_transfer_buf(chip, buf, count, 1); -} - -static int tpm_st_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) -{ - return tpm_st_i2c_transfer_buf(chip, buf, len, 0); -} - -#ifdef CONFIG_PM -static int tpm_st_i2c_suspend(struct i2c_client *client, pm_message_t msg) -{ - return tpm_pm_suspend(&client->dev, msg); -} - -static int tpm_st_i2c_resume(struct i2c_client *client) -{ - return tpm_pm_resume(&client->dev); -} -#endif - -static const struct file_operations tpm_st_i2c_fs_ops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .open = tpm_open, - .read = tpm_read, - .write = tpm_write, - .release = tpm_release, -}; - -static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); -static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL); -static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL); -static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL); -static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL); -static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, - NULL); -static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL); - -static struct attribute *tpm_st_i2c_attrs[] = { - &dev_attr_pubek.attr, - &dev_attr_pcrs.attr, - &dev_attr_enabled.attr, - &dev_attr_active.attr, - &dev_attr_owned.attr, - &dev_attr_temp_deactivated.attr, - &dev_attr_caps.attr, - NULL, -}; - -static struct attribute_group tpm_st_i2c_attr_grp = { - .attrs = tpm_st_i2c_attrs -}; - -static struct tpm_vendor_specific tpm_st_i2c_vendor = { - .status = tpm_st_i2c_status, - .recv = tpm_st_i2c_recv, - .send = tpm_st_i2c_send, - .cancel = tpm_st_i2c_cancel, - .req_complete_mask = TPM_ST_I2C_REQ_COMPLETE_MASK, - .req_complete_val = TPM_ST_I2C_REQ_COMPLETE_MASK, - .req_canceled = 0xff, /* not supported */ - .attr_group = &tpm_st_i2c_attr_grp, - .miscdev = { - .fops = &tpm_st_i2c_fs_ops,}, -}; - -static irqreturn_t tpm_st_i2c_isr(int irq, void *dev_id) -{ - disable_irq_nosync(irq); - if (irq == tpm_st_i2c_dev->pd->accept_cmd_irq) - complete(&tpm_st_i2c_dev->com[ACCEPT_CMD_INDEX]); - else - complete(&tpm_st_i2c_dev->com[DATA_AVAIL_INDEX]); - return IRQ_HANDLED; -} - -static int tpm_st_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int rc = 0; - struct tpm_st_i2c_platform_data *pd; - struct tpm_chip *chip; - int high; - - dev_dbg(&client->dev, "%s()\n", __func__); - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE | - I2C_FUNC_SMBUS_I2C_BLOCK | - I2C_FUNC_I2C)) { - dev_err(&client->dev, "incompatible adapter\n"); - return -ENODEV; - } - - pd = client->dev.platform_data; - if (!pd || !pd->gpio_setup || !pd->gpio_release) { - dev_err(&client->dev, "platform data not setup\n"); - rc = -EFAULT; - goto no_platform_data; - } - rc = pd->gpio_setup(); - if (rc) { - dev_err(&client->dev, "gpio_setup failed\n"); - goto gpio_setup_fail; - } - - gpio_direction_input(pd->accept_cmd_gpio); - gpio_direction_input(pd->data_avail_gpio); - - tpm_st_i2c_dev = kzalloc(sizeof(struct tpm_st_i2c_dev), GFP_KERNEL); - if (!tpm_st_i2c_dev) { - printk(KERN_ERR "%s Unable to allocate memory for struct\n", - __func__); - rc = -ENOMEM; - goto kzalloc_fail; - } - - tpm_st_i2c_dev->client = client; - tpm_st_i2c_dev->pd = pd; - - init_completion(&tpm_st_i2c_dev->com[ACCEPT_CMD_INDEX]); - init_completion(&tpm_st_i2c_dev->com[DATA_AVAIL_INDEX]); - /* This logic allows us to setup irq but not have it enabled, in - * case the lines are already active - */ - high = gpio_get_value(pd->data_avail_gpio); - rc = request_irq(pd->data_avail_irq, tpm_st_i2c_isr, IRQF_TRIGGER_HIGH, - DEVICE_NAME "-data", NULL); - if (rc) { - dev_err(&client->dev, "request for data irq failed\n"); - goto data_irq_fail; - } - if (!high) - disable_irq(pd->data_avail_irq); - high = gpio_get_value(pd->accept_cmd_gpio); - rc = request_irq(pd->accept_cmd_irq, tpm_st_i2c_isr, IRQF_TRIGGER_HIGH, - DEVICE_NAME "-cmd", NULL); - if (rc) { - dev_err(&client->dev, "request for cmd irq failed\n"); - goto cmd_irq_fail; - } - if (!high) - disable_irq(pd->accept_cmd_irq); - - tpm_st_i2c_vendor.irq = pd->data_avail_irq; - - chip = tpm_register_hardware(&client->dev, &tpm_st_i2c_vendor); - if (!chip) { - dev_err(&client->dev, "Could not register tpm hardware\n"); - rc = -ENODEV; - goto tpm_reg_fail; - } - - dev_info(&client->dev, "added\n"); - - return 0; - -tpm_reg_fail: - free_irq(pd->accept_cmd_irq, NULL); -cmd_irq_fail: - free_irq(pd->data_avail_irq, NULL); -data_irq_fail: -kzalloc_fail: - pd->gpio_release(); -gpio_setup_fail: -no_platform_data: - - return rc; -} - -static int __exit tpm_st_i2c_remove(struct i2c_client *client) -{ - free_irq(tpm_st_i2c_dev->pd->accept_cmd_irq, NULL); - free_irq(tpm_st_i2c_dev->pd->data_avail_irq, NULL); - tpm_remove_hardware(&client->dev); - tpm_st_i2c_dev->pd->gpio_release(); - kfree(tpm_st_i2c_dev); - - return 0; -} - -static const struct i2c_device_id tpm_st_i2c_id[] = { - { DEVICE_NAME, 0 }, - { } -}; - -static struct i2c_driver tpm_st_i2c_driver = { - .driver = { - .name = DEVICE_NAME, - .owner = THIS_MODULE, - }, - .probe = tpm_st_i2c_probe, - .remove = __exit_p(tpm_st_i2c_remove), -#ifdef CONFIG_PM - .suspend = tpm_st_i2c_suspend, - .resume = tpm_st_i2c_resume, -#endif - .id_table = tpm_st_i2c_id, -}; - -static int __init tpm_st_i2c_init(void) -{ - int ret; - - ret = i2c_add_driver(&tpm_st_i2c_driver); - if (ret) - printk(KERN_ERR "%s: failed to add i2c driver\n", __func__); - - return ret; -} - -static void __exit tpm_st_i2c_exit(void) -{ - i2c_del_driver(&tpm_st_i2c_driver); -} - -module_init(tpm_st_i2c_init); -module_exit(tpm_st_i2c_exit); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("1.0"); -MODULE_AUTHOR("Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("ST19NP18-TPM-I2C driver"); diff --git a/drivers/char/tpm/tpmd_dev/Makefile b/drivers/char/tpm/tpmd_dev/Makefile deleted file mode 100644 index 7d62de463de1532108ad286f8fb39571b5d8161a..0000000000000000000000000000000000000000 --- a/drivers/char/tpm/tpmd_dev/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# -# Makefile for the kernel tpm emulator device driver. -# -obj-$(CONFIG_TCG_TPM) += tpmd_dev.o diff --git a/drivers/char/tpm/tpmd_dev/config.h b/drivers/char/tpm/tpmd_dev/config.h deleted file mode 100644 index ec8d93e535d0987ce7459145574e8cbecf469a98..0000000000000000000000000000000000000000 --- a/drivers/char/tpm/tpmd_dev/config.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Software-based Trusted Platform Module (TPM) Emulator - * Copyright (C) 2004-2010 Mario Strasser - * - * This module 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; either version 2 of the License, - * or (at your option) any later version. - * - * This module 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. - * - * $Id: config.h.in 426 2010-02-22 17:11:58Z mast $ - */ - -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -/* project and build version */ -#define VERSION_MAJOR 0 -#define VERSION_MINOR 7 -#define VERSION_BUILD 424 - -/* TDDL and LKM configuration */ -#define TPM_SOCKET_NAME "/var/run/tpm/tpmd_socket:0" -#define TPM_STORAGE_NAME "/var/lib/tpm/tpm_emulator-1_2_0_7" -#define TPM_DEVICE_NAME "/dev/tpm" -#define TPM_LOG_FILE "" -#define TPM_CMD_BUF_SIZE 4096 - -#endif /* _CONFIG_H_ */ diff --git a/drivers/char/tpm/tpmd_dev/tpmd_dev.c b/drivers/char/tpm/tpmd_dev/tpmd_dev.c deleted file mode 100644 index cbfcbd869d912a85c9bcc965a73044cac34c0295..0000000000000000000000000000000000000000 --- a/drivers/char/tpm/tpmd_dev/tpmd_dev.c +++ /dev/null @@ -1,272 +0,0 @@ -/* Software-based Trusted Platform Module (TPM) Emulator - * Copyright (C) 2004-2010 Mario Strasser - * - * This module 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; either version 2 of the License, - * or (at your option) any later version. - * - * This module 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. - * - * $Id: tpmd_dev.c 426 2010-02-22 17:11:58Z mast $ - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "config.h" - -#define TPM_DEVICE_MINOR 224 -#define TPM_DEVICE_ID "tpm" -#define TPM_MODULE_NAME "tpmd_dev" - -#define TPM_STATE_IS_OPEN 0 - -#ifdef DEBUG -#define debug(fmt, ...) printk(KERN_DEBUG "%s %s:%d: Debug: " fmt "\n", \ - TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) -#else -#define debug(fmt, ...) -#endif -#define info(fmt, ...) printk(KERN_INFO "%s %s:%d: Info: " fmt "\n", \ - TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) -#define error(fmt, ...) printk(KERN_ERR "%s %s:%d: Error: " fmt "\n", \ - TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) -#define alert(fmt, ...) printk(KERN_ALERT "%s %s:%d: Alert: " fmt "\n", \ - TPM_MODULE_NAME, __FILE__, __LINE__, ## __VA_ARGS__) - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Mario Strasser "); -MODULE_DESCRIPTION("Trusted Platform Module (TPM) Emulator"); -MODULE_SUPPORTED_DEVICE(TPM_DEVICE_ID); - -/* module parameters */ -char *tpmd_socket_name = TPM_SOCKET_NAME; -module_param(tpmd_socket_name, charp, 0444); -MODULE_PARM_DESC(tpmd_socket_name, " Sets the name of the TPM daemon socket."); - -/* TPM lock */ -static struct semaphore tpm_mutex; - -/* TPM command response */ -static struct { - uint8_t *data; - uint32_t size; -} tpm_response; - -/* module state */ -static uint32_t module_state; -static struct socket *tpmd_sock; -static struct sockaddr_un addr; - -static int tpmd_connect(char *socket_name) -{ - int res; - res = sock_create(PF_UNIX, SOCK_STREAM, 0, &tpmd_sock); - if (res != 0) { - error("sock_create() failed: %d\n", res); - tpmd_sock = NULL; - return res; - } - addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, socket_name, sizeof(addr.sun_path)); - res = tpmd_sock->ops->connect(tpmd_sock, - (struct sockaddr*)&addr, sizeof(struct sockaddr_un), 0); - if (res != 0) { - error("sock_connect() failed: %d\n", res); - tpmd_sock->ops->release(tpmd_sock); - tpmd_sock = NULL; - return res; - } - return 0; -} - -static void tpmd_disconnect(void) -{ - if (tpmd_sock != NULL) tpmd_sock->ops->release(tpmd_sock); - tpmd_sock = NULL; -} - -static int tpmd_handle_command(const uint8_t *in, uint32_t in_size) -{ - int res; - mm_segment_t oldmm; - struct msghdr msg; - struct iovec iov; - /* send command to tpmd */ - memset(&msg, 0, sizeof(msg)); - iov.iov_base = (void*)in; - iov.iov_len = in_size; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - res = sock_sendmsg(tpmd_sock, &msg, in_size); - if (res < 0) { - error("sock_sendmsg() failed: %d\n", res); - return res; - } - /* receive response from tpmd */ - tpm_response.size = TPM_CMD_BUF_SIZE; - tpm_response.data = kmalloc(tpm_response.size, GFP_KERNEL); - if (tpm_response.data == NULL) return -1; - memset(&msg, 0, sizeof(msg)); - iov.iov_base = (void*)tpm_response.data; - iov.iov_len = tpm_response.size; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - oldmm = get_fs(); - set_fs(KERNEL_DS); - res = sock_recvmsg(tpmd_sock, &msg, tpm_response.size, 0); - set_fs(oldmm); - if (res < 0) { - error("sock_recvmsg() failed: %d\n", res); - tpm_response.data = NULL; - return res; - } - tpm_response.size = res; - return 0; -} - -static int tpm_open(struct inode *inode, struct file *file) -{ - int res; - debug("%s()", __FUNCTION__); - if (test_and_set_bit(TPM_STATE_IS_OPEN, (void*)&module_state)) return -EBUSY; - down(&tpm_mutex); - res = tpmd_connect(tpmd_socket_name); - up(&tpm_mutex); - if (res != 0) { - clear_bit(TPM_STATE_IS_OPEN, (void*)&module_state); - return -EIO; - } - return 0; -} - -static int tpm_release(struct inode *inode, struct file *file) -{ - debug("%s()", __FUNCTION__); - down(&tpm_mutex); - if (tpm_response.data != NULL) { - kfree(tpm_response.data); - tpm_response.data = NULL; - } - tpmd_disconnect(); - up(&tpm_mutex); - clear_bit(TPM_STATE_IS_OPEN, (void*)&module_state); - return 0; -} - -static ssize_t tpm_read(struct file *file, char *buf, size_t count, loff_t *ppos) -{ - debug("%s(%zd)", __FUNCTION__, count); - down(&tpm_mutex); - if (tpm_response.data != NULL) { - count = min(count, (size_t)tpm_response.size - (size_t)*ppos); - count -= copy_to_user(buf, &tpm_response.data[*ppos], count); - *ppos += count; - if ((size_t)tpm_response.size == (size_t)*ppos) { - kfree(tpm_response.data); - tpm_response.data = NULL; - } - } else { - count = 0; - } - up(&tpm_mutex); - return count; -} - -static ssize_t tpm_write(struct file *file, const char *buf, size_t count, loff_t *ppos) -{ - debug("%s(%zd)", __FUNCTION__, count); - down(&tpm_mutex); - *ppos = 0; - if (tpm_response.data != NULL) { - kfree(tpm_response.data); - tpm_response.data = NULL; - } - if (tpmd_handle_command(buf, count) != 0) { - count = -EILSEQ; - tpm_response.data = NULL; - } - up(&tpm_mutex); - return count; -} - -#define TPMIOC_CANCEL _IO('T', 0x00) -#define TPMIOC_TRANSMIT _IO('T', 0x01) - -static int tpm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) -{ - debug("%s(%d, %p)", __FUNCTION__, cmd, (char*)arg); - if (cmd == TPMIOC_TRANSMIT) { - uint32_t count = ntohl(*(uint32_t*)(arg + 2)); - down(&tpm_mutex); - if (tpm_response.data != NULL) { - kfree(tpm_response.data); - tpm_response.data = NULL; - } - if (tpmd_handle_command((char*)arg, count) == 0) { - tpm_response.size -= copy_to_user((char*)arg, tpm_response.data, tpm_response.size); - kfree(tpm_response.data); - tpm_response.data = NULL; - } else { - tpm_response.size = 0; - tpm_response.data = NULL; - } - up(&tpm_mutex); - return tpm_response.size; - } - return -1; -} - -struct file_operations fops = { - .owner = THIS_MODULE, - .open = tpm_open, - .release = tpm_release, - .read = tpm_read, - .write = tpm_write, - .ioctl = tpm_ioctl, -}; - -static struct miscdevice tpm_dev = { - .minor = TPM_DEVICE_MINOR, - .name = TPM_DEVICE_ID, - .fops = &fops, -}; - -int __init init_tpm_module(void) -{ - int res = misc_register(&tpm_dev); - if (res != 0) { - error("misc_register() failed for minor %d\n", TPM_DEVICE_MINOR); - return res; - } - /* initialize variables */ - sema_init(&tpm_mutex, 1); - module_state = 0; - tpm_response.data = NULL; - tpm_response.size = 0; - tpmd_sock = NULL; - return 0; -} - -void __exit cleanup_tpm_module(void) -{ - misc_deregister(&tpm_dev); - tpmd_disconnect(); - if (tpm_response.data != NULL) kfree(tpm_response.data); -} - -module_init(init_tpm_module); -module_exit(cleanup_tpm_module); - diff --git a/drivers/coresight/Kconfig b/drivers/coresight/Kconfig index fc6df7bf524338d5a6ba8efa6e047002ac81cae2..47a324e81709ae99c21e656fd5b0fd8d5cfdb11f 100644 --- a/drivers/coresight/Kconfig +++ b/drivers/coresight/Kconfig @@ -71,13 +71,6 @@ config CORESIGHT_TPIU This driver provides support for Trace Port Interface Unit which acts as a conduit for offchip trace collection. -config CORESIGHT_ETB - bool "CoreSight Embedded Trace Buffer driver" - select HAVE_CORESIGHT_SINK - help - This driver provides support for the legacy Embedded Trace Buffer - which is a circular buffer. - if HAVE_CORESIGHT_SINK config CORESIGHT_FUNNEL diff --git a/drivers/coresight/Makefile b/drivers/coresight/Makefile index 9d93a6cb609059bd17683ce828d9f146ee281b44..7140c1ab3bdfe86fcb5b477d7c11c06c339ed5a8 100644 --- a/drivers/coresight/Makefile +++ b/drivers/coresight/Makefile @@ -7,7 +7,6 @@ obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o obj-$(CONFIG_CORESIGHT_CSR) += coresight-csr.o obj-$(CONFIG_CORESIGHT_TMC) += coresight-tmc.o obj-$(CONFIG_CORESIGHT_TPIU) += coresight-tpiu.o -obj-$(CONFIG_CORESIGHT_ETB) += coresight-etb.o obj-$(CONFIG_CORESIGHT_FUNNEL) += coresight-funnel.o obj-$(CONFIG_CORESIGHT_REPLICATOR) += coresight-replicator.o obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o diff --git a/drivers/coresight/coresight-etb.c b/drivers/coresight/coresight-etb.c deleted file mode 100644 index cf2508acfecb5fedf7d143f7e97de18cd596172d..0000000000000000000000000000000000000000 --- a/drivers/coresight/coresight-etb.c +++ /dev/null @@ -1,470 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "coresight-priv.h" - -#define etb_writel(drvdata, val, off) __raw_writel((val), drvdata->base + off) -#define etb_readl(drvdata, off) __raw_readl(drvdata->base + off) - -#define ETB_LOCK(drvdata) \ -do { \ - mb(); \ - etb_writel(drvdata, 0x0, CORESIGHT_LAR); \ -} while (0) -#define ETB_UNLOCK(drvdata) \ -do { \ - etb_writel(drvdata, CORESIGHT_UNLOCK, CORESIGHT_LAR); \ - mb(); \ -} while (0) - -#define ETB_RAM_DEPTH_REG (0x004) -#define ETB_STATUS_REG (0x00C) -#define ETB_RAM_READ_DATA_REG (0x010) -#define ETB_RAM_READ_POINTER (0x014) -#define ETB_RAM_WRITE_POINTER (0x018) -#define ETB_TRG (0x01C) -#define ETB_CTL_REG (0x020) -#define ETB_RWD_REG (0x024) -#define ETB_FFSR (0x300) -#define ETB_FFCR (0x304) -#define ETB_ITMISCOP0 (0xEE0) -#define ETB_ITTRFLINACK (0xEE4) -#define ETB_ITTRFLIN (0xEE8) -#define ETB_ITATBDATA0 (0xEEC) -#define ETB_ITATBCTR2 (0xEF0) -#define ETB_ITATBCTR1 (0xEF4) -#define ETB_ITATBCTR0 (0xEF8) - -#define BYTES_PER_WORD 4 -#define ETB_SIZE_WORDS 4096 -#define FRAME_SIZE_WORDS 4 - -struct etb_drvdata { - void __iomem *base; - struct device *dev; - struct coresight_device *csdev; - struct miscdevice miscdev; - struct clk *clk; - spinlock_t spinlock; - bool reading; - atomic_t in_use; - uint8_t *buf; - bool enable; - uint32_t trigger_cntr; -}; - -static void __etb_enable(struct etb_drvdata *drvdata) -{ - int i; - - ETB_UNLOCK(drvdata); - - etb_writel(drvdata, 0x0, ETB_RAM_WRITE_POINTER); - for (i = 0; i < ETB_SIZE_WORDS; i++) - etb_writel(drvdata, 0x0, ETB_RWD_REG); - - etb_writel(drvdata, 0x0, ETB_RAM_WRITE_POINTER); - etb_writel(drvdata, 0x0, ETB_RAM_READ_POINTER); - - etb_writel(drvdata, drvdata->trigger_cntr, ETB_TRG); - etb_writel(drvdata, BIT(13) | BIT(0), ETB_FFCR); - etb_writel(drvdata, BIT(0), ETB_CTL_REG); - - ETB_LOCK(drvdata); -} - -static int etb_enable(struct coresight_device *csdev) -{ - struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - int ret; - unsigned long flags; - - ret = clk_prepare_enable(drvdata->clk); - if (ret) - return ret; - - spin_lock_irqsave(&drvdata->spinlock, flags); - __etb_enable(drvdata); - drvdata->enable = true; - spin_unlock_irqrestore(&drvdata->spinlock, flags); - - dev_info(drvdata->dev, "ETB enabled\n"); - return 0; -} - -static void __etb_disable(struct etb_drvdata *drvdata) -{ - int count; - uint32_t ffcr; - - ETB_UNLOCK(drvdata); - - ffcr = etb_readl(drvdata, ETB_FFCR); - ffcr |= BIT(12); - etb_writel(drvdata, ffcr, ETB_FFCR); - ffcr |= BIT(6); - etb_writel(drvdata, ffcr, ETB_FFCR); - for (count = TIMEOUT_US; BVAL(etb_readl(drvdata, ETB_FFCR), 6) != 0 - && count > 0; count--) - udelay(1); - WARN(count == 0, "timeout while flushing DRVDATA, ETB_FFCR: %#x\n", - etb_readl(drvdata, ETB_FFCR)); - - etb_writel(drvdata, 0x0, ETB_CTL_REG); - for (count = TIMEOUT_US; BVAL(etb_readl(drvdata, ETB_FFSR), 1) != 1 - && count > 0; count--) - udelay(1); - WARN(count == 0, "timeout while disabling DRVDATA, ETB_FFSR: %#x\n", - etb_readl(drvdata, ETB_FFSR)); - - ETB_LOCK(drvdata); -} - -static void __etb_dump(struct etb_drvdata *drvdata) -{ - int i; - uint8_t *buf_ptr; - uint32_t read_data; - uint32_t read_ptr; - uint32_t write_ptr; - uint32_t frame_off; - uint32_t frame_endoff; - - ETB_UNLOCK(drvdata); - - read_ptr = etb_readl(drvdata, ETB_RAM_READ_POINTER); - write_ptr = etb_readl(drvdata, ETB_RAM_WRITE_POINTER); - - frame_off = write_ptr % FRAME_SIZE_WORDS; - frame_endoff = FRAME_SIZE_WORDS - frame_off; - if (frame_off) { - dev_err(drvdata->dev, "write_ptr: %lu not aligned to formatter " - "frame size\n", (unsigned long)write_ptr); - dev_err(drvdata->dev, "frameoff: %lu, frame_endoff: %lu\n", - (unsigned long)frame_off, (unsigned long)frame_endoff); - write_ptr += frame_endoff; - } - - if ((etb_readl(drvdata, ETB_STATUS_REG) & BIT(0)) == 0) - etb_writel(drvdata, 0x0, ETB_RAM_READ_POINTER); - else - etb_writel(drvdata, write_ptr, ETB_RAM_READ_POINTER); - - buf_ptr = drvdata->buf; - for (i = 0; i < ETB_SIZE_WORDS; i++) { - read_data = etb_readl(drvdata, ETB_RAM_READ_DATA_REG); - *buf_ptr++ = read_data >> 0; - *buf_ptr++ = read_data >> 8; - *buf_ptr++ = read_data >> 16; - *buf_ptr++ = read_data >> 24; - } - - if (frame_off) { - buf_ptr -= (frame_endoff * BYTES_PER_WORD); - for (i = 0; i < frame_endoff; i++) { - *buf_ptr++ = 0x0; - *buf_ptr++ = 0x0; - *buf_ptr++ = 0x0; - *buf_ptr++ = 0x0; - } - } - - etb_writel(drvdata, read_ptr, ETB_RAM_READ_POINTER); - - ETB_LOCK(drvdata); -} - -static void etb_disable(struct coresight_device *csdev) -{ - struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - unsigned long flags; - - spin_lock_irqsave(&drvdata->spinlock, flags); - __etb_disable(drvdata); - __etb_dump(drvdata); - drvdata->enable = false; - spin_unlock_irqrestore(&drvdata->spinlock, flags); - - clk_disable_unprepare(drvdata->clk); - - dev_info(drvdata->dev, "ETB disabled\n"); -} - -static void etb_abort(struct coresight_device *csdev) -{ - struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - unsigned long flags; - - spin_lock_irqsave(&drvdata->spinlock, flags); - __etb_disable(drvdata); - __etb_dump(drvdata); - drvdata->enable = false; - spin_unlock_irqrestore(&drvdata->spinlock, flags); - - dev_info(drvdata->dev, "ETB aborted\n"); -} - -static const struct coresight_ops_sink etb_sink_ops = { - .enable = etb_enable, - .disable = etb_disable, - .abort = etb_abort, -}; - -static const struct coresight_ops etb_cs_ops = { - .sink_ops = &etb_sink_ops, -}; - -static void etb_dump(struct etb_drvdata *drvdata) -{ - unsigned long flags; - - spin_lock_irqsave(&drvdata->spinlock, flags); - if (drvdata->enable) { - __etb_disable(drvdata); - __etb_dump(drvdata); - __etb_enable(drvdata); - } - spin_unlock_irqrestore(&drvdata->spinlock, flags); - - dev_info(drvdata->dev, "ETB dumped\n"); -} - -static int etb_open(struct inode *inode, struct file *file) -{ - struct etb_drvdata *drvdata = container_of(file->private_data, - struct etb_drvdata, miscdev); - - if (atomic_cmpxchg(&drvdata->in_use, 0, 1)) - return -EBUSY; - - dev_dbg(drvdata->dev, "%s: successfully opened\n", __func__); - return 0; -} - -static ssize_t etb_read(struct file *file, char __user *data, - size_t len, loff_t *ppos) -{ - struct etb_drvdata *drvdata = container_of(file->private_data, - struct etb_drvdata, miscdev); - - if (drvdata->reading == false) { - etb_dump(drvdata); - drvdata->reading = true; - } - - if (*ppos + len > ETB_SIZE_WORDS * BYTES_PER_WORD) - len = ETB_SIZE_WORDS * BYTES_PER_WORD - *ppos; - - if (copy_to_user(data, drvdata->buf + *ppos, len)) { - dev_dbg(drvdata->dev, "%s: copy_to_user failed\n", __func__); - return -EFAULT; - } - - *ppos += len; - - dev_dbg(drvdata->dev, "%s: %d bytes copied, %d bytes left\n", - __func__, len, (int) (ETB_SIZE_WORDS * BYTES_PER_WORD - *ppos)); - return len; -} - -static int etb_release(struct inode *inode, struct file *file) -{ - struct etb_drvdata *drvdata = container_of(file->private_data, - struct etb_drvdata, miscdev); - - drvdata->reading = false; - atomic_set(&drvdata->in_use, 0); - - dev_dbg(drvdata->dev, "%s: released\n", __func__); - return 0; -} - -static const struct file_operations etb_fops = { - .owner = THIS_MODULE, - .open = etb_open, - .read = etb_read, - .release = etb_release, - .llseek = no_llseek, -}; - -static ssize_t etb_show_trigger_cntr(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent); - unsigned long val = drvdata->trigger_cntr; - - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); -} - -static ssize_t etb_store_trigger_cntr(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct etb_drvdata *drvdata = dev_get_drvdata(dev->parent); - unsigned long val; - - if (sscanf(buf, "%lx", &val) != 1) - return -EINVAL; - - drvdata->trigger_cntr = val; - return size; -} -static DEVICE_ATTR(trigger_cntr, S_IRUGO | S_IWUSR, etb_show_trigger_cntr, - etb_store_trigger_cntr); - -static struct attribute *etb_attrs[] = { - &dev_attr_trigger_cntr.attr, - NULL, -}; - -static struct attribute_group etb_attr_grp = { - .attrs = etb_attrs, -}; - -static const struct attribute_group *etb_attr_grps[] = { - &etb_attr_grp, - NULL, -}; - -static int etb_probe(struct platform_device *pdev) -{ - int ret; - struct device *dev = &pdev->dev; - struct coresight_platform_data *pdata; - struct etb_drvdata *drvdata; - struct resource *res; - struct coresight_desc *desc; - - if (coresight_fuse_access_disabled()) - return -EPERM; - - if (pdev->dev.of_node) { - pdata = of_get_coresight_platform_data(dev, pdev->dev.of_node); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - pdev->dev.platform_data = pdata; - } - - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) - return -ENOMEM; - drvdata->dev = &pdev->dev; - platform_set_drvdata(pdev, drvdata); - - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "etb-base"); - if (!res) - return -ENODEV; - - drvdata->base = devm_ioremap(dev, res->start, resource_size(res)); - if (!drvdata->base) - return -ENOMEM; - - spin_lock_init(&drvdata->spinlock); - - drvdata->clk = devm_clk_get(dev, "core_clk"); - if (IS_ERR(drvdata->clk)) - return PTR_ERR(drvdata->clk); - - ret = clk_set_rate(drvdata->clk, CORESIGHT_CLK_RATE_TRACE); - if (ret) - return ret; - - drvdata->buf = devm_kzalloc(dev, ETB_SIZE_WORDS * BYTES_PER_WORD, - GFP_KERNEL); - if (!drvdata->buf) - return -ENOMEM; - - desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); - if (!desc) - return -ENOMEM; - desc->type = CORESIGHT_DEV_TYPE_SINK; - desc->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; - desc->ops = &etb_cs_ops; - desc->pdata = pdev->dev.platform_data; - desc->dev = &pdev->dev; - desc->groups = etb_attr_grps; - desc->owner = THIS_MODULE; - drvdata->csdev = coresight_register(desc); - if (IS_ERR(drvdata->csdev)) - return PTR_ERR(drvdata->csdev); - - drvdata->miscdev.name = ((struct coresight_platform_data *) - (pdev->dev.platform_data))->name; - drvdata->miscdev.minor = MISC_DYNAMIC_MINOR; - drvdata->miscdev.fops = &etb_fops; - ret = misc_register(&drvdata->miscdev); - if (ret) - goto err; - - dev_info(dev, "ETB initialized\n"); - return 0; -err: - coresight_unregister(drvdata->csdev); - return ret; -} - -static int etb_remove(struct platform_device *pdev) -{ - struct etb_drvdata *drvdata = platform_get_drvdata(pdev); - - misc_deregister(&drvdata->miscdev); - coresight_unregister(drvdata->csdev); - return 0; -} - -static struct of_device_id etb_match[] = { - {.compatible = "arm,coresight-etb"}, - {} -}; - -static struct platform_driver etb_driver = { - .probe = etb_probe, - .remove = etb_remove, - .driver = { - .name = "coresight-etb", - .owner = THIS_MODULE, - .of_match_table = etb_match, - }, -}; - -static int __init etb_init(void) -{ - return platform_driver_register(&etb_driver); -} -module_init(etb_init); - -static void __exit etb_exit(void) -{ - platform_driver_unregister(&etb_driver); -} -module_exit(etb_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("CoreSight Embedded Trace Buffer driver"); diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 4600203d3893a04c3d8ada6595d45ca8295ae0d7..52647cdf8636fc3ceb7be56c2e1860fa8346e2c1 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile @@ -11,7 +11,6 @@ obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o obj-$(CONFIG_CPU_FREQ_GOV_INTERACTIVE) += cpufreq_interactive.o obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o -obj-$(CONFIG_MSM_DCVS) += cpufreq_gov_msm.o # CPUfreq cross-arch helpers obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o diff --git a/drivers/cpufreq/cpufreq_gov_msm.c b/drivers/cpufreq/cpufreq_gov_msm.c deleted file mode 100644 index 3f053388e96086808fd24b53e6f4a7dbb42dd005..0000000000000000000000000000000000000000 --- a/drivers/cpufreq/cpufreq_gov_msm.c +++ /dev/null @@ -1,290 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct cpu_idle_info { - int enabled; - int dcvs_core_id; - struct pm_qos_request pm_qos_req; -}; - -static DEFINE_PER_CPU_SHARED_ALIGNED(struct cpu_idle_info, cpu_idle_info); -static DEFINE_PER_CPU_SHARED_ALIGNED(u64, iowait_on_cpu); -static uint32_t latency; - -static int msm_dcvs_idle_notifier(int core_num, - enum msm_core_control_event event) -{ - struct cpu_idle_info *info = &per_cpu(cpu_idle_info, core_num); - - switch (event) { - case MSM_DCVS_ENABLE_IDLE_PULSE: - info->enabled = true; - break; - - case MSM_DCVS_DISABLE_IDLE_PULSE: - info->enabled = false; - break; - - case MSM_DCVS_ENABLE_HIGH_LATENCY_MODES: - pm_qos_update_request(&info->pm_qos_req, PM_QOS_DEFAULT_VALUE); - break; - - case MSM_DCVS_DISABLE_HIGH_LATENCY_MODES: - pm_qos_update_request(&info->pm_qos_req, latency); - break; - } - - return 0; -} - -static int msm_cpuidle_notifier(struct notifier_block *self, unsigned long cmd, - void *v) -{ - struct cpu_idle_info *info = - &per_cpu(cpu_idle_info, smp_processor_id()); - u64 io_wait_us = 0; - u64 prev_io_wait_us = 0; - u64 last_update_time = 0; - u64 val = 0; - uint32_t iowaited = 0; - - if (!info->enabled) - return NOTIFY_OK; - - switch (cmd) { - case CPU_PM_ENTER: - val = get_cpu_iowait_time_us(smp_processor_id(), - &last_update_time); - /* val could be -1 when NOHZ is not enabled */ - if (val == (u64)-1) - val = 0; - per_cpu(iowait_on_cpu, smp_processor_id()) = val; - msm_dcvs_idle(info->dcvs_core_id, MSM_DCVS_IDLE_ENTER, 0); - break; - - case CPU_PM_EXIT: - prev_io_wait_us = per_cpu(iowait_on_cpu, smp_processor_id()); - val = get_cpu_iowait_time_us(smp_processor_id(), - &last_update_time); - if (val == (u64)-1) - val = 0; - io_wait_us = val; - iowaited = (io_wait_us - prev_io_wait_us); - msm_dcvs_idle(info->dcvs_core_id, MSM_DCVS_IDLE_EXIT, iowaited); - break; - } - - return NOTIFY_OK; -} - -static struct notifier_block idle_nb = { - .notifier_call = msm_cpuidle_notifier, -}; - -static void msm_gov_idle_source_init(int cpu, int dcvs_core_id) -{ - struct cpu_idle_info *info = NULL; - - info = &per_cpu(cpu_idle_info, cpu); - info->dcvs_core_id = dcvs_core_id; - - pm_qos_add_request(&info->pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); -} - -struct msm_gov { - int cpu; - unsigned int cur_freq; - unsigned int min_freq; - unsigned int max_freq; - struct cpufreq_policy *policy; - int dcvs_core_id; -}; - -static DEFINE_PER_CPU_SHARED_ALIGNED(struct mutex, gov_mutex); -static DEFINE_PER_CPU_SHARED_ALIGNED(struct msm_gov, msm_gov_info); - -static void msm_gov_check_limits(struct cpufreq_policy *policy) -{ - struct msm_gov *gov = &per_cpu(msm_gov_info, policy->cpu); - - if (policy->max < gov->cur_freq) - __cpufreq_driver_target(policy, policy->max, - CPUFREQ_RELATION_H); - else if (policy->min > gov->cur_freq) - __cpufreq_driver_target(policy, policy->min, - CPUFREQ_RELATION_L); - else - __cpufreq_driver_target(policy, gov->cur_freq, - CPUFREQ_RELATION_L); - - gov->cur_freq = policy->cur; - gov->min_freq = policy->min; - gov->max_freq = policy->max; - msm_dcvs_update_limits(gov->dcvs_core_id); -} - -static int msm_dcvs_freq_set(int core_num, - unsigned int freq) -{ - int ret = -EINVAL; - struct msm_gov *gov = &per_cpu(msm_gov_info, core_num); - - mutex_lock(&per_cpu(gov_mutex, gov->cpu)); - - if (freq < gov->min_freq) - freq = gov->min_freq; - if (freq > gov->max_freq) - freq = gov->max_freq; - - mutex_unlock(&per_cpu(gov_mutex, gov->cpu)); - - ret = cpufreq_driver_target(gov->policy, freq, CPUFREQ_RELATION_L); - - if (!ret) { - gov->cur_freq = cpufreq_quick_get(gov->cpu); - if (freq != gov->cur_freq) - pr_err("cpu %d freq %u gov->cur_freq %u didn't match", - gov->cpu, freq, gov->cur_freq); - } - ret = gov->cur_freq; - - return ret; -} - -static unsigned int msm_dcvs_freq_get(int core_num) -{ - struct msm_gov *gov = &per_cpu(msm_gov_info, core_num); - /* - * the rw_sem in cpufreq is always held when this is called. - * The policy->cur won't be updated in this case - so it is safe to - * access policy->cur - */ - return gov->policy->cur; -} - -static int cpufreq_governor_msm(struct cpufreq_policy *policy, - unsigned int event) -{ - unsigned int cpu = policy->cpu; - int ret = 0; - int handle = 0; - struct msm_gov *gov = &per_cpu(msm_gov_info, policy->cpu); - - switch (event) { - case CPUFREQ_GOV_START: - if (!cpu_online(cpu)) - return -EINVAL; - BUG_ON(!policy->cur); - mutex_lock(&per_cpu(gov_mutex, cpu)); - per_cpu(msm_gov_info, cpu).cpu = cpu; - gov->policy = policy; - handle = msm_dcvs_freq_sink_start(gov->dcvs_core_id); - BUG_ON(handle < 0); - msm_gov_check_limits(policy); - mutex_unlock(&per_cpu(gov_mutex, cpu)); - break; - - case CPUFREQ_GOV_STOP: - msm_dcvs_freq_sink_stop(gov->dcvs_core_id); - break; - - case CPUFREQ_GOV_LIMITS: - mutex_lock(&per_cpu(gov_mutex, cpu)); - msm_gov_check_limits(policy); - mutex_unlock(&per_cpu(gov_mutex, cpu)); - break; - }; - - return ret; -} - -struct cpufreq_governor cpufreq_gov_msm = { - .name = "msm-dcvs", - .governor = cpufreq_governor_msm, - .owner = THIS_MODULE, -}; - -static int msm_gov_probe(struct platform_device *pdev) -{ - int cpu; - struct msm_dcvs_core_info *core = NULL; - struct msm_dcvs_core_info *core_info = NULL; - struct msm_gov_platform_data *pdata = pdev->dev.platform_data; - int sensor = 0; - - core = pdev->dev.platform_data; - core_info = pdata->info; - latency = pdata->latency; - - for_each_possible_cpu(cpu) { - struct msm_gov *gov = &per_cpu(msm_gov_info, cpu); - - mutex_init(&per_cpu(gov_mutex, cpu)); - if (cpu < core->num_cores) - sensor = core_info->sensors[cpu]; - gov->dcvs_core_id = msm_dcvs_register_core( - MSM_DCVS_CORE_TYPE_CPU, - cpu, - core_info, - msm_dcvs_freq_set, - msm_dcvs_freq_get, - msm_dcvs_idle_notifier, - NULL, - sensor); - if (gov->dcvs_core_id < 0) { - pr_err("Unable to register core for %d\n", cpu); - return -EINVAL; - } - - msm_gov_idle_source_init(cpu, gov->dcvs_core_id); - } - - cpu_pm_register_notifier(&idle_nb); - - return cpufreq_register_governor(&cpufreq_gov_msm); -} - -static int msm_gov_remove(struct platform_device *pdev) -{ - platform_set_drvdata(pdev, NULL); - return 0; -} - -static struct platform_driver msm_gov_driver = { - .probe = msm_gov_probe, - .remove = msm_gov_remove, - .driver = { - .name = "msm_dcvs_gov", - .owner = THIS_MODULE, - }, -}; - -static int __init cpufreq_gov_msm_init(void) -{ - return platform_driver_register(&msm_gov_driver); -} -late_initcall(cpufreq_gov_msm_init); diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index fc6006a1ea912613df4a43a93b38bd45bd07ea5c..58702f5a79503ac3188e11ef56104bd9f98371ee 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig @@ -317,7 +317,6 @@ config CRYPTO_DEV_QCRYPTO config CRYPTO_DEV_QCE tristate "Qualcomm Crypto Engine (QCE) module" - select CRYPTO_DEV_QCE40 if ARCH_MSM8960 || ARCH_MSM9615 select CRYPTO_DEV_QCE50 if ARCH_MSM8974 || ARCH_MSM9625 || ARCH_MSM8226 || ARCH_MSM8610 || ARCH_FSM9900 || ARCH_APQ8084 default n help diff --git a/drivers/crypto/msm/Makefile b/drivers/crypto/msm/Makefile index df9acf2a2e14f64a2c14a56ea2c999ed79c16303..73750df7f0f1babd0f392e779c5fa5652e29713a 100644 --- a/drivers/crypto/msm/Makefile +++ b/drivers/crypto/msm/Makefile @@ -3,7 +3,6 @@ ifeq ($(CONFIG_CRYPTO_DEV_QCE50), y) obj-$(CONFIG_CRYPTO_DEV_QCE) += qce50.o else ifeq ($(CONFIG_CRYPTO_DEV_QCE40), y) - obj-$(CONFIG_CRYPTO_DEV_QCE) += qce40.o else obj-$(CONFIG_CRYPTO_DEV_QCE) += qce.o endif diff --git a/drivers/crypto/msm/qce40.c b/drivers/crypto/msm/qce40.c deleted file mode 100644 index 1dcd3bc20fccd13f0aeec7a0df8fb2e1ba3d2f4d..0000000000000000000000000000000000000000 --- a/drivers/crypto/msm/qce40.c +++ /dev/null @@ -1,2694 +0,0 @@ -/* Qualcomm Crypto Engine driver. - * - * Copyright (c) 2011 - 2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qce.h" -#include "qce40.h" -#include "qcryptohw_40.h" - -/* ADM definitions */ -#define LI_SG_CMD (1 << 31) /* last index in the scatter gather cmd */ -#define SRC_INDEX_SG_CMD(index) ((index & 0x3fff) << 16) -#define DST_INDEX_SG_CMD(index) (index & 0x3fff) -#define ADM_DESC_LAST (1 << 31) -#define QCE_FIFO_SIZE 0x8000 - -/* - * CE HW device structure. - * Each engine has an instance of the structure. - * Each engine can only handle one crypto operation at one time. It is up to - * the sw above to ensure single threading of operation on an engine. - */ -struct qce_device { - struct device *pdev; /* Handle to platform_device structure */ - - unsigned char *coh_vmem; /* Allocated coherent virtual memory */ - dma_addr_t coh_pmem; /* Allocated coherent physical memory */ - int memsize; /* Memory allocated */ - - void __iomem *iobase; /* Virtual io base of CE HW */ - unsigned int phy_iobase; /* Physical io base of CE HW */ - - struct clk *ce_core_src_clk; /* Handle to CE src clk*/ - struct clk *ce_core_clk; /* Handle to CE clk */ - struct clk *ce_clk; /* Handle to CE clk */ - - qce_comp_func_ptr_t qce_cb; /* qce callback function pointer */ - - int assoc_nents; - int ivsize; - int authsize; - int src_nents; - int dst_nents; - - void *areq; - enum qce_cipher_mode_enum mode; - struct ce_dm_data ce_dm; -}; - -/* Standard initialization vector for SHA-1, source: FIPS 180-2 */ -static uint8_t _std_init_vector_sha1_uint8[] = { - 0x67, 0x45, 0x23, 0x01, 0xEF, 0xCD, 0xAB, 0x89, - 0x98, 0xBA, 0xDC, 0xFE, 0x10, 0x32, 0x54, 0x76, - 0xC3, 0xD2, 0xE1, 0xF0 -}; - -/* Standard initialization vector for SHA-256, source: FIPS 180-2 */ -static uint8_t _std_init_vector_sha256_uint8[] = { - 0x6A, 0x09, 0xE6, 0x67, 0xBB, 0x67, 0xAE, 0x85, - 0x3C, 0x6E, 0xF3, 0x72, 0xA5, 0x4F, 0xF5, 0x3A, - 0x51, 0x0E, 0x52, 0x7F, 0x9B, 0x05, 0x68, 0x8C, - 0x1F, 0x83, 0xD9, 0xAB, 0x5B, 0xE0, 0xCD, 0x19 -}; - -static void _byte_stream_swap_to_net_words(uint32_t *iv, unsigned char *b, - unsigned int len) -{ - unsigned i, j; - unsigned char swap_iv[AES_IV_LENGTH]; - - memset(swap_iv, 0, AES_IV_LENGTH); - for (i = (AES_IV_LENGTH-len), j = len-1; i < AES_IV_LENGTH; i++, j--) - swap_iv[i] = b[j]; - memcpy(iv, swap_iv, AES_IV_LENGTH); -} - -static int count_sg(struct scatterlist *sg, int nbytes) -{ - int i; - - for (i = 0; nbytes > 0; i++, sg = scatterwalk_sg_next(sg)) - nbytes -= sg->length; - return i; -} - -static int qce_dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, - enum dma_data_direction direction) -{ - int i; - - for (i = 0; i < nents; ++i) { - dma_map_sg(dev, sg, 1, direction); - sg = scatterwalk_sg_next(sg); - } - - return nents; -} - -static int qce_dma_unmap_sg(struct device *dev, struct scatterlist *sg, - int nents, enum dma_data_direction direction) -{ - int i; - - for (i = 0; i < nents; ++i) { - dma_unmap_sg(dev, sg, 1, direction); - sg = scatterwalk_sg_next(sg); - } - - return nents; -} - -static int dma_map_pmem_sg(struct buf_info *pmem, unsigned entries, - struct scatterlist *sg) -{ - int i; - for (i = 0; i < entries; i++) { - - sg->dma_address = (dma_addr_t)pmem->offset; - sg++; - pmem++; - } - return 0; -} - -static int _probe_ce_engine(struct qce_device *pce_dev) -{ - unsigned int val; - unsigned int rev; - unsigned int ret; - - val = (uint32_t)(*((uint32_t *)pce_dev->ce_dm.buffer.version)); - if (((val & 0xfffffff) != 0x0000043) && - ((val & 0xfffffff) != 0x0000042) && - ((val & 0xfffffff) != 0x0000040)) { - dev_err(pce_dev->pdev, - "Unknown Qualcomm crypto device at 0x%x 0x%x\n", - pce_dev->phy_iobase, val); - return -EIO; - }; - rev = (val & CRYPTO_CORE_REV_MASK); - if (rev >= 0x42) { - dev_info(pce_dev->pdev, - "Qualcomm Crypto 4.2 device found at 0x%x\n", - pce_dev->phy_iobase); - pce_dev->ce_dm.ce_block_size = 64; - - /* Configure the crypto register to support 64byte CRCI if it - * is not XPU protected and the HW version of device is greater - * than 0x42. - * Crypto config register returns a 0 when it is XPU protected. - */ - - ret = readl_relaxed(pce_dev->iobase + CRYPTO_CONFIG_REG); - if (ret) { - val = BIT(CRYPTO_MASK_DOUT_INTR) | - BIT(CRYPTO_MASK_DIN_INTR) | - BIT(CRYPTO_MASK_OP_DONE_INTR) | - BIT(CRYPTO_MASK_ERR_INTR) | - (CRYPTO_REQ_SIZE_ENUM_64_BYTES << - CRYPTO_REQ_SIZE) | - (CRYPTO_FIFO_ENUM_64_BYTES << - CRYPTO_FIFO_THRESHOLD); - - writel_relaxed(val, pce_dev->iobase + - CRYPTO_CONFIG_REG); - } /* end of if (ret) */ - } else { - if (rev == 0x40) { - dev_info(pce_dev->pdev, - "Qualcomm Crypto 4.0 device found at 0x%x\n", - pce_dev->phy_iobase); - pce_dev->ce_dm.ce_block_size = 16; - } - } - - dev_info(pce_dev->pdev, - "IO base 0x%x\n, ce_in channel %d , " - "ce_out channel %d\n, " - "crci_in %d, crci_out %d\n", - (unsigned int) pce_dev->iobase, - pce_dev->ce_dm.chan_ce_in, pce_dev->ce_dm.chan_ce_out, - pce_dev->ce_dm.crci_in, pce_dev->ce_dm.crci_out); - - return 0; -}; - - -static void _check_probe_done_call_back(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - pce_dev = (struct qce_device *) cmd_ptr->user; - - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_in_status = -1; - } else { - _probe_ce_engine(pce_dev); - pce_dev->ce_dm.chan_ce_in_status = 0; - } - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; -}; - -static int _init_ce_engine(struct qce_device *pce_dev) -{ - int status; - /* Reset ce */ - clk_reset(pce_dev->ce_core_clk, CLK_RESET_ASSERT); - clk_reset(pce_dev->ce_core_clk, CLK_RESET_DEASSERT); - - /* - * Ensure previous instruction (any writes to CLK registers) - * to toggle the CLK reset lines was completed before configuring - * ce engine. The ce engine configuration settings should not be lost - * becasue of clk reset. - */ - mb(); - - /* - * Clear ACCESS_VIOL bit in CRYPTO_STATUS REGISTER - */ - status = readl_relaxed(pce_dev->iobase + CRYPTO_STATUS_REG); - *((uint32_t *)(pce_dev->ce_dm.buffer.status)) = status & (~0x40000); - /* - * Ensure ce configuration is completed. - */ - mb(); - - pce_dev->ce_dm.chan_ce_in_cmd->complete_func = - _check_probe_done_call_back; - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - pce_dev->ce_dm.cmdptrlist.probe_ce_hw; - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IN_PROG; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_COMP; - msm_dmov_enqueue_cmd(pce_dev->ce_dm.chan_ce_in, - pce_dev->ce_dm.chan_ce_in_cmd); - - return 0; -}; - -static int _ce_setup_hash_cmdrptrlist(struct qce_device *pce_dev, - struct qce_sha_req *sreq) -{ - struct ce_cmdptrlists_ops *cmdptrlist = &pce_dev->ce_dm.cmdptrlist; - - switch (sreq->alg) { - case QCE_HASH_SHA1: - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = cmdptrlist->auth_sha1; - break; - - case QCE_HASH_SHA256: - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = cmdptrlist->auth_sha256; - break; - case QCE_HASH_SHA1_HMAC: - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->auth_sha1_hmac; - break; - - case QCE_HASH_SHA256_HMAC: - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->auth_sha256_hmac; - break; - case QCE_HASH_AES_CMAC: - if (sreq->authklen == AES128_KEY_SIZE) - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->auth_aes_128_cmac; - else - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->auth_aes_256_cmac; - break; - - default: - break; - } - - return 0; -} - -static int _ce_setup_hash(struct qce_device *pce_dev, struct qce_sha_req *sreq) -{ - uint32_t diglen; - int i; - uint32_t auth_cfg = 0; - bool sha1 = false; - - if (sreq->alg == QCE_HASH_AES_CMAC) { - - memcpy(pce_dev->ce_dm.buffer.auth_key, sreq->authkey, - sreq->authklen); - auth_cfg |= (1 << CRYPTO_LAST); - auth_cfg |= (CRYPTO_AUTH_MODE_CMAC << CRYPTO_AUTH_MODE); - auth_cfg |= (CRYPTO_AUTH_SIZE_ENUM_16_BYTES << - CRYPTO_AUTH_SIZE); - auth_cfg |= CRYPTO_AUTH_ALG_AES << CRYPTO_AUTH_ALG; - - switch (sreq->authklen) { - case AES128_KEY_SIZE: - auth_cfg |= (CRYPTO_AUTH_KEY_SZ_AES128 << - CRYPTO_AUTH_KEY_SIZE); - break; - case AES256_KEY_SIZE: - auth_cfg |= (CRYPTO_AUTH_KEY_SZ_AES256 << - CRYPTO_AUTH_KEY_SIZE); - break; - default: - break; - } - - goto go_proc; - } - - /* if not the last, the size has to be on the block boundary */ - if (sreq->last_blk == 0 && (sreq->size % SHA256_BLOCK_SIZE)) - return -EIO; - - switch (sreq->alg) { - case QCE_HASH_SHA1: - case QCE_HASH_SHA1_HMAC: - diglen = SHA1_DIGEST_SIZE; - sha1 = true; - break; - case QCE_HASH_SHA256: - case QCE_HASH_SHA256_HMAC: - diglen = SHA256_DIGEST_SIZE; - break; - default: - return -EINVAL; - } - - if ((sreq->alg == QCE_HASH_SHA1_HMAC) || - (sreq->alg == QCE_HASH_SHA256_HMAC)) { - - memcpy(pce_dev->ce_dm.buffer.auth_key, sreq->authkey, - sreq->authklen); - auth_cfg |= (CRYPTO_AUTH_MODE_HMAC << CRYPTO_AUTH_MODE); - } else { - auth_cfg |= (CRYPTO_AUTH_MODE_HASH << CRYPTO_AUTH_MODE); - } - - /* write 20/32 bytes, 5/8 words into auth_iv for SHA1/SHA256 */ - if (sreq->first_blk) { - if (sha1) - memcpy(pce_dev->ce_dm.buffer.auth_iv, - _std_init_vector_sha1_uint8, diglen); - else - memcpy(pce_dev->ce_dm.buffer.auth_iv, - _std_init_vector_sha256_uint8, diglen); - } else { - memcpy(pce_dev->ce_dm.buffer.auth_iv, sreq->digest, - diglen); - } - - /* write auth_bytecnt 0/1/2/3, start with 0 */ - for (i = 0; i < 4; i++) - *(((uint32_t *)(pce_dev->ce_dm.buffer.auth_byte_count) + i)) = - sreq->auth_data[i]; - - /* write seg_cfg */ - if (sha1) - auth_cfg |= (CRYPTO_AUTH_SIZE_SHA1 << CRYPTO_AUTH_SIZE); - else - auth_cfg |= (CRYPTO_AUTH_SIZE_SHA256 << CRYPTO_AUTH_SIZE); - - if (sreq->last_blk) - auth_cfg |= 1 << CRYPTO_LAST; - - auth_cfg |= CRYPTO_AUTH_ALG_SHA << CRYPTO_AUTH_ALG; - -go_proc: - auth_cfg |= (CRYPTO_AUTH_POS_BEFORE << CRYPTO_AUTH_POS); - - /* write auth seg cfg */ - *((uint32_t *)(pce_dev->ce_dm.buffer.auth_seg_cfg_size_start)) = - auth_cfg; - /* write auth seg size */ - *((uint32_t *)(pce_dev->ce_dm.buffer.auth_seg_cfg_size_start) + 1) = - sreq->size; - - /* write auth seg size start*/ - *((uint32_t *)(pce_dev->ce_dm.buffer.auth_seg_cfg_size_start)+2) = 0; - - /* write seg size */ - *((uint32_t *)(pce_dev->ce_dm.buffer.seg_size)) = sreq->size; - - /* clear status */ - *((uint32_t *)(pce_dev->ce_dm.buffer.status)) = 0; - - _ce_setup_hash_cmdrptrlist(pce_dev, sreq); - - return 0; -} - -static int _ce_setup_cipher_cmdrptrlist(struct qce_device *pce_dev, - struct qce_req *creq) -{ - struct ce_cmdptrlists_ops *cmdptrlist = - &pce_dev->ce_dm.cmdptrlist; - - if (creq->alg != CIPHER_ALG_AES) { - switch (creq->alg) { - case CIPHER_ALG_DES: - if (creq->mode == QCE_MODE_ECB) { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_des_ecb; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_des_cbc; - } - break; - - case CIPHER_ALG_3DES: - if (creq->mode == QCE_MODE_ECB) { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_3des_ecb; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_3des_cbc; - } - break; - default: - break; - } - } else { - switch (creq->mode) { - case QCE_MODE_ECB: - if (creq->encklen == AES128_KEY_SIZE) { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_128_ecb; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_256_ecb; - } - break; - - case QCE_MODE_CBC: - if (creq->encklen == AES128_KEY_SIZE) { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_128_cbc_ctr; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_256_cbc_ctr; - } - break; - - case QCE_MODE_CTR: - if (creq->encklen == AES128_KEY_SIZE) { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_128_cbc_ctr; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_256_cbc_ctr; - } - break; - - case QCE_MODE_XTS: - if (creq->encklen == AES128_KEY_SIZE) { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_128_xts; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->cipher_aes_256_xts; - } - break; - case QCE_MODE_CCM: - if (creq->encklen == AES128_KEY_SIZE) { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->aead_aes_128_ccm; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->cmdptr = - cmdptrlist->aead_aes_256_ccm; - } - break; - default: - break; - } - } - - switch (creq->mode) { - case QCE_MODE_CCM: - pce_dev->ce_dm.chan_ce_out_cmd->cmdptr = - cmdptrlist->aead_ce_out; - break; - case QCE_MODE_ECB: - pce_dev->ce_dm.chan_ce_out_cmd->cmdptr = - cmdptrlist->cipher_ce_out; - break; - default: - pce_dev->ce_dm.chan_ce_out_cmd->cmdptr = - cmdptrlist->cipher_ce_out_get_iv; - break; - } - - return 0; -} - -static int _ce_setup_cipher(struct qce_device *pce_dev, struct qce_req *creq, - uint32_t totallen_in, uint32_t coffset) -{ - uint32_t enck_size_in_word = creq->encklen / sizeof(uint32_t); - uint32_t encr_cfg = 0; - uint32_t ivsize = creq->ivsize; - struct ce_reg_buffer_addr *buffer = &pce_dev->ce_dm.buffer; - - if (creq->mode == QCE_MODE_XTS) - memcpy(buffer->encr_key, creq->enckey, - creq->encklen/2); - else - memcpy(buffer->encr_key, creq->enckey, creq->encklen); - - if ((creq->op == QCE_REQ_AEAD) && (creq->mode == QCE_MODE_CCM)) { - uint32_t noncelen32 = MAX_NONCE/sizeof(uint32_t); - uint32_t auth_cfg = 0; - - /* write nonce */ - memcpy(buffer->auth_nonce_info, creq->nonce, MAX_NONCE); - memcpy(buffer->auth_key, creq->enckey, creq->encklen); - - auth_cfg |= (noncelen32 << CRYPTO_AUTH_NONCE_NUM_WORDS); - auth_cfg &= ~(1 << CRYPTO_USE_HW_KEY_AUTH); - auth_cfg |= (1 << CRYPTO_LAST); - if (creq->dir == QCE_ENCRYPT) - auth_cfg |= (CRYPTO_AUTH_POS_BEFORE << CRYPTO_AUTH_POS); - else - auth_cfg |= (CRYPTO_AUTH_POS_AFTER << CRYPTO_AUTH_POS); - auth_cfg |= (((creq->authsize >> 1) - 2) << CRYPTO_AUTH_SIZE); - auth_cfg |= (CRYPTO_AUTH_MODE_CCM << CRYPTO_AUTH_MODE); - if (creq->authklen == AES128_KEY_SIZE) - auth_cfg |= (CRYPTO_AUTH_KEY_SZ_AES128 << - CRYPTO_AUTH_KEY_SIZE); - else { - if (creq->authklen == AES256_KEY_SIZE) - auth_cfg |= (CRYPTO_AUTH_KEY_SZ_AES256 << - CRYPTO_AUTH_KEY_SIZE); - } - auth_cfg |= (CRYPTO_AUTH_ALG_AES << CRYPTO_AUTH_ALG); - *((uint32_t *)(buffer->auth_seg_cfg_size_start)) = auth_cfg; - - if (creq->dir == QCE_ENCRYPT) - *((uint32_t *)(buffer->auth_seg_cfg_size_start) + 1) = - totallen_in; - else - *((uint32_t *)(buffer->auth_seg_cfg_size_start) + 1) = - (totallen_in - creq->authsize); - *((uint32_t *)(buffer->auth_seg_cfg_size_start) + 2) = 0; - } - - *((uint32_t *)(buffer->auth_seg_cfg_size_start) + 2) = 0; - - switch (creq->mode) { - case QCE_MODE_ECB: - encr_cfg |= (CRYPTO_ENCR_MODE_ECB << CRYPTO_ENCR_MODE); - break; - - case QCE_MODE_CBC: - encr_cfg |= (CRYPTO_ENCR_MODE_CBC << CRYPTO_ENCR_MODE); - break; - - case QCE_MODE_XTS: - encr_cfg |= (CRYPTO_ENCR_MODE_XTS << CRYPTO_ENCR_MODE); - break; - - case QCE_MODE_CCM: - encr_cfg |= (CRYPTO_ENCR_MODE_CCM << CRYPTO_ENCR_MODE); - break; - - case QCE_MODE_CTR: - default: - encr_cfg |= (CRYPTO_ENCR_MODE_CTR << CRYPTO_ENCR_MODE); - break; - } - pce_dev->mode = creq->mode; - - switch (creq->alg) { - case CIPHER_ALG_DES: - if (creq->mode != QCE_MODE_ECB) - memcpy(buffer->encr_cntr_iv, creq->iv, ivsize); - - encr_cfg |= ((CRYPTO_ENCR_KEY_SZ_DES << CRYPTO_ENCR_KEY_SZ) | - (CRYPTO_ENCR_ALG_DES << CRYPTO_ENCR_ALG)); - break; - - case CIPHER_ALG_3DES: - if (creq->mode != QCE_MODE_ECB) - memcpy(buffer->encr_cntr_iv, creq->iv, ivsize); - - encr_cfg |= ((CRYPTO_ENCR_KEY_SZ_3DES << CRYPTO_ENCR_KEY_SZ) | - (CRYPTO_ENCR_ALG_DES << CRYPTO_ENCR_ALG)); - break; - - case CIPHER_ALG_AES: - default: - if (creq->mode == QCE_MODE_XTS) { - memcpy(buffer->encr_xts_key, (creq->enckey + - creq->encklen/2), creq->encklen/2); - *((uint32_t *)(buffer->encr_xts_du_size)) = - creq->cryptlen; - - } - if (creq->mode != QCE_MODE_ECB) { - if (creq->mode == QCE_MODE_XTS) - _byte_stream_swap_to_net_words( - (uint32_t *)(buffer->encr_cntr_iv), - creq->iv, ivsize); - else - memcpy(buffer->encr_cntr_iv, creq->iv, - ivsize); - } - /* set number of counter bits */ - *((uint32_t *)(buffer->encr_mask)) = (uint32_t)0xffffffff; - - if (creq->op == QCE_REQ_ABLK_CIPHER_NO_KEY) { - encr_cfg |= (CRYPTO_ENCR_KEY_SZ_AES128 << - CRYPTO_ENCR_KEY_SZ); - encr_cfg |= CRYPTO_ENCR_ALG_AES << CRYPTO_ENCR_ALG; - } else { - uint32_t key_size; - - if (creq->mode == QCE_MODE_XTS) { - key_size = creq->encklen/2; - enck_size_in_word = key_size/sizeof(uint32_t); - } else { - key_size = creq->encklen; - } - - switch (key_size) { - case AES128_KEY_SIZE: - encr_cfg |= (CRYPTO_ENCR_KEY_SZ_AES128 << - CRYPTO_ENCR_KEY_SZ); - break; - case AES256_KEY_SIZE: - default: - encr_cfg |= (CRYPTO_ENCR_KEY_SZ_AES256 << - CRYPTO_ENCR_KEY_SZ); - break; - } /* end of switch (creq->encklen) */ - - encr_cfg |= CRYPTO_ENCR_ALG_AES << CRYPTO_ENCR_ALG; - } /* else of if (creq->op == QCE_REQ_ABLK_CIPHER_NO_KEY) */ - break; - } /* end of switch (creq->mode) */ - - /* write encr seg cfg */ - encr_cfg |= ((creq->dir == QCE_ENCRYPT) ? 1 : 0) << CRYPTO_ENCODE; - - /* write encr seg cfg */ - *((uint32_t *)(buffer->encr_seg_cfg_size_start)) = encr_cfg; - /* write encr seg size */ - if ((creq->mode == QCE_MODE_CCM) && (creq->dir == QCE_DECRYPT)) - *((uint32_t *)(buffer->encr_seg_cfg_size_start) + 1) = - (creq->cryptlen + creq->authsize); - else - *((uint32_t *)(buffer->encr_seg_cfg_size_start) + 1) = - creq->cryptlen; - - - *((uint32_t *)(buffer->encr_seg_cfg_size_start) + 2) = - (coffset & 0xffff); - - *((uint32_t *)(buffer->seg_size)) = totallen_in; - - /* clear status */ - *((uint32_t *)(pce_dev->ce_dm.buffer.status)) = 0; - - _ce_setup_cipher_cmdrptrlist(pce_dev, creq); - return 0; -}; - -static int _aead_complete(struct qce_device *pce_dev) -{ - struct aead_request *areq; - - areq = (struct aead_request *) pce_dev->areq; - - if (areq->src != areq->dst) { - qce_dma_unmap_sg(pce_dev->pdev, areq->dst, pce_dev->dst_nents, - DMA_FROM_DEVICE); - } - qce_dma_unmap_sg(pce_dev->pdev, areq->src, pce_dev->src_nents, - (areq->src == areq->dst) ? DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); - - qce_dma_unmap_sg(pce_dev->pdev, areq->assoc, pce_dev->assoc_nents, - DMA_TO_DEVICE); - - /* check MAC */ - if (pce_dev->mode == QCE_MODE_CCM) { - int32_t result = 0; - - result = - (uint32_t)(*((uint32_t *)pce_dev->ce_dm.buffer.status)); - result &= (1 << CRYPTO_MAC_FAILED); - result |= (pce_dev->ce_dm.chan_ce_in_status | - pce_dev->ce_dm.chan_ce_out_status); - if (pce_dev->ce_dm.chan_ce_in_status | - pce_dev->ce_dm.chan_ce_out_status) - result = -ENXIO; - else if (result & (1 << CRYPTO_MAC_FAILED)) - result = -EBADMSG; - - pce_dev->qce_cb(areq, pce_dev->ce_dm.buffer.auth_result, NULL, - result); - } - return 0; -}; - -static void _sha_complete(struct qce_device *pce_dev) -{ - struct ahash_request *areq; - - areq = (struct ahash_request *) pce_dev->areq; - qce_dma_unmap_sg(pce_dev->pdev, areq->src, pce_dev->src_nents, - DMA_TO_DEVICE); - - pce_dev->qce_cb(areq, pce_dev->ce_dm.buffer.auth_result, - pce_dev->ce_dm.buffer.auth_byte_count, - pce_dev->ce_dm.chan_ce_in_status); - -}; - -static int _ablk_cipher_complete(struct qce_device *pce_dev) -{ - struct ablkcipher_request *areq; - - areq = (struct ablkcipher_request *) pce_dev->areq; - - if (areq->src != areq->dst) { - qce_dma_unmap_sg(pce_dev->pdev, areq->dst, - pce_dev->dst_nents, DMA_FROM_DEVICE); - } - qce_dma_unmap_sg(pce_dev->pdev, areq->src, pce_dev->src_nents, - (areq->src == areq->dst) ? DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); - - if (pce_dev->mode == QCE_MODE_ECB) { - pce_dev->qce_cb(areq, NULL, NULL, - pce_dev->ce_dm.chan_ce_in_status | - pce_dev->ce_dm.chan_ce_out_status); - } else { - - pce_dev->qce_cb(areq, NULL, pce_dev->ce_dm.buffer.encr_cntr_iv, - pce_dev->ce_dm.chan_ce_in_status | - pce_dev->ce_dm.chan_ce_out_status); - } - - return 0; -}; - -static int _ablk_cipher_use_pmem_complete(struct qce_device *pce_dev) -{ - struct ablkcipher_request *areq; - - areq = (struct ablkcipher_request *) pce_dev->areq; - - if (pce_dev->mode == QCE_MODE_ECB) { - pce_dev->qce_cb(areq, NULL, NULL, - pce_dev->ce_dm.chan_ce_in_status | - pce_dev->ce_dm.chan_ce_out_status); - } else { - pce_dev->qce_cb(areq, NULL, pce_dev->ce_dm.buffer.encr_cntr_iv, - pce_dev->ce_dm.chan_ce_in_status | - pce_dev->ce_dm.chan_ce_out_status); - } - - return 0; -}; - -static int qce_split_and_insert_dm_desc(struct dmov_desc *pdesc, - unsigned int plen, unsigned int paddr, int *index) -{ - while (plen > QCE_FIFO_SIZE) { - pdesc->len = QCE_FIFO_SIZE; - if (paddr > 0) { - pdesc->addr = paddr; - paddr += QCE_FIFO_SIZE; - } - plen -= pdesc->len; - if (plen > 0) { - *index = (*index) + 1; - if ((*index) >= QCE_MAX_NUM_DESC) - return -ENOMEM; - pdesc++; - } - } - if ((plen > 0) && (plen <= QCE_FIFO_SIZE)) { - pdesc->len = plen; - if (paddr > 0) - pdesc->addr = paddr; - } - - return 0; -} - -static int _chain_sg_buffer_in(struct qce_device *pce_dev, - struct scatterlist *sg, unsigned int nbytes) -{ - unsigned int len; - unsigned int dlen; - struct dmov_desc *pdesc; - - pdesc = pce_dev->ce_dm.ce_in_src_desc + - pce_dev->ce_dm.ce_in_src_desc_index; - /* - * Two consective chunks may be handled by the old - * buffer descriptor. - */ - while (nbytes > 0) { - len = min(nbytes, sg_dma_len(sg)); - dlen = pdesc->len & ADM_DESC_LENGTH_MASK; - nbytes -= len; - if (dlen == 0) { - pdesc->addr = sg_dma_address(sg); - pdesc->len = len; - if (pdesc->len > QCE_FIFO_SIZE) - qce_split_and_insert_dm_desc(pdesc, pdesc->len, - sg_dma_address(sg), - &pce_dev->ce_dm.ce_in_src_desc_index); - } else if (sg_dma_address(sg) == (pdesc->addr + dlen)) { - pdesc->len = dlen + len; - if (pdesc->len > QCE_FIFO_SIZE) - qce_split_and_insert_dm_desc(pdesc, pdesc->len, - pdesc->addr, - &pce_dev->ce_dm.ce_in_src_desc_index); - } else { - pce_dev->ce_dm.ce_in_src_desc_index++; - if (pce_dev->ce_dm.ce_in_src_desc_index >= - QCE_MAX_NUM_DESC) - return -ENOMEM; - pdesc++; - pdesc->len = len; - pdesc->addr = sg_dma_address(sg); - if (pdesc->len > QCE_FIFO_SIZE) - qce_split_and_insert_dm_desc(pdesc, pdesc->len, - sg_dma_address(sg), - &pce_dev->ce_dm.ce_in_src_desc_index); - } - if (nbytes > 0) - sg = scatterwalk_sg_next(sg); - } - return 0; -} - -static int _chain_pm_buffer_in(struct qce_device *pce_dev, - unsigned int pmem, unsigned int nbytes) -{ - unsigned int dlen; - struct dmov_desc *pdesc; - - pdesc = pce_dev->ce_dm.ce_in_src_desc + - pce_dev->ce_dm.ce_in_src_desc_index; - dlen = pdesc->len & ADM_DESC_LENGTH_MASK; - if (dlen == 0) { - pdesc->addr = pmem; - pdesc->len = nbytes; - } else if (pmem == (pdesc->addr + dlen)) { - pdesc->len = dlen + nbytes; - } else { - pce_dev->ce_dm.ce_in_src_desc_index++; - if (pce_dev->ce_dm.ce_in_src_desc_index >= - QCE_MAX_NUM_DESC) - return -ENOMEM; - pdesc++; - pdesc->len = nbytes; - pdesc->addr = pmem; - } - return 0; -} - -static void _chain_buffer_in_init(struct qce_device *pce_dev) -{ - struct dmov_desc *pdesc; - - pce_dev->ce_dm.ce_in_src_desc_index = 0; - pce_dev->ce_dm.ce_in_dst_desc_index = 0; - pdesc = pce_dev->ce_dm.ce_in_src_desc; - pdesc->len = 0; -} - -static void _ce_in_final(struct qce_device *pce_dev, unsigned total) -{ - struct dmov_desc *pdesc; - dmov_sg *pcmd; - - pdesc = pce_dev->ce_dm.ce_in_src_desc + - pce_dev->ce_dm.ce_in_src_desc_index; - pdesc->len |= ADM_DESC_LAST; - - pdesc = pce_dev->ce_dm.ce_in_dst_desc; - if (total > QCE_FIFO_SIZE) { - qce_split_and_insert_dm_desc(pdesc, total, 0, - &pce_dev->ce_dm.ce_in_dst_desc_index); - pdesc = pce_dev->ce_dm.ce_in_dst_desc + - pce_dev->ce_dm.ce_in_dst_desc_index; - pdesc->len |= ADM_DESC_LAST; - } else - pdesc->len = ADM_DESC_LAST | total; - - pcmd = (dmov_sg *) pce_dev->ce_dm.cmdlist.ce_data_in; - pcmd->cmd |= CMD_LC; - -} - -#ifdef QCE_DEBUG -static void _ce_in_dump(struct qce_device *pce_dev) -{ - int i; - struct dmov_desc *pdesc; - - dev_info(pce_dev->pdev, "_ce_in_dump: src\n"); - for (i = 0; i <= pce_dev->ce_dm.ce_in_src_desc_index; i++) { - pdesc = pce_dev->ce_dm.ce_in_src_desc + i; - dev_info(pce_dev->pdev, "%x , %x\n", pdesc->addr, - pdesc->len); - } - dev_info(pce_dev->pdev, "_ce_in_dump: dst\n"); - for (i = 0; i <= pce_dev->ce_dm.ce_in_dst_desc_index; i++) { - pdesc = pce_dev->ce_dm.ce_in_dst_desc + i; - dev_info(pce_dev->pdev, "%x , %x\n", pdesc->addr, - pdesc->len); - } -}; - -static void _ce_out_dump(struct qce_device *pce_dev) -{ - int i; - struct dmov_desc *pdesc; - - dev_info(pce_dev->pdev, "_ce_out_dump: src\n"); - for (i = 0; i <= pce_dev->ce_dm.ce_out_src_desc_index; i++) { - pdesc = pce_dev->ce_dm.ce_out_src_desc + i; - dev_info(pce_dev->pdev, "%x , %x\n", pdesc->addr, - pdesc->len); - } - - dev_info(pce_dev->pdev, "_ce_out_dump: dst\n"); - for (i = 0; i <= pce_dev->ce_dm.ce_out_dst_desc_index; i++) { - pdesc = pce_dev->ce_dm.ce_out_dst_desc + i; - dev_info(pce_dev->pdev, "%x , %x\n", pdesc->addr, - pdesc->len); - } -}; - -#else - -static void _ce_in_dump(struct qce_device *pce_dev) -{ -}; - -static void _ce_out_dump(struct qce_device *pce_dev) -{ -}; - -#endif - -static int _chain_sg_buffer_out(struct qce_device *pce_dev, - struct scatterlist *sg, unsigned int nbytes) -{ - unsigned int len; - unsigned int dlen; - struct dmov_desc *pdesc; - - pdesc = pce_dev->ce_dm.ce_out_dst_desc + - pce_dev->ce_dm.ce_out_dst_desc_index; - /* - * Two consective chunks may be handled by the old - * buffer descriptor. - */ - while (nbytes > 0) { - len = min(nbytes, sg_dma_len(sg)); - dlen = pdesc->len & ADM_DESC_LENGTH_MASK; - nbytes -= len; - if (dlen == 0) { - pdesc->addr = sg_dma_address(sg); - pdesc->len = len; - if (pdesc->len > QCE_FIFO_SIZE) - qce_split_and_insert_dm_desc(pdesc, pdesc->len, - sg_dma_address(sg), - &pce_dev->ce_dm.ce_out_dst_desc_index); - } else if (sg_dma_address(sg) == (pdesc->addr + dlen)) { - pdesc->len = dlen + len; - if (pdesc->len > QCE_FIFO_SIZE) - qce_split_and_insert_dm_desc(pdesc, pdesc->len, - pdesc->addr, - &pce_dev->ce_dm.ce_out_dst_desc_index); - - } else { - pce_dev->ce_dm.ce_out_dst_desc_index++; - if (pce_dev->ce_dm.ce_out_dst_desc_index >= - QCE_MAX_NUM_DESC) - return -EIO; - pdesc++; - pdesc->len = len; - pdesc->addr = sg_dma_address(sg); - if (pdesc->len > QCE_FIFO_SIZE) - qce_split_and_insert_dm_desc(pdesc, pdesc->len, - sg_dma_address(sg), - &pce_dev->ce_dm.ce_out_dst_desc_index); - - } - if (nbytes > 0) - sg = scatterwalk_sg_next(sg); - } - return 0; -} - -static int _chain_pm_buffer_out(struct qce_device *pce_dev, - unsigned int pmem, unsigned int nbytes) -{ - unsigned int dlen; - struct dmov_desc *pdesc; - - pdesc = pce_dev->ce_dm.ce_out_dst_desc + - pce_dev->ce_dm.ce_out_dst_desc_index; - dlen = pdesc->len & ADM_DESC_LENGTH_MASK; - - if (dlen == 0) { - pdesc->addr = pmem; - pdesc->len = nbytes; - } else if (pmem == (pdesc->addr + dlen)) { - pdesc->len = dlen + nbytes; - } else { - pce_dev->ce_dm.ce_out_dst_desc_index++; - if (pce_dev->ce_dm.ce_out_dst_desc_index >= QCE_MAX_NUM_DESC) - return -EIO; - pdesc++; - pdesc->len = nbytes; - pdesc->addr = pmem; - } - return 0; -}; - -static void _chain_buffer_out_init(struct qce_device *pce_dev) -{ - struct dmov_desc *pdesc; - - pce_dev->ce_dm.ce_out_dst_desc_index = 0; - pce_dev->ce_dm.ce_out_src_desc_index = 0; - pdesc = pce_dev->ce_dm.ce_out_dst_desc; - pdesc->len = 0; -}; - -static void _ce_out_final(struct qce_device *pce_dev, unsigned total) -{ - struct dmov_desc *pdesc; - dmov_sg *pcmd; - - pdesc = pce_dev->ce_dm.ce_out_dst_desc + - pce_dev->ce_dm.ce_out_dst_desc_index; - pdesc->len |= ADM_DESC_LAST; - - pdesc = pce_dev->ce_dm.ce_out_src_desc + - pce_dev->ce_dm.ce_out_src_desc_index; - if (total > QCE_FIFO_SIZE) { - qce_split_and_insert_dm_desc(pdesc, total, 0, - &pce_dev->ce_dm.ce_out_src_desc_index); - pdesc = pce_dev->ce_dm.ce_out_src_desc + - pce_dev->ce_dm.ce_out_src_desc_index; - pdesc->len |= ADM_DESC_LAST; - } else - pdesc->len = ADM_DESC_LAST | total; - - pcmd = (dmov_sg *) pce_dev->ce_dm.cmdlist.ce_data_out; - pcmd->cmd |= CMD_LC; -}; - -static void _aead_ce_in_call_back(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - - pce_dev = (struct qce_device *) cmd_ptr->user; - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_in_status = -1; - } else { - pce_dev->ce_dm.chan_ce_in_status = 0; - } - - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_COMP; - if (pce_dev->ce_dm.chan_ce_out_state == QCE_CHAN_STATE_COMP) { - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IDLE; - - /* done */ - _aead_complete(pce_dev); - } -}; - -static void _aead_ce_out_call_back(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - - pce_dev = (struct qce_device *) cmd_ptr->user; - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_out_status = -1; - } else { - pce_dev->ce_dm.chan_ce_out_status = 0; - }; - - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_COMP; - if (pce_dev->ce_dm.chan_ce_in_state == QCE_CHAN_STATE_COMP) { - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IDLE; - - /* done */ - _aead_complete(pce_dev); - } - -}; - -static void _sha_ce_in_call_back(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - - pce_dev = (struct qce_device *) cmd_ptr->user; - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_in_status = -1; - } else { - pce_dev->ce_dm.chan_ce_in_status = 0; - } - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - _sha_complete(pce_dev); -}; - -static void _ablk_cipher_ce_in_call_back(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - - pce_dev = (struct qce_device *) cmd_ptr->user; - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_in_status = -1; - } else { - pce_dev->ce_dm.chan_ce_in_status = 0; - } - - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_COMP; - if (pce_dev->ce_dm.chan_ce_out_state == QCE_CHAN_STATE_COMP) { - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IDLE; - - /* done */ - _ablk_cipher_complete(pce_dev); - } -}; - -static void _ablk_cipher_ce_out_call_back(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - - pce_dev = (struct qce_device *) cmd_ptr->user; - - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_out_status = -1; - } else { - pce_dev->ce_dm.chan_ce_out_status = 0; - }; - - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_COMP; - if (pce_dev->ce_dm.chan_ce_in_state == QCE_CHAN_STATE_COMP) { - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IDLE; - - /* done */ - _ablk_cipher_complete(pce_dev); - } -}; - - -static void _ablk_cipher_ce_in_call_back_pmem(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - pce_dev = (struct qce_device *) cmd_ptr->user; - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_in_status = -1; - } else { - pce_dev->ce_dm.chan_ce_in_status = 0; - } - - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_COMP; - if (pce_dev->ce_dm.chan_ce_out_state == QCE_CHAN_STATE_COMP) { - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IDLE; - - /* done */ - _ablk_cipher_use_pmem_complete(pce_dev); - } -}; - -static void _ablk_cipher_ce_out_call_back_pmem(struct msm_dmov_cmd *cmd_ptr, - unsigned int result, struct msm_dmov_errdata *err) -{ - struct qce_device *pce_dev; - - pce_dev = (struct qce_device *) cmd_ptr->user; - if (result != ADM_STATUS_OK) { - dev_err(pce_dev->pdev, "Qualcomm ADM status error %x\n", - result); - pce_dev->ce_dm.chan_ce_out_status = -1; - } else { - pce_dev->ce_dm.chan_ce_out_status = 0; - }; - - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_COMP; - if (pce_dev->ce_dm.chan_ce_in_state == QCE_CHAN_STATE_COMP) { - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IDLE; - - /* done */ - _ablk_cipher_use_pmem_complete(pce_dev); - } -}; - -static int qce_setup_cmd_buffers(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - struct ce_reg_buffers *addr = (struct ce_reg_buffers *)(*pvaddr); - struct ce_reg_buffer_addr *buffer = &pce_dev->ce_dm.buffer; - - /* - * Designate chunks of the allocated memory to various - * buffer pointers - */ - buffer->reset_buf_64 = addr->reset_buf_64; - buffer->version = addr->version; - buffer->encr_seg_cfg_size_start = addr->encr_seg_cfg_size_start; - buffer->encr_key = addr->encr_key; - buffer->encr_xts_key = addr->encr_xts_key; - buffer->encr_xts_du_size = addr->encr_xts_du_size; - buffer->encr_cntr_iv = addr->encr_cntr_iv; - buffer->encr_mask = addr->encr_mask; - buffer->auth_seg_cfg_size_start = addr->auth_seg_cfg_size_start; - buffer->auth_key = addr->auth_key; - buffer->auth_iv = addr->auth_iv; - buffer->auth_result = addr->auth_result; - buffer->auth_nonce_info = addr->auth_nonce_info; - buffer->auth_byte_count = addr->auth_byte_count; - buffer->seg_size = addr->seg_size; - buffer->go_proc = addr->go_proc; - buffer->status = addr->status; - buffer->pad = addr->pad; - - memset(buffer->reset_buf_64, 0, 64); - *((uint32_t *)buffer->encr_mask) = (uint32_t)(0xffffffff); - *((uint32_t *)buffer->go_proc) = (uint32_t)(1 << CRYPTO_GO); - - *pvaddr += sizeof(struct ce_reg_buffers); - - return 0; - -} - -static int _setup_cipher_cmdlists(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - dmov_s *pscmd = (dmov_s *)(*pvaddr); - - /* - * Designate chunks of the allocated memory to various - * command list pointers related to cipher operation - */ - pce_dev->ce_dm.cmdlist.set_cipher_cfg = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_SEG_CFG_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 3; - pscmd->src = - GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_seg_cfg_size_start); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_aes_128_key = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_aes_256_key = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 8; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_des_key = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 2; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_3des_key = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 6; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_aes_128_xts_key = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_XTS_KEY0_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_xts_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_aes_256_xts_key = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_XTS_KEY0_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 8; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_xts_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_xts_du_size = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_XTS_DU_SIZE_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_xts_du_size); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_aes_iv = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_CNTR0_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_cntr_iv); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_des_iv = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_CNTR0_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 2; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_cntr_iv); - pscmd++; - - pce_dev->ce_dm.cmdlist.get_cipher_iv = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->src = (unsigned) (CRYPTO_CNTR0_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_cntr_iv); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_cipher_mask = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_CNTR_MASK_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.encr_mask); - pscmd++; - - /* RESET CIPHER AND AUTH REGISTERS COMMAND LISTS*/ - - pce_dev->ce_dm.cmdlist.reset_cipher_key = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 8; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - pce_dev->ce_dm.cmdlist.reset_cipher_xts_key = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_XTS_KEY0_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 8; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - pce_dev->ce_dm.cmdlist.reset_cipher_iv = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_CNTR0_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - pce_dev->ce_dm.cmdlist.reset_cipher_cfg = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_ENCR_SEG_CFG_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - *pvaddr = (unsigned char *) pscmd; - - return 0; -} - -static int _setup_auth_cmdlists(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - dmov_s *pscmd = (dmov_s *)(*pvaddr); - - /* - * Designate chunks of the allocated memory to various - * command list pointers related to authentication operation - */ - pce_dev->ce_dm.cmdlist.set_auth_cfg = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_SEG_CFG_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 3; - pscmd->src = - GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_seg_cfg_size_start); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_key_128 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_key_256 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 8; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_key_512 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 16; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_key); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_iv_16 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_iv); - pscmd++; - - pce_dev->ce_dm.cmdlist.get_auth_result_16 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->src = (unsigned) (CRYPTO_AUTH_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_result); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_iv_20 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 5; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_iv); - pscmd++; - - pce_dev->ce_dm.cmdlist.get_auth_result_20 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->src = (unsigned) (CRYPTO_AUTH_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 5; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_result); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_iv_32 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 8; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_iv); - pscmd++; - - - pce_dev->ce_dm.cmdlist.get_auth_result_32 = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->src = (unsigned) (CRYPTO_AUTH_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 8; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_result); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_byte_count = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_BYTECNT0_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_byte_count); - pscmd++; - - pce_dev->ce_dm.cmdlist.get_auth_byte_count = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->src = (unsigned) (CRYPTO_AUTH_BYTECNT0_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_byte_count); - pscmd++; - - pce_dev->ce_dm.cmdlist.set_auth_nonce_info = pscmd; - pscmd->cmd = CMD_LC | CMD_SRC_SWAP_BYTES | - CMD_SRC_SWAP_SHORTS | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_INFO_NONCE0_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.auth_nonce_info); - pscmd++; - - /* RESET CIPHER AND AUTH REGISTERS COMMAND LISTS*/ - - pce_dev->ce_dm.cmdlist.reset_auth_key = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_KEY0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 16; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - pce_dev->ce_dm.cmdlist.reset_auth_iv = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_IV0_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 16; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - pce_dev->ce_dm.cmdlist.reset_auth_cfg = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_SEG_CFG_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - - pce_dev->ce_dm.cmdlist.reset_auth_byte_count = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_AUTH_BYTECNT0_REG + - pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE * 4; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.reset_buf_64); - pscmd++; - - /* WAIT UNTIL MAC OP IS DONE*/ - - pce_dev->ce_dm.cmdlist.get_status_wait = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->src = (unsigned) (CRYPTO_STATUS_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.status); - pscmd++; - - *pvaddr = (unsigned char *) pscmd; - - return 0; -} - -static int qce_setup_cmdlists(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - dmov_sg *pcmd; - dmov_s *pscmd; - unsigned char *vaddr = *pvaddr; - struct dmov_desc *pdesc; - int i = 0; - - /* - * Designate chunks of the allocated memory to various - * command list pointers related to operation define - * in ce_cmdlists structure. - */ - vaddr = (unsigned char *) ALIGN(((unsigned int)vaddr), 16); - *pvaddr = (unsigned char *) vaddr; - - _setup_cipher_cmdlists(pce_dev, pvaddr); - _setup_auth_cmdlists(pce_dev, pvaddr); - - pscmd = (dmov_s *)(*pvaddr); - - /* GET HW VERSION COMMAND LIST */ - pce_dev->ce_dm.cmdlist.get_hw_version = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE | CMD_OCB; - pscmd->src = (unsigned) (CRYPTO_VERSION_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.version); - pscmd++; - - - /* SET SEG SIZE REGISTER LIST */ - pce_dev->ce_dm.cmdlist.set_seg_size = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_SEG_SIZE_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.seg_size); - pscmd++; - - - /* Get status and OCU COMMAND LIST */ - pce_dev->ce_dm.cmdlist.get_status_ocu = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE | CMD_OCU; - pscmd->src = (unsigned) (CRYPTO_STATUS_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->dst = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.status); - pscmd++; - - /* CLEAR STATUS and OCU COMMAND LIST */ - pce_dev->ce_dm.cmdlist.clear_status = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE | CMD_OCU; - pscmd->dst = (unsigned) (CRYPTO_STATUS_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.status); - pscmd++; - - /* CLEAR STATUS and OCB COMMAND LIST */ - pce_dev->ce_dm.cmdlist.clear_status_ocb = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE | CMD_OCB; - pscmd->dst = (unsigned) (CRYPTO_STATUS_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.status); - pscmd++; - - /* SET GO_PROC REGISTERS COMMAND LIST */ - pce_dev->ce_dm.cmdlist.set_go_proc = pscmd; - pscmd->cmd = CMD_LC | CMD_MODE_SINGLE; - pscmd->dst = (unsigned) (CRYPTO_GOPROC_REG + pce_dev->phy_iobase); - pscmd->len = CRYPTO_REG_SIZE; - pscmd->src = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.go_proc); - pscmd++; - - pcmd = (dmov_sg *)pscmd; - pce_dev->ce_dm.cmdlist.ce_data_in = pcmd; - /* swap byte and half word , dst crci , scatter gather */ - pcmd->cmd = CMD_DST_SWAP_BYTES | CMD_DST_SWAP_SHORTS | - CMD_DST_CRCI(pce_dev->ce_dm.crci_in) | CMD_MODE_SG; - - pdesc = pce_dev->ce_dm.ce_in_src_desc; - pdesc->addr = 0; /* to be filled in each operation */ - pdesc->len = 0; /* to be filled in each operation */ - - pdesc = pce_dev->ce_dm.ce_in_dst_desc; - for (i = 0; i < QCE_MAX_NUM_DESC; i++) { - pdesc->addr = (CRYPTO_DATA_SHADOW0 + pce_dev->phy_iobase); - pdesc->len = 0; /* to be filled in each operation */ - pdesc++; - } - pcmd->src_dscr = GET_PHYS_ADDR(pce_dev->ce_dm.ce_in_src_desc); - pcmd->dst_dscr = GET_PHYS_ADDR(pce_dev->ce_dm.ce_in_dst_desc); - pcmd->_reserved = LI_SG_CMD | SRC_INDEX_SG_CMD(0) | - DST_INDEX_SG_CMD(0); - - - pcmd++; - pce_dev->ce_dm.cmdlist.ce_data_out = pcmd; - /* swap byte, half word, source crci, scatter gather */ - pcmd->cmd = CMD_SRC_SWAP_BYTES | CMD_SRC_SWAP_SHORTS | - CMD_SRC_CRCI(pce_dev->ce_dm.crci_out) | CMD_MODE_SG; - - pdesc = pce_dev->ce_dm.ce_out_src_desc; - for (i = 0; i < QCE_MAX_NUM_DESC; i++) { - pdesc->addr = (CRYPTO_DATA_SHADOW0 + pce_dev->phy_iobase); - pdesc->len = 0; /* to be filled in each operation */ - pdesc++; - } - - pdesc = pce_dev->ce_dm.ce_out_dst_desc; - pdesc->addr = 0; /* to be filled in each operation */ - pdesc->len = 0; /* to be filled in each operation */ - - pcmd->src_dscr = GET_PHYS_ADDR(pce_dev->ce_dm.ce_out_src_desc); - pcmd->dst_dscr = GET_PHYS_ADDR(pce_dev->ce_dm.ce_out_dst_desc); - pcmd->_reserved = LI_SG_CMD | SRC_INDEX_SG_CMD(0) | - DST_INDEX_SG_CMD(0); - pcmd++; - - *pvaddr = (unsigned char *) pcmd; - - return 0; -} - -static int _setup_cipher_cmdptrlists(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - uint32_t * cmd_ptr_vaddr = (uint32_t *)(*pvaddr); - struct ce_cmdlists *cmdlist = &pce_dev->ce_dm.cmdlist; - struct ce_cmdptrlists_ops *cmdptrlist = &pce_dev->ce_dm.cmdptrlist; - - /* - * Designate chunks of the allocated memory to various - * command list pointers related to cipher operations defined - * in ce_cmdptrlists_ops structure. - */ - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_aes_128_cbc_ctr = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_128_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_aes_256_cbc_ctr = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_256_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_aes_128_ecb = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_128_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *)ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_aes_256_ecb = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_256_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *)ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_aes_128_xts = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_128_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_128_xts_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_xts_du_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_aes_256_xts = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_256_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_256_xts_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_xts_du_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *)ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_des_cbc = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_des_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_des_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *)ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_des_ecb = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_des_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_3des_cbc = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_3des_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_des_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_3des_ecb = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_3des_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_ce_out = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_out); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->cipher_ce_out_get_iv = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_out); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_cipher_iv); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - *pvaddr = (unsigned char *) cmd_ptr_vaddr; - - return 0; -} - -static int _setup_auth_cmdptrlists(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - uint32_t * cmd_ptr_vaddr = (uint32_t *)(*pvaddr); - struct ce_cmdlists *cmdlist = &pce_dev->ce_dm.cmdlist; - struct ce_cmdptrlists_ops *cmdptrlist = &pce_dev->ce_dm.cmdptrlist; - - /* - * Designate chunks of the allocated memory to various - * command list pointers related to authentication operations - * defined in ce_cmdptrlists_ops structure. - */ - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->auth_sha1 = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_iv_20); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_in); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_result_20); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->auth_sha256 = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_iv_32); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_in); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_result_32); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->auth_sha1_hmac = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_key_512); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_iv_20); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_in); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_result_20); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->auth_sha256_hmac = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_key_512); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_iv_32); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_in); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_result_32); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->auth_aes_128_cmac = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_key_128); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_in); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_result_16); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->auth_aes_256_cmac = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_key_256); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_in); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_auth_result_16); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - *pvaddr = (unsigned char *) cmd_ptr_vaddr; - - return 0; -} - -static int _setup_aead_cmdptrlists(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - uint32_t * cmd_ptr_vaddr = (uint32_t *)(*pvaddr); - struct ce_cmdlists *cmdlist = &pce_dev->ce_dm.cmdlist; - struct ce_cmdptrlists_ops *cmdptrlist = &pce_dev->ce_dm.cmdptrlist; - - /* - * Designate chunks of the allocated memory to various - * command list pointers related to aead operations - * defined in ce_cmdptrlists_ops structure. - */ - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->aead_aes_128_ccm = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_key_128); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_nonce_info); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_128_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->aead_aes_256_ccm = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status_ocb); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_seg_size); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->reset_auth_byte_count); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_key_256); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_nonce_info); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_auth_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_cfg); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_256_key); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_aes_iv); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_cipher_mask); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->set_go_proc); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->ce_data_in); - - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->aead_ce_out = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->ce_data_out); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_status_wait); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - *pvaddr = (unsigned char *) cmd_ptr_vaddr; - - return 0; -} - -static int qce_setup_cmdptrlists(struct qce_device *pce_dev, - unsigned char **pvaddr) -{ - uint32_t * cmd_ptr_vaddr = (uint32_t *)(*pvaddr); - struct ce_cmdlists *cmdlist = &pce_dev->ce_dm.cmdlist; - struct ce_cmdptrlists_ops *cmdptrlist = &pce_dev->ce_dm.cmdptrlist; - /* - * Designate chunks of the allocated memory to various - * command list pointers related to operations defined - * in ce_cmdptrlists_ops structure. - */ - cmd_ptr_vaddr = (uint32_t *) ALIGN(((unsigned int) cmd_ptr_vaddr), 16); - cmdptrlist->probe_ce_hw = QCE_SET_CMD_PTR(cmd_ptr_vaddr); - - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->get_hw_version); - *cmd_ptr_vaddr++ = QCE_SET_CMD_PTR(cmdlist->clear_status); - *cmd_ptr_vaddr++ = QCE_SET_LAST_CMD_PTR(cmdlist->get_status_ocu); - - *pvaddr = (unsigned char *) cmd_ptr_vaddr; - - _setup_cipher_cmdptrlists(pce_dev, pvaddr); - _setup_auth_cmdptrlists(pce_dev, pvaddr); - _setup_aead_cmdptrlists(pce_dev, pvaddr); - - return 0; -} - - -static int qce_setup_ce_dm_data(struct qce_device *pce_dev) -{ - unsigned char *vaddr; - - /* 1. ce_in channel data xfer command src descriptors, 128 entries */ - vaddr = pce_dev->coh_vmem; - vaddr = (unsigned char *) ALIGN(((unsigned int)vaddr), 16); - pce_dev->ce_dm.ce_in_src_desc = (struct dmov_desc *) vaddr; - vaddr = vaddr + (sizeof(struct dmov_desc) * QCE_MAX_NUM_DESC); - - /* 2. ce_in channel data xfer command dst descriptors, 128 entries */ - vaddr = (unsigned char *) ALIGN(((unsigned int)vaddr), 16); - pce_dev->ce_dm.ce_in_dst_desc = (struct dmov_desc *) vaddr; - vaddr = vaddr + (sizeof(struct dmov_desc) * QCE_MAX_NUM_DESC); - - - /* 3. ce_out channel data xfer command src descriptors, 128 entries */ - vaddr = (unsigned char *) ALIGN(((unsigned int)vaddr), 16); - pce_dev->ce_dm.ce_out_src_desc = (struct dmov_desc *) vaddr; - vaddr = vaddr + (sizeof(struct dmov_desc) * QCE_MAX_NUM_DESC); - - /* 4. ce_out channel data xfer command dst descriptors, 128 entries. */ - vaddr = (unsigned char *) ALIGN(((unsigned int)vaddr), 16); - pce_dev->ce_dm.ce_out_dst_desc = (struct dmov_desc *) vaddr; - vaddr = vaddr + (sizeof(struct dmov_desc) * QCE_MAX_NUM_DESC); - - qce_setup_cmd_buffers(pce_dev, &vaddr); - qce_setup_cmdlists(pce_dev, &vaddr); - qce_setup_cmdptrlists(pce_dev, &vaddr); - - pce_dev->ce_dm.buffer.ignore_data = vaddr; - - pce_dev->ce_dm.phy_ce_pad = GET_PHYS_ADDR(pce_dev->ce_dm.buffer.pad); - pce_dev->ce_dm.phy_ce_out_ignore = - GET_PHYS_ADDR(pce_dev->ce_dm.buffer.ignore_data); - - pce_dev->ce_dm.chan_ce_in_cmd->user = (void *) pce_dev; - pce_dev->ce_dm.chan_ce_in_cmd->exec_func = NULL; - - pce_dev->ce_dm.chan_ce_out_cmd->user = (void *) pce_dev; - pce_dev->ce_dm.chan_ce_out_cmd->exec_func = NULL; - - return 0; -} - -static int _qce_start_dma(struct qce_device *pce_dev, bool ce_in, bool ce_out) -{ - - if (ce_in) - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IN_PROG; - else - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_COMP; - - if (ce_out) - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IN_PROG; - else - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_COMP; - - if (ce_in) - msm_dmov_enqueue_cmd(pce_dev->ce_dm.chan_ce_in, - pce_dev->ce_dm.chan_ce_in_cmd); - if (ce_out) - msm_dmov_enqueue_cmd(pce_dev->ce_dm.chan_ce_out, - pce_dev->ce_dm.chan_ce_out_cmd); - - return 0; -}; - -int qce_aead_req(void *handle, struct qce_req *q_req) -{ - struct qce_device *pce_dev = (struct qce_device *) handle; - struct aead_request *areq = (struct aead_request *) q_req->areq; - uint32_t authsize = q_req->authsize; - uint32_t totallen_in, totallen_out, out_len; - uint32_t pad_len_in, pad_len_out; - int rc = 0; - int ce_block_size; - - ce_block_size = pce_dev->ce_dm.ce_block_size; - if (q_req->dir == QCE_ENCRYPT) { - uint32_t pad_mac_len_out; - - q_req->cryptlen = areq->cryptlen; - totallen_in = q_req->cryptlen + areq->assoclen; - pad_len_in = ALIGN(totallen_in, ce_block_size) - totallen_in; - - out_len = areq->cryptlen + authsize; - totallen_out = q_req->cryptlen + authsize + areq->assoclen; - pad_mac_len_out = ALIGN(authsize, ce_block_size) - authsize; - totallen_out += pad_mac_len_out; - pad_len_out = ALIGN(totallen_out, ce_block_size) - - totallen_out + pad_mac_len_out; - - } else { - q_req->cryptlen = areq->cryptlen - authsize; - totallen_in = areq->cryptlen + areq->assoclen; - pad_len_in = ALIGN(totallen_in, ce_block_size) - totallen_in; - - out_len = q_req->cryptlen; - totallen_out = totallen_in; - pad_len_out = ALIGN(totallen_out, ce_block_size) - totallen_out; - pad_len_out += authsize; - } - - _chain_buffer_in_init(pce_dev); - _chain_buffer_out_init(pce_dev); - - pce_dev->assoc_nents = 0; - pce_dev->src_nents = 0; - pce_dev->dst_nents = 0; - pce_dev->ivsize = q_req->ivsize; - pce_dev->authsize = q_req->authsize; - - /* associated data input */ - pce_dev->assoc_nents = count_sg(areq->assoc, areq->assoclen); - qce_dma_map_sg(pce_dev->pdev, areq->assoc, pce_dev->assoc_nents, - DMA_TO_DEVICE); - if (_chain_sg_buffer_in(pce_dev, areq->assoc, areq->assoclen) < 0) { - rc = -ENOMEM; - goto bad; - } - /* cipher input */ - pce_dev->src_nents = count_sg(areq->src, areq->cryptlen); - qce_dma_map_sg(pce_dev->pdev, areq->src, pce_dev->src_nents, - (areq->src == areq->dst) ? DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); - if (_chain_sg_buffer_in(pce_dev, areq->src, areq->cryptlen) < 0) { - rc = -ENOMEM; - goto bad; - } - /* pad data in */ - if (pad_len_in) { - if (_chain_pm_buffer_in(pce_dev, pce_dev->ce_dm.phy_ce_pad, - pad_len_in) < 0) { - rc = -ENOMEM; - goto bad; - } - } - - /* ignore associated data */ - if (_chain_pm_buffer_out(pce_dev, pce_dev->ce_dm.phy_ce_out_ignore, - areq->assoclen) < 0) { - rc = -ENOMEM; - goto bad; - } - /* cipher + mac output for encryption */ - if (areq->src != areq->dst) { - pce_dev->dst_nents = count_sg(areq->dst, out_len); - qce_dma_map_sg(pce_dev->pdev, areq->dst, pce_dev->dst_nents, - DMA_FROM_DEVICE); - }; - if (_chain_sg_buffer_out(pce_dev, areq->dst, out_len) < 0) { - rc = -ENOMEM; - goto bad; - } - /* pad data out */ - if (pad_len_out) { - if (_chain_pm_buffer_out(pce_dev, pce_dev->ce_dm.phy_ce_pad, - pad_len_out) < 0) { - rc = -ENOMEM; - goto bad; - } - } - - /* finalize the ce_in and ce_out channels command lists */ - _ce_in_final(pce_dev, ALIGN(totallen_in, ce_block_size)); - _ce_out_final(pce_dev, ALIGN(totallen_out, ce_block_size)); - - /* set up crypto device */ - rc = _ce_setup_cipher(pce_dev, q_req, totallen_in, areq->assoclen); - if (rc < 0) - goto bad; - - /* setup for callback, and issue command to adm */ - pce_dev->areq = q_req->areq; - pce_dev->qce_cb = q_req->qce_cb; - - pce_dev->ce_dm.chan_ce_in_cmd->complete_func = _aead_ce_in_call_back; - pce_dev->ce_dm.chan_ce_out_cmd->complete_func = _aead_ce_out_call_back; - - _ce_in_dump(pce_dev); - _ce_out_dump(pce_dev); - - rc = _qce_start_dma(pce_dev, true, true); - if (rc == 0) - return 0; -bad: - if (pce_dev->assoc_nents) { - qce_dma_unmap_sg(pce_dev->pdev, areq->assoc, - pce_dev->assoc_nents, DMA_TO_DEVICE); - } - - if (pce_dev->src_nents) { - qce_dma_unmap_sg(pce_dev->pdev, areq->src, pce_dev->src_nents, - (areq->src == areq->dst) ? DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); - } - if (pce_dev->dst_nents) { - qce_dma_unmap_sg(pce_dev->pdev, areq->dst, pce_dev->dst_nents, - DMA_FROM_DEVICE); - } - return rc; -} -EXPORT_SYMBOL(qce_aead_req); - -int qce_ablk_cipher_req(void *handle, struct qce_req *c_req) -{ - int rc = 0; - struct qce_device *pce_dev = (struct qce_device *) handle; - struct ablkcipher_request *areq = (struct ablkcipher_request *) - c_req->areq; - - uint32_t pad_len = ALIGN(areq->nbytes, pce_dev->ce_dm.ce_block_size) - - areq->nbytes; - - _chain_buffer_in_init(pce_dev); - _chain_buffer_out_init(pce_dev); - - pce_dev->src_nents = 0; - pce_dev->dst_nents = 0; - - /* cipher input */ - pce_dev->src_nents = count_sg(areq->src, areq->nbytes); - - if (c_req->use_pmem != 1) - qce_dma_map_sg(pce_dev->pdev, areq->src, pce_dev->src_nents, - (areq->src == areq->dst) ? DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); - else - dma_map_pmem_sg(&c_req->pmem->src[0], pce_dev->src_nents, - areq->src); - - if (_chain_sg_buffer_in(pce_dev, areq->src, areq->nbytes) < 0) { - rc = -ENOMEM; - goto bad; - } - - /* cipher output */ - if (areq->src != areq->dst) { - pce_dev->dst_nents = count_sg(areq->dst, areq->nbytes); - if (c_req->use_pmem != 1) - qce_dma_map_sg(pce_dev->pdev, areq->dst, - pce_dev->dst_nents, DMA_FROM_DEVICE); - else - dma_map_pmem_sg(&c_req->pmem->dst[0], - pce_dev->dst_nents, areq->dst); - }; - if (_chain_sg_buffer_out(pce_dev, areq->dst, areq->nbytes) < 0) { - rc = -ENOMEM; - goto bad; - } - - /* pad data */ - if (pad_len) { - if (_chain_pm_buffer_in(pce_dev, pce_dev->ce_dm.phy_ce_pad, - pad_len) < 0) { - rc = -ENOMEM; - goto bad; - } - if (_chain_pm_buffer_out(pce_dev, pce_dev->ce_dm.phy_ce_pad, - pad_len) < 0) { - rc = -ENOMEM; - goto bad; - } - } - - /* finalize the ce_in and ce_out channels command lists */ - _ce_in_final(pce_dev, areq->nbytes + pad_len); - _ce_out_final(pce_dev, areq->nbytes + pad_len); - - _ce_in_dump(pce_dev); - _ce_out_dump(pce_dev); - - /* set up crypto device */ - rc = _ce_setup_cipher(pce_dev, c_req, areq->nbytes, 0); - if (rc < 0) - goto bad; - - /* setup for callback, and issue command to adm */ - pce_dev->areq = areq; - pce_dev->qce_cb = c_req->qce_cb; - if (c_req->use_pmem == 1) { - pce_dev->ce_dm.chan_ce_in_cmd->complete_func = - _ablk_cipher_ce_in_call_back_pmem; - pce_dev->ce_dm.chan_ce_out_cmd->complete_func = - _ablk_cipher_ce_out_call_back_pmem; - } else { - pce_dev->ce_dm.chan_ce_in_cmd->complete_func = - _ablk_cipher_ce_in_call_back; - pce_dev->ce_dm.chan_ce_out_cmd->complete_func = - _ablk_cipher_ce_out_call_back; - } - rc = _qce_start_dma(pce_dev, true, true); - - if (rc == 0) - return 0; -bad: - if (c_req->use_pmem != 1) { - if (pce_dev->dst_nents) { - qce_dma_unmap_sg(pce_dev->pdev, areq->dst, - pce_dev->dst_nents, DMA_FROM_DEVICE); - } - if (pce_dev->src_nents) { - qce_dma_unmap_sg(pce_dev->pdev, areq->src, - pce_dev->src_nents, - (areq->src == areq->dst) ? - DMA_BIDIRECTIONAL : - DMA_TO_DEVICE); - } - } - return rc; -} -EXPORT_SYMBOL(qce_ablk_cipher_req); - -int qce_process_sha_req(void *handle, struct qce_sha_req *sreq) -{ - struct qce_device *pce_dev = (struct qce_device *) handle; - int rc; - uint32_t pad_len = ALIGN(sreq->size, pce_dev->ce_dm.ce_block_size) - - sreq->size; - struct ahash_request *areq = (struct ahash_request *)sreq->areq; - - _chain_buffer_in_init(pce_dev); - pce_dev->src_nents = count_sg(sreq->src, sreq->size); - qce_dma_map_sg(pce_dev->pdev, sreq->src, pce_dev->src_nents, - DMA_TO_DEVICE); - - if (_chain_sg_buffer_in(pce_dev, sreq->src, sreq->size) < 0) { - rc = -ENOMEM; - goto bad; - } - - if (pad_len) { - if (_chain_pm_buffer_in(pce_dev, pce_dev->ce_dm.phy_ce_pad, - pad_len) < 0) { - rc = -ENOMEM; - goto bad; - } - } - _ce_in_final(pce_dev, sreq->size + pad_len); - - _ce_in_dump(pce_dev); - - rc = _ce_setup_hash(pce_dev, sreq); - - if (rc < 0) - goto bad; - - pce_dev->areq = areq; - pce_dev->qce_cb = sreq->qce_cb; - pce_dev->ce_dm.chan_ce_in_cmd->complete_func = _sha_ce_in_call_back; - - rc = _qce_start_dma(pce_dev, true, false); - - if (rc == 0) - return 0; -bad: - if (pce_dev->src_nents) { - qce_dma_unmap_sg(pce_dev->pdev, sreq->src, - pce_dev->src_nents, DMA_TO_DEVICE); - } - - return rc; -} -EXPORT_SYMBOL(qce_process_sha_req); - -int qce_enable_clk(void *handle) -{ - return 0; -} -EXPORT_SYMBOL(qce_enable_clk); - -int qce_disable_clk(void *handle) -{ - return 0; -} -EXPORT_SYMBOL(qce_disable_clk); - -/* crypto engine open function. */ -void *qce_open(struct platform_device *pdev, int *rc) -{ - struct qce_device *pce_dev; - struct resource *resource; - struct clk *ce_core_clk; - struct clk *ce_clk; - struct clk *ce_core_src_clk; - int ret = 0; - - pce_dev = kzalloc(sizeof(struct qce_device), GFP_KERNEL); - if (!pce_dev) { - *rc = -ENOMEM; - dev_err(&pdev->dev, "Can not allocate memory\n"); - return NULL; - } - pce_dev->pdev = &pdev->dev; - - resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!resource) { - *rc = -ENXIO; - dev_err(pce_dev->pdev, "Missing MEM resource\n"); - goto err_pce_dev; - }; - pce_dev->phy_iobase = resource->start; - pce_dev->iobase = ioremap_nocache(resource->start, - resource->end - resource->start + 1); - if (!pce_dev->iobase) { - *rc = -ENOMEM; - dev_err(pce_dev->pdev, "Can not map io memory\n"); - goto err_pce_dev; - } - - pce_dev->ce_dm.chan_ce_in_cmd = kzalloc(sizeof(struct msm_dmov_cmd), - GFP_KERNEL); - pce_dev->ce_dm.chan_ce_out_cmd = kzalloc(sizeof(struct msm_dmov_cmd), - GFP_KERNEL); - if (pce_dev->ce_dm.chan_ce_in_cmd == NULL || - pce_dev->ce_dm.chan_ce_out_cmd == NULL) { - dev_err(pce_dev->pdev, "Can not allocate memory\n"); - *rc = -ENOMEM; - goto err_dm_chan_cmd; - } - - resource = platform_get_resource_byname(pdev, IORESOURCE_DMA, - "crypto_channels"); - if (!resource) { - *rc = -ENXIO; - dev_err(pce_dev->pdev, "Missing DMA channel resource\n"); - goto err_dm_chan_cmd; - }; - pce_dev->ce_dm.chan_ce_in = resource->start; - pce_dev->ce_dm.chan_ce_out = resource->end; - resource = platform_get_resource_byname(pdev, IORESOURCE_DMA, - "crypto_crci_in"); - if (!resource) { - *rc = -ENXIO; - dev_err(pce_dev->pdev, "Missing DMA crci in resource\n"); - goto err_dm_chan_cmd; - }; - pce_dev->ce_dm.crci_in = resource->start; - resource = platform_get_resource_byname(pdev, IORESOURCE_DMA, - "crypto_crci_out"); - if (!resource) { - *rc = -ENXIO; - dev_err(pce_dev->pdev, "Missing DMA crci out resource\n"); - goto err_dm_chan_cmd; - }; - pce_dev->ce_dm.crci_out = resource->start; - pce_dev->memsize = 2 * PAGE_SIZE; - pce_dev->coh_vmem = dma_alloc_coherent(pce_dev->pdev, - pce_dev->memsize, &pce_dev->coh_pmem, GFP_KERNEL); - - if (pce_dev->coh_vmem == NULL) { - *rc = -ENOMEM; - dev_err(pce_dev->pdev, "Can not allocate coherent memory.\n"); - goto err; - } - - /* Get CE3 src core clk. */ - ce_core_src_clk = clk_get(pce_dev->pdev, "ce3_core_src_clk"); - if (!IS_ERR(ce_core_src_clk)) { - pce_dev->ce_core_src_clk = ce_core_src_clk; - - /* Set the core src clk @100Mhz */ - ret = clk_set_rate(pce_dev->ce_core_src_clk, 100000000); - if (ret) { - clk_put(pce_dev->ce_core_src_clk); - goto err; - } - } else - pce_dev->ce_core_src_clk = NULL; - - /* Get CE core clk */ - ce_core_clk = clk_get(pce_dev->pdev, "core_clk"); - if (IS_ERR(ce_core_clk)) { - *rc = PTR_ERR(ce_core_clk); - if (pce_dev->ce_core_src_clk != NULL) - clk_put(pce_dev->ce_core_src_clk); - goto err; - } - pce_dev->ce_core_clk = ce_core_clk; - /* Get CE clk */ - ce_clk = clk_get(pce_dev->pdev, "iface_clk"); - if (IS_ERR(ce_clk)) { - *rc = PTR_ERR(ce_clk); - if (pce_dev->ce_core_src_clk != NULL) - clk_put(pce_dev->ce_core_src_clk); - clk_put(pce_dev->ce_core_clk); - goto err; - } - pce_dev->ce_clk = ce_clk; - - /* Enable CE core clk */ - *rc = clk_prepare_enable(pce_dev->ce_core_clk); - if (*rc) { - if (pce_dev->ce_core_src_clk != NULL) - clk_put(pce_dev->ce_core_src_clk); - clk_put(pce_dev->ce_core_clk); - clk_put(pce_dev->ce_clk); - goto err; - } else { - /* Enable CE clk */ - *rc = clk_prepare_enable(pce_dev->ce_clk); - if (*rc) { - clk_disable_unprepare(pce_dev->ce_core_clk); - if (pce_dev->ce_core_src_clk != NULL) - clk_put(pce_dev->ce_core_src_clk); - clk_put(pce_dev->ce_core_clk); - clk_put(pce_dev->ce_clk); - goto err; - - } - } - qce_setup_ce_dm_data(pce_dev); - - pce_dev->ce_dm.chan_ce_in_state = QCE_CHAN_STATE_IDLE; - pce_dev->ce_dm.chan_ce_out_state = QCE_CHAN_STATE_IDLE; - if (_init_ce_engine(pce_dev)) { - *rc = -ENXIO; - goto err; - } - *rc = 0; - return pce_dev; - -err: - if (pce_dev->coh_vmem) - dma_free_coherent(pce_dev->pdev, pce_dev->memsize, - pce_dev->coh_vmem, pce_dev->coh_pmem); -err_dm_chan_cmd: - kfree(pce_dev->ce_dm.chan_ce_in_cmd); - kfree(pce_dev->ce_dm.chan_ce_out_cmd); - if (pce_dev->iobase) - iounmap(pce_dev->iobase); - -err_pce_dev: - - kfree(pce_dev); - - return NULL; -} -EXPORT_SYMBOL(qce_open); - -/* crypto engine close function. */ -int qce_close(void *handle) -{ - struct qce_device *pce_dev = (struct qce_device *) handle; - - if (handle == NULL) - return -ENODEV; - if (pce_dev->iobase) - iounmap(pce_dev->iobase); - - if (pce_dev->coh_vmem) - dma_free_coherent(pce_dev->pdev, pce_dev->memsize, - pce_dev->coh_vmem, pce_dev->coh_pmem); - clk_disable_unprepare(pce_dev->ce_clk); - clk_disable_unprepare(pce_dev->ce_core_clk); - - if (pce_dev->ce_core_src_clk != NULL) - clk_put(pce_dev->ce_core_src_clk); - - clk_put(pce_dev->ce_clk); - clk_put(pce_dev->ce_core_clk); - - kfree(pce_dev->ce_dm.chan_ce_in_cmd); - kfree(pce_dev->ce_dm.chan_ce_out_cmd); - kfree(handle); - - return 0; -} -EXPORT_SYMBOL(qce_close); - -int qce_hw_support(void *handle, struct ce_hw_support *ce_support) -{ - if (ce_support == NULL) - return -EINVAL; - - ce_support->sha1_hmac_20 = false; - ce_support->sha1_hmac = false; - ce_support->sha256_hmac = false; - ce_support->sha_hmac = false; - ce_support->cmac = true; - ce_support->aes_key_192 = false; - ce_support->aes_xts = true; - ce_support->aes_ccm = true; - ce_support->ota = false; - ce_support->aligned_only = false; - ce_support->is_shared = false; - ce_support->bam = false; - return 0; -} -EXPORT_SYMBOL(qce_hw_support); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Crypto Engine driver"); diff --git a/drivers/crypto/msm/qce40.h b/drivers/crypto/msm/qce40.h deleted file mode 100644 index 179250cc64cc2b31d79a239d07344843a4fad906..0000000000000000000000000000000000000000 --- a/drivers/crypto/msm/qce40.h +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (c) 2013, 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 _DRIVERS_CRYPTO_MSM_QCE40_H_ -#define _DRIVERS_CRYPTO_MSM_QCE40_H_ - - -#define GET_VIRT_ADDR(x) \ - ((uint32_t)pce_dev->coh_vmem + \ - ((uint32_t)x - pce_dev->coh_pmem)) -#define GET_PHYS_ADDR(x) \ - (pce_dev->coh_pmem + ((unsigned char *)x - \ - pce_dev->coh_vmem)) - -/* Sets the adddress of a command list in command pointer list */ -#define QCE_SET_CMD_PTR(x) \ - (uint32_t)(DMOV_CMD_ADDR(GET_PHYS_ADDR((unsigned char *)x))) - -/* Sets the adddress of the last command list in command pointer list */ -#define SET_LAST_CMD_PTR(x) \ - ((DMOV_CMD_ADDR(x)) | CMD_PTR_LP) - -/* Get the adddress of the last command list in command pointer list */ -#define QCE_SET_LAST_CMD_PTR(x) \ - SET_LAST_CMD_PTR((GET_PHYS_ADDR((unsigned char *)x))) - - -/* MAX Data xfer block size between DM and CE */ -#define MAX_ADM_CE_BLOCK_SIZE 64 -#define ADM_DESC_LENGTH_MASK 0xffff -#define ADM_DESC_LENGTH(x) (x & ADM_DESC_LENGTH_MASK) - -#define ADM_STATUS_OK 0x80000002 - -/* QCE max number of descriptor in a descriptor list */ -#define QCE_MAX_NUM_DESC 128 - -#define CRYPTO_REG_SIZE 0x4 - -struct dmov_desc { - uint32_t addr; - uint32_t len; -}; - -/* State of DM channel */ -enum qce_chan_st_enum { - QCE_CHAN_STATE_IDLE = 0, - QCE_CHAN_STATE_IN_PROG = 1, - QCE_CHAN_STATE_COMP = 2, - QCE_CHAN_STATE_LAST -}; - -/* CE buffers */ -struct ce_reg_buffer_addr { - - unsigned char *reset_buf_64; - unsigned char *version; - - unsigned char *encr_seg_cfg_size_start; - unsigned char *encr_key; - unsigned char *encr_xts_key; - unsigned char *encr_cntr_iv; - unsigned char *encr_mask; - unsigned char *encr_xts_du_size; - - unsigned char *auth_seg_cfg_size_start; - unsigned char *auth_key; - unsigned char *auth_iv; - unsigned char *auth_result; - unsigned char *auth_nonce_info; - unsigned char *auth_byte_count; - - unsigned char *seg_size; - unsigned char *go_proc; - unsigned char *status; - - unsigned char *pad; - unsigned char *ignore_data; -}; - -/* CE buffers */ -struct ce_reg_buffers { - - unsigned char reset_buf_64[64]; - unsigned char version[CRYPTO_REG_SIZE]; - - unsigned char encr_seg_cfg_size_start[3 * CRYPTO_REG_SIZE]; - unsigned char encr_key[8 * CRYPTO_REG_SIZE]; - unsigned char encr_xts_key[8 * CRYPTO_REG_SIZE]; - unsigned char encr_cntr_iv[4 * CRYPTO_REG_SIZE]; - unsigned char encr_mask[CRYPTO_REG_SIZE]; - unsigned char encr_xts_du_size[CRYPTO_REG_SIZE]; - - unsigned char auth_seg_cfg_size_start[3 * CRYPTO_REG_SIZE]; - unsigned char auth_key[16 * CRYPTO_REG_SIZE]; - unsigned char auth_iv[16 * CRYPTO_REG_SIZE]; - unsigned char auth_result[16 * CRYPTO_REG_SIZE]; - unsigned char auth_nonce_info[4 * CRYPTO_REG_SIZE]; - unsigned char auth_byte_count[4 * CRYPTO_REG_SIZE]; - - unsigned char seg_size[CRYPTO_REG_SIZE]; - unsigned char go_proc[CRYPTO_REG_SIZE]; - unsigned char status[CRYPTO_REG_SIZE]; - - unsigned char pad[2 * MAX_ADM_CE_BLOCK_SIZE]; -}; - -/* CE Command lists */ -struct ce_cmdlists { - dmov_s *get_hw_version; - dmov_s *clear_status; - dmov_s *clear_status_ocb; - dmov_s *get_status_ocu; - - dmov_s *set_cipher_cfg; - - dmov_s *set_cipher_aes_128_key; - dmov_s *set_cipher_aes_256_key; - dmov_s *set_cipher_des_key; - dmov_s *set_cipher_3des_key; - - dmov_s *set_cipher_aes_128_xts_key; - dmov_s *set_cipher_aes_256_xts_key; - dmov_s *set_cipher_xts_du_size; - - dmov_s *set_cipher_aes_iv; - dmov_s *set_cipher_aes_xts_iv; - dmov_s *set_cipher_des_iv; - dmov_s *get_cipher_iv; - - dmov_s *set_cipher_mask; - - dmov_s *set_auth_cfg; - dmov_s *set_auth_key_128; - dmov_s *set_auth_key_256; - dmov_s *set_auth_key_512; - dmov_s *set_auth_iv_16; - dmov_s *get_auth_result_16; - dmov_s *set_auth_iv_20; - dmov_s *get_auth_result_20; - dmov_s *set_auth_iv_32; - dmov_s *get_auth_result_32; - dmov_s *set_auth_byte_count; - dmov_s *get_auth_byte_count; - - dmov_s *set_auth_nonce_info; - - dmov_s *reset_cipher_key; - dmov_s *reset_cipher_xts_key; - dmov_s *reset_cipher_iv; - dmov_s *reset_cipher_cfg; - dmov_s *reset_auth_key; - dmov_s *reset_auth_iv; - dmov_s *reset_auth_cfg; - dmov_s *reset_auth_byte_count; - - dmov_s *set_seg_size; - dmov_s *get_status_wait; - dmov_s *set_go_proc; - - dmov_sg *ce_data_in; - dmov_sg *ce_data_out; -}; - -/* Command pointer lists */ -struct ce_cmdptrlists_ops { - - uint32_t probe_ce_hw; - uint32_t cipher_aes_128_cbc_ctr; - uint32_t cipher_aes_256_cbc_ctr; - uint32_t cipher_aes_128_ecb; - uint32_t cipher_aes_256_ecb; - uint32_t cipher_aes_128_xts; - uint32_t cipher_aes_256_xts; - uint32_t cipher_des_cbc; - uint32_t cipher_des_ecb; - uint32_t cipher_3des_cbc; - uint32_t cipher_3des_ecb; - uint32_t auth_sha1; - uint32_t auth_sha256; - uint32_t auth_sha1_hmac; - uint32_t auth_sha256_hmac; - uint32_t auth_aes_128_cmac; - uint32_t auth_aes_256_cmac; - uint32_t aead_aes_128_ccm; - uint32_t aead_aes_256_ccm; - - uint32_t cipher_ce_out; - uint32_t cipher_ce_out_get_iv; - uint32_t aead_ce_out; -}; - -/* DM data structure with buffers, commandlists & commmand pointer lists */ -struct ce_dm_data { - unsigned int chan_ce_in; /* ADM channel used for CE input - * and auth result if authentication - * only operation. */ - unsigned int chan_ce_out; /* ADM channel used for CE output, - * and icv for esp */ - - unsigned int crci_in; /* CRCI for CE DM IN Channel */ - unsigned int crci_out; /* CRCI for CE DM OUT Channel */ - - enum qce_chan_st_enum chan_ce_in_state; /* chan ce_in state */ - enum qce_chan_st_enum chan_ce_out_state; /* chan ce_out state */ - - int chan_ce_in_status; /* chan ce_in status */ - int chan_ce_out_status; /* chan ce_out status */ - - struct dmov_desc *ce_out_src_desc; - struct dmov_desc *ce_out_dst_desc; - struct dmov_desc *ce_in_src_desc; - struct dmov_desc *ce_in_dst_desc; - - int ce_out_src_desc_index; - int ce_out_dst_desc_index; - int ce_in_src_desc_index; - int ce_in_dst_desc_index; - - int ce_block_size; - - dma_addr_t phy_ce_out_ignore; - dma_addr_t phy_ce_pad; - - struct ce_reg_buffer_addr buffer; - struct ce_cmdlists cmdlist; - struct ce_cmdptrlists_ops cmdptrlist; - - struct msm_dmov_cmd *chan_ce_in_cmd; - struct msm_dmov_cmd *chan_ce_out_cmd; -}; -#endif /* _DRIVERS_CRYPTO_MSM_QCE40_H */ diff --git a/drivers/crypto/msm/qcryptohw_40.h b/drivers/crypto/msm/qcryptohw_40.h deleted file mode 100644 index f2102c6e4cffe40a6a3b3dfdd71dfc0e002ee87a..0000000000000000000000000000000000000000 --- a/drivers/crypto/msm/qcryptohw_40.h +++ /dev/null @@ -1,316 +0,0 @@ -/* Copyright (c) 2011, 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 _DRIVERS_CRYPTO_MSM_QCRYPTOHW_40_H_ -#define _DRIVERS_CRYPTO_MSM_QCRYPTOHW_40_H_ - - -#define QCE_AUTH_REG_BYTE_COUNT 4 -#define CRYPTO_VERSION_REG 0x0 -#define CRYPTO_DATA_IN_REG 0x008 -#define CRYPTO_DATA_OUT_REG 0x010 -#define CRYPTO_STATUS_REG 0x100 -#define CRYPTO_ENGINES_AVAIL 0x104 -#define CRYPTO3_VERSION_REG 0x108 -#define CRYPTO_SEG_SIZE_REG 0x200 -#define CRYPTO_GOPROC_REG 0x204 -#define CRYPTO_ENCR_SEG_CFG_REG 0x300 - -#define CRYPTO_ENCR_SEG_SIZE_REG 0x304 -#define CRYPTO_ENCR_SEG_START_REG 0x308 - -#define CRYPTO_ENCR_KEY0_REG 0x310 -#define CRYPTO_ENCR_KEY1_REG 0x314 -#define CRYPTO_ENCR_KEY2_REG 0x318 -#define CRYPTO_ENCR_KEY3_REG 0x31C -#define CRYPTO_ENCR_KEY4_REG 0x320 -#define CRYPTO_ENCR_KEY5_REG 0x324 -#define CRYPTO_ENCR_KEY6_REG 0x328 -#define CRYPTO_ENCR_KEY7_REG 0x32C - -#define CRYPTO_ENCR_XTS_KEY0_REG 0x330 -#define CRYPTO_ENCR_XTS_KEY1_REG 0x334 -#define CRYPTO_ENCR_XTS_KEY2_REG 0x338 -#define CRYPTO_ENCR_XTS_KEY3_REG 0x33C -#define CRYPTO_ENCR_XTS_KEY4_REG 0x340 -#define CRYPTO_ENCR_XTS_KEY5_REG 0x344 -#define CRYPTO_ENCR_XTS_KEY6_REG 0x348 -#define CRYPTO_ENCR_XTS_KEY7_REG 0x34C - -#define CRYPTO_CNTR0_IV0_REG 0x350 -#define CRYPTO_CNTR1_IV1_REG 0x354 -#define CRYPTO_CNTR2_IV2_REG 0x358 -#define CRYPTO_CNTR3_IV3_REG 0x35C - -#define CRYPTO_CNTR_MASK_REG 0x360 - -#define CRYPTO_ENCR_XTS_DU_SIZE_REG 0x364 - -#define CRYPTO_AUTH_SEG_CFG_REG 0x400 -#define CRYPTO_AUTH_SEG_SIZE_REG 0x404 -#define CRYPTO_AUTH_SEG_START_REG 0x408 - -#define CRYPTO_AUTH_KEY0_REG 0x410 -#define CRYPTO_AUTH_KEY1_REG 0x414 -#define CRYPTO_AUTH_KEY2_REG 0x418 -#define CRYPTO_AUTH_KEY3_REG 0x41C -#define CRYPTO_AUTH_KEY4_REG 0x420 -#define CRYPTO_AUTH_KEY5_REG 0x424 -#define CRYPTO_AUTH_KEY6_REG 0x428 -#define CRYPTO_AUTH_KEY7_REG 0x42C -#define CRYPTO_AUTH_KEY8_REG 0x430 -#define CRYPTO_AUTH_KEY9_REG 0x434 -#define CRYPTO_AUTH_KEY10_REG 0x438 -#define CRYPTO_AUTH_KEY11_REG 0x43C -#define CRYPTO_AUTH_KEY12_REG 0x440 -#define CRYPTO_AUTH_KEY13_REG 0x444 -#define CRYPTO_AUTH_KEY14_REG 0x448 -#define CRYPTO_AUTH_KEY15_REG 0x44C - -#define CRYPTO_AUTH_IV0_REG 0x450 -#define CRYPTO_AUTH_IV1_REG 0x454 -#define CRYPTO_AUTH_IV2_REG 0x458 -#define CRYPTO_AUTH_IV3_REG 0x45C -#define CRYPTO_AUTH_IV4_REG 0x460 -#define CRYPTO_AUTH_IV5_REG 0x464 -#define CRYPTO_AUTH_IV6_REG 0x468 -#define CRYPTO_AUTH_IV7_REG 0x46C -#define CRYPTO_AUTH_IV8_REG 0x470 -#define CRYPTO_AUTH_IV9_REG 0x474 -#define CRYPTO_AUTH_IV10_REG 0x478 -#define CRYPTO_AUTH_IV11_REG 0x47C -#define CRYPTO_AUTH_IV12_REG 0x480 -#define CRYPTO_AUTH_IV13_REG 0x484 -#define CRYPTO_AUTH_IV14_REG 0x488 -#define CRYPTO_AUTH_IV15_REG 0x48C - -#define CRYPTO_AUTH_INFO_NONCE0_REG 0x490 -#define CRYPTO_AUTH_INFO_NONCE1_REG 0x494 -#define CRYPTO_AUTH_INFO_NONCE2_REG 0x498 -#define CRYPTO_AUTH_INFO_NONCE3_REG 0x49C - -#define CRYPTO_AUTH_BYTECNT0_REG 0x4A0 -#define CRYPTO_AUTH_BYTECNT1_REG 0x4A4 -#define CRYPTO_AUTH_BYTECNT2_REG 0x4A8 -#define CRYPTO_AUTH_BYTECNT3_REG 0x4AC - -#define CRYPTO_AUTH_EXP_MAC0_REG 0x4B0 -#define CRYPTO_AUTH_EXP_MAC1_REG 0x4B4 -#define CRYPTO_AUTH_EXP_MAC2_REG 0x4B8 -#define CRYPTO_AUTH_EXP_MAC3_REG 0x4BC -#define CRYPTO_AUTH_EXP_MAC4_REG 0x4C0 -#define CRYPTO_AUTH_EXP_MAC5_REG 0x4C4 -#define CRYPTO_AUTH_EXP_MAC6_REG 0x4C8 -#define CRYPTO_AUTH_EXP_MAC7_REG 0x4CC - -#define CRYPTO_CONFIG_REG 0x500 -#define CRYPTO_SACR_REG 0x504 -#define CRYPTO_DEBUG_REG 0x508 - -#define CRYPTO_DATA_SHADOW0 0x8000 -#define CRYPTO_DATA_SHADOW8191 0x8FFC - - -/* Register bits */ - -#define CRYPTO_CORE_MAJOR_REV 4 /* bit 7-4 */ -#define CRYPTO_CORE_MAJOR_REV_MASK (0xF << CRYPTO_CORE_MAJOR_REV) -#define CRYPTO_CORE_MINOR_REV 0 /* bit 3-0 */ -#define CRYPTO_CORE_MINOR_REV_MASK (0xF << CRYPTO_CORE_MINOR_REV) -#define CRYPTO_CORE_REV_MASK 0xFF - -/* status reg */ -#define CRYPTO_MAC_FAILED 25 -#define CRYPTO_DOUT_SIZE_AVAIL 22 /* bit 24-22 */ -#define CRYPTO_DOUT_SIZE_AVAIL_MASK (0x7 << CRYPTO_DOUT_SIZE_AVAIL) -#define CRYPTO_DIN_SIZE_AVAIL 19 /* bit 21-19 */ -#define CRYPTO_DIN_SIZE_AVAIL_MASK (0x7 << CRYPTO_DIN_SIZE_AVAIL) -#define CRYPTO_ACCESS_VIOL 18 -#define CRYPTO_SEG_CHNG_ERR 17 -#define CRYPTO_CFH_CHNG_ERR 16 -#define CRYPTO_DOUT_ERR 15 -#define CRYPTO_DIN_ERR 14 -#define CRYPTO_LOCKED 13 -#define CRYPTO_CRYPTO_STATE 10 /* bit 12-10 */ -#define CRYPTO_CRYPTO_STATE_MASK (0x7 << CRYPTO_CRYPTO_STATE) -#define CRYPTO_ENCR_BUSY 9 -#define CRYPTO_AUTH_BUSY 8 -#define CRYPTO_DOUT_INTR 7 -#define CRYPTO_DIN_INTR 6 -#define CRYPTO_OP_DONE_INTR 5 -#define CRYPTO_ERR_INTR 4 -#define CRYPTO_DOUT_RDY 3 -#define CRYPTO_DIN_RDY 2 -#define CRYPTO_OPERATION_DONE 1 -#define CRYPTO_SW_ERR 0 - -/* config reg */ -#define CRYPTO_REQ_SIZE 30 /* bit 31-30 */ -#define CRYPTO_REQ_SIZE_MASK (0x3 << CRYPTO_REQ_SIZE) -#define CRYPTO_REQ_SIZE_ENUM_16_BYTES 0 -#define CRYPTO_REQ_SIZE_ENUM_32_BYTES 1 -#define CRYPTO_REQ_SIZE_ENUM_64_BYTES 2 - -#define CRYPTO_MAX_QUEUED_REQ 27 /* bit 29-27 */ -#define CRYPTO_MAX_QUEUED_REQ_MASK (0x7 << CRYPTO_MAX_QUEUED_REQ) -#define CRYPTO_ENUM1_QUEUED_REQS 0 -#define CRYPTO_ENUM2_QUEUED_REQS 1 -#define CRYPTO_ENUM3_QUEUED_REQS 2 -#define CRYPTO_ENUM4_QUEUED_REQS 3 - -#define CRYPTO_FIFO_THRESHOLD 24 /* bit 26-24 */ -#define CRYPTO_FIFO_THRESHOLD_MASK (0x7 << CRYPTO_FIFO_THRESHOLD) -#define CRYPTO_FIFO_ENUM_16_BYTES 0 -#define CRYPTO_FIFO_ENUM_32_BYTES 1 -#define CRYPTO_FIFO_ENUM_48_BYTES 2 -#define CRYPTO_FIFO_ENUM_64_BYTES 3 - -#define CRYPTO_IRQ_ENABLES 20 /* bit 23-20 */ -#define CRYPTO_IRQ_ENABLES_MASK (0xF << CRYPTO_IRQ_ENABLES) - -#define CRYPTO_ACR_EN 18 -#define CRYPTO_BAM_MODE 17 -#define CRYPTO_LITTLE_ENDIAN_MODE 16 -#define CRYPTO_HIGH_SPD_OUT_EN_N 14 -#define CRYPTO_HIGH_SPD_IN_EN_N 13 -#define CRYPTO_DBG_EN 12 - -#define CRYPTO_DBG_SEL 7 /* bit 11:7 */ -#define CRYPTO_DBG_SEL_MASK (0x1F << CRYPTO_DBG_SEL) - -#define CRYPTO_MASK_DOUT_INTR 6 -#define CRYPTO_MASK_DIN_INTR 5 -#define CRYPTO_MASK_OP_DONE_INTR 4 -#define CRYPTO_MASK_ERR_INTR 3 -#define CRYPTO_AUTO_SHUTDOWN_EN 2 -#define CRYPTO_CLK_EN_N 1 - -/* auth_seg_cfg reg */ -#define CRYPTO_COMP_EXP_MAC 20 -#define CRYPTO_COMP_EXP_MAC_DISABLED 0 -#define CRYPTO_COMP_EXP_MAC_ENABLED 1 - -#define CRYPTO_F9_DIRECTION 19 -#define CRYPTO_F9_DIRECTION_UPLINK 0 -#define CRYPTO_F9_DIRECTION_DOWNLINK 1 - -#define CRYPTO_AUTH_NONCE_NUM_WORDS 16 -#define CRYPTO_AUTH_NONCE_NUM_WORDS_MASK \ - (0x7 << CRYPTO_AUTH_NONCE_NUM_WORDS) - -#define CRYPTO_USE_HW_KEY_AUTH 15 - -#define CRYPTO_LAST 14 - -#define CRYPTO_AUTH_POS 12 /* bit 13 .. 12*/ -#define CRYPTO_AUTH_POS_MASK (0x3 << CRYPTO_AUTH_POS) -#define CRYPTO_AUTH_POS_BEFORE 0 -#define CRYPTO_AUTH_POS_AFTER 1 - -#define CRYPTO_AUTH_SIZE 9 /* bits 11 .. 9*/ -#define CRYPTO_AUTH_SIZE_MASK (0x7 << CRYPTO_AUTH_SIZE) -#define CRYPTO_AUTH_SIZE_SHA1 0 -#define CRYPTO_AUTH_SIZE_SHA256 1 -#define CRYPTO_AUTH_SIZE_ENUM_4_BYTES 0 -#define CRYPTO_AUTH_SIZE_ENUM_6_BYTES 1 -#define CRYPTO_AUTH_SIZE_ENUM_8_BYTES 2 -#define CRYPTO_AUTH_SIZE_ENUM_10_BYTES 3 -#define CRYPTO_AUTH_SIZE_ENUM_12_BYTES 4 -#define CRYPTO_AUTH_SIZE_ENUM_14_BYTES 5 -#define CRYPTO_AUTH_SIZE_ENUM_16_BYTES 6 - -#define CRYPTO_AUTH_MODE 6 /* bit 8 .. 6*/ -#define CRYPTO_AUTH_MODE_MASK (0x7 << CRYPTO_AUTH_MODE) -#define CRYPTO_AUTH_MODE_HASH 0 -#define CRYPTO_AUTH_MODE_HMAC 1 -#define CRYPTO_AUTH_MODE_CCM 0 -#define CRYPTO_AUTH_MODE_CMAC 1 - -#define CRYPTO_AUTH_KEY_SIZE 3 -#define CRYPTO_AUTH_KEY_SIZE_MASK (0x7 << CRYPTO_AUTH_KEY_SIZE) -#define CRYPTO_AUTH_KEY_SZ_AES128 0 -#define CRYPTO_AUTH_KEY_SZ_AES256 2 - -#define CRYPTO_AUTH_ALG 0 /* bit 2 .. 0*/ -#define CRYPTO_AUTH_ALG_MASK 7 -#define CRYPTO_AUTH_ALG_NONE 0 -#define CRYPTO_AUTH_ALG_SHA 1 -#define CRYPTO_AUTH_ALG_AES 2 -#define CRYPTO_AUTH_ALG_KASUMI 3 -#define CRYPTO_AUTH_ALG_SNOW3G 4 - -/* encr_xts_du_size reg */ -#define CRYPTO_ENCR_XTS_DU_SIZE 0 /* bit 19-0 */ -#define CRYPTO_ENCR_XTS_DU_SIZE_MASK 0xfffff - -/* encr_seg_cfg reg */ -#define CRYPTO_F8_KEYSTREAM_ENABLE 15 -#define CRYPTO_F8_KEYSTREAM_DISABLED 0 -#define CRYPTO_F8_KEYSTREAM_ENABLED 1 - -#define CRYPTO_F8_DIRECTION 14 -#define CRYPTO_F8_DIRECTION_UPLINK 0 -#define CRYPTO_F8_DIRECTION_DOWNLINK 1 - -#define CRYPTO_USE_HW_KEY_ENCR 13 -#define CRYPTO_USE_HW_KEY_REG 0 -#define CRYPTO_USE_HW_KEY 1 - -#define CRYPTO_CNTR_ALG 11 /* bit 12-11 */ -#define CRYPTO_CNTR_ALG_MASK (3 << CRYPTO_CNTR_ALG) -#define CRYPTO_CNTR_ALG_NIST 0 - -#define CRYPTO_ENCODE 10 - -#define CRYPTO_ENCR_MODE 6 /* bit 9-6 */ -#define CRYPTO_ENCR_MODE_MASK (0xF << CRYPTO_ENCR_MODE) -/* only valid when AES */ -#define CRYPTO_ENCR_MODE_ECB 0 -#define CRYPTO_ENCR_MODE_CBC 1 -#define CRYPTO_ENCR_MODE_CTR 2 -#define CRYPTO_ENCR_MODE_XTS 3 -#define CRYPTO_ENCR_MODE_CCM 4 - -#define CRYPTO_ENCR_KEY_SZ 3 /* bit 5-3 */ -#define CRYPTO_ENCR_KEY_SZ_MASK (7 << CRYPTO_ENCR_KEY_SZ) -#define CRYPTO_ENCR_KEY_SZ_DES 0 -#define CRYPTO_ENCR_KEY_SZ_3DES 1 -#define CRYPTO_ENCR_KEY_SZ_AES128 0 -#define CRYPTO_ENCR_KEY_SZ_AES256 2 -#define CRYPTO_ENCR_KEY_SZ_UEA1 0 -#define CRYPTO_ENCR_KEY_SZ_UEA2 1 - -#define CRYPTO_ENCR_ALG 0 /* bit 2-0 */ -#define CRYPTO_ENCR_ALG_MASK (7 << CRYPTO_ENCR_ALG) -#define CRYPTO_ENCR_ALG_NONE 0 -#define CRYPTO_ENCR_ALG_DES 1 -#define CRYPTO_ENCR_ALG_AES 2 -#define CRYPTO_ENCR_ALG_KASUMI 3 -#define CRYPTO_ENCR_ALG_SNOW_3G 5 - -/* goproc reg */ -#define CRYPTO_GO 0 -#define CRYPTO_CLR_CNTXT 1 - -/* engines_avail */ -#define CRYPTO_ENCR_AES_SEL 0 -#define CRYPTO_DES_SEL 3 -#define CRYPTO_ENCR_SNOW3G_SEL 4 -#define CRYPTO_ENCR_KASUMI_SEL 5 -#define CRYPTO_SHA_SEL 6 -#define CRYPTO_SHA512_SEL 7 -#define CRYPTO_AUTH_AES_SEL 8 -#define CRYPTO_AUTH_SNOW3G_SEL 9 -#define CRYPTO_AUTH_KASUMI_SEL 10 -#define CRYPTO_BAM_SEL 11 - -#endif /* _DRIVERS_CRYPTO_MSM_QCRYPTOHW_40_H_ */ diff --git a/drivers/esoc/Kconfig b/drivers/esoc/Kconfig index 0dea0b33e70df61b8e68afd549988e6ed9000bf3..c9849f2848606e634cdb9b35e6533f7b619397b7 100644 --- a/drivers/esoc/Kconfig +++ b/drivers/esoc/Kconfig @@ -11,14 +11,6 @@ menuconfig ESOC if ESOC -config ESOC_DEV - bool "ESOC userspace interface" - help - Say yes here to enable a userspace representation of the control - link. Userspace can register a request engine or a command engine - for the external soc. It can receive event notifications from the - control link. - config ESOC_DEBUG bool "ESOC debug support" help diff --git a/drivers/esoc/Makefile b/drivers/esoc/Makefile deleted file mode 100644 index 8720bda39527f110470d72793583f658b7f9dae6..0000000000000000000000000000000000000000 --- a/drivers/esoc/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# generic external soc control support - -ccflags-$(CONFIG_ESOC_DEBUG) := -DDEBUG -obj-$(CONFIG_ESOC) += esoc_bus.o -obj-$(CONFIG_ESOC_DEV) += esoc_dev.o - diff --git a/drivers/esoc/esoc.h b/drivers/esoc/esoc.h deleted file mode 100644 index d6daa5ee77cade3e6bc06c6cfe3523c27d262ca6..0000000000000000000000000000000000000000 --- a/drivers/esoc/esoc.h +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright (c) 2013, 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 __ESOC_H__ -#define __ESOC_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ESOC_DEV_MAX 4 -#define ESOC_NAME_LEN 20 -#define ESOC_LINK_LEN 8 - -struct esoc_clink; -/** - * struct esoc_eng: Engine of the esoc control link - * @handle_clink_req: handle incoming esoc requests. - * @handle_clink_evt: handle for esoc events. - * @esoc_clink: pointer to esoc control link. - */ -struct esoc_eng { - void (*handle_clink_req)(enum esoc_req req, - struct esoc_eng *eng); - void (*handle_clink_evt)(enum esoc_evt evt, - struct esoc_eng *eng); - struct esoc_clink *esoc_clink; -}; - -/** - * struct esoc_clink: Representation of external esoc device - * @name: Name of the external esoc. - * @link_name: name of the physical link. - * @parent: parent device. - * @dev: device for userspace interface. - * @id: id of the external device. - * @owner: owner of the device. - * @clink_ops: control operations for the control link - * @req_eng: handle for request engine. - * @cmd_eng: handle for command engine. - * @clink_data: private data of esoc control link. - * @compat_data: compat data of esoc driver. - * @subsys_desc: descriptor for subsystem restart - * @subsys_dev: ssr device handle. - */ -struct esoc_clink { - const char *name; - const char *link_name; - struct device *parent; - struct device dev; - unsigned int id; - struct module *owner; - const struct esoc_clink_ops const *clink_ops; - struct esoc_eng *req_eng; - struct esoc_eng *cmd_eng; - spinlock_t notify_lock; - void *clink_data; - void *compat_data; - struct subsys_desc subsys; - struct subsys_device *subsys_dev; -}; - -/** - * struct esoc_clink_ops: Operations to control external soc - * @cmd_exe: Execute control command - * @get_status: Get current status, or response to previous command - * @notify_esoc: notify external soc of events - */ -struct esoc_clink_ops { - int (*cmd_exe)(enum esoc_cmd cmd, struct esoc_clink *dev); - int (*get_status)(u32 *status, struct esoc_clink *dev); - void (*notify)(enum esoc_notify notify, struct esoc_clink *dev); -}; - -/** - * struct esoc_compat: Compatibility of esoc drivers. - * @name: esoc link that driver is compatible with. - * @data: driver data associated with esoc clink. - */ -struct esoc_compat { - const char *name; - void *data; -}; - -/** - * struct esoc_drv: Driver for an esoc clink - * @driver: drivers for esoc. - * @owner: module owner of esoc driver. - * @compat_table: compatible table for driver. - * @compat_entries - * @probe: probe function for esoc driver. - */ -struct esoc_drv { - struct device_driver driver; - struct module *owner; - struct esoc_compat *compat_table; - unsigned int compat_entries; - int (*probe)(struct esoc_clink *esoc_clink); -}; - -#define to_esoc_clink(d) container_of(d, struct esoc_clink, dev) -#define to_esoc_drv(d) container_of(d, struct esoc_drv, driver) - -extern struct bus_type esoc_bus_type; - - -/* Exported apis */ -void esoc_dev_exit(void); -int esoc_dev_init(void); -void esoc_clink_unregister(struct esoc_clink *esoc_dev); -int esoc_clink_register(struct esoc_clink *esoc_dev); -struct esoc_clink *get_esoc_clink(int id); -void put_esoc_clink(struct esoc_clink *esoc_clink); -void *get_esoc_clink_data(struct esoc_clink *esoc); -void set_esoc_clink_data(struct esoc_clink *esoc, void *data); -void esoc_clink_evt_notify(enum esoc_evt, struct esoc_clink *esoc_dev); -void esoc_clink_queue_request(enum esoc_req req, struct esoc_clink *esoc_dev); -void esoc_for_each_dev(void *data, int (*fn)(struct device *dev, - void *data)); -int esoc_clink_register_cmd_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng); -void esoc_clink_unregister_cmd_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng); -int esoc_clink_register_req_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng); -void esoc_clink_unregister_req_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng); -int esoc_drv_register(struct esoc_drv *driver); -void esoc_set_drv_data(struct esoc_clink *esoc_clink, void *data); -void *esoc_get_drv_data(struct esoc_clink *esoc_clink); -/* ssr operations */ -int esoc_clink_register_ssr(struct esoc_clink *esoc_clink); -int esoc_clink_request_ssr(struct esoc_clink *esoc_clink); -void esoc_clink_unregister_ssr(struct esoc_clink *esoc_clink); -#endif diff --git a/drivers/esoc/esoc_bus.c b/drivers/esoc/esoc_bus.c deleted file mode 100644 index 4a32fddac711f5d8d6a3b09bdfe04e5caf0bed20..0000000000000000000000000000000000000000 --- a/drivers/esoc/esoc_bus.c +++ /dev/null @@ -1,336 +0,0 @@ -/* Copyright (c) 2013, 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 -#include -#include "esoc.h" - -static DEFINE_IDA(esoc_ida); - -/* SYSFS */ -static ssize_t -esoc_name_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return snprintf(buf, ESOC_NAME_LEN, "%s", to_esoc_clink(dev)->name); -} - -static ssize_t -esoc_link_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - return snprintf(buf, ESOC_LINK_LEN, "%s", - to_esoc_clink(dev)->link_name); -} - -static struct device_attribute esoc_clink_attrs[] = { - - __ATTR_RO(esoc_name), - __ATTR_RO(esoc_link), - __ATTR_NULL, -}; - -static int esoc_bus_match(struct device *dev, struct device_driver *drv) -{ - struct esoc_clink *esoc_clink = to_esoc_clink(dev); - - return !memcmp(esoc_clink->name, drv->name, - strlen(drv->name)); -} - -static int esoc_bus_probe(struct device *dev) -{ - int ret; - struct esoc_clink *esoc_clink = to_esoc_clink(dev); - struct esoc_drv *esoc_drv = to_esoc_drv(dev->driver); - - ret = esoc_drv->probe(esoc_clink); - if (ret) { - pr_err("failed to probe %s dev\n", esoc_clink->name); - return ret; - } - return 0; -} - -struct bus_type esoc_bus_type = { - .name = "esoc", - .match = esoc_bus_match, - .dev_attrs = esoc_clink_attrs, -}; -EXPORT_SYMBOL(esoc_bus_type); - -struct device esoc_bus = { - .init_name = "esoc-bus" -}; -EXPORT_SYMBOL(esoc_bus); - -/* bus accessor */ -static void esoc_clink_release(struct device *dev) -{ - struct esoc_clink *esoc_clink = to_esoc_clink(dev); - ida_simple_remove(&esoc_ida, esoc_clink->id); - kfree(esoc_clink); -} - -static int esoc_clink_match_id(struct device *dev, void *id) -{ - struct esoc_clink *esoc_clink = to_esoc_clink(dev); - int *esoc_id = (int *)id; - - if (esoc_clink->id == *esoc_id) { - if (!try_module_get(esoc_clink->owner)) - return 0; - return 1; - } - return 0; -} - -void esoc_for_each_dev(void *data, int (*fn)(struct device *dev, void *)) -{ - int ret; - - ret = bus_for_each_dev(&esoc_bus_type, NULL, data, fn); - return; -} -EXPORT_SYMBOL(esoc_for_each_dev); - -struct esoc_clink *get_esoc_clink(int id) -{ - struct esoc_clink *esoc_clink; - struct device *dev; - - dev = bus_find_device(&esoc_bus_type, NULL, &id, esoc_clink_match_id); - if (IS_ERR(dev)) - return NULL; - esoc_clink = to_esoc_clink(dev); - return esoc_clink; -} -EXPORT_SYMBOL(get_esoc_clink); - -void put_esoc_clink(struct esoc_clink *esoc_clink) -{ - module_put(esoc_clink->owner); -} -EXPORT_SYMBOL(put_esoc_clink); - -/* ssr operations */ -int esoc_clink_register_ssr(struct esoc_clink *esoc_clink) -{ - int ret; - int len; - char *subsys_name; - - len = strlen("esoc") + sizeof(esoc_clink->id); - subsys_name = kzalloc(len, GFP_KERNEL); - if (IS_ERR(subsys_name)) - return PTR_ERR(subsys_name); - snprintf(subsys_name, len, "esoc%d", esoc_clink->id); - esoc_clink->subsys.name = subsys_name; - esoc_clink->subsys.dev = &esoc_clink->dev; - esoc_clink->subsys_dev = subsys_register(&esoc_clink->subsys); - if (IS_ERR(esoc_clink->subsys_dev)) { - dev_err(&esoc_clink->dev, "failed to register ssr node\n"); - ret = PTR_ERR(esoc_clink->subsys_dev); - goto subsys_err; - } - return 0; -subsys_err: - kfree(subsys_name); - return ret; -} -EXPORT_SYMBOL(esoc_clink_register_ssr); - -void esoc_clink_unregister_ssr(struct esoc_clink *esoc_clink) -{ - subsys_unregister(esoc_clink->subsys_dev); - kfree(esoc_clink->subsys.name); -} -EXPORT_SYMBOL(esoc_clink_unregister_ssr); - -int esoc_clink_request_ssr(struct esoc_clink *esoc_clink) -{ - subsystem_restart_dev(esoc_clink->subsys_dev); - return 0; -} -EXPORT_SYMBOL(esoc_clink_request_ssr); - -/* bus operations */ -void esoc_clink_evt_notify(enum esoc_evt evt, struct esoc_clink *esoc_clink) -{ - unsigned long flags; - - spin_lock_irqsave(&esoc_clink->notify_lock, flags); - if (esoc_clink->req_eng && esoc_clink->req_eng->handle_clink_evt) - esoc_clink->req_eng->handle_clink_evt(evt, esoc_clink->req_eng); - if (esoc_clink->cmd_eng && esoc_clink->cmd_eng->handle_clink_evt) - esoc_clink->cmd_eng->handle_clink_evt(evt, esoc_clink->cmd_eng); - spin_unlock_irqrestore(&esoc_clink->notify_lock, flags); -} -EXPORT_SYMBOL(esoc_clink_evt_notify); - -void *get_esoc_clink_data(struct esoc_clink *esoc) -{ - return esoc->clink_data; -} -EXPORT_SYMBOL(get_esoc_clink_data); - -void set_esoc_clink_data(struct esoc_clink *esoc, void *data) -{ - esoc->clink_data = data; -} -EXPORT_SYMBOL(set_esoc_clink_data); - -void esoc_clink_queue_request(enum esoc_req req, struct esoc_clink *esoc_clink) -{ - unsigned long flags; - struct esoc_eng *req_eng; - - spin_lock_irqsave(&esoc_clink->notify_lock, flags); - if (esoc_clink->req_eng != NULL) { - req_eng = esoc_clink->req_eng; - req_eng->handle_clink_req(req, req_eng); - } - spin_unlock_irqrestore(&esoc_clink->notify_lock, flags); -} -EXPORT_SYMBOL(esoc_clink_queue_request); - -void esoc_set_drv_data(struct esoc_clink *esoc_clink, void *data) -{ - dev_set_drvdata(&esoc_clink->dev, data); -} -EXPORT_SYMBOL(esoc_set_drv_data); - -void *esoc_get_drv_data(struct esoc_clink *esoc_clink) -{ - return dev_get_drvdata(&esoc_clink->dev); -} -EXPORT_SYMBOL(esoc_get_drv_data); - -/* bus registration functions */ -void esoc_clink_unregister(struct esoc_clink *esoc_clink) -{ - if (get_device(&esoc_clink->dev) != NULL) { - device_unregister(&esoc_clink->dev); - put_device(&esoc_clink->dev); - } -} -EXPORT_SYMBOL(esoc_clink_unregister); - -int esoc_clink_register(struct esoc_clink *esoc_clink) -{ - int id, err; - struct device *dev; - - if (!esoc_clink->name || !esoc_clink->link_name || - !esoc_clink->clink_ops) { - dev_err(esoc_clink->parent, "invalid esoc arguments\n"); - return -EINVAL; - } - id = ida_simple_get(&esoc_ida, 0, ESOC_DEV_MAX, GFP_KERNEL); - if (id < 0) { - err = id; - goto exit_ida; - } - esoc_clink->id = id; - dev = &esoc_clink->dev; - dev->bus = &esoc_bus_type; - dev->release = esoc_clink_release; - if (!esoc_clink->parent) - dev->parent = &esoc_bus; - else - dev->parent = esoc_clink->parent; - dev_set_name(dev, "esoc%d", id); - err = device_register(dev); - if (err) { - dev_err(esoc_clink->parent, "esoc device register failed\n"); - goto exit_ida; - } - spin_lock_init(&esoc_clink->notify_lock); - return 0; -exit_ida: - ida_simple_remove(&esoc_ida, id); - pr_err("unable to register %s, err = %d\n", esoc_clink->name, err); - return err; -} -EXPORT_SYMBOL(esoc_clink_register); - -int esoc_clink_register_req_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng) -{ - if (esoc_clink->req_eng) - return -EBUSY; - if (!eng->handle_clink_req) - return -EINVAL; - esoc_clink->req_eng = eng; - eng->esoc_clink = esoc_clink; - return 0; -} -EXPORT_SYMBOL(esoc_clink_register_req_eng); - -int esoc_clink_register_cmd_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng) -{ - if (esoc_clink->cmd_eng) - return -EBUSY; - esoc_clink->cmd_eng = eng; - eng->esoc_clink = esoc_clink; - return 0; -} -EXPORT_SYMBOL(esoc_clink_register_cmd_eng); - -void esoc_clink_unregister_req_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng) -{ - esoc_clink->req_eng = NULL; -} -EXPORT_SYMBOL(esoc_clink_unregister_req_eng); - -void esoc_clink_unregister_cmd_eng(struct esoc_clink *esoc_clink, - struct esoc_eng *eng) -{ - esoc_clink->cmd_eng = NULL; -} -EXPORT_SYMBOL(esoc_clink_unregister_cmd_eng); - -int esoc_drv_register(struct esoc_drv *driver) -{ - int ret; - - driver->driver.bus = &esoc_bus_type; - driver->driver.probe = esoc_bus_probe; - ret = driver_register(&driver->driver); - if (ret) - return ret; - return 0; -} -EXPORT_SYMBOL(esoc_drv_register); - -static int __init esoc_init(void) -{ - int ret; - - ret = device_register(&esoc_bus); - if (ret) { - pr_err("esoc bus device register fail\n"); - return ret; - } - ret = bus_register(&esoc_bus_type); - if (ret) { - pr_err("esoc bus register fail\n"); - return ret; - } - pr_debug("esoc bus registration done\n"); - return 0; -} - -subsys_initcall(esoc_init); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/esoc/esoc_dev.c b/drivers/esoc/esoc_dev.c deleted file mode 100644 index 57a7fbf6baedf4e06f96bd14f0e015648d902f1f..0000000000000000000000000000000000000000 --- a/drivers/esoc/esoc_dev.c +++ /dev/null @@ -1,380 +0,0 @@ -/* Copyright (c) 2013, 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 -#include -#include -#include -#include -#include "esoc.h" - -/** - * struct esoc_udev: Userspace char interface - * @dev: interface device. - * @req_fifio: fifo for clink requests. - * @req_wait: signal availability of request from clink - * @req_fifo_lock: serialize access to req fifo - * @evt_fito: fifo for clink events - * @evt_wait: signal availablity of clink event - * @evt_fifo_lock: serialize access to event fifo - * @list: entry in esoc dev list. - * @clink: reference to contorl link - */ -struct esoc_udev { - struct device *dev; - struct kfifo req_fifo; - wait_queue_head_t req_wait; - spinlock_t req_fifo_lock; - struct kfifo evt_fifo; - wait_queue_head_t evt_wait; - spinlock_t evt_fifo_lock; - struct list_head list; - struct esoc_clink *clink; -}; - -/** - * struct esoc_uhandle: Userspace handle of esoc - * @esoc_clink: esoc control link. - * @eng: esoc engine for commands/ requests. - * @esoc_udev: user interface device. - */ -struct esoc_uhandle { - struct esoc_clink *esoc_clink; - struct esoc_eng eng; - struct esoc_udev *esoc_udev; -}; - -#define ESOC_MAX_MINOR 256 -#define ESOC_MAX_REQ 8 -#define ESOC_MAX_EVT 4 - -static LIST_HEAD(esoc_udev_list); -static DEFINE_SPINLOCK(esoc_udev_list_lock); -struct class *esoc_class; -static int esoc_major; - -static struct esoc_udev *get_free_esoc_udev(struct esoc_clink *esoc_clink) -{ - struct esoc_udev *esoc_udev; - int err; - - if (esoc_clink->id > ESOC_MAX_MINOR) { - pr_err("too many esoc devices\n"); - return ERR_PTR(-ENODEV); - } - esoc_udev = kzalloc(sizeof(*esoc_udev), GFP_KERNEL); - if (!esoc_udev) - return ERR_PTR(-ENOMEM); - err = kfifo_alloc(&esoc_udev->req_fifo, (sizeof(u32)) * ESOC_MAX_REQ, - GFP_KERNEL); - if (err) { - pr_err("unable to allocate request fifo for %s\n", - esoc_clink->name); - goto req_fifo_fail; - } - err = kfifo_alloc(&esoc_udev->req_fifo, (sizeof(u32)) * ESOC_MAX_EVT, - GFP_KERNEL); - if (err) { - pr_err("unable to allocate evt fifo for %s\n", - esoc_clink->name); - goto evt_fifo_fail; - } - init_waitqueue_head(&esoc_udev->req_wait); - init_waitqueue_head(&esoc_udev->evt_wait); - spin_lock_init(&esoc_udev->req_fifo_lock); - spin_lock_init(&esoc_udev->evt_fifo_lock); - esoc_udev->clink = esoc_clink; - spin_lock(&esoc_udev_list_lock); - list_add_tail(&esoc_udev->list, &esoc_udev_list); - spin_unlock(&esoc_udev_list_lock); - return esoc_udev; -evt_fifo_fail: - kfifo_free(&esoc_udev->req_fifo); -req_fifo_fail: - kfree(esoc_udev); - return ERR_PTR(-ENODEV); -} - -static void return_esoc_udev(struct esoc_udev *esoc_udev) -{ - spin_lock(&esoc_udev_list_lock); - list_del(&esoc_udev->list); - spin_unlock(&esoc_udev_list_lock); - kfifo_free(&esoc_udev->req_fifo); - kfifo_free(&esoc_udev->evt_fifo); - kfree(esoc_udev); -} - -static struct esoc_udev *esoc_udev_get_by_minor(unsigned index) -{ - struct esoc_udev *esoc_udev; - - spin_lock(&esoc_udev_list_lock); - list_for_each_entry(esoc_udev, &esoc_udev_list, list) { - if (esoc_udev->clink->id == index) - goto found; - } - esoc_udev = NULL; -found: - spin_unlock(&esoc_udev_list_lock); - return esoc_udev; -} - -void esoc_udev_handle_clink_req(enum esoc_req req, struct esoc_eng *eng) -{ - int err; - u32 clink_req; - struct esoc_clink *esoc_clink = eng->esoc_clink; - struct esoc_udev *esoc_udev = esoc_udev_get_by_minor(esoc_clink->id); - - if (!esoc_udev) - return; - clink_req = (u32)req; - err = kfifo_in_spinlocked(&esoc_udev->req_fifo, &clink_req, - sizeof(clink_req), - &esoc_udev->req_fifo_lock); - if (err != sizeof(clink_req)) { - pr_err("unable to queue request for %s\n", esoc_clink->name); - return; - } - wake_up_interruptible(&esoc_udev->req_wait); -} - -void esoc_udev_handle_clink_evt(enum esoc_evt evt, struct esoc_eng *eng) -{ - int err; - u32 clink_evt; - struct esoc_clink *esoc_clink = eng->esoc_clink; - struct esoc_udev *esoc_udev = esoc_udev_get_by_minor(esoc_clink->id); - if (!esoc_udev) - return; - clink_evt = (u32)evt; - err = kfifo_in_spinlocked(&esoc_udev->evt_fifo, &clink_evt, - sizeof(clink_evt), - &esoc_udev->evt_fifo_lock); - if (err != sizeof(clink_evt)) { - pr_err("unable to queue event for %s\n", esoc_clink->name); - return; - } - wake_up_interruptible(&esoc_udev->evt_wait); -} - -static long esoc_dev_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - int err; - u32 esoc_cmd , status, req, evt; - struct esoc_uhandle *uhandle = file->private_data; - struct esoc_udev *esoc_udev = uhandle->esoc_udev; - struct esoc_clink *esoc_clink = uhandle->esoc_clink; - const struct esoc_clink_ops const *clink_ops = esoc_clink->clink_ops; - void __user *uarg = (void __user *)arg; - - switch (cmd) { - case ESOC_REG_REQ_ENG: - err = esoc_clink_register_req_eng(esoc_clink, &uhandle->eng); - if (err) - return err; - break; - case ESOC_REG_CMD_ENG: - err = esoc_clink_register_cmd_eng(esoc_clink, &uhandle->eng); - if (err) - return err; - break; - case ESOC_CMD_EXE: - if (esoc_clink->cmd_eng != &uhandle->eng) - return -EACCES; - get_user(esoc_cmd, (u32 __user *)arg); - return clink_ops->cmd_exe(esoc_cmd, esoc_clink); - case ESOC_WAIT_FOR_REQ: - if (esoc_clink->req_eng != &uhandle->eng) - return -EACCES; - err = wait_event_interruptible(esoc_udev->req_wait, - !kfifo_is_empty(&esoc_udev->req_fifo)); - if (!err) { - err = kfifo_out_spinlocked(&esoc_udev->req_fifo, &req, - sizeof(req), - &esoc_udev->req_fifo_lock); - if (err != sizeof(req)) { - pr_err("read from clink %s req q failed\n", - esoc_clink->name); - return -EIO; - } - put_user(req, (unsigned long __user *)uarg); - - } - return err; - break; - case ESOC_NOTIFY: - get_user(esoc_cmd, (u32 __user *)arg); - clink_ops->notify(esoc_cmd, esoc_clink); - break; - case ESOC_GET_STATUS: - err = clink_ops->get_status(&status, esoc_clink); - if (err) - return err; - put_user(status, (unsigned long __user *)uarg); - break; - case ESOC_WAIT_FOR_CRASH: - err = wait_event_interruptible(esoc_udev->evt_wait, - !kfifo_is_empty(&esoc_udev->evt_fifo)); - if (!err) { - err = kfifo_out_spinlocked(&esoc_udev->evt_fifo, &evt, - sizeof(evt), - &esoc_udev->evt_fifo_lock); - if (err != sizeof(evt)) { - pr_err("read from clink %s evt q failed\n", - esoc_clink->name); - return -EIO; - } - put_user(evt, (unsigned long __user *)uarg); - } - return err; - break; - default: - return -EINVAL; - }; - return 0; -} - -static int esoc_dev_open(struct inode *inode, struct file *file) -{ - struct esoc_uhandle *uhandle; - struct esoc_udev *esoc_udev; - struct esoc_clink *esoc_clink; - struct esoc_eng *eng; - unsigned int minor = iminor(inode); - - esoc_udev = esoc_udev_get_by_minor(minor); - esoc_clink = get_esoc_clink(esoc_udev->clink->id); - - uhandle = kzalloc(sizeof(*uhandle), GFP_KERNEL); - if (!uhandle) { - pr_err("failed to allocate memory for uhandle\n"); - put_esoc_clink(esoc_clink); - return -ENOMEM; - } - uhandle->esoc_udev = esoc_udev; - uhandle->esoc_clink = esoc_clink; - eng = &uhandle->eng; - eng->handle_clink_req = esoc_udev_handle_clink_req; - eng->handle_clink_evt = esoc_udev_handle_clink_evt; - file->private_data = uhandle; - return 0; -} - -static int esoc_dev_release(struct inode *inode, struct file *file) -{ - struct esoc_clink *esoc_clink; - struct esoc_uhandle *uhandle = file->private_data; - - esoc_clink = uhandle->esoc_clink; - put_esoc_clink(esoc_clink); - kfree(uhandle); - return 0; -} -static const struct file_operations esoc_dev_fops = { - .owner = THIS_MODULE, - .open = esoc_dev_open, - .unlocked_ioctl = esoc_dev_ioctl, - .release = esoc_dev_release, -}; - -int esoc_clink_add_device(struct device *dev, void *dummy) -{ - struct esoc_udev *esoc_udev; - struct esoc_clink *esoc_clink = to_esoc_clink(dev); - - esoc_udev = get_free_esoc_udev(esoc_clink); - if (IS_ERR(esoc_udev)) - return PTR_ERR(esoc_udev); - esoc_udev->dev = device_create(esoc_class, &esoc_clink->dev, - MKDEV(esoc_major, esoc_clink->id), - esoc_clink, "esoc-%d", esoc_clink->id); - if (IS_ERR(esoc_udev->dev)) { - pr_err("failed to create user device\n"); - goto dev_err; - } - return 0; -dev_err: - return_esoc_udev(esoc_udev); - return -ENODEV; -} - -int esoc_clink_del_device(struct device *dev, void *dummy) -{ - struct esoc_udev *esoc_udev; - struct esoc_clink *esoc_clink = to_esoc_clink(dev); - - esoc_udev = esoc_udev_get_by_minor(esoc_clink->id); - if (!esoc_udev) - return 0; - return_esoc_udev(esoc_udev); - device_destroy(esoc_class, MKDEV(esoc_major, esoc_clink->id)); - return_esoc_udev(esoc_udev); - return 0; -} - -static int esoc_dev_notifier_call(struct notifier_block *nb, - unsigned long action, - void *data) -{ - struct device *dev = data; - - switch (action) { - case BUS_NOTIFY_ADD_DEVICE: - return esoc_clink_add_device(dev, NULL); - case BUS_NOTIFY_DEL_DEVICE: - return esoc_clink_del_device(dev, NULL); - }; - return 0; -} - -static struct notifier_block esoc_dev_notifier = { - .notifier_call = esoc_dev_notifier_call, -}; - -int __init esoc_dev_init(void) -{ - int ret = 0; - esoc_class = class_create(THIS_MODULE, "esoc-dev"); - if (IS_ERR(esoc_class)) { - pr_err("coudn't create class"); - return PTR_ERR(esoc_class); - } - esoc_major = register_chrdev(0, "esoc", &esoc_dev_fops); - if (esoc_major < 0) { - pr_err("failed to allocate char dev\n"); - ret = esoc_major; - goto class_unreg; - } - ret = bus_register_notifier(&esoc_bus_type, &esoc_dev_notifier); - if (ret) - goto chrdev_unreg; - esoc_for_each_dev(NULL, esoc_clink_add_device); - return ret; -chrdev_unreg: - unregister_chrdev(esoc_major, "esoc"); -class_unreg: - class_destroy(esoc_class); - return 0; -} - -void __exit esoc_dev_exit(void) -{ - bus_unregister_notifier(&esoc_bus_type, &esoc_dev_notifier); - class_destroy(esoc_class); - unregister_chrdev(esoc_major, "esoc-dev"); -} - -MODULE_LICENSE("GPLv2"); -module_init(esoc_dev_init); -module_exit(esoc_dev_exit); diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index f2175fd0bf5e991867759d354d9b396098b6d4a3..7fab6eef36eb1cd11bc7447fd0a1e1e4e7fa3b65 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -180,14 +180,6 @@ config GPIO_MSM_V3 the pins on the MSM can be selected for GPIO, and are controlled by this driver. -config GPIO_FSM9XXX - tristate "Qualcomm FSM GPIO" - depends on GPIOLIB && ARCH_MSM - help - Say yes here to support the GPIO interface on Qualcomm FSM chips. - Most of the pins on the MSM can be selected for GPIO, and are - controlled by this driver. - config GPIO_MVEBU def_bool y depends on PLAT_ORION @@ -714,29 +706,6 @@ config GPIO_TPS65910 Select this option to enable GPIO driver for the TPS65910 chip family. -config GPIO_PM8XXX - tristate "Qualcomm PM8xxx GPIO support" - depends on MFD_PM8XXX - default y if MFD_PM8XXX - help - This option enables support for on-chip GPIO found on Qualcomm PM8xxx - PMICs. - -config GPIO_PM8XXX_MPP - tristate "Support for Qualcomm PM8xxx MPP features" - depends on MFD_PM8XXX - default y if MFD_PM8XXX - help - This is the multi-purpose pin (MPP) driver for Qualcomm PM 8xxx PMIC - chips. - -config GPIO_PM8XXX_RPC - tristate "Qualcomm PM8xxx RPC based GPIO support" - depends on MSM_SMD - help - This option enables support for on-chip GPIO found on Qualcomm PM8xxx - PMICs through RPC. - config GPIO_MSIC bool "Intel MSIC mixed signal gpio support" depends on MFD_INTEL_MSIC diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 13bbc5e3df19db5872e55cd7bde6cb11982fc2e5..dae4d3cd3fcbad9dcb7a716d07e5a3a2a31a35c7 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -48,7 +48,6 @@ obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o obj-$(CONFIG_GPIO_MSM_V1) += gpio-msm-v1.o obj-$(CONFIG_GPIO_MSM_V2) += gpio-msm-common.o gpio-msm-v2.o obj-$(CONFIG_GPIO_MSM_V3) += gpio-msm-common.o gpio-msm-v3.o -obj-$(CONFIG_GPIO_FSM9XXX) += gpio-fsm9xxx.o obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o @@ -57,9 +56,6 @@ obj-$(CONFIG_GPIO_PCA953X) += gpio-pca953x.o obj-$(CONFIG_GPIO_PCF857X) += gpio-pcf857x.o obj-$(CONFIG_GPIO_PCH) += gpio-pch.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o -obj-$(CONFIG_GPIO_PM8XXX) += pm8xxx-gpio.o -obj-$(CONFIG_GPIO_PM8XXX_MPP) += pm8xxx-mpp.o -obj-$(CONFIG_GPIO_PM8XXX_RPC) += gpio-pm8xxx-rpc.o obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o obj-$(CONFIG_GPIO_QPNP_PIN) += qpnp-pin.o diff --git a/drivers/gpio/gpio-fsm9xxx.c b/drivers/gpio/gpio-fsm9xxx.c deleted file mode 100644 index 496e97e4128caa42e5740a6e42606dada39d8e71..0000000000000000000000000000000000000000 --- a/drivers/gpio/gpio-fsm9xxx.c +++ /dev/null @@ -1,335 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include - -/* see 80-VA736-2 Rev C pp 695-751 -** -** These are actually the *shadow* gpio registers, since the -** real ones (which allow full access) are only available to the -** ARM9 side of the world. -** -** Since the _BASE need to be page-aligned when we're mapping them -** to virtual addresses, adjust for the additional offset in these -** macros. -*/ - -#if defined(CONFIG_ARCH_FSM9XXX) -#define MSM_GPIO1_REG(off) (MSM_TLMM_BASE + (off)) -#endif - -#if defined(CONFIG_ARCH_FSM9XXX) - -/* output value */ -#define MSM_GPIO_OUT_G(group) MSM_GPIO1_REG(0x00 + (group) * 4) -#define MSM_GPIO_OUT_N(gpio) MSM_GPIO_OUT_G((gpio) / 32) -#define MSM_GPIO_OUT_0 MSM_GPIO_OUT_G(0) /* gpio 31-0 */ -#define MSM_GPIO_OUT_1 MSM_GPIO_OUT_G(1) /* gpio 63-32 */ -#define MSM_GPIO_OUT_2 MSM_GPIO_OUT_G(2) /* gpio 95-64 */ -#define MSM_GPIO_OUT_3 MSM_GPIO_OUT_G(3) /* gpio 127-96 */ -#define MSM_GPIO_OUT_4 MSM_GPIO_OUT_G(4) /* gpio 159-128 */ -#define MSM_GPIO_OUT_5 MSM_GPIO_OUT_G(5) /* gpio 167-160 */ - -/* same pin map as above, output enable */ -#define MSM_GPIO_OE_G(group) MSM_GPIO1_REG(0x20 + (group) * 4) -#define MSM_GPIO_OE_N(gpio) MSM_GPIO_OE_G((gpio) / 32) -#define MSM_GPIO_OE_0 MSM_GPIO_OE_G(0) -#define MSM_GPIO_OE_1 MSM_GPIO_OE_G(1) -#define MSM_GPIO_OE_2 MSM_GPIO_OE_G(2) -#define MSM_GPIO_OE_3 MSM_GPIO_OE_G(3) -#define MSM_GPIO_OE_4 MSM_GPIO_OE_G(4) -#define MSM_GPIO_OE_5 MSM_GPIO_OE_G(5) - -/* same pin map as above, input read */ -#define MSM_GPIO_IN_G(group) MSM_GPIO1_REG(0x48 + (group) * 4) -#define MSM_GPIO_IN_N(gpio) MSM_GPIO_IN_G((gpio) / 32) -#define MSM_GPIO_IN_0 MSM_GPIO_IN_G(0) -#define MSM_GPIO_IN_1 MSM_GPIO_IN_G(1) -#define MSM_GPIO_IN_2 MSM_GPIO_IN_G(2) -#define MSM_GPIO_IN_3 MSM_GPIO_IN_G(3) -#define MSM_GPIO_IN_4 MSM_GPIO_IN_G(4) -#define MSM_GPIO_IN_5 MSM_GPIO_IN_G(5) - -/* configuration */ -#define MSM_GPIO_PAGE MSM_GPIO1_REG(0x40) -#define MSM_GPIO_CONFIG MSM_GPIO1_REG(0x44) - -#endif /* CONFIG_ARCH_FSM9XXX */ - -#define MSM_GPIO_BANK(bank, first, last) \ - { \ - .regs = { \ - .out = MSM_GPIO_OUT_##bank, \ - .in = MSM_GPIO_IN_##bank, \ - .oe = MSM_GPIO_OE_##bank, \ - }, \ - .chip = { \ - .base = (first), \ - .ngpio = (last) - (first) + 1, \ - .get = msm_gpio_get, \ - .set = msm_gpio_set, \ - .direction_input = msm_gpio_direction_input, \ - .direction_output = msm_gpio_direction_output, \ - .request = msm_gpio_request, \ - .free = msm_gpio_free, \ - } \ - } - -struct msm_gpio_regs { - void __iomem *out; - void __iomem *in; - void __iomem *oe; -}; - -struct msm_gpio_chip { - spinlock_t lock; - struct gpio_chip chip; - struct msm_gpio_regs regs; -}; - -static int msm_gpio_write(struct msm_gpio_chip *msm_chip, - unsigned offset, unsigned on) -{ - unsigned mask = BIT(offset); - unsigned val; - - val = __raw_readl(msm_chip->regs.out); - if (on) - __raw_writel(val | mask, msm_chip->regs.out); - else - __raw_writel(val & ~mask, msm_chip->regs.out); - return 0; -} - -static int msm_gpio_direction_input(struct gpio_chip *chip, unsigned offset) -{ - struct msm_gpio_chip *msm_chip; - unsigned long irq_flags; - - msm_chip = container_of(chip, struct msm_gpio_chip, chip); - spin_lock_irqsave(&msm_chip->lock, irq_flags); - __raw_writel(__raw_readl(msm_chip->regs.oe) & ~BIT(offset), - msm_chip->regs.oe); - spin_unlock_irqrestore(&msm_chip->lock, irq_flags); - return 0; -} - -static int -msm_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) -{ - struct msm_gpio_chip *msm_chip; - unsigned long irq_flags; - - msm_chip = container_of(chip, struct msm_gpio_chip, chip); - spin_lock_irqsave(&msm_chip->lock, irq_flags); - msm_gpio_write(msm_chip, offset, value); - __raw_writel(__raw_readl(msm_chip->regs.oe) | BIT(offset), - msm_chip->regs.oe); - spin_unlock_irqrestore(&msm_chip->lock, irq_flags); - return 0; -} - -static int msm_gpio_get(struct gpio_chip *chip, unsigned offset) -{ - struct msm_gpio_chip *msm_chip; - - msm_chip = container_of(chip, struct msm_gpio_chip, chip); - return (__raw_readl(msm_chip->regs.in) & (1U << offset)) ? 1 : 0; -} - -static void msm_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -{ - struct msm_gpio_chip *msm_chip; - unsigned long irq_flags; - - msm_chip = container_of(chip, struct msm_gpio_chip, chip); - spin_lock_irqsave(&msm_chip->lock, irq_flags); - msm_gpio_write(msm_chip, offset, value); - spin_unlock_irqrestore(&msm_chip->lock, irq_flags); -} - -#ifdef CONFIG_MSM_GPIOMUX -static int msm_gpio_request(struct gpio_chip *chip, unsigned offset) -{ - return msm_gpiomux_get(chip->base + offset); -} - -static void msm_gpio_free(struct gpio_chip *chip, unsigned offset) -{ - msm_gpiomux_put(chip->base + offset); -} -#else -#define msm_gpio_request NULL -#define msm_gpio_free NULL -#endif - -struct msm_gpio_chip msm_gpio_chips[] = { - MSM_GPIO_BANK(0, 0, 31), - MSM_GPIO_BANK(1, 32, 63), - MSM_GPIO_BANK(2, 64, 95), - MSM_GPIO_BANK(3, 96, 127), - MSM_GPIO_BANK(4, 128, 159), - MSM_GPIO_BANK(5, 160, 167), -}; - -void msm_gpio_enter_sleep(int from_idle) -{ - return; -} - -void msm_gpio_exit_sleep(void) -{ - return; -} - -static int __init msm_init_gpio(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) { - spin_lock_init(&msm_gpio_chips[i].lock); - gpiochip_add(&msm_gpio_chips[i].chip); - } - - return 0; -} - -postcore_initcall(msm_init_gpio); - -int gpio_tlmm_config(unsigned config, unsigned disable) -{ - uint32_t flags; - unsigned gpio = GPIO_PIN(config); - - if (gpio > NR_MSM_GPIOS) - return -EINVAL; - flags = ((GPIO_DRVSTR(config) << 6) & (0x7 << 6)) | - ((GPIO_FUNC(config) << 2) & (0xf << 2)) | - ((GPIO_PULL(config) & 0x3)); - dsb(); - __raw_writel(gpio, MSM_GPIO_PAGE); - dsb(); - __raw_writel(flags, MSM_GPIO_CONFIG); - - return 0; -} -EXPORT_SYMBOL(gpio_tlmm_config); - -int msm_gpios_request_enable(const struct msm_gpio *table, int size) -{ - int rc = msm_gpios_request(table, size); - if (rc) - return rc; - rc = msm_gpios_enable(table, size); - if (rc) - msm_gpios_free(table, size); - return rc; -} -EXPORT_SYMBOL(msm_gpios_request_enable); - -void msm_gpios_disable_free(const struct msm_gpio *table, int size) -{ - msm_gpios_disable(table, size); - msm_gpios_free(table, size); -} -EXPORT_SYMBOL(msm_gpios_disable_free); - -int msm_gpios_request(const struct msm_gpio *table, int size) -{ - int rc; - int i; - const struct msm_gpio *g; - for (i = 0; i < size; i++) { - g = table + i; - rc = gpio_request(GPIO_PIN(g->gpio_cfg), g->label); - if (rc) { - pr_err("gpio_request(%d) <%s> failed: %d\n", - GPIO_PIN(g->gpio_cfg), g->label ?: "?", rc); - goto err; - } - } - return 0; -err: - msm_gpios_free(table, i); - return rc; -} -EXPORT_SYMBOL(msm_gpios_request); - -void msm_gpios_free(const struct msm_gpio *table, int size) -{ - int i; - const struct msm_gpio *g; - for (i = size-1; i >= 0; i--) { - g = table + i; - gpio_free(GPIO_PIN(g->gpio_cfg)); - } -} -EXPORT_SYMBOL(msm_gpios_free); - -int msm_gpios_enable(const struct msm_gpio *table, int size) -{ - int rc; - int i; - const struct msm_gpio *g; - for (i = 0; i < size; i++) { - g = table + i; - rc = gpio_tlmm_config(g->gpio_cfg, GPIO_CFG_ENABLE); - if (rc) { - pr_err("gpio_tlmm_config(0x%08x, GPIO_CFG_ENABLE)" - " <%s> failed: %d\n", - g->gpio_cfg, g->label ?: "?", rc); - pr_err("pin %d func %d dir %d pull %d drvstr %d\n", - GPIO_PIN(g->gpio_cfg), GPIO_FUNC(g->gpio_cfg), - GPIO_DIR(g->gpio_cfg), GPIO_PULL(g->gpio_cfg), - GPIO_DRVSTR(g->gpio_cfg)); - goto err; - } - } - return 0; -err: - msm_gpios_disable(table, i); - return rc; -} -EXPORT_SYMBOL(msm_gpios_enable); - -int msm_gpios_disable(const struct msm_gpio *table, int size) -{ - int rc = 0; - int i; - const struct msm_gpio *g; - for (i = size-1; i >= 0; i--) { - int tmp; - g = table + i; - tmp = gpio_tlmm_config(g->gpio_cfg, GPIO_CFG_DISABLE); - if (tmp) { - pr_err("gpio_tlmm_config(0x%08x, GPIO_CFG_DISABLE)" - " <%s> failed: %d\n", - g->gpio_cfg, g->label ?: "?", rc); - pr_err("pin %d func %d dir %d pull %d drvstr %d\n", - GPIO_PIN(g->gpio_cfg), GPIO_FUNC(g->gpio_cfg), - GPIO_DIR(g->gpio_cfg), GPIO_PULL(g->gpio_cfg), - GPIO_DRVSTR(g->gpio_cfg)); - if (!rc) - rc = tmp; - } - } - - return rc; -} -EXPORT_SYMBOL(msm_gpios_disable); - diff --git a/drivers/gpio/gpio-pm8xxx-rpc.c b/drivers/gpio/gpio-pm8xxx-rpc.c deleted file mode 100644 index 4b1a91b6dc3bb2b68875904c190bc0a30fee276e..0000000000000000000000000000000000000000 --- a/drivers/gpio/gpio-pm8xxx-rpc.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Qualcomm PMIC8XXX GPIO driver based on RPC - * - * Copyright (c) 2011, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include - -struct pm8xxx_gpio_rpc_chip { - struct list_head link; - struct gpio_chip gpio_chip; -}; - -static LIST_HEAD(pm8xxx_gpio_rpc_chips); -static DEFINE_MUTEX(pm8xxx_gpio_chips_lock); - -static int pm8xxx_gpio_rpc_get(struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip, - unsigned gpio) -{ - int rc; - - if (gpio >= pm8xxx_gpio_chip->gpio_chip.ngpio - || pm8xxx_gpio_chip == NULL) - return -EINVAL; - - rc = pmic_gpio_get_value(gpio); - - return rc; -} - -static int pm8xxx_gpio_rpc_set(struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip, - unsigned gpio, int value) -{ - int rc; - - if (gpio >= pm8xxx_gpio_chip->gpio_chip.ngpio || - pm8xxx_gpio_chip == NULL) - return -EINVAL; - - rc = pmic_gpio_set_value(gpio, value); - - return rc; -} - -static int pm8xxx_gpio_rpc_set_direction(struct pm8xxx_gpio_rpc_chip - *pm8xxx_gpio_chip, unsigned gpio, int direction) -{ - int rc = 0; - - if (!direction || pm8xxx_gpio_chip == NULL) - return -EINVAL; - - if (direction == PM_GPIO_DIR_IN) - rc = pmic_gpio_direction_input(gpio); - else if (direction == PM_GPIO_DIR_OUT) - rc = pmic_gpio_direction_output(gpio); - - return rc; -} - -static int pm8xxx_gpio_rpc_read(struct gpio_chip *gpio_chip, unsigned offset) -{ - struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip = - dev_get_drvdata(gpio_chip->dev); - - return pm8xxx_gpio_rpc_get(pm8xxx_gpio_chip, offset); -} - -static void pm8xxx_gpio_rpc_write(struct gpio_chip *gpio_chip, - unsigned offset, int val) -{ - struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip = - dev_get_drvdata(gpio_chip->dev); - - pm8xxx_gpio_rpc_set(pm8xxx_gpio_chip, offset, !!val); -} - -static int pm8xxx_gpio_rpc_direction_input(struct gpio_chip *gpio_chip, - unsigned offset) -{ - struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip = - dev_get_drvdata(gpio_chip->dev); - - return pm8xxx_gpio_rpc_set_direction(pm8xxx_gpio_chip, offset, - PM_GPIO_DIR_IN); -} - -static int pm8xxx_gpio_rpc_direction_output(struct gpio_chip *gpio_chip, - unsigned offset, int val) -{ - int ret = 0; - - struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip = - dev_get_drvdata(gpio_chip->dev); - - ret = pm8xxx_gpio_rpc_set_direction(pm8xxx_gpio_chip, offset, - PM_GPIO_DIR_OUT); - if (!ret) - ret = pm8xxx_gpio_rpc_set(pm8xxx_gpio_chip, offset, !!val); - - return ret; -} - -static void pm8xxx_gpio_rpc_dbg_show(struct seq_file *s, struct gpio_chip - *gpio_chip) -{ - struct pm8xxx_gpio_rpc_chip *pmxx_gpio_chip = - dev_get_drvdata(gpio_chip->dev); - u8 state, mode; - const char *label; - int i; - - for (i = 0; i < gpio_chip->ngpio; i++) { - label = gpiochip_is_requested(gpio_chip, i); - state = pm8xxx_gpio_rpc_get(pmxx_gpio_chip, i); - mode = pmic_gpio_get_direction(i); - seq_printf(s, "gpio-%-3d (%-12.12s) %s %s", - gpio_chip->base + i, - label ? label : " ", mode ? "out" : "in", - state ? "hi" : "lo"); - seq_printf(s, "\n"); - } -} - -static int pm8xxx_gpio_rpc_probe(struct platform_device *pdev) -{ - int ret; - struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip; - const struct pm8xxx_gpio_rpc_platform_data *pdata = - pdev->dev.platform_data; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - pm8xxx_gpio_chip = kzalloc(sizeof(struct pm8xxx_gpio_rpc_chip), - GFP_KERNEL); - if (!pm8xxx_gpio_chip) { - pr_err("Cannot allocate pm8xxx_gpio_chip\n"); - return -ENOMEM; - } - - pm8xxx_gpio_chip->gpio_chip.label = "pm8xxx-gpio-rpc"; - pm8xxx_gpio_chip->gpio_chip.direction_input = - pm8xxx_gpio_rpc_direction_input; - pm8xxx_gpio_chip->gpio_chip.direction_output = - pm8xxx_gpio_rpc_direction_output; - pm8xxx_gpio_chip->gpio_chip.get = pm8xxx_gpio_rpc_read; - pm8xxx_gpio_chip->gpio_chip.set = pm8xxx_gpio_rpc_write; - pm8xxx_gpio_chip->gpio_chip.dbg_show = pm8xxx_gpio_rpc_dbg_show; - pm8xxx_gpio_chip->gpio_chip.ngpio = pdata->ngpios; - pm8xxx_gpio_chip->gpio_chip.can_sleep = 1; - pm8xxx_gpio_chip->gpio_chip.dev = &pdev->dev; - pm8xxx_gpio_chip->gpio_chip.base = pdata->gpio_base; - - mutex_lock(&pm8xxx_gpio_chips_lock); - list_add(&pm8xxx_gpio_chip->link, &pm8xxx_gpio_rpc_chips); - mutex_unlock(&pm8xxx_gpio_chips_lock); - platform_set_drvdata(pdev, pm8xxx_gpio_chip); - - ret = gpiochip_add(&pm8xxx_gpio_chip->gpio_chip); - if (ret) { - pr_err("gpiochip_add failed ret = %d\n", ret); - goto reset_drvdata; - } - - pr_info("OK: base=%d, ngpio=%d\n", pm8xxx_gpio_chip->gpio_chip.base, - pm8xxx_gpio_chip->gpio_chip.ngpio); - - return 0; - -reset_drvdata: - mutex_lock(&pm8xxx_gpio_chips_lock); - list_del(&pm8xxx_gpio_chip->link); - mutex_unlock(&pm8xxx_gpio_chips_lock); - platform_set_drvdata(pdev, NULL); - kfree(pm8xxx_gpio_chip); - mutex_destroy(&pm8xxx_gpio_chips_lock); - return ret; -} - -static int pm8xxx_gpio_rpc_remove(struct platform_device *pdev) -{ - struct pm8xxx_gpio_rpc_chip *pm8xxx_gpio_chip = - platform_get_drvdata(pdev); - - mutex_lock(&pm8xxx_gpio_chips_lock); - list_del(&pm8xxx_gpio_chip->link); - mutex_unlock(&pm8xxx_gpio_chips_lock); - platform_set_drvdata(pdev, NULL); - if (gpiochip_remove(&pm8xxx_gpio_chip->gpio_chip)) - pr_err("failed to remove gpio chip\n"); - kfree(pm8xxx_gpio_chip); - mutex_destroy(&pm8xxx_gpio_chips_lock); - return 0; -} - -static struct platform_driver pm8xxx_gpio_rpc_driver = { - .probe = pm8xxx_gpio_rpc_probe, - .remove = pm8xxx_gpio_rpc_remove, - .driver = { - .name = PM8XXX_GPIO_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_gpio_rpc_init(void) -{ - return platform_driver_register(&pm8xxx_gpio_rpc_driver); -} -postcore_initcall(pm8xxx_gpio_rpc_init); - -static void __exit pm8xxx_gpio_rpc_exit(void) -{ - platform_driver_unregister(&pm8xxx_gpio_rpc_driver); -} -module_exit(pm8xxx_gpio_rpc_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC GPIO driver based on RPC"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_GPIO_DEV_NAME); diff --git a/drivers/gpio/pm8xxx-gpio.c b/drivers/gpio/pm8xxx-gpio.c deleted file mode 100644 index 0ce598982d9c9d300592982e20bc6e9ae3117e44..0000000000000000000000000000000000000000 --- a/drivers/gpio/pm8xxx-gpio.c +++ /dev/null @@ -1,453 +0,0 @@ -/* Copyright (c) 2011-2013, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* GPIO registers */ -#define SSBI_REG_ADDR_GPIO_BASE 0x150 -#define SSBI_REG_ADDR_GPIO(n) (SSBI_REG_ADDR_GPIO_BASE + n) - -/* GPIO */ -#define PM_GPIO_BANK_MASK 0x70 -#define PM_GPIO_BANK_SHIFT 4 -#define PM_GPIO_WRITE 0x80 - -/* Bank 0 */ -#define PM_GPIO_VIN_MASK 0x0E -#define PM_GPIO_VIN_SHIFT 1 -#define PM_GPIO_MODE_ENABLE 0x01 - -/* Bank 1 */ -#define PM_GPIO_MODE_MASK 0x0C -#define PM_GPIO_MODE_SHIFT 2 -#define PM_GPIO_OUT_BUFFER 0x02 -#define PM_GPIO_OUT_INVERT 0x01 - -#define PM_GPIO_MODE_OFF 3 -#define PM_GPIO_MODE_OUTPUT 2 -#define PM_GPIO_MODE_INPUT 0 -#define PM_GPIO_MODE_BOTH 1 - -/* Bank 2 */ -#define PM_GPIO_PULL_MASK 0x0E -#define PM_GPIO_PULL_SHIFT 1 - -/* Bank 3 */ -#define PM_GPIO_OUT_STRENGTH_MASK 0x0C -#define PM_GPIO_OUT_STRENGTH_SHIFT 2 -#define PM_GPIO_PIN_ENABLE 0x00 -#define PM_GPIO_PIN_DISABLE 0x01 - -/* Bank 4 */ -#define PM_GPIO_FUNC_MASK 0x0E -#define PM_GPIO_FUNC_SHIFT 1 - -/* Bank 5 */ -#define PM_GPIO_NON_INT_POL_INV 0x08 -#define PM_GPIO_BANKS 6 - -struct pm_gpio_chip { - struct list_head link; - struct gpio_chip gpio_chip; - spinlock_t pm_lock; - u8 *bank1; - int irq_base; -}; - -static LIST_HEAD(pm_gpio_chips); -static DEFINE_MUTEX(pm_gpio_chips_lock); - -static int pm_gpio_get(struct pm_gpio_chip *pm_gpio_chip, unsigned gpio) -{ - int mode; - - /* Get gpio value from config bank 1 if output gpio. - Get gpio value from IRQ RT status register for all other gpio modes. - */ - mode = (pm_gpio_chip->bank1[gpio] & PM_GPIO_MODE_MASK) >> - PM_GPIO_MODE_SHIFT; - if (mode == PM_GPIO_MODE_OUTPUT) - return pm_gpio_chip->bank1[gpio] & PM_GPIO_OUT_INVERT; - else - return pm8xxx_read_irq_stat(pm_gpio_chip->gpio_chip.dev->parent, - pm_gpio_chip->irq_base + gpio); -} - -static int pm_gpio_set(struct pm_gpio_chip *pm_gpio_chip, - unsigned gpio, int value) -{ - int rc; - u8 bank1; - unsigned long flags; - - spin_lock_irqsave(&pm_gpio_chip->pm_lock, flags); - bank1 = PM_GPIO_WRITE - | (pm_gpio_chip->bank1[gpio] & ~PM_GPIO_OUT_INVERT); - - if (value) - bank1 |= PM_GPIO_OUT_INVERT; - - pm_gpio_chip->bank1[gpio] = bank1; - rc = pm8xxx_writeb(pm_gpio_chip->gpio_chip.dev->parent, - SSBI_REG_ADDR_GPIO(gpio), bank1); - spin_unlock_irqrestore(&pm_gpio_chip->pm_lock, flags); - - if (rc) - pr_err("FAIL pm8xxx_writeb(): rc=%d. " - "(gpio=%d, value=%d)\n", - rc, gpio, value); - - return rc; -} - -static int dir_map[] = { - PM_GPIO_MODE_OFF, - PM_GPIO_MODE_OUTPUT, - PM_GPIO_MODE_INPUT, - PM_GPIO_MODE_BOTH, -}; - -static int pm_gpio_set_direction(struct pm_gpio_chip *pm_gpio_chip, - unsigned gpio, int direction) -{ - int rc; - u8 bank1; - unsigned long flags; - - if (!direction || pm_gpio_chip == NULL) - return -EINVAL; - - spin_lock_irqsave(&pm_gpio_chip->pm_lock, flags); - bank1 = PM_GPIO_WRITE - | (pm_gpio_chip->bank1[gpio] & ~PM_GPIO_MODE_MASK); - - bank1 |= ((dir_map[direction] << PM_GPIO_MODE_SHIFT) - & PM_GPIO_MODE_MASK); - - pm_gpio_chip->bank1[gpio] = bank1; - rc = pm8xxx_writeb(pm_gpio_chip->gpio_chip.dev->parent, - SSBI_REG_ADDR_GPIO(gpio), bank1); - spin_unlock_irqrestore(&pm_gpio_chip->pm_lock, flags); - - if (rc) - pr_err("Failed on pm8xxx_writeb(): rc=%d (GPIO config)\n", - rc); - - return rc; -} - -static int pm_gpio_init_bank1(struct pm_gpio_chip *pm_gpio_chip) -{ - int i, rc; - u8 bank; - - for (i = 0; i < pm_gpio_chip->gpio_chip.ngpio; i++) { - bank = 1 << PM_GPIO_BANK_SHIFT; - rc = pm8xxx_writeb(pm_gpio_chip->gpio_chip.dev->parent, - SSBI_REG_ADDR_GPIO(i), - bank); - if (rc) { - pr_err("error setting bank rc=%d\n", rc); - return rc; - } - - rc = pm8xxx_readb(pm_gpio_chip->gpio_chip.dev->parent, - SSBI_REG_ADDR_GPIO(i), - &pm_gpio_chip->bank1[i]); - if (rc) { - pr_err("error reading bank 1 rc=%d\n", rc); - return rc; - } - } - return 0; -} - -static int pm_gpio_to_irq(struct gpio_chip *gpio_chip, unsigned offset) -{ - struct pm_gpio_chip *pm_gpio_chip = dev_get_drvdata(gpio_chip->dev); - - return pm_gpio_chip->irq_base + offset; -} - -static int pm_gpio_read(struct gpio_chip *gpio_chip, unsigned offset) -{ - struct pm_gpio_chip *pm_gpio_chip = dev_get_drvdata(gpio_chip->dev); - - return pm_gpio_get(pm_gpio_chip, offset); -} - -static void pm_gpio_write(struct gpio_chip *gpio_chip, - unsigned offset, int val) -{ - struct pm_gpio_chip *pm_gpio_chip = dev_get_drvdata(gpio_chip->dev); - - pm_gpio_set(pm_gpio_chip, offset, val); -} - -static int pm_gpio_direction_input(struct gpio_chip *gpio_chip, - unsigned offset) -{ - struct pm_gpio_chip *pm_gpio_chip = dev_get_drvdata(gpio_chip->dev); - - return pm_gpio_set_direction(pm_gpio_chip, offset, PM_GPIO_DIR_IN); -} - -static int pm_gpio_direction_output(struct gpio_chip *gpio_chip, - unsigned offset, - int val) -{ - int ret; - struct pm_gpio_chip *pm_gpio_chip = dev_get_drvdata(gpio_chip->dev); - - ret = pm_gpio_set_direction(pm_gpio_chip, offset, PM_GPIO_DIR_OUT); - if (!ret) - ret = pm_gpio_set(pm_gpio_chip, offset, val); - - return ret; -} - -static void pm_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gpio_chip) -{ - static const char * const cmode[] = { "in", "in/out", "out", "off" }; - struct pm_gpio_chip *pm_gpio_chip = dev_get_drvdata(gpio_chip->dev); - u8 mode, state, bank; - const char *label; - int i, j; - - for (i = 0; i < gpio_chip->ngpio; i++) { - label = gpiochip_is_requested(gpio_chip, i); - mode = (pm_gpio_chip->bank1[i] & PM_GPIO_MODE_MASK) >> - PM_GPIO_MODE_SHIFT; - state = pm_gpio_get(pm_gpio_chip, i); - seq_printf(s, "gpio-%-3d (%-12.12s) %-10.10s" - " %s", - gpio_chip->base + i, - label ? label : "--", - cmode[mode], - state ? "hi" : "lo"); - for (j = 0; j < PM_GPIO_BANKS; j++) { - bank = j << PM_GPIO_BANK_SHIFT; - pm8xxx_writeb(gpio_chip->dev->parent, - SSBI_REG_ADDR_GPIO(i), - bank); - pm8xxx_readb(gpio_chip->dev->parent, - SSBI_REG_ADDR_GPIO(i), - &bank); - seq_printf(s, " 0x%02x", bank); - } - seq_printf(s, "\n"); - } -} - -static int pm_gpio_probe(struct platform_device *pdev) -{ - int ret; - const struct pm8xxx_gpio_platform_data *pdata = pdev->dev.platform_data; - struct pm_gpio_chip *pm_gpio_chip; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - pm_gpio_chip = kzalloc(sizeof(struct pm_gpio_chip), GFP_KERNEL); - if (!pm_gpio_chip) { - pr_err("Cannot allocate pm_gpio_chip\n"); - return -ENOMEM; - } - - pm_gpio_chip->bank1 = kzalloc(sizeof(u8) * pdata->gpio_cdata.ngpios, - GFP_KERNEL); - if (!pm_gpio_chip->bank1) { - pr_err("Cannot allocate pm_gpio_chip->bank1\n"); - ret = -ENOMEM; - goto free_chip; - } - - spin_lock_init(&pm_gpio_chip->pm_lock); - pm_gpio_chip->gpio_chip.label = "pm-gpio"; - pm_gpio_chip->gpio_chip.direction_input = pm_gpio_direction_input; - pm_gpio_chip->gpio_chip.direction_output = pm_gpio_direction_output; - pm_gpio_chip->gpio_chip.to_irq = pm_gpio_to_irq; - pm_gpio_chip->gpio_chip.get = pm_gpio_read; - pm_gpio_chip->gpio_chip.set = pm_gpio_write; - pm_gpio_chip->gpio_chip.dbg_show = pm_gpio_dbg_show; - pm_gpio_chip->gpio_chip.ngpio = pdata->gpio_cdata.ngpios; - pm_gpio_chip->gpio_chip.can_sleep = 0; - pm_gpio_chip->gpio_chip.dev = &pdev->dev; - pm_gpio_chip->gpio_chip.base = pdata->gpio_base; - pm_gpio_chip->irq_base = platform_get_irq(pdev, 0); - mutex_lock(&pm_gpio_chips_lock); - list_add(&pm_gpio_chip->link, &pm_gpio_chips); - mutex_unlock(&pm_gpio_chips_lock); - platform_set_drvdata(pdev, pm_gpio_chip); - - ret = gpiochip_add(&pm_gpio_chip->gpio_chip); - if (ret) { - pr_err("gpiochip_add failed ret = %d\n", ret); - goto reset_drvdata; - } - - ret = pm_gpio_init_bank1(pm_gpio_chip); - if (ret) { - pr_err("gpio init bank failed ret = %d\n", ret); - goto remove_chip; - } - - pr_info("OK: base=%d, ngpio=%d\n", pm_gpio_chip->gpio_chip.base, - pm_gpio_chip->gpio_chip.ngpio); - - return 0; - -remove_chip: - if (gpiochip_remove(&pm_gpio_chip->gpio_chip)) - pr_err("failed to remove gpio chip\n"); -reset_drvdata: - platform_set_drvdata(pdev, NULL); - kfree(pm_gpio_chip->bank1); -free_chip: - kfree(pm_gpio_chip); - return ret; -} - -static int pm_gpio_remove(struct platform_device *pdev) -{ - struct pm_gpio_chip *pm_gpio_chip - = platform_get_drvdata(pdev); - - mutex_lock(&pm_gpio_chips_lock); - list_del(&pm_gpio_chip->link); - mutex_unlock(&pm_gpio_chips_lock); - platform_set_drvdata(pdev, NULL); - if (gpiochip_remove(&pm_gpio_chip->gpio_chip)) - pr_err("failed to remove gpio chip\n"); - kfree(pm_gpio_chip->bank1); - kfree(pm_gpio_chip); - return 0; -} - -int pm8xxx_gpio_config(int gpio, struct pm_gpio *param) -{ - int rc, pm_gpio = -EINVAL; - u8 bank[8]; - unsigned long flags; - struct pm_gpio_chip *pm_gpio_chip; - struct gpio_chip *gpio_chip; - - if (param == NULL) - return -EINVAL; - - mutex_lock(&pm_gpio_chips_lock); - list_for_each_entry(pm_gpio_chip, &pm_gpio_chips, link) { - gpio_chip = &pm_gpio_chip->gpio_chip; - if (gpio >= gpio_chip->base - && gpio < gpio_chip->base + gpio_chip->ngpio) { - pm_gpio = gpio - gpio_chip->base; - break; - } - } - mutex_unlock(&pm_gpio_chips_lock); - if (pm_gpio < 0) { - pr_err("called on gpio %d not handled by any pmic\n", gpio); - return -EINVAL; - } - - /* Select banks and configure the gpio */ - bank[0] = PM_GPIO_WRITE | - ((param->vin_sel << PM_GPIO_VIN_SHIFT) & - PM_GPIO_VIN_MASK) | - PM_GPIO_MODE_ENABLE; - bank[1] = PM_GPIO_WRITE | - ((1 << PM_GPIO_BANK_SHIFT) & - PM_GPIO_BANK_MASK) | - ((dir_map[param->direction] << - PM_GPIO_MODE_SHIFT) & - PM_GPIO_MODE_MASK) | - ((param->direction & PM_GPIO_DIR_OUT) ? - ((param->output_buffer & 1) ? - PM_GPIO_OUT_BUFFER : 0) : 0) | - ((param->direction & PM_GPIO_DIR_OUT) ? - param->output_value & 0x01 : 0); - bank[2] = PM_GPIO_WRITE | - ((2 << PM_GPIO_BANK_SHIFT) & - PM_GPIO_BANK_MASK) | - ((param->pull << PM_GPIO_PULL_SHIFT) & - PM_GPIO_PULL_MASK); - bank[3] = PM_GPIO_WRITE | - ((3 << PM_GPIO_BANK_SHIFT) & - PM_GPIO_BANK_MASK) | - ((param->out_strength << - PM_GPIO_OUT_STRENGTH_SHIFT) & - PM_GPIO_OUT_STRENGTH_MASK) | - (param->disable_pin ? - PM_GPIO_PIN_DISABLE : PM_GPIO_PIN_ENABLE); - bank[4] = PM_GPIO_WRITE | - ((4 << PM_GPIO_BANK_SHIFT) & - PM_GPIO_BANK_MASK) | - ((param->function << PM_GPIO_FUNC_SHIFT) & - PM_GPIO_FUNC_MASK); - bank[5] = PM_GPIO_WRITE | - ((5 << PM_GPIO_BANK_SHIFT) & PM_GPIO_BANK_MASK) | - (param->inv_int_pol ? 0 : PM_GPIO_NON_INT_POL_INV); - - spin_lock_irqsave(&pm_gpio_chip->pm_lock, flags); - /* Remember bank1 for later use */ - pm_gpio_chip->bank1[pm_gpio] = bank[1]; - rc = pm8xxx_write_buf(pm_gpio_chip->gpio_chip.dev->parent, - SSBI_REG_ADDR_GPIO(pm_gpio), bank, 6); - spin_unlock_irqrestore(&pm_gpio_chip->pm_lock, flags); - - if (rc) - pr_err("Failed on pm8xxx_write_buf() rc=%d (GPIO config)\n", - rc); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_gpio_config); - -static struct platform_driver pm_gpio_driver = { - .probe = pm_gpio_probe, - .remove = pm_gpio_remove, - .driver = { - .name = PM8XXX_GPIO_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm_gpio_init(void) -{ - return platform_driver_register(&pm_gpio_driver); -} -postcore_initcall(pm_gpio_init); - -static void __exit pm_gpio_exit(void) -{ - platform_driver_unregister(&pm_gpio_driver); -} -module_exit(pm_gpio_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC GPIO driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_GPIO_DEV_NAME); diff --git a/drivers/gpio/pm8xxx-mpp.c b/drivers/gpio/pm8xxx-mpp.c deleted file mode 100644 index 37e0cf1c7c47c04b13ddf2852768befea0621304..0000000000000000000000000000000000000000 --- a/drivers/gpio/pm8xxx-mpp.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Qualcomm PM8XXX Multi-Purpose Pin (MPP) driver - * - * Copyright (c) 2011-2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* MPP Type */ -#define PM8XXX_MPP_TYPE_MASK 0xE0 -#define PM8XXX_MPP_TYPE_SHIFT 5 - -/* MPP Config Level */ -#define PM8XXX_MPP_CONFIG_LVL_MASK 0x1C -#define PM8XXX_MPP_CONFIG_LVL_SHIFT 2 - -/* MPP Config Control */ -#define PM8XXX_MPP_CONFIG_CTRL_MASK 0x03 -#define PM8XXX_MPP_CONFIG_CTRL_SHIFT 0 - -struct pm8xxx_mpp_chip { - struct list_head link; - struct gpio_chip gpio_chip; - spinlock_t pm_lock; - u8 *ctrl_reg; - int mpp_base; - int irq_base; - int nmpps; - u16 base_addr; -}; - -static LIST_HEAD(pm8xxx_mpp_chips); -static DEFINE_MUTEX(pm8xxx_mpp_chips_lock); - -static int pm8xxx_mpp_write(struct pm8xxx_mpp_chip *mpp_chip, u16 offset, - u8 val, u8 mask) -{ - u8 reg; - int rc; - unsigned long flags; - - spin_lock_irqsave(&mpp_chip->pm_lock, flags); - - reg = (mpp_chip->ctrl_reg[offset] & ~mask) | (val & mask); - rc = pm8xxx_writeb(mpp_chip->gpio_chip.dev->parent, - mpp_chip->base_addr + offset, reg); - if (!rc) - mpp_chip->ctrl_reg[offset] = reg; - - spin_unlock_irqrestore(&mpp_chip->pm_lock, flags); - - return rc; -} - -static int pm8xxx_mpp_to_irq(struct gpio_chip *chip, unsigned offset) -{ - struct pm8xxx_mpp_chip *mpp_chip = dev_get_drvdata(chip->dev); - - return mpp_chip->irq_base + offset; -} - -static int pm8xxx_mpp_get(struct gpio_chip *chip, unsigned offset) -{ - struct pm8xxx_mpp_chip *mpp_chip = dev_get_drvdata(chip->dev); - int rc; - - if ((mpp_chip->ctrl_reg[offset] & PM8XXX_MPP_TYPE_MASK) >> - PM8XXX_MPP_TYPE_SHIFT == PM8XXX_MPP_TYPE_D_OUTPUT) - rc = mpp_chip->ctrl_reg[offset] & PM8XXX_MPP_CONFIG_CTRL_MASK; - else - rc = pm8xxx_read_irq_stat(mpp_chip->gpio_chip.dev->parent, - mpp_chip->irq_base + offset); - - return rc; -} - -static void pm8xxx_mpp_set(struct gpio_chip *chip, unsigned offset, int val) -{ - struct pm8xxx_mpp_chip *mpp_chip = dev_get_drvdata(chip->dev); - u8 reg = val ? PM8XXX_MPP_DOUT_CTRL_HIGH : PM8XXX_MPP_DOUT_CTRL_LOW; - int rc; - - rc = pm8xxx_mpp_write(mpp_chip, offset, reg, - PM8XXX_MPP_CONFIG_CTRL_MASK); - if (rc) - pr_err("pm8xxx_mpp_write(): rc=%d\n", rc); -} - -static int pm8xxx_mpp_dir_input(struct gpio_chip *chip, unsigned offset) -{ - struct pm8xxx_mpp_chip *mpp_chip = dev_get_drvdata(chip->dev); - int rc = pm8xxx_mpp_write(mpp_chip, offset, - PM8XXX_MPP_TYPE_D_INPUT << PM8XXX_MPP_TYPE_SHIFT, - PM8XXX_MPP_TYPE_MASK); - - if (rc) - pr_err("pm8xxx_mpp_write(): rc=%d\n", rc); - return rc; -} - -static int pm8xxx_mpp_dir_output(struct gpio_chip *chip, - unsigned offset, int val) -{ - struct pm8xxx_mpp_chip *mpp_chip = dev_get_drvdata(chip->dev); - u8 reg = (PM8XXX_MPP_TYPE_D_OUTPUT << PM8XXX_MPP_TYPE_SHIFT) | - (val & PM8XXX_MPP_CONFIG_CTRL_MASK); - u8 mask = PM8XXX_MPP_TYPE_MASK | PM8XXX_MPP_CONFIG_CTRL_MASK; - int rc = pm8xxx_mpp_write(mpp_chip, offset, reg, mask); - - if (rc) - pr_err("pm8xxx_mpp_write(): rc=%d\n", rc); - return rc; -} - -static void pm8xxx_mpp_dbg_show(struct seq_file *s, struct gpio_chip *chip) -{ - static const char * const ctype[] = { "d_in", "d_out", "bi_dir", - "a_in", "a_out", "sink", - "dtest_sink", "dtest_out" - }; - struct pm8xxx_mpp_chip *mpp_chip = dev_get_drvdata(chip->dev); - u8 type, state; - const char *label; - int i; - - for (i = 0; i < mpp_chip->nmpps; i++) { - label = gpiochip_is_requested(chip, i); - type = (mpp_chip->ctrl_reg[i] & PM8XXX_MPP_TYPE_MASK) >> - PM8XXX_MPP_TYPE_SHIFT; - state = pm8xxx_mpp_get(chip, i); - seq_printf(s, "gpio-%-3d (%-12.12s) %-10.10s" - " %s 0x%02x\n", - chip->base + i, - label ? label : "--", - ctype[type], - state ? "hi" : "lo", - mpp_chip->ctrl_reg[i]); - } -} - -int pm8xxx_mpp_config(unsigned mpp, struct pm8xxx_mpp_config_data *config) -{ - struct pm8xxx_mpp_chip *mpp_chip; - int rc, found = 0; - u8 config_reg, mask; - - if (!config) { - pr_err("config not specified for MPP %d\n", mpp); - return -EINVAL; - } - - mutex_lock(&pm8xxx_mpp_chips_lock); - list_for_each_entry(mpp_chip, &pm8xxx_mpp_chips, link) { - if (mpp >= mpp_chip->mpp_base - && mpp < mpp_chip->mpp_base + mpp_chip->nmpps) { - found = 1; - break; - } - } - mutex_unlock(&pm8xxx_mpp_chips_lock); - if (!found) { - pr_err("called on mpp %d not handled by any pmic\n", mpp); - return -EINVAL; - } - - mask = PM8XXX_MPP_TYPE_MASK | PM8XXX_MPP_CONFIG_LVL_MASK | - PM8XXX_MPP_CONFIG_CTRL_MASK; - config_reg = (config->type << PM8XXX_MPP_TYPE_SHIFT) - & PM8XXX_MPP_TYPE_MASK; - config_reg |= (config->level << PM8XXX_MPP_CONFIG_LVL_SHIFT) - & PM8XXX_MPP_CONFIG_LVL_MASK; - config_reg |= config->control & PM8XXX_MPP_CONFIG_CTRL_MASK; - - rc = pm8xxx_mpp_write(mpp_chip, mpp - mpp_chip->mpp_base, config_reg, - mask); - - if (rc) - pr_err("pm8xxx_mpp_write(): rc=%d\n", rc); - - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_mpp_config); - -static int pm8xxx_mpp_reg_init(struct pm8xxx_mpp_chip *mpp_chip) -{ - int rc, i; - - for (i = 0; i < mpp_chip->nmpps; i++) { - rc = pm8xxx_readb(mpp_chip->gpio_chip.dev->parent, - mpp_chip->base_addr + i, - &mpp_chip->ctrl_reg[i]); - if (rc) { - pr_err("failed to read register 0x%x rc=%d\n", - mpp_chip->base_addr + i, rc); - return rc; - } - } - return 0; -} - -static int pm8xxx_mpp_probe(struct platform_device *pdev) -{ - int rc; - const struct pm8xxx_mpp_platform_data *pdata = pdev->dev.platform_data; - struct pm8xxx_mpp_chip *mpp_chip; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - mpp_chip = kzalloc(sizeof(struct pm8xxx_mpp_chip), GFP_KERNEL); - if (!mpp_chip) { - pr_err("Cannot allocate %d bytes\n", - sizeof(struct pm8xxx_mpp_chip)); - return -ENOMEM; - } - - mpp_chip->ctrl_reg = kzalloc(pdata->core_data.nmpps, GFP_KERNEL); - if (!mpp_chip->ctrl_reg) { - pr_err("Cannot allocate %d bytes\n", pdata->core_data.nmpps); - rc = -ENOMEM; - goto free_mpp_chip; - } - - spin_lock_init(&mpp_chip->pm_lock); - - mpp_chip->gpio_chip.label = PM8XXX_MPP_DEV_NAME; - mpp_chip->gpio_chip.direction_input = pm8xxx_mpp_dir_input; - mpp_chip->gpio_chip.direction_output = pm8xxx_mpp_dir_output; - mpp_chip->gpio_chip.to_irq = pm8xxx_mpp_to_irq; - mpp_chip->gpio_chip.get = pm8xxx_mpp_get; - mpp_chip->gpio_chip.set = pm8xxx_mpp_set; - mpp_chip->gpio_chip.dbg_show = pm8xxx_mpp_dbg_show; - mpp_chip->gpio_chip.ngpio = pdata->core_data.nmpps; - mpp_chip->gpio_chip.can_sleep = 0; - mpp_chip->gpio_chip.dev = &pdev->dev; - mpp_chip->gpio_chip.base = pdata->mpp_base; - mpp_chip->irq_base = platform_get_irq(pdev, 0); - mpp_chip->mpp_base = pdata->mpp_base; - mpp_chip->base_addr = pdata->core_data.base_addr; - mpp_chip->nmpps = pdata->core_data.nmpps; - - mutex_lock(&pm8xxx_mpp_chips_lock); - list_add(&mpp_chip->link, &pm8xxx_mpp_chips); - mutex_unlock(&pm8xxx_mpp_chips_lock); - - platform_set_drvdata(pdev, mpp_chip); - - rc = gpiochip_add(&mpp_chip->gpio_chip); - if (rc) { - pr_err("gpiochip_add failed, rc=%d\n", rc); - goto reset_drvdata; - } - - rc = pm8xxx_mpp_reg_init(mpp_chip); - if (rc) { - pr_err("failed to read MPP ctrl registers, rc=%d\n", rc); - goto remove_chip; - } - - pr_info("OK: base=%d, ngpio=%d\n", mpp_chip->gpio_chip.base, - mpp_chip->gpio_chip.ngpio); - - return 0; - -remove_chip: - if (gpiochip_remove(&mpp_chip->gpio_chip)) - pr_err("failed to remove gpio chip\n"); -reset_drvdata: - platform_set_drvdata(pdev, NULL); -free_mpp_chip: - kfree(mpp_chip); - return rc; -} - -static int pm8xxx_mpp_remove(struct platform_device *pdev) -{ - struct pm8xxx_mpp_chip *mpp_chip = platform_get_drvdata(pdev); - - mutex_lock(&pm8xxx_mpp_chips_lock); - list_del(&mpp_chip->link); - mutex_unlock(&pm8xxx_mpp_chips_lock); - platform_set_drvdata(pdev, NULL); - if (gpiochip_remove(&mpp_chip->gpio_chip)) - pr_err("failed to remove gpio chip\n"); - kfree(mpp_chip->ctrl_reg); - kfree(mpp_chip); - - return 0; -} - -static struct platform_driver pm8xxx_mpp_driver = { - .probe = pm8xxx_mpp_probe, - .remove = pm8xxx_mpp_remove, - .driver = { - .name = PM8XXX_MPP_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_mpp_init(void) -{ - return platform_driver_register(&pm8xxx_mpp_driver); -} -postcore_initcall(pm8xxx_mpp_init); - -static void __exit pm8xxx_mpp_exit(void) -{ - platform_driver_unregister(&pm8xxx_mpp_driver); -} -module_exit(pm8xxx_mpp_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PM8XXX MPP driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_MPP_DEV_NAME); diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h index 6cf8479fff1ec88314f6ead21fe195e38c65a3d9..a52619b51c258d3f2011be1265f8117775750e0f 100644 --- a/drivers/gpu/msm/adreno.h +++ b/drivers/gpu/msm/adreno.h @@ -58,8 +58,6 @@ #ifdef CONFIG_MSM_SCM #define ADRENO_DEFAULT_PWRSCALE_POLICY (&kgsl_pwrscale_policy_tz) -#elif defined CONFIG_MSM_SLEEP_STATS_DEVICE -#define ADRENO_DEFAULT_PWRSCALE_POLICY (&kgsl_pwrscale_policy_idlestats) #else #define ADRENO_DEFAULT_PWRSCALE_POLICY NULL #endif diff --git a/drivers/gud/mobicore_driver/platforms/msm8960_surf_std/platform.h b/drivers/gud/mobicore_driver/platforms/msm8960_surf_std/platform.h index 7854fc5083010965f8122b8668ff63b1515d069b..0085e8c6857f4685f2e7d357cf932ef7513ad1ae 100644 --- a/drivers/gud/mobicore_driver/platforms/msm8960_surf_std/platform.h +++ b/drivers/gud/mobicore_driver/platforms/msm8960_surf_std/platform.h @@ -41,9 +41,7 @@ static inline int smc_fastcall(void *fc_generic, size_t size) /* Enable the use of vm_unamp instead of the deprecated do_munmap * and other 3.7 features */ -#ifndef CONFIG_ARCH_MSM8960 #define MC_VM_UNMAP -#endif #if defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8226) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 5cf950caa7ef0eeb8d49b44ac9d7909f7a449741..402aba319631e70b1a65ac346aa2c7865636b4c0 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -956,28 +956,6 @@ config SENSORS_NTC_THERMISTOR This driver can also be built as a module. If so, the module will be called ntc-thermistor. -config SENSORS_MSM_ADC - tristate "MSM ADC Driver for current measurement" - depends on ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_FSM9XXX || ARCH_MSM7X27A - default n - help - Provides interface for measuring the ADC's on AMUX channels of XOADC, - MPP's and the XOTHERM on pmic8058 for msm8x60 and provides post processing - of the channel for the ADC Raw Data. For reading LTC and EPM ADC channels - say yes here to include support for measuring current in real-time - from various power-rails on the Fluid board. The ADC circuit - internally uses an array of LTC2499 and EPM ADCs in a differential - configuration to provide a flat set of channels that can be addressed. - -config SENSORS_PM8XXX_ADC - tristate "Support for Qualcomm PM8XXX ADC" - depends on MFD_PM8XXX - help - This is the ADC arbiter driver for Qualcomm PM8XXX Chip. - - The driver supports reading the HKADC, XOADC and support to set and receive - temperature threshold notifications using the Battery temperature module. - config SENSORS_EPM_ADC tristate "EPM ADC Driver for power measurement" depends on I2C && SPI_MASTER diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 3c8e1141b077357e94afa340d2ce36c465a8123a..397e1b9e18f6a821c6f9f6aec521f0a182099b69 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -140,9 +140,6 @@ obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o -obj-$(CONFIG_SENSORS_WPCE775X) += wpce775x.o -obj-$(CONFIG_SENSORS_MSM_ADC) += msm_adc.o m_adcproc.o -obj-$(CONFIG_SENSORS_PM8XXX_ADC) += pm8xxx-adc.o pm8xxx-adc-scale.o obj-$(CONFIG_SENSORS_EPM_ADC) += epm_adc.o obj-$(CONFIG_SENSORS_QPNP_ADC_VOLTAGE) += qpnp-adc-voltage.o qpnp-adc-common.o obj-$(CONFIG_SENSORS_QPNP_ADC_CURRENT) += qpnp-adc-current.o qpnp-adc-common.o diff --git a/drivers/hwmon/m_adcproc.c b/drivers/hwmon/m_adcproc.c deleted file mode 100644 index fe12492499efbc39ae2f3fb0917a2ee24eb8c18d..0000000000000000000000000000000000000000 --- a/drivers/hwmon/m_adcproc.c +++ /dev/null @@ -1,469 +0,0 @@ -/* Copyright (c) 2010-2011, 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 - -#include - -#define KELVINMIL_DEGMIL 273160 - -static const struct adc_map_pt adcmap_batttherm[] = { - {2020, -30}, - {1923, -20}, - {1796, -10}, - {1640, 0}, - {1459, 10}, - {1260, 20}, - {1159, 25}, - {1059, 30}, - {871, 40}, - {706, 50}, - {567, 60}, - {453, 70}, - {364, 80} -}; - -static const struct adc_map_pt adcmap_msmtherm[] = { - {2150, -30}, - {2107, -20}, - {2037, -10}, - {1929, 0}, - {1776, 10}, - {1579, 20}, - {1467, 25}, - {1349, 30}, - {1108, 40}, - {878, 50}, - {677, 60}, - {513, 70}, - {385, 80}, - {287, 90}, - {215, 100}, - {186, 110}, - {107, 120} -}; - -static const struct adc_map_pt adcmap_ntcg104ef104fb[] = { - {696483, -40960}, - {649148, -39936}, - {605368, -38912}, - {564809, -37888}, - {527215, -36864}, - {492322, -35840}, - {460007, -34816}, - {429982, -33792}, - {402099, -32768}, - {376192, -31744}, - {352075, -30720}, - {329714, -29696}, - {308876, -28672}, - {289480, -27648}, - {271417, -26624}, - {254574, -25600}, - {238903, -24576}, - {224276, -23552}, - {210631, -22528}, - {197896, -21504}, - {186007, -20480}, - {174899, -19456}, - {164521, -18432}, - {154818, -17408}, - {145744, -16384}, - {137265, -15360}, - {129307, -14336}, - {121866, -13312}, - {114896, -12288}, - {108365, -11264}, - {102252, -10240}, - {96499, -9216}, - {91111, -8192}, - {86055, -7168}, - {81308, -6144}, - {76857, -5120}, - {72660, -4096}, - {68722, -3072}, - {65020, -2048}, - {61538, -1024}, - {58261, 0}, - {55177, 1024}, - {52274, 2048}, - {49538, 3072}, - {46962, 4096}, - {44531, 5120}, - {42243, 6144}, - {40083, 7168}, - {38045, 8192}, - {36122, 9216}, - {34308, 10240}, - {32592, 11264}, - {30972, 12288}, - {29442, 13312}, - {27995, 14336}, - {26624, 15360}, - {25333, 16384}, - {24109, 17408}, - {22951, 18432}, - {21854, 19456}, - {20807, 20480}, - {19831, 21504}, - {18899, 22528}, - {18016, 23552}, - {17178, 24576}, - {16384, 25600}, - {15631, 26624}, - {14916, 27648}, - {14237, 28672}, - {13593, 29696}, - {12976, 30720}, - {12400, 31744}, - {11848, 32768}, - {11324, 33792}, - {10825, 34816}, - {10354, 35840}, - {9900, 36864}, - {9471, 37888}, - {9062, 38912}, - {8674, 39936}, - {8306, 40960}, - {7951, 41984}, - {7616, 43008}, - {7296, 44032}, - {6991, 45056}, - {6701, 46080}, - {6424, 47104}, - {6160, 48128}, - {5908, 49152}, - {5667, 50176}, - {5439, 51200}, - {5219, 52224}, - {5010, 53248}, - {4810, 54272}, - {4619, 55296}, - {4440, 56320}, - {4263, 57344}, - {4097, 58368}, - {3938, 59392}, - {3785, 60416}, - {3637, 61440}, - {3501, 62464}, - {3368, 63488}, - {3240, 64512}, - {3118, 65536}, - {2998, 66560}, - {2889, 67584}, - {2782, 68608}, - {2680, 69632}, - {2581, 70656}, - {2490, 71680}, - {2397, 72704}, - {2310, 73728}, - {2227, 74752}, - {2147, 75776}, - {2064, 76800}, - {1998, 77824}, - {1927, 78848}, - {1860, 79872}, - {1795, 80896}, - {1736, 81920}, - {1673, 82944}, - {1615, 83968}, - {1560, 84992}, - {1507, 86016}, - {1456, 87040}, - {1407, 88064}, - {1360, 89088}, - {1314, 90112}, - {1271, 91136}, - {1228, 92160}, - {1189, 93184}, - {1150, 94208}, - {1112, 95232}, - {1076, 96256}, - {1042, 97280}, - {1008, 98304}, - {976, 99328}, - {945, 100352}, - {915, 101376}, - {886, 102400}, - {859, 103424}, - {832, 104448}, - {807, 105472}, - {782, 106496}, - {756, 107520}, - {735, 108544}, - {712, 109568}, - {691, 110592}, - {670, 111616}, - {650, 112640}, - {631, 113664}, - {612, 114688}, - {594, 115712}, - {577, 116736}, - {560, 117760}, - {544, 118784}, - {528, 119808}, - {513, 120832}, - {498, 121856}, - {483, 122880}, - {470, 123904}, - {457, 124928}, - {444, 125952}, - {431, 126976}, - {419, 128000} -}; - -static int32_t - adc_map_linear(const struct adc_map_pt *pts, - uint32_t tablesize, int32_t input, int64_t *output) -{ - bool descending = 1; - uint32_t i = 0; - - if ((pts == NULL) || (output == NULL)) - return -EINVAL; - - /* Check if table is descending or ascending */ - if (tablesize > 1) { - if (pts[0].x < pts[1].x) - descending = 0; - } - - while (i < tablesize) { - if ((descending == 1) && (pts[i].x < input)) { - /* table entry is less than measured - value and table is descending, stop */ - break; - } else if ((descending == 0) && - (pts[i].x > input)) { - /* table entry is greater than measured - value and table is ascending, stop */ - break; - } else - i++; - } - - if (i == 0) - *output = pts[0].y; - else if (i == tablesize) - *output = pts[tablesize-1].y; - else { - /* result is between search_index and search_index-1 */ - /* interpolate linearly */ - *output = (((int32_t) ((pts[i].y - pts[i-1].y)* - (input - pts[i-1].x))/ - (pts[i].x - pts[i-1].x))+ - pts[i-1].y); - } - - return 0; -} - -int32_t scale_default(int32_t adc_code, - const struct adc_properties *adc_properties, - const struct chan_properties *chan_properties, - struct adc_chan_result *adc_chan_result) -{ - bool negative_rawfromoffset = 0; - int32_t rawfromoffset = adc_code - chan_properties->adc_graph->offset; - - if (!chan_properties->gain_numerator || - !chan_properties->gain_denominator) - return -EINVAL; - - adc_chan_result->adc_code = adc_code; - if (rawfromoffset < 0) { - if (adc_properties->bipolar) { - rawfromoffset = (rawfromoffset ^ -1) + 1; - negative_rawfromoffset = 1; - } else - rawfromoffset = 0; - } - - if (rawfromoffset >= 1 << adc_properties->bitresolution) - rawfromoffset = (1 << adc_properties->bitresolution) - 1; - - adc_chan_result->measurement = (int64_t)rawfromoffset* - chan_properties->adc_graph->dx* - chan_properties->gain_denominator; - - /* do_div only perform positive integer division! */ - do_div(adc_chan_result->measurement, chan_properties->adc_graph->dy* - chan_properties->gain_numerator); - - if (negative_rawfromoffset) - adc_chan_result->measurement = - (adc_chan_result->measurement ^ -1) + 1; - - /* Note: adc_chan_result->measurement is in the unit of - * adc_properties.adc_reference. For generic channel processing, - * channel measurement is a scale/ratio relative to the adc - * reference input */ - adc_chan_result->physical = (int32_t) adc_chan_result->measurement; - - return 0; -} - -int32_t scale_batt_therm(int32_t adc_code, - const struct adc_properties *adc_properties, - const struct chan_properties *chan_properties, - struct adc_chan_result *adc_chan_result) -{ - scale_default(adc_code, adc_properties, chan_properties, - adc_chan_result); - /* convert mV ---> degC using the table */ - return adc_map_linear( - adcmap_batttherm, - sizeof(adcmap_batttherm)/sizeof(adcmap_batttherm[0]), - adc_chan_result->physical, - &adc_chan_result->physical); -} - -int32_t scale_msm_therm(int32_t adc_code, - const struct adc_properties *adc_properties, - const struct chan_properties *chan_properties, - struct adc_chan_result *adc_chan_result) -{ - scale_default(adc_code, adc_properties, chan_properties, - adc_chan_result); - /* convert mV ---> degC using the table */ - return adc_map_linear( - adcmap_msmtherm, - sizeof(adcmap_msmtherm)/sizeof(adcmap_msmtherm[0]), - adc_chan_result->physical, - &adc_chan_result->physical); -} - -int32_t scale_pmic_therm(int32_t adc_code, - const struct adc_properties *adc_properties, - const struct chan_properties *chan_properties, - struct adc_chan_result *adc_chan_result) -{ - /* 2mV/K */ - int32_t rawfromoffset = adc_code - chan_properties->adc_graph->offset; - - if (!chan_properties->gain_numerator || - !chan_properties->gain_denominator) - return -EINVAL; - - adc_chan_result->adc_code = adc_code; - if (rawfromoffset > 0) { - if (rawfromoffset >= 1 << adc_properties->bitresolution) - rawfromoffset = (1 << adc_properties->bitresolution) - - 1; - adc_chan_result->measurement = (int64_t)rawfromoffset* - chan_properties->adc_graph->dx* - chan_properties->gain_denominator*1000; - do_div(adc_chan_result->measurement, - chan_properties->adc_graph->dy* - chan_properties->gain_numerator*2); - } else { - adc_chan_result->measurement = 0; - } - /* Note: adc_chan_result->measurement is in the unit of - adc_properties.adc_reference */ - adc_chan_result->physical = (int32_t)adc_chan_result->measurement; - /* Change to .001 deg C */ - adc_chan_result->physical -= KELVINMIL_DEGMIL; - adc_chan_result->measurement <<= 1; - - return 0; -} - -/* Scales the ADC code to 0.001 degrees C using the map - * table for the XO thermistor. - */ -int32_t tdkntcgtherm(int32_t adc_code, - const struct adc_properties *adc_properties, - const struct chan_properties *chan_properties, - struct adc_chan_result *adc_chan_result) -{ - int32_t offset = chan_properties->adc_graph->offset, - dy = chan_properties->adc_graph->dy, - dx = chan_properties->adc_graph->dx, - fullscale_calibrated_adc_code; - - uint32_t rt_r25; - uint32_t num1, num2, denom; - - adc_chan_result->adc_code = adc_code; - fullscale_calibrated_adc_code = dy + offset; - /* The above is a short cut in math that would reduce a lot of - computation whereas the below expression - (adc_properties->adc_reference*dy+dx*offset+(dx>>1))/dx - is a more generic formula when the 2 reference voltages are - different than 0 and full scale voltage. */ - - if ((dy == 0) || (dx == 0) || - (offset >= fullscale_calibrated_adc_code)) { - return -EINVAL; - } else { - if (adc_code >= fullscale_calibrated_adc_code) { - rt_r25 = (uint32_t)-1; - } else if (adc_code <= offset) { - rt_r25 = 0; - } else { - /* The formula used is (adc_code of current reading - offset)/ - * (the calibrated fullscale adc code - adc_code of current reading). - * For this channel, at this time, chan_properties->gain_numerator = - * chan_properties->gain_denominator = 1, so no need to incorporate - * into the formula even though we could and multiply/divide by 1 - * which yields the same result but expensive on computation. */ - num1 = (adc_code - offset) << 14; - num2 = (fullscale_calibrated_adc_code - adc_code) >> 1; - denom = fullscale_calibrated_adc_code - adc_code; - - if ((int)denom <= 0) - rt_r25 = 0x7FFFFFFF; - else - rt_r25 = (num1 + num2) / denom; - } - - if (rt_r25 > 0x7FFFFFFF) - rt_r25 = 0x7FFFFFFF; - - adc_map_linear(adcmap_ntcg104ef104fb, - sizeof(adcmap_ntcg104ef104fb)/sizeof(adcmap_ntcg104ef104fb[0]), - (int32_t)rt_r25, &adc_chan_result->physical); - } - - return 0; -} - -int32_t scale_xtern_chgr_cur(int32_t adc_code, - const struct adc_properties *adc_properties, - const struct chan_properties *chan_properties, - struct adc_chan_result *adc_chan_result) -{ - int32_t rawfromoffset = adc_code - chan_properties->adc_graph->offset; - - if (!chan_properties->gain_numerator || - !chan_properties->gain_denominator) - return -EINVAL; - - adc_chan_result->adc_code = adc_code; - if (rawfromoffset > 0) { - if (rawfromoffset >= 1 << adc_properties->bitresolution) - rawfromoffset = (1 << adc_properties->bitresolution) - - 1; - adc_chan_result->measurement = ((int64_t)rawfromoffset * 5)* - chan_properties->adc_graph->dx* - chan_properties->gain_denominator; - do_div(adc_chan_result->measurement, - chan_properties->adc_graph->dy* - chan_properties->gain_numerator); - } else { - adc_chan_result->measurement = 0; - } - adc_chan_result->physical = (int32_t) adc_chan_result->measurement; - - return 0; -} diff --git a/drivers/hwmon/msm_adc.c b/drivers/hwmon/msm_adc.c deleted file mode 100644 index 54690e56354ff230674b2cd1c9f975fa95b16707..0000000000000000000000000000000000000000 --- a/drivers/hwmon/msm_adc.c +++ /dev/null @@ -1,1533 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define MSM_ADC_DRIVER_NAME "msm_adc" -#define MSM_ADC_MAX_FNAME 15 - -#define MSM_ADC_DALRPC_DEVICEID 0x02000067 -#define MSM_ADC_DALRPC_PORT_NAME "DAL00" -#define MSM_ADC_DALRPC_CPU SMD_APPS_MODEM - -#define MSM_ADC_DALRPC_CMD_REQ_CONV 9 -#define MSM_ADC_DALRPC_CMD_INPUT_PROP 11 - -#define MSM_ADC_DALRC_CONV_TIMEOUT (5 * HZ) /* 5 seconds */ - -#define MSM_8x25_ADC_DEV_ID 0 -#define MSM_8x25_CHAN_ID 16 - -enum dal_error { - DAL_ERROR_INVALID_DEVICE_IDX = 1, - DAL_ERROR_INVALID_CHANNEL_IDX, - DAL_ERROR_NULL_POINTER, - DAL_ERROR_DEVICE_QUEUE_FULL, - DAL_ERROR_INVALID_PROPERTY_LENGTH, - DAL_ERROR_REMOTE_EVENT_POOL_FULL -}; - -enum dal_result_status { - DAL_RESULT_STATUS_INVALID, - DAL_RESULT_STATUS_VALID -}; - -struct dal_conv_state { - struct dal_conv_slot context[MSM_ADC_DEV_MAX_INFLIGHT]; - struct list_head slots; - struct mutex list_lock; - struct semaphore slot_count; -}; - -struct adc_dev { - char *name; - uint32_t nchans; - struct dal_conv_state conv; - struct dal_translation transl; - struct sensor_device_attribute *sens_attr; - char **fnames; -}; - -struct msm_adc_drv { - /* Common to both XOADC and EPM */ - struct platform_device *pdev; - struct device *hwmon; - struct miscdevice misc; - /* XOADC variables */ - struct sensor_device_attribute *sens_attr; - struct workqueue_struct *wq; - atomic_t online; - atomic_t total_outst; - wait_queue_head_t total_outst_wait; - - /* EPM variables */ - void *dev_h; - struct adc_dev *devs[MSM_ADC_MAX_NUM_DEVS]; - struct mutex prop_lock; - atomic_t rpc_online; - atomic_t rpc_total_outst; - wait_queue_head_t rpc_total_outst_wait; -}; - -static bool epm_init; -static bool epm_fluid_enabled; - -/* Needed to support file_op interfaces */ -static struct msm_adc_drv *msm_adc_drv; - -static bool conv_first_request; - -static ssize_t msm_adc_show_curr(struct device *dev, - struct device_attribute *devattr, char *buf); - -static int msm_rpc_adc_blocking_conversion(struct msm_adc_drv *msm_adc, - uint32_t chan, struct adc_chan_result *result); - -static int msm_adc_blocking_conversion(struct msm_adc_drv *msm_adc, - uint32_t chan, struct adc_chan_result *result); - -static int msm_adc_open(struct inode *inode, struct file *file) -{ - struct msm_client_data *client; - struct msm_adc_drv *msm_adc = msm_adc_drv; - struct platform_device *pdev = msm_adc->pdev; - - client = kzalloc(sizeof(struct msm_client_data), GFP_KERNEL); - if (!client) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - if (!try_module_get(THIS_MODULE)) { - kfree(client); - return -EACCES; - } - - mutex_init(&client->lock); - INIT_LIST_HEAD(&client->complete_list); - init_waitqueue_head(&client->data_wait); - init_waitqueue_head(&client->outst_wait); - - client->online = 1; - - file->private_data = client; - - return nonseekable_open(inode, file); -} - -static inline void msm_adc_restore_slot(struct dal_conv_state *conv_s, - struct dal_conv_slot *slot) -{ - mutex_lock(&conv_s->list_lock); - list_add(&slot->list, &conv_s->slots); - mutex_unlock(&conv_s->list_lock); - - up(&conv_s->slot_count); -} - -static int no_pending_client_requests(struct msm_client_data *client) -{ - mutex_lock(&client->lock); - - if (client->num_outstanding == 0) { - mutex_unlock(&client->lock); - return 1; - } - - mutex_unlock(&client->lock); - - return 0; -} - -static int data_avail(struct msm_client_data *client, uint32_t *pending) -{ - uint32_t completed; - - mutex_lock(&client->lock); - completed = client->num_complete; - mutex_unlock(&client->lock); - - if (completed > 0) { - if (pending != NULL) - *pending = completed; - return 1; - } - - return 0; -} - -static int msm_adc_release(struct inode *inode, struct file *file) -{ - struct msm_client_data *client = file->private_data; - struct adc_conv_slot *slot, *tmp; - int rc; - struct msm_adc_platform_data *pdata = - msm_adc_drv->pdev->dev.platform_data; - struct msm_adc_channels *channel = pdata->channel; - - module_put(THIS_MODULE); - - mutex_lock(&client->lock); - - /* prevent any further requests while we teardown the client */ - client->online = 0; - - mutex_unlock(&client->lock); - - /* - * We may still have outstanding transactions in flight from this - * client that have not completed. Make sure they're completed - * before removing the client. - */ - rc = wait_event_interruptible(client->outst_wait, - no_pending_client_requests(client)); - if (rc) { - pr_err("%s: wait_event_interruptible failed rc = %d\n", - __func__, rc); - return rc; - } - - /* - * All transactions have completed. Add slot resources back to the - * appropriate devices. - */ - list_for_each_entry_safe(slot, tmp, &client->complete_list, list) { - slot->client = NULL; - list_del(&slot->list); - channel[slot->conv.result.chan].adc_access_fn->adc_restore_slot( - channel[slot->conv.result.chan].adc_dev_instance, slot); - } - - kfree(client); - - return 0; -} - -static int msm_adc_translate_dal_to_hwmon(struct msm_adc_drv *msm_adc, - uint32_t chan, - struct adc_dev_spec *dest) -{ - struct dal_translation *transl; - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - int i; - - for (i = 0; i < pdata->num_adc; i++) { - transl = &msm_adc->devs[i]->transl; - if (chan >= transl->hwmon_start && - chan <= transl->hwmon_end) { - dest->dal.dev_idx = transl->dal_dev_idx; - dest->hwmon_dev_idx = transl->hwmon_dev_idx; - dest->dal.chan_idx = chan - transl->hwmon_start; - return 0; - } - } - return -EINVAL; -} - -static int msm_adc_translate_hwmon_to_dal(struct msm_adc_drv *msm_adc, - struct adc_dev_spec *source, - uint32_t *chan) -{ - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - struct dal_translation *transl; - int i; - - for (i = 0; i < pdata->num_adc; i++) { - transl = &msm_adc->devs[i]->transl; - if (source->dal.dev_idx != transl->dal_dev_idx) - continue; - *chan = transl->hwmon_start + source->dal.chan_idx; - return 0; - } - return -EINVAL; -} - -static int msm_adc_getinputproperties(struct msm_adc_drv *msm_adc, - const char *lookup_name, - struct adc_dev_spec *result) -{ - struct device *dev = &msm_adc->pdev->dev; - int rc; - - mutex_lock(&msm_adc->prop_lock); - - rc = dalrpc_fcn_8(MSM_ADC_DALRPC_CMD_INPUT_PROP, msm_adc->dev_h, - lookup_name, strlen(lookup_name) + 1, - &result->dal, sizeof(struct dal_dev_spec)); - if (rc) { - dev_err(dev, "DAL getprop request failed: rc = %d\n", rc); - mutex_unlock(&msm_adc->prop_lock); - return -EIO; - } - - mutex_unlock(&msm_adc->prop_lock); - return rc; -} - -static int msm_adc_lookup(struct msm_adc_drv *msm_adc, - struct msm_adc_lookup *lookup) -{ - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - struct adc_dev_spec target; - int rc = 0, i = 0; - uint32_t len = 0; - - len = strnlen(lookup->name, MSM_ADC_MAX_CHAN_STR); - while (i < pdata->num_chan_supported) { - if (strncmp(lookup->name, pdata->channel[i].name, len)) - i++; - else - break; - } - - if (pdata->num_chan_supported > 0 && i < pdata->num_chan_supported) { - lookup->chan_idx = i; - } else if (msm_adc->dev_h) { - rc = msm_adc_getinputproperties(msm_adc, lookup->name, &target); - if (rc) { - pr_err("%s: Lookup failed for %s\n", __func__, - lookup->name); - return rc; - } - rc = msm_adc_translate_hwmon_to_dal(msm_adc, &target, - &lookup->chan_idx); - if (rc) - pr_err("%s: Translation failed for %s\n", __func__, - lookup->name); - } else { - pr_err("%s: Lookup failed for %s\n", __func__, lookup->name); - rc = -EINVAL; - } - return rc; -} - -static int msm_adc_aio_conversion(struct msm_adc_drv *msm_adc, - struct adc_chan_result *request, - struct msm_client_data *client) -{ - struct msm_adc_platform_data *pdata = - msm_adc_drv->pdev->dev.platform_data; - struct msm_adc_channels *channel = &pdata->channel[request->chan]; - struct adc_conv_slot *slot; - - /* we could block here, but only for a bounded time */ - channel->adc_access_fn->adc_slot_request(channel->adc_dev_instance, - &slot); - - if (slot) { - atomic_inc(&msm_adc->total_outst); - mutex_lock(&client->lock); - client->num_outstanding++; - mutex_unlock(&client->lock); - - /* indicates non blocking request to callback handler */ - slot->blocking = 0; - slot->compk = NULL;/*For kernel space usage; n/a for usr space*/ - slot->conv.result.chan = client->adc_chan = request->chan; - slot->client = client; - slot->adc_request = START_OF_CONV; - slot->chan_path = channel->chan_path_type; - slot->chan_adc_config = channel->adc_config_type; - slot->chan_adc_calib = channel->adc_calib_type; - queue_work(msm_adc->wq, &slot->work); - return 0; - } - return -EBUSY; -} - -static int msm_adc_fluid_hw_deinit(struct msm_adc_drv *msm_adc) -{ - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - - if (!epm_init) - return -EINVAL; - - if (pdata->gpio_config == APROC_CONFIG && - epm_fluid_enabled && pdata->adc_fluid_disable != NULL) { - pdata->adc_fluid_disable(); - epm_fluid_enabled = false; - } - - return 0; -} - -static int msm_adc_fluid_hw_init(struct msm_adc_drv *msm_adc) -{ - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - - if (!epm_init) - return -EINVAL; - - if (!pdata->adc_fluid_enable) - return -ENODEV; - - printk(KERN_DEBUG "msm_adc_fluid_hw_init: Calling adc_fluid_enable.\n"); - - if (pdata->gpio_config == APROC_CONFIG && !epm_fluid_enabled) { - pdata->adc_fluid_enable(); - epm_fluid_enabled = true; - } - - /* return success for now but check for errors from hw init configuration */ - return 0; -} - -static int msm_adc_poll_complete(struct msm_adc_drv *msm_adc, - struct msm_client_data *client, uint32_t *pending) -{ - int rc; - - /* - * Don't proceed if there there's nothing queued on this client. - * We could deadlock otherwise in a single threaded scenario. - */ - if (no_pending_client_requests(client) && !data_avail(client, pending)) - return -EDEADLK; - - rc = wait_event_interruptible(client->data_wait, - data_avail(client, pending)); - if (rc) - return rc; - - return 0; -} - -static int msm_adc_read_result(struct msm_adc_drv *msm_adc, - struct msm_client_data *client, - struct adc_chan_result *result) -{ - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - struct msm_adc_channels *channel = pdata->channel; - struct adc_conv_slot *slot; - int rc = 0; - - mutex_lock(&client->lock); - - slot = list_first_entry(&client->complete_list, - struct adc_conv_slot, list); - if (!slot) { - mutex_unlock(&client->lock); - return -ENOMSG; - } - - slot->client = NULL; - list_del(&slot->list); - - client->num_complete--; - - mutex_unlock(&client->lock); - - *result = slot->conv.result; - - /* restore this slot to reserve */ - channel[slot->conv.result.chan].adc_access_fn->adc_restore_slot( - channel[slot->conv.result.chan].adc_dev_instance, slot); - - return rc; -} - -static long msm_adc_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct msm_client_data *client = file->private_data; - struct msm_adc_drv *msm_adc = msm_adc_drv; - struct platform_device *pdev = msm_adc->pdev; - struct msm_adc_platform_data *pdata = pdev->dev.platform_data; - uint32_t block_res = 0; - - int rc; - - switch (cmd) { - case MSM_ADC_REQUEST: - { - struct adc_chan_result conv; - - if (copy_from_user(&conv, (void __user *)arg, - sizeof(struct adc_chan_result))) - return -EFAULT; - - if (conv.chan < pdata->num_chan_supported) { - rc = msm_adc_blocking_conversion(msm_adc, - conv.chan, &conv); - } else { - if (!msm_adc->dev_h) - return -EAGAIN; - - rc = msm_rpc_adc_blocking_conversion(msm_adc, - conv.chan, &conv); - } - if (rc) { - dev_dbg(&pdev->dev, "BLK conversion failed\n"); - return rc; - } - - if (copy_to_user((void __user *)arg, &conv, - sizeof(struct adc_chan_result))) - return -EFAULT; - break; - } - case MSM_ADC_AIO_REQUEST_BLOCK_RES: - block_res = 1; - case MSM_ADC_AIO_REQUEST: - { - struct adc_chan_result conv; - - if (copy_from_user(&conv, (void __user *)arg, - sizeof(struct adc_chan_result))) - return -EFAULT; - - if (conv.chan >= pdata->num_chan_supported) - return -EINVAL; - - rc = msm_adc_aio_conversion(msm_adc, &conv, client); - if (rc) { - dev_dbg(&pdev->dev, "AIO conversion failed\n"); - return rc; - } - if (copy_to_user((void __user *)arg, &conv, - sizeof(struct adc_chan_result))) - return -EFAULT; - break; - } - case MSM_ADC_AIO_POLL: - { - uint32_t completed; - - rc = msm_adc_poll_complete(msm_adc, client, &completed); - if (rc) { - dev_dbg(&pdev->dev, "poll request failed\n"); - return rc; - } - - if (copy_to_user((void __user *)arg, &completed, - sizeof(uint32_t))) - return -EFAULT; - - break; - } - case MSM_ADC_AIO_READ: - { - struct adc_chan_result result; - - rc = msm_adc_read_result(msm_adc, client, &result); - if (rc) { - dev_dbg(&pdev->dev, "read result failed\n"); - return rc; - } - - if (copy_to_user((void __user *)arg, &result, - sizeof(struct adc_chan_result))) - return -EFAULT; - break; - } - case MSM_ADC_LOOKUP: - { - struct msm_adc_lookup lookup; - - if (copy_from_user(&lookup, (void __user *)arg, - sizeof(struct msm_adc_lookup))) - return -EFAULT; - - rc = msm_adc_lookup(msm_adc, &lookup); - if (rc) { - dev_dbg(&pdev->dev, "No such channel: %s\n", - lookup.name); - return rc; - } - - if (copy_to_user((void __user *)arg, &lookup, - sizeof(struct msm_adc_lookup))) - return -EFAULT; - break; - } - case MSM_ADC_FLUID_INIT: - { - uint32_t result; - - result = msm_adc_fluid_hw_init(msm_adc); - - if (copy_to_user((void __user *)arg, &result, - sizeof(uint32_t))) { - printk(KERN_ERR "MSM_ADC_FLUID_INIT: " - "copy_to_user returned an error.\n"); - return -EFAULT; - } - printk(KERN_DEBUG "MSM_ADC_FLUID_INIT: Success.\n"); - break; - } - case MSM_ADC_FLUID_DEINIT: - { - uint32_t result; - - result = msm_adc_fluid_hw_deinit(msm_adc); - - if (copy_to_user((void __user *)arg, &result, - sizeof(uint32_t))) - return -EFAULT; - break; - } - default: - return -EINVAL; - } - - return 0; -} - -const struct file_operations msm_adc_fops = { - .open = msm_adc_open, - .release = msm_adc_release, - .unlocked_ioctl = msm_adc_ioctl, -}; - -static ssize_t msm_adc_show_curr(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct msm_adc_drv *msm_adc = dev_get_drvdata(dev); - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - struct adc_chan_result result; - int rc; - -#ifdef CONFIG_PMIC8058_XOADC - rc = pm8058_xoadc_registered(); - if (rc <= 0) - return -ENODEV; -#endif - if (attr->index < pdata->num_chan_supported) { - rc = msm_adc_blocking_conversion(msm_adc, - attr->index, &result); - } else { - if (pdata->gpio_config == APROC_CONFIG && !epm_fluid_enabled - && pdata->adc_fluid_enable != NULL) { - printk(KERN_DEBUG "This is to read ADC value for " - "Fluid EPM and init. Do it only once.\n"); - pdata->adc_fluid_enable(); - epm_fluid_enabled = true; - } - rc = msm_rpc_adc_blocking_conversion(msm_adc, - attr->index, &result); - } - if (rc) - return 0; - - return sprintf(buf, "Result: %lld Raw: %d\n", result.physical, - result.adc_code); -} - -static int msm_rpc_adc_blocking_conversion(struct msm_adc_drv *msm_adc, - uint32_t hwmon_chan, struct adc_chan_result *result) -{ - struct msm_adc_platform_data *pdata = msm_adc->pdev->dev.platform_data; - struct dal_conv_request params; - struct device *dev = &msm_adc->pdev->dev; - struct adc_dev *adc_dev; - struct dal_conv_state *conv_s; - struct dal_conv_slot *slot; - struct adc_dev_spec dest; - int timeout, rc = 0; - - if (pdata->gpio_config == APROC_CONFIG && - pdata->adc_gpio_enable != NULL) - pdata->adc_gpio_enable(hwmon_chan-pdata->num_chan_supported); - - rc = msm_adc_translate_dal_to_hwmon(msm_adc, hwmon_chan, &dest); - if (rc) { - dev_err(dev, "%s: translation from chan %u failed\n", - __func__, hwmon_chan); - if (pdata->gpio_config == APROC_CONFIG && - pdata->adc_gpio_disable != NULL) - pdata->adc_gpio_disable(hwmon_chan - -pdata->num_chan_supported); - return -EINVAL; - } - - adc_dev = msm_adc->devs[dest.hwmon_dev_idx]; - conv_s = &adc_dev->conv; - - down(&conv_s->slot_count); - - mutex_lock(&conv_s->list_lock); - - slot = list_first_entry(&conv_s->slots, struct dal_conv_slot, list); - list_del(&slot->list); - BUG_ON(!slot); - - mutex_unlock(&conv_s->list_lock); - - /* indicates blocking request to callback handler */ - slot->blocking = 1; - - params.target.dev_idx = dest.dal.dev_idx; - params.target.chan_idx = dest.dal.chan_idx; - params.cb_h = slot->cb_h; - - rc = dalrpc_fcn_8(MSM_ADC_DALRPC_CMD_REQ_CONV, msm_adc->dev_h, - ¶ms, sizeof(params), NULL, 0); - if (rc) { - dev_err(dev, "%s: Conversion for device = %u channel = %u" - " failed\n", __func__, params.target.dev_idx, - params.target.chan_idx); - - rc = -EIO; - goto blk_conv_err; - } - - timeout = wait_for_completion_interruptible_timeout(&slot->comp, - MSM_ADC_DALRC_CONV_TIMEOUT); - if (timeout == 0) { - dev_err(dev, "read for device = %u channel = %u timed out\n", - params.target.dev_idx, params.target.chan_idx); - rc = -ETIMEDOUT; - goto blk_conv_err; - } else if (timeout < 0) { - rc = -EINTR; - goto blk_conv_err; - } - - result->physical = (int64_t)slot->result.physical; - - if (slot->result.status == DAL_RESULT_STATUS_INVALID) - rc = -ENODATA; - -blk_conv_err: - if (pdata->gpio_config == APROC_CONFIG && - pdata->adc_gpio_disable != NULL) - pdata->adc_gpio_disable(hwmon_chan-pdata->num_chan_supported); - msm_adc_restore_slot(conv_s, slot); - - return rc; -} - -static int msm_adc_blocking_conversion(struct msm_adc_drv *msm_adc, - uint32_t hwmon_chan, struct adc_chan_result *result) -{ - struct adc_conv_slot *slot; - struct msm_adc_platform_data *pdata = - msm_adc_drv->pdev->dev.platform_data; - struct msm_adc_channels *channel = &pdata->channel[hwmon_chan]; - int ret = 0; - - if (conv_first_request) { - ret = pm8058_xoadc_calib_device(channel->adc_dev_instance); - if (ret) { - pr_err("pmic8058 xoadc calibration failed, retry\n"); - return ret; - } - conv_first_request = false; - } - - channel->adc_access_fn->adc_slot_request(channel->adc_dev_instance, - &slot); - if (slot) { - slot->conv.result.chan = hwmon_chan; - /* indicates blocking request to callback handler */ - slot->blocking = 1; - slot->adc_request = START_OF_CONV; - slot->chan_path = channel->chan_path_type; - slot->chan_adc_config = channel->adc_config_type; - slot->chan_adc_calib = channel->adc_calib_type; - queue_work(msm_adc_drv->wq, &slot->work); - - wait_for_completion_interruptible(&slot->comp); - *result = slot->conv.result; - channel->adc_access_fn->adc_restore_slot( - channel->adc_dev_instance, slot); - return 0; - } - return -EBUSY; -} - -int32_t adc_channel_open(uint32_t channel, void **h) -{ - struct msm_client_data *client; - struct msm_adc_drv *msm_adc = msm_adc_drv; - struct msm_adc_platform_data *pdata; - struct platform_device *pdev; - int i = 0; - - if (!msm_adc_drv) - return -EFAULT; - -#ifdef CONFIG_PMIC8058_XOADC - if (pm8058_xoadc_registered() <= 0) - return -ENODEV; -#endif - pdata = msm_adc->pdev->dev.platform_data; - pdev = msm_adc->pdev; - - while (i < pdata->num_chan_supported) { - if (channel == pdata->channel[i].channel_name) - break; - else - i++; - } - - if (i == pdata->num_chan_supported) - return -EBADF; /* unknown channel */ - - client = kzalloc(sizeof(struct msm_client_data), GFP_KERNEL); - if (!client) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - if (!try_module_get(THIS_MODULE)) { - kfree(client); - return -EACCES; - } - - mutex_init(&client->lock); - INIT_LIST_HEAD(&client->complete_list); - init_waitqueue_head(&client->data_wait); - init_waitqueue_head(&client->outst_wait); - - client->online = 1; - client->adc_chan = i; - *h = (void *)client; - return 0; -} - -int32_t adc_channel_close(void *h) -{ - struct msm_client_data *client = (struct msm_client_data *)h; - - kfree(client); - return 0; -} - -int32_t adc_channel_request_conv(void *h, struct completion *conv_complete_evt) -{ - struct msm_client_data *client = (struct msm_client_data *)h; - struct msm_adc_platform_data *pdata = - msm_adc_drv->pdev->dev.platform_data; - struct msm_adc_channels *channel = &pdata->channel[client->adc_chan]; - struct adc_conv_slot *slot; - int ret; - - if (conv_first_request) { - ret = pm8058_xoadc_calib_device(channel->adc_dev_instance); - if (ret) { - pr_err("pmic8058 xoadc calibration failed, retry\n"); - return ret; - } - conv_first_request = false; - } - - channel->adc_access_fn->adc_slot_request(channel->adc_dev_instance, - &slot); - - if (slot) { - atomic_inc(&msm_adc_drv->total_outst); - mutex_lock(&client->lock); - client->num_outstanding++; - mutex_unlock(&client->lock); - - slot->conv.result.chan = client->adc_chan; - slot->blocking = 0; - slot->compk = conv_complete_evt; - slot->client = client; - slot->adc_request = START_OF_CONV; - slot->chan_path = channel->chan_path_type; - slot->chan_adc_config = channel->adc_config_type; - slot->chan_adc_calib = channel->adc_calib_type; - queue_work(msm_adc_drv->wq, &slot->work); - return 0; - } - return -EBUSY; -} - -int32_t adc_channel_read_result(void *h, struct adc_chan_result *chan_result) -{ - struct msm_client_data *client = (struct msm_client_data *)h; - struct msm_adc_platform_data *pdata = - msm_adc_drv->pdev->dev.platform_data; - struct msm_adc_channels *channel = pdata->channel; - struct adc_conv_slot *slot; - int rc = 0; - - mutex_lock(&client->lock); - - slot = list_first_entry(&client->complete_list, - struct adc_conv_slot, list); - if (!slot) { - mutex_unlock(&client->lock); - return -ENOMSG; - } - - slot->client = NULL; - list_del(&slot->list); - - client->num_complete--; - - mutex_unlock(&client->lock); - - *chan_result = slot->conv.result; - - /* restore this slot to reserve */ - channel[slot->conv.result.chan].adc_access_fn->adc_restore_slot( - channel[slot->conv.result.chan].adc_dev_instance, slot); - - return rc; -} - -static void msm_rpc_adc_conv_cb(void *context, u32 param, - void *evt_buf, u32 len) -{ - struct dal_adc_result *result = evt_buf; - struct dal_conv_slot *slot = context; - struct msm_adc_drv *msm_adc = msm_adc_drv; - - memcpy(&slot->result, result, sizeof(slot->result)); - - /* for blocking requests, signal complete */ - if (slot->blocking) - complete(&slot->comp); - - /* for non-blocking requests, add slot to the client completed list */ - else { - struct msm_client_data *client = slot->client; - - mutex_lock(&client->lock); - - list_add(&slot->list, &client->complete_list); - client->num_complete++; - client->num_outstanding--; - - /* - * if the client release has been invoked and this is call - * corresponds to the last request, then signal release - * to complete. - */ - if (slot->client->online == 0 && client->num_outstanding == 0) - wake_up_interruptible_all(&client->outst_wait); - - mutex_unlock(&client->lock); - - wake_up_interruptible_all(&client->data_wait); - - atomic_dec(&msm_adc->total_outst); - - /* verify driver remove has not been invoked */ - if (atomic_read(&msm_adc->online) == 0 && - atomic_read(&msm_adc->total_outst) == 0) - wake_up_interruptible_all(&msm_adc->total_outst_wait); - } -} - -void msm_adc_conv_cb(void *context, u32 param, - void *evt_buf, u32 len) -{ - struct adc_conv_slot *slot = context; - struct msm_adc_drv *msm_adc = msm_adc_drv; - - switch (slot->adc_request) { - case START_OF_CONV: - slot->adc_request = END_OF_CONV; - break; - case START_OF_CALIBRATION: - slot->adc_request = END_OF_CALIBRATION; - break; - case END_OF_CALIBRATION: - case END_OF_CONV: - break; - } - queue_work(msm_adc->wq, &slot->work); -} - -static void msm_adc_teardown_device_conv(struct platform_device *pdev, - struct adc_dev *adc_dev) -{ - struct dal_conv_state *conv_s = &adc_dev->conv; - struct msm_adc_drv *msm_adc = platform_get_drvdata(pdev); - struct dal_conv_slot *slot; - int i; - - for (i = 0; i < MSM_ADC_DEV_MAX_INFLIGHT; i++) { - slot = &conv_s->context[i]; - if (slot->cb_h) { - dalrpc_dealloc_cb(msm_adc->dev_h, slot->cb_h); - slot->cb_h = NULL; - } - } -} - -static void msm_rpc_adc_teardown_device(struct platform_device *pdev, - struct adc_dev *adc_dev) -{ - struct dal_translation *transl = &adc_dev->transl; - int i, num_chans = transl->hwmon_end - transl->hwmon_start + 1; - - if (adc_dev->sens_attr) - for (i = 0; i < num_chans; i++) - device_remove_file(&pdev->dev, - &adc_dev->sens_attr[i].dev_attr); - - msm_adc_teardown_device_conv(pdev, adc_dev); - - kfree(adc_dev->fnames); - kfree(adc_dev->sens_attr); - kfree(adc_dev); -} - -static void msm_rpc_adc_teardown_devices(struct platform_device *pdev) -{ - struct msm_adc_platform_data *pdata = pdev->dev.platform_data; - struct msm_adc_drv *msm_adc = platform_get_drvdata(pdev); - int i, rc = 0; - - for (i = 0; i < pdata->num_adc; i++) { - if (msm_adc->devs[i]) { - msm_rpc_adc_teardown_device(pdev, msm_adc->devs[i]); - msm_adc->devs[i] = NULL; - } else - break; - } - - if (msm_adc->dev_h) { - rc = daldevice_detach(msm_adc->dev_h); - if (rc) - dev_err(&pdev->dev, "Cannot detach from dal device\n"); - msm_adc->dev_h = NULL; - } - -} - -static void msm_adc_teardown_device(struct platform_device *pdev, - struct msm_adc_drv *msm_adc) -{ - struct msm_adc_platform_data *pdata = pdev->dev.platform_data; - int i, num_chans = pdata->num_chan_supported; - - if (pdata->num_chan_supported > 0) { - if (msm_adc->sens_attr) - for (i = 0; i < num_chans; i++) - device_remove_file(&pdev->dev, - &msm_adc->sens_attr[i].dev_attr); - kfree(msm_adc->sens_attr); - } -} - -static void msm_adc_teardown(struct platform_device *pdev) -{ - struct msm_adc_drv *msm_adc = platform_get_drvdata(pdev); - - if (!msm_adc) - return; - - misc_deregister(&msm_adc->misc); - - if (msm_adc->hwmon) - hwmon_device_unregister(msm_adc->hwmon); - - msm_rpc_adc_teardown_devices(pdev); - msm_adc_teardown_device(pdev, msm_adc); - - kfree(msm_adc); - platform_set_drvdata(pdev, NULL); -} - -static int msm_adc_device_conv_init(struct msm_adc_drv *msm_adc, - struct adc_dev *adc_dev) -{ - struct platform_device *pdev = msm_adc->pdev; - struct dal_conv_state *conv_s = &adc_dev->conv; - struct dal_conv_slot *slot = conv_s->context; - int rc, i; - - sema_init(&conv_s->slot_count, MSM_ADC_DEV_MAX_INFLIGHT); - mutex_init(&conv_s->list_lock); - INIT_LIST_HEAD(&conv_s->slots); - - for (i = 0; i < MSM_ADC_DEV_MAX_INFLIGHT; i++) { - list_add(&slot->list, &conv_s->slots); - slot->cb_h = dalrpc_alloc_cb(msm_adc->dev_h, - msm_rpc_adc_conv_cb, slot); - if (!slot->cb_h) { - dev_err(&pdev->dev, "Unable to allocate DAL callback" - " for slot %d\n", i); - rc = -ENOMEM; - goto dal_err_cb; - } - init_completion(&slot->comp); - slot->idx = i; - slot++; - } - - return 0; - -dal_err_cb: - msm_adc_teardown_device_conv(pdev, adc_dev); - - return rc; -} - -static struct sensor_device_attribute msm_rpc_adc_curr_in_attr = - SENSOR_ATTR(NULL, S_IRUGO, msm_adc_show_curr, NULL, 0); - -static int msm_rpc_adc_device_init_hwmon(struct platform_device *pdev, - struct adc_dev *adc_dev) -{ - struct dal_translation *transl = &adc_dev->transl; - int i, rc, num_chans = transl->hwmon_end - transl->hwmon_start + 1; - const char prefix[] = "curr", postfix[] = "_input"; - char tmpbuf[5]; - - adc_dev->fnames = kzalloc(num_chans * MSM_ADC_MAX_FNAME + - num_chans * sizeof(char *), GFP_KERNEL); - if (!adc_dev->fnames) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - adc_dev->sens_attr = kzalloc(num_chans * - sizeof(struct sensor_device_attribute), GFP_KERNEL); - if (!adc_dev->sens_attr) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - rc = -ENOMEM; - goto hwmon_err_fnames; - } - - for (i = 0; i < num_chans; i++) { - adc_dev->fnames[i] = (char *)adc_dev->fnames + - i * MSM_ADC_MAX_FNAME + num_chans * sizeof(char *); - strcpy(adc_dev->fnames[i], prefix); - sprintf(tmpbuf, "%d", transl->hwmon_start + i); - strcat(adc_dev->fnames[i], tmpbuf); - strcat(adc_dev->fnames[i], postfix); - - msm_rpc_adc_curr_in_attr.index = transl->hwmon_start + i; - msm_rpc_adc_curr_in_attr.dev_attr.attr.name = - adc_dev->fnames[i]; - memcpy(&adc_dev->sens_attr[i], &msm_rpc_adc_curr_in_attr, - sizeof(msm_rpc_adc_curr_in_attr)); - - rc = device_create_file(&pdev->dev, - &adc_dev->sens_attr[i].dev_attr); - if (rc) { - dev_err(&pdev->dev, "device_create_file failed for " - "dal dev %u chan %d\n", - adc_dev->transl.dal_dev_idx, i); - goto hwmon_err_sens; - } - } - - return 0; - -hwmon_err_sens: - kfree(adc_dev->sens_attr); -hwmon_err_fnames: - kfree(adc_dev->fnames); - - return rc; -} - -static int msm_rpc_adc_device_init(struct platform_device *pdev) -{ - struct msm_adc_platform_data *pdata = pdev->dev.platform_data; - struct msm_adc_drv *msm_adc = platform_get_drvdata(pdev); - struct adc_dev *adc_dev; - struct adc_dev_spec target; - int i, rc; - int hwmon_cntr = pdata->num_chan_supported; - - for (i = 0; i < pdata->num_adc; i++) { - adc_dev = kzalloc(sizeof(struct adc_dev), GFP_KERNEL); - if (!adc_dev) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - rc = -ENOMEM; - goto dev_init_err; - } - - msm_adc->devs[i] = adc_dev; - adc_dev->name = pdata->dev_names[i]; - - rc = msm_adc_device_conv_init(msm_adc, adc_dev); - if (rc) { - dev_err(&pdev->dev, "DAL device[%s] failed conv init\n", - adc_dev->name); - goto dev_init_err; - } - - if (!pdata->target_hw == MSM_8x25) { - /* DAL device lookup */ - rc = msm_adc_getinputproperties(msm_adc, adc_dev->name, - &target); - if (rc) { - dev_err(&pdev->dev, "No such DAL device[%s]\n", - adc_dev->name); - goto dev_init_err; - } - - adc_dev->transl.dal_dev_idx = target.dal.dev_idx; - adc_dev->nchans = target.dal.chan_idx; - } else { - /* On targets prior to MSM7x30 the remote driver has - only the channel list and no device id. */ - adc_dev->transl.dal_dev_idx = MSM_8x25_ADC_DEV_ID; - adc_dev->nchans = MSM_8x25_CHAN_ID; - } - - adc_dev->transl.hwmon_dev_idx = i; - adc_dev->transl.hwmon_start = hwmon_cntr; - adc_dev->transl.hwmon_end = hwmon_cntr + adc_dev->nchans - 1; - hwmon_cntr += adc_dev->nchans; - - rc = msm_rpc_adc_device_init_hwmon(pdev, adc_dev); - if (rc) - goto dev_init_err; - } - - return 0; - -dev_init_err: - msm_rpc_adc_teardown_devices(pdev); - return rc; -} - -static int msm_rpc_adc_init(struct platform_device *pdev1) -{ - struct msm_adc_drv *msm_adc = msm_adc_drv; - struct platform_device *pdev = msm_adc->pdev; - struct msm_adc_platform_data *pdata = pdev->dev.platform_data; - int rc = 0; - - dev_dbg(&pdev->dev, "msm_rpc_adc_init called\n"); - - if (!pdata) { - dev_err(&pdev->dev, "no platform data?\n"); - return -EINVAL; - } - - mutex_init(&msm_adc->prop_lock); - - rc = daldevice_attach(MSM_ADC_DALRPC_DEVICEID, - MSM_ADC_DALRPC_PORT_NAME, - MSM_ADC_DALRPC_CPU, - &msm_adc->dev_h); - if (rc) { - dev_err(&pdev->dev, "Cannot attach to dal device\n"); - return rc; - } - - dev_dbg(&pdev->dev, "Attach to dal device Succeeded\n"); - - rc = msm_rpc_adc_device_init(pdev); - if (rc) { - dev_err(&pdev->dev, "msm_adc_dev_init failed\n"); - goto err_cleanup; - } - - init_waitqueue_head(&msm_adc->rpc_total_outst_wait); - atomic_set(&msm_adc->rpc_online, 1); - atomic_set(&msm_adc->rpc_total_outst, 0); - epm_init = true; - pr_info("msm_adc successfully registered\n"); - - return 0; - -err_cleanup: - msm_rpc_adc_teardown_devices(pdev); - - return rc; -} - -/* - * Process the deferred job - */ -void msm_adc_wq_work(struct work_struct *work) -{ - struct adc_properties *adc_properties; - struct adc_conv_slot *slot = container_of(work, - struct adc_conv_slot, work); - uint32_t idx = slot->conv.result.chan; - struct msm_adc_platform_data *pdata = - msm_adc_drv->pdev->dev.platform_data; - struct msm_adc_channels *channel = &pdata->channel[idx]; - int32_t adc_code; - - switch (slot->adc_request) { - case START_OF_CONV: - channel->adc_access_fn->adc_select_chan_and_start_conv( - channel->adc_dev_instance, slot); - break; - case END_OF_CONV: - adc_properties = channel->adc_access_fn->adc_get_properties( - channel->adc_dev_instance); - if (channel->adc_access_fn->adc_read_adc_code) - channel->adc_access_fn->adc_read_adc_code( - channel->adc_dev_instance, &adc_code); - if (channel->chan_processor) - channel->chan_processor(adc_code, adc_properties, - &slot->chan_properties, &slot->conv.result); - /* Intentionally a fall thru here. Calibraton does not need - to perform channel processing, etc. However, both - end of conversion and end of calibration requires the below - fall thru code to be executed. */ - case END_OF_CALIBRATION: - /* for blocking requests, signal complete */ - if (slot->blocking) - complete(&slot->comp); - else { - struct msm_client_data *client = slot->client; - - mutex_lock(&client->lock); - - if (slot->adc_request == END_OF_CONV) { - list_add(&slot->list, &client->complete_list); - client->num_complete++; - } - client->num_outstanding--; - - /* - * if the client release has been invoked and this is call - * corresponds to the last request, then signal release - * to complete. - */ - if (slot->client->online == 0 && - client->num_outstanding == 0) - wake_up_interruptible_all(&client->outst_wait); - - mutex_unlock(&client->lock); - - wake_up_interruptible_all(&client->data_wait); - - atomic_dec(&msm_adc_drv->total_outst); - - /* verify driver remove has not been invoked */ - if (atomic_read(&msm_adc_drv->online) == 0 && - atomic_read(&msm_adc_drv->total_outst) == 0) - wake_up_interruptible_all( - &msm_adc_drv->total_outst_wait); - - if (slot->compk) /* Kernel space request */ - complete(slot->compk); - if (slot->adc_request == END_OF_CALIBRATION) - channel->adc_access_fn->adc_restore_slot( - channel->adc_dev_instance, slot); - } - break; - case START_OF_CALIBRATION: /* code here to please code reviewers - to satisfy silly compiler warnings */ - break; - } -} - -static struct sensor_device_attribute msm_adc_curr_in_attr = - SENSOR_ATTR(NULL, S_IRUGO, msm_adc_show_curr, NULL, 0); - -static int msm_adc_init_hwmon(struct platform_device *pdev, - struct msm_adc_drv *msm_adc) -{ - struct msm_adc_platform_data *pdata = pdev->dev.platform_data; - struct msm_adc_channels *channel = pdata->channel; - int i, rc, num_chans = pdata->num_chan_supported; - - if (!channel) - return -EINVAL; - - msm_adc->sens_attr = kzalloc(num_chans * - sizeof(struct sensor_device_attribute), GFP_KERNEL); - if (!msm_adc->sens_attr) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - rc = -ENOMEM; - goto hwmon_err_sens; - } - - for (i = 0; i < num_chans; i++) { - msm_adc_curr_in_attr.index = i; - msm_adc_curr_in_attr.dev_attr.attr.name = channel[i].name; - memcpy(&msm_adc->sens_attr[i], &msm_adc_curr_in_attr, - sizeof(msm_adc_curr_in_attr)); - - rc = device_create_file(&pdev->dev, - &msm_adc->sens_attr[i].dev_attr); - if (rc) { - dev_err(&pdev->dev, "device_create_file failed for " - "dal dev %s\n", - channel[i].name); - goto hwmon_err_sens; - } - } - - return 0; - -hwmon_err_sens: - kfree(msm_adc->sens_attr); - - return rc; -} - -static struct platform_driver msm_adc_rpcrouter_remote_driver = { - .probe = msm_rpc_adc_init, - .driver = { - .name = MSM_ADC_DALRPC_PORT_NAME, - .owner = THIS_MODULE, - }, -}; - -static int msm_adc_probe(struct platform_device *pdev) -{ - struct msm_adc_platform_data *pdata = pdev->dev.platform_data; - struct msm_adc_drv *msm_adc; - int rc = 0; - - if (!pdata) { - dev_err(&pdev->dev, "no platform data?\n"); - return -EINVAL; - } - - msm_adc = kzalloc(sizeof(struct msm_adc_drv), GFP_KERNEL); - if (!msm_adc) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - platform_set_drvdata(pdev, msm_adc); - msm_adc_drv = msm_adc; - msm_adc->pdev = pdev; - - if (pdata->target_hw == MSM_8x60 || pdata->target_hw == FSM_9xxx) { - rc = msm_adc_init_hwmon(pdev, msm_adc); - if (rc) { - dev_err(&pdev->dev, "msm_adc_dev_init failed\n"); - goto err_cleanup; - } - } - - msm_adc->hwmon = hwmon_device_register(&pdev->dev); - if (IS_ERR(msm_adc->hwmon)) { - dev_err(&pdev->dev, "hwmon_device_register failed\n"); - rc = PTR_ERR(msm_adc->hwmon); - goto err_cleanup; - } - - msm_adc->misc.name = MSM_ADC_DRIVER_NAME; - msm_adc->misc.minor = MISC_DYNAMIC_MINOR; - msm_adc->misc.fops = &msm_adc_fops; - - if (misc_register(&msm_adc->misc)) { - dev_err(&pdev->dev, "Unable to register misc device!\n"); - goto err_cleanup; - } - - init_waitqueue_head(&msm_adc->total_outst_wait); - atomic_set(&msm_adc->online, 1); - atomic_set(&msm_adc->total_outst, 0); - - msm_adc->wq = create_singlethread_workqueue("msm_adc"); - if (!msm_adc->wq) - goto err_cleanup; - - if (pdata->num_adc > 0) { - if (pdata->target_hw == MSM_8x60) - platform_driver_register( - &msm_adc_rpcrouter_remote_driver); - else - msm_rpc_adc_init(pdev); - } - conv_first_request = true; - - pr_info("msm_adc successfully registered\n"); - - return 0; - -err_cleanup: - msm_adc_teardown(pdev); - - return rc; -} - -static int msm_adc_remove(struct platform_device *pdev) -{ - int rc; - - struct msm_adc_drv *msm_adc = platform_get_drvdata(pdev); - - atomic_set(&msm_adc->online, 0); - - atomic_set(&msm_adc->rpc_online, 0); - - misc_deregister(&msm_adc->misc); - - hwmon_device_unregister(msm_adc->hwmon); - msm_adc->hwmon = NULL; - - /* - * We may still have outstanding transactions in flight that have not - * completed. Make sure they're completed before tearing down. - */ - rc = wait_event_interruptible(msm_adc->total_outst_wait, - atomic_read(&msm_adc->total_outst) == 0); - if (rc) { - pr_err("%s: wait_event_interruptible failed rc = %d\n", - __func__, rc); - return rc; - } - - rc = wait_event_interruptible(msm_adc->rpc_total_outst_wait, - atomic_read(&msm_adc->rpc_total_outst) == 0); - if (rc) { - pr_err("%s: wait_event_interruptible failed rc = %d\n", - __func__, rc); - return rc; - } - - msm_adc_teardown(pdev); - - pr_info("msm_adc unregistered\n"); - - return 0; -} - -static struct platform_driver msm_adc_driver = { - .probe = msm_adc_probe, - .remove = msm_adc_remove, - .driver = { - .name = MSM_ADC_DRIVER_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init msm_adc_init(void) -{ - return platform_driver_register(&msm_adc_driver); -} -module_init(msm_adc_init); - -static void __exit msm_adc_exit(void) -{ - platform_driver_unregister(&msm_adc_driver); -} -module_exit(msm_adc_exit); - -MODULE_DESCRIPTION("MSM ADC Driver"); -MODULE_ALIAS("platform:msm_adc"); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("0.1"); diff --git a/drivers/hwmon/pm8xxx-adc-scale.c b/drivers/hwmon/pm8xxx-adc-scale.c deleted file mode 100644 index 62e86b236247999684762be40e77cff833d40cac..0000000000000000000000000000000000000000 --- a/drivers/hwmon/pm8xxx-adc-scale.c +++ /dev/null @@ -1,790 +0,0 @@ -/* - * Copyright (c) 2011-2013, 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 -#include -#include -#include -#define KELVINMIL_DEGMIL 273160 - -/* Units for temperature below (on x axis) is in 0.1DegC as - required by the battery driver. Note the resolution used - here to compute the table was done for DegC to milli-volts. - In consideration to limit the size of the table for the given - temperature range below, the result is linearly interpolated - and provided to the battery driver in the units desired for - their framework which is 0.1DegC. True resolution of 0.1DegC - will result in the below table size to increase by 10 times */ -static const struct pm8xxx_adc_map_pt adcmap_btm_threshold[] = { - {-300, 1642}, - {-200, 1544}, - {-100, 1414}, - {0, 1260}, - {10, 1244}, - {20, 1228}, - {30, 1212}, - {40, 1195}, - {50, 1179}, - {60, 1162}, - {70, 1146}, - {80, 1129}, - {90, 1113}, - {100, 1097}, - {110, 1080}, - {120, 1064}, - {130, 1048}, - {140, 1032}, - {150, 1016}, - {160, 1000}, - {170, 985}, - {180, 969}, - {190, 954}, - {200, 939}, - {210, 924}, - {220, 909}, - {230, 894}, - {240, 880}, - {250, 866}, - {260, 852}, - {270, 838}, - {280, 824}, - {290, 811}, - {300, 798}, - {310, 785}, - {320, 773}, - {330, 760}, - {340, 748}, - {350, 736}, - {360, 725}, - {370, 713}, - {380, 702}, - {390, 691}, - {400, 681}, - {410, 670}, - {420, 660}, - {430, 650}, - {440, 640}, - {450, 631}, - {460, 622}, - {470, 613}, - {480, 604}, - {490, 595}, - {500, 587}, - {510, 579}, - {520, 571}, - {530, 563}, - {540, 556}, - {550, 548}, - {560, 541}, - {570, 534}, - {580, 527}, - {590, 521}, - {600, 514}, - {610, 508}, - {620, 502}, - {630, 496}, - {640, 490}, - {650, 485}, - {660, 479}, - {670, 474}, - {680, 469}, - {690, 464}, - {700, 459}, - {710, 454}, - {720, 449}, - {730, 445}, - {740, 440}, - {750, 437}, - {760, 432}, - {770, 428}, - {780, 424}, - {790, 420} -}; - -static const struct pm8xxx_adc_map_pt adcmap_pa_therm[] = { - {1731, -30}, - {1726, -29}, - {1721, -28}, - {1715, -27}, - {1710, -26}, - {1703, -25}, - {1697, -24}, - {1690, -23}, - {1683, -22}, - {1675, -21}, - {1667, -20}, - {1659, -19}, - {1650, -18}, - {1641, -17}, - {1632, -16}, - {1622, -15}, - {1611, -14}, - {1600, -13}, - {1589, -12}, - {1577, -11}, - {1565, -10}, - {1552, -9}, - {1539, -8}, - {1525, -7}, - {1511, -6}, - {1496, -5}, - {1481, -4}, - {1465, -3}, - {1449, -2}, - {1432, -1}, - {1415, 0}, - {1398, 1}, - {1380, 2}, - {1362, 3}, - {1343, 4}, - {1324, 5}, - {1305, 6}, - {1285, 7}, - {1265, 8}, - {1245, 9}, - {1224, 10}, - {1203, 11}, - {1182, 12}, - {1161, 13}, - {1139, 14}, - {1118, 15}, - {1096, 16}, - {1074, 17}, - {1052, 18}, - {1030, 19}, - {1008, 20}, - {986, 21}, - {964, 22}, - {943, 23}, - {921, 24}, - {899, 25}, - {878, 26}, - {857, 27}, - {836, 28}, - {815, 29}, - {794, 30}, - {774, 31}, - {754, 32}, - {734, 33}, - {714, 34}, - {695, 35}, - {676, 36}, - {657, 37}, - {639, 38}, - {621, 39}, - {604, 40}, - {586, 41}, - {570, 42}, - {553, 43}, - {537, 44}, - {521, 45}, - {506, 46}, - {491, 47}, - {476, 48}, - {462, 49}, - {448, 50}, - {435, 51}, - {421, 52}, - {409, 53}, - {396, 54}, - {384, 55}, - {372, 56}, - {361, 57}, - {350, 58}, - {339, 59}, - {329, 60}, - {318, 61}, - {309, 62}, - {299, 63}, - {290, 64}, - {281, 65}, - {272, 66}, - {264, 67}, - {256, 68}, - {248, 69}, - {240, 70}, - {233, 71}, - {226, 72}, - {219, 73}, - {212, 74}, - {206, 75}, - {199, 76}, - {193, 77}, - {187, 78}, - {182, 79}, - {176, 80}, - {171, 81}, - {166, 82}, - {161, 83}, - {156, 84}, - {151, 85}, - {147, 86}, - {142, 87}, - {138, 88}, - {134, 89}, - {130, 90}, - {126, 91}, - {122, 92}, - {119, 93}, - {115, 94}, - {112, 95}, - {109, 96}, - {106, 97}, - {103, 98}, - {100, 99}, - {97, 100}, - {94, 101}, - {91, 102}, - {89, 103}, - {86, 104}, - {84, 105}, - {82, 106}, - {79, 107}, - {77, 108}, - {75, 109}, - {73, 110}, - {71, 111}, - {69, 112}, - {67, 113}, - {65, 114}, - {64, 115}, - {62, 116}, - {60, 117}, - {59, 118}, - {57, 119}, - {56, 120}, - {54, 121}, - {53, 122}, - {51, 123}, - {50, 124}, - {49, 125} -}; - -static const struct pm8xxx_adc_map_pt adcmap_ntcg_104ef_104fb[] = { - {374682, -40960}, - {360553, -39936}, - {346630, -38912}, - {332940, -37888}, - {319510, -36864}, - {306363, -35840}, - {293521, -34816}, - {281001, -33792}, - {268818, -32768}, - {256987, -31744}, - {245516, -30720}, - {234413, -29696}, - {223685, -28672}, - {213333, -27648}, - {203360, -26624}, - {193763, -25600}, - {184541, -24576}, - {175691, -23552}, - {167205, -22528}, - {159079, -21504}, - {151304, -20480}, - {143872, -19456}, - {136775, -18432}, - {130001, -17408}, - {123542, -16384}, - {117387, -15360}, - {111526, -14336}, - {105946, -13312}, - {100639, -12288}, - {95592, -11264}, - {90795, -10240}, - {86238, -9216}, - {81909, -8192}, - {77800, -7168}, - {73899, -6144}, - {70197, -5120}, - {66685, -4096}, - {63354, -3072}, - {60194, -2048}, - {57198, -1024}, - {54356, 0}, - {51662, 1024}, - {49108, 2048}, - {46687, 3072}, - {44391, 4096}, - {42215, 5120}, - {40151, 6144}, - {38195, 7168}, - {36340, 8192}, - {34582, 9216}, - {32914, 10240}, - {31333, 11264}, - {29833, 12288}, - {28410, 13312}, - {27061, 14336}, - {25781, 15360}, - {24566, 16384}, - {23413, 17408}, - {22319, 18432}, - {21280, 19456}, - {20294, 20480}, - {19358, 21504}, - {18469, 22528}, - {17624, 23552}, - {16822, 24576}, - {16060, 25600}, - {15335, 26624}, - {14646, 27648}, - {13992, 28672}, - {13369, 29696}, - {12777, 30720}, - {12214, 31744}, - {11678, 32768}, - {11168, 33792}, - {10682, 34816}, - {10220, 35840}, - {9780, 36864}, - {9361, 37888}, - {8962, 38912}, - {8582, 39936}, - {8219, 40960}, - {7874, 41984}, - {7545, 43008}, - {7231, 44032}, - {6931, 45056}, - {6646, 46080}, - {6373, 47104}, - {6113, 48128}, - {5865, 49152}, - {5628, 50176}, - {5402, 51200}, - {5185, 52224}, - {4979, 53248}, - {4782, 54272}, - {4593, 55296}, - {4413, 56320}, - {4241, 57344}, - {4076, 58368}, - {3919, 59392}, - {3768, 60416}, - {3624, 61440}, - {3486, 62464}, - {3354, 63488}, - {3227, 64512}, - {3106, 65536}, - {2990, 66560}, - {2879, 67584}, - {2773, 68608}, - {2671, 69632}, - {2573, 70656}, - {2479, 71680}, - {2390, 72704}, - {2303, 73728}, - {2221, 74752}, - {2142, 75776}, - {2066, 76800}, - {1993, 77824}, - {1923, 78848}, - {1855, 79872}, - {1791, 80896}, - {1729, 81920}, - {1669, 82944}, - {1612, 83968}, - {1557, 84992}, - {1504, 86016}, - {1453, 87040}, - {1404, 88064}, - {1357, 89088}, - {1312, 90112}, - {1269, 91136}, - {1227, 92160}, - {1187, 93184}, - {1148, 94208}, - {1111, 95232}, - {1075, 96256}, - {1040, 97280}, - {1007, 98304}, - {975, 99328}, - {944, 100352}, - {914, 101376}, - {886, 102400}, - {858, 103424}, - {831, 104448}, - {806, 105472}, - {781, 106496}, - {757, 107520}, - {734, 108544}, - {712, 109568}, - {690, 110592}, - {670, 111616}, - {650, 112640}, - {630, 113664}, - {612, 114688}, - {594, 115712}, - {576, 116736}, - {559, 117760}, - {543, 118784}, - {527, 119808}, - {512, 120832}, - {498, 121856}, - {483, 122880}, - {470, 123904}, - {456, 124928}, - {444, 125952}, - {431, 126976}, - {419, 128000}, - {408, 129024}, - {396, 130048} -}; - -static int32_t pm8xxx_adc_map_linear(const struct pm8xxx_adc_map_pt *pts, - uint32_t tablesize, int32_t input, int64_t *output) -{ - bool descending = 1; - uint32_t i = 0; - - if ((pts == NULL) || (output == NULL)) - return -EINVAL; - - /* Check if table is descending or ascending */ - if (tablesize > 1) { - if (pts[0].x < pts[1].x) - descending = 0; - } - - while (i < tablesize) { - if ((descending == 1) && (pts[i].x < input)) { - /* table entry is less than measured - value and table is descending, stop */ - break; - } else if ((descending == 0) && - (pts[i].x > input)) { - /* table entry is greater than measured - value and table is ascending, stop */ - break; - } else { - i++; - } - } - - if (i == 0) - *output = pts[0].y; - else if (i == tablesize) - *output = pts[tablesize-1].y; - else { - /* result is between search_index and search_index-1 */ - /* interpolate linearly */ - *output = (((int32_t) ((pts[i].y - pts[i-1].y)* - (input - pts[i-1].x))/ - (pts[i].x - pts[i-1].x))+ - pts[i-1].y); - } - - return 0; -} - -static int32_t pm8xxx_adc_map_batt_therm(const struct pm8xxx_adc_map_pt *pts, - uint32_t tablesize, int32_t input, int64_t *output) -{ - bool descending = 1; - uint32_t i = 0; - - if ((pts == NULL) || (output == NULL)) - return -EINVAL; - - /* Check if table is descending or ascending */ - if (tablesize > 1) { - if (pts[0].y < pts[1].y) - descending = 0; - } - - while (i < tablesize) { - if ((descending == 1) && (pts[i].y < input)) { - /* table entry is less than measured - value and table is descending, stop */ - break; - } else if ((descending == 0) && (pts[i].y > input)) { - /* table entry is greater than measured - value and table is ascending, stop */ - break; - } else { - i++; - } - } - - if (i == 0) { - *output = pts[0].x; - } else if (i == tablesize) { - *output = pts[tablesize-1].x; - } else { - /* result is between search_index and search_index-1 */ - /* interpolate linearly */ - *output = (((int32_t) ((pts[i].x - pts[i-1].x)* - (input - pts[i-1].y))/ - (pts[i].y - pts[i-1].y))+ - pts[i-1].x); - } - - return 0; -} - -int32_t pm8xxx_adc_scale_default(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties, - struct pm8xxx_adc_chan_result *adc_chan_result) -{ - bool negative_rawfromoffset = 0, negative_offset = 0; - int64_t scale_voltage = 0; - - if (!chan_properties || !chan_properties->offset_gain_numerator || - !chan_properties->offset_gain_denominator || !adc_properties - || !adc_chan_result) - return -EINVAL; - - scale_voltage = (adc_code - - chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].adc_gnd) - * chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].dx; - if (scale_voltage < 0) { - negative_offset = 1; - scale_voltage = -scale_voltage; - } - do_div(scale_voltage, - chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].dy); - if (negative_offset) - scale_voltage = -scale_voltage; - scale_voltage += chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].dx; - - if (scale_voltage < 0) { - if (adc_properties->bipolar) { - scale_voltage = -scale_voltage; - negative_rawfromoffset = 1; - } else { - scale_voltage = 0; - } - } - - adc_chan_result->measurement = scale_voltage * - chan_properties->offset_gain_denominator; - - /* do_div only perform positive integer division! */ - do_div(adc_chan_result->measurement, - chan_properties->offset_gain_numerator); - - if (negative_rawfromoffset) - adc_chan_result->measurement = -adc_chan_result->measurement; - - /* Note: adc_chan_result->measurement is in the unit of - * adc_properties.adc_reference. For generic channel processing, - * channel measurement is a scale/ratio relative to the adc - * reference input */ - adc_chan_result->physical = adc_chan_result->measurement; - - return 0; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_scale_default); - -static int64_t pm8xxx_adc_scale_ratiometric_calib(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties) -{ - int64_t adc_voltage = 0; - bool negative_offset = 0; - - if (!chan_properties || !chan_properties->offset_gain_numerator || - !chan_properties->offset_gain_denominator || !adc_properties) - return -EINVAL; - - adc_voltage = (adc_code - - chan_properties->adc_graph[ADC_CALIB_RATIOMETRIC].adc_gnd) - * adc_properties->adc_vdd_reference; - if (adc_voltage < 0) { - negative_offset = 1; - adc_voltage = -adc_voltage; - } - do_div(adc_voltage, - chan_properties->adc_graph[ADC_CALIB_RATIOMETRIC].dy); - if (negative_offset) - adc_voltage = -adc_voltage; - - return adc_voltage; -} - -int32_t pm8xxx_adc_scale_batt_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties, - struct pm8xxx_adc_chan_result *adc_chan_result) -{ - int64_t bat_voltage = 0; - - bat_voltage = pm8xxx_adc_scale_ratiometric_calib(adc_code, - adc_properties, chan_properties); - - return pm8xxx_adc_map_batt_therm( - adcmap_btm_threshold, - ARRAY_SIZE(adcmap_btm_threshold), - bat_voltage, - &adc_chan_result->physical); -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_scale_batt_therm); - -int32_t pm8xxx_adc_scale_pa_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties, - struct pm8xxx_adc_chan_result *adc_chan_result) -{ - int64_t pa_voltage = 0; - - pa_voltage = pm8xxx_adc_scale_ratiometric_calib(adc_code, - adc_properties, chan_properties); - - return pm8xxx_adc_map_linear( - adcmap_pa_therm, - ARRAY_SIZE(adcmap_pa_therm), - pa_voltage, - &adc_chan_result->physical); -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_scale_pa_therm); - -int32_t pm8xxx_adc_scale_batt_id(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties, - struct pm8xxx_adc_chan_result *adc_chan_result) -{ - int64_t batt_id_voltage = 0; - - batt_id_voltage = pm8xxx_adc_scale_ratiometric_calib(adc_code, - adc_properties, chan_properties); - adc_chan_result->physical = batt_id_voltage; - adc_chan_result->physical = adc_chan_result->measurement; - - return 0; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_scale_batt_id); - -int32_t pm8xxx_adc_scale_pmic_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties, - struct pm8xxx_adc_chan_result *adc_chan_result) -{ - int64_t pmic_voltage = 0; - bool negative_offset = 0; - - if (!chan_properties || !chan_properties->offset_gain_numerator || - !chan_properties->offset_gain_denominator || !adc_properties - || !adc_chan_result) - return -EINVAL; - - pmic_voltage = (adc_code - - chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].adc_gnd) - * chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].dx; - if (pmic_voltage < 0) { - negative_offset = 1; - pmic_voltage = -pmic_voltage; - } - do_div(pmic_voltage, - chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].dy); - if (negative_offset) - pmic_voltage = -pmic_voltage; - pmic_voltage += chan_properties->adc_graph[ADC_CALIB_ABSOLUTE].dx; - - if (pmic_voltage > 0) { - /* 2mV/K */ - adc_chan_result->measurement = pmic_voltage* - chan_properties->offset_gain_denominator; - - do_div(adc_chan_result->measurement, - chan_properties->offset_gain_numerator * 2); - } else { - adc_chan_result->measurement = 0; - } - /* Change to .001 deg C */ - adc_chan_result->measurement -= KELVINMIL_DEGMIL; - adc_chan_result->physical = (int32_t)adc_chan_result->measurement; - - return 0; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_scale_pmic_therm); - -/* Scales the ADC code to 0.001 degrees C using the map - * table for the XO thermistor. - */ -int32_t pm8xxx_adc_tdkntcg_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties, - struct pm8xxx_adc_chan_result *adc_chan_result) -{ - int64_t xo_thm = 0; - uint32_t num1 = 0; - uint32_t num2 = 0; - uint32_t dnum = 0; - uint32_t rt_r25 = 0; - - if (!chan_properties || !chan_properties->offset_gain_numerator || - !chan_properties->offset_gain_denominator || !adc_properties - || !adc_chan_result) - return -EINVAL; - - xo_thm = pm8xxx_adc_scale_ratiometric_calib(adc_code, - adc_properties, chan_properties); - if (xo_thm < 0) - xo_thm = -xo_thm; - - num1 = xo_thm << 14; - num2 = (adc_properties->adc_vdd_reference - xo_thm) >> 1; - dnum = (adc_properties->adc_vdd_reference - xo_thm); - - if (dnum == 0) - rt_r25 = 0x7FFFFFFF ; - else - rt_r25 = (num1 + num2)/dnum ; - - pm8xxx_adc_map_linear(adcmap_ntcg_104ef_104fb, - ARRAY_SIZE(adcmap_ntcg_104ef_104fb), - rt_r25, &adc_chan_result->physical); - - return 0; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_tdkntcg_therm); - -int32_t pm8xxx_adc_batt_scaler(struct pm8xxx_adc_arb_btm_param *btm_param, - const struct pm8xxx_adc_properties *adc_properties, - const struct pm8xxx_adc_chan_properties *chan_properties) -{ - int rc; - - rc = pm8xxx_adc_map_linear( - adcmap_btm_threshold, - ARRAY_SIZE(adcmap_btm_threshold), - (btm_param->low_thr_temp), - &btm_param->low_thr_voltage); - if (rc) - return rc; - - btm_param->low_thr_voltage *= - chan_properties->adc_graph[ADC_CALIB_RATIOMETRIC].dy; - do_div(btm_param->low_thr_voltage, adc_properties->adc_vdd_reference); - btm_param->low_thr_voltage += - chan_properties->adc_graph[ADC_CALIB_RATIOMETRIC].adc_gnd; - - rc = pm8xxx_adc_map_linear( - adcmap_btm_threshold, - ARRAY_SIZE(adcmap_btm_threshold), - (btm_param->high_thr_temp), - &btm_param->high_thr_voltage); - if (rc) - return rc; - - btm_param->high_thr_voltage *= - chan_properties->adc_graph[ADC_CALIB_RATIOMETRIC].dy; - do_div(btm_param->high_thr_voltage, adc_properties->adc_vdd_reference); - btm_param->high_thr_voltage += - chan_properties->adc_graph[ADC_CALIB_RATIOMETRIC].adc_gnd; - - - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_batt_scaler); diff --git a/drivers/hwmon/pm8xxx-adc.c b/drivers/hwmon/pm8xxx-adc.c deleted file mode 100644 index f9d392b1fbd7b080ff33ff31bea9716e69af0b2d..0000000000000000000000000000000000000000 --- a/drivers/hwmon/pm8xxx-adc.c +++ /dev/null @@ -1,1332 +0,0 @@ -/* - * Copyright (c) 2011-2013, 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. - * - * Qualcomm's PM8921/PM8018 ADC Arbiter driver - */ -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* User Bank register set */ -#define PM8XXX_ADC_ARB_USRP_CNTRL1 0x197 -#define PM8XXX_ADC_ARB_USRP_CNTRL1_EN_ARB BIT(0) -#define PM8XXX_ADC_ARB_USRP_CNTRL1_RSV1 BIT(1) -#define PM8XXX_ADC_ARB_USRP_CNTRL1_RSV2 BIT(2) -#define PM8XXX_ADC_ARB_USRP_CNTRL1_RSV3 BIT(3) -#define PM8XXX_ADC_ARB_USRP_CNTRL1_RSV4 BIT(4) -#define PM8XXX_ADC_ARB_USRP_CNTRL1_RSV5 BIT(5) -#define PM8XXX_ADC_ARB_USRP_CNTRL1_EOC BIT(6) -#define PM8XXX_ADC_ARB_USRP_CNTRL1_REQ BIT(7) - -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL 0x198 -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_RSV0 BIT(0) -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_RSV1 BIT(1) -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_PREMUX0 BIT(2) -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_PREMUX1 BIT(3) -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_SEL0 BIT(4) -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_SEL1 BIT(5) -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_SEL2 BIT(6) -#define PM8XXX_ADC_ARB_USRP_AMUX_CNTRL_SEL3 BIT(7) - -#define PM8XXX_ADC_ARB_USRP_ANA_PARAM 0x199 -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM 0x19A -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_SEL_SHIFT0 BIT(0) -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_SEL_SHIFT1 BIT(1) -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_CLK_RATE0 BIT(2) -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_CLK_RATE1 BIT(3) -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_EOC BIT(4) -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_DEC_RATE0 BIT(5) -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_DEC_RATE1 BIT(6) -#define PM8XXX_ADC_ARB_USRP_DIG_PARAM_EN BIT(7) - -#define PM8XXX_ADC_ARB_USRP_RSV 0x19B -#define PM8XXX_ADC_ARB_USRP_RSV_RST BIT(0) -#define PM8XXX_ADC_ARB_USRP_RSV_DTEST0 BIT(1) -#define PM8XXX_ADC_ARB_USRP_RSV_DTEST1 BIT(2) -#define PM8XXX_ADC_ARB_USRP_RSV_OP BIT(3) -#define PM8XXX_ADC_ARB_USRP_RSV_IP_SEL0 BIT(4) -#define PM8XXX_ADC_ARB_USRP_RSV_IP_SEL1 BIT(5) -#define PM8XXX_ADC_ARB_USRP_RSV_IP_SEL2 BIT(6) -#define PM8XXX_ADC_ARB_USRP_RSV_TRM BIT(7) - -#define PM8XXX_ADC_ARB_USRP_DATA0 0x19D -#define PM8XXX_ADC_ARB_USRP_DATA1 0x19C - -#define PM8XXX_ADC_ARB_BTM_CNTRL1 0x17e -#define PM8XXX_ADC_ARB_BTM_CNTRL1_EN_BTM BIT(0) -#define PM8XXX_ADC_ARB_BTM_CNTRL1_SEL_OP_MODE BIT(1) -#define PM8XXX_ADC_ARB_BTM_CNTRL1_MEAS_INTERVAL1 BIT(2) -#define PM8XXX_ADC_ARB_BTM_CNTRL1_MEAS_INTERVAL2 BIT(3) -#define PM8XXX_ADC_ARB_BTM_CNTRL1_MEAS_INTERVAL3 BIT(4) -#define PM8XXX_ADC_ARB_BTM_CNTRL1_MEAS_INTERVAL4 BIT(5) -#define PM8XXX_ADC_ARB_BTM_CNTRL1_EOC BIT(6) -#define PM8XXX_ADC_ARB_BTM_CNTRL1_REQ BIT(7) - -#define PM8XXX_ADC_ARB_BTM_CNTRL2 0x18c -#define PM8XXX_ADC_ARB_BTM_AMUX_CNTRL 0x17f -#define PM8XXX_ADC_ARB_BTM_ANA_PARAM 0x180 -#define PM8XXX_ADC_ARB_BTM_DIG_PARAM 0x181 -#define PM8XXX_ADC_ARB_BTM_RSV 0x182 -#define PM8XXX_ADC_ARB_BTM_DATA1 0x183 -#define PM8XXX_ADC_ARB_BTM_DATA0 0x184 -#define PM8XXX_ADC_ARB_BTM_BAT_COOL_THR1 0x185 -#define PM8XXX_ADC_ARB_BTM_BAT_COOL_THR0 0x186 -#define PM8XXX_ADC_ARB_BTM_BAT_WARM_THR1 0x187 -#define PM8XXX_ADC_ARB_BTM_BAT_WARM_THR0 0x188 - -#define PM8XXX_ADC_ARB_ANA_DIG 0xa0 -#define PM8XXX_ADC_BTM_RSV 0x10 -#define PM8XXX_ADC_AMUX_MPP_SEL 2 -#define PM8XXX_ADC_AMUX_SEL 4 -#define PM8XXX_ADC_RSV_IP_SEL 4 -#define PM8XXX_ADC_BTM_CHANNEL_SEL 4 -#define PM8XXX_MAX_CHANNEL_PROPERTIES 2 -#define PM8XXX_ADC_IRQ_0 0 -#define PM8XXX_ADC_IRQ_1 1 -#define PM8XXX_ADC_IRQ_2 2 -#define PM8XXX_ADC_BTM_INTERVAL_SEL_MASK 0xF -#define PM8XXX_ADC_BTM_INTERVAL_SEL_SHIFT 2 -#define PM8XXX_ADC_BTM_DECIMATION_SEL 5 -#define PM8XXX_ADC_MUL 10 -#define PM8XXX_ADC_CONV_TIME_MIN 2000 -#define PM8XXX_ADC_CONV_TIME_MAX 2100 -#define PM8XXX_ADC_MPP_SETTLE_TIME_MIN 200 -#define PM8XXX_ADC_MPP_SETTLE_TIME_MAX 200 -#define PM8XXX_ADC_PA_THERM_VREG_UV_MIN 1800000 -#define PM8XXX_ADC_PA_THERM_VREG_UV_MAX 1800000 -#define PM8XXX_ADC_PA_THERM_VREG_UA_LOAD 100000 -#define PM8XXX_ADC_HWMON_NAME_LENGTH 32 -#define PM8XXX_ADC_BTM_INTERVAL_MAX 0x14 -#define PM8XXX_ADC_COMPLETION_TIMEOUT (2 * HZ) - -struct pm8xxx_adc { - struct device *dev; - struct pm8xxx_adc_properties *adc_prop; - int adc_irq; - struct mutex adc_lock; - struct mutex mpp_adc_lock; - spinlock_t btm_lock; - uint32_t adc_num_board_channel; - struct completion adc_rslt_completion; - struct pm8xxx_adc_amux *adc_channel; - int btm_warm_irq; - int btm_cool_irq; - struct dentry *dent; - struct work_struct warm_work; - struct work_struct cool_work; - uint32_t mpp_base; - struct device *hwmon; - struct msm_xo_voter *adc_voter; - int msm_suspend_check; - struct pm8xxx_adc_amux_properties *conv; - struct pm8xxx_adc_arb_btm_param batt; - struct sensor_device_attribute sens_attr[0]; -}; - -struct pm8xxx_adc_amux_properties { - uint32_t amux_channel; - uint32_t decimation; - uint32_t amux_ip_rsv; - uint32_t amux_mpp_channel; - struct pm8xxx_adc_chan_properties chan_prop[0]; -}; - -static const struct pm8xxx_adc_scaling_ratio pm8xxx_amux_scaling_ratio[] = { - {1, 1}, - {1, 3}, - {1, 4}, - {1, 6} -}; - -static struct pm8xxx_adc *pmic_adc; -static struct regulator *pa_therm; - -static struct pm8xxx_adc_scale_fn adc_scale_fn[] = { - [ADC_SCALE_DEFAULT] = {pm8xxx_adc_scale_default}, - [ADC_SCALE_BATT_THERM] = {pm8xxx_adc_scale_batt_therm}, - [ADC_SCALE_PA_THERM] = {pm8xxx_adc_scale_pa_therm}, - [ADC_SCALE_PMIC_THERM] = {pm8xxx_adc_scale_pmic_therm}, - [ADC_SCALE_XOTHERM] = {pm8xxx_adc_tdkntcg_therm}, -}; - -/* On PM8921 ADC the MPP needs to first be configured -as an analog input to the AMUX pre-mux channel before -issuing a read request. PM8921 MPP 8 is mapped to AMUX8 -and is common between remote processor's. -On PM8018 ADC the MPP is directly connected to the AMUX -pre-mux. Therefore clients of the PM8018 MPP do not need -to configure the MPP as an analog input to the pre-mux. -Clients can directly issue request on the pre-mux AMUX -channel to read the ADC on the MPP */ -static struct pm8xxx_mpp_config_data pm8xxx_adc_mpp_config = { - .type = PM8XXX_MPP_TYPE_A_INPUT, - /* AMUX6 is dedicated to be used for apps processor */ - .level = PM8XXX_MPP_AIN_AMUX_CH6, - .control = PM8XXX_MPP_AOUT_CTRL_DISABLE, -}; - -/* MPP Configuration for default settings */ -static struct pm8xxx_mpp_config_data pm8xxx_adc_mpp_unconfig = { - .type = PM8XXX_MPP_TYPE_SINK, - .level = PM8XXX_MPP_AIN_AMUX_CH5, - .control = PM8XXX_MPP_AOUT_CTRL_DISABLE, -}; - -static bool pm8xxx_adc_calib_first_adc; -static bool pm8xxx_adc_initialized, pm8xxx_adc_calib_device_init; - -static int32_t pm8xxx_adc_check_channel_valid(uint32_t channel) -{ - if (channel < CHANNEL_VCOIN || - (channel > CHANNEL_MUXOFF && channel < ADC_MPP_1_ATEST_8) || - (channel > ADC_MPP_1_ATEST_7 && channel < ADC_MPP_2_ATEST_8) - || (channel >= ADC_CHANNEL_MAX_NUM)) - return -EBADF; - else - return 0; -} - -static int32_t pm8xxx_adc_arb_cntrl(uint32_t arb_cntrl, - uint32_t channel) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int i, rc; - u8 data_arb_cntrl = 0; - - if (arb_cntrl) { - if (adc_pmic->msm_suspend_check) - pr_err("PM8xxx ADC request made after suspend_noirq " - "with channel: %d\n", channel); - data_arb_cntrl |= PM8XXX_ADC_ARB_USRP_CNTRL1_EN_ARB; - } - - /* Write twice to the CNTRL register for the arbiter settings - to take into effect */ - for (i = 0; i < 2; i++) { - rc = pm8xxx_writeb(adc_pmic->dev->parent, - PM8XXX_ADC_ARB_USRP_CNTRL1, data_arb_cntrl); - if (rc < 0) { - pr_err("PM8xxx arb cntrl write failed with %d\n", rc); - return rc; - } - } - - if (arb_cntrl) { - data_arb_cntrl |= PM8XXX_ADC_ARB_USRP_CNTRL1_REQ; - INIT_COMPLETION(adc_pmic->adc_rslt_completion); - rc = pm8xxx_writeb(adc_pmic->dev->parent, - PM8XXX_ADC_ARB_USRP_CNTRL1, data_arb_cntrl); - } - - return 0; -} - -static int32_t pm8xxx_adc_patherm_power(bool on) -{ - int rc = 0; - - if (!pa_therm) { - pr_err("pm8xxx adc pa_therm not valid\n"); - return -EINVAL; - } - - if (on) { - rc = regulator_set_voltage(pa_therm, - PM8XXX_ADC_PA_THERM_VREG_UV_MIN, - PM8XXX_ADC_PA_THERM_VREG_UV_MAX); - if (rc < 0) { - pr_err("failed to set the voltage for " - "pa_therm with error %d\n", rc); - return rc; - } - - rc = regulator_set_optimum_mode(pa_therm, - PM8XXX_ADC_PA_THERM_VREG_UA_LOAD); - if (rc < 0) { - pr_err("failed to set optimum mode for " - "pa_therm with error %d\n", rc); - return rc; - } - - rc = regulator_enable(pa_therm); - if (rc < 0) { - pr_err("failed to enable pa_therm vreg " - "with error %d\n", rc); - return rc; - } - } else { - rc = regulator_disable(pa_therm); - if (rc < 0) { - pr_err("failed to disable pa_therm vreg " - "with error %d\n", rc); - return rc; - } - } - - return rc; -} - -static int32_t pm8xxx_adc_xo_vote(bool on) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - - if (on) - msm_xo_mode_vote(adc_pmic->adc_voter, MSM_XO_MODE_ON); - else - msm_xo_mode_vote(adc_pmic->adc_voter, MSM_XO_MODE_OFF); - - return 0; -} - -static int32_t pm8xxx_adc_channel_power_enable(uint32_t channel, - bool power_cntrl) -{ - int rc = 0; - - switch (channel) { - case ADC_MPP_1_AMUX8: - rc = pm8xxx_adc_patherm_power(power_cntrl); - break; - case CHANNEL_DIE_TEMP: - case CHANNEL_MUXOFF: - rc = pm8xxx_adc_xo_vote(power_cntrl); - break; - default: - break; - } - - return rc; -} - - -static uint32_t pm8xxx_adc_read_reg(uint32_t reg, u8 *data) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int rc; - - rc = pm8xxx_readb(adc_pmic->dev->parent, reg, data); - if (rc < 0) { - pr_err("PM8xxx adc read reg %d failed with %d\n", reg, rc); - return rc; - } - - return 0; -} - -static uint32_t pm8xxx_adc_write_reg(uint32_t reg, u8 data) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int rc; - - rc = pm8xxx_writeb(adc_pmic->dev->parent, reg, data); - if (rc < 0) { - pr_err("PM8xxx adc write reg %d failed with %d\n", reg, rc); - return rc; - } - - return 0; -} - -static int32_t pm8xxx_adc_configure( - struct pm8xxx_adc_amux_properties *chan_prop) -{ - u8 data_amux_chan = 0, data_arb_rsv = 0, data_dig_param = 0; - int rc; - - data_amux_chan |= chan_prop->amux_channel << PM8XXX_ADC_AMUX_SEL; - - if (chan_prop->amux_mpp_channel) - data_amux_chan |= chan_prop->amux_mpp_channel << - PM8XXX_ADC_AMUX_MPP_SEL; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_USRP_AMUX_CNTRL, - data_amux_chan); - if (rc < 0) - return rc; - - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_USRP_RSV, &data_arb_rsv); - if (rc < 0) - return rc; - - data_arb_rsv &= (PM8XXX_ADC_ARB_USRP_RSV_RST | - PM8XXX_ADC_ARB_USRP_RSV_DTEST0 | - PM8XXX_ADC_ARB_USRP_RSV_DTEST1 | - PM8XXX_ADC_ARB_USRP_RSV_OP); - data_arb_rsv |= (chan_prop->amux_ip_rsv << PM8XXX_ADC_RSV_IP_SEL | - PM8XXX_ADC_ARB_USRP_RSV_TRM); - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_USRP_RSV, data_arb_rsv); - if (rc < 0) - return rc; - - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_USRP_DIG_PARAM, - &data_dig_param); - if (rc < 0) - return rc; - - /* Default 2.4Mhz clock rate */ - /* Client chooses the decimation */ - switch (chan_prop->decimation) { - case ADC_DECIMATION_TYPE1: - data_dig_param |= PM8XXX_ADC_ARB_USRP_DIG_PARAM_DEC_RATE0; - break; - case ADC_DECIMATION_TYPE2: - data_dig_param |= (PM8XXX_ADC_ARB_USRP_DIG_PARAM_DEC_RATE0 - | PM8XXX_ADC_ARB_USRP_DIG_PARAM_DEC_RATE1); - break; - default: - data_dig_param |= PM8XXX_ADC_ARB_USRP_DIG_PARAM_DEC_RATE0; - break; - } - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_USRP_DIG_PARAM, - PM8XXX_ADC_ARB_ANA_DIG); - if (rc < 0) - return rc; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_USRP_ANA_PARAM, - PM8XXX_ADC_ARB_ANA_DIG); - if (rc < 0) - return rc; - - rc = pm8xxx_adc_arb_cntrl(1, data_amux_chan); - if (rc < 0) { - pr_err("Configuring ADC Arbiter" - "enable failed with %d\n", rc); - return rc; - } - - return 0; -} - -static uint32_t pm8xxx_adc_read_adc_code(int32_t *data) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - uint8_t rslt_lsb, rslt_msb; - int32_t rc, max_ideal_adc_code = 1 << adc_pmic->adc_prop->bitresolution; - - rc = pm8xxx_readb(adc_pmic->dev->parent, - PM8XXX_ADC_ARB_USRP_DATA0, &rslt_lsb); - if (rc < 0) { - pr_err("PM8xxx adc result read failed with %d\n", rc); - return rc; - } - - rc = pm8xxx_readb(adc_pmic->dev->parent, - PM8XXX_ADC_ARB_USRP_DATA1, &rslt_msb); - if (rc < 0) { - pr_err("PM8xxx adc result read failed with %d\n", rc); - return rc; - } - - *data = (rslt_msb << 8) | rslt_lsb; - - /* Use the midpoint to determine underflow or overflow */ - if (*data > max_ideal_adc_code + (max_ideal_adc_code >> 1)) - *data |= ((1 << (8 * sizeof(*data) - - adc_pmic->adc_prop->bitresolution)) - 1) << - adc_pmic->adc_prop->bitresolution; - - /* Default value for switching off the arbiter after reading - the ADC value. Bit 0 set to 0. */ - rc = pm8xxx_adc_arb_cntrl(0, CHANNEL_NONE); - if (rc < 0) { - pr_err("%s: Configuring ADC Arbiter disable" - "failed\n", __func__); - return rc; - } - - return 0; -} - -static void pm8xxx_adc_btm_warm_scheduler_fn(struct work_struct *work) -{ - struct pm8xxx_adc *adc_pmic = container_of(work, struct pm8xxx_adc, - warm_work); - unsigned long flags = 0; - bool warm_status; - - spin_lock_irqsave(&adc_pmic->btm_lock, flags); - warm_status = irq_read_line(adc_pmic->btm_warm_irq); - if (adc_pmic->batt.btm_warm_fn != NULL) - adc_pmic->batt.btm_warm_fn(warm_status); - spin_unlock_irqrestore(&adc_pmic->btm_lock, flags); -} - -static void pm8xxx_adc_btm_cool_scheduler_fn(struct work_struct *work) -{ - struct pm8xxx_adc *adc_pmic = container_of(work, struct pm8xxx_adc, - cool_work); - unsigned long flags = 0; - bool cool_status; - - spin_lock_irqsave(&adc_pmic->btm_lock, flags); - cool_status = irq_read_line(adc_pmic->btm_cool_irq); - if (adc_pmic->batt.btm_cool_fn != NULL) - adc_pmic->batt.btm_cool_fn(cool_status); - spin_unlock_irqrestore(&adc_pmic->btm_lock, flags); -} - -void trigger_completion(struct work_struct *work) -{ - struct pm8xxx_adc *adc_8xxx = pmic_adc; - - complete(&adc_8xxx->adc_rslt_completion); -} -DECLARE_WORK(trigger_completion_work, trigger_completion); - -static irqreturn_t pm8xxx_adc_isr(int irq, void *dev_id) -{ - - if (pm8xxx_adc_calib_first_adc) - return IRQ_HANDLED; - - schedule_work(&trigger_completion_work); - - return IRQ_HANDLED; -} - -static irqreturn_t pm8xxx_btm_warm_isr(int irq, void *dev_id) -{ - struct pm8xxx_adc *btm_8xxx = dev_id; - - schedule_work(&btm_8xxx->warm_work); - - return IRQ_HANDLED; -} - -static irqreturn_t pm8xxx_btm_cool_isr(int irq, void *dev_id) -{ - struct pm8xxx_adc *btm_8xxx = dev_id; - - schedule_work(&btm_8xxx->cool_work); - - return IRQ_HANDLED; -} - -static uint32_t pm8xxx_adc_calib_device(void) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - struct pm8xxx_adc_amux_properties conv; - int rc, calib_read_1, calib_read_2; - u8 data_arb_usrp_cntrl1 = 0; - - conv.amux_channel = CHANNEL_125V; - conv.decimation = ADC_DECIMATION_TYPE2; - conv.amux_ip_rsv = AMUX_RSV1; - conv.amux_mpp_channel = PREMUX_MPP_SCALE_0; - pm8xxx_adc_calib_first_adc = true; - rc = pm8xxx_adc_configure(&conv); - if (rc) { - pr_err("pm8xxx_adc configure failed with %d\n", rc); - goto calib_fail; - } - - while (data_arb_usrp_cntrl1 != (PM8XXX_ADC_ARB_USRP_CNTRL1_EOC | - PM8XXX_ADC_ARB_USRP_CNTRL1_EN_ARB)) { - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_USRP_CNTRL1, - &data_arb_usrp_cntrl1); - if (rc < 0) - return rc; - usleep_range(PM8XXX_ADC_CONV_TIME_MIN, - PM8XXX_ADC_CONV_TIME_MAX); - } - data_arb_usrp_cntrl1 = 0; - - rc = pm8xxx_adc_read_adc_code(&calib_read_1); - if (rc) { - pr_err("pm8xxx_adc read adc failed with %d\n", rc); - pm8xxx_adc_calib_first_adc = false; - goto calib_fail; - } - pm8xxx_adc_calib_first_adc = false; - - conv.amux_channel = CHANNEL_625MV; - conv.decimation = ADC_DECIMATION_TYPE2; - conv.amux_ip_rsv = AMUX_RSV1; - conv.amux_mpp_channel = PREMUX_MPP_SCALE_0; - pm8xxx_adc_calib_first_adc = true; - rc = pm8xxx_adc_configure(&conv); - if (rc) { - pr_err("pm8xxx_adc configure failed with %d\n", rc); - goto calib_fail; - } - - while (data_arb_usrp_cntrl1 != (PM8XXX_ADC_ARB_USRP_CNTRL1_EOC | - PM8XXX_ADC_ARB_USRP_CNTRL1_EN_ARB)) { - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_USRP_CNTRL1, - &data_arb_usrp_cntrl1); - if (rc < 0) - return rc; - usleep_range(PM8XXX_ADC_CONV_TIME_MIN, - PM8XXX_ADC_CONV_TIME_MAX); - } - data_arb_usrp_cntrl1 = 0; - - rc = pm8xxx_adc_read_adc_code(&calib_read_2); - if (rc) { - pr_err("pm8xxx_adc read adc failed with %d\n", rc); - pm8xxx_adc_calib_first_adc = false; - goto calib_fail; - } - pm8xxx_adc_calib_first_adc = false; - - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_ABSOLUTE].dy = - (calib_read_1 - calib_read_2); - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_ABSOLUTE].dx - = PM8XXX_CHANNEL_ADC_625_UV; - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_ABSOLUTE].adc_vref = - calib_read_1; - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_ABSOLUTE].adc_gnd = - calib_read_2; - rc = pm8xxx_adc_arb_cntrl(0, CHANNEL_NONE); - if (rc < 0) { - pr_err("%s: Configuring ADC Arbiter disable" - "failed\n", __func__); - return rc; - } - /* Ratiometric Calibration */ - conv.amux_channel = CHANNEL_MUXOFF; - conv.decimation = ADC_DECIMATION_TYPE2; - conv.amux_ip_rsv = AMUX_RSV5; - conv.amux_mpp_channel = PREMUX_MPP_SCALE_0; - pm8xxx_adc_calib_first_adc = true; - rc = pm8xxx_adc_configure(&conv); - if (rc) { - pr_err("pm8xxx_adc configure failed with %d\n", rc); - goto calib_fail; - } - - while (data_arb_usrp_cntrl1 != (PM8XXX_ADC_ARB_USRP_CNTRL1_EOC | - PM8XXX_ADC_ARB_USRP_CNTRL1_EN_ARB)) { - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_USRP_CNTRL1, - &data_arb_usrp_cntrl1); - if (rc < 0) - return rc; - usleep_range(PM8XXX_ADC_CONV_TIME_MIN, - PM8XXX_ADC_CONV_TIME_MAX); - } - data_arb_usrp_cntrl1 = 0; - - rc = pm8xxx_adc_read_adc_code(&calib_read_1); - if (rc) { - pr_err("pm8xxx_adc read adc failed with %d\n", rc); - pm8xxx_adc_calib_first_adc = false; - goto calib_fail; - } - pm8xxx_adc_calib_first_adc = false; - - conv.amux_channel = CHANNEL_MUXOFF; - conv.decimation = ADC_DECIMATION_TYPE2; - conv.amux_ip_rsv = AMUX_RSV4; - conv.amux_mpp_channel = PREMUX_MPP_SCALE_0; - pm8xxx_adc_calib_first_adc = true; - rc = pm8xxx_adc_configure(&conv); - if (rc) { - pr_err("pm8xxx_adc configure failed with %d\n", rc); - goto calib_fail; - } - - while (data_arb_usrp_cntrl1 != (PM8XXX_ADC_ARB_USRP_CNTRL1_EOC | - PM8XXX_ADC_ARB_USRP_CNTRL1_EN_ARB)) { - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_USRP_CNTRL1, - &data_arb_usrp_cntrl1); - if (rc < 0) - return rc; - usleep_range(PM8XXX_ADC_CONV_TIME_MIN, - PM8XXX_ADC_CONV_TIME_MAX); - } - data_arb_usrp_cntrl1 = 0; - - rc = pm8xxx_adc_read_adc_code(&calib_read_2); - if (rc) { - pr_err("pm8xxx_adc read adc failed with %d\n", rc); - pm8xxx_adc_calib_first_adc = false; - goto calib_fail; - } - pm8xxx_adc_calib_first_adc = false; - - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_RATIOMETRIC].dy = - (calib_read_1 - calib_read_2); - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_RATIOMETRIC].dx = - adc_pmic->adc_prop->adc_vdd_reference; - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_RATIOMETRIC].adc_vref = - calib_read_1; - adc_pmic->conv->chan_prop->adc_graph[ADC_CALIB_RATIOMETRIC].adc_gnd = - calib_read_2; -calib_fail: - rc = pm8xxx_adc_arb_cntrl(0, CHANNEL_NONE); - if (rc < 0) { - pr_err("%s: Configuring ADC Arbiter disable" - "failed\n", __func__); - } - - return rc; -} - -uint32_t pm8xxx_adc_read(enum pm8xxx_adc_channels channel, - struct pm8xxx_adc_chan_result *result) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int i = 0, rc = 0, rc_fail, amux_prescaling, scale_type; - enum pm8xxx_adc_premux_mpp_scale_type mpp_scale; - - if (!pm8xxx_adc_initialized) - return -ENODEV; - - if (!pm8xxx_adc_calib_device_init) { - if (pm8xxx_adc_calib_device() == 0) - pm8xxx_adc_calib_device_init = true; - } - - mutex_lock(&adc_pmic->adc_lock); - - for (i = 0; i < adc_pmic->adc_num_board_channel; i++) { - if (channel == adc_pmic->adc_channel[i].channel_name) - break; - } - - if (i == adc_pmic->adc_num_board_channel || - (pm8xxx_adc_check_channel_valid(channel) != 0)) { - rc = -EBADF; - goto fail_unlock; - } - - if (channel < PM8XXX_CHANNEL_MPP_SCALE1_IDX) { - mpp_scale = PREMUX_MPP_SCALE_0; - adc_pmic->conv->amux_channel = channel; - } else if (channel >= PM8XXX_CHANNEL_MPP_SCALE1_IDX && - channel < PM8XXX_CHANNEL_MPP_SCALE3_IDX) { - mpp_scale = PREMUX_MPP_SCALE_1; - adc_pmic->conv->amux_channel = channel % - PM8XXX_CHANNEL_MPP_SCALE1_IDX; - } else { - mpp_scale = PREMUX_MPP_SCALE_1_DIV3; - adc_pmic->conv->amux_channel = channel % - PM8XXX_CHANNEL_MPP_SCALE3_IDX; - } - - adc_pmic->conv->amux_mpp_channel = mpp_scale; - adc_pmic->conv->amux_ip_rsv = adc_pmic->adc_channel[i].adc_rsv; - adc_pmic->conv->decimation = adc_pmic->adc_channel[i].adc_decimation; - amux_prescaling = adc_pmic->adc_channel[i].chan_path_prescaling; - - adc_pmic->conv->chan_prop->offset_gain_numerator = - pm8xxx_amux_scaling_ratio[amux_prescaling].num; - adc_pmic->conv->chan_prop->offset_gain_denominator = - pm8xxx_amux_scaling_ratio[amux_prescaling].den; - - rc = pm8xxx_adc_channel_power_enable(channel, true); - if (rc) { - rc = -EINVAL; - goto fail_unlock; - } - - rc = pm8xxx_adc_configure(adc_pmic->conv); - if (rc) { - rc = -EINVAL; - goto fail; - } - - rc = wait_for_completion_timeout(&adc_pmic->adc_rslt_completion, - PM8XXX_ADC_COMPLETION_TIMEOUT); - if (!rc) { - u8 data_arb_usrp_cntrl1 = 0; - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_USRP_CNTRL1, - &data_arb_usrp_cntrl1); - if (rc < 0) - goto fail; - if (data_arb_usrp_cntrl1 == (PM8XXX_ADC_ARB_USRP_CNTRL1_EOC | - PM8XXX_ADC_ARB_USRP_CNTRL1_EN_ARB)) - pr_debug("End of conversion status set\n"); - else { - pr_err("EOC interrupt not received\n"); - rc = -EINVAL; - goto fail; - } - } - - rc = pm8xxx_adc_read_adc_code(&result->adc_code); - if (rc) { - rc = -EINVAL; - goto fail; - } - - scale_type = adc_pmic->adc_channel[i].adc_scale_fn; - if (scale_type >= ADC_SCALE_NONE) { - rc = -EBADF; - goto fail; - } - - adc_scale_fn[scale_type].chan(result->adc_code, - adc_pmic->adc_prop, adc_pmic->conv->chan_prop, result); - - rc = pm8xxx_adc_channel_power_enable(channel, false); - if (rc) { - rc = -EINVAL; - goto fail_unlock; - } - - mutex_unlock(&adc_pmic->adc_lock); - - return 0; -fail: - rc_fail = pm8xxx_adc_channel_power_enable(channel, false); - if (rc_fail) - pr_err("pm8xxx adc power disable failed\n"); -fail_unlock: - mutex_unlock(&adc_pmic->adc_lock); - pr_err("pm8xxx adc error with %d\n", rc); - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_read); - -uint32_t pm8xxx_adc_mpp_config_read(uint32_t mpp_num, - enum pm8xxx_adc_channels channel, - struct pm8xxx_adc_chan_result *result) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int rc = 0; - - if (!pm8xxx_adc_initialized) - return -ENODEV; - - if (!adc_pmic->mpp_base) { - rc = -EINVAL; - pr_info("PM8xxx MPP base invalid with error %d\n", rc); - return rc; - } - - if (mpp_num == PM8XXX_AMUX_MPP_8) { - rc = -EINVAL; - pr_info("PM8xxx MPP8 is already configured " - "to AMUX8. Use pm8xxx_adc_read() instead.\n"); - return rc; - } - - mutex_lock(&adc_pmic->mpp_adc_lock); - - rc = pm8xxx_mpp_config(((mpp_num - 1) + adc_pmic->mpp_base), - &pm8xxx_adc_mpp_config); - if (rc < 0) { - pr_err("pm8xxx adc mpp config error with %d\n", rc); - goto fail; - } - - usleep_range(PM8XXX_ADC_MPP_SETTLE_TIME_MIN, - PM8XXX_ADC_MPP_SETTLE_TIME_MAX); - - rc = pm8xxx_adc_read(channel, result); - if (rc < 0) - pr_err("pm8xxx adc read error with %d\n", rc); - - rc = pm8xxx_mpp_config(((mpp_num - 1) + adc_pmic->mpp_base), - &pm8xxx_adc_mpp_unconfig); - if (rc < 0) - pr_err("pm8xxx adc mpp config error with %d\n", rc); -fail: - mutex_unlock(&adc_pmic->mpp_adc_lock); - - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_mpp_config_read); - -uint32_t pm8xxx_adc_btm_configure(struct pm8xxx_adc_arb_btm_param *btm_param) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - u8 data_btm_cool_thr0, data_btm_cool_thr1; - u8 data_btm_warm_thr0, data_btm_warm_thr1; - u8 arb_btm_cntrl1; - unsigned long flags = 0; - int rc; - - if (adc_pmic == NULL) { - pr_err("PMIC ADC not valid\n"); - return -EINVAL; - } - - if ((btm_param->btm_cool_fn == NULL) && - (btm_param->btm_warm_fn == NULL)) { - pr_err("No BTM warm/cool notification??\n"); - return -EINVAL; - } - - rc = pm8xxx_adc_batt_scaler(btm_param, adc_pmic->adc_prop, - adc_pmic->conv->chan_prop); - if (rc < 0) { - pr_err("Failed to lookup the BTM thresholds\n"); - return rc; - } - - if (btm_param->interval > PM8XXX_ADC_BTM_INTERVAL_MAX) { - pr_info("Bug in PMIC BTM interval time and cannot set" - " a value greater than 0x14 %x\n", btm_param->interval); - btm_param->interval = PM8XXX_ADC_BTM_INTERVAL_MAX; - } - - spin_lock_irqsave(&adc_pmic->btm_lock, flags); - - data_btm_cool_thr0 = ((btm_param->low_thr_voltage << 24) >> 24); - data_btm_cool_thr1 = ((btm_param->low_thr_voltage << 16) >> 24); - data_btm_warm_thr0 = ((btm_param->high_thr_voltage << 24) >> 24); - data_btm_warm_thr1 = ((btm_param->high_thr_voltage << 16) >> 24); - - if (btm_param->btm_cool_fn != NULL) { - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_BAT_COOL_THR0, - data_btm_cool_thr0); - if (rc < 0) - goto write_err; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_BAT_COOL_THR1, - data_btm_cool_thr1); - if (rc < 0) - goto write_err; - - adc_pmic->batt.btm_cool_fn = btm_param->btm_cool_fn; - } - - if (btm_param->btm_warm_fn != NULL) { - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_BAT_WARM_THR0, - data_btm_warm_thr0); - if (rc < 0) - goto write_err; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_BAT_WARM_THR1, - data_btm_warm_thr1); - if (rc < 0) - goto write_err; - - adc_pmic->batt.btm_warm_fn = btm_param->btm_warm_fn; - } - - rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_BTM_CNTRL1, &arb_btm_cntrl1); - if (rc < 0) - goto bail_out; - - btm_param->interval &= PM8XXX_ADC_BTM_INTERVAL_SEL_MASK; - arb_btm_cntrl1 |= - btm_param->interval << PM8XXX_ADC_BTM_INTERVAL_SEL_SHIFT; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_CNTRL1, arb_btm_cntrl1); - if (rc < 0) - goto write_err; - - spin_unlock_irqrestore(&adc_pmic->btm_lock, flags); - - return rc; -bail_out: -write_err: - spin_unlock_irqrestore(&adc_pmic->btm_lock, flags); - pr_debug("%s: with error code %d\n", __func__, rc); - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_btm_configure); - -static uint32_t pm8xxx_adc_btm_read(uint32_t channel) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int rc, i; - u8 arb_btm_dig_param, arb_btm_ana_param, arb_btm_rsv; - u8 arb_btm_amux_cntrl, data_arb_btm_cntrl = 0; - unsigned long flags; - - arb_btm_amux_cntrl = channel << PM8XXX_ADC_BTM_CHANNEL_SEL; - arb_btm_rsv = adc_pmic->adc_channel[channel].adc_rsv; - arb_btm_dig_param = arb_btm_ana_param = PM8XXX_ADC_ARB_ANA_DIG; - - spin_lock_irqsave(&adc_pmic->btm_lock, flags); - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_AMUX_CNTRL, - arb_btm_amux_cntrl); - if (rc < 0) - goto write_err; - - arb_btm_rsv = PM8XXX_ADC_BTM_RSV; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_RSV, arb_btm_rsv); - if (rc < 0) - goto write_err; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_DIG_PARAM, - arb_btm_dig_param); - if (rc < 0) - goto write_err; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_ANA_PARAM, - arb_btm_ana_param); - if (rc < 0) - goto write_err; - - data_arb_btm_cntrl |= PM8XXX_ADC_ARB_BTM_CNTRL1_EN_BTM; - - for (i = 0; i < 2; i++) { - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_CNTRL1, - data_arb_btm_cntrl); - if (rc < 0) - goto write_err; - } - - data_arb_btm_cntrl |= PM8XXX_ADC_ARB_BTM_CNTRL1_REQ - | PM8XXX_ADC_ARB_BTM_CNTRL1_SEL_OP_MODE; - - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_CNTRL1, - data_arb_btm_cntrl); - if (rc < 0) - goto write_err; - - if (pmic_adc->batt.btm_warm_fn != NULL) - enable_irq(adc_pmic->btm_warm_irq); - - if (pmic_adc->batt.btm_cool_fn != NULL) - enable_irq(adc_pmic->btm_cool_irq); - -write_err: - spin_unlock_irqrestore(&adc_pmic->btm_lock, flags); - return rc; -} - -uint32_t pm8xxx_adc_btm_start(void) -{ - return pm8xxx_adc_btm_read(CHANNEL_BATT_THERM); -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_btm_start); - -uint32_t pm8xxx_adc_btm_end(void) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int i, rc; - u8 data_arb_btm_cntrl = 0; - unsigned long flags; - - disable_irq_nosync(adc_pmic->btm_warm_irq); - disable_irq_nosync(adc_pmic->btm_cool_irq); - - spin_lock_irqsave(&adc_pmic->btm_lock, flags); - - /* Write twice to the CNTRL register for the arbiter settings - to take into effect */ - for (i = 0; i < 2; i++) { - rc = pm8xxx_adc_write_reg(PM8XXX_ADC_ARB_BTM_CNTRL1, - data_arb_btm_cntrl); - if (rc < 0) { - spin_unlock_irqrestore(&adc_pmic->btm_lock, flags); - return rc; - } - } - - spin_unlock_irqrestore(&adc_pmic->btm_lock, flags); - - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_adc_btm_end); - -static ssize_t pm8xxx_adc_show(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct pm8xxx_adc_chan_result result; - int rc = -1; - - rc = pm8xxx_adc_read(attr->index, &result); - - if (rc) - return 0; - - return snprintf(buf, PM8XXX_ADC_HWMON_NAME_LENGTH, - "Result:%lld Raw:%d\n", result.physical, result.adc_code); -} - -static int get_adc(void *data, u64 *val) -{ - struct pm8xxx_adc_chan_result result; - int i = (int)data; - int rc; - - rc = pm8xxx_adc_read(i, &result); - if (!rc) - pr_info("ADC value raw:%x physical:%lld\n", - result.adc_code, result.physical); - *val = result.physical; - - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(reg_fops, get_adc, NULL, "%lld\n"); - -#ifdef CONFIG_DEBUG_FS -static void create_debugfs_entries(void) -{ - int i = 0; - pmic_adc->dent = debugfs_create_dir("pm8xxx_adc", NULL); - - if (IS_ERR(pmic_adc->dent)) { - pr_err("pmic adc debugfs dir not created\n"); - return; - } - - for (i = 0; i < pmic_adc->adc_num_board_channel; i++) - debugfs_create_file(pmic_adc->adc_channel[i].name, - 0644, pmic_adc->dent, - (void *)pmic_adc->adc_channel[i].channel_name, - ®_fops); -} -#else -static inline void create_debugfs_entries(void) -{ -} -#endif -static struct sensor_device_attribute pm8xxx_adc_attr = - SENSOR_ATTR(NULL, S_IRUGO, pm8xxx_adc_show, NULL, 0); - -static int32_t pm8xxx_adc_init_hwmon(struct platform_device *pdev) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int rc = 0, i, channel; - - for (i = 0; i < pmic_adc->adc_num_board_channel; i++) { - channel = adc_pmic->adc_channel[i].channel_name; - if (pm8xxx_adc_check_channel_valid(channel)) { - pr_err("Invalid ADC init HWMON channel: %d\n", channel); - continue; - } - pm8xxx_adc_attr.index = adc_pmic->adc_channel[i].channel_name; - pm8xxx_adc_attr.dev_attr.attr.name = - adc_pmic->adc_channel[i].name; - memcpy(&adc_pmic->sens_attr[i], &pm8xxx_adc_attr, - sizeof(pm8xxx_adc_attr)); - sysfs_attr_init(&adc_pmic->sens_attr[i].dev_attr.attr); - rc = device_create_file(&pdev->dev, - &adc_pmic->sens_attr[i].dev_attr); - if (rc) { - dev_err(&pdev->dev, "device_create_file failed for " - "dev %s\n", - adc_pmic->adc_channel[i].name); - goto hwmon_err_sens; - } - } - - return 0; -hwmon_err_sens: - pr_info("Init HWMON failed for pm8xxx_adc with %d\n", rc); - return rc; -} - -#ifdef CONFIG_PM -static int pm8xxx_adc_suspend_noirq(struct device *dev) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - - adc_pmic->msm_suspend_check = 1; - - return 0; -} - -static int pm8xxx_adc_resume_noirq(struct device *dev) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - - adc_pmic->msm_suspend_check = 0; - - return 0; -} - -static const struct dev_pm_ops pm8xxx_adc_dev_pm_ops = { - .suspend_noirq = pm8xxx_adc_suspend_noirq, - .resume_noirq = pm8xxx_adc_resume_noirq, -}; - -#define PM8XXX_ADC_DEV_PM_OPS (&pm8xxx_adc_dev_pm_ops) -#else -#define PM8XXX_ADC_DEV_PM_OPS NULL -#endif - -static int pm8xxx_adc_teardown(struct platform_device *pdev) -{ - struct pm8xxx_adc *adc_pmic = pmic_adc; - int i; - - msm_xo_put(adc_pmic->adc_voter); - platform_set_drvdata(pdev, NULL); - pmic_adc = NULL; - if (!pa_therm) { - regulator_put(pa_therm); - pa_therm = NULL; - } - for (i = 0; i < adc_pmic->adc_num_board_channel; i++) - device_remove_file(adc_pmic->dev, - &adc_pmic->sens_attr[i].dev_attr); - pm8xxx_adc_initialized = false; - - return 0; -} - -static int pm8xxx_adc_probe(struct platform_device *pdev) -{ - const struct pm8xxx_adc_platform_data *pdata = pdev->dev.platform_data; - struct pm8xxx_adc *adc_pmic; - struct pm8xxx_adc_amux_properties *adc_amux_prop; - int rc = 0; - - if (!pdata) { - dev_err(&pdev->dev, "no platform data?\n"); - return -EINVAL; - } - - adc_pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8xxx_adc) + - (sizeof(struct sensor_device_attribute) * - pdata->adc_num_board_channel), GFP_KERNEL); - if (!adc_pmic) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - adc_amux_prop = devm_kzalloc(&pdev->dev, - sizeof(struct pm8xxx_adc_amux_properties) + - sizeof(struct pm8xxx_adc_chan_properties) - , GFP_KERNEL); - if (!adc_amux_prop) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - adc_pmic->dev = &pdev->dev; - adc_pmic->adc_prop = pdata->adc_prop; - adc_pmic->conv = adc_amux_prop; - init_completion(&adc_pmic->adc_rslt_completion); - adc_pmic->adc_channel = pdata->adc_channel; - adc_pmic->adc_num_board_channel = pdata->adc_num_board_channel; - adc_pmic->mpp_base = pdata->adc_mpp_base; - - mutex_init(&adc_pmic->adc_lock); - mutex_init(&adc_pmic->mpp_adc_lock); - spin_lock_init(&adc_pmic->btm_lock); - - adc_pmic->adc_irq = platform_get_irq(pdev, PM8XXX_ADC_IRQ_0); - if (adc_pmic->adc_irq < 0) - return adc_pmic->adc_irq; - - rc = devm_request_irq(&pdev->dev, adc_pmic->adc_irq, - pm8xxx_adc_isr, - IRQF_TRIGGER_RISING, "pm8xxx_adc_interrupt", adc_pmic); - if (rc) { - dev_err(&pdev->dev, "failed to request adc irq " - "with error %d\n", rc); - } else { - enable_irq_wake(adc_pmic->adc_irq); - } - - adc_pmic->btm_warm_irq = platform_get_irq(pdev, PM8XXX_ADC_IRQ_1); - if (adc_pmic->btm_warm_irq < 0) - return adc_pmic->btm_warm_irq; - - rc = devm_request_irq(&pdev->dev, adc_pmic->btm_warm_irq, - pm8xxx_btm_warm_isr, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - "pm8xxx_btm_warm_interrupt", adc_pmic); - if (rc) { - pr_err("btm warm irq failed %d with interrupt number %d\n", - rc, adc_pmic->btm_warm_irq); - dev_err(&pdev->dev, "failed to request btm irq\n"); - } - - disable_irq_nosync(adc_pmic->btm_warm_irq); - - adc_pmic->btm_cool_irq = platform_get_irq(pdev, PM8XXX_ADC_IRQ_2); - if (adc_pmic->btm_cool_irq < 0) - return adc_pmic->btm_cool_irq; - - rc = devm_request_irq(&pdev->dev, adc_pmic->btm_cool_irq, - pm8xxx_btm_cool_isr, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - "pm8xxx_btm_cool_interrupt", adc_pmic); - if (rc) { - pr_err("btm cool irq failed with return %d and number %d\n", - rc, adc_pmic->btm_cool_irq); - dev_err(&pdev->dev, "failed to request btm irq\n"); - } - - disable_irq_nosync(adc_pmic->btm_cool_irq); - platform_set_drvdata(pdev, adc_pmic); - adc_pmic->msm_suspend_check = 0; - pmic_adc = adc_pmic; - - INIT_WORK(&adc_pmic->warm_work, pm8xxx_adc_btm_warm_scheduler_fn); - INIT_WORK(&adc_pmic->cool_work, pm8xxx_adc_btm_cool_scheduler_fn); - create_debugfs_entries(); - pm8xxx_adc_calib_first_adc = false; - pm8xxx_adc_calib_device_init = false; - pm8xxx_adc_initialized = true; - - rc = pm8xxx_adc_init_hwmon(pdev); - if (rc) { - pr_err("pm8xxx adc init hwmon failed with %d\n", rc); - dev_err(&pdev->dev, "failed to initialize pm8xxx hwmon adc\n"); - } - adc_pmic->hwmon = hwmon_device_register(adc_pmic->dev); - - if (adc_pmic->adc_voter == NULL) { - adc_pmic->adc_voter = msm_xo_get(MSM_XO_TCXO_D0, "pmic_xoadc"); - if (IS_ERR(adc_pmic->adc_voter)) { - dev_err(&pdev->dev, "Failed to get XO vote\n"); - return PTR_ERR(adc_pmic->adc_voter); - } - } - - pa_therm = regulator_get(adc_pmic->dev, "pa_therm"); - if (IS_ERR(pa_therm)) { - rc = PTR_ERR(pa_therm); - pr_err("failed to request pa_therm vreg with error %d\n", rc); - pa_therm = NULL; - } - return 0; -} - -static struct platform_driver pm8xxx_adc_driver = { - .probe = pm8xxx_adc_probe, - .remove = pm8xxx_adc_teardown, - .driver = { - .name = PM8XXX_ADC_DEV_NAME, - .owner = THIS_MODULE, - .pm = PM8XXX_ADC_DEV_PM_OPS, - }, -}; - -static int __init pm8xxx_adc_init(void) -{ - return platform_driver_register(&pm8xxx_adc_driver); -} -module_init(pm8xxx_adc_init); - -static void __exit pm8xxx_adc_exit(void) -{ - platform_driver_unregister(&pm8xxx_adc_driver); -} -module_exit(pm8xxx_adc_exit); - -MODULE_ALIAS("platform:" PM8XXX_ADC_DEV_NAME); -MODULE_DESCRIPTION("PMIC8921/8018 ADC driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/hwmon/wpce775x.c b/drivers/hwmon/wpce775x.c deleted file mode 100644 index bf1f6f0a002481d21dbd9fb7d06366d524519cc6..0000000000000000000000000000000000000000 --- a/drivers/hwmon/wpce775x.c +++ /dev/null @@ -1,167 +0,0 @@ -/* Quanta EC driver for the Winbond Embedded Controller - * - * Copyright (C) 2009 Quanta Computer Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include - -#define EC_ID_NAME "qci-i2cec" -#define EC_BUFFER_LEN 16 -#define EC_CMD_POWER_OFF 0xAC -#define EC_CMD_RESTART 0xAB - -static struct i2c_client *g_i2cec_client; - -/* General structure to hold the driver data */ -struct i2cec_drv_data { - struct i2c_client *i2cec_client; - struct work_struct work; - char ec_data[EC_BUFFER_LEN+1]; -}; - -static int wpce_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int wpce_remove(struct i2c_client *kbd); - -#ifdef CONFIG_PM -static int wpce_suspend(struct device *dev) -{ - return 0; -} - -static int wpce_resume(struct device *dev) -{ - return 0; -} -#endif - -#ifdef CONFIG_PM -static struct dev_pm_ops wpce_pm_ops = { - .suspend = wpce_suspend, - .resume = wpce_resume, -}; -#endif - -static const struct i2c_device_id wpce_idtable[] = { - { EC_ID_NAME, 0 }, - { } -}; - -static struct i2c_driver wpce_driver = { - .driver = { - .owner = THIS_MODULE, - .name = EC_ID_NAME, -#ifdef CONFIG_PM - .pm = &wpce_pm_ops, -#endif - }, - .probe = wpce_probe, - .remove = wpce_remove, - .id_table = wpce_idtable, -}; - -static int wpce_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int err = -ENOMEM; - struct i2cec_drv_data *context = 0; - - /* there is no need to call i2c_check_functionality() since it is the - client's job to use the interface (I2C vs SMBUS) appropriate for it. */ - client->driver = &wpce_driver; - context = kzalloc(sizeof(struct i2cec_drv_data), GFP_KERNEL); - if (!context) - return err; - - context->i2cec_client = client; - g_i2cec_client = client; - i2c_set_clientdata(context->i2cec_client, context); - - return 0; -} - -static int wpce_remove(struct i2c_client *dev) -{ - struct i2cec_drv_data *context = i2c_get_clientdata(dev); - g_i2cec_client = NULL; - kfree(context); - - return 0; -} - -static int __init wpce_init(void) -{ - return i2c_add_driver(&wpce_driver); -} - -static void __exit wpce_exit(void) -{ - i2c_del_driver(&wpce_driver); -} - -struct i2c_client *wpce_get_i2c_client(void) -{ - return g_i2cec_client; -} -EXPORT_SYMBOL_GPL(wpce_get_i2c_client); - -void wpce_poweroff(void) -{ - if (g_i2cec_client == NULL) - return; - i2c_smbus_write_byte(g_i2cec_client, EC_CMD_POWER_OFF); -} -EXPORT_SYMBOL_GPL(wpce_poweroff); - -void wpce_restart(void) -{ - if (g_i2cec_client == NULL) - return; - i2c_smbus_write_byte(g_i2cec_client, EC_CMD_RESTART); -} -EXPORT_SYMBOL_GPL(wpce_restart); - -int wpce_i2c_transfer(struct i2c_msg *msg) -{ - if (g_i2cec_client == NULL) - return -1; - msg->addr = g_i2cec_client->addr; - return i2c_transfer(g_i2cec_client->adapter, msg, 1); -} -EXPORT_SYMBOL_GPL(wpce_i2c_transfer); - -int wpce_smbus_write_word_data(u8 command, u16 value) -{ - if (g_i2cec_client == NULL) - return -1; - return i2c_smbus_write_word_data(g_i2cec_client, command, value); -} -EXPORT_SYMBOL_GPL(wpce_smbus_write_word_data); - -int wpce_smbus_write_byte_data(u8 command, u8 value) -{ - if (g_i2cec_client == NULL) - return -1; - return i2c_smbus_write_byte_data(g_i2cec_client, command, value); -} -EXPORT_SYMBOL_GPL(wpce_smbus_write_byte_data); - -module_init(wpce_init); -module_exit(wpce_exit); - -MODULE_AUTHOR("Quanta Computer Inc."); -MODULE_DESCRIPTION("Quanta Embedded Controller I2C Bridge Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index f1bce0ea7d06621bd61a55b4948b777da1f71fdc..3d2d2b329ca5b75828b51872d3e30bcb1e0ac3d2 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -520,17 +520,6 @@ config I2C_QUP If you say yes to this option, support will be included for the built-in I2C interface on the MSM family processors. -config I2C_SSBI - tristate "Qualcomm Single-wire Serial Bus Interface (SSBI)" - depends on I2C && (ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_FSM9XXX) - default n - help - If you say yes to this option, support will be included for the - built-in SSBI interface on the MSM family processors. - - Note that SSBI is not an I2C device, but is functionally related - enough such that it is able to leverages the I2C framework. - config I2C_MV64XXX tristate "Marvell mv64xxx I2C Controller" depends on (MV64X60 || PLAT_ORION) diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 35b73cde6bf9a32d0ac05322f3ee31f82da59e97..2a8a5724f03eece094612054e9e9dd1d6fd561eb 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -52,7 +52,6 @@ obj-$(CONFIG_I2C_MPC) += i2c-mpc.o obj-$(CONFIG_I2C_MSM) += i2c-msm.o obj-$(CONFIG_I2C_QUP) += i2c-qup.o obj-$(CONFIG_I2C_QUP) += i2c-msm-v2.o -obj-$(CONFIG_I2C_SSBI) += i2c-ssbi.o obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o obj-$(CONFIG_I2C_MXS) += i2c-mxs.o obj-$(CONFIG_I2C_NOMADIK) += i2c-nomadik.o diff --git a/drivers/i2c/busses/i2c-ssbi.c b/drivers/i2c/busses/i2c-ssbi.c deleted file mode 100644 index 9da9236806628677cda948ce69e514a04bd0c40e..0000000000000000000000000000000000000000 --- a/drivers/i2c/busses/i2c-ssbi.c +++ /dev/null @@ -1,517 +0,0 @@ -/* Copyright (c) 2009-2011, 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. - */ -/* - * SSBI driver for Qualcomm MSM platforms - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* SSBI 2.0 controller registers */ -#define SSBI2_CMD 0x0008 -#define SSBI2_RD 0x0010 -#define SSBI2_STATUS 0x0014 -#define SSBI2_MODE2 0x001C - -/* SSBI_CMD fields */ -#define SSBI_CMD_RDWRN (0x01 << 24) -#define SSBI_CMD_REG_ADDR_SHFT (0x10) -#define SSBI_CMD_REG_ADDR_MASK (0xFF << SSBI_CMD_REG_ADDR_SHFT) -#define SSBI_CMD_REG_DATA_SHFT (0x00) -#define SSBI_CMD_REG_DATA_MASK (0xFF << SSBI_CMD_REG_DATA_SHFT) - -/* SSBI_STATUS fields */ -#define SSBI_STATUS_DATA_IN 0x10 -#define SSBI_STATUS_RD_CLOBBERED 0x08 -#define SSBI_STATUS_RD_READY 0x04 -#define SSBI_STATUS_READY 0x02 -#define SSBI_STATUS_MCHN_BUSY 0x01 - -/* SSBI_RD fields */ -#define SSBI_RD_RDWRN 0x01000000 -#define SSBI_RD_REG_ADDR_SHFT 0x10 -#define SSBI_RD_REG_ADDR_MASK (0xFF << SSBI_RD_REG_ADDR_SHFT) -#define SSBI_RD_REG_DATA_SHFT (0x00) -#define SSBI_RD_REG_DATA_MASK (0xFF << SSBI_RD_REG_DATA_SHFT) - -/* SSBI_MODE2 fields */ -#define SSBI_MODE2_REG_ADDR_15_8_SHFT 0x04 -#define SSBI_MODE2_REG_ADDR_15_8_MASK (0x7F << SSBI_MODE2_REG_ADDR_15_8_SHFT) -#define SSBI_MODE2_ADDR_WIDTH_SHFT 0x01 -#define SSBI_MODE2_ADDR_WIDTH_MASK (0x07 << SSBI_MODE2_ADDR_WIDTH_SHFT) -#define SSBI_MODE2_SSBI2_MODE 0x00000001 - -#define SSBI_MODE2_REG_ADDR_15_8(MD, AD) \ - (((MD) & 0x0F) | ((((AD) >> 8) << SSBI_MODE2_REG_ADDR_15_8_SHFT) & \ - SSBI_MODE2_REG_ADDR_15_8_MASK)) - -#define SSBI_MODE2_ADDR_WIDTH(N) \ - ((((N) - 8) << SSBI_MODE2_ADDR_WIDTH_SHFT) & SSBI_MODE2_ADDR_WIDTH_MASK) - -#define SSBI_TIMEOUT_US 100 - -#define SSBI_CMD_READ(AD) \ - (SSBI_CMD_RDWRN | (((AD) & 0xFF) << SSBI_CMD_REG_ADDR_SHFT)) - -#define SSBI_CMD_WRITE(AD, DT) \ - ((((AD) & 0xFF) << SSBI_CMD_REG_ADDR_SHFT) | \ - (((DT) & 0xFF) << SSBI_CMD_REG_DATA_SHFT)) - -/* SSBI PMIC Arbiter command registers */ -#define SSBI_PA_CMD 0x0000 -#define SSBI_PA_RD_STATUS 0x0004 - -/* SSBI_PA_CMD fields */ -#define SSBI_PA_CMD_RDWRN (0x01 << 24) -#define SSBI_PA_CMD_REG_ADDR_14_8_SHFT (0x10) -#define SSBI_PA_CMD_REG_ADDR_14_8_MASK (0x7F << SSBI_PA_CMD_REG_ADDR_14_8_SHFT) -#define SSBI_PA_CMD_REG_ADDR_7_0_SHFT (0x08) -#define SSBI_PA_CMD_REG_ADDR_7_0_MASK (0xFF << SSBI_PA_CMD_REG_ADDR_7_0_SHFT) -#define SSBI_PA_CMD_REG_DATA_SHFT (0x00) -#define SSBI_PA_CMD_REG_DATA_MASK (0xFF << SSBI_PA_CMD_REG_DATA_SHFT) - -#define SSBI_PA_CMD_REG_DATA(DT) \ - (((DT) << SSBI_PA_CMD_REG_DATA_SHFT) & SSBI_PA_CMD_REG_DATA_MASK) - -#define SSBI_PA_CMD_REG_ADDR(AD) \ - (((AD) << SSBI_PA_CMD_REG_ADDR_7_0_SHFT) & \ - (SSBI_PA_CMD_REG_ADDR_14_8_MASK|SSBI_PA_CMD_REG_ADDR_7_0_MASK)) - -/* SSBI_PA_RD_STATUS fields */ -#define SSBI_PA_RD_STATUS_TRANS_DONE (0x01 << 27) -#define SSBI_PA_RD_STATUS_TRANS_DENIED (0x01 << 26) -#define SSBI_PA_RD_STATUS_REG_DATA_SHFT (0x00) -#define SSBI_PA_RD_STATUS_REG_DATA_MASK (0xFF << SSBI_PA_CMD_REG_DATA_SHFT) -#define SSBI_PA_RD_STATUS_TRANS_COMPLETE \ - (SSBI_PA_RD_STATUS_TRANS_DONE|SSBI_PA_RD_STATUS_TRANS_DENIED) - -/* SSBI_FSM Read and Write commands for the FSM9xxx SSBI implementation */ -#define SSBI_FSM_CMD_REG_ADDR_SHFT (0x08) - -#define SSBI_FSM_CMD_READ(AD) \ - (SSBI_CMD_RDWRN | (((AD) & 0xFFFF) << SSBI_FSM_CMD_REG_ADDR_SHFT)) - -#define SSBI_FSM_CMD_WRITE(AD, DT) \ - ((((AD) & 0xFFFF) << SSBI_FSM_CMD_REG_ADDR_SHFT) | \ - (((DT) & 0xFF) << SSBI_CMD_REG_DATA_SHFT)) - -#define SSBI_MSM_NAME "i2c_ssbi" - -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("2.0"); -MODULE_ALIAS("platform:i2c_ssbi"); - -struct i2c_ssbi_dev { - void __iomem *base; - struct device *dev; - struct i2c_adapter adapter; - unsigned long mem_phys_addr; - size_t mem_size; - bool use_rlock; - remote_spinlock_t rspin_lock; - enum msm_ssbi_controller_type controller_type; - int (*read)(struct i2c_ssbi_dev *, struct i2c_msg *); - int (*write)(struct i2c_ssbi_dev *, struct i2c_msg *); -}; - -static inline u32 ssbi_readl(struct i2c_ssbi_dev *ssbi, u32 reg) -{ - return readl_relaxed(ssbi->base + reg); -} - -static inline void ssbi_writel(struct i2c_ssbi_dev *ssbi, u32 reg, u32 val) -{ - writel_relaxed(val, ssbi->base + reg); -} - -static inline int -i2c_ssbi_poll_for_device_ready(struct i2c_ssbi_dev *ssbi) -{ - u32 timeout = SSBI_TIMEOUT_US; - - while (!(ssbi_readl(ssbi, SSBI2_STATUS) & SSBI_STATUS_READY)) { - if (--timeout == 0) { - dev_err(ssbi->dev, "%s: timeout, status %x\n", __func__, - ssbi_readl(ssbi, SSBI2_STATUS)); - return -ETIMEDOUT; - } - udelay(1); - } - - return 0; -} - -static inline int -i2c_ssbi_poll_for_read_completed(struct i2c_ssbi_dev *ssbi) -{ - u32 timeout = SSBI_TIMEOUT_US; - - while (!(ssbi_readl(ssbi, SSBI2_STATUS) & SSBI_STATUS_RD_READY)) { - if (--timeout == 0) { - dev_err(ssbi->dev, "%s: timeout, status %x\n", __func__, - ssbi_readl(ssbi, SSBI2_STATUS)); - return -ETIMEDOUT; - } - udelay(1); - } - - return 0; -} - -static inline int -i2c_ssbi_poll_for_transfer_completed(struct i2c_ssbi_dev *ssbi) -{ - u32 timeout = SSBI_TIMEOUT_US; - - while ((ssbi_readl(ssbi, SSBI2_STATUS) & SSBI_STATUS_MCHN_BUSY)) { - if (--timeout == 0) { - dev_err(ssbi->dev, "%s: timeout, status %x\n", __func__, - ssbi_readl(ssbi, SSBI2_STATUS)); - return -ETIMEDOUT; - } - udelay(1); - } - - return 0; -} - -static int -i2c_ssbi_read_bytes(struct i2c_ssbi_dev *ssbi, struct i2c_msg *msg) -{ - int ret = 0; - u8 *buf = msg->buf; - u16 len = msg->len; - u16 addr = msg->addr; - u32 read_cmd; - - if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { - u32 mode2 = ssbi_readl(ssbi, SSBI2_MODE2); - ssbi_writel(ssbi, SSBI2_MODE2, - SSBI_MODE2_REG_ADDR_15_8(mode2, addr)); - } - - if (ssbi->controller_type == FSM_SBI_CTRL_SSBI) - read_cmd = SSBI_FSM_CMD_READ(addr); - else - read_cmd = SSBI_CMD_READ(addr); - - while (len) { - ret = i2c_ssbi_poll_for_device_ready(ssbi); - if (ret) - goto read_failed; - - ssbi_writel(ssbi, SSBI2_CMD, read_cmd); - - ret = i2c_ssbi_poll_for_read_completed(ssbi); - if (ret) - goto read_failed; - - *buf++ = ssbi_readl(ssbi, SSBI2_RD) & SSBI_RD_REG_DATA_MASK; - len--; - } - -read_failed: - return ret; -} - -static int -i2c_ssbi_write_bytes(struct i2c_ssbi_dev *ssbi, struct i2c_msg *msg) -{ - int ret = 0; - u8 *buf = msg->buf; - u16 len = msg->len; - u16 addr = msg->addr; - - if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { - u32 mode2 = ssbi_readl(ssbi, SSBI2_MODE2); - ssbi_writel(ssbi, SSBI2_MODE2, - SSBI_MODE2_REG_ADDR_15_8(mode2, addr)); - } - - while (len) { - ret = i2c_ssbi_poll_for_device_ready(ssbi); - if (ret) - goto write_failed; - - if (ssbi->controller_type == FSM_SBI_CTRL_SSBI) - ssbi_writel(ssbi, SSBI2_CMD, - SSBI_FSM_CMD_WRITE(addr, *buf++)); - else - ssbi_writel(ssbi, SSBI2_CMD, - SSBI_CMD_WRITE(addr, *buf++)); - - ret = i2c_ssbi_poll_for_transfer_completed(ssbi); - if (ret) - goto write_failed; - - len--; - } - -write_failed: - return ret; -} - -static inline int -i2c_ssbi_pa_transfer(struct i2c_ssbi_dev *ssbi, u32 cmd, u8 *data) -{ - u32 rd_status; - u32 timeout = SSBI_TIMEOUT_US; - - ssbi_writel(ssbi, SSBI_PA_CMD, cmd); - rd_status = ssbi_readl(ssbi, SSBI_PA_RD_STATUS); - - while ((rd_status & (SSBI_PA_RD_STATUS_TRANS_COMPLETE)) == 0) { - - if (--timeout == 0) { - dev_err(ssbi->dev, "%s: timeout, status %x\n", - __func__, rd_status); - return -ETIMEDOUT; - } - udelay(1); - rd_status = ssbi_readl(ssbi, SSBI_PA_RD_STATUS); - } - - if (rd_status & SSBI_PA_RD_STATUS_TRANS_DENIED) { - dev_err(ssbi->dev, "%s: transaction denied, status %x\n", - __func__, rd_status); - return -EPERM; - } - - if (data) - *data = (rd_status & SSBI_PA_RD_STATUS_REG_DATA_MASK) >> - SSBI_PA_CMD_REG_DATA_SHFT; - return 0; -} - -static int -i2c_ssbi_pa_read_bytes(struct i2c_ssbi_dev *ssbi, struct i2c_msg *msg) -{ - int ret = 0; - u8 data; - u8 *buf = msg->buf; - u16 len = msg->len; - u32 read_cmd = (SSBI_PA_CMD_RDWRN | SSBI_PA_CMD_REG_ADDR(msg->addr)); - - while (len) { - - ret = i2c_ssbi_pa_transfer(ssbi, read_cmd, &data); - if (ret) - goto read_failed; - - *buf++ = data; - len--; - } - -read_failed: - return ret; -} - -static int -i2c_ssbi_pa_write_bytes(struct i2c_ssbi_dev *ssbi, struct i2c_msg *msg) -{ - int ret = 0; - u8 *buf = msg->buf; - u16 len = msg->len; - u32 addr = SSBI_PA_CMD_REG_ADDR(msg->addr); - - while (len) { - - u32 write_cmd = addr | (*buf++ & SSBI_PA_CMD_REG_DATA_MASK); - - ret = i2c_ssbi_pa_transfer(ssbi, write_cmd, NULL); - if (ret) - goto write_failed; - len--; - } - -write_failed: - return ret; -} - -static int -i2c_ssbi_transfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) -{ - int ret = 0; - int rem = num; - unsigned long flags = 0; - struct i2c_ssbi_dev *ssbi = i2c_get_adapdata(adap); - - if (ssbi->use_rlock) - remote_spin_lock_irqsave(&ssbi->rspin_lock, flags); - - while (rem) { - if (msgs->flags & I2C_M_RD) { - ret = ssbi->read(ssbi, msgs); - if (ret) - goto transfer_failed; - } else { - ret = ssbi->write(ssbi, msgs); - if (ret) - goto transfer_failed; - } - - msgs++; - rem--; - } - - if (ssbi->use_rlock) - remote_spin_unlock_irqrestore(&ssbi->rspin_lock, flags); - - return num; - -transfer_failed: - if (ssbi->use_rlock) - remote_spin_unlock_irqrestore(&ssbi->rspin_lock, flags); - return ret; -} - -static u32 i2c_ssbi_i2c_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C; -} - -static const struct i2c_algorithm msm_i2c_algo = { - .master_xfer = i2c_ssbi_transfer, - .functionality = i2c_ssbi_i2c_func, -}; - -static int __init i2c_ssbi_probe(struct platform_device *pdev) -{ - int ret = 0; - struct resource *ssbi_res; - struct i2c_ssbi_dev *ssbi; - const struct msm_i2c_ssbi_platform_data *pdata; - - pdata = pdev->dev.platform_data; - if (!pdata) { - ret = -ENXIO; - dev_err(&pdev->dev, "platform data not initialized\n"); - goto err_probe_exit; - } - - ssbi = kzalloc(sizeof(struct i2c_ssbi_dev), GFP_KERNEL); - if (!ssbi) { - ret = -ENOMEM; - dev_err(&pdev->dev, "allocation failed\n"); - goto err_probe_exit; - } - - ssbi_res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "ssbi_base"); - if (!ssbi_res) { - ret = -ENXIO; - dev_err(&pdev->dev, "get_resource_byname failed\n"); - goto err_probe_res; - } - - ssbi->mem_phys_addr = ssbi_res->start; - ssbi->mem_size = resource_size(ssbi_res); - if (!request_mem_region(ssbi->mem_phys_addr, ssbi->mem_size, - SSBI_MSM_NAME)) { - ret = -ENXIO; - dev_err(&pdev->dev, "request_mem_region failed\n"); - goto err_probe_reqmem; - } - - ssbi->base = ioremap(ssbi->mem_phys_addr, ssbi->mem_size); - if (!ssbi->base) { - dev_err(&pdev->dev, "ioremap failed\n"); - goto err_probe_ioremap; - } - - ssbi->dev = &pdev->dev; - platform_set_drvdata(pdev, ssbi); - - ssbi->controller_type = pdata->controller_type; - if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) { - ssbi->read = i2c_ssbi_pa_read_bytes; - ssbi->write = i2c_ssbi_pa_write_bytes; - } else { - ssbi->read = i2c_ssbi_read_bytes; - ssbi->write = i2c_ssbi_write_bytes; - } - - i2c_set_adapdata(&ssbi->adapter, ssbi); - ssbi->adapter.algo = &msm_i2c_algo; - strlcpy(ssbi->adapter.name, - "MSM SSBI adapter", - sizeof(ssbi->adapter.name)); - - if (pdata->rsl_id) { - ret = remote_spin_lock_init(&ssbi->rspin_lock, pdata->rsl_id); - if (ret) { - dev_err(&pdev->dev, "remote spinlock init failed\n"); - goto err_remote_spinlock_init_failed; - } - ssbi->use_rlock = 1; - } - - ssbi->adapter.nr = pdev->id; - ret = i2c_add_numbered_adapter(&ssbi->adapter); - if (ret) { - dev_err(&pdev->dev, "i2c_add_numbered_adapter failed\n"); - goto err_add_adapter_failed; - } - return 0; - -err_add_adapter_failed: -err_remote_spinlock_init_failed: - iounmap(ssbi->base); - platform_set_drvdata(pdev, NULL); -err_probe_ioremap: - release_mem_region(ssbi->mem_phys_addr, ssbi->mem_size); -err_probe_reqmem: -err_probe_res: - kfree(ssbi); -err_probe_exit: - return ret; -} - -static int i2c_ssbi_remove(struct platform_device *pdev) -{ - struct i2c_ssbi_dev *ssbi = platform_get_drvdata(pdev); - - platform_set_drvdata(pdev, NULL); - i2c_del_adapter(&ssbi->adapter); - iounmap(ssbi->base); - release_mem_region(ssbi->mem_phys_addr, ssbi->mem_size); - kfree(ssbi); - return 0; -} - -static struct platform_driver i2c_ssbi_driver = { - .driver = { - .name = "i2c_ssbi", - .owner = THIS_MODULE, - }, - .remove = __exit_p(i2c_ssbi_remove), -}; - -static int __init i2c_ssbi_init(void) -{ - return platform_driver_probe(&i2c_ssbi_driver, i2c_ssbi_probe); -} -arch_initcall(i2c_ssbi_init); - -static void __exit i2c_ssbi_exit(void) -{ - platform_driver_unregister(&i2c_ssbi_driver); -} -module_exit(i2c_ssbi_exit); diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig index aaee4481197f668d0b9faae07816472196986b1c..1e3c279f07a8aed678660b0f5076eb195dca382b 100644 --- a/drivers/input/joystick/Kconfig +++ b/drivers/input/joystick/Kconfig @@ -328,16 +328,4 @@ config JOYSTICK_MAPLE To compile this as a module choose M here: the module will be called maplecontrol. - -config TOUCHDISC_VTD518_SHINETSU - tristate "ShinEtsu VTD518 TouchDisc" - depends on I2C - default n - help - Say Y here if you have the ShinEtsu VTD518 Touchdisc connected. It - provides the detection of absolute and relative motions and dpad - like buttons. - - To compile this as a module choose M here: the module will be called - tdisc_vtd518_shinetsu. endif diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile index 7009c38e79fd485a8dd25208d01108b288482706..e6584c8d855a0ef2814e00a9a347e1b615b62e88 100644 --- a/drivers/input/joystick/Makefile +++ b/drivers/input/joystick/Makefile @@ -32,4 +32,3 @@ obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o -obj-$(CONFIG_TOUCHDISC_VTD518_SHINETSU) += tdisc_vtd518_shinetsu.o \ No newline at end of file diff --git a/drivers/input/joystick/tdisc_vtd518_shinetsu.c b/drivers/input/joystick/tdisc_vtd518_shinetsu.c deleted file mode 100644 index 076d6d4916297b5c89ebed3a4c4f434a2041cd2d..0000000000000000000000000000000000000000 --- a/drivers/input/joystick/tdisc_vtd518_shinetsu.c +++ /dev/null @@ -1,528 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_HAS_EARLYSUSPEND) -#include -/* Early-suspend level */ -#define TDISC_SUSPEND_LEVEL 1 -#endif - -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("0.1"); -MODULE_DESCRIPTION("Shinetsu Touchdisc driver"); -MODULE_ALIAS("platform:tdisc-shinetsu"); - -#define TDSIC_BLK_READ_CMD 0x00 -#define TDISC_READ_DELAY msecs_to_jiffies(25) -#define X_MAX (32) -#define X_MIN (-32) -#define Y_MAX (32) -#define Y_MIN (-32) -#define PRESSURE_MAX (32) -#define PRESSURE_MIN (0) -#define TDISC_USER_ACTIVE_MASK 0x40 -#define TDISC_NORTH_SWITCH_MASK 0x20 -#define TDISC_SOUTH_SWITCH_MASK 0x10 -#define TDISC_EAST_SWITCH_MASK 0x08 -#define TDISC_WEST_SWITCH_MASK 0x04 -#define TDISC_CENTER_SWITCH 0x01 -#define TDISC_BUTTON_PRESS_MASK 0x3F - -#define DRIVER_NAME "tdisc-shinetsu" -#define DEVICE_NAME "vtd518" -#define TDISC_NAME "tdisc_shinetsu" -#define TDISC_INT "tdisc_interrupt" - -struct tdisc_data { - struct input_dev *tdisc_device; - struct i2c_client *clientp; - struct tdisc_platform_data *pdata; - struct delayed_work tdisc_work; -#if defined(CONFIG_HAS_EARLYSUSPEND) - struct early_suspend tdisc_early_suspend; -#endif -}; - -static void process_tdisc_data(struct tdisc_data *dd, u8 *data) -{ - int i; - static bool button_press; - s8 x, y; - - /* Check if the user is actively navigating */ - if (!(data[7] & TDISC_USER_ACTIVE_MASK)) { - pr_debug(" TDISC ! No Data to report ! False positive \n"); - return; - } - - for (i = 0; i < 8 ; i++) - pr_debug(" Data[%d] = %x\n", i, data[i]); - - /* Check if there is a button press */ - if (dd->pdata->tdisc_report_keys) - if (data[7] & TDISC_BUTTON_PRESS_MASK || button_press == true) { - input_report_key(dd->tdisc_device, KEY_UP, - (data[7] & TDISC_NORTH_SWITCH_MASK)); - - input_report_key(dd->tdisc_device, KEY_DOWN, - (data[7] & TDISC_SOUTH_SWITCH_MASK)); - - input_report_key(dd->tdisc_device, KEY_RIGHT, - (data[7] & TDISC_EAST_SWITCH_MASK)); - - input_report_key(dd->tdisc_device, KEY_LEFT, - (data[7] & TDISC_WEST_SWITCH_MASK)); - - input_report_key(dd->tdisc_device, KEY_ENTER, - (data[7] & TDISC_CENTER_SWITCH)); - - if (data[7] & TDISC_BUTTON_PRESS_MASK) - button_press = true; - else - button_press = false; - } - - if (dd->pdata->tdisc_report_relative) { - /* Report relative motion values */ - x = (s8) data[0]; - y = (s8) data[1]; - - if (dd->pdata->tdisc_reverse_x) - x *= -1; - if (dd->pdata->tdisc_reverse_y) - y *= -1; - - input_report_rel(dd->tdisc_device, REL_X, x); - input_report_rel(dd->tdisc_device, REL_Y, y); - } - - if (dd->pdata->tdisc_report_absolute) { - input_report_abs(dd->tdisc_device, ABS_X, data[2]); - input_report_abs(dd->tdisc_device, ABS_Y, data[3]); - input_report_abs(dd->tdisc_device, ABS_PRESSURE, data[4]); - } - - if (dd->pdata->tdisc_report_wheel) - input_report_rel(dd->tdisc_device, REL_WHEEL, (s8) data[6]); - - input_sync(dd->tdisc_device); -} - -static void tdisc_work_f(struct work_struct *work) -{ - int rc; - u8 data[8]; - struct tdisc_data *dd = - container_of(work, struct tdisc_data, tdisc_work.work); - - /* - * Read the value of the interrupt pin. If low, perform - * an I2C read of 8 bytes to get the touch values and then - * reschedule the work after 25ms. If pin is high, exit - * and wait for next interrupt. - */ - rc = gpio_get_value_cansleep(dd->pdata->tdisc_gpio); - if (rc < 0) { - rc = pm_runtime_put_sync(&dd->clientp->dev); - if (rc < 0) - dev_dbg(&dd->clientp->dev, "%s: pm_runtime_put_sync" - " failed\n", __func__); - enable_irq(dd->clientp->irq); - return; - } - - pr_debug("%s: TDISC gpio_get_value = %d\n", __func__, rc); - if (rc == 0) { - /* We have data to read */ - rc = i2c_smbus_read_i2c_block_data(dd->clientp, - TDSIC_BLK_READ_CMD, 8, data); - if (rc < 0) { - pr_debug("%s:I2C read failed,trying again\n", __func__); - rc = i2c_smbus_read_i2c_block_data(dd->clientp, - TDSIC_BLK_READ_CMD, 8, data); - if (rc < 0) { - pr_err("%s:I2C read failed again, exiting\n", - __func__); - goto fail_i2c_read; - } - } - pr_debug("%s: TDISC: I2C read success\n", __func__); - process_tdisc_data(dd, data); - } else { - /* - * We have no data to read. - * Enable the IRQ to receive further interrupts. - */ - enable_irq(dd->clientp->irq); - - rc = pm_runtime_put_sync(&dd->clientp->dev); - if (rc < 0) - dev_dbg(&dd->clientp->dev, "%s: pm_runtime_put_sync" - " failed\n", __func__); - return; - } - -fail_i2c_read: - schedule_delayed_work(&dd->tdisc_work, TDISC_READ_DELAY); -} - -static irqreturn_t tdisc_interrupt(int irq, void *dev_id) -{ - /* - * The touch disc intially generates an interrupt on any - * touch. The interrupt line is pulled low and remains low - * untill there are touch operations being performed. In case - * there are no further touch operations, the line goes high. The - * same process repeats again the next time,when the disc is touched. - * - * We do the following operations once we receive an interrupt. - * 1. Disable the IRQ for any further interrutps. - * 2. Schedule work every 25ms if the GPIO is still low. - * 3. In the work queue do a I2C read to get the touch data. - * 4. If the GPIO is pulled high, enable the IRQ and cancel the work. - */ - struct tdisc_data *dd = dev_id; - int rc; - - rc = pm_runtime_get(&dd->clientp->dev); - if (rc < 0) - dev_dbg(&dd->clientp->dev, "%s: pm_runtime_get" - " failed\n", __func__); - pr_debug("%s: TDISC IRQ ! :-)\n", __func__); - - /* Schedule the work immediately */ - disable_irq_nosync(dd->clientp->irq); - schedule_delayed_work(&dd->tdisc_work, 0); - return IRQ_HANDLED; -} - -static int tdisc_open(struct input_dev *dev) -{ - int rc; - struct tdisc_data *dd = input_get_drvdata(dev); - - if (!dd->clientp) { - /* Check if a valid i2c client is present */ - pr_err("%s: no i2c adapter present \n", __func__); - return -ENODEV; - } - - /* Enable the device */ - if (dd->pdata->tdisc_enable != NULL) { - rc = dd->pdata->tdisc_enable(); - if (rc) - goto fail_open; - } - rc = request_any_context_irq(dd->clientp->irq, tdisc_interrupt, - IRQF_TRIGGER_FALLING, TDISC_INT, dd); - if (rc < 0) { - pr_err("%s: request IRQ failed\n", __func__); - goto fail_irq_open; - } - - return 0; - -fail_irq_open: - if (dd->pdata->tdisc_disable != NULL) - dd->pdata->tdisc_disable(); -fail_open: - return rc; -} - -static void tdisc_close(struct input_dev *dev) -{ - struct tdisc_data *dd = input_get_drvdata(dev); - - free_irq(dd->clientp->irq, dd); - cancel_delayed_work_sync(&dd->tdisc_work); - if (dd->pdata->tdisc_disable != NULL) - dd->pdata->tdisc_disable(); -} - -static int tdisc_remove(struct i2c_client *client) -{ - struct tdisc_data *dd; - - pm_runtime_disable(&client->dev); - dd = i2c_get_clientdata(client); -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&dd->tdisc_early_suspend); -#endif - input_unregister_device(dd->tdisc_device); - if (dd->pdata->tdisc_release != NULL) - dd->pdata->tdisc_release(); - i2c_set_clientdata(client, NULL); - kfree(dd); - - return 0; -} - -#ifdef CONFIG_PM -static int tdisc_suspend(struct device *dev) -{ - int rc; - struct tdisc_data *dd; - - dd = dev_get_drvdata(dev); - if (device_may_wakeup(&dd->clientp->dev)) - enable_irq_wake(dd->clientp->irq); - else { - disable_irq(dd->clientp->irq); - - if (cancel_delayed_work_sync(&dd->tdisc_work)) - enable_irq(dd->clientp->irq); - - if (dd->pdata->tdisc_disable) { - rc = dd->pdata->tdisc_disable(); - if (rc) { - pr_err("%s: Suspend failed\n", __func__); - return rc; - } - } - } - - return 0; -} - -static int tdisc_resume(struct device *dev) -{ - int rc; - struct tdisc_data *dd; - - dd = dev_get_drvdata(dev); - if (device_may_wakeup(&dd->clientp->dev)) - disable_irq_wake(dd->clientp->irq); - else { - if (dd->pdata->tdisc_enable) { - rc = dd->pdata->tdisc_enable(); - if (rc) { - pr_err("%s: Resume failed\n", __func__); - return rc; - } - } - enable_irq(dd->clientp->irq); - } - - return 0; -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void tdisc_early_suspend(struct early_suspend *h) -{ - struct tdisc_data *dd = container_of(h, struct tdisc_data, - tdisc_early_suspend); - - tdisc_suspend(&dd->clientp->dev); -} - -static void tdisc_late_resume(struct early_suspend *h) -{ - struct tdisc_data *dd = container_of(h, struct tdisc_data, - tdisc_early_suspend); - - tdisc_resume(&dd->clientp->dev); -} -#endif - -static struct dev_pm_ops tdisc_pm_ops = { -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = tdisc_suspend, - .resume = tdisc_resume, -#endif -}; -#endif - -static const struct i2c_device_id tdisc_id[] = { - { DEVICE_NAME, 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, tdisc_id); - -static int tdisc_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int rc = -1; - int x_max, x_min, y_max, y_min, pressure_min, pressure_max; - struct tdisc_platform_data *pd; - struct tdisc_data *dd; - - /* Check if the I2C adapter supports the BLOCK READ functionality */ - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) - return -ENODEV; - - /* Enable runtime PM ops, start in ACTIVE mode */ - rc = pm_runtime_set_active(&client->dev); - if (rc < 0) - dev_dbg(&client->dev, "unable to set runtime pm state\n"); - pm_runtime_enable(&client->dev); - - dd = kzalloc(sizeof *dd, GFP_KERNEL); - if (!dd) { - rc = -ENOMEM; - goto probe_exit; - } - - i2c_set_clientdata(client, dd); - dd->clientp = client; - pd = client->dev.platform_data; - if (!pd) { - pr_err("%s: platform data not set \n", __func__); - rc = -EFAULT; - goto probe_free_exit; - } - - dd->pdata = pd; - - dd->tdisc_device = input_allocate_device(); - if (!dd->tdisc_device) { - rc = -ENOMEM; - goto probe_free_exit; - } - - input_set_drvdata(dd->tdisc_device, dd); - dd->tdisc_device->open = tdisc_open; - dd->tdisc_device->close = tdisc_close; - dd->tdisc_device->name = TDISC_NAME; - dd->tdisc_device->id.bustype = BUS_I2C; - dd->tdisc_device->id.product = 1; - dd->tdisc_device->id.version = 1; - - if (pd->tdisc_abs) { - x_max = pd->tdisc_abs->x_max; - x_min = pd->tdisc_abs->x_min; - y_max = pd->tdisc_abs->y_max; - y_min = pd->tdisc_abs->y_min; - pressure_max = pd->tdisc_abs->pressure_max; - pressure_min = pd->tdisc_abs->pressure_min; - } else { - x_max = X_MAX; - x_min = X_MIN; - y_max = Y_MAX; - y_min = Y_MIN; - pressure_max = PRESSURE_MAX; - pressure_min = PRESSURE_MIN; - } - - /* Device capablities for relative motion */ - input_set_capability(dd->tdisc_device, EV_REL, REL_X); - input_set_capability(dd->tdisc_device, EV_REL, REL_Y); - input_set_capability(dd->tdisc_device, EV_KEY, BTN_MOUSE); - - /* Device capablities for absolute motion */ - input_set_capability(dd->tdisc_device, EV_ABS, ABS_X); - input_set_capability(dd->tdisc_device, EV_ABS, ABS_Y); - input_set_capability(dd->tdisc_device, EV_ABS, ABS_PRESSURE); - - input_set_abs_params(dd->tdisc_device, ABS_X, x_min, x_max, 0, 0); - input_set_abs_params(dd->tdisc_device, ABS_Y, y_min, y_max, 0, 0); - input_set_abs_params(dd->tdisc_device, ABS_PRESSURE, pressure_min, - pressure_max, 0, 0); - - /* Device capabilities for scroll and buttons */ - input_set_capability(dd->tdisc_device, EV_REL, REL_WHEEL); - input_set_capability(dd->tdisc_device, EV_KEY, KEY_LEFT); - input_set_capability(dd->tdisc_device, EV_KEY, KEY_RIGHT); - input_set_capability(dd->tdisc_device, EV_KEY, KEY_UP); - input_set_capability(dd->tdisc_device, EV_KEY, KEY_DOWN); - input_set_capability(dd->tdisc_device, EV_KEY, KEY_ENTER); - - /* Setup the device for operation */ - if (dd->pdata->tdisc_setup != NULL) { - rc = dd->pdata->tdisc_setup(); - if (rc) { - pr_err("%s: Setup failed \n", __func__); - goto probe_unreg_free_exit; - } - } - - /* Setup wakeup capability */ - device_init_wakeup(&dd->clientp->dev, dd->pdata->tdisc_wakeup); - - INIT_DELAYED_WORK(&dd->tdisc_work, tdisc_work_f); - - rc = input_register_device(dd->tdisc_device); - if (rc) { - pr_err("%s: input register device failed \n", __func__); - rc = -EINVAL; - goto probe_register_fail; - } - - pm_runtime_set_suspended(&client->dev); - -#ifdef CONFIG_HAS_EARLYSUSPEND - dd->tdisc_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + - TDISC_SUSPEND_LEVEL; - dd->tdisc_early_suspend.suspend = tdisc_early_suspend; - dd->tdisc_early_suspend.resume = tdisc_late_resume; - register_early_suspend(&dd->tdisc_early_suspend); -#endif - return 0; - -probe_register_fail: - if (dd->pdata->tdisc_release != NULL) - dd->pdata->tdisc_release(); -probe_unreg_free_exit: - input_free_device(dd->tdisc_device); -probe_free_exit: - i2c_set_clientdata(client, NULL); - kfree(dd); -probe_exit: - pm_runtime_set_suspended(&client->dev); - pm_runtime_disable(&client->dev); - return rc; -} - -static struct i2c_driver tdisc_driver = { - .driver = { - .name = DRIVER_NAME, - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &tdisc_pm_ops, -#endif - }, - .probe = tdisc_probe, - .remove = tdisc_remove, - .id_table = tdisc_id, -}; - -static int __init tdisc_init(void) -{ - int rc; - - rc = i2c_add_driver(&tdisc_driver); - if (rc) - pr_err("%s: i2c add driver failed \n", __func__); - return rc; -} - -static void __exit tdisc_exit(void) -{ - i2c_del_driver(&tdisc_driver); -} - -module_init(tdisc_init); -module_exit(tdisc_exit); diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 8aa014fae9f77ad98f244df51547fc76bbdf8242..5d3ee420d614e9d2251281868bec6e222506b856 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -629,14 +629,6 @@ config KEYBOARD_XTKBD To compile this driver as a module, choose M here: the module will be called xtkbd. -config KEYBOARD_QCIKBD - tristate "Quanta Computer Inc. keyboard" - depends on I2C - default n - help - Say Y here if you want to use the Quanta keyboard driver for ST 1.5 - platform. - config KEYBOARD_QCIKBD_REPEAT bool "Enable Quanta Computer Inc. keyboard key repeat feature" depends on KEYBOARD_QCIKBD diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 09030b4f9c083855a3df2a884a842e0a44a66e56..7797f9dc7262b4c7c375db5fbbbc067dab0c336c 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -56,5 +56,4 @@ obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o -obj-$(CONFIG_KEYBOARD_QCIKBD) += qci_kbd.o obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o diff --git a/drivers/input/keyboard/qci_kbd.c b/drivers/input/keyboard/qci_kbd.c deleted file mode 100644 index ef3a2b54d22630dbdedcbec1fe4ec889f03170ee..0000000000000000000000000000000000000000 --- a/drivers/input/keyboard/qci_kbd.c +++ /dev/null @@ -1,721 +0,0 @@ -/* Quanta I2C Keyboard Driver - * - * Copyright (C) 2009 Quanta Computer Inc. - * Copyright (c) 2010, The Linux Foundation. All rights reserved. - * Author: Hsin Wu - * Author: Austin Lai - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - - /* - * - * The Driver with I/O communications via the I2C Interface for ON2 of AP BU. - * And it is only working on the nuvoTon WPCE775x Embedded Controller. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* Keyboard special scancode */ -#define RC_KEY_FN 0x70 -#define RC_KEY_BREAK 0x80 -#define KEY_ACK_FA 0xFA -#define SCAN_EMUL0 0xE0 -#define SCAN_EMUL1 0xE1 -#define SCAN_PAUSE1 0x1D -#define SCAN_PAUSE2 0x45 -#define SCAN_LIDSW_OPEN 0x70 -#define SCAN_LIDSW_CLOSE 0x71 - -/* Keyboard keycodes */ -#define NOKEY KEY_RESERVED -#define KEY_LEFTWIN KEY_LEFTMETA -#define KEY_RIGHTWIN KEY_RIGHTMETA -#define KEY_APPS KEY_COMPOSE -#define KEY_PRINTSCR KEY_SYSRQ - -#define KEYBOARD_ID_NAME "qci-i2ckbd" -#define KEYBOARD_NAME "Quanta Keyboard" -#define KEYBOARD_DEVICE "/i2c/input0" -#define KEYBOARD_CMD_ENABLE 0xF4 -#define KEYBOARD_CMD_SET_LED 0xED - -/*----------------------------------------------------------------------------- - * Keyboard scancode to linux keycode translation table - *---------------------------------------------------------------------------*/ - -static const unsigned char on2_keycode[256] = { - [0] = NOKEY, - [1] = NOKEY, - [2] = NOKEY, - [3] = KEY_5, - [4] = KEY_7, - [5] = KEY_9, - [6] = KEY_MINUS, - [7] = NOKEY, - [8] = NOKEY, - [9] = NOKEY, - [10] = NOKEY, - [11] = KEY_LEFTBRACE, - [12] = KEY_F10, - [13] = KEY_INSERT, - [14] = KEY_F11, - [15] = KEY_ESC, - [16] = NOKEY, - [17] = NOKEY, - [18] = NOKEY, - [19] = KEY_4, - [20] = KEY_6, - [21] = KEY_8, - [22] = KEY_0, - [23] = KEY_EQUAL, - [24] = NOKEY, - [25] = NOKEY, - [26] = NOKEY, - [27] = KEY_P, - [28] = KEY_F9, - [29] = KEY_DELETE, - [30] = KEY_F12, - [31] = KEY_GRAVE, - [32] = KEY_W, - [33] = NOKEY, - [34] = NOKEY, - [35] = KEY_R, - [36] = KEY_T, - [37] = KEY_U, - [38] = KEY_O, - [39] = KEY_RIGHTBRACE, - [40] = NOKEY, - [41] = NOKEY, - [42] = NOKEY, - [43] = KEY_APOSTROPHE, - [44] = KEY_BACKSPACE, - [45] = NOKEY, - [46] = KEY_F8, - [47] = KEY_F5, - [48] = KEY_S, - [49] = NOKEY, - [50] = NOKEY, - [51] = KEY_E, - [52] = KEY_H, - [53] = KEY_Y, - [54] = KEY_I, - [55] = KEY_ENTER, - [56] = NOKEY, - [57] = NOKEY, - [58] = NOKEY, - [59] = KEY_SEMICOLON, - [60] = KEY_3, - [61] = KEY_PAGEUP, - [62] = KEY_Q, - [63] = KEY_TAB, - [64] = KEY_A, - [65] = NOKEY, - [66] = NOKEY, - [67] = KEY_F, - [68] = KEY_G, - [69] = KEY_J, - [70] = KEY_L, - [71] = NOKEY, - [72] = KEY_RIGHTSHIFT, - [73] = NOKEY, - [74] = NOKEY, - [75] = KEY_SLASH, - [76] = KEY_2, - [77] = KEY_PAGEDOWN, - [78] = KEY_F4, - [79] = KEY_F1, - [80] = KEY_Z, - [81] = NOKEY, - [82] = NOKEY, - [83] = KEY_D, - [84] = KEY_V, - [85] = KEY_N, - [86] = KEY_K, - [87] = NOKEY, - [88] = KEY_LEFTSHIFT, - [89] = KEY_RIGHTCTRL, - [90] = NOKEY, - [91] = KEY_DOT, - [92] = KEY_UP, - [93] = KEY_RIGHT, - [94] = KEY_F3, - [95] = KEY_F2, - [96] = NOKEY, - [97] = NOKEY, - [98] = KEY_RIGHTALT, - [99] = KEY_X, - [100] = KEY_C, - [101] = KEY_B, - [102] = KEY_COMMA, - [103] = NOKEY, - [104] = NOKEY, - [105] = NOKEY, - [106] = NOKEY, - [107] = NOKEY, - [108] = KEY_PRINTSCR, - [109] = KEY_DOWN, - [110] = KEY_1, - [111] = KEY_CAPSLOCK, - [112] = KEY_F24, - [113] = KEY_HOME, - [114] = KEY_LEFTALT, - [115] = NOKEY, - [116] = KEY_SPACE, - [117] = KEY_BACKSLASH, - [118] = KEY_M, - [119] = KEY_COMPOSE, - [120] = NOKEY, - [121] = KEY_LEFTCTRL, - [122] = NOKEY, - [123] = NOKEY, - [124] = KEY_PAUSE, - [125] = KEY_LEFT, - [126] = KEY_F7, - [127] = KEY_F6, - [128] = NOKEY, - [129] = NOKEY, - [130] = NOKEY, - [131] = NOKEY, - [132] = NOKEY, - [133] = NOKEY, - [134] = NOKEY, - [135] = NOKEY, - [136] = NOKEY, - [137] = NOKEY, - [138] = NOKEY, - [139] = NOKEY, - [140] = NOKEY, - [141] = NOKEY, - [142] = NOKEY, - [143] = NOKEY, - [144] = NOKEY, - [145] = NOKEY, - [146] = NOKEY, - [147] = NOKEY, - [148] = NOKEY, - [149] = NOKEY, - [150] = NOKEY, - [151] = NOKEY, - [152] = NOKEY, - [153] = NOKEY, - [154] = NOKEY, - [155] = NOKEY, - [156] = NOKEY, - [157] = NOKEY, - [158] = NOKEY, - [159] = NOKEY, - [160] = NOKEY, - [161] = NOKEY, - [162] = NOKEY, - [163] = NOKEY, - [164] = NOKEY, - [165] = NOKEY, - [166] = NOKEY, - [167] = NOKEY, - [168] = NOKEY, - [169] = NOKEY, - [170] = NOKEY, - [171] = NOKEY, - [172] = NOKEY, - [173] = NOKEY, - [174] = NOKEY, - [175] = NOKEY, - [176] = NOKEY, - [177] = NOKEY, - [178] = NOKEY, - [179] = NOKEY, - [180] = NOKEY, - [181] = NOKEY, - [182] = NOKEY, - [183] = NOKEY, - [184] = NOKEY, - [185] = NOKEY, - [186] = NOKEY, - [187] = NOKEY, - [188] = NOKEY, - [189] = KEY_HOME, - [190] = NOKEY, - [191] = NOKEY, - [192] = NOKEY, - [193] = NOKEY, - [194] = NOKEY, - [195] = NOKEY, - [196] = NOKEY, - [197] = NOKEY, - [198] = NOKEY, - [199] = NOKEY, - [200] = NOKEY, - [201] = NOKEY, - [202] = NOKEY, - [203] = NOKEY, - [204] = NOKEY, - [205] = KEY_END, - [206] = NOKEY, - [207] = NOKEY, - [208] = NOKEY, - [209] = NOKEY, - [210] = NOKEY, - [211] = NOKEY, - [212] = NOKEY, - [213] = NOKEY, - [214] = NOKEY, - [215] = NOKEY, - [216] = NOKEY, - [217] = NOKEY, - [218] = NOKEY, - [219] = NOKEY, - [220] = KEY_VOLUMEUP, - [221] = KEY_BRIGHTNESSUP, - [222] = NOKEY, - [223] = NOKEY, - [224] = NOKEY, - [225] = NOKEY, - [226] = NOKEY, - [227] = NOKEY, - [228] = NOKEY, - [229] = NOKEY, - [230] = NOKEY, - [231] = NOKEY, - [232] = NOKEY, - [233] = NOKEY, - [234] = NOKEY, - [235] = NOKEY, - [236] = NOKEY, - [237] = KEY_VOLUMEDOWN, - [238] = NOKEY, - [239] = NOKEY, - [240] = NOKEY, - [241] = NOKEY, - [242] = NOKEY, - [243] = NOKEY, - [244] = NOKEY, - [245] = NOKEY, - [246] = NOKEY, - [247] = NOKEY, - [248] = NOKEY, - [249] = NOKEY, - [250] = NOKEY, - [251] = NOKEY, - [252] = NOKEY, - [253] = KEY_BRIGHTNESSDOWN, - [254] = NOKEY, - [255] = NOKEY, -}; - -static const u8 emul0_map[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 97, 0, 0, - 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 0, - 115, 0, 0, 0, 0, 98, 0, 99, 100, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 102, 103, 104, 0, 105, 0, 106, 0, 107, - 108, 109, 110, 111, 0, 0, 0, 0, 0, 0, 0, 139, 0, 150, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -/*----------------------------------------------------------------------------- - * Global variables - *---------------------------------------------------------------------------*/ - -struct input_dev *g_qci_keyboard_dev; - -/* General structure to hold the driver data */ -struct i2ckbd_drv_data { - struct i2c_client *ki2c_client; - struct work_struct work; - struct input_dev *qcikbd_dev; - struct mutex kb_mutex; - unsigned int qcikbd_gpio; /* GPIO used for interrupt */ - unsigned int qcikbd_irq; - unsigned int key_down; - unsigned int escape; - unsigned int pause_seq; - unsigned int fn; - unsigned char led_status; - bool standard_scancodes; - bool kb_leds; - bool event_led; - bool emul0; - bool emul1; - bool pause1; -}; -#ifdef CONFIG_PM -static int qcikbd_suspend(struct device *dev) -{ - struct i2ckbd_drv_data *context = input_get_drvdata(g_qci_keyboard_dev); - - enable_irq_wake(context->qcikbd_irq); - return 0; -} - -static int qcikbd_resume(struct device *dev) -{ - struct i2ckbd_drv_data *context = input_get_drvdata(g_qci_keyboard_dev); - struct i2c_client *ikbdclient = context->ki2c_client; - - disable_irq_wake(context->qcikbd_irq); - - /* consume any keypress generated while suspended */ - i2c_smbus_read_byte(ikbdclient); - return 0; -} -#endif -static int qcikbd_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int qcikbd_remove(struct i2c_client *kbd); - -static const struct i2c_device_id qcikbd_idtable[] = { - { KEYBOARD_ID_NAME, 0 }, - { } -}; - -MODULE_DEVICE_TABLE(i2c, qcikbd_idtable); - -#ifdef CONFIG_PM -static struct dev_pm_ops qcikbd_pm_ops = { - .suspend = qcikbd_suspend, - .resume = qcikbd_resume, -}; -#endif -static struct i2c_driver i2ckbd_driver = { - .driver = { - .owner = THIS_MODULE, - .name = KEYBOARD_ID_NAME, -#ifdef CONFIG_PM - .pm = &qcikbd_pm_ops, -#endif - }, - .probe = qcikbd_probe, - .remove = qcikbd_remove, - .id_table = qcikbd_idtable, -}; - -/*----------------------------------------------------------------------------- - * Driver functions - *---------------------------------------------------------------------------*/ - -#ifdef CONFIG_KEYBOARD_QCIKBD_LID -static void process_lid(struct input_dev *ikbdev, unsigned char scancode) -{ - if (scancode == SCAN_LIDSW_OPEN) - input_report_switch(ikbdev, SW_LID, 0); - else if (scancode == SCAN_LIDSW_CLOSE) - input_report_switch(ikbdev, SW_LID, 1); - else - return; - input_sync(ikbdev); -} -#endif - -static irqreturn_t qcikbd_interrupt(int irq, void *dev_id) -{ - struct i2ckbd_drv_data *ikbd_drv_data = dev_id; - schedule_work(&ikbd_drv_data->work); - return IRQ_HANDLED; -} - -static void qcikbd_work_handler(struct work_struct *_work) -{ - unsigned char scancode; - unsigned char scancode_only; - unsigned int keycode; - - struct i2ckbd_drv_data *ikbd_drv_data = - container_of(_work, struct i2ckbd_drv_data, work); - - struct i2c_client *ikbdclient = ikbd_drv_data->ki2c_client; - struct input_dev *ikbdev = ikbd_drv_data->qcikbd_dev; - - mutex_lock(&ikbd_drv_data->kb_mutex); - - if ((ikbd_drv_data->kb_leds) && (ikbd_drv_data->event_led)) { - i2c_smbus_write_byte(ikbdclient, KEYBOARD_CMD_SET_LED); - i2c_smbus_write_byte(ikbdclient, ikbd_drv_data->led_status); - ikbd_drv_data->event_led = 0; - goto work_exit; - } - - scancode = i2c_smbus_read_byte(ikbdclient); - - if (scancode == KEY_ACK_FA) - goto work_exit; - - if (ikbd_drv_data->standard_scancodes) { - /* pause key is E1 1D 45 */ - if (scancode == SCAN_EMUL1) { - ikbd_drv_data->emul1 = 1; - goto work_exit; - } - if (ikbd_drv_data->emul1) { - ikbd_drv_data->emul1 = 0; - if ((scancode & 0x7f) == SCAN_PAUSE1) - ikbd_drv_data->pause1 = 1; - goto work_exit; - } - if (ikbd_drv_data->pause1) { - ikbd_drv_data->pause1 = 0; - if ((scancode & 0x7f) == SCAN_PAUSE2) { - input_report_key(ikbdev, KEY_PAUSE, - !(scancode & 0x80)); - input_sync(ikbdev); - } - goto work_exit; - } - - if (scancode == SCAN_EMUL0) { - ikbd_drv_data->emul0 = 1; - goto work_exit; - } - if (ikbd_drv_data->emul0) { - ikbd_drv_data->emul0 = 0; - scancode_only = scancode & 0x7f; -#ifdef CONFIG_KEYBOARD_QCIKBD_LID - if ((scancode_only == SCAN_LIDSW_OPEN) || - (scancode_only == SCAN_LIDSW_CLOSE)) { - process_lid(ikbdev, scancode); - goto work_exit; - } -#endif - keycode = emul0_map[scancode_only]; - if (!keycode) { - dev_err(&ikbdev->dev, - "Unrecognized scancode %02x %02x\n", - SCAN_EMUL0, scancode); - goto work_exit; - } - } else { - keycode = scancode & 0x7f; - } - /* MS bit of scancode indicates direction of keypress */ - ikbd_drv_data->key_down = !(scancode & 0x80); - if (keycode) { - input_event(ikbdev, EV_MSC, MSC_SCAN, scancode); - input_report_key(ikbdev, keycode, - ikbd_drv_data->key_down); - input_sync(ikbdev); - } - goto work_exit; - } - - mutex_unlock(&ikbd_drv_data->kb_mutex); - - if (scancode == RC_KEY_FN) { - ikbd_drv_data->fn = 0x80; /* select keycode table > 0x7F */ - } else { - ikbd_drv_data->key_down = 1; - if (scancode & RC_KEY_BREAK) { - ikbd_drv_data->key_down = 0; - if ((scancode & 0x7F) == RC_KEY_FN) - ikbd_drv_data->fn = 0; - } - keycode = on2_keycode[(scancode & 0x7F) | ikbd_drv_data->fn]; - if (keycode != NOKEY) { - input_report_key(ikbdev, - keycode, - ikbd_drv_data->key_down); - input_sync(ikbdev); - } - } - return; - -work_exit: - mutex_unlock(&ikbd_drv_data->kb_mutex); -} - -static int qcikbd_input_event(struct input_dev *dev, unsigned int type, - unsigned int code, int value) -{ - struct i2ckbd_drv_data *ikbd_drv_data = input_get_drvdata(dev); - struct input_dev *ikbdev = ikbd_drv_data->qcikbd_dev; - - if (type != EV_LED) - return -EINVAL; - - ikbd_drv_data->led_status = - (test_bit(LED_SCROLLL, ikbdev->led) ? 1 : 0) | - (test_bit(LED_NUML, ikbdev->led) ? 2 : 0) | - (test_bit(LED_CAPSL, ikbdev->led) ? 4 : 0); - ikbd_drv_data->event_led = 1; - - schedule_work(&ikbd_drv_data->work); - return 0; -} - -static int qcikbd_open(struct input_dev *dev) -{ - struct i2ckbd_drv_data *ikbd_drv_data = input_get_drvdata(dev); - struct i2c_client *ikbdclient = ikbd_drv_data->ki2c_client; - - /* Send F4h - enable keyboard */ - i2c_smbus_write_byte(ikbdclient, KEYBOARD_CMD_ENABLE); - return 0; -} - -static int qcikbd_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int err; - int i; - struct i2ckbd_drv_data *context; - struct qci_kbd_platform_data *pdata = client->dev.platform_data; - - if (!pdata) { - pr_err("[KBD] platform data not supplied\n"); - return -EINVAL; - } - - context = kzalloc(sizeof(struct i2ckbd_drv_data), GFP_KERNEL); - if (!context) - return -ENOMEM; - i2c_set_clientdata(client, context); - context->ki2c_client = client; - context->qcikbd_gpio = client->irq; - client->driver = &i2ckbd_driver; - - INIT_WORK(&context->work, qcikbd_work_handler); - mutex_init(&context->kb_mutex); - - err = gpio_request(context->qcikbd_gpio, "qci-kbd"); - if (err) { - pr_err("[KBD] err gpio request\n"); - goto gpio_request_fail; - } - - context->qcikbd_irq = gpio_to_irq(context->qcikbd_gpio); - err = request_irq(context->qcikbd_irq, - qcikbd_interrupt, - IRQF_TRIGGER_FALLING, - KEYBOARD_ID_NAME, - context); - if (err) { - pr_err("[KBD] err unable to get IRQ\n"); - goto request_irq_fail; - } - - context->standard_scancodes = pdata->standard_scancodes; - context->kb_leds = pdata->kb_leds; - context->qcikbd_dev = input_allocate_device(); - if (!context->qcikbd_dev) { - pr_err("[KBD]allocting memory err\n"); - err = -ENOMEM; - goto allocate_fail; - } - - context->qcikbd_dev->name = KEYBOARD_NAME; - context->qcikbd_dev->phys = KEYBOARD_DEVICE; - context->qcikbd_dev->id.bustype = BUS_I2C; - context->qcikbd_dev->id.vendor = 0x1050; - context->qcikbd_dev->id.product = 0x0006; - context->qcikbd_dev->id.version = 0x0004; - context->qcikbd_dev->open = qcikbd_open; - set_bit(EV_KEY, context->qcikbd_dev->evbit); - __set_bit(MSC_SCAN, context->qcikbd_dev->mscbit); - - if (pdata->repeat) - set_bit(EV_REP, context->qcikbd_dev->evbit); - - /* Enable all supported keys */ - for (i = 1; i < ARRAY_SIZE(on2_keycode) ; i++) - set_bit(on2_keycode[i], context->qcikbd_dev->keybit); - - set_bit(KEY_POWER, context->qcikbd_dev->keybit); - set_bit(KEY_END, context->qcikbd_dev->keybit); - set_bit(KEY_VOLUMEUP, context->qcikbd_dev->keybit); - set_bit(KEY_VOLUMEDOWN, context->qcikbd_dev->keybit); - set_bit(KEY_ZOOMIN, context->qcikbd_dev->keybit); - set_bit(KEY_ZOOMOUT, context->qcikbd_dev->keybit); - -#ifdef CONFIG_KEYBOARD_QCIKBD_LID - set_bit(EV_SW, context->qcikbd_dev->evbit); - set_bit(SW_LID, context->qcikbd_dev->swbit); -#endif - - if (context->kb_leds) { - context->qcikbd_dev->event = qcikbd_input_event; - __set_bit(EV_LED, context->qcikbd_dev->evbit); - __set_bit(LED_NUML, context->qcikbd_dev->ledbit); - __set_bit(LED_CAPSL, context->qcikbd_dev->ledbit); - __set_bit(LED_SCROLLL, context->qcikbd_dev->ledbit); - } - - input_set_drvdata(context->qcikbd_dev, context); - err = input_register_device(context->qcikbd_dev); - if (err) { - pr_err("[KBD] err input register device\n"); - goto register_fail; - } - g_qci_keyboard_dev = context->qcikbd_dev; - return 0; -register_fail: - input_free_device(context->qcikbd_dev); - -allocate_fail: - free_irq(context->qcikbd_irq, context); - -request_irq_fail: - gpio_free(context->qcikbd_gpio); - -gpio_request_fail: - i2c_set_clientdata(client, NULL); - kfree(context); - return err; -} - -static int qcikbd_remove(struct i2c_client *dev) -{ - struct i2ckbd_drv_data *context = i2c_get_clientdata(dev); - - free_irq(context->qcikbd_irq, context); - gpio_free(context->qcikbd_gpio); - input_free_device(context->qcikbd_dev); - input_unregister_device(context->qcikbd_dev); - kfree(context); - - return 0; -} - -static int __init qcikbd_init(void) -{ - return i2c_add_driver(&i2ckbd_driver); -} - -static void __exit qcikbd_exit(void) -{ - i2c_del_driver(&i2ckbd_driver); -} - -struct input_dev *nkbc_keypad_get_input_dev(void) -{ - return g_qci_keyboard_dev; -} -EXPORT_SYMBOL(nkbc_keypad_get_input_dev); -module_init(qcikbd_init); -module_exit(qcikbd_exit); - -MODULE_AUTHOR("Quanta Computer Inc."); -MODULE_DESCRIPTION("Quanta Embedded Controller I2C Keyboard Driver"); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index d0762073fbd2c106852f7f2a464f5b94d5d816bc..71df8588f30f9ac1dd1a7003c83dbeeda3ff3bbe 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -665,35 +665,6 @@ config INPUT_XEN_KBDDEV_FRONTEND To compile this driver as a module, choose M here: the module will be called xen-kbdfront. -config PMIC8058_OTHC - tristate "Qualcomm PMIC8058 OTHC support" - default n - depends on PMIC8058 - help - Say Y here if you want support PMIC8058 OTHC. - - To compile this driver as a module, choose M here: the - module will be called pmic8058-othc. - -config INPUT_PMIC8058_VIBRA_MEMLESS - tristate "Qualcomm PM8058 vibrator support (ff-memless)" - depends on PMIC8058 && INPUT_FF_MEMLESS - default n - help - This option enables device driver support for the vibrator - on Qualcomm PM8058 chip. This driver supports ff-memless interface - from input framework. - - To compile this driver as module, choose M here: the - module will be called pmic8058-vib-memless. - -config STM_LIS3DH - tristate "STM LIS3DH acceleration sensor support" - depends on I2C=y - help - If you say yes here you get support for STMicroelectronics's - acceleration sensors LIS3DH. - config BMP18X tristate "BMP18X digital pressure sensor" depends on (I2C ) && SYSFS diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index e379a65c3c47ba5c8e7e5117bbbeee134504fbd0..ad915b35069e6dd869e30cdae61ec6e3beac72cd 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -62,9 +62,6 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND) += xen-kbdfront.o obj-$(CONFIG_INPUT_YEALINK) += yealink.o -obj-$(CONFIG_PMIC8058_OTHC) += pmic8058-othc.o -obj-$(CONFIG_INPUT_PMIC8058_VIBRA_MEMLESS) += pmic8058-vib-memless.o -obj-$(CONFIG_STM_LIS3DH) += lis3dh_acc.o obj-$(CONFIG_BMP18X) += bmp18x-core.o obj-$(CONFIG_BMP18X_I2C) += bmp18x-i2c.o obj-$(CONFIG_SENSORS_MMA8X5X) += mma8x5x.o diff --git a/drivers/input/misc/isa1200-ff-memless.c b/drivers/input/misc/isa1200-ff-memless.c deleted file mode 100644 index 5515bba9dbddad11337ba5a98288d3a865271079..0000000000000000000000000000000000000000 --- a/drivers/input/misc/isa1200-ff-memless.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * Copyright (C) 2009 Samsung Electronics - * Kyungmin Park - * - * Copyright (c) 2011, 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. - * - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ISA1200_HCTRL0 0x30 -#define HCTRL0_MODE_CTRL_BIT (3) -#define HCTRL0_OVERDRIVE_HIGH_BIT (5) -#define HCTRL0_OVERDRIVE_EN_BIT (6) -#define HCTRL0_HAP_EN (7) -#define HCTRL0_RESET 0x01 -#define HCTRL1_RESET 0x4B - -#define ISA1200_HCTRL1 0x31 -#define HCTRL1_SMART_ENABLE_BIT (3) -#define HCTRL1_ERM_BIT (5) -#define HCTRL1_EXT_CLK_ENABLE_BIT (7) - -#define ISA1200_HCTRL5 0x35 -#define HCTRL5_VIB_STRT 0xD5 -#define HCTRL5_VIB_STOP 0x6B - -#define DIVIDER_128 (128) -#define DIVIDER_1024 (1024) -#define DIVIDE_SHIFTER_128 (7) - -#define FREQ_22400 (22400) -#define FREQ_172600 (172600) - -#define POR_DELAY_USEC 250 - -struct isa1200_chip { - const struct isa1200_platform_data *pdata; - struct i2c_client *client; - struct input_dev *input_device; - struct pwm_device *pwm; - unsigned int period_ns; - unsigned int state; - struct work_struct work; -}; - -static void isa1200_vib_set(struct isa1200_chip *haptic, int enable) -{ - int rc; - - if (enable) { - if (haptic->pdata->mode_ctrl == PWM_INPUT_MODE) { - int period_us = haptic->period_ns / NSEC_PER_USEC; - rc = pwm_config(haptic->pwm, - (period_us * haptic->pdata->duty) / 100, - period_us); - if (rc < 0) - pr_err("pwm_config fail\n"); - rc = pwm_enable(haptic->pwm); - if (rc < 0) - pr_err("pwm_enable fail\n"); - } else if (haptic->pdata->mode_ctrl == PWM_GEN_MODE) { - rc = i2c_smbus_write_byte_data(haptic->client, - ISA1200_HCTRL5, - HCTRL5_VIB_STRT); - if (rc < 0) - pr_err("start vibration fail\n"); - } - } else { - if (haptic->pdata->mode_ctrl == PWM_INPUT_MODE) - pwm_disable(haptic->pwm); - else if (haptic->pdata->mode_ctrl == PWM_GEN_MODE) { - rc = i2c_smbus_write_byte_data(haptic->client, - ISA1200_HCTRL5, - HCTRL5_VIB_STOP); - if (rc < 0) - pr_err("stop vibration fail\n"); - } - } -} - -static int isa1200_setup(struct i2c_client *client) -{ - struct isa1200_chip *haptic = i2c_get_clientdata(client); - int value, temp, rc; - - gpio_set_value_cansleep(haptic->pdata->hap_en_gpio, 0); - udelay(POR_DELAY_USEC); - gpio_set_value_cansleep(haptic->pdata->hap_en_gpio, 1); - - value = (haptic->pdata->smart_en << HCTRL1_SMART_ENABLE_BIT) | - (haptic->pdata->is_erm << HCTRL1_ERM_BIT) | - (haptic->pdata->ext_clk_en << HCTRL1_EXT_CLK_ENABLE_BIT); - - rc = i2c_smbus_write_byte_data(client, ISA1200_HCTRL1, value); - if (rc < 0) { - pr_err("i2c write failure\n"); - return rc; - } - - if (haptic->pdata->mode_ctrl == PWM_GEN_MODE) { - temp = haptic->pdata->pwm_fd.pwm_div; - if (temp < DIVIDER_128 || temp > DIVIDER_1024 || - temp % DIVIDER_128) { - pr_err("Invalid divider\n"); - rc = -EINVAL; - goto reset_hctrl1; - } - value = ((temp >> DIVIDE_SHIFTER_128) - 1); - } else if (haptic->pdata->mode_ctrl == PWM_INPUT_MODE) { - temp = haptic->pdata->pwm_fd.pwm_freq; - if (temp < FREQ_22400 || temp > FREQ_172600 || - temp % FREQ_22400) { - pr_err("Invalid frequency\n"); - rc = -EINVAL; - goto reset_hctrl1; - } - value = ((temp / FREQ_22400) - 1); - haptic->period_ns = NSEC_PER_SEC / temp; - } - value |= (haptic->pdata->mode_ctrl << HCTRL0_MODE_CTRL_BIT) | - (haptic->pdata->overdrive_high << HCTRL0_OVERDRIVE_HIGH_BIT) | - (haptic->pdata->overdrive_en << HCTRL0_OVERDRIVE_EN_BIT) | - (haptic->pdata->chip_en << HCTRL0_HAP_EN); - - rc = i2c_smbus_write_byte_data(client, ISA1200_HCTRL0, value); - if (rc < 0) { - pr_err("i2c write failure\n"); - goto reset_hctrl1; - } - - return 0; - -reset_hctrl1: - i2c_smbus_write_byte_data(client, ISA1200_HCTRL1, - HCTRL1_RESET); - return rc; -} - -static void isa1200_worker(struct work_struct *work) -{ - struct isa1200_chip *haptic; - - haptic = container_of(work, struct isa1200_chip, work); - isa1200_vib_set(haptic, !!haptic->state); -} - -static int isa1200_play_effect(struct input_dev *dev, void *data, - struct ff_effect *effect) -{ - struct isa1200_chip *haptic = input_get_drvdata(dev); - - /* support basic vibration */ - haptic->state = effect->u.rumble.strong_magnitude >> 8; - if (!haptic->state) - haptic->state = effect->u.rumble.weak_magnitude >> 9; - - schedule_work(&haptic->work); - - return 0; -} - -#ifdef CONFIG_PM -static int isa1200_suspend(struct device *dev) -{ - struct isa1200_chip *haptic = dev_get_drvdata(dev); - int rc; - - cancel_work_sync(&haptic->work); - /* turn-off current vibration */ - isa1200_vib_set(haptic, 0); - - if (haptic->pdata->power_on) { - rc = haptic->pdata->power_on(0); - if (rc) { - pr_err("power-down failed\n"); - return rc; - } - } - - return 0; -} - -static int isa1200_resume(struct device *dev) -{ - struct isa1200_chip *haptic = dev_get_drvdata(dev); - int rc; - - if (haptic->pdata->power_on) { - rc = haptic->pdata->power_on(1); - if (rc) { - pr_err("power-up failed\n"); - return rc; - } - } - - isa1200_setup(haptic->client); - return 0; -} -#else -#define isa1200_suspend NULL -#define isa1200_resume NULL -#endif - -static int isa1200_open(struct input_dev *dev) -{ - struct isa1200_chip *haptic = input_get_drvdata(dev); - int rc; - - /* device setup */ - if (haptic->pdata->dev_setup) { - rc = haptic->pdata->dev_setup(true); - if (rc < 0) { - pr_err("setup failed!\n"); - return rc; - } - } - - /* power on */ - if (haptic->pdata->power_on) { - rc = haptic->pdata->power_on(true); - if (rc < 0) { - pr_err("power failed\n"); - goto err_setup; - } - } - - /* request gpio */ - rc = gpio_is_valid(haptic->pdata->hap_en_gpio); - if (rc) { - rc = gpio_request(haptic->pdata->hap_en_gpio, "haptic_gpio"); - if (rc) { - pr_err("gpio %d request failed\n", - haptic->pdata->hap_en_gpio); - goto err_power_on; - } - } else { - pr_err("Invalid gpio %d\n", - haptic->pdata->hap_en_gpio); - goto err_power_on; - } - - rc = gpio_direction_output(haptic->pdata->hap_en_gpio, 0); - if (rc) { - pr_err("gpio %d set direction failed\n", - haptic->pdata->hap_en_gpio); - goto err_gpio_free; - } - - /* setup registers */ - rc = isa1200_setup(haptic->client); - if (rc < 0) { - pr_err("setup fail %d\n", rc); - goto err_gpio_free; - } - - if (haptic->pdata->mode_ctrl == PWM_INPUT_MODE) { - haptic->pwm = pwm_request(haptic->pdata->pwm_ch_id, - haptic->client->driver->id_table->name); - if (IS_ERR(haptic->pwm)) { - pr_err("pwm request failed\n"); - rc = PTR_ERR(haptic->pwm); - goto err_reset_hctrl0; - } - } - - /* init workqeueue */ - INIT_WORK(&haptic->work, isa1200_worker); - return 0; - -err_reset_hctrl0: - i2c_smbus_write_byte_data(haptic->client, ISA1200_HCTRL0, - HCTRL0_RESET); -err_gpio_free: - gpio_free(haptic->pdata->hap_en_gpio); -err_power_on: - if (haptic->pdata->power_on) - haptic->pdata->power_on(0); -err_setup: - if (haptic->pdata->dev_setup) - haptic->pdata->dev_setup(false); - - return rc; -} - -static void isa1200_close(struct input_dev *dev) -{ - struct isa1200_chip *haptic = input_get_drvdata(dev); - - /* turn-off current vibration */ - isa1200_vib_set(haptic, 0); - - if (haptic->pdata->mode_ctrl == PWM_INPUT_MODE) - pwm_free(haptic->pwm); - - gpio_free(haptic->pdata->hap_en_gpio); - - /* reset hardware registers */ - i2c_smbus_write_byte_data(haptic->client, ISA1200_HCTRL0, - HCTRL0_RESET); - i2c_smbus_write_byte_data(haptic->client, ISA1200_HCTRL1, - HCTRL1_RESET); - - if (haptic->pdata->dev_setup) - haptic->pdata->dev_setup(false); - - /* power-off the chip */ - if (haptic->pdata->power_on) - haptic->pdata->power_on(0); -} - -static int isa1200_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct isa1200_chip *haptic; - int rc; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - pr_err("i2c is not supported\n"); - return -EIO; - } - - if (!client->dev.platform_data) { - pr_err("pdata is not avaiable\n"); - return -EINVAL; - } - - haptic = kzalloc(sizeof(struct isa1200_chip), GFP_KERNEL); - if (!haptic) { - pr_err("no memory\n"); - return -ENOMEM; - } - - haptic->pdata = client->dev.platform_data; - haptic->client = client; - - i2c_set_clientdata(client, haptic); - - haptic->input_device = input_allocate_device(); - if (!haptic->input_device) { - pr_err("input device alloc failed\n"); - rc = -ENOMEM; - goto err_mem_alloc; - } - - input_set_drvdata(haptic->input_device, haptic); - haptic->input_device->name = haptic->pdata->name ? : - "isa1200-ff-memless"; - - haptic->input_device->dev.parent = &client->dev; - - input_set_capability(haptic->input_device, EV_FF, FF_RUMBLE); - - haptic->input_device->open = isa1200_open; - haptic->input_device->close = isa1200_close; - - rc = input_ff_create_memless(haptic->input_device, NULL, - isa1200_play_effect); - if (rc < 0) { - pr_err("unable to register with ff\n"); - goto err_free_dev; - } - - rc = input_register_device(haptic->input_device); - if (rc < 0) { - pr_err("unable to register input device\n"); - goto err_ff_destroy; - } - - return 0; - -err_ff_destroy: - input_ff_destroy(haptic->input_device); -err_free_dev: - input_free_device(haptic->input_device); -err_mem_alloc: - kfree(haptic); - return rc; -} - -static int isa1200_remove(struct i2c_client *client) -{ - struct isa1200_chip *haptic = i2c_get_clientdata(client); - - input_unregister_device(haptic->input_device); - kfree(haptic); - - return 0; -} - -static const struct i2c_device_id isa1200_id_table[] = { - {"isa1200_1", 0}, - { }, -}; -MODULE_DEVICE_TABLE(i2c, isa1200_id_table); - -static const struct dev_pm_ops isa1200_pm_ops = { - .suspend = isa1200_suspend, - .resume = isa1200_resume, -}; - -static struct i2c_driver isa1200_driver = { - .driver = { - .name = "isa1200-ff-memless", - .owner = THIS_MODULE, - .pm = &isa1200_pm_ops, - }, - .probe = isa1200_probe, - .remove = isa1200_remove, - .id_table = isa1200_id_table, -}; - -static int __init isa1200_init(void) -{ - return i2c_add_driver(&isa1200_driver); -} -module_init(isa1200_init); - -static void __exit isa1200_exit(void) -{ - i2c_del_driver(&isa1200_driver); -} -module_exit(isa1200_exit); - -MODULE_DESCRIPTION("isa1200 based vibrator chip driver"); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Kyungmin Park "); diff --git a/drivers/input/misc/lis3dh_acc.c b/drivers/input/misc/lis3dh_acc.c deleted file mode 100644 index f31c174832b7e8059b5cb014c85a4b7d24c54add..0000000000000000000000000000000000000000 --- a/drivers/input/misc/lis3dh_acc.c +++ /dev/null @@ -1,1596 +0,0 @@ -/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** - * - * File Name : lis3dh_acc.c - * Authors : MSH - Motion Mems BU - Application Team - * : Matteo Dameno (matteo.dameno@st.com) - * : Carmine Iascone (carmine.iascone@st.com) - * : Samuel Huo (samuel.huo@st.com) - * Version : V.1.1.0 - * Date : 07/10/2012 - * Description : LIS3DH accelerometer sensor driver - * - ******************************************************************************* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * THE PRESENT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, FOR THE SOLE - * PURPOSE TO SUPPORT YOUR APPLICATION DEVELOPMENT. - * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, - * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE - * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING - * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - * THIS SOFTWARE IS SPECIFICALLY DESIGNED FOR EXCLUSIVE USE WITH ST PARTS. - * - ****************************************************************************** - Revision 1.0.0 05/11/09 - First Release; - Revision 1.0.3 22/01/2010 - Linux K&R Compliant Release; - Revision 1.0.5 16/08/2010 - modified _get_acceleration_data function; - modified _update_odr function; - manages 2 interrupts; - Revision 1.0.6 15/11/2010 - supports sysfs; - no more support for ioctl; - Revision 1.0.7 26/11/2010 - checks for availability of interrupts pins - correction on FUZZ and FLAT values; - Revision 1.0.8 2010/Apr/01 - corrects a bug in interrupt pin management in 1.0.7 - Revision 1.0.9 07/25/2011 - Romove several unused functions,add 5ms delay in init,change sysfs attributes. - Revision 1.1.0 07/10/2012 - To replace some deprecated functions for 3.4 kernel; - To pass the checkpatch's formatting requirement; - To add regulator request; - - ******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define DEBUG 1 - -#define G_MAX 16000 - - -#define SENSITIVITY_2G 1 /** mg/LSB */ -#define SENSITIVITY_4G 2 /** mg/LSB */ -#define SENSITIVITY_8G 4 /** mg/LSB */ -#define SENSITIVITY_16G 12 /** mg/LSB */ - - - - -/* Accelerometer Sensor Operating Mode */ -#define LIS3DH_ACC_ENABLE 0x01 -#define LIS3DH_ACC_DISABLE 0x00 - -#define HIGH_RESOLUTION 0x08 - -#define AXISDATA_REG 0x28 -#define WHOAMI_LIS3DH_ACC 0x33 /* Expected content for WAI */ - -/* CONTROL REGISTERS */ -#define WHO_AM_I 0x0F /* WhoAmI register */ -#define TEMP_CFG_REG 0x1F /* temper sens control reg */ -/* ctrl 1: ODR3 ODR2 ODR ODR0 LPen Zenable Yenable Zenable */ -#define CTRL_REG1 0x20 /* control reg 1 */ -#define CTRL_REG2 0x21 /* control reg 2 */ -#define CTRL_REG3 0x22 /* control reg 3 */ -#define CTRL_REG4 0x23 /* control reg 4 */ -#define CTRL_REG5 0x24 /* control reg 5 */ -#define CTRL_REG6 0x25 /* control reg 6 */ - -#define FIFO_CTRL_REG 0x2E /* FiFo control reg */ - -#define INT_CFG1 0x30 /* interrupt 1 config */ -#define INT_SRC1 0x31 /* interrupt 1 source */ -#define INT_THS1 0x32 /* interrupt 1 threshold */ -#define INT_DUR1 0x33 /* interrupt 1 duration */ - - -#define TT_CFG 0x38 /* tap config */ -#define TT_SRC 0x39 /* tap source */ -#define TT_THS 0x3A /* tap threshold */ -#define TT_LIM 0x3B /* tap time limit */ -#define TT_TLAT 0x3C /* tap time latency */ -#define TT_TW 0x3D /* tap time window */ -/* end CONTROL REGISTRES */ - - -#define ENABLE_HIGH_RESOLUTION 1 - -#define LIS3DH_ACC_PM_OFF 0x00 -#define LIS3DH_ACC_ENABLE_ALL_AXES 0x07 - - -#define PMODE_MASK 0x08 -#define ODR_MASK 0XF0 - -#define ODR1 0x10 /* 1Hz output data rate */ -#define ODR10 0x20 /* 10Hz output data rate */ -#define ODR25 0x30 /* 25Hz output data rate */ -#define ODR50 0x40 /* 50Hz output data rate */ -#define ODR100 0x50 /* 100Hz output data rate */ -#define ODR200 0x60 /* 200Hz output data rate */ -#define ODR400 0x70 /* 400Hz output data rate */ -#define ODR1250 0x90 /* 1250Hz output data rate */ - - - -#define IA 0x40 -#define ZH 0x20 -#define ZL 0x10 -#define YH 0x08 -#define YL 0x04 -#define XH 0x02 -#define XL 0x01 -/* */ -/* CTRL REG BITS*/ -#define CTRL_REG3_I1_AOI1 0x40 -#define CTRL_REG6_I2_TAPEN 0x80 -#define CTRL_REG6_HLACTIVE 0x02 -/* */ -#define NO_MASK 0xFF -#define INT1_DURATION_MASK 0x7F -#define INT1_THRESHOLD_MASK 0x7F -#define TAP_CFG_MASK 0x3F -#define TAP_THS_MASK 0x7F -#define TAP_TLIM_MASK 0x7F -#define TAP_TLAT_MASK NO_MASK -#define TAP_TW_MASK NO_MASK - - -/* TAP_SOURCE_REG BIT */ -#define DTAP 0x20 -#define STAP 0x10 -#define SIGNTAP 0x08 -#define ZTAP 0x04 -#define YTAP 0x02 -#define XTAZ 0x01 - - -#define FUZZ 0 -#define FLAT 0 -#define I2C_RETRY_DELAY 5 -#define I2C_RETRIES 5 -#define I2C_AUTO_INCREMENT 0x80 - -/* RESUME STATE INDICES */ -#define RES_CTRL_REG1 0 -#define RES_CTRL_REG2 1 -#define RES_CTRL_REG3 2 -#define RES_CTRL_REG4 3 -#define RES_CTRL_REG5 4 -#define RES_CTRL_REG6 5 - -#define RES_INT_CFG1 6 -#define RES_INT_THS1 7 -#define RES_INT_DUR1 8 - -#define RES_TT_CFG 9 -#define RES_TT_THS 10 -#define RES_TT_LIM 11 -#define RES_TT_TLAT 12 -#define RES_TT_TW 13 - -#define RES_TEMP_CFG_REG 14 -#define RES_REFERENCE_REG 15 -#define RES_FIFO_CTRL_REG 16 - -#define RESUME_ENTRIES 17 -/* end RESUME STATE INDICES */ - - -struct { - unsigned int cutoff_ms; - unsigned int mask; -} lis3dh_acc_odr_table[] = { - { 1, ODR1250 }, - { 3, ODR400 }, - { 5, ODR200 }, - { 10, ODR100 }, - { 20, ODR50 }, - { 40, ODR25 }, - { 100, ODR10 }, - { 1000, ODR1 }, -}; - -struct lis3dh_acc_data { - struct i2c_client *client; - struct lis3dh_acc_platform_data *pdata; - - struct mutex lock; - struct delayed_work input_work; - - struct input_dev *input_dev; - - int hw_initialized; - /* hw_working=-1 means not tested yet */ - int hw_working; - atomic_t enabled; - int on_before_suspend; - - u8 sensitivity; - - u8 resume_state[RESUME_ENTRIES]; - - int irq1; - struct work_struct irq1_work; - struct workqueue_struct *irq1_work_queue; - int irq2; - struct work_struct irq2_work; - struct workqueue_struct *irq2_work_queue; - -#ifdef DEBUG - u8 reg_addr; -#endif -}; - -struct sensor_regulator { - struct regulator *vreg; - const char *name; - u32 min_uV; - u32 max_uV; -}; - -struct sensor_regulator lis3dh_acc_vreg[] = { - {NULL, "vdd", 1700000, 3600000}, - {NULL, "vddio", 1700000, 3600000}, -}; - -static int lis3dh_acc_config_regulator(struct lis3dh_acc_data *acc, bool on) -{ - int rc = 0, i; - int num_reg = sizeof(lis3dh_acc_vreg) / sizeof(struct sensor_regulator); - - if (on) { - for (i = 0; i < num_reg; i++) { - lis3dh_acc_vreg[i].vreg = - regulator_get(&acc->client->dev, - lis3dh_acc_vreg[i].name); - if (IS_ERR(lis3dh_acc_vreg[i].vreg)) { - rc = PTR_ERR(lis3dh_acc_vreg[i].vreg); - pr_err("%s:regulator get failed rc=%d\n", - __func__, rc); - lis3dh_acc_vreg[i].vreg = NULL; - goto error_vdd; - } - - if (regulator_count_voltages( - lis3dh_acc_vreg[i].vreg) > 0) { - rc = regulator_set_voltage( - lis3dh_acc_vreg[i].vreg, - lis3dh_acc_vreg[i].min_uV, - lis3dh_acc_vreg[i].max_uV); - if (rc) { - pr_err("%s: set voltage failed rc=%d\n", - __func__, rc); - regulator_put(lis3dh_acc_vreg[i].vreg); - lis3dh_acc_vreg[i].vreg = NULL; - goto error_vdd; - } - } - - rc = regulator_enable(lis3dh_acc_vreg[i].vreg); - if (rc) { - pr_err("%s: regulator_enable failed rc =%d\n", - __func__, rc); - if (regulator_count_voltages( - lis3dh_acc_vreg[i].vreg) > 0) { - regulator_set_voltage( - lis3dh_acc_vreg[i].vreg, 0, - lis3dh_acc_vreg[i].max_uV); - } - regulator_put(lis3dh_acc_vreg[i].vreg); - lis3dh_acc_vreg[i].vreg = NULL; - goto error_vdd; - } - } - return rc; - } else { - i = num_reg; - } - -error_vdd: - while (--i >= 0) { - if (!IS_ERR_OR_NULL(lis3dh_acc_vreg[i].vreg)) { - if (regulator_count_voltages( - lis3dh_acc_vreg[i].vreg) > 0) { - regulator_set_voltage(lis3dh_acc_vreg[i].vreg, - 0, lis3dh_acc_vreg[i].max_uV); - } - regulator_disable(lis3dh_acc_vreg[i].vreg); - regulator_put(lis3dh_acc_vreg[i].vreg); - lis3dh_acc_vreg[i].vreg = NULL; - } - } - return rc; -} - -static int lis3dh_acc_i2c_read(struct lis3dh_acc_data *acc, - u8 *buf, int len) -{ - int err; - int tries = 0; - - struct i2c_msg msgs[] = { - { - .addr = acc->client->addr, - .flags = acc->client->flags & I2C_M_TEN, - .len = 1, - .buf = buf, - }, - { - .addr = acc->client->addr, - .flags = (acc->client->flags & I2C_M_TEN) | I2C_M_RD, - .len = len, - .buf = buf, - }, - }; - - do { - err = i2c_transfer(acc->client->adapter, msgs, 2); - if (err != 2) - msleep_interruptible(I2C_RETRY_DELAY); - } while ((err != 2) && (++tries < I2C_RETRIES)); - - if (err != 2) { - dev_err(&acc->client->dev, "read transfer error\n"); - err = -EIO; - } else { - err = 0; - } - - return err; -} - -static int lis3dh_acc_i2c_write(struct lis3dh_acc_data *acc, u8 *buf, int len) -{ - int err; - int tries = 0; - - struct i2c_msg msgs[] = { - { - .addr = acc->client->addr, - .flags = acc->client->flags & I2C_M_TEN, - .len = len + 1, - .buf = buf, - }, - }; - - do { - err = i2c_transfer(acc->client->adapter, msgs, 1); - if (err != 1) - msleep_interruptible(I2C_RETRY_DELAY); - } while ((err != 1) && (++tries < I2C_RETRIES)); - - if (err != 1) { - dev_err(&acc->client->dev, "write transfer error\n"); - err = -EIO; - } else { - err = 0; - } - - return err; -} - -static int lis3dh_acc_hw_init(struct lis3dh_acc_data *acc) -{ - int err = -1; - u8 buf[7]; - - printk(KERN_INFO "%s: hw init start\n", LIS3DH_ACC_DEV_NAME); - - buf[0] = WHO_AM_I; - err = lis3dh_acc_i2c_read(acc, buf, 1); - if (err < 0) { - dev_warn(&acc->client->dev, - "Error reading WHO_AM_I: is device available/working?\n"); - goto err_firstread; - } else - acc->hw_working = 1; - if (buf[0] != WHOAMI_LIS3DH_ACC) { - dev_err(&acc->client->dev, - "device unknown. Expected: 0x%x, Replies: 0x%x\n", - WHOAMI_LIS3DH_ACC, buf[0]); - err = -1; /* choose the right coded error */ - goto err_unknown_device; - } - - buf[0] = CTRL_REG1; - buf[1] = acc->resume_state[RES_CTRL_REG1]; - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - goto err_resume_state; - - buf[0] = TEMP_CFG_REG; - buf[1] = acc->resume_state[RES_TEMP_CFG_REG]; - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - goto err_resume_state; - - buf[0] = FIFO_CTRL_REG; - buf[1] = acc->resume_state[RES_FIFO_CTRL_REG]; - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - goto err_resume_state; - - buf[0] = (I2C_AUTO_INCREMENT | TT_THS); - buf[1] = acc->resume_state[RES_TT_THS]; - buf[2] = acc->resume_state[RES_TT_LIM]; - buf[3] = acc->resume_state[RES_TT_TLAT]; - buf[4] = acc->resume_state[RES_TT_TW]; - err = lis3dh_acc_i2c_write(acc, buf, 4); - if (err < 0) - goto err_resume_state; - buf[0] = TT_CFG; - buf[1] = acc->resume_state[RES_TT_CFG]; - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - goto err_resume_state; - - buf[0] = (I2C_AUTO_INCREMENT | INT_THS1); - buf[1] = acc->resume_state[RES_INT_THS1]; - buf[2] = acc->resume_state[RES_INT_DUR1]; - err = lis3dh_acc_i2c_write(acc, buf, 2); - if (err < 0) - goto err_resume_state; - buf[0] = INT_CFG1; - buf[1] = acc->resume_state[RES_INT_CFG1]; - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - goto err_resume_state; - - - buf[0] = (I2C_AUTO_INCREMENT | CTRL_REG2); - buf[1] = acc->resume_state[RES_CTRL_REG2]; - buf[2] = acc->resume_state[RES_CTRL_REG3]; - buf[3] = acc->resume_state[RES_CTRL_REG4]; - buf[4] = acc->resume_state[RES_CTRL_REG5]; - buf[5] = acc->resume_state[RES_CTRL_REG6]; - err = lis3dh_acc_i2c_write(acc, buf, 5); - if (err < 0) - goto err_resume_state; - - acc->hw_initialized = 1; - printk(KERN_INFO "%s: hw init done\n", LIS3DH_ACC_DEV_NAME); - return 0; - -err_firstread: - acc->hw_working = 0; -err_unknown_device: -err_resume_state: - acc->hw_initialized = 0; - dev_err(&acc->client->dev, "hw init error 0x%x,0x%x: %d\n", buf[0], - buf[1], err); - return err; -} - -static void lis3dh_acc_device_power_off(struct lis3dh_acc_data *acc) -{ - int err; - u8 buf[2] = { CTRL_REG1, LIS3DH_ACC_PM_OFF }; - - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - dev_err(&acc->client->dev, "soft power off failed: %d\n", err); - - if (acc->pdata->gpio_int1) - disable_irq_nosync(acc->irq1); - if (acc->pdata->gpio_int2) - disable_irq_nosync(acc->irq2); - - lis3dh_acc_config_regulator(acc, false); - - if (acc->hw_initialized) { - if (acc->pdata->gpio_int1) - disable_irq_nosync(acc->irq1); - if (acc->pdata->gpio_int2) - disable_irq_nosync(acc->irq2); - acc->hw_initialized = 0; - } -} - -static int lis3dh_acc_device_power_on(struct lis3dh_acc_data *acc) -{ - int err = -1; - - err = lis3dh_acc_config_regulator(acc, true); - if (err < 0) { - dev_err(&acc->client->dev, - "power_on failed: %d\n", err); - return err; - } - - if (acc->pdata->gpio_int1 >= 0) - enable_irq(acc->irq1); - if (acc->pdata->gpio_int2 >= 0) - enable_irq(acc->irq2); - - msleep(20); - - if (!acc->hw_initialized) { - err = lis3dh_acc_hw_init(acc); - if (acc->hw_working == 1 && err < 0) { - lis3dh_acc_device_power_off(acc); - return err; - } - } - - if (acc->hw_initialized) { - if (acc->pdata->gpio_int1 >= 0) - enable_irq(acc->irq1); - if (acc->pdata->gpio_int2 >= 0) - enable_irq(acc->irq2); - } - return 0; -} - -static irqreturn_t lis3dh_acc_isr1(int irq, void *dev) -{ - struct lis3dh_acc_data *acc = dev; - - disable_irq_nosync(irq); - queue_work(acc->irq1_work_queue, &acc->irq1_work); -#ifdef DEBUG - printk(KERN_INFO "%s: isr1 queued\n", LIS3DH_ACC_DEV_NAME); -#endif - return IRQ_HANDLED; -} - -static irqreturn_t lis3dh_acc_isr2(int irq, void *dev) -{ - struct lis3dh_acc_data *acc = dev; - - disable_irq_nosync(irq); - queue_work(acc->irq2_work_queue, &acc->irq2_work); -#ifdef DEBUG - printk(KERN_INFO "%s: isr2 queued\n", LIS3DH_ACC_DEV_NAME); -#endif - return IRQ_HANDLED; -} - -static void lis3dh_acc_irq1_work_func(struct work_struct *work) -{ - - struct lis3dh_acc_data *acc = - container_of(work, struct lis3dh_acc_data, irq1_work); - /* TODO add interrupt service procedure. - ie:lis3dh_acc_get_int1_source(acc); */ - ; - /* */ - printk(KERN_INFO "%s: IRQ1 triggered\n", LIS3DH_ACC_DEV_NAME); - goto exit; -exit: - enable_irq(acc->irq1); -} - -static void lis3dh_acc_irq2_work_func(struct work_struct *work) -{ - - struct lis3dh_acc_data *acc = - container_of(work, struct lis3dh_acc_data, irq2_work); - /* TODO add interrupt service procedure. - ie:lis3dh_acc_get_tap_source(acc); */ - ; - /* */ - printk(KERN_INFO "%s: IRQ2 triggered\n", LIS3DH_ACC_DEV_NAME); - goto exit; -exit: - enable_irq(acc->irq2); -} - -int lis3dh_acc_update_g_range(struct lis3dh_acc_data *acc, u8 new_g_range) -{ - int err = -1; - - u8 sensitivity; - u8 buf[2]; - u8 updated_val; - u8 init_val; - u8 new_val; - u8 mask = LIS3DH_ACC_FS_MASK | HIGH_RESOLUTION; - - switch (new_g_range) { - case LIS3DH_ACC_G_2G: - - sensitivity = SENSITIVITY_2G; - break; - case LIS3DH_ACC_G_4G: - - sensitivity = SENSITIVITY_4G; - break; - case LIS3DH_ACC_G_8G: - - sensitivity = SENSITIVITY_8G; - break; - case LIS3DH_ACC_G_16G: - - sensitivity = SENSITIVITY_16G; - break; - default: - dev_err(&acc->client->dev, "invalid g range requested: %u\n", - new_g_range); - return -EINVAL; - } - - if (atomic_read(&acc->enabled)) { - /* Updates configuration register 4, - * which contains g range setting */ - buf[0] = CTRL_REG4; - err = lis3dh_acc_i2c_read(acc, buf, 1); - if (err < 0) - goto error; - init_val = buf[0]; - acc->resume_state[RES_CTRL_REG4] = init_val; - new_val = new_g_range | HIGH_RESOLUTION; - updated_val = ((mask & new_val) | ((~mask) & init_val)); - buf[1] = updated_val; - buf[0] = CTRL_REG4; - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - goto error; - acc->resume_state[RES_CTRL_REG4] = updated_val; - acc->sensitivity = sensitivity; - } - - - return err; -error: - dev_err(&acc->client->dev, "update g range failed 0x%x,0x%x: %d\n", - buf[0], buf[1], err); - - return err; -} - -int lis3dh_acc_update_odr(struct lis3dh_acc_data *acc, int poll_interval_ms) -{ - int err = -1; - int i; - u8 config[2]; - - /* Following, looks for the longest possible odr interval scrolling the - * odr_table vector from the end (shortest interval) backward (longest - * interval), to support the poll_interval requested by the system. - * It must be the longest interval lower then the poll interval.*/ - for (i = ARRAY_SIZE(lis3dh_acc_odr_table) - 1; i >= 0; i--) { - if (lis3dh_acc_odr_table[i].cutoff_ms <= poll_interval_ms) - break; - } - config[1] = lis3dh_acc_odr_table[i].mask; - - config[1] |= LIS3DH_ACC_ENABLE_ALL_AXES; - - /* If device is currently enabled, we need to write new - * configuration out to it */ - if (atomic_read(&acc->enabled)) { - config[0] = CTRL_REG1; - err = lis3dh_acc_i2c_write(acc, config, 1); - if (err < 0) - goto error; - acc->resume_state[RES_CTRL_REG1] = config[1]; - } - - return err; - -error: - dev_err(&acc->client->dev, "update odr failed 0x%x,0x%x: %d\n", - config[0], config[1], err); - - return err; -} - - - -static int lis3dh_acc_register_write(struct lis3dh_acc_data *acc, u8 *buf, - u8 reg_address, u8 new_value) -{ - int err = -1; - - /* Sets configuration register at reg_address - * NOTE: this is a straight overwrite */ - buf[0] = reg_address; - buf[1] = new_value; - err = lis3dh_acc_i2c_write(acc, buf, 1); - if (err < 0) - return err; - return err; -} - -static int lis3dh_acc_get_acceleration_data(struct lis3dh_acc_data *acc, - int *xyz) -{ - int err = -1; - /* Data bytes from hardware xL, xH, yL, yH, zL, zH */ - u8 acc_data[6]; - /* x,y,z hardware data */ - s16 hw_d[3] = { 0 }; - - acc_data[0] = (I2C_AUTO_INCREMENT | AXISDATA_REG); - err = lis3dh_acc_i2c_read(acc, acc_data, 6); - if (err < 0) - return err; - - hw_d[0] = (((s16) ((acc_data[1] << 8) | acc_data[0])) >> 4); - hw_d[1] = (((s16) ((acc_data[3] << 8) | acc_data[2])) >> 4); - hw_d[2] = (((s16) ((acc_data[5] << 8) | acc_data[4])) >> 4); - - hw_d[0] = hw_d[0] * acc->sensitivity; - hw_d[1] = hw_d[1] * acc->sensitivity; - hw_d[2] = hw_d[2] * acc->sensitivity; - - - xyz[0] = ((acc->pdata->negate_x) ? (-hw_d[acc->pdata->axis_map_x]) - : (hw_d[acc->pdata->axis_map_x])); - xyz[1] = ((acc->pdata->negate_y) ? (-hw_d[acc->pdata->axis_map_y]) - : (hw_d[acc->pdata->axis_map_y])); - xyz[2] = ((acc->pdata->negate_z) ? (-hw_d[acc->pdata->axis_map_z]) - : (hw_d[acc->pdata->axis_map_z])); - - #ifdef DEBUG - /* - printk(KERN_INFO "%s read x=%d, y=%d, z=%d\n", - LIS3DH_ACC_DEV_NAME, xyz[0], xyz[1], xyz[2]); - */ - #endif - return err; -} - -static void lis3dh_acc_report_values(struct lis3dh_acc_data *acc, - int *xyz) -{ - input_report_abs(acc->input_dev, ABS_X, xyz[0]); - input_report_abs(acc->input_dev, ABS_Y, xyz[1]); - input_report_abs(acc->input_dev, ABS_Z, xyz[2]); - input_sync(acc->input_dev); -} - -static int lis3dh_acc_enable(struct lis3dh_acc_data *acc) -{ - int err; - - if (!atomic_cmpxchg(&acc->enabled, 0, 1)) { - err = lis3dh_acc_device_power_on(acc); - if (err < 0) { - atomic_set(&acc->enabled, 0); - return err; - } - schedule_delayed_work(&acc->input_work, - msecs_to_jiffies(acc->pdata->poll_interval)); - } - - return 0; -} - -static int lis3dh_acc_disable(struct lis3dh_acc_data *acc) -{ - if (atomic_cmpxchg(&acc->enabled, 1, 0)) { - cancel_delayed_work_sync(&acc->input_work); - lis3dh_acc_device_power_off(acc); - } - - return 0; -} - - -static ssize_t read_single_reg(struct device *dev, char *buf, u8 reg) -{ - ssize_t ret; - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - int err; - - u8 data = reg; - err = lis3dh_acc_i2c_read(acc, &data, 1); - if (err < 0) - return err; - ret = snprintf(buf, 4, "0x%02x\n", data); - return ret; - -} - -static int write_reg(struct device *dev, const char *buf, u8 reg, - u8 mask, int resumeIndex) -{ - int err = -1; - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - u8 x[2]; - u8 new_val; - unsigned long val; - - if (kstrtoul(buf, 16, &val)) - return -EINVAL; - - new_val = ((u8) val & mask); - x[0] = reg; - x[1] = new_val; - err = lis3dh_acc_register_write(acc, x, reg, new_val); - if (err < 0) - return err; - acc->resume_state[resumeIndex] = new_val; - return err; -} - -static ssize_t attr_get_polling_rate(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int val; - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - mutex_lock(&acc->lock); - val = acc->pdata->poll_interval; - mutex_unlock(&acc->lock); - return snprintf(buf, 8, "%d\n", val); -} - -static ssize_t attr_set_polling_rate(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - unsigned long interval_ms; - - if (kstrtoul(buf, 10, &interval_ms)) - return -EINVAL; - if (!interval_ms) - return -EINVAL; - mutex_lock(&acc->lock); - acc->pdata->poll_interval = interval_ms; - lis3dh_acc_update_odr(acc, interval_ms); - mutex_unlock(&acc->lock); - return size; -} - -static ssize_t attr_get_range(struct device *dev, - struct device_attribute *attr, char *buf) -{ - char val; - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - char range = 2; - mutex_lock(&acc->lock); - val = acc->pdata->g_range ; - switch (val) { - case LIS3DH_ACC_G_2G: - range = 2; - break; - case LIS3DH_ACC_G_4G: - range = 4; - break; - case LIS3DH_ACC_G_8G: - range = 8; - break; - case LIS3DH_ACC_G_16G: - range = 16; - break; - } - mutex_unlock(&acc->lock); - return snprintf(buf, 4, "%d\n", range); -} - -static ssize_t attr_set_range(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - unsigned long val; - if (kstrtoul(buf, 10, &val)) - return -EINVAL; - mutex_lock(&acc->lock); - acc->pdata->g_range = val; - lis3dh_acc_update_g_range(acc, val); - mutex_unlock(&acc->lock); - return size; -} - -static ssize_t attr_get_enable(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - int val = atomic_read(&acc->enabled); - return snprintf(buf, sizeof(val) + 2, "%d\n", val); -} - -static ssize_t attr_set_enable(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - unsigned long val; - - if (kstrtoul(buf, 10, &val)) - return -EINVAL; - - if (val) - lis3dh_acc_enable(acc); - else - lis3dh_acc_disable(acc); - - return size; -} - -static ssize_t attr_set_intconfig1(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, INT_CFG1, NO_MASK, RES_INT_CFG1); -} - -static ssize_t attr_get_intconfig1(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, INT_CFG1); -} - -static ssize_t attr_set_duration1(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, INT_DUR1, INT1_DURATION_MASK, RES_INT_DUR1); -} - -static ssize_t attr_get_duration1(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, INT_DUR1); -} - -static ssize_t attr_set_thresh1(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, INT_THS1, INT1_THRESHOLD_MASK, RES_INT_THS1); -} - -static ssize_t attr_get_thresh1(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, INT_THS1); -} - -static ssize_t attr_get_source1(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, INT_SRC1); -} - -static ssize_t attr_set_click_cfg(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, TT_CFG, TAP_CFG_MASK, RES_TT_CFG); -} - -static ssize_t attr_get_click_cfg(struct device *dev, - struct device_attribute *attr, char *buf) -{ - - return read_single_reg(dev, buf, TT_CFG); -} - -static ssize_t attr_get_click_source(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, TT_SRC); -} - -static ssize_t attr_set_click_ths(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, TT_THS, TAP_THS_MASK, RES_TT_THS); -} - -static ssize_t attr_get_click_ths(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, TT_THS); -} - -static ssize_t attr_set_click_tlim(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, TT_LIM, TAP_TLIM_MASK, RES_TT_LIM); -} - -static ssize_t attr_get_click_tlim(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, TT_LIM); -} - -static ssize_t attr_set_click_tlat(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, TT_TLAT, TAP_TLAT_MASK, RES_TT_TLAT); -} - -static ssize_t attr_get_click_tlat(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, TT_TLAT); -} - -static ssize_t attr_set_click_tw(struct device *dev, - struct device_attribute *attr, const char *buf, size_t size) -{ - return write_reg(dev, buf, TT_TLAT, TAP_TW_MASK, RES_TT_TLAT); -} - -static ssize_t attr_get_click_tw(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return read_single_reg(dev, buf, TT_TLAT); -} - - -#ifdef DEBUG -/* PAY ATTENTION: These DEBUG funtions don't manage resume_state */ -static ssize_t attr_reg_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t size) -{ - int rc; - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - u8 x[2]; - unsigned long val; - - if (kstrtoul(buf, 16, &val)) - return -EINVAL; - mutex_lock(&acc->lock); - x[0] = acc->reg_addr; - mutex_unlock(&acc->lock); - x[1] = val; - rc = lis3dh_acc_i2c_write(acc, x, 1); - /*TODO: error need to be managed */ - return size; -} - -static ssize_t attr_reg_get(struct device *dev, struct device_attribute *attr, - char *buf) -{ - ssize_t ret; - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - int rc; - u8 data; - - mutex_lock(&acc->lock); - data = acc->reg_addr; - mutex_unlock(&acc->lock); - rc = lis3dh_acc_i2c_read(acc, &data, 1); - /* TODO: error need to be managed */ - ret = snprintf(buf, 8, "0x%02x\n", data); - return ret; -} - -static ssize_t attr_addr_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t size) -{ - struct lis3dh_acc_data *acc = dev_get_drvdata(dev); - unsigned long val; - if (kstrtoul(buf, 16, &val)) - return -EINVAL; - mutex_lock(&acc->lock); - acc->reg_addr = val; - mutex_unlock(&acc->lock); - return size; -} -#endif - -static struct device_attribute attributes[] = { - - __ATTR(poll_delay, 0664, attr_get_polling_rate, - attr_set_polling_rate), - __ATTR(range, 0664, attr_get_range, attr_set_range), - __ATTR(enable, 0664, attr_get_enable, attr_set_enable), - __ATTR(int1_config, 0664, attr_get_intconfig1, attr_set_intconfig1), - __ATTR(int1_duration, 0664, attr_get_duration1, attr_set_duration1), - __ATTR(int1_threshold, 0664, attr_get_thresh1, attr_set_thresh1), - __ATTR(int1_source, 0444, attr_get_source1, NULL), - __ATTR(click_config, 0664, attr_get_click_cfg, attr_set_click_cfg), - __ATTR(click_source, 0444, attr_get_click_source, NULL), - __ATTR(click_threshold, 0664, attr_get_click_ths, attr_set_click_ths), - __ATTR(click_timelimit, 0664, attr_get_click_tlim, - attr_set_click_tlim), - __ATTR(click_timelatency, 0664, attr_get_click_tlat, - attr_set_click_tlat), - __ATTR(click_timewindow, 0664, attr_get_click_tw, attr_set_click_tw), - -#ifdef DEBUG - __ATTR(reg_value, 0664, attr_reg_get, attr_reg_set), - __ATTR(reg_addr, 0220, NULL, attr_addr_set), -#endif -}; - -static int create_sysfs_interfaces(struct device *dev) -{ - int i; - int err; - for (i = 0; i < ARRAY_SIZE(attributes); i++) { - err = device_create_file(dev, attributes + i); - if (err) - goto error; - } - return 0; - -error: - for ( ; i >= 0; i--) - device_remove_file(dev, attributes + i); - dev_err(dev, "%s:Unable to create interface\n", __func__); - return err; -} - -static int remove_sysfs_interfaces(struct device *dev) -{ - int i; - for (i = 0; i < ARRAY_SIZE(attributes); i++) - device_remove_file(dev, attributes + i); - return 0; -} - -static void lis3dh_acc_input_work_func(struct work_struct *work) -{ - struct lis3dh_acc_data *acc; - - int xyz[3] = { 0 }; - int err; - - acc = container_of((struct delayed_work *)work, - struct lis3dh_acc_data, input_work); - - mutex_lock(&acc->lock); - err = lis3dh_acc_get_acceleration_data(acc, xyz); - if (err < 0) - dev_err(&acc->client->dev, "get_acceleration_data failed\n"); - else - lis3dh_acc_report_values(acc, xyz); - - schedule_delayed_work(&acc->input_work, msecs_to_jiffies( - acc->pdata->poll_interval)); - mutex_unlock(&acc->lock); -} - -int lis3dh_acc_input_open(struct input_dev *input) -{ - struct lis3dh_acc_data *acc = input_get_drvdata(input); - - return lis3dh_acc_enable(acc); -} - -void lis3dh_acc_input_close(struct input_dev *dev) -{ - struct lis3dh_acc_data *acc = input_get_drvdata(dev); - - lis3dh_acc_disable(acc); -} - -static int lis3dh_acc_validate_pdata(struct lis3dh_acc_data *acc) -{ - acc->pdata->poll_interval = max(acc->pdata->poll_interval, - acc->pdata->min_interval); - - if (acc->pdata->axis_map_x > 2 || - acc->pdata->axis_map_y > 2 || - acc->pdata->axis_map_z > 2) { - dev_err(&acc->client->dev, - "invalid axis_map value x:%u y:%u z%u\n", - acc->pdata->axis_map_x, - acc->pdata->axis_map_y, acc->pdata->axis_map_z); - return -EINVAL; - } - - /* Only allow 0 and 1 for negation boolean flag */ - if (acc->pdata->negate_x > 1 || acc->pdata->negate_y > 1 - || acc->pdata->negate_z > 1) { - dev_err(&acc->client->dev, - "invalid negate value x:%u y:%u z:%u\n", - acc->pdata->negate_x, - acc->pdata->negate_y, acc->pdata->negate_z); - return -EINVAL; - } - - /* Enforce minimum polling interval */ - if (acc->pdata->poll_interval < acc->pdata->min_interval) { - dev_err(&acc->client->dev, "minimum poll interval violated\n"); - return -EINVAL; - } - - return 0; -} - -static int lis3dh_acc_input_init(struct lis3dh_acc_data *acc) -{ - int err; - - INIT_DELAYED_WORK(&acc->input_work, lis3dh_acc_input_work_func); - acc->input_dev = input_allocate_device(); - if (!acc->input_dev) { - err = -ENOMEM; - dev_err(&acc->client->dev, "input device allocation failed\n"); - goto err0; - } - - acc->input_dev->open = lis3dh_acc_input_open; - acc->input_dev->close = lis3dh_acc_input_close; - acc->input_dev->name = ACCEL_INPUT_DEV_NAME; - acc->input_dev->id.bustype = BUS_I2C; - acc->input_dev->dev.parent = &acc->client->dev; - - input_set_drvdata(acc->input_dev, acc); - - set_bit(EV_ABS, acc->input_dev->evbit); - /* next is used for interruptA sources data if the case */ - set_bit(ABS_MISC, acc->input_dev->absbit); - /* next is used for interruptB sources data if the case */ - set_bit(ABS_WHEEL, acc->input_dev->absbit); - - input_set_abs_params(acc->input_dev, ABS_X, -G_MAX, G_MAX, FUZZ, FLAT); - input_set_abs_params(acc->input_dev, ABS_Y, -G_MAX, G_MAX, FUZZ, FLAT); - input_set_abs_params(acc->input_dev, ABS_Z, -G_MAX, G_MAX, FUZZ, FLAT); - /* next is used for interruptA sources data if the case */ - input_set_abs_params(acc->input_dev, ABS_MISC, INT_MIN, INT_MAX, 0, 0); - /* next is used for interruptB sources data if the case */ - input_set_abs_params(acc->input_dev, ABS_WHEEL, INT_MIN, INT_MAX, 0, 0); - - - err = input_register_device(acc->input_dev); - if (err) { - dev_err(&acc->client->dev, - "unable to register input device %s\n", - acc->input_dev->name); - goto err1; - } - - return 0; - -err1: - input_free_device(acc->input_dev); -err0: - return err; -} - -static void lis3dh_acc_input_cleanup(struct lis3dh_acc_data *acc) -{ - input_unregister_device(acc->input_dev); - input_free_device(acc->input_dev); -} - -static int lis3dh_acc_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - - struct lis3dh_acc_data *acc; - - int err = -1; - - pr_info("%s: probe start.\n", LIS3DH_ACC_DEV_NAME); - - if (client->dev.platform_data == NULL) { - dev_err(&client->dev, "platform data is NULL. exiting.\n"); - err = -ENODEV; - goto exit_check_functionality_failed; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, "client not i2c capable\n"); - err = -ENODEV; - goto exit_check_functionality_failed; - } - - /* - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE | - I2C_FUNC_SMBUS_BYTE_DATA | - I2C_FUNC_SMBUS_WORD_DATA)) { - dev_err(&client->dev, "client not smb-i2c capable:2\n"); - err = -EIO; - goto exit_check_functionality_failed; - } - - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_I2C_BLOCK)) { - dev_err(&client->dev, "client not smb-i2c capable:3\n"); - err = -EIO; - goto exit_check_functionality_failed; - } - */ - - acc = kzalloc(sizeof(struct lis3dh_acc_data), GFP_KERNEL); - if (acc == NULL) { - err = -ENOMEM; - dev_err(&client->dev, - "failed to allocate memory for module data: " - "%d\n", err); - goto exit_check_functionality_failed; - } - - - mutex_init(&acc->lock); - mutex_lock(&acc->lock); - - acc->client = client; - i2c_set_clientdata(client, acc); - - acc->pdata = kmalloc(sizeof(*acc->pdata), GFP_KERNEL); - if (acc->pdata == NULL) { - err = -ENOMEM; - dev_err(&client->dev, - "failed to allocate memory for pdata: %d\n", - err); - goto err_mutexunlock; - } - - memcpy(acc->pdata, client->dev.platform_data, sizeof(*acc->pdata)); - - err = lis3dh_acc_validate_pdata(acc); - if (err < 0) { - dev_err(&client->dev, "failed to validate platform data\n"); - goto exit_kfree_pdata; - } - - - if (acc->pdata->init) { - err = acc->pdata->init(); - if (err < 0) { - dev_err(&client->dev, "init failed: %d\n", err); - goto err_pdata_init; - } - } - - if (acc->pdata->gpio_int1 >= 0) { - acc->irq1 = gpio_to_irq(acc->pdata->gpio_int1); - printk(KERN_INFO "%s: %s has set irq1 to irq: %d\n", - LIS3DH_ACC_DEV_NAME, __func__, acc->irq1); - printk(KERN_INFO "%s: %s has mapped irq1 on gpio: %d\n", - LIS3DH_ACC_DEV_NAME, __func__, - acc->pdata->gpio_int1); - } - - if (acc->pdata->gpio_int2 >= 0) { - acc->irq2 = gpio_to_irq(acc->pdata->gpio_int2); - printk(KERN_INFO "%s: %s has set irq2 to irq: %d\n", - LIS3DH_ACC_DEV_NAME, __func__, acc->irq2); - printk(KERN_INFO "%s: %s has mapped irq2 on gpio: %d\n", - LIS3DH_ACC_DEV_NAME, __func__, - acc->pdata->gpio_int2); - } - - memset(acc->resume_state, 0, ARRAY_SIZE(acc->resume_state)); - - acc->resume_state[RES_CTRL_REG1] = LIS3DH_ACC_ENABLE_ALL_AXES; - acc->resume_state[RES_CTRL_REG2] = 0x00; - acc->resume_state[RES_CTRL_REG3] = 0x00; - acc->resume_state[RES_CTRL_REG4] = 0x00; - acc->resume_state[RES_CTRL_REG5] = 0x00; - acc->resume_state[RES_CTRL_REG6] = 0x00; - - acc->resume_state[RES_TEMP_CFG_REG] = 0x00; - acc->resume_state[RES_FIFO_CTRL_REG] = 0x00; - acc->resume_state[RES_INT_CFG1] = 0x00; - acc->resume_state[RES_INT_THS1] = 0x00; - acc->resume_state[RES_INT_DUR1] = 0x00; - - acc->resume_state[RES_TT_CFG] = 0x00; - acc->resume_state[RES_TT_THS] = 0x00; - acc->resume_state[RES_TT_LIM] = 0x00; - acc->resume_state[RES_TT_TLAT] = 0x00; - acc->resume_state[RES_TT_TW] = 0x00; - - err = lis3dh_acc_device_power_on(acc); - if (err < 0) { - dev_err(&client->dev, "power on failed: %d\n", err); - goto err_pdata_init; - } - - atomic_set(&acc->enabled, 1); - - err = lis3dh_acc_update_g_range(acc, acc->pdata->g_range); - if (err < 0) { - dev_err(&client->dev, "update_g_range failed\n"); - goto err_power_off; - } - - err = lis3dh_acc_update_odr(acc, acc->pdata->poll_interval); - if (err < 0) { - dev_err(&client->dev, "update_odr failed\n"); - goto err_power_off; - } - - err = lis3dh_acc_input_init(acc); - if (err < 0) { - dev_err(&client->dev, "input init failed\n"); - goto err_power_off; - } - - - err = create_sysfs_interfaces(&client->dev); - if (err < 0) { - dev_err(&client->dev, - "device LIS3DH_ACC_DEV_NAME sysfs register failed\n"); - goto err_input_cleanup; - } - - lis3dh_acc_device_power_off(acc); - - /* As default, do not report information */ - atomic_set(&acc->enabled, 0); - - if (acc->pdata->gpio_int1 >= 0) { - INIT_WORK(&acc->irq1_work, lis3dh_acc_irq1_work_func); - acc->irq1_work_queue = - create_singlethread_workqueue("lis3dh_acc_wq1"); - if (!acc->irq1_work_queue) { - err = -ENOMEM; - dev_err(&client->dev, - "cannot create work queue1: %d\n", err); - goto err_remove_sysfs_int; - } - err = request_irq(acc->irq1, lis3dh_acc_isr1, - IRQF_TRIGGER_RISING, "lis3dh_acc_irq1", acc); - if (err < 0) { - dev_err(&client->dev, "request irq1 failed: %d\n", err); - goto err_destoyworkqueue1; - } - disable_irq_nosync(acc->irq1); - } - - if (acc->pdata->gpio_int2 >= 0) { - INIT_WORK(&acc->irq2_work, lis3dh_acc_irq2_work_func); - acc->irq2_work_queue = - create_singlethread_workqueue("lis3dh_acc_wq2"); - if (!acc->irq2_work_queue) { - err = -ENOMEM; - dev_err(&client->dev, - "cannot create work queue2: %d\n", err); - goto err_free_irq1; - } - err = request_irq(acc->irq2, lis3dh_acc_isr2, - IRQF_TRIGGER_RISING, "lis3dh_acc_irq2", acc); - if (err < 0) { - dev_err(&client->dev, "request irq2 failed: %d\n", err); - goto err_destoyworkqueue2; - } - disable_irq_nosync(acc->irq2); - } - - - - mutex_unlock(&acc->lock); - - dev_info(&client->dev, "%s: probed\n", LIS3DH_ACC_DEV_NAME); - - return 0; - -err_destoyworkqueue2: - if (acc->pdata->gpio_int2 >= 0) - destroy_workqueue(acc->irq2_work_queue); -err_free_irq1: - free_irq(acc->irq1, acc); -err_destoyworkqueue1: - if (acc->pdata->gpio_int1 >= 0) - destroy_workqueue(acc->irq1_work_queue); -err_remove_sysfs_int: - remove_sysfs_interfaces(&client->dev); -err_input_cleanup: - lis3dh_acc_input_cleanup(acc); -err_power_off: - lis3dh_acc_device_power_off(acc); -err_pdata_init: - if (acc->pdata->exit) - acc->pdata->exit(); -exit_kfree_pdata: - kfree(acc->pdata); -err_mutexunlock: - mutex_unlock(&acc->lock); - kfree(acc); -exit_check_functionality_failed: - printk(KERN_ERR "%s: Driver Init failed\n", LIS3DH_ACC_DEV_NAME); - return err; -} - -static int lis3dh_acc_remove(struct i2c_client *client) -{ - struct lis3dh_acc_data *acc = i2c_get_clientdata(client); - - if (acc->pdata->gpio_int1 >= 0) { - free_irq(acc->irq1, acc); - gpio_free(acc->pdata->gpio_int1); - destroy_workqueue(acc->irq1_work_queue); - } - - if (acc->pdata->gpio_int2 >= 0) { - free_irq(acc->irq2, acc); - gpio_free(acc->pdata->gpio_int2); - destroy_workqueue(acc->irq2_work_queue); - } - - lis3dh_acc_input_cleanup(acc); - lis3dh_acc_device_power_off(acc); - remove_sysfs_interfaces(&client->dev); - - if (acc->pdata->exit) - acc->pdata->exit(); - kfree(acc->pdata); - kfree(acc); - - return 0; -} - -#ifdef CONFIG_PM -static int lis3dh_acc_resume(struct i2c_client *client) -{ - struct lis3dh_acc_data *acc = i2c_get_clientdata(client); - - if (acc->on_before_suspend) - return lis3dh_acc_enable(acc); - return 0; -} - -static int lis3dh_acc_suspend(struct i2c_client *client, pm_message_t mesg) -{ - struct lis3dh_acc_data *acc = i2c_get_clientdata(client); - - acc->on_before_suspend = atomic_read(&acc->enabled); - return lis3dh_acc_disable(acc); -} -#else -#define lis3dh_acc_suspend NULL -#define lis3dh_acc_resume NULL -#endif /* CONFIG_PM */ - -static const struct i2c_device_id lis3dh_acc_id[] - = { { LIS3DH_ACC_DEV_NAME, 0 }, { }, }; - -MODULE_DEVICE_TABLE(i2c, lis3dh_acc_id); - -static struct i2c_driver lis3dh_acc_driver = { - .driver = { - .owner = THIS_MODULE, - .name = LIS3DH_ACC_DEV_NAME, - }, - .probe = lis3dh_acc_probe, - .remove = lis3dh_acc_remove, - .suspend = lis3dh_acc_suspend, - .resume = lis3dh_acc_resume, - .id_table = lis3dh_acc_id, -}; - -static int __init lis3dh_acc_init(void) -{ - printk(KERN_INFO "%s accelerometer driver: init\n", - LIS3DH_ACC_DEV_NAME); - return i2c_add_driver(&lis3dh_acc_driver); -} - -static void __exit lis3dh_acc_exit(void) -{ -#ifdef DEBUG - printk(KERN_INFO "%s accelerometer driver exit\n", - LIS3DH_ACC_DEV_NAME); -#endif /* DEBUG */ - i2c_del_driver(&lis3dh_acc_driver); - return; -} - -module_init(lis3dh_acc_init); -module_exit(lis3dh_acc_exit); - -MODULE_DESCRIPTION("lis3dh digital accelerometer sysfs driver"); -MODULE_AUTHOR("Matteo Dameno, Carmine Iascone, Samuel Huo, STMicroelectronics"); -MODULE_LICENSE("GPL"); - diff --git a/drivers/input/misc/pmic8058-othc.c b/drivers/input/misc/pmic8058-othc.c deleted file mode 100644 index b60fbc0848c63aa2ff5b3646e1a5f15b119a86a2..0000000000000000000000000000000000000000 --- a/drivers/input/misc/pmic8058-othc.c +++ /dev/null @@ -1,1188 +0,0 @@ -/* Copyright (c) 2010-2011, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define PM8058_OTHC_LOW_CURR_MASK 0xF0 -#define PM8058_OTHC_HIGH_CURR_MASK 0x0F -#define PM8058_OTHC_EN_SIG_MASK 0x3F -#define PM8058_OTHC_HYST_PREDIV_MASK 0xC7 -#define PM8058_OTHC_CLK_PREDIV_MASK 0xF8 -#define PM8058_OTHC_HYST_CLK_MASK 0x0F -#define PM8058_OTHC_PERIOD_CLK_MASK 0xF0 - -#define PM8058_OTHC_LOW_CURR_SHIFT 0x4 -#define PM8058_OTHC_EN_SIG_SHIFT 0x6 -#define PM8058_OTHC_HYST_PREDIV_SHIFT 0x3 -#define PM8058_OTHC_HYST_CLK_SHIFT 0x4 - -#define OTHC_GPIO_MAX_LEN 25 - -struct pm8058_othc { - bool othc_sw_state; - bool switch_reject; - bool othc_support_n_switch; - bool accessory_support; - bool accessories_adc_support; - int othc_base; - int othc_irq_sw; - int othc_irq_ir; - int othc_ir_state; - int num_accessories; - int curr_accessory_code; - int curr_accessory; - int video_out_gpio; - u32 sw_key_code; - u32 accessories_adc_channel; - int ir_gpio; - unsigned long switch_debounce_ms; - unsigned long detection_delay_ms; - void *adc_handle; - void *accessory_adc_handle; - spinlock_t lock; - struct device *dev; - struct regulator *othc_vreg; - struct input_dev *othc_ipd; - struct switch_dev othc_sdev; - struct pmic8058_othc_config_pdata *othc_pdata; - struct othc_accessory_info *accessory_info; - struct hrtimer timer; - struct othc_n_switch_config *switch_config; - struct work_struct switch_work; - struct delayed_work detect_work; - struct delayed_work hs_work; -}; - -static struct pm8058_othc *config[OTHC_MICBIAS_MAX]; - -static void hs_worker(struct work_struct *work) -{ - int rc; - struct pm8058_othc *dd = - container_of(work, struct pm8058_othc, hs_work.work); - - rc = gpio_get_value_cansleep(dd->ir_gpio); - if (rc < 0) { - pr_err("Unable to read IR GPIO\n"); - enable_irq(dd->othc_irq_ir); - return; - } - - dd->othc_ir_state = !rc; - schedule_delayed_work(&dd->detect_work, - msecs_to_jiffies(dd->detection_delay_ms)); -} - -static irqreturn_t ir_gpio_irq(int irq, void *dev_id) -{ - unsigned long flags; - struct pm8058_othc *dd = dev_id; - - spin_lock_irqsave(&dd->lock, flags); - /* Enable the switch reject flag */ - dd->switch_reject = true; - spin_unlock_irqrestore(&dd->lock, flags); - - /* Start the HR timer if one is not active */ - if (hrtimer_active(&dd->timer)) - hrtimer_cancel(&dd->timer); - - hrtimer_start(&dd->timer, - ktime_set((dd->switch_debounce_ms / 1000), - (dd->switch_debounce_ms % 1000) * 1000000), HRTIMER_MODE_REL); - - /* disable irq, this gets enabled in the workqueue */ - disable_irq_nosync(dd->othc_irq_ir); - schedule_delayed_work(&dd->hs_work, 0); - - return IRQ_HANDLED; -} -/* - * The API pm8058_micbias_enable() allows to configure - * the MIC_BIAS. Only the lines which are not used for - * headset detection can be configured using this API. - * The API returns an error code if it fails to configure - * the specified MIC_BIAS line, else it returns 0. - */ -int pm8058_micbias_enable(enum othc_micbias micbias, - enum othc_micbias_enable enable) -{ - int rc; - u8 reg; - struct pm8058_othc *dd = config[micbias]; - - if (dd == NULL) { - pr_err("MIC_BIAS not registered, cannot enable\n"); - return -ENODEV; - } - - if (dd->othc_pdata->micbias_capability != OTHC_MICBIAS) { - pr_err("MIC_BIAS enable capability not supported\n"); - return -EINVAL; - } - - rc = pm8xxx_readb(dd->dev->parent, dd->othc_base + 1, ®); - if (rc < 0) { - pr_err("PM8058 read failed\n"); - return rc; - } - - reg &= PM8058_OTHC_EN_SIG_MASK; - reg |= (enable << PM8058_OTHC_EN_SIG_SHIFT); - - rc = pm8xxx_writeb(dd->dev->parent, dd->othc_base + 1, reg); - if (rc < 0) { - pr_err("PM8058 write failed\n"); - return rc; - } - - return rc; -} -EXPORT_SYMBOL(pm8058_micbias_enable); - -int pm8058_othc_svideo_enable(enum othc_micbias micbias, bool enable) -{ - struct pm8058_othc *dd = config[micbias]; - - if (dd == NULL) { - pr_err("MIC_BIAS not registered, cannot enable\n"); - return -ENODEV; - } - - if (dd->othc_pdata->micbias_capability != OTHC_MICBIAS_HSED) { - pr_err("MIC_BIAS enable capability not supported\n"); - return -EINVAL; - } - - if (dd->accessories_adc_support) { - /* GPIO state for MIC_IN = 0, SVIDEO = 1 */ - gpio_set_value_cansleep(dd->video_out_gpio, !!enable); - if (enable) { - pr_debug("Enable the video path\n"); - switch_set_state(&dd->othc_sdev, dd->curr_accessory); - input_report_switch(dd->othc_ipd, - dd->curr_accessory_code, 1); - input_sync(dd->othc_ipd); - } else { - pr_debug("Disable the video path\n"); - switch_set_state(&dd->othc_sdev, 0); - input_report_switch(dd->othc_ipd, - dd->curr_accessory_code, 0); - input_sync(dd->othc_ipd); - } - } - - return 0; -} -EXPORT_SYMBOL(pm8058_othc_svideo_enable); - -#ifdef CONFIG_PM -static int pm8058_othc_suspend(struct device *dev) -{ - int rc = 0; - struct pm8058_othc *dd = dev_get_drvdata(dev); - - if (dd->othc_pdata->micbias_capability == OTHC_MICBIAS_HSED) { - if (device_may_wakeup(dev)) { - enable_irq_wake(dd->othc_irq_sw); - enable_irq_wake(dd->othc_irq_ir); - } - } - - if (!device_may_wakeup(dev)) { - rc = regulator_disable(dd->othc_vreg); - if (rc) - pr_err("othc micbais power off failed\n"); - } - - return rc; -} - -static int pm8058_othc_resume(struct device *dev) -{ - int rc = 0; - struct pm8058_othc *dd = dev_get_drvdata(dev); - - if (dd->othc_pdata->micbias_capability == OTHC_MICBIAS_HSED) { - if (device_may_wakeup(dev)) { - disable_irq_wake(dd->othc_irq_sw); - disable_irq_wake(dd->othc_irq_ir); - } - } - - if (!device_may_wakeup(dev)) { - rc = regulator_enable(dd->othc_vreg); - if (rc) - pr_err("othc micbais power on failed\n"); - } - - return rc; -} - -static struct dev_pm_ops pm8058_othc_pm_ops = { - .suspend = pm8058_othc_suspend, - .resume = pm8058_othc_resume, -}; -#endif - -static int pm8058_othc_remove(struct platform_device *pd) -{ - struct pm8058_othc *dd = platform_get_drvdata(pd); - - pm_runtime_set_suspended(&pd->dev); - pm_runtime_disable(&pd->dev); - - if (dd->othc_pdata->micbias_capability == OTHC_MICBIAS_HSED) { - device_init_wakeup(&pd->dev, 0); - if (dd->othc_support_n_switch == true) { - adc_channel_close(dd->adc_handle); - cancel_work_sync(&dd->switch_work); - } - - if (dd->accessory_support == true) { - int i; - for (i = 0; i < dd->num_accessories; i++) { - if (dd->accessory_info[i].detect_flags & - OTHC_GPIO_DETECT) - gpio_free(dd->accessory_info[i].gpio); - } - } - cancel_delayed_work_sync(&dd->detect_work); - cancel_delayed_work_sync(&dd->hs_work); - free_irq(dd->othc_irq_sw, dd); - free_irq(dd->othc_irq_ir, dd); - if (dd->ir_gpio != -1) - gpio_free(dd->ir_gpio); - input_unregister_device(dd->othc_ipd); - } - regulator_disable(dd->othc_vreg); - regulator_put(dd->othc_vreg); - - kfree(dd); - - return 0; -} - -static enum hrtimer_restart pm8058_othc_timer(struct hrtimer *timer) -{ - unsigned long flags; - struct pm8058_othc *dd = container_of(timer, - struct pm8058_othc, timer); - - spin_lock_irqsave(&dd->lock, flags); - dd->switch_reject = false; - spin_unlock_irqrestore(&dd->lock, flags); - - return HRTIMER_NORESTART; -} - -static void othc_report_switch(struct pm8058_othc *dd, u32 res) -{ - u8 i; - struct othc_switch_info *sw_info = dd->switch_config->switch_info; - - for (i = 0; i < dd->switch_config->num_keys; i++) { - if (res >= sw_info[i].min_adc_threshold && - res <= sw_info[i].max_adc_threshold) { - dd->othc_sw_state = true; - dd->sw_key_code = sw_info[i].key_code; - input_report_key(dd->othc_ipd, sw_info[i].key_code, 1); - input_sync(dd->othc_ipd); - return; - } - } - - /* - * If the switch is not present in a specified ADC range - * report a default switch press. - */ - if (dd->switch_config->default_sw_en) { - dd->othc_sw_state = true; - dd->sw_key_code = - sw_info[dd->switch_config->default_sw_idx].key_code; - input_report_key(dd->othc_ipd, dd->sw_key_code, 1); - input_sync(dd->othc_ipd); - } -} - -static void switch_work_f(struct work_struct *work) -{ - int rc, i; - u32 res = 0; - struct adc_chan_result adc_result; - struct pm8058_othc *dd = - container_of(work, struct pm8058_othc, switch_work); - DECLARE_COMPLETION_ONSTACK(adc_wait); - u8 num_adc_samples = dd->switch_config->num_adc_samples; - - /* sleep for settling time */ - msleep(dd->switch_config->voltage_settling_time_ms); - - for (i = 0; i < num_adc_samples; i++) { - rc = adc_channel_request_conv(dd->adc_handle, &adc_wait); - if (rc) { - pr_err("adc_channel_request_conv failed\n"); - goto bail_out; - } - rc = wait_for_completion_interruptible(&adc_wait); - if (rc) { - pr_err("wait_for_completion_interruptible failed\n"); - goto bail_out; - } - rc = adc_channel_read_result(dd->adc_handle, &adc_result); - if (rc) { - pr_err("adc_channel_read_result failed\n"); - goto bail_out; - } - res += adc_result.physical; - } -bail_out: - if (i == num_adc_samples && num_adc_samples != 0) { - res /= num_adc_samples; - othc_report_switch(dd, res); - } else - pr_err("Insufficient ADC samples\n"); - - enable_irq(dd->othc_irq_sw); -} - -static int accessory_adc_detect(struct pm8058_othc *dd, int accessory) -{ - int rc; - u32 res; - struct adc_chan_result accessory_adc_result; - DECLARE_COMPLETION_ONSTACK(accessory_adc_wait); - - rc = adc_channel_request_conv(dd->accessory_adc_handle, - &accessory_adc_wait); - if (rc) { - pr_err("adc_channel_request_conv failed\n"); - goto adc_failed; - } - rc = wait_for_completion_interruptible(&accessory_adc_wait); - if (rc) { - pr_err("wait_for_completion_interruptible failed\n"); - goto adc_failed; - } - rc = adc_channel_read_result(dd->accessory_adc_handle, - &accessory_adc_result); - if (rc) { - pr_err("adc_channel_read_result failed\n"); - goto adc_failed; - } - - res = accessory_adc_result.physical; - - if (res >= dd->accessory_info[accessory].adc_thres.min_threshold && - res <= dd->accessory_info[accessory].adc_thres.max_threshold) { - pr_debug("Accessory on ADC detected!, ADC Value = %u\n", res); - return 1; - } - -adc_failed: - return 0; -} - - -static int pm8058_accessory_report(struct pm8058_othc *dd, int status) -{ - int i, rc, detected = 0; - u8 micbias_status, switch_status; - - if (dd->accessory_support == false) { - /* Report default headset */ - switch_set_state(&dd->othc_sdev, !!status); - input_report_switch(dd->othc_ipd, SW_HEADPHONE_INSERT, - !!status); - input_sync(dd->othc_ipd); - return 0; - } - - /* For accessory */ - if (dd->accessory_support == true && status == 0) { - /* Report removal of the accessory. */ - - /* - * If the current accessory is video cable, reject the removal - * interrupt. - */ - pr_info("Accessory [%d] removed\n", dd->curr_accessory); - if (dd->curr_accessory == OTHC_SVIDEO_OUT) - return 0; - - switch_set_state(&dd->othc_sdev, 0); - input_report_switch(dd->othc_ipd, dd->curr_accessory_code, 0); - input_sync(dd->othc_ipd); - return 0; - } - - if (dd->ir_gpio < 0) { - /* Check the MIC_BIAS status */ - rc = pm8xxx_read_irq_stat(dd->dev->parent, dd->othc_irq_ir); - if (rc < 0) { - pr_err("Unable to read IR status from PMIC\n"); - goto fail_ir_accessory; - } - micbias_status = !!rc; - } else { - rc = gpio_get_value_cansleep(dd->ir_gpio); - if (rc < 0) { - pr_err("Unable to read IR status from GPIO\n"); - goto fail_ir_accessory; - } - micbias_status = !rc; - } - - /* Check the switch status */ - rc = pm8xxx_read_irq_stat(dd->dev->parent, dd->othc_irq_sw); - if (rc < 0) { - pr_err("Unable to read SWITCH status\n"); - goto fail_ir_accessory; - } - switch_status = !!rc; - - /* Loop through to check which accessory is connected */ - for (i = 0; i < dd->num_accessories; i++) { - detected = 0; - if (dd->accessory_info[i].enabled == false) - continue; - - if (dd->accessory_info[i].detect_flags & OTHC_MICBIAS_DETECT) { - if (micbias_status) - detected = 1; - else - continue; - } - if (dd->accessory_info[i].detect_flags & OTHC_SWITCH_DETECT) { - if (switch_status) - detected = 1; - else - continue; - } - if (dd->accessory_info[i].detect_flags & OTHC_GPIO_DETECT) { - rc = gpio_get_value_cansleep( - dd->accessory_info[i].gpio); - if (rc < 0) - continue; - - if (rc ^ dd->accessory_info[i].active_low) - detected = 1; - else - continue; - } - if (dd->accessory_info[i].detect_flags & OTHC_ADC_DETECT) - detected = accessory_adc_detect(dd, i); - - if (detected) - break; - } - - if (detected) { - dd->curr_accessory = dd->accessory_info[i].accessory; - dd->curr_accessory_code = dd->accessory_info[i].key_code; - - /* if Video out cable detected enable the video path*/ - if (dd->curr_accessory == OTHC_SVIDEO_OUT) { - pm8058_othc_svideo_enable( - dd->othc_pdata->micbias_select, true); - - } else { - switch_set_state(&dd->othc_sdev, dd->curr_accessory); - input_report_switch(dd->othc_ipd, - dd->curr_accessory_code, 1); - input_sync(dd->othc_ipd); - } - pr_info("Accessory [%d] inserted\n", dd->curr_accessory); - } else - pr_info("Unable to detect accessory. False interrupt!\n"); - - return 0; - -fail_ir_accessory: - return rc; -} - -static void detect_work_f(struct work_struct *work) -{ - int rc; - struct pm8058_othc *dd = - container_of(work, struct pm8058_othc, detect_work.work); - - /* Accessory has been inserted */ - rc = pm8058_accessory_report(dd, 1); - if (rc) - pr_err("Accessory insertion could not be detected\n"); - - enable_irq(dd->othc_irq_ir); -} - -/* - * The pm8058_no_sw detects the switch press and release operation. - * The odd number call is press and even number call is release. - * The current state of the button is maintained in othc_sw_state variable. - * This isr gets called only for NO type headsets. - */ -static irqreturn_t pm8058_no_sw(int irq, void *dev_id) -{ - int level; - struct pm8058_othc *dd = dev_id; - unsigned long flags; - - /* Check if headset has been inserted, else return */ - if (!dd->othc_ir_state) - return IRQ_HANDLED; - - spin_lock_irqsave(&dd->lock, flags); - if (dd->switch_reject == true) { - pr_debug("Rejected switch interrupt\n"); - spin_unlock_irqrestore(&dd->lock, flags); - return IRQ_HANDLED; - } - spin_unlock_irqrestore(&dd->lock, flags); - - level = pm8xxx_read_irq_stat(dd->dev->parent, dd->othc_irq_sw); - if (level < 0) { - pr_err("Unable to read IRQ status register\n"); - return IRQ_HANDLED; - } - - if (dd->othc_support_n_switch == true) { - if (level == 0) { - dd->othc_sw_state = false; - input_report_key(dd->othc_ipd, dd->sw_key_code, 0); - input_sync(dd->othc_ipd); - } else { - disable_irq_nosync(dd->othc_irq_sw); - schedule_work(&dd->switch_work); - } - return IRQ_HANDLED; - } - /* - * It is necessary to check the software state and the hardware state - * to make sure that the residual interrupt after the debounce time does - * not disturb the software state machine. - */ - if (level == 1 && dd->othc_sw_state == false) { - /* Switch has been pressed */ - dd->othc_sw_state = true; - input_report_key(dd->othc_ipd, KEY_MEDIA, 1); - } else if (level == 0 && dd->othc_sw_state == true) { - /* Switch has been released */ - dd->othc_sw_state = false; - input_report_key(dd->othc_ipd, KEY_MEDIA, 0); - } - input_sync(dd->othc_ipd); - - return IRQ_HANDLED; -} - -/* - * The pm8058_nc_ir detects insert / remove of the headset (for NO), - * The current state of the headset is maintained in othc_ir_state variable. - * Due to a hardware bug, false switch interrupts are seen during headset - * insert. This is handled in the software by rejecting the switch interrupts - * for a small period of time after the headset has been inserted. - */ -static irqreturn_t pm8058_nc_ir(int irq, void *dev_id) -{ - unsigned long flags, rc; - struct pm8058_othc *dd = dev_id; - - spin_lock_irqsave(&dd->lock, flags); - /* Enable the switch reject flag */ - dd->switch_reject = true; - spin_unlock_irqrestore(&dd->lock, flags); - - /* Start the HR timer if one is not active */ - if (hrtimer_active(&dd->timer)) - hrtimer_cancel(&dd->timer); - - hrtimer_start(&dd->timer, - ktime_set((dd->switch_debounce_ms / 1000), - (dd->switch_debounce_ms % 1000) * 1000000), HRTIMER_MODE_REL); - - - /* Check the MIC_BIAS status, to check if inserted or removed */ - rc = pm8xxx_read_irq_stat(dd->dev->parent, dd->othc_irq_ir); - if (rc < 0) { - pr_err("Unable to read IR status\n"); - goto fail_ir; - } - - dd->othc_ir_state = rc; - if (dd->othc_ir_state) { - /* disable irq, this gets enabled in the workqueue */ - disable_irq_nosync(dd->othc_irq_ir); - /* Accessory has been inserted, report with detection delay */ - schedule_delayed_work(&dd->detect_work, - msecs_to_jiffies(dd->detection_delay_ms)); - } else { - /* Accessory has been removed, report removal immediately */ - rc = pm8058_accessory_report(dd, 0); - if (rc) - pr_err("Accessory removal could not be detected\n"); - /* Clear existing switch state */ - dd->othc_sw_state = false; - } - -fail_ir: - return IRQ_HANDLED; -} - -static int pm8058_configure_micbias(struct pm8058_othc *dd) -{ - int rc; - u8 reg, value; - u32 value1; - u16 base_addr = dd->othc_base; - struct hsed_bias_config *hsed_config = - dd->othc_pdata->hsed_config->hsed_bias_config; - - /* Intialize the OTHC module */ - /* Control Register 1*/ - rc = pm8xxx_readb(dd->dev->parent, base_addr, ®); - if (rc < 0) { - pr_err("PM8058 read failed\n"); - return rc; - } - - /* set iDAC high current threshold */ - value = (hsed_config->othc_highcurr_thresh_uA / 100) - 2; - reg = (reg & PM8058_OTHC_HIGH_CURR_MASK) | value; - - rc = pm8xxx_writeb(dd->dev->parent, base_addr, reg); - if (rc < 0) { - pr_err("PM8058 read failed\n"); - return rc; - } - - /* Control register 2*/ - rc = pm8xxx_readb(dd->dev->parent, base_addr + 1, ®); - if (rc < 0) { - pr_err("PM8058 read failed\n"); - return rc; - } - - value = dd->othc_pdata->micbias_enable; - reg &= PM8058_OTHC_EN_SIG_MASK; - reg |= (value << PM8058_OTHC_EN_SIG_SHIFT); - - value = 0; - value1 = (hsed_config->othc_hyst_prediv_us << 10) / USEC_PER_SEC; - while (value1 != 0) { - value1 = value1 >> 1; - value++; - } - if (value > 7) { - pr_err("Invalid input argument - othc_hyst_prediv_us\n"); - return -EINVAL; - } - reg &= PM8058_OTHC_HYST_PREDIV_MASK; - reg |= (value << PM8058_OTHC_HYST_PREDIV_SHIFT); - - value = 0; - value1 = (hsed_config->othc_period_clkdiv_us << 10) / USEC_PER_SEC; - while (value1 != 1) { - value1 = value1 >> 1; - value++; - } - if (value > 8) { - pr_err("Invalid input argument - othc_period_clkdiv_us\n"); - return -EINVAL; - } - reg = (reg & PM8058_OTHC_CLK_PREDIV_MASK) | (value - 1); - - rc = pm8xxx_writeb(dd->dev->parent, base_addr + 1, reg); - if (rc < 0) { - pr_err("PM8058 read failed\n"); - return rc; - } - - /* Control register 3 */ - rc = pm8xxx_readb(dd->dev->parent, base_addr + 2 , ®); - if (rc < 0) { - pr_err("PM8058 read failed\n"); - return rc; - } - - value = hsed_config->othc_hyst_clk_us / - hsed_config->othc_hyst_prediv_us; - if (value > 15) { - pr_err("Invalid input argument - othc_hyst_prediv_us\n"); - return -EINVAL; - } - reg &= PM8058_OTHC_HYST_CLK_MASK; - reg |= value << PM8058_OTHC_HYST_CLK_SHIFT; - - value = hsed_config->othc_period_clk_us / - hsed_config->othc_period_clkdiv_us; - if (value > 15) { - pr_err("Invalid input argument - othc_hyst_prediv_us\n"); - return -EINVAL; - } - reg = (reg & PM8058_OTHC_PERIOD_CLK_MASK) | value; - - rc = pm8xxx_writeb(dd->dev->parent, base_addr + 2, reg); - if (rc < 0) { - pr_err("PM8058 read failed\n"); - return rc; - } - - return 0; -} - -static ssize_t othc_headset_print_name(struct switch_dev *sdev, char *buf) -{ - switch (switch_get_state(sdev)) { - case OTHC_NO_DEVICE: - return sprintf(buf, "No Device\n"); - case OTHC_HEADSET: - case OTHC_HEADPHONE: - case OTHC_MICROPHONE: - case OTHC_ANC_HEADSET: - case OTHC_ANC_HEADPHONE: - case OTHC_ANC_MICROPHONE: - return sprintf(buf, "Headset\n"); - } - return -EINVAL; -} - -static int pm8058_configure_switch(struct pm8058_othc *dd) -{ - int rc, i; - - if (dd->othc_support_n_switch == true) { - /* n-switch support */ - rc = adc_channel_open(dd->switch_config->adc_channel, - &dd->adc_handle); - if (rc) { - pr_err("Unable to open ADC channel\n"); - return -ENODEV; - } - - for (i = 0; i < dd->switch_config->num_keys; i++) { - input_set_capability(dd->othc_ipd, EV_KEY, - dd->switch_config->switch_info[i].key_code); - } - } else /* Only single switch supported */ - input_set_capability(dd->othc_ipd, EV_KEY, KEY_MEDIA); - - return 0; -} - -static int -pm8058_configure_accessory(struct pm8058_othc *dd) -{ - int i, rc; - char name[OTHC_GPIO_MAX_LEN]; - - /* - * Not bailing out if the gpio_* configure calls fail. This is required - * as multiple accessories are detected by the same gpio. - */ - for (i = 0; i < dd->num_accessories; i++) { - if (dd->accessory_info[i].enabled == false) - continue; - if (dd->accessory_info[i].detect_flags & OTHC_GPIO_DETECT) { - snprintf(name, OTHC_GPIO_MAX_LEN, "%s%d", - "othc_acc_gpio_", i); - rc = gpio_request(dd->accessory_info[i].gpio, name); - if (rc) { - pr_debug("Unable to request GPIO [%d]\n", - dd->accessory_info[i].gpio); - continue; - } - rc = gpio_direction_input(dd->accessory_info[i].gpio); - if (rc) { - pr_debug("Unable to set-direction GPIO [%d]\n", - dd->accessory_info[i].gpio); - gpio_free(dd->accessory_info[i].gpio); - continue; - } - } - input_set_capability(dd->othc_ipd, EV_SW, - dd->accessory_info[i].key_code); - } - - if (dd->accessories_adc_support) { - /* - * Check if 3 switch is supported. If both are using the same - * ADC channel, the same handle can be used. - */ - if (dd->othc_support_n_switch) { - if (dd->adc_handle != NULL && - (dd->accessories_adc_channel == - dd->switch_config->adc_channel)) - dd->accessory_adc_handle = dd->adc_handle; - } else { - rc = adc_channel_open(dd->accessories_adc_channel, - &dd->accessory_adc_handle); - if (rc) { - pr_err("Unable to open ADC channel\n"); - rc = -ENODEV; - goto accessory_adc_fail; - } - } - if (dd->video_out_gpio != 0) { - rc = gpio_request(dd->video_out_gpio, "vout_enable"); - if (rc < 0) { - pr_err("request VOUT gpio failed (%d)\n", rc); - goto accessory_adc_fail; - } - rc = gpio_direction_output(dd->video_out_gpio, 0); - if (rc < 0) { - pr_err("direction_out failed (%d)\n", rc); - goto accessory_adc_fail; - } - } - - } - - return 0; - -accessory_adc_fail: - for (i = 0; i < dd->num_accessories; i++) { - if (dd->accessory_info[i].enabled == false) - continue; - gpio_free(dd->accessory_info[i].gpio); - } - return rc; -} - -static int -othc_configure_hsed(struct pm8058_othc *dd, struct platform_device *pd) -{ - int rc; - struct input_dev *ipd; - struct pmic8058_othc_config_pdata *pdata = pd->dev.platform_data; - struct othc_hsed_config *hsed_config = pdata->hsed_config; - - dd->othc_sdev.name = "h2w"; - dd->othc_sdev.print_name = othc_headset_print_name; - - rc = switch_dev_register(&dd->othc_sdev); - if (rc) { - pr_err("Unable to register switch device\n"); - return rc; - } - - ipd = input_allocate_device(); - if (ipd == NULL) { - pr_err("Unable to allocate memory\n"); - rc = -ENOMEM; - goto fail_input_alloc; - } - - /* Get the IRQ for Headset Insert-remove and Switch-press */ - dd->othc_irq_sw = platform_get_irq(pd, 0); - dd->othc_irq_ir = platform_get_irq(pd, 1); - if (dd->othc_irq_ir < 0 || dd->othc_irq_sw < 0) { - pr_err("othc resource:IRQs absent\n"); - rc = -ENXIO; - goto fail_micbias_config; - } - - if (pdata->hsed_name != NULL) - ipd->name = pdata->hsed_name; - else - ipd->name = "pmic8058_othc"; - - ipd->phys = "pmic8058_othc/input0"; - ipd->dev.parent = &pd->dev; - - dd->othc_ipd = ipd; - dd->ir_gpio = hsed_config->ir_gpio; - dd->othc_sw_state = false; - dd->switch_debounce_ms = hsed_config->switch_debounce_ms; - dd->othc_support_n_switch = hsed_config->othc_support_n_switch; - dd->accessory_support = pdata->hsed_config->accessories_support; - dd->detection_delay_ms = pdata->hsed_config->detection_delay_ms; - - if (dd->othc_support_n_switch == true) - dd->switch_config = hsed_config->switch_config; - - if (dd->accessory_support == true) { - dd->accessory_info = pdata->hsed_config->accessories; - dd->num_accessories = pdata->hsed_config->othc_num_accessories; - dd->accessories_adc_support = - pdata->hsed_config->accessories_adc_support; - dd->accessories_adc_channel = - pdata->hsed_config->accessories_adc_channel; - dd->video_out_gpio = pdata->hsed_config->video_out_gpio; - } - - /* Configure the MIC_BIAS line for headset detection */ - rc = pm8058_configure_micbias(dd); - if (rc < 0) - goto fail_micbias_config; - - /* Configure for the switch events */ - rc = pm8058_configure_switch(dd); - if (rc < 0) - goto fail_micbias_config; - - /* Configure the accessory */ - if (dd->accessory_support == true) { - rc = pm8058_configure_accessory(dd); - if (rc < 0) - goto fail_micbias_config; - } - - input_set_drvdata(ipd, dd); - spin_lock_init(&dd->lock); - - rc = input_register_device(ipd); - if (rc) { - pr_err("Unable to register OTHC device\n"); - goto fail_micbias_config; - } - - hrtimer_init(&dd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - dd->timer.function = pm8058_othc_timer; - - /* Request the HEADSET IR interrupt */ - if (dd->ir_gpio < 0) { - rc = request_threaded_irq(dd->othc_irq_ir, NULL, pm8058_nc_ir, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_DISABLED, - "pm8058_othc_ir", dd); - if (rc < 0) { - pr_err("Unable to request pm8058_othc_ir IRQ\n"); - goto fail_ir_irq; - } - } else { - rc = gpio_request(dd->ir_gpio, "othc_ir_gpio"); - if (rc) { - pr_err("Unable to request IR GPIO\n"); - goto fail_ir_gpio_req; - } - rc = gpio_direction_input(dd->ir_gpio); - if (rc) { - pr_err("GPIO %d set_direction failed\n", dd->ir_gpio); - goto fail_ir_irq; - } - dd->othc_irq_ir = gpio_to_irq(dd->ir_gpio); - rc = request_any_context_irq(dd->othc_irq_ir, ir_gpio_irq, - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, - "othc_gpio_ir_irq", dd); - if (rc < 0) { - pr_err("could not request hs irq err=%d\n", rc); - goto fail_ir_irq; - } - } - /* Request the SWITCH press/release interrupt */ - rc = request_threaded_irq(dd->othc_irq_sw, NULL, pm8058_no_sw, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_DISABLED, - "pm8058_othc_sw", dd); - if (rc < 0) { - pr_err("Unable to request pm8058_othc_sw IRQ\n"); - goto fail_sw_irq; - } - - /* Check if the accessory is already inserted during boot up */ - if (dd->ir_gpio < 0) { - rc = pm8xxx_read_irq_stat(dd->dev->parent, dd->othc_irq_ir); - if (rc < 0) { - pr_err("Unable to get accessory status at boot\n"); - goto fail_ir_status; - } - } else { - rc = gpio_get_value_cansleep(dd->ir_gpio); - if (rc < 0) { - pr_err("Unable to get accessory status at boot\n"); - goto fail_ir_status; - } - rc = !rc; - } - if (rc) { - pr_debug("Accessory inserted during boot up\n"); - /* process the data and report the inserted accessory */ - rc = pm8058_accessory_report(dd, 1); - if (rc) - pr_debug("Unabele to detect accessory at boot up\n"); - } - - device_init_wakeup(&pd->dev, - hsed_config->hsed_bias_config->othc_wakeup); - - INIT_DELAYED_WORK(&dd->detect_work, detect_work_f); - - INIT_DELAYED_WORK(&dd->hs_work, hs_worker); - - if (dd->othc_support_n_switch == true) - INIT_WORK(&dd->switch_work, switch_work_f); - - - return 0; - -fail_ir_status: - free_irq(dd->othc_irq_sw, dd); -fail_sw_irq: - free_irq(dd->othc_irq_ir, dd); -fail_ir_irq: - if (dd->ir_gpio != -1) - gpio_free(dd->ir_gpio); -fail_ir_gpio_req: - input_unregister_device(ipd); - dd->othc_ipd = NULL; -fail_micbias_config: - input_free_device(ipd); -fail_input_alloc: - switch_dev_unregister(&dd->othc_sdev); - return rc; -} - -static int pm8058_othc_probe(struct platform_device *pd) -{ - int rc; - struct pm8058_othc *dd; - struct resource *res; - struct pmic8058_othc_config_pdata *pdata = pd->dev.platform_data; - - if (pdata == NULL) { - pr_err("Platform data not present\n"); - return -EINVAL; - } - - dd = kzalloc(sizeof(*dd), GFP_KERNEL); - if (dd == NULL) { - pr_err("Unable to allocate memory\n"); - return -ENOMEM; - } - - /* Enable runtime PM ops, start in ACTIVE mode */ - rc = pm_runtime_set_active(&pd->dev); - if (rc < 0) - dev_dbg(&pd->dev, "unable to set runtime pm state\n"); - pm_runtime_enable(&pd->dev); - - res = platform_get_resource_byname(pd, IORESOURCE_IO, "othc_base"); - if (res == NULL) { - pr_err("othc resource:Base address absent\n"); - rc = -ENXIO; - goto fail_get_res; - } - - dd->dev = &pd->dev; - dd->othc_pdata = pdata; - dd->othc_base = res->start; - if (pdata->micbias_regulator == NULL) { - pr_err("OTHC regulator not specified\n"); - goto fail_get_res; - } - - dd->othc_vreg = regulator_get(NULL, - pdata->micbias_regulator->regulator); - if (IS_ERR(dd->othc_vreg)) { - pr_err("regulator get failed\n"); - rc = PTR_ERR(dd->othc_vreg); - goto fail_get_res; - } - - rc = regulator_set_voltage(dd->othc_vreg, - pdata->micbias_regulator->min_uV, - pdata->micbias_regulator->max_uV); - if (rc) { - pr_err("othc regulator set voltage failed\n"); - goto fail_reg_enable; - } - - rc = regulator_enable(dd->othc_vreg); - if (rc) { - pr_err("othc regulator enable failed\n"); - goto fail_reg_enable; - } - - platform_set_drvdata(pd, dd); - - if (pdata->micbias_capability == OTHC_MICBIAS_HSED) { - /* HSED to be supported on this MICBIAS line */ - if (pdata->hsed_config != NULL) { - rc = othc_configure_hsed(dd, pd); - if (rc < 0) - goto fail_othc_hsed; - } else { - pr_err("HSED config data not present\n"); - rc = -EINVAL; - goto fail_othc_hsed; - } - } - - /* Store the local driver data structure */ - if (dd->othc_pdata->micbias_select < OTHC_MICBIAS_MAX) - config[dd->othc_pdata->micbias_select] = dd; - - pr_debug("Device %s:%d successfully registered\n", - pd->name, pd->id); - return 0; - -fail_othc_hsed: - regulator_disable(dd->othc_vreg); -fail_reg_enable: - regulator_put(dd->othc_vreg); -fail_get_res: - pm_runtime_set_suspended(&pd->dev); - pm_runtime_disable(&pd->dev); - - kfree(dd); - return rc; -} - -static struct platform_driver pm8058_othc_driver = { - .driver = { - .name = "pm8058-othc", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &pm8058_othc_pm_ops, -#endif - }, - .probe = pm8058_othc_probe, - .remove = pm8058_othc_remove, -}; - -static int __init pm8058_othc_init(void) -{ - return platform_driver_register(&pm8058_othc_driver); -} - -static void __exit pm8058_othc_exit(void) -{ - platform_driver_unregister(&pm8058_othc_driver); -} -/* - * Move to late_initcall, to make sure that the ADC driver registration is - * completed before we open a ADC channel. - */ -late_initcall(pm8058_othc_init); -module_exit(pm8058_othc_exit); - -MODULE_ALIAS("platform:pmic8058_othc"); -MODULE_DESCRIPTION("PMIC 8058 OTHC"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/input/misc/pmic8058-vib-memless.c b/drivers/input/misc/pmic8058-vib-memless.c deleted file mode 100644 index 4fbabf47ddc7482053fd89c0f3c3f46571c3eb6d..0000000000000000000000000000000000000000 --- a/drivers/input/misc/pmic8058-vib-memless.c +++ /dev/null @@ -1,282 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define VIB_DRV 0x4A - -#define VIB_DRV_SEL_MASK 0xf8 -#define VIB_DRV_SEL_SHIFT 0x03 -#define VIB_DRV_EN_MANUAL_MASK 0xfc - -#define VIB_MAX_LEVEL_mV (3100) -#define VIB_MIN_LEVEL_mV (1200) -#define VIB_MAX_LEVELS (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV) - -#define MAX_FF_SPEED 0xff - -struct pmic8058_vib { - struct input_dev *info; - spinlock_t lock; - struct work_struct work; - - bool enabled; - int speed; - struct device *dev; - struct pmic8058_vibrator_pdata *pdata; - int state; - int level; - u8 reg_vib_drv; - - struct pm8058_chip *pm_chip; -}; - -/* REVISIT: just for debugging, will be removed in final working version */ -static void __dump_vib_regs(struct pmic8058_vib *vib, char *msg) -{ - u8 temp; - - dev_dbg(vib->dev, "%s\n", msg); - - pm8058_read(vib->pm_chip, VIB_DRV, &temp, 1); - dev_dbg(vib->dev, "VIB_DRV - %X\n", temp); -} - -static int pmic8058_vib_read_u8(struct pmic8058_vib *vib, - u8 *data, u16 reg) -{ - int rc; - - rc = pm8058_read(vib->pm_chip, reg, data, 1); - if (rc < 0) - dev_warn(vib->dev, "Error reading pmic8058: %X - ret %X\n", - reg, rc); - - return rc; -} - -static int pmic8058_vib_write_u8(struct pmic8058_vib *vib, - u8 data, u16 reg) -{ - int rc; - - rc = pm8058_write(vib->pm_chip, reg, &data, 1); - if (rc < 0) - dev_warn(vib->dev, "Error writing pmic8058: %X - ret %X\n", - reg, rc); - return rc; -} - -static int pmic8058_vib_set(struct pmic8058_vib *vib, int on) -{ - int rc; - u8 val; - - if (on) { - val = vib->reg_vib_drv; - val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK); - rc = pmic8058_vib_write_u8(vib, val, VIB_DRV); - if (rc < 0) - return rc; - vib->reg_vib_drv = val; - vib->enabled = 1; - - } else { - val = vib->reg_vib_drv; - val &= ~VIB_DRV_SEL_MASK; - rc = pmic8058_vib_write_u8(vib, val, VIB_DRV); - if (rc < 0) - return rc; - vib->reg_vib_drv = val; - vib->enabled = 0; - } - __dump_vib_regs(vib, "vib_set_end"); - - return rc; -} - -static void pmic8058_work_handler(struct work_struct *work) -{ - u8 val; - int rc; - struct pmic8058_vib *info; - - info = container_of(work, struct pmic8058_vib, work); - - rc = pmic8058_vib_read_u8(info, &val, VIB_DRV); - if (rc < 0) - return; - - /* - * Vibrator support voltage ranges from 1.2 to 3.1V, so - * scale the FF speed to these range. - */ - if (info->speed) { - info->state = 1; - info->level = ((VIB_MAX_LEVELS * info->speed) / MAX_FF_SPEED) + - VIB_MIN_LEVEL_mV; - info->level /= 100; - } else { - info->state = 0; - info->level = VIB_MIN_LEVEL_mV / 100; - } - pmic8058_vib_set(info, info->state); -} - -static int pmic8058_vib_play_effect(struct input_dev *dev, void *data, - struct ff_effect *effect) -{ - struct pmic8058_vib *info = input_get_drvdata(dev); - - info->speed = effect->u.rumble.strong_magnitude >> 8; - if (!info->speed) - info->speed = effect->u.rumble.weak_magnitude >> 9; - schedule_work(&info->work); - return 0; -} - -static int pmic8058_vib_probe(struct platform_device *pdev) - -{ - struct pmic8058_vibrator_pdata *pdata = pdev->dev.platform_data; - struct pmic8058_vib *vib; - u8 val; - int rc; - - struct pm8058_chip *pm_chip; - - pm_chip = dev_get_drvdata(pdev->parent.dev); - if (pm_chip == NULL) { - dev_err(&pdev->dev, "no parent data passed in\n"); - return -EFAULT; - } - - if (!pdata) - return -EINVAL; - - if (pdata->level_mV < VIB_MIN_LEVEL_mV || - pdata->level_mV > VIB_MAX_LEVEL_mV) - return -EINVAL; - - vib = kzalloc(sizeof(*vib), GFP_KERNEL); - if (!vib) - return -ENOMEM; - - vib->pm_chip = pm_chip; - vib->enabled = 0; - vib->pdata = pdata; - vib->level = pdata->level_mV / 100; - vib->dev = &pdev->dev; - - spin_lock_init(&vib->lock); - INIT_WORK(&vib->work, pmic8058_work_handler); - - vib->info = input_allocate_device(); - - if (vib->info == NULL) { - dev_err(&pdev->dev, "couldn't allocate input device\n"); - return -ENOMEM; - } - - input_set_drvdata(vib->info, vib); - - vib->info->name = "pmic8058:vibrator"; - vib->info->id.version = 1; - vib->info->dev.parent = pdev->dev.parent; - - __set_bit(FF_RUMBLE, vib->info->ffbit); - __dump_vib_regs(vib, "boot_vib_default"); - - /* operate in manual mode */ - rc = pmic8058_vib_read_u8(vib, &val, VIB_DRV); - if (rc < 0) - goto err_read_vib; - val &= ~VIB_DRV_EN_MANUAL_MASK; - rc = pmic8058_vib_write_u8(vib, val, VIB_DRV); - if (rc < 0) - goto err_read_vib; - - vib->reg_vib_drv = val; - - rc = input_ff_create_memless(vib->info, NULL, pmic8058_vib_play_effect); - if (rc < 0) { - dev_dbg(&pdev->dev, "couldn't register vibrator to FF\n"); - goto create_memless_err; - } - - platform_set_drvdata(pdev, vib); - - rc = input_register_device(vib->info); - if (rc < 0) { - dev_dbg(&pdev->dev, "couldn't register input device\n"); - goto reg_err; - } - - return 0; - -reg_err: - input_ff_destroy(vib->info); -create_memless_err: - input_free_device(vib->info); -err_read_vib: - kfree(vib); - return rc; -} - -static int pmic8058_vib_remove(struct platform_device *pdev) -{ - struct pmic8058_vib *vib = platform_get_drvdata(pdev); - - cancel_work_sync(&vib->work); - if (vib->enabled) - pmic8058_vib_set(vib, 0); - - input_unregister_device(vib->info); - kfree(vib); - - return 0; -} - -static struct platform_driver pmic8058_vib_driver = { - .probe = pmic8058_vib_probe, - .remove = pmic8058_vib_remove, - .driver = { - .name = "pm8058-vib", - .owner = THIS_MODULE, - }, -}; - -static int __init pmic8058_vib_init(void) -{ - return platform_driver_register(&pmic8058_vib_driver); -} -module_init(pmic8058_vib_init); - -static void __exit pmic8058_vib_exit(void) -{ - platform_driver_unregister(&pmic8058_vib_driver); -} -module_exit(pmic8058_vib_exit); - -MODULE_ALIAS("platform:pmic8058_vib"); -MODULE_DESCRIPTION("PMIC8058 vibrator driver memless framework"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/input/mouse/qci_touchpad.c b/drivers/input/mouse/qci_touchpad.c deleted file mode 100644 index cf19ac35db8cce3c0c12ba8b8eb1afbb57678365..0000000000000000000000000000000000000000 --- a/drivers/input/mouse/qci_touchpad.c +++ /dev/null @@ -1,309 +0,0 @@ -/* Quanta I2C Touchpad Driver - * - * Copyright (C) 2009 Quanta Computer Inc. - * Author: Hsin Wu - * Author: Austin Lai - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - - /* - * - * The Driver with I/O communications via the I2C Interface for ON2 of AP BU. - * And it is only working on the nuvoTon WPCE775x Embedded Controller. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TOUCHPAD_ID_NAME "qci-i2cpad" -#define TOUCHPAD_NAME "PS2 Touchpad" -#define TOUCHPAD_DEVICE "/i2c/input1" -#define TOUCHPAD_CMD_ENABLE 0xF4 -#define TOUCHPAD_INIT_DELAY_MS 100 - -static int qcitp_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int qcitp_remove(struct i2c_client *kbd); - -/* General structure to hold the driver data */ -struct i2ctpad_drv_data { - struct i2c_client *ti2c_client; - struct work_struct work; - struct input_dev *qcitp_dev; - struct kobject *tp_kobj; - unsigned int qcitp_gpio; - unsigned int qcitp_irq; - char ecdata[8]; -}; - -static int tp_sense_val = 10; -static ssize_t tp_sensitive_show(struct kobject *kobj, - struct kobj_attribute *attr, char * buf) -{ - return sprintf(buf, "%d\n", tp_sense_val); -} - -static ssize_t tp_sensitive_store(struct kobject *kobj, - struct kobj_attribute *attr, const char* buf, size_t n) -{ - unsigned int val = 0; - sscanf(buf, "%d", &val); - - if (val >= 1 && val <= 10) - tp_sense_val = val; - else - return -ENOSYS; - - return sizeof(buf); -} - -static struct kobj_attribute tp_sensitivity = __ATTR(tp_sensitivity , - 0644 , - tp_sensitive_show , - tp_sensitive_store); - -static struct attribute *g_tp[] = { - &tp_sensitivity.attr, - NULL, -}; - -static struct attribute_group attr_group = { - .attrs = g_tp, -}; - -/*----------------------------------------------------------------------------- - * Driver functions - *---------------------------------------------------------------------------*/ - -#ifdef CONFIG_PM -static int qcitp_suspend(struct device *dev) -{ - return 0; -} - -static int qcitp_resume(struct device *dev) -{ - return 0; -} -#endif - -static const struct i2c_device_id qcitp_idtable[] = { - { TOUCHPAD_ID_NAME, 0 }, - { } -}; - -MODULE_DEVICE_TABLE(i2c, qcitp_idtable); -#ifdef CONFIG_PM -static const struct dev_pm_ops qcitp_pm_ops = { - .suspend = qcitp_suspend, - .resume = qcitp_resume, -}; -#endif -static struct i2c_driver i2ctp_driver = { - .driver = { - .owner = THIS_MODULE, - .name = TOUCHPAD_ID_NAME, -#ifdef CONFIG_PM - .pm = &qcitp_pm_ops, -#endif - }, - .probe = qcitp_probe, - .remove = qcitp_remove, - .id_table = qcitp_idtable, -}; - -static void qcitp_fetch_data(struct i2c_client *tpad_client, - char *ec_data) -{ - struct i2c_msg tp_msg; - int ret; - tp_msg.addr = tpad_client->addr; - tp_msg.flags = I2C_M_RD; - tp_msg.len = 3; - tp_msg.buf = (char *)&ec_data[0]; - ret = i2c_transfer(tpad_client->adapter, &tp_msg, 1); -} - -static void qcitp_report_key(struct input_dev *tpad_dev, char *ec_data) -{ - int dx = 0; - int dy = 0; - - if (ec_data[1]) - dx = (int) ec_data[1] - - (int) ((ec_data[0] << 4) & 0x100); - - if (ec_data[2]) - dy = (int) ((ec_data[0] << 3) & 0x100) - - (int) ec_data[2]; - - dx = (dx * tp_sense_val)/10; - dy = (dy * tp_sense_val)/10; - - input_report_key(tpad_dev, BTN_LEFT, ec_data[0] & 0x01); - input_report_key(tpad_dev, BTN_RIGHT, ec_data[0] & 0x02); - input_report_key(tpad_dev, BTN_MIDDLE, ec_data[0] & 0x04); - input_report_rel(tpad_dev, REL_X, dx); - input_report_rel(tpad_dev, REL_Y, dy); - input_sync(tpad_dev); -} - -static void qcitp_work_handler(struct work_struct *_work) -{ - struct i2ctpad_drv_data *itpad_drv_data = - container_of(_work, struct i2ctpad_drv_data, work); - - struct i2c_client *itpad_client = itpad_drv_data->ti2c_client; - struct input_dev *itpad_dev = itpad_drv_data->qcitp_dev; - - qcitp_fetch_data(itpad_client, itpad_drv_data->ecdata); - qcitp_report_key(itpad_dev, itpad_drv_data->ecdata); -} - -static irqreturn_t qcitp_interrupt(int irq, void *dev_id) -{ - struct i2ctpad_drv_data *itpad_drv_data = dev_id; - schedule_work(&itpad_drv_data->work); - return IRQ_HANDLED; -} - -static int qcitp_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int err = -ENOMEM; - struct i2ctpad_drv_data *context = 0; - - context = kzalloc(sizeof(struct i2ctpad_drv_data), GFP_KERNEL); - if (!context) - return err; - i2c_set_clientdata(client, context); - context->ti2c_client = client; - context->qcitp_gpio = client->irq; - - /* Enable mouse */ - i2c_smbus_write_byte(client, TOUCHPAD_CMD_ENABLE); - msleep(TOUCHPAD_INIT_DELAY_MS); - i2c_smbus_read_byte(client); - /*allocate and register input device*/ - context->qcitp_dev = input_allocate_device(); - if (!context->qcitp_dev) { - pr_err("[TouchPad] allocting memory fail\n"); - err = -ENOMEM; - goto allocate_fail; - } - context->qcitp_dev->name = TOUCHPAD_NAME; - context->qcitp_dev->phys = TOUCHPAD_DEVICE; - context->qcitp_dev->id.bustype = BUS_I2C; - context->qcitp_dev->id.vendor = 0x1050; - context->qcitp_dev->id.product = 0x1; - context->qcitp_dev->id.version = 0x1; - context->qcitp_dev->evbit[0] = BIT_MASK(EV_KEY) | - BIT_MASK(EV_REL); - context->qcitp_dev->relbit[0] = BIT_MASK(REL_X) | - BIT_MASK(REL_Y); - context->qcitp_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | - BIT_MASK(BTN_MIDDLE) | - BIT_MASK(BTN_RIGHT); - - input_set_drvdata(context->qcitp_dev, context); - err = input_register_device(context->qcitp_dev); - if (err) { - pr_err("[TouchPad] register device fail\n"); - goto register_fail; - } - - /*request intterrupt*/ - INIT_WORK(&context->work, qcitp_work_handler); - - err = gpio_request(context->qcitp_gpio, "qci-pad"); - if (err) { - pr_err("[TouchPad]err gpio request\n"); - goto gpio_request_fail; - } - - context->qcitp_irq = gpio_to_irq(context->qcitp_gpio); - err = request_irq(context->qcitp_irq, - qcitp_interrupt, - IRQF_TRIGGER_FALLING, - TOUCHPAD_ID_NAME, - context); - if (err) { - pr_err("[TouchPad] unable to get IRQ\n"); - goto request_irq_fail; - } - /*create touchpad kobject*/ - context->tp_kobj = kobject_create_and_add("touchpad", NULL); - - err = sysfs_create_group(context->tp_kobj, &attr_group); - if (err) - pr_warning("[TouchPad] sysfs create fail\n"); - - tp_sense_val = 10; - - return 0; - -request_irq_fail: - gpio_free(context->qcitp_gpio); - -gpio_request_fail: - input_unregister_device(context->qcitp_dev); - -register_fail: - input_free_device(context->qcitp_dev); - -allocate_fail: - i2c_set_clientdata(client, NULL); - kfree(context); - return err; -} - -static int qcitp_remove(struct i2c_client *dev) -{ - struct i2ctpad_drv_data *context = i2c_get_clientdata(dev); - - free_irq(context->qcitp_irq, context); - gpio_free(context->qcitp_gpio); - input_free_device(context->qcitp_dev); - input_unregister_device(context->qcitp_dev); - kfree(context); - - return 0; -} - -static int __init qcitp_init(void) -{ - return i2c_add_driver(&i2ctp_driver); -} - - -static void __exit qcitp_exit(void) -{ - i2c_del_driver(&i2ctp_driver); -} - -module_init(qcitp_init); -module_exit(qcitp_exit); - -MODULE_AUTHOR("Quanta Computer Inc."); -MODULE_DESCRIPTION("Quanta Embedded Controller I2C Touch Pad Driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 74b856f9090a63a2e4a6d373ef0e0ae7836ede8f..7c5a76cc5e0a6d65817471166c6f57ee1e13cce0 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -55,18 +55,6 @@ config TOUCHSCREEN_AD7877 To compile this driver as a module, choose M here: the module will be called ad7877. -config TOUCHSCREEN_ATMEL_MAXTOUCH - tristate "Atmel maXTouch based touchscreens" - depends on I2C - default n - help - Say Y here if you have an Atmel Maxtouch based touchscreen. - - If unsure, say N. - - To compile this driver as a module, choose M here: the - module will be called maXTouch. - config TOUCHSCREEN_AD7879 tristate "Analog Devices AD7879-1/AD7889-1 touchscreen interface" help @@ -485,15 +473,6 @@ config TOUCHSCREEN_EDT_FT5X06 To compile this driver as a module, choose M here: the module will be called edt-ft5x06. -config TOUCHSCREEN_MSM - bool "Qualcomm MSM touchscreen controller" - depends on ARCH_MSM7X30 && MARIMBA_TSADC - default n - help - Say Y here if you have a 4-wire resistive touchscreen panel - connected to the TSSC touchscreen controller on a - Qualcomm MSM/QSD based SoC. - config TOUCHSCREEN_MIGOR tristate "Renesas MIGO-R touchscreen" depends on SH_MIGOR && I2C @@ -868,17 +847,6 @@ config TOUCHSCREEN_TSC2007 To compile this driver as a module, choose M here: the module will be called tsc2007. -config TOUCHSCREEN_MSM_LEGACY - default n - tristate "MSM Touchscreen" - depends on ARCH_MSM && !ARCH_MSM7X30 - help - Say Y here if you have a touchscreen interface using MSM - touchscreen controller. - - To compile this driver as a module, choose M here: the - module will be called msm_touch. - config ANDROID_TOUCHSCREEN_MSM_HACKS default y depends on TOUCHSCREEN_MSM_LEGACY @@ -942,34 +910,6 @@ config TOUCHSCREEN_TPS6507X To compile this driver as a module, choose M here: the module will be called tps6507x_ts. -config TOUCHSCREEN_CY8C_TS - tristate "Cypress TMA300-TMG200 based touchscreens" - depends on I2C - default n - help - Say Y here if you have a Cypress TMA300/TMG200 based touchscreen. - TMA300 is a multi-touch screen which can report upto 10 - touches at a time. TMG200 supports 2 touches. - - If unsure, say N. - - To compile this driver as a module, choose M here: the - module will be called cy8c_ts. - -config TOUCHSCREEN_CYTTSP_I2C_QC - tristate "Cypress TTSP based touchscreens" - depends on I2C - default n - help - Say Y here if you have a Cypress TTSP based touchscreen. - TMA300 is a multi-touch screen which can report upto 10 - touches at a time. - - If unsure, say N. - - To compile this driver as a module, choose M here: the - module will be called cyttsp-i2c. - config TOUCHSCREEN_FT5X06 tristate "FocalTech touchscreens" depends on I2C diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 88476ee5772d8809a21315ba34ded52a10c6cd9d..89c750d00be4b5c319e54dfd14efac6b087ed2ba 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -12,11 +12,9 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o -obj-$(CONFIG_TOUCHSCREEN_ATMEL_MAXTOUCH) += atmel_maxtouch.o obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o -obj-$(CONFIG_TOUCHSCREEN_CYPRESS_TMG) += cy8c_tmg_ts.o obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o obj-$(CONFIG_TOUCHSCREEN_CYTTSP_CORE) += cyttsp_core.o @@ -44,7 +42,6 @@ obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o -obj-$(CONFIG_TOUCHSCREEN_MSM) += msm_ts.o obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o obj-$(CONFIG_TOUCHSCREEN_HTCPEN) += htcpen.o @@ -57,7 +54,6 @@ obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o -obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) += synaptics/ obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o @@ -77,9 +73,6 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o -obj-$(CONFIG_TOUCHSCREEN_MSM_LEGACY) += msm_touch.o -obj-$(CONFIG_TOUCHSCREEN_CY8C_TS) += cy8c_ts.o -obj-$(CONFIG_TOUCHSCREEN_CYTTSP_I2C_QC) += cyttsp-i2c-qc.o obj-$(CONFIG_TOUCHSCREEN_FT5X06) += ft5x06_ts.o obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4) += synaptics_i2c_rmi4.o obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_RMI4_DEV) += synaptics_rmi_dev.o diff --git a/drivers/input/touchscreen/atmel_maxtouch.c b/drivers/input/touchscreen/atmel_maxtouch.c deleted file mode 100644 index 9c8e5ad58acc4735acf8ba6230aef025d47324d5..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/atmel_maxtouch.c +++ /dev/null @@ -1,2341 +0,0 @@ -/* - * Atmel maXTouch Touchscreen Controller Driver - * - * - * Copyright (C) 2010 Atmel Corporation - * Copyright (C) 2010 Ulf Samuelsson (ulf@atmel.com) - * Copyright (C) 2009 Raphael Derosso Pereira - * - * 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 of the License - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * - * Driver for Atmel maXTouch family of touch controllers. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#if defined(CONFIG_HAS_EARLYSUSPEND) -#include - -/* Early-suspend level */ -#define MXT_SUSPEND_LEVEL 1 -#endif - - -#define DRIVER_VERSION "0.91a_mod" - -static int debug = DEBUG_INFO; -static int comms = 0; -module_param(debug, int, 0644); -module_param(comms, int, 0644); - -MODULE_PARM_DESC(debug, "Activate debugging output"); -MODULE_PARM_DESC(comms, "Select communications mode"); - -#define T7_DATA_SIZE 3 - -/* Device Info descriptor */ -/* Parsed from maXTouch "Id information" inside device */ -struct mxt_device_info { - u8 family_id; - u8 variant_id; - u8 major; - u8 minor; - u8 build; - u8 num_objs; - u8 x_size; - u8 y_size; - char family_name[16]; /* Family name */ - char variant_name[16]; /* Variant name */ - u16 num_nodes; /* Number of sensor nodes */ -}; - -/* object descriptor table, parsed from maXTouch "object table" */ -struct mxt_object { - u16 chip_addr; - u8 type; - u8 size; - u8 instances; - u8 num_report_ids; -}; - - -/* Mapping from report id to object type and instance */ -struct report_id_map { - u8 object; - u8 instance; -/* - * This is the first report ID belonging to object. It enables us to - * find out easily the touch number: each touch has different report - * ID (which are assigned to touches in increasing order). By - * subtracting the first report ID from current, we get the touch - * number. - */ - u8 first_rid; -}; - - -/* Driver datastructure */ -struct mxt_data { - struct i2c_client *client; - struct input_dev *input; - char phys_name[32]; - int irq; - - u16 last_read_addr; - bool new_msgs; - u8 *last_message; - - int valid_irq_counter; - int invalid_irq_counter; - int irq_counter; - int message_counter; - int read_fail_counter; - - - int bytes_to_read; - - struct delayed_work dwork; - u8 xpos_format; - u8 ypos_format; - - u8 numtouch; - - struct mxt_device_info device_info; - - u32 info_block_crc; - u32 configuration_crc; - u16 report_id_count; - struct report_id_map *rid_map; - struct mxt_object *object_table; - - u16 msg_proc_addr; - u8 message_size; - - u16 min_x_val; - u16 min_y_val; - u16 max_x_val; - u16 max_y_val; - - int (*init_hw)(struct i2c_client *client); - int (*exit_hw)(struct i2c_client *client); - int (*power_on)(bool on); - u8 (*valid_interrupt)(void); - u8 (*read_chg)(void); - - /* debugfs variables */ - struct dentry *debug_dir; - int current_debug_datap; - - struct mutex debug_mutex; - u16 *debug_data; - - /* Character device variables */ - struct cdev cdev; - struct cdev cdev_messages; /* 2nd Char dev for messages */ - dev_t dev_num; - struct class *mxt_class; - - - u16 address_pointer; - bool valid_ap; - - /* Message buffer & pointers */ - char *messages; - int msg_buffer_startp, msg_buffer_endp; - /* Put only non-touch messages to buffer if this is set */ - char nontouch_msg_only; - struct mutex msg_mutex; -#if defined(CONFIG_HAS_EARLYSUSPEND) - struct early_suspend early_suspend; -#endif - u8 t7_data[T7_DATA_SIZE]; - bool is_suspended; -}; -/*default value, enough to read versioning*/ -#define CONFIG_DATA_SIZE 6 -static u16 t38_size = CONFIG_DATA_SIZE; -static int mxt_read_block(struct i2c_client *client, u16 addr, u16 length, - u8 *value); -static int mxt_write_byte(struct i2c_client *client, u16 addr, u8 value); -static int mxt_write_block(struct i2c_client *client, u16 addr, u16 length, - u8 *value); -static u8 mxt_valid_interrupt_dummy(void) -{ - return 1; -} - -#define I2C_RETRY_COUNT 5 -#define I2C_PAYLOAD_SIZE 254 - -/* Returns the start address of object in mXT memory. */ -#define MXT_BASE_ADDR(object_type, mxt) \ - get_object_address(object_type, 0, mxt->object_table, \ - mxt->device_info.num_objs) - -/* Maps a report ID to an object type (object type number). */ -#define REPORT_ID_TO_OBJECT(rid, mxt) \ - (((rid) == 0xff) ? 0 : mxt->rid_map[rid].object) - -/* Maps a report ID to an object type (string). */ -#define REPORT_ID_TO_OBJECT_NAME(rid, mxt) \ - object_type_name[REPORT_ID_TO_OBJECT(rid, mxt)] - -/* Returns non-zero if given object is a touch object */ -#define IS_TOUCH_OBJECT(object) \ - ((object == MXT_TOUCH_MULTITOUCHSCREEN_T9) || \ - (object == MXT_TOUCH_KEYARRAY_T15) || \ - (object == MXT_TOUCH_PROXIMITY_T23) || \ - (object == MXT_TOUCH_SINGLETOUCHSCREEN_T10) || \ - (object == MXT_TOUCH_XSLIDER_T11) || \ - (object == MXT_TOUCH_YSLIDER_T12) || \ - (object == MXT_TOUCH_XWHEEL_T13) || \ - (object == MXT_TOUCH_YWHEEL_T14) || \ - (object == MXT_TOUCH_KEYSET_T31) || \ - (object == MXT_TOUCH_XSLIDERSET_T32) ? 1 : 0) - -#define mxt_debug(level, ...) \ - do { \ - if (debug >= (level)) \ - pr_debug(__VA_ARGS__); \ - } while (0) - - -/* - * Check whether we have multi-touch enabled kernel; if not, report just the - * first touch (on mXT224, the maximum is 10 simultaneous touches). - * Because just the 1st one is reported, it might seem that the screen is not - * responding to touch if the first touch is removed while the screen is being - * touched by another finger, so beware. - * - */ - -#ifdef ABS_MT_TRACKING_ID -static inline void report_mt(int touch_number, int size, int x, int y, struct - mxt_data *mxt) { - input_report_abs(mxt->input, ABS_MT_TRACKING_ID, touch_number); - input_report_abs(mxt->input, ABS_MT_TOUCH_MAJOR, size); - input_report_abs(mxt->input, ABS_MT_POSITION_X, x); - input_report_abs(mxt->input, ABS_MT_POSITION_Y, y); - input_mt_sync(mxt->input); -} -#else -static inline void report_mt(int touch_number, int size, int x, int y, struct - mxt_data *mxt) { - if (touch_number == 0) { - input_report_abs(mxt->input, ABS_TOOL_WIDTH, size); - input_report_abs(mxt->input, ABS_X, x); - input_report_abs(mxt->input, ABS_Y, y); - } -} -#endif - - -static inline void report_gesture(int data, struct mxt_data *mxt) -{ - input_event(mxt->input, EV_MSC, MSC_GESTURE, data); -} - - -static const u8 *object_type_name[] = { - [0] = "Reserved", - [5] = "GEN_MESSAGEPROCESSOR_T5", - [6] = "GEN_COMMANDPROCESSOR_T6", - [7] = "GEN_POWERCONFIG_T7", - [8] = "GEN_ACQUIRECONFIG_T8", - [9] = "TOUCH_MULTITOUCHSCREEN_T9", - [15] = "TOUCH_KEYARRAY_T15", - [17] = "SPT_COMMSCONFIG_T18", - [19] = "SPT_GPIOPWM_T19", - [20] = "PROCI_GRIPFACESUPPRESSION_T20", - [22] = "PROCG_NOISESUPPRESSION_T22", - [23] = "TOUCH_PROXIMITY_T23", - [24] = "PROCI_ONETOUCHGESTUREPROCESSOR_T24", - [25] = "SPT_SELFTEST_T25", - [27] = "PROCI_TWOTOUCHGESTUREPROCESSOR_T27", - [28] = "SPT_CTECONFIG_T28", - [37] = "DEBUG_DIAGNOSTICS_T37", - [38] = "SPT_USER_DATA_T38", - [40] = "PROCI_GRIPSUPPRESSION_T40", - [41] = "PROCI_PALMSUPPRESSION_T41", - [42] = "PROCI_FACESUPPRESSION_T42", - [43] = "SPT_DIGITIZER_T43", - [44] = "SPT_MESSAGECOUNT_T44", -}; - - -static u16 get_object_address(uint8_t object_type, - uint8_t instance, - struct mxt_object *object_table, - int max_objs); - -int mxt_write_ap(struct mxt_data *mxt, u16 ap); - -static int mxt_read_block_wo_addr(struct i2c_client *client, - u16 length, - u8 *value); - -ssize_t debug_data_read(struct mxt_data *mxt, char *buf, size_t count, - loff_t *ppos, u8 debug_command){ - int i; - u16 *data; - u16 diagnostics_reg; - int offset = 0; - int size; - int read_size; - int error; - char *buf_start; - u16 debug_data_addr; - u16 page_address; - u8 page; - u8 debug_command_reg; - - data = mxt->debug_data; - if (data == NULL) - return -EIO; - - /* If first read after open, read all data to buffer. */ - if (mxt->current_debug_datap == 0){ - - diagnostics_reg = MXT_BASE_ADDR(MXT_GEN_COMMANDPROCESSOR_T6, - mxt) + - MXT_ADR_T6_DIAGNOSTIC; - if (count > (mxt->device_info.num_nodes * 2)) - count = mxt->device_info.num_nodes; - - debug_data_addr = MXT_BASE_ADDR(MXT_DEBUG_DIAGNOSTIC_T37, mxt)+ - MXT_ADR_T37_DATA; - page_address = MXT_BASE_ADDR(MXT_DEBUG_DIAGNOSTIC_T37, mxt) + - MXT_ADR_T37_PAGE; - error = mxt_read_block(mxt->client, page_address, 1, &page); - if (error < 0) - return error; - mxt_debug(DEBUG_TRACE, "debug data page = %d\n", page); - while (page != 0) { - error = mxt_write_byte(mxt->client, - diagnostics_reg, - MXT_CMD_T6_PAGE_DOWN); - if (error < 0) - return error; - /* Wait for command to be handled; when it has, the - register will be cleared. */ - debug_command_reg = 1; - while (debug_command_reg != 0) { - error = mxt_read_block(mxt->client, - diagnostics_reg, 1, - &debug_command_reg); - if (error < 0) - return error; - mxt_debug(DEBUG_TRACE, - "Waiting for debug diag command " - "to propagate...\n"); - - } - error = mxt_read_block(mxt->client, page_address, 1, - &page); - if (error < 0) - return error; - mxt_debug(DEBUG_TRACE, "debug data page = %d\n", page); - } - - /* - * Lock mutex to prevent writing some unwanted data to debug - * command register. User can still write through the char - * device interface though. TODO: fix? - */ - - mutex_lock(&mxt->debug_mutex); - /* Configure Debug Diagnostics object to show deltas/refs */ - error = mxt_write_byte(mxt->client, diagnostics_reg, - debug_command); - - /* Wait for command to be handled; when it has, the - * register will be cleared. */ - debug_command_reg = 1; - while (debug_command_reg != 0) { - error = mxt_read_block(mxt->client, - diagnostics_reg, 1, - &debug_command_reg); - if (error < 0) - return error; - mxt_debug(DEBUG_TRACE, "Waiting for debug diag command " - "to propagate...\n"); - - } - - if (error < 0) { - printk (KERN_WARNING - "Error writing to maXTouch device!\n"); - return error; - } - - size = mxt->device_info.num_nodes * sizeof(u16); - - while (size > 0) { - read_size = size > 128 ? 128 : size; - mxt_debug(DEBUG_TRACE, - "Debug data read loop, reading %d bytes...\n", - read_size); - error = mxt_read_block(mxt->client, - debug_data_addr, - read_size, - (u8 *) &data[offset]); - if (error < 0) { - printk(KERN_WARNING - "Error reading debug data\n"); - goto error; - } - offset += read_size/2; - size -= read_size; - - /* Select next page */ - error = mxt_write_byte(mxt->client, diagnostics_reg, - MXT_CMD_T6_PAGE_UP); - if (error < 0) { - printk(KERN_WARNING - "Error writing to maXTouch device!\n"); - goto error; - } - } - mutex_unlock(&mxt->debug_mutex); - } - - buf_start = buf; - i = mxt->current_debug_datap; - - while (((buf- buf_start) < (count - 6)) && - (i < mxt->device_info.num_nodes)){ - - mxt->current_debug_datap++; - if (debug_command == MXT_CMD_T6_REFERENCES_MODE) - buf += sprintf(buf, "%d: %5d\n", i, - (u16) le16_to_cpu(data[i])); - else if (debug_command == MXT_CMD_T6_DELTAS_MODE) - buf += sprintf(buf, "%d: %5d\n", i, - (s16) le16_to_cpu(data[i])); - i++; - } - - return (buf - buf_start); -error: - mutex_unlock(&mxt->debug_mutex); - return error; -} - -ssize_t deltas_read(struct file *file, char *buf, size_t count, loff_t *ppos) -{ - return debug_data_read(file->private_data, buf, count, ppos, - MXT_CMD_T6_DELTAS_MODE); -} - -ssize_t refs_read(struct file *file, char *buf, size_t count, - loff_t *ppos) -{ - return debug_data_read(file->private_data, buf, count, ppos, - MXT_CMD_T6_REFERENCES_MODE); -} - -int debug_data_open(struct inode *inode, struct file *file) -{ - struct mxt_data *mxt; - int i; - mxt = inode->i_private; - if (mxt == NULL) - return -EIO; - mxt->current_debug_datap = 0; - mxt->debug_data = kmalloc(mxt->device_info.num_nodes * sizeof(u16), - GFP_KERNEL); - if (mxt->debug_data == NULL) - return -ENOMEM; - - - for (i = 0; i < mxt->device_info.num_nodes; i++) - mxt->debug_data[i] = 7777; - - - file->private_data = mxt; - return 0; -} - -int debug_data_release(struct inode *inode, struct file *file) -{ - struct mxt_data *mxt; - mxt = file->private_data; - kfree(mxt->debug_data); - return 0; -} - -static struct file_operations delta_fops = { - .owner = THIS_MODULE, - .open = debug_data_open, - .release = debug_data_release, - .read = deltas_read, -}; - -static struct file_operations refs_fops = { - .owner = THIS_MODULE, - .open = debug_data_open, - .release = debug_data_release, - .read = refs_read, -}; - - -int mxt_memory_open(struct inode *inode, struct file *file) -{ - struct mxt_data *mxt; - mxt = container_of(inode->i_cdev, struct mxt_data, cdev); - if (mxt == NULL) - return -EIO; - file->private_data = mxt; - return 0; -} - -int mxt_message_open(struct inode *inode, struct file *file) -{ - struct mxt_data *mxt; - mxt = container_of(inode->i_cdev, struct mxt_data, cdev_messages); - if (mxt == NULL) - return -EIO; - file->private_data = mxt; - return 0; -} - - -ssize_t mxt_memory_read(struct file *file, char *buf, size_t count, - loff_t *ppos) -{ - int i; - struct mxt_data *mxt; - - mxt = file->private_data; - if (mxt->valid_ap){ - mxt_debug(DEBUG_TRACE, "Reading %d bytes from current ap\n", - (int) count); - i = mxt_read_block_wo_addr(mxt->client, count, (u8 *) buf); - } else { - mxt_debug(DEBUG_TRACE, "Address pointer changed since set;" - "writing AP (%d) before reading %d bytes", - mxt->address_pointer, (int) count); - i = mxt_read_block(mxt->client, mxt->address_pointer, count, - buf); - } - - return i; -} - -ssize_t mxt_memory_write(struct file *file, const char *buf, size_t count, - loff_t *ppos) -{ - int i; - int whole_blocks; - int last_block_size; - struct mxt_data *mxt; - u16 address; - - mxt = file->private_data; - address = mxt->address_pointer; - - mxt_debug(DEBUG_TRACE, "mxt_memory_write entered\n"); - whole_blocks = count / I2C_PAYLOAD_SIZE; - last_block_size = count % I2C_PAYLOAD_SIZE; - - for (i = 0; i < whole_blocks; i++) { - mxt_debug(DEBUG_TRACE, "About to write to %d...", - address); - mxt_write_block(mxt->client, address, I2C_PAYLOAD_SIZE, - (u8 *) buf); - address += I2C_PAYLOAD_SIZE; - buf += I2C_PAYLOAD_SIZE; - } - - mxt_write_block(mxt->client, address, last_block_size, (u8 *) buf); - - return count; -} - -static long mxt_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) -{ - int retval; - struct mxt_data *mxt; - - retval = 0; - mxt = file->private_data; - - switch (cmd) { - case MXT_SET_ADDRESS_IOCTL: - retval = mxt_write_ap(mxt, (u16) arg); - if (retval >= 0) { - mxt->address_pointer = (u16) arg; - mxt->valid_ap = 1; - } - break; - case MXT_RESET_IOCTL: - retval = mxt_write_byte(mxt->client, - MXT_BASE_ADDR(MXT_GEN_COMMANDPROCESSOR_T6, mxt) + - MXT_ADR_T6_RESET, - 1); - break; - case MXT_CALIBRATE_IOCTL: - retval = mxt_write_byte(mxt->client, - MXT_BASE_ADDR(MXT_GEN_COMMANDPROCESSOR_T6, mxt) + - MXT_ADR_T6_CALIBRATE, - 1); - - break; - case MXT_BACKUP_IOCTL: - retval = mxt_write_byte(mxt->client, - MXT_BASE_ADDR(MXT_GEN_COMMANDPROCESSOR_T6, mxt) + - MXT_ADR_T6_BACKUPNV, - MXT_CMD_T6_BACKUP); - break; - case MXT_NONTOUCH_MSG_IOCTL: - mxt->nontouch_msg_only = 1; - break; - case MXT_ALL_MSG_IOCTL: - mxt->nontouch_msg_only = 0; - break; - default: - return -EIO; - } - - return retval; -} - -/* - * Copies messages from buffer to user space. - * - * NOTE: if less than (mxt->message_size * 5 + 1) bytes requested, - * this will return 0! - * - */ -ssize_t mxt_message_read(struct file *file, char *buf, size_t count, - loff_t *ppos) -{ - int i; - struct mxt_data *mxt; - char *buf_start; - - mxt = file->private_data; - if (mxt == NULL) - return -EIO; - buf_start = buf; - - mutex_lock(&mxt->msg_mutex); - /* Copy messages until buffer empty, or 'count' bytes written */ - while ((mxt->msg_buffer_startp != mxt->msg_buffer_endp) && - ((buf - buf_start) < (count - (5 * mxt->message_size) - 1))){ - - for (i = 0; i < mxt->message_size; i++){ - buf += sprintf(buf, "[%2X] ", - *(mxt->messages + mxt->msg_buffer_endp * - mxt->message_size + i)); - } - buf += sprintf(buf, "\n"); - if (mxt->msg_buffer_endp < MXT_MESSAGE_BUFFER_SIZE) - mxt->msg_buffer_endp++; - else - mxt->msg_buffer_endp = 0; - } - mutex_unlock(&mxt->msg_mutex); - return (buf - buf_start); -} - -static struct file_operations mxt_message_fops = { - .owner = THIS_MODULE, - .open = mxt_message_open, - .read = mxt_message_read, -}; - -static struct file_operations mxt_memory_fops = { - .owner = THIS_MODULE, - .open = mxt_memory_open, - .read = mxt_memory_read, - .write = mxt_memory_write, - .unlocked_ioctl = mxt_ioctl, -}; - - -/* Writes the address pointer (to set up following reads). */ - -int mxt_write_ap(struct mxt_data *mxt, u16 ap) -{ - struct i2c_client *client; - __le16 le_ap = cpu_to_le16(ap); - client = mxt->client; - if (mxt != NULL) - mxt->last_read_addr = -1; - if (i2c_master_send(client, (u8 *) &le_ap, 2) == 2) { - mxt_debug(DEBUG_TRACE, "Address pointer set to %d\n", ap); - return 0; - } else { - mxt_debug(DEBUG_INFO, "Error writing address pointer!\n"); - return -EIO; - } -} - - - -/* Calculates the 24-bit CRC sum. */ -static u32 CRC_24(u32 crc, u8 byte1, u8 byte2) -{ - static const u32 crcpoly = 0x80001B; - u32 result; - u32 data_word; - - data_word = ((((u16) byte2) << 8u) | byte1); - result = ((crc << 1u) ^ data_word); - if (result & 0x1000000) - result ^= crcpoly; - return result; -} - -/* Returns object address in mXT chip, or zero if object is not found */ -static u16 get_object_address(uint8_t object_type, - uint8_t instance, - struct mxt_object *object_table, - int max_objs) -{ - uint8_t object_table_index = 0; - uint8_t address_found = 0; - uint16_t address = 0; - struct mxt_object *obj; - - while ((object_table_index < max_objs) && !address_found) { - obj = &object_table[object_table_index]; - if (obj->type == object_type) { - address_found = 1; - /* Are there enough instances defined in the FW? */ - if (obj->instances >= instance) { - address = obj->chip_addr + - (obj->size + 1) * instance; - } else { - return 0; - } - } - object_table_index++; - } - return address; -} - - -/* - * Reads a block of bytes from given address from mXT chip. If we are - * reading from message window, and previous read was from message window, - * there's no need to write the address pointer: the mXT chip will - * automatically set the address pointer back to message window start. - */ - -static int mxt_read_block(struct i2c_client *client, - u16 addr, - u16 length, - u8 *value) -{ - struct i2c_adapter *adapter = client->adapter; - struct i2c_msg msg[2]; - __le16 le_addr; - struct mxt_data *mxt; - - mxt = i2c_get_clientdata(client); - - if (mxt != NULL) { - if ((mxt->last_read_addr == addr) && - (addr == mxt->msg_proc_addr)) { - if (i2c_master_recv(client, value, length) == length) - return length; - else - return -EIO; - } else { - mxt->last_read_addr = addr; - } - } - - mxt_debug(DEBUG_TRACE, "Writing address pointer & reading %d bytes " - "in on i2c transaction...\n", length); - - le_addr = cpu_to_le16(addr); - msg[0].addr = client->addr; - msg[0].flags = 0x00; - msg[0].len = 2; - msg[0].buf = (u8 *) &le_addr; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].len = length; - msg[1].buf = (u8 *) value; - if (i2c_transfer(adapter, msg, 2) == 2) - return length; - else - return -EIO; - -} - -/* Reads a block of bytes from current address from mXT chip. */ - -static int mxt_read_block_wo_addr(struct i2c_client *client, - u16 length, - u8 *value) -{ - - - if (i2c_master_recv(client, value, length) == length) { - mxt_debug(DEBUG_TRACE, "I2C block read ok\n"); - return length; - } else { - mxt_debug(DEBUG_INFO, "I2C block read failed\n"); - return -EIO; - } - -} - - -/* Writes one byte to given address in mXT chip. */ - -static int mxt_write_byte(struct i2c_client *client, u16 addr, u8 value) -{ - struct { - __le16 le_addr; - u8 data; - - } i2c_byte_transfer; - - struct mxt_data *mxt; - - mxt = i2c_get_clientdata(client); - if (mxt != NULL) - mxt->last_read_addr = -1; - i2c_byte_transfer.le_addr = cpu_to_le16(addr); - i2c_byte_transfer.data = value; - if (i2c_master_send(client, (u8 *) &i2c_byte_transfer, 3) == 3) - return 0; - else - return -EIO; -} - - -/* Writes a block of bytes (max 256) to given address in mXT chip. */ -static int mxt_write_block(struct i2c_client *client, - u16 addr, - u16 length, - u8 *value) -{ - int i; - struct { - __le16 le_addr; - u8 data[256]; - - } i2c_block_transfer; - - struct mxt_data *mxt; - - mxt_debug(DEBUG_TRACE, "Writing %d bytes to %d...", length, addr); - if (length > 256) - return -EINVAL; - mxt = i2c_get_clientdata(client); - if (mxt != NULL) - mxt->last_read_addr = -1; - for (i = 0; i < length; i++) - i2c_block_transfer.data[i] = *value++; - i2c_block_transfer.le_addr = cpu_to_le16(addr); - i = i2c_master_send(client, (u8 *) &i2c_block_transfer, length + 2); - if (i == (length + 2)) - return length; - else - return -EIO; -} - -/* Calculates the CRC value for mXT infoblock. */ -int calculate_infoblock_crc(u32 *crc_result, u8 *data, int crc_area_size) -{ - u32 crc = 0; - int i; - - for (i = 0; i < (crc_area_size - 1); i = i + 2) - crc = CRC_24(crc, *(data + i), *(data + i + 1)); - /* If uneven size, pad with zero */ - if (crc_area_size & 0x0001) - crc = CRC_24(crc, *(data + i), 0); - /* Return only 24 bits of CRC. */ - *crc_result = (crc & 0x00FFFFFF); - - return 0; -} - -/* Processes a touchscreen message. */ -void process_T9_message(u8 *message, struct mxt_data *mxt, int last_touch) -{ - - struct input_dev *input; - u8 status; - u16 xpos = 0xFFFF; - u16 ypos = 0xFFFF; - u8 touch_size = 255; - u8 touch_number; - u8 amplitude; - u8 report_id; - - static int stored_size[10]; - static int stored_x[10]; - static int stored_y[10]; - int i; - int active_touches = 0; - /* - * If the 'last_touch' flag is set, we have received all the touch - * messages - * there are available in this cycle, so send the events for touches - * that are - * active. - */ - if (last_touch){ - /* TODO: For compatibility with single-touch systems, send ABS_X & - * ABS_Y */ - /* - if (stored_size[0]){ - input_report_abs(mxt->input, ABS_X, stored_x[0]); - input_report_abs(mxt->input, ABS_Y, stored_y[0]); - }*/ - - - for (i = 0; i < 10; i++){ - if (stored_size[i]){ - active_touches++; - input_report_abs(mxt->input, - ABS_MT_TRACKING_ID, - i); - input_report_abs(mxt->input, - ABS_MT_TOUCH_MAJOR, - stored_size[i]); - input_report_abs(mxt->input, - ABS_MT_POSITION_X, - stored_x[i]); - input_report_abs(mxt->input, - ABS_MT_POSITION_Y, - stored_y[i]); - input_mt_sync(mxt->input); - } - } - input_report_key(mxt->input, BTN_TOUCH, !!active_touches); - if (active_touches == 0) - input_mt_sync(mxt->input); - input_sync(mxt->input); - - }else{ - - input = mxt->input; - status = message[MXT_MSG_T9_STATUS]; - report_id = message[0]; - - if (status & MXT_MSGB_T9_SUPPRESS) { - /* Touch has been suppressed by grip/face */ - /* detection */ - mxt_debug(DEBUG_TRACE, "SUPRESS"); - } else { - /* Put together the 10-/12-bit coordinate values. */ - xpos = message[MXT_MSG_T9_XPOSMSB] * 16 + - ((message[MXT_MSG_T9_XYPOSLSB] >> 4) & 0xF); - ypos = message[MXT_MSG_T9_YPOSMSB] * 16 + - ((message[MXT_MSG_T9_XYPOSLSB] >> 0) & 0xF); - - if (mxt->max_x_val < 1024) - xpos >>= 2; - if (mxt->max_y_val < 1024) - ypos >>= 2; - - touch_number = message[MXT_MSG_REPORTID] - - mxt->rid_map[report_id].first_rid; - - stored_x[touch_number] = xpos; - stored_y[touch_number] = ypos; - - if (status & MXT_MSGB_T9_DETECT) { - /* - * mXT224 reports the number of touched nodes, - * so the exact value for touch ellipse major - * axis length in nodes would be 2*sqrt(touch_size/pi) - * (assuming round touch shape), which would then need - * to be scaled using information about how many sensor - * lines we do have. So this is very much simplified, - * but sufficient for most if not all apps? - */ - touch_size = message[MXT_MSG_T9_TCHAREA]; - touch_size = touch_size >> 2; - if (!touch_size) - touch_size = 1; - /* - * report_mt(touch_number, touch_size, xpos, ypos, mxt); - */ - - stored_size[touch_number] = touch_size; - - if (status & MXT_MSGB_T9_AMP) - /* Amplitude of touch has changed */ - amplitude = message[MXT_MSG_T9_TCHAMPLITUDE]; - } - - if (status & MXT_MSGB_T9_RELEASE) { - /* The previously reported touch has been removed.*/ - /* report_mt(touch_number, 0, xpos, ypos, mxt); */ - stored_size[touch_number] = 0; - } - - /* input_sync(input); */ - } - - if (status & MXT_MSGB_T9_SUPPRESS) { - mxt_debug(DEBUG_TRACE, "SUPRESS"); - } else { - if (status & MXT_MSGB_T9_DETECT) { - mxt_debug(DEBUG_TRACE, "DETECT:%s%s%s%s", - ((status & MXT_MSGB_T9_PRESS) ? " PRESS" : ""), - ((status & MXT_MSGB_T9_MOVE) ? " MOVE" : ""), - ((status & MXT_MSGB_T9_AMP) ? " AMP" : ""), - ((status & MXT_MSGB_T9_VECTOR) ? " VECT" : "")); - - } else if (status & MXT_MSGB_T9_RELEASE) { - mxt_debug(DEBUG_TRACE, "RELEASE"); - } - } - mxt_debug(DEBUG_TRACE, "X=%d, Y=%d, TOUCHSIZE=%d", - xpos, ypos, touch_size); - } - return; -} - - -int process_message(u8 *message, u8 object, struct mxt_data *mxt) -{ - struct i2c_client *client; - u8 status; - u16 xpos = 0xFFFF; - u16 ypos = 0xFFFF; - u8 event; - u8 direction; - u16 distance; - u8 length; - u8 report_id; - static u8 error_cond = 0; - - client = mxt->client; - length = mxt->message_size; - report_id = message[0]; - - if ((mxt->nontouch_msg_only == 0) || - (!IS_TOUCH_OBJECT(object))){ - mutex_lock(&mxt->msg_mutex); - /* Copy the message to buffer */ - if (mxt->msg_buffer_startp < MXT_MESSAGE_BUFFER_SIZE) { - mxt->msg_buffer_startp++; - } else { - mxt->msg_buffer_startp = 0; - } - - if (mxt->msg_buffer_startp == mxt->msg_buffer_endp) { - mxt_debug(DEBUG_TRACE, - "Message buf full, discarding last entry.\n"); - if (mxt->msg_buffer_endp < MXT_MESSAGE_BUFFER_SIZE) { - mxt->msg_buffer_endp++; - } else { - mxt->msg_buffer_endp = 0; - } - } - memcpy((mxt->messages + mxt->msg_buffer_startp * length), - message, - length); - mutex_unlock(&mxt->msg_mutex); - } - - switch (object) { - case MXT_GEN_COMMANDPROCESSOR_T6: - status = message[1]; - - if (status & MXT_MSGB_T6_COMSERR) { - if ((!error_cond) & MXT_MSGB_T6_COMSERR){ - dev_err(&client->dev, - "maXTouch checksum error\n"); - error_cond |= MXT_MSGB_T6_COMSERR; - } - } - if (status & MXT_MSGB_T6_CFGERR) { - /* - * Configuration error. A proper configuration - * needs to be written to chip and backed up. - */ - if ((!error_cond) & MXT_MSGB_T6_CFGERR){ - dev_err(&client->dev, - "maXTouch configuration error\n"); - error_cond |= MXT_MSGB_T6_CFGERR; - } - } - if (status & MXT_MSGB_T6_CAL) { - /* Calibration in action, no need to react */ - dev_dbg(&client->dev, - "maXTouch calibration in progress\n"); - } - if (status & MXT_MSGB_T6_SIGERR) { - /* - * Signal acquisition error, something is seriously - * wrong, not much we can in the driver to correct - * this - */ - if ((!error_cond) & MXT_MSGB_T6_SIGERR){ - dev_err(&client->dev, - "maXTouch acquisition error\n"); - error_cond |= MXT_MSGB_T6_SIGERR; - } - } - if (status & MXT_MSGB_T6_OFL) { - /* - * Cycle overflow, the acquisition interval is too - * short. - */ - dev_err(&client->dev, - "maXTouch cycle overflow\n"); - } - if (status & MXT_MSGB_T6_RESET) { - /* Chip has reseted, no need to react. */ - dev_dbg(&client->dev, - "maXTouch chip reset\n"); - } - if (status == 0) { - /* Chip status back to normal. */ - dev_dbg(&client->dev, - "maXTouch status normal\n"); - error_cond = 0; - } - break; - - case MXT_TOUCH_MULTITOUCHSCREEN_T9: - process_T9_message(message, mxt, 0); - break; - - case MXT_SPT_GPIOPWM_T19: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "Receiving GPIO message\n"); - break; - - case MXT_PROCI_GRIPFACESUPPRESSION_T20: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "Receiving face suppression msg\n"); - break; - - case MXT_PROCG_NOISESUPPRESSION_T22: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "Receiving noise suppression msg\n"); - status = message[MXT_MSG_T22_STATUS]; - if (status & MXT_MSGB_T22_FHCHG) { - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "maXTouch: Freq changed\n"); - } - if (status & MXT_MSGB_T22_GCAFERR) { - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "maXTouch: High noise " - "level\n"); - } - if (status & MXT_MSGB_T22_FHERR) { - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "maXTouch: Freq changed - " - "Noise level too high\n"); - } - break; - - case MXT_PROCI_ONETOUCHGESTUREPROCESSOR_T24: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "Receiving one-touch gesture msg\n"); - - event = message[MXT_MSG_T24_STATUS] & 0x0F; - xpos = message[MXT_MSG_T24_XPOSMSB] * 16 + - ((message[MXT_MSG_T24_XYPOSLSB] >> 4) & 0x0F); - ypos = message[MXT_MSG_T24_YPOSMSB] * 16 + - ((message[MXT_MSG_T24_XYPOSLSB] >> 0) & 0x0F); - if (mxt->max_x_val < 1024) - xpos >>= 2; - if (mxt->max_y_val < 1024) - ypos >>= 2; - direction = message[MXT_MSG_T24_DIR]; - distance = message[MXT_MSG_T24_DIST] + - (message[MXT_MSG_T24_DIST + 1] << 16); - - report_gesture((event << 24) | (direction << 16) | distance, - mxt); - report_gesture((xpos << 16) | ypos, mxt); - - break; - - case MXT_SPT_SELFTEST_T25: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "Receiving Self-Test msg\n"); - - if (message[MXT_MSG_T25_STATUS] == MXT_MSGR_T25_OK) { - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "maXTouch: Self-Test OK\n"); - - } else { - dev_err(&client->dev, - "maXTouch: Self-Test Failed [%02x]:" - "{%02x,%02x,%02x,%02x,%02x}\n", - message[MXT_MSG_T25_STATUS], - message[MXT_MSG_T25_STATUS + 0], - message[MXT_MSG_T25_STATUS + 1], - message[MXT_MSG_T25_STATUS + 2], - message[MXT_MSG_T25_STATUS + 3], - message[MXT_MSG_T25_STATUS + 4] - ); - } - break; - - case MXT_PROCI_TWOTOUCHGESTUREPROCESSOR_T27: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "Receiving 2-touch gesture message\n"); - - event = message[MXT_MSG_T27_STATUS] & 0xF0; - xpos = message[MXT_MSG_T27_XPOSMSB] * 16 + - ((message[MXT_MSG_T27_XYPOSLSB] >> 4) & 0x0F); - ypos = message[MXT_MSG_T27_YPOSMSB] * 16 + - ((message[MXT_MSG_T27_XYPOSLSB] >> 0) & 0x0F); - if (mxt->max_x_val < 1024) - xpos >>= 2; - if (mxt->max_y_val < 1024) - ypos >>= 2; - - direction = message[MXT_MSG_T27_ANGLE]; - distance = message[MXT_MSG_T27_SEPARATION] + - (message[MXT_MSG_T27_SEPARATION + 1] << 16); - - report_gesture((event << 24) | (direction << 16) | distance, - mxt); - report_gesture((xpos << 16) | ypos, mxt); - - - break; - - case MXT_SPT_CTECONFIG_T28: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "Receiving CTE message...\n"); - status = message[MXT_MSG_T28_STATUS]; - if (status & MXT_MSGB_T28_CHKERR) - dev_err(&client->dev, - "maXTouch: Power-Up CRC failure\n"); - - break; - default: - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, - "maXTouch: Unknown message!\n"); - - break; - } - - return 0; -} - - -/* - * Processes messages when the interrupt line (CHG) is asserted. Keeps - * reading messages until a message with report ID 0xFF is received, - * which indicates that there is no more new messages. - * - */ - -static void mxt_worker(struct work_struct *work) -{ - struct mxt_data *mxt; - struct i2c_client *client; - - u8 *message; - u16 message_length; - u16 message_addr; - u8 report_id; - u8 object; - int error; - int i; - char *message_string; - char *message_start; - - message = NULL; - mxt = container_of(work, struct mxt_data, dwork.work); - client = mxt->client; - message_addr = mxt->msg_proc_addr; - message_length = mxt->message_size; - - if (message_length < 256) { - message = kmalloc(message_length, GFP_KERNEL); - if (message == NULL) { - dev_err(&client->dev, "Error allocating memory\n"); - goto fail_worker; - } - } else { - dev_err(&client->dev, - "Message length larger than 256 bytes not supported\n"); - goto fail_worker; - } - - mxt_debug(DEBUG_TRACE, "maXTouch worker active:\n"); - - do { - /* Read next message, reread on failure. */ - /* TODO: message length, CRC included? */ - mxt->message_counter++; - for (i = 1; i < I2C_RETRY_COUNT; i++) { - error = mxt_read_block(client, - message_addr, - message_length - 1, - message); - if (error >= 0) - break; - mxt->read_fail_counter++; - dev_err(&client->dev, - "Failure reading maxTouch device\n"); - } - if (error < 0) { - kfree(message); - goto fail_worker; - } - - if (mxt->address_pointer != message_addr) - mxt->valid_ap = 0; - report_id = message[0]; - - if (debug >= DEBUG_RAW) { - mxt_debug(DEBUG_RAW, "%s message [msg count: %08x]:", - REPORT_ID_TO_OBJECT_NAME(report_id, mxt), - mxt->message_counter - ); - /* 5 characters per one byte */ - message_string = kmalloc(message_length * 5, - GFP_KERNEL); - if (message_string == NULL) { - dev_err(&client->dev, - "Error allocating memory\n"); - kfree(message); - goto fail_worker; - } - message_start = message_string; - for (i = 0; i < message_length; i++) { - message_string += - sprintf(message_string, - "0x%02X ", message[i]); - } - mxt_debug(DEBUG_RAW, "%s", message_start); - kfree(message_start); - } - - if ((report_id != MXT_END_OF_MESSAGES) && (report_id != 0)) { - memcpy(mxt->last_message, message, message_length); - mxt->new_msgs = 1; - smp_wmb(); - /* Get type of object and process the message */ - object = mxt->rid_map[report_id].object; - process_message(message, object, mxt); - } - - mxt_debug(DEBUG_TRACE, "chgline: %d\n", mxt->read_chg()); - } while (comms ? (mxt->read_chg() == 0) : - ((report_id != MXT_END_OF_MESSAGES) && (report_id != 0))); - - /* All messages processed, send the events) */ - process_T9_message(NULL, mxt, 1); - - kfree(message); - -fail_worker: - /* Make sure we just didn't miss a interrupt. */ - if (mxt->read_chg() == 0){ - schedule_delayed_work(&mxt->dwork, 0); - } else - enable_irq(mxt->irq); -} - - -/* - * The maXTouch device will signal the host about a new message by asserting - * the CHG line. This ISR schedules a worker routine to read the message when - * that happens. - */ - -static irqreturn_t mxt_irq_handler(int irq, void *_mxt) -{ - struct mxt_data *mxt = _mxt; - - mxt->irq_counter++; - if (mxt->valid_interrupt()) { - /* Send the signal only if falling edge generated the irq. */ - disable_irq_nosync(mxt->irq); - schedule_delayed_work(&mxt->dwork, 0); - mxt->valid_irq_counter++; - } else { - mxt->invalid_irq_counter++; - return IRQ_NONE; - } - - return IRQ_HANDLED; -} - - - -/******************************************************************************/ -/* Initialization of driver */ -/******************************************************************************/ - -static int mxt_identify(struct i2c_client *client, - struct mxt_data *mxt, - u8 *id_block_data) -{ - u8 buf[MXT_ID_BLOCK_SIZE]; - int error; - int identified; - - identified = 0; - - /* Read Device info to check if chip is valid */ - error = mxt_read_block(client, MXT_ADDR_INFO_BLOCK, MXT_ID_BLOCK_SIZE, - (u8 *) buf); - - if (error < 0) { - mxt->read_fail_counter++; - dev_err(&client->dev, "Failure accessing maXTouch device\n"); - return -EIO; - } - - memcpy(id_block_data, buf, MXT_ID_BLOCK_SIZE); - - mxt->device_info.family_id = buf[0]; - mxt->device_info.variant_id = buf[1]; - mxt->device_info.major = ((buf[2] >> 4) & 0x0F); - mxt->device_info.minor = (buf[2] & 0x0F); - mxt->device_info.build = buf[3]; - mxt->device_info.x_size = buf[4]; - mxt->device_info.y_size = buf[5]; - mxt->device_info.num_objs = buf[6]; - mxt->device_info.num_nodes = mxt->device_info.x_size * - mxt->device_info.y_size; - - /* - * Check Family & Variant Info; warn if not recognized but - * still continue. - */ - - /* MXT224 */ - if (mxt->device_info.family_id == MXT224_FAMILYID) { - strcpy(mxt->device_info.family_name, "mXT224"); - - if (mxt->device_info.variant_id == MXT224_CAL_VARIANTID) { - strcpy(mxt->device_info.variant_name, "Calibrated"); - } else if (mxt->device_info.variant_id == - MXT224_UNCAL_VARIANTID) { - strcpy(mxt->device_info.variant_name, "Uncalibrated"); - } else { - dev_err(&client->dev, - "Warning: maXTouch Variant ID [%d] not " - "supported\n", - mxt->device_info.variant_id); - strcpy(mxt->device_info.variant_name, "UNKNOWN"); - /* identified = -ENXIO; */ - } - - /* MXT1386 */ - } else if (mxt->device_info.family_id == MXT1386_FAMILYID) { - strcpy(mxt->device_info.family_name, "mXT1386"); - - if (mxt->device_info.variant_id == MXT1386_CAL_VARIANTID) { - strcpy(mxt->device_info.variant_name, "Calibrated"); - } else { - dev_err(&client->dev, - "Warning: maXTouch Variant ID [%d] not " - "supported\n", - mxt->device_info.variant_id); - strcpy(mxt->device_info.variant_name, "UNKNOWN"); - /* identified = -ENXIO; */ - } - /* Unknown family ID! */ - } else { - dev_err(&client->dev, - "Warning: maXTouch Family ID [%d] not supported\n", - mxt->device_info.family_id); - strcpy(mxt->device_info.family_name, "UNKNOWN"); - strcpy(mxt->device_info.variant_name, "UNKNOWN"); - /* identified = -ENXIO; */ - } - - dev_info( - &client->dev, - "Atmel maXTouch (Family %s (%X), Variant %s (%X)) Firmware " - "version [%d.%d] Build %d\n", - mxt->device_info.family_name, - mxt->device_info.family_id, - mxt->device_info.variant_name, - mxt->device_info.variant_id, - mxt->device_info.major, - mxt->device_info.minor, - mxt->device_info.build - ); - dev_dbg( - &client->dev, - "Atmel maXTouch Configuration " - "[X: %d] x [Y: %d]\n", - mxt->device_info.x_size, - mxt->device_info.y_size - ); - return identified; -} - -/* - * Reads the object table from maXTouch chip to get object data like - * address, size, report id. For Info Block CRC calculation, already read - * id data is passed to this function too (Info Block consists of the ID - * block and object table). - * - */ -static int mxt_read_object_table(struct i2c_client *client, - struct mxt_data *mxt, - u8 *raw_id_data) -{ - u16 report_id_count; - u8 buf[MXT_OBJECT_TABLE_ELEMENT_SIZE]; - u8 *raw_ib_data; - u8 object_type; - u16 object_address; - u16 object_size; - u8 object_instances; - u8 object_report_ids; - u16 object_info_address; - u32 crc; - u32 calculated_crc; - int i; - int error; - - u8 object_instance; - u8 object_report_id; - u8 report_id; - int first_report_id; - int ib_pointer; - struct mxt_object *object_table; - - mxt_debug(DEBUG_TRACE, "maXTouch driver reading configuration\n"); - - object_table = kzalloc(sizeof(struct mxt_object) * - mxt->device_info.num_objs, - GFP_KERNEL); - if (object_table == NULL) { - printk(KERN_WARNING "maXTouch: Memory allocation failed!\n"); - error = -ENOMEM; - goto err_object_table_alloc; - } - - raw_ib_data = kmalloc(MXT_OBJECT_TABLE_ELEMENT_SIZE * - mxt->device_info.num_objs + MXT_ID_BLOCK_SIZE, - GFP_KERNEL); - if (raw_ib_data == NULL) { - printk(KERN_WARNING "maXTouch: Memory allocation failed!\n"); - error = -ENOMEM; - goto err_ib_alloc; - } - - /* Copy the ID data for CRC calculation. */ - memcpy(raw_ib_data, raw_id_data, MXT_ID_BLOCK_SIZE); - ib_pointer = MXT_ID_BLOCK_SIZE; - - mxt->object_table = object_table; - - mxt_debug(DEBUG_TRACE, "maXTouch driver Memory allocated\n"); - - object_info_address = MXT_ADDR_OBJECT_TABLE; - - report_id_count = 0; - for (i = 0; i < mxt->device_info.num_objs; i++) { - mxt_debug(DEBUG_TRACE, "Reading maXTouch at [0x%04x]: ", - object_info_address); - - error = mxt_read_block(client, object_info_address, - MXT_OBJECT_TABLE_ELEMENT_SIZE, buf); - - if (error < 0) { - mxt->read_fail_counter++; - dev_err(&client->dev, - "maXTouch Object %d could not be read\n", i); - error = -EIO; - goto err_object_read; - } - - memcpy(raw_ib_data + ib_pointer, buf, - MXT_OBJECT_TABLE_ELEMENT_SIZE); - ib_pointer += MXT_OBJECT_TABLE_ELEMENT_SIZE; - - object_type = buf[0]; - object_address = (buf[2] << 8) + buf[1]; - object_size = buf[3] + 1; - object_instances = buf[4] + 1; - object_report_ids = buf[5]; - mxt_debug(DEBUG_TRACE, "Type=%03d, Address=0x%04x, " - "Size=0x%02x, %d instances, %d report id's\n", - object_type, - object_address, - object_size, - object_instances, - object_report_ids - ); - - if (object_type == 38) - t38_size = object_size; - /* TODO: check whether object is known and supported? */ - - /* Save frequently needed info. */ - if (object_type == MXT_GEN_MESSAGEPROCESSOR_T5) { - mxt->msg_proc_addr = object_address; - mxt->message_size = object_size; - } - - object_table[i].type = object_type; - object_table[i].chip_addr = object_address; - object_table[i].size = object_size; - object_table[i].instances = object_instances; - object_table[i].num_report_ids = object_report_ids; - report_id_count += object_instances * object_report_ids; - - object_info_address += MXT_OBJECT_TABLE_ELEMENT_SIZE; - } - - mxt->rid_map = - kzalloc(sizeof(struct report_id_map) * (report_id_count + 1), - /* allocate for report_id 0, even if not used */ - GFP_KERNEL); - if (mxt->rid_map == NULL) { - printk(KERN_WARNING "maXTouch: Can't allocate memory!\n"); - error = -ENOMEM; - goto err_rid_map_alloc; - } - - mxt->messages = kzalloc(mxt->message_size * MXT_MESSAGE_BUFFER_SIZE, - GFP_KERNEL); - if (mxt->messages == NULL) { - printk(KERN_WARNING "maXTouch: Can't allocate memory!\n"); - error = -ENOMEM; - goto err_msg_alloc; - } - - mxt->last_message = kzalloc(mxt->message_size, GFP_KERNEL); - if (mxt->last_message == NULL) { - printk(KERN_WARNING "maXTouch: Can't allocate memory!\n"); - error = -ENOMEM; - goto err_msg_alloc; - } - - mxt->report_id_count = report_id_count; - if (report_id_count > 254) { /* 0 & 255 are reserved */ - dev_err(&client->dev, - "Too many maXTouch report id's [%d]\n", - report_id_count); - error = -ENXIO; - goto err_max_rid; - } - - /* Create a mapping from report id to object type */ - report_id = 1; /* Start from 1, 0 is reserved. */ - - /* Create table associating report id's with objects & instances */ - for (i = 0; i < mxt->device_info.num_objs; i++) { - for (object_instance = 0; - object_instance < object_table[i].instances; - object_instance++){ - first_report_id = report_id; - for (object_report_id = 0; - object_report_id < object_table[i].num_report_ids; - object_report_id++) { - mxt->rid_map[report_id].object = - object_table[i].type; - mxt->rid_map[report_id].instance = - object_instance; - mxt->rid_map[report_id].first_rid = - first_report_id; - report_id++; - } - } - } - - /* Read 3 byte CRC */ - error = mxt_read_block(client, object_info_address, 3, buf); - if (error < 0) { - mxt->read_fail_counter++; - dev_err(&client->dev, "Error reading CRC\n"); - } - - crc = (buf[2] << 16) | (buf[1] << 8) | buf[0]; - - if (calculate_infoblock_crc(&calculated_crc, raw_ib_data, - ib_pointer)) { - printk(KERN_WARNING "Error while calculating CRC!\n"); - calculated_crc = 0; - } - kfree(raw_ib_data); - - mxt_debug(DEBUG_TRACE, "\nReported info block CRC = 0x%6X\n", crc); - mxt_debug(DEBUG_TRACE, "Calculated info block CRC = 0x%6X\n\n", - calculated_crc); - - if (crc == calculated_crc) { - mxt->info_block_crc = crc; - } else { - mxt->info_block_crc = 0; - printk(KERN_ALERT "maXTouch: Info block CRC invalid!\n"); - } - - if (debug >= DEBUG_VERBOSE) { - - dev_info(&client->dev, "maXTouch: %d Objects\n", - mxt->device_info.num_objs); - - for (i = 0; i < mxt->device_info.num_objs; i++) { - dev_info(&client->dev, "Type:\t\t\t[%d]: %s\n", - object_table[i].type, - object_type_name[object_table[i].type]); - dev_info(&client->dev, "\tAddress:\t0x%04X\n", - object_table[i].chip_addr); - dev_info(&client->dev, "\tSize:\t\t%d Bytes\n", - object_table[i].size); - dev_info(&client->dev, "\tInstances:\t%d\n", - object_table[i].instances); - dev_info(&client->dev, "\tReport Id's:\t%d\n", - object_table[i].num_report_ids); - } - } - - return 0; - - -err_max_rid: - kfree(mxt->last_message); -err_msg_alloc: - kfree(mxt->rid_map); -err_rid_map_alloc: -err_object_read: - kfree(raw_ib_data); -err_ib_alloc: - kfree(object_table); -err_object_table_alloc: - return error; -} - -#if defined(CONFIG_PM) -static int mxt_suspend(struct device *dev) -{ - struct mxt_data *mxt = dev_get_drvdata(dev); - int error, i; - u8 t7_deepsl_data[T7_DATA_SIZE]; - u16 t7_addr; - - if (device_may_wakeup(dev)) { - enable_irq_wake(mxt->irq); - return 0; - } - - disable_irq(mxt->irq); - - flush_delayed_work(&mxt->dwork); - - for (i = 0; i < T7_DATA_SIZE; i++) - t7_deepsl_data[i] = 0; - - t7_addr = MXT_BASE_ADDR(MXT_GEN_POWERCONFIG_T7, mxt); - /* save current power state values */ - error = mxt_read_block(mxt->client, t7_addr, - ARRAY_SIZE(mxt->t7_data), mxt->t7_data); - if (error < 0) - goto err_enable_irq; - - /* configure deep sleep mode */ - error = mxt_write_block(mxt->client, t7_addr, - ARRAY_SIZE(t7_deepsl_data), t7_deepsl_data); - if (error < 0) - goto err_enable_irq; - - /* power off the device */ - if (mxt->power_on) { - error = mxt->power_on(false); - if (error) { - dev_err(dev, "power off failed"); - goto err_write_block; - } - } - mxt->is_suspended = true; - return 0; - -err_write_block: - mxt_write_block(mxt->client, t7_addr, - ARRAY_SIZE(mxt->t7_data), mxt->t7_data); -err_enable_irq: - enable_irq(mxt->irq); - return error; -} - -static int mxt_resume(struct device *dev) -{ - struct mxt_data *mxt = dev_get_drvdata(dev); - int error; - u16 t7_addr; - - if (device_may_wakeup(dev)) { - disable_irq_wake(mxt->irq); - return 0; - } - - if (!mxt->is_suspended) - return 0; - - /* power on the device */ - if (mxt->power_on) { - error = mxt->power_on(true); - if (error) { - dev_err(dev, "power on failed"); - return error; - } - } - - t7_addr = MXT_BASE_ADDR(MXT_GEN_POWERCONFIG_T7, mxt); - /* restore the old power state values */ - error = mxt_write_block(mxt->client, t7_addr, - ARRAY_SIZE(mxt->t7_data), mxt->t7_data); - if (error < 0) - goto err_write_block; - - /* Make sure we just didn't miss a interrupt. */ - if (mxt->read_chg() == 0) - schedule_delayed_work(&mxt->dwork, 0); - else - enable_irq(mxt->irq); - - mxt->is_suspended = false; - - return 0; - -err_write_block: - if (mxt->power_on) - mxt->power_on(false); - return error; -} - -#if defined(CONFIG_HAS_EARLYSUSPEND) -static void mxt_early_suspend(struct early_suspend *h) -{ - struct mxt_data *mxt = container_of(h, struct mxt_data, early_suspend); - - mxt_suspend(&mxt->client->dev); -} - -static void mxt_late_resume(struct early_suspend *h) -{ - struct mxt_data *mxt = container_of(h, struct mxt_data, early_suspend); - - mxt_resume(&mxt->client->dev); -} -#endif - -static const struct dev_pm_ops mxt_pm_ops = { -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = mxt_suspend, - .resume = mxt_resume, -#endif -}; -#endif - -static int mxt_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct mxt_data *mxt; - struct maxtouch_platform_data *pdata; - struct input_dev *input; - u8 *id_data; - u8 *t38_data; - u16 t38_addr; - int error; - - mxt_debug(DEBUG_INFO, "mXT224: mxt_probe\n"); - - if (client == NULL) { - pr_debug("maXTouch: client == NULL\n"); - return -EINVAL; - } else if (client->adapter == NULL) { - pr_debug("maXTouch: client->adapter == NULL\n"); - return -EINVAL; - } else if (&client->dev == NULL) { - pr_debug("maXTouch: client->dev == NULL\n"); - return -EINVAL; - } else if (&client->adapter->dev == NULL) { - pr_debug("maXTouch: client->adapter->dev == NULL\n"); - return -EINVAL; - } else if (id == NULL) { - pr_debug("maXTouch: id == NULL\n"); - return -EINVAL; - } - - /* Enable runtime PM ops, start in ACTIVE mode */ - error = pm_runtime_set_active(&client->dev); - if (error < 0) - dev_dbg(&client->dev, "unable to set runtime pm state\n"); - pm_runtime_enable(&client->dev); - - mxt_debug(DEBUG_INFO, "maXTouch driver v. %s\n", DRIVER_VERSION); - mxt_debug(DEBUG_INFO, "\t \"%s\"\n", client->name); - mxt_debug(DEBUG_INFO, "\taddr:\t0x%04x\n", client->addr); - mxt_debug(DEBUG_INFO, "\tirq:\t%d\n", client->irq); - mxt_debug(DEBUG_INFO, "\tflags:\t0x%04x\n", client->flags); - mxt_debug(DEBUG_INFO, "\tadapter:\"%s\"\n", client->adapter->name); - mxt_debug(DEBUG_INFO, "\tdevice:\t\"%s\"\n", client->dev.init_name); - - mxt_debug(DEBUG_TRACE, "maXTouch driver functionality OK\n"); - - /* Allocate structure - we need it to identify device */ - mxt = kzalloc(sizeof(struct mxt_data), GFP_KERNEL); - if (mxt == NULL) { - dev_err(&client->dev, "insufficient memory\n"); - error = -ENOMEM; - goto err_mxt_alloc; - } - - id_data = kmalloc(MXT_ID_BLOCK_SIZE, GFP_KERNEL); - if (id_data == NULL) { - dev_err(&client->dev, "insufficient memory\n"); - error = -ENOMEM; - goto err_id_alloc; - } - - input = input_allocate_device(); - if (!input) { - dev_err(&client->dev, "error allocating input device\n"); - error = -ENOMEM; - goto err_input_dev_alloc; - } - - /* Initialize Platform data */ - - pdata = client->dev.platform_data; - if (pdata == NULL) { - dev_err(&client->dev, "platform data is required!\n"); - error = -EINVAL; - goto err_pdata; - } - if (debug >= DEBUG_TRACE) - printk(KERN_INFO "Platform OK: pdata = 0x%08x\n", - (unsigned int) pdata); - - mxt->is_suspended = false; - mxt->read_fail_counter = 0; - mxt->message_counter = 0; - - if (pdata->min_x) - mxt->min_x_val = pdata->min_x; - else - mxt->min_x_val = 0; - - if (pdata->min_y) - mxt->min_y_val = pdata->min_y; - else - mxt->min_y_val = 0; - - mxt->max_x_val = pdata->max_x; - mxt->max_y_val = pdata->max_y; - - /* Get data that is defined in board specific code. */ - mxt->init_hw = pdata->init_platform_hw; - mxt->exit_hw = pdata->exit_platform_hw; - mxt->power_on = pdata->power_on; - mxt->read_chg = pdata->read_chg; - - if (pdata->valid_interrupt != NULL) - mxt->valid_interrupt = pdata->valid_interrupt; - else - mxt->valid_interrupt = mxt_valid_interrupt_dummy; - - if (mxt->init_hw) { - error = mxt->init_hw(client); - if (error) { - dev_err(&client->dev, "hw init failed"); - goto err_init_hw; - } - } - - /* power on the device */ - if (mxt->power_on) { - error = mxt->power_on(true); - if (error) { - dev_err(&client->dev, "power on failed"); - goto err_pwr_on; - } - } - - if (debug >= DEBUG_TRACE) - printk(KERN_INFO "maXTouch driver identifying chip\n"); - - if (mxt_identify(client, mxt, id_data) < 0) { - dev_err(&client->dev, "Chip could not be identified\n"); - error = -ENODEV; - goto err_identify; - } - /* Chip is valid and active. */ - if (debug >= DEBUG_TRACE) - printk(KERN_INFO "maXTouch driver allocating input device\n"); - - mxt->client = client; - mxt->input = input; - - INIT_DELAYED_WORK(&mxt->dwork, mxt_worker); - mutex_init(&mxt->debug_mutex); - mutex_init(&mxt->msg_mutex); - mxt_debug(DEBUG_TRACE, "maXTouch driver creating device name\n"); - - snprintf( - mxt->phys_name, - sizeof(mxt->phys_name), - "%s/input0", - dev_name(&client->dev) - ); - input->name = "Atmel maXTouch Touchscreen controller"; - input->phys = mxt->phys_name; - input->id.bustype = BUS_I2C; - input->dev.parent = &client->dev; - - mxt_debug(DEBUG_INFO, "maXTouch name: \"%s\"\n", input->name); - mxt_debug(DEBUG_INFO, "maXTouch phys: \"%s\"\n", input->phys); - mxt_debug(DEBUG_INFO, "maXTouch driver setting abs parameters\n"); - - set_bit(BTN_TOUCH, input->keybit); - set_bit(INPUT_PROP_DIRECT, input->propbit); - - /* Single touch */ - input_set_abs_params(input, ABS_X, mxt->min_x_val, - mxt->max_x_val, 0, 0); - input_set_abs_params(input, ABS_Y, mxt->min_y_val, - mxt->max_y_val, 0, 0); - input_set_abs_params(input, ABS_PRESSURE, 0, MXT_MAX_REPORTED_PRESSURE, - 0, 0); - input_set_abs_params(input, ABS_TOOL_WIDTH, 0, MXT_MAX_REPORTED_WIDTH, - 0, 0); - - /* Multitouch */ - input_set_abs_params(input, ABS_MT_POSITION_X, mxt->min_x_val, - mxt->max_x_val, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, mxt->min_y_val, - mxt->max_y_val, 0, 0); - input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, MXT_MAX_TOUCH_SIZE, - 0, 0); - input_set_abs_params(input, ABS_MT_TRACKING_ID, 0, MXT_MAX_NUM_TOUCHES, - 0, 0); - - __set_bit(EV_ABS, input->evbit); - __set_bit(EV_SYN, input->evbit); - __set_bit(EV_KEY, input->evbit); - __set_bit(EV_MSC, input->evbit); - input->mscbit[0] = BIT_MASK(MSC_GESTURE); - - mxt_debug(DEBUG_TRACE, "maXTouch driver setting client data\n"); - i2c_set_clientdata(client, mxt); - mxt_debug(DEBUG_TRACE, "maXTouch driver setting drv data\n"); - input_set_drvdata(input, mxt); - mxt_debug(DEBUG_TRACE, "maXTouch driver input register device\n"); - error = input_register_device(mxt->input); - if (error < 0) { - dev_err(&client->dev, - "Failed to register input device\n"); - goto err_register_device; - } - - error = mxt_read_object_table(client, mxt, id_data); - if (error < 0) - goto err_read_ot; - - - /* Create debugfs entries. */ - mxt->debug_dir = debugfs_create_dir("maXTouch", NULL); - if (mxt->debug_dir == ERR_PTR(-ENODEV)) { - /* debugfs is not enabled. */ - printk(KERN_WARNING "debugfs not enabled in kernel\n"); - } else if (mxt->debug_dir == NULL) { - printk(KERN_WARNING "error creating debugfs dir\n"); - } else { - mxt_debug(DEBUG_TRACE, "created \"maXTouch\" debugfs dir\n"); - - debugfs_create_file("deltas", S_IRUSR, mxt->debug_dir, mxt, - &delta_fops); - debugfs_create_file("refs", S_IRUSR, mxt->debug_dir, mxt, - &refs_fops); - } - - /* Create character device nodes for reading & writing registers */ - mxt->mxt_class = class_create(THIS_MODULE, "maXTouch_memory"); - if (IS_ERR(mxt->mxt_class)){ - printk(KERN_WARNING "class create failed! exiting..."); - goto err_class_create; - - } - /* 2 numbers; one for memory and one for messages */ - error = alloc_chrdev_region(&mxt->dev_num, 0, 2, - "maXTouch_memory"); - mxt_debug(DEBUG_VERBOSE, - "device number %d allocated!\n", MAJOR(mxt->dev_num)); - if (error){ - printk(KERN_WARNING "Error registering device\n"); - } - cdev_init(&mxt->cdev, &mxt_memory_fops); - cdev_init(&mxt->cdev_messages, &mxt_message_fops); - - mxt_debug(DEBUG_VERBOSE, "cdev initialized\n"); - mxt->cdev.owner = THIS_MODULE; - mxt->cdev_messages.owner = THIS_MODULE; - - error = cdev_add(&mxt->cdev, mxt->dev_num, 1); - if (error){ - printk(KERN_WARNING "Bad cdev\n"); - } - - error = cdev_add(&mxt->cdev_messages, mxt->dev_num + 1, 1); - if (error){ - printk(KERN_WARNING "Bad cdev\n"); - } - - mxt_debug(DEBUG_VERBOSE, "cdev added\n"); - - device_create(mxt->mxt_class, NULL, MKDEV(MAJOR(mxt->dev_num), 0), NULL, - "maXTouch"); - - device_create(mxt->mxt_class, NULL, MKDEV(MAJOR(mxt->dev_num), 1), NULL, - "maXTouch_messages"); - - mxt->msg_buffer_startp = 0; - mxt->msg_buffer_endp = 0; - - /* Allocate the interrupt */ - mxt_debug(DEBUG_TRACE, "maXTouch driver allocating interrupt...\n"); - mxt->irq = client->irq; - mxt->valid_irq_counter = 0; - mxt->invalid_irq_counter = 0; - mxt->irq_counter = 0; - if (mxt->irq) { - /* Try to request IRQ with falling edge first. This is - * not always supported. If it fails, try with any edge. */ - error = request_irq(mxt->irq, - mxt_irq_handler, - IRQF_TRIGGER_FALLING, - client->dev.driver->name, - mxt); - if (error < 0) { - /* TODO: why only 0 works on STK1000? */ - error = request_irq(mxt->irq, - mxt_irq_handler, - 0, - client->dev.driver->name, - mxt); - } - - if (error < 0) { - dev_err(&client->dev, - "failed to allocate irq %d\n", mxt->irq); - goto err_irq; - } - } - - if (debug > DEBUG_INFO) - dev_info(&client->dev, "touchscreen, irq %d\n", mxt->irq); - - t38_data = kmalloc(t38_size*sizeof(u8), GFP_KERNEL); - - if (t38_data == NULL) { - dev_err(&client->dev, "insufficient memory\n"); - error = -ENOMEM; - goto err_t38; - } - - t38_addr = MXT_BASE_ADDR(MXT_USER_INFO_T38, mxt); - mxt_read_block(client, t38_addr, t38_size, t38_data); - dev_info(&client->dev, "VERSION:%02x.%02x.%02x, DATE: %d/%d/%d\n", - t38_data[0], t38_data[1], t38_data[2], - t38_data[3], t38_data[4], t38_data[5]); - - /* Schedule a worker routine to read any messages that might have - * been sent before interrupts were enabled. */ - cancel_delayed_work(&mxt->dwork); - disable_irq(mxt->irq); - schedule_delayed_work(&mxt->dwork, 0); - kfree(t38_data); - kfree(id_data); - - device_init_wakeup(&client->dev, pdata->wakeup); -#if defined(CONFIG_HAS_EARLYSUSPEND) - mxt->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + - MXT_SUSPEND_LEVEL; - mxt->early_suspend.suspend = mxt_early_suspend; - mxt->early_suspend.resume = mxt_late_resume; - register_early_suspend(&mxt->early_suspend); -#endif - - return 0; - -err_t38: - free_irq(mxt->irq, mxt); -err_irq: - kfree(mxt->rid_map); - kfree(mxt->object_table); - kfree(mxt->last_message); -err_class_create: - if (mxt->debug_dir) - debugfs_remove(mxt->debug_dir); - kfree(mxt->last_message); - kfree(mxt->rid_map); - kfree(mxt->object_table); -err_read_ot: - input_unregister_device(mxt->input); - mxt->input = NULL; -err_register_device: - mutex_destroy(&mxt->debug_mutex); - mutex_destroy(&mxt->msg_mutex); -err_identify: - if (mxt->power_on) - mxt->power_on(false); -err_pwr_on: - if (mxt->exit_hw != NULL) - mxt->exit_hw(client); -err_init_hw: -err_pdata: - input_free_device(input); -err_input_dev_alloc: - kfree(id_data); -err_id_alloc: - kfree(mxt); -err_mxt_alloc: - pm_runtime_set_suspended(&client->dev); - pm_runtime_disable(&client->dev); - return error; -} - -static int mxt_remove(struct i2c_client *client) -{ - struct mxt_data *mxt; - - pm_runtime_set_suspended(&client->dev); - pm_runtime_disable(&client->dev); - - mxt = i2c_get_clientdata(client); - - /* Remove debug dir entries */ - debugfs_remove_recursive(mxt->debug_dir); - - device_init_wakeup(&client->dev, 0); -#if defined(CONFIG_HAS_EARLYSUSPEND) - unregister_early_suspend(&mxt->early_suspend); -#endif - - if (mxt != NULL) { - if (mxt->power_on) - mxt->power_on(false); - - if (mxt->exit_hw != NULL) - mxt->exit_hw(client); - - if (mxt->irq) { - free_irq(mxt->irq, mxt); - } - - unregister_chrdev_region(mxt->dev_num, 2); - device_destroy(mxt->mxt_class, MKDEV(MAJOR(mxt->dev_num), 0)); - device_destroy(mxt->mxt_class, MKDEV(MAJOR(mxt->dev_num), 1)); - cdev_del(&mxt->cdev); - cdev_del(&mxt->cdev_messages); - cancel_delayed_work_sync(&mxt->dwork); - input_unregister_device(mxt->input); - class_destroy(mxt->mxt_class); - debugfs_remove(mxt->debug_dir); - - kfree(mxt->rid_map); - kfree(mxt->object_table); - kfree(mxt->last_message); - } - kfree(mxt); - - i2c_set_clientdata(client, NULL); - if (debug >= DEBUG_TRACE) - dev_info(&client->dev, "Touchscreen unregistered\n"); - - return 0; -} - -static const struct i2c_device_id mxt_idtable[] = { - {"maXTouch", 0,}, - { } -}; - -MODULE_DEVICE_TABLE(i2c, mxt_idtable); - -static struct i2c_driver mxt_driver = { - .driver = { - .name = "maXTouch", - .owner = THIS_MODULE, -#if defined(CONFIG_PM) - .pm = &mxt_pm_ops, -#endif - }, - - .id_table = mxt_idtable, - .probe = mxt_probe, - .remove = mxt_remove, -}; - -static int __init mxt_init(void) -{ - int err; - err = i2c_add_driver(&mxt_driver); - if (err) { - printk(KERN_WARNING "Adding maXTouch driver failed " - "(errno = %d)\n", err); - } else { - mxt_debug(DEBUG_TRACE, "Successfully added driver %s\n", - mxt_driver.driver.name); - } - return err; -} - -static void __exit mxt_cleanup(void) -{ - i2c_del_driver(&mxt_driver); -} - - -module_init(mxt_init); -module_exit(mxt_cleanup); - -MODULE_AUTHOR("Iiro Valkonen"); -MODULE_DESCRIPTION("Driver for Atmel maXTouch Touchscreen Controller"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/cy8c_tmg_ts.c b/drivers/input/touchscreen/cy8c_tmg_ts.c deleted file mode 100644 index d8ecddb6138b01e5c81f7bed619ffe1f6498b7b1..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/cy8c_tmg_ts.c +++ /dev/null @@ -1,467 +0,0 @@ -/* drivers/input/touchscreen/cy8c_tmg_ts.c - * - * Copyright (C) 2007-2008 HTC Corporation. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#define CY8C_REG_START_NEW_SCAN 0x0F -#define CY8C_REG_INTR_STATUS 0x3C -#define CY8C_REG_VERSION 0x3E - -struct cy8c_ts_data { - struct i2c_client *client; - struct input_dev *input_dev; - int use_irq; - struct hrtimer timer; - struct work_struct work; - uint16_t version; - int (*power) (int on); - struct early_suspend early_suspend; -}; - -struct workqueue_struct *cypress_touch_wq; - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void cy8c_ts_early_suspend(struct early_suspend *h); -static void cy8c_ts_late_resume(struct early_suspend *h); -#endif - -uint16_t sample_count, X_mean, Y_mean, first_touch; - -static s32 cy8c_read_word_data(struct i2c_client *client, - u8 command, uint16_t * data) -{ - s32 ret = i2c_smbus_read_word_data(client, command); - if (ret != -1) { - *data = (u16) ((ret << 8) | (ret >> 8)); - } - return ret; -} - -static int cy8c_init_panel(struct cy8c_ts_data *ts) -{ - int ret; - sample_count = X_mean = Y_mean = first_touch = 0; - - /* clean intr busy */ - ret = i2c_smbus_write_byte_data(ts->client, CY8C_REG_INTR_STATUS, - 0x00); - if (ret < 0) { - dev_err(&ts->client->dev, - "cy8c_init_panel failed for clean intr busy\n"); - goto exit; - } - - /* start new scan */ - ret = i2c_smbus_write_byte_data(ts->client, CY8C_REG_START_NEW_SCAN, - 0x01); - if (ret < 0) { - dev_err(&ts->client->dev, - "cy8c_init_panel failed for start new scan\n"); - goto exit; - } - -exit: - return ret; -} - -static void cy8c_ts_reset(struct i2c_client *client) -{ - struct cy8c_ts_data *ts = i2c_get_clientdata(client); - - if (ts->power) { - ts->power(0); - msleep(10); - ts->power(1); - msleep(10); - } - - cy8c_init_panel(ts); -} - -static void cy8c_ts_work_func(struct work_struct *work) -{ - struct cy8c_ts_data *ts = container_of(work, struct cy8c_ts_data, work); - uint16_t x1, y1, x2, y2; - uint8_t is_touch, start_reg, force, area, finger2_pressed; - uint8_t buf[11]; - struct i2c_msg msg[2]; - int ret = 0; - - x2 = y2 = 0; - - /*printk("%s: enter\n",__func__);*/ - is_touch = i2c_smbus_read_byte_data(ts->client, 0x20); - dev_dbg(&ts->client->dev, "fIsTouch %d,\n", is_touch); - if (is_touch < 0 || is_touch > 3) { - pr_err("%s: invalid is_touch = %d\n", __func__, is_touch); - cy8c_ts_reset(ts->client); - msleep(10); - goto done; - } - - msg[0].addr = ts->client->addr; - msg[0].flags = 0; - msg[0].len = 1; - start_reg = 0x16; - msg[0].buf = &start_reg; - - msg[1].addr = ts->client->addr; - msg[1].flags = I2C_M_RD; - msg[1].len = sizeof(buf); - msg[1].buf = buf; - - ret = i2c_transfer(ts->client->adapter, msg, 2); - if (ret < 0) - goto done; - - /* parse data */ - force = buf[0]; - area = buf[1]; - x1 = (buf[2] << 8) | buf[3]; - y1 = (buf[6] << 8) | buf[7]; - is_touch = buf[10]; - - if (is_touch == 2) { - x2 = (buf[4] << 8) | buf[5]; - y2 = (buf[8] << 8) | buf[9]; - finger2_pressed = 1; - } - - dev_dbg(&ts->client->dev, - "bFingerForce %d, bFingerArea %d \n", force, area); - dev_dbg(&ts->client->dev, "x1: %d, y1: %d \n", x1, y1); - if (finger2_pressed) - dev_dbg(&ts->client->dev, "x2: %d, y2: %d \n", x2, y2); - - /* drop the first one? */ - if ((is_touch == 1) && (first_touch == 0)) { - first_touch = 1; - goto done; - } - - if (!first_touch) - goto done; - - if (is_touch == 2) - finger2_pressed = 1; - - input_report_abs(ts->input_dev, ABS_X, x1); - input_report_abs(ts->input_dev, ABS_Y, y1); - input_report_abs(ts->input_dev, ABS_PRESSURE, force); - input_report_abs(ts->input_dev, ABS_TOOL_WIDTH, area); - input_report_key(ts->input_dev, BTN_TOUCH, is_touch); - input_report_key(ts->input_dev, BTN_2, finger2_pressed); - - if (finger2_pressed) { - input_report_abs(ts->input_dev, ABS_HAT0X, x2); - input_report_abs(ts->input_dev, ABS_HAT0Y, y2); - } - input_sync(ts->input_dev); - -done: - if (is_touch == 0) - first_touch = sample_count = 0; - - /* prepare for next intr */ - i2c_smbus_write_byte_data(ts->client, CY8C_REG_INTR_STATUS, 0x00); - if (!ts->use_irq) - hrtimer_start(&ts->timer, ktime_set(0, 12500000), HRTIMER_MODE_REL); - else - enable_irq(ts->client->irq); -} - -static enum hrtimer_restart cy8c_ts_timer_func(struct hrtimer *timer) -{ - struct cy8c_ts_data *ts; - - ts = container_of(timer, struct cy8c_ts_data, timer); - queue_work(cypress_touch_wq, &ts->work); - return HRTIMER_NORESTART; -} - -static irqreturn_t cy8c_ts_irq_handler(int irq, void *dev_id) -{ - struct cy8c_ts_data *ts = dev_id; - - disable_irq_nosync(ts->client->irq); - queue_work(cypress_touch_wq, &ts->work); - return IRQ_HANDLED; -} - -static int cy8c_ts_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct cy8c_ts_data *ts; - struct cy8c_i2c_platform_data *pdata; - uint16_t panel_version; - int ret = 0; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, "need I2C_FUNC_I2C\n"); - ret = -ENODEV; - goto err_check_functionality_failed; - } - - ts = kzalloc(sizeof(struct cy8c_ts_data), GFP_KERNEL); - if (ts == NULL) { - dev_err(&client->dev, "allocate cy8c_ts_data failed\n"); - ret = -ENOMEM; - goto err_alloc_data_failed; - } - - INIT_WORK(&ts->work, cy8c_ts_work_func); - ts->client = client; - i2c_set_clientdata(client, ts); - - pdata = client->dev.platform_data; - if (pdata) { - ts->version = pdata->version; - ts->power = pdata->power; - } - - if (ts->power) { - ret = ts->power(1); - msleep(10); - if (ret < 0) { - dev_err(&client->dev, "power on failed\n"); - goto err_power_failed; - } - } - - ret = cy8c_read_word_data(ts->client, CY8C_REG_VERSION, &panel_version); - if (ret < 0) { - dev_err(&client->dev, "init panel failed\n"); - goto err_detect_failed; - } - dev_info(&client->dev, "Panel Version %04X\n", panel_version); - if (pdata) { - while (pdata->version > panel_version) { - dev_info(&client->dev, "old tp detected, " - "panel version = %x\n", panel_version); - pdata++; - } - } - - ret = cy8c_init_panel(ts); - if (ret < 0) { - dev_err(&client->dev, "init panel failed\n"); - goto err_detect_failed; - } - - ts->input_dev = input_allocate_device(); - if (ts->input_dev == NULL) { - ret = -ENOMEM; - dev_err(&client->dev, "Failed to allocate input device\n"); - goto err_input_dev_alloc_failed; - } - ts->input_dev->name = "cy8c-touchscreen"; - - set_bit(EV_SYN, ts->input_dev->evbit); - set_bit(EV_ABS, ts->input_dev->evbit); - set_bit(EV_KEY, ts->input_dev->evbit); - input_set_capability(ts->input_dev, EV_KEY, BTN_TOUCH); - input_set_capability(ts->input_dev, EV_KEY, BTN_2); - - input_set_abs_params(ts->input_dev, ABS_X, - pdata->abs_x_min, pdata->abs_x_max, 5, 0); - input_set_abs_params(ts->input_dev, ABS_Y, - pdata->abs_y_min, pdata->abs_y_max, 5, 0); - input_set_abs_params(ts->input_dev, ABS_HAT0X, - pdata->abs_x_min, pdata->abs_x_max, 0, 0); - input_set_abs_params(ts->input_dev, ABS_HAT0Y, - pdata->abs_y_min, pdata->abs_y_max, 0, 0); - input_set_abs_params(ts->input_dev, ABS_PRESSURE, - pdata->abs_pressure_min, pdata->abs_pressure_max, - 0, 0); - input_set_abs_params(ts->input_dev, ABS_TOOL_WIDTH, - pdata->abs_width_min, pdata->abs_width_max, 0, 0); - - ret = input_register_device(ts->input_dev); - if (ret) { - dev_err(&client->dev, - "cy8c_ts_probe: Unable to register %s input device\n", - ts->input_dev->name); - goto err_input_register_device_failed; - } - - if (client->irq) { - ret = request_irq(client->irq, cy8c_ts_irq_handler, - IRQF_TRIGGER_LOW, CYPRESS_TMG_NAME, ts); - if (ret == 0) - ts->use_irq = 1; - else - dev_err(&client->dev, "request_irq failed\n"); - } - - if (!ts->use_irq) { - hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - ts->timer.function = cy8c_ts_timer_func; - hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL); - } - -#ifdef CONFIG_HAS_EARLYSUSPEND - ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; - ts->early_suspend.suspend = cy8c_ts_early_suspend; - ts->early_suspend.resume = cy8c_ts_late_resume; - register_early_suspend(&ts->early_suspend); -#endif - - dev_info(&client->dev, "Start touchscreen %s in %s mode\n", - ts->input_dev->name, (ts->use_irq ? "interrupt" : "polling")); - - return 0; - -err_input_register_device_failed: - input_free_device(ts->input_dev); - -err_input_dev_alloc_failed: - if (ts->power) - ts->power(0); - -err_detect_failed: -err_power_failed: - kfree(ts); - -err_alloc_data_failed: -err_check_functionality_failed: - return ret; -} - -static int cy8c_ts_remove(struct i2c_client *client) -{ - struct cy8c_ts_data *ts = i2c_get_clientdata(client); - - unregister_early_suspend(&ts->early_suspend); - - if (ts->use_irq) - free_irq(client->irq, ts); - else - hrtimer_cancel(&ts->timer); - - input_unregister_device(ts->input_dev); - kfree(ts); - - return 0; -} - -static int cy8c_ts_suspend(struct i2c_client *client, pm_message_t mesg) -{ - struct cy8c_ts_data *ts = i2c_get_clientdata(client); - int ret; - - if (ts->use_irq) - disable_irq_nosync(client->irq); - else - hrtimer_cancel(&ts->timer); - - ret = cancel_work_sync(&ts->work); - if (ret && ts->use_irq) - enable_irq(client->irq); - - if (ts->power) - ts->power(0); - - return 0; -} - -static int cy8c_ts_resume(struct i2c_client *client) -{ - int ret; - struct cy8c_ts_data *ts = i2c_get_clientdata(client); - - if (ts->power) { - ret = ts->power(1); - if (ret < 0) - dev_err(&client->dev, - "cy8c_ts_resume power on failed\n"); - msleep(10); - - cy8c_init_panel(ts); - } - - if (ts->use_irq) - enable_irq(client->irq); - else - hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL); - - return 0; -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void cy8c_ts_early_suspend(struct early_suspend *h) -{ - struct cy8c_ts_data *ts; - ts = container_of(h, struct cy8c_ts_data, early_suspend); - cy8c_ts_suspend(ts->client, PMSG_SUSPEND); -} - -static void cy8c_ts_late_resume(struct early_suspend *h) -{ - struct cy8c_ts_data *ts; - ts = container_of(h, struct cy8c_ts_data, early_suspend); - cy8c_ts_resume(ts->client); -} -#endif - -static const struct i2c_device_id cy8c_ts_i2c_id[] = { - {CYPRESS_TMG_NAME, 0}, - {} -}; - -static struct i2c_driver cy8c_ts_driver = { - .id_table = cy8c_ts_i2c_id, - .probe = cy8c_ts_probe, - .remove = cy8c_ts_remove, -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = cy8c_ts_suspend, - .resume = cy8c_ts_resume, -#endif - .driver = { - .name = CYPRESS_TMG_NAME, - .owner = THIS_MODULE, - }, -}; - -static int cy8c_ts_init(void) -{ - cypress_touch_wq = create_singlethread_workqueue("cypress_touch_wq"); - if (!cypress_touch_wq) - return -ENOMEM; - - return i2c_add_driver(&cy8c_ts_driver); -} - -static void __exit cy8c_ts_exit(void) -{ - if (cypress_touch_wq) - destroy_workqueue(cypress_touch_wq); - - i2c_del_driver(&cy8c_ts_driver); -} - -module_init(cy8c_ts_init); -module_exit(cy8c_ts_exit); - -MODULE_DESCRIPTION("Cypress TMG Touchscreen Driver"); -MODULE_LICENSE("GPL"); - diff --git a/drivers/input/touchscreen/cy8c_ts.c b/drivers/input/touchscreen/cy8c_ts.c deleted file mode 100644 index 1f0c0be3438f9112bbfdf13292276bfd81a496e7..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/cy8c_ts.c +++ /dev/null @@ -1,825 +0,0 @@ -/* Source for: - * Cypress CY8CTMA300 Prototype touchscreen driver. - * drivers/input/touchscreen/cy8c_ts.c - * - * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc. - * Copyright (c) 2010-2012 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Cypress reserves the right to make changes without further notice - * to the materials described herein. Cypress does not assume any - * liability arising out of the application described herein. - * - * Contact Cypress Semiconductor at www.cypress.com - * - * History: - * (C) 2010 Cypress - Update for GPL distribution - * (C) 2009 Cypress - Assume maintenance ownership - * (C) 2009 Enea - Original prototype - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_HAS_EARLYSUSPEND) -#include - -/* Early-suspend level */ -#define CY8C_TS_SUSPEND_LEVEL 1 -#endif - -#define CY8CTMA300 0x0 -#define CY8CTMG200 0x1 -#define CY8CTMA340 0x2 - -#define INVALID_DATA 0xff - -#define TOUCHSCREEN_TIMEOUT (msecs_to_jiffies(10)) -#define INITIAL_DELAY (msecs_to_jiffies(25000)) - -struct cy8c_ts_data { - u8 x_index; - u8 y_index; - u8 z_index; - u8 id_index; - u8 touch_index; - u8 data_reg; - u8 status_reg; - u8 data_size; - u8 touch_bytes; - u8 update_data; - u8 touch_meta_data; - u8 finger_size; -}; - -static struct cy8c_ts_data devices[] = { - [0] = { - .x_index = 6, - .y_index = 4, - .z_index = 3, - .id_index = 0, - .data_reg = 0x3, - .status_reg = 0x1, - .update_data = 0x4, - .touch_bytes = 8, - .touch_meta_data = 3, - .finger_size = 70, - }, - [1] = { - .x_index = 2, - .y_index = 4, - .id_index = 6, - .data_reg = 0x6, - .status_reg = 0x5, - .update_data = 0x1, - .touch_bytes = 12, - .finger_size = 70, - }, - [2] = { - .x_index = 1, - .y_index = 3, - .z_index = 5, - .id_index = 6, - .data_reg = 0x2, - .status_reg = 0, - .update_data = 0x4, - .touch_bytes = 6, - .touch_meta_data = 3, - .finger_size = 70, - }, -}; - -struct cy8c_ts { - struct i2c_client *client; - struct input_dev *input; - struct delayed_work work; - struct workqueue_struct *wq; - struct cy8c_ts_platform_data *pdata; - struct cy8c_ts_data *dd; - u8 *touch_data; - u8 device_id; - u8 prev_touches; - bool is_suspended; - bool int_pending; - struct mutex sus_lock; - u32 pen_irq; -#if defined(CONFIG_HAS_EARLYSUSPEND) - struct early_suspend early_suspend; -#endif -}; - -static inline u16 join_bytes(u8 a, u8 b) -{ - u16 ab = 0; - ab = ab | a; - ab = ab << 8 | b; - return ab; -} - -static s32 cy8c_ts_write_reg_u8(struct i2c_client *client, u8 reg, u8 val) -{ - s32 data; - - data = i2c_smbus_write_byte_data(client, reg, val); - if (data < 0) - dev_err(&client->dev, "error %d in writing reg 0x%x\n", - data, reg); - - return data; -} - -static s32 cy8c_ts_read_reg_u8(struct i2c_client *client, u8 reg) -{ - s32 data; - - data = i2c_smbus_read_byte_data(client, reg); - if (data < 0) - dev_err(&client->dev, "error %d in reading reg 0x%x\n", - data, reg); - - return data; -} - -static int cy8c_ts_read(struct i2c_client *client, u8 reg, u8 *buf, int num) -{ - struct i2c_msg xfer_msg[2]; - - xfer_msg[0].addr = client->addr; - xfer_msg[0].len = 1; - xfer_msg[0].flags = 0; - xfer_msg[0].buf = ® - - xfer_msg[1].addr = client->addr; - xfer_msg[1].len = num; - xfer_msg[1].flags = I2C_M_RD; - xfer_msg[1].buf = buf; - - return i2c_transfer(client->adapter, xfer_msg, 2); -} - -static void report_data(struct cy8c_ts *ts, u16 x, u16 y, u8 pressure, u8 id) -{ - if (ts->pdata->swap_xy) - swap(x, y); - - /* handle inverting coordinates */ - if (ts->pdata->invert_x) - x = ts->pdata->res_x - x; - if (ts->pdata->invert_y) - y = ts->pdata->res_y - y; - - input_report_abs(ts->input, ABS_MT_TRACKING_ID, id); - input_report_abs(ts->input, ABS_MT_POSITION_X, x); - input_report_abs(ts->input, ABS_MT_POSITION_Y, y); - input_report_abs(ts->input, ABS_MT_PRESSURE, pressure); - input_mt_sync(ts->input); -} - -static void process_tma300_data(struct cy8c_ts *ts) -{ - u8 id, pressure, touches, i; - u16 x, y; - - touches = ts->touch_data[ts->dd->touch_index]; - - for (i = 0; i < touches; i++) { - id = ts->touch_data[i * ts->dd->touch_bytes + - ts->dd->id_index]; - pressure = ts->touch_data[i * ts->dd->touch_bytes + - ts->dd->z_index]; - x = join_bytes(ts->touch_data[i * ts->dd->touch_bytes + - ts->dd->x_index], - ts->touch_data[i * ts->dd->touch_bytes + - ts->dd->x_index + 1]); - y = join_bytes(ts->touch_data[i * ts->dd->touch_bytes + - ts->dd->y_index], - ts->touch_data[i * ts->dd->touch_bytes + - ts->dd->y_index + 1]); - - report_data(ts, x, y, pressure, id); - } - - for (i = 0; i < ts->prev_touches - touches; i++) { - input_report_abs(ts->input, ABS_MT_PRESSURE, 0); - input_mt_sync(ts->input); - } - - ts->prev_touches = touches; - input_sync(ts->input); -} - -static void process_tmg200_data(struct cy8c_ts *ts) -{ - u8 id, touches, i; - u16 x, y; - - touches = ts->touch_data[ts->dd->touch_index]; - - if (touches > 0) { - x = join_bytes(ts->touch_data[ts->dd->x_index], - ts->touch_data[ts->dd->x_index+1]); - y = join_bytes(ts->touch_data[ts->dd->y_index], - ts->touch_data[ts->dd->y_index+1]); - id = ts->touch_data[ts->dd->id_index]; - - report_data(ts, x, y, 255, id - 1); - - if (touches == 2) { - x = join_bytes(ts->touch_data[ts->dd->x_index+5], - ts->touch_data[ts->dd->x_index+6]); - y = join_bytes(ts->touch_data[ts->dd->y_index+5], - ts->touch_data[ts->dd->y_index+6]); - id = ts->touch_data[ts->dd->id_index+5]; - - report_data(ts, x, y, 255, id - 1); - } - } else { - for (i = 0; i < ts->prev_touches; i++) { - input_report_abs(ts->input, ABS_MT_PRESSURE, 0); - input_mt_sync(ts->input); - } - } - - input_sync(ts->input); - ts->prev_touches = touches; -} - -static void cy8c_ts_xy_worker(struct work_struct *work) -{ - int rc; - struct cy8c_ts *ts = container_of(work, struct cy8c_ts, - work.work); - - mutex_lock(&ts->sus_lock); - if (ts->is_suspended == true) { - dev_dbg(&ts->client->dev, "TS is supended\n"); - ts->int_pending = true; - mutex_unlock(&ts->sus_lock); - return; - } - mutex_unlock(&ts->sus_lock); - - /* read data from DATA_REG */ - rc = cy8c_ts_read(ts->client, ts->dd->data_reg, ts->touch_data, - ts->dd->data_size); - if (rc < 0) { - dev_err(&ts->client->dev, "read failed\n"); - goto schedule; - } - - if (ts->touch_data[ts->dd->touch_index] == INVALID_DATA) - goto schedule; - - if ((ts->device_id == CY8CTMA300) || (ts->device_id == CY8CTMA340)) - process_tma300_data(ts); - else - process_tmg200_data(ts); - -schedule: - enable_irq(ts->pen_irq); - - /* write to STATUS_REG to update coordinates*/ - rc = cy8c_ts_write_reg_u8(ts->client, ts->dd->status_reg, - ts->dd->update_data); - if (rc < 0) { - dev_err(&ts->client->dev, "write failed, try once more\n"); - - rc = cy8c_ts_write_reg_u8(ts->client, ts->dd->status_reg, - ts->dd->update_data); - if (rc < 0) - dev_err(&ts->client->dev, "write failed, exiting\n"); - } -} - -static irqreturn_t cy8c_ts_irq(int irq, void *dev_id) -{ - struct cy8c_ts *ts = dev_id; - - disable_irq_nosync(irq); - - queue_delayed_work(ts->wq, &ts->work, 0); - - return IRQ_HANDLED; -} - -static int cy8c_ts_init_ts(struct i2c_client *client, struct cy8c_ts *ts) -{ - struct input_dev *input_device; - int rc = 0; - - ts->dd = &devices[ts->device_id]; - - if (!ts->pdata->nfingers) { - dev_err(&client->dev, "Touches information not specified\n"); - return -EINVAL; - } - - if (ts->device_id == CY8CTMA300) { - if (ts->pdata->nfingers > 10) { - dev_err(&client->dev, "Touches >=1 & <= 10\n"); - return -EINVAL; - } - ts->dd->data_size = ts->pdata->nfingers * ts->dd->touch_bytes + - ts->dd->touch_meta_data; - ts->dd->touch_index = ts->pdata->nfingers * - ts->dd->touch_bytes; - } else if (ts->device_id == CY8CTMG200) { - if (ts->pdata->nfingers > 2) { - dev_err(&client->dev, "Touches >=1 & <= 2\n"); - return -EINVAL; - } - ts->dd->data_size = ts->dd->touch_bytes; - ts->dd->touch_index = 0x0; - } else if (ts->device_id == CY8CTMA340) { - if (ts->pdata->nfingers > 10) { - dev_err(&client->dev, "Touches >=1 & <= 10\n"); - return -EINVAL; - } - ts->dd->data_size = ts->pdata->nfingers * ts->dd->touch_bytes + - ts->dd->touch_meta_data; - ts->dd->touch_index = 0x0; - } - - ts->touch_data = kzalloc(ts->dd->data_size, GFP_KERNEL); - if (!ts->touch_data) { - pr_err("%s: Unable to allocate memory\n", __func__); - return -ENOMEM; - } - - ts->prev_touches = 0; - - input_device = input_allocate_device(); - if (!input_device) { - rc = -ENOMEM; - goto error_alloc_dev; - } - - ts->input = input_device; - input_device->name = ts->pdata->ts_name; - input_device->id.bustype = BUS_I2C; - input_device->dev.parent = &client->dev; - input_set_drvdata(input_device, ts); - - __set_bit(EV_ABS, input_device->evbit); - __set_bit(INPUT_PROP_DIRECT, input_device->propbit); - - if (ts->device_id == CY8CTMA340) { - /* set up virtual key */ - __set_bit(EV_KEY, input_device->evbit); - /* set dummy key to make driver work with virtual keys */ - input_set_capability(input_device, EV_KEY, KEY_PROG1); - } - - input_set_abs_params(input_device, ABS_MT_POSITION_X, - ts->pdata->dis_min_x, ts->pdata->dis_max_x, 0, 0); - input_set_abs_params(input_device, ABS_MT_POSITION_Y, - ts->pdata->dis_min_y, ts->pdata->dis_max_y, 0, 0); - input_set_abs_params(input_device, ABS_MT_PRESSURE, - ts->pdata->min_touch, ts->pdata->max_touch, 0, 0); - input_set_abs_params(input_device, ABS_MT_TRACKING_ID, - ts->pdata->min_tid, ts->pdata->max_tid, 0, 0); - - ts->wq = create_singlethread_workqueue("kworkqueue_ts"); - if (!ts->wq) { - dev_err(&client->dev, "Could not create workqueue\n"); - goto error_wq_create; - } - - INIT_DELAYED_WORK(&ts->work, cy8c_ts_xy_worker); - - rc = input_register_device(input_device); - if (rc) - goto error_unreg_device; - - return 0; - -error_unreg_device: - destroy_workqueue(ts->wq); -error_wq_create: - input_free_device(input_device); -error_alloc_dev: - kfree(ts->touch_data); - return rc; -} - -#ifdef CONFIG_PM -static int cy8c_ts_suspend(struct device *dev) -{ - struct cy8c_ts *ts = dev_get_drvdata(dev); - int rc = 0; - - if (device_may_wakeup(dev)) { - /* mark suspend flag */ - mutex_lock(&ts->sus_lock); - ts->is_suspended = true; - mutex_unlock(&ts->sus_lock); - - enable_irq_wake(ts->pen_irq); - } else { - disable_irq_nosync(ts->pen_irq); - - rc = cancel_delayed_work_sync(&ts->work); - - if (rc) { - /* missed the worker, write to STATUS_REG to - acknowledge interrupt */ - rc = cy8c_ts_write_reg_u8(ts->client, - ts->dd->status_reg, ts->dd->update_data); - if (rc < 0) { - dev_err(&ts->client->dev, - "write failed, try once more\n"); - - rc = cy8c_ts_write_reg_u8(ts->client, - ts->dd->status_reg, - ts->dd->update_data); - if (rc < 0) - dev_err(&ts->client->dev, - "write failed, exiting\n"); - } - - enable_irq(ts->pen_irq); - } - - gpio_free(ts->pdata->irq_gpio); - - if (ts->pdata->power_on) { - rc = ts->pdata->power_on(0); - if (rc) { - dev_err(dev, "unable to goto suspend\n"); - return rc; - } - } - } - return 0; -} - -static int cy8c_ts_resume(struct device *dev) -{ - struct cy8c_ts *ts = dev_get_drvdata(dev); - int rc = 0; - - if (device_may_wakeup(dev)) { - disable_irq_wake(ts->pen_irq); - - mutex_lock(&ts->sus_lock); - ts->is_suspended = false; - - if (ts->int_pending == true) { - ts->int_pending = false; - - /* start a delayed work */ - queue_delayed_work(ts->wq, &ts->work, 0); - } - mutex_unlock(&ts->sus_lock); - - } else { - if (ts->pdata->power_on) { - rc = ts->pdata->power_on(1); - if (rc) { - dev_err(dev, "unable to resume\n"); - return rc; - } - } - - /* configure touchscreen interrupt gpio */ - rc = gpio_request(ts->pdata->irq_gpio, "cy8c_irq_gpio"); - if (rc) { - pr_err("%s: unable to request gpio %d\n", - __func__, ts->pdata->irq_gpio); - goto err_power_off; - } - - rc = gpio_direction_input(ts->pdata->irq_gpio); - if (rc) { - pr_err("%s: unable to set direction for gpio %d\n", - __func__, ts->pdata->irq_gpio); - goto err_gpio_free; - } - - enable_irq(ts->pen_irq); - - /* Clear the status register of the TS controller */ - rc = cy8c_ts_write_reg_u8(ts->client, - ts->dd->status_reg, ts->dd->update_data); - if (rc < 0) { - dev_err(&ts->client->dev, - "write failed, try once more\n"); - - rc = cy8c_ts_write_reg_u8(ts->client, - ts->dd->status_reg, - ts->dd->update_data); - if (rc < 0) - dev_err(&ts->client->dev, - "write failed, exiting\n"); - } - } - return 0; -err_gpio_free: - gpio_free(ts->pdata->irq_gpio); -err_power_off: - if (ts->pdata->power_on) - rc = ts->pdata->power_on(0); - return rc; -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void cy8c_ts_early_suspend(struct early_suspend *h) -{ - struct cy8c_ts *ts = container_of(h, struct cy8c_ts, early_suspend); - - cy8c_ts_suspend(&ts->client->dev); -} - -static void cy8c_ts_late_resume(struct early_suspend *h) -{ - struct cy8c_ts *ts = container_of(h, struct cy8c_ts, early_suspend); - - cy8c_ts_resume(&ts->client->dev); -} -#endif - -static struct dev_pm_ops cy8c_ts_pm_ops = { -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = cy8c_ts_suspend, - .resume = cy8c_ts_resume, -#endif -}; -#endif - -static int cy8c_ts_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct cy8c_ts *ts; - struct cy8c_ts_platform_data *pdata = client->dev.platform_data; - int rc, temp_reg; - - if (!pdata) { - dev_err(&client->dev, "platform data is required!\n"); - return -EINVAL; - } - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - dev_err(&client->dev, "I2C functionality not supported\n"); - return -EIO; - } - - ts = kzalloc(sizeof(*ts), GFP_KERNEL); - if (!ts) - return -ENOMEM; - - /* Enable runtime PM ops, start in ACTIVE mode */ - rc = pm_runtime_set_active(&client->dev); - if (rc < 0) - dev_dbg(&client->dev, "unable to set runtime pm state\n"); - pm_runtime_enable(&client->dev); - - ts->client = client; - ts->pdata = pdata; - i2c_set_clientdata(client, ts); - ts->device_id = id->driver_data; - - if (ts->pdata->dev_setup) { - rc = ts->pdata->dev_setup(1); - if (rc < 0) { - dev_err(&client->dev, "dev setup failed\n"); - goto error_touch_data_alloc; - } - } - - /* power on the device */ - if (ts->pdata->power_on) { - rc = ts->pdata->power_on(1); - if (rc) { - pr_err("%s: Unable to power on the device\n", __func__); - goto error_dev_setup; - } - } - - /* read one byte to make sure i2c device exists */ - if (id->driver_data == CY8CTMA300) - temp_reg = 0x01; - else if (id->driver_data == CY8CTMA340) - temp_reg = 0x00; - else - temp_reg = 0x05; - - rc = cy8c_ts_read_reg_u8(client, temp_reg); - if (rc < 0) { - dev_err(&client->dev, "i2c sanity check failed\n"); - goto error_power_on; - } - - ts->is_suspended = false; - ts->int_pending = false; - mutex_init(&ts->sus_lock); - - rc = cy8c_ts_init_ts(client, ts); - if (rc < 0) { - dev_err(&client->dev, "CY8CTMG200-TMA300 init failed\n"); - goto error_mutex_destroy; - } - - if (ts->pdata->resout_gpio < 0) - goto config_irq_gpio; - - /* configure touchscreen reset out gpio */ - rc = gpio_request(ts->pdata->resout_gpio, "cy8c_resout_gpio"); - if (rc) { - pr_err("%s: unable to request gpio %d\n", - __func__, ts->pdata->resout_gpio); - goto error_uninit_ts; - } - - rc = gpio_direction_output(ts->pdata->resout_gpio, 0); - if (rc) { - pr_err("%s: unable to set direction for gpio %d\n", - __func__, ts->pdata->resout_gpio); - goto error_resout_gpio_dir; - } - /* reset gpio stabilization time */ - msleep(20); - -config_irq_gpio: - /* configure touchscreen interrupt gpio */ - rc = gpio_request(ts->pdata->irq_gpio, "cy8c_irq_gpio"); - if (rc) { - pr_err("%s: unable to request gpio %d\n", - __func__, ts->pdata->irq_gpio); - goto error_irq_gpio_req; - } - - rc = gpio_direction_input(ts->pdata->irq_gpio); - if (rc) { - pr_err("%s: unable to set direction for gpio %d\n", - __func__, ts->pdata->irq_gpio); - goto error_irq_gpio_dir; - } - - ts->pen_irq = gpio_to_irq(ts->pdata->irq_gpio); - rc = request_irq(ts->pen_irq, cy8c_ts_irq, - IRQF_TRIGGER_FALLING, - ts->client->dev.driver->name, ts); - if (rc) { - dev_err(&ts->client->dev, "could not request irq\n"); - goto error_req_irq_fail; - } - - /* Clear the status register of the TS controller */ - rc = cy8c_ts_write_reg_u8(ts->client, ts->dd->status_reg, - ts->dd->update_data); - if (rc < 0) { - /* Do multiple writes in case of failure */ - dev_err(&ts->client->dev, "%s: write failed %d" - "trying again\n", __func__, rc); - rc = cy8c_ts_write_reg_u8(ts->client, - ts->dd->status_reg, ts->dd->update_data); - if (rc < 0) { - dev_err(&ts->client->dev, "%s: write failed" - "second time(%d)\n", __func__, rc); - } - } - - device_init_wakeup(&client->dev, ts->pdata->wakeup); - -#ifdef CONFIG_HAS_EARLYSUSPEND - ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + - CY8C_TS_SUSPEND_LEVEL; - ts->early_suspend.suspend = cy8c_ts_early_suspend; - ts->early_suspend.resume = cy8c_ts_late_resume; - register_early_suspend(&ts->early_suspend); -#endif - - return 0; -error_req_irq_fail: -error_irq_gpio_dir: - gpio_free(ts->pdata->irq_gpio); -error_irq_gpio_req: -error_resout_gpio_dir: - if (ts->pdata->resout_gpio >= 0) - gpio_free(ts->pdata->resout_gpio); -error_uninit_ts: - destroy_workqueue(ts->wq); - input_unregister_device(ts->input); - kfree(ts->touch_data); -error_mutex_destroy: - mutex_destroy(&ts->sus_lock); -error_power_on: - if (ts->pdata->power_on) - ts->pdata->power_on(0); -error_dev_setup: - if (ts->pdata->dev_setup) - ts->pdata->dev_setup(0); -error_touch_data_alloc: - pm_runtime_set_suspended(&client->dev); - pm_runtime_disable(&client->dev); - kfree(ts); - return rc; -} - -static int cy8c_ts_remove(struct i2c_client *client) -{ - struct cy8c_ts *ts = i2c_get_clientdata(client); - -#if defined(CONFIG_HAS_EARLYSUSPEND) - unregister_early_suspend(&ts->early_suspend); -#endif - pm_runtime_set_suspended(&client->dev); - pm_runtime_disable(&client->dev); - - device_init_wakeup(&client->dev, 0); - - cancel_delayed_work_sync(&ts->work); - - free_irq(ts->pen_irq, ts); - - gpio_free(ts->pdata->irq_gpio); - - if (ts->pdata->resout_gpio >= 0) - gpio_free(ts->pdata->resout_gpio); - - destroy_workqueue(ts->wq); - - input_unregister_device(ts->input); - - mutex_destroy(&ts->sus_lock); - - if (ts->pdata->power_on) - ts->pdata->power_on(0); - - if (ts->pdata->dev_setup) - ts->pdata->dev_setup(0); - - kfree(ts->touch_data); - kfree(ts); - - return 0; -} - -static const struct i2c_device_id cy8c_ts_id[] = { - {"cy8ctma300", CY8CTMA300}, - {"cy8ctmg200", CY8CTMG200}, - {"cy8ctma340", CY8CTMA340}, - {} -}; -MODULE_DEVICE_TABLE(i2c, cy8c_ts_id); - - -static struct i2c_driver cy8c_ts_driver = { - .driver = { - .name = "cy8c_ts", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &cy8c_ts_pm_ops, -#endif - }, - .probe = cy8c_ts_probe, - .remove = cy8c_ts_remove, - .id_table = cy8c_ts_id, -}; - -static int __init cy8c_ts_init(void) -{ - return i2c_add_driver(&cy8c_ts_driver); -} -/* Making this as late init to avoid power fluctuations - * during LCD initialization. - */ -late_initcall(cy8c_ts_init); - -static void __exit cy8c_ts_exit(void) -{ - return i2c_del_driver(&cy8c_ts_driver); -} -module_exit(cy8c_ts_exit); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("CY8CTMA340-CY8CTMG200 touchscreen controller driver"); -MODULE_AUTHOR("Cypress"); -MODULE_ALIAS("platform:cy8c_ts"); diff --git a/drivers/input/touchscreen/cyttsp-i2c-qc.c b/drivers/input/touchscreen/cyttsp-i2c-qc.c deleted file mode 100644 index f7439789efe8dcffb72f82bb0fcfd53638317bfa..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/cyttsp-i2c-qc.c +++ /dev/null @@ -1,3172 +0,0 @@ -/* Source for: - * Cypress TrueTouch(TM) Standard Product I2C touchscreen driver. - * drivers/input/touchscreen/cyttsp-i2c.c - * - * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc. - * - * 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Cypress reserves the right to make changes without further notice - * to the materials described herein. Cypress does not assume any - * liability arising out of the application described herein. - * - * Contact Cypress Semiconductor at www.cypress.com - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_HAS_EARLYSUSPEND -#include -#endif /* CONFIG_HAS_EARLYSUSPEND */ - -#define CY_DECLARE_GLOBALS - -#include - -uint32_t cyttsp_tsdebug1 = 0xff; -module_param_named(tsdebug1, cyttsp_tsdebug1, uint, 0664); - -#define FW_FNAME_LEN 40 -#define TTSP_BUFF_SIZE 50 - -/* CY TTSP I2C Driver private data */ -struct cyttsp { - struct i2c_client *client; - struct input_dev *input; - struct timer_list timer; - struct mutex mutex; - char phys[32]; - struct cyttsp_platform_data *platform_data; - u8 num_prv_st_tch; - u16 fw_start_addr; - u16 act_trk[CY_NUM_TRK_ID]; - u16 prv_st_tch[CY_NUM_ST_TCH_ID]; - u16 prv_mt_tch[CY_NUM_MT_TCH_ID]; - u16 prv_mt_pos[CY_NUM_TRK_ID][2]; - atomic_t irq_enabled; - bool cyttsp_update_fw; - bool cyttsp_fwloader_mode; - bool is_suspended; - struct regulator **vdd; - struct dentry *dir; - char fw_fname[FW_FNAME_LEN]; -#ifdef CONFIG_HAS_EARLYSUSPEND - struct early_suspend early_suspend; -#endif /* CONFIG_HAS_EARLYSUSPEND */ -}; -static u8 irq_cnt; /* comparison counter with register valuw */ -static u32 irq_cnt_total; /* total interrupts */ -static u32 irq_err_cnt; /* count number of touch interrupts with err */ -#define CY_IRQ_CNT_MASK 0x000000FF /* mapped for sizeof count in reg */ -#define CY_IRQ_CNT_REG 0x00 /* tt_undef[0]=reg 0x1B - Gen3 only */ - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void cyttsp_early_suspend(struct early_suspend *handler); -static void cyttsp_late_resume(struct early_suspend *handler); -#endif /* CONFIG_HAS_EARLYSUSPEND */ - -#define CYTTSP_DEBUG_DIR_NAME "ts_debug" - -/* **************************************************************************** - * Prototypes for static functions - * ************************************************************************** */ -static irqreturn_t cyttsp_irq(int irq, void *handle); -static int cyttsp_inlist(u16 prev_track[], - u8 cur_trk_id, u8 *prev_loc, u8 num_touches); -static int cyttsp_next_avail_inlist(u16 cur_trk[], - u8 *new_loc, u8 num_touches); -static int cyttsp_putbl(struct cyttsp *ts, int show, - int show_status, int show_version, int show_cid); -static int cyttsp_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int cyttsp_remove(struct i2c_client *client); -static int cyttsp_resume(struct device *dev); -static int cyttsp_suspend(struct device *dev); - -/* Static variables */ -static struct cyttsp_gen3_xydata_t g_xy_data; -static struct cyttsp_bootloader_data_t g_bl_data; -static struct cyttsp_sysinfo_data_t g_sysinfo_data; -static const struct i2c_device_id cyttsp_id[] = { - { CY_I2C_NAME, 0 }, { } -}; -static u8 bl_cmd[] = { - CY_BL_FILE0, CY_BL_CMD, CY_BL_EXIT, - CY_BL_KEY0, CY_BL_KEY1, CY_BL_KEY2, - CY_BL_KEY3, CY_BL_KEY4, CY_BL_KEY5, - CY_BL_KEY6, CY_BL_KEY7}; - -MODULE_DEVICE_TABLE(i2c, cyttsp_id); - -#ifdef CONFIG_PM -static const struct dev_pm_ops cyttsp_pm_ops = { -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = cyttsp_suspend, - .resume = cyttsp_resume, -#endif -}; -#endif - -static struct i2c_driver cyttsp_driver = { - .driver = { - .name = CY_I2C_NAME, - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &cyttsp_pm_ops, -#endif - }, - .probe = cyttsp_probe, - .remove = cyttsp_remove, - .id_table = cyttsp_id, -}; - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard touchscreen driver"); -MODULE_AUTHOR("Cypress"); - -static ssize_t cyttsp_irq_status(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - struct cyttsp *ts = i2c_get_clientdata(client); - return snprintf(buf, TTSP_BUFF_SIZE, "%u\n", - atomic_read(&ts->irq_enabled)); -} - -static ssize_t cyttsp_irq_enable(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - struct cyttsp *ts = i2c_get_clientdata(client); - int err = 0; - unsigned long value; - - if (size > 2) - return -EINVAL; - - err = strict_strtoul(buf, 10, &value); - if (err != 0) - return err; - - switch (value) { - case 0: - if (atomic_cmpxchg(&ts->irq_enabled, 1, 0)) { - pr_info("touch irq disabled!\n"); - disable_irq_nosync(ts->client->irq); - } - err = size; - break; - case 1: - if (!atomic_cmpxchg(&ts->irq_enabled, 0, 1)) { - pr_info("touch irq enabled!\n"); - enable_irq(ts->client->irq); - } - err = size; - break; - default: - pr_info("cyttsp_irq_enable failed -> irq_enabled = %d\n", - atomic_read(&ts->irq_enabled)); - err = -EINVAL; - break; - } - - return err; -} - -static DEVICE_ATTR(irq_enable, 0664, cyttsp_irq_status, cyttsp_irq_enable); - -static ssize_t cyttsp_fw_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return snprintf(buf, TTSP_BUFF_SIZE, "%d.%d.%d\n", g_bl_data.appid_lo, - g_bl_data.appver_hi, g_bl_data.appver_lo); -} - -static DEVICE_ATTR(cyttsp_fw_ver, 0664, cyttsp_fw_show, NULL); - -/* firmware flashing block */ -#define BLK_SIZE 16 -#define DATA_REC_LEN 64 -#define BLK_SEED 0xff -#define RECAL_REG 0x1b - -enum bl_commands { - BL_CMD_WRBLK = 0x39, - BL_CMD_INIT = 0x38, - BL_CMD_TERMINATE = 0x3b, -}; -/* TODO: Add key as part of platform data */ -#define KEY_CS (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7) -#define KEY {0, 1, 2, 3, 4, 5, 6, 7} - -static const char _key[] = KEY; -#define KEY_LEN sizeof(_key) - -static int rec_cnt; -struct fw_record { - u8 seed; - u8 cmd; - u8 key[KEY_LEN]; - u8 blk_hi; - u8 blk_lo; - u8 data[DATA_REC_LEN]; - u8 data_cs; - u8 rec_cs; -}; -#define fw_rec_size (sizeof(struct fw_record)) - -struct cmd_record { - u8 reg; - u8 seed; - u8 cmd; - u8 key[KEY_LEN]; -}; -#define cmd_rec_size (sizeof(struct cmd_record)) - -static struct fw_record data_record = { - .seed = BLK_SEED, - .cmd = BL_CMD_WRBLK, - .key = KEY, -}; - -static const struct cmd_record terminate_rec = { - .reg = 0, - .seed = BLK_SEED, - .cmd = BL_CMD_TERMINATE, - .key = KEY, -}; -static const struct cmd_record initiate_rec = { - .reg = 0, - .seed = BLK_SEED, - .cmd = BL_CMD_INIT, - .key = KEY, -}; - -#define BL_REC1_ADDR 0x0780 -#define BL_REC2_ADDR 0x07c0 -#define BL_CHECKSUM_MASK 0x01 - -#define ID_INFO_REC ":40078000" -#define ID_INFO_OFFSET_IN_REC 77 - -#define REC_START_CHR ':' -#define REC_LEN_OFFSET 1 -#define REC_ADDR_HI_OFFSET 3 -#define REC_ADDR_LO_OFFSET 5 -#define REC_TYPE_OFFSET 7 -#define REC_DATA_OFFSET 9 -#define REC_LINE_SIZE 141 - -#define NUM_CHAR_IN_HEX 2 -#define ID_INFO_REC_LEN 9 - -static int cyttsp_soft_reset(struct cyttsp *ts) -{ - int retval = 0, tries = 0; - u8 host_reg = CY_SOFT_RESET_MODE; - - do { - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, sizeof(host_reg), &host_reg); - if (retval < 0) - msleep(20); - } while (tries++ < 10 && (retval < 0)); - - if (retval < 0) { - pr_err("%s: failed\n", __func__); - return retval; - } - - tries = 0; - do { - msleep(20); - cyttsp_putbl(ts, 1, true, true, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - - if (g_bl_data.bl_status != 0x11 && g_bl_data.bl_status != 0x10) - return -EINVAL; - - return 0; -} - -static void cyttsp_exit_bl_mode(struct cyttsp *ts) -{ - int retval, tries = 0; - - do { - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, sizeof(bl_cmd), bl_cmd); - if (retval < 0) - msleep(20); - } while (tries++ < 10 && (retval < 0)); -} - -static void cyttsp_set_sysinfo_mode(struct cyttsp *ts) -{ - int retval, tries = 0; - u8 host_reg = CY_SYSINFO_MODE; - - do { - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, sizeof(host_reg), &host_reg); - if (retval < 0) - msleep(20); - } while (tries++ < 10 && (retval < 0)); - - /* wait for TTSP Device to complete switch to SysInfo mode */ - if (!(retval < 0)) { - retval = i2c_smbus_read_i2c_block_data(ts->client, - CY_REG_BASE, - sizeof(struct cyttsp_sysinfo_data_t), - (u8 *)&g_sysinfo_data); - } else - pr_err("%s: failed\n", __func__); -} - -static void cyttsp_set_opmode(struct cyttsp *ts) -{ - int retval, tries = 0; - u8 host_reg = CY_OP_MODE; - - do { - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, sizeof(host_reg), &host_reg); - if (retval < 0) - msleep(20); - } while (tries++ < 10 && (retval < 0)); -} - -static int str2uc(char *str, u8 *val) -{ - char substr[3]; - unsigned long ulval; - int rc; - - if (!str) - return -EINVAL; - - if (strnlen(str, NUM_CHAR_IN_HEX) < 2) - return -EINVAL; - - substr[0] = str[0]; - substr[1] = str[1]; - substr[2] = '\0'; - - rc = strict_strtoul(substr, 16, &ulval); - if (rc != 0) - return rc; - - *val = (u8) ulval; - - return 0; -} - -static int flash_block(struct cyttsp *ts, u8 *blk, int len) -{ - int retval, i, tries = 0; - char buf[(2 * (BLK_SIZE + 1)) + 1]; - char *p = buf; - - for (i = 0; i < len; i++, p += 2) - snprintf(p, TTSP_BUFF_SIZE, "%02x", blk[i]); - pr_debug("%s: size %d, pos %ld payload %s\n", - __func__, len, (long)0, buf); - - do { - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, len, blk); - if (retval < 0) - msleep(20); - } while (tries++ < 20 && (retval < 0)); - - if (retval < 0) { - pr_err("%s: failed\n", __func__); - return retval; - } - - return 0; -} - -static int flash_command(struct cyttsp *ts, const struct cmd_record *record) -{ - return flash_block(ts, (u8 *)record, cmd_rec_size); -} - -static void init_data_record(struct fw_record *rec, unsigned short addr) -{ - addr >>= 6; - rec->blk_hi = (addr >> 8) & 0xff; - rec->blk_lo = addr & 0xff; - rec->rec_cs = rec->blk_hi + rec->blk_lo + - (unsigned char)(BLK_SEED + BL_CMD_WRBLK + KEY_CS); - rec->data_cs = 0; -} - -static int check_record(struct cyttsp *ts, u8 *rec) -{ - int rc; - u16 addr; - u8 r_len, type, hi_off, lo_off; - - rc = str2uc(rec + REC_LEN_OFFSET, &r_len); - if (rc < 0) - return rc; - - rc = str2uc(rec + REC_TYPE_OFFSET, &type); - if (rc < 0) - return rc; - - if (*rec != REC_START_CHR || r_len != DATA_REC_LEN || type != 0) - return -EINVAL; - - rc = str2uc(rec + REC_ADDR_HI_OFFSET, &hi_off); - if (rc < 0) - return rc; - - rc = str2uc(rec + REC_ADDR_LO_OFFSET, &lo_off); - if (rc < 0) - return rc; - - addr = (hi_off << 8) | lo_off; - - if (addr >= ts->fw_start_addr || addr == BL_REC1_ADDR - || addr == BL_REC2_ADDR) - return 0; - - return -EINVAL; -} - -static struct fw_record *prepare_record(u8 *rec) -{ - int i, rc; - u16 addr; - u8 hi_off, lo_off; - u8 *p; - - rc = str2uc(rec + REC_ADDR_HI_OFFSET, &hi_off); - if (rc < 0) - return ERR_PTR((long) rc); - - rc = str2uc(rec + REC_ADDR_LO_OFFSET, &lo_off); - if (rc < 0) - return ERR_PTR((long) rc); - - addr = (hi_off << 8) | lo_off; - - init_data_record(&data_record, addr); - p = rec + REC_DATA_OFFSET; - for (i = 0; i < DATA_REC_LEN; i++) { - rc = str2uc(p, &data_record.data[i]); - if (rc < 0) - return ERR_PTR((long) rc); - data_record.data_cs += data_record.data[i]; - data_record.rec_cs += data_record.data[i]; - p += 2; - } - data_record.rec_cs += data_record.data_cs; - - return &data_record; -} - -static int flash_record(struct cyttsp *ts, const struct fw_record *record) -{ - int len = fw_rec_size; - int blk_len, rc; - u8 *rec = (u8 *)record; - u8 data[BLK_SIZE + 1]; - u8 blk_offset; - - for (blk_offset = 0; len; len -= blk_len) { - data[0] = blk_offset; - blk_len = len > BLK_SIZE ? BLK_SIZE : len; - memcpy(data + 1, rec, blk_len); - rec += blk_len; - rc = flash_block(ts, data, blk_len + 1); - if (rc < 0) - return rc; - blk_offset += blk_len; - } - return 0; -} - -static int flash_data_rec(struct cyttsp *ts, u8 *buf) -{ - struct fw_record *rec; - int rc, tries; - - if (!buf) - return -EINVAL; - - rc = check_record(ts, buf); - - if (rc < 0) { - pr_debug("%s: record ignored %s", __func__, buf); - return 0; - } - - rec = prepare_record(buf); - if (IS_ERR_OR_NULL(rec)) - return PTR_ERR(rec); - - rc = flash_record(ts, rec); - if (rc < 0) - return rc; - - tries = 0; - do { - if (rec_cnt%2) - msleep(20); - cyttsp_putbl(ts, 4, true, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - rec_cnt++; - return rc; -} - -static int cyttspfw_flash_firmware(struct cyttsp *ts, const u8 *data, - int data_len) -{ - u8 *buf; - int i, j; - int rc, tries = 0; - - /* initiate bootload: this will erase all the existing data */ - rc = flash_command(ts, &initiate_rec); - if (rc < 0) - return rc; - - do { - msleep(100); - cyttsp_putbl(ts, 4, true, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - - buf = kzalloc(REC_LINE_SIZE + 1, GFP_KERNEL); - if (!buf) { - pr_err("%s: no memory\n", __func__); - return -ENOMEM; - } - - rec_cnt = 0; - /* flash data records */ - for (i = 0, j = 0; i < data_len; i++, j++) { - if ((data[i] == REC_START_CHR) && j) { - buf[j] = 0; - rc = flash_data_rec(ts, buf); - if (rc < 0) - return rc; - j = 0; - } - buf[j] = data[i]; - } - - /* flash last data record */ - if (j) { - buf[j] = 0; - rc = flash_data_rec(ts, buf); - if (rc < 0) - return rc; - } - - kfree(buf); - - /* termiate bootload */ - tries = 0; - rc = flash_command(ts, &terminate_rec); - do { - msleep(100); - cyttsp_putbl(ts, 4, true, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - - return rc; -} - -static int get_hex_fw_ver(u8 *p, u8 *ttspver_hi, u8 *ttspver_lo, - u8 *appid_hi, u8 *appid_lo, u8 *appver_hi, - u8 *appver_lo, u8 *cid_0, u8 *cid_1, u8 *cid_2) -{ - int rc; - - p = p + ID_INFO_OFFSET_IN_REC; - rc = str2uc(p, ttspver_hi); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, ttspver_lo); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, appid_hi); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, appid_lo); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, appver_hi); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, appver_lo); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, cid_0); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, cid_1); - if (rc < 0) - return rc; - p += 2; - rc = str2uc(p, cid_2); - if (rc < 0) - return rc; - - return 0; -} - -static void cyttspfw_flash_start(struct cyttsp *ts, const u8 *data, - int data_len, u8 *buf, bool force) -{ - int rc; - u8 ttspver_hi = 0, ttspver_lo = 0, fw_upgrade = 0; - u8 appid_hi = 0, appid_lo = 0; - u8 appver_hi = 0, appver_lo = 0; - u8 cid_0 = 0, cid_1 = 0, cid_2 = 0; - char *p = buf; - - /* get hex firmware version */ - rc = get_hex_fw_ver(p, &ttspver_hi, &ttspver_lo, - &appid_hi, &appid_lo, &appver_hi, - &appver_lo, &cid_0, &cid_1, &cid_2); - - if (rc < 0) { - pr_err("%s: unable to get hex firmware version\n", __func__); - return; - } - - /* disable interrupts before flashing */ - if (ts->client->irq == 0) - del_timer(&ts->timer); - else - disable_irq(ts->client->irq); - - /* enter bootloader idle mode */ - rc = cyttsp_soft_reset(ts); - - if (rc < 0) { - pr_err("%s: try entering into idle mode" - " second time\n", __func__); - msleep(1000); - rc = cyttsp_soft_reset(ts); - } - - if (rc < 0) { - pr_err("%s: try again later\n", __func__); - return; - } - - - pr_info("Current firmware: %d.%d.%d", g_bl_data.appid_lo, - g_bl_data.appver_hi, g_bl_data.appver_lo); - pr_info("New firmware: %d.%d.%d", appid_lo, appver_hi, appver_lo); - - if (force) - fw_upgrade = 1; - else if (!(g_bl_data.bl_status & BL_CHECKSUM_MASK) && - (appid_lo == ts->platform_data->correct_fw_ver)) - fw_upgrade = 1; - else if ((appid_hi == g_bl_data.appid_hi) && - (appid_lo == g_bl_data.appid_lo)) - if (appver_hi > g_bl_data.appver_hi) - fw_upgrade = 1; - else if ((appver_hi == g_bl_data.appver_hi) && - (appver_lo > g_bl_data.appver_lo)) - fw_upgrade = 1; - else { - fw_upgrade = 0; - pr_info("%s: Firmware version " - "lesser/equal to existing firmware, " - "upgrade not needed\n", __func__); - } - else if (appid_lo == ts->platform_data->correct_fw_ver) - fw_upgrade = 1; - else { - fw_upgrade = 0; - pr_info("%s: Firmware versions do not match, " - "cannot upgrade\n", __func__); - } - - if (fw_upgrade) { - pr_info("%s: Starting firmware upgrade\n", __func__); - rc = cyttspfw_flash_firmware(ts, data, data_len); - if (rc < 0) - pr_err("%s: firmware upgrade failed\n", __func__); - else - pr_info("%s: firmware upgrade success\n", __func__); - } - - /* enter bootloader idle mode */ - cyttsp_soft_reset(ts); - /* exit bootloader mode */ - cyttsp_exit_bl_mode(ts); - msleep(100); - /* set sysinfo details */ - cyttsp_set_sysinfo_mode(ts); - /* enter application mode */ - cyttsp_set_opmode(ts); - - /* enable interrupts */ - if (ts->client->irq == 0) - mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT); - else - enable_irq(ts->client->irq); -} - -static void cyttspfw_upgrade_start(struct cyttsp *ts, const u8 *data, - int data_len, bool force) -{ - int i, j; - u8 *buf; - - buf = kzalloc(REC_LINE_SIZE + 1, GFP_KERNEL); - if (!buf) { - pr_err("%s: no memory\n", __func__); - return; - } - - for (i = 0, j = 0; i < data_len; i++, j++) { - if ((data[i] == REC_START_CHR) && j) { - buf[j] = 0; - j = 0; - if (!strncmp(buf, ID_INFO_REC, - strnlen(ID_INFO_REC, ID_INFO_REC_LEN))) { - cyttspfw_flash_start(ts, data, data_len, - buf, force); - break; - } - } - buf[j] = data[i]; - } - - /* check in the last record of firmware */ - if (j) { - buf[j] = 0; - if (!strncmp(buf, ID_INFO_REC, - strnlen(ID_INFO_REC, ID_INFO_REC_LEN))) { - cyttspfw_flash_start(ts, data, data_len, - buf, force); - } - } - - kfree(buf); -} - -static void cyttspfw_upgrade(struct device *dev, bool force) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - const struct firmware *cyttsp_fw; - int retval = 0; - - if (ts->is_suspended == true) { - pr_err("%s: in suspend state, resume it\n", __func__); - retval = cyttsp_resume(dev); - if (retval < 0) { - pr_err("%s: unable to resume\n", __func__); - return; - } - } - - retval = request_firmware(&cyttsp_fw, ts->fw_fname, dev); - if (retval < 0) { - pr_err("%s: %s request failed(%d)\n", __func__, - ts->fw_fname, retval); - } else { - /* check and start upgrade */ - cyttspfw_upgrade_start(ts, cyttsp_fw->data, - cyttsp_fw->size, force); - release_firmware(cyttsp_fw); - } -} - -static ssize_t cyttsp_update_fw_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - return snprintf(buf, 2, "%d\n", ts->cyttsp_fwloader_mode); -} - -static ssize_t cyttsp_force_update_fw_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - unsigned long val; - int rc; - - if (size > 2) - return -EINVAL; - - rc = strict_strtoul(buf, 10, &val); - if (rc != 0) - return rc; - - mutex_lock(&ts->mutex); - if (!ts->cyttsp_fwloader_mode && val) { - ts->cyttsp_fwloader_mode = 1; - cyttspfw_upgrade(dev, true); - ts->cyttsp_fwloader_mode = 0; - } - mutex_unlock(&ts->mutex); - return size; -} - -static DEVICE_ATTR(cyttsp_force_update_fw, 0664, cyttsp_update_fw_show, - cyttsp_force_update_fw_store); - -static ssize_t cyttsp_update_fw_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - unsigned long val; - int rc; - - if (size > 2) - return -EINVAL; - - rc = strict_strtoul(buf, 10, &val); - if (rc != 0) - return rc; - - mutex_lock(&ts->mutex); - if (!ts->cyttsp_fwloader_mode && val) { - ts->cyttsp_fwloader_mode = 1; - cyttspfw_upgrade(dev, false); - ts->cyttsp_fwloader_mode = 0; - } - mutex_unlock(&ts->mutex); - - return size; -} - -static DEVICE_ATTR(cyttsp_update_fw, 0664, cyttsp_update_fw_show, - cyttsp_update_fw_store); - -static ssize_t cyttsp_fw_name_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - return snprintf(buf, FW_FNAME_LEN - 1, "%s\n", ts->fw_fname); -} - -static ssize_t cyttsp_fw_name_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - - if (size > FW_FNAME_LEN - 1) - return -EINVAL; - - strlcpy(ts->fw_fname, buf, size); - if (ts->fw_fname[size-1] == '\n') - ts->fw_fname[size-1] = 0; - - return size; -} - -static DEVICE_ATTR(cyttsp_fw_name, 0664, cyttsp_fw_name_show, - cyttsp_fw_name_store); - -static int cyttsp_debug_suspend_set(void *_data, u64 val) -{ - struct cyttsp *ts = _data; - - mutex_lock(&ts->input->mutex); - - if (val) - cyttsp_suspend(&ts->client->dev); - else - cyttsp_resume(&ts->client->dev); - - mutex_unlock(&ts->input->mutex); - - return 0; -} - -static int cyttsp_debug_suspend_get(void *_data, u64 *val) -{ - struct cyttsp *ts = _data; - - mutex_lock(&ts->input->mutex); - *val = ts->is_suspended; - mutex_unlock(&ts->input->mutex); - - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debug_suspend_fops, cyttsp_debug_suspend_get, - cyttsp_debug_suspend_set, "%lld\n"); - -static void cyttsp_xy_handler(struct cyttsp *ts) -{ - u8 id, tilt, rev_x, rev_y; - u8 i, loc; - u8 prv_tch; /* number of previous touches */ - u8 cur_tch; /* number of current touches */ - u16 tmp_trk[CY_NUM_MT_TCH_ID]; - u16 snd_trk[CY_NUM_MT_TCH_ID]; - u16 cur_trk[CY_NUM_TRK_ID]; - u16 cur_st_tch[CY_NUM_ST_TCH_ID]; - u16 cur_mt_tch[CY_NUM_MT_TCH_ID]; - /* if NOT CY_USE_TRACKING_ID then - * only uses CY_NUM_MT_TCH_ID positions */ - u16 cur_mt_pos[CY_NUM_TRK_ID][2]; - /* if NOT CY_USE_TRACKING_ID then - * only uses CY_NUM_MT_TCH_ID positions */ - u8 cur_mt_z[CY_NUM_TRK_ID]; - u8 curr_tool_width; - u16 st_x1, st_y1; - u8 st_z1; - u16 st_x2, st_y2; - u8 st_z2; - s32 retval; - int val; - - cyttsp_xdebug("TTSP handler start 1:\n"); - - /* get event data from CYTTSP device */ - i = CY_NUM_RETRY; - do { - retval = i2c_smbus_read_i2c_block_data(ts->client, - CY_REG_BASE, - sizeof(struct cyttsp_gen3_xydata_t), (u8 *)&g_xy_data); - } while ((retval < CY_OK) && --i); - - if (retval < CY_OK) { - /* return immediately on - * failure to read device on the i2c bus */ - goto exit_xy_handler; - } - - cyttsp_xdebug("TTSP handler start 2:\n"); - - /* compare own irq counter with the device irq counter */ - if (ts->client->irq) { - u8 host_reg; - u8 cur_cnt; - if (ts->platform_data->use_hndshk) { - - host_reg = g_xy_data.hst_mode & CY_HNDSHK_BIT ? - g_xy_data.hst_mode & ~CY_HNDSHK_BIT : - g_xy_data.hst_mode | CY_HNDSHK_BIT; - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, sizeof(host_reg), &host_reg); - } - cur_cnt = g_xy_data.tt_undef[CY_IRQ_CNT_REG]; - irq_cnt_total++; - irq_cnt++; - if (irq_cnt != cur_cnt) { - irq_err_cnt++; - cyttsp_debug("i_c_ER: dv=%d fw=%d hm=%02X t=%lu te=%lu\n", \ - irq_cnt, \ - cur_cnt, g_xy_data.hst_mode, \ - (unsigned long)irq_cnt_total, \ - (unsigned long)irq_err_cnt); - } else { - cyttsp_debug("i_c_ok: dv=%d fw=%d hm=%02X t=%lu te=%lu\n", \ - irq_cnt, \ - cur_cnt, g_xy_data.hst_mode, \ - (unsigned long)irq_cnt_total, \ - (unsigned long)irq_err_cnt); - } - irq_cnt = cur_cnt; - } - - /* Get the current num touches and return if there are no touches */ - if ((GET_BOOTLOADERMODE(g_xy_data.tt_mode) == 1) || - (GET_HSTMODE(g_xy_data.hst_mode) != CY_OK)) { - u8 host_reg, tries; - /* the TTSP device has suffered spurious reset or mode switch */ - cyttsp_debug( \ - "Spurious err opmode (tt_mode=%02X hst_mode=%02X)\n", \ - g_xy_data.tt_mode, g_xy_data.hst_mode); - cyttsp_debug("Reset TTSP Device; Terminating active tracks\n"); - /* terminate all active tracks */ - cur_tch = CY_NTCH; - /* reset TTSP part and take it back out of Bootloader mode */ - /* reset TTSP Device back to bootloader mode */ - host_reg = CY_SOFT_RESET_MODE; - retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, - sizeof(host_reg), &host_reg); - /* wait for TTSP Device to complete reset back to bootloader */ - tries = 0; - do { - usleep_range(1000, 1000); - cyttsp_putbl(ts, 1, false, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - retval = cyttsp_putbl(ts, 1, true, true, true); - /* switch back to operational mode */ - /* take TTSP device out of bootloader mode; - * switch back to TrueTouch operational mode */ - if (!(retval < CY_OK)) { - int tries; - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, - sizeof(bl_cmd), bl_cmd); - /* wait for TTSP Device to complete - * switch to Operational mode */ - tries = 0; - do { - msleep(100); - cyttsp_putbl(ts, 2, false, false, false); - } while (GET_BOOTLOADERMODE(g_bl_data.bl_status) && - tries++ < 100); - cyttsp_putbl(ts, 2, true, false, false); - } - goto exit_xy_handler; - } else { - cur_tch = GET_NUM_TOUCHES(g_xy_data.tt_stat); - if (IS_LARGE_AREA(g_xy_data.tt_stat)) { - /* terminate all active tracks */ - cur_tch = CY_NTCH; - cyttsp_debug("Large obj detect (tt_stat=0x%02X). Terminate act trks\n", \ - g_xy_data.tt_stat); - } else if (cur_tch > CY_NUM_MT_TCH_ID) { - /* if the number of fingers on the touch surface - * is more than the maximum then - * there will be no new track information - * even for the original touches. - * Therefore, terminate all active tracks. - */ - cur_tch = CY_NTCH; - cyttsp_debug("Num touch err (tt_stat=0x%02X). Terminate act trks\n", \ - g_xy_data.tt_stat); - } - } - - /* set tool size */ - curr_tool_width = CY_SMALL_TOOL_WIDTH; - - /* translate Gen2 interface data into comparable Gen3 data */ - if (ts->platform_data->gen == CY_GEN2) { - struct cyttsp_gen2_xydata_t *pxy_gen2_data; - pxy_gen2_data = (struct cyttsp_gen2_xydata_t *)(&g_xy_data); - - /* use test data? */ - cyttsp_testdat(&g_xy_data, &tt_gen2_testray, \ - sizeof(struct cyttsp_gen3_xydata_t)); - - if (ts->platform_data->disable_ghost_det && - (cur_tch == CY_GEN2_GHOST)) - cur_tch = CY_GEN2_2TOUCH; - - if (pxy_gen2_data->evnt_idx == CY_GEN2_NOTOUCH) { - cur_tch = 0; - } else if (cur_tch == CY_GEN2_GHOST) { - cur_tch = 0; - } else if (cur_tch == CY_GEN2_2TOUCH) { - /* stuff artificial track ID1 and ID2 */ - g_xy_data.touch12_id = 0x12; - g_xy_data.z1 = CY_MAXZ; - g_xy_data.z2 = CY_MAXZ; - cur_tch--; /* 2 touches */ - } else if (cur_tch == CY_GEN2_1TOUCH) { - /* stuff artificial track ID1 and ID2 */ - g_xy_data.touch12_id = 0x12; - g_xy_data.z1 = CY_MAXZ; - g_xy_data.z2 = CY_NTCH; - if (pxy_gen2_data->evnt_idx == CY_GEN2_TOUCH2) { - /* push touch 2 data into touch1 - * (first finger up; second finger down) */ - /* stuff artificial track ID1 for touch2 info */ - g_xy_data.touch12_id = 0x20; - /* stuff touch 1 with touch 2 coordinate data */ - g_xy_data.x1 = g_xy_data.x2; - g_xy_data.y1 = g_xy_data.y2; - } - } else { - cur_tch = 0; - } - } else { - /* use test data? */ - cyttsp_testdat(&g_xy_data, &tt_gen3_testray, \ - sizeof(struct cyttsp_gen3_xydata_t)); - } - - - - /* clear current active track ID array and count previous touches */ - for (id = 0, prv_tch = CY_NTCH; - id < CY_NUM_TRK_ID; id++) { - cur_trk[id] = CY_NTCH; - prv_tch += ts->act_trk[id]; - } - - /* send no events if no previous touches and no new touches */ - if ((prv_tch == CY_NTCH) && - ((cur_tch == CY_NTCH) || - (cur_tch > CY_NUM_MT_TCH_ID))) { - goto exit_xy_handler; - } - - cyttsp_debug("prev=%d curr=%d\n", prv_tch, cur_tch); - - for (id = 0; id < CY_NUM_ST_TCH_ID; id++) { - /* clear current single touches array */ - cur_st_tch[id] = CY_IGNR_TCH; - } - - /* clear single touch positions */ - st_x1 = CY_NTCH; - st_y1 = CY_NTCH; - st_z1 = CY_NTCH; - st_x2 = CY_NTCH; - st_y2 = CY_NTCH; - st_z2 = CY_NTCH; - - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - /* clear current multi-touches array and - * multi-touch positions/z */ - cur_mt_tch[id] = CY_IGNR_TCH; - } - - if (ts->platform_data->use_trk_id) { - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - cur_mt_pos[id][CY_XPOS] = 0; - cur_mt_pos[id][CY_YPOS] = 0; - cur_mt_z[id] = 0; - } - } else { - for (id = 0; id < CY_NUM_TRK_ID; id++) { - cur_mt_pos[id][CY_XPOS] = 0; - cur_mt_pos[id][CY_YPOS] = 0; - cur_mt_z[id] = 0; - } - } - - /* Determine if display is tilted */ - if (FLIP_DATA(ts->platform_data->flags)) - tilt = true; - else - tilt = false; - - /* Check for switch in origin */ - if (REVERSE_X(ts->platform_data->flags)) - rev_x = true; - else - rev_x = false; - - if (REVERSE_Y(ts->platform_data->flags)) - rev_y = true; - else - rev_y = false; - - if (cur_tch) { - struct cyttsp_gen2_xydata_t *pxy_gen2_data; - struct cyttsp_gen3_xydata_t *pxy_gen3_data; - switch (ts->platform_data->gen) { - case CY_GEN2: { - pxy_gen2_data = - (struct cyttsp_gen2_xydata_t *)(&g_xy_data); - cyttsp_xdebug("TTSP Gen2 report:\n"); - cyttsp_xdebug("%02X %02X %02X\n", \ - pxy_gen2_data->hst_mode, \ - pxy_gen2_data->tt_mode, \ - pxy_gen2_data->tt_stat); - cyttsp_xdebug("%04X %04X %02X %02X\n", \ - pxy_gen2_data->x1, \ - pxy_gen2_data->y1, \ - pxy_gen2_data->z1, \ - pxy_gen2_data->evnt_idx); - cyttsp_xdebug("%04X %04X %02X\n", \ - pxy_gen2_data->x2, \ - pxy_gen2_data->y2, \ - pxy_gen2_data->tt_undef1); - cyttsp_xdebug("%02X %02X %02X\n", \ - pxy_gen2_data->gest_cnt, \ - pxy_gen2_data->gest_id, \ - pxy_gen2_data->gest_set); - break; - } - case CY_GEN3: - default: { - pxy_gen3_data = - (struct cyttsp_gen3_xydata_t *)(&g_xy_data); - cyttsp_xdebug("TTSP Gen3 report:\n"); - cyttsp_xdebug("%02X %02X %02X\n", \ - pxy_gen3_data->hst_mode, - pxy_gen3_data->tt_mode, - pxy_gen3_data->tt_stat); - cyttsp_xdebug("%04X %04X %02X %02X", \ - pxy_gen3_data->x1, - pxy_gen3_data->y1, - pxy_gen3_data->z1, \ - pxy_gen3_data->touch12_id); - cyttsp_xdebug("%04X %04X %02X\n", \ - pxy_gen3_data->x2, \ - pxy_gen3_data->y2, \ - pxy_gen3_data->z2); - cyttsp_xdebug("%02X %02X %02X\n", \ - pxy_gen3_data->gest_cnt, \ - pxy_gen3_data->gest_id, \ - pxy_gen3_data->gest_set); - cyttsp_xdebug("%04X %04X %02X %02X\n", \ - pxy_gen3_data->x3, \ - pxy_gen3_data->y3, \ - pxy_gen3_data->z3, \ - pxy_gen3_data->touch34_id); - cyttsp_xdebug("%04X %04X %02X\n", \ - pxy_gen3_data->x4, \ - pxy_gen3_data->y4, \ - pxy_gen3_data->z4); - break; - } - } - } - - /* process the touches */ - switch (cur_tch) { - case 4: { - g_xy_data.x4 = be16_to_cpu(g_xy_data.x4); - g_xy_data.y4 = be16_to_cpu(g_xy_data.y4); - if (tilt) - FLIP_XY(g_xy_data.x4, g_xy_data.y4); - - if (rev_x) { - val = INVERT_X(g_xy_data.x4, - ts->platform_data->panel_maxx); - if (val >= 0) - g_xy_data.x4 = val; - else - pr_debug("X value is negative. Please configure" - " maxx in platform data structure\n"); - } - if (rev_y) { - val = INVERT_X(g_xy_data.y4, - ts->platform_data->panel_maxy); - if (val >= 0) - g_xy_data.y4 = val; - else - pr_debug("Y value is negative. Please configure" - " maxy in platform data structure\n"); - - } - id = GET_TOUCH4_ID(g_xy_data.touch34_id); - if (ts->platform_data->use_trk_id) { - cur_mt_pos[CY_MT_TCH4_IDX][CY_XPOS] = - g_xy_data.x4; - cur_mt_pos[CY_MT_TCH4_IDX][CY_YPOS] = - g_xy_data.y4; - cur_mt_z[CY_MT_TCH4_IDX] = g_xy_data.z4; - } else { - cur_mt_pos[id][CY_XPOS] = g_xy_data.x4; - cur_mt_pos[id][CY_YPOS] = g_xy_data.y4; - cur_mt_z[id] = g_xy_data.z4; - } - cur_mt_tch[CY_MT_TCH4_IDX] = id; - cur_trk[id] = CY_TCH; - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] < - CY_NUM_TRK_ID) { - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) { - st_x1 = g_xy_data.x4; - st_y1 = g_xy_data.y4; - st_z1 = g_xy_data.z4; - cur_st_tch[CY_ST_FNGR1_IDX] = id; - } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) { - st_x2 = g_xy_data.x4; - st_y2 = g_xy_data.y4; - st_z2 = g_xy_data.z4; - cur_st_tch[CY_ST_FNGR2_IDX] = id; - } - } - cyttsp_xdebug("4th XYZ:% 3d,% 3d,% 3d ID:% 2d\n\n", \ - g_xy_data.x4, g_xy_data.y4, g_xy_data.z4, \ - (g_xy_data.touch34_id & 0x0F)); - /* do not break */ - } - case 3: { - g_xy_data.x3 = be16_to_cpu(g_xy_data.x3); - g_xy_data.y3 = be16_to_cpu(g_xy_data.y3); - if (tilt) - FLIP_XY(g_xy_data.x3, g_xy_data.y3); - - if (rev_x) { - val = INVERT_X(g_xy_data.x3, - ts->platform_data->panel_maxx); - if (val >= 0) - g_xy_data.x3 = val; - else - pr_debug("X value is negative. Please configure" - " maxx in platform data structure\n"); - - } - if (rev_y) { - val = INVERT_X(g_xy_data.y3, - ts->platform_data->panel_maxy); - if (val >= 0) - g_xy_data.y3 = val; - else - pr_debug("Y value is negative. Please configure" - " maxy in platform data structure\n"); - - } - id = GET_TOUCH3_ID(g_xy_data.touch34_id); - if (ts->platform_data->use_trk_id) { - cur_mt_pos[CY_MT_TCH3_IDX][CY_XPOS] = - g_xy_data.x3; - cur_mt_pos[CY_MT_TCH3_IDX][CY_YPOS] = - g_xy_data.y3; - cur_mt_z[CY_MT_TCH3_IDX] = g_xy_data.z3; - } else { - cur_mt_pos[id][CY_XPOS] = g_xy_data.x3; - cur_mt_pos[id][CY_YPOS] = g_xy_data.y3; - cur_mt_z[id] = g_xy_data.z3; - } - cur_mt_tch[CY_MT_TCH3_IDX] = id; - cur_trk[id] = CY_TCH; - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] < - CY_NUM_TRK_ID) { - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) { - st_x1 = g_xy_data.x3; - st_y1 = g_xy_data.y3; - st_z1 = g_xy_data.z3; - cur_st_tch[CY_ST_FNGR1_IDX] = id; - } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) { - st_x2 = g_xy_data.x3; - st_y2 = g_xy_data.y3; - st_z2 = g_xy_data.z3; - cur_st_tch[CY_ST_FNGR2_IDX] = id; - } - } - cyttsp_xdebug("3rd XYZ:% 3d,% 3d,% 3d ID:% 2d\n", \ - g_xy_data.x3, g_xy_data.y3, g_xy_data.z3, \ - ((g_xy_data.touch34_id >> 4) & 0x0F)); - /* do not break */ - } - case 2: { - g_xy_data.x2 = be16_to_cpu(g_xy_data.x2); - g_xy_data.y2 = be16_to_cpu(g_xy_data.y2); - if (tilt) - FLIP_XY(g_xy_data.x2, g_xy_data.y2); - - if (rev_x) { - val = INVERT_X(g_xy_data.x2, - ts->platform_data->panel_maxx); - if (val >= 0) - g_xy_data.x2 = val; - else - pr_debug("X value is negative. Please configure" - " maxx in platform data structure\n"); - } - if (rev_y) { - val = INVERT_X(g_xy_data.y2, - ts->platform_data->panel_maxy); - if (val >= 0) - g_xy_data.y2 = val; - else - pr_debug("Y value is negative. Please configure" - " maxy in platform data structure\n"); - } - id = GET_TOUCH2_ID(g_xy_data.touch12_id); - if (ts->platform_data->use_trk_id) { - cur_mt_pos[CY_MT_TCH2_IDX][CY_XPOS] = - g_xy_data.x2; - cur_mt_pos[CY_MT_TCH2_IDX][CY_YPOS] = - g_xy_data.y2; - cur_mt_z[CY_MT_TCH2_IDX] = g_xy_data.z2; - } else { - cur_mt_pos[id][CY_XPOS] = g_xy_data.x2; - cur_mt_pos[id][CY_YPOS] = g_xy_data.y2; - cur_mt_z[id] = g_xy_data.z2; - } - cur_mt_tch[CY_MT_TCH2_IDX] = id; - cur_trk[id] = CY_TCH; - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] < - CY_NUM_TRK_ID) { - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) { - st_x1 = g_xy_data.x2; - st_y1 = g_xy_data.y2; - st_z1 = g_xy_data.z2; - cur_st_tch[CY_ST_FNGR1_IDX] = id; - } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) { - st_x2 = g_xy_data.x2; - st_y2 = g_xy_data.y2; - st_z2 = g_xy_data.z2; - cur_st_tch[CY_ST_FNGR2_IDX] = id; - } - } - cyttsp_xdebug("2nd XYZ:% 3d,% 3d,% 3d ID:% 2d\n", \ - g_xy_data.x2, g_xy_data.y2, g_xy_data.z2, \ - (g_xy_data.touch12_id & 0x0F)); - /* do not break */ - } - case 1: { - g_xy_data.x1 = be16_to_cpu(g_xy_data.x1); - g_xy_data.y1 = be16_to_cpu(g_xy_data.y1); - if (tilt) - FLIP_XY(g_xy_data.x1, g_xy_data.y1); - - if (rev_x) { - val = INVERT_X(g_xy_data.x1, - ts->platform_data->panel_maxx); - if (val >= 0) - g_xy_data.x1 = val; - else - pr_debug("X value is negative. Please configure" - " maxx in platform data structure\n"); - } - if (rev_y) { - val = INVERT_X(g_xy_data.y1, - ts->platform_data->panel_maxy); - if (val >= 0) - g_xy_data.y1 = val; - else - pr_debug("Y value is negative. Please configure" - " maxy in platform data structure"); - } - id = GET_TOUCH1_ID(g_xy_data.touch12_id); - if (ts->platform_data->use_trk_id) { - cur_mt_pos[CY_MT_TCH1_IDX][CY_XPOS] = - g_xy_data.x1; - cur_mt_pos[CY_MT_TCH1_IDX][CY_YPOS] = - g_xy_data.y1; - cur_mt_z[CY_MT_TCH1_IDX] = g_xy_data.z1; - } else { - cur_mt_pos[id][CY_XPOS] = g_xy_data.x1; - cur_mt_pos[id][CY_YPOS] = g_xy_data.y1; - cur_mt_z[id] = g_xy_data.z1; - } - cur_mt_tch[CY_MT_TCH1_IDX] = id; - cur_trk[id] = CY_TCH; - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] < - CY_NUM_TRK_ID) { - if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) { - st_x1 = g_xy_data.x1; - st_y1 = g_xy_data.y1; - st_z1 = g_xy_data.z1; - cur_st_tch[CY_ST_FNGR1_IDX] = id; - } else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) { - st_x2 = g_xy_data.x1; - st_y2 = g_xy_data.y1; - st_z2 = g_xy_data.z1; - cur_st_tch[CY_ST_FNGR2_IDX] = id; - } - } - cyttsp_xdebug("1st XYZ:% 3d,% 3d,% 3d ID:% 2d\n", \ - g_xy_data.x1, g_xy_data.y1, g_xy_data.z1, \ - ((g_xy_data.touch12_id >> 4) & 0x0F)); - break; - } - case 0: - default:{ - break; - } - } - - /* handle Single Touch signals */ - if (ts->platform_data->use_st) { - cyttsp_xdebug("ST STEP 0 - ST1 ID=%d ST2 ID=%d\n", \ - cur_st_tch[CY_ST_FNGR1_IDX], \ - cur_st_tch[CY_ST_FNGR2_IDX]); - if (cur_st_tch[CY_ST_FNGR1_IDX] > CY_NUM_TRK_ID) { - /* reassign finger 1 and 2 positions to new tracks */ - if (cur_tch > 0) { - /* reassign st finger1 */ - if (ts->platform_data->use_trk_id) { - id = CY_MT_TCH1_IDX; - cur_st_tch[CY_ST_FNGR1_IDX] = cur_mt_tch[id]; - } else { - id = GET_TOUCH1_ID(g_xy_data.touch12_id); - cur_st_tch[CY_ST_FNGR1_IDX] = id; - } - st_x1 = cur_mt_pos[id][CY_XPOS]; - st_y1 = cur_mt_pos[id][CY_YPOS]; - st_z1 = cur_mt_z[id]; - cyttsp_xdebug("ST STEP 1 - ST1 ID=%3d\n", \ - cur_st_tch[CY_ST_FNGR1_IDX]); - if ((cur_tch > 1) && - (cur_st_tch[CY_ST_FNGR2_IDX] > - CY_NUM_TRK_ID)) { - /* reassign st finger2 */ - if (cur_tch > 1) { - if (ts->platform_data->use_trk_id) { - id = CY_MT_TCH2_IDX; - cur_st_tch[CY_ST_FNGR2_IDX] = cur_mt_tch[id]; - } else { - id = GET_TOUCH2_ID(g_xy_data.touch12_id); - cur_st_tch[CY_ST_FNGR2_IDX] = id; - } - st_x2 = cur_mt_pos[id][CY_XPOS]; - st_y2 = cur_mt_pos[id][CY_YPOS]; - st_z2 = cur_mt_z[id]; - cyttsp_xdebug("ST STEP 2 - ST2 ID=%3d\n", \ - cur_st_tch[CY_ST_FNGR2_IDX]); - } - } - } - } else if (cur_st_tch[CY_ST_FNGR2_IDX] > CY_NUM_TRK_ID) { - if (cur_tch > 1) { - /* reassign st finger2 */ - if (ts->platform_data->use_trk_id) { - /* reassign st finger2 */ - id = CY_MT_TCH2_IDX; - cur_st_tch[CY_ST_FNGR2_IDX] = - cur_mt_tch[id]; - } else { - /* reassign st finger2 */ - id = GET_TOUCH2_ID(g_xy_data.touch12_id); - cur_st_tch[CY_ST_FNGR2_IDX] = id; - } - st_x2 = cur_mt_pos[id][CY_XPOS]; - st_y2 = cur_mt_pos[id][CY_YPOS]; - st_z2 = cur_mt_z[id]; - cyttsp_xdebug("ST STEP 3 - ST2 ID=%3d\n", \ - cur_st_tch[CY_ST_FNGR2_IDX]); - } - } - /* if the 1st touch is missing and there is a 2nd touch, - * then set the 1st touch to 2nd touch and terminate 2nd touch - */ - if ((cur_st_tch[CY_ST_FNGR1_IDX] > CY_NUM_TRK_ID) && - (cur_st_tch[CY_ST_FNGR2_IDX] < CY_NUM_TRK_ID)) { - st_x1 = st_x2; - st_y1 = st_y2; - st_z1 = st_z2; - cur_st_tch[CY_ST_FNGR1_IDX] = - cur_st_tch[CY_ST_FNGR2_IDX]; - cur_st_tch[CY_ST_FNGR2_IDX] = - CY_IGNR_TCH; - } - /* if the 2nd touch ends up equal to the 1st touch, - * then just report a single touch */ - if (cur_st_tch[CY_ST_FNGR1_IDX] == - cur_st_tch[CY_ST_FNGR2_IDX]) { - cur_st_tch[CY_ST_FNGR2_IDX] = - CY_IGNR_TCH; - } - /* set Single Touch current event signals */ - if (cur_st_tch[CY_ST_FNGR1_IDX] < CY_NUM_TRK_ID) { - input_report_abs(ts->input, - ABS_X, st_x1); - input_report_abs(ts->input, - ABS_Y, st_y1); - input_report_abs(ts->input, - ABS_PRESSURE, st_z1); - input_report_key(ts->input, - BTN_TOUCH, - CY_TCH); - input_report_abs(ts->input, - ABS_TOOL_WIDTH, - curr_tool_width); - cyttsp_debug("ST->F1:%3d X:%3d Y:%3d Z:%3d\n", \ - cur_st_tch[CY_ST_FNGR1_IDX], \ - st_x1, st_y1, st_z1); - } else { - input_report_abs(ts->input, ABS_PRESSURE, CY_NTCH); - input_report_key(ts->input, BTN_TOUCH, CY_NTCH); - } - /* update platform data for the current single touch info */ - ts->prv_st_tch[CY_ST_FNGR1_IDX] = cur_st_tch[CY_ST_FNGR1_IDX]; - ts->prv_st_tch[CY_ST_FNGR2_IDX] = cur_st_tch[CY_ST_FNGR2_IDX]; - - } - - /* handle Multi-touch signals */ - if (ts->platform_data->use_mt) { - if (ts->platform_data->use_trk_id) { - /* terminate any previous touch where the track - * is missing from the current event */ - for (id = 0; id < CY_NUM_TRK_ID; id++) { - if ((ts->act_trk[id] != CY_NTCH) && - (cur_trk[id] == CY_NTCH)) { - input_report_abs(ts->input, - ABS_MT_TRACKING_ID, - id); - input_report_abs(ts->input, - ABS_MT_TOUCH_MAJOR, - CY_NTCH); - input_report_abs(ts->input, - ABS_MT_WIDTH_MAJOR, - curr_tool_width); - input_report_abs(ts->input, - ABS_MT_POSITION_X, - ts->prv_mt_pos[id][CY_XPOS]); - input_report_abs(ts->input, - ABS_MT_POSITION_Y, - ts->prv_mt_pos[id][CY_YPOS]); - CY_MT_SYNC(ts->input); - ts->act_trk[id] = CY_NTCH; - ts->prv_mt_pos[id][CY_XPOS] = 0; - ts->prv_mt_pos[id][CY_YPOS] = 0; - } - } - /* set Multi-Touch current event signals */ - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - if (cur_mt_tch[id] < CY_NUM_TRK_ID) { - input_report_abs(ts->input, - ABS_MT_TRACKING_ID, - cur_mt_tch[id]); - input_report_abs(ts->input, - ABS_MT_TOUCH_MAJOR, - cur_mt_z[id]); - input_report_abs(ts->input, - ABS_MT_WIDTH_MAJOR, - curr_tool_width); - input_report_abs(ts->input, - ABS_MT_POSITION_X, - cur_mt_pos[id][CY_XPOS]); - input_report_abs(ts->input, - ABS_MT_POSITION_Y, - cur_mt_pos[id][CY_YPOS]); - CY_MT_SYNC(ts->input); - ts->act_trk[id] = CY_TCH; - ts->prv_mt_pos[id][CY_XPOS] = - cur_mt_pos[id][CY_XPOS]; - ts->prv_mt_pos[id][CY_YPOS] = - cur_mt_pos[id][CY_YPOS]; - } - } - } else { - /* set temporary track array elements to voids */ - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - tmp_trk[id] = CY_IGNR_TCH; - snd_trk[id] = CY_IGNR_TCH; - } - - /* get what is currently active */ - for (i = 0, id = 0; - id < CY_NUM_TRK_ID && i < CY_NUM_MT_TCH_ID; - id++) { - if (cur_trk[id] == CY_TCH) { - /* only incr counter if track found */ - tmp_trk[i] = id; - i++; - } - } - cyttsp_xdebug("T1: t0=%d, t1=%d, t2=%d, t3=%d\n", \ - tmp_trk[0], tmp_trk[1], tmp_trk[2], \ - tmp_trk[3]); - cyttsp_xdebug("T1: p0=%d, p1=%d, p2=%d, p3=%d\n", \ - ts->prv_mt_tch[0], ts->prv_mt_tch[1], \ - ts->prv_mt_tch[2], ts->prv_mt_tch[3]); - - /* pack in still active previous touches */ - for (id = 0, prv_tch = 0; - id < CY_NUM_MT_TCH_ID; id++) { - if (tmp_trk[id] < CY_NUM_TRK_ID) { - if (cyttsp_inlist(ts->prv_mt_tch, - tmp_trk[id], &loc, - CY_NUM_MT_TCH_ID)) { - loc &= CY_NUM_MT_TCH_ID - 1; - snd_trk[loc] = tmp_trk[id]; - prv_tch++; - cyttsp_xdebug("inlist s[%d]=%d t[%d]=%d l=%d p=%d\n", \ - loc, snd_trk[loc], \ - id, tmp_trk[id], \ - loc, prv_tch); - } else { - cyttsp_xdebug("not inlist s[%d]=%d t[%d]=%d l=%d \n", \ - id, snd_trk[id], \ - id, tmp_trk[id], \ - loc); - } - } - } - cyttsp_xdebug("S1: s0=%d, s1=%d, s2=%d, s3=%d p=%d\n", \ - snd_trk[0], snd_trk[1], snd_trk[2], \ - snd_trk[3], prv_tch); - - /* pack in new touches */ - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - if (tmp_trk[id] < CY_NUM_TRK_ID) { - if (!cyttsp_inlist(snd_trk, tmp_trk[id], &loc, CY_NUM_MT_TCH_ID)) { - cyttsp_xdebug("not inlist t[%d]=%d l=%d\n", \ - id, tmp_trk[id], loc); - if (cyttsp_next_avail_inlist(snd_trk, &loc, CY_NUM_MT_TCH_ID)) { - loc &= CY_NUM_MT_TCH_ID - 1; - snd_trk[loc] = tmp_trk[id]; - cyttsp_xdebug("put inlist s[%d]=%d t[%d]=%d\n", - loc, snd_trk[loc], id, tmp_trk[id]); - } - } else { - cyttsp_xdebug("is in list s[%d]=%d t[%d]=%d loc=%d\n", \ - id, snd_trk[id], id, tmp_trk[id], loc); - } - } - } - cyttsp_xdebug("S2: s0=%d, s1=%d, s2=%d, s3=%d\n", \ - snd_trk[0], snd_trk[1], - snd_trk[2], snd_trk[3]); - - /* sync motion event signals for each current touch */ - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - /* z will either be 0 (NOTOUCH) or - * some pressure (TOUCH) */ - cyttsp_xdebug("MT0 prev[%d]=%d temp[%d]=%d send[%d]=%d\n", \ - id, ts->prv_mt_tch[id], \ - id, tmp_trk[id], \ - id, snd_trk[id]); - if (snd_trk[id] < CY_NUM_TRK_ID) { - input_mt_slot(ts->input, snd_trk[id]); - input_mt_report_slot_state(ts->input, - MT_TOOL_FINGER, true); - input_report_abs(ts->input, - ABS_MT_TOUCH_MAJOR, - cur_mt_z[snd_trk[id]]); - input_report_abs(ts->input, - ABS_MT_WIDTH_MAJOR, - curr_tool_width); - input_report_abs(ts->input, - ABS_MT_POSITION_X, - cur_mt_pos[snd_trk[id]][CY_XPOS]); - input_report_abs(ts->input, - ABS_MT_POSITION_Y, - cur_mt_pos[snd_trk[id]][CY_YPOS]); - cyttsp_debug("MT1->TID:%2d X:%3d Y:%3d Z:%3d touch-sent\n", \ - snd_trk[id], \ - cur_mt_pos[snd_trk[id]][CY_XPOS], \ - cur_mt_pos[snd_trk[id]][CY_YPOS], \ - cur_mt_z[snd_trk[id]]); - } else if (ts->prv_mt_tch[id] < CY_NUM_TRK_ID) { - /* void out this touch */ - input_mt_slot(ts->input, - ts->prv_mt_tch[id]); - input_mt_report_slot_state(ts->input, - MT_TOOL_FINGER, false); - cyttsp_debug("MT2->TID:%2d X:%3d Y:%3d Z:%3d lift off-sent\n", \ - ts->prv_mt_tch[id], \ - ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_XPOS], \ - ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_YPOS], \ - CY_NTCH); - } else { - /* do not stuff any signals for this - * previously and currently - * void touches */ - cyttsp_xdebug("MT3->send[%d]=%d - No touch - NOT sent\n", \ - id, snd_trk[id]); - } - } - - /* save current posted tracks to - * previous track memory */ - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - ts->prv_mt_tch[id] = snd_trk[id]; - if (snd_trk[id] < CY_NUM_TRK_ID) { - ts->prv_mt_pos[snd_trk[id]][CY_XPOS] = - cur_mt_pos[snd_trk[id]][CY_XPOS]; - ts->prv_mt_pos[snd_trk[id]][CY_YPOS] = - cur_mt_pos[snd_trk[id]][CY_YPOS]; - cyttsp_xdebug("MT4->TID:%2d X:%3d Y:%3d Z:%3d save for previous\n", \ - snd_trk[id], \ - ts->prv_mt_pos[snd_trk[id]][CY_XPOS], \ - ts->prv_mt_pos[snd_trk[id]][CY_YPOS], \ - CY_NTCH); - } - } - for (id = 0; id < CY_NUM_TRK_ID; id++) - ts->act_trk[id] = CY_NTCH; - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) { - if (snd_trk[id] < CY_NUM_TRK_ID) - ts->act_trk[snd_trk[id]] = CY_TCH; - } - } - } - - /* handle gestures */ - if (ts->platform_data->use_gestures) { - if (g_xy_data.gest_id) { - input_report_key(ts->input, - BTN_3, CY_TCH); - input_report_abs(ts->input, - ABS_HAT1X, g_xy_data.gest_id); - input_report_abs(ts->input, - ABS_HAT2Y, g_xy_data.gest_cnt); - } - } - - /* signal the view motion event */ - input_sync(ts->input); - - for (id = 0; id < CY_NUM_TRK_ID; id++) { - /* update platform data for the current MT information */ - ts->act_trk[id] = cur_trk[id]; - } - -exit_xy_handler: - /* restart event timer */ - if (ts->client->irq == 0) - mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT); - return; -} - -static int cyttsp_inlist(u16 prev_track[], u8 cur_trk_id, - u8 *prev_loc, u8 num_touches) -{ - u8 id = 0; - - *prev_loc = CY_IGNR_TCH; - - cyttsp_xdebug("IN p[%d]=%d c=%d n=%d loc=%d\n", \ - id, prev_track[id], cur_trk_id, \ - num_touches, *prev_loc); - for (id = 0, *prev_loc = CY_IGNR_TCH; - (id < num_touches); id++) { - cyttsp_xdebug("p[%d]=%d c=%d n=%d loc=%d\n", \ - id, prev_track[id], cur_trk_id, \ - num_touches, *prev_loc); - if (prev_track[id] == cur_trk_id) { - *prev_loc = id; - break; - } - } - cyttsp_xdebug("OUT p[%d]=%d c=%d n=%d loc=%d\n", \ - id, prev_track[id], cur_trk_id, num_touches, *prev_loc); - - return ((*prev_loc < CY_NUM_TRK_ID) ? true : false); -} - -static int cyttsp_next_avail_inlist(u16 cur_trk[], - u8 *new_loc, u8 num_touches) -{ - u8 id; - - for (id = 0, *new_loc = CY_IGNR_TCH; - (id < num_touches); id++) { - if (cur_trk[id] > CY_NUM_TRK_ID) { - *new_loc = id; - break; - } - } - - return ((*new_loc < CY_NUM_TRK_ID) ? true : false); -} - -/* Timer function used as dummy interrupt driver */ -static void cyttsp_timer(unsigned long handle) -{ - struct cyttsp *ts = (struct cyttsp *) handle; - - cyttsp_xdebug("TTSP Device timer event\n"); - - /* schedule motion signal handling */ - cyttsp_xy_handler(ts); - - return; -} - - - -/* ************************************************************************ - * ISR function. This function is general, initialized in drivers init - * function - * ************************************************************************ */ -static irqreturn_t cyttsp_irq(int irq, void *handle) -{ - struct cyttsp *ts = (struct cyttsp *) handle; - - cyttsp_xdebug("%s: Got IRQ\n", CY_I2C_NAME); - - cyttsp_xy_handler(ts); - - return IRQ_HANDLED; -} - -/* ************************************************************************ - * Probe initialization functions - * ************************************************************************ */ -static int cyttsp_putbl(struct cyttsp *ts, int show, - int show_status, int show_version, int show_cid) -{ - int retval = CY_OK; - - int num_bytes = (show_status * 3) + (show_version * 6) + (show_cid * 3); - - if (show_cid) - num_bytes = sizeof(struct cyttsp_bootloader_data_t); - else if (show_version) - num_bytes = sizeof(struct cyttsp_bootloader_data_t) - 3; - else - num_bytes = sizeof(struct cyttsp_bootloader_data_t) - 9; - - if (show) { - retval = i2c_smbus_read_i2c_block_data(ts->client, - CY_REG_BASE, num_bytes, (u8 *)&g_bl_data); - if (show_status) { - cyttsp_debug("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X\n", \ - show, \ - g_bl_data.bl_file, \ - g_bl_data.bl_status, \ - g_bl_data.bl_error, \ - g_bl_data.blver_hi, g_bl_data.blver_lo, \ - g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo); - } - if (show_version) { - cyttsp_debug("BL%d: ttspver=0x%02X%02X appid=0x%02X%02X appver=0x%02X%02X\n", \ - show, \ - g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \ - g_bl_data.appid_hi, g_bl_data.appid_lo, \ - g_bl_data.appver_hi, g_bl_data.appver_lo); - } - if (show_cid) { - cyttsp_debug("BL%d: cid=0x%02X%02X%02X\n", \ - show, \ - g_bl_data.cid_0, \ - g_bl_data.cid_1, \ - g_bl_data.cid_2); - } - } - - return retval; -} - -#ifdef CY_INCLUDE_LOAD_FILE -#define CY_MAX_I2C_LEN 256 -#define CY_MAX_TRY 10 -#define CY_BL_PAGE_SIZE 16 -#define CY_BL_NUM_PAGES 5 -static int cyttsp_i2c_wr_blk_chunks(struct cyttsp *ts, u8 command, - u8 length, const u8 *values) -{ - int retval = CY_OK; - int block = 1; - - u8 dataray[CY_MAX_I2C_LEN]; - - /* first page already includes the bl page offset */ - retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, - CY_BL_PAGE_SIZE+1, values); - values += CY_BL_PAGE_SIZE+1; - length -= CY_BL_PAGE_SIZE+1; - - /* rem blocks require bl page offset stuffing */ - while (length && - (block < CY_BL_NUM_PAGES) && - !(retval < CY_OK)) { - udelay(43*2); /* TRM * 2 */ - dataray[0] = CY_BL_PAGE_SIZE*block; - memcpy(&dataray[1], values, - length >= CY_BL_PAGE_SIZE ? - CY_BL_PAGE_SIZE : length); - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, - length >= CY_BL_PAGE_SIZE ? - CY_BL_PAGE_SIZE + 1 : length+1, dataray); - values += CY_BL_PAGE_SIZE; - length = length >= CY_BL_PAGE_SIZE ? - length - CY_BL_PAGE_SIZE : 0; - block++; - } - - return retval; -} - -static int cyttsp_bootload_app(struct cyttsp *ts) -{ - int retval = CY_OK; - int i, tries; - u8 host_reg; - - cyttsp_debug("load new firmware \n"); - /* reset TTSP Device back to bootloader mode */ - host_reg = CY_SOFT_RESET_MODE; - retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, - sizeof(host_reg), &host_reg); - /* wait for TTSP Device to complete reset back to bootloader */ - tries = 0; - do { - usleep_range(1000, 1000); - cyttsp_putbl(ts, 3, false, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - cyttsp_debug("load file - tver=0x%02X%02X a_id=0x%02X%02X aver=0x%02X%02X\n", \ - cyttsp_fw_tts_verh, cyttsp_fw_tts_verl, \ - cyttsp_fw_app_idh, cyttsp_fw_app_idl, \ - cyttsp_fw_app_verh, cyttsp_fw_app_verl); - - /* download new TTSP Application to the Bootloader */ - if (!(retval < CY_OK)) { - i = 0; - /* send bootload initiation command */ - if (cyttsp_fw[i].Command == CY_BL_INIT_LOAD) { - g_bl_data.bl_file = 0; - g_bl_data.bl_status = 0; - g_bl_data.bl_error = 0; - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, - cyttsp_fw[i].Length, cyttsp_fw[i].Block); - /* delay to allow bl to get ready for block writes */ - i++; - tries = 0; - do { - msleep(100); - cyttsp_putbl(ts, 4, false, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - cyttsp_debug("wait init f=%02X, s=%02X, e=%02X t=%d\n", \ - g_bl_data.bl_file, g_bl_data.bl_status, \ - g_bl_data.bl_error, tries); - /* send bootload firmware load blocks */ - if (!(retval < CY_OK)) { - while (cyttsp_fw[i].Command == CY_BL_WRITE_BLK) { - retval = cyttsp_i2c_wr_blk_chunks(ts, - CY_REG_BASE, - cyttsp_fw[i].Length, - cyttsp_fw[i].Block); - cyttsp_xdebug("BL DNLD Rec=% 3d Len=% 3d Addr=%04X\n", \ - cyttsp_fw[i].Record, \ - cyttsp_fw[i].Length, \ - cyttsp_fw[i].Address); - i++; - if (retval < CY_OK) { - cyttsp_debug("BL fail Rec=%3d retval=%d\n", \ - cyttsp_fw[i-1].Record, \ - retval); - break; - } else { - tries = 0; - cyttsp_putbl(ts, 5, false, false, false); - while (!((g_bl_data.bl_status == 0x10) && - (g_bl_data.bl_error == 0x20)) && - !((g_bl_data.bl_status == 0x11) && - (g_bl_data.bl_error == 0x20)) && - (tries++ < 100)) { - usleep_range(1000, 1000); - cyttsp_putbl(ts, 5, false, false, false); - } - } - } - - if (!(retval < CY_OK)) { - while (i < cyttsp_fw_records) { - retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, - cyttsp_fw[i].Length, - cyttsp_fw[i].Block); - i++; - tries = 0; - do { - msleep(100); - cyttsp_putbl(ts, 6, true, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - cyttsp_debug("wait term f=%02X, s=%02X, e=%02X t=%d\n", \ - g_bl_data.bl_file, \ - g_bl_data.bl_status, \ - g_bl_data.bl_error, \ - tries); - if (retval < CY_OK) - break; - } - } - } - } - } - - /* reset TTSP Device back to bootloader mode */ - host_reg = CY_SOFT_RESET_MODE; - retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, - sizeof(host_reg), &host_reg); - /* wait for TTSP Device to complete reset back to bootloader */ - tries = 0; - do { - usleep_range(1000, 1000); - cyttsp_putbl(ts, 3, false, false, false); - } while (g_bl_data.bl_status != 0x10 && - g_bl_data.bl_status != 0x11 && - tries++ < 100); - - /* set arg2 to non-0 to activate */ - retval = cyttsp_putbl(ts, 8, true, true, true); - - return retval; -} -#else -static int cyttsp_bootload_app(struct cyttsp *ts) -{ - cyttsp_debug("no-load new firmware \n"); - return CY_OK; -} -#endif /* CY_INCLUDE_LOAD_FILE */ - - -static int cyttsp_power_on(struct cyttsp *ts) -{ - int retval = CY_OK; - u8 host_reg; - int tries; - - cyttsp_debug("Power up \n"); - - /* check if the TTSP device has a bootloader installed */ - host_reg = CY_SOFT_RESET_MODE; - retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, - sizeof(host_reg), &host_reg); - tries = 0; - do { - usleep_range(1000, 1000); - - /* set arg2 to non-0 to activate */ - retval = cyttsp_putbl(ts, 1, true, true, true); - cyttsp_info("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X R=%d\n", \ - 101, \ - g_bl_data.bl_file, g_bl_data.bl_status, \ - g_bl_data.bl_error, \ - g_bl_data.blver_hi, g_bl_data.blver_lo, \ - g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo, - retval); - cyttsp_info("BL%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \ - 102, \ - g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \ - g_bl_data.appid_hi, g_bl_data.appid_lo, \ - g_bl_data.appver_hi, g_bl_data.appver_lo); - cyttsp_info("BL%d: c_id=%02X%02X%02X\n", \ - 103, \ - g_bl_data.cid_0, g_bl_data.cid_1, g_bl_data.cid_2); - } while (!(retval < CY_OK) && - !GET_BOOTLOADERMODE(g_bl_data.bl_status) && - !(g_bl_data.bl_file == CY_OP_MODE + CY_LOW_PWR_MODE) && - tries++ < 100); - - /* is bootloader missing? */ - if (!(retval < CY_OK)) { - cyttsp_xdebug("Ret=%d Check if bootloader is missing...\n", \ - retval); - if (!GET_BOOTLOADERMODE(g_bl_data.bl_status)) { - /* skip all bl and sys info and go to op mode */ - if (!(retval < CY_OK)) { - cyttsp_xdebug("Bl is missing (ret=%d)\n", \ - retval); - host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/; - retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE, - sizeof(host_reg), &host_reg); - /* wait for TTSP Device to complete switch to - * Operational mode */ - msleep(1000); - goto bypass; - } - } - } - - - /* take TTSP out of bootloader mode; go to TrueTouch operational mode */ - if (!(retval < CY_OK)) { - cyttsp_xdebug1("exit bootloader; go operational\n"); - tries = 0; - do { - msleep(100); - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, sizeof(bl_cmd), bl_cmd); - if (retval == CY_OK) - break; - } while (tries++ < 5); - - if (retval == CY_OK) { - tries = 0; - do { - msleep(100); - cyttsp_putbl(ts, 4, true, false, false); - cyttsp_info("BL%d: f=%02X s=%02X err=%02X" \ - "bl=%02X%02X bld=%02X%02X\n", 104, \ - g_bl_data.bl_file, \ - g_bl_data.bl_status, \ - g_bl_data.bl_error, \ - g_bl_data.blver_hi, \ - g_bl_data.blver_lo, \ - g_bl_data.bld_blver_hi, \ - g_bl_data.bld_blver_lo); - } while (GET_BOOTLOADERMODE(g_bl_data.bl_status) && - tries++ < 5); - } - } - - if (!(retval < CY_OK) && - cyttsp_app_load()) { - if (CY_DIFF(g_bl_data.ttspver_hi, cyttsp_tts_verh()) || - CY_DIFF(g_bl_data.ttspver_lo, cyttsp_tts_verl()) || - CY_DIFF(g_bl_data.appid_hi, cyttsp_app_idh()) || - CY_DIFF(g_bl_data.appid_lo, cyttsp_app_idl()) || - CY_DIFF(g_bl_data.appver_hi, cyttsp_app_verh()) || - CY_DIFF(g_bl_data.appver_lo, cyttsp_app_verl()) || - CY_DIFF(g_bl_data.cid_0, cyttsp_cid_0()) || - CY_DIFF(g_bl_data.cid_1, cyttsp_cid_1()) || - CY_DIFF(g_bl_data.cid_2, cyttsp_cid_2()) || - cyttsp_force_fw_load()) { - cyttsp_debug("blttsp=0x%02X%02X flttsp=0x%02X%02X force=%d\n", \ - g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \ - cyttsp_tts_verh(), cyttsp_tts_verl(), \ - cyttsp_force_fw_load()); - cyttsp_debug("blappid=0x%02X%02X flappid=0x%02X%02X\n", \ - g_bl_data.appid_hi, g_bl_data.appid_lo, \ - cyttsp_app_idh(), cyttsp_app_idl()); - cyttsp_debug("blappver=0x%02X%02X flappver=0x%02X%02X\n", \ - g_bl_data.appver_hi, g_bl_data.appver_lo, \ - cyttsp_app_verh(), cyttsp_app_verl()); - cyttsp_debug("blcid=0x%02X%02X%02X flcid=0x%02X%02X%02X\n", \ - g_bl_data.cid_0, \ - g_bl_data.cid_1, \ - g_bl_data.cid_2, \ - cyttsp_cid_0(), \ - cyttsp_cid_1(), \ - cyttsp_cid_2()); - /* enter bootloader to load new app into TTSP Device */ - retval = cyttsp_bootload_app(ts); - /* take TTSP device out of bootloader mode; - * switch back to TrueTouch operational mode */ - if (!(retval < CY_OK)) { - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, - sizeof(bl_cmd), bl_cmd); - /* wait for TTSP Device to complete - * switch to Operational mode */ - tries = 0; - do { - msleep(100); - cyttsp_putbl(ts, 9, false, false, false); - } while (GET_BOOTLOADERMODE(g_bl_data.bl_status) && - tries++ < 100); - cyttsp_putbl(ts, 9, true, false, false); - } - } - } - -bypass: - /* switch to System Information mode to read versions - * and set interval registers */ - if (!(retval < CY_OK)) { - cyttsp_debug("switch to sysinfo mode\n"); - host_reg = CY_SYSINFO_MODE; - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, sizeof(host_reg), &host_reg); - /* wait for TTSP Device to complete switch to SysInfo mode */ - msleep(100); - if (!(retval < CY_OK)) { - retval = i2c_smbus_read_i2c_block_data(ts->client, - CY_REG_BASE, - sizeof(struct cyttsp_sysinfo_data_t), - (u8 *)&g_sysinfo_data); - cyttsp_debug("SI2: hst_mode=0x%02X mfg_cmd=0x%02X"\ - "mfg_stat=0x%02X\n", - g_sysinfo_data.hst_mode, - g_sysinfo_data.mfg_cmd, - g_sysinfo_data.mfg_stat); - cyttsp_debug("SI2: bl_ver=0x%02X%02X\n", - g_sysinfo_data.bl_verh, - g_sysinfo_data.bl_verl); - pr_debug("SI2: sysinfo act_int=0x%02X tch_tmout=0x%02X lp_int=0x%02X\n", - g_sysinfo_data.act_intrvl, - g_sysinfo_data.tch_tmout, - g_sysinfo_data.lp_intrvl); - pr_info("SI%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", - 102, - g_sysinfo_data.tts_verh, - g_sysinfo_data.tts_verl, - g_sysinfo_data.app_idh, - g_sysinfo_data.app_idl, - g_sysinfo_data.app_verh, - g_sysinfo_data.app_verl); - cyttsp_info("SI%d: c_id=%02X%02X%02X\n", - 103, - g_sysinfo_data.cid[0], - g_sysinfo_data.cid[1], - g_sysinfo_data.cid[2]); - if (!(retval < CY_OK) && - (CY_DIFF(ts->platform_data->act_intrvl, - CY_ACT_INTRVL_DFLT) || - CY_DIFF(ts->platform_data->tch_tmout, - CY_TCH_TMOUT_DFLT) || - CY_DIFF(ts->platform_data->lp_intrvl, - CY_LP_INTRVL_DFLT))) { - if (!(retval < CY_OK)) { - u8 intrvl_ray[sizeof(\ - ts->platform_data->act_intrvl) + - sizeof(\ - ts->platform_data->tch_tmout) + - sizeof(\ - ts->platform_data->lp_intrvl)]; - u8 i = 0; - - intrvl_ray[i++] = - ts->platform_data->act_intrvl; - intrvl_ray[i++] = - ts->platform_data->tch_tmout; - intrvl_ray[i++] = - ts->platform_data->lp_intrvl; - - pr_debug("SI2: platinfo act_intrvl=0x%02X tch_tmout=0x%02X lp_intrvl=0x%02X\n", - ts->platform_data->act_intrvl, - ts->platform_data->tch_tmout, - ts->platform_data->lp_intrvl); - /* set intrvl registers */ - retval = i2c_smbus_write_i2c_block_data( - ts->client, - CY_REG_ACT_INTRVL, - sizeof(intrvl_ray), intrvl_ray); - msleep(CY_DLY_SYSINFO); - } - } - } - /* switch back to Operational mode */ - cyttsp_debug("switch back to operational mode\n"); - if (!(retval < CY_OK)) { - host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/; - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, - sizeof(host_reg), &host_reg); - /* wait for TTSP Device to complete - * switch to Operational mode */ - msleep(100); - } - } - /* init gesture setup; - * this is required even if not using gestures - * in order to set the active distance */ - if (!(retval < CY_OK)) { - u8 gesture_setup; - cyttsp_debug("init gesture setup\n"); - gesture_setup = ts->platform_data->gest_set; - retval = i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_GEST_SET, - sizeof(gesture_setup), &gesture_setup); - msleep(CY_DLY_DFLT); - } - - if (!(retval < CY_OK)) - ts->platform_data->power_state = CY_ACTIVE_STATE; - else - ts->platform_data->power_state = CY_IDLE_STATE; - - cyttsp_debug("Retval=%d Power state is %s\n", \ - retval, \ - ts->platform_data->power_state == CY_ACTIVE_STATE ? \ - "ACTIVE" : "IDLE"); - - return retval; -} - -static int cyttsp_power_device(struct cyttsp *ts, bool on) -{ - int rc = 0, i; - const struct cyttsp_regulator *reg_info = - ts->platform_data->regulator_info; - u8 num_reg = ts->platform_data->num_regulators; - - if (!reg_info) { - pr_err("regulator pdata not specified\n"); - return -EINVAL; - } - - if (on == false) /* Turn off the regulators */ - goto ts_reg_disable; - - ts->vdd = kzalloc(num_reg * sizeof(struct regulator *), GFP_KERNEL); - if (!ts->vdd) { - pr_err("unable to allocate memory\n"); - return -ENOMEM; - } - - for (i = 0; i < num_reg; i++) { - ts->vdd[i] = regulator_get(&ts->client->dev, reg_info[i].name); - if (IS_ERR(ts->vdd[i])) { - rc = PTR_ERR(ts->vdd[i]); - pr_err("%s:regulator get failed rc=%d\n", - __func__, rc); - goto error_vdd; - } - - if (regulator_count_voltages(ts->vdd[i]) > 0) { - rc = regulator_set_voltage(ts->vdd[i], - reg_info[i].min_uV, reg_info[i].max_uV); - if (rc) { - pr_err("%s: regulator_set_voltage" - "failed rc =%d\n", __func__, rc); - regulator_put(ts->vdd[i]); - goto error_vdd; - } - - rc = regulator_set_optimum_mode(ts->vdd[i], - reg_info[i].hpm_load_uA); - if (rc < 0) { - pr_err("%s: regulator_set_optimum_mode failed " - "rc=%d\n", __func__, rc); - - regulator_set_voltage(ts->vdd[i], 0, - reg_info[i].max_uV); - regulator_put(ts->vdd[i]); - goto error_vdd; - } - } - - rc = regulator_enable(ts->vdd[i]); - if (rc) { - pr_err("%s: regulator_enable failed rc =%d\n", - __func__, rc); - if (regulator_count_voltages(ts->vdd[i]) > 0) { - regulator_set_optimum_mode(ts->vdd[i], 0); - regulator_set_voltage(ts->vdd[i], 0, - reg_info[i].max_uV); - } - regulator_put(ts->vdd[i]); - goto error_vdd; - } - } - - return rc; - -ts_reg_disable: - i = ts->platform_data->num_regulators; -error_vdd: - while (--i >= 0) { - if (regulator_count_voltages(ts->vdd[i]) > 0) { - regulator_set_voltage(ts->vdd[i], 0, - reg_info[i].max_uV); - regulator_set_optimum_mode(ts->vdd[i], 0); - } - regulator_disable(ts->vdd[i]); - regulator_put(ts->vdd[i]); - } - kfree(ts->vdd); - return rc; -} - -/* cyttsp_initialize: Driver Initialization. This function takes - * care of the following tasks: - * 1. Create and register an input device with input layer - * 2. Take CYTTSP device out of bootloader mode; go operational - * 3. Start any timers/Work queues. */ -static int cyttsp_initialize(struct i2c_client *client, struct cyttsp *ts) -{ - struct input_dev *input_device; - struct dentry *dir, *temp; - int error = 0; - int retval = CY_OK; - u8 id; - - /* Create the input device and register it. */ - input_device = input_allocate_device(); - if (!input_device) { - error = -ENOMEM; - cyttsp_xdebug1("err input allocate device\n"); - goto error_free_device; - } - - if (!client) { - error = ~ENODEV; - cyttsp_xdebug1("err client is Null\n"); - goto error_free_device; - } - - if (!ts) { - error = ~ENODEV; - cyttsp_xdebug1("err context is Null\n"); - goto error_free_device; - } - - ts->input = input_device; - input_device->name = CY_I2C_NAME; - input_device->phys = ts->phys; - input_device->dev.parent = &client->dev; - - /* init the touch structures */ - ts->num_prv_st_tch = CY_NTCH; - for (id = 0; id < CY_NUM_TRK_ID; id++) { - ts->act_trk[id] = CY_NTCH; - ts->prv_mt_pos[id][CY_XPOS] = 0; - ts->prv_mt_pos[id][CY_YPOS] = 0; - } - - for (id = 0; id < CY_NUM_MT_TCH_ID; id++) - ts->prv_mt_tch[id] = CY_IGNR_TCH; - - for (id = 0; id < CY_NUM_ST_TCH_ID; id++) - ts->prv_st_tch[id] = CY_IGNR_TCH; - - set_bit(EV_SYN, input_device->evbit); - set_bit(EV_KEY, input_device->evbit); - set_bit(EV_ABS, input_device->evbit); - set_bit(BTN_TOUCH, input_device->keybit); - set_bit(INPUT_PROP_DIRECT, input_device->propbit); - - if (ts->platform_data->use_gestures) - set_bit(BTN_3, input_device->keybit); - - input_set_abs_params(input_device, ABS_X, ts->platform_data->disp_minx, - ts->platform_data->disp_maxx, 0, 0); - input_set_abs_params(input_device, ABS_Y, ts->platform_data->disp_miny, - ts->platform_data->disp_maxy, 0, 0); - input_set_abs_params(input_device, - ABS_TOOL_WIDTH, 0, CY_LARGE_TOOL_WIDTH, 0 , 0); - input_set_abs_params(input_device, - ABS_PRESSURE, 0, CY_MAXZ, 0, 0); - if (ts->platform_data->use_gestures) { - input_set_abs_params(input_device, - ABS_HAT1X, 0, CY_MAXZ, 0, 0); - input_set_abs_params(input_device, - ABS_HAT1Y, 0, CY_MAXZ, 0, 0); - } - if (ts->platform_data->use_mt) { - input_set_abs_params(input_device, ABS_MT_POSITION_X, - ts->platform_data->disp_minx, - ts->platform_data->disp_maxx, 0, 0); - input_set_abs_params(input_device, ABS_MT_POSITION_Y, - ts->platform_data->disp_miny, - ts->platform_data->disp_maxy, 0, 0); - input_set_abs_params(input_device, - ABS_MT_TOUCH_MAJOR, 0, CY_MAXZ, 0, 0); - input_set_abs_params(input_device, - ABS_MT_WIDTH_MAJOR, 0, CY_LARGE_TOOL_WIDTH, 0, 0); - input_mt_init_slots(input_device, CY_NUM_TRK_ID); - if (ts->platform_data->use_trk_id) { - input_set_abs_params(input_device, - ABS_MT_TRACKING_ID, 0, CY_NUM_TRK_ID, 0, 0); - } - } - - /* set dummy key to make driver work with virtual keys */ - input_set_capability(input_device, EV_KEY, KEY_PROG1); - - cyttsp_info("%s: Register input device\n", CY_I2C_NAME); - error = input_register_device(input_device); - if (error) { - cyttsp_alert("%s: Failed to register input device\n", \ - CY_I2C_NAME); - retval = error; - goto error_free_device; - } - - if (gpio_is_valid(ts->platform_data->resout_gpio)) { - /* configure touchscreen reset out gpio */ - retval = gpio_request(ts->platform_data->resout_gpio, - "cyttsp_resout_gpio"); - if (retval) { - pr_err("%s: unable to request reset gpio %d\n", - __func__, ts->platform_data->resout_gpio); - goto error_free_device; - } - - retval = gpio_direction_output( - ts->platform_data->resout_gpio, 1); - if (retval) { - pr_err("%s: unable to set direction for gpio %d\n", - __func__, ts->platform_data->resout_gpio); - goto error_resout_gpio_dir; - } - } - - if (gpio_is_valid(ts->platform_data->sleep_gpio)) { - /* configure touchscreen reset out gpio */ - retval = gpio_request(ts->platform_data->sleep_gpio, - "cy8c_sleep_gpio"); - if (retval) { - pr_err("%s: unable to request sleep gpio %d\n", - __func__, ts->platform_data->sleep_gpio); - goto error_sleep_gpio_req; - } - - retval = gpio_direction_output( - ts->platform_data->sleep_gpio, 0); - if (retval) { - pr_err("%s: unable to set direction for gpio %d\n", - __func__, ts->platform_data->resout_gpio); - goto error_sleep_gpio_dir; - } - } - - if (gpio_is_valid(ts->platform_data->irq_gpio)) { - /* configure touchscreen irq gpio */ - retval = gpio_request(ts->platform_data->irq_gpio, - "ts_irq_gpio"); - if (retval) { - pr_err("%s: unable to request gpio [%d]\n", __func__, - ts->platform_data->irq_gpio); - goto error_irq_gpio_req; - } - retval = gpio_direction_input(ts->platform_data->irq_gpio); - if (retval) { - pr_err("%s: unable to set_direction for gpio [%d]\n", - __func__, ts->platform_data->irq_gpio); - goto error_irq_gpio_dir; - } - } - - if (ts->platform_data->regulator_info) { - retval = cyttsp_power_device(ts, true); - if (retval) { - pr_err("%s: Unable to power device %d\n", - __func__, retval); - goto error_irq_gpio_dir; - } - } - - /* Power on the chip and make sure that I/Os are set as specified - * in the platform */ - if (ts->platform_data->init) { - retval = ts->platform_data->init(client); - if (retval) { - pr_err("%s: ts init failed\n", __func__); - goto error_power_device; - } - } - - msleep(100); - - /* check this device active by reading first byte/register */ - retval = i2c_smbus_read_byte_data(ts->client, 0x01); - if (retval < 0) { - pr_err("%s: i2c sanity check failed\n", __func__); - goto error_power_device; - } - - retval = cyttsp_power_on(ts); - if (retval < 0) { - pr_err("%s: cyttsp_power_on failed\n", __func__); - goto error_power_device; - } - - /* Timer or Interrupt setup */ - if (ts->client->irq == 0) { - cyttsp_info("Setting up timer\n"); - setup_timer(&ts->timer, cyttsp_timer, (unsigned long) ts); - mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT); - } else { - cyttsp_info("Setting up interrupt\n"); - error = request_threaded_irq(client->irq, NULL, cyttsp_irq, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - client->dev.driver->name, ts); - if (error) { - cyttsp_alert("error: could not request irq\n"); - retval = error; - goto error_power_device; - } - } - - irq_cnt = 0; - irq_cnt_total = 0; - irq_err_cnt = 0; - - atomic_set(&ts->irq_enabled, 1); - retval = device_create_file(&ts->client->dev, &dev_attr_irq_enable); - if (retval < CY_OK) { - cyttsp_alert("File device creation failed: %d\n", retval); - retval = -ENODEV; - goto error_free_irq; - } - - retval = device_create_file(&client->dev, &dev_attr_cyttsp_fw_ver); - if (retval) { - cyttsp_alert("sysfs entry for firmware version failed\n"); - goto error_rm_dev_file_irq_en; - } - - ts->cyttsp_fwloader_mode = 0; - retval = device_create_file(&client->dev, &dev_attr_cyttsp_update_fw); - if (retval) { - cyttsp_alert("sysfs entry for firmware update failed\n"); - goto error_rm_dev_file_fw_ver; - } - - retval = device_create_file(&client->dev, - &dev_attr_cyttsp_force_update_fw); - if (retval) { - cyttsp_alert("sysfs entry for force firmware update failed\n"); - goto error_rm_dev_file_update_fw; - } - if (ts->platform_data->correct_fw_ver) { - if (g_bl_data.appid_lo != ts->platform_data->correct_fw_ver) - pr_warn("%s: Invalid firmware version detected;" - " Please update.\n", __func__); - } - - retval = device_create_file(&client->dev, - &dev_attr_cyttsp_fw_name); - if (retval) { - cyttsp_alert("sysfs entry for file name selection failed\n"); - goto error_rm_dev_file_fupdate_fw; - } - - dir = debugfs_create_dir(CYTTSP_DEBUG_DIR_NAME, NULL); - if (dir == NULL || IS_ERR(dir)) { - pr_err("debugfs_create_dir failed: rc=%ld\n", PTR_ERR(dir)); - error = PTR_ERR(dir); - goto error_rm_dev_file_fw_name; - } - - temp = debugfs_create_file("suspend", S_IRUSR | S_IWUSR, dir, ts, - &debug_suspend_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("debugfs_create_file failed: rc=%ld\n", PTR_ERR(temp)); - error = PTR_ERR(temp); - goto error_rm_debug_dir; - } - - cyttsp_info("%s: Successful registration\n", CY_I2C_NAME); - - goto success; - -error_rm_debug_dir: - debugfs_remove_recursive(ts->dir); -error_rm_dev_file_fw_name: - device_remove_file(&client->dev, &dev_attr_cyttsp_fw_name); -error_rm_dev_file_fupdate_fw: - device_remove_file(&client->dev, &dev_attr_cyttsp_force_update_fw); -error_rm_dev_file_update_fw: - device_remove_file(&client->dev, &dev_attr_cyttsp_update_fw); -error_rm_dev_file_fw_ver: - device_remove_file(&client->dev, &dev_attr_cyttsp_fw_ver); -error_rm_dev_file_irq_en: - device_remove_file(&client->dev, &dev_attr_irq_enable); -error_free_irq: - if (ts->client->irq) - free_irq(client->irq, ts); -error_power_device: - if (ts->platform_data->regulator_info) - cyttsp_power_device(ts, false); -error_irq_gpio_dir: - if (gpio_is_valid(ts->platform_data->irq_gpio)) - gpio_free(ts->platform_data->irq_gpio); -error_irq_gpio_req: - if (gpio_is_valid(ts->platform_data->sleep_gpio)) - gpio_direction_output(ts->platform_data->sleep_gpio, 1); -error_sleep_gpio_dir: - if (gpio_is_valid(ts->platform_data->sleep_gpio)) - gpio_free(ts->platform_data->sleep_gpio); -error_sleep_gpio_req: - if (gpio_is_valid(ts->platform_data->resout_gpio)) - gpio_direction_output(ts->platform_data->resout_gpio, 0); -error_resout_gpio_dir: - if (gpio_is_valid(ts->platform_data->resout_gpio)) - gpio_free(ts->platform_data->resout_gpio); -error_free_device: - if (input_device) - input_free_device(input_device); - -success: - return retval; -} - -/* I2C driver probe function */ -static int cyttsp_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct cyttsp *ts; - int error; - int retval = CY_OK; - - cyttsp_info("Start Probe 1.2\n"); - - /* allocate and clear memory */ - ts = kzalloc(sizeof(struct cyttsp), GFP_KERNEL); - if (ts == NULL) { - cyttsp_xdebug1("err kzalloc for cyttsp\n"); - return -ENOMEM; - } - - /* Enable runtime PM ops, start in ACTIVE mode */ - error = pm_runtime_set_active(&client->dev); - if (error < 0) - dev_dbg(&client->dev, "unable to set runtime pm state\n"); - pm_runtime_enable(&client->dev); - - if (!(retval < CY_OK)) { - /* register driver_data */ - ts->client = client; - ts->platform_data = client->dev.platform_data; - - if (ts->platform_data->fw_fname) - strlcpy(ts->fw_fname, ts->platform_data->fw_fname, - FW_FNAME_LEN - 1); - else - strlcpy(ts->fw_fname, "cyttsp.hex", FW_FNAME_LEN - 1); - - if (ts->platform_data->gen == CY_GEN3) { - ts->fw_start_addr = 0x0b00; - } else if (ts->platform_data->gen == CY_GEN2) { - ts->fw_start_addr = 0x0880; - } else { - pr_err("%s: unsupported cypress chip\n", __func__); - kfree(ts); - return -EINVAL; - } - - mutex_init(&ts->mutex); - i2c_set_clientdata(client, ts); - - error = cyttsp_initialize(client, ts); - if (error) { - cyttsp_xdebug1("err cyttsp_initialize\n"); - /* release mutex */ - mutex_destroy(&ts->mutex); - /* deallocate memory */ - kfree(ts); -/* - i2c_del_driver(&cyttsp_driver); -*/ - return -ENODEV; - } - } - -#ifdef CONFIG_HAS_EARLYSUSPEND - if (!(retval < CY_OK)) { - ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; - ts->early_suspend.suspend = cyttsp_early_suspend; - ts->early_suspend.resume = cyttsp_late_resume; - register_early_suspend(&ts->early_suspend); - } -#endif /* CONFIG_HAS_EARLYSUSPEND */ - device_init_wakeup(&client->dev, ts->platform_data->wakeup); - - cyttsp_info("Start Probe %s\n", \ - (retval < CY_OK) ? "FAIL" : "PASS"); - - return retval; -} - -#ifdef CONFIG_PM -static int cyttsp_regulator_lpm(struct cyttsp *ts, bool on) -{ - int rc = 0, i; - const struct cyttsp_regulator *reg_info = - ts->platform_data->regulator_info; - u8 num_reg = ts->platform_data->num_regulators; - - if (on == false) - goto regulator_hpm; - - for (i = 0; i < num_reg; i++) { - if (regulator_count_voltages(ts->vdd[i]) < 0) - continue; - rc = regulator_set_optimum_mode(ts->vdd[i], - reg_info[i].lpm_load_uA); - if (rc < 0) { - pr_err("%s: regulator_set_optimum failed rc = %d\n", - __func__, rc); - goto fail_regulator_lpm; - } - - } - - return 0; - -regulator_hpm: - for (i = 0; i < num_reg; i++) { - if (regulator_count_voltages(ts->vdd[i]) < 0) - continue; - rc = regulator_set_optimum_mode(ts->vdd[i], - reg_info[i].hpm_load_uA); - if (rc < 0) { - pr_err("%s: regulator_set_optimum failed" - "rc = %d\n", __func__, rc); - goto fail_regulator_hpm; - } - } - - return 0; - -fail_regulator_lpm: - while (i--) { - if (regulator_count_voltages(ts->vdd[i]) < 0) - continue; - regulator_set_optimum_mode(ts->vdd[i], - reg_info[i].hpm_load_uA); - } - - return rc; - -fail_regulator_hpm: - while (i--) { - if (regulator_count_voltages(ts->vdd[i]) < 0) - continue; - regulator_set_optimum_mode(ts->vdd[i], - reg_info[i].lpm_load_uA); - } - - return rc; -} - -/* Function to manage power-on resume */ -static int cyttsp_resume(struct device *dev) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - int retval = CY_OK; - - cyttsp_debug("Wake Up\n"); - - if (device_may_wakeup(dev)) { - if (ts->client->irq) - disable_irq_wake(ts->client->irq); - return 0; - } - - if (ts->is_suspended == false) { - pr_err("%s: in wakeup state\n", __func__); - return 0; - } - - /* re-enable the interrupt prior to wake device */ - if (ts->client->irq) - enable_irq(ts->client->irq); - - if (ts->platform_data->use_sleep && - (ts->platform_data->power_state != CY_ACTIVE_STATE)) { - if (ts->platform_data->resume) - retval = ts->platform_data->resume(ts->client); - else - retval = cyttsp_regulator_lpm(ts, false); - /* take TTSP device out of bootloader mode; - * switch back to TrueTouch operational mode */ - if (!(retval < CY_OK)) { - int tries = 0; - do { - msleep(100); - retval = i2c_smbus_write_i2c_block_data( - ts->client, CY_REG_BASE, - sizeof(bl_cmd), bl_cmd); - if (retval == CY_OK) - break; - } while (tries++ < 2); - /* wait for TTSP Device to complete - * switch to Operational mode */ - tries = 0; - do { - msleep(100); - cyttsp_putbl(ts, 16, false, false, false); - } while (GET_BOOTLOADERMODE(g_bl_data.bl_status) && - tries++ < 2); - cyttsp_putbl(ts, 16, true, false, false); - } - } - - if (!(retval < CY_OK) && - (GET_HSTMODE(g_bl_data.bl_file) == CY_OK)) { - ts->platform_data->power_state = CY_ACTIVE_STATE; - - /* re-enable the timer after resuming */ - if (ts->client->irq == 0) - mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT); - } else - retval = -ENODEV; - - ts->is_suspended = false; - cyttsp_debug("Wake Up %s\n", \ - (retval < CY_OK) ? "FAIL" : "PASS"); - - return retval; -} - -/* Function to manage low power suspend */ -static int cyttsp_suspend(struct device *dev) -{ - struct cyttsp *ts = dev_get_drvdata(dev); - u8 sleep_mode = CY_OK; - int retval = CY_OK; - - cyttsp_debug("Enter Sleep\n"); - - if (device_may_wakeup(dev)) { - if (ts->client->irq) - enable_irq_wake(ts->client->irq); - return 0; - } - - if (ts->is_suspended == true) { - pr_err("%s: in sleep state\n", __func__); - return 0; - } - - mutex_lock(&ts->mutex); - if (ts->cyttsp_fwloader_mode) { - pr_err("%s:firmware upgrade mode:" - "suspend not allowed\n", __func__); - mutex_unlock(&ts->mutex); - return -EBUSY; - } - mutex_unlock(&ts->mutex); - - - if (ts->client->irq == 0) - del_timer(&ts->timer); - else - disable_irq(ts->client->irq); - - if (!(retval < CY_OK)) { - if (ts->platform_data->use_sleep && - (ts->platform_data->power_state == CY_ACTIVE_STATE)) { - if (ts->platform_data->suspend) { - retval = - ts->platform_data->suspend(ts->client); - } else { - retval = cyttsp_regulator_lpm(ts, true); - } - if (ts->platform_data->use_sleep & CY_USE_DEEP_SLEEP_SEL) - sleep_mode = CY_DEEP_SLEEP_MODE; - else - sleep_mode = CY_LOW_PWR_MODE; - - if (!(retval < CY_OK)) { - retval = - i2c_smbus_write_i2c_block_data(ts->client, - CY_REG_BASE, - sizeof(sleep_mode), &sleep_mode); - } - } - } - - if (!(retval < CY_OK)) { - if (sleep_mode == CY_DEEP_SLEEP_MODE) - ts->platform_data->power_state = CY_SLEEP_STATE; - else if (sleep_mode == CY_LOW_PWR_MODE) - ts->platform_data->power_state = CY_LOW_PWR_STATE; - } - - ts->is_suspended = true; - cyttsp_debug("Sleep Power state is %s\n", \ - (ts->platform_data->power_state == CY_ACTIVE_STATE) ? \ - "ACTIVE" : \ - ((ts->platform_data->power_state == CY_SLEEP_STATE) ? \ - "SLEEP" : "LOW POWER")); - - return retval; -} -#endif - -/* registered in driver struct */ -static int cyttsp_remove(struct i2c_client *client) -{ - /* clientdata registered on probe */ - struct cyttsp *ts = i2c_get_clientdata(client); - int err; - - cyttsp_alert("Unregister\n"); - - pm_runtime_set_suspended(&client->dev); - pm_runtime_disable(&client->dev); - - device_init_wakeup(&client->dev, 0); - device_remove_file(&ts->client->dev, &dev_attr_irq_enable); - device_remove_file(&client->dev, &dev_attr_cyttsp_fw_ver); - device_remove_file(&client->dev, &dev_attr_cyttsp_update_fw); - device_remove_file(&client->dev, &dev_attr_cyttsp_force_update_fw); - device_remove_file(&client->dev, &dev_attr_cyttsp_fw_name); - debugfs_remove_recursive(ts->dir); - - /* free up timer or irq */ - if (ts->client->irq == 0) { - err = del_timer(&ts->timer); - if (err < CY_OK) - cyttsp_alert("error: failed to delete timer\n"); - } else - free_irq(client->irq, ts); - - if (ts->platform_data->regulator_info) - cyttsp_power_device(ts, false); - -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&ts->early_suspend); -#endif /* CONFIG_HAS_EARLYSUSPEND */ - - mutex_destroy(&ts->mutex); - - if (gpio_is_valid(ts->platform_data->sleep_gpio)) { - gpio_direction_output(ts->platform_data->sleep_gpio, 1); - gpio_free(ts->platform_data->sleep_gpio); - } - - if (gpio_is_valid(ts->platform_data->resout_gpio)) { - gpio_direction_output(ts->platform_data->resout_gpio, 0); - gpio_free(ts->platform_data->resout_gpio); - } - - if (gpio_is_valid(ts->platform_data->irq_gpio)) - gpio_free(ts->platform_data->irq_gpio); - - /* housekeeping */ - kfree(ts); - - cyttsp_alert("Leaving\n"); - - return 0; -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void cyttsp_early_suspend(struct early_suspend *handler) -{ - struct cyttsp *ts; - - ts = container_of(handler, struct cyttsp, early_suspend); - cyttsp_suspend(&ts->client->dev); -} - -static void cyttsp_late_resume(struct early_suspend *handler) -{ - struct cyttsp *ts; - - ts = container_of(handler, struct cyttsp, early_suspend); - cyttsp_resume(&ts->client->dev); -} -#endif /* CONFIG_HAS_EARLYSUSPEND */ - -static int cyttsp_init(void) -{ - int ret; - - cyttsp_info("Cypress TrueTouch(R) Standard Product\n"); - cyttsp_info("I2C Touchscreen Driver (Built %s @ %s)\n", \ - __DATE__, __TIME__); - - ret = i2c_add_driver(&cyttsp_driver); - - return ret; -} - -static void cyttsp_exit(void) -{ - return i2c_del_driver(&cyttsp_driver); -} - -module_init(cyttsp_init); -module_exit(cyttsp_exit); -MODULE_FIRMWARE("cyttsp.fw"); - diff --git a/drivers/input/touchscreen/cyttsp_fw.h b/drivers/input/touchscreen/cyttsp_fw.h deleted file mode 100644 index f14153e0dec80a3e6d58473768f94615ddbe246a..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/cyttsp_fw.h +++ /dev/null @@ -1,4307 +0,0 @@ -/* Header file for: - * Cypress TrueTouch(TM) Standard Product touchscreen drivers. - * drivers/input/touchscreen/cyttsp_fw.h - * - * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc. - * - * 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Cypress reserves the right to make changes without further notice - * to the materials described herein. Cypress does not assume any - * liability arising out of the application described herein. - * - * Contact Cypress Semiconductor at www.cypress.com - * - */ - -#define CYTTSP_BL_OST_LEN 1 -#define CYTTSP_BL_CMD_LEN 2 -#define CYTTSP_BL_KEY_LEN 8 -#define CYTTSP_LD_ADR_LEN 2 -#define CYTTSP_LD_DAT_LEN 64 -#define CYTTSP_LD_CHK_LEN 2 -#define CYTTSP_LD_BLK_LEN (CYTTSP_BL_OST_LEN + CYTTSP_BL_CMD_LEN + CYTTSP_BL_KEY_LEN + \ - CYTTSP_LD_ADR_LEN + CYTTSP_LD_DAT_LEN + CYTTSP_LD_CHK_LEN) - -typedef struct cyttsp_ld_blk_ray_t { - unsigned short Record; - unsigned short Length; - unsigned char Command; - unsigned short Address; - unsigned char Block[CYTTSP_LD_BLK_LEN]; -} cyttsp_ld_blk_ray, *pcyttsp_ld_blk_ray; - -cyttsp_ld_blk_ray cyttsp_fw[] = { - { - 0, - 11, - 0x38, - -1, - { - 0x00, 0xFF, 0x38, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 - } - }, - { - 1, - 79, - 0x39, - 0x002C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x2C, 0x40, 0x7D, 0x0B, 0x68, 0x30, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x7D, 0x10, 0x12, 0x7E, 0x7D, 0x10, 0x36, 0x7E, 0x7E, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x7D, 0x1F, 0x2A, 0x7E, 0x7E, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x7D, 0x20, 0x70, 0x7E, 0x7E, 0x30, 0x30, 0x30, 0x5B, 0x36 - } - }, - { - 2, - 79, - 0x39, - 0x002D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x2D, 0x7E, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x7E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x40, 0x43, 0xE6, 0x02, 0x40, 0x70, 0xCF, 0x71, 0x10, 0x62, 0xE3, 0x02, 0x70, 0xCF, 0x41, 0xFF, 0xEF, 0x50, 0x80, 0x4E, 0x5D, 0xD5, 0x08, 0x62, 0x44, 0x09 - } - }, - { - 3, - 79, - 0x39, - 0x002E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x2E, 0xD5, 0x00, 0x55, 0xFA, 0x01, 0x40, 0x50, 0x06, 0x55, 0xF8, 0x3A, 0x7C, 0x00, 0x60, 0x40, 0x40, 0x70, 0xCF, 0x71, 0x10, 0x51, 0xFA, 0x60, 0xE8, 0x70, 0xCF, 0x18, 0x60, 0xD5, 0x55, 0xF8, 0x00, 0x55, 0xF9, 0x00, 0x70, 0xCF, 0x71, 0x10, 0x41, 0x9F, 0xFE, 0x70, 0xCF, 0x62, 0xE3, 0x38, 0x62, 0xD1, 0x0F, 0x50, 0x00, 0x4E, 0x62, 0xD3, 0x0F, 0x62, 0xD0, 0x00, 0x62, 0xD5, 0x00, 0x62, 0xD4, 0x35, 0xEC - } - }, - { - 4, - 79, - 0x39, - 0x002F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x2F, 0x00, 0x71, 0xC0, 0x7C, 0x0F, 0x76, 0x62, 0xD0, 0x00, 0x50, 0x0F, 0x57, 0x74, 0x08, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x4B, 0x51, 0xE9, 0x80, 0x04, 0x75, 0x09, 0x00, 0x62, 0xE3, 0x00, 0x08, 0x28, 0x60, 0xD5, 0x74, 0xA0, 0x4B, 0x18, 0x75, 0x09, 0x00, 0x08, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x08, 0x28, 0xA0, 0x1C, 0x53, 0xE8, 0x18, 0x75, 0x09, 0x00, 0x08, 0x28, 0xCD, 0x1D - } - }, - { - 5, - 79, - 0x39, - 0x0030, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x30, 0x3F, 0xE9, 0x47, 0xE9, 0xFF, 0xB0, 0x06, 0x5D, 0xD5, 0x74, 0x60, 0xD5, 0x18, 0x7A, 0xE8, 0xBF, 0xEB, 0x8F, 0xC9, 0x18, 0x75, 0x09, 0x00, 0x08, 0x28, 0x53, 0xE8, 0x50, 0x00, 0x3F, 0xE9, 0x47, 0xE9, 0xFF, 0xB0, 0x08, 0x5D, 0xD5, 0x74, 0x60, 0xD5, 0x50, 0x00, 0x7A, 0xE8, 0xBF, 0xEF, 0x18, 0x8F, 0xAA, 0x18, 0x70, 0xCF, 0x71, 0x10, 0x62, 0xEC, 0x10, 0x43, 0xE3, 0x00, 0x70, 0xCF, 0x62, 0x4D, 0x1E - } - }, - { - 6, - 79, - 0x39, - 0x0031, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x31, 0xE0, 0x00, 0x41, 0xFE, 0xE7, 0x43, 0xFE, 0x10, 0x70, 0xCF, 0x71, 0x10, 0x62, 0xE0, 0x53, 0x70, 0xCF, 0x62, 0xE2, 0x00, 0x7C, 0x3E, 0xD3, 0x8F, 0xFF, 0x7F, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xE9, 0x57 - } - }, - { - 7, - 79, - 0x39, - 0x0032, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x32, 0x5D, 0x04, 0x73, 0x21, 0xA0, 0xBF, 0xFA, 0x5D, 0x04, 0x73, 0x21, 0xA0, 0xBF, 0xF3, 0x5D, 0x04, 0x73, 0x21, 0xA0, 0xBF, 0xEC, 0x50, 0x18, 0x49, 0x04, 0x20, 0xAF, 0xE5, 0x60, 0xFF, 0x49, 0xC9, 0x01, 0xB0, 0x1A, 0x41, 0xD6, 0xFE, 0x70, 0xCF, 0x71, 0x10, 0x41, 0x04, 0x5F, 0x70, 0xCF, 0x43, 0xD6, 0x01, 0x40, 0x70, 0xCF, 0x71, 0x10, 0x43, 0x04, 0xA0, 0x70, 0xCF, 0x7F, 0x30, 0x30, 0x30, 0x81, 0x88 - } - }, - { - 8, - 79, - 0x39, - 0x0033, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x87 - } - }, - { - 9, - 79, - 0x39, - 0x0034, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x34, 0x0A, 0x20, 0x20, 0x51, 0x55, 0x41, 0x4C, 0x43, 0x4F, 0x4D, 0x4D, 0x20, 0x56, 0x50, 0x30, 0x34, 0x33, 0x2D, 0x48, 0x32, 0x20, 0x54, 0x4D, 0x41, 0x33, 0x30, 0x30, 0x45, 0x20, 0x46, 0x69, 0x72, 0x6D, 0x77, 0x61, 0x72, 0x65, 0x20, 0x49, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x42, 0x6C, 0x6F, 0x63, 0x6B, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x56, 0x99, 0xBA - } - }, - { - 10, - 79, - 0x39, - 0x0035, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x35, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x30, 0x32, 0x2E, 0x30, 0x34, 0x2E, 0x30, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x70, 0x69, 0x6C, 0x65, 0x64, 0x20, 0x4A, 0x75, 0x6C, 0x20, 0x31, 0x34, 0x20, 0x32, 0x30, 0x31, 0x30, 0x20, 0x31, 0x32, 0x3A, 0x35, 0x33, 0x3A, 0x31, 0x33, 0x0A, 0x20, 0x20, 0x45, 0x6E, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x49, 0x44, 0x20, 0x42, 0x6C, 0x6F, 0x63, 0x6B, 0x0A, 0x0D, 0xA3 - } - }, - { - 11, - 79, - 0x39, - 0x0036, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x36, 0x00, 0x03, 0x09, 0x10, 0x16, 0x06, 0x02, 0x02, 0x02, 0x01, 0xF4, 0x00, 0x0A, 0x01, 0xF4, 0x00, 0x0A, 0x01, 0xF4, 0x00, 0x0A, 0x14, 0x19, 0x19, 0x00, 0x32, 0x02, 0x14, 0x01, 0x01, 0xE0, 0x03, 0x98, 0x0C, 0x0C, 0x00, 0x10, 0x10, 0x08, 0x00, 0x04, 0x08, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x04, 0x08, 0x00, 0x00, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x01, 0x80, 0x10, 0x01, 0x80, 0x50, 0x2A - } - }, - { - 12, - 79, - 0x39, - 0x0037, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x37, 0x01, 0x40, 0x04, 0x02, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x02, 0x40, 0x08, 0x80, 0x20, 0x80, 0x08, 0x04, 0x02, 0x40, 0x20, 0x23, 0x04, 0x21, 0x20, 0x22, 0x00, 0x61, 0x00, 0xFD, 0x00, 0xA0, 0x00, 0xA1, 0x00, 0xA2, 0x00, 0xA3, 0x00, 0xA8, 0x00, 0xA7, 0x00, 0x7C, 0x00, 0x7A, 0x00, 0x7B, 0x00, 0x79, 0x00, 0xCA, 0x24, 0xD6, 0x04, 0xCF, 0x00, 0xC8, 0x00, 0xA9, 0x00, 0xB7, 0x00, 0xB0, 0xB3, 0xF1 - } - }, - { - 13, - 79, - 0x39, - 0x0038, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x38, 0xCA, 0xB1, 0x0B, 0xB2, 0x00, 0xB3, 0x33, 0xB4, 0x33, 0xB5, 0x80, 0xB6, 0x00, 0x6C, 0x00, 0x6D, 0x00, 0x6E, 0x00, 0x6F, 0x00, 0xE6, 0x00, 0xE9, 0x00, 0xEC, 0x00, 0xE8, 0x20, 0xEB, 0x00, 0xEE, 0x00, 0xE7, 0x00, 0xEA, 0x00, 0xED, 0x00, 0xFF, 0x23, 0x00, 0x20, 0x20, 0x21, 0x07, 0x22, 0x40, 0x76, 0x00, 0xAF, 0x00, 0xD1, 0x00, 0xA1, 0x00, 0xD3, 0x00, 0xA3, 0x00, 0xD0, 0x00, 0xA0, 0x00, 0x69, 0x5E - } - }, - { - 14, - 79, - 0x39, - 0x0039, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x39, 0xD2, 0x00, 0xA2, 0x00, 0xDC, 0x08, 0xE1, 0xFF, 0xE2, 0x01, 0xDF, 0xFF, 0xDE, 0x02, 0xDD, 0x00, 0x99, 0x00, 0x9C, 0x00, 0xD8, 0x00, 0xD9, 0x00, 0xDA, 0x00, 0xDB, 0x00, 0x9E, 0x00, 0xAC, 0x00, 0xFF, 0x70, 0xCF, 0x62, 0x00, 0x04, 0x70, 0xCF, 0x71, 0x10, 0x62, 0x00, 0xFF, 0x62, 0x01, 0xF6, 0x70, 0xCF, 0x62, 0x02, 0x00, 0x62, 0x01, 0x00, 0x62, 0x04, 0xAB, 0x70, 0xCF, 0x71, 0x10, 0x62, 0xF2, 0x71 - } - }, - { - 15, - 79, - 0x39, - 0x003A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x3A, 0x04, 0xEF, 0x62, 0x05, 0xFC, 0x70, 0xCF, 0x62, 0x06, 0x00, 0x62, 0x05, 0x00, 0x62, 0x08, 0x04, 0x70, 0xCF, 0x71, 0x10, 0x62, 0x08, 0xFF, 0x62, 0x09, 0x8F, 0x70, 0xCF, 0x62, 0x0A, 0x00, 0x62, 0x09, 0x00, 0x62, 0x0C, 0x00, 0x70, 0xCF, 0x71, 0x10, 0x62, 0x0C, 0xFF, 0x62, 0x0D, 0xFF, 0x70, 0xCF, 0x62, 0x0E, 0x00, 0x62, 0x0D, 0x00, 0x62, 0x10, 0x00, 0x70, 0xCF, 0x71, 0x10, 0x62, 0x10, 0xD6, 0x3A - } - }, - { - 16, - 79, - 0x39, - 0x003B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x3B, 0xFF, 0x62, 0x11, 0xEF, 0x70, 0xCF, 0x62, 0x12, 0x00, 0x62, 0x11, 0x00, 0x70, 0xCF, 0x7F, 0xC1, 0x00, 0xC2, 0x00, 0xC3, 0x00, 0x80, 0x00, 0x81, 0x00, 0x82, 0x00, 0x83, 0x00, 0xA8, 0x00, 0xA9, 0x00, 0xAA, 0x00, 0x84, 0x00, 0x85, 0x00, 0x86, 0x00, 0x87, 0x00, 0xAB, 0x00, 0xAC, 0x00, 0xAD, 0x00, 0x88, 0x00, 0x89, 0x00, 0x8A, 0x00, 0x8B, 0x00, 0xAE, 0x00, 0xAF, 0x00, 0xB0, 0x00, 0x8C, 0x65, 0x59 - } - }, - { - 17, - 79, - 0x39, - 0x003C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x3C, 0x00, 0x8D, 0x00, 0x8E, 0x00, 0x8F, 0x00, 0xB1, 0x00, 0xB2, 0x00, 0xB3, 0x00, 0x90, 0x00, 0x91, 0x00, 0x92, 0x00, 0x93, 0x00, 0xB4, 0x00, 0xB5, 0x00, 0xB6, 0x00, 0x94, 0x00, 0x95, 0x00, 0x96, 0x00, 0x97, 0x00, 0xB7, 0x00, 0xB8, 0x00, 0xB9, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9A, 0x00, 0x9B, 0x00, 0xBA, 0x00, 0xBB, 0x00, 0xBC, 0x00, 0x9C, 0x00, 0x9D, 0x00, 0x9E, 0x00, 0x9F, 0x00, 0xBD, 0x6D, 0x6A - } - }, - { - 18, - 79, - 0x39, - 0x003D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x3D, 0x00, 0xBE, 0x00, 0xBF, 0x00, 0xA4, 0x00, 0xC0, 0x00, 0xFF, 0x11, 0x06, 0x12, 0x02, 0x13, 0x87, 0x14, 0x03, 0x1B, 0x30, 0x1C, 0x00, 0x19, 0x24, 0x1A, 0x30, 0x0A, 0x3C, 0x0B, 0x3C, 0xFF, 0x01, 0x02, 0x06, 0x00, 0x01, 0x02, 0x01, 0x00, 0x02, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x02, 0x01, 0x00, 0x73, 0x97, 0x55, 0xAE, 0x04, 0x55, 0xAF, 0xAB, 0x55, 0xB0, 0x04, 0x55, 0x6F, 0x6F - } - }, - { - 19, - 79, - 0x39, - 0x003E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x3E, 0xB1, 0x00, 0x55, 0xB2, 0x00, 0x7C, 0x0F, 0x8C, 0x7C, 0x0E, 0x61, 0x7F, 0x10, 0x70, 0xCF, 0x50, 0x00, 0x08, 0x50, 0x0D, 0x57, 0xD5, 0x7C, 0x0F, 0xBF, 0x18, 0x50, 0x01, 0x08, 0x50, 0x0E, 0x57, 0x28, 0x7C, 0x0F, 0xBF, 0x18, 0x50, 0x02, 0x08, 0x50, 0x0E, 0x57, 0xCF, 0x7C, 0x0F, 0xBF, 0x18, 0x50, 0x03, 0x08, 0x50, 0x0F, 0x57, 0x4A, 0x7C, 0x0F, 0xBF, 0x18, 0x70, 0xCF, 0x20, 0x7F, 0x38, 0x76, 0x7E - } - }, - { - 20, - 79, - 0x39, - 0x003F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x3F, 0x02, 0x10, 0x08, 0x4F, 0x52, 0xF9, 0x64, 0x08, 0x64, 0x03, 0x00, 0x54, 0xFC, 0x18, 0x18, 0x20, 0x70, 0xCF, 0x62, 0xE3, 0x00, 0x10, 0x08, 0x28, 0x39, 0xFF, 0xA0, 0x30, 0x4F, 0x54, 0xFD, 0x52, 0xFC, 0x39, 0x00, 0xA0, 0x13, 0x11, 0x06, 0xE0, 0x01, 0x70, 0xCF, 0x71, 0x10, 0x80, 0x09, 0x70, 0xCF, 0x71, 0x20, 0x80, 0x03, 0x71, 0x30, 0x18, 0x20, 0x75, 0x09, 0x00, 0x10, 0x08, 0x28, 0x4F, 0x47, 0x21 - } - }, - { - 21, - 79, - 0x39, - 0x0040, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x40, 0x59, 0xFD, 0x61, 0x00, 0x18, 0x20, 0x75, 0x09, 0x00, 0x8F, 0xC6, 0x38, 0xFC, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x08, 0x10, 0x5D, 0xD0, 0x08, 0x5D, 0xD3, 0x08, 0x5D, 0xD4, 0x08, 0x5D, 0xD5, 0x08, 0x70, 0x3F, 0x71, 0x80, 0x62, 0xD0, 0x00, 0x18, 0x60, 0xD5, 0x18, 0x60, 0xD4, 0x18, 0x60, 0xD3, 0x18, 0x60, 0xD0, 0x20, 0x18, 0x7E, 0x08, 0x51, 0x54, 0x04, 0x01, 0x51, 0x53, 0x0C, 0x00, 0x51, 0xB4, 0xFC - } - }, - { - 22, - 79, - 0x39, - 0x0041, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x41, 0x54, 0x04, 0x03, 0x51, 0x53, 0x0C, 0x02, 0x51, 0x54, 0x04, 0x05, 0x51, 0x53, 0x0C, 0x04, 0x51, 0x54, 0x04, 0x07, 0x51, 0x53, 0x0C, 0x06, 0x18, 0x08, 0x51, 0x0B, 0x04, 0x0D, 0x51, 0x0A, 0x0C, 0x0C, 0x41, 0x23, 0xFE, 0x55, 0xBB, 0x00, 0x51, 0x55, 0x60, 0x21, 0x62, 0xDB, 0xFE, 0x43, 0x23, 0x01, 0x18, 0x7E, 0x05, 0x62, 0xD0, 0x00, 0x51, 0x42, 0x08, 0x26, 0x42, 0xEF, 0x7C, 0x19, 0x73, 0xD7, 0x43 - } - }, - { - 23, - 79, - 0x39, - 0x0042, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x42, 0x7C, 0x19, 0x73, 0x62, 0xD0, 0x00, 0x18, 0x53, 0x42, 0x70, 0xBF, 0x57, 0x98, 0x62, 0xD3, 0x05, 0x52, 0x00, 0x73, 0x54, 0x00, 0x62, 0xD3, 0x05, 0x54, 0x00, 0x79, 0xDF, 0xF1, 0x7C, 0x19, 0x64, 0x7C, 0x19, 0x64, 0x70, 0xBF, 0x57, 0x98, 0x62, 0xD3, 0x05, 0x52, 0x00, 0x62, 0xD3, 0x08, 0x54, 0x00, 0x62, 0xD3, 0x07, 0x56, 0x00, 0x00, 0x79, 0xDF, 0xEE, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x7F, 0x12, 0xBA - } - }, - { - 24, - 79, - 0x39, - 0x0043, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x43, 0x5C, 0x51, 0x41, 0xE0, 0x01, 0x80, 0x13, 0x80, 0x08, 0x80, 0x01, 0x5B, 0x9F, 0xF1, 0x80, 0x77, 0x62, 0xD3, 0x05, 0x51, 0x57, 0x54, 0x00, 0x80, 0x6E, 0x62, 0xD3, 0x05, 0x51, 0x57, 0x73, 0x53, 0x46, 0x47, 0x42, 0x07, 0xB0, 0x05, 0x54, 0x00, 0x80, 0x15, 0x47, 0x42, 0x04, 0xA0, 0x10, 0x62, 0xD3, 0x05, 0x3B, 0x00, 0xA0, 0x09, 0xC0, 0x04, 0x78, 0x80, 0x02, 0x74, 0x54, 0x00, 0x62, 0xD3, 0xA3, 0xDD - } - }, - { - 25, - 79, - 0x39, - 0x0044, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x44, 0x08, 0x13, 0x00, 0xD0, 0x0E, 0x62, 0xD3, 0x02, 0x56, 0x00, 0x00, 0x3C, 0x0E, 0x00, 0xB0, 0x37, 0x80, 0x16, 0x62, 0xD3, 0x02, 0x08, 0x11, 0x05, 0xD0, 0x03, 0x50, 0x00, 0x54, 0x00, 0x18, 0x3A, 0x15, 0xD0, 0x24, 0x51, 0x0E, 0xB0, 0x20, 0x62, 0xD3, 0x08, 0x52, 0x00, 0x53, 0x45, 0x51, 0x47, 0x12, 0x45, 0x1E, 0x45, 0x00, 0x62, 0xD3, 0x07, 0x03, 0x00, 0x0E, 0x45, 0x00, 0x54, 0x00, 0x51, 0x53, 0x3E - } - }, - { - 26, - 79, - 0x39, - 0x0045, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x45, 0x45, 0x62, 0xD3, 0x08, 0x54, 0x00, 0x7F, 0x7C, 0x21, 0xD2, 0x08, 0x18, 0x7F, 0x50, 0xFF, 0x3C, 0x10, 0x80, 0xC0, 0x11, 0x34, 0x12, 0x76, 0x12, 0x34, 0x11, 0x0E, 0x11, 0x00, 0x34, 0x10, 0x0E, 0x10, 0x00, 0x53, 0x0F, 0x50, 0x00, 0x53, 0x48, 0x53, 0x49, 0x53, 0x4A, 0x53, 0x4B, 0x55, 0x46, 0x18, 0x65, 0x12, 0x6B, 0x11, 0x6B, 0x10, 0x6B, 0x4B, 0x6B, 0x4A, 0x6B, 0x49, 0x51, 0x4B, 0x1A, 0xFD, 0x93 - } - }, - { - 27, - 79, - 0x39, - 0x0046, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x46, 0x14, 0x51, 0x4A, 0x1A, 0x13, 0x51, 0x49, 0x19, 0x00, 0xC0, 0x0D, 0x53, 0x49, 0x51, 0x14, 0x14, 0x4B, 0x51, 0x13, 0x1C, 0x4A, 0x76, 0x12, 0x7A, 0x46, 0xBF, 0xD7, 0x50, 0xFF, 0x3C, 0x0F, 0x80, 0xC0, 0x11, 0x34, 0x12, 0x76, 0x12, 0x34, 0x11, 0x0E, 0x11, 0x00, 0x34, 0x10, 0x0E, 0x10, 0x00, 0x34, 0x0F, 0x7F, 0x50, 0x00, 0x53, 0x48, 0x53, 0x49, 0x53, 0x4A, 0x53, 0x4B, 0x51, 0x12, 0x04, 0xCE, 0x36 - } - }, - { - 28, - 79, - 0x39, - 0x0047, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x47, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x90, 0x54, 0x90, 0x52, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x90, 0x48, 0x90, 0x46, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x90, 0x3C, 0x90, 0x3A, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x90, 0x30, 0x90, 0x2E, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x90, 0x24, 0x90, 0x22, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0xA3, 0xE1 - } - }, - { - 29, - 79, - 0x39, - 0x0048, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x48, 0x48, 0x90, 0x18, 0x90, 0x16, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x90, 0x0C, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x90, 0x02, 0x90, 0x00, 0x70, 0xFB, 0x6E, 0x48, 0x6E, 0x49, 0x6E, 0x4A, 0x6E, 0x4B, 0x7F, 0x50, 0x00, 0x53, 0x48, 0x53, 0x49, 0x53, 0x4A, 0x53, 0x4B, 0x9F, 0xE9, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x9F, 0xDF, 0x51, 0x12, 0x04, 0x49, 0xC6, 0x28 - } - }, - { - 30, - 79, - 0x39, - 0x0049, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x9F, 0xD5, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x9F, 0xCB, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x9F, 0xC1, 0x9F, 0xBF, 0x9F, 0xBD, 0x9F, 0xBB, 0x9F, 0xB9, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x9F, 0xAF, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x9F, 0xA5, 0x9F, 0xA3, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x32, 0x01 - } - }, - { - 31, - 79, - 0x39, - 0x004A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x4A, 0x9F, 0x99, 0x51, 0x12, 0x04, 0x49, 0x51, 0x11, 0x0C, 0x48, 0x9F, 0x8F, 0x9F, 0x8D, 0x8F, 0x8C, 0x70, 0xBF, 0x62, 0xD0, 0x00, 0x53, 0x44, 0x55, 0x0F, 0x80, 0x55, 0x10, 0x60, 0x55, 0x11, 0x00, 0x62, 0xD3, 0x02, 0x50, 0x10, 0x57, 0x98, 0x54, 0x00, 0x79, 0xDF, 0xFC, 0x62, 0xD3, 0x01, 0x51, 0x0F, 0x57, 0x1A, 0x54, 0xA0, 0x79, 0xDF, 0xFC, 0x55, 0x3D, 0x00, 0x7C, 0x17, 0x18, 0x55, 0x45, 0x6E, 0x7A - } - }, - { - 32, - 79, - 0x39, - 0x004B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x4B, 0x00, 0x62, 0xD3, 0x01, 0x58, 0xA1, 0x51, 0x10, 0x54, 0xC5, 0x62, 0xD3, 0x01, 0x58, 0xA1, 0x51, 0x0F, 0x54, 0xA0, 0x55, 0x4A, 0x80, 0x52, 0xC5, 0x70, 0xCF, 0x71, 0x20, 0x60, 0xA5, 0x70, 0xCF, 0x62, 0xD3, 0x01, 0x58, 0xA1, 0x52, 0xA0, 0x60, 0xFD, 0x55, 0x4B, 0x10, 0x7C, 0x1B, 0x87, 0x51, 0xA0, 0x01, 0x00, 0x5C, 0x62, 0xD3, 0x02, 0x51, 0x45, 0x7C, 0x19, 0x8F, 0x43, 0xA4, 0x08, 0x47, 0x37, 0x0D - } - }, - { - 33, - 79, - 0x39, - 0x004C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x4C, 0x9F, 0x01, 0xA0, 0x03, 0x71, 0x01, 0x70, 0xCF, 0x7C, 0x1C, 0x8E, 0x7C, 0x1C, 0xE3, 0x55, 0x56, 0x00, 0x55, 0x57, 0xFF, 0x55, 0x48, 0x07, 0x62, 0xD3, 0x00, 0x58, 0x48, 0x3D, 0x70, 0x00, 0xA0, 0x2A, 0x52, 0x68, 0x08, 0x51, 0x48, 0x64, 0x5C, 0x52, 0x59, 0x20, 0x62, 0xD3, 0x02, 0x3A, 0x44, 0xD0, 0x06, 0x51, 0x4B, 0x73, 0x25, 0x00, 0x51, 0x4B, 0x67, 0x2D, 0x00, 0x52, 0x00, 0x3A, 0x56, 0x92, 0xC4 - } - }, - { - 34, - 79, - 0x39, - 0x004D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x4D, 0xC0, 0x03, 0x53, 0x56, 0x3A, 0x57, 0xD0, 0x03, 0x53, 0x57, 0x7A, 0x48, 0xDF, 0xCA, 0x68, 0x4B, 0xDF, 0x9B, 0x51, 0x4A, 0xA0, 0x42, 0x47, 0x11, 0x01, 0xB0, 0x3D, 0x58, 0xA1, 0x62, 0xD3, 0x01, 0x51, 0x57, 0x02, 0x56, 0x39, 0x1F, 0xA0, 0x30, 0xD0, 0x06, 0x51, 0x4A, 0x73, 0x25, 0xA0, 0x51, 0x4A, 0x67, 0x21, 0x7F, 0x2D, 0xA0, 0x68, 0x4A, 0x26, 0x4A, 0x7F, 0x55, 0x48, 0x07, 0x62, 0xD3, 0xBE, 0x1D - } - }, - { - 35, - 79, - 0x39, - 0x004E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x4E, 0x00, 0x58, 0x48, 0x3D, 0x70, 0x00, 0xA0, 0x0A, 0x52, 0x68, 0x5C, 0x62, 0xD3, 0x02, 0x56, 0x00, 0x10, 0x7A, 0x48, 0xDF, 0xEA, 0x8F, 0x4A, 0x47, 0x11, 0x02, 0xB0, 0x32, 0x3C, 0x56, 0x1F, 0xC0, 0x2D, 0x62, 0xD3, 0x01, 0x58, 0xA1, 0x3D, 0xC5, 0x40, 0xA0, 0x23, 0x17, 0xC5, 0x20, 0x55, 0x48, 0x07, 0x62, 0xD3, 0x00, 0x62, 0xD3, 0x00, 0x58, 0x48, 0x3D, 0x70, 0x00, 0xA0, 0x0A, 0x52, 0x68, 0xD7, 0x50 - } - }, - { - 36, - 79, - 0x39, - 0x004F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x4F, 0x5C, 0x62, 0xD3, 0x02, 0x56, 0x00, 0x10, 0x7A, 0x48, 0xDF, 0xEA, 0x8E, 0xFE, 0x76, 0xA1, 0x51, 0x45, 0x7C, 0x1A, 0xE9, 0x76, 0x45, 0x3C, 0x45, 0x03, 0xCE, 0xE7, 0x7C, 0x17, 0x55, 0x76, 0x3D, 0x3C, 0x3D, 0x09, 0xCE, 0xD7, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x70, 0xBF, 0x62, 0xD0, 0x00, 0x55, 0x44, 0x99, 0x53, 0x0F, 0x5A, 0x10, 0x55, 0x11, 0x03, 0x8E, 0xA6, 0x70, 0xBF, 0x62, 0xD0, 0x00, 0xAE, 0xFF - } - }, - { - 37, - 79, - 0x39, - 0x0050, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x50, 0x55, 0x44, 0x99, 0x53, 0x0F, 0x55, 0x10, 0x60, 0x55, 0x11, 0x01, 0x8E, 0x94, 0x70, 0xBF, 0x62, 0xD0, 0x00, 0x55, 0x44, 0x99, 0x55, 0x0F, 0x80, 0x53, 0x10, 0x55, 0x11, 0x02, 0x8E, 0x82, 0x90, 0x11, 0x55, 0x38, 0x03, 0x51, 0x38, 0x90, 0x1A, 0x76, 0x38, 0x3C, 0x38, 0x0A, 0xCF, 0xF6, 0x90, 0x66, 0x7F, 0x62, 0xD5, 0x02, 0x62, 0xD0, 0x00, 0x55, 0x34, 0x99, 0x55, 0x0E, 0x00, 0x55, 0x33, 0x76, 0x90 - } - }, - { - 38, - 79, - 0x39, - 0x0051, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x51, 0x01, 0x7F, 0x70, 0xBF, 0x62, 0xD3, 0x02, 0x62, 0xD5, 0x02, 0x62, 0xD0, 0x00, 0x11, 0x02, 0x53, 0x45, 0x51, 0x33, 0x02, 0x4C, 0x53, 0x33, 0x53, 0x32, 0x55, 0x44, 0x01, 0x58, 0x32, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x24, 0x3B, 0x12, 0xC0, 0x20, 0x3B, 0x11, 0xC0, 0x1C, 0x3B, 0x10, 0xC0, 0x18, 0x3B, 0x01, 0xC0, 0x14, 0x78, 0x3B, 0xFF, 0xC0, 0x0F, 0x3B, 0xF0, 0xC0, 0x0B, 0x3B, 0xEF, 0xC0, 0x6C, 0x7D - } - }, - { - 39, - 79, - 0x39, - 0x0052, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x52, 0x07, 0x3B, 0xEE, 0xC0, 0x03, 0x91, 0x84, 0x76, 0x32, 0x76, 0x44, 0x51, 0x4C, 0x78, 0x3A, 0x44, 0xBF, 0xCB, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x70, 0xBF, 0x62, 0xD3, 0x02, 0x62, 0xD5, 0x02, 0x62, 0xD0, 0x00, 0x55, 0x32, 0x01, 0x55, 0x44, 0x01, 0x55, 0x45, 0x00, 0x58, 0x32, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x18, 0x3B, 0x12, 0xC0, 0x14, 0x3B, 0x11, 0xC0, 0x10, 0x3B, 0x10, 0xC0, 0x0C, 0x3B, 0x06, 0xB2 - } - }, - { - 40, - 79, - 0x39, - 0x0053, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x53, 0x01, 0xC0, 0x08, 0x78, 0x3B, 0xFF, 0xC0, 0x03, 0x91, 0x41, 0x76, 0x32, 0x76, 0x44, 0x51, 0x4C, 0x78, 0x3A, 0x44, 0xBF, 0xD7, 0x55, 0x44, 0x01, 0x51, 0x4D, 0x78, 0x53, 0x45, 0x51, 0x4E, 0x12, 0x4C, 0x74, 0x74, 0x53, 0x32, 0x58, 0x32, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x18, 0x3B, 0x01, 0xC0, 0x14, 0x78, 0x3B, 0xFF, 0xC0, 0x0F, 0x3B, 0xF0, 0xC0, 0x0B, 0x3B, 0xEF, 0xC0, 0x07, 0x3B, 0xEE, 0xF2, 0x8B - } - }, - { - 41, - 79, - 0x39, - 0x0054, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x54, 0xC0, 0x03, 0x91, 0x07, 0x76, 0x32, 0x76, 0x44, 0x51, 0x4C, 0x78, 0x3A, 0x44, 0xBF, 0xD7, 0x51, 0x4C, 0x78, 0x53, 0x44, 0x55, 0x45, 0x01, 0x02, 0x4C, 0x53, 0x32, 0x58, 0x32, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x18, 0x3B, 0x11, 0xC0, 0x14, 0x3B, 0x10, 0xC0, 0x10, 0x78, 0x3B, 0xFF, 0xC0, 0x0B, 0x3B, 0xEF, 0xC0, 0x07, 0x3B, 0xEE, 0xC0, 0x03, 0x90, 0xD1, 0x51, 0x4C, 0x04, 0x32, 0x76, 0x45, 0x88, 0xB8 - } - }, - { - 42, - 79, - 0x39, - 0x0055, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x55, 0x51, 0x4D, 0x78, 0x3A, 0x45, 0xBF, 0xD5, 0x55, 0x44, 0x00, 0x55, 0x45, 0x01, 0x51, 0x4C, 0x53, 0x32, 0x58, 0x32, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x18, 0x3B, 0x12, 0xC0, 0x14, 0x3B, 0x11, 0xC0, 0x10, 0x3B, 0x01, 0xC0, 0x0C, 0x78, 0x3B, 0xF0, 0xC0, 0x07, 0x3B, 0xEF, 0xC0, 0x03, 0x90, 0x9B, 0x51, 0x4C, 0x04, 0x32, 0x76, 0x45, 0x51, 0x4D, 0x78, 0x3A, 0x45, 0xBF, 0xD5, 0x50, 0x00, 0x53, 0xA4, 0xF1 - } - }, - { - 43, - 79, - 0x39, - 0x0056, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x56, 0x44, 0x53, 0x45, 0x55, 0x32, 0x00, 0x5C, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x0F, 0x3B, 0x12, 0xC0, 0x0B, 0x3B, 0x11, 0xC0, 0x07, 0x3B, 0x01, 0xC0, 0x03, 0x90, 0x70, 0x55, 0x44, 0x00, 0x51, 0x4D, 0x78, 0x53, 0x45, 0x51, 0x4E, 0x12, 0x4C, 0x74, 0x53, 0x32, 0x5C, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x10, 0x3B, 0x01, 0xC0, 0x0C, 0x78, 0x3B, 0xF0, 0xC0, 0x07, 0x3B, 0xEF, 0xC0, 0x03, 0x90, 0x4B, 0x9F, 0xE8 - } - }, - { - 44, - 79, - 0x39, - 0x0057, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x57, 0x55, 0x45, 0x00, 0x51, 0x4C, 0x78, 0x53, 0x44, 0x53, 0x32, 0x5C, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x10, 0x3B, 0x11, 0xC0, 0x0C, 0x3B, 0x10, 0xC0, 0x08, 0x78, 0x3B, 0xFF, 0xC0, 0x03, 0x90, 0x2B, 0x51, 0x4D, 0x53, 0x45, 0x51, 0x4C, 0x53, 0x44, 0x51, 0x4E, 0x7A, 0x44, 0x7A, 0x45, 0x53, 0x32, 0x5C, 0x52, 0x00, 0x3A, 0x16, 0xC0, 0x10, 0x78, 0x3B, 0xFF, 0xC0, 0x0B, 0x3B, 0xEF, 0xC0, 0x07, 0x3B, 0x21 - } - }, - { - 45, - 79, - 0x39, - 0x0058, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x58, 0x3B, 0xEE, 0xC0, 0x03, 0x90, 0x05, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x51, 0x43, 0x01, 0x03, 0x3A, 0x0E, 0xC0, 0x0F, 0x51, 0x45, 0x3F, 0x34, 0x51, 0x44, 0x3F, 0x34, 0x51, 0x32, 0x3F, 0x34, 0x76, 0x0E, 0x7F, 0x84, 0x88, 0x8C, 0x90, 0x94, 0x98, 0x9C, 0x9C, 0x9C, 0x10, 0x80, 0x10, 0x80, 0x10, 0x80, 0x10, 0x20, 0x40, 0x62, 0xD0, 0x00, 0x55, 0x4C, 0x11, 0x55, 0x4D, 0x09, 0x55, 0x4E, 0x98, 0xAB, 0x02 - } - }, - { - 46, - 79, - 0x39, - 0x0059, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x59, 0x55, 0x4F, 0x03, 0x55, 0x50, 0x97, 0x55, 0x51, 0x01, 0x55, 0x52, 0xDF, 0x55, 0x15, 0x08, 0x55, 0x16, 0x08, 0x55, 0x17, 0x08, 0x55, 0x42, 0x1C, 0x55, 0x43, 0x04, 0x55, 0xA2, 0x00, 0x55, 0xA3, 0x00, 0x55, 0xA4, 0x48, 0x55, 0xA5, 0x04, 0x55, 0xA6, 0x08, 0x55, 0xA9, 0x01, 0x55, 0xA7, 0x0C, 0x55, 0xA8, 0x05, 0x55, 0x18, 0x04, 0x55, 0xAD, 0x02, 0x55, 0x40, 0x00, 0x55, 0x3F, 0x00, 0x51, 0xE1, 0x6F - } - }, - { - 47, - 79, - 0x39, - 0x005A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x5A, 0xA9, 0xA0, 0x08, 0x51, 0xA7, 0x58, 0xA8, 0x7C, 0x18, 0xF9, 0x70, 0xBF, 0x62, 0xD3, 0x01, 0x57, 0x3F, 0x50, 0x09, 0x28, 0x54, 0xA0, 0x79, 0xDF, 0xF9, 0x70, 0x3F, 0x71, 0xC0, 0x5D, 0xFC, 0x70, 0xCF, 0x71, 0x10, 0x62, 0x76, 0x07, 0x43, 0xE2, 0x08, 0x70, 0xCF, 0x71, 0x20, 0x62, 0xA4, 0x01, 0x62, 0xC0, 0x00, 0x39, 0x04, 0xD0, 0x04, 0x43, 0xC8, 0x04, 0x7C, 0x19, 0x41, 0x70, 0xCF, 0x71, 0x3B, 0x24 - } - }, - { - 48, - 79, - 0x39, - 0x005B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x5B, 0x20, 0x43, 0x81, 0x0E, 0x43, 0x85, 0x0E, 0x43, 0x89, 0x0E, 0x43, 0x8D, 0x0E, 0x43, 0x91, 0x0E, 0x43, 0x95, 0x0E, 0x43, 0x99, 0x0E, 0x43, 0x9D, 0x0E, 0x70, 0xCF, 0x55, 0x9A, 0x07, 0x55, 0x9C, 0x02, 0x55, 0x9E, 0x06, 0x55, 0x9D, 0x00, 0x50, 0x48, 0x57, 0x00, 0x7C, 0x18, 0xB7, 0x71, 0x30, 0x62, 0x1B, 0x40, 0x70, 0xCF, 0x62, 0xA2, 0x10, 0x7C, 0x2A, 0xD8, 0x50, 0x04, 0x7C, 0x18, 0xE7, 0x6B, 0x85 - } - }, - { - 49, - 79, - 0x39, - 0x005C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x5C, 0x70, 0xCF, 0x7C, 0x19, 0x4E, 0x7F, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x00, 0x03, 0x06, 0x09, 0x0C, 0x0F, 0x12, 0x15, 0x18, 0x62, 0xD0, 0x00, 0x70, 0xCF, 0x71, 0x10, 0x51, 0x3D, 0xF0, 0x60, 0x5C, 0x51, 0x3D, 0xF0, 0x75, 0x73, 0x53, 0x09, 0x5E, 0x00, 0x22, 0x09, 0x61, 0x00, 0x70, 0xCF, 0x71, 0x20, 0x51, 0x3D, 0xFE, 0xE9, 0x5C, 0x51, 0x3D, 0xFE, 0xED, 0x53, 0x09, 0xBF, 0x2E - } - }, - { - 50, - 79, - 0x39, - 0x005D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x5D, 0x5E, 0x00, 0x2A, 0x09, 0x61, 0x00, 0x70, 0xCF, 0x51, 0x3D, 0xFF, 0xBA, 0x53, 0xA0, 0x51, 0x3D, 0xFF, 0xBD, 0x53, 0xA1, 0x7F, 0x70, 0xCF, 0x71, 0x20, 0x51, 0x3D, 0xFE, 0xC5, 0x5C, 0x51, 0x3D, 0xFE, 0xC9, 0x73, 0x53, 0x09, 0x5E, 0x00, 0x22, 0x09, 0x61, 0x00, 0x70, 0xCF, 0x71, 0x10, 0x51, 0x3D, 0xF0, 0x10, 0x5C, 0x51, 0x3D, 0xF0, 0x25, 0x53, 0x09, 0x5E, 0x00, 0x2A, 0x09, 0x61, 0x00, 0x4E, 0x4D - } - }, - { - 51, - 79, - 0x39, - 0x005E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x5E, 0x70, 0xCF, 0x7F, 0x0C, 0x0C, 0x00, 0x10, 0x10, 0x08, 0x00, 0x04, 0x08, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x04, 0x08, 0x00, 0x00, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x01, 0x80, 0x10, 0x01, 0x80, 0x01, 0x40, 0x04, 0x02, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x02, 0x40, 0x08, 0x80, 0x20, 0x80, 0x08, 0x04, 0x02, 0x40, 0x20, 0x62, 0xD0, 0x00, 0x55, 0x9D, 0x00, 0x51, 0xA6, 0x91, 0x11, 0xD4 - } - }, - { - 52, - 79, - 0x39, - 0x005F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x5F, 0x76, 0x51, 0xA4, 0x58, 0xA3, 0x7C, 0x18, 0xB7, 0x51, 0xA5, 0x7C, 0x18, 0xE7, 0x70, 0xCF, 0x71, 0x20, 0x50, 0x00, 0x60, 0x80, 0x60, 0x84, 0x60, 0x88, 0x60, 0x8C, 0x60, 0x90, 0x60, 0x94, 0x60, 0x98, 0x60, 0x9C, 0x60, 0x82, 0x60, 0x86, 0x60, 0x8A, 0x60, 0x8E, 0x60, 0x92, 0x60, 0x96, 0x60, 0x9A, 0x60, 0x9E, 0x60, 0xC0, 0x43, 0x81, 0x04, 0x43, 0x85, 0x04, 0x43, 0x89, 0x04, 0x43, 0x8D, 0x86, 0xBF - } - }, - { - 53, - 79, - 0x39, - 0x0060, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x60, 0x04, 0x43, 0x91, 0x04, 0x43, 0x95, 0x04, 0x43, 0x99, 0x04, 0x43, 0x9D, 0x04, 0x71, 0x30, 0x71, 0x30, 0x62, 0x1F, 0x00, 0x62, 0x1B, 0x70, 0x62, 0x13, 0x87, 0x70, 0xCF, 0x71, 0x10, 0x55, 0x09, 0x19, 0x51, 0x09, 0xFF, 0x5E, 0x5C, 0x51, 0x09, 0xFF, 0x73, 0x53, 0x45, 0x5E, 0x00, 0x2A, 0x45, 0x61, 0x00, 0x7A, 0x09, 0xDF, 0xEC, 0x70, 0xCF, 0x41, 0xA2, 0x3F, 0x55, 0x40, 0x00, 0x55, 0x3F, 0xDC, 0x6C - } - }, - { - 54, - 79, - 0x39, - 0x0061, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x61, 0x00, 0x51, 0xA9, 0xA0, 0x08, 0x51, 0xA7, 0x58, 0xA8, 0x7C, 0x18, 0xF9, 0x7F, 0x41, 0xE0, 0xFB, 0x71, 0x30, 0x41, 0x1B, 0xBF, 0x70, 0xCF, 0x71, 0x20, 0x41, 0x81, 0xFD, 0x41, 0x85, 0xFD, 0x41, 0x89, 0xFD, 0x41, 0x8D, 0xFD, 0x41, 0x91, 0xFD, 0x41, 0x95, 0xFD, 0x41, 0x99, 0xFD, 0x41, 0x9D, 0xFD, 0x70, 0xCF, 0x41, 0xA2, 0xEF, 0x7C, 0x19, 0x5A, 0x70, 0xCF, 0x71, 0x10, 0x41, 0xE2, 0xF7, 0x90, 0xD5 - } - }, - { - 55, - 79, - 0x39, - 0x0062, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x62, 0x70, 0xCF, 0x7F, 0x7C, 0x19, 0x41, 0x70, 0xCF, 0x71, 0x10, 0x43, 0xE2, 0x08, 0x71, 0x30, 0x43, 0x1B, 0x40, 0x70, 0xCF, 0x71, 0x20, 0x43, 0x81, 0x02, 0x43, 0x85, 0x02, 0x43, 0x89, 0x02, 0x43, 0x8D, 0x02, 0x43, 0x91, 0x02, 0x43, 0x95, 0x02, 0x43, 0x99, 0x02, 0x43, 0x9D, 0x02, 0x70, 0xCF, 0x43, 0xA2, 0x10, 0x7C, 0x19, 0x4E, 0x7F, 0x62, 0xD0, 0x00, 0x53, 0x49, 0x5A, 0x48, 0x53, 0x9B, 0x24, 0xFE - } - }, - { - 56, - 79, - 0x39, - 0x0063, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x63, 0x5B, 0x21, 0x01, 0xA0, 0x06, 0x2E, 0x9E, 0x01, 0x80, 0x04, 0x26, 0x9E, 0xFE, 0x68, 0x48, 0x6E, 0x49, 0x51, 0x49, 0x78, 0x70, 0xCF, 0x71, 0x20, 0x60, 0xC9, 0x70, 0xCF, 0x7C, 0x2A, 0xBA, 0x7F, 0x00, 0x04, 0x0C, 0x1C, 0x3C, 0x7C, 0xFC, 0x62, 0xD0, 0x00, 0x53, 0x3E, 0x76, 0x3E, 0xFF, 0xF0, 0x26, 0x9C, 0x03, 0x2C, 0x9C, 0x7C, 0x2A, 0xBA, 0x7F, 0x62, 0xD0, 0x00, 0x53, 0xA7, 0x5A, 0xA8, 0xA6, 0x03 - } - }, - { - 57, - 79, - 0x39, - 0x0064, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x64, 0x90, 0x01, 0x7F, 0x62, 0xD0, 0x00, 0x08, 0x5A, 0x3E, 0x55, 0x40, 0xFF, 0x55, 0x3F, 0x01, 0x78, 0xA0, 0x0A, 0x06, 0x40, 0xFF, 0x0E, 0x3F, 0x01, 0x78, 0xBF, 0xF8, 0x51, 0x3E, 0x68, 0x3F, 0x6E, 0x40, 0x78, 0xDF, 0xFA, 0x16, 0x40, 0x7F, 0x1E, 0x3F, 0x00, 0x18, 0x78, 0x64, 0x64, 0x26, 0x9C, 0x03, 0x2C, 0x9C, 0x7C, 0x2A, 0xBA, 0x7F, 0x62, 0xD0, 0x00, 0x78, 0x53, 0x9A, 0x7C, 0x2A, 0xBA, 0x11, 0xDA - } - }, - { - 58, - 79, - 0x39, - 0x0065, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x65, 0x7F, 0x70, 0xCF, 0x71, 0x20, 0x62, 0xA7, 0x89, 0x62, 0xA7, 0x49, 0x70, 0xCF, 0x7F, 0x70, 0xCF, 0x71, 0x20, 0x49, 0xC8, 0x08, 0xAF, 0xFC, 0x70, 0xCF, 0x7F, 0x70, 0xCF, 0x71, 0x20, 0x62, 0xA7, 0x09, 0x70, 0xCF, 0x7F, 0x70, 0xBF, 0x62, 0xD0, 0x00, 0x55, 0x41, 0x00, 0x93, 0xA8, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x70, 0xBF, 0x62, 0xD0, 0x00, 0x55, 0x41, 0x02, 0x93, 0x99, 0x70, 0x3F, 0x71, 0xB9, 0x2B - } - }, - { - 59, - 79, - 0x39, - 0x0066, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x66, 0xC0, 0x7F, 0x57, 0x98, 0x50, 0x0A, 0x28, 0x21, 0xE0, 0xB0, 0x04, 0x79, 0xDF, 0xF7, 0x7F, 0x70, 0xCF, 0x71, 0x10, 0x64, 0xE0, 0x01, 0x80, 0x09, 0x80, 0x75, 0x80, 0xE1, 0x81, 0x3D, 0x81, 0x49, 0x41, 0x00, 0xFD, 0x41, 0x0C, 0xF7, 0x41, 0x0C, 0xBF, 0x41, 0x00, 0x7F, 0x41, 0x10, 0xF7, 0x41, 0x10, 0xBF, 0x70, 0xCF, 0x71, 0x20, 0x5D, 0xF7, 0x53, 0x9F, 0x70, 0xFE, 0x43, 0x80, 0x04, 0x52, 0xE2, 0x7E - } - }, - { - 60, - 79, - 0x39, - 0x0067, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x67, 0x06, 0x60, 0x83, 0x06, 0x68, 0x06, 0x2E, 0x70, 0x01, 0x43, 0x84, 0x08, 0x52, 0x03, 0x60, 0x87, 0x06, 0x69, 0x03, 0x2E, 0x71, 0x01, 0x43, 0x88, 0x04, 0x52, 0x00, 0x60, 0x8B, 0x06, 0x6A, 0x00, 0x2E, 0x72, 0x01, 0x43, 0x8C, 0x02, 0x52, 0x09, 0x60, 0x8F, 0x06, 0x6B, 0x09, 0x2E, 0x73, 0x01, 0x43, 0x90, 0x01, 0x52, 0x0C, 0x60, 0x93, 0x06, 0x6C, 0x0C, 0x2E, 0x74, 0x01, 0x43, 0x94, 0x02, 0x8C, 0xD3 - } - }, - { - 61, - 79, - 0x39, - 0x0068, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x68, 0x52, 0x0F, 0x60, 0x97, 0x06, 0x6D, 0x0F, 0x2E, 0x75, 0x01, 0x43, 0xA3, 0x3F, 0x7F, 0x41, 0x04, 0xBF, 0x41, 0x0C, 0xFB, 0x41, 0x0C, 0xDF, 0x41, 0x00, 0xDF, 0x41, 0x10, 0xFB, 0x41, 0x10, 0xDF, 0x70, 0xCF, 0x71, 0x20, 0x5D, 0xF7, 0x53, 0x9F, 0x70, 0xFE, 0x43, 0x80, 0x02, 0x52, 0x07, 0x60, 0x83, 0x06, 0x68, 0x07, 0x2E, 0x70, 0x01, 0x43, 0x84, 0x04, 0x52, 0x04, 0x60, 0x87, 0x06, 0x69, 0x46, 0x48 - } - }, - { - 62, - 79, - 0x39, - 0x0069, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x69, 0x04, 0x2E, 0x71, 0x01, 0x43, 0x88, 0x02, 0x52, 0x01, 0x60, 0x8B, 0x06, 0x6A, 0x01, 0x2E, 0x72, 0x01, 0x43, 0x8C, 0x04, 0x52, 0x0A, 0x60, 0x8F, 0x06, 0x6B, 0x0A, 0x2E, 0x73, 0x01, 0x43, 0x90, 0x02, 0x52, 0x0D, 0x60, 0x93, 0x06, 0x6C, 0x0D, 0x2E, 0x74, 0x01, 0x43, 0x94, 0x04, 0x52, 0x10, 0x60, 0x97, 0x06, 0x6D, 0x10, 0x2E, 0x75, 0x01, 0x43, 0xA3, 0x3F, 0x7F, 0x41, 0x08, 0xF7, 0x41, 0xC5, 0x47 - } - }, - { - 63, - 79, - 0x39, - 0x006A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x6A, 0x0C, 0xFD, 0x41, 0x0C, 0xEF, 0x41, 0x08, 0x7F, 0x41, 0x10, 0xFD, 0x70, 0xCF, 0x71, 0x20, 0x5D, 0xF7, 0x53, 0x9F, 0x70, 0xFE, 0x43, 0x80, 0x01, 0x52, 0x08, 0x60, 0x83, 0x06, 0x68, 0x08, 0x2E, 0x70, 0x01, 0x43, 0x84, 0x02, 0x52, 0x05, 0x60, 0x87, 0x06, 0x69, 0x05, 0x2E, 0x71, 0x01, 0x43, 0x88, 0x01, 0x52, 0x02, 0x60, 0x8B, 0x06, 0x6A, 0x02, 0x2E, 0x72, 0x01, 0x43, 0x8C, 0x08, 0x52, 0x57, 0x6C - } - }, - { - 64, - 79, - 0x39, - 0x006B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x6B, 0x0B, 0x60, 0x8F, 0x06, 0x6B, 0x0B, 0x2E, 0x73, 0x01, 0x43, 0x90, 0x04, 0x52, 0x0E, 0x60, 0x93, 0x06, 0x6C, 0x0E, 0x2E, 0x74, 0x01, 0x43, 0xA3, 0x1F, 0x7F, 0x70, 0xCF, 0x71, 0x20, 0x5D, 0xF7, 0x53, 0x9F, 0x70, 0xFE, 0x43, 0xA3, 0x00, 0x7F, 0x7F, 0x70, 0xCF, 0x71, 0x10, 0x64, 0xE0, 0x01, 0x80, 0x09, 0x80, 0x34, 0x80, 0x5F, 0x80, 0x84, 0x80, 0x8B, 0x43, 0x00, 0x02, 0x43, 0x0C, 0x08, 0x1D, 0xF9 - } - }, - { - 65, - 79, - 0x39, - 0x006C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x6C, 0x43, 0x0C, 0x40, 0x43, 0x00, 0x80, 0x43, 0x10, 0x08, 0x43, 0x10, 0x40, 0x70, 0xCF, 0x71, 0x20, 0x41, 0x80, 0xFB, 0x41, 0x84, 0xF7, 0x41, 0x88, 0xFB, 0x41, 0x8C, 0xFD, 0x41, 0x90, 0xFE, 0x41, 0x94, 0xFD, 0x62, 0xA3, 0x00, 0x80, 0x5E, 0x43, 0x04, 0x40, 0x43, 0x0C, 0x04, 0x43, 0x0C, 0x20, 0x43, 0x00, 0x20, 0x43, 0x10, 0x04, 0x43, 0x10, 0x20, 0x70, 0xCF, 0x71, 0x20, 0x41, 0x80, 0xFD, 0x9E, 0xFC - } - }, - { - 66, - 79, - 0x39, - 0x006D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x6D, 0x41, 0x84, 0xFB, 0x41, 0x88, 0xFD, 0x41, 0x8C, 0xFB, 0x41, 0x90, 0xFD, 0x41, 0x94, 0xFB, 0x62, 0xA3, 0x00, 0x80, 0x31, 0x43, 0x08, 0x08, 0x43, 0x0C, 0x02, 0x43, 0x0C, 0x10, 0x43, 0x08, 0x80, 0x43, 0x10, 0x02, 0x70, 0xCF, 0x71, 0x20, 0x41, 0x80, 0xFE, 0x41, 0x84, 0xFD, 0x41, 0x88, 0xFE, 0x41, 0x8C, 0xF7, 0x41, 0x90, 0xFB, 0x62, 0xA3, 0x00, 0x80, 0x0A, 0x70, 0xCF, 0x71, 0x20, 0x62, 0x2E, 0x1D - } - }, - { - 67, - 79, - 0x39, - 0x006E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x6E, 0xA3, 0x00, 0x80, 0x01, 0x70, 0xCF, 0x7F, 0x62, 0xD3, 0x00, 0x57, 0x07, 0x52, 0x70, 0x54, 0x80, 0x52, 0x68, 0x54, 0x78, 0x51, 0xA0, 0x56, 0x70, 0x00, 0x54, 0x68, 0x79, 0xDF, 0xEF, 0x7F, 0x62, 0xD5, 0x00, 0x62, 0xD3, 0x00, 0x58, 0xA0, 0x55, 0x09, 0x88, 0x50, 0x0A, 0x28, 0x21, 0x1F, 0x3F, 0x09, 0x75, 0x3C, 0x09, 0x99, 0xCF, 0xF4, 0x7F, 0x62, 0xD0, 0x00, 0x55, 0xAA, 0x00, 0x55, 0xAC, 0xE5, 0x8C - } - }, - { - 68, - 79, - 0x39, - 0x006F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x6F, 0x00, 0x57, 0x07, 0x62, 0xD3, 0x00, 0x5B, 0x3D, 0x80, 0x00, 0xA0, 0x5A, 0x10, 0x64, 0x5C, 0x52, 0x58, 0x53, 0x56, 0x52, 0x59, 0x53, 0x57, 0x51, 0x3E, 0x6E, 0x56, 0x6E, 0x57, 0x78, 0xDF, 0xFA, 0x51, 0x40, 0x14, 0x57, 0x51, 0x3F, 0x1C, 0x56, 0xA0, 0x0E, 0xD0, 0x06, 0x55, 0x57, 0x00, 0x80, 0x04, 0x55, 0x57, 0xFF, 0x55, 0x56, 0x00, 0x20, 0x10, 0x52, 0x78, 0x5C, 0x62, 0xD3, 0x02, 0x51, 0x6C, 0x9B - } - }, - { - 69, - 79, - 0x39, - 0x0070, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x70, 0x57, 0x73, 0x54, 0x00, 0x39, 0xDC, 0xD0, 0x05, 0x39, 0x23, 0xD0, 0x04, 0x55, 0xAB, 0x01, 0x62, 0xD3, 0x08, 0x13, 0x00, 0xC0, 0x07, 0x39, 0x0F, 0xD0, 0x0B, 0x80, 0x05, 0x39, 0xF1, 0xC0, 0x05, 0x04, 0xAA, 0x76, 0xAC, 0x20, 0x79, 0xDF, 0x9C, 0x51, 0xAC, 0x47, 0xAA, 0x80, 0xA0, 0x03, 0x76, 0xAA, 0x68, 0xAA, 0x39, 0x02, 0xC0, 0x18, 0x47, 0xAA, 0x80, 0xA0, 0x03, 0x76, 0xAA, 0x68, 0xAA, 0x67, 0x92 - } - }, - { - 70, - 79, - 0x39, - 0x0071, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x71, 0x67, 0x39, 0x02, 0xC0, 0x0A, 0x47, 0xAA, 0x80, 0xA0, 0x03, 0x76, 0xAA, 0x68, 0xAA, 0x57, 0x07, 0x62, 0xD3, 0x00, 0x3D, 0x80, 0x00, 0xA0, 0x33, 0x10, 0x52, 0x78, 0x5C, 0x62, 0xD3, 0x02, 0x52, 0x00, 0x53, 0x47, 0x47, 0x42, 0x10, 0xA0, 0x1B, 0x51, 0xAA, 0x15, 0x00, 0xD0, 0x0B, 0x47, 0xAA, 0x80, 0xB0, 0x0E, 0x56, 0x00, 0x00, 0x80, 0x09, 0x47, 0xAA, 0x80, 0xA0, 0x04, 0x56, 0x00, 0xFF, 0xE5, 0x8F - } - }, - { - 71, - 79, - 0x39, - 0x0072, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x72, 0x52, 0x00, 0x73, 0x53, 0x57, 0x5B, 0x7C, 0x10, 0xC0, 0x20, 0x79, 0xDF, 0xC4, 0x7F, 0x62, 0xD0, 0x00, 0x70, 0xCF, 0x71, 0x20, 0x49, 0xC4, 0x01, 0xAF, 0xFC, 0x41, 0xA4, 0xF7, 0x41, 0xC4, 0xFE, 0x5D, 0xA8, 0x53, 0x59, 0x5D, 0xA9, 0x53, 0x58, 0x5D, 0xAB, 0x53, 0x5B, 0x5D, 0xAC, 0x53, 0x5A, 0x5D, 0xAE, 0x53, 0x5D, 0x5D, 0xAF, 0x53, 0x5C, 0x5D, 0xB1, 0x53, 0x5F, 0x5D, 0xB2, 0x53, 0x5E, 0x2F, 0x24 - } - }, - { - 72, - 79, - 0x39, - 0x0073, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x73, 0x5D, 0xB4, 0x53, 0x61, 0x5D, 0xB5, 0x53, 0x60, 0x5D, 0xB7, 0x53, 0x63, 0x5D, 0xB8, 0x53, 0x62, 0x5D, 0xBA, 0x53, 0x65, 0x5D, 0xBB, 0x53, 0x64, 0x5D, 0xBD, 0x53, 0x67, 0x5D, 0xBE, 0x53, 0x66, 0x70, 0xCF, 0x7F, 0x62, 0xD3, 0x00, 0x57, 0x07, 0x5B, 0x3D, 0x70, 0x00, 0xA0, 0x25, 0x10, 0x64, 0x5C, 0x51, 0x3E, 0x6F, 0x58, 0x6F, 0x59, 0x78, 0xDF, 0xFA, 0x51, 0x40, 0x15, 0x59, 0x51, 0x3F, 0x50, 0x67 - } - }, - { - 73, - 79, - 0x39, - 0x0074, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x74, 0x1D, 0x58, 0xA0, 0x0E, 0xD0, 0x06, 0x56, 0x59, 0x00, 0x80, 0x04, 0x56, 0x59, 0xFF, 0x56, 0x58, 0x00, 0x20, 0x79, 0xDF, 0xD4, 0x7F, 0x55, 0x3D, 0x00, 0x55, 0x37, 0x01, 0x7C, 0x17, 0x18, 0x9E, 0x7E, 0x58, 0xA1, 0x62, 0xD3, 0x01, 0x52, 0xA0, 0x60, 0xFD, 0x52, 0xC5, 0x70, 0xCF, 0x71, 0x20, 0x60, 0xA5, 0x70, 0xCF, 0x9E, 0x51, 0x50, 0x00, 0x57, 0x88, 0x9C, 0x53, 0x43, 0xA4, 0x08, 0x47, 0x25, 0x12 - } - }, - { - 74, - 79, - 0x39, - 0x0075, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x75, 0x9F, 0x01, 0xA0, 0x03, 0x71, 0x01, 0x70, 0xCF, 0x51, 0x3D, 0xA0, 0x05, 0x9E, 0x6A, 0x51, 0x3D, 0x9F, 0x3C, 0x50, 0x00, 0x9D, 0x93, 0x62, 0xD3, 0x01, 0x58, 0xA1, 0x52, 0xA1, 0x60, 0xFD, 0x52, 0xC6, 0x70, 0xCF, 0x71, 0x20, 0x60, 0xA5, 0x70, 0xCF, 0x9E, 0x1C, 0x50, 0x01, 0x57, 0x88, 0x9C, 0x1E, 0x43, 0xA4, 0x08, 0x47, 0x9F, 0x01, 0xA0, 0x03, 0x71, 0x01, 0x70, 0xCF, 0x9E, 0x39, 0x9F, 0x07, 0xD7 - } - }, - { - 75, - 79, - 0x39, - 0x0076, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x76, 0x0D, 0x50, 0x01, 0x9D, 0x64, 0x62, 0xD3, 0x01, 0x58, 0xA1, 0x52, 0xA2, 0x60, 0xFD, 0x52, 0xC7, 0x70, 0xCF, 0x71, 0x20, 0x60, 0xA5, 0x70, 0xCF, 0x9D, 0xED, 0x50, 0x02, 0x57, 0x88, 0x9B, 0xEF, 0x43, 0xA4, 0x08, 0x47, 0x9F, 0x01, 0xA0, 0x03, 0x71, 0x01, 0x70, 0xCF, 0x9E, 0x0A, 0x9E, 0xDE, 0x50, 0x02, 0x9D, 0x35, 0x7C, 0x17, 0x55, 0x76, 0x3D, 0x3C, 0x3D, 0x09, 0xCF, 0x5F, 0x62, 0xD3, 0x43, 0x50 - } - }, - { - 76, - 79, - 0x39, - 0x0077, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x77, 0x00, 0x9D, 0xC4, 0x9D, 0xF3, 0x7C, 0x14, 0x1F, 0x55, 0x37, 0x00, 0x7F, 0x43, 0xE0, 0x08, 0x7F, 0x41, 0xE0, 0xF7, 0x7F, 0x62, 0xE6, 0x04, 0x62, 0xD0, 0x00, 0x5A, 0x53, 0x53, 0x54, 0x10, 0x08, 0x51, 0x55, 0x08, 0x38, 0x03, 0x4F, 0x50, 0x00, 0x54, 0xFE, 0x54, 0xFD, 0x01, 0x08, 0x54, 0xFF, 0x48, 0xFC, 0x01, 0xA0, 0x09, 0x52, 0xFB, 0x05, 0xFE, 0x52, 0xFA, 0x0D, 0xFD, 0x6F, 0xFD, 0x6F, 0xCC, 0x63 - } - }, - { - 77, - 79, - 0x39, - 0x0078, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x78, 0xFE, 0x6F, 0xFC, 0x7B, 0xFF, 0xBF, 0xEA, 0x52, 0xFC, 0x60, 0xE8, 0x52, 0xFE, 0x60, 0xE7, 0x62, 0xE6, 0x00, 0x62, 0xE6, 0x01, 0x38, 0xFA, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x5D, 0xF7, 0x08, 0x70, 0xFE, 0x57, 0xF0, 0x50, 0x00, 0x62, 0xE6, 0x04, 0x62, 0xE8, 0x01, 0x62, 0xE7, 0x00, 0x62, 0xE6, 0x00, 0x62, 0xE6, 0x01, 0x62, 0xDA, 0xF7, 0x49, 0xDA, 0x08, 0xAF, 0xFC, 0x62, 0xDA, 0xF7, 0x08, 0xF1, 0xAE - } - }, - { - 78, - 79, - 0x39, - 0x0079, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x79, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x51, 0x00, 0x18, 0x49, 0xDA, 0x08, 0xB0, 0x04, 0x40, 0x80, 0x05, 0x74, 0x62, 0xDA, 0xF7, 0x79, 0xBF, 0xE0, 0x49, 0xDA, 0x08, 0xA0, 0x02, 0x74, 0x62, 0xE6, 0x04, 0x60, 0xE8, 0x62, 0xE7, 0x00, 0x62, 0xE6, 0x00, 0x62, 0xE6, 0x01, 0x62, 0xD0, 0x00, 0x53, 0x55, 0x55, 0x53, 0x00, 0x55, 0x54, 0x01, 0x7E, 0x55, 0x77 - } - }, - { - 79, - 79, - 0x39, - 0x007A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x7A, 0x5D, 0xF7, 0x08, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0x05, 0x58, 0x04, 0x7E, 0x5D, 0xF7, 0x08, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0x01, 0x58, 0x00, 0x7E, 0x5D, 0xF7, 0x08, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0x03, 0x58, 0x02, 0x7E, 0x5D, 0xF7, 0x08, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0x07, 0x58, 0x06, 0x7E, 0x08, 0x08, 0x10, 0x4F, 0x5D, 0xF7, 0x54, 0xFD, 0x70, 0x3F, 0x71, 0xC0, 0x9C, 0x06 - } - }, - { - 80, - 79, - 0x39, - 0x007B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x7B, 0x20, 0x18, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x53, 0x05, 0x5A, 0x04, 0x7E, 0x08, 0x08, 0x10, 0x4F, 0x5D, 0xF7, 0x54, 0xFD, 0x70, 0x3F, 0x71, 0xC0, 0x20, 0x18, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x53, 0x01, 0x5A, 0x00, 0x7E, 0x08, 0x08, 0x10, 0x4F, 0x5D, 0xF7, 0x54, 0xFD, 0x70, 0x3F, 0x71, 0xC0, 0x20, 0x18, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x53, 0x03, 0x5A, 0x02, 0x7E, 0x0E, 0x1E, 0x3D, 0x7A, 0xE3, 0x95 - } - }, - { - 81, - 79, - 0x39, - 0x007C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x7C, 0x07, 0x03, 0x00, 0x00, 0x07, 0x0E, 0x1E, 0x3D, 0x03, 0x01, 0x00, 0x00, 0x1E, 0x3D, 0x7A, 0xF6, 0x0E, 0x07, 0x01, 0x00, 0x58, 0x45, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x79, 0xDF, 0xF6, 0x7A, 0x44, 0xBF, 0xF0, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x08, 0x10, 0x70, 0x3F, 0x71, 0x80, 0x5D, 0xD3, 0x08, 0x5D, 0xD0, 0x08, 0x62, 0xD0, 0x00, 0x51, 0xB6, 0x60, 0xD3, 0x2E, 0xB3, 0x80, 0x48, 0x60 - } - }, - { - 82, - 79, - 0x39, - 0x007D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x7D, 0x49, 0xD7, 0x08, 0xA0, 0x09, 0x26, 0xB3, 0xF0, 0x2E, 0xB3, 0x00, 0x80, 0x08, 0x49, 0xD7, 0x20, 0xA0, 0x03, 0x80, 0xA6, 0x51, 0xB3, 0x21, 0x0E, 0xE0, 0x01, 0x80, 0x11, 0x80, 0x67, 0x80, 0x79, 0x80, 0x47, 0x80, 0x96, 0x80, 0x94, 0x80, 0x92, 0x80, 0x90, 0x80, 0x97, 0x5D, 0xD8, 0x21, 0xFE, 0x39, 0x48, 0xA0, 0x06, 0x62, 0xD7, 0x00, 0x80, 0x8A, 0x49, 0xD8, 0x01, 0xB0, 0x0F, 0x55, 0xBA, 0x69, 0xA3 - } - }, - { - 83, - 79, - 0x39, - 0x007E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x7E, 0x02, 0x26, 0xB3, 0xF0, 0x2E, 0xB3, 0x02, 0x62, 0xD7, 0x10, 0x80, 0x77, 0x55, 0xBA, 0x01, 0x26, 0xB3, 0xF0, 0x2E, 0xB3, 0x06, 0x5F, 0xB5, 0xB4, 0x51, 0xB7, 0x02, 0xB5, 0x5C, 0x52, 0x00, 0x60, 0xD8, 0x76, 0xB5, 0x62, 0xD7, 0x14, 0x80, 0x5B, 0x51, 0xB8, 0x78, 0x3A, 0xB5, 0xC0, 0x0F, 0x51, 0xB7, 0x02, 0xB5, 0x5C, 0x52, 0x00, 0x60, 0xD8, 0x76, 0xB5, 0x2E, 0xB3, 0x20, 0x60, 0xD8, 0x62, 0x18, 0x02 - } - }, - { - 84, - 79, - 0x39, - 0x007F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x7F, 0xD7, 0x04, 0x80, 0x3F, 0x5D, 0xD8, 0x3A, 0xB8, 0xD0, 0x2B, 0xA0, 0x29, 0x53, 0xB5, 0x53, 0xB4, 0x26, 0xB3, 0xF0, 0x2E, 0xB3, 0x04, 0x80, 0x18, 0x51, 0xB9, 0x78, 0x3A, 0xB5, 0xC0, 0x16, 0x51, 0xB7, 0x02, 0xB5, 0x5C, 0x5D, 0xD8, 0x54, 0x00, 0x2E, 0xB3, 0x10, 0x76, 0xB5, 0x80, 0x01, 0x62, 0xD7, 0x10, 0x80, 0x0F, 0x62, 0xD7, 0x00, 0x80, 0x0A, 0x26, 0xB3, 0xF0, 0x2E, 0xB3, 0x00, 0x55, 0xFC, 0xCB - } - }, - { - 85, - 79, - 0x39, - 0x0080, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x80, 0xBA, 0x00, 0x18, 0x60, 0xD0, 0x18, 0x60, 0xD3, 0x20, 0x18, 0x7E, 0x62, 0xD0, 0x00, 0x70, 0xCF, 0x71, 0x10, 0x41, 0x04, 0x5F, 0x43, 0x05, 0xA0, 0x70, 0xCF, 0x26, 0xAF, 0x5F, 0x51, 0xAF, 0x60, 0x04, 0x55, 0xBA, 0x00, 0x90, 0x1F, 0x90, 0x24, 0x40, 0x40, 0x40, 0x40, 0x40, 0x50, 0x00, 0x53, 0xB4, 0x70, 0xCF, 0x71, 0x10, 0x43, 0x04, 0xA0, 0x43, 0x05, 0xA0, 0x70, 0xCF, 0x2E, 0xAF, 0xA0, 0xAC, 0x2C - } - }, - { - 86, - 79, - 0x39, - 0x0081, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x81, 0x51, 0xAF, 0x60, 0x04, 0x7F, 0x41, 0xE0, 0x7F, 0x43, 0xE0, 0x80, 0x7F, 0x43, 0xD6, 0x31, 0x7F, 0x41, 0xE0, 0x7F, 0x41, 0xD6, 0xFE, 0x7F, 0x62, 0xD0, 0x00, 0x4F, 0x52, 0xFD, 0x53, 0xB8, 0x52, 0xFC, 0x53, 0xB9, 0x52, 0xFB, 0x53, 0xB7, 0x52, 0xFA, 0x53, 0xB6, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x76, 0xBB, 0xD0, 0x04, 0x55, 0xBB, 0xFF, 0x7E, 0x43, 0xE1, 0x01, 0x7F, 0x41, 0xE1, 0xFE, 0x7F, 0xB7, 0x43 - } - }, - { - 87, - 79, - 0x39, - 0x0082, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x82, 0x43, 0x23, 0x01, 0x7F, 0x54, 0x00, 0x70, 0xFE, 0x41, 0x23, 0xFE, 0x18, 0x60, 0x22, 0x18, 0x60, 0x23, 0x18, 0x70, 0x3F, 0x71, 0xC0, 0x7E, 0x30, 0x62, 0xD0, 0x00, 0x53, 0xF8, 0x5D, 0xF7, 0x08, 0x21, 0xC0, 0xB0, 0x07, 0x56, 0x01, 0x00, 0x55, 0xF8, 0x00, 0x51, 0xF8, 0x70, 0x3F, 0x71, 0x80, 0x60, 0xD3, 0x55, 0xFD, 0x01, 0x3C, 0xFD, 0x01, 0xB0, 0xAE, 0x70, 0xCF, 0x71, 0x10, 0x5D, 0xE0, 0xFE, 0xD2 - } - }, - { - 88, - 79, - 0x39, - 0x0083, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x83, 0x08, 0x21, 0xF8, 0x49, 0xFE, 0x08, 0xB0, 0x0A, 0x49, 0xFE, 0x10, 0xB0, 0x09, 0x29, 0x01, 0x80, 0x07, 0x29, 0x02, 0x80, 0x03, 0x29, 0x00, 0x60, 0xE0, 0x70, 0xCF, 0x80, 0x01, 0x65, 0xFD, 0x3C, 0xFD, 0x02, 0xB0, 0x84, 0x65, 0xFD, 0x70, 0xCF, 0x71, 0x10, 0x49, 0xE4, 0x08, 0xA0, 0x05, 0x70, 0xCF, 0x80, 0x20, 0x70, 0xCF, 0x52, 0x00, 0x53, 0xFA, 0x51, 0xFD, 0x39, 0x04, 0xB0, 0x69, 0x08, 0xF8, 0xC7 - } - }, - { - 89, - 79, - 0x39, - 0x0084, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x84, 0x10, 0x50, 0x03, 0x55, 0xF8, 0x3A, 0x7C, 0x00, 0x60, 0x20, 0x18, 0x53, 0xFD, 0x3C, 0xF8, 0x00, 0xA0, 0x09, 0x55, 0xFF, 0x00, 0x55, 0xFD, 0x10, 0x80, 0x37, 0x65, 0xFD, 0x52, 0x00, 0x53, 0xFA, 0x52, 0x02, 0x53, 0xFB, 0x52, 0x01, 0x60, 0xD4, 0x52, 0x05, 0x53, 0xFC, 0x55, 0xFE, 0x56, 0x51, 0xFD, 0x39, 0x08, 0xB0, 0x33, 0x08, 0x10, 0x50, 0x02, 0x55, 0xF8, 0x3A, 0x7C, 0x00, 0x60, 0x20, 0x70, 0xB8 - } - }, - { - 90, - 79, - 0x39, - 0x0085, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x85, 0x18, 0x53, 0xFD, 0x55, 0xFF, 0x01, 0x3C, 0xF8, 0x00, 0xA0, 0x04, 0x55, 0xFF, 0x00, 0x65, 0xFD, 0x3C, 0xFD, 0x10, 0xB0, 0x13, 0x18, 0x70, 0xCF, 0x71, 0x10, 0x60, 0xE0, 0x70, 0xCF, 0x65, 0xFD, 0x51, 0xFF, 0x3C, 0xFD, 0x20, 0xA0, 0x04, 0x30, 0x8F, 0xFE, 0x62, 0xD0, 0x00, 0x62, 0xD5, 0x00, 0x62, 0xD4, 0x00, 0x7E, 0x30, 0x30, 0x30, 0x51, 0xF8, 0x70, 0x3F, 0x71, 0x80, 0x60, 0xD3, 0x52, 0x35, 0x43 - } - }, - { - 91, - 79, - 0x39, - 0x0086, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x86, 0x02, 0x53, 0xFB, 0x52, 0x01, 0x60, 0xD5, 0x52, 0x03, 0x74, 0x53, 0xFD, 0x52, 0x04, 0x53, 0xFE, 0x50, 0x00, 0x6C, 0x00, 0x6A, 0x6C, 0x00, 0x6A, 0x6C, 0x00, 0x6A, 0x6C, 0x00, 0x6A, 0x6C, 0x00, 0x6A, 0x6C, 0x00, 0x6A, 0x6C, 0x00, 0x6A, 0x08, 0x52, 0x00, 0x5C, 0x18, 0x08, 0x28, 0x3F, 0xFB, 0x18, 0x75, 0xB0, 0x02, 0x74, 0x7A, 0xFE, 0xB0, 0x05, 0x7A, 0xFD, 0xA0, 0x0F, 0x3C, 0xFB, 0x00, 0x37, 0x48 - } - }, - { - 92, - 79, - 0x39, - 0x0087, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x87, 0xBF, 0xEB, 0x08, 0x5D, 0xD5, 0x74, 0x60, 0xD5, 0x18, 0x8F, 0xE2, 0x62, 0xD0, 0x00, 0x62, 0xD5, 0x00, 0x7E, 0x70, 0xBF, 0x62, 0xD0, 0x00, 0x47, 0x36, 0x40, 0xB0, 0x0F, 0x47, 0x36, 0x80, 0xA0, 0x0A, 0x26, 0x36, 0x3F, 0x51, 0x36, 0x3A, 0x0E, 0xA0, 0x01, 0x70, 0xBF, 0x51, 0x0E, 0xA1, 0x1A, 0x55, 0xBE, 0x00, 0x3C, 0x0E, 0x02, 0xC0, 0x04, 0x55, 0xBE, 0x01, 0x5F, 0x36, 0x0E, 0x62, 0xD4, 0xE5, 0xA5 - } - }, - { - 93, - 79, - 0x39, - 0x0088, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x88, 0x02, 0x62, 0xD5, 0x01, 0x55, 0x0E, 0x00, 0x55, 0x35, 0x99, 0x55, 0x34, 0xE0, 0x3E, 0x35, 0x53, 0x45, 0x3E, 0x35, 0x53, 0x44, 0x3E, 0x35, 0x53, 0x32, 0x3C, 0x45, 0x02, 0xC0, 0x94, 0x51, 0x4D, 0x11, 0x03, 0x3A, 0x45, 0xC0, 0x8C, 0x3C, 0x44, 0x02, 0xC0, 0x87, 0x51, 0x4C, 0x11, 0x03, 0x3A, 0x44, 0xC0, 0x7F, 0x62, 0xD3, 0x02, 0x58, 0x32, 0x52, 0xFE, 0x53, 0x23, 0x52, 0xFF, 0x53, 0x24, 0x10, 0xFC - } - }, - { - 94, - 79, - 0x39, - 0x0089, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x89, 0x52, 0x00, 0x53, 0x25, 0x52, 0x01, 0x53, 0x26, 0x52, 0x02, 0x53, 0x27, 0x5B, 0x12, 0x4C, 0x5C, 0x52, 0xFE, 0x53, 0x1E, 0x52, 0xFF, 0x53, 0x1F, 0x52, 0x00, 0x53, 0x20, 0x52, 0x01, 0x53, 0x21, 0x52, 0x02, 0x53, 0x22, 0x5B, 0x12, 0x4C, 0x5C, 0x52, 0xFE, 0x53, 0x19, 0x52, 0xFF, 0x53, 0x1A, 0x52, 0x00, 0x53, 0x1B, 0x52, 0x01, 0x53, 0x1C, 0x52, 0x02, 0x53, 0x1D, 0x51, 0x32, 0x02, 0x4C, 0xF8, 0xCD - } - }, - { - 95, - 79, - 0x39, - 0x008A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x8A, 0x5C, 0x52, 0xFE, 0x53, 0x28, 0x52, 0xFF, 0x53, 0x29, 0x52, 0x00, 0x53, 0x2A, 0x52, 0x01, 0x53, 0x2B, 0x52, 0x02, 0x53, 0x2C, 0x5B, 0x02, 0x4C, 0x5C, 0x52, 0xFE, 0x53, 0x2D, 0x52, 0xFF, 0x53, 0x2E, 0x52, 0x00, 0x53, 0x2F, 0x52, 0x01, 0x53, 0x30, 0x52, 0x02, 0x53, 0x31, 0x90, 0x62, 0x80, 0x44, 0x7C, 0x25, 0x70, 0x90, 0x5B, 0x55, 0xBD, 0x00, 0x51, 0x45, 0xA0, 0x18, 0x51, 0x4D, 0x78, 0xB8, 0x4E - } - }, - { - 96, - 79, - 0x39, - 0x008B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x8B, 0x3A, 0x45, 0xA0, 0x11, 0x51, 0x44, 0xA0, 0x1A, 0x51, 0x4C, 0x78, 0x3A, 0x44, 0xA0, 0x13, 0x7C, 0x26, 0x0E, 0x80, 0x21, 0x51, 0x44, 0xA0, 0x17, 0x51, 0x4C, 0x78, 0x3A, 0x44, 0xA0, 0x10, 0x80, 0x11, 0x51, 0x45, 0xA0, 0x0A, 0x51, 0x4D, 0x78, 0x3A, 0x45, 0xA0, 0x03, 0x80, 0x04, 0x55, 0xBD, 0x01, 0x7C, 0x26, 0x94, 0x51, 0x0E, 0x3A, 0x43, 0xC0, 0x05, 0x50, 0xFF, 0x80, 0x0C, 0x7C, 0x23, 0x96, 0x0B - } - }, - { - 97, - 79, - 0x39, - 0x008C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x8C, 0x48, 0x7A, 0x36, 0x51, 0x36, 0xBF, 0x07, 0x51, 0x0E, 0x55, 0x36, 0x00, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x55, 0x13, 0x00, 0x51, 0x1F, 0x02, 0x20, 0x0E, 0x13, 0x00, 0x02, 0x21, 0x0E, 0x13, 0x00, 0x02, 0x24, 0x0E, 0x13, 0x00, 0x02, 0x25, 0x0E, 0x13, 0x00, 0x02, 0x26, 0x0E, 0x13, 0x00, 0x02, 0x29, 0x0E, 0x13, 0x00, 0x02, 0x2A, 0x0E, 0x13, 0x00, 0x02, 0x2B, 0x0E, 0x13, 0x00, 0x3C, 0x13, 0xFB, 0xD6 - } - }, - { - 98, - 79, - 0x39, - 0x008D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x8D, 0x00, 0xA0, 0x03, 0x50, 0xFF, 0x53, 0xBC, 0x7F, 0x3C, 0xBE, 0x01, 0xB0, 0x23, 0x50, 0x00, 0x53, 0x19, 0x53, 0x1A, 0x53, 0x1B, 0x53, 0x1C, 0x53, 0x1D, 0x53, 0x1E, 0x53, 0x22, 0x53, 0x23, 0x53, 0x27, 0x53, 0x28, 0x53, 0x2C, 0x53, 0x2D, 0x53, 0x2E, 0x53, 0x2F, 0x53, 0x30, 0x53, 0x31, 0x62, 0xD5, 0x01, 0x06, 0x34, 0x03, 0x50, 0x00, 0x53, 0x0F, 0x53, 0x10, 0x53, 0x12, 0x53, 0x13, 0x62, 0xD5, 0x8B - } - }, - { - 99, - 79, - 0x39, - 0x008E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x8E, 0xD3, 0x00, 0x10, 0x51, 0x31, 0x57, 0x17, 0x03, 0x19, 0x0E, 0x13, 0x00, 0x79, 0xDF, 0xF9, 0x53, 0x14, 0x20, 0x51, 0xBC, 0x80, 0x08, 0x3C, 0x13, 0x00, 0xA0, 0x03, 0x50, 0xFF, 0x3F, 0x34, 0x51, 0x31, 0x02, 0x2C, 0x0E, 0x10, 0x00, 0x02, 0x27, 0x0E, 0x10, 0x00, 0x02, 0x22, 0x0E, 0x10, 0x00, 0x02, 0x1D, 0x0E, 0x10, 0x00, 0x12, 0x19, 0x1E, 0x10, 0x00, 0x12, 0x1E, 0x1E, 0x10, 0x00, 0x12, 0x8E, 0xFE - } - }, - { - 100, - 79, - 0x39, - 0x008F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x8F, 0x23, 0x1E, 0x10, 0x00, 0x12, 0x28, 0x1E, 0x10, 0x00, 0x12, 0x2D, 0x1E, 0x10, 0x00, 0x64, 0x6B, 0x10, 0x02, 0x30, 0x0E, 0x10, 0x00, 0x02, 0x2B, 0x0E, 0x10, 0x00, 0x02, 0x26, 0x0E, 0x10, 0x00, 0x02, 0x21, 0x0E, 0x10, 0x00, 0x02, 0x1C, 0x0E, 0x10, 0x00, 0x12, 0x1A, 0x1E, 0x10, 0x00, 0x12, 0x1F, 0x1E, 0x10, 0x00, 0x12, 0x24, 0x1E, 0x10, 0x00, 0x12, 0x29, 0x1E, 0x10, 0x00, 0x12, 0x2E, 0x29, 0x35 - } - }, - { - 101, - 79, - 0x39, - 0x0090, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x90, 0x1E, 0x10, 0x00, 0x53, 0x11, 0x7C, 0x11, 0x4D, 0x51, 0x44, 0x06, 0x12, 0x80, 0x0C, 0x11, 0x0E, 0x10, 0x00, 0x47, 0x10, 0x80, 0xA0, 0x0A, 0x55, 0x10, 0x00, 0x55, 0x11, 0x00, 0x55, 0x12, 0x00, 0x7C, 0x12, 0x26, 0x47, 0x42, 0x08, 0xA0, 0x36, 0x62, 0xD3, 0x01, 0x4D, 0x34, 0x51, 0x48, 0x3B, 0x00, 0xC0, 0x1E, 0xB0, 0x09, 0x51, 0x49, 0x3B, 0x01, 0xA0, 0x21, 0xC0, 0x14, 0x51, 0x48, 0x3A, 0x02, 0xE8 - } - }, - { - 102, - 79, - 0x39, - 0x0091, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x91, 0x4F, 0xB0, 0x07, 0x51, 0x49, 0x3A, 0x50, 0xA0, 0x13, 0x7A, 0x49, 0x1E, 0x48, 0x00, 0x80, 0x0C, 0x51, 0x48, 0x2A, 0x49, 0xA0, 0x06, 0x76, 0x49, 0x0E, 0x48, 0x00, 0x4D, 0x34, 0x51, 0x48, 0x3A, 0x4F, 0xC0, 0x0B, 0xB0, 0x13, 0x51, 0x49, 0x3A, 0x50, 0xC0, 0x03, 0xB0, 0x0B, 0x51, 0x48, 0x3F, 0x34, 0x51, 0x49, 0x3F, 0x34, 0x80, 0x09, 0x51, 0x4F, 0x3F, 0x34, 0x51, 0x50, 0x3F, 0x34, 0x50, 0x45, 0x6F - } - }, - { - 103, - 79, - 0x39, - 0x0092, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x92, 0x00, 0x53, 0x10, 0x53, 0x12, 0x51, 0x2D, 0x02, 0x2E, 0x0E, 0x10, 0x00, 0x02, 0x2F, 0x0E, 0x10, 0x00, 0x02, 0x30, 0x0E, 0x10, 0x00, 0x02, 0x31, 0x0E, 0x10, 0x00, 0x12, 0x19, 0x1E, 0x10, 0x00, 0x12, 0x1A, 0x1E, 0x10, 0x00, 0x12, 0x1B, 0x1E, 0x10, 0x00, 0x12, 0x1C, 0x1E, 0x10, 0x00, 0x12, 0x1D, 0x1E, 0x10, 0x00, 0x64, 0x6B, 0x10, 0x02, 0x28, 0x0E, 0x10, 0x00, 0x02, 0x29, 0x0E, 0x10, 0xBB, 0x5C - } - }, - { - 104, - 79, - 0x39, - 0x0093, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x93, 0x00, 0x02, 0x2A, 0x0E, 0x10, 0x00, 0x02, 0x2B, 0x0E, 0x10, 0x00, 0x02, 0x2C, 0x0E, 0x10, 0x00, 0x12, 0x1E, 0x1E, 0x10, 0x00, 0x12, 0x1F, 0x1E, 0x10, 0x00, 0x12, 0x20, 0x1E, 0x10, 0x00, 0x12, 0x21, 0x1E, 0x10, 0x00, 0x12, 0x22, 0x1E, 0x10, 0x00, 0x53, 0x11, 0x7C, 0x11, 0x4D, 0x51, 0x45, 0x06, 0x12, 0x80, 0x0C, 0x11, 0x0E, 0x10, 0x00, 0x47, 0x10, 0x80, 0xA0, 0x0A, 0x55, 0x10, 0x00, 0x4E, 0x83 - } - }, - { - 105, - 79, - 0x39, - 0x0094, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x94, 0x55, 0x11, 0x00, 0x55, 0x12, 0x00, 0x7C, 0x11, 0xB3, 0x47, 0x42, 0x08, 0xA0, 0x36, 0x62, 0xD3, 0x01, 0x4D, 0x34, 0x51, 0x48, 0x3B, 0x00, 0xC0, 0x1E, 0xB0, 0x09, 0x51, 0x49, 0x3B, 0x01, 0xA0, 0x21, 0xC0, 0x14, 0x51, 0x48, 0x3A, 0x51, 0xB0, 0x07, 0x51, 0x49, 0x3A, 0x52, 0xA0, 0x13, 0x7A, 0x49, 0x1E, 0x48, 0x00, 0x80, 0x0C, 0x51, 0x48, 0x2A, 0x49, 0xA0, 0x06, 0x76, 0x49, 0x0E, 0x48, 0x31, 0x4A - } - }, - { - 106, - 79, - 0x39, - 0x0095, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x95, 0x00, 0x4D, 0x34, 0x51, 0x48, 0x3A, 0x51, 0xC0, 0x0B, 0xB0, 0x13, 0x51, 0x49, 0x3A, 0x52, 0xC0, 0x03, 0xB0, 0x0B, 0x51, 0x48, 0x3F, 0x34, 0x51, 0x49, 0x3F, 0x34, 0x80, 0x09, 0x51, 0x51, 0x3F, 0x34, 0x51, 0x52, 0x3F, 0x34, 0x62, 0xD3, 0x02, 0x76, 0x0E, 0x51, 0x0E, 0x55, 0xBC, 0x00, 0x7F, 0x55, 0x12, 0x00, 0x5F, 0x11, 0x45, 0x06, 0x11, 0xFE, 0x5F, 0x10, 0x44, 0x06, 0x10, 0xFE, 0x51, 0x97, 0x17 - } - }, - { - 107, - 79, - 0x39, - 0x0096, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x96, 0x32, 0x08, 0x51, 0x4C, 0x14, 0x32, 0x14, 0x32, 0x16, 0x32, 0x02, 0x55, 0x0F, 0x06, 0x7A, 0x0F, 0x51, 0x0F, 0xA0, 0x74, 0x47, 0x11, 0x80, 0xB0, 0x44, 0x51, 0x4D, 0x78, 0x3A, 0x11, 0xC0, 0x3D, 0x55, 0x13, 0x06, 0x7A, 0x13, 0x51, 0x13, 0xA0, 0x4F, 0x47, 0x10, 0x80, 0xB0, 0x1E, 0x51, 0x4C, 0x78, 0x3A, 0x10, 0xC0, 0x17, 0x58, 0x32, 0x62, 0xD3, 0x02, 0x52, 0x00, 0x58, 0x12, 0x62, 0xD3, 0x19, 0x1C - } - }, - { - 108, - 79, - 0x39, - 0x0097, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x97, 0x00, 0x54, 0x19, 0x76, 0x12, 0x76, 0x10, 0x76, 0x32, 0x8F, 0xD9, 0x58, 0x12, 0x62, 0xD3, 0x00, 0x56, 0x19, 0x00, 0x75, 0x5A, 0x12, 0x76, 0x10, 0x76, 0x32, 0x8F, 0xC8, 0x58, 0x12, 0x62, 0xD3, 0x00, 0x50, 0x00, 0x54, 0x19, 0x75, 0x54, 0x19, 0x75, 0x54, 0x19, 0x75, 0x54, 0x19, 0x75, 0x54, 0x19, 0x75, 0x5A, 0x12, 0x06, 0x32, 0x05, 0x76, 0x11, 0x5F, 0x10, 0x44, 0x06, 0x10, 0xFE, 0x51, 0xA0, 0x2B - } - }, - { - 109, - 79, - 0x39, - 0x0098, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x98, 0x4C, 0x11, 0x05, 0x04, 0x32, 0x8F, 0x88, 0x62, 0xD3, 0x02, 0x18, 0x53, 0x32, 0x7F, 0x62, 0xD3, 0x00, 0x3C, 0x45, 0x01, 0xB0, 0x1B, 0x57, 0x05, 0x52, 0x19, 0x6D, 0x6D, 0x6D, 0x21, 0x1F, 0x53, 0x0F, 0x6D, 0x21, 0x7F, 0x02, 0x0F, 0x54, 0x14, 0x75, 0x5B, 0x39, 0x0A, 0xBF, 0xEB, 0x80, 0x21, 0x51, 0x4D, 0x11, 0x02, 0x3A, 0x45, 0xB0, 0x19, 0x57, 0x0F, 0x52, 0x19, 0x6D, 0x6D, 0x6D, 0x21, 0x4A, 0x80 - } - }, - { - 110, - 79, - 0x39, - 0x0099, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x99, 0x1F, 0x53, 0x0F, 0x6D, 0x21, 0x7F, 0x02, 0x0F, 0x54, 0x1E, 0x75, 0x5B, 0x39, 0x14, 0xBF, 0xEB, 0x3C, 0x44, 0x01, 0xB0, 0x1D, 0x57, 0x01, 0x52, 0x19, 0x6D, 0x6D, 0x6D, 0x21, 0x1F, 0x53, 0x0F, 0x6D, 0x21, 0x7F, 0x02, 0x0F, 0x54, 0x18, 0x5B, 0x01, 0x05, 0x5C, 0x39, 0x15, 0xBF, 0xE9, 0x80, 0x23, 0x51, 0x4C, 0x11, 0x02, 0x3A, 0x44, 0xB0, 0x1B, 0x57, 0x03, 0x52, 0x19, 0x6D, 0x6D, 0x6D, 0xB7, 0x5B - } - }, - { - 111, - 79, - 0x39, - 0x009A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x9A, 0x21, 0x1F, 0x53, 0x0F, 0x6D, 0x21, 0x7F, 0x02, 0x0F, 0x54, 0x1A, 0x5B, 0x01, 0x05, 0x5C, 0x39, 0x17, 0xBF, 0xE9, 0x7F, 0x62, 0xD3, 0x00, 0x51, 0x45, 0xB0, 0x94, 0x55, 0x19, 0x04, 0x55, 0x1A, 0x10, 0x55, 0x1B, 0x10, 0x55, 0x1C, 0x10, 0x55, 0x1D, 0x04, 0x51, 0xBD, 0xB0, 0x23, 0x51, 0x25, 0xA0, 0x0D, 0x51, 0x24, 0x5F, 0x12, 0x26, 0x5F, 0x14, 0x25, 0x92, 0x47, 0x53, 0x1B, 0x51, 0x2A, 0x43, 0x74 - } - }, - { - 112, - 79, - 0x39, - 0x009B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x9B, 0xA0, 0x0F, 0x51, 0x29, 0x5F, 0x12, 0x2B, 0x5F, 0x14, 0x2A, 0x92, 0x37, 0x53, 0x1A, 0x53, 0x1C, 0x57, 0x04, 0x52, 0x23, 0x53, 0x4A, 0x52, 0x19, 0x53, 0x4B, 0x7C, 0x29, 0x2D, 0x50, 0x04, 0x6E, 0x4A, 0x6E, 0x4B, 0x78, 0xBF, 0xFA, 0x52, 0x28, 0x14, 0x4B, 0x1E, 0x4A, 0x00, 0x47, 0x4A, 0x80, 0xA0, 0x07, 0x55, 0x4A, 0x00, 0x55, 0x4B, 0x00, 0x47, 0x4A, 0x7F, 0xA0, 0x04, 0x55, 0x4B, 0xFF, 0xD0, 0x8F - } - }, - { - 113, - 79, - 0x39, - 0x009C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x9C, 0x51, 0x4B, 0x3C, 0xAD, 0x02, 0xA0, 0x0D, 0x3C, 0xAD, 0x03, 0xA0, 0x03, 0x80, 0x10, 0x6D, 0x21, 0x7F, 0x80, 0x0B, 0x6D, 0x21, 0x7F, 0x53, 0x4B, 0x6D, 0x21, 0x7F, 0x02, 0x4B, 0x54, 0x1E, 0x6D, 0x6D, 0x6D, 0x21, 0x1F, 0x54, 0x19, 0x6D, 0x21, 0x7F, 0x05, 0x19, 0x79, 0xDF, 0xA5, 0x51, 0x4D, 0x11, 0x01, 0x3A, 0x45, 0xB0, 0x94, 0x55, 0x2D, 0x04, 0x55, 0x2E, 0x10, 0x55, 0x2F, 0x10, 0x55, 0xF3, 0xD6 - } - }, - { - 114, - 79, - 0x39, - 0x009D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x9D, 0x30, 0x10, 0x55, 0x31, 0x04, 0x51, 0xBD, 0xB0, 0x23, 0x51, 0x25, 0xA0, 0x0D, 0x51, 0x24, 0x5F, 0x12, 0x26, 0x5F, 0x14, 0x25, 0x91, 0xAC, 0x53, 0x2F, 0x51, 0x20, 0xA0, 0x0F, 0x51, 0x1F, 0x5F, 0x12, 0x21, 0x5F, 0x14, 0x20, 0x91, 0x9C, 0x53, 0x2E, 0x53, 0x30, 0x57, 0x04, 0x52, 0x23, 0x53, 0x4A, 0x52, 0x2D, 0x53, 0x4B, 0x7C, 0x29, 0x2D, 0x50, 0x04, 0x6E, 0x4A, 0x6E, 0x4B, 0x78, 0xBF, 0x6F, 0xCF - } - }, - { - 115, - 79, - 0x39, - 0x009E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x9E, 0xFA, 0x52, 0x1E, 0x14, 0x4B, 0x1E, 0x4A, 0x00, 0x47, 0x4A, 0x80, 0xA0, 0x07, 0x55, 0x4A, 0x00, 0x55, 0x4B, 0x00, 0x47, 0x4A, 0x7F, 0xA0, 0x04, 0x55, 0x4B, 0xFF, 0x51, 0x4B, 0x3C, 0xAD, 0x02, 0xA0, 0x0D, 0x3C, 0xAD, 0x03, 0xA0, 0x03, 0x80, 0x10, 0x6D, 0x21, 0x7F, 0x80, 0x0B, 0x6D, 0x21, 0x7F, 0x53, 0x4B, 0x6D, 0x21, 0x7F, 0x02, 0x4B, 0x54, 0x28, 0x6D, 0x6D, 0x6D, 0x21, 0x1F, 0x54, 0xC2, 0x76 - } - }, - { - 116, - 79, - 0x39, - 0x009F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x9F, 0x2D, 0x6D, 0x21, 0x7F, 0x05, 0x2D, 0x79, 0xDF, 0xA5, 0x3C, 0x44, 0x00, 0xB0, 0x97, 0x55, 0x19, 0x04, 0x55, 0x1E, 0x10, 0x55, 0x23, 0x10, 0x55, 0x28, 0x10, 0x55, 0x2D, 0x04, 0x51, 0xBD, 0xB0, 0x23, 0x51, 0x25, 0xA0, 0x0D, 0x51, 0x20, 0x5F, 0x12, 0x2A, 0x5F, 0x14, 0x25, 0x91, 0x14, 0x53, 0x23, 0x51, 0x26, 0xA0, 0x0F, 0x51, 0x21, 0x5F, 0x12, 0x2B, 0x5F, 0x14, 0x26, 0x91, 0x04, 0x53, 0x38, 0x63 - } - }, - { - 117, - 79, - 0x39, - 0x00A0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA0, 0x1E, 0x53, 0x28, 0x57, 0x14, 0x52, 0x1B, 0x53, 0x4A, 0x52, 0x19, 0x53, 0x4B, 0x7C, 0x29, 0x2D, 0x50, 0x04, 0x6E, 0x4A, 0x6E, 0x4B, 0x78, 0xBF, 0xFA, 0x52, 0x1C, 0x14, 0x4B, 0x1E, 0x4A, 0x00, 0x47, 0x4A, 0x80, 0xA0, 0x07, 0x55, 0x4A, 0x00, 0x55, 0x4B, 0x00, 0x47, 0x4A, 0x7F, 0xA0, 0x04, 0x55, 0x4B, 0xFF, 0x51, 0x4B, 0x3C, 0xAD, 0x02, 0xA0, 0x0D, 0x3C, 0xAD, 0x03, 0xA0, 0x03, 0x80, 0xA1, 0x36 - } - }, - { - 118, - 79, - 0x39, - 0x00A1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA1, 0x10, 0x6D, 0x21, 0x7F, 0x80, 0x0B, 0x6D, 0x21, 0x7F, 0x53, 0x4B, 0x6D, 0x21, 0x7F, 0x02, 0x4B, 0x54, 0x1A, 0x6D, 0x6D, 0x6D, 0x21, 0x1F, 0x54, 0x19, 0x6D, 0x21, 0x7F, 0x05, 0x19, 0x5B, 0x11, 0x05, 0x5C, 0xDF, 0xA2, 0x51, 0x4C, 0x11, 0x01, 0x3A, 0x44, 0xB0, 0x97, 0x55, 0x1D, 0x04, 0x55, 0x22, 0x10, 0x55, 0x27, 0x10, 0x55, 0x2C, 0x10, 0x55, 0x31, 0x04, 0x51, 0xBD, 0xB0, 0x23, 0x51, 0xD2, 0x99 - } - }, - { - 119, - 79, - 0x39, - 0x00A2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA2, 0x25, 0xA0, 0x0D, 0x51, 0x20, 0x5F, 0x12, 0x2A, 0x5F, 0x14, 0x25, 0x90, 0x76, 0x53, 0x27, 0x51, 0x24, 0xA0, 0x0F, 0x51, 0x1F, 0x5F, 0x12, 0x29, 0x5F, 0x14, 0x24, 0x90, 0x66, 0x53, 0x22, 0x53, 0x2C, 0x57, 0x14, 0x52, 0x1B, 0x53, 0x4A, 0x52, 0x1D, 0x53, 0x4B, 0x7C, 0x29, 0x2D, 0x50, 0x04, 0x6E, 0x4A, 0x6E, 0x4B, 0x78, 0xBF, 0xFA, 0x52, 0x1A, 0x14, 0x4B, 0x1E, 0x4A, 0x00, 0x47, 0x4A, 0xB3, 0x5C - } - }, - { - 120, - 79, - 0x39, - 0x00A3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA3, 0x80, 0xA0, 0x07, 0x55, 0x4A, 0x00, 0x55, 0x4B, 0x00, 0x47, 0x4A, 0x7F, 0xA0, 0x04, 0x55, 0x4B, 0xFF, 0x51, 0x4B, 0x3C, 0xAD, 0x02, 0xA0, 0x0D, 0x3C, 0xAD, 0x03, 0xA0, 0x03, 0x80, 0x10, 0x6D, 0x21, 0x7F, 0x80, 0x0B, 0x6D, 0x21, 0x7F, 0x53, 0x4B, 0x6D, 0x21, 0x7F, 0x02, 0x4B, 0x54, 0x1C, 0x6D, 0x6D, 0x6D, 0x21, 0x1F, 0x54, 0x1D, 0x6D, 0x21, 0x7F, 0x05, 0x1D, 0x5B, 0x11, 0x05, 0x5C, 0x0D, 0x11 - } - }, - { - 121, - 79, - 0x39, - 0x00A4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA4, 0xDF, 0xA2, 0x7F, 0x55, 0x11, 0x00, 0x04, 0x12, 0x0E, 0x11, 0x00, 0x65, 0x12, 0x6B, 0x11, 0x65, 0x12, 0x6B, 0x11, 0x65, 0x12, 0x6B, 0x11, 0x65, 0x12, 0x6B, 0x11, 0x55, 0x10, 0x00, 0x55, 0x13, 0x00, 0x7C, 0x11, 0x4D, 0x51, 0x12, 0x39, 0x10, 0xD0, 0x03, 0x50, 0x10, 0x7F, 0x12, 0x4B, 0x55, 0x10, 0x08, 0x47, 0x4B, 0x01, 0xA0, 0x03, 0x02, 0x4A, 0x6D, 0x6E, 0x4B, 0x7A, 0x10, 0xBF, 0xF3, 0x1A, 0x2C - } - }, - { - 122, - 79, - 0x39, - 0x00A5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA5, 0x53, 0x4A, 0x7F, 0x62, 0xD0, 0x00, 0x3C, 0x0E, 0x02, 0xC0, 0x0E, 0x55, 0x36, 0x00, 0x90, 0x09, 0x47, 0x36, 0x40, 0xA0, 0x04, 0x7C, 0x14, 0x1F, 0x7F, 0x70, 0xBF, 0x62, 0xD4, 0x02, 0x62, 0xD3, 0x02, 0x50, 0x00, 0x53, 0x32, 0x53, 0x35, 0x53, 0x44, 0x53, 0x45, 0x55, 0x34, 0x99, 0x3E, 0x34, 0x53, 0x19, 0x3E, 0x34, 0x53, 0x1A, 0x3E, 0x34, 0x53, 0x1B, 0x76, 0x45, 0x51, 0x45, 0x3A, 0x0E, 0x9D, 0x33 - } - }, - { - 123, - 79, - 0x39, - 0x00A6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA6, 0xD1, 0x1F, 0x3E, 0x34, 0x53, 0x1C, 0x3E, 0x34, 0x53, 0x1D, 0x3E, 0x34, 0x53, 0x1E, 0x51, 0x19, 0x12, 0x1C, 0xD0, 0x03, 0x73, 0x74, 0x53, 0x1F, 0x51, 0x1A, 0x12, 0x1D, 0xD0, 0x03, 0x73, 0x74, 0x53, 0x20, 0x51, 0x1F, 0xA0, 0x07, 0x39, 0x02, 0xA0, 0x03, 0x80, 0x2D, 0x51, 0x20, 0xA0, 0x05, 0x39, 0x02, 0xB0, 0x25, 0x51, 0x19, 0x3A, 0x1C, 0xC0, 0x0B, 0xA0, 0x11, 0x51, 0x1B, 0x12, 0x4C, 0xEF, 0xD8 - } - }, - { - 124, - 79, - 0x39, - 0x00A7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA7, 0x53, 0x21, 0x80, 0x0C, 0x51, 0x1B, 0x02, 0x4C, 0x53, 0x21, 0x80, 0x04, 0x5F, 0x21, 0x1B, 0x51, 0x1A, 0x12, 0x1D, 0x67, 0x14, 0x21, 0x80, 0x8D, 0x3C, 0x1F, 0x02, 0xB0, 0x41, 0x3C, 0x20, 0x01, 0xB0, 0x3C, 0x51, 0x19, 0x3A, 0x1C, 0xC0, 0x0B, 0xA0, 0x11, 0x51, 0x1B, 0x12, 0x4C, 0x53, 0x21, 0x80, 0x0C, 0x51, 0x1B, 0x02, 0x4C, 0x53, 0x21, 0x80, 0x04, 0x5F, 0x21, 0x1B, 0x51, 0x1A, 0x3A, 0x1F, 0x39 - } - }, - { - 125, - 79, - 0x39, - 0x00A8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA8, 0x1D, 0xC0, 0x0E, 0x58, 0x21, 0x52, 0x00, 0x79, 0x3B, 0x00, 0xD0, 0x10, 0x7A, 0x21, 0x80, 0x0C, 0x58, 0x21, 0x52, 0x00, 0x75, 0x3B, 0x00, 0xD0, 0x03, 0x76, 0x21, 0x80, 0x48, 0x3C, 0x1F, 0x01, 0xB0, 0x41, 0x3C, 0x20, 0x02, 0xB0, 0x3C, 0x51, 0x1A, 0x3A, 0x1D, 0xC0, 0x08, 0x51, 0x1B, 0x78, 0x53, 0x21, 0x80, 0x06, 0x51, 0x1B, 0x74, 0x53, 0x21, 0x51, 0x19, 0x3A, 0x1C, 0xC0, 0x0B, 0xA0, 0x9C, 0x34 - } - }, - { - 126, - 79, - 0x39, - 0x00A9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xA9, 0x11, 0x51, 0x21, 0x12, 0x4C, 0x53, 0x1F, 0x80, 0x0C, 0x51, 0x21, 0x02, 0x4C, 0x53, 0x1F, 0x80, 0x04, 0x55, 0x1F, 0x00, 0x58, 0x21, 0x52, 0x00, 0x58, 0x1F, 0x3B, 0x00, 0xD0, 0x03, 0x5A, 0x21, 0x80, 0x03, 0x8F, 0x17, 0x58, 0x1B, 0x52, 0x00, 0x58, 0x21, 0x13, 0x00, 0xCF, 0x0D, 0x3A, 0x18, 0xDF, 0x09, 0x58, 0x1E, 0x52, 0x00, 0x58, 0x21, 0x13, 0x00, 0xCE, 0xFF, 0x3A, 0x18, 0xDE, 0xFB, 0xB0, 0x5D - } - }, - { - 127, - 79, - 0x39, - 0x00AA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xAA, 0x58, 0x1B, 0x52, 0x00, 0x58, 0x1E, 0x3B, 0x00, 0xD0, 0x0A, 0x52, 0x00, 0x01, 0x01, 0x55, 0x36, 0x40, 0x80, 0x06, 0x01, 0x01, 0x55, 0x36, 0x40, 0x58, 0x21, 0x54, 0x00, 0x76, 0x32, 0x8E, 0xDB, 0x76, 0x44, 0x5F, 0x45, 0x44, 0x06, 0x35, 0x03, 0x51, 0x35, 0x55, 0x34, 0x99, 0x04, 0x34, 0x51, 0x44, 0x3A, 0x0E, 0xCE, 0xBA, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x62, 0xD0, 0x00, 0x70, 0xCF, 0x71, 0x06, 0x0A - } - }, - { - 128, - 79, - 0x39, - 0x00AB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xAB, 0x20, 0x51, 0x9A, 0x60, 0xA0, 0x51, 0x9C, 0x60, 0xA2, 0x51, 0x9B, 0x60, 0xA1, 0x51, 0x9E, 0x60, 0xC7, 0x51, 0x9D, 0x60, 0xA4, 0x70, 0xCF, 0x7F, 0x62, 0xD0, 0x00, 0x62, 0xD5, 0x00, 0x62, 0xD4, 0x00, 0x62, 0xD3, 0x00, 0x55, 0xFA, 0x00, 0x50, 0x06, 0x55, 0xF8, 0x3A, 0x7C, 0x00, 0x60, 0x3C, 0xF8, 0x05, 0xB0, 0x12, 0x70, 0xCF, 0x71, 0x20, 0x62, 0xA6, 0x00, 0x71, 0x30, 0x62, 0x1B, 0x30, 0xAA, 0x53 - } - }, - { - 129, - 79, - 0x39, - 0x00AC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xAC, 0x43, 0x1B, 0x40, 0x70, 0xCF, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x62, 0xD0, 0x03, 0x51, 0xE1, 0x54, 0x01, 0x51, 0xE0, 0x54, 0x00, 0x38, 0xFE, 0x20, 0x7F, 0x7F, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x62, 0xD0, 0x00, 0x26, 0xAF, 0xFD, 0x7C, 0x72, 0x51, 0x26, 0xAE, 0xFB, 0x51, 0xAE, 0x60, 0x00, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0xEF, 0xDE - } - }, - { - 130, - 79, - 0x39, - 0x00AD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xAD, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x62, 0xD0, 0x00, 0x51, 0xAF, 0x29, 0x02, 0x7C, 0x6F, 0x20, 0x62, 0xD0, 0x00, 0x51, 0xAE, 0x29, 0x04, 0x53, 0xAE, 0x51, 0xAE, 0x60, 0x00, 0x20, 0x7F, 0x7F, 0x7F, 0x08, 0x62, 0xD0, 0x00, 0x55, 0xFA, 0x00, 0x62, 0xD5, 0x00, 0x62, 0xD4, 0x00, 0x4F, 0x5B, 0x01, 0x03, 0x53, 0xF9, 0x55, 0xF8, 0x3A, 0x50, 0xE3, 0xC7 - } - }, - { - 131, - 79, - 0x39, - 0x00AE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xAE, 0x06, 0x00, 0x20, 0x70, 0xBF, 0x62, 0xD3, 0x00, 0x52, 0xF8, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x62, 0xD0, 0x00, 0x55, 0xFA, 0x00, 0x62, 0xD5, 0x00, 0x62, 0xD4, 0x00, 0x4F, 0x5B, 0x01, 0x03, 0x53, 0xF9, 0x55, 0xF8, 0x3A, 0x50, 0x06, 0x00, 0x7F, 0x11, 0x04, 0x4B, 0xD0, 0x04, 0x78, 0xC0, 0x09, 0x3A, 0x80, 0x40, 0x79, 0x19, 0x00, 0xDF, 0xF9, 0x7F, 0x71, 0x40, 0xA0, 0x05, 0x70, 0xCF, 0x71, 0xD5, 0xAC - } - }, - { - 132, - 79, - 0x39, - 0x00AF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xAF, 0x10, 0x5E, 0x00, 0x70, 0xCF, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x56, 0x00, 0x00, 0x80, 0x13, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xC0, 0x7C, 0x6F, 0x54, 0x52, 0x00, 0x3F, 0xE8, 0x77, 0x00, 0x3D, 0x00, 0x04, 0xCF, 0xEA, 0x62, 0xD0, 0x04, 0x55, 0xB6, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xB5, 0x00, 0x7C, 0x73, 0x74, 0x38, 0xFF, 0x20, 0x7F, 0x7F, 0x10, 0x4F, 0xBC, 0x7B - } - }, - { - 133, - 79, - 0x39, - 0x00B0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB0, 0x38, 0x01, 0x10, 0x7C, 0x11, 0x47, 0x62, 0xD0, 0x00, 0x20, 0x54, 0x00, 0x50, 0x0F, 0x08, 0x10, 0x7C, 0x2B, 0x38, 0x38, 0xFE, 0x52, 0x00, 0x62, 0xD0, 0x00, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x56, 0x01, 0x00, 0x9F, 0xD7, 0x62, 0xD0, 0x00, 0x54, 0x00, 0x52, 0x00, 0x08, 0x7C, 0x47, 0x34, 0x38, 0xFF, 0x52, 0x00, 0x08, 0x90, 0x46, 0x52, 0x00, 0x08, 0x62, 0xD0, 0x04, 0x51, 0x2E, 0x60 - } - }, - { - 134, - 79, - 0x39, - 0x00B1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB1, 0xB5, 0x08, 0x7C, 0x3A, 0x9B, 0x38, 0xFD, 0x62, 0xD0, 0x00, 0x54, 0x01, 0x5A, 0xE8, 0x06, 0xE8, 0x01, 0x50, 0x0F, 0x08, 0x51, 0xE8, 0x08, 0x52, 0x00, 0x08, 0x91, 0x47, 0x62, 0xD0, 0x00, 0x5A, 0xE8, 0x06, 0xE8, 0x01, 0x50, 0x0F, 0x08, 0x51, 0xE8, 0x08, 0x7C, 0x2B, 0x3C, 0x38, 0xFB, 0x52, 0x00, 0x62, 0xD0, 0x04, 0x53, 0xB5, 0x52, 0x01, 0x62, 0xD0, 0x00, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0xF0, 0xE5 - } - }, - { - 135, - 79, - 0x39, - 0x00B2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB2, 0x4F, 0x38, 0x06, 0x50, 0x04, 0x3B, 0xFC, 0xD0, 0x04, 0x56, 0xFC, 0x04, 0x56, 0x05, 0x00, 0x56, 0x04, 0x00, 0x80, 0x67, 0x56, 0x02, 0xE0, 0x56, 0x01, 0x01, 0x56, 0x00, 0x00, 0x80, 0x23, 0x7C, 0x6F, 0x4C, 0x52, 0x01, 0x7C, 0x70, 0xCD, 0x7C, 0x6F, 0x44, 0x06, 0xE8, 0xC4, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x3B, 0x03, 0xB0, 0x03, 0x80, 0x0F, 0x07, 0x02, 0x08, 0x0F, 0x01, 0x00, 0x77, 0x09, 0x18 - } - }, - { - 136, - 79, - 0x39, - 0x00B3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB3, 0x00, 0x52, 0x00, 0x3B, 0xFC, 0xCF, 0xD9, 0x52, 0x00, 0x3B, 0xFC, 0xA0, 0x2C, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x18, 0x06, 0xE8, 0xC0, 0x7C, 0x6F, 0x54, 0x52, 0x00, 0x3F, 0xE8, 0x7C, 0x6F, 0x18, 0x06, 0xE8, 0xC4, 0x7C, 0x6F, 0x54, 0x52, 0x03, 0x3F, 0xE8, 0x52, 0x02, 0x53, 0xE8, 0x52, 0x01, 0x60, 0xD5, 0x50, 0xFF, 0x3F, 0xE8, 0x77, 0x05, 0x77, 0x04, 0x62, 0xD0, 0x04, 0x52, 0x04, 0x3A, 0xDB, 0xBD - } - }, - { - 137, - 79, - 0x39, - 0x00B4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB4, 0xB6, 0xCF, 0x92, 0x52, 0x05, 0x62, 0xD0, 0x04, 0x53, 0xB6, 0x3D, 0x05, 0x04, 0xD0, 0x55, 0x56, 0x02, 0xE0, 0x56, 0x01, 0x01, 0x56, 0x00, 0x00, 0x80, 0x44, 0x7C, 0x6F, 0x4C, 0x52, 0x01, 0x7C, 0x70, 0xCD, 0x3D, 0x03, 0xFF, 0xA0, 0x2F, 0x62, 0xD0, 0x04, 0x51, 0xB6, 0x7C, 0x70, 0x0E, 0x06, 0xE8, 0xC0, 0x7C, 0x6F, 0x54, 0x52, 0x00, 0x7C, 0x72, 0xE6, 0x7C, 0x70, 0x0E, 0x06, 0xE8, 0xC4, 0x09, 0x1A - } - }, - { - 138, - 79, - 0x39, - 0x00B5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB5, 0x7C, 0x6F, 0x54, 0x52, 0x03, 0x7C, 0x72, 0xE6, 0x01, 0x01, 0x53, 0xB6, 0x62, 0xD0, 0x00, 0x39, 0x04, 0xC0, 0x03, 0x80, 0x0F, 0x07, 0x02, 0x08, 0x0F, 0x01, 0x00, 0x77, 0x00, 0x52, 0x00, 0x3B, 0xFC, 0xCF, 0xB8, 0x56, 0x04, 0x00, 0x80, 0x32, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x44, 0x06, 0xE8, 0xC4, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x7C, 0x72, 0x31, 0x06, 0xE6, 0xC0, 0x0E, 0x76, 0xF5 - } - }, - { - 139, - 79, - 0x39, - 0x00B6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB6, 0xE7, 0x03, 0x51, 0xE7, 0x60, 0xD4, 0x3E, 0xE6, 0x7C, 0x6E, 0xB6, 0x7C, 0x70, 0x1E, 0x06, 0xE6, 0xE0, 0x0E, 0xE7, 0x01, 0x7C, 0x6D, 0xEA, 0x77, 0x04, 0x52, 0x04, 0x3B, 0x05, 0xCF, 0xCA, 0x38, 0xFA, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x3D, 0xFC, 0x00, 0xB0, 0x06, 0x7C, 0x73, 0x74, 0x80, 0x28, 0x90, 0x29, 0x54, 0x00, 0x3D, 0x00, 0x00, 0xA0, 0x1F, 0x62, 0xD0, 0x04, 0x3C, 0xB4, 0x00, 0xF5, 0xF4 - } - }, - { - 140, - 79, - 0x39, - 0x00B7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB7, 0xB0, 0x10, 0x62, 0xD0, 0x00, 0x52, 0xFB, 0x53, 0xE8, 0x52, 0xFA, 0x60, 0xD5, 0x50, 0x01, 0x3F, 0xE8, 0x52, 0x00, 0x62, 0xD0, 0x04, 0x53, 0xB4, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x7C, 0x6F, 0xC9, 0x80, 0x22, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x62, 0xD0, 0x00, 0x51, 0x16, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0x04, 0x13 - } - }, - { - 141, - 79, - 0x39, - 0x00B8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB8, 0xD0, 0x03, 0x77, 0x01, 0x77, 0x00, 0x3D, 0x00, 0x99, 0xD0, 0x07, 0x50, 0x28, 0x3B, 0x01, 0xDF, 0xD5, 0x50, 0x28, 0x3B, 0x01, 0xD0, 0x08, 0x62, 0xD0, 0x00, 0x50, 0x10, 0x80, 0x06, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x6F, 0x2F, 0xB0, 0x0A, 0x3D, 0xFC, 0x00, 0xA0, 0x4E, 0x91, 0x78, 0x80, 0x4A, 0x3D, 0x00, 0x10, 0xB0, 0x03, 0x80, 0x43, 0xFB, 0x02 - } - }, - { - 142, - 79, - 0x39, - 0x00B9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xB9, 0x3D, 0x00, 0x20, 0xB0, 0x2B, 0x62, 0xD0, 0x04, 0x51, 0xB5, 0x21, 0x0F, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xB4, 0x21, 0xF0, 0x62, 0xD0, 0x00, 0x2A, 0xE9, 0x62, 0xD0, 0x03, 0x53, 0x9A, 0x51, 0x9A, 0x08, 0x50, 0x02, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x80, 0x14, 0x3D, 0x00, 0x30, 0xB0, 0x05, 0x90, 0x10, 0x80, 0x0B, 0x62, 0xD0, 0x03, 0x47, 0x99, 0x40, 0xA0, 0x03, 0xDB, 0xC3 - } - }, - { - 143, - 79, - 0x39, - 0x00BA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xBA, 0x90, 0xE4, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x04, 0x62, 0xD0, 0x04, 0x51, 0xB5, 0x08, 0x50, 0x23, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x62, 0xD0, 0x04, 0x50, 0x04, 0x3A, 0xB5, 0xC0, 0xB7, 0x56, 0x03, 0x00, 0x80, 0xA9, 0x62, 0xD0, 0x00, 0x52, 0x03, 0x7C, 0x6D, 0x8A, 0x51, 0xE8, 0x01, 0xE0, 0x54, 0x02, 0x51, 0xE9, 0x09, 0x01, 0x54, 0x01, 0x52, 0x03, 0x64, 0x64, 0x64, 0x01, 0x8B, 0x24 - } - }, - { - 144, - 79, - 0x39, - 0x00BB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xBB, 0x03, 0x54, 0x00, 0x7C, 0x6F, 0xF6, 0x08, 0x52, 0x00, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x01, 0x01, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x7C, 0x6D, 0xE3, 0x3E, 0xE8, 0x53, 0xE8, 0x51, 0xE9, 0x08, 0x51, 0xE8, 0x08, 0x52, 0x00, 0x01, 0x01, 0x08, 0x7C, 0x32, 0x52, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x01, 0x03, 0x7C, 0x6E, 0xA3, 0x08, 0x52, 0x00, 0x01, 0x03, 0x2A, 0x63 - } - }, - { - 145, - 79, - 0x39, - 0x00BC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xBC, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFB, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x01, 0x04, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x7C, 0x6D, 0xE3, 0x3E, 0xE8, 0x53, 0xE8, 0x51, 0xE9, 0x08, 0x51, 0xE8, 0x08, 0x52, 0x00, 0x01, 0x04, 0x08, 0x7C, 0x32, 0x52, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x01, 0x06, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x7C, 0x6D, 0xE3, 0x3E, 0xE8, 0x53, 0xE8, 0x51, 0xE9, 0x08, 0x51, 0x0A, 0x24 - } - }, - { - 146, - 79, - 0x39, - 0x00BD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xBD, 0xE8, 0x08, 0x52, 0x00, 0x01, 0x06, 0x08, 0x7C, 0x32, 0x52, 0x38, 0xFA, 0x77, 0x03, 0x62, 0xD0, 0x04, 0x52, 0x03, 0x3A, 0xB5, 0xCF, 0x50, 0x50, 0x00, 0x08, 0x50, 0x25, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x38, 0xFC, 0x20, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xB5, 0x21, 0x0F, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xB4, 0x21, 0xF0, 0x62, 0xD0, 0x00, 0x2A, 0xE9, 0x62, 0xD0, 0xCB, 0xA7 - } - }, - { - 147, - 79, - 0x39, - 0x00BE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xBE, 0x03, 0x53, 0x9A, 0x51, 0x9A, 0x08, 0x50, 0x02, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x62, 0xD0, 0x01, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x50, 0x03, 0x08, 0x7C, 0x32, 0x52, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x50, 0x05, 0x08, 0x7C, 0x32, 0x52, 0x38, 0xFA, 0x7F, 0x10, 0x4F, 0x38, 0x07, 0x62, 0xD0, 0x04, 0x51, 0xB5, 0x21, 0x0F, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x62, 0xD0, 0xB2 - } - }, - { - 148, - 79, - 0x39, - 0x00BF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xBF, 0xD0, 0x04, 0x51, 0xB4, 0x21, 0xF0, 0x62, 0xD0, 0x00, 0x2A, 0xE9, 0x62, 0xD0, 0x03, 0x53, 0x9A, 0x51, 0x9A, 0x08, 0x50, 0x02, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x56, 0x00, 0x00, 0x80, 0xCA, 0x56, 0x04, 0x00, 0x62, 0xD0, 0x04, 0x52, 0x00, 0x3A, 0xB5, 0xD0, 0x12, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xC0, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x54, 0x04, 0x62, 0xD0, 0x00, 0x3F, 0x91 - } - }, - { - 149, - 79, - 0x39, - 0x00C0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC0, 0x52, 0x04, 0x7C, 0x6D, 0x8A, 0x51, 0xE8, 0x01, 0xE0, 0x54, 0x02, 0x51, 0xE9, 0x09, 0x01, 0x54, 0x01, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x81, 0x0E, 0xE9, 0x0D, 0x7C, 0x6F, 0x5C, 0x54, 0x03, 0x52, 0x02, 0x01, 0x06, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x7C, 0x6D, 0xE3, 0x3E, 0xE8, 0x53, 0xE8, 0x51, 0xE9, 0x08, 0x51, 0xE8, 0x08, 0x52, 0x03, 0x08, 0x7C, 0x32, 0x52, 0x38, 0xFD, 0x62, 0xD0, 0xD7, 0xC2 - } - }, - { - 150, - 79, - 0x39, - 0x00C1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC1, 0x00, 0x52, 0x02, 0x01, 0x04, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x7C, 0x6D, 0xE3, 0x3E, 0xE8, 0x53, 0xE8, 0x51, 0xE9, 0x08, 0x51, 0xE8, 0x08, 0x52, 0x03, 0x01, 0x02, 0x08, 0x7C, 0x32, 0x52, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x01, 0x03, 0x7C, 0x6E, 0xA3, 0x08, 0x52, 0x03, 0x01, 0x04, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFB, 0x7C, 0x6F, 0x4C, 0x52, 0x01, 0x60, 0xD4, 0x3E, 0xE8, 0x54, 0x05, 0xAB, 0x6B - } - }, - { - 151, - 79, - 0x39, - 0x00C2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC2, 0x48, 0x00, 0x01, 0xA0, 0x18, 0x52, 0x05, 0x21, 0x0F, 0x53, 0xE9, 0x52, 0x06, 0x2A, 0xE9, 0x08, 0x52, 0x03, 0x11, 0x01, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x80, 0x0C, 0x52, 0x05, 0x62, 0xD0, 0x00, 0x64, 0x64, 0x64, 0x64, 0x54, 0x06, 0x77, 0x00, 0x3D, 0x00, 0x04, 0xCF, 0x33, 0x38, 0xF9, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x71, 0x10, 0x41, 0x04, 0x5F, 0x70, 0xCF, 0x62, 0xD0, 0x00, 0x4D, 0xB0 - } - }, - { - 152, - 79, - 0x39, - 0x00C3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC3, 0x51, 0xAF, 0x29, 0xA0, 0x7C, 0x6F, 0x20, 0x10, 0x7C, 0x20, 0x0B, 0x7C, 0x20, 0x50, 0x20, 0x10, 0x50, 0x01, 0x08, 0x50, 0x00, 0x08, 0x50, 0xA0, 0x08, 0x08, 0x7C, 0x20, 0x57, 0x38, 0xFC, 0x20, 0x62, 0xC8, 0x0B, 0x62, 0xCA, 0x24, 0x43, 0xD6, 0x01, 0x62, 0xCD, 0x00, 0x56, 0x00, 0x20, 0x80, 0x06, 0x62, 0xCF, 0x00, 0x7B, 0x00, 0x3D, 0x00, 0x00, 0xBF, 0xF7, 0x41, 0xD6, 0xFE, 0x38, 0xFF, 0x54, 0xBF - } - }, - { - 153, - 79, - 0x39, - 0x00C4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC4, 0x20, 0x7F, 0x10, 0x4F, 0x3D, 0xFC, 0x21, 0xD0, 0x0C, 0x41, 0xD6, 0xEF, 0x41, 0xE0, 0x7F, 0x62, 0xC8, 0x0B, 0x80, 0x0A, 0x62, 0xC8, 0x00, 0x43, 0xD6, 0x10, 0x43, 0xE0, 0x80, 0x20, 0x7F, 0x43, 0xD6, 0x01, 0x40, 0x62, 0xD0, 0x00, 0x51, 0xAF, 0x29, 0xA0, 0x7C, 0x6F, 0x20, 0x71, 0x10, 0x43, 0x04, 0xA0, 0x70, 0xCF, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x5D, 0xF7, 0x54, 0x00, 0x70, 0xFE, 0x7C, 0xDE, 0xD4 - } - }, - { - 154, - 79, - 0x39, - 0x00C5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC5, 0x70, 0xF8, 0xB0, 0x13, 0x7C, 0x73, 0x90, 0xBF, 0xFC, 0x71, 0x01, 0x40, 0x70, 0xFE, 0x62, 0xE3, 0x38, 0x41, 0xD6, 0xFE, 0x80, 0x06, 0x10, 0x7C, 0x33, 0x60, 0x20, 0x71, 0x10, 0x41, 0x04, 0x5F, 0x70, 0xCF, 0x62, 0xD0, 0x00, 0x51, 0xAF, 0x29, 0xA0, 0x7C, 0x6F, 0x20, 0x48, 0x00, 0x01, 0xA0, 0x03, 0x71, 0x01, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x7C, 0x33, 0x60, 0x20, 0x71, 0x10, 0x41, 0x04, 0x7F, 0x17 - } - }, - { - 155, - 79, - 0x39, - 0x00C6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC6, 0x5F, 0x70, 0xCF, 0x62, 0xD0, 0x00, 0x51, 0xAF, 0x29, 0xA0, 0x7C, 0x6F, 0x20, 0x71, 0x10, 0x43, 0xEC, 0x02, 0x70, 0xCF, 0x62, 0xDA, 0x7F, 0x43, 0xE0, 0x80, 0x9F, 0x83, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x9F, 0x92, 0x71, 0x10, 0x43, 0xEC, 0x02, 0x70, 0xCF, 0x62, 0xDA, 0x7F, 0x43, 0xE0, 0x80, 0x9F, 0x6D, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x73, 0x89, 0x38, 0xFF, 0x20, 0xF5, 0x04 - } - }, - { - 156, - 79, - 0x39, - 0x00C7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC7, 0x7F, 0x7C, 0x73, 0x89, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x5D, 0xC8, 0x39, 0x00, 0xB0, 0x18, 0x7C, 0x73, 0x90, 0xA0, 0x09, 0x56, 0x01, 0x01, 0x56, 0x00, 0x00, 0x80, 0x04, 0x7C, 0x6F, 0xC9, 0x62, 0xD0, 0x00, 0x52, 0x01, 0x80, 0x1D, 0x5D, 0xC9, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x47, 0xE9, 0x01, 0xA0, 0x09, 0x56, 0x01, 0x01, 0x56, 0x00, 0x00, 0x80, 0x04, 0x7C, 0x6F, 0xC9, 0x62, 0xD0, 0x00, 0xEB, 0xF1 - } - }, - { - 157, - 79, - 0x39, - 0x00C8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC8, 0x52, 0x01, 0x38, 0xFE, 0x20, 0x7F, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x70, 0xF8, 0xA0, 0x25, 0x5D, 0xD6, 0x53, 0xE9, 0x2E, 0xE9, 0xFE, 0x51, 0xE9, 0x54, 0x00, 0x43, 0xD6, 0x01, 0x52, 0xFC, 0x60, 0xCD, 0x52, 0xFB, 0x60, 0xCF, 0x5D, 0xD6, 0x53, 0xE9, 0x52, 0x00, 0x24, 0xE9, 0x51, 0xE9, 0x60, 0xD6, 0x80, 0x16, 0x3D, 0xFC, 0xA0, 0xD0, 0x11, 0x7C, 0x6F, 0x06, 0x28 - } - }, - { - 158, - 79, - 0x39, - 0x00C9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xC9, 0xB9, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0x00, 0x7C, 0x71, 0x08, 0x52, 0xFB, 0x3F, 0xE8, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x52, 0xFB, 0x54, 0x01, 0x52, 0xFA, 0x54, 0x00, 0x7C, 0x70, 0xF8, 0xA0, 0x1C, 0x7C, 0x71, 0x65, 0x60, 0xCD, 0x52, 0x00, 0x60, 0xCF, 0x52, 0x01, 0x60, 0xCF, 0x5D, 0xD6, 0x53, 0xE9, 0x52, 0x02, 0x24, 0xE9, 0x51, 0xE9, 0x60, 0xD6, 0x80, 0x26, 0x3D, 0xFC, 0x41, 0x9F - } - }, - { - 159, - 79, - 0x39, - 0x00CA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xCA, 0x9F, 0xD0, 0x21, 0x7C, 0x6F, 0xB9, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x01, 0x7C, 0x6F, 0xD9, 0x52, 0xFC, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0x01, 0x7C, 0x71, 0x08, 0x52, 0x01, 0x3F, 0xE8, 0x38, 0xFD, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x7C, 0x70, 0xF8, 0xA0, 0x29, 0x5D, 0xD6, 0x53, 0xE9, 0x2E, 0xE9, 0xFE, 0x51, 0xE9, 0x54, 0x01, 0x43, 0xD6, 0x01, 0x10, 0x52, 0xEA, 0xF2 - } - }, - { - 160, - 79, - 0x39, - 0x00CB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xCB, 0xFC, 0x7C, 0x33, 0x49, 0x62, 0xD0, 0x00, 0x20, 0x54, 0x00, 0x5D, 0xD6, 0x53, 0xE9, 0x52, 0x01, 0x24, 0xE9, 0x51, 0xE9, 0x60, 0xD6, 0x80, 0x17, 0x3D, 0xFC, 0xA0, 0xD0, 0x12, 0x7C, 0x6F, 0xB9, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x54, 0x00, 0x52, 0x00, 0x62, 0xD0, 0x00, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x7C, 0x70, 0xF8, 0xA0, 0x1B, 0x45, 0xA9 - } - }, - { - 161, - 79, - 0x39, - 0x00CC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xCC, 0x7C, 0x71, 0x65, 0x08, 0x7C, 0x33, 0x53, 0x38, 0xFF, 0x7C, 0x72, 0x25, 0x5D, 0xD6, 0x53, 0xE9, 0x52, 0x02, 0x24, 0xE9, 0x51, 0xE9, 0x60, 0xD6, 0x80, 0x29, 0x3D, 0xFC, 0x9F, 0xD0, 0x24, 0x7C, 0x6F, 0xB9, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x54, 0x00, 0x52, 0xFC, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0x01, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0xFD, 0x1A - } - }, - { - 162, - 79, - 0x39, - 0x00CD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xCD, 0x54, 0x01, 0x7C, 0x71, 0x2E, 0x38, 0xFD, 0x20, 0x7F, 0x60, 0xCD, 0x5D, 0xF7, 0x08, 0x70, 0xFE, 0x5D, 0xCF, 0x7E, 0x60, 0xCD, 0x5D, 0xF7, 0x08, 0x70, 0xFE, 0x5D, 0xCF, 0x5C, 0x5D, 0xCF, 0x7E, 0x49, 0xC9, 0x01, 0xBF, 0xFC, 0x41, 0xD6, 0xFE, 0x7F, 0x41, 0x05, 0xF7, 0x7C, 0x73, 0x82, 0x62, 0xD0, 0x00, 0x51, 0xAF, 0x29, 0x08, 0x7C, 0x6F, 0x20, 0x71, 0x10, 0x43, 0x05, 0x08, 0x43, 0x04, 0xA4, 0x69 - } - }, - { - 163, - 79, - 0x39, - 0x00CE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xCE, 0x08, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x55, 0xB9, 0x00, 0x62, 0xD0, 0x03, 0x55, 0x99, 0x04, 0x55, 0x9A, 0x00, 0x55, 0x9B, 0xF8, 0x55, 0x9C, 0x00, 0x55, 0x9E, 0x64, 0x55, 0x9D, 0x32, 0x55, 0x9F, 0x00, 0x55, 0xA0, 0x00, 0x7C, 0x30, 0xB2, 0x90, 0x10, 0x7C, 0x6F, 0x64, 0x10, 0x57, 0x01, 0x50, 0xF4, 0x7C, 0x2B, 0xA8, 0x20, 0x7C, 0x6E, 0xE8, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x7C, 0x31, 0x35, 0x13, 0x48 - } - }, - { - 164, - 79, - 0x39, - 0x00CF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xCF, 0x7C, 0x6F, 0x2F, 0xB0, 0x06, 0x56, 0x01, 0x20, 0x80, 0x04, 0x56, 0x01, 0xA0, 0x52, 0x01, 0x08, 0x7C, 0x31, 0x02, 0x38, 0xFF, 0x62, 0xD0, 0x03, 0x51, 0x99, 0x21, 0xFC, 0x62, 0xD0, 0x00, 0x08, 0x50, 0x00, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x20, 0x08, 0x50, 0x01, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x3D, 0x00, 0x00, 0xB0, 0x28, 0x62, 0xD0, 0x04, 0x51, 0xB9, 0x08, 0x50, 0x01, 0x08, 0x7C, 0x7C, 0x1B - } - }, - { - 165, - 79, - 0x39, - 0x00D0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD0, 0x32, 0x0C, 0x38, 0xFE, 0x50, 0x00, 0x08, 0x50, 0x02, 0x08, 0x7C, 0x32, 0x0C, 0x62, 0xD0, 0x03, 0x51, 0x9B, 0x08, 0x50, 0x1E, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x82, 0x52, 0x3D, 0x00, 0x10, 0xB1, 0x87, 0x50, 0x00, 0x08, 0x50, 0x02, 0x08, 0x7C, 0x32, 0x0C, 0x7C, 0x40, 0x1F, 0x62, 0xD0, 0x00, 0x08, 0x50, 0x01, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0xC0, 0x08, 0x50, 0x03, 0x08, 0x01, 0x26 - } - }, - { - 166, - 79, - 0x39, - 0x00D1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD1, 0x7C, 0x32, 0x0C, 0x50, 0xC1, 0x08, 0x50, 0x04, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0xC2, 0x08, 0x50, 0x05, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x00, 0x08, 0x50, 0x06, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x10, 0x50, 0x00, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0x50, 0x07, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x10, 0x50, 0x01, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0xD6, 0xD1 - } - }, - { - 167, - 79, - 0x39, - 0x00D2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD2, 0x50, 0x08, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x10, 0x50, 0x02, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0x50, 0x09, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x10, 0x50, 0x03, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0x50, 0x0A, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x10, 0x50, 0x04, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0x50, 0x0B, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xAF, 0x84 - } - }, - { - 168, - 79, - 0x39, - 0x00D3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD3, 0xFE, 0x10, 0x50, 0x05, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0x50, 0x0C, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x10, 0x50, 0x06, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0x50, 0x0D, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x10, 0x50, 0x07, 0x7C, 0x2B, 0x69, 0x62, 0xD0, 0x00, 0x20, 0x08, 0x50, 0x0E, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x50, 0x07, 0x10, 0x06, 0x33 - } - }, - { - 169, - 79, - 0x39, - 0x00D4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD4, 0x08, 0x57, 0xA0, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x53, 0xE8, 0x20, 0x51, 0xE9, 0x08, 0x51, 0xE8, 0x08, 0x50, 0x0F, 0x08, 0x7C, 0x32, 0x52, 0x38, 0xFD, 0x50, 0x10, 0x08, 0x50, 0x12, 0x08, 0x50, 0x11, 0x08, 0x7C, 0x32, 0x52, 0x50, 0xA0, 0x08, 0x50, 0x02, 0x08, 0x50, 0x13, 0x08, 0x7C, 0x32, 0x52, 0x38, 0xFA, 0x50, 0x04, 0x08, 0x50, 0x00, 0x08, 0x50, 0x15, 0x08, 0x7C, 0x62, 0xEC - } - }, - { - 170, - 79, - 0x39, - 0x00D5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD5, 0x32, 0x52, 0x50, 0x00, 0x08, 0x50, 0x17, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFB, 0x50, 0x00, 0x08, 0x50, 0x18, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x00, 0x08, 0x50, 0x19, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x00, 0x08, 0x50, 0x1A, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x00, 0x08, 0x50, 0x1B, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x00, 0x08, 0x50, 0x1C, 0x08, 0x7C, 0x32, 0x0C, 0x62, 0xD0, 0x66, 0xF5 - } - }, - { - 171, - 79, - 0x39, - 0x00D6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD6, 0x03, 0x51, 0x9C, 0x08, 0x50, 0x1D, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x62, 0xD0, 0x03, 0x51, 0x9E, 0x08, 0x50, 0x1E, 0x08, 0x7C, 0x32, 0x0C, 0x62, 0xD0, 0x03, 0x51, 0x9D, 0x08, 0x50, 0x1F, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x80, 0xC7, 0x3D, 0x00, 0x20, 0xB0, 0x03, 0x80, 0xC0, 0x3D, 0x00, 0x30, 0xB0, 0xBB, 0x50, 0x01, 0x08, 0x50, 0x00, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x04, 0x08, 0x7D, 0x24 - } - }, - { - 172, - 79, - 0x39, - 0x00D7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD7, 0x50, 0x01, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x01, 0x08, 0x50, 0x02, 0x08, 0x7C, 0x32, 0x0C, 0x62, 0xD0, 0x03, 0x51, 0x9F, 0x08, 0x50, 0x29, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x04, 0x08, 0x50, 0x2A, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x08, 0x08, 0x50, 0x2B, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x08, 0x08, 0x50, 0x2C, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x00, 0x08, 0x50, 0xFF, 0x29 - } - }, - { - 173, - 79, - 0x39, - 0x00D8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD8, 0x48, 0x08, 0x50, 0x2D, 0x08, 0x7C, 0x32, 0x52, 0x38, 0xFB, 0x50, 0x1C, 0x08, 0x50, 0x2F, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x00, 0x08, 0x50, 0x30, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x08, 0x08, 0x50, 0x31, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x08, 0x08, 0x50, 0x32, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x5A, 0x08, 0x50, 0x33, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x00, 0x08, 0x50, 0x34, 0xD9, 0xDE - } - }, - { - 174, - 79, - 0x39, - 0x00D9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xD9, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x04, 0x08, 0x50, 0x35, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x0C, 0x08, 0x50, 0x36, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x50, 0x05, 0x08, 0x50, 0x37, 0x08, 0x7C, 0x32, 0x0C, 0x50, 0x01, 0x08, 0x50, 0x38, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x7C, 0x2B, 0x1A, 0x7C, 0x31, 0x1F, 0x38, 0xFD, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x7C, 0x32, 0x06, 0x7C, 0x20, 0x6D - } - }, - { - 175, - 79, - 0x39, - 0x00DA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xDA, 0x6F, 0x3C, 0x54, 0x00, 0x3D, 0x00, 0x30, 0xB0, 0x05, 0x90, 0xE8, 0x80, 0x03, 0x90, 0x4B, 0x62, 0xD0, 0x03, 0x51, 0x99, 0x21, 0x01, 0x62, 0xD0, 0x00, 0x39, 0x01, 0xB0, 0x19, 0x7C, 0x31, 0x35, 0x62, 0xD4, 0x00, 0x62, 0xD5, 0x00, 0x62, 0xD1, 0x00, 0x62, 0xD3, 0x00, 0x62, 0xD0, 0x00, 0x62, 0xE3, 0x38, 0x50, 0x00, 0x00, 0x7C, 0x6F, 0x3C, 0x54, 0x01, 0x52, 0x01, 0x3B, 0x00, 0xA0, 0x17, 0xE4, 0xF6 - } - }, - { - 176, - 79, - 0x39, - 0x00DB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xDB, 0x52, 0x01, 0x08, 0x52, 0x00, 0x08, 0x7C, 0x2B, 0x1B, 0x9C, 0xEE, 0x52, 0x01, 0x08, 0x52, 0x00, 0x08, 0x7C, 0x2B, 0x1F, 0x38, 0xFC, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x6F, 0x2F, 0xB0, 0x30, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x03, 0x53, 0x99, 0x50, 0x1E, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFE, 0x62, 0xD0, 0x03, 0x53, 0x9B, 0x47, 0x99, 0x02, 0xA0, 0x70, 0xFB, 0x25 - } - }, - { - 177, - 79, - 0x39, - 0x00DC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xDC, 0x51, 0x99, 0x21, 0xFD, 0x62, 0xD0, 0x00, 0x08, 0x50, 0x00, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x80, 0x5E, 0x3D, 0x00, 0x10, 0xB0, 0x33, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x03, 0x53, 0x99, 0x50, 0x1D, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFE, 0x62, 0xD0, 0x03, 0x53, 0x9C, 0x50, 0x1F, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x03, 0x53, 0x9D, 0x50, 0x1E, 0x08, 0x7C, 0x32, 0xA7, 0x46, 0xBC - } - }, - { - 178, - 79, - 0x39, - 0x00DD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xDD, 0x38, 0xFE, 0x62, 0xD0, 0x03, 0x53, 0x9E, 0x80, 0x27, 0x3D, 0x00, 0x20, 0xB0, 0x10, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFF, 0x62, 0xD0, 0x03, 0x53, 0x99, 0x80, 0x13, 0x48, 0x00, 0x40, 0xA0, 0x0E, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFF, 0x62, 0xD0, 0x03, 0x53, 0x99, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x04, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFF, 0x62, 0xAA, 0x85 - } - }, - { - 179, - 79, - 0x39, - 0x00DE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xDE, 0xD0, 0x00, 0x54, 0x00, 0x3D, 0x00, 0x01, 0xA0, 0x1F, 0x52, 0x00, 0x21, 0x70, 0x39, 0x30, 0xB0, 0x0E, 0x50, 0x01, 0x08, 0x50, 0x00, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x80, 0xE7, 0x52, 0x00, 0x62, 0xD0, 0x03, 0x53, 0x99, 0x80, 0xDE, 0x50, 0x29, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x03, 0x53, 0x9F, 0x50, 0x02, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x39, 0x81, 0xB0, 0x82, 0x36 - } - }, - { - 180, - 79, - 0x39, - 0x00DF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xDF, 0xC4, 0x50, 0x2A, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x00, 0x53, 0xA5, 0x50, 0x2B, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x53, 0x15, 0x50, 0x2C, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x00, 0x53, 0x16, 0x50, 0x2D, 0x08, 0x7C, 0x32, 0xF7, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x00, 0x53, 0xA3, 0x18, 0x53, 0xA4, 0x50, 0x2F, 0x08, 0x7C, 0x28, 0x83 - } - }, - { - 181, - 79, - 0x39, - 0x00E0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE0, 0x32, 0xA7, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x53, 0x42, 0x50, 0x30, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x04, 0x53, 0xB7, 0x50, 0x31, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x53, 0xA6, 0x50, 0x32, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0xD0, 0x00, 0x53, 0x17, 0x50, 0x36, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x53, 0xA7, 0x50, 0x37, 0x08, 0x7C, 0x32, 0xA7, 0x62, 0x39, 0xA6 - } - }, - { - 182, - 79, - 0x39, - 0x00E1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE1, 0xD0, 0x00, 0x53, 0xA8, 0x50, 0x38, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x53, 0xA9, 0x10, 0x7C, 0x18, 0x83, 0x7C, 0x17, 0xB7, 0x20, 0x80, 0x04, 0x62, 0xE3, 0x38, 0x7C, 0x31, 0xC5, 0x62, 0xD0, 0x00, 0x39, 0x00, 0xBF, 0xF4, 0x7C, 0x71, 0x10, 0x7C, 0x49, 0x07, 0x62, 0xE3, 0x38, 0x52, 0x01, 0x71, 0x10, 0x60, 0xE0, 0x50, 0x01, 0x08, 0x50, 0x02, 0x08, 0x70, 0xCF, 0x7C, 0xFE, 0x31 - } - }, - { - 183, - 79, - 0x39, - 0x00E2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE2, 0x32, 0x0C, 0x38, 0xFE, 0x38, 0xFC, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x6F, 0x2F, 0xB0, 0x06, 0x3D, 0xFC, 0x00, 0xB0, 0x0B, 0x3D, 0x00, 0x20, 0xA0, 0x06, 0x48, 0x00, 0x40, 0xA0, 0x26, 0x62, 0xD0, 0x04, 0x06, 0xB9, 0x40, 0x51, 0xB9, 0x29, 0x20, 0x62, 0xD0, 0x00, 0x08, 0x50, 0x01, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x80, 0x04, 0x62, 0xE3, 0x38, 0x7C, 0x31, 0xC5, 0x62, 0xD0, 0xA4, 0x7E - } - }, - { - 184, - 79, - 0x39, - 0x00E3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE3, 0x00, 0x39, 0x00, 0xBF, 0xF4, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x6F, 0x2F, 0xB0, 0x06, 0x3D, 0xFC, 0x00, 0xB0, 0x0B, 0x3D, 0x00, 0x20, 0xA0, 0x06, 0x48, 0x00, 0x40, 0xA0, 0x0F, 0x62, 0xD0, 0x04, 0x51, 0xB9, 0x08, 0x50, 0x01, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFF, 0x21, 0x80, 0x62, 0xD0, 0x04, 0x53, 0xB8, 0x38, 0xFF, 0xE6, 0x03 - } - }, - { - 185, - 79, - 0x39, - 0x00E4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE4, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x6F, 0x2F, 0xB0, 0x0A, 0x3D, 0xFC, 0x01, 0xB0, 0x19, 0x90, 0xC1, 0x80, 0x15, 0x3D, 0x00, 0x10, 0xB0, 0x05, 0x90, 0x63, 0x80, 0x0C, 0x3D, 0x00, 0x30, 0xB0, 0x05, 0x90, 0x21, 0x80, 0x03, 0x90, 0x56, 0x52, 0xFC, 0x08, 0x7C, 0x2B, 0x4C, 0x38, 0xFF, 0x38, 0xFF, 0x20, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xB9, 0x62, 0xD0, 0x00, 0x67, 0x67, 0x67, 0x67, 0x15, 0x62 - } - }, - { - 186, - 79, - 0x39, - 0x00E5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE5, 0x67, 0x67, 0x21, 0x03, 0x7F, 0x50, 0x84, 0x08, 0x50, 0x01, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x7C, 0x6F, 0x64, 0x7C, 0x32, 0x06, 0x62, 0xD0, 0x00, 0x62, 0xE3, 0x38, 0x50, 0x01, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x39, 0x04, 0xA0, 0x10, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x39, 0x01, 0xAF, 0xDA, 0x7C, 0x6E, 0xE8, 0x7F, 0x10, 0x4F, 0xD5, 0xE3 - } - }, - { - 187, - 79, - 0x39, - 0x00E6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE6, 0x38, 0x02, 0x7C, 0x6F, 0x64, 0x56, 0x01, 0xFA, 0x56, 0x00, 0x00, 0x80, 0x36, 0x7C, 0x32, 0x06, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x08, 0x7C, 0x32, 0xA7, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x26, 0xE9, 0x80, 0x62, 0xD0, 0x04, 0x51, 0xB8, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0xA0, 0x03, 0x80, 0x1C, 0x10, 0x57, 0x03, 0x50, 0xE3, 0x7C, 0x2B, 0xA8, 0x20, 0x62, 0xE3, 0x38, 0x7B, 0x01, 0x1F, 0xA4, 0x82 - } - }, - { - 188, - 79, - 0x39, - 0x00E7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE7, 0x00, 0x00, 0x3D, 0x00, 0x00, 0xBF, 0xC7, 0x3D, 0x01, 0x00, 0xBF, 0xC2, 0x7C, 0x6E, 0xE8, 0x38, 0xFE, 0x20, 0x7F, 0x7C, 0x6F, 0x64, 0x10, 0x57, 0x01, 0x50, 0xF4, 0x7C, 0x2B, 0xA8, 0x20, 0x7C, 0x6E, 0xE8, 0x7C, 0x32, 0x06, 0x62, 0xD0, 0x00, 0x7F, 0x7C, 0x31, 0x77, 0x7F, 0x7C, 0x31, 0xC1, 0x7F, 0x43, 0x05, 0x08, 0x62, 0xD0, 0x00, 0x26, 0xB0, 0xFB, 0x51, 0xB0, 0x60, 0x00, 0x62, 0xDA, 0x4A, 0xCF - } - }, - { - 189, - 79, - 0x39, - 0x00E8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE8, 0xEF, 0x43, 0xE0, 0x10, 0x7C, 0x31, 0x9D, 0x7F, 0x7C, 0x31, 0xB6, 0x7C, 0x73, 0x82, 0x41, 0x05, 0xF7, 0x62, 0xD0, 0x00, 0x51, 0xB0, 0x29, 0x04, 0x53, 0xB0, 0x51, 0xB0, 0x60, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xC3, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xC2, 0x00, 0x62, 0xD0, 0x04, 0x09, 0x4E - } - }, - { - 190, - 79, - 0x39, - 0x00E9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xE9, 0x55, 0xC1, 0x00, 0x7C, 0x3A, 0x1F, 0x10, 0x7C, 0x49, 0x5B, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x62, 0xD0, 0x03, 0x51, 0x9B, 0x21, 0xF0, 0x62, 0xD0, 0x04, 0x53, 0xC2, 0x7C, 0x6F, 0x2F, 0xA0, 0x06, 0x3D, 0x00, 0x30, 0xB0, 0x0B, 0x7C, 0x73, 0x26, 0x62, 0xD0, 0x00, 0x53, 0x39, 0x80, 0x07, 0x62, 0xD0, 0x00, 0x55, 0x39, 0x00, 0x62, 0xD0, 0x00, 0x51, 0x39, 0x62, 0xD0, 0x00, 0x53, 0x3A, 0x4C, 0xD5 - } - }, - { - 191, - 79, - 0x39, - 0x00EA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xEA, 0x62, 0xD0, 0x00, 0x51, 0x39, 0x62, 0xD0, 0x00, 0x53, 0x3B, 0x62, 0xD0, 0x00, 0x51, 0x39, 0x62, 0xD0, 0x00, 0x53, 0x3C, 0x7C, 0x3A, 0x21, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x62, 0xD0, 0x04, 0x51, 0xCF, 0x54, 0x01, 0x10, 0x52, 0xFB, 0x7C, 0x49, 0x92, 0x20, 0x62, 0xD0, 0x04, 0x53, 0xC3, 0x3C, 0xC3, 0x00, 0xB0, 0x4F, 0x52, 0xFB, 0x3B, 0xFC, 0xA0, 0x49, 0x52, 0xFC, 0x3B, 0xFE, 0x3A - } - }, - { - 192, - 79, - 0x39, - 0x00EB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xEB, 0xFB, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xC3, 0x2F, 0x80, 0x21, 0x62, 0xD0, 0x04, 0x55, 0xC3, 0x4F, 0x3D, 0xFB, 0x00, 0xB0, 0x16, 0x7C, 0x3A, 0x2C, 0x7C, 0x3A, 0x22, 0x62, 0xD0, 0x00, 0x39, 0x00, 0xA0, 0x09, 0x7C, 0x3A, 0x22, 0x62, 0xD0, 0x04, 0x53, 0xC3, 0x62, 0xD0, 0x04, 0x51, 0xC1, 0x62, 0xD0, 0x04, 0x3A, 0xC3, 0xB0, 0x0C, 0x62, 0xD0, 0x04, 0x52, 0x01, 0x01, 0x01, 0x53, 0xCF, 0x63, 0x05 - } - }, - { - 193, - 79, - 0x39, - 0x00EC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xEC, 0x80, 0x04, 0x7C, 0x70, 0x5B, 0x62, 0xD0, 0x04, 0x3C, 0xC3, 0x00, 0xA0, 0x09, 0x52, 0xFB, 0x08, 0x7C, 0x3A, 0x28, 0x38, 0xFF, 0x62, 0xD0, 0x04, 0x51, 0xC3, 0x08, 0x52, 0xFB, 0x08, 0x91, 0x86, 0x38, 0xFE, 0x39, 0x00, 0xA0, 0x21, 0x62, 0xD0, 0x04, 0x55, 0xC3, 0xFF, 0x62, 0xD0, 0x04, 0x51, 0xC1, 0x62, 0xD0, 0x04, 0x3A, 0xC3, 0xB0, 0x0C, 0x62, 0xD0, 0x04, 0x52, 0x01, 0x01, 0x01, 0x53, 0x63, 0x06 - } - }, - { - 194, - 79, - 0x39, - 0x00ED, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xED, 0xCF, 0x80, 0x04, 0x7C, 0x70, 0x5B, 0x62, 0xD0, 0x04, 0x3C, 0xC3, 0x00, 0xA0, 0x06, 0x56, 0x00, 0x01, 0x80, 0x04, 0x56, 0x00, 0x00, 0x52, 0xFB, 0x08, 0x52, 0xFC, 0x08, 0x50, 0x04, 0x08, 0x50, 0xC3, 0x08, 0x62, 0xD0, 0x00, 0x50, 0x0F, 0x08, 0x10, 0x7C, 0x2B, 0x40, 0x38, 0xFA, 0x62, 0xD0, 0x04, 0x3C, 0xC3, 0x00, 0xA0, 0x2B, 0x90, 0x31, 0x62, 0xD0, 0x04, 0x3C, 0xC3, 0x00, 0xA0, 0x21, 0x41, 0xC3 - } - }, - { - 195, - 79, - 0x39, - 0x00EE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xEE, 0x62, 0xD0, 0x04, 0x3C, 0xCF, 0x00, 0xB0, 0x0F, 0x62, 0xD0, 0x04, 0x3C, 0xC3, 0xFF, 0xA0, 0x07, 0x62, 0xD0, 0x04, 0x55, 0xCF, 0x80, 0x62, 0xD0, 0x04, 0x51, 0xC3, 0x62, 0xD0, 0x04, 0x53, 0xC1, 0x52, 0x00, 0x62, 0xD0, 0x00, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x62, 0xD0, 0x04, 0x51, 0xC3, 0x54, 0x00, 0x3C, 0xC3, 0x00, 0xA0, 0x0B, 0x7C, 0x6F, 0x3C, 0x62, 0xD0, 0x00, 0x39, 0x14, 0x6A - } - }, - { - 196, - 79, - 0x39, - 0x00EF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xEF, 0x30, 0xB0, 0x03, 0x80, 0xB1, 0x50, 0x10, 0x08, 0x50, 0x29, 0x08, 0x50, 0x28, 0x08, 0x90, 0xA9, 0x50, 0x20, 0x08, 0x50, 0x3F, 0x08, 0x50, 0x30, 0x08, 0x90, 0x9E, 0x38, 0xFA, 0x50, 0x40, 0x08, 0x50, 0x49, 0x08, 0x50, 0x48, 0x08, 0x90, 0x91, 0x50, 0x80, 0x08, 0x50, 0x9F, 0x08, 0x50, 0x90, 0x08, 0x90, 0x86, 0x38, 0xFA, 0x62, 0xD0, 0x04, 0x51, 0xC3, 0x3B, 0x00, 0xA0, 0x6E, 0x3D, 0x00, 0x76, 0x2F - } - }, - { - 197, - 79, - 0x39, - 0x00F0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF0, 0x28, 0xC0, 0x69, 0x50, 0x29, 0x3B, 0x00, 0xC0, 0x63, 0x62, 0xD0, 0x04, 0x51, 0xDF, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x65, 0xE9, 0x51, 0xE9, 0x01, 0x10, 0x62, 0xD0, 0x04, 0x53, 0xC3, 0x62, 0xD0, 0x04, 0x51, 0xC1, 0x62, 0xD0, 0x04, 0x3A, 0xC3, 0xB0, 0x0F, 0x62, 0xD0, 0x04, 0x51, 0xBF, 0x01, 0x01, 0x62, 0xD0, 0x04, 0x53, 0xCF, 0x80, 0x04, 0x7C, 0x70, 0x5B, 0x50, 0x10, 0x08, 0x50, 0x29, 0x67, 0x12 - } - }, - { - 198, - 79, - 0x39, - 0x00F1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF1, 0x08, 0x50, 0x28, 0x08, 0x90, 0x33, 0x50, 0x20, 0x08, 0x50, 0x3F, 0x08, 0x50, 0x30, 0x08, 0x90, 0x28, 0x38, 0xFA, 0x50, 0x40, 0x08, 0x50, 0x49, 0x08, 0x50, 0x48, 0x08, 0x90, 0x1B, 0x50, 0x80, 0x08, 0x50, 0x9F, 0x08, 0x50, 0x90, 0x08, 0x90, 0x10, 0x38, 0xFA, 0x62, 0xD0, 0x04, 0x51, 0xCF, 0x62, 0xD0, 0x04, 0x53, 0xBF, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x62, 0xD0, 0x04, 0x51, 0xC3, 0xF6, 0x31 - } - }, - { - 199, - 79, - 0x39, - 0x00F2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF2, 0x3B, 0xFC, 0xC0, 0x21, 0x62, 0xD0, 0x04, 0x52, 0xFB, 0x3A, 0xC3, 0xC0, 0x18, 0x62, 0xD0, 0x04, 0x51, 0xC2, 0x23, 0xFA, 0x39, 0x00, 0xB0, 0x0D, 0x62, 0xD0, 0x04, 0x55, 0xC3, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xCF, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x0A, 0x50, 0x02, 0x3B, 0xFC, 0xD1, 0xA6, 0x7C, 0x73, 0x26, 0x54, 0x03, 0x56, 0x00, 0x00, 0x80, 0xCA, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x80, 0x46 - } - }, - { - 200, - 79, - 0x39, - 0x00F3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF3, 0x06, 0xE8, 0xC0, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x7C, 0x6D, 0x8A, 0x51, 0xE8, 0x01, 0xE0, 0x54, 0x02, 0x51, 0xE9, 0x09, 0x01, 0x54, 0x01, 0x7C, 0x6D, 0xA5, 0x65, 0xE8, 0x6B, 0xE9, 0x06, 0xE8, 0xDD, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x7C, 0x6E, 0xE1, 0x52, 0x02, 0x53, 0xE6, 0x52, 0x01, 0x60, 0xD4, 0x3E, 0xE6, 0x53, 0xE6, 0x50, 0x00, 0x3A, 0xE9, 0xB0, 0x07, 0x51, 0xE6, 0x3A, 0xC6, 0xD3 - } - }, - { - 201, - 79, - 0x39, - 0x00F4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF4, 0xE8, 0xA0, 0x03, 0x80, 0x84, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x01, 0x06, 0x7C, 0x6E, 0xA3, 0x54, 0x04, 0x3E, 0xE8, 0x54, 0x05, 0x52, 0x02, 0x01, 0x04, 0x7C, 0x6E, 0xA3, 0x54, 0x06, 0x3E, 0xE8, 0x54, 0x07, 0x7C, 0x6D, 0xA5, 0x65, 0xE8, 0x6B, 0xE9, 0x06, 0xE8, 0xF5, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x7C, 0x6E, 0xE1, 0x51, 0xE9, 0x08, 0x51, 0xE8, 0x08, 0x52, 0x04, 0x08, 0x52, 0x05, 0xBB, 0xBE - } - }, - { - 202, - 79, - 0x39, - 0x00F5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF5, 0x08, 0x91, 0x1B, 0x38, 0xFC, 0x62, 0xD0, 0x00, 0x52, 0x03, 0x7C, 0x71, 0xD1, 0xC0, 0x31, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x65, 0xE8, 0x6B, 0xE9, 0x06, 0xE8, 0xA1, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x7C, 0x6E, 0xE1, 0x51, 0xE9, 0x08, 0x51, 0xE8, 0x08, 0x52, 0x06, 0x08, 0x52, 0x07, 0x08, 0x90, 0xEB, 0x38, 0xFC, 0x62, 0xD0, 0x00, 0x52, 0x03, 0x7C, 0x71, 0xD1, 0xD0, 0x03, 0x80, 0xCA, 0xDD - } - }, - { - 203, - 79, - 0x39, - 0x00F6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF6, 0x08, 0x77, 0x00, 0x7C, 0x72, 0x41, 0xCF, 0x33, 0x50, 0x04, 0x3B, 0xFC, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xC0, 0x04, 0x80, 0x08, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0xC0, 0x7C, 0x72, 0x41, 0xA0, 0xAD, 0x56, 0x00, 0x00, 0x80, 0x89, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xC0, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x7C, 0x6D, 0x8A, 0x51, 0xE8, 0x01, 0xE0, 0x54, 0x02, 0x51, 0x65, 0x14 - } - }, - { - 204, - 79, - 0x39, - 0x00F7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF7, 0xE9, 0x09, 0x01, 0x54, 0x01, 0x7C, 0x6F, 0xF6, 0x53, 0xE8, 0x7C, 0x6E, 0xAE, 0x65, 0xE6, 0x6B, 0xE7, 0x06, 0xE6, 0xDD, 0x0E, 0xE7, 0x02, 0x51, 0xE7, 0x60, 0xD5, 0x50, 0x00, 0x3F, 0xE6, 0x51, 0xE8, 0x3F, 0xE6, 0x52, 0x02, 0x01, 0x06, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x7C, 0x6D, 0xE3, 0x3E, 0xE8, 0x53, 0xE8, 0x7C, 0x6E, 0xAE, 0x65, 0xE6, 0x6B, 0xE7, 0x06, 0xE6, 0xF5, 0x0E, 0xE7, 0xC3, 0xD1 - } - }, - { - 205, - 79, - 0x39, - 0x00F8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF8, 0x02, 0x7C, 0x6D, 0xEA, 0x51, 0xE8, 0x3F, 0xE6, 0x52, 0x02, 0x01, 0x04, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x7C, 0x6D, 0xE3, 0x3E, 0xE8, 0x53, 0xE8, 0x7C, 0x6E, 0xAE, 0x65, 0xE6, 0x6B, 0xE7, 0x06, 0xE6, 0xA1, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x51, 0xE8, 0x3F, 0xE6, 0x77, 0x00, 0x7C, 0x72, 0x41, 0xCF, 0x74, 0x3D, 0xFB, 0x00, 0xB0, 0x09, 0x56, 0x09, 0x01, 0x56, 0x08, 0x00, 0x80, 0x53, 0xF2 - } - }, - { - 206, - 79, - 0x39, - 0x00F9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xF9, 0x07, 0x56, 0x09, 0x00, 0x56, 0x08, 0x00, 0x62, 0xD0, 0x00, 0x52, 0x09, 0x80, 0x0D, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x80, 0x06, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x38, 0xF6, 0x20, 0x7F, 0x10, 0x4F, 0x52, 0xFC, 0x13, 0xFA, 0x52, 0xFB, 0x1B, 0xF9, 0xC0, 0x12, 0x62, 0xD0, 0x00, 0x52, 0xFC, 0x13, 0xFA, 0x53, 0xE8, 0x52, 0xFB, 0x1B, 0xF9, 0x53, 0xE9, 0x80, 0x10, 0x62, 0xD0, 0x00, 0x52, 0xFA, 0x95, 0x77 - } - }, - { - 207, - 79, - 0x39, - 0x00FA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xFA, 0x13, 0xFC, 0x53, 0xE8, 0x52, 0xF9, 0x1B, 0xFB, 0x53, 0xE9, 0x20, 0x7F, 0x10, 0x4F, 0x7C, 0x72, 0x93, 0xB0, 0x22, 0x3D, 0xFC, 0x01, 0xB0, 0x32, 0x62, 0xD0, 0x04, 0x51, 0xCF, 0x08, 0x50, 0x0E, 0x08, 0x7C, 0x32, 0x0C, 0x62, 0xD0, 0x04, 0x51, 0xC3, 0x08, 0x50, 0x0F, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x80, 0x16, 0x7C, 0x6F, 0x3C, 0x39, 0x30, 0xB0, 0x0F, 0x62, 0xD0, 0x04, 0x51, 0xC3, 0xA8, 0x9E - } - }, - { - 208, - 79, - 0x39, - 0x00FB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xFB, 0x08, 0x50, 0x24, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x52, 0xFC, 0x08, 0x7C, 0x3A, 0x2D, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x62, 0xE3, 0x38, 0x7C, 0x2B, 0x06, 0x71, 0x01, 0x90, 0x67, 0x90, 0xC5, 0x80, 0x5D, 0x62, 0xD0, 0x00, 0x26, 0xAE, 0xFB, 0x51, 0xAE, 0x60, 0x00, 0x7C, 0x70, 0x4B, 0x51, 0xAE, 0x29, 0x04, 0x53, 0xAE, 0x51, 0xAE, 0x60, 0x00, 0x7C, 0x70, 0x4B, 0x26, 0x61, 0x11 - } - }, - { - 209, - 79, - 0x39, - 0x00FC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xFC, 0xAF, 0xFD, 0x51, 0xAF, 0x60, 0x04, 0x7C, 0x70, 0x4B, 0x51, 0xAF, 0x29, 0x02, 0x7C, 0x6F, 0x20, 0x56, 0x01, 0x00, 0x80, 0x03, 0x77, 0x01, 0x3D, 0x01, 0x0A, 0xCF, 0xFA, 0x62, 0xE3, 0x38, 0x90, 0x9D, 0x62, 0xD0, 0x04, 0x3C, 0xC4, 0x00, 0xA0, 0x0C, 0x7C, 0x45, 0x53, 0x7C, 0x2C, 0x1E, 0x62, 0xD0, 0x00, 0x54, 0x00, 0x52, 0x00, 0x08, 0x90, 0x9B, 0x52, 0x00, 0x08, 0x7C, 0x39, 0x02, 0x38, 0x9A, 0x84 - } - }, - { - 210, - 79, - 0x39, - 0x00FD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xFD, 0xFE, 0x8F, 0xA3, 0x38, 0xFE, 0x20, 0x8F, 0xFF, 0x10, 0x4F, 0x38, 0x01, 0x10, 0x7C, 0x16, 0x34, 0x20, 0x10, 0x57, 0x13, 0x50, 0x88, 0x7C, 0x2B, 0xA8, 0x20, 0x62, 0xD0, 0x04, 0x55, 0xC4, 0x01, 0x62, 0xD0, 0x00, 0x55, 0xA7, 0x0C, 0x62, 0xD0, 0x00, 0x55, 0xA8, 0x05, 0x62, 0xD0, 0x00, 0x55, 0xA9, 0x01, 0x10, 0x7C, 0x17, 0xB7, 0x7C, 0x19, 0x82, 0x62, 0xD0, 0x00, 0x20, 0x39, 0x00, 0xA0, 0xEE, 0x2D - } - }, - { - 211, - 79, - 0x39, - 0x00FE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xFE, 0x1F, 0x71, 0x10, 0x5D, 0xE0, 0x54, 0x00, 0x41, 0xE0, 0xE7, 0x43, 0xE0, 0x18, 0x70, 0xCF, 0x62, 0xE3, 0x38, 0x7C, 0x49, 0x07, 0x62, 0xE3, 0x38, 0x52, 0x00, 0x7C, 0x72, 0xB2, 0x80, 0x06, 0x10, 0x7C, 0x10, 0x74, 0x20, 0x38, 0xFF, 0x20, 0x7F, 0x7C, 0x33, 0x69, 0x7C, 0x40, 0x59, 0x7C, 0x45, 0x51, 0x7C, 0x2B, 0xCA, 0x7C, 0x3A, 0x31, 0x7C, 0x40, 0x10, 0x7C, 0x2B, 0x19, 0x7F, 0x7C, 0x40, 0x55, 0xFC - } - }, - { - 212, - 79, - 0x39, - 0x00FF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0xFF, 0x98, 0x7C, 0x36, 0x78, 0x7C, 0x45, 0x52, 0x7C, 0x2B, 0xFD, 0x7C, 0x3A, 0x4C, 0x7C, 0x40, 0x1E, 0x7C, 0x2B, 0x23, 0x7F, 0x10, 0x4F, 0x52, 0xFC, 0x08, 0x7C, 0x38, 0x88, 0x52, 0xFC, 0x08, 0x7C, 0x45, 0x4D, 0x38, 0xFE, 0x52, 0xFC, 0x08, 0x7C, 0x45, 0x76, 0x52, 0xFC, 0x08, 0x7C, 0x2E, 0x27, 0x38, 0xFE, 0x52, 0xFC, 0x08, 0x7C, 0x3E, 0x8C, 0x52, 0xFC, 0x08, 0x7C, 0x40, 0x28, 0x38, 0xFE, 0x1F, 0x91 - } - }, - { - 213, - 79, - 0x39, - 0x0100, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x00, 0x52, 0xFC, 0x08, 0x7C, 0x2B, 0x48, 0x52, 0xFC, 0x08, 0x7C, 0x38, 0xC9, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x62, 0xD0, 0x04, 0x55, 0xC5, 0x04, 0x38, 0xFF, 0x20, 0x7F, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xC5, 0x62, 0xD0, 0x00, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x62, 0xD0, 0x00, 0x51, 0x54, 0x54, 0x01, 0x51, 0x53, 0x54, 0x00, 0x70, 0xFE, 0x10, 0x7C, 0x1E, 0xFE, 0x51 - } - }, - { - 214, - 79, - 0x39, - 0x0101, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x01, 0x1C, 0x62, 0xD0, 0x00, 0x20, 0x10, 0x52, 0x00, 0x08, 0x52, 0x01, 0x20, 0x7C, 0x1D, 0xD4, 0x20, 0x62, 0xDA, 0xF7, 0x71, 0x01, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x7C, 0x1E, 0x1C, 0x20, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x55, 0x0D, 0x00, 0x55, 0x0C, 0x00, 0x7C, 0x72, 0x19, 0x92, 0x21, 0x7C, 0x73, 0x6D, 0x10, 0x7C, 0x1D, 0xCC, 0x7C, 0x20, 0x80, 0x7C, 0x20, 0x78, 0x20, 0x62, 0xD0, 0x00, 0x55, 0xFD, 0x50 - } - }, - { - 215, - 79, - 0x39, - 0x0102, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x02, 0xEF, 0x00, 0x55, 0xEE, 0x00, 0x62, 0xD0, 0x03, 0x55, 0xC8, 0x00, 0x55, 0xC9, 0x00, 0x55, 0xCA, 0x00, 0x55, 0xCB, 0x00, 0x7C, 0x2B, 0x67, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x7C, 0x72, 0x93, 0xB0, 0xF9, 0x7C, 0x70, 0xE8, 0x54, 0x01, 0x51, 0x0C, 0x54, 0x00, 0x71, 0x01, 0x62, 0xD0, 0x03, 0x47, 0x99, 0x02, 0xA0, 0x3F, 0x93, 0x58, 0x9F, 0x74, 0x7C, 0x70, 0xE8, 0x08, 0x51, 0x0C, 0x62, 0xD0, 0xDD, 0x11 - } - }, - { - 216, - 79, - 0x39, - 0x0103, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x03, 0x00, 0x53, 0xEE, 0x18, 0x53, 0xEF, 0x71, 0x01, 0x62, 0xD0, 0x03, 0x55, 0xC8, 0x00, 0x55, 0xC9, 0x00, 0x55, 0xCA, 0x00, 0x55, 0xCB, 0x00, 0x7C, 0x2B, 0x67, 0x10, 0x7C, 0x18, 0x83, 0x20, 0x10, 0x57, 0x13, 0x50, 0x88, 0x7C, 0x2B, 0xA8, 0x7C, 0x10, 0x74, 0x20, 0x91, 0x3B, 0x7C, 0x6F, 0xEA, 0x81, 0x33, 0x62, 0xD0, 0x03, 0x51, 0x9A, 0x21, 0x0F, 0x54, 0x02, 0x62, 0xD0, 0x04, 0x3C, 0xCB, 0x0A, 0x6C - } - }, - { - 217, - 79, - 0x39, - 0x0104, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x04, 0xF1, 0xB0, 0x45, 0x62, 0xD0, 0x03, 0x3C, 0x9C, 0x00, 0xA0, 0x03, 0x93, 0x67, 0x3D, 0x02, 0x00, 0xA0, 0x06, 0x7C, 0x6F, 0xEA, 0x80, 0x97, 0x7C, 0x73, 0x2E, 0xA0, 0x27, 0x62, 0xD0, 0x03, 0x52, 0x01, 0x12, 0xE5, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x52, 0x00, 0x62, 0xD0, 0x03, 0x1A, 0xE4, 0x7C, 0x72, 0x49, 0x62, 0xD0, 0x03, 0x12, 0xDB, 0x7C, 0x70, 0xA1, 0x1A, 0xDA, 0xC0, 0x70, 0x91, 0x2A, 0x7B, 0x4F - } - }, - { - 218, - 79, - 0x39, - 0x0105, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x05, 0x80, 0x6C, 0x7C, 0x6F, 0xEA, 0x80, 0x67, 0x62, 0xD0, 0x04, 0x3C, 0xCB, 0xF2, 0xB0, 0x1E, 0x3D, 0x02, 0x00, 0xB0, 0x06, 0x7C, 0x73, 0x2E, 0xB0, 0x08, 0x90, 0xCD, 0x7C, 0x6F, 0xEA, 0x80, 0x4E, 0x62, 0xD0, 0x03, 0x3C, 0x9D, 0x00, 0xA0, 0x46, 0x93, 0x0A, 0x80, 0x42, 0x9E, 0xBE, 0x7C, 0x70, 0xE8, 0x08, 0x51, 0x0C, 0x62, 0xD0, 0x00, 0x53, 0xEE, 0x18, 0x53, 0xEF, 0x71, 0x01, 0x62, 0xD0, 0xC8, 0xEA - } - }, - { - 219, - 79, - 0x39, - 0x0106, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x06, 0x03, 0x55, 0xC8, 0x00, 0x55, 0xC9, 0x00, 0x55, 0xCA, 0x00, 0x55, 0xCB, 0x00, 0x7C, 0x2B, 0x67, 0x90, 0xFD, 0x90, 0x94, 0x7C, 0x6F, 0xEA, 0x80, 0x15, 0x62, 0xD0, 0x04, 0x3C, 0xCB, 0xF4, 0xA0, 0x0D, 0x10, 0x57, 0x00, 0x50, 0x01, 0x7C, 0x1D, 0xD4, 0x20, 0x7C, 0x73, 0x6D, 0x7C, 0x72, 0x93, 0xB0, 0x70, 0x7C, 0x70, 0xE8, 0x54, 0x01, 0x51, 0x0C, 0x54, 0x00, 0x71, 0x01, 0x62, 0xD0, 0x00, 0x44, 0xE3 - } - }, - { - 220, - 79, - 0x39, - 0x0107, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x07, 0x52, 0x01, 0x12, 0xEF, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x52, 0x00, 0x62, 0xD0, 0x00, 0x1A, 0xEE, 0x7C, 0x72, 0x49, 0x53, 0xE6, 0x51, 0xE9, 0x53, 0xE7, 0x51, 0xE6, 0x62, 0xD0, 0x03, 0x04, 0xCB, 0x62, 0xD0, 0x00, 0x51, 0xE7, 0x62, 0xD0, 0x03, 0x0C, 0xCA, 0x0E, 0xC9, 0x00, 0x0E, 0xC8, 0x00, 0x62, 0xD0, 0x00, 0x52, 0x01, 0x53, 0xEF, 0x52, 0x00, 0x53, 0xEE, 0x62, 0xD0, 0x03, 0x51, 0xCB, 0x39, 0xCE - } - }, - { - 221, - 79, - 0x39, - 0x0108, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x08, 0x11, 0x30, 0x51, 0xCA, 0x19, 0x75, 0x51, 0xC9, 0x19, 0x00, 0x51, 0xC8, 0x19, 0x00, 0xC0, 0x12, 0x9E, 0x1A, 0x62, 0xD0, 0x03, 0x55, 0xC8, 0x00, 0x55, 0xC9, 0x00, 0x55, 0xCA, 0x00, 0x55, 0xCB, 0x00, 0x7C, 0x2B, 0x68, 0x38, 0xFD, 0x20, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xCB, 0xF1, 0x62, 0xD0, 0x03, 0x51, 0x9C, 0x08, 0x62, 0xD0, 0x03, 0x55, 0xD8, 0x00, 0x18, 0x53, 0xD9, 0x62, 0xD0, 0x03, 0xB7, 0xCB - } - }, - { - 222, - 79, - 0x39, - 0x0109, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x09, 0x3C, 0x9C, 0x00, 0xA0, 0x14, 0x10, 0x62, 0xD0, 0x03, 0x51, 0xD8, 0x08, 0x51, 0xD9, 0x20, 0x7C, 0x1D, 0xD4, 0x20, 0x7C, 0x70, 0xAA, 0x80, 0x0F, 0x10, 0x57, 0x00, 0x50, 0x01, 0x7C, 0x1D, 0xD4, 0x20, 0x70, 0xFE, 0x7C, 0x72, 0x19, 0x7C, 0x71, 0x54, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xCB, 0xF2, 0x62, 0xD0, 0x03, 0x51, 0xD7, 0x08, 0x51, 0xD6, 0x62, 0xD0, 0x03, 0x53, 0xD8, 0x18, 0x53, 0xD9, 0xF0, 0x3E - } - }, - { - 223, - 79, - 0x39, - 0x010A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x0A, 0x10, 0x51, 0xD8, 0x08, 0x51, 0xD9, 0x20, 0x7C, 0x1D, 0xD4, 0x20, 0x7C, 0x70, 0xAA, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x62, 0xD0, 0x03, 0x50, 0x78, 0x3A, 0x9D, 0xD0, 0x07, 0x62, 0xD0, 0x03, 0x55, 0x9D, 0x78, 0x7C, 0x71, 0xD8, 0x53, 0xE9, 0x65, 0xE9, 0x7C, 0x71, 0xD8, 0x64, 0x64, 0x64, 0x02, 0xE9, 0x54, 0x00, 0x80, 0x09, 0x62, 0xD0, 0x03, 0x76, 0x9D, 0x07, 0x00, 0x0A, 0x62, 0xD0, 0x03, 0xA5, 0xA9 - } - }, - { - 224, - 79, - 0x39, - 0x010B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x0B, 0x3C, 0x9D, 0x1A, 0xD0, 0x0A, 0x62, 0xD0, 0x03, 0x52, 0x00, 0x3A, 0x9C, 0xCF, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0x9D, 0x08, 0x62, 0xD0, 0x03, 0x55, 0xD6, 0x00, 0x18, 0x53, 0xD7, 0x62, 0xD0, 0x03, 0x51, 0x9D, 0x7C, 0x70, 0x0E, 0x7C, 0x6D, 0x9C, 0x62, 0xD0, 0x03, 0x51, 0xD7, 0x62, 0xD0, 0x00, 0x04, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0xD6, 0x62, 0xD0, 0x00, 0x0C, 0xE9, 0x7C, 0x70, 0x17, 0x08, 0x59, 0x12 - } - }, - { - 225, - 79, - 0x39, - 0x010C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x0C, 0x51, 0xE9, 0x62, 0xD0, 0x03, 0x53, 0xD6, 0x18, 0x53, 0xD7, 0x62, 0xD0, 0x03, 0x51, 0x9E, 0x08, 0x62, 0xD0, 0x03, 0x55, 0xDA, 0x00, 0x18, 0x53, 0xDB, 0x51, 0xDB, 0x08, 0x51, 0xDA, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x18, 0x53, 0xE8, 0x7C, 0x6D, 0x9C, 0x62, 0xD0, 0x03, 0x51, 0xDB, 0x62, 0xD0, 0x00, 0x04, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0xDA, 0x62, 0xD0, 0x00, 0x0C, 0xE9, 0x7C, 0x70, 0x17, 0x5E, 0x1D - } - }, - { - 226, - 79, - 0x39, - 0x010D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x0D, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x03, 0x53, 0xDA, 0x18, 0x53, 0xDB, 0x38, 0xFF, 0x20, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0xAE, 0x21, 0x0D, 0x60, 0x00, 0x62, 0xD0, 0x00, 0x51, 0xAF, 0x21, 0xBB, 0x60, 0x04, 0x62, 0xD0, 0x00, 0x51, 0xB0, 0x21, 0x74, 0x7C, 0x73, 0x1E, 0x21, 0x00, 0x7C, 0x73, 0x16, 0x21, 0x10, 0x60, 0x10, 0x71, 0x10, 0x5D, 0x00, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x53, 0xCA, 0x71, 0x6E, 0x3E - } - }, - { - 227, - 79, - 0x39, - 0x010E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x0E, 0x10, 0x5D, 0x04, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x53, 0xC9, 0x71, 0x10, 0x5D, 0x08, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x53, 0xC8, 0x71, 0x10, 0x5D, 0x0C, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x53, 0xC7, 0x71, 0x10, 0x5D, 0x10, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x53, 0xC6, 0x71, 0x10, 0x43, 0x00, 0xF2, 0x43, 0x04, 0x44, 0x43, 0x08, 0x8B, 0x43, 0x0C, 0xFF, 0x43, 0x10, 0xEF, 0x70, 0xCF, 0x7F, 0x62, 0x34, 0xCB - } - }, - { - 228, - 79, - 0x39, - 0x010F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x0F, 0xD0, 0x04, 0x51, 0xCA, 0x71, 0x10, 0x60, 0x00, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x51, 0xC9, 0x71, 0x10, 0x60, 0x04, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x51, 0xC8, 0x71, 0x10, 0x60, 0x08, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x51, 0xC7, 0x71, 0x10, 0x60, 0x0C, 0x70, 0xCF, 0x62, 0xD0, 0x04, 0x51, 0xC6, 0x71, 0x10, 0x60, 0x10, 0x70, 0xCF, 0x62, 0xD0, 0x00, 0x51, 0xAE, 0x60, 0x00, 0x62, 0xD0, 0x00, 0xB4, 0xCC - } - }, - { - 229, - 79, - 0x39, - 0x0110, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x10, 0x7C, 0x72, 0x51, 0x51, 0xB0, 0x7C, 0x73, 0x1E, 0x7C, 0x73, 0x16, 0x60, 0x10, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x71, 0x10, 0x43, 0xEC, 0x01, 0x70, 0xFE, 0x70, 0xCF, 0x9F, 0x32, 0x7C, 0x31, 0xC5, 0x62, 0xD0, 0x00, 0x39, 0x00, 0xB0, 0x3A, 0x7C, 0x72, 0xCB, 0x10, 0x70, 0xCF, 0x7C, 0x1D, 0xD0, 0x7C, 0x20, 0x7C, 0x20, 0x62, 0xDB, 0xFE, 0x7C, 0x39, 0xF1, 0x71, 0x10, 0x43, 0xD7, 0x20, 0x43, 0x58, 0x15 - } - }, - { - 230, - 79, - 0x39, - 0x0111, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x11, 0xC9, 0x80, 0x70, 0xCF, 0x43, 0xFF, 0x08, 0x71, 0x10, 0x41, 0xC9, 0x7F, 0x41, 0xD7, 0xDF, 0x40, 0x7C, 0x73, 0x7B, 0x70, 0xCF, 0x7C, 0x3A, 0x08, 0x10, 0x7C, 0x20, 0x78, 0x7C, 0x1D, 0xCC, 0x20, 0x62, 0xD0, 0x00, 0x55, 0xBB, 0xFF, 0x62, 0xD0, 0x03, 0x26, 0x99, 0xFD, 0x9F, 0x51, 0x71, 0x01, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x56, 0x00, 0x00, 0x71, 0x10, 0x41, 0xEC, 0xFE, 0x27, 0xB4 - } - }, - { - 231, - 79, - 0x39, - 0x0112, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x12, 0x70, 0xFE, 0x70, 0xCF, 0x9E, 0xC9, 0x7C, 0x71, 0x10, 0x80, 0x6B, 0x7C, 0x32, 0x06, 0x62, 0xD0, 0x00, 0x7C, 0x31, 0xC5, 0x39, 0x00, 0xB0, 0x5A, 0x3D, 0x00, 0x00, 0xB0, 0x55, 0x62, 0xD0, 0x00, 0x3C, 0xBB, 0xFF, 0xA0, 0x4D, 0x7C, 0x39, 0xE9, 0x62, 0xD0, 0x03, 0x51, 0xD9, 0x11, 0x02, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0xD8, 0x19, 0x00, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x50, 0x07 - } - }, - { - 232, - 79, - 0x39, - 0x0113, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x13, 0x62, 0xD0, 0x00, 0x51, 0xBB, 0x62, 0xD0, 0x00, 0x7C, 0x70, 0xBF, 0xC0, 0x22, 0x7C, 0x72, 0xCB, 0x56, 0x00, 0x01, 0x10, 0x70, 0xCF, 0x7C, 0x20, 0x7C, 0x20, 0x62, 0xDB, 0xFE, 0x10, 0x7C, 0x0C, 0x80, 0x20, 0x71, 0x10, 0x7C, 0x73, 0x7B, 0x10, 0x70, 0xCF, 0x7C, 0x20, 0x78, 0x20, 0x7C, 0x39, 0xED, 0x71, 0x01, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0x0D, 0x62, 0xD0, 0x03, 0x12, 0xD5, 0x62, 0x05, 0x72 - } - }, - { - 233, - 79, - 0x39, - 0x0114, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x14, 0xD0, 0x00, 0x53, 0xE8, 0x62, 0xD0, 0x00, 0x51, 0x0C, 0x62, 0xD0, 0x03, 0x1A, 0xD4, 0x7C, 0x72, 0x49, 0x62, 0xD0, 0x03, 0x12, 0xD9, 0x7C, 0x70, 0xA1, 0x1A, 0xD8, 0xCF, 0x6F, 0x52, 0x01, 0x7C, 0x72, 0xB2, 0x9E, 0x9B, 0x7C, 0x71, 0x54, 0x71, 0x01, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x62, 0xD0, 0x04, 0x3C, 0xCB, 0xF2, 0xB0, 0x09, 0x56, 0x01, 0x01, 0x56, 0x00, 0x00, 0x80, 0x34, 0xD1 - } - }, - { - 234, - 79, - 0x39, - 0x0115, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x15, 0x04, 0x7C, 0x6F, 0xC9, 0x62, 0xD0, 0x00, 0x52, 0x01, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x7F, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x56, 0x00, 0x00, 0x10, 0x7C, 0x18, 0x83, 0x7C, 0x19, 0x64, 0x20, 0x56, 0x00, 0x01, 0x52, 0x00, 0x08, 0x7C, 0x2B, 0x34, 0x38, 0xFF, 0x10, 0x7C, 0x18, 0x4D, 0x20, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x04, 0x7C, 0x6F, 0x3C, 0x54, 0x01, 0x3D, 0x3A, 0xDE - } - }, - { - 235, - 79, - 0x39, - 0x0116, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x16, 0x01, 0x50, 0xB0, 0x29, 0x56, 0x00, 0x00, 0x80, 0x1D, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x08, 0x52, 0x00, 0x01, 0x07, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x77, 0x00, 0x3D, 0x00, 0x99, 0xCF, 0xE0, 0x81, 0x85, 0x3D, 0x01, 0x40, 0xB0, 0x29, 0x56, 0x00, 0x00, 0x80, 0x1D, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x00, 0x0E, 0x92, 0x8F - } - }, - { - 236, - 79, - 0x39, - 0x0117, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x17, 0xE9, 0x05, 0x7C, 0x6D, 0x83, 0x08, 0x52, 0x00, 0x01, 0x07, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x77, 0x00, 0x3D, 0x00, 0x99, 0xCF, 0xE0, 0x81, 0x58, 0x3D, 0x01, 0x70, 0xB0, 0x61, 0x7C, 0x39, 0x34, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x26, 0xE9, 0x01, 0x3C, 0xE9, 0x01, 0xB0, 0x29, 0x56, 0x00, 0x00, 0x80, 0x1D, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x05, 0x7C, 0xC7, 0xFA - } - }, - { - 237, - 79, - 0x39, - 0x0118, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x18, 0x6D, 0x83, 0x08, 0x52, 0x00, 0x01, 0x07, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x77, 0x00, 0x3D, 0x00, 0x99, 0xCF, 0xE0, 0x81, 0x1B, 0x56, 0x00, 0x00, 0x80, 0x1D, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x08, 0x7C, 0x6D, 0x83, 0x08, 0x52, 0x00, 0x01, 0x07, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x77, 0x00, 0x3D, 0x00, 0x99, 0xCF, 0xE0, 0x80, 0xF3, 0x3D, 0x01, 0xF5, 0x57 - } - }, - { - 238, - 79, - 0x39, - 0x0119, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x19, 0x60, 0xB0, 0x95, 0x7C, 0x39, 0x34, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x26, 0xE9, 0x01, 0x3C, 0xE9, 0x01, 0xB0, 0x5D, 0x50, 0x1B, 0x08, 0x50, 0x07, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x56, 0x00, 0x00, 0x80, 0x1D, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x09, 0x7C, 0x6F, 0x5C, 0x08, 0x52, 0x00, 0x01, 0x08, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x77, 0x00, 0x3D, 0xF8, 0x5E - } - }, - { - 239, - 79, - 0x39, - 0x011A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x1A, 0x00, 0x1B, 0xCF, 0xE0, 0x56, 0x02, 0x23, 0x56, 0x00, 0x00, 0x80, 0x1D, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x25, 0x0E, 0xE9, 0x09, 0x7C, 0x6F, 0x5C, 0x08, 0x52, 0x02, 0x03, 0x00, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x77, 0x00, 0x3D, 0x00, 0x1B, 0xCF, 0xE0, 0x80, 0x82, 0x56, 0x00, 0x00, 0x80, 0x1D, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x0A, 0xCB, 0x05 - } - }, - { - 240, - 79, - 0x39, - 0x011B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x1B, 0x7C, 0x6F, 0x5C, 0x08, 0x52, 0x00, 0x01, 0x07, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x77, 0x00, 0x3D, 0x00, 0x99, 0xCF, 0xE0, 0x80, 0x5A, 0x3D, 0x01, 0x30, 0xB0, 0x55, 0x62, 0xD0, 0x03, 0x3C, 0x9F, 0x99, 0xD0, 0x4D, 0x62, 0xD0, 0x03, 0x51, 0x9F, 0x7C, 0x70, 0x0E, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x08, 0x7C, 0x6D, 0x83, 0x08, 0x50, 0x26, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFE, 0x62, 0xD0, 0xD0, 0x10 - } - }, - { - 241, - 79, - 0x39, - 0x011C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x1C, 0x03, 0x51, 0x9F, 0x7C, 0x70, 0x0E, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x08, 0x50, 0x27, 0x08, 0x7C, 0x32, 0x0C, 0x62, 0xD0, 0x03, 0x51, 0x9F, 0x7C, 0x70, 0x0E, 0x06, 0xE8, 0x00, 0x0E, 0xE9, 0x05, 0x7C, 0x6D, 0x83, 0x08, 0x50, 0x28, 0x08, 0x7C, 0x32, 0x0C, 0x38, 0xFC, 0x38, 0xFC, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x56, 0x00, 0x00, 0x80, 0x5A, 0x62, 0xD0, 0x00, 0x3B, 0xE7 - } - }, - { - 242, - 79, - 0x39, - 0x011D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x1D, 0x52, 0x00, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE6, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x54, 0x01, 0x3E, 0xE8, 0x54, 0x02, 0x7C, 0x70, 0x01, 0x7C, 0x70, 0xD4, 0x52, 0x02, 0x53, 0xE9, 0x7C, 0x6E, 0xAE, 0x06, 0xE6, 0xB8, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x52, 0x00, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE4, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x54, 0x01, 0x3E, 0xE8, 0x54, 0x02, 0x7C, 0x70, 0xCA, 0x06 - } - }, - { - 243, - 79, - 0x39, - 0x011E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x1E, 0xD4, 0x7C, 0x70, 0x01, 0x52, 0x02, 0x53, 0xE9, 0x7C, 0x6E, 0xAE, 0x06, 0xE6, 0xB4, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0xA3, 0x52, 0xFC, 0x08, 0x7C, 0x5F, 0x91, 0x38, 0xFF, 0x38, 0xFD, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x7C, 0x6F, 0xB9, 0x52, 0xFB, 0x60, 0xD5, 0x50, 0x04, 0x3F, 0xE8, 0x52, 0xFC, 0x01, 0x01, 0x7C, 0x71, 0x76, 0x50, 0x01, 0x3F, 0x32, 0xD7 - } - }, - { - 244, - 79, - 0x39, - 0x011F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x1F, 0xE8, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x7C, 0x6F, 0xB9, 0x52, 0xFB, 0x7C, 0x6D, 0xE3, 0x47, 0xE9, 0x80, 0xBF, 0xF4, 0x52, 0xFC, 0x53, 0xE8, 0x52, 0xFB, 0x60, 0xD4, 0x3E, 0xE8, 0x39, 0x04, 0xB0, 0x73, 0x56, 0x00, 0x00, 0x80, 0x3F, 0x62, 0xD0, 0x00, 0x52, 0x00, 0x7C, 0x6D, 0x8A, 0x52, 0xFC, 0x01, 0x02, 0x53, 0xE6, 0x52, 0xFB, 0x09, 0x00, 0x53, 0xE7, 0x51, 0xE8, 0x02, 0x69, 0x46 - } - }, - { - 245, - 79, - 0x39, - 0x0120, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x20, 0xE6, 0x53, 0xE6, 0x51, 0xE9, 0x0A, 0xE7, 0x53, 0xE7, 0x06, 0xE8, 0xE0, 0x0E, 0xE9, 0x01, 0x51, 0xE9, 0x60, 0xD4, 0x51, 0xE7, 0x60, 0xD5, 0x10, 0x57, 0x08, 0x62, 0xD0, 0x00, 0x3E, 0xE8, 0x3F, 0xE6, 0x79, 0xBF, 0xF7, 0x20, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0xBE, 0x62, 0xD0, 0x00, 0x52, 0xFC, 0x01, 0x22, 0x7C, 0x71, 0x76, 0x52, 0xF9, 0x3F, 0xE8, 0x52, 0xFC, 0x01, 0x23, 0x7C, 0x71, 0xE7, 0x43 - } - }, - { - 246, - 79, - 0x39, - 0x0121, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x21, 0x76, 0x52, 0xFA, 0x3F, 0xE8, 0x52, 0xFC, 0x01, 0x24, 0x7C, 0x71, 0x76, 0x62, 0xD0, 0x00, 0x51, 0xA2, 0x62, 0xD0, 0x00, 0x3F, 0xE8, 0x7C, 0x6F, 0xB9, 0x52, 0xFB, 0x60, 0xD5, 0x50, 0x84, 0x3F, 0xE8, 0x38, 0xFD, 0x20, 0x7F, 0x10, 0x4F, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x62, 0xD0, 0x03, 0x55, 0xAC, 0x19, 0x55, 0xAB, 0x00, 0x55, 0xAA, 0x02, 0x62, 0xD0, 0x00, 0x55, 0xE8, 0x00, 0x55, 0xDD, 0x30 - } - }, - { - 247, - 79, - 0x39, - 0x0122, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x22, 0xE9, 0x0A, 0x7C, 0x6D, 0xAD, 0x7C, 0x6D, 0xC6, 0x51, 0xE8, 0x62, 0xD0, 0x03, 0x53, 0xA9, 0x10, 0x50, 0x03, 0x08, 0x50, 0xA9, 0x5C, 0x18, 0x7C, 0x20, 0x98, 0x20, 0x62, 0xD0, 0x03, 0x50, 0x00, 0x01, 0x80, 0x53, 0xAB, 0x50, 0x02, 0x09, 0x00, 0x53, 0xAA, 0x62, 0xD0, 0x00, 0x55, 0xE8, 0x00, 0x55, 0xE9, 0x0A, 0x7C, 0x6D, 0xC6, 0x7C, 0x6D, 0xAD, 0x7C, 0x73, 0x3C, 0x51, 0xE8, 0x62, 0xD0, 0xBC, 0xEF - } - }, - { - 248, - 79, - 0x39, - 0x0123, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x23, 0x03, 0x53, 0xA9, 0x10, 0x50, 0x03, 0x08, 0x50, 0xA9, 0x5C, 0x18, 0x7C, 0x20, 0x98, 0x20, 0x62, 0xD0, 0x03, 0x55, 0xAB, 0xA0, 0x55, 0xAA, 0x01, 0x62, 0xD0, 0x00, 0x55, 0xE8, 0x00, 0x55, 0xE9, 0x0A, 0x7C, 0x6D, 0xC6, 0x7C, 0x6D, 0xAD, 0x16, 0xE8, 0x02, 0x1E, 0xE9, 0x00, 0x51, 0xE8, 0x62, 0xD0, 0x03, 0x53, 0xA9, 0x10, 0x50, 0x03, 0x08, 0x50, 0xA9, 0x5C, 0x18, 0x7C, 0x20, 0x98, 0x62, 0xDB, 0x2E - } - }, - { - 249, - 79, - 0x39, - 0x0124, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x24, 0xD0, 0x00, 0x20, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x50, 0x99, 0x7C, 0x12, 0x90, 0x20, 0x9F, 0x59, 0x10, 0x7C, 0x10, 0x74, 0x20, 0x7F, 0x10, 0x4F, 0x10, 0x52, 0xFB, 0x08, 0x52, 0xFC, 0x20, 0x7C, 0x13, 0xEA, 0x20, 0x9F, 0x44, 0x10, 0x7C, 0x10, 0x74, 0x20, 0x20, 0x7F, 0x10, 0x4F, 0x10, 0x52, 0xFC, 0x7C, 0x13, 0xFB, 0x20, 0x9F, 0x32, 0x10, 0x7C, 0x10, 0x74, 0x20, 0x20, 0x7F, 0x10, 0x4F, 0x86, 0x85 - } - }, - { - 250, - 79, - 0x39, - 0x0125, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x25, 0x10, 0x52, 0xFC, 0x7C, 0x14, 0x0D, 0x20, 0x9F, 0x20, 0x10, 0x7C, 0x10, 0x74, 0x20, 0x20, 0x7F, 0x10, 0x4F, 0x52, 0xFC, 0x62, 0xD0, 0x00, 0x53, 0xA9, 0x20, 0x7F, 0x62, 0xD0, 0x00, 0x55, 0x39, 0x08, 0x55, 0x3A, 0x08, 0x55, 0x3B, 0x08, 0x55, 0x3C, 0x08, 0x55, 0x01, 0x00, 0x55, 0x00, 0x00, 0x55, 0x03, 0x00, 0x55, 0x02, 0x00, 0x55, 0x05, 0x00, 0x55, 0x04, 0x00, 0x55, 0x07, 0x00, 0x55, 0x71, 0x5C - } - }, - { - 251, - 79, - 0x39, - 0x0126, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x26, 0x06, 0x00, 0x55, 0x55, 0x20, 0x55, 0x54, 0x01, 0x55, 0x53, 0x00, 0x43, 0xE6, 0x01, 0x43, 0xE0, 0x08, 0x7F, 0x49, 0xE0, 0x08, 0xB0, 0x05, 0x50, 0x00, 0x80, 0x07, 0x08, 0x7C, 0x54, 0x59, 0x38, 0xFF, 0x7F, 0x08, 0x7C, 0x54, 0xA4, 0x38, 0xFF, 0x7F, 0x08, 0x7C, 0x54, 0xB5, 0x38, 0xFF, 0x7F, 0x08, 0x7C, 0x54, 0xE2, 0x38, 0xFF, 0x7F, 0x08, 0x7C, 0x54, 0xF3, 0x38, 0xFF, 0x7F, 0x08, 0x7C, 0x84, 0x83 - } - }, - { - 252, - 79, - 0x39, - 0x0127, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x27, 0x55, 0x04, 0x38, 0xFF, 0x7F, 0x08, 0x7C, 0x55, 0x15, 0x38, 0xFF, 0x7F, 0x08, 0x7C, 0x5B, 0xE0, 0x38, 0xFF, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x50, 0x00, 0x3D, 0xF9, 0x80, 0xC0, 0x06, 0x7C, 0x4A, 0x8B, 0x50, 0xC0, 0x3D, 0xF5, 0x80, 0xC0, 0x0C, 0x10, 0x4B, 0x11, 0x04, 0x4B, 0x7C, 0x4A, 0x8B, 0x31, 0x80, 0x20, 0x08, 0x7C, 0x4A, 0x28, 0x18, 0x6A, 0xD0, 0x04, 0x7C, 0x4A, 0x8B, 0x6A, 0xD0, 0x1F, 0xBA - } - }, - { - 253, - 79, - 0x39, - 0x0128, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x28, 0x08, 0x4B, 0x11, 0x04, 0x4B, 0x7C, 0x4A, 0x8B, 0x38, 0xFF, 0x20, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x10, 0x4F, 0x5D, 0xD0, 0x08, 0x62, 0xD0, 0x00, 0x7C, 0x4A, 0xA3, 0x51, 0xE1, 0x54, 0xFB, 0x18, 0x60, 0xD0, 0x20, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x5D, 0xD0, 0x08, 0x62, 0xD0, 0x00, 0x51, 0xE9, 0x08, 0x50, 0x00, 0x53, 0xE9, 0x53, 0xE1, 0x53, 0xE0, 0x53, 0xDF, 0x56, 0x00, 0x20, 0x66, 0xFC, 0xD7, 0x2B - } - }, - { - 254, - 79, - 0x39, - 0x0129, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x29, 0x6C, 0xFB, 0x6C, 0xFA, 0x6C, 0xF9, 0x6B, 0xDF, 0x6B, 0xE0, 0x6B, 0xE1, 0x6B, 0xE9, 0x51, 0xDF, 0x1B, 0xF8, 0x51, 0xE0, 0x1B, 0xF7, 0x51, 0xE1, 0x1B, 0xF6, 0x51, 0xE9, 0x1B, 0xF5, 0xC0, 0x11, 0x53, 0xE9, 0x52, 0xF8, 0x14, 0xDF, 0x52, 0xF7, 0x1C, 0xE0, 0x52, 0xF6, 0x1C, 0xE1, 0x77, 0xFC, 0x7B, 0x00, 0xBF, 0xCB, 0x51, 0xDF, 0x54, 0xF8, 0x51, 0xE0, 0x54, 0xF7, 0x51, 0xE1, 0x54, 0xF6, 0x3A, 0xF2 - } - }, - { - 255, - 79, - 0x39, - 0x012A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x2A, 0x51, 0xE9, 0x54, 0xF5, 0x18, 0x53, 0xE9, 0x18, 0x60, 0xD0, 0x7F, 0x37, 0xFC, 0xFF, 0x77, 0xFC, 0x37, 0xFB, 0xFF, 0x0F, 0xFB, 0x00, 0x37, 0xFA, 0xFF, 0x0F, 0xFA, 0x00, 0x37, 0xF9, 0xFF, 0x0F, 0xF9, 0x00, 0x7F, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x08, 0x66, 0xFC, 0x6B, 0xE1, 0x51, 0xE1, 0x1B, 0xFB, 0xC0, 0x05, 0x53, 0xE1, 0x77, 0xFC, 0x7A, 0xE0, 0xBF, 0xEF, 0x7F, 0x08, 0x10, 0x4F, 0x50, 0x80, 0x7F - } - }, - { - 256, - 79, - 0x39, - 0x012B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x2B, 0x00, 0x6F, 0xFF, 0xD0, 0x03, 0x03, 0xFE, 0x66, 0xFE, 0xBF, 0xF7, 0x38, 0xFE, 0x70, 0x3F, 0x71, 0xC0, 0x7F, 0x7C, 0x6E, 0x82, 0x7C, 0x6E, 0xC0, 0x7F, 0x62, 0xD0, 0x01, 0x51, 0xE7, 0x08, 0x51, 0xE6, 0x62, 0xD0, 0x03, 0x53, 0xFE, 0x18, 0x53, 0xFF, 0x62, 0xD0, 0x01, 0x51, 0xE5, 0x08, 0x51, 0xE4, 0x62, 0xD0, 0x03, 0x53, 0xFC, 0x18, 0x53, 0xFD, 0x62, 0xD0, 0x01, 0x51, 0xEF, 0x08, 0x51, 0x7E, 0x7C - } - }, - { - 257, - 79, - 0x39, - 0x012C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x2C, 0xEE, 0x62, 0xD0, 0x03, 0x53, 0xFA, 0x18, 0x53, 0xFB, 0x62, 0xD0, 0x01, 0x51, 0xED, 0x08, 0x51, 0xEC, 0x62, 0xD0, 0x03, 0x53, 0xF8, 0x18, 0x53, 0xF9, 0x7F, 0x62, 0xD0, 0x01, 0x51, 0xE7, 0x02, 0xEF, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x62, 0xD0, 0x01, 0x51, 0xE6, 0x0A, 0xEE, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x7C, 0x6D, 0xF3, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xA3, 0x18, 0x23, 0xC7 - } - }, - { - 258, - 79, - 0x39, - 0x012D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x2D, 0x53, 0xA4, 0x62, 0xD0, 0x01, 0x51, 0xE5, 0x02, 0xED, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x0A, 0xEC, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x7C, 0x6D, 0xF3, 0x7C, 0x71, 0xC3, 0x7F, 0x10, 0x4F, 0x52, 0xFA, 0x13, 0xFC, 0x52, 0xF9, 0x1B, 0xFB, 0xD0, 0x12, 0x62, 0xD0, 0x00, 0x52, 0xFC, 0x13, 0xFA, 0x53, 0xE8, 0x52, 0xFB, 0x1B, 0xF9, 0x53, 0xE9, 0x80, 0x10, 0x62, 0xD0, 0xB7, 0xF0 - } - }, - { - 259, - 79, - 0x39, - 0x012E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x2E, 0x00, 0x52, 0xFA, 0x13, 0xFC, 0x53, 0xE8, 0x52, 0xF9, 0x1B, 0xFB, 0x53, 0xE9, 0x20, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xCD, 0x00, 0x7C, 0x70, 0x41, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x9F, 0xB4, 0x38, 0xFC, 0x7C, 0x6F, 0xA8, 0x62, 0xD0, 0x03, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xEE, 0x8C, 0x9B - } - }, - { - 260, - 79, - 0x39, - 0x012F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x2F, 0x08, 0x51, 0xEF, 0x08, 0x9F, 0x9B, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x62, 0xD0, 0x04, 0x04, 0xA0, 0x7C, 0x71, 0x7F, 0x0C, 0x9F, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x9F, 0x78, 0x38, 0xF8, 0x7C, 0x6F, 0x76, 0x62, 0xD0, 0x03, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x6A, 0x58 - } - }, - { - 261, - 79, - 0x39, - 0x0130, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x30, 0x9F, 0x5F, 0x38, 0xFC, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x62, 0xD0, 0x04, 0x04, 0x9E, 0x7C, 0x71, 0x7F, 0x0C, 0x9D, 0x7F, 0x10, 0x7C, 0x1E, 0x80, 0x62, 0xD0, 0x00, 0x5A, 0xE9, 0x20, 0x7C, 0x71, 0x22, 0x51, 0xAE, 0x62, 0xD0, 0x03, 0x12, 0xDD, 0x62, 0xD0, 0x04, 0x53, 0xA6, 0x62, 0xD0, 0x04, 0x51, 0xAD, 0x62, 0xD0, 0x03, 0x1A, 0xDC, 0x62, 0xD0, 0x04, 0x53, 0xA5, 0x62, 0xD0, 0x04, 0x51, 0x3D, 0xFF - } - }, - { - 262, - 79, - 0x39, - 0x0131, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x31, 0xAE, 0x08, 0x51, 0xAD, 0x62, 0xD0, 0x03, 0x53, 0xDC, 0x18, 0x53, 0xDD, 0x62, 0xD0, 0x04, 0x51, 0xA6, 0x62, 0xD0, 0x00, 0x53, 0xE6, 0x62, 0xD0, 0x04, 0x51, 0xA5, 0x62, 0xD0, 0x00, 0x53, 0xE7, 0x62, 0xD0, 0x04, 0x51, 0xA0, 0x08, 0x62, 0xD0, 0x00, 0x18, 0x53, 0xE5, 0x55, 0xE4, 0x00, 0x65, 0xE5, 0x65, 0xE4, 0x6B, 0xE5, 0x51, 0xE4, 0x53, 0xE2, 0x51, 0xE5, 0x53, 0xE3, 0x50, 0x00, 0x08, 0x8B, 0x9C - } - }, - { - 263, - 79, - 0x39, - 0x0132, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x32, 0x08, 0x51, 0xE7, 0x08, 0x51, 0xE6, 0x08, 0x50, 0x00, 0x08, 0x08, 0x51, 0xE3, 0x08, 0x51, 0xE2, 0x08, 0x7C, 0x49, 0xD3, 0x18, 0x53, 0xE6, 0x18, 0x53, 0xE7, 0x18, 0x18, 0x38, 0xFC, 0x51, 0xE6, 0x53, 0xE8, 0x51, 0xE7, 0x53, 0xE9, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0x9B, 0x18, 0x53, 0x9C, 0x62, 0xD0, 0x04, 0x51, 0xA6, 0x62, 0xD0, 0x00, 0x53, 0xE6, 0x62, 0xD0, 0x04, 0x57, 0x35 - } - }, - { - 264, - 79, - 0x39, - 0x0133, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x33, 0x51, 0xA5, 0x62, 0xD0, 0x00, 0x53, 0xE7, 0x62, 0xD0, 0x04, 0x51, 0x9E, 0x08, 0x62, 0xD0, 0x00, 0x18, 0x53, 0xE5, 0x55, 0xE4, 0x00, 0x65, 0xE5, 0x65, 0xE4, 0x6B, 0xE5, 0x51, 0xE4, 0x53, 0xE2, 0x51, 0xE5, 0x53, 0xE3, 0x50, 0x00, 0x08, 0x08, 0x51, 0xE7, 0x08, 0x51, 0xE6, 0x08, 0x50, 0x00, 0x08, 0x08, 0x51, 0xE3, 0x08, 0x51, 0xE2, 0x08, 0x7C, 0x49, 0xD3, 0x18, 0x53, 0xE6, 0x18, 0x53, 0x0D, 0xA2 - } - }, - { - 265, - 79, - 0x39, - 0x0134, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x34, 0xE7, 0x18, 0x18, 0x38, 0xFC, 0x51, 0xE6, 0x53, 0xE8, 0x51, 0xE7, 0x53, 0xE9, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0x99, 0x18, 0x53, 0x9A, 0x7C, 0x6E, 0x82, 0x7F, 0x10, 0x4F, 0x38, 0x08, 0x62, 0xD0, 0x04, 0x55, 0xDE, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xDD, 0x00, 0x52, 0xFC, 0x03, 0xFA, 0x54, 0x01, 0x52, 0xFB, 0x0B, 0xF9, 0x54, 0x00, 0x52, 0xF8, 0x03, 0xF6, 0x54, 0x03, 0x0D, 0xA3 - } - }, - { - 266, - 79, - 0x39, - 0x0135, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x35, 0x52, 0xF7, 0x0B, 0xF5, 0x54, 0x02, 0x52, 0xFC, 0x03, 0xF6, 0x54, 0x05, 0x52, 0xFB, 0x0B, 0xF5, 0x54, 0x04, 0x52, 0xFA, 0x03, 0xF8, 0x54, 0x07, 0x52, 0xF9, 0x0B, 0xF7, 0x54, 0x06, 0x52, 0xFC, 0x13, 0xF8, 0x52, 0xFB, 0x1B, 0xF7, 0xC0, 0x43, 0x7C, 0x72, 0xD4, 0xD0, 0x1E, 0x62, 0xD0, 0x04, 0x55, 0xDE, 0x01, 0x52, 0x01, 0x13, 0x03, 0x52, 0x00, 0x1B, 0x02, 0xD0, 0x06, 0x7C, 0x73, 0x66, 0x05, 0x94 - } - }, - { - 267, - 79, - 0x39, - 0x0136, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x36, 0x80, 0x69, 0x62, 0xD0, 0x04, 0x55, 0xDD, 0x02, 0x80, 0x61, 0x62, 0xD0, 0x04, 0x55, 0xDE, 0x02, 0x52, 0x07, 0x13, 0x05, 0x52, 0x06, 0x1B, 0x04, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xDD, 0x02, 0x80, 0x49, 0x62, 0xD0, 0x04, 0x55, 0xDD, 0x03, 0x80, 0x41, 0x7C, 0x72, 0xD4, 0xC0, 0x21, 0x62, 0xD0, 0x04, 0x55, 0xDE, 0x03, 0x52, 0x03, 0x13, 0x01, 0x52, 0x02, 0x1B, 0x00, 0xD0, 0x09, 0x62, 0xE1, 0x4D - } - }, - { - 268, - 79, - 0x39, - 0x0137, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x37, 0xD0, 0x04, 0x55, 0xDD, 0x03, 0x80, 0x24, 0x62, 0xD0, 0x04, 0x55, 0xDD, 0x04, 0x80, 0x1C, 0x62, 0xD0, 0x04, 0x55, 0xDE, 0x04, 0x52, 0x05, 0x13, 0x07, 0x52, 0x04, 0x1B, 0x06, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xDD, 0x04, 0x80, 0x04, 0x7C, 0x73, 0x66, 0x62, 0xD0, 0x04, 0x3C, 0xDD, 0x01, 0xB0, 0x29, 0x62, 0xD0, 0x00, 0x52, 0xF3, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x52, 0xFA, 0x02, 0xE8, 0x77, 0x7A - } - }, - { - 269, - 79, - 0x39, - 0x0138, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x38, 0x53, 0xE8, 0x52, 0xF9, 0x0A, 0xE9, 0x53, 0xE9, 0x51, 0xE8, 0x13, 0xF6, 0x51, 0xE9, 0x1B, 0xF5, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xE0, 0x01, 0x80, 0x97, 0x62, 0xD0, 0x04, 0x3C, 0xDD, 0x02, 0xB0, 0x29, 0x62, 0xD0, 0x00, 0x52, 0xF4, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x52, 0xF8, 0x02, 0xE8, 0x53, 0xE8, 0x52, 0xF7, 0x0A, 0xE9, 0x53, 0xE9, 0x51, 0xE8, 0x13, 0xFC, 0x51, 0xE9, 0x1B, 0xFB, 0x37, 0xFB - } - }, - { - 270, - 79, - 0x39, - 0x0139, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x39, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xE0, 0x02, 0x80, 0x67, 0x62, 0xD0, 0x04, 0x3C, 0xDD, 0x03, 0xB0, 0x29, 0x62, 0xD0, 0x00, 0x52, 0xF3, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x52, 0xF6, 0x02, 0xE8, 0x53, 0xE8, 0x52, 0xF5, 0x0A, 0xE9, 0x53, 0xE9, 0x51, 0xE8, 0x13, 0xFA, 0x51, 0xE9, 0x1B, 0xF9, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xE0, 0x03, 0x80, 0x37, 0x62, 0xD0, 0x04, 0x3C, 0xDD, 0x04, 0x10, 0xAE - } - }, - { - 271, - 79, - 0x39, - 0x013A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x3A, 0xB0, 0x29, 0x62, 0xD0, 0x00, 0x52, 0xF4, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x52, 0xFC, 0x02, 0xE8, 0x53, 0xE8, 0x52, 0xFB, 0x0A, 0xE9, 0x53, 0xE9, 0x51, 0xE8, 0x13, 0xF8, 0x51, 0xE9, 0x1B, 0xF7, 0xD0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xE0, 0x04, 0x80, 0x07, 0x62, 0xD0, 0x04, 0x55, 0xE0, 0x00, 0x62, 0xD0, 0x04, 0x3C, 0xDE, 0x04, 0xB0, 0x15, 0x62, 0xD0, 0x04, 0x3C, 0xDD, 0x01, 0xB0, 0x0D, 0xA9, 0xE1 - } - }, - { - 272, - 79, - 0x39, - 0x013B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x3B, 0x62, 0xD0, 0x04, 0x51, 0xDE, 0x01, 0x03, 0x62, 0xD0, 0x00, 0x80, 0x15, 0x62, 0xD0, 0x04, 0x51, 0xDE, 0x62, 0xD0, 0x04, 0x02, 0xDD, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x16, 0xE9, 0x02, 0x51, 0xE9, 0x38, 0xF8, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x09, 0x52, 0xF7, 0x3B, 0xFB, 0xB0, 0x1B, 0x52, 0xF8, 0x3B, 0xFC, 0xB0, 0x15, 0x52, 0xF5, 0x3B, 0xF9, 0xB0, 0x0F, 0x52, 0xF6, 0x3B, 0xFA, 0xB0, 0x09, 0xC2, 0x14 - } - }, - { - 273, - 79, - 0x39, - 0x013C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x3C, 0x62, 0xD0, 0x04, 0x55, 0xDF, 0xFE, 0x81, 0x17, 0x52, 0xF7, 0x3B, 0xFB, 0xB0, 0x07, 0x52, 0xF8, 0x3B, 0xFC, 0xA0, 0x0D, 0x52, 0xF5, 0x3B, 0xF9, 0xB0, 0x4E, 0x52, 0xF6, 0x3B, 0xFA, 0xB0, 0x48, 0x62, 0xD0, 0x04, 0x3C, 0xCE, 0x00, 0xA0, 0x06, 0x3C, 0xCE, 0x07, 0xB0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xDF, 0x00, 0x80, 0xEA, 0x62, 0xD0, 0x04, 0x3C, 0xCE, 0x01, 0xA0, 0x06, 0x3C, 0xCE, 0x02, 0xC9, 0x23 - } - }, - { - 274, - 79, - 0x39, - 0x013D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x3D, 0xB0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xDF, 0x02, 0x80, 0xD5, 0x62, 0xD0, 0x04, 0x3C, 0xCE, 0x03, 0xA0, 0x06, 0x3C, 0xCE, 0x04, 0xB0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xDF, 0x04, 0x80, 0xC0, 0x62, 0xD0, 0x04, 0x55, 0xDF, 0x06, 0x80, 0xB8, 0x52, 0xFB, 0x08, 0x52, 0xFC, 0x08, 0x52, 0xF7, 0x08, 0x52, 0xF8, 0x08, 0x9B, 0xEC, 0x7C, 0x72, 0x25, 0x52, 0xF9, 0x08, 0x52, 0xFA, 0x08, 0x52, 0xF5, 0x56, 0x3E - } - }, - { - 275, - 79, - 0x39, - 0x013E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x3E, 0x08, 0x52, 0xF6, 0x08, 0x9B, 0xDB, 0x38, 0xF8, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x54, 0x03, 0x51, 0xE9, 0x54, 0x02, 0x52, 0x01, 0x13, 0x03, 0x52, 0x00, 0x1B, 0x02, 0xD0, 0x23, 0x7C, 0x71, 0x2E, 0x7C, 0x70, 0x17, 0x7C, 0x73, 0x4A, 0xD0, 0x09, 0x56, 0x06, 0x01, 0x56, 0x05, 0x00, 0x80, 0x07, 0x56, 0x06, 0x00, 0x56, 0x05, 0x00, 0x62, 0xD0, 0x00, 0x52, 0x06, 0x54, 0x04, 0x80, 0x2C, 0x62, 0x31, 0xF5 - } - }, - { - 276, - 79, - 0x39, - 0x013F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x3F, 0xD0, 0x00, 0x52, 0x03, 0x53, 0xE8, 0x52, 0x02, 0x53, 0xE9, 0x7C, 0x70, 0x17, 0x13, 0x01, 0x51, 0xE9, 0x1B, 0x00, 0xD0, 0x09, 0x56, 0x08, 0x01, 0x56, 0x07, 0x00, 0x80, 0x07, 0x56, 0x08, 0x00, 0x56, 0x07, 0x00, 0x62, 0xD0, 0x00, 0x52, 0x08, 0x54, 0x04, 0x62, 0xD0, 0x04, 0x47, 0xCE, 0x01, 0xB0, 0x1B, 0x62, 0xD0, 0x00, 0x52, 0x04, 0x31, 0x01, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xCE, 0x79, 0x86 - } - }, - { - 277, - 79, - 0x39, - 0x0140, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x40, 0x62, 0xD0, 0x00, 0x02, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xDF, 0x80, 0x0D, 0x62, 0xD0, 0x04, 0x51, 0xCE, 0x03, 0x04, 0x62, 0xD0, 0x04, 0x53, 0xDF, 0x62, 0xD0, 0x04, 0x26, 0xDF, 0x07, 0x62, 0xD0, 0x04, 0x51, 0xDF, 0x01, 0x01, 0x62, 0xD0, 0x00, 0x38, 0xF7, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x04, 0x56, 0x00, 0x00, 0x7C, 0x72, 0xAB, 0x10, 0x7C, 0x1E, 0x80, 0x62, 0xD0, 0x00, 0x5A, 0xE9, 0x20, 0xC9, 0x27 - } - }, - { - 278, - 79, - 0x39, - 0x0141, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x41, 0x7C, 0x71, 0x22, 0x3D, 0xFC, 0x01, 0xA0, 0x62, 0x3D, 0xFC, 0x00, 0xB0, 0x41, 0x62, 0xD0, 0x04, 0x55, 0xD0, 0x00, 0x62, 0xD0, 0x04, 0x7C, 0x71, 0xEE, 0x3C, 0xAD, 0x00, 0xB0, 0x06, 0x3C, 0xAE, 0x00, 0xA0, 0x22, 0x62, 0xD0, 0x04, 0x51, 0xAE, 0x08, 0x51, 0xAD, 0x62, 0xD0, 0x04, 0x53, 0xAF, 0x18, 0x53, 0xB0, 0x10, 0x50, 0x00, 0x5C, 0x7C, 0x1E, 0xB4, 0x20, 0x62, 0xD0, 0x03, 0x55, 0xDD, 0x4B, 0x2C - } - }, - { - 279, - 79, - 0x39, - 0x0142, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x42, 0x00, 0x55, 0xDC, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xA6, 0x00, 0x55, 0xA5, 0x00, 0x7C, 0x72, 0x85, 0x62, 0xD0, 0x03, 0x55, 0xE3, 0x00, 0x55, 0xE2, 0x00, 0x7C, 0x73, 0x5F, 0x62, 0xD0, 0x04, 0x55, 0xD4, 0x00, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x83, 0xAD, 0x62, 0xD0, 0x04, 0x3C, 0xDC, 0x01, 0xA0, 0x2A, 0x62, 0xD0, 0x01, 0x51, 0xE7, 0x08, 0x51, 0xE6, 0x62, 0xD0, 0x03, 0x53, 0xFE, 0x18, 0x53, 0x86, 0xA3 - } - }, - { - 280, - 79, - 0x39, - 0x0143, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x43, 0xFF, 0x62, 0xD0, 0x01, 0x51, 0xE5, 0x08, 0x51, 0xE4, 0x62, 0xD0, 0x03, 0x53, 0xFC, 0x18, 0x53, 0xFD, 0x7C, 0x6E, 0x82, 0x62, 0xD0, 0x04, 0x55, 0xDC, 0x01, 0x62, 0xD0, 0x01, 0x51, 0xE7, 0x08, 0x51, 0xE6, 0x62, 0xD0, 0x03, 0x53, 0xF6, 0x18, 0x53, 0xF7, 0x62, 0xD0, 0x01, 0x51, 0xE5, 0x08, 0x51, 0xE4, 0x62, 0xD0, 0x03, 0x53, 0xF4, 0x18, 0x53, 0xF5, 0x62, 0xD0, 0x00, 0x51, 0x3A, 0x08, 0x36, 0x04 - } - }, - { - 281, - 79, - 0x39, - 0x0144, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x44, 0x62, 0xD0, 0x00, 0x51, 0x39, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x9B, 0xF5, 0x38, 0xF6, 0x7C, 0x71, 0x88, 0x54, 0x00, 0x3D, 0x00, 0x00, 0xA1, 0x23, 0x3D, 0xFB, 0x00, 0xA1, 0x1E, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0xAC, 0xF1 - } - }, - { - 282, - 79, - 0x39, - 0x0145, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x45, 0x62, 0xD0, 0x03, 0x51, 0xE3, 0x21, 0x0F, 0x62, 0xD0, 0x00, 0x53, 0xE6, 0x62, 0xD0, 0x03, 0x51, 0xE2, 0x21, 0x00, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0xB0, 0x07, 0x51, 0xE6, 0x3A, 0xE8, 0xA0, 0xA4, 0x62, 0xD0, 0x03, 0x65, 0xE3, 0x6B, 0xE2, 0x65, 0xE3, 0x6B, 0xE2, 0x65, 0xE3, 0x6B, 0xE2, 0x65, 0xE3, 0x6B, 0xE2, 0x52, 0x00, 0x2C, 0xE3, 0x3C, 0xE2, 0x12, 0xB0, 0x06, 0x3C, 0xE3, 0x34, 0xA0, 0xF9, 0x8C - } - }, - { - 283, - 79, - 0x39, - 0x0146, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x46, 0x28, 0x62, 0xD0, 0x03, 0x3C, 0xE2, 0x23, 0xB0, 0x06, 0x3C, 0xE3, 0x41, 0xA0, 0x1B, 0x62, 0xD0, 0x03, 0x3C, 0xE2, 0x34, 0xB0, 0x06, 0x3C, 0xE3, 0x12, 0xA0, 0x0E, 0x62, 0xD0, 0x03, 0x3C, 0xE2, 0x41, 0xB0, 0x14, 0x3C, 0xE3, 0x23, 0xB0, 0x0F, 0x62, 0xD0, 0x04, 0x55, 0xD2, 0x01, 0x62, 0xD0, 0x04, 0x55, 0xD3, 0x01, 0x80, 0x49, 0x62, 0xD0, 0x03, 0x3C, 0xE2, 0x43, 0xB0, 0x06, 0x3C, 0xE3, 0xD5, 0x45 - } - }, - { - 284, - 79, - 0x39, - 0x0147, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x47, 0x21, 0xA0, 0x28, 0x62, 0xD0, 0x03, 0x3C, 0xE2, 0x32, 0xB0, 0x06, 0x3C, 0xE3, 0x14, 0xA0, 0x1B, 0x62, 0xD0, 0x03, 0x3C, 0xE2, 0x21, 0xB0, 0x06, 0x3C, 0xE3, 0x43, 0xA0, 0x0E, 0x62, 0xD0, 0x03, 0x3C, 0xE2, 0x14, 0xB0, 0x14, 0x3C, 0xE3, 0x32, 0xB0, 0x0F, 0x62, 0xD0, 0x04, 0x55, 0xD2, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xD3, 0x01, 0x80, 0x07, 0x62, 0xD0, 0x04, 0x55, 0xD3, 0x00, 0x7C, 0x72, 0x16, 0xC8 - } - }, - { - 285, - 79, - 0x39, - 0x0148, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x48, 0x85, 0x80, 0x3D, 0x7C, 0x73, 0x0E, 0x39, 0x00, 0xA0, 0x36, 0x62, 0xD0, 0x04, 0x3C, 0xD3, 0x01, 0xB0, 0x2E, 0x62, 0xD0, 0x00, 0x7C, 0x73, 0x0E, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xD1, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0xA0, 0x08, 0x62, 0xD0, 0x04, 0x76, 0xD1, 0x80, 0x13, 0x62, 0xD0, 0x03, 0x55, 0xE3, 0x00, 0x55, 0xE2, 0x00, 0x7C, 0x72, 0x85, 0x62, 0xD0, 0x04, 0x55, 0xD3, 0x00, 0x62, 0x19, 0xCF - } - }, - { - 286, - 79, - 0x39, - 0x0149, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x49, 0xD0, 0x04, 0x3C, 0xD3, 0x01, 0xB0, 0x11, 0x62, 0xD0, 0x04, 0x3C, 0xD2, 0x01, 0xB0, 0x06, 0x56, 0x00, 0x28, 0x80, 0x04, 0x56, 0x00, 0x29, 0x3D, 0x00, 0x00, 0xA0, 0x3E, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x9C, 0x65, 0x38, 0x1E, 0xDA - } - }, - { - 287, - 79, - 0x39, - 0x014A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x4A, 0xF8, 0x54, 0x03, 0x3D, 0xFB, 0x00, 0xA0, 0x09, 0x62, 0xD0, 0x04, 0x3C, 0xD3, 0x00, 0xB0, 0x0A, 0x52, 0x03, 0x54, 0x00, 0x66, 0x00, 0x07, 0x00, 0x0E, 0x7C, 0x72, 0xF6, 0x39, 0x00, 0xA1, 0x5B, 0x3D, 0x00, 0x00, 0xA1, 0x56, 0x3D, 0x00, 0x28, 0xA1, 0x51, 0x3D, 0x00, 0x29, 0xA1, 0x4C, 0x62, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0xB4, 0x07 - } - }, - { - 288, - 79, - 0x39, - 0x014B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x4B, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x7C, 0x6F, 0xA8, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x7C, 0x6F, 0x76, 0x62, 0xD0, 0x04, 0x52, 0x00, 0x3A, 0xD4, 0xB0, 0x04, 0x56, 0x01, 0x01, 0x3D, 0x01, 0x00, 0xB0, 0xD4, 0x62, 0xD0, 0x00, 0x3C, 0x39, 0x00, 0xB0, 0x73, 0x62, 0xD0, 0x00, 0x3C, 0xBA, 0x14 - } - }, - { - 289, - 79, - 0x39, - 0x014C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x4C, 0x3A, 0x00, 0xB0, 0x6B, 0x62, 0xD0, 0x04, 0x3C, 0x9F, 0x00, 0xB0, 0x06, 0x3C, 0xA0, 0x00, 0xA0, 0x0E, 0x62, 0xD0, 0x04, 0x3C, 0x9D, 0x00, 0xB0, 0x56, 0x3C, 0x9E, 0x00, 0xB0, 0x51, 0x3D, 0x00, 0x10, 0xB0, 0x13, 0x62, 0xD0, 0x04, 0x3C, 0xD4, 0x14, 0xA0, 0x06, 0x3C, 0xD4, 0x1C, 0xB0, 0x3F, 0x56, 0x01, 0x01, 0x80, 0x3A, 0x3D, 0x00, 0x1C, 0xB0, 0x13, 0x62, 0xD0, 0x04, 0x3C, 0xD4, 0x18, 0x4D, 0x3B - } - }, - { - 290, - 79, - 0x39, - 0x014D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x4D, 0xA0, 0x06, 0x3C, 0xD4, 0x10, 0xB0, 0x28, 0x56, 0x01, 0x01, 0x80, 0x23, 0x3D, 0x00, 0x18, 0xA0, 0x06, 0x3D, 0x00, 0x14, 0xB0, 0x19, 0x62, 0xD0, 0x00, 0x52, 0x00, 0x11, 0x04, 0x7C, 0x70, 0x27, 0xA0, 0x0A, 0x52, 0x00, 0x01, 0x04, 0x7C, 0x70, 0x27, 0xB0, 0x04, 0x56, 0x01, 0x01, 0x3D, 0x00, 0x10, 0xB0, 0x18, 0x62, 0xD0, 0x04, 0x3C, 0xD4, 0x10, 0xA0, 0x0B, 0x3C, 0xD4, 0x1E, 0xA0, 0x06, 0x64, 0x6A - } - }, - { - 291, - 79, - 0x39, - 0x014E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x4E, 0x3C, 0xD4, 0x12, 0xB0, 0x43, 0x56, 0x01, 0x01, 0x80, 0x3E, 0x3D, 0x00, 0x1E, 0xB0, 0x18, 0x62, 0xD0, 0x04, 0x3C, 0xD4, 0x1E, 0xA0, 0x0B, 0x3C, 0xD4, 0x10, 0xA0, 0x06, 0x3C, 0xD4, 0x1C, 0xB0, 0x27, 0x56, 0x01, 0x01, 0x80, 0x22, 0x62, 0xD0, 0x04, 0x51, 0xD4, 0x3B, 0x00, 0xA0, 0x16, 0x62, 0xD0, 0x00, 0x52, 0x00, 0x11, 0x02, 0x7C, 0x70, 0x27, 0xA0, 0x0A, 0x52, 0x00, 0x01, 0x02, 0x7C, 0x91, 0xC5 - } - }, - { - 292, - 79, - 0x39, - 0x014F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x4F, 0x70, 0x27, 0xB0, 0x04, 0x56, 0x01, 0x01, 0x3D, 0x01, 0x01, 0xB0, 0x22, 0x62, 0xD0, 0x00, 0x7C, 0x72, 0xF6, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xD5, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0xA0, 0x1B, 0x7C, 0x6E, 0x82, 0x62, 0xD0, 0x04, 0x76, 0xD5, 0x56, 0x00, 0x00, 0x80, 0x0E, 0x7C, 0x73, 0x5F, 0x52, 0x00, 0x62, 0xD0, 0x04, 0x53, 0xD4, 0x56, 0x00, 0x00, 0x3D, 0x00, 0x00, 0xA0, 0x52, 0x62, 0x27, 0xF2 - } - }, - { - 293, - 79, - 0x39, - 0x0150, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x50, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x7C, 0x6F, 0xA8, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x7C, 0x6F, 0x76, 0x7C, 0x4C, 0x14, 0x62, 0xD0, 0x04, 0x52, 0x00, 0x3A, 0xD0, 0xB0, 0x08, 0x62, 0xAE, 0x01 - } - }, - { - 294, - 79, - 0x39, - 0x0151, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x51, 0xD0, 0x04, 0x76, 0xCF, 0x80, 0x04, 0x7C, 0x70, 0x5B, 0x52, 0x00, 0x62, 0xD0, 0x04, 0x53, 0xD0, 0x52, 0x00, 0x62, 0xD0, 0x00, 0x38, 0xFC, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x7C, 0x72, 0xAB, 0x56, 0x00, 0x00, 0x52, 0xFC, 0x08, 0x7C, 0x5B, 0xE0, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x54, 0x00, 0x52, 0xFC, 0x08, 0x90, 0x6D, 0x62, 0xD0, 0x00, 0x54, 0x01, 0x52, 0xFC, 0x08, 0x90, 0x96, 0x38, 0xC7, 0x34 - } - }, - { - 295, - 79, - 0x39, - 0x0152, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x52, 0xFE, 0x62, 0xD0, 0x00, 0x54, 0x02, 0x3D, 0x00, 0x00, 0xA0, 0x05, 0x52, 0x00, 0x80, 0x12, 0x3D, 0x01, 0x00, 0xA0, 0x08, 0x52, 0x01, 0x62, 0xD0, 0x00, 0x80, 0x06, 0x52, 0x02, 0x62, 0xD0, 0x00, 0x38, 0xFD, 0x20, 0x7F, 0x10, 0x4F, 0x50, 0x00, 0x08, 0x52, 0xFC, 0x08, 0x9B, 0x7E, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x01, 0x56, 0x00, 0x00, 0x50, 0x01, 0x08, 0x52, 0x5D, 0x61 - } - }, - { - 296, - 79, - 0x39, - 0x0153, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x53, 0xFC, 0x08, 0x9B, 0x68, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x54, 0x00, 0x3D, 0x00, 0x28, 0xA0, 0x0A, 0x3D, 0x00, 0x29, 0xA0, 0x05, 0x50, 0x00, 0x80, 0x06, 0x52, 0x00, 0x62, 0xD0, 0x00, 0x38, 0xFF, 0x20, 0x7F, 0x10, 0x4F, 0x50, 0x01, 0x08, 0x52, 0xFC, 0x08, 0x9B, 0x40, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x50, 0x00, 0x08, 0x52, 0xFC, 0x08, 0x90, 0x29, 0x38, 0xFE, 0x62, 0x5B, 0x5E - } - }, - { - 297, - 79, - 0x39, - 0x0154, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x54, 0xD0, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x50, 0x01, 0x08, 0x52, 0xFC, 0x08, 0x90, 0x18, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x50, 0x02, 0x08, 0x52, 0xFC, 0x08, 0x90, 0x07, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x0F, 0x56, 0x00, 0x00, 0x56, 0x04, 0x00, 0x7C, 0x72, 0xAB, 0x56, 0x03, 0x00, 0x10, 0x7C, 0x1E, 0x80, 0x62, 0xD0, 0x00, 0x5A, 0xE9, 0x20, 0xE0, 0x69 - } - }, - { - 298, - 79, - 0x39, - 0x0155, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x55, 0x7C, 0x71, 0x22, 0x10, 0x7C, 0x1E, 0x8D, 0x62, 0xD0, 0x00, 0x5A, 0xE9, 0x20, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xAB, 0x18, 0x53, 0xAC, 0x3D, 0xFC, 0x02, 0xD0, 0x61, 0x3D, 0xFC, 0x00, 0xB0, 0x41, 0x62, 0xD0, 0x04, 0x55, 0xD0, 0x00, 0x62, 0xD0, 0x04, 0x7C, 0x71, 0xEE, 0x3C, 0xAD, 0x00, 0xB0, 0x06, 0x3C, 0xAE, 0x00, 0xA0, 0x22, 0x62, 0xD0, 0x04, 0x51, 0xAE, 0x08, 0x51, 0xAD, 0xF0, 0x8A - } - }, - { - 299, - 79, - 0x39, - 0x0156, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x56, 0x62, 0xD0, 0x04, 0x53, 0xAF, 0x18, 0x53, 0xB0, 0x10, 0x50, 0x00, 0x5C, 0x7C, 0x1E, 0xB4, 0x20, 0x62, 0xD0, 0x03, 0x55, 0xDD, 0x00, 0x55, 0xDC, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xA6, 0x00, 0x55, 0xA5, 0x00, 0x62, 0xD0, 0x04, 0x55, 0xDB, 0x00, 0x7C, 0x73, 0x58, 0x7C, 0x73, 0x51, 0x10, 0x50, 0x00, 0x5C, 0x7C, 0x1E, 0xCC, 0x20, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x83, 0x71, 0x3D, 0xFC, 0x02, 0x20, 0xEB - } - }, - { - 300, - 79, - 0x39, - 0x0157, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x57, 0xB3, 0x0F, 0x62, 0xD0, 0x04, 0x3C, 0xDC, 0x02, 0xD0, 0x55, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x7C, 0x72, 0x01, 0x20, 0x3C, 0xE9, 0x00, 0xB0, 0x05, 0x39, 0x00, 0xA0, 0x33, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x7C, 0x72, 0x01, 0x53, 0xE8, 0x20, 0x62, 0xD0, 0x04, 0x51, 0xAC, 0x62, 0xD0, 0x00, 0x12, 0xE8, 0x62, 0xD0, 0x04, 0x51, 0xAB, 0x62, 0xD0, 0x00, 0x1A, 0xE9, 0xD0, 0x1A, 0x7C, 0xE0, 0x6C - } - }, - { - 301, - 79, - 0x39, - 0x0158, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x58, 0x4A, 0xD9, 0x7C, 0x4A, 0xD2, 0x7C, 0x4B, 0x1A, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x83, 0x1F, 0x7C, 0x4A, 0xD9, 0x7C, 0x4A, 0xD2, 0x7C, 0x4B, 0x1A, 0x62, 0xD0, 0x04, 0x55, 0xDC, 0x02, 0x3D, 0xFB, 0x01, 0xA0, 0x06, 0x3D, 0xFB, 0x02, 0xB1, 0x49, 0x62, 0xD0, 0x01, 0x51, 0xEE, 0x08, 0x51, 0xEF, 0x08, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x7C, 0x4B, 0x61, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x54, 0x7C, 0xA5 - } - }, - { - 302, - 79, - 0x39, - 0x0159, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x59, 0x08, 0x51, 0xE9, 0x54, 0x07, 0x62, 0xD0, 0x01, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xF8, 0x7C, 0x71, 0xF5, 0x62, 0xD0, 0x03, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x7C, 0x4B, 0x61, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x54, 0x0C, 0x51, 0xE9, 0x54, 0x0B, 0x62, 0xD0, 0x03, 0x51, 0x9A, 0xE2 - } - }, - { - 303, - 79, - 0x39, - 0x015A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x5A, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xF8, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x54, 0x0E, 0x51, 0xE9, 0x54, 0x0D, 0x52, 0x08, 0x13, 0x0C, 0x54, 0x06, 0x52, 0x07, 0x1B, 0x0B, 0x54, 0x05, 0x62, 0xD0, 0x00, 0x51, 0x3B, 0x62, 0xD0, 0x00, 0x13, 0x06, 0x52, 0x05, 0x31, 0x80, 0x53, 0xE1, 0x50, 0x00, 0x31, 0x80, 0x1A, 0xE1, 0x96, 0xDB - } - }, - { - 304, - 79, - 0x39, - 0x015B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x5B, 0xD0, 0x06, 0x56, 0x00, 0x48, 0x80, 0x41, 0x52, 0x06, 0x11, 0x00, 0x52, 0x05, 0x31, 0x80, 0x19, 0x80, 0xD0, 0x35, 0x62, 0xD0, 0x00, 0x52, 0x06, 0x73, 0x53, 0xE8, 0x52, 0x05, 0x73, 0x53, 0xE9, 0x51, 0xE8, 0x01, 0x01, 0x54, 0x06, 0x51, 0xE9, 0x09, 0x00, 0x54, 0x05, 0x62, 0xD0, 0x00, 0x51, 0x3B, 0x62, 0xD0, 0x00, 0x13, 0x06, 0x52, 0x05, 0x31, 0x80, 0x53, 0xE1, 0x50, 0x00, 0x31, 0x80, 0xF9, 0xA2 - } - }, - { - 305, - 79, - 0x39, - 0x015C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x5C, 0x1A, 0xE1, 0xD0, 0x04, 0x56, 0x00, 0x49, 0x52, 0x0A, 0x13, 0x0E, 0x54, 0x06, 0x52, 0x09, 0x1B, 0x0D, 0x54, 0x05, 0x62, 0xD0, 0x00, 0x51, 0x3C, 0x62, 0xD0, 0x00, 0x13, 0x06, 0x52, 0x05, 0x31, 0x80, 0x53, 0xE1, 0x50, 0x00, 0x31, 0x80, 0x1A, 0xE1, 0xD0, 0x06, 0x56, 0x00, 0x48, 0x80, 0x41, 0x52, 0x06, 0x11, 0x00, 0x52, 0x05, 0x31, 0x80, 0x19, 0x80, 0xD0, 0x35, 0x62, 0xD0, 0x00, 0x52, 0x2B, 0x07 - } - }, - { - 306, - 79, - 0x39, - 0x015D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x5D, 0x06, 0x73, 0x53, 0xE8, 0x52, 0x05, 0x73, 0x53, 0xE9, 0x51, 0xE8, 0x01, 0x01, 0x54, 0x06, 0x51, 0xE9, 0x09, 0x00, 0x54, 0x05, 0x62, 0xD0, 0x00, 0x51, 0x3C, 0x62, 0xD0, 0x00, 0x13, 0x06, 0x52, 0x05, 0x31, 0x80, 0x53, 0xE1, 0x50, 0x00, 0x31, 0x80, 0x1A, 0xE1, 0xD0, 0x04, 0x56, 0x00, 0x49, 0x3D, 0xFB, 0x00, 0xA0, 0x06, 0x3D, 0xFB, 0x02, 0xB1, 0x57, 0x62, 0xD0, 0x00, 0x51, 0x3A, 0x08, 0x85, 0xBC - } - }, - { - 307, - 79, - 0x39, - 0x015E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x5E, 0x62, 0xD0, 0x00, 0x51, 0x39, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x7C, 0x4D, 0x1E, 0x7C, 0x71, 0x88, 0x54, 0x01, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x08, 0x51, 0xEB, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x92, 0xD7 - } - }, - { - 308, - 79, - 0x39, - 0x015F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x5F, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xE4, 0x08, 0x51, 0xE5, 0x08, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x7C, 0x4E, 0xE4, 0x38, 0xEE, 0x54, 0x02, 0x62, 0xD0, 0x00, 0x51, 0x3A, 0x08, 0x62, 0xD0, 0x00, 0x51, 0x39, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x51, 0xEE, 0x51, 0x56 - } - }, - { - 309, - 79, - 0x39, - 0x0160, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x60, 0x08, 0x51, 0xEF, 0x08, 0x7C, 0x4D, 0x1E, 0x7C, 0x71, 0x88, 0x05, 0x01, 0x62, 0xD0, 0x03, 0x51, 0xE6, 0x08, 0x51, 0xE7, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x08, 0x62, 0xD0, 0x01, 0x51, 0xEC, 0x08, 0x51, 0xED, 0x08, 0x51, 0xEE, 0x08, 0x51, 0xEF, 0x08, 0x7C, 0x4E, 0xE4, 0x38, 0xEE, 0x62, 0xD0, 0x00, 0x54, 0x03, 0x3D, 0x01, 0x00, 0xA0, 0x95, 0x3D, 0x02, 0xFF, 0xA0, 0x19, 0xE7 - } - }, - { - 310, - 79, - 0x39, - 0x0161, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x61, 0x90, 0x3D, 0x03, 0xFF, 0xA0, 0x8B, 0x52, 0x02, 0x3B, 0x03, 0xA0, 0x0B, 0x3D, 0x02, 0x08, 0xB0, 0x0B, 0x3D, 0x03, 0x01, 0xB0, 0x06, 0x7C, 0x71, 0xB9, 0x80, 0x76, 0x3D, 0x03, 0x08, 0xB0, 0x11, 0x3D, 0x02, 0x01, 0xB0, 0x0C, 0x52, 0x03, 0x03, 0x03, 0x54, 0x00, 0x07, 0x00, 0x2E, 0x80, 0x61, 0x52, 0x03, 0x3B, 0x02, 0xD0, 0x2C, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x13, 0x03, 0x39, 0x01, 0xB0, 0xAA, 0x0A - } - }, - { - 311, - 79, - 0x39, - 0x0162, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x62, 0x21, 0x50, 0x02, 0x08, 0x52, 0x02, 0x08, 0x7C, 0x4A, 0x10, 0x38, 0xFF, 0x18, 0x39, 0x00, 0xB0, 0x06, 0x7C, 0x71, 0xB9, 0x80, 0x3B, 0x52, 0x03, 0x03, 0x03, 0x54, 0x00, 0x07, 0x00, 0x2E, 0x80, 0x30, 0x52, 0x02, 0x3B, 0x03, 0xD0, 0x2A, 0x62, 0xD0, 0x00, 0x52, 0x03, 0x13, 0x02, 0x39, 0x01, 0xB0, 0x1F, 0x50, 0x02, 0x08, 0x52, 0x03, 0x08, 0x7C, 0x4A, 0x10, 0x38, 0xFF, 0x18, 0x39, 0x00, 0x26, 0x03 - } - }, - { - 312, - 79, - 0x39, - 0x0163, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x63, 0xB0, 0x0C, 0x52, 0x03, 0x03, 0x03, 0x54, 0x00, 0x07, 0x00, 0x2E, 0x80, 0x04, 0x7C, 0x71, 0xB9, 0x3D, 0x00, 0x00, 0xA0, 0x54, 0x3D, 0xFB, 0x01, 0xB0, 0x0D, 0x52, 0x00, 0x08, 0x90, 0x52, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x80, 0x48, 0x3D, 0xFB, 0x00, 0xB0, 0x12, 0x62, 0xD0, 0x00, 0x52, 0x00, 0x29, 0x30, 0x08, 0x91, 0x16, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x80, 0x32, 0x3D, 0xFB, 0x02, 0xB0, 0xE9, 0x8A - } - }, - { - 313, - 79, - 0x39, - 0x0164, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x64, 0x28, 0x3D, 0x00, 0x48, 0xA0, 0x06, 0x3D, 0x00, 0x49, 0xB0, 0x0D, 0x52, 0x00, 0x08, 0x90, 0x21, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x80, 0x17, 0x62, 0xD0, 0x00, 0x52, 0x00, 0x29, 0x30, 0x08, 0x90, 0xEA, 0x38, 0xFF, 0x62, 0xD0, 0x00, 0x80, 0x06, 0x62, 0xD0, 0x00, 0x50, 0x00, 0x38, 0xF1, 0x20, 0x7F, 0x10, 0x4F, 0x7C, 0x72, 0xEE, 0x39, 0x00, 0xA0, 0x43, 0x3D, 0xFC, 0x00, 0xA0, 0x3E, 0x62, 0x09, 0xCB - } - }, - { - 314, - 79, - 0x39, - 0x0165, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x65, 0xD0, 0x04, 0x52, 0xFC, 0x3A, 0xD7, 0xB0, 0x2C, 0x62, 0xD0, 0x00, 0x7C, 0x72, 0xEE, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xD8, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0xA0, 0x21, 0x7C, 0x72, 0x39, 0x39, 0x00, 0xA0, 0x04, 0x7C, 0x72, 0x8C, 0x7C, 0x4A, 0xD2, 0x62, 0xD0, 0x04, 0x76, 0xD8, 0x56, 0xFC, 0x00, 0x80, 0x0A, 0x62, 0xD0, 0x04, 0x55, 0xD8, 0x00, 0x7C, 0x72, 0x59, 0x7C, 0x72, 0x39, 0x39, 0x4E, 0x56 - } - }, - { - 315, - 79, - 0x39, - 0x0166, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x66, 0x00, 0xA0, 0x4D, 0x3D, 0xFC, 0x00, 0xA0, 0x48, 0x62, 0xD0, 0x04, 0x3C, 0xDB, 0x00, 0xA0, 0x3D, 0x3C, 0xDB, 0x48, 0xA0, 0x38, 0x3C, 0xDB, 0x49, 0xA0, 0x33, 0x62, 0xD0, 0x04, 0x52, 0xFC, 0x3A, 0xD7, 0xB0, 0x22, 0x62, 0xD0, 0x00, 0x7C, 0x72, 0x39, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xD6, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0xA0, 0x19, 0x7C, 0x4A, 0xD2, 0x62, 0xD0, 0x04, 0x76, 0xD6, 0x56, 0x79, 0xAD - } - }, - { - 316, - 79, - 0x39, - 0x0167, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x67, 0xFC, 0x00, 0x80, 0x0C, 0x7C, 0x72, 0x8C, 0x7C, 0x72, 0x59, 0x80, 0x04, 0x7C, 0x72, 0x8C, 0x3D, 0xFC, 0x00, 0xA0, 0x31, 0x7C, 0x4B, 0x1A, 0x7C, 0x4B, 0x99, 0x7C, 0x4C, 0x14, 0x7C, 0x6E, 0xC0, 0x62, 0xD0, 0x04, 0x52, 0xFC, 0x3A, 0xD0, 0xB0, 0x08, 0x62, 0xD0, 0x04, 0x76, 0xCF, 0x80, 0x04, 0x7C, 0x70, 0x5B, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0xD0, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0x22, 0x00 - } - }, - { - 317, - 79, - 0x39, - 0x0168, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x68, 0xDB, 0x7C, 0x73, 0x58, 0x52, 0xFC, 0x62, 0xD0, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x05, 0x7C, 0x72, 0x64, 0x39, 0x00, 0xA1, 0x10, 0x56, 0x00, 0x00, 0x3D, 0xFC, 0x00, 0xA1, 0x08, 0x7C, 0x4B, 0x99, 0x62, 0xD0, 0x04, 0x52, 0xFC, 0x3A, 0xD9, 0xB0, 0x04, 0x56, 0x00, 0x01, 0x3D, 0x00, 0x00, 0xB0, 0xC1, 0x62, 0xD0, 0x00, 0x3C, 0x39, 0x00, 0xB0, 0x73, 0x62, 0xD0, 0x00, 0x3C, 0x3A, 0x00, 0x73, 0xA3 - } - }, - { - 318, - 79, - 0x39, - 0x0169, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x69, 0xB0, 0x6B, 0x62, 0xD0, 0x04, 0x3C, 0x9F, 0x00, 0xB0, 0x06, 0x3C, 0xA0, 0x00, 0xA0, 0x0E, 0x62, 0xD0, 0x04, 0x3C, 0x9D, 0x00, 0xB0, 0x56, 0x3C, 0x9E, 0x00, 0xB0, 0x51, 0x3D, 0xFC, 0x30, 0xB0, 0x13, 0x62, 0xD0, 0x04, 0x3C, 0xD9, 0x34, 0xA0, 0x06, 0x3C, 0xD9, 0x3C, 0xB0, 0x3F, 0x56, 0x00, 0x01, 0x80, 0x3A, 0x3D, 0xFC, 0x3C, 0xB0, 0x13, 0x62, 0xD0, 0x04, 0x3C, 0xD9, 0x38, 0xA0, 0x06, 0x5F, 0x7C - } - }, - { - 319, - 79, - 0x39, - 0x016A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x6A, 0x3C, 0xD9, 0x30, 0xB0, 0x28, 0x56, 0x00, 0x01, 0x80, 0x23, 0x3D, 0xFC, 0x38, 0xA0, 0x06, 0x3D, 0xFC, 0x34, 0xB0, 0x19, 0x62, 0xD0, 0x00, 0x52, 0xFC, 0x11, 0x04, 0x7C, 0x70, 0x34, 0xA0, 0x0A, 0x52, 0xFC, 0x01, 0x04, 0x7C, 0x70, 0x34, 0xB0, 0x04, 0x56, 0x00, 0x01, 0x3D, 0xFC, 0x30, 0xB0, 0x13, 0x62, 0xD0, 0x04, 0x3C, 0xD9, 0x3E, 0xA0, 0x06, 0x3C, 0xD9, 0x32, 0xB0, 0x35, 0x56, 0x00, 0x1E, 0xFB - } - }, - { - 320, - 79, - 0x39, - 0x016B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x6B, 0x01, 0x80, 0x30, 0x3D, 0xFC, 0x3E, 0xB0, 0x13, 0x62, 0xD0, 0x04, 0x3C, 0xD9, 0x30, 0xA0, 0x06, 0x3C, 0xD9, 0x3C, 0xB0, 0x1E, 0x56, 0x00, 0x01, 0x80, 0x19, 0x62, 0xD0, 0x00, 0x52, 0xFC, 0x11, 0x02, 0x7C, 0x70, 0x34, 0xA0, 0x0A, 0x52, 0xFC, 0x01, 0x02, 0x7C, 0x70, 0x34, 0xB0, 0x04, 0x56, 0x00, 0x01, 0x3D, 0x00, 0x01, 0xB0, 0x1F, 0x7C, 0x72, 0x64, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0x16, 0xEC - } - }, - { - 321, - 79, - 0x39, - 0x016C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x6C, 0xDA, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0xA0, 0x1E, 0x7C, 0x4A, 0xD2, 0x62, 0xD0, 0x04, 0x76, 0xDA, 0x56, 0xFC, 0x00, 0x80, 0x11, 0x62, 0xD0, 0x04, 0x55, 0xDA, 0x00, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0xD9, 0x56, 0xFC, 0x00, 0x3D, 0xFC, 0x00, 0xA0, 0xAE, 0x7C, 0x4B, 0x1A, 0x62, 0xD0, 0x03, 0x51, 0xED, 0x62, 0xD0, 0x03, 0x02, 0xE9, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0x43, 0x47 - } - }, - { - 322, - 79, - 0x39, - 0x016D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x6D, 0xEC, 0x62, 0xD0, 0x03, 0x0A, 0xE8, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x7C, 0x6D, 0xF3, 0x51, 0xE8, 0x54, 0x02, 0x51, 0xE9, 0x54, 0x01, 0x62, 0xD0, 0x03, 0x51, 0xEB, 0x62, 0xD0, 0x03, 0x02, 0xE7, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0xEA, 0x62, 0xD0, 0x03, 0x0A, 0xE6, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x7C, 0x6D, 0xF3, 0x51, 0xE8, 0x54, 0x04, 0x51, 0xE9, 0x54, 0x03, 0x52, 0xCA, 0x56 - } - }, - { - 323, - 79, - 0x39, - 0x016E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x6E, 0x01, 0x08, 0x52, 0x02, 0x08, 0x62, 0xD0, 0x04, 0x51, 0xA3, 0x08, 0x51, 0xA4, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x7C, 0x6F, 0xA8, 0x52, 0x03, 0x08, 0x52, 0x04, 0x08, 0x62, 0xD0, 0x04, 0x51, 0xA1, 0x08, 0x51, 0xA2, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x7C, 0x6F, 0x76, 0x7C, 0x4C, 0x14, 0x7C, 0x6E, 0xC0, 0x62, 0xD0, 0x04, 0x52, 0xFC, 0x3A, 0xD0, 0xB0, 0x08, 0x62, 0xD0, 0x04, 0x76, 0x9E, 0xFF - } - }, - { - 324, - 79, - 0x39, - 0x016F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x6F, 0xCF, 0x80, 0x04, 0x7C, 0x70, 0x5B, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0xD0, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0xDB, 0x7C, 0x73, 0x51, 0x52, 0xFC, 0x62, 0xD0, 0x00, 0x38, 0xFB, 0x20, 0x7F, 0x10, 0x4F, 0x50, 0x00, 0x08, 0x52, 0xFC, 0x08, 0x90, 0x07, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x04, 0x7C, 0x6F, 0xC9, 0x3D, 0xFB, 0x00, 0xA0, 0x37, 0x62, 0xD0, 0x04, 0xC4, 0x4C - } - }, - { - 325, - 79, - 0x39, - 0x0170, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x70, 0x55, 0xCD, 0x00, 0x7C, 0x70, 0x62, 0x50, 0x0D, 0x10, 0x08, 0x57, 0x8D, 0x28, 0x53, 0xE7, 0x18, 0x75, 0x09, 0x00, 0x28, 0x20, 0x02, 0xE8, 0x53, 0xE8, 0x51, 0xE7, 0x0A, 0xE9, 0x10, 0x08, 0x51, 0xE8, 0x20, 0x7C, 0x1E, 0xE4, 0x20, 0x7C, 0x73, 0x43, 0x7C, 0x70, 0x41, 0x52, 0xFB, 0x62, 0xD0, 0x00, 0x83, 0x5B, 0x3D, 0xFC, 0x00, 0xB2, 0xB8, 0x7C, 0x70, 0x5B, 0x10, 0x7C, 0x1E, 0x9A, 0x62, 0xB4, 0x2D - } - }, - { - 326, - 79, - 0x39, - 0x0171, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x71, 0xD0, 0x00, 0x5A, 0xE9, 0x20, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xA9, 0x18, 0x53, 0xAA, 0x10, 0x7C, 0x1E, 0xA7, 0x62, 0xD0, 0x00, 0x5A, 0xE9, 0x20, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xA7, 0x18, 0x53, 0xA8, 0x62, 0xD0, 0x04, 0x3C, 0xA9, 0x00, 0xB0, 0x06, 0x3C, 0xAA, 0x00, 0xA1, 0x37, 0x62, 0xD0, 0x04, 0x3C, 0xCC, 0x01, 0xB0, 0xFB, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x3F, 0x44 - } - }, - { - 327, - 79, - 0x39, - 0x0172, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x72, 0x08, 0x57, 0x8F, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x20, 0x62, 0xD0, 0x04, 0x12, 0xAA, 0x7C, 0x71, 0x7F, 0x1A, 0xA9, 0xD0, 0xDD, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x08, 0x57, 0x8D, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x53, 0xE8, 0x20, 0x7C, 0x70, 0x77, 0xD0, 0xC4, 0x7C, 0x72, 0xB9, 0x3A, 0xFE, 0xB0, 0x08, 0x7C, 0x72, 0xC2, 0x3A, 0xFF, 0xA0, 0x96, 0x62, 0x15, 0xF1 - } - }, - { - 328, - 79, - 0x39, - 0x0173, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x73, 0xD0, 0x03, 0x51, 0xF4, 0x62, 0xD0, 0x03, 0x3A, 0xFC, 0xB0, 0x0D, 0x62, 0xD0, 0x03, 0x51, 0xF5, 0x62, 0xD0, 0x03, 0x3A, 0xFD, 0xA0, 0x7E, 0x62, 0xD0, 0x03, 0x51, 0xF6, 0x08, 0x51, 0xF7, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xFE, 0x08, 0x51, 0xFF, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x57, 0x96, 0x28, 0x20, 0x7C, 0x71, 0xD1, 0xC0, 0x27, 0x62, 0xD0, 0x03, 0x07, 0xD6 - } - }, - { - 329, - 79, - 0x39, - 0x0174, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x74, 0x51, 0xF4, 0x08, 0x51, 0xF5, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xFC, 0x08, 0x51, 0xFD, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x57, 0x97, 0x28, 0x20, 0x7C, 0x71, 0xD1, 0xD0, 0x32, 0x56, 0x01, 0x01, 0x62, 0xD0, 0x04, 0x55, 0xCD, 0x00, 0x7C, 0x70, 0x41, 0x62, 0xD0, 0x03, 0x50, 0x0D, 0x10, 0x08, 0x57, 0x9D, 0x28, 0x53, 0xBC, 0x18, 0x75, 0x09, 0x00, 0x28, 0xDC, 0x81 - } - }, - { - 330, - 79, - 0x39, - 0x0175, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x75, 0x53, 0xBD, 0x20, 0x50, 0x0D, 0x10, 0x08, 0x57, 0x9F, 0x28, 0x53, 0xBE, 0x18, 0x75, 0x09, 0x00, 0x28, 0x53, 0xBF, 0x20, 0x3D, 0x01, 0x00, 0xB0, 0x1C, 0x62, 0xD0, 0x04, 0x3C, 0xCD, 0x00, 0xB0, 0x07, 0x7C, 0x6F, 0x87, 0x56, 0x00, 0x20, 0x62, 0xD0, 0x04, 0x76, 0xCD, 0x3C, 0xCD, 0x01, 0xB0, 0x04, 0x7C, 0x71, 0x3A, 0x62, 0xD0, 0x04, 0x3C, 0xCC, 0x02, 0xB0, 0x2D, 0x62, 0xD0, 0x00, 0x50, 0xA9, 0x1C - } - }, - { - 331, - 79, - 0x39, - 0x0176, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x76, 0x0D, 0x10, 0x08, 0x57, 0x8B, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x20, 0x62, 0xD0, 0x04, 0x12, 0xAA, 0x7C, 0x71, 0x7F, 0x1A, 0xA9, 0xD0, 0x0F, 0x7C, 0x70, 0x62, 0x7C, 0x70, 0x77, 0xD0, 0x07, 0x56, 0x00, 0x40, 0x7C, 0x4B, 0x8F, 0x62, 0xD0, 0x03, 0x3C, 0xEE, 0x00, 0xB0, 0x06, 0x3C, 0xEF, 0x00, 0xA1, 0x26, 0x62, 0xD0, 0x04, 0x3C, 0xCC, 0x00, 0xB0, 0x42, 0x62, 0xD0, 0x04, 0x2A, 0x1F - } - }, - { - 332, - 79, - 0x39, - 0x0177, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x77, 0x3C, 0xCD, 0x01, 0xB0, 0x3A, 0x62, 0xD0, 0x03, 0x51, 0xEF, 0x62, 0xD0, 0x04, 0x12, 0xA8, 0x62, 0xD0, 0x03, 0x51, 0xEE, 0x62, 0xD0, 0x04, 0x1A, 0xA7, 0xD0, 0x0D, 0x7C, 0x72, 0x6F, 0x54, 0x03, 0x7C, 0x72, 0x7A, 0x54, 0x02, 0x80, 0x04, 0x7C, 0x70, 0x41, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x7C, 0x72, 0x0D, 0x20, 0x7C, 0x73, 0x4A, 0xD0, 0xEA, 0x7C, 0x4B, 0x8F, 0x80, 0xE5, 0x62, 0xD0, 0x5E, 0x88 - } - }, - { - 333, - 79, - 0x39, - 0x0178, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x78, 0x04, 0x3C, 0xCC, 0x01, 0xB0, 0xDD, 0x7C, 0x73, 0x35, 0xB0, 0xD8, 0x62, 0xD0, 0x03, 0x51, 0xEF, 0x62, 0xD0, 0x04, 0x12, 0xA8, 0x62, 0xD0, 0x03, 0x51, 0xEE, 0x62, 0xD0, 0x04, 0x1A, 0xA7, 0xD0, 0x0D, 0x7C, 0x72, 0x6F, 0x53, 0xEF, 0x7C, 0x72, 0x7A, 0x53, 0xEE, 0x80, 0x04, 0x7C, 0x70, 0x41, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x08, 0x57, 0x93, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x77, 0xBB - } - }, - { - 334, - 79, - 0x39, - 0x0179, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x79, 0x28, 0x20, 0x62, 0xD0, 0x03, 0x12, 0xEF, 0x7C, 0x70, 0xA1, 0x1A, 0xEE, 0xD0, 0x88, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x7C, 0x72, 0x0D, 0x53, 0xE8, 0x20, 0x62, 0xD0, 0x03, 0x51, 0xEF, 0x62, 0xD0, 0x00, 0x12, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0xEE, 0x62, 0xD0, 0x00, 0x1A, 0xE9, 0xD0, 0x66, 0x62, 0xD0, 0x03, 0x51, 0xF6, 0x08, 0x51, 0xF7, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xBC, 0x08, 0x51, 0x4F, 0x6C - } - }, - { - 335, - 79, - 0x39, - 0x017A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x7A, 0xBD, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x57, 0x95, 0x28, 0x20, 0x7C, 0x70, 0xBF, 0xD0, 0x2F, 0x62, 0xD0, 0x03, 0x51, 0xF4, 0x08, 0x51, 0xF5, 0x08, 0x62, 0xD0, 0x03, 0x51, 0xBE, 0x08, 0x51, 0xBF, 0x08, 0x7C, 0x4B, 0x61, 0x38, 0xFC, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x57, 0x95, 0x28, 0x20, 0x7C, 0x70, 0xBF, 0xD0, 0x09, 0x56, 0x00, 0x22, 0x7C, 0x79, 0xC1 - } - }, - { - 336, - 79, - 0x39, - 0x017B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x7B, 0x4B, 0x8F, 0x80, 0x1F, 0x7C, 0x6F, 0x87, 0x62, 0xD0, 0x04, 0x55, 0xCD, 0x01, 0x7C, 0x71, 0x3A, 0x56, 0x00, 0x20, 0x80, 0x0E, 0x7C, 0x4B, 0x8F, 0x80, 0x09, 0x7C, 0x73, 0x35, 0xB0, 0x04, 0x7C, 0x4B, 0x8F, 0x10, 0x50, 0x00, 0x5C, 0x7C, 0x1E, 0xE4, 0x20, 0x7C, 0x73, 0x43, 0x80, 0x53, 0x62, 0xD0, 0x04, 0x3C, 0xCC, 0x00, 0xB0, 0x04, 0x7C, 0x4A, 0xD9, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0x43, 0x56 - } - }, - { - 337, - 79, - 0x39, - 0x017C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x7C, 0xCC, 0x62, 0xD0, 0x01, 0x51, 0xE7, 0x08, 0x51, 0xE6, 0x62, 0xD0, 0x03, 0x53, 0xF6, 0x18, 0x53, 0xF7, 0x62, 0xD0, 0x01, 0x51, 0xE5, 0x08, 0x51, 0xE4, 0x62, 0xD0, 0x03, 0x53, 0xF4, 0x18, 0x53, 0xF5, 0x62, 0xD0, 0x01, 0x51, 0xEF, 0x08, 0x51, 0xEE, 0x62, 0xD0, 0x03, 0x53, 0xF2, 0x18, 0x53, 0xF3, 0x62, 0xD0, 0x01, 0x51, 0xED, 0x08, 0x51, 0xEC, 0x62, 0xD0, 0x03, 0x53, 0xF0, 0x18, 0x53, 0x03, 0xD7 - } - }, - { - 338, - 79, - 0x39, - 0x017D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x7D, 0xF1, 0x3D, 0x00, 0x40, 0xB0, 0x43, 0x7C, 0x72, 0xC2, 0x02, 0xF3, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x7C, 0x72, 0xB9, 0x0A, 0xF2, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x7C, 0x6D, 0xF3, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xA3, 0x18, 0x53, 0xA4, 0x62, 0xD0, 0x03, 0x51, 0xF5, 0x02, 0xF5, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0xF4, 0x0A, 0xF4, 0x62, 0xD0, 0x00, 0x9F, 0x10 - } - }, - { - 339, - 79, - 0x39, - 0x017E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x7E, 0x53, 0xE9, 0x7C, 0x6D, 0xF3, 0x7C, 0x71, 0xC3, 0x52, 0x00, 0x62, 0xD0, 0x00, 0x38, 0xFC, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x06, 0x62, 0xD0, 0x00, 0x3C, 0x0E, 0x00, 0xA0, 0x06, 0x3D, 0xFC, 0xFF, 0xB0, 0x09, 0x62, 0xD0, 0x04, 0x55, 0xE2, 0x01, 0x85, 0xED, 0x62, 0xD0, 0x04, 0x3C, 0xE1, 0x00, 0xA0, 0x06, 0x3C, 0xE1, 0xFF, 0xB0, 0x74, 0x56, 0x00, 0x00, 0x56, 0x00, 0x00, 0x80, 0x65, 0x62, 0xDB, 0x89 - } - }, - { - 340, - 79, - 0x39, - 0x017F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x7F, 0xD0, 0x00, 0x52, 0x00, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE0, 0x7C, 0x71, 0x08, 0x62, 0xD0, 0x04, 0x51, 0xE2, 0x62, 0xD0, 0x00, 0x3F, 0xE8, 0x52, 0x00, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE1, 0x7C, 0x71, 0x08, 0x7C, 0x72, 0x9A, 0x62, 0xD0, 0x04, 0x76, 0xE2, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xB8, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x7C, 0x6E, 0xAE, 0x06, 0xE6, 0x45, 0x5E - } - }, - { - 341, - 79, - 0x39, - 0x0180, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x80, 0xB0, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xB4, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x7C, 0x6E, 0xAE, 0x06, 0xE6, 0xEA, 0x0E, 0xE7, 0x00, 0x7C, 0x6D, 0xEA, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0x98, 0x85, 0x6D, 0x62, 0xD0, 0x04, 0x50, 0x03, 0x3A, 0xE1, 0xC0, 0x0A, 0x62, 0xD0, 0x00, 0x50, 0x03, 0x3A, 0x0E, 0xD4, 0xAD, 0x7C, 0x71, 0x93, 0xC2, 0xFD, 0xCF - } - }, - { - 342, - 79, - 0x39, - 0x0181, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x81, 0x0D, 0x7C, 0x6F, 0xC9, 0x80, 0x13, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xCC, 0x7C, 0x6F, 0x54, 0x50, 0xFF, 0x3F, 0xE8, 0x77, 0x00, 0x7C, 0x71, 0xB1, 0xCF, 0xEA, 0x56, 0x00, 0x00, 0x80, 0x51, 0x56, 0x02, 0x00, 0x80, 0x41, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x27, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x47, 0xE9, 0x0F, 0xA0, 0x29, 0x52, 0x02, 0x08, 0x95, 0x00 - } - }, - { - 343, - 79, - 0x39, - 0x0182, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x82, 0x52, 0x00, 0x08, 0x95, 0xA1, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x54, 0x03, 0x50, 0x0D, 0x10, 0x57, 0x85, 0x28, 0x20, 0x3B, 0x03, 0xC0, 0x0F, 0x52, 0x02, 0x08, 0x52, 0x00, 0x08, 0x95, 0x0D, 0x38, 0xFE, 0x77, 0x01, 0x80, 0x0C, 0x77, 0x02, 0x62, 0xD0, 0x04, 0x52, 0x02, 0x3A, 0xE1, 0xCF, 0xB8, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0xAC, 0x7C, 0x71, 0xE1, 0x3D, 0x00, 0x02, 0xA0, 0x06, 0x3D, 0xB2, 0x3B - } - }, - { - 344, - 79, - 0x39, - 0x0183, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x83, 0x00, 0x03, 0xB1, 0x09, 0x7C, 0x68, 0xBB, 0x52, 0x01, 0x08, 0x7C, 0x66, 0xDE, 0x52, 0x01, 0x08, 0x7C, 0x6A, 0x7F, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0x0E, 0x13, 0x01, 0x62, 0xD0, 0x00, 0x54, 0x00, 0x56, 0x02, 0x00, 0x80, 0xDF, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x27, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0x73, 0xBE - } - }, - { - 345, - 79, - 0x39, - 0x0184, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x84, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xCE, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x54, 0x04, 0x7C, 0x6F, 0x27, 0x06, 0xE8, 0xFD, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x54, 0x03, 0x7C, 0x71, 0x00, 0xCF, 0x77 - } - }, - { - 346, - 79, - 0x39, - 0x0185, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x85, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xC5, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x25, 0x24 - } - }, - { - 347, - 79, - 0x39, - 0x0186, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x86, 0x83, 0x54, 0x03, 0x52, 0x03, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE0, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x7C, 0x72, 0x31, 0x06, 0xE6, 0xD0, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x52, 0x03, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE1, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x7C, 0x6E, 0xE1, 0x52, 0x04, 0x7C, 0x6E, 0xB6, 0x06, 0xE6, 0xD5, 0x0E, 0xE7, 0x02, 0x7C, 0x6D, 0xEA, 0x51, 0xE8, 0x36, 0x47 - } - }, - { - 348, - 79, - 0x39, - 0x0187, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x87, 0x3F, 0xE6, 0x77, 0x02, 0x52, 0x02, 0x3B, 0x00, 0xCF, 0x1D, 0x83, 0x3A, 0x56, 0x00, 0x00, 0x80, 0x76, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x47, 0xE9, 0xF0, 0xA0, 0x5E, 0x56, 0x03, 0x00, 0x56, 0x04, 0xFF, 0x56, 0x02, 0x00, 0x80, 0x3B, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x27, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x02, 0xE0 - } - }, - { - 349, - 79, - 0x39, - 0x0188, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x88, 0x83, 0x53, 0xE9, 0x47, 0xE9, 0x0F, 0xA0, 0x23, 0x52, 0x02, 0x08, 0x52, 0x00, 0x08, 0x94, 0x16, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x54, 0x05, 0x3D, 0x03, 0x00, 0xB0, 0x06, 0x7C, 0x71, 0x4B, 0x80, 0x0A, 0x52, 0x05, 0x3B, 0x03, 0xD0, 0x04, 0x7C, 0x71, 0x4B, 0x77, 0x02, 0x62, 0xD0, 0x04, 0x52, 0x02, 0x3A, 0xE1, 0xCF, 0xBE, 0x3D, 0x04, 0xFF, 0xA0, 0x0B, 0x52, 0x04, 0x08, 0x52, 0x00, 0x08, 0x89, 0xEF - } - }, - { - 350, - 79, - 0x39, - 0x0189, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x89, 0x93, 0x6A, 0x38, 0xFE, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0x87, 0x82, 0xB9, 0x7C, 0x6F, 0xC9, 0x80, 0x13, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xCC, 0x7C, 0x6F, 0x54, 0x50, 0xFF, 0x3F, 0xE8, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0xEA, 0x56, 0x00, 0x00, 0x80, 0x51, 0x56, 0x02, 0x00, 0x80, 0x41, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x27, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0xED, 0xB8 - } - }, - { - 351, - 79, - 0x39, - 0x018A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x8A, 0x6D, 0x83, 0x53, 0xE9, 0x47, 0xE9, 0xF0, 0xA0, 0x29, 0x52, 0x00, 0x08, 0x52, 0x02, 0x08, 0x93, 0x95, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x54, 0x03, 0x50, 0x0D, 0x10, 0x57, 0x85, 0x28, 0x20, 0x3B, 0x03, 0xC0, 0x0F, 0x52, 0x00, 0x08, 0x52, 0x02, 0x08, 0x93, 0x01, 0x38, 0xFE, 0x77, 0x01, 0x80, 0x0C, 0x77, 0x02, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x3A, 0x0E, 0xCF, 0xB8, 0x77, 0x00, 0x7C, 0x71, 0x06, 0xEB - } - }, - { - 352, - 79, - 0x39, - 0x018B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x8B, 0xB1, 0xCF, 0xAC, 0x7C, 0x71, 0xE1, 0x50, 0x00, 0x3B, 0x00, 0xC0, 0x06, 0x3D, 0x00, 0x04, 0xD1, 0x24, 0x62, 0xD0, 0x00, 0x51, 0x0E, 0x13, 0x01, 0x62, 0xD0, 0x00, 0x39, 0x04, 0xD1, 0x16, 0x7C, 0x68, 0xBB, 0x52, 0x01, 0x08, 0x93, 0xF7, 0x52, 0x01, 0x08, 0x7C, 0x6B, 0x94, 0x38, 0xFE, 0x56, 0x02, 0x00, 0x80, 0xF9, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x27, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x9B, 0x16 - } - }, - { - 353, - 79, - 0x39, - 0x018C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x8C, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xC5, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x54, 0x04, 0x7C, 0x6F, 0x27, 0x98, 0x11 - } - }, - { - 354, - 79, - 0x39, - 0x018D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x8D, 0x06, 0xE8, 0xFD, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x54, 0x03, 0x7C, 0x6F, 0x44, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x7A, 0xE8, 0x53, 0xE7, 0x26, 0xE7, 0xF0, 0x7C, 0x6F, 0xD0, 0x7C, 0x71, 0x00, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xE5, 0xAC - } - }, - { - 355, - 79, - 0x39, - 0x018E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x8E, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xCE, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x54, 0x03, 0x52, 0x04, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE0, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x52, 0x03, 0x53, 0xE6, 0x55, 0xE7, 0x00, 0x06, 0xE6, 0x47, 0x71 - } - }, - { - 356, - 79, - 0x39, - 0x018F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x8F, 0xD0, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x52, 0x04, 0x7C, 0x6D, 0x8A, 0x06, 0xE8, 0xE1, 0x0E, 0xE9, 0x01, 0x7C, 0x6D, 0x83, 0x7C, 0x6E, 0xE1, 0x52, 0x03, 0x7C, 0x6E, 0xB6, 0x06, 0xE6, 0xD5, 0x0E, 0xE7, 0x02, 0x7C, 0x6D, 0xEA, 0x51, 0xE8, 0x3F, 0xE6, 0x77, 0x02, 0x52, 0x02, 0x3B, 0x00, 0xCF, 0x03, 0x80, 0x80, 0x56, 0x00, 0x00, 0x80, 0x76, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0x2C, 0x3C - } - }, - { - 357, - 79, - 0x39, - 0x0190, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x90, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x47, 0xE9, 0x0F, 0xA0, 0x5E, 0x56, 0x03, 0x00, 0x56, 0x04, 0xFF, 0x56, 0x02, 0x00, 0x80, 0x3B, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x27, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x47, 0xE9, 0xF0, 0xA0, 0x23, 0x52, 0x00, 0x08, 0x52, 0x02, 0x08, 0x91, 0xEE, 0x38, 0xFE, 0x62, 0xD0, 0x00, 0x54, 0x05, 0x3D, 0x0E, 0x01 - } - }, - { - 358, - 79, - 0x39, - 0x0191, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x91, 0x03, 0x00, 0xB0, 0x06, 0x7C, 0x71, 0x4B, 0x80, 0x0A, 0x52, 0x05, 0x3B, 0x03, 0xD0, 0x04, 0x7C, 0x71, 0x4B, 0x77, 0x02, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x3A, 0x0E, 0xCF, 0xBE, 0x3D, 0x04, 0xFF, 0xA0, 0x0B, 0x52, 0x00, 0x08, 0x52, 0x04, 0x08, 0x91, 0x42, 0x38, 0xFE, 0x77, 0x00, 0x7C, 0x71, 0xB1, 0xCF, 0x87, 0x7C, 0x71, 0x93, 0xD0, 0x8E, 0x7C, 0x72, 0xDD, 0x12, 0xE1, 0x62, 0xD0, 0x00, 0xD5, 0x90 - } - }, - { - 359, - 79, - 0x39, - 0x0192, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x92, 0x54, 0x00, 0x56, 0x02, 0x00, 0x80, 0x57, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x27, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x26, 0xE9, 0xF0, 0x3C, 0xE9, 0xF0, 0xB0, 0x35, 0x7C, 0x6F, 0x27, 0x06, 0xE8, 0xD0, 0x7C, 0x6F, 0x54, 0x62, 0xD0, 0x04, 0x51, 0xE2, 0x62, 0xD0, 0x00, 0x3F, 0xE8, 0x52, 0x02, 0x7C, 0x6D, 0xD9, 0x06, 0xE8, 0xD5, 0x7C, 0x6F, 0xE2, 0x7C, 0x72, 0x81, 0xE9 - } - }, - { - 360, - 79, - 0x39, - 0x0193, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x93, 0x9A, 0x62, 0xD0, 0x04, 0x51, 0xE2, 0x08, 0x91, 0xCC, 0x38, 0xFF, 0x62, 0xD0, 0x04, 0x53, 0xE2, 0x7B, 0x00, 0x80, 0x08, 0x3D, 0x00, 0x00, 0xB0, 0x03, 0x80, 0x2B, 0x77, 0x02, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x3A, 0x0E, 0xCF, 0xA2, 0x80, 0x1E, 0x50, 0x00, 0x08, 0x91, 0xF1, 0x38, 0xFF, 0x7C, 0x71, 0x93, 0xC0, 0x0A, 0x50, 0x00, 0x08, 0x95, 0x86, 0x38, 0xFF, 0x80, 0x09, 0x50, 0x00, 0x08, 0xE4, 0xB0 - } - }, - { - 361, - 79, - 0x39, - 0x0194, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x94, 0x7C, 0x6B, 0x94, 0x38, 0xFF, 0x56, 0x00, 0x00, 0x80, 0x88, 0x62, 0xD0, 0x00, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xD0, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x7C, 0x6E, 0xAE, 0x65, 0xE6, 0x6B, 0xE7, 0x7C, 0x70, 0x1E, 0x06, 0xE6, 0xE0, 0x0E, 0xE7, 0x01, 0x7C, 0x6D, 0xEA, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xB8, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x7C, 0x6E, 0xAE, 0x06, 0x78, 0xD9 - } - }, - { - 362, - 79, - 0x39, - 0x0195, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x95, 0xE6, 0xB0, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x7C, 0x6D, 0xA5, 0x06, 0xE8, 0xB4, 0x0E, 0xE9, 0x03, 0x7C, 0x6D, 0x83, 0x53, 0xE9, 0x7C, 0x6E, 0xAE, 0x06, 0xE6, 0xEA, 0x0E, 0xE7, 0x00, 0x7C, 0x6D, 0xEA, 0x7C, 0x6D, 0xA5, 0x65, 0xE8, 0x6B, 0xE9, 0x06, 0xE8, 0xD5, 0x0E, 0xE9, 0x02, 0x7C, 0x6D, 0x83, 0x7C, 0x6E, 0xE1, 0x7C, 0x73, 0x3C, 0x7C, 0x6E, 0xAE, 0x65, 0xE6, 0x6B, 0xE7, 0x7C, 0x67, 0xB8 - } - }, - { - 363, - 79, - 0x39, - 0x0196, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x96, 0x70, 0x1E, 0x06, 0xE6, 0xE1, 0x0E, 0xE7, 0x01, 0x7C, 0x6D, 0xEA, 0x51, 0xE8, 0x3F, 0xE6, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0x75, 0x3D, 0xFC, 0xFF, 0xA0, 0x08, 0x7C, 0x72, 0xDD, 0x53, 0xE1, 0x80, 0x07, 0x62, 0xD0, 0x04, 0x55, 0xE1, 0xFF, 0x38, 0xFA, 0x20, 0x7F, 0x10, 0x4F, 0x62, 0xD0, 0x00, 0x52, 0xFB, 0x97, 0xD5, 0x40, 0x06, 0xE8, 0xE0, 0x0E, 0xE9, 0x01, 0x97, 0xC5, 0x40, 0x53, 0xCA, 0x7F - } - }, - { - 364, - 79, - 0x39, - 0x0197, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x97, 0xE9, 0x52, 0xFC, 0x53, 0xE6, 0x55, 0xE7, 0x00, 0x06, 0xE6, 0xD0, 0x0E, 0xE7, 0x03, 0x7C, 0x6D, 0xEA, 0x52, 0xFB, 0x97, 0xB5, 0x40, 0x06, 0xE8, 0xE1, 0x0E, 0xE9, 0x01, 0x97, 0xA5, 0x40, 0x7C, 0x6E, 0xE1, 0x52, 0xFC, 0x7C, 0x6E, 0xB6, 0x06, 0xE6, 0xD5, 0x0E, 0xE7, 0x02, 0x97, 0xFB, 0x40, 0x51, 0xE8, 0x3F, 0xE6, 0x7C, 0x70, 0xF0, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x97, 0x84, 0x40, 0xDB, 0xA2 - } - }, - { - 365, - 79, - 0x39, - 0x0198, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x98, 0x7A, 0xE8, 0x53, 0xE7, 0x26, 0xE7, 0xF0, 0x7C, 0x6F, 0xD0, 0x52, 0xFC, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x97, 0x6A, 0x40, 0x7A, 0xE8, 0x53, 0xE7, 0x26, 0xE7, 0x0F, 0x7C, 0x6F, 0xD0, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x03, 0x7C, 0x6F, 0xB9, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0xB8, 0x0E, 0xE9, 0x03, 0x97, 0x4B, 0x40, 0x54, 0x00, 0x7C, 0x70, 0xF0, 0x06, 0xE8, 0x7E, 0xE9 - } - }, - { - 366, - 79, - 0x39, - 0x0199, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x99, 0xB0, 0x0E, 0xE9, 0x03, 0x97, 0x3D, 0x40, 0x54, 0x01, 0x52, 0x00, 0x3B, 0x01, 0xD0, 0x08, 0x7C, 0x73, 0x06, 0x54, 0x02, 0x80, 0x06, 0x7C, 0x72, 0xFE, 0x54, 0x02, 0x7C, 0x6F, 0xB9, 0x55, 0xE9, 0x00, 0x06, 0xE8, 0xB4, 0x0E, 0xE9, 0x03, 0x97, 0x1A, 0x40, 0x54, 0x00, 0x7C, 0x70, 0xF0, 0x06, 0xE8, 0xEA, 0x0E, 0xE9, 0x00, 0x97, 0x0C, 0x40, 0x54, 0x01, 0x52, 0x00, 0x3B, 0x01, 0xD0, 0x08, 0x98, 0x1E - } - }, - { - 367, - 79, - 0x39, - 0x019A, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x9A, 0x7C, 0x73, 0x06, 0x05, 0x02, 0x80, 0x06, 0x7C, 0x72, 0xFE, 0x05, 0x02, 0x52, 0x02, 0x62, 0xD0, 0x00, 0x38, 0xFD, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x77, 0xFC, 0xB0, 0x03, 0x77, 0xFC, 0x50, 0x0F, 0x3B, 0xFC, 0xD0, 0x04, 0x56, 0xFC, 0x01, 0x52, 0xFC, 0x54, 0x01, 0x56, 0x00, 0x00, 0x80, 0x1A, 0x62, 0xD0, 0x00, 0x52, 0x00, 0x96, 0xD2, 0x40, 0x06, 0xE8, 0xE0, 0x0E, 0xE9, 0x01, 0x96, 0xD9, 0xA1 - } - }, - { - 368, - 79, - 0x39, - 0x019B, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x9B, 0xC2, 0x40, 0x3B, 0xFC, 0xB0, 0x03, 0x77, 0xFC, 0x77, 0x00, 0x7C, 0x6F, 0xC1, 0xCF, 0xE3, 0x52, 0xFC, 0x3B, 0x01, 0xBF, 0xD4, 0x52, 0xFC, 0x62, 0xD0, 0x00, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x0B, 0x3D, 0xFC, 0x00, 0xB0, 0x11, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x54, 0x03, 0x62, 0xD0, 0x00, 0x51, 0x0E, 0x54, 0x02, 0x80, 0x0D, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x13, 0xFC, 0x54, 0x03, 0x43, 0x76 - } - }, - { - 369, - 79, - 0x39, - 0x019C, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x9C, 0x7C, 0x70, 0xDB, 0x56, 0x00, 0x00, 0x56, 0x01, 0x00, 0x81, 0xA7, 0x56, 0x04, 0x00, 0x81, 0x97, 0x3D, 0xFC, 0x00, 0xB0, 0x22, 0x62, 0xD0, 0x00, 0x7C, 0x6F, 0x44, 0x06, 0xE8, 0xB8, 0x0E, 0xE9, 0x03, 0x96, 0x60, 0x40, 0x54, 0x05, 0x96, 0x7D, 0x40, 0x06, 0xE8, 0xB0, 0x0E, 0xE9, 0x03, 0x96, 0x52, 0x40, 0x54, 0x06, 0x80, 0x54, 0x62, 0xD0, 0x00, 0x52, 0x04, 0x96, 0xBD, 0x40, 0x96, 0x43, 0xDE, 0xAD - } - }, - { - 370, - 79, - 0x39, - 0x019D, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x9D, 0x40, 0x54, 0x05, 0x96, 0x60, 0x40, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0x4D, 0x8C - } - }, - { - 371, - 79, - 0x39, - 0x019E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x9E, 0xC3, 0x0E, 0xE9, 0x02, 0x95, 0xFD, 0x40, 0x54, 0x06, 0x52, 0x05, 0x3B, 0x06, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x52, 0x06, 0x13, 0x05, 0x54, 0x07, 0x80, 0x0A, 0x62, 0xD0, 0x00, 0x52, 0x05, 0x13, 0x06, 0x54, 0x07, 0x3D, 0xFC, 0x00, 0xB0, 0x22, 0x62, 0xD0, 0x00, 0x97, 0x97, 0x40, 0x06, 0xE8, 0xB4, 0x0E, 0xE9, 0x03, 0x95, 0xCD, 0x40, 0x54, 0x05, 0x95, 0xEA, 0x40, 0x06, 0xE8, 0xEA, 0x0E, 0xC7, 0x81 - } - }, - { - 372, - 79, - 0x39, - 0x019F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0x9F, 0xE9, 0x00, 0x95, 0xBF, 0x40, 0x54, 0x06, 0x80, 0x54, 0x62, 0xD0, 0x00, 0x52, 0x04, 0x96, 0x6E, 0x40, 0x95, 0xB0, 0x40, 0x54, 0x05, 0x95, 0xCD, 0x40, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0B, 0x0A - } - }, - { - 373, - 79, - 0x39, - 0x01A0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA0, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xC4, 0x0E, 0xE9, 0x02, 0x95, 0x6A, 0x40, 0x54, 0x06, 0x52, 0x05, 0x3B, 0x06, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x52, 0x06, 0x13, 0x05, 0x54, 0x08, 0x80, 0x0A, 0x62, 0xD0, 0x00, 0x52, 0x05, 0x13, 0x06, 0x54, 0x08, 0x62, 0xD0, 0x00, 0x52, 0x07, 0x53, 0xE8, 0x50, 0x00, 0x08, 0xD8, 0xA5 - } - }, - { - 374, - 79, - 0x39, - 0x01A1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA1, 0x51, 0xE8, 0x08, 0x52, 0x07, 0x08, 0x95, 0x13, 0x7C, 0x71, 0xF5, 0x52, 0x08, 0x53, 0xE6, 0x50, 0x00, 0x08, 0x51, 0xE6, 0x08, 0x52, 0x08, 0x08, 0x95, 0x01, 0x38, 0xFA, 0x62, 0xD0, 0x00, 0x52, 0x0A, 0x02, 0xE8, 0x62, 0xD0, 0x03, 0x53, 0xDF, 0x52, 0x09, 0x62, 0xD0, 0x00, 0x0A, 0xE9, 0x62, 0xD0, 0x03, 0x53, 0xDE, 0x62, 0xD0, 0x00, 0x96, 0xCB, 0x40, 0x52, 0x01, 0x02, 0xE8, 0x53, 0xE8, 0x90, 0x16 - } - }, - { - 375, - 79, - 0x39, - 0x01A2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA2, 0x50, 0x00, 0x0A, 0xE9, 0x53, 0xE9, 0x65, 0xE8, 0x6B, 0xE9, 0x06, 0xE8, 0xB1, 0x97, 0x53, 0x40, 0x62, 0xD0, 0x03, 0x51, 0xDE, 0x62, 0xD0, 0x00, 0x3F, 0xE8, 0x62, 0xD0, 0x03, 0x51, 0xDF, 0x62, 0xD0, 0x00, 0x3F, 0xE8, 0x77, 0x04, 0x52, 0x04, 0x3B, 0x02, 0xCE, 0x65, 0x77, 0x00, 0x07, 0x01, 0x03, 0x52, 0x00, 0x3B, 0x03, 0xCE, 0x55, 0x38, 0xF5, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x97, 0xD6, 0xA3 - } - }, - { - 376, - 79, - 0x39, - 0x01A3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA3, 0x08, 0x40, 0x80, 0x95, 0x62, 0xD0, 0x00, 0x94, 0xDC, 0x40, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x94, 0xB1, 0x40, 0x53, 0xE9, 0x47, 0xE9, 0xF0, 0xA0, 0x7D, 0x52, 0x01, 0x95, 0x1C, 0x40, 0x95, 0xCD, 0x40, 0x06, 0xE6, 0xB8, 0x0E, 0xE7, 0x03, 0x51, 0xE7, 0x60, 0xD4, 0x3E, 0xE6, 0x53, 0xE7, 0x96, 0xDE, 0x40, 0x52, 0x01, 0x95, 0x47, 0x40, 0x95, 0xB4, 0x40, 0x06, 0xE6, 0xB4, 0x0E, 0xE7, 0x7E, 0xF4 - } - }, - { - 377, - 79, - 0x39, - 0x01A4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA4, 0x03, 0x51, 0xE7, 0x60, 0xD4, 0x3E, 0xE6, 0x53, 0xE7, 0x96, 0xC5, 0x40, 0x52, 0x01, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0xD5, 0xA3 - } - }, - { - 378, - 79, - 0x39, - 0x01A5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA5, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xCE, 0x0E, 0xE9, 0x02, 0x96, 0x86, 0x40, 0x77, 0x01, 0x77, 0x00, 0x96, 0x67, 0x40, 0xCF, 0x68, 0x96, 0x6A, 0x40, 0x81, 0x15, 0x62, 0xD0, 0x00, 0x94, 0x3E, 0x40, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x03, 0x94, 0x13, 0x40, 0x53, 0xE9, 0x47, 0xE9, 0x0F, 0xA0, 0xFD, 0x52, 0x01, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x55, 0x51, 0x9C - } - }, - { - 379, - 79, - 0x39, - 0x01A6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA6, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xC3, 0x0E, 0xE9, 0x02, 0x94, 0xEF, 0x40, 0xA8, 0x4B - } - }, - { - 380, - 79, - 0x39, - 0x01A7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA7, 0x06, 0xE6, 0xB0, 0x0E, 0xE7, 0x03, 0x51, 0xE7, 0x60, 0xD4, 0x3E, 0xE6, 0x53, 0xE7, 0x96, 0x00, 0x40, 0x52, 0x01, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0x20, 0x3C - } - }, - { - 381, - 79, - 0x39, - 0x01A8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA8, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xC4, 0x0E, 0xE9, 0x02, 0x94, 0x96, 0x40, 0x06, 0xE6, 0xEA, 0x0E, 0xE7, 0x00, 0x51, 0xE7, 0x60, 0xD4, 0x3E, 0xE6, 0x53, 0xE7, 0x95, 0xA7, 0x40, 0x52, 0x01, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0x6A, 0xD1 - } - }, - { - 382, - 79, - 0x39, - 0x01A9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xA9, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xC5, 0x0E, 0xE9, 0x02, 0x95, 0x68, 0x40, 0x77, 0x01, 0x77, 0x00, 0x97, 0x39, 0x40, 0xCE, 0xE8, 0x38, 0xFE, 0x20, 0x7F, 0x10, 0x0B, 0x14 - } - }, - { - 383, - 79, - 0x39, - 0x01AA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xAA, 0x4F, 0x38, 0x07, 0x3D, 0xFC, 0x00, 0xB0, 0x11, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x54, 0x05, 0x62, 0xD0, 0x00, 0x51, 0x0E, 0x54, 0x02, 0x80, 0x0D, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x13, 0xFC, 0x54, 0x05, 0x96, 0x38, 0x40, 0x62, 0xD0, 0x00, 0x94, 0x6F, 0x40, 0x06, 0xE8, 0x5E, 0x0E, 0xE9, 0x0F, 0x94, 0xAA, 0x40, 0x54, 0x04, 0x56, 0x03, 0x00, 0x56, 0x01, 0x00, 0x97, 0xE4, 0x40, 0x80, 0xCB, 0xEE, 0xDB - } - }, - { - 384, - 79, - 0x39, - 0x01AB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xAB, 0x62, 0xD0, 0x03, 0x55, 0xDF, 0x00, 0x55, 0xDE, 0x00, 0x56, 0x06, 0x00, 0x80, 0x34, 0x96, 0xCE, 0x40, 0x52, 0x01, 0x94, 0x2B, 0x40, 0x10, 0x57, 0x03, 0x7C, 0x4A, 0xBC, 0x20, 0x03, 0x06, 0x54, 0x00, 0x92, 0xC2, 0x40, 0x65, 0xE8, 0x6B, 0xE9, 0x06, 0xE8, 0xB1, 0x0E, 0xE9, 0x02, 0x92, 0x93, 0x40, 0x53, 0xE9, 0x3E, 0xE8, 0x62, 0xD0, 0x03, 0x04, 0xDF, 0x95, 0xA5, 0x40, 0x0C, 0xDE, 0x77, 0x92, 0x24 - } - }, - { - 385, - 79, - 0x39, - 0x01AC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xAC, 0x06, 0x52, 0x06, 0x3B, 0x02, 0xCF, 0xC8, 0x95, 0x83, 0x40, 0xD0, 0x7A, 0x62, 0xD0, 0x03, 0x51, 0xDF, 0x08, 0x51, 0xDE, 0x62, 0xD0, 0x04, 0x53, 0xB1, 0x18, 0x53, 0xB2, 0x56, 0x06, 0x00, 0x80, 0x5F, 0x96, 0x7B, 0x40, 0x52, 0x01, 0x93, 0xD8, 0x40, 0x54, 0x00, 0x3D, 0xFC, 0x00, 0xB0, 0x42, 0x52, 0x00, 0x92, 0x56, 0x40, 0x06, 0xE8, 0xE0, 0x0E, 0xE9, 0x01, 0x92, 0x46, 0x40, 0x53, 0xE9, 0x64, 0xC9 - } - }, - { - 386, - 79, - 0x39, - 0x01AD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xAD, 0x96, 0x67, 0x40, 0x06, 0xE6, 0xD0, 0x0E, 0xE7, 0x03, 0x92, 0x9F, 0x40, 0x52, 0x00, 0x92, 0x3A, 0x40, 0x06, 0xE8, 0xE1, 0x0E, 0xE9, 0x01, 0x92, 0x2A, 0x40, 0x93, 0x85, 0x40, 0x52, 0x06, 0x93, 0x55, 0x40, 0x06, 0xE6, 0xD5, 0x0E, 0xE7, 0x02, 0x92, 0x80, 0x40, 0x51, 0xE8, 0x3F, 0xE6, 0x80, 0x0D, 0x96, 0x2B, 0x40, 0x06, 0xE8, 0xFD, 0x0E, 0xE9, 0x02, 0x94, 0x5D, 0x40, 0x77, 0x06, 0x52, 0x35, 0x6C - } - }, - { - 387, - 79, - 0x39, - 0x01AE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xAE, 0x06, 0x3B, 0x02, 0xCF, 0x9D, 0x77, 0x03, 0x07, 0x01, 0x03, 0x52, 0x03, 0x3B, 0x04, 0xCF, 0x31, 0x38, 0xF9, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x07, 0x3D, 0xFC, 0x00, 0xB0, 0x11, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x54, 0x01, 0x62, 0xD0, 0x00, 0x51, 0x0E, 0x54, 0x02, 0x80, 0x0D, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x13, 0xFC, 0x54, 0x01, 0x95, 0x23, 0x40, 0x62, 0xD0, 0x00, 0x93, 0x69, 0x40, 0x06, 0x99, 0x35 - } - }, - { - 388, - 79, - 0x39, - 0x01AF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xAF, 0xE8, 0x5E, 0x0E, 0xE9, 0x0F, 0x93, 0x95, 0x40, 0x54, 0x04, 0x56, 0x03, 0x00, 0x56, 0x00, 0x00, 0x96, 0xCF, 0x40, 0x81, 0x6E, 0x62, 0xD0, 0x03, 0x55, 0xDF, 0x00, 0x55, 0xDE, 0x00, 0x56, 0x05, 0x00, 0x80, 0x39, 0x62, 0xD0, 0x00, 0x93, 0x30, 0x40, 0x52, 0x00, 0x93, 0x13, 0x40, 0x53, 0xE9, 0x10, 0x52, 0x05, 0x57, 0x03, 0x7C, 0x4A, 0xBC, 0x20, 0x02, 0xE9, 0x54, 0x06, 0x52, 0x06, 0x91, 0x39, 0x76 - } - }, - { - 389, - 79, - 0x39, - 0x01B0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB0, 0xD8, 0x40, 0x06, 0xE8, 0xB1, 0x0E, 0xE9, 0x02, 0x91, 0x79, 0x40, 0x53, 0xE9, 0x3E, 0xE8, 0x62, 0xD0, 0x03, 0x04, 0xDF, 0x94, 0x8B, 0x40, 0x0C, 0xDE, 0x77, 0x05, 0x52, 0x05, 0x3B, 0x01, 0xCF, 0xC3, 0x94, 0x69, 0x40, 0xD1, 0x18, 0x62, 0xD0, 0x03, 0x51, 0xDF, 0x08, 0x51, 0xDE, 0x62, 0xD0, 0x04, 0x53, 0xB1, 0x18, 0x53, 0xB2, 0x56, 0x05, 0x00, 0x80, 0x2A, 0x3D, 0xFC, 0x00, 0xB0, 0x13, 0x78, 0xF5 - } - }, - { - 390, - 79, - 0x39, - 0x01B1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB1, 0x62, 0xD0, 0x00, 0x92, 0xD3, 0x40, 0x06, 0xE8, 0xD0, 0x93, 0x09, 0x40, 0x50, 0x00, 0x3F, 0xE8, 0x80, 0x11, 0x62, 0xD0, 0x00, 0x92, 0xC1, 0x40, 0x06, 0xE8, 0xFD, 0x93, 0x85, 0x40, 0x50, 0xFF, 0x3F, 0xE8, 0x77, 0x05, 0x52, 0x05, 0x3B, 0x02, 0xCF, 0xD2, 0x56, 0x05, 0x00, 0x80, 0x66, 0x62, 0xD0, 0x00, 0x92, 0xA4, 0x40, 0x52, 0x00, 0x92, 0x87, 0x40, 0x54, 0x06, 0x3D, 0xFC, 0x00, 0xB0, 0x7F, 0x04 - } - }, - { - 391, - 79, - 0x39, - 0x01B2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB2, 0x42, 0x52, 0x05, 0x91, 0x05, 0x40, 0x06, 0xE8, 0xE0, 0x0E, 0xE9, 0x01, 0x90, 0xF5, 0x40, 0x53, 0xE9, 0x95, 0x16, 0x40, 0x06, 0xE6, 0xD0, 0x0E, 0xE7, 0x03, 0x91, 0x4E, 0x40, 0x52, 0x05, 0x90, 0xE9, 0x40, 0x06, 0xE8, 0xE1, 0x0E, 0xE9, 0x01, 0x90, 0xD9, 0x40, 0x92, 0x34, 0x40, 0x52, 0x06, 0x92, 0x04, 0x40, 0x06, 0xE6, 0xD5, 0x0E, 0xE7, 0x02, 0x91, 0x2F, 0x40, 0x51, 0xE8, 0x3F, 0xE6, 0xBE, 0x83 - } - }, - { - 392, - 79, - 0x39, - 0x01B3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB3, 0x80, 0x11, 0x62, 0xD0, 0x00, 0x92, 0x51, 0x40, 0x06, 0xE8, 0xFD, 0x93, 0x15, 0x40, 0x52, 0x06, 0x3F, 0xE8, 0x77, 0x05, 0x52, 0x05, 0x3B, 0x01, 0xCF, 0x96, 0x3D, 0xFC, 0x00, 0xB0, 0x5F, 0x62, 0xD0, 0x04, 0x51, 0xE2, 0x62, 0xD0, 0x04, 0x53, 0xE3, 0x56, 0x05, 0x00, 0x80, 0x4A, 0x62, 0xD0, 0x00, 0x92, 0x25, 0x40, 0x06, 0xE8, 0xD0, 0x0E, 0xE9, 0x03, 0x90, 0x87, 0x40, 0x39, 0x00, 0xB0, 0x0F, 0x26 - } - }, - { - 393, - 79, - 0x39, - 0x01B4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB4, 0x35, 0x92, 0x15, 0x40, 0x06, 0xE8, 0xD0, 0x92, 0x4B, 0x40, 0x62, 0xD0, 0x04, 0x51, 0xE3, 0x62, 0xD0, 0x00, 0x3F, 0xE8, 0x62, 0xD0, 0x04, 0x51, 0xE3, 0x08, 0x7C, 0x66, 0x95, 0x38, 0xFF, 0x62, 0xD0, 0x04, 0x53, 0xE3, 0x62, 0xD0, 0x00, 0x52, 0x05, 0x90, 0xAE, 0x40, 0x06, 0xE8, 0xD5, 0x92, 0xB1, 0x40, 0x95, 0x66, 0x40, 0x77, 0x05, 0x52, 0x05, 0x3B, 0x02, 0xCF, 0xB2, 0x77, 0x03, 0x07, 0xE0, 0xC9 - } - }, - { - 394, - 79, - 0x39, - 0x01B5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB5, 0x00, 0x03, 0x52, 0x03, 0x3B, 0x04, 0xCE, 0x8E, 0x3D, 0xFC, 0x00, 0xB0, 0x0B, 0x62, 0xD0, 0x04, 0x51, 0xE3, 0x62, 0xD0, 0x04, 0x53, 0xE2, 0x38, 0xF9, 0x20, 0x7F, 0x10, 0x4F, 0x38, 0x02, 0x92, 0x68, 0x40, 0x48, 0xFC, 0x01, 0xA0, 0x09, 0x52, 0xFB, 0x05, 0x01, 0x52, 0xFA, 0x0D, 0x00, 0x66, 0xFB, 0x6C, 0xFA, 0x70, 0xFB, 0x6F, 0xFC, 0x3D, 0xFC, 0x00, 0xBF, 0xE7, 0x93, 0xB0, 0x40, 0x38, 0x30, 0x6A - } - }, - { - 395, - 79, - 0x39, - 0x01B6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB6, 0xFE, 0x20, 0x7F, 0x51, 0xE9, 0x60, 0xD4, 0x3E, 0xE8, 0x7F, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x65, 0xE8, 0x6B, 0xE9, 0x65, 0xE8, 0x6B, 0xE9, 0x65, 0xE8, 0x6B, 0xE9, 0x7F, 0x65, 0xE8, 0x6B, 0xE9, 0x65, 0xE8, 0x6B, 0xE9, 0x7F, 0x52, 0x00, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x70, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x70, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x70, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x70, 0x4E, 0xA7 - } - }, - { - 396, - 79, - 0x39, - 0x01B7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB7, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x7F, 0x70, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x70, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x70, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x7F, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x65, 0xE8, 0x6B, 0xE9, 0x7F, 0x60, 0xD4, 0x3E, 0xE8, 0x53, 0xE9, 0x7F, 0x51, 0xE7, 0x60, 0xD5, 0x51, 0xE9, 0x3F, 0xE6, 0x7F, 0x70, 0xFB, 0x6E, 0xE9, 0x6E, 0xE8, 0x7F, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x55, 0x4C, 0xA4 - } - }, - { - 397, - 79, - 0x39, - 0x01B8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB8, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xCC, 0x0E, 0xE9, 0x02, 0x7F, 0x53, 0xE8, 0xA8, 0x5D - } - }, - { - 398, - 79, - 0x39, - 0x01B9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xB9, 0x55, 0xE9, 0x00, 0x55, 0xE6, 0x03, 0x55, 0xE7, 0x00, 0x55, 0xE1, 0x00, 0x55, 0xE0, 0x00, 0x3C, 0xE7, 0x00, 0xB0, 0x06, 0x3C, 0xE6, 0x00, 0xA0, 0x1A, 0x70, 0xFB, 0x6E, 0xE7, 0x6E, 0xE6, 0xD0, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x04, 0xE1, 0x51, 0xE9, 0x0C, 0xE0, 0x65, 0xE8, 0x6B, 0xE9, 0x8F, 0xDE, 0x5F, 0xE8, 0xE1, 0x5F, 0xE9, 0xE0, 0x62, 0xD0, 0x00, 0x06, 0xE8, 0xCD, 0x0E, 0xE9, 0x80, 0x0E - } - }, - { - 399, - 79, - 0x39, - 0x01BA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xBA, 0x02, 0x7F, 0x62, 0xD0, 0x01, 0x51, 0xE7, 0x08, 0x51, 0xE6, 0x62, 0xD0, 0x03, 0x53, 0xEC, 0x18, 0x53, 0xED, 0x62, 0xD0, 0x01, 0x51, 0xE5, 0x08, 0x51, 0xE4, 0x62, 0xD0, 0x03, 0x53, 0xEA, 0x18, 0x53, 0xEB, 0x7F, 0x53, 0xE8, 0x52, 0x01, 0x09, 0x00, 0x60, 0xD4, 0x3E, 0xE8, 0x7F, 0x52, 0x00, 0x53, 0xE6, 0x55, 0xE7, 0x00, 0x7F, 0x53, 0xE6, 0x55, 0xE7, 0x00, 0x65, 0xE6, 0x6B, 0xE7, 0x7F, 0x2B, 0x65 - } - }, - { - 400, - 79, - 0x39, - 0x01BB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xBB, 0x62, 0xD0, 0x01, 0x51, 0xEF, 0x08, 0x51, 0xEE, 0x62, 0xD0, 0x03, 0x53, 0xE8, 0x18, 0x53, 0xE9, 0x62, 0xD0, 0x01, 0x51, 0xED, 0x08, 0x51, 0xEC, 0x62, 0xD0, 0x03, 0x53, 0xE6, 0x18, 0x53, 0xE7, 0x7F, 0x53, 0xE9, 0x3E, 0xE8, 0x53, 0xE8, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0xAF, 0x29, 0x01, 0x53, 0xAF, 0x51, 0xAF, 0x60, 0x04, 0x51, 0xAF, 0x29, 0x08, 0x53, 0xAF, 0x51, 0xAF, 0x60, 0x04, 0x7F, 0x67, 0xDE - } - }, - { - 401, - 79, - 0x39, - 0x01BC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xBC, 0x02, 0xE8, 0x53, 0xE8, 0x50, 0x00, 0x0A, 0xE9, 0x53, 0xE9, 0x06, 0xE8, 0x62, 0x0E, 0xE9, 0x0F, 0x51, 0xE9, 0x10, 0x58, 0xE8, 0x28, 0x20, 0x7F, 0x52, 0x05, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x53, 0xAF, 0x51, 0xAF, 0x60, 0x04, 0x7F, 0x52, 0x02, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0x99, 0x21, 0x70, 0x54, 0x00, 0x3D, 0x00, 0x00, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0x11, 0x33 - } - }, - { - 402, - 79, - 0x39, - 0x01BD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xBD, 0x99, 0x21, 0x70, 0x7F, 0x52, 0x04, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x62, 0xD0, 0x00, 0x52, 0x02, 0x53, 0xE8, 0x7F, 0x0E, 0xE9, 0x03, 0x51, 0xE9, 0x60, 0xD5, 0x7F, 0x51, 0xE9, 0x10, 0x58, 0xE8, 0x28, 0x20, 0x7F, 0x62, 0xD0, 0x00, 0x26, 0xAF, 0xF7, 0x51, 0xAF, 0x60, 0x04, 0x26, 0xAF, 0xFE, 0x51, 0xAF, 0x60, 0x04, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x67, 0xE0 - } - }, - { - 403, - 79, - 0x39, - 0x01BE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xBE, 0x04, 0x53, 0x9D, 0x18, 0x53, 0x9E, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0xF7, 0x08, 0x51, 0xF6, 0x62, 0xD0, 0x03, 0x53, 0xBC, 0x18, 0x53, 0xBD, 0x62, 0xD0, 0x03, 0x51, 0xF5, 0x08, 0x51, 0xF4, 0x62, 0xD0, 0x03, 0x53, 0xBE, 0x18, 0x53, 0xBF, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0x9F, 0x18, 0x53, 0xA0, 0x7F, 0x62, 0xD0, 0x00, 0x52, 0xFC, 0x53, 0xE8, 0x85, 0x1D - } - }, - { - 404, - 79, - 0x39, - 0x01BF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xBF, 0x7F, 0x62, 0xD0, 0x00, 0x52, 0x00, 0x3A, 0x0E, 0x7F, 0x56, 0x01, 0x00, 0x56, 0x00, 0x00, 0x7F, 0x51, 0xE9, 0x60, 0xD5, 0x51, 0xE7, 0x3F, 0xE8, 0x7F, 0x51, 0xE9, 0x60, 0xD5, 0x52, 0x00, 0x3F, 0xE8, 0x7F, 0x0E, 0xE9, 0x02, 0x51, 0xE9, 0x60, 0xD5, 0x7F, 0x62, 0xD0, 0x03, 0x52, 0x01, 0x53, 0xE5, 0x52, 0x00, 0x53, 0xE4, 0x7F, 0x52, 0x02, 0x53, 0xE8, 0x52, 0x01, 0x60, 0xD4, 0x3E, 0xE8, 0x95, 0x3E - } - }, - { - 405, - 79, - 0x39, - 0x01C0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC0, 0x7F, 0x70, 0xFB, 0x6F, 0x01, 0x6F, 0x02, 0x70, 0xFB, 0x6F, 0x01, 0x6F, 0x02, 0x7F, 0x62, 0xD0, 0x00, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x65, 0xE8, 0x6B, 0xE9, 0x51, 0xE8, 0x7F, 0x65, 0xE6, 0x6B, 0xE7, 0x65, 0xE6, 0x6B, 0xE7, 0x7F, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xD4, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0x7F, 0x53, 0xE9, 0x62, 0xD0, 0x04, 0x51, 0xD9, 0x62, 0xD0, 0x00, 0x3A, 0xE9, 0x2E, 0x71 - } - }, - { - 406, - 79, - 0x39, - 0x01C1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC1, 0x7F, 0x62, 0xD0, 0x03, 0x55, 0xEF, 0x00, 0x55, 0xEE, 0x00, 0x7F, 0x56, 0x01, 0x00, 0x80, 0x03, 0x77, 0x01, 0x3D, 0x01, 0x0A, 0xCF, 0xFA, 0x62, 0xD0, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xCF, 0x01, 0x7F, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x08, 0x57, 0x89, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x53, 0xE8, 0x20, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xAA, 0x62, 0xD0, 0x00, 0x12, 0xA0, 0x56 - } - }, - { - 407, - 79, - 0x39, - 0x01C2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC2, 0xE8, 0x62, 0xD0, 0x04, 0x51, 0xA9, 0x62, 0xD0, 0x00, 0x1A, 0xE9, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0xDF, 0x62, 0xD0, 0x04, 0x12, 0xB2, 0x62, 0xD0, 0x03, 0x51, 0xDE, 0x62, 0xD0, 0x04, 0x1A, 0xB1, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0xE9, 0x62, 0xD0, 0x03, 0x7F, 0x70, 0xFE, 0x62, 0xD0, 0x03, 0x51, 0xD9, 0x08, 0x51, 0xD8, 0x62, 0xD0, 0x00, 0x53, 0x0A, 0x18, 0x53, 0x0B, 0x71, 0x01, 0x7F, 0x53, 0x76, 0x03 - } - }, - { - 408, - 79, - 0x39, - 0x01C3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC3, 0xE6, 0x55, 0xE7, 0x00, 0x51, 0xE8, 0x12, 0xE6, 0x51, 0xE9, 0x1A, 0xE7, 0x7F, 0x60, 0xD4, 0x3E, 0xE8, 0x54, 0x03, 0x7F, 0x70, 0xFB, 0x6F, 0x01, 0x6F, 0x02, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0x0E, 0x13, 0xFC, 0x62, 0xD0, 0x00, 0x54, 0x02, 0x7F, 0x70, 0xFE, 0x62, 0xD0, 0x00, 0x51, 0x0D, 0x7F, 0x52, 0xFB, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x5D, 0xC8, 0x62, 0xD0, 0x00, 0x39, 0x00, 0x7F, 0x80, 0x18 - } - }, - { - 409, - 79, - 0x39, - 0x01C4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC4, 0x52, 0x03, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x0E, 0xE9, 0x01, 0x51, 0xE9, 0x60, 0xD5, 0x7F, 0x71, 0x10, 0x5D, 0xE0, 0x54, 0x01, 0x41, 0xE0, 0xE7, 0x43, 0xE0, 0x18, 0x70, 0xCF, 0x62, 0xE3, 0x38, 0x7F, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xAD, 0x18, 0x53, 0xAE, 0x7F, 0x62, 0xD0, 0x00, 0x52, 0x01, 0x53, 0xE8, 0x52, 0x00, 0x53, 0xE9, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xA8, 0x08, 0xD8, 0xC9 - } - }, - { - 410, - 79, - 0x39, - 0x01C5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC5, 0x51, 0xA7, 0x62, 0xD0, 0x03, 0x53, 0xEE, 0x18, 0x53, 0xEF, 0x7F, 0x52, 0x05, 0x54, 0x03, 0x52, 0x02, 0x54, 0x04, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0x0D, 0x08, 0x51, 0x0C, 0x62, 0xD0, 0x03, 0x53, 0xD4, 0x18, 0x53, 0xD5, 0x7F, 0x5D, 0xD6, 0x53, 0xE9, 0x2E, 0xE9, 0xFE, 0x51, 0xE9, 0x54, 0x02, 0x43, 0xD6, 0x01, 0x52, 0xFC, 0x7F, 0x53, 0xE8, 0x52, 0xFB, 0x09, 0x00, 0x60, 0xD5, 0x7F, 0x62, 0xD2, 0xBE - } - }, - { - 411, - 79, - 0x39, - 0x01C6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC6, 0xD0, 0x00, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x7F, 0x62, 0xD0, 0x04, 0x53, 0xCE, 0x62, 0xD0, 0x04, 0x51, 0xE0, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x62, 0xD0, 0x00, 0x3A, 0x0E, 0x7F, 0x62, 0xD0, 0x00, 0x52, 0x06, 0x53, 0xE8, 0x55, 0xE9, 0x00, 0x7F, 0x52, 0x06, 0x53, 0xE6, 0x55, 0xE7, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x52, 0x00, 0x3A, 0xE1, 0x7F, 0x52, 0x02, 0x03, 0x02, 0x54, 0x00, 0x07, 0x01, 0x1D - } - }, - { - 412, - 79, - 0x39, - 0x01C7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC7, 0x00, 0x2E, 0x7F, 0x51, 0xE8, 0x08, 0x51, 0xE9, 0x62, 0xD0, 0x04, 0x53, 0xA1, 0x18, 0x53, 0xA2, 0x7F, 0x12, 0xE8, 0x50, 0x00, 0x1A, 0xE9, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0x9D, 0x62, 0xD0, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xE1, 0x13, 0x01, 0x62, 0xD0, 0x00, 0x54, 0x00, 0x7F, 0x55, 0xDC, 0x00, 0x62, 0xD0, 0x04, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x54, 0x0A, 0x51, 0xE9, 0x54, 0x09, 0x45, 0xA6 - } - }, - { - 413, - 79, - 0x39, - 0x01C8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC8, 0x7F, 0x08, 0x57, 0x98, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x7F, 0x08, 0x57, 0x91, 0x28, 0x53, 0xE9, 0x18, 0x75, 0x09, 0x00, 0x28, 0x7F, 0x62, 0xD0, 0x00, 0x55, 0x0B, 0x01, 0x55, 0x0A, 0x00, 0x71, 0x01, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0xE8, 0x54, 0x01, 0x51, 0xE9, 0x54, 0x00, 0x7F, 0x52, 0x04, 0x53, 0xE6, 0x55, 0xE7, 0x00, 0x7F, 0x50, 0x0D, 0x10, 0x57, 0x88, 0x28, 0x20, 0x36, 0x89 - } - }, - { - 414, - 79, - 0x39, - 0x01C9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xC9, 0x7F, 0x62, 0xD0, 0x04, 0x52, 0x00, 0x3A, 0xC0, 0x7F, 0x62, 0xD0, 0x00, 0x53, 0xE9, 0x51, 0xE8, 0x7F, 0x51, 0xAF, 0x60, 0x04, 0x62, 0xD0, 0x00, 0x7F, 0x52, 0xFC, 0x62, 0xD0, 0x04, 0x53, 0xD7, 0x56, 0xFC, 0x00, 0x7F, 0x62, 0xD0, 0x00, 0x50, 0x0D, 0x10, 0x57, 0x87, 0x28, 0x20, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xA8, 0x62, 0xD0, 0x03, 0x12, 0xEF, 0x7F, 0x62, 0xD0, 0x04, 0x51, 0xA7, 0x62, 0xF2, 0x02 - } - }, - { - 415, - 79, - 0x39, - 0x01CA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xCA, 0xD0, 0x03, 0x1A, 0xEE, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xD1, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xD6, 0x00, 0x7F, 0x62, 0xD0, 0x03, 0x47, 0x99, 0x70, 0x7F, 0x50, 0x00, 0x3F, 0xE8, 0x3F, 0xE8, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xB2, 0xFF, 0x55, 0xB1, 0xFF, 0x7F, 0x56, 0x01, 0x00, 0x56, 0x02, 0x00, 0x7F, 0x71, 0x10, 0x60, 0xE0, 0x70, 0xCF, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0xF6, 0x62, 0xD0, 0x51, 0xC1 - } - }, - { - 416, - 79, - 0x39, - 0x01CB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xCB, 0x03, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0xF7, 0x62, 0xD0, 0x03, 0x7F, 0x71, 0x10, 0x43, 0xD7, 0x20, 0x43, 0xE0, 0x40, 0x7F, 0x52, 0xFA, 0x13, 0xF6, 0x52, 0xF9, 0x1B, 0xF5, 0x7F, 0x62, 0xD0, 0x00, 0x51, 0x0E, 0x62, 0xD0, 0x04, 0x7F, 0x3F, 0xE8, 0x62, 0xD0, 0x04, 0x51, 0xB6, 0x7F, 0x50, 0x0D, 0x10, 0x57, 0x86, 0x28, 0x20, 0x7F, 0x50, 0x0D, 0x10, 0x57, 0x9A, 0x28, 0x20, 0x7F, 0x62, 0xD0, 0x10, 0x40 - } - }, - { - 417, - 79, - 0x39, - 0x01CC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xCC, 0x00, 0x52, 0x00, 0x13, 0x01, 0x7F, 0x62, 0xD0, 0x00, 0x52, 0x01, 0x13, 0x00, 0x7F, 0x50, 0x0D, 0x10, 0x57, 0x9B, 0x28, 0x20, 0x7F, 0x60, 0x0C, 0x62, 0xD0, 0x00, 0x51, 0xB2, 0x7F, 0x60, 0x08, 0x62, 0xD0, 0x00, 0x51, 0xB1, 0x7F, 0x62, 0xD0, 0x03, 0x51, 0x9B, 0x21, 0x0F, 0x7F, 0x62, 0xD0, 0x03, 0x47, 0x99, 0x04, 0x7F, 0x62, 0xD0, 0x04, 0x3C, 0xCD, 0x02, 0x7F, 0x06, 0xE8, 0x01, 0x0E, 0x82, 0x25 - } - }, - { - 418, - 79, - 0x39, - 0x01CD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xCD, 0xE9, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xCC, 0x00, 0x7F, 0x13, 0x03, 0x51, 0xE9, 0x1B, 0x02, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xD7, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xD9, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xD5, 0x00, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xDD, 0x01, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xCB, 0xF4, 0x7F, 0x62, 0xD0, 0x04, 0x55, 0xB4, 0x00, 0x7F, 0x41, 0xD7, 0xDF, 0x41, 0xE0, 0x54, 0xCA - } - }, - { - 419, - 79, - 0x39, - 0x01CE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xCE, 0xBF, 0x7F, 0x41, 0xE0, 0xEF, 0x62, 0xDA, 0xEF, 0x7F, 0x41, 0xE0, 0x7F, 0x62, 0xDA, 0x7F, 0x7F, 0x62, 0xD0, 0x00, 0x3C, 0xBA, 0x00, 0x7F, 0x00, 0xBF, 0x00, 0x20, 0x00, 0xEA, 0x00, 0x06, 0x01, 0x00, 0x00, 0xA0, 0x02, 0xB1, 0x00, 0x4F, 0x03, 0x99, 0x00, 0x47, 0x03, 0xE0, 0x01, 0x0D, 0x03, 0xE1, 0x00, 0x1F, 0x04, 0x99, 0x00, 0x49, 0x04, 0xE2, 0x02, 0x01, 0x00, 0xFF, 0x00, 0x30, 0x30, 0xF0, 0x03 - } - }, - { - 420, - 79, - 0x39, - 0x01CF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xCF, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x24 - } - }, - { - 421, - 79, - 0x39, - 0x01D0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x25 - } - }, - { - 422, - 79, - 0x39, - 0x01D1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD1, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x26 - } - }, - { - 423, - 79, - 0x39, - 0x01D2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD2, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x27 - } - }, - { - 424, - 79, - 0x39, - 0x01D3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD3, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x28 - } - }, - { - 425, - 79, - 0x39, - 0x01D4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD4, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x29 - } - }, - { - 426, - 79, - 0x39, - 0x01D5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD5, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x2A - } - }, - { - 427, - 79, - 0x39, - 0x01D6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD6, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x2B - } - }, - { - 428, - 79, - 0x39, - 0x01D7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD7, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x2C - } - }, - { - 429, - 79, - 0x39, - 0x01D8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD8, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x2D - } - }, - { - 430, - 79, - 0x39, - 0x01D9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xD9, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x2E - } - }, - { - 431, - 79, - 0x39, - 0x01DA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xDA, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x2F - } - }, - { - 432, - 79, - 0x39, - 0x01DB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xDB, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30 - } - }, - { - 433, - 79, - 0x39, - 0x01DC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xDC, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x31 - } - }, - { - 434, - 79, - 0x39, - 0x01DD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xDD, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x32 - } - }, - { - 435, - 79, - 0x39, - 0x01DE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xDE, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x33 - } - }, - { - 436, - 79, - 0x39, - 0x01DF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xDF, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x34 - } - }, - { - 437, - 79, - 0x39, - 0x01E0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x35 - } - }, - { - 438, - 79, - 0x39, - 0x01E1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE1, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x36 - } - }, - { - 439, - 79, - 0x39, - 0x01E2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE2, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x37 - } - }, - { - 440, - 79, - 0x39, - 0x01E3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE3, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x38 - } - }, - { - 441, - 79, - 0x39, - 0x01E4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE4, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x39 - } - }, - { - 442, - 79, - 0x39, - 0x01E5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE5, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3A - } - }, - { - 443, - 79, - 0x39, - 0x01E6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE6, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3B - } - }, - { - 444, - 79, - 0x39, - 0x01E7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE7, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3C - } - }, - { - 445, - 79, - 0x39, - 0x01E8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE8, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3D - } - }, - { - 446, - 79, - 0x39, - 0x01E9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xE9, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3E - } - }, - { - 447, - 79, - 0x39, - 0x01EA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xEA, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3F - } - }, - { - 448, - 79, - 0x39, - 0x01EB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xEB, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x40 - } - }, - { - 449, - 79, - 0x39, - 0x01EC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xEC, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x41 - } - }, - { - 450, - 79, - 0x39, - 0x01ED, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xED, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x42 - } - }, - { - 451, - 79, - 0x39, - 0x01EE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xEE, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x43 - } - }, - { - 452, - 79, - 0x39, - 0x01EF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xEF, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x44 - } - }, - { - 453, - 79, - 0x39, - 0x01F0, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x45 - } - }, - { - 454, - 79, - 0x39, - 0x01F1, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF1, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x46 - } - }, - { - 455, - 79, - 0x39, - 0x01F2, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF2, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x47 - } - }, - { - 456, - 79, - 0x39, - 0x01F3, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF3, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x48 - } - }, - { - 457, - 79, - 0x39, - 0x01F4, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF4, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x49 - } - }, - { - 458, - 79, - 0x39, - 0x01F5, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF5, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x4A - } - }, - { - 459, - 79, - 0x39, - 0x01F6, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF6, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x4B - } - }, - { - 460, - 79, - 0x39, - 0x01F7, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF7, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x4C - } - }, - { - 461, - 79, - 0x39, - 0x01F8, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF8, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x4D - } - }, - { - 462, - 79, - 0x39, - 0x01F9, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xF9, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x4E - } - }, - { - 463, - 79, - 0x39, - 0x01FA, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xFA, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x4F - } - }, - { - 464, - 79, - 0x39, - 0x01FB, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xFB, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x50 - } - }, - { - 465, - 79, - 0x39, - 0x01FC, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xFC, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x51 - } - }, - { - 466, - 79, - 0x39, - 0x01FD, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xFD, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x52 - } - }, - { - 467, - 79, - 0x39, - 0x01FE, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xFE, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x53 - } - }, - { - 468, - 79, - 0x39, - 0x01FF, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01, 0xFF, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x54 - } - }, - { - 469, - 79, - 0x39, - 0x001E, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x1E, 0x19, 0xE5, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x01, 0x0B, 0x10, 0x12, 0xA0, 0x02, 0x04, 0x00, 0xC0, 0xC1, 0xC2, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xA5, 0xBC - } - }, - { - 470, - 79, - 0x39, - 0x001F, - { - 0x00, 0xFF, 0x39, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x1F, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xA0, 0x07, 0x5F, 0xF8, 0x3E, 0xEF - } - }, - { - 471, - 11, - 0x3B, - -1, - { - 0x00, 0xFF, 0x3B, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 - } - }, -}; - -unsigned short cyttsp_fw_records = 472; - -unsigned char cyttsp_fw_tts_verh = 0x10; -unsigned char cyttsp_fw_tts_verl = 0x12; -unsigned char cyttsp_fw_app_idh = 0xA0; -unsigned char cyttsp_fw_app_idl = 0x02; -unsigned char cyttsp_fw_app_verh = 0x04; -unsigned char cyttsp_fw_app_verl = 0x00; -unsigned char cyttsp_fw_cid_0 = 0xC0; -unsigned char cyttsp_fw_cid_1 = 0xC1; -unsigned char cyttsp_fw_cid_2 = 0xC2; diff --git a/drivers/input/touchscreen/gt9xx/gt9xx_firmware.h b/drivers/input/touchscreen/gt9xx/gt9xx_firmware.h deleted file mode 100644 index 81e3affe62e906a6ae11845ece1bf00b5d31720c..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/gt9xx/gt9xx_firmware.h +++ /dev/null @@ -1,6 +0,0 @@ -/* - * make sense only when GTP_HEADER_FW_UPDATE & GTP_AUTO_UPDATE are enabled - * define your own firmware array here -*/ -const unsigned char header_fw_array[] = { -}; diff --git a/drivers/input/touchscreen/gt9xx/gt9xx_update.c b/drivers/input/touchscreen/gt9xx/gt9xx_update.c index 6d30f0cca4d0fe5d319532d707896d4c9f4442f2..d7ca2a8992d162eab9e9492ada4593384321c8d2 100644 --- a/drivers/input/touchscreen/gt9xx/gt9xx_update.c +++ b/drivers/input/touchscreen/gt9xx/gt9xx_update.c @@ -39,7 +39,6 @@ #if GTP_HEADER_FW_UPDATE #include #include -#include "gt9xx_firmware.h" #endif #define FIRMWARE_NAME_LEN_MAX 256 diff --git a/drivers/input/touchscreen/msm_touch.c b/drivers/input/touchscreen/msm_touch.c deleted file mode 100644 index be2993e86887cb3811121c8fef3a3ac5a9af9da8..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/msm_touch.c +++ /dev/null @@ -1,317 +0,0 @@ -/* drivers/input/touchscreen/msm_touch.c - * - * Copyright (c) 2008-2009, 2011, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include - -/* HW register map */ -#define TSSC_CTL_REG 0x100 -#define TSSC_SI_REG 0x108 -#define TSSC_OPN_REG 0x104 -#define TSSC_STATUS_REG 0x10C -#define TSSC_AVG12_REG 0x110 - -/* status bits */ -#define TSSC_STS_OPN_SHIFT 0x6 -#define TSSC_STS_OPN_BMSK 0x1C0 -#define TSSC_STS_NUMSAMP_SHFT 0x1 -#define TSSC_STS_NUMSAMP_BMSK 0x3E - -/* CTL bits */ -#define TSSC_CTL_EN (0x1 << 0) -#define TSSC_CTL_SW_RESET (0x1 << 2) -#define TSSC_CTL_MASTER_MODE (0x3 << 3) -#define TSSC_CTL_AVG_EN (0x1 << 5) -#define TSSC_CTL_DEB_EN (0x1 << 6) -#define TSSC_CTL_DEB_12_MS (0x2 << 7) /* 1.2 ms */ -#define TSSC_CTL_DEB_16_MS (0x3 << 7) /* 1.6 ms */ -#define TSSC_CTL_DEB_2_MS (0x4 << 7) /* 2 ms */ -#define TSSC_CTL_DEB_3_MS (0x5 << 7) /* 3 ms */ -#define TSSC_CTL_DEB_4_MS (0x6 << 7) /* 4 ms */ -#define TSSC_CTL_DEB_6_MS (0x7 << 7) /* 6 ms */ -#define TSSC_CTL_INTR_FLAG1 (0x1 << 10) -#define TSSC_CTL_DATA (0x1 << 11) -#define TSSC_CTL_SSBI_CTRL_EN (0x1 << 13) - -/* control reg's default state */ -#define TSSC_CTL_STATE ( \ - TSSC_CTL_DEB_12_MS | \ - TSSC_CTL_DEB_EN | \ - TSSC_CTL_AVG_EN | \ - TSSC_CTL_MASTER_MODE | \ - TSSC_CTL_EN) - -#define TSSC_NUMBER_OF_OPERATIONS 2 -#define TS_PENUP_TIMEOUT_MS 20 - -#define TS_DRIVER_NAME "msm_touchscreen" - -#define X_MAX 1024 -#define Y_MAX 1024 -#define P_MAX 256 - -struct ts { - struct input_dev *input; - struct timer_list timer; - int irq; - unsigned int x_max; - unsigned int y_max; -}; - -static void __iomem *virt; -#define TSSC_REG(reg) (virt + TSSC_##reg##_REG) - -static void ts_update_pen_state(struct ts *ts, int x, int y, int pressure) -{ - if (pressure) { - input_report_abs(ts->input, ABS_X, x); - input_report_abs(ts->input, ABS_Y, y); - input_report_abs(ts->input, ABS_PRESSURE, pressure); - input_report_key(ts->input, BTN_TOUCH, !!pressure); - } else { - input_report_abs(ts->input, ABS_PRESSURE, 0); - input_report_key(ts->input, BTN_TOUCH, 0); - } - - input_sync(ts->input); -} - -static void ts_timer(unsigned long arg) -{ - struct ts *ts = (struct ts *)arg; - - ts_update_pen_state(ts, 0, 0, 0); -} - -static irqreturn_t ts_interrupt(int irq, void *dev_id) -{ - u32 avgs, x, y, lx, ly; - u32 num_op, num_samp; - u32 status; - - struct ts *ts = dev_id; - - status = readl_relaxed(TSSC_REG(STATUS)); - avgs = readl_relaxed(TSSC_REG(AVG12)); - x = avgs & 0xFFFF; - y = avgs >> 16; - - /* For pen down make sure that the data just read is still valid. - * The DATA bit will still be set if the ARM9 hasn't clobbered - * the TSSC. If it's not set, then it doesn't need to be cleared - * here, so just return. - */ - if (!(readl_relaxed(TSSC_REG(CTL)) & TSSC_CTL_DATA)) - goto out; - - /* Data has been read, OK to clear the data flag */ - writel_relaxed(TSSC_CTL_STATE, TSSC_REG(CTL)); - /* barrier: Write to complete before the next sample */ - mb(); - /* Valid samples are indicated by the sample number in the status - * register being the number of expected samples and the number of - * samples collected being zero (this check is due to ADC contention). - */ - num_op = (status & TSSC_STS_OPN_BMSK) >> TSSC_STS_OPN_SHIFT; - num_samp = (status & TSSC_STS_NUMSAMP_BMSK) >> TSSC_STS_NUMSAMP_SHFT; - - if ((num_op == TSSC_NUMBER_OF_OPERATIONS) && (num_samp == 0)) { - /* TSSC can do Z axis measurment, but driver doesn't support - * this yet. - */ - - /* - * REMOVE THIS: - * These x, y co-ordinates adjustments will be removed once - * Android framework adds calibration framework. - */ -#ifdef CONFIG_ANDROID_TOUCHSCREEN_MSM_HACKS - lx = ts->x_max - x; - ly = ts->y_max - y; -#else - lx = x; - ly = y; -#endif - ts_update_pen_state(ts, lx, ly, 255); - /* kick pen up timer - to make sure it expires again(!) */ - mod_timer(&ts->timer, - jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS)); - - } else - printk(KERN_INFO "Ignored interrupt: {%3d, %3d}," - " op = %3d samp = %3d\n", - x, y, num_op, num_samp); - -out: - return IRQ_HANDLED; -} - -static int ts_probe(struct platform_device *pdev) -{ - int result; - struct input_dev *input_dev; - struct resource *res, *ioarea; - struct ts *ts; - unsigned int x_max, y_max, pressure_max; - struct msm_ts_platform_data *pdata = pdev->dev.platform_data; - - /* The primary initialization of the TS Hardware - * is taken care of by the ADC code on the modem side - */ - - ts = kzalloc(sizeof(struct ts), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!input_dev || !ts) { - result = -ENOMEM; - goto fail_alloc_mem; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); - result = -ENOENT; - goto fail_alloc_mem; - } - - ts->irq = platform_get_irq(pdev, 0); - if (!ts->irq) { - dev_err(&pdev->dev, "Could not get IORESOURCE_IRQ\n"); - result = -ENODEV; - goto fail_alloc_mem; - } - - ioarea = request_mem_region(res->start, resource_size(res), pdev->name); - if (!ioarea) { - dev_err(&pdev->dev, "Could not allocate io region\n"); - result = -EBUSY; - goto fail_alloc_mem; - } - - virt = ioremap(res->start, resource_size(res)); - if (!virt) { - dev_err(&pdev->dev, "Could not ioremap region\n"); - result = -ENOMEM; - goto fail_ioremap; - } - - input_dev->name = TS_DRIVER_NAME; - input_dev->phys = "msm_touch/input0"; - input_dev->id.bustype = BUS_HOST; - input_dev->id.vendor = 0x0001; - input_dev->id.product = 0x0002; - input_dev->id.version = 0x0100; - input_dev->dev.parent = &pdev->dev; - - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); - input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); - input_dev->absbit[BIT_WORD(ABS_MISC)] = BIT_MASK(ABS_MISC); - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); - - if (pdata) { - x_max = pdata->x_max ? : X_MAX; - y_max = pdata->y_max ? : Y_MAX; - pressure_max = pdata->pressure_max ? : P_MAX; - } else { - x_max = X_MAX; - y_max = Y_MAX; - pressure_max = P_MAX; - } - - ts->x_max = x_max; - ts->y_max = y_max; - - input_set_abs_params(input_dev, ABS_X, 0, x_max, 0, 0); - input_set_abs_params(input_dev, ABS_Y, 0, y_max, 0, 0); - input_set_abs_params(input_dev, ABS_PRESSURE, 0, pressure_max, 0, 0); - - result = input_register_device(input_dev); - if (result) - goto fail_ip_reg; - - ts->input = input_dev; - - setup_timer(&ts->timer, ts_timer, (unsigned long)ts); - result = request_irq(ts->irq, ts_interrupt, IRQF_TRIGGER_RISING, - "touchscreen", ts); - if (result) - goto fail_req_irq; - - platform_set_drvdata(pdev, ts); - - return 0; - -fail_req_irq: - input_unregister_device(input_dev); - input_dev = NULL; -fail_ip_reg: - iounmap(virt); -fail_ioremap: - release_mem_region(res->start, resource_size(res)); -fail_alloc_mem: - input_free_device(input_dev); - kfree(ts); - return result; -} - -static int ts_remove(struct platform_device *pdev) -{ - struct resource *res; - struct ts *ts = platform_get_drvdata(pdev); - - free_irq(ts->irq, ts); - del_timer_sync(&ts->timer); - - input_unregister_device(ts->input); - iounmap(virt); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(res->start, resource_size(res)); - platform_set_drvdata(pdev, NULL); - kfree(ts); - - return 0; -} - -static struct platform_driver ts_driver = { - .probe = ts_probe, - .remove = ts_remove, - .driver = { - .name = TS_DRIVER_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init ts_init(void) -{ - return platform_driver_register(&ts_driver); -} -module_init(ts_init); - -static void __exit ts_exit(void) -{ - platform_driver_unregister(&ts_driver); -} -module_exit(ts_exit); - -MODULE_DESCRIPTION("MSM Touch Screen driver"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:msm_touchscreen"); diff --git a/drivers/input/touchscreen/msm_ts.c b/drivers/input/touchscreen/msm_ts.c deleted file mode 100644 index d9793d9ad540ed8fae85bdc824bf70de71fd06e7..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/msm_ts.c +++ /dev/null @@ -1,514 +0,0 @@ -/* drivers/input/touchscreen/msm_ts.c - * - * Copyright (C) 2008 Google, Inc. - * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - * TODO: - * - Add a timer to simulate a pen_up in case there's a timeout. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_HAS_EARLYSUSPEND) -#include -#endif - -#include - -#define TSSC_CTL 0x100 -#define TSSC_CTL_PENUP_IRQ (1 << 12) -#define TSSC_CTL_DATA_FLAG (1 << 11) -#define TSSC_CTL_DEBOUNCE_EN (1 << 6) -#define TSSC_CTL_EN_AVERAGE (1 << 5) -#define TSSC_CTL_MODE_MASTER (3 << 3) -#define TSSC_CTL_SW_RESET (1 << 2) -#define TSSC_CTL_ENABLE (1 << 0) -#define TSSC_OPN 0x104 -#define TSSC_OPN_NOOP 0x00 -#define TSSC_OPN_4WIRE_X 0x01 -#define TSSC_OPN_4WIRE_Y 0x02 -#define TSSC_OPN_4WIRE_Z1 0x03 -#define TSSC_OPN_4WIRE_Z2 0x04 -#define TSSC_SAMPLING_INT 0x108 -#define TSSC_STATUS 0x10c -#define TSSC_AVG_12 0x110 -#define TSSC_AVG_34 0x114 -#define TSSC_SAMPLE(op,samp) ((0x118 + ((op & 0x3) * 0x20)) + \ - ((samp & 0x7) * 0x4)) -#define TSSC_TEST_1 0x198 - #define TSSC_TEST_1_EN_GATE_DEBOUNCE (1 << 2) -#define TSSC_TEST_2 0x19c - -struct msm_ts { - struct msm_ts_platform_data *pdata; - struct input_dev *input_dev; - void __iomem *tssc_base; - uint32_t ts_down:1; - struct ts_virt_key *vkey_down; - struct marimba_tsadc_client *ts_client; - - unsigned int sample_irq; - unsigned int pen_up_irq; - -#if defined(CONFIG_HAS_EARLYSUSPEND) - struct early_suspend early_suspend; -#endif - struct device *dev; -}; - -static uint32_t msm_tsdebug; -module_param_named(tsdebug, msm_tsdebug, uint, 0664); - -#define tssc_readl(t, a) (readl_relaxed(((t)->tssc_base) + (a))) -#define tssc_writel(t, v, a) do {writel_relaxed(v, \ - ((t)->tssc_base) + (a)); } \ - while (0) - -static void setup_next_sample(struct msm_ts *ts) -{ - uint32_t tmp; - - /* 1.2ms debounce time */ - tmp = ((2 << 7) | TSSC_CTL_DEBOUNCE_EN | TSSC_CTL_EN_AVERAGE | - TSSC_CTL_MODE_MASTER | TSSC_CTL_ENABLE); - tssc_writel(ts, tmp, TSSC_CTL); - /* barrier: Make sure the write completes before the next sample */ - mb(); -} - -static struct ts_virt_key *find_virt_key(struct msm_ts *ts, - struct msm_ts_virtual_keys *vkeys, - uint32_t val) -{ - int i; - - if (!vkeys) - return NULL; - - for (i = 0; i < vkeys->num_keys; ++i) - if ((val >= vkeys->keys[i].min) && (val <= vkeys->keys[i].max)) - return &vkeys->keys[i]; - return NULL; -} - - -static irqreturn_t msm_ts_irq(int irq, void *dev_id) -{ - struct msm_ts *ts = dev_id; - struct msm_ts_platform_data *pdata = ts->pdata; - - uint32_t tssc_avg12, tssc_avg34, tssc_status, tssc_ctl; - int x, y, z1, z2; - int was_down; - int down; - - tssc_ctl = tssc_readl(ts, TSSC_CTL); - tssc_status = tssc_readl(ts, TSSC_STATUS); - tssc_avg12 = tssc_readl(ts, TSSC_AVG_12); - tssc_avg34 = tssc_readl(ts, TSSC_AVG_34); - - setup_next_sample(ts); - - x = tssc_avg12 & 0xffff; - y = tssc_avg12 >> 16; - z1 = tssc_avg34 & 0xffff; - z2 = tssc_avg34 >> 16; - - /* invert the inputs if necessary */ - if (pdata->inv_x) x = pdata->inv_x - x; - if (pdata->inv_y) y = pdata->inv_y - y; - if (x < 0) x = 0; - if (y < 0) y = 0; - - down = !(tssc_ctl & TSSC_CTL_PENUP_IRQ); - was_down = ts->ts_down; - ts->ts_down = down; - - /* no valid data */ - if (down && !(tssc_ctl & TSSC_CTL_DATA_FLAG)) - return IRQ_HANDLED; - - if (msm_tsdebug & 2) - printk("%s: down=%d, x=%d, y=%d, z1=%d, z2=%d, status %x\n", - __func__, down, x, y, z1, z2, tssc_status); - - if (!was_down && down) { - struct ts_virt_key *vkey = NULL; - - if (pdata->vkeys_y && (y > pdata->virt_y_start)) - vkey = find_virt_key(ts, pdata->vkeys_y, x); - if (!vkey && ts->pdata->vkeys_x && (x > pdata->virt_x_start)) - vkey = find_virt_key(ts, pdata->vkeys_x, y); - - if (vkey) { - WARN_ON(ts->vkey_down != NULL); - if(msm_tsdebug) - printk("%s: virtual key down %d\n", __func__, - vkey->key); - ts->vkey_down = vkey; - input_report_key(ts->input_dev, vkey->key, 1); - input_sync(ts->input_dev); - return IRQ_HANDLED; - } - } else if (ts->vkey_down != NULL) { - if (!down) { - if(msm_tsdebug) - printk("%s: virtual key up %d\n", __func__, - ts->vkey_down->key); - input_report_key(ts->input_dev, ts->vkey_down->key, 0); - input_sync(ts->input_dev); - ts->vkey_down = NULL; - } - return IRQ_HANDLED; - } - - if (down) { - input_report_abs(ts->input_dev, ABS_X, x); - input_report_abs(ts->input_dev, ABS_Y, y); - input_report_abs(ts->input_dev, ABS_PRESSURE, z1); - } - input_report_key(ts->input_dev, BTN_TOUCH, down); - input_sync(ts->input_dev); - - return IRQ_HANDLED; -} - -static void dump_tssc_regs(struct msm_ts *ts) -{ -#define __dump_tssc_reg(r) \ - do { printk(#r " %x\n", tssc_readl(ts, (r))); } while(0) - - __dump_tssc_reg(TSSC_CTL); - __dump_tssc_reg(TSSC_OPN); - __dump_tssc_reg(TSSC_SAMPLING_INT); - __dump_tssc_reg(TSSC_STATUS); - __dump_tssc_reg(TSSC_AVG_12); - __dump_tssc_reg(TSSC_AVG_34); - __dump_tssc_reg(TSSC_TEST_1); -#undef __dump_tssc_reg -} - -static int msm_ts_hw_init(struct msm_ts *ts) -{ - uint32_t tmp; - - /* Enable the register clock to tssc so we can configure it. */ - tssc_writel(ts, TSSC_CTL_ENABLE, TSSC_CTL); - /* Enable software reset*/ - tssc_writel(ts, TSSC_CTL_SW_RESET, TSSC_CTL); - - /* op1 - measure X, 1 sample, 12bit resolution */ - tmp = (TSSC_OPN_4WIRE_X << 16) | (2 << 8) | (2 << 0); - /* op2 - measure Y, 1 sample, 12bit resolution */ - tmp |= (TSSC_OPN_4WIRE_Y << 20) | (2 << 10) | (2 << 2); - /* op3 - measure Z1, 1 sample, 8bit resolution */ - tmp |= (TSSC_OPN_4WIRE_Z1 << 24) | (2 << 12) | (0 << 4); - - /* XXX: we don't actually need to measure Z2 (thus 0 samples) when - * doing voltage-driven measurement */ - /* op4 - measure Z2, 0 samples, 8bit resolution */ - tmp |= (TSSC_OPN_4WIRE_Z2 << 28) | (0 << 14) | (0 << 6); - tssc_writel(ts, tmp, TSSC_OPN); - - /* 16ms sampling interval */ - tssc_writel(ts, 16, TSSC_SAMPLING_INT); - /* Enable gating logic to fix the timing delays caused because of - * enabling debounce logic */ - tssc_writel(ts, TSSC_TEST_1_EN_GATE_DEBOUNCE, TSSC_TEST_1); - - setup_next_sample(ts); - - return 0; -} - -static void msm_ts_enable(struct msm_ts *ts, bool enable) -{ - uint32_t val; - - if (enable == true) - msm_ts_hw_init(ts); - else { - val = tssc_readl(ts, TSSC_CTL); - val &= ~TSSC_CTL_ENABLE; - tssc_writel(ts, val, TSSC_CTL); - } -} - -#ifdef CONFIG_PM -static int -msm_ts_suspend(struct device *dev) -{ - struct msm_ts *ts = dev_get_drvdata(dev); - - if (device_may_wakeup(dev) && - device_may_wakeup(dev->parent)) - enable_irq_wake(ts->sample_irq); - else { - disable_irq(ts->sample_irq); - disable_irq(ts->pen_up_irq); - msm_ts_enable(ts, false); - } - - return 0; -} - -static int -msm_ts_resume(struct device *dev) -{ - struct msm_ts *ts = dev_get_drvdata(dev); - - if (device_may_wakeup(dev) && - device_may_wakeup(dev->parent)) - disable_irq_wake(ts->sample_irq); - else { - msm_ts_enable(ts, true); - enable_irq(ts->sample_irq); - enable_irq(ts->pen_up_irq); - } - - return 0; -} - -static struct dev_pm_ops msm_touchscreen_pm_ops = { -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = msm_ts_suspend, - .resume = msm_ts_resume, -#endif -}; -#endif - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void msm_ts_early_suspend(struct early_suspend *h) -{ - struct msm_ts *ts = container_of(h, struct msm_ts, early_suspend); - - msm_ts_suspend(ts->dev); -} - -static void msm_ts_late_resume(struct early_suspend *h) -{ - struct msm_ts *ts = container_of(h, struct msm_ts, early_suspend); - - msm_ts_resume(ts->dev); -} -#endif - - -static int msm_ts_probe(struct platform_device *pdev) -{ - struct msm_ts_platform_data *pdata = pdev->dev.platform_data; - struct msm_ts *ts; - struct resource *tssc_res; - struct resource *irq1_res; - struct resource *irq2_res; - int err = 0; - int i; - struct marimba_tsadc_client *ts_client; - - printk("%s\n", __func__); - - tssc_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tssc"); - irq1_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "tssc1"); - irq2_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "tssc2"); - - if (!tssc_res || !irq1_res || !irq2_res) { - pr_err("%s: required resources not defined\n", __func__); - return -ENODEV; - } - - if (pdata == NULL) { - pr_err("%s: missing platform_data\n", __func__); - return -ENODEV; - } - - ts = kzalloc(sizeof(struct msm_ts), GFP_KERNEL); - if (ts == NULL) { - pr_err("%s: No memory for struct msm_ts\n", __func__); - return -ENOMEM; - } - ts->pdata = pdata; - ts->dev = &pdev->dev; - - ts->sample_irq = irq1_res->start; - ts->pen_up_irq = irq2_res->start; - - ts->tssc_base = ioremap(tssc_res->start, resource_size(tssc_res)); - if (ts->tssc_base == NULL) { - pr_err("%s: Can't ioremap region (0x%08x - 0x%08x)\n", __func__, - (uint32_t)tssc_res->start, (uint32_t)tssc_res->end); - err = -ENOMEM; - goto err_ioremap_tssc; - } - - ts_client = marimba_tsadc_register(pdev, 1); - if (IS_ERR(ts_client)) { - pr_err("%s: Unable to register with TSADC\n", __func__); - err = -ENOMEM; - goto err_tsadc_register; - } - ts->ts_client = ts_client; - - err = marimba_tsadc_start(ts_client); - if (err) { - pr_err("%s: Unable to start TSADC\n", __func__); - err = -EINVAL; - goto err_start_tsadc; - } - - ts->input_dev = input_allocate_device(); - if (ts->input_dev == NULL) { - pr_err("failed to allocate touchscreen input device\n"); - err = -ENOMEM; - goto err_alloc_input_dev; - } - ts->input_dev->name = "msm-touchscreen"; - ts->input_dev->dev.parent = &pdev->dev; - - input_set_drvdata(ts->input_dev, ts); - - input_set_capability(ts->input_dev, EV_KEY, BTN_TOUCH); - set_bit(EV_ABS, ts->input_dev->evbit); - set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); - - input_set_abs_params(ts->input_dev, ABS_X, pdata->min_x, pdata->max_x, - 0, 0); - input_set_abs_params(ts->input_dev, ABS_Y, pdata->min_y, pdata->max_y, - 0, 0); - input_set_abs_params(ts->input_dev, ABS_PRESSURE, pdata->min_press, - pdata->max_press, 0, 0); - - for (i = 0; pdata->vkeys_x && (i < pdata->vkeys_x->num_keys); ++i) - input_set_capability(ts->input_dev, EV_KEY, - pdata->vkeys_x->keys[i].key); - for (i = 0; pdata->vkeys_y && (i < pdata->vkeys_y->num_keys); ++i) - input_set_capability(ts->input_dev, EV_KEY, - pdata->vkeys_y->keys[i].key); - - err = input_register_device(ts->input_dev); - if (err != 0) { - pr_err("%s: failed to register input device\n", __func__); - goto err_input_dev_reg; - } - - msm_ts_hw_init(ts); - - err = request_irq(ts->sample_irq, msm_ts_irq, - (irq1_res->flags & ~IORESOURCE_IRQ) | IRQF_DISABLED, - "msm_touchscreen", ts); - if (err != 0) { - pr_err("%s: Cannot register irq1 (%d)\n", __func__, err); - goto err_request_irq1; - } - - err = request_irq(ts->pen_up_irq, msm_ts_irq, - (irq2_res->flags & ~IORESOURCE_IRQ) | IRQF_DISABLED, - "msm_touchscreen", ts); - if (err != 0) { - pr_err("%s: Cannot register irq2 (%d)\n", __func__, err); - goto err_request_irq2; - } - - platform_set_drvdata(pdev, ts); - -#ifdef CONFIG_HAS_EARLYSUSPEND - ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + - TSSC_SUSPEND_LEVEL; - ts->early_suspend.suspend = msm_ts_early_suspend; - ts->early_suspend.resume = msm_ts_late_resume; - register_early_suspend(&ts->early_suspend); -#endif - - device_init_wakeup(&pdev->dev, pdata->can_wakeup); - pr_info("%s: tssc_base=%p irq1=%d irq2=%d\n", __func__, - ts->tssc_base, (int)ts->sample_irq, (int)ts->pen_up_irq); - dump_tssc_regs(ts); - return 0; - -err_request_irq2: - free_irq(ts->sample_irq, ts); - -err_request_irq1: - /* disable the tssc */ - tssc_writel(ts, TSSC_CTL_ENABLE, TSSC_CTL); - -err_input_dev_reg: - input_set_drvdata(ts->input_dev, NULL); - input_free_device(ts->input_dev); - -err_alloc_input_dev: -err_start_tsadc: - marimba_tsadc_unregister(ts->ts_client); - -err_tsadc_register: - iounmap(ts->tssc_base); - -err_ioremap_tssc: - kfree(ts); - return err; -} - -static int msm_ts_remove(struct platform_device *pdev) -{ - struct msm_ts *ts = platform_get_drvdata(pdev); - - device_init_wakeup(&pdev->dev, 0); - marimba_tsadc_unregister(ts->ts_client); - free_irq(ts->sample_irq, ts); - free_irq(ts->pen_up_irq, ts); - input_unregister_device(ts->input_dev); - iounmap(ts->tssc_base); -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&ts->early_suspend); -#endif - platform_set_drvdata(pdev, NULL); - kfree(ts); - - return 0; -} - -static struct platform_driver msm_touchscreen_driver = { - .driver = { - .name = "msm_touchscreen", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &msm_touchscreen_pm_ops, -#endif - }, - .probe = msm_ts_probe, - .remove = msm_ts_remove, -}; - -static int __init msm_ts_init(void) -{ - return platform_driver_register(&msm_touchscreen_driver); -} - -static void __exit msm_ts_exit(void) -{ - platform_driver_unregister(&msm_touchscreen_driver); -} - -module_init(msm_ts_init); -module_exit(msm_ts_exit); -MODULE_DESCRIPTION("Qualcomm MSM/QSD Touchscreen controller driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:msm_touchscreen"); diff --git a/drivers/input/touchscreen/synaptics/Makefile b/drivers/input/touchscreen/synaptics/Makefile deleted file mode 100644 index 32cbd76f3f5a376fc1df25c95583ce94d5e0f0fb..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -CFLAGS_rmi_bus.o := -DDEBUG -CFLAGS_rmi_sensor.o := -DDEBUG -CFLAGS_rmi_function.o := -DDEBUG -CFLAGS_rmi_f01.o := -DDEBUG -CFLAGS_rmi_f05.o := -DDEBUG -CFLAGS_rmi_f11.o := -DDEBUG -CFLAGS_rmi_f19.o := -DDEBUG -CFLAGS_rmi_f34.o := -DDEBUG -CFLAGS_rmi_i2c.o := -DDEBUG -CFLAGS_rmi_spi.o := -DDEBUG -obj-y += rmi_bus.o rmi_sensor.o rmi_function.o rmi_f01.o rmi_f05.o rmi_f11.o rmi_f19.o rmi_f34.o rmi_i2c.o diff --git a/drivers/input/touchscreen/synaptics/rmi.h b/drivers/input/touchscreen/synaptics/rmi.h deleted file mode 100644 index 7484258f7d0c05471c9e7b24f0d92de4bde970a4..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi.h +++ /dev/null @@ -1,164 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Header File. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_H -#define _RMI_H - -/* RMI4 Protocol Support - */ - -/* For each function present on the RMI device, we need to get the RMI4 Function - * Descriptor info from the Page Descriptor Table. This will give us the - * addresses for Query, Command, Control, Data and the Source Count (number - * of sources for this function) and the function id. - */ -struct rmi_function_descriptor { - unsigned char queryBaseAddr; - unsigned char commandBaseAddr; - unsigned char controlBaseAddr; - unsigned char dataBaseAddr; - unsigned char interruptSrcCnt; - unsigned char functionNum; -}; - -/* This encapsulates the information found using the RMI4 Function $01 - * query registers. There is only one Function $01 per device. - * - * Assuming appropriate endian-ness, you can populate most of this - * structure by reading query registers starting at the query base address - * that was obtained from RMI4 function 0x01 function descriptor info read - * from the Page Descriptor Table. - * - * Specific register information is provided in the comments for each field. - * For further reference, please see the "Synaptics RMI 4 Interfacing - * Guide" document : go to http://www.synaptics.com/developers/manuals - and - * select "Synaptics RMI 4 Interfacting Guide". - */ -struct rmi_F01_query { - /* The manufacturer identification byte.*/ - unsigned char mfgid; - - /* The Product Properties information.*/ - unsigned char properties; - - /* The product info bytes.*/ - unsigned char prod_info[2]; - - /* Date Code - Year, Month, Day.*/ - unsigned char date_code[3]; - - /* Tester ID (14 bits).*/ - unsigned short tester_id; - - /* Serial Number (14 bits).*/ - unsigned short serial_num; - - /* A null-terminated string that identifies this particular product.*/ - char prod_id[11]; -}; - -/* This encapsulates the F01 Device Control control registers. - * TODO: This isn't right. The number of interrupt enables needs to be determined - * dynamically as the sensor is initialized. Fix this. - */ -struct rmi_F01_control { - unsigned char deviceControl; - unsigned char interruptEnable[1]; -}; - -/** This encapsulates the F01 Device Control data registers. - * TODO: This isn't right. The number of irqs needs to be determined - * dynamically as the sensor is initialized. Fix this. - */ -struct rmi_F01_data { - unsigned char deviceStatus; - unsigned char irqs[1]; -}; - - -/**********************************************************/ - -/** This is the data read from the F11 query registers. - */ -struct rmi_F11_device_query { - bool hasQuery9; - unsigned char numberOfSensors; -}; - -struct rmi_F11_sensor_query { - bool configurable; - bool hasSensitivityAdjust; - bool hasGestures; - bool hasAbs; - bool hasRel; - unsigned char numberOfFingers; - unsigned char numberOfXElectrodes; - unsigned char numberOfYElectrodes; - unsigned char maximumElectrodes; - bool hasAnchoredFinger; - unsigned char absDataSize; -}; - -struct rmi_F11_control { - bool relativeBallistics; - bool relativePositionFilter; - bool absolutePositionFilter; - unsigned char reportingMode; - bool manuallyTrackedFinger; - bool manuallyTrackedFingerEnable; - unsigned char motionSensitivity; - unsigned char palmDetectThreshold; - unsigned char deltaXPosThreshold; - unsigned char deltaYPosThreshold; - unsigned char velocity; - unsigned char acceleration; - unsigned short sensorMaxXPos; - unsigned short sensorMaxYPos; -}; - - -/**********************************************************/ - -/** This is the data read from the F19 query registers. - */ -struct rmi_F19_query { - bool hasHysteresisThreshold; - bool hasSensitivityAdjust; - bool configurable; - unsigned char buttonCount; -}; - -struct rmi_F19_control { - unsigned char buttonUsage; - unsigned char filterMode; - unsigned char *intEnableRegisters; - unsigned char *singleButtonControl; - unsigned char *sensorMap; - unsigned char *singleButtonSensitivity; - unsigned char globalSensitivityAdjustment; - unsigned char globalHysteresisThreshold; -}; - -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_bus.c b/drivers/input/touchscreen/synaptics/rmi_bus.c deleted file mode 100644 index b65eabb8b65df5c45804b95e7d890d26fdfe93a3..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_bus.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - * Synaptics Register Mapped Interface (RMI4) - RMI Bus Module. - * Copyright (C) 2007 - 2011, Synaptics Incorporated - * - * Impliments "rmi" bus per Documentation/driver-model/bus.txt - * - * This protocol is layered as follows. - * - * - * - * +-------+ +-------+ +-------+ +--------+ - * | Fn32 | | Fn11| | Fn19 | | Fn11 | Devices/Functions - * *---|---+ +--|----+ +----|--+ +----|---* (2D, cap. btns, etc.) - * | | | | - * +----------------+ +----------------+ - * | Sensor0 | | Sensor1 | Sensors Dev/Drivers - * +----------------+ +----------------+ (a sensor has one or - * | | more functions) - * | | - * +----------------------------------------+ - * | | - * | RMI4 Bus | RMI Bus Layer - * | (this file) | - * *--|-----|------|--------------|---------* - * | | | | - * | | | | - * +-----+-----+-------+--------------------+ - * | I2C | SPI | SMBus | etc. | Physical Layer - * +-----+-----+-------+--------------------+ - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * - *############################################################################# - */ - -static const char busname[] = "rmi"; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmi_drvr.h" -#include "rmi.h" -#include "rmi_bus.h" -#include "rmi_sensor.h" -#include "rmi_function.h" - -/* list of physical drivers - i2c, spi, etc. */ -static LIST_HEAD(phys_drivers); -static DEFINE_MUTEX(phys_drivers_mutex); - -/* list of sensors found on a physical bus (i2c, smi, etc.)*/ -static LIST_HEAD(sensor_drivers); -static DEFINE_MUTEX(sensor_drivers_mutex); -static LIST_HEAD(sensor_devices); -static DEFINE_MUTEX(sensor_devices_mutex); - -#define PDT_START_SCAN_LOCATION 0x00E9 -#define PDT_END_SCAN_LOCATION 0x0005 -#define PDT_ENTRY_SIZE 0x0006 - -/* definitions for rmi bus */ -struct device rmi_bus_device; - -struct bus_type rmi_bus_type; -EXPORT_SYMBOL(rmi_bus_type); - - -/* - * This method is called, perhaps multiple times, whenever a new device or driver - * is added for this bus. It should return a nonzero value if the given device can be - * handled by the given driver. This function must be handled at the bus level, - * because that is where the proper logic exists; the core kernel cannot know how - * to match devices and drivers for every possible bus type - * The match function does a comparison between the hardware ID provided by - * the device itself and the IDs supported by the driver. - * - */ -static int rmi_bus_match(struct device *dev, struct device_driver *driver) -{ - printk(KERN_DEBUG "%s: Matching %s for rmi bus.\n", __func__, dev->bus->name); - return !strncmp(dev->bus->name, driver->name, strlen(driver->name)); -} - -/** Stub for now. - */ -static int rmi_bus_suspend(struct device *dev, pm_message_t state) -{ - printk(KERN_INFO "%s: RMI bus suspending.", __func__); - return 0; -} - -/** Stub for now. - */ -static int rmi_bus_resume(struct device *dev) -{ - printk(KERN_INFO "%s: RMI bus resuming.", __func__); - return 0; -} - -/* - * This method is called, whenever a new device is added for this bus. - * It will scan the devices PDT to get the function $01 query, control, - * command and data regsiters so that it can create a function $01 (sensor) - * device for the new physical device. It also caches the PDT for later use by - * other functions that are created for the device. For example, if a function - * $11 is found it will need the query, control, command and data register - * addresses for that function. The new function could re-scan the PDT but - * since it is being done here we can cache it and keep it around. - * - * TODO: If the device is reset or some action takes place that would invalidate - * the PDT - such as a reflash of the firmware - then the device should be re-added - * to the bus and the PDT re-scanned and cached. - * - */ -int rmi_register_sensor(struct rmi_phys_driver *rpd, struct rmi_sensordata *sensordata) -{ - int i; - int pdt_entry_count = 0; - struct rmi_sensor_device *rmi_sensor_dev; - struct rmi_function_info *rfi; - struct rmi_function_descriptor rmi_fd; - int retval; - static int index; - - /* Make sure we have a read, write, read_multiple, write_multiple - function pointers from whatever physical layer the sensor is on. - */ - if (!rpd->name) { - printk(KERN_ERR "%s: Physical driver must specify a name", - __func__); - return -EINVAL; - } - if (!rpd->write) { - printk(KERN_ERR - "%s: Physical driver %s must specify a writer.", - __func__, rpd->name); - return -EINVAL; - } - if (!rpd->read) { - printk(KERN_ERR - "%s: Physical driver %s must specify a reader.", - __func__, rpd->name); - return -EINVAL; - } - if (!rpd->write_multiple) { - printk(KERN_ERR "%s: Physical driver %s must specify a " - "multiple writer.", - __func__, rpd->name); - return -EINVAL; - } - if (!rpd->read_multiple) { - printk(KERN_ERR "%s: Physical driver %s must specify a " - "multiple reader.", - __func__, rpd->name); - return -EINVAL; - } - - /* Get some information from the device */ - printk(KERN_DEBUG "%s: Identifying sensors by presence of F01...", __func__); - - rmi_sensor_dev = NULL; - - /* Scan the page descriptor table until we find F01. If we find that, - * we assume that we can reliably talk to this sensor. - */ - for (i = PDT_START_SCAN_LOCATION; /* Register the rmi sensor driver */ - i >= PDT_END_SCAN_LOCATION; - i -= PDT_ENTRY_SIZE) { - retval = rpd->read_multiple(rpd, i, (char *)&rmi_fd, - sizeof(rmi_fd)); - if (!retval) { - rfi = NULL; - - if (rmi_fd.functionNum != 0x00 && rmi_fd.functionNum != 0xff) { - pdt_entry_count++; - if ((rmi_fd.functionNum & 0xff) == 0x01) { - printk(KERN_DEBUG "%s: F01 Found - RMI Device Control", __func__); - - /* This appears to be a valid device, so create a sensor - * device and sensor driver for it. */ - rmi_sensor_dev = kzalloc(sizeof(*rmi_sensor_dev), GFP_KERNEL); - if (!rmi_sensor_dev) { - printk(KERN_ERR "%s: Error allocating memory for rmi_sensor_device\n", __func__); - retval = -ENOMEM; - goto exit_fail; - } - rmi_sensor_dev->dev.bus = &rmi_bus_type; - - retval = rmi_sensor_register_device(rmi_sensor_dev, index++); - if (retval < 0) { - printk(KERN_ERR "%s: Error %d registering sensor device.", __func__, retval); - goto exit_fail; - } - - rmi_sensor_dev->driver = kzalloc(sizeof(struct rmi_sensor_driver), GFP_KERNEL); - if (!rmi_sensor_dev->driver) { - printk(KERN_ERR "%s: Error allocating memory for rmi_sensor_driver\n", __func__); - retval = -ENOMEM; - goto exit_fail; - } - rmi_sensor_dev->driver->sensor_device = rmi_sensor_dev; - rmi_sensor_dev->driver->polling_required = rpd->polling_required; - rmi_sensor_dev->driver->rpd = rpd; - if (sensordata) - rmi_sensor_dev->driver->perfunctiondata = sensordata->perfunctiondata; - INIT_LIST_HEAD(&rmi_sensor_dev->driver->functions); - - retval = rmi_sensor_register_driver(rmi_sensor_dev->driver); - if (retval < 0) { - printk(KERN_ERR "%s: Error %d registering sensor driver.", __func__, retval); - goto exit_fail; - } - - /* link the attention fn in the rpd to the sensor attn fn */ - - rpd->sensor = rmi_sensor_dev->driver; - rpd->attention = rmi_sensor_dev->driver->attention; - - /* Add it into the list of sensors on the rmi bus */ - mutex_lock(&sensor_devices_mutex); - list_add_tail(&rmi_sensor_dev->sensors, &sensor_devices); - mutex_unlock(&sensor_devices_mutex); - - /* All done with this sensor, fall out of PDT scan loop. */ - break; - } else { - /* Just print out the function found for now */ - printk(KERN_DEBUG "%s: Found Function %02x - Ignored.\n", __func__, rmi_fd.functionNum & 0xff); - } - } else { - /* A zero or 0xff in the function number - signals the end of the PDT */ - pr_debug("%s: Found End of PDT.", - __func__); - break; - } - } else { - /* failed to read next PDT entry - end PDT - scan - this may result in an incomplete set - of recognized functions - should probably - return an error but the driver may still be - viable for diagnostics and debugging so let's - let it continue. */ - printk(KERN_ERR "%s: Read Error %d when reading next PDT entry - " - "ending PDT scan.", - __func__, retval); - break; - } - } - - /* If we actually found a sensor, keep it around. */ - if (rmi_sensor_dev) { - /* Add physical driver struct to list */ - mutex_lock(&phys_drivers_mutex); - list_add_tail(&rpd->drivers, &phys_drivers); - mutex_unlock(&phys_drivers_mutex); - printk(KERN_DEBUG "%s: Registered sensor drivers.", __func__); - retval = 0; - } else { - printk(KERN_ERR "%s: Failed to find sensor. PDT contained %d entries.", __func__, pdt_entry_count); - retval = -ENODEV; - } - -exit_fail: - return retval; -} -EXPORT_SYMBOL(rmi_register_sensor); - -int rmi_unregister_sensors(struct rmi_phys_driver *rpd) -{ - if (rpd->sensor) { - printk(KERN_WARNING "%s: WARNING: unregister of %s while %s still attached.", - __func__, rpd->name, rpd->sensor->drv.name); - } - - pr_debug("%s: Unregistering sensor drivers %s\n", __func__, rpd->name); - - /* TODO: We should call sensor_teardown() for each sensor before we get - * rid of this list. - */ - - mutex_lock(&sensor_drivers_mutex); - list_del(&rpd->sensor->sensor_drivers); - mutex_unlock(&sensor_drivers_mutex); - - return 0; -} -EXPORT_SYMBOL(rmi_unregister_sensors); - - -static void rmi_bus_dev_release(struct device *dev) -{ - printk(KERN_DEBUG "rmi bus device release\n"); -} - - -int rmi_register_bus_device(struct device *rmibusdev) -{ - printk(KERN_DEBUG "%s: Registering RMI4 bus device.\n", __func__); - - /* Here, we simply fill in some of the embedded device structure fields - (which individual drivers should not need to know about), and register - the device with the driver core. */ - - rmibusdev->bus = &rmi_bus_type; - rmibusdev->parent = &rmi_bus_device; - rmibusdev->release = rmi_bus_dev_release; - dev_set_name(rmibusdev, "rmi"); - - /* If we wanted to add bus-specific attributes to the device, we could do so here.*/ - - return device_register(rmibusdev); -} -EXPORT_SYMBOL(rmi_register_bus_device); - -void rmi_unregister_bus_device(struct device *rmibusdev) -{ - printk(KERN_DEBUG "%s: Unregistering bus device.", __func__); - - device_unregister(rmibusdev); -} -EXPORT_SYMBOL(rmi_unregister_bus_device); - -static int __init rmi_bus_init(void) -{ - int status; - - status = 0; - - printk(KERN_INFO "%s: RMI Bus Driver Init", __func__); - - /* Register the rmi bus */ - rmi_bus_type.name = busname; - rmi_bus_type.match = rmi_bus_match; - rmi_bus_type.suspend = rmi_bus_suspend; - rmi_bus_type.resume = rmi_bus_resume; - status = bus_register(&rmi_bus_type); - if (status < 0) { - printk(KERN_ERR "%s: Error %d registering the rmi bus.", __func__, status); - goto err_exit; - } - printk(KERN_DEBUG "%s: registered bus.", __func__); - -#if 0 - /** This doesn't seem to be required any more. It worked OK in Froyo, - * but breaks in Gingerbread */ - /* Register the rmi bus device - "rmi". There is only one rmi bus device. */ - status = rmi_register_bus_device(&rmi_bus_device); - if (status < 0) { - printk(KERN_ERR "%s: Error %d registering rmi bus device.", __func__, status); - bus_unregister(&rmi_bus_type); - goto err_exit; - } - printk(KERN_DEBUG "%s: Registered bus device.", __func__); -#endif - - return 0; -err_exit: - return status; -} - -static void __exit rmi_bus_exit(void) -{ - printk(KERN_DEBUG "%s: RMI Bus Driver Exit.", __func__); - - /* Unregister the rmi bus device - "rmi". There is only one rmi bus device. */ - rmi_unregister_bus_device(&rmi_bus_device); - - /* Unregister the rmi bus */ - bus_unregister(&rmi_bus_type); -} - - -module_init(rmi_bus_init); -module_exit(rmi_bus_exit); - -MODULE_AUTHOR("Synaptics, Inc."); -MODULE_DESCRIPTION("RMI4 Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/synaptics/rmi_bus.h b/drivers/input/touchscreen/synaptics/rmi_bus.h deleted file mode 100644 index 1e9bd24edc92e1cb844da3c447173700d0ffba27..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_bus.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) - RMI Bus Module Header. - * Copyright (C) 2007 - 2010, Synaptics Incorporated - * - */ -/* - * - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_BUS_H -#define _RMI_BUS_H - - -extern struct bus_type rmi_bus_type; - -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_drvr.h b/drivers/input/touchscreen/synaptics/rmi_drvr.h deleted file mode 100644 index d8c848d339fe4007ed90c3e32ad32df630d3af25..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_drvr.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) RMI Driver Header File. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 "rmi.h" - -#ifndef _RMI_DRVR_H -#define _RMI_DRVR_H - -#include - -/* RMI4 Protocol Support - */ - -struct rmi_phys_driver { - char *name; - int (*write)(struct rmi_phys_driver *physdrvr, unsigned short address, - char data); - int (*read)(struct rmi_phys_driver *physdrvr, unsigned short address, - char *buffer); - int (*write_multiple)(struct rmi_phys_driver *physdrvr, - unsigned short address, char *buffer, int length); - int (*read_multiple)(struct rmi_phys_driver *physdrvr, unsigned short address, - char *buffer, int length); - void (*attention)(struct rmi_phys_driver *physdrvr, int instance); - bool polling_required; - int irq; - - /* Standard kernel linked list implementation. - * Documentation on how to use it can be found at - * http://isis.poly.edu/kulesh/stuff/src/klist/. - */ - struct list_head drivers; - struct rmi_sensor_driver *sensor; - struct module *module; -}; - -int rmi_read(struct rmi_sensor_driver *sensor, unsigned short address, char *dest); -int rmi_write(struct rmi_sensor_driver *sensor, unsigned short address, - unsigned char data); -int rmi_read_multiple(struct rmi_sensor_driver *sensor, unsigned short address, - char *dest, int length); -int rmi_write_multiple(struct rmi_sensor_driver *sensor, unsigned short address, - unsigned char *data, int length); -int rmi_register_sensor(struct rmi_phys_driver *physdrvr, - struct rmi_sensordata *sensordata); -int rmi_unregister_sensors(struct rmi_phys_driver *physdrvr); - -/* Utility routine to set bits in a register. */ -int rmi_set_bits(struct rmi_sensor_driver *sensor, unsigned short address, unsigned char bits); -/* Utility routine to clear bits in a register. */ -int rmi_clear_bits(struct rmi_sensor_driver *sensor, unsigned short address, unsigned char bits); -/* Utility routine to set the value of a bit field in a register. */ -int rmi_set_bit_field(struct rmi_sensor_driver *sensor, unsigned short address, - unsigned char field_mask, unsigned char bits); - -/* Set this to 1 to turn on code used in detecting buffer leaks. */ -#define RMI_ALLOC_STATS 1 - -#if RMI_ALLOC_STATS -extern int appallocsrmi; -extern int rfiallocsrmi; -extern int fnallocsrmi; - -#define INC_ALLOC_STAT(X) (X##allocsrmi++) -#define DEC_ALLOC_STAT(X) \ - do { \ - if (X##allocsrmi) X##allocsrmi--; \ - else printk(KERN_DEBUG "Too many " #X " frees\n"); \ - } while (0) -#define CHECK_ALLOC_STAT(X) \ - do { \ - if (X##allocsrmi) \ - printk(KERN_DEBUG "Left over " #X " buffers: %d\n", \ - X##allocsrmi); \ - } while (0) -#else -#define INC_ALLOC_STAT(X) do { } while (0) -#define DEC_ALLOC_STAT(X) do { } while (0) -#define CHECK_ALLOC_STAT(X) do { } while (0) -#endif - -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_f01.c b/drivers/input/touchscreen/synaptics/rmi_f01.c deleted file mode 100644 index 25a337d612bbb4627b175c3afb60e86aaf1af4b5..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f01.c +++ /dev/null @@ -1,603 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $01 support for sensor - * control and configuration. - * - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmi.h" -#include "rmi_drvr.h" -#include "rmi_bus.h" -#include "rmi_sensor.h" -#include "rmi_function.h" -#include "rmi_f01.h" - -/* Control register bits. */ -#define F01_CONFIGURED (1 << 7) -#define NONSTANDARD_REPORT_RATE (1 << 6) - -/* Command register bits. */ -#define F01_RESET 1 -#define F01_SHUTDOWN (1 << 1) - -/* Data register 0 bits. */ -#define F01_UNCONFIGURED (1 << 7) -#define F01_FLASH_PROGRAMMING_MODE (1 << 6) -#define F01_STATUS_MASK 0x0F - -/** Context data for each F01 we find. - */ -struct f01_instance_data { - struct rmi_F01_control *controlRegisters; - struct rmi_F01_data *dataRegisters; - struct rmi_F01_query *query_registers; - - bool nonstandard_report_rate; -}; - -static ssize_t rmi_fn_01_productinfo_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_productinfo_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(productinfo, 0444, rmi_fn_01_productinfo_show, rmi_fn_01_productinfo_store); /* RO attr */ - -static ssize_t rmi_fn_01_productid_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_productid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(productid, 0444, rmi_fn_01_productid_show, rmi_fn_01_productid_store); /* RO attr */ - -static ssize_t rmi_fn_01_manufacturer_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_manufacturer_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(manufacturer, 0444, rmi_fn_01_manufacturer_show, rmi_fn_01_manufacturer_store); /* RO attr */ - -static ssize_t rmi_fn_01_datecode_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_datecode_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(datecode, 0444, rmi_fn_01_datecode_show, rmi_fn_01_datecode_store); /* RO attr */ - -static ssize_t rmi_fn_01_reportrate_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_reportrate_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(reportrate, 0644, rmi_fn_01_reportrate_show, rmi_fn_01_reportrate_store); /* RW attr */ - -static ssize_t rmi_fn_01_reset_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_reset_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(reset, 0200, rmi_fn_01_reset_show, rmi_fn_01_reset_store); /* WO attr */ - -static ssize_t rmi_fn_01_testerid_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_testerid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(testerid, 0444, rmi_fn_01_testerid_show, rmi_fn_01_testerid_store); /* RO attr */ - -static ssize_t rmi_fn_01_serialnumber_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_01_serialnumber_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(serialnumber, 0444, rmi_fn_01_serialnumber_show, rmi_fn_01_serialnumber_store); /* RO attr */ - -static int set_report_rate(struct rmi_function_info *function_info, bool nonstandard) -{ - if (nonstandard) { - return rmi_set_bits(function_info->sensor, function_info->funcDescriptor.controlBaseAddr, NONSTANDARD_REPORT_RATE); - } else { - return rmi_set_bits(function_info->sensor, function_info->funcDescriptor.controlBaseAddr, NONSTANDARD_REPORT_RATE); - } -} - -/*. - * The interrupt handler for Fn $01 doesn't do anything (for now). - */ -void FN_01_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs) -{ - struct f01_instance_data *instanceData = (struct f01_instance_data *) rmifninfo->fndata; - - printk(KERN_DEBUG "%s: Read device status.", __func__); - - if (rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.dataBaseAddr, - &instanceData->dataRegisters->deviceStatus, 1)) { - printk(KERN_ERR "%s : Could not read F01 device status.\n", - __func__); - } - printk(KERN_INFO "%s: read device status register. Value 0x%02X.", __func__, instanceData->dataRegisters->deviceStatus); - - if (instanceData->dataRegisters->deviceStatus & F01_UNCONFIGURED) { - printk(KERN_INFO "%s: ++++ Device reset detected.", __func__); - /* TODO: Handle device reset appropriately. - */ - } -} -EXPORT_SYMBOL(FN_01_inthandler); - -/* - * This reads in the function $01 source data. - * - */ -void FN_01_attention(struct rmi_function_info *rmifninfo) -{ - struct f01_instance_data *instanceData = (struct f01_instance_data *) rmifninfo->fndata; - - /* TODO: Compute size to read and number of IRQ registers to processors - * dynamically. See comments in rmi.h. */ - if (rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.dataBaseAddr+1, - instanceData->dataRegisters->irqs, 1)) { - printk(KERN_ERR "%s : Could not read interrupt status registers at 0x%02x\n", - __func__, rmifninfo->funcDescriptor.dataBaseAddr); - return; - } - - if (instanceData->dataRegisters->irqs[0] & instanceData->controlRegisters->interruptEnable[0]) { -// printk(KERN_INFO "%s: ++++ IRQs == 0x%02X", __func__, instanceData->dataRegisters->irqs[0]); - /* call down to the sensors irq dispatcher to dispatch all enabled IRQs */ - rmifninfo->sensor->dispatchIRQs(rmifninfo->sensor, - instanceData->dataRegisters->irqs[0]); - } - -} -EXPORT_SYMBOL(FN_01_attention); - -int FN_01_config(struct rmi_function_info *rmifninfo) -{ - int retval = 0; - struct f01_instance_data *instance_data = rmifninfo->fndata; - - printk(KERN_DEBUG "%s: RMI4 function $01 config\n", __func__); - - /* First thing to do is set the configuration bit. We'll check this at - * the end to determine if the device has reset during the config process. - */ - retval = rmi_set_bits(rmifninfo->sensor, rmifninfo->funcDescriptor.controlBaseAddr, F01_CONFIGURED); - if (retval) - printk(KERN_WARNING "%s: failed to set configured bit, errno = %d.", - __func__, retval); - - /* At config time, the device is presumably in its default state, so we - * only need to write non-default configuration settings. - */ - if (instance_data->nonstandard_report_rate) { - retval = set_report_rate(rmifninfo, true); - if (!retval) - printk(KERN_WARNING "%s: failed to configure report rate, errno = %d.", - __func__, retval); - } - - /* TODO: Check for reset! */ - - return retval; -} -EXPORT_SYMBOL(FN_01_config); - -/* Initialize any function $01 specific params and settings - input - * settings, device settings, etc. - */ -int FN_01_init(struct rmi_function_device *function_device) -{ - int retval; - struct rmi_f01_functiondata *functiondata = rmi_sensor_get_functiondata(function_device->sensor, RMI_F01_INDEX); - struct f01_instance_data *instance_data = function_device->rfi->fndata; - - pr_debug("%s: RMI4 function $01 init\n", __func__); - - if (functiondata) { - instance_data->nonstandard_report_rate = functiondata->nonstandard_report_rate; - } - - retval = device_create_file(&function_device->dev, &dev_attr_productinfo); - if (retval) { - printk(KERN_ERR "%s: Failed to create productinfo.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_productid); - if (retval) { - printk(KERN_ERR "%s: Failed to create productid.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_manufacturer); - if (retval) { - printk(KERN_ERR "%s: Failed to create manufacturer.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_datecode); - if (retval) { - printk(KERN_ERR "%s: Failed to create datecode.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_reportrate); - if (retval) { - printk(KERN_ERR "%s: Failed to create reportrate.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_reset); - if (retval) { - printk(KERN_ERR "%s: Failed to create reset.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_serialnumber); - if (retval) { - printk(KERN_ERR "%s: Failed to create serialnumber.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_testerid); - if (retval) { - printk(KERN_ERR "%s: Failed to create testerid.", __func__); - return retval; - } - - return 0; -} -EXPORT_SYMBOL(FN_01_init); - -int FN_01_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, unsigned int interruptCount) -{ - int i; - int InterruptOffset; - int retval = 0; - struct f01_instance_data *instanceData = NULL; - struct rmi_F01_control *controlRegisters = NULL; - struct rmi_F01_data *dataRegisters = NULL; - struct rmi_F01_query *query_registers = NULL; - unsigned char query_buffer[21]; - - pr_debug("%s: RMI4 function $01 detect\n", __func__); - - /* Store addresses - used elsewhere to read data, - * control, query, etc. */ - rmifninfo->funcDescriptor.queryBaseAddr = fndescr->queryBaseAddr; - rmifninfo->funcDescriptor.commandBaseAddr = fndescr->commandBaseAddr; - rmifninfo->funcDescriptor.controlBaseAddr = fndescr->controlBaseAddr; - rmifninfo->funcDescriptor.dataBaseAddr = fndescr->dataBaseAddr; - rmifninfo->funcDescriptor.interruptSrcCnt = fndescr->interruptSrcCnt; - rmifninfo->funcDescriptor.functionNum = fndescr->functionNum; - - rmifninfo->numSources = fndescr->interruptSrcCnt; - - /* Set up context data. */ - instanceData = kzalloc(sizeof(*instanceData), GFP_KERNEL); - if (!instanceData) { - printk(KERN_ERR "%s: Error allocating memory for F01 context data.\n", __func__); - retval = -ENOMEM; - goto error_exit; - } - query_registers = kzalloc(sizeof(*query_registers), GFP_KERNEL); - if (!query_registers) { - printk(KERN_ERR "%s: Error allocating memory for F01 query registers.\n", __func__); - retval = -ENOMEM; - goto error_exit; - } - instanceData->query_registers = query_registers; - - /* Read the query info and unpack it. */ - retval = rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.queryBaseAddr, - query_buffer, 21); - if (retval) { - printk(KERN_ERR "%s : Could not read F01 query registers at 0x%02x. Error %d.\n", - __func__, rmifninfo->funcDescriptor.queryBaseAddr, retval); - /* Presumably if the read fails, the buffer should be all zeros, so we're OK to continue. */ - } - query_registers->mfgid = query_buffer[0]; - query_registers->properties = query_buffer[1]; - query_registers->prod_info[0] = query_buffer[2] & 0x7F; - query_registers->prod_info[1] = query_buffer[3] & 0x7F; - query_registers->date_code[0] = query_buffer[4] & 0x1F; - query_registers->date_code[1] = query_buffer[5] & 0x0F; - query_registers->date_code[2] = query_buffer[6] & 0x1F; - query_registers->tester_id = (((unsigned short) query_buffer[7] & 0x7F) << 7) | (query_buffer[8] & 0x7F); - query_registers->serial_num = (((unsigned short) query_buffer[9] & 0x7F) << 7) | (query_buffer[10] & 0x7F); - memcpy(query_registers->prod_id, &query_buffer[11], 10); - - printk(KERN_DEBUG "%s: RMI4 Protocol Function $01 Query information, rmifninfo->funcDescriptor.queryBaseAddr = %d\n", __func__, rmifninfo->funcDescriptor.queryBaseAddr); - printk(KERN_DEBUG "%s: Manufacturer ID: %d %s\n", __func__, - query_registers->mfgid, query_registers->mfgid == 1 ? "(Synaptics)" : ""); - printk(KERN_DEBUG "%s: Product Properties: 0x%x\n", - __func__, query_registers->properties); - printk(KERN_DEBUG "%s: Product Info: 0x%x 0x%x\n", - __func__, query_registers->prod_info[0], query_registers->prod_info[1]); - printk(KERN_DEBUG "%s: Date Code: Year : %d Month: %d Day: %d\n", - __func__, query_registers->date_code[0], query_registers->date_code[1], - query_registers->date_code[2]); - printk(KERN_DEBUG "%s: Tester ID: %d\n", __func__, query_registers->tester_id); - printk(KERN_DEBUG "%s: Serial Number: 0x%x\n", - __func__, query_registers->serial_num); - printk(KERN_DEBUG "%s: Product ID: %s\n", __func__, query_registers->prod_id); - - /* TODO: size of control registers needs to be computed dynamically. See comment - * in rmi.h. */ - controlRegisters = kzalloc(sizeof(*controlRegisters), GFP_KERNEL); - if (!controlRegisters) { - printk(KERN_ERR "%s: Error allocating memory for F01 control registers.\n", __func__); - retval = -ENOMEM; - goto error_exit; - } - instanceData->controlRegisters = controlRegisters; - retval = rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.controlBaseAddr, - (char *)instanceData->controlRegisters, sizeof(struct rmi_F01_control)); - if (retval) { - printk(KERN_ERR "%s : Could not read F01 control registers at 0x%02x. Error %d.\n", - __func__, rmifninfo->funcDescriptor.controlBaseAddr, retval); - } - - /* TODO: size of data registers needs to be computed dynamically. See comment - * in rmi.h. */ - dataRegisters = kzalloc(sizeof(*dataRegisters), GFP_KERNEL); - if (!dataRegisters) { - printk(KERN_ERR "%s: Error allocating memory for F01 data registers.\n", __func__); - retval = -ENOMEM; - goto error_exit; - } - instanceData->dataRegisters = dataRegisters; - rmifninfo->fndata = instanceData; - - /* Need to get interrupt info to be used later when handling - * interrupts. */ - rmifninfo->interruptRegister = interruptCount/8; - - /* loop through interrupts for each source and or in a bit - * to the interrupt mask for each. */ - InterruptOffset = interruptCount % 8; - - for (i = InterruptOffset; - i < ((fndescr->interruptSrcCnt & 0x7) + InterruptOffset); - i++) { - rmifninfo->interruptMask |= 1 << i; - } - - return retval; - -error_exit: - kfree(instanceData); - kfree(query_registers); - kfree(controlRegisters); - kfree(dataRegisters); - return retval; -} -EXPORT_SYMBOL(FN_01_detect); - -static ssize_t rmi_fn_01_productinfo_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - - if (instance_data && instance_data->query_registers && instance_data->query_registers->prod_info) - return sprintf(buf, "0x%02X 0x%02X\n", instance_data->query_registers->prod_info[0], instance_data->query_registers->prod_info[1]); - - return sprintf(buf, "unknown"); -} - -static ssize_t rmi_fn_01_productinfo_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return -EPERM; -} - - -static ssize_t rmi_fn_01_productid_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - - if (instance_data && instance_data->query_registers && instance_data->query_registers->prod_id) - return sprintf(buf, "%s\n", instance_data->query_registers->prod_id); - - return sprintf(buf, "unknown"); -} - -static ssize_t rmi_fn_01_productid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return -EPERM; -} - -static ssize_t rmi_fn_01_manufacturer_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - - if (instance_data && instance_data->query_registers) - return sprintf(buf, "0x%02X\n", instance_data->query_registers->mfgid); - - return sprintf(buf, "unknown"); -} - -static ssize_t rmi_fn_01_manufacturer_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return -EPERM; -} - -static ssize_t rmi_fn_01_datecode_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - - if (instance_data && instance_data->query_registers && instance_data->query_registers->date_code) - return sprintf(buf, "20%02u-%02u-%02u\n", instance_data->query_registers->date_code[0], instance_data->query_registers->date_code[1], instance_data->query_registers->date_code[2]); - - return sprintf(buf, "unknown"); -} - -static ssize_t rmi_fn_01_datecode_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return -EPERM; -} - -static ssize_t rmi_fn_01_reportrate_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - - if (instance_data && instance_data->query_registers && instance_data->query_registers->date_code) - return sprintf(buf, "%d\n", instance_data->nonstandard_report_rate); - - return sprintf(buf, "unknown"); -} - -static ssize_t rmi_fn_01_reportrate_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - unsigned int new_rate; - int retval; - - printk(KERN_DEBUG "%s: Report rate set to %s", __func__, buf); - - if (sscanf(buf, "%u", &new_rate) != 1) - return -EINVAL; - if (new_rate < 0 || new_rate > 1) - return -EINVAL; - instance_data->nonstandard_report_rate = new_rate; - - retval = set_report_rate(fn->rfi, new_rate); - if (retval < 0) { - printk(KERN_ERR "%s: failed to set report rate bit, error = %d.", __func__, retval); - return retval; - } - - return count; -} - -static ssize_t rmi_fn_01_reset_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return -EPERM; -} - -static ssize_t rmi_fn_01_reset_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - unsigned int reset; - int retval; - - printk(KERN_INFO "%s: Reset written with %s", __func__, buf); - - if (sscanf(buf, "%u", &reset) != 1) - return -EINVAL; - if (reset < 0 || reset > 1) - return -EINVAL; - - /* Per spec, 0 has no effect, so we skip it entirely. */ - if (reset) { - retval = rmi_set_bits(fn->sensor, fn->rfi->funcDescriptor.commandBaseAddr, F01_RESET); - if (retval < 0) { - printk(KERN_ERR "%s: failed to issue reset command, error = %d.", __func__, retval); - return retval; - } - } - - return count; -} - -static ssize_t rmi_fn_01_serialnumber_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - - if (instance_data && instance_data->query_registers) - return sprintf(buf, "%u\n", instance_data->query_registers->serial_num); - - return sprintf(buf, "unknown"); -} - -static ssize_t rmi_fn_01_serialnumber_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return -EPERM; -} - -static ssize_t rmi_fn_01_testerid_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f01_instance_data *instance_data = (struct f01_instance_data *)fn->rfi->fndata; - - if (instance_data && instance_data->query_registers) - return sprintf(buf, "%u\n", instance_data->query_registers->tester_id); - - return sprintf(buf, "unknown"); -} - -static ssize_t rmi_fn_01_testerid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return -EPERM; -} diff --git a/drivers/input/touchscreen/synaptics/rmi_f01.h b/drivers/input/touchscreen/synaptics/rmi_f01.h deleted file mode 100644 index 976e0620ee0e08c919f8050702939070e330c8d6..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f01.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $01 header. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - * There is only one function $01 for each RMI4 sensor. This will be - * the function that is used to set sensor control and configurations - * and check the interrupts to find the source function that is interrupting. - * - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_FUNCTION_01_H -#define _RMI_FUNCTION_01_H - -void FN_01_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs); -int FN_01_config(struct rmi_function_info *rmifninfo); -int FN_01_init(struct rmi_function_device *function_device); -int FN_01_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, - unsigned int interruptCount); -void FN_01_attention(struct rmi_function_info *rmifninfo); -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_f05.c b/drivers/input/touchscreen/synaptics/rmi_f05.c deleted file mode 100644 index 4f209e7fba060cb867f327d05d18f20111057133..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f05.c +++ /dev/null @@ -1,137 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $11 support for 2D. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmi.h" -#include "rmi_drvr.h" -#include "rmi_bus.h" -#include "rmi_sensor.h" -#include "rmi_function.h" -#include "rmi_f05.h" - -struct f05_instance_data { - int dummy; /* TODO: Write this */ -}; - -/* - * There is no attention function for F05 - it is left NULL - * in the function table so it is not called. - * - */ - - -/* - * This reads in a sample and reports the F05 source data to the - * input subsystem. It is used for both polling and interrupt driven - * operation. This is called a lot so don't put in any informational - * printks since they will slow things way down! - */ -void FN_05_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs) -{ -// struct f05_instance_data *instance_data = rmifninfo->fndata; -} -EXPORT_SYMBOL(FN_05_inthandler); - -int FN_05_config(struct rmi_function_info *rmifninfo) -{ - int retval = 0; - - pr_debug("%s: RMI4 F05 config\n", __func__); - - /* TODO: Perform configuration. In particular, write any cached control - * register values to the device. */ - - return retval; -} -EXPORT_SYMBOL(FN_05_config); - -/* Initialize any F05 specific params and settings - input - * settings, device settings, etc. - */ -int FN_05_init(struct rmi_function_device *function_device) -{ - int retval = 0; -// struct f05_instance_data *instance_data = function_device->rfi->fndata; -// struct rmi_f05_functiondata *functiondata = rmi_sensor_get_functiondata(function_device->sensor, RMI_F05_INDEX); - - printk(KERN_DEBUG "%s: RMI4 F05 init\n", __func__); - - return retval; -} -EXPORT_SYMBOL(FN_05_init); - - -int FN_05_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, unsigned int interruptCount) -{ - int retval = 0; - int i; - struct f05_instance_data *instanceData; - int fn05InterruptOffset; - - printk(KERN_DEBUG "%s: RMI4 F05 detect\n", __func__); - - instanceData = kzalloc(sizeof(struct f05_instance_data), GFP_KERNEL); - if (!instanceData) { - printk(KERN_ERR "%s: Error allocating F05 instance data.\n", __func__); - return -ENOMEM; - } - rmifninfo->fndata = instanceData; - - /* Store addresses - used elsewhere to read data, - * control, query, etc. */ - rmifninfo->funcDescriptor.queryBaseAddr = fndescr->queryBaseAddr; - rmifninfo->funcDescriptor.commandBaseAddr = fndescr->commandBaseAddr; - rmifninfo->funcDescriptor.controlBaseAddr = fndescr->controlBaseAddr; - rmifninfo->funcDescriptor.dataBaseAddr = fndescr->dataBaseAddr; - rmifninfo->funcDescriptor.interruptSrcCnt = fndescr->interruptSrcCnt; - rmifninfo->funcDescriptor.functionNum = fndescr->functionNum; - - rmifninfo->numSources = fndescr->interruptSrcCnt; - /* Need to get interrupt info to be used later when handling - interrupts. */ - rmifninfo->interruptRegister = interruptCount/8; - - /* loop through interrupts for each source in fn $11 and or in a bit - to the interrupt mask for each. */ - fn05InterruptOffset = interruptCount % 8; - - for (i = fn05InterruptOffset; - i < ((fndescr->interruptSrcCnt & 0x7) + fn05InterruptOffset); - i++) - rmifninfo->interruptMask |= 1 << i; - - return retval; -} -EXPORT_SYMBOL(FN_05_detect); diff --git a/drivers/input/touchscreen/synaptics/rmi_f05.h b/drivers/input/touchscreen/synaptics/rmi_f05.h deleted file mode 100644 index b820e715936483c9ec107510b9ca548a256e950b..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f05.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $11 header. - * Copyright (c) 2007 - 2010, Synaptics Incorporated - * - * For every RMI4 function that has a data source - like 2D sensors, - * buttons, LEDs, GPIOs, etc. - the user will create a new rmi_function_xx.c - * file and add these functions to perform the config(), init(), report() - * and detect() functionality. The function pointers are then srored under - * the RMI function info and these functions will automatically be called by - * the global config(), init(), report() and detect() functions that will - * loop through all data sources and call the data sources functions using - * these functions pointed to by the function ptrs. - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_FUNCTION_05_H -#define _RMI_FUNCTION_05_H - -void FN_05_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs); -int FN_05_config(struct rmi_function_info *rmifninfo); -int FN_05_init(struct rmi_function_device *function_device); -int FN_05_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, - unsigned int interruptCount); -/* No attention function for F05 */ -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_f11.c b/drivers/input/touchscreen/synaptics/rmi_f11.c deleted file mode 100644 index b75b3e0cee858b84604ac03ddd4deac2246c0339..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f11.c +++ /dev/null @@ -1,913 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $11 support for 2D. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmi.h" -#include "rmi_drvr.h" -#include "rmi_bus.h" -#include "rmi_sensor.h" -#include "rmi_function.h" -#include "rmi_f11.h" - -static int sensorMaxX; -static int sensorMaxY; - -struct f11_instance_data { - struct rmi_F11_device_query *deviceInfo; - struct rmi_F11_sensor_query *sensorInfo; - struct rmi_F11_control *controlRegisters; - int button_height; - unsigned char fingerDataBufferSize; - unsigned char absDataOffset; - unsigned char absDataSize; - unsigned char relDataOffset; - unsigned char gestureDataOffset; - unsigned char *fingerDataBuffer; - /* Last X & Y seen, needed at finger lift. Was down indicates at least one finger was here. */ - /* TODO: Eventually we'll need to track this info on a per finger basis. */ - bool wasdown; - unsigned int oldX; - unsigned int oldY; - /* Transformations to be applied to coordinates before reporting. */ - bool flipX; - bool flipY; - int offsetX; - int offsetY; - int clipXLow; - int clipXHigh; - int clipYLow; - int clipYHigh; - bool swap_axes; - bool relReport; -}; - -enum f11_finger_state { - F11_NO_FINGER = 0, - F11_PRESENT = 1, - F11_INACCURATE = 2, - F11_RESERVED = 3 -}; - -static ssize_t rmi_fn_11_flip_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_11_flip_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(flip, 0664, rmi_fn_11_flip_show, rmi_fn_11_flip_store); /* RW attr */ - -static ssize_t rmi_fn_11_clip_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_11_clip_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(clip, 0664, rmi_fn_11_clip_show, rmi_fn_11_clip_store); /* RW attr */ - -static ssize_t rmi_fn_11_offset_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_11_offset_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(offset, 0664, rmi_fn_11_offset_show, rmi_fn_11_offset_store); /* RW attr */ - -static ssize_t rmi_fn_11_swap_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_11_swap_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(swap, 0664, rmi_fn_11_swap_show, rmi_fn_11_swap_store); /* RW attr */ - -static ssize_t rmi_fn_11_relreport_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_11_relreport_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(relreport, 0664, rmi_fn_11_relreport_show, rmi_fn_11_relreport_store); /* RW attr */ - -static ssize_t rmi_fn_11_maxPos_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_11_maxPos_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(maxPos, 0664, rmi_fn_11_maxPos_show, rmi_fn_11_maxPos_store); /* RW attr */ - - -static void FN_11_relreport(struct rmi_function_info *rmifninfo); - -/* - * There is no attention function for Fn $11 - it is left NULL - * in the function table so it is not called. - * - */ - - -/* - * This reads in a sample and reports the function $11 source data to the - * input subsystem. It is used for both polling and interrupt driven - * operation. This is called a lot so don't put in any informational - * printks since they will slow things way down! - */ -void FN_11_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs) -{ - /* number of touch points - fingers down in this case */ - int fingerDownCount; - int finger; - struct rmi_function_device *function_device; - struct f11_instance_data *instanceData; - - instanceData = (struct f11_instance_data *) rmifninfo->fndata; - - fingerDownCount = 0; - function_device = rmifninfo->function_device; - - /* get 2D sensor finger data */ - - if (rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.dataBaseAddr, - instanceData->fingerDataBuffer, instanceData->fingerDataBufferSize)) { - printk(KERN_ERR "%s: Failed to read finger data registers.\n", __func__); - return; - } - - /* First we need to count the fingers and generate some events related to that. */ - for (finger = 0; finger < instanceData->sensorInfo->numberOfFingers; finger++) { - int reg; - int fingerShift; - int fingerStatus; - - /* determine which data byte the finger status is in */ - reg = finger/4; - /* bit shift to get finger's status */ - fingerShift = (finger % 4) * 2; - fingerStatus = (instanceData->fingerDataBuffer[reg] >> fingerShift) & 3; - - if (fingerStatus == F11_PRESENT || fingerStatus == F11_INACCURATE) { - fingerDownCount++; - instanceData->wasdown = true; - } - } - input_report_key(function_device->input, - BTN_TOUCH, !!fingerDownCount); - - for (finger = 0; finger < instanceData->sensorInfo->numberOfFingers; finger++) { - int reg; - int fingerShift; - int fingerStatus; - int X = 0, Y = 0, Z = 0, Wy = 0, Wx = 0; - - /* determine which data byte the finger status is in */ - reg = finger/4; - /* bit shift to get finger's status */ - fingerShift = (finger % 4) * 2; - fingerStatus = (instanceData->fingerDataBuffer[reg] >> fingerShift) & 3; - - /* if finger status indicates a finger is present then - read the finger data and report it */ - if (fingerStatus == F11_PRESENT || fingerStatus == F11_INACCURATE) { - - if (instanceData->sensorInfo->hasAbs) { - int maxX = instanceData->controlRegisters->sensorMaxXPos; - int maxY = instanceData->controlRegisters->sensorMaxYPos; - reg = instanceData->absDataOffset + (finger * instanceData->absDataSize); - X = (instanceData->fingerDataBuffer[reg] << 4) & 0x0ff0; - X |= (instanceData->fingerDataBuffer[reg+2] & 0x0f); - Y = (instanceData->fingerDataBuffer[reg+1] << 4) & 0x0ff0; - Y |= ((instanceData->fingerDataBuffer[reg+2] & 0xf0) >> 4) & 0x0f; - /* First thing to do is swap axes if needed. - */ - if (instanceData->swap_axes) { - int temp = X; - X = Y; - Y = temp; - maxX = instanceData->controlRegisters->sensorMaxYPos; - maxY = instanceData->controlRegisters->sensorMaxXPos; - } - if (instanceData->flipX) - X = max(maxX-X, 0); - X = X - instanceData->offsetX; - X = min(max(X, instanceData->clipXLow), instanceData->clipXHigh); - if (instanceData->flipY) - Y = max(maxY-Y, 0); - Y = Y - instanceData->offsetY; - Y = min(max(Y, instanceData->clipYLow), instanceData->clipYHigh); - - /* upper 4 bits of W are Wy, - lower 4 of W are Wx */ - Wy = (instanceData->fingerDataBuffer[reg+3] >> 4) & 0x0f; - Wx = instanceData->fingerDataBuffer[reg+3] & 0x0f; - if (instanceData->swap_axes) { - int temp = Wx; - Wx = Wy; - Wy = temp; - } - - Z = instanceData->fingerDataBuffer[reg+4]; - - /* if this is the first finger report normal - ABS_X, ABS_Y, PRESSURE, TOOL_WIDTH events for - non-MT apps. Apps that support Multi-touch - will ignore these events and use the MT events. - Apps that don't support Multi-touch will still - function. - */ - if (fingerDownCount == 1) { - instanceData->oldX = X; - instanceData->oldY = Y; - input_report_abs(function_device->input, ABS_X, X); - input_report_abs(function_device->input, ABS_Y, Y); - input_report_abs(function_device->input, ABS_PRESSURE, Z); - input_report_abs(function_device->input, ABS_TOOL_WIDTH, - max(Wx, Wy)); - - } else { - /* TODO generate non MT events for multifinger situation. */ - } -#ifdef CONFIG_SYNA_MULTI_TOUCH - /* Report Multi-Touch events for each finger */ - input_report_abs(function_device->input, - ABS_MT_PRESSURE, Z); - input_report_abs(function_device->input, ABS_MT_POSITION_X, X); - input_report_abs(function_device->input, ABS_MT_POSITION_Y, Y); - - /* TODO: Tracking ID needs to be reported but not used yet. */ - /* Could be formed by keeping an id per position and assiging */ - /* a new id when fingerStatus changes for that position.*/ - input_report_abs(function_device->input, ABS_MT_TRACKING_ID, - finger); - /* MT sync between fingers */ - input_mt_sync(function_device->input); -#endif - } - } - } - - /* if we had a finger down before and now we don't have any send a button up. */ - if ((fingerDownCount == 0) && instanceData->wasdown) { - instanceData->wasdown = false; - -#ifdef CONFIG_SYNA_MULTI_TOUCH - input_report_abs(function_device->input, ABS_MT_PRESSURE, 0); - input_report_key(function_device->input, BTN_TOUCH, 0); - input_mt_sync(function_device->input); -#endif - } - - FN_11_relreport(rmifninfo); - input_sync(function_device->input); /* sync after groups of events */ - -} -EXPORT_SYMBOL(FN_11_inthandler); - -/* This function reads in relative data for first finger and send to input system */ -static void FN_11_relreport(struct rmi_function_info *rmifninfo) -{ - struct f11_instance_data *instanceData; - struct rmi_function_device *function_device; - signed char X, Y; - unsigned short fn11DataBaseAddr; - - instanceData = (struct f11_instance_data *) rmifninfo->fndata; - - if (instanceData->sensorInfo->hasRel && instanceData->relReport) { - int reg = instanceData->relDataOffset; - - function_device = rmifninfo->function_device; - - fn11DataBaseAddr = rmifninfo->funcDescriptor.dataBaseAddr; - /* Read and report Rel data for primary finger one register for X and one for Y*/ - X = instanceData->fingerDataBuffer[reg]; - Y = instanceData->fingerDataBuffer[reg+1]; - if (instanceData->swap_axes) { - signed char temp = X; - X = Y; - Y = temp; - } - if (instanceData->flipX) { - X = -X; - } - if (instanceData->flipY) { - Y = -Y; - } - X = (signed char) min(127, max(-128, (int) X)); - Y = (signed char) min(127, max(-128, (int) Y)); - - input_report_rel(function_device->input, REL_X, X); - input_report_rel(function_device->input, REL_Y, Y); - } -} - -int FN_11_config(struct rmi_function_info *rmifninfo) -{ - /* For the data source - print info and do any - source specific configuration. */ - unsigned char data[14]; - int retval = 0; - - pr_debug("%s: RMI4 function $11 config\n", __func__); - - /* Get and print some info about the data source... */ - - /* To Query 2D devices we need to read from the address obtained - * from the function descriptor stored in the RMI function info. - */ - retval = rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.queryBaseAddr, - data, 9); - if (retval) { - printk(KERN_ERR "%s: RMI4 function $11 config:" - "Could not read function query registers 0x%x\n", - __func__, rmifninfo->funcDescriptor.queryBaseAddr); - } else { - pr_debug("%s: Number of Fingers: %d\n", - __func__, data[1] & 7); - pr_debug("%s: Is Configurable: %d\n", - __func__, data[1] & (1 << 7) ? 1 : 0); - pr_debug("%s: Has Gestures: %d\n", - __func__, data[1] & (1 << 5) ? 1 : 0); - pr_debug("%s: Has Absolute: %d\n", - __func__, data[1] & (1 << 4) ? 1 : 0); - pr_debug("%s: Has Relative: %d\n", - __func__, data[1] & (1 << 3) ? 1 : 0); - - pr_debug("%s: Number X Electrodes: %d\n", - __func__, data[2] & 0x1f); - pr_debug("%s: Number Y Electrodes: %d\n", - __func__, data[3] & 0x1f); - pr_debug("%s: Maximum Electrodes: %d\n", - __func__, data[4] & 0x1f); - - pr_debug("%s: Absolute Data Size: %d\n", - __func__, data[5] & 3); - - pr_debug("%s: Has XY Dist: %d\n", - __func__, data[7] & (1 << 7) ? 1 : 0); - pr_debug("%s: Has Pinch: %d\n", - __func__, data[7] & (1 << 6) ? 1 : 0); - pr_debug("%s: Has Press: %d\n", - __func__, data[7] & (1 << 5) ? 1 : 0); - pr_debug("%s: Has Flick: %d\n", - __func__, data[7] & (1 << 4) ? 1 : 0); - pr_debug("%s: Has Early Tap: %d\n", - __func__, data[7] & (1 << 3) ? 1 : 0); - pr_debug("%s: Has Double Tap: %d\n", - __func__, data[7] & (1 << 2) ? 1 : 0); - pr_debug("%s: Has Tap and Hold: %d\n", - __func__, data[7] & (1 << 1) ? 1 : 0); - pr_debug("%s: Has Tap: %d\n", - __func__, data[7] & 1 ? 1 : 0); - pr_debug("%s: Has Palm Detect: %d\n", - __func__, data[8] & 1 ? 1 : 0); - pr_debug("%s: Has Rotate: %d\n", - __func__, data[8] & (1 << 1) ? 1 : 0); - - retval = rmi_read_multiple(rmifninfo->sensor, - rmifninfo->funcDescriptor.controlBaseAddr, data, 14); - if (retval) { - printk(KERN_ERR "%s: RMI4 function $11 config:" - "Could not read control registers 0x%x\n", - __func__, rmifninfo->funcDescriptor.controlBaseAddr); - return retval; - } - - /* Store these for use later...*/ - sensorMaxX = ((data[6] & 0x1f) << 8) | ((data[7] & 0xff) << 0); - sensorMaxY = ((data[8] & 0x1f) << 8) | ((data[9] & 0xff) << 0); - - pr_debug("%s: Sensor Max X: %d\n", __func__, sensorMaxX); - pr_debug("%s: Sensor Max Y: %d\n", __func__, sensorMaxY); - } - - return retval; -} -EXPORT_SYMBOL(FN_11_config); - -/* This operation is done in a number of places, so we have a handy routine - * for it. - */ -static void f11_set_abs_params(struct rmi_function_device *function_device) -{ - struct f11_instance_data *instance_data = function_device->rfi->fndata; - /* Use the max X and max Y read from the device, or the clip values, - * whichever is stricter. - */ - int xMin = instance_data->clipXLow; - int xMax = min((int) instance_data->controlRegisters->sensorMaxXPos, instance_data->clipXHigh); - int yMin = instance_data->clipYLow; - int yMax = min((int) instance_data->controlRegisters->sensorMaxYPos, instance_data->clipYHigh) - instance_data->button_height; - if (instance_data->swap_axes) { - int temp = xMin; - xMin = yMin; - yMin = temp; - temp = xMax; - xMax = yMax; - yMax = temp; - } - printk(KERN_DEBUG "%s: Set ranges X=[%d..%d] Y=[%d..%d].", __func__, xMin, xMax, yMin, yMax); - input_set_abs_params(function_device->input, ABS_X, xMin, xMax, - 0, 0); - input_set_abs_params(function_device->input, ABS_Y, yMin, yMax, - 0, 0); - input_set_abs_params(function_device->input, ABS_PRESSURE, 0, 255, 0, 0); - input_set_abs_params(function_device->input, ABS_TOOL_WIDTH, 0, 15, 0, 0); - -#ifdef CONFIG_SYNA_MULTI_TOUCH - input_set_abs_params(function_device->input, ABS_MT_PRESSURE, - 0, 15, 0, 0); - input_set_abs_params(function_device->input, ABS_MT_ORIENTATION, 0, 1, 0, 0); - input_set_abs_params(function_device->input, ABS_MT_TRACKING_ID, - 0, 10, 0, 0); - input_set_abs_params(function_device->input, ABS_MT_POSITION_X, xMin, xMax, - 0, 0); - input_set_abs_params(function_device->input, ABS_MT_POSITION_Y, yMin, yMax, - 0, 0); -#endif -} - -/* Initialize any function $11 specific params and settings - input - * settings, device settings, etc. - */ -int FN_11_init(struct rmi_function_device *function_device) -{ - struct f11_instance_data *instanceData = function_device->rfi->fndata; - int retval = 0; - struct rmi_f11_functiondata *functiondata = rmi_sensor_get_functiondata(function_device->sensor, RMI_F11_INDEX); - printk(KERN_DEBUG "%s: RMI4 F11 init", __func__); - - /* TODO: Initialize these through some normal kernel mechanism. - */ - instanceData->flipX = false; - instanceData->flipY = false; - instanceData->swap_axes = false; - instanceData->relReport = true; - instanceData->offsetX = instanceData->offsetY = 0; - instanceData->clipXLow = instanceData->clipYLow = 0; - /* TODO: 65536 should actually be the largest valid RMI4 position coordinate */ - instanceData->clipXHigh = instanceData->clipYHigh = 65536; - - /* Load any overrides that were specified via platform data. - */ - if (functiondata) { - printk(KERN_DEBUG "%s: found F11 per function platformdata.", __func__); - instanceData->flipX = functiondata->flipX; - instanceData->flipY = functiondata->flipY; - instanceData->button_height = functiondata->button_height; - instanceData->swap_axes = functiondata->swap_axes; - if (functiondata->offset) { - instanceData->offsetX = functiondata->offset->x; - instanceData->offsetY = functiondata->offset->y; - } - if (functiondata->clipX) { - if (functiondata->clipX->min >= functiondata->clipX->max) { - printk(KERN_WARNING "%s: Clip X min (%d) >= X clip max (%d) - ignored.", - __func__, functiondata->clipX->min, functiondata->clipX->max); - } else { - instanceData->clipXLow = functiondata->clipX->min; - instanceData->clipXHigh = functiondata->clipX->max; - } - } - if (functiondata->clipY) { - if (functiondata->clipY->min >= functiondata->clipY->max) { - printk(KERN_WARNING "%s: Clip Y min (%d) >= Y clip max (%d) - ignored.", - __func__, functiondata->clipY->min, functiondata->clipY->max); - } else { - instanceData->clipYLow = functiondata->clipY->min; - instanceData->clipYHigh = functiondata->clipY->max; - } - } - } - - /* need to init the input abs params for the 2D */ - set_bit(EV_ABS, function_device->input->evbit); - set_bit(EV_SYN, function_device->input->evbit); - set_bit(EV_KEY, function_device->input->evbit); - set_bit(BTN_TOUCH, function_device->input->keybit); - set_bit(KEY_OK, function_device->input->keybit); - - f11_set_abs_params(function_device); - - printk(KERN_DEBUG "%s: Creating sysfs files.", __func__); - retval = device_create_file(&function_device->dev, &dev_attr_flip); - if (retval) { - printk(KERN_ERR "%s: Failed to create flip.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_clip); - if (retval) { - printk(KERN_ERR "%s: Failed to create clip.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_offset); - if (retval) { - printk(KERN_ERR "%s: Failed to create offset.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_swap); - if (retval) { - printk(KERN_ERR "%s: Failed to create swap.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_relreport); - if (retval) { - printk(KERN_ERR "%s: Failed to create relreport.", __func__); - return retval; - } - retval = device_create_file(&function_device->dev, &dev_attr_maxPos); - if (retval) { - printk(KERN_ERR "%s: Failed to create maxPos.", __func__); - return retval; - } - - return 0; -} -EXPORT_SYMBOL(FN_11_init); - -int FN_11_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, unsigned int interruptCount) -{ - unsigned char fn11Queries[12]; /* TODO: Compute size correctly. */ - unsigned char fn11Control[12]; /* TODO: Compute size correctly. */ - int i; - unsigned short fn11InterruptOffset; - unsigned char fn11AbsDataBlockSize; - int fn11HasPinch, fn11HasFlick, fn11HasTap; - int fn11HasTapAndHold, fn11HasDoubleTap; - int fn11HasEarlyTap, fn11HasPress; - int fn11HasPalmDetect, fn11HasRotate; - int fn11HasRel; - unsigned char f11_egr_0, f11_egr_1; - unsigned int fn11AllDataBlockSize; - int retval = 0; - struct f11_instance_data *instanceData; - - printk(KERN_DEBUG "%s: RMI4 F11 detect\n", __func__); - - instanceData = kzalloc(sizeof(struct f11_instance_data), GFP_KERNEL); - if (!instanceData) { - printk(KERN_ERR "%s: Error allocating F11 instance data.\n", __func__); - return -ENOMEM; - } - instanceData->deviceInfo = kzalloc(sizeof(struct rmi_F11_device_query), GFP_KERNEL); - if (!instanceData->deviceInfo) { - printk(KERN_ERR "%s: Error allocating F11 device query.\n", __func__); - return -ENOMEM; - } - instanceData->sensorInfo = kzalloc(sizeof(struct rmi_F11_sensor_query), GFP_KERNEL); - if (!instanceData->sensorInfo) { - printk(KERN_ERR "%s: Error allocating F11 sensor query.\n", __func__); - return -ENOMEM; - } - rmifninfo->fndata = instanceData; - - /* Store addresses - used elsewhere to read data, - * control, query, etc. */ - rmifninfo->funcDescriptor.queryBaseAddr = fndescr->queryBaseAddr; - rmifninfo->funcDescriptor.commandBaseAddr = fndescr->commandBaseAddr; - rmifninfo->funcDescriptor.controlBaseAddr = fndescr->controlBaseAddr; - rmifninfo->funcDescriptor.dataBaseAddr = fndescr->dataBaseAddr; - rmifninfo->funcDescriptor.interruptSrcCnt = fndescr->interruptSrcCnt; - rmifninfo->funcDescriptor.functionNum = fndescr->functionNum; - - rmifninfo->numSources = fndescr->interruptSrcCnt; - - /* need to get number of fingers supported, data size, etc. - - to be used when getting data since the number of registers to - read depends on the number of fingers supported and data size. */ - retval = rmi_read_multiple(rmifninfo->sensor, fndescr->queryBaseAddr, fn11Queries, - sizeof(fn11Queries)); - if (retval) { - printk(KERN_ERR "%s: RMI4 function $11 detect: " - "Could not read function query registers 0x%x\n", - __func__, rmifninfo->funcDescriptor.queryBaseAddr); - return retval; - } - - /* Extract device data. */ - instanceData->deviceInfo->hasQuery9 = (fn11Queries[0] & 0x04) != 0; - instanceData->deviceInfo->numberOfSensors = (fn11Queries[0] & 0x07) + 1; - printk(KERN_DEBUG "%s: F11 device - %d sensors. Query 9? %d.", __func__, instanceData->deviceInfo->numberOfSensors, instanceData->deviceInfo->hasQuery9); - - /* Extract sensor data. */ - /* 2D data sources have only 3 bits for the number of fingers - supported - so the encoding is a bit wierd. */ - instanceData->sensorInfo->numberOfFingers = 2; /* default number of fingers supported */ - if ((fn11Queries[1] & 0x7) <= 4) - /* add 1 since zero based */ - instanceData->sensorInfo->numberOfFingers = (fn11Queries[1] & 0x7) + 1; - else { - /* a value of 5 is up to 10 fingers - 6 and 7 are reserved - (shouldn't get these i int retval;n a normal 2D source). */ - if ((fn11Queries[1] & 0x7) == 5) - instanceData->sensorInfo->numberOfFingers = 10; - } - instanceData->sensorInfo->configurable = (fn11Queries[1] & 0x80) != 0; - instanceData->sensorInfo->hasSensitivityAdjust = (fn11Queries[1] & 0x40) != 0; - instanceData->sensorInfo->hasGestures = (fn11Queries[1] & 0x20) != 0; - instanceData->sensorInfo->hasAbs = (fn11Queries[1] & 0x10) != 0; - instanceData->sensorInfo->hasRel = (fn11Queries[1] & 0x08) != 0; - instanceData->sensorInfo->absDataSize = fn11Queries[5] & 0x03; - printk(KERN_DEBUG "%s: Number of fingers: %d.", __func__, instanceData->sensorInfo->numberOfFingers); - - /* Need to get interrupt info to be used later when handling - interrupts. */ - rmifninfo->interruptRegister = interruptCount/8; - - /* loop through interrupts for each source in fn $11 and or in a bit - to the interrupt mask for each. */ - fn11InterruptOffset = interruptCount % 8; - - for (i = fn11InterruptOffset; - i < ((fndescr->interruptSrcCnt & 0x7) + fn11InterruptOffset); - i++) - rmifninfo->interruptMask |= 1 << i; - - /* Figure out just how much data we'll need to read. */ - instanceData->fingerDataBufferSize = (instanceData->sensorInfo->numberOfFingers + 3) / 4; - /* One each for X and Y, one for LSB for X & Y, one for W, one for Z */ - fn11AbsDataBlockSize = 5; - if (instanceData->sensorInfo->absDataSize != 0) - printk(KERN_WARNING "%s: Unrecognized abs data size %d ignored.", __func__, instanceData->sensorInfo->absDataSize); - if (instanceData->sensorInfo->hasAbs) { - instanceData->absDataSize = fn11AbsDataBlockSize; - instanceData->absDataOffset = instanceData->fingerDataBufferSize; - instanceData->fingerDataBufferSize += instanceData->sensorInfo->numberOfFingers * fn11AbsDataBlockSize; - } - if (instanceData->sensorInfo->hasRel) { - instanceData->relDataOffset = ((instanceData->sensorInfo->numberOfFingers + 3) / 4) + - /* absolute data, per finger times number of fingers */ - (fn11AbsDataBlockSize * instanceData->sensorInfo->numberOfFingers); - instanceData->fingerDataBufferSize += instanceData->sensorInfo->numberOfFingers * 2; - } - if (instanceData->sensorInfo->hasGestures) { - instanceData->gestureDataOffset = instanceData->fingerDataBufferSize; - printk(KERN_WARNING "%s: WARNING Need to correctly compute gesture data location.", __func__); - } - - /* need to determine the size of data to read - this depends on - conditions such as whether Relative data is reported and if Gesture - data is reported. */ - f11_egr_0 = fn11Queries[7]; - f11_egr_1 = fn11Queries[8]; - - /* Get info about what EGR data is supported, whether it has - Relative data supported, etc. */ - fn11HasPinch = f11_egr_0 & 0x40; - fn11HasFlick = f11_egr_0 & 0x10; - fn11HasTap = f11_egr_0 & 0x01; - fn11HasTapAndHold = f11_egr_0 & 0x02; - fn11HasDoubleTap = f11_egr_0 & 0x04; - fn11HasEarlyTap = f11_egr_0 & 0x08; - fn11HasPress = f11_egr_0 & 0x20; - fn11HasPalmDetect = f11_egr_1 & 0x01; - fn11HasRotate = f11_egr_1 & 0x02; - fn11HasRel = fn11Queries[1] & 0x08; - - /* Size of all data including finger status, absolute data for each - finger, relative data and EGR data */ - fn11AllDataBlockSize = - /* finger status, four fingers per register */ - ((instanceData->sensorInfo->numberOfFingers + 3) / 4) + - /* absolute data, per finger times number of fingers */ - (fn11AbsDataBlockSize * instanceData->sensorInfo->numberOfFingers) + - /* two relative registers (if relative is being reported) */ - 2 * fn11HasRel + - /* F11_2D_Data8 is only present if the egr_0 - register is non-zero. */ - !!(f11_egr_0) + - /* F11_2D_Data9 is only present if either egr_0 or - egr_1 registers are non-zero. */ - (f11_egr_0 || f11_egr_1) + - /* F11_2D_Data10 is only present if EGR_PINCH or EGR_FLICK of - egr_0 reports as 1. */ - !!(fn11HasPinch | fn11HasFlick) + - /* F11_2D_Data11 and F11_2D_Data12 are only present if - EGR_FLICK of egr_0 reports as 1. */ - 2 * !!(fn11HasFlick); - instanceData->fingerDataBuffer = kcalloc(instanceData->fingerDataBufferSize, sizeof(unsigned char), GFP_KERNEL); - if (!instanceData->fingerDataBuffer) { - printk(KERN_ERR "%s: Failed to allocate finger data buffer.", __func__); - return -ENOMEM; - } - - /* Grab a copy of the control registers. */ - instanceData->controlRegisters = kzalloc(sizeof(struct rmi_F11_control), GFP_KERNEL); - if (!instanceData->controlRegisters) { - printk(KERN_ERR "%s: Error allocating F11 control registers.\n", __func__); - return -ENOMEM; - } - retval = rmi_read_multiple(rmifninfo->sensor, fndescr->controlBaseAddr, - fn11Control, sizeof(fn11Control)); - if (retval) { - printk(KERN_ERR "%s: Failed to read F11 control registers.", __func__); - return retval; - } - instanceData->controlRegisters->sensorMaxXPos = (((int) fn11Control[7] & 0x0F) << 8) + fn11Control[6]; - instanceData->controlRegisters->sensorMaxYPos = (((int) fn11Control[9] & 0x0F) << 8) + fn11Control[8]; - printk(KERN_DEBUG "%s: Max X %d Max Y %d", __func__, instanceData->controlRegisters->sensorMaxXPos, instanceData->controlRegisters->sensorMaxYPos); - return 0; -} -EXPORT_SYMBOL(FN_11_detect); - -static ssize_t rmi_fn_11_maxPos_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - - return sprintf(buf, "%u %u\n", instance_data->controlRegisters->sensorMaxXPos, instance_data->controlRegisters->sensorMaxYPos); -} - -static ssize_t rmi_fn_11_maxPos_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return -EPERM; -} - -static ssize_t rmi_fn_11_flip_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - - return sprintf(buf, "%u %u\n", instance_data->flipX, instance_data->flipY); -} - -static ssize_t rmi_fn_11_flip_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - unsigned int newX, newY; - - printk(KERN_DEBUG "%s: Flip set to %s", __func__, buf); - - if (sscanf(buf, "%u %u", &newX, &newY) != 2) - return -EINVAL; - if (newX < 0 || newX > 1 || newY < 0 || newY > 1) - return -EINVAL; - instance_data->flipX = newX; - instance_data->flipY = newY; - - return count; -} - -static ssize_t rmi_fn_11_swap_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - - return sprintf(buf, "%u\n", instance_data->swap_axes); -} - -static ssize_t rmi_fn_11_swap_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - unsigned int newSwap; - - printk(KERN_DEBUG "%s: Swap set to %s", __func__, buf); - - if (sscanf(buf, "%u", &newSwap) != 1) - return -EINVAL; - if (newSwap < 0 || newSwap > 1) - return -EINVAL; - instance_data->swap_axes = newSwap; - - f11_set_abs_params(fn); - - return count; -} - -static ssize_t rmi_fn_11_relreport_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - - return sprintf(buf, "%u \n", instance_data->relReport); -} - -static ssize_t rmi_fn_11_relreport_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - unsigned int relRep; - - printk(KERN_DEBUG "%s: relReport set to %s", __func__, buf); - if (sscanf(buf, "%u", &relRep) != 1) - return -EINVAL; - if (relRep < 0 || relRep > 1) - return -EINVAL; - instance_data->relReport = relRep; - - return count; -} - -static ssize_t rmi_fn_11_offset_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - - return sprintf(buf, "%d %d\n", instance_data->offsetX, instance_data->offsetY); -} - -static ssize_t rmi_fn_11_offset_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - int newX, newY; - - printk(KERN_DEBUG "%s: Offset set to %s", __func__, buf); - - if (sscanf(buf, "%d %d", &newX, &newY) != 2) - return -EINVAL; - instance_data->offsetX = newX; - instance_data->offsetY = newY; - - return count; -} - -static ssize_t rmi_fn_11_clip_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - - return sprintf(buf, "%u %u %u %u\n", - instance_data->clipXLow, instance_data->clipXHigh, - instance_data->clipYLow, instance_data->clipYHigh); -} - -static ssize_t rmi_fn_11_clip_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f11_instance_data *instance_data = (struct f11_instance_data *)fn->rfi->fndata; - unsigned int newXLow, newXHigh, newYLow, newYHigh; - - printk(KERN_DEBUG "%s: Clip set to %s", __func__, buf); - - if (sscanf(buf, "%u %u %u %u", &newXLow, &newXHigh, &newYLow, &newYHigh) != 4) - return -EINVAL; - if (newXLow < 0 || newXLow >= newXHigh || newYLow < 0 || newYLow >= newYHigh) - return -EINVAL; - instance_data->clipXLow = newXLow; - instance_data->clipXHigh = newXHigh; - instance_data->clipYLow = newYLow; - instance_data->clipYHigh = newYHigh; - - f11_set_abs_params(fn); - - return count; -} diff --git a/drivers/input/touchscreen/synaptics/rmi_f11.h b/drivers/input/touchscreen/synaptics/rmi_f11.h deleted file mode 100644 index 0bf386aea166021fe98c319402773245f6bdf724..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f11.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $11 header. - * Copyright (c) 2007 - 2010, Synaptics Incorporated - * - * For every RMI4 function that has a data source - like 2D sensors, - * buttons, LEDs, GPIOs, etc. - the user will create a new rmi_function_xx.c - * file and add these functions to perform the config(), init(), report() - * and detect() functionality. The function pointers are then srored under - * the RMI function info and these functions will automatically be called by - * the global config(), init(), report() and detect() functions that will - * loop through all data sources and call the data sources functions using - * these functions pointed to by the function ptrs. - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_FUNCTION_11_H -#define _RMI_FUNCTION_11_H - -void FN_11_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs); -int FN_11_config(struct rmi_function_info *rmifninfo); -int FN_11_init(struct rmi_function_device *function_device); -int FN_11_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, - unsigned int interruptCount); -/* No attention function for Fn $11 */ -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_f19.c b/drivers/input/touchscreen/synaptics/rmi_f19.c deleted file mode 100644 index 7bb8712aa8680596b63f9992dd2f36e422d0c738..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f19.c +++ /dev/null @@ -1,514 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $11 support for 2D. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmi.h" -#include "rmi_drvr.h" -#include "rmi_bus.h" -#include "rmi_sensor.h" -#include "rmi_function.h" -#include "rmi_f19.h" - -struct f19_instance_data { - struct rmi_F19_query *deviceInfo; - struct rmi_F19_control *controlRegisters; - bool *buttonDown; - unsigned char buttonDataBufferSize; - unsigned char *buttonDataBuffer; - unsigned char *buttonMap; - int fn19ControlRegisterSize; - int fn19regCountForBitPerButton; - int fn19btnUsageandfilterModeOffset; - int fn19intEnableOffset; - int fn19intEnableLen; - int fn19singleBtnCtrlLen; - int fn19singleBtnCtrlOffset; - int fn19sensorMapCtrlOffset; - int fn19sensorMapCtrlLen; - int fn19singleBtnSensOffset; - int fn19singleBtnSensLen; - int fn19globalSensOffset; - int fn19globalHystThreshOffset; -}; - -static ssize_t rmi_f19_buttonCount_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_f19_buttonCount_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(buttonCount, 0444, rmi_f19_buttonCount_show, rmi_f19_buttonCount_store); /* RO attr */ - -static ssize_t rmi_f19_buttonMap_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_f19_buttonMap_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -DEVICE_ATTR(buttonMap, 0664, rmi_f19_buttonMap_show, rmi_f19_buttonMap_store); /* RW attr */ - - -/* - * There is no attention function for F19 - it is left NULL - * in the function table so it is not called. - * - */ - - -/* - * This reads in a sample and reports the F19 source data to the - * input subsystem. It is used for both polling and interrupt driven - * operation. This is called a lot so don't put in any informational - * printks since they will slow things way down! - */ -void FN_19_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs) -{ - struct rmi_function_device *function_device; - struct f19_instance_data *instanceData; - int button; - - instanceData = (struct f19_instance_data *) rmifninfo->fndata; - - function_device = rmifninfo->function_device; - - /* Read the button data. */ - - if (rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.dataBaseAddr, - instanceData->buttonDataBuffer, instanceData->buttonDataBufferSize)) { - printk(KERN_ERR "%s: Failed to read button data registers.\n", __func__); - return; - } - - /* Generate events for buttons that change state. */ - for (button = 0; button < instanceData->deviceInfo->buttonCount; button++) { - int buttonReg; - int buttonShift; - bool buttonStatus; - - /* determine which data byte the button status is in */ - buttonReg = button/4; - /* bit shift to get button's status */ - buttonShift = button % 8; - buttonStatus = ((instanceData->buttonDataBuffer[buttonReg] >> buttonShift) & 0x01) != 0; - - /* if the button state changed from the last time report it and store the new state */ - if (buttonStatus != instanceData->buttonDown[button]) { - printk(KERN_DEBUG "%s: Button %d (code %d) -> %d.", __func__, button, instanceData->buttonMap[button], buttonStatus); - /* Generate an event here. */ - input_report_key(function_device->input, - instanceData->buttonMap[button], buttonStatus); - instanceData->buttonDown[button] = buttonStatus; - } - } - - input_sync(function_device->input); /* sync after groups of events */ -} -EXPORT_SYMBOL(FN_19_inthandler); - -int FN_19_config(struct rmi_function_info *rmifninfo) -{ - int retval = 0; - - pr_debug("%s: RMI4 F19 config\n", __func__); - - /* TODO: Perform configuration. In particular, write any cached control - * register values to the device. */ - - return retval; -} -EXPORT_SYMBOL(FN_19_config); - -/* Initialize any F19 specific params and settings - input - * settings, device settings, etc. - */ -int FN_19_init(struct rmi_function_device *function_device) -{ - int i, retval = 0; - struct f19_instance_data *instance_data = function_device->rfi->fndata; - struct rmi_f19_functiondata *functiondata = rmi_sensor_get_functiondata(function_device->sensor, RMI_F19_INDEX); - - printk(KERN_DEBUG "%s: RMI4 F19 init\n", __func__); - - if (functiondata) { - if (functiondata->button_map) { - if (functiondata->button_map->nbuttons != instance_data->deviceInfo->buttonCount) { - printk(KERN_WARNING "%s: Platformdata button map size (%d) != number of buttons on device (%d) - ignored.", __func__, functiondata->button_map->nbuttons, instance_data->deviceInfo->buttonCount); - } else if (!functiondata->button_map->map) { - printk(KERN_WARNING "%s: Platformdata button map is missing!", __func__); - } else { - for (i = 0; i < functiondata->button_map->nbuttons; i++) - instance_data->buttonMap[i] = functiondata->button_map->map[i]; - } - } - } - - /* Set up any input events. */ - set_bit(EV_SYN, function_device->input->evbit); - set_bit(EV_KEY, function_device->input->evbit); - /* set bits for each button...*/ - for (i = 0; i < instance_data->deviceInfo->buttonCount; i++) { - set_bit(instance_data->buttonMap[i], function_device->input->keybit); - } - - printk(KERN_DEBUG "%s: Creating sysfs files.", __func__); - retval = device_create_file(&function_device->dev, &dev_attr_buttonCount); - if (retval) { - printk(KERN_ERR "%s: Failed to create button count.", __func__); - return retval; - } - - retval = device_create_file(&function_device->dev, &dev_attr_buttonMap); - if (retval) { - printk(KERN_ERR "%s: Failed to create button map.", __func__); - return retval; - } - - return 0; -} -EXPORT_SYMBOL(FN_19_init); - -static int getControlRegisters(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr) -{ - struct f19_instance_data *instanceData; - unsigned char *fn19Control = NULL; - int retval = 0; - - /* Get the instance data - it should have been allocated and stored in detect.*/ - instanceData = rmifninfo->fndata; - - /* Check to make sure instanceData is really there before using.*/ - if (!instanceData) { - printk(KERN_ERR "%s: Error - instance data not initialized yet when getting fn19 control registers.\n", __func__); - return -EINVAL; - } - - /* Allocate memory for the control registers. */ - instanceData->controlRegisters = kzalloc(sizeof(struct rmi_F19_control), GFP_KERNEL); - if (!instanceData->controlRegisters) { - printk(KERN_ERR "%s: Error allocating F19 control registers.\n", __func__); - return -ENOMEM; - } - - instanceData->fn19regCountForBitPerButton = (instanceData->deviceInfo->buttonCount + 7)/8; - - /* Need to compute the amount of data to read since it varies with the - * number of buttons */ - instanceData->fn19ControlRegisterSize = 1 /* 1 for filter mode and button usage bits */ - + 2*instanceData->fn19regCountForBitPerButton /* interrupt enable bits and single button participation bits */ - + 2*instanceData->deviceInfo->buttonCount /* sensormap registers + single button sensitivity registers */ - + 2; /* 1 for global sensitivity adjust + 1 for global hysteresis threshold */ - - /* Allocate a temp memory buffer to read the control registers into */ - fn19Control = kzalloc(instanceData->fn19ControlRegisterSize, GFP_KERNEL); - if (!fn19Control) { - printk(KERN_ERR "%s: Error allocating temp storage to read fn19 control info.\n", __func__); - return -ENOMEM; - } - - /* Grab a copy of the control registers. */ - retval = rmi_read_multiple(rmifninfo->sensor, fndescr->controlBaseAddr, - fn19Control, instanceData->fn19ControlRegisterSize); - if (retval) { - printk(KERN_ERR "%s: Failed to read F19 control registers.", __func__); - return retval; - } - - /* Copy over control registers data to the instance data */ - instanceData->fn19btnUsageandfilterModeOffset = 0; - instanceData->controlRegisters->buttonUsage = fn19Control[instanceData->fn19btnUsageandfilterModeOffset] & 0x3; - instanceData->controlRegisters->filterMode = fn19Control[instanceData->fn19btnUsageandfilterModeOffset] & 0xc; - - /* Fill in interrupt enable registers */ - instanceData->fn19intEnableOffset = 1; - instanceData->fn19intEnableLen = instanceData->fn19regCountForBitPerButton; - instanceData->controlRegisters->intEnableRegisters = kzalloc(instanceData->fn19intEnableLen, GFP_KERNEL); - if (!instanceData->controlRegisters->intEnableRegisters) { - printk(KERN_ERR "%s: Error allocating storage for interrupt enable control info.\n", __func__); - return -ENOMEM; - } - memcpy(instanceData->controlRegisters->intEnableRegisters, &fn19Control[instanceData->fn19intEnableOffset], - instanceData->fn19intEnableLen); - - /* Fill in single button control registers */ - instanceData->fn19singleBtnCtrlOffset = instanceData->fn19intEnableOffset + instanceData->fn19intEnableLen; - instanceData->fn19singleBtnCtrlLen = instanceData->fn19regCountForBitPerButton; - instanceData->controlRegisters->singleButtonControl = kzalloc(instanceData->fn19singleBtnCtrlLen, GFP_KERNEL); - if (!instanceData->controlRegisters->singleButtonControl) { - printk(KERN_ERR "%s: Error allocating storage for single button participation control info.\n", __func__); - return -ENOMEM; - } - memcpy(instanceData->controlRegisters->singleButtonControl, &fn19Control[instanceData->fn19singleBtnCtrlOffset], - instanceData->fn19singleBtnCtrlLen); - - /* Fill in sensor map registers */ - instanceData->fn19sensorMapCtrlOffset = instanceData->fn19singleBtnCtrlOffset + instanceData->fn19singleBtnCtrlLen; - instanceData->fn19sensorMapCtrlLen = instanceData->deviceInfo->buttonCount; - instanceData->controlRegisters->sensorMap = kzalloc(instanceData->fn19sensorMapCtrlLen, GFP_KERNEL); - if (!instanceData->controlRegisters->sensorMap) { - printk(KERN_ERR "%s: Error allocating storage for sensor map control info.\n", __func__); - return -ENOMEM; - } - memcpy(instanceData->controlRegisters->sensorMap, &fn19Control[instanceData->fn19sensorMapCtrlOffset], - instanceData->fn19sensorMapCtrlLen); - - /* Fill in single button sensitivity registers */ - instanceData->fn19singleBtnSensOffset = instanceData->fn19sensorMapCtrlOffset + instanceData->fn19sensorMapCtrlLen; - instanceData->fn19singleBtnSensLen = instanceData->deviceInfo->buttonCount; - instanceData->controlRegisters->singleButtonSensitivity = kzalloc(instanceData->fn19singleBtnSensLen, GFP_KERNEL); - if (!instanceData->controlRegisters->intEnableRegisters) { - printk(KERN_ERR "%s: Error allocating storage for single button sensitivity control info.\n", __func__); - return -ENOMEM; - } - memcpy(instanceData->controlRegisters->singleButtonSensitivity, &fn19Control[instanceData->fn19singleBtnSensOffset], - instanceData->fn19singleBtnSensLen); - - /* Fill in global sensitivity adjustment and global hysteresis threshold values */ - instanceData->fn19globalSensOffset = instanceData->fn19singleBtnSensOffset + instanceData->fn19singleBtnSensLen; - instanceData->fn19globalHystThreshOffset = instanceData->fn19globalSensOffset + 1; - instanceData->controlRegisters->globalSensitivityAdjustment = fn19Control[instanceData->fn19globalSensOffset] & 0x1f; - instanceData->controlRegisters->globalHysteresisThreshold = fn19Control[instanceData->fn19globalHystThreshOffset] & 0x0f; - - /* Free up temp storage that held copy of control registers */ - kfree(fn19Control); - - return 0; -} - -int FN_19_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, unsigned int interruptCount) -{ - unsigned char fn19queries[2]; - int retval = 0; - int i; - struct f19_instance_data *instanceData; - int fn19InterruptOffset; - - printk(KERN_DEBUG "%s: RMI4 F19 detect\n", __func__); - - instanceData = kzalloc(sizeof(struct f19_instance_data), GFP_KERNEL); - if (!instanceData) { - printk(KERN_ERR "%s: Error allocating F19 instance data.\n", __func__); - return -ENOMEM; - } - instanceData->deviceInfo = kzalloc(sizeof(struct rmi_F19_query), GFP_KERNEL); - if (!instanceData->deviceInfo) { - printk(KERN_ERR "%s: Error allocating F19 device query.\n", __func__); - return -ENOMEM; - } - rmifninfo->fndata = instanceData; - - /* Store addresses - used elsewhere to read data, - * control, query, etc. */ - rmifninfo->funcDescriptor.queryBaseAddr = fndescr->queryBaseAddr; - rmifninfo->funcDescriptor.commandBaseAddr = fndescr->commandBaseAddr; - rmifninfo->funcDescriptor.controlBaseAddr = fndescr->controlBaseAddr; - rmifninfo->funcDescriptor.dataBaseAddr = fndescr->dataBaseAddr; - rmifninfo->funcDescriptor.interruptSrcCnt = fndescr->interruptSrcCnt; - rmifninfo->funcDescriptor.functionNum = fndescr->functionNum; - - rmifninfo->numSources = fndescr->interruptSrcCnt; - - /* need to get number of fingers supported, data size, etc. - - to be used when getting data since the number of registers to - read depends on the number of fingers supported and data size. */ - retval = rmi_read_multiple(rmifninfo->sensor, fndescr->queryBaseAddr, fn19queries, - sizeof(fn19queries)); - if (retval) { - printk(KERN_ERR "%s: RMI4 F19 detect: " - "Could not read function query registers 0x%x\n", - __func__, rmifninfo->funcDescriptor.queryBaseAddr); - return retval; - } - - /* Extract device data. */ - instanceData->deviceInfo->configurable = fn19queries[0] & 0x01; - instanceData->deviceInfo->hasSensitivityAdjust = fn19queries[0] & 0x02; - instanceData->deviceInfo->hasHysteresisThreshold = fn19queries[0] & 0x04; - instanceData->deviceInfo->buttonCount = fn19queries[1] & 0x01F; - printk(KERN_DEBUG "%s: F19 device - %d buttons...", __func__, instanceData->deviceInfo->buttonCount); - - /* Need to get interrupt info to be used later when handling - interrupts. */ - rmifninfo->interruptRegister = interruptCount/8; - - /* loop through interrupts for each source in fn $11 and or in a bit - to the interrupt mask for each. */ - fn19InterruptOffset = interruptCount % 8; - - for (i = fn19InterruptOffset; - i < ((fndescr->interruptSrcCnt & 0x7) + fn19InterruptOffset); - i++) - rmifninfo->interruptMask |= 1 << i; - - /* Figure out just how much data we'll need to read. */ - instanceData->buttonDown = kcalloc(instanceData->deviceInfo->buttonCount, sizeof(bool), GFP_KERNEL); - if (!instanceData->buttonDown) { - printk(KERN_ERR "%s: Error allocating F19 button state buffer.\n", __func__); - return -ENOMEM; - } - - instanceData->buttonDataBufferSize = (instanceData->deviceInfo->buttonCount + 7) / 8; - instanceData->buttonDataBuffer = kcalloc(instanceData->buttonDataBufferSize, sizeof(unsigned char), GFP_KERNEL); - if (!instanceData->buttonDataBuffer) { - printk(KERN_ERR "%s: Failed to allocate button data buffer.", __func__); - return -ENOMEM; - } - - instanceData->buttonMap = kcalloc(instanceData->deviceInfo->buttonCount, sizeof(unsigned char), GFP_KERNEL); - if (!instanceData->buttonMap) { - printk(KERN_ERR "%s: Error allocating F19 button map.\n", __func__); - return -ENOMEM; - } - - for (i = 0; i < instanceData->deviceInfo->buttonCount; i++) - instanceData->buttonMap[i] = BTN_0 + i; /* default values */ - - /* Grab the control register info. */ - retval = getControlRegisters(rmifninfo, fndescr); - if (retval) { - printk(KERN_ERR "%s: Error %d getting fn19 control register info.\n", __func__, retval); - return retval; - } - - return 0; -} -EXPORT_SYMBOL(FN_19_detect); - -static ssize_t rmi_f19_buttonCount_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f19_instance_data *instance_data = (struct f19_instance_data *)fn->rfi->fndata; - - return sprintf(buf, "%u\n", instance_data->deviceInfo->buttonCount); -} - -static ssize_t rmi_f19_buttonCount_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - /* Not allowed. */ - return -EPERM; -} - -static ssize_t rmi_f19_buttonMap_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f19_instance_data *instance_data = (struct f19_instance_data *)fn->rfi->fndata; - int i, len, totalLen = 0; - - /* loop through each button map value and copy it's string representation into buf */ - for (i = 0; i < instance_data->deviceInfo->buttonCount; i++) { - /* get next button mapping value and write it to buf */ - len = sprintf(buf, "%u ", instance_data->buttonMap[i]); - /* bump up ptr to next location in buf if the sprintf was valid */ - if (len > 0) { - buf += len; - totalLen += len; - } - } - - return totalLen; -} - -static ssize_t rmi_f19_buttonMap_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct f19_instance_data *instance_data = (struct f19_instance_data *)fn->rfi->fndata; - unsigned int button; - int i; - int retval = count; - int buttonCount = 0; - unsigned char *tmpButtonMap; - - /* Do validation on the button map data passed in. */ - /* Store button mappings into a temp buffer and then verify button count - and data prior to clearing out old button mappings and storing the new ones. */ - tmpButtonMap = kzalloc(instance_data->deviceInfo->buttonCount, GFP_KERNEL); - if (!tmpButtonMap) { - printk(KERN_ERR "%s: Error allocating temp button map.\n", __func__); - return -ENOMEM; - } - - for (i = 0; i < instance_data->deviceInfo->buttonCount && *buf != 0; i++) { - /* get next button mapping value and store and bump up to point to next item in buf */ - sscanf(buf, "%u", &button); - - /* Make sure the key is a valid key */ - if (button > KEY_MAX) { - printk(KERN_ERR "%s: Error - button map for button %d is not a valid value 0x%x.\n", - __func__, i, button); - retval = -EINVAL; - goto err_ret; - } - - tmpButtonMap[i] = button; - buttonCount++; - - /* bump up buf to point to next item to read */ - while (*buf != 0) { - buf++; - if (*(buf-1) == ' ') - break; - } - } - - /* Make sure the button count matches */ - if (buttonCount != instance_data->deviceInfo->buttonCount) { - printk(KERN_ERR "%s: Error - button map count of %d doesn't match device button count of %d.\n" - , __func__, buttonCount, instance_data->deviceInfo->buttonCount); - retval = -EINVAL; - goto err_ret; - } - - /* Clear out old buttonMap data */ - memset(instance_data->buttonMap, 0, buttonCount); - - /* Loop through the temp buffer and copy the button event and set the key bit for the new mapping. */ - for (i = 0; i < buttonCount; i++) { - instance_data->buttonMap[i] = tmpButtonMap[1]; - set_bit(instance_data->buttonMap[i], fn->input->keybit); - } - -err_ret: - kfree(tmpButtonMap); - - return retval; -} diff --git a/drivers/input/touchscreen/synaptics/rmi_f19.h b/drivers/input/touchscreen/synaptics/rmi_f19.h deleted file mode 100644 index 41f3e4d8a295da0ed7a455c1faf7256f1e07be90..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f19.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $11 header. - * Copyright (c) 2007 - 2010, Synaptics Incorporated - * - * For every RMI4 function that has a data source - like 2D sensors, - * buttons, LEDs, GPIOs, etc. - the user will create a new rmi_function_xx.c - * file and add these functions to perform the config(), init(), report() - * and detect() functionality. The function pointers are then srored under - * the RMI function info and these functions will automatically be called by - * the global config(), init(), report() and detect() functions that will - * loop through all data sources and call the data sources functions using - * these functions pointed to by the function ptrs. - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_FUNCTION_19_H -#define _RMI_FUNCTION_19_H - -void FN_19_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs); -int FN_19_config(struct rmi_function_info *rmifninfo); -int FN_19_init(struct rmi_function_device *function_device); -int FN_19_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, - unsigned int interruptCount); -/* No attention function for Fn $19 */ -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_f34.c b/drivers/input/touchscreen/synaptics/rmi_f34.c deleted file mode 100644 index 26b63898ce5647f56b872a260b705c5742ca7bd3..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f34.c +++ /dev/null @@ -1,557 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $34 support for sensor - * firmware reflashing. - * - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "rmi_drvr.h" -#include "rmi_bus.h" -#include "rmi_sensor.h" -#include "rmi_function.h" -#include "rmi_f34.h" - -/* data specific to fn $34 that needs to be kept around */ -struct rmi_fn_34_data { - unsigned char status; - unsigned char cmd; - unsigned short bootloaderid; - unsigned short blocksize; -}; - - -static ssize_t rmi_fn_34_status_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_34_status_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - - -static ssize_t rmi_fn_34_cmd_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_34_cmd_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -static ssize_t rmi_fn_34_data_read(struct file *, - struct kobject *kobj, - struct bin_attribute *attributes, - char *buf, loff_t pos, size_t count); - -static ssize_t rmi_fn_34_data_write(struct file *, - struct kobject *kobj, - struct bin_attribute *attributes, - char *buf, loff_t pos, size_t count); - -static ssize_t rmi_fn_34_bootloaderid_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_34_bootloaderid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -static ssize_t rmi_fn_34_blocksize_show(struct device *dev, - struct device_attribute *attr, char *buf); - -static ssize_t rmi_fn_34_blocksize_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); - -/* define the device attributes using DEVICE_ATTR macros */ -DEVICE_ATTR(status, 0444, rmi_fn_34_status_show, rmi_fn_34_status_store); /* RO attr */ -DEVICE_ATTR(cmd, 0664, rmi_fn_34_cmd_show, rmi_fn_34_cmd_store); /* RW attr */ -DEVICE_ATTR(bootloaderid, 0644, rmi_fn_34_bootloaderid_show, rmi_fn_34_bootloaderid_store); /* RW attr */ -DEVICE_ATTR(blocksize, 0444, rmi_fn_34_blocksize_show, rmi_fn_34_blocksize_store); /* RO attr */ - - -struct bin_attribute dev_attr_data = { - .attr = { - .name = "data", - .mode = 0644 - }, - .size = 0, - .read = rmi_fn_34_data_read, - .write = rmi_fn_34_data_write, -}; - -/* Helper fn to convert from processor specific data to our firmware specific endianness. - * TODO: Should we use ntohs or something like that? - */ -void copyEndianAgnostic(unsigned char *dest, unsigned short src) -{ - dest[0] = src%0x100; - dest[1] = src/0x100; -} - -/*. - * The interrupt handler for Fn $34. - */ -void FN_34_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs) -{ - unsigned int status; - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)rmifninfo->fndata; - - /* Read the Fn $34 status register to see whether the previous command executed OK */ - /* inform user space - through a sysfs param. */ - if (rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.dataBaseAddr+3, - (unsigned char *)&status, 1)) { - printk(KERN_ERR "%s : Could not read status from 0x%x\n", - __func__, rmifninfo->funcDescriptor.dataBaseAddr+3); - status = 0xff; /* failure */ - } - - /* set a sysfs value that the user mode can read - only upper 4 bits are the status */ - fn34data->status = status & 0xf0; /* successful is $80, anything else is failure */ -} -EXPORT_SYMBOL(FN_34_inthandler); - -void FN_34_attention(struct rmi_function_info *rmifninfo) -{ - -} -EXPORT_SYMBOL(FN_34_attention); - -int FN_34_config(struct rmi_function_info *rmifninfo) -{ - pr_debug("%s: RMI4 function $34 config\n", __func__); - return 0; -} -EXPORT_SYMBOL(FN_34_config); - - -int FN_34_init(struct rmi_function_device *function_device) -{ - int retval = 0; - unsigned char uData[2]; - struct rmi_function_info *rmifninfo = function_device->rfi; - struct rmi_fn_34_data *fn34data; - - pr_debug("%s: RMI4 function $34 init\n", __func__); - - /* Here we will need to set up sysfs files for Bootloader ID and Block size */ - fn34data = kzalloc(sizeof(struct rmi_fn_34_data), GFP_KERNEL); - if (!fn34data) { - printk(KERN_ERR "%s: Error allocating memeory for rmi_fn_34_data.\n", __func__); - return -ENOMEM; - } - rmifninfo->fndata = (void *)fn34data; - - /* set up sysfs file for Bootloader ID. */ - if (sysfs_create_file(&function_device->dev.kobj, &dev_attr_bootloaderid.attr) < 0) { - printk(KERN_ERR "%s: Failed to create sysfs file for fn 34 bootloaderid.\n", __func__); - return -ENODEV; - } - - /* set up sysfs file for Block Size. */ - if (sysfs_create_file(&function_device->dev.kobj, &dev_attr_blocksize.attr) < 0) { - printk(KERN_ERR "%s: Failed to create sysfs file for fn 34 blocksize.\n", __func__); - return -ENODEV; - } - - /* get the Bootloader ID and Block Size and store in the sysfs attributes. */ - retval = rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.queryBaseAddr, - uData, 2); - if (retval) { - printk(KERN_ERR "%s : Could not read bootloaderid from 0x%x\n", - __func__, function_device->function->functionQueryBaseAddr); - return retval; - } - /* need to convert from our firmware storage to processore specific data */ - fn34data->bootloaderid = (unsigned int)uData[0] + (unsigned int)uData[1]*0x100; - - retval = rmi_read_multiple(rmifninfo->sensor, rmifninfo->funcDescriptor.queryBaseAddr+3, - uData, 2); - if (retval) { - printk(KERN_ERR "%s : Could not read block size from 0x%x\n", - __func__, rmifninfo->funcDescriptor.queryBaseAddr+3); - return retval; - } - /* need to convert from our firmware storage to processor specific data */ - fn34data->blocksize = (unsigned int)uData[0] + (unsigned int)uData[1]*0x100; - - /* set up sysfs file for status. */ - if (sysfs_create_file(&function_device->dev.kobj, &dev_attr_status.attr) < 0) { - printk(KERN_ERR "%s: Failed to create sysfs file for fn 34 status.\n", __func__); - return -ENODEV; - } - - /* Also, sysfs will need to have a file set up to distinguish between commands - like - Config write/read, Image write/verify.*/ - /* set up sysfs file for command code. */ - if (sysfs_create_file(&function_device->dev.kobj, &dev_attr_cmd.attr) < 0) { - printk(KERN_ERR "%s: Failed to create sysfs file for fn 34 cmd.\n", __func__); - return -ENODEV; - } - - /* We will also need a sysfs file for the image/config block to write or read.*/ - /* set up sysfs bin file for binary data block. Since the image is already in our format - there is no need to convert the data for endianess. */ - if (sysfs_create_bin_file(&function_device->dev.kobj, &dev_attr_data) < 0) { - printk(KERN_ERR "%s: Failed to create sysfs file for fn 34 data.\n", __func__); - return -ENODEV; - } - - return retval; -} -EXPORT_SYMBOL(FN_34_init); - -int FN_34_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, unsigned int interruptCount) -{ - int i; - int InterruptOffset; - int retval = 0; - - pr_debug("%s: RMI4 function $34 detect\n", __func__); - if (rmifninfo->sensor == NULL) { - printk(KERN_ERR "%s: NULL sensor passed in!", __func__); - return -EINVAL; - } - - /* Store addresses - used elsewhere to read data, - * control, query, etc. */ - rmifninfo->funcDescriptor.queryBaseAddr = fndescr->queryBaseAddr; - rmifninfo->funcDescriptor.commandBaseAddr = fndescr->commandBaseAddr; - rmifninfo->funcDescriptor.controlBaseAddr = fndescr->controlBaseAddr; - rmifninfo->funcDescriptor.dataBaseAddr = fndescr->dataBaseAddr; - rmifninfo->funcDescriptor.interruptSrcCnt = fndescr->interruptSrcCnt; - rmifninfo->funcDescriptor.functionNum = fndescr->functionNum; - - rmifninfo->numSources = fndescr->interruptSrcCnt; - - /* Need to get interrupt info to be used later when handling - interrupts. */ - rmifninfo->interruptRegister = interruptCount/8; - - /* loop through interrupts for each source and or in a bit - to the interrupt mask for each. */ - InterruptOffset = interruptCount % 8; - - for (i = InterruptOffset; - i < ((fndescr->interruptSrcCnt & 0x7) + InterruptOffset); - i++) { - rmifninfo->interruptMask |= 1 << i; - } - - return retval; -} -EXPORT_SYMBOL(FN_34_detect); - -static ssize_t rmi_fn_34_bootloaderid_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)fn->rfi->fndata; - - return sprintf(buf, "%u\n", fn34data->bootloaderid); -} - -static ssize_t rmi_fn_34_bootloaderid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - int error; - unsigned long val; - unsigned char uData[2]; - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)fn->rfi->fndata; - - /* need to convert the string data to an actual value */ - error = strict_strtoul(buf, 10, &val); - - if (error) - return error; - - fn34data->bootloaderid = val; - - /* Write the Bootloader ID key data back to the first two Block Data registers - (F34_Flash_Data2.0 and F34_Flash_Data2.1).*/ - copyEndianAgnostic(uData, (unsigned short)val); - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr, - uData, 2); - if (error) { - printk(KERN_ERR "%s : Could not write bootloader id to 0x%x\n", - __func__, fn->function->functionDataBaseAddr); - return error; - } - - return count; -} - -static ssize_t rmi_fn_34_blocksize_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)fn->rfi->fndata; - - return sprintf(buf, "%u\n", fn34data->blocksize); -} - -static ssize_t rmi_fn_34_blocksize_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - /* Block Size is RO so we shouldn't do anything if the - user space writes to the sysfs file. */ - - return -EPERM; -} - -static ssize_t rmi_fn_34_status_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)fn->rfi->fndata; - - return sprintf(buf, "%u\n", fn34data->status); -} - -static ssize_t rmi_fn_34_status_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - /* Status is RO so we shouldn't do anything if the user - app writes to the sysfs file. */ - return -EPERM; -} - -static ssize_t rmi_fn_34_cmd_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)fn->rfi->fndata; - - return sprintf(buf, "%u\n", fn34data->cmd); -} - -static ssize_t rmi_fn_34_cmd_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)fn->rfi->fndata; - unsigned long val; - unsigned char cmd; - int error; - - /* need to convert the string data to an actual value */ - error = strict_strtoul(buf, 10, &val); - - if (error) - return error; - - fn34data->cmd = val; - - /* determine the proper command to issue. - */ - switch (val) { - case ENABLE_FLASH_PROG: - /* Issue a Flash Program Enable ($0F) command to the Flash Command - (F34_Flash_Data3, bits 3:0) field.*/ - cmd = 0x0F; - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr+3, - (unsigned char *)&cmd, 1); - if (error) { - printk(KERN_ERR "%s : Could not write Flash Program Enable cmd to 0x%x\n", - __func__, fn->function->functionDataBaseAddr+3); - return error; - } - break; - - case ERASE_ALL: - /* Issue a Erase All ($03) command to the Flash Command - (F34_Flash_Data3, bits 3:0) field.*/ - cmd = 0x03; - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr+3, - (unsigned char *)&cmd, 1); - if (error) { - printk(KERN_ERR "%s : Could not write Erase All cmd to 0x%x\n", - __func__, fn->function->functionDataBaseAddr+3); - return error; - } - break; - - case ERASE_CONFIG: - /* Issue a Erase Configuration ($07) command to the Flash Command - (F34_Flash_Data3, bits 3:0) field.*/ - cmd = 0x07; - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr+3, - (unsigned char *)&cmd, 1); - if (error) { - printk(KERN_ERR "%s : Could not write Erase Configuration cmd to 0x%x\n", - __func__, fn->function->functionDataBaseAddr+3); - return error; - } - break; - - case WRITE_FW_BLOCK: - /* Issue a Write Firmware Block ($02) command to the Flash Command - (F34_Flash_Data3, bits 3:0) field.*/ - cmd = 0x02; - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr+3, - (unsigned char *)&cmd, 1); - if (error) { - printk(KERN_ERR "%s : Could not write Write Firmware Block cmd to 0x%x\n", - __func__, fn->function->functionDataBaseAddr+3); - return error; - } - break; - - case WRITE_CONFIG_BLOCK: - /* Issue a Write Config Block ($06) command to the Flash Command - (F34_Flash_Data3, bits 3:0) field.*/ - cmd = 0x06; - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr+3, - (unsigned char *)&cmd, 1); - if (error) { - printk(KERN_ERR "%s : Could not write Write Config Block cmd to 0x%x\n", - __func__, fn->function->functionDataBaseAddr+3); - return error; - } - break; - - case READ_CONFIG_BLOCK: - /* Issue a Read Config Block ($05) command to the Flash Command - (F34_Flash_Data3, bits 3:0) field.*/ - cmd = 0x05; - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr+3, - (unsigned char *)&cmd, 1); - if (error) { - printk(KERN_ERR "%s : Could not write Read Config Block cmd to 0x%x\n", - __func__, fn->function->functionDataBaseAddr+3); - return error; - } - break; - - case DISABLE_FLASH_PROG: - /* Issue a reset command ($01) - this will reboot the sensor and ATTN will now go to - the Fn $01 instead of the Fn $34 since the sensor will no longer be in Flash mode. */ - cmd = 0x01; - /*if ((error = rmi_write_multiple(fn->sensor, fn->sensor->sensorCommandBaseAddr, - (unsigned char *)&cmd, 1))) { - printk(KERN_ERR "%s : Could not write Reset cmd to 0x%x\n", - __func__, fn->sensor->sensorCommandBaseAddr); - return error; - }*/ - break; - - default: - pr_debug("%s: RMI4 function $34 - unknown command.\n", __func__); - break; - } - - return count; -} - -static ssize_t rmi_fn_34_data_read(struct file * filp, - struct kobject *kobj, - struct bin_attribute *attributes, - char *buf, loff_t pos, size_t count) -{ - struct device *dev = container_of(kobj, struct device, kobj); - struct rmi_function_device *fn = dev_get_drvdata(dev); - int error; - - /* TODO: add check for count to verify it's the correct blocksize */ - - /* read the data from flash into buf. */ - /* the app layer will be blocked at reading from the sysfs file. */ - /* when we return the count (or error if we fail) the app will resume. */ - error = rmi_read_multiple(fn->sensor, fn->function->functionDataBaseAddr+pos, - (unsigned char *)buf, count); - if (error) { - printk(KERN_ERR "%s : Could not read data from 0x%llx\n", - __func__, fn->function->functionDataBaseAddr+pos); - return error; - } - - return count; -} - -static ssize_t rmi_fn_34_data_write(struct file *filp, - struct kobject *kobj, - struct bin_attribute *attributes, - char *buf, loff_t pos, size_t count) -{ - struct device *dev = container_of(kobj, struct device, kobj); - struct rmi_function_device *fn = dev_get_drvdata(dev); - struct rmi_fn_34_data *fn34data = (struct rmi_fn_34_data *)fn->rfi->fndata; - unsigned int blocknum; - int error; - - /* write the data from buf to flash. */ - /* the app layer will be blocked at writing to the sysfs file. */ - /* when we return the count (or error if we fail) the app will resume. */ - - /* TODO: Add check on count - if non-zero veriy it's the correct blocksize */ - - /* Verify that the byte offset is always aligned on a block boundary and if not - return an error. We can't just use the mod operator % and do a (pos % fn34data->blocksize) because of a gcc - bug that results in undefined symbols. So we have to compute it the hard - way. Grumble. */ - unsigned int remainder; - div_u64_rem(pos, fn34data->blocksize, &remainder); - if (remainder) { - printk(KERN_ERR "%s : Invalid byte offset of %llx leads to invalid block number.\n", - __func__, pos); - return -EINVAL; - } - - /* Compute the block number using the byte offset (pos) and the block size. - once again, we can't just do a divide due to a gcc bug. */ - blocknum = div_u64(pos, fn34data->blocksize); - - /* Write the block number first */ - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr, - (unsigned char *)&blocknum, 2); - if (error) { - printk(KERN_ERR "%s : Could not write block number to 0x%x\n", - __func__, fn->function->functionDataBaseAddr); - return error; - } - - /* Write the data block - only if the count is non-zero */ - if (count) { - error = rmi_write_multiple(fn->sensor, fn->function->functionDataBaseAddr+2, - (unsigned char *)buf, count); - if (error) { - printk(KERN_ERR "%s : Could not write block data to 0x%x\n", - __func__, fn->function->functionDataBaseAddr+2); - return error; - } - } - - return count; -} diff --git a/drivers/input/touchscreen/synaptics/rmi_f34.h b/drivers/input/touchscreen/synaptics/rmi_f34.h deleted file mode 100644 index 48293e3d131a9ae02586c0f1bee68058602294c9..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_f34.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function $34 header. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - * There is only one function $34 for each RMI4 sensor. This will be - * the function that is used to reflash the firmware and get the - * boot loader address and the boot image block size. - * - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_FUNCTION_34_H -#define _RMI_FUNCTION_34_H - -/* define fn $34 commands */ -#define WRITE_FW_BLOCK 2 -#define ERASE_ALL 3 -#define READ_CONFIG_BLOCK 5 -#define WRITE_CONFIG_BLOCK 6 -#define ERASE_CONFIG 7 -#define ENABLE_FLASH_PROG 15 -#define DISABLE_FLASH_PROG 16 - -void FN_34_inthandler(struct rmi_function_info *rmifninfo, - unsigned int assertedIRQs); -int FN_34_config(struct rmi_function_info *rmifninfo); -int FN_34_init(struct rmi_function_device *function_device); -int FN_34_detect(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, - unsigned int interruptCount); -void FN_34_attention(struct rmi_function_info *rmifninfo); - -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_function.c b/drivers/input/touchscreen/synaptics/rmi_function.c deleted file mode 100644 index 4a029f792f4427f7b87c64ac3e7f9b78bea244e2..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_function.c +++ /dev/null @@ -1,326 +0,0 @@ -/** - * Synaptics Register Mapped Interface (RMI4) - RMI Function Module. - * Copyright (C) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * - *############################################################################# - */ - -static const char functionname[10] = "fn"; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmi_drvr.h" -#include "rmi_function.h" -#include "rmi_bus.h" -#include "rmi_sensor.h" -#include "rmi_f01.h" -#include "rmi_f05.h" -#include "rmi_f11.h" -#include "rmi_f19.h" -#include "rmi_f34.h" - -/* Each time a new RMI4 function support is added the developer needs to -bump the number of supported functions and add the info for -that RMI4 function to the array along with pointers to the report, -config, init and detect functions that they coded in rmi_fxx.c -and rmi_fxx.h - where xx is the RMI4 function number in hex for the new -RMI4 data source function. The information for the RMI4 functions is -obtained from the RMI4 specification document. - */ -#define rmi4_num_supported_data_src_fns 5 - -/* supported RMI4 functions list - controls what we - * will provide support for - if it's not in the list then - * the developer needs to add support functions for it.*/ -static LIST_HEAD(fns_list); -static DEFINE_MUTEX(fns_mutex); - -/* NOTE: Developer - add in any new RMI4 fn data info - function number - * and ptrs to report, config, init and detect functions. This data is - * used to point to the functions that need to be called to config, init, - * detect and report data for the new RMI4 function. Refer to the RMI4 - * specification for information on RMI4 functions. - */ -/* TODO: This will eventually go away, and each function will be an independent - * module. */ -static struct rmi_functions_data - rmi4_supported_data_src_functions[rmi4_num_supported_data_src_fns] = { - /* Fn $11 - 2D sensing */ - {.functionNumber = 0x11, .inthandlerFn = FN_11_inthandler, .configFn = FN_11_config, .initFn = FN_11_init, .detectFn = FN_11_detect, .attnFn = NULL}, - /* Fn $01 - device control */ - {.functionNumber = 0x01, .inthandlerFn = FN_01_inthandler, .configFn = FN_01_config, .initFn = FN_01_init, .detectFn = FN_01_detect, .attnFn = FN_01_attention}, - /* Fn $05 - analog report */ - {.functionNumber = 0x05, .inthandlerFn = FN_05_inthandler, .configFn = FN_05_config, .initFn = FN_05_init, .detectFn = FN_05_detect, .attnFn = NULL}, - /* Fn $19 - buttons */ - {.functionNumber = 0x19, .inthandlerFn = FN_19_inthandler, .configFn = FN_19_config, .initFn = FN_19_init, .detectFn = FN_19_detect, .attnFn = NULL}, - /* Fn $34 - firmware reflash */ - {.functionNumber = 0x34, .inthandlerFn = FN_34_inthandler, .configFn = FN_34_config, .initFn = FN_34_init, .detectFn = FN_34_detect, .attnFn = FN_34_attention}, -}; - - -/* This function is here to provide a way for external modules to access the - * functions list. It will try to find a matching function base on the passed - * in RMI4 function number and return the pointer to the struct rmi_functions - * if a match is found or NULL if not found. - */ -struct rmi_functions *rmi_find_function(int functionNum) -{ - struct rmi_functions *fn; - bool found = false; - - list_for_each_entry(fn, &fns_list, link) { - if (functionNum == fn->functionNum) { - found = true; - break; - } - } - - if (!found) - return NULL; - else - return fn; -} -EXPORT_SYMBOL(rmi_find_function); - - -static void rmi_function_config(struct rmi_function_device *function) -{ - printk(KERN_DEBUG "%s: rmi_function_config", __func__); - -} - -#if 0 /* This may not be needed anymore. */ -/** - * This is the probe function passed to the RMI4 subsystem that gives us a - * chance to recognize an RMI4 function. - */ -static int rmi_function_probe(struct rmi_function_driver *function) -{ - struct rmi_phys_driver *rpd; - - rpd = function->rpd; - - if (!rpd) { - printk(KERN_ERR "%s: Invalid rmi physical driver - null ptr.", __func__); - return 0; - } - - return 1; -} -#endif - -/** Just a stub for now. - */ -static int rmi_function_suspend(struct device *dev, pm_message_t state) -{ - printk(KERN_INFO "%s: function suspend called.", __func__); - return 0; -} - -/** Just a stub for now. - */ -static int rmi_function_resume(struct device *dev) -{ - printk(KERN_INFO "%s: function resume called.", __func__); - return 0; -} - -int rmi_function_register_driver(struct rmi_function_driver *drv, int fnNumber) -{ - int retval; - char *drvrname; - - printk(KERN_INFO "%s: Registering function driver for F%02x.\n", __func__, fnNumber); - - retval = 0; - - /* Create a function device and function driver for this Fn */ - drvrname = kzalloc(sizeof(functionname) + 4, GFP_KERNEL); - if (!drvrname) { - printk(KERN_ERR "%s: Error allocating memeory for rmi_function_driver name.\n", __func__); - return -ENOMEM; - } - sprintf(drvrname, "fn%02x", fnNumber); - - drv->drv.name = drvrname; - drv->module = drv->drv.owner; - - drv->drv.suspend = rmi_function_suspend; - drv->drv.resume = rmi_function_resume; - - /* register the sensor driver */ - retval = driver_register(&drv->drv); - if (retval) { - printk(KERN_ERR "%s: Failed driver_register %d\n", - __func__, retval); - } - - return retval; -} -EXPORT_SYMBOL(rmi_function_register_driver); - -void rmi_function_unregister_driver(struct rmi_function_driver *drv) -{ - printk(KERN_INFO "%s: Unregistering function driver.\n", __func__); - - driver_unregister(&drv->drv); -} -EXPORT_SYMBOL(rmi_function_unregister_driver); - -int rmi_function_register_device(struct rmi_function_device *function_device, int fnNumber) -{ - struct input_dev *input; - int retval; - - printk(KERN_INFO "%s: Registering function device for F%02x.\n", __func__, fnNumber); - - retval = 0; - - /* make name - fn11, fn19, etc. */ - dev_set_name(&function_device->dev, "%sfn%02x", function_device->sensor->drv.name, fnNumber); - dev_set_drvdata(&function_device->dev, function_device); - retval = device_register(&function_device->dev); - if (retval) { - printk(KERN_ERR "%s: Failed device_register for function device.\n", - __func__); - return retval; - } - - input = input_allocate_device(); - if (input == NULL) { - printk(KERN_ERR "%s: Failed to allocate memory for a " - "new input device.\n", - __func__); - return -ENOMEM; - } - - input->name = dev_name(&function_device->dev); - input->phys = "rmi_function"; - function_device->input = input; - - - /* init any input specific params for this function */ - function_device->rmi_funcs->init(function_device); - - retval = input_register_device(input); - - if (retval) { - printk(KERN_ERR "%s: Failed input_register_device.\n", - __func__); - return retval; - } - - - rmi_function_config(function_device); - - return retval; -} -EXPORT_SYMBOL(rmi_function_register_device); - -void rmi_function_unregister_device(struct rmi_function_device *dev) -{ - printk(KERN_INFO "%s: Unregistering function device.n", __func__); - - input_unregister_device(dev->input); - device_unregister(&dev->dev); -} -EXPORT_SYMBOL(rmi_function_unregister_device); - -static int __init rmi_function_init(void) -{ - struct rmi_functions_data *rmi4_fn; - int i; - - printk(KERN_DEBUG "%s: RMI Function Init\n", __func__); - - /* Initialize global list of RMI4 Functions. - We need to add the supported RMI4 funcions so that we will have - pointers to the associated functions for init, config, report and - detect. See rmi.h for more details. The developer will add a new - RMI4 function number in the array in rmi_drvr.h, then add a new file to - the build (called rmi_fXX.c where XX is the hex number for - the added RMI4 function). The rest should be automatic. - */ - - /* for each function number defined in rmi.h creat a new rmi_function - struct and initialize the pointers to the servicing functions and then - add it into the global list for function support. - */ - for (i = 0; i < rmi4_num_supported_data_src_fns; i++) { - /* Add new rmi4 function struct to list */ - struct rmi_functions *fn = kzalloc(sizeof(*fn), GFP_KERNEL); - if (!fn) { - printk(KERN_ERR "%s: could not allocate memory " - "for rmi_function struct for function 0x%x\n", - __func__, - rmi4_supported_data_src_functions[i].functionNumber); - return -ENOMEM; - } else { - - rmi4_fn = &rmi4_supported_data_src_functions[i]; - fn->functionNum = rmi4_fn->functionNumber; - /* Fill in ptrs to functions. The functions are - linked in from a file called rmi_fxx.c - where xx is the hex number of the RMI4 function - from the RMI4 spec. Also, the function prototypes - need to be added to rmi_fxx.h - also where - xx is the hex number of the RMI4 function. So - that you don't get compile errors and that new - header needs to be included in the rmi_function.h - */ - fn->inthandler = rmi4_fn->inthandlerFn; - fn->config = rmi4_fn->configFn; - fn->init = rmi4_fn->initFn; - fn->detect = rmi4_fn->detectFn; - fn->attention = rmi4_fn->attnFn; - - /* Add the new fn to the global list */ - mutex_lock(&fns_mutex); - list_add_tail(&fn->link, &fns_list); - mutex_unlock(&fns_mutex); - } - } - - return 0; -} - -static void __exit rmi_function_exit(void) -{ - printk(KERN_DEBUG "%s: RMI Function Exit\n", __func__); -} - - -module_init(rmi_function_init); -module_exit(rmi_function_exit); - -MODULE_AUTHOR("Synaptics, Inc."); -MODULE_DESCRIPTION("RMI4 Function Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/synaptics/rmi_function.h b/drivers/input/touchscreen/synaptics/rmi_function.h deleted file mode 100644 index 801609bd77a02857d274d9c39808cfcb228ff3d0..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_function.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) Function Device Header File. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_FUNCTION_H -#define _RMI_FUNCTION_H - -#include -#include - - -/* For each function present on the RMI device, there will be a corresponding - * entry in the functions list of the rmi_sensor_driver structure. This entry - * gives information about the number of data sources and the number of data - * registers associated with the function. - */ -struct rmi_function_info { - /* The sensor this function belongs to. - */ - struct rmi_sensor_driver *sensor; - - /* A device associated with this function. - */ - struct rmi_function_device *function_device; - - unsigned char functionNum; - - /* This is the number of data sources associated with the function.*/ - unsigned char numSources; - - /* This is the number of data registers to read.*/ - unsigned char dataRegBlockSize; - - /* This is the interrupt register and mask - needed for enabling the - * interrupts and for checking what source had caused the attention line - * interrupt. - */ - unsigned char interruptRegister; - unsigned char interruptMask; - - /* This is the RMI function descriptor associated with this function. - * It contains the Base addresses for the functions query, command, - * control, and data registers. - */ - struct rmi_function_descriptor funcDescriptor; - - /* pointer to data specific to a functions implementation. */ - void *fndata; - - /* A list of the function information. - * This list uses the standard kernel linked list implementation. - * Documentation on on how to use it can be found at - * http://isis.poly.edu/kulesh/stuff/src/klist/. - */ - struct list_head link; -}; - - -/* This struct is for creating a list of RMI4 functions that have data sources -associated with them. This is to facilitate adding new support for other -data sources besides 2D sensors. -To add a new data source support, the developer will create a new file -and add these 4 functions below with FN$## in front of the names - where -## is the hex number for the function taken from the RMI4 specification. - -The function number will be associated with this and later will be used to -match the RMI4 function to the 4 functions for that RMI4 function number. -The user will also have to add code that adds the new rmi_functions item -to the global list of RMI4 functions and stores the pointers to the 4 -functions in the function pointers. - */ -struct rmi_functions { - unsigned char functionNum; - - /* Pointers to function specific functions for interruptHandler, config, init - , detect and attention. */ - /* These ptrs. need to be filled in for every RMI4 function that has - data source(s) associated with it - like fn $11 (2D sensors), - fn $19 (buttons), etc. Each RMI4 function that has data sources - will be added into a list that is used to match the function - number against the number stored here. - */ - /* The sensor implementation will call this whenever and IRQ is - * dispatched that this function is interested in. - */ - void (*inthandler)(struct rmi_function_info *rfi, unsigned int assertedIRQs); - - int (*config)(struct rmi_function_info *rmifninfo); - int (*init)(struct rmi_function_device *function_device); - int (*detect)(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, - unsigned int interruptCount); - /** If this is non-null, the sensor implemenation will call this - * whenever the ATTN line is asserted. - */ - void (*attention)(struct rmi_function_info *rmifninfo); - - - /* Standard kernel linked list implementation. - * Documentation on how to use it can be found at - * http://isis.poly.edu/kulesh/stuff/src/klist/. - */ - struct list_head link; -}; - - -typedef void(*inthandlerFuncPtr)(struct rmi_function_info *rfi, unsigned int assertedIRQs); -typedef int(*configFuncPtr)(struct rmi_function_info *rmifninfo); -typedef int(*initFuncPtr)(struct rmi_function_device *function_device); -typedef int(*detectFuncPtr)(struct rmi_function_info *rmifninfo, - struct rmi_function_descriptor *fndescr, - unsigned int interruptCount); -typedef void (*attnFuncPtr)(struct rmi_function_info *rmifninfo); - -struct rmi_functions_data { - int functionNumber; - inthandlerFuncPtr inthandlerFn; - configFuncPtr configFn; - initFuncPtr initFn; - detectFuncPtr detectFn; - attnFuncPtr attnFn; -}; - - -struct rmi_functions *rmi_find_function(int functionNum); -int rmi_functions_init(struct input_dev *inputdev); - -struct rmi_function_driver { - struct module *module; - struct device_driver drv; - - /* Probe Function - * This function is called to give the function driver layer an - * opportunity to claim an RMI function. - */ - int (*probe)(struct rmi_function_driver *function); - /* Config Function - * This function is called after a successful probe. It gives the - * function driver an opportunity to query and/or configure an RMI - * function before data starts flowing. - */ - void (*config)(struct rmi_function_driver *function); - - unsigned short functionQueryBaseAddr; /* RMI4 function control */ - unsigned short functionControlBaseAddr; - unsigned short functionCommandBaseAddr; - unsigned short functionDataBaseAddr; - unsigned int interruptRegisterOffset; /* offset from start of interrupt registers */ - unsigned int interruptMask; - - /* pointer to the corresponding phys driver info for this sensor */ - /* The phys driver has the pointers to read, write, etc. */ - /* Probably don't need it here - used down in bus driver and sensor driver */ - struct rmi_phys_driver *rpd; - - /* Standard kernel linked list implementation. - * Documentation on how to use it can be found at - * http://isis.poly.edu/kulesh/stuff/src/klist/. - */ - struct list_head function_drivers; /* link function drivers into list */ -}; - -struct rmi_function_device { - struct rmi_function_driver *function; - struct device dev; - struct input_dev *input; - struct rmi_sensor_driver *sensor; /* need this to be bound to phys driver layer */ - - /* the function ptrs to the config, init, detect and - report fns for this rmi function device. */ - struct rmi_functions *rmi_funcs; - struct rmi_function_info *rfi; - - /** An RMI sensor might actually have several IRQ registers - - * this tells us which IRQ register this function is interested in. - */ - unsigned int irqRegisterSet; - - /** This is a mask of the IRQs the function is interested in. - */ - unsigned int irqMask; - - /* Standard kernel linked list implementation. - * Documentation on how to use it can be found at - * http://isis.poly.edu/kulesh/stuff/src/klist/. - */ - struct list_head functions; /* link functions into list */ -}; - -int rmi_function_register_device(struct rmi_function_device *dev, int fnNumber); - -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_i2c.c b/drivers/input/touchscreen/synaptics/rmi_i2c.c deleted file mode 100644 index 1932b9be8a783bf1d670b70a1bbf671198c88d81..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_i2c.c +++ /dev/null @@ -1,633 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) I2C Physical Layer Driver. - * Copyright (c) 2007-2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmi_drvr.h" - -#define DRIVER_NAME "rmi4_ts" - -#define DEVICE_NAME "rmi4_ts" - -/* Used to lock access to the page address.*/ -/* TODO: for multiple device support will need a per-device mutex */ -static DEFINE_MUTEX(page_mutex); - - -static const struct i2c_device_id rmi_i2c_id_table[] = { - { DEVICE_NAME, 0 }, - { }, -}; -MODULE_DEVICE_TABLE(i2c, rmi_i2c_id_table); - - -/* Used to count the number of I2C modules we get. - */ -static int device_count; - - -/* - * This is the data kept on a per instance (client) basis. This data is - * always accessible by using the container_of() macro of the various elements - * inside. - */ -struct instance_data { - int instance_no; - int irq; - struct rmi_phys_driver rmiphysdrvr; - struct i2c_client *i2cclient; /* pointer to i2c_client for later use in - read, write, read_multiple, etc. */ - int page; -}; - -/* - * RMI devices have 16-bit addressing, but some of the physical - * implementations (like SMBus) only have 8-bit addressing. So RMI implements - * a page address at 0xff of every page so we can reliable page addresses - * every 256 registers. This function sets the page. - * - * The page_mutex lock must be held when this function is entered. - * - * param[in] id - The pointer to the instance_data struct - * param[in] page - The new page address. - * returns zero on success, non-zero on failure. - */ -/** Writing to page select is giving errors in some configurations. It's - * not needed for basic operation, so we've turned it off for the moment. - */ -#if defined(USE_PAGESELECT) -int -rmi_set_page(struct instance_data *instancedata, unsigned int page) -{ - char txbuf[2]; - int retval; - txbuf[0] = 0xff; - txbuf[1] = page; - retval = i2c_master_send(instancedata->i2cclient, txbuf, 2); - if (retval != 2) { - dev_err(&instancedata->i2cclient->dev, - "%s: Set page failed: %d.", __func__, retval); - } else { - retval = 0; - instancedata->page = page; - } - return retval; -} -#else -int -rmi_set_page(struct instance_data *instancedata, unsigned int page) -{ - return 0; -} -#endif - -/* - * Read a single register through i2c. - * - * param[in] pd - The pointer to the rmi_phys_driver struct - * param[in] address - The address at which to start the data read. - * param[out] valp - Pointer to the buffer where the data will be stored. - * returns zero upon success (with the byte read in valp), non-zero upon error. - */ -static int -rmi_i2c_read(struct rmi_phys_driver *physdrvr, unsigned short address, char *valp) -{ - struct instance_data *instancedata = - container_of(physdrvr, struct instance_data, rmiphysdrvr); - - char txbuf[2]; - int retval = 0; - int retry_count = 0; - - /* Can't have anyone else changing the page behind our backs */ - mutex_lock(&page_mutex); - - if (((address >> 8) & 0xff) != instancedata->page) { - /* Switch pages */ - retval = rmi_set_page(instancedata, ((address >> 8) & 0xff)); - if (retval) - goto exit; - } - -retry: - txbuf[0] = address & 0xff; - retval = i2c_master_send(instancedata->i2cclient, txbuf, 1); - - if (retval != 1) { - dev_err(&instancedata->i2cclient->dev, "%s: Write fail: %d\n", - __func__, retval); - goto exit; - } - retval = i2c_master_recv(instancedata->i2cclient, txbuf, 1); - - if (retval != 1) { - if (++retry_count == 5) { - dev_err(&instancedata->i2cclient->dev, - "%s: Read of 0x%04x fail: %d\n", - __func__, address, retval); - } else { - mdelay(10); - rmi_set_page(instancedata, ((address >> 8) & 0xff)); - goto retry; - } - } else { - retval = 0; - *valp = txbuf[0]; - } -exit: - - mutex_unlock(&page_mutex); - return retval; -} - -/* - * Same as rmi_i2c_read, except that multiple bytes are allowed to be read. - * - * param[in] pd - The pointer to the rmi_phys_driver struct - * param[in] address - The address at which to start the data read. - * param[out] valp - Pointer to the buffer where the data will be stored. This - * buffer must be at least size bytes long. - * param[in] size - The number of bytes to be read. - * returns zero upon success (with the byte read in valp), non-zero upon error. - * - */ -static int -rmi_i2c_read_multiple(struct rmi_phys_driver *physdrvr, unsigned short address, - char *valp, int size) -{ - struct instance_data *instancedata = - container_of(physdrvr, struct instance_data, rmiphysdrvr); - - char txbuf[2]; - int retval = 0; - int retry_count = 0; - - /* Can't have anyone else changing the page behind our backs */ - mutex_lock(&page_mutex); - - if (((address >> 8) & 0xff) != instancedata->page) { - /* Switch pages */ - retval = rmi_set_page(instancedata, ((address >> 8) & 0xff)); - if (retval) - goto exit; - } - -retry: - txbuf[0] = address & 0xff; - retval = i2c_master_send(instancedata->i2cclient, txbuf, 1); - - if (retval != 1) { - dev_err(&instancedata->i2cclient->dev, "%s: Write fail: %d\n", - __func__, retval); - goto exit; - } - retval = i2c_master_recv(instancedata->i2cclient, valp, size); - - if (retval != size) { - if (++retry_count == 5) { - dev_err(&instancedata->i2cclient->dev, - "%s: Read of 0x%04x size %d fail: %d\n", - __func__, address, size, retval); - } else { - mdelay(10); - rmi_set_page(instancedata, ((address >> 8) & 0xff)); - goto retry; - } - } else { - retval = 0; - } -exit: - - mutex_unlock(&page_mutex); - return retval; -} - - -/* - * Write a single register through i2c. - * You can write multiple registers at once, but I made the functions for that - * seperate for performance reasons. Writing multiple requires allocation and - * freeing. - * - * param[in] pd - The pointer to the rmi_phys_driver struct - * param[in] address - The address at which to start the write. - * param[in] data - The data to be written. - * returns one upon success, something else upon error. - */ -static int -rmi_i2c_write(struct rmi_phys_driver *physdrvr, unsigned short address, char data) -{ - struct instance_data *instancedata = - container_of(physdrvr, struct instance_data, rmiphysdrvr); - - unsigned char txbuf[2]; - int retval = 0; - - /* Can't have anyone else changing the page behind our backs */ - mutex_lock(&page_mutex); - - if (((address >> 8) & 0xff) != instancedata->page) { - /* Switch pages */ - retval = rmi_set_page(instancedata, ((address >> 8) & 0xff)); - if (retval) - goto exit; - } - - txbuf[0] = address & 0xff; - txbuf[1] = data; - retval = i2c_master_send(instancedata->i2cclient, txbuf, 2); - - /* TODO: Add in retry on writes only in certian error return values */ - if (retval != 2) { - dev_err(&instancedata->i2cclient->dev, "%s: Write fail: %d\n", - __func__, retval); - goto exit; /* Leave this in case we add code below */ - } else { - retval = 1; - } -exit: - - mutex_unlock(&page_mutex); - return retval; -} - -/* - * Write multiple registers. - * - * For fast writes of 16 bytes of less we will re-use a buffer on the stack. - * For larger writes (like for RMI reflashing) we will need to allocate a - * temp buffer. - * - * param[in] pd - The pointer to the rmi_phys_driver struct - * param[in] address - The address at which to start the write. - * param[in] valp - A pointer to a buffer containing the data to be written. - * param[in] size - The number of bytes to write. - * returns one upon success, something else upon error. - */ -static int -rmi_i2c_write_multiple(struct rmi_phys_driver *physdrvr, unsigned short address, - char *valp, int size) -{ - struct instance_data *instancedata = - container_of(physdrvr, struct instance_data, rmiphysdrvr); - - unsigned char *txbuf; - unsigned char txbuf_most[17]; /* Use this buffer for fast writes of 16 - bytes or less. The first byte will - contain the address at which to start - the write. */ - int retval = 0; - int i; - - if (size < sizeof(txbuf_most)) { - /* Avoid an allocation if we can help it. */ - txbuf = txbuf_most; - } else { - /* over 16 bytes write we'll need to allocate a temp buffer */ - txbuf = kzalloc(size + 1, GFP_KERNEL); - if (!txbuf) - return -ENOMEM; - } - - /* Yes, it stinks here that we have to copy the buffer */ - /* We copy from valp to txbuf leaving - the first location open for the address */ - for (i = 0; i < size; i++) - txbuf[i + 1] = valp[i]; - - /* Can't have anyone else changing the page behind our backs */ - mutex_lock(&page_mutex); - - if (((address >> 8) & 0xff) != instancedata->page) { - /* Switch pages */ - retval = rmi_set_page(instancedata, ((address >> 8) & 0xff)); - if (retval) - goto exit; - } - - txbuf[0] = address & 0xff; /* put the address in the first byte */ - retval = i2c_master_send(instancedata->i2cclient, txbuf, size + 1); - - /* TODO: Add in retyr on writes only in certian error return values */ - if (retval != 1) { - dev_err(&instancedata->i2cclient->dev, "%s: Write fail: %d\n", - __func__, retval); - goto exit; - } -exit: - - mutex_unlock(&page_mutex); - if (txbuf != txbuf_most) - kfree(txbuf); - return retval; -} - -/* - * This is the Interrupt Service Routine. It just notifies the application - * layer that attention is required. - */ -static irqreturn_t -i2c_attn_isr(int irq, void *info) -{ - struct instance_data *instancedata = info; - - disable_irq_nosync(instancedata->irq); - - if (instancedata->rmiphysdrvr.attention) { - instancedata->rmiphysdrvr.attention(&instancedata->rmiphysdrvr, - instancedata->instance_no); - } - - return IRQ_HANDLED; -} - -/* The Driver probe function - will allocate and initialize the instance - * data and request the irq and set the instance data as the clients - * platform data then register the physical driver which will do a scan of - * the RMI4 Physical Device Table and enumerate any RMI4 functions that - * have data sources associated with them. - */ -static int -rmi_i2c_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) -{ - - struct instance_data *instancedata; - int retval = 0; - int irqtype = 0; - - struct rmi_i2c_platformdata *platformdata; - struct rmi_sensordata *sensordata; - - if (client == NULL) { - printk(KERN_ERR "%s: Invalid NULL client received.", __func__); - return -EINVAL; - } - - printk(KERN_DEBUG "%s: Probing i2c RMI device, addr: 0x%02x", __func__, client->addr); - - - /* Allocate and initialize the instance data for this client */ - instancedata = kzalloc(sizeof(*instancedata), GFP_KERNEL); - if (!instancedata) { - dev_err(&client->dev, - "%s: Out of memory trying to allocate instance_data.\n", - __func__); - return -ENOMEM; - } - - instancedata->rmiphysdrvr.name = DRIVER_NAME; - instancedata->rmiphysdrvr.write = rmi_i2c_write; - instancedata->rmiphysdrvr.read = rmi_i2c_read; - instancedata->rmiphysdrvr.write_multiple = rmi_i2c_write_multiple; - instancedata->rmiphysdrvr.read_multiple = rmi_i2c_read_multiple; - instancedata->rmiphysdrvr.module = THIS_MODULE; - - /* Set default to polling in case no matching platform data is located - for this device. We'll still work but in polling mode since we didn't - find any irq info */ - instancedata->rmiphysdrvr.polling_required = true; - - instancedata->page = 0xffff; /* Force a set page the first time */ - - /* cast to our struct rmi_i2c_platformdata so we know - the fields (see rmi_ic2.h) */ - platformdata = client->dev.platform_data; - if (platformdata == NULL) { - printk(KERN_ERR "%s: CONFIGURATION ERROR - platform data is NULL.", __func__); - return -EINVAL; - } - sensordata = platformdata->sensordata; - - /* Egregiously horrible delay here that seems to prevent I2C disasters on - * certain broken dev systems. In most cases, you can safely leave this - * as zero. - */ - if (platformdata->delay_ms > 0) - mdelay(platformdata->delay_ms); - - /* Call the platform setup routine, to do any setup that is required before - * interacting with the device. - */ - if (sensordata && sensordata->rmi_sensor_setup) { - retval = sensordata->rmi_sensor_setup(); - if (retval) { - printk(KERN_ERR "%s: sensor setup failed with code %d.", __func__, retval); - return retval; - } - } - - printk(KERN_DEBUG "%s: sensor addr: 0x%02x irq: 0x%x type: %d", - __func__, platformdata->i2c_address, platformdata->irq, platformdata->irq_type); - if (client->addr != platformdata->i2c_address) { - printk(KERN_ERR "%s: CONFIGURATION ERROR - client I2C address 0x%02x doesn't match platform data address 0x%02x.", __func__, client->addr, platformdata->i2c_address); - return -EINVAL; - } - - instancedata->instance_no = device_count++; - - /* set the device name using the instance_no appended - to DEVICE_NAME to make a unique name */ - dev_set_name(&client->dev, - "rmi4-i2c%d", instancedata->instance_no); - - /* Determine if we need to poll (inefficient) or use interrupts. - */ - if (platformdata->irq) { - instancedata->irq = platformdata->irq; - switch (platformdata->irq_type) { - case IORESOURCE_IRQ_HIGHEDGE: - irqtype = IRQF_TRIGGER_RISING; - break; - case IORESOURCE_IRQ_LOWEDGE: - irqtype = IRQF_TRIGGER_FALLING; - break; - case IORESOURCE_IRQ_HIGHLEVEL: - irqtype = IRQF_TRIGGER_HIGH; - break; - case IORESOURCE_IRQ_LOWLEVEL: - irqtype = IRQF_TRIGGER_LOW; - break; - default: - dev_warn(&client->dev, - "%s: Invalid IRQ flags in platform data.\n", - __func__); - kfree(instancedata); - return -ENXIO; - } - - instancedata->rmiphysdrvr.polling_required = false; - instancedata->rmiphysdrvr.irq = instancedata->irq; - - } else { - instancedata->rmiphysdrvr.polling_required = true; - dev_info(&client->dev, - "%s: No IRQ info given. Polling required.\n", - __func__); - } - - /* Store the instance data in the i2c_client - we need to do this prior - * to calling register_physical_driver since it may use the read, write - * functions. If nothing was found then the id fields will be set to 0 - * for the irq and the default will be set to polling required so we - * will still work but in polling mode. */ - i2c_set_clientdata(client, instancedata); - - /* Copy i2c_client pointer into instance_data's i2c_client pointer for - later use in rmi4_read, rmi4_write, etc. */ - instancedata->i2cclient = client; - - /* Register sensor drivers - this will call the detect function that - * will then scan the device and determine the supported RMI4 sensors - * and functions. - */ - retval = rmi_register_sensor(&instancedata->rmiphysdrvr, platformdata->sensordata); - if (retval) { - dev_err(&client->dev, "%s: Failed to Register %s sensor drivers\n", - __func__, instancedata->rmiphysdrvr.name); - i2c_set_clientdata(client, NULL); - kfree(instancedata); - return retval; - } - - if (instancedata->rmiphysdrvr.polling_required == false) { - retval = request_irq(instancedata->irq, i2c_attn_isr, - irqtype, "rmi_i2c", instancedata); - if (retval) { - dev_err(&client->dev, "%s: failed to obtain IRQ %d. Result: %d.", - __func__, instancedata->irq, retval); - dev_info(&client->dev, "%s: Reverting to polling.\n", __func__); - instancedata->rmiphysdrvr.polling_required = true; - /* TODO: Need to revert back to polling - create and start timer. */ - } else { - dev_dbg(&client->dev, "%s: got irq.\n", __func__); - } - } - - dev_dbg(&client->dev, "%s: Successfully registered %s sensor driver.\n", - __func__, instancedata->rmiphysdrvr.name); - - printk(KERN_INFO "%s: Successfully registered %s sensor driver.\n", __func__, instancedata->rmiphysdrvr.name); - - return retval; -} - -/* The Driver remove function. We tear down the instance data and unregister - * the phys driver in this call. - */ -static int -rmi_i2c_remove(struct i2c_client *client) -{ - struct instance_data *instancedata = - i2c_get_clientdata(client); - - dev_dbg(&client->dev, "%s: Unregistering phys driver %s\n", __func__, - instancedata->rmiphysdrvr.name); - - rmi_unregister_sensors(&instancedata->rmiphysdrvr); - - dev_dbg(&client->dev, "%s: Unregistered phys driver %s\n", - __func__, instancedata->rmiphysdrvr.name); - - /* only free irq if we have an irq - otherwise the instance_data - will be 0 for that field */ - if (instancedata->irq) - free_irq(instancedata->irq, instancedata); - - kfree(instancedata); - dev_dbg(&client->dev, "%s: Remove successful\n", __func__); - - return 0; -} - -#ifdef CONFIG_PM -static int -rmi_i2c_suspend(struct i2c_client *client, pm_message_t mesg) -{ - /* Touch sleep mode */ - return 0; -} - -static int -rmi_i2c_resume(struct i2c_client *client) -{ - /* Re-initialize upon resume */ - return 0; -} -#else -#define rmi_i2c_suspend NULL -#define rmi_i2c_resume NULL -#endif - -/* - * This structure tells the i2c subsystem about us. - * - * TODO: we should add .suspend and .resume fns. - * - */ -static struct i2c_driver rmi_i2c_driver = { - .probe = rmi_i2c_probe, - .remove = rmi_i2c_remove, - .suspend = rmi_i2c_suspend, - .resume = rmi_i2c_resume, - .driver = { - .name = DRIVER_NAME, - .owner = THIS_MODULE, - }, - .id_table = rmi_i2c_id_table, -}; - -/* - * Register ourselves with i2c Chip Driver. - * - */ -static int __init rmi_phys_i2c_init(void) -{ - return i2c_add_driver(&rmi_i2c_driver); -} - -/* - * Un-register ourselves from the i2c Chip Driver. - * - */ -static void __exit rmi_phys_i2c_exit(void) -{ - i2c_del_driver(&rmi_i2c_driver); -} - - -module_init(rmi_phys_i2c_init); -module_exit(rmi_phys_i2c_exit); - -MODULE_AUTHOR("Synaptics, Inc."); -MODULE_DESCRIPTION("RMI4 Driver I2C Physical Layer"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/synaptics/rmi_sensor.c b/drivers/input/touchscreen/synaptics/rmi_sensor.c deleted file mode 100644 index 2c64609c1aeaa0171746b9b8fd0f670d57f96f12..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_sensor.c +++ /dev/null @@ -1,662 +0,0 @@ -/** - * Synaptics Register Mapped Interface (RMI4) - RMI Sensor Module. - * Copyright (C) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################ - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * - *############################################################################ - */ - -static const char sensorname[] = "sensor"; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "rmi_drvr.h" -#include "rmi_bus.h" -#include "rmi_function.h" -#include "rmi_sensor.h" - -long polltime = 25000000; /* Shared with rmi_function.c. */ -EXPORT_SYMBOL(polltime); -module_param(polltime, long, 0644); -MODULE_PARM_DESC(polltime, "How long to wait between polls (in nano seconds)."); - - -#define PDT_START_SCAN_LOCATION 0x00E9 -#define PDT_END_SCAN_LOCATION 0x0005 -#define PDT_ENTRY_SIZE 0x0006 - -static DEFINE_MUTEX(rfi_mutex); - -struct rmi_functions *rmi_find_function(int functionNum); - -int rmi_read(struct rmi_sensor_driver *sensor, unsigned short address, - char *dest) -{ - struct rmi_phys_driver *rpd = sensor->rpd; - if (!rpd) - return -ENODEV; - return rpd->read(rpd, address, dest); -} -EXPORT_SYMBOL(rmi_read); - -int rmi_write(struct rmi_sensor_driver *sensor, unsigned short address, - unsigned char data) -{ - struct rmi_phys_driver *rpd = sensor->rpd; - if (!rpd) - return -ENODEV; - return rpd->write(rpd, address, data); -} -EXPORT_SYMBOL(rmi_write); - -int rmi_read_multiple(struct rmi_sensor_driver *sensor, - unsigned short address, char *dest, int length) -{ - struct rmi_phys_driver *rpd = sensor->rpd; - if (!rpd) - return -ENODEV; - return rpd->read_multiple(rpd, address, dest, length); -} -EXPORT_SYMBOL(rmi_read_multiple); - -int rmi_write_multiple(struct rmi_sensor_driver *sensor, - unsigned short address, unsigned char *data, int length) -{ - struct rmi_phys_driver *rpd = sensor->rpd; - if (!rpd) - return -ENODEV; - return rpd->write_multiple(rpd, address, data, length); -} -EXPORT_SYMBOL(rmi_write_multiple); - -/* Utility routine to set bits in a register. */ -int rmi_set_bits(struct rmi_sensor_driver *sensor, unsigned short address, - unsigned char bits) -{ - unsigned char reg_contents; - int retval; - - retval = rmi_read(sensor, address, ®_contents); - if (retval) - return retval; - reg_contents = reg_contents | bits; - retval = rmi_write(sensor, address, reg_contents); - if (retval == 1) - return 0; - else if (retval == 0) - return -EINVAL; /* TODO: What should this be? */ - else - return retval; -} -EXPORT_SYMBOL(rmi_set_bits); - -/* Utility routine to clear bits in a register. */ -int rmi_clear_bits(struct rmi_sensor_driver *sensor, - unsigned short address, unsigned char bits) -{ - unsigned char reg_contents; - int retval; - - retval = rmi_read(sensor, address, ®_contents); - if (retval) - return retval; - reg_contents = reg_contents & ~bits; - retval = rmi_write(sensor, address, reg_contents); - if (retval == 1) - return 0; - else if (retval == 0) - return -EINVAL; /* TODO: What should this be? */ - else - return retval; -} -EXPORT_SYMBOL(rmi_clear_bits); - -/* Utility routine to set the value of a bit field in a register. */ -int rmi_set_bit_field(struct rmi_sensor_driver *sensor, - unsigned short address, unsigned char field_mask, unsigned char bits) -{ - unsigned char reg_contents; - int retval; - - retval = rmi_read(sensor, address, ®_contents); - if (retval) - return retval; - reg_contents = (reg_contents & ~field_mask) | bits; - retval = rmi_write(sensor, address, reg_contents); - if (retval == 1) - return 0; - else if (retval == 0) - return -EINVAL; /* TODO: What should this be? */ - else - return retval; -} -EXPORT_SYMBOL(rmi_set_bit_field); - -bool rmi_polling_required(struct rmi_sensor_driver *sensor) -{ - return sensor->polling_required; -} -EXPORT_SYMBOL(rmi_polling_required); - -/** Functions can call this in order to dispatch IRQs. */ -void dispatchIRQs(struct rmi_sensor_driver *sensor, unsigned int irqStatus) -{ - struct rmi_function_info *functionInfo; - - list_for_each_entry(functionInfo, &sensor->functions, link) { - if ((functionInfo->interruptMask & irqStatus)) { - if (functionInfo->function_device-> - rmi_funcs->inthandler) { - /* Call the functions interrupt handler function. */ - functionInfo->function_device->rmi_funcs-> - inthandler(functionInfo, - (functionInfo->interruptMask & irqStatus)); - } - } - } -} - -/** - * This is the function we pass to the RMI4 subsystem so we can be notified - * when attention is required. It may be called in interrupt context. - */ -static void attention(struct rmi_phys_driver *physdrvr, int instance) -{ - /* All we have to do is schedule work. */ - - /* TODO: It's possible that workIsReady is not really needed anymore. - * Investigate this to see if the race condition between setting up - * the work and enabling the interrupt still exists. - */ - if (physdrvr->sensor->workIsReady) { - schedule_work(&(physdrvr->sensor->work)); - } else { - /* Got an interrupt but we're not ready so enable the irq - * so it doesn't get hung up - */ - printk(KERN_DEBUG "%s: Work not initialized yet -" - "enabling irqs.\n", __func__); - enable_irq(physdrvr->irq); - } -} - -/** - * This notifies any interested functions that there - * is an Attention interrupt. The interested functions should take - * appropriate - * actions (such as reading the interrupt status register and dispatching any - * appropriate RMI4 interrupts). - */ -void attn_notify(struct rmi_sensor_driver *sensor) -{ - struct rmi_function_info *functionInfo; - - /* check each function that has data sources and if the interrupt for - * that triggered then call that RMI4 functions report() function to - * gather data and report it to the input subsystem - */ - list_for_each_entry(functionInfo, &sensor->functions, link) { - if (functionInfo->function_device && - functionInfo->function_device->rmi_funcs->attention) - functionInfo->function_device-> - rmi_funcs->attention(functionInfo); - } -} - -/* This is the worker function - for now it simply has to call attn_notify. - * This work should be scheduled whenever an ATTN interrupt is asserted by - * the touch sensor. - * We then call attn_notify to dispatch notification of the ATTN interrupt - * to all - * interested functions. After all the attention handling functions - * have returned, it is presumed safe to re-enable the Attention interrupt. - */ -static void sensor_work_func(struct work_struct *work) -{ - struct rmi_sensor_driver *sensor = container_of(work, - struct rmi_sensor_driver, work); - - attn_notify(sensor); - - /* we only need to enable the irq if doing interrupts */ - if (!rmi_polling_required(sensor)) - enable_irq(sensor->rpd->irq); -} - -/* This is the timer function for polling - it simply has to schedule work - * and restart the timer. */ -static enum hrtimer_restart sensor_poll_timer_func(struct hrtimer *timer) -{ - struct rmi_sensor_driver *sensor = container_of(timer, - struct rmi_sensor_driver, timer); - - schedule_work(&sensor->work); - hrtimer_start(&sensor->timer, ktime_set(0, polltime), - HRTIMER_MODE_REL); - return HRTIMER_NORESTART; -} - -/* This is the probe function passed to the RMI4 subsystem that gives us a - * chance to recognize an RMI4 device. In this case, we're looking for - * Synaptics devices that have data sources - such as touch screens, buttons, - * etc. - * - * TODO: Well, it used to do this. I'm not sure it's required any more. - */ -static int probe(struct rmi_sensor_driver *sensor) -{ - struct rmi_phys_driver *rpd; - - rpd = sensor->rpd; - - if (!rpd) { - printk(KERN_ERR "%s: Invalid rmi physical driver - null ptr:" - "%p\n", __func__, rpd); - return 0; - } - - return 1; -} - -static void config(struct rmi_sensor_driver *sensor) -{ - /* For each data source we had detected print info and set up interrupts - or polling. */ - struct rmi_function_info *functionInfo; - struct rmi_phys_driver *rpd; - - rpd = sensor->rpd; /* get ptr to rmi_physical_driver from app */ - - list_for_each_entry(functionInfo, &sensor->functions, link) { - /* Get and print some info about the data sources... */ - struct rmi_functions *fn; - bool found = false; - /* check if function number matches - if so call that - config function */ - fn = rmi_find_function(functionInfo->functionNum); - if (fn) { - found = true; - - if (fn->config) { - fn->config(functionInfo); - } else { - /* the developer did not add in the - pointer to the config function into - rmi4_supported_data_src_functions */ - printk(KERN_ERR - "%s: no config function for " - "function 0x%x\n", - __func__, functionInfo->functionNum); - break; - } - } - - if (!found) { - /* if no support found for this RMI4 function - it means the developer did not add the - appropriate function pointer list into the - rmi4_supported_data_src_functions array and/or - did not bump up the number of supported RMI4 - functions in rmi.h as required */ - printk(KERN_ERR "%s: could not find support " - "for function 0x%x\n", - __func__, functionInfo->functionNum); - } - } - - /* This will handle interrupts on the ATTN line (interrupt driven) - * or will be called every poll interval (when we're not interrupt - * driven). - */ - INIT_WORK(&sensor->work, sensor_work_func); - sensor->workIsReady = true; - - if (rmi_polling_required(sensor)) { - /* We're polling driven, so set up the polling timer - and timer function. */ - hrtimer_init(&sensor->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - sensor->timer.function = sensor_poll_timer_func; - hrtimer_start(&sensor->timer, ktime_set(1, 0), HRTIMER_MODE_REL); - } -} - -/** Just a stub for now. - */ -static int rmi_sensor_suspend(struct device *dev, pm_message_t state) -{ - printk(KERN_INFO "%s: sensor suspend called.", __func__); - return 0; -} - -/** Just a stub for now. - */ -static int rmi_sensor_resume(struct device *dev) -{ - printk(KERN_INFO "%s: sensor resume called.", __func__); - return 0; -} - -/* - * This method is called, whenever a new sensor device is added for the rmi - * bus. - * - * It will scan the devices PDT to determine the supported functions - * and create a new function device for each of these. It will read - * the query, control, command and data regsiters for the function - * to be used for each newly created function device. - * - * The sensor device is then bound to every function it supports. - * - */ -int rmi_sensor_register_functions(struct rmi_sensor_driver *sensor) -{ - struct rmi_function_device *function; - unsigned int interruptRegisterCount; - struct rmi_phys_driver *rpd; - int i; - unsigned char interruptCount; - struct rmi_function_info *functionInfo; - struct rmi_function_descriptor rmi_fd; - struct rmi_functions *fn; - int retval; - - pr_debug("%s: Registering sensor functions\n", __func__); - - retval = 0; - - /* Scan device for functions that may be supported */ - { - pr_debug("%s: Scanning sensor for Functions:\n", __func__); - - interruptCount = 0; - rpd = sensor->rpd; - - /* Read the Page Descriptor Table to determine what functions - * are present */ - - printk(KERN_DEBUG "%s: Scanning page descriptors.", __func__); - for (i = PDT_START_SCAN_LOCATION; - i >= PDT_END_SCAN_LOCATION; - i -= PDT_ENTRY_SIZE) { - printk(KERN_DEBUG "%s: Reading page descriptor 0x%02x", __func__, i); - retval = rpd->read_multiple(rpd, i, (char *)&rmi_fd, - sizeof(rmi_fd)); - if (!retval) { - functionInfo = NULL; - - if (rmi_fd.functionNum != 0x00 && rmi_fd.functionNum != 0xff) { - printk(KERN_DEBUG "%s: F%02x - queries %02x commands %02x control %02x data %02x ints %02x", __func__, rmi_fd.functionNum, rmi_fd.queryBaseAddr, rmi_fd.commandBaseAddr, rmi_fd.controlBaseAddr, rmi_fd.dataBaseAddr, rmi_fd.interruptSrcCnt); - - if ((rmi_fd.functionNum & 0xff) == 0x01) - printk(KERN_DEBUG "%s: Fn $01 Found - RMI Device Control", __func__); - - /* determine if the function is supported and if so - * then bind this function device to the sensor */ - if (rmi_fd.interruptSrcCnt) { - functionInfo = kzalloc(sizeof(*functionInfo), GFP_KERNEL); - if (!functionInfo) { - printk(KERN_ERR "%s: could not allocate memory for function 0x%x.", - __func__, rmi_fd.functionNum); - retval = -ENOMEM; - goto exit_fail; - } - functionInfo->sensor = sensor; - functionInfo->functionNum = (rmi_fd.functionNum & 0xff); - INIT_LIST_HEAD(&functionInfo->link); - /* Get the ptr to the detect function based on - * the function number */ - printk(KERN_DEBUG "%s: Checking for RMI function F%02x.", __func__, rmi_fd.functionNum); - fn = rmi_find_function(rmi_fd.functionNum); - if (fn) { - retval = fn->detect(functionInfo, &rmi_fd, - interruptCount); - if (retval) - printk(KERN_ERR "%s: Function detect for F%02x failed with %d.", - __func__, rmi_fd.functionNum, retval); - - /* Create a function device and function driver for this Fn */ - function = kzalloc(sizeof(*function), GFP_KERNEL); - if (!function) { - printk(KERN_ERR "%s: Error allocating memory for rmi_function_device.", __func__); - return -ENOMEM; - } - - function->dev.parent = &sensor->sensor_device->dev; - function->dev.bus = sensor->sensor_device->dev.bus; - function->rmi_funcs = fn; - function->sensor = sensor; - function->rfi = functionInfo; - functionInfo->function_device = function; - - /* Check if we have an interrupt mask of 0 and a non-NULL interrupt - handler function and print a debug message since we should never - have this. - */ - if (functionInfo->interruptMask == 0 && fn->inthandler != NULL) { - printk(KERN_DEBUG "%s: Can't have a zero interrupt mask for function F%02x (which requires an interrupt handler).\n", - __func__, rmi_fd.functionNum); - } - - - /* Check if we have a non-zero interrupt mask and a NULL interrupt - handler function and print a debug message since we should never - have this. - */ - if (functionInfo->interruptMask != 0 && fn->inthandler == NULL) { - printk(KERN_DEBUG "%s: Can't have a non-zero interrupt mask %d for function F%02x with a NULL inthandler fn.\n", - __func__, functionInfo->interruptMask, rmi_fd.functionNum); - } - - /* Register the rmi function device */ - retval = rmi_function_register_device(function, rmi_fd.functionNum); - if (retval) { - printk(KERN_ERR "%s: Failed rmi_function_register_device.\n", - __func__); - return retval; - } - } else { - printk(KERN_ERR "%s: could not find support for function 0x%02X.\n", - __func__, rmi_fd.functionNum); - } - } else { - printk(KERN_DEBUG "%s: Found function F%02x - Ignored.\n", __func__, rmi_fd.functionNum & 0xff); - } - - /* bump interrupt count for next iteration */ - /* NOTE: The value 7 is reserved - for now, only bump up one for an interrupt count of 7 */ - if ((rmi_fd.interruptSrcCnt & 0x7) == 0x7) { - interruptCount += 1; - } else { - interruptCount += - (rmi_fd.interruptSrcCnt & 0x7); - } - - /* link this function info to the RMI module infos list - of functions */ - if (functionInfo == NULL) { - printk(KERN_DEBUG "%s: WTF? functionInfo is null here.", __func__); - } else { - printk(KERN_DEBUG "%s: Adding function F%02x with %d sources.\n", - __func__, functionInfo->functionNum, functionInfo->numSources); - - mutex_lock(&rfi_mutex); - list_add_tail(&functionInfo->link, - &sensor->functions); - mutex_unlock(&rfi_mutex); - } - - } else { - /* A zero or 0xff in the function number - signals the end of the PDT */ - printk(KERN_DEBUG "%s: Found End of PDT\n", - __func__); - break; - } - } else { - /* failed to read next PDT entry - end PDT - scan - this may result in an incomplete set - of recognized functions - should probably - return an error but the driver may still be - viable for diagnostics and debugging so let's - let it continue. */ - printk(KERN_ERR "%s: Read Error %d when reading next PDT entry - " - "ending PDT scan.\n", - __func__, retval); - break; - } - } - printk(KERN_DEBUG "%s: Done scanning.", __func__); - - /* calculate the interrupt register count - used in the - ISR to read the correct number of interrupt registers */ - interruptRegisterCount = (interruptCount + 7) / 8; - sensor->interruptRegisterCount = interruptRegisterCount; /* TODO: Is this needed by the sensor anymore? */ - } - - return 0; - -exit_fail: - return retval; -} -EXPORT_SYMBOL(rmi_sensor_register_functions); - -int rmi_sensor_register_device(struct rmi_sensor_device *dev, int index) -{ - int status; - - printk(KERN_INFO "%s: Registering sensor device.\n", __func__); - - /* make name - sensor00, sensor01, etc. */ - dev_set_name(&dev->dev, "sensor%02d", index); - status = device_register(&dev->dev); - - return status; -} -EXPORT_SYMBOL(rmi_sensor_register_device); - -static void rmi_sensor_unregister_device(struct rmi_sensor_device *rmisensordev) -{ - printk(KERN_INFO "%s: Unregistering sensor device.\n", __func__); - - device_unregister(&rmisensordev->dev); -} -EXPORT_SYMBOL(rmi_sensor_unregister_device); - -int rmi_sensor_register_driver(struct rmi_sensor_driver *driver) -{ - static int index; - int ret; - char *drvrname; - - driver->workIsReady = false; - - printk(KERN_INFO "%s: Registering sensor driver.\n", __func__); - driver->dispatchIRQs = dispatchIRQs; - driver->attention = attention; - driver->config = config; - driver->probe = probe; - - /* assign the bus type for this driver to be rmi bus */ - driver->drv.bus = &rmi_bus_type; - driver->drv.suspend = rmi_sensor_suspend; - driver->drv.resume = rmi_sensor_resume; - /* Create a function device and function driver for this Fn */ - drvrname = kzalloc(sizeof(sensorname) + 4, GFP_KERNEL); - if (!drvrname) { - printk(KERN_ERR "%s: Error allocating memeory for rmi_sensor_driver name.\n", __func__); - return -ENOMEM; - } - sprintf(drvrname, "sensor%02d", index++); - - driver->drv.name = drvrname; - driver->module = driver->drv.owner; - - /* register the sensor driver */ - ret = driver_register(&driver->drv); - if (ret) { - printk(KERN_ERR "%s: Failed driver_register %d\n", - __func__, ret); - goto exit_fail; - } - - /* register the functions on the sensor */ - ret = rmi_sensor_register_functions(driver); - if (ret) { - printk(KERN_ERR "%s: Failed rmi_sensor_register_functions %d\n", - __func__, ret); - } - - /* configure the sensor - enable interrupts for each function, init work, set polling timer or adjust report rate, etc. */ - config(driver); - - printk(KERN_DEBUG "%s: sensor driver registration completed.", __func__); - -exit_fail: - return ret; -} -EXPORT_SYMBOL(rmi_sensor_register_driver); - -static void rmi_sensor_unregister_driver(struct rmi_sensor_driver *driver) -{ - printk(KERN_DEBUG "%s: Unregistering sensor driver.\n", __func__); - - /* Stop the polling timer if doing polling */ - if (rmi_polling_required(driver)) - hrtimer_cancel(&driver->timer); - - flush_scheduled_work(); /* Make sure all scheduled work is stopped */ - - driver_unregister(&driver->drv); -} -EXPORT_SYMBOL(rmi_sensor_unregister_driver); - - -static int __init rmi_sensor_init(void) -{ - printk(KERN_DEBUG "%s: RMI Sensor Init\n", __func__); - return 0; -} - -static void __exit rmi_sensor_exit(void) -{ - printk(KERN_DEBUG "%s: RMI Sensor Driver Exit\n", __func__); - flush_scheduled_work(); /* Make sure all scheduled work is stopped */ -} - - -module_init(rmi_sensor_init); -module_exit(rmi_sensor_exit); - -MODULE_AUTHOR("Synaptics, Inc."); -MODULE_DESCRIPTION("RMI4 Sensor Driver"); -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/synaptics/rmi_sensor.h b/drivers/input/touchscreen/synaptics/rmi_sensor.h deleted file mode 100644 index 63d255538775da89744a9f3e5fd4d55ca279e716..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_sensor.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) - RMI Sensor Module Header. - * Copyright (C) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * - * This file is licensed under the GPL2 license. - * - *############################################################################ - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 - -#ifndef _RMI_SENSOR_H -#define _RMI_SENSOR_H - -#include - -struct rmi_sensor_driver { - struct module *module; - struct device_driver drv; - struct rmi_sensor_device *sensor_device; - - /* Attention Function - * This function is called by the low level isr in the physical - * driver. It merely schedules work to be done. - */ - void (*attention)(struct rmi_phys_driver *physdrvr, int instance); - /* Probe Function - * This function is called to give the sensor driver layer an - * opportunity to claim an RMI device. The sensor layer cannot - * read RMI registers at this point since the rmi physical driver - * has not been bound to it yet. Defer that to the config - * function call which occurs immediately after a successful probe. - */ - int (*probe)(struct rmi_sensor_driver *sensor); - /* Config Function - * This function is called after a successful probe. It gives the - * sensor driver an opportunity to query and/or configure an RMI - * device before data starts flowing. - */ - void (*config)(struct rmi_sensor_driver *sensor); - - /* Functions can call this in order to dispatch IRQs. */ - void (*dispatchIRQs)(struct rmi_sensor_driver *sensor, - unsigned int irqStatus); - - /* Register Functions - * This function is called in the rmi bus - * driver to have the sensor driver scan for any supported - * functions on the sensor and add devices for each one. - */ - void (*rmi_sensor_register_functions)(struct rmi_sensor_driver - *sensor); - - unsigned int interruptRegisterCount; - - bool polling_required; - - /* pointer to the corresponding phys driver info for this sensor */ - /* The phys driver has the pointers to read, write, etc. */ - struct rmi_phys_driver *rpd; - - struct hrtimer timer; - struct work_struct work; - bool workIsReady; - - /* This list is for keeping around the list of sensors. - * Every time that a physical device is detected by the - * physical layer - be it i2c, spi, or some other - then - * we need to bind the physical layer to the device. When - * the Page Descriptor Table is scanned and when Function $01 - * is found then a new sensor device is created. The corresponding - * rmi_phys_driver struct pointer needs to be bound to the new - * sensor since Function $01 will be used to control and get - * interrupt information about the particular data source that is - * doing the interrupt. The rmi_phys_driver contains the pointers - * to the particular read, write, read_multiple, write_multiple - * functions for this device. This rmi_phys_driver struct will - * have to be up-bound to any drivers upstream that need it. - */ - - /* Standard kernel linked list implementation. - * Documentation on how to use it can be found at - * http://isis.poly.edu/kulesh/stuff/src/klist/. - */ - struct list_head sensor_drivers; /* link sensor drivers into list */ - - struct list_head functions; /* List of rmi_function_infos */ - /* Per function initialization data. */ - struct rmi_functiondata_list *perfunctiondata; -}; - -/* macro to get the pointer to the device_driver struct from the sensor */ -#define to_rmi_sensor_driver(drv) container_of(drv, \ - struct rmi_sensor_driver, drv); - -struct rmi_sensor_device { - struct rmi_sensor_driver *driver; - struct device dev; - - /* Standard kernel linked list implementation. - * Documentation on how to use it can be found at - * http://isis.poly.edu/kulesh/stuff/src/klist/. - */ - struct list_head sensors; /* link sensors into list */ -}; - -int rmi_sensor_register_device(struct rmi_sensor_device *dev, int index); -int rmi_sensor_register_driver(struct rmi_sensor_driver *driver); -int rmi_sensor_register_functions(struct rmi_sensor_driver *sensor); -bool rmi_polling_required(struct rmi_sensor_driver *sensor); - -static inline void *rmi_sensor_get_functiondata(struct rmi_sensor_driver - *driver, unsigned char function_index) -{ - int i; - if (driver->perfunctiondata) { - for (i = 0; i < driver->perfunctiondata->count; i++) { - if (driver->perfunctiondata->functiondata[i]. - function_index == function_index) - return driver->perfunctiondata-> - functiondata[i].data; - } - } - return NULL; -} - -#endif diff --git a/drivers/input/touchscreen/synaptics/rmi_spi.c b/drivers/input/touchscreen/synaptics/rmi_spi.c deleted file mode 100644 index 662f40e908a6a27583d72b5ff0d229c722f91908..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_spi.c +++ /dev/null @@ -1,616 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) SPI Physical Layer Driver. - * Copyright (C) 2008-2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################ - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include "rmi_spi.h" -#include "rmi_drvr.h" - -#define COMM_DEBUG 1 /* Set to 1 to dump transfers. */ - -/* 65 microseconds inter-byte delay between bytes for RMI chip*/ -#define RMI_DEFAULT_BYTE_DELAY_US 0 /* 65 */ -#define SPI_BUFFER_SIZE 32 - -static u8 *buf; - -/* This is the data kept on a per instance (client) basis. This data is - * always accessible by using the container_of() macro of the various elements - * inside. - */ -struct spi_device_instance_data { - int instance_no; - int irq; - unsigned int byte_delay_us; - struct rmi_phys_driver rpd; - struct spi_device *spidev; - struct rmi_spi_platformdata *platformdata; -}; - -static int spi_xfer(struct spi_device_instance_data *instance_data, - const u8 *txbuf, unsigned n_tx, u8 *rxbuf, unsigned n_rx) -{ - struct spi_device *spi = instance_data->spidev; -#if COMM_DEBUG - int i; -#endif - int status; - struct spi_message message; - struct spi_transfer *xfer_list; - u8 *local_buf; - int nXfers = 0; - int xfer_index = 0; - - if ((n_tx + n_rx) > SPI_BUFFER_SIZE) - return -EINVAL; - - if (n_tx) - nXfers += 1; - if (n_rx) { - if (instance_data->byte_delay_us) - nXfers += n_rx; - else - nXfers += 1; - } - - xfer_list = kcalloc(nXfers, sizeof(struct spi_transfer), GFP_KERNEL); - if (!xfer_list) - return -ENOMEM; - - /* ... unless someone else is using the pre-allocated buffer */ - local_buf = kzalloc(SPI_BUFFER_SIZE, GFP_KERNEL); - if (!local_buf) { - kfree(xfer_list); - return -ENOMEM; - } - - spi_message_init(&message); - - if (n_tx) { - memset(&xfer_list[0], 0, sizeof(struct spi_transfer)); - xfer_list[0].len = n_tx; - xfer_list[0].delay_usecs = instance_data->byte_delay_us; - spi_message_add_tail(&xfer_list[0], &message); - memcpy(local_buf, txbuf, n_tx); - xfer_list[0].tx_buf = local_buf; - xfer_index++; - } - if (n_rx) { - if (instance_data->byte_delay_us) { - int buffer_offset = n_tx; - for (; xfer_index < nXfers; xfer_index++) { - memset(&xfer_list[xfer_index], 0, - sizeof(struct spi_transfer)); - xfer_list[xfer_index].len = 1; - xfer_list[xfer_index].delay_usecs = - instance_data->byte_delay_us; - xfer_list[xfer_index].rx_buf = - local_buf + buffer_offset; - buffer_offset++; - spi_message_add_tail(&xfer_list[xfer_index], - &message); -#ifdef CONFIG_ARCH_OMAP - printk(KERN_INFO "%s: Did you compensate for - ARCH_OMAP?", __func__); -/* x[1].len = n_rx-1; */ /* since OMAP has one dummy byte. */ -#else -/* x[1].len = n_rx; */ -#endif - } - } else { - memset(&xfer_list[xfer_index], 0, sizeof(struct - spi_transfer)); -#ifdef CONFIG_ARCH_OMAP - /* since OMAP has one dummy byte. */ - xfer_list[xfer_index].len = n_rx-1; -#else - xfer_list[xfer_index].len = n_rx; -#endif - xfer_list[xfer_index].rx_buf = local_buf + n_tx; - spi_message_add_tail(&xfer_list[xfer_index], - &message); - xfer_index++; - } - } - printk(KERN_INFO "%s: Ready to go, xfer_index = %d, nXfers = %d.", - __func__, xfer_index, nXfers); -#if COMM_DEBUG - printk(KERN_INFO "%s: SPI transmits %d bytes...", __func__, n_tx); - for (i = 0; i < n_tx; i++) - printk(KERN_INFO " 0x%02X", local_buf[i]); -#endif - - /* do the i/o */ - status = spi_sync(spi, &message); - if (status == 0) { - memcpy(rxbuf, local_buf + n_tx, n_rx); - status = message.status; -#if COMM_DEBUG - if (n_rx) { - printk(KERN_INFO "%s: SPI received %d bytes...", - __func__, n_rx); - for (i = 0; i < n_rx; i++) - printk(KERN_INFO " 0x%02X", rxbuf[i]); - } -#endif - } else { - printk(KERN_ERR "%s: spi_sync failed with error code %d.", - __func__, status); - } - - kfree(local_buf); - kfree(xfer_list); - - return status; -} - -/** - * Read a single register through spi. - * \param[in] pd - * \param[in] address The address at which to start the data read. - * \param[out] valp Pointer to the buffer where the data will be stored. - * \return zero upon success (with the byte read in valp),non-zero upon error. - */ -static int -rmi_spi_read(struct rmi_phys_driver *pd, unsigned short address, char *valp) -{ - struct spi_device_instance_data *id = - container_of(pd, struct spi_device_instance_data, rpd); - - char rxbuf[2]; - int retval; - unsigned short addr = address; - - addr = ((addr & 0xff00) >> 8); - address = ((address & 0x00ff) << 8); - addr |= address; - addr |= 0x80; /* High bit set indicates read. */ - - retval = spi_xfer(id, (u8 *)&addr, 2, rxbuf, 1); - - *valp = rxbuf[0]; - - return retval; -} - -/** - * Same as rmi_spi_read, except that multiple bytes are allowed to be read. - * \param[in] pd - * \param[in] address The address at which to start the data read. - * \param[out] valp Pointer to the buffer where the data will be stored. This - * buffer must be at least size bytes long. - * \param[in] size The number of bytes to be read. - * \return zero upon success(with the byte read in valp), non-zero upon error. - */ -static int -rmi_spi_read_multiple(struct rmi_phys_driver *pd, unsigned short address, - char *valp, int size) -{ - struct spi_device_instance_data *id = - container_of(pd, struct spi_device_instance_data, rpd); - int retval; - - unsigned short addr = address; - - addr = ((addr & 0xff00) >> 8); - address = ((address & 0x00ff) << 8); - addr |= address; - addr |= 0x80; /* High bit set indicates read. */ - - retval = spi_xfer(id, (u8 *)&addr, 2, valp, size); - - return retval; -} - -/** - * Write a single register through spi. - * You can write multiple registers at once, but I made the functions for that - * seperate for performance reasons. Writing multiple requires allocation and - * freeing. - * \param[in] pd - * \param[in] address The address at which to start the write. - * \param[in] data The data to be written. - * \return one upon success, something else upon error. - */ -static int -rmi_spi_write(struct rmi_phys_driver *pd, unsigned short address, char data) -{ - struct spi_device_instance_data *id = - container_of(pd, struct spi_device_instance_data, rpd); - unsigned char txbuf[4]; - int retval; - - txbuf[2] = data; - txbuf[1] = address; - txbuf[0] = address>>8; - - retval = spi_xfer(id, txbuf, 3, NULL, 0); - return retval ? 0 : 1; -} - -/** - * Write multiple registers. - * \param[in] pd - * \param[in] address The address at which to start the write. - * \param[in] valp A pointer to a buffer containing the data to be written. - * \param[in] size The number of bytes to write. - * \return one upon success, something else upon error. - */ -static int -rmi_spi_write_multiple(struct rmi_phys_driver *pd, unsigned short address, - char *valp, int size) -{ - struct spi_device_instance_data *id = - container_of(pd, struct spi_device_instance_data, rpd); - unsigned char txbuf[32]; - int retval; - int i; - - txbuf[1] = address; - txbuf[0] = address>>8; - - for (i = 0; i < size; i++) - txbuf[i + 2] = valp[i]; - - retval = spi_xfer(id, txbuf, size+2, NULL, 0); - - return retval ? 0 : 1; -} - -/** - * This is the Interrupt Service Routine. - * It just notifies the physical device - * that attention is required. - */ -static irqreturn_t spi_attn_isr(int irq, void *info) -{ - struct spi_device_instance_data *instance_data = info; - disable_irq_nosync(instance_data->irq); - if (instance_data->rpd.attention) - instance_data->rpd.attention(&instance_data->rpd, - instance_data->instance_no); - return IRQ_HANDLED; -} - -/* TODO: Move this to rmi_bus, and call a function to get the next sensorID - */ -static int sensor_count; - -static int rmi_spi_probe(struct spi_device *spi) -{ - struct spi_device_instance_data *instance_data; - int retval; - struct rmi_spi_platformdata *platformdata; - struct rmi_sensordata *sensordata; - int irqtype = 0; - - printk(KERN_INFO "Probing RMI4 SPI device\n"); - - /* This should have already been set up in the board file, - shouldn't it? */ - spi->bits_per_word = 8; - - spi->mode = SPI_MODE_3; - - retval = spi_setup(spi); - if (retval < 0) { - printk(KERN_ERR "%s: spi_setup failed with %d.", __func__, - retval); - return retval; - } - - buf = kzalloc(SPI_BUFFER_SIZE, GFP_KERNEL); - if (!buf) { - printk(KERN_ERR "%s: Failed to allocate memory for spi - buffer.", __func__); - return -ENOMEM; - } - - instance_data = kzalloc(sizeof(*instance_data), GFP_KERNEL); - if (!instance_data) { - printk(KERN_ERR "%s: Failer to allocate memory for instance - data.", __func__); - return -ENOMEM; - } - - instance_data->byte_delay_us = RMI_DEFAULT_BYTE_DELAY_US; - instance_data->spidev = spi; - instance_data->rpd.name = RMI4_SPI_DRIVER_NAME; - instance_data->rpd.write = rmi_spi_write; - instance_data->rpd.read = rmi_spi_read; - instance_data->rpd.write_multiple = rmi_spi_write_multiple; - instance_data->rpd.read_multiple = rmi_spi_read_multiple; - instance_data->rpd.module = THIS_MODULE; - /* default to polling if irq not used */ - instance_data->rpd.polling_required = true; - - platformdata = spi->dev.platform_data; - if (platformdata == NULL) { - printk(KERN_ERR "%s: CONFIGURATION ERROR - platform data - is NULL.", __func__); - return -EINVAL; - } - - instance_data->platformdata = platformdata; - sensordata = platformdata->sensordata; - - /* Call the platform setup routine, to do any setup that is required - * before - * interacting with the device. - */ - if (sensordata && sensordata->rmi_sensor_setup) { - retval = sensordata->rmi_sensor_setup(); - if (retval) { - printk(KERN_ERR "%s: sensor setup failed with - code %d.", __func__, retval); - kfree(instance_data); - return retval; - } - } - - /* TODO: I think this if is no longer required. */ - if (platformdata->chip == RMI_SUPPORT) { - instance_data->instance_no = sensor_count; - sensor_count++; - - /* set the device name using the instance_no - * appended to DEVICE_NAME to make a unique name - */ - dev_set_name(&spi->dev, "%s%d", RMI4_SPI_DEVICE_NAME, - instance_data->instance_no); - /* - * Determine if we need to poll (inefficient) or - * use interrupts. - */ - if (platformdata->irq) { - switch (platformdata->irq_type) { - case IORESOURCE_IRQ_HIGHEDGE: - irqtype = IRQF_TRIGGER_RISING; - break; - case IORESOURCE_IRQ_LOWEDGE: - irqtype = IRQF_TRIGGER_FALLING; - break; - case IORESOURCE_IRQ_HIGHLEVEL: - irqtype = IRQF_TRIGGER_HIGH; - break; - case IORESOURCE_IRQ_LOWLEVEL: - irqtype = IRQF_TRIGGER_LOW; - break; - default: - dev_warn(&spi->dev, "%s: Invalid IRQ flags - in platform data.", __func__); - retval = -ENXIO; - goto error_exit; - } -/* - retval = request_irq(instance_data->irq, spi_attn_isr, - irqtype, "rmi_spi", instance_data); - if (retval) { - dev_info(&spi->dev, "%s: Unable to get attn - irq %d. Reverting to polling. ", __func__, - instance_data->irq); - instance_data->rpd.polling_required = true; - } else { - dev_dbg(&spi->dev, "%s: got irq", __func__); - instance_data->rpd.polling_required = false; - instance_data->rpd.irq = instance_data->irq; - } -*/ - instance_data->rpd.polling_required = false; - } else { - instance_data->rpd.polling_required = true; - dev_info(&spi->dev, "%s: No IRQ info given. - Polling required.", __func__); - } - } - - /* Store instance data for later access. */ - if (instance_data) - spi_set_drvdata(spi, instance_data); - - /* Register the sensor driver - - * which will trigger a scan of the PDT. - */ - retval = rmi_register_sensor(&instance_data->rpd, - platformdata->sensordata); - if (retval) { - printk(KERN_ERR "%s: sensor registration failed with code - %d.", __func__, retval); - goto error_exit; - } - - if (instance_data->rpd.polling_required == false) { - instance_data->irq = platformdata->irq; - retval = request_irq(platformdata->irq, spi_attn_isr, - irqtype, dev_name(&spi->dev), instance_data); - if (retval) { - dev_err(&spi->dev, "%s: failed to obtain IRQ %d. - Result: %d.", __func__, - platformdata->irq, retval); - dev_info(&spi->dev, "%s: Reverting to polling.\n", - __func__); - instance_data->rpd.polling_required = true; - instance_data->irq = 0; - /* TODO: Need to revert back to polling - * - create and start timer. - */ - } else { - dev_dbg(&spi->dev, "%s: got irq.\n", __func__); - instance_data->rpd.irq = instance_data->irq; - } - } - - printk(KERN_INFO "%s: Successfully Registered %s.", - __func__, instance_data->rpd.name); - - return 0; - -error_exit: - if (sensordata && sensordata->rmi_sensor_teardown) - sensordata->rmi_sensor_teardown(); - if (instance_data->irq) - free_irq(instance_data->irq, instance_data); - kfree(instance_data); - return retval; -} - -static int rmi_spi_suspend(struct spi_device *spi, pm_message_t message) -{ - printk(KERN_INFO "%s: Suspending...", __func__); - return 0; -} - -static int rmi_spi_resume(struct spi_device *spi) -{ - printk(KERN_INFO "%s: Resuming...", __func__); - return 0; -} - -static int rmi_spi_remove(struct spi_device *spi) -{ - struct spi_device_instance_data *id = spi_get_drvdata(spi); - - printk(KERN_INFO "%s: RMI SPI device removed.", __func__); - - rmi_spi_suspend(spi, PMSG_SUSPEND); - - rmi_unregister_sensors(&id->rpd); - - if (id) { - if (id->irq) - free_irq(id->irq, id); - kfree(id); - } - - return 0; -} - -static struct spi_driver rmi_spi_driver = { - .driver = { - .name = RMI4_SPI_DRIVER_NAME, - .bus = &spi_bus_type, - .owner = THIS_MODULE, - }, - .probe = rmi_spi_probe, - .remove = rmi_spi_remove, - .suspend = rmi_spi_suspend, - .resume = rmi_spi_resume, -}; - -/** - * The Platform Driver probe function. We just tell the spi subsystem about - * ourselves in this call. - */ -static int -rmi_spi_plat_probe(struct platform_device *dev) -{ - struct rmi_spi_platformdata *platform_data = dev->dev.platform_data; - - printk(KERN_INFO "%s: Platform driver probe.", __func__); - - if (!platform_data) { - printk(KERN_ERR "A platform device must contain - rmi_spi_platformdata\n"); - return -ENXIO; - } - - return spi_register_driver(&rmi_spi_driver); -} - -/** - * Tell the spi subsystem that we're done. - * \param[in] dev - * \return Always returns 0. - */ -static int -rmi_spi_plat_remove(struct platform_device *dev) -{ - printk(KERN_INFO "%s: Platform driver removed.", __func__); - spi_unregister_driver(&rmi_spi_driver); - return 0; -} - -/** - * Structure used to tell the Platform Driver subsystem about us. - */ -static struct platform_driver rmi_spi_platform_driver = { - .driver = { - .name = RMI4_SPI_DRIVER_NAME, - .owner = THIS_MODULE, - }, - .probe = rmi_spi_plat_probe, - .remove = rmi_spi_plat_remove, -}; - -static int __init rmi_spi_init(void) -{ - int retval; - - printk(KERN_INFO "%s: RMI SPI physical layer initialization.", - __func__); - retval = spi_register_driver(&rmi_spi_driver); - if (retval < 0) { - printk(KERN_ERR "%s: Failed to register spi driver, code - = %d.", __func__, retval); - return retval; - } -/* -#else - retval = platform_driver_register(&rmi_spi_platform_driver); - if (retval < 0) { - printk(KERN_ERR "%s: Failed to register platform driver, - code = %d.", __func__, retval); - return retval; - } -#endif -*/ - printk(KERN_INFO "%s: result = %d", __func__, retval); - return retval; -} -module_init(rmi_spi_init); - -static void __exit rmi_spi_exit(void) -{ - printk(KERN_INFO "%s: RMI SPI physical layer exits.", __func__); - kfree(buf); - buf = NULL; - platform_driver_unregister(&rmi_spi_platform_driver); -} -module_exit(rmi_spi_exit); - -/** Standard driver module information - the author of the module. - */ -MODULE_AUTHOR("Synaptics, Inc."); -/** Standard driver module information - a summary description of this module. - */ -MODULE_DESCRIPTION("RMI4 Driver SPI Physical Layer"); -/** Standard driver module information - the license under which this module - * is included in the kernel. - */ -MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/synaptics/rmi_spi.h b/drivers/input/touchscreen/synaptics/rmi_spi.h deleted file mode 100644 index daeebede2cce18d75acc1ebb26127dd5cda2ad6d..0000000000000000000000000000000000000000 --- a/drivers/input/touchscreen/synaptics/rmi_spi.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - * Register Mapped Interface SPI Physical Layer Driver Header File. - * Copyright (C) 2008-2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * - *############################################################################# - */ - -#if !defined(_RMI_SPI_H) -#define _RMI_SPI_H - -#include - -#define RMI_CHIP_VER_3 0 -#define RMI_CHIP_VER_4 1 - -#define RMI_SUPPORT (RMI_CHIP_VER_3|RMI_CHIP_VER_4) - -#define RMI4_SPI_DRIVER_NAME "rmi4_ts" -#define RMI4_SPI_DEVICE_NAME "rmi4_ts" - -/** Platform-specific configuration data. - * This structure is used by the platform-specific driver to designate - * specific information about the hardware. A platform client may supply - * an array of these to the rmi_phys_spi driver. - */ -struct rmi_spi_platformdata { - int chip; - - /* The number of the irq. Set to zero if polling is required. */ - int irq; - - /* The type of the irq (e.g., IRQF_TRIGGER_FALLING). Only valid if - * irq != 0 */ - int irq_type; - - /* Use this to specify platformdata that is not I2C specific. */ - struct rmi_sensordata *sensordata; -}; - -#endif diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index b88d15f347bfe914c2d18ed1bdf82672c210ca66..519172394b45225f3de30126db290c47d5b75cfc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -181,44 +181,6 @@ config LEDS_GPIO defined as platform devices and/or OpenFirmware platform devices. The code to use these bindings can be selected below. -config LEDS_MSM_PDM - tristate "LED Support through PDM" - depends on LEDS_CLASS - help - This option enables support for the LEDs operated through Pulse - Denisty Modulation. - - If unsure, say N. - - To compile this driver as a module, choose M here: the - module will be called leds-msm-pdm. - -config LEDS_PMIC_MPP - tristate "LED Support for Qualcomm PMIC MPP connected LEDs" - depends on LEDS_CLASS && MSM_SMD - help - This option enables support for LEDs connected to PMIC MPPs - on Qualcomm reference boards. - - If unsure, say N. - - To compile this driver as a module, choose M here: the - module will be called leds-pmic-mpp. - -config LEDS_MSM_TRICOLOR - tristate "LED Support for Qualcomm tricolor LEDs" - depends on LEDS_CLASS && MSM_SMD - help - This option enables support for tricolor LEDs connected to - to Qualcomm reference boards. Red, green and blue color leds - are supported. These leds are turned on/off, blink on/off - by Modem upon receiving command through rpc from this driver. - - If unsure, say N. - - To compile this driver as a module, choose M here: the - module will be called leds-msm-tricolor. - config LEDS_LP3944 tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip" depends on LEDS_CLASS @@ -239,12 +201,6 @@ config LEDS_LP55XX_COMMON This option supports common operations for LP5521 and LP5523/55231 devices. -config LEDS_CPLD - tristate "LED Support for CPLD connected LEDs" - depends on LEDS_CLASS - help - This option enables support for the LEDs connected to CPLD - config LEDS_LP5521 tristate "LED Support for N.S. LP5521 LED driver chip" depends on LEDS_CLASS && I2C @@ -323,17 +279,6 @@ config LEDS_PCA955X LED driver chips accessed via the I2C bus. Supported devices include PCA9550, PCA9551, PCA9552, and PCA9553. -config LEDS_PM8XXX - tristate "LED Support for Qualcomm PMIC8XXX" - depends on MFD_PM8XXX - help - This option enables support for LEDs connected over PMIC8XXX - (Power Management IC) chip on Qualcomm reference boards, - for example SURF and FFAs. - - To compile this driver as a module, choose M here: the module will - be called leds-pmic8xxx. - config LEDS_PCA9633 tristate "LED support for PCA9633 I2C chip" depends on LEDS_CLASS @@ -424,24 +369,6 @@ config LEDS_BD2802 This option enables support for BD2802GU RGB LED driver chips accessed via the I2C bus. -config LEDS_MSM_PMIC - tristate "LED Support for Qualcomm PMIC connected LEDs" - default n - depends on ARCH_MSM - help - This option enables support for LEDs connected over PMIC - (Power Management IC) chip on Qualcomm reference boards, - for example SURF and FFAs. - -config LEDS_PMIC8058 - tristate "LED Support for Qualcomm PMIC8058" - default n - depends on PMIC8058 - help - This option enables support for LEDs connected over PMIC8058 - (Power Management IC) chip on Qualcomm reference boards, - for example SURF and FFAs. - config LEDS_INTEL_SS4200 tristate "LED driver for Intel NAS SS4200 series" depends on LEDS_CLASS @@ -488,14 +415,6 @@ config LEDS_MC13783 This option enable support for on-chip LED drivers found on Freescale Semiconductor MC13783 PMIC. -config LEDS_QCIBL - tristate "LED Support for Quanta LCD backlight" - depends on SENSORS_WPCE775X && ARCH_MSM_SCORPION - default n - help - Say Y here if you want to use the Quanta backlight driver for ST15 - platform. - config LEDS_NS2 tristate "LED support for Network Space v2 GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c674d5889824408266d69f44defbf45cb1202ef5..b5b1f073c96048ff5a470647e41c3401ab6c5de3 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -20,7 +20,6 @@ obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o -obj-$(CONFIG_LEDS_PM8XXX) += leds-pm8xxx.o obj-$(CONFIG_LEDS_QPNP) += leds-qpnp.o obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o @@ -32,12 +31,10 @@ obj-$(CONFIG_LEDS_LP5562) += leds-lp5562.o obj-$(CONFIG_LEDS_LP8788) += leds-lp8788.o obj-$(CONFIG_LEDS_TCA6507) += leds-tca6507.o obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o -obj-$(CONFIG_LEDS_CPLD) += leds-cpld.o obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o obj-$(CONFIG_LEDS_OT200) += leds-ot200.o obj-$(CONFIG_LEDS_FSG) += leds-fsg.o obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o -obj-$(CONFIG_LEDS_MSM_PMIC) += leds-msm-pmic.o obj-$(CONFIG_LEDS_PCA9633) += leds-pca9633.o obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o obj-$(CONFIG_LEDS_DA9052) += leds-da9052.o @@ -57,11 +54,6 @@ obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o -obj-$(CONFIG_LEDS_PMIC8058) += leds-pmic8058.o -obj-$(CONFIG_LEDS_PMIC_MPP) += leds-pmic-mpp.o -obj-$(CONFIG_LEDS_QCIBL) += leds-qci-backlight.o -obj-$(CONFIG_LEDS_MSM_PDM) += leds-msm-pdm.o -obj-$(CONFIG_LEDS_MSM_TRICOLOR) += leds-msm-tricolor.o obj-$(CONFIG_LEDS_MSM_GPIO_FLASH) += leds-msm-gpio-flash.o # LED SPI Drivers diff --git a/drivers/leds/leds-cpld.c b/drivers/leds/leds-cpld.c deleted file mode 100644 index d444d3da4a8e8e340b8655801d7a63dd44e4635c..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-cpld.c +++ /dev/null @@ -1,404 +0,0 @@ -/* include/asm/mach-msm/leds-cpld.c - * - * Copyright (C) 2008 HTC Corporation. - * - * Author: Farmer Tseng - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_LED_CHANGE 0 - -static int _g_cpld_led_addr; - -struct CPLD_LED_data { - spinlock_t data_lock; - struct led_classdev leds[4]; /* blue, green, red */ -}; - -static ssize_t led_blink_solid_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct CPLD_LED_data *CPLD_LED; - int idx = 2; - uint8_t reg_val; - struct led_classdev *led_cdev = dev_get_drvdata(dev); - ssize_t ret = 0; - - if (!strcmp(led_cdev->name, "red")) - idx = 0; - else if (!strcmp(led_cdev->name, "green")) - idx = 1; - else - idx = 2; - - CPLD_LED = container_of(led_cdev, struct CPLD_LED_data, leds[idx]); - - spin_lock(&CPLD_LED->data_lock); - reg_val = readb(_g_cpld_led_addr); - reg_val = reg_val >> (2 * idx + 1); - reg_val &= 0x1; - spin_unlock(&CPLD_LED->data_lock); - - /* no lock needed for this */ - sprintf(buf, "%u\n", reg_val); - ret = strlen(buf) + 1; - - return ret; -} - -static ssize_t led_blink_solid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct CPLD_LED_data *CPLD_LED; - int idx = 2; - uint8_t reg_val; - char *after; - unsigned long state; - ssize_t ret = -EINVAL; - size_t count; - - struct led_classdev *led_cdev = dev_get_drvdata(dev); - - if (!strcmp(led_cdev->name, "red")) - idx = 0; - else if (!strcmp(led_cdev->name, "green")) - idx = 1; - else - idx = 2; - - CPLD_LED = container_of(led_cdev, struct CPLD_LED_data, leds[idx]); - - state = simple_strtoul(buf, &after, 10); - - count = after - buf; - - if (*after && isspace(*after)) - count++; - - if (count == size) { - ret = count; - spin_lock(&CPLD_LED->data_lock); - reg_val = readb(_g_cpld_led_addr); - if (state) - reg_val |= 1 << (2 * idx + 1); - else - reg_val &= ~(1 << (2 * idx + 1)); - - writeb(reg_val, _g_cpld_led_addr); - spin_unlock(&CPLD_LED->data_lock); - } - - return ret; -} - -static DEVICE_ATTR(blink, 0644, led_blink_solid_show, led_blink_solid_store); - -static ssize_t cpldled_blink_all_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - uint8_t reg_val; - struct CPLD_LED_data *CPLD_LED = dev_get_drvdata(dev); - ssize_t ret = 0; - - spin_lock(&CPLD_LED->data_lock); - reg_val = readb(_g_cpld_led_addr); - reg_val &= 0x2A; - if (reg_val == 0x2A) - reg_val = 1; - else - reg_val = 0; - spin_unlock(&CPLD_LED->data_lock); - - /* no lock needed for this */ - sprintf(buf, "%u\n", reg_val); - ret = strlen(buf) + 1; - - return ret; -} - -static ssize_t cpldled_blink_all_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - uint8_t reg_val; - char *after; - unsigned long state; - ssize_t ret = -EINVAL; - size_t count; - struct CPLD_LED_data *CPLD_LED = dev_get_drvdata(dev); - - state = simple_strtoul(buf, &after, 10); - - count = after - buf; - - if (*after && isspace(*after)) - count++; - - if (count == size) { - ret = count; - spin_lock(&CPLD_LED->data_lock); - reg_val = readb(_g_cpld_led_addr); - if (state) - reg_val |= 0x2A; - else - reg_val &= ~0x2A; - - writeb(reg_val, _g_cpld_led_addr); - spin_unlock(&CPLD_LED->data_lock); - } - - return ret; -} - -static struct device_attribute dev_attr_blink_all = { - .attr = { - .name = "blink", - .mode = 0644, - }, - .show = cpldled_blink_all_show, - .store = cpldled_blink_all_store, -}; - -static void led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - struct CPLD_LED_data *CPLD_LED; - int idx = 2; - struct led_classdev *led; - uint8_t reg_val; - - if (!strcmp(led_cdev->name, "jogball-backlight")) { - if (brightness > 7) - reg_val = 1; - else - reg_val = brightness; - writeb(0, _g_cpld_led_addr + 0x8); - writeb(reg_val, _g_cpld_led_addr + 0x8); -#if DEBUG_LED_CHANGE - printk(KERN_INFO "LED change: jogball backlight = %d \n", - reg_val); -#endif - return; - } else if (!strcmp(led_cdev->name, "red")) { - idx = 0; - } else if (!strcmp(led_cdev->name, "green")) { - idx = 1; - } else { - idx = 2; - } - - CPLD_LED = container_of(led_cdev, struct CPLD_LED_data, leds[idx]); - spin_lock(&CPLD_LED->data_lock); - reg_val = readb(_g_cpld_led_addr); - led = &CPLD_LED->leds[idx]; - - if (led->brightness > LED_OFF) - reg_val |= 1 << (2 * idx); - else - reg_val &= ~(1 << (2 * idx)); - - writeb(reg_val, _g_cpld_led_addr); -#if DEBUG_LED_CHANGE - printk(KERN_INFO "LED change: %s = %d \n", led_cdev->name, led->brightness); -#endif - spin_unlock(&CPLD_LED->data_lock); -} - -static ssize_t cpldled_grpfreq_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", 0); -} - -static ssize_t cpldled_grpfreq_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return 0; -} - -static DEVICE_ATTR(grpfreq, 0644, cpldled_grpfreq_show, cpldled_grpfreq_store); - -static ssize_t cpldled_grppwm_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", 0); -} - -static ssize_t cpldled_grppwm_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return 0; -} - -static DEVICE_ATTR(grppwm, 0644, cpldled_grppwm_show, cpldled_grppwm_store); - -static int CPLD_LED_probe(struct platform_device *pdev) -{ - int ret = 0; - int i, j; - struct resource *res; - struct CPLD_LED_data *CPLD_LED; - - CPLD_LED = kzalloc(sizeof(struct CPLD_LED_data), GFP_KERNEL); - if (CPLD_LED == NULL) { - printk(KERN_ERR "CPLD_LED_probe: no memory for device\n"); - ret = -ENOMEM; - goto err_alloc_failed; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - ret = -ENOMEM; - goto err_alloc_failed; - } - - _g_cpld_led_addr = res->start; - if (!_g_cpld_led_addr) { - ret = -ENOMEM; - goto err_alloc_failed; - } - - memset(CPLD_LED, 0, sizeof(struct CPLD_LED_data)); - writeb(0x00, _g_cpld_led_addr); - - CPLD_LED->leds[0].name = "red"; - CPLD_LED->leds[0].brightness_set = led_brightness_set; - - CPLD_LED->leds[1].name = "green"; - CPLD_LED->leds[1].brightness_set = led_brightness_set; - - CPLD_LED->leds[2].name = "blue"; - CPLD_LED->leds[2].brightness_set = led_brightness_set; - - CPLD_LED->leds[3].name = "jogball-backlight"; - CPLD_LED->leds[3].brightness_set = led_brightness_set; - - spin_lock_init(&CPLD_LED->data_lock); - - for (i = 0; i < 4; i++) { /* red, green, blue jogball */ - ret = led_classdev_register(&pdev->dev, &CPLD_LED->leds[i]); - if (ret) { - printk(KERN_ERR - "CPLD_LED: led_classdev_register failed\n"); - goto err_led_classdev_register_failed; - } - } - - for (i = 0; i < 3; i++) { - ret = - device_create_file(CPLD_LED->leds[i].dev, &dev_attr_blink); - if (ret) { - printk(KERN_ERR - "CPLD_LED: device_create_file failed\n"); - goto err_out_attr_blink; - } - } - - dev_set_drvdata(&pdev->dev, CPLD_LED); - ret = device_create_file(&pdev->dev, &dev_attr_blink_all); - if (ret) { - printk(KERN_ERR - "CPLD_LED: create dev_attr_blink_all failed\n"); - goto err_out_attr_blink; - } - ret = device_create_file(&pdev->dev, &dev_attr_grppwm); - if (ret) { - printk(KERN_ERR - "CPLD_LED: create dev_attr_grppwm failed\n"); - goto err_out_attr_grppwm; - } - ret = device_create_file(&pdev->dev, &dev_attr_grpfreq); - if (ret) { - printk(KERN_ERR - "CPLD_LED: create dev_attr_grpfreq failed\n"); - goto err_out_attr_grpfreq; - } - - return 0; - -err_out_attr_grpfreq: - device_remove_file(&pdev->dev, &dev_attr_grppwm); -err_out_attr_grppwm: - device_remove_file(&pdev->dev, &dev_attr_blink_all); -err_out_attr_blink: - for (j = 0; j < i; j++) - device_remove_file(CPLD_LED->leds[j].dev, &dev_attr_blink); - i = 3; - -err_led_classdev_register_failed: - for (j = 0; j < i; j++) - led_classdev_unregister(&CPLD_LED->leds[j]); - -err_alloc_failed: - kfree(CPLD_LED); - - return ret; -} - -static int CPLD_LED_remove(struct platform_device *pdev) -{ - struct CPLD_LED_data *CPLD_LED; - int i; - - CPLD_LED = platform_get_drvdata(pdev); - - for (i = 0; i < 3; i++) { - device_remove_file(CPLD_LED->leds[i].dev, &dev_attr_blink); - led_classdev_unregister(&CPLD_LED->leds[i]); - } - - device_remove_file(&pdev->dev, &dev_attr_blink_all); - device_remove_file(&pdev->dev, &dev_attr_grppwm); - device_remove_file(&pdev->dev, &dev_attr_grpfreq); - - kfree(CPLD_LED); - return 0; -} - -static struct platform_driver CPLD_LED_driver = { - .probe = CPLD_LED_probe, - .remove = CPLD_LED_remove, - .driver = { - .name = "leds-cpld", - .owner = THIS_MODULE, - }, -}; - -static int __init CPLD_LED_init(void) -{ - return platform_driver_register(&CPLD_LED_driver); -} - -static void __exit CPLD_LED_exit(void) -{ - platform_driver_unregister(&CPLD_LED_driver); -} - -MODULE_AUTHOR("Farmer Tseng"); -MODULE_DESCRIPTION("CPLD_LED driver"); -MODULE_LICENSE("GPL"); - -module_init(CPLD_LED_init); -module_exit(CPLD_LED_exit); diff --git a/drivers/leds/leds-msm-pdm.c b/drivers/leds/leds-msm-pdm.c deleted file mode 100644 index ffd1fe35e4782e0a751bcecf306f1a132b796a9a..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-msm-pdm.c +++ /dev/null @@ -1,234 +0,0 @@ -/* Copyright (c) 2011, 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. - */ -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_HAS_EARLYSUSPEND -#include - -/* Early-suspend level */ -#define LED_SUSPEND_LEVEL 1 -#endif - -#define PDM_DUTY_MAXVAL BIT(16) -#define PDM_DUTY_REFVAL BIT(15) - -struct pdm_led_data { - struct led_classdev cdev; - void __iomem *perph_base; - int pdm_offset; -#ifdef CONFIG_HAS_EARLYSUSPEND - struct early_suspend early_suspend; -#endif -}; - -static void msm_led_brightness_set_percent(struct pdm_led_data *led, - int duty_per) -{ - u16 duty_val; - - duty_val = PDM_DUTY_REFVAL - ((PDM_DUTY_MAXVAL * duty_per) / 100); - - if (!duty_per) - duty_val--; - - writel_relaxed(duty_val, led->perph_base + led->pdm_offset); -} - -static void msm_led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct pdm_led_data *led = - container_of(led_cdev, struct pdm_led_data, cdev); - - msm_led_brightness_set_percent(led, (value * 100) / LED_FULL); -} - -#ifdef CONFIG_PM_SLEEP -static int msm_led_pdm_suspend(struct device *dev) -{ - struct pdm_led_data *led = dev_get_drvdata(dev); - - msm_led_brightness_set_percent(led, 0); - - return 0; -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void msm_led_pdm_early_suspend(struct early_suspend *h) -{ - struct pdm_led_data *led = container_of(h, - struct pdm_led_data, early_suspend); - - msm_led_pdm_suspend(led->cdev.dev->parent); -} - -#endif - -static const struct dev_pm_ops msm_led_pdm_pm_ops = { -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = msm_led_pdm_suspend, -#endif -}; -#endif - -static int msm_pdm_led_probe(struct platform_device *pdev) -{ - const struct led_info *pdata = pdev->dev.platform_data; - struct pdm_led_data *led; - struct resource *res, *ioregion; - u32 tcxo_pdm_ctl; - int rc; - - if (!pdata) { - pr_err("platform data is invalid\n"); - return -EINVAL; - } - - if (pdev->id > 2) { - pr_err("pdm id is invalid\n"); - return -EINVAL; - } - - led = kzalloc(sizeof(struct pdm_led_data), GFP_KERNEL); - if (!led) - return -ENOMEM; - - /* Enable runtime PM ops, start in ACTIVE mode */ - rc = pm_runtime_set_active(&pdev->dev); - if (rc < 0) - dev_dbg(&pdev->dev, "unable to set runtime pm state\n"); - pm_runtime_enable(&pdev->dev); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - pr_err("get resource failed\n"); - rc = -EINVAL; - goto err_get_res; - } - - ioregion = request_mem_region(res->start, resource_size(res), - pdev->name); - if (!ioregion) { - pr_err("request for mem region failed\n"); - rc = -ENOMEM; - goto err_get_res; - } - - led->perph_base = ioremap(res->start, resource_size(res)); - if (!led->perph_base) { - pr_err("ioremap failed\n"); - rc = -ENOMEM; - goto err_ioremap; - } - - /* Pulse Density Modulation(PDM) ids start with 0 and - * every PDM register takes 4 bytes - */ - led->pdm_offset = ((pdev->id) + 1) * 4; - - /* program tcxo_pdm_ctl register to enable pdm*/ - tcxo_pdm_ctl = readl_relaxed(led->perph_base); - tcxo_pdm_ctl |= (1 << pdev->id); - writel_relaxed(tcxo_pdm_ctl, led->perph_base); - - /* Start with LED in off state */ - msm_led_brightness_set_percent(led, 0); - - led->cdev.brightness_set = msm_led_brightness_set; - led->cdev.name = pdata->name ? : "leds-msm-pdm"; - - rc = led_classdev_register(&pdev->dev, &led->cdev); - if (rc) { - pr_err("led class registration failed\n"); - goto err_led_reg; - } - -#ifdef CONFIG_HAS_EARLYSUSPEND - led->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + - LED_SUSPEND_LEVEL; - led->early_suspend.suspend = msm_led_pdm_early_suspend; - register_early_suspend(&led->early_suspend); -#endif - - platform_set_drvdata(pdev, led); - return 0; - -err_led_reg: - iounmap(led->perph_base); -err_ioremap: - release_mem_region(res->start, resource_size(res)); -err_get_res: - pm_runtime_set_suspended(&pdev->dev); - pm_runtime_disable(&pdev->dev); - kfree(led); - return rc; -} - -static int msm_pdm_led_remove(struct platform_device *pdev) -{ - struct pdm_led_data *led = platform_get_drvdata(pdev); - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&led->early_suspend); -#endif - pm_runtime_set_suspended(&pdev->dev); - pm_runtime_disable(&pdev->dev); - - led_classdev_unregister(&led->cdev); - msm_led_brightness_set_percent(led, 0); - iounmap(led->perph_base); - release_mem_region(res->start, resource_size(res)); - kfree(led); - - return 0; -} - -static struct platform_driver msm_pdm_led_driver = { - .probe = msm_pdm_led_probe, - .remove = msm_pdm_led_remove, - .driver = { - .name = "leds-msm-pdm", - .owner = THIS_MODULE, -#ifdef CONFIG_PM_SLEEP - .pm = &msm_led_pdm_pm_ops, -#endif - }, -}; - -static int __init msm_pdm_led_init(void) -{ - return platform_driver_register(&msm_pdm_led_driver); -} -module_init(msm_pdm_led_init); - -static void __exit msm_pdm_led_exit(void) -{ - platform_driver_unregister(&msm_pdm_led_driver); -} -module_exit(msm_pdm_led_exit); - -MODULE_DESCRIPTION("MSM PDM LEDs driver"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:leds-msm-pdm"); diff --git a/drivers/leds/leds-msm-pmic.c b/drivers/leds/leds-msm-pmic.c deleted file mode 100644 index cc90349597e28963cd314f9a8f48c76a8f5fea02..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-msm-pmic.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * leds-msm-pmic.c - MSM PMIC LEDs driver. - * - * Copyright (c) 2009, 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 -#include -#include -#include - -#include - -#define MAX_KEYPAD_BL_LEVEL 16 - -static void msm_keypad_bl_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - int ret; - - ret = pmic_set_led_intensity(LED_KEYPAD, value / MAX_KEYPAD_BL_LEVEL); - if (ret) - dev_err(led_cdev->dev, "can't set keypad backlight\n"); -} - -static struct led_classdev msm_kp_bl_led = { - .name = "keyboard-backlight", - .brightness_set = msm_keypad_bl_led_set, - .brightness = LED_OFF, -}; - -static int msm_pmic_led_probe(struct platform_device *pdev) -{ - int rc; - - rc = led_classdev_register(&pdev->dev, &msm_kp_bl_led); - if (rc) { - dev_err(&pdev->dev, "unable to register led class driver\n"); - return rc; - } - msm_keypad_bl_led_set(&msm_kp_bl_led, LED_OFF); - return rc; -} - -static int msm_pmic_led_remove(struct platform_device *pdev) -{ - led_classdev_unregister(&msm_kp_bl_led); - - return 0; -} - -#ifdef CONFIG_PM -static int msm_pmic_led_suspend(struct platform_device *dev, - pm_message_t state) -{ - led_classdev_suspend(&msm_kp_bl_led); - - return 0; -} - -static int msm_pmic_led_resume(struct platform_device *dev) -{ - led_classdev_resume(&msm_kp_bl_led); - - return 0; -} -#else -#define msm_pmic_led_suspend NULL -#define msm_pmic_led_resume NULL -#endif - -static struct platform_driver msm_pmic_led_driver = { - .probe = msm_pmic_led_probe, - .remove = msm_pmic_led_remove, - .suspend = msm_pmic_led_suspend, - .resume = msm_pmic_led_resume, - .driver = { - .name = "pmic-leds", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_pmic_led_init(void) -{ - return platform_driver_register(&msm_pmic_led_driver); -} -module_init(msm_pmic_led_init); - -static void __exit msm_pmic_led_exit(void) -{ - platform_driver_unregister(&msm_pmic_led_driver); -} -module_exit(msm_pmic_led_exit); - -MODULE_DESCRIPTION("MSM PMIC LEDs driver"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:pmic-leds"); diff --git a/drivers/leds/leds-msm-tricolor.c b/drivers/leds/leds-msm-tricolor.c deleted file mode 100644 index f5b2db1c7d33eba98449cd3a1c5f5acd57c56e61..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-msm-tricolor.c +++ /dev/null @@ -1,410 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include - -#include -#include - -#define LED_RPC_PROG 0x30000091 -#define LED_RPC_VER 0x00030001 - -#define LED_SUBSCRIBE_PROC 0x03 -#define LED_SUBS_RCV_EVNT 0x01 -#define LED_SUBS_REGISTER 0x00 -#define LED_EVNT_CLASS_ALL 0x00 -#define LINUX_HOST 0x04 -#define LED_CMD_PROC 0x02 -#define TRICOLOR_LED_ID 0x0A - -enum tricolor_led_status { - ALL_OFF, - ALL_ON, - BLUE_ON, - BLUE_OFF, - RED_ON, - RED_OFF, - GREEN_ON, - GREEN_OFF, - BLUE_BLINK, - RED_BLINK, - GREEN_BLINK, - BLUE_BLINK_OFF, - RED_BLINK_OFF, - GREEN_BLINK_OFF, - LED_MAX, -}; - -struct led_cmd_data_type { - u32 cmd_data_type_ptr; /* cmd_data_type ptr */ - u32 ver; /* version */ - u32 id; /* command id */ - u32 handle; /* handle returned from subscribe proc */ - u32 disc_id1; /* discriminator id */ - u32 input_ptr; /* input ptr length */ - u32 input_val; /* command specific data */ - u32 input_len; /* length of command input */ - u32 disc_id2; /* discriminator id */ - u32 output_len; /* length of output data */ - u32 delayed; /* execution context for modem */ -}; - -struct led_subscribe_req { - u32 subs_ptr; /* subscribe ptr */ - u32 ver; /* version */ - u32 srvc; /* command or event */ - u32 req; /* subscribe or unsubscribe */ - u32 host_os; /* host operating system */ - u32 disc_id; /* discriminator id */ - u32 event; /* event */ - u32 cb_id; /* callback id */ - u32 handle_ptr; /* handle ptr */ - u32 handle_data; /* handle data */ -}; - -struct tricolor_led_data { - struct led_classdev cdev; - struct msm_rpc_client *rpc_client; - bool blink_status; - struct mutex lock; - u8 color; -}; - -static struct led_subscribe_req *led_subs_req; - -static int led_send_cmd_arg(struct msm_rpc_client *client, - void *buffer, void *data) -{ - struct led_cmd_data_type *led_cmd = buffer; - enum tricolor_led_status status = *(enum tricolor_led_status *) data; - - led_cmd->cmd_data_type_ptr = cpu_to_be32(0x01); - led_cmd->ver = cpu_to_be32(0x03); - led_cmd->id = cpu_to_be32(TRICOLOR_LED_ID); - led_cmd->handle = cpu_to_be32(led_subs_req->handle_data); - led_cmd->disc_id1 = cpu_to_be32(TRICOLOR_LED_ID); - led_cmd->input_ptr = cpu_to_be32(0x01); - led_cmd->input_val = cpu_to_be32(status); - led_cmd->input_len = cpu_to_be32(0x01); - led_cmd->disc_id2 = cpu_to_be32(TRICOLOR_LED_ID); - led_cmd->output_len = cpu_to_be32(0x00); - led_cmd->delayed = cpu_to_be32(0x00); - - return sizeof(*led_cmd); -} - -static int led_rpc_res(struct msm_rpc_client *client, - void *buffer, void *data) -{ - uint32_t result; - - result = be32_to_cpu(*((uint32_t *)buffer)); - pr_debug("%s: request completed: 0x%x\n", __func__, result); - - return 0; -} - -static void led_rpc_set_status(struct msm_rpc_client *client, - enum tricolor_led_status status) -{ - int rc; - - rc = msm_rpc_client_req(client, LED_CMD_PROC, - led_send_cmd_arg, &status, led_rpc_res, NULL, -1); - if (rc) - pr_err("%s: RPC client request for led failed", __func__); - -} - -static ssize_t led_blink_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct tricolor_led_data *led = dev_get_drvdata(dev); - - return snprintf(buf, 2, "%d\n", led->blink_status); -} - -static ssize_t led_blink_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - struct tricolor_led_data *led = dev_get_drvdata(dev); - enum tricolor_led_status status; - unsigned long value; - int rc; - - if (size > 2) - return -EINVAL; - - rc = kstrtoul(buf, 10, &value); - if (rc) - return rc; - - - if (value < LED_OFF || value > led->cdev.max_brightness) { - dev_err(dev, "invalid brightness\n"); - return -EINVAL; - } - - switch (led->color) { - case LED_COLOR_RED: - status = value ? RED_BLINK : RED_BLINK_OFF; - break; - case LED_COLOR_GREEN: - status = value ? GREEN_BLINK : GREEN_BLINK_OFF; - break; - case LED_COLOR_BLUE: - status = value ? BLUE_BLINK : BLUE_BLINK_OFF; - break; - default: - dev_err(dev, "unknown led device\n"); - return -EINVAL; - } - - mutex_lock(&led->lock); - led->blink_status = !!value; - led->cdev.brightness = 0; - - /* program the led blink */ - led_rpc_set_status(led->rpc_client, status); - mutex_unlock(&led->lock); - - return size; -} - -static DEVICE_ATTR(blink, 0644, led_blink_show, led_blink_store); - -static void tricolor_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct tricolor_led_data *led; - enum tricolor_led_status status; - - led = container_of(led_cdev, struct tricolor_led_data, cdev); - - if (value < LED_OFF || value > led->cdev.max_brightness) { - dev_err(led->cdev.dev, "invalid brightness\n"); - return; - } - - switch (led->color) { - case LED_COLOR_RED: - status = value ? RED_ON : RED_OFF; - break; - case LED_COLOR_GREEN: - status = value ? GREEN_ON : GREEN_OFF; - break; - case LED_COLOR_BLUE: - status = value ? BLUE_ON : BLUE_OFF; - break; - default: - dev_err(led->cdev.dev, "unknown led device\n"); - return; - } - - mutex_lock(&led->lock); - led->blink_status = 0; - led->cdev.brightness = value; - - /* program the led brightness */ - led_rpc_set_status(led->rpc_client, status); - mutex_unlock(&led->lock); -} - -static enum led_brightness tricolor_led_get(struct led_classdev *led_cdev) -{ - struct tricolor_led_data *led; - - led = container_of(led_cdev, struct tricolor_led_data, cdev); - - return led->cdev.brightness; -} - -static int led_rpc_register_subs_arg(struct msm_rpc_client *client, - void *buffer, void *data) -{ - led_subs_req = buffer; - - led_subs_req->subs_ptr = cpu_to_be32(0x1); - led_subs_req->ver = cpu_to_be32(0x1); - led_subs_req->srvc = cpu_to_be32(LED_SUBS_RCV_EVNT); - led_subs_req->req = cpu_to_be32(LED_SUBS_REGISTER); - led_subs_req->host_os = cpu_to_be32(LINUX_HOST); - led_subs_req->disc_id = cpu_to_be32(LED_SUBS_RCV_EVNT); - led_subs_req->event = cpu_to_be32(LED_EVNT_CLASS_ALL); - led_subs_req->cb_id = cpu_to_be32(0x1); - led_subs_req->handle_ptr = cpu_to_be32(0x1); - led_subs_req->handle_data = cpu_to_be32(0x0); - - return sizeof(*led_subs_req); -} - -static int led_cb_func(struct msm_rpc_client *client, void *buffer, int in_size) -{ - struct rpc_request_hdr *hdr = buffer; - int rc; - - hdr->type = be32_to_cpu(hdr->type); - hdr->xid = be32_to_cpu(hdr->xid); - hdr->rpc_vers = be32_to_cpu(hdr->rpc_vers); - hdr->prog = be32_to_cpu(hdr->prog); - hdr->vers = be32_to_cpu(hdr->vers); - hdr->procedure = be32_to_cpu(hdr->procedure); - - msm_rpc_start_accepted_reply(client, hdr->xid, - RPC_ACCEPTSTAT_SUCCESS); - rc = msm_rpc_send_accepted_reply(client, 0); - if (rc) - pr_err("%s: sending reply failed: %d\n", __func__, rc); - - return rc; -} - -static int tricolor_led_probe(struct platform_device *pdev) -{ - const struct led_platform_data *pdata = pdev->dev.platform_data; - struct msm_rpc_client *rpc_client; - struct led_info *curr_led; - struct tricolor_led_data *led, *tmp_led; - int rc, i, j; - - if (!pdata) { - dev_err(&pdev->dev, "platform data not supplied\n"); - return -EINVAL; - } - - /* initialize rpc client */ - rpc_client = msm_rpc_register_client("led", LED_RPC_PROG, - LED_RPC_VER, 0, led_cb_func); - rc = IS_ERR(rpc_client); - if (rc) { - dev_err(&pdev->dev, "failed to initialize rpc_client\n"); - return -EINVAL; - } - - /* subscribe */ - rc = msm_rpc_client_req(rpc_client, LED_SUBSCRIBE_PROC, - led_rpc_register_subs_arg, NULL, - led_rpc_res, NULL, -1); - if (rc) { - pr_err("%s: RPC client request failed for subscribe services\n", - __func__); - goto fail_mem_alloc; - } - - led = devm_kzalloc(&pdev->dev, pdata->num_leds * sizeof(*led), - GFP_KERNEL); - if (!led) { - dev_err(&pdev->dev, "failed to alloc memory\n"); - rc = -ENOMEM; - goto fail_mem_alloc; - } - - for (i = 0; i < pdata->num_leds; i++) { - curr_led = &pdata->leds[i]; - tmp_led = &led[i]; - - tmp_led->cdev.name = curr_led->name; - tmp_led->cdev.default_trigger = curr_led->default_trigger; - tmp_led->cdev.brightness_set = tricolor_led_set; - tmp_led->cdev.brightness_get = tricolor_led_get; - tmp_led->cdev.brightness = LED_OFF; - tmp_led->cdev.max_brightness = LED_FULL; - tmp_led->color = curr_led->flags; - tmp_led->rpc_client = rpc_client; - tmp_led->blink_status = false; - - mutex_init(&tmp_led->lock); - - rc = led_classdev_register(&pdev->dev, &tmp_led->cdev); - if (rc) { - dev_err(&pdev->dev, "failed to register led %s(%d)\n", - tmp_led->cdev.name, rc); - goto fail_led_reg; - } - - /* Add blink attributes */ - rc = device_create_file(tmp_led->cdev.dev, &dev_attr_blink); - if (rc) { - dev_err(&pdev->dev, "failed to create blink attr\n"); - goto fail_blink_attr; - } - dev_set_drvdata(tmp_led->cdev.dev, tmp_led); - } - - platform_set_drvdata(pdev, led); - - return 0; - -fail_blink_attr: - j = i; - while (j) - device_remove_file(led[--j].cdev.dev, &dev_attr_blink); - i++; -fail_led_reg: - while (i) { - led_classdev_unregister(&led[--i].cdev); - mutex_destroy(&led[i].lock); - } -fail_mem_alloc: - msm_rpc_unregister_client(rpc_client); - return rc; -} - -static int tricolor_led_remove(struct platform_device *pdev) -{ - const struct led_platform_data *pdata = pdev->dev.platform_data; - struct tricolor_led_data *led = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < pdata->num_leds; i++) { - led_classdev_unregister(&led[i].cdev); - device_remove_file(led[i].cdev.dev, &dev_attr_blink); - mutex_destroy(&led[i].lock); - } - - msm_rpc_unregister_client(led->rpc_client); - - return 0; -} - -static struct platform_driver tricolor_led_driver = { - .probe = tricolor_led_probe, - .remove = tricolor_led_remove, - .driver = { - .name = "msm-tricolor-leds", - .owner = THIS_MODULE, - }, -}; - -static int __init tricolor_led_init(void) -{ - return platform_driver_register(&tricolor_led_driver); -} -late_initcall(tricolor_led_init); - -static void __exit tricolor_led_exit(void) -{ - platform_driver_unregister(&tricolor_led_driver); -} -module_exit(tricolor_led_exit); - -MODULE_DESCRIPTION("MSM Tri-color LEDs driver"); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:tricolor-led"); diff --git a/drivers/leds/leds-pm8xxx.c b/drivers/leds/leds-pm8xxx.c deleted file mode 100644 index aa10bd3a113f757c1b214080b3d319530f689a5f..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-pm8xxx.c +++ /dev/null @@ -1,1054 +0,0 @@ -/* Copyright (c) 2010-2013, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define SSBI_REG_ADDR_DRV_KEYPAD 0x48 -#define PM8XXX_DRV_KEYPAD_BL_MASK 0xf0 -#define PM8XXX_DRV_KEYPAD_BL_SHIFT 0x04 - -#define SSBI_REG_ADDR_FLASH_DRV0 0x49 -#define PM8XXX_DRV_FLASH_MASK 0xf0 -#define PM8XXX_DRV_FLASH_SHIFT 0x04 - -#define SSBI_REG_ADDR_FLASH_DRV1 0xFB - -#define SSBI_REG_ADDR_LED_CTRL_BASE 0x131 -#define SSBI_REG_ADDR_LED_CTRL(n) (SSBI_REG_ADDR_LED_CTRL_BASE + (n)) -#define PM8XXX_DRV_LED_CTRL_MASK 0xf8 -#define PM8XXX_DRV_LED_CTRL_SHIFT 0x03 - -#define SSBI_REG_ADDR_WLED_CTRL_BASE 0x25A -#define SSBI_REG_ADDR_WLED_CTRL(n) (SSBI_REG_ADDR_WLED_CTRL_BASE + (n) - 1) - -/* wled control registers */ -#define WLED_MOD_CTRL_REG SSBI_REG_ADDR_WLED_CTRL(1) -#define WLED_MAX_CURR_CFG_REG(n) SSBI_REG_ADDR_WLED_CTRL(n + 2) -#define WLED_BRIGHTNESS_CNTL_REG1(n) SSBI_REG_ADDR_WLED_CTRL((2 * n) + 5) -#define WLED_BRIGHTNESS_CNTL_REG2(n) SSBI_REG_ADDR_WLED_CTRL((2 * n) + 6) -#define WLED_SYNC_REG SSBI_REG_ADDR_WLED_CTRL(11) -#define WLED_OVP_CFG_REG SSBI_REG_ADDR_WLED_CTRL(13) -#define WLED_BOOST_CFG_REG SSBI_REG_ADDR_WLED_CTRL(14) -#define WLED_HIGH_POLE_CAP_REG SSBI_REG_ADDR_WLED_CTRL(16) - -#define WLED_STRING_ONE 0 /* Rightmost string */ -#define WLED_STRING_TWO 1 /* Middle string */ -#define WLED_STRING_THREE 2 /* Leftmost string */ -#define WLED_STRINGS 0x03 -#define WLED_OVP_VAL_MASK 0x30 -#define WLED_OVP_VAL_BIT_SHFT 0x04 -#define WLED_BOOST_LIMIT_MASK 0xE0 -#define WLED_BOOST_LIMIT_BIT_SHFT 0x05 -#define WLED_BOOST_OFF 0x00 -#define WLED_EN_MASK 0x01 -#define WLED_CP_SELECT_MAX 0x03 -#define WLED_CP_SELECT_MASK 0x03 -#define WLED_DIG_MOD_GEN_MASK 0x70 -#define WLED_CS_OUT_MASK 0x0E -#define WLED_CTL_DLY_STEP 200 -#define WLED_CTL_DLY_MAX 1400 -#define WLED_CTL_DLY_MASK 0xE0 -#define WLED_CTL_DLY_BIT_SHFT 0x05 -#define WLED_MAX_CURR 25 -#define WLED_MAX_CURR_MASK 0x1F -#define WLED_BRIGHTNESS_MSB_MASK 0x0F -#define WLED_OP_FDBCK_MASK 0x1C -#define WLED_OP_FDBCK_BIT_SHFT 0x02 - -#define WLED_MAX_LEVEL 255 -#define WLED_8_BIT_MASK 0xFF -#define WLED_8_BIT_SHFT 0x08 -#define WLED_MAX_DUTY_CYCLE 0xFFF - -#define WLED_SYNC_VAL 0x07 -#define WLED_SYNC_RESET_VAL 0x00 -#define WLED_SYNC_MASK 0xF8 - -#define ONE_WLED_STRING 1 -#define TWO_WLED_STRINGS 2 -#define THREE_WLED_STRINGS 3 - -#define WLED_CABC_SHIFT 3 - -#define SSBI_REG_ADDR_RGB_CNTL1 0x12D -#define SSBI_REG_ADDR_RGB_CNTL2 0x12E - -#define PM8XXX_DRV_RGB_RED_LED BIT(2) -#define PM8XXX_DRV_RGB_GREEN_LED BIT(1) -#define PM8XXX_DRV_RGB_BLUE_LED BIT(0) - -#define MAX_FLASH_LED_CURRENT 300 -#define MAX_LC_LED_CURRENT 40 -#define MAX_KP_BL_LED_CURRENT 300 - -#define PM8XXX_ID_LED_CURRENT_FACTOR 2 /* Iout = x * 2mA */ -#define PM8XXX_ID_FLASH_CURRENT_FACTOR 20 /* Iout = x * 20mA */ - -#define PM8XXX_FLASH_MODE_DBUS1 1 -#define PM8XXX_FLASH_MODE_DBUS2 2 -#define PM8XXX_FLASH_MODE_PWM 3 - -#define MAX_LC_LED_BRIGHTNESS 20 -#define MAX_FLASH_BRIGHTNESS 15 -#define MAX_KB_LED_BRIGHTNESS 15 - -#define PM8XXX_LED_OFFSET(id) ((id) - PM8XXX_ID_LED_0) - -#define PM8XXX_LED_PWM_FLAGS (PM_PWM_LUT_LOOP | PM_PWM_LUT_RAMP_UP) - -#define LED_MAP(_version, _kb, _led0, _led1, _led2, _flash_led0, _flash_led1, \ - _wled, _rgb_led_red, _rgb_led_green, _rgb_led_blue)\ - {\ - .version = _version,\ - .supported = _kb << PM8XXX_ID_LED_KB_LIGHT | \ - _led0 << PM8XXX_ID_LED_0 | _led1 << PM8XXX_ID_LED_1 | \ - _led2 << PM8XXX_ID_LED_2 | \ - _flash_led0 << PM8XXX_ID_FLASH_LED_0 | \ - _flash_led1 << PM8XXX_ID_FLASH_LED_1 | \ - _wled << PM8XXX_ID_WLED | \ - _rgb_led_red << PM8XXX_ID_RGB_LED_RED | \ - _rgb_led_green << PM8XXX_ID_RGB_LED_GREEN | \ - _rgb_led_blue << PM8XXX_ID_RGB_LED_BLUE, \ - } - -#define PM8XXX_PWM_CURRENT_4MA 4 -#define PM8XXX_PWM_CURRENT_8MA 8 -#define PM8XXX_PWM_CURRENT_12MA 12 - - -/** - * supported_leds - leds supported for each PMIC version - * @version - version of PMIC - * @supported - which leds are supported on version - */ - -struct supported_leds { - enum pm8xxx_version version; - u32 supported; -}; - -static const struct supported_leds led_map[] = { - LED_MAP(PM8XXX_VERSION_8058, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0), - LED_MAP(PM8XXX_VERSION_8921, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0), - LED_MAP(PM8XXX_VERSION_8018, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), - LED_MAP(PM8XXX_VERSION_8922, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1), - LED_MAP(PM8XXX_VERSION_8038, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1), -}; - -/** - * struct pm8xxx_led_data - internal led data structure - * @led_classdev - led class device - * @id - led index - * @work - workqueue for led - * @lock - to protect the transactions - * @reg - cached value of led register - * @pwm_dev - pointer to PWM device if LED is driven using PWM - * @pwm_channel - PWM channel ID - * @pwm_period_us - PWM period in micro seconds - * @pwm_duty_cycles - struct that describes PWM duty cycles info - */ -struct pm8xxx_led_data { - struct led_classdev cdev; - int id; - u8 reg; - u8 wled_mod_ctrl_val; - struct device *dev; - struct work_struct work; - struct mutex lock; - struct pwm_device *pwm_dev; - int pwm_channel; - boot is_pwm_enabled; - u32 pwm_period_us; - struct pm8xxx_pwm_duty_cycles *pwm_duty_cycles; - struct wled_config_data *wled_cfg; - int max_current; -}; - -static void led_kp_set(struct pm8xxx_led_data *led, enum led_brightness value) -{ - int rc; - u8 level; - - level = (value << PM8XXX_DRV_KEYPAD_BL_SHIFT) & - PM8XXX_DRV_KEYPAD_BL_MASK; - - led->reg &= ~PM8XXX_DRV_KEYPAD_BL_MASK; - led->reg |= level; - - rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_DRV_KEYPAD, - led->reg); - if (rc < 0) - dev_err(led->cdev.dev, - "can't set keypad backlight level rc=%d\n", rc); -} - -static void led_lc_set(struct pm8xxx_led_data *led, enum led_brightness value) -{ - int rc, offset; - u8 level; - - level = (value << PM8XXX_DRV_LED_CTRL_SHIFT) & - PM8XXX_DRV_LED_CTRL_MASK; - - offset = PM8XXX_LED_OFFSET(led->id); - - led->reg &= ~PM8XXX_DRV_LED_CTRL_MASK; - led->reg |= level; - - rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_LED_CTRL(offset), - led->reg); - if (rc) - dev_err(led->cdev.dev, "can't set (%d) led value rc=%d\n", - led->id, rc); -} - -static void -led_flash_set(struct pm8xxx_led_data *led, enum led_brightness value) -{ - int rc; - u8 level; - u16 reg_addr; - - level = (value << PM8XXX_DRV_FLASH_SHIFT) & - PM8XXX_DRV_FLASH_MASK; - - led->reg &= ~PM8XXX_DRV_FLASH_MASK; - led->reg |= level; - - if (led->id == PM8XXX_ID_FLASH_LED_0) - reg_addr = SSBI_REG_ADDR_FLASH_DRV0; - else - reg_addr = SSBI_REG_ADDR_FLASH_DRV1; - - rc = pm8xxx_writeb(led->dev->parent, reg_addr, led->reg); - if (rc < 0) - dev_err(led->cdev.dev, "can't set flash led%d level rc=%d\n", - led->id, rc); -} - -static int -led_wled_set(struct pm8xxx_led_data *led, enum led_brightness value) -{ - int rc, duty; - u8 val, i; - - if (value > WLED_MAX_LEVEL) - value = WLED_MAX_LEVEL; - - if (value == 0) { - rc = pm8xxx_writeb(led->dev->parent, WLED_MOD_CTRL_REG, - WLED_BOOST_OFF); - if (rc) { - dev_err(led->dev->parent, "can't write wled ctrl config" - " register rc=%d\n", rc); - return rc; - } - } else { - rc = pm8xxx_writeb(led->dev->parent, WLED_MOD_CTRL_REG, - led->wled_mod_ctrl_val); - if (rc) { - dev_err(led->dev->parent, "can't write wled ctrl config" - " register rc=%d\n", rc); - return rc; - } - } - - duty = (WLED_MAX_DUTY_CYCLE * value) / WLED_MAX_LEVEL; - - /* program brightness control registers */ - for (i = 0; i < WLED_STRINGS; i++) { - if (led->wled_cfg->strings && (1 << i)) { - rc = pm8xxx_readb(led->dev->parent, - WLED_BRIGHTNESS_CNTL_REG1(i), &val); - if (rc) { - dev_err(led->dev->parent, - "can't read wled brightnes ctrl" - " register1 rc=%d\n", rc); - return rc; - } - - val = (val & ~WLED_MAX_CURR_MASK) | - (duty >> WLED_8_BIT_SHFT); - - rc = pm8xxx_writeb(led->dev->parent, - WLED_BRIGHTNESS_CNTL_REG1(i), val); - if (rc) { - dev_err(led->dev->parent, - "can't write wled brightness ctrl" - " register1 rc=%d\n", rc); - return rc; - } - - val = duty & WLED_8_BIT_MASK; - rc = pm8xxx_writeb(led->dev->parent, - WLED_BRIGHTNESS_CNTL_REG2(i), val); - if (rc) { - dev_err(led->dev->parent, - "can't write wled brightness ctrl" - " register2 rc=%d\n", rc); - return rc; - } - } else - continue; - } - rc = pm8xxx_readb(led->dev->parent, WLED_SYNC_REG, &val); - if (rc) { - dev_err(led->dev->parent, - "can't read wled sync register rc=%d\n", rc); - return rc; - } - /* sync */ - val &= WLED_SYNC_MASK; - val |= WLED_SYNC_VAL; - rc = pm8xxx_writeb(led->dev->parent, WLED_SYNC_REG, val); - if (rc) { - dev_err(led->dev->parent, - "can't read wled sync register rc=%d\n", rc); - return rc; - } - val &= WLED_SYNC_MASK; - val |= WLED_SYNC_RESET_VAL; - rc = pm8xxx_writeb(led->dev->parent, WLED_SYNC_REG, val); - if (rc) { - dev_err(led->dev->parent, - "can't read wled sync register rc=%d\n", rc); - return rc; - } - return 0; -} - -static void wled_dump_regs(struct pm8xxx_led_data *led) -{ - int i; - u8 val; - - for (i = 1; i < 17; i++) { - pm8xxx_readb(led->dev->parent, - SSBI_REG_ADDR_WLED_CTRL(i), &val); - pr_debug("WLED_CTRL_%d = 0x%x\n", i, val); - } -} - -static void -led_rgb_write(struct pm8xxx_led_data *led, u16 addr, enum led_brightness value) -{ - int rc; - u8 val, mask; - - if (led->id != PM8XXX_ID_RGB_LED_BLUE && - led->id != PM8XXX_ID_RGB_LED_RED && - led->id != PM8XXX_ID_RGB_LED_GREEN) - return; - - rc = pm8xxx_readb(led->dev->parent, addr, &val); - if (rc) { - dev_err(led->cdev.dev, "can't read rgb ctrl register rc=%d\n", - rc); - return; - } - - switch (led->id) { - case PM8XXX_ID_RGB_LED_RED: - mask = PM8XXX_DRV_RGB_RED_LED; - break; - case PM8XXX_ID_RGB_LED_GREEN: - mask = PM8XXX_DRV_RGB_GREEN_LED; - break; - case PM8XXX_ID_RGB_LED_BLUE: - mask = PM8XXX_DRV_RGB_BLUE_LED; - break; - default: - return; - } - - if (value) - val |= mask; - else - val &= ~mask; - - rc = pm8xxx_writeb(led->dev->parent, addr, val); - if (rc < 0) - dev_err(led->cdev.dev, "can't set rgb led %d level rc=%d\n", - led->id, rc); -} - -static void -led_rgb_set(struct pm8xxx_led_data *led, enum led_brightness value) -{ - if (value) { - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL1, value); - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL2, value); - } else { - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL2, value); - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL1, value); - } -} - -static int pm8xxx_led_pwm_work(struct pm8xxx_led_data *led) -{ - int duty_us; - int rc = 0; - - if (led->pwm_duty_cycles == NULL) { - duty_us = (led->pwm_period_us * led->cdev.brightness) / - LED_FULL; - rc = pwm_config(led->pwm_dev, duty_us, led->pwm_period_us); - if (led->cdev.brightness) { - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL1, - led->cdev.brightness); - if (led->is_pwm_enabled) { - pwm_disable(led->pwm_dev); - led->is_pwm_enabled = 0; - } - - rc = pwm_enable(led->pwm_dev); - if (!rc) - led->is_pwm_enabled = 1; - } else { - pwm_disable(led->pwm_dev); - led->is_pwm_enabled = 0; - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL1, - led->cdev.brightness); - } - } else { - if (led->cdev.brightness) - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL1, - led->cdev.brightness); - rc = pm8xxx_pwm_lut_enable(led->pwm_dev, led->cdev.brightness); - if (!led->cdev.brightness) - led_rgb_write(led, SSBI_REG_ADDR_RGB_CNTL1, - led->cdev.brightness); - } - - return rc; -} - -static void __pm8xxx_led_work(struct pm8xxx_led_data *led, - enum led_brightness level) -{ - int rc; - - mutex_lock(&led->lock); - - switch (led->id) { - case PM8XXX_ID_LED_KB_LIGHT: - led_kp_set(led, level); - break; - case PM8XXX_ID_LED_0: - case PM8XXX_ID_LED_1: - case PM8XXX_ID_LED_2: - led_lc_set(led, level); - break; - case PM8XXX_ID_FLASH_LED_0: - case PM8XXX_ID_FLASH_LED_1: - led_flash_set(led, level); - break; - case PM8XXX_ID_WLED: - rc = led_wled_set(led, level); - if (rc < 0) - pr_err("wled brightness set failed %d\n", rc); - break; - case PM8XXX_ID_RGB_LED_RED: - case PM8XXX_ID_RGB_LED_GREEN: - case PM8XXX_ID_RGB_LED_BLUE: - led_rgb_set(led, level); - break; - default: - dev_err(led->cdev.dev, "unknown led id %d", led->id); - break; - } - - mutex_unlock(&led->lock); -} - -static void pm8xxx_led_work(struct work_struct *work) -{ - int rc; - - struct pm8xxx_led_data *led = container_of(work, - struct pm8xxx_led_data, work); - - if (led->pwm_dev == NULL) { - __pm8xxx_led_work(led, led->cdev.brightness); - } else { - rc = pm8xxx_led_pwm_work(led); - if (rc) - pr_err("could not configure PWM mode for LED:%d\n", - led->id); - } -} - -static void pm8xxx_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct pm8xxx_led_data *led; - - led = container_of(led_cdev, struct pm8xxx_led_data, cdev); - - if (value < LED_OFF || value > led->cdev.max_brightness) { - dev_err(led->cdev.dev, "Invalid brightness value exceeds"); - return; - } - - led->cdev.brightness = value; - schedule_work(&led->work); -} - -static int pm8xxx_set_led_mode_and_max_brightness(struct pm8xxx_led_data *led, - enum pm8xxx_led_modes led_mode, int max_current) -{ - switch (led->id) { - case PM8XXX_ID_LED_0: - case PM8XXX_ID_LED_1: - case PM8XXX_ID_LED_2: - led->cdev.max_brightness = max_current / - PM8XXX_ID_LED_CURRENT_FACTOR; - if (led->cdev.max_brightness > MAX_LC_LED_BRIGHTNESS) - led->cdev.max_brightness = MAX_LC_LED_BRIGHTNESS; - led->reg = led_mode; - break; - case PM8XXX_ID_LED_KB_LIGHT: - case PM8XXX_ID_FLASH_LED_0: - case PM8XXX_ID_FLASH_LED_1: - led->cdev.max_brightness = max_current / - PM8XXX_ID_FLASH_CURRENT_FACTOR; - if (led->cdev.max_brightness > MAX_FLASH_BRIGHTNESS) - led->cdev.max_brightness = MAX_FLASH_BRIGHTNESS; - - switch (led_mode) { - case PM8XXX_LED_MODE_PWM1: - case PM8XXX_LED_MODE_PWM2: - case PM8XXX_LED_MODE_PWM3: - led->reg = PM8XXX_FLASH_MODE_PWM; - break; - case PM8XXX_LED_MODE_DTEST1: - led->reg = PM8XXX_FLASH_MODE_DBUS1; - break; - case PM8XXX_LED_MODE_DTEST2: - led->reg = PM8XXX_FLASH_MODE_DBUS2; - break; - default: - led->reg = PM8XXX_LED_MODE_MANUAL; - break; - } - break; - case PM8XXX_ID_WLED: - led->cdev.max_brightness = WLED_MAX_LEVEL; - break; - case PM8XXX_ID_RGB_LED_RED: - case PM8XXX_ID_RGB_LED_GREEN: - case PM8XXX_ID_RGB_LED_BLUE: - led->cdev.max_brightness = LED_FULL; - break; - default: - dev_err(led->cdev.dev, "LED Id is invalid"); - return -EINVAL; - } - - return 0; -} - -static enum led_brightness pm8xxx_led_get(struct led_classdev *led_cdev) -{ - struct pm8xxx_led_data *led; - - led = container_of(led_cdev, struct pm8xxx_led_data, cdev); - - return led->cdev.brightness; -} - -static int init_wled(struct pm8xxx_led_data *led) -{ - int rc, i; - u8 val, string_max_current; - - /* program over voltage protection threshold */ - if (led->wled_cfg->ovp_val > WLED_OVP_37V) { - dev_err(led->dev->parent, "Invalid ovp value"); - return -EINVAL; - } - - rc = pm8xxx_readb(led->dev->parent, WLED_OVP_CFG_REG, &val); - if (rc) { - dev_err(led->dev->parent, "can't read wled ovp config" - " register rc=%d\n", rc); - return rc; - } - - val = (val & ~WLED_OVP_VAL_MASK) | - (led->wled_cfg->ovp_val << WLED_OVP_VAL_BIT_SHFT); - - rc = pm8xxx_writeb(led->dev->parent, WLED_OVP_CFG_REG, val); - if (rc) { - dev_err(led->dev->parent, "can't write wled ovp config" - " register rc=%d\n", rc); - return rc; - } - - /* program current boost limit and output feedback*/ - if (led->wled_cfg->boost_curr_lim > WLED_CURR_LIMIT_1680mA) { - dev_err(led->dev->parent, "Invalid boost current limit"); - return -EINVAL; - } - - rc = pm8xxx_readb(led->dev->parent, WLED_BOOST_CFG_REG, &val); - if (rc) { - dev_err(led->dev->parent, "can't read wled boost config" - " register rc=%d\n", rc); - return rc; - } - - val = (val & ~WLED_BOOST_LIMIT_MASK) | - (led->wled_cfg->boost_curr_lim << WLED_BOOST_LIMIT_BIT_SHFT); - - val = (val & ~WLED_OP_FDBCK_MASK) | - (led->wled_cfg->op_fdbck << WLED_OP_FDBCK_BIT_SHFT); - - rc = pm8xxx_writeb(led->dev->parent, WLED_BOOST_CFG_REG, val); - if (rc) { - dev_err(led->dev->parent, "can't write wled boost config" - " register rc=%d\n", rc); - return rc; - } - - /* program high pole capacitance */ - if (led->wled_cfg->cp_select > WLED_CP_SELECT_MAX) { - dev_err(led->dev->parent, "Invalid pole capacitance"); - return -EINVAL; - } - - rc = pm8xxx_readb(led->dev->parent, WLED_HIGH_POLE_CAP_REG, &val); - if (rc) { - dev_err(led->dev->parent, "can't read wled high pole" - " capacitance register rc=%d\n", rc); - return rc; - } - - val = (val & ~WLED_CP_SELECT_MASK) | led->wled_cfg->cp_select; - - rc = pm8xxx_writeb(led->dev->parent, WLED_HIGH_POLE_CAP_REG, val); - if (rc) { - dev_err(led->dev->parent, "can't write wled high pole" - " capacitance register rc=%d\n", rc); - return rc; - } - - /* program activation delay and maximum current */ - for (i = 0; i < WLED_STRINGS; i++) { - if (led->wled_cfg->strings && (1 << i)) { - rc = pm8xxx_readb(led->dev->parent, - WLED_MAX_CURR_CFG_REG(i), &val); - if (rc) { - dev_err(led->dev->parent, - "can't read wled max current" - " config register rc=%d\n", rc); - return rc; - } - - if ((led->wled_cfg->ctrl_delay_us % WLED_CTL_DLY_STEP) - || (led->wled_cfg->ctrl_delay_us > - WLED_CTL_DLY_MAX)) { - dev_err(led->dev->parent, - "Invalid control delay\n"); - return rc; - } - - val = val / WLED_CTL_DLY_STEP; - val = (val & ~WLED_CTL_DLY_MASK) | - (led->wled_cfg->ctrl_delay_us << - WLED_CTL_DLY_BIT_SHFT); - - if ((led->max_current > WLED_MAX_CURR)) { - dev_err(led->dev->parent, - "Invalid max current\n"); - return -EINVAL; - } - if (led->wled_cfg->max_current_ind) { - switch (i) { - case WLED_STRING_ONE: - string_max_current = led->wled_cfg->max_one; - break; - case WLED_STRING_TWO: - string_max_current = led->wled_cfg->max_two; - break; - case WLED_STRING_THREE: - string_max_current = led->wled_cfg->max_three; - break; - default: - return -EINVAL; - } - val = (val & ~WLED_MAX_CURR_MASK) | string_max_current; - } else - val = (val & ~WLED_MAX_CURR_MASK) | led->max_current; - - rc = pm8xxx_writeb(led->dev->parent, - WLED_MAX_CURR_CFG_REG(i), val); - if (rc) { - dev_err(led->dev->parent, - "can't write wled max current" - " config register rc=%d\n", rc); - return rc; - } - } - } - - if (led->wled_cfg->cabc_en) { - rc = pm8xxx_readb(led->dev->parent, WLED_SYNC_REG, &val); - if (rc) { - dev_err(led->dev->parent, - "can't read cabc register rc=%d\n", rc); - return rc; - } - - val |= (led->wled_cfg->strings << WLED_CABC_SHIFT); - - rc = pm8xxx_writeb(led->dev->parent, WLED_SYNC_REG, val); - if (rc) { - dev_err(led->dev->parent, - "can't write to enable cabc rc=%d\n", rc); - return rc; - } - } - - /* program digital module generator, cs out and enable the module */ - rc = pm8xxx_readb(led->dev->parent, WLED_MOD_CTRL_REG, &val); - if (rc) { - dev_err(led->dev->parent, "can't read wled module ctrl" - " register rc=%d\n", rc); - return rc; - } - - if (led->wled_cfg->dig_mod_gen_en) - val |= WLED_DIG_MOD_GEN_MASK; - - if (led->wled_cfg->cs_out_en) - val |= WLED_CS_OUT_MASK; - - val |= WLED_EN_MASK; - - rc = pm8xxx_writeb(led->dev->parent, WLED_MOD_CTRL_REG, val); - if (rc) { - dev_err(led->dev->parent, "can't write wled module ctrl" - " register rc=%d\n", rc); - return rc; - } - led->wled_mod_ctrl_val = val; - - /* dump wled registers */ - wled_dump_regs(led); - - return 0; -} - -static int get_init_value(struct pm8xxx_led_data *led, u8 *val) -{ - int rc, offset; - u16 addr; - - switch (led->id) { - case PM8XXX_ID_LED_KB_LIGHT: - addr = SSBI_REG_ADDR_DRV_KEYPAD; - break; - case PM8XXX_ID_LED_0: - case PM8XXX_ID_LED_1: - case PM8XXX_ID_LED_2: - offset = PM8XXX_LED_OFFSET(led->id); - addr = SSBI_REG_ADDR_LED_CTRL(offset); - break; - case PM8XXX_ID_FLASH_LED_0: - addr = SSBI_REG_ADDR_FLASH_DRV0; - break; - case PM8XXX_ID_FLASH_LED_1: - addr = SSBI_REG_ADDR_FLASH_DRV1; - break; - case PM8XXX_ID_WLED: - rc = init_wled(led); - if (rc) - dev_err(led->cdev.dev, "can't initialize wled rc=%d\n", - rc); - return rc; - case PM8XXX_ID_RGB_LED_RED: - case PM8XXX_ID_RGB_LED_GREEN: - case PM8XXX_ID_RGB_LED_BLUE: - addr = SSBI_REG_ADDR_RGB_CNTL1; - break; - default: - dev_err(led->cdev.dev, "unknown led id %d", led->id); - return -EINVAL; - } - - rc = pm8xxx_readb(led->dev->parent, addr, val); - if (rc) - dev_err(led->cdev.dev, "can't get led(%d) level rc=%d\n", - led->id, rc); - - return rc; -} - -static int pm8xxx_led_pwm_configure(struct pm8xxx_led_data *led) -{ - int start_idx, idx_len, duty_us, rc, flags; - - led->pwm_dev = pwm_request(led->pwm_channel, - led->cdev.name); - - if (IS_ERR_OR_NULL(led->pwm_dev)) { - pr_err("could not acquire PWM Channel %d, " - "error %ld\n", led->pwm_channel, - PTR_ERR(led->pwm_dev)); - led->pwm_dev = NULL; - return -ENODEV; - } - - flags = PM8XXX_LED_PWM_FLAGS; - switch (led->max_current) { - case PM8XXX_PWM_CURRENT_4MA: - flags |= PM_PWM_BANK_LO; - break; - case PM8XXX_PWM_CURRENT_8MA: - flags |= PM_PWM_BANK_HI; - break; - case PM8XXX_PWM_CURRENT_12MA: - flags |= (PM_PWM_BANK_LO | PM_PWM_BANK_HI); - break; - default: - flags |= (PM_PWM_BANK_LO | PM_PWM_BANK_HI); - break; - } - - if (led->pwm_duty_cycles != NULL) { - start_idx = led->pwm_duty_cycles->start_idx; - idx_len = led->pwm_duty_cycles->num_duty_pcts; - - if (idx_len >= PM_PWM_LUT_SIZE && start_idx) { - pr_err("Wrong LUT size or index\n"); - return -EINVAL; - } - if ((start_idx + idx_len) > PM_PWM_LUT_SIZE) { - pr_err("Exceed LUT limit\n"); - return -EINVAL; - } - - rc = pm8xxx_pwm_lut_config(led->pwm_dev, led->pwm_period_us, - led->pwm_duty_cycles->duty_pcts, - led->pwm_duty_cycles->duty_ms, - start_idx, idx_len, 0, 0, - flags); - } else { - duty_us = led->pwm_period_us; - rc = pwm_config(led->pwm_dev, duty_us, led->pwm_period_us); - } - - return rc; -} - - -static int pm8xxx_led_probe(struct platform_device *pdev) -{ - const struct pm8xxx_led_platform_data *pdata = pdev->dev.platform_data; - const struct led_platform_data *pcore_data; - struct led_info *curr_led; - struct pm8xxx_led_data *led, *led_dat; - struct pm8xxx_led_config *led_cfg; - enum pm8xxx_version version; - bool found = false; - int rc, i, j; - - if (pdata == NULL) { - dev_err(&pdev->dev, "platform data not supplied\n"); - return -EINVAL; - } - - pcore_data = pdata->led_core; - - if (pcore_data->num_leds != pdata->num_configs) { - dev_err(&pdev->dev, "#no. of led configs and #no. of led" - "entries are not equal\n"); - return -EINVAL; - } - - led = kcalloc(pcore_data->num_leds, sizeof(*led), GFP_KERNEL); - if (led == NULL) { - dev_err(&pdev->dev, "failed to alloc memory\n"); - return -ENOMEM; - } - - for (i = 0; i < pcore_data->num_leds; i++) { - curr_led = &pcore_data->leds[i]; - led_dat = &led[i]; - led_cfg = &pdata->configs[i]; - - led_dat->id = led_cfg->id; - led_dat->pwm_channel = led_cfg->pwm_channel; - led_dat->pwm_period_us = led_cfg->pwm_period_us; - led_dat->pwm_duty_cycles = led_cfg->pwm_duty_cycles; - led_dat->wled_cfg = led_cfg->wled_cfg; - led_dat->max_current = led_cfg->max_current; - - if (!((led_dat->id >= PM8XXX_ID_LED_KB_LIGHT) && - (led_dat->id < PM8XXX_ID_MAX))) { - dev_err(&pdev->dev, "invalid LED ID(%d) specified\n", - led_dat->id); - rc = -EINVAL; - goto fail_id_check; - - } - - found = false; - version = pm8xxx_get_version(pdev->dev.parent); - for (j = 0; j < ARRAY_SIZE(led_map); j++) { - if (version == led_map[j].version - && (led_map[j].supported & (1 << led_dat->id))) { - found = true; - break; - } - } - - if (!found) { - dev_err(&pdev->dev, "invalid LED ID(%d) specified\n", - led_dat->id); - rc = -EINVAL; - goto fail_id_check; - } - - led_dat->cdev.name = curr_led->name; - led_dat->cdev.default_trigger = curr_led->default_trigger; - led_dat->cdev.brightness_set = pm8xxx_led_set; - led_dat->cdev.brightness_get = pm8xxx_led_get; - led_dat->cdev.brightness = LED_OFF; - led_dat->cdev.flags = curr_led->flags; - led_dat->dev = &pdev->dev; - - rc = get_init_value(led_dat, &led_dat->reg); - if (rc < 0) - goto fail_id_check; - - rc = pm8xxx_set_led_mode_and_max_brightness(led_dat, - led_cfg->mode, led_cfg->max_current); - if (rc < 0) - goto fail_id_check; - - mutex_init(&led_dat->lock); - INIT_WORK(&led_dat->work, pm8xxx_led_work); - - rc = led_classdev_register(&pdev->dev, &led_dat->cdev); - if (rc) { - dev_err(&pdev->dev, "unable to register led %d,rc=%d\n", - led_dat->id, rc); - goto fail_id_check; - } - - /* configure default state */ - if (led_cfg->default_state) - led->cdev.brightness = led_dat->cdev.max_brightness; - else - led->cdev.brightness = LED_OFF; - - if (led_cfg->mode != PM8XXX_LED_MODE_MANUAL) { - if (led_dat->id == PM8XXX_ID_RGB_LED_RED || - led_dat->id == PM8XXX_ID_RGB_LED_GREEN || - led_dat->id == PM8XXX_ID_RGB_LED_BLUE) - __pm8xxx_led_work(led_dat, 0); - else - __pm8xxx_led_work(led_dat, - led_dat->cdev.max_brightness); - - if (led_dat->pwm_channel != -1) { - led_dat->cdev.max_brightness = LED_FULL; - rc = pm8xxx_led_pwm_configure(led_dat); - if (rc) { - dev_err(&pdev->dev, "failed to " - "configure LED, error: %d\n", rc); - goto fail_id_check; - } - schedule_work(&led->work); - } - } else { - __pm8xxx_led_work(led_dat, led->cdev.brightness); - } - } - - platform_set_drvdata(pdev, led); - - return 0; - -fail_id_check: - if (i > 0) { - for (i = i - 1; i >= 0; i--) { - mutex_destroy(&led[i].lock); - led_classdev_unregister(&led[i].cdev); - if (led[i].pwm_dev != NULL) - pwm_free(led[i].pwm_dev); - } - } - kfree(led); - return rc; -} - -static int pm8xxx_led_remove(struct platform_device *pdev) -{ - int i; - const struct led_platform_data *pdata = - pdev->dev.platform_data; - struct pm8xxx_led_data *led = platform_get_drvdata(pdev); - - for (i = 0; i < pdata->num_leds; i++) { - cancel_work_sync(&led[i].work); - mutex_destroy(&led[i].lock); - led_classdev_unregister(&led[i].cdev); - if (led[i].pwm_dev != NULL) - pwm_free(led[i].pwm_dev); - } - - kfree(led); - - return 0; -} - -static struct platform_driver pm8xxx_led_driver = { - .probe = pm8xxx_led_probe, - .remove = pm8xxx_led_remove, - .driver = { - .name = PM8XXX_LEDS_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_led_init(void) -{ - return platform_driver_register(&pm8xxx_led_driver); -} -subsys_initcall(pm8xxx_led_init); - -static void __exit pm8xxx_led_exit(void) -{ - platform_driver_unregister(&pm8xxx_led_driver); -} -module_exit(pm8xxx_led_exit); - -MODULE_DESCRIPTION("PM8XXX LEDs driver"); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pm8xxx-led"); diff --git a/drivers/leds/leds-pmic-mpp.c b/drivers/leds/leds-pmic-mpp.c deleted file mode 100644 index 3608569b482e59df7094aaa470cb0207e0d3f497..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-pmic-mpp.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include - -#include - -#define LED_MPP(x) ((x) & 0xFF) -#define LED_CURR(x) ((x) >> 16) - -struct pmic_mpp_led_data { - struct led_classdev cdev; - int curr; - int mpp; -}; - -static void pm_mpp_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct pmic_mpp_led_data *led; - int ret; - - led = container_of(led_cdev, struct pmic_mpp_led_data, cdev); - - if (value < LED_OFF || value > led->cdev.max_brightness) { - dev_err(led->cdev.dev, "Invalid brightness value"); - return; - } - - ret = pmic_secure_mpp_config_i_sink(led->mpp, led->curr, - value ? PM_MPP__I_SINK__SWITCH_ENA : - PM_MPP__I_SINK__SWITCH_DIS); - if (ret) - dev_err(led_cdev->dev, "can't set mpp led\n"); -} - -static int pmic_mpp_led_probe(struct platform_device *pdev) -{ - const struct led_platform_data *pdata = pdev->dev.platform_data; - struct pmic_mpp_led_data *led, *tmp_led; - int i, rc; - - if (!pdata) { - dev_err(&pdev->dev, "platform data not supplied\n"); - return -EINVAL; - } - - led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL); - if (!led) { - dev_err(&pdev->dev, "failed to alloc memory\n"); - return -ENOMEM; - } - - platform_set_drvdata(pdev, led); - - for (i = 0; i < pdata->num_leds; i++) { - tmp_led = &led[i]; - tmp_led->cdev.name = pdata->leds[i].name; - tmp_led->cdev.brightness_set = pm_mpp_led_set; - tmp_led->cdev.brightness = LED_OFF; - tmp_led->cdev.max_brightness = LED_FULL; - tmp_led->mpp = LED_MPP(pdata->leds[i].flags); - tmp_led->curr = LED_CURR(pdata->leds[i].flags); - - if (tmp_led->curr < PM_MPP__I_SINK__LEVEL_5mA || - tmp_led->curr > PM_MPP__I_SINK__LEVEL_40mA) { - dev_err(&pdev->dev, "invalid current\n"); - goto unreg_led_cdev; - } - - rc = led_classdev_register(&pdev->dev, &tmp_led->cdev); - if (rc) { - dev_err(&pdev->dev, "failed to register led\n"); - goto unreg_led_cdev; - } - } - - return 0; - -unreg_led_cdev: - while (i) - led_classdev_unregister(&led[--i].cdev); - - kfree(led); - return rc; - -} - -static int pmic_mpp_led_remove(struct platform_device *pdev) -{ - const struct led_platform_data *pdata = pdev->dev.platform_data; - struct pmic_mpp_led_data *led = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < pdata->num_leds; i++) - led_classdev_unregister(&led[i].cdev); - - kfree(led); - - return 0; -} - -static struct platform_driver pmic_mpp_led_driver = { - .probe = pmic_mpp_led_probe, - .remove = pmic_mpp_led_remove, - .driver = { - .name = "pmic-mpp-leds", - .owner = THIS_MODULE, - }, -}; - -static int __init pmic_mpp_led_init(void) -{ - return platform_driver_register(&pmic_mpp_led_driver); -} -module_init(pmic_mpp_led_init); - -static void __exit pmic_mpp_led_exit(void) -{ - platform_driver_unregister(&pmic_mpp_led_driver); -} -module_exit(pmic_mpp_led_exit); - -MODULE_DESCRIPTION("PMIC MPP LEDs driver"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:pmic-mpp-leds"); diff --git a/drivers/leds/leds-pmic8058.c b/drivers/leds/leds-pmic8058.c deleted file mode 100644 index 19ff2ccc9b7283e3cce27ee882fa9221b972db18..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-pmic8058.c +++ /dev/null @@ -1,428 +0,0 @@ -/* Copyright (c) 2010, 2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SSBI_REG_ADDR_DRV_KEYPAD 0x48 -#define PM8058_DRV_KEYPAD_BL_MASK 0xf0 -#define PM8058_DRV_KEYPAD_BL_SHIFT 0x04 - -#define SSBI_REG_ADDR_FLASH_DRV0 0x49 -#define PM8058_DRV_FLASH_MASK 0xf0 -#define PM8058_DRV_FLASH_SHIFT 0x04 - -#define SSBI_REG_ADDR_FLASH_DRV1 0xFB - -#define SSBI_REG_ADDR_LED_CTRL_BASE 0x131 -#define SSBI_REG_ADDR_LED_CTRL(n) (SSBI_REG_ADDR_LED_CTRL_BASE + (n)) -#define PM8058_DRV_LED_CTRL_MASK 0xf8 -#define PM8058_DRV_LED_CTRL_SHIFT 0x03 - -#define MAX_FLASH_CURRENT 300 -#define MAX_KEYPAD_CURRENT 300 -#define MAX_KEYPAD_BL_LEVEL (1 << 4) -#define MAX_LED_DRV_LEVEL 20 /* 2 * 20 mA */ - -#define PMIC8058_LED_OFFSET(id) ((id) - PMIC8058_ID_LED_0) - -struct pmic8058_led_data { - struct device *dev; - struct led_classdev cdev; - int id; - enum led_brightness brightness; - u8 flags; - struct work_struct work; - struct mutex lock; - spinlock_t value_lock; - u8 reg_kp; - u8 reg_led_ctrl[3]; - u8 reg_flash_led0; - u8 reg_flash_led1; -}; - -#define PM8058_MAX_LEDS 7 -static struct pmic8058_led_data led_data[PM8058_MAX_LEDS]; - -static void kp_bl_set(struct pmic8058_led_data *led, enum led_brightness value) -{ - int rc; - u8 level; - unsigned long flags; - - spin_lock_irqsave(&led->value_lock, flags); - level = (value << PM8058_DRV_KEYPAD_BL_SHIFT) & - PM8058_DRV_KEYPAD_BL_MASK; - - led->reg_kp &= ~PM8058_DRV_KEYPAD_BL_MASK; - led->reg_kp |= level; - spin_unlock_irqrestore(&led->value_lock, flags); - - rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_DRV_KEYPAD, - led->reg_kp); - if (rc) - pr_err("%s: can't set keypad backlight level\n", __func__); -} - -static enum led_brightness kp_bl_get(struct pmic8058_led_data *led) -{ - if ((led->reg_kp & PM8058_DRV_KEYPAD_BL_MASK) >> - PM8058_DRV_KEYPAD_BL_SHIFT) - return LED_FULL; - else - return LED_OFF; -} - -static void led_lc_set(struct pmic8058_led_data *led, enum led_brightness value) -{ - unsigned long flags; - int rc, offset; - u8 level, tmp; - - spin_lock_irqsave(&led->value_lock, flags); - - level = (led->brightness << PM8058_DRV_LED_CTRL_SHIFT) & - PM8058_DRV_LED_CTRL_MASK; - - offset = PMIC8058_LED_OFFSET(led->id); - tmp = led->reg_led_ctrl[offset]; - - tmp &= ~PM8058_DRV_LED_CTRL_MASK; - tmp |= level; - spin_unlock_irqrestore(&led->value_lock, flags); - - rc = pm8xxx_writeb(led->dev->parent, SSBI_REG_ADDR_LED_CTRL(offset), - tmp); - if (rc) { - dev_err(led->cdev.dev, "can't set (%d) led value\n", - led->id); - return; - } - - spin_lock_irqsave(&led->value_lock, flags); - led->reg_led_ctrl[offset] = tmp; - spin_unlock_irqrestore(&led->value_lock, flags); -} - -static enum led_brightness led_lc_get(struct pmic8058_led_data *led) -{ - int offset; - u8 value; - - offset = PMIC8058_LED_OFFSET(led->id); - value = led->reg_led_ctrl[offset]; - - if ((value & PM8058_DRV_LED_CTRL_MASK) >> - PM8058_DRV_LED_CTRL_SHIFT) - return LED_FULL; - else - return LED_OFF; -} - -static void -led_flash_set(struct pmic8058_led_data *led, enum led_brightness value) -{ - int rc; - u8 level; - unsigned long flags; - u8 reg_flash_led; - u16 reg_addr; - - spin_lock_irqsave(&led->value_lock, flags); - level = (value << PM8058_DRV_FLASH_SHIFT) & - PM8058_DRV_FLASH_MASK; - - if (led->id == PMIC8058_ID_FLASH_LED_0) { - led->reg_flash_led0 &= ~PM8058_DRV_FLASH_MASK; - led->reg_flash_led0 |= level; - reg_flash_led = led->reg_flash_led0; - reg_addr = SSBI_REG_ADDR_FLASH_DRV0; - } else { - led->reg_flash_led1 &= ~PM8058_DRV_FLASH_MASK; - led->reg_flash_led1 |= level; - reg_flash_led = led->reg_flash_led1; - reg_addr = SSBI_REG_ADDR_FLASH_DRV1; - } - spin_unlock_irqrestore(&led->value_lock, flags); - - rc = pm8xxx_writeb(led->dev->parent, reg_addr, reg_flash_led); - if (rc) - pr_err("%s: can't set flash led%d level %d\n", __func__, - led->id, rc); -} - -int pm8058_set_flash_led_current(enum pmic8058_leds id, unsigned mA) -{ - struct pmic8058_led_data *led; - - if ((id < PMIC8058_ID_FLASH_LED_0) || (id > PMIC8058_ID_FLASH_LED_1)) { - pr_err("%s: invalid LED ID (%d) specified\n", __func__, id); - return -EINVAL; - } - - led = &led_data[id]; - if (!led) { - pr_err("%s: flash led not available\n", __func__); - return -EINVAL; - } - - if (mA > MAX_FLASH_CURRENT) - return -EINVAL; - - led_flash_set(led, mA / 20); - - return 0; -} -EXPORT_SYMBOL(pm8058_set_flash_led_current); - -int pm8058_set_led_current(enum pmic8058_leds id, unsigned mA) -{ - struct pmic8058_led_data *led; - int brightness = 0; - - if ((id < PMIC8058_ID_LED_KB_LIGHT) || (id > PMIC8058_ID_FLASH_LED_1)) { - pr_err("%s: invalid LED ID (%d) specified\n", __func__, id); - return -EINVAL; - } - - led = &led_data[id]; - if (!led) { - pr_err("%s: flash led not available\n", __func__); - return -EINVAL; - } - - switch (id) { - case PMIC8058_ID_LED_0: - case PMIC8058_ID_LED_1: - case PMIC8058_ID_LED_2: - brightness = mA / 2; - if (brightness > led->cdev.max_brightness) - return -EINVAL; - led_lc_set(led, brightness); - break; - - case PMIC8058_ID_LED_KB_LIGHT: - case PMIC8058_ID_FLASH_LED_0: - case PMIC8058_ID_FLASH_LED_1: - brightness = mA / 20; - if (brightness > led->cdev.max_brightness) - return -EINVAL; - if (id == PMIC8058_ID_LED_KB_LIGHT) - kp_bl_set(led, brightness); - else - led_flash_set(led, brightness); - break; - } - - return 0; -} -EXPORT_SYMBOL(pm8058_set_led_current); - -static void pmic8058_led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - struct pmic8058_led_data *led; - unsigned long flags; - - led = container_of(led_cdev, struct pmic8058_led_data, cdev); - - spin_lock_irqsave(&led->value_lock, flags); - led->brightness = value; - schedule_work(&led->work); - spin_unlock_irqrestore(&led->value_lock, flags); -} - -static void pmic8058_led_work(struct work_struct *work) -{ - struct pmic8058_led_data *led = container_of(work, - struct pmic8058_led_data, work); - - mutex_lock(&led->lock); - - switch (led->id) { - case PMIC8058_ID_LED_KB_LIGHT: - kp_bl_set(led, led->brightness); - break; - case PMIC8058_ID_LED_0: - case PMIC8058_ID_LED_1: - case PMIC8058_ID_LED_2: - led_lc_set(led, led->brightness); - break; - case PMIC8058_ID_FLASH_LED_0: - case PMIC8058_ID_FLASH_LED_1: - led_flash_set(led, led->brightness); - break; - } - - mutex_unlock(&led->lock); -} - -static enum led_brightness pmic8058_led_get(struct led_classdev *led_cdev) -{ - struct pmic8058_led_data *led; - - led = container_of(led_cdev, struct pmic8058_led_data, cdev); - - switch (led->id) { - case PMIC8058_ID_LED_KB_LIGHT: - return kp_bl_get(led); - case PMIC8058_ID_LED_0: - case PMIC8058_ID_LED_1: - case PMIC8058_ID_LED_2: - return led_lc_get(led); - } - return LED_OFF; -} - -static int pmic8058_led_probe(struct platform_device *pdev) -{ - struct pmic8058_leds_platform_data *pdata = pdev->dev.platform_data; - struct pmic8058_led_data *led_dat; - struct pmic8058_led *curr_led; - int rc, i = 0; - u8 reg_kp; - u8 reg_led_ctrl[3]; - u8 reg_flash_led0; - u8 reg_flash_led1; - - if (pdata == NULL) { - dev_err(&pdev->dev, "platform data not supplied\n"); - return -EINVAL; - } - - rc = pm8xxx_readb(pdev->dev.parent, SSBI_REG_ADDR_DRV_KEYPAD, ®_kp); - if (rc) { - dev_err(&pdev->dev, "can't get keypad backlight level\n"); - goto err_reg_read; - } - - rc = pm8xxx_read_buf(pdev->dev.parent, SSBI_REG_ADDR_LED_CTRL_BASE, - reg_led_ctrl, 3); - if (rc) { - dev_err(&pdev->dev, "can't get led levels\n"); - goto err_reg_read; - } - - rc = pm8xxx_readb(pdev->dev.parent, SSBI_REG_ADDR_FLASH_DRV0, - ®_flash_led0); - if (rc) { - dev_err(&pdev->dev, "can't read flash led0\n"); - goto err_reg_read; - } - - rc = pm8xxx_readb(pdev->dev.parent, SSBI_REG_ADDR_FLASH_DRV1, - ®_flash_led1); - if (rc) { - dev_err(&pdev->dev, "can't get flash led1\n"); - goto err_reg_read; - } - - for (i = 0; i < pdata->num_leds; i++) { - curr_led = &pdata->leds[i]; - led_dat = &led_data[curr_led->id]; - - led_dat->cdev.name = curr_led->name; - led_dat->cdev.default_trigger = curr_led->default_trigger; - led_dat->cdev.brightness_set = pmic8058_led_set; - led_dat->cdev.brightness_get = pmic8058_led_get; - led_dat->cdev.brightness = LED_OFF; - led_dat->cdev.max_brightness = curr_led->max_brightness; - led_dat->cdev.flags = LED_CORE_SUSPENDRESUME; - - led_dat->id = curr_led->id; - led_dat->reg_kp = reg_kp; - memcpy(led_data->reg_led_ctrl, reg_led_ctrl, - sizeof(reg_led_ctrl)); - led_dat->reg_flash_led0 = reg_flash_led0; - led_dat->reg_flash_led1 = reg_flash_led1; - - if (!((led_dat->id >= PMIC8058_ID_LED_KB_LIGHT) && - (led_dat->id <= PMIC8058_ID_FLASH_LED_1))) { - dev_err(&pdev->dev, "invalid LED ID (%d) specified\n", - led_dat->id); - rc = -EINVAL; - goto fail_id_check; - } - - led_dat->dev = &pdev->dev; - - mutex_init(&led_dat->lock); - spin_lock_init(&led_dat->value_lock); - INIT_WORK(&led_dat->work, pmic8058_led_work); - - rc = led_classdev_register(&pdev->dev, &led_dat->cdev); - if (rc) { - dev_err(&pdev->dev, "unable to register led %d\n", - led_dat->id); - goto fail_id_check; - } - } - - platform_set_drvdata(pdev, led_data); - - return 0; - -err_reg_read: -fail_id_check: - if (i > 0) { - for (i = i - 1; i >= 0; i--) - led_classdev_unregister(&led_data[i].cdev); - } - return rc; -} - -static int pmic8058_led_remove(struct platform_device *pdev) -{ - int i; - struct pmic8058_leds_platform_data *pdata = pdev->dev.platform_data; - struct pmic8058_led_data *led = platform_get_drvdata(pdev); - - for (i = 0; i < pdata->num_leds; i++) { - led_classdev_unregister(&led[led->id].cdev); - cancel_work_sync(&led[led->id].work); - } - - return 0; -} - -static struct platform_driver pmic8058_led_driver = { - .probe = pmic8058_led_probe, - .remove = pmic8058_led_remove, - .driver = { - .name = "pm8058-led", - .owner = THIS_MODULE, - }, -}; - -static int __init pmic8058_led_init(void) -{ - return platform_driver_register(&pmic8058_led_driver); -} -module_init(pmic8058_led_init); - -static void __exit pmic8058_led_exit(void) -{ - platform_driver_unregister(&pmic8058_led_driver); -} -module_exit(pmic8058_led_exit); - -MODULE_DESCRIPTION("PMIC8058 LEDs driver"); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pmic8058-led"); diff --git a/drivers/leds/leds-qci-backlight.c b/drivers/leds/leds-qci-backlight.c deleted file mode 100644 index 67502e89f635bb5aafde07587ea16d0af0fcb876..0000000000000000000000000000000000000000 --- a/drivers/leds/leds-qci-backlight.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Quanta I2C Backlight Driver - * - * Copyright (C) 2009 Quanta Computer Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -/* - * - * The Driver with I/O communications via the I2C Interface for ST15 platform. - * And it is only working on the nuvoTon WPCE775x Embedded Controller. - * - */ - -#include -#include -#include -#include -#include - -#define EC_CMD_SET_BACKLIGHT 0xB1 - -static void qci_backlight_store(struct led_classdev *led_cdev, - enum led_brightness val); - -static struct platform_device *bl_pdev; -static struct led_classdev lcd_backlight = { - .name = "lcd-backlight", - .brightness = 147, - .brightness_set = qci_backlight_store, -}; - -static void qci_backlight_store(struct led_classdev *led_cdev, - enum led_brightness val) -{ - u16 value = val; - wpce_smbus_write_word_data(EC_CMD_SET_BACKLIGHT, value); - msleep(10); - - dev_dbg(&bl_pdev->dev, "[backlight_store] : value = %d\n", value); -} - -static int __init qci_backlight_init(void) -{ - int err = 0; - bl_pdev = platform_device_register_simple("backlight", 0, NULL, 0); - err = led_classdev_register(&bl_pdev->dev, &lcd_backlight); - return err; -} - -static void __exit qci_backlight_exit(void) -{ - led_classdev_unregister(&lcd_backlight); - platform_device_unregister(bl_pdev); -} - -module_init(qci_backlight_init); -module_exit(qci_backlight_exit); - -MODULE_AUTHOR("Quanta Computer Inc."); -MODULE_DESCRIPTION("Quanta Embedded Controller I2C Backlight Driver"); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/media/platform/msm/Makefile b/drivers/media/platform/msm/Makefile index 799b6a6400fe10d74ffe5d36fbca8418dbada1be..80f675016f7765e12bcb468da0115394880eafcb 100644 --- a/drivers/media/platform/msm/Makefile +++ b/drivers/media/platform/msm/Makefile @@ -8,4 +8,3 @@ obj-$(CONFIG_MSM_WFD) += wfd/ obj-y += broadcast/ obj-$(CONFIG_DVB_MPQ) += dvb/ obj-$(CONFIG_MSMB_CAMERA) += camera_v2/ -obj-y += vcap/ diff --git a/drivers/media/platform/msm/camera_v2/Makefile b/drivers/media/platform/msm/camera_v2/Makefile index 51a91d0d59eaa2b95727e333edd7205412f36978..a7dad0a8129e184cbc45a3812079e1fb926e935a 100644 --- a/drivers/media/platform/msm/camera_v2/Makefile +++ b/drivers/media/platform/msm/camera_v2/Makefile @@ -16,4 +16,3 @@ obj-$(CONFIG_MSMB_CAMERA) += isp/ obj-$(CONFIG_MSMB_CAMERA) += ispif/ obj-$(CONFIG_MSMB_JPEG) += jpeg_10/ obj-$(CONFIG_MSMB_CAMERA) += msm_buf_mgr/ -obj-$(CONFIG_MSMB_CAMERA) += gemini/ diff --git a/drivers/media/platform/msm/camera_v2/gemini/Makefile b/drivers/media/platform/msm/camera_v2/gemini/Makefile deleted file mode 100644 index 74d72949159ec9b00d89ff487d83b1d8037451ff..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -GCC_VERSION := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc) -ccflags-y += -Idrivers/media/video/msm -ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/io - -obj-$(CONFIG_MSM_GEMINI) += msm_gemini_dev.o msm_gemini_sync.o msm_gemini_core.o msm_gemini_hw.o msm_gemini_platform.o diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_common.h b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_common.h deleted file mode 100644 index eefad6d8cd67df098436f0e1cce55bdb196a2e38..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_common.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2010,2013, 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 MSM_GEMINI_COMMON_H -#define MSM_GEMINI_COMMON_H - -#define MSM_GEMINI_DEBUG -#ifdef MSM_GEMINI_DEBUG -#define GMN_DBG(fmt, args...) pr_debug(fmt, ##args) -#else -#define GMN_DBG(fmt, args...) do { } while (0) -#endif - -#define GMN_PR_ERR pr_err - -enum GEMINI_MODE { - GEMINI_MODE_DISABLE, - GEMINI_MODE_OFFLINE, - GEMINI_MODE_REALTIME, - GEMINI_MODE_REALTIME_ROTATION -}; - -enum GEMINI_ROTATION { - GEMINI_ROTATION_0, - GEMINI_ROTATION_90, - GEMINI_ROTATION_180, - GEMINI_ROTATION_270 -}; - -#endif /* MSM_GEMINI_COMMON_H */ diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_core.c b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_core.c deleted file mode 100644 index 88fa9e72931eec8008e79add8f9d75a58f06b60e..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_core.c +++ /dev/null @@ -1,250 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include "msm_gemini_hw.h" -#include "msm_gemini_core.h" -#include "msm_gemini_platform.h" -#include "msm_gemini_common.h" - -static struct msm_gemini_hw_pingpong fe_pingpong_buf; -static struct msm_gemini_hw_pingpong we_pingpong_buf; -static int we_pingpong_index; -static int reset_done_ack; -static spinlock_t reset_lock; -static wait_queue_head_t reset_wait; - -int msm_gemini_core_reset(uint8_t op_mode, void *base, int size) -{ - unsigned long flags; - int rc = 0; - int tm = 500; - memset(&fe_pingpong_buf, 0, sizeof(fe_pingpong_buf)); - fe_pingpong_buf.is_fe = 1; - we_pingpong_index = 0; - memset(&we_pingpong_buf, 0, sizeof(we_pingpong_buf)); - spin_lock_irqsave(&reset_lock, flags); - reset_done_ack = 0; - msm_gemini_hw_reset(base, size); - spin_unlock_irqrestore(&reset_lock, flags); - rc = wait_event_interruptible_timeout( - reset_wait, - reset_done_ack, - msecs_to_jiffies(tm)); - - if (!reset_done_ack) { - GMN_DBG("%s: reset ACK failed %d", __func__, rc); - return -EBUSY; - } - - GMN_DBG("%s: reset_done_ack rc %d", __func__, rc); - spin_lock_irqsave(&reset_lock, flags); - reset_done_ack = 0; - spin_unlock_irqrestore(&reset_lock, flags); - - if (op_mode == MSM_GEMINI_MODE_REALTIME_ENCODE) { - /* Nothing needed for fe buffer cfg, config we only */ - msm_gemini_hw_we_buffer_cfg(1); - } else { - /* Nothing needed for fe buffer cfg, config we only */ - msm_gemini_hw_we_buffer_cfg(0); - } - - /* @todo wait for reset done irq */ - - return 0; -} - -void msm_gemini_core_release(int release_buf) -{ - int i = 0; - for (i = 0; i < 2; i++) { - if (we_pingpong_buf.buf_status[i] && release_buf) - msm_gemini_platform_p2v(we_pingpong_buf.buf[i].file, - &we_pingpong_buf.buf[i].handle); - we_pingpong_buf.buf_status[i] = 0; - } -} - -void msm_gemini_core_init(void) -{ - init_waitqueue_head(&reset_wait); - spin_lock_init(&reset_lock); -} - -int msm_gemini_core_fe_start(void) -{ - msm_gemini_hw_fe_start(); - return 0; -} - -/* fetch engine */ -int msm_gemini_core_fe_buf_update(struct msm_gemini_core_buf *buf) -{ - GMN_DBG("%s:%d] 0x%08x %d 0x%08x %d\n", __func__, __LINE__, - (int) buf->y_buffer_addr, buf->y_len, - (int) buf->cbcr_buffer_addr, buf->cbcr_len); - return msm_gemini_hw_pingpong_update(&fe_pingpong_buf, buf); -} - -void *msm_gemini_core_fe_pingpong_irq(int gemini_irq_status, void *context) -{ - return msm_gemini_hw_pingpong_irq(&fe_pingpong_buf); -} - -/* write engine */ -int msm_gemini_core_we_buf_update(struct msm_gemini_core_buf *buf) -{ - int rc; - GMN_DBG("%s:%d] 0x%08x 0x%08x %d\n", __func__, __LINE__, - (int) buf->y_buffer_addr, (int) buf->cbcr_buffer_addr, - buf->y_len); - we_pingpong_buf.buf_status[we_pingpong_index] = 0; - we_pingpong_index = (we_pingpong_index + 1)%2; - rc = msm_gemini_hw_pingpong_update(&we_pingpong_buf, buf); - return 0; -} - -int msm_gemini_core_we_buf_reset(struct msm_gemini_hw_buf *buf) -{ - int i; - for (i = 0; i < 2; i++) { - if (we_pingpong_buf.buf[i].y_buffer_addr - == buf->y_buffer_addr) - we_pingpong_buf.buf_status[i] = 0; - } - return 0; -} - -void *msm_gemini_core_we_pingpong_irq(int gemini_irq_status, void *context) -{ - GMN_DBG("%s:%d]\n", __func__, __LINE__); - - return msm_gemini_hw_pingpong_irq(&we_pingpong_buf); -} - -void *msm_gemini_core_framedone_irq(int gemini_irq_status, void *context) -{ - struct msm_gemini_hw_buf *buf_p; - - GMN_DBG("%s:%d]\n", __func__, __LINE__); - - buf_p = msm_gemini_hw_pingpong_active_buffer(&we_pingpong_buf); - if (buf_p) { - buf_p->framedone_len = msm_gemini_hw_encode_output_size(); - GMN_DBG("%s:%d] framedone_len %d\n", __func__, __LINE__, - buf_p->framedone_len); - } - - return buf_p; -} - -void *msm_gemini_core_reset_ack_irq(int gemini_irq_status, void *context) -{ - /* @todo return the status back to msm_gemini_core_reset */ - GMN_DBG("%s:%d]\n", __func__, __LINE__); - return NULL; -} - -void *msm_gemini_core_err_irq(int gemini_irq_status, void *context) -{ - GMN_PR_ERR("%s:%d]\n", __func__, gemini_irq_status); - return NULL; -} - -static int (*msm_gemini_irq_handler) (int, void *, void *); - -irqreturn_t msm_gemini_core_irq(int irq_num, void *context) -{ - void *data = NULL; - unsigned long flags; - int gemini_irq_status; - - GMN_DBG("%s:%d] irq_num = %d\n", __func__, __LINE__, irq_num); - - spin_lock_irqsave(&reset_lock, flags); - reset_done_ack = 1; - spin_unlock_irqrestore(&reset_lock, flags); - gemini_irq_status = msm_gemini_hw_irq_get_status(); - - GMN_DBG("%s:%d] gemini_irq_status = %0x\n", __func__, __LINE__, - gemini_irq_status); - - /* For reset and framedone IRQs, clear all bits */ - if (gemini_irq_status & 0x400) { - wake_up(&reset_wait); - msm_gemini_hw_irq_clear(HWIO_JPEG_IRQ_CLEAR_RMSK, - JPEG_IRQ_CLEAR_ALL); - } else if (gemini_irq_status & 0x1) { - msm_gemini_hw_irq_clear(HWIO_JPEG_IRQ_CLEAR_RMSK, - JPEG_IRQ_CLEAR_ALL); - } else { - msm_gemini_hw_irq_clear(HWIO_JPEG_IRQ_CLEAR_RMSK, - gemini_irq_status); - } - - if (msm_gemini_hw_irq_is_frame_done(gemini_irq_status)) { - data = msm_gemini_core_framedone_irq(gemini_irq_status, - context); - if (msm_gemini_irq_handler) - msm_gemini_irq_handler( - MSM_GEMINI_HW_MASK_COMP_FRAMEDONE, - context, data); - } - - if (msm_gemini_hw_irq_is_fe_pingpong(gemini_irq_status)) { - data = msm_gemini_core_fe_pingpong_irq(gemini_irq_status, - context); - if (msm_gemini_irq_handler) - msm_gemini_irq_handler(MSM_GEMINI_HW_MASK_COMP_FE, - context, data); - } - - if (msm_gemini_hw_irq_is_we_pingpong(gemini_irq_status) && - !msm_gemini_hw_irq_is_frame_done(gemini_irq_status)) { - data = msm_gemini_core_we_pingpong_irq(gemini_irq_status, - context); - if (msm_gemini_irq_handler) - msm_gemini_irq_handler(MSM_GEMINI_HW_MASK_COMP_WE, - context, data); - } - - if (msm_gemini_hw_irq_is_reset_ack(gemini_irq_status)) { - data = msm_gemini_core_reset_ack_irq(gemini_irq_status, - context); - if (msm_gemini_irq_handler) - msm_gemini_irq_handler( - MSM_GEMINI_HW_MASK_COMP_RESET_ACK, - context, data); - } - - /* Unexpected/unintended HW interrupt */ - if (msm_gemini_hw_irq_is_err(gemini_irq_status)) { - data = msm_gemini_core_err_irq(gemini_irq_status, context); - if (msm_gemini_irq_handler) - msm_gemini_irq_handler(MSM_GEMINI_HW_MASK_COMP_ERR, - context, data); - } - - return IRQ_HANDLED; -} - -void msm_gemini_core_irq_install(int (*irq_handler) (int, void *, void *)) -{ - msm_gemini_irq_handler = irq_handler; -} - -void msm_gemini_core_irq_remove(void) -{ - msm_gemini_irq_handler = NULL; -} diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_core.h b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_core.h deleted file mode 100644 index 3aac25aa91cf84fa1900faf639c3c8f2e0bea89e..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_core.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2010,2013, 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 MSM_GEMINI_CORE_H -#define MSM_GEMINI_CORE_H - -#include -#include "msm_gemini_hw.h" - -#define msm_gemini_core_buf msm_gemini_hw_buf - -irqreturn_t msm_gemini_core_irq(int irq_num, void *context); - -void msm_gemini_core_irq_install(int (*irq_handler) (int, void *, void *)); -void msm_gemini_core_irq_remove(void); - -int msm_gemini_core_fe_buf_update(struct msm_gemini_core_buf *buf); -int msm_gemini_core_we_buf_update(struct msm_gemini_core_buf *buf); -int msm_gemini_core_we_buf_reset(struct msm_gemini_hw_buf *buf); - -int msm_gemini_core_reset(uint8_t op_mode, void *base, int size); -int msm_gemini_core_fe_start(void); - -void msm_gemini_core_release(int); -void msm_gemini_core_init(void); -#endif /* MSM_GEMINI_CORE_H */ diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_dev.c b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_dev.c deleted file mode 100644 index 13c1e112a93c587ddc7c9522d0f370ed78b82016..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_dev.c +++ /dev/null @@ -1,265 +0,0 @@ -/* Copyright (c) 2010-2011,2013 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../msm.h" -#include "msm_gemini_sync.h" -#include "msm_gemini_common.h" - -#define MSM_GEMINI_NAME "gemini" -#define MSM_GEMINI_DRV_NAME "msm_gemini" - -static int msm_gemini_open(struct inode *inode, struct file *filp) -{ - int rc; - - struct msm_gemini_device *pgmn_dev = container_of(inode->i_cdev, - struct msm_gemini_device, cdev); - filp->private_data = pgmn_dev; - - GMN_DBG("%s:%d]\n", __func__, __LINE__); - - rc = __msm_gemini_open(pgmn_dev); - - GMN_DBG("%s:%d] %s open_count = %d\n", __func__, __LINE__, - filp->f_path.dentry->d_name.name, pgmn_dev->open_count); - - return rc; -} - -static int msm_gemini_release(struct inode *inode, struct file *filp) -{ - int rc; - - struct msm_gemini_device *pgmn_dev = filp->private_data; - - GMN_DBG("%s:%d]\n", __func__, __LINE__); - - rc = __msm_gemini_release(pgmn_dev); - - GMN_DBG("%s:%d] %s open_count = %d\n", __func__, __LINE__, - filp->f_path.dentry->d_name.name, pgmn_dev->open_count); - return rc; -} - -static long msm_gemini_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - int rc; - struct msm_gemini_device *pgmn_dev = filp->private_data; - - GMN_DBG("%s:%d] cmd=%d pgmn_dev=0x%x arg=0x%x\n", __func__, - __LINE__, _IOC_NR(cmd), (uint32_t)pgmn_dev, (uint32_t)arg); - - rc = __msm_gemini_ioctl(pgmn_dev, cmd, arg); - - GMN_DBG("%s:%d]\n", __func__, __LINE__); - return rc; -} - -static const struct file_operations msm_gemini_fops = { - .owner = THIS_MODULE, - .open = msm_gemini_open, - .release = msm_gemini_release, - .unlocked_ioctl = msm_gemini_ioctl, -}; - -static struct class *msm_gemini_class; -static dev_t msm_gemini_devno; -static struct msm_gemini_device *msm_gemini_device_p; - -int msm_gemini_subdev_init(struct v4l2_subdev *gemini_sd) -{ - int rc; - struct msm_gemini_device *pgmn_dev = - (struct msm_gemini_device *)gemini_sd->host_priv; - - GMN_DBG("%s:%d: gemini_sd=0x%x pgmn_dev=0x%x\n", - __func__, __LINE__, (uint32_t)gemini_sd, (uint32_t)pgmn_dev); - rc = __msm_gemini_open(pgmn_dev); - GMN_DBG("%s:%d: rc=%d\n", - __func__, __LINE__, rc); - return rc; -} - -static long msm_gemini_subdev_ioctl(struct v4l2_subdev *sd, - unsigned int cmd, void *arg) -{ - long rc; - struct msm_gemini_device *pgmn_dev = - (struct msm_gemini_device *)sd->host_priv; - - GMN_DBG("%s: cmd=%d\n", __func__, cmd); - - GMN_DBG("%s: pgmn_dev 0x%x", __func__, (uint32_t)pgmn_dev); - - GMN_DBG("%s: Calling __msm_gemini_ioctl\n", __func__); - - rc = __msm_gemini_ioctl(pgmn_dev, cmd, (unsigned long)arg); - GMN_DBG("%s: X\n", __func__); - return rc; -} - -void msm_gemini_subdev_release(struct v4l2_subdev *gemini_sd) -{ - int rc; - struct msm_gemini_device *pgmn_dev = - (struct msm_gemini_device *)gemini_sd->host_priv; - GMN_DBG("%s:pgmn_dev=0x%x", __func__, (uint32_t)pgmn_dev); - rc = __msm_gemini_release(pgmn_dev); - GMN_DBG("%s:rc=%d", __func__, rc); -} - -static const struct v4l2_subdev_core_ops msm_gemini_subdev_core_ops = { - .ioctl = msm_gemini_subdev_ioctl, -}; - -static const struct v4l2_subdev_ops msm_gemini_subdev_ops = { - .core = &msm_gemini_subdev_core_ops, -}; - -static int msm_gemini_init(struct platform_device *pdev) -{ - int rc = -1; - struct device *dev; - - GMN_DBG("%s:\n", __func__); - msm_gemini_device_p = __msm_gemini_init(pdev); - if (msm_gemini_device_p == NULL) { - GMN_PR_ERR("%s: initialization failed\n", __func__); - goto fail; - } - - v4l2_subdev_init(&msm_gemini_device_p->subdev, &msm_gemini_subdev_ops); - v4l2_set_subdev_hostdata(&msm_gemini_device_p->subdev, - msm_gemini_device_p); - GMN_DBG("%s: msm_gemini_device_p 0x%x", __func__, - (uint32_t)msm_gemini_device_p); - GMN_DBG("%s:gemini: platform_set_drvdata\n", __func__); - platform_set_drvdata(pdev, &msm_gemini_device_p->subdev); - - rc = alloc_chrdev_region(&msm_gemini_devno, 0, 1, MSM_GEMINI_NAME); - if (rc < 0) { - GMN_PR_ERR("%s: failed to allocate chrdev\n", __func__); - goto fail_1; - } - - if (!msm_gemini_class) { - msm_gemini_class = class_create(THIS_MODULE, MSM_GEMINI_NAME); - if (IS_ERR(msm_gemini_class)) { - rc = PTR_ERR(msm_gemini_class); - GMN_PR_ERR("%s: create device class failed\n", - __func__); - goto fail_2; - } - } - - dev = device_create(msm_gemini_class, NULL, - MKDEV(MAJOR(msm_gemini_devno), MINOR(msm_gemini_devno)), NULL, - "%s%d", MSM_GEMINI_NAME, 0); - - if (IS_ERR(dev)) { - GMN_PR_ERR("%s: error creating device\n", __func__); - rc = -ENODEV; - goto fail_3; - } - - cdev_init(&msm_gemini_device_p->cdev, &msm_gemini_fops); - msm_gemini_device_p->cdev.owner = THIS_MODULE; - msm_gemini_device_p->cdev.ops = - (const struct file_operations *) &msm_gemini_fops; - rc = cdev_add(&msm_gemini_device_p->cdev, msm_gemini_devno, 1); - if (rc < 0) { - GMN_PR_ERR("%s: error adding cdev\n", __func__); - rc = -ENODEV; - goto fail_4; - } - - GMN_DBG("%s %s: success\n", __func__, MSM_GEMINI_NAME); - - return rc; - -fail_4: - device_destroy(msm_gemini_class, msm_gemini_devno); - -fail_3: - class_destroy(msm_gemini_class); - -fail_2: - unregister_chrdev_region(msm_gemini_devno, 1); - -fail_1: - __msm_gemini_exit(msm_gemini_device_p); - -fail: - return rc; -} - -static void msm_gemini_exit(void) -{ - cdev_del(&msm_gemini_device_p->cdev); - device_destroy(msm_gemini_class, msm_gemini_devno); - class_destroy(msm_gemini_class); - unregister_chrdev_region(msm_gemini_devno, 1); - - __msm_gemini_exit(msm_gemini_device_p); -} - -static int __msm_gemini_probe(struct platform_device *pdev) -{ - return msm_gemini_init(pdev); -} - -static int __msm_gemini_remove(struct platform_device *pdev) -{ - msm_gemini_exit(); - return 0; -} - -static struct platform_driver msm_gemini_driver = { - .probe = __msm_gemini_probe, - .remove = __msm_gemini_remove, - .driver = { - .name = MSM_GEMINI_DRV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init msm_gemini_driver_init(void) -{ - int rc; - rc = platform_driver_register(&msm_gemini_driver); - return rc; -} - -static void __exit msm_gemini_driver_exit(void) -{ - platform_driver_unregister(&msm_gemini_driver); -} - -MODULE_DESCRIPTION("MSM Gemini JPEG driver"); -MODULE_VERSION("msm gemini 0.1"); - -module_init(msm_gemini_driver_init); -module_exit(msm_gemini_driver_exit); - diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw.c b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw.c deleted file mode 100644 index da6f69f9705f94176b4165040cf4e1e456bd17c8..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw.c +++ /dev/null @@ -1,520 +0,0 @@ -/* Copyright (c) 2010,2013, 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 -#include -#include -#include "msm_gemini_hw.h" -#include "msm_gemini_common.h" - - -static void *gemini_region_base; -static uint32_t gemini_region_size; - -int msm_gemini_hw_pingpong_update(struct msm_gemini_hw_pingpong *pingpong_hw, - struct msm_gemini_hw_buf *buf) -{ - int buf_free_index = -1; - - if (!pingpong_hw->buf_status[0]) - buf_free_index = 0; - else if (!pingpong_hw->buf_status[1]) - buf_free_index = 1; - else { - GMN_PR_ERR("%s:%d: pingpong buffer busy\n", __func__, __LINE__); - return -EBUSY; - } - - pingpong_hw->buf[buf_free_index] = *buf; - pingpong_hw->buf_status[buf_free_index] = 1; - - if (pingpong_hw->is_fe) - msm_gemini_hw_fe_buffer_update( - &pingpong_hw->buf[buf_free_index], buf_free_index); - else - msm_gemini_hw_we_buffer_update( - &pingpong_hw->buf[buf_free_index], buf_free_index); - return 0; -} - -void *msm_gemini_hw_pingpong_irq(struct msm_gemini_hw_pingpong *pingpong_hw) -{ - struct msm_gemini_hw_buf *buf_p = NULL; - - if (pingpong_hw->buf_status[pingpong_hw->buf_active_index]) { - buf_p = &pingpong_hw->buf[pingpong_hw->buf_active_index]; - pingpong_hw->buf_status[pingpong_hw->buf_active_index] = 0; - } - - pingpong_hw->buf_active_index = !pingpong_hw->buf_active_index; - - return (void *) buf_p; -} - -void *msm_gemini_hw_pingpong_active_buffer( - struct msm_gemini_hw_pingpong *pingpong_hw) -{ - struct msm_gemini_hw_buf *buf_p = NULL; - - if (pingpong_hw->buf_status[pingpong_hw->buf_active_index]) - buf_p = &pingpong_hw->buf[pingpong_hw->buf_active_index]; - - return (void *) buf_p; -} - -struct msm_gemini_hw_cmd hw_cmd_irq_get_status[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_READ, 1, HWIO_JPEG_IRQ_STATUS_ADDR, - HWIO_JPEG_IRQ_STATUS_RMSK, {0} }, -}; - -int msm_gemini_hw_irq_get_status(void) -{ - uint32_t n_irq_status = 0; - n_irq_status = msm_gemini_hw_read(&hw_cmd_irq_get_status[0]); - return n_irq_status; -} - -struct msm_gemini_hw_cmd hw_cmd_encode_output_size[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_READ, 1, - HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_ADDR, - HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_RMSK, {0} }, -}; - -long msm_gemini_hw_encode_output_size(void) -{ - long encode_output_size; - - encode_output_size = msm_gemini_hw_read(&hw_cmd_encode_output_size[0]); - - return encode_output_size; -} - -struct msm_gemini_hw_cmd hw_cmd_irq_clear[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_CLEAR_ADDR, - HWIO_JPEG_IRQ_CLEAR_RMSK, {JPEG_IRQ_CLEAR_ALL} }, -}; - -void msm_gemini_hw_irq_clear(uint32_t mask, uint32_t data) -{ - GMN_DBG("%s:%d] mask %0x data %0x", __func__, __LINE__, mask, data); - hw_cmd_irq_clear[0].mask = mask; - hw_cmd_irq_clear[0].data = data; - msm_gemini_hw_write(&hw_cmd_irq_clear[0]); -} - -struct msm_gemini_hw_cmd hw_cmd_fe_ping_update[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_BUFFER_CFG_ADDR, - HWIO_JPEG_FE_BUFFER_CFG_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_Y_PING_ADDR_ADDR, - HWIO_JPEG_FE_Y_PING_ADDR_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CBCR_PING_ADDR_ADDR, - HWIO_JPEG_FE_CBCR_PING_ADDR_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CMD_ADDR, - HWIO_JPEG_FE_CMD_RMSK, {JPEG_FE_CMD_BUFFERRELOAD} }, -}; - -struct msm_gemini_hw_cmd hw_cmd_fe_pong_update[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_BUFFER_CFG_ADDR, - HWIO_JPEG_FE_BUFFER_CFG_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_Y_PONG_ADDR_ADDR, - HWIO_JPEG_FE_Y_PONG_ADDR_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CBCR_PONG_ADDR_ADDR, - HWIO_JPEG_FE_CBCR_PONG_ADDR_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CMD_ADDR, - HWIO_JPEG_FE_CMD_RMSK, {JPEG_FE_CMD_BUFFERRELOAD} }, -}; - -void msm_gemini_hw_fe_buffer_update(struct msm_gemini_hw_buf *p_input, - uint8_t pingpong_index) -{ - uint32_t n_reg_val = 0; - - struct msm_gemini_hw_cmd *hw_cmd_p; - - if (pingpong_index == 0) { - hw_cmd_p = &hw_cmd_fe_ping_update[0]; - n_reg_val = ((((p_input->num_of_mcu_rows - 1) << - HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_SHFT) & - HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_BMSK) | - (((p_input->num_of_mcu_rows - 1) << - HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_SHFT) & - HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_BMSK)); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - n_reg_val = ((p_input->y_buffer_addr << - HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_SHFT) & - HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_BMSK); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - n_reg_val = ((p_input->cbcr_buffer_addr<< - HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_SHFT) & - HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_BMSK); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - msm_gemini_hw_write(hw_cmd_p); - } else if (pingpong_index == 1) { - hw_cmd_p = &hw_cmd_fe_pong_update[0]; - n_reg_val = ((((p_input->num_of_mcu_rows - 1) << - HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_SHFT) & - HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_BMSK) | - (((p_input->num_of_mcu_rows - 1) << - HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_SHFT) & - HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_BMSK)); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - n_reg_val = ((p_input->y_buffer_addr << - HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_SHFT) & - HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_BMSK); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - n_reg_val = ((p_input->cbcr_buffer_addr<< - HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_SHFT) & - HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_BMSK); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - msm_gemini_hw_write(hw_cmd_p); - } else { - /* shall not get to here */ - } - - return; -} - -struct msm_gemini_hw_cmd hw_cmd_fe_start[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CMD_ADDR, - HWIO_JPEG_FE_CMD_RMSK, {JPEG_OFFLINE_CMD_START} }, -}; - -void msm_gemini_hw_fe_start(void) -{ - msm_gemini_hw_write(&hw_cmd_fe_start[0]); - - return; -} - -struct msm_gemini_hw_cmd hw_cmd_we_buffer_cfg[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_THRESHOLD_ADDR, - HWIO_JPEG_WE_Y_THRESHOLD_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_UB_CFG_ADDR, - HWIO_JPEG_WE_Y_UB_CFG_RMSK, {JPEG_WE_YUB_ENCODE} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_CBCR_THRESHOLD_ADDR, - HWIO_JPEG_WE_CBCR_THRESHOLD_RMSK, {0} }, -}; - -/* - * first dimension is WE_ASSERT_STALL_TH and WE_DEASSERT_STALL_TH - * second dimension is for offline and real-time settings - */ -static const uint32_t GEMINI_WE_Y_THRESHOLD[2][2] = { - { 0x00000190, 0x000001ff }, - { 0x0000016a, 0x000001ff } -}; - -/* - * first dimension is WE_ASSERT_STALL_TH and WE_DEASSERT_STALL_TH - * second dimension is for offline and real-time settings - */ -static const uint32_t GEMINI_WE_CBCR_THRESHOLD[2][2] = { - { 0x00000190, 0x000001ff }, - { 0x0000016a, 0x000001ff } -}; - -void msm_gemini_hw_we_buffer_cfg(uint8_t is_realtime) -{ - uint32_t n_reg_val = 0; - - struct msm_gemini_hw_cmd *hw_cmd_p = &hw_cmd_we_buffer_cfg[0]; - - n_reg_val = (((GEMINI_WE_Y_THRESHOLD[1][is_realtime] << - HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT) & - HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK) | - ((GEMINI_WE_Y_THRESHOLD[0][is_realtime] << - HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_SHFT) & - HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_BMSK)); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - msm_gemini_hw_write(hw_cmd_p++); - - /* @todo maybe not for realtime? */ - n_reg_val = (((GEMINI_WE_CBCR_THRESHOLD[1][is_realtime] << - HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT) & - HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK) | - ((GEMINI_WE_CBCR_THRESHOLD[0][is_realtime] << - HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_SHFT) & - HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_BMSK)); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p); - - return; -} - -struct msm_gemini_hw_cmd hw_cmd_we_ping_update[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PING_BUFFER_CFG_ADDR, - HWIO_JPEG_WE_Y_PING_BUFFER_CFG_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PING_ADDR_ADDR, - HWIO_JPEG_WE_Y_PING_ADDR_RMSK, {0} }, -}; - -struct msm_gemini_hw_cmd hw_cmd_we_pong_update[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_ADDR, - HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_RMSK, {0} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PONG_ADDR_ADDR, - HWIO_JPEG_WE_Y_PONG_ADDR_RMSK, {0} }, -}; - -void msm_gemini_hw_we_buffer_update(struct msm_gemini_hw_buf *p_input, - uint8_t pingpong_index) -{ - uint32_t n_reg_val = 0; - - struct msm_gemini_hw_cmd *hw_cmd_p; - - GMN_DBG("%s:%d] pingpong index %d", __func__, __LINE__, - pingpong_index); - if (pingpong_index == 0) { - hw_cmd_p = &hw_cmd_we_ping_update[0]; - - n_reg_val = ((p_input->y_len << - HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT) & - HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - n_reg_val = p_input->y_buffer_addr; - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - } else if (pingpong_index == 1) { - hw_cmd_p = &hw_cmd_we_pong_update[0]; - - n_reg_val = ((p_input->y_len << - HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT) & - HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK); - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - - n_reg_val = p_input->y_buffer_addr; - hw_cmd_p->data = n_reg_val; - msm_gemini_hw_write(hw_cmd_p++); - } else { - /* shall not get to here */ - } - - return; -} - -struct msm_gemini_hw_cmd hw_cmd_reset[] = { - /* type, repeat n times, offset, mask, data or pdata */ - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_MASK_ADDR, - HWIO_JPEG_IRQ_MASK_RMSK, {JPEG_IRQ_DISABLE_ALL} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_CLEAR_ADDR, - HWIO_JPEG_IRQ_MASK_RMSK, {JPEG_IRQ_CLEAR_ALL} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_MASK_ADDR, - HWIO_JPEG_IRQ_MASK_RMSK, {JPEG_IRQ_ALLSOURCES_ENABLE} }, - {MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_RESET_CMD_ADDR, - HWIO_JPEG_RESET_CMD_RMSK, {JPEG_RESET_DEFAULT} }, -}; - -void msm_gemini_hw_init(void *base, int size) -{ - gemini_region_base = base; - gemini_region_size = size; -} - -void msm_gemini_hw_reset(void *base, int size) -{ - struct msm_gemini_hw_cmd *hw_cmd_p; - - hw_cmd_p = &hw_cmd_reset[0]; - - msm_gemini_hw_write(hw_cmd_p++); - msm_gemini_hw_write(hw_cmd_p++); - msm_gemini_hw_write(hw_cmd_p++); - msm_gemini_hw_write(hw_cmd_p); -} - -uint32_t msm_gemini_hw_read(struct msm_gemini_hw_cmd *hw_cmd_p) -{ - uint32_t *paddr; - uint32_t data; - - paddr = gemini_region_base + hw_cmd_p->offset; - - data = readl_relaxed(paddr); - data &= hw_cmd_p->mask; - - GMN_DBG("%s:%d] type-%d n-%d offset-0x%4x mask-0x%8x data-0x%8x\n", - __func__, __LINE__, hw_cmd_p->type, hw_cmd_p->n, - hw_cmd_p->offset, hw_cmd_p->mask, data); - return data; -} - -void msm_gemini_hw_write(struct msm_gemini_hw_cmd *hw_cmd_p) -{ - uint32_t *paddr; - uint32_t old_data, new_data; - - /* type, repeat n times, offset, mask, data or pdata */ - GMN_DBG("%s:%d] type-%d n-%d offset-0x%4x mask-0x%8x data-0x%8x\n", - __func__, __LINE__, hw_cmd_p->type, hw_cmd_p->n, - hw_cmd_p->offset, hw_cmd_p->mask, hw_cmd_p->data); - - paddr = gemini_region_base + hw_cmd_p->offset; - - if (hw_cmd_p->mask == 0xffffffff) { - old_data = 0; - } else { - old_data = readl_relaxed(paddr); - old_data &= ~hw_cmd_p->mask; - } - - new_data = hw_cmd_p->data & hw_cmd_p->mask; - new_data |= old_data; - writel_relaxed(new_data, paddr); -} - -int msm_gemini_hw_wait(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us) -{ - int tm = hw_cmd_p->n; - uint32_t data; - uint32_t wait_data = hw_cmd_p->data & hw_cmd_p->mask; - - data = msm_gemini_hw_read(hw_cmd_p); - if (data != wait_data) { - while (tm) { - udelay(m_us); - data = msm_gemini_hw_read(hw_cmd_p); - if (data == wait_data) - break; - tm--; - } - } - hw_cmd_p->data = data; - return tm; -} - -void msm_gemini_hw_delay(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us) -{ - int tm = hw_cmd_p->n; - while (tm) { - udelay(m_us); - tm--; - } -} - -int msm_gemini_hw_exec_cmds(struct msm_gemini_hw_cmd *hw_cmd_p, uint32_t m_cmds) -{ - int is_copy_to_user = -1; - uint32_t data; - - while (m_cmds--) { - if (hw_cmd_p->offset > gemini_region_size) { - GMN_PR_ERR("%s:%d] %d exceed hw region %d\n", __func__, - __LINE__, hw_cmd_p->offset, gemini_region_size); - return -EFAULT; - } - - switch (hw_cmd_p->type) { - case MSM_GEMINI_HW_CMD_TYPE_READ: - hw_cmd_p->data = msm_gemini_hw_read(hw_cmd_p); - is_copy_to_user = 1; - break; - - case MSM_GEMINI_HW_CMD_TYPE_WRITE: - msm_gemini_hw_write(hw_cmd_p); - break; - - case MSM_GEMINI_HW_CMD_TYPE_WRITE_OR: - data = msm_gemini_hw_read(hw_cmd_p); - hw_cmd_p->data = (hw_cmd_p->data & hw_cmd_p->mask) | - data; - msm_gemini_hw_write(hw_cmd_p); - break; - - case MSM_GEMINI_HW_CMD_TYPE_UWAIT: - msm_gemini_hw_wait(hw_cmd_p, 1); - break; - - case MSM_GEMINI_HW_CMD_TYPE_MWAIT: - msm_gemini_hw_wait(hw_cmd_p, 1000); - break; - - case MSM_GEMINI_HW_CMD_TYPE_UDELAY: - /* Userspace driver provided delay duration */ - msm_gemini_hw_delay(hw_cmd_p, 1); - break; - - case MSM_GEMINI_HW_CMD_TYPE_MDELAY: - /* Userspace driver provided delay duration */ - msm_gemini_hw_delay(hw_cmd_p, 1000); - break; - - default: - GMN_PR_ERR("wrong hw command type\n"); - break; - } - - hw_cmd_p++; - } - return is_copy_to_user; -} - -#ifdef MSM_GMN_DBG_DUMP -void msm_gemini_io_dump(int size) -{ - char line_str[128], *p_str; - void __iomem *addr = gemini_region_base; - int i; - u32 *p = (u32 *) addr; - u32 data; - pr_info("%s: %p %d reg_size %d\n", __func__, addr, size, - gemini_region_size); - line_str[0] = '\0'; - p_str = line_str; - for (i = 0; i < size/4; i++) { - if (i % 4 == 0) { - snprintf(p_str, 12, "%08x: ", (u32) p); - p_str += 10; - } - data = readl_relaxed(p++); - snprintf(p_str, 12, "%08x ", data); - p_str += 9; - if ((i + 1) % 4 == 0) { - pr_info("%s\n", line_str); - line_str[0] = '\0'; - p_str = line_str; - } - } - if (line_str[0] != '\0') - pr_info("%s\n", line_str); -} -#else -void msm_gemini_io_dump(int size) -{ - -} -#endif diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw.h b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw.h deleted file mode 100644 index f4c32a755e21a0e2570406a4bc3da90cbb4a9431..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw.h +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (c) 2010-2013, 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 MSM_GEMINI_HW_H -#define MSM_GEMINI_HW_H - -#include -#include -#include -#include "msm_gemini_hw_reg.h" - -struct msm_gemini_hw_buf { - struct msm_gemini_buf vbuf; - struct file *file; - uint32_t framedone_len; - uint32_t y_buffer_addr; - uint32_t y_len; - uint32_t cbcr_buffer_addr; - uint32_t cbcr_len; - uint32_t num_of_mcu_rows; - struct ion_handle *handle; -}; - -struct msm_gemini_hw_pingpong { - uint8_t is_fe; /* 1: fe; 0: we */ - struct msm_gemini_hw_buf buf[2]; - int buf_status[2]; - int buf_active_index; -}; - -int msm_gemini_hw_pingpong_update(struct msm_gemini_hw_pingpong *pingpong_hw, - struct msm_gemini_hw_buf *buf); -void *msm_gemini_hw_pingpong_irq(struct msm_gemini_hw_pingpong *pingpong_hw); -void *msm_gemini_hw_pingpong_active_buffer(struct msm_gemini_hw_pingpong - *pingpong_hw); - -void msm_gemini_hw_irq_clear(uint32_t, uint32_t); -int msm_gemini_hw_irq_get_status(void); -long msm_gemini_hw_encode_output_size(void); -#define MSM_GEMINI_HW_MASK_COMP_FRAMEDONE \ - MSM_GEMINI_HW_IRQ_STATUS_FRAMEDONE_MASK -#define MSM_GEMINI_HW_MASK_COMP_FE \ - MSM_GEMINI_HW_IRQ_STATUS_FE_RD_DONE_MASK -#define MSM_GEMINI_HW_MASK_COMP_WE \ - (MSM_GEMINI_HW_IRQ_STATUS_WE_Y_PINGPONG_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_PINGPONG_MASK) -#define MSM_GEMINI_HW_MASK_COMP_RESET_ACK \ - MSM_GEMINI_HW_IRQ_STATUS_RESET_ACK_MASK -#define MSM_GEMINI_HW_MASK_COMP_ERR \ - (MSM_GEMINI_HW_IRQ_STATUS_FE_RTOVF_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_FE_VFE_OVERFLOW_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_WE_Y_BUFFER_OVERFLOW_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_BUFFER_OVERFLOW_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_WE_CH0_DATAFIFO_OVERFLOW_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_WE_CH1_DATAFIFO_OVERFLOW_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_BUS_ERROR_MASK | \ - MSM_GEMINI_HW_IRQ_STATUS_VIOLATION_MASK) - -#define msm_gemini_hw_irq_is_frame_done(gemini_irq_status) \ - (gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_FRAMEDONE) -#define msm_gemini_hw_irq_is_fe_pingpong(gemini_irq_status) \ - (gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_FE) -#define msm_gemini_hw_irq_is_we_pingpong(gemini_irq_status) \ - (gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_WE) -#define msm_gemini_hw_irq_is_reset_ack(gemini_irq_status) \ - (gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_RESET_ACK) -#define msm_gemini_hw_irq_is_err(gemini_irq_status) \ - (gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_ERR) - -void msm_gemini_hw_fe_buffer_update(struct msm_gemini_hw_buf *p_input, - uint8_t pingpong_index); -void msm_gemini_hw_we_buffer_update(struct msm_gemini_hw_buf *p_input, - uint8_t pingpong_index); - -void msm_gemini_hw_we_buffer_cfg(uint8_t is_realtime); - -void msm_gemini_hw_fe_start(void); -void msm_gemini_hw_clk_cfg(void); - -void msm_gemini_hw_reset(void *base, int size); -void msm_gemini_hw_irq_cfg(void); -void msm_gemini_hw_init(void *base, int size); - -uint32_t msm_gemini_hw_read(struct msm_gemini_hw_cmd *hw_cmd_p); -void msm_gemini_hw_write(struct msm_gemini_hw_cmd *hw_cmd_p); -int msm_gemini_hw_wait(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us); -void msm_gemini_hw_delay(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us); -int msm_gemini_hw_exec_cmds(struct msm_gemini_hw_cmd *hw_cmd_p, - uint32_t m_cmds); -void msm_gemini_io_dump(int size); - -#define MSM_GEMINI_PIPELINE_CLK_128MHZ 128 /* 8MP 128MHz */ -#define MSM_GEMINI_PIPELINE_CLK_140MHZ 140 /* 9MP 140MHz */ -#define MSM_GEMINI_PIPELINE_CLK_200MHZ 153 /* 12MP 153MHz */ - -#endif /* MSM_GEMINI_HW_H */ diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw_reg.h b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw_reg.h deleted file mode 100644 index 4f056508430948d9025a387e2a8f2eaf9d9a37e7..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_hw_reg.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Copyright (c) 2010,2013, 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 MSM_GEMINI_HW_REG_H -#define MSM_GEMINI_HW_REG_H - -#define GEMINI_REG_BASE 0 - -#define MSM_GEMINI_HW_IRQ_MASK_ADDR 0x00000014 -#define MSM_GEMINI_HW_IRQ_MASK_RMSK 0xffffffff -#define MSM_GEMINI_HW_IRQ_MASK_SHFT 0 -#define MSM_GEMINI_HW_IRQ_DISABLE 0 -#define MSM_GEMINI_HW_IRQ_ENABLE 0xffffffff - -#define MSM_GEMINI_HW_IRQ_CLEAR_ADDR 0x00000018 -#define MSM_GEMINI_HW_IRQ_CLEAR_RMSK 0xffffffff -#define MSM_GEMINI_HW_IRQ_CLEAR_SHFT 0 -#define MSM_GEMINI_HW_IRQ_CLEAR 0xffffffff - -#define MSM_GEMINI_HW_IRQ_STATUS_FRAMEDONE_MASK 0x00000001 -#define MSM_GEMINI_HW_IRQ_STATUS_FRAMEDONE_SHIFT 0x00000000 - -#define MSM_GEMINI_HW_IRQ_STATUS_FE_RD_DONE_MASK 0x00000002 -#define MSM_GEMINI_HW_IRQ_STATUS_FE_RD_DONE_SHIFT 0x00000001 - -#define MSM_GEMINI_HW_IRQ_STATUS_FE_RTOVF_MASK 0x00000004 -#define MSM_GEMINI_HW_IRQ_STATUS_FE_RTOVF_SHIFT 0x00000002 - -#define MSM_GEMINI_HW_IRQ_STATUS_FE_VFE_OVERFLOW_MASK 0x00000008 -#define MSM_GEMINI_HW_IRQ_STATUS_FE_VFE_OVERFLOW_SHIFT 0x00000003 - -#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_PINGPONG_MASK 0x00000010 -#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_PINGPONG_SHIFT 0x00000004 - -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_PINGPONG_MASK 0x00000020 -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_PINGPONG_SHIFT 0x00000005 - -#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_BUFFER_OVERFLOW_MASK 0x00000040 -#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_BUFFER_OVERFLOW_SHIFT 0x00000006 - -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_BUFFER_OVERFLOW_MASK 0x00000080 -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_BUFFER_OVERFLOW_SHIFT 0x00000007 - -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH0_DATAFIFO_OVERFLOW_MASK 0x00000100 -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH0_DATAFIFO_OVERFLOW_SHIFT 0x00000008 - -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH1_DATAFIFO_OVERFLOW_MASK 0x00000200 -#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH1_DATAFIFO_OVERFLOW_SHIFT 0x00000009 - -#define MSM_GEMINI_HW_IRQ_STATUS_RESET_ACK_MASK 0x00000400 -#define MSM_GEMINI_HW_IRQ_STATUS_RESET_ACK_SHIFT 0x0000000a - -#define MSM_GEMINI_HW_IRQ_STATUS_BUS_ERROR_MASK 0x00000800 -#define MSM_GEMINI_HW_IRQ_STATUS_BUS_ERROR_SHIFT 0x0000000b - -#define MSM_GEMINI_HW_IRQ_STATUS_VIOLATION_MASK 0x00001000 -#define MSM_GEMINI_HW_IRQ_STATUS_VIOLATION_SHIFT 0x0000000c - -#define JPEG_BUS_CMD_HALT_REQ 0x00000001 - -#define JPEG_REALTIME_CMD_STOP_FB 0x00000000 -#define JPEG_REALTIME_CMD_STOP_IM 0x00000003 -#define JPEG_REALTIME_CMD_START 0x00000001 - -#define JPEG_OFFLINE_CMD_START 0x00000003 - -#define JPEG_DMI_CFG_DISABLE 0x00000000 -#define JPEG_DMI_ADDR_START 0x00000000 - -#define JPEG_FE_CMD_BUFFERRELOAD 0x00000001 - -#define JPEG_WE_YUB_ENCODE 0x01ff0000 - -#define JPEG_RESET_DEFAULT 0x0004ffff /* cfff? */ - -#define JPEG_IRQ_DISABLE_ALL 0x00000000 -#define JPEG_IRQ_CLEAR_ALL 0xffffffff -#define JPEG_IRQ_ALLSOURCES_ENABLE 0xffffffff - -#define HWIO_JPEG_FE_BUFFER_CFG_ADDR (GEMINI_REG_BASE + 0x00000080) -#define HWIO_JPEG_FE_BUFFER_CFG_RMSK 0x1fff1fff - -#define HWIO_JPEG_FE_Y_PING_ADDR_ADDR (GEMINI_REG_BASE + 0x00000084) -#define HWIO_JPEG_FE_Y_PING_ADDR_RMSK 0xffffffff - -#define HWIO_JPEG_FE_Y_PONG_ADDR_ADDR (GEMINI_REG_BASE + 0x00000088) -#define HWIO_JPEG_FE_Y_PONG_ADDR_RMSK 0xffffffff - -#define HWIO_JPEG_FE_CBCR_PING_ADDR_ADDR (GEMINI_REG_BASE + 0x0000008c) -#define HWIO_JPEG_FE_CBCR_PING_ADDR_RMSK 0xffffffff - -#define HWIO_JPEG_FE_CBCR_PONG_ADDR_ADDR (GEMINI_REG_BASE + 0x00000090) -#define HWIO_JPEG_FE_CBCR_PONG_ADDR_RMSK 0xffffffff - -#define HWIO_JPEG_FE_CMD_ADDR (GEMINI_REG_BASE + 0x00000094) -#define HWIO_JPEG_FE_CMD_RMSK 0x3 - -#define HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_BMSK 0x1fff0000 -#define HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_SHFT 0x10 -#define HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_BMSK 0x1fff -#define HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_SHFT 0 - -#define HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_BMSK 0xffffffff -#define HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_SHFT 0 - -#define HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_BMSK 0xffffffff -#define HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_SHFT 0 - -#define HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_BMSK 0xffffffff -#define HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_SHFT 0 - -#define HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_BMSK 0xffffffff -#define HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_SHFT 0 - -#define HWIO_JPEG_WE_Y_THRESHOLD_ADDR (GEMINI_REG_BASE + 0x000000c0) -#define HWIO_JPEG_WE_Y_THRESHOLD_RMSK 0x1ff01ff - -#define HWIO_JPEG_WE_CBCR_THRESHOLD_ADDR (GEMINI_REG_BASE + 0x000000c4) -#define HWIO_JPEG_WE_CBCR_THRESHOLD_RMSK 0x1ff01ff - -#define HWIO_JPEG_WE_Y_UB_CFG_ADDR (GEMINI_REG_BASE + 0x000000e8) -#define HWIO_JPEG_WE_Y_UB_CFG_RMSK 0x1ff01ff - -#define HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK 0x1ff0000 -#define HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT 0x10 -#define HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_BMSK 0x1ff -#define HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_SHFT 0 - -#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK 0x1ff0000 -#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT 0x10 -#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_BMSK 0x1ff -#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_SHFT 0 - -#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_ADDR (GEMINI_REG_BASE + 0x000000c8) -#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_RMSK 0x7fffff - -#define HWIO_JPEG_WE_Y_PING_ADDR_ADDR (GEMINI_REG_BASE + 0x000000d8) -#define HWIO_JPEG_WE_Y_PING_ADDR_RMSK 0xfffffff8 - -#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_ADDR (GEMINI_REG_BASE + 0x000000cc) -#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_RMSK 0x7fffff - -#define HWIO_JPEG_WE_Y_PONG_ADDR_ADDR (GEMINI_REG_BASE + 0x000000dc) -#define HWIO_JPEG_WE_Y_PONG_ADDR_RMSK 0xfffffff8 - -#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK 0x7fffff -#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT 0 - -#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK 0x7fffff -#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT 0 - -#define HWIO_JPEG_IRQ_MASK_ADDR (GEMINI_REG_BASE + 0x00000014) -#define HWIO_JPEG_IRQ_MASK_RMSK 0xffffffff - -#define HWIO_JPEG_IRQ_CLEAR_ADDR (GEMINI_REG_BASE + 0x00000018) -#define HWIO_JPEG_IRQ_CLEAR_RMSK 0xffffffff - -#define HWIO_JPEG_RESET_CMD_ADDR (GEMINI_REG_BASE + 0x00000004) -#define HWIO_JPEG_RESET_CMD_RMSK 0xe004ffff - -#define HWIO_JPEG_IRQ_STATUS_ADDR (GEMINI_REG_BASE + 0x0000001c) -#define HWIO_JPEG_IRQ_STATUS_RMSK 0xffffffff - -#define HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_ADDR (GEMINI_REG_BASE + 0x00000034) -#define HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_RMSK 0xffffffff - -#endif /* MSM_GEMINI_HW_REG_H */ diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_platform.c b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_platform.c deleted file mode 100644 index f442068b862df203dbd016b9e3a5ffa267c363ee..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_platform.c +++ /dev/null @@ -1,283 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include "msm_gemini_platform.h" -#include "msm_gemini_sync.h" -#include "msm_gemini_common.h" -#include "msm_gemini_hw.h" -#include "msm_camera_io_util.h" - -/* AXI rate in KHz */ -#define MSM_SYSTEM_BUS_RATE 160000 -struct ion_client *gemini_client; - - -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION -void msm_gemini_platform_p2v(struct file *file, - struct ion_handle **ionhandle) -{ - ion_unmap_iommu(gemini_client, *ionhandle, CAMERA_DOMAIN, GEN_POOL); - ion_free(gemini_client, *ionhandle); - *ionhandle = NULL; -} -#else -void msm_gemini_platform_p2v(struct file *file, - struct ion_handle **ionhandle) -{ - -} -#endif - - -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION -uint32_t msm_gemini_platform_v2p(int fd, uint32_t len, struct file **file_p, - struct ion_handle **ionhandle) -{ - unsigned long paddr; - unsigned long size; - int rc; - - *ionhandle = ion_import_dma_buf(gemini_client, fd); - if (IS_ERR_OR_NULL(*ionhandle)) - return 0; - - rc = ion_map_iommu(gemini_client, *ionhandle, CAMERA_DOMAIN, GEN_POOL, - SZ_4K, 0, &paddr, (unsigned long *)&size, 0, 0); - if (rc < 0) { - GMN_PR_ERR("%s: get_pmem_file fd %d error %d\n", __func__, fd, - rc); - goto error1; - } - /* validate user input */ - if (len > size) { - GMN_PR_ERR("%s: invalid offset + len\n", __func__); - goto error1; - } - - return paddr; -error1: - ion_free(gemini_client, *ionhandle); - - return 0; -} -#else -uint32_t msm_gemini_platform_v2p(int fd, uint32_t len, struct file **file_p, - struct ion_handle **ionhandle) -{ - return 0; -} -#endif - -static struct msm_cam_clk_info gemini_8x_clk_info[] = { - {"core_clk", 228571000, 0}, - {"iface_clk", -1, 0}, -}; - -static struct msm_cam_clk_info gemini_7x_clk_info[] = { - {"core_clk", 153600000, 0}, - {"iface_clk", -1, 0}, -}; - -static struct msm_cam_clk_info gemini_imem_clk_info[] = { - {"mem_clk", -1, 0}, -}; - -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION -static struct ion_client *msm_gemini_ion_client_create(unsigned int heap_mask, - const char *name) -{ - return msm_ion_client_create(heap_mask, name); -} -#else -static struct ion_client *msm_gemini_ion_client_create(unsigned int heap_mask, - const char *name) -{ - return NULL; -} -#endif - -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION -void msm_gemini_ion_client_destroy(struct ion_client *client) -{ - ion_client_destroy(client); -} -#else -void msm_gemini_ion_client_destroy(struct ion_client *client) -{ - -} -#endif - -int msm_gemini_platform_init(struct platform_device *pdev, - struct resource **mem, - void **base, - int *irq, - irqreturn_t (*handler) (int, void *), - void *context) -{ - int rc = -1; - int gemini_irq; - struct resource *gemini_mem, *gemini_io, *gemini_irq_res; - void *gemini_base; - struct msm_gemini_device *pgmn_dev = - (struct msm_gemini_device *) context; - - gemini_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!gemini_mem) { - GMN_PR_ERR("%s: no mem resource!\n", __func__); - return -ENODEV; - } - - gemini_irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!gemini_irq_res) { - GMN_PR_ERR("no irq resource!\n"); - return -ENODEV; - } - gemini_irq = gemini_irq_res->start; - - gemini_io = request_mem_region(gemini_mem->start, - resource_size(gemini_mem), pdev->name); - if (!gemini_io) { - GMN_PR_ERR("%s: region already claimed\n", __func__); - return -EBUSY; - } - - gemini_base = ioremap(gemini_mem->start, resource_size(gemini_mem)); - if (!gemini_base) { - rc = -ENOMEM; - GMN_PR_ERR("%s: ioremap failed\n", __func__); - goto fail1; - } - pgmn_dev->hw_version = GEMINI_8X60; - rc = msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_8x_clk_info, - pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_8x_clk_info), 1); - if (rc < 0) { - pgmn_dev->hw_version = GEMINI_7X; - rc = msm_cam_clk_enable(&pgmn_dev->pdev->dev, - gemini_7x_clk_info, pgmn_dev->gemini_clk, - ARRAY_SIZE(gemini_7x_clk_info), 1); - if (rc < 0) { - GMN_PR_ERR("%s: clk failed rc = %d\n", __func__, rc); - goto fail2; - } - } else { - rc = msm_cam_clk_enable(&pgmn_dev->pdev->dev, - gemini_imem_clk_info, &pgmn_dev->gemini_clk[2], - ARRAY_SIZE(gemini_imem_clk_info), 1); - if (!rc) - pgmn_dev->hw_version = GEMINI_8960; - } - - if (pgmn_dev->hw_version != GEMINI_7X) { - if (pgmn_dev->gemini_fs == NULL) { - pgmn_dev->gemini_fs = - regulator_get(&pgmn_dev->pdev->dev, "vdd"); - if (IS_ERR(pgmn_dev->gemini_fs)) { - GMN_PR_ERR("%s: regulator_get failed %ld\n", - __func__, PTR_ERR(pgmn_dev->gemini_fs)); - pgmn_dev->gemini_fs = NULL; - goto gemini_fs_failed; - } else if (regulator_enable(pgmn_dev->gemini_fs)) { - GMN_PR_ERR("%s: regulator_enable failed\n", - __func__); - regulator_put(pgmn_dev->gemini_fs); - pgmn_dev->gemini_fs = NULL; - goto gemini_fs_failed; - } - } - } - - msm_gemini_hw_init(gemini_base, resource_size(gemini_mem)); - rc = request_irq(gemini_irq, handler, IRQF_TRIGGER_RISING, "gemini", - context); - if (rc) { - GMN_PR_ERR("%s: request_irq failed, %d\n", __func__, - gemini_irq); - goto fail3; - } - - *mem = gemini_mem; - *base = gemini_base; - *irq = gemini_irq; - - gemini_client = msm_gemini_ion_client_create(-1, "camera/gemini"); - - GMN_DBG("%s:%d] success\n", __func__, __LINE__); - - return rc; - -fail3: - if (pgmn_dev->hw_version != GEMINI_7X) { - regulator_disable(pgmn_dev->gemini_fs); - regulator_put(pgmn_dev->gemini_fs); - pgmn_dev->gemini_fs = NULL; - } -gemini_fs_failed: - if (pgmn_dev->hw_version == GEMINI_8960) - msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_imem_clk_info, - &pgmn_dev->gemini_clk[2], ARRAY_SIZE(gemini_imem_clk_info), 0); - if (pgmn_dev->hw_version != GEMINI_7X) - msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_8x_clk_info, - pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_8x_clk_info), 0); - else - msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_7x_clk_info, - pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_7x_clk_info), 0); -fail2: - iounmap(gemini_base); -fail1: - release_mem_region(gemini_mem->start, resource_size(gemini_mem)); - GMN_DBG("%s:%d] fail\n", __func__, __LINE__); - return rc; -} - -int msm_gemini_platform_release(struct resource *mem, void *base, int irq, - void *context) -{ - int result = 0; - struct msm_gemini_device *pgmn_dev = - (struct msm_gemini_device *) context; - - free_irq(irq, context); - - if (pgmn_dev->hw_version != GEMINI_7X) { - regulator_disable(pgmn_dev->gemini_fs); - regulator_put(pgmn_dev->gemini_fs); - pgmn_dev->gemini_fs = NULL; - } - - if (pgmn_dev->hw_version == GEMINI_8960) - msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_imem_clk_info, - &pgmn_dev->gemini_clk[2], ARRAY_SIZE(gemini_imem_clk_info), 0); - if (pgmn_dev->hw_version != GEMINI_7X) - msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_8x_clk_info, - pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_8x_clk_info), 0); - else - msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_7x_clk_info, - pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_7x_clk_info), 0); - - iounmap(base); - release_mem_region(mem->start, resource_size(mem)); - - msm_gemini_ion_client_destroy(gemini_client); - - GMN_DBG("%s:%d] success\n", __func__, __LINE__); - return result; -} - diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_platform.h b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_platform.h deleted file mode 100644 index a071df9302dc1ed11950f1dc0eed66164e7e7aa1..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_platform.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2010-2013, 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 MSM_GEMINI_PLATFORM_H -#define MSM_GEMINI_PLATFORM_H - -#include -#include -#include -#include -void msm_gemini_platform_p2v(struct file *file, - struct ion_handle **ionhandle); -uint32_t msm_gemini_platform_v2p(int fd, uint32_t len, struct file **file, - struct ion_handle **ionhandle); - -int msm_gemini_platform_clk_enable(void); -int msm_gemini_platform_clk_disable(void); - -int msm_gemini_platform_init(struct platform_device *pdev, - struct resource **mem, - void **base, - int *irq, - irqreturn_t (*handler) (int, void *), - void *context); -int msm_gemini_platform_release(struct resource *mem, void *base, int irq, - void *context); - -#endif /* MSM_GEMINI_PLATFORM_H */ diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_sync.c b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_sync.c deleted file mode 100644 index ebf8d4bc1ef9fae24c8efbc4746e10f59dec2482..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_sync.c +++ /dev/null @@ -1,1089 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include "msm_gemini_sync.h" -#include "msm_gemini_core.h" -#include "msm_gemini_platform.h" -#include "msm_gemini_common.h" - -#define UINT32_MAX (0xFFFFFFFFU) - -static int release_buf; - -/* size is based on 4k page size */ -static const int g_max_out_size = 0x7ff000; - -/*************** queue helper ****************/ -static inline void msm_gemini_q_init(char const *name, struct msm_gemini_q *q_p) -{ - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, name); - q_p->name = name; - spin_lock_init(&q_p->lck); - INIT_LIST_HEAD(&q_p->q); - init_waitqueue_head(&q_p->wait); - q_p->unblck = 0; -} - -static inline void *msm_gemini_q_out(struct msm_gemini_q *q_p) -{ - unsigned long flags; - struct msm_gemini_q_entry *q_entry_p = NULL; - void *data = NULL; - - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - spin_lock_irqsave(&q_p->lck, flags); - if (!list_empty(&q_p->q)) { - q_entry_p = list_first_entry(&q_p->q, struct msm_gemini_q_entry, - list); - list_del_init(&q_entry_p->list); - } - spin_unlock_irqrestore(&q_p->lck, flags); - - if (q_entry_p) { - data = q_entry_p->data; - kfree(q_entry_p); - } else { - GMN_DBG("%s:%d] %s no entry\n", __func__, __LINE__, - q_p->name); - } - - return data; -} - -static inline int msm_gemini_q_in(struct msm_gemini_q *q_p, void *data) -{ - unsigned long flags; - - struct msm_gemini_q_entry *q_entry_p; - - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - - q_entry_p = kmalloc(sizeof(struct msm_gemini_q_entry), GFP_ATOMIC); - if (!q_entry_p) { - GMN_PR_ERR("%s: no mem\n", __func__); - return -ENOMEM; - } - q_entry_p->data = data; - - spin_lock_irqsave(&q_p->lck, flags); - list_add_tail(&q_entry_p->list, &q_p->q); - spin_unlock_irqrestore(&q_p->lck, flags); - - return 0; -} - -static inline int msm_gemini_q_in_buf(struct msm_gemini_q *q_p, - struct msm_gemini_core_buf *buf) -{ - struct msm_gemini_core_buf *buf_p; - - GMN_DBG("%s:%d]\n", __func__, __LINE__); - buf_p = kmalloc(sizeof(struct msm_gemini_core_buf), GFP_ATOMIC); - if (!buf_p) { - GMN_PR_ERR("%s: no mem\n", __func__); - return -ENOMEM; - } - - memcpy(buf_p, buf, sizeof(struct msm_gemini_core_buf)); - - msm_gemini_q_in(q_p, buf_p); - return 0; -} - -static inline int msm_gemini_q_wait(struct msm_gemini_q *q_p) -{ - int tm = MAX_SCHEDULE_TIMEOUT; - int rc; - - GMN_DBG("%s:%d] %s wait\n", __func__, __LINE__, q_p->name); - rc = wait_event_interruptible_timeout(q_p->wait, - (!list_empty_careful(&q_p->q) || q_p->unblck), - msecs_to_jiffies(tm)); - GMN_DBG("%s:%d] %s wait done\n", __func__, __LINE__, q_p->name); - if (list_empty_careful(&q_p->q)) { - if (rc == 0) { - rc = -ETIMEDOUT; - GMN_PR_ERR("%s:%d] %s timeout\n", __func__, __LINE__, - q_p->name); - } else if (q_p->unblck) { - GMN_DBG("%s:%d] %s unblock is true\n", __func__, - __LINE__, q_p->name); - q_p->unblck = 0; - rc = -ECANCELED; - } else if (rc < 0) { - GMN_PR_ERR("%s:%d] %s rc %d\n", __func__, __LINE__, - q_p->name, rc); - } - } - return rc; -} - -static inline int msm_gemini_q_wakeup(struct msm_gemini_q *q_p) -{ - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - wake_up(&q_p->wait); - return 0; -} - -static inline int msm_gemini_q_unblock(struct msm_gemini_q *q_p) -{ - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - q_p->unblck = 1; - wake_up(&q_p->wait); - return 0; -} - -static inline void msm_gemini_outbuf_q_cleanup(struct msm_gemini_q *q_p) -{ - struct msm_gemini_core_buf *buf_p; - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - do { - buf_p = msm_gemini_q_out(q_p); - if (buf_p) { - msm_gemini_platform_p2v(buf_p->file, - &buf_p->handle); - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - kfree(buf_p); - } - } while (buf_p); - q_p->unblck = 0; -} - -static inline void msm_gemini_q_cleanup(struct msm_gemini_q *q_p) -{ - void *data; - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - do { - data = msm_gemini_q_out(q_p); - if (data) { - GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name); - kfree(data); - } - } while (data); - q_p->unblck = 0; -} - -/*************** event queue ****************/ - -int msm_gemini_framedone_irq(struct msm_gemini_device *pgmn_dev, - struct msm_gemini_core_buf *buf_in) -{ - int rc = 0; - - GMN_DBG("%s:%d] buf_in %p", __func__, __LINE__, buf_in); - - if (buf_in) { - buf_in->vbuf.framedone_len = buf_in->framedone_len; - buf_in->vbuf.type = MSM_GEMINI_EVT_FRAMEDONE; - GMN_DBG("%s:%d] 0x%08x %d framedone_len %d\n", - __func__, __LINE__, - (int) buf_in->y_buffer_addr, buf_in->y_len, - buf_in->vbuf.framedone_len); - rc = msm_gemini_q_in_buf(&pgmn_dev->evt_q, buf_in); - } else { - GMN_DBG("%s:%d] no output return buffer\n", - __func__, __LINE__); - rc = -1; - } - - if (buf_in) - rc = msm_gemini_q_wakeup(&pgmn_dev->evt_q); - - return rc; -} - -int msm_gemini_evt_get(struct msm_gemini_device *pgmn_dev, - void __user *to) -{ - struct msm_gemini_core_buf *buf_p; - struct msm_gemini_ctrl_cmd ctrl_cmd; - - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - - msm_gemini_q_wait(&pgmn_dev->evt_q); - buf_p = msm_gemini_q_out(&pgmn_dev->evt_q); - - if (!buf_p) { - GMN_DBG("%s:%d] no buffer\n", __func__, __LINE__); - return -EAGAIN; - } - - memset(&ctrl_cmd, 0, sizeof(struct msm_gemini_ctrl_cmd)); - ctrl_cmd.type = buf_p->vbuf.type; - kfree(buf_p); - - GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, - (int) ctrl_cmd.value, ctrl_cmd.len); - - if (copy_to_user(to, &ctrl_cmd, sizeof(ctrl_cmd))) { - GMN_PR_ERR("%s:%d]\n", __func__, __LINE__); - return -EFAULT; - } - - return 0; -} - -int msm_gemini_evt_get_unblock(struct msm_gemini_device *pgmn_dev) -{ - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - msm_gemini_q_unblock(&pgmn_dev->evt_q); - return 0; -} - -void msm_gemini_reset_ack_irq(struct msm_gemini_device *pgmn_dev) -{ - GMN_DBG("%s:%d]\n", __func__, __LINE__); -} - -void msm_gemini_err_irq(struct msm_gemini_device *pgmn_dev, - int event) -{ - int rc = 0; - struct msm_gemini_core_buf buf; - - GMN_DBG("%s:%d] error: %d\n", __func__, __LINE__, event); - - buf.vbuf.type = MSM_GEMINI_EVT_ERR; - rc = msm_gemini_q_in_buf(&pgmn_dev->evt_q, &buf); - if (!rc) - rc = msm_gemini_q_wakeup(&pgmn_dev->evt_q); - - if (!rc) - GMN_PR_ERR("%s:%d] err err\n", __func__, __LINE__); - - return; -} - -/*************** output queue ****************/ - -int msm_gemini_get_out_buffer(struct msm_gemini_device *pgmn_dev, - struct msm_gemini_hw_buf *p_outbuf) -{ - int buf_size = 0; - int bytes_remaining = 0; - if (pgmn_dev->out_offset >= pgmn_dev->out_buf.y_len) { - GMN_PR_ERR("%s:%d] no more buffers", __func__, __LINE__); - return -EINVAL; - } - bytes_remaining = pgmn_dev->out_buf.y_len - pgmn_dev->out_offset; - buf_size = min(bytes_remaining, pgmn_dev->max_out_size); - - pgmn_dev->out_frag_cnt++; - GMN_DBG("%s:%d] buf_size[%d] %d", __func__, __LINE__, - pgmn_dev->out_frag_cnt, buf_size); - p_outbuf->y_len = buf_size; - p_outbuf->y_buffer_addr = pgmn_dev->out_buf.y_buffer_addr + - pgmn_dev->out_offset; - pgmn_dev->out_offset += buf_size; - return 0; -} - -int msm_gemini_outmode_single_we_pingpong_irq( - struct msm_gemini_device *pgmn_dev, - struct msm_gemini_core_buf *buf_in) -{ - int rc = 0; - struct msm_gemini_core_buf out_buf; - int frame_done = buf_in && - buf_in->vbuf.type == MSM_GEMINI_EVT_FRAMEDONE; - GMN_DBG("%s:%d] framedone %d", __func__, __LINE__, frame_done); - if (!pgmn_dev->out_buf_set) { - GMN_PR_ERR("%s:%d] output buffer not set", - __func__, __LINE__); - return -EFAULT; - } - if (frame_done) { - /* send the buffer back */ - pgmn_dev->out_buf.vbuf.framedone_len = buf_in->framedone_len; - pgmn_dev->out_buf.vbuf.type = MSM_GEMINI_EVT_FRAMEDONE; - rc = msm_gemini_q_in_buf(&pgmn_dev->output_rtn_q, - &pgmn_dev->out_buf); - if (rc) { - GMN_PR_ERR("%s:%d] cannot queue the output buffer", - __func__, __LINE__); - return -EFAULT; - } - rc = msm_gemini_q_wakeup(&pgmn_dev->output_rtn_q); - /* - * reset the output buffer since the ownership is - * transferred to the rtn queue - */ - if (!rc) - pgmn_dev->out_buf_set = 0; - } else { - /* configure ping/pong */ - rc = msm_gemini_get_out_buffer(pgmn_dev, &out_buf); - if (rc) - msm_gemini_core_we_buf_reset(&out_buf); - else - msm_gemini_core_we_buf_update(&out_buf); - } - return rc; -} - -int msm_gemini_we_pingpong_irq(struct msm_gemini_device *pgmn_dev, - struct msm_gemini_core_buf *buf_in) -{ - int rc = 0; - struct msm_gemini_core_buf *buf_out; - - GMN_DBG("%s:%d] Enter mode %d", __func__, __LINE__, - pgmn_dev->out_mode); - - if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_SINGLE) - return msm_gemini_outmode_single_we_pingpong_irq(pgmn_dev, - buf_in); - - if (buf_in) { - GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, - (int) buf_in->y_buffer_addr, buf_in->y_len); - rc = msm_gemini_q_in_buf(&pgmn_dev->output_rtn_q, buf_in); - } else { - GMN_DBG("%s:%d] no output return buffer\n", __func__, - __LINE__); - rc = -1; - return rc; - } - - buf_out = msm_gemini_q_out(&pgmn_dev->output_buf_q); - - if (buf_out) { - rc = msm_gemini_core_we_buf_update(buf_out); - kfree(buf_out); - } else { - msm_gemini_core_we_buf_reset(buf_in); - GMN_DBG("%s:%d] no output buffer\n", __func__, __LINE__); - rc = -2; - } - - if (buf_in) - rc = msm_gemini_q_wakeup(&pgmn_dev->output_rtn_q); - - return rc; -} - -int msm_gemini_output_get(struct msm_gemini_device *pgmn_dev, void __user *to) -{ - struct msm_gemini_core_buf *buf_p; - struct msm_gemini_buf buf_cmd; - - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - - msm_gemini_q_wait(&pgmn_dev->output_rtn_q); - buf_p = msm_gemini_q_out(&pgmn_dev->output_rtn_q); - - if (!buf_p) { - GMN_DBG("%s:%d] no output buffer return\n", - __func__, __LINE__); - return -EAGAIN; - } - - buf_cmd = buf_p->vbuf; - msm_gemini_platform_p2v(buf_p->file, &buf_p->handle); - kfree(buf_p); - - GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, - (int) buf_cmd.vaddr, buf_cmd.y_len); - - if (copy_to_user(to, &buf_cmd, sizeof(buf_cmd))) { - GMN_PR_ERR("%s:%d]", __func__, __LINE__); - return -EFAULT; - } - - return 0; -} - -int msm_gemini_output_get_unblock(struct msm_gemini_device *pgmn_dev) -{ - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - msm_gemini_q_unblock(&pgmn_dev->output_rtn_q); - return 0; -} - -int msm_gemini_set_output_buf(struct msm_gemini_device *pgmn_dev, - void __user *arg) -{ - struct msm_gemini_buf buf_cmd; - - if (pgmn_dev->out_buf_set) { - GMN_PR_ERR("%s:%d] outbuffer buffer already provided", - __func__, __LINE__); - return -EINVAL; - } - - if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_gemini_buf))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - - GMN_DBG("%s:%d] output addr 0x%08x len %d", __func__, __LINE__, - (int) buf_cmd.vaddr, - buf_cmd.y_len); - - pgmn_dev->out_buf.y_buffer_addr = msm_gemini_platform_v2p( - buf_cmd.fd, - buf_cmd.y_len, - &pgmn_dev->out_buf.file, - &pgmn_dev->out_buf.handle); - if (!pgmn_dev->out_buf.y_buffer_addr) { - GMN_PR_ERR("%s:%d] cannot map the output address", - __func__, __LINE__); - return -EFAULT; - } - pgmn_dev->out_buf.y_len = buf_cmd.y_len; - pgmn_dev->out_buf.vbuf = buf_cmd; - pgmn_dev->out_buf_set = 1; - - return 0; -} - -int msm_gemini_output_buf_enqueue(struct msm_gemini_device *pgmn_dev, - void __user *arg) -{ - struct msm_gemini_buf buf_cmd; - struct msm_gemini_core_buf *buf_p; - - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_gemini_buf))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - - buf_p = kmalloc(sizeof(struct msm_gemini_core_buf), GFP_ATOMIC); - if (!buf_p) { - GMN_PR_ERR("%s:%d] no mem\n", __func__, __LINE__); - return -ENOMEM; - } - - GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, (int) buf_cmd.vaddr, - buf_cmd.y_len); - - buf_p->y_buffer_addr = msm_gemini_platform_v2p(buf_cmd.fd, - buf_cmd.y_len, &buf_p->file, &buf_p->handle); - if (!buf_p->y_buffer_addr) { - GMN_PR_ERR("%s:%d] v2p wrong\n", __func__, __LINE__); - kfree(buf_p); - return -ENOMEM; - } - buf_p->y_len = buf_cmd.y_len; - buf_p->vbuf = buf_cmd; - - msm_gemini_q_in(&pgmn_dev->output_buf_q, buf_p); - return 0; -} - -/*************** input queue ****************/ - -int msm_gemini_fe_pingpong_irq(struct msm_gemini_device *pgmn_dev, - struct msm_gemini_core_buf *buf_in) -{ - struct msm_gemini_core_buf *buf_out; - int rc = 0; - - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - if (buf_in) { - GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, - (int) buf_in->y_buffer_addr, buf_in->y_len); - rc = msm_gemini_q_in_buf(&pgmn_dev->input_rtn_q, buf_in); - } else { - GMN_DBG("%s:%d] no input return buffer\n", __func__, - __LINE__); - rc = -1; - } - - buf_out = msm_gemini_q_out(&pgmn_dev->input_buf_q); - - if (buf_out) { - rc = msm_gemini_core_fe_buf_update(buf_out); - kfree(buf_out); - msm_gemini_core_fe_start(); - } else { - GMN_DBG("%s:%d] no input buffer\n", __func__, __LINE__); - rc = -2; - } - - if (buf_in) - rc = msm_gemini_q_wakeup(&pgmn_dev->input_rtn_q); - - return rc; -} - -int msm_gemini_input_get(struct msm_gemini_device *pgmn_dev, void __user *to) -{ - struct msm_gemini_core_buf *buf_p; - struct msm_gemini_buf buf_cmd; - - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - msm_gemini_q_wait(&pgmn_dev->input_rtn_q); - buf_p = msm_gemini_q_out(&pgmn_dev->input_rtn_q); - - if (!buf_p) { - GMN_DBG("%s:%d] no input buffer return\n", - __func__, __LINE__); - return -EAGAIN; - } - - buf_cmd = buf_p->vbuf; - if (pgmn_dev->op_mode == MSM_GEMINI_MODE_OFFLINE_ENCODE || - pgmn_dev->op_mode == MSM_GEMINI_MODE_OFFLINE_ROTATION) { - msm_gemini_platform_p2v(buf_p->file, &buf_p->handle); - } - kfree(buf_p); - - GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, - (int) buf_cmd.vaddr, buf_cmd.y_len); - - if (copy_to_user(to, &buf_cmd, sizeof(buf_cmd))) { - GMN_PR_ERR("%s:%d]\n", __func__, __LINE__); - return -EFAULT; - } - - return 0; -} - -int msm_gemini_input_get_unblock(struct msm_gemini_device *pgmn_dev) -{ - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - msm_gemini_q_unblock(&pgmn_dev->input_rtn_q); - return 0; -} - -int msm_gemini_input_buf_enqueue(struct msm_gemini_device *pgmn_dev, - void __user *arg) -{ - struct msm_gemini_core_buf *buf_p; - struct msm_gemini_buf buf_cmd; - int rc = 0; - struct msm_bus_scale_pdata *p_bus_scale_data = NULL; - - if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_gemini_buf))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - - buf_p = kmalloc(sizeof(struct msm_gemini_core_buf), GFP_ATOMIC); - if (!buf_p) { - GMN_PR_ERR("%s:%d] no mem\n", __func__, __LINE__); - return -EFAULT; - } - - GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, - (int) buf_cmd.vaddr, buf_cmd.y_len); - - if (pgmn_dev->op_mode == MSM_GEMINI_MODE_REALTIME_ENCODE) { - rc = msm_iommu_map_contig_buffer( - (unsigned long)buf_cmd.y_off, CAMERA_DOMAIN, GEN_POOL, - ((buf_cmd.y_len + buf_cmd.cbcr_len + 4095) & (~4095)), - SZ_4K, IOMMU_WRITE | IOMMU_READ, - (unsigned long *)&buf_p->y_buffer_addr); - if (rc < 0) { - GMN_PR_ERR("%s iommu mapping failed with error %d\n", - __func__, rc); - kfree(buf_p); - return rc; - } - } else { - buf_p->y_buffer_addr = msm_gemini_platform_v2p(buf_cmd.fd, - buf_cmd.y_len + buf_cmd.cbcr_len, &buf_p->file, - &buf_p->handle) + buf_cmd.offset + buf_cmd.y_off; - } - buf_p->y_len = buf_cmd.y_len; - - buf_p->cbcr_buffer_addr = buf_p->y_buffer_addr + buf_cmd.y_len + - buf_cmd.cbcr_off; - buf_p->cbcr_len = buf_cmd.cbcr_len; - buf_p->num_of_mcu_rows = buf_cmd.num_of_mcu_rows; - GMN_DBG("%s: y_addr=%x,y_len=%x,cbcr_addr=%x,cbcr_len=%x\n", __func__, - buf_p->y_buffer_addr, buf_p->y_len, buf_p->cbcr_buffer_addr, - buf_p->cbcr_len); - - if (!buf_p->y_buffer_addr || !buf_p->cbcr_buffer_addr) { - GMN_PR_ERR("%s:%d] v2p wrong\n", __func__, __LINE__); - kfree(buf_p); - return -EINVAL; - } - buf_p->vbuf = buf_cmd; - buf_p->vbuf.type = MSM_GEMINI_EVT_RESET; - - /* Set bus vectors */ - p_bus_scale_data = (struct msm_bus_scale_pdata *) - pgmn_dev->pdev->dev.platform_data; - if (pgmn_dev->bus_perf_client && - (MSM_GMN_OUTMODE_SINGLE == pgmn_dev->out_mode)) { - int rc; - struct msm_bus_paths *path = &(p_bus_scale_data->usecase[1]); - GMN_DBG("%s:%d] Update bus bandwidth", __func__, __LINE__); - if (pgmn_dev->op_mode & MSM_GEMINI_MODE_OFFLINE_ENCODE) { - path->vectors[0].ab = (buf_p->y_len + buf_p->cbcr_len) * - 15 * 2; - path->vectors[0].ib = path->vectors[0].ab; - path->vectors[1].ab = 0; - path->vectors[1].ib = 0; - } - rc = msm_bus_scale_client_update_request( - pgmn_dev->bus_perf_client, 1); - if (rc < 0) { - GMN_PR_ERR("%s:%d] update_request fails %d", - __func__, __LINE__, rc); - } - } - - msm_gemini_q_in(&pgmn_dev->input_buf_q, buf_p); - - return 0; -} - -int msm_gemini_irq(int event, void *context, void *data) -{ - struct msm_gemini_device *pgmn_dev = - (struct msm_gemini_device *) context; - - switch (event) { - case MSM_GEMINI_HW_MASK_COMP_FRAMEDONE: - msm_gemini_framedone_irq(pgmn_dev, data); - msm_gemini_we_pingpong_irq(pgmn_dev, data); - break; - - case MSM_GEMINI_HW_MASK_COMP_FE: - msm_gemini_fe_pingpong_irq(pgmn_dev, data); - break; - - case MSM_GEMINI_HW_MASK_COMP_WE: - msm_gemini_we_pingpong_irq(pgmn_dev, data); - break; - - case MSM_GEMINI_HW_MASK_COMP_RESET_ACK: - msm_gemini_reset_ack_irq(pgmn_dev); - break; - - case MSM_GEMINI_HW_MASK_COMP_ERR: - default: - msm_gemini_err_irq(pgmn_dev, event); - break; - } - - return 0; -} - -int __msm_gemini_open(struct msm_gemini_device *pgmn_dev) -{ - int rc; - struct msm_bus_scale_pdata *p_bus_scale_data = - (struct msm_bus_scale_pdata *)pgmn_dev->pdev->dev. - platform_data; - - mutex_lock(&pgmn_dev->lock); - if (pgmn_dev->open_count) { - /* only open once */ - GMN_PR_ERR("%s:%d] busy\n", __func__, __LINE__); - mutex_unlock(&pgmn_dev->lock); - return -EBUSY; - } - pgmn_dev->open_count++; - mutex_unlock(&pgmn_dev->lock); - - msm_gemini_core_irq_install(msm_gemini_irq); - - - rc = msm_gemini_platform_init(pgmn_dev->pdev, - &pgmn_dev->mem, &pgmn_dev->base, - &pgmn_dev->irq, msm_gemini_core_irq, pgmn_dev); - if (rc) { - GMN_PR_ERR("%s:%d] platform_init fail %d\n", __func__, - __LINE__, rc); - return rc; - } - - GMN_DBG("%s:%d] platform resources - mem %p, base %p, irq %d\n", - __func__, __LINE__, - pgmn_dev->mem, pgmn_dev->base, pgmn_dev->irq); - - msm_gemini_q_cleanup(&pgmn_dev->evt_q); - msm_gemini_q_cleanup(&pgmn_dev->output_rtn_q); - msm_gemini_outbuf_q_cleanup(&pgmn_dev->output_buf_q); - msm_gemini_q_cleanup(&pgmn_dev->input_rtn_q); - msm_gemini_q_cleanup(&pgmn_dev->input_buf_q); - msm_gemini_core_init(); - pgmn_dev->out_mode = MSM_GMN_OUTMODE_FRAGMENTED; - pgmn_dev->out_buf_set = 0; - pgmn_dev->out_offset = 0; - pgmn_dev->max_out_size = g_max_out_size; - pgmn_dev->out_frag_cnt = 0; - pgmn_dev->bus_perf_client = 0; - - if (p_bus_scale_data) { - GMN_DBG("%s:%d] register bus client", __func__, __LINE__); - pgmn_dev->bus_perf_client = - msm_bus_scale_register_client(p_bus_scale_data); - if (!pgmn_dev->bus_perf_client) { - GMN_PR_ERR("%s:%d] bus client register failed", - __func__, __LINE__); - return -EINVAL; - } - } - GMN_DBG("%s:%d] success\n", __func__, __LINE__); - return rc; -} - -int __msm_gemini_release(struct msm_gemini_device *pgmn_dev) -{ - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - mutex_lock(&pgmn_dev->lock); - if (!pgmn_dev->open_count) { - GMN_PR_ERR("%s: not opened\n", __func__); - mutex_unlock(&pgmn_dev->lock); - return -EINVAL; - } - pgmn_dev->open_count--; - mutex_unlock(&pgmn_dev->lock); - - if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_FRAGMENTED) { - msm_gemini_core_release(release_buf); - } else if (pgmn_dev->out_buf_set) { - msm_gemini_platform_p2v(pgmn_dev->out_buf.file, - &pgmn_dev->out_buf.handle); - } - msm_gemini_q_cleanup(&pgmn_dev->evt_q); - msm_gemini_q_cleanup(&pgmn_dev->output_rtn_q); - msm_gemini_outbuf_q_cleanup(&pgmn_dev->output_buf_q); - msm_gemini_q_cleanup(&pgmn_dev->input_rtn_q); - msm_gemini_outbuf_q_cleanup(&pgmn_dev->input_buf_q); - - if (pgmn_dev->bus_perf_client) { - msm_bus_scale_unregister_client(pgmn_dev->bus_perf_client); - pgmn_dev->bus_perf_client = 0; - } - - if (pgmn_dev->open_count) - GMN_PR_ERR("%s: multiple opens\n", __func__); - - msm_gemini_platform_release(pgmn_dev->mem, pgmn_dev->base, - pgmn_dev->irq, pgmn_dev); - - return 0; -} - -int msm_gemini_ioctl_hw_cmd(struct msm_gemini_device *pgmn_dev, - void * __user arg) -{ - struct msm_gemini_hw_cmd hw_cmd; - int is_copy_to_user; - - if (copy_from_user(&hw_cmd, arg, sizeof(struct msm_gemini_hw_cmd))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - - is_copy_to_user = msm_gemini_hw_exec_cmds(&hw_cmd, 1); - GMN_DBG("%s:%d] type %d, n %d, offset %d, mask %x, data %x, pdata %x\n", - __func__, __LINE__, hw_cmd.type, hw_cmd.n, hw_cmd.offset, - hw_cmd.mask, hw_cmd.data, (int) hw_cmd.pdata); - - if (is_copy_to_user >= 0) { - if (copy_to_user(arg, &hw_cmd, sizeof(hw_cmd))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - } - - return 0; -} - -static int msm_gemini_ioctl_hw_cmds(struct msm_gemini_device *pgmn_dev, - void * __user arg) -{ - int is_copy_to_user; - uint32_t len; - uint32_t m; - struct msm_gemini_hw_cmds *hw_cmds_p; - struct msm_gemini_hw_cmd *hw_cmd_p; - - if (copy_from_user(&m, arg, sizeof(m))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - - if ((m == 0) || (m > ((UINT32_MAX - sizeof(struct msm_gemini_hw_cmds)) / - sizeof(struct msm_gemini_hw_cmd)))) { - GMN_PR_ERR("%s:%d] m_cmds out of range\n", __func__, __LINE__); - return -EFAULT; - } - - len = sizeof(struct msm_gemini_hw_cmds) + - sizeof(struct msm_gemini_hw_cmd) * (m - 1); - hw_cmds_p = kmalloc(len, GFP_KERNEL); - if (!hw_cmds_p) { - GMN_PR_ERR("%s:%d] no mem %d\n", __func__, __LINE__, len); - return -EFAULT; - } - - if (copy_from_user(hw_cmds_p, arg, len)) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - kfree(hw_cmds_p); - return -EFAULT; - } - - hw_cmd_p = (struct msm_gemini_hw_cmd *) &(hw_cmds_p->hw_cmd); - - is_copy_to_user = msm_gemini_hw_exec_cmds(hw_cmd_p, m); - - if (is_copy_to_user >= 0) { - if (copy_to_user(arg, hw_cmds_p, len)) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - kfree(hw_cmds_p); - return -EFAULT; - } - } - kfree(hw_cmds_p); - return 0; -} - -static int msm_gemini_start(struct msm_gemini_device *pgmn_dev, - void * __user arg) -{ - struct msm_gemini_core_buf *buf_out; - struct msm_gemini_core_buf *buf_out_free[2] = {NULL, NULL}; - int i, rc; - - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - - release_buf = 1; - for (i = 0; i < 2; i++) { - buf_out = msm_gemini_q_out(&pgmn_dev->input_buf_q); - - if (buf_out) { - msm_gemini_core_fe_buf_update(buf_out); - kfree(buf_out); - } else { - GMN_DBG("%s:%d] no input buffer\n", __func__, __LINE__); - break; - } - } - - if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_FRAGMENTED) { - for (i = 0; i < 2; i++) { - buf_out_free[i] = - msm_gemini_q_out(&pgmn_dev->output_buf_q); - - if (buf_out_free[i]) { - msm_gemini_core_we_buf_update(buf_out_free[i]); - } else if (i == 1) { - /* set the pong to same address as ping */ - buf_out_free[0]->y_len >>= 1; - buf_out_free[0]->y_buffer_addr += - buf_out_free[0]->y_len; - msm_gemini_core_we_buf_update(buf_out_free[0]); - /* - * since ping and pong are same buf - * release only once - */ - release_buf = 0; - } else { - GMN_DBG("%s:%d] no output buffer\n", - __func__, __LINE__); - break; - } - } - for (i = 0; i < 2; i++) - kfree(buf_out_free[i]); - } else { - struct msm_gemini_core_buf out_buf; - /* - * Since the same buffer is fragmented, p2v need not be - * called for all the buffers - */ - release_buf = 0; - if (!pgmn_dev->out_buf_set) { - GMN_PR_ERR("%s:%d] output buffer not set", - __func__, __LINE__); - return -EFAULT; - } - /* configure ping */ - rc = msm_gemini_get_out_buffer(pgmn_dev, &out_buf); - if (rc) { - GMN_PR_ERR("%s:%d] no output buffer for ping", - __func__, __LINE__); - return rc; - } - msm_gemini_core_we_buf_update(&out_buf); - /* configure pong */ - rc = msm_gemini_get_out_buffer(pgmn_dev, &out_buf); - if (rc) { - GMN_DBG("%s:%d] no output buffer for pong", - __func__, __LINE__); - /* fall through to configure same buffer */ - } - msm_gemini_core_we_buf_update(&out_buf); - msm_gemini_io_dump(0x150); - } - - rc = msm_gemini_ioctl_hw_cmds(pgmn_dev, arg); - GMN_DBG("%s:%d]\n", __func__, __LINE__); - return rc; -} - -static int msm_gemini_ioctl_reset(struct msm_gemini_device *pgmn_dev, - void * __user arg) -{ - int rc; - struct msm_gemini_ctrl_cmd ctrl_cmd; - - GMN_DBG("%s:%d] Enter\n", __func__, __LINE__); - if (copy_from_user(&ctrl_cmd, arg, sizeof(ctrl_cmd))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - - pgmn_dev->op_mode = ctrl_cmd.type; - - rc = msm_gemini_core_reset(pgmn_dev->op_mode, pgmn_dev->base, - resource_size(pgmn_dev->mem)); - return rc; -} - -static int msm_gemini_ioctl_set_outmode(struct msm_gemini_device *pgmn_dev, - void * __user arg) -{ - int rc = 0; - enum msm_gmn_out_mode mode; - - if (copy_from_user(&mode, arg, sizeof(mode))) { - GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__); - return -EFAULT; - } - GMN_DBG("%s:%d] mode %d", __func__, __LINE__, mode); - - if ((mode == MSM_GMN_OUTMODE_FRAGMENTED) - || (mode == MSM_GMN_OUTMODE_SINGLE)) - pgmn_dev->out_mode = mode; - return rc; -} - -long __msm_gemini_ioctl(struct msm_gemini_device *pgmn_dev, - unsigned int cmd, unsigned long arg) -{ - int rc = 0; - switch (cmd) { - case MSM_GMN_IOCTL_GET_HW_VERSION: - GMN_DBG("%s:%d] VERSION 1\n", __func__, __LINE__); - rc = msm_gemini_ioctl_hw_cmd(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_RESET: - rc = msm_gemini_ioctl_reset(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_STOP: - rc = msm_gemini_ioctl_hw_cmds(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_START: - rc = msm_gemini_start(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_INPUT_BUF_ENQUEUE: - rc = msm_gemini_input_buf_enqueue(pgmn_dev, - (void __user *) arg); - break; - - case MSM_GMN_IOCTL_INPUT_GET: - rc = msm_gemini_input_get(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_INPUT_GET_UNBLOCK: - rc = msm_gemini_input_get_unblock(pgmn_dev); - break; - - case MSM_GMN_IOCTL_OUTPUT_BUF_ENQUEUE: - if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_FRAGMENTED) - rc = msm_gemini_output_buf_enqueue(pgmn_dev, - (void __user *) arg); - else - rc = msm_gemini_set_output_buf(pgmn_dev, - (void __user *) arg); - break; - - case MSM_GMN_IOCTL_OUTPUT_GET: - rc = msm_gemini_output_get(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_OUTPUT_GET_UNBLOCK: - rc = msm_gemini_output_get_unblock(pgmn_dev); - break; - - case MSM_GMN_IOCTL_EVT_GET: - rc = msm_gemini_evt_get(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_EVT_GET_UNBLOCK: - rc = msm_gemini_evt_get_unblock(pgmn_dev); - break; - - case MSM_GMN_IOCTL_HW_CMD: - rc = msm_gemini_ioctl_hw_cmd(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_HW_CMDS: - rc = msm_gemini_ioctl_hw_cmds(pgmn_dev, (void __user *) arg); - break; - - case MSM_GMN_IOCTL_SET_MODE: - rc = msm_gemini_ioctl_set_outmode(pgmn_dev, (void __user *)arg); - break; - - default: - GMN_PR_ERR("%s:%d] cmd = %d not supported\n", - __func__, __LINE__, _IOC_NR(cmd)); - rc = -EINVAL; - break; - } - return rc; -} - -struct msm_gemini_device *__msm_gemini_init(struct platform_device *pdev) -{ - struct msm_gemini_device *pgmn_dev; - - pgmn_dev = kzalloc(sizeof(struct msm_gemini_device), GFP_ATOMIC); - if (!pgmn_dev) { - GMN_PR_ERR("%s:%d]no mem\n", __func__, __LINE__); - return NULL; - } - - mutex_init(&pgmn_dev->lock); - - pgmn_dev->pdev = pdev; - - msm_gemini_q_init("evt_q", &pgmn_dev->evt_q); - msm_gemini_q_init("output_rtn_q", &pgmn_dev->output_rtn_q); - msm_gemini_q_init("output_buf_q", &pgmn_dev->output_buf_q); - msm_gemini_q_init("input_rtn_q", &pgmn_dev->input_rtn_q); - msm_gemini_q_init("input_buf_q", &pgmn_dev->input_buf_q); - - return pgmn_dev; -} - -int __msm_gemini_exit(struct msm_gemini_device *pgmn_dev) -{ - mutex_destroy(&pgmn_dev->lock); - kfree(pgmn_dev); - return 0; -} - diff --git a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_sync.h b/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_sync.h deleted file mode 100644 index 6982a78ca58b7b3ca26579c5f7527cea497a51b7..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/gemini/msm_gemini_sync.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2010,2013, 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 MSM_GEMINI_SYNC_H -#define MSM_GEMINI_SYNC_H - -#include -#include -#include -#include -#include -#include -#include "msm_gemini_core.h" - -#define GEMINI_7X 0x1 -#define GEMINI_8X60 (0x1 << 1) -#define GEMINI_8960 (0x1 << 2) - -struct msm_gemini_q { - char const *name; - struct list_head q; - spinlock_t lck; - wait_queue_head_t wait; - int unblck; -}; - -struct msm_gemini_q_entry { - struct list_head list; - void *data; -}; - -struct msm_gemini_device { - struct platform_device *pdev; - struct resource *mem; - int irq; - void *base; - struct clk *gemini_clk[3]; - struct regulator *gemini_fs; - uint32_t hw_version; - - struct device *device; - struct cdev cdev; - struct mutex lock; - char open_count; - uint8_t op_mode; - - /* event queue including frame done & err indications - */ - struct msm_gemini_q evt_q; - - /* output return queue - */ - struct msm_gemini_q output_rtn_q; - - /* output buf queue - */ - struct msm_gemini_q output_buf_q; - - /* input return queue - */ - struct msm_gemini_q input_rtn_q; - - /* input buf queue - */ - struct msm_gemini_q input_buf_q; - - struct v4l2_subdev subdev; - enum msm_gmn_out_mode out_mode; - - /*single out mode parameters*/ - struct msm_gemini_hw_buf out_buf; - int out_offset; - int out_buf_set; - int max_out_size; - int out_frag_cnt; - - uint32_t bus_perf_client; -}; - -int __msm_gemini_open(struct msm_gemini_device *pgmn_dev); -int __msm_gemini_release(struct msm_gemini_device *pgmn_dev); - -long __msm_gemini_ioctl(struct msm_gemini_device *pgmn_dev, - unsigned int cmd, unsigned long arg); - -struct msm_gemini_device *__msm_gemini_init(struct platform_device *pdev); -int __msm_gemini_exit(struct msm_gemini_device *pgmn_dev); - -#endif /* MSM_GEMINI_SYNC_H */ diff --git a/drivers/media/platform/msm/camera_v2/sensor/csid/include/csi2.0/msm_csid_hwreg.h b/drivers/media/platform/msm/camera_v2/sensor/csid/include/csi2.0/msm_csid_hwreg.h deleted file mode 100644 index c912d72ea9ddbe82e8dc1f05a6c07094620259d8..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/sensor/csid/include/csi2.0/msm_csid_hwreg.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) 2012-2013, 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 MSM_CSID_HWREG_H -#define MSM_CSID_HWREG_H - - -#include "msm_camera_io_util.h" - -/* MIPI CSID registers */ -#define CSID_HW_VERSION_ADDR 0x0 -#define CSID_CORE_CTRL_0_ADDR 0x4 -#define CSID_CORE_CTRL_1_ADDR 0x4 -#define CSID_RST_CMD_ADDR 0x8 -#define CSID_CID_LUT_VC_0_ADDR 0xc -#define CSID_CID_LUT_VC_1_ADDR 0x10 -#define CSID_CID_LUT_VC_2_ADDR 0x14 -#define CSID_CID_LUT_VC_3_ADDR 0x18 -#define CSID_CID_n_CFG_ADDR 0x1C -#define CSID_IRQ_CLEAR_CMD_ADDR 0x5c -#define CSID_IRQ_MASK_ADDR 0x60 -#define CSID_IRQ_STATUS_ADDR 0x64 -#define CSID_CAPTURED_UNMAPPED_LONG_PKT_HDR_ADDR 0x68 -#define CSID_CAPTURED_MMAPPED_LONG_PKT_HDR_ADDR 0x6c -#define CSID_CAPTURED_SHORT_PKT_ADDR 0x70 -#define CSID_CAPTURED_LONG_PKT_HDR_ADDR 0x74 -#define CSID_CAPTURED_LONG_PKT_FTR_ADDR 0x78 -#define CSID_PIF_MISR_DL0_ADDR 0x7C -#define CSID_PIF_MISR_DL1_ADDR 0x80 -#define CSID_PIF_MISR_DL2_ADDR 0x84 -#define CSID_PIF_MISR_DL3_ADDR 0x88 -#define CSID_STATS_TOTAL_PKTS_RCVD_ADDR 0x8C -#define CSID_STATS_ECC_ADDR 0x90 -#define CSID_STATS_CRC_ADDR 0x94 -#define CSID_TG_CTRL_ADDR 0x9C -#define CSID_TG_VC_CFG_ADDR 0xA0 -#define CSID_TG_DT_n_CFG_0_ADDR 0xA8 -#define CSID_TG_DT_n_CFG_1_ADDR 0xAC -#define CSID_TG_DT_n_CFG_2_ADDR 0xB0 -#define CSID_RST_DONE_IRQ_BITSHIFT 11 -#define CSID_RST_STB_ALL 0x7FFF -#define CSID_DL_INPUT_SEL_SHIFT 0x2 -#define CSID_PHY_SEL_SHIFT 17 -#define CSID_VERSION 0x02000011 - -static struct msm_cam_clk_info csid_clk_info[] = { - {"csi_src_clk", 177780000}, - {"csi_clk", -1}, - {"csi_phy_clk", -1}, - {"csi_pclk", -1}, -}; - -static struct msm_cam_clk_info csid_clk_src_info[] = { - {"csi_phy_src_clk", 0}, - {"csi_phy_src_clk", 0}, - {"csi_pix_src_clk", 0}, - {"csi_rdi_src_clk", 0}, - {"csi_rdi_src_clk", 0}, - {"csi_rdi_src_clk", 0}, -}; - -static struct camera_vreg_t csid_vreg_info[] = { - {"mipi_csi_vdd", REG_LDO, 1200000, 1200000, 20000}, -}; - -#endif diff --git a/drivers/media/platform/msm/camera_v2/sensor/csiphy/include/csi2.0/msm_csiphy_hwreg.h b/drivers/media/platform/msm/camera_v2/sensor/csiphy/include/csi2.0/msm_csiphy_hwreg.h deleted file mode 100644 index d13b953dfeea4c07d4dd1ac6725135e9359f017c..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/camera_v2/sensor/csiphy/include/csi2.0/msm_csiphy_hwreg.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2012-2013, 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 MSM_CSIPHY_HWREG_H -#define MSM_CSIPHY_HWREG_H - -#include "msm_camera_io_util.h" - -/*MIPI CSI PHY registers*/ -#define MIPI_CSIPHY_HW_VERSION_ADDR 0x17C -#define MIPI_CSIPHY_LNn_CFG1_ADDR 0x0 -#define MIPI_CSIPHY_LNn_CFG2_ADDR 0x4 -#define MIPI_CSIPHY_LNn_CFG3_ADDR 0x8 -#define MIPI_CSIPHY_LNn_CFG4_ADDR 0xC -#define MIPI_CSIPHY_LNn_CFG5_ADDR 0x10 -#define MIPI_CSIPHY_LNCK_CFG1_ADDR 0x100 -#define MIPI_CSIPHY_LNCK_CFG2_ADDR 0x104 -#define MIPI_CSIPHY_LNCK_CFG3_ADDR 0x108 -#define MIPI_CSIPHY_LNCK_CFG4_ADDR 0x10C -#define MIPI_CSIPHY_LNCK_CFG5_ADDR 0x110 -#define MIPI_CSIPHY_LNCK_MISC1_ADDR 0x128 -#define MIPI_CSIPHY_GLBL_RESET_ADDR 0x140 -#define MIPI_CSIPHY_GLBL_PWR_CFG_ADDR 0x144 -#define MIPI_CSIPHY_GLBL_IRQ_CMD_ADDR 0x164 -#define MIPI_CSIPHY_INTERRUPT_STATUS0_ADDR 0x180 -#define MIPI_CSIPHY_INTERRUPT_MASK0_ADDR 0x1A0 -#define MIPI_CSIPHY_INTERRUPT_MASK_VAL 0x6F -#define MIPI_CSIPHY_INTERRUPT_MASK_ADDR 0x1A4 -#define MIPI_CSIPHY_INTERRUPT_CLEAR0_ADDR 0x1C0 -#define MIPI_CSIPHY_INTERRUPT_CLEAR_ADDR 0x1C4 -#define MIPI_CSIPHY_MODE_CONFIG_SHIFT 0x4 -#define MIPI_CSIPHY_GLBL_T_INIT_CFG0_ADDR 0x1E0 -#define MIPI_CSIPHY_T_WAKEUP_CFG0_ADDR 0x1E8 -#define CSIPHY_VERSION 0x0 - -static struct msm_cam_clk_info csiphy_clk_info[] = { - {"csiphy_timer_src_clk", 177780000}, - {"csiphy_timer_clk", -1}, -}; - -static struct msm_cam_clk_info csiphy_8610_clk_info[] = { - {"csiphy_timer_src_clk", 200000000}, - {"csiphy_timer_clk", -1}, - {"csi_ahb_clk", -1}, -}; - -#endif diff --git a/drivers/media/platform/msm/dvb/demux/Kconfig b/drivers/media/platform/msm/dvb/demux/Kconfig index 0e48f009128454941a4411e3ab7979d2e6d8ed76..c1fae4f5b9fe282010d68b1b62f99e67ed688428 100644 --- a/drivers/media/platform/msm/dvb/demux/Kconfig +++ b/drivers/media/platform/msm/dvb/demux/Kconfig @@ -19,7 +19,7 @@ config DVB_MPQ_NUM_DMX_DEVICES choice prompt "Demux Hardware Plugin" depends on DVB_MPQ_DEMUX - default DVB_MPQ_TSIF + default DVB_MPQ_TSPP1 help Enable support of specific demux HW plugin depending on the existing HW support. Depending on the enabled HW, demux may take advantage of HW capbailities to perform some tasks in HW instead of SW. @@ -42,10 +42,5 @@ choice - Indexing of video - Crytographic operations - config DVB_MPQ_TSIF - bool "TSIF plugin" - depends on TSIF - help - Use this option if your HW has only TSIF input without any Transport Stream Packet Processor (TSPP) support endchoice diff --git a/drivers/media/platform/msm/dvb/demux/Makefile b/drivers/media/platform/msm/dvb/demux/Makefile index 3a39b84d4c2b96f501c1e9416508ffc6609d52c3..2ad15268c1f60d8086bd2969c12fa7badf96721f 100644 --- a/drivers/media/platform/msm/dvb/demux/Makefile +++ b/drivers/media/platform/msm/dvb/demux/Makefile @@ -13,6 +13,5 @@ mpq-dmx-hw-plugin-$(CONFIG_DVB_MPQ_TSPP1) += mpq_dmx_plugin_tspp_v1.o mpq-dmx-hw-plugin-$(CONFIG_DVB_MPQ_TSPP2) += mpq_dmx_plugin_tspp_v2.o -mpq-dmx-hw-plugin-$(CONFIG_DVB_MPQ_TSIF) += mpq_dmx_plugin_tsif.o diff --git a/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_tsif.c b/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_tsif.c deleted file mode 100644 index a7e304cebb34acd3fad4b63002481644c93f0ccf..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_tsif.c +++ /dev/null @@ -1,860 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include "mpq_dvb_debug.h" -#include "mpq_dmx_plugin_common.h" - - -/* TSIF HW configuration: */ -#define TSIF_COUNT 2 - -/* Max number of section filters */ -#define DMX_TSIF_MAX_SECTION_FILTER_NUM 64 - -/* When TSIF driver notifies demux that new packets are received */ -#define DMX_TSIF_PACKETS_IN_CHUNK_DEF 512 -#define DMX_TSIF_CHUNKS_IN_BUF 16 -#define DMX_TSIF_TIME_LIMIT 10000 - -/* TSIF_DRIVER_MODE: 3 means manual control from debugfs. use 2 normally. */ -#define DMX_TSIF_DRIVER_MODE_DEF 2 - -/* module parameters for load time configuration: */ -static int threshold = DMX_TSIF_PACKETS_IN_CHUNK_DEF; -module_param(threshold, int, S_IRUGO); - - -/* - * TSIF driver information - */ -struct tsif_driver_info { - /* handler to TSIF driver */ - void *tsif_handler; - /* TSIF driver data buffer pointer */ - void *data_buffer; - /* TSIF driver data buffer size, in packets */ - int buffer_size; - /* TSIF driver read pointer */ - int ri; - /* TSIF driver write pointer */ - int wi; - /* TSIF driver state */ - enum tsif_state state; -}; - - -/* - * The following structure hold singelton information - * required for dmx implementation on top of TSIF. - */ -static struct -{ - /* Information for each TSIF input processing */ - struct { - /* thread processing TS packets from TSIF */ - struct task_struct *thread; - wait_queue_head_t wait_queue; - - /* Counter for data notifications from TSIF */ - atomic_t data_cnt; - - /* TSIF alias */ - char name[TSIF_NAME_LENGTH]; - - /* TSIF driver information */ - struct tsif_driver_info tsif_driver; - - /* TSIF reference count (counts start/stop operations */ - int ref_count; - - /* Pointer to the demux connected to this TSIF */ - struct mpq_demux *mpq_demux; - - /* mutex protecting the data-structure */ - struct mutex mutex; - } tsif[TSIF_COUNT]; -} mpq_dmx_tsif_info; - - -/** - * Demux thread function handling data from specific TSIF. - * - * @arg: TSIF number - */ -static int mpq_dmx_tsif_thread(void *arg) -{ - struct mpq_demux *mpq_demux; - struct tsif_driver_info *tsif_driver; - size_t packets = 0; - int tsif = (int)arg; - int ret; - - do { - ret = wait_event_interruptible( - mpq_dmx_tsif_info.tsif[tsif].wait_queue, - (atomic_read( - &mpq_dmx_tsif_info.tsif[tsif].data_cnt) != 0) || - kthread_should_stop()); - - if ((ret < 0) || kthread_should_stop()) { - MPQ_DVB_DBG_PRINT("%s: exit\n", __func__); - break; - } - - if (mutex_lock_interruptible( - &mpq_dmx_tsif_info.tsif[tsif].mutex)) - return -ERESTARTSYS; - - tsif_driver = &(mpq_dmx_tsif_info.tsif[tsif].tsif_driver); - mpq_demux = mpq_dmx_tsif_info.tsif[tsif].mpq_demux; - - /* Check if driver handler is still valid */ - if (tsif_driver->tsif_handler == NULL) { - mutex_unlock(&mpq_dmx_tsif_info.tsif[tsif].mutex); - MPQ_DVB_DBG_PRINT( - "%s: tsif was detached\n", - __func__); - continue; - } - - tsif_get_state( - tsif_driver->tsif_handler, &(tsif_driver->ri), - &(tsif_driver->wi), &(tsif_driver->state)); - - if ((tsif_driver->wi == tsif_driver->ri) || - (tsif_driver->state == tsif_state_stopped) || - (tsif_driver->state == tsif_state_error)) { - - mpq_demux->hw_notification_size = 0; - - mutex_unlock(&mpq_dmx_tsif_info.tsif[tsif].mutex); - - MPQ_DVB_DBG_PRINT( - "%s: TSIF invalid state %d, %d, %d\n", - __func__, - tsif_driver->state, - tsif_driver->wi, - tsif_driver->ri); - continue; - } - - atomic_dec(&mpq_dmx_tsif_info.tsif[tsif].data_cnt); - - if (tsif_driver->wi > tsif_driver->ri) { - packets = (tsif_driver->wi - tsif_driver->ri); - mpq_demux->hw_notification_size = packets; - - dvb_dmx_swfilter_format( - &mpq_demux->demux, - (tsif_driver->data_buffer + - (tsif_driver->ri * TSIF_PKT_SIZE)), - (packets * TSIF_PKT_SIZE), - DMX_TSP_FORMAT_192_TAIL); - - tsif_driver->ri = - (tsif_driver->ri + packets) % - tsif_driver->buffer_size; - - tsif_reclaim_packets( - tsif_driver->tsif_handler, - tsif_driver->ri); - } else { - /* - * wi < ri, means wraparound on cyclic buffer. - * Handle in two stages. - */ - packets = (tsif_driver->buffer_size - tsif_driver->ri); - mpq_demux->hw_notification_size = packets; - - dvb_dmx_swfilter_format( - &mpq_demux->demux, - (tsif_driver->data_buffer + - (tsif_driver->ri * TSIF_PKT_SIZE)), - (packets * TSIF_PKT_SIZE), - DMX_TSP_FORMAT_192_TAIL); - - /* tsif_driver->ri should be 0 after this */ - tsif_driver->ri = - (tsif_driver->ri + packets) % - tsif_driver->buffer_size; - - packets = tsif_driver->wi; - if (packets > 0) { - mpq_demux->hw_notification_size += packets; - - dvb_dmx_swfilter_format( - &mpq_demux->demux, - (tsif_driver->data_buffer + - (tsif_driver->ri * TSIF_PKT_SIZE)), - (packets * TSIF_PKT_SIZE), - DMX_TSP_FORMAT_192_TAIL); - - tsif_driver->ri = - (tsif_driver->ri + packets) % - tsif_driver->buffer_size; - } - - tsif_reclaim_packets( - tsif_driver->tsif_handler, - tsif_driver->ri); - } - - mutex_unlock(&mpq_dmx_tsif_info.tsif[tsif].mutex); - } while (1); - - return 0; -} - - -/** - * Callback function from TSIF driver when new data is ready. - * - * @user: user-data holding TSIF number - */ -static void mpq_tsif_callback(void *user) -{ - int tsif = (int)user; - struct mpq_demux *mpq_demux; - - MPQ_DVB_DBG_PRINT("%s executed, tsif = %d\n", __func__, tsif); - - /* Save statistics on TSIF notifications */ - mpq_demux = mpq_dmx_tsif_info.tsif[tsif].mpq_demux; - mpq_dmx_update_hw_statistics(mpq_demux); - - atomic_inc(&mpq_dmx_tsif_info.tsif[tsif].data_cnt); - wake_up(&mpq_dmx_tsif_info.tsif[tsif].wait_queue); -} - - -/** - * Attach to TSIF driver and start TSIF operation. - * - * @mpq_demux: the mpq_demux we are working on. - * - * Return error code. - */ -static int mpq_tsif_dmx_start(struct mpq_demux *mpq_demux) -{ - int ret = 0; - int tsif; - int tsif_mode = mpq_dmx_get_param_tsif_mode(); - int clock_inv = mpq_dmx_get_param_clock_inv(); - struct tsif_driver_info *tsif_driver; - - MPQ_DVB_DBG_PRINT("%s executed\n", __func__); - - /* determine the TSIF we are reading from */ - if (mpq_demux->source == DMX_SOURCE_FRONT0) { - tsif = 0; - } else if (mpq_demux->source == DMX_SOURCE_FRONT1) { - tsif = 1; - } else { - /* invalid source */ - MPQ_DVB_ERR_PRINT( - "%s: invalid input source (%d)\n", - __func__, - mpq_demux->source); - - return -EINVAL; - } - - if (mutex_lock_interruptible(&mpq_dmx_tsif_info.tsif[tsif].mutex)) - return -ERESTARTSYS; - - if (mpq_dmx_tsif_info.tsif[tsif].ref_count == 0) { - tsif_driver = &(mpq_dmx_tsif_info.tsif[tsif].tsif_driver); - - /* Attach to TSIF driver */ - tsif_driver->tsif_handler = - tsif_attach(tsif, mpq_tsif_callback, (void *)tsif); - if (IS_ERR_OR_NULL(tsif_driver->tsif_handler)) { - tsif_driver->tsif_handler = NULL; - mutex_unlock(&mpq_dmx_tsif_info.tsif[tsif].mutex); - MPQ_DVB_DBG_PRINT("%s: tsif_attach(%d) failed\n", - __func__, tsif); - return -ENODEV; - } - - ret = tsif_set_clk_inverse(tsif_driver->tsif_handler, - clock_inv); - if (ret < 0) { - MPQ_DVB_ERR_PRINT( - "%s: tsif_set_clk_inverse (%d) failed\n", - __func__, clock_inv); - } - - /* Set TSIF driver mode */ - ret = tsif_set_mode(tsif_driver->tsif_handler, tsif_mode); - if (ret < 0) { - MPQ_DVB_ERR_PRINT("%s: tsif_set_mode (%d) failed\n", - __func__, tsif_mode); - } - - /* Set TSIF buffer configuration */ - ret = tsif_set_buf_config(tsif_driver->tsif_handler, - threshold, - DMX_TSIF_CHUNKS_IN_BUF); - if (ret < 0) { - MPQ_DVB_ERR_PRINT( - "%s: tsif_set_buf_config (%d, %d) failed\n", - __func__, threshold, - DMX_TSIF_CHUNKS_IN_BUF); - MPQ_DVB_ERR_PRINT("Using default TSIF driver values\n"); - } - - /* Start TSIF driver */ - ret = tsif_start(tsif_driver->tsif_handler); - if (ret < 0) { - mutex_unlock(&mpq_dmx_tsif_info.tsif[tsif].mutex); - MPQ_DVB_ERR_PRINT("%s: tsif_start failed\n", __func__); - return ret; - } - - /* - * Get data buffer information from TSIF driver - * (must be called after tsif_start) - */ - tsif_get_info(tsif_driver->tsif_handler, - &(tsif_driver->data_buffer), - &(tsif_driver->buffer_size)); - - /* save pointer to the mpq_demux we are working on */ - mpq_dmx_tsif_info.tsif[tsif].mpq_demux = mpq_demux; - } - mpq_dmx_tsif_info.tsif[tsif].ref_count++; - - mutex_unlock(&mpq_dmx_tsif_info.tsif[tsif].mutex); - - return ret; -} - - -/** - * Stop TSIF operation and detach from TSIF driver. - * - * @mpq_demux: the mpq_demux we are working on. - * - * Return error code. - */ -static int mpq_tsif_dmx_stop(struct mpq_demux *mpq_demux) -{ - int tsif; - struct tsif_driver_info *tsif_driver; - - MPQ_DVB_DBG_PRINT("%s executed\n", __func__); - - /* determine the TSIF we are reading from */ - if (mpq_demux->source == DMX_SOURCE_FRONT0) { - tsif = 0; - } else if (mpq_demux->source == DMX_SOURCE_FRONT1) { - tsif = 1; - } else { - /* invalid source */ - MPQ_DVB_ERR_PRINT( - "%s: invalid input source (%d)\n", - __func__, - mpq_demux->source); - - return -EINVAL; - } - - if (mutex_lock_interruptible(&mpq_dmx_tsif_info.tsif[tsif].mutex)) - return -ERESTARTSYS; - - mpq_dmx_tsif_info.tsif[tsif].ref_count--; - - if (mpq_dmx_tsif_info.tsif[tsif].ref_count == 0) { - tsif_driver = &(mpq_dmx_tsif_info.tsif[tsif].tsif_driver); - tsif_stop(tsif_driver->tsif_handler); - tsif_detach(tsif_driver->tsif_handler); - tsif_driver->tsif_handler = NULL; - tsif_driver->data_buffer = NULL; - tsif_driver->buffer_size = 0; - atomic_set(&mpq_dmx_tsif_info.tsif[tsif].data_cnt, 0); - mpq_dmx_tsif_info.tsif[tsif].mpq_demux = NULL; - } - - mutex_unlock(&mpq_dmx_tsif_info.tsif[tsif].mutex); - - return 0; -} - - -/** - * Start filtering according to feed parameter. - * - * @feed: the feed we are working on. - * - * Return error code. - */ -static int mpq_tsif_dmx_start_filtering(struct dvb_demux_feed *feed) -{ - int ret = 0; - struct mpq_demux *mpq_demux = feed->demux->priv; - - MPQ_DVB_DBG_PRINT( - "%s(%d) executed\n", - __func__, - feed->pid); - - if (mpq_demux == NULL) { - MPQ_DVB_ERR_PRINT( - "%s: invalid mpq_demux handle\n", - __func__); - - return -EINVAL; - } - - if (mpq_demux->source < DMX_SOURCE_DVR0) { - /* Source from TSIF, need to configure TSIF hardware */ - ret = mpq_tsif_dmx_start(mpq_demux); - - if (ret < 0) { - MPQ_DVB_DBG_PRINT( - "%s: mpq_tsif_dmx_start failed(%d)\n", - __func__, - ret); - return ret; - } - } - - /* Always feed sections/PES starting from a new one and - * do not partial transfer data from older one - */ - feed->pusi_seen = 0; - - ret = mpq_dmx_init_mpq_feed(feed); - if (ret < 0) { - MPQ_DVB_DBG_PRINT( - "%s: mpq_dmx_init_mpq_feed failed(%d)\n", - __func__, - ret); - - if (mpq_demux->source < DMX_SOURCE_DVR0) - mpq_tsif_dmx_stop(mpq_demux); - - return ret; - } - - return ret; -} - - -/** - * Stop filtering according to feed parameter. - * - * @feed: the feed we are working on. - * - * Return error code. - */ -static int mpq_tsif_dmx_stop_filtering(struct dvb_demux_feed *feed) -{ - int ret = 0; - struct mpq_demux *mpq_demux = feed->demux->priv; - - MPQ_DVB_DBG_PRINT( - "%s(%d) executed\n", - __func__, - feed->pid); - - if (mpq_demux == NULL) { - MPQ_DVB_ERR_PRINT( - "%s: invalid mpq_demux handle\n", - __func__); - - return -EINVAL; - } - - mpq_dmx_terminate_feed(feed); - - if (mpq_demux->source < DMX_SOURCE_DVR0) { - /* Source from TSIF, need to configure TSIF hardware */ - ret = mpq_tsif_dmx_stop(mpq_demux); - } - - return ret; -} - - -/** - * TSIF demux plugin write-to-decoder function. - * - * @feed: The feed we are working on. - * @buf: The data buffer to process. - * @len: The data buffer length. - * - * Return error code - */ -static int mpq_tsif_dmx_write_to_decoder( - struct dvb_demux_feed *feed, - const u8 *buf, - size_t len) -{ - MPQ_DVB_DBG_PRINT("%s executed\n", __func__); - - /* - * It is assumed that this function is called once for each - * TS packet of the relevant feed. - */ - if (len > TSIF_PKT_SIZE) - MPQ_DVB_DBG_PRINT( - "%s: warnning - len larger than one packet\n", - __func__); - - if (dvb_dmx_is_video_feed(feed)) - return mpq_dmx_process_video_packet(feed, buf); - - if (dvb_dmx_is_pcr_feed(feed)) - return mpq_dmx_process_pcr_packet(feed, buf); - - return 0; -} - -/** - * Returns demux capabilities of TSIF plugin - * - * @demux: demux device - * @caps: Returned capbabilities - * - * Return error code - */ -static int mpq_tsif_dmx_get_caps(struct dmx_demux *demux, - struct dmx_caps *caps) -{ - struct dvb_demux *dvb_demux = demux->priv; - - if ((dvb_demux == NULL) || (caps == NULL)) { - MPQ_DVB_ERR_PRINT( - "%s: invalid parameters\n", - __func__); - - return -EINVAL; - } - - caps->caps = DMX_CAP_PULL_MODE | DMX_CAP_VIDEO_DECODER_DATA | - DMX_CAP_TS_INSERTION | DMX_CAP_VIDEO_INDEXING; - caps->recording_max_video_pids_indexed = 0; - caps->num_decoders = MPQ_ADAPTER_MAX_NUM_OF_INTERFACES; - caps->num_demux_devices = CONFIG_DVB_MPQ_NUM_DMX_DEVICES; - caps->num_pid_filters = dvb_demux->feednum; - caps->num_section_filters = dvb_demux->filternum; - caps->num_section_filters_per_pid = dvb_demux->filternum; - caps->section_filter_length = DMX_FILTER_SIZE; - caps->num_demod_inputs = TSIF_COUNT; - caps->num_memory_inputs = CONFIG_DVB_MPQ_NUM_DMX_DEVICES; - caps->max_bitrate = 144; - caps->demod_input_max_bitrate = 72; - caps->memory_input_max_bitrate = 72; - caps->num_cipher_ops = 0; - - /* TSIF reports 3 bytes STC at unit of 27MHz/256 */ - caps->max_stc = (u64)0xFFFFFF * 256; - - /* Buffer requirements */ - caps->section.flags = - DMX_BUFFER_EXTERNAL_SUPPORT | - DMX_BUFFER_INTERNAL_SUPPORT | - DMX_BUFFER_CACHED; - caps->section.max_buffer_num = 1; - caps->section.max_size = 0xFFFFFFFF; - caps->section.size_alignment = 0; - caps->pes.flags = - DMX_BUFFER_EXTERNAL_SUPPORT | - DMX_BUFFER_INTERNAL_SUPPORT | - DMX_BUFFER_CACHED; - caps->pes.max_buffer_num = 1; - caps->pes.max_size = 0xFFFFFFFF; - caps->pes.size_alignment = 0; - caps->recording_188_tsp.flags = - DMX_BUFFER_EXTERNAL_SUPPORT | - DMX_BUFFER_INTERNAL_SUPPORT | - DMX_BUFFER_CACHED; - caps->recording_188_tsp.max_buffer_num = 1; - caps->recording_188_tsp.max_size = 0xFFFFFFFF; - caps->recording_188_tsp.size_alignment = 0; - caps->recording_192_tsp.flags = - DMX_BUFFER_EXTERNAL_SUPPORT | - DMX_BUFFER_INTERNAL_SUPPORT | - DMX_BUFFER_CACHED; - caps->recording_192_tsp.max_buffer_num = 1; - caps->recording_192_tsp.max_size = 0xFFFFFFFF; - caps->recording_192_tsp.size_alignment = 0; - caps->playback_188_tsp.flags = - DMX_BUFFER_EXTERNAL_SUPPORT | - DMX_BUFFER_INTERNAL_SUPPORT | - DMX_BUFFER_CACHED; - caps->playback_188_tsp.max_buffer_num = 1; - caps->playback_188_tsp.max_size = 0xFFFFFFFF; - caps->playback_188_tsp.size_alignment = 0; - caps->playback_192_tsp.flags = - DMX_BUFFER_EXTERNAL_SUPPORT | - DMX_BUFFER_INTERNAL_SUPPORT | - DMX_BUFFER_CACHED; - caps->playback_192_tsp.max_buffer_num = 1; - caps->playback_192_tsp.max_size = 0xFFFFFFFF; - caps->playback_192_tsp.size_alignment = 0; - caps->decoder.flags = - DMX_BUFFER_SECURED_IF_DECRYPTED | - DMX_BUFFER_EXTERNAL_SUPPORT | - DMX_BUFFER_INTERNAL_SUPPORT | - DMX_BUFFER_LINEAR_GROUP_SUPPORT | - DMX_BUFFER_CACHED; - caps->decoder.max_buffer_num = DMX_MAX_DECODER_BUFFER_NUM; - caps->decoder.max_size = 0xFFFFFFFF; - caps->decoder.size_alignment = SZ_4K; - - return 0; -} - -/** - * Reads TSIF STC from TSPP - * - * @demux: demux device - * @num: STC number. 0 for TSIF0 and 1 for TSIF1. - * @stc: STC value - * @base: divisor to get 90KHz value - * - * Return error code - */ -static int mpq_tsif_dmx_get_stc(struct dmx_demux *demux, unsigned int num, - u64 *stc, unsigned int *base) -{ - struct tsif_driver_info *tsif_driver; - u32 tcr_counter; - - if (!demux || !stc || !base) - return -EINVAL; - - if (num == 0) - tsif_driver = &mpq_dmx_tsif_info.tsif[0].tsif_driver; - else if (num == 1) - tsif_driver = &mpq_dmx_tsif_info.tsif[1].tsif_driver; - else - return -EINVAL; - - if (!tsif_driver->tsif_handler) - return -ENODEV; - - tsif_get_ref_clk_counter(tsif_driver->tsif_handler, &tcr_counter); - - *stc = ((u64)tcr_counter) * 256; /* conversion to 27MHz */ - *base = 300; /* divisor to get 90KHz clock from stc value */ - - return 0; -} - -/** - * Initialize a single demux device. - * - * @mpq_adapter: MPQ DVB adapter - * @mpq_demux: The demux device to initialize - * - * Return error code - */ -static int mpq_tsif_dmx_init( - struct dvb_adapter *mpq_adapter, - struct mpq_demux *mpq_demux) -{ - int result; - - MPQ_DVB_DBG_PRINT("%s executed\n", __func__); - - /* Set the kernel-demux object capabilities */ - mpq_demux->demux.dmx.capabilities = - DMX_TS_FILTERING | - DMX_PES_FILTERING | - DMX_SECTION_FILTERING | - DMX_MEMORY_BASED_FILTERING | - DMX_CRC_CHECKING | - DMX_TS_DESCRAMBLING; - - mpq_demux->decoder_alloc_flags = ION_FLAG_CACHED; - - /* Set dvb-demux "virtual" function pointers */ - mpq_demux->demux.priv = (void *)mpq_demux; - mpq_demux->demux.filternum = DMX_TSIF_MAX_SECTION_FILTER_NUM; - mpq_demux->demux.feednum = MPQ_MAX_DMX_FILES; - mpq_demux->demux.start_feed = mpq_tsif_dmx_start_filtering; - mpq_demux->demux.stop_feed = mpq_tsif_dmx_stop_filtering; - mpq_demux->demux.write_to_decoder = mpq_tsif_dmx_write_to_decoder; - mpq_demux->demux.decoder_fullness_init = mpq_dmx_decoder_fullness_init; - mpq_demux->demux.decoder_fullness_wait = mpq_dmx_decoder_fullness_wait; - mpq_demux->demux.decoder_fullness_abort = - mpq_dmx_decoder_fullness_abort; - mpq_demux->demux.decoder_buffer_status = mpq_dmx_decoder_buffer_status; - mpq_demux->demux.reuse_decoder_buffer = mpq_dmx_reuse_decoder_buffer; - mpq_demux->demux.set_secure_mode = NULL; - mpq_demux->demux.oob_command = mpq_dmx_oob_command; - mpq_demux->demux.convert_ts = mpq_dmx_convert_tts; - - /* Initialize dvb_demux object */ - result = dvb_dmx_init(&mpq_demux->demux); - if (result < 0) { - MPQ_DVB_ERR_PRINT("%s: dvb_dmx_init failed\n", __func__); - goto init_failed; - } - - /* Now initailize the dmx-dev object */ - mpq_demux->dmxdev.filternum = MPQ_MAX_DMX_FILES; - mpq_demux->dmxdev.demux = &mpq_demux->demux.dmx; - mpq_demux->dmxdev.capabilities = DMXDEV_CAP_DUPLEX; - - mpq_demux->dmxdev.demux->set_source = mpq_dmx_set_source; - mpq_demux->dmxdev.demux->get_stc = mpq_tsif_dmx_get_stc; - mpq_demux->dmxdev.demux->get_caps = mpq_tsif_dmx_get_caps; - mpq_demux->dmxdev.demux->map_buffer = mpq_dmx_map_buffer; - mpq_demux->dmxdev.demux->unmap_buffer = mpq_dmx_unmap_buffer; - - result = dvb_dmxdev_init(&mpq_demux->dmxdev, mpq_adapter); - if (result < 0) { - MPQ_DVB_ERR_PRINT("%s: dvb_dmxdev_init failed (errno=%d)\n", - __func__, - result); - goto init_failed_dmx_release; - } - - /* Extend dvb-demux debugfs with TSIF statistics. */ - mpq_dmx_init_debugfs_entries(mpq_demux); - - return 0; - -init_failed_dmx_release: - dvb_dmx_release(&mpq_demux->demux); -init_failed: - return result; -} - - -/** - * Module initialization function. - * - * Return error code - */ -static int __init mpq_dmx_tsif_plugin_init(void) -{ - int i; - int ret; - int tsif_mode = mpq_dmx_get_param_tsif_mode(); - - MPQ_DVB_DBG_PRINT("%s executed\n", __func__); - - /* check module parameters validity */ - if (threshold < 1) { - MPQ_DVB_ERR_PRINT( - "%s: invalid threshold parameter, using %d instead\n", - __func__, DMX_TSIF_PACKETS_IN_CHUNK_DEF); - threshold = DMX_TSIF_PACKETS_IN_CHUNK_DEF; - } - if ((tsif_mode < 1) || (tsif_mode > 3)) { - MPQ_DVB_ERR_PRINT( - "%s: invalid mode parameter, using %d instead\n", - __func__, DMX_TSIF_DRIVER_MODE_DEF); - tsif_mode = DMX_TSIF_DRIVER_MODE_DEF; - } - - for (i = 0; i < TSIF_COUNT; i++) { - snprintf(mpq_dmx_tsif_info.tsif[i].name, - TSIF_NAME_LENGTH, - "dmx_tsif%d", - i); - - atomic_set(&mpq_dmx_tsif_info.tsif[i].data_cnt, 0); - init_waitqueue_head(&mpq_dmx_tsif_info.tsif[i].wait_queue); - mpq_dmx_tsif_info.tsif[i].thread = - kthread_run( - mpq_dmx_tsif_thread, (void *)i, - mpq_dmx_tsif_info.tsif[i].name); - - if (IS_ERR(mpq_dmx_tsif_info.tsif[i].thread)) { - int j; - - for (j = 0; j < i; j++) { - kthread_stop(mpq_dmx_tsif_info.tsif[j].thread); - mutex_destroy(&mpq_dmx_tsif_info.tsif[j].mutex); - } - - MPQ_DVB_ERR_PRINT( - "%s: kthread_run failed\n", - __func__); - - return -ENOMEM; - } - - mutex_init(&mpq_dmx_tsif_info.tsif[i].mutex); - - mpq_dmx_tsif_info.tsif[i].tsif_driver.tsif_handler = NULL; - mpq_dmx_tsif_info.tsif[i].ref_count = 0; - } - - ret = mpq_dmx_plugin_init(mpq_tsif_dmx_init); - - if (ret < 0) { - MPQ_DVB_ERR_PRINT( - "%s: mpq_dmx_plugin_init failed (errno=%d)\n", - __func__, - ret); - - for (i = 0; i < TSIF_COUNT; i++) { - kthread_stop(mpq_dmx_tsif_info.tsif[i].thread); - mutex_destroy(&mpq_dmx_tsif_info.tsif[i].mutex); - } - } - - return ret; -} - - -/** - * Module exit function. - */ -static void __exit mpq_dmx_tsif_plugin_exit(void) -{ - int i; - struct tsif_driver_info *tsif_driver; - - MPQ_DVB_DBG_PRINT("%s executed\n", __func__); - - for (i = 0; i < TSIF_COUNT; i++) { - mutex_lock(&mpq_dmx_tsif_info.tsif[i].mutex); - - tsif_driver = &(mpq_dmx_tsif_info.tsif[i].tsif_driver); - if (mpq_dmx_tsif_info.tsif[i].ref_count > 0) { - mpq_dmx_tsif_info.tsif[i].ref_count = 0; - if (tsif_driver->tsif_handler) - tsif_stop(tsif_driver->tsif_handler); - } - - /* Detach from TSIF driver to avoid further notifications. */ - if (tsif_driver->tsif_handler) - tsif_detach(tsif_driver->tsif_handler); - - mutex_unlock(&mpq_dmx_tsif_info.tsif[i].mutex); - kthread_stop(mpq_dmx_tsif_info.tsif[i].thread); - mutex_destroy(&mpq_dmx_tsif_info.tsif[i].mutex); - } - - mpq_dmx_plugin_exit(); -} - - -module_init(mpq_dmx_tsif_plugin_init); -module_exit(mpq_dmx_tsif_plugin_exit); - -MODULE_DESCRIPTION("Qualcomm demux TSIF HW Plugin"); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/media/platform/msm/vcap/Kconfig b/drivers/media/platform/msm/vcap/Kconfig index db3bc47cb124b5320f8f1d36a95c7c5de953f5ba..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/drivers/media/platform/msm/vcap/Kconfig +++ b/drivers/media/platform/msm/vcap/Kconfig @@ -1,6 +0,0 @@ -config MSM_VCAP - tristate "Qualcomm MSM VCAP" - depends on VIDEO_DEV && VIDEO_V4L2 - ---help--- - Enables VCAP driver. This device allows for video capture and - video processing using the v4l2 api diff --git a/drivers/media/platform/msm/vcap/Makefile b/drivers/media/platform/msm/vcap/Makefile deleted file mode 100644 index b9c6e4c7f975aac2f6a5cc2f758f8e5818620674..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/vcap/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -obj-$(CONFIG_MSM_VCAP) += vcap_v4l2.o -obj-$(CONFIG_MSM_VCAP) += vcap_vc.o -obj-$(CONFIG_MSM_VCAP) += vcap_vp.o diff --git a/drivers/media/platform/msm/vcap/vcap_v4l2.c b/drivers/media/platform/msm/vcap/vcap_v4l2.c deleted file mode 100644 index 8fc8136963c692eacbe9804fc9d083fe584be859..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/vcap/vcap_v4l2.c +++ /dev/null @@ -1,2507 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "vcap_vc.h" -#include "vcap_vp.h" - -#define NUM_INPUTS 1 -#define MSM_VCAP_DRV_NAME "msm_vcap" - -static struct vcap_dev *vcap_ctrl; - -#ifdef CONFIG_DEBUG_FS -static struct dentry *vcap_debugfs_base; -static struct reg_range debug_reg_range[] = { - { - VCAP_REG_RANGE_1_MIN, - VCAP_REG_RANGE_1_MAX, - }, - { - VCAP_REG_RANGE_2_MIN, - VCAP_REG_RANGE_2_MAX, - }, - { - VCAP_REG_RANGE_3_MIN, - VCAP_REG_RANGE_3_MAX, - }, - { - VCAP_REG_RANGE_4_MIN, - VCAP_REG_RANGE_4_MAX, - }, - { - VCAP_REG_RANGE_5_MIN, - VCAP_REG_RANGE_5_MAX, - }, -}; -#endif - -static int vcap_reg_powerup(struct vcap_dev *dev) -{ - dev->fs_vcap = regulator_get(dev->ddev, "fs_vcap"); - if (IS_ERR(dev->fs_vcap)) { - pr_err("%s: Regulator FS_VCAP get failed %ld\n", __func__, - PTR_ERR(dev->fs_vcap)); - dev->fs_vcap = NULL; - return -EINVAL; - } else if (regulator_enable(dev->fs_vcap)) { - pr_err("%s: Regulator FS_VCAP enable failed\n", __func__); - regulator_put(dev->fs_vcap); - return -EINVAL; - } - return 0; -} - -static void vcap_reg_powerdown(struct vcap_dev *dev) -{ - if (dev->fs_vcap == NULL) - return; - regulator_disable(dev->fs_vcap); - regulator_put(dev->fs_vcap); - dev->fs_vcap = NULL; - return; -} - -static int vcap_config_gpios(int on, struct vcap_platform_data *pdata) -{ - int i, ret; - int num_gpios = pdata->num_gpios; - unsigned *gpios = pdata->gpios; - - pr_debug("GPIO config start\n"); - if (on) { - for (i = 0; i < num_gpios; i++) { - ret = gpio_request(gpios[i], "vcap:vc"); - if (ret) { - pr_err("VCAP: failed at GPIO %d to request\n", - gpios[i]); - goto gpio_failed; - } - ret = gpio_direction_input(gpios[i]); - if (ret) { - pr_err("VCAP: failed at GPIO %d to set to input\n", - gpios[i]); - i++; - goto gpio_failed; - } - } - } else { - for (i = 0; i < num_gpios; i++) - gpio_free(gpios[i]); - } - pr_debug("GPIO config exit\n"); - return 0; -gpio_failed: - for (i--; i >= 0; i--) - gpio_free(gpios[i]); - return -EINVAL; -} - -static int vcap_clk_powerup(struct vcap_dev *dev, struct device *ddev, - unsigned long rate) -{ - int ret = 0; - - dev->vcap_clk = clk_get(ddev, "core_clk"); - if (IS_ERR(dev->vcap_clk)) { - dev->vcap_clk = NULL; - pr_err("%s: Could not clk_get core_clk\n", __func__); - clk_put(dev->vcap_clk); - dev->vcap_clk = NULL; - return -EINVAL; - } - - clk_prepare(dev->vcap_clk); - ret = clk_enable(dev->vcap_clk); - if (ret) { - pr_err("%s: Failed core clk_enable %d\n", __func__, ret); - goto fail_vcap_clk_unprep; - } - - rate = clk_round_rate(dev->vcap_clk, rate); - if (rate < 0) { - pr_err("%s: Failed core rnd_rate\n", __func__); - goto fail_vcap_clk; - } - ret = clk_set_rate(dev->vcap_clk, rate); - if (ret < 0) { - pr_err("%s: Failed core set_rate %d\n", __func__, ret); - goto fail_vcap_clk; - } - dev->dbg_p.clk_rate = (uint32_t) rate; - - dev->vcap_npl_clk = clk_get(ddev, "vcap_npl_clk"); - if (IS_ERR(dev->vcap_npl_clk)) { - dev->vcap_npl_clk = NULL; - pr_err("%s: Could not clk_get npl\n", __func__); - clk_put(dev->vcap_npl_clk); - dev->vcap_npl_clk = NULL; - goto fail_vcap_clk; - } - - clk_prepare(dev->vcap_npl_clk); - ret = clk_enable(dev->vcap_npl_clk); - if (ret) { - pr_err("%s:Failed npl clk_enable %d\n", __func__, ret); - goto fail_vcap_npl_clk_unprep; - } - - dev->vcap_p_clk = clk_get(ddev, "iface_clk"); - if (IS_ERR(dev->vcap_p_clk)) { - dev->vcap_p_clk = NULL; - pr_err("%s: Could not clk_get pix(AHB)\n", __func__); - clk_put(dev->vcap_p_clk); - dev->vcap_p_clk = NULL; - goto fail_vcap_npl_clk; - } - - clk_prepare(dev->vcap_p_clk); - ret = clk_enable(dev->vcap_p_clk); - if (ret) { - pr_err("%s: Failed pix(AHB) clk_enable %d\n", __func__, ret); - goto fail_vcap_p_clk_unprep; - } - return 0; - -fail_vcap_p_clk_unprep: - clk_unprepare(dev->vcap_p_clk); - clk_put(dev->vcap_p_clk); - dev->vcap_p_clk = NULL; - -fail_vcap_npl_clk: - clk_disable(dev->vcap_npl_clk); -fail_vcap_npl_clk_unprep: - clk_unprepare(dev->vcap_npl_clk); - clk_put(dev->vcap_npl_clk); - dev->vcap_npl_clk = NULL; - -fail_vcap_clk: - dev->dbg_p.clk_rate = 0; - clk_disable(dev->vcap_clk); -fail_vcap_clk_unprep: - clk_unprepare(dev->vcap_clk); - clk_put(dev->vcap_clk); - dev->vcap_clk = NULL; - return -EINVAL; -} - -static void vcap_clk_powerdown(struct vcap_dev *dev) -{ - if (dev->vcap_p_clk != NULL) { - clk_disable(dev->vcap_p_clk); - clk_unprepare(dev->vcap_p_clk); - clk_put(dev->vcap_p_clk); - dev->vcap_p_clk = NULL; - } - - if (dev->vcap_npl_clk != NULL) { - clk_disable(dev->vcap_npl_clk); - clk_unprepare(dev->vcap_npl_clk); - clk_put(dev->vcap_npl_clk); - dev->vcap_npl_clk = NULL; - } - - if (dev->vcap_clk != NULL) { - clk_disable(dev->vcap_clk); - clk_unprepare(dev->vcap_clk); - clk_put(dev->vcap_clk); - dev->vcap_clk = NULL; - } - - dev->dbg_p.clk_rate = 0; -} - -static int vcap_get_bus_client_handle(struct vcap_dev *dev) -{ - struct msm_bus_scale_pdata *vcap_axi_client_pdata = - dev->vcap_pdata->bus_client_pdata; - dev->bus_client_handle = - msm_bus_scale_register_client(vcap_axi_client_pdata); - - return 0; -} - -static int vcap_enable(struct vcap_dev *dev, struct device *ddev, - unsigned long rate) -{ - int rc; - pr_debug("Enter %s", __func__); - - rc = vcap_reg_powerup(dev); - if (rc < 0) - goto reg_failed; - rc = vcap_clk_powerup(dev, ddev, rate); - if (rc < 0) - goto clk_failed; - rc = vcap_get_bus_client_handle(dev); - if (rc < 0) - goto bus_r_failed; - rc = vcap_config_gpios(1, dev->vcap_pdata); - if (rc < 0) - goto gpio_failed; - rc = iommu_attach_device(dev->iommu_vcap_domain, dev->vc_iommu_ctx); - if (rc < 0) - goto vc_iommu_attach_failed; - rc = iommu_attach_device(dev->iommu_vcap_domain, dev->vp_iommu_ctx); - if (rc < 0) - goto vp_iommu_attach_failed; - writel_relaxed(0x00030003, VCAP_OFFSET(0xD78)); - writel_relaxed(0x00030003, VCAP_OFFSET(0xD7C)); - pr_debug("Success Exit %s", __func__); - return 0; - -vp_iommu_attach_failed: - iommu_detach_device(dev->iommu_vcap_domain, dev->vc_iommu_ctx); -vc_iommu_attach_failed: - vcap_config_gpios(0, dev->vcap_pdata); -gpio_failed: - msm_bus_scale_unregister_client(dev->bus_client_handle); - dev->bus_client_handle = 0; -bus_r_failed: - vcap_clk_powerdown(dev); -clk_failed: - vcap_reg_powerdown(dev); -reg_failed: - return rc; -} - -static int vcap_disable(struct vcap_dev *dev) -{ - pr_debug("Enter %s", __func__); - iommu_detach_device(dev->iommu_vcap_domain, dev->vp_iommu_ctx); - iommu_detach_device(dev->iommu_vcap_domain, dev->vc_iommu_ctx); - - vcap_config_gpios(0, dev->vcap_pdata); - - msm_bus_scale_unregister_client(dev->bus_client_handle); - dev->bus_client_handle = 0; - dev->dbg_p.bw_request = 0; - vcap_clk_powerdown(dev); - vcap_reg_powerdown(dev); - return 0; -} - -static int vcap_register_domain(void) -{ - struct msm_iova_partition vcap_partition = { - .start = 0, - .size = SZ_2G, - }; - struct msm_iova_layout vcap_layout = { - .partitions = &vcap_partition, - .npartitions = 1, - .client_name = "vcap", - .domain_flags = 0, - }; - - return msm_register_domain(&vcap_layout); -} - -enum vcap_op_mode determine_mode(struct vcap_client_data *cd) -{ - if (cd->set_cap == 1 && cd->set_vp_o == 0 && - cd->set_decode == 0) - return VC_VCAP_OP; - else if (cd->set_cap == 1 && cd->set_vp_o == 1 && - cd->set_decode == 0) - return VC_AND_VP_VCAP_OP; - else if (cd->set_cap == 0 && cd->set_vp_o == 1 && - cd->set_decode == 1) - return VP_VCAP_OP; - else - return UNKNOWN_VCAP_OP; -} - -void dealloc_resources(struct vcap_client_data *cd) -{ - cd->set_cap = false; - cd->set_decode = false; - cd->set_vp_o = false; -} - -/* VCAP Internal QBUF and DQBUF for VC + VP */ -int vcvp_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) -{ - struct vb2_buffer *vb; - - if (q->fileio) { - pr_debug("%s: file io in progress\n", __func__); - return -EBUSY; - } - - if (b->type != q->type) { - pr_debug("%s: invalid buffer type\n", __func__); - return -EINVAL; - } - - if (b->index >= q->num_buffers) { - pr_debug("%s: buffer index out of range\n", __func__); - return -EINVAL; - } - - vb = q->bufs[b->index]; - if (NULL == vb) { - pr_debug("%s: buffer is NULL\n", __func__); - return -EINVAL; - } - - if (b->memory != q->memory) { - pr_debug("%s: invalid memory type\n", __func__); - return -EINVAL; - } - - if (vb->state != VB2_BUF_STATE_DEQUEUED && - vb->state != VB2_BUF_STATE_PREPARED) { - pr_err("%s: buffer already in use\n", __func__); - return -EINVAL; - } - - vb->v4l2_buf.timestamp = b->timestamp; - vb->v4l2_buf.field = b->field; - list_add_tail(&vb->queued_entry, &q->queued_list); - vb->state = VB2_BUF_STATE_QUEUED; - - if (q->streaming) { - vb->state = VB2_BUF_STATE_ACTIVE; - atomic_inc(&q->queued_count); - q->ops->buf_queue(vb); - } - return 0; -} - -int vcvp_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b) -{ - struct vb2_buffer *vb = NULL; - unsigned long flags; - - if (q->fileio) { - pr_debug("%s: file io in progress\n", __func__); - return -EBUSY; - } - - if (b->type != q->type) { - pr_debug("%s: invalid buffer type\n", __func__); - return -EINVAL; - } - - if (!q->streaming) { - pr_debug("Streaming off, will not wait for buffers\n"); - return -EINVAL; - } - - if (!list_empty(&q->done_list)) { - spin_lock_irqsave(&q->done_lock, flags); - vb = list_first_entry(&q->done_list, struct vb2_buffer, - done_entry); - list_del(&vb->done_entry); - spin_unlock_irqrestore(&q->done_lock, flags); - - switch (vb->state) { - case VB2_BUF_STATE_DONE: - pr_debug("%s: Returning done buffer\n", __func__); - break; - case VB2_BUF_STATE_ERROR: - pr_debug("%s: Ret done buf with err\n", __func__); - break; - default: - pr_debug("%s: Invalid buffer state\n", __func__); - return -EINVAL; - } - - memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); - - list_del(&vb->queued_entry); - - vb->state = VB2_BUF_STATE_DEQUEUED; - return 0; - } - - pr_debug("%s: No buffers to dequeue\n", __func__); - return -EAGAIN; -} - -int get_phys_addr(struct vcap_dev *dev, struct vb2_queue *q, - struct v4l2_buffer *b) -{ - struct vb2_buffer *vb; - struct vcap_buffer *buf; - unsigned long len, offset; - int rc; - - if (q->fileio) { - pr_debug("%s: file io in progress\n", __func__); - return -EBUSY; - } - - if (b->type != q->type) { - pr_debug("%s: invalid buffer type\n", __func__); - return -EINVAL; - } - - if (b->index >= q->num_buffers) { - pr_debug("%s: buffer index out of range\n", __func__); - return -EINVAL; - } - - vb = q->bufs[b->index]; - if (NULL == vb) { - pr_debug("%s: buffer is NULL\n", __func__); - return -EINVAL; - } - - if (vb->state != VB2_BUF_STATE_DEQUEUED) { - pr_debug("%s: buffer already in use\n", __func__); - return -EINVAL; - } - - buf = container_of(vb, struct vcap_buffer, vb); - - buf->ion_handle = ion_import_dma_buf(dev->ion_client, b->m.userptr); - if (IS_ERR_OR_NULL((void *)buf->ion_handle)) { - pr_err("%s: Could not alloc memory\n", __func__); - buf->ion_handle = NULL; - return -ENOMEM; - } - rc = ion_map_iommu(dev->ion_client, buf->ion_handle, - dev->domain_num, 0, SZ_4K, 0, &buf->paddr, &len, - 0, 0); - if (rc < 0) { - pr_err("%s: Could not get phys addr\n", __func__); - ion_free(dev->ion_client, buf->ion_handle); - buf->ion_handle = NULL; - return -EFAULT; - } - - offset = b->reserved; - buf->paddr += offset; - return 0; -} - -void free_ion_handle_work(struct vcap_client_data *c_data, - struct vb2_buffer *vb) -{ - struct vcap_buffer *buf; - struct vcap_dev *dev = c_data->dev; - struct ion_handle *handle; - unsigned long flags = 0; - - buf = container_of(vb, struct vcap_buffer, vb); - - spin_lock_irqsave(&c_data->cap_slock, flags); - handle = buf->ion_handle; - buf->ion_handle = NULL; - spin_unlock_irqrestore(&c_data->cap_slock, flags); - - if (handle == NULL) { - pr_debug("%s: no ION handle to free\n", __func__); - return; - } - buf->paddr = 0; - ion_unmap_iommu(dev->ion_client, handle, dev->domain_num, 0); - ion_free(dev->ion_client, handle); - return; -} - -int free_ion_handle(struct vcap_client_data *c_data, struct vb2_queue *q, - struct v4l2_buffer *b) -{ - struct vb2_buffer *vb; - - if (q->fileio) - return -EBUSY; - - if (b->type != q->type) - return -EINVAL; - - if (b->index >= q->num_buffers) - return -EINVAL; - - vb = q->bufs[b->index]; - if (NULL == vb) - return -EINVAL; - - free_ion_handle_work(c_data, vb); - return 0; -} - -void free_ion_on_q_bufs(struct vb2_queue *vq) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(vq); - struct vb2_buffer *vb; - - if (!vq->streaming) { - list_for_each_entry(vb, &vq->queued_list, queued_entry) - free_ion_handle_work(c_data, vb); - } -} - -/* VC Videobuf operations */ -static void wait_prepare(struct vb2_queue *q) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(q); - mutex_unlock(&c_data->mutex); -} - -static void wait_finish(struct vb2_queue *q) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(q); - mutex_lock(&c_data->mutex); -} - -static int capture_queue_setup(struct vb2_queue *vq, - const struct v4l2_format *fmt, - unsigned int *nbuffers, - unsigned int *nplanes, unsigned int sizes[], - void *alloc_ctxs[]) -{ - *nbuffers += vcap_ctrl->vc_tot_buf; - if (*nbuffers > VIDEO_MAX_FRAME) - return -EINVAL; - *nplanes = 1; - return 0; -} - -static int capture_buffer_init(struct vb2_buffer *vb) -{ - return 0; -} - -static int capture_buffer_prepare(struct vb2_buffer *vb) -{ - return 0; -} - -static void capture_buffer_queue(struct vb2_buffer *vb) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(vb->vb2_queue); - struct vcap_buffer *buf = container_of(vb, struct vcap_buffer, vb); - struct vc_action *vc_action = &c_data->vc_action; - struct vb2_queue *q = vb->vb2_queue; - unsigned long flags = 0; - - spin_lock_irqsave(&c_data->cap_slock, flags); - list_add_tail(&buf->list, &vc_action->active); - spin_unlock_irqrestore(&c_data->cap_slock, flags); - - if (atomic_read(&c_data->dev->vc_enabled) == 0) { - if (atomic_read(&q->queued_count) >= c_data->vc_action.tot_buf) - if (vc_hw_kick_off(c_data) == 0) - atomic_set(&c_data->dev->vc_enabled, 1); - } -} - -static int capture_start_streaming(struct vb2_queue *vq, unsigned int count) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(vq); - pr_debug("VC start streaming\n"); - return vc_start_capture(c_data); -} - -static int capture_stop_streaming(struct vb2_queue *vq) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(vq); - struct vb2_buffer *vb; - - vc_stop_capture(c_data); - - while (!list_empty(&c_data->vc_action.active)) { - struct vcap_buffer *buf; - buf = list_entry(c_data->vc_action.active.next, - struct vcap_buffer, list); - list_del(&buf->list); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); - } - - /* clean ion handles */ - list_for_each_entry(vb, &vq->queued_list, queued_entry) - free_ion_handle_work(c_data, vb); - return 0; -} - -static int capture_buffer_finish(struct vb2_buffer *vb) -{ - return 0; -} - -static void capture_buffer_cleanup(struct vb2_buffer *vb) -{ -} - -static struct vb2_ops capture_video_qops = { - .queue_setup = capture_queue_setup, - .wait_finish = wait_finish, - .wait_prepare = wait_prepare, - .buf_init = capture_buffer_init, - .buf_prepare = capture_buffer_prepare, - .buf_queue = capture_buffer_queue, - .start_streaming = capture_start_streaming, - .stop_streaming = capture_stop_streaming, - .buf_finish = capture_buffer_finish, - .buf_cleanup = capture_buffer_cleanup, -}; - -/* VP I/P Videobuf operations */ - -static int vp_in_queue_setup(struct vb2_queue *vq, - const struct v4l2_format *fmt, - unsigned int *nbuffers, - unsigned int *nplanes, unsigned int sizes[], - void *alloc_ctxs[]) -{ - if (*nbuffers >= VIDEO_MAX_FRAME && *nbuffers < 5) - *nbuffers = 5; - - *nplanes = 1; - return 0; -} - -static int vp_in_buffer_init(struct vb2_buffer *vb) -{ - return 0; -} - -static int vp_in_buffer_prepare(struct vb2_buffer *vb) -{ - return 0; -} - -static void vp_in_buffer_queue(struct vb2_buffer *vb) -{ - struct vcap_client_data *cd = vb2_get_drv_priv(vb->vb2_queue); - struct vcap_buffer *buf = container_of(vb, struct vcap_buffer, vb); - struct vp_action *vp_act = &cd->vp_action; - struct vb2_queue *q = vb->vb2_queue; - unsigned long flags = 0; - - spin_lock_irqsave(&cd->cap_slock, flags); - list_add_tail(&buf->list, &vp_act->in_active); - spin_unlock_irqrestore(&cd->cap_slock, flags); - - if (atomic_read(&cd->dev->vp_enabled) == 0) { - if (cd->vp_action.vp_state == VP_FRAME1) { - if (atomic_read(&q->queued_count) > 1 && - atomic_read(&cd->vp_out_vidq.queued_count) > 0) - /* Valid code flow for VC-VP mode */ - kickoff_vp(cd); - } else { - /* VP has already kicked off just needs cont */ - continue_vp(cd); - } - } -} - -static int vp_in_start_streaming(struct vb2_queue *vq, unsigned int count) -{ - pr_debug("VP IN start streaming\n"); - return 0; -} - -static int vp_in_stop_streaming(struct vb2_queue *vq) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(vq); - struct vb2_buffer *vb; - - pr_debug("VP IN stop streaming\n"); - vp_stop_capture(c_data); - - while (!list_empty(&c_data->vp_action.in_active)) { - struct vcap_buffer *buf; - buf = list_entry(c_data->vp_action.in_active.next, - struct vcap_buffer, list); - list_del(&buf->list); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); - } - - /* clean ion handles */ - list_for_each_entry(vb, &vq->queued_list, queued_entry) - free_ion_handle_work(c_data, vb); - return 0; -} - -static int vp_in_buffer_finish(struct vb2_buffer *vb) -{ - return 0; -} - -static void vp_in_buffer_cleanup(struct vb2_buffer *vb) -{ -} - -static struct vb2_ops vp_in_video_qops = { - .queue_setup = vp_in_queue_setup, - .wait_finish = wait_finish, - .wait_prepare = wait_prepare, - .buf_init = vp_in_buffer_init, - .buf_prepare = vp_in_buffer_prepare, - .buf_queue = vp_in_buffer_queue, - .start_streaming = vp_in_start_streaming, - .stop_streaming = vp_in_stop_streaming, - .buf_finish = vp_in_buffer_finish, - .buf_cleanup = vp_in_buffer_cleanup, -}; - - -/* VP O/P Videobuf operations */ - -static int vp_out_queue_setup(struct vb2_queue *vq, - const struct v4l2_format *fmt, - unsigned int *nbuffers, - unsigned int *nplanes, unsigned int sizes[], - void *alloc_ctxs[]) -{ - if (*nbuffers >= VIDEO_MAX_FRAME && *nbuffers < 3) - *nbuffers = 3; - - *nplanes = 1; - return 0; -} - -static int vp_out_buffer_init(struct vb2_buffer *vb) -{ - return 0; -} - -static int vp_out_buffer_prepare(struct vb2_buffer *vb) -{ - return 0; -} - -static void vp_out_buffer_queue(struct vb2_buffer *vb) -{ - struct vcap_client_data *cd = vb2_get_drv_priv(vb->vb2_queue); - struct vcap_buffer *buf = container_of(vb, struct vcap_buffer, vb); - struct vp_action *vp_act = &cd->vp_action; - struct vb2_queue *q = vb->vb2_queue; - unsigned long flags = 0; - - spin_lock_irqsave(&cd->cap_slock, flags); - list_add_tail(&buf->list, &vp_act->out_active); - spin_unlock_irqrestore(&cd->cap_slock, flags); - - if (atomic_read(&cd->dev->vp_enabled) == 0) { - if (cd->vp_action.vp_state == VP_FRAME1) { - if (atomic_read(&q->queued_count) > 0 && - atomic_read(& - cd->vp_in_vidq.queued_count) > 1) - kickoff_vp(cd); - } else { - /* VP has already kicked off just needs cont */ - continue_vp(cd); - } - } -} - -static int vp_out_start_streaming(struct vb2_queue *vq, unsigned int count) -{ - return 0; -} - -static int vp_out_stop_streaming(struct vb2_queue *vq) -{ - struct vcap_client_data *c_data = vb2_get_drv_priv(vq); - struct vb2_buffer *vb; - - pr_debug("VP OUT q stop streaming\n"); - vp_stop_capture(c_data); - - while (!list_empty(&c_data->vp_action.out_active)) { - struct vcap_buffer *buf; - buf = list_entry(c_data->vp_action.out_active.next, - struct vcap_buffer, list); - list_del(&buf->list); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); - } - - /* clean ion handles */ - list_for_each_entry(vb, &vq->queued_list, queued_entry) - free_ion_handle_work(c_data, vb); - return 0; -} - -static int vp_out_buffer_finish(struct vb2_buffer *vb) -{ - return 0; -} - -static void vp_out_buffer_cleanup(struct vb2_buffer *vb) -{ -} - -static struct vb2_ops vp_out_video_qops = { - .queue_setup = vp_out_queue_setup, - .wait_finish = wait_finish, - .wait_prepare = wait_prepare, - .buf_init = vp_out_buffer_init, - .buf_prepare = vp_out_buffer_prepare, - .buf_queue = vp_out_buffer_queue, - .start_streaming = vp_out_start_streaming, - .stop_streaming = vp_out_stop_streaming, - .buf_finish = vp_out_buffer_finish, - .buf_cleanup = vp_out_buffer_cleanup, -}; - -/* IOCTL vidioc handling */ - -static int vidioc_querycap(struct file *file, void *priv, - struct v4l2_capability *cap) -{ - struct vcap_dev *dev = video_drvdata(file); - - strlcpy(cap->driver, MSM_VCAP_DRV_NAME, sizeof(cap->driver)); - strlcpy(cap->card, MSM_VCAP_DRV_NAME, sizeof(cap->card)); - strlcpy(cap->bus_info, dev->v4l2_dev.name, sizeof(cap->bus_info)); - cap->version = 0x10000000; - cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; - return 0; -} - -static int vidioc_enum_input(struct file *file, void *priv, - struct v4l2_input *inp) -{ - if (inp->index >= NUM_INPUTS) - return -EINVAL; - return 0; -} - -static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) -{ - return 0; -} - -static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) -{ - return 0; -} - -static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) -{ - int size; - struct vcap_priv_fmt *priv_fmt; - struct v4l2_format_vc_ext *vc_format; - struct vcap_client_data *c_data = to_client_data(file->private_data); - - priv_fmt = (struct vcap_priv_fmt *) f->fmt.raw_data; - - switch (priv_fmt->type) { - case VC_TYPE: - vc_format = (struct v4l2_format_vc_ext *) &priv_fmt->u.timing; - c_data->vc_format = *vc_format; - c_data->stride = priv_fmt->stride; - - size = (c_data->vc_format.hactive_end - - c_data->vc_format.hactive_start); - if (c_data->stride == VC_STRIDE_32) - size = VCAP_STRIDE_CALC(size, VCAP_STRIDE_ALIGN_32); - else - size = VCAP_STRIDE_CALC(size, VCAP_STRIDE_ALIGN_16); - - - if (c_data->vc_format.color_space) - size *= 3; - else - size *= 2; - - priv_fmt->u.timing.bytesperline = size; - size *= (c_data->vc_format.vactive_end - - c_data->vc_format.vactive_start); - priv_fmt->u.timing.sizeimage = size; - c_data->set_cap = true; - break; - case VP_IN_TYPE: - c_data->vp_in_fmt.width = priv_fmt->u.pix.width; - c_data->vp_in_fmt.height = priv_fmt->u.pix.height; - c_data->vp_in_fmt.pixfmt = priv_fmt->u.pix.pixelformat; - - size = c_data->vp_in_fmt.width * c_data->vp_in_fmt.height; - if (c_data->vp_in_fmt.pixfmt == V4L2_PIX_FMT_NV16) - size = size * 2; - else - size = size / 2 * 3; - priv_fmt->u.pix.sizeimage = size; - c_data->set_decode = true; - break; - case VP_OUT_TYPE: - c_data->vp_out_fmt.width = priv_fmt->u.pix.width; - c_data->vp_out_fmt.height = priv_fmt->u.pix.height; - c_data->vp_out_fmt.pixfmt = priv_fmt->u.pix.pixelformat; - - size = c_data->vp_out_fmt.width * c_data->vp_out_fmt.height; - if (c_data->vp_out_fmt.pixfmt == V4L2_PIX_FMT_NV16) - size = size * 2; - else - size = size / 2 * 3; - priv_fmt->u.pix.sizeimage = size; - c_data->set_vp_o = true; - break; - default: - break; - } - - return 0; -} - -static int vidioc_reqbufs(struct file *file, void *priv, - struct v4l2_requestbuffers *rb) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - struct vcap_dev *dev = c_data->dev; - int rc; - - pr_debug("VCAP: In Req Buf %08x\n", (unsigned int)rb->type); - c_data->op_mode = determine_mode(c_data); - if (c_data->op_mode == UNKNOWN_VCAP_OP) { - pr_err("VCAP Error: %s: VCAP in unknown mode\n", __func__); - return -ENOTRECOVERABLE; - } - - switch (rb->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - if (c_data->op_mode == VC_AND_VP_VCAP_OP) { - if (c_data->vc_format.color_space) { - pr_err("VCAP Err: %s: VP No RGB support\n", - __func__); - return -ENOTRECOVERABLE; - } - if (!c_data->vc_format.mode) { - pr_err("VCAP Err: VP No prog support\n"); - return -ENOTRECOVERABLE; - } - if (rb->count <= VCAP_VP_MIN_BUF) { - pr_err("VCAP Err: Not enough buf for VC_VP\n"); - return -EINVAL; - } - rc = vb2_reqbufs(&c_data->vc_vidq, rb); - if (rc < 0) - return rc; - - c_data->vp_in_fmt.width = - (c_data->vc_format.hactive_end - - c_data->vc_format.hactive_start); - c_data->vp_in_fmt.height = - (c_data->vc_format.vactive_end - - c_data->vc_format.vactive_start); - /* VC outputs YCbCr 4:2:2 */ - c_data->vp_in_fmt.pixfmt = V4L2_PIX_FMT_NV16; - rb->type = V4L2_BUF_TYPE_INTERLACED_IN_DECODER; - rc = vb2_reqbufs(&c_data->vp_in_vidq, rb); - rb->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - c_data->vc_action.tot_buf = dev->vc_tot_buf; - return rc; - - } else { - rc = vb2_reqbufs(&c_data->vc_vidq, rb); - c_data->vc_action.tot_buf = dev->vc_tot_buf; - return rc; - } - case V4L2_BUF_TYPE_INTERLACED_IN_DECODER: - return vb2_reqbufs(&c_data->vp_in_vidq, rb); - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - return vb2_reqbufs(&c_data->vp_out_vidq, rb); - default: - pr_err("VCAP Error: %s: Unknown buffer type\n", __func__); - return -EINVAL; - } - return 0; -} - -static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - - switch (p->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - return vb2_querybuf(&c_data->vc_vidq, p); - default: - pr_err("VCAP Error: %s: Unknown buffer type\n", __func__); - return -EINVAL; - } - return 0; -} - -static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - struct vb2_buffer *vb; - struct vb2_queue *q; - int rc; - - pr_debug("VCAP In Q Buf %08x\n", (unsigned int)p->type); - switch (p->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - if (c_data->op_mode == VC_AND_VP_VCAP_OP) { - /* If buffer in vp_in_q it will be coming back */ - q = &c_data->vp_in_vidq; - if (p->index >= q->num_buffers) { - pr_debug("VCAP qbuf: buffer index out of range\n"); - return -EINVAL; - } - - vb = q->bufs[p->index]; - if (NULL == vb) { - pr_debug("VCAP qbuf: buffer is NULL\n"); - return -EINVAL; - } - - if (vb->state != VB2_BUF_STATE_DEQUEUED) { - pr_debug("VCAP qbuf: buffer already in use\n"); - return -EINVAL; - } - rc = get_phys_addr(c_data->dev, &c_data->vc_vidq, p); - if (rc < 0) - return rc; - rc = vcvp_qbuf(&c_data->vc_vidq, p); - if (rc < 0) - free_ion_handle(c_data, - &c_data->vc_vidq, p); - return rc; - } - rc = get_phys_addr(c_data->dev, &c_data->vc_vidq, p); - if (rc < 0) - return rc; - mutex_lock(&c_data->mutex); - rc = vb2_qbuf(&c_data->vc_vidq, p); - mutex_unlock(&c_data->mutex); - if (rc < 0) - free_ion_handle(c_data, &c_data->vc_vidq, p); - return rc; - case V4L2_BUF_TYPE_INTERLACED_IN_DECODER: - if (c_data->op_mode == VC_AND_VP_VCAP_OP) - return -EINVAL; - rc = get_phys_addr(c_data->dev, &c_data->vp_in_vidq, p); - if (rc < 0) - return rc; - mutex_lock(&c_data->mutex); - rc = vb2_qbuf(&c_data->vp_in_vidq, p); - mutex_unlock(&c_data->mutex); - if (rc < 0) - free_ion_handle(c_data, &c_data->vp_in_vidq, p); - return rc; - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - rc = get_phys_addr(c_data->dev, &c_data->vp_out_vidq, p); - if (rc < 0) - return rc; - mutex_lock(&c_data->mutex); - rc = vb2_qbuf(&c_data->vp_out_vidq, p); - mutex_unlock(&c_data->mutex); - if (rc < 0) - free_ion_handle(c_data, &c_data->vp_out_vidq, p); - return rc; - default: - pr_err("VCAP Error: %s: Unknown buffer type\n", __func__); - return -EINVAL; - } - return 0; -} - -static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - int rc; - - if (c_data->streaming == 0) - return -EPERM; - - pr_debug("VCAP In DQ Buf %08x\n", (unsigned int)p->type); - switch (p->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - if (c_data->op_mode == VC_AND_VP_VCAP_OP) - return -EINVAL; - mutex_lock(&c_data->mutex); - rc = vb2_dqbuf(&c_data->vc_vidq, p, file->f_flags & O_NONBLOCK); - mutex_unlock(&c_data->mutex); - if (rc < 0) - return rc; - return free_ion_handle(c_data, &c_data->vc_vidq, p); - case V4L2_BUF_TYPE_INTERLACED_IN_DECODER: - if (c_data->op_mode == VC_AND_VP_VCAP_OP) - return -EINVAL; - mutex_lock(&c_data->mutex); - rc = vb2_dqbuf(&c_data->vp_in_vidq, p, file->f_flags & - O_NONBLOCK); - mutex_unlock(&c_data->mutex); - if (rc < 0) - return rc; - return free_ion_handle(c_data, &c_data->vp_in_vidq, p); - case V4L2_BUF_TYPE_VIDEO_OUTPUT: - mutex_lock(&c_data->mutex); - rc = vb2_dqbuf(&c_data->vp_out_vidq, p, file->f_flags & - O_NONBLOCK); - mutex_unlock(&c_data->mutex); - if (rc < 0) - return rc; - return free_ion_handle(c_data, &c_data->vp_out_vidq, p); - default: - pr_err("VCAP Error: %s: Unknown buffer type", __func__); - return -EINVAL; - } - return 0; -} - -/* - * When calling streamon on multiple queues there is a need to first verify - * that the steamon will succeed on all queues, similarly for streamoff - */ -int streamon_validate_q(struct vb2_queue *q) -{ - if (q->fileio) { - pr_debug("%s: file io in progress\n", __func__); - return -EBUSY; - } - - if (q->streaming) { - pr_debug("%s: already streaming\n", __func__); - return -EBUSY; - } - - if (V4L2_TYPE_IS_OUTPUT(q->type)) { - if (list_empty(&q->queued_list)) { - pr_debug("%s: no output buffers queued\n", __func__); - return -EINVAL; - } - } - return 0; -} - -int request_bus_bw(struct vcap_dev *dev, unsigned long rate) -{ - struct msm_bus_paths *bus_vectors; - int idx, length; - bus_vectors = dev->vcap_pdata->bus_client_pdata->usecase; - length = dev->vcap_pdata->bus_client_pdata->num_usecases; - idx = 0; - do { - if (rate <= bus_vectors[idx].vectors[0].ab) - break; - idx++; - } while (idx < length); - if (idx == length) { - pr_info("VCAP: Defaulting to highest BW request\n"); - idx--; - } - msm_bus_scale_client_update_request(dev->bus_client_handle, idx); - dev->dbg_p.bw_request = bus_vectors[idx].vectors[0].ab; - return 0; -} - -static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - struct vcap_dev *dev = c_data->dev; - int rc; - unsigned long rate; - long rate_rc; - - pr_debug("VCAP: In Stream ON\n"); - if (determine_mode(c_data) != c_data->op_mode) { - pr_err("VCAP Error: %s: s_fmt called after req_buf", __func__); - return -ENOTRECOVERABLE; - } - - if (!dev->vp_dummy_complete) { - pr_err("VCAP Err: %s: VP dummy read not complete", - __func__); - return -EINVAL; - } - - switch (c_data->op_mode) { - case VC_VCAP_OP: - mutex_lock(&dev->dev_mutex); - if (dev->vc_resource) { - pr_err("VCAP Err: %s: VC resource taken", __func__); - mutex_unlock(&dev->dev_mutex); - return -EBUSY; - } - dev->vc_resource = 1; - mutex_unlock(&dev->dev_mutex); - - c_data->dev->vc_client = c_data; - - if (!c_data->vc_format.clk_freq) { - rc = -EINVAL; - goto free_res; - } - - rate = c_data->vc_format.clk_freq / 100 * 102; - rate_rc = clk_round_rate(dev->vcap_clk, rate); - if (rate_rc <= 0) { - pr_err("%s: Failed core rnd_rate\n", __func__); - rc = -EINVAL; - goto free_res; - } - rate = (unsigned long)rate_rc; - rc = clk_set_rate(dev->vcap_clk, rate); - if (rc < 0) - goto free_res; - - dev->dbg_p.clk_rate = (uint32_t) rate; - - rate = (c_data->vc_format.hactive_end - - c_data->vc_format.hactive_start); - - if (c_data->vc_format.color_space) - rate *= 3; - else - rate *= 2; - - rate *= (c_data->vc_format.vactive_end - - c_data->vc_format.vactive_start); - rate *= c_data->vc_format.frame_rate; - if (rate == 0) - goto free_res; - - rc = request_bus_bw(dev, rate); - if (rc < 0) - goto free_res; - - config_vc_format(c_data); - c_data->streaming = 1; - rc = vb2_streamon(&c_data->vc_vidq, i); - if (rc < 0) - goto free_res; - break; - case VP_VCAP_OP: - mutex_lock(&dev->dev_mutex); - if (dev->vp_resource) { - pr_err("VCAP Err: %s: VP resource taken", __func__); - mutex_unlock(&dev->dev_mutex); - return -EBUSY; - } - dev->vp_resource = 1; - mutex_unlock(&dev->dev_mutex); - c_data->dev->vp_client = c_data; - - rate = 160000000; - rate_rc = clk_round_rate(dev->vcap_clk, rate); - if (rate_rc <= 0) { - pr_err("%s: Failed core rnd_rate\n", __func__); - rc = -EINVAL; - goto free_res; - } - rate = (unsigned long)rate_rc; - rc = clk_set_rate(dev->vcap_clk, rate); - - dev->dbg_p.clk_rate = (uint32_t) rate; - if (rc < 0) - goto free_res; - - rate = c_data->vp_out_fmt.width * - c_data->vp_out_fmt.height * 240; - rc = request_bus_bw(dev, rate); - if (rc < 0) - goto free_res; - - rc = streamon_validate_q(&c_data->vp_in_vidq); - if (rc < 0) - goto free_res; - rc = streamon_validate_q(&c_data->vp_out_vidq); - if (rc < 0) - goto free_res; - - rc = config_vp_format(c_data); - if (rc < 0) - goto free_res; - rc = init_motion_buf(c_data); - if (rc < 0) - goto free_res; - if (dev->nr_param.mode) { - rc = init_nr_buf(c_data); - if (rc < 0) - goto s_on_deinit_m_buf; - } - - c_data->vp_action.vp_state = VP_FRAME1; - c_data->streaming = 1; - - rc = vb2_streamon(&c_data->vp_in_vidq, - V4L2_BUF_TYPE_INTERLACED_IN_DECODER); - if (rc < 0) - goto s_on_deinit_nr_buf; - - rc = vb2_streamon(&c_data->vp_out_vidq, - V4L2_BUF_TYPE_VIDEO_OUTPUT); - if (rc < 0) - goto s_on_deinit_nr_buf; - break; - case VC_AND_VP_VCAP_OP: - mutex_lock(&dev->dev_mutex); - if (dev->vc_resource || dev->vp_resource) { - pr_err("VCAP Err: %s: VC/VP resource taken", - __func__); - mutex_unlock(&dev->dev_mutex); - return -EBUSY; - } - dev->vc_resource = 1; - dev->vp_resource = 1; - mutex_unlock(&dev->dev_mutex); - c_data->dev->vc_client = c_data; - c_data->dev->vp_client = c_data; - - if (!c_data->vc_format.clk_freq) { - rc = -EINVAL; - goto free_res; - } - - rate = c_data->vc_format.clk_freq / 100 * 102; - if ((c_data->vc_format.hactive_end - - c_data->vc_format.hactive_start) > 539) - rate = 200000000; - rate_rc = clk_round_rate(dev->vcap_clk, rate); - if (rate_rc <= 0) { - pr_err("%s: Failed core rnd_rate\n", __func__); - rc = -EINVAL; - goto free_res; - } - rate = (unsigned long)rate_rc; - rc = clk_set_rate(dev->vcap_clk, rate); - if (rc < 0) - goto free_res; - - dev->dbg_p.clk_rate = (uint32_t) rate; - - rate = (c_data->vc_format.hactive_end - - c_data->vc_format.hactive_start); - - if (c_data->vc_format.color_space) - rate *= 3; - else - rate *= 2; - - rate *= (c_data->vc_format.vactive_end - - c_data->vc_format.vactive_start); - rate *= c_data->vc_format.frame_rate; - rate *= 2; - if (rate == 0) - goto free_res; - - rc = request_bus_bw(dev, rate); - if (rc < 0) - goto free_res; - - rc = streamon_validate_q(&c_data->vc_vidq); - if (rc < 0) - return rc; - rc = streamon_validate_q(&c_data->vp_in_vidq); - if (rc < 0) - goto free_res; - rc = streamon_validate_q(&c_data->vp_out_vidq); - if (rc < 0) - goto free_res; - - rc = config_vc_format(c_data); - if (rc < 0) - goto free_res; - rc = config_vp_format(c_data); - if (rc < 0) - goto free_res; - rc = init_motion_buf(c_data); - if (rc < 0) - goto free_res; - - if (dev->nr_param.mode) { - rc = init_nr_buf(c_data); - if (rc < 0) - goto s_on_deinit_m_buf; - } - - c_data->dev->vc_to_vp_work.cd = c_data; - c_data->vp_action.vp_state = VP_FRAME1; - c_data->streaming = 1; - - /* These stream on calls should not fail */ - rc = vb2_streamon(&c_data->vc_vidq, - V4L2_BUF_TYPE_VIDEO_CAPTURE); - if (rc < 0) - goto s_on_deinit_nr_buf; - - rc = vb2_streamon(&c_data->vp_in_vidq, - V4L2_BUF_TYPE_INTERLACED_IN_DECODER); - if (rc < 0) - goto s_on_deinit_nr_buf; - - rc = vb2_streamon(&c_data->vp_out_vidq, - V4L2_BUF_TYPE_VIDEO_OUTPUT); - if (rc < 0) - goto s_on_deinit_nr_buf; - break; - default: - pr_err("VCAP Error: %s: Operation Mode type", __func__); - return -ENOTRECOVERABLE; - } - return 0; - -s_on_deinit_nr_buf: - if (dev->nr_param.mode) - deinit_nr_buf(c_data); -s_on_deinit_m_buf: - deinit_motion_buf(c_data); -free_res: - mutex_lock(&dev->dev_mutex); - if (c_data->op_mode == VC_VCAP_OP) { - dev->vc_resource = 0; - c_data->dev->vc_client = NULL; - } else if (c_data->op_mode == VP_VCAP_OP) { - dev->vp_resource = 0; - c_data->dev->vp_client = NULL; - } else if (c_data->op_mode == VC_AND_VP_VCAP_OP) { - c_data->dev->vc_client = NULL; - c_data->dev->vp_client = NULL; - dev->vc_resource = 0; - dev->vp_resource = 0; - } - mutex_unlock(&dev->dev_mutex); - return rc; -} - -int streamoff_validate_q(struct vb2_queue *q) -{ - if (q->fileio) { - pr_debug("%s: file io in progress\n", __func__); - return -EBUSY; - } - - if (!q->streaming) { - pr_debug("%s: not streaming\n", __func__); - return -EINVAL; - } - return 0; -} - -int streamoff_work(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - int rc; - switch (c_data->op_mode) { - case VC_VCAP_OP: - if (c_data != dev->vc_client) { - pr_err("VCAP Err: %s: VC held by other client", - __func__); - return -EBUSY; - } - mutex_lock(&dev->dev_mutex); - if (!dev->vc_resource) { - pr_err("VCAP Err: %s: VC res not acquired", __func__); - mutex_unlock(&dev->dev_mutex); - return -EBUSY; - } - dev->vc_resource = 0; - mutex_unlock(&dev->dev_mutex); - c_data->streaming = 0; - mutex_lock(&c_data->mutex); - rc = vb2_streamoff(&c_data->vc_vidq, - V4L2_BUF_TYPE_VIDEO_CAPTURE); - mutex_unlock(&c_data->mutex); - if (rc >= 0) - atomic_set(&c_data->dev->vc_enabled, 0); - return rc; - case VP_VCAP_OP: - if (c_data != dev->vp_client) { - pr_err("VCAP Err: %s: VP held by other client", - __func__); - return -EBUSY; - } - mutex_lock(&dev->dev_mutex); - if (!dev->vp_resource) { - pr_err("VCAP Err: %s: VP res not acquired", __func__); - mutex_unlock(&dev->dev_mutex); - return -EBUSY; - } - dev->vp_resource = 0; - mutex_unlock(&dev->dev_mutex); - rc = streamoff_validate_q(&c_data->vp_in_vidq); - if (rc < 0) - return rc; - rc = streamoff_validate_q(&c_data->vp_out_vidq); - if (rc < 0) - return rc; - c_data->streaming = 0; - - mutex_unlock(&dev->dev_mutex); - /* These stream on calls should not fail */ - rc = vb2_streamoff(&c_data->vp_in_vidq, - V4L2_BUF_TYPE_INTERLACED_IN_DECODER); - if (rc < 0) { - mutex_unlock(&c_data->mutex); - return rc; - } - - rc = vb2_streamoff(&c_data->vp_out_vidq, - V4L2_BUF_TYPE_VIDEO_OUTPUT); - mutex_unlock(&c_data->mutex); - if (rc < 0) - return rc; - - deinit_motion_buf(c_data); - if (dev->nr_param.mode) - deinit_nr_buf(c_data); - atomic_set(&c_data->dev->vp_enabled, 0); - return rc; - case VC_AND_VP_VCAP_OP: - if (c_data != dev->vp_client || c_data != dev->vc_client) { - pr_err("VCAP Err: %s: VC/VP held by other client", - __func__); - return -EBUSY; - } - mutex_lock(&dev->dev_mutex); - if (!(dev->vc_resource || dev->vp_resource)) { - pr_err("VCAP Err: %s: VC or VP res not acquired", - __func__); - mutex_unlock(&dev->dev_mutex); - return -EBUSY; - } - dev->vc_resource = 0; - dev->vp_resource = 0; - mutex_unlock(&dev->dev_mutex); - rc = streamoff_validate_q(&c_data->vc_vidq); - if (rc < 0) - return rc; - rc = streamoff_validate_q(&c_data->vp_in_vidq); - if (rc < 0) - return rc; - rc = streamoff_validate_q(&c_data->vp_out_vidq); - if (rc < 0) - return rc; - - c_data->streaming = 0; - mutex_lock(&c_data->mutex); - /* These stream on calls should not fail */ - rc = vb2_streamoff(&c_data->vc_vidq, - V4L2_BUF_TYPE_VIDEO_CAPTURE); - if (rc < 0) { - mutex_unlock(&c_data->mutex); - return rc; - } - - rc = vb2_streamoff(&c_data->vp_in_vidq, - V4L2_BUF_TYPE_INTERLACED_IN_DECODER); - if (rc < 0) { - mutex_unlock(&c_data->mutex); - return rc; - } - - rc = vb2_streamoff(&c_data->vp_out_vidq, - V4L2_BUF_TYPE_VIDEO_OUTPUT); - mutex_unlock(&c_data->mutex); - if (rc < 0) - return rc; - - deinit_motion_buf(c_data); - if (dev->nr_param.mode) - deinit_nr_buf(c_data); - atomic_set(&c_data->dev->vc_enabled, 0); - atomic_set(&c_data->dev->vp_enabled, 0); - return rc; - default: - pr_err("VCAP Error: %s: Unknown Operation mode", __func__); - return -ENOTRECOVERABLE; - } -} - -static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - return streamoff_work(c_data); -} - -static int vidioc_subscribe_event(struct v4l2_fh *fh, - const struct v4l2_event_subscription *sub) -{ - int rc; - struct v4l2_event_subscription s; - - if (sub->type == V4L2_EVENT_ALL) { - rc = 0; - s = *sub; - s.type = V4L2_EVENT_PRIVATE_START + - VCAP_GENERIC_NOTIFY_EVENT; - s.id = 0; - do { - rc = v4l2_event_subscribe(fh, &s, 16, NULL); - if (rc < 0) { - s.type = V4L2_EVENT_ALL; - v4l2_event_unsubscribe(fh, &s); - return rc; - } - s.type++; - } while (s.type != - V4L2_EVENT_PRIVATE_START + VCAP_MAX_NOTIFY_EVENT); - } else { - rc = v4l2_event_subscribe(fh, sub, 16, NULL); - } - return rc; -} - -static int vidioc_unsubscribe_event(struct v4l2_fh *fh, - const struct v4l2_event_subscription *sub) -{ - return v4l2_event_unsubscribe(fh, sub); -} - -static long vidioc_default(struct file *file, void *fh, bool valid_prio, - unsigned int cmd, void *arg) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - struct vcap_dev *dev = c_data->dev; - struct nr_param *param; - int val; - unsigned long flags = 0; - int ret; - - switch (cmd) { - case VCAPIOC_NR_S_PARAMS: - - if (c_data->streaming != 0 && - (!(!((struct nr_param *) arg)->mode) != - !(!(dev->nr_param.mode)))) { - pr_err("ERR: Trying to toggle on/off while VP is already running"); - return -EBUSY; - } - - - spin_lock_irqsave(&c_data->cap_slock, flags); - ret = nr_s_param(c_data, (struct nr_param *) arg); - if (ret < 0) { - spin_unlock_irqrestore(&c_data->cap_slock, flags); - return ret; - } - param = (struct nr_param *) arg; - dev->nr_param = *param; - if (param->mode == NR_AUTO) - s_default_nr_val(&dev->nr_param); - dev->nr_update = true; - spin_unlock_irqrestore(&c_data->cap_slock, flags); - break; - case VCAPIOC_NR_G_PARAMS: - *((struct nr_param *)arg) = dev->nr_param; - if (dev->nr_param.mode != NR_DISABLE) { - if (c_data->streaming) - nr_g_param(c_data, (struct nr_param *) arg); - else - (*(struct nr_param *) arg) = - dev->nr_param; - } - break; - case VCAPIOC_S_NUM_VC_BUF: - val = (*(int *) arg); - if (val < VCAP_VC_MIN_BUF || val > VCAP_VC_MAX_BUF) - return -EINVAL; - dev->vc_tot_buf = (uint8_t) val; - break; - default: - return -EINVAL; - } - return 0; -} - -/* VCAP fops */ -static void *vcap_ops_get_userptr(void *alloc_ctx, unsigned long vaddr, - unsigned long size, int write) -{ - struct vcap_buf_info *mem; - mem = kzalloc(sizeof(*mem), GFP_KERNEL); - if (!mem) - return ERR_PTR(-ENOMEM); - mem->vaddr = vaddr; - mem->size = size; - return mem; -} - -static void vcap_ops_put_userptr(void *buf_priv) -{ - kfree(buf_priv); -} - -const struct vb2_mem_ops vcap_mem_ops = { - .get_userptr = vcap_ops_get_userptr, - .put_userptr = vcap_ops_put_userptr, -}; - -static int vcap_open(struct file *file) -{ - struct vcap_dev *dev = video_drvdata(file); - struct vcap_client_data *c_data; - struct vb2_queue *q; - int ret; - if (!dev) - return -EINVAL; - c_data = kzalloc(sizeof(*c_data), GFP_KERNEL); - if (!c_data) - return -ENOMEM; - - c_data->dev = dev; - - spin_lock_init(&c_data->cap_slock); - mutex_init(&c_data->mutex); - - /* initialize vc queue */ - q = &c_data->vc_vidq; - memset(q, 0, sizeof(c_data->vc_vidq)); - q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - q->io_modes = VB2_USERPTR; - q->drv_priv = c_data; - q->buf_struct_size = sizeof(struct vcap_buffer); - q->ops = &capture_video_qops; - q->mem_ops = &vcap_mem_ops; - ret = vb2_queue_init(q); - if (ret < 0) - goto vc_q_failed; - - /* initialize vp in queue */ - q = &c_data->vp_in_vidq; - memset(q, 0, sizeof(c_data->vp_in_vidq)); - q->type = V4L2_BUF_TYPE_INTERLACED_IN_DECODER; - q->io_modes = VB2_USERPTR; - q->drv_priv = c_data; - q->buf_struct_size = sizeof(struct vcap_buffer); - q->ops = &vp_in_video_qops; - q->mem_ops = &vcap_mem_ops; - ret = vb2_queue_init(q); - if (ret < 0) - goto vp_in_q_failed; - - /* initialize vp out queue */ - q = &c_data->vp_out_vidq; - memset(q, 0, sizeof(c_data->vp_out_vidq)); - q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - q->io_modes = VB2_USERPTR; - q->drv_priv = c_data; - q->buf_struct_size = sizeof(struct vcap_buffer); - q->ops = &vp_out_video_qops; - q->mem_ops = &vcap_mem_ops; - - ret = vb2_queue_init(q); - if (ret < 0) - goto vp_out_q_failed; - - INIT_LIST_HEAD(&c_data->vc_action.active); - INIT_LIST_HEAD(&c_data->vp_action.in_active); - INIT_LIST_HEAD(&c_data->vp_action.out_active); - - v4l2_fh_init(&c_data->vfh, dev->vfd); - v4l2_fh_add(&c_data->vfh); - - mutex_lock(&dev->dev_mutex); - atomic_inc(&dev->open_clients); - ret = atomic_read(&dev->open_clients); - if (ret == 1) { - ret = vcap_enable(dev, dev->ddev, 54860000); - if (ret < 0) { - pr_err("Err: %s: Power on vcap failed", __func__); - mutex_unlock(&dev->dev_mutex); - goto vcap_power_failed; - } - - ret = vp_dummy_event(c_data); - if (ret < 0) { - pr_err("Err: %s: Dummy Event failed", __func__); - mutex_unlock(&dev->dev_mutex); - vcap_disable(dev); - goto vcap_power_failed; - } - } - mutex_unlock(&dev->dev_mutex); - - file->private_data = &c_data->vfh; - return 0; - -vcap_power_failed: - atomic_dec(&dev->open_clients); - - v4l2_fh_del(&c_data->vfh); - v4l2_fh_exit(&c_data->vfh); - vb2_queue_release(&c_data->vp_out_vidq); -vp_out_q_failed: - vb2_queue_release(&c_data->vp_in_vidq); -vp_in_q_failed: - vb2_queue_release(&c_data->vc_vidq); -vc_q_failed: - mutex_destroy(&c_data->mutex); - kfree(c_data); - return ret; -} - -static int vcap_close(struct file *file) -{ - struct vcap_dev *dev = video_drvdata(file); - struct vcap_client_data *c_data = to_client_data(file->private_data); - int ret; - - if (c_data == NULL) - return 0; - - if (c_data->streaming) - streamoff_work(c_data); - - mutex_lock(&dev->dev_mutex); - atomic_dec(&dev->open_clients); - ret = atomic_read(&dev->open_clients); - mutex_unlock(&dev->dev_mutex); - if (ret == 0) { - vcap_disable(dev); - dev->vc_tot_buf = 2; - dev->vp_dummy_complete = false; - } - v4l2_fh_del(&c_data->vfh); - v4l2_fh_exit(&c_data->vfh); - free_ion_on_q_bufs(&c_data->vp_out_vidq); - free_ion_on_q_bufs(&c_data->vp_in_vidq); - free_ion_on_q_bufs(&c_data->vc_vidq); - - vb2_queue_release(&c_data->vp_out_vidq); - vb2_queue_release(&c_data->vp_in_vidq); - vb2_queue_release(&c_data->vc_vidq); - if (c_data->dev->vc_client == c_data) - c_data->dev->vc_client = NULL; - if (c_data->dev->vp_client == c_data) - c_data->dev->vp_client = NULL; - mutex_destroy(&c_data->mutex); - kfree(c_data); - return 0; -} - -unsigned int poll_work(struct vb2_queue *q, struct file *file, - poll_table *wait, bool write_q) -{ - unsigned long flags; - struct vb2_buffer *vb = NULL; - - if (q->num_buffers == 0) - return POLLERR; - - if (list_empty(&q->queued_list)) - return POLLERR; - - poll_wait(file, &q->done_wq, wait); - - spin_lock_irqsave(&q->done_lock, flags); - if (!list_empty(&q->done_list)) - vb = list_first_entry(&q->done_list, struct vb2_buffer, - done_entry); - spin_unlock_irqrestore(&q->done_lock, flags); - - if (vb && (vb->state == VB2_BUF_STATE_DONE - || vb->state == VB2_BUF_STATE_ERROR)) { - return (write_q) ? POLLOUT | POLLWRNORM : - POLLIN | POLLRDNORM; - } - return 0; -} - -static unsigned int vcap_poll(struct file *file, - struct poll_table_struct *wait) -{ - struct vcap_client_data *c_data = to_client_data(file->private_data); - struct vb2_queue *q; - unsigned int mask = 0; - - if (c_data->streaming == 0) - return 0; - - pr_debug("%s: Enter slect/poll\n", __func__); - - switch (c_data->op_mode) { - case VC_VCAP_OP: - q = &c_data->vc_vidq; - mask = vb2_poll(q, file, wait); - break; - case VP_VCAP_OP: - q = &c_data->vp_in_vidq; - mask = poll_work(q, file, wait, 0); - q = &c_data->vp_out_vidq; - mask |= poll_work(q, file, wait, 1); - break; - case VC_AND_VP_VCAP_OP: - q = &c_data->vp_out_vidq; - mask = poll_work(q, file, wait, 0); - break; - default: - pr_err("VCAP Error: %s: Unknown operation mode", __func__); - return POLLERR; - } - if (v4l2_event_pending(&c_data->vfh)) - mask |= POLLPRI; - poll_wait(file, &(c_data->vfh.wait), wait); - return mask; -} -/* V4L2 and video device structures */ - -static const struct v4l2_file_operations vcap_fops = { - .owner = THIS_MODULE, - .open = vcap_open, - .release = vcap_close, - .poll = vcap_poll, - .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ -}; - -static const struct v4l2_ioctl_ops vcap_ioctl_ops = { - .vidioc_querycap = vidioc_querycap, - .vidioc_enum_input = vidioc_enum_input, - .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - .vidioc_s_fmt_vid_out_mplane = vidioc_s_fmt_vid_cap, - .vidioc_g_fmt_vid_out_mplane = vidioc_g_fmt_vid_cap, - .vidioc_reqbufs = vidioc_reqbufs, - .vidioc_querybuf = vidioc_querybuf, - .vidioc_qbuf = vidioc_qbuf, - .vidioc_dqbuf = vidioc_dqbuf, - .vidioc_streamon = vidioc_streamon, - .vidioc_streamoff = vidioc_streamoff, - - .vidioc_subscribe_event = vidioc_subscribe_event, - .vidioc_unsubscribe_event = vidioc_unsubscribe_event, - .vidioc_default = vidioc_default, -}; - -static struct video_device vcap_template = { - .name = "vcap", - .fops = &vcap_fops, - .ioctl_ops = &vcap_ioctl_ops, - .release = video_device_release, -}; - -static irqreturn_t vcap_vp_handler(int irq_num, void *data) -{ - return vp_handler(vcap_ctrl); -} - -static irqreturn_t vcap_vc_handler(int irq_num, void *data) -{ - return vc_handler(vcap_ctrl); -} - -#ifdef CONFIG_DEBUG_FS -/* Query VCAP resource usage */ -static ssize_t read_dump_info(struct file *file, char __user *user_buf, - size_t len, loff_t *ppos) -{ - struct vcap_dev *dev = file->private_data; - char str_buf[512]; - size_t tot_size = 0, size; - - if (dev->vc_client) { - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "VCAP: VC\n"); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vc_resourse = %d\n", dev->vc_resource); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vc_enabled = %d\n", atomic_read(&dev->vc_enabled)); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vc_client id = %p\n", dev->vc_client); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vc_queue_count = %d\n", - atomic_read(&dev->vc_client->vc_vidq.queued_count)); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vc_total_buffers = %d\n", - dev->vc_client->vc_action.tot_buf); - tot_size += size; - } else { - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "VCAP: VC not in use\n"); - tot_size += size; - } - if (dev->vp_client) { - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "VCAP: VP\n"); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vp_resourse = %d\n", dev->vp_resource); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vp_enabled = %d\n", atomic_read(&dev->vp_enabled)); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vp_client id = %p\n", dev->vp_client); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vp_in_queue_count = %d\n", - atomic_read( - &dev->vp_client->vp_in_vidq.queued_count)); - tot_size += size; - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "vp_out_queue_count = %d\n", - atomic_read( - &dev->vp_client->vp_out_vidq.queued_count)); - tot_size += size; - } else { - size = scnprintf(str_buf + tot_size, sizeof(str_buf) - tot_size, - "VCAP: VP not in use\n"); - tot_size += size; - } - - return simple_read_from_buffer(user_buf, len, ppos, str_buf, tot_size); -} - -static const struct file_operations dump_info_fops = { - .read = read_dump_info, - .open = simple_open, - .llseek = default_llseek, -}; - -static int vcap_debug_clk_rate_get(void *data, u64 *val) -{ - struct vcap_dev *dev = data; - *val = (u64)dev->dbg_p.clk_rate; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(clk_rate_fops, vcap_debug_clk_rate_get, - NULL, "%llu\n"); - -static int vcap_debug_bw_req_get(void *data, u64 *val) -{ - struct vcap_dev *dev = data; - *val = (u64)dev->dbg_p.bw_request; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(bw_req_fops, vcap_debug_bw_req_get, - NULL, "%llu\n"); - -static int vcap_debug_drop_frames_get(void *data, u64 *val) -{ - struct vcap_dev *dev = data; - struct timeval tv; - int drop_count; - - if (!dev->vc_resource) - return -EPERM; - drop_count = atomic_read(&dev->dbg_p.vc_drop_count); - atomic_set(&dev->dbg_p.vc_drop_count, 0); - - do_gettimeofday(&tv); - dev->dbg_p.vc_timestamp = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - - *val = (u64)drop_count; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(tot_frame_drop_fops, vcap_debug_drop_frames_get, - NULL, "%llu\n"); - -static int vcap_debug_drop_fps_get(void *data, u64 *val) -{ - struct vcap_dev *dev = data; - struct timeval tv; - int drop_count; - uint32_t new_ts; - - if (!dev->vc_resource) - return -EPERM; - drop_count = atomic_read(&dev->dbg_p.vc_drop_count); - atomic_set(&dev->dbg_p.vc_drop_count, 0); - - do_gettimeofday(&tv); - new_ts = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - - if ((new_ts - dev->dbg_p.vc_timestamp) / VCAP_USEC && - new_ts > dev->dbg_p.vc_timestamp) - drop_count /= ((new_ts - dev->dbg_p.vc_timestamp) / VCAP_USEC); - else - drop_count = 0; - - dev->dbg_p.vc_timestamp = new_ts; - *val = (u64)drop_count; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(drop_fps_fops, vcap_debug_drop_fps_get, - NULL, "%llu\n"); - -static int vcap_debug_vp_lat_get(void *data, u64 *val) -{ - struct vcap_dev *dev = data; - - if (!dev->vp_resource) - return -EPERM; - *val = (u64)dev->dbg_p.vp_ewma; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(vp_lat_fops, vcap_debug_vp_lat_get, - NULL, "%llu\n"); - -/* Read/Write to VCAP Registers */ -static int vcap_debug_reg_set(void *data, u64 val) -{ - struct vcap_dev *dev = data; - int i; - for (i = 0; i < ARRAY_SIZE(debug_reg_range); i++) { - if (val >= debug_reg_range[i].min_val && val <= - debug_reg_range[i].max_val) - break; - } - if (i == ARRAY_SIZE(debug_reg_range)) - return -EINVAL; - dev->dbg_p.reg_addr = (uint32_t) val; - return 0; -} - -static int vcap_debug_reg_get(void *data, u64 *val) -{ - struct vcap_dev *dev = data; - *val = (u64)dev->dbg_p.reg_addr; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(vcap_reg_fops, vcap_debug_reg_get, - vcap_debug_reg_set, "0x%08llx\n") - -static int vcap_debug_reg_rdwr_set(void *data, u64 val) -{ - struct vcap_dev *dev = data; - u32 reg_val = (u32) val; - - writel_iowmb(reg_val, VCAP_OFFSET(dev->dbg_p.reg_addr)); - return 0; -} - -static int vcap_debug_reg_rdwr_get(void *data, u64 *val) -{ - struct vcap_dev *dev = data; - *val = (u64)readl_relaxed(VCAP_OFFSET(dev->dbg_p.reg_addr)); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(vcap_reg_rdwr_fops, vcap_debug_reg_rdwr_get, - vcap_debug_reg_rdwr_set, "0x%08llx\n"); - -static int vcap_debugfs_init(struct vcap_dev *dev) -{ - vcap_debugfs_base = debugfs_create_dir("vcap", NULL); - if (!vcap_debugfs_base) - return -ENOMEM; - - if (!debugfs_create_file("dump_info", S_IRUGO, - vcap_debugfs_base, dev, &dump_info_fops)) - goto error; - - if (!debugfs_create_file("vcap_core_clk_rate", S_IRUGO, - vcap_debugfs_base, dev, &clk_rate_fops)) - goto error; - - if (!debugfs_create_file("vcap_bw_req", S_IRUGO, - vcap_debugfs_base, dev, &bw_req_fops)) - goto error; - - if (!debugfs_create_file("vc_total_frames_drop", S_IRUGO, - vcap_debugfs_base, dev, &tot_frame_drop_fops)) - goto error; - - if (!debugfs_create_file("vc_drop_fps", S_IRUGO, - vcap_debugfs_base, dev, &drop_fps_fops)) - goto error; - - if (!debugfs_create_file("vp_avg_completion_t", S_IRUGO, - vcap_debugfs_base, dev, &vp_lat_fops)) - goto error; - - if (!debugfs_create_file("vcap_reg_addr", S_IRUGO | S_IWUSR, - vcap_debugfs_base, dev, &vcap_reg_fops)) - goto error; - - if (!debugfs_create_file("vcap_reg_val", S_IRUGO | S_IWUSR, - vcap_debugfs_base, dev, &vcap_reg_rdwr_fops)) - goto error; - return 0; - -error: - debugfs_remove_recursive(vcap_debugfs_base); - vcap_debugfs_base = NULL; - return -ENOMEM; -} - -static void vcap_debugfs_remove(void) -{ - if (vcap_debugfs_base) { - debugfs_remove_recursive(vcap_debugfs_base); - vcap_debugfs_base = NULL; - } -} -#else - -static int vcap_debugfs_init(struct vcap_dev *dev) -{ - return 0; -} -static void vcap_debugfs_remove(void) {} -#endif - -static int vcap_probe(struct platform_device *pdev) -{ - struct vcap_dev *dev; - struct video_device *vfd; - int ret; - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; - vcap_ctrl = dev; - dev->vcap_pdata = pdev->dev.platform_data; - - dev->vcapmem = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "vcap"); - if (!dev->vcapmem) { - pr_err("VCAP: %s: no mem resource?\n", __func__); - ret = -ENODEV; - goto free_dev; - } - - dev->vcapio = request_mem_region(dev->vcapmem->start, - resource_size(dev->vcapmem), pdev->name); - if (!dev->vcapio) { - pr_err("VCAP: %s: no valid mem region\n", __func__); - ret = -EBUSY; - goto free_dev; - } - - dev->vcapbase = ioremap(dev->vcapmem->start, - resource_size(dev->vcapmem)); - if (!dev->vcapbase) { - ret = -ENOMEM; - pr_err("VCAP: %s: vcap ioremap failed\n", __func__); - goto free_resource; - } - - dev->vcirq = platform_get_resource_byname(pdev, - IORESOURCE_IRQ, "vc_irq"); - if (!dev->vcirq) { - pr_err("%s: no vc irq resource?\n", __func__); - ret = -ENODEV; - goto free_resource; - } - dev->vpirq = platform_get_resource_byname(pdev, - IORESOURCE_IRQ, "vp_irq"); - if (!dev->vpirq) { - pr_err("%s: no vp irq resource?\n", __func__); - ret = -ENODEV; - goto free_resource; - } - - - ret = request_irq(dev->vcirq->start, vcap_vc_handler, - IRQF_TRIGGER_HIGH, "vc_irq", 0); - if (ret < 0) { - pr_err("%s: vc irq request fail\n", __func__); - ret = -EBUSY; - goto free_resource; - } - disable_irq(dev->vcirq->start); - - ret = request_irq(dev->vpirq->start, vcap_vp_handler, - IRQF_TRIGGER_RISING, "vp_irq", 0); - - if (ret < 0) { - pr_err("%s: vp irq request fail\n", __func__); - ret = -EBUSY; - goto free_resource; - } - disable_irq(dev->vpirq->start); - - snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), - "%s", MSM_VCAP_DRV_NAME); - - ret = v4l2_device_register(NULL, &dev->v4l2_dev); - if (ret) - goto free_resource; - - dev->vc_iommu_ctx = msm_iommu_get_ctx("vcap_vc"); - if (!dev->vc_iommu_ctx) { - pr_err("%s: No iommu vc context found\n", __func__); - ret = -ENODEV; - goto free_resource; - } - - dev->vp_iommu_ctx = msm_iommu_get_ctx("vcap_vp"); - if (!dev->vp_iommu_ctx) { - pr_err("%s: No iommu vp context found\n", __func__); - ret = -ENODEV; - goto free_resource; - } - - dev->domain_num = vcap_register_domain(); - if (dev->domain_num < 0) { - pr_err("%s: VCAP iommu domain register failed\n", __func__); - ret = -ENODEV; - goto free_resource; - } - - dev->iommu_vcap_domain = msm_get_iommu_domain(dev->domain_num); - if (!dev->iommu_vcap_domain) { - pr_err("%s: No iommu vcap domain found\n", __func__); - ret = -ENODEV; - goto free_resource; - } - - ret = vcap_enable(dev, &pdev->dev, 54860000); - if (ret) - goto unreg_dev; - msm_bus_scale_client_update_request(dev->bus_client_handle, 0); - dev->dbg_p.bw_request = 0; - - ret = detect_vc(dev); - - if (ret) - goto power_down; - - /* init video device*/ - vfd = video_device_alloc(); - if (!vfd) { - ret = -ENOMEM; - goto deinit_vc; - } - - *vfd = vcap_template; - vfd->v4l2_dev = &dev->v4l2_dev; - - ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); - if (ret < 0) - goto rel_vdev; - - dev->vfd = vfd; - video_set_drvdata(vfd, dev); - - dev->vcap_wq = create_workqueue("vcap"); - if (!dev->vcap_wq) { - ret = -ENOMEM; - pr_err("Could not create workqueue"); - goto rel_vdev; - } - - dev->ion_client = msm_ion_client_create(-1, "vcap"); - if (IS_ERR((void *)dev->ion_client)) { - pr_err("could not get ion client"); - ret = PTR_ERR(dev->ion_client); - dev->ion_client = NULL; - goto rel_vcap_wq; - } - - atomic_set(&dev->dbg_p.vc_drop_count, 0); - ret = vcap_debugfs_init(dev); - if (ret < 0) - pr_err("VCAP debugfs failed to load"); - - dev->vc_tot_buf = 2; - atomic_set(&dev->vc_enabled, 0); - atomic_set(&dev->vp_enabled, 0); - atomic_set(&dev->open_clients, 0); - dev->ddev = &pdev->dev; - mutex_init(&dev->dev_mutex); - init_waitqueue_head(&dev->vp_dummy_waitq); - vcap_disable(dev); - - return 0; -rel_vcap_wq: - destroy_workqueue(dev->vcap_wq); -rel_vdev: - video_device_release(vfd); -deinit_vc: - deinit_vc(); -power_down: - vcap_disable(dev); -unreg_dev: - v4l2_device_unregister(&dev->v4l2_dev); -free_resource: - iounmap(dev->vcapbase); - release_mem_region(dev->vcapmem->start, resource_size(dev->vcapmem)); -free_dev: - vcap_ctrl = NULL; - kfree(dev); - return ret; -} - -static int vcap_remove(struct platform_device *pdev) -{ - struct vcap_dev *dev = vcap_ctrl; - vcap_debugfs_remove(); - ion_client_destroy(dev->ion_client); - flush_workqueue(dev->vcap_wq); - destroy_workqueue(dev->vcap_wq); - video_device_release(dev->vfd); - deinit_vc(); - vcap_disable(dev); - v4l2_device_unregister(&dev->v4l2_dev); - iounmap(dev->vcapbase); - release_mem_region(dev->vcapmem->start, resource_size(dev->vcapmem)); - vcap_ctrl = NULL; - kfree(dev); - - return 0; -} - -struct platform_driver vcap_platform_driver = { - .driver = { - .name = MSM_VCAP_DRV_NAME, - .owner = THIS_MODULE, - }, - .probe = vcap_probe, - .remove = vcap_remove, -}; - -static int __init vcap_init_module(void) -{ - return platform_driver_register(&vcap_platform_driver); -} - -static void __exit vcap_exit_module(void) -{ - platform_driver_unregister(&vcap_platform_driver); -} - -module_init(vcap_init_module); -module_exit(vcap_exit_module); -MODULE_DESCRIPTION("VCAP driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/platform/msm/vcap/vcap_vc.c b/drivers/media/platform/msm/vcap/vcap_vc.c deleted file mode 100644 index b64e624fc41907e49de82e7c1a77f8856df0dc4c..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/vcap/vcap_vc.c +++ /dev/null @@ -1,573 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "vcap_vc.h" - -void config_buffer(struct vcap_client_data *c_data, - struct vcap_buffer *buf, - void __iomem *y_addr, - void __iomem *c_addr) -{ - if (c_data->vc_format.color_space == HAL_VCAP_RGB) { - writel_relaxed(buf->paddr, y_addr); - } else { - int size = (c_data->vc_format.hactive_end - - c_data->vc_format.hactive_start); - if (c_data->stride == VC_STRIDE_32) - size = VCAP_STRIDE_CALC(size, VCAP_STRIDE_ALIGN_32); - else - size = VCAP_STRIDE_CALC(size, VCAP_STRIDE_ALIGN_16); - size *= (c_data->vc_format.vactive_end - - c_data->vc_format.vactive_start); - writel_relaxed(buf->paddr, y_addr); - writel_relaxed(buf->paddr + size, c_addr); - } -} - -static void mov_buf_to_vp(struct work_struct *work) -{ - struct vp_work_t *vp_work = container_of(work, struct vp_work_t, work); - struct v4l2_buffer p; - struct vb2_buffer *vb_vc; - struct vcap_buffer *buf_vc; - struct vb2_buffer *vb_vp; - struct vcap_buffer *buf_vp; - - int rc; - p.memory = V4L2_MEMORY_USERPTR; - while (1) { - p.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (!vp_work->cd->streaming) - return; - rc = vcvp_dqbuf(&vp_work->cd->vc_vidq, &p); - if (rc < 0) - return; - - vb_vc = vp_work->cd->vc_vidq.bufs[p.index]; - if (NULL == vb_vc) { - pr_debug("%s: buffer is NULL\n", __func__); - vcvp_qbuf(&vp_work->cd->vc_vidq, &p); - return; - } - buf_vc = container_of(vb_vc, struct vcap_buffer, vb); - - vb_vp = vp_work->cd->vp_in_vidq.bufs[p.index]; - if (NULL == vb_vp) { - pr_debug("%s: buffer is NULL\n", __func__); - vcvp_qbuf(&vp_work->cd->vc_vidq, &p); - return; - } - buf_vp = container_of(vb_vp, struct vcap_buffer, vb); - buf_vp->ion_handle = buf_vc->ion_handle; - buf_vp->paddr = buf_vc->paddr; - buf_vc->ion_handle = NULL; - buf_vc->paddr = 0; - - p.type = V4L2_BUF_TYPE_INTERLACED_IN_DECODER; - - /* This call should not fail */ - rc = vcvp_qbuf(&vp_work->cd->vp_in_vidq, &p); - if (rc < 0) { - pr_err("%s: qbuf to vp_in failed\n", __func__); - buf_vc->ion_handle = buf_vp->ion_handle; - buf_vc->paddr = buf_vp->paddr; - buf_vp->ion_handle = NULL; - buf_vp->paddr = 0; - p.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - vcvp_qbuf(&vp_work->cd->vc_vidq, &p); - } - } -} - -static uint8_t correct_buf_num(uint32_t reg) -{ - int i; - bool block_found = false; - for (i = 0; i < VCAP_VC_MAX_BUF; i++) { - if (reg & (0x2 << i)) { - block_found = true; - continue; - } - if (block_found) - return i; - } - return 0; -} - -static struct timeval interpolate_ts(struct timeval tv, uint32_t delta) -{ - if (tv.tv_usec < delta) { - tv.tv_sec--; - tv.tv_usec += VCAP_USEC - delta; - } else { - tv.tv_usec -= delta; - } - return tv; -} - -inline void vc_isr_error_checking(struct vcap_dev *dev, - struct v4l2_event v4l2_evt, uint32_t irq) -{ - if (irq & 0x200) { - if (irq & 0x80000000) { - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_PIX_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - if (irq & 0x40000000) { - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_LINE_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - if (irq & 0x20000000) { - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_VSYNC_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - } - if (irq & 0x00001000) { - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_VSYNC_SEQ_ERR; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - if (irq & 0x00000800) { - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_NPL_OFLOW_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - if (irq & 0x00000400) { - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_LBUF_OFLOW_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } -} - -inline uint8_t vc_isr_buffer_done_count(struct vcap_dev *dev, - struct vcap_client_data *c_data, uint32_t irq) -{ - int i; - uint8_t done_count = 0; - for (i = 0; i < VCAP_VC_MAX_BUF; i++) { - if (0x2 & (irq >> i)) - done_count++; - } - return done_count; -} - -inline bool vc_isr_verify_expect_buf_rdy(struct vcap_dev *dev, - struct vcap_client_data *c_data, struct v4l2_event v4l2_evt, - uint32_t irq, uint8_t done_count, uint8_t tot, uint8_t buf_num) -{ - int i; - /* Double check expected buffers are done */ - for (i = 0; i < done_count; i++) { - if (!(irq & (0x1 << (((buf_num + i) % tot) + 1)))) { - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_UNEXPECT_BUF_DONE; - v4l2_event_queue(dev->vfd, &v4l2_evt); - pr_debug("Unexpected buffer done\n"); - c_data->vc_action.buf_num = - correct_buf_num(irq) % tot; - return true; - } - } - return false; -} - -inline void vc_isr_update_timestamp(struct vcap_dev *dev, - struct vcap_client_data *c_data) -{ - uint32_t timestamp; - - timestamp = readl_relaxed(VCAP_VC_TIMESTAMP); - if (timestamp < c_data->vc_action.last_ts) { - c_data->vc_action.vc_ts.tv_usec += - (0xFFFFFFFF - c_data->vc_action.last_ts) + - timestamp + 1; - } else { - c_data->vc_action.vc_ts.tv_usec += - timestamp - c_data->vc_action.last_ts; - } - - c_data->vc_action.vc_ts.tv_sec += - c_data->vc_action.vc_ts.tv_usec / VCAP_USEC; - c_data->vc_action.vc_ts.tv_usec = - c_data->vc_action.vc_ts.tv_usec % VCAP_USEC; - c_data->vc_action.last_ts = timestamp; -} - -inline void vc_isr_no_new_buffer(struct vcap_dev *dev, - struct vcap_client_data *c_data, struct v4l2_event v4l2_evt) -{ - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VC_BUF_OVERWRITE_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - - c_data->vc_action.field_dropped = - !c_data->vc_action.field_dropped; - - c_data->vc_action.field1 = - !c_data->vc_action.field1; - atomic_inc(&dev->dbg_p.vc_drop_count); -} - -inline void vc_isr_switch_buffers(struct vcap_dev *dev, - struct vcap_client_data *c_data, struct vcap_buffer *buf, - struct vb2_buffer *vb, uint8_t idx, int done_count, int i) -{ - /* Config vc with this new buffer */ - config_buffer(c_data, buf, VCAP_VC_Y_ADDR_1 + 0x8 * idx, - VCAP_VC_C_ADDR_1 + 0x8 * idx); - vb->v4l2_buf.timestamp = interpolate_ts( - c_data->vc_action.vc_ts, - 1000000 / c_data->vc_format.frame_rate * - (done_count - 1 - i)); - if (c_data->vc_format.mode == HAL_VCAP_MODE_INT) { - if (c_data->vc_action.field1) - vb->v4l2_buf.field = V4L2_FIELD_TOP; - else - vb->v4l2_buf.field = V4L2_FIELD_BOTTOM; - - c_data->vc_action.field1 = - !c_data->vc_action.field1; - } - vb2_buffer_done(vb, VB2_BUF_STATE_DONE); - c_data->vc_action.buf[idx] = buf; -} - -inline bool vc_isr_change_buffers(struct vcap_dev *dev, - struct vcap_client_data *c_data, struct v4l2_event v4l2_evt, - int done_count, uint8_t tot, uint8_t buf_num) -{ - struct vb2_buffer *vb = NULL; - struct vcap_buffer *buf; - bool schedule_work = false; - uint8_t idx; - int i; - - for (i = 0; i < done_count; i++) { - idx = (buf_num + i) % tot; - vb = &c_data->vc_action.buf[idx]->vb; - spin_lock(&c_data->cap_slock); - if (list_empty(&c_data->vc_action.active)) { - spin_unlock(&c_data->cap_slock); - vc_isr_no_new_buffer(dev, c_data, v4l2_evt); - continue; - } - if (c_data->vc_format.mode == HAL_VCAP_MODE_INT && - c_data->vc_action.field_dropped) { - spin_unlock(&c_data->cap_slock); - vc_isr_no_new_buffer(dev, c_data, v4l2_evt); - continue; - } - buf = list_entry(c_data->vc_action.active.next, - struct vcap_buffer, list); - list_del(&buf->list); - spin_unlock(&c_data->cap_slock); - vc_isr_switch_buffers(dev, c_data, buf, vb, idx, done_count, i); - schedule_work = true; - } - return schedule_work; -} - -irqreturn_t vc_handler(struct vcap_dev *dev) -{ - uint32_t irq; - struct vcap_client_data *c_data; - struct v4l2_event v4l2_evt; - uint8_t done_count = 0, buf_num, tot; - bool schedule_work = false; - - v4l2_evt.id = 0; - irq = readl_relaxed(VCAP_VC_INT_STATUS); - writel_relaxed(irq, VCAP_VC_INT_CLEAR); - - pr_debug("%s: irq=0x%08x\n", __func__, irq); - - if (dev->vc_client == NULL) { - /* This should never happen */ - pr_err("VC: There is no active vc client\n"); - return IRQ_HANDLED; - } - - c_data = dev->vc_client; - if (!c_data->streaming) { - pr_err("VC no longer streaming\n"); - return IRQ_HANDLED; - } - - if (irq == VC_VSYNC_MASK) { - if (c_data->vc_format.mode == HAL_VCAP_MODE_INT) - c_data->vc_action.field1 = irq & 0x1; - return IRQ_HANDLED; - } - - if (irq & VC_ERR_MASK) { - vc_isr_error_checking(dev, v4l2_evt, irq); - return IRQ_HANDLED; - } - - if (!(irq & VC_BUFFER_MASK)) { - pr_debug("No frames done\n"); - return IRQ_HANDLED; - } - - done_count = vc_isr_buffer_done_count(dev, c_data, irq); - buf_num = c_data->vc_action.buf_num; - tot = c_data->vc_action.tot_buf; - - if (vc_isr_verify_expect_buf_rdy(dev, c_data, - v4l2_evt, irq, done_count, tot, buf_num)) - return IRQ_HANDLED; - - vc_isr_update_timestamp(dev, c_data); - - c_data->vc_action.buf_num = (buf_num + done_count) % tot; - - schedule_work = vc_isr_change_buffers(dev, c_data, v4l2_evt, - done_count, tot, buf_num); - - if (schedule_work && c_data->op_mode == VC_AND_VP_VCAP_OP) - queue_work(dev->vcap_wq, &dev->vc_to_vp_work.work); - - return IRQ_HANDLED; -} - -int vc_start_capture(struct vcap_client_data *c_data) -{ - return 0; -} - -int vc_hw_kick_off(struct vcap_client_data *c_data) -{ - struct vc_action *vc_action = &c_data->vc_action; - struct vcap_dev *dev; - struct timeval tv; - unsigned long flags = 0; - int rc, i, counter = 0; - struct vcap_buffer *buf; - - dev = c_data->dev; - pr_debug("Start Kickoff\n"); - - if (dev->vc_client == NULL) { - pr_err("No active vc client\n"); - return -ENODEV; - } - c_data->vc_action.buf_num = 0; - spin_lock_irqsave(&dev->vc_client->cap_slock, flags); - if (list_empty(&dev->vc_client->vc_action.active)) { - spin_unlock_irqrestore(&dev->vc_client->cap_slock, flags); - pr_err("%s: VC We have no more avilable buffers\n", - __func__); - return -EINVAL; - } - - list_for_each_entry(buf, &vc_action->active, list) - counter++; - - if (counter < c_data->vc_action.tot_buf) { - /* not enough buffers have been queued */ - spin_unlock_irqrestore(&dev->vc_client->cap_slock, flags); - return -EINVAL; - } - - for (i = 0; i < c_data->vc_action.tot_buf; i++) { - vc_action->buf[i] = list_entry(vc_action->active.next, - struct vcap_buffer, list); - list_del(&vc_action->buf[i]->list); - } - spin_unlock_irqrestore(&dev->vc_client->cap_slock, flags); - - for (i = 0; i < c_data->vc_action.tot_buf; i++) { - config_buffer(c_data, vc_action->buf[i], - VCAP_VC_Y_ADDR_1 + i * 8, - VCAP_VC_C_ADDR_1 + i * 8); - } - - c_data->vc_action.last_ts = readl_relaxed(VCAP_VC_TIMESTAMP); - c_data->vc_action.vc_ts.tv_sec = - c_data->vc_action.last_ts / VCAP_USEC; - c_data->vc_action.vc_ts.tv_usec = - c_data->vc_action.last_ts % VCAP_USEC; - - atomic_set(&dev->dbg_p.vc_drop_count, 0); - do_gettimeofday(&tv); - dev->dbg_p.vc_timestamp = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - - rc = 0; - for (i = 0; i < c_data->vc_action.tot_buf; i++) - rc = rc << 1 | 0x2; - rc |= VC_ERR_MASK; - rc |= VC_VSYNC_MASK; - writel_relaxed(rc, VCAP_VC_INT_MASK); - - enable_irq(dev->vcirq->start); - rc = readl_relaxed(VCAP_VC_CTRL); - writel_iowmb(rc | 0x1, VCAP_VC_CTRL); - - return 0; -} - -void vc_stop_capture(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - unsigned int reg; - int timeout; - - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - writel_iowmb(0x0, VCAP_VC_INT_MASK); - flush_workqueue(dev->vcap_wq); - if (atomic_read(&dev->vc_enabled) == 1) - disable_irq_nosync(dev->vcirq->start); - - writel_iowmb(0x00000000, VCAP_VC_CTRL); - writel_iowmb(0x00000001, VCAP_SW_RESET_REQ); - timeout = 10000; - while (1) { - reg = (readl_relaxed(VCAP_SW_RESET_STATUS) & 0x1); - if (!reg) - break; - timeout--; - if (timeout == 0) { - /* This should not happen */ - pr_err("VC is not resetting properly\n"); - writel_iowmb(0x00000000, VCAP_SW_RESET_REQ); - break; - } - } - - reg = readl_relaxed(VCAP_VC_NPL_CTRL); - reg = readl_relaxed(VCAP_VC_NPL_CTRL); - writel_iowmb(0x00000002, VCAP_VC_NPL_CTRL); -} - -int config_vc_format(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev; - unsigned int rc; - int timeout; - struct v4l2_format_vc_ext *vc_format = &c_data->vc_format; - dev = c_data->dev; - - /* restart VC */ - writel_iowmb(0x00000102, VCAP_VC_NPL_CTRL); - writel_iowmb(0x00000001, VCAP_SW_RESET_REQ); - timeout = 10000; - while (1) { - if (!(readl_relaxed(VCAP_SW_RESET_STATUS) & 0x1)) - break; - timeout--; - if (timeout == 0) { - pr_err("VC is not resetting properly\n"); - writel_iowmb(0x00000002, VCAP_VC_NPL_CTRL); - return -EINVAL; - } - } - - rc = readl_relaxed(VCAP_VC_NPL_CTRL); - rc = readl_relaxed(VCAP_VC_NPL_CTRL); - writel_iowmb(0x00000002, VCAP_VC_NPL_CTRL); - - pr_debug("%s: Starting VC configuration\n", __func__); - writel_iowmb(0x00000002, VCAP_VC_NPL_CTRL); - writel_iowmb(0x00000004 | vc_format->color_space << 1 | - vc_format->mode << 3 | - (c_data->vc_action.tot_buf - 2) << 4 | - vc_format->mode << 10, - VCAP_VC_CTRL); - - writel_relaxed(vc_format->d_polar << 8 | - vc_format->h_polar << 4 | - vc_format->v_polar << 0, VCAP_VC_POLARITY); - - writel_relaxed(((vc_format->htotal << 16) | vc_format->vtotal), - VCAP_VC_V_H_TOTAL); - writel_relaxed(((vc_format->hactive_end << 16) | - vc_format->hactive_start), VCAP_VC_H_ACTIVE); - - writel_relaxed(((vc_format->vactive_end << 16) | - vc_format->vactive_start), VCAP_VC_V_ACTIVE); - writel_relaxed(((vc_format->f2_vactive_end << 16) | - vc_format->f2_vactive_start), VCAP_VC_V_ACTIVE_F2); - writel_relaxed(((vc_format->vsync_end << 16) | vc_format->vsync_start), - VCAP_VC_VSYNC_VPOS); - writel_relaxed(((vc_format->f2_vsync_v_end << 16) | - vc_format->f2_vsync_v_start), VCAP_VC_VSYNC_F2_VPOS); - writel_relaxed(((vc_format->hsync_end << 16) | - vc_format->hsync_start), VCAP_VC_HSYNC_HPOS); - writel_relaxed(((vc_format->f2_vsync_h_end << 16) | - vc_format->f2_vsync_h_start), VCAP_VC_VSYNC_F2_HPOS); - writel_iowmb(0x000033FF, VCAP_VC_BUF_CTRL); - - rc = vc_format->hactive_end - vc_format->hactive_start; - if (c_data->stride == VC_STRIDE_32) - rc = VCAP_STRIDE_CALC(rc, VCAP_STRIDE_ALIGN_32); - else - rc = VCAP_STRIDE_CALC(rc, VCAP_STRIDE_ALIGN_16); - if (vc_format->color_space) - rc *= 3; - - writel_relaxed(rc, VCAP_VC_Y_STRIDE); - writel_relaxed(rc, VCAP_VC_C_STRIDE); - - writel_relaxed(0x00010033 , VCAP_OFFSET(0x0898)); - writel_relaxed(0x00010fff , VCAP_OFFSET(0x089c)); - writel_relaxed(0x0a418820, VCAP_VC_IN_CTRL1); - writel_relaxed(0x16a4a0e6, VCAP_VC_IN_CTRL2); - writel_relaxed(0x2307b9ac, VCAP_VC_IN_CTRL3); - writel_relaxed(0x2f6ad272, VCAP_VC_IN_CTRL4); - writel_relaxed(0x00006b38, VCAP_VC_IN_CTRL5); - - writel_iowmb(0x00000001 , VCAP_OFFSET(0x0d00)); - pr_debug("%s: Done VC configuration\n", __func__); - - return 0; -} - -int detect_vc(struct vcap_dev *dev) -{ - int result; - result = readl_relaxed(VCAP_HARDWARE_VERSION_REG); - pr_debug("Hardware version: %08x\n", result); - if (result != VCAP_HARDWARE_VERSION) - return -ENODEV; - INIT_WORK(&dev->vc_to_vp_work.work, mov_buf_to_vp); - return 0; -} - -int deinit_vc(void) -{ - return 0; -} diff --git a/drivers/media/platform/msm/vcap/vcap_vc.h b/drivers/media/platform/msm/vcap/vcap_vc.h deleted file mode 100644 index 20320ddea1b07291472a07865cf6728af0cebcfe..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/vcap/vcap_vc.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) 2012, 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 VCAP_VC_H -#define VCAP_VC_H - -#include - -#include - -#define VCAP_HARDWARE_VERSION 0x10000000 - -#define VCAP_HARDWARE_VERSION_REG (VCAP_BASE + 0x0000) - -#define VCAP_VC_CTRL (VCAP_BASE + 0x0800) -#define VCAP_VC_NPL_CTRL (VCAP_BASE + 0x0804) -#define VCAP_VC_POLARITY (VCAP_BASE + 0x081c) -#define VCAP_VC_V_H_TOTAL (VCAP_BASE + 0x0820) -#define VCAP_VC_H_ACTIVE (VCAP_BASE + 0x0824) -#define VCAP_VC_V_ACTIVE (VCAP_BASE + 0x0828) -#define VCAP_VC_V_ACTIVE_F2 (VCAP_BASE + 0x0830) -#define VCAP_VC_VSYNC_VPOS (VCAP_BASE + 0x0834) -#define VCAP_VC_VSYNC_F2_VPOS (VCAP_BASE + 0x0838) -#define VCAP_VC_HSYNC_HPOS (VCAP_BASE + 0x0840) -#define VCAP_VC_VSYNC_F2_HPOS (VCAP_BASE + 0x083c) -#define VCAP_VC_BUF_CTRL (VCAP_BASE + 0x0848) - -#define VCAP_VC_Y_STRIDE (VCAP_BASE + 0x084c) -#define VCAP_VC_C_STRIDE (VCAP_BASE + 0x0850) - -#define VCAP_VC_Y_ADDR_1 (VCAP_BASE + 0x0854) -#define VCAP_VC_C_ADDR_1 (VCAP_BASE + 0x0858) -#define VCAP_VC_Y_ADDR_2 (VCAP_BASE + 0x085c) -#define VCAP_VC_C_ADDR_2 (VCAP_BASE + 0x0860) -#define VCAP_VC_Y_ADDR_3 (VCAP_BASE + 0x0864) -#define VCAP_VC_C_ADDR_3 (VCAP_BASE + 0x0868) -#define VCAP_VC_Y_ADDR_4 (VCAP_BASE + 0x086c) -#define VCAP_VC_C_ADDR_4 (VCAP_BASE + 0x0870) -#define VCAP_VC_Y_ADDR_5 (VCAP_BASE + 0x0874) -#define VCAP_VC_C_ADDR_5 (VCAP_BASE + 0x0878) -#define VCAP_VC_Y_ADDR_6 (VCAP_BASE + 0x087c) -#define VCAP_VC_C_ADDR_6 (VCAP_BASE + 0x0880) - -#define VCAP_VC_IN_CTRL1 (VCAP_BASE + 0x0808) -#define VCAP_VC_IN_CTRL2 (VCAP_BASE + 0x080c) -#define VCAP_VC_IN_CTRL3 (VCAP_BASE + 0x0810) -#define VCAP_VC_IN_CTRL4 (VCAP_BASE + 0x0814) -#define VCAP_VC_IN_CTRL5 (VCAP_BASE + 0x0818) - -#define VCAP_VC_INT_MASK (VCAP_BASE + 0x0884) -#define VCAP_VC_INT_CLEAR (VCAP_BASE + 0x0888) -#define VCAP_VC_INT_STATUS (VCAP_BASE + 0x088c) -#define VCAP_VC_TIMESTAMP (VCAP_BASE + 0x0034) - -#define VC_BUFFER_WRITTEN (0x3 << 1) -#define VC_BUFFER_MASK 0x7E -#define VC_ERR_MASK 0xE0001E00 -#define VC_VSYNC_MASK 0x1 - -int vc_start_capture(struct vcap_client_data *c_data); -int vc_hw_kick_off(struct vcap_client_data *c_data); -void vc_stop_capture(struct vcap_client_data *c_data); -int config_vc_format(struct vcap_client_data *c_data); -int detect_vc(struct vcap_dev *dev); -int deinit_vc(void); -irqreturn_t vc_handler(struct vcap_dev *dev); -#endif diff --git a/drivers/media/platform/msm/vcap/vcap_vp.c b/drivers/media/platform/msm/vcap/vcap_vp.c deleted file mode 100644 index bcaab5a1480caf024433f8d0b7127e65d435a26a..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/vcap/vcap_vp.c +++ /dev/null @@ -1,900 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include "vcap_vp.h" - -void config_nr_buffer(struct vcap_client_data *c_data, - struct vcap_buffer *buf) -{ - struct vcap_dev *dev = c_data->dev; - int size = c_data->vp_in_fmt.height * c_data->vp_in_fmt.width; - - writel_relaxed(buf->paddr, VCAP_VP_NR_T2_Y_BASE_ADDR); - writel_relaxed(buf->paddr + size, VCAP_VP_NR_T2_C_BASE_ADDR); -} - -void config_in_buffer(struct vcap_client_data *c_data, - struct vcap_buffer *buf) -{ - struct vcap_dev *dev = c_data->dev; - int size = c_data->vp_in_fmt.height * c_data->vp_in_fmt.width; - - writel_relaxed(buf->paddr, VCAP_VP_T2_Y_BASE_ADDR); - writel_relaxed(buf->paddr + size, VCAP_VP_T2_C_BASE_ADDR); -} - -void config_out_buffer(struct vcap_client_data *c_data, - struct vcap_buffer *buf) -{ - struct vcap_dev *dev = c_data->dev; - int size; - size = c_data->vp_out_fmt.height * c_data->vp_out_fmt.width; - writel_relaxed(buf->paddr, VCAP_VP_OUT_Y_BASE_ADDR); - writel_relaxed(buf->paddr + size, VCAP_VP_OUT_C_BASE_ADDR); -} - -int vp_setup_buffers(struct vcap_client_data *c_data) -{ - struct vp_action *vp_act; - struct vcap_dev *dev; - unsigned long flags = 0; - - if (!c_data->streaming) - return -ENOEXEC; - dev = c_data->dev; - pr_debug("VP: Start setup buffers\n"); - - if (dev->vp_shutdown) { - pr_debug("%s: VP shutting down, no buf setup\n", - __func__); - return -EPERM; - } - - /* No need to verify vp_client is not NULL caller does so */ - vp_act = &dev->vp_client->vp_action; - - spin_lock_irqsave(&dev->vp_client->cap_slock, flags); - if (list_empty(&vp_act->in_active)) { - spin_unlock_irqrestore(&dev->vp_client->cap_slock, flags); - pr_debug("%s: VP We have no more input buffers\n", - __func__); - return -EAGAIN; - } - - if (list_empty(&vp_act->out_active)) { - spin_unlock_irqrestore(&dev->vp_client->cap_slock, - flags); - pr_debug("%s: VP We have no more output buffers\n", - __func__); - return -EAGAIN; - } - - vp_act->bufT2 = list_entry(vp_act->in_active.next, - struct vcap_buffer, list); - list_del(&vp_act->bufT2->list); - - vp_act->bufOut = list_entry(vp_act->out_active.next, - struct vcap_buffer, list); - list_del(&vp_act->bufOut->list); - spin_unlock_irqrestore(&dev->vp_client->cap_slock, flags); - - config_in_buffer(c_data, vp_act->bufT2); - config_out_buffer(c_data, vp_act->bufOut); - return 0; -} - -static void mov_buf_to_vc(struct work_struct *work) -{ - struct vp_work_t *vp_work = container_of(work, struct vp_work_t, work); - struct v4l2_buffer p; - struct vb2_buffer *vb_vc; - struct vcap_buffer *buf_vc; - struct vb2_buffer *vb_vp; - struct vcap_buffer *buf_vp; - int rc; - - p.memory = V4L2_MEMORY_USERPTR; - - /* This loop exits when there is no more buffers left */ - while (1) { - p.type = V4L2_BUF_TYPE_INTERLACED_IN_DECODER; - if (!vp_work->cd->streaming) - return; - rc = vcvp_dqbuf(&vp_work->cd->vp_in_vidq, &p); - if (rc < 0) - return; - - vb_vc = vp_work->cd->vc_vidq.bufs[p.index]; - if (NULL == vb_vc) { - pr_debug("%s: buffer is NULL\n", __func__); - vcvp_qbuf(&vp_work->cd->vp_in_vidq, &p); - return; - } - buf_vc = container_of(vb_vc, struct vcap_buffer, vb); - - vb_vp = vp_work->cd->vp_in_vidq.bufs[p.index]; - if (NULL == vb_vp) { - pr_debug("%s: buffer is NULL\n", __func__); - vcvp_qbuf(&vp_work->cd->vp_in_vidq, &p); - return; - } - buf_vp = container_of(vb_vp, struct vcap_buffer, vb); - buf_vc->ion_handle = buf_vp->ion_handle; - buf_vc->paddr = buf_vp->paddr; - buf_vp->ion_handle = NULL; - buf_vp->paddr = 0; - - p.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - /* This call should not fail */ - rc = vcvp_qbuf(&vp_work->cd->vc_vidq, &p); - if (rc < 0) { - pr_err("%s: qbuf to vc failed\n", __func__); - buf_vp->ion_handle = buf_vc->ion_handle; - buf_vp->paddr = buf_vc->paddr; - buf_vc->ion_handle = NULL; - buf_vc->paddr = 0; - p.type = V4L2_BUF_TYPE_INTERLACED_IN_DECODER; - vcvp_qbuf(&vp_work->cd->vp_in_vidq, &p); - } - } -} - -void update_nr_value(struct vcap_dev *dev) -{ - struct nr_param *par; - uint32_t val = 0; - par = &dev->nr_param; - if (par->mode == NR_MANUAL) { - writel_relaxed(par->window << 24 | par->decay_ratio << 20, - VCAP_VP_NR_CONFIG); - if (par->threshold) - val = VP_NR_DYNAMIC_THRESHOLD; - writel_relaxed(val | - par->luma.max_blend_ratio << 24 | - par->luma.scale_diff_ratio << 12 | - par->luma.diff_limit_ratio << 8 | - par->luma.scale_motion_ratio << 4 | - par->luma.blend_limit_ratio << 0, - VCAP_VP_NR_LUMA_CONFIG); - writel_relaxed(val | - par->chroma.max_blend_ratio << 24 | - par->chroma.scale_diff_ratio << 12 | - par->chroma.diff_limit_ratio << 8 | - par->chroma.scale_motion_ratio << 4 | - par->chroma.blend_limit_ratio << 0, - VCAP_VP_NR_CHROMA_CONFIG); - } - dev->nr_update = false; -} - -static void vp_wq_fnc(struct work_struct *work) -{ - struct vp_work_t *vp_work = container_of(work, struct vp_work_t, work); - struct vcap_dev *dev; - struct vp_action *vp_act; - struct timeval tv; - unsigned long flags = 0; - uint32_t irq; - int rc; - bool top_field = 0; - - if (vp_work && vp_work->cd && vp_work->cd->dev) - dev = vp_work->cd->dev; - else - return; - - vp_act = &dev->vp_client->vp_action; - - rc = readl_relaxed(VCAP_OFFSET(0x048)); - while (!(rc & 0x00000100)) - rc = readl_relaxed(VCAP_OFFSET(0x048)); - - irq = readl_relaxed(VCAP_VP_INT_STATUS); - - writel_relaxed(0x00000000, VCAP_VP_BAL_VMOTION_STATE); - writel_relaxed(0x40000000, VCAP_VP_REDUCT_AVG_MOTION2); - - spin_lock_irqsave(&dev->vp_client->cap_slock, flags); - if (dev->nr_update == true) - update_nr_value(dev); - spin_unlock_irqrestore(&dev->vp_client->cap_slock, flags); - - /* Queue the done buffers */ - if (vp_act->vp_state == VP_NORMAL && - vp_act->bufNR.nr_pos != TM1_BUF) { - vb2_buffer_done(&vp_act->bufTm1->vb, VB2_BUF_STATE_DONE); - if (vp_work->cd->op_mode == VC_AND_VP_VCAP_OP) - queue_work(dev->vcap_wq, &dev->vp_to_vc_work.work); - } - - if (vp_act->bufT0 != NULL && vp_act->vp_state == VP_NORMAL) { - vp_act->bufOut->vb.v4l2_buf.timestamp = - vp_act->bufT0->vb.v4l2_buf.timestamp; - } - vb2_buffer_done(&vp_act->bufOut->vb, VB2_BUF_STATE_DONE); - - /* Cycle to next state */ - if (vp_act->vp_state != VP_NORMAL) - vp_act->vp_state++; - - /* Cycle Buffers*/ - if (dev->nr_param.mode) { - if (vp_act->bufNR.nr_pos == TM1_BUF) - vp_act->bufNR.nr_pos = BUF_NOT_IN_USE; - - if (vp_act->bufNR.nr_pos != BUF_NOT_IN_USE) - vp_act->bufNR.nr_pos++; - - vp_act->bufTm1 = vp_act->bufT0; - vp_act->bufT0 = vp_act->bufT1; - vp_act->bufT1 = vp_act->bufNRT2; - vp_act->bufNRT2 = vp_act->bufT2; - config_nr_buffer(vp_work->cd, vp_act->bufNRT2); - } else { - vp_act->bufTm1 = vp_act->bufT0; - vp_act->bufT0 = vp_act->bufT1; - vp_act->bufT1 = vp_act->bufT2; - } - - rc = vp_setup_buffers(vp_work->cd); - if (rc < 0) { - /* setup_buf failed because we are waiting for buffers */ - writel_relaxed(0x00000000, VCAP_VP_INTERRUPT_ENABLE); - writel_iowmb(irq, VCAP_VP_INT_CLEAR); - atomic_set(&dev->vp_enabled, 0); - if (dev->vp_shutdown) - wake_up(&dev->vp_dummy_waitq); - return; - } - - /* Config VP */ - if (vp_act->bufT2->vb.v4l2_buf.field == V4L2_FIELD_BOTTOM) - top_field = 1; - - writel_iowmb(0x00000000 | top_field, VCAP_VP_CTRL); - writel_iowmb(0x00010000 | top_field, VCAP_VP_CTRL); - enable_irq(dev->vpirq->start); - - do_gettimeofday(&tv); - dev->dbg_p.vp_timestamp = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - - writel_iowmb(irq, VCAP_VP_INT_CLEAR); -} - -irqreturn_t vp_handler(struct vcap_dev *dev) -{ - struct vcap_client_data *c_data; - struct vp_action *vp_act; - struct v4l2_event v4l2_evt; - uint32_t irq; - int rc; - struct timeval tv; - uint32_t new_ts; - - irq = readl_relaxed(VCAP_VP_INT_STATUS); - if (dev->vp_dummy_event == true) { - writel_relaxed(irq, VCAP_VP_INT_CLEAR); - dev->vp_dummy_complete = true; - wake_up(&dev->vp_dummy_waitq); - return IRQ_HANDLED; - } - - if (irq & 0x02000000) { - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VP_REG_R_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - if (irq & 0x01000000) { - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VP_REG_W_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - if (irq & 0x00020000) { - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VP_IN_HEIGHT_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - if (irq & 0x00010000) { - v4l2_evt.type = V4L2_EVENT_PRIVATE_START + - VCAP_VP_IN_WIDTH_ERR_EVENT; - v4l2_event_queue(dev->vfd, &v4l2_evt); - } - - pr_debug("%s: irq=0x%08x\n", __func__, irq); - if (!(irq & (VP_PIC_DONE | VP_MODE_CHANGE))) { - writel_relaxed(irq, VCAP_VP_INT_CLEAR); - pr_err("VP IRQ shows some error\n"); - return IRQ_HANDLED; - } - - if (dev->vp_client == NULL) { - writel_relaxed(irq, VCAP_VP_INT_CLEAR); - pr_err("VC: There is no active vp client\n"); - return IRQ_HANDLED; - } - - vp_act = &dev->vp_client->vp_action; - c_data = dev->vp_client; - - if (vp_act->vp_state == VP_UNKNOWN) { - writel_relaxed(irq, VCAP_VP_INT_CLEAR); - pr_err("%s: VP is in an unknown state\n", - __func__); - return -EAGAIN; - } - - do_gettimeofday(&tv); - new_ts = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - if (new_ts > dev->dbg_p.vp_timestamp) { - dev->dbg_p.vp_ewma = ((new_ts - dev->dbg_p.vp_timestamp) / - 10 + (dev->dbg_p.vp_ewma / 10 * 9)); - } - - dev->dbg_p.vp_timestamp = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - - INIT_WORK(&dev->vp_work.work, vp_wq_fnc); - dev->vp_work.cd = c_data; - rc = queue_work(dev->vcap_wq, &dev->vp_work.work); - - disable_irq_nosync(dev->vpirq->start); - return IRQ_HANDLED; -} - -int vp_sw_reset(struct vcap_dev *dev) -{ - int timeout; - writel_iowmb(0x00000010, VCAP_SW_RESET_REQ); - timeout = 10000; - while (1) { - if (!(readl_relaxed(VCAP_SW_RESET_STATUS) & 0x10)) - break; - timeout--; - if (timeout == 0) { - /* This should not happen */ - pr_err("VP is not resetting properly\n"); - writel_iowmb(0x00000000, VCAP_SW_RESET_REQ); - return -EINVAL; - } - } - return 0; -} - -void vp_stop_capture(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - int rc; - - dev->vp_shutdown = true; - flush_workqueue(dev->vcap_wq); - - if (atomic_read(&dev->vp_enabled) == 1) { - rc = wait_event_interruptible_timeout(dev->vp_dummy_waitq, - !atomic_read(&dev->vp_enabled), - msecs_to_jiffies(50)); - if (rc == 0 && atomic_read(&dev->vp_enabled) == 1) { - /* This should not happen, if it does hw is stuck */ - disable_irq_nosync(dev->vpirq->start); - atomic_set(&dev->vp_enabled, 0); - pr_err("%s: VP Timeout and VP still running\n", - __func__); - } - } - - vp_sw_reset(dev); - dev->vp_shutdown = false; -} - -int config_vp_format(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - int rc; - - INIT_WORK(&dev->vp_to_vc_work.work, mov_buf_to_vc); - dev->vp_to_vc_work.cd = c_data; - - /* SW restart VP */ - rc = vp_sw_reset(dev); - if (rc < 0) - return rc; - - /* Film Mode related settings */ - writel_iowmb(0x00000000, VCAP_VP_FILM_PROJECTION_T0); - writel_relaxed(0x00000000, VCAP_VP_FILM_PROJECTION_T2); - writel_relaxed(0x00000000, VCAP_VP_FILM_PAST_MAX_PROJ); - writel_relaxed(0x00000000, VCAP_VP_FILM_PAST_MIN_PROJ); - writel_relaxed(0x00000000, VCAP_VP_FILM_SEQUENCE_HIST); - writel_relaxed(0x00000000, VCAP_VP_FILM_MODE_STATE); - - writel_relaxed(0x00000000, VCAP_VP_BAL_VMOTION_STATE); - writel_relaxed(0x00000010, VCAP_VP_REDUCT_AVG_MOTION); - writel_relaxed(0x40000000, VCAP_VP_REDUCT_AVG_MOTION2); - writel_relaxed(0x40000000, VCAP_VP_NR_AVG_LUMA); - writel_relaxed(0x40000000, VCAP_VP_NR_AVG_CHROMA); - writel_relaxed(0x40000000, VCAP_VP_NR_CTRL_LUMA); - writel_relaxed(0x40000000, VCAP_VP_NR_CTRL_CHROMA); - writel_relaxed(0x00000000, VCAP_VP_BAL_AVG_BLEND); - writel_relaxed(0x00000000, VCAP_VP_VMOTION_HIST); - writel_relaxed(0x05047D19, VCAP_VP_FILM_ANALYSIS_CONFIG); - writel_relaxed(0x20260200, VCAP_VP_FILM_STATE_CONFIG); - writel_relaxed(0x23A60114, VCAP_VP_FVM_CONFIG); - writel_relaxed(0x03043210, VCAP_VP_FILM_ANALYSIS_CONFIG2); - writel_relaxed(0x04DB7A51, VCAP_VP_MIXED_ANALYSIS_CONFIG); - writel_relaxed(0x14224916, VCAP_VP_SPATIAL_CONFIG); - writel_relaxed(0x83270400, VCAP_VP_SPATIAL_CONFIG2); - writel_relaxed(0x0F000F92, VCAP_VP_SPATIAL_CONFIG3); - writel_relaxed(0x00000000, VCAP_VP_TEMPORAL_CONFIG); - writel_relaxed(0x00000000, VCAP_VP_PIXEL_DIFF_CONFIG); - writel_relaxed(0x0C090511, VCAP_VP_H_FREQ_CONFIG); - writel_relaxed(0x0A000000, VCAP_VP_NR_CONFIG); - writel_relaxed(0x008F4149, VCAP_VP_NR_LUMA_CONFIG); - writel_relaxed(0x008F4149, VCAP_VP_NR_CHROMA_CONFIG); - writel_relaxed(0x43C0FD0C, VCAP_VP_BAL_CONFIG); - writel_relaxed(0x00000255, VCAP_VP_BAL_MOTION_CONFIG); - writel_relaxed(0x24154252, VCAP_VP_BAL_LIGHT_COMB); - writel_relaxed(0x10024414, VCAP_VP_BAL_VMOTION_CONFIG); - writel_relaxed(0x00000002, VCAP_VP_NR_CONFIG2); - writel_relaxed((c_data->vp_out_fmt.height-1)<<16 | - (c_data->vp_out_fmt.width - 1), VCAP_VP_FRAME_SIZE); - writel_relaxed(0x00000000, VCAP_VP_SPLIT_SCRN_CTRL); - - return 0; -} - -int init_motion_buf(struct vcap_client_data *c_data) -{ - int rc; - struct vcap_dev *dev = c_data->dev; - struct ion_handle *handle = NULL; - unsigned long len; - dma_addr_t paddr; - void *vaddr; - size_t size = ((c_data->vp_out_fmt.width + 63) >> 6) * - ((c_data->vp_out_fmt.height + 7) >> 3) * 16; - - if (c_data->vp_action.motionHandle) { - pr_err("Motion buffer has already been created"); - return -ENOEXEC; - } - - handle = ion_alloc(dev->ion_client, size, SZ_4K, - ION_HEAP(ION_CP_MM_HEAP_ID), 0); - if (IS_ERR_OR_NULL(handle)) { - pr_err("%s: ion_alloc failed\n", __func__); - return -ENOMEM; - } - - vaddr = ion_map_kernel(dev->ion_client, handle); - if (IS_ERR(vaddr)) { - pr_err("%s: Map motion buffer failed\n", __func__); - ion_free(dev->ion_client, handle); - rc = -ENOMEM; - return rc; - } - - memset(vaddr, 0, size); - ion_unmap_kernel(dev->ion_client, handle); - - rc = ion_map_iommu(dev->ion_client, handle, - dev->domain_num, 0, SZ_4K, 0, &paddr, &len, - 0, 0); - if (rc < 0) { - pr_err("%s: map_iommu failed\n", __func__); - ion_free(dev->ion_client, handle); - return rc; - } - - c_data->vp_action.motionHandle = handle; - - vaddr = NULL; - - writel_iowmb(paddr, VCAP_VP_MOTION_EST_ADDR); - return 0; -} - -void deinit_motion_buf(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - if (!c_data->vp_action.motionHandle) { - pr_err("Motion buffer has not been created"); - return; - } - - writel_iowmb(0x00000000, VCAP_VP_MOTION_EST_ADDR); - ion_unmap_iommu(dev->ion_client, c_data->vp_action.motionHandle, - dev->domain_num, 0); - ion_free(dev->ion_client, c_data->vp_action.motionHandle); - c_data->vp_action.motionHandle = NULL; - return; -} - -int init_nr_buf(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - struct ion_handle *handle = NULL; - size_t frame_size, tot_size; - unsigned long len; - dma_addr_t paddr; - int rc; - - if (c_data->vp_action.bufNR.nr_handle) { - pr_err("NR buffer has already been created"); - return -ENOEXEC; - } - - frame_size = c_data->vp_in_fmt.width * c_data->vp_in_fmt.height; - if (c_data->vp_in_fmt.pixfmt == V4L2_PIX_FMT_NV16) - tot_size = frame_size * 2; - else - tot_size = frame_size / 2 * 3; - - handle = ion_alloc(dev->ion_client, tot_size, SZ_4K, - ION_HEAP(ION_CP_MM_HEAP_ID), 0); - if (IS_ERR_OR_NULL(handle)) { - pr_err("%s: ion_alloc failed\n", __func__); - return -ENOMEM; - } - - rc = ion_map_iommu(dev->ion_client, handle, - dev->domain_num, 0, SZ_4K, 0, &paddr, &len, - 0, 0); - if (rc < 0) { - pr_err("%s: map_iommu failed\n", __func__); - ion_free(dev->ion_client, handle); - return rc; - } - - c_data->vp_action.bufNR.nr_handle = handle; - update_nr_value(dev); - - c_data->vp_action.bufNR.paddr = paddr; - rc = readl_relaxed(VCAP_VP_NR_CONFIG2); - rc |= (((c_data->vp_out_fmt.width / 16) << 20) | 0x1); - writel_relaxed(rc, VCAP_VP_NR_CONFIG2); - writel_relaxed(paddr, VCAP_VP_NR_T2_Y_BASE_ADDR); - writel_relaxed(paddr + frame_size, VCAP_VP_NR_T2_C_BASE_ADDR); - c_data->vp_action.bufNR.nr_pos = NRT2_BUF; - return 0; -} - -void deinit_nr_buf(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - struct nr_buffer *buf; - uint32_t rc; - - if (!c_data->vp_action.bufNR.nr_handle) { - pr_err("NR buffer has not been created"); - return; - } - buf = &c_data->vp_action.bufNR; - - rc = readl_relaxed(VCAP_VP_NR_CONFIG2); - rc &= !(0x0FF00001); - writel_relaxed(rc, VCAP_VP_NR_CONFIG2); - - ion_unmap_iommu(dev->ion_client, buf->nr_handle, dev->domain_num, 0); - ion_free(dev->ion_client, buf->nr_handle); - buf->nr_handle = NULL; - buf->paddr = 0; - return; -} - -int nr_s_param(struct vcap_client_data *c_data, struct nr_param *param) -{ - if (param->mode != NR_MANUAL) - return 0; - - /* Verify values in range */ - if (param->window > VP_NR_MAX_WINDOW) - return -EINVAL; - if (param->luma.max_blend_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->luma.scale_diff_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->luma.diff_limit_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->luma.scale_motion_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->luma.blend_limit_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->chroma.max_blend_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->chroma.scale_diff_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->chroma.diff_limit_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->chroma.scale_motion_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - if (param->chroma.blend_limit_ratio > VP_NR_MAX_RATIO) - return -EINVAL; - return 0; -} - -void nr_g_param(struct vcap_client_data *c_data, struct nr_param *param) -{ - struct vcap_dev *dev = c_data->dev; - uint32_t rc; - rc = readl_relaxed(VCAP_VP_NR_CONFIG); - param->window = BITS_VALUE(rc, 24, 4); - param->decay_ratio = BITS_VALUE(rc, 20, 3); - - rc = readl_relaxed(VCAP_VP_NR_LUMA_CONFIG); - param->threshold = NR_THRESHOLD_STATIC; - if (BITS_VALUE(rc, 16, 1)) - param->threshold = NR_THRESHOLD_DYNAMIC; - param->luma.max_blend_ratio = BITS_VALUE(rc, 24, 4); - param->luma.scale_diff_ratio = BITS_VALUE(rc, 12, 4); - param->luma.diff_limit_ratio = BITS_VALUE(rc, 8, 4); - param->luma.scale_motion_ratio = BITS_VALUE(rc, 4, 4); - param->luma.blend_limit_ratio = BITS_VALUE(rc, 0, 4); - - rc = readl_relaxed(VCAP_VP_NR_CHROMA_CONFIG); - param->chroma.max_blend_ratio = BITS_VALUE(rc, 24, 4); - param->chroma.scale_diff_ratio = BITS_VALUE(rc, 12, 4); - param->chroma.diff_limit_ratio = BITS_VALUE(rc, 8, 4); - param->chroma.scale_motion_ratio = BITS_VALUE(rc, 4, 4); - param->chroma.blend_limit_ratio = BITS_VALUE(rc, 0, 4); -} - -void s_default_nr_val(struct nr_param *param) -{ - param->threshold = NR_THRESHOLD_STATIC; - param->window = 10; - param->decay_ratio = 0; - param->luma.max_blend_ratio = 0; - param->luma.scale_diff_ratio = 4; - param->luma.diff_limit_ratio = 1; - param->luma.scale_motion_ratio = 4; - param->luma.blend_limit_ratio = 9; - param->chroma.max_blend_ratio = 0; - param->chroma.scale_diff_ratio = 4; - param->chroma.diff_limit_ratio = 1; - param->chroma.scale_motion_ratio = 4; - param->chroma.blend_limit_ratio = 9; -} - -int vp_dummy_event(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev = c_data->dev; - unsigned int width, height; - struct ion_handle *handle = NULL; - unsigned long len; - dma_addr_t paddr; - uint32_t reg; - int rc = 0; - - pr_debug("%s: Start VP dummy event\n", __func__); - handle = ion_alloc(dev->ion_client, 0x1200, SZ_4K, - ION_HEAP(ION_CP_MM_HEAP_ID), 0); - if (IS_ERR_OR_NULL(handle)) { - pr_err("%s: ion_alloc failed\n", __func__); - return -ENOMEM; - } - - rc = ion_map_iommu(dev->ion_client, handle, - dev->domain_num, 0, SZ_4K, 0, &paddr, &len, - 0, 0); - if (rc < 0) { - pr_err("%s: map_iommu failed\n", __func__); - ion_free(dev->ion_client, handle); - return rc; - } - - width = c_data->vp_out_fmt.width; - height = c_data->vp_out_fmt.height; - - c_data->vp_out_fmt.width = 0x3F; - c_data->vp_out_fmt.height = 0x16; - - config_vp_format(c_data); - writel_relaxed(paddr, VCAP_VP_T1_Y_BASE_ADDR); - writel_relaxed(paddr + 0x2C0, VCAP_VP_T1_C_BASE_ADDR); - writel_relaxed(paddr + 0x440, VCAP_VP_T2_Y_BASE_ADDR); - writel_relaxed(paddr + 0x700, VCAP_VP_T2_C_BASE_ADDR); - writel_relaxed(paddr + 0x880, VCAP_VP_OUT_Y_BASE_ADDR); - writel_relaxed(paddr + 0xB40, VCAP_VP_OUT_C_BASE_ADDR); - writel_iowmb(paddr + 0x1100, VCAP_VP_MOTION_EST_ADDR); - writel_relaxed(4 << 20 | 0x2 << 4, VCAP_VP_IN_CONFIG); - writel_relaxed(4 << 20 | 0x1 << 4, VCAP_VP_OUT_CONFIG); - - dev->vp_dummy_event = true; - - enable_irq(dev->vpirq->start); - writel_relaxed(0x01100101, VCAP_VP_INTERRUPT_ENABLE); - writel_iowmb(0x00000000, VCAP_VP_CTRL); - writel_iowmb(0x00010000, VCAP_VP_CTRL); - - rc = wait_event_interruptible_timeout(dev->vp_dummy_waitq, - dev->vp_dummy_complete, msecs_to_jiffies(50)); - if (!rc && !dev->vp_dummy_complete) { - pr_err("%s: VP dummy event timeout", __func__); - rc = -ETIME; - - vp_sw_reset(dev); - dev->vp_dummy_complete = false; - } - - writel_relaxed(0x00000000, VCAP_VP_INTERRUPT_ENABLE); - disable_irq(dev->vpirq->start); - dev->vp_dummy_event = false; - - reg = readl_relaxed(VCAP_OFFSET(0x0D94)); - writel_relaxed(reg, VCAP_OFFSET(0x0D9C)); - - c_data->vp_out_fmt.width = width; - c_data->vp_out_fmt.height = height; - ion_unmap_iommu(dev->ion_client, handle, dev->domain_num, 0); - ion_free(dev->ion_client, handle); - - pr_debug("%s: Exit VP dummy event\n", __func__); - return rc; -} - -int kickoff_vp(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev; - struct vp_action *vp_act; - struct timeval tv; - unsigned long flags = 0; - unsigned int chroma_fmt = 0; - int size; - bool top_field = 0; - - if (!c_data->streaming) - return -ENOEXEC; - - dev = c_data->dev; - pr_debug("Start VP Kickoff\n"); - - if (dev->vp_client == NULL) { - pr_err("No active vp client\n"); - return -ENODEV; - } - vp_act = &dev->vp_client->vp_action; - - spin_lock_irqsave(&dev->vp_client->cap_slock, flags); - if (list_empty(&vp_act->in_active)) { - spin_unlock_irqrestore(&dev->vp_client->cap_slock, flags); - pr_err("%s: VP We have no more input buffers\n", - __func__); - return -EAGAIN; - } - - vp_act->bufT1 = list_entry(vp_act->in_active.next, - struct vcap_buffer, list); - list_del(&vp_act->bufT1->list); - - if (list_empty(&vp_act->in_active)) { - spin_unlock_irqrestore(&dev->vp_client->cap_slock, flags); - list_add(&vp_act->bufT1->list, &vp_act->in_active); - pr_err("%s: VP We have no more input buffers\n", - __func__); - return -EAGAIN; - } - - vp_act->bufT2 = list_entry(vp_act->in_active.next, - struct vcap_buffer, list); - list_del(&vp_act->bufT2->list); - - if (list_empty(&vp_act->out_active)) { - spin_unlock_irqrestore(&dev->vp_client->cap_slock, flags); - list_add(&vp_act->bufT2->list, &vp_act->in_active); - list_add(&vp_act->bufT1->list, &vp_act->in_active); - pr_err("%s: VP We have no more output buffers\n", - __func__); - return -EAGAIN; - } - - vp_act->bufOut = list_entry(vp_act->out_active.next, - struct vcap_buffer, list); - list_del(&vp_act->bufOut->list); - spin_unlock_irqrestore(&dev->vp_client->cap_slock, flags); - - size = c_data->vp_in_fmt.height * c_data->vp_in_fmt.width; - writel_relaxed(vp_act->bufT1->paddr, VCAP_VP_T1_Y_BASE_ADDR); - writel_relaxed(vp_act->bufT1->paddr + size, VCAP_VP_T1_C_BASE_ADDR); - - config_in_buffer(c_data, vp_act->bufT2); - config_out_buffer(c_data, vp_act->bufOut); - - /* Config VP */ - if (c_data->vp_in_fmt.pixfmt == V4L2_PIX_FMT_NV16) - chroma_fmt = 1; - writel_relaxed((c_data->vp_in_fmt.width / 16) << 20 | - chroma_fmt << 11 | 0x2 << 4, VCAP_VP_IN_CONFIG); - - chroma_fmt = 0; - if (c_data->vp_out_fmt.pixfmt == V4L2_PIX_FMT_NV16) - chroma_fmt = 1; - - writel_relaxed((c_data->vp_out_fmt.width / 16) << 20 | - chroma_fmt << 11 | 0x1 << 4, VCAP_VP_OUT_CONFIG); - - /* Enable Interrupt */ - if (vp_act->bufT2->vb.v4l2_buf.field == V4L2_FIELD_BOTTOM) - top_field = 1; - vp_act->vp_state = VP_FRAME2; - writel_relaxed(0x01100001, VCAP_VP_INTERRUPT_ENABLE); - writel_iowmb(0x00000000 | top_field, VCAP_VP_CTRL); - writel_iowmb(0x00010000 | top_field, VCAP_VP_CTRL); - atomic_set(&c_data->dev->vp_enabled, 1); - enable_irq(dev->vpirq->start); - - do_gettimeofday(&tv); - dev->dbg_p.vp_timestamp = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - - return 0; -} - -int continue_vp(struct vcap_client_data *c_data) -{ - struct vcap_dev *dev; - struct vp_action *vp_act; - struct timeval tv; - int rc; - bool top_field = 0; - - pr_debug("Start VP Continue\n"); - dev = c_data->dev; - - if (dev->vp_client == NULL) { - pr_err("No active vp client\n"); - return -ENODEV; - } - vp_act = &dev->vp_client->vp_action; - - if (vp_act->vp_state == VP_UNKNOWN) { - pr_err("%s: VP is in an unknown state\n", - __func__); - return -EAGAIN; - } - - rc = vp_setup_buffers(c_data); - if (rc < 0) - return rc; - - if (vp_act->bufT2->vb.v4l2_buf.field == V4L2_FIELD_BOTTOM) - top_field = 1; - - /* Config VP & Enable Interrupt */ - writel_relaxed(0x01100001, VCAP_VP_INTERRUPT_ENABLE); - writel_iowmb(0x00000000 | top_field, VCAP_VP_CTRL); - writel_iowmb(0x00010000 | top_field, VCAP_VP_CTRL); - - atomic_set(&c_data->dev->vp_enabled, 1); - enable_irq(dev->vpirq->start); - - do_gettimeofday(&tv); - dev->dbg_p.vp_timestamp = (uint32_t) (tv.tv_sec * VCAP_USEC + - tv.tv_usec); - - return 0; -} diff --git a/drivers/media/platform/msm/vcap/vcap_vp.h b/drivers/media/platform/msm/vcap/vcap_vp.h deleted file mode 100644 index bd825fc891eccf87b3f072caafa23a724b687e31..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/vcap/vcap_vp.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (c) 2012, 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 VCAP_VP_H -#define VCAP_VP_H - -#include - -#include - -#define VCAP_VP_INT_STATUS (VCAP_BASE + 0x404) -#define VCAP_VP_INT_CLEAR (VCAP_BASE + 0x40C) - -#define VCAP_VP_SW_RESET (VCAP_BASE + 0x410) -#define VCAP_VP_INTERRUPT_ENABLE (VCAP_BASE + 0x408) - -#define VCAP_VP_FILM_PROJECTION_T0 (VCAP_BASE + 0x50C) -#define VCAP_VP_FILM_PROJECTION_T2 (VCAP_BASE + 0x508) -#define VCAP_VP_FILM_PAST_MAX_PROJ (VCAP_BASE + 0x510) -#define VCAP_VP_FILM_PAST_MIN_PROJ (VCAP_BASE + 0x514) -#define VCAP_VP_FILM_SEQUENCE_HIST (VCAP_BASE + 0x504) -#define VCAP_VP_FILM_MODE_STATE (VCAP_BASE + 0x500) - -#define VCAP_VP_BAL_VMOTION_STATE (VCAP_BASE + 0x690) -#define VCAP_VP_REDUCT_AVG_MOTION (VCAP_BASE + 0x610) -#define VCAP_VP_REDUCT_AVG_MOTION2 (VCAP_BASE + 0x614) - -#define VCAP_VP_NR_AVG_LUMA (VCAP_BASE + 0x608) -#define VCAP_VP_NR_AVG_CHROMA (VCAP_BASE + 0x60C) -#define VCAP_VP_NR_CTRL_LUMA (VCAP_BASE + 0x600) -#define VCAP_VP_NR_CTRL_CHROMA (VCAP_BASE + 0x604) - -#define VCAP_VP_BAL_AVG_BLEND (VCAP_BASE + 0x694) -#define VCAP_VP_VMOTION_HIST (VCAP_BASE + 0x6F8) - -#define VCAP_VP_MOTION_EST_ADDR (VCAP_BASE + 0x4E0) -#define VCAP_VP_FILM_ANALYSIS_CONFIG (VCAP_BASE + 0x520) -#define VCAP_VP_FILM_STATE_CONFIG (VCAP_BASE + 0x524) - -#define VCAP_VP_FVM_CONFIG (VCAP_BASE + 0x550) -#define VCAP_VP_FILM_ANALYSIS_CONFIG2 (VCAP_BASE + 0x52C) -#define VCAP_VP_MIXED_ANALYSIS_CONFIG (VCAP_BASE + 0x530) - -#define VCAP_VP_SPATIAL_CONFIG (VCAP_BASE + 0x580) -#define VCAP_VP_SPATIAL_CONFIG2 (VCAP_BASE + 0x584) -#define VCAP_VP_SPATIAL_CONFIG3 (VCAP_BASE + 0x588) -#define VCAP_VP_TEMPORAL_CONFIG (VCAP_BASE + 0x5C0) - -#define VCAP_VP_PIXEL_DIFF_CONFIG (VCAP_BASE + 0x6FC) -#define VCAP_VP_H_FREQ_CONFIG (VCAP_BASE + 0x528) -#define VCAP_VP_NR_CONFIG (VCAP_BASE + 0x620) -#define VCAP_VP_NR_LUMA_CONFIG (VCAP_BASE + 0x624) -#define VCAP_VP_NR_CHROMA_CONFIG (VCAP_BASE + 0x628) -#define VCAP_VP_BAL_CONFIG (VCAP_BASE + 0x680) -#define VCAP_VP_BAL_MOTION_CONFIG (VCAP_BASE + 0x684) -#define VCAP_VP_BAL_LIGHT_COMB (VCAP_BASE + 0x688) -#define VCAP_VP_BAL_VMOTION_CONFIG (VCAP_BASE + 0x68C) - -#define VCAP_VP_NR_CONFIG2 (VCAP_BASE + 0x484) -#define VCAP_VP_FRAME_SIZE (VCAP_BASE + 0x48C) -#define VCAP_VP_SPLIT_SCRN_CTRL (VCAP_BASE + 0x750) - -#define VCAP_VP_IN_CONFIG (VCAP_BASE + 0x480) -#define VCAP_VP_OUT_CONFIG (VCAP_BASE + 0x488) - -#define VCAP_VP_T2_Y_BASE_ADDR (VCAP_BASE + 0x4C0) -#define VCAP_VP_T2_C_BASE_ADDR (VCAP_BASE + 0x4C4) -#define VCAP_VP_OUT_Y_BASE_ADDR (VCAP_BASE + 0x4CC) -#define VCAP_VP_OUT_C_BASE_ADDR (VCAP_BASE + 0x4D0) -#define VCAP_VP_OUT_CR_BASE_ADDR (VCAP_BASE + 0x4D4) - -#define VCAP_VP_CTRL (VCAP_BASE + 0x4D8) - -#define VCAP_VP_T1_Y_BASE_ADDR (VCAP_BASE + 0x4A8) -#define VCAP_VP_T1_C_BASE_ADDR (VCAP_BASE + 0x4Ac) -#define VCAP_VP_NR_T2_Y_BASE_ADDR (VCAP_BASE + 0x4B4) -#define VCAP_VP_NR_T2_C_BASE_ADDR (VCAP_BASE + 0x4B8) - -#define VP_PIC_DONE (0x1 << 0) -#define VP_MODE_CHANGE (0x1 << 8) - -#define VP_NR_MAX_WINDOW 120 -#define VP_NR_MAX_RATIO 16 -#define VP_NR_DYNAMIC_THRESHOLD 0x000F0000 - -#define BITS_MASK(start, num_of_bits) \ - (((1 << (num_of_bits)) - 1) << (start)) - -#define BITS_VALUE(x, start, num_of_bits) \ - (((x) & BITS_MASK(start, num_of_bits)) >> (start)) - -irqreturn_t vp_handler(struct vcap_dev *dev); -int config_vp_format(struct vcap_client_data *c_data); -void vp_stop_capture(struct vcap_client_data *c_data); -int init_motion_buf(struct vcap_client_data *c_data); -void deinit_motion_buf(struct vcap_client_data *c_data); -int init_nr_buf(struct vcap_client_data *c_data); -void deinit_nr_buf(struct vcap_client_data *c_data); -int nr_s_param(struct vcap_client_data *c_data, struct nr_param *param); -void nr_g_param(struct vcap_client_data *c_data, struct nr_param *param); -void s_default_nr_val(struct nr_param *param); -int kickoff_vp(struct vcap_client_data *c_data); -int continue_vp(struct vcap_client_data *c_data); -int vp_dummy_event(struct vcap_client_data *c_data); - -#endif diff --git a/drivers/media/platform/msm/wfd/Makefile b/drivers/media/platform/msm/wfd/Makefile index c05f517e288950a0ba06bf669358d26181eef65d..04e68b0dc333fc720dec898ca4a82d1bdb249a9d 100644 --- a/drivers/media/platform/msm/wfd/Makefile +++ b/drivers/media/platform/msm/wfd/Makefile @@ -5,20 +5,16 @@ ifeq ($(CONFIG_MSM_WFD),y) #pick up the MDP subdevice ifeq ($(CONFIG_FB_MSM_WRITEBACK_MSM_PANEL),y) - obj-y += mdp-4-subdev.o else ifeq ($(CONFIG_FB_MSM_MDSS_WRITEBACK),y) obj-y += mdp-5-subdev.o else - obj-y += mdp-dummy-subdev.o endif #pick up the Encoder subdevice ifeq ($(CONFIG_MSM_VIDC_1080P),y) - obj-y += enc-mfc-subdev.o else ifeq ($(CONFIG_MSM_VIDC_V4L2),y) obj-y += enc-venus-subdev.o else - obj-y += enc-dummy-subdev.o endif endif diff --git a/drivers/media/platform/msm/wfd/enc-dummy-subdev.c b/drivers/media/platform/msm/wfd/enc-dummy-subdev.c deleted file mode 100644 index 3acb6f8beb9629cf476b7272d49d53b735ee3dec..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/wfd/enc-dummy-subdev.c +++ /dev/null @@ -1,575 +0,0 @@ -/* Copyright (c) 2013, 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 -#include -#include -#include -#include "enc-subdev.h" -#include "wfd-util.h" - -#ifndef CONFIG_MSM_WFD_DEBUG -#error "Dummy subdevice must only be used when CONFIG_MSM_WFD_DEBUG=y" -#endif - -#define DEFAULT_WIDTH 1920 -#define DEFAULT_HEIGHT 1080 -#define ALLOC_SIZE ALIGN((DEFAULT_WIDTH * DEFAULT_HEIGHT * 3) / 2, SZ_1M) -#define FILL_SIZE ((DEFAULT_WIDTH * DEFAULT_HEIGHT * 3) / 2) - -static struct ion_client *venc_ion_client; -struct venc_inst { - struct mutex lock; - struct venc_msg_ops vmops; - struct mem_region output_bufs, input_bufs; - struct workqueue_struct *wq; -}; - -struct encode_task { - struct venc_inst *inst; - struct work_struct work; -}; - -int venc_load_fw(struct v4l2_subdev *sd) -{ - return 0; -} - -int venc_init(struct v4l2_subdev *sd, u32 val) -{ - if (!venc_ion_client) - venc_ion_client = msm_ion_client_create(-1, "wfd_enc_subdev"); - - return venc_ion_client ? 0 : -ENOMEM; -} - -static long venc_open(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst = NULL; - struct venc_msg_ops *vmops = arg; - int rc = 0; - - if (!vmops) { - WFD_MSG_ERR("Callbacks required for %s\n", __func__); - rc = -EINVAL; - goto venc_open_fail; - } else if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - rc = -EINVAL; - goto venc_open_fail; - } - - inst = kzalloc(sizeof(*inst), GFP_KERNEL); - if (!inst) { - WFD_MSG_ERR("Failed to allocate memory\n"); - rc = -EINVAL; - goto venc_open_fail; - } - - INIT_LIST_HEAD(&inst->output_bufs.list); - INIT_LIST_HEAD(&inst->input_bufs.list); - mutex_init(&inst->lock); - inst->wq = create_workqueue("venc-dummy-subdev"); - inst->vmops = *vmops; - sd->dev_priv = inst; - vmops->cookie = inst; - return 0; -venc_open_fail: - return rc; -} - -static long venc_close(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst = NULL; - int rc = 0; - - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - rc = -EINVAL; - goto venc_close_fail; - } - - inst = (struct venc_inst *)sd->dev_priv; - destroy_workqueue(inst->wq); - kfree(inst); - sd->dev_priv = inst = NULL; -venc_close_fail: - return rc; - -} - -static long venc_get_buffer_req(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct bufreq *bufreq = arg; - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - rc = -EINVAL; - goto venc_buf_req_fail; - } else if (!arg) { - WFD_MSG_ERR("Invalid buffer requirements\n"); - rc = -EINVAL; - goto venc_buf_req_fail; - } - - - bufreq->count = 3; - bufreq->size = ALLOC_SIZE; -venc_buf_req_fail: - return rc; -} - -static long venc_set_buffer_req(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct bufreq *bufreq = arg; - - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - rc = -EINVAL; - goto venc_buf_req_fail; - } else if (!arg) { - WFD_MSG_ERR("Invalid buffer requirements\n"); - rc = -EINVAL; - goto venc_buf_req_fail; - } - - bufreq->size = ALLOC_SIZE; -venc_buf_req_fail: - return rc; - -} - -static long venc_start(struct v4l2_subdev *sd) -{ - return 0; -} - -static long venc_stop(struct v4l2_subdev *sd) -{ - struct venc_inst *inst = NULL; - - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - return -EINVAL; - } - - inst = (struct venc_inst *)sd->dev_priv; - flush_workqueue(inst->wq); - return 0; -} - -static long venc_set_input_buffer(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_set_output_buffer(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_set_format(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst = NULL; - struct v4l2_format *fmt = arg; - - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - return -EINVAL; - } else if (!fmt) { - WFD_MSG_ERR("Invalid format\n"); - return -EINVAL; - } else if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - WFD_MSG_ERR("Invalid buffer type %d\n", fmt->type); - return -ENOTSUPP; - } - - inst = (struct venc_inst *)sd->dev_priv; - fmt->fmt.pix.sizeimage = ALLOC_SIZE; - return 0; -} - -static long venc_set_framerate(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static int venc_map_user_to_kernel(struct venc_inst *inst, - struct mem_region *mregion) -{ - int rc = 0; - unsigned long flags = 0; - if (!mregion) { - rc = -EINVAL; - goto venc_map_fail; - } - - mregion->ion_handle = ion_import_dma_buf(venc_ion_client, mregion->fd); - if (IS_ERR_OR_NULL(mregion->ion_handle)) { - rc = PTR_ERR(mregion->ion_handle); - WFD_MSG_ERR("Failed to get handle: %p, %d, %d, %d\n", - venc_ion_client, mregion->fd, mregion->offset, rc); - mregion->ion_handle = NULL; - goto venc_map_fail; - } - - rc = ion_handle_get_flags(venc_ion_client, mregion->ion_handle, &flags); - if (rc) { - WFD_MSG_ERR("Failed to get ion flags %d\n", rc); - goto venc_map_fail; - } - - mregion->paddr = mregion->kvaddr = ion_map_kernel(venc_ion_client, - mregion->ion_handle); - - if (IS_ERR_OR_NULL(mregion->kvaddr)) { - WFD_MSG_ERR("Failed to map buffer into kernel\n"); - rc = PTR_ERR(mregion->kvaddr); - mregion->kvaddr = NULL; - goto venc_map_fail; - } - -venc_map_fail: - return rc; -} - -static int venc_unmap_user_to_kernel(struct venc_inst *inst, - struct mem_region *mregion) -{ - if (!mregion || !mregion->ion_handle) - return 0; - - if (mregion->kvaddr) { - ion_unmap_kernel(venc_ion_client, mregion->ion_handle); - mregion->kvaddr = NULL; - } - - - return 0; -} - -#ifdef CONFIG_MSM_VIDC_V4L2 -static int encode_memcpy(uint8_t *dst, uint8_t *src, int size) -{ - int y_stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, DEFAULT_WIDTH), - y_scan = VENUS_Y_SCANLINES(COLOR_FMT_NV12, DEFAULT_HEIGHT), - uv_stride = VENUS_UV_STRIDE(COLOR_FMT_NV12, DEFAULT_WIDTH), - uv_scan = VENUS_UV_SCANLINES(COLOR_FMT_NV12, DEFAULT_HEIGHT); - int y_size = y_stride * y_scan; - int c = 0, dst_offset = 0, src_offset = 0; - - /* copy the luma */ - for (c = 0; c < DEFAULT_HEIGHT; ++c) { - memcpy(dst + dst_offset, src + src_offset, DEFAULT_WIDTH); - src_offset += y_stride; - dst_offset += DEFAULT_WIDTH; - } - - /* skip over padding between luma and chroma */ - src_offset = y_size; - /* now do the chroma */ - for (c = 0; c < DEFAULT_HEIGHT / 2; ++c) { - memcpy(dst + dst_offset, src + src_offset, DEFAULT_WIDTH); - src_offset += uv_stride; - dst_offset += DEFAULT_WIDTH; - } - - (void)uv_scan; - return dst_offset; -} -#else -static int encode_memcpy(uint8_t *dst, uint8_t *src, int size) -{ - memcpy(dst, src, size); - return size; -} -#endif - -static void encode(struct work_struct *work) -{ - struct encode_task *et = NULL; - struct venc_inst *inst = NULL; - struct mem_region *input, *output; - struct vb2_buffer *vb; - int bytes_copied = 0; - if (!work) - return; - - et = container_of(work, struct encode_task, work); - inst = et->inst; - - mutex_lock(&inst->lock); - if (list_empty(&inst->input_bufs.list)) { - WFD_MSG_ERR("Can't find an input buffer"); - mutex_unlock(&inst->lock); - return; - } - - if (list_empty(&inst->output_bufs.list)) { - WFD_MSG_ERR("Can't find an output buffer"); - mutex_unlock(&inst->lock); - return; - } - - /* Grab an i/p & o/p buffer pair */ - input = list_first_entry(&inst->input_bufs.list, - struct mem_region, list); - list_del(&input->list); - - output = list_first_entry(&inst->output_bufs.list, - struct mem_region, list); - list_del(&output->list); - mutex_unlock(&inst->lock); - - /* This is our "encode" */ - bytes_copied = encode_memcpy(output->kvaddr, input->kvaddr, - min(output->size, input->size)); - - vb = (struct vb2_buffer *)output->cookie; - vb->v4l2_planes[0].bytesused = bytes_copied; - inst->vmops.op_buffer_done( - inst->vmops.cbdata, 0, vb); - - inst->vmops.ip_buffer_done( - inst->vmops.cbdata, - 0, input); - - venc_unmap_user_to_kernel(inst, output); - kfree(input); - kfree(output); - kfree(et); -} - -static void prepare_for_encode(struct venc_inst *inst) -{ - struct encode_task *et = kzalloc(sizeof(*et), GFP_KERNEL); - et->inst = inst; - INIT_WORK(&et->work, encode); - queue_work(inst->wq, &et->work); -} - -static long venc_fill_outbuf(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst = NULL; - struct mem_region *mregion = NULL; - - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - return -EINVAL; - } else if (!arg) { - WFD_MSG_ERR("Invalid output buffer in %s", __func__); - return -EINVAL; - } - - inst = (struct venc_inst *)sd->dev_priv; - - /* check for dupes */ - list_for_each_entry(mregion, &inst->output_bufs.list, list) { - struct mem_region *temp = arg; - if (mem_region_equals(temp, mregion)) { - WFD_MSG_ERR("Attempt to queue dupe buffer\n"); - return -EEXIST; - } - } - - mregion = kzalloc(sizeof(*mregion), GFP_KERNEL); - if (!mregion) { - WFD_MSG_ERR("Invalid output buffer in %s", __func__); - return -EINVAL; - } - - *mregion = *(struct mem_region *)arg; - - if (venc_map_user_to_kernel(inst, mregion)) { - WFD_MSG_ERR("unable to map buffer into kernel\n"); - return -EFAULT; - } - - mutex_lock(&inst->lock); - list_add_tail(&mregion->list, &inst->output_bufs.list); - - if (!list_empty(&inst->input_bufs.list)) - prepare_for_encode(inst); - mutex_unlock(&inst->lock); - - return 0; -} - -static long venc_encode_frame(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst = NULL; - struct venc_buf_info *venc_buf = arg; - struct mem_region *mregion = NULL; - - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - return -EINVAL; - } else if (!venc_buf) { - WFD_MSG_ERR("Invalid output buffer ot fill\n"); - return -EINVAL; - } - - mregion = kzalloc(sizeof(*mregion), GFP_KERNEL); - if (!mregion) { - WFD_MSG_ERR("Invalid output buffer in %s", __func__); - return -EINVAL; - } - - inst = (struct venc_inst *)sd->dev_priv; - *mregion = *venc_buf->mregion; - - mutex_lock(&inst->lock); - list_add_tail(&mregion->list, &inst->input_bufs.list); - - if (!list_empty(&inst->output_bufs.list)) - prepare_for_encode(inst); - mutex_unlock(&inst->lock); - return 0; -} - -static long venc_alloc_recon_buffers(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_free_output_buffer(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_flush_buffers(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_free_input_buffer(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_free_recon_buffers(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_set_property(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_get_property(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_mmap(struct v4l2_subdev *sd, void *arg) -{ - struct mem_region_map *mmap = arg; - struct mem_region *mregion; - - mregion = mmap->mregion; - mregion->paddr = mregion->kvaddr; - return 0; -} - -static long venc_munmap(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static long venc_set_framerate_mode(struct v4l2_subdev *sd, - void *arg) -{ - return 0; -} - -long venc_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) -{ - long rc = 0; - switch (cmd) { - case OPEN: - rc = venc_open(sd, arg); - break; - case CLOSE: - rc = venc_close(sd, arg); - break; - case ENCODE_START: - rc = venc_start(sd); - break; - case ENCODE_FRAME: - venc_encode_frame(sd, arg); - break; - case ENCODE_STOP: - rc = venc_stop(sd); - break; - case SET_PROP: - rc = venc_set_property(sd, arg); - break; - case GET_PROP: - rc = venc_get_property(sd, arg); - break; - case GET_BUFFER_REQ: - rc = venc_get_buffer_req(sd, arg); - break; - case SET_BUFFER_REQ: - rc = venc_set_buffer_req(sd, arg); - break; - case FREE_BUFFER: - break; - case FILL_OUTPUT_BUFFER: - rc = venc_fill_outbuf(sd, arg); - break; - case SET_FORMAT: - rc = venc_set_format(sd, arg); - break; - case SET_FRAMERATE: - rc = venc_set_framerate(sd, arg); - break; - case SET_INPUT_BUFFER: - rc = venc_set_input_buffer(sd, arg); - break; - case SET_OUTPUT_BUFFER: - rc = venc_set_output_buffer(sd, arg); - break; - case ALLOC_RECON_BUFFERS: - rc = venc_alloc_recon_buffers(sd, arg); - break; - case FREE_OUTPUT_BUFFER: - rc = venc_free_output_buffer(sd, arg); - break; - case FREE_INPUT_BUFFER: - rc = venc_free_input_buffer(sd, arg); - break; - case FREE_RECON_BUFFERS: - rc = venc_free_recon_buffers(sd, arg); - break; - case ENCODE_FLUSH: - rc = venc_flush_buffers(sd, arg); - break; - case ENC_MMAP: - rc = venc_mmap(sd, arg); - break; - case ENC_MUNMAP: - rc = venc_munmap(sd, arg); - break; - case SET_FRAMERATE_MODE: - rc = venc_set_framerate_mode(sd, arg); - break; - default: - WFD_MSG_ERR("Unknown ioctl %d to enc-subdev\n", cmd); - rc = -ENOTSUPP; - break; - } - return rc; -} diff --git a/drivers/media/platform/msm/wfd/enc-mfc-subdev.c b/drivers/media/platform/msm/wfd/enc-mfc-subdev.c deleted file mode 100644 index 26e24dadf6e7c09d41a4f6ae065483e3aaf8dbc1..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/wfd/enc-mfc-subdev.c +++ /dev/null @@ -1,2565 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include "enc-subdev.h" -#include "wfd-util.h" -#include -#include -#include -#include -#include -#include - -#define VID_ENC_MAX_ENCODER_CLIENTS 1 -#define MAX_NUM_CTRLS 20 -#define V4L2_FRAME_FLAGS (V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_PFRAME | \ - V4L2_BUF_FLAG_BFRAME | V4L2_QCOM_BUF_FLAG_CODECCONFIG) - -static long venc_fill_outbuf(struct v4l2_subdev *sd, void *arg); - -struct venc_inst { - struct video_client_ctx venc_client; - void *cbdata; - void (*op_buffer_done)(void *cookie, u32 status, - struct vb2_buffer *buf); - void (*ip_buffer_done)(void *cookie, u32 status, - struct mem_region *mregion); - u32 width; - u32 height; - int secure; - struct mem_region unqueued_op_bufs; - bool streaming; - enum venc_framerate_modes framerate_mode; -}; - -struct venc { - s32 device_handle; - void *virt_base; - struct venc_inst venc_clients[VID_ENC_MAX_ENCODER_CLIENTS]; - struct mutex lock; - struct ion_client *iclient; -}; - -static struct venc venc_p; - -static void *venc_map_dev_base_addr(void *device_name) -{ - return venc_p.virt_base; -} - -static void venc_interrupt_deregister(void) -{ -} - -static void venc_interrupt_register(void *device_name) -{ -} - -static void venc_interrupt_clear(void) -{ -} - -int venc_load_fw(struct v4l2_subdev *sd) -{ - return !vidc_load_firmware(); -} - -static u32 venc_get_empty_client_index(void) -{ - u32 i; - u32 found = false; - - for (i = 0; i < VID_ENC_MAX_ENCODER_CLIENTS; i++) { - if (!venc_p.venc_clients[i].venc_client.vcd_handle) { - found = true; - break; - } - } - if (!found) { - WFD_MSG_ERR("%s():ERROR No space for new client\n", - __func__); - return -ENOMEM; - } - WFD_MSG_INFO("%s(): available client index = %u\n", - __func__, i); - return i; -} - -int venc_init(struct v4l2_subdev *sd, u32 val) -{ - struct vcd_init_config vcd_init_config; - mutex_init(&venc_p.lock); - venc_p.virt_base = vidc_get_ioaddr(); - vcd_init_config.device_name = "VIDC"; - vcd_init_config.map_dev_base_addr = venc_map_dev_base_addr; - vcd_init_config.interrupt_clr = venc_interrupt_clear; - vcd_init_config.register_isr = venc_interrupt_register; - vcd_init_config.deregister_isr = venc_interrupt_deregister; - vcd_init(&vcd_init_config, &venc_p.device_handle); - return 0; -} - -static void venc_notify_client(struct video_client_ctx *client_ctx) -{ - if (client_ctx) - complete(&client_ctx->event); -} - -static void venc_open_done(struct video_client_ctx *client_ctx, - struct vcd_handle_container *handle_container) -{ - if (client_ctx) { - if (handle_container) - client_ctx->vcd_handle = handle_container->handle; - else - WFD_MSG_ERR("handle_container is NULL\n"); - venc_notify_client(client_ctx); - } else - WFD_MSG_ERR("ERROR. client_ctx is NULL"); -} - -static void venc_start_done(struct video_client_ctx *client_ctx, u32 status) -{ - if (client_ctx) - venc_notify_client(client_ctx); - else - WFD_MSG_ERR("ERROR. client_ctx is NULL"); -} - -static void venc_stop_done(struct video_client_ctx *client_ctx, u32 status) -{ - WFD_MSG_DBG("Inside venc_stop_done: E\n"); - if (client_ctx) - venc_notify_client(client_ctx); - else - WFD_MSG_ERR("ERROR. client_ctx is NULL"); - WFD_MSG_DBG("Inside venc_stop_done: X\n"); -} - -static void venc_cb(u32 event, u32 status, void *info, u32 size, void *handle, - void *const client_data) -{ - struct venc_inst *inst = client_data; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct vb2_buffer *vbuf; - struct mem_region *mregion; - struct vcd_frame_data *frame_data = (struct vcd_frame_data *)info; - - if (!client_ctx) { - WFD_MSG_ERR("Client context is NULL\n"); - return; - } - client_ctx->event_status = status; - switch (event) { - case VCD_EVT_RESP_OPEN: - WFD_MSG_DBG("EVENT: open done = %d\n", event); - venc_open_done(client_ctx, - (struct vcd_handle_container *)info); - break; - case VCD_EVT_RESP_INPUT_DONE: - case VCD_EVT_RESP_INPUT_FLUSHED: - WFD_MSG_DBG("EVENT: input done = %d\n", event); - mregion = (struct mem_region *) - frame_data->frm_clnt_data; - inst->ip_buffer_done(inst->cbdata, status, mregion); - break; - case VCD_EVT_RESP_OUTPUT_DONE: - case VCD_EVT_RESP_OUTPUT_FLUSHED: - WFD_MSG_DBG("EVENT: output done = %d\n", event); - vbuf = (struct vb2_buffer *) - frame_data->frm_clnt_data; - vbuf->v4l2_planes[0].bytesused = - frame_data->data_len; - - vbuf->v4l2_buf.flags &= ~(V4L2_FRAME_FLAGS); - switch (frame_data->frame) { - case VCD_FRAME_I: - case VCD_FRAME_IDR: - vbuf->v4l2_buf.flags |= V4L2_BUF_FLAG_KEYFRAME; - break; - case VCD_FRAME_P: - vbuf->v4l2_buf.flags |= V4L2_BUF_FLAG_PFRAME; - break; - case VCD_FRAME_B: - vbuf->v4l2_buf.flags |= V4L2_BUF_FLAG_BFRAME; - break; - default: - break; - } - - if (frame_data->flags & VCD_FRAME_FLAG_CODECCONFIG) - vbuf->v4l2_buf.flags |= V4L2_QCOM_BUF_FLAG_CODECCONFIG; - - vbuf->v4l2_buf.timestamp = - ns_to_timeval(frame_data->time_stamp * NSEC_PER_USEC); - - WFD_MSG_DBG("bytes used %d, ts: %d.%d, frame type is %d\n", - frame_data->data_len, - (int)vbuf->v4l2_buf.timestamp.tv_sec, - (int)vbuf->v4l2_buf.timestamp.tv_usec, - frame_data->frame); - - /* - * Output buffers are enc-subdev and vcd's problem, so - * if buffer is cached, need to flush before giving to - * client. So doing the dirty stuff in this little context - */ - { - unsigned long kvaddr, phys_addr; - s32 buffer_index = -1, ion_flags = 0; - struct ion_handle *ion_handle; - int pmem_fd; - struct file *filp; - bool rc; - - rc = vidc_lookup_addr_table(client_ctx, - BUFFER_TYPE_OUTPUT, true, - (unsigned long *)&frame_data-> - frm_clnt_data, &kvaddr, &phys_addr, - &pmem_fd, &filp, &buffer_index); - - if (rc) - ion_flags = vidc_get_fd_info(client_ctx, - BUFFER_TYPE_OUTPUT, pmem_fd, - kvaddr, buffer_index, &ion_handle); - else - WFD_MSG_ERR("Got an output buffer that we " \ - "couldn't recognize!\n"); - - if (msm_ion_do_cache_op(client_ctx->user_ion_client, - ion_handle, &kvaddr, frame_data->data_len, - ION_IOC_CLEAN_INV_CACHES)) - WFD_MSG_ERR("OP buffer flush failed\n"); - - } - - inst->op_buffer_done(inst->cbdata, status, vbuf); - break; - case VCD_EVT_RESP_START: - WFD_MSG_DBG("EVENT: start done = %d\n", event); - venc_start_done(client_ctx, status); - /*TODO: should wait for this event*/ - break; - case VCD_EVT_RESP_STOP: - WFD_MSG_DBG("EVENT: not expected = %d\n", event); - venc_stop_done(client_ctx, status); - break; - case VCD_EVT_RESP_FLUSH_INPUT_DONE: - case VCD_EVT_RESP_FLUSH_OUTPUT_DONE: - venc_notify_client(client_ctx); - break; - case VCD_EVT_RESP_PAUSE: - case VCD_EVT_IND_OUTPUT_RECONFIG: - WFD_MSG_DBG("EVENT: not expected = %d\n", event); - break; - case VCD_EVT_IND_HWERRFATAL: - case VCD_EVT_IND_RESOURCES_LOST: - WFD_MSG_DBG("EVENT: error = %d\n", event); - break; - default: - WFD_MSG_ERR("Invalid event type = %u\n", event); - break; - } -} - -static long venc_open(struct v4l2_subdev *sd, void *arg) -{ - u32 client_index; - int rc = 0; - struct venc_inst *inst; - struct video_client_ctx *client_ctx; - struct venc_msg_ops *vmops = arg; - int flags = 0; - mutex_lock(&venc_p.lock); - client_index = venc_get_empty_client_index(); - if (client_index < 0) { - WFD_MSG_ERR("No free clients, client_index = %d\n", - client_index); - rc = -ENODEV; - goto no_free_client; - } - inst = &venc_p.venc_clients[client_index]; - client_ctx = &inst->venc_client; - init_completion(&client_ctx->event); - mutex_init(&client_ctx->msg_queue_lock); - mutex_init(&client_ctx->enrty_queue_lock); - INIT_LIST_HEAD(&client_ctx->msg_queue); - init_waitqueue_head(&client_ctx->msg_wait); - inst->op_buffer_done = vmops->op_buffer_done; - inst->ip_buffer_done = vmops->ip_buffer_done; - INIT_LIST_HEAD(&inst->unqueued_op_bufs.list); - inst->cbdata = vmops->cbdata; - inst->secure = vmops->secure; - inst->streaming = false; - inst->framerate_mode = VENC_MODE_VFR; - - if (vmops->secure) { - WFD_MSG_ERR("OPENING SECURE SESSION\n"); - flags |= VCD_CP_SESSION; - } - if (vcd_get_ion_status()) { - client_ctx->user_ion_client = vcd_get_ion_client(); - if (!client_ctx->user_ion_client) { - WFD_MSG_ERR("vcd_open ion get client failed"); - return -EFAULT; - } - } - - rc = vcd_open(venc_p.device_handle, false, venc_cb, - inst, flags); - if (rc) { - WFD_MSG_ERR("vcd_open failed, rc = %d\n", rc); - rc = -ENODEV; - goto no_free_client; - } - wait_for_completion(&client_ctx->event); - if (client_ctx->event_status) { - WFD_MSG_ERR("callback for vcd_open returned error: %u", - client_ctx->event_status); - goto no_free_client; - } - WFD_MSG_ERR("NOTE: client_ctx = %p\n", client_ctx); - vmops->cookie = inst; - sd->dev_priv = inst; -no_free_client: - mutex_unlock(&venc_p.lock); - return rc; -} - -static long venc_close(struct v4l2_subdev *sd, void *arg) -{ - long rc = 0; - struct venc_inst *inst; - struct video_client_ctx *client_ctx = NULL; - mutex_lock(&venc_p.lock); - inst = sd->dev_priv; - client_ctx = &inst->venc_client; - if (!client_ctx || !client_ctx->vcd_handle) { - WFD_MSG_ERR("Invalid client context in close\n"); - rc = -ENODEV; - goto end; - } - rc = vcd_close(client_ctx->vcd_handle); - if (rc) { - WFD_MSG_ERR("Failed to close encoder subdevice\n"); - goto end; - } - memset((void *)client_ctx, 0, - sizeof(struct video_client_ctx)); -end: - mutex_unlock(&venc_p.lock); - return rc; -} - -static long venc_get_buffer_req(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct v4l2_requestbuffers *b = arg; - struct vcd_buffer_requirement buf_req; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - if (!client_ctx) { - WFD_MSG_ERR("Invalid client context"); - rc = -EINVAL; - goto err; - } - rc = vcd_get_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, &buf_req); - if (rc) { - WFD_MSG_ERR("Failed to get out buf reqs rc = %d", rc); - goto err; - } - - buf_req.actual_count = b->count = max(buf_req.min_count, b->count); - rc = vcd_set_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, &buf_req); - if (rc) { - WFD_MSG_ERR("Failed to set out buf reqs rc = %d", rc); - goto err; - } - -err: - return rc; -} - -static long venc_set_buffer_req(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct bufreq *b = arg; - struct vcd_buffer_requirement buf_req; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - int aligned_width, aligned_height; - if (!client_ctx) { - WFD_MSG_ERR("Invalid client context"); - rc = -EINVAL; - goto err; - } - aligned_width = ALIGN(b->width, 16); - aligned_height = ALIGN(b->height, 16); - - if (aligned_width != b->width) { - WFD_MSG_ERR("Width not 16 byte aligned\n"); - rc = -EINVAL; - goto err; - } - - buf_req.actual_count = b->count; - buf_req.min_count = b->count; - buf_req.max_count = b->count; - buf_req.sz = ALIGN(aligned_height * aligned_width, SZ_2K) - + ALIGN(aligned_height * aligned_width * 1/2, SZ_2K); - buf_req.align = SZ_4K; - inst->width = b->width; - inst->height = b->height; - rc = vcd_set_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_INPUT, &buf_req); - if (rc) { - WFD_MSG_ERR("Failed to get out buf reqs rc = %d", rc); - goto err; - } - b->size = buf_req.sz; -err: - return rc; -} - -static long venc_start(struct v4l2_subdev *sd) -{ - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct mem_region *curr = NULL, *temp = NULL; - int rc; - if (!client_ctx) { - WFD_MSG_ERR("Client context is NULL"); - return -EINVAL; - } - - rc = vcd_encode_start(client_ctx->vcd_handle); - if (rc) { - WFD_MSG_ERR("vcd_encode_start failed, rc = %d\n", rc); - goto err; - } - wait_for_completion(&client_ctx->event); - if (client_ctx->event_status) - WFD_MSG_ERR("callback for vcd_encode_start returned error: %u", - client_ctx->event_status); - - inst->streaming = true; - /* Push any buffers that we have held back */ - list_for_each_entry_safe(curr, temp, - &inst->unqueued_op_bufs.list, list) { - venc_fill_outbuf(sd, curr); - list_del(&curr->list); - kfree(curr); - } -err: - return rc; -} - -static long venc_stop(struct v4l2_subdev *sd) -{ - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct mem_region *curr = NULL, *temp = NULL; - int rc; - if (!client_ctx) { - WFD_MSG_ERR("Client context is NULL"); - return -EINVAL; - } - rc = vcd_stop(client_ctx->vcd_handle); - wait_for_completion(&client_ctx->event); - inst->streaming = false; - /* Drop whatever frames we haven't queued */ - list_for_each_entry_safe(curr, temp, - &inst->unqueued_op_bufs.list, list) { - inst->op_buffer_done(inst->cbdata, 0, - (struct vb2_buffer *)curr->cookie); - list_del(&curr->list); - kfree(curr); - } - return rc; -} - -static long venc_set_codec(struct video_client_ctx *client_ctx, __s32 codec) -{ - struct vcd_property_codec vcd_property_codec; - struct vcd_property_hdr vcd_property_hdr; - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - vcd_property_codec.codec = VCD_CODEC_H264; - - switch (codec) { - case V4L2_PIX_FMT_H264: - vcd_property_codec.codec = VCD_CODEC_H264; - break; - case V4L2_PIX_FMT_MPEG4: - vcd_property_codec.codec = VCD_CODEC_MPEG4; - break; - default: - WFD_MSG_ERR("Codec not supported, defaulting to h264\n"); - break; - } - return vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); -} - -static long venc_set_codec_level(struct video_client_ctx *client_ctx, - __s32 codec, __s32 level) -{ - struct vcd_property_level vcd_property_level; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_codec vcd_property_codec; - - int rc = 0; - int mpeg4_base = VCD_LEVEL_MPEG4_0; - int h264_base = VCD_LEVEL_H264_1; - - /* Validate params */ - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - - if (rc < 0) { - WFD_MSG_ERR("Error getting codec property"); - rc = -EINVAL; - goto err; - } - - if (!((vcd_property_codec.codec == VCD_CODEC_H264 - && codec == V4L2_CID_MPEG_VIDEO_H264_LEVEL) || - (vcd_property_codec.codec == VCD_CODEC_MPEG4 - && codec == V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL))) { - WFD_MSG_ERR("Attempting to set %d for codec type %d", - codec, vcd_property_codec.codec); - rc = -EINVAL; - goto err; - } - - /* Set property */ - vcd_property_hdr.prop_id = VCD_I_LEVEL; - vcd_property_hdr.sz = sizeof(struct vcd_property_level); - - if (codec == V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL) { - vcd_property_level.level = mpeg4_base + level; - - if (vcd_property_level.level < VCD_LEVEL_MPEG4_0 - || vcd_property_level.level > VCD_LEVEL_MPEG4_X) { - WFD_MSG_ERR("Level (%d) out of range for codec (%d)\n", - level, codec); - - rc = -EINVAL; - goto err; - } - } else if (codec == V4L2_CID_MPEG_VIDEO_H264_LEVEL) { - vcd_property_level.level = h264_base + level; - - if (vcd_property_level.level < VCD_LEVEL_H264_1 - || vcd_property_level.level > VCD_LEVEL_H264_5p1) { - WFD_MSG_ERR("Level (%d) out of range for codec (%d)\n", - level, codec); - - rc = -EINVAL; - goto err; - } - } else { - WFD_MSG_ERR("Codec (%d) not supported, not setting level (%d)", - codec, level); - rc = -ENOTSUPP; - goto err; - } - - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_level); -err: - return rc; -} - -static long venc_get_codec_level(struct video_client_ctx *client_ctx, - __s32 codec, __s32 *level) -{ - struct vcd_property_level vcd_property_level; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_codec vcd_property_codec; - - int rc = 0; - int mpeg4_base = VCD_LEVEL_MPEG4_0; - int h264_base = VCD_LEVEL_H264_1; - - /* Validate params */ - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - - if (rc < 0) { - WFD_MSG_ERR("Error getting codec property"); - rc = -EINVAL; - goto err; - } - - if (!((vcd_property_codec.codec == VCD_CODEC_H264 - && codec == V4L2_CID_MPEG_VIDEO_H264_LEVEL) || - (vcd_property_codec.codec == VCD_CODEC_MPEG4 - && codec == V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL))) { - WFD_MSG_ERR("Attempting to get %d for codec type %d", - codec, vcd_property_codec.codec); - rc = -EINVAL; - goto err; - } - - vcd_property_hdr.prop_id = VCD_I_LEVEL; - vcd_property_hdr.sz = sizeof(struct vcd_property_level); - - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_level); - if (rc < 0) { - rc = -EINVAL; - goto err; - } - - if (codec == V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL) { - *level = vcd_property_level.level - mpeg4_base; - } else if (codec == V4L2_CID_MPEG_VIDEO_H264_LEVEL) { - *level = vcd_property_level.level - h264_base; - } else { - WFD_MSG_ERR("Codec (%d) not supported", codec); - rc = -ENOTSUPP; - goto err; - } - -err: - return rc; -} - -static long venc_set_codec_profile(struct video_client_ctx *client_ctx, - __s32 codec, __s32 profile) -{ - struct vcd_property_profile vcd_property_profile; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_codec vcd_property_codec; - struct vcd_property_i_period vcd_property_i_period; - int rc = 0; - - /* Validate params */ - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - - if (rc < 0) { - WFD_MSG_ERR("Error getting codec property"); - rc = -EINVAL; - goto err_set_profile; - } - - if (!((vcd_property_codec.codec == VCD_CODEC_H264 - && codec == V4L2_CID_MPEG_VIDEO_H264_PROFILE) || - (vcd_property_codec.codec == VCD_CODEC_MPEG4 - && codec == V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE))) { - WFD_MSG_ERR("Attempting to set %d for codec type %d", - codec, vcd_property_codec.codec); - rc = -EINVAL; - goto err_set_profile; - } - - /* Set property */ - vcd_property_hdr.prop_id = VCD_I_PROFILE; - vcd_property_hdr.sz = sizeof(struct vcd_property_profile); - - if (codec == V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE) { - switch (profile) { - case V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE: - vcd_property_profile.profile = VCD_PROFILE_MPEG4_SP; - break; - case V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE: - vcd_property_profile.profile = VCD_PROFILE_MPEG4_ASP; - break; - default: - WFD_MSG_ERR("Profile %d not supported, defaulting " \ - "to simple (%d)", profile, - VCD_PROFILE_MPEG4_SP); - vcd_property_profile.profile = VCD_PROFILE_MPEG4_SP; - break; - } - } else if (codec == V4L2_CID_MPEG_VIDEO_H264_PROFILE) { - switch (profile) { - case V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE: - vcd_property_profile.profile = - VCD_PROFILE_H264_BASELINE; - break; - case V4L2_MPEG_VIDEO_H264_PROFILE_MAIN: - vcd_property_profile.profile = VCD_PROFILE_H264_MAIN; - break; - case V4L2_MPEG_VIDEO_H264_PROFILE_HIGH: - vcd_property_profile.profile = VCD_PROFILE_H264_HIGH; - break; - default: - WFD_MSG_ERR("Profile %d not supported, defaulting " \ - "to baseline (%d)", profile, - VCD_PROFILE_H264_BASELINE); - vcd_property_profile.profile = - VCD_PROFILE_H264_BASELINE; - break; - } - } else { - WFD_MSG_ERR("Codec (%d) not supported, not "\ - "setting profile (%d)", codec, profile); - rc = -ENOTSUPP; - goto err_set_profile; - } - - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_profile); - - /* Disable B-frames, since VSG doesn't support out of order i/p bufs */ - vcd_property_hdr.prop_id = VCD_I_INTRA_PERIOD; - vcd_property_hdr.sz = sizeof(struct vcd_property_i_period); - - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_i_period); - if (rc) { - WFD_MSG_ERR("Error getting I-period property"); - goto err_set_profile; - } - vcd_property_i_period.b_frames = 0; - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_i_period); - if (rc) { - WFD_MSG_ERR("Error setting I-period property"); - goto err_set_profile; - } - -err_set_profile: - return rc; -} - -static long venc_get_codec_profile(struct video_client_ctx *client_ctx, - __s32 codec, __s32 *profile) -{ - struct vcd_property_profile vcd_property_profile; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_codec vcd_property_codec; - int rc = 0; - - /* Validate params */ - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - - if (rc < 0) { - WFD_MSG_ERR("Error getting codec property"); - rc = -EINVAL; - goto err; - } - - if (!((vcd_property_codec.codec == VCD_CODEC_H264 - && codec == V4L2_CID_MPEG_VIDEO_H264_PROFILE) || - (vcd_property_codec.codec == VCD_CODEC_MPEG4 - && codec == V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE))) { - WFD_MSG_ERR("Attempting to set %d for codec type %d", - codec, vcd_property_codec.codec); - rc = -EINVAL; - goto err; - } - - /* Set property */ - vcd_property_hdr.prop_id = VCD_I_PROFILE; - vcd_property_hdr.sz = sizeof(struct vcd_property_profile); - - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_profile); - - if (rc < 0) { - WFD_MSG_ERR("Unable to get property"); - rc = -EINVAL; - goto err; - } - - switch (vcd_property_profile.profile) { - case VCD_PROFILE_MPEG4_SP: - *profile = V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE; - break; - case VCD_PROFILE_MPEG4_ASP: - *profile = V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE; - break; - case VCD_PROFILE_H264_BASELINE: - *profile = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE; - break; - case VCD_PROFILE_H264_MAIN: - *profile = V4L2_MPEG_VIDEO_H264_PROFILE_MAIN; - break; - case VCD_PROFILE_H264_HIGH: - *profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH; - break; - default: - WFD_MSG_ERR("Unexpected profile"); - rc = -EINVAL; - goto err; - break; - } -err: - return rc; -} - -static long venc_set_h264_intra_period(struct video_client_ctx *client_ctx, - __s32 period) -{ - struct vcd_property_i_period vcd_property_i_period; - struct vcd_property_codec vcd_property_codec; - struct vcd_property_hdr vcd_property_hdr; - int rc = 0; - - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - - if (rc < 0) { - WFD_MSG_ERR("Error getting codec property\n"); - goto err; - } - - if (vcd_property_codec.codec != VCD_CODEC_H264) { - rc = -ENOTSUPP; - WFD_MSG_ERR("Control not supported for non H264 codec\n"); - goto err; - } - - vcd_property_hdr.prop_id = VCD_I_INTRA_PERIOD; - vcd_property_hdr.sz = sizeof(struct vcd_property_i_period); - - vcd_property_i_period.p_frames = period - 1; - vcd_property_i_period.b_frames = 0; - - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_i_period); - - if (rc < 0) { - WFD_MSG_ERR("Error setting intra period\n"); - goto err; - } - -err: - return rc; -} - -static long venc_get_h264_intra_period(struct video_client_ctx *client_ctx, - __s32 *period) -{ - struct vcd_property_i_period vcd_property_i_period; - struct vcd_property_codec vcd_property_codec; - struct vcd_property_hdr vcd_property_hdr; - int rc = 0; - - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - - if (rc < 0) { - WFD_MSG_ERR("Error getting codec property\n"); - goto err; - } - - if (vcd_property_codec.codec != VCD_CODEC_H264) { - rc = -ENOTSUPP; - WFD_MSG_ERR("Control not supported for non H264 codec\n"); - goto err; - } - - vcd_property_hdr.prop_id = VCD_I_INTRA_PERIOD; - vcd_property_hdr.sz = sizeof(struct vcd_property_i_period); - - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_i_period); - - if (rc < 0) { - WFD_MSG_ERR("Error getting intra period\n"); - goto err; - } - - *period = vcd_property_i_period.p_frames + 1; -err: - return rc; -} - -static long venc_request_frame(struct video_client_ctx *client_ctx, __s32 type) -{ - struct vcd_property_req_i_frame vcd_property_req_i_frame; - struct vcd_property_hdr vcd_property_hdr; - - vcd_property_hdr.prop_id = VCD_I_REQ_IFRAME; - vcd_property_hdr.sz = sizeof(struct vcd_property_req_i_frame); - vcd_property_req_i_frame.req_i_frame = 1; - - return vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_req_i_frame); - -} - -static long venc_set_bitrate(struct video_client_ctx *client_ctx, - __s32 bitrate) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_target_bitrate bit_rate; - if (!client_ctx || !bitrate) - return -EINVAL; - - vcd_property_hdr.prop_id = VCD_I_TARGET_BITRATE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_target_bitrate); - bit_rate.target_bitrate = bitrate; - return vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &bit_rate); -} - -static long venc_get_bitrate(struct video_client_ctx *client_ctx, - __s32 *bitrate) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_target_bitrate bit_rate; - int rc = 0; - - if (!client_ctx || !bitrate) - return -EINVAL; - - vcd_property_hdr.prop_id = VCD_I_TARGET_BITRATE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_target_bitrate); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &bit_rate); - - if (rc < 0) { - WFD_MSG_ERR("Failed getting property for bitrate"); - return rc; - } - - *bitrate = bit_rate.target_bitrate; - return rc; -} - -static long venc_set_bitrate_mode(struct video_client_ctx *client_ctx, - __s32 mode) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_rate_control rate_control; - int rc = 0; - - if (!client_ctx) { - rc = -EINVAL; - goto err; - } - - vcd_property_hdr.prop_id = VCD_I_RATE_CONTROL; - vcd_property_hdr.sz = sizeof(struct vcd_property_rate_control); - /* - * XXX: V4L doesn't seem have a control to toggle between CFR - * and VFR, so assuming worse case VFR. - */ - switch (mode) { - case V4L2_MPEG_VIDEO_BITRATE_MODE_VBR: - rate_control.rate_control = VCD_RATE_CONTROL_VBR_VFR; - break; - case V4L2_MPEG_VIDEO_BITRATE_MODE_CBR: - rate_control.rate_control = VCD_RATE_CONTROL_CBR_VFR; - break; - default: - WFD_MSG_ERR("unknown bitrate mode %d", mode); - rc = -EINVAL; - goto err; - } - - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &rate_control); -err: - return rc; -} - -static long venc_get_bitrate_mode(struct video_client_ctx *client_ctx, - __s32 *mode) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_rate_control rate_control; - int rc = 0; - - if (!client_ctx) - return -EINVAL; - - vcd_property_hdr.prop_id = VCD_I_RATE_CONTROL; - vcd_property_hdr.sz = sizeof(struct vcd_property_rate_control); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &rate_control); - - switch (rate_control.rate_control) { - case VCD_RATE_CONTROL_CBR_VFR: - case VCD_RATE_CONTROL_CBR_CFR: - *mode = V4L2_MPEG_VIDEO_BITRATE_MODE_CBR; - break; - case VCD_RATE_CONTROL_VBR_VFR: - case VCD_RATE_CONTROL_VBR_CFR: - *mode = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR; - break; - default: - WFD_MSG_ERR("unknown bitrate mode %d", - rate_control.rate_control); - return -EINVAL; - } - - return 0; -} - -static long venc_set_frame_size(struct video_client_ctx *client_ctx, - u32 height, u32 width) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_size frame_size; - vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_frame_size); - frame_size.height = height; - frame_size.width = width; - return vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &frame_size); -} - -static long venc_set_format(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst; - struct video_client_ctx *client_ctx; - struct v4l2_format *fmt = arg; - struct vcd_buffer_requirement buf_req; - int rc = 0; - - inst = sd->dev_priv; - client_ctx = &inst->venc_client; - if (!inst || !client_ctx || !fmt) { - WFD_MSG_ERR("Invalid parameters\n"); - return -EINVAL; - } - rc = venc_set_codec(client_ctx, fmt->fmt.pix.pixelformat); - if (rc) { - WFD_MSG_ERR("Failed to set codec, rc = %d\n", rc); - goto err; - } - - rc = venc_set_frame_size(client_ctx, fmt->fmt.pix.height, - fmt->fmt.pix.width); - if (rc) { - WFD_MSG_ERR("Failed to set frame size, rc = %d\n", rc); - goto err; - } - rc = vcd_get_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, &buf_req); - if (rc) { - WFD_MSG_ERR("Failed to get buf requrements, rc = %d\n", rc); - goto err; - } - fmt->fmt.pix.sizeimage = buf_req.sz; -err: - return rc; -} - -static long venc_set_framerate(struct v4l2_subdev *sd, - void *arg) -{ - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct v4l2_fract *frate = arg; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_rate vcd_frame_rate; - struct vcd_property_vop_timing_constant_delta vcd_delta; - int rc; - vcd_property_hdr.prop_id = VCD_I_FRAME_RATE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_frame_rate); - /* v4l2 passes in "fps" as "spf", so take reciprocal*/ - vcd_frame_rate.fps_denominator = frate->numerator; - vcd_frame_rate.fps_numerator = frate->denominator; - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_frame_rate); - if (rc) { - WFD_MSG_ERR("Failed to set frame rate, rc = %d\n", rc); - goto set_framerate_fail; - } - - vcd_property_hdr.prop_id = VCD_I_VOP_TIMING_CONSTANT_DELTA; - vcd_property_hdr.sz = sizeof(vcd_delta); - - vcd_delta.constant_delta = (frate->numerator * USEC_PER_SEC) / - frate->denominator; - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_delta); - - if (rc) { - WFD_MSG_ERR("Failed to set frame delta, rc = %d", rc); - goto set_framerate_fail; - } - -set_framerate_fail: - return rc; -} - -static long venc_set_framerate_mode(struct v4l2_subdev *sd, - void *arg) -{ - struct venc_inst *inst = sd->dev_priv; - inst->framerate_mode = *(enum venc_framerate_modes *)arg; - return 0; -} - -static long venc_set_qp_value(struct video_client_ctx *client_ctx, - __s32 frametype, __s32 qp) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_session_qp vcd_property_session_qp; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - return -EINVAL; - } - - vcd_property_hdr.prop_id = VCD_I_SESSION_QP; - vcd_property_hdr.sz = sizeof(vcd_property_session_qp); - - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_property_session_qp); - - if (rc) { - WFD_MSG_ERR("Failed to get session qp\n"); - goto err; - } - - switch (frametype) { - case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: - vcd_property_session_qp.i_frame_qp = qp; - break; - case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP: - vcd_property_session_qp.p_frame_qp = qp; - break; - case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP: - vcd_property_session_qp.b_frame_qp = qp; - break; - case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP: - rc = -ENOTSUPP; - goto err; - default: - rc = -EINVAL; - goto err; - } - - - rc = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_property_session_qp); - - if (rc) { - WFD_MSG_ERR("Failed to set session qp\n"); - goto err; - } -err: - return rc; -} - -static long venc_get_qp_value(struct video_client_ctx *client_ctx, - __s32 frametype, __s32 *qp) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_session_qp vcd_property_session_qp; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - return -EINVAL; - } - - vcd_property_hdr.prop_id = VCD_I_SESSION_QP; - vcd_property_hdr.sz = sizeof(vcd_property_session_qp); - - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_property_session_qp); - - if (rc) { - WFD_MSG_ERR("Failed to get session qp\n"); - goto err; - } - - switch (frametype) { - case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: - *qp = vcd_property_session_qp.i_frame_qp; - break; - case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP: - *qp = vcd_property_session_qp.p_frame_qp; - break; - case V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP: - *qp = vcd_property_session_qp.b_frame_qp; - break; - default: - rc = -EINVAL; - goto err; - } - -err: - return rc; -} - -static long venc_set_qp_range(struct video_client_ctx *client_ctx, - __s32 type, __s32 qp) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_qp_range vcd_property_qp_range; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - return -EINVAL; - } - - vcd_property_hdr.prop_id = VCD_I_QP_RANGE; - vcd_property_hdr.sz = sizeof(vcd_property_qp_range); - - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_property_qp_range); - - if (rc) { - WFD_MSG_ERR("Failed to get qp range\n"); - goto err; - } - - switch (type) { - case V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H263_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H264_MIN_QP: - vcd_property_qp_range.min_qp = qp; - break; - case V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H263_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H264_MAX_QP: - vcd_property_qp_range.max_qp = qp; - break; - default: - rc = -EINVAL; - goto err; - } - - rc = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_property_qp_range); - - if (rc) { - WFD_MSG_ERR("Failed to set qp range\n"); - goto err; - } -err: - return rc; -} - -static long venc_get_qp_range(struct video_client_ctx *client_ctx, - __s32 type, __s32 *qp) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_qp_range vcd_property_qp_range; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - return -EINVAL; - } - - vcd_property_hdr.prop_id = VCD_I_QP_RANGE; - vcd_property_hdr.sz = sizeof(vcd_property_qp_range); - - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_property_qp_range); - - if (rc) { - WFD_MSG_ERR("Failed to get qp range\n"); - goto err; - } - - switch (type) { - case V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H263_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H264_MIN_QP: - *qp = vcd_property_qp_range.min_qp; - break; - case V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H263_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H264_MAX_QP: - *qp = vcd_property_qp_range.max_qp; - break; - default: - rc = -EINVAL; - goto err; - } - - rc = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_property_qp_range); - - if (rc) { - WFD_MSG_ERR("Failed to set qp range\n"); - goto err; - } -err: - return rc; -} -static long venc_set_max_perf_level(struct video_client_ctx *client_ctx, - __s32 value) -{ - int rc = 0; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_perf_level perf; - int level = 0; - - switch (value) { - case V4L2_CID_MPEG_VIDC_PERF_LEVEL_PERFORMANCE: - level = VCD_PERF_LEVEL2; - break; - case V4L2_CID_MPEG_VIDC_PERF_LEVEL_TURBO: - level = VCD_PERF_LEVEL_TURBO; - break; - default: - WFD_MSG_ERR("Unknown performance level: %d\n", value); - rc = -ENOTSUPP; - goto err_set_perf_level; - } - - vcd_property_hdr.prop_id = VCD_REQ_PERF_LEVEL; - vcd_property_hdr.sz = - sizeof(struct vcd_property_perf_level); - perf.level = level; - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &perf); -err_set_perf_level: - return rc; -} - -static long venc_set_avc_delimiter(struct video_client_ctx *client_ctx, - __s32 flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_avc_delimiter_enable delimiter_flag; - if (!client_ctx) - return -EINVAL; - - vcd_property_hdr.prop_id = VCD_I_ENABLE_DELIMITER_FLAG; - vcd_property_hdr.sz = - sizeof(struct vcd_property_avc_delimiter_enable); - delimiter_flag.avc_delimiter_enable_flag = flag; - return vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &delimiter_flag); -} - -static long venc_get_avc_delimiter(struct video_client_ctx *client_ctx, - __s32 *flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_avc_delimiter_enable delimiter_flag; - int rc = 0; - - if (!client_ctx || !flag) - return -EINVAL; - - vcd_property_hdr.prop_id = VCD_I_ENABLE_DELIMITER_FLAG; - vcd_property_hdr.sz = - sizeof(struct vcd_property_avc_delimiter_enable); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &delimiter_flag); - - if (rc < 0) { - WFD_MSG_ERR("Failed getting property for delimiter"); - return rc; - } - - *flag = delimiter_flag.avc_delimiter_enable_flag; - return rc; -} - -static long venc_set_vui_timing_info(struct video_client_ctx *client_ctx, - struct venc_inst *inst, __s32 flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_vui_timing_info_enable vui_timing_info_enable; - - if (!client_ctx) - return -EINVAL; - if (inst->framerate_mode == VENC_MODE_VFR) { - WFD_MSG_ERR("VUI timing info not suported in VFR mode "); - return -EINVAL; - } - vcd_property_hdr.prop_id = VCD_I_ENABLE_VUI_TIMING_INFO; - vcd_property_hdr.sz = - sizeof(struct vcd_property_vui_timing_info_enable); - vui_timing_info_enable.vui_timing_info = flag; - return vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vui_timing_info_enable); -} - -static long venc_get_vui_timing_info(struct video_client_ctx *client_ctx, - __s32 *flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_vui_timing_info_enable vui_timing_info_enable; - int rc = 0; - - if (!client_ctx || !flag) - return -EINVAL; - - vcd_property_hdr.prop_id = VCD_I_ENABLE_VUI_TIMING_INFO; - vcd_property_hdr.sz = - sizeof(struct vcd_property_vui_timing_info_enable); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vui_timing_info_enable); - - if (rc < 0) { - WFD_MSG_ERR("Failed getting property for VUI timing info"); - return rc; - } - - *flag = vui_timing_info_enable.vui_timing_info; - return rc; -} - -static long venc_set_header_mode(struct video_client_ctx *client_ctx, - __s32 mode) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_sps_pps_for_idr_enable sps_pps_for_idr_enable; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto err; - } - - vcd_property_hdr.prop_id = VCD_I_ENABLE_SPS_PPS_FOR_IDR; - vcd_property_hdr.sz = sizeof(sps_pps_for_idr_enable); - switch (mode) { - case V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE: - sps_pps_for_idr_enable.sps_pps_for_idr_enable_flag = 0; - break; - case V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_I_FRAME: - sps_pps_for_idr_enable.sps_pps_for_idr_enable_flag = 1; - break; - case V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME: - default: - WFD_MSG_ERR("Video header mode %d not supported\n", - mode); - rc = -ENOTSUPP; - goto err; - } - - rc = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &sps_pps_for_idr_enable); - if (rc) { - WFD_MSG_ERR("Failed to set enable_sps_pps_for_idr\n"); - goto err; - } -err: - return rc; -} - -static long venc_get_header_mode(struct video_client_ctx *client_ctx, - __s32 *mode) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_sps_pps_for_idr_enable sps_pps_for_idr_enable; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto err; - } - - vcd_property_hdr.prop_id = VCD_I_ENABLE_SPS_PPS_FOR_IDR; - vcd_property_hdr.sz = sizeof(sps_pps_for_idr_enable); - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &sps_pps_for_idr_enable); - if (rc) { - WFD_MSG_ERR("Failed to get sps/pps for idr enable\n"); - goto err; - } - - *mode = sps_pps_for_idr_enable.sps_pps_for_idr_enable_flag ? - V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_I_FRAME : - V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE; -err: - return rc; -} - -static long venc_set_multislicing_mode(struct video_client_ctx *client_ctx, - __u32 control, __s32 value) -{ - int rc = 0; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_size vcd_frame_size; - struct vcd_buffer_requirement vcd_buf_req; - struct vcd_property_multi_slice vcd_multi_slice; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto set_multislicing_mode_fail; - } - - vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; - vcd_property_hdr.sz = - sizeof(vcd_frame_size); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_frame_size); - - if (rc) { - WFD_MSG_ERR("Failed to get frame size\n"); - goto set_multislicing_mode_fail; - } - - rc = vcd_get_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, &vcd_buf_req); - - if (rc) { - WFD_MSG_ERR("Failed to get buf reqs\n"); - goto set_multislicing_mode_fail; - } - - vcd_property_hdr.prop_id = VCD_I_MULTI_SLICE; - vcd_property_hdr.sz = sizeof(vcd_multi_slice); - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_multi_slice); - if (rc) { - WFD_MSG_ERR("Failed to get multi slice\n"); - goto set_multislicing_mode_fail; - } - - switch (control) { - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES: - if (vcd_multi_slice.m_slice_sel != - VCD_MSLICE_BY_BYTE_COUNT) { - WFD_MSG_ERR("Not in proper mode\n"); - goto set_multislicing_mode_fail; - } - vcd_multi_slice.m_slice_size = value; - break; - - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: - if (vcd_multi_slice.m_slice_sel != - VCD_MSLICE_BY_MB_COUNT) { - WFD_MSG_ERR("Not in proper mode\n"); - goto set_multislicing_mode_fail; - } - vcd_multi_slice.m_slice_size = value; - break; - - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: - switch (value) { - case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE: - vcd_multi_slice.m_slice_sel = VCD_MSLICE_OFF; - break; - case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB: - vcd_multi_slice.m_slice_sel = VCD_MSLICE_BY_MB_COUNT; - /* Just a temporary size until client calls - * V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB */ - vcd_multi_slice.m_slice_size = - (vcd_frame_size.stride / 16) * - (vcd_frame_size.scan_lines / 16); - break; - case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES: - vcd_multi_slice.m_slice_sel = VCD_MSLICE_BY_BYTE_COUNT; - /* Just a temporary size until client calls - * V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES */ - vcd_multi_slice.m_slice_size = vcd_buf_req.sz; - break; - default: - WFD_MSG_ERR("Unrecognized mode %d\n", value); - rc = -ENOTSUPP; - goto set_multislicing_mode_fail; - } - - break; - default: - rc = -EINVAL; - goto set_multislicing_mode_fail; - } - - rc = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_multi_slice); - if (rc) { - WFD_MSG_ERR("Failed to set multi slice\n"); - goto set_multislicing_mode_fail; - } - -set_multislicing_mode_fail: - return rc; -} - -static long venc_get_multislicing_mode(struct video_client_ctx *client_ctx, - __u32 control, __s32 *value) -{ - int rc = 0; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_size vcd_frame_size; - struct vcd_buffer_requirement vcd_buf_req; - struct vcd_property_multi_slice vcd_multi_slice; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto get_multislicing_mode_fail; - } - - vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; - vcd_property_hdr.sz = - sizeof(vcd_frame_size); - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_frame_size); - - if (rc) { - WFD_MSG_ERR("Failed to get frame size\n"); - goto get_multislicing_mode_fail; - } - - vcd_property_hdr.prop_id = VCD_I_MULTI_SLICE; - vcd_property_hdr.sz = sizeof(vcd_multi_slice); - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_multi_slice); - if (rc) { - WFD_MSG_ERR("Failed to get multi slice\n"); - goto get_multislicing_mode_fail; - } - - rc = vcd_get_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, &vcd_buf_req); - - if (rc) { - WFD_MSG_ERR("Failed to get buf reqs\n"); - goto get_multislicing_mode_fail; - } - - switch (control) { - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES: - if (vcd_multi_slice.m_slice_sel == VCD_MSLICE_BY_BYTE_COUNT) - *value = vcd_multi_slice.m_slice_size; - else { - WFD_MSG_ERR("Invalid query when in slice mode %d\n", - vcd_multi_slice.m_slice_sel); - rc = -EINVAL; - goto get_multislicing_mode_fail; - } - break; - - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: - if (vcd_multi_slice.m_slice_sel == VCD_MSLICE_BY_MB_COUNT) - *value = vcd_multi_slice.m_slice_size; - else { - WFD_MSG_ERR("Invalid query when in slice mode %d\n", - vcd_multi_slice.m_slice_sel); - rc = -EINVAL; - goto get_multislicing_mode_fail; - } - break; - - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: - switch (vcd_multi_slice.m_slice_sel) { - case VCD_MSLICE_OFF: - *value = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE; - break; - case VCD_MSLICE_BY_MB_COUNT: - *value = V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB; - break; - case VCD_MSLICE_BY_BYTE_COUNT: - *value = V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES; - break; - default: - WFD_MSG_ERR("Encoder in an unknown mode %d\n", - vcd_multi_slice.m_slice_sel); - rc = -ENOENT; - goto get_multislicing_mode_fail; - - } - break; - default: - rc = -EINVAL; - goto get_multislicing_mode_fail; - } - -get_multislicing_mode_fail: - return rc; -} - -static long venc_set_entropy_mode(struct video_client_ctx *client_ctx, - __s32 value) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_entropy_control entropy_control; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto set_entropy_mode_fail; - } - - vcd_property_hdr.prop_id = VCD_I_ENTROPY_CTRL; - vcd_property_hdr.sz = sizeof(entropy_control); - - switch (value) { - case V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC: - entropy_control.entropy_sel = VCD_ENTROPY_SEL_CAVLC; - break; - case V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC: - entropy_control.entropy_sel = VCD_ENTROPY_SEL_CABAC; - entropy_control.cabac_model = VCD_CABAC_MODEL_NUMBER_0; - break; - default: - WFD_MSG_ERR("Entropy type %d not supported\n", value); - rc = -ENOTSUPP; - goto set_entropy_mode_fail; - } - rc = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &entropy_control); - if (rc) { - WFD_MSG_ERR("Failed to set entropy mode\n"); - goto set_entropy_mode_fail; - } - -set_entropy_mode_fail: - return rc; -} - -static long venc_get_entropy_mode(struct video_client_ctx *client_ctx, - __s32 *value) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_entropy_control entropy_control; - int rc = 0; - - if (!client_ctx || !value) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto get_entropy_mode_fail; - } - - vcd_property_hdr.prop_id = VCD_I_ENTROPY_CTRL; - vcd_property_hdr.sz = sizeof(entropy_control); - - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &entropy_control); - - if (rc) { - WFD_MSG_ERR("Failed to get entropy mode\n"); - goto get_entropy_mode_fail; - } - - switch (entropy_control.entropy_sel) { - case VCD_ENTROPY_SEL_CAVLC: - *value = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CAVLC; - break; - case VCD_ENTROPY_SEL_CABAC: - *value = V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC; - break; - default: - WFD_MSG_ERR("Entropy type %d not known\n", - entropy_control.entropy_sel); - rc = -EINVAL; - goto get_entropy_mode_fail; - } -get_entropy_mode_fail: - return rc; -} - -static long venc_set_cyclic_intra_refresh_mb( - struct video_client_ctx *client_ctx, - __s32 value) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_intra_refresh_mb_number cir_mb_num; - int rc = 0; - - if (!client_ctx) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto set_cir_mbs_fail; - } - - vcd_property_hdr.prop_id = VCD_I_INTRA_REFRESH; - vcd_property_hdr.sz = sizeof(cir_mb_num); - - cir_mb_num.cir_mb_number = value; - - rc = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &cir_mb_num); - if (rc) { - WFD_MSG_ERR("Failed to set CIR MBs\n"); - goto set_cir_mbs_fail; - } - -set_cir_mbs_fail: - return rc; -} - -static long venc_get_cyclic_intra_refresh_mb( - struct video_client_ctx *client_ctx, - __s32 *value) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_intra_refresh_mb_number cir_mb_num; - int rc = 0; - - if (!client_ctx || !value) { - WFD_MSG_ERR("Invalid parameters\n"); - rc = -EINVAL; - goto get_cir_mbs_fail; - } - - vcd_property_hdr.prop_id = VCD_I_INTRA_REFRESH; - vcd_property_hdr.sz = sizeof(cir_mb_num); - - rc = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &cir_mb_num); - if (rc) { - WFD_MSG_ERR("Failed to set CIR MBs\n"); - goto get_cir_mbs_fail; - } - - *value = cir_mb_num.cir_mb_number; - -get_cir_mbs_fail: - return rc; -} -static long venc_set_input_buffer(struct v4l2_subdev *sd, void *arg) -{ - struct mem_region *mregion = arg; - struct venc_inst *inst = sd->dev_priv; - unsigned long paddr, kvaddr, temp; - struct video_client_ctx *client_ctx = &inst->venc_client; - int rc = 0; - - if (!client_ctx || !mregion) { - WFD_MSG_ERR("Invalid input\n"); - rc = -EINVAL; - goto ins_table_fail; - } - - kvaddr = (unsigned long)mregion->kvaddr; - paddr = (unsigned long)mregion->paddr; - - if (!kvaddr || !paddr) { - WFD_MSG_ERR("Invalid addresses\n"); - rc = -EINVAL; - goto ins_table_fail; - } - - /* - * Just a note: the third arg of vidc_insert_\ - * addr_table_kernel is supposed to be a userspace - * address that is used as a key in the table. As - * these bufs never leave the kernel, we need to have - * an unique value to use as a key. So re-using kernel - * virtual addr for this purpose - */ - rc = vidc_insert_addr_table_kernel(client_ctx, - BUFFER_TYPE_INPUT, kvaddr, kvaddr, - paddr, 32, mregion->size); - - if (rc == (u32)false) { - WFD_MSG_ERR("Failed to insert input buffer into table\n"); - rc = -EFAULT; - goto ins_table_fail; - } - - rc = vcd_set_buffer(client_ctx->vcd_handle, - VCD_BUFFER_INPUT, (u8 *)kvaddr, - mregion->size); - - if (rc) { - WFD_MSG_ERR("Failed to set input buffer\n"); - rc = -EFAULT; - goto set_input_buf_fail; - } - - - return rc; - -set_input_buf_fail: - vidc_delete_addr_table(client_ctx, BUFFER_TYPE_INPUT, - kvaddr, &temp); -ins_table_fail: - return rc; -} - -static long venc_set_output_buffer(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct mem_region *mregion = arg; - if (!client_ctx || !mregion) { - WFD_MSG_ERR("Invalid input\n"); - return -EINVAL; - } - WFD_MSG_DBG("size = %u, offset = %u fd = %d\n", mregion->size, - mregion->offset, mregion->fd); - rc = vidc_insert_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - mregion->cookie, - (unsigned long *)&mregion->kvaddr, - mregion->fd, - mregion->offset, - 32, - mregion->size); - if (rc == (u32)false) { - WFD_MSG_ERR("Failed to insert outbuf in table\n"); - rc = -EINVAL; - goto err; - } - WFD_MSG_DBG("size = %u, %p\n", mregion->size, mregion->kvaddr); - - rc = vcd_set_buffer(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, (u8 *) mregion->kvaddr, - mregion->size); - if (rc) - WFD_MSG_ERR("Failed to set outbuf on encoder\n"); -err: - return rc; -} - -static long venc_fill_outbuf(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct mem_region *mregion = arg; - struct vcd_frame_data vcd_frame = {0}; - unsigned long kernel_vaddr, phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - - if (inst->streaming) { - user_vaddr = mregion->cookie; - rc = vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - true, &user_vaddr, - &kernel_vaddr, &phy_addr, &pmem_fd, &file, - &buffer_index); - if (!rc) { - WFD_MSG_ERR("Address lookup failed\n"); - goto err; - } - vcd_frame.virtual = (u8 *) kernel_vaddr; - vcd_frame.frm_clnt_data = mregion->cookie; - vcd_frame.alloc_len = mregion->size; - - rc = vcd_fill_output_buffer(client_ctx->vcd_handle, &vcd_frame); - if (rc) - WFD_MSG_ERR("Failed to fill output buffer on encoder"); - } else { - struct mem_region *temp = kzalloc(sizeof(*temp), GFP_KERNEL); - *temp = *mregion; - INIT_LIST_HEAD(&temp->list); - list_add_tail(&temp->list, &inst->unqueued_op_bufs.list); - } -err: - return rc; -} - -static long venc_encode_frame(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct venc_buf_info *venc_buf = arg; - struct mem_region *mregion = venc_buf->mregion; - struct vcd_frame_data vcd_input_buffer = {0}; - int64_t ts = 0; - - ts = venc_buf->timestamp; - do_div(ts, NSEC_PER_USEC); - - vcd_input_buffer.virtual = mregion->kvaddr; - vcd_input_buffer.frm_clnt_data = (u32)mregion; - vcd_input_buffer.ip_frm_tag = (u32)mregion; - vcd_input_buffer.data_len = mregion->size; - vcd_input_buffer.time_stamp = ts; - vcd_input_buffer.offset = 0; - - rc = vcd_encode_frame(client_ctx->vcd_handle, - &vcd_input_buffer); - - if (rc) - WFD_MSG_ERR("encode frame failed\n"); - return rc; -} - -static long venc_alloc_recon_buffers(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_buffer_size control; - struct vcd_property_enc_recon_buffer *ctrl = NULL; - unsigned long phy_addr; - int i = 0; - int heap_mask = 0; - u32 ion_flags = 0; - u32 len; - control.width = inst->width; - control.height = inst->height; - vcd_property_hdr.prop_id = VCD_I_GET_RECON_BUFFER_SIZE; - vcd_property_hdr.sz = sizeof(struct vcd_property_buffer_size); - - rc = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (rc) { - WFD_MSG_ERR("Failed to get recon buf size\n"); - goto err; - } - heap_mask = ION_HEAP(ION_CP_MM_HEAP_ID); - heap_mask |= inst->secure ? 0 : ION_HEAP(ION_IOMMU_HEAP_ID); - ion_flags |= inst->secure ? ION_FLAG_SECURE : 0; - - if (vcd_get_ion_status()) { - for (i = 0; i < 4; ++i) { - ctrl = &client_ctx->recon_buffer[i]; - ctrl->buffer_size = control.size; - ctrl->pmem_fd = 0; - ctrl->offset = 0; - ctrl->user_virtual_addr = (void *)i; - client_ctx->recon_buffer_ion_handle[i] - = ion_alloc(client_ctx->user_ion_client, - control.size, SZ_8K, heap_mask, ion_flags); - - ctrl->kernel_virtual_addr = ion_map_kernel( - client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - - if (IS_ERR_OR_NULL(ctrl->kernel_virtual_addr)) { - WFD_MSG_ERR("ion map kernel failed\n"); - rc = -EINVAL; - goto free_ion_alloc; - } - - if (inst->secure) { - rc = ion_phys(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - &phy_addr, (size_t *)&len); - if (rc || !phy_addr) { - WFD_MSG_ERR("ion physical failed\n"); - goto unmap_ion_alloc; - } - } else { - rc = ion_map_iommu(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - VIDEO_DOMAIN, VIDEO_MAIN_POOL, SZ_4K, - 0, &phy_addr, (unsigned long *)&len, - 0, 0); - if (rc || !phy_addr) { - WFD_MSG_ERR( - "ion map iommu failed, rc = %d, phy_addr = 0x%lx\n", - rc, phy_addr); - goto unmap_ion_alloc; - } - - } - ctrl->physical_addr = (u8 *) phy_addr; - ctrl->dev_addr = ctrl->physical_addr; - vcd_property_hdr.prop_id = VCD_I_RECON_BUFFERS; - vcd_property_hdr.sz = - sizeof(struct vcd_property_enc_recon_buffer); - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, ctrl); - if (rc) { - WFD_MSG_ERR("Failed to set recon buffers\n"); - goto unmap_ion_iommu; - } - } - } else { - WFD_MSG_ERR("PMEM not suported\n"); - return -ENOMEM; - } - return rc; -unmap_ion_iommu: - if (!inst->secure) { - if (client_ctx->recon_buffer_ion_handle[i]) { - ion_unmap_iommu(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - VIDEO_DOMAIN, VIDEO_MAIN_POOL); - } - } -unmap_ion_alloc: - if (client_ctx->recon_buffer_ion_handle[i]) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - ctrl->kernel_virtual_addr = NULL; - ctrl->physical_addr = NULL; - } -free_ion_alloc: - if (client_ctx->recon_buffer_ion_handle[i]) { - ion_free(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - client_ctx->recon_buffer_ion_handle[i] = NULL; - } - WFD_MSG_ERR("Failed to allo recon buffers\n"); -err: - return rc; -} - -static long venc_free_output_buffer(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct mem_region *mregion = arg; - unsigned long kernel_vaddr, user_vaddr; - - if (!client_ctx || !mregion) { - WFD_MSG_ERR("Invalid input\n"); - return -EINVAL; - } - - user_vaddr = mregion->cookie; - rc = vidc_delete_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - user_vaddr, - &kernel_vaddr); - if (!rc) { - WFD_MSG_ERR("Failed to delete buf from address table\n"); - return -EINVAL; - } - return vcd_free_buffer(client_ctx->vcd_handle, VCD_BUFFER_OUTPUT, - (u8 *)kernel_vaddr); -} - -static long venc_flush_buffers(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - if (!client_ctx) { - WFD_MSG_ERR("Invalid input\n"); - return -EINVAL; - } - rc = vcd_flush(client_ctx->vcd_handle, VCD_FLUSH_INPUT); - if (rc) { - WFD_MSG_ERR("Failed to flush input buffers\n"); - rc = -EIO; - goto flush_failed; - } - wait_for_completion(&client_ctx->event); - if (client_ctx->event_status) { - WFD_MSG_ERR("callback for vcd_flush input returned error: %u", - client_ctx->event_status); - rc = -EIO; - goto flush_failed; - } - rc = vcd_flush(client_ctx->vcd_handle, VCD_FLUSH_OUTPUT); - if (rc) { - WFD_MSG_ERR("Failed to flush output buffers\n"); - rc = -EIO; - goto flush_failed; - } - wait_for_completion(&client_ctx->event); - if (client_ctx->event_status) { - WFD_MSG_ERR("callback for vcd_flush output returned error: %u", - client_ctx->event_status); - rc = -EIO; - goto flush_failed; - } - -flush_failed: - return rc; -} - -static long venc_free_input_buffer(struct v4l2_subdev *sd, void *arg) -{ - int del_rc = 0, free_rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct mem_region *mregion = arg; - unsigned long vidc_kvaddr; - - if (!client_ctx || !mregion) { - WFD_MSG_ERR("Invalid input\n"); - return -EINVAL; - } - - del_rc = vidc_delete_addr_table(client_ctx, BUFFER_TYPE_INPUT, - (unsigned long)mregion->kvaddr, - &vidc_kvaddr); - /* - * Even if something went wrong in when - * deleting from table, call vcd_free_buf - */ - if (del_rc == (u32)false) { - WFD_MSG_ERR("Failed to delete buf from address table\n"); - del_rc = -ENOKEY; - } else if ((u8 *)vidc_kvaddr != mregion->kvaddr) { - WFD_MSG_ERR("Failed to find expected buffer\n"); - del_rc = -EINVAL; - } else - del_rc = 0; - - free_rc = vcd_free_buffer(client_ctx->vcd_handle, VCD_BUFFER_INPUT, - (u8 *)vidc_kvaddr); - - if (free_rc) { - WFD_MSG_ERR("Failed to free buffer from encoder\n"); - free_rc = -EINVAL; - } - - return del_rc ? del_rc : free_rc; -} - -static long venc_free_recon_buffers(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct video_client_ctx *client_ctx = &inst->venc_client; - struct vcd_property_hdr vcd_property_hdr; - int i; - - if (vcd_get_ion_status()) { - for (i = 0; i < 4; i++) { - vcd_property_hdr.prop_id = VCD_I_FREE_RECON_BUFFERS; - vcd_property_hdr.sz = - sizeof(struct vcd_property_buffer_size); - rc = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &client_ctx->recon_buffer[i]); - if (rc) - WFD_MSG_ERR("Failed to free recon buffer\n"); - - if (!IS_ERR_OR_NULL( - client_ctx->recon_buffer_ion_handle[i])) { - if (!inst->secure) { - ion_unmap_iommu( - client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - VIDEO_DOMAIN, VIDEO_MAIN_POOL); - } - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - ion_free(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - client_ctx->recon_buffer_ion_handle[i] = NULL; - } - } - } - return rc; -} - -static long venc_set_property(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct v4l2_control *ctrl = arg; - struct video_client_ctx *client_ctx = &inst->venc_client; - switch (ctrl->id) { - case V4L2_CID_MPEG_VIDEO_BITRATE: - rc = venc_set_bitrate(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: - rc = venc_set_bitrate_mode(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_I_PERIOD: - rc = venc_set_h264_intra_period(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_LEVEL: - rc = venc_set_codec_level(client_ctx, ctrl->id, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_PROFILE: - rc = venc_set_codec_profile(client_ctx, ctrl->id, ctrl->value); - break; - case V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_IFRAME: - rc = venc_request_frame(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP: - rc = venc_set_qp_value(client_ctx, ctrl->id, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H263_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H263_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H264_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H264_MAX_QP: - rc = venc_set_qp_range(client_ctx, ctrl->id, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_HEADER_MODE: - rc = venc_set_header_mode(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES: - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: - rc = venc_set_multislicing_mode(client_ctx, ctrl->id, - ctrl->value); - break; - case V4L2_CID_MPEG_VIDC_SET_PERF_LEVEL: - rc = venc_set_max_perf_level(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDC_VIDEO_H264_AU_DELIMITER: - rc = venc_set_avc_delimiter(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDC_VIDEO_H264_VUI_TIMING_INFO: - rc = venc_set_vui_timing_info(client_ctx, inst, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: - rc = venc_set_entropy_mode(client_ctx, ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: - rc = venc_set_cyclic_intra_refresh_mb(client_ctx, ctrl->value); - break; - default: - WFD_MSG_ERR("Set property not suported: %d\n", ctrl->id); - rc = -ENOTSUPP; - break; - } - return rc; -} - -static long venc_get_property(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct venc_inst *inst = sd->dev_priv; - struct v4l2_control *ctrl = arg; - struct video_client_ctx *client_ctx = &inst->venc_client; - - switch (ctrl->id) { - case V4L2_CID_MPEG_VIDEO_BITRATE: - rc = venc_get_bitrate(client_ctx, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: - rc = venc_get_bitrate_mode(client_ctx, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_LEVEL: - rc = venc_get_codec_level(client_ctx, ctrl->id, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_PROFILE: - rc = venc_get_codec_profile(client_ctx, ctrl->id, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_I_PERIOD: - rc = venc_get_h264_intra_period(client_ctx, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP: - rc = venc_get_qp_value(client_ctx, ctrl->id, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP: - case V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H263_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H263_MAX_QP: - case V4L2_CID_MPEG_VIDEO_H264_MIN_QP: - case V4L2_CID_MPEG_VIDEO_H264_MAX_QP: - rc = venc_get_qp_range(client_ctx, ctrl->id, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_HEADER_MODE: - rc = venc_get_header_mode(client_ctx, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES: - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: - case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: - rc = venc_get_multislicing_mode(client_ctx, ctrl->id, - &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: - rc = venc_get_entropy_mode(client_ctx, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: - rc = venc_get_cyclic_intra_refresh_mb(client_ctx, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDC_VIDEO_H264_AU_DELIMITER: - rc = venc_get_avc_delimiter(client_ctx, &ctrl->value); - break; - case V4L2_CID_MPEG_VIDC_VIDEO_H264_VUI_TIMING_INFO: - rc = venc_get_vui_timing_info(client_ctx, &ctrl->value); - break; - default: - WFD_MSG_ERR("Get property not suported: %d\n", ctrl->id); - rc = -ENOTSUPP; - break; - } - return rc; -} - -long venc_mmap(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst = sd->dev_priv; - struct mem_region_map *mmap = arg; - struct mem_region *mregion = NULL; - unsigned long rc = 0, size = 0; - void *paddr = NULL; - - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - return -EINVAL; - } else if (!mmap || !mmap->mregion) { - WFD_MSG_ERR("Memregion required for %s\n", __func__); - return -EINVAL; - } - - mregion = mmap->mregion; - if (mregion->size % SZ_4K != 0) { - WFD_MSG_ERR("Memregion not aligned to %d\n", SZ_4K); - return -EINVAL; - } - - if (inst->secure) { - rc = ion_phys(mmap->ion_client, mregion->ion_handle, - (unsigned long *)&paddr, - (size_t *)&size); - } else { - rc = ion_map_iommu(mmap->ion_client, mregion->ion_handle, - VIDEO_DOMAIN, VIDEO_MAIN_POOL, SZ_4K, - 0, (unsigned long *)&paddr, - &size, 0, 0); - } - - if (rc) { - WFD_MSG_ERR("Failed to get physical addr\n"); - paddr = NULL; - } else if (size < mregion->size) { - WFD_MSG_ERR("Failed to map enough memory\n"); - rc = -ENOMEM; - } - - mregion->paddr = paddr; - return rc; -} - -long venc_munmap(struct v4l2_subdev *sd, void *arg) -{ - struct venc_inst *inst = sd->dev_priv; - struct mem_region_map *mmap = arg; - struct mem_region *mregion = NULL; - if (!sd) { - WFD_MSG_ERR("Subdevice required for %s\n", __func__); - return -EINVAL; - } else if (!mregion) { - WFD_MSG_ERR("Memregion required for %s\n", __func__); - return -EINVAL; - } - - mregion = mmap->mregion; - if (!inst->secure) { - ion_unmap_iommu(mmap->ion_client, mregion->ion_handle, - VIDEO_DOMAIN, VIDEO_MAIN_POOL); - } - - return 0; -} - -long venc_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) -{ - long rc = 0; - switch (cmd) { - case OPEN: - rc = venc_open(sd, arg); - break; - case CLOSE: - rc = venc_close(sd, arg); - break; - case ENCODE_START: - rc = venc_start(sd); - break; - case ENCODE_FRAME: - venc_encode_frame(sd, arg); - break; - case ENCODE_STOP: - rc = venc_stop(sd); - break; - case SET_PROP: - rc = venc_set_property(sd, arg); - break; - case GET_PROP: - rc = venc_get_property(sd, arg); - break; - case GET_BUFFER_REQ: - rc = venc_get_buffer_req(sd, arg); - break; - case SET_BUFFER_REQ: - rc = venc_set_buffer_req(sd, arg); - break; - case FREE_BUFFER: - break; - case FILL_OUTPUT_BUFFER: - rc = venc_fill_outbuf(sd, arg); - break; - case SET_FORMAT: - rc = venc_set_format(sd, arg); - break; - case SET_FRAMERATE: - rc = venc_set_framerate(sd, arg); - break; - case SET_INPUT_BUFFER: - rc = venc_set_input_buffer(sd, arg); - break; - case SET_OUTPUT_BUFFER: - rc = venc_set_output_buffer(sd, arg); - break; - case ALLOC_RECON_BUFFERS: - rc = venc_alloc_recon_buffers(sd, arg); - break; - case FREE_OUTPUT_BUFFER: - rc = venc_free_output_buffer(sd, arg); - break; - case FREE_INPUT_BUFFER: - rc = venc_free_input_buffer(sd, arg); - break; - case FREE_RECON_BUFFERS: - rc = venc_free_recon_buffers(sd, arg); - break; - case ENCODE_FLUSH: - rc = venc_flush_buffers(sd, arg); - break; - case ENC_MMAP: - rc = venc_mmap(sd, arg); - break; - case ENC_MUNMAP: - rc = venc_munmap(sd, arg); - break; - case SET_FRAMERATE_MODE: - rc = venc_set_framerate_mode(sd, arg); - break; - default: - rc = -1; - break; - } - return rc; -} diff --git a/drivers/media/platform/msm/wfd/mdp-4-subdev.c b/drivers/media/platform/msm/wfd/mdp-4-subdev.c deleted file mode 100644 index 2d79622f2203e82b78a7f81a89c4e7c23e714c10..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/wfd/mdp-4-subdev.c +++ /dev/null @@ -1,300 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include "enc-subdev.h" -#include "mdp-subdev.h" -#include "wfd-util.h" - -struct mdp_instance { - struct fb_info *mdp; - u32 height; - u32 width; - bool secure; - bool uses_iommu_split_domain; -}; - -int mdp_init(struct v4l2_subdev *sd, u32 val) -{ - return 0; -} - -int mdp_open(struct v4l2_subdev *sd, void *arg) -{ - struct mdp_instance *inst = kzalloc(sizeof(struct mdp_instance), - GFP_KERNEL); - struct mdp_msg_ops *mops = arg; - int rc = 0; - struct fb_info *fbi = NULL; - - if (!inst) { - WFD_MSG_ERR("Out of memory\n"); - rc = -ENOMEM; - goto mdp_open_fail; - } else if (!mops) { - WFD_MSG_ERR("Invalid arguments\n"); - rc = -EINVAL; - goto mdp_open_fail; - } - - fbi = msm_fb_get_writeback_fb(); - if (!fbi) { - WFD_MSG_ERR("Failed to acquire mdp instance\n"); - rc = -ENODEV; - goto mdp_open_fail; - } - - msm_fb_writeback_init(fbi); - inst->mdp = fbi; - inst->secure = mops->secure; - inst->uses_iommu_split_domain = mops->iommu_split_domain; - - mops->cookie = inst; - return rc; -mdp_open_fail: - kfree(inst); - return rc; -} - -int mdp_start(struct v4l2_subdev *sd, void *arg) -{ - struct mdp_instance *inst = arg; - int rc = 0; - struct fb_info *fbi = NULL; - if (inst) { - rc = msm_fb_writeback_start(inst->mdp); - if (rc) { - WFD_MSG_ERR("Failed to start MDP mode\n"); - goto exit; - } - fbi = msm_fb_get_writeback_fb(); - if (!fbi) { - WFD_MSG_ERR("Failed to acquire mdp instance\n"); - rc = -ENODEV; - goto exit; - } - } -exit: - return rc; -} -int mdp_stop(struct v4l2_subdev *sd, void *arg) -{ - struct mdp_instance *inst = arg; - int rc = 0; - struct fb_info *fbi = NULL; - if (inst) { - rc = msm_fb_writeback_stop(inst->mdp); - if (rc) { - WFD_MSG_ERR("Failed to stop writeback mode\n"); - return rc; - } - fbi = (struct fb_info *)inst->mdp; - } - return 0; -} -int mdp_close(struct v4l2_subdev *sd, void *arg) -{ - struct mdp_instance *inst = arg; - struct fb_info *fbi = NULL; - if (inst) { - fbi = (struct fb_info *)inst->mdp; - msm_fb_writeback_terminate(fbi); - kfree(inst); - } - return 0; -} -int mdp_q_buffer(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct mdp_buf_info *binfo = arg; - struct msmfb_data fbdata; - struct mdp_instance *inst; - if (!binfo || !binfo->inst || !binfo->cookie) { - WFD_MSG_ERR("Invalid argument\n"); - return -EINVAL; - } - inst = binfo->inst; - fbdata.offset = binfo->offset; - fbdata.memory_id = binfo->fd; - fbdata.iova = binfo->paddr; - fbdata.id = 0; - fbdata.flags = 0; - fbdata.priv = (uint32_t)binfo->cookie; - - WFD_MSG_INFO("queue buffer to mdp with offset = %u, fd = %u, "\ - "priv = %p, iova = %p\n", - fbdata.offset, fbdata.memory_id, - (void *)fbdata.priv, (void *)fbdata.iova); - rc = msm_fb_writeback_queue_buffer(inst->mdp, &fbdata); - - if (rc) - WFD_MSG_ERR("Failed to queue buffer\n"); - return rc; -} -int mdp_dq_buffer(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct mdp_buf_info *obuf = arg; - struct msmfb_data fbdata; - struct mdp_instance *inst; - if (!arg) { - WFD_MSG_ERR("Invalid argument\n"); - return -EINVAL; - } - - inst = obuf->inst; - fbdata.flags = MSMFB_WRITEBACK_DEQUEUE_BLOCKING; - rc = msm_fb_writeback_dequeue_buffer(inst->mdp, &fbdata); - if (rc) { - WFD_MSG_ERR("Failed to dequeue buffer\n"); - return rc; - } - WFD_MSG_DBG("dequeue buf from mdp with priv = %u\n", - fbdata.priv); - obuf->cookie = (void *)fbdata.priv; - return rc; -} -int mdp_set_prop(struct v4l2_subdev *sd, void *arg) -{ - struct mdp_prop *prop = (struct mdp_prop *)arg; - struct mdp_instance *inst = prop->inst; - if (!prop || !inst) { - WFD_MSG_ERR("Invalid arguments\n"); - return -EINVAL; - } - inst->height = prop->height; - inst->width = prop->width; - return 0; -} - -int mdp_mmap(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0, domain = -1; - struct mem_region_map *mmap = arg; - struct mem_region *mregion; - bool use_iommu = true; - struct mdp_instance *inst = NULL; - - if (!mmap || !mmap->mregion || !mmap->cookie) { - WFD_MSG_ERR("Invalid argument\n"); - return -EINVAL; - } - - inst = mmap->cookie; - mregion = mmap->mregion; - if (mregion->size % SZ_4K != 0) { - WFD_MSG_ERR("Memregion not aligned to %d\n", SZ_4K); - return -EINVAL; - } - - if (inst->uses_iommu_split_domain) { - if (inst->secure) - use_iommu = false; - else - domain = DISPLAY_WRITE_DOMAIN; - } else { - domain = DISPLAY_READ_DOMAIN; - } - - if (use_iommu) { - rc = ion_map_iommu(mmap->ion_client, mregion->ion_handle, - domain, GEN_POOL, SZ_4K, 0, - (unsigned long *)&mregion->paddr, - (unsigned long *)&mregion->size, - 0, 0); - } else { - rc = ion_phys(mmap->ion_client, mregion->ion_handle, - (unsigned long *)&mregion->paddr, - (size_t *)&mregion->size); - } - - return rc; -} - -int mdp_munmap(struct v4l2_subdev *sd, void *arg) -{ - struct mem_region_map *mmap = arg; - struct mem_region *mregion; - bool use_iommu = false; - int domain = -1; - struct mdp_instance *inst = NULL; - - if (!mmap || !mmap->mregion || !mmap->cookie) { - WFD_MSG_ERR("Invalid argument\n"); - return -EINVAL; - } - - inst = mmap->cookie; - mregion = mmap->mregion; - - if (inst->uses_iommu_split_domain) { - if (inst->secure) - use_iommu = false; - else - domain = DISPLAY_WRITE_DOMAIN; - } else { - domain = DISPLAY_READ_DOMAIN; - } - - if (use_iommu) - ion_unmap_iommu(mmap->ion_client, - mregion->ion_handle, - domain, GEN_POOL); - - return 0; -} - -long mdp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) -{ - int rc = 0; - if (!sd) { - WFD_MSG_ERR("Invalid arguments\n"); - return -EINVAL; - } - switch (cmd) { - case MDP_Q_BUFFER: - rc = mdp_q_buffer(sd, arg); - break; - case MDP_DQ_BUFFER: - rc = mdp_dq_buffer(sd, arg); - break; - case MDP_OPEN: - rc = mdp_open(sd, arg); - break; - case MDP_START: - rc = mdp_start(sd, arg); - break; - case MDP_STOP: - rc = mdp_stop(sd, arg); - break; - case MDP_SET_PROP: - rc = mdp_set_prop(sd, arg); - break; - case MDP_CLOSE: - rc = mdp_close(sd, arg); - break; - case MDP_MMAP: - rc = mdp_mmap(sd, arg); - break; - case MDP_MUNMAP: - rc = mdp_munmap(sd, arg); - break; - default: - WFD_MSG_ERR("IOCTL: %u not supported\n", cmd); - rc = -EINVAL; - break; - } - return rc; -} diff --git a/drivers/media/platform/msm/wfd/mdp-dummy-subdev.c b/drivers/media/platform/msm/wfd/mdp-dummy-subdev.c deleted file mode 100644 index 46977a67edb83a10d12a1a70722d2b206318b593..0000000000000000000000000000000000000000 --- a/drivers/media/platform/msm/wfd/mdp-dummy-subdev.c +++ /dev/null @@ -1,207 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include - -#include "enc-subdev.h" -#include "mdp-subdev.h" -#include "wfd-util.h" - -#ifndef CONFIG_MSM_WFD_DEBUG -#error "Dummy subdevice must only be used when CONFIG_MSM_WFD_DEBUG=y" -#endif - -struct mdp_buf_queue { - struct mdp_buf_info mdp_buf_info; - struct list_head node; -}; - -struct mdp_instance { - struct mdp_buf_queue mdp_bufs; - struct mutex mutex; -}; - -static int mdp_init(struct v4l2_subdev *sd, u32 val) -{ - return 0; -} - -static int mdp_open(struct v4l2_subdev *sd, void *arg) -{ - struct mdp_instance *inst = kzalloc(sizeof(struct mdp_instance), - GFP_KERNEL); - void **cookie = (void **)arg; - int rc = 0; - - if (!inst) { - WFD_MSG_ERR("Out of memory\n"); - return -ENOMEM; - } - - INIT_LIST_HEAD(&inst->mdp_bufs.node); - mutex_init(&inst->mutex); - *cookie = inst; - return rc; -} - -static int mdp_start(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static int mdp_stop(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static int mdp_close(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static int mdp_q_buffer(struct v4l2_subdev *sd, void *arg) -{ - static int foo; - int rc = 0; - struct mdp_buf_info *binfo = arg; - struct mdp_instance *inst = NULL; - struct mdp_buf_queue *new_entry = NULL; - - if (!binfo || !binfo->inst || !binfo->cookie) { - WFD_MSG_ERR("Invalid argument\n"); - return -EINVAL; - } - - inst = binfo->inst; - new_entry = kzalloc(sizeof(*new_entry), GFP_KERNEL); - if (!new_entry) - return -ENOMEM; - - new_entry->mdp_buf_info = *binfo; - if (binfo->kvaddr) - memset((void *)binfo->kvaddr, foo++, 1024); - - - mutex_lock(&inst->mutex); - list_add_tail(&new_entry->node, &inst->mdp_bufs.node); - mutex_unlock(&inst->mutex); - - WFD_MSG_DBG("Queue %p with cookie %p\n", - (void *)binfo->paddr, (void *)binfo->cookie); - return rc; -} - -static int mdp_dq_buffer(struct v4l2_subdev *sd, void *arg) -{ - struct mdp_buf_info *binfo = arg; - struct mdp_buf_queue *head = NULL; - struct mdp_instance *inst = NULL; - - inst = binfo->inst; - - while (head == NULL) { - mutex_lock(&inst->mutex); - if (!list_empty(&inst->mdp_bufs.node)) - head = list_first_entry(&inst->mdp_bufs.node, - struct mdp_buf_queue, node); - mutex_unlock(&inst->mutex); - } - - if (head == NULL) - return -ENOBUFS; - - mutex_lock(&inst->mutex); - list_del(&head->node); - mutex_unlock(&inst->mutex); - - *binfo = head->mdp_buf_info; - WFD_MSG_DBG("Dequeue %p with cookie %p\n", - (void *)binfo->paddr, (void *)binfo->cookie); - return 0; - -} - -static int mdp_set_prop(struct v4l2_subdev *sd, void *arg) -{ - return 0; -} - -static int mdp_mmap(struct v4l2_subdev *sd, void *arg) -{ - int rc = 0; - struct mem_region_map *mmap = arg; - struct mem_region *mregion; - - mregion = mmap->mregion; - mregion->paddr = mregion->kvaddr; - return rc; -} - -static int mdp_munmap(struct v4l2_subdev *sd, void *arg) -{ - /* Whatever */ - return 0; -} - -static int mdp_secure(struct v4l2_subdev *sd) -{ - return 0; -} - -long mdp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) -{ - int rc = 0; - if (!sd) { - WFD_MSG_ERR("Invalid arguments\n"); - return -EINVAL; - } - switch (cmd) { - case MDP_Q_BUFFER: - rc = mdp_q_buffer(sd, arg); - break; - case MDP_DQ_BUFFER: - rc = mdp_dq_buffer(sd, arg); - break; - case MDP_OPEN: - rc = mdp_open(sd, arg); - break; - case MDP_START: - rc = mdp_start(sd, arg); - break; - case MDP_STOP: - rc = mdp_stop(sd, arg); - break; - case MDP_SET_PROP: - rc = mdp_set_prop(sd, arg); - break; - case MDP_CLOSE: - rc = mdp_close(sd, arg); - break; - case MDP_MMAP: - rc = mdp_mmap(sd, arg); - break; - case MDP_MUNMAP: - rc = mdp_munmap(sd, arg); - break; - case MDP_SECURE: - rc = mdp_secure(sd); - break; - default: - WFD_MSG_ERR("IOCTL: %u not supported\n", cmd); - rc = -EINVAL; - break; - } - return rc; -} diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 14945887b0269e42f640d5ca5668774338cb350a..6a3840f22bded25f20127a98a7bccb58093c79aa 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -495,17 +495,6 @@ config RADIO_ZOLTRIX_PORT endif # V4L_RADIO_ISA_DRIVERS -config RADIO_TAVARUA - tristate "Qualcomm Tavaraua I2C FM support" - depends on I2C && VIDEO_V4L2 && MARIMBA_CORE - default n - ---help--- - Say Y here if you want to use the Qualcomm FM chip (Tavarua). - This FM chip uses I2C interface. - - To compile this driver as a module, choose M here: the - module will be called radio-tavarua. - config RADIO_IRIS tristate "Qualcomm IRIS FM support" depends on VIDEO_V4L2 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 40d82215fc2426c771129919a699b89e0be61222..be41d9988f49fce332304bef8168dfafa6d43fa3 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -32,7 +32,6 @@ obj-$(CONFIG_RADIO_TEF6862) += tef6862.o obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o obj-$(CONFIG_RADIO_WL128X) += wl128x/ -obj-$(CONFIG_RADIO_TAVARUA) += radio-tavarua.o obj-$(CONFIG_RADIO_IRIS) += radio-iris.o obj-$(CONFIG_RADIO_IRIS_TRANSPORT) += radio-iris-transport.o diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 40e8808cf10adfe96882346a2851508850c0ca44..88d73e877fea0dd4dd836120cacb08ca313952d9 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -233,30 +233,6 @@ config MFD_JANZ_CMODIO host many different types of MODULbus daughterboards, including CAN and GPIO controllers. -config TPS65023 - tristate "TPS65023 Power Management chip" - depends on I2C && ARCH_MSM_SCORPION && !MSM_SMP - default y if I2C && ARCH_MSM_SCORPION && !MSM_SMP - help - Say yes here for Qualcomm QSD chips. The TI PMIC is used by the - QSD8x50 series of chips for power management. - -config PMIC8058 - tristate "PMIC8058 Power Management chip" - depends on MSM_SSBI - select MFD_CORE - select MFD_PM8XXX - help - Say yes here for Qualcomm PM8058 chip. - -config PMIC8901 - tristate "PMIC8901 Power Management chip" - depends on MSM_SSBI - select MFD_CORE - select MFD_PM8XXX - help - Say yes here for Qualcomm PM8901 chip. - config MFD_JZ4740_ADC bool "Janz JZ4740 ADC core" select MFD_CORE @@ -349,41 +325,6 @@ config MFD_MAX8925 accessing the device, additional drivers must be enabled in order to use the functionality of the device. -config MARIMBA_CORE - tristate "Marimba Core" - depends on I2C && (ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_MSM7X27A || ARCH_MSM8960) - default n - help - Enables the Marimba Core driver. The core driver provides - read/write capability to registers which are part of the - marimba core. - This driver dynamically detects the SoC and works for both - Marimba and Bahama Chip. - -config MARIMBA_CODEC - tristate "Marimba Codec" - depends on MARIMBA_CORE - default n - help - This driver programs Marimba Wideband Codec for input/output of - audio signal. - -config TIMPANI_CODEC - tristate "Timpani Codec" - depends on MARIMBA_CORE - default n - help - This driver programs Timpani Wideband Codec for input/output of - audio signal. - -config MARIMBA_TSADC - tristate "Support for Marimba Touchscreen ADC" - depends on MARIMBA_CORE && ARCH_MSM7X30 - default y if MARIMBA_CORE - help - Say yes here if you want to include support for TSADC in the - Qualcomm Marimba chip. - config MFD_MAX8997 bool "Maxim Semiconductor MAX8997/8966 PMIC Support" depends on I2C=y && GENERIC_HARDIRQS @@ -491,51 +432,6 @@ config MFD_PM8921_CORE Say M here if you want to include support for PM8921 chip as a module. This will build a module called "pm8921-core". -config MFD_PM8821_CORE - tristate "Qualcomm PM8821 PMIC chip" - depends on MSM_SSBI - select MFD_CORE - select MFD_PM8XXX - help - If you say yes to this option, support will be included for the - built-in PM8821 PMIC chip. - - This is required if your board has a PM8821 and uses its features, - such as: MPPs, and interrupts. - - Say M here if you want to include support for PM8821 chip as a module. - This will build a module called "pm8821-core". - -config MFD_PM8018_CORE - tristate "Qualcomm PM8018 PMIC chip" - depends on MSM_SSBI - select MFD_CORE - select MFD_PM8XXX - help - If you say yes to this option, support will be included for the - built-in PM8018 PMIC chip. - - This is required if your board has a PM8018 and uses its features, - such as: MPPs, GPIOs, regulators, interrupts, and PWM. - - Say M here if you want to include support for PM8018 chip as a module. - This will build a module called "pm8018-core". - -config MFD_PM8038_CORE - tristate "Qualcomm PM8038 PMIC chip" - depends on MSM_SSBI - select MFD_CORE - select MFD_PM8XXX - help - If you say yes to this option, support will be included for the - built-in PM8038 PMIC chip. - - This is required if your board has a PM8038 and uses its features, - such as: MPPs, GPIOs, regulators, interrupts, and PWM. - - Say M here if you want to include support for PM8038 chip as a module. - This will build a module called "pm8038-core". - config MFD_PM8XXX_IRQ bool "Qualcomm PM8xxx IRQ features" depends on MFD_PM8XXX @@ -546,49 +442,6 @@ config MFD_PM8XXX_IRQ This is required to use certain other PM 8xxx features, such as GPIO and MPP. -config MFD_PM8XXX_PWM - tristate "Support for Qualcomm PM8xxx PWM feature" - depends on MFD_PM8XXX - default y if MFD_PM8XXX - help - This is the Pulse Width Modulation (PWM) driver for Qualcomm - PM 8xxx PMIC chips. It can drive 8 channels of PWM output, and - has a lookup table with size of 64 to be shared by any of the - 8 channels. - -config MFD_PM8XXX_MISC - tristate "Support for Qualcomm PM8xxx miscellaneous APIs" - depends on MFD_PM8XXX - default y if MFD_PM8XXX - help - This driver implements several miscellaneous APIs that may be needed - in order to control the PM8XXX PMIC chip. - -config MFD_PM8XXX_SPK - tristate "Support for Qualcomm PM8xxx speaker APIs" - depends on MFD_PM8XXX - help - This driver implements several external speaker amplifier APIs that - may be needed in order to control the PM8XXX PMIC chip. - -config MFD_PM8XXX_BATT_ALARM - tristate "Support for Qualcomm PM8xxx battery voltage alarm" - depends on MFD_PM8XXX - help - This driver provides a means monitor battery under and over-voltage - conditions. An upper and/or lower threshold can be specified for - normal operation. A wakeable interrupt is triggered when the battery - voltage leaves the accepatable range which then calls a notifier call - chain. - -config MFD_PM8821_IRQ - bool "Support for Qualcomm PM8821 IRQ features" - default y if MFD_PM8821_CORE - help - This is the IRQ driver for Qualcomm PM 8821 PMIC chips. - - This is required to use certain other PM 8821 features, such as MPPs. - config MFD_RDC321X tristate "RDC R-321x southbridge" select MFD_CORE @@ -1193,16 +1046,6 @@ config MFD_WM5110 help Support for Wolfson Microelectronics WM5110 low power audio SoC -config MFD_PM8XXX_DEBUG - tristate "Qualcomm PM8xxx debugfs support" - depends on MFD_PM8XXX && DEBUG_FS - default y if MFD_PM8XXX - help - This driver provides a debugfs interface to the SSBI registers on - Qualcomm PM 8xxx PMIC chips. It allows for reads and writes to - arbitrary addresses. Writes are blocking so values are guaranteed to - be set into hardware registers upon return. - config MFD_WM8400 bool "Wolfson Microelectronics WM8400" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 147e6dd4634cd34dbb1b171b4e243756881edae2..66437f94e950bb6a54142a8a944a505197f76226 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -73,14 +73,7 @@ obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o obj-$(CONFIG_TWL6040_CORE) += twl6040.o -obj-$(CONFIG_MARIMBA_CORE) += marimba-core.o -obj-$(CONFIG_MARIMBA_CODEC) += marimba-codec.o -obj-$(CONFIG_MARIMBA_CODEC) += msm-adie-codec.o -obj-$(CONFIG_MARIMBA_TSADC) += marimba-tsadc.o -obj-$(CONFIG_TPS65023) += tps65023.o -obj-$(CONFIG_TIMPANI_CODEC) += timpani-codec.o -obj-$(CONFIG_TIMPANI_CODEC) += msm-adie-codec.o obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o obj-$(CONFIG_MFD_MC13XXX_SPI) += mc13xxx-spi.o @@ -159,8 +152,6 @@ obj-$(CONFIG_MFD_SI476X_CORE) += si476x-core.o obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o omap-usb-tll.o obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o -obj-$(CONFIG_MFD_PM8821_CORE) += pm8821-core.o -obj-$(CONFIG_MFD_PM8018_CORE) += pm8018-core.o obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o obj-$(CONFIG_MFD_TPS65090) += tps65090.o @@ -175,12 +166,3 @@ obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o vexpress-sysreg.o obj-$(CONFIG_MFD_RETU) += retu-mfd.o obj-$(CONFIG_MFD_AS3711) += as3711.o -obj-$(CONFIG_PMIC8058) += pmic8058.o -obj-$(CONFIG_PMIC8901) += pmic8901.o -obj-$(CONFIG_MFD_PM8038_CORE) += pm8038-core.o -obj-$(CONFIG_MFD_PM8821_IRQ) += pm8821-irq.o -obj-$(CONFIG_MFD_PM8XXX_DEBUG) += pm8xxx-debug.o -obj-$(CONFIG_MFD_PM8XXX_PWM) += pm8xxx-pwm.o -obj-$(CONFIG_MFD_PM8XXX_MISC) += pm8xxx-misc.o -obj-$(CONFIG_MFD_PM8XXX_SPK) += pm8xxx-spk.o -obj-$(CONFIG_MFD_PM8XXX_BATT_ALARM) += pm8xxx-batt-alarm.o diff --git a/drivers/mfd/marimba-codec.c b/drivers/mfd/marimba-codec.c deleted file mode 100644 index 2ba251cb4282c84018df2d392e8c0b24c90b6e67..0000000000000000000000000000000000000000 --- a/drivers/mfd/marimba-codec.c +++ /dev/null @@ -1,963 +0,0 @@ -/* Copyright (c) 2009-2010, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#define MARIMBA_CDC_RX_CTL 0x81 -#define MARIMBA_CDC_RX_CTL_ST_EN_MASK 0x20 -#define MARIMBA_CDC_RX_CTL_ST_EN_SHFT 0x5 -#define MARIMBA_CODEC_CDC_LRXG 0x84 -#define MARIMBA_CODEC_CDC_RRXG 0x85 -#define MARIMBA_CODEC_CDC_LTXG 0x86 -#define MARIMBA_CODEC_CDC_RTXG 0x87 - -#define MAX_MDELAY_US 2000 -#define MIN_MDELAY_US 1000 - -struct adie_codec_path { - struct adie_codec_dev_profile *profile; - struct adie_codec_register_image img; - u32 hwsetting_idx; - u32 stage_idx; - u32 curr_stage; -}; - -static struct adie_codec_register adie_codec_tx_regs[] = { - { 0x04, 0xc0, 0x8C }, - { 0x0D, 0xFF, 0x00 }, - { 0x0E, 0xFF, 0x00 }, - { 0x0F, 0xFF, 0x00 }, - { 0x10, 0xF8, 0x68 }, - { 0x11, 0xFE, 0x00 }, - { 0x12, 0xFE, 0x00 }, - { 0x13, 0xFF, 0x58 }, - { 0x14, 0xFF, 0x00 }, - { 0x15, 0xFE, 0x00 }, - { 0x16, 0xFF, 0x00 }, - { 0x1A, 0xFF, 0x00 }, - { 0x80, 0x01, 0x00 }, - { 0x82, 0x7F, 0x18 }, - { 0x83, 0x1C, 0x00 }, - { 0x86, 0xFF, 0xAC }, - { 0x87, 0xFF, 0xAC }, - { 0x89, 0xFF, 0xFF }, - { 0x8A, 0xF0, 0x30 } -}; - -static struct adie_codec_register adie_codec_rx_regs[] = { - { 0x23, 0xF8, 0x00 }, - { 0x24, 0x6F, 0x00 }, - { 0x25, 0x7F, 0x00 }, - { 0x26, 0xFC, 0x00 }, - { 0x28, 0xFE, 0x00 }, - { 0x29, 0xFE, 0x00 }, - { 0x33, 0xFF, 0x00 }, - { 0x34, 0xFF, 0x00 }, - { 0x35, 0xFC, 0x00 }, - { 0x36, 0xFE, 0x00 }, - { 0x37, 0xFE, 0x00 }, - { 0x38, 0xFE, 0x00 }, - { 0x39, 0xF0, 0x00 }, - { 0x3A, 0xFF, 0x0A }, - { 0x3B, 0xFC, 0xAC }, - { 0x3C, 0xFC, 0xAC }, - { 0x3D, 0xFF, 0x55 }, - { 0x3E, 0xFF, 0x55 }, - { 0x3F, 0xCF, 0x00 }, - { 0x40, 0x3F, 0x00 }, - { 0x41, 0x3F, 0x00 }, - { 0x42, 0xFF, 0x00 }, - { 0x43, 0xF7, 0x00 }, - { 0x43, 0xF7, 0x00 }, - { 0x43, 0xF7, 0x00 }, - { 0x43, 0xF7, 0x00 }, - { 0x44, 0xF7, 0x00 }, - { 0x45, 0xFF, 0x00 }, - { 0x46, 0xFF, 0x00 }, - { 0x47, 0xF7, 0x00 }, - { 0x48, 0xF7, 0x00 }, - { 0x49, 0xFF, 0x00 }, - { 0x4A, 0xFF, 0x00 }, - { 0x80, 0x02, 0x00 }, - { 0x81, 0xFF, 0x4C }, - { 0x83, 0x23, 0x00 }, - { 0x84, 0xFF, 0xAC }, - { 0x85, 0xFF, 0xAC }, - { 0x88, 0xFF, 0xFF }, - { 0x8A, 0x0F, 0x03 }, - { 0x8B, 0xFF, 0xAC }, - { 0x8C, 0x03, 0x01 }, - { 0x8D, 0xFF, 0x00 }, - { 0x8E, 0xFF, 0x00 } -}; - -static struct adie_codec_register adie_codec_lb_regs[] = { - { 0x2B, 0x8F, 0x02 }, - { 0x2C, 0x8F, 0x02 } -}; - -struct adie_codec_state { - struct adie_codec_path path[ADIE_CODEC_MAX]; - u32 ref_cnt; - struct marimba *pdrv_ptr; - struct marimba_codec_platform_data *codec_pdata; - struct mutex lock; -}; - -static struct adie_codec_state adie_codec; - -/* Array containing write details of Tx and RX Digital Volume - Tx and Rx and both the left and right channel use the same data -*/ -u8 adie_codec_rx_tx_dig_vol_data[] = { - 0x81, 0x82, 0x83, 0x84, - 0x85, 0x86, 0x87, 0x88, - 0x89, 0x8a, 0x8b, 0x8c, - 0x8d, 0x8e, 0x8f, 0x90, - 0x91, 0x92, 0x93, 0x94, - 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0x9b, 0x9c, - 0x9d, 0x9e, 0x9f, 0xa0, - 0xa1, 0xa2, 0xa3, 0xa4, - 0xa5, 0xa6, 0xa7, 0xa8, - 0xa9, 0xaa, 0xab, 0xac, - 0xad, 0xae, 0xaf, 0xb0, - 0xb1, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, - 0xb9, 0xba, 0xbb, 0xbc, - 0xbd, 0xbe, 0xbf, 0xc0, - 0xc1, 0xc2, 0xc3, 0xc4, - 0xc5, 0xc6, 0xc7, 0xc8, - 0xc9, 0xca, 0xcb, 0xcc, - 0xcd, 0xce, 0xcf, 0xd0, - 0xd1, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, - 0xd9, 0xda, 0xdb, 0xdc, - 0xdd, 0xde, 0xdf, 0xe0, - 0xe1, 0xe2, 0xe3, 0xe4, - 0xe5, 0xe6, 0xe7, 0xe8, - 0xe9, 0xea, 0xeb, 0xec, - 0xed, 0xee, 0xf0, 0xf1, - 0xf2, 0xf3, 0xf4, 0xf5, - 0xf6, 0xf7, 0xf8, 0xf9, - 0xfa, 0xfb, 0xfc, 0xfd, - 0xfe, 0xff, 0x00, 0x01, - 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, - 0x0a, 0x0b, 0x0c, 0x0d, - 0x0e, 0x0f, 0x10, 0x11, - 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0x19, - 0x1a, 0x1b, 0x1c, 0x1d, - 0x1e, 0x1f, 0x20, 0x21, - 0x22, 0x23, 0x24, 0x25, - 0x26, 0x27, 0x28, 0x29, - 0x2a, 0x2b, 0x2c, 0x2d, - 0x2e, 0x2f, 0x30, 0x31, - 0x32, 0x33, 0x34, 0x35, - 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x3b, 0x3c, 0x3d, - 0x3e, 0x3f, 0x40, 0x41, - 0x42, 0x43, 0x44, 0x45, - 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x4b, 0x4c, 0x4d, - 0x4e, 0x4f, 0x50, 0x51, - 0x52, 0x53, 0x54, 0x55, - 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x5b, 0x5c, 0x5d, - 0x5e, 0x5f, 0x60, 0x61, - 0x62, 0x63, 0x64, 0x65, - 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x6b, 0x6c, 0x6d, - 0x6e, 0x6f, 0x70, 0x71, - 0x72, 0x73, 0x74, 0x75, - 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x7b, 0x7c, 0x7d, - 0x7e, 0x7f -}; - -enum adie_vol_type { - ADIE_CODEC_RX_DIG_VOL, - ADIE_CODEC_TX_DIG_VOL, - ADIE_CODEC_VOL_TYPE_MAX -}; - -struct adie_codec_ch_vol_cntrl { - u8 codec_reg; - u8 codec_mask; - u8 *vol_cntrl_data; -}; - -struct adie_codec_vol_cntrl_data { - - enum adie_vol_type vol_type; - - /* Jump length used while doing writes in incremental fashion */ - u32 jump_length; - s32 min_mb; /* Min Db applicable to the vol control */ - s32 max_mb; /* Max Db applicable to the vol control */ - u32 step_in_mb; - u32 steps; /* No of steps allowed for this vol type */ - - struct adie_codec_ch_vol_cntrl *ch_vol_cntrl_info; -}; - -static struct adie_codec_ch_vol_cntrl adie_codec_rx_vol_cntrl[] = { - {MARIMBA_CODEC_CDC_LRXG, 0xff, adie_codec_rx_tx_dig_vol_data}, - {MARIMBA_CODEC_CDC_RRXG, 0xff, adie_codec_rx_tx_dig_vol_data} -}; - -static struct adie_codec_ch_vol_cntrl adie_codec_tx_vol_cntrl[] = { - {MARIMBA_CODEC_CDC_LTXG, 0xff, adie_codec_rx_tx_dig_vol_data}, - {MARIMBA_CODEC_CDC_RTXG, 0xff, adie_codec_rx_tx_dig_vol_data} -}; - -static struct adie_codec_vol_cntrl_data adie_codec_vol_cntrl[] = { - {ADIE_CODEC_RX_DIG_VOL, 5100, -12700, 12700, 100, 255, - adie_codec_rx_vol_cntrl}, - - {ADIE_CODEC_TX_DIG_VOL, 5100, -12700, 12700, 100, 255, - adie_codec_tx_vol_cntrl} -}; - -static int adie_codec_write(u8 reg, u8 mask, u8 val) -{ - int rc; - - rc = marimba_write_bit_mask(adie_codec.pdrv_ptr, reg, &val, 1, mask); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: fail to write reg %x\n", __func__, reg); - return -EIO; - } - - pr_debug("%s: write reg %x val %x\n", __func__, reg, val); - - return 0; -} - -static int adie_codec_read(u8 reg, u8 *val) -{ - return marimba_read(adie_codec.pdrv_ptr, reg, val, 1); -} - -static int adie_codec_read_dig_vol(enum adie_vol_type vol_type, u32 chan_index, - u32 *cur_index) -{ - u32 counter; - u32 size; - u8 reg, mask, cur_val; - int rc; - - reg = - adie_codec_vol_cntrl[vol_type]. - ch_vol_cntrl_info[chan_index].codec_reg; - - mask = - adie_codec_vol_cntrl[vol_type]. - ch_vol_cntrl_info[chan_index].codec_mask; - - rc = marimba_read(adie_codec.pdrv_ptr, reg, &cur_val, 1); - - if (IS_ERR_VALUE(rc)) { - pr_err("%s: fail to read reg %x\n", __func__, reg); - return -EIO; - } - - cur_val = cur_val & mask; - - pr_debug("%s: reg 0x%x mask 0x%x reg_value = 0x%x" - "vol_type = %d\n", __func__, reg, mask, cur_val, vol_type); - - size = adie_codec_vol_cntrl[vol_type].steps; - - for (counter = 0; counter <= size; counter++) { - - if (adie_codec_vol_cntrl[vol_type].ch_vol_cntrl_info - [chan_index].vol_cntrl_data[counter] == cur_val) { - *cur_index = counter; - return 0; - } - } - - pr_err("%s: could not find 0x%x in reg 0x%x values array\n", - __func__, cur_val, reg); - - return -EINVAL;; -} - -static int adie_codec_set_dig_vol(enum adie_vol_type vol_type, u32 chan_index, - u32 cur_index, u32 target_index) -{ - u32 count; - u8 reg, mask, val; - u32 i; - u32 index; - u32 index_jump; - - int rc; - - index_jump = adie_codec_vol_cntrl[vol_type].jump_length; - - reg = - adie_codec_vol_cntrl[vol_type]. - ch_vol_cntrl_info[chan_index].codec_reg; - - mask = - adie_codec_vol_cntrl[vol_type]. - ch_vol_cntrl_info[chan_index].codec_mask; - - /* compare the target index with current index */ - if (cur_index < target_index) { - - /* Volume is being increased loop and increase it in 4-5 steps - */ - count = ((target_index - cur_index) * 100 / index_jump); - index = cur_index; - - for (i = 1; i <= count; i++) { - index = index + (int)(index_jump / 100); - - val = - adie_codec_vol_cntrl[vol_type].ch_vol_cntrl_info - [chan_index].vol_cntrl_data[index]; - - pr_debug("%s: write reg %x val 0x%x\n", - __func__, reg, val); - - rc = adie_codec_write(reg, mask, val); - if (rc < 0) { - pr_err("%s: write reg %x val 0x%x failed\n", - __func__, reg, val); - return rc; - } - } - - /*do one final write to take it to the target index level */ - val = - adie_codec_vol_cntrl[vol_type].ch_vol_cntrl_info - [chan_index].vol_cntrl_data[target_index]; - - pr_debug("%s: write reg %x val 0x%x\n", __func__, reg, val); - - rc = adie_codec_write(reg, mask, val); - - if (rc < 0) { - pr_err("%s: write reg %x val 0x%x failed\n", - __func__, reg, val); - return rc; - } - - } else { - - /* Volume is being decreased from the current setting */ - index = cur_index; - /* loop and decrease it in 4-5 steps */ - count = ((cur_index - target_index) * 100 / index_jump); - - for (i = 1; i <= count; i++) { - index = index - (int)(index_jump / 100); - - val = - adie_codec_vol_cntrl[vol_type].ch_vol_cntrl_info - [chan_index].vol_cntrl_data[index]; - - pr_debug("%s: write reg %x val 0x%x\n", - __func__, reg, val); - - rc = adie_codec_write(reg, mask, val); - if (rc < 0) { - pr_err("%s: write reg %x val 0x%x failed\n", - __func__, reg, val); - return rc; - } - } - - /* do one final write to take it to the target index level */ - val = - adie_codec_vol_cntrl[vol_type].ch_vol_cntrl_info - [chan_index].vol_cntrl_data[target_index]; - - pr_debug("%s: write reg %x val 0x%x\n", __func__, reg, val); - - rc = adie_codec_write(reg, mask, val); - - if (rc < 0) { - pr_err("%s: write reg %x val 0x%x failed\n", - __func__, reg, val); - return rc; - } - } - return 0; -} - -static int marimba_adie_codec_set_device_digital_volume( - struct adie_codec_path *path_ptr, - u32 num_channels, u32 vol_percentage /* in percentage */) -{ - enum adie_vol_type vol_type; - s32 milli_bel; - u32 chan_index; - u32 step_index; - u32 cur_step_index = 0; - - if (!path_ptr || (path_ptr->curr_stage != - ADIE_CODEC_DIGITAL_ANALOG_READY)) { - pr_info("%s: Marimba codec not ready for volume control\n", - __func__); - return -EPERM; - } - - if (num_channels > 2) { - pr_err("%s: Marimba codec only supports max two channels\n", - __func__); - return -EINVAL; - } - - if (path_ptr->profile->path_type == ADIE_CODEC_RX) - vol_type = ADIE_CODEC_RX_DIG_VOL; - else if (path_ptr->profile->path_type == ADIE_CODEC_TX) - vol_type = ADIE_CODEC_TX_DIG_VOL; - else { - pr_err("%s: invalid device data neither RX nor TX\n", - __func__); - return -EINVAL; - } - - milli_bel = ((adie_codec_vol_cntrl[vol_type].max_mb - - adie_codec_vol_cntrl[vol_type].min_mb) * - vol_percentage) / 100; - - milli_bel = adie_codec_vol_cntrl[vol_type].min_mb + milli_bel; - - pr_debug("%s: milli bell = %d vol_type = %d vol_percentage = %d" - " num_cha = %d \n", - __func__, milli_bel, vol_type, vol_percentage, num_channels); - - - step_index = ((milli_bel - - adie_codec_vol_cntrl[vol_type].min_mb - + (adie_codec_vol_cntrl[vol_type].step_in_mb / 2)) - / adie_codec_vol_cntrl[vol_type].step_in_mb); - - - for (chan_index = 0; chan_index < num_channels; chan_index++) { - adie_codec_read_dig_vol(vol_type, chan_index, &cur_step_index); - - pr_debug("%s: cur_step_index = %u current vol = 0x%x\n", - __func__, cur_step_index, - adie_codec_vol_cntrl[vol_type].ch_vol_cntrl_info - [chan_index].vol_cntrl_data[cur_step_index]); - - pr_debug("%s: step index = %u new volume = 0x%x\n", - __func__, step_index, - adie_codec_vol_cntrl[vol_type].ch_vol_cntrl_info - [chan_index].vol_cntrl_data[step_index]); - - adie_codec_set_dig_vol(vol_type, chan_index, cur_step_index, - step_index); - - } - return 0; -} - -static int marimba_adie_codec_setpath(struct adie_codec_path *path_ptr, - u32 freq_plan, u32 osr) -{ - int rc = 0; - u32 i, freq_idx = 0, freq = 0; - - if ((path_ptr->curr_stage != ADIE_CODEC_DIGITAL_OFF) && - (path_ptr->curr_stage != ADIE_CODEC_FLASH_IMAGE)) { - rc = -EBUSY; - goto error; - } - - for (i = 0; i < path_ptr->profile->setting_sz; i++) { - if (path_ptr->profile->settings[i].osr == osr) { - if (path_ptr->profile->settings[i].freq_plan >= - freq_plan) { - if (freq == 0) { - freq = path_ptr->profile->settings[i]. - freq_plan; - freq_idx = i; - } else if (path_ptr->profile->settings[i]. - freq_plan < freq) { - freq = path_ptr->profile->settings[i]. - freq_plan; - freq_idx = i; - } - } - } - } - - if (freq_idx >= path_ptr->profile->setting_sz) - rc = -ENODEV; - else { - path_ptr->hwsetting_idx = freq_idx; - path_ptr->stage_idx = 0; - } - -error: - return rc; -} - -static u32 marimba_adie_codec_freq_supported( - struct adie_codec_dev_profile *profile, - u32 requested_freq) -{ - u32 i, rc = -EINVAL; - - for (i = 0; i < profile->setting_sz; i++) { - if (profile->settings[i].freq_plan >= requested_freq) { - rc = 0; - break; - } - } - return rc; -} - -static int marimba_adie_codec_enable_sidetone( - struct adie_codec_path *rx_path_ptr, - u32 enable) -{ - int rc = 0; - - pr_debug("%s()\n", __func__); - - mutex_lock(&adie_codec.lock); - - if (!rx_path_ptr || &adie_codec.path[ADIE_CODEC_RX] != rx_path_ptr) { - pr_err("%s: invalid path pointer\n", __func__); - rc = -EINVAL; - goto error; - } else if (rx_path_ptr->curr_stage != - ADIE_CODEC_DIGITAL_ANALOG_READY) { - pr_err("%s: bad state\n", __func__); - rc = -EPERM; - goto error; - } - - if (enable) - rc = adie_codec_write(MARIMBA_CDC_RX_CTL, - MARIMBA_CDC_RX_CTL_ST_EN_MASK, - (0x1 << MARIMBA_CDC_RX_CTL_ST_EN_SHFT)); - else - rc = adie_codec_write(MARIMBA_CDC_RX_CTL, - MARIMBA_CDC_RX_CTL_ST_EN_MASK, 0); - -error: - mutex_unlock(&adie_codec.lock); - return rc; -} - -static void adie_codec_reach_stage_action(struct adie_codec_path *path_ptr, - u32 stage) -{ - u32 iter; - struct adie_codec_register *reg_info; - - if (stage == ADIE_CODEC_FLASH_IMAGE) { - /* perform reimage */ - for (iter = 0; iter < path_ptr->img.img_sz; iter++) { - reg_info = &path_ptr->img.regs[iter]; - adie_codec_write(reg_info->reg, - reg_info->mask, reg_info->val); - } - } -} - -static int marimba_adie_codec_proceed_stage(struct adie_codec_path *path_ptr, - u32 state) -{ - int rc = 0, loop_exit = 0; - struct adie_codec_action_unit *curr_action; - struct adie_codec_hwsetting_entry *setting; - u8 reg, mask, val; - - mutex_lock(&adie_codec.lock); - setting = &path_ptr->profile->settings[path_ptr->hwsetting_idx]; - while (!loop_exit) { - curr_action = &setting->actions[path_ptr->stage_idx]; - switch (curr_action->type) { - case ADIE_CODEC_ACTION_ENTRY: - ADIE_CODEC_UNPACK_ENTRY(curr_action->action, - reg, mask, val); - adie_codec_write(reg, mask, val); - break; - case ADIE_CODEC_ACTION_DELAY_WAIT: - if (curr_action->action > MAX_MDELAY_US) - msleep(curr_action->action/1000); - else if (curr_action->action < MIN_MDELAY_US) - udelay(curr_action->action); - else - mdelay(curr_action->action/1000); - break; - case ADIE_CODEC_ACTION_STAGE_REACHED: - adie_codec_reach_stage_action(path_ptr, - curr_action->action); - if (curr_action->action == state) { - path_ptr->curr_stage = state; - loop_exit = 1; - } - break; - default: - BUG(); - } - - path_ptr->stage_idx++; - if (path_ptr->stage_idx == setting->action_sz) - path_ptr->stage_idx = 0; - } - mutex_unlock(&adie_codec.lock); - return rc; -} - -static void marimba_codec_bring_up(void) -{ - /* bring up sequence for Marimba codec core - * ensure RESET_N = 0 and GDFS_CLAMP_EN=1 - - * set GDFS_EN_FEW=1 then GDFS_EN_REST=1 then - * GDFS_CLAMP_EN = 0 and finally RESET_N = 1 - * Marimba codec bring up should use the Marimba - * slave address after which the codec slave - * address can be used - */ - - /* Bring up codec */ - adie_codec_write(0xFF, 0xFF, 0x08); - - /* set GDFS_EN_FEW=1 */ - adie_codec_write(0xFF, 0xFF, 0x0a); - - /* set GDFS_EN_REST=1 */ - adie_codec_write(0xFF, 0xFF, 0x0e); - - /* set RESET_N=1 */ - adie_codec_write(0xFF, 0xFF, 0x07); - - adie_codec_write(0xFF, 0xFF, 0x17); - - /* enable band gap */ - adie_codec_write(0x03, 0xFF, 0x04); - - /* dither delay selected and dmic gain stage bypassed */ - adie_codec_write(0x8F, 0xFF, 0x44); -} - -static void marimba_codec_bring_down(void) -{ - adie_codec_write(0xFF, 0xFF, 0x07); - adie_codec_write(0xFF, 0xFF, 0x06); - adie_codec_write(0xFF, 0xFF, 0x0e); - adie_codec_write(0xFF, 0xFF, 0x08); - adie_codec_write(0x03, 0xFF, 0x00); -} - -static int marimba_adie_codec_open(struct adie_codec_dev_profile *profile, - struct adie_codec_path **path_pptr) -{ - int rc = 0; - - mutex_lock(&adie_codec.lock); - - if (!profile || !path_pptr) { - rc = -EINVAL; - goto error; - } - - if (adie_codec.path[profile->path_type].profile) { - rc = -EBUSY; - goto error; - } - - if (!adie_codec.ref_cnt) { - - if (adie_codec.codec_pdata && - adie_codec.codec_pdata->marimba_codec_power) { - - rc = adie_codec.codec_pdata->marimba_codec_power(1); - if (rc) { - pr_err("%s: could not power up marimba " - "codec\n", __func__); - goto error; - } - } - marimba_codec_bring_up(); - } - - adie_codec.path[profile->path_type].profile = profile; - *path_pptr = (void *) &adie_codec.path[profile->path_type]; - adie_codec.ref_cnt++; - adie_codec.path[profile->path_type].hwsetting_idx = 0; - adie_codec.path[profile->path_type].curr_stage = ADIE_CODEC_FLASH_IMAGE; - adie_codec.path[profile->path_type].stage_idx = 0; - - -error: - - mutex_unlock(&adie_codec.lock); - return rc; -} - -static int marimba_adie_codec_close(struct adie_codec_path *path_ptr) -{ - int rc = 0; - - mutex_lock(&adie_codec.lock); - - if (!path_ptr) { - rc = -EINVAL; - goto error; - } - if (path_ptr->curr_stage != ADIE_CODEC_DIGITAL_OFF) - adie_codec_proceed_stage(path_ptr, ADIE_CODEC_DIGITAL_OFF); - - BUG_ON(!adie_codec.ref_cnt); - - path_ptr->profile = NULL; - adie_codec.ref_cnt--; - - if (!adie_codec.ref_cnt) { - - marimba_codec_bring_down(); - - if (adie_codec.codec_pdata && - adie_codec.codec_pdata->marimba_codec_power) { - - rc = adie_codec.codec_pdata->marimba_codec_power(0); - if (rc) { - pr_err("%s: could not power down marimba " - "codec\n", __func__); - goto error; - } - } - } - -error: - mutex_unlock(&adie_codec.lock); - return rc; -} - -static const struct adie_codec_operations marimba_adie_ops = { - .codec_id = MARIMBA_ID, - .codec_open = marimba_adie_codec_open, - .codec_close = marimba_adie_codec_close, - .codec_setpath = marimba_adie_codec_setpath, - .codec_proceed_stage = marimba_adie_codec_proceed_stage, - .codec_freq_supported = marimba_adie_codec_freq_supported, - .codec_enable_sidetone = marimba_adie_codec_enable_sidetone, - .codec_set_device_digital_volume = - marimba_adie_codec_set_device_digital_volume, -}; - -#ifdef CONFIG_DEBUG_FS -static struct dentry *debugfs_marimba_dent; -static struct dentry *debugfs_peek; -static struct dentry *debugfs_poke; -static struct dentry *debugfs_power; - -static unsigned char read_data; - -static int codec_debug_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static int get_parameters(char *buf, long int *param1, int num_of_par) -{ - char *token; - int base, cnt; - - token = strsep(&buf, " "); - - for (cnt = 0; cnt < num_of_par; cnt++) { - if (token != NULL) { - if ((token[1] == 'x') || (token[1] == 'X')) - base = 16; - else - base = 10; - - if (strict_strtoul(token, base, ¶m1[cnt]) != 0) - return -EINVAL; - - token = strsep(&buf, " "); - } - else - return -EINVAL; - } - return 0; -} - -static ssize_t codec_debug_read(struct file *file, char __user *ubuf, - size_t count, loff_t *ppos) -{ - char lbuf[8]; - - snprintf(lbuf, sizeof(lbuf), "0x%x\n", read_data); - return simple_read_from_buffer(ubuf, count, ppos, lbuf, strlen(lbuf)); -} - -static ssize_t codec_debug_write(struct file *filp, - const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char *access_str = filp->private_data; - char lbuf[32]; - int rc; - long int param[5]; - - if (cnt > sizeof(lbuf) - 1) - return -EINVAL; - - rc = copy_from_user(lbuf, ubuf, cnt); - if (rc) - return -EFAULT; - - lbuf[cnt] = '\0'; - - if (!strcmp(access_str, "power")) { - if (get_parameters(lbuf, param, 1) == 0) { - switch (param[0]) { - case 1: - adie_codec.codec_pdata->marimba_codec_power(1); - marimba_codec_bring_up(); - break; - case 0: - marimba_codec_bring_down(); - adie_codec.codec_pdata->marimba_codec_power(0); - break; - default: - rc = -EINVAL; - break; - } - } else - rc = -EINVAL; - } else if (!strcmp(access_str, "poke")) { - /* write */ - rc = get_parameters(lbuf, param, 2); - if ((param[0] <= 0xFF) && (param[1] <= 0xFF) && - (rc == 0)) - adie_codec_write(param[0], 0xFF, param[1]); - else - rc = -EINVAL; - } else if (!strcmp(access_str, "peek")) { - /* read */ - rc = get_parameters(lbuf, param, 1); - if ((param[0] <= 0xFF) && (rc == 0)) - adie_codec_read(param[0], &read_data); - else - rc = -EINVAL; - } - - if (rc == 0) - rc = cnt; - else - pr_err("%s: rc = %d\n", __func__, rc); - - return rc; -} - -static const struct file_operations codec_debug_ops = { - .open = codec_debug_open, - .write = codec_debug_write, - .read = codec_debug_read -}; -#endif - -static int marimba_codec_probe(struct platform_device *pdev) -{ - int rc; - - adie_codec.pdrv_ptr = platform_get_drvdata(pdev); - adie_codec.codec_pdata = pdev->dev.platform_data; - - if (adie_codec.codec_pdata->snddev_profile_init) - adie_codec.codec_pdata->snddev_profile_init(); - - /* Register the marimba ADIE operations */ - rc = adie_codec_register_codec_operations(&marimba_adie_ops); - -#ifdef CONFIG_DEBUG_FS - debugfs_marimba_dent = debugfs_create_dir("msm_adie_codec", 0); - if (!IS_ERR(debugfs_marimba_dent)) { - debugfs_peek = debugfs_create_file("peek", - S_IFREG | S_IRUGO, debugfs_marimba_dent, - (void *) "peek", &codec_debug_ops); - - debugfs_poke = debugfs_create_file("poke", - S_IFREG | S_IRUGO, debugfs_marimba_dent, - (void *) "poke", &codec_debug_ops); - - debugfs_power = debugfs_create_file("power", - S_IFREG | S_IRUGO, debugfs_marimba_dent, - (void *) "power", &codec_debug_ops); - } -#endif - return rc; -} - -static struct platform_driver marimba_codec_driver = { - .probe = marimba_codec_probe, - .driver = { - .name = "marimba_codec", - .owner = THIS_MODULE, - }, -}; - -static int __init marimba_codec_init(void) -{ - s32 rc; - - rc = platform_driver_register(&marimba_codec_driver); - if (IS_ERR_VALUE(rc)) - goto error; - - adie_codec.path[ADIE_CODEC_TX].img.regs = adie_codec_tx_regs; - adie_codec.path[ADIE_CODEC_TX].img.img_sz = - ARRAY_SIZE(adie_codec_tx_regs); - adie_codec.path[ADIE_CODEC_RX].img.regs = adie_codec_rx_regs; - adie_codec.path[ADIE_CODEC_RX].img.img_sz = - ARRAY_SIZE(adie_codec_rx_regs); - adie_codec.path[ADIE_CODEC_LB].img.regs = adie_codec_lb_regs; - adie_codec.path[ADIE_CODEC_LB].img.img_sz = - ARRAY_SIZE(adie_codec_lb_regs); - mutex_init(&adie_codec.lock); - -error: - return rc; -} - -static void __exit marimba_codec_exit(void) -{ -#ifdef CONFIG_DEBUG_FS - debugfs_remove(debugfs_peek); - debugfs_remove(debugfs_poke); - debugfs_remove(debugfs_power); - debugfs_remove(debugfs_marimba_dent); -#endif - platform_driver_unregister(&marimba_codec_driver); -} - -module_init(marimba_codec_init); -module_exit(marimba_codec_exit); - -MODULE_DESCRIPTION("Marimba codec driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/mfd/marimba-core.c b/drivers/mfd/marimba-core.c deleted file mode 100644 index 3c9e634ddc0eeb861ea5e32fa5eb5bd57acbdced..0000000000000000000000000000000000000000 --- a/drivers/mfd/marimba-core.c +++ /dev/null @@ -1,941 +0,0 @@ -/* Copyright (c) 2009-2012, 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. - * - */ -/* - * Qualcomm Marimba Core Driver - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#define MARIMBA_MODE 0x00 - -#define ADIE_ARRY_SIZE (CHIP_ID_MAX * MARIMBA_NUM_CHILD) - -static int marimba_shadow[ADIE_ARRY_SIZE][0xff]; -static int mutex_initialized; -struct marimba marimba_modules[ADIE_ARRY_SIZE]; - -#define MARIMBA_VERSION_REG 0x11 -#define MARIMBA_MODE_REG 0x00 - -struct marimba_platform_data *marimba_pdata; - -static uint32_t marimba_gpio_count; -static bool fm_status; -static bool bt_status; - -#ifdef CONFIG_I2C_SSBI -#define NUM_ADD MARIMBA_NUM_CHILD -#else -#define NUM_ADD (MARIMBA_NUM_CHILD - 1) -#endif - -#if defined(CONFIG_DEBUG_FS) -struct adie_dbg_device { - struct mutex dbg_mutex; - struct dentry *dent; - int addr; - int mod_id; -}; - -static struct adie_dbg_device *marimba_dbg_device; -static struct adie_dbg_device *timpani_dbg_device; -static struct adie_dbg_device *bahama_dbg_device; -#endif - - -/** - * marimba_read_bahama_ver - Reads Bahama version. - * @param marimba: marimba structure pointer passed by client - * @returns result of the operation. - */ -int marimba_read_bahama_ver(struct marimba *marimba) -{ - int rc; - u8 bahama_version; - - rc = marimba_read_bit_mask(marimba, 0x00, &bahama_version, 1, 0x1F); - if (rc < 0) - return rc; - pr_debug("%s: Bahama version: 0x%x\n", __func__, bahama_version); - switch (bahama_version) { - case 0x08: /* varient of bahama v1 */ - case 0x10: - case 0x00: - return BAHAMA_VER_1_0; - case 0x09: /* variant of bahama v2 */ - case 0x0a: /* variant of bahama v2.1 */ - /* Falling through because initialization */ - /* and configuration for 2.0 and 2.1 are same */ - return BAHAMA_VER_2_0; - default: - return BAHAMA_VER_UNSUPPORTED; - } -} -EXPORT_SYMBOL(marimba_read_bahama_ver); -/** - * marimba_ssbi_write - Writes a n bit TSADC register in Marimba - * @param marimba: marimba structure pointer passed by client - * @param reg: register address - * @param value: buffer to be written - * @param len: num of bytes - * @returns result of the operation. - */ -int marimba_ssbi_write(struct marimba *marimba, u16 reg , u8 *value, int len) -{ - struct i2c_msg *msg; - int ret; - - marimba = &marimba_modules[marimba->mod_id]; - - mutex_lock(&marimba->xfer_lock); - - msg = &marimba->xfer_msg[0]; - msg->addr = reg; - msg->flags = 0x0; - msg->buf = value; - msg->len = len; - - ret = i2c_transfer(marimba->client->adapter, marimba->xfer_msg, 1); - - mutex_unlock(&marimba->xfer_lock); - - return ret; -} -EXPORT_SYMBOL(marimba_ssbi_write); - -/** - * marimba_ssbi_read - Reads a n bit TSADC register in Marimba - * @param marimba: marimba structure pointer passed by client - * @param reg: register address - * @param value: ssbi read of the register to be stored - * @param len: num of bytes - * - * @returns result of the operation. -*/ -int marimba_ssbi_read(struct marimba *marimba, u16 reg, u8 *value, int len) -{ - struct i2c_msg *msg; - int ret; - - marimba = &marimba_modules[marimba->mod_id]; - - mutex_lock(&marimba->xfer_lock); - - msg = &marimba->xfer_msg[0]; - msg->addr = reg; - msg->flags = I2C_M_RD; - msg->buf = value; - msg->len = len; - - ret = i2c_transfer(marimba->client->adapter, marimba->xfer_msg, 1); - - mutex_unlock(&marimba->xfer_lock); - - return ret; -} -EXPORT_SYMBOL(marimba_ssbi_read); - -/** - * marimba_write_bit_mask - Sets n bit register using bit mask - * @param marimba: marimba structure pointer passed by client - * @param reg: register address - * @param value: buffer to be written to the registers - * @param num_bytes: n bytes to write - * @param mask: bit mask corresponding to the registers - * - * @returns result of the operation. - */ -int marimba_write_bit_mask(struct marimba *marimba, u8 reg, u8 *value, - unsigned num_bytes, u8 mask) -{ - int ret, i; - struct i2c_msg *msg; - u8 data[num_bytes + 1]; - u8 mask_value[num_bytes]; - - memset(mask_value, 0, sizeof(mask_value)); - - marimba = &marimba_modules[marimba->mod_id]; - if (marimba == NULL) { - pr_err("%s: Unable to access Marimba core\n", __func__); - return -ENODEV; - } - - mutex_lock(&marimba->xfer_lock); - - for (i = 0; i < num_bytes; i++) - mask_value[i] = (marimba_shadow[marimba->mod_id][reg + i] - & ~mask) | (value[i] & mask); - - msg = &marimba->xfer_msg[0]; - if (marimba->client == NULL) { - pr_err("%s: Unable to access the Marimba slave device.\n", - __func__); - return -ENODEV; - } - - msg->addr = marimba->client->addr; - msg->flags = 0; - msg->len = num_bytes + 1; - msg->buf = data; - data[0] = reg; - memcpy(data+1, mask_value, num_bytes); - - ret = i2c_transfer(marimba->client->adapter, marimba->xfer_msg, 1); - - /* Try again if the write fails */ - if (ret != 1) - ret = i2c_transfer(marimba->client->adapter, - marimba->xfer_msg, 1); - - if (ret == 1) { - for (i = 0; i < num_bytes; i++) - marimba_shadow[marimba->mod_id][reg + i] - = mask_value[i]; - } else { - dev_err(&marimba->client->dev, "i2c write failed\n"); - ret = -ENODEV; - } - - mutex_unlock(&marimba->xfer_lock); - - return ret; -} -EXPORT_SYMBOL(marimba_write_bit_mask); - -/** - * marimba_write - Sets n bit register in Marimba - * @param marimba: marimba structure pointer passed by client - * @param reg: register address - * @param value: buffer values to be written - * @param num_bytes: n bytes to write - * - * @returns result of the operation. - */ -int marimba_write(struct marimba *marimba, u8 reg, u8 *value, - unsigned num_bytes) -{ - return marimba_write_bit_mask(marimba, reg, value, num_bytes, 0xff); -} -EXPORT_SYMBOL(marimba_write); - -/** - * marimba_read_bit_mask - Reads a n bit register based on bit mask - * @param marimba: marimba structure pointer passed by client - * @param reg: register address - * @param value: i2c read of the register to be stored - * @param num_bytes: n bytes to be read. - * @param mask: bit mask concerning its register - * - * @returns result of the operation. -*/ -int marimba_read_bit_mask(struct marimba *marimba, u8 reg, u8 *value, - unsigned num_bytes, u8 mask) -{ - int ret, i; - - struct i2c_msg *msg; - - marimba = &marimba_modules[marimba->mod_id]; - - mutex_lock(&marimba->xfer_lock); - - msg = &marimba->xfer_msg[0]; - msg->addr = marimba->client->addr; - msg->len = 1; - msg->flags = 0; - msg->buf = ® - - msg = &marimba->xfer_msg[1]; - msg->addr = marimba->client->addr; - msg->len = num_bytes; - msg->flags = I2C_M_RD; - msg->buf = value; - - ret = i2c_transfer(marimba->client->adapter, marimba->xfer_msg, 2); - - /* Try again if read fails first time */ - if (ret != 2) - ret = i2c_transfer(marimba->client->adapter, - marimba->xfer_msg, 2); - - if (ret == 2) { - for (i = 0; i < num_bytes; i++) { - marimba_shadow[marimba->mod_id][reg + i] = value[i]; - value[i] &= mask; - } - } else { - dev_err(&marimba->client->dev, "i2c read failed\n"); - ret = -ENODEV; - } - - mutex_unlock(&marimba->xfer_lock); - - return ret; -} -EXPORT_SYMBOL(marimba_read_bit_mask); - -/** - * marimba_read - Reads n bit registers in Marimba - * @param marimba: marimba structure pointer passed by client - * @param reg: register address - * @param value: i2c read of the register to be stored - * @param num_bytes: n bytes to read. - * @param mask: bit mask concerning its register - * - * @returns result of the operation. -*/ -int marimba_read(struct marimba *marimba, u8 reg, u8 *value, unsigned num_bytes) -{ - return marimba_read_bit_mask(marimba, reg, value, num_bytes, 0xff); -} -EXPORT_SYMBOL(marimba_read); - -int timpani_read(struct marimba *marimba, u8 reg, u8 *value, unsigned num_bytes) -{ - return marimba_read_bit_mask(marimba, reg, value, num_bytes, 0xff); -} -EXPORT_SYMBOL(timpani_read); - -int timpani_write(struct marimba *marimba, u8 reg, - u8 *value, unsigned num_bytes) -{ - return marimba_write_bit_mask(marimba, reg, value, num_bytes, 0xff); -} -EXPORT_SYMBOL(timpani_write); - -static int cur_codec_type = -1, cur_adie_type = -1, cur_connv_type = -1; -static int adie_arry_idx; - -int adie_get_detected_codec_type(void) -{ - return cur_codec_type; -} -EXPORT_SYMBOL(adie_get_detected_codec_type); - -int adie_get_detected_connectivity_type(void) -{ - return cur_connv_type; -} -EXPORT_SYMBOL(adie_get_detected_connectivity_type); - -static struct device * -add_numbered_child(unsigned chip, const char *name, int num, u8 driver_data, - void *pdata, unsigned pdata_len) -{ - struct platform_device *pdev; - struct marimba *marimba = &marimba_modules[chip + adie_arry_idx]; - int status = 0; - - pdev = platform_device_alloc(name, num); - if (!pdev) { - status = -ENOMEM; - return ERR_PTR(status); - } - - pdev->dev.parent = &marimba->client->dev; - - marimba->mod_id = chip + adie_arry_idx; - - platform_set_drvdata(pdev, marimba); - - if (pdata) { - status = platform_device_add_data(pdev, pdata, pdata_len); - if (status < 0) - goto err; - } - - status = platform_device_add(pdev); - if (status < 0) - goto err; - -err: - if (status < 0) { - platform_set_drvdata(pdev, NULL); - platform_device_put(pdev); - dev_err(&marimba->client->dev, "can't add %s dev\n", name); - return ERR_PTR(status); - } - return &pdev->dev; -} - -static inline struct device *add_child(unsigned chip, const char *name, - u8 driver_data, void *pdata, unsigned pdata_len) -{ - return add_numbered_child(chip, name, -1, driver_data, pdata, - pdata_len); -} - -static int marimba_add_child(struct marimba_platform_data *pdata, - u8 driver_data) -{ - struct device *child; - - if (cur_adie_type == MARIMBA_ID) { - child = add_child(MARIMBA_SLAVE_ID_FM, "marimba_fm", - driver_data, pdata->fm, sizeof(*pdata->fm)); - if (IS_ERR(child)) - return PTR_ERR(child); - } else if ((cur_adie_type == BAHAMA_ID) && - (cur_connv_type == BAHAMA_ID)) { - child = add_child(BAHAMA_SLAVE_ID_FM_ID, "marimba_fm", - driver_data, pdata->fm, sizeof(*pdata->fm)); - if (IS_ERR(child)) - return PTR_ERR(child); - } - - /* Add Codec for Marimba and Timpani */ - if (cur_adie_type == MARIMBA_ID) { - child = add_child(MARIMBA_SLAVE_ID_CDC, "marimba_codec", - driver_data, pdata->codec, sizeof(*pdata->codec)); - if (IS_ERR(child)) - return PTR_ERR(child); - } else if (cur_adie_type == TIMPANI_ID) { - child = add_child(MARIMBA_SLAVE_ID_CDC, "timpani_codec", - driver_data, pdata->codec, sizeof(*pdata->codec)); - if (IS_ERR(child)) - return PTR_ERR(child); - } - -#if defined(CONFIG_I2C_SSBI) - if ((pdata->tsadc != NULL) && (cur_adie_type != BAHAMA_ID)) { - child = add_child(MARIMBA_ID_TSADC, "marimba_tsadc", - driver_data, pdata->tsadc, sizeof(*pdata->tsadc)); - if (IS_ERR(child)) - return PTR_ERR(child); - } -#endif - return 0; -} - -int marimba_gpio_config(int gpio_value) -{ - struct marimba *marimba = &marimba_modules[MARIMBA_SLAVE_ID_MARIMBA]; - struct marimba_platform_data *pdata = marimba_pdata; - int rc = 0; - - /* Clients BT/FM need to manage GPIO 34 on Fusion for its clocks */ - - mutex_lock(&marimba->xfer_lock); - - if (gpio_value) { - marimba_gpio_count++; - if (marimba_gpio_count == 1) - rc = pdata->marimba_gpio_config(1); - } else { - marimba_gpio_count--; - if (marimba_gpio_count == 0) - rc = pdata->marimba_gpio_config(0); - } - - mutex_unlock(&marimba->xfer_lock); - - return rc; - -} -EXPORT_SYMBOL(marimba_gpio_config); - -bool marimba_get_fm_status(struct marimba *marimba) -{ - bool ret; - - marimba = &marimba_modules[marimba->mod_id]; - - mutex_lock(&marimba->xfer_lock); - - ret = fm_status; - - mutex_unlock(&marimba->xfer_lock); - - return ret; -} -EXPORT_SYMBOL(marimba_get_fm_status); - -void marimba_set_fm_status(struct marimba *marimba, bool value) -{ - marimba = &marimba_modules[marimba->mod_id]; - - mutex_lock(&marimba->xfer_lock); - - fm_status = value; - - mutex_unlock(&marimba->xfer_lock); -} -EXPORT_SYMBOL(marimba_set_fm_status); - -bool marimba_get_bt_status(struct marimba *marimba) -{ - bool ret; - - marimba = &marimba_modules[marimba->mod_id]; - - mutex_lock(&marimba->xfer_lock); - - ret = bt_status; - - mutex_unlock(&marimba->xfer_lock); - - return ret; -} -EXPORT_SYMBOL(marimba_get_bt_status); - -void marimba_set_bt_status(struct marimba *marimba, bool value) -{ - marimba = &marimba_modules[marimba->mod_id]; - - mutex_lock(&marimba->xfer_lock); - - bt_status = value; - - mutex_unlock(&marimba->xfer_lock); -} -EXPORT_SYMBOL(marimba_set_bt_status); - -#if defined(CONFIG_DEBUG_FS) - -static int check_addr(int addr, const char *func_name) -{ - if (addr < 0 || addr > 0xFF) { - pr_err("%s: Marimba register address is invalid: %d\n", - func_name, addr); - return -EINVAL; - } - return 0; -} - -static int marimba_debugfs_set(void *data, u64 val) -{ - struct adie_dbg_device *dbgdev = data; - u8 reg = val; - int rc; - struct marimba marimba_id; - - mutex_lock(&dbgdev->dbg_mutex); - - rc = check_addr(dbgdev->addr, __func__); - if (rc) - goto done; - - marimba_id.mod_id = dbgdev->mod_id; - rc = marimba_write(&marimba_id, dbgdev->addr, ®, 1); - rc = (rc == 1) ? 0 : rc; - - if (rc) - pr_err("%s: FAIL marimba_write(0x%03X)=0x%02X: rc=%d\n", - __func__, dbgdev->addr, reg, rc); -done: - mutex_unlock(&dbgdev->dbg_mutex); - return rc; -} - -static int marimba_debugfs_get(void *data, u64 *val) -{ - struct adie_dbg_device *dbgdev = data; - int rc; - u8 reg; - struct marimba marimba_id; - - mutex_lock(&dbgdev->dbg_mutex); - - rc = check_addr(dbgdev->addr, __func__); - if (rc) - goto done; - - marimba_id.mod_id = dbgdev->mod_id; - rc = marimba_read(&marimba_id, dbgdev->addr, ®, 1); - rc = (rc == 2) ? 0 : rc; - - if (rc) { - pr_err("%s: FAIL marimba_read(0x%03X)=0x%02X: rc=%d\n", - __func__, dbgdev->addr, reg, rc); - goto done; - } - - *val = reg; -done: - mutex_unlock(&dbgdev->dbg_mutex); - return rc; -} - -DEFINE_SIMPLE_ATTRIBUTE(dbg_marimba_fops, marimba_debugfs_get, - marimba_debugfs_set, "0x%02llX\n"); - -static int addr_set(void *data, u64 val) -{ - struct adie_dbg_device *dbgdev = data; - int rc; - - rc = check_addr(val, __func__); - if (rc) - return rc; - - mutex_lock(&dbgdev->dbg_mutex); - dbgdev->addr = val; - mutex_unlock(&dbgdev->dbg_mutex); - - return 0; -} - -static int addr_get(void *data, u64 *val) -{ - struct adie_dbg_device *dbgdev = data; - int rc; - - mutex_lock(&dbgdev->dbg_mutex); - - rc = check_addr(dbgdev->addr, __func__); - if (rc) { - mutex_unlock(&dbgdev->dbg_mutex); - return rc; - } - *val = dbgdev->addr; - - mutex_unlock(&dbgdev->dbg_mutex); - - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(dbg_addr_fops, addr_get, addr_set, "0x%03llX\n"); - -static int marimba_dbg_init(int adie_type) -{ - struct adie_dbg_device *dbgdev; - struct dentry *dent = NULL; - struct dentry *temp; - - dbgdev = kzalloc(sizeof *dbgdev, GFP_KERNEL); - if (dbgdev == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - return -ENOMEM; - } - - mutex_init(&dbgdev->dbg_mutex); - dbgdev->addr = -1; - - if (adie_type == MARIMBA_ID) { - marimba_dbg_device = dbgdev; - marimba_dbg_device->mod_id = MARIMBA_SLAVE_ID_MARIMBA; - dent = debugfs_create_dir("marimba-dbg", NULL); - } else if (adie_type == TIMPANI_ID) { - timpani_dbg_device = dbgdev; - timpani_dbg_device->mod_id = MARIMBA_SLAVE_ID_MARIMBA; - dent = debugfs_create_dir("timpani-dbg", NULL); - } else if (adie_type == BAHAMA_ID) { - bahama_dbg_device = dbgdev; - bahama_dbg_device->mod_id = SLAVE_ID_BAHAMA; - dent = debugfs_create_dir("bahama-dbg", NULL); - } - if (dent == NULL || IS_ERR(dent)) { - pr_err("%s: ERR debugfs_create_dir: dent=0x%X\n", - __func__, (unsigned)dent); - kfree(dbgdev); - return -ENOMEM; - } - - temp = debugfs_create_file("addr", S_IRUSR | S_IWUSR, dent, - dbgdev, &dbg_addr_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("%s: ERR debugfs_create_file: dent=0x%X\n", - __func__, (unsigned)temp); - goto debug_error; - } - - temp = debugfs_create_file("data", S_IRUSR | S_IWUSR, dent, - dbgdev, &dbg_marimba_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("%s: ERR debugfs_create_file: dent=0x%X\n", - __func__, (unsigned)temp); - goto debug_error; - } - dbgdev->dent = dent; - - return 0; - -debug_error: - kfree(dbgdev); - debugfs_remove_recursive(dent); - return -ENOMEM; -} - -static int marimba_dbg_remove(void) -{ - if (marimba_dbg_device) { - debugfs_remove_recursive(marimba_dbg_device->dent); - kfree(marimba_dbg_device); - } - if (timpani_dbg_device) { - debugfs_remove_recursive(timpani_dbg_device->dent); - kfree(timpani_dbg_device); - } - if (bahama_dbg_device) { - debugfs_remove_recursive(bahama_dbg_device->dent); - kfree(bahama_dbg_device); - } - return 0; -} - -#else - -static int marimba_dbg_init(int adie_type) -{ - return 0; -} - -static int marimba_dbg_remove(void) -{ - return 0; -} - -#endif - -static int get_adie_type(void) -{ - u8 rd_val; - int ret; - - struct marimba *marimba = &marimba_modules[ADIE_ARRY_SIZE - 1]; - - marimba->mod_id = ADIE_ARRY_SIZE - 1; - /* Enable the Mode for Marimba/Timpani */ - ret = marimba_read(marimba, MARIMBA_MODE_REG, &rd_val, 1); - - if (ret >= 0) { - if (rd_val & 0x80) { - cur_adie_type = BAHAMA_ID; - return cur_adie_type; - } else { - ret = marimba_read(marimba, - MARIMBA_VERSION_REG, &rd_val, 1); - if ((ret >= 0) && (rd_val & 0x20)) { - cur_adie_type = TIMPANI_ID; - return cur_adie_type; - } else if (ret >= 0) { - cur_adie_type = MARIMBA_ID; - return cur_adie_type; - } - } - } - - return ret; -} - -static void marimba_init_reg(struct i2c_client *client, u8 driver_data) -{ - struct marimba_platform_data *pdata = client->dev.platform_data; - struct marimba *marimba = - &marimba_modules[MARIMBA_SLAVE_ID_MARIMBA + adie_arry_idx]; - - u8 buf[1]; - - buf[0] = 0x10; - - if (cur_adie_type != BAHAMA_ID) { - marimba->mod_id = MARIMBA_SLAVE_ID_MARIMBA + adie_arry_idx; - /* Enable the Mode for Marimba/Timpani */ - marimba_write(marimba, MARIMBA_MODE, buf, 1); - } else if ((cur_adie_type == BAHAMA_ID) && - (cur_connv_type == BAHAMA_ID)) { - marimba->mod_id = MARIMBA_SLAVE_ID_MARIMBA + adie_arry_idx; - marimba_write(marimba, BAHAMA_SLAVE_ID_FM_ID, - &pdata->slave_id[SLAVE_ID_BAHAMA_FM], 1); - /* Configure Bahama core registers (AREG & DREG) */ - /* with optimal values to eliminate power leakage */ - if (pdata->bahama_core_config != NULL) - pdata->bahama_core_config(cur_adie_type); - } -} - -static int marimba_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct marimba_platform_data *pdata = client->dev.platform_data; - struct i2c_adapter *ssbi_adap; - struct marimba *marimba; - int i, status, rc, client_loop, adie_slave_idx_offset; - int rc_bahama = 0, rc_marimba = 0; - - if (!pdata) { - dev_dbg(&client->dev, "no platform data?\n"); - status = -EINVAL; - goto fail; - } - - if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { - dev_dbg(&client->dev, "can't talk I2C?\n"); - status = -EIO; - goto fail; - } - if (!mutex_initialized) { - for (i = 0; i < ADIE_ARRY_SIZE; ++i) { - marimba = &marimba_modules[i]; - mutex_init(&marimba->xfer_lock); - } - mutex_initialized = 1; - } - /* First, identify the codec type */ - if (pdata->marimba_setup != NULL) { - rc_marimba = pdata->marimba_setup(); - if (rc_marimba) - pdata->marimba_shutdown(); - } - if (pdata->bahama_setup != NULL && - cur_connv_type != BAHAMA_ID) { - rc_bahama = pdata->bahama_setup(); - if (rc_bahama) - pdata->bahama_shutdown(cur_connv_type); - } - if (rc_marimba & rc_bahama) { - status = -EAGAIN; - goto fail; - } - marimba = &marimba_modules[ADIE_ARRY_SIZE - 1]; - marimba->client = client; - - rc = get_adie_type(); - - if (rc < 0) { - if (pdata->bahama_setup != NULL) - pdata->bahama_shutdown(cur_adie_type); - if (pdata->marimba_shutdown != NULL) - pdata->marimba_shutdown(); - status = -ENODEV; - goto fail; - } - - if (rc < 2) { - adie_arry_idx = 0; - adie_slave_idx_offset = 0; - client_loop = 0; - cur_codec_type = rc; - if (cur_connv_type < 0) - cur_connv_type = rc; - if (pdata->bahama_shutdown != NULL) - pdata->bahama_shutdown(cur_connv_type); - } else { - adie_arry_idx = 5; - adie_slave_idx_offset = 5; - client_loop = 1; - cur_connv_type = rc; - } - - marimba = &marimba_modules[adie_arry_idx]; - marimba->client = client; - - for (i = 1; i <= (NUM_ADD - client_loop); i++) { - /* Skip adding BT/FM for Timpani */ - if (i == 1 && rc >= 1) - i++; - marimba = &marimba_modules[i + adie_arry_idx]; - if (i != MARIMBA_ID_TSADC) - marimba->client = i2c_new_dummy(client->adapter, - pdata->slave_id[i + adie_slave_idx_offset]); - else if (pdata->tsadc_ssbi_adap) { - ssbi_adap = i2c_get_adapter(pdata->tsadc_ssbi_adap); - marimba->client = i2c_new_dummy(ssbi_adap, - 0x55); - } else - ssbi_adap = NULL; - - if (!marimba->client) { - pr_err("can't attach client %d\n", i); - status = -ENOMEM; - goto fail; - } - strlcpy(marimba->client->name, id->name, - sizeof(marimba->client->name)); - - } - - if (marimba_dbg_init(rc) != 0) - pr_debug("%s: marimba debugfs init failed\n", __func__); - - marimba_init_reg(client, id->driver_data); - - status = marimba_add_child(pdata, id->driver_data); - - marimba_pdata = pdata; - - return 0; - -fail: - return status; -} - -static int marimba_remove(struct i2c_client *client) -{ - int i; - struct marimba_platform_data *pdata; - - pdata = client->dev.platform_data; - for (i = 0; i < ADIE_ARRY_SIZE; i++) { - struct marimba *marimba = &marimba_modules[i]; - - if (marimba->client && marimba->client != client) - i2c_unregister_device(marimba->client); - - marimba_modules[i].client = NULL; - if (mutex_initialized) - mutex_destroy(&marimba->xfer_lock); - - } - marimba_dbg_remove(); - mutex_initialized = 0; - if (pdata->marimba_shutdown != NULL) - pdata->marimba_shutdown(); - - return 0; -} - -static struct i2c_device_id marimba_id_table[] = { - {"marimba", MARIMBA_ID}, - {"timpani", TIMPANI_ID}, - {} -}; -MODULE_DEVICE_TABLE(i2c, marimba_id_table); - -static struct i2c_driver marimba_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "marimba-core", - }, - .id_table = marimba_id_table, - .probe = marimba_probe, - .remove = marimba_remove, -}; - -static int __init marimba_init(void) -{ - return i2c_add_driver(&marimba_driver); -} -module_init(marimba_init); - -static void __exit marimba_exit(void) -{ - i2c_del_driver(&marimba_driver); -} -module_exit(marimba_exit); - -MODULE_DESCRIPTION("Marimba Top level Driver"); -MODULE_ALIAS("platform:marimba-core"); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("0.1"); diff --git a/drivers/mfd/marimba-tsadc.c b/drivers/mfd/marimba-tsadc.c deleted file mode 100644 index 931e585b64d54d9a63c6a1e1a0adfeebcc711253..0000000000000000000000000000000000000000 --- a/drivers/mfd/marimba-tsadc.c +++ /dev/null @@ -1,696 +0,0 @@ -/* - * Marimba TSADC driver. - * - * Copyright (c) 2009-2010, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_HAS_EARLYSUSPEND) -#include -#endif - -/* marimba configuration block: TS_CTL0 */ -#define TS_CTL0 0xFF -#define TS_CTL0_RESET BIT(0) -#define TS_CTL0_CLK_EN BIT(1) -#define TS_CTL0_XO_EN BIT(2) -#define TS_CTL0_EOC_EN BIT(3) -#define TS_CTL0_PENIRQ_EN BIT(4) - -/* TSADC registers */ -#define SSBI_PRESET 0x00 -#define TSHK_DIG_CONFIG 0x4F -#define TSHK_INTF_CONFIG 0x50 -#define TSHK_SETUP 0x51 - #define TSHK_SETUP_EN_ADC BIT(0) - #define TSHK_SETUP_EN_PIRQ BIT(7) -#define TSHK_PARAM 0x52 -#define TSHK_DATA_RD 0x53 -#define TSHK_STATUS 0x54 -#define TSHK_SETUP2 0x55 -#define TSHK_RSV1 0x56 - #define TSHK_RSV1_PRECHARGE_EN BIT(0) -#define TSHK_COMMAND 0x57 -#define TSHK_PARAM2 0x58 - #define TSHK_INPUT_CLK_MASK 0x3F - #define TSHK_SAMPLE_PRD_MASK 0xC7 - #define TSHK_INPUT_CLK_SHIFT 0x6 - #define TSHK_SAMPLE_PRD_SHIFT 0x3 -#define TSHK_PARAM3 0x59 - #define TSHK_PARAM3_MODE_MASK 0xFC - #define TSHK_PARAM3_PRE_CHG_SHIFT (5) - #define TSHK_PARAM3_STABIZ_SHIFT (2) - #define TSHK_STABLE_TIME_MASK 0xE3 - #define TSHK_PRECHG_TIME_MASK 0x1F -#define TSHK_PARAM4 0x5A -#define TSHK_RSV2 0x5B -#define TSHK_RSV3 0x5C -#define TSHK_RSV4 0x5D -#define TSHK_RSV5 0x5E - -struct marimba_tsadc_client { - unsigned int is_ts; - struct platform_device *pdev; -}; - -struct marimba_tsadc { - struct marimba *marimba; - struct device *dev; - struct marimba_tsadc_platform_data *pdata; - struct clk *codec_ssbi; - struct device *child_tssc; - bool clk_enabled; -#if defined(CONFIG_HAS_EARLYSUSPEND) - struct early_suspend early_suspend; -#endif -}; - -static struct marimba_tsadc *tsadc_dev; - -static int marimba_write_u8(struct marimba_tsadc *tsadc, u8 reg, u8 data) -{ - int rc; - - tsadc->marimba->mod_id = MARIMBA_SLAVE_ID_MARIMBA; - rc = marimba_write(tsadc->marimba, reg, &data, 1); - - if (!rc) - dev_warn(tsadc->dev, "Error writing marimba reg %X - ret %X\n", - reg, data); - return 0; -} - -static int marimba_tsadc_write(struct marimba_tsadc *tsadc, u8 reg, u8 data) -{ - int rc; - - tsadc->marimba->mod_id = MARIMBA_ID_TSADC; - - rc = marimba_ssbi_write(tsadc->marimba, reg, &data, 1); - if (!rc) - dev_warn(tsadc->dev, "Error writing marimba reg %X - ret %X\n", - reg, data); - return rc; -} - -static int marimba_tsadc_shutdown(struct marimba_tsadc *tsadc) -{ - u8 val; - int rc; - - /* force reset */ - val = TS_CTL0_XO_EN | TS_CTL0_EOC_EN | TS_CTL0_PENIRQ_EN | - TS_CTL0_CLK_EN; - rc = marimba_write_u8(tsadc, TS_CTL0, val); - if (rc < 0) - return rc; - - /* disable xo, clock */ - val = TS_CTL0_PENIRQ_EN | TS_CTL0_EOC_EN; - rc = marimba_write_u8(tsadc, TS_CTL0, val); - if (rc < 0) - return rc; - - /* de-vote S2 1.3v */ - if (tsadc->pdata->level_vote) - /* REVISIT: Ignore error for level_vote(0) for now*/ - tsadc->pdata->level_vote(0); - - return 0; -} - -static int marimba_tsadc_startup(struct marimba_tsadc *tsadc) -{ - u8 val; - int rc = 0; - - /* vote for S2 1.3v */ - if (tsadc->pdata->level_vote) { - rc = tsadc->pdata->level_vote(1); - if (rc < 0) - return rc; - } - - /* disable XO, clock and output enables */ - rc = marimba_write_u8(tsadc, TS_CTL0, 0x00); - if (rc < 0) - goto fail_marimba_write; - - /* Enable output enables */ - val = TS_CTL0_XO_EN | TS_CTL0_EOC_EN | TS_CTL0_PENIRQ_EN; - rc = marimba_write_u8(tsadc, TS_CTL0, val); - if (rc < 0) - goto fail_marimba_write; - - /* Enable clock */ - val = val | TS_CTL0_CLK_EN; - rc = marimba_write_u8(tsadc, TS_CTL0, val); - if (rc < 0) - goto fail_marimba_write; - - /* remove reset */ - val = val | TS_CTL0_RESET; - rc = marimba_write_u8(tsadc, TS_CTL0, val); - if (rc < 0) - goto fail_marimba_write; - - return 0; - -fail_marimba_write: - if (tsadc->pdata->level_vote) - /* REVISIT: Ignore error for level_vote(0) for now*/ - tsadc->pdata->level_vote(0); - return rc; -} - - -static int marimba_tsadc_configure(struct marimba_tsadc *tsadc) -{ - u8 rsv1 = 0, setup = 0, i, count = 0; - u8 param2 = 0, param3 = 0; - unsigned long val; - int rc; - - rc = marimba_tsadc_write(tsadc, SSBI_PRESET, 0x00); - if (rc < 0) - return rc; - - if (!tsadc->pdata) - return -EINVAL; - - /* Configure RSV1 register*/ - if (tsadc->pdata->tsadc_prechg_en == true) - rsv1 |= TSHK_RSV1_PRECHARGE_EN; - else - rsv1 &= ~TSHK_RSV1_PRECHARGE_EN; - - /* Set RSV1 register*/ - rc = marimba_tsadc_write(tsadc, TSHK_RSV1, rsv1); - if (rc < 0) - return rc; - - /* Configure PARAM2 register */ - /* Input clk */ - val = tsadc->pdata->params2.input_clk_khz; - param2 &= TSHK_INPUT_CLK_MASK; - val /= 600; - if (val >= 1 && val <= 8 && !(val & (val - 1))) { - /* Input clk can be .6, 1.2, 2.4, 4.8Mhz */ - if (val % 4 != 0) - param2 = (4 - (val % 4)) << TSHK_INPUT_CLK_SHIFT; - else - param2 = ((val / 4) - 1) << TSHK_INPUT_CLK_SHIFT; - } else /* Configure the default clk 2.4Mhz */ - param2 = 0x00 << TSHK_INPUT_CLK_SHIFT; - - /* Sample period */ - param2 &= TSHK_SAMPLE_PRD_MASK; - param2 |= tsadc->pdata->params2.sample_prd << TSHK_SAMPLE_PRD_SHIFT; - - /* Write PARAM2 register */ - rc = marimba_tsadc_write(tsadc, TSHK_PARAM2, param2); - if (rc < 0) - return rc; - - /* REVISIT: If Precharge time, stabilization time > 409.6us */ - /* Configure PARAM3 register */ - val = tsadc->pdata->params3.prechg_time_nsecs; - param3 &= TSHK_PRECHG_TIME_MASK; - val /= 6400; - if (val >= 1 && val <= 64 && !(val & (val - 1))) { - count = 0; - while ((val = val >> 1) != 0) - count++; - param3 |= count << TSHK_PARAM3_PRE_CHG_SHIFT; - } else /* Set default value if the input is wrong */ - param3 |= 0x00 << TSHK_PARAM3_PRE_CHG_SHIFT; - - val = tsadc->pdata->params3.stable_time_nsecs; - param3 &= TSHK_STABLE_TIME_MASK; - val /= 6400; - if (val >= 1 && val <= 64 && !(val & (val - 1))) { - count = 0; - while ((val = val >> 1) != 0) - count++; - param3 |= count << TSHK_PARAM3_STABIZ_SHIFT; - } else /* Set default value if the input is wrong */ - param3 |= 0x00 << TSHK_PARAM3_STABIZ_SHIFT; - - /* Get TSADC mode */ - val = tsadc->pdata->params3.tsadc_test_mode; - param3 &= TSHK_PARAM3_MODE_MASK; - if (val == 0) - param3 |= 0x00; - else - for (i = 0; i < 3 ; i++) { - if (((val + i) % 39322) == 0) { - param3 |= (i + 1); - break; - } - } - if (i == 3) /* Set to normal mode if input is wrong */ - param3 |= 0x00; - - rc = marimba_tsadc_write(tsadc, TSHK_PARAM3, param3); - if (rc < 0) - return rc; - - /* Configure TSHK SETUP Register */ - if (tsadc->pdata->setup.pen_irq_en == true) - setup |= TSHK_SETUP_EN_PIRQ; - else - setup &= ~TSHK_SETUP_EN_PIRQ; - - if (tsadc->pdata->setup.tsadc_en == true) - setup |= TSHK_SETUP_EN_ADC; - else - setup &= ~TSHK_SETUP_EN_ADC; - - /* Enable signals to ADC, pen irq assertion */ - rc = marimba_tsadc_write(tsadc, TSHK_SETUP, setup); - if (rc < 0) - return rc; - - return 0; -} - -int marimba_tsadc_start(struct marimba_tsadc_client *client) -{ - int rc = 0; - - if (!client) { - pr_err("%s: Not a valid client\n", __func__); - return -ENODEV; - } - - if (!tsadc_dev) { - dev_err(&client->pdev->dev, - "%s: No tsadc device available\n", __func__); - return -ENODEV; - } - - /* REVISIT - add locks */ - if (client->is_ts) { - rc = marimba_tsadc_startup(tsadc_dev); - if (rc < 0) - goto fail_tsadc_startup; - rc = marimba_tsadc_configure(tsadc_dev); - if (rc < 0) - goto fail_tsadc_conf; - } - - return 0; -fail_tsadc_conf: - marimba_tsadc_shutdown(tsadc_dev); -fail_tsadc_startup: - return rc; -} -EXPORT_SYMBOL(marimba_tsadc_start); - -struct marimba_tsadc_client * -marimba_tsadc_register(struct platform_device *pdev, unsigned int is_ts) -{ - struct marimba_tsadc_client *client; - - if (!pdev) { - pr_err("%s: valid platform device pointer please\n", __func__); - return ERR_PTR(-EINVAL); - } - - if (!is_ts) { - dev_err(&pdev->dev, "%s: only TS right now\n", __func__); - return ERR_PTR(-EINVAL); - } - - if (!tsadc_dev) { - dev_err(&pdev->dev, - "%s: No tsadc device available\n", __func__); - return ERR_PTR(-ENODEV); - } - - client = kzalloc(sizeof *client, GFP_KERNEL); - if (!client) - return ERR_PTR(-ENOMEM); - - client->pdev = pdev; - client->is_ts = is_ts; - - return client; -} -EXPORT_SYMBOL(marimba_tsadc_register); - -void marimba_tsadc_unregister(struct marimba_tsadc_client *client) -{ - if (client->is_ts) - marimba_tsadc_shutdown(tsadc_dev); - kfree(client); -} -EXPORT_SYMBOL(marimba_tsadc_unregister); - -static struct resource resources_tssc[] = { - { - .start = 0xAD300000, - .end = 0xAD300000 + SZ_4K - 1, - .name = "tssc", - .flags = IORESOURCE_MEM, - }, - { - .start = 55, - .end = 55, - .name = "tssc1", - .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, - }, - { - .start = 56, - .end = 56, - .name = "tssc2", - .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, - }, -}; - -static struct device * -marimba_add_tssc_subdev(struct device *parent, const char *name, int num, - struct resource *resources, int num_resources, - void *pdata, int pdata_len) -{ - struct platform_device *pdev; - int status; - - pdev = platform_device_alloc(name, num); - if (!pdev) { - dev_dbg(parent, "can't alloc dev\n"); - status = -ENOMEM; - goto err; - } - - pdev->dev.parent = parent; - - if (pdata) { - status = platform_device_add_data(pdev, pdata, pdata_len); - if (status < 0) { - dev_dbg(&pdev->dev, "can't add platform_data\n"); - goto err; - } - } - - status = platform_device_add_resources(pdev, resources, num_resources); - if (status < 0) { - dev_dbg(&pdev->dev, "can't add resources\n"); - goto err; - } - - status = platform_device_add(pdev); - -err: - if (status < 0) { - platform_device_put(pdev); - dev_err(parent, "can't add %s dev\n", name); - return ERR_PTR(status); - } - return &pdev->dev; -} - -#ifdef CONFIG_PM -static int -marimba_tsadc_suspend(struct device *dev) -{ - int rc = 0, ret = 0; - struct marimba_tsadc *tsadc = dev_get_drvdata(dev); - - if (tsadc->clk_enabled == true) { - clk_disable_unprepare(tsadc->codec_ssbi); - tsadc->clk_enabled = false; - } - - if (!(device_may_wakeup(dev) && - device_may_wakeup(tsadc->child_tssc))) { - rc = marimba_tsadc_shutdown(tsadc); - if (rc < 0) { - pr_err("%s: Unable to shutdown TSADC\n", __func__); - goto fail_shutdown; - } - - if (tsadc->pdata->marimba_tsadc_power) { - rc = tsadc->pdata->marimba_tsadc_power(0); - if (rc < 0) - goto fail_tsadc_power; - } - } - return rc; - -fail_tsadc_power: - marimba_tsadc_startup(tsadc_dev); - marimba_tsadc_configure(tsadc_dev); -fail_shutdown: - if (tsadc->clk_enabled == false) { - ret = clk_prepare_enable(tsadc->codec_ssbi); - if (ret == 0) - tsadc->clk_enabled = true; - } - return rc; -} - -static int marimba_tsadc_resume(struct device *dev) -{ - int rc = 0; - struct marimba_tsadc *tsadc = dev_get_drvdata(dev); - - if (tsadc->clk_enabled == false) { - rc = clk_prepare_enable(tsadc->codec_ssbi); - if (rc != 0) { - pr_err("%s: Clk enable failed\n", __func__); - return rc; - } - tsadc->clk_enabled = true; - } - - if (!(device_may_wakeup(dev) && - device_may_wakeup(tsadc->child_tssc))) { - if (tsadc->pdata->marimba_tsadc_power) { - rc = tsadc->pdata->marimba_tsadc_power(1); - if (rc) { - pr_err("%s: Unable to power on TSADC \n", - __func__); - goto fail_tsadc_power; - } - } - - rc = marimba_tsadc_startup(tsadc_dev); - if (rc < 0) { - pr_err("%s: Unable to startup TSADC\n", __func__); - goto fail_tsadc_startup; - } - - rc = marimba_tsadc_configure(tsadc_dev); - if (rc < 0) { - pr_err("%s: Unable to configure TSADC\n", __func__); - goto fail_tsadc_configure; - } - } - return rc; - -fail_tsadc_configure: - marimba_tsadc_shutdown(tsadc_dev); -fail_tsadc_startup: - if (tsadc->pdata->marimba_tsadc_power) - tsadc->pdata->marimba_tsadc_power(0); -fail_tsadc_power: - if (tsadc->clk_enabled == true) { - clk_disable_unprepare(tsadc->codec_ssbi); - tsadc->clk_enabled = false; - } - return rc; -} - -static struct dev_pm_ops tsadc_pm_ops = { -#ifndef CONFIG_HAS_EARLYSUSPEND - .suspend = marimba_tsadc_suspend, - .resume = marimba_tsadc_resume, -#endif -}; -#endif - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void marimba_tsadc_early_suspend(struct early_suspend *h) -{ - struct marimba_tsadc *tsadc = container_of(h, struct marimba_tsadc, - early_suspend); - - marimba_tsadc_suspend(tsadc->dev); -} - -static void marimba_tsadc_late_resume(struct early_suspend *h) -{ - struct marimba_tsadc *tsadc = container_of(h, struct marimba_tsadc, - early_suspend); - - marimba_tsadc_resume(tsadc->dev); -} -#endif - -static int marimba_tsadc_probe(struct platform_device *pdev) -{ - struct marimba *marimba = platform_get_drvdata(pdev); - struct marimba_tsadc *tsadc; - struct marimba_tsadc_platform_data *pdata = pdev->dev.platform_data; - int rc = 0; - struct device *child; - - printk("%s\n", __func__); - - if (!pdata) { - dev_dbg(&pdev->dev, "no tsadc platform data?\n"); - return -EINVAL; - } - - tsadc = kzalloc(sizeof *tsadc, GFP_KERNEL); - if (!tsadc) - return -ENOMEM; - - tsadc->marimba = marimba; - tsadc->dev = &pdev->dev; - tsadc->pdata = pdata; - - platform_set_drvdata(pdev, tsadc); - - if (tsadc->pdata->init) { - rc = tsadc->pdata->init(); - if (rc < 0) - goto fail_tsadc_init; - } - - if (tsadc->pdata->marimba_tsadc_power) { - rc = tsadc->pdata->marimba_tsadc_power(1); - if (rc) { - pr_err("%s: Unable to power up TSADC \n", __func__); - goto fail_tsadc_power; - } - } - - tsadc->codec_ssbi = clk_get(NULL, "codec_ssbi_clk"); - if (IS_ERR(tsadc->codec_ssbi)) { - rc = PTR_ERR(tsadc->codec_ssbi); - goto fail_clk_get; - } - rc = clk_prepare_enable(tsadc->codec_ssbi); - if (rc != 0) - goto fail_clk_enable; - - tsadc->clk_enabled = true; - - child = marimba_add_tssc_subdev(&pdev->dev, "msm_touchscreen", -1, - resources_tssc, ARRAY_SIZE(resources_tssc), - pdata->tssc_data, sizeof(*pdata->tssc_data)); - - if (IS_ERR(child)) { - rc = PTR_ERR(child); - goto fail_add_subdev; - } - - tsadc->child_tssc = child; - platform_set_drvdata(pdev, tsadc); - -#ifdef CONFIG_HAS_EARLYSUSPEND - tsadc->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + - TSADC_SUSPEND_LEVEL; - tsadc->early_suspend.suspend = marimba_tsadc_early_suspend; - tsadc->early_suspend.resume = marimba_tsadc_late_resume; - register_early_suspend(&tsadc->early_suspend); -#endif - - tsadc_dev = tsadc; - device_init_wakeup(&pdev->dev, pdata->can_wakeup); - - return rc; - -fail_add_subdev: - clk_disable_unprepare(tsadc->codec_ssbi); - -fail_clk_enable: - clk_put(tsadc->codec_ssbi); - -fail_clk_get: - if (tsadc->pdata->marimba_tsadc_power) - rc = tsadc->pdata->marimba_tsadc_power(0); -fail_tsadc_power: - if (tsadc->pdata->exit) - rc = tsadc->pdata->exit(); -fail_tsadc_init: - kfree(tsadc); - return rc; -} - -static int marimba_tsadc_remove(struct platform_device *pdev) -{ - int rc = 0; - struct marimba_tsadc *tsadc = platform_get_drvdata(pdev); - - device_init_wakeup(&pdev->dev, 0); - - if (tsadc->clk_enabled == true) - clk_disable_unprepare(tsadc->codec_ssbi); - - clk_put(tsadc->codec_ssbi); - - if (tsadc->pdata->exit) - rc = tsadc->pdata->exit(); - - if (tsadc->pdata->marimba_tsadc_power) - rc = tsadc->pdata->marimba_tsadc_power(0); - -#ifdef CONFIG_HAS_EARLYSUSPEND - unregister_early_suspend(&tsadc->early_suspend); -#endif - - platform_set_drvdata(pdev, NULL); - kfree(tsadc); - return rc; -} - -static struct platform_driver tsadc_driver = { - .probe = marimba_tsadc_probe, - .remove = marimba_tsadc_remove, - .driver = { - .name = "marimba_tsadc", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &tsadc_pm_ops, -#endif - }, -}; - -static int __init marimba_tsadc_init(void) -{ - return platform_driver_register(&tsadc_driver); -} -device_initcall(marimba_tsadc_init); - -static void __exit marimba_tsadc_exit(void) -{ - return platform_driver_unregister(&tsadc_driver); -} -module_exit(marimba_tsadc_exit); - -MODULE_DESCRIPTION("Marimba TSADC driver"); -MODULE_VERSION("0.1"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:marimba_tsadc"); diff --git a/drivers/mfd/msm-adie-codec.c b/drivers/mfd/msm-adie-codec.c deleted file mode 100644 index b9e317ef702d6fe9db62ae9e2df03d0a6591eb4b..0000000000000000000000000000000000000000 --- a/drivers/mfd/msm-adie-codec.c +++ /dev/null @@ -1,196 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include -#include -#include - -static const struct adie_codec_operations *cur_adie_ops; - -int adie_codec_register_codec_operations( - const struct adie_codec_operations *adie_ops) -{ - if (adie_ops == NULL) - return -EINVAL; - - if (adie_ops->codec_id != adie_get_detected_codec_type()) - return -EINVAL; - - cur_adie_ops = adie_ops; - pr_info("%s: codec type %d\n", __func__, adie_ops->codec_id); - return 0; -} - -int adie_codec_open(struct adie_codec_dev_profile *profile, - struct adie_codec_path **path_pptr) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_open != NULL) - rc = cur_adie_ops->codec_open(profile, path_pptr); - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_open); - -int adie_codec_close(struct adie_codec_path *path_ptr) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_close != NULL) - rc = cur_adie_ops->codec_close(path_ptr); - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_close); - -int adie_codec_set_device_digital_volume(struct adie_codec_path *path_ptr, - u32 num_channels, u32 vol_percentage /* in percentage */) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_set_device_digital_volume != NULL) { - rc = cur_adie_ops->codec_set_device_digital_volume( - path_ptr, - num_channels, - vol_percentage); - } - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_set_device_digital_volume); - -int adie_codec_set_device_analog_volume(struct adie_codec_path *path_ptr, - u32 num_channels, u32 volume /* in percentage */) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_set_device_analog_volume != NULL) { - rc = cur_adie_ops->codec_set_device_analog_volume( - path_ptr, - num_channels, - volume); - } - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_set_device_analog_volume); - -int adie_codec_setpath(struct adie_codec_path *path_ptr, u32 freq_plan, u32 osr) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_setpath != NULL) { - rc = cur_adie_ops->codec_setpath(path_ptr, - freq_plan, - osr); - } - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_setpath); - -u32 adie_codec_freq_supported(struct adie_codec_dev_profile *profile, - u32 requested_freq) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_freq_supported != NULL) - rc = cur_adie_ops->codec_freq_supported(profile, - requested_freq); - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_freq_supported); - -int adie_codec_enable_sidetone(struct adie_codec_path *rx_path_ptr, - u32 enable) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_enable_sidetone != NULL) - rc = cur_adie_ops->codec_enable_sidetone(rx_path_ptr, - enable); - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_enable_sidetone); - -int adie_codec_enable_anc(struct adie_codec_path *rx_path_ptr, - u32 enable, struct adie_codec_anc_data *calibration_writes) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_enable_anc != NULL) - rc = cur_adie_ops->codec_enable_anc(rx_path_ptr, - enable, calibration_writes); - } - - return rc; -} -EXPORT_SYMBOL(adie_codec_enable_anc); - -int adie_codec_proceed_stage(struct adie_codec_path *path_ptr, u32 state) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_proceed_stage != NULL) - rc = cur_adie_ops->codec_proceed_stage(path_ptr, - state); - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_proceed_stage); - -int adie_codec_set_master_mode(struct adie_codec_path *path_ptr, u8 master) -{ - int rc = -EPERM; - - if (cur_adie_ops != NULL) { - if (cur_adie_ops->codec_set_master_mode != NULL) - rc = cur_adie_ops->codec_set_master_mode(path_ptr, - master); - } else - rc = -ENODEV; - - return rc; -} -EXPORT_SYMBOL(adie_codec_set_master_mode); - - diff --git a/drivers/mfd/pm8018-core.c b/drivers/mfd/pm8018-core.c deleted file mode 100644 index 7fe2ae11edb4b75ed9def9a8dec1cea13009e4c2..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8018-core.c +++ /dev/null @@ -1,673 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/* PMIC PM8018 SSBI Addresses */ -#define REG_HWREV 0x002 /* PMIC4 revision */ -#define REG_HWREV_2 0x0E8 /* PMIC4 revision 2 */ - -#define REG_MPP_BASE 0x050 -#define REG_IRQ_BASE 0x1BB - -#define REG_RTC_BASE 0x11D - -#define REG_TEMP_ALARM_CTRL 0x01B -#define REG_TEMP_ALARM_PWM 0x09B - - -#define PM8018_VERSION_MASK 0xFFF0 -#define PM8018_VERSION_VALUE 0x08F0 -#define PM8018_REVISION_MASK 0x000F - -#define REG_PM8018_PON_CNTRL_3 0x01D - -#define SINGLE_IRQ_RESOURCE(_name, _irq) \ -{ \ - .name = _name, \ - .start = _irq, \ - .end = _irq, \ - .flags = IORESOURCE_IRQ, \ -} - -struct pm8018 { - struct device *dev; - struct pm_irq_chip *irq_chip; - struct mfd_cell *mfd_regulators; - struct pm8xxx_regulator_core_platform_data *regulator_cdata; - u32 rev_registers; - u8 restart_reason; -}; - -static int pm8018_readb(const struct device *dev, u16 addr, u8 *val) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, val, 1); -} - -static int pm8018_writeb(const struct device *dev, u16 addr, u8 val) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, &val, 1); -} - -static int pm8018_read_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8018_write_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8018_read_irq_stat(const struct device *dev, int irq) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - - return pm8xxx_get_irq_stat(pmic->irq_chip, irq); -} - -static enum pm8xxx_version pm8018_get_version(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - enum pm8xxx_version version = -ENODEV; - - if ((pmic->rev_registers & PM8018_VERSION_MASK) == PM8018_VERSION_VALUE) - version = PM8XXX_VERSION_8018; - - return version; -} - -static int pm8018_get_revision(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - - return pmic->rev_registers & PM8018_REVISION_MASK; -} - -static u8 pm8018_restart_reason(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8018_drvdata = dev_get_drvdata(dev); - const struct pm8018 *pmic = pm8018_drvdata->pm_chip_data; - - return pmic->restart_reason; -} - -static struct pm8xxx_drvdata pm8018_drvdata = { - .pmic_readb = pm8018_readb, - .pmic_writeb = pm8018_writeb, - .pmic_read_buf = pm8018_read_buf, - .pmic_write_buf = pm8018_write_buf, - .pmic_read_irq_stat = pm8018_read_irq_stat, - .pmic_get_version = pm8018_get_version, - .pmic_get_revision = pm8018_get_revision, - .pmic_restart_reason = pm8018_restart_reason, -}; - -static const struct resource gpio_cell_resources[] = { - [0] = { - .start = PM8018_IRQ_BLOCK_BIT(PM8018_GPIO_BLOCK_START, 0), - .end = PM8018_IRQ_BLOCK_BIT(PM8018_GPIO_BLOCK_START, 0) - + PM8018_NR_GPIOS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell gpio_cell = { - .name = PM8XXX_GPIO_DEV_NAME, - .id = -1, - .resources = gpio_cell_resources, - .num_resources = ARRAY_SIZE(gpio_cell_resources), -}; - -static const struct resource adc_cell_resources[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8018_ADC_EOC_USR_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8018_ADC_BATT_TEMP_WARM_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8018_ADC_BATT_TEMP_COLD_IRQ), -}; - -static struct mfd_cell adc_cell = { - .name = PM8XXX_ADC_DEV_NAME, - .id = -1, - .resources = adc_cell_resources, - .num_resources = ARRAY_SIZE(adc_cell_resources), -}; - -static const struct resource mpp_cell_resources[] = { - { - .start = PM8018_IRQ_BLOCK_BIT(PM8018_MPP_BLOCK_START, 0), - .end = PM8018_IRQ_BLOCK_BIT(PM8018_MPP_BLOCK_START, 0) - + PM8018_NR_MPPS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell mpp_cell = { - .name = PM8XXX_MPP_DEV_NAME, - .id = -1, - .resources = mpp_cell_resources, - .num_resources = ARRAY_SIZE(mpp_cell_resources), -}; - -static const struct resource rtc_cell_resources[] = { - [0] = SINGLE_IRQ_RESOURCE(NULL, PM8018_RTC_ALARM_IRQ), - [1] = { - .name = "pmic_rtc_base", - .start = REG_RTC_BASE, - .end = REG_RTC_BASE, - .flags = IORESOURCE_IO, - }, -}; - -static struct mfd_cell rtc_cell = { - .name = PM8XXX_RTC_DEV_NAME, - .id = -1, - .resources = rtc_cell_resources, - .num_resources = ARRAY_SIZE(rtc_cell_resources), -}; - -static const struct resource resources_pwrkey[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8018_PWRKEY_REL_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8018_PWRKEY_PRESS_IRQ), -}; - -static struct mfd_cell pwrkey_cell = { - .name = PM8XXX_PWRKEY_DEV_NAME, - .id = -1, - .num_resources = ARRAY_SIZE(resources_pwrkey), - .resources = resources_pwrkey, -}; - -static struct mfd_cell misc_cell = { - .name = PM8XXX_MISC_DEV_NAME, - .id = -1, -}; - -static struct mfd_cell debugfs_cell = { - .name = "pm8xxx-debug", - .id = -1, - .platform_data = "pm8018-dbg", - .pdata_size = sizeof("pm8018-dbg"), -}; - -static struct mfd_cell pwm_cell = { - .name = PM8XXX_PWM_DEV_NAME, - .id = -1, -}; - -static struct mfd_cell leds_cell = { - .name = PM8XXX_LEDS_DEV_NAME, - .id = -1, -}; - -static const struct resource thermal_alarm_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8018_tempstat_irq", PM8018_TEMPSTAT_IRQ), - SINGLE_IRQ_RESOURCE("pm8018_overtemp_irq", PM8018_OVERTEMP_IRQ), -}; - -static struct pm8xxx_tm_core_data thermal_alarm_cdata = { - .adc_channel = CHANNEL_DIE_TEMP, - .adc_type = PM8XXX_TM_ADC_PM8XXX_ADC, - .reg_addr_temp_alarm_ctrl = REG_TEMP_ALARM_CTRL, - .reg_addr_temp_alarm_pwm = REG_TEMP_ALARM_PWM, - .tm_name = "pm8018_tz", - .irq_name_temp_stat = "pm8018_tempstat_irq", - .irq_name_over_temp = "pm8018_overtemp_irq", -}; - -static struct mfd_cell thermal_alarm_cell = { - .name = PM8XXX_TM_DEV_NAME, - .id = -1, - .resources = thermal_alarm_cell_resources, - .num_resources = ARRAY_SIZE(thermal_alarm_cell_resources), - .platform_data = &thermal_alarm_cdata, - .pdata_size = sizeof(struct pm8xxx_tm_core_data), -}; - -static struct pm8xxx_vreg regulator_data[] = { - /* name pc_name ctrl test hpm_min */ - PLDO("8018_l2", "8018_l2_pc", 0x0B0, 0x0B1, LDO_50), - PLDO("8018_l3", "8018_l3_pc", 0x0B2, 0x0B3, LDO_50), - PLDO("8018_l4", "8018_l4_pc", 0x0B4, 0x0B5, LDO_300), - PLDO("8018_l5", "8018_l5_pc", 0x0B6, 0x0B7, LDO_150), - PLDO("8018_l6", "8018_l6_pc", 0x0B8, 0x0B9, LDO_150), - PLDO("8018_l7", "8018_l7_pc", 0x0BA, 0x0BB, LDO_300), - NLDO("8018_l8", "8018_l8_pc", 0x0BC, 0x0BD, LDO_150), - NLDO1200("8018_l9", 0x0BE, 0x0BF, LDO_1200), - NLDO1200("8018_l10", 0x0C0, 0x0C1, LDO_1200), - NLDO1200("8018_l11", 0x0C2, 0x0C3, LDO_1200), - NLDO1200("8018_l12", 0x0C4, 0x0C5, LDO_1200), - PLDO("8018_l13", "8018_l13_pc", 0x0C8, 0x0C9, LDO_50), - PLDO("8018_l14", "8018_l14_pc", 0x0CA, 0x0CB, LDO_50), - - /* name pc_name ctrl test2 clk sleep hpm_min */ - SMPS("8018_s1", "8018_s1_pc", 0x1D0, 0x1D5, 0x009, 0x1D2, SMPS_1500), - SMPS("8018_s2", "8018_s2_pc", 0x1D8, 0x1DD, 0x00A, 0x1DA, SMPS_1500), - SMPS("8018_s3", "8018_s3_pc", 0x1E0, 0x1E5, 0x00B, 0x1E2, SMPS_1500), - SMPS("8018_s4", "8018_s4_pc", 0x1E8, 0x1ED, 0x00C, 0x1EA, SMPS_1500), - SMPS("8018_s5", "8018_s5_pc", 0x1F0, 0x1F5, 0x00D, 0x1F2, SMPS_1500), - - /* name pc_name ctrl test */ - VS("8018_lvs1", "8018_lvs1_pc", 0x060, 0x061), -}; - -#define MAX_NAME_COMPARISON_LEN 32 - -static int match_regulator( - struct pm8xxx_regulator_core_platform_data *core_data, const char *name) -{ - int found = 0; - int i; - - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) { - if (regulator_data[i].rdesc.name - && strncmp(regulator_data[i].rdesc.name, name, - MAX_NAME_COMPARISON_LEN) == 0) { - core_data->is_pin_controlled = false; - core_data->vreg = ®ulator_data[i]; - found = 1; - break; - } else if (regulator_data[i].rdesc_pc.name - && strncmp(regulator_data[i].rdesc_pc.name, name, - MAX_NAME_COMPARISON_LEN) == 0) { - core_data->is_pin_controlled = true; - core_data->vreg = ®ulator_data[i]; - found = 1; - break; - } - } - - if (!found) - pr_err("could not find a match for regulator: %s\n", name); - - return found; -} - -static int -pm8018_add_regulators(const struct pm8018_platform_data *pdata, - struct pm8018 *pmic, int irq_base) -{ - int ret = 0; - struct mfd_cell *mfd_regulators; - struct pm8xxx_regulator_core_platform_data *cdata; - int i; - - /* Add one device for each regulator used by the board. */ - mfd_regulators = kzalloc(sizeof(struct mfd_cell) - * (pdata->num_regulators), GFP_KERNEL); - if (!mfd_regulators) { - pr_err("Cannot allocate %d bytes for pm8018 regulator " - "mfd cells\n", sizeof(struct mfd_cell) - * (pdata->num_regulators)); - return -ENOMEM; - } - cdata = kzalloc(sizeof(struct pm8xxx_regulator_core_platform_data) - * pdata->num_regulators, GFP_KERNEL); - if (!cdata) { - pr_err("Cannot allocate %d bytes for pm8018 regulator " - "core data\n", pdata->num_regulators - * sizeof(struct pm8xxx_regulator_core_platform_data)); - kfree(mfd_regulators); - return -ENOMEM; - } - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) - mutex_init(®ulator_data[i].pc_lock); - - for (i = 0; i < pdata->num_regulators; i++) { - if (!pdata->regulator_pdatas[i].init_data.constraints.name) { - pr_err("name missing for regulator %d\n", i); - ret = -EINVAL; - goto bail; - } - if (!match_regulator(&cdata[i], - pdata->regulator_pdatas[i].init_data.constraints.name)) { - ret = -ENODEV; - goto bail; - } - cdata[i].pdata = &(pdata->regulator_pdatas[i]); - mfd_regulators[i].name = PM8XXX_REGULATOR_DEV_NAME; - mfd_regulators[i].id = cdata[i].pdata->id; - mfd_regulators[i].platform_data = &cdata[i]; - mfd_regulators[i].pdata_size = - sizeof(struct pm8xxx_regulator_core_platform_data); - } - ret = mfd_add_devices(pmic->dev, 0, mfd_regulators, - pdata->num_regulators, NULL, irq_base); - if (ret) - goto bail; - - pmic->mfd_regulators = mfd_regulators; - pmic->regulator_cdata = cdata; - return ret; - -bail: - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) - mutex_destroy(®ulator_data[i].pc_lock); - kfree(mfd_regulators); - kfree(cdata); - return ret; -} - -static int -pm8018_add_subdevices(const struct pm8018_platform_data *pdata, - struct pm8018 *pmic) -{ - int ret = 0, irq_base = 0; - struct pm_irq_chip *irq_chip; - - if (pdata->irq_pdata) { - pdata->irq_pdata->irq_cdata.nirqs = PM8018_NR_IRQS; - pdata->irq_pdata->irq_cdata.base_addr = REG_IRQ_BASE; - irq_base = pdata->irq_pdata->irq_base; - irq_chip = pm8xxx_irq_init(pmic->dev, pdata->irq_pdata); - - if (IS_ERR(irq_chip)) { - pr_err("Failed to init interrupts ret=%ld\n", - PTR_ERR(irq_chip)); - return PTR_ERR(irq_chip); - } - pmic->irq_chip = irq_chip; - } - - if (pdata->gpio_pdata) { - pdata->gpio_pdata->gpio_cdata.ngpios = PM8018_NR_GPIOS; - gpio_cell.platform_data = pdata->gpio_pdata; - gpio_cell.pdata_size = sizeof(struct pm8xxx_gpio_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &gpio_cell, 1, - NULL, irq_base); - if (ret) { - pr_err("Failed to add gpio subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->mpp_pdata) { - pdata->mpp_pdata->core_data.nmpps = PM8018_NR_MPPS; - pdata->mpp_pdata->core_data.base_addr = REG_MPP_BASE; - mpp_cell.platform_data = pdata->mpp_pdata; - mpp_cell.pdata_size = sizeof(struct pm8xxx_mpp_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &mpp_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add mpp subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->rtc_pdata) { - rtc_cell.platform_data = pdata->rtc_pdata; - rtc_cell.pdata_size = sizeof(struct pm8xxx_rtc_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &rtc_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add rtc subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->pwrkey_pdata) { - pwrkey_cell.platform_data = pdata->pwrkey_pdata; - pwrkey_cell.pdata_size = - sizeof(struct pm8xxx_pwrkey_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &pwrkey_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add pwrkey subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->misc_pdata) { - misc_cell.platform_data = pdata->misc_pdata; - misc_cell.pdata_size = sizeof(struct pm8xxx_misc_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &misc_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add misc subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->adc_pdata) { - adc_cell.platform_data = pdata->adc_pdata; - adc_cell.pdata_size = sizeof(struct pm8xxx_adc_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &adc_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add adc subdevice ret=%d\n", ret); - } - } - - if (pdata->leds_pdata) { - leds_cell.platform_data = pdata->leds_pdata; - leds_cell.pdata_size = sizeof(struct pm8xxx_led_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &leds_cell, 1, NULL, 0); - if (ret) { - pr_err("Failed to add leds subdevice ret=%d\n", ret); - goto bail; - } - } - - ret = mfd_add_devices(pmic->dev, 0, &debugfs_cell, 1, NULL, irq_base); - if (ret) { - pr_err("Failed to add debugfs subdevice ret=%d\n", ret); - goto bail; - } - - ret = mfd_add_devices(pmic->dev, 0, &pwm_cell, 1, NULL, 0); - if (ret) { - pr_err("Failed to add pwm subdevice ret=%d\n", ret); - goto bail; - } - - if (pdata->num_regulators > 0 && pdata->regulator_pdatas) { - ret = pm8018_add_regulators(pdata, pmic, irq_base); - if (ret) { - pr_err("Failed to add regulator subdevices ret=%d\n", - ret); - goto bail; - } - } - - ret = mfd_add_devices(pmic->dev, 0, &thermal_alarm_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add thermal alarm subdevice, ret=%d\n", ret); - goto bail; - } - - return 0; -bail: - if (pmic->irq_chip) { - pm8xxx_irq_exit(pmic->irq_chip); - pmic->irq_chip = NULL; - } - return ret; -} - -static const char * const pm8018_rev_names[] = { - [PM8XXX_REVISION_8018_TEST] = "test", - [PM8XXX_REVISION_8018_1p0] = "1.0", - [PM8XXX_REVISION_8018_2p0] = "2.0", - [PM8XXX_REVISION_8018_2p1] = "2.1", -}; - -static int pm8018_probe(struct platform_device *pdev) -{ - const struct pm8018_platform_data *pdata = pdev->dev.platform_data; - const char *revision_name = "unknown"; - struct pm8018 *pmic; - enum pm8xxx_version version; - int revision; - int rc; - u8 val; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - pmic = kzalloc(sizeof(struct pm8018), GFP_KERNEL); - if (!pmic) { - pr_err("Cannot alloc pm8018 struct\n"); - return -ENOMEM; - } - - /* Read PMIC chip revision */ - rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); - if (rc) { - pr_err("Failed to read hw rev 1 reg %d:rc=%d\n", REG_HWREV, rc); - goto err_read_rev; - } - pr_info("PMIC revision 1: %02X\n", val); - pmic->rev_registers = val; - - /* Read PMIC chip revision 2 */ - rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV_2, &val, sizeof(val)); - if (rc) { - pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", REG_HWREV_2, - rc); - goto err_read_rev; - } - pr_info("PMIC revision 2: %02X\n", val); - pmic->rev_registers |= val << BITS_PER_BYTE; - - pmic->dev = &pdev->dev; - pm8018_drvdata.pm_chip_data = pmic; - platform_set_drvdata(pdev, &pm8018_drvdata); - - /* Print out human readable version and revision names. */ - version = pm8xxx_get_version(pmic->dev); - if (version == PM8XXX_VERSION_8018) { - revision = pm8xxx_get_revision(pmic->dev); - if (revision >= 0 && revision < ARRAY_SIZE(pm8018_rev_names)) - revision_name = pm8018_rev_names[revision]; - pr_info("PMIC version: PM8018 rev %s\n", revision_name); - } else { - WARN_ON(version != PM8XXX_VERSION_8018); - } - /* Log human readable restart reason */ - rc = msm_ssbi_read(pdev->dev.parent, REG_PM8018_PON_CNTRL_3, &val, 1); - if (rc) { - pr_err("Cannot read restart reason rc=%d\n", rc); - goto err_read_rev; - } - val &= PM8XXX_RESTART_REASON_MASK; - pr_info("PMIC Restart Reason: %s\n", pm8xxx_restart_reason_str[val]); - pmic->restart_reason = val; - - rc = pm8018_add_subdevices(pdata, pmic); - if (rc) { - pr_err("Cannot add subdevices rc=%d\n", rc); - goto err; - } - - /* gpio might not work if no irq device is found */ - WARN_ON(pmic->irq_chip == NULL); - - return 0; - -err: - mfd_remove_devices(pmic->dev); - platform_set_drvdata(pdev, NULL); - kfree(pmic->mfd_regulators); - kfree(pmic->regulator_cdata); -err_read_rev: - kfree(pmic); - return rc; -} - -static int pm8018_remove(struct platform_device *pdev) -{ - struct pm8xxx_drvdata *drvdata; - struct pm8018 *pmic = NULL; - int i; - - drvdata = platform_get_drvdata(pdev); - if (drvdata) - pmic = drvdata->pm_chip_data; - if (pmic) { - if (pmic->dev) - mfd_remove_devices(pmic->dev); - if (pmic->irq_chip) { - pm8xxx_irq_exit(pmic->irq_chip); - pmic->irq_chip = NULL; - } - if (pmic->mfd_regulators) { - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) - mutex_destroy(®ulator_data[i].pc_lock); - } - kfree(pmic->mfd_regulators); - kfree(pmic->regulator_cdata); - kfree(pmic); - } - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver pm8018_driver = { - .probe = pm8018_probe, - .remove = pm8018_remove, - .driver = { - .name = PM8018_CORE_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8018_init(void) -{ - return platform_driver_register(&pm8018_driver); -} -postcore_initcall(pm8018_init); - -static void __exit pm8018_exit(void) -{ - platform_driver_unregister(&pm8018_driver); -} -module_exit(pm8018_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC 8018 core driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8018_CORE_DEV_NAME); diff --git a/drivers/mfd/pm8038-core.c b/drivers/mfd/pm8038-core.c deleted file mode 100644 index 24b3e68922a258ea9a676fac8e5a43833bdbf3d7..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8038-core.c +++ /dev/null @@ -1,884 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define REG_HWREV 0x002 /* PMIC4 revision */ -#define REG_HWREV_2 0x0E8 /* PMIC4 revision 2 */ - -#define REG_MPP_BASE 0x050 -#define REG_RTC_BASE 0x11D -#define REG_IRQ_BASE 0x1BB - -#define REG_BATT_ALARM_THRESH 0x023 -#define REG_BATT_ALARM_CTRL1 0x024 -#define REG_BATT_ALARM_CTRL2 0x021 -#define REG_BATT_ALARM_PWM_CTRL 0x020 - -#define REG_SPK_BASE 0x253 -#define REG_SPK_REGISTERS 6 - -#define REG_TEMP_ALARM_CTRL 0x01B -#define REG_TEMP_ALARM_PWM 0x09B - -#define PM8038_VERSION_MASK 0xFFF0 -#define PM8038_VERSION_VALUE 0x09F0 -#define PM8038_REVISION_MASK 0x000F - -#define REG_PM8038_PON_CNTRL_3 0x01D - -#define SINGLE_IRQ_RESOURCE(_name, _irq) \ -{ \ - .name = _name, \ - .start = _irq, \ - .end = _irq, \ - .flags = IORESOURCE_IRQ, \ -} - -struct pm8038 { - struct device *dev; - struct pm_irq_chip *irq_chip; - struct mfd_cell *mfd_regulators; - struct pm8xxx_regulator_core_platform_data *regulator_cdata; - u32 rev_registers; - u8 restart_reason; -}; - -static int pm8038_readb(const struct device *dev, u16 addr, u8 *val) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, val, 1); -} - -static int pm8038_writeb(const struct device *dev, u16 addr, u8 val) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, &val, 1); -} - -static int pm8038_read_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8038_write_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8038_read_irq_stat(const struct device *dev, int irq) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - - return pm8xxx_get_irq_stat(pmic->irq_chip, irq); -} - -static enum pm8xxx_version pm8038_get_version(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - enum pm8xxx_version version = -ENODEV; - - if ((pmic->rev_registers & PM8038_VERSION_MASK) == PM8038_VERSION_VALUE) - version = PM8XXX_VERSION_8038; - - return version; -} - -static int pm8038_get_revision(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - - return pmic->rev_registers & PM8038_REVISION_MASK; -} - -static u8 pm8038_restart_reason(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8038_drvdata = dev_get_drvdata(dev); - const struct pm8038 *pmic = pm8038_drvdata->pm_chip_data; - - return pmic->restart_reason; -} - -static struct pm8xxx_drvdata pm8038_drvdata = { - .pmic_readb = pm8038_readb, - .pmic_writeb = pm8038_writeb, - .pmic_read_buf = pm8038_read_buf, - .pmic_write_buf = pm8038_write_buf, - .pmic_read_irq_stat = pm8038_read_irq_stat, - .pmic_get_version = pm8038_get_version, - .pmic_get_revision = pm8038_get_revision, - .pmic_restart_reason = pm8038_restart_reason, -}; - -static const struct resource gpio_cell_resources[] = { - [0] = { - .start = PM8038_IRQ_BLOCK_BIT(PM8038_GPIO_BLOCK_START, 0), - .end = PM8038_IRQ_BLOCK_BIT(PM8038_GPIO_BLOCK_START, 0) - + PM8038_NR_GPIOS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell gpio_cell = { - .name = PM8XXX_GPIO_DEV_NAME, - .id = -1, - .resources = gpio_cell_resources, - .num_resources = ARRAY_SIZE(gpio_cell_resources), -}; - -static const struct resource adc_cell_resources[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8038_ADC_EOC_USR_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8038_ADC_BATT_TEMP_WARM_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8038_ADC_BATT_TEMP_COLD_IRQ), -}; - -static struct mfd_cell adc_cell = { - .name = PM8XXX_ADC_DEV_NAME, - .id = -1, - .resources = adc_cell_resources, - .num_resources = ARRAY_SIZE(adc_cell_resources), -}; - -static const struct resource charger_cell_resources[] = { - SINGLE_IRQ_RESOURCE("USBIN_VALID_IRQ", PM8921_USBIN_VALID_IRQ), - SINGLE_IRQ_RESOURCE("USBIN_OV_IRQ", PM8921_USBIN_OV_IRQ), - SINGLE_IRQ_RESOURCE("BATT_INSERTED_IRQ", PM8921_BATT_INSERTED_IRQ), - SINGLE_IRQ_RESOURCE("VBATDET_LOW_IRQ", PM8921_VBATDET_LOW_IRQ), - SINGLE_IRQ_RESOURCE("USBIN_UV_IRQ", PM8921_USBIN_UV_IRQ), - SINGLE_IRQ_RESOURCE("VBAT_OV_IRQ", PM8921_VBAT_OV_IRQ), - SINGLE_IRQ_RESOURCE("CHGWDOG_IRQ", PM8921_CHGWDOG_IRQ), - SINGLE_IRQ_RESOURCE("VCP_IRQ", PM8921_VCP_IRQ), - SINGLE_IRQ_RESOURCE("ATCDONE_IRQ", PM8921_ATCDONE_IRQ), - SINGLE_IRQ_RESOURCE("ATCFAIL_IRQ", PM8921_ATCFAIL_IRQ), - SINGLE_IRQ_RESOURCE("CHGDONE_IRQ", PM8921_CHGDONE_IRQ), - SINGLE_IRQ_RESOURCE("CHGFAIL_IRQ", PM8921_CHGFAIL_IRQ), - SINGLE_IRQ_RESOURCE("CHGSTATE_IRQ", PM8921_CHGSTATE_IRQ), - SINGLE_IRQ_RESOURCE("LOOP_CHANGE_IRQ", PM8921_LOOP_CHANGE_IRQ), - SINGLE_IRQ_RESOURCE("FASTCHG_IRQ", PM8921_FASTCHG_IRQ), - SINGLE_IRQ_RESOURCE("TRKLCHG_IRQ", PM8921_TRKLCHG_IRQ), - SINGLE_IRQ_RESOURCE("BATT_REMOVED_IRQ", PM8921_BATT_REMOVED_IRQ), - SINGLE_IRQ_RESOURCE("BATTTEMP_HOT_IRQ", PM8921_BATTTEMP_HOT_IRQ), - SINGLE_IRQ_RESOURCE("CHGHOT_IRQ", PM8921_CHGHOT_IRQ), - SINGLE_IRQ_RESOURCE("BATTTEMP_COLD_IRQ", PM8921_BATTTEMP_COLD_IRQ), - SINGLE_IRQ_RESOURCE("CHG_GONE_IRQ", PM8921_CHG_GONE_IRQ), - SINGLE_IRQ_RESOURCE("BAT_TEMP_OK_IRQ", PM8921_BAT_TEMP_OK_IRQ), - SINGLE_IRQ_RESOURCE("COARSE_DET_LOW_IRQ", PM8921_COARSE_DET_LOW_IRQ), - SINGLE_IRQ_RESOURCE("VDD_LOOP_IRQ", PM8921_VDD_LOOP_IRQ), - SINGLE_IRQ_RESOURCE("VREG_OV_IRQ", PM8921_VREG_OV_IRQ), - SINGLE_IRQ_RESOURCE("VBATDET_IRQ", PM8921_VBATDET_IRQ), - SINGLE_IRQ_RESOURCE("BATFET_IRQ", PM8921_BATFET_IRQ), - SINGLE_IRQ_RESOURCE("PSI_IRQ", PM8921_PSI_IRQ), - SINGLE_IRQ_RESOURCE("DCIN_VALID_IRQ", PM8921_DCIN_VALID_IRQ), - SINGLE_IRQ_RESOURCE("DCIN_OV_IRQ", PM8921_DCIN_OV_IRQ), - SINGLE_IRQ_RESOURCE("DCIN_UV_IRQ", PM8921_DCIN_UV_IRQ), -}; - -static const struct resource bms_cell_resources[] = { - SINGLE_IRQ_RESOURCE("PM8921_BMS_SBI_WRITE_OK", PM8921_BMS_SBI_WRITE_OK), - SINGLE_IRQ_RESOURCE("PM8921_BMS_CC_THR", PM8921_BMS_CC_THR), - SINGLE_IRQ_RESOURCE("PM8921_BMS_VSENSE_THR", PM8921_BMS_VSENSE_THR), - SINGLE_IRQ_RESOURCE("PM8921_BMS_VSENSE_FOR_R", PM8921_BMS_VSENSE_FOR_R), - SINGLE_IRQ_RESOURCE("PM8921_BMS_OCV_FOR_R", PM8921_BMS_OCV_FOR_R), - SINGLE_IRQ_RESOURCE("PM8921_BMS_GOOD_OCV", PM8921_BMS_GOOD_OCV), - SINGLE_IRQ_RESOURCE("PM8921_BMS_VSENSE_AVG", PM8921_BMS_VSENSE_AVG), -}; - -static struct mfd_cell charger_cell = { - .name = PM8921_CHARGER_DEV_NAME, - .id = -1, - .resources = charger_cell_resources, - .num_resources = ARRAY_SIZE(charger_cell_resources), -}; - -static struct mfd_cell bms_cell = { - .name = PM8921_BMS_DEV_NAME, - .id = -1, - .resources = bms_cell_resources, - .num_resources = ARRAY_SIZE(bms_cell_resources), -}; -static const struct resource mpp_cell_resources[] = { - { - .start = PM8038_IRQ_BLOCK_BIT(PM8038_MPP_BLOCK_START, 0), - .end = PM8038_IRQ_BLOCK_BIT(PM8038_MPP_BLOCK_START, 0) - + PM8038_NR_MPPS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell mpp_cell = { - .name = PM8XXX_MPP_DEV_NAME, - .id = 1, - .resources = mpp_cell_resources, - .num_resources = ARRAY_SIZE(mpp_cell_resources), -}; - -static const struct resource rtc_cell_resources[] = { - [0] = SINGLE_IRQ_RESOURCE(NULL, PM8038_RTC_ALARM_IRQ), - [1] = { - .name = "pmic_rtc_base", - .start = REG_RTC_BASE, - .end = REG_RTC_BASE, - .flags = IORESOURCE_IO, - }, -}; - -static struct mfd_cell rtc_cell = { - .name = PM8XXX_RTC_DEV_NAME, - .id = -1, - .resources = rtc_cell_resources, - .num_resources = ARRAY_SIZE(rtc_cell_resources), -}; - -static const struct resource resources_pwrkey[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8038_PWRKEY_REL_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8038_PWRKEY_PRESS_IRQ), -}; - -static struct mfd_cell pwrkey_cell = { - .name = PM8XXX_PWRKEY_DEV_NAME, - .id = -1, - .num_resources = ARRAY_SIZE(resources_pwrkey), - .resources = resources_pwrkey, -}; - -static struct mfd_cell pwm_cell = { - .name = PM8XXX_PWM_DEV_NAME, - .id = -1, -}; - -static struct mfd_cell misc_cell = { - .name = PM8XXX_MISC_DEV_NAME, - .id = -1, -}; - -static struct mfd_cell leds_cell = { - .name = PM8XXX_LEDS_DEV_NAME, - .id = -1, -}; - -static const struct resource resources_spk[] = { - [0] = { - .name = PM8XXX_SPK_DEV_NAME, - .start = REG_SPK_BASE, - .end = REG_SPK_BASE + REG_SPK_REGISTERS - 1, - .flags = IORESOURCE_IO, - }, -}; - -static struct mfd_cell spk_cell = { - .name = PM8XXX_SPK_DEV_NAME, - .id = -1, - .num_resources = ARRAY_SIZE(resources_spk), - .resources = resources_spk, -}; - -static struct mfd_cell debugfs_cell = { - .name = "pm8xxx-debug", - .id = 0, - .platform_data = "pm8038-dbg", - .pdata_size = sizeof("pm8038-dbg"), -}; - -static const struct resource thermal_alarm_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8038_tempstat_irq", PM8038_TEMPSTAT_IRQ), - SINGLE_IRQ_RESOURCE("pm8038_overtemp_irq", PM8038_OVERTEMP_IRQ), -}; - -static struct pm8xxx_tm_core_data thermal_alarm_cdata = { - .adc_channel = CHANNEL_DIE_TEMP, - .adc_type = PM8XXX_TM_ADC_PM8XXX_ADC, - .reg_addr_temp_alarm_ctrl = REG_TEMP_ALARM_CTRL, - .reg_addr_temp_alarm_pwm = REG_TEMP_ALARM_PWM, - .tm_name = "pm8038_tz", - .irq_name_temp_stat = "pm8038_tempstat_irq", - .irq_name_over_temp = "pm8038_overtemp_irq", -}; - -static struct mfd_cell thermal_alarm_cell = { - .name = PM8XXX_TM_DEV_NAME, - .id = -1, - .resources = thermal_alarm_cell_resources, - .num_resources = ARRAY_SIZE(thermal_alarm_cell_resources), - .platform_data = &thermal_alarm_cdata, - .pdata_size = sizeof(struct pm8xxx_tm_core_data), -}; - -static const struct resource batt_alarm_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8921_batt_alarm_irq", PM8038_BATT_ALARM_IRQ), -}; - -static struct pm8xxx_batt_alarm_core_data batt_alarm_cdata = { - .irq_name = "pm8921_batt_alarm_irq", - .reg_addr_threshold = REG_BATT_ALARM_THRESH, - .reg_addr_ctrl1 = REG_BATT_ALARM_CTRL1, - .reg_addr_ctrl2 = REG_BATT_ALARM_CTRL2, - .reg_addr_pwm_ctrl = REG_BATT_ALARM_PWM_CTRL, -}; - -static struct mfd_cell batt_alarm_cell = { - .name = PM8XXX_BATT_ALARM_DEV_NAME, - .id = -1, - .resources = batt_alarm_cell_resources, - .num_resources = ARRAY_SIZE(batt_alarm_cell_resources), - .platform_data = &batt_alarm_cdata, - .pdata_size = sizeof(struct pm8xxx_batt_alarm_core_data), -}; - -static const struct resource ccadc_cell_resources[] = { - SINGLE_IRQ_RESOURCE("PM8921_BMS_CCADC_EOC", PM8921_BMS_CCADC_EOC), -}; - -static struct mfd_cell ccadc_cell = { - .name = PM8XXX_CCADC_DEV_NAME, - .id = -1, - .resources = ccadc_cell_resources, - .num_resources = ARRAY_SIZE(ccadc_cell_resources), -}; - -static struct mfd_cell vibrator_cell = { - .name = PM8XXX_VIBRATOR_DEV_NAME, - .id = -1, -}; - -static struct pm8xxx_vreg regulator_data[] = { - /* name pc_name ctrl test hpm_min */ - NLDO1200("8038_l1", 0x0AE, 0x0AF, LDO_1200), - NLDO("8038_l2", "8038_l2_pc", 0x0B0, 0x0B1, LDO_150), - PLDO("8038_l3", "8038_l3_pc", 0x0B2, 0x0B3, LDO_50), - PLDO("8038_l4", "8038_l4_pc", 0x0B4, 0x0B5, LDO_50), - PLDO("8038_l5", "8038_l5_pc", 0x0B6, 0x0B7, LDO_600), - PLDO("8038_l6", "8038_l6_pc", 0x0B8, 0x0B9, LDO_600), - PLDO("8038_l7", "8038_l7_pc", 0x0BA, 0x0BB, LDO_600), - PLDO("8038_l8", "8038_l8_pc", 0x0BC, 0x0BD, LDO_300), - PLDO("8038_l9", "8038_l9_pc", 0x0BE, 0x0BF, LDO_300), - PLDO("8038_l10", "8038_l10_pc", 0x0C0, 0x0C1, LDO_600), - PLDO("8038_l11", "8038_l11_pc", 0x0C2, 0x0C3, LDO_600), - NLDO("8038_l12", "8038_l12_pc", 0x0C4, 0x0C5, LDO_300), - PLDO("8038_l14", "8038_l14_pc", 0x0C8, 0x0C9, LDO_50), - PLDO("8038_l15", "8038_l15_pc", 0x0CA, 0x0CB, LDO_150), - NLDO1200("8038_l16", 0x0CC, 0x0CD, LDO_1200), - PLDO("8038_l17", "8038_l17_pc", 0x0CE, 0x0CF, LDO_150), - PLDO("8038_l18", "8038_l18_pc", 0x0D0, 0x0D1, LDO_50), - NLDO1200("8038_l19", 0x0D2, 0x0D3, LDO_1200), - NLDO1200("8038_l20", 0x0D4, 0x0D5, LDO_1200), - PLDO("8038_l21", "8038_l21_pc", 0x0D6, 0x0D7, LDO_150), - PLDO("8038_l22", "8038_l22_pc", 0x0D8, 0x0D9, LDO_50), - PLDO("8038_l23", "8038_l23_pc", 0x0DA, 0x0DB, LDO_50), - NLDO1200("8038_l24", 0x0DC, 0x0DD, LDO_1200), - NLDO("8038_l26", "8038_l26_pc", 0x0E0, 0x0E1, LDO_150), - NLDO1200("8038_l27", 0x0E2, 0x0E3, LDO_1200), - - /* name pc_name ctrl test2 clk sleep hpm_min */ - SMPS("8038_s1", "8038_s1_pc", 0x1E0, 0x1E5, 0x009, 0x1E2, SMPS_1500), - SMPS("8038_s2", "8038_s2_pc", 0x1D8, 0x1DD, 0x00A, 0x1DA, SMPS_1500), - SMPS("8038_s3", "8038_s3_pc", 0x1D0, 0x1D5, 0x00B, 0x1D2, SMPS_1500), - SMPS("8038_s4", "8038_s4_pc", 0x1E8, 0x1ED, 0x00C, 0x1EA, SMPS_1500), - - /* name ctrl fts_cnfg1 pfm pwr_cnfg hpm_min */ - FTSMPS("8038_s5", 0x025, 0x02E, 0x026, 0x032, SMPS_2000), - FTSMPS("8038_s6", 0x036, 0x03F, 0x037, 0x043, SMPS_2000), - - /* name pc_name ctrl test */ - VS("8038_lvs1", "8038_lvs1_pc", 0x060, 0x061), - VS("8038_lvs2", "8038_lvs2_pc", 0x062, 0x063), -}; - -#define MAX_NAME_COMPARISON_LEN 32 - -static int match_regulator( - struct pm8xxx_regulator_core_platform_data *core_data, const char *name) -{ - int found = 0; - int i; - - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) { - if (regulator_data[i].rdesc.name - && strncmp(regulator_data[i].rdesc.name, name, - MAX_NAME_COMPARISON_LEN) == 0) { - core_data->is_pin_controlled = false; - core_data->vreg = ®ulator_data[i]; - found = 1; - break; - } else if (regulator_data[i].rdesc_pc.name - && strncmp(regulator_data[i].rdesc_pc.name, name, - MAX_NAME_COMPARISON_LEN) == 0) { - core_data->is_pin_controlled = true; - core_data->vreg = ®ulator_data[i]; - found = 1; - break; - } - } - - if (!found) - pr_err("could not find a match for regulator: %s\n", name); - - return found; -} - -static int -pm8038_add_regulators(const struct pm8038_platform_data *pdata, - struct pm8038 *pmic, int irq_base) -{ - int ret = 0; - struct mfd_cell *mfd_regulators; - struct pm8xxx_regulator_core_platform_data *cdata; - int i; - - /* Add one device for each regulator used by the board. */ - mfd_regulators = kzalloc(sizeof(struct mfd_cell) - * (pdata->num_regulators), GFP_KERNEL); - if (!mfd_regulators) { - pr_err("Cannot allocate %d bytes for pm8038 regulator " - "mfd cells\n", sizeof(struct mfd_cell) - * (pdata->num_regulators)); - return -ENOMEM; - } - cdata = kzalloc(sizeof(struct pm8xxx_regulator_core_platform_data) - * pdata->num_regulators, GFP_KERNEL); - if (!cdata) { - pr_err("Cannot allocate %d bytes for pm8038 regulator " - "core data\n", pdata->num_regulators - * sizeof(struct pm8xxx_regulator_core_platform_data)); - kfree(mfd_regulators); - return -ENOMEM; - } - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) - mutex_init(®ulator_data[i].pc_lock); - - for (i = 0; i < pdata->num_regulators; i++) { - if (!pdata->regulator_pdatas[i].init_data.constraints.name) { - pr_err("name missing for regulator %d\n", i); - ret = -EINVAL; - goto bail; - } - if (!match_regulator(&cdata[i], - pdata->regulator_pdatas[i].init_data.constraints.name)) { - ret = -ENODEV; - goto bail; - } - cdata[i].pdata = &(pdata->regulator_pdatas[i]); - mfd_regulators[i].name = PM8XXX_REGULATOR_DEV_NAME; - mfd_regulators[i].id = cdata[i].pdata->id; - mfd_regulators[i].platform_data = &cdata[i]; - mfd_regulators[i].pdata_size = - sizeof(struct pm8xxx_regulator_core_platform_data); - } - ret = mfd_add_devices(pmic->dev, 0, mfd_regulators, - pdata->num_regulators, NULL, irq_base); - if (ret) - goto bail; - - pmic->mfd_regulators = mfd_regulators; - pmic->regulator_cdata = cdata; - return ret; - -bail: - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) - mutex_destroy(®ulator_data[i].pc_lock); - kfree(mfd_regulators); - kfree(cdata); - return ret; -} - -static int -pm8038_add_subdevices(const struct pm8038_platform_data *pdata, - struct pm8038 *pmic) -{ - int ret = 0, irq_base = 0; - struct pm_irq_chip *irq_chip; - - if (pdata->irq_pdata) { - pdata->irq_pdata->irq_cdata.nirqs = PM8038_NR_IRQS; - pdata->irq_pdata->irq_cdata.base_addr = REG_IRQ_BASE; - irq_base = pdata->irq_pdata->irq_base; - irq_chip = pm8xxx_irq_init(pmic->dev, pdata->irq_pdata); - - if (IS_ERR(irq_chip)) { - pr_err("Failed to init interrupts ret=%ld\n", - PTR_ERR(irq_chip)); - return PTR_ERR(irq_chip); - } - pmic->irq_chip = irq_chip; - } - - if (pdata->gpio_pdata) { - pdata->gpio_pdata->gpio_cdata.ngpios = PM8038_NR_GPIOS; - gpio_cell.platform_data = pdata->gpio_pdata; - gpio_cell.pdata_size = sizeof(struct pm8xxx_gpio_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &gpio_cell, 1, - NULL, irq_base); - if (ret) { - pr_err("Failed to add gpio subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->mpp_pdata) { - pdata->mpp_pdata->core_data.nmpps = PM8038_NR_MPPS; - pdata->mpp_pdata->core_data.base_addr = REG_MPP_BASE; - mpp_cell.platform_data = pdata->mpp_pdata; - mpp_cell.pdata_size = sizeof(struct pm8xxx_mpp_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &mpp_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add mpp subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->rtc_pdata) { - rtc_cell.platform_data = pdata->rtc_pdata; - rtc_cell.pdata_size = sizeof(struct pm8xxx_rtc_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &rtc_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add rtc subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->pwrkey_pdata) { - pwrkey_cell.platform_data = pdata->pwrkey_pdata; - pwrkey_cell.pdata_size = - sizeof(struct pm8xxx_pwrkey_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &pwrkey_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add pwrkey subdevice ret=%d\n", ret); - goto bail; - } - } - - ret = mfd_add_devices(pmic->dev, 0, &pwm_cell, 1, NULL, 0); - if (ret) { - pr_err("Failed to add pwm subdevice ret=%d\n", ret); - goto bail; - } - - if (pdata->misc_pdata) { - misc_cell.platform_data = pdata->misc_pdata; - misc_cell.pdata_size = sizeof(struct pm8xxx_misc_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &misc_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add misc subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->leds_pdata) { - leds_cell.platform_data = pdata->leds_pdata; - leds_cell.pdata_size = sizeof(struct pm8xxx_led_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &leds_cell, 1, NULL, 0); - if (ret) { - pr_err("Failed to add leds subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->vibrator_pdata) { - vibrator_cell.platform_data = pdata->vibrator_pdata; - vibrator_cell.pdata_size = - sizeof(struct pm8xxx_vibrator_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &vibrator_cell, 1, NULL, 0); - if (ret) { - pr_err("Failed to add vibrator ret=%d\n", ret); - goto bail; - } - } - - if (pdata->spk_pdata) { - spk_cell.platform_data = pdata->spk_pdata; - spk_cell.pdata_size = sizeof(struct pm8xxx_spk_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &spk_cell, 1, NULL, 0); - if (ret) { - pr_err("Failed to add spk subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->num_regulators > 0 && pdata->regulator_pdatas) { - ret = pm8038_add_regulators(pdata, pmic, irq_base); - if (ret) { - pr_err("Failed to add regulator subdevices ret=%d\n", - ret); - goto bail; - } - } - - ret = mfd_add_devices(pmic->dev, 0, &debugfs_cell, 1, NULL, irq_base); - if (ret) { - pr_err("Failed to add debugfs subdevice ret=%d\n", ret); - goto bail; - } - - if (pdata->adc_pdata) { - adc_cell.platform_data = pdata->adc_pdata; - adc_cell.pdata_size = - sizeof(struct pm8xxx_adc_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &adc_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add adc subdevices ret=%d\n", - ret); - } - } - - if (pdata->charger_pdata) { - pdata->charger_pdata->charger_cdata.vbat_channel = CHANNEL_VBAT; - pdata->charger_pdata->charger_cdata.batt_temp_channel - = CHANNEL_BATT_THERM; - pdata->charger_pdata->charger_cdata.batt_id_channel - = CHANNEL_BATT_ID; - charger_cell.platform_data = pdata->charger_pdata; - charger_cell.pdata_size = - sizeof(struct pm8921_charger_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &charger_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add charger subdevice ret=%d\n", ret); - goto bail; - } - } - - if (pdata->bms_pdata) { - pdata->bms_pdata->bms_cdata.batt_temp_channel - = CHANNEL_BATT_THERM; - pdata->bms_pdata->bms_cdata.vbat_channel = CHANNEL_VBAT; - pdata->bms_pdata->bms_cdata.ref625mv_channel = CHANNEL_625MV; - pdata->bms_pdata->bms_cdata.ref1p25v_channel = CHANNEL_125V; - pdata->bms_pdata->bms_cdata.batt_id_channel = CHANNEL_BATT_ID; - bms_cell.platform_data = pdata->bms_pdata; - bms_cell.pdata_size = sizeof(struct pm8921_bms_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &bms_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add bms subdevice ret=%d\n", ret); - goto bail; - } - } - - ret = mfd_add_devices(pmic->dev, 0, &thermal_alarm_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add thermal alarm subdevice ret=%d\n", ret); - goto bail; - } - - ret = mfd_add_devices(pmic->dev, 0, &batt_alarm_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add battery alarm subdevice ret=%d\n", ret); - goto bail; - } - - if (pdata->ccadc_pdata) { - pdata->ccadc_pdata->ccadc_cdata.batt_temp_channel - = CHANNEL_BATT_THERM; - ccadc_cell.platform_data = pdata->ccadc_pdata; - ccadc_cell.pdata_size = - sizeof(struct pm8xxx_ccadc_platform_data); - - ret = mfd_add_devices(pmic->dev, 0, &ccadc_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add ccadc subdevice ret=%d\n", ret); - goto bail; - } - } - - return 0; -bail: - if (pmic->irq_chip) { - pm8xxx_irq_exit(pmic->irq_chip); - pmic->irq_chip = NULL; - } - return ret; -} - -static const char * const pm8038_rev_names[] = { - [PM8XXX_REVISION_8038_TEST] = "test", - [PM8XXX_REVISION_8038_1p0] = "1.0", - [PM8XXX_REVISION_8038_2p0] = "2.0", - [PM8XXX_REVISION_8038_2p1] = "2.1", -}; - -static int pm8038_probe(struct platform_device *pdev) -{ - const struct pm8038_platform_data *pdata = pdev->dev.platform_data; - const char *revision_name = "unknown"; - struct pm8038 *pmic; - enum pm8xxx_version version; - int revision; - int rc; - u8 val; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - pmic = kzalloc(sizeof(struct pm8038), GFP_KERNEL); - if (!pmic) { - pr_err("Cannot alloc pm8038 struct\n"); - return -ENOMEM; - } - - /* Read PMIC chip revision */ - rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); - if (rc) { - pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); - goto err_read_rev; - } - pr_info("PMIC revision 1: PM8038 rev %02X\n", val); - pmic->rev_registers = val; - - /* Read PMIC chip revision 2 */ - rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV_2, &val, sizeof(val)); - if (rc) { - pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", - REG_HWREV_2, rc); - goto err_read_rev; - } - pr_info("PMIC revision 2: PM8038 rev %02X\n", val); - pmic->rev_registers |= val << BITS_PER_BYTE; - - pmic->dev = &pdev->dev; - pm8038_drvdata.pm_chip_data = pmic; - platform_set_drvdata(pdev, &pm8038_drvdata); - - /* Print out human readable version and revision names. */ - version = pm8xxx_get_version(pmic->dev); - if (version == PM8XXX_VERSION_8038) { - revision = pm8xxx_get_revision(pmic->dev); - if (revision >= 0 && revision < ARRAY_SIZE(pm8038_rev_names)) - revision_name = pm8038_rev_names[revision]; - pr_info("PMIC version: PM8038 ver %s\n", revision_name); - } else { - WARN_ON(version != PM8XXX_VERSION_8038); - } - - /* Log human readable restart reason */ - rc = msm_ssbi_read(pdev->dev.parent, REG_PM8038_PON_CNTRL_3, &val, 1); - if (rc) { - pr_err("Cannot read restart reason rc=%d\n", rc); - goto err_read_rev; - } - val &= PM8XXX_RESTART_REASON_MASK; - pr_info("PMIC Restart Reason: %s\n", pm8xxx_restart_reason_str[val]); - pmic->restart_reason = val; - - rc = pm8038_add_subdevices(pdata, pmic); - if (rc) { - pr_err("Cannot add subdevices rc=%d\n", rc); - goto err; - } - - return 0; - -err: - mfd_remove_devices(pmic->dev); - platform_set_drvdata(pdev, NULL); - kfree(pmic->mfd_regulators); - kfree(pmic->regulator_cdata); -err_read_rev: - kfree(pmic); - return rc; -} - -static int pm8038_remove(struct platform_device *pdev) -{ - struct pm8xxx_drvdata *drvdata; - struct pm8038 *pmic = NULL; - int i; - - drvdata = platform_get_drvdata(pdev); - - if (drvdata) - pmic = drvdata->pm_chip_data; - - if (pmic) { - if (pmic->dev) - mfd_remove_devices(pmic->dev); - - if (pmic->irq_chip) { - pm8xxx_irq_exit(pmic->irq_chip); - pmic->irq_chip = NULL; - } - if (pmic->mfd_regulators) { - for (i = 0; i < ARRAY_SIZE(regulator_data); i++) - mutex_destroy(®ulator_data[i].pc_lock); - } - kfree(pmic->mfd_regulators); - kfree(pmic->regulator_cdata); - kfree(pmic); - } - - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver pm8038_driver = { - .probe = pm8038_probe, - .remove = pm8038_remove, - .driver = { - .name = PM8038_CORE_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8038_init(void) -{ - return platform_driver_register(&pm8038_driver); -} -postcore_initcall(pm8038_init); - -static void __exit pm8038_exit(void) -{ - platform_driver_unregister(&pm8038_driver); -} -module_exit(pm8038_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC 8038 core driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pm8038-core"); diff --git a/drivers/mfd/pm8821-core.c b/drivers/mfd/pm8821-core.c deleted file mode 100644 index 3ee4e709fb83682096654ed6893b5ae92221e3fe..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8821-core.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define REG_HWREV 0x002 /* PMIC4 revision */ -#define REG_HWREV_2 0x0E8 /* PMIC4 revision 2 */ - -#define REG_MPP_BASE 0x050 -#define REG_IRQ_BASE 0x100 - -#define REG_TEMP_ALARM_CTRL 0x01B -#define REG_TEMP_ALARM_PWM 0x09B - -#define PM8821_VERSION_MASK 0xFFF0 -#define PM8821_VERSION_VALUE 0x0BF0 -#define PM8821_REVISION_MASK 0x000F - -#define SINGLE_IRQ_RESOURCE(_name, _irq) \ -{ \ - .name = _name, \ - .start = _irq, \ - .end = _irq, \ - .flags = IORESOURCE_IRQ, \ -} - -struct pm8821 { - struct device *dev; - struct pm_irq_chip *irq_chip; - u32 rev_registers; -}; - -static int pm8821_readb(const struct device *dev, u16 addr, u8 *val) -{ - const struct pm8xxx_drvdata *pm8821_drvdata = dev_get_drvdata(dev); - const struct pm8821 *pmic = pm8821_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, val, 1); -} - -static int pm8821_writeb(const struct device *dev, u16 addr, u8 val) -{ - const struct pm8xxx_drvdata *pm8821_drvdata = dev_get_drvdata(dev); - const struct pm8821 *pmic = pm8821_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, &val, 1); -} - -static int pm8821_read_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8821_drvdata = dev_get_drvdata(dev); - const struct pm8821 *pmic = pm8821_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8821_write_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8821_drvdata = dev_get_drvdata(dev); - const struct pm8821 *pmic = pm8821_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8821_read_irq_stat(const struct device *dev, int irq) -{ - const struct pm8xxx_drvdata *pm8821_drvdata = dev_get_drvdata(dev); - const struct pm8821 *pmic = pm8821_drvdata->pm_chip_data; - - return pm8821_get_irq_stat(pmic->irq_chip, irq); -} - -static enum pm8xxx_version pm8821_get_version(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8821_drvdata = dev_get_drvdata(dev); - const struct pm8821 *pmic = pm8821_drvdata->pm_chip_data; - enum pm8xxx_version version = -ENODEV; - - if ((pmic->rev_registers & PM8821_VERSION_MASK) == PM8821_VERSION_VALUE) - version = PM8XXX_VERSION_8821; - - return version; -} - -static int pm8821_get_revision(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8821_drvdata = dev_get_drvdata(dev); - const struct pm8821 *pmic = pm8821_drvdata->pm_chip_data; - - return pmic->rev_registers & PM8821_REVISION_MASK; -} - -static struct pm8xxx_drvdata pm8821_drvdata = { - .pmic_readb = pm8821_readb, - .pmic_writeb = pm8821_writeb, - .pmic_read_buf = pm8821_read_buf, - .pmic_write_buf = pm8821_write_buf, - .pmic_read_irq_stat = pm8821_read_irq_stat, - .pmic_get_version = pm8821_get_version, - .pmic_get_revision = pm8821_get_revision, -}; - -static const struct resource mpp_cell_resources[] = { - { - .start = PM8821_IRQ_BLOCK_BIT(PM8821_MPP_BLOCK_START, 0), - .end = PM8821_IRQ_BLOCK_BIT(PM8821_MPP_BLOCK_START, 0) - + PM8821_NR_MPPS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell mpp_cell = { - .name = PM8XXX_MPP_DEV_NAME, - .id = 1, - .resources = mpp_cell_resources, - .num_resources = ARRAY_SIZE(mpp_cell_resources), -}; - -static struct mfd_cell debugfs_cell = { - .name = "pm8xxx-debug", - .id = 1, - .platform_data = "pm8821-dbg", - .pdata_size = sizeof("pm8821-dbg"), -}; - -static const struct resource thermal_alarm_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8821_tempstat_irq", PM8821_TEMPSTAT_IRQ), - SINGLE_IRQ_RESOURCE("pm8821_overtemp_irq", PM8821_OVERTEMP_IRQ), -}; - -static struct pm8xxx_tm_core_data thermal_alarm_cdata = { - .adc_type = PM8XXX_TM_ADC_NONE, - .reg_addr_temp_alarm_ctrl = REG_TEMP_ALARM_CTRL, - .reg_addr_temp_alarm_pwm = REG_TEMP_ALARM_PWM, - .tm_name = "pm8821_tz", - .irq_name_temp_stat = "pm8821_tempstat_irq", - .irq_name_over_temp = "pm8821_overtemp_irq", - .default_no_adc_temp = 37000, -}; - -static struct mfd_cell thermal_alarm_cell = { - .name = PM8XXX_TM_DEV_NAME, - .id = 1, - .resources = thermal_alarm_cell_resources, - .num_resources = ARRAY_SIZE(thermal_alarm_cell_resources), - .platform_data = &thermal_alarm_cdata, - .pdata_size = sizeof(struct pm8xxx_tm_core_data), -}; - -static int -pm8821_add_subdevices(const struct pm8821_platform_data *pdata, - struct pm8821 *pmic) -{ - int ret = 0, irq_base = 0; - struct pm_irq_chip *irq_chip; - - if (pdata->irq_pdata) { - pdata->irq_pdata->irq_cdata.nirqs = PM8821_NR_IRQS; - pdata->irq_pdata->irq_cdata.base_addr = REG_IRQ_BASE; - irq_base = pdata->irq_pdata->irq_base; - irq_chip = pm8821_irq_init(pmic->dev, pdata->irq_pdata); - - if (IS_ERR(irq_chip)) { - pr_err("Failed to init interrupts ret=%ld\n", - PTR_ERR(irq_chip)); - return PTR_ERR(irq_chip); - } - pmic->irq_chip = irq_chip; - } - - if (pdata->mpp_pdata) { - pdata->mpp_pdata->core_data.nmpps = PM8821_NR_MPPS; - pdata->mpp_pdata->core_data.base_addr = REG_MPP_BASE; - mpp_cell.platform_data = pdata->mpp_pdata; - mpp_cell.pdata_size = sizeof(struct pm8xxx_mpp_platform_data); - ret = mfd_add_devices(pmic->dev, 0, &mpp_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add mpp subdevice ret=%d\n", ret); - goto bail; - } - } - - ret = mfd_add_devices(pmic->dev, 0, &debugfs_cell, 1, NULL, irq_base); - if (ret) { - pr_err("Failed to add debugfs subdevice ret=%d\n", ret); - goto bail; - } - - ret = mfd_add_devices(pmic->dev, 0, &thermal_alarm_cell, 1, NULL, - irq_base); - if (ret) { - pr_err("Failed to add thermal alarm subdevice ret=%d\n", - ret); - goto bail; - } - - return 0; -bail: - if (pmic->irq_chip) { - pm8821_irq_exit(pmic->irq_chip); - pmic->irq_chip = NULL; - } - return ret; -} - -static const char * const pm8821_rev_names[] = { - [PM8XXX_REVISION_8821_TEST] = "test", - [PM8XXX_REVISION_8821_1p0] = "1.0", - [PM8XXX_REVISION_8821_2p0] = "2.0", - [PM8XXX_REVISION_8821_2p1] = "2.1", -}; - -static int pm8821_probe(struct platform_device *pdev) -{ - const struct pm8821_platform_data *pdata = pdev->dev.platform_data; - const char *revision_name = "unknown"; - struct pm8821 *pmic; - enum pm8xxx_version version; - int revision; - int rc; - u8 val; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - pmic = kzalloc(sizeof(struct pm8821), GFP_KERNEL); - if (!pmic) { - pr_err("Cannot alloc pm8821 struct\n"); - return -ENOMEM; - } - - /* Read PMIC chip revision */ - rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); - if (rc) { - pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); - goto err_read_rev; - } - pr_info("PMIC revision 1: PM8821 rev %02X\n", val); - pmic->rev_registers = val; - - /* Read PMIC chip revision 2 */ - rc = msm_ssbi_read(pdev->dev.parent, REG_HWREV_2, &val, sizeof(val)); - if (rc) { - pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", - REG_HWREV_2, rc); - goto err_read_rev; - } - pr_info("PMIC revision 2: PM8821 rev %02X\n", val); - pmic->rev_registers |= val << BITS_PER_BYTE; - - pmic->dev = &pdev->dev; - pm8821_drvdata.pm_chip_data = pmic; - platform_set_drvdata(pdev, &pm8821_drvdata); - - /* Print out human readable version and revision names. */ - version = pm8xxx_get_version(pmic->dev); - if (version == PM8XXX_VERSION_8821) { - revision = pm8xxx_get_revision(pmic->dev); - if (revision >= 0 && revision < ARRAY_SIZE(pm8821_rev_names)) - revision_name = pm8821_rev_names[revision]; - pr_info("PMIC version: PM8821 ver %s\n", revision_name); - } else { - WARN_ON(version != PM8XXX_VERSION_8821); - } - - rc = pm8821_add_subdevices(pdata, pmic); - if (rc) { - pr_err("Cannot add subdevices rc=%d\n", rc); - goto err; - } - - return 0; - -err: - mfd_remove_devices(pmic->dev); - platform_set_drvdata(pdev, NULL); -err_read_rev: - kfree(pmic); - return rc; -} - -static int pm8821_remove(struct platform_device *pdev) -{ - struct pm8xxx_drvdata *drvdata; - struct pm8821 *pmic = NULL; - - drvdata = platform_get_drvdata(pdev); - if (drvdata) - pmic = drvdata->pm_chip_data; - if (pmic) { - if (pmic->dev) - mfd_remove_devices(pmic->dev); - if (pmic->irq_chip) - pm8821_irq_exit(pmic->irq_chip); - } - platform_set_drvdata(pdev, NULL); - kfree(pmic); - - return 0; -} - -static struct platform_driver pm8821_driver = { - .probe = pm8821_probe, - .remove = pm8821_remove, - .driver = { - .name = "pm8821-core", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8821_init(void) -{ - return platform_driver_register(&pm8821_driver); -} -postcore_initcall(pm8821_init); - -static void __exit pm8821_exit(void) -{ - platform_driver_unregister(&pm8821_driver); -} -module_exit(pm8821_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC 8821 core driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pm8821-core"); diff --git a/drivers/mfd/pm8821-irq.c b/drivers/mfd/pm8821-irq.c deleted file mode 100644 index 344c68315dddbee67ee9c2b0bd02246e1ac52e62..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8821-irq.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PM8821_TOTAL_IRQ_MASTERS 2 -#define PM8821_BLOCKS_PER_MASTER 7 -#define PM8821_IRQ_MASTER1_SET 0x01 -#define PM8821_IRQ_CLEAR_OFFSET 0x01 -#define PM8821_IRQ_RT_STATUS_OFFSET 0x0F -#define PM8821_IRQ_MASK_REG_OFFSET 0x08 -#define SSBI_REG_ADDR_IRQ_MASTER0 0x30 -#define SSBI_REG_ADDR_IRQ_MASTER1 0xB0 -#define MPM_PIN_FOR_8821_IRQ 7 -#define SSBI_REG_ADDR_IRQ_IT_STATUS(master_base, block) (master_base + block) - -/* - * Block 0 does not exist in PM8821 IRQ SSBI address space, - * IRQ0 is assigned to bit0 of block1. - */ -#define SSBI_REG_ADDR_IRQ_IT_CLEAR(master_base, block) \ - (master_base + PM8821_IRQ_CLEAR_OFFSET + block) - -#define SSBI_REG_ADDR_IRQ_RT_STATUS(master_base, block) \ - (master_base + PM8821_IRQ_RT_STATUS_OFFSET + block) - -#define SSBI_REG_ADDR_IRQ_MASK(master_base, block) \ - (master_base + PM8821_IRQ_MASK_REG_OFFSET + block) - -struct pm_irq_chip { - struct device *dev; - spinlock_t pm_irq_lock; - unsigned int base_addr; - unsigned int devirq; - unsigned int irq_base; - unsigned int num_irqs; - int masters[PM8821_TOTAL_IRQ_MASTERS]; -}; - -static int pm8821_irq_masked_write(struct pm_irq_chip *chip, u16 addr, - u8 mask, u8 val) -{ - int rc; - u8 reg; - - rc = pm8xxx_readb(chip->dev, addr, ®); - if (rc) { - pr_err("read failed addr = %03X, rc = %d\n", addr, rc); - return rc; - } - - reg &= ~mask; - reg |= val & mask; - - rc = pm8xxx_writeb(chip->dev, addr, reg); - if (rc) { - pr_err("write failed addr = %03X, rc = %d\n", addr, rc); - return rc; - } - - return 0; -} - -static int pm8821_read_master_irq(const struct pm_irq_chip *chip, - int m, u8 *master) -{ - return pm8xxx_readb(chip->dev, chip->masters[m], master); -} - -static int pm8821_read_block_irq(struct pm_irq_chip *chip, int master, - u8 block, u8 *bits) -{ - int rc; - - spin_lock(&chip->pm_irq_lock); - - rc = pm8xxx_readb(chip->dev, - SSBI_REG_ADDR_IRQ_IT_STATUS(chip->masters[master], block), bits); - if (rc) - pr_err("Failed Reading Status rc=%d\n", rc); - - spin_unlock(&chip->pm_irq_lock); - return rc; -} - - -static int pm8821_irq_block_handler(struct pm_irq_chip *chip, - int master_number, int block) -{ - int pmirq, irq, i, ret; - u8 bits; - - ret = pm8821_read_block_irq(chip, master_number, block, &bits); - if (ret) { - pr_err("Failed reading %d block ret=%d", block, ret); - return ret; - } - if (!bits) { - pr_err("block bit set in master but no irqs: %d", block); - return 0; - } - - /* Convert block offset to global block number */ - block += (master_number * PM8821_BLOCKS_PER_MASTER) - 1; - - /* Check IRQ bits */ - for (i = 0; i < 8; i++) { - if (bits & BIT(i)) { - pmirq = (block << 3) + i; - irq = pmirq + chip->irq_base; - generic_handle_irq(irq); - } - } - return 0; -} - -static int pm8821_irq_read_master(struct pm_irq_chip *chip, - int master_number, u8 master_val) -{ - int ret = 0; - int block; - - for (block = 1; block < 8; block++) { - if (master_val & BIT(block)) { - ret |= pm8821_irq_block_handler(chip, - master_number, block); - } - } - - return ret; -} - -static irqreturn_t pm8821_irq_handler(int irq, void *data) -{ - struct pm_irq_chip *chip = data; - int ret; - u8 master; - - ret = pm8821_read_master_irq(chip, 0, &master); - if (ret) { - pr_err("Failed to read master 0 ret=%d\n", ret); - return ret; - } - - if (master & ~PM8821_IRQ_MASTER1_SET) - pm8821_irq_read_master(chip, 0, master); - - if (!(master & PM8821_IRQ_MASTER1_SET)) - goto done; - - ret = pm8821_read_master_irq(chip, 1, &master); - if (ret) { - pr_err("Failed to read master 1 ret=%d\n", ret); - return ret; - } - - pm8821_irq_read_master(chip, 1, master); - -done: - return IRQ_HANDLED; -} - -static void pm8821_irq_mask(struct irq_data *d) -{ - struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); - unsigned int pmirq = d->irq - chip->irq_base; - int irq_bit, rc; - u8 block, master; - - block = pmirq >> 3; - master = block / PM8821_BLOCKS_PER_MASTER; - irq_bit = pmirq % 8; - block %= PM8821_BLOCKS_PER_MASTER; - - spin_lock(&chip->pm_irq_lock); - - rc = pm8821_irq_masked_write(chip, - SSBI_REG_ADDR_IRQ_MASK(chip->masters[master], block), - BIT(irq_bit), BIT(irq_bit)); - - if (rc) - pr_err("Failed to read/write mask IRQ:%d rc=%d\n", pmirq, rc); - - spin_unlock(&chip->pm_irq_lock); -} - -static void pm8821_irq_mask_ack(struct irq_data *d) -{ - struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); - unsigned int pmirq = d->irq - chip->irq_base; - int irq_bit, rc; - u8 block, master; - - block = pmirq >> 3; - master = block / PM8821_BLOCKS_PER_MASTER; - irq_bit = pmirq % 8; - block %= PM8821_BLOCKS_PER_MASTER; - - spin_lock(&chip->pm_irq_lock); - - rc = pm8821_irq_masked_write(chip, - SSBI_REG_ADDR_IRQ_MASK(chip->masters[master], block), - BIT(irq_bit), BIT(irq_bit)); - - if (rc) { - pr_err("Failed to read/write mask IRQ:%d rc=%d\n", pmirq, rc); - goto fail; - } - - rc = pm8821_irq_masked_write(chip, - SSBI_REG_ADDR_IRQ_IT_CLEAR(chip->masters[master], block), - BIT(irq_bit), BIT(irq_bit)); - - if (rc) { - pr_err("Failed to read/write IT_CLEAR IRQ:%d rc=%d\n", - pmirq, rc); - } - -fail: - spin_unlock(&chip->pm_irq_lock); -} - -static void pm8821_irq_unmask(struct irq_data *d) -{ - struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); - unsigned int pmirq = d->irq - chip->irq_base; - int irq_bit, rc; - u8 block, master; - - block = pmirq >> 3; - master = block / PM8821_BLOCKS_PER_MASTER; - irq_bit = pmirq % 8; - block %= PM8821_BLOCKS_PER_MASTER; - - spin_lock(&chip->pm_irq_lock); - - rc = pm8821_irq_masked_write(chip, - SSBI_REG_ADDR_IRQ_MASK(chip->masters[master], block), - BIT(irq_bit), ~BIT(irq_bit)); - - if (rc) - pr_err("Failed to read/write unmask IRQ:%d rc=%d\n", pmirq, rc); - - spin_unlock(&chip->pm_irq_lock); -} - -static int pm8821_irq_set_type(struct irq_data *d, unsigned int flow_type) -{ - /* - * PM8821 IRQ controller does not have explicit software support for - * IRQ flow type. - */ - return 0; -} - -static int pm8821_irq_set_wake(struct irq_data *d, unsigned int on) -{ - return 0; -} - -static int pm8821_irq_read_line(struct irq_data *d) -{ - struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); - - return pm8821_get_irq_stat(chip, d->irq); -} - -static struct irq_chip pm_irq_chip = { - .name = "pm8821-irq", - .irq_mask = pm8821_irq_mask, - .irq_mask_ack = pm8821_irq_mask_ack, - .irq_unmask = pm8821_irq_unmask, - .irq_set_type = pm8821_irq_set_type, - .irq_set_wake = pm8821_irq_set_wake, - .irq_read_line = pm8821_irq_read_line, - .flags = IRQCHIP_MASK_ON_SUSPEND, -}; - -/** - * pm8821_get_irq_stat - get the status of the irq line - * @chip: pointer to identify a pmic irq controller - * @irq: the irq number - * - * The pm8821 gpio and mpp rely on the interrupt block to read - * the values on their pins. This function is to facilitate reading - * the status of a gpio or an mpp line. The caller has to convert the - * gpio number to irq number. - * - * RETURNS: - * an int indicating the value read on that line - */ -int pm8821_get_irq_stat(struct pm_irq_chip *chip, int irq) -{ - int pmirq, rc; - u8 block, bits, bit, master; - unsigned long flags; - - if (chip == NULL || irq < chip->irq_base - || irq >= chip->irq_base + chip->num_irqs) - return -EINVAL; - - pmirq = irq - chip->irq_base; - - block = pmirq >> 3; - master = block / PM8821_BLOCKS_PER_MASTER; - bit = pmirq % 8; - block %= PM8821_BLOCKS_PER_MASTER; - - spin_lock_irqsave(&chip->pm_irq_lock, flags); - - rc = pm8xxx_readb(chip->dev, - SSBI_REG_ADDR_IRQ_RT_STATUS(chip->masters[master], block), - &bits); - if (rc) { - pr_err("Failed Configuring irq=%d pmirq=%d blk=%d rc=%d\n", - irq, pmirq, block, rc); - goto bail_out; - } - - rc = (bits & BIT(bit)) ? 1 : 0; - -bail_out: - spin_unlock_irqrestore(&chip->pm_irq_lock, flags); - - return rc; -} -EXPORT_SYMBOL_GPL(pm8821_get_irq_stat); - -struct pm_irq_chip * pm8821_irq_init(struct device *dev, - const struct pm8xxx_irq_platform_data *pdata) -{ - struct pm_irq_chip *chip; - int devirq, rc, blocks, masters; - unsigned int pmirq; - - if (!pdata) { - pr_err("No platform data\n"); - return ERR_PTR(-EINVAL); - } - - devirq = pdata->devirq; - if (devirq < 0) { - pr_err("missing devirq\n"); - rc = devirq; - return ERR_PTR(-EINVAL); - } - - chip = kzalloc(sizeof(struct pm_irq_chip) - + sizeof(u8) * pdata->irq_cdata.nirqs, GFP_KERNEL); - if (!chip) { - pr_err("Cannot alloc pm_irq_chip struct\n"); - return ERR_PTR(-EINVAL); - } - - chip->dev = dev; - chip->devirq = devirq; - chip->irq_base = pdata->irq_base; - chip->num_irqs = pdata->irq_cdata.nirqs; - chip->base_addr = pdata->irq_cdata.base_addr; - blocks = DIV_ROUND_UP(pdata->irq_cdata.nirqs, 8); - masters = DIV_ROUND_UP(blocks, PM8821_BLOCKS_PER_MASTER); - chip->masters[0] = chip->base_addr + SSBI_REG_ADDR_IRQ_MASTER0; - chip->masters[1] = chip->base_addr + SSBI_REG_ADDR_IRQ_MASTER1; - - if (masters != PM8821_TOTAL_IRQ_MASTERS) { - pr_err("Unequal number of masters, passed: %d, " - "should have been: %d\n", masters, PM8821_TOTAL_IRQ_MASTERS); - kfree(chip); - return ERR_PTR(-EINVAL); - } - - spin_lock_init(&chip->pm_irq_lock); - - for (pmirq = 0; pmirq < chip->num_irqs; pmirq++) { - irq_set_chip_and_handler(chip->irq_base + pmirq, - &pm_irq_chip, handle_level_irq); - irq_set_chip_data(chip->irq_base + pmirq, chip); -#ifdef CONFIG_ARM - set_irq_flags(chip->irq_base + pmirq, IRQF_VALID); -#else - irq_set_noprobe(chip->irq_base + pmirq); -#endif - } - - if (devirq != 0) { - rc = request_irq(devirq, pm8821_irq_handler, - pdata->irq_trigger_flag, "pm8821_sec_irq", chip); - if (rc) { - pr_err("failed to request_irq for %d rc=%d\n", - devirq, rc); - kfree(chip); - return ERR_PTR(rc); - } else{ - irq_set_irq_wake(devirq, 1); - msm_mpm_set_pin_wake(MPM_PIN_FOR_8821_IRQ, 1); - msm_mpm_set_pin_type(MPM_PIN_FOR_8821_IRQ, - pdata->irq_trigger_flag); - } - } - - return chip; -} - -int pm8821_irq_exit(struct pm_irq_chip *chip) -{ - irq_set_chained_handler(chip->devirq, NULL); - kfree(chip); - return 0; -} diff --git a/drivers/mfd/pm8xxx-batt-alarm.c b/drivers/mfd/pm8xxx-batt-alarm.c deleted file mode 100644 index 4ce0817fc6c483bd5f0b6fef763c6da277f9ad14..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8xxx-batt-alarm.c +++ /dev/null @@ -1,806 +0,0 @@ -/* Copyright (c) 2011, 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. - */ -/* - * Qualcomm PMIC PM8xxx Battery Alarm driver - * - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* Available voltage threshold values */ -#define THRESHOLD_MIN_MV 2500 -#define THRESHOLD_MAX_MV 5675 -#define THRESHOLD_STEP_MV 25 - -/* Register bit definitions */ - -/* Threshold register */ -#define THRESHOLD_UPPER_MASK 0xF0 -#define THRESHOLD_LOWER_MASK 0x0F -#define THRESHOLD_UPPER_SHIFT 4 -#define THRESHOLD_LOWER_SHIFT 0 - -/* CTRL 1 register */ -#define CTRL1_BATT_ALARM_ENABLE_MASK 0x80 -#define CTRL1_BATT_ALARM_ENABLE 0x80 -#define CTRL1_BATT_ALARM_DISABLE 0x00 -#define CTRL1_HOLD_TIME_MASK 0x70 -#define CTRL1_STATUS_UPPER_MASK 0x02 -#define CTRL1_STATUS_LOWER_MASK 0x01 -#define CTRL1_HOLD_TIME_SHIFT 4 -#define CTRL1_HOLD_TIME_MIN 0 -#define CTRL1_HOLD_TIME_MAX 7 - -/* CTRL 2 register */ -#define CTRL2_COMP_UPPER_DISABLE_MASK 0x80 -#define CTRL2_COMP_UPPER_ENABLE 0x00 -#define CTRL2_COMP_UPPER_DISABLE 0x80 -#define CTRL2_COMP_LOWER_DISABLE_MASK 0x40 -#define CTRL2_COMP_LOWER_ENABLE 0x00 -#define CTRL2_COMP_LOWER_DISABLE 0x40 -#define CTRL2_FINE_STEP_UPPER_MASK 0x30 -#define CTRL2_RANGE_EXT_UPPER_MASK 0x08 -#define CTRL2_FINE_STEP_LOWER_MASK 0x06 -#define CTRL2_RANGE_EXT_LOWER_MASK 0x01 -#define CTRL2_FINE_STEP_UPPER_SHIFT 4 -#define CTRL2_FINE_STEP_LOWER_SHIFT 1 - -/* PWM control register */ -#define PWM_CTRL_ALARM_EN_MASK 0xC0 -#define PWM_CTRL_ALARM_EN_NEVER 0x00 -#define PWM_CTRL_ALARM_EN_TCXO 0x40 -#define PWM_CTRL_ALARM_EN_PWM 0x80 -#define PWM_CTRL_ALARM_EN_ALWAYS 0xC0 -#define PWM_CTRL_PRE_MASK 0x38 -#define PWM_CTRL_DIV_MASK 0x07 -#define PWM_CTRL_PRE_SHIFT 3 -#define PWM_CTRL_DIV_SHIFT 0 -#define PWM_CTRL_PRE_MIN 0 -#define PWM_CTRL_PRE_MAX 7 -#define PWM_CTRL_DIV_MIN 1 -#define PWM_CTRL_DIV_MAX 7 - -/* PWM control input range */ -#define PWM_CTRL_PRE_INPUT_MIN 2 -#define PWM_CTRL_PRE_INPUT_MAX 9 -#define PWM_CTRL_DIV_INPUT_MIN 2 -#define PWM_CTRL_DIV_INPUT_MAX 8 - -/* Available voltage threshold values */ -#define THRESHOLD_BASIC_MIN_MV 2800 -#define THRESHOLD_EXT_MIN_MV 4400 - -/* - * Default values used during initialization: - * Slowest PWM rate to ensure minimal status jittering when crossing thresholds. - * Largest hold time also helps reduce status value jittering. Comparators - * are disabled by default and must be turned on by calling - * pm8xxx_batt_alarm_state_set. - */ -#define DEFAULT_THRESHOLD_LOWER 3200 -#define DEFAULT_THRESHOLD_UPPER 4300 -#define DEFAULT_HOLD_TIME PM8XXX_BATT_ALARM_HOLD_TIME_16_MS -#define DEFAULT_USE_PWM 1 -#define DEFAULT_PWM_SCALER 9 -#define DEFAULT_PWM_DIVIDER 8 -#define DEFAULT_LOWER_ENABLE 0 -#define DEFAULT_UPPER_ENABLE 0 - -struct pm8xxx_batt_alarm_chip { - struct pm8xxx_batt_alarm_core_data cdata; - struct srcu_notifier_head irq_notifier_list; - struct work_struct irq_work; - struct device *dev; - struct mutex lock; - unsigned int irq; - int notifier_count; - u8 reg_threshold; - u8 reg_ctrl1; - u8 reg_ctrl2; - u8 reg_pwm_ctrl; -}; -static struct pm8xxx_batt_alarm_chip *the_battalarm; - -static int pm8xxx_reg_write(struct pm8xxx_batt_alarm_chip *chip, u16 addr, - u8 val, u8 mask, u8 *reg_save) -{ - int rc = 0; - u8 reg; - - reg = (*reg_save & ~mask) | (val & mask); - if (reg != *reg_save) - rc = pm8xxx_writeb(chip->dev->parent, addr, reg); - if (rc) - pr_err("pm8xxx_writeb failed; addr=%03X, rc=%d\n", addr, rc); - else - *reg_save = reg; - return rc; -} - -/** - * pm8xxx_batt_alarm_enable - enable one of the battery voltage threshold - * comparators - * @comparator: selects which comparator to enable - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_enable(enum pm8xxx_batt_alarm_comparator comparator) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int rc; - u8 val_ctrl2 = 0, mask_ctrl2 = 0; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENODEV; - } - - if (comparator < 0 || comparator > PM8XXX_BATT_ALARM_UPPER_COMPARATOR) { - pr_err("invalid comparator ID number: %d\n", comparator); - return -EINVAL; - } - - if (comparator == PM8XXX_BATT_ALARM_LOWER_COMPARATOR) { - val_ctrl2 = CTRL2_COMP_LOWER_ENABLE; - mask_ctrl2 = CTRL2_COMP_LOWER_DISABLE_MASK; - } else { - val_ctrl2 = CTRL2_COMP_UPPER_ENABLE; - mask_ctrl2 = CTRL2_COMP_UPPER_DISABLE_MASK; - } - - mutex_lock(&chip->lock); - - /* Enable the battery alarm block. */ - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_ctrl1, - CTRL1_BATT_ALARM_ENABLE, - CTRL1_BATT_ALARM_ENABLE_MASK, &chip->reg_ctrl1); - if (rc) - goto bail; - - /* Enable the individual comparators. */ - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_ctrl2, val_ctrl2, - mask_ctrl2, &chip->reg_ctrl2); - -bail: - mutex_unlock(&chip->lock); - return rc; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_enable); - -/** - * pm8xxx_batt_alarm_disable - disable one of the battery voltage threshold - * comparators - * @comparator: selects which comparator to disable - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_disable(enum pm8xxx_batt_alarm_comparator comparator) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int rc; - u8 val_ctrl1 = 0, val_ctrl2 = 0, mask_ctrl2 = 0; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENODEV; - } - - if (comparator < 0 || comparator > PM8XXX_BATT_ALARM_UPPER_COMPARATOR) { - pr_err("invalid comparator ID number: %d\n", comparator); - return -EINVAL; - } - - if (comparator == PM8XXX_BATT_ALARM_LOWER_COMPARATOR) { - val_ctrl2 = CTRL2_COMP_LOWER_DISABLE; - mask_ctrl2 = CTRL2_COMP_LOWER_DISABLE_MASK; - } else { - val_ctrl2 = CTRL2_COMP_UPPER_DISABLE; - mask_ctrl2 = CTRL2_COMP_UPPER_DISABLE_MASK; - } - - mutex_lock(&chip->lock); - - /* Disable the specified comparator. */ - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_ctrl2, val_ctrl2, - mask_ctrl2, &chip->reg_ctrl2); - if (rc) - goto bail; - - /* Disable the battery alarm block if both comparators are disabled. */ - val_ctrl2 = chip->reg_ctrl2 - & (CTRL2_COMP_LOWER_DISABLE_MASK | CTRL2_COMP_UPPER_DISABLE_MASK); - if (val_ctrl2 == (CTRL2_COMP_LOWER_DISABLE | CTRL2_COMP_UPPER_DISABLE)) - val_ctrl1 = CTRL1_BATT_ALARM_DISABLE; - else - val_ctrl1 = CTRL1_BATT_ALARM_ENABLE; - - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_ctrl1, val_ctrl1, - CTRL1_BATT_ALARM_ENABLE_MASK, &chip->reg_ctrl1); - -bail: - mutex_unlock(&chip->lock); - return rc; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_disable); - -/** - * pm8xxx_batt_alarm_threshold_set - set the lower and upper alarm thresholds - * @comparator: selects which comparator to set the threshold of - * @threshold_mV: battery voltage threshold in millivolts - * set points = 2500-5675 mV in 25 mV steps - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_threshold_set( - enum pm8xxx_batt_alarm_comparator comparator, int threshold_mV) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int step, fine_step, rc; - u8 val_threshold = 0, val_ctrl2 = 0; - int threshold_mask, threshold_shift, range_ext_mask, fine_step_mask; - int fine_step_shift; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENXIO; - } - - if (comparator < 0 || comparator > PM8XXX_BATT_ALARM_UPPER_COMPARATOR) { - pr_err("invalid comparator ID number: %d\n", comparator); - return -EINVAL; - } - - if (threshold_mV < THRESHOLD_MIN_MV - || threshold_mV > THRESHOLD_MAX_MV) { - pr_err("threshold value, %d mV, is outside of allowable " - "range: [%d, %d] mV\n", threshold_mV, - THRESHOLD_MIN_MV, THRESHOLD_MAX_MV); - return -EINVAL; - } - - if (comparator == PM8XXX_BATT_ALARM_LOWER_COMPARATOR) { - threshold_mask = THRESHOLD_LOWER_MASK; - threshold_shift = THRESHOLD_LOWER_SHIFT; - range_ext_mask = CTRL2_RANGE_EXT_LOWER_MASK; - fine_step_mask = CTRL2_FINE_STEP_LOWER_MASK; - fine_step_shift = CTRL2_FINE_STEP_LOWER_SHIFT; - } else { - threshold_mask = THRESHOLD_UPPER_MASK; - threshold_shift = THRESHOLD_UPPER_SHIFT; - range_ext_mask = CTRL2_RANGE_EXT_UPPER_MASK; - fine_step_mask = CTRL2_FINE_STEP_UPPER_MASK; - fine_step_shift = CTRL2_FINE_STEP_UPPER_SHIFT; - } - - /* Determine register settings to achieve the threshold. */ - if (threshold_mV < THRESHOLD_BASIC_MIN_MV) { - /* Extended low range */ - val_ctrl2 |= range_ext_mask; - - step = (threshold_mV - THRESHOLD_MIN_MV) / THRESHOLD_STEP_MV; - - fine_step = step & 0x3; - /* Extended low range is for steps 0 to 2 */ - step >>= 2; - } else if (threshold_mV >= THRESHOLD_EXT_MIN_MV) { - /* Extended high range */ - val_ctrl2 |= range_ext_mask; - - step = (threshold_mV - THRESHOLD_EXT_MIN_MV) - / THRESHOLD_STEP_MV; - - fine_step = step & 0x3; - /* Extended high range is for steps 3 to 15 */ - step = (step >> 2) + 3; - } else { - /* Basic range */ - step = (threshold_mV - THRESHOLD_BASIC_MIN_MV) - / THRESHOLD_STEP_MV; - - fine_step = step & 0x3; - step >>= 2; - } - val_threshold |= step << threshold_shift; - val_ctrl2 |= (fine_step << fine_step_shift) & fine_step_mask; - - mutex_lock(&chip->lock); - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_threshold, - val_threshold, threshold_mask, &chip->reg_threshold); - if (rc) - goto bail; - - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_ctrl2, val_ctrl2, - range_ext_mask | fine_step_mask, &chip->reg_ctrl2); - -bail: - mutex_unlock(&chip->lock); - return rc; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_threshold_set); - -/** - * pm8xxx_batt_alarm_status_read - get status of both threshold comparators - * - * RETURNS: < 0 = error - * 0 = battery voltage ok - * BIT(0) set = battery voltage below lower threshold - * BIT(1) set = battery voltage above upper threshold - */ -int pm8xxx_batt_alarm_status_read(void) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int status, rc; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENXIO; - } - - mutex_lock(&chip->lock); - rc = pm8xxx_readb(chip->dev->parent, chip->cdata.reg_addr_ctrl1, - &chip->reg_ctrl1); - - status = ((chip->reg_ctrl1 & CTRL1_STATUS_LOWER_MASK) - ? PM8XXX_BATT_ALARM_STATUS_BELOW_LOWER : 0) - | ((chip->reg_ctrl1 & CTRL1_STATUS_UPPER_MASK) - ? PM8XXX_BATT_ALARM_STATUS_ABOVE_UPPER : 0); - mutex_unlock(&chip->lock); - - if (rc) { - pr_err("pm8xxx_readb failed, rc=%d\n", rc); - return rc; - } - - return status; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_status_read); - -/** - * pm8xxx_batt_alarm_hold_time_set - set hold time of interrupt output * - * @hold_time: amount of time that battery voltage must remain outside of the - * threshold range before the battery alarm interrupt triggers - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_hold_time_set(enum pm8xxx_batt_alarm_hold_time hold_time) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int rc; - u8 reg_ctrl1 = 0; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENXIO; - } - - if (hold_time < CTRL1_HOLD_TIME_MIN - || hold_time > CTRL1_HOLD_TIME_MAX) { - - pr_err("hold time, %d, is outside of allowable range: " - "[%d, %d]\n", hold_time, CTRL1_HOLD_TIME_MIN, - CTRL1_HOLD_TIME_MAX); - return -EINVAL; - } - - reg_ctrl1 = hold_time << CTRL1_HOLD_TIME_SHIFT; - - mutex_lock(&chip->lock); - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_ctrl1, reg_ctrl1, - CTRL1_HOLD_TIME_MASK, &chip->reg_ctrl1); - mutex_unlock(&chip->lock); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_hold_time_set); - -/** - * pm8xxx_batt_alarm_pwm_rate_set - set battery alarm update rate * - * @use_pwm: 1 = use PWM update rate, 0 = comparators always active - * @clock_scaler: PWM clock scaler = 2 to 9 - * @clock_divider: PWM clock divider = 2 to 8 - * - * This function sets the rate at which the battery alarm module enables - * the threshold comparators. The rate is determined by the following equation: - * - * f_update = (1024 Hz) / (clock_divider * (2 ^ clock_scaler)) - * - * Thus, the update rate can range from 0.25 Hz to 128 Hz. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_pwm_rate_set(int use_pwm, int clock_scaler, - int clock_divider) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int rc; - u8 reg_pwm_ctrl = 0, mask = 0; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENXIO; - } - - if (use_pwm && (clock_scaler < PWM_CTRL_PRE_INPUT_MIN - || clock_scaler > PWM_CTRL_PRE_INPUT_MAX)) { - pr_err("PWM clock scaler, %d, is outside of allowable range: " - "[%d, %d]\n", clock_scaler, PWM_CTRL_PRE_INPUT_MIN, - PWM_CTRL_PRE_INPUT_MAX); - return -EINVAL; - } - - if (use_pwm && (clock_divider < PWM_CTRL_DIV_INPUT_MIN - || clock_divider > PWM_CTRL_DIV_INPUT_MAX)) { - pr_err("PWM clock divider, %d, is outside of allowable range: " - "[%d, %d]\n", clock_divider, PWM_CTRL_DIV_INPUT_MIN, - PWM_CTRL_DIV_INPUT_MAX); - return -EINVAL; - } - - if (!use_pwm) { - /* Turn off PWM control and always enable. */ - reg_pwm_ctrl = PWM_CTRL_ALARM_EN_ALWAYS; - mask = PWM_CTRL_ALARM_EN_MASK; - } else { - /* Use PWM control. */ - reg_pwm_ctrl = PWM_CTRL_ALARM_EN_PWM; - mask = PWM_CTRL_ALARM_EN_MASK | PWM_CTRL_PRE_MASK - | PWM_CTRL_DIV_MASK; - - clock_scaler -= PWM_CTRL_PRE_INPUT_MIN - PWM_CTRL_PRE_MIN; - clock_divider -= PWM_CTRL_DIV_INPUT_MIN - PWM_CTRL_DIV_MIN; - - reg_pwm_ctrl |= (clock_scaler << PWM_CTRL_PRE_SHIFT) - & PWM_CTRL_PRE_MASK; - reg_pwm_ctrl |= (clock_divider << PWM_CTRL_DIV_SHIFT) - & PWM_CTRL_DIV_MASK; - } - - mutex_lock(&chip->lock); - rc = pm8xxx_reg_write(chip, chip->cdata.reg_addr_pwm_ctrl, reg_pwm_ctrl, - mask, &chip->reg_pwm_ctrl); - mutex_unlock(&chip->lock); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_pwm_rate_set); - -/* - * Handle the BATT_ALARM interrupt: - * Battery voltage is above or below threshold range. - */ -static irqreturn_t pm8xxx_batt_alarm_isr(int irq, void *data) -{ - struct pm8xxx_batt_alarm_chip *chip = data; - - disable_irq_nosync(chip->irq); - schedule_work(&chip->irq_work); - - return IRQ_HANDLED; -} - -static void pm8xxx_batt_alarm_isr_work(struct work_struct *work) -{ - struct pm8xxx_batt_alarm_chip *chip - = container_of(work, struct pm8xxx_batt_alarm_chip, irq_work); - int status; - - if (!chip) - return; - - status = pm8xxx_batt_alarm_status_read(); - - if (status < 0) - pr_err("failed to read status, rc=%d\n", status); - else - srcu_notifier_call_chain(&chip->irq_notifier_list, - status, NULL); - - enable_irq(chip->irq); -} - -/** - * pm8xxx_batt_alarm_register_notifier - register a notifier to run when a - * battery voltage change interrupt fires - * @nb: notifier block containing callback function to register - * - * nb->notifier_call must point to a function of this form - - * int (*notifier_call)(struct notifier_block *nb, unsigned long status, - * void *unused); - * "status" will receive the battery alarm status; "unused" will be NULL. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_register_notifier(struct notifier_block *nb) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int rc; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENXIO; - } - - rc = srcu_notifier_chain_register(&chip->irq_notifier_list, nb); - mutex_lock(&chip->lock); - if (rc == 0) { - if (chip->notifier_count == 0) { - enable_irq(chip->irq); - rc = irq_set_irq_wake(chip->irq, 1); - } - - chip->notifier_count++; - } - - mutex_unlock(&chip->lock); - return rc; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_register_notifier); - -/** - * pm8xxx_batt_alarm_unregister_notifier - unregister a notifier that is run - * when a battery voltage change interrupt fires - * @nb: notifier block containing callback function to unregister - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_unregister_notifier(struct notifier_block *nb) -{ - struct pm8xxx_batt_alarm_chip *chip = the_battalarm; - int rc; - - if (!chip) { - pr_err("no battery alarm device found.\n"); - return -ENXIO; - } - - rc = srcu_notifier_chain_unregister(&chip->irq_notifier_list, nb); - if (rc == 0) { - mutex_lock(&chip->lock); - - chip->notifier_count--; - - if (chip->notifier_count == 0) { - rc = irq_set_irq_wake(chip->irq, 0); - disable_irq(chip->irq); - } - - WARN_ON(chip->notifier_count < 0); - - mutex_unlock(&chip->lock); - } - - return rc; -} -EXPORT_SYMBOL(pm8xxx_batt_alarm_unregister_notifier); - -static int pm8xxx_batt_alarm_reg_init(struct pm8xxx_batt_alarm_chip *chip) -{ - int rc = 0; - - /* save the current register states */ - rc = pm8xxx_readb(chip->dev->parent, chip->cdata.reg_addr_threshold, - &chip->reg_threshold); - if (rc) - goto bail; - - rc = pm8xxx_readb(chip->dev->parent, chip->cdata.reg_addr_ctrl1, - &chip->reg_ctrl1); - if (rc) - goto bail; - - rc = pm8xxx_readb(chip->dev->parent, chip->cdata.reg_addr_ctrl2, - &chip->reg_ctrl2); - if (rc) - goto bail; - - rc = pm8xxx_readb(chip->dev->parent, chip->cdata.reg_addr_pwm_ctrl, - &chip->reg_pwm_ctrl); - if (rc) - goto bail; - -bail: - if (rc) - pr_err("pm8xxx_readb failed; initial register states " - "unknown, rc=%d\n", rc); - return rc; -} - -/* TODO: should this default setting function be removed? */ -static int pm8xxx_batt_alarm_config_defaults(void) -{ - int rc = 0; - - /* Use default values when no platform data is provided. */ - rc = pm8xxx_batt_alarm_threshold_set(PM8XXX_BATT_ALARM_LOWER_COMPARATOR, - DEFAULT_THRESHOLD_LOWER); - if (rc) { - pr_err("threshold_set failed, rc=%d\n", rc); - goto done; - } - - rc = pm8xxx_batt_alarm_threshold_set(PM8XXX_BATT_ALARM_UPPER_COMPARATOR, - DEFAULT_THRESHOLD_UPPER); - if (rc) { - pr_err("threshold_set failed, rc=%d\n", rc); - goto done; - } - - rc = pm8xxx_batt_alarm_hold_time_set(DEFAULT_HOLD_TIME); - if (rc) { - pr_err("hold_time_set failed, rc=%d\n", rc); - goto done; - } - - rc = pm8xxx_batt_alarm_pwm_rate_set(DEFAULT_USE_PWM, - DEFAULT_PWM_SCALER, DEFAULT_PWM_DIVIDER); - if (rc) { - pr_err("pwm_rate_set failed, rc=%d\n", rc); - goto done; - } - - rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (rc) { - pr_err("disable lower failed, rc=%d\n", rc); - goto done; - } - - rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (rc) { - pr_err("disable upper failed, rc=%d\n", rc); - goto done; - } - -done: - return rc; -} - -static int pm8xxx_batt_alarm_probe(struct platform_device *pdev) -{ - const struct pm8xxx_batt_alarm_core_data *cdata - = pdev->dev.platform_data; - struct pm8xxx_batt_alarm_chip *chip; - struct resource *res; - int rc; - - if (the_battalarm) { - pr_err("A PMIC battery alarm device has already probed.\n"); - return -ENODEV; - } - - if (!cdata) { - pr_err("missing core data\n"); - return -EINVAL; - } - - if (!cdata->irq_name) { - pr_err("missing IRQ name\n"); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct pm8xxx_batt_alarm_chip), GFP_KERNEL); - if (chip == NULL) { - pr_err("kzalloc() failed.\n"); - return -ENOMEM; - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - cdata->irq_name); - if (res) { - chip->irq = res->start; - } else { - pr_err("Battery alarm IRQ not specified\n"); - rc = -EINVAL; - goto err_free_chip; - } - - chip->dev = &pdev->dev; - memcpy(&(chip->cdata), cdata, - sizeof(struct pm8xxx_batt_alarm_core_data)); - - srcu_init_notifier_head(&chip->irq_notifier_list); - - chip->notifier_count = 0; - mutex_init(&chip->lock); - - the_battalarm = chip; - - rc = pm8xxx_batt_alarm_reg_init(chip); - if (rc) - goto err_free_mutex; - - rc = pm8xxx_batt_alarm_config_defaults(); - if (rc) - goto err_free_mutex; - - INIT_WORK(&chip->irq_work, pm8xxx_batt_alarm_isr_work); - -/* TODO: Is it best to trigger on both edges? Should this be configurable? */ - rc = request_irq(chip->irq, pm8xxx_batt_alarm_isr, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, cdata->irq_name, - chip); - if (rc < 0) { - pr_err("request_irq(%d) failed, rc=%d\n", chip->irq, rc); - goto err_cancel_work; - } - - /* Disable the IRQ until a notifier is registered. */ - disable_irq(chip->irq); - - platform_set_drvdata(pdev, chip); - - return 0; - -err_cancel_work: - cancel_work_sync(&chip->irq_work); -err_free_mutex: - mutex_destroy(&chip->lock); - srcu_cleanup_notifier_head(&chip->irq_notifier_list); -err_free_chip: - kfree(chip); - the_battalarm = NULL; - - return rc; -} - -static int pm8xxx_batt_alarm_remove(struct platform_device *pdev) -{ - struct pm8xxx_batt_alarm_chip *chip = platform_get_drvdata(pdev); - - if (chip) { - platform_set_drvdata(pdev, NULL); - irq_set_irq_wake(chip->irq, 0); - free_irq(chip->irq, chip); - cancel_work_sync(&chip->irq_work); - srcu_cleanup_notifier_head(&chip->irq_notifier_list); - mutex_destroy(&chip->lock); - kfree(chip); - the_battalarm = NULL; - } - - return 0; -} - -static struct platform_driver pm8xxx_batt_alarm_driver = { - .probe = pm8xxx_batt_alarm_probe, - .remove = pm8xxx_batt_alarm_remove, - .driver = { - .name = PM8XXX_BATT_ALARM_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_batt_alarm_init(void) -{ - return platform_driver_register(&pm8xxx_batt_alarm_driver); -} - -static void __exit pm8xxx_batt_alarm_exit(void) -{ - platform_driver_unregister(&pm8xxx_batt_alarm_driver); -} - -module_init(pm8xxx_batt_alarm_init); -module_exit(pm8xxx_batt_alarm_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC PM8xxx Battery Alarm"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_BATT_ALARM_DEV_NAME); diff --git a/drivers/mfd/pm8xxx-debug.c b/drivers/mfd/pm8xxx-debug.c deleted file mode 100644 index d62f34b45304afaee5798b6abba223f7d00fdeea..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8xxx-debug.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include - -#define PM8XXX_DEBUG_DEV_NAME "pm8xxx-debug" - -struct pm8xxx_debug_device { - struct mutex debug_mutex; - struct device *parent; - struct dentry *dir; - int addr; -}; - -static bool pm8xxx_debug_addr_is_valid(int addr) -{ - if (addr < 0 || addr > 0x3FF) { - pr_err("PMIC register address is invalid: %d\n", addr); - return false; - } - return true; -} - -static int pm8xxx_debug_data_set(void *data, u64 val) -{ - struct pm8xxx_debug_device *debugdev = data; - u8 reg = val; - int rc; - - mutex_lock(&debugdev->debug_mutex); - - if (pm8xxx_debug_addr_is_valid(debugdev->addr)) { - rc = pm8xxx_writeb(debugdev->parent, debugdev->addr, reg); - - if (rc) - pr_err("pm8xxx_writeb(0x%03X)=0x%02X failed: rc=%d\n", - debugdev->addr, reg, rc); - } - - mutex_unlock(&debugdev->debug_mutex); - return 0; -} - -static int pm8xxx_debug_data_get(void *data, u64 *val) -{ - struct pm8xxx_debug_device *debugdev = data; - int rc; - u8 reg; - - mutex_lock(&debugdev->debug_mutex); - - if (pm8xxx_debug_addr_is_valid(debugdev->addr)) { - rc = pm8xxx_readb(debugdev->parent, debugdev->addr, ®); - - if (rc) - pr_err("pm8xxx_readb(0x%03X) failed: rc=%d\n", - debugdev->addr, rc); - else - *val = reg; - } - - mutex_unlock(&debugdev->debug_mutex); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debug_data_fops, pm8xxx_debug_data_get, - pm8xxx_debug_data_set, "0x%02llX\n"); - -static int pm8xxx_debug_addr_set(void *data, u64 val) -{ - struct pm8xxx_debug_device *debugdev = data; - - if (pm8xxx_debug_addr_is_valid(val)) { - mutex_lock(&debugdev->debug_mutex); - debugdev->addr = val; - mutex_unlock(&debugdev->debug_mutex); - } - - return 0; -} - -static int pm8xxx_debug_addr_get(void *data, u64 *val) -{ - struct pm8xxx_debug_device *debugdev = data; - - mutex_lock(&debugdev->debug_mutex); - - if (pm8xxx_debug_addr_is_valid(debugdev->addr)) - *val = debugdev->addr; - - mutex_unlock(&debugdev->debug_mutex); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debug_addr_fops, pm8xxx_debug_addr_get, - pm8xxx_debug_addr_set, "0x%03llX\n"); - -static int pm8xxx_debug_probe(struct platform_device *pdev) -{ - char *name = pdev->dev.platform_data; - struct pm8xxx_debug_device *debugdev; - struct dentry *dir; - struct dentry *temp; - int rc; - - if (name == NULL) { - pr_err("debugfs directory name must be specified in " - "platform_data pointer\n"); - return -EINVAL; - } - - debugdev = kzalloc(sizeof(struct pm8xxx_debug_device), GFP_KERNEL); - if (debugdev == NULL) { - pr_err("kzalloc failed\n"); - return -ENOMEM; - } - - debugdev->parent = pdev->dev.parent; - debugdev->addr = -1; - - dir = debugfs_create_dir(name, NULL); - if (dir == NULL || IS_ERR(dir)) { - pr_err("debugfs_create_dir failed: rc=%ld\n", PTR_ERR(dir)); - rc = PTR_ERR(dir); - goto dir_error; - } - - temp = debugfs_create_file("addr", S_IRUSR | S_IWUSR, dir, debugdev, - &debug_addr_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("debugfs_create_file failed: rc=%ld\n", PTR_ERR(temp)); - rc = PTR_ERR(temp); - goto file_error; - } - - temp = debugfs_create_file("data", S_IRUSR | S_IWUSR, dir, debugdev, - &debug_data_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("debugfs_create_file failed: rc=%ld\n", PTR_ERR(temp)); - rc = PTR_ERR(temp); - goto file_error; - } - - mutex_init(&debugdev->debug_mutex); - - debugdev->dir = dir; - platform_set_drvdata(pdev, debugdev); - - return 0; - -file_error: - debugfs_remove_recursive(dir); -dir_error: - kfree(debugdev); - - return rc; -} - -static int pm8xxx_debug_remove(struct platform_device *pdev) -{ - struct pm8xxx_debug_device *debugdev = platform_get_drvdata(pdev); - - if (debugdev) { - debugfs_remove_recursive(debugdev->dir); - mutex_destroy(&debugdev->debug_mutex); - kfree(debugdev); - } - - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver pm8xxx_debug_driver = { - .probe = pm8xxx_debug_probe, - .remove = pm8xxx_debug_remove, - .driver = { - .name = PM8XXX_DEBUG_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_debug_init(void) -{ - return platform_driver_register(&pm8xxx_debug_driver); -} -subsys_initcall(pm8xxx_debug_init); - -static void __exit pm8xxx_debug_exit(void) -{ - platform_driver_unregister(&pm8xxx_debug_driver); -} -module_exit(pm8xxx_debug_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PM8XXX Debug driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_DEBUG_DEV_NAME); diff --git a/drivers/mfd/pm8xxx-misc.c b/drivers/mfd/pm8xxx-misc.c deleted file mode 100644 index a6e393cd54023c1398d373c661b73e6947179001..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8xxx-misc.c +++ /dev/null @@ -1,1298 +0,0 @@ -/* - * Copyright (c) 2011-2013, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* PON CTRL 1 register */ -#define REG_PM8XXX_PON_CTRL_1 0x01C - -#define PON_CTRL_1_PULL_UP_MASK 0xE0 -#define PON_CTRL_1_USB_PWR_EN 0x10 - -#define PON_CTRL_1_WD_EN_MASK 0x08 -#define PON_CTRL_1_WD_EN_RESET 0x08 -#define PON_CTRL_1_WD_EN_PWR_OFF 0x00 - -/* PON CNTL registers */ -#define REG_PM8058_PON_CNTL_4 0x098 -#define REG_PM8901_PON_CNTL_4 0x099 -#define REG_PM8018_PON_CNTL_4 0x01E -#define REG_PM8921_PON_CNTL_4 0x01E -#define REG_PM8058_PON_CNTL_5 0x07B -#define REG_PM8901_PON_CNTL_5 0x09A -#define REG_PM8018_PON_CNTL_5 0x01F -#define REG_PM8921_PON_CNTL_5 0x01F - -#define PON_CTRL_4_RESET_EN_MASK 0x01 -#define PON_CTRL_4_SHUTDOWN_ON_RESET 0x0 -#define PON_CTRL_4_RESTART_ON_RESET 0x1 -#define PON_CTRL_5_HARD_RESET_EN_MASK 0x08 -#define PON_CTRL_5_HARD_RESET_EN 0x08 -#define PON_CTRL_5_HARD_RESET_DIS 0x00 - -/* Regulator master enable addresses */ -#define REG_PM8058_VREG_EN_MSM 0x018 -#define REG_PM8058_VREG_EN_GRP_5_4 0x1C8 - -/* Regulator control registers for shutdown/reset */ -#define REG_PM8058_S0_CTRL 0x004 -#define REG_PM8058_S1_CTRL 0x005 -#define REG_PM8058_S3_CTRL 0x111 -#define REG_PM8058_L21_CTRL 0x120 -#define REG_PM8058_L22_CTRL 0x121 - -#define PM8058_REGULATOR_ENABLE_MASK 0x80 -#define PM8058_REGULATOR_ENABLE 0x80 -#define PM8058_REGULATOR_DISABLE 0x00 -#define PM8058_REGULATOR_PULL_DOWN_MASK 0x40 -#define PM8058_REGULATOR_PULL_DOWN_EN 0x40 - -/* Buck CTRL register */ -#define PM8058_SMPS_LEGACY_VREF_SEL 0x20 -#define PM8058_SMPS_LEGACY_VPROG_MASK 0x1F -#define PM8058_SMPS_ADVANCED_BAND_MASK 0xC0 -#define PM8058_SMPS_ADVANCED_BAND_SHIFT 6 -#define PM8058_SMPS_ADVANCED_VPROG_MASK 0x3F - -/* Buck TEST2 registers for shutdown/reset */ -#define REG_PM8058_S0_TEST2 0x084 -#define REG_PM8058_S1_TEST2 0x085 -#define REG_PM8058_S3_TEST2 0x11A - -#define PM8058_REGULATOR_BANK_WRITE 0x80 -#define PM8058_REGULATOR_BANK_MASK 0x70 -#define PM8058_REGULATOR_BANK_SHIFT 4 -#define PM8058_REGULATOR_BANK_SEL(n) ((n) << PM8058_REGULATOR_BANK_SHIFT) - -/* Buck TEST2 register bank 1 */ -#define PM8058_SMPS_LEGACY_VLOW_SEL 0x01 - -/* Buck TEST2 register bank 7 */ -#define PM8058_SMPS_ADVANCED_MODE_MASK 0x02 -#define PM8058_SMPS_ADVANCED_MODE 0x02 -#define PM8058_SMPS_LEGACY_MODE 0x00 - -/* SLEEP CTRL register */ -#define REG_PM8058_SLEEP_CTRL 0x02B -#define REG_PM8921_SLEEP_CTRL 0x10A -#define REG_PM8018_SLEEP_CTRL 0x10A - -#define SLEEP_CTRL_SMPL_EN_MASK 0x04 -#define SLEEP_CTRL_SMPL_EN_RESET 0x04 -#define SLEEP_CTRL_SMPL_EN_PWR_OFF 0x00 - -#define SLEEP_CTRL_SMPL_SEL_MASK 0x03 -#define SLEEP_CTRL_SMPL_SEL_MIN 0 -#define SLEEP_CTRL_SMPL_SEL_MAX 3 - -/* FTS regulator PMR registers */ -#define REG_PM8901_REGULATOR_S1_PMR 0xA7 -#define REG_PM8901_REGULATOR_S2_PMR 0xA8 -#define REG_PM8901_REGULATOR_S3_PMR 0xA9 -#define REG_PM8901_REGULATOR_S4_PMR 0xAA - -#define PM8901_REGULATOR_PMR_STATE_MASK 0x60 -#define PM8901_REGULATOR_PMR_STATE_OFF 0x20 - -/* COINCELL CHG registers */ -#define REG_PM8058_COIN_CHG 0x02F -#define REG_PM8921_COIN_CHG 0x09C -#define REG_PM8018_COIN_CHG 0x09C - -#define COINCELL_RESISTOR_SHIFT 0x2 - -/* GP TEST register */ -#define REG_PM8XXX_GP_TEST_1 0x07A - -/* Stay on configuration */ -#define PM8XXX_STAY_ON_CFG 0x92 - -/* GPIO UART MUX CTRL registers */ -#define REG_PM8XXX_GPIO_MUX_CTRL 0x1CC - -#define UART_PATH_SEL_MASK 0x60 -#define UART_PATH_SEL_SHIFT 0x5 - -#define USB_ID_PU_EN_MASK 0x10 /* PM8921 family only */ -#define USB_ID_PU_EN_SHIFT 4 - -/* Shutdown/restart delays to allow for LDO 7/dVdd regulator load settling. */ -#define PM8901_DELAY_AFTER_REG_DISABLE_MS 4 -#define PM8901_DELAY_BEFORE_SHUTDOWN_MS 8 - -#define REG_PM8XXX_XO_CNTRL_2 0x114 -#define MP3_1_MASK 0xE0 -#define MP3_2_MASK 0x1C -#define MP3_1_SHIFT 5 -#define MP3_2_SHIFT 2 - -#define REG_HSED_BIAS0_CNTL2 0xA1 -#define REG_HSED_BIAS1_CNTL2 0x135 -#define REG_HSED_BIAS2_CNTL2 0x138 -#define HSED_EN_MASK 0xC0 - -struct pm8xxx_misc_chip { - struct list_head link; - struct pm8xxx_misc_platform_data pdata; - struct device *dev; - enum pm8xxx_version version; - u64 osc_halt_count; -}; - -static LIST_HEAD(pm8xxx_misc_chips); -static DEFINE_SPINLOCK(pm8xxx_misc_chips_lock); - -static int pm8xxx_misc_masked_write(struct pm8xxx_misc_chip *chip, u16 addr, - u8 mask, u8 val) -{ - int rc; - u8 reg; - - rc = pm8xxx_readb(chip->dev->parent, addr, ®); - if (rc) { - pr_err("pm8xxx_readb(0x%03X) failed, rc=%d\n", addr, rc); - return rc; - } - reg &= ~mask; - reg |= val & mask; - rc = pm8xxx_writeb(chip->dev->parent, addr, reg); - if (rc) - pr_err("pm8xxx_writeb(0x%03X)=0x%02X failed, rc=%d\n", addr, - reg, rc); - return rc; -} - -/** - * pm8xxx_read_register - Read a PMIC register - * @addr: PMIC register address - * @value: Output parameter which gets the value of the register read. - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_read_register(u16 addr, u8 *value) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8921: - rc = pm8xxx_readb(chip->dev->parent, addr, value); - if (rc) { - pr_err("pm8xxx_readb(0x%03X) failed, rc=%d\n", - addr, rc); - break; - } - default: - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_read_register); - -/* - * Set an SMPS regulator to be disabled in its CTRL register, but enabled - * in the master enable register. Also set it's pull down enable bit. - * Take care to make sure that the output voltage doesn't change if switching - * from advanced mode to legacy mode. - */ -static int -__pm8058_disable_smps_locally_set_pull_down(struct pm8xxx_misc_chip *chip, - u16 ctrl_addr, u16 test2_addr, u16 master_enable_addr, - u8 master_enable_bit) -{ - int rc = 0; - u8 vref_sel, vlow_sel, band, vprog, bank, reg; - - bank = PM8058_REGULATOR_BANK_SEL(7); - rc = pm8xxx_writeb(chip->dev->parent, test2_addr, bank); - if (rc) { - pr_err("%s: pm8xxx_writeb(0x%03X) failed: rc=%d\n", __func__, - test2_addr, rc); - goto done; - } - - rc = pm8xxx_readb(chip->dev->parent, test2_addr, ®); - if (rc) { - pr_err("%s: FAIL pm8xxx_readb(0x%03X): rc=%d\n", - __func__, test2_addr, rc); - goto done; - } - - /* Check if in advanced mode. */ - if ((reg & PM8058_SMPS_ADVANCED_MODE_MASK) == - PM8058_SMPS_ADVANCED_MODE) { - /* Determine current output voltage. */ - rc = pm8xxx_readb(chip->dev->parent, ctrl_addr, ®); - if (rc) { - pr_err("%s: FAIL pm8xxx_readb(0x%03X): rc=%d\n", - __func__, ctrl_addr, rc); - goto done; - } - - band = (reg & PM8058_SMPS_ADVANCED_BAND_MASK) - >> PM8058_SMPS_ADVANCED_BAND_SHIFT; - switch (band) { - case 3: - vref_sel = 0; - vlow_sel = 0; - break; - case 2: - vref_sel = PM8058_SMPS_LEGACY_VREF_SEL; - vlow_sel = 0; - break; - case 1: - vref_sel = PM8058_SMPS_LEGACY_VREF_SEL; - vlow_sel = PM8058_SMPS_LEGACY_VLOW_SEL; - break; - default: - pr_err("%s: regulator already disabled\n", __func__); - return -EPERM; - } - vprog = (reg & PM8058_SMPS_ADVANCED_VPROG_MASK); - /* Round up if fine step is in use. */ - vprog = (vprog + 1) >> 1; - if (vprog > PM8058_SMPS_LEGACY_VPROG_MASK) - vprog = PM8058_SMPS_LEGACY_VPROG_MASK; - - /* Set VLOW_SEL bit. */ - bank = PM8058_REGULATOR_BANK_SEL(1); - rc = pm8xxx_writeb(chip->dev->parent, test2_addr, bank); - if (rc) { - pr_err("%s: FAIL pm8xxx_writeb(0x%03X): rc=%d\n", - __func__, test2_addr, rc); - goto done; - } - - rc = pm8xxx_misc_masked_write(chip, test2_addr, - PM8058_REGULATOR_BANK_WRITE | PM8058_REGULATOR_BANK_MASK - | PM8058_SMPS_LEGACY_VLOW_SEL, - PM8058_REGULATOR_BANK_WRITE | - PM8058_REGULATOR_BANK_SEL(1) | vlow_sel); - if (rc) - goto done; - - /* Switch to legacy mode */ - bank = PM8058_REGULATOR_BANK_SEL(7); - rc = pm8xxx_writeb(chip->dev->parent, test2_addr, bank); - if (rc) { - pr_err("%s: FAIL pm8xxx_writeb(0x%03X): rc=%d\n", - __func__, test2_addr, rc); - goto done; - } - rc = pm8xxx_misc_masked_write(chip, test2_addr, - PM8058_REGULATOR_BANK_WRITE | - PM8058_REGULATOR_BANK_MASK | - PM8058_SMPS_ADVANCED_MODE_MASK, - PM8058_REGULATOR_BANK_WRITE | - PM8058_REGULATOR_BANK_SEL(7) | - PM8058_SMPS_LEGACY_MODE); - if (rc) - goto done; - - /* Enable locally, enable pull down, keep voltage the same. */ - rc = pm8xxx_misc_masked_write(chip, ctrl_addr, - PM8058_REGULATOR_ENABLE_MASK | - PM8058_REGULATOR_PULL_DOWN_MASK | - PM8058_SMPS_LEGACY_VREF_SEL | - PM8058_SMPS_LEGACY_VPROG_MASK, - PM8058_REGULATOR_ENABLE | PM8058_REGULATOR_PULL_DOWN_EN - | vref_sel | vprog); - if (rc) - goto done; - } - - /* Enable in master control register. */ - rc = pm8xxx_misc_masked_write(chip, master_enable_addr, - master_enable_bit, master_enable_bit); - if (rc) - goto done; - - /* Disable locally and enable pull down. */ - rc = pm8xxx_misc_masked_write(chip, ctrl_addr, - PM8058_REGULATOR_ENABLE_MASK | PM8058_REGULATOR_PULL_DOWN_MASK, - PM8058_REGULATOR_DISABLE | PM8058_REGULATOR_PULL_DOWN_EN); - -done: - return rc; -} - -static int -__pm8058_disable_ldo_locally_set_pull_down(struct pm8xxx_misc_chip *chip, - u16 ctrl_addr, u16 master_enable_addr, u8 master_enable_bit) -{ - int rc; - - /* Enable LDO in master control register. */ - rc = pm8xxx_misc_masked_write(chip, master_enable_addr, - master_enable_bit, master_enable_bit); - if (rc) - goto done; - - /* Disable LDO in CTRL register and set pull down */ - rc = pm8xxx_misc_masked_write(chip, ctrl_addr, - PM8058_REGULATOR_ENABLE_MASK | PM8058_REGULATOR_PULL_DOWN_MASK, - PM8058_REGULATOR_DISABLE | PM8058_REGULATOR_PULL_DOWN_EN); - -done: - return rc; -} - -static int __pm8018_reset_pwr_off(struct pm8xxx_misc_chip *chip, int reset) -{ - int rc; - - /* Enable SMPL if resetting is desired. */ - rc = pm8xxx_misc_masked_write(chip, REG_PM8018_SLEEP_CTRL, - SLEEP_CTRL_SMPL_EN_MASK, - (reset ? SLEEP_CTRL_SMPL_EN_RESET : SLEEP_CTRL_SMPL_EN_PWR_OFF)); - if (rc) { - pr_err("pm8xxx_misc_masked_write failed, rc=%d\n", rc); - return rc; - } - - /* - * Select action to perform (reset or shutdown) when PS_HOLD goes low. - * Also ensure that KPD, CBL0, and CBL1 pull ups are enabled and that - * USB charging is enabled. - */ - rc = pm8xxx_misc_masked_write(chip, REG_PM8XXX_PON_CTRL_1, - PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN - | PON_CTRL_1_WD_EN_MASK, - PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN - | (reset ? PON_CTRL_1_WD_EN_RESET : PON_CTRL_1_WD_EN_PWR_OFF)); - if (rc) - pr_err("pm8xxx_misc_masked_write failed, rc=%d\n", rc); - - return rc; -} - -static int __pm8058_reset_pwr_off(struct pm8xxx_misc_chip *chip, int reset) -{ - int rc; - - /* When shutting down, enable active pulldowns on important rails. */ - if (!reset) { - /* Disable SMPS's 0,1,3 locally and set pulldown enable bits. */ - __pm8058_disable_smps_locally_set_pull_down(chip, - REG_PM8058_S0_CTRL, REG_PM8058_S0_TEST2, - REG_PM8058_VREG_EN_MSM, BIT(7)); - __pm8058_disable_smps_locally_set_pull_down(chip, - REG_PM8058_S1_CTRL, REG_PM8058_S1_TEST2, - REG_PM8058_VREG_EN_MSM, BIT(6)); - __pm8058_disable_smps_locally_set_pull_down(chip, - REG_PM8058_S3_CTRL, REG_PM8058_S3_TEST2, - REG_PM8058_VREG_EN_GRP_5_4, BIT(7) | BIT(4)); - /* Disable LDO 21 locally and set pulldown enable bit. */ - __pm8058_disable_ldo_locally_set_pull_down(chip, - REG_PM8058_L21_CTRL, REG_PM8058_VREG_EN_GRP_5_4, - BIT(1)); - } - - /* - * Fix-up: Set regulator LDO22 to 1.225 V in high power mode. Leave its - * pull-down state intact. This ensures a safe shutdown. - */ - rc = pm8xxx_misc_masked_write(chip, REG_PM8058_L22_CTRL, 0xBF, 0x93); - if (rc) { - pr_err("pm8xxx_misc_masked_write failed, rc=%d\n", rc); - goto read_write_err; - } - - /* Enable SMPL if resetting is desired. */ - rc = pm8xxx_misc_masked_write(chip, REG_PM8058_SLEEP_CTRL, - SLEEP_CTRL_SMPL_EN_MASK, - (reset ? SLEEP_CTRL_SMPL_EN_RESET : SLEEP_CTRL_SMPL_EN_PWR_OFF)); - if (rc) { - pr_err("pm8xxx_misc_masked_write failed, rc=%d\n", rc); - goto read_write_err; - } - - /* - * Select action to perform (reset or shutdown) when PS_HOLD goes low. - * Also ensure that KPD, CBL0, and CBL1 pull ups are enabled and that - * USB charging is enabled. - */ - rc = pm8xxx_misc_masked_write(chip, REG_PM8XXX_PON_CTRL_1, - PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN - | PON_CTRL_1_WD_EN_MASK, - PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN - | (reset ? PON_CTRL_1_WD_EN_RESET : PON_CTRL_1_WD_EN_PWR_OFF)); - if (rc) { - pr_err("pm8xxx_misc_masked_write failed, rc=%d\n", rc); - goto read_write_err; - } - -read_write_err: - return rc; -} - -static int __pm8901_reset_pwr_off(struct pm8xxx_misc_chip *chip, int reset) -{ - int rc = 0, i; - u8 pmr_addr[4] = { - REG_PM8901_REGULATOR_S2_PMR, - REG_PM8901_REGULATOR_S3_PMR, - REG_PM8901_REGULATOR_S4_PMR, - REG_PM8901_REGULATOR_S1_PMR, - }; - - /* Fix-up: Turn off regulators S1, S2, S3, S4 when shutting down. */ - if (!reset) { - for (i = 0; i < 4; i++) { - rc = pm8xxx_misc_masked_write(chip, pmr_addr[i], - PM8901_REGULATOR_PMR_STATE_MASK, - PM8901_REGULATOR_PMR_STATE_OFF); - if (rc) { - pr_err("pm8xxx_misc_masked_write failed, " - "rc=%d\n", rc); - goto read_write_err; - } - mdelay(PM8901_DELAY_AFTER_REG_DISABLE_MS); - } - } - -read_write_err: - mdelay(PM8901_DELAY_BEFORE_SHUTDOWN_MS); - return rc; -} - -static int __pm8921_reset_pwr_off(struct pm8xxx_misc_chip *chip, int reset) -{ - int rc; - - /* Enable SMPL if resetting is desired. */ - rc = pm8xxx_misc_masked_write(chip, REG_PM8921_SLEEP_CTRL, - SLEEP_CTRL_SMPL_EN_MASK, - (reset ? SLEEP_CTRL_SMPL_EN_RESET : SLEEP_CTRL_SMPL_EN_PWR_OFF)); - if (rc) { - pr_err("pm8xxx_misc_masked_write failed, rc=%d\n", rc); - goto read_write_err; - } - - /* - * Select action to perform (reset or shutdown) when PS_HOLD goes low. - * Also ensure that KPD, CBL0, and CBL1 pull ups are enabled and that - * USB charging is enabled. - */ - rc = pm8xxx_misc_masked_write(chip, REG_PM8XXX_PON_CTRL_1, - PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN - | PON_CTRL_1_WD_EN_MASK, - PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN - | (reset ? PON_CTRL_1_WD_EN_RESET : PON_CTRL_1_WD_EN_PWR_OFF)); - if (rc) { - pr_err("pm8xxx_misc_masked_write failed, rc=%d\n", rc); - goto read_write_err; - } - -read_write_err: - return rc; -} - -/** - * pm8xxx_reset_pwr_off - switch all PM8XXX PMIC chips attached to the system to - * either reset or shutdown when they are turned off - * @reset: 0 = shudown the PMICs, 1 = shutdown and then restart the PMICs - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_reset_pwr_off(int reset) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - rc = __pm8018_reset_pwr_off(chip, reset); - break; - case PM8XXX_VERSION_8058: - rc = __pm8058_reset_pwr_off(chip, reset); - break; - case PM8XXX_VERSION_8901: - rc = __pm8901_reset_pwr_off(chip, reset); - break; - case PM8XXX_VERSION_8038: - case PM8XXX_VERSION_8917: - case PM8XXX_VERSION_8921: - rc = __pm8921_reset_pwr_off(chip, reset); - break; - default: - /* PMIC doesn't have reset_pwr_off; do nothing. */ - break; - } - if (rc) { - pr_err("reset_pwr_off failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_reset_pwr_off); - -/** - * pm8xxx_smpl_control - enables/disables SMPL detection - * @enable: 0 = shutdown PMIC on power loss, 1 = reset PMIC on power loss - * - * This function enables or disables the Sudden Momentary Power Loss detection - * module. If SMPL detection is enabled, then when a sufficiently long power - * loss event occurs, the PMIC will automatically reset itself. If SMPL - * detection is disabled, then the PMIC will shutdown when power loss occurs. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_smpl_control(int enable) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8018_SLEEP_CTRL, SLEEP_CTRL_SMPL_EN_MASK, - (enable ? SLEEP_CTRL_SMPL_EN_RESET - : SLEEP_CTRL_SMPL_EN_PWR_OFF)); - break; - case PM8XXX_VERSION_8058: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8058_SLEEP_CTRL, SLEEP_CTRL_SMPL_EN_MASK, - (enable ? SLEEP_CTRL_SMPL_EN_RESET - : SLEEP_CTRL_SMPL_EN_PWR_OFF)); - break; - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8921_SLEEP_CTRL, SLEEP_CTRL_SMPL_EN_MASK, - (enable ? SLEEP_CTRL_SMPL_EN_RESET - : SLEEP_CTRL_SMPL_EN_PWR_OFF)); - break; - default: - /* PMIC doesn't have reset_pwr_off; do nothing. */ - break; - } - if (rc) { - pr_err("setting smpl control failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_smpl_control); - - -/** - * pm8xxx_smpl_set_delay - sets the SMPL detection time delay - * @delay: enum value corresponding to delay time - * - * This function sets the time delay of the SMPL detection module. If power - * is reapplied within this interval, then the PMIC reset automatically. The - * SMPL detection module must be enabled for this delay time to take effect. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - if (delay < SLEEP_CTRL_SMPL_SEL_MIN - || delay > SLEEP_CTRL_SMPL_SEL_MAX) { - pr_err("%s: invalid delay specified: %d\n", __func__, delay); - return -EINVAL; - } - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8018_SLEEP_CTRL, SLEEP_CTRL_SMPL_SEL_MASK, - delay); - break; - case PM8XXX_VERSION_8058: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8058_SLEEP_CTRL, SLEEP_CTRL_SMPL_SEL_MASK, - delay); - break; - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8921_SLEEP_CTRL, SLEEP_CTRL_SMPL_SEL_MASK, - delay); - break; - default: - /* PMIC doesn't have reset_pwr_off; do nothing. */ - break; - } - if (rc) { - pr_err("setting smpl delay failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_smpl_set_delay); - -/** - * pm8xxx_coincell_chg_config - Disables or enables the coincell charger, and - * configures its voltage and resistor settings. - * @chg_config: Holds both voltage and resistor values, and a - * switch to change the state of charger. - * If state is to disable the charger then - * both voltage and resistor are disregarded. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - u8 reg = 0, voltage, resistor; - int rc = 0; - - if (chg_config == NULL) { - pr_err("chg_config is NULL\n"); - return -EINVAL; - } - - voltage = chg_config->voltage; - resistor = chg_config->resistor; - - if (resistor > PM8XXX_COINCELL_RESISTOR_800_OHMS) { - pr_err("Invalid resistor value provided\n"); - return -EINVAL; - } - - if (voltage < PM8XXX_COINCELL_VOLTAGE_3p2V || - (voltage > PM8XXX_COINCELL_VOLTAGE_3p0V && - voltage != PM8XXX_COINCELL_VOLTAGE_2p5V)) { - pr_err("Invalid voltage value provided\n"); - return -EINVAL; - } - - if (chg_config->state == PM8XXX_COINCELL_CHG_DISABLE) { - reg = 0; - } else { - reg |= voltage; - reg |= (resistor << COINCELL_RESISTOR_SHIFT); - } - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - rc = pm8xxx_writeb(chip->dev->parent, - REG_PM8018_COIN_CHG, reg); - break; - case PM8XXX_VERSION_8058: - rc = pm8xxx_writeb(chip->dev->parent, - REG_PM8058_COIN_CHG, reg); - break; - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - rc = pm8xxx_writeb(chip->dev->parent, - REG_PM8921_COIN_CHG, reg); - break; - default: - /* PMIC doesn't have reset_pwr_off; do nothing. */ - break; - } - if (rc) { - pr_err("coincell chg. config failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_coincell_chg_config); - -/** - * pm8xxx_watchdog_reset_control - enables/disables watchdog reset detection - * @enable: 0 = shutdown when PS_HOLD goes low, 1 = reset when PS_HOLD goes low - * - * This function enables or disables the PMIC watchdog reset detection feature. - * If watchdog reset detection is enabled, then the PMIC will reset itself - * when PS_HOLD goes low. If it is not enabled, then the PMIC will shutdown - * when PS_HOLD goes low. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_watchdog_reset_control(int enable) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - case PM8XXX_VERSION_8058: - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8XXX_PON_CTRL_1, PON_CTRL_1_WD_EN_MASK, - (enable ? PON_CTRL_1_WD_EN_RESET - : PON_CTRL_1_WD_EN_PWR_OFF)); - break; - default: - /* WD reset control not supported */ - break; - } - if (rc) { - pr_err("setting WD reset control failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_watchdog_reset_control); - -/** - * pm8xxx_stay_on - enables stay_on feature - * - * PMIC stay-on feature allows PMIC to ignore MSM PS_HOLD=low - * signal so that some special functions like debugging could be - * performed. - * - * This feature should not be used in any product release. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_stay_on(void) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - case PM8XXX_VERSION_8058: - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - rc = pm8xxx_writeb(chip->dev->parent, - REG_PM8XXX_GP_TEST_1, PM8XXX_STAY_ON_CFG); - break; - default: - /* stay on not supported */ - break; - } - if (rc) { - pr_err("stay_on failed failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_stay_on); - -static int -__pm8xxx_hard_reset_config(struct pm8xxx_misc_chip *chip, - enum pm8xxx_pon_config config, u16 pon4_addr, u16 pon5_addr) -{ - int rc = 0; - - switch (config) { - case PM8XXX_DISABLE_HARD_RESET: - rc = pm8xxx_misc_masked_write(chip, pon5_addr, - PON_CTRL_5_HARD_RESET_EN_MASK, - PON_CTRL_5_HARD_RESET_DIS); - break; - case PM8XXX_SHUTDOWN_ON_HARD_RESET: - rc = pm8xxx_misc_masked_write(chip, pon5_addr, - PON_CTRL_5_HARD_RESET_EN_MASK, - PON_CTRL_5_HARD_RESET_EN); - if (!rc) { - rc = pm8xxx_misc_masked_write(chip, pon4_addr, - PON_CTRL_4_RESET_EN_MASK, - PON_CTRL_4_SHUTDOWN_ON_RESET); - } - break; - case PM8XXX_RESTART_ON_HARD_RESET: - rc = pm8xxx_misc_masked_write(chip, pon5_addr, - PON_CTRL_5_HARD_RESET_EN_MASK, - PON_CTRL_5_HARD_RESET_EN); - if (!rc) { - rc = pm8xxx_misc_masked_write(chip, pon4_addr, - PON_CTRL_4_RESET_EN_MASK, - PON_CTRL_4_RESTART_ON_RESET); - } - break; - default: - rc = -EINVAL; - break; - } - return rc; -} - -/** - * pm8xxx_hard_reset_config - Allows different reset configurations - * - * config = PM8XXX_DISABLE_HARD_RESET to disable hard reset - * = PM8XXX_SHUTDOWN_ON_HARD_RESET to turn off the system on hard reset - * = PM8XXX_RESTART_ON_HARD_RESET to restart the system on hard reset - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - __pm8xxx_hard_reset_config(chip, config, - REG_PM8018_PON_CNTL_4, REG_PM8018_PON_CNTL_5); - break; - case PM8XXX_VERSION_8058: - __pm8xxx_hard_reset_config(chip, config, - REG_PM8058_PON_CNTL_4, REG_PM8058_PON_CNTL_5); - break; - case PM8XXX_VERSION_8901: - __pm8xxx_hard_reset_config(chip, config, - REG_PM8901_PON_CNTL_4, REG_PM8901_PON_CNTL_5); - break; - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - __pm8xxx_hard_reset_config(chip, config, - REG_PM8921_PON_CNTL_4, REG_PM8921_PON_CNTL_5); - break; - default: - /* hard reset config. no supported */ - break; - } - if (rc) { - pr_err("hard reset config. failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_hard_reset_config); - -/* Handle the OSC_HALT interrupt: 32 kHz XTAL oscillator has stopped. */ -static irqreturn_t pm8xxx_osc_halt_isr(int irq, void *data) -{ - struct pm8xxx_misc_chip *chip = data; - u64 count = 0; - - if (chip) { - chip->osc_halt_count++; - count = chip->osc_halt_count; - } - - pr_crit("%s: OSC_HALT interrupt has triggered, 32 kHz XTAL oscillator" - " has halted (%llu)!\n", __func__, count); - - return IRQ_HANDLED; -} - -/** - * pm8xxx_uart_gpio_mux_ctrl - Mux configuration to select the UART - * - * @uart_path_sel: Input argument to select either UART1/2/3 - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8018: - case PM8XXX_VERSION_8058: - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8XXX_GPIO_MUX_CTRL, UART_PATH_SEL_MASK, - uart_path_sel << UART_PATH_SEL_SHIFT); - break; - default: - /* Functionality not supported */ - break; - } - if (rc) { - pr_err("uart_gpio_mux_ctrl failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_uart_gpio_mux_ctrl); - -/** - * pm8xxx_usb_id_pullup - Control a pullup for USB ID - * - * @enable: enable (1) or disable (0) the pullup - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_usb_id_pullup(int enable) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = -ENXIO; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8922: - case PM8XXX_VERSION_8917: - case PM8XXX_VERSION_8038: - rc = pm8xxx_misc_masked_write(chip, - REG_PM8XXX_GPIO_MUX_CTRL, USB_ID_PU_EN_MASK, - enable << USB_ID_PU_EN_SHIFT); - - if (rc) - pr_err("Fail: reg=%x, rc=%d\n", - REG_PM8XXX_GPIO_MUX_CTRL, rc); - break; - default: - /* Functionality not supported */ - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_usb_id_pullup); - -static int __pm8901_preload_dVdd(struct pm8xxx_misc_chip *chip) -{ - int rc; - - /* dVdd preloading is not needed for PMIC PM8901 rev 2.3 and beyond. */ - if (pm8xxx_get_revision(chip->dev->parent) >= PM8XXX_REVISION_8901_2p3) - return 0; - - rc = pm8xxx_writeb(chip->dev->parent, 0x0BD, 0x0F); - if (rc) - pr_err("pm8xxx_writeb failed for 0x0BD, rc=%d\n", rc); - - rc = pm8xxx_writeb(chip->dev->parent, 0x001, 0xB4); - if (rc) - pr_err("pm8xxx_writeb failed for 0x001, rc=%d\n", rc); - - pr_info("dVdd preloaded\n"); - - return rc; -} - -/** - * pm8xxx_preload_dVdd - preload the dVdd regulator during off state. - * - * This can help to reduce fluctuations in the dVdd voltage during startup - * at the cost of additional off state current draw. - * - * This API should only be called if dVdd startup issues are suspected. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_preload_dVdd(void) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8901: - rc = __pm8901_preload_dVdd(chip); - break; - default: - /* PMIC doesn't have preload_dVdd; do nothing. */ - break; - } - if (rc) { - pr_err("preload_dVdd failed, rc=%d\n", rc); - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_preload_dVdd); - -int pm8xxx_aux_clk_control(enum pm8xxx_aux_clk_id clk_id, - enum pm8xxx_aux_clk_div divider, bool enable) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - u8 clk_mask = 0, value = 0; - - if (clk_id == CLK_MP3_1) { - clk_mask = MP3_1_MASK; - value = divider << MP3_1_SHIFT; - } else if (clk_id == CLK_MP3_2) { - clk_mask = MP3_2_MASK; - value = divider << MP3_2_SHIFT; - } else { - pr_err("Invalid clock id of %d\n", clk_id); - return -EINVAL; - } - if (!enable) - value = 0; - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8038: - case PM8XXX_VERSION_8921: - case PM8XXX_VERSION_8917: - pm8xxx_misc_masked_write(chip, - REG_PM8XXX_XO_CNTRL_2, clk_mask, value); - break; - default: - /* Functionality not supported */ - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return 0; -} -EXPORT_SYMBOL_GPL(pm8xxx_aux_clk_control); - -int pm8xxx_hsed_bias_control(enum pm8xxx_hsed_bias bias, bool enable) -{ - struct pm8xxx_misc_chip *chip; - unsigned long flags; - int rc = 0; - u16 addr; - - switch (bias) { - case PM8XXX_HSED_BIAS0: - addr = REG_HSED_BIAS0_CNTL2; - break; - case PM8XXX_HSED_BIAS1: - addr = REG_HSED_BIAS1_CNTL2; - break; - case PM8XXX_HSED_BIAS2: - addr = REG_HSED_BIAS2_CNTL2; - break; - default: - pr_err("Invalid BIAS line\n"); - return -EINVAL; - } - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - - /* Loop over all attached PMICs and call specific functions for them. */ - list_for_each_entry(chip, &pm8xxx_misc_chips, link) { - switch (chip->version) { - case PM8XXX_VERSION_8058: - case PM8XXX_VERSION_8921: - rc = pm8xxx_misc_masked_write(chip, addr, - HSED_EN_MASK, enable ? HSED_EN_MASK : 0); - if (rc < 0) - pr_err("Enable HSED BIAS failed rc=%d\n", rc); - break; - default: - /* Functionality not supported */ - break; - } - } - - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_hsed_bias_control); - -static int pm8xxx_misc_probe(struct platform_device *pdev) -{ - const struct pm8xxx_misc_platform_data *pdata = pdev->dev.platform_data; - struct pm8xxx_misc_chip *chip; - struct pm8xxx_misc_chip *sibling; - struct list_head *prev; - unsigned long flags; - int rc = 0, irq; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct pm8xxx_misc_chip), GFP_KERNEL); - if (!chip) { - pr_err("Cannot allocate %d bytes\n", - sizeof(struct pm8xxx_misc_chip)); - return -ENOMEM; - } - - chip->dev = &pdev->dev; - chip->version = pm8xxx_get_version(chip->dev->parent); - memcpy(&(chip->pdata), pdata, sizeof(struct pm8xxx_misc_platform_data)); - - irq = platform_get_irq_byname(pdev, "pm8xxx_osc_halt_irq"); - if (irq > 0) { - rc = request_any_context_irq(irq, pm8xxx_osc_halt_isr, - IRQF_TRIGGER_RISING | IRQF_DISABLED, - "pm8xxx_osc_halt_irq", chip); - if (rc < 0) { - pr_err("%s: request_any_context_irq(%d) FAIL: %d\n", - __func__, irq, rc); - goto fail_irq; - } - } - - /* Insert PMICs in priority order (lowest value first). */ - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - prev = &pm8xxx_misc_chips; - list_for_each_entry(sibling, &pm8xxx_misc_chips, link) { - if (chip->pdata.priority < sibling->pdata.priority) - break; - else - prev = &sibling->link; - } - list_add(&chip->link, prev); - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - platform_set_drvdata(pdev, chip); - - return rc; - -fail_irq: - platform_set_drvdata(pdev, NULL); - kfree(chip); - return rc; -} - -static int pm8xxx_misc_remove(struct platform_device *pdev) -{ - struct pm8xxx_misc_chip *chip = platform_get_drvdata(pdev); - unsigned long flags; - int irq = platform_get_irq_byname(pdev, "pm8xxx_osc_halt_irq"); - if (irq > 0) - free_irq(irq, chip); - - spin_lock_irqsave(&pm8xxx_misc_chips_lock, flags); - list_del(&chip->link); - spin_unlock_irqrestore(&pm8xxx_misc_chips_lock, flags); - - platform_set_drvdata(pdev, NULL); - kfree(chip); - - return 0; -} - -static struct platform_driver pm8xxx_misc_driver = { - .probe = pm8xxx_misc_probe, - .remove = pm8xxx_misc_remove, - .driver = { - .name = PM8XXX_MISC_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_misc_init(void) -{ - return platform_driver_register(&pm8xxx_misc_driver); -} -postcore_initcall(pm8xxx_misc_init); - -static void __exit pm8xxx_misc_exit(void) -{ - platform_driver_unregister(&pm8xxx_misc_driver); -} -module_exit(pm8xxx_misc_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC 8XXX misc driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_MISC_DEV_NAME); diff --git a/drivers/mfd/pm8xxx-pwm.c b/drivers/mfd/pm8xxx-pwm.c deleted file mode 100644 index 3e6ca4ce73e11877b5b77e93986171eb8deb5e69..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8xxx-pwm.c +++ /dev/null @@ -1,1548 +0,0 @@ -/* Copyright (c) 2011-2013, 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. - */ -/* - * Qualcomm PM8XXX Pulse Width Modulation (PWM) driver - * - * The HW module is also called LPG (Light Pulse Generator). - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include - -#define PM8XXX_PWM_CHANNELS 3 - -/* - * For the lack of better term to distinguish functional - * differences, hereby, LPG version 0 (V0, v0) denotes - * PM8058/8921, and version 1 (V1, v1) denotes - * PM8922/8038. - */ -#define PM8XXX_LPG_V0_PWM_CHANNELS 8 -#define PM8XXX_LPG_V1_PWM_CHANNELS 6 -#define PM8XXX_LPG_CTL_REGS 8 - -/* PM8XXX PWM */ -#define SSBI_REG_ADDR_PWM1_CTRL1 0x88 -#define SSBI_REG_ADDR_PWM1_CTRL2 0x89 -#define SSBI_REG_ADDR_PWM_CTL(id, base) (id == 0 ? base : (base + (id << 1))) -#define SSBI_REG_ADDR_PWM_CTL1(id) SSBI_REG_ADDR_PWM_CTL(id, \ - SSBI_REG_ADDR_PWM1_CTRL1) -#define SSBI_REG_ADDR_PWM_CTL2(id) SSBI_REG_ADDR_PWM_CTL(id, \ - SSBI_REG_ADDR_PWM1_CTRL2) - -#define PM8XXX_PWM_CLK_SEL_SHIFT 6 -#define PM8XXX_PWM_CLK_SEL_MASK 0xC0 -#define PM8XXX_PWM_PREDIVIDE_SHIFT 5 -#define PM8XXX_PWM_PREDIVIDE_MASK 0x20 -#define PM8XXX_PWM_M_SHIFT 2 -#define PM8XXX_PWM_M_MASK 0x1C -#define PM8XXX_PWM_SIZE_SHIFT 1 -#define PM8XXX_PWM_SIZE_MASK 0x02 -#define PM8XXX_PWM_VALUE_BIT0 0x01 -#define PM8XXX_PWM_DISABLE 0x3F - -/* PM8XXX LPG PWM */ -#define SSBI_REG_ADDR_LPG_BANK_LOW_EN 0x130 -#define SSBI_REG_ADDR_LPG_CTL_BASE 0x13C -#define SSBI_REG_ADDR_LPG_CTL(n) (SSBI_REG_ADDR_LPG_CTL_BASE + (n)) -#define SSBI_REG_ADDR_LPG_BANK_SEL 0x143 -#define SSBI_REG_ADDR_LPG_BANK_HIGH_EN 0x144 -#define SSBI_REG_ADDR_LPG_LUT_CFG0 0x145 -#define SSBI_REG_ADDR_LPG_LUT_CFG1 0x146 -#define SSBI_REG_ADDR_LPG_TEST 0x147 -#define SSBI_REG_ADDR_LPG_CTL_7 0x14D - -/* LPG Control 0 */ -#define PM8XXX_PWM_1KHZ_COUNT_MASK 0xF0 -#define PM8XXX_PWM_1KHZ_COUNT_SHIFT 4 - -#define PM8XXX_PWM_1KHZ_COUNT_MAX 15 - -#define PM8XXX_PWM_OUTPUT_EN 0x08 -#define PM8XXX_PWM_PWM_EN 0x04 -#define PM8XXX_PWM_RAMP_GEN_EN 0x02 -#define PM8XXX_PWM_RAMP_START 0x01 - -#define PM8XXX_PWM_PWM_START (PM8XXX_PWM_OUTPUT_EN \ - | PM8XXX_PWM_PWM_EN) -#define PM8XXX_PWM_RAMP_GEN_START (PM8XXX_PWM_RAMP_GEN_EN \ - | PM8XXX_PWM_RAMP_START) - -/* LPG Control 1 */ -#define PM8XXX_PWM_REVERSE_EN 0x80 -#define PM8XXX_PWM_BYPASS_LUT 0x40 -#define PM8XXX_PWM_HIGH_INDEX_MASK 0x3F - -/* LPG Control 2 */ -#define PM8XXX_PWM_LOOP_EN 0x80 -#define PM8XXX_PWM_RAMP_UP 0x40 -#define PM8XXX_PWM_LOW_INDEX_MASK 0x3F - -/* LPG Control 3 */ -#define PM8XXX_PWM_VALUE_BIT7_0 0xFF -#define PM8XXX_PWM_VALUE_BIT5_0 0x3F - -/* LPG Control 4 */ -#define PM8XXX_PWM_VALUE_BIT8 0x80 - -#define PM8XXX_LPG_PWM_CLK_SEL_MASK 0x60 -#define PM8XXX_LPG_PWM_CLK_SEL_SHIFT 5 - -#define PM8XXX_PWM_CLK_SEL_NO 0 -#define PM8XXX_PWM_CLK_SEL_1KHZ 1 -#define PM8XXX_PWM_CLK_SEL_32KHZ 2 -#define PM8XXX_PWM_CLK_SEL_19P2MHZ 3 - -#define PM8XXX_LPG_PWM_PREDIVIDE_MASK 0x18 -#define PM8XXX_LPG_PWM_PREDIVIDE_SHIFT 3 - -#define PM8XXX_PWM_PREDIVIDE_2 0 -#define PM8XXX_PWM_PREDIVIDE_3 1 -#define PM8XXX_PWM_PREDIVIDE_5 2 -#define PM8XXX_PWM_PREDIVIDE_6 3 - -#define PM8XXX_LPG_PWM_M_MASK 0x07 -#define PM8XXX_PWM_M_MIN 0 -#define PM8XXX_PWM_M_MAX 7 - -/* LPG Control 5 */ -#define PM8XXX_PWM_PAUSE_COUNT_HI_MASK 0xFC -#define PM8XXX_PWM_PAUSE_COUNT_HI_SHIFT 2 - -#define PM8XXX_PWM_PAUSE_ENABLE_HIGH 0x02 -#define PM8XXX_PWM_SIZE_9_BIT 0x01 -#define PM8XXX_PWM_SIZE_7_BIT 0x04 - -/* LPG Control 6 */ -#define PM8XXX_PWM_PAUSE_COUNT_LO_MASK 0xFC -#define PM8XXX_PWM_PAUSE_COUNT_LO_SHIFT 2 - -#define PM8XXX_PWM_PAUSE_ENABLE_LOW 0x02 -#define PM8XXX_PWM_RESERVED 0x01 - -#define PM8XXX_PWM_PAUSE_COUNT_MAX 56 /* < 2^6 = 64 */ - -/* LPG LUT_CFG1 */ -#define PM8XXX_PWM_LUT_READ 0x40 - -/* TEST */ -#define PM8XXX_PWM_DTEST_MASK 0x38 -#define PM8XXX_PWM_DTEST_SHIFT 3 -#define PM8XXX_PWM_DTEST_BANK_MASK 0x07 - -/* - * PWM Frequency = Clock Frequency / (N * T) - * or - * PWM Period = Clock Period * (N * T) - * where - * N = 2^9 or 2^6 for 9-bit or 6-bit PWM size - * T = Pre-divide * 2^m, where m = 0..7 (exponent) - * - * This is the formula to figure out m for the best pre-divide and clock: - * (PWM Period / N) = (Pre-divide * Clock Period) * 2^m - */ -#define NUM_CLOCKS 3 - -#define NSEC_1024HZ (NSEC_PER_SEC / 1024) -#define NSEC_32768HZ (NSEC_PER_SEC / 32768) -#define NSEC_19P2MHZ (NSEC_PER_SEC / 19200000) - -#define NUM_LPG_PRE_DIVIDE 4 -#define NUM_PWM_PRE_DIVIDE 2 - -#define PRE_DIVIDE_1 1 /* v1 */ -#define PRE_DIVIDE_2 2 -#define PRE_DIVIDE_3 3 -#define PRE_DIVIDE_5 5 -#define PRE_DIVIDE_6 6 - -static unsigned int pt_t[NUM_LPG_PRE_DIVIDE][NUM_CLOCKS] = { - { PRE_DIVIDE_2 * NSEC_1024HZ, - PRE_DIVIDE_2 * NSEC_32768HZ, - PRE_DIVIDE_2 * NSEC_19P2MHZ, - }, - { PRE_DIVIDE_3 * NSEC_1024HZ, - PRE_DIVIDE_3 * NSEC_32768HZ, - PRE_DIVIDE_3 * NSEC_19P2MHZ, - }, - { PRE_DIVIDE_5 * NSEC_1024HZ, - PRE_DIVIDE_5 * NSEC_32768HZ, - PRE_DIVIDE_5 * NSEC_19P2MHZ, - }, - { PRE_DIVIDE_6 * NSEC_1024HZ, - PRE_DIVIDE_6 * NSEC_32768HZ, - PRE_DIVIDE_6 * NSEC_19P2MHZ, - }, -}; - -struct pm8xxx_pwm_channel_data { - struct pm8xxx_pwm_period period; - u8 pwm_lpg_ctl[PM8XXX_LPG_CTL_REGS]; - u8 pwm_ctl1; - u8 pwm_ctl2; - int pwm_value; - int pwm_duty; - int bypass_lut; - int dtest_mode_supported; - int banks; -}; - -struct pm8xxx_pwm_chip { - struct pm8xxx_pwm_channel_data *channels; - struct mutex pwm_mutex; - struct device *dev; - struct pwm_chip chip; - u8 pwm_channels; - u8 pwm_total_pre_divs; - u8 lo_bank_mask; - u8 hi_bank_mask; -#define PM8XXX_FEATURE_LPG_SUPPORTED (1 << 0) -#define PM8XXX_FEATURE_PWM_ENABLE_SYNC (1 << 1) - u32 feature_flags; - int current_channel; -}; - -struct pm8xxx_pwm_lut { - /* LUT parameters */ - int lut_duty_ms; - int lut_lo_index; - int lut_hi_index; - int lut_pause_hi; - int lut_pause_lo; - int flags; -}; - -static const u16 duty_msec[PM8XXX_PWM_1KHZ_COUNT_MAX + 1] = { - 0, 1, 2, 3, 4, 6, 8, 16, 18, 24, 32, 36, 64, 128, 256, 512 -}; - -static const u16 pause_count[PM8XXX_PWM_PAUSE_COUNT_MAX + 1] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 23, 28, 31, 42, 47, 56, 63, 83, 94, 111, 125, 167, 188, 222, 250, 333, - 375, 500, 667, 750, 800, 900, 1000, 1100, - 1200, 1300, 1400, 1500, 1600, 1800, 2000, 2500, - 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, - 7000 -}; - -/* Internal functions */ -static inline struct pm8xxx_pwm_chip *pm8xxx_pwm_from_pwm_dev( - struct pwm_device *pwm) -{ - return container_of(pwm->chip, struct pm8xxx_pwm_chip, chip); -} - -static inline struct pm8xxx_pwm_chip *pm8xxx_pwm_from_pwm_chip( - struct pwm_chip *chip) -{ - return container_of(chip, struct pm8xxx_pwm_chip, chip); -} - -static void pm8xxx_pwm_save(u8 *u8p, u8 mask, u8 val) -{ - *u8p &= ~mask; - *u8p |= val & mask; -} - -static int pm8xxx_pwm_bank_enable(struct pm8xxx_pwm_chip *chip, int enable) -{ - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel]; - int rc; - u8 reg; - - if (!cdata->banks) - cdata->banks = (PM_PWM_BANK_LO | PM_PWM_BANK_HI); - - if (cdata->banks & PM_PWM_BANK_LO) { - if (enable) - reg = chip->lo_bank_mask | - (1 << chip->current_channel); - else - reg = chip->lo_bank_mask & - ~(1 << chip->current_channel); - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_LPG_BANK_LOW_EN, reg); - if (rc) { - pr_err("pm8xxx_writeb(): Enable Bank Low =%d\n", rc); - return rc; - } - - chip->lo_bank_mask = reg; - } - - if (cdata->banks & PM_PWM_BANK_HI) { - if (enable) - reg = chip->lo_bank_mask | - (1 << chip->current_channel); - else - reg = chip->lo_bank_mask & - ~(1 << chip->current_channel); - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_LPG_BANK_HIGH_EN, reg); - if (rc) { - pr_err("pm8xxx_writeb(): Enable Bank High =%d\n", rc); - return rc; - } - - chip->hi_bank_mask = reg; - } - return 0; -} - -static int pm8xxx_pwm_bank_sel(struct pm8xxx_pwm_chip *chip) -{ - int rc; - - rc = pm8xxx_writeb(chip->dev->parent, SSBI_REG_ADDR_LPG_BANK_SEL, - chip->current_channel); - if (rc) - pr_err("pm8xxx_writeb(): rc=%d (Select PWM Bank)\n", rc); - return rc; -} - -static int pm8xxx_pwm_start(struct pm8xxx_pwm_chip *chip, - int start, int ramp_start) -{ - int rc; - u8 reg; - - if (start) { - reg = chip->channels[chip->current_channel].pwm_lpg_ctl[0] | - PM8XXX_PWM_PWM_START; - if (ramp_start) - reg |= PM8XXX_PWM_RAMP_GEN_START; - else - reg &= ~PM8XXX_PWM_RAMP_GEN_START; - } else { - reg = chip->channels[chip->current_channel].pwm_lpg_ctl[0] & - ~PM8XXX_PWM_PWM_START; - reg &= ~PM8XXX_PWM_RAMP_GEN_START; - } - - rc = pm8xxx_writeb(chip->dev->parent, SSBI_REG_ADDR_LPG_CTL(0), reg); - if (rc) - pr_err("pm8xxx_writeb(): rc=%d (Enable PWM Ctl 0)\n", rc); - else - chip->channels[chip->current_channel].pwm_lpg_ctl[0] = reg; - return rc; -} - -static int _pm8xxx_pwm_disable(struct pm8xxx_pwm_chip *chip) -{ - int rc; - u8 reg; - - reg = chip->channels[chip->current_channel].pwm_ctl1 & - PM8XXX_PWM_DISABLE; - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_PWM_CTL1(chip->current_channel), reg); - - if (rc) - pr_err("pm8xxx_writeb(): rc=%d (Disable PWM Ctl %d)\n", rc, - chip->current_channel); - return rc; -} - -static int _pm8xxx_pwm_enable(struct pm8xxx_pwm_chip *chip) -{ - /** - * A kind of best Effort: Just write the clock information that - * we have in the register. - */ - int rc; - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_PWM_CTL1(chip->current_channel), - chip->channels[chip->current_channel].pwm_ctl1); - - if (rc) - pr_err("pm8xxx_writeb(): rc=%d (Enable PWM Ctl %d)\n", rc, - chip->current_channel); - return rc; -} - -static void pm8xxx_pwm_calc_period(struct pm8xxx_pwm_chip *chip, - unsigned int period_us, struct pm8xxx_pwm_period *period) -{ - int n, m, clk, div; - int best_m, best_div, best_clk; - unsigned int last_err, cur_err, min_err; - unsigned int tmp_p, period_n; - struct pm8xxx_pwm_period *period = &pwm->period; - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel] - - if (cdata->banks == PM_PWM_BANK_LO) - n = 7; - else - n = 6; - - /* PWM Period / N */ - if (period_us < ((unsigned)(-1) / NSEC_PER_USEC)) { - period_n = (period_us * NSEC_PER_USEC) >> n; - } else { - period_n = (period_us >> 9) * NSEC_PER_USEC; - n = 9; - } - - min_err = last_err = (unsigned)(-1); - best_m = 0; - best_clk = 0; - best_div = 0; - for (clk = 0; clk < NUM_CLOCKS; clk++) { - for (div = 0; div < chip->pwm_total_pre_divs; div++) { - /* period_n = (PWM Period / N) */ - /* tmp_p = (Pre-divide * Clock Period) * 2^m */ - tmp_p = pt_t[div][clk]; - for (m = 0; m <= PM8XXX_PWM_M_MAX; m++) { - if (period_n > tmp_p) - cur_err = period_n - tmp_p; - else - cur_err = tmp_p - period_n; - - if (cur_err < min_err) { - min_err = cur_err; - best_m = m; - best_clk = clk; - best_div = div; - } - - if (m && cur_err > last_err) - /* Break for bigger cur_err */ - break; - - last_err = cur_err; - tmp_p <<= 1; - } - } - } - - /* Use higher resolution */ - if (best_m >= 3 && n == 6) { - n += 3; - best_m -= 3; - } - - period->pwm_size = n; - period->clk = best_clk; - period->pre_div = best_div; - period->pre_div_exp = best_m; -} - -static void pm8xxx_pwm_calc_pwm_value(struct pm8xxx_pwm_chip *chip, - unsigned int period_us, - unsigned int duty_us) -{ - unsigned int max_pwm_value, tmp; - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel]; - - /* Figure out pwm_value with overflow handling */ - tmp = 1 << (sizeof(tmp) * 8 - cdata->period.pwm_size); - if (duty_us < tmp) { - tmp = duty_us << cdata->period.pwm_size; - cdata->pwm_value = tmp / period_us; - } else { - tmp = period_us >> cdata->period.pwm_size; - cdata->pwm_value = duty_us / tmp; - } - max_pwm_value = (1 << cdata->period.pwm_size) - 1; - if (cdata->pwm_value > max_pwm_value) - cdata->pwm_value = max_pwm_value; -} - -static int pm8xxx_pwm_change_table(struct pm8xxx_pwm_chip *chip, int duty_pct[], - int start_idx, int len, int raw_value) -{ - unsigned int pwm_value, max_pwm_value; - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel]; - u8 cfg0, cfg1; - int i, pwm_size; - int rc = 0; - - pwm_size = (cdata->pwm_lpg_ctl[5] & PM8XXX_PWM_SIZE_9_BIT) ? 9 : 6; - if (cdata->period.pwm_size == 7) - pwm_size = 7; - - max_pwm_value = (1 << pwm_size) - 1; - for (i = 0; i < len; i++) { - if (raw_value) - pwm_value = duty_pct[i]; - else - pwm_value = (duty_pct[i] << pwm_size) / 100; - - if (pwm_value > max_pwm_value) - pwm_value = max_pwm_value; - cfg0 = pwm_value; - cfg1 = (pwm_value >> 1) & 0x80; - cfg1 |= start_idx + i; - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_LPG_LUT_CFG0, cfg0); - if (rc) - break; - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_LPG_LUT_CFG1, cfg1); - if (rc) - break; - } - return rc; -} - -static void pm8xxx_pwm_save_index(struct pm8xxx_pwm_channel_data *cdata, - int low_idx, int high_idx, int flags) -{ - cdata->pwm_lpg_ctl[1] = high_idx & PM8XXX_PWM_HIGH_INDEX_MASK; - cdata->pwm_lpg_ctl[2] = low_idx & PM8XXX_PWM_LOW_INDEX_MASK; - - if (flags & PM_PWM_LUT_REVERSE) - cdata->pwm_lpg_ctl[1] |= PM8XXX_PWM_REVERSE_EN; - if (flags & PM_PWM_LUT_RAMP_UP) - cdata->pwm_lpg_ctl[2] |= PM8XXX_PWM_RAMP_UP; - if (flags & PM_PWM_LUT_LOOP) - cdata->pwm_lpg_ctl[2] |= PM8XXX_PWM_LOOP_EN; -} - -static void pm8xxx_pwm_save_period(struct pm8xxx_pwm_chip *chip) -{ - u8 mask, val; - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel]; - struct pm8xxx_pwm_period *period = &cdata->period; - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - val = ((period->clk + 1) << PM8XXX_LPG_PWM_CLK_SEL_SHIFT) - & PM8XXX_LPG_PWM_CLK_SEL_MASK; - val |= (period->pre_div << PM8XXX_LPG_PWM_PREDIVIDE_SHIFT) - & PM8XXX_LPG_PWM_PREDIVIDE_MASK; - val |= period->pre_div_exp & PM8XXX_LPG_PWM_M_MASK; - mask = PM8XXX_LPG_PWM_CLK_SEL_MASK | - PM8XXX_LPG_PWM_PREDIVIDE_MASK | PM8XXX_LPG_PWM_M_MASK; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[4], mask, val); - - if (cdata->period.pwm_size == 7) { - val = PM8XXX_PWM_SIZE_7_BIT; - mask = PM8XXX_PWM_SIZE_7_BIT; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[7], mask, val); - } else { - val = (cdata->period.pwm_size > 6) ? - PM8XXX_PWM_SIZE_9_BIT : 0; - mask = PM8XXX_PWM_SIZE_9_BIT; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[5], mask, val); - } - - mask = PM8XXX_PWM_SIZE_9_BIT; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[5], mask, val); - } else { - val = ((period->clk + 1) << PM8XXX_PWM_CLK_SEL_SHIFT) - & PM8XXX_PWM_CLK_SEL_MASK; - val |= (period->pre_div << PM8XXX_PWM_PREDIVIDE_SHIFT) - & PM8XXX_PWM_PREDIVIDE_MASK; - val |= (period->pre_div_exp << PM8XXX_PWM_M_SHIFT) - & PM8XXX_PWM_M_MASK; - val |= (((period->pwm_size > 6) ? PM8XXX_PWM_SIZE_9_BIT : 0) - << PM8XXX_PWM_SIZE_SHIFT) & PM8XXX_PWM_SIZE_MASK; - - mask = PM8XXX_PWM_CLK_SEL_MASK | PM8XXX_PWM_PREDIVIDE_MASK | - PM8XXX_PWM_M_MASK | PM8XXX_PWM_SIZE_MASK; - pm8xxx_pwm_save(&cdata->pwm_ctl1, mask, val); - } -} - -static void pm8xxx_pwm_save_pwm_value(struct pm8xxx_pwm_chip *chip) -{ - u8 mask, val; - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel]; - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - val = (cdata->period.pwm_size > 6) ? - (cdata->pwm_value >> 1) : 0; - cdata->pwm_lpg_ctl[3] = cdata->pwm_value; - mask = PM8XXX_PWM_VALUE_BIT8; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[4], mask, val); - } else { - val = (cdata->period.pwm_size > 6) ? - (cdata->pwm_value >> 8) : 0; - cdata->pwm_ctl2 = cdata->pwm_value; - mask = PM8XXX_PWM_VALUE_BIT0; - pm8xxx_pwm_save(&cdata->pwm_ctl1, mask, val); - } -} - -static void pm8xxx_pwm_save_duty_time(struct pm8xxx_pwm_channel_data *cdata, - struct pm8xxx_pwm_lut *lut) -{ - int i; - u8 mask, val; - - /* Linear search for duty time */ - for (i = 0; i < PM8XXX_PWM_1KHZ_COUNT_MAX; i++) { - if (duty_msec[i] >= lut->lut_duty_ms) - break; - } - val = i << PM8XXX_PWM_1KHZ_COUNT_SHIFT; - - mask = PM8XXX_PWM_1KHZ_COUNT_MASK; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[0], mask, val); -} - -static void pm8xxx_pwm_save_pause(struct pm8xxx_pwm_channel_data *cdata, - struct pm8xxx_pwm_lut *lut) -{ - int i, pause_cnt, time_cnt; - u8 mask, val; - - time_cnt = (cdata->pwm_lpg_ctl[0] & PM8XXX_PWM_1KHZ_COUNT_MASK) - >> PM8XXX_PWM_1KHZ_COUNT_SHIFT; - if (lut->flags & PM_PWM_LUT_PAUSE_HI_EN) { - pause_cnt = (lut->lut_pause_hi + duty_msec[time_cnt] / 2) - / duty_msec[time_cnt]; - /* Linear search for pause time */ - for (i = 0; i < PM8XXX_PWM_PAUSE_COUNT_MAX; i++) { - if (pause_count[i] >= pause_cnt) - break; - } - val = (i << PM8XXX_PWM_PAUSE_COUNT_HI_SHIFT) & - PM8XXX_PWM_PAUSE_COUNT_HI_MASK; - val |= PM8XXX_PWM_PAUSE_ENABLE_HIGH; - } else { - val = 0; - } - - mask = PM8XXX_PWM_PAUSE_COUNT_HI_MASK | PM8XXX_PWM_PAUSE_ENABLE_HIGH; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[5], mask, val); - - if (lut->flags & PM_PWM_LUT_PAUSE_LO_EN) { - /* Linear search for pause time */ - pause_cnt = (lut->lut_pause_lo + duty_msec[time_cnt] / 2) - / duty_msec[time_cnt]; - for (i = 0; i < PM8XXX_PWM_PAUSE_COUNT_MAX; i++) { - if (pause_count[i] >= pause_cnt) - break; - } - val = (i << PM8XXX_PWM_PAUSE_COUNT_LO_SHIFT) & - PM8XXX_PWM_PAUSE_COUNT_LO_MASK; - val |= PM8XXX_PWM_PAUSE_ENABLE_LOW; - } else { - val = 0; - } - - mask = PM8XXX_PWM_PAUSE_COUNT_LO_MASK | PM8XXX_PWM_PAUSE_ENABLE_LOW; - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[6], mask, val); -} - -static int pm8xxx_pwm_write(struct pm8xxx_pwm_chip *chip) -{ - int rc = 0; - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel]; - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_PWM_CTL1(chip->current_channel), - cdata->pwm_ctl1); - if (rc) { - pr_err("pm8xxx_writeb() failed: rc=%d (PWM Ctl1[%d])\n", - rc, chip->current_channel); - return rc; - } - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_PWM_CTL2(chip->current_channel), - cdata->pwm_ctl2); - if (rc) { - pr_err("pm8xxx_writeb() failed: rc=%d (PWM Ctl2[%d])\n", - rc, chip->current_channel); - return rc; - } - - return rc; -} - -static int pm8xxx_lpg_pwm_write(struct pm8xxx_pwm_chip *chip, - int start, int end) -{ - int i, rc; - - if (end == 7) { - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_LPG_CTL_7, - chip->channels[chip->current_channel].pwm_lpg_ctl[end]); - if (rc) { - pr_err("pm8xxx_writeb(): rc=%d (PWM Ctl[7])\n", rc); - return rc; - } - } - - /* Write in reverse way so 0 would be the last */ - for (i = end - 2; i >= start; i--) { - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_LPG_CTL(i), - chip->channels[chip->current_channel].pwm_lpg_ctl[i]); - if (rc) { - pr_err("pm8xxx_writeb(): rc=%d (PWM Ctl[%d])\n", rc, i); - return rc; - } - } - - return 0; -} - -static int pm8xxx_pwm_change_lut(struct pm8xxx_pwm_chip *chip, - struct pm8xxx_pwm_lut *lut) -{ - int rc; - struct pm8xxx_pwm_channel_data *cdata = - &chip->channels[chip->current_channel]; - - pm8xxx_pwm_save_index(cdata, lut->lut_lo_index, - lut->lut_hi_index, lut->flags); - pm8xxx_pwm_save_duty_time(cdata, lut); - pm8xxx_pwm_save_pause(cdata, lut); - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[1], PM8XXX_PWM_BYPASS_LUT, 0); - - pm8xxx_pwm_bank_sel(chip); - rc = pm8xxx_lpg_pwm_write(chip, 0, 7); - - return rc; -} - -static int pm8xxx_pwm_set_dtest(struct pm8xxx_pwm_chip *chip, int enable) -{ - int rc; - u8 reg; - - reg = chip->current_channel & PM8XXX_PWM_DTEST_BANK_MASK; - - if (enable) { - /* Observe LPG_OUT on DTEST1*/ - reg |= (1 << PM8XXX_PWM_DTEST_SHIFT) & - PM8XXX_PWM_DTEST_MASK; - } - - rc = pm8xxx_writeb(chip->dev->parent, - SSBI_REG_ADDR_LPG_TEST, reg); - if (rc) - pr_err("pm8xxx_write(DTEST=0x%x) failed: rc=%d\n", - reg, rc); - - return rc; -} - -/* APIs */ -/** - * pm8xxx_pwm_free - free a PWM device - * @pwm_chip: the PWM chip - * @pwm: the PWM device - */ -void pm8xxx_pwm_free(struct pwm_chip *pwm_chip, struct pwm_device *pwm) -{ - struct pm8xxx_pwm_chip *chip = pm8xxx_pwm_from_pwm_chip(pwm_chip); - - chip->current_channel = pwm->hwpwm; - - mutex_lock(&chip->pwm_mutex); - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - pm8xxx_pwm_bank_sel(chip); - pm8xxx_pwm_start(chip, 0, 0); - } else { - _pm8xxx_pwm_disable(chip); - } - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) - pm8xxx_pwm_bank_enable(chip, 0); - - mutex_unlock(&chip->pwm_mutex); -} - -/** - * pm8xxx_pwm_config - change a PWM device configuration - * @pwm_chip: the PWM chip - * @pwm: the PWM device - * @period_us: period in microseconds - * @duty_us: duty cycle in microseconds - */ -int pm8xxx_pwm_config(struct pwm_chip *pwm_chip, struct pwm_device *pwm, - int duty_us, int period_us) -{ - struct pm8xxx_pwm_chip *chip = pm8xxx_pwm_from_pwm_chip(pwm_chip); - struct pm8xxx_pwm_period *period; - int rc = 0; - - if ((unsigned)period_us > PM8XXX_PWM_PERIOD_MAX || - (unsigned)period_us < PM8XXX_PWM_PERIOD_MIN) { - pr_err("Invalid parameters\n"); - return -EINVAL; - } - - chip->current_channel = pwm->hwpwm; - period = &chip->channels[pwm->hwpwm].period; - - mutex_lock(&chip->pwm_mutex); - - if (pwm->period != period_us) { - pm8xxx_pwm_calc_period(chip, period_us, period); - pm8xxx_pwm_save_period(chip); - pwm->period = period_us; - } - - pm8xxx_pwm_calc_pwm_value(chip, period_us, duty_us); - pm8xxx_pwm_save_pwm_value(chip); - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - pm8xxx_pwm_save( - &chip->channels[chip->current_channel].pwm_lpg_ctl[1], - PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT); - - pm8xxx_pwm_bank_sel(chip); - rc = pm8xxx_lpg_pwm_write(chip, 1, 7); - } else { - rc = pm8xxx_pwm_write(chip); - } - - pr_debug("duty/period=%u/%u usec: pwm_value=%d (of %d)\n", - (unsigned)duty_us, (unsigned)period_us, - chip->channels[chip->current_channel].pwm_value, - 1 << period->pwm_size); - - mutex_unlock(&chip->pwm_mutex); - return rc; -} - -/** - * pm8xxx_pwm_enable - start a PWM output toggling - * @pwm_chip: the PWM chip - * @pwm: the PWM device - */ -int pm8xxx_pwm_enable(struct pwm_chip *pwm_chip, struct pwm_device *pwm) -{ - int rc = 0; - struct pm8xxx_pwm_chip *chip = pm8xxx_pwm_from_pwm_chip(pwm_chip); - chip->current_channel = pwm->hwpwm; - - mutex_lock(&chip->pwm_mutex); - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - if (chip->channels[pwm->hwpwm].dtest_mode_supported) - pm8xxx_pwm_set_dtest(chip, 1); - - pm8xxx_pwm_bank_sel(chip); - rc = pm8xxx_pwm_bank_enable(chip, 1); - pm8xxx_pwm_start(chip, 1, 0); - - /* In PM8038, due to hardware bug, PWM_VALUE register - * needs to be written one more time after enabling - * PWM mode. - */ - if (chip->feature_flags & PM8XXX_FEATURE_PWM_ENABLE_SYNC) - rc = pm8xxx_lpg_pwm_write(pwm, 3, 5); - - } else { - _pm8xxx_pwm_enable(chip); - } - - mutex_unlock(&chip->pwm_mutex); - - return rc; -} - -/** - * pm8xxx_pwm_disable - stop a PWM output toggling - * @pwm_chip: the PWM chip - * @pwm: the PWM device - */ -void pm8xxx_pwm_disable(struct pwm_chip *pwm_chip, struct pwm_device *pwm) -{ - struct pm8xxx_pwm_chip *chip = pm8xxx_pwm_from_pwm_chip(pwm_chip); - chip->current_channel = pwm->hwpwm; - - mutex_lock(&chip->pwm_mutex); - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - if (chip->channels[pwm->hwpwm].dtest_mode_supported) - pm8xxx_pwm_set_dtest(chip, 0); - pm8xxx_pwm_bank_sel(chip); - pm8xxx_pwm_start(chip, 0, 0); - pm8xxx_pwm_bank_enable(chip, 0); - } else { - _pm8xxx_pwm_disable(chip); - } - - mutex_unlock(&chip->pwm_mutex); -} - -/** - * pm8xxx_pwm_config_period - change PWM period - * - * @pwm: the PWM device - * @pwm_p: period in struct pm8xxx_pwm_period - */ -int pm8xxx_pwm_config_period(struct pwm_device *pwm, - struct pm8xxx_pwm_period *period) -{ - int rc; - struct pm8xxx_pwm_chip *chip; - struct pm8xxx_pwm_channel_data *cdata; - - if (pwm == NULL || IS_ERR(pwm) || period == NULL) - return -EINVAL; - - chip = pm8xxx_pwm_from_pwm_dev(pwm); - chip->current_channel = pwm->hwpwm; - cdata = &chip->channels[pwm->hwpwm]; - - mutex_lock(&chip->pwm_mutex); - - cdata->period.pwm_size = period->pwm_size; - cdata->period.clk = period->clk; - cdata->period.pre_div = period->pre_div; - cdata->period.pre_div_exp = period->pre_div_exp; - - pm8xxx_pwm_save_period(chip); - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - pm8xxx_pwm_bank_sel(chip); - rc = pm8xxx_lpg_pwm_write(pwm, 4, 7); - } else { - rc = pm8xxx_pwm_write(chip); - } - - mutex_unlock(&chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_pwm_config_period); - -/** - * pm8xxx_pwm_config_pwm_value - change a PWM device configuration - * @pwm: the PWM device - * @pwm_value: the duty cycle in raw PWM value (< 2^pwm_size) - */ -int pm8xxx_pwm_config_pwm_value(struct pwm_device *pwm, int pwm_value) -{ - int rc = 0; - struct pm8xxx_pwm_chip *chip; - struct pm8xxx_pwm_channel_data *cdata; - - if (pwm == NULL || IS_ERR(pwm)) - return -EINVAL; - - chip = pm8xxx_pwm_from_pwm_dev(pwm); - chip->current_channel = pwm->hwpwm; - cdata = &chip->channels[pwm->hwpwm]; - - mutex_lock(&chip->pwm_mutex); - - if (!pwm->period) { - rc = -EINVAL; - goto out_unlock; - } - - if (cdata->pwm_value == pwm_value) - goto out_unlock; - - cdata->pwm_value = pwm_value; - - pm8xxx_pwm_save_pwm_value(chip); - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - pm8xxx_pwm_save(&cdata->pwm_lpg_ctl[1], - PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT); - - pm8xxx_pwm_bank_sel(chip); - rc = pm8xxx_lpg_pwm_write(chip, 1, 7); - } else { - rc = pm8xxx_pwm_write(chip); - } - - if (rc) - pr_err("[%d]: pm8xxx_pwm_write: rc=%d\n", pwm->hwpwm, rc); - -out_unlock: - mutex_unlock(&chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_pwm_config_pwm_value); - -/** - * pm8xxx_pwm_lut_config - change a PWM device configuration to use LUT - * @pwm: the PWM device - * @period_us: period in microseconds - * @duty_pct: arrary of duty cycles in percent, like 20, 50. - * @duty_time_ms: time for each duty cycle in milliseconds - * @start_idx: start index in lookup table from 0 to MAX-1 - * @idx_len: number of index - * @pause_lo: pause time in milliseconds at low index - * @pause_hi: pause time in milliseconds at high index - * @flags: control flags - */ -int pm8xxx_pwm_lut_config(struct pwm_device *pwm, int period_us, - int duty_pct[], int duty_time_ms, int start_idx, - int idx_len, int pause_lo, int pause_hi, int flags) -{ - struct pm8xxx_pwm_lut lut; - struct pm8xxx_pwm_period *period; - struct pm8xxx_pwm_chip *chip; - struct pm8xxx_pwm_channel_data *cdata; - int len; - int rc; - - if (pwm == NULL || IS_ERR(pwm) || !idx_len) { - pr_err("Invalid pwm handle or idx_len=0\n"); - return -EINVAL; - } - if (duty_pct == NULL && !(flags & PM_PWM_LUT_NO_TABLE)) { - pr_err("Invalid duty_pct with flag\n"); - return -EINVAL; - } - - chip = pm8xxx_pwm_from_pwm_dev(pwm); - - if (!(chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED)) { - pr_err("LPG module isn't supported\n"); - return -EINVAL; - } - - if (idx_len >= PM_PWM_LUT_SIZE && start_idx) { - pr_err("Wrong LUT size or index\n"); - return -EINVAL; - } - if ((start_idx + idx_len) > PM_PWM_LUT_SIZE) { - pr_err("Exceed LUT limit\n"); - return -EINVAL; - } - if ((unsigned)period_us > PM8XXX_PWM_PERIOD_MAX || - (unsigned)period_us < PM8XXX_PWM_PERIOD_MIN) { - pr_err("Period out of range\n"); - return -EINVAL; - } - - chip->current_channel = pwm->hwpwm; - cdata = &chip->channels[pwm->hwpwm]; - period = &cdata->period; - mutex_lock(&chip->pwm_mutex); - - if (flags & PM_PWM_BANK_HI) - cdata->banks = PM_PWM_BANK_HI; - - if (flags & PM_PWM_BANK_LO) - cdata->banks |= PM_PWM_BANK_LO; - - /*Enable both banks if banks information is not shared.*/ - if (!cdata->banks) - cdata->banks |= (PM_PWM_BANK_LO | PM_PWM_BANK_HI); - - if (pwm->period != period_us) { - pm8xxx_pwm_calc_period(chip, period_us, period); - pm8xxx_pwm_save_period(chip); - pwm->period = period_us; - } - - len = (idx_len > PM_PWM_LUT_SIZE) ? PM_PWM_LUT_SIZE : idx_len; - - if (flags & PM_PWM_LUT_NO_TABLE) - goto after_table_write; - - rc = pm8xxx_pwm_change_table(chip, duty_pct, start_idx, len, 0); - if (rc) { - pr_err("pm8xxx_pwm_change_table: rc=%d\n", rc); - goto out_unlock; - } - -after_table_write: - lut.lut_duty_ms = duty_time_ms; - lut.lut_lo_index = start_idx; - lut.lut_hi_index = start_idx + len - 1; - lut.lut_pause_lo = pause_lo; - lut.lut_pause_hi = pause_hi; - lut.flags = flags; - cdata->bypass_lut = 0; - - rc = pm8xxx_pwm_change_lut(chip, &lut); - -out_unlock: - mutex_unlock(&chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL_GPL(pm8xxx_pwm_lut_config); - -/** - * pm8xxx_pwm_lut_enable - control a PWM device to start/stop LUT ramp - * @pwm: the PWM device - * @start: to start (1), or stop (0) - */ -int pm8xxx_pwm_lut_enable(struct pwm_device *pwm, int start) -{ - struct pm8xxx_pwm_chip *chip; - - if (pwm == NULL || IS_ERR(pwm)) { - pr_err("Invalid pwm handle\n"); - return -EINVAL; - } - - chip = pm8xxx_pwm_from_pwm_dev(pwm); - chip->current_channel = pwm->hwpwm; - - if (!(chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED)) { - pr_err("LPG module isn't supported\n"); - return -EINVAL; - } - - mutex_lock(&chip->pwm_mutex); - if (start) { - if (chip->channels[pwm->hwpwm].dtest_mode_supported) - pm8xxx_pwm_set_dtest(chip, 1); - - pm8xxx_pwm_bank_sel(chip); - pm8xxx_pwm_bank_enable(chip, 1); - - pm8xxx_pwm_start(chip, 1, 1); - } else { - if (chip->channels[pwm->hwpwm].dtest_mode_supported) - pm8xxx_pwm_set_dtest(chip, 0); - - pm8xxx_pwm_bank_sel(chip); - pm8xxx_pwm_start(chip, 0, 0); - - pm8xxx_pwm_bank_enable(chip, 0); - } - mutex_unlock(&chip->pwm_mutex); - return 0; -} -EXPORT_SYMBOL_GPL(pm8xxx_pwm_lut_enable); - -#if defined(CONFIG_DEBUG_FS) - -struct pm8xxx_pwm_dbg_device; - -struct pm8xxx_pwm_user { - int pwm_id; - struct pwm_device *pwm; - int period; - int duty_cycle; - int enable; - struct pm8xxx_pwm_dbg_device *dbgdev; -}; - -struct pm8xxx_pwm_dbg_device { - struct mutex dbg_mutex; - struct device *dev; - struct dentry *dent; - - struct pm8xxx_pwm_user *user; -}; - -static struct pm8xxx_pwm_dbg_device *pmic_dbg_device; - -static int dbg_pwm_check_period(int period) -{ - if (period < PM8XXX_PWM_PERIOD_MIN || period > PM8XXX_PWM_PERIOD_MAX) { - pr_err("period is invalid: %d\n", period); - return -EINVAL; - } - return 0; -} - -static int dbg_pwm_check_duty_cycle(int duty_cycle, const char *func_name) -{ - if (duty_cycle <= 0 || duty_cycle > 100) { - pr_err("%s: duty_cycle is invalid: %d\n", - func_name, duty_cycle); - return -EINVAL; - } - return 0; -} - -static void dbg_pwm_check_handle(struct pm8xxx_pwm_user *puser) -{ - struct pwm_device *tmp; - - if (puser->pwm == NULL) { - tmp = pwm_request(puser->pwm_id, "pwm-dbg"); - if (PTR_ERR(puser->pwm)) { - pr_err("pwm_request: err=%ld\n", PTR_ERR(puser->pwm)); - puser->pwm = NULL; - } else { - pr_debug("[id=%d] pwm_request ok\n", puser->pwm_id); - puser->pwm = tmp; - } - } -} - -static int dbg_pwm_enable_set(void *data, u64 val) -{ - struct pm8xxx_pwm_user *puser = data; - struct pm8xxx_pwm_dbg_device *dbgdev = puser->dbgdev; - int rc; - - mutex_lock(&dbgdev->dbg_mutex); - rc = dbg_pwm_check_duty_cycle(puser->duty_cycle, __func__); - if (!rc) { - puser->enable = val; - dbg_pwm_check_handle(puser); - if (puser->pwm) { - if (puser->enable) - pwm_enable(puser->pwm); - else - pwm_disable(puser->pwm); - } - } - mutex_unlock(&dbgdev->dbg_mutex); - return 0; -} - -static int dbg_pwm_enable_get(void *data, u64 *val) -{ - struct pm8xxx_pwm_user *puser = data; - struct pm8xxx_pwm_dbg_device *dbgdev = puser->dbgdev; - - mutex_lock(&dbgdev->dbg_mutex); - *val = puser->enable; - mutex_unlock(&dbgdev->dbg_mutex); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(dbg_pwm_enable_fops, - dbg_pwm_enable_get, dbg_pwm_enable_set, - "%lld\n"); - -static int dbg_pwm_duty_cycle_set(void *data, u64 val) -{ - struct pm8xxx_pwm_user *puser = data; - struct pm8xxx_pwm_dbg_device *dbgdev = puser->dbgdev; - int rc; - - mutex_lock(&dbgdev->dbg_mutex); - rc = dbg_pwm_check_duty_cycle(val, __func__); - if (!rc) { - puser->duty_cycle = val; - dbg_pwm_check_handle(puser); - if (puser->pwm) { - int duty_us; - - duty_us = puser->duty_cycle * puser->period / 100; - pwm_config(puser->pwm, duty_us, puser->period); - } - } - mutex_unlock(&dbgdev->dbg_mutex); - return 0; -} - -static int dbg_pwm_duty_cycle_get(void *data, u64 *val) -{ - struct pm8xxx_pwm_user *puser = data; - struct pm8xxx_pwm_dbg_device *dbgdev = puser->dbgdev; - - mutex_lock(&dbgdev->dbg_mutex); - *val = puser->duty_cycle; - mutex_unlock(&dbgdev->dbg_mutex); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(dbg_pwm_duty_cycle_fops, - dbg_pwm_duty_cycle_get, dbg_pwm_duty_cycle_set, - "%lld\n"); - -static int dbg_pwm_period_set(void *data, u64 val) -{ - struct pm8xxx_pwm_user *puser = data; - struct pm8xxx_pwm_dbg_device *dbgdev = puser->dbgdev; - int rc; - - mutex_lock(&dbgdev->dbg_mutex); - rc = dbg_pwm_check_period(val); - if (!rc) - puser->period = val; - mutex_unlock(&dbgdev->dbg_mutex); - return 0; -} - -static int dbg_pwm_period_get(void *data, u64 *val) -{ - struct pm8xxx_pwm_user *puser = data; - struct pm8xxx_pwm_dbg_device *dbgdev = puser->dbgdev; - - mutex_lock(&dbgdev->dbg_mutex); - *val = puser->period; - mutex_unlock(&dbgdev->dbg_mutex); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(dbg_pwm_period_fops, - dbg_pwm_period_get, dbg_pwm_period_set, "%lld\n"); - -static int pm8xxx_pwm_dbg_probe(struct pm8xxx_pwm_chip *chip) -{ - struct pm8xxx_pwm_dbg_device *dbgdev; - struct dentry *dent; - struct dentry *temp; - struct pm8xxx_pwm_user *puser; - int i; - int rc = 0; - - if (chip->dev == NULL) { - pr_err("no parent data passed in.\n"); - return -EINVAL; - } - - dbgdev = kzalloc(sizeof *dbgdev, GFP_KERNEL); - if (dbgdev == NULL) { - pr_err("kzalloc() failed.\n"); - return -ENOMEM; - } - - dbgdev->user = kcalloc(chip->pwm_channels, - sizeof(struct pm8xxx_pwm_user), GFP_KERNEL); - if (dbgdev->user == NULL) { - pr_err("kcalloc() failed.\n"); - rc = -ENOMEM; - goto user_error; - } - - mutex_init(&dbgdev->dbg_mutex); - - dbgdev->dev = chip->dev; - - dent = debugfs_create_dir("pm8xxx-pwm-dbg", NULL); - if (dent == NULL || IS_ERR(dent)) { - pr_err("ERR debugfs_create_dir: dent=%p\n", dent); - rc = -ENOMEM; - goto dir_error; - } - - dbgdev->dent = dent; - - for (i = 0; i < chip->pwm_channels; i++) { - char pwm_ch[] = "0"; - - pwm_ch[0] = '0' + i; - dent = debugfs_create_dir(pwm_ch, dbgdev->dent); - if (dent == NULL || IS_ERR(dent)) { - pr_err("ERR: pwm=%d: dir: dent=%p\n", i, dent); - rc = -ENOMEM; - goto debug_error; - } - - puser = &dbgdev->user[i]; - puser->dbgdev = dbgdev; - puser->pwm_id = i; - temp = debugfs_create_file("period", S_IRUGO | S_IWUSR, - dent, puser, &dbg_pwm_period_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("ERR: pwm=%d: period: dent=%p\n", i, dent); - rc = -ENOMEM; - goto debug_error; - } - - temp = debugfs_create_file("duty-cycle", S_IRUGO | S_IWUSR, - dent, puser, &dbg_pwm_duty_cycle_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("ERR: pwm=%d: duty-cycle: dent=%p\n", i, dent); - rc = -ENOMEM; - goto debug_error; - } - - temp = debugfs_create_file("enable", S_IRUGO | S_IWUSR, - dent, puser, &dbg_pwm_enable_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("ERR: pwm=%d: enable: dent=%p\n", i, dent); - rc = -ENOMEM; - goto debug_error; - } - } - - pmic_dbg_device = dbgdev; - - return 0; - -debug_error: - debugfs_remove_recursive(dbgdev->dent); -dir_error: - kfree(dbgdev->user); -user_error: - kfree(dbgdev); - return rc; -} - -static int pm8xxx_pwm_dbg_remove(void) -{ - if (pmic_dbg_device) { - kfree(pmic_dbg_device->user); - debugfs_remove_recursive(pmic_dbg_device->dent); - kfree(pmic_dbg_device); - } - return 0; -} - -#else - -static int pm8xxx_pwm_dbg_probe(struct device *dev) -{ - return 0; -} - -static int pm8xxx_pwm_dbg_remove(void) -{ - return 0; -} - -#endif - -static struct pwm_ops pm8xxx_pwm_ops = { - .enable = pm8xxx_pwm_enable, - .disable = pm8xxx_pwm_disable, - .config = pm8xxx_pwm_config, - .free = pm8xxx_pwm_free, - .owner = THIS_MODULE, -}; - -static int pm8xxx_pwm_probe(struct platform_device *pdev) -{ - const struct pm8xxx_pwm_platform_data *pdata = pdev->dev.platform_data; - struct pm8xxx_pwm_chip *chip; - int i, dtest_channel, rc; - enum pm8xxx_version version; - - chip = kzalloc(sizeof *chip, GFP_KERNEL); - if (chip == NULL) { - pr_err("kzalloc() failed.\n"); - return -ENOMEM; - } - - if (pdata != NULL) - dtest_channel = pdata->dtest_channel; - else - dtest_channel = -1; - - mutex_init(&chip->pwm_mutex); - - chip->dev = &pdev->dev; - - version = pm8xxx_get_version(chip->dev->parent); - - if (version == PM8XXX_VERSION_8921 || - version == PM8XXX_VERSION_8058 || - version == PM8XXX_VERSION_8922 || - version == PM8XXX_VERSION_8038) { - chip->feature_flags |= PM8XXX_FEATURE_LPG_SUPPORTED; - } - - if (version == PM8XXX_VERSION_8038) - chip->feature_flags |= PM8XXX_FEATURE_PWM_ENABLE_SYNC; - - if (chip->feature_flags & PM8XXX_FEATURE_LPG_SUPPORTED) { - if (version == PM8XXX_VERSION_8922 || - version == PM8XXX_VERSION_8038) { - for (i = 0; i < NUM_CLOCKS; i++) - pt_t[0][i] /= PRE_DIVIDE_2; - chip->pwm_channels = PM8XXX_LPG_V1_PWM_CHANNELS; - } else { - chip->pwm_channels = PM8XXX_LPG_V0_PWM_CHANNELS; - } - chip->pwm_total_pre_divs = NUM_LPG_PRE_DIVIDE; - } else { - chip->pwm_channels = PM8XXX_PWM_CHANNELS; - chip->pwm_total_pre_divs = NUM_PWM_PRE_DIVIDE; - } - - chip->channels = kcalloc(chip->pwm_channels, - sizeof(struct pm8xxx_pwm_channel_data), GFP_KERNEL); - if (chip->channels == NULL) { - pr_err("kcalloc() failed.\n"); - mutex_destroy(&chip->pwm_mutex); - kfree(chip); - return -ENOMEM; - } - - for (i = 0; i < chip->pwm_channels; i++) { - if (i == dtest_channel) - chip->channels[i].dtest_mode_supported = 1; - } - - platform_set_drvdata(pdev, chip); - - chip->chip.dev = &pdev->dev; - chip->chip.ops = &pm8xxx_pwm_ops; - chip->chip.base = -1; - chip->chip.npwm = chip->pwm_channels; - - rc = pwmchip_add(&chip->chip); - if (rc < 0) { - pr_err("pwmchip_add() failed: %d\n", rc); - goto failed_add; - } - - if (pm8xxx_pwm_dbg_probe(chip) < 0) - pr_err("could not set up debugfs\n"); - - return 0; - -failed_add: - kfree(chip->channels); - mutex_destroy(&chip->pwm_mutex); - platform_set_drvdata(pdev, NULL); - kfree(chip); - return rc; -} - -static int pm8xxx_pwm_remove(struct platform_device *pdev) -{ - struct pm8xxx_pwm_chip *chip = dev_get_drvdata(pdev->dev.parent); - - pm8xxx_pwm_dbg_remove(); - pwmchip_remove(&chip->chip); - kfree(chip->channels); - mutex_destroy(&chip->pwm_mutex); - platform_set_drvdata(pdev, NULL); - kfree(chip); - return 0; -} - -static struct platform_driver pm8xxx_pwm_driver = { - .probe = pm8xxx_pwm_probe, - .remove = pm8xxx_pwm_remove, - .driver = { - .name = PM8XXX_PWM_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_pwm_init(void) -{ - return platform_driver_register(&pm8xxx_pwm_driver); -} - -static void __exit pm8xxx_pwm_exit(void) -{ - platform_driver_unregister(&pm8xxx_pwm_driver); -} - -subsys_initcall(pm8xxx_pwm_init); -module_exit(pm8xxx_pwm_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PM8XXX PWM driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_PWM_DEV_NAME); diff --git a/drivers/mfd/pm8xxx-spk.c b/drivers/mfd/pm8xxx-spk.c deleted file mode 100644 index d5d6b5eb83d08362b3dacc45b5da42a173829349..0000000000000000000000000000000000000000 --- a/drivers/mfd/pm8xxx-spk.c +++ /dev/null @@ -1,299 +0,0 @@ -/* Copyright (c) 2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define PM8XXX_SPK_CTL1_REG_OFF 0 -#define PM8XXX_SPK_CTL2_REG_OFF 1 -#define PM8XXX_SPK_CTL3_REG_OFF 2 -#define PM8XXX_SPK_CTL4_REG_OFF 3 -#define PM8XXX_SPK_TEST_REG_1_OFF 4 -#define PM8XXX_SPK_TEST_REG_2_OFF 5 - -#define PM8XXX_SPK_BANK_SEL 4 -#define PM8XXX_SPK_BANK_WRITE 0x80 -#define PM8XXX_SPK_BANK_VAL_MASK 0xF - -#define BOOST_6DB_GAIN_EN_MASK 0x8 -#define VSEL_LD0_1P1 0x0 -#define VSEL_LD0_1P2 0x2 -#define VSEL_LD0_1P0 0x4 - -#define PWM_EN_MASK 0xF -#define PM8XXX_SPK_TEST_REG_1_BANKS 8 -#define PM8XXX_SPK_TEST_REG_2_BANKS 2 - -#define PM8XXX_SPK_GAIN 0x5 -#define PM8XXX_ADD_EN 0x1 - -struct pm8xxx_spk_chip { - struct list_head link; - struct pm8xxx_spk_platform_data pdata; - struct device *dev; - enum pm8xxx_version version; - struct mutex spk_mutex; - u16 base; - u16 end; -}; - -static struct pm8xxx_spk_chip *the_spk_chip; - -static inline bool spk_defined(void) -{ - if (the_spk_chip == NULL || IS_ERR(the_spk_chip)) - return false; - return true; -} - -static int pm8xxx_spk_bank_write(u16 reg, u16 bank, u8 val) -{ - int rc = 0; - u8 bank_val = PM8XXX_SPK_BANK_WRITE | (bank << PM8XXX_SPK_BANK_SEL); - - bank_val |= (val & PM8XXX_SPK_BANK_VAL_MASK); - mutex_lock(&the_spk_chip->spk_mutex); - rc = pm8xxx_writeb(the_spk_chip->dev->parent, reg, bank_val); - if (rc) - pr_err("pm8xxx_writeb(): rc=%d\n", rc); - mutex_unlock(&the_spk_chip->spk_mutex); - return rc; -} - - -static int pm8xxx_spk_read(u16 addr) -{ - int rc = 0; - u8 val = 0; - - mutex_lock(&the_spk_chip->spk_mutex); - rc = pm8xxx_readb(the_spk_chip->dev->parent, - the_spk_chip->base + addr, &val); - if (rc) { - pr_err("pm8xxx_spk_readb() failed: rc=%d\n", rc); - val = rc; - } - mutex_unlock(&the_spk_chip->spk_mutex); - - return val; -} - -static int pm8xxx_spk_write(u16 addr, u8 val) -{ - int rc = 0; - - mutex_lock(&the_spk_chip->spk_mutex); - rc = pm8xxx_writeb(the_spk_chip->dev->parent, - the_spk_chip->base + addr, val); - if (rc) - pr_err("pm8xxx_writeb() failed: rc=%d\n", rc); - mutex_unlock(&the_spk_chip->spk_mutex); - return rc; -} - -int pm8xxx_spk_mute(bool mute) -{ - u8 val = 0; - int ret = 0; - if (spk_defined() == false) { - pr_err("Invalid spk handle or no spk_chip\n"); - return -ENODEV; - } - - val = pm8xxx_spk_read(PM8XXX_SPK_CTL1_REG_OFF); - val |= mute << 2; - ret = pm8xxx_spk_write(PM8XXX_SPK_CTL1_REG_OFF, val); - return ret; -} -EXPORT_SYMBOL_GPL(pm8xxx_spk_mute); - -int pm8xxx_spk_gain(u8 gain) -{ - u8 val; - int ret = 0; - - if (spk_defined() == false) { - pr_err("Invalid spk handle or no spk_chip\n"); - return -ENODEV; - } - - val = pm8xxx_spk_read(PM8XXX_SPK_CTL1_REG_OFF); - val = (gain << 4) | (val & 0xF); - ret = pm8xxx_spk_write(PM8XXX_SPK_CTL1_REG_OFF, val); - if (!ret) { - pm8xxx_spk_bank_write(the_spk_chip->base - + PM8XXX_SPK_TEST_REG_1_OFF, - 0, BOOST_6DB_GAIN_EN_MASK | VSEL_LD0_1P2); - } - return ret; -} -EXPORT_SYMBOL_GPL(pm8xxx_spk_gain); - -int pm8xxx_spk_enable(int enable) -{ - int val = 0; - u16 addr; - int ret = 0; - - if (spk_defined() == false) { - pr_err("Invalid spk handle or no spk_chip\n"); - return -ENODEV; - } - - addr = the_spk_chip->base + PM8XXX_SPK_TEST_REG_1_OFF; - val = pm8xxx_spk_read(PM8XXX_SPK_CTL1_REG_OFF); - if (val < 0) - return val; - if (enable) - val |= (1 << 3); - else - val &= ~(1 << 3); - ret = pm8xxx_spk_write(PM8XXX_SPK_CTL1_REG_OFF, val); - if (!ret) - ret = pm8xxx_spk_bank_write(addr, 6, PWM_EN_MASK); - return ret; -} -EXPORT_SYMBOL_GPL(pm8xxx_spk_enable); - -static int pm8xxx_spk_config(void) -{ - u16 addr; - int ret = 0; - - if (spk_defined() == false) { - pr_err("Invalid spk handle or no spk_chip\n"); - return -ENODEV; - } - - addr = the_spk_chip->base + PM8XXX_SPK_TEST_REG_1_OFF; - ret = pm8xxx_spk_bank_write(addr, 6, PWM_EN_MASK & 0); - if (!ret) - ret = pm8xxx_spk_gain(PM8XXX_SPK_GAIN); - return ret; -} - -static int pm8xxx_spk_probe(struct platform_device *pdev) -{ - const struct pm8xxx_spk_platform_data *pdata = pdev->dev.platform_data; - int ret = 0; - u8 value = 0; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - the_spk_chip = kzalloc(sizeof(struct pm8xxx_spk_chip), GFP_KERNEL); - if (the_spk_chip == NULL) { - pr_err("kzalloc() failed.\n"); - return -ENOMEM; - } - - mutex_init(&the_spk_chip->spk_mutex); - - the_spk_chip->dev = &pdev->dev; - the_spk_chip->version = pm8xxx_get_version(the_spk_chip->dev->parent); - switch (pm8xxx_get_version(the_spk_chip->dev->parent)) { - case PM8XXX_VERSION_8038: - break; - default: - ret = -ENODEV; - goto err_handle; - } - - memcpy(&(the_spk_chip->pdata), pdata, - sizeof(struct pm8xxx_spk_platform_data)); - - the_spk_chip->base = pdev->resource[0].start; - the_spk_chip->end = pdev->resource[0].end; - - if (the_spk_chip->pdata.spk_add_enable) { - int val; - val = pm8xxx_spk_read(PM8XXX_SPK_CTL1_REG_OFF); - if (val < 0) { - ret = val; - goto err_handle; - } - val |= (the_spk_chip->pdata.spk_add_enable & PM8XXX_ADD_EN); - ret = pm8xxx_spk_write(PM8XXX_SPK_CTL1_REG_OFF, val); - if (ret < 0) - goto err_handle; - } - value = ((the_spk_chip->pdata.cd_ng_threshold << 5) | - the_spk_chip->pdata.cd_nf_preamp_bias << 3); - pr_debug("Setting SPK_CTL2_REG = %02x\n", value); - pm8xxx_spk_write(PM8XXX_SPK_CTL2_REG_OFF, value); - - value = ((the_spk_chip->pdata.cd_ng_hold << 5) | - (the_spk_chip->pdata.cd_ng_max_atten << 1) | - the_spk_chip->pdata.noise_mute); - pr_debug("Setting SPK_CTL3_REG = %02x\n", value); - pm8xxx_spk_write(PM8XXX_SPK_CTL3_REG_OFF, value); - - value = ((the_spk_chip->pdata.cd_ng_decay_rate << 5) | - (the_spk_chip->pdata.cd_ng_attack_rate << 3) | - the_spk_chip->pdata.cd_delay << 2); - pr_debug("Setting SPK_CTL4_REG = %02x\n", value); - pm8xxx_spk_write(PM8XXX_SPK_CTL4_REG_OFF, value); - - return pm8xxx_spk_config(); -err_handle: - pr_err("pm8xxx_spk_probe failed." - "Audio unavailable on speaker.\n"); - mutex_destroy(&the_spk_chip->spk_mutex); - kfree(the_spk_chip); - return ret; -} - -static int pm8xxx_spk_remove(struct platform_device *pdev) -{ - if (spk_defined() == false) { - pr_err("Invalid spk handle or no spk_chip\n"); - return -ENODEV; - } - mutex_destroy(&the_spk_chip->spk_mutex); - kfree(the_spk_chip); - return 0; -} - -static struct platform_driver pm8xxx_spk_driver = { - .probe = pm8xxx_spk_probe, - .remove = pm8xxx_spk_remove, - .driver = { - .name = PM8XXX_SPK_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_spk_init(void) -{ - return platform_driver_register(&pm8xxx_spk_driver); -} -subsys_initcall(pm8xxx_spk_init); - -static void __exit pm8xxx_spk_exit(void) -{ - platform_driver_unregister(&pm8xxx_spk_driver); -} -module_exit(pm8xxx_spk_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PM8XXX SPK driver"); -MODULE_ALIAS("platform:" PM8XXX_SPK_DEV_NAME); diff --git a/drivers/mfd/pmic8058.c b/drivers/mfd/pmic8058.c deleted file mode 100644 index 8efd240c23fc0cdc2974e978aca46eccf3305a4e..0000000000000000000000000000000000000000 --- a/drivers/mfd/pmic8058.c +++ /dev/null @@ -1,792 +0,0 @@ -/* Copyright (c) 2009-2011, 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. - * - */ -/* - * Qualcomm PMIC8058 driver - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define REG_MPP_BASE 0x50 -#define REG_IRQ_BASE 0x1BB - -/* PMIC8058 Revision */ -#define PM8058_REG_REV 0x002 /* PMIC4 revision */ -#define PM8058_VERSION_MASK 0xF0 -#define PM8058_REVISION_MASK 0x0F -#define PM8058_VERSION_VALUE 0xE0 - -/* PMIC 8058 Battery Alarm SSBI registers */ -#define REG_BATT_ALARM_THRESH 0x023 -#define REG_BATT_ALARM_CTRL1 0x024 -#define REG_BATT_ALARM_CTRL2 0x0AA -#define REG_BATT_ALARM_PWM_CTRL 0x0A3 - -#define REG_TEMP_ALRM_CTRL 0x1B -#define REG_TEMP_ALRM_PWM 0x9B - -/* PON CNTL 4 register */ -#define SSBI_REG_ADDR_PON_CNTL_4 0x98 -#define PM8058_PON_RESET_EN_MASK 0x01 - -/* PON CNTL 5 register */ -#define SSBI_REG_ADDR_PON_CNTL_5 0x7B -#define PM8058_HARD_RESET_EN_MASK 0x08 - -/* GP_TEST1 register */ -#define SSBI_REG_ADDR_GP_TEST_1 0x07A - -#define PM8058_RTC_BASE 0x1E8 -#define PM8058_OTHC_CNTR_BASE0 0xA0 -#define PM8058_OTHC_CNTR_BASE1 0x134 -#define PM8058_OTHC_CNTR_BASE2 0x137 - -#define SINGLE_IRQ_RESOURCE(_name, _irq) \ -{ \ - .name = _name, \ - .start = _irq, \ - .end = _irq, \ - .flags = IORESOURCE_IRQ, \ -} - -struct pm8058_chip { - struct pm8058_platform_data pdata; - struct device *dev; - struct pm_irq_chip *irq_chip; - struct mfd_cell *mfd_regulators, *mfd_xo_buffers; - - u8 revision; -}; - -static int pm8058_readb(const struct device *dev, u16 addr, u8 *val) -{ - const struct pm8xxx_drvdata *pm8058_drvdata = dev_get_drvdata(dev); - const struct pm8058_chip *pmic = pm8058_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, val, 1); -} - -static int pm8058_writeb(const struct device *dev, u16 addr, u8 val) -{ - const struct pm8xxx_drvdata *pm8058_drvdata = dev_get_drvdata(dev); - const struct pm8058_chip *pmic = pm8058_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, &val, 1); -} - -static int pm8058_read_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8058_drvdata = dev_get_drvdata(dev); - const struct pm8058_chip *pmic = pm8058_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8058_write_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8058_drvdata = dev_get_drvdata(dev); - const struct pm8058_chip *pmic = pm8058_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8058_read_irq_stat(const struct device *dev, int irq) -{ - const struct pm8xxx_drvdata *pm8058_drvdata = dev_get_drvdata(dev); - const struct pm8058_chip *pmic = pm8058_drvdata->pm_chip_data; - - return pm8xxx_get_irq_stat(pmic->irq_chip, irq); - - return 0; -} - -static enum pm8xxx_version pm8058_get_version(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8058_drvdata = dev_get_drvdata(dev); - const struct pm8058_chip *pmic = pm8058_drvdata->pm_chip_data; - enum pm8xxx_version version = -ENODEV; - - if ((pmic->revision & PM8058_VERSION_MASK) == PM8058_VERSION_VALUE) - version = PM8XXX_VERSION_8058; - - return version; -} - -static int pm8058_get_revision(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8058_drvdata = dev_get_drvdata(dev); - const struct pm8058_chip *pmic = pm8058_drvdata->pm_chip_data; - - return pmic->revision & PM8058_REVISION_MASK; -} - -static struct pm8xxx_drvdata pm8058_drvdata = { - .pmic_readb = pm8058_readb, - .pmic_writeb = pm8058_writeb, - .pmic_read_buf = pm8058_read_buf, - .pmic_write_buf = pm8058_write_buf, - .pmic_read_irq_stat = pm8058_read_irq_stat, - .pmic_get_version = pm8058_get_version, - .pmic_get_revision = pm8058_get_revision, -}; - -static const struct resource pm8058_charger_resources[] = { - SINGLE_IRQ_RESOURCE("CHGVAL", PM8058_CHGVAL_IRQ), - SINGLE_IRQ_RESOURCE("CHGINVAL", PM8058_CHGINVAL_IRQ), - SINGLE_IRQ_RESOURCE("CHGILIM", PM8058_CHGILIM_IRQ), - SINGLE_IRQ_RESOURCE("VCP", PM8058_VCP_IRQ), - SINGLE_IRQ_RESOURCE("ATC_DONE", PM8058_ATC_DONE_IRQ), - SINGLE_IRQ_RESOURCE("ATCFAIL", PM8058_ATCFAIL_IRQ), - SINGLE_IRQ_RESOURCE("AUTO_CHGDONE", PM8058_AUTO_CHGDONE_IRQ), - SINGLE_IRQ_RESOURCE("AUTO_CHGFAIL", PM8058_AUTO_CHGFAIL_IRQ), - SINGLE_IRQ_RESOURCE("CHGSTATE", PM8058_CHGSTATE_IRQ), - SINGLE_IRQ_RESOURCE("FASTCHG", PM8058_FASTCHG_IRQ), - SINGLE_IRQ_RESOURCE("CHG_END", PM8058_CHG_END_IRQ), - SINGLE_IRQ_RESOURCE("BATTTEMP", PM8058_BATTTEMP_IRQ), - SINGLE_IRQ_RESOURCE("CHGHOT", PM8058_CHGHOT_IRQ), - SINGLE_IRQ_RESOURCE("CHGTLIMIT", PM8058_CHGTLIMIT_IRQ), - SINGLE_IRQ_RESOURCE("CHG_GONE", PM8058_CHG_GONE_IRQ), - SINGLE_IRQ_RESOURCE("VCPMAJOR", PM8058_VCPMAJOR_IRQ), - SINGLE_IRQ_RESOURCE("VBATDET", PM8058_VBATDET_IRQ), - SINGLE_IRQ_RESOURCE("BATFET", PM8058_BATFET_IRQ), - SINGLE_IRQ_RESOURCE("BATT_REPLACE", PM8058_BATT_REPLACE_IRQ), - SINGLE_IRQ_RESOURCE("BATTCONNECT", PM8058_BATTCONNECT_IRQ), - SINGLE_IRQ_RESOURCE("VBATDET_LOW", PM8058_VBATDET_LOW_IRQ), -}; - -static struct mfd_cell pm8058_charger_cell = { - .name = "pm8058-charger", - .id = -1, - .resources = pm8058_charger_resources, - .num_resources = ARRAY_SIZE(pm8058_charger_resources), -}; - -static const struct resource misc_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8xxx_osc_halt_irq", PM8058_OSCHALT_IRQ), -}; - -static struct mfd_cell misc_cell = { - .name = PM8XXX_MISC_DEV_NAME, - .id = -1, - .resources = misc_cell_resources, - .num_resources = ARRAY_SIZE(misc_cell_resources), -}; - -static struct mfd_cell pm8058_pwm_cell = { - .name = "pm8058-pwm", - .id = -1, -}; - -static struct resource xoadc_resources[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8058_ADC_IRQ), -}; - -static struct mfd_cell xoadc_cell = { - .name = "pm8058-xoadc", - .id = -1, - .resources = xoadc_resources, - .num_resources = ARRAY_SIZE(xoadc_resources), -}; - -static const struct resource thermal_alarm_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8058_tempstat_irq", PM8058_TEMPSTAT_IRQ), - SINGLE_IRQ_RESOURCE("pm8058_overtemp_irq", PM8058_OVERTEMP_IRQ), -}; - -static struct pm8xxx_tm_core_data thermal_alarm_cdata = { - .adc_channel = CHANNEL_ADC_DIE_TEMP, - .adc_type = PM8XXX_TM_ADC_PM8058_ADC, - .reg_addr_temp_alarm_ctrl = REG_TEMP_ALRM_CTRL, - .reg_addr_temp_alarm_pwm = REG_TEMP_ALRM_PWM, - .tm_name = "pm8058_tz", - .irq_name_temp_stat = "pm8058_tempstat_irq", - .irq_name_over_temp = "pm8058_overtemp_irq", -}; - -static struct mfd_cell thermal_alarm_cell = { - .name = PM8XXX_TM_DEV_NAME, - .id = -1, - .resources = thermal_alarm_cell_resources, - .num_resources = ARRAY_SIZE(thermal_alarm_cell_resources), - .platform_data = &thermal_alarm_cdata, - .pdata_size = sizeof(struct pm8xxx_tm_core_data), -}; - -static struct mfd_cell debugfs_cell = { - .name = "pm8xxx-debug", - .id = -1, - .platform_data = "pm8058-dbg", - .pdata_size = sizeof("pm8058-dbg"), -}; - -static const struct resource othc0_cell_resources[] = { - { - .name = "othc_base", - .start = PM8058_OTHC_CNTR_BASE0, - .end = PM8058_OTHC_CNTR_BASE0, - .flags = IORESOURCE_IO, - }, -}; - -static const struct resource othc1_cell_resources[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8058_SW_1_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8058_IR_1_IRQ), - { - .name = "othc_base", - .start = PM8058_OTHC_CNTR_BASE1, - .end = PM8058_OTHC_CNTR_BASE1, - .flags = IORESOURCE_IO, - }, -}; - -static const struct resource othc2_cell_resources[] = { - { - .name = "othc_base", - .start = PM8058_OTHC_CNTR_BASE2, - .end = PM8058_OTHC_CNTR_BASE2, - .flags = IORESOURCE_IO, - }, -}; - -static const struct resource batt_alarm_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8058_batt_alarm_irq", PM8058_BATT_ALARM_IRQ), -}; - -static struct mfd_cell leds_cell = { - .name = "pm8058-led", - .id = -1, -}; - -static struct mfd_cell othc0_cell = { - .name = "pm8058-othc", - .id = 0, - .resources = othc0_cell_resources, - .num_resources = ARRAY_SIZE(othc0_cell_resources), -}; - -static struct mfd_cell othc1_cell = { - .name = "pm8058-othc", - .id = 1, - .resources = othc1_cell_resources, - .num_resources = ARRAY_SIZE(othc1_cell_resources), -}; - -static struct mfd_cell othc2_cell = { - .name = "pm8058-othc", - .id = 2, - .resources = othc2_cell_resources, - .num_resources = ARRAY_SIZE(othc2_cell_resources), -}; - -static struct pm8xxx_batt_alarm_core_data batt_alarm_cdata = { - .irq_name = "pm8058_batt_alarm_irq", - .reg_addr_threshold = REG_BATT_ALARM_THRESH, - .reg_addr_ctrl1 = REG_BATT_ALARM_CTRL1, - .reg_addr_ctrl2 = REG_BATT_ALARM_CTRL2, - .reg_addr_pwm_ctrl = REG_BATT_ALARM_PWM_CTRL, -}; - -static struct mfd_cell batt_alarm_cell = { - .name = PM8XXX_BATT_ALARM_DEV_NAME, - .id = -1, - .resources = batt_alarm_cell_resources, - .num_resources = ARRAY_SIZE(batt_alarm_cell_resources), - .platform_data = &batt_alarm_cdata, - .pdata_size = sizeof(struct pm8xxx_batt_alarm_core_data), -}; - -static struct mfd_cell upl_cell = { - .name = PM8XXX_UPL_DEV_NAME, - .id = -1, -}; - -static struct mfd_cell nfc_cell = { - .name = PM8XXX_NFC_DEV_NAME, - .id = -1, -}; - -static const struct resource rtc_cell_resources[] = { - [0] = SINGLE_IRQ_RESOURCE(NULL, PM8058_RTC_ALARM_IRQ), - [1] = { - .name = "pmic_rtc_base", - .start = PM8058_RTC_BASE, - .end = PM8058_RTC_BASE, - .flags = IORESOURCE_IO, - }, -}; - -static struct mfd_cell rtc_cell = { - .name = PM8XXX_RTC_DEV_NAME, - .id = -1, - .resources = rtc_cell_resources, - .num_resources = ARRAY_SIZE(rtc_cell_resources), -}; - -static const struct resource resources_pwrkey[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8058_PWRKEY_REL_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8058_PWRKEY_PRESS_IRQ), -}; - -static struct mfd_cell vibrator_cell = { - .name = PM8XXX_VIBRATOR_DEV_NAME, - .id = -1, -}; - -static struct mfd_cell pwrkey_cell = { - .name = PM8XXX_PWRKEY_DEV_NAME, - .id = -1, - .num_resources = ARRAY_SIZE(resources_pwrkey), - .resources = resources_pwrkey, -}; - -static const struct resource resources_keypad[] = { - SINGLE_IRQ_RESOURCE(NULL, PM8058_KEYPAD_IRQ), - SINGLE_IRQ_RESOURCE(NULL, PM8058_KEYSTUCK_IRQ), -}; - -static struct mfd_cell keypad_cell = { - .name = PM8XXX_KEYPAD_DEV_NAME, - .id = -1, - .num_resources = ARRAY_SIZE(resources_keypad), - .resources = resources_keypad, -}; - -static const struct resource mpp_cell_resources[] = { - { - .start = PM8058_IRQ_BLOCK_BIT(PM8058_MPP_BLOCK_START, 0), - .end = PM8058_IRQ_BLOCK_BIT(PM8058_MPP_BLOCK_START, 0) - + PM8058_MPPS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell mpp_cell = { - .name = PM8XXX_MPP_DEV_NAME, - .id = 0, - .resources = mpp_cell_resources, - .num_resources = ARRAY_SIZE(mpp_cell_resources), -}; - -static const struct resource gpio_cell_resources[] = { - [0] = { - .start = PM8058_IRQ_BLOCK_BIT(PM8058_GPIO_BLOCK_START, 0), - .end = PM8058_IRQ_BLOCK_BIT(PM8058_GPIO_BLOCK_START, 0) - + PM8058_GPIOS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell gpio_cell = { - .name = PM8XXX_GPIO_DEV_NAME, - .id = -1, - .resources = gpio_cell_resources, - .num_resources = ARRAY_SIZE(gpio_cell_resources), -}; - -static int -pm8058_add_subdevices(const struct pm8058_platform_data *pdata, - struct pm8058_chip *pmic) -{ - int rc = 0, irq_base = 0, i; - struct pm_irq_chip *irq_chip; - static struct mfd_cell *mfd_regulators, *mfd_xo_buffers; - - if (pdata->irq_pdata) { - pdata->irq_pdata->irq_cdata.nirqs = PM8058_NR_IRQS; - pdata->irq_pdata->irq_cdata.base_addr = REG_IRQ_BASE; - irq_base = pdata->irq_pdata->irq_base; - irq_chip = pm8xxx_irq_init(pmic->dev, pdata->irq_pdata); - - if (IS_ERR(irq_chip)) { - pr_err("Failed to init interrupts ret=%ld\n", - PTR_ERR(irq_chip)); - return PTR_ERR(irq_chip); - } - pmic->irq_chip = irq_chip; - } - - if (pdata->gpio_pdata) { - pdata->gpio_pdata->gpio_cdata.ngpios = PM8058_GPIOS; - gpio_cell.platform_data = pdata->gpio_pdata; - gpio_cell.pdata_size = sizeof(struct pm8xxx_gpio_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &gpio_cell, 1, - NULL, irq_base); - if (rc) { - pr_err("Failed to add gpio subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->mpp_pdata) { - pdata->mpp_pdata->core_data.nmpps = PM8058_MPPS; - pdata->mpp_pdata->core_data.base_addr = REG_MPP_BASE; - mpp_cell.platform_data = pdata->mpp_pdata; - mpp_cell.pdata_size = sizeof(struct pm8xxx_mpp_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &mpp_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add mpp subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->num_regulators > 0 && pdata->regulator_pdatas) { - mfd_regulators = kzalloc(sizeof(struct mfd_cell) - * (pdata->num_regulators), GFP_KERNEL); - if (!mfd_regulators) { - pr_err("Cannot allocate %d bytes for pm8058 regulator " - "mfd cells\n", sizeof(struct mfd_cell) - * (pdata->num_regulators)); - rc = -ENOMEM; - goto bail; - } - for (i = 0; i < pdata->num_regulators; i++) { - mfd_regulators[i].name = "pm8058-regulator"; - mfd_regulators[i].id = pdata->regulator_pdatas[i].id; - mfd_regulators[i].platform_data = - &(pdata->regulator_pdatas[i]); - mfd_regulators[i].pdata_size = - sizeof(struct pm8058_vreg_pdata); - } - rc = mfd_add_devices(pmic->dev, 0, mfd_regulators, - pdata->num_regulators, NULL, irq_base); - if (rc) { - pr_err("Failed to add regulator subdevices ret=%d\n", - rc); - kfree(mfd_regulators); - goto bail; - } - pmic->mfd_regulators = mfd_regulators; - } - - if (pdata->num_xo_buffers > 0 && pdata->xo_buffer_pdata) { - mfd_xo_buffers = kzalloc(sizeof(struct mfd_cell) - * (pdata->num_xo_buffers), GFP_KERNEL); - if (!mfd_xo_buffers) { - pr_err("Cannot allocate %d bytes for pm8058 XO buffer " - "mfd cells\n", sizeof(struct mfd_cell) - * (pdata->num_xo_buffers)); - rc = -ENOMEM; - goto bail; - } - for (i = 0; i < pdata->num_xo_buffers; i++) { - mfd_xo_buffers[i].name = PM8058_XO_BUFFER_DEV_NAME; - mfd_xo_buffers[i].id = pdata->xo_buffer_pdata[i].id; - mfd_xo_buffers[i].platform_data = - &(pdata->xo_buffer_pdata[i]); - mfd_xo_buffers[i].pdata_size = - sizeof(struct pm8058_xo_pdata); - } - rc = mfd_add_devices(pmic->dev, 0, mfd_xo_buffers, - pdata->num_xo_buffers, NULL, irq_base); - if (rc) { - pr_err("Failed to add XO buffer subdevices ret=%d\n", - rc); - kfree(mfd_xo_buffers); - goto bail; - } - pmic->mfd_xo_buffers = mfd_xo_buffers; - } - - if (pdata->keypad_pdata) { - keypad_cell.platform_data = pdata->keypad_pdata; - keypad_cell.pdata_size = - sizeof(struct pm8xxx_keypad_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &keypad_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add keypad subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->rtc_pdata) { - rtc_cell.platform_data = pdata->rtc_pdata; - rtc_cell.pdata_size = sizeof(struct pm8xxx_rtc_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &rtc_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add rtc subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->pwrkey_pdata) { - pwrkey_cell.platform_data = pdata->pwrkey_pdata; - pwrkey_cell.pdata_size = - sizeof(struct pm8xxx_pwrkey_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &pwrkey_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add pwrkey subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->vibrator_pdata) { - vibrator_cell.platform_data = pdata->vibrator_pdata; - vibrator_cell.pdata_size = - sizeof(struct pm8xxx_vibrator_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &vibrator_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add vibrator subdevice ret=%d\n", - rc); - goto bail; - } - } - - if (pdata->leds_pdata) { - leds_cell.platform_data = pdata->leds_pdata; - leds_cell.pdata_size = - sizeof(struct pmic8058_leds_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &leds_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add leds subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->xoadc_pdata) { - xoadc_cell.platform_data = pdata->xoadc_pdata; - xoadc_cell.pdata_size = - sizeof(struct xoadc_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &xoadc_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add leds subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->othc0_pdata) { - othc0_cell.platform_data = pdata->othc0_pdata; - othc0_cell.pdata_size = - sizeof(struct pmic8058_othc_config_pdata); - rc = mfd_add_devices(pmic->dev, 0, &othc0_cell, 1, NULL, 0); - if (rc) { - pr_err("Failed to add othc0 subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->othc1_pdata) { - othc1_cell.platform_data = pdata->othc1_pdata; - othc1_cell.pdata_size = - sizeof(struct pmic8058_othc_config_pdata); - rc = mfd_add_devices(pmic->dev, 0, &othc1_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add othc1 subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->othc2_pdata) { - othc2_cell.platform_data = pdata->othc2_pdata; - othc2_cell.pdata_size = - sizeof(struct pmic8058_othc_config_pdata); - rc = mfd_add_devices(pmic->dev, 0, &othc2_cell, 1, NULL, 0); - if (rc) { - pr_err("Failed to add othc2 subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->pwm_pdata) { - pm8058_pwm_cell.platform_data = pdata->pwm_pdata; - pm8058_pwm_cell.pdata_size = sizeof(struct pm8058_pwm_pdata); - rc = mfd_add_devices(pmic->dev, 0, &pm8058_pwm_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add pwm subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->misc_pdata) { - misc_cell.platform_data = pdata->misc_pdata; - misc_cell.pdata_size = sizeof(struct pm8xxx_misc_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &misc_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add misc subdevice ret=%d\n", rc); - goto bail; - } - } - - rc = mfd_add_devices(pmic->dev, 0, &thermal_alarm_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add thermal alarm subdevice ret=%d\n", - rc); - goto bail; - } - - rc = mfd_add_devices(pmic->dev, 0, &batt_alarm_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add battery alarm subdevice ret=%d\n", - rc); - goto bail; - } - - rc = mfd_add_devices(pmic->dev, 0, &upl_cell, 1, NULL, 0); - if (rc) { - pr_err("Failed to add upl subdevice ret=%d\n", rc); - goto bail; - } - - rc = mfd_add_devices(pmic->dev, 0, &nfc_cell, 1, NULL, 0); - if (rc) { - pr_err("Failed to add upl subdevice ret=%d\n", rc); - goto bail; - } - - if (pdata->charger_pdata) { - pm8058_charger_cell.platform_data = pdata->charger_pdata; - pm8058_charger_cell.pdata_size = sizeof(struct - pmic8058_charger_data); - rc = mfd_add_devices(pmic->dev, 0, &pm8058_charger_cell, - 1, NULL, irq_base); - if (rc) { - pr_err("Failed to add charger subdevice ret=%d\n", rc); - goto bail; - } - } - - rc = mfd_add_devices(pmic->dev, 0, &debugfs_cell, 1, NULL, irq_base); - if (rc) { - pr_err("Failed to add debugfs subdevice ret=%d\n", rc); - goto bail; - } - - return rc; -bail: - if (pmic->irq_chip) { - pm8xxx_irq_exit(pmic->irq_chip); - pmic->irq_chip = NULL; - } - return rc; -} - -static int pm8058_probe(struct platform_device *pdev) -{ - int rc; - struct pm8058_platform_data *pdata = pdev->dev.platform_data; - struct pm8058_chip *pmic; - - if (pdata == NULL) { - pr_err("%s: No platform_data or IRQ.\n", __func__); - return -ENODEV; - } - - pmic = kzalloc(sizeof *pmic, GFP_KERNEL); - if (pmic == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - return -ENOMEM; - } - - pmic->dev = &pdev->dev; - - pm8058_drvdata.pm_chip_data = pmic; - platform_set_drvdata(pdev, &pm8058_drvdata); - - /* Read PMIC chip revision */ - rc = pm8058_readb(pmic->dev, PM8058_REG_REV, &pmic->revision); - if (rc) - pr_err("%s: Failed on pm8058_readb for revision: rc=%d.\n", - __func__, rc); - - pr_info("%s: PMIC revision: %X\n", __func__, pmic->revision); - - (void) memcpy((void *)&pmic->pdata, (const void *)pdata, - sizeof(pmic->pdata)); - - rc = pm8058_add_subdevices(pdata, pmic); - if (rc) { - pr_err("Cannot add subdevices rc=%d\n", rc); - goto err; - } - - rc = pm8xxx_hard_reset_config(PM8XXX_SHUTDOWN_ON_HARD_RESET); - if (rc < 0) - pr_err("%s: failed to config shutdown on hard reset: %d\n", - __func__, rc); - - return 0; - -err: - mfd_remove_devices(pmic->dev); - platform_set_drvdata(pdev, NULL); - kfree(pmic); - return rc; -} - -static int pm8058_remove(struct platform_device *pdev) -{ - struct pm8xxx_drvdata *drvdata; - struct pm8058_chip *pmic = NULL; - - drvdata = platform_get_drvdata(pdev); - if (drvdata) - pmic = drvdata->pm_chip_data; - if (pmic) { - if (pmic->dev) - mfd_remove_devices(pmic->dev); - if (pmic->irq_chip) - pm8xxx_irq_exit(pmic->irq_chip); - kfree(pmic->mfd_regulators); - kfree(pmic); - } - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver pm8058_driver = { - .probe = pm8058_probe, - .remove = pm8058_remove, - .driver = { - .name = "pm8058-core", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8058_init(void) -{ - return platform_driver_register(&pm8058_driver); -} -postcore_initcall(pm8058_init); - -static void __exit pm8058_exit(void) -{ - platform_driver_unregister(&pm8058_driver); -} -module_exit(pm8058_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8058 core driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pmic8058-core"); diff --git a/drivers/mfd/pmic8901.c b/drivers/mfd/pmic8901.c deleted file mode 100644 index d19d42ee8ec34984c60079fddcec6db43f53c992..0000000000000000000000000000000000000000 --- a/drivers/mfd/pmic8901.c +++ /dev/null @@ -1,382 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include - -/* PMIC8901 Revision */ -#define PM8901_REG_REV 0x002 -#define PM8901_VERSION_MASK 0xF0 -#define PM8901_REVISION_MASK 0x0F -#define PM8901_VERSION_VALUE 0xF0 - -#define REG_IRQ_BASE 0xD5 -#define REG_MPP_BASE 0x27 - -#define REG_TEMP_ALRM_CTRL 0x23 -#define REG_TEMP_ALRM_PWM 0x24 - -#define SINGLE_IRQ_RESOURCE(_name, _irq) \ -{ \ - .name = _name, \ - .start = _irq, \ - .end = _irq, \ - .flags = IORESOURCE_IRQ, \ -} - -struct pm8901_chip { - struct pm8901_platform_data pdata; - struct device *dev; - struct pm_irq_chip *irq_chip; - struct mfd_cell *mfd_regulators; - u8 revision; -}; - -static int pm8901_readb(const struct device *dev, u16 addr, u8 *val) -{ - const struct pm8xxx_drvdata *pm8901_drvdata = dev_get_drvdata(dev); - const struct pm8901_chip *pmic = pm8901_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, val, 1); -} - -static int pm8901_writeb(const struct device *dev, u16 addr, u8 val) -{ - const struct pm8xxx_drvdata *pm8901_drvdata = dev_get_drvdata(dev); - const struct pm8901_chip *pmic = pm8901_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, &val, 1); -} - -static int pm8901_read_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8901_drvdata = dev_get_drvdata(dev); - const struct pm8901_chip *pmic = pm8901_drvdata->pm_chip_data; - - return msm_ssbi_read(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8901_write_buf(const struct device *dev, u16 addr, u8 *buf, - int cnt) -{ - const struct pm8xxx_drvdata *pm8901_drvdata = dev_get_drvdata(dev); - const struct pm8901_chip *pmic = pm8901_drvdata->pm_chip_data; - - return msm_ssbi_write(pmic->dev->parent, addr, buf, cnt); -} - -static int pm8901_read_irq_stat(const struct device *dev, int irq) -{ - const struct pm8xxx_drvdata *pm8901_drvdata = dev_get_drvdata(dev); - const struct pm8901_chip *pmic = pm8901_drvdata->pm_chip_data; - - return pm8xxx_get_irq_stat(pmic->irq_chip, irq); - - return 0; -} - -static enum pm8xxx_version pm8901_get_version(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8901_drvdata = dev_get_drvdata(dev); - const struct pm8901_chip *pmic = pm8901_drvdata->pm_chip_data; - enum pm8xxx_version version = -ENODEV; - - if ((pmic->revision & PM8901_VERSION_MASK) == PM8901_VERSION_VALUE) - version = PM8XXX_VERSION_8901; - - return version; -} - -static int pm8901_get_revision(const struct device *dev) -{ - const struct pm8xxx_drvdata *pm8901_drvdata = dev_get_drvdata(dev); - const struct pm8901_chip *pmic = pm8901_drvdata->pm_chip_data; - - return pmic->revision & PM8901_REVISION_MASK; -} - -static struct pm8xxx_drvdata pm8901_drvdata = { - .pmic_readb = pm8901_readb, - .pmic_writeb = pm8901_writeb, - .pmic_read_buf = pm8901_read_buf, - .pmic_write_buf = pm8901_write_buf, - .pmic_read_irq_stat = pm8901_read_irq_stat, - .pmic_get_version = pm8901_get_version, - .pmic_get_revision = pm8901_get_revision, -}; - -static struct mfd_cell misc_cell = { - .name = PM8XXX_MISC_DEV_NAME, - .id = 1, -}; - -static struct mfd_cell debugfs_cell = { - .name = "pm8xxx-debug", - .id = 1, - .platform_data = "pm8901-dbg", - .pdata_size = sizeof("pm8901-dbg"), -}; - -static const struct resource thermal_alarm_cell_resources[] = { - SINGLE_IRQ_RESOURCE("pm8901_tempstat_irq", PM8901_TEMPSTAT_IRQ), - SINGLE_IRQ_RESOURCE("pm8901_overtemp_irq", PM8901_OVERTEMP_IRQ), -}; - -static struct pm8xxx_tm_core_data thermal_alarm_cdata = { - .adc_type = PM8XXX_TM_ADC_NONE, - .reg_addr_temp_alarm_ctrl = REG_TEMP_ALRM_CTRL, - .reg_addr_temp_alarm_pwm = REG_TEMP_ALRM_PWM, - .tm_name = "pm8901_tz", - .irq_name_temp_stat = "pm8901_tempstat_irq", - .irq_name_over_temp = "pm8901_overtemp_irq", -}; - -static struct mfd_cell thermal_alarm_cell = { - .name = PM8XXX_TM_DEV_NAME, - .id = 1, - .resources = thermal_alarm_cell_resources, - .num_resources = ARRAY_SIZE(thermal_alarm_cell_resources), - .platform_data = &thermal_alarm_cdata, - .pdata_size = sizeof(struct pm8xxx_tm_core_data), -}; - -static const struct resource mpp_cell_resources[] = { - { - .start = PM8901_IRQ_BLOCK_BIT(PM8901_MPP_BLOCK_START, 0), - .end = PM8901_IRQ_BLOCK_BIT(PM8901_MPP_BLOCK_START, 0) - + PM8901_MPPS - 1, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell mpp_cell = { - .name = PM8XXX_MPP_DEV_NAME, - .id = 1, - .resources = mpp_cell_resources, - .num_resources = ARRAY_SIZE(mpp_cell_resources), -}; - -static int -pm8901_add_subdevices(const struct pm8901_platform_data *pdata, - struct pm8901_chip *pmic) -{ - int rc = 0, irq_base = 0, i; - struct pm_irq_chip *irq_chip; - static struct mfd_cell *mfd_regulators; - - if (pdata->irq_pdata) { - pdata->irq_pdata->irq_cdata.nirqs = PM8901_NR_IRQS; - pdata->irq_pdata->irq_cdata.base_addr = REG_IRQ_BASE; - irq_base = pdata->irq_pdata->irq_base; - irq_chip = pm8xxx_irq_init(pmic->dev, pdata->irq_pdata); - - if (IS_ERR(irq_chip)) { - pr_err("Failed to init interrupts ret=%ld\n", - PTR_ERR(irq_chip)); - return PTR_ERR(irq_chip); - } - pmic->irq_chip = irq_chip; - } - - if (pdata->mpp_pdata) { - pdata->mpp_pdata->core_data.nmpps = PM8901_MPPS; - pdata->mpp_pdata->core_data.base_addr = REG_MPP_BASE; - mpp_cell.platform_data = pdata->mpp_pdata; - mpp_cell.pdata_size = sizeof(struct pm8xxx_mpp_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &mpp_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add mpp subdevice ret=%d\n", rc); - goto bail; - } - } - - if (pdata->num_regulators > 0 && pdata->regulator_pdatas) { - mfd_regulators = kzalloc(sizeof(struct mfd_cell) - * (pdata->num_regulators), GFP_KERNEL); - if (!mfd_regulators) { - pr_err("Cannot allocate %d bytes for pm8901 regulator " - "mfd cells\n", sizeof(struct mfd_cell) - * (pdata->num_regulators)); - rc = -ENOMEM; - goto bail; - } - for (i = 0; i < pdata->num_regulators; i++) { - mfd_regulators[i].name = "pm8901-regulator"; - mfd_regulators[i].id = pdata->regulator_pdatas[i].id; - mfd_regulators[i].platform_data = - &(pdata->regulator_pdatas[i]); - mfd_regulators[i].pdata_size = - sizeof(struct pm8901_vreg_pdata); - } - rc = mfd_add_devices(pmic->dev, 0, mfd_regulators, - pdata->num_regulators, NULL, irq_base); - if (rc) { - pr_err("Failed to add regulator subdevices ret=%d\n", - rc); - kfree(mfd_regulators); - goto bail; - } - pmic->mfd_regulators = mfd_regulators; - } - - rc = mfd_add_devices(pmic->dev, 0, &thermal_alarm_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add thermal alarm subdevice ret=%d\n", - rc); - goto bail; - } - - rc = mfd_add_devices(pmic->dev, 0, &debugfs_cell, 1, NULL, irq_base); - if (rc) { - pr_err("Failed to add debugfs subdevice ret=%d\n", rc); - goto bail; - } - - if (pdata->misc_pdata) { - misc_cell.platform_data = pdata->misc_pdata; - misc_cell.pdata_size = sizeof(struct pm8xxx_misc_platform_data); - rc = mfd_add_devices(pmic->dev, 0, &misc_cell, 1, NULL, - irq_base); - if (rc) { - pr_err("Failed to add misc subdevice ret=%d\n", rc); - goto bail; - } - } - - return rc; - -bail: - if (pmic->irq_chip) { - pm8xxx_irq_exit(pmic->irq_chip); - pmic->irq_chip = NULL; - } - return rc; -} - -static const char * const pm8901_rev_names[] = { - [PM8XXX_REVISION_8901_TEST] = "test", - [PM8XXX_REVISION_8901_1p0] = "1.0", - [PM8XXX_REVISION_8901_1p1] = "1.1", - [PM8XXX_REVISION_8901_2p0] = "2.0", - [PM8XXX_REVISION_8901_2p1] = "2.1", - [PM8XXX_REVISION_8901_2p2] = "2.2", - [PM8XXX_REVISION_8901_2p3] = "2.3", -}; - -static int pm8901_probe(struct platform_device *pdev) -{ - int rc; - struct pm8901_platform_data *pdata = pdev->dev.platform_data; - const char *revision_name = "unknown"; - struct pm8901_chip *pmic; - int revision; - - if (pdata == NULL) { - pr_err("%s: No platform_data or IRQ.\n", __func__); - return -ENODEV; - } - - pmic = kzalloc(sizeof *pmic, GFP_KERNEL); - if (pmic == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - return -ENOMEM; - } - - pmic->dev = &pdev->dev; - - pm8901_drvdata.pm_chip_data = pmic; - platform_set_drvdata(pdev, &pm8901_drvdata); - - /* Read PMIC chip revision */ - rc = pm8901_readb(pmic->dev, PM8901_REG_REV, &pmic->revision); - if (rc) - pr_err("%s: Failed reading version register rc=%d.\n", - __func__, rc); - - pr_info("%s: PMIC revision reg: %02X\n", __func__, pmic->revision); - revision = pm8xxx_get_revision(pmic->dev); - if (revision >= 0 && revision < ARRAY_SIZE(pm8901_rev_names)) - revision_name = pm8901_rev_names[revision]; - pr_info("%s: PMIC version: PM8901 rev %s\n", __func__, revision_name); - - (void) memcpy((void *)&pmic->pdata, (const void *)pdata, - sizeof(pmic->pdata)); - - rc = pm8901_add_subdevices(pdata, pmic); - if (rc) { - pr_err("Cannot add subdevices rc=%d\n", rc); - goto err; - } - - return 0; - -err: - platform_set_drvdata(pdev, NULL); - kfree(pmic); - return rc; -} - -static int pm8901_remove(struct platform_device *pdev) -{ - struct pm8xxx_drvdata *drvdata; - struct pm8901_chip *pmic = NULL; - - drvdata = platform_get_drvdata(pdev); - if (drvdata) - pmic = drvdata->pm_chip_data; - if (pmic) { - if (pmic->dev) - mfd_remove_devices(pmic->dev); - if (pmic->irq_chip) - pm8xxx_irq_exit(pmic->irq_chip); - kfree(pmic->mfd_regulators); - kfree(pmic); - } - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver pm8901_driver = { - .probe = pm8901_probe, - .remove = pm8901_remove, - .driver = { - .name = "pm8901-core", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8901_init(void) -{ - return platform_driver_register(&pm8901_driver); -} -postcore_initcall(pm8901_init); - -static void __exit pm8901_exit(void) -{ - platform_driver_unregister(&pm8901_driver); -} -module_exit(pm8901_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8901 core driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pmic8901-core"); diff --git a/drivers/mfd/timpani-codec.c b/drivers/mfd/timpani-codec.c deleted file mode 100644 index 164ffcca1e9f2cced3a52c12cf6ede316de0dfd2..0000000000000000000000000000000000000000 --- a/drivers/mfd/timpani-codec.c +++ /dev/null @@ -1,3661 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Timpani codec driver is activated through Marimba core driver */ - -#define MAX_MDELAY_US 20000 - -#define TIMPANI_PATH_MASK(x) (1 << (x)) - -#define TIMPANI_CODEC_AUXPGA_GAIN_RANGE (0x0F) - -#define TIMPANI_RX1_ST_MASK (TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_L_M |\ - TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_R_M) -#define TIMPANI_RX1_ST_ENABLE ((1 << TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_L_S) |\ - (1 << TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_R_S)) -#define TIMPANI_CDC_ST_MIXING_TX1_MASK (TIMPANI_CDC_ST_MIXING_TX1_L_M |\ - TIMPANI_CDC_ST_MIXING_TX1_R_M) -#define TIMPANI_CDC_ST_MIXING_TX1_ENABLE ((1 << TIMPANI_CDC_ST_MIXING_TX1_L_S)\ - | (1 << TIMPANI_CDC_ST_MIXING_TX1_R_S)) -#define TIMPANI_CDC_ST_MIXING_TX2_MASK (TIMPANI_CDC_ST_MIXING_TX2_L_M |\ - TIMPANI_CDC_ST_MIXING_TX2_R_M) -#define TIMPANI_CDC_ST_MIXING_TX2_ENABLE ((1 << TIMPANI_CDC_ST_MIXING_TX2_L_S)\ - | (1 << TIMPANI_CDC_ST_MIXING_TX2_R_S)) - -enum refcnt { - DEC = 0, - INC = 1, - IGNORE = 2, -}; -#define TIMPANI_ARRAY_SIZE (TIMPANI_A_CDC_COMP_HALT + 1) -#define MAX_SHADOW_RIGISTERS TIMPANI_A_CDC_COMP_HALT - -static u8 timpani_shadow[TIMPANI_ARRAY_SIZE]; - -struct adie_codec_path { - struct adie_codec_dev_profile *profile; - struct adie_codec_register_image img; - u32 hwsetting_idx; - u32 stage_idx; - u32 curr_stage; - u32 reg_owner; -}; - -enum /* regaccess blk id */ -{ - RA_BLOCK_RX1 = 0, - RA_BLOCK_RX2, - RA_BLOCK_TX1, - RA_BLOCK_TX2, - RA_BLOCK_LB, - RA_BLOCK_SHARED_RX_LB, - RA_BLOCK_SHARED_TX, - RA_BLOCK_TXFE1, - RA_BLOCK_TXFE2, - RA_BLOCK_PA_COMMON, - RA_BLOCK_PA_EAR, - RA_BLOCK_PA_HPH, - RA_BLOCK_PA_LINE, - RA_BLOCK_PA_AUX, - RA_BLOCK_ADC, - RA_BLOCK_DMIC, - RA_BLOCK_TX_I2S, - RA_BLOCK_DRV, - RA_BLOCK_TEST, - RA_BLOCK_RESERVED, - RA_BLOCK_NUM, -}; - -enum /* regaccess onwer ID */ -{ - RA_OWNER_NONE = 0, - RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, - RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, - RA_OWNER_PATH_LB, - RA_OWNER_DRV, - RA_OWNER_NUM, -}; - -struct reg_acc_blk_cfg { - u8 valid_owners[RA_OWNER_NUM]; -}; - -struct reg_ref_cnt { - u8 mask; - u8 path_mask; -}; - -#define TIMPANI_MAX_FIELDS 5 - -struct timpani_regaccess { - u8 reg_addr; - u8 blk_mask[RA_BLOCK_NUM]; - u8 reg_mask; - u8 reg_default; - struct reg_ref_cnt fld_ref_cnt[TIMPANI_MAX_FIELDS]; -}; - -struct timpani_regaccess timpani_regset[] = { - { - TIMPANI_A_MREF, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFC, 0x0, 0x3}, - TIMPANI_MREF_M, - TIMPANI_MREF_POR, - { - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDAC_IDAC_REF_CUR, - {0xFC, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDAC_IDAC_REF_CUR_M, - TIMPANI_CDAC_IDAC_REF_CUR_POR, - { - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC12_REF_CURR, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_TXADC12_REF_CURR_M, - TIMPANI_TXADC12_REF_CURR_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC3_EN, - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_TXADC3_EN_M, - TIMPANI_TXADC3_EN_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC4_EN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_TXADC4_EN_M, - TIMPANI_TXADC4_EN_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CODEC_TXADC_STATUS_REGISTER_1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0, 0x30, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF}, - TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_M, - TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_POR, - { - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x30, .path_mask = 0}, - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_TXFE1_M, - TIMPANI_TXFE1_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_TXFE2_M, - TIMPANI_TXFE2_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE12_ATEST, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_TXFE12_ATEST_M, - TIMPANI_TXFE12_ATEST_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE_CLT, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF8, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7}, - TIMPANI_TXFE_CLT_M, - TIMPANI_TXFE_CLT_POR, - { - { .mask = 0xF8, .path_mask = 0}, - { .mask = 0x07, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC1_EN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_TXADC1_EN_M, - TIMPANI_TXADC1_EN_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC2_EN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_TXADC2_EN_M, - TIMPANI_TXADC2_EN_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_TXADC_CTL_M, - TIMPANI_TXADC_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC_CTL2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_TXADC_CTL2_M, - TIMPANI_TXADC_CTL2_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC_CTL3, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xFE, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_TXADC_CTL3_M, - TIMPANI_TXADC_CTL3_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXADC_CHOP_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xFC, 0x0, 0x0, 0x0, 0x0, 0x3}, - TIMPANI_TXADC_CHOP_CTL_M, - TIMPANI_TXADC_CHOP_CTL_POR, - { - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE3, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE2, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1D}, - TIMPANI_TXFE3_M, - TIMPANI_TXFE3_POR, - { - { .mask = 0xE2, .path_mask = 0}, - { .mask = 0x1D, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE4, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE2, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1D}, - TIMPANI_TXFE4_M, - TIMPANI_TXFE4_POR, - { - { .mask = 0xE2, .path_mask = 0}, - { .mask = 0x1D, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE3_ATEST, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_TXFE3_ATEST_M, - TIMPANI_TXFE3_ATEST_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_TXFE_DIFF_SE, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0xC, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF0}, - TIMPANI_TXFE_DIFF_SE_M, - TIMPANI_TXFE_DIFF_SE_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x0C, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDAC_RX_CLK_CTL, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDAC_RX_CLK_CTL_M, - TIMPANI_CDAC_RX_CLK_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDAC_BUFF_CTL, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDAC_BUFF_CTL_M, - TIMPANI_CDAC_BUFF_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDAC_REF_CTL1, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDAC_REF_CTL1_M, - TIMPANI_CDAC_REF_CTL1_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_IDAC_DWA_FIR_CTL, - {0xF8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7}, - TIMPANI_IDAC_DWA_FIR_CTL_M, - TIMPANI_IDAC_DWA_FIR_CTL_POR, - { - { .mask = 0xF8, .path_mask = 0}, - { .mask = 0x07, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDAC_REF_CTL2, - {0x6F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x90}, - TIMPANI_CDAC_REF_CTL2_M, - TIMPANI_CDAC_REF_CTL2_POR, - { - { .mask = 0x6F, .path_mask = 0}, - { .mask = 0x90, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDAC_CTL1, - {0x7F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80}, - TIMPANI_CDAC_CTL1_M, - TIMPANI_CDAC_CTL1_POR, - { - { .mask = 0x7F, .path_mask = 0}, - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDAC_CTL2, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDAC_CTL2_M, - TIMPANI_CDAC_CTL2_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_IDAC_L_CTL, - {0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_IDAC_L_CTL_M, - TIMPANI_IDAC_L_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_IDAC_R_CTL, - {0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_IDAC_R_CTL_M, - TIMPANI_IDAC_R_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_MASTER_BIAS, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, - 0xE0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_MASTER_BIAS_M, - TIMPANI_PA_MASTER_BIAS_POR, - { - { .mask = 0x1F, .path_mask = 0}, - { .mask = 0xE0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_BIAS, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_CLASSD_BIAS_M, - TIMPANI_PA_CLASSD_BIAS_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_AUXPGA_CUR, - {0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_AUXPGA_CUR_M, - TIMPANI_AUXPGA_CUR_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_AUXPGA_CM, - {0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_AUXPGA_CM_M, - TIMPANI_AUXPGA_CM_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_EARPA_MSTB_EN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x2, 0xFC, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_HPH_EARPA_MSTB_EN_M, - TIMPANI_PA_HPH_EARPA_MSTB_EN_POR, - { - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x02, .path_mask = 0}, - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_LINE_AUXO_EN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xF8, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_LINE_AUXO_EN_M, - TIMPANI_PA_LINE_AUXO_EN_POR, - { - { .mask = 0xF8, .path_mask = 0}, - { .mask = 0x07, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_AUXPGA_EN, - {0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_PA_CLASSD_AUXPGA_EN_M, - TIMPANI_PA_CLASSD_AUXPGA_EN_POR, - { - { .mask = 0x30, .path_mask = 0}, - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_LINE_L_GAIN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFC, 0x0, 0x3}, - TIMPANI_PA_LINE_L_GAIN_M, - TIMPANI_PA_LINE_L_GAIN_POR, - { - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_LINE_R_GAIN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFC, 0x0, 0x3}, - TIMPANI_PA_LINE_R_GAIN_M, - TIMPANI_PA_LINE_R_GAIN_POR, - { - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_L_GAIN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, 0x0, 0x1}, - TIMPANI_PA_HPH_L_GAIN_M, - TIMPANI_PA_HPH_L_GAIN_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_R_GAIN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, 0x0, 0x1}, - TIMPANI_PA_HPH_R_GAIN_M, - TIMPANI_PA_HPH_R_GAIN_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_AUXPGA_LR_GAIN, - {0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_AUXPGA_LR_GAIN_M, - TIMPANI_AUXPGA_LR_GAIN_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_AUXO_EARPA_CONN, - {0x21, 0x42, 0x0, 0x0, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18}, - TIMPANI_PA_AUXO_EARPA_CONN_M, - TIMPANI_PA_AUXO_EARPA_CONN_POR, - { - { .mask = 0x21, .path_mask = 0}, - { .mask = 0x42, .path_mask = 0}, - { .mask = 0x84, .path_mask = 0}, - { .mask = 0x18, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_LINE_ST_CONN, - {0x24, 0x48, 0x0, 0x0, 0x93, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_LINE_ST_CONN_M, - TIMPANI_PA_LINE_ST_CONN_POR, - { - { .mask = 0x24, .path_mask = 0}, - { .mask = 0x48, .path_mask = 0}, - { .mask = 0x93, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_LINE_MONO_CONN, - {0x24, 0x48, 0x0, 0x0, 0x93, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_LINE_MONO_CONN_M, - TIMPANI_PA_LINE_MONO_CONN_POR, - { - { .mask = 0x24, .path_mask = 0}, - { .mask = 0x48, .path_mask = 0}, - { .mask = 0x93, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_ST_CONN, - {0x24, 0x48, 0x0, 0x0, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_HPH_ST_CONN_M, - TIMPANI_PA_HPH_ST_CONN_POR, - { - { .mask = 0x24, .path_mask = 0}, - { .mask = 0x48, .path_mask = 0}, - { .mask = 0x90, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_MONO_CONN, - {0x24, 0x48, 0x0, 0x0, 0x90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3}, - TIMPANI_PA_HPH_MONO_CONN_M, - TIMPANI_PA_HPH_MONO_CONN_POR, - { - { .mask = 0x24, .path_mask = 0}, - { .mask = 0x48, .path_mask = 0}, - { .mask = 0x90, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_CONN, - {0x80, 0x40, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF}, - TIMPANI_PA_CLASSD_CONN_M, - TIMPANI_PA_CLASSD_CONN_POR, - { - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x40, .path_mask = 0}, - { .mask = 0x20, .path_mask = 0}, - { .mask = 0x10, .path_mask = 0}, - { .mask = 0x0F, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CNP_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xCF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30}, - TIMPANI_PA_CNP_CTL_M, - TIMPANI_PA_CNP_CTL_POR, - { - { .mask = 0xCF, .path_mask = 0}, - { .mask = 0x30, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_L_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_PA_CLASSD_L_CTL_M, - TIMPANI_PA_CLASSD_L_CTL_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_R_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_PA_CLASSD_R_CTL_M, - TIMPANI_PA_CLASSD_R_CTL_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_INT2_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_CLASSD_INT2_CTL_M, - TIMPANI_PA_CLASSD_INT2_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_L_OCP_CLK_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_HPH_L_OCP_CLK_CTL_M, - TIMPANI_PA_HPH_L_OCP_CLK_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_L_SW_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF7, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8}, - TIMPANI_PA_CLASSD_L_SW_CTL_M, - TIMPANI_PA_CLASSD_L_SW_CTL_POR, - { - { .mask = 0xF7, .path_mask = 0}, - { .mask = 0x08, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_L_OCP1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_CLASSD_L_OCP1_M, - TIMPANI_PA_CLASSD_L_OCP1_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_L_OCP2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_CLASSD_L_OCP2_M, - TIMPANI_PA_CLASSD_L_OCP2_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_R_OCP_CLK_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_HPH_R_OCP_CLK_CTL_M, - TIMPANI_PA_HPH_R_OCP_CLK_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_R_SW_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF7, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8}, - TIMPANI_PA_CLASSD_R_SW_CTL_M, - TIMPANI_PA_CLASSD_R_SW_CTL_POR, - { - { .mask = 0xF7, .path_mask = 0}, - { .mask = 0x08, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_R_OCP1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_CLASSD_R_OCP1_M, - TIMPANI_PA_CLASSD_R_OCP1_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_R_OCP2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_CLASSD_R_OCP2_M, - TIMPANI_PA_CLASSD_R_OCP2_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_CTL1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_PA_HPH_CTL1_M, - TIMPANI_PA_HPH_CTL1_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_CTL2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_PA_HPH_CTL2_M, - TIMPANI_PA_HPH_CTL2_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_LINE_AUXO_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0xC3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x3C, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_LINE_AUXO_CTL_M, - TIMPANI_PA_LINE_AUXO_CTL_POR, - { - { .mask = 0xC3, .path_mask = 0}, - { .mask = 0x3C, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_AUXO_EARPA_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, - 0x0, 0x38, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_PA_AUXO_EARPA_CTL_M, - TIMPANI_PA_AUXO_EARPA_CTL_POR, - { - { .mask = 0x07, .path_mask = 0}, - { .mask = 0x38, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_EARO_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_PA_EARO_CTL_M, - TIMPANI_PA_EARO_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_MASTER_BIAS_CUR, - {0x0, 0x0, 0x0, 0x0, 0x60, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x18, - 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_PA_MASTER_BIAS_CUR_M, - TIMPANI_PA_MASTER_BIAS_CUR_POR, - { - { .mask = 0x60, .path_mask = 0}, - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x18, .path_mask = 0}, - { .mask = 0x06, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_CLASSD_SC_STATUS, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xCC, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x33}, - TIMPANI_PA_CLASSD_SC_STATUS_M, - TIMPANI_PA_CLASSD_SC_STATUS_POR, - { - { .mask = 0xCC, .path_mask = 0}, - { .mask = 0x33, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_PA_HPH_SC_STATUS, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x88, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x77}, - TIMPANI_PA_HPH_SC_STATUS_M, - TIMPANI_PA_HPH_SC_STATUS_POR, - { - { .mask = 0x88, .path_mask = 0}, - { .mask = 0x77, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_EN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x7F}, - TIMPANI_ATEST_EN_M, - TIMPANI_ATEST_EN_POR, - { - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x7F, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_TSHKADC, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF0}, - TIMPANI_ATEST_TSHKADC_M, - TIMPANI_ATEST_TSHKADC_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_TXADC13, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7F, 0x80}, - TIMPANI_ATEST_TXADC13_M, - TIMPANI_ATEST_TXADC13_POR, - { - { .mask = 0x7F, .path_mask = 0}, - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_TXADC24, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7F, 0x80}, - TIMPANI_ATEST_TXADC24_M, - TIMPANI_ATEST_TXADC24_POR, - { - { .mask = 0x7F, .path_mask = 0}, - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_AUXPGA, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF8, 0x7}, - TIMPANI_ATEST_AUXPGA_M, - TIMPANI_ATEST_AUXPGA_POR, - { - { .mask = 0xF8, .path_mask = 0}, - { .mask = 0x07, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_CDAC, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0}, - TIMPANI_ATEST_CDAC_M, - TIMPANI_ATEST_CDAC_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_IDAC, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0}, - TIMPANI_ATEST_IDAC_M, - TIMPANI_ATEST_IDAC_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_PA1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0}, - TIMPANI_ATEST_PA1_M, - TIMPANI_ATEST_PA1_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_CLASSD, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0}, - TIMPANI_ATEST_CLASSD_M, - TIMPANI_ATEST_CLASSD_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_ATEST_LINEO_AUXO, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0}, - TIMPANI_ATEST_LINEO_AUXO_M, - TIMPANI_ATEST_LINEO_AUXO_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RESET_CTL, - {0x2, 0x8, 0x5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_RESET_CTL_M, - TIMPANI_CDC_RESET_CTL_POR, - { - { .mask = 0x02, .path_mask = 0}, - { .mask = 0x08, .path_mask = 0}, - { .mask = 0x05, .path_mask = 0}, - { .mask = 0x30, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX1_CTL, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX1_CTL_M, - TIMPANI_CDC_RX1_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX_I2S_CTL, - {0x0, 0x0, 0x10, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_TX_I2S_CTL_M, - TIMPANI_CDC_TX_I2S_CTL_POR, - { - { .mask = 0x10, .path_mask = 0}, - { .mask = 0x20, .path_mask = 0}, - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_CH_CTL, - {0x3, 0x30, 0xC, 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_CH_CTL_M, - TIMPANI_CDC_CH_CTL_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x30, .path_mask = 0}, - { .mask = 0x0C, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX1LG, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX1LG_M, - TIMPANI_CDC_RX1LG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX1RG, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX1RG_M, - TIMPANI_CDC_RX1RG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX1LG, - {0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX1LG_M, - TIMPANI_CDC_TX1LG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX1RG, - {0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX1RG_M, - TIMPANI_CDC_TX1RG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX_PGA_TIMER, - {0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX_PGA_TIMER_M, - TIMPANI_CDC_RX_PGA_TIMER_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX_PGA_TIMER, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX_PGA_TIMER_M, - TIMPANI_CDC_TX_PGA_TIMER_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_GCTL1, - {0xF, 0x0, 0xF0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_GCTL1_M, - TIMPANI_CDC_GCTL1_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX1L_STG, - {0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX1L_STG_M, - TIMPANI_CDC_TX1L_STG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ST_CTL, - {0x0, 0xF, 0x0, 0xF0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_ST_CTL_M, - TIMPANI_CDC_ST_CTL_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX1L_DCOFFSET, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX1L_DCOFFSET_M, - TIMPANI_CDC_RX1L_DCOFFSET_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX1R_DCOFFSET, - {0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX1R_DCOFFSET_M, - TIMPANI_CDC_RX1R_DCOFFSET_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_BYPASS_CTL1, - {0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF0}, - TIMPANI_CDC_BYPASS_CTL1_M, - TIMPANI_CDC_BYPASS_CTL1_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_PDM_CONFIG, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0xF0}, - TIMPANI_CDC_PDM_CONFIG_M, - TIMPANI_CDC_PDM_CONFIG_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TESTMODE1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, 0xC0}, - TIMPANI_CDC_TESTMODE1_M, - TIMPANI_CDC_TESTMODE1_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_DMIC_CLK_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x3F, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_DMIC_CLK_CTL_M, - TIMPANI_CDC_DMIC_CLK_CTL_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ADC12_CLK_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_ADC12_CLK_CTL_M, - TIMPANI_CDC_ADC12_CLK_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX1_CTL, - {0x0, 0x0, 0x3F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_TX1_CTL_M, - TIMPANI_CDC_TX1_CTL_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ADC34_CLK_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_ADC34_CLK_CTL_M, - TIMPANI_CDC_ADC34_CLK_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX2_CTL, - {0x0, 0x0, 0x0, 0x3F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_TX2_CTL_M, - TIMPANI_CDC_TX2_CTL_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX1_CLK_CTL, - {0x1F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE0}, - TIMPANI_CDC_RX1_CLK_CTL_M, - TIMPANI_CDC_RX1_CLK_CTL_POR, - { - { .mask = 0x1F, .path_mask = 0}, - { .mask = 0xE0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX2_CLK_CTL, - {0x1F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xE0}, - TIMPANI_CDC_RX2_CLK_CTL_M, - TIMPANI_CDC_RX2_CLK_CTL_POR, - { - { .mask = 0x1F, .path_mask = 0}, - { .mask = 0xE0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_DEC_ADC_SEL, - {0x0, 0x0, 0xF, 0xF0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_DEC_ADC_SEL_M, - TIMPANI_CDC_DEC_ADC_SEL_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC_INPUT_MUX, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, 0x0, 0xC0}, - TIMPANI_CDC_ANC_INPUT_MUX_M, - TIMPANI_CDC_ANC_INPUT_MUX_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC_RX_CLK_NS_SEL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFE}, - TIMPANI_CDC_ANC_RX_CLK_NS_SEL_M, - TIMPANI_CDC_ANC_RX_CLK_NS_SEL_POR, - { - { .mask = 0x01, .path_mask = 0}, - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC_FB_TUNE_SEL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_CDC_ANC_FB_TUNE_SEL_M, - TIMPANI_CDC_ANC_FB_TUNE_SEL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CLK_DIV_SYNC_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0xFC}, - TIMPANI_CLK_DIV_SYNC_CTL_M, - TIMPANI_CLK_DIV_SYNC_CTL_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ADC_CLK_EN, - {0x0, 0x0, 0x3, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF0}, - TIMPANI_CDC_ADC_CLK_EN_M, - TIMPANI_CDC_ADC_CLK_EN_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x0C, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ST_MIXING, - {0x0, 0x0, 0x3, 0xC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF0}, - TIMPANI_CDC_ST_MIXING_M, - TIMPANI_CDC_ST_MIXING_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x0C, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX2_CTL, - {0x0, 0x7F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80}, - TIMPANI_CDC_RX2_CTL_M, - TIMPANI_CDC_RX2_CTL_POR, - { - { .mask = 0x7F, .path_mask = 0}, - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ARB_CLK_EN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_CDC_ARB_CLK_EN_M, - TIMPANI_CDC_ARB_CLK_EN_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_I2S_CTL2, - {0x2, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x39, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_I2S_CTL2_M, - TIMPANI_CDC_I2S_CTL2_POR, - { - { .mask = 0x02, .path_mask = 0}, - { .mask = 0x04, .path_mask = 0}, - { .mask = 0x39, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX2LG, - {0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX2LG_M, - TIMPANI_CDC_RX2LG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX2RG, - {0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX2RG_M, - TIMPANI_CDC_RX2RG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX2LG, - {0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX2LG_M, - TIMPANI_CDC_TX2LG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX2RG, - {0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX2RG_M, - TIMPANI_CDC_TX2RG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_DMIC_MUX, - {0x0, 0x0, 0xF, 0xF0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_DMIC_MUX_M, - TIMPANI_CDC_DMIC_MUX_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ARB_CLK_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0xFC}, - TIMPANI_CDC_ARB_CLK_CTL_M, - TIMPANI_CDC_ARB_CLK_CTL_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_GCTL2, - {0x0, 0xF, 0x0, 0xF0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_GCTL2_M, - TIMPANI_CDC_GCTL2_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_BYPASS_CTL2, - {0x0, 0x0, 0x3F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_BYPASS_CTL2_M, - TIMPANI_CDC_BYPASS_CTL2_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_BYPASS_CTL3, - {0x0, 0x0, 0x0, 0x3F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0}, - TIMPANI_CDC_BYPASS_CTL3_M, - TIMPANI_CDC_BYPASS_CTL3_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_BYPASS_CTL4, - {0x0, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xF0}, - TIMPANI_CDC_BYPASS_CTL4_M, - TIMPANI_CDC_BYPASS_CTL4_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX2L_DCOFFSET, - {0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX2L_DCOFFSET_M, - TIMPANI_CDC_RX2L_DCOFFSET_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX2R_DCOFFSET, - {0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_RX2R_DCOFFSET_M, - TIMPANI_CDC_RX2R_DCOFFSET_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_RX_MIX_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0xFC}, - TIMPANI_CDC_RX_MIX_CTL_M, - TIMPANI_CDC_RX_MIX_CTL_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_SPARE_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xFE}, - TIMPANI_CDC_SPARE_CTL_M, - TIMPANI_CDC_SPARE_CTL_POR, - { - { .mask = 0x01, .path_mask = 0}, - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TESTMODE2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0xE0}, - TIMPANI_CDC_TESTMODE2_M, - TIMPANI_CDC_TESTMODE2_POR, - { - { .mask = 0x1F, .path_mask = 0}, - { .mask = 0xE0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_PDM_OE, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0}, - TIMPANI_CDC_PDM_OE_M, - TIMPANI_CDC_PDM_OE_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX1R_STG, - {0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX1R_STG_M, - TIMPANI_CDC_TX1R_STG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX2L_STG, - {0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX2L_STG_M, - TIMPANI_CDC_TX2L_STG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_TX2R_STG, - {0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - TIMPANI_CDC_TX2R_STG_M, - TIMPANI_CDC_TX2R_STG_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ARB_BYPASS_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_CDC_ARB_BYPASS_CTL_M, - TIMPANI_CDC_ARB_BYPASS_CTL_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_CTL1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0x0, 0xE0}, - TIMPANI_CDC_ANC1_CTL1_M, - TIMPANI_CDC_ANC1_CTL1_POR, - { - { .mask = 0x1F, .path_mask = 0}, - { .mask = 0xE0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_CTL2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, 0x0, 0xC0}, - TIMPANI_CDC_ANC1_CTL2_M, - TIMPANI_CDC_ANC1_CTL2_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_FF_FB_SHIFT, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC1_FF_FB_SHIFT_M, - TIMPANI_CDC_ANC1_FF_FB_SHIFT_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_RX_NS, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0xF8}, - TIMPANI_CDC_ANC1_RX_NS_M, - TIMPANI_CDC_ANC1_RX_NS_POR, - { - { .mask = 0x07, .path_mask = 0}, - { .mask = 0xF8, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_SPARE, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC1_SPARE_M, - TIMPANI_CDC_ANC1_SPARE_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_IIR_COEFF_PTR, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0x0, 0xE0}, - TIMPANI_CDC_ANC1_IIR_COEFF_PTR_M, - TIMPANI_CDC_ANC1_IIR_COEFF_PTR_POR, - { - { .mask = 0x1F, .path_mask = 0}, - { .mask = 0xE0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_IIR_COEFF_MSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFE}, - TIMPANI_CDC_ANC1_IIR_COEFF_MSB_M, - TIMPANI_CDC_ANC1_IIR_COEFF_MSB_POR, - { - { .mask = 0x01, .path_mask = 0}, - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_IIR_COEFF_LSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC1_IIR_COEFF_LSB_M, - TIMPANI_CDC_ANC1_IIR_COEFF_LSB_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_IIR_COEFF_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0xFC}, - TIMPANI_CDC_ANC1_IIR_COEFF_CTL_M, - TIMPANI_CDC_ANC1_IIR_COEFF_CTL_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_LPF_COEFF_PTR, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_ANC1_LPF_COEFF_PTR_M, - TIMPANI_CDC_ANC1_LPF_COEFF_PTR_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_LPF_COEFF_MSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_ANC1_LPF_COEFF_MSB_M, - TIMPANI_CDC_ANC1_LPF_COEFF_MSB_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_LPF_COEFF_LSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC1_LPF_COEFF_LSB_M, - TIMPANI_CDC_ANC1_LPF_COEFF_LSB_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_SCALE_PTR, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC1_SCALE_PTR_M, - TIMPANI_CDC_ANC1_SCALE_PTR_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_SCALE, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC1_SCALE_M, - TIMPANI_CDC_ANC1_SCALE_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC1_DEBUG, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_ANC1_DEBUG_M, - TIMPANI_CDC_ANC1_DEBUG_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_CTL1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1F, 0x0, 0xE0}, - TIMPANI_CDC_ANC2_CTL1_M, - TIMPANI_CDC_ANC2_CTL1_POR, - { - { .mask = 0x1F, .path_mask = 0}, - { .mask = 0xE0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_CTL2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, 0x0, 0xC0}, - TIMPANI_CDC_ANC2_CTL2_M, - TIMPANI_CDC_ANC2_CTL2_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_FF_FB_SHIFT, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC2_FF_FB_SHIFT_M, - TIMPANI_CDC_ANC2_FF_FB_SHIFT_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_RX_NS, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0xF8}, - TIMPANI_CDC_ANC2_RX_NS_M, - TIMPANI_CDC_ANC2_RX_NS_POR, - { - { .mask = 0x07, .path_mask = 0}, - { .mask = 0xF8, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_SPARE, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC2_SPARE_M, - TIMPANI_CDC_ANC2_SPARE_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_IIR_COEFF_PTR, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_ANC2_IIR_COEFF_PTR_M, - TIMPANI_CDC_ANC2_IIR_COEFF_PTR_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_IIR_COEFF_MSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFE}, - TIMPANI_CDC_ANC2_IIR_COEFF_MSB_M, - TIMPANI_CDC_ANC2_IIR_COEFF_MSB_POR, - { - { .mask = 0x01, .path_mask = 0}, - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_IIR_COEFF_LSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC2_IIR_COEFF_LSB_M, - TIMPANI_CDC_ANC2_IIR_COEFF_LSB_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_IIR_COEFF_CTL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0xFC}, - TIMPANI_CDC_ANC2_IIR_COEFF_CTL_M, - TIMPANI_CDC_ANC2_IIR_COEFF_CTL_POR, - { - { .mask = 0x03, .path_mask = 0}, - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_LPF_COEFF_PTR, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_ANC2_LPF_COEFF_PTR_M, - TIMPANI_CDC_ANC2_LPF_COEFF_PTR_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_LPF_COEFF_MSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_ANC2_LPF_COEFF_MSB_M, - TIMPANI_CDC_ANC2_LPF_COEFF_MSB_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_LPF_COEFF_LSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC2_LPF_COEFF_LSB_M, - TIMPANI_CDC_ANC2_LPF_COEFF_LSB_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_SCALE_PTR, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC2_SCALE_PTR_M, - TIMPANI_CDC_ANC2_SCALE_PTR_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_SCALE, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_ANC2_SCALE_M, - TIMPANI_CDC_ANC2_SCALE_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_ANC2_DEBUG, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_ANC2_DEBUG_M, - TIMPANI_CDC_ANC2_DEBUG_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_LINE_L_AVOL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xFC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3}, - TIMPANI_CDC_LINE_L_AVOL_M, - TIMPANI_CDC_LINE_L_AVOL_POR, - { - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_LINE_R_AVOL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xFC, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3}, - TIMPANI_CDC_LINE_R_AVOL_M, - TIMPANI_CDC_LINE_R_AVOL_POR, - { - { .mask = 0xFC, .path_mask = 0}, - { .mask = 0x03, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_HPH_L_AVOL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_CDC_HPH_L_AVOL_M, - TIMPANI_CDC_HPH_L_AVOL_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_HPH_R_AVOL, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFE, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, - TIMPANI_CDC_HPH_R_AVOL_M, - TIMPANI_CDC_HPH_R_AVOL_POR, - { - { .mask = 0xFE, .path_mask = 0}, - { .mask = 0x01, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_CTL1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, 0x0, 0xC0}, - TIMPANI_CDC_COMP_CTL1_M, - TIMPANI_CDC_COMP_CTL1_POR, - { - { .mask = 0x3F, .path_mask = 0}, - { .mask = 0xC0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_CTL2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_COMP_CTL2_M, - TIMPANI_CDC_COMP_CTL2_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_PEAK_METER, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_COMP_PEAK_METER_M, - TIMPANI_CDC_COMP_PEAK_METER_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_LEVEL_METER_CTL1, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xF, 0x0, 0xF0}, - TIMPANI_CDC_COMP_LEVEL_METER_CTL1_M, - TIMPANI_CDC_COMP_LEVEL_METER_CTL1_POR, - { - { .mask = 0x0F, .path_mask = 0}, - { .mask = 0xF0, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_LEVEL_METER_CTL2, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_COMP_LEVEL_METER_CTL2_M, - TIMPANI_CDC_COMP_LEVEL_METER_CTL2_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_ZONE_SELECT, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x7F, 0x0, 0x80}, - TIMPANI_CDC_COMP_ZONE_SELECT_M, - TIMPANI_CDC_COMP_ZONE_SELECT_POR, - { - { .mask = 0x7F, .path_mask = 0}, - { .mask = 0x80, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_ZC_MSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_COMP_ZC_MSB_M, - TIMPANI_CDC_COMP_ZC_MSB_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_ZC_LSB, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0}, - TIMPANI_CDC_COMP_ZC_LSB_M, - TIMPANI_CDC_COMP_ZC_LSB_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_SHUT_DOWN, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_CDC_COMP_SHUT_DOWN_M, - TIMPANI_CDC_COMP_SHUT_DOWN_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_SHUT_DOWN_STATUS, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_M, - TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - }, - { - TIMPANI_A_CDC_COMP_HALT, - {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xFF}, - TIMPANI_CDC_COMP_HALT_M, - TIMPANI_CDC_COMP_HALT_POR, - { - { .mask = 0xFF, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - { .mask = 0x00, .path_mask = 0}, - } - } -}; - -struct reg_acc_blk_cfg timpani_blkcfg[RA_BLOCK_NUM] = { - { - .valid_owners = {RA_OWNER_NONE, RA_OWNER_PATH_RX1, - 0, 0, 0, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_RX1 */ - { - .valid_owners = {RA_OWNER_NONE, 0, RA_OWNER_PATH_RX2, - 0, 0, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_RX2 */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, RA_OWNER_PATH_TX1, - 0, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_TX1 */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, 0, RA_OWNER_PATH_TX2, - 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_TX2 */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, 0, 0, - RA_OWNER_PATH_LB, RA_OWNER_DRV} - }, - /* RA_BLOCK_LB */ - { - .valid_owners = {RA_OWNER_NONE, RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, 0, 0, RA_OWNER_PATH_LB, RA_OWNER_DRV} - }, - /* RA_BLOCK_SHARED_RX_LB */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_SHARED_TX */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_TXFE1 */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_TXFE2 */ - { - .valid_owners = {RA_OWNER_NONE, RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, 0, 0, RA_OWNER_PATH_LB, RA_OWNER_DRV} - }, - /* RA_BLOCK_PA_COMMON */ - { - .valid_owners = {RA_OWNER_NONE, RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, 0, 0, RA_OWNER_PATH_LB, RA_OWNER_DRV} - }, - /* RA_BLOCK_PA_EAR */ - { - .valid_owners = {RA_OWNER_NONE, RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, 0, 0, RA_OWNER_PATH_LB, RA_OWNER_DRV} - }, - /* RA_BLOCK_PA_HPH */ - { - .valid_owners = {RA_OWNER_NONE, RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, 0, 0, RA_OWNER_PATH_LB, RA_OWNER_DRV} - }, - /* RA_BLOCK_PA_LINE */ - { - .valid_owners = {RA_OWNER_NONE, RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, 0, 0, RA_OWNER_PATH_LB, RA_OWNER_DRV} - }, - /* RA_BLOCK_PA_AUX */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_ADC */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_DMIC */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_TX_I2S */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, 0, 0, 0, RA_OWNER_DRV} - }, - /*RA_BLOCK_DRV */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, 0, 0, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_TEST */ - { - .valid_owners = {RA_OWNER_NONE, 0, 0, 0, 0, 0, RA_OWNER_DRV} - }, - /* RA_BLOCK_RESERVED */ -}; - -struct adie_codec_state { - struct adie_codec_path path[ADIE_CODEC_MAX]; - u32 ref_cnt; - struct marimba *pdrv_ptr; - struct marimba_codec_platform_data *codec_pdata; - struct mutex lock; -}; - -static struct adie_codec_state adie_codec; - -/* A cacheable register is one that if the register's current value is being - * written to it again, then it is permissable to skip that register write - * because it does not actually change the value of the hardware register. - * - * Some registers are uncacheable, meaning that even they are being written - * again with their current value, the write has another purpose and must go - * through. - * - * Knowing the codec's uncacheable registers allows the driver to avoid - * unnecessary codec register writes while making sure important register writes - * are not skipped. - */ - -static bool timpani_register_is_cacheable(u8 reg) -{ - switch (reg) { - case TIMPANI_A_PA_LINE_L_GAIN: - case TIMPANI_A_PA_LINE_R_GAIN: - case TIMPANI_A_PA_HPH_L_GAIN: - case TIMPANI_A_PA_HPH_R_GAIN: - case TIMPANI_A_CDC_GCTL1: - case TIMPANI_A_CDC_ST_CTL: - case TIMPANI_A_CDC_GCTL2: - case TIMPANI_A_CDC_ARB_BYPASS_CTL: - case TIMPANI_A_CDC_CH_CTL: - case TIMPANI_A_CDC_ANC1_IIR_COEFF_PTR: - case TIMPANI_A_CDC_ANC1_IIR_COEFF_MSB: - case TIMPANI_A_CDC_ANC1_IIR_COEFF_LSB: - case TIMPANI_A_CDC_ANC1_LPF_COEFF_PTR: - case TIMPANI_A_CDC_ANC1_LPF_COEFF_MSB: - case TIMPANI_A_CDC_ANC1_LPF_COEFF_LSB: - case TIMPANI_A_CDC_ANC1_SCALE_PTR: - case TIMPANI_A_CDC_ANC1_SCALE: - case TIMPANI_A_CDC_ANC2_IIR_COEFF_PTR: - case TIMPANI_A_CDC_ANC2_IIR_COEFF_MSB: - case TIMPANI_A_CDC_ANC2_IIR_COEFF_LSB: - case TIMPANI_A_CDC_ANC2_LPF_COEFF_PTR: - case TIMPANI_A_CDC_ANC2_LPF_COEFF_MSB: - case TIMPANI_A_CDC_ANC2_LPF_COEFF_LSB: - case TIMPANI_A_CDC_ANC2_SCALE_PTR: - case TIMPANI_A_CDC_ANC2_SCALE: - case TIMPANI_A_CDC_ANC1_CTL1: - case TIMPANI_A_CDC_ANC1_CTL2: - case TIMPANI_A_CDC_ANC1_FF_FB_SHIFT: - case TIMPANI_A_CDC_ANC2_CTL1: - case TIMPANI_A_CDC_ANC2_CTL2: - case TIMPANI_A_CDC_ANC2_FF_FB_SHIFT: - case TIMPANI_A_AUXPGA_LR_GAIN: - case TIMPANI_A_CDC_ANC_INPUT_MUX: - return false; - default: - return true; - } -} - -static int adie_codec_write(u8 reg, u8 mask, u8 val) -{ - int rc = 0; - u8 new_val; - - if (reg > MAX_SHADOW_RIGISTERS) { - pr_debug("register number is out of bound for shadow" - " registers reg = %d\n", reg); - new_val = (val & mask); - rc = marimba_write_bit_mask(adie_codec.pdrv_ptr, reg, &new_val, - 1, 0xFF); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: fail to write reg %x\n", __func__, reg); - rc = -EIO; - goto error; - } - return rc; - } - new_val = (val & mask) | (timpani_shadow[reg] & ~mask); - if (!(timpani_register_is_cacheable(reg) && - (new_val == timpani_shadow[reg]))) { - - rc = marimba_write_bit_mask(adie_codec.pdrv_ptr, reg, &new_val, - 1, 0xFF); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: fail to write reg %x\n", __func__, reg); - rc = -EIO; - goto error; - } - timpani_shadow[reg] = new_val; - pr_debug("%s: write reg %x val %x new value %x\n", __func__, - reg, val, new_val); - } - -error: - return rc; -} - - -static int reg_in_use(u8 reg_ref, u8 path_type) -{ - if ((reg_ref & ~path_type) == 0) - return 0; - else - return 1; -} - -static int adie_codec_refcnt_write(u8 reg, u8 mask, u8 val, enum refcnt cnt, - u8 path_type) -{ - u8 i; - int j; - u8 fld_mask; - u8 path_mask; - u8 reg_mask = 0; - int rc = 0; - - for (i = 0; i < ARRAY_SIZE(timpani_regset); i++) { - if (timpani_regset[i].reg_addr == reg) { - for (j = 0; j < TIMPANI_MAX_FIELDS; j++) { - fld_mask = timpani_regset[i].fld_ref_cnt[j].mask - & mask; - path_mask = timpani_regset[i].fld_ref_cnt[j] - .path_mask; - if (fld_mask) { - if (!reg_in_use(path_mask, path_type)) - reg_mask |= fld_mask; - if (cnt == INC) - timpani_regset[i].fld_ref_cnt[j] - .path_mask |= path_type; - else if (cnt == DEC) - timpani_regset[i].fld_ref_cnt[j] - .path_mask &= - ~path_type; - } - } - - if (reg_mask) - rc = adie_codec_write(reg, reg_mask, val); - reg_mask = 0; - break; - } - } - - return rc; -} - -static int adie_codec_read(u8 reg, u8 *val) -{ - return marimba_read(adie_codec.pdrv_ptr, reg, val, 1); -} - -static int timpani_adie_codec_setpath(struct adie_codec_path *path_ptr, - u32 freq_plan, u32 osr) -{ - int rc = 0; - u32 i, freq_idx = 0, freq = 0; - - if (path_ptr == NULL) - return -EINVAL; - - if (path_ptr->curr_stage != ADIE_CODEC_DIGITAL_OFF) { - rc = -EBUSY; - goto error; - } - - for (i = 0; i < path_ptr->profile->setting_sz; i++) { - if (path_ptr->profile->settings[i].osr == osr) { - if (path_ptr->profile->settings[i].freq_plan >= - freq_plan) { - if (freq == 0) { - freq = path_ptr->profile->settings[i]. - freq_plan; - freq_idx = i; - } else if (path_ptr->profile->settings[i]. - freq_plan < freq) { - freq = path_ptr->profile->settings[i]. - freq_plan; - freq_idx = i; - } - } - } - } - - if (freq_idx >= path_ptr->profile->setting_sz) - rc = -ENODEV; - else { - path_ptr->hwsetting_idx = freq_idx; - path_ptr->stage_idx = 0; - } - -error: - return rc; -} - -static u32 timpani_adie_codec_freq_supported( - struct adie_codec_dev_profile *profile, - u32 requested_freq) -{ - u32 i, rc = -EINVAL; - - for (i = 0; i < profile->setting_sz; i++) { - if (profile->settings[i].freq_plan >= requested_freq) { - rc = 0; - break; - } - } - return rc; -} -int timpani_adie_codec_enable_sidetone(struct adie_codec_path *rx_path_ptr, - u32 enable) -{ - int rc = 0; - - pr_debug("%s()\n", __func__); - - mutex_lock(&adie_codec.lock); - - if (!rx_path_ptr || &adie_codec.path[ADIE_CODEC_RX] != rx_path_ptr) { - pr_err("%s: invalid path pointer\n", __func__); - rc = -EINVAL; - goto error; - } else if (rx_path_ptr->curr_stage != - ADIE_CODEC_DIGITAL_ANALOG_READY) { - pr_err("%s: bad state\n", __func__); - rc = -EPERM; - goto error; - } - - if (enable) { - rc = adie_codec_write(TIMPANI_A_CDC_RX1_CTL, - TIMPANI_RX1_ST_MASK, TIMPANI_RX1_ST_ENABLE); - - if (rx_path_ptr->reg_owner == RA_OWNER_PATH_RX1) - adie_codec_write(TIMPANI_A_CDC_ST_MIXING, - TIMPANI_CDC_ST_MIXING_TX1_MASK, - TIMPANI_CDC_ST_MIXING_TX1_ENABLE); - else if (rx_path_ptr->reg_owner == RA_OWNER_PATH_RX2) - adie_codec_write(TIMPANI_A_CDC_ST_MIXING, - TIMPANI_CDC_ST_MIXING_TX2_MASK, - TIMPANI_CDC_ST_MIXING_TX2_ENABLE); - } else { - rc = adie_codec_write(TIMPANI_A_CDC_RX1_CTL, - TIMPANI_RX1_ST_MASK, 0); - - if (rx_path_ptr->reg_owner == RA_OWNER_PATH_RX1) - adie_codec_write(TIMPANI_A_CDC_ST_MIXING, - TIMPANI_CDC_ST_MIXING_TX1_MASK, 0); - else if (rx_path_ptr->reg_owner == RA_OWNER_PATH_RX2) - adie_codec_write(TIMPANI_A_CDC_ST_MIXING, - TIMPANI_CDC_ST_MIXING_TX2_MASK, 0); - } - -error: - mutex_unlock(&adie_codec.lock); - return rc; -} -static int timpani_adie_codec_enable_anc(struct adie_codec_path *rx_path_ptr, - u32 enable, struct adie_codec_anc_data *calibration_writes) -{ - int index = 0; - int rc = 0; - u8 reg, mask, val; - pr_debug("%s: enable = %d\n", __func__, enable); - - mutex_lock(&adie_codec.lock); - - if (!rx_path_ptr || &adie_codec.path[ADIE_CODEC_RX] != rx_path_ptr) { - pr_err("%s: invalid path pointer\n", __func__); - rc = -EINVAL; - goto error; - } else if (rx_path_ptr->curr_stage != - ADIE_CODEC_DIGITAL_ANALOG_READY) { - pr_err("%s: bad state\n", __func__); - rc = -EPERM; - goto error; - } - if (enable) { - if (!calibration_writes || !calibration_writes->writes) { - pr_err("%s: No ANC calibration data\n", __func__); - rc = -EPERM; - goto error; - } - while (index < calibration_writes->size) { - ADIE_CODEC_UNPACK_ENTRY(calibration_writes-> - writes[index], reg, mask, val); - adie_codec_write(reg, mask, val); - index++; - } - } else { - adie_codec_write(TIMPANI_A_CDC_ANC1_CTL1, - TIMPANI_CDC_ANC1_CTL1_ANC1_EN_M, - TIMPANI_CDC_ANC1_CTL1_ANC1_EN_ANC_DIS << - TIMPANI_CDC_ANC1_CTL1_ANC1_EN_S); - - adie_codec_write(TIMPANI_A_CDC_ANC2_CTL1, - TIMPANI_CDC_ANC2_CTL1_ANC2_EN_M, - TIMPANI_CDC_ANC2_CTL1_ANC2_EN_ANC_DIS << - TIMPANI_CDC_ANC2_CTL1_ANC2_EN_S); - } - -error: - mutex_unlock(&adie_codec.lock); - return rc; -} - -static void adie_codec_restore_regdefault(u8 path_mask, u32 blk) -{ - u32 ireg; - u32 regset_sz = - (sizeof(timpani_regset)/sizeof(struct timpani_regaccess)); - - for (ireg = 0; ireg < regset_sz; ireg++) { - if (timpani_regset[ireg].blk_mask[blk]) { - /* only process register belong to the block */ - u8 reg = timpani_regset[ireg].reg_addr; - u8 mask = timpani_regset[ireg].blk_mask[blk]; - u8 val = timpani_regset[ireg].reg_default; - adie_codec_refcnt_write(reg, mask, val, IGNORE, - path_mask); - } - } -} - -static void adie_codec_reach_stage_action(struct adie_codec_path *path_ptr, - u32 stage) -{ - u32 iblk, iowner; /* iterators */ - u8 path_mask; - - if (path_ptr == NULL) - return; - - path_mask = TIMPANI_PATH_MASK(path_ptr->reg_owner); - - if (stage != ADIE_CODEC_DIGITAL_OFF) - return; - - for (iblk = 0 ; iblk <= RA_BLOCK_RESERVED ; iblk++) { - for (iowner = 0; iowner < RA_OWNER_NUM; iowner++) { - if (timpani_blkcfg[iblk].valid_owners[iowner] == - path_ptr->reg_owner) { - adie_codec_restore_regdefault(path_mask, iblk); - break; /* This path owns this block */ - } - } - } -} - -static int timpani_adie_codec_proceed_stage(struct adie_codec_path *path_ptr, - u32 state) -{ - int rc = 0, loop_exit = 0; - struct adie_codec_action_unit *curr_action; - struct adie_codec_hwsetting_entry *setting; - u8 reg, mask, val; - u8 path_mask; - - if (path_ptr == NULL) - return -EINVAL; - - path_mask = TIMPANI_PATH_MASK(path_ptr->reg_owner); - - mutex_lock(&adie_codec.lock); - setting = &path_ptr->profile->settings[path_ptr->hwsetting_idx]; - while (!loop_exit) { - - curr_action = &setting->actions[path_ptr->stage_idx]; - - switch (curr_action->type) { - case ADIE_CODEC_ACTION_ENTRY: - ADIE_CODEC_UNPACK_ENTRY(curr_action->action, - reg, mask, val); - if (state == ADIE_CODEC_DIGITAL_OFF) - adie_codec_refcnt_write(reg, mask, val, DEC, - path_mask); - else - adie_codec_refcnt_write(reg, mask, val, INC, - path_mask); - break; - case ADIE_CODEC_ACTION_DELAY_WAIT: - if (curr_action->action > MAX_MDELAY_US) - msleep(curr_action->action/1000); - else - usleep_range(curr_action->action, - curr_action->action); - break; - case ADIE_CODEC_ACTION_STAGE_REACHED: - adie_codec_reach_stage_action(path_ptr, - curr_action->action); - if (curr_action->action == state) { - path_ptr->curr_stage = state; - loop_exit = 1; - } - break; - default: - BUG(); - } - - path_ptr->stage_idx++; - if (path_ptr->stage_idx == setting->action_sz) - path_ptr->stage_idx = 0; - } - mutex_unlock(&adie_codec.lock); - - return rc; -} - -static void timpani_codec_bring_up(void) -{ - /* Codec power up sequence */ - adie_codec_write(0xFF, 0xFF, 0x08); - adie_codec_write(0xFF, 0xFF, 0x0A); - adie_codec_write(0xFF, 0xFF, 0x0E); - adie_codec_write(0xFF, 0xFF, 0x07); - adie_codec_write(0xFF, 0xFF, 0x17); - adie_codec_write(TIMPANI_A_MREF, 0xFF, 0xF2); - msleep(15); - adie_codec_write(TIMPANI_A_MREF, 0xFF, 0x22); - - /* Bypass TX HPFs to prevent pops */ - adie_codec_write(TIMPANI_A_CDC_BYPASS_CTL2, TIMPANI_CDC_BYPASS_CTL2_M, - TIMPANI_CDC_BYPASS_CTL2_POR); - adie_codec_write(TIMPANI_A_CDC_BYPASS_CTL3, TIMPANI_CDC_BYPASS_CTL3_M, - TIMPANI_CDC_BYPASS_CTL3_POR); -} - -static void timpani_codec_bring_down(void) -{ - adie_codec_write(TIMPANI_A_MREF, 0xFF, TIMPANI_MREF_POR); - adie_codec_write(0xFF, 0xFF, 0x07); - adie_codec_write(0xFF, 0xFF, 0x06); - adie_codec_write(0xFF, 0xFF, 0x0E); - adie_codec_write(0xFF, 0xFF, 0x08); -} - -static int timpani_adie_codec_open(struct adie_codec_dev_profile *profile, - struct adie_codec_path **path_pptr) -{ - int rc = 0; - - mutex_lock(&adie_codec.lock); - - if (!profile || !path_pptr) { - rc = -EINVAL; - goto error; - } - - if (adie_codec.path[profile->path_type].profile) { - rc = -EBUSY; - goto error; - } - - if (!adie_codec.ref_cnt) { - - if (adie_codec.codec_pdata && - adie_codec.codec_pdata->marimba_codec_power) { - - rc = adie_codec.codec_pdata->marimba_codec_power(1); - if (rc) { - pr_err("%s: could not power up timpani " - "codec\n", __func__); - goto error; - } - timpani_codec_bring_up(); - } else { - pr_err("%s: couldn't detect timpani codec\n", __func__); - rc = -ENODEV; - goto error; - } - - } - - adie_codec.path[profile->path_type].profile = profile; - *path_pptr = (void *) &adie_codec.path[profile->path_type]; - adie_codec.ref_cnt++; - adie_codec.path[profile->path_type].hwsetting_idx = 0; - adie_codec.path[profile->path_type].curr_stage = ADIE_CODEC_DIGITAL_OFF; - adie_codec.path[profile->path_type].stage_idx = 0; - - -error: - mutex_unlock(&adie_codec.lock); - return rc; -} - -static int timpani_adie_codec_close(struct adie_codec_path *path_ptr) -{ - int rc = 0; - - mutex_lock(&adie_codec.lock); - - if (!path_ptr) { - rc = -EINVAL; - goto error; - } - if (path_ptr->curr_stage != ADIE_CODEC_DIGITAL_OFF) - adie_codec_proceed_stage(path_ptr, ADIE_CODEC_DIGITAL_OFF); - - BUG_ON(!adie_codec.ref_cnt); - - path_ptr->profile = NULL; - adie_codec.ref_cnt--; - - if (!adie_codec.ref_cnt) { - /* Timpani CDC power down sequence */ - timpani_codec_bring_down(); - - if (adie_codec.codec_pdata && - adie_codec.codec_pdata->marimba_codec_power) { - - rc = adie_codec.codec_pdata->marimba_codec_power(0); - if (rc) { - pr_err("%s: could not power down timpani " - "codec\n", __func__); - goto error; - } - } - } - -error: - mutex_unlock(&adie_codec.lock); - return rc; -} - -static int timpani_adie_codec_set_master_mode(struct adie_codec_path *path_ptr, - u8 master) -{ - u8 val = master ? 1 : 0; - - if (!path_ptr) - return -EINVAL; - - if (path_ptr->reg_owner == RA_OWNER_PATH_RX1) - adie_codec_write(TIMPANI_A_CDC_RX1_CTL, 0x01, val); - else if (path_ptr->reg_owner == RA_OWNER_PATH_TX1) - adie_codec_write(TIMPANI_A_CDC_TX_I2S_CTL, 0x01, val); - else - return -EINVAL; - - return 0; -} - -int timpani_adie_codec_set_device_analog_volume( - struct adie_codec_path *path_ptr, - u32 num_channels, u32 volume) -{ - u8 val; - u8 curr_val; - u8 i; - - adie_codec_read(TIMPANI_A_AUXPGA_LR_GAIN, &curr_val); - - /* Volume is expressed as a percentage. */ - /* The upper nibble is the left channel, lower right channel. */ - val = (u8)((volume * TIMPANI_CODEC_AUXPGA_GAIN_RANGE) / 100); - val |= val << 4; - - if ((curr_val & 0x0F) < (val & 0x0F)) { - for (i = curr_val; i < val; i += 0x11) - adie_codec_write(TIMPANI_A_AUXPGA_LR_GAIN, 0xFF, i); - } else if ((curr_val & 0x0F) > (val & 0x0F)) { - for (i = curr_val; i > val; i -= 0x11) - adie_codec_write(TIMPANI_A_AUXPGA_LR_GAIN, 0xFF, i); - } - - return 0; -} - -enum adie_vol_type { - ADIE_CODEC_RX_DIG_VOL, - ADIE_CODEC_TX_DIG_VOL, - ADIE_CODEC_VOL_TYPE_MAX -}; - -#define CDC_RX1LG 0x84 -#define CDC_RX1RG 0x85 -#define CDC_TX1LG 0x86 -#define CDC_TX1RG 0x87 -#define DIG_VOL_MASK 0xFF - -#define CDC_GCTL1 0x8A -#define RX1_PGA_UPDATE_L 0x04 -#define RX1_PGA_UPDATE_R 0x08 -#define TX1_PGA_UPDATE_L 0x40 -#define TX1_PGA_UPDATE_R 0x80 -#define CDC_GCTL1_RX_MASK 0x0F -#define CDC_GCTL1_TX_MASK 0xF0 - -enum { - TIMPANI_MIN_DIG_VOL = -84, /* in DB*/ - TIMPANI_MAX_DIG_VOL = 16, /* in DB*/ - TIMPANI_DIG_VOL_STEP = 3 /* in DB*/ -}; - -static int timpani_adie_codec_set_dig_vol(enum adie_vol_type vol_type, - u32 num_chan, u32 vol_per) -{ - u8 reg_left, reg_right; - u8 gain_reg_val, gain_reg_mask; - s8 new_reg_val, cur_reg_val; - s8 step_size; - - adie_codec_read(CDC_GCTL1, &gain_reg_val); - - if (vol_type == ADIE_CODEC_RX_DIG_VOL) { - - pr_debug("%s : RX DIG VOL. num_chan = %u\n", __func__, - num_chan); - reg_left = CDC_RX1LG; - reg_right = CDC_RX1RG; - - if (num_chan == 1) - gain_reg_val |= RX1_PGA_UPDATE_L; - else - gain_reg_val |= (RX1_PGA_UPDATE_L | RX1_PGA_UPDATE_R); - - gain_reg_mask = CDC_GCTL1_RX_MASK; - } else { - - pr_debug("%s : TX DIG VOL. num_chan = %u\n", __func__, - num_chan); - reg_left = CDC_TX1LG; - reg_right = CDC_TX1RG; - - if (num_chan == 1) - gain_reg_val |= TX1_PGA_UPDATE_L; - else - gain_reg_val |= (TX1_PGA_UPDATE_L | TX1_PGA_UPDATE_R); - - gain_reg_mask = CDC_GCTL1_TX_MASK; - } - - adie_codec_read(reg_left, &cur_reg_val); - - pr_debug("%s: vol_per = %d cur_reg_val = %d 0x%x\n", __func__, vol_per, - cur_reg_val, cur_reg_val); - - new_reg_val = TIMPANI_MIN_DIG_VOL + - (((TIMPANI_MAX_DIG_VOL - TIMPANI_MIN_DIG_VOL) * vol_per) / 100); - - pr_debug("new_reg_val = %d 0x%x\n", new_reg_val, new_reg_val); - - if (new_reg_val > cur_reg_val) { - step_size = TIMPANI_DIG_VOL_STEP; - } else if (new_reg_val < cur_reg_val) { - step_size = -TIMPANI_DIG_VOL_STEP; - } else { - pr_debug("new_reg_val and cur_reg_val are same 0x%x\n", - new_reg_val); - return 0; - } - - while (cur_reg_val != new_reg_val) { - - if (((new_reg_val > cur_reg_val) && - ((new_reg_val - cur_reg_val) < TIMPANI_DIG_VOL_STEP)) || - ((cur_reg_val > new_reg_val) && - ((cur_reg_val - new_reg_val) - < TIMPANI_DIG_VOL_STEP))) { - - cur_reg_val = new_reg_val; - - pr_debug("diff less than step. write new_reg_val = %d" - " 0x%x\n", new_reg_val, new_reg_val); - - } else { - cur_reg_val = cur_reg_val + step_size; - - pr_debug("cur_reg_val = %d 0x%x\n", - cur_reg_val, cur_reg_val); - } - - adie_codec_write(reg_left, DIG_VOL_MASK, cur_reg_val); - - if (num_chan == 2) - adie_codec_write(reg_right, DIG_VOL_MASK, cur_reg_val); - - adie_codec_write(CDC_GCTL1, gain_reg_mask, gain_reg_val); - } - return 0; -} - -static int timpani_adie_codec_set_device_digital_volume( - struct adie_codec_path *path_ptr, - u32 num_channels, u32 vol_percentage /* in percentage */) -{ - enum adie_vol_type vol_type; - - if (!path_ptr || (path_ptr->curr_stage != - ADIE_CODEC_DIGITAL_ANALOG_READY)) { - pr_info("%s: timpani codec not ready for volume control\n", - __func__); - return -EPERM; - } - - if (num_channels > 2) { - pr_err("%s: timpani odec only supports max two channels\n", - __func__); - return -EINVAL; - } - - if (path_ptr->profile->path_type == ADIE_CODEC_RX) { - vol_type = ADIE_CODEC_RX_DIG_VOL; - } else if (path_ptr->profile->path_type == ADIE_CODEC_TX) { - vol_type = ADIE_CODEC_TX_DIG_VOL; - } else { - pr_err("%s: invalid device data neither RX nor TX\n", - __func__); - return -EINVAL; - } - - timpani_adie_codec_set_dig_vol(vol_type, num_channels, vol_percentage); - - return 0; -} - -static const struct adie_codec_operations timpani_adie_ops = { - .codec_id = TIMPANI_ID, - .codec_open = timpani_adie_codec_open, - .codec_close = timpani_adie_codec_close, - .codec_setpath = timpani_adie_codec_setpath, - .codec_proceed_stage = timpani_adie_codec_proceed_stage, - .codec_freq_supported = timpani_adie_codec_freq_supported, - .codec_enable_sidetone = timpani_adie_codec_enable_sidetone, - .codec_set_master_mode = timpani_adie_codec_set_master_mode, - .codec_enable_anc = timpani_adie_codec_enable_anc, - .codec_set_device_analog_volume = - timpani_adie_codec_set_device_analog_volume, - .codec_set_device_digital_volume = - timpani_adie_codec_set_device_digital_volume, -}; - -static void timpani_codec_populate_shadow_registers(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(timpani_regset); i++) { - if (timpani_regset[i].reg_addr < TIMPANI_ARRAY_SIZE) { - timpani_shadow[timpani_regset[i].reg_addr] = - timpani_regset[i].reg_default; - } - } -} - -#ifdef CONFIG_DEBUG_FS -static struct dentry *debugfs_timpani_dent; -static struct dentry *debugfs_peek; -static struct dentry *debugfs_poke; -static struct dentry *debugfs_power; -static struct dentry *debugfs_dump; - -static unsigned char read_data; - -static int codec_debug_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static int get_parameters(char *buf, long int *param1, int num_of_par) -{ - char *token; - int base, cnt; - - token = strsep(&buf, " "); - - for (cnt = 0; cnt < num_of_par; cnt++) { - if (token != NULL) { - if ((token[1] == 'x') || (token[1] == 'X')) - base = 16; - else - base = 10; - - if (strict_strtoul(token, base, ¶m1[cnt]) != 0) - return -EINVAL; - - token = strsep(&buf, " "); - } - else - return -EINVAL; - } - return 0; -} - -static ssize_t codec_debug_read(struct file *file, char __user *ubuf, - size_t count, loff_t *ppos) -{ - char lbuf[8]; - - snprintf(lbuf, sizeof(lbuf), "0x%x\n", read_data); - return simple_read_from_buffer(ubuf, count, ppos, lbuf, strlen(lbuf)); -} - -static ssize_t codec_debug_write(struct file *filp, - const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char *access_str = filp->private_data; - char lbuf[32]; - int rc; - int i; - int read_result; - u8 reg_val; - long int param[5]; - - if (cnt > sizeof(lbuf) - 1) - return -EINVAL; - - rc = copy_from_user(lbuf, ubuf, cnt); - if (rc) - return -EFAULT; - - lbuf[cnt] = '\0'; - - if (!strcmp(access_str, "power")) { - if (get_parameters(lbuf, param, 1) == 0) { - switch (param[0]) { - case 1: - adie_codec.codec_pdata->marimba_codec_power(1); - timpani_codec_bring_up(); - break; - case 0: - timpani_codec_bring_down(); - adie_codec.codec_pdata->marimba_codec_power(0); - break; - default: - rc = -EINVAL; - break; - } - } else - rc = -EINVAL; - } else if (!strcmp(access_str, "poke")) { - /* write */ - rc = get_parameters(lbuf, param, 2); - if ((param[0] <= 0xFF) && (param[1] <= 0xFF) && - (rc == 0)) - adie_codec_write(param[0], 0xFF, param[1]); - else - rc = -EINVAL; - } else if (!strcmp(access_str, "peek")) { - /* read */ - rc = get_parameters(lbuf, param, 1); - if ((param[0] <= 0xFF) && (rc == 0)) - adie_codec_read(param[0], &read_data); - else - rc = -EINVAL; - } else if (!strcmp(access_str, "dump")) { - pr_info("************** timpani regs *************\n"); - for (i = 0; i < 0xFF; i++) { - read_result = adie_codec_read(i, ®_val); - if (read_result < 0) { - pr_info("failed to read codec register\n"); - break; - } else - pr_info("reg 0x%02X val 0x%02X\n", i, reg_val); - } - pr_info("*****************************************\n"); - } - - if (rc == 0) - rc = cnt; - else - pr_err("%s: rc = %d\n", __func__, rc); - - return rc; -} - -static const struct file_operations codec_debug_ops = { - .open = codec_debug_open, - .write = codec_debug_write, - .read = codec_debug_read -}; -#endif - -static int timpani_codec_probe(struct platform_device *pdev) -{ - int rc; - - adie_codec.pdrv_ptr = platform_get_drvdata(pdev); - adie_codec.codec_pdata = pdev->dev.platform_data; - - if (adie_codec.codec_pdata->snddev_profile_init) - adie_codec.codec_pdata->snddev_profile_init(); - - timpani_codec_populate_shadow_registers(); - - /* Register the timpani ADIE operations */ - rc = adie_codec_register_codec_operations(&timpani_adie_ops); - -#ifdef CONFIG_DEBUG_FS - debugfs_timpani_dent = debugfs_create_dir("msm_adie_codec", 0); - if (!IS_ERR(debugfs_timpani_dent)) { - debugfs_peek = debugfs_create_file("peek", - S_IFREG | S_IRUGO, debugfs_timpani_dent, - (void *) "peek", &codec_debug_ops); - - debugfs_poke = debugfs_create_file("poke", - S_IFREG | S_IRUGO, debugfs_timpani_dent, - (void *) "poke", &codec_debug_ops); - - debugfs_power = debugfs_create_file("power", - S_IFREG | S_IRUGO, debugfs_timpani_dent, - (void *) "power", &codec_debug_ops); - - debugfs_dump = debugfs_create_file("dump", - S_IFREG | S_IRUGO, debugfs_timpani_dent, - (void *) "dump", &codec_debug_ops); - - } -#endif - - return rc; -} - -static struct platform_driver timpani_codec_driver = { - .probe = timpani_codec_probe, - .driver = { - .name = "timpani_codec", - .owner = THIS_MODULE, - }, -}; - -static int __init timpani_codec_init(void) -{ - s32 rc; - - rc = platform_driver_register(&timpani_codec_driver); - if (IS_ERR_VALUE(rc)) - goto error; - - adie_codec.path[ADIE_CODEC_TX].reg_owner = RA_OWNER_PATH_TX1; - adie_codec.path[ADIE_CODEC_RX].reg_owner = RA_OWNER_PATH_RX1; - adie_codec.path[ADIE_CODEC_LB].reg_owner = RA_OWNER_PATH_LB; - mutex_init(&adie_codec.lock); -error: - return rc; -} - -static void __exit timpani_codec_exit(void) -{ -#ifdef CONFIG_DEBUG_FS - debugfs_remove(debugfs_peek); - debugfs_remove(debugfs_poke); - debugfs_remove(debugfs_power); - debugfs_remove(debugfs_dump); - debugfs_remove(debugfs_timpani_dent); -#endif - platform_driver_unregister(&timpani_codec_driver); -} - -module_init(timpani_codec_init); -module_exit(timpani_codec_exit); - -MODULE_DESCRIPTION("Timpani codec driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/mfd/tps65023.c b/drivers/mfd/tps65023.c deleted file mode 100644 index 08f88fab787fb4ef94d3b98b6424ff7b5dbf3914..0000000000000000000000000000000000000000 --- a/drivers/mfd/tps65023.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (c) 2009, 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 -#include -#include - -/* TPS65023_registers */ -#define TPS65023_VERSION 0 -#define TPS65023_PGOODZ 1 -#define TPS65023_MASK 2 -#define TPS65023_REG_CTRL 3 -#define TPS65023_CON_CTRL 4 -#define TPS65023_CON_CTRL2 5 -#define TPS65023_DEFCORE 6 -#define TPS65023_DEFSLEW 7 -#define TPS65023_LDO_CTRL 8 -#define TPS65023_MAX 9 - -static struct i2c_client *tpsclient; - -int tps65023_set_dcdc1_level(int mvolts) -{ - int val; - int ret; - - if (!tpsclient) - return -ENODEV; - - if (mvolts < 800 || mvolts > 1600) - return -EINVAL; - - if (mvolts == 1600) - val = 0x1F; - else - val = ((mvolts - 800)/25) & 0x1F; - - ret = i2c_smbus_write_byte_data(tpsclient, TPS65023_DEFCORE, val); - - if (!ret) - ret = i2c_smbus_write_byte_data(tpsclient, - TPS65023_CON_CTRL2, 0x80); - - return ret; -} -EXPORT_SYMBOL(tps65023_set_dcdc1_level); - -int tps65023_get_dcdc1_level(int *mvolts) -{ - int val; - - if (!tpsclient) - return -ENODEV; - - val = i2c_smbus_read_byte_data(tpsclient, TPS65023_DEFCORE) & 0x1F; - - if (val == 0x1F) - *mvolts = 1600; - else - *mvolts = (val * 25) + 800; - return 0; -} -EXPORT_SYMBOL(tps65023_get_dcdc1_level); - -static int tps65023_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - printk(KERN_ERR "TPS65023 does not support SMBUS_BYTE_DATA.\n"); - return -EINVAL; - } - - tpsclient = client; - printk(KERN_INFO "TPS65023: PMIC probed.\n"); - return 0; -} - -static int tps65023_remove(struct i2c_client *client) -{ - tpsclient = NULL; - return 0; -} - -static const struct i2c_device_id tps65023_id[] = { - { "tps65023", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, tps65023_id); - -static struct i2c_driver tps65023_driver = { - .driver = { - .name = "tps65023", - .owner = THIS_MODULE, - }, - .probe = tps65023_probe, - .remove = tps65023_remove, - .id_table = tps65023_id, -}; - -static int __init tps65023_init(void) -{ - return i2c_add_driver(&tps65023_driver); -} - - -static void __exit tps65023_exit(void) -{ - i2c_del_driver(&tps65023_driver); -} - -module_init(tps65023_init); -module_exit(tps65023_exit); diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index b7e257a0fe8dabd6c8aca59008f00fee9faf4ef4..d68fb4f3663d4fb2bda70e8868c07f2e829f5f5e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -543,20 +543,6 @@ config TSIF To compile this driver as module, choose M here: the module will be called msm_tsif. -config TSIF_CHRDEV - tristate "TSIF character device" - depends on TSIF - default n - ---help--- - This driver uses low level TSIF interface. It provides character - device useable from user space programs: one can read TSIF stream - from this device. - - This driver may be used as example for TSIF API usage. - - To compile this driver as module, choose M here: the - module will be called tsif_chrdev. - config TSIF_DEBUG bool "Turn on debugging information for tsif driver" depends on TSIF @@ -571,49 +557,6 @@ config HAPTIC_ISA1200 help The ISA1200 is a high performance enhanced haptic driver. -config PMIC8058_PWM - tristate "Qualcomm PM8058 PWM support" - depends on PMIC8058 - default y - help - This option enables device driver support for the PWM channels - on Qualcomm PM8058 chip. Pulse Width Modulation is used for - purposes including software controlled brightness of backlight, - motor control, and waveform generation. - -config PMIC8XXX_VIBRATOR - tristate "Qualcomm Vibrator support for PMIC8XXX" - depends on MFD_PM8XXX && ANDROID_TIMED_OUTPUT - help - This option enables device driver support for the vibrator - on the PM8XXX chips. The vibrator is controlled using the - timed output class. - -config PMIC8XXX_NFC - tristate "Qualcomm PM8XXX support for Near Field Communication" - depends on MFD_PM8XXX - help - Qualcomm PM8XXX chips have a module to support NFC (Near Field - Communication). This option enables the driver to support it. - -config PMIC8XXX_UPL - tristate "Qualcomm PM8XXX support for User Programmable Logic" - depends on MFD_PM8XXX - help - This option enables device driver support for User Programmable Logic - on Qualcomm PM8XXX chips. The UPL module provides a means to implement - simple truth table based logic via a set of control registers. I/O may - be routed in and out of the UPL module via GPIO or DTEST pins. - -config PMIC8058_XOADC - tristate "Qualcomm PM8058 XOADC driver" - depends on PMIC8058 - default n - help - Enables User processor ADC reads over the XOADC module of Qualcomm's - PMIC8058. Driver interface to program registers of the ADC over - AMUX channels, devices on programmable MPP's and xotherm. - config QSEECOM tristate "Qualcomm Secure Execution Communicator driver" help diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 31ec479d6be0aba1ce313cb007fad491e4ef9994..f4bc9cbef95d6634aaa4047534cf243905572652 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -56,16 +56,7 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_TSIF) += msm_tsif.o -msm_tsif-objs := tsif.o -obj-$(CONFIG_TSIF_CHRDEV) += tsif_chrdev.o obj-$(CONFIG_HAPTIC_ISA1200) += isa1200.o -obj-$(CONFIG_PMIC8058_PWM) += pmic8058-pwm.o -obj-$(CONFIG_PMIC8XXX_VIBRATOR) += pm8xxx-vibrator.o -obj-$(CONFIG_PMIC8XXX_NFC) += pm8xxx-nfc.o -obj-$(CONFIG_PMIC8XXX_UPL) += pm8xxx-upl.o -obj-$(CONFIG_MSM_MEMORY_LOW_POWER_MODE_SUSPEND_DEEP_POWER_DOWN) \ - += msm_migrate_pages.o -obj-$(CONFIG_PMIC8058_XOADC) += pmic8058-xoadc.o obj-$(CONFIG_QSEECOM) += qseecom.o obj-$(CONFIG_QFP_FUSE) += qfp_fuse.o obj-$(CONFIG_TI_DRV2667) += ti_drv2667.o diff --git a/drivers/misc/msm_migrate_pages.c b/drivers/misc/msm_migrate_pages.c deleted file mode 100644 index 24fbb67eea4dfe3ad028cc21114cdc0862a9f89c..0000000000000000000000000000000000000000 --- a/drivers/misc/msm_migrate_pages.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2010, 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 -#include -#include -#include -#include - -static unsigned long unstable_memory_state; - -unsigned long get_msm_migrate_pages_status(void) -{ - return unstable_memory_state; -} -EXPORT_SYMBOL(get_msm_migrate_pages_status); - -#ifdef CONFIG_MEMORY_HOTPLUG -static int migrate_pages_callback(struct notifier_block *self, - unsigned long action, void *arg) -{ - int ret = 0; - - switch (action) { - case MEM_ONLINE: - unstable_memory_state = action; - break; - case MEM_OFFLINE: - unstable_memory_state = action; - break; - case MEM_GOING_OFFLINE: - case MEM_GOING_ONLINE: - case MEM_CANCEL_ONLINE: - case MEM_CANCEL_OFFLINE: - break; - } - return ret; -} -#endif - -static int msm_migrate_pages_probe(struct platform_device *pdev) -{ -#ifdef CONFIG_MEMORY_HOTPLUG - hotplug_memory_notifier(migrate_pages_callback, 0); -#endif - unstable_memory_state = 0; - return 0; -} - -static struct platform_driver msm_migrate_pages_driver = { - .probe = msm_migrate_pages_probe, - .driver = { - .name = "msm_migrate_pages", - }, -}; - -static int __init msm_migrate_pages_init(void) -{ - return platform_driver_register(&msm_migrate_pages_driver); -} - -static void __exit msm_migrate_pages_exit(void) -{ - platform_driver_unregister(&msm_migrate_pages_driver); -} - -module_init(msm_migrate_pages_init); -module_exit(msm_migrate_pages_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Get Status of Unstable Memory Region"); diff --git a/drivers/misc/pm8xxx-nfc.c b/drivers/misc/pm8xxx-nfc.c deleted file mode 100644 index 3ca6eccfe570e4043d0e65b042cded931ab6e5f8..0000000000000000000000000000000000000000 --- a/drivers/misc/pm8xxx-nfc.c +++ /dev/null @@ -1,311 +0,0 @@ -/* Copyright (c) 2010,2011 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. - * - */ -/* - * Qualcomm PMIC8XXX NFC driver - * - */ - -#include -#include -#include -#include -#include -#include -#include - -/* PM8XXX NFC */ -#define SSBI_REG_NFC_CTRL 0x14D -#define SSBI_REG_NFC_TEST 0x14E - -/* NFC_CTRL */ -#define PM8XXX_NFC_SUPPORT_EN 0x80 -#define PM8XXX_NFC_LDO_EN 0x40 -#define PM8XXX_NFC_EN 0x20 -#define PM8XXX_NFC_EXT_VDDLDO_EN 0x10 -#define PM8XXX_NFC_VPH_PWR_EN 0x08 -#define PM8XXX_NFC_RESERVED 0x04 -#define PM8XXX_NFC_VDDLDO_LEVEL 0x03 - -/* NFC_TEST */ -#define PM8XXX_NFC_VDDLDO_MON_EN 0x80 -#define PM8XXX_NFC_ATEST_EN 0x40 -#define PM8XXX_NFC_DTEST1_EN 0x20 -#define PM8XXX_NFC_RESERVED2 0x18 -#define PM8XXX_NFC_VDDLDO_OK_S 0x04 -#define PM8XXX_NFC_MBG_EN_S 0x02 -#define PM8XXX_NFC_EXT_EN_S 0x01 - -struct pm8xxx_nfc_device { - struct device *dev; - struct mutex nfc_mutex; -#if defined(CONFIG_DEBUG_FS) - struct dentry *dent; -#endif -}; -static struct pm8xxx_nfc_device *nfc_dev; - -/* APIs */ -/* - * pm8xxx_nfc_request - request a handle to access NFC device - */ -struct pm8xxx_nfc_device *pm8xxx_nfc_request(void) -{ - return nfc_dev; -} -EXPORT_SYMBOL(pm8xxx_nfc_request); - -/* - * pm8xxx_nfc_config - configure NFC signals - * - * @nfcdev: the NFC device - * @mask: signal mask to configure - * @flags: control flags - */ -int pm8xxx_nfc_config(struct pm8xxx_nfc_device *nfcdev, u32 mask, u32 flags) -{ - u8 nfc_ctrl, nfc_test, m, f; - int rc; - - if (nfcdev == NULL || IS_ERR(nfcdev) || !mask) - return -EINVAL; - - mutex_lock(&nfcdev->nfc_mutex); - - if (!(mask & PM_NFC_CTRL_REQ)) - goto config_test; - - rc = pm8xxx_readb(nfcdev->dev->parent, SSBI_REG_NFC_CTRL, &nfc_ctrl); - if (rc) { - pr_err("%s: FAIL pm8xxx_readb(): rc=%d (nfc_ctrl=0x%x)\n", - __func__, rc, nfc_ctrl); - goto config_done; - } - - m = mask & 0x00ff; - f = flags & 0x00ff; - nfc_ctrl &= ~m; - nfc_ctrl |= m & f; - - rc = pm8xxx_writeb(nfcdev->dev->parent, SSBI_REG_NFC_CTRL, nfc_ctrl); - if (rc) { - pr_err("%s: FAIL pm8xxx_writeb(): rc=%d (nfc_ctrl=0x%x)\n", - __func__, rc, nfc_ctrl); - goto config_done; - } - -config_test: - if (!(mask & PM_NFC_TEST_REQ)) - goto config_done; - - rc = pm8xxx_readb(nfcdev->dev->parent, SSBI_REG_NFC_TEST, &nfc_test); - if (rc) { - pr_err("%s: FAIL pm8xxx_readb(): rc=%d (nfc_test=0x%x)\n", - __func__, rc, nfc_test); - goto config_done; - } - - m = (mask >> 8) & 0x00ff; - f = (flags >> 8) & 0x00ff; - nfc_test &= ~m; - nfc_test |= m & f; - - rc = pm8xxx_writeb(nfcdev->dev->parent, SSBI_REG_NFC_TEST, nfc_test); - if (rc) { - pr_err("%s: FAIL pm8xxx_writeb(): rc=%d (nfc_test=0x%x)\n", - __func__, rc, nfc_test); - goto config_done; - } - -config_done: - mutex_unlock(&nfcdev->nfc_mutex); - return 0; -} -EXPORT_SYMBOL(pm8xxx_nfc_config); - -/* - * pm8xxx_nfc_get_status - get NFC status - * - * @nfcdev: the NFC device - * @mask: of status mask to read - * @status: pointer to the status variable - */ -int pm8xxx_nfc_get_status(struct pm8xxx_nfc_device *nfcdev, - u32 mask, u32 *status) -{ - u8 nfc_ctrl, nfc_test; - u32 st; - int rc; - - if (nfcdev == NULL || IS_ERR(nfcdev) || status == NULL) - return -EINVAL; - - st = 0; - mutex_lock(&nfcdev->nfc_mutex); - - if (!(mask & PM_NFC_CTRL_REQ)) - goto read_test; - - rc = pm8xxx_readb(nfcdev->dev->parent, SSBI_REG_NFC_CTRL, &nfc_ctrl); - if (rc) { - pr_err("%s: FAIL pm8xxx_readb(): rc=%d (nfc_ctrl=0x%x)\n", - __func__, rc, nfc_ctrl); - goto get_status_done; - } - -read_test: - if (!(mask & (PM_NFC_TEST_REQ | PM_NFC_TEST_STATUS))) - goto get_status_done; - - rc = pm8xxx_readb(nfcdev->dev->parent, SSBI_REG_NFC_TEST, &nfc_test); - if (rc) - pr_err("%s: FAIL pm8xxx_readb(): rc=%d (nfc_test=0x%x)\n", - __func__, rc, nfc_test); - -get_status_done: - st = nfc_ctrl; - st |= nfc_test << 8; - *status = st; - - mutex_unlock(&nfcdev->nfc_mutex); - return 0; -} -EXPORT_SYMBOL(pm8xxx_nfc_get_status); - -/* - * pm8xxx_nfc_free - free the NFC device - */ -void pm8xxx_nfc_free(struct pm8xxx_nfc_device *nfcdev) -{ - /* Disable all signals */ - pm8xxx_nfc_config(nfcdev, PM_NFC_CTRL_REQ, 0); -} -EXPORT_SYMBOL(pm8xxx_nfc_free); - -#if defined(CONFIG_DEBUG_FS) -static int pm8xxx_nfc_debug_set(void *data, u64 val) -{ - struct pm8xxx_nfc_device *nfcdev; - u32 mask, control; - int rc; - - nfcdev = (struct pm8xxx_nfc_device *)data; - control = (u32)val & 0xffff; - mask = ((u32)val >> 16) & 0xffff; - rc = pm8xxx_nfc_config(nfcdev, mask, control); - if (rc) - pr_err("%s: ERR pm8xxx_nfc_config: rc=%d, " - "[mask, control]=[0x%x, 0x%x]\n", - __func__, rc, mask, control); - - return 0; -} - -static int pm8xxx_nfc_debug_get(void *data, u64 *val) -{ - struct pm8xxx_nfc_device *nfcdev; - u32 status; - int rc; - - nfcdev = (struct pm8xxx_nfc_device *)data; - rc = pm8xxx_nfc_get_status(nfcdev, (u32)-1, &status); - if (rc) - pr_err("%s: ERR pm8xxx_nfc_get_status: rc=%d, status=0x%x\n", - __func__, rc, status); - - if (val) - *val = (u64)status; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(pm8xxx_nfc_fops, pm8xxx_nfc_debug_get, - pm8xxx_nfc_debug_set, "%llu\n"); - -static int pm8xxx_nfc_debug_init(struct pm8xxx_nfc_device *nfcdev) -{ - struct dentry *dent; - - dent = debugfs_create_file("pm8xxx-nfc", 0644, NULL, - (void *)nfcdev, &pm8xxx_nfc_fops); - - if (dent == NULL || IS_ERR(dent)) - pr_err("%s: ERR debugfs_create_file: dent=0x%x\n", - __func__, (unsigned)dent); - - nfcdev->dent = dent; - return 0; -} -#endif - -static int pm8xxx_nfc_probe(struct platform_device *pdev) -{ - struct pm8xxx_nfc_device *nfcdev; - - nfcdev = kzalloc(sizeof *nfcdev, GFP_KERNEL); - if (nfcdev == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - return -ENOMEM; - } - - mutex_init(&nfcdev->nfc_mutex); - - nfcdev->dev = &pdev->dev; - nfc_dev = nfcdev; - platform_set_drvdata(pdev, nfcdev); - -#if defined(CONFIG_DEBUG_FS) - pm8xxx_nfc_debug_init(nfc_dev); -#endif - - pr_notice("%s: OK\n", __func__); - return 0; -} - -static int pm8xxx_nfc_remove(struct platform_device *pdev) -{ - struct pm8xxx_nfc_device *nfcdev = platform_get_drvdata(pdev); - -#if defined(CONFIG_DEBUG_FS) - debugfs_remove(nfcdev->dent); -#endif - - platform_set_drvdata(pdev, NULL); - kfree(nfcdev); - return 0; -} - -static struct platform_driver pm8xxx_nfc_driver = { - .probe = pm8xxx_nfc_probe, - .remove = pm8xxx_nfc_remove, - .driver = { - .name = PM8XXX_NFC_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_nfc_init(void) -{ - return platform_driver_register(&pm8xxx_nfc_driver); -} - -static void __exit pm8xxx_nfc_exit(void) -{ - platform_driver_unregister(&pm8xxx_nfc_driver); -} - -module_init(pm8xxx_nfc_init); -module_exit(pm8xxx_nfc_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PM8XXX NFC driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_NFC_DEV_NAME); diff --git a/drivers/misc/pm8xxx-upl.c b/drivers/misc/pm8xxx-upl.c deleted file mode 100644 index 69ac00102cf043b837d9bb8698033b4c978fa360..0000000000000000000000000000000000000000 --- a/drivers/misc/pm8xxx-upl.c +++ /dev/null @@ -1,350 +0,0 @@ -/* Copyright (c) 2010,2011 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. - * - */ -/* - * Qualcomm PM8XXX UPL driver - * - */ - -#include -#include -#include -#include -#include -#include -#include - -/* PMIC8XXX UPL registers */ -#define SSBI_REG_UPL_CTRL 0x17B -#define SSBI_REG_UPL_TRUTHTABLE1 0x17C -#define SSBI_REG_UPL_TRUTHTABLE2 0x17D - -struct pm8xxx_upl_device { - struct device *dev; - struct mutex upl_mutex; -#if defined(CONFIG_DEBUG_FS) - struct dentry *dent; -#endif -}; -static struct pm8xxx_upl_device *upl_dev; - -/* APIs */ - -/* - * pm8xxx_upl_request - request a handle to access UPL device - */ -struct pm8xxx_upl_device *pm8xxx_upl_request(void) -{ - return upl_dev; -} -EXPORT_SYMBOL(pm8xxx_upl_request); - -/* - * pm8xxx_upl_read_truthtable - read value currently stored in UPL truth table - * - * @upldev: the UPL device - * @truthtable: value read from UPL truth table - */ -int pm8xxx_upl_read_truthtable(struct pm8xxx_upl_device *upldev, - u16 *truthtable) -{ - int rc = 0; - u8 table[2]; - - if (upldev == NULL || IS_ERR(upldev)) - return -EINVAL; - - mutex_lock(&upldev->upl_mutex); - - rc = pm8xxx_readb(upldev->dev->parent, SSBI_REG_UPL_TRUTHTABLE1, - &(table[0])); - if (rc) { - pr_err("%s: FAIL pm8xxx_readb(0x%X)=0x%02X: rc=%d\n", - __func__, SSBI_REG_UPL_TRUTHTABLE1, table[0], rc); - goto upl_read_done; - } - - rc = pm8xxx_readb(upldev->dev->parent, SSBI_REG_UPL_TRUTHTABLE2, - &(table[1])); - if (rc) - pr_err("%s: FAIL pm8xxx_readb(0x%X)=0x%02X: rc=%d\n", - __func__, SSBI_REG_UPL_TRUTHTABLE2, table[1], rc); -upl_read_done: - mutex_unlock(&upldev->upl_mutex); - *truthtable = (((u16)table[1]) << 8) | table[0]; - return rc; -} -EXPORT_SYMBOL(pm8xxx_upl_read_truthtable); - -/* - * pm8xxx_upl_writes_truthtable - write value into UPL truth table - * - * @upldev: the UPL device - * @truthtable: value written to UPL truth table - * - * Each bit in parameter "truthtable" corresponds to the UPL output for a given - * set of input pin values. For example, if the input pins have the following - * values: A=1, B=1, C=1, D=0, then the UPL would output the value of bit 14 - * (0b1110) in parameter "truthtable". - */ -int pm8xxx_upl_write_truthtable(struct pm8xxx_upl_device *upldev, - u16 truthtable) -{ - int rc = 0; - u8 table[2]; - - if (upldev == NULL || IS_ERR(upldev)) - return -EINVAL; - - table[0] = truthtable & 0xFF; - table[1] = (truthtable >> 8) & 0xFF; - - mutex_lock(&upldev->upl_mutex); - - rc = pm8xxx_writeb(upldev->dev->parent, SSBI_REG_UPL_TRUTHTABLE1, - table[0]); - if (rc) { - pr_err("%s: FAIL pm8xxx_writeb(0x%X)=0x%04X: rc=%d\n", - __func__, SSBI_REG_UPL_TRUTHTABLE1, table[0], rc); - goto upl_write_done; - } - - rc = pm8xxx_writeb(upldev->dev->parent, SSBI_REG_UPL_TRUTHTABLE2, - table[1]); - if (rc) - pr_err("%s: FAIL pm8xxx_writeb(0x%X)=0x%04X: rc=%d\n", - __func__, SSBI_REG_UPL_TRUTHTABLE2, table[1], rc); -upl_write_done: - mutex_unlock(&upldev->upl_mutex); - return rc; -} -EXPORT_SYMBOL(pm8xxx_upl_write_truthtable); - -/* - * pm8xxx_upl_config - configure UPL I/O settings and UPL enable/disable - * - * @upldev: the UPL device - * @mask: setting mask to configure - * @flags: setting flags - */ -int pm8xxx_upl_config(struct pm8xxx_upl_device *upldev, u32 mask, u32 flags) -{ - int rc; - u8 upl_ctrl, m, f; - - if (upldev == NULL || IS_ERR(upldev)) - return -EINVAL; - - mutex_lock(&upldev->upl_mutex); - - rc = pm8xxx_readb(upldev->dev->parent, SSBI_REG_UPL_CTRL, &upl_ctrl); - if (rc) { - pr_err("%s: FAIL pm8xxx_readb(0x%X)=0x%02X: rc=%d\n", - __func__, SSBI_REG_UPL_CTRL, upl_ctrl, rc); - goto upl_config_done; - } - - m = mask & 0x00ff; - f = flags & 0x00ff; - upl_ctrl &= ~m; - upl_ctrl |= m & f; - - rc = pm8xxx_writeb(upldev->dev->parent, SSBI_REG_UPL_CTRL, upl_ctrl); - if (rc) - pr_err("%s: FAIL pm8xxx_writeb(0x%X)=0x%02X: rc=%d\n", - __func__, SSBI_REG_UPL_CTRL, upl_ctrl, rc); -upl_config_done: - mutex_unlock(&upldev->upl_mutex); - return rc; -} -EXPORT_SYMBOL(pm8xxx_upl_config); - -#if defined(CONFIG_DEBUG_FS) - -static int truthtable_set(void *data, u64 val) -{ - int rc; - - rc = pm8xxx_upl_write_truthtable(data, val); - if (rc) - pr_err("%s: pm8xxx_upl_write_truthtable: rc=%d, " - "truthtable=0x%llX\n", __func__, rc, val); - return rc; -} - -static int truthtable_get(void *data, u64 *val) -{ - int rc; - u16 truthtable; - - rc = pm8xxx_upl_read_truthtable(data, &truthtable); - if (rc) - pr_err("%s: pm8xxx_upl_read_truthtable: rc=%d, " - "truthtable=0x%X\n", __func__, rc, truthtable); - if (val) - *val = truthtable; - - return rc; -} - -DEFINE_SIMPLE_ATTRIBUTE(upl_truthtable_fops, truthtable_get, - truthtable_set, "0x%04llX\n"); - -/* enter values as 0xMMMMFFFF where MMMM is the mask and FFFF is the flags */ -static int control_set(void *data, u64 val) -{ - u8 mask, flags; - int rc; - - flags = val & 0xFFFF; - mask = (val >> 16) & 0xFFFF; - - rc = pm8xxx_upl_config(data, mask, flags); - if (rc) - pr_err("%s: pm8xxx_upl_config: rc=%d, mask = 0x%X, " - "flags = 0x%X\n", __func__, rc, mask, flags); - return rc; -} - -static int control_get(void *data, u64 *val) -{ - struct pm8xxx_upl_device *upldev; - int rc = 0; - u8 ctrl; - - upldev = data; - - mutex_lock(&upldev->upl_mutex); - - rc = pm8xxx_readb(upldev->dev->parent, SSBI_REG_UPL_CTRL, &ctrl); - if (rc) - pr_err("%s: FAIL pm8xxx_readb(): rc=%d (ctrl=0x%02X)\n", - __func__, rc, ctrl); - - mutex_unlock(&upldev->upl_mutex); - - *val = ctrl; - - return rc; -} - -DEFINE_SIMPLE_ATTRIBUTE(upl_control_fops, control_get, - control_set, "0x%02llX\n"); - -static int pm8xxx_upl_debug_init(struct pm8xxx_upl_device *upldev) -{ - struct dentry *dent; - struct dentry *temp; - - dent = debugfs_create_dir("pm8xxx-upl", NULL); - if (dent == NULL || IS_ERR(dent)) { - pr_err("%s: ERR debugfs_create_dir: dent=0x%X\n", - __func__, (unsigned)dent); - return -ENOMEM; - } - - temp = debugfs_create_file("truthtable", S_IRUSR | S_IWUSR, dent, - upldev, &upl_truthtable_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("%s: ERR debugfs_create_file: dent=0x%X\n", - __func__, (unsigned)dent); - goto debug_error; - } - - temp = debugfs_create_file("control", S_IRUSR | S_IWUSR, dent, - upldev, &upl_control_fops); - if (temp == NULL || IS_ERR(temp)) { - pr_err("%s: ERR debugfs_create_file: dent=0x%X\n", - __func__, (unsigned)dent); - goto debug_error; - } - - upldev->dent = dent; - return 0; - -debug_error: - debugfs_remove_recursive(dent); - return -ENOMEM; -} - -static int pm8xxx_upl_debug_remove(struct pm8xxx_upl_device *upldev) -{ - debugfs_remove_recursive(upldev->dent); - return 0; -} - -#endif /* CONFIG_DEBUG_FS */ - -static int pm8xxx_upl_probe(struct platform_device *pdev) -{ - struct pm8xxx_upl_device *upldev; - - upldev = kzalloc(sizeof *upldev, GFP_KERNEL); - if (upldev == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - return -ENOMEM; - } - - mutex_init(&upldev->upl_mutex); - - upl_dev = upldev; - upldev->dev = &pdev->dev; - platform_set_drvdata(pdev, upldev); - -#if defined(CONFIG_DEBUG_FS) - pm8xxx_upl_debug_init(upl_dev); -#endif - pr_notice("%s: OK\n", __func__); - return 0; -} - -static int pm8xxx_upl_remove(struct platform_device *pdev) -{ - struct pm8xxx_upl_device *upldev = platform_get_drvdata(pdev); - -#if defined(CONFIG_DEBUG_FS) - pm8xxx_upl_debug_remove(upldev); -#endif - - platform_set_drvdata(pdev, NULL); - kfree(upldev); - pr_notice("%s: OK\n", __func__); - - return 0; -} - -static struct platform_driver pm8xxx_upl_driver = { - .probe = pm8xxx_upl_probe, - .remove = pm8xxx_upl_remove, - .driver = { - .name = PM8XXX_UPL_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_upl_init(void) -{ - return platform_driver_register(&pm8xxx_upl_driver); -} - -static void __exit pm8xxx_upl_exit(void) -{ - platform_driver_unregister(&pm8xxx_upl_driver); -} - -module_init(pm8xxx_upl_init); -module_exit(pm8xxx_upl_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PM8XXX UPL driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_UPL_DEV_NAME); diff --git a/drivers/misc/pm8xxx-vibrator.c b/drivers/misc/pm8xxx-vibrator.c deleted file mode 100644 index 9565c3f45ae312e1086c762fb6e3a7880d76b5fe..0000000000000000000000000000000000000000 --- a/drivers/misc/pm8xxx-vibrator.c +++ /dev/null @@ -1,325 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../staging/android/timed_output.h" - -#define VIB_DRV 0x4A - -#define VIB_DRV_SEL_MASK 0xf8 -#define VIB_DRV_SEL_SHIFT 0x03 -#define VIB_DRV_EN_MANUAL_MASK 0xfc -#define VIB_DRV_LOGIC_SHIFT 0x2 - -#define VIB_MAX_LEVEL_mV 3100 -#define VIB_MIN_LEVEL_mV 1200 - -struct pm8xxx_vib { - struct hrtimer vib_timer; - struct timed_output_dev timed_dev; - spinlock_t lock; - struct work_struct work; - struct device *dev; - const struct pm8xxx_vibrator_platform_data *pdata; - int state; - int level; - u8 reg_vib_drv; -}; - -static struct pm8xxx_vib *vib_dev; - -int pm8xxx_vibrator_config(struct pm8xxx_vib_config *vib_config) -{ - u8 reg = 0; - int rc; - - if (vib_dev == NULL) { - pr_err("%s: vib_dev is NULL\n", __func__); - return -EINVAL; - } - - if (vib_config->drive_mV) { - if ((vib_config->drive_mV < VIB_MIN_LEVEL_mV) || - (vib_config->drive_mV > VIB_MAX_LEVEL_mV)) { - pr_err("Invalid vibrator drive strength\n"); - return -EINVAL; - } - } - - reg = (vib_config->drive_mV / 100) << VIB_DRV_SEL_SHIFT; - - reg |= (!!vib_config->active_low) << VIB_DRV_LOGIC_SHIFT; - - reg |= vib_config->enable_mode; - - rc = pm8xxx_writeb(vib_dev->dev->parent, VIB_DRV, reg); - if (rc) - pr_err("%s: pm8xxx write failed: rc=%d\n", __func__, rc); - - return rc; -} -EXPORT_SYMBOL(pm8xxx_vibrator_config); - -/* REVISIT: just for debugging, will be removed in final working version */ -static void __dump_vib_regs(struct pm8xxx_vib *vib, char *msg) -{ - u8 temp; - - dev_dbg(vib->dev, "%s\n", msg); - - pm8xxx_readb(vib->dev->parent, VIB_DRV, &temp); - dev_dbg(vib->dev, "VIB_DRV - %X\n", temp); -} - -static int pm8xxx_vib_read_u8(struct pm8xxx_vib *vib, - u8 *data, u16 reg) -{ - int rc; - - rc = pm8xxx_readb(vib->dev->parent, reg, data); - if (rc < 0) - dev_warn(vib->dev, "Error reading pm8xxx: %X - ret %X\n", - reg, rc); - - return rc; -} - -static int pm8xxx_vib_write_u8(struct pm8xxx_vib *vib, - u8 data, u16 reg) -{ - int rc; - - rc = pm8xxx_writeb(vib->dev->parent, reg, data); - if (rc < 0) - dev_warn(vib->dev, "Error writing pm8xxx: %X - ret %X\n", - reg, rc); - return rc; -} - -static int pm8xxx_vib_set(struct pm8xxx_vib *vib, int on) -{ - int rc; - u8 val; - - if (on) { - val = vib->reg_vib_drv; - val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK); - rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV); - if (rc < 0) - return rc; - vib->reg_vib_drv = val; - } else { - val = vib->reg_vib_drv; - val &= ~VIB_DRV_SEL_MASK; - rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV); - if (rc < 0) - return rc; - vib->reg_vib_drv = val; - } - __dump_vib_regs(vib, "vib_set_end"); - - return rc; -} - -static void pm8xxx_vib_enable(struct timed_output_dev *dev, int value) -{ - struct pm8xxx_vib *vib = container_of(dev, struct pm8xxx_vib, - timed_dev); - unsigned long flags; - -retry: - spin_lock_irqsave(&vib->lock, flags); - if (hrtimer_try_to_cancel(&vib->vib_timer) < 0) { - spin_unlock_irqrestore(&vib->lock, flags); - cpu_relax(); - goto retry; - } - - if (value == 0) - vib->state = 0; - else { - value = (value > vib->pdata->max_timeout_ms ? - vib->pdata->max_timeout_ms : value); - vib->state = 1; - hrtimer_start(&vib->vib_timer, - ktime_set(value / 1000, (value % 1000) * 1000000), - HRTIMER_MODE_REL); - } - spin_unlock_irqrestore(&vib->lock, flags); - schedule_work(&vib->work); -} - -static void pm8xxx_vib_update(struct work_struct *work) -{ - struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib, - work); - - pm8xxx_vib_set(vib, vib->state); -} - -static int pm8xxx_vib_get_time(struct timed_output_dev *dev) -{ - struct pm8xxx_vib *vib = container_of(dev, struct pm8xxx_vib, - timed_dev); - - if (hrtimer_active(&vib->vib_timer)) { - ktime_t r = hrtimer_get_remaining(&vib->vib_timer); - return (int)ktime_to_us(r); - } else - return 0; -} - -static enum hrtimer_restart pm8xxx_vib_timer_func(struct hrtimer *timer) -{ - struct pm8xxx_vib *vib = container_of(timer, struct pm8xxx_vib, - vib_timer); - - vib->state = 0; - schedule_work(&vib->work); - - return HRTIMER_NORESTART; -} - -#ifdef CONFIG_PM -static int pm8xxx_vib_suspend(struct device *dev) -{ - struct pm8xxx_vib *vib = dev_get_drvdata(dev); - - hrtimer_cancel(&vib->vib_timer); - cancel_work_sync(&vib->work); - /* turn-off vibrator */ - pm8xxx_vib_set(vib, 0); - - return 0; -} - -static const struct dev_pm_ops pm8xxx_vib_pm_ops = { - .suspend = pm8xxx_vib_suspend, -}; -#endif - -static int pm8xxx_vib_probe(struct platform_device *pdev) - -{ - const struct pm8xxx_vibrator_platform_data *pdata = - pdev->dev.platform_data; - struct pm8xxx_vib *vib; - u8 val; - int rc; - - if (!pdata) - return -EINVAL; - - if (pdata->level_mV < VIB_MIN_LEVEL_mV || - pdata->level_mV > VIB_MAX_LEVEL_mV) - return -EINVAL; - - vib = kzalloc(sizeof(*vib), GFP_KERNEL); - if (!vib) - return -ENOMEM; - - vib->pdata = pdata; - vib->level = pdata->level_mV / 100; - vib->dev = &pdev->dev; - - spin_lock_init(&vib->lock); - INIT_WORK(&vib->work, pm8xxx_vib_update); - - hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - vib->vib_timer.function = pm8xxx_vib_timer_func; - - vib->timed_dev.name = "vibrator"; - vib->timed_dev.get_time = pm8xxx_vib_get_time; - vib->timed_dev.enable = pm8xxx_vib_enable; - - __dump_vib_regs(vib, "boot_vib_default"); - - /* - * Configure the vibrator, it operates in manual mode - * for timed_output framework. - */ - rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV); - if (rc < 0) - goto err_read_vib; - val &= ~VIB_DRV_EN_MANUAL_MASK; - rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV); - if (rc < 0) - goto err_read_vib; - - vib->reg_vib_drv = val; - - rc = timed_output_dev_register(&vib->timed_dev); - if (rc < 0) - goto err_read_vib; - - pm8xxx_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms); - - platform_set_drvdata(pdev, vib); - - vib_dev = vib; - - return 0; - -err_read_vib: - kfree(vib); - return rc; -} - -static int pm8xxx_vib_remove(struct platform_device *pdev) -{ - struct pm8xxx_vib *vib = platform_get_drvdata(pdev); - - cancel_work_sync(&vib->work); - hrtimer_cancel(&vib->vib_timer); - timed_output_dev_unregister(&vib->timed_dev); - platform_set_drvdata(pdev, NULL); - kfree(vib); - - return 0; -} - -static struct platform_driver pm8xxx_vib_driver = { - .probe = pm8xxx_vib_probe, - .remove = pm8xxx_vib_remove, - .driver = { - .name = PM8XXX_VIBRATOR_DEV_NAME, - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &pm8xxx_vib_pm_ops, -#endif - }, -}; - -static int __init pm8xxx_vib_init(void) -{ - return platform_driver_register(&pm8xxx_vib_driver); -} -module_init(pm8xxx_vib_init); - -static void __exit pm8xxx_vib_exit(void) -{ - platform_driver_unregister(&pm8xxx_vib_driver); -} -module_exit(pm8xxx_vib_exit); - -MODULE_ALIAS("platform:" PM8XXX_VIBRATOR_DEV_NAME); -MODULE_DESCRIPTION("pm8xxx vibrator driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/misc/pmic8058-pwm.c b/drivers/misc/pmic8058-pwm.c deleted file mode 100644 index 6aad6b9a9d991227cf1b71a353c3faa7d5047622..0000000000000000000000000000000000000000 --- a/drivers/misc/pmic8058-pwm.c +++ /dev/null @@ -1,1085 +0,0 @@ -/* Copyright (c) 2010-2011, 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. - * - */ -/* - * Qualcomm PMIC8058 PWM driver - * - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include - -#define PM8058_LPG_BANKS 8 -#define PM8058_PWM_CHANNELS PM8058_LPG_BANKS /* MAX=8 */ - -#define PM8058_LPG_CTL_REGS 7 - -/* PMIC8058 LPG/PWM */ -#define SSBI_REG_ADDR_LPG_CTL_BASE 0x13C -#define SSBI_REG_ADDR_LPG_CTL(n) (SSBI_REG_ADDR_LPG_CTL_BASE + (n)) -#define SSBI_REG_ADDR_LPG_BANK_SEL 0x143 -#define SSBI_REG_ADDR_LPG_BANK_EN 0x144 -#define SSBI_REG_ADDR_LPG_LUT_CFG0 0x145 -#define SSBI_REG_ADDR_LPG_LUT_CFG1 0x146 -#define SSBI_REG_ADDR_LPG_TEST 0x147 - -/* Control 0 */ -#define PM8058_PWM_1KHZ_COUNT_MASK 0xF0 -#define PM8058_PWM_1KHZ_COUNT_SHIFT 4 - -#define PM8058_PWM_1KHZ_COUNT_MAX 15 - -#define PM8058_PWM_OUTPUT_EN 0x08 -#define PM8058_PWM_PWM_EN 0x04 -#define PM8058_PWM_RAMP_GEN_EN 0x02 -#define PM8058_PWM_RAMP_START 0x01 - -#define PM8058_PWM_PWM_START (PM8058_PWM_OUTPUT_EN \ - | PM8058_PWM_PWM_EN) -#define PM8058_PWM_RAMP_GEN_START (PM8058_PWM_RAMP_GEN_EN \ - | PM8058_PWM_RAMP_START) - -/* Control 1 */ -#define PM8058_PWM_REVERSE_EN 0x80 -#define PM8058_PWM_BYPASS_LUT 0x40 -#define PM8058_PWM_HIGH_INDEX_MASK 0x3F - -/* Control 2 */ -#define PM8058_PWM_LOOP_EN 0x80 -#define PM8058_PWM_RAMP_UP 0x40 -#define PM8058_PWM_LOW_INDEX_MASK 0x3F - -/* Control 3 */ -#define PM8058_PWM_VALUE_BIT7_0 0xFF -#define PM8058_PWM_VALUE_BIT5_0 0x3F - -/* Control 4 */ -#define PM8058_PWM_VALUE_BIT8 0x80 - -#define PM8058_PWM_CLK_SEL_MASK 0x60 -#define PM8058_PWM_CLK_SEL_SHIFT 5 - -#define PM8058_PWM_CLK_SEL_NO 0 -#define PM8058_PWM_CLK_SEL_1KHZ 1 -#define PM8058_PWM_CLK_SEL_32KHZ 2 -#define PM8058_PWM_CLK_SEL_19P2MHZ 3 - -#define PM8058_PWM_PREDIVIDE_MASK 0x18 -#define PM8058_PWM_PREDIVIDE_SHIFT 3 - -#define PM8058_PWM_PREDIVIDE_2 0 -#define PM8058_PWM_PREDIVIDE_3 1 -#define PM8058_PWM_PREDIVIDE_5 2 -#define PM8058_PWM_PREDIVIDE_6 3 - -#define PM8058_PWM_M_MASK 0x07 -#define PM8058_PWM_M_MIN 0 -#define PM8058_PWM_M_MAX 7 - -/* Control 5 */ -#define PM8058_PWM_PAUSE_COUNT_HI_MASK 0xFC -#define PM8058_PWM_PAUSE_COUNT_HI_SHIFT 2 - -#define PM8058_PWM_PAUSE_ENABLE_HIGH 0x02 -#define PM8058_PWM_SIZE_9_BIT 0x01 - -/* Control 6 */ -#define PM8058_PWM_PAUSE_COUNT_LO_MASK 0xFC -#define PM8058_PWM_PAUSE_COUNT_LO_SHIFT 2 - -#define PM8058_PWM_PAUSE_ENABLE_LOW 0x02 -#define PM8058_PWM_RESERVED 0x01 - -#define PM8058_PWM_PAUSE_COUNT_MAX 56 /* < 2^6 = 64*/ - -/* LUT_CFG1 */ -#define PM8058_PWM_LUT_READ 0x40 - -/* TEST */ -#define PM8058_PWM_DTEST_MASK 0x38 -#define PM8058_PWM_DTEST_SHIFT 3 - -#define PM8058_PWM_DTEST_BANK_MASK 0x07 - -/* PWM frequency support - * - * PWM Frequency = Clock Frequency / (N * T) - * or - * PWM Period = Clock Period * (N * T) - * where - * N = 2^9 or 2^6 for 9-bit or 6-bit PWM size - * T = Pre-divide * 2^m, m = 0..7 (exponent) - * - * We use this formula to figure out m for the best pre-divide and clock: - * (PWM Period / N) / 2^m = (Pre-divide * Clock Period) -*/ -#define NUM_CLOCKS 3 - -#define NSEC_1000HZ (NSEC_PER_SEC / 1000) -#define NSEC_32768HZ (NSEC_PER_SEC / 32768) -#define NSEC_19P2MHZ (NSEC_PER_SEC / 19200000) - -#define CLK_PERIOD_MIN NSEC_19P2MHZ -#define CLK_PERIOD_MAX NSEC_1000HZ - -#define NUM_PRE_DIVIDE 3 /* No default support for pre-divide = 6 */ - -#define PRE_DIVIDE_0 2 -#define PRE_DIVIDE_1 3 -#define PRE_DIVIDE_2 5 - -#define PRE_DIVIDE_MIN PRE_DIVIDE_0 -#define PRE_DIVIDE_MAX PRE_DIVIDE_2 - -static char *clks[NUM_CLOCKS] = { - "1K", "32768", "19.2M" -}; - -static unsigned pre_div[NUM_PRE_DIVIDE] = { - PRE_DIVIDE_0, PRE_DIVIDE_1, PRE_DIVIDE_2 -}; - -static unsigned int pt_t[NUM_PRE_DIVIDE][NUM_CLOCKS] = { - { PRE_DIVIDE_0 * NSEC_1000HZ, - PRE_DIVIDE_0 * NSEC_32768HZ, - PRE_DIVIDE_0 * NSEC_19P2MHZ, - }, - { PRE_DIVIDE_1 * NSEC_1000HZ, - PRE_DIVIDE_1 * NSEC_32768HZ, - PRE_DIVIDE_1 * NSEC_19P2MHZ, - }, - { PRE_DIVIDE_2 * NSEC_1000HZ, - PRE_DIVIDE_2 * NSEC_32768HZ, - PRE_DIVIDE_2 * NSEC_19P2MHZ, - }, -}; - -#define MIN_MPT ((PRE_DIVIDE_MIN * CLK_PERIOD_MIN) << PM8058_PWM_M_MIN) -#define MAX_MPT ((PRE_DIVIDE_MAX * CLK_PERIOD_MAX) << PM8058_PWM_M_MAX) - -#define CHAN_LUT_SIZE (PM_PWM_LUT_SIZE / PM8058_PWM_CHANNELS) - -/* Private data */ -struct pm8058_pwm_chip; - -struct pwm_device { - struct device *dev; - int pwm_id; /* = bank/channel id */ - int in_use; - const char *label; - struct pm8058_pwm_period period; - int pwm_value; - int pwm_period; - int use_lut; /* Use LUT to output PWM */ - u8 pwm_ctl[PM8058_LPG_CTL_REGS]; - int irq; - struct pm8058_pwm_chip *chip; -}; - -struct pm8058_pwm_chip { - struct pwm_device pwm_dev[PM8058_PWM_CHANNELS]; - u8 bank_mask; - struct mutex pwm_mutex; - struct pm8058_pwm_pdata *pdata; -}; - -static struct pm8058_pwm_chip *pwm_chip; - -struct pm8058_pwm_lut { - /* LUT parameters */ - int lut_duty_ms; - int lut_lo_index; - int lut_hi_index; - int lut_pause_hi; - int lut_pause_lo; - int flags; -}; - -static u16 duty_msec[PM8058_PWM_1KHZ_COUNT_MAX + 1] = { - 0, 1, 2, 3, 4, 6, 8, 16, 18, 24, 32, 36, 64, 128, 256, 512 -}; - -static u16 pause_count[PM8058_PWM_PAUSE_COUNT_MAX + 1] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 23, 28, 31, 42, 47, 56, 63, 83, 94, 111, 125, 167, 188, 222, 250, 333, - 375, 500, 667, 750, 800, 900, 1000, 1100, - 1200, 1300, 1400, 1500, 1600, 1800, 2000, 2500, - 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, - 7000 -}; - -/* Internal functions */ -static void pm8058_pwm_save(u8 *u8p, u8 mask, u8 val) -{ - *u8p &= ~mask; - *u8p |= val & mask; -} - -static int pm8058_pwm_bank_enable(struct pwm_device *pwm, int enable) -{ - int rc; - u8 reg; - struct pm8058_pwm_chip *chip; - - chip = pwm->chip; - - if (enable) - reg = chip->bank_mask | (1 << pwm->pwm_id); - else - reg = chip->bank_mask & ~(1 << pwm->pwm_id); - - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_LPG_BANK_EN, reg); - if (rc) { - pr_err("pm8xxx_write(): rc=%d (Enable LPG Bank)\n", rc); - goto bail_out; - } - chip->bank_mask = reg; - -bail_out: - return rc; -} - -static int pm8058_pwm_bank_sel(struct pwm_device *pwm) -{ - int rc; - u8 reg; - - reg = pwm->pwm_id; - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_LPG_BANK_SEL, reg); - if (rc) - pr_err("pm8xxx_write(): rc=%d (Select PWM Bank)\n", rc); - return rc; -} - -static int pm8058_pwm_start(struct pwm_device *pwm, int start, int ramp_start) -{ - int rc; - u8 reg; - - if (start) { - reg = pwm->pwm_ctl[0] | PM8058_PWM_PWM_START; - if (ramp_start) - reg |= PM8058_PWM_RAMP_GEN_START; - else - reg &= ~PM8058_PWM_RAMP_GEN_START; - } else { - reg = pwm->pwm_ctl[0] & ~PM8058_PWM_PWM_START; - reg &= ~PM8058_PWM_RAMP_GEN_START; - } - - rc = pm8xxx_writeb(pwm->dev->parent, SSBI_REG_ADDR_LPG_CTL(0), - reg); - if (rc) - pr_err("pm8xxx_write(): rc=%d (Enable PWM Ctl 0)\n", rc); - else - pwm->pwm_ctl[0] = reg; - return rc; -} - -static void pm8058_pwm_calc_period(unsigned int period_us, - struct pm8058_pwm_period *period) -{ - int n, m, clk, div; - int best_m, best_div, best_clk; - int last_err, cur_err, better_err, better_m; - unsigned int tmp_p, last_p, min_err, period_n; - - /* PWM Period / N : handle underflow or overflow */ - if (period_us < (PM_PWM_PERIOD_MAX / NSEC_PER_USEC)) - period_n = (period_us * NSEC_PER_USEC) >> 6; - else - period_n = (period_us >> 6) * NSEC_PER_USEC; - if (period_n >= MAX_MPT) { - n = 9; - period_n >>= 3; - } else - n = 6; - - min_err = MAX_MPT; - best_m = 0; - best_clk = 0; - best_div = 0; - for (clk = 0; clk < NUM_CLOCKS; clk++) { - for (div = 0; div < NUM_PRE_DIVIDE; div++) { - tmp_p = period_n; - last_p = tmp_p; - for (m = 0; m <= PM8058_PWM_M_MAX; m++) { - if (tmp_p <= pt_t[div][clk]) { - /* Found local best */ - if (!m) { - better_err = pt_t[div][clk] - - tmp_p; - better_m = m; - } else { - last_err = last_p - - pt_t[div][clk]; - cur_err = pt_t[div][clk] - - tmp_p; - - if (cur_err < last_err) { - better_err = cur_err; - better_m = m; - } else { - better_err = last_err; - better_m = m - 1; - } - } - - if (better_err < min_err) { - min_err = better_err; - best_m = better_m; - best_clk = clk; - best_div = div; - } - break; - } else { - last_p = tmp_p; - tmp_p >>= 1; - } - } - } - } - - /* Use higher resolution */ - if (best_m >= 3 && n == 6) { - n += 3; - best_m -= 3; - } - - period->pwm_size = n; - period->clk = best_clk; - period->pre_div = best_div; - period->pre_div_exp = best_m; - - pr_debug("period=%u: n=%d, m=%d, clk[%d]=%s, div[%d]=%d\n", - (unsigned)period_us, n, best_m, - best_clk, clks[best_clk], best_div, pre_div[best_div]); -} - -static void pm8058_pwm_calc_pwm_value(struct pwm_device *pwm, - unsigned int period_us, - unsigned int duty_us) -{ - unsigned int max_pwm_value, tmp; - - /* Figure out pwm_value with overflow handling */ - tmp = 1 << (sizeof(tmp) * 8 - pwm->period.pwm_size); - if (duty_us < tmp) { - tmp = duty_us << pwm->period.pwm_size; - pwm->pwm_value = tmp / period_us; - } else { - tmp = period_us >> pwm->period.pwm_size; - pwm->pwm_value = duty_us / tmp; - } - max_pwm_value = (1 << pwm->period.pwm_size) - 1; - if (pwm->pwm_value > max_pwm_value) - pwm->pwm_value = max_pwm_value; -} - -static int pm8058_pwm_change_table(struct pwm_device *pwm, int duty_pct[], - int start_idx, int len, int raw_value) -{ - unsigned int pwm_value, max_pwm_value; - u8 cfg0, cfg1; - int i, pwm_size; - int rc = 0; - - pwm_size = (pwm->pwm_ctl[5] & PM8058_PWM_SIZE_9_BIT) ? 9 : 6; - max_pwm_value = (1 << pwm_size) - 1; - for (i = 0; i < len; i++) { - if (raw_value) - pwm_value = duty_pct[i]; - else - pwm_value = (duty_pct[i] << pwm_size) / 100; - - if (pwm_value > max_pwm_value) - pwm_value = max_pwm_value; - cfg0 = pwm_value; - cfg1 = (pwm_value >> 1) & 0x80; - cfg1 |= start_idx + i; - - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_LPG_LUT_CFG0, cfg0); - if (rc) - break; - - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_LPG_LUT_CFG1, cfg1); - if (rc) - break; - } - return rc; -} - -static void pm8058_pwm_save_index(struct pwm_device *pwm, - int low_idx, int high_idx, int flags) -{ - pwm->pwm_ctl[1] = high_idx & PM8058_PWM_HIGH_INDEX_MASK; - pwm->pwm_ctl[2] = low_idx & PM8058_PWM_LOW_INDEX_MASK; - - if (flags & PM_PWM_LUT_REVERSE) - pwm->pwm_ctl[1] |= PM8058_PWM_REVERSE_EN; - if (flags & PM_PWM_LUT_RAMP_UP) - pwm->pwm_ctl[2] |= PM8058_PWM_RAMP_UP; - if (flags & PM_PWM_LUT_LOOP) - pwm->pwm_ctl[2] |= PM8058_PWM_LOOP_EN; -} - -static void pm8058_pwm_save_period(struct pwm_device *pwm) -{ - u8 mask, val; - - val = ((pwm->period.clk + 1) << PM8058_PWM_CLK_SEL_SHIFT) - & PM8058_PWM_CLK_SEL_MASK; - val |= (pwm->period.pre_div << PM8058_PWM_PREDIVIDE_SHIFT) - & PM8058_PWM_PREDIVIDE_MASK; - val |= pwm->period.pre_div_exp & PM8058_PWM_M_MASK; - mask = PM8058_PWM_CLK_SEL_MASK | PM8058_PWM_PREDIVIDE_MASK | - PM8058_PWM_M_MASK; - pm8058_pwm_save(&pwm->pwm_ctl[4], mask, val); - - val = (pwm->period.pwm_size > 6) ? PM8058_PWM_SIZE_9_BIT : 0; - mask = PM8058_PWM_SIZE_9_BIT; - pm8058_pwm_save(&pwm->pwm_ctl[5], mask, val); -} - -static void pm8058_pwm_save_pwm_value(struct pwm_device *pwm) -{ - u8 mask, val; - - pwm->pwm_ctl[3] = pwm->pwm_value; - - val = (pwm->period.pwm_size > 6) ? (pwm->pwm_value >> 1) : 0; - mask = PM8058_PWM_VALUE_BIT8; - pm8058_pwm_save(&pwm->pwm_ctl[4], mask, val); -} - -static void pm8058_pwm_save_duty_time(struct pwm_device *pwm, - struct pm8058_pwm_lut *lut) -{ - int i; - u8 mask, val; - - /* Linear search for duty time */ - for (i = 0; i < PM8058_PWM_1KHZ_COUNT_MAX; i++) { - if (duty_msec[i] >= lut->lut_duty_ms) - break; - } - val = i << PM8058_PWM_1KHZ_COUNT_SHIFT; - - mask = PM8058_PWM_1KHZ_COUNT_MASK; - pm8058_pwm_save(&pwm->pwm_ctl[0], mask, val); -} - -static void pm8058_pwm_save_pause(struct pwm_device *pwm, - struct pm8058_pwm_lut *lut) -{ - int i, pause_cnt, time_cnt; - u8 mask, val; - - time_cnt = (pwm->pwm_ctl[0] & PM8058_PWM_1KHZ_COUNT_MASK) - >> PM8058_PWM_1KHZ_COUNT_SHIFT; - if (lut->flags & PM_PWM_LUT_PAUSE_HI_EN) { - pause_cnt = (lut->lut_pause_hi + duty_msec[time_cnt] / 2) - / duty_msec[time_cnt]; - /* Linear search for pause time */ - for (i = 0; i < PM8058_PWM_PAUSE_COUNT_MAX; i++) { - if (pause_count[i] >= pause_cnt) - break; - } - val = (i << PM8058_PWM_PAUSE_COUNT_HI_SHIFT) & - PM8058_PWM_PAUSE_COUNT_HI_MASK; - val |= PM8058_PWM_PAUSE_ENABLE_HIGH; - } else - val = 0; - - mask = PM8058_PWM_PAUSE_COUNT_HI_MASK | PM8058_PWM_PAUSE_ENABLE_HIGH; - pm8058_pwm_save(&pwm->pwm_ctl[5], mask, val); - - if (lut->flags & PM_PWM_LUT_PAUSE_LO_EN) { - /* Linear search for pause time */ - pause_cnt = (lut->lut_pause_lo + duty_msec[time_cnt] / 2) - / duty_msec[time_cnt]; - for (i = 0; i < PM8058_PWM_PAUSE_COUNT_MAX; i++) { - if (pause_count[i] >= pause_cnt) - break; - } - val = (i << PM8058_PWM_PAUSE_COUNT_LO_SHIFT) & - PM8058_PWM_PAUSE_COUNT_LO_MASK; - val |= PM8058_PWM_PAUSE_ENABLE_LOW; - } else - val = 0; - - mask = PM8058_PWM_PAUSE_COUNT_LO_MASK | PM8058_PWM_PAUSE_ENABLE_LOW; - pm8058_pwm_save(&pwm->pwm_ctl[6], mask, val); -} - -static int pm8058_pwm_write(struct pwm_device *pwm, int start, int end) -{ - int i, rc; - - /* Write in reverse way so 0 would be the last */ - for (i = end - 1; i >= start; i--) { - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_LPG_CTL(i), - pwm->pwm_ctl[i]); - if (rc) { - pr_err("pm8xxx_write(): rc=%d (PWM Ctl[%d])\n", rc, i); - return rc; - } - } - - return 0; -} - -static int pm8058_pwm_change_lut(struct pwm_device *pwm, - struct pm8058_pwm_lut *lut) -{ - int rc; - - pm8058_pwm_save_index(pwm, lut->lut_lo_index, - lut->lut_hi_index, lut->flags); - pm8058_pwm_save_duty_time(pwm, lut); - pm8058_pwm_save_pause(pwm, lut); - pm8058_pwm_save(&pwm->pwm_ctl[1], PM8058_PWM_BYPASS_LUT, 0); - - pm8058_pwm_bank_sel(pwm); - rc = pm8058_pwm_write(pwm, 0, 7); - - return rc; -} - -/* APIs */ -/* - * pwm_request - request a PWM device - */ -struct pwm_device *pwm_request(int pwm_id, const char *label) -{ - struct pwm_device *pwm; - - if (pwm_id > PM8058_PWM_CHANNELS || pwm_id < 0) - return ERR_PTR(-EINVAL); - if (pwm_chip == NULL) - return ERR_PTR(-ENODEV); - - mutex_lock(&pwm_chip->pwm_mutex); - pwm = &pwm_chip->pwm_dev[pwm_id]; - if (!pwm->in_use) { - pwm->in_use = 1; - pwm->label = label; - pwm->use_lut = 0; - - if (pwm_chip->pdata && pwm_chip->pdata->config) - pwm_chip->pdata->config(pwm, pwm_id, 1); - } else - pwm = ERR_PTR(-EBUSY); - mutex_unlock(&pwm_chip->pwm_mutex); - - return pwm; -} -EXPORT_SYMBOL(pwm_request); - -/* - * pwm_free - free a PWM device - */ -void pwm_free(struct pwm_device *pwm) -{ - if (pwm == NULL || IS_ERR(pwm) || pwm->chip == NULL) - return; - - mutex_lock(&pwm->chip->pwm_mutex); - if (pwm->in_use) { - pm8058_pwm_bank_sel(pwm); - pm8058_pwm_start(pwm, 0, 0); - - if (pwm->chip->pdata && pwm->chip->pdata->config) - pwm->chip->pdata->config(pwm, pwm->pwm_id, 0); - - pwm->in_use = 0; - pwm->label = NULL; - } - pm8058_pwm_bank_enable(pwm, 0); - mutex_unlock(&pwm->chip->pwm_mutex); -} -EXPORT_SYMBOL(pwm_free); - -/* - * pwm_config - change a PWM device configuration - * - * @pwm: the PWM device - * @period_us: period in micro second - * @duty_us: duty cycle in micro second - */ -int pwm_config(struct pwm_device *pwm, int duty_us, int period_us) -{ - int rc; - - if (pwm == NULL || IS_ERR(pwm) || - duty_us > period_us || - (unsigned)period_us > PM_PWM_PERIOD_MAX || - (unsigned)period_us < PM_PWM_PERIOD_MIN) - return -EINVAL; - if (pwm->chip == NULL) - return -ENODEV; - - mutex_lock(&pwm->chip->pwm_mutex); - - if (!pwm->in_use) { - rc = -EINVAL; - goto out_unlock; - } - - if (pwm->pwm_period != period_us) { - pm8058_pwm_calc_period(period_us, &pwm->period); - pm8058_pwm_save_period(pwm); - pwm->pwm_period = period_us; - } - - pm8058_pwm_calc_pwm_value(pwm, period_us, duty_us); - pm8058_pwm_save_pwm_value(pwm); - pm8058_pwm_save(&pwm->pwm_ctl[1], - PM8058_PWM_BYPASS_LUT, PM8058_PWM_BYPASS_LUT); - - pm8058_pwm_bank_sel(pwm); - rc = pm8058_pwm_write(pwm, 1, 6); - - pr_debug("duty/period=%u/%u usec: pwm_value=%d (of %d)\n", - (unsigned)duty_us, (unsigned)period_us, - pwm->pwm_value, 1 << pwm->period.pwm_size); - -out_unlock: - mutex_unlock(&pwm->chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL(pwm_config); - -/* - * pwm_enable - start a PWM output toggling - */ -int pwm_enable(struct pwm_device *pwm) -{ - int rc; - - if (pwm == NULL || IS_ERR(pwm)) - return -EINVAL; - if (pwm->chip == NULL) - return -ENODEV; - - mutex_lock(&pwm->chip->pwm_mutex); - if (!pwm->in_use) - rc = -EINVAL; - else { - if (pwm->chip->pdata && pwm->chip->pdata->enable) - pwm->chip->pdata->enable(pwm, pwm->pwm_id, 1); - - rc = pm8058_pwm_bank_enable(pwm, 1); - - pm8058_pwm_bank_sel(pwm); - pm8058_pwm_start(pwm, 1, 0); - } - mutex_unlock(&pwm->chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL(pwm_enable); - -/* - * pwm_disable - stop a PWM output toggling - */ -void pwm_disable(struct pwm_device *pwm) -{ - if (pwm == NULL || IS_ERR(pwm) || pwm->chip == NULL) - return; - - mutex_lock(&pwm->chip->pwm_mutex); - if (pwm->in_use) { - pm8058_pwm_bank_sel(pwm); - pm8058_pwm_start(pwm, 0, 0); - - pm8058_pwm_bank_enable(pwm, 0); - - if (pwm->chip->pdata && pwm->chip->pdata->enable) - pwm->chip->pdata->enable(pwm, pwm->pwm_id, 0); - } - mutex_unlock(&pwm->chip->pwm_mutex); -} -EXPORT_SYMBOL(pwm_disable); - -/** - * pm8058_pwm_config_period - change PWM period - * - * @pwm: the PWM device - * @pwm_p: period in struct pm8058_pwm_period - */ -int pm8058_pwm_config_period(struct pwm_device *pwm, - struct pm8058_pwm_period *period) -{ - int rc; - - if (pwm == NULL || IS_ERR(pwm) || period == NULL) - return -EINVAL; - if (pwm->chip == NULL) - return -ENODEV; - - mutex_lock(&pwm->chip->pwm_mutex); - - if (!pwm->in_use) { - rc = -EINVAL; - goto out_unlock; - } - - pwm->period.pwm_size = period->pwm_size; - pwm->period.clk = period->clk; - pwm->period.pre_div = period->pre_div; - pwm->period.pre_div_exp = period->pre_div_exp; - - pm8058_pwm_save_period(pwm); - pm8058_pwm_bank_sel(pwm); - rc = pm8058_pwm_write(pwm, 4, 6); - -out_unlock: - mutex_unlock(&pwm->chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL(pm8058_pwm_config_period); - -/** - * pm8058_pwm_config_duty_cycle - change PWM duty cycle - * - * @pwm: the PWM device - * @pwm_value: the duty cycle in raw PWM value (< 2^pwm_size) - */ -int pm8058_pwm_config_duty_cycle(struct pwm_device *pwm, int pwm_value) -{ - struct pm8058_pwm_lut lut; - int flags, start_idx; - int rc = 0; - - if (pwm == NULL || IS_ERR(pwm)) - return -EINVAL; - if (pwm->chip == NULL) - return -ENODEV; - - mutex_lock(&pwm->chip->pwm_mutex); - - if (!pwm->in_use || !pwm->pwm_period) { - rc = -EINVAL; - goto out_unlock; - } - - if (pwm->pwm_value == pwm_value) - goto out_unlock; - - pwm->pwm_value = pwm_value; - flags = PM_PWM_LUT_RAMP_UP; - - start_idx = pwm->pwm_id * CHAN_LUT_SIZE; - pm8058_pwm_change_table(pwm, &pwm_value, start_idx, 1, 1); - - if (!pwm->use_lut) { - pwm->use_lut = 1; - - lut.lut_duty_ms = 1; - lut.lut_lo_index = start_idx; - lut.lut_hi_index = start_idx; - lut.lut_pause_lo = 0; - lut.lut_pause_hi = 0; - lut.flags = flags; - - rc = pm8058_pwm_change_lut(pwm, &lut); - } else { - pm8058_pwm_save_index(pwm, start_idx, start_idx, flags); - pm8058_pwm_save(&pwm->pwm_ctl[1], PM8058_PWM_BYPASS_LUT, 0); - - pm8058_pwm_bank_sel(pwm); - rc = pm8058_pwm_write(pwm, 0, 3); - } - - if (rc) - pr_err("[%d]: pm8058_pwm_write: rc=%d\n", pwm->pwm_id, rc); - -out_unlock: - mutex_unlock(&pwm->chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL(pm8058_pwm_config_duty_cycle); - -/** - * pm8058_pwm_lut_config - change a PWM device configuration to use LUT - * - * @pwm: the PWM device - * @period_us: period in micro second - * @duty_pct: arrary of duty cycles in percent, like 20, 50. - * @duty_time_ms: time for each duty cycle in millisecond - * @start_idx: start index in lookup table from 0 to MAX-1 - * @idx_len: number of index - * @pause_lo: pause time in millisecond at low index - * @pause_hi: pause time in millisecond at high index - * @flags: control flags - */ -int pm8058_pwm_lut_config(struct pwm_device *pwm, int period_us, - int duty_pct[], int duty_time_ms, int start_idx, - int idx_len, int pause_lo, int pause_hi, int flags) -{ - struct pm8058_pwm_lut lut; - int len; - int rc; - - if (pwm == NULL || IS_ERR(pwm) || !idx_len) - return -EINVAL; - if (duty_pct == NULL && !(flags & PM_PWM_LUT_NO_TABLE)) - return -EINVAL; - if (pwm->chip == NULL) - return -ENODEV; - if (idx_len >= PM_PWM_LUT_SIZE && start_idx) - return -EINVAL; - if ((start_idx + idx_len) > PM_PWM_LUT_SIZE) - return -EINVAL; - if ((unsigned)period_us > PM_PWM_PERIOD_MAX || - (unsigned)period_us < PM_PWM_PERIOD_MIN) - return -EINVAL; - - mutex_lock(&pwm->chip->pwm_mutex); - - if (!pwm->in_use) { - rc = -EINVAL; - goto out_unlock; - } - - if (pwm->pwm_period != period_us) { - pm8058_pwm_calc_period(period_us, &pwm->period); - pm8058_pwm_save_period(pwm); - pwm->pwm_period = period_us; - } - - len = (idx_len > PM_PWM_LUT_SIZE) ? PM_PWM_LUT_SIZE : idx_len; - - if (flags & PM_PWM_LUT_NO_TABLE) - goto after_table_write; - - rc = pm8058_pwm_change_table(pwm, duty_pct, start_idx, len, 0); - if (rc) { - pr_err("pm8058_pwm_change_table: rc=%d\n", rc); - goto out_unlock; - } - -after_table_write: - lut.lut_duty_ms = duty_time_ms; - lut.lut_lo_index = start_idx; - lut.lut_hi_index = start_idx + len - 1; - lut.lut_pause_lo = pause_lo; - lut.lut_pause_hi = pause_hi; - lut.flags = flags; - - rc = pm8058_pwm_change_lut(pwm, &lut); - -out_unlock: - mutex_unlock(&pwm->chip->pwm_mutex); - return rc; -} -EXPORT_SYMBOL(pm8058_pwm_lut_config); - -/** - * pm8058_pwm_lut_enable - control a PWM device to start/stop LUT ramp - * - * @pwm: the PWM device - * @start: to start (1), or stop (0) - */ -int pm8058_pwm_lut_enable(struct pwm_device *pwm, int start) -{ - if (pwm == NULL || IS_ERR(pwm)) - return -EINVAL; - if (pwm->chip == NULL) - return -ENODEV; - - mutex_lock(&pwm->chip->pwm_mutex); - if (start) { - pm8058_pwm_bank_enable(pwm, 1); - - pm8058_pwm_bank_sel(pwm); - pm8058_pwm_start(pwm, 1, 1); - } else { - pm8058_pwm_bank_sel(pwm); - pm8058_pwm_start(pwm, 0, 0); - - pm8058_pwm_bank_enable(pwm, 0); - } - mutex_unlock(&pwm->chip->pwm_mutex); - return 0; -} -EXPORT_SYMBOL(pm8058_pwm_lut_enable); - -#define SSBI_REG_ADDR_LED_BASE 0x131 -#define SSBI_REG_ADDR_LED(n) (SSBI_REG_ADDR_LED_BASE + (n)) -#define SSBI_REG_ADDR_FLASH_BASE 0x48 -#define SSBI_REG_ADDR_FLASH_DRV_1 0xFB -#define SSBI_REG_ADDR_FLASH(n) (((n) < 2 ? \ - SSBI_REG_ADDR_FLASH_BASE + (n) : \ - SSBI_REG_ADDR_FLASH_DRV_1)) - -#define PM8058_LED_CURRENT_SHIFT 3 -#define PM8058_LED_MODE_MASK 0x07 - -#define PM8058_FLASH_CURRENT_SHIFT 4 -#define PM8058_FLASH_MODE_MASK 0x03 -#define PM8058_FLASH_MODE_NONE 0 -#define PM8058_FLASH_MODE_DTEST1 1 -#define PM8058_FLASH_MODE_DTEST2 2 -#define PM8058_FLASH_MODE_PWM 3 - -int pm8058_pwm_config_led(struct pwm_device *pwm, int id, - int mode, int max_current) -{ - int rc; - u8 conf; - - switch (id) { - case PM_PWM_LED_0: - case PM_PWM_LED_1: - case PM_PWM_LED_2: - conf = mode & PM8058_LED_MODE_MASK; - conf |= (max_current / 2) << PM8058_LED_CURRENT_SHIFT; - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_LED(id), conf); - break; - - case PM_PWM_LED_KPD: - case PM_PWM_LED_FLASH: - case PM_PWM_LED_FLASH1: - switch (mode) { - case PM_PWM_CONF_PWM1: - case PM_PWM_CONF_PWM2: - case PM_PWM_CONF_PWM3: - conf = PM8058_FLASH_MODE_PWM; - break; - case PM_PWM_CONF_DTEST1: - conf = PM8058_FLASH_MODE_DTEST1; - break; - case PM_PWM_CONF_DTEST2: - conf = PM8058_FLASH_MODE_DTEST2; - break; - default: - conf = PM8058_FLASH_MODE_NONE; - break; - } - conf |= (max_current / 20) << PM8058_FLASH_CURRENT_SHIFT; - id -= PM_PWM_LED_KPD; - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_FLASH(id), conf); - break; - default: - rc = -EINVAL; - break; - } - - return rc; -} -EXPORT_SYMBOL(pm8058_pwm_config_led); - -int pm8058_pwm_set_dtest(struct pwm_device *pwm, int enable) -{ - int rc; - u8 reg; - - if (pwm == NULL || IS_ERR(pwm)) - return -EINVAL; - if (pwm->chip == NULL) - return -ENODEV; - - if (!pwm->in_use) - rc = -EINVAL; - else { - reg = pwm->pwm_id & PM8058_PWM_DTEST_BANK_MASK; - if (enable) - /* Only Test 1 available */ - reg |= (1 << PM8058_PWM_DTEST_SHIFT) & - PM8058_PWM_DTEST_MASK; - rc = pm8xxx_writeb(pwm->dev->parent, - SSBI_REG_ADDR_LPG_TEST, reg); - if (rc) - pr_err("pm8xxx_write(DTEST=0x%x): rc=%d\n", reg, rc); - - } - return rc; -} -EXPORT_SYMBOL(pm8058_pwm_set_dtest); - -static int pmic8058_pwm_probe(struct platform_device *pdev) -{ - struct pm8058_pwm_chip *chip; - int i; - - chip = kzalloc(sizeof *chip, GFP_KERNEL); - if (chip == NULL) { - pr_err("kzalloc() failed.\n"); - return -ENOMEM; - } - - for (i = 0; i < PM8058_PWM_CHANNELS; i++) { - chip->pwm_dev[i].pwm_id = i; - chip->pwm_dev[i].chip = chip; - chip->pwm_dev[i].dev = &pdev->dev; - } - - mutex_init(&chip->pwm_mutex); - - chip->pdata = pdev->dev.platform_data; - pwm_chip = chip; - platform_set_drvdata(pdev, chip); - - pr_notice("OK\n"); - return 0; -} - -static int pmic8058_pwm_remove(struct platform_device *pdev) -{ - struct pm8058_pwm_chip *chip = platform_get_drvdata(pdev); - - platform_set_drvdata(pdev, NULL); - kfree(chip); - return 0; -} - -static struct platform_driver pmic8058_pwm_driver = { - .probe = pmic8058_pwm_probe, - .remove = pmic8058_pwm_remove, - .driver = { - .name = "pm8058-pwm", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8058_pwm_init(void) -{ - return platform_driver_register(&pmic8058_pwm_driver); -} - -static void __exit pm8058_pwm_exit(void) -{ - platform_driver_unregister(&pmic8058_pwm_driver); -} - -subsys_initcall(pm8058_pwm_init); -module_exit(pm8058_pwm_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8058 PWM driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pmic8058_pwm"); diff --git a/drivers/misc/pmic8058-xoadc.c b/drivers/misc/pmic8058-xoadc.c deleted file mode 100644 index c9a4402bbedf3f64665d712097818f4731901365..0000000000000000000000000000000000000000 --- a/drivers/misc/pmic8058-xoadc.c +++ /dev/null @@ -1,800 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define ADC_DRIVER_NAME "pm8058-xoadc" - -#define MAX_QUEUE_LENGTH 0X15 -#define MAX_CHANNEL_PROPERTIES_QUEUE 0X7 -#define MAX_QUEUE_SLOT 0x1 - -/* User Processor */ -#define ADC_ARB_USRP_CNTRL 0x197 - #define ADC_ARB_USRP_CNTRL_EN_ARB BIT(0) - #define ADC_ARB_USRP_CNTRL_RSV1 BIT(1) - #define ADC_ARB_USRP_CNTRL_RSV2 BIT(2) - #define ADC_ARB_USRP_CNTRL_RSV3 BIT(3) - #define ADC_ARB_USRP_CNTRL_RSV4 BIT(4) - #define ADC_ARB_USRP_CNTRL_RSV5 BIT(5) - #define ADC_ARB_USRP_CNTRL_EOC BIT(6) - #define ADC_ARB_USRP_CNTRL_REQ BIT(7) - -#define ADC_ARB_USRP_AMUX_CNTRL 0x198 -#define ADC_ARB_USRP_ANA_PARAM 0x199 -#define ADC_ARB_USRP_DIG_PARAM 0x19A -#define ADC_ARB_USRP_RSV 0x19B - -#define ADC_ARB_USRP_DATA0 0x19D -#define ADC_ARB_USRP_DATA1 0x19C - -struct pmic8058_adc { - struct device *dev; - struct xoadc_platform_data *pdata; - struct adc_properties *adc_prop; - struct xoadc_conv_state conv[2]; - int xoadc_queue_count; - int adc_irq; - struct linear_graph *adc_graph; - struct xoadc_conv_state *conv_slot_request; - struct xoadc_conv_state *conv_queue_list; - struct adc_conv_slot conv_queue_elements[MAX_QUEUE_LENGTH]; - int xoadc_num; - struct msm_xo_voter *adc_voter; - struct wake_lock adc_wakelock; - /* flag to warn/bug if wakelocks are taken after suspend_noirq */ - int msm_suspend_check; -}; - -static struct pmic8058_adc *pmic_adc[XOADC_PMIC_0 + 1]; - -static bool xoadc_initialized, xoadc_calib_first_adc; - -DEFINE_RATELIMIT_STATE(pm8058_xoadc_msg_ratelimit, - DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); - -static inline int pm8058_xoadc_can_print(void) -{ - return __ratelimit(&pm8058_xoadc_msg_ratelimit); -} - -int32_t pm8058_xoadc_registered(void) -{ - return xoadc_initialized; -} -EXPORT_SYMBOL(pm8058_xoadc_registered); - -void pm8058_xoadc_restore_slot(uint32_t adc_instance, - struct adc_conv_slot *slot) -{ - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - struct xoadc_conv_state *slot_state = adc_pmic->conv_slot_request; - - mutex_lock(&slot_state->list_lock); - list_add(&slot->list, &slot_state->slots); - mutex_unlock(&slot_state->list_lock); -} -EXPORT_SYMBOL(pm8058_xoadc_restore_slot); - -void pm8058_xoadc_slot_request(uint32_t adc_instance, - struct adc_conv_slot **slot) -{ - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - struct xoadc_conv_state *slot_state = adc_pmic->conv_slot_request; - - mutex_lock(&slot_state->list_lock); - - if (!list_empty(&slot_state->slots)) { - *slot = list_first_entry(&slot_state->slots, - struct adc_conv_slot, list); - list_del(&(*slot)->list); - } else - *slot = NULL; - - mutex_unlock(&slot_state->list_lock); -} -EXPORT_SYMBOL(pm8058_xoadc_slot_request); - -static int32_t pm8058_xoadc_arb_cntrl(uint32_t arb_cntrl, - uint32_t adc_instance, uint32_t channel) -{ - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - int i, rc; - u8 data_arb_cntrl; - - data_arb_cntrl = ADC_ARB_USRP_CNTRL_EOC | - ADC_ARB_USRP_CNTRL_RSV5 | - ADC_ARB_USRP_CNTRL_RSV4; - - if (arb_cntrl) { - if (adc_pmic->msm_suspend_check) - pr_err("XOADC request being made after suspend irq " - "with channel id:%d\n", channel); - data_arb_cntrl |= ADC_ARB_USRP_CNTRL_EN_ARB; - msm_xo_mode_vote(adc_pmic->adc_voter, MSM_XO_MODE_ON); - adc_pmic->pdata->xoadc_mpp_config(); - wake_lock(&adc_pmic->adc_wakelock); - } - - /* Write twice to the CNTRL register for the arbiter settings - to take into effect */ - for (i = 0; i < 2; i++) { - rc = pm8xxx_writeb(adc_pmic->dev->parent, ADC_ARB_USRP_CNTRL, - data_arb_cntrl); - if (rc < 0) { - pr_debug("%s: PM8058 write failed\n", __func__); - return rc; - } - } - - if (!arb_cntrl) { - msm_xo_mode_vote(adc_pmic->adc_voter, MSM_XO_MODE_OFF); - wake_unlock(&adc_pmic->adc_wakelock); - } - - return 0; -} - -static int32_t pm8058_xoadc_configure(uint32_t adc_instance, - struct adc_conv_slot *slot) -{ - - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - u8 data_arb_cntrl = 0, data_amux_chan = 0, data_arb_rsv = 0; - u8 data_dig_param = 0, data_ana_param2 = 0, data_ana_param = 0; - int rc; - - rc = pm8058_xoadc_arb_cntrl(1, adc_instance, slot->chan_path); - if (rc < 0) { - pr_debug("%s: Configuring ADC Arbiter" - "enable failed\n", __func__); - return rc; - } - - switch (slot->chan_path) { - - case CHAN_PATH_TYPE1: - data_amux_chan = CHANNEL_VCOIN << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 2; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE2: - data_amux_chan = CHANNEL_VBAT << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 3; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE3: - data_amux_chan = CHANNEL_VCHG << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 10; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE4: - data_amux_chan = CHANNEL_CHG_MONITOR << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE5: - data_amux_chan = CHANNEL_VPH_PWR << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 3; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE6: - data_amux_chan = CHANNEL_MPP5 << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[1]; - break; - - case CHAN_PATH_TYPE7: - data_amux_chan = CHANNEL_MPP6 << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE8: - data_amux_chan = CHANNEL_MPP7 << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 2; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE9: - data_amux_chan = CHANNEL_MPP8 << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 2; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE10: - data_amux_chan = CHANNEL_MPP9 << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 3; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE11: - data_amux_chan = CHANNEL_USB_VBUS << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 3; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE12: - data_amux_chan = CHANNEL_DIE_TEMP << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE13: - data_amux_chan = CHANNEL_125V << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE14: - data_amux_chan = CHANNEL_INTERNAL_2 << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - - case CHAN_PATH_TYPE_NONE: - data_amux_chan = CHANNEL_MUXOFF << 4; - data_arb_rsv = 0x10; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[1]; - break; - - case CHAN_PATH_TYPE15: - data_amux_chan = CHANNEL_INTERNAL << 4; - data_arb_rsv = 0x20; - slot->chan_properties.gain_numerator = 1; - slot->chan_properties.gain_denominator = 1; - slot->chan_properties.adc_graph = &adc_pmic->adc_graph[0]; - break; - } - - rc = pm8xxx_writeb(adc_pmic->dev->parent, - ADC_ARB_USRP_AMUX_CNTRL, data_amux_chan); - if (rc < 0) { - pr_debug("%s: PM8058 write failed\n", __func__); - return rc; - } - - rc = pm8xxx_writeb(adc_pmic->dev->parent, - ADC_ARB_USRP_RSV, data_arb_rsv); - if (rc < 0) { - pr_debug("%s: PM8058 write failed\n", __func__); - return rc; - } - - /* Set default clock rate to 2.4 MHz XO ADC clock digital */ - switch (slot->chan_adc_config) { - - case ADC_CONFIG_TYPE1: - data_ana_param = 0xFE; - data_dig_param = 0x23; - data_ana_param2 = 0xFF; - /* AMUX register data to start the ADC conversion */ - data_arb_cntrl = 0xF1; - break; - - case ADC_CONFIG_TYPE2: - data_ana_param = 0xFE; - data_dig_param = 0x03; - data_ana_param2 = 0xFF; - /* AMUX register data to start the ADC conversion */ - data_arb_cntrl = 0xF1; - break; - } - - rc = pm8xxx_writeb(adc_pmic->dev->parent, - ADC_ARB_USRP_ANA_PARAM, data_ana_param); - if (rc < 0) { - pr_debug("%s: PM8058 write failed\n", __func__); - return rc; - } - - rc = pm8xxx_writeb(adc_pmic->dev->parent, - ADC_ARB_USRP_DIG_PARAM, data_dig_param); - if (rc < 0) { - pr_debug("%s: PM8058 write failed\n", __func__); - return rc; - } - - rc = pm8xxx_writeb(adc_pmic->dev->parent, - ADC_ARB_USRP_ANA_PARAM, data_ana_param2); - if (rc < 0) { - pr_debug("%s: PM8058 write failed\n", __func__); - return rc; - } - - enable_irq(adc_pmic->adc_irq); - - rc = pm8xxx_writeb(adc_pmic->dev->parent, - ADC_ARB_USRP_CNTRL, data_arb_cntrl); - if (rc < 0) { - pr_debug("%s: PM8058 write failed\n", __func__); - return rc; - } - - return 0; -} - -int32_t pm8058_xoadc_select_chan_and_start_conv(uint32_t adc_instance, - struct adc_conv_slot *slot) -{ - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - struct xoadc_conv_state *slot_state = adc_pmic->conv_queue_list; - - if (!xoadc_initialized) - return -ENODEV; - - mutex_lock(&slot_state->list_lock); - list_add_tail(&slot->list, &slot_state->slots); - if (adc_pmic->xoadc_queue_count == 0) { - if (adc_pmic->pdata->xoadc_vreg_set != NULL) - adc_pmic->pdata->xoadc_vreg_set(1); - pm8058_xoadc_configure(adc_instance, slot); - } - adc_pmic->xoadc_queue_count++; - mutex_unlock(&slot_state->list_lock); - - return 0; -} -EXPORT_SYMBOL(pm8058_xoadc_select_chan_and_start_conv); - -static int32_t pm8058_xoadc_dequeue_slot_request(uint32_t adc_instance, - struct adc_conv_slot **slot) -{ - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - struct xoadc_conv_state *slot_state = adc_pmic->conv_queue_list; - int rc = 0; - - mutex_lock(&slot_state->list_lock); - if (adc_pmic->xoadc_queue_count > 0 && - !list_empty(&slot_state->slots)) { - *slot = list_first_entry(&slot_state->slots, - struct adc_conv_slot, list); - list_del(&(*slot)->list); - } else - rc = -EINVAL; - mutex_unlock(&slot_state->list_lock); - - if (rc < 0) { - if (pm8058_xoadc_can_print()) - pr_err("Pmic 8058 xoadc spurious interrupt detected\n"); - return rc; - } - - return 0; -} - -int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, int32_t *data) -{ - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - struct xoadc_conv_state *slot_state = adc_pmic->conv_queue_list; - uint8_t rslt_lsb, rslt_msb; - struct adc_conv_slot *slot; - int32_t rc, max_ideal_adc_code = 1 << adc_pmic->adc_prop->bitresolution; - - if (!xoadc_initialized) - return -ENODEV; - - rc = pm8xxx_readb(adc_pmic->dev->parent, ADC_ARB_USRP_DATA0, - &rslt_lsb); - if (rc < 0) { - pr_debug("%s: PM8058 read failed\n", __func__); - return rc; - } - - rc = pm8xxx_readb(adc_pmic->dev->parent, ADC_ARB_USRP_DATA1, - &rslt_msb); - if (rc < 0) { - pr_debug("%s: PM8058 read failed\n", __func__); - return rc; - } - - *data = (rslt_msb << 8) | rslt_lsb; - - /* Use the midpoint to determine underflow or overflow */ - if (*data > max_ideal_adc_code + (max_ideal_adc_code >> 1)) - *data |= ((1 << (8 * sizeof(*data) - - adc_pmic->adc_prop->bitresolution)) - 1) << - adc_pmic->adc_prop->bitresolution; - /* Return if this is a calibration run since there - * is no need to check requests in the waiting queue */ - if (xoadc_calib_first_adc) - return 0; - - mutex_lock(&slot_state->list_lock); - adc_pmic->xoadc_queue_count--; - if (adc_pmic->xoadc_queue_count > 0) { - slot = list_first_entry(&slot_state->slots, - struct adc_conv_slot, list); - pm8058_xoadc_configure(adc_instance, slot); - } - mutex_unlock(&slot_state->list_lock); - - mutex_lock(&slot_state->list_lock); - /* Default value for switching off the arbiter after reading - the ADC value. Bit 0 set to 0. */ - if (adc_pmic->xoadc_queue_count == 0) { - rc = pm8058_xoadc_arb_cntrl(0, adc_instance, CHANNEL_MUXOFF); - if (rc < 0) { - pr_debug("%s: Configuring ADC Arbiter disable" - "failed\n", __func__); - return rc; - } - if (adc_pmic->pdata->xoadc_vreg_set != NULL) - adc_pmic->pdata->xoadc_vreg_set(0); - } - mutex_unlock(&slot_state->list_lock); - - return 0; -} -EXPORT_SYMBOL(pm8058_xoadc_read_adc_code); - -static irqreturn_t pm8058_xoadc(int irq, void *dev_id) -{ - struct pmic8058_adc *xoadc_8058 = dev_id; - struct adc_conv_slot *slot = NULL; - int rc; - - disable_irq_nosync(xoadc_8058->adc_irq); - - if (xoadc_calib_first_adc) - return IRQ_HANDLED; - - rc = pm8058_xoadc_dequeue_slot_request(xoadc_8058->xoadc_num, &slot); - - if (rc < 0) - return IRQ_NONE; - - if (rc == 0) - msm_adc_conv_cb(slot, 0, NULL, 0); - - return IRQ_HANDLED; -} - -struct adc_properties *pm8058_xoadc_get_properties(uint32_t dev_instance) -{ - struct pmic8058_adc *xoadc_8058 = pmic_adc[dev_instance]; - - return xoadc_8058->adc_prop; -} -EXPORT_SYMBOL(pm8058_xoadc_get_properties); - -int32_t pm8058_xoadc_calib_device(uint32_t adc_instance) -{ - struct pmic8058_adc *adc_pmic = pmic_adc[adc_instance]; - struct adc_conv_slot *slot; - int rc, offset_xoadc, slope_xoadc, calib_read_1, calib_read_2; - - if (adc_pmic->pdata->xoadc_vreg_set != NULL) - adc_pmic->pdata->xoadc_vreg_set(1); - - pm8058_xoadc_slot_request(adc_instance, &slot); - if (slot) { - slot->chan_path = CHAN_PATH_TYPE13; - slot->chan_adc_config = ADC_CONFIG_TYPE2; - slot->chan_adc_calib = ADC_CONFIG_TYPE2; - xoadc_calib_first_adc = true; - rc = pm8058_xoadc_configure(adc_instance, slot); - if (rc) { - pr_err("pm8058_xoadc configure failed\n"); - goto fail; - } - } else { - rc = -EINVAL; - goto fail; - } - - msleep(3); - - rc = pm8058_xoadc_read_adc_code(adc_instance, &calib_read_1); - if (rc) { - pr_err("pm8058_xoadc read adc failed\n"); - xoadc_calib_first_adc = false; - goto fail; - } - xoadc_calib_first_adc = false; - - pm8058_xoadc_slot_request(adc_instance, &slot); - if (slot) { - slot->chan_path = CHAN_PATH_TYPE15; - slot->chan_adc_config = ADC_CONFIG_TYPE2; - slot->chan_adc_calib = ADC_CONFIG_TYPE2; - xoadc_calib_first_adc = true; - rc = pm8058_xoadc_configure(adc_instance, slot); - if (rc) { - pr_err("pm8058_xoadc configure failed\n"); - goto fail; - } - } else { - rc = -EINVAL; - goto fail; - } - - msleep(3); - - rc = pm8058_xoadc_read_adc_code(adc_instance, &calib_read_2); - if (rc) { - pr_err("pm8058_xoadc read adc failed\n"); - xoadc_calib_first_adc = false; - goto fail; - } - xoadc_calib_first_adc = false; - - pm8058_xoadc_restore_slot(adc_instance, slot); - - slope_xoadc = (((calib_read_1 - calib_read_2) << 10)/ - CHANNEL_ADC_625_MV); - offset_xoadc = calib_read_2 - - ((slope_xoadc * CHANNEL_ADC_625_MV) >> 10); - - printk(KERN_INFO"pmic8058_xoadc:The offset for AMUX calibration" - "was %d\n", offset_xoadc); - - adc_pmic->adc_graph[0].offset = offset_xoadc; - adc_pmic->adc_graph[0].dy = (calib_read_1 - calib_read_2); - adc_pmic->adc_graph[0].dx = CHANNEL_ADC_625_MV; - - /* Retain ideal calibration settings for therm readings */ - adc_pmic->adc_graph[1].offset = 0 ; - adc_pmic->adc_graph[1].dy = (1 << 15) - 1; - adc_pmic->adc_graph[1].dx = 2200; - - if (adc_pmic->pdata->xoadc_vreg_set != NULL) - adc_pmic->pdata->xoadc_vreg_set(0); - - return 0; -fail: - if (adc_pmic->pdata->xoadc_vreg_set != NULL) - adc_pmic->pdata->xoadc_vreg_set(0); - - return rc; -} -EXPORT_SYMBOL(pm8058_xoadc_calib_device); - -int32_t pm8058_xoadc_calibrate(uint32_t dev_instance, - struct adc_conv_slot *slot, int *calib_status) -{ - *calib_status = CALIB_NOT_REQUIRED; - - return 0; -} -EXPORT_SYMBOL(pm8058_xoadc_calibrate); - -#ifdef CONFIG_PM -static int pm8058_xoadc_suspend_noirq(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct pmic8058_adc *adc_pmic = platform_get_drvdata(pdev); - - adc_pmic->msm_suspend_check = 1; - - return 0; -} - -static int pm8058_xoadc_resume_noirq(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct pmic8058_adc *adc_pmic = platform_get_drvdata(pdev); - - adc_pmic->msm_suspend_check = 0; - - return 0; -} - -static const struct dev_pm_ops pm8058_xoadc_dev_pm_ops = { - .suspend_noirq = pm8058_xoadc_suspend_noirq, - .resume_noirq = pm8058_xoadc_resume_noirq, -}; - -#define PM8058_XOADC_DEV_PM_OPS (&pm8058_xoadc_dev_pm_ops) -#else -#define PM8058_XOADC_DEV_PM_OPS NULL -#endif - -static int pm8058_xoadc_probe(struct platform_device *pdev) -{ - struct xoadc_platform_data *pdata = pdev->dev.platform_data; - struct pmic8058_adc *adc_pmic; - int i, rc = 0; - - if (!pdata) { - dev_err(&pdev->dev, "no platform data?\n"); - return -EINVAL; - } - - adc_pmic = devm_kzalloc(&pdev->dev, sizeof(*adc_pmic), GFP_KERNEL); - if (!adc_pmic) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - adc_pmic->dev = &pdev->dev; - adc_pmic->adc_prop = pdata->xoadc_prop; - adc_pmic->xoadc_num = pdata->xoadc_num; - adc_pmic->xoadc_queue_count = 0; - - platform_set_drvdata(pdev, adc_pmic); - - if (adc_pmic->xoadc_num > XOADC_PMIC_0) { - dev_err(&pdev->dev, "ADC device not supported\n"); - return -EINVAL; - } - - adc_pmic->pdata = pdata; - adc_pmic->adc_graph = devm_kzalloc(&pdev->dev, - sizeof(struct linear_graph) * MAX_CHANNEL_PROPERTIES_QUEUE, - GFP_KERNEL); - if (!adc_pmic->adc_graph) { - dev_err(&pdev->dev, "Unable to allocate memory\n"); - return -ENOMEM; - } - - /* Will be replaced by individual channel calibration */ - for (i = 0; i < MAX_CHANNEL_PROPERTIES_QUEUE; i++) { - adc_pmic->adc_graph[i].offset = 0 ; - adc_pmic->adc_graph[i].dy = (1 << 15) - 1; - adc_pmic->adc_graph[i].dx = 2200; - } - - if (pdata->xoadc_mpp_config != NULL) - pdata->xoadc_mpp_config(); - - adc_pmic->conv_slot_request = &adc_pmic->conv[0]; - adc_pmic->conv_slot_request->context = - &adc_pmic->conv_queue_elements[0]; - - mutex_init(&adc_pmic->conv_slot_request->list_lock); - INIT_LIST_HEAD(&adc_pmic->conv_slot_request->slots); - - /* tie each slot and initwork them */ - for (i = 0; i < MAX_QUEUE_LENGTH; i++) { - list_add(&adc_pmic->conv_slot_request->context[i].list, - &adc_pmic->conv_slot_request->slots); - INIT_WORK(&adc_pmic->conv_slot_request->context[i].work, - msm_adc_wq_work); - init_completion(&adc_pmic->conv_slot_request->context[i].comp); - adc_pmic->conv_slot_request->context[i].idx = i; - } - - adc_pmic->conv_queue_list = &adc_pmic->conv[1]; - - mutex_init(&adc_pmic->conv_queue_list->list_lock); - INIT_LIST_HEAD(&adc_pmic->conv_queue_list->slots); - - adc_pmic->adc_irq = platform_get_irq(pdev, 0); - if (adc_pmic->adc_irq < 0) - return -ENXIO; - - rc = request_threaded_irq(adc_pmic->adc_irq, - NULL, pm8058_xoadc, - IRQF_TRIGGER_RISING, "pm8058_adc_interrupt", adc_pmic); - if (rc) { - dev_err(&pdev->dev, "failed to request adc irq\n"); - return rc; - } - - disable_irq(adc_pmic->adc_irq); - - if (adc_pmic->adc_voter == NULL) { - adc_pmic->adc_voter = msm_xo_get(MSM_XO_TCXO_D1, - "pmic8058_xoadc"); - if (IS_ERR(adc_pmic->adc_voter)) { - dev_err(&pdev->dev, "Failed to get XO vote\n"); - return PTR_ERR(adc_pmic->adc_voter); - } - } - - device_init_wakeup(&pdev->dev, pdata->xoadc_wakeup); - wake_lock_init(&adc_pmic->adc_wakelock, WAKE_LOCK_SUSPEND, - "pmic8058_xoadc_wakelock"); - - pmic_adc[adc_pmic->xoadc_num] = adc_pmic; - - if (pdata->xoadc_vreg_setup != NULL) - pdata->xoadc_vreg_setup(); - - xoadc_initialized = true; - xoadc_calib_first_adc = false; - - return 0; -} - -static int pm8058_xoadc_teardown(struct platform_device *pdev) -{ - struct pmic8058_adc *adc_pmic = platform_get_drvdata(pdev); - - if (adc_pmic->pdata->xoadc_vreg_shutdown != NULL) - adc_pmic->pdata->xoadc_vreg_shutdown(); - - wake_lock_destroy(&adc_pmic->adc_wakelock); - msm_xo_put(adc_pmic->adc_voter); - device_init_wakeup(&pdev->dev, 0); - xoadc_initialized = false; - - return 0; -} - -static struct platform_driver pm8058_xoadc_driver = { - .probe = pm8058_xoadc_probe, - .remove = pm8058_xoadc_teardown, - .driver = { - .name = "pm8058-xoadc", - .owner = THIS_MODULE, - .pm = PM8058_XOADC_DEV_PM_OPS, - }, -}; - -static int __init pm8058_xoadc_init(void) -{ - return platform_driver_register(&pm8058_xoadc_driver); -} -module_init(pm8058_xoadc_init); - -static void __exit pm8058_xoadc_exit(void) -{ - platform_driver_unregister(&pm8058_xoadc_driver); -} -module_exit(pm8058_xoadc_exit); - -MODULE_ALIAS("platform:pmic8058_xoadc"); -MODULE_DESCRIPTION("PMIC8058 XOADC driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/misc/tsif.c b/drivers/misc/tsif.c deleted file mode 100644 index f638f4d9018c1f36775be3acf2530649c6f9fbbe..0000000000000000000000000000000000000000 --- a/drivers/misc/tsif.c +++ /dev/null @@ -1,1797 +0,0 @@ -/* - * TSIF Driver - * - * Copyright (c) 2012-2013, 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 /* Needed by all modules */ -#include /* Needed for KERN_INFO */ -#include /* Needed for the macros */ -#include /* IS_ERR etc. */ -#include - -#include /* XXX_mem_region */ -#include -#include /* dma_XXX */ -#include /* msleep */ - -#include /* ioXXX */ -#include /* copy_from_user */ -#include -#include -#include -#include -#include /* kfree, kzalloc */ -#include -#include -#include - -/* - * TSIF register offsets - */ -#define TSIF_STS_CTL_OFF (0x0) -#define TSIF_TIME_LIMIT_OFF (0x4) -#define TSIF_CLK_REF_OFF (0x8) -#define TSIF_LPBK_FLAGS_OFF (0xc) -#define TSIF_LPBK_DATA_OFF (0x10) -#define TSIF_TEST_CTL_OFF (0x14) -#define TSIF_TEST_MODE_OFF (0x18) -#define TSIF_TEST_RESET_OFF (0x1c) -#define TSIF_TEST_EXPORT_OFF (0x20) -#define TSIF_TEST_CURRENT_OFF (0x24) - -#define TSIF_DATA_PORT_OFF (0x100) - -/* bits for TSIF_STS_CTL register */ -#define TSIF_STS_CTL_EN_IRQ (1 << 28) -#define TSIF_STS_CTL_PACK_AVAIL (1 << 27) -#define TSIF_STS_CTL_1ST_PACKET (1 << 26) -#define TSIF_STS_CTL_OVERFLOW (1 << 25) -#define TSIF_STS_CTL_LOST_SYNC (1 << 24) -#define TSIF_STS_CTL_TIMEOUT (1 << 23) -#define TSIF_STS_CTL_INV_SYNC (1 << 21) -#define TSIF_STS_CTL_INV_NULL (1 << 20) -#define TSIF_STS_CTL_INV_ERROR (1 << 19) -#define TSIF_STS_CTL_INV_ENABLE (1 << 18) -#define TSIF_STS_CTL_INV_DATA (1 << 17) -#define TSIF_STS_CTL_INV_CLOCK (1 << 16) -#define TSIF_STS_CTL_SPARE (1 << 15) -#define TSIF_STS_CTL_EN_NULL (1 << 11) -#define TSIF_STS_CTL_EN_ERROR (1 << 10) -#define TSIF_STS_CTL_LAST_BIT (1 << 9) -#define TSIF_STS_CTL_EN_TIME_LIM (1 << 8) -#define TSIF_STS_CTL_EN_TCR (1 << 7) -#define TSIF_STS_CTL_TEST_MODE (3 << 5) -#define TSIF_STS_CTL_EN_DM (1 << 4) -#define TSIF_STS_CTL_STOP (1 << 3) -#define TSIF_STS_CTL_START (1 << 0) - -/* - * Data buffering parameters - * - * Data stored in cyclic buffer; - * - * Data organized in chunks of packets. - * One chunk processed at a time by the data mover - * - */ -#define TSIF_PKTS_IN_CHUNK_DEFAULT (16) /**< packets in one DM chunk */ -#define TSIF_CHUNKS_IN_BUF_DEFAULT (8) -#define TSIF_PKTS_IN_CHUNK (tsif_device->pkts_per_chunk) -#define TSIF_CHUNKS_IN_BUF (tsif_device->chunks_per_buf) -#define TSIF_PKTS_IN_BUF (TSIF_PKTS_IN_CHUNK * TSIF_CHUNKS_IN_BUF) -#define TSIF_BUF_SIZE (TSIF_PKTS_IN_BUF * TSIF_PKT_SIZE) -#define TSIF_MAX_ID 1 - -#define ROW_RESET (MSM_CLK_CTL_BASE + 0x214) -#define GLBL_CLK_ENA (MSM_CLK_CTL_BASE + 0x000) -#define CLK_HALT_STATEB (MSM_CLK_CTL_BASE + 0x104) -#define TSIF_NS_REG (MSM_CLK_CTL_BASE + 0x0b4) -#define TV_NS_REG (MSM_CLK_CTL_BASE + 0x0bc) - -/* used to create debugfs entries */ -static const struct { - const char *name; - mode_t mode; - int offset; -} debugfs_tsif_regs[] = { - {"sts_ctl", S_IRUGO | S_IWUSR, TSIF_STS_CTL_OFF}, - {"time_limit", S_IRUGO | S_IWUSR, TSIF_TIME_LIMIT_OFF}, - {"clk_ref", S_IRUGO | S_IWUSR, TSIF_CLK_REF_OFF}, - {"lpbk_flags", S_IRUGO | S_IWUSR, TSIF_LPBK_FLAGS_OFF}, - {"lpbk_data", S_IRUGO | S_IWUSR, TSIF_LPBK_DATA_OFF}, - {"test_ctl", S_IRUGO | S_IWUSR, TSIF_TEST_CTL_OFF}, - {"test_mode", S_IRUGO | S_IWUSR, TSIF_TEST_MODE_OFF}, - {"test_reset", S_IWUSR, TSIF_TEST_RESET_OFF}, - {"test_export", S_IRUGO | S_IWUSR, TSIF_TEST_EXPORT_OFF}, - {"test_current", S_IRUGO, TSIF_TEST_CURRENT_OFF}, - {"data_port", S_IRUSR, TSIF_DATA_PORT_OFF}, -}; - -/* structures for Data Mover */ -struct tsif_dmov_cmd { - dmov_box box; - dma_addr_t box_ptr; -}; - -struct msm_tsif_device; - -struct tsif_xfer { - struct msm_dmov_cmd hdr; - struct msm_tsif_device *tsif_device; - int busy; - int wi; /**< set devices's write index after xfer */ -}; - -struct msm_tsif_device { - struct list_head devlist; - struct platform_device *pdev; - struct resource *memres; - void __iomem *base; - unsigned int irq; - int mode; - u32 time_limit; - int clock_inverse; - int data_inverse; - int sync_inverse; - int enable_inverse; - enum tsif_state state; - struct wake_lock wake_lock; - /* clocks */ - struct clk *tsif_clk; - struct clk *tsif_pclk; - struct clk *tsif_ref_clk; - /* debugfs */ - struct dentry *dent_tsif; - struct dentry *debugfs_tsif_regs[ARRAY_SIZE(debugfs_tsif_regs)]; - struct dentry *debugfs_gpio; - struct dentry *debugfs_action; - struct dentry *debugfs_dma; - struct dentry *debugfs_databuf; - struct debugfs_blob_wrapper blob_wrapper_databuf; - /* DMA related */ - int dma; - int crci; - void *data_buffer; - dma_addr_t data_buffer_dma; - u32 pkts_per_chunk; - u32 chunks_per_buf; - int ri; - int wi; - int dmwi; /**< DataMover write index */ - struct tsif_dmov_cmd *dmov_cmd[2]; - dma_addr_t dmov_cmd_dma[2]; - struct tsif_xfer xfer[2]; - struct tasklet_struct dma_refill; - struct tasklet_struct clocks_off; - /* statistics */ - u32 stat_rx; - u32 stat_overflow; - u32 stat_lost_sync; - u32 stat_timeout; - u32 stat_dmov_err; - u32 stat_soft_drop; - int stat_ifi; /* inter frame interval */ - u32 stat0, stat1; - /* client */ - void *client_data; - void (*client_notify)(void *client_data); -}; - -/* ===clocks begin=== */ - -static void tsif_put_clocks(struct msm_tsif_device *tsif_device) -{ - if (tsif_device->tsif_clk) { - clk_put(tsif_device->tsif_clk); - tsif_device->tsif_clk = NULL; - } - if (tsif_device->tsif_pclk) { - clk_put(tsif_device->tsif_pclk); - tsif_device->tsif_pclk = NULL; - } - - if (tsif_device->tsif_ref_clk) { - clk_put(tsif_device->tsif_ref_clk); - tsif_device->tsif_ref_clk = NULL; - } -} - -static int tsif_get_clocks(struct msm_tsif_device *tsif_device) -{ - struct msm_tsif_platform_data *pdata = - tsif_device->pdev->dev.platform_data; - int rc = 0; - - if (pdata->tsif_clk) { - tsif_device->tsif_clk = clk_get(&tsif_device->pdev->dev, - pdata->tsif_clk); - if (IS_ERR(tsif_device->tsif_clk)) { - rc = PTR_ERR(tsif_device->tsif_clk); - tsif_device->tsif_clk = NULL; - goto ret; - } - } - if (pdata->tsif_pclk) { - tsif_device->tsif_pclk = clk_get(&tsif_device->pdev->dev, - pdata->tsif_pclk); - if (IS_ERR(tsif_device->tsif_pclk)) { - rc = PTR_ERR(tsif_device->tsif_pclk); - tsif_device->tsif_pclk = NULL; - goto ret; - } - } - if (pdata->tsif_ref_clk) { - tsif_device->tsif_ref_clk = clk_get(&tsif_device->pdev->dev, - pdata->tsif_ref_clk); - if (IS_ERR(tsif_device->tsif_ref_clk)) { - rc = PTR_ERR(tsif_device->tsif_ref_clk); - tsif_device->tsif_ref_clk = NULL; - goto ret; - } - } - return 0; -ret: - tsif_put_clocks(tsif_device); - return rc; -} - -static void tsif_clock(struct msm_tsif_device *tsif_device, int on) -{ - if (on) { - if (tsif_device->tsif_clk) - clk_prepare_enable(tsif_device->tsif_clk); - if (tsif_device->tsif_pclk) - clk_prepare_enable(tsif_device->tsif_pclk); - clk_prepare_enable(tsif_device->tsif_ref_clk); - } else { - if (tsif_device->tsif_clk) - clk_disable_unprepare(tsif_device->tsif_clk); - if (tsif_device->tsif_pclk) - clk_disable_unprepare(tsif_device->tsif_pclk); - clk_disable_unprepare(tsif_device->tsif_ref_clk); - } -} - -static void tsif_clocks_off(unsigned long data) -{ - struct msm_tsif_device *tsif_device = (struct msm_tsif_device *) data; - tsif_clock(tsif_device, 0); -} -/* ===clocks end=== */ -/* ===gpio begin=== */ - -static int tsif_gpios_disable(const struct msm_gpio *table, int size) -{ - int rc = 0; - int i; - const struct msm_gpio *g; - for (i = size-1; i >= 0; i--) { - int tmp; - g = table + i; - tmp = gpio_tlmm_config(GPIO_CFG(GPIO_PIN(g->gpio_cfg), - 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), - GPIO_CFG_DISABLE); - if (tmp) { - pr_err("gpio_tlmm_config(0x%08x, GPIO_CFG_DISABLE)" - " <%s> failed: %d\n", - g->gpio_cfg, g->label ?: "?", rc); - pr_err("pin %d func %d dir %d pull %d drvstr %d\n", - GPIO_PIN(g->gpio_cfg), GPIO_FUNC(g->gpio_cfg), - GPIO_DIR(g->gpio_cfg), GPIO_PULL(g->gpio_cfg), - GPIO_DRVSTR(g->gpio_cfg)); - if (!rc) - rc = tmp; - } - } - - return rc; -} - -static int tsif_gpios_enable(const struct msm_gpio *table, int size) -{ - int rc; - int i; - const struct msm_gpio *g; - for (i = 0; i < size; i++) { - g = table + i; - rc = gpio_tlmm_config(g->gpio_cfg, GPIO_CFG_ENABLE); - if (rc) { - pr_err("gpio_tlmm_config(0x%08x, GPIO_CFG_ENABLE)" - " <%s> failed: %d\n", - g->gpio_cfg, g->label ?: "?", rc); - pr_err("pin %d func %d dir %d pull %d drvstr %d\n", - GPIO_PIN(g->gpio_cfg), GPIO_FUNC(g->gpio_cfg), - GPIO_DIR(g->gpio_cfg), GPIO_PULL(g->gpio_cfg), - GPIO_DRVSTR(g->gpio_cfg)); - goto err; - } - } - return 0; -err: - tsif_gpios_disable(table, i); - return rc; -} - -static int tsif_gpios_request_enable(const struct msm_gpio *table, int size) -{ - int rc; - rc = tsif_gpios_enable(table, size); - return rc; -} - -static void tsif_gpios_disable_free(const struct msm_gpio *table, int size) -{ - tsif_gpios_disable(table, size); -} - -static int tsif_start_gpios(struct msm_tsif_device *tsif_device) -{ - struct msm_tsif_platform_data *pdata = - tsif_device->pdev->dev.platform_data; - return tsif_gpios_request_enable(pdata->gpios, pdata->num_gpios); -} - -static void tsif_stop_gpios(struct msm_tsif_device *tsif_device) -{ - struct msm_tsif_platform_data *pdata = - tsif_device->pdev->dev.platform_data; - tsif_gpios_disable_free(pdata->gpios, pdata->num_gpios); -} - -/* ===gpio end=== */ - -static int tsif_start_hw(struct msm_tsif_device *tsif_device) -{ - u32 ctl = TSIF_STS_CTL_EN_IRQ | - TSIF_STS_CTL_EN_TIME_LIM | - TSIF_STS_CTL_EN_TCR | - TSIF_STS_CTL_EN_DM; - - if (tsif_device->clock_inverse) - ctl |= TSIF_STS_CTL_INV_CLOCK; - - if (tsif_device->data_inverse) - ctl |= TSIF_STS_CTL_INV_DATA; - - if (tsif_device->sync_inverse) - ctl |= TSIF_STS_CTL_INV_SYNC; - - if (tsif_device->enable_inverse) - ctl |= TSIF_STS_CTL_INV_ENABLE; - - dev_info(&tsif_device->pdev->dev, "%s\n", __func__); - switch (tsif_device->mode) { - case 1: /* mode 1 */ - ctl |= (0 << 5); - break; - case 2: /* mode 2 */ - ctl |= (1 << 5); - break; - case 3: /* manual - control from debugfs */ - return 0; - break; - default: - return -EINVAL; - } - iowrite32(ctl, tsif_device->base + TSIF_STS_CTL_OFF); - iowrite32(tsif_device->time_limit, - tsif_device->base + TSIF_TIME_LIMIT_OFF); - wmb(); - iowrite32(ctl | TSIF_STS_CTL_START, - tsif_device->base + TSIF_STS_CTL_OFF); - wmb(); - ctl = ioread32(tsif_device->base + TSIF_STS_CTL_OFF); - return (ctl & TSIF_STS_CTL_START) ? 0 : -EFAULT; -} - -static void tsif_stop_hw(struct msm_tsif_device *tsif_device) -{ - iowrite32(TSIF_STS_CTL_STOP, tsif_device->base + TSIF_STS_CTL_OFF); - wmb(); -} - -/* ===DMA begin=== */ -/** - * TSIF DMA theory of operation - * - * Circular memory buffer \a tsif_mem_buffer allocated; - * 4 pointers points to and moved forward on: - * - \a ri index of first ready to read packet. - * Updated by client's call to tsif_reclaim_packets() - * - \a wi points to the next packet to be written by DM. - * Data below is valid and will not be overriden by DMA. - * Moved on DM callback - * - \a dmwi points to the next packet not scheduled yet for DM - * moved when packet scheduled for DM - * - * In addition, DM xfer keep internal \a wi - copy of \a tsif_device->dmwi - * at time immediately after scheduling. - * - * Initially, 2 packets get scheduled for the DM. - * - * Upon packet receive, DM writes packet to the pre-programmed - * location and invoke its callback. - * - * DM callback moves sets wi pointer to \a xfer->wi; - * then it schedules next packet for DM and moves \a dmwi pointer. - * - * Buffer overflow handling - * - * If \a dmwi == \a ri-1, buffer is full and \a dmwi can't be advanced. - * DMA re-scheduled to the same index. - * Callback check and not move \a wi to become equal to \a ri - * - * On \a read request, data between \a ri and \a wi pointers may be read; - * \ri pointer moved accordingly. - * - * It is always granted, on modulo sizeof(tsif_mem_buffer), that - * \a wi is between [\a ri, \a dmwi] - * - * Amount of data available is (wi-ri)*TSIF_PKT_SIZE - * - * Number of scheduled packets for DM: (dmwi-wi) - */ - -/** - * tsif_dma_schedule - schedule DMA transfers - * - * @tsif_device: device - * - * Executed from process context on init, or from tasklet when - * re-scheduling upon DMA completion. - * This prevent concurrent execution from several CPU's - */ -static void tsif_dma_schedule(struct msm_tsif_device *tsif_device) -{ - int i, dmwi0, dmwi1, found = 0; - /* find free entry */ - for (i = 0; i < 2; i++) { - struct tsif_xfer *xfer = &tsif_device->xfer[i]; - if (xfer->busy) - continue; - found++; - xfer->busy = 1; - dmwi0 = tsif_device->dmwi; - tsif_device->dmov_cmd[i]->box.dst_row_addr = - tsif_device->data_buffer_dma + TSIF_PKT_SIZE * dmwi0; - /* proposed value for dmwi */ - dmwi1 = (dmwi0 + TSIF_PKTS_IN_CHUNK) % TSIF_PKTS_IN_BUF; - /** - * If dmwi going to overlap with ri, - * overflow occurs because data was not read. - * Still get this packet, to not interrupt TSIF - * hardware, but do not advance dmwi. - * - * Upon receive, packet will be dropped. - */ - if (dmwi1 != tsif_device->ri) { - tsif_device->dmwi = dmwi1; - } else { - dev_info(&tsif_device->pdev->dev, - "Overflow detected\n"); - } - xfer->wi = tsif_device->dmwi; -#ifdef CONFIG_TSIF_DEBUG - dev_info(&tsif_device->pdev->dev, - "schedule xfer[%d] -> [%2d]{%2d}\n", - i, dmwi0, xfer->wi); -#endif - /* complete all the writes to box */ - dma_coherent_pre_ops(); - msm_dmov_enqueue_cmd(tsif_device->dma, &xfer->hdr); - } - if (!found) - dev_info(&tsif_device->pdev->dev, - "All xfer entries are busy\n"); -} - -/** - * tsif_dmov_complete_func - DataMover completion callback - * - * @cmd: original DM command - * @result: DM result - * @err: optional error buffer - * - * Executed in IRQ context (Data Mover's IRQ) - * DataMover's spinlock @msm_dmov_lock held. - */ -static void tsif_dmov_complete_func(struct msm_dmov_cmd *cmd, - unsigned int result, - struct msm_dmov_errdata *err) -{ - int i; - u32 data_offset; - struct tsif_xfer *xfer; - struct msm_tsif_device *tsif_device; - int reschedule = 0; - if (!(result & DMOV_RSLT_VALID)) { /* can I trust to @cmd? */ - pr_err("Invalid DMOV result: rc=0x%08x, cmd = %p", result, cmd); - return; - } - /* restore original context */ - xfer = container_of(cmd, struct tsif_xfer, hdr); - tsif_device = xfer->tsif_device; - i = xfer - tsif_device->xfer; - data_offset = tsif_device->dmov_cmd[i]->box.dst_row_addr - - tsif_device->data_buffer_dma; - - /* order reads from the xferred buffer */ - dma_coherent_post_ops(); - if (result & DMOV_RSLT_DONE) { - int w = data_offset / TSIF_PKT_SIZE; - tsif_device->stat_rx++; - /* - * sowtware overflow when I was scheduled? - * - * @w is where this xfer was actually written to; - * @xfer->wi is where device's @wi will be set; - * - * if these 2 are equal, we are short in space and - * going to overwrite this xfer - this is "soft drop" - */ - if (w == xfer->wi) - tsif_device->stat_soft_drop++; - reschedule = (tsif_device->state == tsif_state_running); -#ifdef CONFIG_TSIF_DEBUG - /* IFI calculation */ - /* - * update stat_ifi (inter frame interval) - * - * Calculate time difference between last and 1-st - * packets in chunk - * - * To be removed after tuning - */ - if (TSIF_PKTS_IN_CHUNK > 1) { - void *ptr = tsif_device->data_buffer + data_offset; - u32 *p0 = ptr; - u32 *p1 = ptr + (TSIF_PKTS_IN_CHUNK - 1) * - TSIF_PKT_SIZE; - u32 tts0 = TSIF_STATUS_TTS(tsif_device->stat0 = - tsif_pkt_status(p0)); - u32 tts1 = TSIF_STATUS_TTS(tsif_device->stat1 = - tsif_pkt_status(p1)); - tsif_device->stat_ifi = (tts1 - tts0) / - (TSIF_PKTS_IN_CHUNK - 1); - } -#endif - } else { - /** - * Error or flush - * - * To recover - re-open TSIF device. - */ - /* mark status "not valid" in data buffer */ - int n; - void *ptr = tsif_device->data_buffer + data_offset; - for (n = 0; n < TSIF_PKTS_IN_CHUNK; n++) { - u32 *p = ptr + (n * TSIF_PKT_SIZE); - /* last dword is status + TTS */ - p[TSIF_PKT_SIZE / sizeof(*p) - 1] = 0; - } - if (result & DMOV_RSLT_ERROR) { - dev_err(&tsif_device->pdev->dev, - "DMA error (0x%08x)\n", result); - tsif_device->stat_dmov_err++; - /* force device close */ - if (tsif_device->state == tsif_state_running) { - tsif_stop_hw(tsif_device); - /* - * This branch is taken only in case of - * severe hardware problem (I don't even know - * what should happen for DMOV_RSLT_ERROR); - * thus I prefer code simplicity over - * performance. - * Clocks are turned off from outside the - * interrupt context. - */ - tasklet_schedule(&tsif_device->clocks_off); - tsif_device->state = tsif_state_flushing; - } - } - if (result & DMOV_RSLT_FLUSH) { - /* - * Flushing normally happens in process of - * @tsif_stop(), when we are waiting for outstanding - * DMA commands to be flushed. - */ - dev_info(&tsif_device->pdev->dev, - "DMA channel flushed (0x%08x)\n", result); - if (tsif_device->state == tsif_state_flushing) { - if ((!tsif_device->xfer[0].busy) && - (!tsif_device->xfer[1].busy)) { - tsif_device->state = tsif_state_stopped; - } - } - } - if (err) - dev_err(&tsif_device->pdev->dev, - "Flush data: %08x %08x %08x %08x %08x %08x\n", - err->flush[0], err->flush[1], err->flush[2], - err->flush[3], err->flush[4], err->flush[5]); - } - tsif_device->wi = xfer->wi; - xfer->busy = 0; - if (tsif_device->client_notify) - tsif_device->client_notify(tsif_device->client_data); - /* - * Can't schedule next DMA - - * DataMover driver still hold its semaphore, - * deadlock will occur. - */ - if (reschedule) - tasklet_schedule(&tsif_device->dma_refill); -} - -/** - * tsif_dma_refill - tasklet function for tsif_device->dma_refill - * - * @data: tsif_device - * - * Reschedule DMA requests - * - * Executed in tasklet - */ -static void tsif_dma_refill(unsigned long data) -{ - struct msm_tsif_device *tsif_device = (struct msm_tsif_device *) data; - if (tsif_device->state == tsif_state_running) - tsif_dma_schedule(tsif_device); -} - -/** - * tsif_dma_flush - flush DMA channel - * - * @tsif_device: - * - * busy wait till DMA flushed - */ -static void tsif_dma_flush(struct msm_tsif_device *tsif_device) -{ - if (tsif_device->xfer[0].busy || tsif_device->xfer[1].busy) { - tsif_device->state = tsif_state_flushing; - while (tsif_device->xfer[0].busy || - tsif_device->xfer[1].busy) { - msm_dmov_flush(tsif_device->dma, 1); - usleep(10000); - } - } - tsif_device->state = tsif_state_stopped; - if (tsif_device->client_notify) - tsif_device->client_notify(tsif_device->client_data); -} - -static void tsif_dma_exit(struct msm_tsif_device *tsif_device) -{ - int i; - tsif_device->state = tsif_state_flushing; - tasklet_kill(&tsif_device->dma_refill); - tsif_dma_flush(tsif_device); - for (i = 0; i < 2; i++) { - if (tsif_device->dmov_cmd[i]) { - dma_free_coherent(NULL, sizeof(struct tsif_dmov_cmd), - tsif_device->dmov_cmd[i], - tsif_device->dmov_cmd_dma[i]); - tsif_device->dmov_cmd[i] = NULL; - } - } - if (tsif_device->data_buffer) { - tsif_device->blob_wrapper_databuf.data = NULL; - tsif_device->blob_wrapper_databuf.size = 0; - dma_free_coherent(NULL, TSIF_BUF_SIZE, - tsif_device->data_buffer, - tsif_device->data_buffer_dma); - tsif_device->data_buffer = NULL; - } -} - -static int tsif_dma_init(struct msm_tsif_device *tsif_device) -{ - int i; - /* TODO: allocate all DMA memory in one buffer */ - /* Note: don't pass device, - it require coherent_dma_mask id device definition */ - tsif_device->data_buffer = dma_alloc_coherent(NULL, TSIF_BUF_SIZE, - &tsif_device->data_buffer_dma, GFP_KERNEL); - if (!tsif_device->data_buffer) - goto err; - dev_info(&tsif_device->pdev->dev, "data_buffer: %p phys 0x%08x\n", - tsif_device->data_buffer, tsif_device->data_buffer_dma); - tsif_device->blob_wrapper_databuf.data = tsif_device->data_buffer; - tsif_device->blob_wrapper_databuf.size = TSIF_BUF_SIZE; - tsif_device->ri = 0; - tsif_device->wi = 0; - tsif_device->dmwi = 0; - for (i = 0; i < 2; i++) { - dmov_box *box; - struct msm_dmov_cmd *hdr; - tsif_device->dmov_cmd[i] = dma_alloc_coherent(NULL, - sizeof(struct tsif_dmov_cmd), - &tsif_device->dmov_cmd_dma[i], GFP_KERNEL); - if (!tsif_device->dmov_cmd[i]) - goto err; - dev_info(&tsif_device->pdev->dev, "dma[%i]: %p phys 0x%08x\n", - i, tsif_device->dmov_cmd[i], - tsif_device->dmov_cmd_dma[i]); - /* dst in 16 LSB, src in 16 MSB */ - box = &(tsif_device->dmov_cmd[i]->box); - box->cmd = CMD_MODE_BOX | CMD_LC | - CMD_SRC_CRCI(tsif_device->crci); - box->src_row_addr = - tsif_device->memres->start + TSIF_DATA_PORT_OFF; - box->src_dst_len = (TSIF_PKT_SIZE << 16) | TSIF_PKT_SIZE; - box->num_rows = (TSIF_PKTS_IN_CHUNK << 16) | TSIF_PKTS_IN_CHUNK; - box->row_offset = (0 << 16) | TSIF_PKT_SIZE; - - tsif_device->dmov_cmd[i]->box_ptr = CMD_PTR_LP | - DMOV_CMD_ADDR(tsif_device->dmov_cmd_dma[i] + - offsetof(struct tsif_dmov_cmd, box)); - tsif_device->xfer[i].tsif_device = tsif_device; - hdr = &tsif_device->xfer[i].hdr; - hdr->cmdptr = DMOV_CMD_ADDR(tsif_device->dmov_cmd_dma[i] + - offsetof(struct tsif_dmov_cmd, box_ptr)); - hdr->complete_func = tsif_dmov_complete_func; - } - msm_dmov_flush(tsif_device->dma, 1); - return 0; -err: - dev_err(&tsif_device->pdev->dev, "Failed to allocate DMA buffers\n"); - tsif_dma_exit(tsif_device); - return -ENOMEM; -} - -/* ===DMA end=== */ - -/* ===IRQ begin=== */ - -static irqreturn_t tsif_irq(int irq, void *dev_id) -{ - struct msm_tsif_device *tsif_device = dev_id; - u32 sts_ctl = ioread32(tsif_device->base + TSIF_STS_CTL_OFF); - if (!(sts_ctl & (TSIF_STS_CTL_PACK_AVAIL | - TSIF_STS_CTL_OVERFLOW | - TSIF_STS_CTL_LOST_SYNC | - TSIF_STS_CTL_TIMEOUT))) { - dev_warn(&tsif_device->pdev->dev, "Spurious interrupt\n"); - return IRQ_NONE; - } - if (sts_ctl & TSIF_STS_CTL_PACK_AVAIL) { - dev_info(&tsif_device->pdev->dev, "TSIF IRQ: PACK_AVAIL\n"); - tsif_device->stat_rx++; - } - if (sts_ctl & TSIF_STS_CTL_OVERFLOW) { - dev_info(&tsif_device->pdev->dev, "TSIF IRQ: OVERFLOW\n"); - tsif_device->stat_overflow++; - } - if (sts_ctl & TSIF_STS_CTL_LOST_SYNC) { - dev_info(&tsif_device->pdev->dev, "TSIF IRQ: LOST SYNC\n"); - tsif_device->stat_lost_sync++; - } - if (sts_ctl & TSIF_STS_CTL_TIMEOUT) { - dev_info(&tsif_device->pdev->dev, "TSIF IRQ: TIMEOUT\n"); - tsif_device->stat_timeout++; - } - iowrite32(sts_ctl, tsif_device->base + TSIF_STS_CTL_OFF); - wmb(); - return IRQ_HANDLED; -} - -/* ===IRQ end=== */ - -/* ===Device attributes begin=== */ - -static ssize_t show_stats(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - char *state_string; - switch (tsif_device->state) { - case tsif_state_stopped: - state_string = "stopped"; - break; - case tsif_state_running: - state_string = "running"; - break; - case tsif_state_flushing: - state_string = "flushing"; - break; - default: - state_string = "???"; - } - return snprintf(buf, PAGE_SIZE, - "Device %s\n" - "Mode = %d\n" - "Time limit = %d\n" - "State %s\n" - "Client = %p\n" - "Pkt/Buf = %d\n" - "Pkt/chunk = %d\n" - "Clock inv = %d\n" - "Data inv = %d\n" - "Sync inv = %d\n" - "Enable inv = %d\n" - "--statistics--\n" - "Rx chunks = %d\n" - "Overflow = %d\n" - "Lost sync = %d\n" - "Timeout = %d\n" - "DMA error = %d\n" - "Soft drop = %d\n" - "IFI = %d\n" - "(0x%08x - 0x%08x) / %d\n" - "--debug--\n" - "GLBL_CLK_ENA = 0x%08x\n" - "ROW_RESET = 0x%08x\n" - "CLK_HALT_STATEB = 0x%08x\n" - "TV_NS_REG = 0x%08x\n" - "TSIF_NS_REG = 0x%08x\n", - dev_name(dev), - tsif_device->mode, - tsif_device->time_limit, - state_string, - tsif_device->client_data, - TSIF_PKTS_IN_BUF, - TSIF_PKTS_IN_CHUNK, - tsif_device->clock_inverse, - tsif_device->data_inverse, - tsif_device->sync_inverse, - tsif_device->enable_inverse, - tsif_device->stat_rx, - tsif_device->stat_overflow, - tsif_device->stat_lost_sync, - tsif_device->stat_timeout, - tsif_device->stat_dmov_err, - tsif_device->stat_soft_drop, - tsif_device->stat_ifi, - tsif_device->stat1, - tsif_device->stat0, - TSIF_PKTS_IN_CHUNK - 1, - ioread32(GLBL_CLK_ENA), - ioread32(ROW_RESET), - ioread32(CLK_HALT_STATEB), - ioread32(TV_NS_REG), - ioread32(TSIF_NS_REG) - ); -} -/** - * set_stats - reset statistics on write - * - * @dev: - * @attr: - * @buf: - * @count: - */ -static ssize_t set_stats(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - tsif_device->stat_rx = 0; - tsif_device->stat_overflow = 0; - tsif_device->stat_lost_sync = 0; - tsif_device->stat_timeout = 0; - tsif_device->stat_dmov_err = 0; - tsif_device->stat_soft_drop = 0; - tsif_device->stat_ifi = 0; - return count; -} -static DEVICE_ATTR(stats, S_IRUGO | S_IWUSR, show_stats, set_stats); - -static ssize_t show_mode(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", tsif_device->mode); -} - -static ssize_t set_mode(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - int value; - int rc; - if (1 != sscanf(buf, "%d", &value)) { - dev_err(&tsif_device->pdev->dev, - "Failed to parse integer: <%s>\n", buf); - return -EINVAL; - } - rc = tsif_set_mode(tsif_device, value); - if (!rc) - rc = count; - return rc; -} -static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, show_mode, set_mode); - -static ssize_t show_time_limit(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", tsif_device->time_limit); -} - -static ssize_t set_time_limit(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - int value; - int rc; - if (1 != sscanf(buf, "%d", &value)) { - dev_err(&tsif_device->pdev->dev, - "Failed to parse integer: <%s>\n", buf); - return -EINVAL; - } - rc = tsif_set_time_limit(tsif_device, value); - if (!rc) - rc = count; - return rc; -} -static DEVICE_ATTR(time_limit, S_IRUGO | S_IWUSR, - show_time_limit, set_time_limit); - -static ssize_t show_buf_config(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d * %d\n", - tsif_device->pkts_per_chunk, - tsif_device->chunks_per_buf); -} - -static ssize_t set_buf_config(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - u32 p, c; - int rc; - if (2 != sscanf(buf, "%d * %d", &p, &c)) { - dev_err(&tsif_device->pdev->dev, - "Failed to parse integer: <%s>\n", buf); - return -EINVAL; - } - rc = tsif_set_buf_config(tsif_device, p, c); - if (!rc) - rc = count; - return rc; -} -static DEVICE_ATTR(buf_config, S_IRUGO | S_IWUSR, - show_buf_config, set_buf_config); - -static ssize_t show_clk_inverse(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", tsif_device->clock_inverse); -} - -static ssize_t set_clk_inverse(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - int value; - int rc; - if (1 != sscanf(buf, "%d", &value)) { - dev_err(&tsif_device->pdev->dev, - "Failed to parse integer: <%s>\n", buf); - return -EINVAL; - } - rc = tsif_set_clk_inverse(tsif_device, value); - if (!rc) - rc = count; - return rc; -} -static DEVICE_ATTR(clk_inverse, S_IRUGO | S_IWUSR, - show_clk_inverse, set_clk_inverse); - -static ssize_t show_data_inverse(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", tsif_device->data_inverse); -} - -static ssize_t set_data_inverse(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - int value; - int rc; - if (1 != sscanf(buf, "%d", &value)) { - dev_err(&tsif_device->pdev->dev, - "Failed to parse integer: <%s>\n", buf); - return -EINVAL; - } - rc = tsif_set_data_inverse(tsif_device, value); - if (!rc) - rc = count; - return rc; -} -static DEVICE_ATTR(data_inverse, S_IRUGO | S_IWUSR, - show_data_inverse, set_data_inverse); - -static ssize_t show_sync_inverse(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", tsif_device->sync_inverse); -} - -static ssize_t set_sync_inverse(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - int value; - int rc; - if (1 != sscanf(buf, "%d", &value)) { - dev_err(&tsif_device->pdev->dev, - "Failed to parse integer: <%s>\n", buf); - return -EINVAL; - } - rc = tsif_set_sync_inverse(tsif_device, value); - if (!rc) - rc = count; - return rc; -} -static DEVICE_ATTR(sync_inverse, S_IRUGO | S_IWUSR, - show_sync_inverse, set_sync_inverse); - -static ssize_t show_enable_inverse(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", tsif_device->enable_inverse); -} - -static ssize_t set_enable_inverse(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct msm_tsif_device *tsif_device = dev_get_drvdata(dev); - int value; - int rc; - if (1 != sscanf(buf, "%d", &value)) { - dev_err(&tsif_device->pdev->dev, - "Failed to parse integer: <%s>\n", buf); - return -EINVAL; - } - rc = tsif_set_enable_inverse(tsif_device, value); - if (!rc) - rc = count; - return rc; -} -static DEVICE_ATTR(enable_inverse, S_IRUGO | S_IWUSR, - show_enable_inverse, set_enable_inverse); - - -static struct attribute *dev_attrs[] = { - &dev_attr_stats.attr, - &dev_attr_mode.attr, - &dev_attr_time_limit.attr, - &dev_attr_buf_config.attr, - &dev_attr_clk_inverse.attr, - &dev_attr_data_inverse.attr, - &dev_attr_sync_inverse.attr, - &dev_attr_enable_inverse.attr, - NULL, -}; -static struct attribute_group dev_attr_grp = { - .attrs = dev_attrs, -}; -/* ===Device attributes end=== */ - -/* ===debugfs begin=== */ - -static int debugfs_iomem_x32_set(void *data, u64 val) -{ - iowrite32(val, data); - wmb(); - return 0; -} - -static int debugfs_iomem_x32_get(void *data, u64 *val) -{ - *val = ioread32(data); - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(fops_iomem_x32, debugfs_iomem_x32_get, - debugfs_iomem_x32_set, "0x%08llx\n"); - -struct dentry *debugfs_create_iomem_x32(const char *name, mode_t mode, - struct dentry *parent, u32 *value) -{ - return debugfs_create_file(name, mode, parent, value, &fops_iomem_x32); -} - -static int action_open(struct msm_tsif_device *tsif_device) -{ - int rc = -EINVAL; - int result; - - struct msm_tsif_platform_data *pdata = - tsif_device->pdev->dev.platform_data; - - dev_info(&tsif_device->pdev->dev, "%s\n", __func__); - if (tsif_device->state != tsif_state_stopped) - return -EAGAIN; - rc = tsif_dma_init(tsif_device); - if (rc) { - dev_err(&tsif_device->pdev->dev, "failed to init DMA\n"); - return rc; - } - tsif_device->state = tsif_state_running; - - /* - * DMA should be scheduled prior to TSIF hardware initialization, - * otherwise "bus error" will be reported by Data Mover - */ - enable_irq(tsif_device->irq); - tsif_clock(tsif_device, 1); - tsif_dma_schedule(tsif_device); - /* - * init the device if required - */ - if (pdata->init) - pdata->init(pdata); - rc = tsif_start_hw(tsif_device); - if (rc) { - dev_err(&tsif_device->pdev->dev, "Unable to start HW\n"); - tsif_dma_exit(tsif_device); - tsif_clock(tsif_device, 0); - disable_irq(tsif_device->irq); - return rc; - } - - /* make sure the GPIO's are set up */ - rc = tsif_start_gpios(tsif_device); - if (rc) { - dev_err(&tsif_device->pdev->dev, "failed to start GPIOs\n"); - tsif_stop_hw(tsif_device); - tsif_dma_exit(tsif_device); - tsif_clock(tsif_device, 0); - disable_irq(tsif_device->irq); - return rc; - } - - result = pm_runtime_get(&tsif_device->pdev->dev); - if (result < 0) { - dev_err(&tsif_device->pdev->dev, - "Runtime PM: Unable to wake up the device, rc = %d\n", - result); - tsif_stop_gpios(tsif_device); - tsif_stop_hw(tsif_device); - tsif_dma_exit(tsif_device); - tsif_clock(tsif_device, 0); - disable_irq(tsif_device->irq); - return result; - } - - wake_lock(&tsif_device->wake_lock); - return 0; -} - -static int action_close(struct msm_tsif_device *tsif_device) -{ - dev_info(&tsif_device->pdev->dev, "%s, state %d\n", __func__, - (int)tsif_device->state); - - /* turn off the GPIO's to prevent new data from entering */ - tsif_stop_gpios(tsif_device); - - /* we unfortunately must sleep here to give the ADM time to - * complete any outstanding reads after the GPIO's are turned - * off. There is no indication from the ADM hardware that - * there are any outstanding reads on the bus, and if we - * stop the TSIF too quickly, it can cause a bus error. - */ - msleep(250); - - /* now we can stop the core */ - tsif_stop_hw(tsif_device); - tsif_dma_exit(tsif_device); - tsif_clock(tsif_device, 0); - disable_irq(tsif_device->irq); - - pm_runtime_put(&tsif_device->pdev->dev); - wake_unlock(&tsif_device->wake_lock); - return 0; -} - - -static struct { - int (*func)(struct msm_tsif_device *); - const char *name; -} actions[] = { - { action_open, "open"}, - { action_close, "close"}, -}; - -static ssize_t tsif_debugfs_action_write(struct file *filp, - const char __user *userbuf, - size_t count, loff_t *f_pos) -{ - int i; - struct msm_tsif_device *tsif_device = filp->private_data; - char s[40]; - int len = min(sizeof(s) - 1, count); - if (copy_from_user(s, userbuf, len)) - return -EFAULT; - s[len] = '\0'; - dev_info(&tsif_device->pdev->dev, "%s:%s\n", __func__, s); - for (i = 0; i < ARRAY_SIZE(actions); i++) { - if (!strncmp(s, actions[i].name, - min(count, strlen(actions[i].name)))) { - int rc = actions[i].func(tsif_device); - if (!rc) - rc = count; - return rc; - } - } - return -EINVAL; -} - -static int tsif_debugfs_generic_open(struct inode *inode, struct file *filp) -{ - filp->private_data = inode->i_private; - return 0; -} - -static const struct file_operations fops_debugfs_action = { - .open = tsif_debugfs_generic_open, - .write = tsif_debugfs_action_write, -}; - -static ssize_t tsif_debugfs_dma_read(struct file *filp, char __user *userbuf, - size_t count, loff_t *f_pos) -{ - static char bufa[200]; - static char *buf = bufa; - int sz = sizeof(bufa); - struct msm_tsif_device *tsif_device = filp->private_data; - int len = 0; - if (tsif_device) { - int i; - len += snprintf(buf + len, sz - len, - "ri %3d | wi %3d | dmwi %3d |", - tsif_device->ri, tsif_device->wi, - tsif_device->dmwi); - for (i = 0; i < 2; i++) { - struct tsif_xfer *xfer = &tsif_device->xfer[i]; - if (xfer->busy) { - u32 dst = - tsif_device->dmov_cmd[i]->box.dst_row_addr; - u32 base = tsif_device->data_buffer_dma; - int w = (dst - base) / TSIF_PKT_SIZE; - len += snprintf(buf + len, sz - len, - " [%3d]{%3d}", - w, xfer->wi); - } else { - len += snprintf(buf + len, sz - len, - " ---idle---"); - } - } - len += snprintf(buf + len, sz - len, "\n"); - } else { - len += snprintf(buf + len, sz - len, "No TSIF device???\n"); - } - return simple_read_from_buffer(userbuf, count, f_pos, buf, len); -} - -static const struct file_operations fops_debugfs_dma = { - .open = tsif_debugfs_generic_open, - .read = tsif_debugfs_dma_read, -}; - -static ssize_t tsif_debugfs_gpios_read(struct file *filp, char __user *userbuf, - size_t count, loff_t *f_pos) -{ - static char bufa[300]; - static char *buf = bufa; - int sz = sizeof(bufa); - struct msm_tsif_device *tsif_device = filp->private_data; - int len = 0; - if (tsif_device) { - struct msm_tsif_platform_data *pdata = - tsif_device->pdev->dev.platform_data; - int i; - for (i = 0; i < pdata->num_gpios; i++) { - if (pdata->gpios[i].gpio_cfg) { - int x = !!gpio_get_value(GPIO_PIN( - pdata->gpios[i].gpio_cfg)); - len += snprintf(buf + len, sz - len, - "%15s: %d\n", - pdata->gpios[i].label, x); - } - } - } else { - len += snprintf(buf + len, sz - len, "No TSIF device???\n"); - } - return simple_read_from_buffer(userbuf, count, f_pos, buf, len); -} - -static const struct file_operations fops_debugfs_gpios = { - .open = tsif_debugfs_generic_open, - .read = tsif_debugfs_gpios_read, -}; - - -static void tsif_debugfs_init(struct msm_tsif_device *tsif_device) -{ - tsif_device->dent_tsif = debugfs_create_dir( - dev_name(&tsif_device->pdev->dev), NULL); - if (tsif_device->dent_tsif) { - int i; - void __iomem *base = tsif_device->base; - for (i = 0; i < ARRAY_SIZE(debugfs_tsif_regs); i++) { - tsif_device->debugfs_tsif_regs[i] = - debugfs_create_iomem_x32( - debugfs_tsif_regs[i].name, - debugfs_tsif_regs[i].mode, - tsif_device->dent_tsif, - base + debugfs_tsif_regs[i].offset); - } - tsif_device->debugfs_gpio = debugfs_create_file("gpios", - S_IRUGO, - tsif_device->dent_tsif, tsif_device, &fops_debugfs_gpios); - tsif_device->debugfs_action = debugfs_create_file("action", - S_IWUSR, - tsif_device->dent_tsif, tsif_device, &fops_debugfs_action); - tsif_device->debugfs_dma = debugfs_create_file("dma", - S_IRUGO, - tsif_device->dent_tsif, tsif_device, &fops_debugfs_dma); - tsif_device->debugfs_databuf = debugfs_create_blob("data_buf", - S_IRUGO, - tsif_device->dent_tsif, &tsif_device->blob_wrapper_databuf); - } -} - -static void tsif_debugfs_exit(struct msm_tsif_device *tsif_device) -{ - if (tsif_device->dent_tsif) { - int i; - debugfs_remove_recursive(tsif_device->dent_tsif); - tsif_device->dent_tsif = NULL; - for (i = 0; i < ARRAY_SIZE(debugfs_tsif_regs); i++) - tsif_device->debugfs_tsif_regs[i] = NULL; - tsif_device->debugfs_gpio = NULL; - tsif_device->debugfs_action = NULL; - tsif_device->debugfs_dma = NULL; - tsif_device->debugfs_databuf = NULL; - } -} -/* ===debugfs end=== */ - -/* ===module begin=== */ -static LIST_HEAD(tsif_devices); - -static struct msm_tsif_device *tsif_find_by_id(int id) -{ - struct msm_tsif_device *tsif_device; - list_for_each_entry(tsif_device, &tsif_devices, devlist) { - if (tsif_device->pdev->id == id) - return tsif_device; - } - return NULL; -} - -static int msm_tsif_probe(struct platform_device *pdev) -{ - int rc = -ENODEV; - struct msm_tsif_platform_data *plat = pdev->dev.platform_data; - struct msm_tsif_device *tsif_device; - struct resource *res; - /* check device validity */ - /* must have platform data */ - if (!plat) { - dev_err(&pdev->dev, "Platform data not available\n"); - rc = -EINVAL; - goto out; - } - - if ((pdev->id < 0) || (pdev->id > TSIF_MAX_ID)) { - dev_err(&pdev->dev, "Invalid device ID %d\n", pdev->id); - rc = -EINVAL; - goto out; - } - /* OK, we will use this device */ - tsif_device = kzalloc(sizeof(struct msm_tsif_device), GFP_KERNEL); - if (!tsif_device) { - dev_err(&pdev->dev, "Failed to allocate memory for device\n"); - rc = -ENOMEM; - goto out; - } - /* cross links */ - tsif_device->pdev = pdev; - platform_set_drvdata(pdev, tsif_device); - tsif_device->mode = 1; - tsif_device->clock_inverse = 0; - tsif_device->data_inverse = 0; - tsif_device->sync_inverse = 0; - tsif_device->enable_inverse = 0; - tsif_device->pkts_per_chunk = TSIF_PKTS_IN_CHUNK_DEFAULT; - tsif_device->chunks_per_buf = TSIF_CHUNKS_IN_BUF_DEFAULT; - tasklet_init(&tsif_device->dma_refill, tsif_dma_refill, - (unsigned long)tsif_device); - tasklet_init(&tsif_device->clocks_off, tsif_clocks_off, - (unsigned long)tsif_device); - rc = tsif_get_clocks(tsif_device); - if (rc) - goto err_clocks; -/* map I/O memory */ - tsif_device->memres = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!tsif_device->memres) { - dev_err(&pdev->dev, "Missing MEM resource\n"); - rc = -ENXIO; - goto err_rgn; - } - res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!res) { - dev_err(&pdev->dev, "Missing DMA resource\n"); - rc = -ENXIO; - goto err_rgn; - } - tsif_device->dma = res->start; - tsif_device->crci = res->end; - tsif_device->base = ioremap(tsif_device->memres->start, - resource_size(tsif_device->memres)); - if (!tsif_device->base) { - dev_err(&pdev->dev, "ioremap failed\n"); - goto err_ioremap; - } - dev_info(&pdev->dev, "remapped phys 0x%08x => virt %p\n", - tsif_device->memres->start, tsif_device->base); - - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - - tsif_debugfs_init(tsif_device); - rc = platform_get_irq(pdev, 0); - if (rc > 0) { - tsif_device->irq = rc; - rc = request_irq(tsif_device->irq, tsif_irq, IRQF_SHARED, - dev_name(&pdev->dev), tsif_device); - disable_irq(tsif_device->irq); - } - if (rc) { - dev_err(&pdev->dev, "failed to request IRQ %d : %d\n", - tsif_device->irq, rc); - goto err_irq; - } - rc = sysfs_create_group(&pdev->dev.kobj, &dev_attr_grp); - if (rc) { - dev_err(&pdev->dev, "failed to create dev. attrs : %d\n", rc); - goto err_attrs; - } - wake_lock_init(&tsif_device->wake_lock, WAKE_LOCK_SUSPEND, - dev_name(&pdev->dev)); - dev_info(&pdev->dev, "Configured irq %d memory 0x%08x DMA %d CRCI %d\n", - tsif_device->irq, tsif_device->memres->start, - tsif_device->dma, tsif_device->crci); - list_add(&tsif_device->devlist, &tsif_devices); - return 0; -/* error path */ - sysfs_remove_group(&pdev->dev.kobj, &dev_attr_grp); -err_attrs: - free_irq(tsif_device->irq, tsif_device); -err_irq: - tsif_debugfs_exit(tsif_device); - iounmap(tsif_device->base); -err_ioremap: -err_rgn: - tsif_put_clocks(tsif_device); -err_clocks: - kfree(tsif_device); -out: - return rc; -} - -static int msm_tsif_remove(struct platform_device *pdev) -{ - struct msm_tsif_device *tsif_device = platform_get_drvdata(pdev); - dev_info(&pdev->dev, "Unload\n"); - list_del(&tsif_device->devlist); - wake_lock_destroy(&tsif_device->wake_lock); - sysfs_remove_group(&pdev->dev.kobj, &dev_attr_grp); - free_irq(tsif_device->irq, tsif_device); - tsif_debugfs_exit(tsif_device); - tsif_dma_exit(tsif_device); - tsif_stop_gpios(tsif_device); - iounmap(tsif_device->base); - tsif_put_clocks(tsif_device); - - pm_runtime_put(&pdev->dev); - pm_runtime_disable(&pdev->dev); - kfree(tsif_device); - return 0; -} - -static int tsif_runtime_suspend(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: suspending...\n"); - return 0; -} - -static int tsif_runtime_resume(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: resuming...\n"); - return 0; -} - -static const struct dev_pm_ops tsif_dev_pm_ops = { - .runtime_suspend = tsif_runtime_suspend, - .runtime_resume = tsif_runtime_resume, -}; - - -static struct platform_driver msm_tsif_driver = { - .probe = msm_tsif_probe, - .remove = __exit_p(msm_tsif_remove), - .driver = { - .name = "msm_tsif", - .pm = &tsif_dev_pm_ops, - }, -}; - -static int __init mod_init(void) -{ - int rc = platform_driver_register(&msm_tsif_driver); - if (rc) - pr_err("TSIF: platform_driver_register failed: %d\n", rc); - return rc; -} - -static void __exit mod_exit(void) -{ - platform_driver_unregister(&msm_tsif_driver); -} -/* ===module end=== */ - -/* public API */ - -int tsif_get_active(void) -{ - struct msm_tsif_device *tsif_device; - list_for_each_entry(tsif_device, &tsif_devices, devlist) { - return tsif_device->pdev->id; - } - return -ENODEV; -} -EXPORT_SYMBOL(tsif_get_active); - -void *tsif_attach(int id, void (*notify)(void *client_data), void *data) -{ - struct msm_tsif_device *tsif_device = tsif_find_by_id(id); - if (!tsif_device) - return ERR_PTR(-ENODEV); - if (tsif_device->client_notify || tsif_device->client_data) - return ERR_PTR(-EBUSY); - tsif_device->client_notify = notify; - tsif_device->client_data = data; - /* prevent from unloading */ - get_device(&tsif_device->pdev->dev); - return tsif_device; -} -EXPORT_SYMBOL(tsif_attach); - -void tsif_detach(void *cookie) -{ - struct msm_tsif_device *tsif_device = cookie; - tsif_device->client_notify = NULL; - tsif_device->client_data = NULL; - put_device(&tsif_device->pdev->dev); -} -EXPORT_SYMBOL(tsif_detach); - -void tsif_get_info(void *cookie, void **pdata, int *psize) -{ - struct msm_tsif_device *tsif_device = cookie; - if (pdata) - *pdata = tsif_device->data_buffer; - if (psize) - *psize = TSIF_PKTS_IN_BUF; -} -EXPORT_SYMBOL(tsif_get_info); - -int tsif_set_mode(void *cookie, int mode) -{ - struct msm_tsif_device *tsif_device = cookie; - if (tsif_device->state != tsif_state_stopped) { - dev_err(&tsif_device->pdev->dev, - "Can't change mode while device is active\n"); - return -EBUSY; - } - switch (mode) { - case 1: - case 2: - case 3: - tsif_device->mode = mode; - break; - default: - dev_err(&tsif_device->pdev->dev, "Invalid mode: %d\n", mode); - return -EINVAL; - } - return 0; -} -EXPORT_SYMBOL(tsif_set_mode); - -int tsif_set_time_limit(void *cookie, u32 value) -{ - struct msm_tsif_device *tsif_device = cookie; - if (tsif_device->state != tsif_state_stopped) { - dev_err(&tsif_device->pdev->dev, - "Can't change time limit while device is active\n"); - return -EBUSY; - } - if (value != (value & 0xFFFFFF)) { - dev_err(&tsif_device->pdev->dev, - "Invalid time limit (should be 24 bit): %#x\n", value); - return -EINVAL; - } - tsif_device->time_limit = value; - return 0; -} -EXPORT_SYMBOL(tsif_set_time_limit); - -int tsif_set_buf_config(void *cookie, u32 pkts_in_chunk, u32 chunks_in_buf) -{ - struct msm_tsif_device *tsif_device = cookie; - if (tsif_device->data_buffer) { - dev_err(&tsif_device->pdev->dev, - "Data buffer already allocated: %p\n", - tsif_device->data_buffer); - return -EBUSY; - } - /* check for crazy user */ - if (pkts_in_chunk * chunks_in_buf > 10240) { - dev_err(&tsif_device->pdev->dev, - "Buffer requested is too large: %d * %d\n", - pkts_in_chunk, - chunks_in_buf); - return -EINVAL; - } - /* parameters are OK, execute */ - tsif_device->pkts_per_chunk = pkts_in_chunk; - tsif_device->chunks_per_buf = chunks_in_buf; - return 0; -} -EXPORT_SYMBOL(tsif_set_buf_config); - -int tsif_set_clk_inverse(void *cookie, int value) -{ - struct msm_tsif_device *tsif_device = cookie; - if (tsif_device->state != tsif_state_stopped) { - dev_err(&tsif_device->pdev->dev, - "Can't change clock inverse while device is active\n"); - return -EBUSY; - } - if ((value != 0) && (value != 1)) { - dev_err(&tsif_device->pdev->dev, - "Invalid parameter, either 0 or 1: %#x\n", value); - return -EINVAL; - } - tsif_device->clock_inverse = value; - return 0; -} -EXPORT_SYMBOL(tsif_set_clk_inverse); - -int tsif_set_data_inverse(void *cookie, int value) -{ - struct msm_tsif_device *tsif_device = cookie; - if (tsif_device->state != tsif_state_stopped) { - dev_err(&tsif_device->pdev->dev, - "Can't change data inverse while device is active\n"); - return -EBUSY; - } - if ((value != 0) && (value != 1)) { - dev_err(&tsif_device->pdev->dev, - "Invalid parameter, either 0 or 1: %#x\n", value); - return -EINVAL; - } - tsif_device->data_inverse = value; - return 0; -} -EXPORT_SYMBOL(tsif_set_data_inverse); - -int tsif_set_sync_inverse(void *cookie, int value) -{ - struct msm_tsif_device *tsif_device = cookie; - if (tsif_device->state != tsif_state_stopped) { - dev_err(&tsif_device->pdev->dev, - "Can't change sync inverse while device is active\n"); - return -EBUSY; - } - if ((value != 0) && (value != 1)) { - dev_err(&tsif_device->pdev->dev, - "Invalid parameter, either 0 or 1: %#x\n", value); - return -EINVAL; - } - tsif_device->sync_inverse = value; - return 0; -} -EXPORT_SYMBOL(tsif_set_sync_inverse); - -int tsif_set_enable_inverse(void *cookie, int value) -{ - struct msm_tsif_device *tsif_device = cookie; - if (tsif_device->state != tsif_state_stopped) { - dev_err(&tsif_device->pdev->dev, - "Can't change enable inverse while device is active\n"); - return -EBUSY; - } - if ((value != 0) && (value != 1)) { - dev_err(&tsif_device->pdev->dev, - "Invalid parameter, either 0 or 1: %#x\n", value); - return -EINVAL; - } - tsif_device->enable_inverse = value; - return 0; -} -EXPORT_SYMBOL(tsif_set_enable_inverse); - -void tsif_get_state(void *cookie, int *ri, int *wi, enum tsif_state *state) -{ - struct msm_tsif_device *tsif_device = cookie; - if (ri) - *ri = tsif_device->ri; - if (wi) - *wi = tsif_device->wi; - if (state) - *state = tsif_device->state; -} -EXPORT_SYMBOL(tsif_get_state); - -int tsif_start(void *cookie) -{ - struct msm_tsif_device *tsif_device = cookie; - return action_open(tsif_device); -} -EXPORT_SYMBOL(tsif_start); - -void tsif_stop(void *cookie) -{ - struct msm_tsif_device *tsif_device = cookie; - action_close(tsif_device); -} -EXPORT_SYMBOL(tsif_stop); - -int tsif_get_ref_clk_counter(void *cookie, u32 *tcr_counter) -{ - struct msm_tsif_device *tsif_device = cookie; - - if (!tsif_device || !tcr_counter) - return -EINVAL; - - if (tsif_device->state == tsif_state_running) - *tcr_counter = ioread32(tsif_device->base + TSIF_CLK_REF_OFF); - else - *tcr_counter = 0; - - return 0; -} -EXPORT_SYMBOL(tsif_get_ref_clk_counter); - -void tsif_reclaim_packets(void *cookie, int read_index) -{ - struct msm_tsif_device *tsif_device = cookie; - tsif_device->ri = read_index; -} -EXPORT_SYMBOL(tsif_reclaim_packets); - -module_init(mod_init); -module_exit(mod_exit); - -MODULE_DESCRIPTION("TSIF (Transport Stream Interface)" - " Driver for the MSM chipset"); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/misc/tsif_chrdev.c b/drivers/misc/tsif_chrdev.c deleted file mode 100644 index a53bc9a2825c0b0b7c61307637848a96a09288d2..0000000000000000000000000000000000000000 --- a/drivers/misc/tsif_chrdev.c +++ /dev/null @@ -1,230 +0,0 @@ -/** - * TSIF driver client - * - * Character device that, being read - * returns stream of TSIF packets. - * - * Copyright (c) 2009-2011, 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 /* Needed by all modules */ -#include /* Needed for KERN_INFO */ -#include -#include /* IS_ERR etc. */ -#include -#include -#include /* TASK_INTERRUPTIBLE */ - -#include /* copy_to_user */ - -#include - -struct tsif_chrdev { - struct cdev cdev; - struct device *dev; - wait_queue_head_t wq_read; - void *cookie; - /* mirror for tsif data */ - void *data_buffer; - unsigned buf_size_packets; /**< buffer size in packets */ - unsigned ri, wi; - enum tsif_state state; - unsigned rptr; -}; - -static ssize_t tsif_open(struct inode *inode, struct file *file) -{ - int rc; - struct tsif_chrdev *the_dev = - container_of(inode->i_cdev, struct tsif_chrdev, cdev); - if (!the_dev->cookie) /* not bound yet */ - return -ENODEV; - file->private_data = the_dev; - rc = tsif_start(the_dev->cookie); - if (rc) - return rc; - tsif_get_info(the_dev->cookie, &the_dev->data_buffer, - &the_dev->buf_size_packets); - the_dev->rptr = 0; - return nonseekable_open(inode, file); -} - -static ssize_t tsif_release(struct inode *inode, struct file *filp) -{ - struct tsif_chrdev *the_dev = filp->private_data; - tsif_stop(the_dev->cookie); - return 0; -} - -static ssize_t tsif_read(struct file *filp, char __user *buf, size_t count, - loff_t *f_pos) -{ - int avail = 0; - int wi; - struct tsif_chrdev *the_dev = filp->private_data; - tsif_get_state(the_dev->cookie, &the_dev->ri, &the_dev->wi, - &the_dev->state); - /* consistency check */ - if (the_dev->ri != (the_dev->rptr / TSIF_PKT_SIZE)) { - dev_err(the_dev->dev, - "%s: inconsistent read pointers: ri %d rptr %d\n", - __func__, the_dev->ri, the_dev->rptr); - the_dev->rptr = the_dev->ri * TSIF_PKT_SIZE; - } - /* ri == wi if no data */ - if (the_dev->ri == the_dev->wi) { - /* shall I block waiting for data? */ - if (filp->f_flags & O_NONBLOCK) { - if (the_dev->state == tsif_state_running) { - return -EAGAIN; - } else { - /* not running -> EOF */ - return 0; - } - } - if (wait_event_interruptible(the_dev->wq_read, - (the_dev->ri != the_dev->wi) || - (the_dev->state != tsif_state_running))) { - /* got signal -> tell FS to handle it */ - return -ERESTARTSYS; - } - if (the_dev->ri == the_dev->wi) { - /* still no data -> EOF */ - return 0; - } - } - /* contiguous chunk last up to wi or end of buffer */ - wi = (the_dev->wi > the_dev->ri) ? - the_dev->wi : the_dev->buf_size_packets; - avail = min(wi * TSIF_PKT_SIZE - the_dev->rptr, count); - if (copy_to_user(buf, the_dev->data_buffer + the_dev->rptr, avail)) - return -EFAULT; - the_dev->rptr = (the_dev->rptr + avail) % - (TSIF_PKT_SIZE * the_dev->buf_size_packets); - the_dev->ri = the_dev->rptr / TSIF_PKT_SIZE; - *f_pos += avail; - tsif_reclaim_packets(the_dev->cookie, the_dev->ri); - return avail; -} - -static void tsif_notify(void *data) -{ - struct tsif_chrdev *the_dev = data; - tsif_get_state(the_dev->cookie, &the_dev->ri, &the_dev->wi, - &the_dev->state); - wake_up_interruptible(&the_dev->wq_read); -} - -static const struct file_operations tsif_fops = { - .owner = THIS_MODULE, - .read = tsif_read, - .open = tsif_open, - .release = tsif_release, -}; - -static struct class *tsif_class; -static dev_t tsif_dev; /**< 1-st dev_t from allocated range */ -static dev_t tsif_dev0; /**< next not yet assigned dev_t */ - -static int tsif_init_one(struct tsif_chrdev *the_dev, int index) -{ - int rc; - pr_info("%s[%d]\n", __func__, index); - cdev_init(&the_dev->cdev, &tsif_fops); - the_dev->cdev.owner = THIS_MODULE; - init_waitqueue_head(&the_dev->wq_read); - rc = cdev_add(&the_dev->cdev, tsif_dev0++, 1); - the_dev->dev = device_create(tsif_class, NULL, the_dev->cdev.dev, - the_dev, "tsif%d", index); - if (IS_ERR(the_dev->dev)) { - rc = PTR_ERR(the_dev->dev); - pr_err("device_create failed: %d\n", rc); - goto err_create; - } - the_dev->cookie = tsif_attach(index, tsif_notify, the_dev); - if (IS_ERR(the_dev->cookie)) { - rc = PTR_ERR(the_dev->cookie); - pr_err("tsif_attach failed: %d\n", rc); - goto err_attach; - } - /* now data buffer is not allocated yet */ - tsif_get_info(the_dev->cookie, &the_dev->data_buffer, NULL); - dev_info(the_dev->dev, - "Device %d.%d attached to TSIF, buffer size %d\n", - MAJOR(the_dev->cdev.dev), MINOR(the_dev->cdev.dev), - the_dev->buf_size_packets); - return 0; -err_attach: - device_destroy(tsif_class, the_dev->cdev.dev); -err_create: - cdev_del(&the_dev->cdev); - return rc; -} - -static void tsif_exit_one(struct tsif_chrdev *the_dev) -{ - dev_info(the_dev->dev, "%s\n", __func__); - tsif_detach(the_dev->cookie); - device_destroy(tsif_class, the_dev->cdev.dev); - cdev_del(&the_dev->cdev); -} - -#define TSIF_NUM_DEVS 1 /**< support this many devices */ - -struct tsif_chrdev the_devices[TSIF_NUM_DEVS]; - -static int __init mod_init(void) -{ - int rc; - int instance; - rc = alloc_chrdev_region(&tsif_dev, 0, TSIF_NUM_DEVS, "tsif"); - if (rc) { - pr_err("alloc_chrdev_region failed: %d\n", rc); - goto err_devrgn; - } - tsif_dev0 = tsif_dev; - tsif_class = class_create(THIS_MODULE, "tsif"); - if (IS_ERR(tsif_class)) { - rc = PTR_ERR(tsif_class); - pr_err("Error creating tsif class: %d\n", rc); - goto err_class; - } - instance = tsif_get_active(); - if (instance >= 0) - rc = tsif_init_one(&the_devices[0], instance); - else - rc = instance; - if (rc) - goto err_init1; - return 0; -err_init1: - class_destroy(tsif_class); -err_class: - unregister_chrdev_region(tsif_dev, TSIF_NUM_DEVS); -err_devrgn: - return rc; -} - -static void __exit mod_exit(void) -{ - tsif_exit_one(&the_devices[0]); - class_destroy(tsif_class); - unregister_chrdev_region(tsif_dev, TSIF_NUM_DEVS); -} - -module_init(mod_init); -module_exit(mod_exit); - -MODULE_DESCRIPTION("TSIF character device interface"); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 2c6151cb6a260e874c4869eb5bb6ce1615266ebe..88111f51e3ec3db0bf1decccac3b33e199690483 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -50,16 +50,6 @@ config MTD_MS02NV say M here and read . The module will be called ms02-nv. -config MTD_MSM_NAND - tristate "MSM NAND Device Support" - depends on MTD && ARCH_MSM - select CRC16 - select BITREVERSE - select MTD_NAND_IDS - default y - help - Support for some NAND chips connected to the MSM NAND controller. - config MTD_MSM_QPIC_NAND tristate "MSM QPIC NAND Device Support" depends on MTD && ARCH_MSM && !MTD_MSM_NAND diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile index bdef48e00494a9c6efd88e99b31b86a9e94fd6f6..82a1e6679aec1c4651d9267473cd5e114e14c368 100644 --- a/drivers/mtd/devices/Makefile +++ b/drivers/mtd/devices/Makefile @@ -7,7 +7,6 @@ obj-$(CONFIG_MTD_SLRAM) += slram.o obj-$(CONFIG_MTD_PHRAM) += phram.o obj-$(CONFIG_MTD_PMC551) += pmc551.o obj-$(CONFIG_MTD_MS02NV) += ms02-nv.o -obj-$(CONFIG_MTD_MSM_NAND) += msm_nand.o obj-$(CONFIG_MTD_MSM_QPIC_NAND) += msm_qpic_nand.o obj-$(CONFIG_MTD_MTDRAM) += mtdram.o obj-$(CONFIG_MTD_LART) += lart.o diff --git a/drivers/mtd/devices/msm_nand.c b/drivers/mtd/devices/msm_nand.c deleted file mode 100644 index 4f530a585fc3c54c2c79309a013c612090001c26..0000000000000000000000000000000000000000 --- a/drivers/mtd/devices/msm_nand.c +++ /dev/null @@ -1,7249 +0,0 @@ -/* - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "msm_nand.h" - -unsigned long msm_nand_phys; -unsigned long msm_nandc01_phys; -unsigned long msm_nandc10_phys; -unsigned long msm_nandc11_phys; -unsigned long ebi2_register_base; -uint32_t dual_nand_ctlr_present; -uint32_t interleave_enable; -uint32_t enable_bch_ecc; - -#define MSM_NAND_DMA_BUFFER_SIZE SZ_8K -#define MSM_NAND_DMA_BUFFER_SLOTS \ - (MSM_NAND_DMA_BUFFER_SIZE / (sizeof(((atomic_t *)0)->counter) * 8)) - -#define MSM_NAND_CFG0_RAW_ONFI_IDENTIFIER 0x88000800 -#define MSM_NAND_CFG0_RAW_ONFI_PARAM_INFO 0x88040000 -#define MSM_NAND_CFG1_RAW_ONFI_IDENTIFIER 0x0005045d -#define MSM_NAND_CFG1_RAW_ONFI_PARAM_INFO 0x0005045d - -#define ONFI_IDENTIFIER_LENGTH 0x0004 -#define ONFI_PARAM_INFO_LENGTH 0x0200 -#define ONFI_PARAM_PAGE_LENGTH 0x0100 - -#define ONFI_PARAMETER_PAGE_SIGNATURE 0x49464E4F - -#define FLASH_READ_ONFI_IDENTIFIER_COMMAND 0x90 -#define FLASH_READ_ONFI_IDENTIFIER_ADDRESS 0x20 -#define FLASH_READ_ONFI_PARAMETERS_COMMAND 0xEC -#define FLASH_READ_ONFI_PARAMETERS_ADDRESS 0x00 - -#define VERBOSE 0 - -struct msm_nand_chip { - struct device *dev; - wait_queue_head_t wait_queue; - atomic_t dma_buffer_busy; - unsigned dma_channel; - uint8_t *dma_buffer; - dma_addr_t dma_addr; - unsigned CFG0, CFG1, CFG0_RAW, CFG1_RAW; - uint32_t ecc_buf_cfg; - uint32_t ecc_bch_cfg; - uint32_t ecc_parity_bytes; - unsigned cw_size; - unsigned int uncorrectable_bit_mask; - unsigned int num_err_mask; -}; - -#define CFG1_WIDE_FLASH (1U << 1) - -/* TODO: move datamover code out */ - -#define SRC_CRCI_NAND_CMD CMD_SRC_CRCI(DMOV_NAND_CRCI_CMD) -#define DST_CRCI_NAND_CMD CMD_DST_CRCI(DMOV_NAND_CRCI_CMD) -#define SRC_CRCI_NAND_DATA CMD_SRC_CRCI(DMOV_NAND_CRCI_DATA) -#define DST_CRCI_NAND_DATA CMD_DST_CRCI(DMOV_NAND_CRCI_DATA) - -#define msm_virt_to_dma(chip, vaddr) \ - ((chip)->dma_addr + \ - ((uint8_t *)(vaddr) - (chip)->dma_buffer)) - -/** - * msm_nand_oob_64 - oob info for 2KB page - */ -static struct nand_ecclayout msm_nand_oob_64 = { - .eccbytes = 40, - .eccpos = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - }, - .oobavail = 16, - .oobfree = { - {30, 16}, - } -}; - -/** - * msm_nand_oob_128 - oob info for 4KB page - */ -static struct nand_ecclayout msm_nand_oob_128 = { - .eccbytes = 80, - .eccpos = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - }, - .oobavail = 32, - .oobfree = { - {70, 32}, - } -}; - -/** - * msm_nand_oob_224 - oob info for 4KB page 8Bit interface - */ -static struct nand_ecclayout msm_nand_oob_224_x8 = { - .eccbytes = 104, - .eccpos = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - }, - .oobavail = 32, - .oobfree = { - {91, 32}, - } -}; - -/** - * msm_nand_oob_224 - oob info for 4KB page 16Bit interface - */ -static struct nand_ecclayout msm_nand_oob_224_x16 = { - .eccbytes = 112, - .eccpos = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - }, - .oobavail = 32, - .oobfree = { - {98, 32}, - } -}; - -/** - * msm_nand_oob_256 - oob info for 8KB page - */ -static struct nand_ecclayout msm_nand_oob_256 = { - .eccbytes = 160, - .eccpos = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 96, 97, 98 , 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, - 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, - 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, - 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, - 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - }, - .oobavail = 64, - .oobfree = { - {151, 64}, - } -}; - -/** - * msm_onenand_oob_64 - oob info for large (2KB) page - */ -static struct nand_ecclayout msm_onenand_oob_64 = { - .eccbytes = 20, - .eccpos = { - 8, 9, 10, 11, 12, - 24, 25, 26, 27, 28, - 40, 41, 42, 43, 44, - 56, 57, 58, 59, 60, - }, - .oobavail = 20, - .oobfree = { - {2, 3}, {14, 2}, {18, 3}, {30, 2}, - {34, 3}, {46, 2}, {50, 3}, {62, 2} - } -}; - -static void *msm_nand_get_dma_buffer(struct msm_nand_chip *chip, size_t size) -{ - unsigned int bitmask, free_bitmask, old_bitmask; - unsigned int need_mask, current_need_mask; - int free_index; - - need_mask = (1UL << DIV_ROUND_UP(size, MSM_NAND_DMA_BUFFER_SLOTS)) - 1; - bitmask = atomic_read(&chip->dma_buffer_busy); - free_bitmask = ~bitmask; - do { - free_index = __ffs(free_bitmask); - current_need_mask = need_mask << free_index; - - if (size + free_index * MSM_NAND_DMA_BUFFER_SLOTS >= - MSM_NAND_DMA_BUFFER_SIZE) - return NULL; - - if ((bitmask & current_need_mask) == 0) { - old_bitmask = - atomic_cmpxchg(&chip->dma_buffer_busy, - bitmask, - bitmask | current_need_mask); - if (old_bitmask == bitmask) - return chip->dma_buffer + - free_index * MSM_NAND_DMA_BUFFER_SLOTS; - free_bitmask = 0; /* force return */ - } - /* current free range was too small, clear all free bits */ - /* below the top busy bit within current_need_mask */ - free_bitmask &= - ~(~0U >> (32 - fls(bitmask & current_need_mask))); - } while (free_bitmask); - - return NULL; -} - -static void msm_nand_release_dma_buffer(struct msm_nand_chip *chip, - void *buffer, size_t size) -{ - int index; - unsigned int used_mask; - - used_mask = (1UL << DIV_ROUND_UP(size, MSM_NAND_DMA_BUFFER_SLOTS)) - 1; - index = ((uint8_t *)buffer - chip->dma_buffer) / - MSM_NAND_DMA_BUFFER_SLOTS; - atomic_sub(used_mask << index, &chip->dma_buffer_busy); - - wake_up(&chip->wait_queue); -} - - -unsigned flash_rd_reg(struct msm_nand_chip *chip, unsigned addr) -{ - struct { - dmov_s cmd; - unsigned cmdptr; - unsigned data; - } *dma_buffer; - unsigned rv; - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer( - chip, sizeof(*dma_buffer)))); - - dma_buffer->cmd.cmd = CMD_LC | CMD_OCB | CMD_OCU; - dma_buffer->cmd.src = addr; - dma_buffer->cmd.dst = msm_virt_to_dma(chip, &dma_buffer->data); - dma_buffer->cmd.len = 4; - - dma_buffer->cmdptr = - (msm_virt_to_dma(chip, &dma_buffer->cmd) >> 3) | CMD_PTR_LP; - dma_buffer->data = 0xeeeeeeee; - - mb(); - msm_dmov_exec_cmd( - chip->dma_channel, DMOV_CMD_PTR_LIST | - DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - rv = dma_buffer->data; - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - return rv; -} - -void flash_wr_reg(struct msm_nand_chip *chip, unsigned addr, unsigned val) -{ - struct { - dmov_s cmd; - unsigned cmdptr; - unsigned data; - } *dma_buffer; - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer( - chip, sizeof(*dma_buffer)))); - - dma_buffer->cmd.cmd = CMD_LC | CMD_OCB | CMD_OCU; - dma_buffer->cmd.src = msm_virt_to_dma(chip, &dma_buffer->data); - dma_buffer->cmd.dst = addr; - dma_buffer->cmd.len = 4; - - dma_buffer->cmdptr = - (msm_virt_to_dma(chip, &dma_buffer->cmd) >> 3) | CMD_PTR_LP; - dma_buffer->data = val; - - mb(); - msm_dmov_exec_cmd( - chip->dma_channel, DMOV_CMD_PTR_LIST | - DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); -} - -static dma_addr_t -msm_nand_dma_map(struct device *dev, void *addr, size_t size, - enum dma_data_direction dir) -{ - struct page *page; - unsigned long offset = (unsigned long)addr & ~PAGE_MASK; - if (virt_addr_valid(addr)) - page = virt_to_page(addr); - else { - if (WARN_ON(size + offset > PAGE_SIZE)) - return ~0; - page = vmalloc_to_page(addr); - } - return dma_map_page(dev, page, offset, size, dir); -} - -uint32_t flash_read_id(struct msm_nand_chip *chip) -{ - struct { - dmov_s cmd[7]; - unsigned cmdptr; - unsigned data[7]; - } *dma_buffer; - uint32_t rv; - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - dma_buffer->data[0] = 0 | 4; - dma_buffer->data[1] = MSM_NAND_CMD_FETCH_ID; - dma_buffer->data[2] = 1; - dma_buffer->data[3] = 0xeeeeeeee; - dma_buffer->data[4] = 0xeeeeeeee; - dma_buffer->data[5] = flash_rd_reg(chip, MSM_NAND_SFLASHC_BURST_CFG); - dma_buffer->data[6] = 0x00000000; - BUILD_BUG_ON(6 != ARRAY_SIZE(dma_buffer->data) - 1); - - dma_buffer->cmd[0].cmd = 0 | CMD_OCB; - dma_buffer->cmd[0].src = msm_virt_to_dma(chip, &dma_buffer->data[6]); - dma_buffer->cmd[0].dst = MSM_NAND_SFLASHC_BURST_CFG; - dma_buffer->cmd[0].len = 4; - - dma_buffer->cmd[1].cmd = 0; - dma_buffer->cmd[1].src = msm_virt_to_dma(chip, &dma_buffer->data[0]); - dma_buffer->cmd[1].dst = MSM_NAND_FLASH_CHIP_SELECT; - dma_buffer->cmd[1].len = 4; - - dma_buffer->cmd[2].cmd = DST_CRCI_NAND_CMD; - dma_buffer->cmd[2].src = msm_virt_to_dma(chip, &dma_buffer->data[1]); - dma_buffer->cmd[2].dst = MSM_NAND_FLASH_CMD; - dma_buffer->cmd[2].len = 4; - - dma_buffer->cmd[3].cmd = 0; - dma_buffer->cmd[3].src = msm_virt_to_dma(chip, &dma_buffer->data[2]); - dma_buffer->cmd[3].dst = MSM_NAND_EXEC_CMD; - dma_buffer->cmd[3].len = 4; - - dma_buffer->cmd[4].cmd = SRC_CRCI_NAND_DATA; - dma_buffer->cmd[4].src = MSM_NAND_FLASH_STATUS; - dma_buffer->cmd[4].dst = msm_virt_to_dma(chip, &dma_buffer->data[3]); - dma_buffer->cmd[4].len = 4; - - dma_buffer->cmd[5].cmd = 0; - dma_buffer->cmd[5].src = MSM_NAND_READ_ID; - dma_buffer->cmd[5].dst = msm_virt_to_dma(chip, &dma_buffer->data[4]); - dma_buffer->cmd[5].len = 4; - - dma_buffer->cmd[6].cmd = CMD_OCU | CMD_LC; - dma_buffer->cmd[6].src = msm_virt_to_dma(chip, &dma_buffer->data[5]); - dma_buffer->cmd[6].dst = MSM_NAND_SFLASHC_BURST_CFG; - dma_buffer->cmd[6].len = 4; - - BUILD_BUG_ON(6 != ARRAY_SIZE(dma_buffer->cmd) - 1); - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3 - ) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, DMOV_CMD_PTR_LIST | - DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - pr_info("status: %x\n", dma_buffer->data[3]); - pr_info("nandid: %x maker %02x device %02x\n", - dma_buffer->data[4], dma_buffer->data[4] & 0xff, - (dma_buffer->data[4] >> 8) & 0xff); - rv = dma_buffer->data[4]; - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - return rv; -} - -struct flash_identification { - uint32_t flash_id; - uint32_t density; - uint32_t widebus; - uint32_t pagesize; - uint32_t blksize; - uint32_t oobsize; - uint32_t ecc_correctability; -} supported_flash; - -uint16_t flash_onfi_crc_check(uint8_t *buffer, uint16_t count) -{ - int i; - uint16_t result; - - for (i = 0; i < count; i++) - buffer[i] = bitrev8(buffer[i]); - - result = bitrev16(crc16(bitrev16(0x4f4e), buffer, count)); - - for (i = 0; i < count; i++) - buffer[i] = bitrev8(buffer[i]); - - return result; -} - - -uint32_t flash_onfi_probe(struct msm_nand_chip *chip) -{ - struct onfi_param_page { - uint32_t parameter_page_signature; - uint16_t revision_number; - uint16_t features_supported; - uint16_t optional_commands_supported; - uint8_t reserved0[22]; - uint8_t device_manufacturer[12]; - uint8_t device_model[20]; - uint8_t jedec_manufacturer_id; - uint16_t date_code; - uint8_t reserved1[13]; - uint32_t number_of_data_bytes_per_page; - uint16_t number_of_spare_bytes_per_page; - uint32_t number_of_data_bytes_per_partial_page; - uint16_t number_of_spare_bytes_per_partial_page; - uint32_t number_of_pages_per_block; - uint32_t number_of_blocks_per_logical_unit; - uint8_t number_of_logical_units; - uint8_t number_of_address_cycles; - uint8_t number_of_bits_per_cell; - uint16_t maximum_bad_blocks_per_logical_unit; - uint16_t block_endurance; - uint8_t guaranteed_valid_begin_blocks; - uint16_t guaranteed_valid_begin_blocks_endurance; - uint8_t number_of_programs_per_page; - uint8_t partial_program_attributes; - uint8_t number_of_bits_ecc_correctability; - uint8_t number_of_interleaved_address_bits; - uint8_t interleaved_operation_attributes; - uint8_t reserved2[13]; - uint8_t io_pin_capacitance; - uint16_t timing_mode_support; - uint16_t program_cache_timing_mode_support; - uint16_t maximum_page_programming_time; - uint16_t maximum_block_erase_time; - uint16_t maximum_page_read_time; - uint16_t maximum_change_column_setup_time; - uint8_t reserved3[23]; - uint16_t vendor_specific_revision_number; - uint8_t vendor_specific[88]; - uint16_t integrity_crc; - - } __attribute__((__packed__)); - - struct onfi_param_page *onfi_param_page_ptr; - uint8_t *onfi_identifier_buf = NULL; - uint8_t *onfi_param_info_buf = NULL; - - struct { - dmov_s cmd[11]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t addr0; - uint32_t addr1; - uint32_t cfg0; - uint32_t cfg1; - uint32_t exec; - uint32_t flash_status; - uint32_t devcmd1_orig; - uint32_t devcmdvld_orig; - uint32_t devcmd1_mod; - uint32_t devcmdvld_mod; - uint32_t sflash_bcfg_orig; - uint32_t sflash_bcfg_mod; - } data; - } *dma_buffer; - dmov_s *cmd; - - unsigned page_address = 0; - int err = 0; - dma_addr_t dma_addr_param_info = 0; - dma_addr_t dma_addr_identifier = 0; - unsigned cmd_set_count = 2; - unsigned crc_chk_count = 0; - - if (msm_nand_data.nr_parts) { - page_address = ((msm_nand_data.parts[0]).offset << 6); - } else { - pr_err("flash_onfi_probe: " - "No partition info available\n"); - err = -EIO; - return err; - } - - wait_event(chip->wait_queue, (onfi_identifier_buf = - msm_nand_get_dma_buffer(chip, ONFI_IDENTIFIER_LENGTH))); - dma_addr_identifier = msm_virt_to_dma(chip, onfi_identifier_buf); - - wait_event(chip->wait_queue, (onfi_param_info_buf = - msm_nand_get_dma_buffer(chip, ONFI_PARAM_INFO_LENGTH))); - dma_addr_param_info = msm_virt_to_dma(chip, onfi_param_info_buf); - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - dma_buffer->data.sflash_bcfg_orig = flash_rd_reg - (chip, MSM_NAND_SFLASHC_BURST_CFG); - dma_buffer->data.devcmd1_orig = flash_rd_reg(chip, MSM_NAND_DEV_CMD1); - dma_buffer->data.devcmdvld_orig = flash_rd_reg(chip, - MSM_NAND_DEV_CMD_VLD); - - while (cmd_set_count-- > 0) { - cmd = dma_buffer->cmd; - - dma_buffer->data.devcmd1_mod = (dma_buffer->data.devcmd1_orig & - 0xFFFFFF00) | (cmd_set_count - ? FLASH_READ_ONFI_IDENTIFIER_COMMAND - : FLASH_READ_ONFI_PARAMETERS_COMMAND); - dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; - dma_buffer->data.addr0 = (page_address << 16) | (cmd_set_count - ? FLASH_READ_ONFI_IDENTIFIER_ADDRESS - : FLASH_READ_ONFI_PARAMETERS_ADDRESS); - dma_buffer->data.addr1 = (page_address >> 16) & 0xFF; - dma_buffer->data.cfg0 = (cmd_set_count - ? MSM_NAND_CFG0_RAW_ONFI_IDENTIFIER - : MSM_NAND_CFG0_RAW_ONFI_PARAM_INFO); - dma_buffer->data.cfg1 = (cmd_set_count - ? MSM_NAND_CFG1_RAW_ONFI_IDENTIFIER - : MSM_NAND_CFG1_RAW_ONFI_PARAM_INFO); - dma_buffer->data.sflash_bcfg_mod = 0x00000000; - dma_buffer->data.devcmdvld_mod = (dma_buffer-> - data.devcmdvld_orig & 0xFFFFFFFE); - dma_buffer->data.exec = 1; - dma_buffer->data.flash_status = 0xeeeeeeee; - - /* Put the Nand ctlr in Async mode and disable SFlash ctlr */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sflash_bcfg_mod); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - /* Block on cmd ready, & write CMD,ADDR0,ADDR1,CHIPSEL regs */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = MSM_NAND_FLASH_CMD; - cmd->len = 12; - cmd++; - - /* Configure the CFG0 and CFG1 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = MSM_NAND_DEV0_CFG0; - cmd->len = 8; - cmd++; - - /* Configure the DEV_CMD_VLD register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.devcmdvld_mod); - cmd->dst = MSM_NAND_DEV_CMD_VLD; - cmd->len = 4; - cmd++; - - /* Configure the DEV_CMD1 register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.devcmd1_mod); - cmd->dst = MSM_NAND_DEV_CMD1; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.exec); - cmd->dst = MSM_NAND_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the two status registers */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_FLASH_STATUS; - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.flash_status); - cmd->len = 4; - cmd++; - - /* Read data block - valid only if status says success */ - cmd->cmd = 0; - cmd->src = MSM_NAND_FLASH_BUFFER; - cmd->dst = (cmd_set_count ? dma_addr_identifier : - dma_addr_param_info); - cmd->len = (cmd_set_count ? ONFI_IDENTIFIER_LENGTH : - ONFI_PARAM_INFO_LENGTH); - cmd++; - - /* Restore the DEV_CMD1 register */ - cmd->cmd = 0 ; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.devcmd1_orig); - cmd->dst = MSM_NAND_DEV_CMD1; - cmd->len = 4; - cmd++; - - /* Restore the DEV_CMD_VLD register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.devcmdvld_orig); - cmd->dst = MSM_NAND_DEV_CMD_VLD; - cmd->len = 4; - cmd++; - - /* Restore the SFLASH_BURST_CONFIG register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sflash_bcfg_orig); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - BUILD_BUG_ON(11 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) - >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - /* Check for errors, protection violations etc */ - if (dma_buffer->data.flash_status & 0x110) { - pr_info("MPU/OP error (0x%x) during " - "ONFI probe\n", - dma_buffer->data.flash_status); - err = -EIO; - break; - } - - if (cmd_set_count) { - onfi_param_page_ptr = (struct onfi_param_page *) - (&(onfi_identifier_buf[0])); - if (onfi_param_page_ptr->parameter_page_signature != - ONFI_PARAMETER_PAGE_SIGNATURE) { - pr_info("ONFI probe : Found a non" - "ONFI Compliant device \n"); - err = -EIO; - break; - } - } else { - for (crc_chk_count = 0; crc_chk_count < - ONFI_PARAM_INFO_LENGTH - / ONFI_PARAM_PAGE_LENGTH; - crc_chk_count++) { - onfi_param_page_ptr = - (struct onfi_param_page *) - (&(onfi_param_info_buf - [ONFI_PARAM_PAGE_LENGTH * - crc_chk_count])); - if (flash_onfi_crc_check( - (uint8_t *)onfi_param_page_ptr, - ONFI_PARAM_PAGE_LENGTH - 2) == - onfi_param_page_ptr->integrity_crc) { - break; - } - } - if (crc_chk_count >= ONFI_PARAM_INFO_LENGTH - / ONFI_PARAM_PAGE_LENGTH) { - pr_info("ONFI probe : CRC Check " - "failed on ONFI Parameter " - "data \n"); - err = -EIO; - break; - } else { - supported_flash.flash_id = - flash_read_id(chip); - supported_flash.widebus = - onfi_param_page_ptr-> - features_supported & 0x01; - supported_flash.pagesize = - onfi_param_page_ptr-> - number_of_data_bytes_per_page; - supported_flash.blksize = - onfi_param_page_ptr-> - number_of_pages_per_block * - supported_flash.pagesize; - supported_flash.oobsize = - onfi_param_page_ptr-> - number_of_spare_bytes_per_page; - supported_flash.density = - onfi_param_page_ptr-> - number_of_blocks_per_logical_unit - * supported_flash.blksize; - supported_flash.ecc_correctability = - onfi_param_page_ptr-> - number_of_bits_ecc_correctability; - - pr_info("ONFI probe : Found an ONFI " - "compliant device %s\n", - onfi_param_page_ptr->device_model); - - /* Temporary hack for MT29F4G08ABC device. - * Since the device is not properly adhering - * to ONFi specification it is reporting - * as 16 bit device though it is 8 bit device!!! - */ - if (!strncmp(onfi_param_page_ptr->device_model, - "MT29F4G08ABC", 12)) - supported_flash.widebus = 0; - } - } - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - msm_nand_release_dma_buffer(chip, onfi_param_info_buf, - ONFI_PARAM_INFO_LENGTH); - msm_nand_release_dma_buffer(chip, onfi_identifier_buf, - ONFI_IDENTIFIER_LENGTH); - - return err; -} - -static int msm_nand_read_oob(struct mtd_info *mtd, loff_t from, - struct mtd_oob_ops *ops) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[8 * 5 + 2]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t addr0; - uint32_t addr1; - uint32_t chipsel; - uint32_t cfg0; - uint32_t cfg1; - uint32_t eccbchcfg; - uint32_t exec; - uint32_t ecccfg; - struct { - uint32_t flash_status; - uint32_t buffer_status; - } result[8]; - } data; - } *dma_buffer; - dmov_s *cmd; - unsigned n; - unsigned page = 0; - uint32_t oob_len; - uint32_t sectordatasize; - uint32_t sectoroobsize; - int err, pageerr, rawerr; - dma_addr_t data_dma_addr = 0; - dma_addr_t oob_dma_addr = 0; - dma_addr_t data_dma_addr_curr = 0; - dma_addr_t oob_dma_addr_curr = 0; - uint32_t oob_col = 0; - unsigned page_count; - unsigned pages_read = 0; - unsigned start_sector = 0; - uint32_t ecc_errors; - uint32_t total_ecc_errors = 0; - unsigned cwperpage; -#if VERBOSE - pr_info("=================================================" - "================\n"); - pr_info("%s:\nfrom 0x%llx mode %d\ndatbuf 0x%p datlen 0x%x" - "\noobbuf 0x%p ooblen 0x%x\n", - __func__, from, ops->mode, ops->datbuf, ops->len, - ops->oobbuf, ops->ooblen); -#endif - - if (mtd->writesize == 2048) - page = from >> 11; - - if (mtd->writesize == 4096) - page = from >> 12; - - oob_len = ops->ooblen; - cwperpage = (mtd->writesize >> 9); - - if (from & (mtd->writesize - 1)) { - pr_err("%s: unsupported from, 0x%llx\n", - __func__, from); - return -EINVAL; - } - if (ops->mode != MTD_OPS_RAW) { - if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { - /* when ops->datbuf is NULL, ops->len can be ooblen */ - pr_err("%s: unsupported ops->len, %d\n", - __func__, ops->len); - return -EINVAL; - } - } else { - if (ops->datbuf != NULL && - (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { - pr_err("%s: unsupported ops->len," - " %d for MTD_OPS_RAW\n", __func__, ops->len); - return -EINVAL; - } - } - - if (ops->mode != MTD_OPS_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { - pr_err("%s: unsupported ops->ooboffs, %d\n", - __func__, ops->ooboffs); - return -EINVAL; - } - - if (ops->oobbuf && !ops->datbuf && ops->mode == MTD_OPS_AUTO_OOB) - start_sector = cwperpage - 1; - - if (ops->oobbuf && !ops->datbuf) { - page_count = ops->ooblen / ((ops->mode == MTD_OPS_AUTO_OOB) ? - mtd->oobavail : mtd->oobsize); - if ((page_count == 0) && (ops->ooblen)) - page_count = 1; - } else if (ops->mode != MTD_OPS_RAW) - page_count = ops->len / mtd->writesize; - else - page_count = ops->len / (mtd->writesize + mtd->oobsize); - - if (ops->datbuf) { - data_dma_addr_curr = data_dma_addr = - msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, - DMA_FROM_DEVICE); - if (dma_mapping_error(chip->dev, data_dma_addr)) { - pr_err("msm_nand_read_oob: failed to get dma addr " - "for %p\n", ops->datbuf); - return -EIO; - } - } - if (ops->oobbuf) { - memset(ops->oobbuf, 0xff, ops->ooblen); - oob_dma_addr_curr = oob_dma_addr = - msm_nand_dma_map(chip->dev, ops->oobbuf, - ops->ooblen, DMA_BIDIRECTIONAL); - if (dma_mapping_error(chip->dev, oob_dma_addr)) { - pr_err("msm_nand_read_oob: failed to get dma addr " - "for %p\n", ops->oobbuf); - err = -EIO; - goto err_dma_map_oobbuf_failed; - } - } - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer( - chip, sizeof(*dma_buffer)))); - - oob_col = start_sector * chip->cw_size; - if (chip->CFG1 & CFG1_WIDE_FLASH) - oob_col >>= 1; - - err = 0; - while (page_count-- > 0) { - cmd = dma_buffer->cmd; - - /* CMD / ADDR0 / ADDR1 / CHIPSEL program values */ - if (ops->mode != MTD_OPS_RAW) { - dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ_ECC; - dma_buffer->data.cfg0 = - (chip->CFG0 & ~(7U << 6)) - | (((cwperpage-1) - start_sector) << 6); - dma_buffer->data.cfg1 = chip->CFG1; - if (enable_bch_ecc) - dma_buffer->data.eccbchcfg = chip->ecc_bch_cfg; - } else { - dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; - dma_buffer->data.cfg0 = (chip->CFG0_RAW - & ~(7U << 6)) | ((cwperpage-1) << 6); - dma_buffer->data.cfg1 = chip->CFG1_RAW | - (chip->CFG1 & CFG1_WIDE_FLASH); - } - - dma_buffer->data.addr0 = (page << 16) | oob_col; - dma_buffer->data.addr1 = (page >> 16) & 0xff; - /* chipsel_0 + enable DM interface */ - dma_buffer->data.chipsel = 0 | 4; - - - /* GO bit for the EXEC register */ - dma_buffer->data.exec = 1; - - - BUILD_BUG_ON(8 != ARRAY_SIZE(dma_buffer->data.result)); - - for (n = start_sector; n < cwperpage; n++) { - /* flash + buffer status return words */ - dma_buffer->data.result[n].flash_status = 0xeeeeeeee; - dma_buffer->data.result[n].buffer_status = 0xeeeeeeee; - - /* block on cmd ready, then - * write CMD / ADDR0 / ADDR1 / CHIPSEL - * regs in a burst - */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = MSM_NAND_FLASH_CMD; - if (n == start_sector) - cmd->len = 16; - else - cmd->len = 4; - cmd++; - - if (n == start_sector) { - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = MSM_NAND_DEV0_CFG0; - if (enable_bch_ecc) - cmd->len = 12; - else - cmd->len = 8; - cmd++; - - dma_buffer->data.ecccfg = chip->ecc_buf_cfg; - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.ecccfg); - cmd->dst = MSM_NAND_EBI2_ECC_BUF_CFG; - cmd->len = 4; - cmd++; - } - - /* kick the execute register */ - cmd->cmd = 0; - cmd->src = - msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = MSM_NAND_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* block on data ready, then - * read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_FLASH_STATUS; - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.result[n]); - /* MSM_NAND_FLASH_STATUS + MSM_NAND_BUFFER_STATUS */ - cmd->len = 8; - cmd++; - - /* read data block - * (only valid if status says success) - */ - if (ops->datbuf) { - if (ops->mode != MTD_OPS_RAW) - sectordatasize = (n < (cwperpage - 1)) - ? 516 : (512 - ((cwperpage - 1) << 2)); - else - sectordatasize = chip->cw_size; - - cmd->cmd = 0; - cmd->src = MSM_NAND_FLASH_BUFFER; - cmd->dst = data_dma_addr_curr; - data_dma_addr_curr += sectordatasize; - cmd->len = sectordatasize; - cmd++; - } - - if (ops->oobbuf && (n == (cwperpage - 1) - || ops->mode != MTD_OPS_AUTO_OOB)) { - cmd->cmd = 0; - if (n == (cwperpage - 1)) { - cmd->src = MSM_NAND_FLASH_BUFFER + - (512 - ((cwperpage - 1) << 2)); - sectoroobsize = (cwperpage << 2); - if (ops->mode != MTD_OPS_AUTO_OOB) - sectoroobsize += - chip->ecc_parity_bytes; - } else { - cmd->src = MSM_NAND_FLASH_BUFFER + 516; - sectoroobsize = chip->ecc_parity_bytes; - } - - cmd->dst = oob_dma_addr_curr; - if (sectoroobsize < oob_len) - cmd->len = sectoroobsize; - else - cmd->len = oob_len; - oob_dma_addr_curr += cmd->len; - oob_len -= cmd->len; - if (cmd->len > 0) - cmd++; - } - } - - BUILD_BUG_ON(8 * 5 + 2 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = - (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) - | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - /* if any of the writes failed (0x10), or there - * was a protection violation (0x100), we lose - */ - pageerr = rawerr = 0; - for (n = start_sector; n < cwperpage; n++) { - if (dma_buffer->data.result[n].flash_status & 0x110) { - rawerr = -EIO; - break; - } - } - if (rawerr) { - if (ops->datbuf && ops->mode != MTD_OPS_RAW) { - uint8_t *datbuf = ops->datbuf + - pages_read * mtd->writesize; - - dma_sync_single_for_cpu(chip->dev, - data_dma_addr_curr-mtd->writesize, - mtd->writesize, DMA_BIDIRECTIONAL); - - for (n = 0; n < mtd->writesize; n++) { - /* empty blocks read 0x54 at - * these offsets - */ - if ((n % 516 == 3 || n % 516 == 175) - && datbuf[n] == 0x54) - datbuf[n] = 0xff; - if (datbuf[n] != 0xff) { - pageerr = rawerr; - break; - } - } - - dma_sync_single_for_device(chip->dev, - data_dma_addr_curr-mtd->writesize, - mtd->writesize, DMA_BIDIRECTIONAL); - - } - if (ops->oobbuf) { - dma_sync_single_for_cpu(chip->dev, - oob_dma_addr_curr - (ops->ooblen - oob_len), - ops->ooblen - oob_len, DMA_BIDIRECTIONAL); - - for (n = 0; n < ops->ooblen; n++) { - if (ops->oobbuf[n] != 0xff) { - pageerr = rawerr; - break; - } - } - - dma_sync_single_for_device(chip->dev, - oob_dma_addr_curr - (ops->ooblen - oob_len), - ops->ooblen - oob_len, DMA_BIDIRECTIONAL); - } - } - if (pageerr) { - for (n = start_sector; n < cwperpage; n++) { - if (dma_buffer->data.result[n].buffer_status & - chip->uncorrectable_bit_mask) { - /* not thread safe */ - mtd->ecc_stats.failed++; - pageerr = -EBADMSG; - break; - } - } - } - if (!rawerr) { /* check for corretable errors */ - for (n = start_sector; n < cwperpage; n++) { - ecc_errors = - (dma_buffer->data.result[n].buffer_status - & chip->num_err_mask); - if (ecc_errors) { - total_ecc_errors += ecc_errors; - /* not thread safe */ - mtd->ecc_stats.corrected += ecc_errors; - if (ecc_errors > 1) - pageerr = -EUCLEAN; - } - } - } - if (pageerr && (pageerr != -EUCLEAN || err == 0)) - err = pageerr; - -#if VERBOSE - if (rawerr && !pageerr) { - pr_err("msm_nand_read_oob %llx %x %x empty page\n", - (loff_t)page * mtd->writesize, ops->len, - ops->ooblen); - } else { - for (n = start_sector; n < cwperpage; n++) - pr_info("flash_status[%d] = %x,\ - buffr_status[%d] = %x\n", - n, dma_buffer->data.result[n].flash_status, - n, dma_buffer->data.result[n].buffer_status); - } -#endif - if (err && err != -EUCLEAN && err != -EBADMSG) - break; - pages_read++; - page++; - } - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - if (ops->oobbuf) { - dma_unmap_page(chip->dev, oob_dma_addr, - ops->ooblen, DMA_FROM_DEVICE); - } -err_dma_map_oobbuf_failed: - if (ops->datbuf) { - dma_unmap_page(chip->dev, data_dma_addr, - ops->len, DMA_BIDIRECTIONAL); - } - - if (ops->mode != MTD_OPS_RAW) - ops->retlen = mtd->writesize * pages_read; - else - ops->retlen = (mtd->writesize + mtd->oobsize) * - pages_read; - ops->oobretlen = ops->ooblen - oob_len; - if (err) - pr_err("msm_nand_read_oob %llx %x %x failed %d, corrected %d\n", - from, ops->datbuf ? ops->len : 0, ops->ooblen, err, - total_ecc_errors); -#if VERBOSE - pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", - __func__, err, ops->retlen, ops->oobretlen); - - pr_info("===================================================" - "==============\n"); -#endif - return err; -} - -static int msm_nand_read_oob_dualnandc(struct mtd_info *mtd, loff_t from, - struct mtd_oob_ops *ops) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[16 * 6 + 20]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t nandc01_addr0; - uint32_t nandc10_addr0; - uint32_t nandc11_addr1; - uint32_t chipsel_cs0; - uint32_t chipsel_cs1; - uint32_t cfg0; - uint32_t cfg1; - uint32_t eccbchcfg; - uint32_t exec; - uint32_t ecccfg; - uint32_t ebi2_chip_select_cfg0; - uint32_t adm_mux_data_ack_req_nc01; - uint32_t adm_mux_cmd_ack_req_nc01; - uint32_t adm_mux_data_ack_req_nc10; - uint32_t adm_mux_cmd_ack_req_nc10; - uint32_t adm_default_mux; - uint32_t default_ebi2_chip_select_cfg0; - uint32_t nc10_flash_dev_cmd_vld; - uint32_t nc10_flash_dev_cmd1; - uint32_t nc10_flash_dev_cmd_vld_default; - uint32_t nc10_flash_dev_cmd1_default; - struct { - uint32_t flash_status; - uint32_t buffer_status; - } result[16]; - } data; - } *dma_buffer; - dmov_s *cmd; - unsigned n; - unsigned page = 0; - uint32_t oob_len; - uint32_t sectordatasize; - uint32_t sectoroobsize; - int err, pageerr, rawerr; - dma_addr_t data_dma_addr = 0; - dma_addr_t oob_dma_addr = 0; - dma_addr_t data_dma_addr_curr = 0; - dma_addr_t oob_dma_addr_curr = 0; - uint32_t oob_col = 0; - unsigned page_count; - unsigned pages_read = 0; - unsigned start_sector = 0; - uint32_t ecc_errors; - uint32_t total_ecc_errors = 0; - unsigned cwperpage; - unsigned cw_offset = chip->cw_size; -#if VERBOSE - pr_info("=================================================" - "============\n"); - pr_info("%s:\nfrom 0x%llx mode %d\ndatbuf 0x%p datlen 0x%x" - "\noobbuf 0x%p ooblen 0x%x\n\n", - __func__, from, ops->mode, ops->datbuf, - ops->len, ops->oobbuf, ops->ooblen); -#endif - - if (mtd->writesize == 2048) - page = from >> 11; - - if (mtd->writesize == 4096) - page = from >> 12; - - if (interleave_enable) - page = (from >> 1) >> 12; - - oob_len = ops->ooblen; - cwperpage = (mtd->writesize >> 9); - - if (from & (mtd->writesize - 1)) { - pr_err("%s: unsupported from, 0x%llx\n", - __func__, from); - return -EINVAL; - } - if (ops->mode != MTD_OPS_RAW) { - if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { - pr_err("%s: unsupported ops->len, %d\n", - __func__, ops->len); - return -EINVAL; - } - } else { - if (ops->datbuf != NULL && - (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { - pr_err("%s: unsupported ops->len," - " %d for MTD_OPS_RAW\n", __func__, ops->len); - return -EINVAL; - } - } - - if (ops->mode != MTD_OPS_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { - pr_err("%s: unsupported ops->ooboffs, %d\n", - __func__, ops->ooboffs); - return -EINVAL; - } - - if (ops->oobbuf && !ops->datbuf && ops->mode == MTD_OPS_AUTO_OOB) - start_sector = cwperpage - 1; - - if (ops->oobbuf && !ops->datbuf) { - page_count = ops->ooblen / ((ops->mode == MTD_OPS_AUTO_OOB) ? - mtd->oobavail : mtd->oobsize); - if ((page_count == 0) && (ops->ooblen)) - page_count = 1; - } else if (ops->mode != MTD_OPS_RAW) - page_count = ops->len / mtd->writesize; - else - page_count = ops->len / (mtd->writesize + mtd->oobsize); - - if (ops->datbuf) { - data_dma_addr_curr = data_dma_addr = - msm_nand_dma_map(chip->dev, ops->datbuf, ops->len, - DMA_FROM_DEVICE); - if (dma_mapping_error(chip->dev, data_dma_addr)) { - pr_err("msm_nand_read_oob_dualnandc: " - "failed to get dma addr for %p\n", - ops->datbuf); - return -EIO; - } - } - if (ops->oobbuf) { - memset(ops->oobbuf, 0xff, ops->ooblen); - oob_dma_addr_curr = oob_dma_addr = - msm_nand_dma_map(chip->dev, ops->oobbuf, - ops->ooblen, DMA_BIDIRECTIONAL); - if (dma_mapping_error(chip->dev, oob_dma_addr)) { - pr_err("msm_nand_read_oob_dualnandc: " - "failed to get dma addr for %p\n", - ops->oobbuf); - err = -EIO; - goto err_dma_map_oobbuf_failed; - } - } - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer( - chip, sizeof(*dma_buffer)))); - - oob_col = start_sector * chip->cw_size; - if (chip->CFG1 & CFG1_WIDE_FLASH) { - oob_col >>= 1; - cw_offset >>= 1; - } - - err = 0; - while (page_count-- > 0) { - cmd = dma_buffer->cmd; - - if (ops->mode != MTD_OPS_RAW) { - dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ_ECC; - if (start_sector == (cwperpage - 1)) { - dma_buffer->data.cfg0 = (chip->CFG0 & - ~(7U << 6)); - } else { - dma_buffer->data.cfg0 = (chip->CFG0 & - ~(7U << 6)) - | (((cwperpage >> 1)-1) << 6); - } - dma_buffer->data.cfg1 = chip->CFG1; - if (enable_bch_ecc) - dma_buffer->data.eccbchcfg = chip->ecc_bch_cfg; - } else { - dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; - dma_buffer->data.cfg0 = ((chip->CFG0_RAW & - ~(7U << 6)) | ((((cwperpage >> 1)-1) << 6))); - dma_buffer->data.cfg1 = chip->CFG1_RAW | - (chip->CFG1 & CFG1_WIDE_FLASH); - } - - if (!interleave_enable) { - if (start_sector == (cwperpage - 1)) { - dma_buffer->data.nandc10_addr0 = - (page << 16) | oob_col; - dma_buffer->data.nc10_flash_dev_cmd_vld = 0xD; - dma_buffer->data.nc10_flash_dev_cmd1 = - 0xF00F3000; - } else { - dma_buffer->data.nandc01_addr0 = page << 16; - /* NC10 ADDR0 points to the next code word */ - dma_buffer->data.nandc10_addr0 = (page << 16) | - cw_offset; - dma_buffer->data.nc10_flash_dev_cmd_vld = 0x1D; - dma_buffer->data.nc10_flash_dev_cmd1 = - 0xF00FE005; - } - } else { - dma_buffer->data.nandc01_addr0 = - dma_buffer->data.nandc10_addr0 = - (page << 16) | oob_col; - } - /* ADDR1 */ - dma_buffer->data.nandc11_addr1 = (page >> 16) & 0xff; - - dma_buffer->data.adm_mux_data_ack_req_nc01 = 0x00000A3C; - dma_buffer->data.adm_mux_cmd_ack_req_nc01 = 0x0000053C; - dma_buffer->data.adm_mux_data_ack_req_nc10 = 0x00000F28; - dma_buffer->data.adm_mux_cmd_ack_req_nc10 = 0x00000F14; - dma_buffer->data.adm_default_mux = 0x00000FC0; - dma_buffer->data.nc10_flash_dev_cmd_vld_default = 0x1D; - dma_buffer->data.nc10_flash_dev_cmd1_default = 0xF00F3000; - - dma_buffer->data.ebi2_chip_select_cfg0 = 0x00000805; - dma_buffer->data.default_ebi2_chip_select_cfg0 = 0x00000801; - - /* chipsel_0 + enable DM interface */ - dma_buffer->data.chipsel_cs0 = (1<<4) | 4; - /* chipsel_1 + enable DM interface */ - dma_buffer->data.chipsel_cs1 = (1<<4) | 5; - - /* GO bit for the EXEC register */ - dma_buffer->data.exec = 1; - - BUILD_BUG_ON(16 != ARRAY_SIZE(dma_buffer->data.result)); - - for (n = start_sector; n < cwperpage; n++) { - /* flash + buffer status return words */ - dma_buffer->data.result[n].flash_status = 0xeeeeeeee; - dma_buffer->data.result[n].buffer_status = 0xeeeeeeee; - - if (n == start_sector) { - if (!interleave_enable) { - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.nc10_flash_dev_cmd_vld); - cmd->dst = NC10(MSM_NAND_DEV_CMD_VLD); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nc10_flash_dev_cmd1); - cmd->dst = NC10(MSM_NAND_DEV_CMD1); - cmd->len = 4; - cmd++; - - /* NC01, NC10 --> ADDR1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc11_addr1); - cmd->dst = NC11(MSM_NAND_ADDR1); - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = NC11(MSM_NAND_DEV0_CFG0); - if (enable_bch_ecc) - cmd->len = 12; - else - cmd->len = 8; - cmd++; - } else { - /* enable CS0 & CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - - /* NC01, NC10 --> ADDR1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc11_addr1); - cmd->dst = NC11(MSM_NAND_ADDR1); - cmd->len = 4; - cmd++; - - /* Enable CS0 for NC01 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.chipsel_cs0); - cmd->dst = - NC01(MSM_NAND_FLASH_CHIP_SELECT); - cmd->len = 4; - cmd++; - - /* Enable CS1 for NC10 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.chipsel_cs1); - cmd->dst = - NC10(MSM_NAND_FLASH_CHIP_SELECT); - cmd->len = 4; - cmd++; - - /* config DEV0_CFG0 & CFG1 for CS0 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = NC01(MSM_NAND_DEV0_CFG0); - cmd->len = 8; - cmd++; - - /* config DEV1_CFG0 & CFG1 for CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = NC10(MSM_NAND_DEV1_CFG0); - cmd->len = 8; - cmd++; - } - - dma_buffer->data.ecccfg = chip->ecc_buf_cfg; - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.ecccfg); - cmd->dst = NC11(MSM_NAND_EBI2_ECC_BUF_CFG); - cmd->len = 4; - cmd++; - - /* if 'only' the last code word */ - if (n == cwperpage - 1) { - /* MASK CMD ACK/REQ --> NC01 (0x53C)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_cmd_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* CMD */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cmd); - cmd->dst = NC10(MSM_NAND_FLASH_CMD); - cmd->len = 4; - cmd++; - - /* NC10 --> ADDR0 ( 0x0 ) */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc10_addr0); - cmd->dst = NC10(MSM_NAND_ADDR0); - cmd->len = 4; - cmd++; - - /* kick the execute reg for NC10 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.exec); - cmd->dst = NC10(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - - /* MASK DATA ACK/REQ --> NC01 (0xA3C)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_data_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* block on data ready from NC10, then - * read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC10(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.result[n]); - /* MSM_NAND_FLASH_STATUS + - * MSM_NAND_BUFFER_STATUS - */ - cmd->len = 8; - cmd++; - } else { - /* NC01 --> ADDR0 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc01_addr0); - cmd->dst = NC01(MSM_NAND_ADDR0); - cmd->len = 4; - cmd++; - - /* NC10 --> ADDR1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc10_addr0); - cmd->dst = NC10(MSM_NAND_ADDR0); - cmd->len = 4; - cmd++; - - /* MASK CMD ACK/REQ --> NC10 (0xF14)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_cmd_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* CMD */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cmd); - cmd->dst = NC01(MSM_NAND_FLASH_CMD); - cmd->len = 4; - cmd++; - - /* kick the execute register for NC01*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.exec); - cmd->dst = NC01(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - } - } - - /* read data block - * (only valid if status says success) - */ - if (ops->datbuf || (ops->oobbuf && - ops->mode != MTD_OPS_AUTO_OOB)) { - if (ops->mode != MTD_OPS_RAW) - sectordatasize = (n < (cwperpage - 1)) - ? 516 : (512 - ((cwperpage - 1) << 2)); - else - sectordatasize = chip->cw_size; - - if (n % 2 == 0) { - /* MASK DATA ACK/REQ --> NC10 (0xF28)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_data_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* block on data ready from NC01, then - * read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC01(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.result[n]); - /* MSM_NAND_FLASH_STATUS + - * MSM_NAND_BUFFER_STATUS - */ - cmd->len = 8; - cmd++; - - /* MASK CMD ACK/REQ --> NC01 (0x53C)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_cmd_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* CMD */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cmd); - cmd->dst = NC10(MSM_NAND_FLASH_CMD); - cmd->len = 4; - cmd++; - - /* kick the execute register for NC10 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.exec); - cmd->dst = NC10(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - - /* Read only when there is data - * buffer - */ - if (ops->datbuf) { - cmd->cmd = 0; - cmd->src = - NC01(MSM_NAND_FLASH_BUFFER); - cmd->dst = data_dma_addr_curr; - data_dma_addr_curr += - sectordatasize; - cmd->len = sectordatasize; - cmd++; - } - } else { - /* MASK DATA ACK/REQ --> - * NC01 (0xA3C) - */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_data_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* block on data ready from NC10 - * then read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = - NC10(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.result[n]); - /* MSM_NAND_FLASH_STATUS + - * MSM_NAND_BUFFER_STATUS - */ - cmd->len = 8; - cmd++; - if (n != cwperpage - 1) { - /* MASK CMD ACK/REQ --> - * NC10 (0xF14) - */ - cmd->cmd = 0; - cmd->src = - msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_cmd_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* CMD */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cmd); - cmd->dst = - NC01(MSM_NAND_FLASH_CMD); - cmd->len = 4; - cmd++; - - /* EXEC */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.exec); - cmd->dst = - NC01(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - } - - /* Read only when there is data - * buffer - */ - if (ops->datbuf) { - cmd->cmd = 0; - cmd->src = - NC10(MSM_NAND_FLASH_BUFFER); - cmd->dst = data_dma_addr_curr; - data_dma_addr_curr += - sectordatasize; - cmd->len = sectordatasize; - cmd++; - } - } - } - - if (ops->oobbuf && (n == (cwperpage - 1) - || ops->mode != MTD_OPS_AUTO_OOB)) { - cmd->cmd = 0; - if (n == (cwperpage - 1)) { - /* Use NC10 for reading the - * last codeword!!! - */ - cmd->src = NC10(MSM_NAND_FLASH_BUFFER) + - (512 - ((cwperpage - 1) << 2)); - sectoroobsize = (cwperpage << 2); - if (ops->mode != MTD_OPS_AUTO_OOB) - sectoroobsize += - chip->ecc_parity_bytes; - } else { - if (n % 2 == 0) - cmd->src = - NC01(MSM_NAND_FLASH_BUFFER) - + 516; - else - cmd->src = - NC10(MSM_NAND_FLASH_BUFFER) - + 516; - sectoroobsize = chip->ecc_parity_bytes; - } - cmd->dst = oob_dma_addr_curr; - if (sectoroobsize < oob_len) - cmd->len = sectoroobsize; - else - cmd->len = oob_len; - oob_dma_addr_curr += cmd->len; - oob_len -= cmd->len; - if (cmd->len > 0) - cmd++; - } - } - /* ADM --> Default mux state (0xFC0) */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_default_mux); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - if (!interleave_enable) { - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nc10_flash_dev_cmd_vld_default); - cmd->dst = NC10(MSM_NAND_DEV_CMD_VLD); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nc10_flash_dev_cmd1_default); - cmd->dst = NC10(MSM_NAND_DEV_CMD1); - cmd->len = 4; - cmd++; - } else { - /* disable CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.default_ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - } - - BUILD_BUG_ON(16 * 6 + 20 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = - (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) - | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - /* if any of the writes failed (0x10), or there - * was a protection violation (0x100), we lose - */ - pageerr = rawerr = 0; - for (n = start_sector; n < cwperpage; n++) { - if (dma_buffer->data.result[n].flash_status & 0x110) { - rawerr = -EIO; - break; - } - } - if (rawerr) { - if (ops->datbuf && ops->mode != MTD_OPS_RAW) { - uint8_t *datbuf = ops->datbuf + - pages_read * mtd->writesize; - - dma_sync_single_for_cpu(chip->dev, - data_dma_addr_curr-mtd->writesize, - mtd->writesize, DMA_BIDIRECTIONAL); - - for (n = 0; n < mtd->writesize; n++) { - /* empty blocks read 0x54 at - * these offsets - */ - if ((n % 516 == 3 || n % 516 == 175) - && datbuf[n] == 0x54) - datbuf[n] = 0xff; - if (datbuf[n] != 0xff) { - pageerr = rawerr; - break; - } - } - - dma_sync_single_for_device(chip->dev, - data_dma_addr_curr-mtd->writesize, - mtd->writesize, DMA_BIDIRECTIONAL); - - } - if (ops->oobbuf) { - dma_sync_single_for_cpu(chip->dev, - oob_dma_addr_curr - (ops->ooblen - oob_len), - ops->ooblen - oob_len, DMA_BIDIRECTIONAL); - - for (n = 0; n < ops->ooblen; n++) { - if (ops->oobbuf[n] != 0xff) { - pageerr = rawerr; - break; - } - } - - dma_sync_single_for_device(chip->dev, - oob_dma_addr_curr - (ops->ooblen - oob_len), - ops->ooblen - oob_len, DMA_BIDIRECTIONAL); - } - } - if (pageerr) { - for (n = start_sector; n < cwperpage; n++) { - if (dma_buffer->data.result[n].buffer_status - & chip->uncorrectable_bit_mask) { - /* not thread safe */ - mtd->ecc_stats.failed++; - pageerr = -EBADMSG; - break; - } - } - } - if (!rawerr) { /* check for corretable errors */ - for (n = start_sector; n < cwperpage; n++) { - ecc_errors = dma_buffer->data. - result[n].buffer_status - & chip->num_err_mask; - if (ecc_errors) { - total_ecc_errors += ecc_errors; - /* not thread safe */ - mtd->ecc_stats.corrected += ecc_errors; - if (ecc_errors > 1) - pageerr = -EUCLEAN; - } - } - } - if (pageerr && (pageerr != -EUCLEAN || err == 0)) - err = pageerr; - -#if VERBOSE - if (rawerr && !pageerr) { - pr_err("msm_nand_read_oob_dualnandc " - "%llx %x %x empty page\n", - (loff_t)page * mtd->writesize, ops->len, - ops->ooblen); - } else { - for (n = start_sector; n < cwperpage; n++) { - if (n%2) { - pr_info("NC10: flash_status[%d] = %x, " - "buffr_status[%d] = %x\n", - n, dma_buffer-> - data.result[n].flash_status, - n, dma_buffer-> - data.result[n].buffer_status); - } else { - pr_info("NC01: flash_status[%d] = %x, " - "buffr_status[%d] = %x\n", - n, dma_buffer-> - data.result[n].flash_status, - n, dma_buffer-> - data.result[n].buffer_status); - } - } - } -#endif - if (err && err != -EUCLEAN && err != -EBADMSG) - break; - pages_read++; - page++; - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - if (ops->oobbuf) { - dma_unmap_page(chip->dev, oob_dma_addr, - ops->ooblen, DMA_FROM_DEVICE); - } -err_dma_map_oobbuf_failed: - if (ops->datbuf) { - dma_unmap_page(chip->dev, data_dma_addr, - ops->len, DMA_BIDIRECTIONAL); - } - - if (ops->mode != MTD_OPS_RAW) - ops->retlen = mtd->writesize * pages_read; - else - ops->retlen = (mtd->writesize + mtd->oobsize) * - pages_read; - ops->oobretlen = ops->ooblen - oob_len; - if (err) - pr_err("msm_nand_read_oob_dualnandc " - "%llx %x %x failed %d, corrected %d\n", - from, ops->datbuf ? ops->len : 0, ops->ooblen, err, - total_ecc_errors); -#if VERBOSE - pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", - __func__, err, ops->retlen, ops->oobretlen); - - pr_info("===================================================" - "==========\n"); -#endif - return err; -} - -static int -msm_nand_read(struct mtd_info *mtd, loff_t from, size_t len, - size_t *retlen, u_char *buf) -{ - int ret; - struct mtd_oob_ops ops; - int (*read_oob)(struct mtd_info *, loff_t, struct mtd_oob_ops *); - - if (!dual_nand_ctlr_present) - read_oob = msm_nand_read_oob; - else - read_oob = msm_nand_read_oob_dualnandc; - - ops.mode = MTD_OPS_PLACE_OOB; - ops.retlen = 0; - ops.ooblen = 0; - ops.oobbuf = NULL; - ret = 0; - *retlen = 0; - - if ((from & (mtd->writesize - 1)) == 0 && len == mtd->writesize) { - /* reading a page on page boundary */ - ops.len = len; - ops.datbuf = buf; - ret = read_oob(mtd, from, &ops); - *retlen = ops.retlen; - } else if (len > 0) { - /* reading any size on any offset. partial page is supported */ - u8 *bounce_buf; - loff_t aligned_from; - loff_t offset; - size_t actual_len; - - bounce_buf = kmalloc(mtd->writesize, GFP_KERNEL); - if (!bounce_buf) { - pr_err("%s: could not allocate memory\n", __func__); - ret = -ENOMEM; - goto out; - } - - ops.len = mtd->writesize; - offset = from & (mtd->writesize - 1); - aligned_from = from - offset; - - for (;;) { - int no_copy; - - actual_len = mtd->writesize - offset; - if (actual_len > len) - actual_len = len; - - no_copy = (offset == 0 && actual_len == mtd->writesize); - ops.datbuf = (no_copy) ? buf : bounce_buf; - ret = read_oob(mtd, aligned_from, &ops); - if (ret < 0) - break; - - if (!no_copy) - memcpy(buf, bounce_buf + offset, actual_len); - - len -= actual_len; - *retlen += actual_len; - if (len == 0) - break; - - buf += actual_len; - offset = 0; - aligned_from += mtd->writesize; - } - - kfree(bounce_buf); - } - -out: - return ret; -} - -static int -msm_nand_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) -{ - struct msm_nand_chip *chip = mtd->priv; - struct { - dmov_s cmd[8 * 7 + 2]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t addr0; - uint32_t addr1; - uint32_t chipsel; - uint32_t cfg0; - uint32_t cfg1; - uint32_t eccbchcfg; - uint32_t exec; - uint32_t ecccfg; - uint32_t clrfstatus; - uint32_t clrrstatus; - uint32_t flash_status[8]; - } data; - } *dma_buffer; - dmov_s *cmd; - unsigned n; - unsigned page = 0; - uint32_t oob_len; - uint32_t sectordatawritesize; - int err = 0; - dma_addr_t data_dma_addr = 0; - dma_addr_t oob_dma_addr = 0; - dma_addr_t data_dma_addr_curr = 0; - dma_addr_t oob_dma_addr_curr = 0; - unsigned page_count; - unsigned pages_written = 0; - unsigned cwperpage; -#if VERBOSE - pr_info("=================================================" - "================\n"); - pr_info("%s:\nto 0x%llx mode %d\ndatbuf 0x%p datlen 0x%x" - "\noobbuf 0x%p ooblen 0x%x\n", - __func__, to, ops->mode, ops->datbuf, ops->len, - ops->oobbuf, ops->ooblen); -#endif - - if (mtd->writesize == 2048) - page = to >> 11; - - if (mtd->writesize == 4096) - page = to >> 12; - - oob_len = ops->ooblen; - cwperpage = (mtd->writesize >> 9); - - if (to & (mtd->writesize - 1)) { - pr_err("%s: unsupported to, 0x%llx\n", __func__, to); - return -EINVAL; - } - - if (ops->mode != MTD_OPS_RAW) { - if (ops->ooblen != 0 && ops->mode != MTD_OPS_AUTO_OOB) { - pr_err("%s: unsupported ops->mode,%d\n", - __func__, ops->mode); - return -EINVAL; - } - if ((ops->len % mtd->writesize) != 0) { - pr_err("%s: unsupported ops->len, %d\n", - __func__, ops->len); - return -EINVAL; - } - } else { - if ((ops->len % (mtd->writesize + mtd->oobsize)) != 0) { - pr_err("%s: unsupported ops->len, " - "%d for MTD_OPS_RAW mode\n", - __func__, ops->len); - return -EINVAL; - } - } - - if (ops->datbuf == NULL) { - pr_err("%s: unsupported ops->datbuf == NULL\n", __func__); - return -EINVAL; - } - if (ops->mode != MTD_OPS_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { - pr_err("%s: unsupported ops->ooboffs, %d\n", - __func__, ops->ooboffs); - return -EINVAL; - } - - if (ops->datbuf) { - data_dma_addr_curr = data_dma_addr = - msm_nand_dma_map(chip->dev, ops->datbuf, - ops->len, DMA_TO_DEVICE); - if (dma_mapping_error(chip->dev, data_dma_addr)) { - pr_err("msm_nand_write_oob: failed to get dma addr " - "for %p\n", ops->datbuf); - return -EIO; - } - } - if (ops->oobbuf) { - oob_dma_addr_curr = oob_dma_addr = - msm_nand_dma_map(chip->dev, ops->oobbuf, - ops->ooblen, DMA_TO_DEVICE); - if (dma_mapping_error(chip->dev, oob_dma_addr)) { - pr_err("msm_nand_write_oob: failed to get dma addr " - "for %p\n", ops->oobbuf); - err = -EIO; - goto err_dma_map_oobbuf_failed; - } - } - if (ops->mode != MTD_OPS_RAW) - page_count = ops->len / mtd->writesize; - else - page_count = ops->len / (mtd->writesize + mtd->oobsize); - - wait_event(chip->wait_queue, (dma_buffer = - msm_nand_get_dma_buffer(chip, sizeof(*dma_buffer)))); - - while (page_count-- > 0) { - cmd = dma_buffer->cmd; - - if (ops->mode != MTD_OPS_RAW) { - dma_buffer->data.cfg0 = chip->CFG0; - dma_buffer->data.cfg1 = chip->CFG1; - if (enable_bch_ecc) - dma_buffer->data.eccbchcfg = chip->ecc_bch_cfg; - } else { - dma_buffer->data.cfg0 = (chip->CFG0_RAW & - ~(7U << 6)) | ((cwperpage-1) << 6); - dma_buffer->data.cfg1 = chip->CFG1_RAW | - (chip->CFG1 & CFG1_WIDE_FLASH); - } - - /* CMD / ADDR0 / ADDR1 / CHIPSEL program values */ - dma_buffer->data.cmd = MSM_NAND_CMD_PRG_PAGE; - dma_buffer->data.addr0 = page << 16; - dma_buffer->data.addr1 = (page >> 16) & 0xff; - /* chipsel_0 + enable DM interface */ - dma_buffer->data.chipsel = 0 | 4; - - - /* GO bit for the EXEC register */ - dma_buffer->data.exec = 1; - dma_buffer->data.clrfstatus = 0x00000020; - dma_buffer->data.clrrstatus = 0x000000C0; - - BUILD_BUG_ON(8 != ARRAY_SIZE(dma_buffer->data.flash_status)); - - for (n = 0; n < cwperpage ; n++) { - /* status return words */ - dma_buffer->data.flash_status[n] = 0xeeeeeeee; - /* block on cmd ready, then - * write CMD / ADDR0 / ADDR1 / CHIPSEL regs in a burst - */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = - msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = MSM_NAND_FLASH_CMD; - if (n == 0) - cmd->len = 16; - else - cmd->len = 4; - cmd++; - - if (n == 0) { - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = MSM_NAND_DEV0_CFG0; - if (enable_bch_ecc) - cmd->len = 12; - else - cmd->len = 8; - cmd++; - - dma_buffer->data.ecccfg = chip->ecc_buf_cfg; - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.ecccfg); - cmd->dst = MSM_NAND_EBI2_ECC_BUF_CFG; - cmd->len = 4; - cmd++; - } - - /* write data block */ - if (ops->mode != MTD_OPS_RAW) - sectordatawritesize = (n < (cwperpage - 1)) ? - 516 : (512 - ((cwperpage - 1) << 2)); - else - sectordatawritesize = chip->cw_size; - - cmd->cmd = 0; - cmd->src = data_dma_addr_curr; - data_dma_addr_curr += sectordatawritesize; - cmd->dst = MSM_NAND_FLASH_BUFFER; - cmd->len = sectordatawritesize; - cmd++; - - if (ops->oobbuf) { - if (n == (cwperpage - 1)) { - cmd->cmd = 0; - cmd->src = oob_dma_addr_curr; - cmd->dst = MSM_NAND_FLASH_BUFFER + - (512 - ((cwperpage - 1) << 2)); - if ((cwperpage << 2) < oob_len) - cmd->len = (cwperpage << 2); - else - cmd->len = oob_len; - oob_dma_addr_curr += cmd->len; - oob_len -= cmd->len; - if (cmd->len > 0) - cmd++; - } - if (ops->mode != MTD_OPS_AUTO_OOB) { - /* skip ecc bytes in oobbuf */ - if (oob_len < chip->ecc_parity_bytes) { - oob_dma_addr_curr += - chip->ecc_parity_bytes; - oob_len -= - chip->ecc_parity_bytes; - } else { - oob_dma_addr_curr += oob_len; - oob_len = 0; - } - } - } - - /* kick the execute register */ - cmd->cmd = 0; - cmd->src = - msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = MSM_NAND_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* block on data ready, then - * read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_FLASH_STATUS; - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.flash_status[n]); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.clrfstatus); - cmd->dst = MSM_NAND_FLASH_STATUS; - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.clrrstatus); - cmd->dst = MSM_NAND_READ_STATUS; - cmd->len = 4; - cmd++; - - } - - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - BUILD_BUG_ON(8 * 7 + 2 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmdptr = - (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | - CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR( - msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - /* if any of the writes failed (0x10), or there was a - * protection violation (0x100), or the program success - * bit (0x80) is unset, we lose - */ - err = 0; - for (n = 0; n < cwperpage; n++) { - if (dma_buffer->data.flash_status[n] & 0x110) { - err = -EIO; - break; - } - if (!(dma_buffer->data.flash_status[n] & 0x80)) { - err = -EIO; - break; - } - } - -#if VERBOSE - for (n = 0; n < cwperpage; n++) - pr_info("write pg %d: flash_status[%d] = %x\n", page, - n, dma_buffer->data.flash_status[n]); - -#endif - if (err) - break; - pages_written++; - page++; - } - if (ops->mode != MTD_OPS_RAW) - ops->retlen = mtd->writesize * pages_written; - else - ops->retlen = (mtd->writesize + mtd->oobsize) * pages_written; - - ops->oobretlen = ops->ooblen - oob_len; - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - if (ops->oobbuf) - dma_unmap_page(chip->dev, oob_dma_addr, - ops->ooblen, DMA_TO_DEVICE); -err_dma_map_oobbuf_failed: - if (ops->datbuf) - dma_unmap_page(chip->dev, data_dma_addr, ops->len, - DMA_TO_DEVICE); - if (err) - pr_err("msm_nand_write_oob %llx %x %x failed %d\n", - to, ops->len, ops->ooblen, err); - -#if VERBOSE - pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", - __func__, err, ops->retlen, ops->oobretlen); - - pr_info("===================================================" - "==============\n"); -#endif - return err; -} - -static int -msm_nand_write_oob_dualnandc(struct mtd_info *mtd, loff_t to, - struct mtd_oob_ops *ops) -{ - struct msm_nand_chip *chip = mtd->priv; - struct { - dmov_s cmd[16 * 6 + 18]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t nandc01_addr0; - uint32_t nandc10_addr0; - uint32_t nandc11_addr1; - uint32_t chipsel_cs0; - uint32_t chipsel_cs1; - uint32_t cfg0; - uint32_t cfg1; - uint32_t eccbchcfg; - uint32_t exec; - uint32_t ecccfg; - uint32_t cfg0_nc01; - uint32_t ebi2_chip_select_cfg0; - uint32_t adm_mux_data_ack_req_nc01; - uint32_t adm_mux_cmd_ack_req_nc01; - uint32_t adm_mux_data_ack_req_nc10; - uint32_t adm_mux_cmd_ack_req_nc10; - uint32_t adm_default_mux; - uint32_t default_ebi2_chip_select_cfg0; - uint32_t nc01_flash_dev_cmd_vld; - uint32_t nc10_flash_dev_cmd0; - uint32_t nc01_flash_dev_cmd_vld_default; - uint32_t nc10_flash_dev_cmd0_default; - uint32_t flash_status[16]; - uint32_t clrfstatus; - uint32_t clrrstatus; - } data; - } *dma_buffer; - dmov_s *cmd; - unsigned n; - unsigned page = 0; - uint32_t oob_len; - uint32_t sectordatawritesize; - int err = 0; - dma_addr_t data_dma_addr = 0; - dma_addr_t oob_dma_addr = 0; - dma_addr_t data_dma_addr_curr = 0; - dma_addr_t oob_dma_addr_curr = 0; - unsigned page_count; - unsigned pages_written = 0; - unsigned cwperpage; - unsigned cw_offset = chip->cw_size; -#if VERBOSE - pr_info("=================================================" - "============\n"); - pr_info("%s:\nto 0x%llx mode %d\ndatbuf 0x%p datlen 0x%x" - "\noobbuf 0x%p ooblen 0x%x\n\n", - __func__, to, ops->mode, ops->datbuf, ops->len, - ops->oobbuf, ops->ooblen); -#endif - - if (mtd->writesize == 2048) - page = to >> 11; - - if (mtd->writesize == 4096) - page = to >> 12; - - if (interleave_enable) - page = (to >> 1) >> 12; - - oob_len = ops->ooblen; - cwperpage = (mtd->writesize >> 9); - - if (to & (mtd->writesize - 1)) { - pr_err("%s: unsupported to, 0x%llx\n", __func__, to); - return -EINVAL; - } - - if (ops->mode != MTD_OPS_RAW) { - if (ops->ooblen != 0 && ops->mode != MTD_OPS_AUTO_OOB) { - pr_err("%s: unsupported ops->mode,%d\n", - __func__, ops->mode); - return -EINVAL; - } - if ((ops->len % mtd->writesize) != 0) { - pr_err("%s: unsupported ops->len, %d\n", - __func__, ops->len); - return -EINVAL; - } - } else { - if ((ops->len % (mtd->writesize + mtd->oobsize)) != 0) { - pr_err("%s: unsupported ops->len, " - "%d for MTD_OPS_RAW mode\n", - __func__, ops->len); - return -EINVAL; - } - } - - if (ops->datbuf == NULL) { - pr_err("%s: unsupported ops->datbuf == NULL\n", __func__); - return -EINVAL; - } - - if (ops->mode != MTD_OPS_RAW && ops->ooblen != 0 && ops->ooboffs != 0) { - pr_err("%s: unsupported ops->ooboffs, %d\n", - __func__, ops->ooboffs); - return -EINVAL; - } - - if (ops->datbuf) { - data_dma_addr_curr = data_dma_addr = - msm_nand_dma_map(chip->dev, ops->datbuf, - ops->len, DMA_TO_DEVICE); - if (dma_mapping_error(chip->dev, data_dma_addr)) { - pr_err("msm_nand_write_oob_dualnandc:" - "failed to get dma addr " - "for %p\n", ops->datbuf); - return -EIO; - } - } - if (ops->oobbuf) { - oob_dma_addr_curr = oob_dma_addr = - msm_nand_dma_map(chip->dev, ops->oobbuf, - ops->ooblen, DMA_TO_DEVICE); - if (dma_mapping_error(chip->dev, oob_dma_addr)) { - pr_err("msm_nand_write_oob_dualnandc:" - "failed to get dma addr " - "for %p\n", ops->oobbuf); - err = -EIO; - goto err_dma_map_oobbuf_failed; - } - } - if (ops->mode != MTD_OPS_RAW) - page_count = ops->len / mtd->writesize; - else - page_count = ops->len / (mtd->writesize + mtd->oobsize); - - wait_event(chip->wait_queue, (dma_buffer = - msm_nand_get_dma_buffer(chip, sizeof(*dma_buffer)))); - - if (chip->CFG1 & CFG1_WIDE_FLASH) - cw_offset >>= 1; - - dma_buffer->data.ebi2_chip_select_cfg0 = 0x00000805; - dma_buffer->data.adm_mux_data_ack_req_nc01 = 0x00000A3C; - dma_buffer->data.adm_mux_cmd_ack_req_nc01 = 0x0000053C; - dma_buffer->data.adm_mux_data_ack_req_nc10 = 0x00000F28; - dma_buffer->data.adm_mux_cmd_ack_req_nc10 = 0x00000F14; - dma_buffer->data.adm_default_mux = 0x00000FC0; - dma_buffer->data.default_ebi2_chip_select_cfg0 = 0x00000801; - dma_buffer->data.nc01_flash_dev_cmd_vld = 0x9; - dma_buffer->data.nc10_flash_dev_cmd0 = 0x1085D060; - dma_buffer->data.nc01_flash_dev_cmd_vld_default = 0x1D; - dma_buffer->data.nc10_flash_dev_cmd0_default = 0x1080D060; - dma_buffer->data.clrfstatus = 0x00000020; - dma_buffer->data.clrrstatus = 0x000000C0; - - while (page_count-- > 0) { - cmd = dma_buffer->cmd; - - if (ops->mode != MTD_OPS_RAW) { - dma_buffer->data.cfg0 = ((chip->CFG0 & ~(7U << 6)) - & ~(1 << 4)) | ((((cwperpage >> 1)-1)) << 6); - dma_buffer->data.cfg1 = chip->CFG1; - if (enable_bch_ecc) - dma_buffer->data.eccbchcfg = chip->ecc_bch_cfg; - } else { - dma_buffer->data.cfg0 = ((chip->CFG0_RAW & - ~(7U << 6)) & ~(1 << 4)) | (((cwperpage >> 1)-1) << 6); - dma_buffer->data.cfg1 = chip->CFG1_RAW | - (chip->CFG1 & CFG1_WIDE_FLASH); - } - - /* Disables the automatic issuing of the read - * status command for first NAND controller. - */ - if (!interleave_enable) - dma_buffer->data.cfg0_nc01 = dma_buffer->data.cfg0 - | (1 << 4); - else - dma_buffer->data.cfg0 |= (1 << 4); - - dma_buffer->data.cmd = MSM_NAND_CMD_PRG_PAGE; - dma_buffer->data.chipsel_cs0 = (1<<4) | 4; - dma_buffer->data.chipsel_cs1 = (1<<4) | 5; - - /* GO bit for the EXEC register */ - dma_buffer->data.exec = 1; - - if (!interleave_enable) { - dma_buffer->data.nandc01_addr0 = (page << 16) | 0x0; - /* NC10 ADDR0 points to the next code word */ - dma_buffer->data.nandc10_addr0 = - (page << 16) | cw_offset; - } else { - dma_buffer->data.nandc01_addr0 = - dma_buffer->data.nandc10_addr0 = (page << 16) | 0x0; - } - /* ADDR1 */ - dma_buffer->data.nandc11_addr1 = (page >> 16) & 0xff; - - BUILD_BUG_ON(16 != ARRAY_SIZE(dma_buffer->data.flash_status)); - - for (n = 0; n < cwperpage; n++) { - /* status return words */ - dma_buffer->data.flash_status[n] = 0xeeeeeeee; - - if (n == 0) { - if (!interleave_enable) { - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.nc01_flash_dev_cmd_vld); - cmd->dst = NC01(MSM_NAND_DEV_CMD_VLD); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nc10_flash_dev_cmd0); - cmd->dst = NC10(MSM_NAND_DEV_CMD0); - cmd->len = 4; - cmd++; - - /* common settings for both NC01 & NC10 - * NC01, NC10 --> ADDR1 / CHIPSEL - */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc11_addr1); - cmd->dst = NC11(MSM_NAND_ADDR1); - cmd->len = 8; - cmd++; - - /* Disables the automatic issue of the - * read status command after the write - * operation. - */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0_nc01); - cmd->dst = NC01(MSM_NAND_DEV0_CFG0); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = NC10(MSM_NAND_DEV0_CFG0); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg1); - cmd->dst = NC11(MSM_NAND_DEV0_CFG1); - if (enable_bch_ecc) - cmd->len = 8; - else - cmd->len = 4; - cmd++; - } else { - /* enable CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - - /* NC11 --> ADDR1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc11_addr1); - cmd->dst = NC11(MSM_NAND_ADDR1); - cmd->len = 4; - cmd++; - - /* Enable CS0 for NC01 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.chipsel_cs0); - cmd->dst = - NC01(MSM_NAND_FLASH_CHIP_SELECT); - cmd->len = 4; - cmd++; - - /* Enable CS1 for NC10 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.chipsel_cs1); - cmd->dst = - NC10(MSM_NAND_FLASH_CHIP_SELECT); - cmd->len = 4; - cmd++; - - /* config DEV0_CFG0 & CFG1 for CS0 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = NC01(MSM_NAND_DEV0_CFG0); - cmd->len = 8; - cmd++; - - /* config DEV1_CFG0 & CFG1 for CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cfg0); - cmd->dst = NC10(MSM_NAND_DEV1_CFG0); - cmd->len = 8; - cmd++; - } - - dma_buffer->data.ecccfg = chip->ecc_buf_cfg; - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.ecccfg); - cmd->dst = NC11(MSM_NAND_EBI2_ECC_BUF_CFG); - cmd->len = 4; - cmd++; - - /* NC01 --> ADDR0 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc01_addr0); - cmd->dst = NC01(MSM_NAND_ADDR0); - cmd->len = 4; - cmd++; - - /* NC10 --> ADDR0 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nandc10_addr0); - cmd->dst = NC10(MSM_NAND_ADDR0); - cmd->len = 4; - cmd++; - } - - if (n % 2 == 0) { - /* MASK CMD ACK/REQ --> NC10 (0xF14)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_cmd_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* CMD */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cmd); - cmd->dst = NC01(MSM_NAND_FLASH_CMD); - cmd->len = 4; - cmd++; - } else { - /* MASK CMD ACK/REQ --> NC01 (0x53C)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_cmd_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* CMD */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.cmd); - cmd->dst = NC10(MSM_NAND_FLASH_CMD); - cmd->len = 4; - cmd++; - } - - if (ops->mode != MTD_OPS_RAW) - sectordatawritesize = (n < (cwperpage - 1)) ? - 516 : (512 - ((cwperpage - 1) << 2)); - else - sectordatawritesize = chip->cw_size; - - cmd->cmd = 0; - cmd->src = data_dma_addr_curr; - data_dma_addr_curr += sectordatawritesize; - - if (n % 2 == 0) - cmd->dst = NC01(MSM_NAND_FLASH_BUFFER); - else - cmd->dst = NC10(MSM_NAND_FLASH_BUFFER); - cmd->len = sectordatawritesize; - cmd++; - - if (ops->oobbuf) { - if (n == (cwperpage - 1)) { - cmd->cmd = 0; - cmd->src = oob_dma_addr_curr; - cmd->dst = NC10(MSM_NAND_FLASH_BUFFER) + - (512 - ((cwperpage - 1) << 2)); - if ((cwperpage << 2) < oob_len) - cmd->len = (cwperpage << 2); - else - cmd->len = oob_len; - oob_dma_addr_curr += cmd->len; - oob_len -= cmd->len; - if (cmd->len > 0) - cmd++; - } - if (ops->mode != MTD_OPS_AUTO_OOB) { - /* skip ecc bytes in oobbuf */ - if (oob_len < chip->ecc_parity_bytes) { - oob_dma_addr_curr += - chip->ecc_parity_bytes; - oob_len -= - chip->ecc_parity_bytes; - } else { - oob_dma_addr_curr += oob_len; - oob_len = 0; - } - } - } - - if (n % 2 == 0) { - if (n != 0) { - /* MASK DATA ACK/REQ --> NC01 (0xA3C)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer-> - data.adm_mux_data_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* block on data ready from NC10, then - * read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC10(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.flash_status[n-1]); - cmd->len = 4; - cmd++; - } - /* kick the NC01 execute register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.exec); - cmd->dst = NC01(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - } else { - /* MASK DATA ACK/REQ --> NC10 (0xF28)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_data_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* block on data ready from NC01, then - * read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC01(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.flash_status[n-1]); - cmd->len = 4; - cmd++; - - /* kick the execute register */ - cmd->cmd = 0; - cmd->src = - msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = NC10(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - } - } - - /* MASK DATA ACK/REQ --> NC01 (0xA3C)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_data_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* we should process outstanding request */ - /* block on data ready, then - * read the status register - */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC10(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.flash_status[n-1]); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrfstatus); - cmd->dst = NC11(MSM_NAND_FLASH_STATUS); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrrstatus); - cmd->dst = NC11(MSM_NAND_READ_STATUS); - cmd->len = 4; - cmd++; - - /* MASK DATA ACK/REQ --> NC01 (0xFC0)*/ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_default_mux); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - if (!interleave_enable) { - /* setting to defalut values back */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nc01_flash_dev_cmd_vld_default); - cmd->dst = NC01(MSM_NAND_DEV_CMD_VLD); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.nc10_flash_dev_cmd0_default); - cmd->dst = NC10(MSM_NAND_DEV_CMD0); - cmd->len = 4; - cmd++; - } else { - /* disable CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.default_ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - } - - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - BUILD_BUG_ON(16 * 6 + 18 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmdptr = - ((msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP); - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR( - msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - /* if any of the writes failed (0x10), or there was a - * protection violation (0x100), or the program success - * bit (0x80) is unset, we lose - */ - err = 0; - for (n = 0; n < cwperpage; n++) { - if (dma_buffer->data.flash_status[n] & 0x110) { - err = -EIO; - break; - } - if (!(dma_buffer->data.flash_status[n] & 0x80)) { - err = -EIO; - break; - } - } - /* check for flash status busy for the last codeword */ - if (!interleave_enable) - if (!(dma_buffer->data.flash_status[cwperpage - 1] - & 0x20)) { - err = -EIO; - break; - } -#if VERBOSE - for (n = 0; n < cwperpage; n++) { - if (n%2) { - pr_info("NC10: write pg %d: flash_status[%d] = %x\n", - page, n, dma_buffer->data.flash_status[n]); - } else { - pr_info("NC01: write pg %d: flash_status[%d] = %x\n", - page, n, dma_buffer->data.flash_status[n]); - } - } -#endif - if (err) - break; - pages_written++; - page++; - } - if (ops->mode != MTD_OPS_RAW) - ops->retlen = mtd->writesize * pages_written; - else - ops->retlen = (mtd->writesize + mtd->oobsize) * pages_written; - - ops->oobretlen = ops->ooblen - oob_len; - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - if (ops->oobbuf) - dma_unmap_page(chip->dev, oob_dma_addr, - ops->ooblen, DMA_TO_DEVICE); -err_dma_map_oobbuf_failed: - if (ops->datbuf) - dma_unmap_page(chip->dev, data_dma_addr, ops->len, - DMA_TO_DEVICE); - if (err) - pr_err("msm_nand_write_oob_dualnandc %llx %x %x failed %d\n", - to, ops->len, ops->ooblen, err); - -#if VERBOSE - pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", - __func__, err, ops->retlen, ops->oobretlen); - - pr_info("===================================================" - "==========\n"); -#endif - return err; -} - -static int msm_nand_write(struct mtd_info *mtd, loff_t to, size_t len, - size_t *retlen, const u_char *buf) -{ - int ret; - struct mtd_oob_ops ops; - int (*write_oob)(struct mtd_info *, loff_t, struct mtd_oob_ops *); - - if (!dual_nand_ctlr_present) - write_oob = msm_nand_write_oob; - else - write_oob = msm_nand_write_oob_dualnandc; - - ops.mode = MTD_OPS_PLACE_OOB; - ops.retlen = 0; - ops.ooblen = 0; - ops.oobbuf = NULL; - ret = 0; - *retlen = 0; - - if (!virt_addr_valid(buf) && - ((to | len) & (mtd->writesize - 1)) == 0 && - ((unsigned long) buf & ~PAGE_MASK) + len > PAGE_SIZE) { - /* - * Handle writing of large size write buffer in vmalloc - * address space that does not fit in an MMU page. - * The destination address must be on page boundary, - * and the size must be multiple of NAND page size. - * Writing partial page is not supported. - */ - ops.len = mtd->writesize; - - for (;;) { - ops.datbuf = (uint8_t *) buf; - - ret = write_oob(mtd, to, &ops); - if (ret < 0) - break; - - len -= mtd->writesize; - *retlen += mtd->writesize; - if (len == 0) - break; - - buf += mtd->writesize; - to += mtd->writesize; - } - } else { - ops.len = len; - ops.datbuf = (uint8_t *) buf; - ret = write_oob(mtd, to, &ops); - *retlen = ops.retlen; - } - - return ret; -} - -static int -msm_nand_erase(struct mtd_info *mtd, struct erase_info *instr) -{ - int err; - struct msm_nand_chip *chip = mtd->priv; - struct { - dmov_s cmd[6]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t addr0; - uint32_t addr1; - uint32_t chipsel; - uint32_t cfg0; - uint32_t cfg1; - uint32_t exec; - uint32_t flash_status; - uint32_t clrfstatus; - uint32_t clrrstatus; - } data; - } *dma_buffer; - dmov_s *cmd; - unsigned page = 0; - - if (mtd->writesize == 2048) - page = instr->addr >> 11; - - if (mtd->writesize == 4096) - page = instr->addr >> 12; - - if (instr->addr & (mtd->erasesize - 1)) { - pr_err("%s: unsupported erase address, 0x%llx\n", - __func__, instr->addr); - return -EINVAL; - } - if (instr->len != mtd->erasesize) { - pr_err("%s: unsupported erase len, %lld\n", - __func__, instr->len); - return -EINVAL; - } - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer( - chip, sizeof(*dma_buffer)))); - - cmd = dma_buffer->cmd; - - dma_buffer->data.cmd = MSM_NAND_CMD_BLOCK_ERASE; - dma_buffer->data.addr0 = page; - dma_buffer->data.addr1 = 0; - dma_buffer->data.chipsel = 0 | 4; - dma_buffer->data.exec = 1; - dma_buffer->data.flash_status = 0xeeeeeeee; - dma_buffer->data.cfg0 = chip->CFG0 & (~(7 << 6)); /* CW_PER_PAGE = 0 */ - dma_buffer->data.cfg1 = chip->CFG1; - dma_buffer->data.clrfstatus = 0x00000020; - dma_buffer->data.clrrstatus = 0x000000C0; - - cmd->cmd = DST_CRCI_NAND_CMD | CMD_OCB; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = MSM_NAND_FLASH_CMD; - cmd->len = 16; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); - cmd->dst = MSM_NAND_DEV0_CFG0; - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = MSM_NAND_EXEC_CMD; - cmd->len = 4; - cmd++; - - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_FLASH_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrfstatus); - cmd->dst = MSM_NAND_FLASH_STATUS; - cmd->len = 4; - cmd++; - - cmd->cmd = CMD_OCU | CMD_LC; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrrstatus); - cmd->dst = MSM_NAND_READ_STATUS; - cmd->len = 4; - cmd++; - - BUILD_BUG_ON(5 != ARRAY_SIZE(dma_buffer->cmd) - 1); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmdptr = - (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd( - chip->dma_channel, DMOV_CMD_PTR_LIST | - DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - /* we fail if there was an operation error, a mpu error, or the - * erase success bit was not set. - */ - - if (dma_buffer->data.flash_status & 0x110 || - !(dma_buffer->data.flash_status & 0x80)) - err = -EIO; - else - err = 0; - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - if (err) { - pr_err("%s: erase failed, 0x%llx\n", __func__, instr->addr); - instr->fail_addr = instr->addr; - instr->state = MTD_ERASE_FAILED; - } else { - instr->state = MTD_ERASE_DONE; - instr->fail_addr = 0xffffffff; - mtd_erase_callback(instr); - } - return err; -} - -static int -msm_nand_erase_dualnandc(struct mtd_info *mtd, struct erase_info *instr) -{ - int err; - struct msm_nand_chip *chip = mtd->priv; - struct { - dmov_s cmd[18]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t addr0; - uint32_t addr1; - uint32_t chipsel_cs0; - uint32_t chipsel_cs1; - uint32_t cfg0; - uint32_t cfg1; - uint32_t exec; - uint32_t ecccfg; - uint32_t ebi2_chip_select_cfg0; - uint32_t adm_mux_data_ack_req_nc01; - uint32_t adm_mux_cmd_ack_req_nc01; - uint32_t adm_mux_data_ack_req_nc10; - uint32_t adm_mux_cmd_ack_req_nc10; - uint32_t adm_default_mux; - uint32_t default_ebi2_chip_select_cfg0; - uint32_t nc01_flash_dev_cmd0; - uint32_t nc01_flash_dev_cmd0_default; - uint32_t flash_status[2]; - uint32_t clrfstatus; - uint32_t clrrstatus; - } data; - } *dma_buffer; - dmov_s *cmd; - unsigned page = 0; - - if (mtd->writesize == 2048) - page = instr->addr >> 11; - - if (mtd->writesize == 4096) - page = instr->addr >> 12; - - if (mtd->writesize == 8192) - page = (instr->addr >> 1) >> 12; - - if (instr->addr & (mtd->erasesize - 1)) { - pr_err("%s: unsupported erase address, 0x%llx\n", - __func__, instr->addr); - return -EINVAL; - } - if (instr->len != mtd->erasesize) { - pr_err("%s: unsupported erase len, %lld\n", - __func__, instr->len); - return -EINVAL; - } - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer( - chip, sizeof(*dma_buffer)))); - - cmd = dma_buffer->cmd; - - dma_buffer->data.cmd = MSM_NAND_CMD_BLOCK_ERASE; - dma_buffer->data.addr0 = page; - dma_buffer->data.addr1 = 0; - dma_buffer->data.chipsel_cs0 = (1<<4) | 4; - dma_buffer->data.chipsel_cs1 = (1<<4) | 5; - dma_buffer->data.exec = 1; - dma_buffer->data.flash_status[0] = 0xeeeeeeee; - dma_buffer->data.flash_status[1] = 0xeeeeeeee; - dma_buffer->data.cfg0 = chip->CFG0 & (~(7 << 6)); /* CW_PER_PAGE = 0 */ - dma_buffer->data.cfg1 = chip->CFG1; - dma_buffer->data.clrfstatus = 0x00000020; - dma_buffer->data.clrrstatus = 0x000000C0; - - dma_buffer->data.ebi2_chip_select_cfg0 = 0x00000805; - dma_buffer->data.adm_mux_data_ack_req_nc01 = 0x00000A3C; - dma_buffer->data.adm_mux_cmd_ack_req_nc01 = 0x0000053C; - dma_buffer->data.adm_mux_data_ack_req_nc10 = 0x00000F28; - dma_buffer->data.adm_mux_cmd_ack_req_nc10 = 0x00000F14; - dma_buffer->data.adm_default_mux = 0x00000FC0; - dma_buffer->data.default_ebi2_chip_select_cfg0 = 0x00000801; - - /* enable CS1 */ - cmd->cmd = 0 | CMD_OCB; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - - /* erase CS0 block now !!! */ - /* 0xF14 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_cmd_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = NC01(MSM_NAND_FLASH_CMD); - cmd->len = 16; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); - cmd->dst = NC01(MSM_NAND_DEV0_CFG0); - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = NC01(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - - /* 0xF28 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_data_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC01(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status[0]); - cmd->len = 4; - cmd++; - - /* erase CS1 block now !!! */ - /* 0x53C */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_cmd_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = NC10(MSM_NAND_FLASH_CMD); - cmd->len = 12; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.chipsel_cs1); - cmd->dst = NC10(MSM_NAND_FLASH_CHIP_SELECT); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); - cmd->dst = NC10(MSM_NAND_DEV1_CFG0); - cmd->len = 8; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = NC10(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - - /* 0xA3C */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_data_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC10(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.flash_status[1]); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrfstatus); - cmd->dst = NC11(MSM_NAND_FLASH_STATUS); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.clrrstatus); - cmd->dst = NC11(MSM_NAND_READ_STATUS); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_default_mux); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* disable CS1 */ - cmd->cmd = CMD_OCU | CMD_LC; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.default_ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - - BUILD_BUG_ON(17 != ARRAY_SIZE(dma_buffer->cmd) - 1); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - - dma_buffer->cmdptr = - (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd( - chip->dma_channel, DMOV_CMD_PTR_LIST | - DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - /* we fail if there was an operation error, a mpu error, or the - * erase success bit was not set. - */ - - if (dma_buffer->data.flash_status[0] & 0x110 || - !(dma_buffer->data.flash_status[0] & 0x80) || - dma_buffer->data.flash_status[1] & 0x110 || - !(dma_buffer->data.flash_status[1] & 0x80)) - err = -EIO; - else - err = 0; - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - if (err) { - pr_err("%s: erase failed, 0x%llx\n", __func__, instr->addr); - instr->fail_addr = instr->addr; - instr->state = MTD_ERASE_FAILED; - } else { - instr->state = MTD_ERASE_DONE; - instr->fail_addr = 0xffffffff; - mtd_erase_callback(instr); - } - return err; -} - -static int -msm_nand_block_isbad(struct mtd_info *mtd, loff_t ofs) -{ - struct msm_nand_chip *chip = mtd->priv; - int ret; - struct { - dmov_s cmd[5]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t addr0; - uint32_t addr1; - uint32_t chipsel; - uint32_t cfg0; - uint32_t cfg1; - uint32_t eccbchcfg; - uint32_t exec; - uint32_t ecccfg; - struct { - uint32_t flash_status; - uint32_t buffer_status; - } result; - } data; - } *dma_buffer; - dmov_s *cmd; - uint8_t *buf; - unsigned page = 0; - unsigned cwperpage; - - if (mtd->writesize == 2048) - page = ofs >> 11; - - if (mtd->writesize == 4096) - page = ofs >> 12; - - cwperpage = (mtd->writesize >> 9); - - /* Check for invalid offset */ - if (ofs > mtd->size) - return -EINVAL; - if (ofs & (mtd->erasesize - 1)) { - pr_err("%s: unsupported block address, 0x%x\n", - __func__, (uint32_t)ofs); - return -EINVAL; - } - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer(chip , - sizeof(*dma_buffer) + 4))); - buf = (uint8_t *)dma_buffer + sizeof(*dma_buffer); - - /* Read 4 bytes starting from the bad block marker location - * in the last code word of the page - */ - - cmd = dma_buffer->cmd; - - dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; - dma_buffer->data.cfg0 = chip->CFG0_RAW & ~(7U << 6); - dma_buffer->data.cfg1 = chip->CFG1_RAW | - (chip->CFG1 & CFG1_WIDE_FLASH); - if (enable_bch_ecc) - dma_buffer->data.eccbchcfg = chip->ecc_bch_cfg; - - if (chip->CFG1 & CFG1_WIDE_FLASH) - dma_buffer->data.addr0 = (page << 16) | - ((chip->cw_size * (cwperpage-1)) >> 1); - else - dma_buffer->data.addr0 = (page << 16) | - (chip->cw_size * (cwperpage-1)); - - dma_buffer->data.addr1 = (page >> 16) & 0xff; - dma_buffer->data.chipsel = 0 | 4; - - dma_buffer->data.exec = 1; - - dma_buffer->data.result.flash_status = 0xeeeeeeee; - dma_buffer->data.result.buffer_status = 0xeeeeeeee; - - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = MSM_NAND_FLASH_CMD; - cmd->len = 16; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); - cmd->dst = MSM_NAND_DEV0_CFG0; - if (enable_bch_ecc) - cmd->len = 12; - else - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = MSM_NAND_EXEC_CMD; - cmd->len = 4; - cmd++; - - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_FLASH_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result); - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = MSM_NAND_FLASH_BUFFER + - (mtd->writesize - (chip->cw_size * (cwperpage-1))); - cmd->dst = msm_virt_to_dma(chip, buf); - cmd->len = 4; - cmd++; - - BUILD_BUG_ON(5 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, - dma_buffer->cmd) >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, DMOV_CMD_PTR_LIST | - DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - ret = 0; - if (dma_buffer->data.result.flash_status & 0x110) - ret = -EIO; - - if (!ret) { - /* Check for bad block marker byte */ - if (chip->CFG1 & CFG1_WIDE_FLASH) { - if (buf[0] != 0xFF || buf[1] != 0xFF) - ret = 1; - } else { - if (buf[0] != 0xFF) - ret = 1; - } - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer) + 4); - return ret; -} - -static int -msm_nand_block_isbad_dualnandc(struct mtd_info *mtd, loff_t ofs) -{ - struct msm_nand_chip *chip = mtd->priv; - int ret; - struct { - dmov_s cmd[18]; - unsigned cmdptr; - struct { - uint32_t cmd; - uint32_t addr0; - uint32_t addr1; - uint32_t chipsel_cs0; - uint32_t chipsel_cs1; - uint32_t cfg0; - uint32_t cfg1; - uint32_t exec; - uint32_t ecccfg; - uint32_t ebi2_chip_select_cfg0; - uint32_t adm_mux_data_ack_req_nc01; - uint32_t adm_mux_cmd_ack_req_nc01; - uint32_t adm_mux_data_ack_req_nc10; - uint32_t adm_mux_cmd_ack_req_nc10; - uint32_t adm_default_mux; - uint32_t default_ebi2_chip_select_cfg0; - struct { - uint32_t flash_status; - uint32_t buffer_status; - } result[2]; - } data; - } *dma_buffer; - dmov_s *cmd; - uint8_t *buf01; - uint8_t *buf10; - unsigned page = 0; - unsigned cwperpage; - - if (mtd->writesize == 2048) - page = ofs >> 11; - - if (mtd->writesize == 4096) - page = ofs >> 12; - - if (mtd->writesize == 8192) - page = (ofs >> 1) >> 12; - - cwperpage = ((mtd->writesize >> 1) >> 9); - - /* Check for invalid offset */ - if (ofs > mtd->size) - return -EINVAL; - if (ofs & (mtd->erasesize - 1)) { - pr_err("%s: unsupported block address, 0x%x\n", - __func__, (uint32_t)ofs); - return -EINVAL; - } - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer(chip , - sizeof(*dma_buffer) + 8))); - buf01 = (uint8_t *)dma_buffer + sizeof(*dma_buffer); - buf10 = buf01 + 4; - - /* Read 4 bytes starting from the bad block marker location - * in the last code word of the page - */ - cmd = dma_buffer->cmd; - - dma_buffer->data.cmd = MSM_NAND_CMD_PAGE_READ; - dma_buffer->data.cfg0 = chip->CFG0_RAW & ~(7U << 6); - dma_buffer->data.cfg1 = chip->CFG1_RAW | - (chip->CFG1 & CFG1_WIDE_FLASH); - - if (chip->CFG1 & CFG1_WIDE_FLASH) - dma_buffer->data.addr0 = (page << 16) | - ((528*(cwperpage-1)) >> 1); - else - dma_buffer->data.addr0 = (page << 16) | - (528*(cwperpage-1)); - - dma_buffer->data.addr1 = (page >> 16) & 0xff; - dma_buffer->data.chipsel_cs0 = (1<<4) | 4; - dma_buffer->data.chipsel_cs1 = (1<<4) | 5; - - dma_buffer->data.exec = 1; - - dma_buffer->data.result[0].flash_status = 0xeeeeeeee; - dma_buffer->data.result[0].buffer_status = 0xeeeeeeee; - dma_buffer->data.result[1].flash_status = 0xeeeeeeee; - dma_buffer->data.result[1].buffer_status = 0xeeeeeeee; - - dma_buffer->data.ebi2_chip_select_cfg0 = 0x00000805; - dma_buffer->data.adm_mux_data_ack_req_nc01 = 0x00000A3C; - dma_buffer->data.adm_mux_cmd_ack_req_nc01 = 0x0000053C; - dma_buffer->data.adm_mux_data_ack_req_nc10 = 0x00000F28; - dma_buffer->data.adm_mux_cmd_ack_req_nc10 = 0x00000F14; - dma_buffer->data.adm_default_mux = 0x00000FC0; - dma_buffer->data.default_ebi2_chip_select_cfg0 = 0x00000801; - - /* Reading last code word from NC01 */ - /* enable CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - - /* 0xF14 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_cmd_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = NC01(MSM_NAND_FLASH_CMD); - cmd->len = 16; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); - cmd->dst = NC01(MSM_NAND_DEV0_CFG0); - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = NC01(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - - /* 0xF28 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_data_ack_req_nc10); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC01(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[0]); - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = NC01(MSM_NAND_FLASH_BUFFER) + ((mtd->writesize >> 1) - - (528*(cwperpage-1))); - cmd->dst = msm_virt_to_dma(chip, buf01); - cmd->len = 4; - cmd++; - - /* Reading last code word from NC10 */ - /* 0x53C */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_cmd_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = NC10(MSM_NAND_FLASH_CMD); - cmd->len = 12; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.chipsel_cs1); - cmd->dst = NC10(MSM_NAND_FLASH_CHIP_SELECT); - cmd->len = 4; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cfg0); - cmd->dst = NC10(MSM_NAND_DEV1_CFG0); - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = NC10(MSM_NAND_EXEC_CMD); - cmd->len = 4; - cmd++; - - /* A3C */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_mux_data_ack_req_nc01); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = NC10(MSM_NAND_FLASH_STATUS); - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.result[1]); - cmd->len = 8; - cmd++; - - cmd->cmd = 0; - cmd->src = NC10(MSM_NAND_FLASH_BUFFER) + ((mtd->writesize >> 1) - - (528*(cwperpage-1))); - cmd->dst = msm_virt_to_dma(chip, buf10); - cmd->len = 4; - cmd++; - - /* FC0 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.adm_default_mux); - cmd->dst = EBI2_NAND_ADM_MUX; - cmd->len = 4; - cmd++; - - /* disble CS1 */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.ebi2_chip_select_cfg0); - cmd->dst = EBI2_CHIP_SELECT_CFG0; - cmd->len = 4; - cmd++; - - BUILD_BUG_ON(18 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, - dma_buffer->cmd) >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, DMOV_CMD_PTR_LIST | - DMOV_CMD_ADDR(msm_virt_to_dma(chip, &dma_buffer->cmdptr))); - mb(); - - ret = 0; - if ((dma_buffer->data.result[0].flash_status & 0x110) || - (dma_buffer->data.result[1].flash_status & 0x110)) - ret = -EIO; - - if (!ret) { - /* Check for bad block marker byte for NC01 & NC10 */ - if (chip->CFG1 & CFG1_WIDE_FLASH) { - if ((buf01[0] != 0xFF || buf01[1] != 0xFF) || - (buf10[0] != 0xFF || buf10[1] != 0xFF)) - ret = 1; - } else { - if (buf01[0] != 0xFF || buf10[0] != 0xFF) - ret = 1; - } - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer) + 8); - return ret; -} - -static int -msm_nand_block_markbad(struct mtd_info *mtd, loff_t ofs) -{ - struct mtd_oob_ops ops; - int ret; - uint8_t *buf; - - /* Check for invalid offset */ - if (ofs > mtd->size) - return -EINVAL; - if (ofs & (mtd->erasesize - 1)) { - pr_err("%s: unsupported block address, 0x%x\n", - __func__, (uint32_t)ofs); - return -EINVAL; - } - - /* - Write all 0s to the first page - This will set the BB marker to 0 - */ - buf = page_address(ZERO_PAGE()); - - ops.mode = MTD_OPS_RAW; - ops.len = mtd->writesize + mtd->oobsize; - ops.retlen = 0; - ops.ooblen = 0; - ops.datbuf = buf; - ops.oobbuf = NULL; - if (!interleave_enable) - ret = msm_nand_write_oob(mtd, ofs, &ops); - else - ret = msm_nand_write_oob_dualnandc(mtd, ofs, &ops); - - return ret; -} - -/** - * msm_nand_suspend - [MTD Interface] Suspend the msm_nand flash - * @param mtd MTD device structure - */ -static int msm_nand_suspend(struct mtd_info *mtd) -{ - return 0; -} - -/** - * msm_nand_resume - [MTD Interface] Resume the msm_nand flash - * @param mtd MTD device structure - */ -static void msm_nand_resume(struct mtd_info *mtd) -{ -} - -struct onenand_information { - uint16_t manufacturer_id; - uint16_t device_id; - uint16_t version_id; - uint16_t data_buf_size; - uint16_t boot_buf_size; - uint16_t num_of_buffers; - uint16_t technology; -}; - -static struct onenand_information onenand_info; -static uint32_t nand_sfcmd_mode; - -uint32_t flash_onenand_probe(struct msm_nand_chip *chip) -{ - struct { - dmov_s cmd[7]; - unsigned cmdptr; - struct { - uint32_t bcfg; - uint32_t cmd; - uint32_t exec; - uint32_t status; - uint32_t addr0; - uint32_t addr1; - uint32_t addr2; - uint32_t addr3; - uint32_t addr4; - uint32_t addr5; - uint32_t addr6; - uint32_t data0; - uint32_t data1; - uint32_t data2; - uint32_t data3; - uint32_t data4; - uint32_t data5; - uint32_t data6; - } data; - } *dma_buffer; - dmov_s *cmd; - - int err = 0; - uint32_t initialsflashcmd = 0; - - initialsflashcmd = flash_rd_reg(chip, MSM_NAND_SFLASHC_CMD); - - if ((initialsflashcmd & 0x10) == 0x10) - nand_sfcmd_mode = MSM_NAND_SFCMD_ASYNC; - else - nand_sfcmd_mode = MSM_NAND_SFCMD_BURST; - - printk(KERN_INFO "SFLASHC Async Mode bit: %x \n", nand_sfcmd_mode); - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - cmd = dma_buffer->cmd; - - dma_buffer->data.bcfg = SFLASH_BCFG | - (nand_sfcmd_mode ? 0 : (1 << 24)); - dma_buffer->data.cmd = SFLASH_PREPCMD(7, 0, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGRD); - dma_buffer->data.exec = 1; - dma_buffer->data.status = CLEAN_DATA_32; - dma_buffer->data.addr0 = (ONENAND_DEVICE_ID << 16) | - (ONENAND_MANUFACTURER_ID); - dma_buffer->data.addr1 = (ONENAND_DATA_BUFFER_SIZE << 16) | - (ONENAND_VERSION_ID); - dma_buffer->data.addr2 = (ONENAND_AMOUNT_OF_BUFFERS << 16) | - (ONENAND_BOOT_BUFFER_SIZE); - dma_buffer->data.addr3 = (CLEAN_DATA_16 << 16) | - (ONENAND_TECHNOLOGY << 0); - dma_buffer->data.data0 = CLEAN_DATA_32; - dma_buffer->data.data1 = CLEAN_DATA_32; - dma_buffer->data.data2 = CLEAN_DATA_32; - dma_buffer->data.data3 = CLEAN_DATA_32; - - /* Enable and configure the SFlash controller */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.bcfg); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.cmd); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Configure the ADDR0 and ADDR1 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); - cmd->dst = MSM_NAND_ADDR0; - cmd->len = 8; - cmd++; - - /* Configure the ADDR2 and ADDR3 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); - cmd->dst = MSM_NAND_ADDR2; - cmd->len = 8; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.exec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the two status registers */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.status); - cmd->len = 4; - cmd++; - - /* Read data registers - valid only if status says success */ - cmd->cmd = 0; - cmd->src = MSM_NAND_GENP_REG0; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data0); - cmd->len = 16; - cmd++; - - BUILD_BUG_ON(7 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) - >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, DMOV_CMD_PTR_LIST - | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - /* Check for errors, protection violations etc */ - if (dma_buffer->data.status & 0x110) { - pr_info("%s: MPU/OP error" - "(0x%x) during Onenand probe\n", - __func__, dma_buffer->data.status); - err = -EIO; - } else { - - onenand_info.manufacturer_id = - (dma_buffer->data.data0 >> 0) & 0x0000FFFF; - onenand_info.device_id = - (dma_buffer->data.data0 >> 16) & 0x0000FFFF; - onenand_info.version_id = - (dma_buffer->data.data1 >> 0) & 0x0000FFFF; - onenand_info.data_buf_size = - (dma_buffer->data.data1 >> 16) & 0x0000FFFF; - onenand_info.boot_buf_size = - (dma_buffer->data.data2 >> 0) & 0x0000FFFF; - onenand_info.num_of_buffers = - (dma_buffer->data.data2 >> 16) & 0x0000FFFF; - onenand_info.technology = - (dma_buffer->data.data3 >> 0) & 0x0000FFFF; - - - pr_info("=======================================" - "==========================\n"); - - pr_info("%s: manufacturer_id = 0x%x\n" - , __func__, onenand_info.manufacturer_id); - pr_info("%s: device_id = 0x%x\n" - , __func__, onenand_info.device_id); - pr_info("%s: version_id = 0x%x\n" - , __func__, onenand_info.version_id); - pr_info("%s: data_buf_size = 0x%x\n" - , __func__, onenand_info.data_buf_size); - pr_info("%s: boot_buf_size = 0x%x\n" - , __func__, onenand_info.boot_buf_size); - pr_info("%s: num_of_buffers = 0x%x\n" - , __func__, onenand_info.num_of_buffers); - pr_info("%s: technology = 0x%x\n" - , __func__, onenand_info.technology); - - pr_info("=======================================" - "==========================\n"); - - if ((onenand_info.manufacturer_id != 0x00EC) - || ((onenand_info.device_id & 0x0040) != 0x0040) - || (onenand_info.data_buf_size != 0x0800) - || (onenand_info.boot_buf_size != 0x0200) - || (onenand_info.num_of_buffers != 0x0201) - || (onenand_info.technology != 0)) { - - pr_info("%s: Detected an unsupported device\n" - , __func__); - err = -EIO; - } - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - return err; -} - -int msm_onenand_read_oob(struct mtd_info *mtd, - loff_t from, struct mtd_oob_ops *ops) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[53]; - unsigned cmdptr; - struct { - uint32_t sfbcfg; - uint32_t sfcmd[9]; - uint32_t sfexec; - uint32_t sfstat[9]; - uint32_t addr0; - uint32_t addr1; - uint32_t addr2; - uint32_t addr3; - uint32_t addr4; - uint32_t addr5; - uint32_t addr6; - uint32_t data0; - uint32_t data1; - uint32_t data2; - uint32_t data3; - uint32_t data4; - uint32_t data5; - uint32_t data6; - uint32_t macro[5]; - } data; - } *dma_buffer; - dmov_s *cmd; - - int err = 0; - int i; - dma_addr_t data_dma_addr = 0; - dma_addr_t oob_dma_addr = 0; - dma_addr_t data_dma_addr_curr = 0; - dma_addr_t oob_dma_addr_curr = 0; - - loff_t from_curr = 0; - unsigned page_count; - unsigned pages_read = 0; - - uint16_t onenand_startaddr1; - uint16_t onenand_startaddr8; - uint16_t onenand_startaddr2; - uint16_t onenand_startbuffer; - uint16_t onenand_sysconfig1; - uint16_t controller_status; - uint16_t interrupt_status; - uint16_t ecc_status; -#if VERBOSE - pr_info("=================================================" - "================\n"); - pr_info("%s: from 0x%llx mode %d \ndatbuf 0x%p datlen 0x%x" - "\noobbuf 0x%p ooblen 0x%x\n", - __func__, from, ops->mode, ops->datbuf, ops->len, - ops->oobbuf, ops->ooblen); -#endif - if (!mtd) { - pr_err("%s: invalid mtd pointer, 0x%x\n", __func__, - (uint32_t)mtd); - return -EINVAL; - } - if (from & (mtd->writesize - 1)) { - pr_err("%s: unsupported from, 0x%llx\n", __func__, - from); - return -EINVAL; - } - - if ((ops->mode != MTD_OPS_PLACE_OOB) && (ops->mode != MTD_OPS_AUTO_OOB) && - (ops->mode != MTD_OPS_RAW)) { - pr_err("%s: unsupported ops->mode, %d\n", __func__, - ops->mode); - return -EINVAL; - } - - if (((ops->datbuf == NULL) || (ops->len == 0)) && - ((ops->oobbuf == NULL) || (ops->ooblen == 0))) { - pr_err("%s: incorrect ops fields - nothing to do\n", - __func__); - return -EINVAL; - } - - if ((ops->datbuf != NULL) && (ops->len == 0)) { - pr_err("%s: data buffer passed but length 0\n", - __func__); - return -EINVAL; - } - - if ((ops->oobbuf != NULL) && (ops->ooblen == 0)) { - pr_err("%s: oob buffer passed but length 0\n", - __func__); - return -EINVAL; - } - - if (ops->mode != MTD_OPS_RAW) { - if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { - /* when ops->datbuf is NULL, ops->len can be ooblen */ - pr_err("%s: unsupported ops->len, %d\n", __func__, - ops->len); - return -EINVAL; - } - } else { - if (ops->datbuf != NULL && - (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { - pr_err("%s: unsupported ops->len," - " %d for MTD_OPS_RAW\n", __func__, ops->len); - return -EINVAL; - } - } - - if ((ops->mode == MTD_OPS_RAW) && (ops->oobbuf)) { - pr_err("%s: unsupported operation, oobbuf pointer " - "passed in for RAW mode, %x\n", __func__, - (uint32_t)ops->oobbuf); - return -EINVAL; - } - - if (ops->oobbuf && !ops->datbuf) { - page_count = ops->ooblen / ((ops->mode == MTD_OPS_AUTO_OOB) ? - mtd->oobavail : mtd->oobsize); - if ((page_count == 0) && (ops->ooblen)) - page_count = 1; - } else if (ops->mode != MTD_OPS_RAW) - page_count = ops->len / mtd->writesize; - else - page_count = ops->len / (mtd->writesize + mtd->oobsize); - - if ((ops->mode == MTD_OPS_PLACE_OOB) && (ops->oobbuf != NULL)) { - if (page_count * mtd->oobsize > ops->ooblen) { - pr_err("%s: unsupported ops->ooblen for " - "PLACE, %d\n", __func__, ops->ooblen); - return -EINVAL; - } - } - - if ((ops->mode == MTD_OPS_PLACE_OOB) && (ops->ooblen != 0) && - (ops->ooboffs != 0)) { - pr_err("%s: unsupported ops->ooboffs, %d\n", __func__, - ops->ooboffs); - return -EINVAL; - } - - if (ops->datbuf) { - memset(ops->datbuf, 0x55, ops->len); - data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, - ops->datbuf, ops->len, DMA_FROM_DEVICE); - if (dma_mapping_error(chip->dev, data_dma_addr)) { - pr_err("%s: failed to get dma addr for %p\n", - __func__, ops->datbuf); - return -EIO; - } - } - if (ops->oobbuf) { - memset(ops->oobbuf, 0x55, ops->ooblen); - oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, - ops->oobbuf, ops->ooblen, DMA_FROM_DEVICE); - if (dma_mapping_error(chip->dev, oob_dma_addr)) { - pr_err("%s: failed to get dma addr for %p\n", - __func__, ops->oobbuf); - err = -EIO; - goto err_dma_map_oobbuf_failed; - } - } - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - from_curr = from; - - while (page_count-- > 0) { - - cmd = dma_buffer->cmd; - - if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) - && (from_curr >= (mtd->size>>1))) { /* DDP Device */ - onenand_startaddr1 = DEVICE_FLASHCORE_1 | - (((uint32_t)(from_curr-(mtd->size>>1)) - / mtd->erasesize)); - onenand_startaddr2 = DEVICE_BUFFERRAM_1; - } else { - onenand_startaddr1 = DEVICE_FLASHCORE_0 | - ((uint32_t)from_curr / mtd->erasesize) ; - onenand_startaddr2 = DEVICE_BUFFERRAM_0; - } - - onenand_startaddr8 = (((uint32_t)from_curr & - (mtd->erasesize - 1)) / mtd->writesize) << 2; - onenand_startbuffer = DATARAM0_0 << 8; - onenand_sysconfig1 = (ops->mode == MTD_OPS_RAW) ? - ONENAND_SYSCFG1_ECCDIS(nand_sfcmd_mode) : - ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode); - - dma_buffer->data.sfbcfg = SFLASH_BCFG | - (nand_sfcmd_mode ? 0 : (1 << 24)); - dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_INTHI); - dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGRD); - dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATRD); - dma_buffer->data.sfcmd[4] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATRD); - dma_buffer->data.sfcmd[5] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATRD); - dma_buffer->data.sfcmd[6] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATRD); - dma_buffer->data.sfcmd[7] = SFLASH_PREPCMD(32, 0, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATRD); - dma_buffer->data.sfcmd[8] = SFLASH_PREPCMD(4, 10, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfexec = 1; - dma_buffer->data.sfstat[0] = CLEAN_DATA_32; - dma_buffer->data.sfstat[1] = CLEAN_DATA_32; - dma_buffer->data.sfstat[2] = CLEAN_DATA_32; - dma_buffer->data.sfstat[3] = CLEAN_DATA_32; - dma_buffer->data.sfstat[4] = CLEAN_DATA_32; - dma_buffer->data.sfstat[5] = CLEAN_DATA_32; - dma_buffer->data.sfstat[6] = CLEAN_DATA_32; - dma_buffer->data.sfstat[7] = CLEAN_DATA_32; - dma_buffer->data.sfstat[8] = CLEAN_DATA_32; - dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.addr2 = (ONENAND_START_BUFFER << 16) | - (ONENAND_START_ADDRESS_2); - dma_buffer->data.addr3 = (ONENAND_ECC_STATUS << 16) | - (ONENAND_COMMAND); - dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | - (ONENAND_INTERRUPT_STATUS); - dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | - (onenand_sysconfig1); - dma_buffer->data.data1 = (onenand_startaddr8 << 16) | - (onenand_startaddr1); - dma_buffer->data.data2 = (onenand_startbuffer << 16) | - (onenand_startaddr2); - dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | - (ONENAND_CMDLOADSPARE); - dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | - (CLEAN_DATA_16); - dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | - (ONENAND_STARTADDR1_RES); - dma_buffer->data.macro[0] = 0x0200; - dma_buffer->data.macro[1] = 0x0300; - dma_buffer->data.macro[2] = 0x0400; - dma_buffer->data.macro[3] = 0x0500; - dma_buffer->data.macro[4] = 0x8010; - - /*************************************************************/ - /* Write necessary address registers in the onenand device */ - /*************************************************************/ - - /* Enable and configure the SFlash controller */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Write the ADDR0 and ADDR1 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); - cmd->dst = MSM_NAND_ADDR0; - cmd->len = 8; - cmd++; - - /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); - cmd->dst = MSM_NAND_ADDR2; - cmd->len = 16; - cmd++; - - /* Write the ADDR6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); - cmd->dst = MSM_NAND_ADDR6; - cmd->len = 4; - cmd++; - - /* Write the GENP0, GENP1, GENP2, GENP3 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); - cmd->dst = MSM_NAND_GENP_REG0; - cmd->len = 16; - cmd++; - - /* Write the FLASH_DEV_CMD4,5,6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->dst = MSM_NAND_DEV_CMD4; - cmd->len = 12; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Wait for the interrupt from the Onenand device controller */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Read necessary status registers from the onenand device */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); - cmd->len = 4; - cmd++; - - /* Read the GENP3 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_GENP_REG3; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); - cmd->len = 4; - cmd++; - - /* Read the DEVCMD4 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_DEV_CMD4; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Read the data ram area from the onenand buffer ram */ - /*************************************************************/ - - if (ops->datbuf) { - - dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | - (ONENAND_CMDLOAD); - - for (i = 0; i < 4; i++) { - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sfcmd[3+i]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Write the MACRO1 register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.macro[i]); - cmd->dst = MSM_NAND_MACRO1_REG; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data rdy, & read status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.sfstat[3+i]); - cmd->len = 4; - cmd++; - - /* Transfer nand ctlr buf contents to usr buf */ - cmd->cmd = 0; - cmd->src = MSM_NAND_FLASH_BUFFER; - cmd->dst = data_dma_addr_curr; - cmd->len = 512; - data_dma_addr_curr += 512; - cmd++; - } - } - - if ((ops->oobbuf) || (ops->mode == MTD_OPS_RAW)) { - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sfcmd[7]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Write the MACRO1 register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.macro[4]); - cmd->dst = MSM_NAND_MACRO1_REG; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.sfstat[7]); - cmd->len = 4; - cmd++; - - /* Transfer nand ctlr buffer contents into usr buf */ - if (ops->mode == MTD_OPS_AUTO_OOB) { - for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) { - cmd->cmd = 0; - cmd->src = MSM_NAND_FLASH_BUFFER + - mtd->ecclayout->oobfree[i].offset; - cmd->dst = oob_dma_addr_curr; - cmd->len = - mtd->ecclayout->oobfree[i].length; - oob_dma_addr_curr += - mtd->ecclayout->oobfree[i].length; - cmd++; - } - } - if (ops->mode == MTD_OPS_PLACE_OOB) { - cmd->cmd = 0; - cmd->src = MSM_NAND_FLASH_BUFFER; - cmd->dst = oob_dma_addr_curr; - cmd->len = mtd->oobsize; - oob_dma_addr_curr += mtd->oobsize; - cmd++; - } - if (ops->mode == MTD_OPS_RAW) { - cmd->cmd = 0; - cmd->src = MSM_NAND_FLASH_BUFFER; - cmd->dst = data_dma_addr_curr; - cmd->len = mtd->oobsize; - data_dma_addr_curr += mtd->oobsize; - cmd++; - } - } - - /*************************************************************/ - /* Restore the necessary registers to proper values */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[8]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[8]); - cmd->len = 4; - cmd++; - - - BUILD_BUG_ON(53 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) - >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - ecc_status = (dma_buffer->data.data3 >> 16) & - 0x0000FFFF; - interrupt_status = (dma_buffer->data.data4 >> 0) & - 0x0000FFFF; - controller_status = (dma_buffer->data.data4 >> 16) & - 0x0000FFFF; - -#if VERBOSE - pr_info("\n%s: sflash status %x %x %x %x %x %x %x" - "%x %x\n", __func__, - dma_buffer->data.sfstat[0], - dma_buffer->data.sfstat[1], - dma_buffer->data.sfstat[2], - dma_buffer->data.sfstat[3], - dma_buffer->data.sfstat[4], - dma_buffer->data.sfstat[5], - dma_buffer->data.sfstat[6], - dma_buffer->data.sfstat[7], - dma_buffer->data.sfstat[8]); - - pr_info("%s: controller_status = %x\n", __func__, - controller_status); - pr_info("%s: interrupt_status = %x\n", __func__, - interrupt_status); - pr_info("%s: ecc_status = %x\n", __func__, - ecc_status); -#endif - /* Check for errors, protection violations etc */ - if ((controller_status != 0) - || (dma_buffer->data.sfstat[0] & 0x110) - || (dma_buffer->data.sfstat[1] & 0x110) - || (dma_buffer->data.sfstat[2] & 0x110) - || (dma_buffer->data.sfstat[8] & 0x110) - || ((dma_buffer->data.sfstat[3] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[4] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[5] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[6] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[7] & 0x110) && - ((ops->oobbuf) - || (ops->mode == MTD_OPS_RAW)))) { - pr_info("%s: ECC/MPU/OP error\n", __func__); - err = -EIO; - } - - if (err) - break; - pages_read++; - from_curr += mtd->writesize; - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - if (ops->oobbuf) { - dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, - DMA_FROM_DEVICE); - } -err_dma_map_oobbuf_failed: - if (ops->datbuf) { - dma_unmap_page(chip->dev, data_dma_addr, ops->len, - DMA_FROM_DEVICE); - } - - if (err) { - pr_err("%s: %llx %x %x failed\n", __func__, from_curr, - ops->datbuf ? ops->len : 0, ops->ooblen); - } else { - ops->retlen = ops->oobretlen = 0; - if (ops->datbuf != NULL) { - if (ops->mode != MTD_OPS_RAW) - ops->retlen = mtd->writesize * pages_read; - else - ops->retlen = (mtd->writesize + mtd->oobsize) - * pages_read; - } - if (ops->oobbuf != NULL) { - if (ops->mode == MTD_OPS_AUTO_OOB) - ops->oobretlen = mtd->oobavail * pages_read; - else - ops->oobretlen = mtd->oobsize * pages_read; - } - } - -#if VERBOSE - pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", - __func__, err, ops->retlen, ops->oobretlen); - - pr_info("===================================================" - "==============\n"); -#endif - return err; -} - -int msm_onenand_read(struct mtd_info *mtd, loff_t from, size_t len, - size_t *retlen, u_char *buf) -{ - int ret; - struct mtd_oob_ops ops; - - ops.mode = MTD_OPS_PLACE_OOB; - ops.datbuf = buf; - ops.len = len; - ops.retlen = 0; - ops.oobbuf = NULL; - ops.ooblen = 0; - ops.oobretlen = 0; - ret = msm_onenand_read_oob(mtd, from, &ops); - *retlen = ops.retlen; - - return ret; -} - -static int msm_onenand_write_oob(struct mtd_info *mtd, loff_t to, - struct mtd_oob_ops *ops) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[53]; - unsigned cmdptr; - struct { - uint32_t sfbcfg; - uint32_t sfcmd[10]; - uint32_t sfexec; - uint32_t sfstat[10]; - uint32_t addr0; - uint32_t addr1; - uint32_t addr2; - uint32_t addr3; - uint32_t addr4; - uint32_t addr5; - uint32_t addr6; - uint32_t data0; - uint32_t data1; - uint32_t data2; - uint32_t data3; - uint32_t data4; - uint32_t data5; - uint32_t data6; - uint32_t macro[5]; - } data; - } *dma_buffer; - dmov_s *cmd; - - int err = 0; - int i, j, k; - dma_addr_t data_dma_addr = 0; - dma_addr_t oob_dma_addr = 0; - dma_addr_t init_dma_addr = 0; - dma_addr_t data_dma_addr_curr = 0; - dma_addr_t oob_dma_addr_curr = 0; - uint8_t *init_spare_bytes; - - loff_t to_curr = 0; - unsigned page_count; - unsigned pages_written = 0; - - uint16_t onenand_startaddr1; - uint16_t onenand_startaddr8; - uint16_t onenand_startaddr2; - uint16_t onenand_startbuffer; - uint16_t onenand_sysconfig1; - - uint16_t controller_status; - uint16_t interrupt_status; - uint16_t ecc_status; - -#if VERBOSE - pr_info("=================================================" - "================\n"); - pr_info("%s: to 0x%llx mode %d \ndatbuf 0x%p datlen 0x%x" - "\noobbuf 0x%p ooblen 0x%x\n", - __func__, to, ops->mode, ops->datbuf, ops->len, - ops->oobbuf, ops->ooblen); -#endif - if (!mtd) { - pr_err("%s: invalid mtd pointer, 0x%x\n", __func__, - (uint32_t)mtd); - return -EINVAL; - } - if (to & (mtd->writesize - 1)) { - pr_err("%s: unsupported to, 0x%llx\n", __func__, to); - return -EINVAL; - } - - if ((ops->mode != MTD_OPS_PLACE_OOB) && (ops->mode != MTD_OPS_AUTO_OOB) && - (ops->mode != MTD_OPS_RAW)) { - pr_err("%s: unsupported ops->mode, %d\n", __func__, - ops->mode); - return -EINVAL; - } - - if (((ops->datbuf == NULL) || (ops->len == 0)) && - ((ops->oobbuf == NULL) || (ops->ooblen == 0))) { - pr_err("%s: incorrect ops fields - nothing to do\n", - __func__); - return -EINVAL; - } - - if ((ops->datbuf != NULL) && (ops->len == 0)) { - pr_err("%s: data buffer passed but length 0\n", - __func__); - return -EINVAL; - } - - if ((ops->oobbuf != NULL) && (ops->ooblen == 0)) { - pr_err("%s: oob buffer passed but length 0\n", - __func__); - return -EINVAL; - } - - if (ops->mode != MTD_OPS_RAW) { - if (ops->datbuf != NULL && (ops->len % mtd->writesize) != 0) { - /* when ops->datbuf is NULL, ops->len can be ooblen */ - pr_err("%s: unsupported ops->len, %d\n", __func__, - ops->len); - return -EINVAL; - } - } else { - if (ops->datbuf != NULL && - (ops->len % (mtd->writesize + mtd->oobsize)) != 0) { - pr_err("%s: unsupported ops->len," - " %d for MTD_OPS_RAW\n", __func__, ops->len); - return -EINVAL; - } - } - - if ((ops->mode == MTD_OPS_RAW) && (ops->oobbuf)) { - pr_err("%s: unsupported operation, oobbuf pointer " - "passed in for RAW mode, %x\n", __func__, - (uint32_t)ops->oobbuf); - return -EINVAL; - } - - if (ops->oobbuf && !ops->datbuf) { - page_count = ops->ooblen / ((ops->mode == MTD_OPS_AUTO_OOB) ? - mtd->oobavail : mtd->oobsize); - if ((page_count == 0) && (ops->ooblen)) - page_count = 1; - } else if (ops->mode != MTD_OPS_RAW) - page_count = ops->len / mtd->writesize; - else - page_count = ops->len / (mtd->writesize + mtd->oobsize); - - if ((ops->mode == MTD_OPS_AUTO_OOB) && (ops->oobbuf != NULL)) { - if (page_count > 1) { - pr_err("%s: unsupported ops->ooblen for" - "AUTO, %d\n", __func__, ops->ooblen); - return -EINVAL; - } - } - - if ((ops->mode == MTD_OPS_PLACE_OOB) && (ops->oobbuf != NULL)) { - if (page_count * mtd->oobsize > ops->ooblen) { - pr_err("%s: unsupported ops->ooblen for" - "PLACE, %d\n", __func__, ops->ooblen); - return -EINVAL; - } - } - - if ((ops->mode == MTD_OPS_PLACE_OOB) && (ops->ooblen != 0) && - (ops->ooboffs != 0)) { - pr_err("%s: unsupported ops->ooboffs, %d\n", - __func__, ops->ooboffs); - return -EINVAL; - } - - init_spare_bytes = kmalloc(64, GFP_KERNEL); - if (!init_spare_bytes) { - pr_err("%s: failed to alloc init_spare_bytes buffer\n", - __func__); - return -ENOMEM; - } - for (i = 0; i < 64; i++) - init_spare_bytes[i] = 0xFF; - - if ((ops->oobbuf) && (ops->mode == MTD_OPS_AUTO_OOB)) { - for (i = 0, k = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) - for (j = 0; j < mtd->ecclayout->oobfree[i].length; - j++) { - init_spare_bytes[j + - mtd->ecclayout->oobfree[i].offset] - = (ops->oobbuf)[k]; - k++; - } - } - - if (ops->datbuf) { - data_dma_addr_curr = data_dma_addr = msm_nand_dma_map(chip->dev, - ops->datbuf, ops->len, DMA_TO_DEVICE); - if (dma_mapping_error(chip->dev, data_dma_addr)) { - pr_err("%s: failed to get dma addr for %p\n", - __func__, ops->datbuf); - return -EIO; - } - } - if (ops->oobbuf) { - oob_dma_addr_curr = oob_dma_addr = msm_nand_dma_map(chip->dev, - ops->oobbuf, ops->ooblen, DMA_TO_DEVICE); - if (dma_mapping_error(chip->dev, oob_dma_addr)) { - pr_err("%s: failed to get dma addr for %p\n", - __func__, ops->oobbuf); - err = -EIO; - goto err_dma_map_oobbuf_failed; - } - } - - init_dma_addr = msm_nand_dma_map(chip->dev, init_spare_bytes, 64, - DMA_TO_DEVICE); - if (dma_mapping_error(chip->dev, init_dma_addr)) { - pr_err("%s: failed to get dma addr for %p\n", - __func__, init_spare_bytes); - err = -EIO; - goto err_dma_map_initbuf_failed; - } - - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - to_curr = to; - - while (page_count-- > 0) { - cmd = dma_buffer->cmd; - - if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) - && (to_curr >= (mtd->size>>1))) { /* DDP Device */ - onenand_startaddr1 = DEVICE_FLASHCORE_1 | - (((uint32_t)(to_curr-(mtd->size>>1)) - / mtd->erasesize)); - onenand_startaddr2 = DEVICE_BUFFERRAM_1; - } else { - onenand_startaddr1 = DEVICE_FLASHCORE_0 | - ((uint32_t)to_curr / mtd->erasesize) ; - onenand_startaddr2 = DEVICE_BUFFERRAM_0; - } - - onenand_startaddr8 = (((uint32_t)to_curr & - (mtd->erasesize - 1)) / mtd->writesize) << 2; - onenand_startbuffer = DATARAM0_0 << 8; - onenand_sysconfig1 = (ops->mode == MTD_OPS_RAW) ? - ONENAND_SYSCFG1_ECCDIS(nand_sfcmd_mode) : - ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode); - - dma_buffer->data.sfbcfg = SFLASH_BCFG | - (nand_sfcmd_mode ? 0 : (1 << 24)); - dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(6, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATWR); - dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATWR); - dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATWR); - dma_buffer->data.sfcmd[4] = SFLASH_PREPCMD(256, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATWR); - dma_buffer->data.sfcmd[5] = SFLASH_PREPCMD(32, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_DATWR); - dma_buffer->data.sfcmd[6] = SFLASH_PREPCMD(1, 6, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfcmd[7] = SFLASH_PREPCMD(0, 0, 32, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_INTHI); - dma_buffer->data.sfcmd[8] = SFLASH_PREPCMD(3, 7, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGRD); - dma_buffer->data.sfcmd[9] = SFLASH_PREPCMD(4, 10, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfexec = 1; - dma_buffer->data.sfstat[0] = CLEAN_DATA_32; - dma_buffer->data.sfstat[1] = CLEAN_DATA_32; - dma_buffer->data.sfstat[2] = CLEAN_DATA_32; - dma_buffer->data.sfstat[3] = CLEAN_DATA_32; - dma_buffer->data.sfstat[4] = CLEAN_DATA_32; - dma_buffer->data.sfstat[5] = CLEAN_DATA_32; - dma_buffer->data.sfstat[6] = CLEAN_DATA_32; - dma_buffer->data.sfstat[7] = CLEAN_DATA_32; - dma_buffer->data.sfstat[8] = CLEAN_DATA_32; - dma_buffer->data.sfstat[9] = CLEAN_DATA_32; - dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.addr2 = (ONENAND_START_BUFFER << 16) | - (ONENAND_START_ADDRESS_2); - dma_buffer->data.addr3 = (ONENAND_ECC_STATUS << 16) | - (ONENAND_COMMAND); - dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | - (ONENAND_INTERRUPT_STATUS); - dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | - (onenand_sysconfig1); - dma_buffer->data.data1 = (onenand_startaddr8 << 16) | - (onenand_startaddr1); - dma_buffer->data.data2 = (onenand_startbuffer << 16) | - (onenand_startaddr2); - dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | - (ONENAND_CMDPROGSPARE); - dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | - (CLEAN_DATA_16); - dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | - (ONENAND_STARTADDR1_RES); - dma_buffer->data.macro[0] = 0x0200; - dma_buffer->data.macro[1] = 0x0300; - dma_buffer->data.macro[2] = 0x0400; - dma_buffer->data.macro[3] = 0x0500; - dma_buffer->data.macro[4] = 0x8010; - - - /*************************************************************/ - /* Write necessary address registers in the onenand device */ - /*************************************************************/ - - /* Enable and configure the SFlash controller */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Write the ADDR0 and ADDR1 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); - cmd->dst = MSM_NAND_ADDR0; - cmd->len = 8; - cmd++; - - /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); - cmd->dst = MSM_NAND_ADDR2; - cmd->len = 16; - cmd++; - - /* Write the ADDR6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); - cmd->dst = MSM_NAND_ADDR6; - cmd->len = 4; - cmd++; - - /* Write the GENP0, GENP1, GENP2, GENP3 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); - cmd->dst = MSM_NAND_GENP_REG0; - cmd->len = 16; - cmd++; - - /* Write the FLASH_DEV_CMD4,5,6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->dst = MSM_NAND_DEV_CMD4; - cmd->len = 12; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Write the data ram area in the onenand buffer ram */ - /*************************************************************/ - - if (ops->datbuf) { - dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | - (ONENAND_CMDPROG); - - for (i = 0; i < 4; i++) { - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sfcmd[1+i]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Trnsfr usr buf contents to nand ctlr buf */ - cmd->cmd = 0; - cmd->src = data_dma_addr_curr; - cmd->dst = MSM_NAND_FLASH_BUFFER; - cmd->len = 512; - data_dma_addr_curr += 512; - cmd++; - - /* Write the MACRO1 register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.macro[i]); - cmd->dst = MSM_NAND_MACRO1_REG; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, - &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data rdy, & read status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, - &dma_buffer->data.sfstat[1+i]); - cmd->len = 4; - cmd++; - - } - } - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[5]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - if ((ops->oobbuf) || (ops->mode == MTD_OPS_RAW)) { - - /* Transfer user buf contents into nand ctlr buffer */ - if (ops->mode == MTD_OPS_AUTO_OOB) { - cmd->cmd = 0; - cmd->src = init_dma_addr; - cmd->dst = MSM_NAND_FLASH_BUFFER; - cmd->len = mtd->oobsize; - cmd++; - } - if (ops->mode == MTD_OPS_PLACE_OOB) { - cmd->cmd = 0; - cmd->src = oob_dma_addr_curr; - cmd->dst = MSM_NAND_FLASH_BUFFER; - cmd->len = mtd->oobsize; - oob_dma_addr_curr += mtd->oobsize; - cmd++; - } - if (ops->mode == MTD_OPS_RAW) { - cmd->cmd = 0; - cmd->src = data_dma_addr_curr; - cmd->dst = MSM_NAND_FLASH_BUFFER; - cmd->len = mtd->oobsize; - data_dma_addr_curr += mtd->oobsize; - cmd++; - } - } else { - cmd->cmd = 0; - cmd->src = init_dma_addr; - cmd->dst = MSM_NAND_FLASH_BUFFER; - cmd->len = mtd->oobsize; - cmd++; - } - - /* Write the MACRO1 register */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.macro[4]); - cmd->dst = MSM_NAND_MACRO1_REG; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[5]); - cmd->len = 4; - cmd++; - - /*********************************************************/ - /* Issuing write command */ - /*********************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[6]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[6]); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Wait for the interrupt from the Onenand device controller */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[7]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[7]); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Read necessary status registers from the onenand device */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[8]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[8]); - cmd->len = 4; - cmd++; - - /* Read the GENP3 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_GENP_REG3; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); - cmd->len = 4; - cmd++; - - /* Read the DEVCMD4 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_DEV_CMD4; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Restore the necessary registers to proper values */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[9]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[9]); - cmd->len = 4; - cmd++; - - - BUILD_BUG_ON(53 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) - >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - ecc_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; - interrupt_status = (dma_buffer->data.data4 >> 0)&0x0000FFFF; - controller_status = (dma_buffer->data.data4 >> 16)&0x0000FFFF; - -#if VERBOSE - pr_info("\n%s: sflash status %x %x %x %x %x %x %x" - " %x %x %x\n", __func__, - dma_buffer->data.sfstat[0], - dma_buffer->data.sfstat[1], - dma_buffer->data.sfstat[2], - dma_buffer->data.sfstat[3], - dma_buffer->data.sfstat[4], - dma_buffer->data.sfstat[5], - dma_buffer->data.sfstat[6], - dma_buffer->data.sfstat[7], - dma_buffer->data.sfstat[8], - dma_buffer->data.sfstat[9]); - - pr_info("%s: controller_status = %x\n", __func__, - controller_status); - pr_info("%s: interrupt_status = %x\n", __func__, - interrupt_status); - pr_info("%s: ecc_status = %x\n", __func__, - ecc_status); -#endif - /* Check for errors, protection violations etc */ - if ((controller_status != 0) - || (dma_buffer->data.sfstat[0] & 0x110) - || (dma_buffer->data.sfstat[6] & 0x110) - || (dma_buffer->data.sfstat[7] & 0x110) - || (dma_buffer->data.sfstat[8] & 0x110) - || (dma_buffer->data.sfstat[9] & 0x110) - || ((dma_buffer->data.sfstat[1] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[2] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[3] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[4] & 0x110) && - (ops->datbuf)) - || ((dma_buffer->data.sfstat[5] & 0x110) && - ((ops->oobbuf) - || (ops->mode == MTD_OPS_RAW)))) { - pr_info("%s: ECC/MPU/OP error\n", __func__); - err = -EIO; - } - - if (err) - break; - pages_written++; - to_curr += mtd->writesize; - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - dma_unmap_page(chip->dev, init_dma_addr, 64, DMA_TO_DEVICE); - -err_dma_map_initbuf_failed: - if (ops->oobbuf) { - dma_unmap_page(chip->dev, oob_dma_addr, ops->ooblen, - DMA_TO_DEVICE); - } -err_dma_map_oobbuf_failed: - if (ops->datbuf) { - dma_unmap_page(chip->dev, data_dma_addr, ops->len, - DMA_TO_DEVICE); - } - - if (err) { - pr_err("%s: %llx %x %x failed\n", __func__, to_curr, - ops->datbuf ? ops->len : 0, ops->ooblen); - } else { - ops->retlen = ops->oobretlen = 0; - if (ops->datbuf != NULL) { - if (ops->mode != MTD_OPS_RAW) - ops->retlen = mtd->writesize * pages_written; - else - ops->retlen = (mtd->writesize + mtd->oobsize) - * pages_written; - } - if (ops->oobbuf != NULL) { - if (ops->mode == MTD_OPS_AUTO_OOB) - ops->oobretlen = mtd->oobavail * pages_written; - else - ops->oobretlen = mtd->oobsize * pages_written; - } - } - -#if VERBOSE - pr_info("\n%s: ret %d, retlen %d oobretlen %d\n", - __func__, err, ops->retlen, ops->oobretlen); - - pr_info("=================================================" - "================\n"); -#endif - kfree(init_spare_bytes); - return err; -} - -static int msm_onenand_write(struct mtd_info *mtd, loff_t to, size_t len, - size_t *retlen, const u_char *buf) -{ - int ret; - struct mtd_oob_ops ops; - - ops.mode = MTD_OPS_PLACE_OOB; - ops.datbuf = (uint8_t *)buf; - ops.len = len; - ops.retlen = 0; - ops.oobbuf = NULL; - ops.ooblen = 0; - ops.oobretlen = 0; - ret = msm_onenand_write_oob(mtd, to, &ops); - *retlen = ops.retlen; - - return ret; -} - -static int msm_onenand_erase(struct mtd_info *mtd, struct erase_info *instr) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[20]; - unsigned cmdptr; - struct { - uint32_t sfbcfg; - uint32_t sfcmd[4]; - uint32_t sfexec; - uint32_t sfstat[4]; - uint32_t addr0; - uint32_t addr1; - uint32_t addr2; - uint32_t addr3; - uint32_t addr4; - uint32_t addr5; - uint32_t addr6; - uint32_t data0; - uint32_t data1; - uint32_t data2; - uint32_t data3; - uint32_t data4; - uint32_t data5; - uint32_t data6; - } data; - } *dma_buffer; - dmov_s *cmd; - - int err = 0; - - uint16_t onenand_startaddr1; - uint16_t onenand_startaddr8; - uint16_t onenand_startaddr2; - uint16_t onenand_startbuffer; - - uint16_t controller_status; - uint16_t interrupt_status; - uint16_t ecc_status; - - uint64_t temp; - -#if VERBOSE - pr_info("=================================================" - "================\n"); - pr_info("%s: addr 0x%llx len 0x%llx\n", - __func__, instr->addr, instr->len); -#endif - if (instr->addr & (mtd->erasesize - 1)) { - pr_err("%s: Unsupported erase address, 0x%llx\n", - __func__, instr->addr); - return -EINVAL; - } - if (instr->len != mtd->erasesize) { - pr_err("%s: Unsupported erase len, %lld\n", - __func__, instr->len); - return -EINVAL; - } - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - cmd = dma_buffer->cmd; - - temp = instr->addr; - - if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) - && (temp >= (mtd->size>>1))) { /* DDP Device */ - onenand_startaddr1 = DEVICE_FLASHCORE_1 | - (((uint32_t)(temp-(mtd->size>>1)) - / mtd->erasesize)); - onenand_startaddr2 = DEVICE_BUFFERRAM_1; - } else { - onenand_startaddr1 = DEVICE_FLASHCORE_0 | - ((uint32_t)temp / mtd->erasesize) ; - onenand_startaddr2 = DEVICE_BUFFERRAM_0; - } - - onenand_startaddr8 = 0x0000; - onenand_startbuffer = DATARAM0_0 << 8; - - dma_buffer->data.sfbcfg = SFLASH_BCFG | - (nand_sfcmd_mode ? 0 : (1 << 24)); - dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_INTHI); - dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGRD); - dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(4, 10, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfexec = 1; - dma_buffer->data.sfstat[0] = CLEAN_DATA_32; - dma_buffer->data.sfstat[1] = CLEAN_DATA_32; - dma_buffer->data.sfstat[2] = CLEAN_DATA_32; - dma_buffer->data.sfstat[3] = CLEAN_DATA_32; - dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.addr2 = (ONENAND_START_BUFFER << 16) | - (ONENAND_START_ADDRESS_2); - dma_buffer->data.addr3 = (ONENAND_ECC_STATUS << 16) | - (ONENAND_COMMAND); - dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | - (ONENAND_INTERRUPT_STATUS); - dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data1 = (onenand_startaddr8 << 16) | - (onenand_startaddr1); - dma_buffer->data.data2 = (onenand_startbuffer << 16) | - (onenand_startaddr2); - dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | - (ONENAND_CMDERAS); - dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | - (CLEAN_DATA_16); - dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | - (ONENAND_STARTADDR1_RES); - - /***************************************************************/ - /* Write the necessary address registers in the onenand device */ - /***************************************************************/ - - /* Enable and configure the SFlash controller */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Write the ADDR0 and ADDR1 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); - cmd->dst = MSM_NAND_ADDR0; - cmd->len = 8; - cmd++; - - /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); - cmd->dst = MSM_NAND_ADDR2; - cmd->len = 16; - cmd++; - - /* Write the ADDR6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); - cmd->dst = MSM_NAND_ADDR6; - cmd->len = 4; - cmd++; - - /* Write the GENP0, GENP1, GENP2, GENP3, GENP4 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); - cmd->dst = MSM_NAND_GENP_REG0; - cmd->len = 16; - cmd++; - - /* Write the FLASH_DEV_CMD4,5,6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->dst = MSM_NAND_DEV_CMD4; - cmd->len = 12; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); - cmd->len = 4; - cmd++; - - /***************************************************************/ - /* Wait for the interrupt from the Onenand device controller */ - /***************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); - cmd->len = 4; - cmd++; - - /***************************************************************/ - /* Read the necessary status registers from the onenand device */ - /***************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); - cmd->len = 4; - cmd++; - - /* Read the GENP3 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_GENP_REG3; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); - cmd->len = 4; - cmd++; - - /* Read the DEVCMD4 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_DEV_CMD4; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->len = 4; - cmd++; - - /***************************************************************/ - /* Restore the necessary registers to proper values */ - /***************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[3]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[3]); - cmd->len = 4; - cmd++; - - - BUILD_BUG_ON(20 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) - >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, DMOV_CMD_PTR_LIST - | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - ecc_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; - interrupt_status = (dma_buffer->data.data4 >> 0) & 0x0000FFFF; - controller_status = (dma_buffer->data.data4 >> 16) & 0x0000FFFF; - -#if VERBOSE - pr_info("\n%s: sflash status %x %x %x %x\n", __func__, - dma_buffer->data.sfstat[0], - dma_buffer->data.sfstat[1], - dma_buffer->data.sfstat[2], - dma_buffer->data.sfstat[3]); - - pr_info("%s: controller_status = %x\n", __func__, - controller_status); - pr_info("%s: interrupt_status = %x\n", __func__, - interrupt_status); - pr_info("%s: ecc_status = %x\n", __func__, - ecc_status); -#endif - /* Check for errors, protection violations etc */ - if ((controller_status != 0) - || (dma_buffer->data.sfstat[0] & 0x110) - || (dma_buffer->data.sfstat[1] & 0x110) - || (dma_buffer->data.sfstat[2] & 0x110) - || (dma_buffer->data.sfstat[3] & 0x110)) { - pr_err("%s: ECC/MPU/OP error\n", __func__); - err = -EIO; - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - - if (err) { - pr_err("%s: Erase failed, 0x%llx\n", __func__, - instr->addr); - instr->fail_addr = instr->addr; - instr->state = MTD_ERASE_FAILED; - } else { - instr->state = MTD_ERASE_DONE; - instr->fail_addr = 0xffffffff; - mtd_erase_callback(instr); - } - -#if VERBOSE - pr_info("\n%s: ret %d\n", __func__, err); - pr_info("====================================================" - "=============\n"); -#endif - return err; -} - -static int msm_onenand_block_isbad(struct mtd_info *mtd, loff_t ofs) -{ - struct mtd_oob_ops ops; - int rval, i; - int ret = 0; - uint8_t *buffer; - uint8_t *oobptr; - - if ((ofs > mtd->size) || (ofs & (mtd->erasesize - 1))) { - pr_err("%s: unsupported block address, 0x%x\n", - __func__, (uint32_t)ofs); - return -EINVAL; - } - - buffer = kmalloc(2112, GFP_KERNEL|GFP_DMA); - if (buffer == 0) { - pr_err("%s: Could not kmalloc for buffer\n", - __func__); - return -ENOMEM; - } - - memset(buffer, 0x00, 2112); - oobptr = &(buffer[2048]); - - ops.mode = MTD_OPS_RAW; - ops.len = 2112; - ops.retlen = 0; - ops.ooblen = 0; - ops.oobretlen = 0; - ops.ooboffs = 0; - ops.datbuf = buffer; - ops.oobbuf = NULL; - - for (i = 0; i < 2; i++) { - ofs = ofs + i*mtd->writesize; - rval = msm_onenand_read_oob(mtd, ofs, &ops); - if (rval) { - pr_err("%s: Error in reading bad blk info\n", - __func__); - ret = rval; - break; - } - if ((oobptr[0] != 0xFF) || (oobptr[1] != 0xFF) || - (oobptr[16] != 0xFF) || (oobptr[17] != 0xFF) || - (oobptr[32] != 0xFF) || (oobptr[33] != 0xFF) || - (oobptr[48] != 0xFF) || (oobptr[49] != 0xFF) - ) { - ret = 1; - break; - } - } - - kfree(buffer); - -#if VERBOSE - if (ret == 1) - pr_info("%s : Block containing 0x%x is bad\n", - __func__, (unsigned int)ofs); -#endif - return ret; -} - -static int msm_onenand_block_markbad(struct mtd_info *mtd, loff_t ofs) -{ - struct mtd_oob_ops ops; - int rval, i; - int ret = 0; - uint8_t *buffer; - - if ((ofs > mtd->size) || (ofs & (mtd->erasesize - 1))) { - pr_err("%s: unsupported block address, 0x%x\n", - __func__, (uint32_t)ofs); - return -EINVAL; - } - - buffer = page_address(ZERO_PAGE()); - - ops.mode = MTD_OPS_RAW; - ops.len = 2112; - ops.retlen = 0; - ops.ooblen = 0; - ops.oobretlen = 0; - ops.ooboffs = 0; - ops.datbuf = buffer; - ops.oobbuf = NULL; - - for (i = 0; i < 2; i++) { - ofs = ofs + i*mtd->writesize; - rval = msm_onenand_write_oob(mtd, ofs, &ops); - if (rval) { - pr_err("%s: Error in writing bad blk info\n", - __func__); - ret = rval; - break; - } - } - - return ret; -} - -static int msm_onenand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[20]; - unsigned cmdptr; - struct { - uint32_t sfbcfg; - uint32_t sfcmd[4]; - uint32_t sfexec; - uint32_t sfstat[4]; - uint32_t addr0; - uint32_t addr1; - uint32_t addr2; - uint32_t addr3; - uint32_t addr4; - uint32_t addr5; - uint32_t addr6; - uint32_t data0; - uint32_t data1; - uint32_t data2; - uint32_t data3; - uint32_t data4; - uint32_t data5; - uint32_t data6; - } data; - } *dma_buffer; - dmov_s *cmd; - - int err = 0; - - uint16_t onenand_startaddr1; - uint16_t onenand_startaddr8; - uint16_t onenand_startaddr2; - uint16_t onenand_startblock; - - uint16_t controller_status; - uint16_t interrupt_status; - uint16_t write_prot_status; - - uint64_t start_ofs; - -#if VERBOSE - pr_info("====================================================" - "=============\n"); - pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); -#endif - /* 'ofs' & 'len' should align to block size */ - if (ofs&(mtd->erasesize - 1)) { - pr_err("%s: Unsupported ofs address, 0x%llx\n", - __func__, ofs); - return -EINVAL; - } - - if (len&(mtd->erasesize - 1)) { - pr_err("%s: Unsupported len, %lld\n", - __func__, len); - return -EINVAL; - } - - if (ofs+len > mtd->size) { - pr_err("%s: Maximum chip size exceeded\n", __func__); - return -EINVAL; - } - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - for (start_ofs = ofs; ofs < start_ofs+len; ofs = ofs+mtd->erasesize) { -#if VERBOSE - pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); -#endif - - cmd = dma_buffer->cmd; - if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) - && (ofs >= (mtd->size>>1))) { /* DDP Device */ - onenand_startaddr1 = DEVICE_FLASHCORE_1 | - (((uint32_t)(ofs - (mtd->size>>1)) - / mtd->erasesize)); - onenand_startaddr2 = DEVICE_BUFFERRAM_1; - onenand_startblock = ((uint32_t)(ofs - (mtd->size>>1)) - / mtd->erasesize); - } else { - onenand_startaddr1 = DEVICE_FLASHCORE_0 | - ((uint32_t)ofs / mtd->erasesize) ; - onenand_startaddr2 = DEVICE_BUFFERRAM_0; - onenand_startblock = ((uint32_t)ofs - / mtd->erasesize); - } - - onenand_startaddr8 = 0x0000; - dma_buffer->data.sfbcfg = SFLASH_BCFG | - (nand_sfcmd_mode ? 0 : (1 << 24)); - dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_INTHI); - dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGRD); - dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(4, 10, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfexec = 1; - dma_buffer->data.sfstat[0] = CLEAN_DATA_32; - dma_buffer->data.sfstat[1] = CLEAN_DATA_32; - dma_buffer->data.sfstat[2] = CLEAN_DATA_32; - dma_buffer->data.sfstat[3] = CLEAN_DATA_32; - dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.addr2 = (ONENAND_START_BLOCK_ADDRESS << 16) | - (ONENAND_START_ADDRESS_2); - dma_buffer->data.addr3 = (ONENAND_WRITE_PROT_STATUS << 16) | - (ONENAND_COMMAND); - dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | - (ONENAND_INTERRUPT_STATUS); - dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data1 = (onenand_startaddr8 << 16) | - (onenand_startaddr1); - dma_buffer->data.data2 = (onenand_startblock << 16) | - (onenand_startaddr2); - dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | - (ONENAND_CMD_UNLOCK); - dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | - (CLEAN_DATA_16); - dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | - (ONENAND_STARTADDR1_RES); - - /*************************************************************/ - /* Write the necessary address reg in the onenand device */ - /*************************************************************/ - - /* Enable and configure the SFlash controller */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Write the ADDR0 and ADDR1 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); - cmd->dst = MSM_NAND_ADDR0; - cmd->len = 8; - cmd++; - - /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); - cmd->dst = MSM_NAND_ADDR2; - cmd->len = 16; - cmd++; - - /* Write the ADDR6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); - cmd->dst = MSM_NAND_ADDR6; - cmd->len = 4; - cmd++; - - /* Write the GENP0, GENP1, GENP2, GENP3, GENP4 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); - cmd->dst = MSM_NAND_GENP_REG0; - cmd->len = 16; - cmd++; - - /* Write the FLASH_DEV_CMD4,5,6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->dst = MSM_NAND_DEV_CMD4; - cmd->len = 12; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Wait for the interrupt from the Onenand device controller */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); - cmd->len = 4; - cmd++; - - /*********************************************************/ - /* Read the necessary status reg from the onenand device */ - /*********************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); - cmd->len = 4; - cmd++; - - /* Read the GENP3 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_GENP_REG3; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); - cmd->len = 4; - cmd++; - - /* Read the DEVCMD4 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_DEV_CMD4; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->len = 4; - cmd++; - - /************************************************************/ - /* Restore the necessary registers to proper values */ - /************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[3]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[3]); - cmd->len = 4; - cmd++; - - - BUILD_BUG_ON(20 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) - >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - write_prot_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; - interrupt_status = (dma_buffer->data.data4 >> 0) & 0x0000FFFF; - controller_status = (dma_buffer->data.data4 >> 16) & 0x0000FFFF; - -#if VERBOSE - pr_info("\n%s: sflash status %x %x %x %x\n", __func__, - dma_buffer->data.sfstat[0], - dma_buffer->data.sfstat[1], - dma_buffer->data.sfstat[2], - dma_buffer->data.sfstat[3]); - - pr_info("%s: controller_status = %x\n", __func__, - controller_status); - pr_info("%s: interrupt_status = %x\n", __func__, - interrupt_status); - pr_info("%s: write_prot_status = %x\n", __func__, - write_prot_status); -#endif - /* Check for errors, protection violations etc */ - if ((controller_status != 0) - || (dma_buffer->data.sfstat[0] & 0x110) - || (dma_buffer->data.sfstat[1] & 0x110) - || (dma_buffer->data.sfstat[2] & 0x110) - || (dma_buffer->data.sfstat[3] & 0x110)) { - pr_err("%s: ECC/MPU/OP error\n", __func__); - err = -EIO; - } - - if (!(write_prot_status & ONENAND_WP_US)) { - pr_err("%s: Unexpected status ofs = 0x%llx," - "wp_status = %x\n", - __func__, ofs, write_prot_status); - err = -EIO; - } - - if (err) - break; - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - -#if VERBOSE - pr_info("\n%s: ret %d\n", __func__, err); - pr_info("====================================================" - "=============\n"); -#endif - return err; -} - -static int msm_onenand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[20]; - unsigned cmdptr; - struct { - uint32_t sfbcfg; - uint32_t sfcmd[4]; - uint32_t sfexec; - uint32_t sfstat[4]; - uint32_t addr0; - uint32_t addr1; - uint32_t addr2; - uint32_t addr3; - uint32_t addr4; - uint32_t addr5; - uint32_t addr6; - uint32_t data0; - uint32_t data1; - uint32_t data2; - uint32_t data3; - uint32_t data4; - uint32_t data5; - uint32_t data6; - } data; - } *dma_buffer; - dmov_s *cmd; - - int err = 0; - - uint16_t onenand_startaddr1; - uint16_t onenand_startaddr8; - uint16_t onenand_startaddr2; - uint16_t onenand_startblock; - - uint16_t controller_status; - uint16_t interrupt_status; - uint16_t write_prot_status; - - uint64_t start_ofs; - -#if VERBOSE - pr_info("====================================================" - "=============\n"); - pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); -#endif - /* 'ofs' & 'len' should align to block size */ - if (ofs&(mtd->erasesize - 1)) { - pr_err("%s: Unsupported ofs address, 0x%llx\n", - __func__, ofs); - return -EINVAL; - } - - if (len&(mtd->erasesize - 1)) { - pr_err("%s: Unsupported len, %lld\n", - __func__, len); - return -EINVAL; - } - - if (ofs+len > mtd->size) { - pr_err("%s: Maximum chip size exceeded\n", __func__); - return -EINVAL; - } - - wait_event(chip->wait_queue, (dma_buffer = msm_nand_get_dma_buffer - (chip, sizeof(*dma_buffer)))); - - for (start_ofs = ofs; ofs < start_ofs+len; ofs = ofs+mtd->erasesize) { -#if VERBOSE - pr_info("%s: ofs 0x%llx len %lld\n", __func__, ofs, len); -#endif - - cmd = dma_buffer->cmd; - if ((onenand_info.device_id & ONENAND_DEVICE_IS_DDP) - && (ofs >= (mtd->size>>1))) { /* DDP Device */ - onenand_startaddr1 = DEVICE_FLASHCORE_1 | - (((uint32_t)(ofs - (mtd->size>>1)) - / mtd->erasesize)); - onenand_startaddr2 = DEVICE_BUFFERRAM_1; - onenand_startblock = ((uint32_t)(ofs - (mtd->size>>1)) - / mtd->erasesize); - } else { - onenand_startaddr1 = DEVICE_FLASHCORE_0 | - ((uint32_t)ofs / mtd->erasesize) ; - onenand_startaddr2 = DEVICE_BUFFERRAM_0; - onenand_startblock = ((uint32_t)ofs - / mtd->erasesize); - } - - onenand_startaddr8 = 0x0000; - dma_buffer->data.sfbcfg = SFLASH_BCFG | - (nand_sfcmd_mode ? 0 : (1 << 24)); - dma_buffer->data.sfcmd[0] = SFLASH_PREPCMD(7, 0, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfcmd[1] = SFLASH_PREPCMD(0, 0, 32, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_INTHI); - dma_buffer->data.sfcmd[2] = SFLASH_PREPCMD(3, 7, 0, - MSM_NAND_SFCMD_DATXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGRD); - dma_buffer->data.sfcmd[3] = SFLASH_PREPCMD(4, 10, 0, - MSM_NAND_SFCMD_CMDXS, - nand_sfcmd_mode, - MSM_NAND_SFCMD_REGWR); - dma_buffer->data.sfexec = 1; - dma_buffer->data.sfstat[0] = CLEAN_DATA_32; - dma_buffer->data.sfstat[1] = CLEAN_DATA_32; - dma_buffer->data.sfstat[2] = CLEAN_DATA_32; - dma_buffer->data.sfstat[3] = CLEAN_DATA_32; - dma_buffer->data.addr0 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr1 = (ONENAND_START_ADDRESS_8 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.addr2 = (ONENAND_START_BLOCK_ADDRESS << 16) | - (ONENAND_START_ADDRESS_2); - dma_buffer->data.addr3 = (ONENAND_WRITE_PROT_STATUS << 16) | - (ONENAND_COMMAND); - dma_buffer->data.addr4 = (ONENAND_CONTROLLER_STATUS << 16) | - (ONENAND_INTERRUPT_STATUS); - dma_buffer->data.addr5 = (ONENAND_INTERRUPT_STATUS << 16) | - (ONENAND_SYSTEM_CONFIG_1); - dma_buffer->data.addr6 = (ONENAND_START_ADDRESS_3 << 16) | - (ONENAND_START_ADDRESS_1); - dma_buffer->data.data0 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data1 = (onenand_startaddr8 << 16) | - (onenand_startaddr1); - dma_buffer->data.data2 = (onenand_startblock << 16) | - (onenand_startaddr2); - dma_buffer->data.data3 = (CLEAN_DATA_16 << 16) | - (ONENAND_CMD_LOCK); - dma_buffer->data.data4 = (CLEAN_DATA_16 << 16) | - (CLEAN_DATA_16); - dma_buffer->data.data5 = (ONENAND_CLRINTR << 16) | - (ONENAND_SYSCFG1_ECCENA(nand_sfcmd_mode)); - dma_buffer->data.data6 = (ONENAND_STARTADDR3_RES << 16) | - (ONENAND_STARTADDR1_RES); - - /*************************************************************/ - /* Write the necessary address reg in the onenand device */ - /*************************************************************/ - - /* Enable and configure the SFlash controller */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfbcfg); - cmd->dst = MSM_NAND_SFLASHC_BURST_CFG; - cmd->len = 4; - cmd++; - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[0]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Write the ADDR0 and ADDR1 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr0); - cmd->dst = MSM_NAND_ADDR0; - cmd->len = 8; - cmd++; - - /* Write the ADDR2 ADDR3 ADDR4 ADDR5 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr2); - cmd->dst = MSM_NAND_ADDR2; - cmd->len = 16; - cmd++; - - /* Write the ADDR6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.addr6); - cmd->dst = MSM_NAND_ADDR6; - cmd->len = 4; - cmd++; - - /* Write the GENP0, GENP1, GENP2, GENP3, GENP4 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data0); - cmd->dst = MSM_NAND_GENP_REG0; - cmd->len = 16; - cmd++; - - /* Write the FLASH_DEV_CMD4,5,6 registers */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->dst = MSM_NAND_DEV_CMD4; - cmd->len = 12; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[0]); - cmd->len = 4; - cmd++; - - /*************************************************************/ - /* Wait for the interrupt from the Onenand device controller */ - /*************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[1]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[1]); - cmd->len = 4; - cmd++; - - /*********************************************************/ - /* Read the necessary status reg from the onenand device */ - /*********************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[2]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[2]); - cmd->len = 4; - cmd++; - - /* Read the GENP3 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_GENP_REG3; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data3); - cmd->len = 4; - cmd++; - - /* Read the DEVCMD4 register */ - cmd->cmd = 0; - cmd->src = MSM_NAND_DEV_CMD4; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.data4); - cmd->len = 4; - cmd++; - - /************************************************************/ - /* Restore the necessary registers to proper values */ - /************************************************************/ - - /* Block on cmd ready and write CMD register */ - cmd->cmd = DST_CRCI_NAND_CMD; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfcmd[3]); - cmd->dst = MSM_NAND_SFLASHC_CMD; - cmd->len = 4; - cmd++; - - /* Kick the execute command */ - cmd->cmd = 0; - cmd->src = msm_virt_to_dma(chip, &dma_buffer->data.sfexec); - cmd->dst = MSM_NAND_SFLASHC_EXEC_CMD; - cmd->len = 4; - cmd++; - - /* Block on data ready, and read the status register */ - cmd->cmd = SRC_CRCI_NAND_DATA; - cmd->src = MSM_NAND_SFLASHC_STATUS; - cmd->dst = msm_virt_to_dma(chip, &dma_buffer->data.sfstat[3]); - cmd->len = 4; - cmd++; - - - BUILD_BUG_ON(20 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) - >> 3) | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, - DMOV_CMD_PTR_LIST | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - - write_prot_status = (dma_buffer->data.data3 >> 16) & 0x0000FFFF; - interrupt_status = (dma_buffer->data.data4 >> 0) & 0x0000FFFF; - controller_status = (dma_buffer->data.data4 >> 16) & 0x0000FFFF; - -#if VERBOSE - pr_info("\n%s: sflash status %x %x %x %x\n", __func__, - dma_buffer->data.sfstat[0], - dma_buffer->data.sfstat[1], - dma_buffer->data.sfstat[2], - dma_buffer->data.sfstat[3]); - - pr_info("%s: controller_status = %x\n", __func__, - controller_status); - pr_info("%s: interrupt_status = %x\n", __func__, - interrupt_status); - pr_info("%s: write_prot_status = %x\n", __func__, - write_prot_status); -#endif - /* Check for errors, protection violations etc */ - if ((controller_status != 0) - || (dma_buffer->data.sfstat[0] & 0x110) - || (dma_buffer->data.sfstat[1] & 0x110) - || (dma_buffer->data.sfstat[2] & 0x110) - || (dma_buffer->data.sfstat[3] & 0x110)) { - pr_err("%s: ECC/MPU/OP error\n", __func__); - err = -EIO; - } - - if (!(write_prot_status & ONENAND_WP_LS)) { - pr_err("%s: Unexpected status ofs = 0x%llx," - "wp_status = %x\n", - __func__, ofs, write_prot_status); - err = -EIO; - } - - if (err) - break; - } - - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - -#if VERBOSE - pr_info("\n%s: ret %d\n", __func__, err); - pr_info("====================================================" - "=============\n"); -#endif - return err; -} - -static int msm_onenand_suspend(struct mtd_info *mtd) -{ - return 0; -} - -static void msm_onenand_resume(struct mtd_info *mtd) -{ -} - -int msm_onenand_scan(struct mtd_info *mtd, int maxchips) -{ - struct msm_nand_chip *chip = mtd->priv; - - /* Probe and check whether onenand device is present */ - if (flash_onenand_probe(chip)) - return -ENODEV; - - mtd->size = 0x1000000 << ((onenand_info.device_id & 0xF0) >> 4); - mtd->writesize = onenand_info.data_buf_size; - mtd->oobsize = mtd->writesize >> 5; - mtd->erasesize = mtd->writesize << 6; - mtd->oobavail = msm_onenand_oob_64.oobavail; - mtd->ecclayout = &msm_onenand_oob_64; - - mtd->type = MTD_NANDFLASH; - mtd->flags = MTD_CAP_NANDFLASH; - mtd->_erase = msm_onenand_erase; - mtd->_point = NULL; - mtd->_unpoint = NULL; - mtd->_read = msm_onenand_read; - mtd->_write = msm_onenand_write; - mtd->_read_oob = msm_onenand_read_oob; - mtd->_write_oob = msm_onenand_write_oob; - mtd->_lock = msm_onenand_lock; - mtd->_unlock = msm_onenand_unlock; - mtd->_suspend = msm_onenand_suspend; - mtd->_resume = msm_onenand_resume; - mtd->_block_isbad = msm_onenand_block_isbad; - mtd->_block_markbad = msm_onenand_block_markbad; - mtd->owner = THIS_MODULE; - - pr_info("Found a supported onenand device\n"); - - return 0; -} - -static const unsigned int bch_sup_cntrl[] = { - 0x307, /* MSM7x2xA */ - 0x4030, /* MDM 9x15 */ -}; - -static inline bool msm_nand_has_bch_ecc_engine(unsigned int hw_id) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(bch_sup_cntrl); i++) { - if (hw_id == bch_sup_cntrl[i]) - return true; - } - - return false; -} - -/** - * msm_nand_scan - [msm_nand Interface] Scan for the msm_nand device - * @param mtd MTD device structure - * @param maxchips Number of chips to scan for - * - * This fills out all the not initialized function pointers - * with the defaults. - * The flash ID is read and the mtd/chip structures are - * filled with the appropriate values. - */ -int msm_nand_scan(struct mtd_info *mtd, int maxchips) -{ - struct msm_nand_chip *chip = mtd->priv; - uint32_t flash_id = 0, i, mtd_writesize; - uint8_t dev_found = 0; - uint8_t wide_bus; - uint32_t manid; - uint32_t devid; - uint32_t devcfg; - struct nand_flash_dev *flashdev = NULL; - struct nand_manufacturers *flashman = NULL; - unsigned int hw_id; - - /* Probe the Flash device for ONFI compliance */ - if (!flash_onfi_probe(chip)) { - dev_found = 1; - } else { - /* Read the Flash ID from the Nand Flash Device */ - flash_id = flash_read_id(chip); - manid = flash_id & 0xFF; - devid = (flash_id >> 8) & 0xFF; - devcfg = (flash_id >> 24) & 0xFF; - - for (i = 0; !flashman && nand_manuf_ids[i].id; ++i) - if (nand_manuf_ids[i].id == manid) - flashman = &nand_manuf_ids[i]; - for (i = 0; !flashdev && nand_flash_ids[i].id; ++i) - if (nand_flash_ids[i].id == devid) - flashdev = &nand_flash_ids[i]; - if (!flashdev || !flashman) { - pr_err("ERROR: unknown nand device manuf=%x devid=%x\n", - manid, devid); - return -ENOENT; - } else - dev_found = 1; - - if (!flashdev->pagesize) { - supported_flash.flash_id = flash_id; - supported_flash.density = flashdev->chipsize << 20; - supported_flash.widebus = devcfg & (1 << 6) ? 1 : 0; - supported_flash.pagesize = 1024 << (devcfg & 0x3); - supported_flash.blksize = (64 * 1024) << - ((devcfg >> 4) & 0x3); - supported_flash.oobsize = (8 << ((devcfg >> 2) & 0x3)) * - (supported_flash.pagesize >> 9); - - if ((supported_flash.oobsize > 64) && - (supported_flash.pagesize == 2048)) { - pr_info("msm_nand: Found a 2K page device with" - " %d oobsize - changing oobsize to 64 " - "bytes.\n", supported_flash.oobsize); - supported_flash.oobsize = 64; - } - } else { - supported_flash.flash_id = flash_id; - supported_flash.density = flashdev->chipsize << 20; - supported_flash.widebus = flashdev->options & - NAND_BUSWIDTH_16 ? 1 : 0; - supported_flash.pagesize = flashdev->pagesize; - supported_flash.blksize = flashdev->erasesize; - supported_flash.oobsize = flashdev->pagesize >> 5; - } - } - - if (dev_found) { - (!interleave_enable) ? (i = 1) : (i = 2); - wide_bus = supported_flash.widebus; - mtd->size = supported_flash.density * i; - mtd->writesize = supported_flash.pagesize * i; - mtd->oobsize = supported_flash.oobsize * i; - mtd->erasesize = supported_flash.blksize * i; - mtd->writebufsize = mtd->writesize; - - if (!interleave_enable) - mtd_writesize = mtd->writesize; - else - mtd_writesize = mtd->writesize >> 1; - - /* Check whether controller and NAND device support 8bit ECC*/ - hw_id = flash_rd_reg(chip, MSM_NAND_HW_INFO); - if (msm_nand_has_bch_ecc_engine(hw_id) - && (supported_flash.ecc_correctability >= 8)) { - pr_info("Found supported NAND device for %dbit ECC\n", - supported_flash.ecc_correctability); - enable_bch_ecc = 1; - } else { - pr_info("Found a supported NAND device\n"); - } - pr_info("NAND Controller ID : 0x%x\n", hw_id); - pr_info("NAND Device ID : 0x%x\n", supported_flash.flash_id); - pr_info("Buswidth : %d Bits\n", (wide_bus) ? 16 : 8); - pr_info("Density : %lld MByte\n", (mtd->size>>20)); - pr_info("Pagesize : %d Bytes\n", mtd->writesize); - pr_info("Erasesize: %d Bytes\n", mtd->erasesize); - pr_info("Oobsize : %d Bytes\n", mtd->oobsize); - } else { - pr_err("Unsupported Nand,Id: 0x%x \n", flash_id); - return -ENODEV; - } - - /* Size of each codeword is 532Bytes incase of 8bit BCH ECC*/ - chip->cw_size = enable_bch_ecc ? 532 : 528; - chip->CFG0 = (((mtd_writesize >> 9)-1) << 6) /* 4/8 cw/pg for 2/4k */ - | (516 << 9) /* 516 user data bytes */ - | (10 << 19) /* 10 parity bytes */ - | (5 << 27) /* 5 address cycles */ - | (0 << 30) /* Do not read status before data */ - | (1 << 31) /* Send read cmd */ - /* 0 spare bytes for 16 bit nand or 1/2 spare bytes for 8 bit */ - | (wide_bus ? 0 << 23 : (enable_bch_ecc ? 2 << 23 : 1 << 23)); - - chip->CFG1 = (0 << 0) /* Enable ecc */ - | (7 << 2) /* 8 recovery cycles */ - | (0 << 5) /* Allow CS deassertion */ - /* Bad block marker location */ - | ((mtd_writesize - (chip->cw_size * ( - (mtd_writesize >> 9) - 1)) + 1) << 6) - | (0 << 16) /* Bad block in user data area */ - | (2 << 17) /* 6 cycle tWB/tRB */ - | ((wide_bus) ? CFG1_WIDE_FLASH : 0); /* Wide flash bit */ - - chip->ecc_buf_cfg = 0x203; - chip->CFG0_RAW = 0xA80420C0; - chip->CFG1_RAW = 0x5045D; - - if (enable_bch_ecc) { - chip->CFG1 |= (1 << 27); /* Enable BCH engine */ - chip->ecc_bch_cfg = (0 << 0) /* Enable ECC*/ - | (0 << 1) /* Enable/Disable SW reset of ECC engine */ - | (1 << 4) /* 8bit ecc*/ - | ((wide_bus) ? (14 << 8) : (13 << 8))/*parity bytes*/ - | (516 << 16) /* 516 user data bytes */ - | (1 << 30); /* Turn on ECC engine clocks always */ - chip->CFG0_RAW = 0xA80428C0; /* CW size is increased to 532B */ - } - - /* - * For 4bit RS ECC (default ECC), parity bytes = 10 (for x8 and x16 I/O) - * For 8bit BCH ECC, parity bytes = 13 (x8) or 14 (x16 I/O). - */ - chip->ecc_parity_bytes = enable_bch_ecc ? (wide_bus ? 14 : 13) : 10; - - pr_info("CFG0 Init : 0x%08x\n", chip->CFG0); - pr_info("CFG1 Init : 0x%08x\n", chip->CFG1); - pr_info("ECCBUFCFG : 0x%08x\n", chip->ecc_buf_cfg); - - if (mtd->oobsize == 64) { - mtd->oobavail = msm_nand_oob_64.oobavail; - mtd->ecclayout = &msm_nand_oob_64; - } else if (mtd->oobsize == 128) { - mtd->oobavail = msm_nand_oob_128.oobavail; - mtd->ecclayout = &msm_nand_oob_128; - } else if (mtd->oobsize == 224) { - mtd->oobavail = wide_bus ? msm_nand_oob_224_x16.oobavail : - msm_nand_oob_224_x8.oobavail; - mtd->ecclayout = wide_bus ? &msm_nand_oob_224_x16 : - &msm_nand_oob_224_x8; - } else if (mtd->oobsize == 256) { - mtd->oobavail = msm_nand_oob_256.oobavail; - mtd->ecclayout = &msm_nand_oob_256; - } else { - pr_err("Unsupported Nand, oobsize: 0x%x \n", - mtd->oobsize); - return -ENODEV; - } - - /* Fill in remaining MTD driver data */ - mtd->type = MTD_NANDFLASH; - mtd->flags = MTD_CAP_NANDFLASH; - /* mtd->ecctype = MTD_ECC_SW; */ - mtd->_erase = msm_nand_erase; - mtd->_block_isbad = msm_nand_block_isbad; - mtd->_block_markbad = msm_nand_block_markbad; - mtd->_point = NULL; - mtd->_unpoint = NULL; - mtd->_read = msm_nand_read; - mtd->_write = msm_nand_write; - mtd->_read_oob = msm_nand_read_oob; - mtd->_write_oob = msm_nand_write_oob; - if (dual_nand_ctlr_present) { - mtd->_read_oob = msm_nand_read_oob_dualnandc; - mtd->_write_oob = msm_nand_write_oob_dualnandc; - if (interleave_enable) { - mtd->_erase = msm_nand_erase_dualnandc; - mtd->_block_isbad = msm_nand_block_isbad_dualnandc; - } - } - - /* mtd->sync = msm_nand_sync; */ - mtd->_lock = NULL; - /* mtd->_unlock = msm_nand_unlock; */ - mtd->_suspend = msm_nand_suspend; - mtd->_resume = msm_nand_resume; - mtd->owner = THIS_MODULE; - - /* Unlock whole block */ - /* msm_nand_unlock_all(mtd); */ - - /* return this->scan_bbt(mtd); */ - return 0; -} -EXPORT_SYMBOL_GPL(msm_nand_scan); - -/** - * msm_nand_release - [msm_nand Interface] Free resources held by the msm_nand device - * @param mtd MTD device structure - */ -void msm_nand_release(struct mtd_info *mtd) -{ - /* struct msm_nand_chip *this = mtd->priv; */ - - /* Deregister the device */ - mtd_device_unregister(mtd); -} -EXPORT_SYMBOL_GPL(msm_nand_release); - -struct msm_nand_info { - struct mtd_info mtd; - struct mtd_partition *parts; - struct msm_nand_chip msm_nand; -}; - -/* duplicating the NC01 XFR contents to NC10 */ -static int msm_nand_nc10_xfr_settings(struct mtd_info *mtd) -{ - struct msm_nand_chip *chip = mtd->priv; - - struct { - dmov_s cmd[2]; - unsigned cmdptr; - } *dma_buffer; - dmov_s *cmd; - - wait_event(chip->wait_queue, - (dma_buffer = msm_nand_get_dma_buffer( - chip, sizeof(*dma_buffer)))); - - cmd = dma_buffer->cmd; - - /* Copying XFR register contents from NC01 --> NC10 */ - cmd->cmd = 0; - cmd->src = NC01(MSM_NAND_XFR_STEP1); - cmd->dst = NC10(MSM_NAND_XFR_STEP1); - cmd->len = 28; - cmd++; - - BUILD_BUG_ON(2 != ARRAY_SIZE(dma_buffer->cmd)); - BUG_ON(cmd - dma_buffer->cmd > ARRAY_SIZE(dma_buffer->cmd)); - dma_buffer->cmd[0].cmd |= CMD_OCB; - cmd[-1].cmd |= CMD_OCU | CMD_LC; - dma_buffer->cmdptr = (msm_virt_to_dma(chip, dma_buffer->cmd) >> 3) - | CMD_PTR_LP; - - mb(); - msm_dmov_exec_cmd(chip->dma_channel, DMOV_CMD_PTR_LIST - | DMOV_CMD_ADDR(msm_virt_to_dma(chip, - &dma_buffer->cmdptr))); - mb(); - msm_nand_release_dma_buffer(chip, dma_buffer, sizeof(*dma_buffer)); - return 0; -} - -static int setup_mtd_device(struct platform_device *pdev, - struct msm_nand_info *info) -{ - int i, err; - struct flash_platform_data *pdata = pdev->dev.platform_data; - - if (pdata) { - for (i = 0; i < pdata->nr_parts; i++) { - pdata->parts[i].offset = pdata->parts[i].offset - * info->mtd.erasesize; - pdata->parts[i].size = pdata->parts[i].size - * info->mtd.erasesize; - } - err = mtd_device_register(&info->mtd, pdata->parts, - pdata->nr_parts); - } else { - err = mtd_device_register(&info->mtd, NULL, 0); - } - return err; -} - -static int msm_nand_probe(struct platform_device *pdev) -{ - struct msm_nand_info *info; - struct resource *res; - int err; - struct flash_platform_data *plat_data; - - plat_data = pdev->dev.platform_data; - - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "msm_nand_phys"); - if (!res || !res->start) { - pr_err("%s: msm_nand_phys resource invalid/absent\n", - __func__); - return -ENODEV; - } - msm_nand_phys = res->start; - pr_info("%s: phys addr 0x%lx \n", __func__, msm_nand_phys); - - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "msm_nandc01_phys"); - if (!res || !res->start) - goto no_dual_nand_ctlr_support; - msm_nandc01_phys = res->start; - - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "msm_nandc10_phys"); - if (!res || !res->start) - goto no_dual_nand_ctlr_support; - msm_nandc10_phys = res->start; - - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "msm_nandc11_phys"); - if (!res || !res->start) - goto no_dual_nand_ctlr_support; - msm_nandc11_phys = res->start; - - res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "ebi2_reg_base"); - if (!res || !res->start) - goto no_dual_nand_ctlr_support; - ebi2_register_base = res->start; - - dual_nand_ctlr_present = 1; - if (plat_data != NULL) - interleave_enable = plat_data->interleave; - else - interleave_enable = 0; - - if (!interleave_enable) - pr_info("%s: Dual Nand Ctrl in ping-pong mode\n", __func__); - else - pr_info("%s: Dual Nand Ctrl in interleave mode\n", __func__); - -no_dual_nand_ctlr_support: - res = platform_get_resource_byname(pdev, - IORESOURCE_DMA, "msm_nand_dmac"); - if (!res || !res->start) { - pr_err("%s: invalid msm_nand_dmac resource\n", __func__); - return -ENODEV; - } - - info = kzalloc(sizeof(struct msm_nand_info), GFP_KERNEL); - if (!info) { - pr_err("%s: No memory for msm_nand_info\n", __func__); - return -ENOMEM; - } - - info->msm_nand.dev = &pdev->dev; - - init_waitqueue_head(&info->msm_nand.wait_queue); - - info->msm_nand.dma_channel = res->start; - pr_info("%s: dmac 0x%x\n", __func__, info->msm_nand.dma_channel); - - /* this currently fails if dev is passed in */ - info->msm_nand.dma_buffer = - dma_alloc_coherent(/*dev*/ NULL, MSM_NAND_DMA_BUFFER_SIZE, - &info->msm_nand.dma_addr, GFP_KERNEL); - if (info->msm_nand.dma_buffer == NULL) { - pr_err("%s: No memory for msm_nand.dma_buffer\n", __func__); - err = -ENOMEM; - goto out_free_info; - } - - pr_info("%s: allocated dma buffer at %p, dma_addr %x\n", - __func__, info->msm_nand.dma_buffer, info->msm_nand.dma_addr); - - /* Let default be VERSION_1 for backward compatibility */ - info->msm_nand.uncorrectable_bit_mask = BIT(3); - info->msm_nand.num_err_mask = 0x7; - - if (plat_data && (plat_data->version == VERSION_2)) { - info->msm_nand.uncorrectable_bit_mask = BIT(8); - info->msm_nand.num_err_mask = 0x1F; - } - - info->mtd.name = dev_name(&pdev->dev); - info->mtd.priv = &info->msm_nand; - info->mtd.owner = THIS_MODULE; - - /* config ebi2_cfg register only for ping pong mode!!! */ - if (!interleave_enable && dual_nand_ctlr_present) - flash_wr_reg(&info->msm_nand, EBI2_CFG_REG, 0x4010080); - - if (dual_nand_ctlr_present) - msm_nand_nc10_xfr_settings(&info->mtd); - - if (msm_nand_scan(&info->mtd, 1)) - if (msm_onenand_scan(&info->mtd, 1)) { - pr_err("%s: No nand device found\n", __func__); - err = -ENXIO; - goto out_free_dma_buffer; - } - - err = setup_mtd_device(pdev, info); - if (err < 0) { - pr_err("%s: setup_mtd_device failed with err=%d\n", - __func__, err); - goto out_free_dma_buffer; - } - - dev_set_drvdata(&pdev->dev, info); - - return 0; - -out_free_dma_buffer: - dma_free_coherent(NULL, MSM_NAND_DMA_BUFFER_SIZE, - info->msm_nand.dma_buffer, - info->msm_nand.dma_addr); -out_free_info: - kfree(info); - - return err; -} - -static int msm_nand_remove(struct platform_device *pdev) -{ - struct msm_nand_info *info = dev_get_drvdata(&pdev->dev); - - dev_set_drvdata(&pdev->dev, NULL); - - if (info) { - msm_nand_release(&info->mtd); - dma_free_coherent(NULL, MSM_NAND_DMA_BUFFER_SIZE, - info->msm_nand.dma_buffer, - info->msm_nand.dma_addr); - kfree(info); - } - - return 0; -} - -#define DRIVER_NAME "msm_nand" - -static struct platform_driver msm_nand_driver = { - .probe = msm_nand_probe, - .remove = msm_nand_remove, - .driver = { - .name = DRIVER_NAME, - } -}; - -MODULE_ALIAS(DRIVER_NAME); - -static int __init msm_nand_init(void) -{ - return platform_driver_register(&msm_nand_driver); -} - -static void __exit msm_nand_exit(void) -{ - platform_driver_unregister(&msm_nand_driver); -} - -module_init(msm_nand_init); -module_exit(msm_nand_exit); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("msm_nand flash driver code"); diff --git a/drivers/mtd/devices/msm_nand.h b/drivers/mtd/devices/msm_nand.h deleted file mode 100644 index 8ad2116003f32a9aca43a3df194d2688cbc5e398..0000000000000000000000000000000000000000 --- a/drivers/mtd/devices/msm_nand.h +++ /dev/null @@ -1,192 +0,0 @@ -/* drivers/mtd/devices/msm_nand.h - * - * Copyright (c) 2008-2011, The Linux Foundation. All rights reserved. - * Copyright (C) 2007 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __DRIVERS_MTD_DEVICES_MSM_NAND_H -#define __DRIVERS_MTD_DEVICES_MSM_NAND_H - -#include - -extern unsigned long msm_nand_phys; -extern unsigned long msm_nandc01_phys; -extern unsigned long msm_nandc10_phys; -extern unsigned long msm_nandc11_phys; -extern unsigned long ebi2_register_base; - -#define NC01(X) ((X) + msm_nandc01_phys - msm_nand_phys) -#define NC10(X) ((X) + msm_nandc10_phys - msm_nand_phys) -#define NC11(X) ((X) + msm_nandc11_phys - msm_nand_phys) - -#define MSM_NAND_REG(off) (msm_nand_phys + (off)) - -#define MSM_NAND_FLASH_CMD MSM_NAND_REG(0x0000) -#define MSM_NAND_ADDR0 MSM_NAND_REG(0x0004) -#define MSM_NAND_ADDR1 MSM_NAND_REG(0x0008) -#define MSM_NAND_FLASH_CHIP_SELECT MSM_NAND_REG(0x000C) -#define MSM_NAND_EXEC_CMD MSM_NAND_REG(0x0010) -#define MSM_NAND_FLASH_STATUS MSM_NAND_REG(0x0014) -#define MSM_NAND_BUFFER_STATUS MSM_NAND_REG(0x0018) -#define MSM_NAND_SFLASHC_STATUS MSM_NAND_REG(0x001C) -#define MSM_NAND_DEV0_CFG0 MSM_NAND_REG(0x0020) -#define MSM_NAND_DEV0_CFG1 MSM_NAND_REG(0x0024) -#define MSM_NAND_DEV0_ECC_CFG MSM_NAND_REG(0x0028) -#define MSM_NAND_DEV1_ECC_CFG MSM_NAND_REG(0x002C) -#define MSM_NAND_DEV1_CFG0 MSM_NAND_REG(0x0030) -#define MSM_NAND_DEV1_CFG1 MSM_NAND_REG(0x0034) -#define MSM_NAND_SFLASHC_CMD MSM_NAND_REG(0x0038) -#define MSM_NAND_SFLASHC_EXEC_CMD MSM_NAND_REG(0x003C) -#define MSM_NAND_READ_ID MSM_NAND_REG(0x0040) -#define MSM_NAND_READ_STATUS MSM_NAND_REG(0x0044) -#define MSM_NAND_CONFIG_DATA MSM_NAND_REG(0x0050) -#define MSM_NAND_CONFIG MSM_NAND_REG(0x0054) -#define MSM_NAND_CONFIG_MODE MSM_NAND_REG(0x0058) -#define MSM_NAND_CONFIG_STATUS MSM_NAND_REG(0x0060) -#define MSM_NAND_MACRO1_REG MSM_NAND_REG(0x0064) -#define MSM_NAND_XFR_STEP1 MSM_NAND_REG(0x0070) -#define MSM_NAND_XFR_STEP2 MSM_NAND_REG(0x0074) -#define MSM_NAND_XFR_STEP3 MSM_NAND_REG(0x0078) -#define MSM_NAND_XFR_STEP4 MSM_NAND_REG(0x007C) -#define MSM_NAND_XFR_STEP5 MSM_NAND_REG(0x0080) -#define MSM_NAND_XFR_STEP6 MSM_NAND_REG(0x0084) -#define MSM_NAND_XFR_STEP7 MSM_NAND_REG(0x0088) -#define MSM_NAND_GENP_REG0 MSM_NAND_REG(0x0090) -#define MSM_NAND_GENP_REG1 MSM_NAND_REG(0x0094) -#define MSM_NAND_GENP_REG2 MSM_NAND_REG(0x0098) -#define MSM_NAND_GENP_REG3 MSM_NAND_REG(0x009C) -#define MSM_NAND_DEV_CMD0 MSM_NAND_REG(0x00A0) -#define MSM_NAND_DEV_CMD1 MSM_NAND_REG(0x00A4) -#define MSM_NAND_DEV_CMD2 MSM_NAND_REG(0x00A8) -#define MSM_NAND_DEV_CMD_VLD MSM_NAND_REG(0x00AC) -#define MSM_NAND_EBI2_MISR_SIG_REG MSM_NAND_REG(0x00B0) -#define MSM_NAND_ADDR2 MSM_NAND_REG(0x00C0) -#define MSM_NAND_ADDR3 MSM_NAND_REG(0x00C4) -#define MSM_NAND_ADDR4 MSM_NAND_REG(0x00C8) -#define MSM_NAND_ADDR5 MSM_NAND_REG(0x00CC) -#define MSM_NAND_DEV_CMD3 MSM_NAND_REG(0x00D0) -#define MSM_NAND_DEV_CMD4 MSM_NAND_REG(0x00D4) -#define MSM_NAND_DEV_CMD5 MSM_NAND_REG(0x00D8) -#define MSM_NAND_DEV_CMD6 MSM_NAND_REG(0x00DC) -#define MSM_NAND_SFLASHC_BURST_CFG MSM_NAND_REG(0x00E0) -#define MSM_NAND_ADDR6 MSM_NAND_REG(0x00E4) -#define MSM_NAND_EBI2_ECC_BUF_CFG MSM_NAND_REG(0x00F0) -#define MSM_NAND_HW_INFO MSM_NAND_REG(0x00FC) -#define MSM_NAND_FLASH_BUFFER MSM_NAND_REG(0x0100) - -/* device commands */ - -#define MSM_NAND_CMD_SOFT_RESET 0x01 -#define MSM_NAND_CMD_PAGE_READ 0x32 -#define MSM_NAND_CMD_PAGE_READ_ECC 0x33 -#define MSM_NAND_CMD_PAGE_READ_ALL 0x34 -#define MSM_NAND_CMD_SEQ_PAGE_READ 0x15 -#define MSM_NAND_CMD_PRG_PAGE 0x36 -#define MSM_NAND_CMD_PRG_PAGE_ECC 0x37 -#define MSM_NAND_CMD_PRG_PAGE_ALL 0x39 -#define MSM_NAND_CMD_BLOCK_ERASE 0x3A -#define MSM_NAND_CMD_FETCH_ID 0x0B -#define MSM_NAND_CMD_STATUS 0x0C -#define MSM_NAND_CMD_RESET 0x0D - -/* Sflash Commands */ - -#define MSM_NAND_SFCMD_DATXS 0x0 -#define MSM_NAND_SFCMD_CMDXS 0x1 -#define MSM_NAND_SFCMD_BURST 0x0 -#define MSM_NAND_SFCMD_ASYNC 0x1 -#define MSM_NAND_SFCMD_ABORT 0x1 -#define MSM_NAND_SFCMD_REGRD 0x2 -#define MSM_NAND_SFCMD_REGWR 0x3 -#define MSM_NAND_SFCMD_INTLO 0x4 -#define MSM_NAND_SFCMD_INTHI 0x5 -#define MSM_NAND_SFCMD_DATRD 0x6 -#define MSM_NAND_SFCMD_DATWR 0x7 - -#define SFLASH_PREPCMD(numxfr, offval, delval, trnstp, mode, opcode) \ - ((numxfr<<20)|(offval<<12)|(delval<<6)|(trnstp<<5)|(mode<<4)|opcode) - -#define SFLASH_BCFG 0x20100327 - -/* Onenand addresses */ - -#define ONENAND_MANUFACTURER_ID 0xF000 -#define ONENAND_DEVICE_ID 0xF001 -#define ONENAND_VERSION_ID 0xF002 -#define ONENAND_DATA_BUFFER_SIZE 0xF003 -#define ONENAND_BOOT_BUFFER_SIZE 0xF004 -#define ONENAND_AMOUNT_OF_BUFFERS 0xF005 -#define ONENAND_TECHNOLOGY 0xF006 -#define ONENAND_START_ADDRESS_1 0xF100 -#define ONENAND_START_ADDRESS_2 0xF101 -#define ONENAND_START_ADDRESS_3 0xF102 -#define ONENAND_START_ADDRESS_4 0xF103 -#define ONENAND_START_ADDRESS_5 0xF104 -#define ONENAND_START_ADDRESS_6 0xF105 -#define ONENAND_START_ADDRESS_7 0xF106 -#define ONENAND_START_ADDRESS_8 0xF107 -#define ONENAND_START_BUFFER 0xF200 -#define ONENAND_COMMAND 0xF220 -#define ONENAND_SYSTEM_CONFIG_1 0xF221 -#define ONENAND_SYSTEM_CONFIG_2 0xF222 -#define ONENAND_CONTROLLER_STATUS 0xF240 -#define ONENAND_INTERRUPT_STATUS 0xF241 -#define ONENAND_START_BLOCK_ADDRESS 0xF24C -#define ONENAND_WRITE_PROT_STATUS 0xF24E -#define ONENAND_ECC_STATUS 0xFF00 -#define ONENAND_ECC_ERRPOS_MAIN0 0xFF01 -#define ONENAND_ECC_ERRPOS_SPARE0 0xFF02 -#define ONENAND_ECC_ERRPOS_MAIN1 0xFF03 -#define ONENAND_ECC_ERRPOS_SPARE1 0xFF04 -#define ONENAND_ECC_ERRPOS_MAIN2 0xFF05 -#define ONENAND_ECC_ERRPOS_SPARE2 0xFF06 -#define ONENAND_ECC_ERRPOS_MAIN3 0xFF07 -#define ONENAND_ECC_ERRPOS_SPARE3 0xFF08 - -/* Onenand commands */ -#define ONENAND_WP_US (1 << 2) -#define ONENAND_WP_LS (1 << 1) - -#define ONENAND_CMDLOAD 0x0000 -#define ONENAND_CMDLOADSPARE 0x0013 -#define ONENAND_CMDPROG 0x0080 -#define ONENAND_CMDPROGSPARE 0x001A -#define ONENAND_CMDERAS 0x0094 -#define ONENAND_CMD_UNLOCK 0x0023 -#define ONENAND_CMD_LOCK 0x002A - -#define ONENAND_SYSCFG1_ECCENA(mode) (0x40E0 | (mode ? 0 : 0x8002)) -#define ONENAND_SYSCFG1_ECCDIS(mode) (0x41E0 | (mode ? 0 : 0x8002)) - -#define ONENAND_CLRINTR 0x0000 -#define ONENAND_STARTADDR1_RES 0x07FF -#define ONENAND_STARTADDR3_RES 0x07FF - -#define DATARAM0_0 0x8 -#define DEVICE_FLASHCORE_0 (0 << 15) -#define DEVICE_FLASHCORE_1 (1 << 15) -#define DEVICE_BUFFERRAM_0 (0 << 15) -#define DEVICE_BUFFERRAM_1 (1 << 15) -#define ONENAND_DEVICE_IS_DDP (1 << 3) - -#define CLEAN_DATA_16 0xFFFF -#define CLEAN_DATA_32 0xFFFFFFFF - -#define EBI2_REG(off) (ebi2_register_base + (off)) -#define EBI2_CHIP_SELECT_CFG0 EBI2_REG(0x0000) -#define EBI2_CFG_REG EBI2_REG(0x0004) -#define EBI2_NAND_ADM_MUX EBI2_REG(0x005C) - -extern struct flash_platform_data msm_nand_data; - -#endif diff --git a/drivers/mtd/tests/Makefile b/drivers/mtd/tests/Makefile index ad404ffd6d16ead158945c263f60bcede6d4a1ea..bd0065c0d359f7e207523ca06f2aa0221dc78fad 100644 --- a/drivers/mtd/tests/Makefile +++ b/drivers/mtd/tests/Makefile @@ -7,4 +7,3 @@ obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o obj-$(CONFIG_MTD_TESTS) += mtd_nandecctest.o obj-$(CONFIG_MTD_TESTS) += mtd_nandbiterrs.o -obj-$(CONFIG_MTD_TESTS) += mtd_erasepart.o diff --git a/drivers/mtd/tests/mtd_erasepart.c b/drivers/mtd/tests/mtd_erasepart.c deleted file mode 100644 index 0e44df43a9986fd18a9f26324ced4fc8f6b60df2..0000000000000000000000000000000000000000 --- a/drivers/mtd/tests/mtd_erasepart.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2010, The Linux Foundation. All rights reserved. - * Copyright (C) 2006-2008 Nokia Corporation - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * - * You should have received a copy of the GNU General Public License along with - * this program; see the file COPYING. If not, write to the Free Software - * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Erase the given MTD partition. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define PRINT_PREF KERN_INFO "mtd_erasepart: " - -static int dev; -module_param(dev, int, S_IRUGO); -MODULE_PARM_DESC(dev, "MTD device number to use"); - -static struct mtd_info *mtd; -static unsigned char *bbt; -static int ebcnt; - -static int erase_eraseblock(int ebnum) -{ - int err; - struct erase_info ei; - loff_t addr = ebnum * mtd->erasesize; - - memset(&ei, 0, sizeof(struct erase_info)); - ei.mtd = mtd; - ei.addr = addr; - ei.len = mtd->erasesize; - - err = mtd_erase(mtd, &ei); - if (err) { - printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum); - return err; - } - - if (ei.state == MTD_ERASE_FAILED) { - printk(PRINT_PREF "some erase error occurred at EB %d\n", - ebnum); - return -EIO; - } - - return 0; -} - -static int erase_whole_device(void) -{ - int err; - unsigned int i; - - printk(PRINT_PREF "erasing whole device\n"); - for (i = 0; i < ebcnt; ++i) { - if (bbt[i]) - continue; - err = erase_eraseblock(i); - if (err) - return err; - cond_resched(); - } - printk(PRINT_PREF "erased %u eraseblocks\n", i); - return 0; -} - -static int is_block_bad(int ebnum) -{ - int ret; - loff_t addr = ebnum * mtd->erasesize; - - ret = mtd_block_isbad(mtd, addr); - if (ret) - printk(PRINT_PREF "block %d is bad\n", ebnum); - return ret; -} - -static int scan_for_bad_eraseblocks(void) -{ - int i, bad = 0; - - bbt = kmalloc(ebcnt, GFP_KERNEL); - if (!bbt) { - printk(PRINT_PREF "error: cannot allocate memory\n"); - return -ENOMEM; - } - memset(bbt, 0 , ebcnt); - - printk(PRINT_PREF "scanning for bad eraseblocks\n"); - for (i = 0; i < ebcnt; ++i) { - bbt[i] = is_block_bad(i) ? 1 : 0; - if (bbt[i]) - bad += 1; - cond_resched(); - } - printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad); - return 0; -} - -static int __init mtd_erasepart_init(void) -{ - int err = 0; - uint64_t tmp; - - printk(KERN_INFO "\n"); - printk(KERN_INFO "=================================================\n"); - printk(PRINT_PREF "MTD device: %d\n", dev); - - mtd = get_mtd_device(NULL, dev); - if (IS_ERR(mtd)) { - err = PTR_ERR(mtd); - printk(PRINT_PREF "error: cannot get MTD device\n"); - return err; - } - - if (mtd->type != MTD_NANDFLASH) { - printk(PRINT_PREF "this test requires NAND flash\n"); - err = -ENODEV; - goto out2; - } - - tmp = mtd->size; - do_div(tmp, mtd->erasesize); - ebcnt = tmp; - - printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, " - "page size %u, count of eraseblocks %u", - (unsigned long long)mtd->size, mtd->erasesize, - mtd->writesize, ebcnt); - - err = scan_for_bad_eraseblocks(); - if (err) - goto out1; - - printk(PRINT_PREF "Erasing the whole mtd partition\n"); - - err = erase_whole_device(); -out1: - kfree(bbt); -out2: - put_mtd_device(mtd); - if (err) - printk(PRINT_PREF "error %d occurred\n", err); - printk(KERN_INFO "=================================================\n"); - return err; -} -module_init(mtd_erasepart_init); - -static void __exit mtd_erasepart_exit(void) -{ - return; -} -module_exit(mtd_erasepart_exit); - -MODULE_DESCRIPTION("Erase a given MTD partition"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/net/ethernet/msm/Kconfig b/drivers/net/ethernet/msm/Kconfig index 303e33bb7d736be4bef0c8529e7adf12b40f6e26..d488f17f5604498a4b4ee41f307d569e780cb075 100644 --- a/drivers/net/ethernet/msm/Kconfig +++ b/drivers/net/ethernet/msm/Kconfig @@ -26,20 +26,6 @@ config MSM_EMAC endif # NET_VENDOR_MSM -config MSM_RMNET - tristate "MSM RMNET Virtual Network Device" - depends on ARCH_MSM - default y - help - Virtual ethernet interface for MSM RMNET transport. - -config MSM_RMNET_SDIO - bool "RMNET SDIO Driver" - depends on MSM_SDIO_DMUX - default n - help - Implements RMNET over SDIO interface. - config MSM_RMNET_BAM bool "RMNET BAM Driver" depends on (MSM_BAM_DMUX && NET_SCHED && NET_SCH_HTB && NET_SCH_PRIO && NET_CLS_FW) @@ -76,15 +62,6 @@ config MSM_RMNET_WWAN applications to send and receive the data to/from A2 -config QFEC - tristate "QFEC ethernet driver" - select MII - depends on ARM - help - This driver supports Ethernet in the FSM9xxx. - To compile this driver as a module, choose M here: the - module will be called qfec. - config ECM_IPA tristate "STD ECM LAN Driver support" depends on IPA diff --git a/drivers/net/ethernet/msm/Makefile b/drivers/net/ethernet/msm/Makefile index bfc1dcb32f626a2e1b26b0cd840d4dde73445ef4..64b76b0b5853b3bb39eb01006df1142549e6c7ab 100644 --- a/drivers/net/ethernet/msm/Makefile +++ b/drivers/net/ethernet/msm/Makefile @@ -3,10 +3,7 @@ # obj-$(CONFIG_MSM_EMAC) += emac/ -obj-$(CONFIG_MSM_RMNET) += msm_rmnet.o obj-$(CONFIG_MSM_RMNET_WWAN) += msm_rmnet_wwan.o -obj-$(CONFIG_MSM_RMNET_SDIO) += msm_rmnet_sdio.o obj-$(CONFIG_MSM_RMNET_BAM) += msm_rmnet_bam.o obj-$(CONFIG_MSM_RMNET_SMUX) += msm_rmnet_smux.o -obj-$(CONFIG_QFEC) += qfec.o obj-$(CONFIG_ECM_IPA) += ecm_ipa.o diff --git a/drivers/net/ethernet/msm/msm_rmnet.c b/drivers/net/ethernet/msm/msm_rmnet.c deleted file mode 100644 index 6fee74188c50e3cd045c1016625abefd334818e3..0000000000000000000000000000000000000000 --- a/drivers/net/ethernet/msm/msm_rmnet.c +++ /dev/null @@ -1,840 +0,0 @@ -/* linux/drivers/net/msm_rmnet.c - * - * Virtual Ethernet Interface for MSM7K Networking - * - * Copyright (C) 2007 Google, Inc. - * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. - * Author: Brian Swetland - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_HAS_EARLYSUSPEND -#include -#endif - -#include -#include - -/* Debug message support */ -static int msm_rmnet_debug_mask; -module_param_named(debug_enable, msm_rmnet_debug_mask, - int, S_IRUGO | S_IWUSR | S_IWGRP); - -#define DEBUG_MASK_LVL0 (1U << 0) -#define DEBUG_MASK_LVL1 (1U << 1) -#define DEBUG_MASK_LVL2 (1U << 2) - -#define DBG(m, x...) do { \ - if (msm_rmnet_debug_mask & m) \ - pr_info(x); \ -} while (0) -#define DBG0(x...) DBG(DEBUG_MASK_LVL0, x) -#define DBG1(x...) DBG(DEBUG_MASK_LVL1, x) -#define DBG2(x...) DBG(DEBUG_MASK_LVL2, x) - -/* Configure device instances */ -#define RMNET_DEVICE_COUNT (8) -static const char *ch_name[RMNET_DEVICE_COUNT] = { - "DATA5", - "DATA6", - "DATA7", - "DATA8", - "DATA9", - "DATA12", - "DATA13", - "DATA14", -}; - -/* XXX should come from smd headers */ -#define SMD_PORT_ETHER0 11 - -/* allow larger frames */ -#define RMNET_DATA_LEN 2000 - -#define HEADROOM_FOR_QOS 8 - -static struct completion *port_complete[RMNET_DEVICE_COUNT]; - -struct rmnet_private -{ - smd_channel_t *ch; - struct net_device_stats stats; - const char *chname; - struct wake_lock wake_lock; -#ifdef CONFIG_MSM_RMNET_DEBUG - ktime_t last_packet; - unsigned long wakeups_xmit; - unsigned long wakeups_rcv; - unsigned long timeout_us; -#endif - struct sk_buff *skb; - spinlock_t lock; - struct tasklet_struct tsklt; - struct tasklet_struct rx_tasklet; - u32 operation_mode; /* IOCTL specified mode (protocol, QoS header) */ - struct platform_driver pdrv; - struct completion complete; - void *pil; - struct mutex pil_lock; -}; - -static uint msm_rmnet_modem_wait; -module_param_named(modem_wait, msm_rmnet_modem_wait, - uint, S_IRUGO | S_IWUSR | S_IWGRP); - -/* Forward declaration */ -static int rmnet_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); - -static int count_this_packet(void *_hdr, int len) -{ - struct ethhdr *hdr = _hdr; - - if (len >= ETH_HLEN && hdr->h_proto == htons(ETH_P_ARP)) - return 0; - - return 1; -} - -#ifdef CONFIG_MSM_RMNET_DEBUG -static unsigned long timeout_us; - -#ifdef CONFIG_HAS_EARLYSUSPEND -/* - * If early suspend is enabled then we specify two timeout values, - * screen on (default), and screen is off. - */ -static unsigned long timeout_suspend_us; -static struct device *rmnet0; - -/* Set timeout in us when the screen is off. */ -static ssize_t timeout_suspend_store(struct device *d, struct device_attribute *attr, const char *buf, size_t n) -{ - timeout_suspend_us = simple_strtoul(buf, NULL, 10); - return n; -} - -static ssize_t timeout_suspend_show(struct device *d, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", (unsigned long) timeout_suspend_us); -} - -static DEVICE_ATTR(timeout_suspend, 0664, timeout_suspend_show, timeout_suspend_store); - -static void rmnet_early_suspend(struct early_suspend *handler) { - if (rmnet0) { - struct rmnet_private *p = netdev_priv(to_net_dev(rmnet0)); - p->timeout_us = timeout_suspend_us; - } -} - -static void rmnet_late_resume(struct early_suspend *handler) { - if (rmnet0) { - struct rmnet_private *p = netdev_priv(to_net_dev(rmnet0)); - p->timeout_us = timeout_us; - } -} - -static struct early_suspend rmnet_power_suspend = { - .suspend = rmnet_early_suspend, - .resume = rmnet_late_resume, -}; - -static int __init rmnet_late_init(void) -{ - register_early_suspend(&rmnet_power_suspend); - return 0; -} - -late_initcall(rmnet_late_init); -#endif - -/* Returns 1 if packet caused rmnet to wakeup, 0 otherwise. */ -static int rmnet_cause_wakeup(struct rmnet_private *p) { - int ret = 0; - ktime_t now; - if (p->timeout_us == 0) /* Check if disabled */ - return 0; - - /* Use real (wall) time. */ - now = ktime_get_real(); - - if (ktime_us_delta(now, p->last_packet) > p->timeout_us) { - ret = 1; - } - p->last_packet = now; - return ret; -} - -static ssize_t wakeups_xmit_show(struct device *d, - struct device_attribute *attr, - char *buf) -{ - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - return sprintf(buf, "%lu\n", p->wakeups_xmit); -} - -DEVICE_ATTR(wakeups_xmit, 0444, wakeups_xmit_show, NULL); - -static ssize_t wakeups_rcv_show(struct device *d, struct device_attribute *attr, - char *buf) -{ - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - return sprintf(buf, "%lu\n", p->wakeups_rcv); -} - -DEVICE_ATTR(wakeups_rcv, 0444, wakeups_rcv_show, NULL); - -/* Set timeout in us. */ -static ssize_t timeout_store(struct device *d, struct device_attribute *attr, - const char *buf, size_t n) -{ -#ifndef CONFIG_HAS_EARLYSUSPEND - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - p->timeout_us = timeout_us = simple_strtoul(buf, NULL, 10); -#else -/* If using early suspend/resume hooks do not write the value on store. */ - timeout_us = simple_strtoul(buf, NULL, 10); -#endif - return n; -} - -static ssize_t timeout_show(struct device *d, struct device_attribute *attr, - char *buf) -{ - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - p = netdev_priv(to_net_dev(d)); - return sprintf(buf, "%lu\n", timeout_us); -} - -DEVICE_ATTR(timeout, 0664, timeout_show, timeout_store); -#endif - -static __be16 rmnet_ip_type_trans(struct sk_buff *skb, struct net_device *dev) -{ - __be16 protocol = 0; - - skb->dev = dev; - - /* Determine L3 protocol */ - switch (skb->data[0] & 0xf0) { - case 0x40: - protocol = htons(ETH_P_IP); - break; - case 0x60: - protocol = htons(ETH_P_IPV6); - break; - default: - pr_err("[%s] rmnet_recv() L3 protocol decode error: 0x%02x", - dev->name, skb->data[0] & 0xf0); - /* skb will be dropped in uppder layer for unknown protocol */ - } - return protocol; -} - -static void smd_net_data_handler(unsigned long arg); - -/* Called in soft-irq context */ -static void smd_net_data_handler(unsigned long arg) -{ - struct net_device *dev = (struct net_device *) arg; - struct rmnet_private *p = netdev_priv(dev); - struct sk_buff *skb; - void *ptr = 0; - int sz; - u32 opmode = p->operation_mode; - unsigned long flags; - - for (;;) { - sz = smd_cur_packet_size(p->ch); - if (sz == 0) break; - if (smd_read_avail(p->ch) < sz) break; - - skb = dev_alloc_skb(sz + NET_IP_ALIGN); - if (skb == NULL) { - pr_err("[%s] rmnet_recv() cannot allocate skb\n", - dev->name); - /* out of memory, reschedule a later attempt */ - p->rx_tasklet.data = (unsigned long)dev; - tasklet_schedule(&p->rx_tasklet); - break; - } else { - skb->dev = dev; - skb_reserve(skb, NET_IP_ALIGN); - ptr = skb_put(skb, sz); - wake_lock_timeout(&p->wake_lock, HZ / 2); - if (smd_read(p->ch, ptr, sz) != sz) { - pr_err("[%s] rmnet_recv() smd lied about avail?!", - dev->name); - ptr = 0; - dev_kfree_skb_irq(skb); - } else { - /* Handle Rx frame format */ - spin_lock_irqsave(&p->lock, flags); - opmode = p->operation_mode; - spin_unlock_irqrestore(&p->lock, flags); - - if (RMNET_IS_MODE_IP(opmode)) { - /* Driver in IP mode */ - skb->protocol = - rmnet_ip_type_trans(skb, dev); - } else { - /* Driver in Ethernet mode */ - skb->protocol = - eth_type_trans(skb, dev); - } - if (RMNET_IS_MODE_IP(opmode) || - count_this_packet(ptr, skb->len)) { -#ifdef CONFIG_MSM_RMNET_DEBUG - p->wakeups_rcv += - rmnet_cause_wakeup(p); -#endif - p->stats.rx_packets++; - p->stats.rx_bytes += skb->len; - } - DBG1("[%s] Rx packet #%lu len=%d\n", - dev->name, p->stats.rx_packets, - skb->len); - - /* Deliver to network stack */ - netif_rx(skb); - } - continue; - } - if (smd_read(p->ch, ptr, sz) != sz) - pr_err("[%s] rmnet_recv() smd lied about avail?!", - dev->name); - } -} - -static int _rmnet_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - smd_channel_t *ch = p->ch; - int smd_ret; - struct QMI_QOS_HDR_S *qmih; - u32 opmode; - unsigned long flags; - - /* For QoS mode, prepend QMI header and assign flow ID from skb->mark */ - spin_lock_irqsave(&p->lock, flags); - opmode = p->operation_mode; - spin_unlock_irqrestore(&p->lock, flags); - - if (RMNET_IS_MODE_QOS(opmode)) { - qmih = (struct QMI_QOS_HDR_S *) - skb_push(skb, sizeof(struct QMI_QOS_HDR_S)); - qmih->version = 1; - qmih->flags = 0; - qmih->flow_id = skb->mark; - } - - dev->trans_start = jiffies; - smd_ret = smd_write(ch, skb->data, skb->len); - if (smd_ret != skb->len) { - pr_err("[%s] %s: smd_write returned error %d", - dev->name, __func__, smd_ret); - p->stats.tx_errors++; - goto xmit_out; - } - - if (RMNET_IS_MODE_IP(opmode) || - count_this_packet(skb->data, skb->len)) { - p->stats.tx_packets++; - p->stats.tx_bytes += skb->len; -#ifdef CONFIG_MSM_RMNET_DEBUG - p->wakeups_xmit += rmnet_cause_wakeup(p); -#endif - } - DBG1("[%s] Tx packet #%lu len=%d mark=0x%x\n", - dev->name, p->stats.tx_packets, skb->len, skb->mark); - -xmit_out: - /* data xmited, safe to release skb */ - dev_kfree_skb_irq(skb); - return 0; -} - -static void _rmnet_resume_flow(unsigned long param) -{ - struct net_device *dev = (struct net_device *)param; - struct rmnet_private *p = netdev_priv(dev); - struct sk_buff *skb = NULL; - unsigned long flags; - - /* xmit and enable the flow only once even if - multiple tasklets were scheduled by smd_net_notify */ - spin_lock_irqsave(&p->lock, flags); - if (p->skb && (smd_write_avail(p->ch) >= p->skb->len)) { - skb = p->skb; - p->skb = NULL; - spin_unlock_irqrestore(&p->lock, flags); - _rmnet_xmit(skb, dev); - netif_wake_queue(dev); - } else - spin_unlock_irqrestore(&p->lock, flags); -} - -static void msm_rmnet_unload_modem(void *pil) -{ - if (pil) - subsystem_put(pil); -} - -static void *msm_rmnet_load_modem(struct net_device *dev) -{ - void *pil; - int rc; - struct rmnet_private *p = netdev_priv(dev); - - pil = subsystem_get("modem"); - if (IS_ERR(pil)) - pr_err("[%s] %s: modem load failed\n", - dev->name, __func__); - else if (msm_rmnet_modem_wait) { - rc = wait_for_completion_interruptible_timeout( - &p->complete, - msecs_to_jiffies(msm_rmnet_modem_wait * 1000)); - if (!rc) - rc = -ETIMEDOUT; - if (rc < 0) { - pr_err("[%s] %s: wait for rmnet port failed %d\n", - dev->name, __func__, rc); - msm_rmnet_unload_modem(pil); - pil = ERR_PTR(rc); - } - } - - return pil; -} - -static void smd_net_notify(void *_dev, unsigned event) -{ - struct rmnet_private *p = netdev_priv((struct net_device *)_dev); - - switch (event) { - case SMD_EVENT_DATA: - spin_lock(&p->lock); - if (p->skb && (smd_write_avail(p->ch) >= p->skb->len)) { - smd_disable_read_intr(p->ch); - tasklet_hi_schedule(&p->tsklt); - } - - spin_unlock(&p->lock); - - if (smd_read_avail(p->ch) && - (smd_read_avail(p->ch) >= smd_cur_packet_size(p->ch))) { - p->rx_tasklet.data = (unsigned long) _dev; - tasklet_schedule(&p->rx_tasklet); - } - break; - - case SMD_EVENT_OPEN: - DBG0("%s: opening SMD port\n", __func__); - netif_carrier_on(_dev); - if (netif_queue_stopped(_dev)) { - DBG0("%s: re-starting if queue\n", __func__); - netif_wake_queue(_dev); - } - break; - - case SMD_EVENT_CLOSE: - DBG0("%s: closing SMD port\n", __func__); - netif_carrier_off(_dev); - break; - } -} - -static int __rmnet_open(struct net_device *dev) -{ - int r; - void *pil; - struct rmnet_private *p = netdev_priv(dev); - - mutex_lock(&p->pil_lock); - if (!p->pil) { - pil = msm_rmnet_load_modem(dev); - if (IS_ERR(pil)) { - mutex_unlock(&p->pil_lock); - return PTR_ERR(pil); - } - p->pil = pil; - } - mutex_unlock(&p->pil_lock); - - if (!p->ch) { - r = smd_named_open_on_edge(p->chname, SMD_APPS_MODEM, &p->ch, - dev, smd_net_notify); - - if (r < 0) - return -ENODEV; - } - - smd_disable_read_intr(p->ch); - return 0; -} - -static int __rmnet_close(struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - - if (p->ch) - return 0; - else - return -EBADF; -} - -static int rmnet_open(struct net_device *dev) -{ - int rc = 0; - - DBG0("[%s] rmnet_open()\n", dev->name); - - rc = __rmnet_open(dev); - if (rc == 0) - netif_start_queue(dev); - - return rc; -} - -static int rmnet_stop(struct net_device *dev) -{ - DBG0("[%s] rmnet_stop()\n", dev->name); - - netif_stop_queue(dev); - - /* TODO: unload modem safely, - currently, this causes unnecessary unloads */ - /* - mutex_lock(&p->pil_lock); - msm_rmnet_unload_modem(p->pil); - p->pil = NULL; - mutex_unlock(&p->pil_lock); - */ - - return 0; -} - -static int rmnet_change_mtu(struct net_device *dev, int new_mtu) -{ - if (0 > new_mtu || RMNET_DATA_LEN < new_mtu) - return -EINVAL; - - DBG0("[%s] MTU change: old=%d new=%d\n", - dev->name, dev->mtu, new_mtu); - dev->mtu = new_mtu; - - return 0; -} - -static int rmnet_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - smd_channel_t *ch = p->ch; - unsigned long flags; - - if (netif_queue_stopped(dev)) { - pr_err("[%s] fatal: rmnet_xmit called when netif_queue is stopped", - dev->name); - return 0; - } - - spin_lock_irqsave(&p->lock, flags); - smd_enable_read_intr(ch); - if (smd_write_avail(ch) < skb->len) { - netif_stop_queue(dev); - p->skb = skb; - spin_unlock_irqrestore(&p->lock, flags); - return 0; - } - smd_disable_read_intr(ch); - spin_unlock_irqrestore(&p->lock, flags); - - _rmnet_xmit(skb, dev); - - return 0; -} - -static struct net_device_stats *rmnet_get_stats(struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - return &p->stats; -} - -static void rmnet_set_multicast_list(struct net_device *dev) -{ -} - -static void rmnet_tx_timeout(struct net_device *dev) -{ - pr_warning("[%s] rmnet_tx_timeout()\n", dev->name); -} - - -static const struct net_device_ops rmnet_ops_ether = { - .ndo_open = rmnet_open, - .ndo_stop = rmnet_stop, - .ndo_start_xmit = rmnet_xmit, - .ndo_get_stats = rmnet_get_stats, - .ndo_set_rx_mode = rmnet_set_multicast_list, - .ndo_tx_timeout = rmnet_tx_timeout, - .ndo_do_ioctl = rmnet_ioctl, - .ndo_change_mtu = rmnet_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; - -static const struct net_device_ops rmnet_ops_ip = { - .ndo_open = rmnet_open, - .ndo_stop = rmnet_stop, - .ndo_start_xmit = rmnet_xmit, - .ndo_get_stats = rmnet_get_stats, - .ndo_set_rx_mode = rmnet_set_multicast_list, - .ndo_tx_timeout = rmnet_tx_timeout, - .ndo_do_ioctl = rmnet_ioctl, - .ndo_change_mtu = rmnet_change_mtu, - .ndo_set_mac_address = 0, - .ndo_validate_addr = 0, -}; - -static int rmnet_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - struct rmnet_private *p = netdev_priv(dev); - u32 old_opmode = p->operation_mode; - unsigned long flags; - int prev_mtu = dev->mtu; - int rc = 0; - - /* Process IOCTL command */ - switch (cmd) { - case RMNET_IOCTL_SET_LLP_ETHERNET: /* Set Ethernet protocol */ - /* Perform Ethernet config only if in IP mode currently*/ - if (p->operation_mode & RMNET_MODE_LLP_IP) { - ether_setup(dev); - random_ether_addr(dev->dev_addr); - dev->mtu = prev_mtu; - - dev->netdev_ops = &rmnet_ops_ether; - spin_lock_irqsave(&p->lock, flags); - p->operation_mode &= ~RMNET_MODE_LLP_IP; - p->operation_mode |= RMNET_MODE_LLP_ETH; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): " - "set Ethernet protocol mode\n", - dev->name); - } - break; - - case RMNET_IOCTL_SET_LLP_IP: /* Set RAWIP protocol */ - /* Perform IP config only if in Ethernet mode currently*/ - if (p->operation_mode & RMNET_MODE_LLP_ETH) { - - /* Undo config done in ether_setup() */ - dev->header_ops = 0; /* No header */ - dev->type = ARPHRD_RAWIP; - dev->hard_header_len = 0; - dev->mtu = prev_mtu; - dev->addr_len = 0; - dev->flags &= ~(IFF_BROADCAST| - IFF_MULTICAST); - - dev->netdev_ops = &rmnet_ops_ip; - spin_lock_irqsave(&p->lock, flags); - p->operation_mode &= ~RMNET_MODE_LLP_ETH; - p->operation_mode |= RMNET_MODE_LLP_IP; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): set IP protocol mode\n", - dev->name); - } - break; - - case RMNET_IOCTL_GET_LLP: /* Get link protocol state */ - ifr->ifr_ifru.ifru_data = - (void *)(p->operation_mode & - (RMNET_MODE_LLP_ETH|RMNET_MODE_LLP_IP)); - break; - - case RMNET_IOCTL_SET_QOS_ENABLE: /* Set QoS header enabled */ - spin_lock_irqsave(&p->lock, flags); - p->operation_mode |= RMNET_MODE_QOS; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): set QMI QOS header enable\n", - dev->name); - break; - - case RMNET_IOCTL_SET_QOS_DISABLE: /* Set QoS header disabled */ - spin_lock_irqsave(&p->lock, flags); - p->operation_mode &= ~RMNET_MODE_QOS; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): set QMI QOS header disable\n", - dev->name); - break; - - case RMNET_IOCTL_GET_QOS: /* Get QoS header state */ - ifr->ifr_ifru.ifru_data = - (void *)(p->operation_mode & RMNET_MODE_QOS); - break; - - case RMNET_IOCTL_GET_OPMODE: /* Get operation mode */ - ifr->ifr_ifru.ifru_data = (void *)p->operation_mode; - break; - - case RMNET_IOCTL_OPEN: /* Open transport port */ - rc = __rmnet_open(dev); - DBG0("[%s] rmnet_ioctl(): open transport port\n", - dev->name); - break; - - case RMNET_IOCTL_CLOSE: /* Close transport port */ - rc = __rmnet_close(dev); - DBG0("[%s] rmnet_ioctl(): close transport port\n", - dev->name); - break; - - default: - pr_err("[%s] error: rmnet_ioct called for unsupported cmd[%d]", - dev->name, cmd); - return -EINVAL; - } - - DBG2("[%s] %s: cmd=0x%x opmode old=0x%08x new=0x%08x\n", - dev->name, __func__, cmd, old_opmode, p->operation_mode); - return rc; -} - - -static void __init rmnet_setup(struct net_device *dev) -{ - /* Using Ethernet mode by default */ - dev->netdev_ops = &rmnet_ops_ether; - ether_setup(dev); - - /* set this after calling ether_setup */ - dev->mtu = RMNET_DATA_LEN; - dev->needed_headroom = HEADROOM_FOR_QOS; - - random_ether_addr(dev->dev_addr); - - dev->watchdog_timeo = 1000; /* 10 seconds? */ -} - -static int msm_rmnet_smd_probe(struct platform_device *pdev) -{ - int i; - - for (i = 0; i < RMNET_DEVICE_COUNT; i++) - if (!strcmp(pdev->name, ch_name[i])) { - complete_all(port_complete[i]); - break; - } - - return 0; -} - -static int __init rmnet_init(void) -{ - int ret; - struct device *d; - struct net_device *dev; - struct rmnet_private *p; - unsigned n; - - pr_info("%s: SMD devices[%d]\n", __func__, RMNET_DEVICE_COUNT); - -#ifdef CONFIG_MSM_RMNET_DEBUG - timeout_us = 0; -#ifdef CONFIG_HAS_EARLYSUSPEND - timeout_suspend_us = 0; -#endif -#endif - - for (n = 0; n < RMNET_DEVICE_COUNT; n++) { - dev = alloc_netdev(sizeof(struct rmnet_private), - "rmnet%d", rmnet_setup); - - if (!dev) - return -ENOMEM; - - d = &(dev->dev); - p = netdev_priv(dev); - p->chname = ch_name[n]; - /* Initial config uses Ethernet */ - p->operation_mode = RMNET_MODE_LLP_ETH; - p->skb = NULL; - spin_lock_init(&p->lock); - tasklet_init(&p->tsklt, _rmnet_resume_flow, - (unsigned long)dev); - tasklet_init(&p->rx_tasklet, smd_net_data_handler, - (unsigned long)dev); - wake_lock_init(&p->wake_lock, WAKE_LOCK_SUSPEND, ch_name[n]); -#ifdef CONFIG_MSM_RMNET_DEBUG - p->timeout_us = timeout_us; - p->wakeups_xmit = p->wakeups_rcv = 0; -#endif - - init_completion(&p->complete); - port_complete[n] = &p->complete; - mutex_init(&p->pil_lock); - p->pdrv.probe = msm_rmnet_smd_probe; - p->pdrv.driver.name = ch_name[n]; - p->pdrv.driver.owner = THIS_MODULE; - ret = platform_driver_register(&p->pdrv); - if (ret) { - free_netdev(dev); - return ret; - } - - ret = register_netdev(dev); - if (ret) { - platform_driver_unregister(&p->pdrv); - free_netdev(dev); - return ret; - } - - -#ifdef CONFIG_MSM_RMNET_DEBUG - if (device_create_file(d, &dev_attr_timeout)) - continue; - if (device_create_file(d, &dev_attr_wakeups_xmit)) - continue; - if (device_create_file(d, &dev_attr_wakeups_rcv)) - continue; -#ifdef CONFIG_HAS_EARLYSUSPEND - if (device_create_file(d, &dev_attr_timeout_suspend)) - continue; - - /* Only care about rmnet0 for suspend/resume tiemout hooks. */ - if (n == 0) - rmnet0 = d; -#endif -#endif - } - return 0; -} - -module_init(rmnet_init); diff --git a/drivers/net/ethernet/msm/msm_rmnet_sdio.c b/drivers/net/ethernet/msm/msm_rmnet_sdio.c deleted file mode 100644 index 754cb8319aecab7bd18c34e6f4c082c8ea0f7287..0000000000000000000000000000000000000000 --- a/drivers/net/ethernet/msm/msm_rmnet_sdio.c +++ /dev/null @@ -1,712 +0,0 @@ -/* Copyright (c) 2010-2012, 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. - * - */ - -/* - * RMNET SDIO Module. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_HAS_EARLYSUSPEND -#include -#endif - -#include - -/* Debug message support */ -static int msm_rmnet_sdio_debug_mask; -module_param_named(debug_enable, msm_rmnet_sdio_debug_mask, - int, S_IRUGO | S_IWUSR | S_IWGRP); - -#define DEBUG_MASK_LVL0 (1U << 0) -#define DEBUG_MASK_LVL1 (1U << 1) -#define DEBUG_MASK_LVL2 (1U << 2) - -#define DBG(m, x...) do { \ - if (msm_rmnet_sdio_debug_mask & m) \ - pr_info(x); \ -} while (0) -#define DBG0(x...) DBG(DEBUG_MASK_LVL0, x) -#define DBG1(x...) DBG(DEBUG_MASK_LVL1, x) -#define DBG2(x...) DBG(DEBUG_MASK_LVL2, x) - -/* Configure device instances */ -#define RMNET_DEVICE_COUNT (8) - -/* allow larger frames */ -#define RMNET_DATA_LEN 2000 - -#define DEVICE_ID_INVALID -1 - -#define DEVICE_INACTIVE 0 -#define DEVICE_ACTIVE 1 - -#define HEADROOM_FOR_SDIO 8 /* for mux header */ -#define HEADROOM_FOR_QOS 8 -#define TAILROOM 8 /* for padding by mux layer */ - -struct rmnet_private { - struct net_device_stats stats; - uint32_t ch_id; -#ifdef CONFIG_MSM_RMNET_DEBUG - ktime_t last_packet; - unsigned long wakeups_xmit; - unsigned long wakeups_rcv; - unsigned long timeout_us; -#endif - struct sk_buff *skb; - spinlock_t lock; - spinlock_t tx_queue_lock; - struct tasklet_struct tsklt; - u32 operation_mode; /* IOCTL specified mode (protocol, QoS header) */ - uint8_t device_up; - uint8_t in_reset; -}; - -#ifdef CONFIG_MSM_RMNET_DEBUG -static unsigned long timeout_us; - -#ifdef CONFIG_HAS_EARLYSUSPEND -/* - * If early suspend is enabled then we specify two timeout values, - * screen on (default), and screen is off. - */ -static unsigned long timeout_suspend_us; -static struct device *rmnet0; - -/* Set timeout in us when the screen is off. */ -static ssize_t timeout_suspend_store(struct device *d, - struct device_attribute *attr, - const char *buf, size_t n) -{ - timeout_suspend_us = strict_strtoul(buf, NULL, 10); - return n; -} - -static ssize_t timeout_suspend_show(struct device *d, - struct device_attribute *attr, - char *buf) -{ - return sprintf(buf, "%lu\n", (unsigned long) timeout_suspend_us); -} - -static DEVICE_ATTR(timeout_suspend, 0664, timeout_suspend_show, - timeout_suspend_store); - -static void rmnet_early_suspend(struct early_suspend *handler) -{ - if (rmnet0) { - struct rmnet_private *p = netdev_priv(to_net_dev(rmnet0)); - p->timeout_us = timeout_suspend_us; - } -} - -static void rmnet_late_resume(struct early_suspend *handler) -{ - if (rmnet0) { - struct rmnet_private *p = netdev_priv(to_net_dev(rmnet0)); - p->timeout_us = timeout_us; - } -} - -static struct early_suspend rmnet_power_suspend = { - .suspend = rmnet_early_suspend, - .resume = rmnet_late_resume, -}; - -static int __init rmnet_late_init(void) -{ - register_early_suspend(&rmnet_power_suspend); - return 0; -} - -late_initcall(rmnet_late_init); -#endif - -/* Returns 1 if packet caused rmnet to wakeup, 0 otherwise. */ -static int rmnet_cause_wakeup(struct rmnet_private *p) -{ - int ret = 0; - ktime_t now; - if (p->timeout_us == 0) /* Check if disabled */ - return 0; - - /* Use real (wall) time. */ - now = ktime_get_real(); - - if (ktime_us_delta(now, p->last_packet) > p->timeout_us) - ret = 1; - - p->last_packet = now; - return ret; -} - -static ssize_t wakeups_xmit_show(struct device *d, - struct device_attribute *attr, - char *buf) -{ - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - return sprintf(buf, "%lu\n", p->wakeups_xmit); -} - -DEVICE_ATTR(wakeups_xmit, 0444, wakeups_xmit_show, NULL); - -static ssize_t wakeups_rcv_show(struct device *d, struct device_attribute *attr, - char *buf) -{ - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - return sprintf(buf, "%lu\n", p->wakeups_rcv); -} - -DEVICE_ATTR(wakeups_rcv, 0444, wakeups_rcv_show, NULL); - -/* Set timeout in us. */ -static ssize_t timeout_store(struct device *d, struct device_attribute *attr, - const char *buf, size_t n) -{ -#ifndef CONFIG_HAS_EARLYSUSPEND - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - p->timeout_us = timeout_us = strict_strtoul(buf, NULL, 10); -#else -/* If using early suspend/resume hooks do not write the value on store. */ - timeout_us = strict_strtoul(buf, NULL, 10); -#endif - return n; -} - -static ssize_t timeout_show(struct device *d, struct device_attribute *attr, - char *buf) -{ - struct rmnet_private *p = netdev_priv(to_net_dev(d)); - p = netdev_priv(to_net_dev(d)); - return sprintf(buf, "%lu\n", timeout_us); -} - -DEVICE_ATTR(timeout, 0664, timeout_show, timeout_store); -#endif - - -/* Forward declaration */ -static int rmnet_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); - -static __be16 rmnet_ip_type_trans(struct sk_buff *skb, struct net_device *dev) -{ - __be16 protocol = 0; - - skb->dev = dev; - - /* Determine L3 protocol */ - switch (skb->data[0] & 0xf0) { - case 0x40: - protocol = htons(ETH_P_IP); - break; - case 0x60: - protocol = htons(ETH_P_IPV6); - break; - default: - pr_err("[%s] rmnet_recv() L3 protocol decode error: 0x%02x", - dev->name, skb->data[0] & 0xf0); - /* skb will be dropped in upper layer for unknown protocol */ - } - return protocol; -} - -static int count_this_packet(void *_hdr, int len) -{ - struct ethhdr *hdr = _hdr; - - if (len >= ETH_HLEN && hdr->h_proto == htons(ETH_P_ARP)) - return 0; - - return 1; -} - -static int sdio_update_reset_state(struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - int new_state; - - new_state = msm_sdio_is_channel_in_reset(p->ch_id); - - if (p->in_reset != new_state) { - p->in_reset = (uint8_t)new_state; - - if (p->in_reset) - netif_carrier_off(dev); - else - netif_carrier_on(dev); - return 1; - } - return 0; -} - -/* Rx Callback, Called in Work Queue context */ -static void sdio_recv_notify(void *dev, struct sk_buff *skb) -{ - struct rmnet_private *p = netdev_priv(dev); - unsigned long flags; - u32 opmode; - - if (skb) { - skb->dev = dev; - /* Handle Rx frame format */ - spin_lock_irqsave(&p->lock, flags); - opmode = p->operation_mode; - spin_unlock_irqrestore(&p->lock, flags); - - if (RMNET_IS_MODE_IP(opmode)) { - /* Driver in IP mode */ - skb->protocol = rmnet_ip_type_trans(skb, dev); - } else { - /* Driver in Ethernet mode */ - skb->protocol = eth_type_trans(skb, dev); - } - if (RMNET_IS_MODE_IP(opmode) || - count_this_packet(skb->data, skb->len)) { -#ifdef CONFIG_MSM_RMNET_DEBUG - p->wakeups_rcv += rmnet_cause_wakeup(p); -#endif - p->stats.rx_packets++; - p->stats.rx_bytes += skb->len; - } - DBG1("[%s] Rx packet #%lu len=%d\n", - ((struct net_device *)dev)->name, - p->stats.rx_packets, skb->len); - - /* Deliver to network stack */ - netif_rx(skb); - } else { - spin_lock_irqsave(&p->lock, flags); - if (!sdio_update_reset_state((struct net_device *)dev)) - pr_err("[%s] %s: No skb received", - ((struct net_device *)dev)->name, __func__); - spin_unlock_irqrestore(&p->lock, flags); - } -} - -static int _rmnet_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - int sdio_ret; - struct QMI_QOS_HDR_S *qmih; - u32 opmode; - unsigned long flags; - - if (!netif_carrier_ok(dev)) { - pr_err("[%s] %s: channel in reset", - dev->name, __func__); - goto xmit_out; - } - - /* For QoS mode, prepend QMI header and assign flow ID from skb->mark */ - spin_lock_irqsave(&p->lock, flags); - opmode = p->operation_mode; - spin_unlock_irqrestore(&p->lock, flags); - - if (RMNET_IS_MODE_QOS(opmode)) { - qmih = (struct QMI_QOS_HDR_S *) - skb_push(skb, sizeof(struct QMI_QOS_HDR_S)); - qmih->version = 1; - qmih->flags = 0; - qmih->flow_id = skb->mark; - } - - dev->trans_start = jiffies; - sdio_ret = msm_sdio_dmux_write(p->ch_id, skb); - - if (sdio_ret != 0) { - pr_err("[%s] %s: write returned error %d", - dev->name, __func__, sdio_ret); - goto xmit_out; - } - - if (count_this_packet(skb->data, skb->len)) { - p->stats.tx_packets++; - p->stats.tx_bytes += skb->len; -#ifdef CONFIG_MSM_RMNET_DEBUG - p->wakeups_xmit += rmnet_cause_wakeup(p); -#endif - } - DBG1("[%s] Tx packet #%lu len=%d mark=0x%x\n", - dev->name, p->stats.tx_packets, skb->len, skb->mark); - - return 0; -xmit_out: - dev_kfree_skb_any(skb); - p->stats.tx_errors++; - return 0; -} - -static void sdio_write_done(void *dev, struct sk_buff *skb) -{ - struct rmnet_private *p = netdev_priv(dev); - unsigned long flags; - - if (skb) - dev_kfree_skb_any(skb); - - if (!p->in_reset) { - DBG1("%s: write complete skb=%p\n", __func__, skb); - - spin_lock_irqsave(&p->tx_queue_lock, flags); - if (netif_queue_stopped(dev) && - msm_sdio_dmux_is_ch_low(p->ch_id)) { - DBG0("%s: Low WM hit, waking queue=%p\n", - __func__, skb); - netif_wake_queue(dev); - } - spin_unlock_irqrestore(&p->tx_queue_lock, flags); - } else { - DBG1("%s: write in reset skb=%p\n", __func__, skb); - } -} - -static int __rmnet_open(struct net_device *dev) -{ - int r; - struct rmnet_private *p = netdev_priv(dev); - - DBG0("[%s] __rmnet_open()\n", dev->name); - - if (!p->device_up) { - r = msm_sdio_dmux_open(p->ch_id, dev, - sdio_recv_notify, sdio_write_done); - - if (r < 0) - return -ENODEV; - } - - p->device_up = DEVICE_ACTIVE; - return 0; -} - -static int rmnet_open(struct net_device *dev) -{ - int rc = 0; - - DBG0("[%s] rmnet_open()\n", dev->name); - - rc = __rmnet_open(dev); - - if (rc == 0) - netif_start_queue(dev); - - return rc; -} - - -static int __rmnet_close(struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - int rc = 0; - - if (p->device_up) { - /* do not close rmnet port once up, this causes - remote side to hang if tried to open again */ - /* rc = msm_sdio_dmux_close(p->ch_id); */ - p->device_up = DEVICE_INACTIVE; - return rc; - } else - return -EBADF; -} - - -static int rmnet_stop(struct net_device *dev) -{ - DBG0("[%s] rmnet_stop()\n", dev->name); - - __rmnet_close(dev); - netif_stop_queue(dev); - - return 0; -} - -static int rmnet_change_mtu(struct net_device *dev, int new_mtu) -{ - if (0 > new_mtu || RMNET_DATA_LEN < new_mtu) - return -EINVAL; - - DBG0("[%s] MTU change: old=%d new=%d\n", - dev->name, dev->mtu, new_mtu); - dev->mtu = new_mtu; - - return 0; -} - -static int rmnet_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - unsigned long flags; - - if (netif_queue_stopped(dev)) { - pr_err("[%s]fatal: rmnet_xmit called when " - "netif_queue is stopped", dev->name); - return 0; - } - - _rmnet_xmit(skb, dev); - - spin_lock_irqsave(&p->tx_queue_lock, flags); - if (msm_sdio_dmux_is_ch_full(p->ch_id)) { - netif_stop_queue(dev); - DBG0("%s: High WM hit, stopping queue=%p\n", __func__, skb); - } - spin_unlock_irqrestore(&p->tx_queue_lock, flags); - - return 0; -} - -static struct net_device_stats *rmnet_get_stats(struct net_device *dev) -{ - struct rmnet_private *p = netdev_priv(dev); - return &p->stats; -} - -static void rmnet_set_multicast_list(struct net_device *dev) -{ -} - -static void rmnet_tx_timeout(struct net_device *dev) -{ - pr_warning("[%s] rmnet_tx_timeout()\n", dev->name); -} - -static const struct net_device_ops rmnet_ops_ether = { - .ndo_open = rmnet_open, - .ndo_stop = rmnet_stop, - .ndo_start_xmit = rmnet_xmit, - .ndo_get_stats = rmnet_get_stats, - .ndo_set_rx_mode = rmnet_set_multicast_list, - .ndo_tx_timeout = rmnet_tx_timeout, - .ndo_do_ioctl = rmnet_ioctl, - .ndo_change_mtu = rmnet_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; - -static const struct net_device_ops rmnet_ops_ip = { - .ndo_open = rmnet_open, - .ndo_stop = rmnet_stop, - .ndo_start_xmit = rmnet_xmit, - .ndo_get_stats = rmnet_get_stats, - .ndo_set_rx_mode = rmnet_set_multicast_list, - .ndo_tx_timeout = rmnet_tx_timeout, - .ndo_do_ioctl = rmnet_ioctl, - .ndo_change_mtu = rmnet_change_mtu, - .ndo_set_mac_address = 0, - .ndo_validate_addr = 0, -}; - -static int rmnet_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - struct rmnet_private *p = netdev_priv(dev); - u32 old_opmode = p->operation_mode; - unsigned long flags; - int prev_mtu = dev->mtu; - int rc = 0; - - /* Process IOCTL command */ - switch (cmd) { - case RMNET_IOCTL_SET_LLP_ETHERNET: /* Set Ethernet protocol */ - /* Perform Ethernet config only if in IP mode currently*/ - if (p->operation_mode & RMNET_MODE_LLP_IP) { - ether_setup(dev); - random_ether_addr(dev->dev_addr); - dev->mtu = prev_mtu; - - dev->netdev_ops = &rmnet_ops_ether; - spin_lock_irqsave(&p->lock, flags); - p->operation_mode &= ~RMNET_MODE_LLP_IP; - p->operation_mode |= RMNET_MODE_LLP_ETH; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): " - "set Ethernet protocol mode\n", - dev->name); - } - break; - - case RMNET_IOCTL_SET_LLP_IP: /* Set RAWIP protocol */ - /* Perform IP config only if in Ethernet mode currently*/ - if (p->operation_mode & RMNET_MODE_LLP_ETH) { - - /* Undo config done in ether_setup() */ - dev->header_ops = 0; /* No header */ - dev->type = ARPHRD_RAWIP; - dev->hard_header_len = 0; - dev->mtu = prev_mtu; - dev->addr_len = 0; - dev->flags &= ~(IFF_BROADCAST| - IFF_MULTICAST); - - dev->needed_headroom = HEADROOM_FOR_SDIO + - HEADROOM_FOR_QOS; - dev->needed_tailroom = TAILROOM; - dev->netdev_ops = &rmnet_ops_ip; - spin_lock_irqsave(&p->lock, flags); - p->operation_mode &= ~RMNET_MODE_LLP_ETH; - p->operation_mode |= RMNET_MODE_LLP_IP; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): " - "set IP protocol mode\n", - dev->name); - } - break; - - case RMNET_IOCTL_GET_LLP: /* Get link protocol state */ - ifr->ifr_ifru.ifru_data = - (void *)(p->operation_mode & - (RMNET_MODE_LLP_ETH|RMNET_MODE_LLP_IP)); - break; - - case RMNET_IOCTL_SET_QOS_ENABLE: /* Set QoS header enabled */ - spin_lock_irqsave(&p->lock, flags); - p->operation_mode |= RMNET_MODE_QOS; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): set QMI QOS header enable\n", - dev->name); - break; - - case RMNET_IOCTL_SET_QOS_DISABLE: /* Set QoS header disabled */ - spin_lock_irqsave(&p->lock, flags); - p->operation_mode &= ~RMNET_MODE_QOS; - spin_unlock_irqrestore(&p->lock, flags); - DBG0("[%s] rmnet_ioctl(): set QMI QOS header disable\n", - dev->name); - break; - - case RMNET_IOCTL_GET_QOS: /* Get QoS header state */ - ifr->ifr_ifru.ifru_data = - (void *)(p->operation_mode & RMNET_MODE_QOS); - break; - - case RMNET_IOCTL_GET_OPMODE: /* Get operation mode */ - ifr->ifr_ifru.ifru_data = (void *)p->operation_mode; - break; - - case RMNET_IOCTL_OPEN: /* Open transport port */ - rc = __rmnet_open(dev); - DBG0("[%s] rmnet_ioctl(): open transport port\n", - dev->name); - break; - - case RMNET_IOCTL_CLOSE: /* Close transport port */ - rc = __rmnet_close(dev); - DBG0("[%s] rmnet_ioctl(): close transport port\n", - dev->name); - break; - - default: - pr_err("[%s] error: rmnet_ioct called for unsupported cmd[%d]", - dev->name, cmd); - return -EINVAL; - } - - DBG2("[%s] %s: cmd=0x%x opmode old=0x%08x new=0x%08x\n", - dev->name, __func__, cmd, old_opmode, p->operation_mode); - return rc; -} - -static void __init rmnet_setup(struct net_device *dev) -{ - /* Using Ethernet mode by default */ - dev->netdev_ops = &rmnet_ops_ether; - ether_setup(dev); - - /* set this after calling ether_setup */ - dev->mtu = RMNET_DATA_LEN; - dev->needed_headroom = HEADROOM_FOR_SDIO + HEADROOM_FOR_QOS ; - dev->needed_tailroom = TAILROOM; - random_ether_addr(dev->dev_addr); - - dev->watchdog_timeo = 1000; /* 10 seconds? */ -} - - -static int __init rmnet_init(void) -{ - int ret; - struct device *d; - struct net_device *dev; - struct rmnet_private *p; - unsigned n; - - pr_info("%s: SDIO devices[%d]\n", __func__, RMNET_DEVICE_COUNT); - -#ifdef CONFIG_MSM_RMNET_DEBUG - timeout_us = 0; -#ifdef CONFIG_HAS_EARLYSUSPEND - timeout_suspend_us = 0; -#endif -#endif - - for (n = 0; n < RMNET_DEVICE_COUNT; n++) { - dev = alloc_netdev(sizeof(struct rmnet_private), - "rmnet_sdio%d", rmnet_setup); - - if (!dev) - return -ENOMEM; - - d = &(dev->dev); - p = netdev_priv(dev); - /* Initial config uses Ethernet */ - p->operation_mode = RMNET_MODE_LLP_ETH; - p->ch_id = n; - spin_lock_init(&p->lock); - spin_lock_init(&p->tx_queue_lock); -#ifdef CONFIG_MSM_RMNET_DEBUG - p->timeout_us = timeout_us; - p->wakeups_xmit = p->wakeups_rcv = 0; -#endif - - ret = register_netdev(dev); - if (ret) { - free_netdev(dev); - return ret; - } - -#ifdef CONFIG_MSM_RMNET_DEBUG - if (device_create_file(d, &dev_attr_timeout)) - continue; - if (device_create_file(d, &dev_attr_wakeups_xmit)) - continue; - if (device_create_file(d, &dev_attr_wakeups_rcv)) - continue; -#ifdef CONFIG_HAS_EARLYSUSPEND - if (device_create_file(d, &dev_attr_timeout_suspend)) - continue; - - /* Only care about rmnet0 for suspend/resume tiemout hooks. */ - if (n == 0) - rmnet0 = d; -#endif -#endif - } - return 0; -} - -module_init(rmnet_init); -MODULE_DESCRIPTION("MSM RMNET SDIO TRANSPORT"); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/net/ethernet/msm/qfec.c b/drivers/net/ethernet/msm/qfec.c deleted file mode 100644 index a41072ba13fc01b30d18a45f096e569f1664aa55..0000000000000000000000000000000000000000 --- a/drivers/net/ethernet/msm/qfec.c +++ /dev/null @@ -1,3056 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include - -#include - -#include /* size_t */ -#include /* mark_bh */ - -#include /* struct device, and other headers */ -#include /* eth_type_trans */ -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "qfec.h" - -#define QFEC_NAME "qfec" -#define QFEC_DRV_VER "Apr 09 2013" - -#define ETH_BUF_SIZE 0x600 -#define MAX_N_BD 50 -#define MAC_ADDR_SIZE 6 - -#define RX_TX_BD_RATIO 8 -#define TX_BD_NUM 256 -#define RX_BD_NUM 256 -#define TX_BD_TI_RATIO 4 -#define MAX_MDIO_REG 32 - -#define H_DPLX 0 -#define F_DPLX 1 -/* - * logging macros - */ -#define QFEC_LOG_PR 1 -#define QFEC_LOG_DBG 2 -#define QFEC_LOG_DBG2 4 -#define QFEC_LOG_MDIO_W 8 -#define QFEC_LOG_MDIO_R 16 -#define QFEC_MII_EXP_MASK (EXPANSION_LCWP | EXPANSION_ENABLENPAGE \ - | EXPANSION_NPCAPABLE) - -static int qfec_debug = QFEC_LOG_PR; - -#ifdef QFEC_DEBUG -# define QFEC_LOG(flag, ...) \ - do { \ - if (flag & qfec_debug) \ - pr_info(__VA_ARGS__); \ - } while (0) -#else -# define QFEC_LOG(flag, ...) -#endif - -#define QFEC_LOG_ERR(...) pr_err(__VA_ARGS__) - -/* - * driver buffer-descriptor - * contains the 4 word HW descriptor plus an additional 4-words. - * (See the DSL bits in the BUS-Mode register). - */ -#define BD_FLAG_LAST_BD 1 - -struct buf_desc { - struct qfec_buf_desc *p_desc; - struct sk_buff *skb; - void *buf_virt_addr; - void *buf_phys_addr; - uint32_t last_bd_flag; -}; - -/* - *inline functions accessing non-struct qfec_buf_desc elements - */ - -/* skb */ -static inline struct sk_buff *qfec_bd_skbuf_get(struct buf_desc *p_bd) -{ - return p_bd->skb; -}; - -static inline void qfec_bd_skbuf_set(struct buf_desc *p_bd, struct sk_buff *p) -{ - p_bd->skb = p; -}; - -/* virtual addr */ -static inline void qfec_bd_virt_set(struct buf_desc *p_bd, void *addr) -{ - p_bd->buf_virt_addr = addr; -}; - -static inline void *qfec_bd_virt_get(struct buf_desc *p_bd) -{ - return p_bd->buf_virt_addr; -}; - -/* physical addr */ -static inline void qfec_bd_phys_set(struct buf_desc *p_bd, void *addr) -{ - p_bd->buf_phys_addr = addr; -}; - -static inline void *qfec_bd_phys_get(struct buf_desc *p_bd) -{ - return p_bd->buf_phys_addr; -}; - -/* last_bd_flag */ -static inline uint32_t qfec_bd_last_bd(struct buf_desc *p_bd) -{ - return (p_bd->last_bd_flag != 0); -}; - -static inline void qfec_bd_last_bd_set(struct buf_desc *p_bd) -{ - p_bd->last_bd_flag = BD_FLAG_LAST_BD; -}; - -/* - *inline functions accessing struct qfec_buf_desc elements - */ - -/* ownership bit */ -static inline uint32_t qfec_bd_own(struct buf_desc *p_bd) -{ - return p_bd->p_desc->status & BUF_OWN; -}; - -static inline void qfec_bd_own_set(struct buf_desc *p_bd) -{ - p_bd->p_desc->status |= BUF_OWN ; -}; - -static inline void qfec_bd_own_clr(struct buf_desc *p_bd) -{ - p_bd->p_desc->status &= ~(BUF_OWN); -}; - -static inline uint32_t qfec_bd_status_get(struct buf_desc *p_bd) -{ - return p_bd->p_desc->status; -}; - -static inline void qfec_bd_status_set(struct buf_desc *p_bd, uint32_t status) -{ - p_bd->p_desc->status = status; -}; - -static inline uint32_t qfec_bd_status_len(struct buf_desc *p_bd) -{ - return BUF_RX_FL_GET((*p_bd->p_desc)); -}; - -/* control register */ -static inline void qfec_bd_ctl_reset(struct buf_desc *p_bd) -{ - p_bd->p_desc->ctl = 0; -}; - -static inline uint32_t qfec_bd_ctl_get(struct buf_desc *p_bd) -{ - return p_bd->p_desc->ctl; -}; - -static inline void qfec_bd_ctl_set(struct buf_desc *p_bd, uint32_t val) -{ - p_bd->p_desc->ctl |= val; -}; - -static inline void qfec_bd_ctl_wr(struct buf_desc *p_bd, uint32_t val) -{ - p_bd->p_desc->ctl = val; -}; - -/* pbuf register */ -static inline void *qfec_bd_pbuf_get(struct buf_desc *p_bd) -{ - return p_bd->p_desc->p_buf; -} - -static inline void qfec_bd_pbuf_set(struct buf_desc *p_bd, void *p) -{ - p_bd->p_desc->p_buf = p; -} - -/* next register */ -static inline void *qfec_bd_next_get(struct buf_desc *p_bd) -{ - return p_bd->p_desc->next; -}; - -/* - * initialize an RX BD w/ a new buf - */ -static int qfec_rbd_init(struct net_device *dev, struct buf_desc *p_bd) -{ - struct sk_buff *skb; - void *p; - void *v; - - /* allocate and record ptrs for sk buff */ - skb = dev_alloc_skb(ETH_BUF_SIZE); - if (!skb) - goto err; - - qfec_bd_skbuf_set(p_bd, skb); - - v = skb_put(skb, ETH_BUF_SIZE); - qfec_bd_virt_set(p_bd, v); - - p = (void *) dma_map_single(&dev->dev, - (void *)skb->data, ETH_BUF_SIZE, DMA_FROM_DEVICE); - qfec_bd_pbuf_set(p_bd, p); - qfec_bd_phys_set(p_bd, p); - - /* populate control register */ - /* mark the last BD and set end-of-ring bit */ - qfec_bd_ctl_wr(p_bd, ETH_BUF_SIZE | - (qfec_bd_last_bd(p_bd) ? BUF_RX_RER : 0)); - - qfec_bd_status_set(p_bd, BUF_OWN); - - if (!(qfec_debug & QFEC_LOG_DBG2)) - return 0; - - /* debug messages */ - QFEC_LOG(QFEC_LOG_DBG2, "%s: %p bd\n", __func__, p_bd); - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %p skb\n", __func__, skb); - - QFEC_LOG(QFEC_LOG_DBG2, - "%s: %p p_bd, %p data, %p skb_put, %p virt, %p p_buf, %p p\n", - __func__, (void *)p_bd, - (void *)skb->data, v, /*(void *)skb_put(skb, ETH_BUF_SIZE), */ - (void *)qfec_bd_virt_get(p_bd), (void *)qfec_bd_pbuf_get(p_bd), - (void *)p); - - return 0; - -err: - return -ENOMEM; -}; - -/* - * ring structure used to maintain indices of buffer-descriptor (BD) usage - * - * The RX BDs are normally all pre-allocated with buffers available to be - * DMA'd into with received frames. The head indicates the first BD/buffer - * containing a received frame, and the tail indicates the oldest BD/buffer - * that needs to be restored for use. Head and tail are both initialized - * to zero, and n_free is initialized to zero, since all BD are initialized. - * - * The TX BDs are normally available for use, only being initialized as - * TX frames are requested for transmission. The head indicates the - * first available BD, and the tail indicate the oldest BD that has - * not been acknowledged as transmitted. Head and tail are both initialized - * to zero, and n_free is initialized to len, since all are available for use. - */ -struct ring { - int head; - int tail; - int n_free; - int len; -}; - -/* accessory in line functions for struct ring */ -static inline void qfec_ring_init(struct ring *p_ring, int size, int free) -{ - p_ring->head = p_ring->tail = 0; - p_ring->len = size; - p_ring->n_free = free; -} - -static inline int qfec_ring_full(struct ring *p_ring) -{ - return (p_ring->n_free == 0); -}; - -static inline int qfec_ring_empty(struct ring *p_ring) -{ - return (p_ring->n_free == p_ring->len); -} - -static inline void qfec_ring_head_adv(struct ring *p_ring) -{ - if (++p_ring->head == p_ring->len) - p_ring->head = 0; - p_ring->n_free--; -}; - -static inline void qfec_ring_tail_adv(struct ring *p_ring) -{ - if (++p_ring->tail == p_ring->len) - p_ring->tail = 0; - p_ring->n_free++; -}; - -static inline int qfec_ring_head(struct ring *p_ring) -{ - - return p_ring->head; -}; - -static inline int qfec_ring_tail(struct ring *p_ring) -{ - return p_ring->tail; -}; - -static inline int qfec_ring_room(struct ring *p_ring) -{ - return p_ring->n_free; -}; - -/* - * counters track normal and abnormal driver events and activity - */ -enum cntr { - isr = 0, - fatal_bus, - - early_tx, - tx_no_resource, - tx_proc_stopped, - tx_jabber_tmout, - - xmit, - tx_int, - tx_isr, - tx_owned, - tx_underflow, - - tx_replenish, - tx_skb_null, - tx_timeout, - tx_too_large, - - gmac_isr, - - /* half */ - norm_int, - abnorm_int, - - early_rx, - rx_buf_unavail, - rx_proc_stopped, - rx_watchdog, - - netif_rx_cntr, - rx_int, - rx_isr, - rx_owned, - rx_overflow, - - rx_dropped, - rx_skb_null, - queue_start, - queue_stop, - - rx_paddr_nok, - ts_ioctl, - ts_tx_en, - ts_tx_rtn, - - ts_rec, - cntr_last, -}; - -static char *cntr_name[] = { - "isr", - "fatal_bus", - - "early_tx", - "tx_no_resource", - "tx_proc_stopped", - "tx_jabber_tmout", - - "xmit", - "tx_int", - "tx_isr", - "tx_owned", - "tx_underflow", - - "tx_replenish", - "tx_skb_null", - "tx_timeout", - "tx_too_large", - - "gmac_isr", - - /* half */ - "norm_int", - "abnorm_int", - - "early_rx", - "rx_buf_unavail", - "rx_proc_stopped", - "rx_watchdog", - - "netif_rx", - "rx_int", - "rx_isr", - "rx_owned", - "rx_overflow", - - "rx_dropped", - "rx_skb_null", - "queue_start", - "queue_stop", - - "rx_paddr_nok", - "ts_ioctl", - "ts_tx_en", - "ts_tx_rtn", - - "ts_rec", - "" -}; - -/* - * private data - */ - -static struct net_device *qfec_dev; - -enum qfec_state { - timestamping = 0x04, -}; - -struct qfec_priv { - struct net_device *net_dev; - struct net_device_stats stats; /* req statistics */ - - struct device dev; - - spinlock_t xmit_lock; - spinlock_t mdio_lock; - - unsigned int state; /* driver state */ - - unsigned int bd_size; /* buf-desc alloc size */ - struct qfec_buf_desc *bd_base; /* * qfec-buf-desc */ - dma_addr_t tbd_dma; /* dma/phy-addr buf-desc */ - dma_addr_t rbd_dma; /* dma/phy-addr buf-desc */ - - struct resource *mac_res; - void *mac_base; /* mac (virt) base address */ - - struct resource *clk_res; - void *clk_base; /* clk (virt) base address */ - - struct resource *fuse_res; - void *fuse_base; /* mac addr fuses */ - - unsigned int n_tbd; /* # of TX buf-desc */ - struct ring ring_tbd; /* TX ring */ - struct buf_desc *p_tbd; - unsigned int tx_ic_mod; /* (%) val for setting IC */ - - unsigned int n_rbd; /* # of RX buf-desc */ - struct ring ring_rbd; /* RX ring */ - struct buf_desc *p_rbd; - - struct buf_desc *p_latest_rbd; - struct buf_desc *p_ending_rbd; - - unsigned long cntr[cntr_last]; /* activity counters */ - - struct mii_if_info mii; /* used by mii lib */ - - int mdio_clk; /* phy mdio clock rate */ - int phy_id; /* default PHY addr (0) */ - struct timer_list phy_tmr; /* monitor PHY state */ -}; - -/* - * cntrs display - */ - -static int qfec_cntrs_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int h = (cntr_last + 1) / 2; - int l; - int n; - int count = PAGE_SIZE; - - QFEC_LOG(QFEC_LOG_DBG2, "%s:\n", __func__); - - l = snprintf(&buf[0], count, "%s:\n", __func__); - for (n = 0; n < h; n++) { - l += snprintf(&buf[l], count - l, - " %12lu %-16s %12lu %s\n", - priv->cntr[n], cntr_name[n], - priv->cntr[n+h], cntr_name[n+h]); - } - - return l; -} - -# define CNTR_INC(priv, name) (priv->cntr[name]++) - -/* - * functions that manage state - */ -static inline void qfec_queue_start(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - - if (netif_queue_stopped(dev)) { - netif_wake_queue(dev); - CNTR_INC(priv, queue_start); - } -}; - -static inline void qfec_queue_stop(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - - netif_stop_queue(dev); - CNTR_INC(priv, queue_stop); -}; - -/* - * functions to access and initialize the MAC registers - */ -static inline uint32_t qfec_reg_read(struct qfec_priv *priv, uint32_t reg) -{ - return ioread32((void *) (priv->mac_base + reg)); -} - -static void qfec_reg_write(struct qfec_priv *priv, uint32_t reg, uint32_t val) -{ - uint32_t addr = (uint32_t)priv->mac_base + reg; - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %08x <- %08x\n", __func__, addr, val); - iowrite32(val, (void *)addr); -} - -/* - * speed/duplex/pause settings - */ -static int qfec_config_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int cfg = qfec_reg_read(priv, MAC_CONFIG_REG); - int flow = qfec_reg_read(priv, FLOW_CONTROL_REG); - int l = 0; - int count = PAGE_SIZE; - - QFEC_LOG(QFEC_LOG_DBG2, "%s:\n", __func__); - - l += snprintf(&buf[l], count, "%s:", __func__); - - l += snprintf(&buf[l], count - l, " [0x%08x] %4dM %s %s", cfg, - (cfg & MAC_CONFIG_REG_PS) - ? ((cfg & MAC_CONFIG_REG_FES) ? 100 : 10) : 1000, - cfg & MAC_CONFIG_REG_DM ? "FD" : "HD", - cfg & MAC_CONFIG_REG_IPC ? "IPC" : "NoIPC"); - - flow &= FLOW_CONTROL_RFE | FLOW_CONTROL_TFE; - l += snprintf(&buf[l], count - l, " [0x%08x] %s", flow, - (flow == (FLOW_CONTROL_RFE | FLOW_CONTROL_TFE)) ? "PAUSE" - : ((flow == FLOW_CONTROL_RFE) ? "RX-PAUSE" - : ((flow == FLOW_CONTROL_TFE) ? "TX-PAUSE" : ""))); - - l += snprintf(&buf[l], count - l, " %s", QFEC_DRV_VER); - l += snprintf(&buf[l], count - l, "\n"); - return l; -} - - -/* - * table and functions to initialize controller registers - */ - -struct reg_entry { - unsigned int rdonly; - unsigned int addr; - char *label; - unsigned int val; -}; - -static struct reg_entry qfec_reg_tbl[] = { - { 0, BUS_MODE_REG, "BUS_MODE_REG", BUS_MODE_REG_DEFAULT }, - { 0, AXI_BUS_MODE_REG, "AXI_BUS_MODE_REG", AXI_BUS_MODE_DEFAULT }, - { 0, AXI_STATUS_REG, "AXI_STATUS_REG", 0 }, - - { 0, MAC_ADR_0_HIGH_REG, "MAC_ADR_0_HIGH_REG", 0x00000302 }, - { 0, MAC_ADR_0_LOW_REG, "MAC_ADR_0_LOW_REG", 0x01350702 }, - - { 1, RX_DES_LST_ADR_REG, "RX_DES_LST_ADR_REG", 0 }, - { 1, TX_DES_LST_ADR_REG, "TX_DES_LST_ADR_REG", 0 }, - { 1, STATUS_REG, "STATUS_REG", 0 }, - { 1, DEBUG_REG, "DEBUG_REG", 0 }, - - { 0, INTRP_EN_REG, "INTRP_EN_REG", QFEC_INTRP_SETUP}, - - { 1, CUR_HOST_TX_DES_REG, "CUR_HOST_TX_DES_REG", 0 }, - { 1, CUR_HOST_RX_DES_REG, "CUR_HOST_RX_DES_REG", 0 }, - { 1, CUR_HOST_TX_BU_ADR_REG, "CUR_HOST_TX_BU_ADR_REG", 0 }, - { 1, CUR_HOST_RX_BU_ADR_REG, "CUR_HOST_RX_BU_ADR_REG", 0 }, - - { 1, MAC_FR_FILTER_REG, "MAC_FR_FILTER_REG", 0 }, - - { 0, MAC_CONFIG_REG, "MAC_CONFIG_REG", MAC_CONFIG_REG_SPD_1G - | MAC_CONFIG_REG_DM - | MAC_CONFIG_REG_TE - | MAC_CONFIG_REG_RE - | MAC_CONFIG_REG_IPC }, - - { 1, INTRP_STATUS_REG, "INTRP_STATUS_REG", 0 }, - { 1, INTRP_MASK_REG, "INTRP_MASK_REG", 0 }, - - { 0, OPER_MODE_REG, "OPER_MODE_REG", OPER_MODE_REG_DEFAULT }, - - { 1, GMII_ADR_REG, "GMII_ADR_REG", 0 }, - { 1, GMII_DATA_REG, "GMII_DATA_REG", 0 }, - - { 0, MMC_INTR_MASK_RX_REG, "MMC_INTR_MASK_RX_REG", 0xFFFFFFFF }, - { 0, MMC_INTR_MASK_TX_REG, "MMC_INTR_MASK_TX_REG", 0xFFFFFFFF }, - - { 1, TS_HIGH_REG, "TS_HIGH_REG", 0 }, - { 1, TS_LOW_REG, "TS_LOW_REG", 0 }, - - { 1, TS_HI_UPDT_REG, "TS_HI_UPDATE_REG", 0 }, - { 1, TS_LO_UPDT_REG, "TS_LO_UPDATE_REG", 0 }, - { 0, TS_SUB_SEC_INCR_REG, "TS_SUB_SEC_INCR_REG", 40 }, - { 0, TS_CTL_REG, "TS_CTL_REG", TS_CTL_TSENALL - | TS_CTL_TSCTRLSSR - | TS_CTL_TSINIT - | TS_CTL_TSENA }, -}; - -static void qfec_reg_init(struct qfec_priv *priv) -{ - struct reg_entry *p = qfec_reg_tbl; - int n = ARRAY_SIZE(qfec_reg_tbl); - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - for (; n--; p++) { - if (!p->rdonly) - qfec_reg_write(priv, p->addr, p->val); - } -} - -/* - * display registers thru sysfs - */ -static int qfec_reg_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - struct reg_entry *p = qfec_reg_tbl; - int n = ARRAY_SIZE(qfec_reg_tbl); - int l = 0; - int count = PAGE_SIZE; - - QFEC_LOG(QFEC_LOG_DBG2, "%s:\n", __func__); - - for (; n--; p++) { - l += snprintf(&buf[l], count - l, " %8p %04x %08x %s\n", - (void *)priv->mac_base + p->addr, p->addr, - qfec_reg_read(priv, p->addr), p->label); - } - - return l; -} - -/* - * set the MAC-0 address - */ -static void qfec_set_adr_regs(struct qfec_priv *priv, uint8_t *addr) -{ - uint32_t h = 0; - uint32_t l = 0; - - h = h << 8 | addr[5]; - h = h << 8 | addr[4]; - - l = l << 8 | addr[3]; - l = l << 8 | addr[2]; - l = l << 8 | addr[1]; - l = l << 8 | addr[0]; - - qfec_reg_write(priv, MAC_ADR_0_HIGH_REG, h); - qfec_reg_write(priv, MAC_ADR_0_LOW_REG, l); - - QFEC_LOG(QFEC_LOG_DBG, "%s: %08x %08x\n", __func__, h, l); -} - -/* - * set up the RX filter - */ -static void qfec_set_rx_mode(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - uint32_t filter_conf; - int index; - - /* Clear address filter entries */ - for (index = 1; index < MAC_ADR_MAX; ++index) { - qfec_reg_write(priv, MAC_ADR_HIGH_REG_N(index), 0); - qfec_reg_write(priv, MAC_ADR_LOW_REG_N(index), 0); - } - - if (dev->flags & IFF_PROMISC) { - /* Receive all frames */ - filter_conf = MAC_FR_FILTER_RA; - } else if ((dev->flags & IFF_MULTICAST) == 0) { - /* Unicast filtering only */ - filter_conf = MAC_FR_FILTER_HPF; - } else if ((netdev_mc_count(dev) > MAC_ADR_MAX - 1) || - (dev->flags & IFF_ALLMULTI)) { - /* Unicast filtering is enabled, Pass all multicast frames */ - filter_conf = MAC_FR_FILTER_HPF | MAC_FR_FILTER_PM; - } else { - struct netdev_hw_addr *ha; - - /* Both unicast and multicast filtering are enabled */ - filter_conf = MAC_FR_FILTER_HPF; - - index = 1; - - netdev_for_each_mc_addr(ha, dev) { - uint32_t high, low; - - high = (1 << 31) | (ha->addr[5] << 8) | (ha->addr[4]); - low = (ha->addr[3] << 24) | (ha->addr[2] << 16) | - (ha->addr[1] << 8) | (ha->addr[0]); - - qfec_reg_write(priv, MAC_ADR_HIGH_REG_N(index), high); - qfec_reg_write(priv, MAC_ADR_LOW_REG_N(index), low); - - index++; - } - } - - qfec_reg_write(priv, MAC_FR_FILTER_REG, filter_conf); -} - -/* - * reset the controller - */ - -#define QFEC_RESET_TIMEOUT 10000 - /* reset should always clear but did not w/o test/delay - * in RgMii mode. there is no spec'd max timeout - */ - -static int qfec_hw_reset(struct qfec_priv *priv) -{ - int timeout = QFEC_RESET_TIMEOUT; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - qfec_reg_write(priv, BUS_MODE_REG, BUS_MODE_SWR); - - while (qfec_reg_read(priv, BUS_MODE_REG) & BUS_MODE_SWR) { - if (timeout-- == 0) { - QFEC_LOG_ERR("%s: timeout\n", __func__); - return -ETIME; - } - - /* there were problems resetting the controller - * in RGMII mode when there wasn't sufficient - * delay between register reads - */ - usleep_range(100, 200); - } - - return 0; -} - -/* - * initialize controller - */ -static int qfec_hw_init(struct qfec_priv *priv) -{ - int res = 0; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - res = qfec_hw_reset(priv); - if (res) - return res; - - qfec_reg_init(priv); - - /* config buf-desc locations */ - qfec_reg_write(priv, TX_DES_LST_ADR_REG, priv->tbd_dma); - qfec_reg_write(priv, RX_DES_LST_ADR_REG, priv->rbd_dma); - - /* clear interrupts */ - qfec_reg_write(priv, STATUS_REG, INTRP_EN_REG_NIE | INTRP_EN_REG_RIE - | INTRP_EN_REG_TIE | INTRP_EN_REG_TUE | INTRP_EN_REG_ETE); - - if (priv->mii.supports_gmii) { - /* Clear RGMII */ - qfec_reg_read(priv, SG_RG_SMII_STATUS_REG); - /* Disable RGMII int */ - qfec_reg_write(priv, INTRP_MASK_REG, 1); - } - - return res; -} - -/* - * en/disable controller - */ -static void qfec_hw_enable(struct qfec_priv *priv) -{ - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - qfec_reg_write(priv, OPER_MODE_REG, - qfec_reg_read(priv, OPER_MODE_REG) - | OPER_MODE_REG_ST | OPER_MODE_REG_SR); -} - -static void qfec_hw_disable(struct qfec_priv *priv) -{ - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - qfec_reg_write(priv, OPER_MODE_REG, - qfec_reg_read(priv, OPER_MODE_REG) - & ~(OPER_MODE_REG_ST | OPER_MODE_REG_SR)); -} - -/* - * interface selection - */ -struct intf_config { - uint32_t intf_sel; - uint32_t emac_ns; - uint32_t eth_x_en_ns; - uint32_t clkmux_sel; -}; - -#define ETH_X_EN_NS_REVMII (ETH_X_EN_NS_DEFAULT | ETH_TX_CLK_INV) -#define CLKMUX_REVMII (EMAC_CLKMUX_SEL_0 | EMAC_CLKMUX_SEL_1) - -static struct intf_config intf_config_tbl[] = { - { EMAC_PHY_INTF_SEL_MII, EMAC_NS_DEFAULT, ETH_X_EN_NS_DEFAULT, 0 }, - { EMAC_PHY_INTF_SEL_RGMII, EMAC_NS_DEFAULT, ETH_X_EN_NS_DEFAULT, 0 }, - { EMAC_PHY_INTF_SEL_REVMII, EMAC_NS_DEFAULT, ETH_X_EN_NS_REVMII, - CLKMUX_REVMII } -}; - -/* - * emac clk register read and write functions - */ -static inline uint32_t qfec_clkreg_read(struct qfec_priv *priv, uint32_t reg) -{ - return ioread32((void *) (priv->clk_base + reg)); -} - -static inline void qfec_clkreg_write(struct qfec_priv *priv, - uint32_t reg, uint32_t val) -{ - uint32_t addr = (uint32_t)priv->clk_base + reg; - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %08x <- %08x\n", __func__, addr, val); - iowrite32(val, (void *)addr); -} - -/* - * configure the PHY interface and clock routing and signal bits - */ -enum phy_intfc { - INTFC_MII = 0, - INTFC_RGMII = 1, - INTFC_REVMII = 2, -}; - -static int qfec_intf_sel(struct qfec_priv *priv, unsigned int intfc) -{ - struct intf_config *p; - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %d\n", __func__, intfc); - - if (intfc > INTFC_REVMII) { - QFEC_LOG_ERR("%s: range\n", __func__); - return -ENXIO; - } - - p = &intf_config_tbl[intfc]; - - qfec_clkreg_write(priv, EMAC_PHY_INTF_SEL_REG, p->intf_sel); - qfec_clkreg_write(priv, EMAC_NS_REG, p->emac_ns); - qfec_clkreg_write(priv, ETH_X_EN_NS_REG, p->eth_x_en_ns); - qfec_clkreg_write(priv, EMAC_CLKMUX_SEL_REG, p->clkmux_sel); - - return 0; -} - -/* - * display registers thru proc-fs - */ -static struct qfec_clk_reg { - uint32_t offset; - char *label; -} qfec_clk_regs[] = { - { ETH_MD_REG, "ETH_MD_REG" }, - { ETH_NS_REG, "ETH_NS_REG" }, - { ETH_X_EN_NS_REG, "ETH_X_EN_NS_REG" }, - { EMAC_PTP_MD_REG, "EMAC_PTP_MD_REG" }, - { EMAC_PTP_NS_REG, "EMAC_PTP_NS_REG" }, - { EMAC_NS_REG, "EMAC_NS_REG" }, - { EMAC_TX_FS_REG, "EMAC_TX_FS_REG" }, - { EMAC_RX_FS_REG, "EMAC_RX_FS_REG" }, - { EMAC_PHY_INTF_SEL_REG, "EMAC_PHY_INTF_SEL_REG" }, - { EMAC_PHY_ADDR_REG, "EMAC_PHY_ADDR_REG" }, - { EMAC_REVMII_PHY_ADDR_REG, "EMAC_REVMII_PHY_ADDR_REG" }, - { EMAC_CLKMUX_SEL_REG, "EMAC_CLKMUX_SEL_REG" }, -}; - -static int qfec_clk_reg_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - struct qfec_clk_reg *p = qfec_clk_regs; - int n = ARRAY_SIZE(qfec_clk_regs); - int l = 0; - int count = PAGE_SIZE; - - QFEC_LOG(QFEC_LOG_DBG2, "%s:\n", __func__); - - for (; n--; p++) { - l += snprintf(&buf[l], count - l, " %8p %8x %08x %s\n", - (void *)priv->clk_base + p->offset, p->offset, - qfec_clkreg_read(priv, p->offset), p->label); - } - - return l; -} - -/* - * speed selection - */ - -struct qfec_pll_cfg { - uint32_t spd; - uint32_t eth_md; /* M [31:16], NOT 2*D [15:0] */ - uint32_t eth_ns; /* NOT(M-N) [31:16], ctl bits [11:0] */ -}; - -static struct qfec_pll_cfg qfec_pll_cfg_tbl[] = { - /* 2.5 MHz */ - { MAC_CONFIG_REG_SPD_10, ETH_MD_M(1) | ETH_MD_2D_N(100), - ETH_NS_NM(100-1) - | ETH_NS_MCNTR_EN - | ETH_NS_MCNTR_MODE_DUAL - | ETH_NS_PRE_DIV(0) - | CLK_SRC_PLL_EMAC }, - /* 25 MHz */ - { MAC_CONFIG_REG_SPD_100, ETH_MD_M(1) | ETH_MD_2D_N(10), - ETH_NS_NM(10-1) - | ETH_NS_MCNTR_EN - | ETH_NS_MCNTR_MODE_DUAL - | ETH_NS_PRE_DIV(0) - | CLK_SRC_PLL_EMAC }, - /* 125 MHz */ - {MAC_CONFIG_REG_SPD_1G, 0, ETH_NS_PRE_DIV(1) - | CLK_SRC_PLL_EMAC }, -}; - -enum speed { - SPD_10 = 0, - SPD_100 = 1, - SPD_1000 = 2, -}; - -/* - * configure the PHY interface and clock routing and signal bits - */ -static int qfec_speed_cfg(struct net_device *dev, unsigned int spd, - unsigned int dplx) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct qfec_pll_cfg *p; - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %d spd, %d dplx\n", __func__, spd, dplx); - - if (spd > SPD_1000) { - QFEC_LOG_ERR("%s: range\n", __func__); - return -ENODEV; - } - - p = &qfec_pll_cfg_tbl[spd]; - - /* set the MAC speed bits */ - qfec_reg_write(priv, MAC_CONFIG_REG, - (qfec_reg_read(priv, MAC_CONFIG_REG) - & ~(MAC_CONFIG_REG_SPD | MAC_CONFIG_REG_DM)) - | p->spd | (dplx ? MAC_CONFIG_REG_DM : H_DPLX)); - - qfec_clkreg_write(priv, ETH_MD_REG, p->eth_md); - qfec_clkreg_write(priv, ETH_NS_REG, p->eth_ns); - - return 0; -} - -/* - * configure PTP divider for 25 MHz assuming EMAC PLL 250 MHz - */ -static struct qfec_pll_cfg qfec_pll_ptp = { - 0, - - ETH_MD_M(1) | ETH_MD_2D_N(10), - - ETH_NS_NM(10-1) | - EMAC_PTP_NS_ROOT_EN | - EMAC_PTP_NS_CLK_EN | - ETH_NS_MCNTR_EN | - ETH_NS_MCNTR_MODE_DUAL | - ETH_NS_PRE_DIV(0) | - CLK_SRC_PLL_EMAC -}; - -#define PLLTEST_PAD_CFG 0x01E0 -#define PLLTEST_PLL_7 0x3700 - -#define CLKTEST_REG 0x01EC -#define CLKTEST_EMAC_RX 0x3fc07f7a - -static int qfec_ptp_cfg(struct qfec_priv *priv) -{ - struct qfec_pll_cfg *p = &qfec_pll_ptp; - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %08x md, %08x ns\n", - __func__, p->eth_md, p->eth_ns); - - qfec_clkreg_write(priv, EMAC_PTP_MD_REG, p->eth_md); - qfec_clkreg_write(priv, EMAC_PTP_NS_REG, p->eth_ns); - - /* configure HS/LS clk test ports to verify clks */ - qfec_clkreg_write(priv, CLKTEST_REG, CLKTEST_EMAC_RX); - qfec_clkreg_write(priv, PLLTEST_PAD_CFG, PLLTEST_PLL_7); - - return 0; -} - -/* - * MDIO operations - */ - -/* - * wait reasonable amount of time for MDIO operation to complete, not busy - */ -static int qfec_mdio_busy(struct net_device *dev) -{ - int i; - - for (i = 100; i > 0; i--) { - if (!(qfec_reg_read( - netdev_priv(dev), GMII_ADR_REG) & GMII_ADR_REG_GB)) { - return 0; - } - udelay(1); - } - - return -ETIME; -} - -/* - * initiate either a read or write MDIO operation - */ - -static int qfec_mdio_oper(struct net_device *dev, int phy_id, int reg, int wr) -{ - struct qfec_priv *priv = netdev_priv(dev); - int res = 0; - - /* insure phy not busy */ - res = qfec_mdio_busy(dev); - if (res) { - QFEC_LOG_ERR("%s: busy\n", __func__); - goto done; - } - - /* initiate operation */ - qfec_reg_write(priv, GMII_ADR_REG, - GMII_ADR_REG_ADR_SET(phy_id) - | GMII_ADR_REG_REG_SET(reg) - | GMII_ADR_REG_CSR_SET(priv->mdio_clk) - | (wr ? GMII_ADR_REG_GW : 0) - | GMII_ADR_REG_GB); - - /* wait for operation to complete */ - res = qfec_mdio_busy(dev); - if (res) - QFEC_LOG_ERR("%s: timeout\n", __func__); - -done: - return res; -} - -/* - * read MDIO register - */ -static int qfec_mdio_read(struct net_device *dev, int phy_id, int reg) -{ - struct qfec_priv *priv = netdev_priv(dev); - int res = 0; - unsigned long flags; - - spin_lock_irqsave(&priv->mdio_lock, flags); - - res = qfec_mdio_oper(dev, phy_id, reg, 0); - if (res) { - QFEC_LOG_ERR("%s: oper\n", __func__); - goto done; - } - - res = qfec_reg_read(priv, GMII_DATA_REG); - QFEC_LOG(QFEC_LOG_MDIO_R, "%s: %2d reg, 0x%04x val\n", - __func__, reg, res); - -done: - spin_unlock_irqrestore(&priv->mdio_lock, flags); - return res; -} - -/* - * write MDIO register - */ -static void qfec_mdio_write(struct net_device *dev, int phy_id, int reg, - int val) -{ - struct qfec_priv *priv = netdev_priv(dev); - unsigned long flags; - - spin_lock_irqsave(&priv->mdio_lock, flags); - - QFEC_LOG(QFEC_LOG_MDIO_W, "%s: %2d reg, %04x\n", - __func__, reg, val); - - qfec_reg_write(priv, GMII_DATA_REG, val); - - if (qfec_mdio_oper(dev, phy_id, reg, 1)) - QFEC_LOG_ERR("%s: oper\n", __func__); - - spin_unlock_irqrestore(&priv->mdio_lock, flags); -} - -/* - * MDIO show - */ -static int qfec_mdio_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int n; - int l = 0; - int count = PAGE_SIZE; - - QFEC_LOG(QFEC_LOG_DBG2, "%s:\n", __func__); - - for (n = 0; n < MAX_MDIO_REG; n++) { - if (!(n % 8)) - l += snprintf(&buf[l], count - l, "\n %02x: ", n); - - l += snprintf(&buf[l], count - l, " %04x", - qfec_mdio_read(to_net_dev(dev), priv->phy_id, n)); - } - l += snprintf(&buf[l], count - l, "\n"); - - return l; -} - -/* - * get auto-negotiation results - */ -#define QFEC_100 (LPA_100HALF | LPA_100FULL | LPA_100HALF) -#define QFEC_100_FD (LPA_100FULL | LPA_100BASE4) -#define QFEC_10 (LPA_10HALF | LPA_10FULL) -#define QFEC_10_FD LPA_10FULL - -static void qfec_get_an(struct net_device *dev, uint32_t *spd, uint32_t *dplx) -{ - struct qfec_priv *priv = netdev_priv(dev); - uint32_t advert = qfec_mdio_read(dev, priv->phy_id, MII_ADVERTISE); - uint32_t lpa = qfec_mdio_read(dev, priv->phy_id, MII_LPA); - uint32_t mastCtrl = qfec_mdio_read(dev, priv->phy_id, MII_CTRL1000); - uint32_t mastStat = qfec_mdio_read(dev, priv->phy_id, MII_STAT1000); - uint32_t anExp = qfec_mdio_read(dev, priv->phy_id, MII_EXPANSION); - uint32_t status = advert & lpa; - uint32_t flow; - - if (priv->mii.supports_gmii) { - if (((anExp & QFEC_MII_EXP_MASK) == QFEC_MII_EXP_MASK) - && (mastCtrl & ADVERTISE_1000FULL) - && (mastStat & LPA_1000FULL)) { - *spd = SPD_1000; - *dplx = F_DPLX; - goto pause; - } - - else if (((anExp & QFEC_MII_EXP_MASK) == QFEC_MII_EXP_MASK) - && (mastCtrl & ADVERTISE_1000HALF) - && (mastStat & LPA_1000HALF)) { - *spd = SPD_1000; - *dplx = H_DPLX; - goto pause; - } - } - - /* mii speeds */ - if (status & QFEC_100) { - *spd = SPD_100; - *dplx = status & QFEC_100_FD ? F_DPLX : H_DPLX; - } - - else if (status & QFEC_10) { - *spd = SPD_10; - *dplx = status & QFEC_10_FD ? F_DPLX : H_DPLX; - } - - /* check pause */ -pause: - flow = qfec_reg_read(priv, FLOW_CONTROL_REG); - flow &= ~(FLOW_CONTROL_TFE | FLOW_CONTROL_RFE); - - if (status & ADVERTISE_PAUSE_CAP) { - flow |= FLOW_CONTROL_RFE | FLOW_CONTROL_TFE; - } else if (status & ADVERTISE_PAUSE_ASYM) { - if (lpa & ADVERTISE_PAUSE_CAP) - flow |= FLOW_CONTROL_TFE; - else if (advert & ADVERTISE_PAUSE_CAP) - flow |= FLOW_CONTROL_RFE; - } - - qfec_reg_write(priv, FLOW_CONTROL_REG, flow); -} - -/* - * monitor phy status, and process auto-neg results when changed - */ - -static void qfec_phy_monitor(unsigned long data) -{ - struct net_device *dev = (struct net_device *) data; - struct qfec_priv *priv = netdev_priv(dev); - unsigned int spd = H_DPLX; - unsigned int dplx = F_DPLX; - - mod_timer(&priv->phy_tmr, jiffies + HZ); - - if (mii_link_ok(&priv->mii) && !netif_carrier_ok(priv->net_dev)) { - qfec_get_an(dev, &spd, &dplx); - qfec_speed_cfg(dev, spd, dplx); - QFEC_LOG(QFEC_LOG_DBG, "%s: link up, %d spd, %d dplx\n", - __func__, spd, dplx); - - netif_carrier_on(dev); - } - - else if (!mii_link_ok(&priv->mii) && netif_carrier_ok(priv->net_dev)) { - QFEC_LOG(QFEC_LOG_DBG, "%s: link down\n", __func__); - netif_carrier_off(dev); - } -} - -/* - * dealloc buffer descriptor memory - */ - -static void qfec_mem_dealloc(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - - dma_free_coherent(&dev->dev, - priv->bd_size, priv->bd_base, priv->tbd_dma); - priv->bd_base = 0; -} - -/* - * allocate shared device memory for TX/RX buf-desc (and buffers) - */ - -static int qfec_mem_alloc(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - - QFEC_LOG(QFEC_LOG_DBG, "%s: %p dev\n", __func__, dev); - - priv->bd_size = - (priv->n_tbd + priv->n_rbd) * sizeof(struct qfec_buf_desc); - - priv->p_tbd = kcalloc(priv->n_tbd, sizeof(struct buf_desc), GFP_KERNEL); - if (!priv->p_tbd) { - QFEC_LOG_ERR("%s: kcalloc failed p_tbd\n", __func__); - return -ENOMEM; - } - - priv->p_rbd = kcalloc(priv->n_rbd, sizeof(struct buf_desc), GFP_KERNEL); - if (!priv->p_rbd) { - QFEC_LOG_ERR("%s: kcalloc failed p_rbd\n", __func__); - return -ENOMEM; - } - - /* alloc mem for buf-desc, if not already alloc'd */ - if (!priv->bd_base) { - priv->bd_base = dma_alloc_coherent(&dev->dev, - priv->bd_size, &priv->tbd_dma, - GFP_KERNEL | __GFP_DMA); - } - - if (!priv->bd_base) { - QFEC_LOG_ERR("%s: dma_alloc_coherent failed\n", __func__); - return -ENOMEM; - } - - priv->rbd_dma = priv->tbd_dma - + (priv->n_tbd * sizeof(struct qfec_buf_desc)); - - QFEC_LOG(QFEC_LOG_DBG, - " %s: 0x%08x size, %d n_tbd, %d n_rbd\n", - __func__, priv->bd_size, priv->n_tbd, priv->n_rbd); - - return 0; -} - -/* - * display buffer descriptors - */ - -static int qfec_bd_fmt(char *buf, int size, struct buf_desc *p_bd) -{ - return snprintf(buf, size, - "%8p: %08x %08x %8p %8p %8p %8p %8p %x", - p_bd, qfec_bd_status_get(p_bd), - qfec_bd_ctl_get(p_bd), qfec_bd_pbuf_get(p_bd), - qfec_bd_next_get(p_bd), qfec_bd_skbuf_get(p_bd), - qfec_bd_virt_get(p_bd), qfec_bd_phys_get(p_bd), - qfec_bd_last_bd(p_bd)); -} - -static int qfec_bd_show(char *buf, int count, struct buf_desc *p_bd, int n_bd, - struct ring *p_ring, char *label) -{ - int l = 0; - int n; - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %s\n", __func__, label); - - l += snprintf(&buf[l], count, "%s: %s\n", __func__, label); - if (!p_bd) - return l; - - n_bd = n_bd > MAX_N_BD ? MAX_N_BD : n_bd; - - for (n = 0; n < n_bd; n++, p_bd++) { - l += qfec_bd_fmt(&buf[l], count - l, p_bd); - l += snprintf(&buf[l], count - l, "%s%s\n", - (qfec_ring_head(p_ring) == n ? " < h" : ""), - (qfec_ring_tail(p_ring) == n ? " < t" : "")); - } - - return l; -} - -/* - * display TX BDs - */ -static int qfec_bd_tx_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int count = PAGE_SIZE; - - return qfec_bd_show(buf, count, priv->p_tbd, priv->n_tbd, - &priv->ring_tbd, "TX"); -} - -/* - * display RX BDs - */ -static int qfec_bd_rx_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int count = PAGE_SIZE; - - return qfec_bd_show(buf, count, priv->p_rbd, priv->n_rbd, - &priv->ring_rbd, "RX"); -} - -/* - * The Ethernet core includes IEEE-1588 support. This includes - * TS_HIGH_REG and TS_LOW_REG registers driven by an external clock. - * Each external clock cycle causes the TS_LOW_REG register to - * increment by the value in TS_SUB_SEC_INCR_REG (e.g. set to 40 using - * a 25 MHz clock). Unfortunately, TS_HIGH_REG increments when - * TS_LOW_REG overflows at 2^31 instead of 10^9. - * - * Conversion requires scaling (dividing) the 63-bit concatenated - * timestamp register value by 10^9 to determine seconds, and taking - * the remainder to determine nsec. Since division is to be avoided, - * a combination of multiplication and shift (>>) minimizes the number - * of operations. - * - * To avoid loss of data, the timestamp value is multipled by 2<<30 / - * 10^9, and the result scaled by 2<<30 (i.e. >> 30). The shift value - * of 30 is determining the log-2 value of the denominator (10^9), - * 29.9, and rounding up, 30. - */ -/* ------------------------------------------------ - * conversion factors - */ -#define TS_LOW_REG_BITS 31 -#define TS_LOW_REG_MASK (((uint64_t)1 << TS_LOW_REG_BITS) - 1) - -#define MILLION 1000000UL -#define BILLION 1000000000UL - -#define F_CLK BILLION -#define F_CLK_PRE_SC 30 -#define F_CLK_INV_Q 60 -#define F_CLK_INV (((uint64_t)1 << F_CLK_INV_Q) / F_CLK) - -#define F_CLK_TO_NS_Q 25 -#define F_CLK_TO_NS \ - (((((uint64_t)1<> 32; - *tsRegLoPtr = cnt & 0xffffffff; -} - -/* - * qfec_hilo_2secnsec - converts Etherent timestamp register values to - * sec and nsec - */ -static inline void qfec_hilo_2secnsec( - uint32_t tsRegHi, - uint32_t tsRegLo, - uint32_t *secPtr, - uint32_t *nsecPtr) -{ - uint64_t cnt; - uint64_t hi; - uint64_t subsec = 0; - - cnt = tsRegHi; - cnt <<= TS_LOW_REG_BITS; - cnt += tsRegLo; - - hi = cnt >> F_CLK_PRE_SC; - hi *= F_CLK_INV; - hi >>= F_CLK_INV_Q - F_CLK_PRE_SC; - - *secPtr = hi; - subsec = cnt - (hi * F_CLK); - - while (subsec > F_CLK) { - subsec -= F_CLK; - *secPtr += 1; - } - - *nsecPtr = subsec; -} - -/* - * qfec_secnsec_2hilo - converts sec and nsec to Etherent timestamp - * register values - */ -static inline void qfec_secnsec_2hilo( - uint32_t sec, - uint32_t nsec, - uint32_t *tsRegHiPtr, - uint32_t *tsRegLoPtr) -{ - uint64_t cnt; - uint64_t subsec; - - subsec = nsec; - - cnt = F_CLK; - cnt *= sec; - cnt += subsec; - - *tsRegHiPtr = cnt >> TS_LOW_REG_BITS; - *tsRegLoPtr = cnt & TS_LOW_REG_MASK; -} - -/* - * qfec_reg_and_time -- - * - * This function does two things: - * - * 1) Retrieves and returns the high and low time registers, and - * - * 2) Converts then returns those high and low register values as - * their seconds and nanoseconds equivalents. - */ -static inline void qfec_reg_and_time( - struct qfec_priv *privPtr, - uint32_t *tsHiPtr, - uint32_t *tsLoPtr, - uint32_t *secPtr, - uint32_t *nsecPtr) -{ - /* - * Read/capture the high and low timestamp registers values. - * - * Insure that the high register's value doesn't increment during read. - */ - do { - *tsHiPtr = qfec_reg_read(privPtr, TS_HIGH_REG); - *tsLoPtr = qfec_reg_read(privPtr, TS_LOW_REG); - } while (*tsHiPtr != qfec_reg_read(privPtr, TS_HIGH_REG)); - - /* - * Convert high and low time registers to secs and nsecs... - */ - qfec_hilo_2secnsec(*tsHiPtr, *tsLoPtr, secPtr, nsecPtr); -} - -/* - * read ethernet timestamp registers, pass up raw register values - * and values converted to sec/ns - */ -static void qfec_read_timestamp( - struct buf_desc *p_bd, - struct skb_shared_hwtstamps *ts) -{ - uint32_t ts_hi; - uint32_t ts_lo; - uint32_t ts_hi63; - uint32_t ts_lo63; - uint32_t sec; - uint32_t nsec; - - ts_hi = (uint32_t) qfec_bd_next_get(p_bd); - ts_lo = (uint32_t) qfec_bd_pbuf_get(p_bd); - - /* - * Combine (then separate) raw registers into 63 (then 32) bit... - */ - qfec_hilo_collapse(ts_hi, ts_lo, &ts_hi63, &ts_lo63); - - ts->hwtstamp = ktime_set(ts_hi63, ts_lo63); - - /* - * Translate raw registers to sec and ns - */ - qfec_hilo_2secnsec(ts_hi, ts_lo, &sec, &nsec); - - ts->syststamp = ktime_set(sec, nsec); -} - -/* - * capture the current system time in the timestamp registers - */ -static int qfec_cmd(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - struct timeval tv; - - if (!strncmp(buf, "setTs", 5)) { - uint32_t ts_hi; - uint32_t ts_lo; - uint32_t cr; - - do_gettimeofday(&tv); - - /* convert raw sec/usec to hi/low registers */ - qfec_secnsec_2hilo(tv.tv_sec, tv.tv_usec * 1000, - &ts_hi, &ts_lo); - - qfec_reg_write(priv, TS_HI_UPDT_REG, ts_hi); - qfec_reg_write(priv, TS_LO_UPDT_REG, ts_lo); - - /* - * TS_CTL_TSINIT bit cannot be written until it is 0, hence the - * following while loop will run until the bit transitions to 0 - */ - while ((cr = qfec_reg_read(priv, TS_CTL_REG)) & TS_CTL_TSINIT) - ; - - qfec_reg_write(priv, TS_CTL_REG, cr | TS_CTL_TSINIT); - } else - pr_err("%s: unknown cmd, %s.\n", __func__, buf); - - return strnlen(buf, count); -} - -/* - * Do a "slam" of a very particular time into the time registers... - */ -static int qfec_slam( - struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - uint32_t sec = 0; - uint32_t nsec = 0; - - if (sscanf(buf, "%u %u", &sec, &nsec) == 2) { - uint32_t ts_hi; - uint32_t ts_lo; - uint32_t cr; - - qfec_secnsec_2hilo(sec, nsec, &ts_hi, &ts_lo); - - qfec_reg_write(priv, TS_HI_UPDT_REG, ts_hi); - qfec_reg_write(priv, TS_LO_UPDT_REG, ts_lo); - - /* - * TS_CTL_TSINIT bit cannot be written until it is 0, hence the - * following while loop will run until the bit transitions to 0 - */ - while ((cr = qfec_reg_read(priv, TS_CTL_REG)) & TS_CTL_TSINIT) - ; - - qfec_reg_write(priv, TS_CTL_REG, cr | TS_CTL_TSINIT); - } else - pr_err("%s: bad offset value, %s.\n", __func__, buf); - - return strnlen(buf, count); -} - -/* - * Do a coarse time ajustment (ie. coarsely adjust (+/-) the time - * registers by the passed offset) - */ -static int qfec_cadj( - struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int64_t offset = 0; - - if (sscanf(buf, "%lld", &offset) == 1) { - uint64_t newOffset; - uint32_t sec; - uint32_t nsec; - uint32_t ts_hi; - uint32_t ts_lo; - uint32_t cr; - - qfec_reg_and_time(priv, &ts_hi, &ts_lo, &sec, &nsec); - - newOffset = (((uint64_t) sec * BILLION) + (uint64_t) nsec) - + offset; - - nsec = do_div(newOffset, BILLION); - sec = newOffset; - - qfec_secnsec_2hilo(sec, nsec, &ts_hi, &ts_lo); - - qfec_reg_write(priv, TS_HI_UPDT_REG, ts_hi); - qfec_reg_write(priv, TS_LO_UPDT_REG, ts_lo); - - /* - * The TS_CTL_TSINIT bit cannot be written until it is 0, - * hence the following while loop will run until the bit - * transitions to 0 - */ - while ((cr = qfec_reg_read(priv, TS_CTL_REG)) & TS_CTL_TSINIT) - ; - - qfec_reg_write(priv, TS_CTL_REG, cr | TS_CTL_TSINIT); - } else - pr_err("%s: bad offset value, %s.\n", __func__, buf); - - return strnlen(buf, count); -} - -/* - * Do a fine time ajustment (ie. have the timestamp registers adjust - * themselves by the passed amount). - */ -static int qfec_fadj( - struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int64_t offset = 0; - - if (sscanf(buf, "%lld", &offset) == 1) { - uint32_t direction = 0; - uint32_t cr; - uint32_t sec, nsec; - uint32_t ts_hi, ts_lo; - - if (offset < 0) { - direction = 1 << TS_LOW_REG_BITS; - offset *= -1; - } - - nsec = do_div(offset, BILLION); - sec = offset; - - qfec_secnsec_2hilo(sec, nsec, &ts_hi, &ts_lo); - - qfec_reg_write(priv, TS_HI_UPDT_REG, ts_hi); - qfec_reg_write(priv, TS_LO_UPDT_REG, ts_lo | direction); - - /* - * As per the hardware documentation, the TS_CTL_TSUPDT bit - * cannot be written until it is 0, hence the following while - * loop will run until the bit transitions to 0... - */ - while ((cr = qfec_reg_read(priv, TS_CTL_REG)) & TS_CTL_TSUPDT) - ; - - qfec_reg_write(priv, TS_CTL_REG, cr | TS_CTL_TSUPDT); - } else - pr_err("%s: bad offset value, %s.\n", __func__, buf); - - return strnlen(buf, count); -} - -/* - * display ethernet tstamp and system time - */ -static int qfec_tstamp_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int count = PAGE_SIZE; - int l; - struct timeval tv; - uint32_t sec; - uint32_t nsec; - uint32_t ts_hi; - uint32_t ts_lo; - - qfec_reg_and_time(priv, &ts_hi, &ts_lo, &sec, &nsec); - - qfec_hilo_collapse(ts_hi, ts_lo, &ts_hi, &ts_lo); - - do_gettimeofday(&tv); - - l = snprintf(buf, count, - "%12u.%09u sec 0x%08x 0x%08x tstamp %12u.%06u time-of-day\n", - sec, nsec, ts_hi, ts_lo, (int)tv.tv_sec, (int)tv.tv_usec); - - return l; -} - -/* - * display ethernet mac time as well as the time of the next mac pps - * pulse... - */ -static int qfec_mtnp_show( - struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int count = PAGE_SIZE; - int l; - uint32_t ts_hi; - uint32_t ts_lo; - uint32_t sec; - uint32_t nsec; - uint32_t ppsSec; - uint32_t ppsNsec; - - qfec_reg_and_time(priv, &ts_hi, &ts_lo, &sec, &nsec); - - /* - * Convert high and low to time of next rollover (ie. PPS - * pulse)... - */ - qfec_hilo_2secnsec(ts_hi + 1, 0, &ppsSec, &ppsNsec); - - l = snprintf(buf, count, - "%u %u %u %u\n", - sec, nsec, ppsSec, ppsNsec); - - return l; -} - -/* - * free transmitted skbufs from buffer-descriptor no owned by HW - */ -static int qfec_tx_replenish(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct ring *p_ring = &priv->ring_tbd; - struct buf_desc *p_bd = &priv->p_tbd[qfec_ring_tail(p_ring)]; - struct sk_buff *skb; - unsigned long flags; - - CNTR_INC(priv, tx_replenish); - - spin_lock_irqsave(&priv->xmit_lock, flags); - - while (!qfec_ring_empty(p_ring)) { - if (qfec_bd_own(p_bd)) - break; /* done for now */ - - skb = qfec_bd_skbuf_get(p_bd); - if (unlikely(skb == NULL)) { - QFEC_LOG_ERR("%s: null sk_buff\n", __func__); - CNTR_INC(priv, tx_skb_null); - break; - } - - qfec_reg_write(priv, STATUS_REG, - STATUS_REG_TU | STATUS_REG_TI); - - /* retrieve timestamp if requested */ - if (qfec_bd_status_get(p_bd) & BUF_TX_TTSS) { - CNTR_INC(priv, ts_tx_rtn); - qfec_read_timestamp(p_bd, skb_hwtstamps(skb)); - skb_tstamp_tx(skb, skb_hwtstamps(skb)); - } - - /* update statistics before freeing skb */ - priv->stats.tx_packets++; - priv->stats.tx_bytes += skb->len; - - dma_unmap_single(&dev->dev, (dma_addr_t) qfec_bd_pbuf_get(p_bd), - skb->len, DMA_TO_DEVICE); - - dev_kfree_skb_any(skb); - qfec_bd_skbuf_set(p_bd, NULL); - - qfec_ring_tail_adv(p_ring); - p_bd = &priv->p_tbd[qfec_ring_tail(p_ring)]; - } - - spin_unlock_irqrestore(&priv->xmit_lock, flags); - - qfec_queue_start(dev); - - return 0; -} - -/* - * clear ownership bits of all TX buf-desc and release the sk-bufs - */ -static void qfec_tx_timeout(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct buf_desc *bd = priv->p_tbd; - int n; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - CNTR_INC(priv, tx_timeout); - - for (n = 0; n < priv->n_tbd; n++, bd++) - qfec_bd_own_clr(bd); - - qfec_tx_replenish(dev); -} - -/* - * rx() - process a received frame - */ -static void qfec_rx_int(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct ring *p_ring = &priv->ring_rbd; - struct buf_desc *p_bd = priv->p_latest_rbd; - uint32_t desc_status; - uint32_t mis_fr_reg; - - desc_status = qfec_bd_status_get(p_bd); - mis_fr_reg = qfec_reg_read(priv, MIS_FR_REG); - - CNTR_INC(priv, rx_int); - - /* check that valid interrupt occurred */ - if (unlikely(desc_status & BUF_OWN)) - return; - - /* accumulate missed-frame count (reg reset when read) */ - priv->stats.rx_missed_errors += mis_fr_reg - & MIS_FR_REG_MISS_CNT; - - /* process all unowned frames */ - while (!(desc_status & BUF_OWN) && (!qfec_ring_full(p_ring))) { - struct sk_buff *skb; - struct buf_desc *p_bd_next; - - skb = qfec_bd_skbuf_get(p_bd); - - if (unlikely(skb == NULL)) { - QFEC_LOG_ERR("%s: null sk_buff\n", __func__); - CNTR_INC(priv, rx_skb_null); - break; - } - - /* cache coherency before skb->data is accessed */ - dma_unmap_single(&dev->dev, - (dma_addr_t) qfec_bd_phys_get(p_bd), - ETH_BUF_SIZE, DMA_FROM_DEVICE); - prefetch(skb->data); - - if (unlikely(desc_status & BUF_RX_ES)) { - priv->stats.rx_dropped++; - CNTR_INC(priv, rx_dropped); - dev_kfree_skb(skb); - } else { - qfec_reg_write(priv, STATUS_REG, STATUS_REG_RI); - - skb->len = BUF_RX_FL_GET_FROM_STATUS(desc_status); - - if (priv->state & timestamping) { - CNTR_INC(priv, ts_rec); - qfec_read_timestamp(p_bd, skb_hwtstamps(skb)); - } - - /* update statistics before freeing skb */ - priv->stats.rx_packets++; - priv->stats.rx_bytes += skb->len; - - skb->dev = dev; - skb->protocol = eth_type_trans(skb, dev); - skb->ip_summed = CHECKSUM_UNNECESSARY; - - if (NET_RX_DROP == netif_rx(skb)) { - priv->stats.rx_dropped++; - CNTR_INC(priv, rx_dropped); - } - CNTR_INC(priv, netif_rx_cntr); - } - - if (p_bd != priv->p_ending_rbd) - p_bd_next = p_bd + 1; - else - p_bd_next = priv->p_rbd; - desc_status = qfec_bd_status_get(p_bd_next); - - qfec_bd_skbuf_set(p_bd, NULL); - - qfec_ring_head_adv(p_ring); - p_bd = p_bd_next; - } - - priv->p_latest_rbd = p_bd; - - /* replenish bufs */ - while (!qfec_ring_empty(p_ring)) { - if (qfec_rbd_init(dev, &priv->p_rbd[qfec_ring_tail(p_ring)])) - break; - qfec_ring_tail_adv(p_ring); - } - - qfec_reg_write(priv, STATUS_REG, STATUS_REG_RI); -} - -/* - * isr() - interrupt service routine - * determine cause of interrupt and invoke/schedule appropriate - * processing or error handling - */ -#define ISR_ERR_CHK(priv, status, interrupt, cntr) \ - if (status & interrupt) \ - CNTR_INC(priv, cntr) - -static irqreturn_t qfec_int(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct qfec_priv *priv = netdev_priv(dev); - uint32_t status = qfec_reg_read(priv, STATUS_REG); - uint32_t int_bits = STATUS_REG_NIS | STATUS_REG_AIS; - - QFEC_LOG(QFEC_LOG_DBG2, "%s: %s\n", __func__, dev->name); - - /* abnormal interrupt */ - if (status & STATUS_REG_AIS) { - QFEC_LOG(QFEC_LOG_DBG, "%s: abnormal status 0x%08x\n", - __func__, status); - - ISR_ERR_CHK(priv, status, STATUS_REG_RU, rx_buf_unavail); - ISR_ERR_CHK(priv, status, STATUS_REG_FBI, fatal_bus); - - ISR_ERR_CHK(priv, status, STATUS_REG_RWT, rx_watchdog); - ISR_ERR_CHK(priv, status, STATUS_REG_RPS, rx_proc_stopped); - ISR_ERR_CHK(priv, status, STATUS_REG_UNF, tx_underflow); - - ISR_ERR_CHK(priv, status, STATUS_REG_OVF, rx_overflow); - ISR_ERR_CHK(priv, status, STATUS_REG_TJT, tx_jabber_tmout); - ISR_ERR_CHK(priv, status, STATUS_REG_TPS, tx_proc_stopped); - - int_bits |= STATUS_REG_AIS_BITS; - CNTR_INC(priv, abnorm_int); - } - - if (status & STATUS_REG_NIS) - CNTR_INC(priv, norm_int); - - /* receive interrupt */ - if (status & STATUS_REG_RI) { - CNTR_INC(priv, rx_isr); - qfec_rx_int(dev); - } - - /* transmit interrupt */ - if (status & STATUS_REG_TI) { - CNTR_INC(priv, tx_isr); - qfec_tx_replenish(dev); - } - - /* gmac interrupt */ - if (status & (STATUS_REG_GPI | STATUS_REG_GMI | STATUS_REG_GLI)) { - status &= ~(STATUS_REG_GPI | STATUS_REG_GMI | STATUS_REG_GLI); - CNTR_INC(priv, gmac_isr); - int_bits |= STATUS_REG_GPI | STATUS_REG_GMI | STATUS_REG_GLI; - qfec_reg_read(priv, SG_RG_SMII_STATUS_REG); - } - - /* clear interrupts */ - qfec_reg_write(priv, STATUS_REG, int_bits); - CNTR_INC(priv, isr); - - return IRQ_HANDLED; -} - -/* - * open () - register system resources (IRQ, DMA, ...) - * turn on HW, perform device setup. - */ -static int qfec_open(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct buf_desc *p_bd; - struct ring *p_ring; - struct qfec_buf_desc *p_desc; - int n; - int res = 0; - - QFEC_LOG(QFEC_LOG_DBG, "%s: %p dev\n", __func__, dev); - - if (!dev) { - res = -EINVAL; - goto err; - } - - /* allocate TX/RX buffer-descriptors and buffers */ - - res = qfec_mem_alloc(dev); - if (res) - goto err; - - /* initialize TX */ - p_desc = priv->bd_base; - - for (n = 0, p_bd = priv->p_tbd; n < priv->n_tbd; n++, p_bd++) { - p_bd->p_desc = p_desc++; - - if (n == (priv->n_tbd - 1)) - qfec_bd_last_bd_set(p_bd); - - qfec_bd_own_clr(p_bd); /* clear ownership */ - } - - qfec_ring_init(&priv->ring_tbd, priv->n_tbd, priv->n_tbd); - - priv->tx_ic_mod = priv->n_tbd / TX_BD_TI_RATIO; - if (priv->tx_ic_mod == 0) - priv->tx_ic_mod = 1; - - /* initialize RX buffer descriptors and allocate sk_bufs */ - p_ring = &priv->ring_rbd; - qfec_ring_init(p_ring, priv->n_rbd, 0); - qfec_bd_last_bd_set(&priv->p_rbd[priv->n_rbd - 1]); - - for (n = 0, p_bd = priv->p_rbd; n < priv->n_rbd; n++, p_bd++) { - p_bd->p_desc = p_desc++; - - if (qfec_rbd_init(dev, p_bd)) - break; - qfec_ring_tail_adv(p_ring); - } - - priv->p_latest_rbd = priv->p_rbd; - priv->p_ending_rbd = priv->p_rbd + priv->n_rbd - 1; - - /* config ptp clock */ - qfec_ptp_cfg(priv); - - /* configure PHY - must be set before reset/hw_init */ - priv->mii.supports_gmii = mii_check_gmii_support(&priv->mii); - if (priv->mii.supports_gmii) { - QFEC_LOG_ERR("%s: RGMII\n", __func__); - qfec_intf_sel(priv, INTFC_RGMII); - } else { - QFEC_LOG_ERR("%s: MII\n", __func__); - qfec_intf_sel(priv, INTFC_MII); - } - - /* initialize controller after BDs allocated */ - res = qfec_hw_init(priv); - if (res) - goto err1; - - /* get/set (primary) MAC address */ - qfec_set_adr_regs(priv, dev->dev_addr); - qfec_set_rx_mode(dev); - - /* start phy monitor */ - QFEC_LOG(QFEC_LOG_DBG, " %s: start timer\n", __func__); - netif_carrier_off(priv->net_dev); - setup_timer(&priv->phy_tmr, qfec_phy_monitor, (unsigned long)dev); - mod_timer(&priv->phy_tmr, jiffies + HZ); - - /* driver supports AN capable PHY only */ - qfec_mdio_write(dev, priv->phy_id, MII_BMCR, BMCR_RESET); - res = (BMCR_ANENABLE|BMCR_ANRESTART); - qfec_mdio_write(dev, priv->phy_id, MII_BMCR, res); - - /* initialize interrupts */ - QFEC_LOG(QFEC_LOG_DBG, " %s: request irq %d\n", __func__, dev->irq); - res = request_irq(dev->irq, qfec_int, 0, dev->name, dev); - if (res) - goto err1; - - /* enable controller */ - qfec_hw_enable(priv); - netif_start_queue(dev); - - QFEC_LOG(QFEC_LOG_DBG, "%s: %08x link, %08x carrier\n", __func__, - mii_link_ok(&priv->mii), netif_carrier_ok(priv->net_dev)); - - QFEC_LOG(QFEC_LOG_DBG, " %s: done\n", __func__); - return 0; - -err1: - qfec_mem_dealloc(dev); -err: - QFEC_LOG_ERR("%s: error - %d\n", __func__, res); - return res; -} - -/* - * stop() - "reverse operations performed at open time" - */ -static int qfec_stop(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct buf_desc *p_bd; - struct sk_buff *skb; - int n; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - del_timer_sync(&priv->phy_tmr); - - qfec_hw_disable(priv); - qfec_queue_stop(dev); - free_irq(dev->irq, dev); - - /* free all pending sk_bufs */ - for (n = priv->n_rbd, p_bd = priv->p_rbd; n > 0; n--, p_bd++) { - skb = qfec_bd_skbuf_get(p_bd); - if (skb) - dev_kfree_skb(skb); - } - - for (n = priv->n_tbd, p_bd = priv->p_tbd; n > 0; n--, p_bd++) { - skb = qfec_bd_skbuf_get(p_bd); - if (skb) - dev_kfree_skb(skb); - } - - qfec_mem_dealloc(dev); - - QFEC_LOG(QFEC_LOG_DBG, " %s: done\n", __func__); - - return 0; -} - -static int qfec_set_config(struct net_device *dev, struct ifmap *map) -{ - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - return 0; -} - -/* - * pass data from skbuf to buf-desc - */ -static int qfec_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct ring *p_ring = &priv->ring_tbd; - struct buf_desc *p_bd; - uint32_t ctrl = 0; - int ret = NETDEV_TX_OK; - unsigned long flags; - - CNTR_INC(priv, xmit); - - spin_lock_irqsave(&priv->xmit_lock, flags); - - /* If there is no room, on the ring try to free some up */ - if (qfec_ring_room(p_ring) == 0) - qfec_tx_replenish(dev); - - /* stop queuing if no resources available */ - if (qfec_ring_room(p_ring) == 0) { - qfec_queue_stop(dev); - CNTR_INC(priv, tx_no_resource); - - ret = NETDEV_TX_BUSY; - goto done; - } - - /* locate and save *sk_buff */ - p_bd = &priv->p_tbd[qfec_ring_head(p_ring)]; - qfec_bd_skbuf_set(p_bd, skb); - - /* set DMA ptr to sk_buff data and write cache to memory */ - qfec_bd_pbuf_set(p_bd, (void *) - dma_map_single(&dev->dev, - (void *)skb->data, skb->len, DMA_TO_DEVICE)); - - ctrl = skb->len; - if (!(qfec_ring_head(p_ring) % priv->tx_ic_mod)) - ctrl |= BUF_TX_IC; /* interrupt on complete */ - - /* check if timestamping enabled and requested */ - if (priv->state & timestamping) { - if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) { - CNTR_INC(priv, ts_tx_en); - ctrl |= BUF_TX_IC; /* interrupt on complete */ - ctrl |= BUF_TX_TTSE; /* enable timestamp */ - skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; - } - } - - if (qfec_bd_last_bd(p_bd)) - ctrl |= BUF_RX_RER; - - /* no gather, no multi buf frames */ - ctrl |= BUF_TX_FS | BUF_TX_LS; /* 1st and last segment */ - - qfec_bd_ctl_wr(p_bd, ctrl); - qfec_bd_status_set(p_bd, BUF_OWN); - - qfec_ring_head_adv(p_ring); - qfec_reg_write(priv, TX_POLL_DEM_REG, 1); /* poll */ - -done: - spin_unlock_irqrestore(&priv->xmit_lock, flags); - - return ret; -} - -static int qfec_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct hwtstamp_config *cfg = (struct hwtstamp_config *) ifr; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - if (cmd == SIOCSHWTSTAMP) { - CNTR_INC(priv, ts_ioctl); - QFEC_LOG(QFEC_LOG_DBG, - "%s: SIOCSHWTSTAMP - %x flags %x tx %x rx\n", - __func__, cfg->flags, cfg->tx_type, cfg->rx_filter); - - cfg->flags = 0; - cfg->tx_type = HWTSTAMP_TX_ON; - cfg->rx_filter = HWTSTAMP_FILTER_ALL; - - priv->state |= timestamping; - qfec_reg_write(priv, TS_CTL_REG, - qfec_reg_read(priv, TS_CTL_REG) | TS_CTL_TSENALL); - - return 0; - } - - return generic_mii_ioctl(&priv->mii, if_mii(ifr), cmd, NULL); -} - -static struct net_device_stats *qfec_get_stats(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - - QFEC_LOG(QFEC_LOG_DBG2, "qfec_stats:\n"); - - priv->stats.multicast = qfec_reg_read(priv, NUM_MULTCST_FRM_RCVD_G); - - return &priv->stats; -} - -/* - * accept new mac address - */ -static int qfec_set_mac_address(struct net_device *dev, void *p) -{ - struct qfec_priv *priv = netdev_priv(dev); - struct sockaddr *addr = p; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - - qfec_set_adr_regs(priv, dev->dev_addr); - - return 0; -} - -/* - * read discontinuous MAC address from corrected fuse memory region - */ - -static int qfec_get_mac_address(char *buf, char *mac_base, int nBytes) -{ - static int offset[] = { 0, 1, 2, 3, 4, 8 }; - int n; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - for (n = 0; n < nBytes; n++) - buf[n] = ioread8(mac_base + offset[n]); - - /* check that MAC programmed */ - if ((buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5]) == 0) { - QFEC_LOG_ERR("%s: null MAC address\n", __func__); - return -ENODATA; - } - - return 0; -} - -/* - * static definition of driver functions - */ -static const struct net_device_ops qfec_netdev_ops = { - .ndo_open = qfec_open, - .ndo_stop = qfec_stop, - .ndo_start_xmit = qfec_xmit, - - .ndo_do_ioctl = qfec_do_ioctl, - .ndo_tx_timeout = qfec_tx_timeout, - .ndo_set_mac_address = qfec_set_mac_address, - .ndo_set_rx_mode = qfec_set_rx_mode, - - .ndo_change_mtu = eth_change_mtu, - .ndo_validate_addr = eth_validate_addr, - - .ndo_get_stats = qfec_get_stats, - .ndo_set_config = qfec_set_config, -}; - -/* - * ethtool functions - */ - -static int qfec_nway_reset(struct net_device *dev) -{ - struct qfec_priv *priv = netdev_priv(dev); - return mii_nway_restart(&priv->mii); -} - -/* - * speed, duplex, auto-neg settings - */ -static void qfec_ethtool_getpauseparam(struct net_device *dev, - struct ethtool_pauseparam *pp) -{ - struct qfec_priv *priv = netdev_priv(dev); - u32 flow = qfec_reg_read(priv, FLOW_CONTROL_REG); - u32 advert; - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - /* report current settings */ - pp->tx_pause = (flow & FLOW_CONTROL_TFE) != 0; - pp->rx_pause = (flow & FLOW_CONTROL_RFE) != 0; - - /* report if pause is being advertised */ - advert = qfec_mdio_read(dev, priv->phy_id, MII_ADVERTISE); - pp->autoneg = - (advert & (ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM)) != 0; -} - -static int qfec_ethtool_setpauseparam(struct net_device *dev, - struct ethtool_pauseparam *pp) -{ - struct qfec_priv *priv = netdev_priv(dev); - u32 advert; - - QFEC_LOG(QFEC_LOG_DBG, "%s: %d aneg, %d rx, %d tx\n", __func__, - pp->autoneg, pp->rx_pause, pp->tx_pause); - - advert = qfec_mdio_read(dev, priv->phy_id, MII_ADVERTISE); - advert &= ~(ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM); - - /* If pause autonegotiation is enabled, but both rx and tx are not - * because neither was specified in the ethtool cmd, - * enable both symetrical and asymetrical pause. - * otherwise, only enable the pause mode indicated by rx/tx. - */ - if (pp->autoneg) { - if (pp->rx_pause) - advert |= ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP; - else if (pp->tx_pause) - advert |= ADVERTISE_PAUSE_ASYM; - else - advert |= ADVERTISE_PAUSE_CAP; - } - - qfec_mdio_write(dev, priv->phy_id, MII_ADVERTISE, advert); - - return 0; -} - -/* - * ethtool ring parameter (-g/G) support - */ - -/* - * setringparamam - change the tx/rx ring lengths - */ -#define MIN_RING_SIZE 3 -#define MAX_RING_SIZE 1000 -static int qfec_ethtool_setringparam(struct net_device *dev, - struct ethtool_ringparam *ring) -{ - struct qfec_priv *priv = netdev_priv(dev); - u32 timeout = 20; - - /* notify stack the link is down */ - netif_carrier_off(dev); - - /* allow tx to complete & free skbufs on the tx ring */ - do { - usleep_range(10000, 100000); - qfec_tx_replenish(dev); - - if (timeout-- == 0) { - QFEC_LOG_ERR("%s: timeout\n", __func__); - return -ETIME; - } - } while (!qfec_ring_empty(&priv->ring_tbd)); - - - qfec_stop(dev); - - /* set tx ring size */ - if (ring->tx_pending < MIN_RING_SIZE) - ring->tx_pending = MIN_RING_SIZE; - else if (ring->tx_pending > MAX_RING_SIZE) - ring->tx_pending = MAX_RING_SIZE; - priv->n_tbd = ring->tx_pending; - - /* set rx ring size */ - if (ring->rx_pending < MIN_RING_SIZE) - ring->rx_pending = MIN_RING_SIZE; - else if (ring->rx_pending > MAX_RING_SIZE) - ring->rx_pending = MAX_RING_SIZE; - priv->n_rbd = ring->rx_pending; - - - qfec_open(dev); - - return 0; -} - -/* - * getringparamam - returns local values - */ -static void qfec_ethtool_getringparam(struct net_device *dev, - struct ethtool_ringparam *ring) -{ - struct qfec_priv *priv = netdev_priv(dev); - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - ring->rx_max_pending = MAX_RING_SIZE; - ring->rx_mini_max_pending = 0; - ring->rx_jumbo_max_pending = 0; - ring->tx_max_pending = MAX_RING_SIZE; - - ring->rx_pending = priv->n_rbd; - ring->rx_mini_pending = 0; - ring->rx_jumbo_pending = 0; - ring->tx_pending = priv->n_tbd; -} - -/* - * speed, duplex, auto-neg settings - */ -static int -qfec_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) -{ - struct qfec_priv *priv = netdev_priv(dev); - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - cmd->maxrxpkt = priv->n_rbd; - cmd->maxtxpkt = priv->n_tbd; - - return mii_ethtool_gset(&priv->mii, cmd); -} - -static int -qfec_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd) -{ - struct qfec_priv *priv = netdev_priv(dev); - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - return mii_ethtool_sset(&priv->mii, cmd); -} - -/* - * msg/debug level - */ -static u32 qfec_ethtool_getmsglevel(struct net_device *dev) -{ - return qfec_debug; -} - -static void qfec_ethtool_setmsglevel(struct net_device *dev, u32 level) -{ - qfec_debug ^= level; /* toggle on/off */ -} - -/* - * register dump - */ -#define DMA_DMP_OFFSET 0x0000 -#define DMA_REG_OFFSET 0x1000 -#define DMA_REG_LEN 23 - -#define MAC_DMP_OFFSET 0x0080 -#define MAC_REG_OFFSET 0x0000 -#define MAC_REG_LEN 55 - -#define TS_DMP_OFFSET 0x0180 -#define TS_REG_OFFSET 0x0700 -#define TS_REG_LEN 15 - -#define MDIO_DMP_OFFSET 0x0200 -#define MDIO_REG_LEN 16 - -#define REG_SIZE (MDIO_DMP_OFFSET + (MDIO_REG_LEN * sizeof(short))) - -static int qfec_ethtool_getregs_len(struct net_device *dev) -{ - return REG_SIZE; -} - -static void -qfec_ethtool_getregs(struct net_device *dev, struct ethtool_regs *regs, - void *buf) -{ - struct qfec_priv *priv = netdev_priv(dev); - u32 *data = buf; - u16 *data16; - unsigned int i; - unsigned int j; - unsigned int n; - - memset(buf, 0, REG_SIZE); - - j = DMA_DMP_OFFSET / sizeof(u32); - for (i = DMA_REG_OFFSET, n = DMA_REG_LEN; n--; i += sizeof(u32)) - data[j++] = htonl(qfec_reg_read(priv, i)); - - j = MAC_DMP_OFFSET / sizeof(u32); - for (i = MAC_REG_OFFSET, n = MAC_REG_LEN; n--; i += sizeof(u32)) - data[j++] = htonl(qfec_reg_read(priv, i)); - - j = TS_DMP_OFFSET / sizeof(u32); - for (i = TS_REG_OFFSET, n = TS_REG_LEN; n--; i += sizeof(u32)) - data[j++] = htonl(qfec_reg_read(priv, i)); - - data16 = (u16 *)&data[MDIO_DMP_OFFSET / sizeof(u32)]; - for (i = 0, n = 0; i < MDIO_REG_LEN; i++) - data16[n++] = htons(qfec_mdio_read(dev, 0, i)); - - regs->len = REG_SIZE; - - QFEC_LOG(QFEC_LOG_DBG, "%s: %d bytes\n", __func__, regs->len); -} - -/* - * statistics - * return counts of various ethernet activity. - * many of these are same as in struct net_device_stats - * - * missed-frames indicates the number of attempts made by the ethernet - * controller to write to a buffer-descriptor when the BD ownership - * bit was not set. The rxfifooverflow counter (0x1D4) is not - * available. The Missed Frame and Buffer Overflow Counter register - * (0x1020) is used, but has only 16-bits and is reset when read. - * It is read and updates the value in priv->stats.rx_missed_errors - * in qfec_rx_int(). - */ -static char qfec_stats_strings[][ETH_GSTRING_LEN] = { - "TX good/bad Bytes ", - "TX Bytes ", - "TX good/bad Frames ", - "TX Bcast Frames ", - "TX Mcast Frames ", - "TX Unicast Frames ", - "TX Pause Frames ", - "TX Vlan Frames ", - "TX Frames 64 ", - "TX Frames 65-127 ", - "TX Frames 128-255 ", - "TX Frames 256-511 ", - "TX Frames 512-1023 ", - "TX Frames 1024+ ", - "TX Pause Frames ", - "TX Collisions ", - "TX Late Collisions ", - "TX Excessive Collisions ", - - "RX good/bad Bytes ", - "RX Bytes ", - "RX good/bad Frames ", - "RX Bcast Frames ", - "RX Mcast Frames ", - "RX Unicast Frames ", - "RX Pause Frames ", - "RX Vlan Frames ", - "RX Frames 64 ", - "RX Frames 65-127 ", - "RX Frames 128-255 ", - "RX Frames 256-511 ", - "RX Frames 512-1023 ", - "RX Frames 1024+ ", - "RX Pause Frames ", - "RX Crc error Frames ", - "RX Length error Frames ", - "RX Alignment error Frames ", - "RX Runt Frames ", - "RX Oversize Frames ", - "RX Missed Frames ", - -}; - -static u32 qfec_stats_regs[] = { - - 69, 89, 70, 71, 72, 90, 92, 93, - 73, 74, 75, 76, 77, 78, 92, 84, - 86, 87, - - 97, 98, 96, 99, 100, 113, 116, 118, - 107, 108, 109, 110, 111, 112, 116, 101, - 114, 102, 103, 106 -}; - -static int qfec_stats_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct qfec_priv *priv = netdev_priv(to_net_dev(dev)); - int count = PAGE_SIZE; - int l = 0; - int n; - - QFEC_LOG(QFEC_LOG_DBG2, "%s:\n", __func__); - - for (n = 0; n < ARRAY_SIZE(qfec_stats_regs); n++) { - l += snprintf(&buf[l], count - l, " %12u %s\n", - qfec_reg_read(priv, - qfec_stats_regs[n] * sizeof(uint32_t)), - qfec_stats_strings[n]); - } - - return l; -} - -static int qfec_get_sset_count(struct net_device *dev, int sset) -{ - switch (sset) { - case ETH_SS_STATS: - return ARRAY_SIZE(qfec_stats_regs) + 1; /* missed frames */ - - default: - return -EOPNOTSUPP; - } -} - -static void qfec_ethtool_getstrings(struct net_device *dev, u32 stringset, - u8 *buf) -{ - QFEC_LOG(QFEC_LOG_DBG, "%s: %d bytes\n", __func__, - sizeof(qfec_stats_strings)); - - memcpy(buf, qfec_stats_strings, sizeof(qfec_stats_strings)); -} - -static void qfec_ethtool_getstats(struct net_device *dev, - struct ethtool_stats *stats, uint64_t *data) -{ - struct qfec_priv *priv = netdev_priv(dev); - int j = 0; - int n; - - for (n = 0; n < ARRAY_SIZE(qfec_stats_regs); n++) - data[j++] = qfec_reg_read(priv, - qfec_stats_regs[n] * sizeof(uint32_t)); - - data[j++] = priv->stats.rx_missed_errors; - - stats->n_stats = j; -} - -static void qfec_ethtool_getdrvinfo(struct net_device *dev, - struct ethtool_drvinfo *info) -{ - strlcpy(info->driver, QFEC_NAME, sizeof(info->driver)); - strlcpy(info->version, QFEC_DRV_VER, sizeof(info->version)); - strlcpy(info->bus_info, dev_name(dev->dev.parent), - sizeof(info->bus_info)); - - info->eedump_len = 0; - info->regdump_len = qfec_ethtool_getregs_len(dev); -} - -/* - * ethtool ops table - */ -static const struct ethtool_ops qfec_ethtool_ops = { - .nway_reset = qfec_nway_reset, - - .get_settings = qfec_ethtool_getsettings, - .set_settings = qfec_ethtool_setsettings, - .get_link = ethtool_op_get_link, - .get_drvinfo = qfec_ethtool_getdrvinfo, - .get_msglevel = qfec_ethtool_getmsglevel, - .set_msglevel = qfec_ethtool_setmsglevel, - .get_regs_len = qfec_ethtool_getregs_len, - .get_regs = qfec_ethtool_getregs, - - .get_ringparam = qfec_ethtool_getringparam, - .set_ringparam = qfec_ethtool_setringparam, - - .get_pauseparam = qfec_ethtool_getpauseparam, - .set_pauseparam = qfec_ethtool_setpauseparam, - - .get_sset_count = qfec_get_sset_count, - .get_strings = qfec_ethtool_getstrings, - .get_ethtool_stats = qfec_ethtool_getstats, -}; - -/* - * create sysfs entries - */ -static DEVICE_ATTR(bd_tx, 0444, qfec_bd_tx_show, NULL); -static DEVICE_ATTR(bd_rx, 0444, qfec_bd_rx_show, NULL); -static DEVICE_ATTR(cfg, 0444, qfec_config_show, NULL); -static DEVICE_ATTR(clk_reg, 0444, qfec_clk_reg_show, NULL); -static DEVICE_ATTR(cmd, 0222, NULL, qfec_cmd); -static DEVICE_ATTR(cntrs, 0444, qfec_cntrs_show, NULL); -static DEVICE_ATTR(reg, 0444, qfec_reg_show, NULL); -static DEVICE_ATTR(mdio, 0444, qfec_mdio_show, NULL); -static DEVICE_ATTR(stats, 0444, qfec_stats_show, NULL); -static DEVICE_ATTR(tstamp, 0444, qfec_tstamp_show, NULL); -static DEVICE_ATTR(slam, 0222, NULL, qfec_slam); -static DEVICE_ATTR(cadj, 0222, NULL, qfec_cadj); -static DEVICE_ATTR(fadj, 0222, NULL, qfec_fadj); -static DEVICE_ATTR(mtnp, 0444, qfec_mtnp_show, NULL); - -static void qfec_sysfs_create(struct net_device *dev) -{ - if (device_create_file(&(dev->dev), &dev_attr_bd_tx) || - device_create_file(&(dev->dev), &dev_attr_bd_rx) || - device_create_file(&(dev->dev), &dev_attr_cfg) || - device_create_file(&(dev->dev), &dev_attr_clk_reg) || - device_create_file(&(dev->dev), &dev_attr_cmd) || - device_create_file(&(dev->dev), &dev_attr_cntrs) || - device_create_file(&(dev->dev), &dev_attr_mdio) || - device_create_file(&(dev->dev), &dev_attr_reg) || - device_create_file(&(dev->dev), &dev_attr_stats) || - device_create_file(&(dev->dev), &dev_attr_tstamp) || - device_create_file(&(dev->dev), &dev_attr_slam) || - device_create_file(&(dev->dev), &dev_attr_cadj) || - device_create_file(&(dev->dev), &dev_attr_fadj) || - device_create_file(&(dev->dev), &dev_attr_mtnp)) - pr_err("qfec_sysfs_create failed to create sysfs files\n"); -} - -/* - * map a specified resource - */ -static int qfec_map_resource(struct platform_device *plat, int resource, - struct resource **priv_res, - void **addr) -{ - struct resource *res; - - QFEC_LOG(QFEC_LOG_DBG, "%s: 0x%x resource\n", __func__, resource); - - /* allocate region to access controller registers */ - *priv_res = res = platform_get_resource(plat, resource, 0); - if (!res) { - QFEC_LOG_ERR("%s: platform_get_resource failed\n", __func__); - return -ENODEV; - } - - res = request_mem_region(res->start, res->end - res->start, QFEC_NAME); - if (!res) { - QFEC_LOG_ERR("%s: request_mem_region failed, %08x %08x\n", - __func__, res->start, res->end - res->start); - return -EBUSY; - } - - *addr = ioremap(res->start, res->end - res->start); - if (!*addr) - return -ENOMEM; - - QFEC_LOG(QFEC_LOG_DBG, " %s: io mapped from %p to %p\n", - __func__, (void *)res->start, *addr); - - return 0; -}; - -/* - * free allocated io regions - */ -static void qfec_free_res(struct resource *res, void *base) -{ - - if (res) { - if (base) - iounmap((void __iomem *)base); - - release_mem_region(res->start, res->end - res->start); - } -}; - -/* - * probe function that obtain configuration info and allocate net_device - */ -static int qfec_probe(struct platform_device *plat) -{ - struct net_device *dev; - struct qfec_priv *priv; - int ret = 0; - - /* allocate device */ - dev = alloc_etherdev(sizeof(struct qfec_priv)); - if (!dev) { - QFEC_LOG_ERR("%s: alloc_etherdev failed\n", __func__); - ret = -ENOMEM; - goto err; - } - - QFEC_LOG(QFEC_LOG_DBG, "%s: %08x dev\n", __func__, (int)dev); - - qfec_dev = dev; - SET_NETDEV_DEV(dev, &plat->dev); - - dev->netdev_ops = &qfec_netdev_ops; - dev->ethtool_ops = &qfec_ethtool_ops; - dev->watchdog_timeo = 2 * HZ; - dev->irq = platform_get_irq(plat, 0); - - dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); - - /* initialize private data */ - priv = (struct qfec_priv *)netdev_priv(dev); - memset((void *)priv, 0, sizeof(priv)); - - priv->net_dev = dev; - platform_set_drvdata(plat, dev); - - priv->n_tbd = TX_BD_NUM; - priv->n_rbd = RX_BD_NUM; - - /* initialize phy structure */ - priv->mii.phy_id_mask = 0x1F; - priv->mii.reg_num_mask = 0x1F; - priv->mii.dev = dev; - priv->mii.mdio_read = qfec_mdio_read; - priv->mii.mdio_write = qfec_mdio_write; - /* initialize mdio clock */ - priv->mdio_clk = GMII_ADR_REG_CR_62; - - /* map register regions */ - ret = qfec_map_resource( - plat, IORESOURCE_MEM, &priv->mac_res, &priv->mac_base); - if (ret) { - QFEC_LOG_ERR("%s: IORESOURCE_MEM mac failed\n", __func__); - goto err1; - } - - ret = qfec_map_resource( - plat, IORESOURCE_IO, &priv->clk_res, &priv->clk_base); - if (ret) { - QFEC_LOG_ERR("%s: IORESOURCE_IO clk failed\n", __func__); - goto err2; - } - - ret = qfec_map_resource( - plat, IORESOURCE_DMA, &priv->fuse_res, &priv->fuse_base); - if (ret) { - QFEC_LOG_ERR("%s: IORESOURCE_DMA fuse failed\n", __func__); - goto err3; - } - - /* initialize MAC addr */ - ret = qfec_get_mac_address(dev->dev_addr, priv->fuse_base, - MAC_ADDR_SIZE); - if (ret) - goto err4; - - QFEC_LOG(QFEC_LOG_DBG, "%s: mac %02x:%02x:%02x:%02x:%02x:%02x\n", - __func__, - dev->dev_addr[0], dev->dev_addr[1], - dev->dev_addr[2], dev->dev_addr[3], - dev->dev_addr[4], dev->dev_addr[5]); - - ret = register_netdev(dev); - if (ret) { - QFEC_LOG_ERR("%s: register_netdev failed\n", __func__); - goto err4; - } - - spin_lock_init(&priv->mdio_lock); - spin_lock_init(&priv->xmit_lock); - qfec_sysfs_create(dev); - - return 0; - - /* error handling */ -err4: - qfec_free_res(priv->fuse_res, priv->fuse_base); -err3: - qfec_free_res(priv->clk_res, priv->clk_base); -err2: - qfec_free_res(priv->mac_res, priv->mac_base); -err1: - free_netdev(dev); -err: - QFEC_LOG_ERR("%s: err\n", __func__); - return ret; -} - -/* - * module remove - */ -static int qfec_remove(struct platform_device *plat) -{ - struct net_device *dev = platform_get_drvdata(plat); - struct qfec_priv *priv = netdev_priv(dev); - - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - platform_set_drvdata(plat, NULL); - - qfec_free_res(priv->fuse_res, priv->fuse_base); - qfec_free_res(priv->clk_res, priv->clk_base); - qfec_free_res(priv->mac_res, priv->mac_base); - - unregister_netdev(dev); - free_netdev(dev); - - return 0; -} - -/* - * module support - * the FSM9xxx is not a mobile device does not support power management - */ - -static struct platform_driver qfec_driver = { - .probe = qfec_probe, - .remove = qfec_remove, - .driver = { - .name = QFEC_NAME, - .owner = THIS_MODULE, - }, -}; - -/* - * module init - */ -static int __init qfec_init_module(void) -{ - int res; - - QFEC_LOG(QFEC_LOG_DBG, "%s: %s\n", __func__, qfec_driver.driver.name); - - res = platform_driver_register(&qfec_driver); - - QFEC_LOG(QFEC_LOG_DBG, "%s: %d - platform_driver_register\n", - __func__, res); - - return res; -} - -/* - * module exit - */ -static void __exit qfec_exit_module(void) -{ - QFEC_LOG(QFEC_LOG_DBG, "%s:\n", __func__); - - platform_driver_unregister(&qfec_driver); -} - -MODULE_DESCRIPTION("FSM Network Driver"); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Rohit Vaswani "); -MODULE_VERSION("1.0"); - -module_init(qfec_init_module); -module_exit(qfec_exit_module); diff --git a/drivers/net/ethernet/msm/qfec.h b/drivers/net/ethernet/msm/qfec.h deleted file mode 100644 index a25436fec9ab608e9465dcdc293a27387253341c..0000000000000000000000000000000000000000 --- a/drivers/net/ethernet/msm/qfec.h +++ /dev/null @@ -1,808 +0,0 @@ -/* Copyright (c) 2010-2011,2013 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. - */ - -/* qualcomm fast Ethernet controller HW description */ - -#ifndef _QFEC_EMAC_H_ -# define _QFEC_EMAC_H_ - -# ifndef __KERNEL__ -# include "stdint.h" -# endif - -# define MskBits(nBits, pos) (((1 << nBits)-1)<> 16) -# define BUF_RX_FL_SET(p, x) \ - (p.status = (p.status & ~BUF_RX_FL) | ((x << 16) & BUF_RX_FL)) -# define BUF_RX_FL_GET_FROM_STATUS(status) \ - (((status) & BUF_RX_FL) >> 16) - -# define BUF_RX_ES 0x00008000 /* error summary */ -# define BUF_RX_DE 0x00004000 /* error descriptor (es) */ -# define BUF_RX_SAF 0x00002000 /* source addr filt fail */ -# define BUF_RX_LE 0x00001000 /* length error */ - -# define BUF_RX_OE 0x00000800 /* overflow error (es) */ -# define BUF_RX_VLAN 0x00000400 /* vlan tag */ -# define BUF_RX_FS 0x00000200 /* first descriptor */ -# define BUF_RX_LS 0x00000100 /* last descriptor */ - -# define BUF_RX_IPC 0x00000080 /* cksum-err/giant-frame (es) */ -# define BUF_RX_LC 0x00000040 /* late collision (es) */ -# define BUF_RX_FT 0x00000020 /* frame type */ -# define BUF_RX_RWT 0x00000010 /* rec watchdog timeout (es) */ - -# define BUF_RX_RE 0x00000008 /* rec error (es) */ -# define BUF_RX_DBE 0x00000004 /* dribble bit err */ -# define BUF_RX_CE 0x00000002 /* crc err (es) */ -# define BUF_RX_CSE 0x00000001 /* checksum err */ - -# define BUF_RX_ERRORS \ - (BUF_RX_DE | BUF_RX_SAF | BUF_RX_LE | BUF_RX_OE \ - | BUF_RX_IPC | BUF_RX_LC | BUF_RX_RWT | BUF_RX_RE \ - | BUF_RX_DBE | BUF_RX_CE | BUF_RX_CSE) - -/* RX buffer control bits */ -# define BUF_RX_DI 0x80000000 /* disable intrp on compl */ -# define BUF_RX_RER 0x02000000 /* rec end of ring */ -# define BUF_RX_RCH 0x01000000 /* 2nd addr chained */ - -# define BUF_RX_SIZ2 0x003ff800 /* buffer 2 size */ -# define BUF_RX_SIZ2_GET(p) ((p.control&BUF_RX_SIZ2) >> 11) - -# define BUF_RX_SIZ 0x000007ff /* rx buf 1 size */ -# define BUF_RX_SIZ_GET(p) (p.ctl&BUF_RX_SIZ) - -/* TX buffer status bits */ -# define BUF_TX_TTSS 0x00020000 /* time stamp status */ -# define BUF_TX_IHE 0x00010000 /* IP hdr err */ - -# define BUF_TX_ES 0x00008000 /* error summary */ -# define BUF_TX_JT 0x00004000 /* jabber timeout (es) */ -# define BUF_TX_FF 0x00002000 /* frame flushed (es) */ -# define BUF_TX_PCE 0x00001000 /* payld cksum err */ - -# define BUF_TX_LOC 0x00000800 /* loss carrier (es) */ -# define BUF_TX_NC 0x00000400 /* no carrier (es) */ -# define BUF_TX_LC 0x00000200 /* late collision (es) */ -# define BUF_TX_EC 0x00000100 /* excessive collision (es) */ - -# define BUF_TX_VLAN 0x00000080 /* VLAN frame */ -# define BUF_TX_CC MskBits(4, 3) /* collision count */ -# define BUF_TX_CC_GET(p) ((p.status&BUF_TX_CC)>>3) - -# define BUF_TX_ED 0x00000004 /* excessive deferral (es) */ -# define BUF_TX_UF 0x00000002 /* underflow err (es) */ -# define BUF_TX_DB 0x00000001 /* deferred bit */ - -/* TX buffer control bits */ -# define BUF_TX_IC 0x80000000 /* intrpt on compl */ -# define BUF_TX_LS 0x40000000 /* last segment */ -# define BUF_TX_FS 0x20000000 /* first segment */ -# define BUF_TX_CIC 0x18000000 /* cksum insert control */ -# define BUF_TX_CIC_SET(n) (BUF_TX_CIC&(n<<27)) - -# define BUF_TX_DC 0x04000000 /* disable CRC */ -# define BUF_TX_TER 0x02000000 /* end of ring */ -# define BUF_TX_TCH 0x01000000 /* 2nd addr chained */ - -# define BUF_TX_DP 0x00800000 /* disable padding */ -# define BUF_TX_TTSE 0x00400000 /* timestamp enable */ - -# define BUF_TX_SIZ2 0x003ff800 /* buffer 2 size */ -# define BUF_TX_SIZ2_SET(n) (BUF_TX_SIZ2(n<<11)) - -# define BUF_TX_SIZ 0x000007ff /* buffer 1 size */ -# define BUF_TX_SIZ_SET(n) (BUF_TX_SI1 & n) - - -/* Ethernet Controller Registers */ -# define BUS_MODE_REG 0x1000 - -# define BUS_MODE_MB 0x04000000 /* mixed burst */ -# define BUS_MODE_AAL 0x02000000 /* address alignment beats */ -# define BUS_MODE_8XPBL 0x01000000 /* */ - -# define BUS_MODE_USP 0x00800000 /* use separate PBL */ -# define BUS_MODE_RPBL 0x007e0000 /* rxDMA PBL */ -# define BUS_MODE_FB 0x00010000 /* fixed burst */ - -# define BUS_MODE_PR 0x0000c000 /* tx/rx priority */ -# define BUS_MODE_PR4 0x0000c000 /* tx/rx priority 4:1 */ -# define BUS_MODE_PR3 0x00008000 /* tx/rx priority 3:1 */ -# define BUS_MODE_PR2 0x00004000 /* tx/rx priority 2:1 */ -# define BUS_MODE_PR1 0x00000000 /* tx/rx priority 1:1 */ - -# define BUS_MODE_PBL 0x00003f00 /* programmable burst length */ -# define BUS_MODE_PBLSET(n) (BUS_MODE_PBL&(n<<8)) - -# define BUS_MODE_DSL 0x0000007c /* descriptor skip length */ -# define BUS_MODE_DSL_SET(n) (BUS_MODE_DSL & (n << 2)) - -# define BUS_MODE_DA 0x00000002 /* DMA arbitration scheme */ -# define BUS_MODE_SWR 0x00000001 /* software reset */ - -#define BUS_MODE_REG_DEFAULT (BUS_MODE_FB \ - | BUS_MODE_AAL \ - | BUS_MODE_PBLSET(16) \ - | BUS_MODE_DA \ - | BUS_MODE_DSL_SET(0)) - -# define TX_POLL_DEM_REG 0x1004 /* transmit poll demand */ -# define RX_POLL_DEM_REG 0x1008 /* receive poll demand */ - -# define RX_DES_LST_ADR_REG 0x100c /* receive buffer descriptor */ -# define TX_DES_LST_ADR_REG 0x1010 /* transmit buffer descriptor */ - -# define STATUS_REG 0x1014 - -# define STATUS_REG_RSVRD_1 0xc0000000 /* reserved */ -# define STATUS_REG_TTI 0x20000000 /* time-stamp trigger intrpt */ -# define STATUS_REG_GPI 0x10000000 /* gmac PMT interrupt */ - -# define STATUS_REG_GMI 0x08000000 /* gmac MMC interrupt */ -# define STATUS_REG_GLI 0x04000000 /* gmac line interface intrpt */ - -# define STATUS_REG_EB 0x03800000 /* error bits */ -# define STATUS_REG_EB_DATA 0x00800000 /* error during data transfer */ -# define STATUS_REG_EB_RDWR 0x01000000 /* error during rd/wr transfer */ -# define STATUS_REG_EB_DESC 0x02000000 /* error during desc access */ - -# define STATUS_REG_TS 0x00700000 /* transmit process state */ - -# define STATUS_REG_TS_STOP 0x00000000 /* stopped */ -# define STATUS_REG_TS_FETCH_DESC 0x00100000 /* fetching descriptor */ -# define STATUS_REG_TS_WAIT 0x00200000 /* waiting for status */ -# define STATUS_REG_TS_READ 0x00300000 /* reading host memory */ -# define STATUS_REG_TS_TIMESTAMP 0x00400000 /* timestamp write status */ -# define STATUS_REG_TS_RSVRD 0x00500000 /* reserved */ -# define STATUS_REG_TS_SUSPEND 0x00600000 /* desc-unavail/buffer-unflw */ -# define STATUS_REG_TS_CLOSE 0x00700000 /* closing desc */ - -# define STATUS_REG_RS 0x000e0000 /* receive process state */ - -# define STATUS_REG_RS_STOP 0x00000000 /* stopped */ -# define STATUS_REG_RS_FETCH_DESC 0x00020000 /* fetching descriptor */ -# define STATUS_REG_RS_RSVRD_1 0x00040000 /* reserved */ -# define STATUS_REG_RS_WAIT 0x00060000 /* waiting for packet */ -# define STATUS_REG_RS_SUSPEND 0x00080000 /* desc unavail */ -# define STATUS_REG_RS_CLOSE 0x000a0000 /* closing desc */ -# define STATUS_REG_RS_TIMESTAMP 0x000c0000 /* timestamp write status */ -# define STATUS_REG_RS_RSVRD_2 0x000e0000 /* writing host memory */ - -# define STATUS_REG_NIS 0x00010000 /* normal intrpt 14|6|2|0 */ -# define STATUS_REG_AIS 0x00008000 /* intrpts 13|10|9|8|7|5|4|3|1 */ - -# define STATUS_REG_ERI 0x00004000 /* early receive interrupt */ -# define STATUS_REG_FBI 0x00002000 /* fatal bus error interrupt */ -# define STATUS_REG_RSVRD_2 0x00001800 /* reserved */ - -# define STATUS_REG_ETI 0x00000400 /* early transmit interrupt */ -# define STATUS_REG_RWT 0x00000200 /* receive watchdog timeout */ -# define STATUS_REG_RPS 0x00000100 /* receive process stopped */ - -# define STATUS_REG_RU 0x00000080 /* receive buffer unavailable */ -# define STATUS_REG_RI 0x00000040 /* receive interrupt */ -# define STATUS_REG_UNF 0x00000020 /* transmit underflow */ -# define STATUS_REG_OVF 0x00000010 /* receive overflow */ - -# define STATUS_REG_TJT 0x00000008 /* transmit jabber timeout */ -# define STATUS_REG_TU 0x00000004 /* transmit buffer unavailable */ -# define STATUS_REG_TPS 0x00000002 /* transmit process stopped */ -# define STATUS_REG_TI 0x00000001 /* transmit interrupt */ - -# define STATUS_REG_AIS_BITS (STATUS_REG_FBI | STATUS_REG_ETI \ - | STATUS_REG_RWT | STATUS_REG_RPS \ - | STATUS_REG_RU | STATUS_REG_UNF \ - | STATUS_REG_OVF | STATUS_REG_TJT \ - | STATUS_REG_TPS | STATUS_REG_AIS) - -# define OPER_MODE_REG 0x1018 - -# define OPER_MODE_REG_DT 0x04000000 /* disab drop ip cksum err fr */ -# define OPER_MODE_REG_RSF 0x02000000 /* rec store and forward */ -# define OPER_MODE_REG_DFF 0x01000000 /* disable flush of rec frames */ - -# define OPER_MODE_REG_RFA2 0x00800000 /* thresh MSB for act flow-ctl */ -# define OPER_MODE_REG_RFD2 0x00400000 /* thresh MSB deAct flow-ctl */ -# define OPER_MODE_REG_TSF 0x00200000 /* tx store and forward */ -# define OPER_MODE_REG_FTF 0x00100000 /* flush tx FIFO */ - -# define OPER_MODE_REG_RSVD1 0x000e0000 /* reserved */ -# define OPER_MODE_REG_TTC 0x0001c000 /* transmit threshold control */ -# define OPER_MODE_REG_TTC_SET(x) (OPER_MODE_REG_TTC & (x << 14)) -# define OPER_MODE_REG_ST 0x00002000 /* start/stop transmission cmd */ - -# define OPER_MODE_REG_RFD 0x00001800 /* thresh for deAct flow-ctl */ -# define OPER_MODE_REG_RFA 0x00000600 /* threshold for act flow-ctl */ -# define OPER_MODE_REG_EFC 0x00000100 /* enable HW flow-ctl */ - -# define OPER_MODE_REG_FEF 0x00000080 /* forward error frames */ -# define OPER_MODE_REG_FUF 0x00000040 /* forward undersize good fr */ -# define OPER_MODE_REG_RSVD2 0x00000020 /* reserved */ -# define OPER_MODE_REG_RTC 0x00000018 /* receive threshold control */ -# define OPER_MODE_REG_RTC_SET(x) (OPER_MODE_REG_RTC & (x << 3)) - -# define OPER_MODE_REG_OSF 0x00000004 /* operate on second frame */ -# define OPER_MODE_REG_SR 0x00000002 /* start/stop receive */ -# define OPER_MODE_REG_RSVD3 0x00000001 /* reserved */ - - -#define OPER_MODE_REG_DEFAULT (OPER_MODE_REG_RSF \ - | OPER_MODE_REG_TSF \ - | OPER_MODE_REG_TTC_SET(5) \ - | OPER_MODE_REG_RTC_SET(1) \ - | OPER_MODE_REG_OSF) - -# define INTRP_EN_REG 0x101c - -# define INTRP_EN_REG_RSVD1 0xfffc0000 /* */ -# define INTRP_EN_REG_NIE 0x00010000 /* normal intrpt summ enable */ - -# define INTRP_EN_REG_AIE 0x00008000 /* abnormal intrpt summary en */ -# define INTRP_EN_REG_ERE 0x00004000 /* early receive intrpt enable */ -# define INTRP_EN_REG_FBE 0x00002000 /* fatal bus error enable */ - -# define INTRP_EN_REG_RSVD2 0x00001800 /* */ - -# define INTRP_EN_REG_ETE 0x00000400 /* early tx intrpt enable */ -# define INTRP_EN_REG_RWE 0x00000200 /* rx watchdog timeout enable */ -# define INTRP_EN_REG_RSE 0x00000100 /* rx stopped enable */ - -# define INTRP_EN_REG_RUE 0x00000080 /* rx buf unavailable enable */ -# define INTRP_EN_REG_RIE 0x00000040 /* rx interrupt enable */ -# define INTRP_EN_REG_UNE 0x00000020 /* underflow interrupt enable */ -# define INTRP_EN_REG_OVE 0x00000010 /* overflow interrupt enable */ - -# define INTRP_EN_REG_TJE 0x00000008 /* tx jabber timeout enable */ -# define INTRP_EN_REG_TUE 0x00000004 /* tx buf unavailable enable */ -# define INTRP_EN_REG_TSE 0x00000002 /* tx stopped enable */ -# define INTRP_EN_REG_TIE 0x00000001 /* tx interrupt enable */ - -# define INTRP_EN_REG_All (~(INTRP_EN_REG_RSVD1)) - -# define MIS_FR_REG 0x1020 - -# define MIS_FR_REG_FIFO_OVFL 0x10000000 /* fifo overflow */ -# define MIS_FR_REG_FIFO_CNT 0x0FFE0000 /* fifo cnt */ - -# define MIS_FR_REG_MISS_OVFL 0x00010000 /* missed-frame overflow */ -# define MIS_FR_REG_MISS_CNT 0x0000FFFF /* missed-frame cnt */ - -# define RX_INTRP_WTCHDOG_REG 0x1024 -# define AXI_BUS_MODE_REG 0x1028 - -# define AXI_BUS_MODE_EN_LPI 0x80000000 /* enable low power interface */ -# define AXI_BUS_MODE_UNLK_MGC_PKT 0x40000000 /* unlock-magic-pkt/rem-wk-up */ -# define AXI_BUS_MODE_WR_OSR_LMT 0x00F00000 /* max wr out stndg req limit */ -# define AXI_BUS_MODE_RD_OSR_LMT 0x000F0000 /* max rd out stndg req limit */ -# define AXI_BUS_MODE_AXI_AAL 0x00001000 /* address aligned beats */ -# define AXI_BUS_MODE_BLEN256 0x00000080 /* axi burst length 256 */ -# define AXI_BUS_MODE_BLEN128 0x00000040 /* axi burst length 128 */ -# define AXI_BUS_MODE_BLEN64 0x00000020 /* axi burst length 64 */ -# define AXI_BUS_MODE_BLEN32 0x00000010 /* axi burst length 32 */ -# define AXI_BUS_MODE_BLEN16 0x00000008 /* axi burst length 16 */ -# define AXI_BUS_MODE_BLEN8 0x00000004 /* axi burst length 8 */ -# define AXI_BUS_MODE_BLEN4 0x00000002 /* axi burst length 4 */ -# define AXI_BUS_MODE_UNDEF 0x00000001 /* axi undef burst length */ - -#define AXI_BUS_MODE_DEFAULT (AXI_BUS_MODE_WR_OSR_LMT \ - | AXI_BUS_MODE_RD_OSR_LMT \ - | AXI_BUS_MODE_BLEN16 \ - | AXI_BUS_MODE_BLEN8 \ - | AXI_BUS_MODE_BLEN4) - -# define AXI_STATUS_REG 0x102c - -/* 0x1030-0x1044 reserved */ -# define CUR_HOST_TX_DES_REG 0x1048 -# define CUR_HOST_RX_DES_REG 0x104c -# define CUR_HOST_TX_BU_ADR_REG 0x1050 -# define CUR_HOST_RX_BU_ADR_REG 0x1054 - -# define HW_FEATURE_REG 0x1058 - -# define MAC_CONFIG_REG 0x0000 - -# define MAC_CONFIG_REG_RSVD1 0xf8000000 /* */ - -# define MAC_CONFIG_REG_SFTERR 0x04000000 /* smii force tx error */ -# define MAC_CONFIG_REG_CST 0x02000000 /* crc strip for type frame */ -# define MAC_CONFIG_REG_TC 0x01000000 /* tx cfg in rgmii/sgmii/smii */ - -# define MAC_CONFIG_REG_WD 0x00800000 /* watchdog disable */ -# define MAC_CONFIG_REG_JD 0x00400000 /* jabber disable */ -# define MAC_CONFIG_REG_BE 0x00200000 /* frame burst enable */ -# define MAC_CONFIG_REG_JE 0x00100000 /* jumbo frame enable */ - -# define MAC_CONFIG_REG_IFG 0x000e0000 /* inter frame gap, 96-(8*n) */ -# define MAC_CONFIG_REG_DCRS 0x00010000 /* dis carrier sense during tx */ - -# define MAC_CONFIG_REG_PS 0x00008000 /* port select: 0/1 g/(10/100) */ -# define MAC_CONFIG_REG_FES 0x00004000 /* speed 100 mbps */ -# define MAC_CONFIG_REG_SPD (MAC_CONFIG_REG_PS | MAC_CONFIG_REG_FES) -# define MAC_CONFIG_REG_SPD_1G (0) -# define MAC_CONFIG_REG_SPD_100 (MAC_CONFIG_REG_PS | MAC_CONFIG_REG_FES) -# define MAC_CONFIG_REG_SPD_10 (MAC_CONFIG_REG_PS) -# define MAC_CONFIG_REG_SPD_SET(x) (MAC_CONFIG_REG_PS_FES & (x << 14)) - -# define MAC_CONFIG_REG_DO 0x00002000 /* disable receive own */ -# define MAC_CONFIG_REG_LM 0x00001000 /* loopback mode */ - -# define MAC_CONFIG_REG_DM 0x00000800 /* (full) duplex mode */ -# define MAC_CONFIG_REG_IPC 0x00000400 /* checksum offload */ -# define MAC_CONFIG_REG_DR 0x00000200 /* disable retry */ -# define MAC_CONFIG_REG_LUD 0x00000100 /* link up/down */ - -# define MAC_CONFIG_REG_ACS 0x00000080 /* auto pad/crc stripping */ -# define MAC_CONFIG_REG_BL 0x00000060 /* back-off limit */ -# define MAC_CONFIG_REG_BL_10 0x00000000 /* 10 */ -# define MAC_CONFIG_REG_BL_8 0x00000020 /* 8 */ -# define MAC_CONFIG_REG_BL_4 0x00000040 /* 4 */ -# define MAC_CONFIG_REG_BL_1 0x00000060 /* 1 */ -# define MAC_CONFIG_REG_DC 0x00000010 /* deferral check */ - -# define MAC_CONFIG_REG_TE 0x00000008 /* transmitter enable */ -# define MAC_CONFIG_REG_RE 0x00000004 /* receiver enable */ -# define MAC_CONFIG_REG_RSVD2 0x00000003 /* */ - -# define MAC_FR_FILTER_REG 0x0004 - -# define MAC_FR_FILTER_RA 0x80000000 /* receive all */ - -# define MAC_FR_FILTER_HPF 0x00000400 /* hash or perfect filter */ -# define MAC_FR_FILTER_SAF 0x00000200 /* source addr filt en */ -# define MAC_FR_FILTER_SAIF 0x00000100 /* SA inverse filter */ -# define MAC_FR_FILTER_PCF_MASK 0x000000c0 /* pass control frames */ -# define MAC_FR_FILTER_PCF_0 0x00000000 /* */ -# define MAC_FR_FILTER_PCF_1 0x00000040 /* */ -# define MAC_FR_FILTER_PCF_2 0x00000080 /* */ -# define MAC_FR_FILTER_PCF_3 0x000000c0 /* */ -# define MAC_FR_FILTER_DBF 0x00000020 /* disable broadcast frames */ -# define MAC_FR_FILTER_PM 0x00000010 /* pass all multicast */ -# define MAC_FR_FILTER_DAIF 0x00000008 /* DA inverse filtering */ -# define MAC_FR_FILTER_HMC 0x00000004 /* hash multicast */ -# define MAC_FR_FILTER_HUC 0x00000002 /* hash unicast */ -# define MAC_FR_FILTER_PR 0x00000001 /* promiscuous mode */ - -# define HASH_TABLE_HIGH_REG 0x0008 -# define HASH_TABLE_LOW_REG 0x000c - -# define GMII_ADR_REG 0x0010 - -# define GMII_ADR_REG_PA 0x0000f800 /* addr bits */ -# define GMII_ADR_REG_GR 0x000007c0 /* addr bits */ -# define GMII_ADR_REG_RSVRD1 0x00000020 /* */ -# define GMII_ADR_REG_CR 0x0000001c /* csr clock range */ - -# define GMII_ADR_REG_CR_42 0x00000000 /* csr clock 42 */ -# define GMII_ADR_REG_CR_62 0x00000001 /* csr clock 62 */ -# define GMII_ADR_REG_CR_16 0x00000002 /* csr clock 16 */ -# define GMII_ADR_REG_CR_26 0x00000003 /* csr clock 26 */ -# define GMII_ADR_REG_CR_102 0x00000004 /* csr clock 102 */ -# define GMII_ADR_REG_CR_124 0x00000005 /* csr clock 124 */ - -# define GMII_ADR_REG_GW 0x00000002 /* gmii write */ -# define GMII_ADR_REG_GB 0x00000001 /* gmii busy */ - -# define GMII_ADR_REG_ADR_SET(x) (GMII_ADR_REG_PA & (x << 11)) -# define GMII_ADR_REG_ADR_GET(x) ((x & GMII_ADR_REG_PA) >> 11) - -# define GMII_ADR_REG_REG_SET(x) (GMII_ADR_REG_GR & (x << 6)) -# define GMII_ADR_REG_REG_GET(x) (((x & GMII_ADR_REG_GR) >> 6) - -# define GMII_ADR_REG_CSR_SET(x) (GMII_ADR_REG_CR & (x << 2)) -# define GMII_ADR_REG_CSR_GET(x) (((x & GMII_ADR_REG_CR) >> 2) - -# define GMII_DATA_REG 0x0014 - -# define GMII_DATA_REG_DATA 0x0000ffff /* gmii data */ - -# define FLOW_CONTROL_REG 0x0018 - -# define FLOW_CONTROL_PT 0xFFFF0000 /* pause time */ -# define FLOW_CONTROL_DZPQ 0x00000080 /* disable zero-quanta pause */ -# define FLOW_CONTROL_PLT 0x00000030 /* pause level threshold */ - -# define FLOW_CONTROL_UP 0x00000008 /* unicast pause frame detect */ -# define FLOW_CONTROL_RFE 0x00000004 /* receive flow control enable */ -# define FLOW_CONTROL_TFE 0x00000002 /* transmit flow control enable */ -# define FLOW_CONTROL_FCB 0x00000001 /* flow control busy (BPA) */ - -# define VLAN_TAG_REG 0x001c - -# define VERSION_REG 0x0020 - -/* don't define these until HW if finished */ -/* # define VERSION_USER 0x10 */ -/* # define VERSION_QFEC 0x36 */ - -# define VERSION_REG_USER(x) (0xFF & (x >> 8)) -# define VERSION_REG_QFEC(x) (0xFF & x) - -# define DEBUG_REG 0x0024 - -# define DEBUG_REG_RSVD1 0xfc000000 /* */ -# define DEBUG_REG_TX_FIFO_FULL 0x02000000 /* Tx fifo full */ -# define DEBUG_REG_TX_FIFO_NEMP 0x01000000 /* Tx fifo not empty */ - -# define DEBUG_REG_RSVD2 0x00800000 /* */ -# define DEBUG_REG_TX_WR_ACTIVE 0x00400000 /* Tx fifo write ctrl active */ - -# define DEBUG_REG_TX_RD_STATE 0x00300000 /* Tx fifo rd ctrl state */ -# define DEBUG_REG_TX_RD_IDLE 0x00000000 /* idle */ -# define DEBUG_REG_TX_RD_WAIT 0x00100000 /* waiting for status */ -# define DEBUG_REG_TX_RD_PASUE 0x00200000 /* generating pause */ -# define DEBUG_REG_TX_RD_WRTG 0x00300000 /* wr stat flush fifo */ - -# define DEBUG_REG_TX_PAUSE 0x00080000 /* Tx in pause condition */ - -# define DEBUG_REG_TX_CTRL_STATE 0x00060000 /* Tx frame controller state */ -# define DEBUG_REG_TX_CTRL_IDLE 0x00090000 /* idle */ -# define DEBUG_REG_TX_CTRL_WAIT 0x00020000 /* waiting for status*/ -# define DEBUG_REG_TX_CTRL_PAUSE 0x00040000 /* generating pause */ -# define DEBUG_REG_TX_CTRL_XFER 0x00060000 /* transferring input */ - -# define DEBUG_REG_TX_ACTIVE 0x00010000 /* Tx actively transmitting */ -# define DEBUG_REG_RSVD3 0x0000fc00 /* */ - -# define DEBUG_REG_RX_STATE 0x00000300 /* Rx fifo state */ -# define DEBUG_REG_RX_EMPTY 0x00000000 /* empty */ -# define DEBUG_REG_RX_LOW 0x00000100 /* below threshold */ -# define DEBUG_REG_RX_HIGH 0x00000200 /* above threshold */ -# define DEBUG_REG_RX_FULL 0x00000300 /* full */ - -# define DEBUG_REG_RSVD4 0x00000080 /* */ - -# define DEBUG_REG_RX_RD_STATE 0x00000060 /* Rx rd ctrl state */ -# define DEBUG_REG_RX_RD_IDLE 0x00000000 /* idle */ -# define DEBUG_REG_RX_RD_RDG_FR 0x00000020 /* reading frame data */ -# define DEBUG_REG_RX_RD_RDG_STA 0x00000040 /* reading status */ -# define DEBUG_REG_RX_RD_FLUSH 0x00000060 /* flush fr data/stat */ - -# define DEBUG_REG_RX_ACTIVE 0x00000010 /* Rx wr ctlr active */ - -# define DEBUG_REG_RSVD5 0x00000008 /* */ -# define DEBUG_REG_SM_FIFO_RW_STA 0x00000006 /* small fifo rd/wr state */ -# define DEBUG_REG_RX_RECVG 0x00000001 /* Rx actively receiving data */ - -# define REM_WAKEUP_FR_REG 0x0028 -# define PMT_CTRL_STAT_REG 0x002c -/* 0x0030-0x0034 reserved */ - -# define INTRP_STATUS_REG 0x0038 - -# define INTRP_STATUS_REG_RSVD1 0x0000fc00 /* */ -# define INTRP_STATUS_REG_TSI 0x00000200 /* time stamp int stat */ -# define INTRP_STATUS_REG_RSVD2 0x00000100 /* */ - -# define INTRP_STATUS_REG_RCOI 0x00000080 /* rec checksum offload int */ -# define INTRP_STATUS_REG_TI 0x00000040 /* tx int stat */ -# define INTRP_STATUS_REG_RI 0x00000020 /* rx int stat */ -# define INTRP_STATUS_REG_NI 0x00000010 /* normal int summary */ - -# define INTRP_STATUS_REG_PMTI 0x00000008 /* PMT int */ -# define INTRP_STATUS_REG_ANC 0x00000004 /* auto negotiation complete */ -# define INTRP_STATUS_REG_LSC 0x00000002 /* link status change */ -# define INTRP_STATUS_REG_MII 0x00000001 /* rgMii/sgMii int */ - -# define INTRP_MASK_REG 0x003c - -# define INTRP_MASK_REG_RSVD1 0xfc00 /* */ -# define INTRP_MASK_REG_TSIM 0x0200 /* time stamp int mask */ -# define INTRP_MASK_REG_RSVD2 0x01f0 /* */ - -# define INTRP_MASK_REG_PMTIM 0x0000 /* PMT int mask */ -# define INTRP_MASK_REG_ANCM 0x0000 /* auto negotiation compl mask */ -# define INTRP_MASK_REG_LSCM 0x0000 /* link status change mask */ -# define INTRP_MASK_REG_MIIM 0x0000 /* rgMii/sgMii int mask */ - -# define MAC_ADR_0_HIGH_REG 0x0040 -# define MAC_ADR_0_LOW_REG 0x0044 -/* additional pairs of registers for MAC addresses 1-15 */ -# define MAC_ADR_HIGH_REG_N(n) (((n) < 16) ? \ - (MAC_ADR_0_HIGH_REG + (n) * 8) : \ - (MAC_ADR16_HIGH_REG + ((n) - 16) * 8)) -# define MAC_ADR_LOW_REG_N(n) (((n) < 16) ? \ - (MAC_ADR_0_LOW_REG + (n) * 8) : \ - (MAC_ADR16_LOW_REG + ((n) - 16) * 8)) - -# define AN_CONTROL_REG 0x00c0 - -# define AN_CONTROL_REG_RSVRD1 0xfff80000 /* */ -# define AN_CONTROL_REG_SGM_RAL 0x00040000 /* sgmii ral control */ -# define AN_CONTROL_REG_LR 0x00020000 /* lock to reference */ -# define AN_CONTROL_REG_ECD 0x00010000 /* enable comma detect */ - -# define AN_CONTROL_REG_RSVRD2 0x00008000 /* */ -# define AN_CONTROL_REG_ELE 0x00004000 /* external loopback enable */ -# define AN_CONTROL_REG_RSVRD3 0x00002000 /* */ -# define AN_CONTROL_REG_ANE 0x00001000 /* auto negotiation enable */ - -# define AN_CONTROL_REG_RSRVD4 0x00000c00 /* */ -# define AN_CONTROL_REG_RAN 0x00000200 /* restart auto negotiation */ -# define AN_CONTROL_REG_RSVRD5 0x000001ff /* */ - -# define AN_STATUS_REG 0x00c4 - -# define AN_STATUS_REG_RSVRD1 0xfffffe00 /* */ -# define AN_STATUS_REG_ES 0x00000100 /* extended status */ -# define AN_STATUS_REG_RSVRD2 0x000000c0 /* */ -# define AN_STATUS_REG_ANC 0x00000020 /* auto-negotiation complete */ -# define AN_STATUS_REG_RSVRD3 0x00000010 /* */ -# define AN_STATUS_REG_ANA 0x00000008 /* auto-negotiation ability */ -# define AN_STATUS_REG_LS 0x00000004 /* link status */ -# define AN_STATUS_REG_RSVRD4 0x00000003 /* */ - -# define AN_ADVERTISE_REG 0x00c8 -# define AN_LNK_PRTNR_ABIL_REG 0x00cc -# define AN_EXPANDSION_REG 0x00d0 -# define TBI_EXT_STATUS_REG 0x00d4 - -# define SG_RG_SMII_STATUS_REG 0x00d8 - -# define LINK_STATUS_REG 0x00d8 - -# define LINK_STATUS_REG_RSVRD1 0xffffffc0 /* */ -# define LINK_STATUS_REG_FCD 0x00000020 /* false carrier detect */ -# define LINK_STATUS_REG_JT 0x00000010 /* jabber timeout */ -# define LINK_STATUS_REG_UP 0x00000008 /* link status */ - -# define LINK_STATUS_REG_SPD 0x00000006 /* link speed */ -# define LINK_STATUS_REG_SPD_2_5 0x00000000 /* 10M 2.5M * 4 */ -# define LINK_STATUS_REG_SPD_25 0x00000002 /* 100M 25M * 4 */ -# define LINK_STATUS_REG_SPD_125 0x00000004 /* 1G 125M * 8 */ - -# define LINK_STATUS_REG_F_DUPLEX 0x00000001 /* full duplex */ - -/* 0x00dc-0x00fc reserved */ - -/* MMC Register Map is from 0x0100-0x02fc */ -# define MMC_CNTRL_REG 0x0100 -# define MMC_INTR_RX_REG 0x0104 -# define MMC_INTR_TX_REG 0x0108 -# define MMC_INTR_MASK_RX_REG 0x010C -# define MMC_INTR_MASK_TX_REG 0x0110 -# define NUM_MULTCST_FRM_RCVD_G 0x0190 - -/* 0x0300-0x06fc reserved */ - -/* precision time protocol time stamp registers */ - -# define TS_CTL_REG 0x0700 - -# define TS_CTL_ATSFC 0x00080000 -# define TS_CTL_TSENMAC 0x00040000 - -# define TS_CTL_TSCLKTYPE 0x00030000 -# define TS_CTL_TSCLK_ORD 0x00000000 -# define TS_CTL_TSCLK_BND 0x00010000 -# define TS_CTL_TSCLK_ETE 0x00020000 -# define TS_CTL_TSCLK_PTP 0x00030000 - -# define TS_CTL_TSMSTRENA 0x00008000 -# define TS_CTL_TSEVNTENA 0x00004000 -# define TS_CTL_TSIPV4ENA 0x00002000 -# define TS_CTL_TSIPV6ENA 0x00001000 - -# define TS_CTL_TSIPENA 0x00000800 -# define TS_CTL_TSVER2ENA 0x00000400 -# define TS_CTL_TSCTRLSSR 0x00000200 -# define TS_CTL_TSENALL 0x00000100 - -# define TS_CTL_TSADDREG 0x00000020 -# define TS_CTL_TSTRIG 0x00000010 - -# define TS_CTL_TSUPDT 0x00000008 -# define TS_CTL_TSINIT 0x00000004 -# define TS_CTL_TSCFUPDT 0x00000002 -# define TS_CTL_TSENA 0x00000001 - - -# define TS_SUB_SEC_INCR_REG 0x0704 -# define TS_HIGH_REG 0x0708 -# define TS_LOW_REG 0x070c -# define TS_HI_UPDT_REG 0x0710 -# define TS_LO_UPDT_REG 0x0714 -# define TS_APPEND_REG 0x0718 -# define TS_TARG_TIME_HIGH_REG 0x071c -# define TS_TARG_TIME_LOW_REG 0x0720 -# define TS_HIGHER_WD_REG 0x0724 -# define TS_STATUS_REG 0x072c - -/* 0x0730-0x07fc reserved */ - -# define MAC_ADR16_HIGH_REG 0x0800 -# define MAC_ADR16_LOW_REG 0x0804 -/* additional pairs of registers for MAC addresses 17-31 */ - -# define MAC_ADR_MAX 32 - - -# define QFEC_INTRP_SETUP (INTRP_EN_REG_AIE \ - | INTRP_EN_REG_FBE \ - | INTRP_EN_REG_RWE \ - | INTRP_EN_REG_RSE \ - | INTRP_EN_REG_RUE \ - | INTRP_EN_REG_UNE \ - | INTRP_EN_REG_OVE \ - | INTRP_EN_REG_TJE \ - | INTRP_EN_REG_TSE \ - | INTRP_EN_REG_NIE \ - | INTRP_EN_REG_RIE \ - | INTRP_EN_REG_TIE) - -/* - * ASIC Ethernet clock register definitions: - * address offsets and some register definitions - */ - -# define EMAC_CLK_REG_BASE 0x94020000 - -/* - * PHY clock PLL register locations - */ -# define ETH_MD_REG 0x02A4 -# define ETH_NS_REG 0x02A8 - -/* definitions of NS_REG control bits - */ -# define ETH_NS_SRC_SEL 0x0007 - -# define ETH_NS_PRE_DIV_MSK 0x0018 -# define ETH_NS_PRE_DIV(x) (ETH_NS_PRE_DIV_MSK & (x << 3)) - -# define ETH_NS_MCNTR_MODE_MSK 0x0060 -# define ETH_NS_MCNTR_MODE_BYPASS 0x0000 -# define ETH_NS_MCNTR_MODE_SWALLOW 0x0020 -# define ETH_NS_MCNTR_MODE_DUAL 0x0040 -# define ETH_NS_MCNTR_MODE_SINGLE 0x0060 - -# define ETH_NS_MCNTR_RST 0x0080 -# define ETH_NS_MCNTR_EN 0x0100 - -# define EMAC_PTP_NS_CLK_EN 0x0200 -# define EMAC_PTP_NS_CLK_INV 0x0400 -# define EMAC_PTP_NS_ROOT_EN 0x0800 - -/* clock sources - */ -# define CLK_SRC_TCXO 0x0 -# define CLK_SRC_PLL_GLOBAL 0x1 -# define CLK_SRC_PLL_ARM 0x2 -# define CLK_SRC_PLL_QDSP6 0x3 -# define CLK_SRC_PLL_EMAC 0x4 -# define CLK_SRC_EXT_CLK2 0x5 -# define CLK_SRC_EXT_CLK1 0x6 -# define CLK_SRC_CORE_TEST 0x7 - -# define ETH_MD_M(x) (x << 16) -# define ETH_MD_2D_N(x) ((~(x) & 0xffff)) -# define ETH_NS_NM(x) ((~(x) << 16) & 0xffff0000) - -/* - * PHY interface clock divider - */ -# define ETH_X_EN_NS_REG 0x02AC - -# define ETH_RX_CLK_FB_INV 0x80 -# define ETH_RX_CLK_FB_EN 0x40 -# define ETH_TX_CLK_FB_INV 0x20 -# define ETH_TX_CLK_FB_EN 0x10 -# define ETH_RX_CLK_INV 0x08 -# define ETH_RX_CLK_EN 0x04 -# define ETH_TX_CLK_INV 0x02 -# define ETH_TX_CLK_EN 0x01 - -# define ETH_X_EN_NS_DEFAULT \ - (ETH_RX_CLK_FB_EN | ETH_TX_CLK_FB_EN | ETH_RX_CLK_EN | ETH_TX_CLK_EN) - -# define EMAC_PTP_MD_REG 0x02B0 - -/* PTP clock divider - */ -# define EMAC_PTP_NS_REG 0x02B4 - -/* - * clock interface pin controls - */ -# define EMAC_NS_REG 0x02B8 - -# define EMAC_RX_180_CLK_INV 0x2000 -# define EMAC_RX_180_CLK_EN 0x1000 -# define EMAC_RX_180_CLK_EN_INV (EMAC_RX_180_CLK_INV | EMAC_RX_180_CLK_EN) - -# define EMAC_TX_180_CLK_INV 0x0800 -# define EMAC_TX_180_CLK_EN 0x0400 -# define EMAC_TX_180_CLK_EN_INV (EMAC_TX_180_CLK_INV | EMAC_TX_180_CLK_EN) - -# define EMAC_REVMII_RX_CLK_INV 0x0200 -# define EMAC_REVMII_RX_CLK_EN 0x0100 - -# define EMAC_RX_CLK_INV 0x0080 -# define EMAC_RX_CLK_EN 0x0040 - -# define EMAC_REVMII_TX_CLK_INV 0x0020 -# define EMAC_REVMII_TX_CLK_EN 0x0010 - -# define EMAC_TX_CLK_INV 0x0008 -# define EMAC_TX_CLK_EN 0x0004 - -# define EMAC_RX_R_CLK_EN 0x0002 -# define EMAC_TX_R_CLK_EN 0x0001 - -# define EMAC_NS_DEFAULT \ - (EMAC_RX_180_CLK_EN_INV | EMAC_TX_180_CLK_EN_INV \ - | EMAC_REVMII_RX_CLK_EN | EMAC_REVMII_TX_CLK_EN \ - | EMAC_RX_CLK_EN | EMAC_TX_CLK_EN \ - | EMAC_RX_R_CLK_EN | EMAC_TX_R_CLK_EN) - -/* - * - */ -# define EMAC_TX_FS_REG 0x02BC -# define EMAC_RX_FS_REG 0x02C0 - -/* - * Ethernet controller PHY interface select - */ -# define EMAC_PHY_INTF_SEL_REG 0x18030 - -# define EMAC_PHY_INTF_SEL_MII 0x0 -# define EMAC_PHY_INTF_SEL_RGMII 0x1 -# define EMAC_PHY_INTF_SEL_REVMII 0x7 -# define EMAC_PHY_INTF_SEL_MASK 0x7 - -/* - * MDIO addresses - */ -# define EMAC_PHY_ADDR_REG 0x18034 -# define EMAC_REVMII_PHY_ADDR_REG 0x18038 - -/* - * clock routing - */ -# define EMAC_CLKMUX_SEL_REG 0x1803c - -# define EMAC_CLKMUX_SEL_0 0x1 -# define EMAC_CLKMUX_SEL_1 0x2 - - -#endif diff --git a/drivers/net/wireless/libra/Makefile b/drivers/net/wireless/libra/Makefile index 849de059a1e50b1b5e3b02347df4742476e22df1..b91af834161766258dade4b255e78e273eb138a0 100644 --- a/drivers/net/wireless/libra/Makefile +++ b/drivers/net/wireless/libra/Makefile @@ -1,14 +1,6 @@ # Makefile for wlan sdio if driver -librasdioif-objs += libra_sdioif.o ../wcnss/qcomwlan_secif.o - -ifdef CONFIG_ARCH_MSM8X60 - librasdioif-objs += qcomwlan_pwrif.o -endif - -ifdef CONFIG_ARCH_MSM7X27A - librasdioif-objs += qcomwlan7x27a_pwrif.o -endif +librasdioif-objs += ../wcnss/qcomwlan_secif.o obj-$(CONFIG_LIBRA_SDIOIF) += librasdioif.o diff --git a/drivers/net/wireless/libra/libra_sdioif.c b/drivers/net/wireless/libra/libra_sdioif.c deleted file mode 100644 index 99385596a65f491c40954d8208cd4a1f622b6fac..0000000000000000000000000000000000000000 --- a/drivers/net/wireless/libra/libra_sdioif.c +++ /dev/null @@ -1,553 +0,0 @@ -/* Copyright (c) 2009-2012, 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 -#include -#include -#include -#include -#include -#include - -/* Libra SDIO function device */ -static struct sdio_func *libra_sdio_func; -static struct mmc_host *libra_mmc_host; -static int libra_mmc_host_index; - -/* SDIO Card ID / Device ID */ -static unsigned short libra_sdio_card_id; - -/* completion variables */ -struct completion gCard_rem_event_var; -EXPORT_SYMBOL(gCard_rem_event_var); -struct completion gShutdown_event_var; -EXPORT_SYMBOL(gShutdown_event_var); - -static suspend_handler_t *libra_suspend_hldr; -static resume_handler_t *libra_resume_hldr; -static notify_card_removal_t *libra_notify_card_removal_hdlr; -static shutdown_handler_t *libra_sdio_shutdown_hdlr; - -int libra_enable_sdio_irq_in_chip(struct sdio_func *func, u8 enable) -{ - unsigned char reg = 0; - int err = 0; - - sdio_claim_host(func); - - /* Read the value into reg */ - libra_sdiocmd52(func, SDIO_CCCR_IENx, ®, 0, &err); - if (err) - printk(KERN_ERR "%s: Could not read SDIO_CCCR_IENx register " - "err=%d\n", __func__, err); - - if (libra_mmc_host) { - if (enable) { - reg |= 1 << func->num; - reg |= 1; - } else { - reg &= ~(1 << func->num); - } - libra_sdiocmd52(func, SDIO_CCCR_IENx, ®, 1, &err); - if (err) - printk(KERN_ERR "%s: Could not enable/disable irq " - "err=%d\n", __func__, err); - } - sdio_release_host(func); - - return err; -} -EXPORT_SYMBOL(libra_enable_sdio_irq_in_chip); - -/** - * libra_sdio_configure() - Function to configure the SDIO device param - * @libra_sdio_rxhandler Rx handler - * @func_drv_fn Function driver function for special setup - * @funcdrv_timeout Function Enable timeout - * @blksize Block size - * - * Configure SDIO device, enable function and set block size - */ -int libra_sdio_configure(sdio_irq_handler_t libra_sdio_rxhandler, - void (*func_drv_fn)(int *status), - unsigned int funcdrv_timeout, unsigned int blksize) -{ - int err_ret = 0; - struct sdio_func *func = libra_sdio_func; - - if (libra_sdio_func == NULL) { - printk(KERN_ERR "%s: Error SDIO card not detected\n", __func__); - goto cfg_error; - } - - sdio_claim_host(func); - - /* Currently block sizes are set here. */ - func->max_blksize = blksize; - if (sdio_set_block_size(func, blksize)) { - printk(KERN_ERR "%s: Unable to set the block size.\n", - __func__); - sdio_release_host(func); - goto cfg_error; - } - - /* Function driver specific configuration. */ - if (func_drv_fn) { - (*func_drv_fn)(&err_ret); - if (err_ret) { - printk(KERN_ERR "%s: function driver provided configure function error=%d\n", - __func__, err_ret); - sdio_release_host(func); - goto cfg_error; - } - } - - /* We set this based on the function card. */ - func->enable_timeout = funcdrv_timeout; - err_ret = sdio_enable_func(func); - if (err_ret != 0) { - printk(KERN_ERR "%s: Unable to enable function %d\n", - __func__, err_ret); - sdio_release_host(func); - goto cfg_error; - } - - if (sdio_claim_irq(func, libra_sdio_rxhandler)) { - sdio_disable_func(func); - printk(KERN_ERR "%s: Unable to claim irq.\n", __func__); - sdio_release_host(func); - goto cfg_error; - } - - libra_enable_sdio_irq_in_chip(func, 0); - - sdio_release_host(func); - - return 0; - -cfg_error: - return -1; - -} -EXPORT_SYMBOL(libra_sdio_configure); - -int libra_sdio_configure_suspend_resume( - suspend_handler_t *libra_sdio_suspend_hdlr, - resume_handler_t *libra_sdio_resume_hdlr) -{ - libra_suspend_hldr = libra_sdio_suspend_hdlr; - libra_resume_hldr = libra_sdio_resume_hdlr; - return 0; -} -EXPORT_SYMBOL(libra_sdio_configure_suspend_resume); - -/* - * libra_sdio_deconfigure() - Function to reset the SDIO device param - */ -void libra_sdio_deconfigure(struct sdio_func *func) -{ - if (NULL == libra_sdio_func) - return; - - sdio_claim_host(func); - sdio_release_irq(func); - sdio_disable_func(func); - sdio_release_host(func); -} -EXPORT_SYMBOL(libra_sdio_deconfigure); - -int libra_enable_sdio_irq(struct sdio_func *func, u8 enable) -{ - if (libra_mmc_host && libra_mmc_host->ops && - libra_mmc_host->ops->enable_sdio_irq) { - libra_mmc_host->ops->enable_sdio_irq(libra_mmc_host, enable); - return 0; - } - - printk(KERN_ERR "%s: Could not enable disable irq\n", __func__); - return -EINVAL; -} -EXPORT_SYMBOL(libra_enable_sdio_irq); - -int libra_disable_sdio_irq_capability(struct sdio_func *func, u8 disable) -{ - if (libra_mmc_host) { - if (disable) - libra_mmc_host->caps &= ~MMC_CAP_SDIO_IRQ; - else - libra_mmc_host->caps |= MMC_CAP_SDIO_IRQ; - return 0; - } - printk(KERN_ERR "%s: Could not change sdio capabilities to polling\n", - __func__); - return -EINVAL; -} -EXPORT_SYMBOL(libra_disable_sdio_irq_capability); - -/* - * libra_sdio_release_irq() - Function to release IRQ - */ -void libra_sdio_release_irq(struct sdio_func *func) -{ - if (NULL == libra_sdio_func) - return; - - sdio_release_irq(func); -} -EXPORT_SYMBOL(libra_sdio_release_irq); - -/* - * libra_sdio_disable_func() - Function to disable sdio func - */ -void libra_sdio_disable_func(struct sdio_func *func) -{ - if (NULL == libra_sdio_func) - return; - - sdio_disable_func(func); -} -EXPORT_SYMBOL(libra_sdio_disable_func); - -/* - * Return the SDIO Function device - */ -struct sdio_func *libra_getsdio_funcdev(void) -{ - return libra_sdio_func; -} -EXPORT_SYMBOL(libra_getsdio_funcdev); - -/* - * Set function driver as the private data for the function device - */ -void libra_sdio_setprivdata(struct sdio_func *sdio_func_dev, - void *padapter) -{ - if (NULL == libra_sdio_func) - return; - - sdio_set_drvdata(sdio_func_dev, padapter); -} -EXPORT_SYMBOL(libra_sdio_setprivdata); - -/* - * Return private data of the function device. - */ -void *libra_sdio_getprivdata(struct sdio_func *sdio_func_dev) -{ - return sdio_get_drvdata(sdio_func_dev); -} -EXPORT_SYMBOL(libra_sdio_getprivdata); - -/* - * Function driver claims the SDIO device - */ -void libra_claim_host(struct sdio_func *sdio_func_dev, - pid_t *curr_claimed, pid_t current_pid, atomic_t *claim_count) -{ - if (NULL == libra_sdio_func) - return; - - if (*curr_claimed == current_pid) { - atomic_inc(claim_count); - return; - } - - /* Go ahead and claim the host if not locked by anybody. */ - sdio_claim_host(sdio_func_dev); - - *curr_claimed = current_pid; - atomic_inc(claim_count); - -} -EXPORT_SYMBOL(libra_claim_host); - -/* - * Function driver releases the SDIO device - */ -void libra_release_host(struct sdio_func *sdio_func_dev, - pid_t *curr_claimed, pid_t current_pid, atomic_t *claim_count) -{ - - if (NULL == libra_sdio_func) - return; - - if (*curr_claimed != current_pid) { - /* Dont release */ - return; - } - - atomic_dec(claim_count); - if (atomic_read(claim_count) == 0) { - *curr_claimed = 0; - sdio_release_host(sdio_func_dev); - } -} -EXPORT_SYMBOL(libra_release_host); - -void libra_sdiocmd52(struct sdio_func *sdio_func_dev, unsigned int addr, - u8 *byte_var, int write, int *err_ret) -{ - if (write) - sdio_writeb(sdio_func_dev, byte_var[0], addr, err_ret); - else - byte_var[0] = sdio_readb(sdio_func_dev, addr, err_ret); -} -EXPORT_SYMBOL(libra_sdiocmd52); - -u8 libra_sdio_readsb(struct sdio_func *func, void *dst, - unsigned int addr, int count) -{ - return sdio_readsb(func, dst, addr, count); -} -EXPORT_SYMBOL(libra_sdio_readsb); - -int libra_sdio_memcpy_fromio(struct sdio_func *func, - void *dst, unsigned int addr, int count) -{ - return sdio_memcpy_fromio(func, dst, addr, count); -} -EXPORT_SYMBOL(libra_sdio_memcpy_fromio); - -int libra_sdio_writesb(struct sdio_func *func, - unsigned int addr, void *src, int count) -{ - return sdio_writesb(func, addr, src, count); -} -EXPORT_SYMBOL(libra_sdio_writesb); - -int libra_sdio_memcpy_toio(struct sdio_func *func, - unsigned int addr, void *src, int count) -{ - return sdio_memcpy_toio(func, addr, src, count); -} -EXPORT_SYMBOL(libra_sdio_memcpy_toio); - -int libra_detect_card_change(void) -{ - if (libra_mmc_host) { - if (!strcmp(libra_mmc_host->class_dev.class->name, "mmc_host") - && (libra_mmc_host_index == libra_mmc_host->index)) { - mmc_detect_change(libra_mmc_host, 0); - return 0; - } - } - - printk(KERN_ERR "%s: Could not trigger card change\n", __func__); - return -EINVAL; -} -EXPORT_SYMBOL(libra_detect_card_change); - -int libra_sdio_enable_polling(void) -{ - if (libra_mmc_host) { - if (!strcmp(libra_mmc_host->class_dev.class->name, "mmc_host") - && (libra_mmc_host_index == libra_mmc_host->index)) { - libra_mmc_host->caps |= MMC_CAP_NEEDS_POLL; - mmc_detect_change(libra_mmc_host, 0); - return 0; - } - } - - printk(KERN_ERR "%s: Could not trigger SDIO scan\n", __func__); - return -1; -} -EXPORT_SYMBOL(libra_sdio_enable_polling); - -void libra_sdio_set_clock(struct sdio_func *func, unsigned int clk_freq) -{ - struct mmc_host *host = func->card->host; - host->ios.clock = clk_freq; - host->ops->set_ios(host, &host->ios); - -} -EXPORT_SYMBOL(libra_sdio_set_clock); - -/* - * API to get SDIO Device Card ID - */ -void libra_sdio_get_card_id(struct sdio_func *func, unsigned short *card_id) -{ - if (card_id) - *card_id = libra_sdio_card_id; -} -EXPORT_SYMBOL(libra_sdio_get_card_id); - -/* - * SDIO Probe - */ -static int libra_sdio_probe(struct sdio_func *func, - const struct sdio_device_id *sdio_dev_id) -{ - libra_mmc_host = func->card->host; - libra_mmc_host_index = libra_mmc_host->index; - libra_sdio_func = func; - libra_sdio_card_id = sdio_dev_id->device; - - printk(KERN_INFO "%s: success with block size of %d device_id=0x%x\n", - __func__, - func->cur_blksize, - sdio_dev_id->device); - - /* Turn off SDIO polling from now on */ - libra_mmc_host->caps &= ~MMC_CAP_NEEDS_POLL; - return 0; -} - -static void libra_sdio_remove(struct sdio_func *func) -{ - if (libra_notify_card_removal_hdlr) - libra_notify_card_removal_hdlr(); - libra_sdio_func = NULL; - - printk(KERN_INFO "%s : Module removed.\n", __func__); -} - -#ifdef CONFIG_PM -static int libra_sdio_suspend(struct device *dev) -{ - struct sdio_func *func = dev_to_sdio_func(dev); - int ret = 0; - - ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); - - if (ret) { - printk(KERN_ERR "%s: Error Host doesn't support the keep power capability\n" , - __func__); - return ret; - } - if (libra_suspend_hldr) { - /* Disable SDIO IRQ when driver is being suspended */ - libra_enable_sdio_irq(func, 0); - ret = libra_suspend_hldr(func); - if (ret) { - printk(KERN_ERR - "%s: Libra driver is not able to suspend\n" , __func__); - /* Error - Restore SDIO IRQ */ - libra_enable_sdio_irq(func, 1); - return ret; - } - } - - - return sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ); -} - -static int libra_sdio_resume(struct device *dev) -{ - struct sdio_func *func = dev_to_sdio_func(dev); - - if (libra_resume_hldr) { - libra_resume_hldr(func); - /* Restore SDIO IRQ */ - libra_enable_sdio_irq(func, 1); - } - - return 0; -} -#else -#define libra_sdio_suspend 0 -#define libra_sdio_resume 0 -#endif - -static void libra_sdio_shutdown(struct device *dev) -{ - if (libra_sdio_shutdown_hdlr) { - libra_sdio_shutdown_hdlr(); - printk(KERN_INFO "%s : Notified shutdown event to Libra driver.\n", - __func__); - } -} - -int libra_sdio_register_shutdown_hdlr( - shutdown_handler_t *libra_shutdown_hdlr) -{ - libra_sdio_shutdown_hdlr = libra_shutdown_hdlr; - return 0; -} -EXPORT_SYMBOL(libra_sdio_register_shutdown_hdlr); - -int libra_sdio_notify_card_removal( - notify_card_removal_t *libra_sdio_notify_card_removal_hdlr) -{ - libra_notify_card_removal_hdlr = libra_sdio_notify_card_removal_hdlr; - return 0; -} -EXPORT_SYMBOL(libra_sdio_notify_card_removal); - -static struct sdio_device_id libra_sdioid[] = { - {.class = 0, .vendor = LIBRA_MAN_ID, .device = LIBRA_REV_1_0_CARD_ID}, - {.class = 0, .vendor = VOLANS_MAN_ID, .device = VOLANS_REV_2_0_CARD_ID}, - {} -}; - -static const struct dev_pm_ops libra_sdio_pm_ops = { - .suspend = libra_sdio_suspend, - .resume = libra_sdio_resume, -}; - -static struct sdio_driver libra_sdiofn_driver = { - .name = "libra_sdiofn", - .id_table = libra_sdioid, - .probe = libra_sdio_probe, - .remove = libra_sdio_remove, - .drv.pm = &libra_sdio_pm_ops, - .drv.shutdown = libra_sdio_shutdown, -}; - -static int __init libra_sdioif_init(void) -{ - libra_sdio_func = NULL; - libra_mmc_host = NULL; - libra_mmc_host_index = -1; - libra_suspend_hldr = NULL; - libra_resume_hldr = NULL; - libra_notify_card_removal_hdlr = NULL; - libra_sdio_shutdown_hdlr = NULL; - - sdio_register_driver(&libra_sdiofn_driver); - - printk(KERN_INFO "%s: Loaded Successfully\n", __func__); - - return 0; -} - -static void __exit libra_sdioif_exit(void) -{ - unsigned int attempts = 0; - - if (!libra_detect_card_change()) { - do { - ++attempts; - msleep(500); - } while (libra_sdio_func != NULL && attempts < 3); - } - - if (libra_sdio_func != NULL) - printk(KERN_ERR "%s: Card removal not detected\n", __func__); - - sdio_unregister_driver(&libra_sdiofn_driver); - - libra_sdio_func = NULL; - libra_mmc_host = NULL; - libra_mmc_host_index = -1; - - printk(KERN_INFO "%s: Unloaded Successfully\n", __func__); -} - -module_init(libra_sdioif_init); -module_exit(libra_sdioif_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("1.0"); -MODULE_DESCRIPTION("WLAN SDIODriver"); diff --git a/drivers/net/wireless/libra/qcomwlan7x27a_pwrif.c b/drivers/net/wireless/libra/qcomwlan7x27a_pwrif.c deleted file mode 100644 index 7fa6cfcb75be54e8a3627a4e06b63048d70c5a68..0000000000000000000000000000000000000000 --- a/drivers/net/wireless/libra/qcomwlan7x27a_pwrif.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Copyright (c) 2011, 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 -#include -#include -#include -#include -#include -#include - -#define WLAN_GPIO_EXT_POR_N 134 - -static const char *id = "WLAN"; - -enum { - WLAN_VREG_L17 = 0, - WLAN_VREG_S3, - WLAN_VREG_TCXO_L11, - WLAN_VREG_L19, - WLAN_VREG_L5, - WLAN_VREG_L6 -}; - -struct wlan_vreg_info { - const char *vreg_id; - unsigned int level_min; - unsigned int level_max; - unsigned int pmapp_id; - unsigned int is_vreg_pin_controlled; - struct regulator *reg; -}; - - -static struct wlan_vreg_info vreg_info[] = { - {"bt", 3050000, 3050000, 21, 1, NULL}, - {"msme1", 1800000, 1800000, 2, 0, NULL}, - {"wlan_tcx0", 1800000, 1800000, 53, 0, NULL}, - {"wlan4", 1200000, 1200000, 23, 0, NULL}, - {"wlan2", 1350000, 1350000, 9, 1, NULL}, - {"wlan3", 1200000, 1200000, 10, 1, NULL}, -}; - -static int qrf6285_init_regs(void) -{ - struct regulator_bulk_data regs[ARRAY_SIZE(vreg_info)]; - int i, rc; - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - regs[i].supply = vreg_info[i].vreg_id; - regs[i].min_uV = vreg_info[i].level_min; - regs[i].max_uV = vreg_info[i].level_max; - } - - rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs); - if (rc) { - pr_err("%s: could not get regulators: %d\n", __func__, rc); - goto out; - } - - for (i = 0; i < ARRAY_SIZE(regs); i++) - vreg_info[i].reg = regs[i].consumer; - - return 0; - -out: - return rc; -} - -int chip_power_qrf6285(bool on) -{ - static bool init_done; - int rc = 0, index = 0; - - if (unlikely(!init_done)) { - rc = qrf6285_init_regs(); - if (rc) - return rc; - else - init_done = true; - } - - if (on) { - rc = gpio_request(WLAN_GPIO_EXT_POR_N, "WLAN_DEEP_SLEEP_N"); - - if (rc) { - pr_err("WLAN reset GPIO %d request failed %d\n", - WLAN_GPIO_EXT_POR_N, rc); - goto fail; - } - rc = gpio_direction_output(WLAN_GPIO_EXT_POR_N, 1); - if (rc < 0) { - pr_err("WLAN reset GPIO %d set direction failed %d\n", - WLAN_GPIO_EXT_POR_N, rc); - goto fail_gpio_dir_out; - } - rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, - PMAPP_CLOCK_VOTE_ON); - if (rc) { - pr_err("%s: Configuring A0 to always" - " on failed %d\n", __func__, rc); - goto clock_vote_fail; - } - } else { - gpio_set_value_cansleep(WLAN_GPIO_EXT_POR_N, 0); - rc = gpio_direction_input(WLAN_GPIO_EXT_POR_N); - if (rc) { - pr_err("WLAN reset GPIO %d set direction failed %d\n", - WLAN_GPIO_EXT_POR_N, rc); - } - gpio_free(WLAN_GPIO_EXT_POR_N); - rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, - PMAPP_CLOCK_VOTE_OFF); - if (rc) { - pr_err("%s: Configuring A0 to turn OFF" - " failed %d\n", __func__, rc); - } - } - - for (index = 0; index < ARRAY_SIZE(vreg_info); index++) { - if (on) { - - rc = regulator_set_voltage(vreg_info[index].reg, - vreg_info[index].level_min, - vreg_info[index].level_max); - if (rc) { - pr_err("%s:%s set voltage failed %d\n", - __func__, vreg_info[index].vreg_id, rc); - - goto vreg_fail; - } - - rc = regulator_enable(vreg_info[index].reg); - if (rc) { - pr_err("%s:%s vreg enable failed %d\n", - __func__, vreg_info[index].vreg_id, rc); - - goto vreg_fail; - } - - if (vreg_info[index].is_vreg_pin_controlled) { - rc = pmapp_vreg_lpm_pincntrl_vote(id, - vreg_info[index].pmapp_id, - PMAPP_CLOCK_ID_A0, 1); - if (rc) { - pr_err("%s:%s pmapp_vreg_lpm_pincntrl" - " for enable failed %d\n", - __func__, - vreg_info[index].vreg_id, rc); - goto vreg_clock_vote_fail; - } - } - - /*At this point CLK_PWR_REQ is high*/ - if (WLAN_VREG_L6 == index) { - /* - * Configure A0 clock to be slave to - * WLAN_CLK_PWR_REQ -` */ - rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, - PMAPP_CLOCK_VOTE_PIN_CTRL); - if (rc) { - pr_err("%s: Configuring A0 to Pin" - " controllable failed %d\n", - __func__, rc); - goto vreg_clock_vote_fail; - } - } - - } else { - - if (vreg_info[index].is_vreg_pin_controlled) { - rc = pmapp_vreg_lpm_pincntrl_vote(id, - vreg_info[index].pmapp_id, - PMAPP_CLOCK_ID_A0, 0); - if (rc) { - pr_err("%s:%s pmapp_vreg_lpm_pincntrl" - " for disable failed %d\n", - __func__, - vreg_info[index].vreg_id, rc); - } - } - rc = regulator_disable(vreg_info[index].reg); - if (rc) { - pr_err("%s:%s vreg disable failed %d\n", - __func__, vreg_info[index].vreg_id, rc); - } - } - } - return 0; -vreg_fail: - index--; -vreg_clock_vote_fail: - while (index >= 0) { - rc = regulator_disable(vreg_info[index].reg); - if (rc) { - pr_err("%s:%s vreg disable failed %d\n", - __func__, vreg_info[index].vreg_id, rc); - } - index--; - } - if (!on) - goto fail; -clock_vote_fail: - gpio_set_value_cansleep(WLAN_GPIO_EXT_POR_N, 0); - rc = gpio_direction_input(WLAN_GPIO_EXT_POR_N); - if (rc) { - pr_err("WLAN reset GPIO %d set direction failed %d\n", - WLAN_GPIO_EXT_POR_N, rc); - } -fail_gpio_dir_out: - gpio_free(WLAN_GPIO_EXT_POR_N); -fail: - return rc; -} -EXPORT_SYMBOL(chip_power_qrf6285); diff --git a/drivers/net/wireless/libra/qcomwlan_pwrif.c b/drivers/net/wireless/libra/qcomwlan_pwrif.c deleted file mode 100644 index 1d01d658a85bebe06ace8725ece3f03cb3019d03..0000000000000000000000000000000000000000 --- a/drivers/net/wireless/libra/qcomwlan_pwrif.c +++ /dev/null @@ -1,359 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include - -#define GPIO_WLAN_DEEP_SLEEP_N 230 -#define GPIO_WLAN_DEEP_SLEEP_N_DRAGON 82 -#define WLAN_RESET_OUT 1 -#define WLAN_RESET 0 - -static const char *id = "WLAN"; - -/** - * vos_chip_power_qrf8615() - WLAN Power Up Seq for WCN1314 rev 2.0 on QRF 8615 - * @on - Turn WLAN ON/OFF (1 or 0) - * - * Power up/down WLAN by turning on/off various regs and asserting/deasserting - * Power-on-reset pin. Also, put XO A0 buffer as slave to wlan_clk_pwr_req while - * turning ON WLAN and vice-versa. - * - * This function returns 0 on success or a non-zero value on failure. - */ -int vos_chip_power_qrf8615(int on) -{ - static char wlan_on; - static const char *vregs_qwlan_name[] = { - "8058_l20", - "8058_l8", - "8901_s4", - "8901_lvs1", - "8901_l0", - "8058_s2", - "8058_s1", - }; - static const char *vregs_qwlan_pc_name[] = { - "8058_l20_pc", - "8058_l8_pc", - NULL, - NULL, - "8901_l0_pc", - "8058_s2_pc", - NULL, - }; - static const int vregs_qwlan_val_min[] = { - 1800000, - 3050000, - 1225000, - 0, - 1200000, - 1300000, - 500000, - }; - static const int vregs_qwlan_val_max[] = { - 1800000, - 3050000, - 1225000, - 0, - 1200000, - 1300000, - 1250000, - }; - static const int vregs_qwlan_peek_current[] = { - 4000, - 150000, - 60000, - 0, - 32000, - 130000, - 0, - }; - static const bool vregs_is_pin_controlled_default[] = { - 1, - 1, - 0, - 0, - 1, - 1, - 0, - }; - static const bool vregs_is_pin_controlled_dragon[] = { - 0, - 0, - 0, - 0, - 0, - 1, - 0, - }; - bool const *vregs_is_pin_controlled; - static struct regulator *vregs_qwlan[ARRAY_SIZE(vregs_qwlan_name)]; - static struct regulator *vregs_pc_qwlan[ARRAY_SIZE(vregs_qwlan_name)]; - static struct msm_xo_voter *wlan_clock; - int ret, i, rc = 0; - unsigned wlan_gpio_deep_sleep = GPIO_WLAN_DEEP_SLEEP_N; - - vregs_is_pin_controlled = vregs_is_pin_controlled_default; - - if (machine_is_msm8x60_dragon()) { - wlan_gpio_deep_sleep = GPIO_WLAN_DEEP_SLEEP_N_DRAGON; - vregs_is_pin_controlled = vregs_is_pin_controlled_dragon; - } - /* WLAN RESET and CLK settings */ - if (on && !wlan_on) { - /* - * Program U12 GPIO expander pin IO1 to de-assert (drive 0) - * WLAN_EXT_POR_N to put WLAN in reset - */ - rc = gpio_request(wlan_gpio_deep_sleep, "WLAN_DEEP_SLEEP_N"); - if (rc) { - pr_err("WLAN reset GPIO %d request failed\n", - wlan_gpio_deep_sleep); - goto fail; - } - rc = gpio_direction_output(wlan_gpio_deep_sleep, - WLAN_RESET); - if (rc < 0) { - pr_err("WLAN reset GPIO %d set output direction failed", - wlan_gpio_deep_sleep); - goto fail_gpio_dir_out; - } - - /* Configure TCXO to be slave to WLAN_CLK_PWR_REQ */ - if (wlan_clock == NULL) { - wlan_clock = msm_xo_get(MSM_XO_TCXO_A0, id); - if (IS_ERR(wlan_clock)) { - pr_err("Failed to get TCXO_A0 voter (%ld)\n", - PTR_ERR(wlan_clock)); - goto fail_gpio_dir_out; - } - } - - rc = msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_PIN_CTRL); - if (rc < 0) { - pr_err("Configuring TCXO to Pin controllable failed" - "(%d)\n", rc); - goto fail_xo_mode_vote; - } - } else if (!on && wlan_on) { - if (wlan_clock != NULL) - msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_OFF); - gpio_set_value_cansleep(wlan_gpio_deep_sleep, WLAN_RESET); - gpio_free(wlan_gpio_deep_sleep); - } - - /* WLAN VREG settings */ - for (i = 0; i < ARRAY_SIZE(vregs_qwlan_name); i++) { - if (on && !wlan_on) { - vregs_qwlan[i] = regulator_get(NULL, - vregs_qwlan_name[i]); - if (IS_ERR(vregs_qwlan[i])) { - pr_err("regulator get of %s failed (%ld)\n", - vregs_qwlan_name[i], - PTR_ERR(vregs_qwlan[i])); - rc = PTR_ERR(vregs_qwlan[i]); - goto vreg_get_fail; - } - if (vregs_qwlan_val_min[i] || vregs_qwlan_val_max[i]) { - rc = regulator_set_voltage(vregs_qwlan[i], - vregs_qwlan_val_min[i], - vregs_qwlan_val_max[i]); - if (rc) { - pr_err("regulator_set_voltage(%s) failed\n", - vregs_qwlan_name[i]); - goto vreg_fail; - } - } - /* vote for pin control (if needed) */ - if (vregs_is_pin_controlled[i]) { - vregs_pc_qwlan[i] = regulator_get(NULL, - vregs_qwlan_pc_name[i]); - if (IS_ERR(vregs_pc_qwlan[i])) { - pr_err("regulator get of %s failed " - "(%ld)\n", - vregs_qwlan_pc_name[i], - PTR_ERR(vregs_pc_qwlan[i])); - rc = PTR_ERR(vregs_pc_qwlan[i]); - goto vreg_fail; - } - } - - if (vregs_qwlan_peek_current[i]) { - rc = regulator_set_optimum_mode(vregs_qwlan[i], - vregs_qwlan_peek_current[i]); - if (rc < 0) - pr_err("vreg %s set optimum mode" - " failed to %d (%d)\n", - vregs_qwlan_name[i], rc, - vregs_qwlan_peek_current[i]); - } - rc = regulator_enable(vregs_qwlan[i]); - if (rc < 0) { - pr_err("vreg %s enable failed (%d)\n", - vregs_qwlan_name[i], rc); - goto vreg_fail; - } - if (vregs_is_pin_controlled[i]) { - rc = regulator_enable(vregs_pc_qwlan[i]); - if (rc < 0) { - pr_err("vreg %s enable failed (%d)\n", - vregs_qwlan_pc_name[i], rc); - goto vreg_fail; - } - } - } else if (!on && wlan_on) { - - if (vregs_qwlan_peek_current[i]) { - /* For legacy reasons we pass 1mA current to - * put regulator in LPM mode. - */ - rc = regulator_set_optimum_mode(vregs_qwlan[i], - 1000); - if (rc < 0) - pr_info("vreg %s set optimum mode" - "failed (%d)\n", - vregs_qwlan_name[i], rc); - rc = regulator_set_voltage(vregs_qwlan[i], 0 , - vregs_qwlan_val_max[i]); - if (rc) - pr_err("regulator_set_voltage(%s)" - "failed (%d)\n", - vregs_qwlan_name[i], rc); - - } - - if (vregs_is_pin_controlled[i]) { - rc = regulator_disable(vregs_pc_qwlan[i]); - if (rc < 0) { - pr_err("vreg %s disable failed (%d)\n", - vregs_qwlan_pc_name[i], rc); - goto vreg_fail; - } - regulator_put(vregs_pc_qwlan[i]); - } - - rc = regulator_disable(vregs_qwlan[i]); - if (rc < 0) { - pr_err("vreg %s disable failed (%d)\n", - vregs_qwlan_name[i], rc); - goto vreg_fail; - } - regulator_put(vregs_qwlan[i]); - } - } - if (on) { - gpio_set_value_cansleep(wlan_gpio_deep_sleep, WLAN_RESET_OUT); - wlan_on = true; - } - else - wlan_on = false; - return 0; - -vreg_fail: - regulator_put(vregs_qwlan[i]); - if (vregs_is_pin_controlled[i]) - regulator_put(vregs_pc_qwlan[i]); -vreg_get_fail: - i--; - while (i >= 0) { - ret = !on ? regulator_enable(vregs_qwlan[i]) : - regulator_disable(vregs_qwlan[i]); - if (ret < 0) { - pr_err("vreg %s %s failed (%d) in err path\n", - vregs_qwlan_name[i], - !on ? "enable" : "disable", ret); - } - if (vregs_is_pin_controlled[i]) { - ret = !on ? regulator_enable(vregs_pc_qwlan[i]) : - regulator_disable(vregs_pc_qwlan[i]); - if (ret < 0) { - pr_err("vreg %s %s failed (%d) in err path\n", - vregs_qwlan_pc_name[i], - !on ? "enable" : "disable", ret); - } - } - regulator_put(vregs_qwlan[i]); - if (vregs_is_pin_controlled[i]) - regulator_put(vregs_pc_qwlan[i]); - i--; - } - if (!on) - goto fail; -fail_xo_mode_vote: - msm_xo_put(wlan_clock); -fail_gpio_dir_out: - gpio_free(wlan_gpio_deep_sleep); -fail: - return rc; -} -EXPORT_SYMBOL(vos_chip_power_qrf8615); - -/** - * qcomwlan_pmic_xo_core_force_enable() - Force XO Core of PMIC to be ALWAYS ON - * @on - Force XO Core ON/OFF (1 or 0) - * - * The XO_CORE controls the XO feeding the TCXO buffers (A0, A1, etc.). WLAN - * wants to keep the XO core on even though our buffer A0 is in pin control - * because it can take a long time turn the XO back on and warm up the buffers. - * This helps in optimizing power in BMPS (power save) mode of WLAN. - * The WLAN driver wrapper function takes care that this API is not called - * consecutively. - * - * This function returns 0 on success or a non-zero value on failure. - */ -int qcomwlan_pmic_xo_core_force_enable(int on) -{ - static struct msm_xo_voter *wlan_ps; - int rc = 0; - - if (wlan_ps == NULL) { - wlan_ps = msm_xo_get(MSM_XO_CORE, id); - if (IS_ERR(wlan_ps)) { - pr_err("Failed to get XO CORE voter (%ld)\n", - PTR_ERR(wlan_ps)); - goto fail; - } - } - - if (on) - rc = msm_xo_mode_vote(wlan_ps, MSM_XO_MODE_ON); - else - rc = msm_xo_mode_vote(wlan_ps, MSM_XO_MODE_OFF); - - if (rc < 0) { - pr_err("XO Core %s failed (%d)\n", - on ? "enable" : "disable", rc); - goto fail_xo_mode_vote; - } - return 0; -fail_xo_mode_vote: - msm_xo_put(wlan_ps); -fail: - return rc; -} -EXPORT_SYMBOL(qcomwlan_pmic_xo_core_force_enable); - - -/** - * qcomwlan_freq_change_1p3v_supply() - function to change the freq for 1.3V RF supply. - * @freq - freq of the 1.3V Supply - * - * This function returns 0 on success or a non-zero value on failure. - */ - -int qcomwlan_freq_change_1p3v_supply(enum rpm_vreg_freq freq) -{ - return rpm_vreg_set_frequency(RPM_VREG_ID_PM8058_S2, freq); -} -EXPORT_SYMBOL(qcomwlan_freq_change_1p3v_supply); diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 0be1df0a08abc94861e9ccd74add5e04c1ece985..463f86e0aa01685ecc168e83ca5fd5abb16acc7e 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -344,12 +344,6 @@ config CHARGER_BQ2415X You'll need this driver to charge batteries on e.g. Nokia RX-51/N900. -config BATTERY_MSM - tristate "MSM battery" - depends on ARCH_MSM && MSM_ONCRPCROUTER - help - Say Y to enable support for the battery in Qualcomm MSM. - config BATTERY_MSM_FAKE tristate "Fake MSM battery" depends on ARCH_MSM && BATTERY_MSM @@ -357,45 +351,6 @@ config BATTERY_MSM_FAKE help Say Y to bypass actual battery queries. -config BATTERY_MSM8X60 - tristate "MSM8X60 battery" - select PMIC8XXX_BATTALARM - help - Some MSM boards have dual charging paths to charge the battery. - Say Y to enable support for the battery charging in - such devices. - -config PM8058_CHARGER - tristate "pmic8058 charger" - depends on BATTERY_MSM8X60 - depends on PMIC8058 - help - Say Y to enable support for battery charging from the pmic8058. - pmic8058 provides a linear charging circuit connected to the usb - cable on Qualcomm's msm8x60 surf board. - -config ISL9519_CHARGER - tristate "isl9519 charger" - depends on (BATTERY_MSM8X60 || PM8921_CHARGER) - depends on I2C - default n - help - The isl9519q charger chip from intersil is connected to an external - charger cable and is preferred way of charging the battery because - of its high current rating. - Choose Y if you are compiling for Qualcomm's msm8x60 surf/ffa board. - -config SMB137B_CHARGER - tristate "smb137b charger" - default n - depends on I2C - help - The smb137b charger chip from summit is a switching mode based - charging solution. - Choose Y if you are compiling for Qualcomm's msm8x60 fluid board. - To compile this driver as a module, choose M here: the module will - be called smb137b. - config SMB137C_CHARGER tristate "Summit SMB137C Battery Charger" depends on I2C @@ -406,16 +361,6 @@ config SMB137C_CHARGER charging, setting the input current limit, and enabling USB OTG mode in order to supply 5 V on the VBUS line. -config SMB349_CHARGER - tristate "smb349 charger" - depends on I2C - help - Say Y to enable support for the SMB349 switching mode based charger - and sysfs. The driver supports controlling charger-enable and - current limiting capabilities. The driver also lets the - SMB349 be operated as a slave device via the power supply - framework. - config SMB349_USB_CHARGER tristate "smb349 usb charger (with VBUS detection)" depends on I2C @@ -449,30 +394,6 @@ config SMB135X_CHARGER The driver reports the charger status via the power supply framework. A charger status change triggers an IRQ via the device STAT pin. -config PM8058_FIX_USB - tristate "pmic8058 software workaround for usb removal" - depends on PMIC8058 - depends on !PM8058_CHARGER - help - Say Y to enable the software workaround to USB Vbus line - staying high even when USB cable is removed. This option - is in lieu of a complete pm8058 charging driver. - -config BATTERY_QCIBAT - tristate "Quanta Computer Inc. Battery" - depends on SENSORS_WPCE775X - default n - help - Say Y here if you want to use the Quanta battery driver for ST15 - platform. - -config BATTERY_BQ27520 - tristate "BQ27520 battery driver" - depends on I2C - default n - help - Say Y here to enable support for batteries with BQ27520 (I2C) chips. - config BQ27520_TEST_ENABLE bool "Enable BQ27520 Fuel Gauge Chip Test" depends on BATTERY_BQ27520 @@ -480,13 +401,6 @@ config BQ27520_TEST_ENABLE help Say Y here to enable Test sysfs Interface for BQ27520 Drivers. -config BATTERY_BQ27541 - tristate "BQ27541 battery driver" - depends on I2C - default n - help - Say Y here to enable support for batteries with BQ27541 (I2C) chips. - config BATTERY_BQ28400 tristate "BQ28400 battery driver" depends on I2C @@ -499,12 +413,6 @@ config BATTERY_BQ28400 The device monitors the battery level (Relative-State-Of-Charge). The device is SBS compliant, providing battery info over I2C. -config PM8921_CHARGER - tristate "PM8921 Charger driver" - depends on MFD_PM8921_CORE - help - Say Y here to enable support for pm8921 chip charger subdevice - config QPNP_CHARGER tristate "QPNP Charger driver" depends on SPMI @@ -516,21 +424,7 @@ config QPNP_CHARGER also offers relevant information to userspace via the power supply framework. -config PM8XXX_CCADC - tristate "PM8XXX battery current adc driver" - depends on MFD_PM8921_CORE - help - Say Y here to enable support for pm8921 chip bms subdevice - -config LTC4088_CHARGER - tristate "LTC4088 Charger driver" - depends on GPIOLIB - help - Say Y here to enable support for ltc4088 chip charger. It controls the - operations through GPIO pins. - config PM8921_BMS - select PM8XXX_CCADC tristate "PM8921 Battery Monitoring System driver" depends on MFD_PM8921_CORE help diff --git a/drivers/power/Makefile b/drivers/power/Makefile index 9624a1095245cae2dea1db081badd665800a78c6..46e838635874b324cddd4d9c430d9a1bc4ebdc70 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -52,27 +52,13 @@ obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_POWER_AVS) += avs/ -obj-$(CONFIG_BATTERY_MSM) += msm_battery.o -obj-$(CONFIG_BATTERY_MSM8X60) += msm_charger.o -obj-$(CONFIG_PM8058_CHARGER) += pmic8058-charger.o -obj-$(CONFIG_ISL9519_CHARGER) += isl9519q.o -obj-$(CONFIG_SMB349_CHARGER) += smb349.o obj-$(CONFIG_SMB349_USB_CHARGER) += smb349-charger.o obj-$(CONFIG_SMB350_CHARGER) += smb350_charger.o obj-$(CONFIG_SMB135X_CHARGER) += smb135x-charger.o -obj-$(CONFIG_PM8058_FIX_USB) += pm8058_usb_fix.o -obj-$(CONFIG_BATTERY_QCIBAT) += qci_battery.o -obj-$(CONFIG_BATTERY_BQ27520) += bq27520_fuelgauger.o -obj-$(CONFIG_BATTERY_BQ27541) += bq27541_fuelgauger.o obj-$(CONFIG_BATTERY_BQ28400) += bq28400_battery.o -obj-$(CONFIG_SMB137B_CHARGER) += smb137b.o obj-$(CONFIG_SMB137C_CHARGER) += smb137c-charger.o -obj-$(CONFIG_PM8XXX_CCADC) += pm8xxx-ccadc.o -obj-$(CONFIG_PM8921_BMS) += pm8921-bms.o obj-$(CONFIG_QPNP_BMS) += qpnp-bms.o -obj-$(CONFIG_PM8921_CHARGER) += pm8921-charger.o obj-$(CONFIG_QPNP_CHARGER) += qpnp-charger.o -obj-$(CONFIG_LTC4088_CHARGER) += ltc4088-charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_BATTERY_BCL) += battery_current_limit.o diff --git a/drivers/power/bq27520_fuelgauger.c b/drivers/power/bq27520_fuelgauger.c deleted file mode 100644 index c5e87c5f9b313e5dd48f0feccab84e0775433192..0000000000000000000000000000000000000000 --- a/drivers/power/bq27520_fuelgauger.c +++ /dev/null @@ -1,960 +0,0 @@ -/* Copyright (C) 2008 Rodolfo Giometti - * Copyright (C) 2008 Eurotech S.p.A. - * Based on a previous work by Copyright (C) 2008 Texas Instruments, Inc. - * - * Copyright (c) 2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_VERSION "1.1.0" -/* Bq27520 standard data commands */ -#define BQ27520_REG_CNTL 0x00 -#define BQ27520_REG_AR 0x02 -#define BQ27520_REG_ARTTE 0x04 -#define BQ27520_REG_TEMP 0x06 -#define BQ27520_REG_VOLT 0x08 -#define BQ27520_REG_FLAGS 0x0A -#define BQ27520_REG_NAC 0x0C -#define BQ27520_REG_FAC 0x0e -#define BQ27520_REG_RM 0x10 -#define BQ27520_REG_FCC 0x12 -#define BQ27520_REG_AI 0x14 -#define BQ27520_REG_TTE 0x16 -#define BQ27520_REG_TTF 0x18 -#define BQ27520_REG_SI 0x1a -#define BQ27520_REG_STTE 0x1c -#define BQ27520_REG_MLI 0x1e -#define BQ27520_REG_MLTTE 0x20 -#define BQ27520_REG_AE 0x22 -#define BQ27520_REG_AP 0x24 -#define BQ27520_REG_TTECP 0x26 -#define BQ27520_REG_SOH 0x28 -#define BQ27520_REG_SOC 0x2c -#define BQ27520_REG_NIC 0x2e -#define BQ27520_REG_ICR 0x30 -#define BQ27520_REG_LOGIDX 0x32 -#define BQ27520_REG_LOGBUF 0x34 -#define BQ27520_FLAG_DSC BIT(0) -#define BQ27520_FLAG_FC BIT(9) -#define BQ27520_FLAG_BAT_DET BIT(3) -#define BQ27520_CS_DLOGEN BIT(15) -#define BQ27520_CS_SS BIT(13) -/* Control subcommands */ -#define BQ27520_SUBCMD_CTNL_STATUS 0x0000 -#define BQ27520_SUBCMD_DEVCIE_TYPE 0x0001 -#define BQ27520_SUBCMD_FW_VER 0x0002 -#define BQ27520_SUBCMD_HW_VER 0x0003 -#define BQ27520_SUBCMD_DF_CSUM 0x0004 -#define BQ27520_SUBCMD_PREV_MACW 0x0007 -#define BQ27520_SUBCMD_CHEM_ID 0x0008 -#define BQ27520_SUBCMD_BD_OFFSET 0x0009 -#define BQ27520_SUBCMD_INT_OFFSET 0x000a -#define BQ27520_SUBCMD_CC_VER 0x000b -#define BQ27520_SUBCMD_OCV 0x000c -#define BQ27520_SUBCMD_BAT_INS 0x000d -#define BQ27520_SUBCMD_BAT_REM 0x000e -#define BQ27520_SUBCMD_SET_HIB 0x0011 -#define BQ27520_SUBCMD_CLR_HIB 0x0012 -#define BQ27520_SUBCMD_SET_SLP 0x0013 -#define BQ27520_SUBCMD_CLR_SLP 0x0014 -#define BQ27520_SUBCMD_FCT_RES 0x0015 -#define BQ27520_SUBCMD_ENABLE_DLOG 0x0018 -#define BQ27520_SUBCMD_DISABLE_DLOG 0x0019 -#define BQ27520_SUBCMD_SEALED 0x0020 -#define BQ27520_SUBCMD_ENABLE_IT 0x0021 -#define BQ27520_SUBCMD_DISABLE_IT 0x0023 -#define BQ27520_SUBCMD_CAL_MODE 0x0040 -#define BQ27520_SUBCMD_RESET 0x0041 - -#define ZERO_DEGREE_CELSIUS_IN_TENTH_KELVIN (-2731) -#define BQ27520_INIT_DELAY ((HZ)*1) -#define BQ27520_POLLING_STATUS ((HZ)*3) -#define BQ27520_COULOMB_POLL ((HZ)*30) - -/* If the system has several batteries we need a different name for each - * of them... - */ -static DEFINE_IDR(battery_id); -static DEFINE_MUTEX(battery_mutex); - -struct bq27520_device_info; -struct bq27520_access_methods { - int (*read)(u8 reg, int *rt_value, int b_single, - struct bq27520_device_info *di); -}; - -struct bq27520_device_info { - struct device *dev; - int id; - struct bq27520_access_methods *bus; - struct i2c_client *client; - const struct bq27520_platform_data *pdata; - struct work_struct counter; - /* 300ms delay is needed after bq27520 is powered up - * and before any successful I2C transaction - */ - struct delayed_work hw_config; - uint32_t irq; -}; - -enum { - GET_BATTERY_STATUS, - GET_BATTERY_TEMPERATURE, - GET_BATTERY_VOLTAGE, - GET_BATTERY_CAPACITY, - NUM_OF_STATUS, -}; - -struct bq27520_status { - /* Informations owned and maintained by Bq27520 driver, updated - * by poller or SOC_INT interrupt, decoupling from I/Oing - * hardware directly - */ - int status[NUM_OF_STATUS]; - spinlock_t lock; - struct delayed_work poller; -}; - -static struct bq27520_status current_battery_status; -static struct bq27520_device_info *bq27520_di; -static int coulomb_counter; -static spinlock_t lock; /* protect access to coulomb_counter */ -static struct timer_list timer; /* charge counter timer every 30 secs */ - -static int bq27520_i2c_txsubcmd(u8 reg, unsigned short subcmd, - struct bq27520_device_info *di); - -static int bq27520_read(u8 reg, int *rt_value, int b_single, - struct bq27520_device_info *di) -{ - return di->bus->read(reg, rt_value, b_single, di); -} - -/* - * Return the battery temperature in tenths of degree Celsius - * Or < 0 if something fails. - */ -static int bq27520_battery_temperature(struct bq27520_device_info *di) -{ - int ret, temp = 0; - - ret = bq27520_read(BQ27520_REG_TEMP, &temp, 0, di); - if (ret) { - dev_err(di->dev, "error %d reading temperature\n", ret); - return ret; - } - - return temp + ZERO_DEGREE_CELSIUS_IN_TENTH_KELVIN; -} - -/* - * Return the battery Voltage in milivolts - * Or < 0 if something fails. - */ -static int bq27520_battery_voltage(struct bq27520_device_info *di) -{ - int ret, volt = 0; - - ret = bq27520_read(BQ27520_REG_VOLT, &volt, 0, di); - if (ret) { - dev_err(di->dev, "error %d reading voltage\n", ret); - return ret; - } - - return volt; -} - -/* - * Return the battery Relative State-of-Charge - * Or < 0 if something fails. - */ -static int bq27520_battery_rsoc(struct bq27520_device_info *di) -{ - int ret, rsoc = 0; - - ret = bq27520_read(BQ27520_REG_SOC, &rsoc, 0, di); - - if (ret) { - dev_err(di->dev, - "error %d reading relative State-of-Charge\n", ret); - return ret; - } - - return rsoc; -} - -static void bq27520_cntl_cmd(struct bq27520_device_info *di, - int subcmd) -{ - bq27520_i2c_txsubcmd(BQ27520_REG_CNTL, subcmd, di); -} - -/* - * i2c specific code - */ -static int bq27520_i2c_txsubcmd(u8 reg, unsigned short subcmd, - struct bq27520_device_info *di) -{ - struct i2c_msg msg; - unsigned char data[3]; - - if (!di->client) - return -ENODEV; - - memset(data, 0, sizeof(data)); - data[0] = reg; - data[1] = subcmd & 0x00FF; - data[2] = (subcmd & 0xFF00) >> 8; - - msg.addr = di->client->addr; - msg.flags = 0; - msg.len = 3; - msg.buf = data; - - if (i2c_transfer(di->client->adapter, &msg, 1) < 0) - return -EIO; - - return 0; -} - -static int bq27520_chip_config(struct bq27520_device_info *di) -{ - int flags = 0, ret = 0; - - bq27520_cntl_cmd(di, BQ27520_SUBCMD_CTNL_STATUS); - udelay(66); - ret = bq27520_read(BQ27520_REG_CNTL, &flags, 0, di); - if (ret < 0) { - dev_err(di->dev, "error %d reading register %02x\n", - ret, BQ27520_REG_CNTL); - return ret; - } - udelay(66); - - bq27520_cntl_cmd(di, BQ27520_SUBCMD_ENABLE_IT); - udelay(66); - - if (di->pdata->enable_dlog && !(flags & BQ27520_CS_DLOGEN)) { - bq27520_cntl_cmd(di, BQ27520_SUBCMD_ENABLE_DLOG); - udelay(66); - } - - return 0; -} - -static void bq27520_every_30secs(unsigned long data) -{ - struct bq27520_device_info *di = (struct bq27520_device_info *)data; - - schedule_work(&di->counter); - mod_timer(&timer, jiffies + BQ27520_COULOMB_POLL); -} - -static void bq27520_coulomb_counter_work(struct work_struct *work) -{ - int value = 0, temp = 0, index = 0, ret = 0, count = 0; - struct bq27520_device_info *di; - unsigned long flags; - - di = container_of(work, struct bq27520_device_info, counter); - - /* retrieve 30 values from FIFO of coulomb data logging buffer - * and average over time - */ - do { - ret = bq27520_read(BQ27520_REG_LOGBUF, &temp, 0, di); - if (ret < 0) - break; - if (temp != 0x7FFF) { - ++count; - value += temp; - } - udelay(66); - ret = bq27520_read(BQ27520_REG_LOGIDX, &index, 0, di); - if (ret < 0) - break; - udelay(66); - } while (index != 0 || temp != 0x7FFF); - - if (ret < 0) { - dev_err(di->dev, "Error %d reading datalog register\n", ret); - return; - } - - if (count) { - spin_lock_irqsave(&lock, flags); - coulomb_counter = value/count; - spin_unlock_irqrestore(&lock, flags); - } -} - -static int bq27520_is_battery_present(void) -{ - return 1; -} - -static int bq27520_is_battery_temp_within_range(void) -{ - return 1; -} - -static int bq27520_is_battery_id_valid(void) -{ - return 1; -} - -static int bq27520_status_getter(int function) -{ - int status = 0; - unsigned long flags; - - spin_lock_irqsave(¤t_battery_status.lock, flags); - status = current_battery_status.status[function]; - spin_unlock_irqrestore(¤t_battery_status.lock, flags); - - return status; -} - -static int bq27520_get_battery_mvolts(void) -{ - return bq27520_status_getter(GET_BATTERY_VOLTAGE); -} - -static int bq27520_get_battery_temperature(void) -{ - return bq27520_status_getter(GET_BATTERY_TEMPERATURE); -} - -static int bq27520_get_battery_status(void) -{ - return bq27520_status_getter(GET_BATTERY_STATUS); -} - -static int bq27520_get_remaining_capacity(void) -{ - return bq27520_status_getter(GET_BATTERY_CAPACITY); -} - -static struct msm_battery_gauge bq27520_batt_gauge = { - .get_battery_mvolts = bq27520_get_battery_mvolts, - .get_battery_temperature = bq27520_get_battery_temperature, - .is_battery_present = bq27520_is_battery_present, - .is_battery_temp_within_range = bq27520_is_battery_temp_within_range, - .is_battery_id_valid = bq27520_is_battery_id_valid, - .get_battery_status = bq27520_get_battery_status, - .get_batt_remaining_capacity = bq27520_get_remaining_capacity, -}; - -static void update_current_battery_status(int data) -{ - int status[4], ret = 0; - unsigned long flag; - - memset(status, 0, sizeof status); - ret = bq27520_battery_rsoc(bq27520_di); - status[GET_BATTERY_CAPACITY] = (ret < 0) ? 0 : ret; - - status[GET_BATTERY_VOLTAGE] = bq27520_battery_voltage(bq27520_di); - status[GET_BATTERY_TEMPERATURE] = - bq27520_battery_temperature(bq27520_di); - - spin_lock_irqsave(¤t_battery_status.lock, flag); - current_battery_status.status[GET_BATTERY_STATUS] = data; - current_battery_status.status[GET_BATTERY_VOLTAGE] = - status[GET_BATTERY_VOLTAGE]; - current_battery_status.status[GET_BATTERY_TEMPERATURE] = - status[GET_BATTERY_TEMPERATURE]; - current_battery_status.status[GET_BATTERY_CAPACITY] = - status[GET_BATTERY_CAPACITY]; - spin_unlock_irqrestore(¤t_battery_status.lock, flag); -} - -/* only if battery charging satus changes then notify msm_charger. otherwise - * only refresh current_batter_status - */ -static int if_notify_msm_charger(int *data) -{ - int ret = 0, flags = 0, status = 0; - unsigned long flag; - - ret = bq27520_read(BQ27520_REG_FLAGS, &flags, 0, bq27520_di); - if (ret < 0) { - dev_err(bq27520_di->dev, "error %d reading register %02x\n", - ret, BQ27520_REG_FLAGS); - status = POWER_SUPPLY_STATUS_UNKNOWN; - } else { - if (flags & BQ27520_FLAG_FC) - status = POWER_SUPPLY_STATUS_FULL; - else if (flags & BQ27520_FLAG_DSC) - status = POWER_SUPPLY_STATUS_DISCHARGING; - else - status = POWER_SUPPLY_STATUS_CHARGING; - } - - *data = status; - spin_lock_irqsave(¤t_battery_status.lock, flag); - ret = (status != current_battery_status.status[GET_BATTERY_STATUS]); - spin_unlock_irqrestore(¤t_battery_status.lock, flag); - return ret; -} - -static void battery_status_poller(struct work_struct *work) -{ - int status = 0, temp = 0; - - temp = if_notify_msm_charger(&status); - update_current_battery_status(status); - if (temp) - msm_charger_notify_event(NULL, CHG_BATT_STATUS_CHANGE); - - schedule_delayed_work(¤t_battery_status.poller, - BQ27520_POLLING_STATUS); -} - -static void bq27520_hw_config(struct work_struct *work) -{ - int ret = 0, flags = 0, type = 0, fw_ver = 0, status = 0; - struct bq27520_device_info *di; - - di = container_of(work, struct bq27520_device_info, hw_config.work); - - pr_debug(KERN_INFO "Enter bq27520_hw_config\n"); - ret = bq27520_chip_config(di); - if (ret) { - dev_err(di->dev, "Failed to config Bq27520 ret = %d\n", ret); - return; - } - /* bq27520 is ready for access, update current_battery_status by reading - * from hardware - */ - if_notify_msm_charger(&status); - update_current_battery_status(status); - msm_battery_gauge_register(&bq27520_batt_gauge); - msm_charger_notify_event(NULL, CHG_BATT_STATUS_CHANGE); - - enable_irq(di->irq); - - /* poll battery status every 3 seconds, if charging status changes, - * notify msm_charger - */ - schedule_delayed_work(¤t_battery_status.poller, - BQ27520_POLLING_STATUS); - - if (di->pdata->enable_dlog) { - schedule_work(&di->counter); - init_timer(&timer); - timer.function = &bq27520_every_30secs; - timer.data = (unsigned long)di; - timer.expires = jiffies + BQ27520_COULOMB_POLL; - add_timer(&timer); - } - - bq27520_cntl_cmd(di, BQ27520_SUBCMD_CTNL_STATUS); - udelay(66); - bq27520_read(BQ27520_REG_CNTL, &flags, 0, di); - bq27520_cntl_cmd(di, BQ27520_SUBCMD_DEVCIE_TYPE); - udelay(66); - bq27520_read(BQ27520_REG_CNTL, &type, 0, di); - bq27520_cntl_cmd(di, BQ27520_SUBCMD_FW_VER); - udelay(66); - bq27520_read(BQ27520_REG_CNTL, &fw_ver, 0, di); - - dev_info(di->dev, "DEVICE_TYPE is 0x%02X, FIRMWARE_VERSION\ - is 0x%02X\n", type, fw_ver); - dev_info(di->dev, "Complete bq27520 configuration 0x%02X\n", flags); -} - -static int bq27520_read_i2c(u8 reg, int *rt_value, int b_single, - struct bq27520_device_info *di) -{ - struct i2c_client *client = di->client; - struct i2c_msg msg[1]; - unsigned char data[2]; - int err; - - if (!client->adapter) - return -ENODEV; - - msg->addr = client->addr; - msg->flags = 0; - msg->len = 1; - msg->buf = data; - - data[0] = reg; - err = i2c_transfer(client->adapter, msg, 1); - - if (err >= 0) { - if (!b_single) - msg->len = 2; - else - msg->len = 1; - - msg->flags = I2C_M_RD; - err = i2c_transfer(client->adapter, msg, 1); - if (err >= 0) { - if (!b_single) - *rt_value = get_unaligned_le16(data); - else - *rt_value = data[0]; - - return 0; - } - } - return err; -} - -#ifdef CONFIG_BQ27520_TEST_ENABLE -static int reg; -static int subcmd; -static ssize_t bq27520_read_stdcmd(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int ret; - int temp = 0; - struct platform_device *client; - struct bq27520_device_info *di; - - client = to_platform_device(dev); - di = platform_get_drvdata(client); - - if (reg <= BQ27520_REG_ICR && reg > 0x00) { - ret = bq27520_read(reg, &temp, 0, di); - if (ret) - ret = snprintf(buf, PAGE_SIZE, "Read Error!\n"); - else - ret = snprintf(buf, PAGE_SIZE, "0x%02x\n", temp); - } else - ret = snprintf(buf, PAGE_SIZE, "Register Error!\n"); - - return ret; -} - -static ssize_t bq27520_write_stdcmd(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int cmd; - - sscanf(buf, "%x", &cmd); - reg = cmd; - dev_info(dev, "recv'd cmd is 0x%02X\n", reg); - return ret; -} - -static ssize_t bq27520_read_subcmd(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int ret, temp = 0; - struct platform_device *client; - struct bq27520_device_info *di; - - client = to_platform_device(dev); - di = platform_get_drvdata(client); - - if (subcmd == BQ27520_SUBCMD_DEVCIE_TYPE || - subcmd == BQ27520_SUBCMD_FW_VER || - subcmd == BQ27520_SUBCMD_HW_VER || - subcmd == BQ27520_SUBCMD_CHEM_ID) { - - bq27520_cntl_cmd(di, subcmd);/* Retrieve Chip status */ - udelay(66); - ret = bq27520_read(BQ27520_REG_CNTL, &temp, 0, di); - - if (ret) - ret = snprintf(buf, PAGE_SIZE, "Read Error!\n"); - else - ret = snprintf(buf, PAGE_SIZE, "0x%02x\n", temp); - } else - ret = snprintf(buf, PAGE_SIZE, "Register Error!\n"); - - return ret; -} - -static ssize_t bq27520_write_subcmd(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int cmd; - - sscanf(buf, "%x", &cmd); - subcmd = cmd; - return ret; -} - -static DEVICE_ATTR(std_cmd, S_IRUGO|S_IWUGO, bq27520_read_stdcmd, - bq27520_write_stdcmd); -static DEVICE_ATTR(sub_cmd, S_IRUGO|S_IWUGO, bq27520_read_subcmd, - bq27520_write_subcmd); -static struct attribute *fs_attrs[] = { - &dev_attr_std_cmd.attr, - &dev_attr_sub_cmd.attr, - NULL, -}; -static struct attribute_group fs_attr_group = { - .attrs = fs_attrs, -}; - -static struct platform_device this_device = { - .name = "bq27520-test", - .id = -1, - .dev.platform_data = NULL, -}; -#endif - -static irqreturn_t soc_irqhandler(int irq, void *dev_id) -{ - int status = 0, temp = 0; - - temp = if_notify_msm_charger(&status); - update_current_battery_status(status); - if (temp) - msm_charger_notify_event(NULL, CHG_BATT_STATUS_CHANGE); - return IRQ_HANDLED; -} - -static struct regulator *vreg_bq27520; -static int bq27520_power(bool enable, struct bq27520_device_info *di) -{ - int rc = 0, ret; - const struct bq27520_platform_data *platdata; - - platdata = di->pdata; - if (enable) { - /* switch on Vreg_S3 */ - rc = regulator_enable(vreg_bq27520); - if (rc < 0) { - dev_err(di->dev, "%s: vreg %s %s failed (%d)\n", - __func__, platdata->vreg_name, "enable", rc); - goto vreg_fail; - } - - /* Battery gauge enable and switch on onchip 2.5V LDO */ - rc = gpio_request(platdata->chip_en, "GAUGE_EN"); - if (rc) { - dev_err(di->dev, "%s: fail to request gpio %d (%d)\n", - __func__, platdata->chip_en, rc); - goto vreg_fail; - } - - gpio_direction_output(platdata->chip_en, 0); - gpio_set_value(platdata->chip_en, 1); - rc = gpio_request(platdata->soc_int, "GAUGE_SOC_INT"); - if (rc) { - dev_err(di->dev, "%s: fail to request gpio %d (%d)\n", - __func__, platdata->soc_int, rc); - goto gpio_fail; - } - gpio_direction_input(platdata->soc_int); - di->irq = gpio_to_irq(platdata->soc_int); - rc = request_threaded_irq(di->irq, NULL, soc_irqhandler, - IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, - "BQ27520_IRQ", di); - if (rc) { - dev_err(di->dev, "%s: fail to request irq %d (%d)\n", - __func__, platdata->soc_int, rc); - goto irqreq_fail; - } else { - disable_irq_nosync(di->irq); - } - } else { - free_irq(di->irq, di); - gpio_free(platdata->soc_int); - /* switch off on-chip 2.5V LDO and disable Battery gauge */ - gpio_set_value(platdata->chip_en, 0); - gpio_free(platdata->chip_en); - /* switch off Vreg_S3 */ - rc = regulator_disable(vreg_bq27520); - if (rc < 0) { - dev_err(di->dev, "%s: vreg %s %s failed (%d)\n", - __func__, platdata->vreg_name, "disable", rc); - goto vreg_fail; - } - } - return rc; - -irqreq_fail: - gpio_free(platdata->soc_int); -gpio_fail: - gpio_set_value(platdata->chip_en, 0); - gpio_free(platdata->chip_en); -vreg_fail: - ret = !enable ? regulator_enable(vreg_bq27520) : - regulator_disable(vreg_bq27520); - if (ret < 0) { - dev_err(di->dev, "%s: vreg %s %s failed (%d) in err path\n", - __func__, platdata->vreg_name, - !enable ? "enable" : "disable", ret); - } - return rc; -} - -static int bq27520_dev_setup(bool enable, struct bq27520_device_info *di) -{ - int rc; - const struct bq27520_platform_data *platdata; - - platdata = di->pdata; - if (enable) { - /* enable and set voltage Vreg_S3 */ - vreg_bq27520 = regulator_get(NULL, - platdata->vreg_name); - if (IS_ERR(vreg_bq27520)) { - dev_err(di->dev, "%s: regulator get of %s\ - failed (%ld)\n", __func__, platdata->vreg_name, - PTR_ERR(vreg_bq27520)); - rc = PTR_ERR(vreg_bq27520); - goto vreg_get_fail; - } - rc = regulator_set_voltage(vreg_bq27520, - platdata->vreg_value, platdata->vreg_value); - if (rc) { - dev_err(di->dev, "%s: regulator_set_voltage(%s) failed\ - (%d)\n", __func__, platdata->vreg_name, rc); - goto vreg_get_fail; - } - } else { - regulator_put(vreg_bq27520); - } - return 0; - -vreg_get_fail: - regulator_put(vreg_bq27520); - return rc; -} - -static int bq27520_battery_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct bq27520_device_info *di; - struct bq27520_access_methods *bus; - const struct bq27520_platform_data *pdata; - int num, retval = 0; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) - return -ENODEV; - - pdata = client->dev.platform_data; - - /* Get new ID for the new battery device */ - retval = idr_pre_get(&battery_id, GFP_KERNEL); - if (retval == 0) - return -ENOMEM; - mutex_lock(&battery_mutex); - retval = idr_get_new(&battery_id, client, &num); - mutex_unlock(&battery_mutex); - if (retval < 0) - return retval; - - di = kzalloc(sizeof(*di), GFP_KERNEL); - if (!di) { - dev_err(&client->dev, "failed to allocate device info data\n"); - retval = -ENOMEM; - goto batt_failed_1; - } - di->id = num; - di->pdata = pdata; - - bus = kzalloc(sizeof(*bus), GFP_KERNEL); - if (!bus) { - dev_err(&client->dev, "failed to allocate data\n"); - retval = -ENOMEM; - goto batt_failed_2; - } - - i2c_set_clientdata(client, di); - di->dev = &client->dev; - bus->read = &bq27520_read_i2c; - di->bus = bus; - di->client = client; - -#ifdef CONFIG_BQ27520_TEST_ENABLE - platform_set_drvdata(&this_device, di); - retval = platform_device_register(&this_device); - if (!retval) { - retval = sysfs_create_group(&this_device.dev.kobj, - &fs_attr_group); - if (retval) - goto batt_failed_3; - } else - goto batt_failed_3; -#endif - - retval = bq27520_dev_setup(true, di); - if (retval) { - dev_err(&client->dev, "failed to setup ret = %d\n", retval); - goto batt_failed_3; - } - - retval = bq27520_power(true, di); - if (retval) { - dev_err(&client->dev, "failed to powerup ret = %d\n", retval); - goto batt_failed_3; - } - - spin_lock_init(&lock); - - bq27520_di = di; - if (pdata->enable_dlog) - INIT_WORK(&di->counter, bq27520_coulomb_counter_work); - - INIT_DELAYED_WORK(¤t_battery_status.poller, - battery_status_poller); - INIT_DELAYED_WORK(&di->hw_config, bq27520_hw_config); - schedule_delayed_work(&di->hw_config, BQ27520_INIT_DELAY); - - return 0; - -batt_failed_3: - kfree(bus); -batt_failed_2: - kfree(di); -batt_failed_1: - mutex_lock(&battery_mutex); - idr_remove(&battery_id, num); - mutex_unlock(&battery_mutex); - - return retval; -} - -static int bq27520_battery_remove(struct i2c_client *client) -{ - struct bq27520_device_info *di = i2c_get_clientdata(client); - - if (di->pdata->enable_dlog) { - del_timer_sync(&timer); - cancel_work_sync(&di->counter); - bq27520_cntl_cmd(di, BQ27520_SUBCMD_DISABLE_DLOG); - udelay(66); - } - - bq27520_cntl_cmd(di, BQ27520_SUBCMD_DISABLE_IT); - cancel_delayed_work_sync(&di->hw_config); - cancel_delayed_work_sync(¤t_battery_status.poller); - - bq27520_dev_setup(false, di); - bq27520_power(false, di); - - kfree(di->bus); - - mutex_lock(&battery_mutex); - idr_remove(&battery_id, di->id); - mutex_unlock(&battery_mutex); - - kfree(di); - return 0; -} - -#ifdef CONFIG_PM -static int bq27520_suspend(struct device *dev) -{ - struct bq27520_device_info *di = dev_get_drvdata(dev); - - disable_irq_nosync(di->irq); - if (di->pdata->enable_dlog) { - del_timer_sync(&timer); - cancel_work_sync(&di->counter); - } - - cancel_delayed_work_sync(¤t_battery_status.poller); - return 0; -} - -static int bq27520_resume(struct device *dev) -{ - struct bq27520_device_info *di = dev_get_drvdata(dev); - - enable_irq(di->irq); - if (di->pdata->enable_dlog) - add_timer(&timer); - - schedule_delayed_work(¤t_battery_status.poller, - BQ27520_POLLING_STATUS); - return 0; -} - -static const struct dev_pm_ops bq27520_pm_ops = { - .suspend = bq27520_suspend, - .resume = bq27520_resume, -}; -#endif - -static const struct i2c_device_id bq27520_id[] = { - { "bq27520", 1 }, - {}, -}; -MODULE_DEVICE_TABLE(i2c, BQ27520_id); - -static struct i2c_driver bq27520_battery_driver = { - .driver = { - .name = "bq27520-battery", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &bq27520_pm_ops, -#endif - }, - .probe = bq27520_battery_probe, - .remove = bq27520_battery_remove, - .id_table = bq27520_id, -}; - -static void init_battery_status(void) -{ - spin_lock_init(¤t_battery_status.lock); - current_battery_status.status[GET_BATTERY_STATUS] = - POWER_SUPPLY_STATUS_UNKNOWN; -} - -static int __init bq27520_battery_init(void) -{ - int ret; - - /* initialize current_battery_status, and register with msm-charger */ - init_battery_status(); - - ret = i2c_add_driver(&bq27520_battery_driver); - if (ret) - printk(KERN_ERR "Unable to register driver ret = %d\n", ret); - - return ret; -} -module_init(bq27520_battery_init); - -static void __exit bq27520_battery_exit(void) -{ - i2c_del_driver(&bq27520_battery_driver); - msm_battery_gauge_unregister(&bq27520_batt_gauge); -} -module_exit(bq27520_battery_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("BQ27520 battery monitor driver"); diff --git a/drivers/power/bq27541_fuelgauger.c b/drivers/power/bq27541_fuelgauger.c deleted file mode 100644 index 2101c5f00bb66dcf8a5caa953568543e8f39fd41..0000000000000000000000000000000000000000 --- a/drivers/power/bq27541_fuelgauger.c +++ /dev/null @@ -1,623 +0,0 @@ -/* Copyright (C) 2008 Rodolfo Giometti - * Copyright (C) 2008 Eurotech S.p.A. - * Based on a previous work by Copyright (C) 2008 Texas Instruments, Inc. - * - * Copyright (c) 2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* use the same platform data as bq27520 */ - -#define DRIVER_VERSION "1.1.0" -/* Bq27541 standard data commands */ -#define BQ27541_REG_CNTL 0x00 -#define BQ27541_REG_AR 0x02 -#define BQ27541_REG_ARTTE 0x04 -#define BQ27541_REG_TEMP 0x06 -#define BQ27541_REG_VOLT 0x08 -#define BQ27541_REG_FLAGS 0x0A -#define BQ27541_REG_NAC 0x0C -#define BQ27541_REG_FAC 0x0e -#define BQ27541_REG_RM 0x10 -#define BQ27541_REG_FCC 0x12 -#define BQ27541_REG_AI 0x14 -#define BQ27541_REG_TTE 0x16 -#define BQ27541_REG_TTF 0x18 -#define BQ27541_REG_SI 0x1a -#define BQ27541_REG_STTE 0x1c -#define BQ27541_REG_MLI 0x1e -#define BQ27541_REG_MLTTE 0x20 -#define BQ27541_REG_AE 0x22 -#define BQ27541_REG_AP 0x24 -#define BQ27541_REG_TTECP 0x26 -#define BQ27541_REG_SOH 0x28 -#define BQ27541_REG_SOC 0x2c -#define BQ27541_REG_NIC 0x2e -#define BQ27541_REG_ICR 0x30 -#define BQ27541_REG_LOGIDX 0x32 -#define BQ27541_REG_LOGBUF 0x34 - -#define BQ27541_FLAG_DSC BIT(0) -#define BQ27541_FLAG_FC BIT(9) - -#define BQ27541_CS_DLOGEN BIT(15) -#define BQ27541_CS_SS BIT(13) - -/* Control subcommands */ -#define BQ27541_SUBCMD_CTNL_STATUS 0x0000 -#define BQ27541_SUBCMD_DEVCIE_TYPE 0x0001 -#define BQ27541_SUBCMD_FW_VER 0x0002 -#define BQ27541_SUBCMD_HW_VER 0x0003 -#define BQ27541_SUBCMD_DF_CSUM 0x0004 -#define BQ27541_SUBCMD_PREV_MACW 0x0007 -#define BQ27541_SUBCMD_CHEM_ID 0x0008 -#define BQ27541_SUBCMD_BD_OFFSET 0x0009 -#define BQ27541_SUBCMD_INT_OFFSET 0x000a -#define BQ27541_SUBCMD_CC_VER 0x000b -#define BQ27541_SUBCMD_OCV 0x000c -#define BQ27541_SUBCMD_BAT_INS 0x000d -#define BQ27541_SUBCMD_BAT_REM 0x000e -#define BQ27541_SUBCMD_SET_HIB 0x0011 -#define BQ27541_SUBCMD_CLR_HIB 0x0012 -#define BQ27541_SUBCMD_SET_SLP 0x0013 -#define BQ27541_SUBCMD_CLR_SLP 0x0014 -#define BQ27541_SUBCMD_FCT_RES 0x0015 -#define BQ27541_SUBCMD_ENABLE_DLOG 0x0018 -#define BQ27541_SUBCMD_DISABLE_DLOG 0x0019 -#define BQ27541_SUBCMD_SEALED 0x0020 -#define BQ27541_SUBCMD_ENABLE_IT 0x0021 -#define BQ27541_SUBCMD_DISABLE_IT 0x0023 -#define BQ27541_SUBCMD_CAL_MODE 0x0040 -#define BQ27541_SUBCMD_RESET 0x0041 -#define ZERO_DEGREE_CELSIUS_IN_TENTH_KELVIN (-2731) -#define BQ27541_INIT_DELAY ((HZ)*1) - -/* If the system has several batteries we need a different name for each - * of them... - */ -static DEFINE_IDR(battery_id); -static DEFINE_MUTEX(battery_mutex); - -struct bq27541_device_info; -struct bq27541_access_methods { - int (*read)(u8 reg, int *rt_value, int b_single, - struct bq27541_device_info *di); -}; - -struct bq27541_device_info { - struct device *dev; - int id; - struct bq27541_access_methods *bus; - struct i2c_client *client; - struct work_struct counter; - /* 300ms delay is needed after bq27541 is powered up - * and before any successful I2C transaction - */ - struct delayed_work hw_config; -}; - -static int coulomb_counter; -static spinlock_t lock; /* protect access to coulomb_counter */ - -static int bq27541_i2c_txsubcmd(u8 reg, unsigned short subcmd, - struct bq27541_device_info *di); - -static int bq27541_read(u8 reg, int *rt_value, int b_single, - struct bq27541_device_info *di) -{ - return di->bus->read(reg, rt_value, b_single, di); -} - -/* - * Return the battery temperature in tenths of degree Celsius - * Or < 0 if something fails. - */ -static int bq27541_battery_temperature(struct bq27541_device_info *di) -{ - int ret; - int temp = 0; - - ret = bq27541_read(BQ27541_REG_TEMP, &temp, 0, di); - if (ret) { - dev_err(di->dev, "error reading temperature\n"); - return ret; - } - - return temp + ZERO_DEGREE_CELSIUS_IN_TENTH_KELVIN; -} - -/* - * Return the battery Voltage in milivolts - * Or < 0 if something fails. - */ -static int bq27541_battery_voltage(struct bq27541_device_info *di) -{ - int ret; - int volt = 0; - - ret = bq27541_read(BQ27541_REG_VOLT, &volt, 0, di); - if (ret) { - dev_err(di->dev, "error reading voltage\n"); - return ret; - } - - return volt * 1000; -} - -static void bq27541_cntl_cmd(struct bq27541_device_info *di, - int subcmd) -{ - bq27541_i2c_txsubcmd(BQ27541_REG_CNTL, subcmd, di); -} - -/* - * i2c specific code - */ -static int bq27541_i2c_txsubcmd(u8 reg, unsigned short subcmd, - struct bq27541_device_info *di) -{ - struct i2c_msg msg; - unsigned char data[3]; - int ret; - - if (!di->client) - return -ENODEV; - - memset(data, 0, sizeof(data)); - data[0] = reg; - data[1] = subcmd & 0x00FF; - data[2] = (subcmd & 0xFF00) >> 8; - - msg.addr = di->client->addr; - msg.flags = 0; - msg.len = 3; - msg.buf = data; - - ret = i2c_transfer(di->client->adapter, &msg, 1); - if (ret < 0) - return -EIO; - - return 0; -} - -static int bq27541_chip_config(struct bq27541_device_info *di) -{ - int flags = 0, ret = 0; - - bq27541_cntl_cmd(di, BQ27541_SUBCMD_CTNL_STATUS); - udelay(66); - ret = bq27541_read(BQ27541_REG_CNTL, &flags, 0, di); - if (ret < 0) { - dev_err(di->dev, "error reading register %02x ret = %d\n", - BQ27541_REG_CNTL, ret); - return ret; - } - udelay(66); - - bq27541_cntl_cmd(di, BQ27541_SUBCMD_ENABLE_IT); - udelay(66); - - if (!(flags & BQ27541_CS_DLOGEN)) { - bq27541_cntl_cmd(di, BQ27541_SUBCMD_ENABLE_DLOG); - udelay(66); - } - - return 0; -} - -static void bq27541_coulomb_counter_work(struct work_struct *work) -{ - int value = 0, temp = 0, index = 0, ret = 0; - struct bq27541_device_info *di; - unsigned long flags; - int count = 0; - - di = container_of(work, struct bq27541_device_info, counter); - - /* retrieve 30 values from FIFO of coulomb data logging buffer - * and average over time - */ - do { - ret = bq27541_read(BQ27541_REG_LOGBUF, &temp, 0, di); - if (ret < 0) - break; - if (temp != 0x7FFF) { - ++count; - value += temp; - } - /* delay 66uS, waiting time between continuous reading - * results - */ - udelay(66); - ret = bq27541_read(BQ27541_REG_LOGIDX, &index, 0, di); - if (ret < 0) - break; - udelay(66); - } while (index != 0 || temp != 0x7FFF); - - if (ret < 0) { - dev_err(di->dev, "Error reading datalog register\n"); - return; - } - - if (count) { - spin_lock_irqsave(&lock, flags); - coulomb_counter = value/count; - spin_unlock_irqrestore(&lock, flags); - } -} - -struct bq27541_device_info *bq27541_di; - -static int bq27541_get_battery_mvolts(void) -{ - return bq27541_battery_voltage(bq27541_di); -} - -static int bq27541_get_battery_temperature(void) -{ - return bq27541_battery_temperature(bq27541_di); -} -static int bq27541_is_battery_present(void) -{ - return 1; -} -static int bq27541_is_battery_temp_within_range(void) -{ - return 1; -} -static int bq27541_is_battery_id_valid(void) -{ - return 1; -} - -static struct msm_battery_gauge bq27541_batt_gauge = { - .get_battery_mvolts = bq27541_get_battery_mvolts, - .get_battery_temperature = bq27541_get_battery_temperature, - .is_battery_present = bq27541_is_battery_present, - .is_battery_temp_within_range = bq27541_is_battery_temp_within_range, - .is_battery_id_valid = bq27541_is_battery_id_valid, -}; -static void bq27541_hw_config(struct work_struct *work) -{ - int ret = 0, flags = 0, type = 0, fw_ver = 0; - struct bq27541_device_info *di; - - di = container_of(work, struct bq27541_device_info, hw_config.work); - ret = bq27541_chip_config(di); - if (ret) { - dev_err(di->dev, "Failed to config Bq27541\n"); - return; - } - msm_battery_gauge_register(&bq27541_batt_gauge); - - bq27541_cntl_cmd(di, BQ27541_SUBCMD_CTNL_STATUS); - udelay(66); - bq27541_read(BQ27541_REG_CNTL, &flags, 0, di); - bq27541_cntl_cmd(di, BQ27541_SUBCMD_DEVCIE_TYPE); - udelay(66); - bq27541_read(BQ27541_REG_CNTL, &type, 0, di); - bq27541_cntl_cmd(di, BQ27541_SUBCMD_FW_VER); - udelay(66); - bq27541_read(BQ27541_REG_CNTL, &fw_ver, 0, di); - - dev_info(di->dev, "DEVICE_TYPE is 0x%02X, FIRMWARE_VERSION is 0x%02X\n", - type, fw_ver); - dev_info(di->dev, "Complete bq27541 configuration 0x%02X\n", flags); -} - -static int bq27541_read_i2c(u8 reg, int *rt_value, int b_single, - struct bq27541_device_info *di) -{ - struct i2c_client *client = di->client; - struct i2c_msg msg[1]; - unsigned char data[2]; - int err; - - if (!client->adapter) - return -ENODEV; - - msg->addr = client->addr; - msg->flags = 0; - msg->len = 1; - msg->buf = data; - - data[0] = reg; - err = i2c_transfer(client->adapter, msg, 1); - - if (err >= 0) { - if (!b_single) - msg->len = 2; - else - msg->len = 1; - - msg->flags = I2C_M_RD; - err = i2c_transfer(client->adapter, msg, 1); - if (err >= 0) { - if (!b_single) - *rt_value = get_unaligned_le16(data); - else - *rt_value = data[0]; - - return 0; - } - } - return err; -} - -#ifdef CONFIG_BQ27541_TEST_ENABLE -static int reg; -static int subcmd; -static ssize_t bq27541_read_stdcmd(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int ret; - int temp = 0; - struct platform_device *client; - struct bq27541_device_info *di; - - client = to_platform_device(dev); - di = platform_get_drvdata(client); - - if (reg <= BQ27541_REG_ICR && reg > 0x00) { - ret = bq27541_read(reg, &temp, 0, di); - if (ret) - ret = snprintf(buf, PAGE_SIZE, "Read Error!\n"); - else - ret = snprintf(buf, PAGE_SIZE, "0x%02x\n", temp); - } else - ret = snprintf(buf, PAGE_SIZE, "Register Error!\n"); - - return ret; -} - -static ssize_t bq27541_write_stdcmd(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int cmd; - - sscanf(buf, "%x", &cmd); - reg = cmd; - return ret; -} - -static ssize_t bq27541_read_subcmd(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int ret; - int temp = 0; - struct platform_device *client; - struct bq27541_device_info *di; - - client = to_platform_device(dev); - di = platform_get_drvdata(client); - - if (subcmd == BQ27541_SUBCMD_DEVCIE_TYPE || - subcmd == BQ27541_SUBCMD_FW_VER || - subcmd == BQ27541_SUBCMD_HW_VER || - subcmd == BQ27541_SUBCMD_CHEM_ID) { - - bq27541_cntl_cmd(di, subcmd); /* Retrieve Chip status */ - udelay(66); - ret = bq27541_read(BQ27541_REG_CNTL, &temp, 0, di); - - if (ret) - ret = snprintf(buf, PAGE_SIZE, "Read Error!\n"); - else - ret = snprintf(buf, PAGE_SIZE, "0x%02x\n", temp); - } else - ret = snprintf(buf, PAGE_SIZE, "Register Error!\n"); - - return ret; -} - -static ssize_t bq27541_write_subcmd(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int cmd; - - sscanf(buf, "%x", &cmd); - subcmd = cmd; - return ret; -} - -static DEVICE_ATTR(std_cmd, S_IRUGO|S_IWUGO, bq27541_read_stdcmd, - bq27541_write_stdcmd); -static DEVICE_ATTR(sub_cmd, S_IRUGO|S_IWUGO, bq27541_read_subcmd, - bq27541_write_subcmd); -static struct attribute *fs_attrs[] = { - &dev_attr_std_cmd.attr, - &dev_attr_sub_cmd.attr, - NULL, -}; -static struct attribute_group fs_attr_group = { - .attrs = fs_attrs, -}; - -static struct platform_device this_device = { - .name = "bq27541-test", - .id = -1, - .dev.platform_data = NULL, -}; -#endif - -static int bq27541_battery_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - char *name; - struct bq27541_device_info *di; - struct bq27541_access_methods *bus; - int num; - int retval = 0; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) - return -ENODEV; - - /* Get new ID for the new battery device */ - retval = idr_pre_get(&battery_id, GFP_KERNEL); - if (retval == 0) - return -ENOMEM; - mutex_lock(&battery_mutex); - retval = idr_get_new(&battery_id, client, &num); - mutex_unlock(&battery_mutex); - if (retval < 0) - return retval; - - name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num); - if (!name) { - dev_err(&client->dev, "failed to allocate device name\n"); - retval = -ENOMEM; - goto batt_failed_1; - } - - di = kzalloc(sizeof(*di), GFP_KERNEL); - if (!di) { - dev_err(&client->dev, "failed to allocate device info data\n"); - retval = -ENOMEM; - goto batt_failed_2; - } - di->id = num; - - bus = kzalloc(sizeof(*bus), GFP_KERNEL); - if (!bus) { - dev_err(&client->dev, "failed to allocate access method " - "data\n"); - retval = -ENOMEM; - goto batt_failed_3; - } - - i2c_set_clientdata(client, di); - di->dev = &client->dev; - bus->read = &bq27541_read_i2c; - di->bus = bus; - di->client = client; - -#ifdef CONFIG_BQ27541_TEST_ENABLE - platform_set_drvdata(&this_device, di); - retval = platform_device_register(&this_device); - if (!retval) { - retval = sysfs_create_group(&this_device.dev.kobj, - &fs_attr_group); - if (retval) - goto batt_failed_4; - } else - goto batt_failed_4; -#endif - - if (retval) { - dev_err(&client->dev, "failed to setup bq27541\n"); - goto batt_failed_4; - } - - if (retval) { - dev_err(&client->dev, "failed to powerup bq27541\n"); - goto batt_failed_4; - } - - spin_lock_init(&lock); - - bq27541_di = di; - INIT_WORK(&di->counter, bq27541_coulomb_counter_work); - INIT_DELAYED_WORK(&di->hw_config, bq27541_hw_config); - schedule_delayed_work(&di->hw_config, BQ27541_INIT_DELAY); - return 0; - -batt_failed_4: - kfree(bus); -batt_failed_3: - kfree(di); -batt_failed_2: - kfree(name); -batt_failed_1: - mutex_lock(&battery_mutex); - idr_remove(&battery_id, num); - mutex_unlock(&battery_mutex); - - return retval; -} - -static int bq27541_battery_remove(struct i2c_client *client) -{ - struct bq27541_device_info *di = i2c_get_clientdata(client); - - msm_battery_gauge_unregister(&bq27541_batt_gauge); - bq27541_cntl_cmd(di, BQ27541_SUBCMD_DISABLE_DLOG); - udelay(66); - bq27541_cntl_cmd(di, BQ27541_SUBCMD_DISABLE_IT); - cancel_delayed_work_sync(&di->hw_config); - - kfree(di->bus); - - mutex_lock(&battery_mutex); - idr_remove(&battery_id, di->id); - mutex_unlock(&battery_mutex); - - kfree(di); - return 0; -} - -static const struct i2c_device_id bq27541_id[] = { - { "bq27541", 1 }, - {}, -}; -MODULE_DEVICE_TABLE(i2c, BQ27541_id); - -static struct i2c_driver bq27541_battery_driver = { - .driver = { - .name = "bq27541-battery", - }, - .probe = bq27541_battery_probe, - .remove = bq27541_battery_remove, - .id_table = bq27541_id, -}; - -static int __init bq27541_battery_init(void) -{ - int ret; - - ret = i2c_add_driver(&bq27541_battery_driver); - if (ret) - printk(KERN_ERR "Unable to register BQ27541 driver\n"); - - return ret; -} -module_init(bq27541_battery_init); - -static void __exit bq27541_battery_exit(void) -{ - i2c_del_driver(&bq27541_battery_driver); -} -module_exit(bq27541_battery_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("BQ27541 battery monitor driver"); diff --git a/drivers/power/isl9519q.c b/drivers/power/isl9519q.c deleted file mode 100644 index a5d8087a11a06dd6c07693d487755fccd3222a43..0000000000000000000000000000000000000000 --- a/drivers/power/isl9519q.c +++ /dev/null @@ -1,849 +0,0 @@ -/* Copyright (c) 2010-2012, 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. - * - */ -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CHG_CURRENT_REG 0x14 -#define MAX_SYS_VOLTAGE_REG 0x15 -#define CONTROL_REG 0x3D -#define MIN_SYS_VOLTAGE_REG 0x3E -#define INPUT_CURRENT_REG 0x3F -#define MANUFACTURER_ID_REG 0xFE -#define DEVICE_ID_REG 0xFF - -#define TRCKL_CHG_STATUS_BIT 0x80 - -#define ISL9519_CHG_PERIOD_SEC 150 - -struct isl9519q_struct { - struct i2c_client *client; - struct delayed_work charge_work; - int present; - int batt_present; - bool charging; - int chgcurrent; - int term_current; - int input_current; - int max_system_voltage; - int min_system_voltage; - int valid_n_gpio; - struct dentry *dent; - struct msm_hardware_charger adapter_hw_chg; - int suspended; - int charge_at_resume; - struct power_supply dc_psy; - spinlock_t lock; - bool notify_by_pmic; - bool trickle; -}; - -static struct isl9519q_struct *the_isl_chg; - -static int isl9519q_read_reg(struct i2c_client *client, int reg, - u16 *val) -{ - int ret; - struct isl9519q_struct *isl_chg; - - isl_chg = i2c_get_clientdata(client); - ret = i2c_smbus_read_word_data(isl_chg->client, reg); - - if (ret < 0) { - dev_err(&isl_chg->client->dev, - "i2c read fail: can't read from %02x: %d\n", reg, ret); - return -EAGAIN; - } else { - *val = ret; - } - - pr_debug("reg=0x%x.val=0x%x.\n", reg, *val); - - return 0; -} - -static int isl9519q_write_reg(struct i2c_client *client, int reg, - u16 val) -{ - int ret; - struct isl9519q_struct *isl_chg; - - pr_debug("reg=0x%x.val=0x%x.\n", reg, val); - - isl_chg = i2c_get_clientdata(client); - ret = i2c_smbus_write_word_data(isl_chg->client, reg, val); - - if (ret < 0) { - dev_err(&isl_chg->client->dev, - "i2c write fail: can't write %02x to %02x: %d\n", - val, reg, ret); - return -EAGAIN; - } - return 0; -} - -/** - * Read charge-current via ADC. - * - * The ISL CCMON (charge-current-monitor) pin is connected to - * the PMIC MPP#X pin. - * This not required when notify_by_pmic is used where the PMIC - * uses BMS to notify the ISL on charging-done / charge-resume. - */ -static int isl_read_adc(int channel, int *mv_reading) -{ - int ret; - void *h; - struct adc_chan_result adc_chan_result; - struct completion conv_complete_evt; - - pr_debug("called for %d\n", channel); - ret = adc_channel_open(channel, &h); - if (ret) { - pr_err("couldnt open channel %d ret=%d\n", channel, ret); - goto out; - } - init_completion(&conv_complete_evt); - ret = adc_channel_request_conv(h, &conv_complete_evt); - if (ret) { - pr_err("couldnt request conv channel %d ret=%d\n", - channel, ret); - goto out; - } - ret = wait_for_completion_interruptible(&conv_complete_evt); - if (ret) { - pr_err("wait interrupted channel %d ret=%d\n", channel, ret); - goto out; - } - ret = adc_channel_read_result(h, &adc_chan_result); - if (ret) { - pr_err("couldnt read result channel %d ret=%d\n", - channel, ret); - goto out; - } - ret = adc_channel_close(h); - if (ret) - pr_err("couldnt close channel %d ret=%d\n", channel, ret); - if (mv_reading) - *mv_reading = (int)adc_chan_result.measurement; - - pr_debug("done for %d\n", channel); - return adc_chan_result.physical; -out: - *mv_reading = 0; - pr_debug("done with error for %d\n", channel); - - return -EINVAL; -} - -static bool is_trickle_charging(struct isl9519q_struct *isl_chg) -{ - u16 ctrl = 0; - int ret; - - ret = isl9519q_read_reg(isl_chg->client, CONTROL_REG, &ctrl); - - if (!ret) { - pr_debug("control_reg=0x%x.\n", ctrl); - } else { - dev_err(&isl_chg->client->dev, - "%s couldnt read cntrl reg\n", __func__); - } - - if (ctrl & TRCKL_CHG_STATUS_BIT) - return true; - - return false; -} - -static void isl_adapter_check_ichg(struct isl9519q_struct *isl_chg) -{ - int ichg; /* isl charger current */ - int mv_reading = 0; - - ichg = isl_read_adc(CHANNEL_ADC_BATT_AMON, &mv_reading); - - dev_dbg(&isl_chg->client->dev, "%s mv_reading=%d\n", - __func__, mv_reading); - dev_dbg(&isl_chg->client->dev, "%s isl_charger_current=%d\n", - __func__, ichg); - - if (ichg >= 0 && ichg <= isl_chg->term_current) - msm_charger_notify_event(&isl_chg->adapter_hw_chg, - CHG_DONE_EVENT); - - isl_chg->trickle = is_trickle_charging(isl_chg); - if (isl_chg->trickle) - msm_charger_notify_event(&isl_chg->adapter_hw_chg, - CHG_BATT_BEGIN_FAST_CHARGING); -} - -/** - * isl9519q_worker - * - * Periodic task required to kick the ISL HW watchdog to keep - * charging. - * - * @isl9519_work: work context. - */ -static void isl9519q_worker(struct work_struct *isl9519_work) -{ - struct isl9519q_struct *isl_chg; - - isl_chg = container_of(isl9519_work, struct isl9519q_struct, - charge_work.work); - - dev_dbg(&isl_chg->client->dev, "%s\n", __func__); - - if (!isl_chg->charging) { - pr_debug("stop charging.\n"); - isl9519q_write_reg(isl_chg->client, CHG_CURRENT_REG, 0); - return; /* Stop periodic worker */ - } - - /* Kick the dog by writting to CHG_CURRENT_REG */ - isl9519q_write_reg(isl_chg->client, CHG_CURRENT_REG, - isl_chg->chgcurrent); - - if (isl_chg->notify_by_pmic) - isl_chg->trickle = is_trickle_charging(isl_chg); - else - isl_adapter_check_ichg(isl_chg); - - schedule_delayed_work(&isl_chg->charge_work, - (ISL9519_CHG_PERIOD_SEC * HZ)); -} - -static int isl9519q_start_charging(struct isl9519q_struct *isl_chg, - int chg_voltage, int chg_current) -{ - pr_debug("\n"); - - if (isl_chg->charging) { - pr_warn("already charging.\n"); - return 0; - } - - if (isl_chg->suspended) { - pr_warn("suspended - can't start charging.\n"); - isl_chg->charge_at_resume = 1; - return 0; - } - - dev_dbg(&isl_chg->client->dev, - "%s starting timed work.period=%d seconds.\n", - __func__, (int) ISL9519_CHG_PERIOD_SEC); - - /* - * The ISL will start charging from the worker context. - * This API might be called from interrupt context. - */ - schedule_delayed_work(&isl_chg->charge_work, 1); - - isl_chg->charging = true; - - return 0; -} - -static int isl9519q_stop_charging(struct isl9519q_struct *isl_chg) -{ - pr_debug("\n"); - - if (!(isl_chg->charging)) { - pr_warn("already not charging.\n"); - return 0; - } - - if (isl_chg->suspended) { - isl_chg->charge_at_resume = 0; - return 0; - } - - dev_dbg(&isl_chg->client->dev, "%s\n", __func__); - - isl_chg->charging = false; - isl_chg->trickle = false; - /* - * The ISL will stop charging from the worker context. - * This API might be called from interrupt context. - */ - schedule_delayed_work(&isl_chg->charge_work, 1); - - return 0; -} - -static int isl_adapter_start_charging(struct msm_hardware_charger *hw_chg, - int chg_voltage, int chg_current) -{ - int rc; - struct isl9519q_struct *isl_chg; - - isl_chg = container_of(hw_chg, struct isl9519q_struct, adapter_hw_chg); - rc = isl9519q_start_charging(isl_chg, chg_voltage, chg_current); - - return rc; -} - -static int isl_adapter_stop_charging(struct msm_hardware_charger *hw_chg) -{ - int rc; - struct isl9519q_struct *isl_chg; - - isl_chg = container_of(hw_chg, struct isl9519q_struct, adapter_hw_chg); - rc = isl9519q_stop_charging(isl_chg); - - return rc; -} - -static int isl9519q_charging_switched(struct msm_hardware_charger *hw_chg) -{ - struct isl9519q_struct *isl_chg; - - isl_chg = container_of(hw_chg, struct isl9519q_struct, adapter_hw_chg); - dev_dbg(&isl_chg->client->dev, "%s\n", __func__); - return 0; -} - -static irqreturn_t isl_valid_handler(int irq, void *dev_id) -{ - int val; - struct isl9519q_struct *isl_chg; - struct i2c_client *client = dev_id; - - isl_chg = i2c_get_clientdata(client); - val = gpio_get_value_cansleep(isl_chg->valid_n_gpio); - if (val < 0) { - dev_err(&isl_chg->client->dev, - "%s gpio_get_value failed for %d ret=%d\n", __func__, - isl_chg->valid_n_gpio, val); - goto err; - } - dev_dbg(&isl_chg->client->dev, "%s val=%d\n", __func__, val); - - if (val) { - if (isl_chg->present == 1) { - msm_charger_notify_event(&isl_chg->adapter_hw_chg, - CHG_REMOVED_EVENT); - isl_chg->present = 0; - } - } else { - if (isl_chg->present == 0) { - msm_charger_notify_event(&isl_chg->adapter_hw_chg, - CHG_INSERTED_EVENT); - isl_chg->present = 1; - } - } -err: - return IRQ_HANDLED; -} - -static enum power_supply_property pm_power_props[] = { - POWER_SUPPLY_PROP_ONLINE, - POWER_SUPPLY_PROP_CURRENT_MAX, - POWER_SUPPLY_PROP_CHARGE_TYPE, -}; - -static char *pm_power_supplied_to[] = { - "battery", -}; - -static int get_prop_charge_type(struct isl9519q_struct *isl_chg) -{ - if (!isl_chg->present) - return POWER_SUPPLY_CHARGE_TYPE_NONE; - - if (isl_chg->trickle) - return POWER_SUPPLY_CHARGE_TYPE_TRICKLE; - - if (isl_chg->charging) - return POWER_SUPPLY_CHARGE_TYPE_FAST; - - return POWER_SUPPLY_CHARGE_TYPE_NONE; -} -static int pm_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct isl9519q_struct *isl_chg = container_of(psy, - struct isl9519q_struct, - dc_psy); - - switch (psp) { - case POWER_SUPPLY_PROP_CURRENT_MAX: - val->intval = isl_chg->chgcurrent; - break; - case POWER_SUPPLY_PROP_ONLINE: - val->intval = (int)isl_chg->present; - break; - case POWER_SUPPLY_PROP_CHARGE_TYPE: - val->intval = get_prop_charge_type(isl_chg); - break; - default: - return -EINVAL; - } - return 0; -} - -static int pm_power_set_property(struct power_supply *psy, - enum power_supply_property psp, - const union power_supply_propval *val) -{ - struct isl9519q_struct *isl_chg = container_of(psy, - struct isl9519q_struct, - dc_psy); - unsigned long flags; - int rc; - - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - if (val->intval) { - isl_chg->present = val->intval; - } else { - isl_chg->present = 0; - if (isl_chg->charging) - goto stop_charging; - } - break; - case POWER_SUPPLY_PROP_CURRENT_MAX: - if (val->intval) { - if (isl_chg->chgcurrent != val->intval) - return -EINVAL; - } - break; - case POWER_SUPPLY_PROP_CHARGE_TYPE: - if (val->intval && isl_chg->present) { - if (val->intval == POWER_SUPPLY_CHARGE_TYPE_FAST) - goto start_charging; - if (val->intval == POWER_SUPPLY_CHARGE_TYPE_NONE) - goto stop_charging; - } else { - return -EINVAL; - } - break; - default: - return -EINVAL; - } - power_supply_changed(&isl_chg->dc_psy); - return 0; - -start_charging: - spin_lock_irqsave(&isl_chg->lock, flags); - rc = isl9519q_start_charging(isl_chg, 0, isl_chg->chgcurrent); - if (rc) - pr_err("Failed to start charging rc=%d\n", rc); - spin_unlock_irqrestore(&isl_chg->lock, flags); - power_supply_changed(&isl_chg->dc_psy); - return rc; - -stop_charging: - spin_lock_irqsave(&isl_chg->lock, flags); - rc = isl9519q_stop_charging(isl_chg); - if (rc) - pr_err("Failed to start charging rc=%d\n", rc); - spin_unlock_irqrestore(&isl_chg->lock, flags); - power_supply_changed(&isl_chg->dc_psy); - return rc; -} - -#define MAX_VOLTAGE_REG_MASK 0x3FF0 -#define MIN_VOLTAGE_REG_MASK 0x3F00 -#define DEFAULT_MAX_VOLTAGE_REG_VALUE 0x1070 -#define DEFAULT_MIN_VOLTAGE_REG_VALUE 0x0D00 - -static int isl9519q_init_adapter(struct isl9519q_struct *isl_chg) -{ - int ret; - struct i2c_client *client = isl_chg->client; - struct isl_platform_data *pdata = client->dev.platform_data; - - isl_chg->adapter_hw_chg.type = CHG_TYPE_AC; - isl_chg->adapter_hw_chg.rating = 2; - isl_chg->adapter_hw_chg.name = "isl-adapter"; - isl_chg->adapter_hw_chg.start_charging = isl_adapter_start_charging; - isl_chg->adapter_hw_chg.stop_charging = isl_adapter_stop_charging; - isl_chg->adapter_hw_chg.charging_switched = isl9519q_charging_switched; - - ret = gpio_request(pdata->valid_n_gpio, "isl_charger_valid"); - if (ret) { - dev_err(&client->dev, "%s gpio_request failed " - "for %d ret=%d\n", - __func__, pdata->valid_n_gpio, ret); - goto out; - } - - ret = msm_charger_register(&isl_chg->adapter_hw_chg); - if (ret) { - dev_err(&client->dev, - "%s msm_charger_register failed for ret =%d\n", - __func__, ret); - goto free_gpio; - } - - ret = request_threaded_irq(client->irq, NULL, - isl_valid_handler, - IRQF_TRIGGER_FALLING | - IRQF_TRIGGER_RISING, - "isl_charger_valid", client); - if (ret) { - dev_err(&client->dev, - "%s request_threaded_irq failed " - "for %d ret =%d\n", - __func__, client->irq, ret); - goto unregister; - } - irq_set_irq_wake(client->irq, 1); - - ret = gpio_get_value_cansleep(isl_chg->valid_n_gpio); - if (ret < 0) { - dev_err(&client->dev, - "%s gpio_get_value failed for %d ret=%d\n", - __func__, pdata->valid_n_gpio, ret); - /* assume absent */ - ret = 1; - } - if (!ret) { - msm_charger_notify_event(&isl_chg->adapter_hw_chg, - CHG_INSERTED_EVENT); - isl_chg->present = 1; - } - - return 0; - -unregister: - msm_charger_unregister(&isl_chg->adapter_hw_chg); -free_gpio: - gpio_free(pdata->valid_n_gpio); -out: - return ret; - -} - -static int isl9519q_init_ext_chg(struct isl9519q_struct *isl_chg) -{ - int ret; - - isl_chg->dc_psy.name = "dc"; - isl_chg->dc_psy.type = POWER_SUPPLY_TYPE_MAINS; - isl_chg->dc_psy.supplied_to = pm_power_supplied_to; - isl_chg->dc_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to); - isl_chg->dc_psy.properties = pm_power_props; - isl_chg->dc_psy.num_properties = ARRAY_SIZE(pm_power_props); - isl_chg->dc_psy.get_property = pm_power_get_property; - isl_chg->dc_psy.set_property = pm_power_set_property; - - ret = power_supply_register(&isl_chg->client->dev, &isl_chg->dc_psy); - if (ret) { - pr_err("failed to register dc charger.ret=%d.\n", ret); - return ret; - } - - return 0; -} -static int set_reg(void *data, u64 val) -{ - int addr = (int)data; - int ret; - u16 temp; - - temp = (u16) val; - ret = isl9519q_write_reg(the_isl_chg->client, addr, temp); - - if (ret) { - pr_err("isl9519q_write_reg to %x value =%d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - return 0; -} -static int get_reg(void *data, u64 *val) -{ - int addr = (int)data; - int ret; - u16 temp; - - ret = isl9519q_read_reg(the_isl_chg->client, addr, &temp); - if (ret) { - pr_err("isl9519q_read_reg to %x value =%d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - - *val = temp; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(reg_fops, get_reg, set_reg, "0x%02llx\n"); - -static void create_debugfs_entries(struct isl9519q_struct *isl_chg) -{ - isl_chg->dent = debugfs_create_dir("isl9519q", NULL); - - if (IS_ERR(isl_chg->dent)) { - pr_err("isl9519q driver couldn't create debugfs dir\n"); - return; - } - - debugfs_create_file("CHG_CURRENT_REG", 0644, isl_chg->dent, - (void *) CHG_CURRENT_REG, ®_fops); - debugfs_create_file("MAX_SYS_VOLTAGE_REG", 0644, isl_chg->dent, - (void *) MAX_SYS_VOLTAGE_REG, ®_fops); - debugfs_create_file("CONTROL_REG", 0644, isl_chg->dent, - (void *) CONTROL_REG, ®_fops); - debugfs_create_file("MIN_SYS_VOLTAGE_REG", 0644, isl_chg->dent, - (void *) MIN_SYS_VOLTAGE_REG, ®_fops); - debugfs_create_file("INPUT_CURRENT_REG", 0644, isl_chg->dent, - (void *) INPUT_CURRENT_REG, ®_fops); - debugfs_create_file("MANUFACTURER_ID_REG", 0644, isl_chg->dent, - (void *) MANUFACTURER_ID_REG, ®_fops); - debugfs_create_file("DEVICE_ID_REG", 0644, isl_chg->dent, - (void *) DEVICE_ID_REG, ®_fops); -} - -static void remove_debugfs_entries(struct isl9519q_struct *isl_chg) -{ - if (isl_chg->dent) - debugfs_remove_recursive(isl_chg->dent); -} - -static int isl9519q_hwinit(struct isl9519q_struct *isl_chg) -{ - int ret; - - ret = isl9519q_write_reg(isl_chg->client, MAX_SYS_VOLTAGE_REG, - isl_chg->max_system_voltage); - if (ret) { - pr_err("Failed to set MAX_SYS_VOLTAGE rc=%d\n", ret); - return ret; - } - - ret = isl9519q_write_reg(isl_chg->client, MIN_SYS_VOLTAGE_REG, - isl_chg->min_system_voltage); - if (ret) { - pr_err("Failed to set MIN_SYS_VOLTAGE rc=%d\n", ret); - return ret; - } - - if (isl_chg->input_current) { - ret = isl9519q_write_reg(isl_chg->client, - INPUT_CURRENT_REG, - isl_chg->input_current); - if (ret) { - pr_err("Failed to set INPUT_CURRENT rc=%d\n", ret); - return ret; - } - } - return 0; -} - -static int isl9519q_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct isl_platform_data *pdata; - struct isl9519q_struct *isl_chg; - int ret; - - ret = 0; - pdata = client->dev.platform_data; - - pr_debug("\n"); - - if (pdata == NULL) { - dev_err(&client->dev, "%s no platform data\n", __func__); - ret = -EINVAL; - goto out; - } - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WORD_DATA)) { - ret = -EIO; - goto out; - } - - isl_chg = kzalloc(sizeof(*isl_chg), GFP_KERNEL); - if (!isl_chg) { - ret = -ENOMEM; - goto out; - } - - spin_lock_init(&isl_chg->lock); - - INIT_DELAYED_WORK(&isl_chg->charge_work, isl9519q_worker); - isl_chg->client = client; - isl_chg->chgcurrent = pdata->chgcurrent; - isl_chg->term_current = pdata->term_current; - isl_chg->input_current = pdata->input_current; - isl_chg->max_system_voltage = pdata->max_system_voltage; - isl_chg->min_system_voltage = pdata->min_system_voltage; - isl_chg->valid_n_gpio = pdata->valid_n_gpio; - - /* h/w ignores lower 7 bits of charging current and input current */ - isl_chg->chgcurrent &= ~0x7F; - isl_chg->input_current &= ~0x7F; - - /** - * ISL is Notified by PMIC to start/stop charging, rather than - * handling interrupt from ISL for End-Of-Chargring, and - * monitoring the charge-current periodically. The valid_n_gpio - * is also not used, dc-present is detected by PMIC. - */ - isl_chg->notify_by_pmic = (client->irq == 0); - i2c_set_clientdata(client, isl_chg); - - if (pdata->chg_detection_config) { - ret = pdata->chg_detection_config(); - if (ret) { - dev_err(&client->dev, "%s valid config failed ret=%d\n", - __func__, ret); - goto free_isl_chg; - } - } - - isl_chg->max_system_voltage &= MAX_VOLTAGE_REG_MASK; - isl_chg->min_system_voltage &= MIN_VOLTAGE_REG_MASK; - if (isl_chg->max_system_voltage == 0) - isl_chg->max_system_voltage = DEFAULT_MAX_VOLTAGE_REG_VALUE; - if (isl_chg->min_system_voltage == 0) - isl_chg->min_system_voltage = DEFAULT_MIN_VOLTAGE_REG_VALUE; - - ret = isl9519q_hwinit(isl_chg); - if (ret) - goto free_isl_chg; - - if (isl_chg->notify_by_pmic) - ret = isl9519q_init_ext_chg(isl_chg); - else - ret = isl9519q_init_adapter(isl_chg); - - if (ret) - goto free_isl_chg; - - the_isl_chg = isl_chg; - create_debugfs_entries(isl_chg); - - pr_info("OK.\n"); - - return 0; - -free_isl_chg: - kfree(isl_chg); -out: - return ret; -} - -static int isl9519q_remove(struct i2c_client *client) -{ - struct isl_platform_data *pdata; - struct isl9519q_struct *isl_chg = i2c_get_clientdata(client); - - pdata = client->dev.platform_data; - gpio_free(pdata->valid_n_gpio); - free_irq(client->irq, client); - cancel_delayed_work_sync(&isl_chg->charge_work); - if (isl_chg->notify_by_pmic) { - power_supply_unregister(&isl_chg->dc_psy); - } else { - msm_charger_notify_event(&isl_chg->adapter_hw_chg, - CHG_REMOVED_EVENT); - msm_charger_unregister(&isl_chg->adapter_hw_chg); - } - remove_debugfs_entries(isl_chg); - the_isl_chg = NULL; - kfree(isl_chg); - return 0; -} - -static const struct i2c_device_id isl9519q_id[] = { - {"isl9519q", 0}, - {}, -}; - -#ifdef CONFIG_PM -static int isl9519q_suspend(struct device *dev) -{ - struct isl9519q_struct *isl_chg = dev_get_drvdata(dev); - - dev_dbg(&isl_chg->client->dev, "%s\n", __func__); - /* - * do not suspend while we are charging - * because we need to periodically update the register - * for charging to proceed - */ - if (isl_chg->charging) - return -EBUSY; - - isl_chg->suspended = 1; - return 0; -} - -static int isl9519q_resume(struct device *dev) -{ - struct isl9519q_struct *isl_chg = dev_get_drvdata(dev); - - dev_dbg(&isl_chg->client->dev, "%s\n", __func__); - isl_chg->suspended = 0; - if (isl_chg->charge_at_resume) { - isl_chg->charge_at_resume = 0; - isl9519q_start_charging(isl_chg, 0, 0); - } - return 0; -} - -static const struct dev_pm_ops isl9519q_pm_ops = { - .suspend = isl9519q_suspend, - .resume = isl9519q_resume, -}; -#endif - -static struct i2c_driver isl9519q_driver = { - .driver = { - .name = "isl9519q", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &isl9519q_pm_ops, -#endif - }, - .probe = isl9519q_probe, - .remove = isl9519q_remove, - .id_table = isl9519q_id, -}; - -static int __init isl9519q_init(void) -{ - return i2c_add_driver(&isl9519q_driver); -} - -late_initcall_sync(isl9519q_init); - -static void __exit isl9519q_exit(void) -{ - return i2c_del_driver(&isl9519q_driver); -} - -module_exit(isl9519q_exit); - -MODULE_AUTHOR("Abhijeet Dharmapurikar "); -MODULE_DESCRIPTION("Driver for ISL9519Q Charger chip"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/power/ltc4088-charger.c b/drivers/power/ltc4088-charger.c deleted file mode 100644 index 40043345178632c36bf14832868e42b89a9b7bc3..0000000000000000000000000000000000000000 --- a/drivers/power/ltc4088-charger.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_CURRENT_UA(n) (n) -#define MAX_CURRENT_MA(n) (n * MAX_CURRENT_UA(1000)) - -/** - * ltc4088_max_current - A typical current values supported by the charger - * @LTC4088_MAX_CURRENT_100mA: 100mA current - * @LTC4088_MAX_CURRENT_500mA: 500mA current - * @LTC4088_MAX_CURRENT_1A: 1A current - */ -enum ltc4088_max_current { - LTC4088_MAX_CURRENT_100mA = 100, - LTC4088_MAX_CURRENT_500mA = 500, - LTC4088_MAX_CURRENT_1A = 1000, -}; - -/** - * struct ltc4088_chg_chip - Device information - * @dev: Device pointer to access the parent - * @lock: Enable mutual exclusion - * @usb_psy: USB device information - * @gpio_mode_select_d0: GPIO #pin for D0 charger line - * @gpio_mode_select_d1: GPIO #pin for D1 charger line - * @gpio_mode_select_d2: GPIO #pin for D2 charger line - * @max_current: Maximum current that is supplied at this time - */ -struct ltc4088_chg_chip { - struct device *dev; - struct mutex lock; - struct power_supply usb_psy; - unsigned int gpio_mode_select_d0; - unsigned int gpio_mode_select_d1; - unsigned int gpio_mode_select_d2; - unsigned int max_current; -}; - -static enum power_supply_property pm_power_props[] = { - POWER_SUPPLY_PROP_CURRENT_MAX, - POWER_SUPPLY_PROP_ONLINE, -}; - -static char *pm_power_supplied_to[] = { - "battery", -}; - -static int ltc4088_set_charging(struct ltc4088_chg_chip *chip, bool enable) -{ - mutex_lock(&chip->lock); - - if (enable) { - gpio_set_value_cansleep(chip->gpio_mode_select_d2, 0); - } else { - /* When disabling charger, set the max current to 0 also */ - chip->max_current = 0; - gpio_set_value_cansleep(chip->gpio_mode_select_d0, 1); - gpio_set_value_cansleep(chip->gpio_mode_select_d1, 1); - gpio_set_value_cansleep(chip->gpio_mode_select_d2, 1); - } - - mutex_unlock(&chip->lock); - - return 0; -} - -static void ltc4088_set_max_current(struct ltc4088_chg_chip *chip, int value) -{ - mutex_lock(&chip->lock); - - /* If current is less than 100mA, we can not support that granularity */ - if (value < MAX_CURRENT_MA(LTC4088_MAX_CURRENT_100mA)) { - chip->max_current = 0; - gpio_set_value_cansleep(chip->gpio_mode_select_d0, 1); - gpio_set_value_cansleep(chip->gpio_mode_select_d1, 1); - } else if (value < MAX_CURRENT_MA(LTC4088_MAX_CURRENT_500mA)) { - chip->max_current = MAX_CURRENT_MA(LTC4088_MAX_CURRENT_100mA); - gpio_set_value_cansleep(chip->gpio_mode_select_d0, 0); - gpio_set_value_cansleep(chip->gpio_mode_select_d1, 0); - } else if (value < MAX_CURRENT_MA(LTC4088_MAX_CURRENT_1A)) { - chip->max_current = MAX_CURRENT_MA(LTC4088_MAX_CURRENT_500mA); - gpio_set_value_cansleep(chip->gpio_mode_select_d0, 0); - gpio_set_value_cansleep(chip->gpio_mode_select_d1, 1); - } else { - chip->max_current = MAX_CURRENT_MA(LTC4088_MAX_CURRENT_1A); - gpio_set_value_cansleep(chip->gpio_mode_select_d0, 1); - gpio_set_value_cansleep(chip->gpio_mode_select_d1, 0); - } - - mutex_unlock(&chip->lock); -} - -static void ltc4088_set_charging_off(struct ltc4088_chg_chip *chip) -{ - gpio_set_value_cansleep(chip->gpio_mode_select_d0, 1); - gpio_set_value_cansleep(chip->gpio_mode_select_d1, 1); -} - -static int ltc4088_set_initial_state(struct ltc4088_chg_chip *chip) -{ - int rc; - - rc = gpio_request(chip->gpio_mode_select_d0, "ltc4088_D0"); - if (rc) { - pr_err("gpio request failed for GPIO %d\n", - chip->gpio_mode_select_d0); - return rc; - } - - rc = gpio_request(chip->gpio_mode_select_d1, "ltc4088_D1"); - if (rc) { - pr_err("gpio request failed for GPIO %d\n", - chip->gpio_mode_select_d1); - goto gpio_err_d0; - } - - rc = gpio_request(chip->gpio_mode_select_d2, "ltc4088_D2"); - if (rc) { - pr_err("gpio request failed for GPIO %d\n", - chip->gpio_mode_select_d2); - goto gpio_err_d1; - } - - rc = gpio_direction_output(chip->gpio_mode_select_d0, 0); - if (rc) { - pr_err("failed to set direction for GPIO %d\n", - chip->gpio_mode_select_d0); - goto gpio_err_d2; - } - - rc = gpio_direction_output(chip->gpio_mode_select_d1, 0); - if (rc) { - pr_err("failed to set direction for GPIO %d\n", - chip->gpio_mode_select_d1); - goto gpio_err_d2; - } - - rc = gpio_direction_output(chip->gpio_mode_select_d2, 1); - if (rc) { - pr_err("failed to set direction for GPIO %d\n", - chip->gpio_mode_select_d2); - goto gpio_err_d2; - } - - return 0; - -gpio_err_d2: - gpio_free(chip->gpio_mode_select_d2); -gpio_err_d1: - gpio_free(chip->gpio_mode_select_d1); -gpio_err_d0: - gpio_free(chip->gpio_mode_select_d0); - return rc; -} - -static int pm_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct ltc4088_chg_chip *chip; - - if (psy->type == POWER_SUPPLY_TYPE_USB) { - chip = container_of(psy, struct ltc4088_chg_chip, - usb_psy); - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - if (chip->max_current) - val->intval = 1; - else - val->intval = 0; - break; - case POWER_SUPPLY_PROP_CURRENT_MAX: - val->intval = chip->max_current; - break; - default: - return -EINVAL; - } - } - return 0; -} - -static int pm_power_set_property(struct power_supply *psy, - enum power_supply_property psp, - const union power_supply_propval *val) -{ - struct ltc4088_chg_chip *chip; - - if (psy->type == POWER_SUPPLY_TYPE_USB) { - chip = container_of(psy, struct ltc4088_chg_chip, usb_psy); - switch (psp) { - case POWER_SUPPLY_PROP_TYPE: - psy.type = val->intval; - break; - case POWER_SUPPLY_PROP_ONLINE: - ltc4088_set_charging(chip, val->intval); - break; - case POWER_SUPPLY_PROP_CURRENT_MAX: - ltc4088_set_max_current(chip, val->intval); - break; - default: - return -EINVAL; - } - } - return 0; -} - -static int ltc4088_charger_probe(struct platform_device *pdev) -{ - int rc; - struct ltc4088_chg_chip *chip; - const struct ltc4088_charger_platform_data *pdata - = pdev->dev.platform_data; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct ltc4088_chg_chip), - GFP_KERNEL); - if (!chip) { - pr_err("Cannot allocate pm_chg_chip\n"); - return -ENOMEM; - } - - chip->dev = &pdev->dev; - - if (pdata->gpio_mode_select_d0 < 0 || - pdata->gpio_mode_select_d1 < 0 || - pdata->gpio_mode_select_d2 < 0) { - pr_err("Invalid platform data supplied\n"); - rc = -EINVAL; - goto free_chip; - } - - mutex_init(&chip->lock); - - chip->gpio_mode_select_d0 = pdata->gpio_mode_select_d0; - chip->gpio_mode_select_d1 = pdata->gpio_mode_select_d1; - chip->gpio_mode_select_d2 = pdata->gpio_mode_select_d2; - - chip->usb_psy.name = "usb", - chip->usb_psy.type = POWER_SUPPLY_TYPE_USB, - chip->usb_psy.supplied_to = pm_power_supplied_to, - chip->usb_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to), - chip->usb_psy.properties = pm_power_props, - chip->usb_psy.num_properties = ARRAY_SIZE(pm_power_props), - chip->usb_psy.get_property = pm_power_get_property, - chip->usb_psy.set_property = pm_power_set_property, - - rc = power_supply_register(chip->dev, &chip->usb_psy); - if (rc < 0) { - pr_err("power_supply_register usb failed rc = %d\n", rc); - goto free_chip; - } - - platform_set_drvdata(pdev, chip); - - rc = ltc4088_set_initial_state(chip); - if (rc < 0) { - pr_err("setting initial state failed rc = %d\n", rc); - goto unregister_usb; - } - - return 0; - -unregister_usb: - platform_set_drvdata(pdev, NULL); - power_supply_unregister(&chip->usb_psy); -free_chip: - kfree(chip); - - return rc; -} - -static int ltc4088_charger_remove(struct platform_device *pdev) -{ - struct ltc4088_chg_chip *chip = platform_get_drvdata(pdev); - - ltc4088_set_charging_off(chip); - - gpio_free(chip->gpio_mode_select_d2); - gpio_free(chip->gpio_mode_select_d1); - gpio_free(chip->gpio_mode_select_d0); - - power_supply_unregister(&chip->usb_psy); - - platform_set_drvdata(pdev, NULL); - mutex_destroy(&chip->lock); - kfree(chip); - - return 0; -} - -static struct platform_driver ltc4088_charger_driver = { - .probe = ltc4088_charger_probe, - .remove = ltc4088_charger_remove, - .driver = { - .name = LTC4088_CHARGER_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init ltc4088_charger_init(void) -{ - return platform_driver_register(<c4088_charger_driver); -} - -static void __exit ltc4088_charger_exit(void) -{ - platform_driver_unregister(<c4088_charger_driver); -} - -subsys_initcall(ltc4088_charger_init); -module_exit(ltc4088_charger_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("LTC4088 charger/battery driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" LTC4088_CHARGER_DEV_NAME); diff --git a/drivers/power/msm_battery.c b/drivers/power/msm_battery.c deleted file mode 100644 index fe554b022dbfbe3869c56d4776cc94ff70b1a616..0000000000000000000000000000000000000000 --- a/drivers/power/msm_battery.c +++ /dev/null @@ -1,1602 +0,0 @@ -/* Copyright (c) 2009-2012, 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. - * - */ - -/* - * this needs to be before is loaded, - * and loads - */ -#define DEBUG 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#define BATTERY_RPC_PROG 0x30000089 -#define BATTERY_RPC_VER_1_1 0x00010001 -#define BATTERY_RPC_VER_2_1 0x00020001 -#define BATTERY_RPC_VER_4_1 0x00040001 -#define BATTERY_RPC_VER_5_1 0x00050001 - -#define BATTERY_RPC_CB_PROG (BATTERY_RPC_PROG | 0x01000000) - -#define CHG_RPC_PROG 0x3000001a -#define CHG_RPC_VER_1_1 0x00010001 -#define CHG_RPC_VER_1_3 0x00010003 -#define CHG_RPC_VER_2_2 0x00020002 -#define CHG_RPC_VER_3_1 0x00030001 -#define CHG_RPC_VER_4_1 0x00040001 - -#define BATTERY_REGISTER_PROC 2 -#define BATTERY_MODIFY_CLIENT_PROC 4 -#define BATTERY_DEREGISTER_CLIENT_PROC 5 -#define BATTERY_READ_MV_PROC 12 -#define BATTERY_ENABLE_DISABLE_FILTER_PROC 14 - -#define VBATT_FILTER 2 - -#define BATTERY_CB_TYPE_PROC 1 -#define BATTERY_CB_ID_ALL_ACTIV 1 -#define BATTERY_CB_ID_LOW_VOL 2 - -#define BATTERY_LOW 3200 -#define BATTERY_HIGH 4300 - -#define ONCRPC_CHG_GET_GENERAL_STATUS_PROC 12 -#define ONCRPC_CHARGER_API_VERSIONS_PROC 0xffffffff - -#define BATT_RPC_TIMEOUT 5000 /* 5 sec */ - -#define INVALID_BATT_HANDLE -1 - -#define RPC_TYPE_REQ 0 -#define RPC_TYPE_REPLY 1 -#define RPC_REQ_REPLY_COMMON_HEADER_SIZE (3 * sizeof(uint32_t)) - - -#if DEBUG -#define DBG_LIMIT(x...) do {if (printk_ratelimit()) pr_debug(x); } while (0) -#else -#define DBG_LIMIT(x...) do {} while (0) -#endif - -enum { - BATTERY_REGISTRATION_SUCCESSFUL = 0, - BATTERY_DEREGISTRATION_SUCCESSFUL = BATTERY_REGISTRATION_SUCCESSFUL, - BATTERY_MODIFICATION_SUCCESSFUL = BATTERY_REGISTRATION_SUCCESSFUL, - BATTERY_INTERROGATION_SUCCESSFUL = BATTERY_REGISTRATION_SUCCESSFUL, - BATTERY_CLIENT_TABLE_FULL = 1, - BATTERY_REG_PARAMS_WRONG = 2, - BATTERY_DEREGISTRATION_FAILED = 4, - BATTERY_MODIFICATION_FAILED = 8, - BATTERY_INTERROGATION_FAILED = 16, - /* Client's filter could not be set because perhaps it does not exist */ - BATTERY_SET_FILTER_FAILED = 32, - /* Client's could not be found for enabling or disabling the individual - * client */ - BATTERY_ENABLE_DISABLE_INDIVIDUAL_CLIENT_FAILED = 64, - BATTERY_LAST_ERROR = 128, -}; - -enum { - BATTERY_VOLTAGE_UP = 0, - BATTERY_VOLTAGE_DOWN, - BATTERY_VOLTAGE_ABOVE_THIS_LEVEL, - BATTERY_VOLTAGE_BELOW_THIS_LEVEL, - BATTERY_VOLTAGE_LEVEL, - BATTERY_ALL_ACTIVITY, - VBATT_CHG_EVENTS, - BATTERY_VOLTAGE_UNKNOWN, -}; - -/* - * This enum contains defintions of the charger hardware status - */ -enum chg_charger_status_type { - /* The charger is good */ - CHARGER_STATUS_GOOD, - /* The charger is bad */ - CHARGER_STATUS_BAD, - /* The charger is weak */ - CHARGER_STATUS_WEAK, - /* Invalid charger status. */ - CHARGER_STATUS_INVALID -}; - -/* - *This enum contains defintions of the charger hardware type - */ -enum chg_charger_hardware_type { - /* The charger is removed */ - CHARGER_TYPE_NONE, - /* The charger is a regular wall charger */ - CHARGER_TYPE_WALL, - /* The charger is a PC USB */ - CHARGER_TYPE_USB_PC, - /* The charger is a wall USB charger */ - CHARGER_TYPE_USB_WALL, - /* The charger is a USB carkit */ - CHARGER_TYPE_USB_CARKIT, - /* Invalid charger hardware status. */ - CHARGER_TYPE_INVALID -}; - -/* - * This enum contains defintions of the battery status - */ -enum chg_battery_status_type { - /* The battery is good */ - BATTERY_STATUS_GOOD, - /* The battery is cold/hot */ - BATTERY_STATUS_BAD_TEMP, - /* The battery is bad */ - BATTERY_STATUS_BAD, - /* The battery is removed */ - BATTERY_STATUS_REMOVED, /* on v2.2 only */ - BATTERY_STATUS_INVALID_v1 = BATTERY_STATUS_REMOVED, - /* Invalid battery status. */ - BATTERY_STATUS_INVALID -}; - -/* - *This enum contains defintions of the battery voltage level - */ -enum chg_battery_level_type { - /* The battery voltage is dead/very low (less than 3.2V) */ - BATTERY_LEVEL_DEAD, - /* The battery voltage is weak/low (between 3.2V and 3.4V) */ - BATTERY_LEVEL_WEAK, - /* The battery voltage is good/normal(between 3.4V and 4.2V) */ - BATTERY_LEVEL_GOOD, - /* The battery voltage is up to full (close to 4.2V) */ - BATTERY_LEVEL_FULL, - /* Invalid battery voltage level. */ - BATTERY_LEVEL_INVALID -}; - -#ifndef CONFIG_BATTERY_MSM_FAKE -struct rpc_reply_batt_chg_v1 { - struct rpc_reply_hdr hdr; - u32 more_data; - - u32 charger_status; - u32 charger_type; - u32 battery_status; - u32 battery_level; - u32 battery_voltage; - u32 battery_temp; -}; - -struct rpc_reply_batt_chg_v2 { - struct rpc_reply_batt_chg_v1 v1; - - u32 is_charger_valid; - u32 is_charging; - u32 is_battery_valid; - u32 ui_event; -}; - -union rpc_reply_batt_chg { - struct rpc_reply_batt_chg_v1 v1; - struct rpc_reply_batt_chg_v2 v2; -}; - -static union rpc_reply_batt_chg rep_batt_chg; -#endif - -struct msm_battery_info { - u32 voltage_max_design; - u32 voltage_min_design; - u32 voltage_fail_safe; - u32 chg_api_version; - u32 batt_technology; - u32 batt_api_version; - - u32 avail_chg_sources; - u32 current_chg_source; - - u32 batt_status; - u32 batt_health; - u32 charger_valid; - u32 batt_valid; - u32 batt_capacity; /* in percentage */ - - u32 charger_status; - u32 charger_type; - u32 battery_status; - u32 battery_level; - u32 battery_voltage; /* in millie volts */ - u32 battery_temp; /* in celsius */ - - u32(*calculate_capacity) (u32 voltage); - - s32 batt_handle; - - struct power_supply *msm_psy_ac; - struct power_supply *msm_psy_usb; - struct power_supply *msm_psy_batt; - struct power_supply *current_ps; - - struct msm_rpc_client *batt_client; - struct msm_rpc_endpoint *chg_ep; - - wait_queue_head_t wait_q; - - u32 vbatt_modify_reply_avail; - - struct early_suspend early_suspend; -}; - -static struct msm_battery_info msm_batt_info = { - .batt_handle = INVALID_BATT_HANDLE, - .charger_status = CHARGER_STATUS_BAD, - .charger_type = CHARGER_TYPE_INVALID, - .battery_status = BATTERY_STATUS_GOOD, - .battery_level = BATTERY_LEVEL_FULL, - .battery_voltage = BATTERY_HIGH, - .batt_capacity = 100, - .batt_status = POWER_SUPPLY_STATUS_DISCHARGING, - .batt_health = POWER_SUPPLY_HEALTH_GOOD, - .batt_valid = 1, - .battery_temp = 23, - .vbatt_modify_reply_avail = 0, -}; - -static enum power_supply_property msm_power_props[] = { - POWER_SUPPLY_PROP_ONLINE, -}; - -static char *msm_power_supplied_to[] = { - "battery", -}; - -static int msm_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - if (psy->type == POWER_SUPPLY_TYPE_MAINS) { - val->intval = msm_batt_info.current_chg_source & AC_CHG - ? 1 : 0; - } - if (psy->type == POWER_SUPPLY_TYPE_USB) { - val->intval = msm_batt_info.current_chg_source & USB_CHG - ? 1 : 0; - } - break; - default: - return -EINVAL; - } - return 0; -} - -static struct power_supply msm_psy_ac = { - .name = "ac", - .type = POWER_SUPPLY_TYPE_MAINS, - .supplied_to = msm_power_supplied_to, - .num_supplicants = ARRAY_SIZE(msm_power_supplied_to), - .properties = msm_power_props, - .num_properties = ARRAY_SIZE(msm_power_props), - .get_property = msm_power_get_property, -}; - -static struct power_supply msm_psy_usb = { - .name = "usb", - .type = POWER_SUPPLY_TYPE_USB, - .supplied_to = msm_power_supplied_to, - .num_supplicants = ARRAY_SIZE(msm_power_supplied_to), - .properties = msm_power_props, - .num_properties = ARRAY_SIZE(msm_power_props), - .get_property = msm_power_get_property, -}; - -static enum power_supply_property msm_batt_power_props[] = { - POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_HEALTH, - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_TECHNOLOGY, - POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_NOW, - POWER_SUPPLY_PROP_CAPACITY, -}; - -static int msm_batt_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - switch (psp) { - case POWER_SUPPLY_PROP_STATUS: - val->intval = msm_batt_info.batt_status; - break; - case POWER_SUPPLY_PROP_HEALTH: - val->intval = msm_batt_info.batt_health; - break; - case POWER_SUPPLY_PROP_PRESENT: - val->intval = msm_batt_info.batt_valid; - break; - case POWER_SUPPLY_PROP_TECHNOLOGY: - val->intval = msm_batt_info.batt_technology; - break; - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: - val->intval = msm_batt_info.voltage_max_design; - break; - case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: - val->intval = msm_batt_info.voltage_min_design; - break; - case POWER_SUPPLY_PROP_VOLTAGE_NOW: - val->intval = msm_batt_info.battery_voltage; - break; - case POWER_SUPPLY_PROP_CAPACITY: - val->intval = msm_batt_info.batt_capacity; - break; - default: - return -EINVAL; - } - return 0; -} - -static struct power_supply msm_psy_batt = { - .name = "battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = msm_batt_power_props, - .num_properties = ARRAY_SIZE(msm_batt_power_props), - .get_property = msm_batt_power_get_property, -}; - -#ifndef CONFIG_BATTERY_MSM_FAKE -struct msm_batt_get_volt_ret_data { - u32 battery_voltage; -}; - -static int msm_batt_get_volt_ret_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - struct msm_batt_get_volt_ret_data *data_ptr, *buf_ptr; - - data_ptr = (struct msm_batt_get_volt_ret_data *)data; - buf_ptr = (struct msm_batt_get_volt_ret_data *)buf; - - data_ptr->battery_voltage = be32_to_cpu(buf_ptr->battery_voltage); - - return 0; -} - -static u32 msm_batt_get_vbatt_voltage(void) -{ - int rc; - - struct msm_batt_get_volt_ret_data rep; - - rc = msm_rpc_client_req(msm_batt_info.batt_client, - BATTERY_READ_MV_PROC, - NULL, NULL, - msm_batt_get_volt_ret_func, &rep, - msecs_to_jiffies(BATT_RPC_TIMEOUT)); - - if (rc < 0) { - pr_err("%s: FAIL: vbatt get volt. rc=%d\n", __func__, rc); - return 0; - } - - return rep.battery_voltage; -} - -#define be32_to_cpu_self(v) (v = be32_to_cpu(v)) - -static int msm_batt_get_batt_chg_status(void) -{ - int rc; - - struct rpc_req_batt_chg { - struct rpc_request_hdr hdr; - u32 more_data; - } req_batt_chg; - struct rpc_reply_batt_chg_v1 *v1p; - - req_batt_chg.more_data = cpu_to_be32(1); - - memset(&rep_batt_chg, 0, sizeof(rep_batt_chg)); - - v1p = &rep_batt_chg.v1; - rc = msm_rpc_call_reply(msm_batt_info.chg_ep, - ONCRPC_CHG_GET_GENERAL_STATUS_PROC, - &req_batt_chg, sizeof(req_batt_chg), - &rep_batt_chg, sizeof(rep_batt_chg), - msecs_to_jiffies(BATT_RPC_TIMEOUT)); - if (rc < 0) { - pr_err("%s: ERROR. msm_rpc_call_reply failed! proc=%d rc=%d\n", - __func__, ONCRPC_CHG_GET_GENERAL_STATUS_PROC, rc); - return rc; - } else if (be32_to_cpu(v1p->more_data)) { - be32_to_cpu_self(v1p->charger_status); - be32_to_cpu_self(v1p->charger_type); - be32_to_cpu_self(v1p->battery_status); - be32_to_cpu_self(v1p->battery_level); - be32_to_cpu_self(v1p->battery_voltage); - be32_to_cpu_self(v1p->battery_temp); - } else { - pr_err("%s: No battery/charger data in RPC reply\n", __func__); - return -EIO; - } - - return 0; -} - -static void msm_batt_update_psy_status(void) -{ - static u32 unnecessary_event_count; - u32 charger_status; - u32 charger_type; - u32 battery_status; - u32 battery_level; - u32 battery_voltage; - u32 battery_temp; - struct power_supply *supp; - - if (msm_batt_get_batt_chg_status()) - return; - - charger_status = rep_batt_chg.v1.charger_status; - charger_type = rep_batt_chg.v1.charger_type; - battery_status = rep_batt_chg.v1.battery_status; - battery_level = rep_batt_chg.v1.battery_level; - battery_voltage = rep_batt_chg.v1.battery_voltage; - battery_temp = rep_batt_chg.v1.battery_temp; - - /* Make correction for battery status */ - if (battery_status == BATTERY_STATUS_INVALID_v1) { - if (msm_batt_info.chg_api_version < CHG_RPC_VER_3_1) - battery_status = BATTERY_STATUS_INVALID; - } - - if (charger_status == msm_batt_info.charger_status && - charger_type == msm_batt_info.charger_type && - battery_status == msm_batt_info.battery_status && - battery_level == msm_batt_info.battery_level && - battery_voltage == msm_batt_info.battery_voltage && - battery_temp == msm_batt_info.battery_temp) { - /* Got unnecessary event from Modem PMIC VBATT driver. - * Nothing changed in Battery or charger status. - */ - unnecessary_event_count++; - if ((unnecessary_event_count % 20) == 1) - DBG_LIMIT("BATT: same event count = %u\n", - unnecessary_event_count); - return; - } - - unnecessary_event_count = 0; - - DBG_LIMIT("BATT: rcvd: %d, %d, %d, %d; %d, %d\n", - charger_status, charger_type, battery_status, - battery_level, battery_voltage, battery_temp); - - if (battery_status == BATTERY_STATUS_INVALID && - battery_level != BATTERY_LEVEL_INVALID) { - DBG_LIMIT("BATT: change status(%d) to (%d) for level=%d\n", - battery_status, BATTERY_STATUS_GOOD, battery_level); - battery_status = BATTERY_STATUS_GOOD; - } - - if (msm_batt_info.charger_type != charger_type) { - if (charger_type == CHARGER_TYPE_USB_PC || - charger_type == CHARGER_TYPE_USB_CARKIT) { - DBG_LIMIT("BATT: USB charger plugged in\n"); - msm_batt_info.current_chg_source = USB_CHG; - supp = &msm_psy_usb; - } else if (charger_type == CHARGER_TYPE_WALL || - charger_type == CHARGER_TYPE_USB_WALL) { - DBG_LIMIT("BATT: AC Wall changer plugged in\n"); - msm_batt_info.current_chg_source = AC_CHG; - supp = &msm_psy_ac; - } else { - if (msm_batt_info.current_chg_source & AC_CHG) - DBG_LIMIT("BATT: AC Wall charger removed\n"); - else if (msm_batt_info.current_chg_source & USB_CHG) - DBG_LIMIT("BATT: USB charger removed\n"); - else - DBG_LIMIT("BATT: No charger present\n"); - msm_batt_info.current_chg_source = 0; - supp = &msm_psy_batt; - - /* Correct charger status */ - if (charger_status != CHARGER_STATUS_INVALID) { - DBG_LIMIT("BATT: No charging!\n"); - charger_status = CHARGER_STATUS_INVALID; - msm_batt_info.batt_status = - POWER_SUPPLY_STATUS_NOT_CHARGING; - } - } - } else - supp = NULL; - - if (msm_batt_info.charger_status != charger_status) { - if (charger_status == CHARGER_STATUS_GOOD || - charger_status == CHARGER_STATUS_WEAK) { - if (msm_batt_info.current_chg_source) { - DBG_LIMIT("BATT: Charging.\n"); - msm_batt_info.batt_status = - POWER_SUPPLY_STATUS_CHARGING; - - /* Correct when supp==NULL */ - if (msm_batt_info.current_chg_source & AC_CHG) - supp = &msm_psy_ac; - else - supp = &msm_psy_usb; - } - } else { - DBG_LIMIT("BATT: No charging.\n"); - msm_batt_info.batt_status = - POWER_SUPPLY_STATUS_NOT_CHARGING; - supp = &msm_psy_batt; - } - } else { - /* Correct charger status */ - if (charger_type != CHARGER_TYPE_INVALID && - charger_status == CHARGER_STATUS_GOOD) { - DBG_LIMIT("BATT: In charging\n"); - msm_batt_info.batt_status = - POWER_SUPPLY_STATUS_CHARGING; - } - } - - /* Correct battery voltage and status */ - if (!battery_voltage) { - if (charger_status == CHARGER_STATUS_INVALID) { - DBG_LIMIT("BATT: Read VBATT\n"); - battery_voltage = msm_batt_get_vbatt_voltage(); - } else - /* Use previous */ - battery_voltage = msm_batt_info.battery_voltage; - } - if (battery_status == BATTERY_STATUS_INVALID) { - if (battery_voltage >= msm_batt_info.voltage_min_design && - battery_voltage <= msm_batt_info.voltage_max_design) { - DBG_LIMIT("BATT: Battery valid\n"); - msm_batt_info.batt_valid = 1; - battery_status = BATTERY_STATUS_GOOD; - } - } - - if (msm_batt_info.battery_status != battery_status) { - if (battery_status != BATTERY_STATUS_INVALID) { - msm_batt_info.batt_valid = 1; - - if (battery_status == BATTERY_STATUS_BAD) { - DBG_LIMIT("BATT: Battery bad.\n"); - msm_batt_info.batt_health = - POWER_SUPPLY_HEALTH_DEAD; - } else if (battery_status == BATTERY_STATUS_BAD_TEMP) { - DBG_LIMIT("BATT: Battery overheat.\n"); - msm_batt_info.batt_health = - POWER_SUPPLY_HEALTH_OVERHEAT; - } else { - DBG_LIMIT("BATT: Battery good.\n"); - msm_batt_info.batt_health = - POWER_SUPPLY_HEALTH_GOOD; - } - } else { - msm_batt_info.batt_valid = 0; - DBG_LIMIT("BATT: Battery invalid.\n"); - msm_batt_info.batt_health = POWER_SUPPLY_HEALTH_UNKNOWN; - } - - if (msm_batt_info.batt_status != POWER_SUPPLY_STATUS_CHARGING) { - if (battery_status == BATTERY_STATUS_INVALID) { - DBG_LIMIT("BATT: Battery -> unknown\n"); - msm_batt_info.batt_status = - POWER_SUPPLY_STATUS_UNKNOWN; - } else { - DBG_LIMIT("BATT: Battery -> discharging\n"); - msm_batt_info.batt_status = - POWER_SUPPLY_STATUS_DISCHARGING; - } - } - - if (!supp) { - if (msm_batt_info.current_chg_source) { - if (msm_batt_info.current_chg_source & AC_CHG) - supp = &msm_psy_ac; - else - supp = &msm_psy_usb; - } else - supp = &msm_psy_batt; - } - } - - msm_batt_info.charger_status = charger_status; - msm_batt_info.charger_type = charger_type; - msm_batt_info.battery_status = battery_status; - msm_batt_info.battery_level = battery_level; - msm_batt_info.battery_temp = battery_temp; - - if (msm_batt_info.battery_voltage != battery_voltage) { - msm_batt_info.battery_voltage = battery_voltage; - msm_batt_info.batt_capacity = - msm_batt_info.calculate_capacity(battery_voltage); - DBG_LIMIT("BATT: voltage = %u mV [capacity = %d%%]\n", - battery_voltage, msm_batt_info.batt_capacity); - - if (!supp) - supp = msm_batt_info.current_ps; - } - - if (supp) { - msm_batt_info.current_ps = supp; - DBG_LIMIT("BATT: Supply = %s\n", supp->name); - power_supply_changed(supp); - } -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -struct batt_modify_client_req { - - u32 client_handle; - - /* The voltage at which callback (CB) should be called. */ - u32 desired_batt_voltage; - - /* The direction when the CB should be called. */ - u32 voltage_direction; - - /* The registered callback to be called when voltage and - * direction specs are met. */ - u32 batt_cb_id; - - /* The call back data */ - u32 cb_data; -}; - -struct batt_modify_client_rep { - u32 result; -}; - -static int msm_batt_modify_client_arg_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - struct batt_modify_client_req *batt_modify_client_req = - (struct batt_modify_client_req *)data; - u32 *req = (u32 *)buf; - int size = 0; - - *req = cpu_to_be32(batt_modify_client_req->client_handle); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_modify_client_req->desired_batt_voltage); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_modify_client_req->voltage_direction); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_modify_client_req->batt_cb_id); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_modify_client_req->cb_data); - size += sizeof(u32); - - return size; -} - -static int msm_batt_modify_client_ret_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - struct batt_modify_client_rep *data_ptr, *buf_ptr; - - data_ptr = (struct batt_modify_client_rep *)data; - buf_ptr = (struct batt_modify_client_rep *)buf; - - data_ptr->result = be32_to_cpu(buf_ptr->result); - - return 0; -} - -static int msm_batt_modify_client(u32 client_handle, u32 desired_batt_voltage, - u32 voltage_direction, u32 batt_cb_id, u32 cb_data) -{ - int rc; - - struct batt_modify_client_req req; - struct batt_modify_client_rep rep; - - req.client_handle = client_handle; - req.desired_batt_voltage = desired_batt_voltage; - req.voltage_direction = voltage_direction; - req.batt_cb_id = batt_cb_id; - req.cb_data = cb_data; - - rc = msm_rpc_client_req(msm_batt_info.batt_client, - BATTERY_MODIFY_CLIENT_PROC, - msm_batt_modify_client_arg_func, &req, - msm_batt_modify_client_ret_func, &rep, - msecs_to_jiffies(BATT_RPC_TIMEOUT)); - - if (rc < 0) { - pr_err("%s: ERROR. failed to modify Vbatt client\n", - __func__); - return rc; - } - - if (rep.result != BATTERY_MODIFICATION_SUCCESSFUL) { - pr_err("%s: ERROR. modify client failed. result = %u\n", - __func__, rep.result); - return -EIO; - } - - return 0; -} - -void msm_batt_early_suspend(struct early_suspend *h) -{ - int rc; - - pr_debug("%s: enter\n", __func__); - - if (msm_batt_info.batt_handle != INVALID_BATT_HANDLE) { - rc = msm_batt_modify_client(msm_batt_info.batt_handle, - msm_batt_info.voltage_fail_safe, - BATTERY_VOLTAGE_BELOW_THIS_LEVEL, - BATTERY_CB_ID_LOW_VOL, - msm_batt_info.voltage_fail_safe); - - if (rc < 0) { - pr_err("%s: msm_batt_modify_client. rc=%d\n", - __func__, rc); - return; - } - } else { - pr_err("%s: ERROR. invalid batt_handle\n", __func__); - return; - } - - pr_debug("%s: exit\n", __func__); -} - -void msm_batt_late_resume(struct early_suspend *h) -{ - int rc; - - pr_debug("%s: enter\n", __func__); - - if (msm_batt_info.batt_handle != INVALID_BATT_HANDLE) { - rc = msm_batt_modify_client(msm_batt_info.batt_handle, - msm_batt_info.voltage_fail_safe, - BATTERY_ALL_ACTIVITY, - BATTERY_CB_ID_ALL_ACTIV, BATTERY_ALL_ACTIVITY); - if (rc < 0) { - pr_err("%s: msm_batt_modify_client FAIL rc=%d\n", - __func__, rc); - return; - } - } else { - pr_err("%s: ERROR. invalid batt_handle\n", __func__); - return; - } - - msm_batt_update_psy_status(); - pr_debug("%s: exit\n", __func__); -} -#endif - -struct msm_batt_vbatt_filter_req { - u32 batt_handle; - u32 enable_filter; - u32 vbatt_filter; -}; - -struct msm_batt_vbatt_filter_rep { - u32 result; -}; - -static int msm_batt_filter_arg_func(struct msm_rpc_client *batt_client, - - void *buf, void *data) -{ - struct msm_batt_vbatt_filter_req *vbatt_filter_req = - (struct msm_batt_vbatt_filter_req *)data; - u32 *req = (u32 *)buf; - int size = 0; - - *req = cpu_to_be32(vbatt_filter_req->batt_handle); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(vbatt_filter_req->enable_filter); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(vbatt_filter_req->vbatt_filter); - size += sizeof(u32); - return size; -} - -static int msm_batt_filter_ret_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - - struct msm_batt_vbatt_filter_rep *data_ptr, *buf_ptr; - - data_ptr = (struct msm_batt_vbatt_filter_rep *)data; - buf_ptr = (struct msm_batt_vbatt_filter_rep *)buf; - - data_ptr->result = be32_to_cpu(buf_ptr->result); - return 0; -} - -static int msm_batt_enable_filter(u32 vbatt_filter) -{ - int rc; - struct msm_batt_vbatt_filter_req vbatt_filter_req; - struct msm_batt_vbatt_filter_rep vbatt_filter_rep; - - vbatt_filter_req.batt_handle = msm_batt_info.batt_handle; - vbatt_filter_req.enable_filter = 1; - vbatt_filter_req.vbatt_filter = vbatt_filter; - - rc = msm_rpc_client_req(msm_batt_info.batt_client, - BATTERY_ENABLE_DISABLE_FILTER_PROC, - msm_batt_filter_arg_func, &vbatt_filter_req, - msm_batt_filter_ret_func, &vbatt_filter_rep, - msecs_to_jiffies(BATT_RPC_TIMEOUT)); - - if (rc < 0) { - pr_err("%s: FAIL: enable vbatt filter. rc=%d\n", - __func__, rc); - return rc; - } - - if (vbatt_filter_rep.result != BATTERY_DEREGISTRATION_SUCCESSFUL) { - pr_err("%s: FAIL: enable vbatt filter: result=%d\n", - __func__, vbatt_filter_rep.result); - return -EIO; - } - - pr_debug("%s: enable vbatt filter: OK\n", __func__); - return rc; -} - -struct batt_client_registration_req { - /* The voltage at which callback (CB) should be called. */ - u32 desired_batt_voltage; - - /* The direction when the CB should be called. */ - u32 voltage_direction; - - /* The registered callback to be called when voltage and - * direction specs are met. */ - u32 batt_cb_id; - - /* The call back data */ - u32 cb_data; - u32 more_data; - u32 batt_error; -}; - -struct batt_client_registration_req_4_1 { - /* The voltage at which callback (CB) should be called. */ - u32 desired_batt_voltage; - - /* The direction when the CB should be called. */ - u32 voltage_direction; - - /* The registered callback to be called when voltage and - * direction specs are met. */ - u32 batt_cb_id; - - /* The call back data */ - u32 cb_data; - u32 batt_error; -}; - -struct batt_client_registration_rep { - u32 batt_handle; -}; - -struct batt_client_registration_rep_4_1 { - u32 batt_handle; - u32 more_data; - u32 err; -}; - -static int msm_batt_register_arg_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - struct batt_client_registration_req *batt_reg_req = - (struct batt_client_registration_req *)data; - - u32 *req = (u32 *)buf; - int size = 0; - - - if (msm_batt_info.batt_api_version == BATTERY_RPC_VER_4_1) { - *req = cpu_to_be32(batt_reg_req->desired_batt_voltage); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->voltage_direction); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->batt_cb_id); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->cb_data); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->batt_error); - size += sizeof(u32); - - return size; - } else { - *req = cpu_to_be32(batt_reg_req->desired_batt_voltage); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->voltage_direction); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->batt_cb_id); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->cb_data); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->more_data); - size += sizeof(u32); - req++; - - *req = cpu_to_be32(batt_reg_req->batt_error); - size += sizeof(u32); - - return size; - } - -} - -static int msm_batt_register_ret_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - struct batt_client_registration_rep *data_ptr, *buf_ptr; - struct batt_client_registration_rep_4_1 *data_ptr_4_1, *buf_ptr_4_1; - - if (msm_batt_info.batt_api_version == BATTERY_RPC_VER_4_1) { - data_ptr_4_1 = (struct batt_client_registration_rep_4_1 *)data; - buf_ptr_4_1 = (struct batt_client_registration_rep_4_1 *)buf; - - data_ptr_4_1->batt_handle - = be32_to_cpu(buf_ptr_4_1->batt_handle); - data_ptr_4_1->more_data - = be32_to_cpu(buf_ptr_4_1->more_data); - data_ptr_4_1->err = be32_to_cpu(buf_ptr_4_1->err); - return 0; - } else { - data_ptr = (struct batt_client_registration_rep *)data; - buf_ptr = (struct batt_client_registration_rep *)buf; - - data_ptr->batt_handle = be32_to_cpu(buf_ptr->batt_handle); - return 0; - } -} - -static int msm_batt_register(u32 desired_batt_voltage, - u32 voltage_direction, u32 batt_cb_id, u32 cb_data) -{ - struct batt_client_registration_req batt_reg_req; - struct batt_client_registration_req_4_1 batt_reg_req_4_1; - struct batt_client_registration_rep batt_reg_rep; - struct batt_client_registration_rep_4_1 batt_reg_rep_4_1; - void *request; - void *reply; - int rc; - - if (msm_batt_info.batt_api_version == BATTERY_RPC_VER_4_1) { - batt_reg_req_4_1.desired_batt_voltage = desired_batt_voltage; - batt_reg_req_4_1.voltage_direction = voltage_direction; - batt_reg_req_4_1.batt_cb_id = batt_cb_id; - batt_reg_req_4_1.cb_data = cb_data; - batt_reg_req_4_1.batt_error = 1; - request = &batt_reg_req_4_1; - } else { - batt_reg_req.desired_batt_voltage = desired_batt_voltage; - batt_reg_req.voltage_direction = voltage_direction; - batt_reg_req.batt_cb_id = batt_cb_id; - batt_reg_req.cb_data = cb_data; - batt_reg_req.more_data = 1; - batt_reg_req.batt_error = 0; - request = &batt_reg_req; - } - - if (msm_batt_info.batt_api_version == BATTERY_RPC_VER_4_1) - reply = &batt_reg_rep_4_1; - else - reply = &batt_reg_rep; - - rc = msm_rpc_client_req(msm_batt_info.batt_client, - BATTERY_REGISTER_PROC, - msm_batt_register_arg_func, request, - msm_batt_register_ret_func, reply, - msecs_to_jiffies(BATT_RPC_TIMEOUT)); - - if (rc < 0) { - pr_err("%s: FAIL: vbatt register. rc=%d\n", __func__, rc); - return rc; - } - - if (msm_batt_info.batt_api_version == BATTERY_RPC_VER_4_1) { - if (batt_reg_rep_4_1.more_data != 0 - && batt_reg_rep_4_1.err - != BATTERY_REGISTRATION_SUCCESSFUL) { - pr_err("%s: vBatt Registration Failed proc_num=%d\n" - , __func__, BATTERY_REGISTER_PROC); - return -EIO; - } - msm_batt_info.batt_handle = batt_reg_rep_4_1.batt_handle; - } else - msm_batt_info.batt_handle = batt_reg_rep.batt_handle; - - return 0; -} - -struct batt_client_deregister_req { - u32 batt_handle; -}; - -struct batt_client_deregister_rep { - u32 batt_error; -}; - -static int msm_batt_deregister_arg_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - struct batt_client_deregister_req *deregister_req = - (struct batt_client_deregister_req *)data; - u32 *req = (u32 *)buf; - int size = 0; - - *req = cpu_to_be32(deregister_req->batt_handle); - size += sizeof(u32); - - return size; -} - -static int msm_batt_deregister_ret_func(struct msm_rpc_client *batt_client, - void *buf, void *data) -{ - struct batt_client_deregister_rep *data_ptr, *buf_ptr; - - data_ptr = (struct batt_client_deregister_rep *)data; - buf_ptr = (struct batt_client_deregister_rep *)buf; - - data_ptr->batt_error = be32_to_cpu(buf_ptr->batt_error); - - return 0; -} - -static int msm_batt_deregister(u32 batt_handle) -{ - int rc; - struct batt_client_deregister_req req; - struct batt_client_deregister_rep rep; - - req.batt_handle = batt_handle; - - rc = msm_rpc_client_req(msm_batt_info.batt_client, - BATTERY_DEREGISTER_CLIENT_PROC, - msm_batt_deregister_arg_func, &req, - msm_batt_deregister_ret_func, &rep, - msecs_to_jiffies(BATT_RPC_TIMEOUT)); - - if (rc < 0) { - pr_err("%s: FAIL: vbatt deregister. rc=%d\n", __func__, rc); - return rc; - } - - if (rep.batt_error != BATTERY_DEREGISTRATION_SUCCESSFUL) { - pr_err("%s: vbatt deregistration FAIL. error=%d, handle=%d\n", - __func__, rep.batt_error, batt_handle); - return -EIO; - } - - return 0; -} -#endif /* CONFIG_BATTERY_MSM_FAKE */ - -static int msm_batt_cleanup(void) -{ - int rc = 0; - -#ifndef CONFIG_BATTERY_MSM_FAKE - if (msm_batt_info.batt_handle != INVALID_BATT_HANDLE) { - - rc = msm_batt_deregister(msm_batt_info.batt_handle); - if (rc < 0) - pr_err("%s: FAIL: msm_batt_deregister. rc=%d\n", - __func__, rc); - } - - msm_batt_info.batt_handle = INVALID_BATT_HANDLE; - - if (msm_batt_info.batt_client) - msm_rpc_unregister_client(msm_batt_info.batt_client); -#endif /* CONFIG_BATTERY_MSM_FAKE */ - - if (msm_batt_info.msm_psy_ac) - power_supply_unregister(msm_batt_info.msm_psy_ac); - - if (msm_batt_info.msm_psy_usb) - power_supply_unregister(msm_batt_info.msm_psy_usb); - if (msm_batt_info.msm_psy_batt) - power_supply_unregister(msm_batt_info.msm_psy_batt); - -#ifndef CONFIG_BATTERY_MSM_FAKE - if (msm_batt_info.chg_ep) { - rc = msm_rpc_close(msm_batt_info.chg_ep); - if (rc < 0) { - pr_err("%s: FAIL. msm_rpc_close(chg_ep). rc=%d\n", - __func__, rc); - } - } - -#ifdef CONFIG_HAS_EARLYSUSPEND - if (msm_batt_info.early_suspend.suspend == msm_batt_early_suspend) - unregister_early_suspend(&msm_batt_info.early_suspend); -#endif -#endif - return rc; -} - -static u32 msm_batt_capacity(u32 current_voltage) -{ - u32 low_voltage = msm_batt_info.voltage_min_design; - u32 high_voltage = msm_batt_info.voltage_max_design; - - if (current_voltage <= low_voltage) - return 0; - else if (current_voltage >= high_voltage) - return 100; - else - return (current_voltage - low_voltage) * 100 - / (high_voltage - low_voltage); -} - -#ifndef CONFIG_BATTERY_MSM_FAKE -int msm_batt_get_charger_api_version(void) -{ - int rc ; - struct rpc_reply_hdr *reply; - - struct rpc_req_chg_api_ver { - struct rpc_request_hdr hdr; - u32 more_data; - } req_chg_api_ver; - - struct rpc_rep_chg_api_ver { - struct rpc_reply_hdr hdr; - u32 num_of_chg_api_versions; - u32 *chg_api_versions; - }; - - u32 num_of_versions; - - struct rpc_rep_chg_api_ver *rep_chg_api_ver; - - - req_chg_api_ver.more_data = cpu_to_be32(1); - - msm_rpc_setup_req(&req_chg_api_ver.hdr, CHG_RPC_PROG, CHG_RPC_VER_1_1, - ONCRPC_CHARGER_API_VERSIONS_PROC); - - rc = msm_rpc_write(msm_batt_info.chg_ep, &req_chg_api_ver, - sizeof(req_chg_api_ver)); - if (rc < 0) { - pr_err("%s: FAIL: msm_rpc_write. proc=0x%08x, rc=%d\n", - __func__, ONCRPC_CHARGER_API_VERSIONS_PROC, rc); - return rc; - } - - for (;;) { - rc = msm_rpc_read(msm_batt_info.chg_ep, (void *) &reply, -1, - BATT_RPC_TIMEOUT); - if (rc < 0) - return rc; - if (rc < RPC_REQ_REPLY_COMMON_HEADER_SIZE) { - pr_err("%s: LENGTH ERR: msm_rpc_read. rc=%d (<%d)\n", - __func__, rc, RPC_REQ_REPLY_COMMON_HEADER_SIZE); - - rc = -EIO; - break; - } - /* we should not get RPC REQ or call packets -- ignore them */ - if (reply->type == RPC_TYPE_REQ) { - pr_err("%s: TYPE ERR: type=%d (!=%d)\n", - __func__, reply->type, RPC_TYPE_REQ); - kfree(reply); - continue; - } - - /* If an earlier call timed out, we could get the (no - * longer wanted) reply for it. Ignore replies that - * we don't expect - */ - if (reply->xid != req_chg_api_ver.hdr.xid) { - pr_err("%s: XID ERR: xid=%d (!=%d)\n", __func__, - reply->xid, req_chg_api_ver.hdr.xid); - kfree(reply); - continue; - } - if (reply->reply_stat != RPCMSG_REPLYSTAT_ACCEPTED) { - rc = -EPERM; - break; - } - if (reply->data.acc_hdr.accept_stat != - RPC_ACCEPTSTAT_SUCCESS) { - rc = -EINVAL; - break; - } - - rep_chg_api_ver = (struct rpc_rep_chg_api_ver *)reply; - - num_of_versions = - be32_to_cpu(rep_chg_api_ver->num_of_chg_api_versions); - - rep_chg_api_ver->chg_api_versions = (u32 *) - ((u8 *) reply + sizeof(struct rpc_reply_hdr) + - sizeof(rep_chg_api_ver->num_of_chg_api_versions)); - - rc = be32_to_cpu( - rep_chg_api_ver->chg_api_versions[num_of_versions - 1]); - - pr_debug("%s: num_of_chg_api_versions = %u. " - "The chg api version = 0x%08x\n", __func__, - num_of_versions, rc); - break; - } - kfree(reply); - return rc; -} - -static int msm_batt_cb_func(struct msm_rpc_client *client, - void *buffer, int in_size) -{ - int rc = 0; - struct rpc_request_hdr *req; - u32 procedure; - u32 accept_status; - - req = (struct rpc_request_hdr *)buffer; - procedure = be32_to_cpu(req->procedure); - - switch (procedure) { - case BATTERY_CB_TYPE_PROC: - accept_status = RPC_ACCEPTSTAT_SUCCESS; - break; - - default: - accept_status = RPC_ACCEPTSTAT_PROC_UNAVAIL; - pr_err("%s: ERROR. procedure (%d) not supported\n", - __func__, procedure); - break; - } - - msm_rpc_start_accepted_reply(msm_batt_info.batt_client, - be32_to_cpu(req->xid), accept_status); - - rc = msm_rpc_send_accepted_reply(msm_batt_info.batt_client, 0); - if (rc) - pr_err("%s: FAIL: sending reply. rc=%d\n", __func__, rc); - - if (accept_status == RPC_ACCEPTSTAT_SUCCESS) - msm_batt_update_psy_status(); - - return rc; -} -#endif /* CONFIG_BATTERY_MSM_FAKE */ - -static int msm_batt_probe(struct platform_device *pdev) -{ - int rc; - struct msm_psy_batt_pdata *pdata = pdev->dev.platform_data; - - if (pdev->id != -1) { - dev_err(&pdev->dev, - "%s: MSM chipsets Can only support one" - " battery ", __func__); - return -EINVAL; - } - -#ifndef CONFIG_BATTERY_MSM_FAKE - if (pdata->avail_chg_sources & AC_CHG) { -#else - { -#endif - rc = power_supply_register(&pdev->dev, &msm_psy_ac); - if (rc < 0) { - dev_err(&pdev->dev, - "%s: power_supply_register failed" - " rc = %d\n", __func__, rc); - msm_batt_cleanup(); - return rc; - } - msm_batt_info.msm_psy_ac = &msm_psy_ac; - msm_batt_info.avail_chg_sources |= AC_CHG; - } - - if (pdata->avail_chg_sources & USB_CHG) { - rc = power_supply_register(&pdev->dev, &msm_psy_usb); - if (rc < 0) { - dev_err(&pdev->dev, - "%s: power_supply_register failed" - " rc = %d\n", __func__, rc); - msm_batt_cleanup(); - return rc; - } - msm_batt_info.msm_psy_usb = &msm_psy_usb; - msm_batt_info.avail_chg_sources |= USB_CHG; - } - - if (!msm_batt_info.msm_psy_ac && !msm_batt_info.msm_psy_usb) { - - dev_err(&pdev->dev, - "%s: No external Power supply(AC or USB)" - "is avilable\n", __func__); - msm_batt_cleanup(); - return -ENODEV; - } - - msm_batt_info.voltage_max_design = pdata->voltage_max_design; - msm_batt_info.voltage_min_design = pdata->voltage_min_design; - msm_batt_info.voltage_fail_safe = pdata->voltage_fail_safe; - - msm_batt_info.batt_technology = pdata->batt_technology; - msm_batt_info.calculate_capacity = pdata->calculate_capacity; - - if (!msm_batt_info.voltage_min_design) - msm_batt_info.voltage_min_design = BATTERY_LOW; - if (!msm_batt_info.voltage_max_design) - msm_batt_info.voltage_max_design = BATTERY_HIGH; - if (!msm_batt_info.voltage_fail_safe) - msm_batt_info.voltage_fail_safe = BATTERY_LOW; - - if (msm_batt_info.batt_technology == POWER_SUPPLY_TECHNOLOGY_UNKNOWN) - msm_batt_info.batt_technology = POWER_SUPPLY_TECHNOLOGY_LION; - - if (!msm_batt_info.calculate_capacity) - msm_batt_info.calculate_capacity = msm_batt_capacity; - - rc = power_supply_register(&pdev->dev, &msm_psy_batt); - if (rc < 0) { - dev_err(&pdev->dev, "%s: power_supply_register failed" - " rc=%d\n", __func__, rc); - msm_batt_cleanup(); - return rc; - } - msm_batt_info.msm_psy_batt = &msm_psy_batt; - -#ifndef CONFIG_BATTERY_MSM_FAKE - rc = msm_batt_register(msm_batt_info.voltage_fail_safe, - BATTERY_ALL_ACTIVITY, - BATTERY_CB_ID_ALL_ACTIV, - BATTERY_ALL_ACTIVITY); - if (rc < 0) { - dev_err(&pdev->dev, - "%s: msm_batt_register failed rc = %d\n", __func__, rc); - msm_batt_cleanup(); - return rc; - } - - rc = msm_batt_enable_filter(VBATT_FILTER); - - if (rc < 0) { - dev_err(&pdev->dev, - "%s: msm_batt_enable_filter failed rc = %d\n", - __func__, rc); - msm_batt_cleanup(); - return rc; - } - -#ifdef CONFIG_HAS_EARLYSUSPEND - msm_batt_info.early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN; - msm_batt_info.early_suspend.suspend = msm_batt_early_suspend; - msm_batt_info.early_suspend.resume = msm_batt_late_resume; - register_early_suspend(&msm_batt_info.early_suspend); -#endif - msm_batt_update_psy_status(); - -#else - power_supply_changed(&msm_psy_ac); -#endif /* CONFIG_BATTERY_MSM_FAKE */ - - return 0; -} - -static int msm_batt_remove(struct platform_device *pdev) -{ - int rc; - rc = msm_batt_cleanup(); - - if (rc < 0) { - dev_err(&pdev->dev, - "%s: msm_batt_cleanup failed rc=%d\n", __func__, rc); - return rc; - } - return 0; -} - -static struct platform_driver msm_batt_driver = { - .probe = msm_batt_probe, - .remove = msm_batt_remove, - .driver = { - .name = "msm-battery", - .owner = THIS_MODULE, - }, -}; - -static int msm_batt_init_rpc(void) -{ - int rc; - -#ifdef CONFIG_BATTERY_MSM_FAKE - pr_info("Faking MSM battery\n"); -#else - - msm_batt_info.chg_ep = - msm_rpc_connect_compatible(CHG_RPC_PROG, CHG_RPC_VER_4_1, 0); - msm_batt_info.chg_api_version = CHG_RPC_VER_4_1; - if (msm_batt_info.chg_ep == NULL) { - pr_err("%s: rpc connect CHG_RPC_PROG = NULL\n", __func__); - return -ENODEV; - } - - if (IS_ERR(msm_batt_info.chg_ep)) { - msm_batt_info.chg_ep = msm_rpc_connect_compatible( - CHG_RPC_PROG, CHG_RPC_VER_3_1, 0); - msm_batt_info.chg_api_version = CHG_RPC_VER_3_1; - } - if (IS_ERR(msm_batt_info.chg_ep)) { - msm_batt_info.chg_ep = msm_rpc_connect_compatible( - CHG_RPC_PROG, CHG_RPC_VER_1_1, 0); - msm_batt_info.chg_api_version = CHG_RPC_VER_1_1; - } - if (IS_ERR(msm_batt_info.chg_ep)) { - msm_batt_info.chg_ep = msm_rpc_connect_compatible( - CHG_RPC_PROG, CHG_RPC_VER_1_3, 0); - msm_batt_info.chg_api_version = CHG_RPC_VER_1_3; - } - if (IS_ERR(msm_batt_info.chg_ep)) { - msm_batt_info.chg_ep = msm_rpc_connect_compatible( - CHG_RPC_PROG, CHG_RPC_VER_2_2, 0); - msm_batt_info.chg_api_version = CHG_RPC_VER_2_2; - } - if (IS_ERR(msm_batt_info.chg_ep)) { - rc = PTR_ERR(msm_batt_info.chg_ep); - pr_err("%s: FAIL: rpc connect for CHG_RPC_PROG. rc=%d\n", - __func__, rc); - msm_batt_info.chg_ep = NULL; - return rc; - } - - /* Get the real 1.x version */ - if (msm_batt_info.chg_api_version == CHG_RPC_VER_1_1) - msm_batt_info.chg_api_version = - msm_batt_get_charger_api_version(); - - /* Fall back to 1.1 for default */ - if (msm_batt_info.chg_api_version < 0) - msm_batt_info.chg_api_version = CHG_RPC_VER_1_1; - msm_batt_info.batt_api_version = BATTERY_RPC_VER_4_1; - - msm_batt_info.batt_client = - msm_rpc_register_client("battery", BATTERY_RPC_PROG, - BATTERY_RPC_VER_4_1, - 1, msm_batt_cb_func); - - if (msm_batt_info.batt_client == NULL) { - pr_err("%s: FAIL: rpc_register_client. batt_client=NULL\n", - __func__); - return -ENODEV; - } - if (IS_ERR(msm_batt_info.batt_client)) { - msm_batt_info.batt_client = - msm_rpc_register_client("battery", BATTERY_RPC_PROG, - BATTERY_RPC_VER_1_1, - 1, msm_batt_cb_func); - msm_batt_info.batt_api_version = BATTERY_RPC_VER_1_1; - } - if (IS_ERR(msm_batt_info.batt_client)) { - msm_batt_info.batt_client = - msm_rpc_register_client("battery", BATTERY_RPC_PROG, - BATTERY_RPC_VER_2_1, - 1, msm_batt_cb_func); - msm_batt_info.batt_api_version = BATTERY_RPC_VER_2_1; - } - if (IS_ERR(msm_batt_info.batt_client)) { - msm_batt_info.batt_client = - msm_rpc_register_client("battery", BATTERY_RPC_PROG, - BATTERY_RPC_VER_5_1, - 1, msm_batt_cb_func); - msm_batt_info.batt_api_version = BATTERY_RPC_VER_5_1; - } - if (IS_ERR(msm_batt_info.batt_client)) { - rc = PTR_ERR(msm_batt_info.batt_client); - pr_err("%s: ERROR: rpc_register_client: rc = %d\n ", - __func__, rc); - msm_batt_info.batt_client = NULL; - return rc; - } -#endif /* CONFIG_BATTERY_MSM_FAKE */ - - rc = platform_driver_register(&msm_batt_driver); - - if (rc < 0) - pr_err("%s: FAIL: platform_driver_register. rc = %d\n", - __func__, rc); - - return rc; -} - -static int __init msm_batt_init(void) -{ - int rc; - - pr_debug("%s: enter\n", __func__); - - rc = msm_batt_init_rpc(); - - if (rc < 0) { - pr_err("%s: FAIL: msm_batt_init_rpc. rc=%d\n", __func__, rc); - msm_batt_cleanup(); - return rc; - } - - pr_info("%s: Charger/Battery = 0x%08x/0x%08x (RPC version)\n", - __func__, msm_batt_info.chg_api_version, - msm_batt_info.batt_api_version); - - return 0; -} - -static void __exit msm_batt_exit(void) -{ - platform_driver_unregister(&msm_batt_driver); -} - -module_init(msm_batt_init); -module_exit(msm_batt_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Kiran Kandi, Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("Battery driver for Qualcomm MSM chipsets."); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:msm_battery"); diff --git a/drivers/power/msm_charger.c b/drivers/power/msm_charger.c deleted file mode 100644 index 8449b1bb4edb9b402bc82eee53855cea49bca651..0000000000000000000000000000000000000000 --- a/drivers/power/msm_charger.c +++ /dev/null @@ -1,1286 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#define MSM_CHG_MAX_EVENTS 16 -#define CHARGING_TEOC_MS 9000000 -#define UPDATE_TIME_MS 60000 -#define RESUME_CHECK_PERIOD_MS 60000 - -#define DEFAULT_BATT_MAX_V 4200 -#define DEFAULT_BATT_MIN_V 3200 - -#define MSM_CHARGER_GAUGE_MISSING_VOLTS 3500 -#define MSM_CHARGER_GAUGE_MISSING_TEMP 35 -/** - * enum msm_battery_status - * @BATT_STATUS_ABSENT: battery not present - * @BATT_STATUS_ID_INVALID: battery present but the id is invalid - * @BATT_STATUS_DISCHARGING: battery is present and is discharging - * @BATT_STATUS_TRKL_CHARGING: battery is being trickle charged - * @BATT_STATUS_FAST_CHARGING: battery is being fast charged - * @BATT_STATUS_JUST_FINISHED_CHARGING: just finished charging, - * battery is fully charged. Do not begin charging untill the - * voltage falls below a threshold to avoid overcharging - * @BATT_STATUS_TEMPERATURE_OUT_OF_RANGE: battery present, - no charging, temp is hot/cold - */ -enum msm_battery_status { - BATT_STATUS_ABSENT, - BATT_STATUS_ID_INVALID, - BATT_STATUS_DISCHARGING, - BATT_STATUS_TRKL_CHARGING, - BATT_STATUS_FAST_CHARGING, - BATT_STATUS_JUST_FINISHED_CHARGING, - BATT_STATUS_TEMPERATURE_OUT_OF_RANGE, -}; - -struct msm_hardware_charger_priv { - struct list_head list; - struct msm_hardware_charger *hw_chg; - enum msm_hardware_charger_state hw_chg_state; - unsigned int max_source_current; - struct power_supply psy; -}; - -struct msm_charger_event { - enum msm_hardware_charger_event event; - struct msm_hardware_charger *hw_chg; -}; - -struct msm_charger_mux { - int inited; - struct list_head msm_hardware_chargers; - int count_chargers; - struct mutex msm_hardware_chargers_lock; - - struct device *dev; - - unsigned int max_voltage; - unsigned int min_voltage; - - unsigned int safety_time; - struct delayed_work teoc_work; - - unsigned int update_time; - int stop_update; - struct delayed_work update_heartbeat_work; - - struct mutex status_lock; - enum msm_battery_status batt_status; - struct msm_hardware_charger_priv *current_chg_priv; - struct msm_hardware_charger_priv *current_mon_priv; - - unsigned int (*get_batt_capacity_percent) (void); - - struct msm_charger_event *queue; - int tail; - int head; - spinlock_t queue_lock; - int queue_count; - struct work_struct queue_work; - struct workqueue_struct *event_wq_thread; - struct wake_lock wl; -}; - -static struct msm_charger_mux msm_chg; - -static struct msm_battery_gauge *msm_batt_gauge; - -static int is_chg_capable_of_charging(struct msm_hardware_charger_priv *priv) -{ - if (priv->hw_chg_state == CHG_READY_STATE - || priv->hw_chg_state == CHG_CHARGING_STATE) - return 1; - - return 0; -} - -static int is_batt_status_capable_of_charging(void) -{ - if (msm_chg.batt_status == BATT_STATUS_ABSENT - || msm_chg.batt_status == BATT_STATUS_TEMPERATURE_OUT_OF_RANGE - || msm_chg.batt_status == BATT_STATUS_ID_INVALID - || msm_chg.batt_status == BATT_STATUS_JUST_FINISHED_CHARGING) - return 0; - return 1; -} - -static int is_batt_status_charging(void) -{ - if (msm_chg.batt_status == BATT_STATUS_TRKL_CHARGING - || msm_chg.batt_status == BATT_STATUS_FAST_CHARGING) - return 1; - return 0; -} - -static int is_battery_present(void) -{ - if (msm_batt_gauge && msm_batt_gauge->is_battery_present) - return msm_batt_gauge->is_battery_present(); - else { - pr_err("msm-charger: no batt gauge batt=absent\n"); - return 0; - } -} - -static int is_battery_temp_within_range(void) -{ - if (msm_batt_gauge && msm_batt_gauge->is_battery_temp_within_range) - return msm_batt_gauge->is_battery_temp_within_range(); - else { - pr_err("msm-charger no batt gauge batt=out_of_temperatur\n"); - return 0; - } -} - -static int is_battery_id_valid(void) -{ - if (msm_batt_gauge && msm_batt_gauge->is_battery_id_valid) - return msm_batt_gauge->is_battery_id_valid(); - else { - pr_err("msm-charger no batt gauge batt=id_invalid\n"); - return 0; - } -} - -static int get_prop_battery_mvolts(void) -{ - if (msm_batt_gauge && msm_batt_gauge->get_battery_mvolts) - return msm_batt_gauge->get_battery_mvolts(); - else { - pr_err("msm-charger no batt gauge assuming 3.5V\n"); - return MSM_CHARGER_GAUGE_MISSING_VOLTS; - } -} - -static int get_battery_temperature(void) -{ - if (msm_batt_gauge && msm_batt_gauge->get_battery_temperature) - return msm_batt_gauge->get_battery_temperature(); - else { - pr_err("msm-charger no batt gauge assuming 35 deg G\n"); - return MSM_CHARGER_GAUGE_MISSING_TEMP; - } -} - -static int get_prop_batt_capacity(void) -{ - int capacity; - - if (msm_batt_gauge && msm_batt_gauge->get_batt_remaining_capacity) - capacity = msm_batt_gauge->get_batt_remaining_capacity(); - else - capacity = msm_chg.get_batt_capacity_percent(); - - if (capacity <= 10) - pr_err("battery capacity very low = %d\n", capacity); - - return capacity; -} - -static int get_prop_batt_health(void) -{ - int status = 0; - - if (msm_chg.batt_status == BATT_STATUS_TEMPERATURE_OUT_OF_RANGE) - status = POWER_SUPPLY_HEALTH_OVERHEAT; - else - status = POWER_SUPPLY_HEALTH_GOOD; - - return status; -} - -static int get_prop_charge_type(void) -{ - int status = 0; - - if (msm_chg.batt_status == BATT_STATUS_TRKL_CHARGING) - status = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; - else if (msm_chg.batt_status == BATT_STATUS_FAST_CHARGING) - status = POWER_SUPPLY_CHARGE_TYPE_FAST; - else - status = POWER_SUPPLY_CHARGE_TYPE_NONE; - - return status; -} - -static int get_prop_batt_status(void) -{ - int status = 0; - - if (msm_batt_gauge && msm_batt_gauge->get_battery_status) { - status = msm_batt_gauge->get_battery_status(); - if (status == POWER_SUPPLY_STATUS_CHARGING || - status == POWER_SUPPLY_STATUS_FULL || - status == POWER_SUPPLY_STATUS_DISCHARGING) - return status; - } - - if (is_batt_status_charging()) - status = POWER_SUPPLY_STATUS_CHARGING; - else if (msm_chg.batt_status == - BATT_STATUS_JUST_FINISHED_CHARGING - && msm_chg.current_chg_priv != NULL) - status = POWER_SUPPLY_STATUS_FULL; - else - status = POWER_SUPPLY_STATUS_DISCHARGING; - - return status; -} - - /* This function should only be called within handle_event or resume */ -static void update_batt_status(void) -{ - if (is_battery_present()) { - if (is_battery_id_valid()) { - if (msm_chg.batt_status == BATT_STATUS_ABSENT - || msm_chg.batt_status - == BATT_STATUS_ID_INVALID) { - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - } - } else - msm_chg.batt_status = BATT_STATUS_ID_INVALID; - } else - msm_chg.batt_status = BATT_STATUS_ABSENT; -} - -static enum power_supply_property msm_power_props[] = { - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_ONLINE, -}; - -static char *msm_power_supplied_to[] = { - "battery", -}; - -static int msm_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct msm_hardware_charger_priv *priv; - - priv = container_of(psy, struct msm_hardware_charger_priv, psy); - switch (psp) { - case POWER_SUPPLY_PROP_PRESENT: - val->intval = !(priv->hw_chg_state == CHG_ABSENT_STATE); - break; - case POWER_SUPPLY_PROP_ONLINE: - val->intval = (priv->hw_chg_state == CHG_READY_STATE) - || (priv->hw_chg_state == CHG_CHARGING_STATE); - break; - default: - return -EINVAL; - } - return 0; -} - -static enum power_supply_property msm_batt_power_props[] = { - POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_CHARGE_TYPE, - POWER_SUPPLY_PROP_HEALTH, - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_TECHNOLOGY, - POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_NOW, - POWER_SUPPLY_PROP_CAPACITY, -}; - -static int msm_batt_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - switch (psp) { - case POWER_SUPPLY_PROP_STATUS: - val->intval = get_prop_batt_status(); - break; - case POWER_SUPPLY_PROP_CHARGE_TYPE: - val->intval = get_prop_charge_type(); - break; - case POWER_SUPPLY_PROP_HEALTH: - val->intval = get_prop_batt_health(); - break; - case POWER_SUPPLY_PROP_PRESENT: - val->intval = !(msm_chg.batt_status == BATT_STATUS_ABSENT); - break; - case POWER_SUPPLY_PROP_TECHNOLOGY: - val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH; - break; - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: - val->intval = msm_chg.max_voltage * 1000; - break; - case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: - val->intval = msm_chg.min_voltage * 1000; - break; - case POWER_SUPPLY_PROP_VOLTAGE_NOW: - val->intval = get_prop_battery_mvolts(); - break; - case POWER_SUPPLY_PROP_CAPACITY: - val->intval = get_prop_batt_capacity(); - break; - default: - return -EINVAL; - } - return 0; -} - -static struct power_supply msm_psy_batt = { - .name = "battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = msm_batt_power_props, - .num_properties = ARRAY_SIZE(msm_batt_power_props), - .get_property = msm_batt_power_get_property, -}; - -static int usb_chg_current; -static struct msm_hardware_charger_priv *usb_hw_chg_priv; -static void (*notify_vbus_state_func_ptr)(int); -static int usb_notified_of_insertion; - -/* this is passed to the hsusb via platform_data msm_otg_pdata */ -int msm_charger_register_vbus_sn(void (*callback)(int)) -{ - pr_debug(KERN_INFO "%s\n", __func__); - notify_vbus_state_func_ptr = callback; - return 0; -} - -/* this is passed to the hsusb via platform_data msm_otg_pdata */ -void msm_charger_unregister_vbus_sn(void (*callback)(int)) -{ - pr_debug(KERN_INFO "%s\n", __func__); - notify_vbus_state_func_ptr = NULL; -} - -static void notify_usb_of_the_plugin_event(struct msm_hardware_charger_priv - *hw_chg, int plugin) -{ - plugin = !!plugin; - if (plugin == 1 && usb_notified_of_insertion == 0) { - usb_notified_of_insertion = 1; - if (notify_vbus_state_func_ptr) { - dev_dbg(msm_chg.dev, "%s notifying plugin\n", __func__); - (*notify_vbus_state_func_ptr) (plugin); - } else - dev_dbg(msm_chg.dev, "%s unable to notify plugin\n", - __func__); - usb_hw_chg_priv = hw_chg; - } - if (plugin == 0 && usb_notified_of_insertion == 1) { - if (notify_vbus_state_func_ptr) { - dev_dbg(msm_chg.dev, "%s notifying unplugin\n", - __func__); - (*notify_vbus_state_func_ptr) (plugin); - } else - dev_dbg(msm_chg.dev, "%s unable to notify unplugin\n", - __func__); - usb_notified_of_insertion = 0; - usb_hw_chg_priv = NULL; - } -} - -static unsigned int msm_chg_get_batt_capacity_percent(void) -{ - unsigned int current_voltage = get_prop_battery_mvolts(); - unsigned int low_voltage = msm_chg.min_voltage; - unsigned int high_voltage = msm_chg.max_voltage; - - if (current_voltage <= low_voltage) - return 0; - else if (current_voltage >= high_voltage) - return 100; - else - return (current_voltage - low_voltage) * 100 - / (high_voltage - low_voltage); -} - -#ifdef DEBUG -static inline void debug_print(const char *func, - struct msm_hardware_charger_priv *hw_chg_priv) -{ - dev_dbg(msm_chg.dev, - "%s current=(%s)(s=%d)(r=%d) new=(%s)(s=%d)(r=%d) batt=%d En\n", - func, - msm_chg.current_chg_priv ? msm_chg.current_chg_priv-> - hw_chg->name : "none", - msm_chg.current_chg_priv ? msm_chg. - current_chg_priv->hw_chg_state : -1, - msm_chg.current_chg_priv ? msm_chg.current_chg_priv-> - hw_chg->rating : -1, - hw_chg_priv ? hw_chg_priv->hw_chg->name : "none", - hw_chg_priv ? hw_chg_priv->hw_chg_state : -1, - hw_chg_priv ? hw_chg_priv->hw_chg->rating : -1, - msm_chg.batt_status); -} -#else -static inline void debug_print(const char *func, - struct msm_hardware_charger_priv *hw_chg_priv) -{ -} -#endif - -static struct msm_hardware_charger_priv *find_best_charger(void) -{ - struct msm_hardware_charger_priv *hw_chg_priv; - struct msm_hardware_charger_priv *better; - int rating; - - better = NULL; - rating = 0; - - list_for_each_entry(hw_chg_priv, &msm_chg.msm_hardware_chargers, list) { - if (is_chg_capable_of_charging(hw_chg_priv)) { - if (hw_chg_priv->hw_chg->rating > rating) { - rating = hw_chg_priv->hw_chg->rating; - better = hw_chg_priv; - } - } - } - - return better; -} - -static int msm_charging_switched(struct msm_hardware_charger_priv *priv) -{ - int ret = 0; - - if (priv->hw_chg->charging_switched) - ret = priv->hw_chg->charging_switched(priv->hw_chg); - return ret; -} - -static int msm_stop_charging(struct msm_hardware_charger_priv *priv) -{ - int ret; - - ret = priv->hw_chg->stop_charging(priv->hw_chg); - if (!ret) - wake_unlock(&msm_chg.wl); - return ret; -} - -static void msm_enable_system_current(struct msm_hardware_charger_priv *priv) -{ - if (priv->hw_chg->start_system_current) - priv->hw_chg->start_system_current(priv->hw_chg, - priv->max_source_current); -} - -static void msm_disable_system_current(struct msm_hardware_charger_priv *priv) -{ - if (priv->hw_chg->stop_system_current) - priv->hw_chg->stop_system_current(priv->hw_chg); -} - -/* the best charger has been selected -start charging from current_chg_priv */ -static int msm_start_charging(void) -{ - int ret; - struct msm_hardware_charger_priv *priv; - - priv = msm_chg.current_chg_priv; - wake_lock(&msm_chg.wl); - ret = priv->hw_chg->start_charging(priv->hw_chg, msm_chg.max_voltage, - priv->max_source_current); - if (ret) { - wake_unlock(&msm_chg.wl); - dev_err(msm_chg.dev, "%s couldnt start chg error = %d\n", - priv->hw_chg->name, ret); - } else - priv->hw_chg_state = CHG_CHARGING_STATE; - - return ret; -} - -static void handle_charging_done(struct msm_hardware_charger_priv *priv) -{ - if (msm_chg.current_chg_priv == priv) { - if (msm_chg.current_chg_priv->hw_chg_state == - CHG_CHARGING_STATE) - if (msm_stop_charging(msm_chg.current_chg_priv)) { - dev_err(msm_chg.dev, "%s couldnt stop chg\n", - msm_chg.current_chg_priv->hw_chg->name); - } - msm_chg.current_chg_priv->hw_chg_state = CHG_READY_STATE; - - msm_chg.batt_status = BATT_STATUS_JUST_FINISHED_CHARGING; - dev_info(msm_chg.dev, "%s: stopping safety timer work\n", - __func__); - cancel_delayed_work(&msm_chg.teoc_work); - - if (msm_batt_gauge && msm_batt_gauge->monitor_for_recharging) - msm_batt_gauge->monitor_for_recharging(); - else - dev_err(msm_chg.dev, - "%s: no batt gauge recharge monitor\n", __func__); - } -} - -static void teoc(struct work_struct *work) -{ - /* we have been charging too long - stop charging */ - dev_info(msm_chg.dev, "%s: safety timer work expired\n", __func__); - - mutex_lock(&msm_chg.status_lock); - if (msm_chg.current_chg_priv != NULL - && msm_chg.current_chg_priv->hw_chg_state == CHG_CHARGING_STATE) { - handle_charging_done(msm_chg.current_chg_priv); - } - mutex_unlock(&msm_chg.status_lock); -} - -static void handle_battery_inserted(void) -{ - /* if a charger is already present start charging */ - if (msm_chg.current_chg_priv != NULL && - is_batt_status_capable_of_charging() && - !is_batt_status_charging()) { - if (msm_start_charging()) { - dev_err(msm_chg.dev, "%s couldnt start chg\n", - msm_chg.current_chg_priv->hw_chg->name); - return; - } - msm_chg.batt_status = BATT_STATUS_TRKL_CHARGING; - - dev_info(msm_chg.dev, "%s: starting safety timer work\n", - __func__); - queue_delayed_work(msm_chg.event_wq_thread, - &msm_chg.teoc_work, - round_jiffies_relative(msecs_to_jiffies - (msm_chg. - safety_time))); - } -} - -static void handle_battery_removed(void) -{ - /* if a charger is charging the battery stop it */ - if (msm_chg.current_chg_priv != NULL - && msm_chg.current_chg_priv->hw_chg_state == CHG_CHARGING_STATE) { - if (msm_stop_charging(msm_chg.current_chg_priv)) { - dev_err(msm_chg.dev, "%s couldnt stop chg\n", - msm_chg.current_chg_priv->hw_chg->name); - } - msm_chg.current_chg_priv->hw_chg_state = CHG_READY_STATE; - - dev_info(msm_chg.dev, "%s: stopping safety timer work\n", - __func__); - cancel_delayed_work(&msm_chg.teoc_work); - } -} - -static void update_heartbeat(struct work_struct *work) -{ - int temperature; - - if (msm_chg.batt_status == BATT_STATUS_ABSENT - || msm_chg.batt_status == BATT_STATUS_ID_INVALID) { - if (is_battery_present()) - if (is_battery_id_valid()) { - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - handle_battery_inserted(); - } - } else { - if (!is_battery_present()) { - msm_chg.batt_status = BATT_STATUS_ABSENT; - handle_battery_removed(); - } - /* - * check battery id because a good battery could be removed - * and replaced with a invalid battery. - */ - if (!is_battery_id_valid()) { - msm_chg.batt_status = BATT_STATUS_ID_INVALID; - handle_battery_removed(); - } - } - pr_debug("msm-charger %s batt_status= %d\n", - __func__, msm_chg.batt_status); - - if (msm_chg.current_chg_priv - && msm_chg.current_chg_priv->hw_chg_state - == CHG_CHARGING_STATE) { - temperature = get_battery_temperature(); - /* TODO implement JEITA SPEC*/ - } - - /* notify that the voltage has changed - * the read of the capacity will trigger a - * voltage read*/ - power_supply_changed(&msm_psy_batt); - - if (msm_chg.stop_update) { - msm_chg.stop_update = 0; - return; - } - queue_delayed_work(msm_chg.event_wq_thread, - &msm_chg.update_heartbeat_work, - round_jiffies_relative(msecs_to_jiffies - (msm_chg.update_time))); -} - -/* set the charger state to READY before calling this */ -static void handle_charger_ready(struct msm_hardware_charger_priv *hw_chg_priv) -{ - struct msm_hardware_charger_priv *old_chg_priv = NULL; - - debug_print(__func__, hw_chg_priv); - - if (msm_chg.current_chg_priv != NULL - && hw_chg_priv->hw_chg->rating > - msm_chg.current_chg_priv->hw_chg->rating) { - /* - * a better charger was found, ask the current charger - * to stop charging if it was charging - */ - if (msm_chg.current_chg_priv->hw_chg_state == - CHG_CHARGING_STATE) { - if (msm_stop_charging(msm_chg.current_chg_priv)) { - dev_err(msm_chg.dev, "%s couldnt stop chg\n", - msm_chg.current_chg_priv->hw_chg->name); - return; - } - if (msm_charging_switched(msm_chg.current_chg_priv)) { - dev_err(msm_chg.dev, "%s couldnt stop chg\n", - msm_chg.current_chg_priv->hw_chg->name); - return; - } - } - msm_chg.current_chg_priv->hw_chg_state = CHG_READY_STATE; - old_chg_priv = msm_chg.current_chg_priv; - msm_chg.current_chg_priv = NULL; - } - - if (msm_chg.current_chg_priv == NULL) { - msm_chg.current_chg_priv = hw_chg_priv; - dev_info(msm_chg.dev, - "%s: best charger = %s\n", __func__, - msm_chg.current_chg_priv->hw_chg->name); - - msm_enable_system_current(msm_chg.current_chg_priv); - /* - * since a better charger was chosen, ask the old - * charger to stop providing system current - */ - if (old_chg_priv != NULL) - msm_disable_system_current(old_chg_priv); - - if (!is_batt_status_capable_of_charging()) - return; - - /* start charging from the new charger */ - if (!msm_start_charging()) { - /* if we simply switched chg continue with teoc timer - * else we update the batt state and set the teoc - * timer */ - if (!is_batt_status_charging()) { - dev_info(msm_chg.dev, - "%s: starting safety timer\n", __func__); - queue_delayed_work(msm_chg.event_wq_thread, - &msm_chg.teoc_work, - round_jiffies_relative - (msecs_to_jiffies - (msm_chg.safety_time))); - msm_chg.batt_status = BATT_STATUS_TRKL_CHARGING; - } - } else { - /* we couldnt start charging from the new readied - * charger */ - if (is_batt_status_charging()) - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - } - } -} - -static void handle_charger_removed(struct msm_hardware_charger_priv - *hw_chg_removed, int new_state) -{ - struct msm_hardware_charger_priv *hw_chg_priv; - - debug_print(__func__, hw_chg_removed); - - if (msm_chg.current_chg_priv == hw_chg_removed) { - msm_disable_system_current(hw_chg_removed); - if (msm_chg.current_chg_priv->hw_chg_state - == CHG_CHARGING_STATE) { - if (msm_stop_charging(hw_chg_removed)) { - dev_err(msm_chg.dev, "%s couldnt stop chg\n", - msm_chg.current_chg_priv->hw_chg->name); - } - } - msm_chg.current_chg_priv = NULL; - } - - hw_chg_removed->hw_chg_state = new_state; - - if (msm_chg.current_chg_priv == NULL) { - hw_chg_priv = find_best_charger(); - if (hw_chg_priv == NULL) { - dev_info(msm_chg.dev, "%s: no chargers\n", __func__); - /* if the battery was Just finished charging - * we keep that state as is so that we dont rush - * in to charging the battery when a charger is - * plugged in shortly. */ - if (is_batt_status_charging()) - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - } else { - msm_chg.current_chg_priv = hw_chg_priv; - msm_enable_system_current(hw_chg_priv); - dev_info(msm_chg.dev, - "%s: best charger = %s\n", __func__, - msm_chg.current_chg_priv->hw_chg->name); - - if (!is_batt_status_capable_of_charging()) - return; - - if (msm_start_charging()) { - /* we couldnt start charging for some reason */ - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - } - } - } - - /* if we arent charging stop the safety timer */ - if (!is_batt_status_charging()) { - dev_info(msm_chg.dev, "%s: stopping safety timer work\n", - __func__); - cancel_delayed_work(&msm_chg.teoc_work); - } -} - -static void handle_event(struct msm_hardware_charger *hw_chg, int event) -{ - struct msm_hardware_charger_priv *priv = NULL; - - /* - * if hw_chg is NULL then this event comes from non-charger - * parties like battery gauge - */ - if (hw_chg) - priv = hw_chg->charger_private; - - mutex_lock(&msm_chg.status_lock); - - switch (event) { - case CHG_INSERTED_EVENT: - if (priv->hw_chg_state != CHG_ABSENT_STATE) { - dev_info(msm_chg.dev, - "%s insertion detected when cbl present", - hw_chg->name); - break; - } - update_batt_status(); - if (hw_chg->type == CHG_TYPE_USB) { - priv->hw_chg_state = CHG_PRESENT_STATE; - notify_usb_of_the_plugin_event(priv, 1); - if (usb_chg_current) { - priv->max_source_current = usb_chg_current; - usb_chg_current = 0; - /* usb has already indicated us to charge */ - priv->hw_chg_state = CHG_READY_STATE; - handle_charger_ready(priv); - } - } else { - priv->hw_chg_state = CHG_READY_STATE; - handle_charger_ready(priv); - } - break; - case CHG_ENUMERATED_EVENT: /* only in USB types */ - if (priv->hw_chg_state == CHG_ABSENT_STATE) { - dev_info(msm_chg.dev, "%s enum withuot presence\n", - hw_chg->name); - break; - } - update_batt_status(); - dev_dbg(msm_chg.dev, "%s enum with %dmA to draw\n", - hw_chg->name, priv->max_source_current); - if (priv->max_source_current == 0) { - /* usb subsystem doesnt want us to draw - * charging current */ - /* act as if the charge is removed */ - if (priv->hw_chg_state != CHG_PRESENT_STATE) - handle_charger_removed(priv, CHG_PRESENT_STATE); - } else { - if (priv->hw_chg_state != CHG_READY_STATE) { - priv->hw_chg_state = CHG_READY_STATE; - handle_charger_ready(priv); - } - } - break; - case CHG_REMOVED_EVENT: - if (priv->hw_chg_state == CHG_ABSENT_STATE) { - dev_info(msm_chg.dev, "%s cable already removed\n", - hw_chg->name); - break; - } - update_batt_status(); - if (hw_chg->type == CHG_TYPE_USB) { - usb_chg_current = 0; - notify_usb_of_the_plugin_event(priv, 0); - } - handle_charger_removed(priv, CHG_ABSENT_STATE); - break; - case CHG_DONE_EVENT: - if (priv->hw_chg_state == CHG_CHARGING_STATE) - handle_charging_done(priv); - break; - case CHG_BATT_BEGIN_FAST_CHARGING: - /* only update if we are TRKL charging */ - if (msm_chg.batt_status == BATT_STATUS_TRKL_CHARGING) - msm_chg.batt_status = BATT_STATUS_FAST_CHARGING; - break; - case CHG_BATT_NEEDS_RECHARGING: - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - handle_battery_inserted(); - priv = msm_chg.current_chg_priv; - break; - case CHG_BATT_TEMP_OUTOFRANGE: - /* the batt_temp out of range can trigger - * when the battery is absent */ - if (!is_battery_present() - && msm_chg.batt_status != BATT_STATUS_ABSENT) { - msm_chg.batt_status = BATT_STATUS_ABSENT; - handle_battery_removed(); - break; - } - if (msm_chg.batt_status == BATT_STATUS_TEMPERATURE_OUT_OF_RANGE) - break; - msm_chg.batt_status = BATT_STATUS_TEMPERATURE_OUT_OF_RANGE; - handle_battery_removed(); - break; - case CHG_BATT_TEMP_INRANGE: - if (msm_chg.batt_status != BATT_STATUS_TEMPERATURE_OUT_OF_RANGE) - break; - msm_chg.batt_status = BATT_STATUS_ID_INVALID; - /* check id */ - if (!is_battery_id_valid()) - break; - /* assume that we are discharging from the battery - * and act as if the battery was inserted - * if a charger is present charging will be resumed */ - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - handle_battery_inserted(); - break; - case CHG_BATT_INSERTED: - if (msm_chg.batt_status != BATT_STATUS_ABSENT) - break; - /* debounce */ - if (!is_battery_present()) - break; - msm_chg.batt_status = BATT_STATUS_ID_INVALID; - if (!is_battery_id_valid()) - break; - /* assume that we are discharging from the battery */ - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - /* check if a charger is present */ - handle_battery_inserted(); - break; - case CHG_BATT_REMOVED: - if (msm_chg.batt_status == BATT_STATUS_ABSENT) - break; - /* debounce */ - if (is_battery_present()) - break; - msm_chg.batt_status = BATT_STATUS_ABSENT; - handle_battery_removed(); - break; - case CHG_BATT_STATUS_CHANGE: - /* TODO battery SOC like battery-alarm/charging-full features - can be added here for future improvement */ - break; - } - dev_dbg(msm_chg.dev, "%s %d done batt_status=%d\n", __func__, - event, msm_chg.batt_status); - - /* update userspace */ - if (msm_batt_gauge) - power_supply_changed(&msm_psy_batt); - if (priv) - power_supply_changed(&priv->psy); - - mutex_unlock(&msm_chg.status_lock); -} - -static int msm_chg_dequeue_event(struct msm_charger_event **event) -{ - unsigned long flags; - - spin_lock_irqsave(&msm_chg.queue_lock, flags); - if (msm_chg.queue_count == 0) { - spin_unlock_irqrestore(&msm_chg.queue_lock, flags); - return -EINVAL; - } - *event = &msm_chg.queue[msm_chg.head]; - msm_chg.head = (msm_chg.head + 1) % MSM_CHG_MAX_EVENTS; - pr_debug("%s dequeueing %d\n", __func__, (*event)->event); - msm_chg.queue_count--; - spin_unlock_irqrestore(&msm_chg.queue_lock, flags); - return 0; -} - -static int msm_chg_enqueue_event(struct msm_hardware_charger *hw_chg, - enum msm_hardware_charger_event event) -{ - unsigned long flags; - - spin_lock_irqsave(&msm_chg.queue_lock, flags); - if (msm_chg.queue_count == MSM_CHG_MAX_EVENTS) { - spin_unlock_irqrestore(&msm_chg.queue_lock, flags); - pr_err("%s: queue full cannot enqueue %d\n", - __func__, event); - return -EAGAIN; - } - pr_debug("%s queueing %d\n", __func__, event); - msm_chg.queue[msm_chg.tail].event = event; - msm_chg.queue[msm_chg.tail].hw_chg = hw_chg; - msm_chg.tail = (msm_chg.tail + 1)%MSM_CHG_MAX_EVENTS; - msm_chg.queue_count++; - spin_unlock_irqrestore(&msm_chg.queue_lock, flags); - return 0; -} - -static void process_events(struct work_struct *work) -{ - struct msm_charger_event *event; - int rc; - - do { - rc = msm_chg_dequeue_event(&event); - if (!rc) - handle_event(event->hw_chg, event->event); - } while (!rc); -} - -/* USB calls these to tell us how much charging current we should draw */ -void msm_charger_vbus_draw(unsigned int mA) -{ - if (usb_hw_chg_priv) { - usb_hw_chg_priv->max_source_current = mA; - msm_charger_notify_event(usb_hw_chg_priv->hw_chg, - CHG_ENUMERATED_EVENT); - } else - /* remember the current, to be used when charger is ready */ - usb_chg_current = mA; -} - -static int determine_initial_batt_status(void) -{ - if (is_battery_present()) - if (is_battery_id_valid()) - if (is_battery_temp_within_range()) - msm_chg.batt_status = BATT_STATUS_DISCHARGING; - else - msm_chg.batt_status - = BATT_STATUS_TEMPERATURE_OUT_OF_RANGE; - else - msm_chg.batt_status = BATT_STATUS_ID_INVALID; - else - msm_chg.batt_status = BATT_STATUS_ABSENT; - - if (is_batt_status_capable_of_charging()) - handle_battery_inserted(); - - /* start updaing the battery powersupply every msm_chg.update_time - * milliseconds */ - queue_delayed_work(msm_chg.event_wq_thread, - &msm_chg.update_heartbeat_work, - round_jiffies_relative(msecs_to_jiffies - (msm_chg.update_time))); - - pr_debug("%s:OK batt_status=%d\n", __func__, msm_chg.batt_status); - return 0; -} - -static int msm_charger_probe(struct platform_device *pdev) -{ - msm_chg.dev = &pdev->dev; - if (pdev->dev.platform_data) { - unsigned int milli_secs; - - struct msm_charger_platform_data *pdata - = - (struct msm_charger_platform_data *)pdev->dev.platform_data; - - milli_secs = pdata->safety_time * 60 * MSEC_PER_SEC; - if (milli_secs > jiffies_to_msecs(MAX_JIFFY_OFFSET)) { - dev_warn(&pdev->dev, "%s: safety time too large" - "%dms\n", __func__, milli_secs); - milli_secs = jiffies_to_msecs(MAX_JIFFY_OFFSET); - } - msm_chg.safety_time = milli_secs; - - milli_secs = pdata->update_time * 60 * MSEC_PER_SEC; - if (milli_secs > jiffies_to_msecs(MAX_JIFFY_OFFSET)) { - dev_warn(&pdev->dev, "%s: safety time too large" - "%dms\n", __func__, milli_secs); - milli_secs = jiffies_to_msecs(MAX_JIFFY_OFFSET); - } - msm_chg.update_time = milli_secs; - - msm_chg.max_voltage = pdata->max_voltage; - msm_chg.min_voltage = pdata->min_voltage; - msm_chg.get_batt_capacity_percent = - pdata->get_batt_capacity_percent; - } - if (msm_chg.safety_time == 0) - msm_chg.safety_time = CHARGING_TEOC_MS; - if (msm_chg.update_time == 0) - msm_chg.update_time = UPDATE_TIME_MS; - if (msm_chg.max_voltage == 0) - msm_chg.max_voltage = DEFAULT_BATT_MAX_V; - if (msm_chg.min_voltage == 0) - msm_chg.min_voltage = DEFAULT_BATT_MIN_V; - if (msm_chg.get_batt_capacity_percent == NULL) - msm_chg.get_batt_capacity_percent = - msm_chg_get_batt_capacity_percent; - - mutex_init(&msm_chg.status_lock); - INIT_DELAYED_WORK(&msm_chg.teoc_work, teoc); - INIT_DELAYED_WORK(&msm_chg.update_heartbeat_work, update_heartbeat); - - wake_lock_init(&msm_chg.wl, WAKE_LOCK_SUSPEND, "msm_charger"); - return 0; -} - -static int msm_charger_remove(struct platform_device *pdev) -{ - wake_lock_destroy(&msm_chg.wl); - mutex_destroy(&msm_chg.status_lock); - power_supply_unregister(&msm_psy_batt); - return 0; -} - -int msm_charger_notify_event(struct msm_hardware_charger *hw_chg, - enum msm_hardware_charger_event event) -{ - msm_chg_enqueue_event(hw_chg, event); - queue_work(msm_chg.event_wq_thread, &msm_chg.queue_work); - return 0; -} -EXPORT_SYMBOL(msm_charger_notify_event); - -int msm_charger_register(struct msm_hardware_charger *hw_chg) -{ - struct msm_hardware_charger_priv *priv; - int rc = 0; - - if (!msm_chg.inited) { - pr_err("%s: msm_chg is NULL,Too early to register\n", __func__); - return -EAGAIN; - } - - if (hw_chg->start_charging == NULL - || hw_chg->stop_charging == NULL - || hw_chg->name == NULL - || hw_chg->rating == 0) { - pr_err("%s: invalid hw_chg\n", __func__); - return -EINVAL; - } - - priv = kzalloc(sizeof *priv, GFP_KERNEL); - if (priv == NULL) { - dev_err(msm_chg.dev, "%s kzalloc failed\n", __func__); - return -ENOMEM; - } - - priv->psy.name = hw_chg->name; - if (hw_chg->type == CHG_TYPE_USB) - priv->psy.type = POWER_SUPPLY_TYPE_USB; - else - priv->psy.type = POWER_SUPPLY_TYPE_MAINS; - - priv->psy.supplied_to = msm_power_supplied_to; - priv->psy.num_supplicants = ARRAY_SIZE(msm_power_supplied_to); - priv->psy.properties = msm_power_props; - priv->psy.num_properties = ARRAY_SIZE(msm_power_props); - priv->psy.get_property = msm_power_get_property; - - rc = power_supply_register(NULL, &priv->psy); - if (rc) { - dev_err(msm_chg.dev, "%s power_supply_register failed\n", - __func__); - goto out; - } - - priv->hw_chg = hw_chg; - priv->hw_chg_state = CHG_ABSENT_STATE; - INIT_LIST_HEAD(&priv->list); - mutex_lock(&msm_chg.msm_hardware_chargers_lock); - list_add_tail(&priv->list, &msm_chg.msm_hardware_chargers); - mutex_unlock(&msm_chg.msm_hardware_chargers_lock); - hw_chg->charger_private = (void *)priv; - return 0; - -out: - kfree(priv); - return rc; -} -EXPORT_SYMBOL(msm_charger_register); - -void msm_battery_gauge_register(struct msm_battery_gauge *batt_gauge) -{ - int rc; - - if (msm_batt_gauge) { - msm_batt_gauge = batt_gauge; - pr_err("msm-charger %s multiple battery gauge called\n", - __func__); - } else { - rc = power_supply_register(msm_chg.dev, &msm_psy_batt); - if (rc < 0) { - dev_err(msm_chg.dev, "%s: power_supply_register failed" - " rc=%d\n", __func__, rc); - return; - } - - msm_batt_gauge = batt_gauge; - determine_initial_batt_status(); - } -} -EXPORT_SYMBOL(msm_battery_gauge_register); - -void msm_battery_gauge_unregister(struct msm_battery_gauge *batt_gauge) -{ - msm_batt_gauge = NULL; -} -EXPORT_SYMBOL(msm_battery_gauge_unregister); - -int msm_charger_unregister(struct msm_hardware_charger *hw_chg) -{ - struct msm_hardware_charger_priv *priv; - - priv = (struct msm_hardware_charger_priv *)(hw_chg->charger_private); - mutex_lock(&msm_chg.msm_hardware_chargers_lock); - list_del(&priv->list); - mutex_unlock(&msm_chg.msm_hardware_chargers_lock); - power_supply_unregister(&priv->psy); - kfree(priv); - return 0; -} -EXPORT_SYMBOL(msm_charger_unregister); - -static int msm_charger_suspend(struct device *dev) -{ - dev_dbg(msm_chg.dev, "%s suspended\n", __func__); - msm_chg.stop_update = 1; - cancel_delayed_work(&msm_chg.update_heartbeat_work); - mutex_lock(&msm_chg.status_lock); - handle_battery_removed(); - mutex_unlock(&msm_chg.status_lock); - return 0; -} - -static int msm_charger_resume(struct device *dev) -{ - dev_dbg(msm_chg.dev, "%s resumed\n", __func__); - msm_chg.stop_update = 0; - /* start updaing the battery powersupply every msm_chg.update_time - * milliseconds */ - queue_delayed_work(msm_chg.event_wq_thread, - &msm_chg.update_heartbeat_work, - round_jiffies_relative(msecs_to_jiffies - (msm_chg.update_time))); - mutex_lock(&msm_chg.status_lock); - handle_battery_inserted(); - mutex_unlock(&msm_chg.status_lock); - return 0; -} - -static SIMPLE_DEV_PM_OPS(msm_charger_pm_ops, - msm_charger_suspend, msm_charger_resume); - -static struct platform_driver msm_charger_driver = { - .probe = msm_charger_probe, - .remove = msm_charger_remove, - .driver = { - .name = "msm-charger", - .owner = THIS_MODULE, - .pm = &msm_charger_pm_ops, - }, -}; - -static int __init msm_charger_init(void) -{ - int rc; - - INIT_LIST_HEAD(&msm_chg.msm_hardware_chargers); - msm_chg.count_chargers = 0; - mutex_init(&msm_chg.msm_hardware_chargers_lock); - - msm_chg.queue = kzalloc(sizeof(struct msm_charger_event) - * MSM_CHG_MAX_EVENTS, - GFP_KERNEL); - if (!msm_chg.queue) { - rc = -ENOMEM; - goto out; - } - msm_chg.tail = 0; - msm_chg.head = 0; - spin_lock_init(&msm_chg.queue_lock); - msm_chg.queue_count = 0; - INIT_WORK(&msm_chg.queue_work, process_events); - msm_chg.event_wq_thread = create_workqueue("msm_charger_eventd"); - if (!msm_chg.event_wq_thread) { - rc = -ENOMEM; - goto free_queue; - } - rc = platform_driver_register(&msm_charger_driver); - if (rc < 0) { - pr_err("%s: FAIL: platform_driver_register. rc = %d\n", - __func__, rc); - goto destroy_wq_thread; - } - msm_chg.inited = 1; - return 0; - -destroy_wq_thread: - destroy_workqueue(msm_chg.event_wq_thread); -free_queue: - kfree(msm_chg.queue); -out: - return rc; -} - -static void __exit msm_charger_exit(void) -{ - flush_workqueue(msm_chg.event_wq_thread); - destroy_workqueue(msm_chg.event_wq_thread); - kfree(msm_chg.queue); - platform_driver_unregister(&msm_charger_driver); -} - -module_init(msm_charger_init); -module_exit(msm_charger_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Abhijeet Dharmapurikar "); -MODULE_DESCRIPTION("Battery driver for Qualcomm MSM chipsets."); -MODULE_VERSION("1.0"); diff --git a/drivers/power/pm8058_usb_fix.c b/drivers/power/pm8058_usb_fix.c deleted file mode 100644 index 13d7ca580e6dddba9933424982e16564886ec147..0000000000000000000000000000000000000000 --- a/drivers/power/pm8058_usb_fix.c +++ /dev/null @@ -1,357 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* Config Regs and their bits*/ -#define PM8058_CHG_TEST 0x75 -#define IGNORE_LL 2 - -#define PM8058_CHG_TEST_2 0xEA -#define PM8058_CHG_TEST_3 0xEB -#define PM8058_OVP_TEST_REG 0xF6 -#define FORCE_OVP_OFF 3 - -#define PM8058_CHG_CNTRL 0x1E -#define CHG_TRICKLE_EN 7 -#define CHG_USB_SUSPEND 6 -#define CHG_IMON_CAL 5 -#define CHG_IMON_GAIN 4 -#define CHG_VBUS_FROM_BOOST_OVRD 2 -#define CHG_CHARGE_DIS 1 -#define CHG_VCP_EN 0 - -#define PM8058_CHG_CNTRL_2 0xD8 -#define ATC_DIS 7 /* coincell backed */ -#define CHARGE_AUTO_DIS 6 -#define DUMB_CHG_OVRD 5 /* coincell backed */ -#define ENUM_DONE 4 -#define CHG_TEMP_MODE 3 -#define CHG_BATT_TEMP_DIS 1 /* coincell backed */ -#define CHG_FAILED_CLEAR 0 - -#define PM8058_CHG_VMAX_SEL 0x21 -#define PM8058_CHG_VBAT_DET 0xD9 -#define PM8058_CHG_IMAX 0x1F -#define PM8058_CHG_TRICKLE 0xDB -#define PM8058_CHG_ITERM 0xDC -#define PM8058_CHG_TTRKL_MAX 0xE1 -#define PM8058_CHG_TCHG_MAX 0xE4 -#define PM8058_CHG_TEMP_THRESH 0xE2 -#define PM8058_CHG_TEMP_REG 0xE3 -#define PM8058_CHG_PULSE 0x22 - -/* IRQ STATUS and CLEAR */ -#define PM8058_CHG_STATUS_CLEAR_IRQ_1 0x31 -#define PM8058_CHG_STATUS_CLEAR_IRQ_3 0x33 -#define PM8058_CHG_STATUS_CLEAR_IRQ_10 0xB3 -#define PM8058_CHG_STATUS_CLEAR_IRQ_11 0xB4 - -/* IRQ MASKS */ -#define PM8058_CHG_MASK_IRQ_1 0x38 - -#define PM8058_CHG_MASK_IRQ_3 0x3A -#define PM8058_CHG_MASK_IRQ_10 0xBA -#define PM8058_CHG_MASK_IRQ_11 0xBB - -/* IRQ Real time status regs */ -#define PM8058_CHG_STATUS_RT_1 0x3F -#define STATUS_RTCHGVAL 7 -#define STATUS_RTCHGINVAL 6 -#define STATUS_RTBATT_REPLACE 5 -#define STATUS_RTVBATDET_LOW 4 -#define STATUS_RTCHGILIM 3 -#define STATUS_RTPCTDONE 1 -#define STATUS_RTVCP 0 -#define PM8058_CHG_STATUS_RT_3 0x41 -#define PM8058_CHG_STATUS_RT_10 0xC1 -#define PM8058_CHG_STATUS_RT_11 0xC2 - -/* VTRIM */ -#define PM8058_CHG_VTRIM 0x1D -#define PM8058_CHG_VBATDET_TRIM 0x1E -#define PM8058_CHG_ITRIM 0x1F -#define PM8058_CHG_TTRIM 0x20 - -#define AUTO_CHARGING_VMAXSEL 4200 -#define AUTO_CHARGING_FAST_TIME_MAX_MINUTES 512 -#define AUTO_CHARGING_TRICKLE_TIME_MINUTES 30 -#define AUTO_CHARGING_VEOC_ITERM 100 -#define AUTO_CHARGING_IEOC_ITERM 160 - -#define AUTO_CHARGING_VBATDET 4150 -#define AUTO_CHARGING_VEOC_VBATDET 4100 -#define AUTO_CHARGING_VEOC_TCHG 16 -#define AUTO_CHARGING_VEOC_TCHG_FINAL_CYCLE 32 -#define AUTO_CHARGING_VEOC_BEGIN_TIME_MS 5400000 - -#define AUTO_CHARGING_VEOC_VBAT_LOW_CHECK_TIME_MS 60000 -#define AUTO_CHARGING_RESUME_CHARGE_DETECTION_COUNTER 5 - -#define PM8058_CHG_I_STEP_MA 50 -#define PM8058_CHG_I_MIN_MA 50 -#define PM8058_CHG_T_TCHG_SHIFT 2 -#define PM8058_CHG_I_TERM_STEP_MA 10 -#define PM8058_CHG_V_STEP_MV 25 -#define PM8058_CHG_V_MIN_MV 2400 -/* - * enum pmic_chg_interrupts: pmic interrupts - * @CHGVAL_IRQ: charger V between 3.3 and 7.9 - * @CHGINVAL_IRQ: charger V outside 3.3 and 7.9 - * @VBATDET_LOW_IRQ: VBAT < VBATDET - * @VCP_IRQ: VDD went below VBAT: BAT_FET is turned on - * @CHGILIM_IRQ: mA consumed>IMAXSEL: chgloop draws less mA - * @ATC_DONE_IRQ: Auto Trickle done - * @ATCFAIL_IRQ: Auto Trickle fail - * @AUTO_CHGDONE_IRQ: Auto chg done - * @AUTO_CHGFAIL_IRQ: time exceeded w/o reaching term current - * @CHGSTATE_IRQ: something happend causing a state change - * @FASTCHG_IRQ: trkl charging completed: moving to fastchg - * @CHG_END_IRQ: mA has dropped to termination current - * @BATTTEMP_IRQ: batt temp is out of range - * @CHGHOT_IRQ: the pass device is too hot - * @CHGTLIMIT_IRQ: unused - * @CHG_GONE_IRQ: charger was removed - * @VCPMAJOR_IRQ: vcp major - * @VBATDET_IRQ: VBAT >= VBATDET - * @BATFET_IRQ: BATFET closed - * @BATT_REPLACE_IRQ: - * @BATTCONNECT_IRQ: - */ -enum pmic_chg_interrupts { - CHGVAL_IRQ, - CHGINVAL_IRQ, - VBATDET_LOW_IRQ, - VCP_IRQ, - CHGILIM_IRQ, - ATC_DONE_IRQ, - ATCFAIL_IRQ, - AUTO_CHGDONE_IRQ, - AUTO_CHGFAIL_IRQ, - CHGSTATE_IRQ, - FASTCHG_IRQ, - CHG_END_IRQ, - BATTTEMP_IRQ, - CHGHOT_IRQ, - CHGTLIMIT_IRQ, - CHG_GONE_IRQ, - VCPMAJOR_IRQ, - VBATDET_IRQ, - BATFET_IRQ, - BATT_REPLACE_IRQ, - BATTCONNECT_IRQ, - PMIC_CHG_MAX_INTS -}; - -struct pm8058_charger { - struct pmic_charger_pdata *pdata; - struct pm8058_chip *pm_chip; - struct device *dev; - - int pmic_chg_irq[PMIC_CHG_MAX_INTS]; - DECLARE_BITMAP(enabled_irqs, PMIC_CHG_MAX_INTS); - - struct delayed_work check_vbat_low_work; - struct delayed_work veoc_begin_work; - int waiting_for_topoff; - int waiting_for_veoc; - int current_charger_current; - - struct msm_xo_voter *voter; - struct dentry *dent; -}; - -static struct pm8058_charger pm8058_chg; - -static int pm_chg_get_rt_status(int irq) -{ - int count = 3; - int ret; - - while ((ret = - pm8058_irq_get_rt_status(pm8058_chg.pm_chip, irq)) == -EAGAIN - && count--) { - dev_info(pm8058_chg.dev, "%s trycount=%d\n", __func__, count); - cpu_relax(); - } - if (ret == -EAGAIN) - return 0; - else - return ret; -} - -static int is_chg_plugged_in(void) -{ - return pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGVAL_IRQ]); -} - -static irqreturn_t pm8058_chg_chgval_handler(int irq, void *dev_id) -{ - u8 old, temp; - int ret; - - if (!is_chg_plugged_in()) { /*this debounces it */ - ret = pm8058_read(pm8058_chg.pm_chip, PM8058_OVP_TEST_REG, - &old, 1); - temp = old | BIT(FORCE_OVP_OFF); - ret = pm8058_write(pm8058_chg.pm_chip, PM8058_OVP_TEST_REG, - &temp, 1); - temp = 0xFC; - ret = pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST, - &temp, 1); - pr_debug("%s forced wrote 0xFC to test ret=%d\n", - __func__, ret); - /* 20 ms sleep is for the VCHG to discharge */ - msleep(20); - temp = 0xF0; - ret = pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST, - &temp, 1); - ret = pm8058_write(pm8058_chg.pm_chip, PM8058_OVP_TEST_REG, - &old, 1); - } - - return IRQ_HANDLED; -} - -static void free_irqs(void) -{ - int i; - - for (i = 0; i < PMIC_CHG_MAX_INTS; i++) - if (pm8058_chg.pmic_chg_irq[i]) { - free_irq(pm8058_chg.pmic_chg_irq[i], NULL); - pm8058_chg.pmic_chg_irq[i] = 0; - } -} - -static int request_irqs(struct platform_device *pdev) -{ - struct resource *res; - int ret; - - ret = 0; - bitmap_fill(pm8058_chg.enabled_irqs, PMIC_CHG_MAX_INTS); - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "CHGVAL"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource CHGVAL\n", __func__); - goto err_out; - } else { - ret = request_any_context_irq(res->start, - pm8058_chg_chgval_handler, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[CHGVAL_IRQ] = res->start; - } - } - - return 0; - -err_out: - free_irqs(); - return -EINVAL; -} - -static int pm8058_usb_voltage_lower_limit(void) -{ - u8 temp, old; - int ret = 0; - - temp = 0x10; - ret |= pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST, &temp, 1); - ret |= pm8058_read(pm8058_chg.pm_chip, PM8058_CHG_TEST, &old, 1); - old = old & ~BIT(IGNORE_LL); - temp = 0x90 | (0xF & old); - pr_debug("%s writing 0x%x to test\n", __func__, temp); - ret |= pm8058_write(pm8058_chg.pm_chip, PM8058_CHG_TEST, &temp, 1); - - return ret; -} - -static int pm8058_charger_probe(struct platform_device *pdev) -{ - struct pm8058_chip *pm_chip; - - pm_chip = dev_get_drvdata(pdev->dev.parent); - if (pm_chip == NULL) { - pr_err("%s:no parent data passed in.\n", __func__); - return -EFAULT; - } - - pm8058_chg.pm_chip = pm_chip; - pm8058_chg.pdata = pdev->dev.platform_data; - pm8058_chg.dev = &pdev->dev; - - if (request_irqs(pdev)) { - pr_err("%s: couldnt register interrupts\n", __func__); - return -EINVAL; - } - - if (pm8058_usb_voltage_lower_limit()) { - pr_err("%s: couldnt write to IGNORE_LL\n", __func__); - return -EINVAL; - } - - return 0; -} - -static int pm8058_charger_remove(struct platform_device *pdev) -{ - free_irqs(); - return 0; -} - -static struct platform_driver pm8058_charger_driver = { - .probe = pm8058_charger_probe, - .remove = pm8058_charger_remove, - .driver = { - .name = "pm-usb-fix", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8058_charger_init(void) -{ - return platform_driver_register(&pm8058_charger_driver); -} - -static void __exit pm8058_charger_exit(void) -{ - platform_driver_unregister(&pm8058_charger_driver); -} - -late_initcall(pm8058_charger_init); -module_exit(pm8058_charger_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8058 BATTERY driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pm8058_charger"); diff --git a/drivers/power/pm8921-bms.c b/drivers/power/pm8921-bms.c deleted file mode 100644 index 08c2f405f3af559f3dd2e117ec8b6b6eff08cc01..0000000000000000000000000000000000000000 --- a/drivers/power/pm8921-bms.c +++ /dev/null @@ -1,3950 +0,0 @@ -/* Copyright (c) 2011-2013, 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. - * - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BMS_CONTROL 0x224 -#define BMS_S1_DELAY 0x225 -#define BMS_OUTPUT0 0x230 -#define BMS_OUTPUT1 0x231 -#define BMS_TOLERANCES 0x232 -#define BMS_TEST1 0x237 - -#define ADC_ARB_SECP_CNTRL 0x190 -#define ADC_ARB_SECP_AMUX_CNTRL 0x191 -#define ADC_ARB_SECP_ANA_PARAM 0x192 -#define ADC_ARB_SECP_DIG_PARAM 0x193 -#define ADC_ARB_SECP_RSV 0x194 -#define ADC_ARB_SECP_DATA1 0x195 -#define ADC_ARB_SECP_DATA0 0x196 - -#define ADC_ARB_BMS_CNTRL 0x18D -#define AMUX_TRIM_2 0x322 -#define TEST_PROGRAM_REV 0x339 - -#define TEMP_SOC_STORAGE 0x107 - -#define TEMP_IAVG_STORAGE 0x105 -#define TEMP_IAVG_STORAGE_USE_MASK 0x0F - -#define PON_CNTRL_6 0x018 -#define WD_BIT BIT(7) - -#define BATT_ALARM_ACCURACY 50 /* 50mV */ - -enum pmic_bms_interrupts { - PM8921_BMS_SBI_WRITE_OK, - PM8921_BMS_CC_THR, - PM8921_BMS_VSENSE_THR, - PM8921_BMS_VSENSE_FOR_R, - PM8921_BMS_OCV_FOR_R, - PM8921_BMS_GOOD_OCV, - PM8921_BMS_VSENSE_AVG, - PM_BMS_MAX_INTS, -}; - -struct pm8921_soc_params { - uint16_t last_good_ocv_raw; - int cc; - - int last_good_ocv_uv; -}; - -struct fcc_data { - int fcc_new; - int chargecycles; - int batt_temp; - int fcc_real; - int temp_real; -}; - -/** - * struct pm8921_bms_chip - - * @bms_output_lock: lock to prevent concurrent bms reads - * - * @last_ocv_uv_mutex: mutex to protect simultaneous invocations of calculate - * state of charge, note that last_ocv_uv could be - * changed as soc is adjusted. This mutex protects - * simultaneous updates of last_ocv_uv as well. This mutex - * also protects changes to *_at_100 variables used in - * faking 100% SOC. - */ -struct pm8921_bms_chip { - struct device *dev; - struct dentry *dent; - int r_sense_uohm; - unsigned int v_cutoff; - unsigned int fcc; - struct single_row_lut *fcc_temp_lut; - struct single_row_lut *fcc_sf_lut; - struct pc_temp_ocv_lut *pc_temp_ocv_lut; - struct sf_lut *pc_sf_lut; - struct sf_lut *rbatt_sf_lut; - int delta_rbatt_mohm; - struct work_struct calib_hkadc_work; - unsigned long last_calib_time; - int last_calib_temp; - struct mutex calib_mutex; - unsigned int revision; - unsigned int xoadc_v0625_usb_present; - unsigned int xoadc_v0625_usb_absent; - unsigned int xoadc_v0625; - unsigned int xoadc_v125; - unsigned int batt_temp_channel; - unsigned int vbat_channel; - unsigned int ref625mv_channel; - unsigned int ref1p25v_channel; - unsigned int batt_id_channel; - unsigned int pmic_bms_irq[PM_BMS_MAX_INTS]; - DECLARE_BITMAP(enabled_irqs, PM_BMS_MAX_INTS); - struct mutex bms_output_lock; - struct single_row_lut *adjusted_fcc_temp_lut; - unsigned int charging_began; - unsigned int start_percent; - unsigned int end_percent; - unsigned int alarm_low_mv; - unsigned int alarm_high_mv; - - int charge_time_us; - int catch_up_time_us; - enum battery_type batt_type; - uint16_t ocv_reading_at_100; - int max_voltage_uv; - - int chg_term_ua; - int default_rbatt_mohm; - int amux_2_trim_delta; - uint16_t prev_last_good_ocv_raw; - int rconn_mohm; - int rbatt_capacitive_mohm; - struct mutex last_ocv_uv_mutex; - int last_ocv_uv; - int last_ocv_temp_decidegc; - int pon_ocv_uv; - int last_cc_uah; - unsigned long tm_sec; - - int enable_fcc_learning; - int min_fcc_learning_soc; - int min_fcc_ocv_pc; - int min_fcc_learning_samples; - struct fcc_data *fcc_table; - int fcc_new; - int start_real_soc; - int pc_at_start_charge; - - int shutdown_soc; - int shutdown_iavg_ua; - struct delayed_work calculate_soc_delayed_work; - struct timespec t_soc_queried; - unsigned long last_recalc_time; - int shutdown_soc_valid_limit; - int ignore_shutdown_soc; - int prev_iavg_ua; - int prev_uuc_iavg_ma; - int prev_pc_unusable; - int adjust_soc_low_threshold; - - int ibat_at_cv_ua; - int soc_at_cv; - int prev_chg_soc; - struct power_supply *batt_psy; - struct wake_lock low_voltage_wake_lock; - int soc_calc_period; - int normal_voltage_calc_ms; - int low_voltage_calc_ms; - int imax_ua; - struct wake_lock soc_wake_lock; - int disable_flat_portion_ocv; - int ocv_dis_high_soc; - int ocv_dis_low_soc; - int high_ocv_correction_limit_uv; - int low_ocv_correction_limit_uv; - int hold_soc_est; - int prev_vbat_batt_terminal_uv; - int vbatt_cutoff_count; - int low_voltage_detect; - int vbatt_cutoff_retries; - bool first_report_after_suspend; - bool soc_updated_on_resume; - int last_soc_at_suspend; -}; - -/* - * protects against simultaneous adjustment of ocv based on shutdown soc and - * invalidating the shutdown soc - */ -static DEFINE_MUTEX(soc_invalidation_mutex); -static int shutdown_soc_invalid; -static struct pm8921_bms_chip *the_chip; - -#define DEFAULT_RBATT_MOHMS 128 -#define DEFAULT_OCV_MICROVOLTS 3900000 -#define DEFAULT_CHARGE_CYCLES 0 - -#define DELTA_FCC_PERCENT 5 -#define MIN_START_PERCENT_FOR_LEARNING 20 -#define MIN_START_OCV_PERCENT_FOR_LEARNING 30 -#define MAX_FCC_LEARNING_COUNT 5 -#define VALID_FCC_CHGCYL_RANGE 50 - -static int last_usb_cal_delta_uv = 1800; -module_param(last_usb_cal_delta_uv, int, 0644); - -static int last_chargecycles = DEFAULT_CHARGE_CYCLES; -static int last_charge_increase; -static int last_fcc_update_count; -static int min_fcc_cycles = -EINVAL; -module_param(last_chargecycles, int, 0644); -module_param(last_charge_increase, int, 0644); -module_param(last_fcc_update_count, int, 0644); - -static int calculated_soc = -EINVAL; -static int last_soc = -EINVAL; -static int last_real_fcc_mah = -EINVAL; -static int last_real_fcc_batt_temp = -EINVAL; -static int battery_removed; - -static int pm8921_battery_gauge_alarm_notify(struct notifier_block *nb, - unsigned long status, void *unused); - -static struct notifier_block alarm_notifier = { - .notifier_call = pm8921_battery_gauge_alarm_notify, -}; - -static int bms_ro_ops_set(const char *val, const struct kernel_param *kp) -{ - return -EINVAL; -} - -static struct kernel_param_ops bms_param_ops = { - .set = bms_ro_ops_set, - .get = param_get_int, -}; -/* Make last_soc as read only as it is already calculated from shutdown_soc */ -module_param_cb(last_soc, &bms_param_ops, &last_soc, 0644); -module_param_cb(battery_removed, &bms_param_ops, &battery_removed, 0644); -module_param_cb(min_fcc_cycles, &bms_param_ops, &min_fcc_cycles, 0644); - -/* - * bms_fake_battery is set in setups where a battery emulator is used instead - * of a real battery. This makes the bms driver report a different/fake value - * regardless of the calculated state of charge. - */ -static int bms_fake_battery = -EINVAL; -module_param(bms_fake_battery, int, 0644); - -/* bms_start_XXX and bms_end_XXX are read only */ -static int bms_start_percent; -static int bms_start_ocv_uv; -static int bms_start_cc_uah; -static int bms_end_percent; -static int bms_end_ocv_uv; -static int bms_end_cc_uah; - -static struct kernel_param_ops bms_ro_param_ops = { - .set = bms_ro_ops_set, - .get = param_get_int, -}; -module_param_cb(bms_start_percent, &bms_ro_param_ops, &bms_start_percent, 0644); -module_param_cb(bms_start_ocv_uv, &bms_ro_param_ops, &bms_start_ocv_uv, 0644); -module_param_cb(bms_start_cc_uah, &bms_ro_param_ops, &bms_start_cc_uah, 0644); - -module_param_cb(bms_end_percent, &bms_ro_param_ops, &bms_end_percent, 0644); -module_param_cb(bms_end_ocv_uv, &bms_ro_param_ops, &bms_end_ocv_uv, 0644); -module_param_cb(bms_end_cc_uah, &bms_ro_param_ops, &bms_end_cc_uah, 0644); - -static void readjust_fcc_table(void) -{ - struct single_row_lut *temp, *old; - int i, fcc, ratio; - - if (!the_chip->enable_fcc_learning || battery_removed) - return; - - if (!the_chip->fcc_temp_lut) { - pr_err("The static fcc lut table is NULL\n"); - return; - } - - temp = kzalloc(sizeof(struct single_row_lut), GFP_KERNEL); - if (!temp) { - pr_err("Cannot allocate memory for adjusted fcc table\n"); - return; - } - - fcc = interpolate_fcc(the_chip->fcc_temp_lut, last_real_fcc_batt_temp); - - temp->cols = the_chip->fcc_temp_lut->cols; - for (i = 0; i < the_chip->fcc_temp_lut->cols; i++) { - temp->x[i] = the_chip->fcc_temp_lut->x[i]; - ratio = div_u64(the_chip->fcc_temp_lut->y[i] * 1000, fcc); - temp->y[i] = (ratio * last_real_fcc_mah); - temp->y[i] /= 1000; - pr_debug("temp=%d, staticfcc=%d, adjfcc=%d, ratio=%d\n", - temp->x[i], the_chip->fcc_temp_lut->y[i], - temp->y[i], ratio); - } - - old = the_chip->adjusted_fcc_temp_lut; - the_chip->adjusted_fcc_temp_lut = temp; - kfree(old); -} - -static int bms_last_real_fcc_set(const char *val, - const struct kernel_param *kp) -{ - int rc = 0; - - if (battery_removed) - return rc; - - if (last_real_fcc_mah == -EINVAL) - rc = param_set_int(val, kp); - if (rc) { - pr_err("Failed to set last_real_fcc_mah rc=%d\n", rc); - return rc; - } - if (last_real_fcc_batt_temp != -EINVAL) - readjust_fcc_table(); - return rc; -} -static struct kernel_param_ops bms_last_real_fcc_param_ops = { - .set = bms_last_real_fcc_set, - .get = param_get_int, -}; -module_param_cb(last_real_fcc_mah, &bms_last_real_fcc_param_ops, - &last_real_fcc_mah, 0644); - -static int bms_last_real_fcc_batt_temp_set(const char *val, - const struct kernel_param *kp) -{ - int rc = 0; - - if (battery_removed) - return rc; - - if (last_real_fcc_batt_temp == -EINVAL) - rc = param_set_int(val, kp); - if (rc) { - pr_err("Failed to set last_real_fcc_batt_temp rc=%d\n", rc); - return rc; - } - if (last_real_fcc_mah != -EINVAL) - readjust_fcc_table(); - return rc; -} - -static struct kernel_param_ops bms_last_real_fcc_batt_temp_param_ops = { - .set = bms_last_real_fcc_batt_temp_set, - .get = param_get_int, -}; -module_param_cb(last_real_fcc_batt_temp, &bms_last_real_fcc_batt_temp_param_ops, - &last_real_fcc_batt_temp, 0644); - -static int pm_bms_get_rt_status(struct pm8921_bms_chip *chip, int irq_id) -{ - return pm8xxx_read_irq_stat(chip->dev->parent, - chip->pmic_bms_irq[irq_id]); -} - -static void pm8921_bms_enable_irq(struct pm8921_bms_chip *chip, int interrupt) -{ - if (!__test_and_set_bit(interrupt, chip->enabled_irqs)) { - dev_dbg(chip->dev, "%s %d\n", __func__, - chip->pmic_bms_irq[interrupt]); - enable_irq(chip->pmic_bms_irq[interrupt]); - } -} - -static void pm8921_bms_disable_irq(struct pm8921_bms_chip *chip, int interrupt) -{ - if (__test_and_clear_bit(interrupt, chip->enabled_irqs)) { - pr_debug("%d\n", chip->pmic_bms_irq[interrupt]); - disable_irq_nosync(chip->pmic_bms_irq[interrupt]); - } -} - -static int pm_bms_masked_write(struct pm8921_bms_chip *chip, u16 addr, - u8 mask, u8 val) -{ - int rc; - u8 reg; - - rc = pm8xxx_readb(chip->dev->parent, addr, ®); - if (rc) { - pr_err("read failed addr = %03X, rc = %d\n", addr, rc); - return rc; - } - reg &= ~mask; - reg |= val & mask; - rc = pm8xxx_writeb(chip->dev->parent, addr, reg); - if (rc) { - pr_err("write failed addr = %03X, rc = %d\n", addr, rc); - return rc; - } - return 0; -} - -static int usb_chg_plugged_in(struct pm8921_bms_chip *chip) -{ - int val = pm8921_is_usb_chg_plugged_in(); - - /* if the charger driver was not initialized, use the restart reason */ - if (val == -EINVAL) { - if (pm8xxx_restart_reason(chip->dev->parent) - == PM8XXX_RESTART_CHG) - val = 1; - else - val = 0; - } - - return val; -} - -static void pm8921_bms_low_voltage_config(struct pm8921_bms_chip *chip, - int time_ms) -{ - int ms = 0; - - /* if work was pending and was cancelled, calculate SOC immediately */ - if (!cancel_delayed_work_sync(&chip->calculate_soc_delayed_work)) - ms = time_ms; - - chip->soc_calc_period = time_ms; - schedule_delayed_work(&chip->calculate_soc_delayed_work, - msecs_to_jiffies(ms)); -} - -static int pm8921_bms_enable_batt_alarm(struct pm8921_bms_chip *chip) -{ - int rc = 0; - - rc = pm8xxx_batt_alarm_enable(PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (rc) { - pr_err("unable to set batt alarm state rc=%d\n", rc); - return rc; - } - - return rc; -} - -static int pm8921_bms_configure_batt_alarm(struct pm8921_bms_chip *chip) -{ - int rc = 0; - - rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (rc) { - pr_err("unable to set batt alarm state rc=%d\n", rc); - return rc; - } - - /* - * The batt-alarm driver requires sane values for both min / max, - * regardless of whether they're both activated. - */ - rc = pm8xxx_batt_alarm_threshold_set( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR, - chip->alarm_low_mv); - if (!rc) - rc = pm8xxx_batt_alarm_threshold_set( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR, - chip->alarm_high_mv); - if (rc) { - pr_err("unable to set batt alarm threshold rc=%d\n", rc); - return rc; - } - - rc = pm8xxx_batt_alarm_hold_time_set( - PM8XXX_BATT_ALARM_HOLD_TIME_16_MS); - if (rc) { - pr_err("unable to set batt alarm hold time rc=%d\n", rc); - return rc; - } - - /* PWM enabled at 2Hz */ - rc = pm8xxx_batt_alarm_pwm_rate_set(1, 7, 4); - if (rc) { - pr_err("unable to set batt alarm pwm rate rc=%d\n", rc); - return rc; - } - - rc = pm8xxx_batt_alarm_register_notifier(&alarm_notifier); - if (rc) { - pr_err("unable to register alarm notifier rc=%d\n", rc); - return rc; - } - - return rc; -} - -static int pm8921_battery_gauge_alarm_notify(struct notifier_block *nb, - unsigned long status, void *unused) -{ - int rc; - - if (!the_chip) { - pr_err("not initialized\n"); - return -EINVAL; - } - - switch (status) { - case 0: - pr_debug("spurious interrupt\n"); - break; - case 1: - pr_debug("Low voltage alarm triggered\n"); - /* - * hold the low voltage wakelock until the soc - * work finds it appropriate to release it. - */ - if (!wake_lock_active(&the_chip->low_voltage_wake_lock)) { - pr_debug("Holding low voltage wakelock\n"); - wake_lock(&the_chip->low_voltage_wake_lock); - pm8921_bms_low_voltage_config(the_chip, - the_chip->low_voltage_calc_ms); - } - - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_enable( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (rc) - pr_err("unable to set alarm state rc=%d\n", rc); - break; - case 2: - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_enable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (rc) - pr_err("unable to set alarm state rc=%d\n", rc); - - break; - default: - pr_err("error received\n"); - break; - } - - return 0; -}; - - -#define HOLD_OREG_DATA BIT(1) -static int pm_bms_lock_output_data(struct pm8921_bms_chip *chip) -{ - int rc; - - rc = pm_bms_masked_write(chip, BMS_CONTROL, HOLD_OREG_DATA, - HOLD_OREG_DATA); - if (rc) { - pr_err("couldnt lock bms output rc = %d\n", rc); - return rc; - } - return 0; -} - -static int pm_bms_unlock_output_data(struct pm8921_bms_chip *chip) -{ - int rc; - - rc = pm_bms_masked_write(chip, BMS_CONTROL, HOLD_OREG_DATA, 0); - if (rc) { - pr_err("fail to unlock BMS_CONTROL rc = %d\n", rc); - return rc; - } - return 0; -} - -#define SELECT_OUTPUT_DATA 0x1C -#define SELECT_OUTPUT_TYPE_SHIFT 2 -#define OCV_FOR_RBATT 0x0 -#define VSENSE_FOR_RBATT 0x1 -#define VBATT_FOR_RBATT 0x2 -#define CC_MSB 0x3 -#define CC_LSB 0x4 -#define LAST_GOOD_OCV_VALUE 0x5 -#define VSENSE_AVG 0x6 -#define VBATT_AVG 0x7 - -static int pm_bms_read_output_data(struct pm8921_bms_chip *chip, int type, - int16_t *result) -{ - int rc; - u8 reg; - - if (!result) { - pr_err("result pointer null\n"); - return -EINVAL; - } - *result = 0; - if (type < OCV_FOR_RBATT || type > VBATT_AVG) { - pr_err("invalid type %d asked to read\n", type); - return -EINVAL; - } - - rc = pm_bms_masked_write(chip, BMS_CONTROL, SELECT_OUTPUT_DATA, - type << SELECT_OUTPUT_TYPE_SHIFT); - if (rc) { - pr_err("fail to select %d type in BMS_CONTROL rc = %d\n", - type, rc); - return rc; - } - - rc = pm8xxx_readb(chip->dev->parent, BMS_OUTPUT0, ®); - if (rc) { - pr_err("fail to read BMS_OUTPUT0 for type %d rc = %d\n", - type, rc); - return rc; - } - *result = reg; - rc = pm8xxx_readb(chip->dev->parent, BMS_OUTPUT1, ®); - if (rc) { - pr_err("fail to read BMS_OUTPUT1 for type %d rc = %d\n", - type, rc); - return rc; - } - *result |= reg << 8; - pr_debug("type %d result %x", type, *result); - return 0; -} - -#define V_PER_BIT_MUL_FACTOR 97656 -#define V_PER_BIT_DIV_FACTOR 1000 -#define XOADC_INTRINSIC_OFFSET 0x6000 -static int xoadc_reading_to_microvolt(unsigned int a) -{ - if (a <= XOADC_INTRINSIC_OFFSET) - return 0; - - return (a - XOADC_INTRINSIC_OFFSET) - * V_PER_BIT_MUL_FACTOR / V_PER_BIT_DIV_FACTOR; -} - -#define XOADC_CALIB_UV 625000 -#define VBATT_MUL_FACTOR 3 -static int adjust_xo_vbatt_reading(struct pm8921_bms_chip *chip, - int usb_chg, unsigned int uv) -{ - s64 numerator, denominator; - int local_delta; - - if (uv == 0) - return 0; - - /* dont adjust if not calibrated */ - if (chip->xoadc_v0625 == 0 || chip->xoadc_v125 == 0) { - pr_debug("No cal yet return %d\n", VBATT_MUL_FACTOR * uv); - return VBATT_MUL_FACTOR * uv; - } - - if (usb_chg) - local_delta = last_usb_cal_delta_uv; - else - local_delta = 0; - - pr_debug("using delta = %d\n", local_delta); - numerator = ((s64)uv - chip->xoadc_v0625 - local_delta) - * XOADC_CALIB_UV; - denominator = (s64)chip->xoadc_v125 - chip->xoadc_v0625 - local_delta; - if (denominator == 0) - return uv * VBATT_MUL_FACTOR; - return (XOADC_CALIB_UV + local_delta + div_s64(numerator, denominator)) - * VBATT_MUL_FACTOR; -} - -#define CC_RESOLUTION_N 868056 -#define CC_RESOLUTION_D 10000 - -static s64 cc_to_microvolt(struct pm8921_bms_chip *chip, s64 cc) -{ - return div_s64(cc * CC_RESOLUTION_N, CC_RESOLUTION_D); -} - -#define CC_READING_TICKS 56 -#define SLEEP_CLK_HZ 32764 -#define SECONDS_PER_HOUR 3600 -/** - * ccmicrovolt_to_pvh - - * @cc_uv: coulumb counter converted to uV - * - * RETURNS: coulumb counter based charge in pVh - * (pico Volt Hour) - */ -static s64 ccmicrovolt_to_pvh(s64 cc_uv) -{ - return div_s64(cc_uv * CC_READING_TICKS * 1000000L, - SLEEP_CLK_HZ * SECONDS_PER_HOUR); -} - -/* returns the signed value read from the hardware */ -static int read_cc(struct pm8921_bms_chip *chip, int *result) -{ - int rc; - uint16_t msw, lsw; - - *result = 0; - rc = pm_bms_read_output_data(chip, CC_LSB, &lsw); - if (rc) { - pr_err("fail to read CC_LSB rc = %d\n", rc); - return rc; - } - rc = pm_bms_read_output_data(chip, CC_MSB, &msw); - if (rc) { - pr_err("fail to read CC_MSB rc = %d\n", rc); - return rc; - } - *result = msw << 16 | lsw; - pr_debug("msw = %04x lsw = %04x cc = %d\n", msw, lsw, *result); - return 0; -} - -static int adjust_xo_vbatt_reading_for_mbg(struct pm8921_bms_chip *chip, - int result) -{ - int64_t numerator; - int64_t denominator; - - if (chip->amux_2_trim_delta == 0) - return result; - - numerator = (s64)result * 1000000; - denominator = (1000000 + (410 * (s64)chip->amux_2_trim_delta)); - return div_s64(numerator, denominator); -} - -static int convert_vbatt_raw_to_uv(struct pm8921_bms_chip *chip, - int usb_chg, - uint16_t reading, int *result) -{ - *result = xoadc_reading_to_microvolt(reading); - pr_debug("raw = %04x vbatt = %u\n", reading, *result); - *result = adjust_xo_vbatt_reading(chip, usb_chg, *result); - pr_debug("after adj vbatt = %u\n", *result); - *result = adjust_xo_vbatt_reading_for_mbg(chip, *result); - return 0; -} - -static int convert_vsense_to_uv(struct pm8921_bms_chip *chip, - int16_t reading, int *result) -{ - *result = pm8xxx_ccadc_reading_to_microvolt(chip->revision, reading); - pr_debug("raw = %04x vsense = %d\n", reading, *result); - *result = pm8xxx_cc_adjust_for_gain(*result); - pr_debug("after adj vsense = %d\n", *result); - return 0; -} - -static int read_vsense_avg(struct pm8921_bms_chip *chip, int *result) -{ - int rc; - int16_t reading; - - rc = pm_bms_read_output_data(chip, VSENSE_AVG, &reading); - if (rc) { - pr_err("fail to read VSENSE_AVG rc = %d\n", rc); - return rc; - } - - convert_vsense_to_uv(chip, reading, result); - return 0; -} - -static int get_batt_temp(struct pm8921_bms_chip *chip, int *batt_temp) -{ - int rc; - struct pm8xxx_adc_chan_result result; - - rc = pm8xxx_adc_read(chip->batt_temp_channel, &result); - if (rc) { - pr_err("error reading batt_temp_channel = %d, rc = %d\n", - chip->batt_temp_channel, rc); - return rc; - } - *batt_temp = result.physical; - pr_debug("batt_temp phy = %lld meas = 0x%llx\n", result.physical, - result.measurement); - return 0; -} - -#define BMS_MODE_BIT BIT(6) -#define EN_VBAT_BIT BIT(5) -#define OVERRIDE_MODE_DELAY_MS 20 -int override_mode_simultaneous_battery_voltage_and_current(int *ibat_ua, - int *vbat_uv) -{ - int16_t vsense_raw; - int16_t vbat_raw; - int vsense_uv; - int usb_chg; - int batt_temp; - - mutex_lock(&the_chip->bms_output_lock); - - pm8xxx_writeb(the_chip->dev->parent, BMS_S1_DELAY, 0x00); - pm_bms_masked_write(the_chip, BMS_CONTROL, - BMS_MODE_BIT | EN_VBAT_BIT, BMS_MODE_BIT | EN_VBAT_BIT); - - msleep(OVERRIDE_MODE_DELAY_MS); - - pm_bms_lock_output_data(the_chip); - pm_bms_read_output_data(the_chip, VSENSE_AVG, &vsense_raw); - pm_bms_read_output_data(the_chip, VBATT_AVG, &vbat_raw); - pm_bms_unlock_output_data(the_chip); - pm_bms_masked_write(the_chip, BMS_CONTROL, - BMS_MODE_BIT | EN_VBAT_BIT, 0); - - pm8xxx_writeb(the_chip->dev->parent, BMS_S1_DELAY, 0x0B); - - mutex_unlock(&the_chip->bms_output_lock); - - get_batt_temp(the_chip, &batt_temp); - usb_chg = usb_chg_plugged_in(the_chip); - - convert_vbatt_raw_to_uv(the_chip, usb_chg, vbat_raw, vbat_uv); - convert_vsense_to_uv(the_chip, vsense_raw, &vsense_uv); - *ibat_ua = div_s64((s64)vsense_uv * 1000000LL, the_chip->r_sense_uohm); - - pr_debug("vsense_raw = 0x%x vbat_raw = 0x%x" - " ibat_ua = %d vbat_uv = %d\n", - (uint16_t)vsense_raw, (uint16_t)vbat_raw, - *ibat_ua, *vbat_uv); - return 0; -} - -#define MBG_TRANSIENT_ERROR_UV 15000 -static void adjust_pon_ocv(struct pm8921_bms_chip *chip, int *uv) -{ - /* - * In 8921 parts the PON ocv is taken when the MBG is not settled. - * decrease the pon ocv by 15mV raw value to account for it - * Since a 1/3rd of vbatt is supplied to the adc the raw value - * needs to be adjusted by 5mV worth bits - */ - if (*uv >= MBG_TRANSIENT_ERROR_UV) - *uv -= MBG_TRANSIENT_ERROR_UV; -} - -#define SEL_ALT_OREG_BIT BIT(2) -static int ocv_ir_compensation(struct pm8921_bms_chip *chip, int ocv) -{ - int compensated_ocv; - int ibatt_ua; - int rbatt_mohm = chip->default_rbatt_mohm + chip->rconn_mohm; - - pm_bms_masked_write(chip, BMS_TEST1, - SEL_ALT_OREG_BIT, SEL_ALT_OREG_BIT); - - /* since the SEL_ALT_OREG_BIT is set this will give us VSENSE_OCV */ - pm8921_bms_get_battery_current(&ibatt_ua); - compensated_ocv = ocv + div_s64((s64)ibatt_ua * rbatt_mohm, 1000); - pr_debug("comp ocv = %d, ocv = %d, ibatt_ua = %d, rbatt_mohm = %d\n", - compensated_ocv, ocv, ibatt_ua, rbatt_mohm); - - pm_bms_masked_write(chip, BMS_TEST1, SEL_ALT_OREG_BIT, 0); - return compensated_ocv; -} - -#define RESET_CC_BIT BIT(3) -static int reset_cc(struct pm8921_bms_chip *chip) -{ - int rc; - - rc = pm_bms_masked_write(chip, BMS_TEST1, RESET_CC_BIT, RESET_CC_BIT); - if (rc < 0) { - pr_err("err setting cc reset rc = %d\n", rc); - return rc; - } - - /* sleep 100uS for the coulomb counter to reset */ - udelay(100); - - rc = pm_bms_masked_write(chip, BMS_TEST1, RESET_CC_BIT, 0); - if (rc < 0) - pr_err("err clearing cc reset rc = %d\n", rc); - return rc; -} - -static int estimate_ocv(struct pm8921_bms_chip *chip) -{ - int ibat_ua, vbat_uv, ocv_est_uv; - int rc; - int rbatt_mohm = chip->default_rbatt_mohm + chip->rconn_mohm - + chip->rbatt_capacitive_mohm; - - rc = pm8921_bms_get_simultaneous_battery_voltage_and_current( - &ibat_ua, - &vbat_uv); - if (rc) { - pr_err("simultaneous failed rc = %d\n", rc); - return rc; - } - - ocv_est_uv = vbat_uv + (ibat_ua * rbatt_mohm) / 1000; - pr_debug("estimated pon ocv = %d\n", ocv_est_uv); - return ocv_est_uv; -} - -static bool is_warm_restart(struct pm8921_bms_chip *chip) -{ - u8 reg; - int rc; - - rc = pm8xxx_readb(chip->dev->parent, PON_CNTRL_6, ®); - if (rc) { - pr_err("err reading pon 6 rc = %d\n", rc); - return false; - } - return reg & WD_BIT; -} - -#define IBAT_TOL_MASK 0x0F -#define OCV_TOL_MASK 0xF0 -#define IBAT_TOL_DEFAULT 0x03 -#define IBAT_TOL_NOCHG 0x0F -#define OCV_TOL_DEFAULT 0x20 -#define OCV_TOL_NO_OCV 0x00 -static int pm8921_bms_stop_ocv_updates(void) -{ - if (!the_chip) { - pr_err("BMS driver has not been initialized yet!\n"); - return -EINVAL; - } - pr_debug("stopping ocv updates\n"); - return pm_bms_masked_write(the_chip, BMS_TOLERANCES, - OCV_TOL_MASK, OCV_TOL_NO_OCV); -} - -static int pm8921_bms_start_ocv_updates(void) -{ - if (!the_chip) { - pr_err("BMS driver has not been initialized yet!\n"); - return -EINVAL; - } - pr_debug("starting ocv updates\n"); - return pm_bms_masked_write(the_chip, BMS_TOLERANCES, - OCV_TOL_MASK, OCV_TOL_DEFAULT); -} - -static int reset_bms_for_test(void) -{ - int ibat_ua, vbat_uv, rc; - int ocv_est_uv; - - if (!the_chip) { - pr_err("BMS driver has not been initialized yet!\n"); - return -EINVAL; - } - - rc = pm8921_bms_get_simultaneous_battery_voltage_and_current( - &ibat_ua, - &vbat_uv); - /* - * don't include rbatt and rbatt_capacitve since we expect this to - * be used with a fake battery which does not have internal resistnaces - */ - ocv_est_uv = vbat_uv + (ibat_ua * the_chip->rconn_mohm) / 1000; - pr_debug("forcing ocv to be %d due to bms reset mode\n", ocv_est_uv); - the_chip->last_ocv_uv = ocv_est_uv; - last_soc = -EINVAL; - reset_cc(the_chip); - the_chip->last_cc_uah = 0; - pm8921_bms_stop_ocv_updates(); - - pr_debug("bms reset to ocv = %duv vbat_ua = %d ibat_ua = %d\n", - the_chip->last_ocv_uv, vbat_uv, ibat_ua); - - return rc; -} - -static int bms_reset_set(const char *val, const struct kernel_param *kp) -{ - int rc; - - rc = param_set_bool(val, kp); - if (rc) { - pr_err("Unable to set bms_reset: %d\n", rc); - return rc; - } - - if (*val == 'Y') { - rc = reset_bms_for_test(); - if (rc) { - pr_err("Unable to modify bms_reset: %d\n", rc); - return rc; - } - } - return 0; -} - -static struct kernel_param_ops bms_reset_ops = { - .set = bms_reset_set, - .get = param_get_bool, -}; - -static bool bms_reset; -module_param_cb(bms_reset, &bms_reset_ops, &bms_reset, 0644); -/* - * This reflects what should the CC readings should be for - * a 5mAh discharge. This value is dependent on - * CC_RESOLUTION_N, CC_RESOLUTION_D, CC_READING_TICKS - * and rsense - */ -#define CC_RAW_5MAH 0x00110000 -#define MIN_OCV_UV 2000000 -#define OCV_RAW_UNINITIALIZED 0xFFFF -static int read_soc_params_raw(struct pm8921_bms_chip *chip, - struct pm8921_soc_params *raw, - int batt_temp_decidegc) -{ - int usb_chg; - int est_ocv_uv; - - mutex_lock(&chip->bms_output_lock); - pm_bms_lock_output_data(chip); - - pm_bms_read_output_data(chip, - LAST_GOOD_OCV_VALUE, &raw->last_good_ocv_raw); - read_cc(chip, &raw->cc); - - pm_bms_unlock_output_data(chip); - mutex_unlock(&chip->bms_output_lock); - - usb_chg = usb_chg_plugged_in(chip); - - if (chip->prev_last_good_ocv_raw == OCV_RAW_UNINITIALIZED) { - chip->prev_last_good_ocv_raw = raw->last_good_ocv_raw; - - convert_vbatt_raw_to_uv(chip, usb_chg, - raw->last_good_ocv_raw, &raw->last_good_ocv_uv); - adjust_pon_ocv(chip, &raw->last_good_ocv_uv); - raw->last_good_ocv_uv = ocv_ir_compensation(chip, - raw->last_good_ocv_uv); - chip->last_ocv_uv = raw->last_good_ocv_uv; - - if (is_warm_restart(chip) - || raw->cc > CC_RAW_5MAH - || (raw->last_good_ocv_uv < MIN_OCV_UV - && raw->cc > 0)) { - /* - * The CC value is higher than 5mAh. - * The phone started without going through a pon - * sequence - * OR - * The ocv was very small and there was no - * charging in the bootloader - * - reset the CC and take an ocv again - */ - pr_debug("cc_raw = 0x%x may be > 5mAh(0x%x)\n", - raw->cc, CC_RAW_5MAH); - pr_debug("ocv_uv = %d ocv_raw = 0x%x may be < 2V\n", - chip->last_ocv_uv, - raw->last_good_ocv_raw); - est_ocv_uv = estimate_ocv(chip); - if (est_ocv_uv > 0) { - raw->last_good_ocv_uv = est_ocv_uv; - chip->last_ocv_uv = est_ocv_uv; - reset_cc(chip); - raw->cc = 0; - } - } - chip->last_ocv_temp_decidegc = batt_temp_decidegc; - pr_debug("PON_OCV_UV = %d\n", chip->last_ocv_uv); - } else if (chip->prev_last_good_ocv_raw != raw->last_good_ocv_raw) { - chip->prev_last_good_ocv_raw = raw->last_good_ocv_raw; - convert_vbatt_raw_to_uv(chip, usb_chg, - raw->last_good_ocv_raw, &raw->last_good_ocv_uv); - chip->last_ocv_uv = raw->last_good_ocv_uv; - chip->last_ocv_temp_decidegc = batt_temp_decidegc; - /* forget the old cc value upon ocv */ - chip->last_cc_uah = 0; - } else { - raw->last_good_ocv_uv = chip->last_ocv_uv; - } - - /* stop faking 100% after an OCV event */ - if (chip->ocv_reading_at_100 != raw->last_good_ocv_raw) - chip->ocv_reading_at_100 = OCV_RAW_UNINITIALIZED; - pr_debug("0p625 = %duV\n", chip->xoadc_v0625); - pr_debug("1p25 = %duV\n", chip->xoadc_v125); - pr_debug("last_good_ocv_raw= 0x%x, last_good_ocv_uv= %duV\n", - raw->last_good_ocv_raw, raw->last_good_ocv_uv); - pr_debug("cc_raw= 0x%x\n", raw->cc); - return 0; -} - -static int get_rbatt(struct pm8921_bms_chip *chip, int soc_rbatt, int batt_temp) -{ - int rbatt, scalefactor; - - rbatt = chip->default_rbatt_mohm; - pr_debug("rbatt before scaling = %d\n", rbatt); - if (chip->rbatt_sf_lut == NULL) { - pr_debug("RBATT = %d\n", rbatt); - return rbatt; - } - /* Convert the batt_temp to DegC from deciDegC */ - batt_temp = batt_temp / 10; - scalefactor = interpolate_scalingfactor(chip->rbatt_sf_lut, - batt_temp, soc_rbatt); - pr_debug("rbatt sf = %d for batt_temp = %d, soc_rbatt = %d\n", - scalefactor, batt_temp, soc_rbatt); - rbatt = (rbatt * scalefactor) / 100; - - rbatt += the_chip->rconn_mohm; - pr_debug("adding rconn_mohm = %d rbatt = %d\n", - the_chip->rconn_mohm, rbatt); - - rbatt += the_chip->rbatt_capacitive_mohm; - pr_debug("adding rbatt_capacitive_mohm = %d rbatt = %d\n", - the_chip->rbatt_capacitive_mohm, rbatt); - - if (is_between(20, 10, soc_rbatt)) - rbatt = rbatt - + ((20 - soc_rbatt) * chip->delta_rbatt_mohm) / 10; - else - if (is_between(10, 0, soc_rbatt)) - rbatt = rbatt + chip->delta_rbatt_mohm; - - pr_debug("RBATT = %d\n", rbatt); - return rbatt; -} - -static int calculate_fcc_uah(struct pm8921_bms_chip *chip, int batt_temp, - int chargecycles) -{ - int initfcc, result, scalefactor = 0; - - if (chip->adjusted_fcc_temp_lut == NULL) { - initfcc = interpolate_fcc(chip->fcc_temp_lut, batt_temp); - - scalefactor = interpolate_scalingfactor_fcc(chip->fcc_sf_lut, - chargecycles); - - /* Multiply the initial FCC value by the scale factor. */ - result = (initfcc * scalefactor * 1000) / 100; - pr_debug("fcc = %d uAh\n", result); - return result; - } else { - return 1000 * interpolate_fcc(chip->adjusted_fcc_temp_lut, - batt_temp); - } -} - -static int get_battery_uvolts(struct pm8921_bms_chip *chip, int *uvolts) -{ - int rc; - struct pm8xxx_adc_chan_result result; - - rc = pm8xxx_adc_read(chip->vbat_channel, &result); - if (rc) { - pr_err("error reading adc channel = %d, rc = %d\n", - chip->vbat_channel, rc); - return rc; - } - pr_debug("mvolts phy = %lld meas = 0x%llx", result.physical, - result.measurement); - *uvolts = (int)result.physical; - return 0; -} - -static int adc_based_ocv(struct pm8921_bms_chip *chip, int *ocv) -{ - int vbatt, rbatt, ibatt_ua, rc; - - rc = get_battery_uvolts(chip, &vbatt); - if (rc) { - pr_err("failed to read vbatt from adc rc = %d\n", rc); - return rc; - } - - rc = pm8921_bms_get_battery_current(&ibatt_ua); - if (rc) { - pr_err("failed to read batt current rc = %d\n", rc); - return rc; - } - - rbatt = chip->default_rbatt_mohm; - *ocv = vbatt + (ibatt_ua * rbatt)/1000; - return 0; -} - -static int calculate_pc(struct pm8921_bms_chip *chip, int ocv_uv, - int batt_temp_decidegc, int chargecycles) -{ - int pc, scalefactor; - - pc = interpolate_pc(chip->pc_temp_ocv_lut, - batt_temp_decidegc / 10, ocv_uv / 1000); - pr_debug("pc = %u for ocv = %dmicroVolts batt_temp = %d\n", - pc, ocv_uv, batt_temp_decidegc); - - scalefactor = interpolate_scalingfactor(chip->pc_sf_lut, - chargecycles, pc); - pr_debug("scalefactor = %u batt_temp = %d\n", - scalefactor, batt_temp_decidegc); - - /* Multiply the initial FCC value by the scale factor. */ - pc = (pc * scalefactor) / 100; - return pc; -} - -/** - * calculate_cc_uah - - * @chip: the bms chip pointer - * @cc: the cc reading from bms h/w - * @val: return value - * @coulumb_counter: adjusted coulumb counter for 100% - * - * RETURNS: in val pointer coulumb counter based charger in uAh - * (micro Amp hour) - */ -static void calculate_cc_uah(struct pm8921_bms_chip *chip, int cc, int *val) -{ - int64_t cc_voltage_uv, cc_pvh, cc_uah; - - cc_voltage_uv = cc; - pr_debug("cc = %d\n", cc); - cc_voltage_uv = cc_to_microvolt(chip, cc_voltage_uv); - cc_voltage_uv = pm8xxx_cc_adjust_for_gain(cc_voltage_uv); - pr_debug("cc_voltage_uv = %lld microvolts\n", cc_voltage_uv); - cc_pvh = ccmicrovolt_to_pvh(cc_voltage_uv); - pr_debug("cc_pvh = %lld pico_volt_hour\n", cc_pvh); - cc_uah = div_s64(cc_pvh, chip->r_sense_uohm); - *val = cc_uah; -} - -int pm8921_bms_cc_uah(int *cc_uah) -{ - int cc; - - *cc_uah = 0; - - if (!the_chip) - return -EINVAL; - - read_cc(the_chip, &cc); - calculate_cc_uah(the_chip, cc, cc_uah); - - return 0; -} -EXPORT_SYMBOL(pm8921_bms_cc_uah); - -static int calculate_termination_uuc(struct pm8921_bms_chip *chip, - int batt_temp, int chargecycles, - int fcc_uah, int i_ma, - int *ret_pc_unusable) -{ - int unusable_uv, pc_unusable, uuc; - int i = 0; - int ocv_mv; - int batt_temp_degc = batt_temp / 10; - int rbatt_mohm; - int delta_uv; - int prev_delta_uv = 0; - int prev_rbatt_mohm = 0; - int prev_ocv_mv = 0; - int uuc_rbatt_uv; - - for (i = 0; i <= 100; i++) { - ocv_mv = interpolate_ocv(chip->pc_temp_ocv_lut, - batt_temp_degc, i); - rbatt_mohm = get_rbatt(chip, i, batt_temp); - unusable_uv = (rbatt_mohm * i_ma) + (chip->v_cutoff * 1000); - delta_uv = ocv_mv * 1000 - unusable_uv; - - pr_debug("soc = %d ocv = %d rbat = %d u_uv = %d delta_v = %d\n", - i, ocv_mv, rbatt_mohm, unusable_uv, delta_uv); - - if (delta_uv > 0) - break; - - prev_delta_uv = delta_uv; - prev_rbatt_mohm = rbatt_mohm; - prev_ocv_mv = ocv_mv; - } - - uuc_rbatt_uv = linear_interpolate(rbatt_mohm, delta_uv, - prev_rbatt_mohm, prev_delta_uv, - 0); - - unusable_uv = (uuc_rbatt_uv * i_ma) + (chip->v_cutoff * 1000); - - pc_unusable = calculate_pc(chip, unusable_uv, batt_temp, chargecycles); - uuc = (fcc_uah * pc_unusable) / 100; - pr_debug("For i_ma = %d, unusable_rbatt = %d unusable_uv = %d unusable_pc = %d uuc = %d\n", - i_ma, uuc_rbatt_uv, unusable_uv, - pc_unusable, uuc); - *ret_pc_unusable = pc_unusable; - return uuc; -} - -#define TIME_PER_PERCENT_UUC 60 -static int adjust_uuc(struct pm8921_bms_chip *chip, int fcc_uah, - int new_pc_unusable, - int new_uuc, - int batt_temp, - int rbatt, - int *iavg_ma, - int delta_time_s) -{ - int new_unusable_mv; - int batt_temp_degc = batt_temp / 10; - int max_percent_change; - - max_percent_change = max(delta_time_s / TIME_PER_PERCENT_UUC, 1); - - if (chip->prev_pc_unusable == -EINVAL - || abs(chip->prev_pc_unusable - new_pc_unusable) - <= max_percent_change) { - chip->prev_pc_unusable = new_pc_unusable; - return new_uuc; - } - - /* the uuc is trying to change more than 1% restrict it */ - if (new_pc_unusable > chip->prev_pc_unusable) - chip->prev_pc_unusable += max_percent_change; - else - chip->prev_pc_unusable -= max_percent_change; - chip->prev_pc_unusable = clamp(chip->prev_pc_unusable, 0, 100); - new_uuc = (fcc_uah * chip->prev_pc_unusable) / 100; - - /* also find update the iavg_ma accordingly */ - new_unusable_mv = interpolate_ocv(chip->pc_temp_ocv_lut, - batt_temp_degc, chip->prev_pc_unusable); - if (new_unusable_mv < chip->v_cutoff) - new_unusable_mv = chip->v_cutoff; - - *iavg_ma = (new_unusable_mv - chip->v_cutoff) * 1000 / rbatt; - if (*iavg_ma == 0) - *iavg_ma = 1; - pr_debug("Restricting UUC to %d (%d%%) unusable_mv = %d iavg_ma = %d\n", - new_uuc, chip->prev_pc_unusable, - new_unusable_mv, *iavg_ma); - - return new_uuc; -} - -static int get_current_time(unsigned long *now_tm_sec) -{ - struct rtc_time tm; - struct rtc_device *rtc; - int rc; - - rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); - if (rtc == NULL) { - pr_err("%s: unable to open rtc device (%s)\n", - __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); - return -EINVAL; - } - - rc = rtc_read_time(rtc, &tm); - if (rc) { - pr_err("Error reading rtc device (%s) : %d\n", - CONFIG_RTC_HCTOSYS_DEVICE, rc); - return rc; - } - - rc = rtc_valid_tm(&tm); - if (rc) { - pr_err("Invalid RTC time (%s): %d\n", - CONFIG_RTC_HCTOSYS_DEVICE, rc); - return rc; - } - rtc_tm_to_time(&tm, now_tm_sec); - - return 0; -} - -static int calculate_delta_time(struct pm8921_bms_chip *chip, int *delta_time_s) -{ - unsigned long now_tm_sec = 0; - - /* default to delta time = 0 if anything fails */ - *delta_time_s = 0; - - get_current_time(&now_tm_sec); - - *delta_time_s = (now_tm_sec - chip->tm_sec); - pr_debug("tm_sec = %ld, now_tm_sec = %ld delta_s = %d\n", - chip->tm_sec, now_tm_sec, *delta_time_s); - - /* remember this time */ - chip->tm_sec = now_tm_sec; - return 0; -} - -static void calculate_iavg_ua(struct pm8921_bms_chip *chip, int cc_uah, - int *iavg_ua, int delta_time_s) -{ - int delta_cc_uah = 0; - - /* if anything fails report the previous iavg_ua */ - *iavg_ua = chip->prev_iavg_ua; - - if (chip->last_cc_uah == INT_MIN) { - pm8921_bms_get_battery_current(iavg_ua); - goto out; - } - - /* use the previous iavg if called within 15 seconds */ - if (delta_time_s < 15) { - *iavg_ua = chip->prev_iavg_ua; - goto out; - } - - delta_cc_uah = cc_uah - chip->last_cc_uah; - - *iavg_ua = div_s64((s64)delta_cc_uah * 3600, delta_time_s); - -out: - pr_debug("delta_cc = %d iavg_ua = %d\n", delta_cc_uah, (int)*iavg_ua); - /* remember the iavg */ - chip->prev_iavg_ua = *iavg_ua; - - /* remember cc_uah */ - chip->last_cc_uah = cc_uah; -} - -#define IAVG_SAMPLES 16 -#define MIN_IAVG_MA 250 -#define MIN_SECONDS_FOR_VALID_SAMPLE 20 -static int calculate_unusable_charge_uah(struct pm8921_bms_chip *chip, - int rbatt, int fcc_uah, int cc_uah, - int soc_rbatt, int batt_temp, int chargecycles, - int iavg_ua, int delta_time_s) -{ - int uuc_uah_iavg; - int i; - int iavg_ma = iavg_ua / 1000; - static int iavg_samples[IAVG_SAMPLES]; - static int iavg_index; - static int iavg_num_samples; - static int firsttime = 1; - int pc_unusable; - - /* - * if we are called first time fill all the - * samples with the the shutdown_iavg_ua - */ - if (firsttime && chip->shutdown_iavg_ua != 0) { - pr_debug("Using shutdown_iavg_ua = %d in all samples\n", - chip->shutdown_iavg_ua); - for (i = 0; i < IAVG_SAMPLES; i++) - iavg_samples[i] = chip->shutdown_iavg_ua; - - iavg_index = 0; - iavg_num_samples = IAVG_SAMPLES; - } - - /* - * if we are charging use a nominal avg current so that we keep - * a reasonable UUC while charging - */ - if (iavg_ma < MIN_IAVG_MA) - iavg_ma = MIN_IAVG_MA; - iavg_samples[iavg_index] = iavg_ma; - iavg_index = (iavg_index + 1) % IAVG_SAMPLES; - iavg_num_samples++; - if (iavg_num_samples >= IAVG_SAMPLES) - iavg_num_samples = IAVG_SAMPLES; - - /* now that this sample is added calcualte the average */ - iavg_ma = 0; - if (iavg_num_samples != 0) { - for (i = 0; i < iavg_num_samples; i++) { - pr_debug("iavg_samples[%d] = %d\n", i, iavg_samples[i]); - iavg_ma += iavg_samples[i]; - } - - iavg_ma = DIV_ROUND_CLOSEST(iavg_ma, iavg_num_samples); - } - - /* - * if we're in bms reset mode, force uuc to be 3% of fcc - */ - if (bms_reset) - return (fcc_uah * 3) / 100; - - uuc_uah_iavg = calculate_termination_uuc(chip, - batt_temp, chargecycles, - fcc_uah, iavg_ma, - &pc_unusable); - pr_debug("iavg = %d uuc_iavg = %d\n", iavg_ma, uuc_uah_iavg); - - /* restrict the uuc change to one percent per 60 seconds */ - uuc_uah_iavg = adjust_uuc(chip, fcc_uah, pc_unusable, uuc_uah_iavg, - batt_temp, rbatt, &iavg_ma, delta_time_s); - - /* find out what the avg current should be for this uuc */ - chip->prev_uuc_iavg_ma = iavg_ma; - - firsttime = 0; - return uuc_uah_iavg; -} - -/* calculate remainging charge at the time of ocv */ -static int calculate_remaining_charge_uah(struct pm8921_bms_chip *chip, - struct pm8921_soc_params *raw, - int fcc_uah, int batt_temp, - int chargecycles) -{ - int ocv, pc, batt_temp_decidegc; - - ocv = raw->last_good_ocv_uv; - batt_temp_decidegc = chip->last_ocv_temp_decidegc; - pc = calculate_pc(chip, ocv, batt_temp_decidegc, chargecycles); - pr_debug("ocv = %d pc = %d\n", ocv, pc); - return (fcc_uah * pc) / 100; -} - -static void calculate_soc_params(struct pm8921_bms_chip *chip, - struct pm8921_soc_params *raw, - int batt_temp, int chargecycles, - int *fcc_uah, - int *unusable_charge_uah, - int *remaining_charge_uah, - int *cc_uah, - int *rbatt, - int *iavg_ua) -{ - int soc_rbatt; - int delta_time_s; - int rc; - - rc = calculate_delta_time(chip, &delta_time_s); - if (rc) { - pr_err("Failed to get delta time from RTC: %d\n", rc); - delta_time_s = 0; - } - *fcc_uah = calculate_fcc_uah(chip, batt_temp, chargecycles); - pr_debug("FCC = %uuAh batt_temp = %d, cycles = %d\n", - *fcc_uah, batt_temp, chargecycles); - - - /* calculate remainging charge */ - *remaining_charge_uah = calculate_remaining_charge_uah(chip, raw, - *fcc_uah, batt_temp, chargecycles); - pr_debug("RC = %uuAh\n", *remaining_charge_uah); - - /* calculate cc micro_volt_hour */ - calculate_cc_uah(chip, raw->cc, cc_uah); - pr_debug("cc_uah = %duAh raw->cc = %x\n", *cc_uah, raw->cc); - - soc_rbatt = ((*remaining_charge_uah - *cc_uah) * 100) / *fcc_uah; - if (soc_rbatt < 0) - soc_rbatt = 0; - *rbatt = get_rbatt(chip, soc_rbatt, batt_temp); - - calculate_iavg_ua(chip, *cc_uah, iavg_ua, delta_time_s); - - *unusable_charge_uah = calculate_unusable_charge_uah(chip, *rbatt, - *fcc_uah, *cc_uah, soc_rbatt, - batt_temp, chargecycles, *iavg_ua, - delta_time_s); - pr_debug("UUC = %uuAh\n", *unusable_charge_uah); -} - -int pm8921_bms_get_simultaneous_battery_voltage_and_current(int *ibat_ua, - int *vbat_uv) -{ - int rc; - - if (the_chip == NULL) { - pr_err("Called too early\n"); - return -EINVAL; - } - - if (pm8921_is_batfet_closed()) { - return override_mode_simultaneous_battery_voltage_and_current( - ibat_ua, - vbat_uv); - } else { - pr_debug("batfet is open using separate vbat and ibat meas\n"); - rc = get_battery_uvolts(the_chip, vbat_uv); - if (rc < 0) { - pr_err("adc vbat failed err = %d\n", rc); - return rc; - } - rc = pm8921_bms_get_battery_current(ibat_ua); - if (rc < 0) { - pr_err("bms ibat failed err = %d\n", rc); - return rc; - } - } - - return 0; -} -EXPORT_SYMBOL(pm8921_bms_get_simultaneous_battery_voltage_and_current); - -#define SIGN(x) ((x) < 0 ? -1 : 1) - -static void find_ocv_for_soc(struct pm8921_bms_chip *chip, - int batt_temp, - int chargecycles, - int fcc_uah, - int uuc_uah, - int cc_uah, - int shutdown_soc, - int *rc_uah, - int *ocv_uv) -{ - s64 rc; - int pc, new_pc; - int batt_temp_degc = batt_temp / 10; - int ocv; - - rc = (s64)shutdown_soc * (fcc_uah - uuc_uah); - rc = div_s64(rc, 100) + cc_uah + uuc_uah; - pc = DIV_ROUND_CLOSEST((int)rc * 100, fcc_uah); - pc = clamp(pc, 0, 100); - - ocv = interpolate_ocv(chip->pc_temp_ocv_lut, batt_temp_degc, pc); - - pr_debug("s_soc = %d, fcc = %d uuc = %d rc = %d, pc = %d, ocv mv = %d\n", - shutdown_soc, fcc_uah, uuc_uah, (int)rc, pc, ocv); - new_pc = interpolate_pc(chip->pc_temp_ocv_lut, batt_temp_degc, ocv); - pr_debug("test revlookup pc = %d for ocv = %d\n", new_pc, ocv); - - if (abs(new_pc - pc) > 0) { - /* Maximum spins to make in while-loop when searching in - * full resolution. - */ - const unsigned int max_spin_count = - chip->max_voltage_uv / 1000 - chip->v_cutoff + 1; - unsigned int count = 0; - int delta_mv = 5; - int diff = abs(new_pc - pc); - char sign = SIGN(new_pc - pc); - char old_sign; - int old_diff; - int old_ocv; - - do { - count++; - old_ocv = ocv; - old_diff = diff; - old_sign = sign; - - if (new_pc > pc) - ocv -= delta_mv; - else - ocv += delta_mv; - - new_pc = interpolate_pc(chip->pc_temp_ocv_lut, - batt_temp_degc, ocv); - pr_debug("test revlookup pc = %d for ocv = %d\n", - new_pc, ocv); - diff = abs(new_pc - pc); - sign = SIGN(new_pc - pc); - - if (sign != old_sign) { - if (delta_mv == 5) { - /* - * we crossed our desired PC probably - * becuase we were overcorrecting - */ - delta_mv = 1; - } else { - /* we crossed our desired PC even with - * 1mV steps, choose the best of two */ - if (diff > old_diff) - ocv = old_ocv; - - break; - } - } - } while (count <= max_spin_count && diff > 0); - } - - *ocv_uv = ocv * 1000; - *rc_uah = (int)rc; -} - -static void adjust_rc_and_uuc_for_specific_soc( - struct pm8921_bms_chip *chip, - int batt_temp, - int chargecycles, - int soc, - int fcc_uah, - int uuc_uah, - int cc_uah, - int rc_uah, - int rbatt, - int *ret_ocv, - int *ret_rc, - int *ret_uuc, - int *ret_rbatt) -{ - int ocv_uv; - - find_ocv_for_soc(chip, batt_temp, chargecycles, - fcc_uah, uuc_uah, cc_uah, - soc, - &rc_uah, &ocv_uv); - - *ret_ocv = ocv_uv; - *ret_rbatt = rbatt; - *ret_rc = rc_uah; - *ret_uuc = uuc_uah; -} - -static void calc_current_max(struct pm8921_bms_chip *chip, int ocv_uv, - int rbatt_mohm) -{ - chip->imax_ua = 1000 * (ocv_uv - chip->v_cutoff * 1000) / rbatt_mohm; -} - -static int bound_soc(int soc) -{ - soc = max(0, soc); - soc = min(100, soc); - return soc; -} - -static int charging_adjustments(struct pm8921_bms_chip *chip, - int soc, int vbat_uv, int ibat_ua, - int batt_temp, int chargecycles, - int fcc_uah, int cc_uah, int uuc_uah) -{ - int chg_soc; - int vbat_batt_terminal_uv = vbat_uv - + (ibat_ua * chip->rconn_mohm) / 1000; - - if (chip->soc_at_cv == -EINVAL) { - /* In constant current charging return the calc soc */ - if (vbat_batt_terminal_uv <= chip->max_voltage_uv) - pr_debug("CC CHG SOC %d\n", soc); - - /* Note the CC to CV point */ - if (vbat_batt_terminal_uv >= chip->max_voltage_uv) { - chip->soc_at_cv = soc; - chip->prev_chg_soc = soc; - chip->ibat_at_cv_ua = ibat_ua; - pr_debug("CC_TO_CV ibat_ua = %d CHG SOC %d\n", - ibat_ua, soc); - } - - chip->prev_vbat_batt_terminal_uv = vbat_batt_terminal_uv; - return soc; - } - - /* - * battery is in CV phase - begin liner inerpolation of soc based on - * battery charge current - */ - - /* - * if the battery terminal voltage lessened (possibly because of - * a sudden increase in system load) keep reporting the prev chg soc - */ - if (vbat_batt_terminal_uv < chip->prev_vbat_batt_terminal_uv) { - pr_debug("vbat_terminals %d < prev = %d CC CHG SOC %d\n", - vbat_batt_terminal_uv, - chip->prev_vbat_batt_terminal_uv, - chip->prev_chg_soc); - chip->prev_vbat_batt_terminal_uv = vbat_batt_terminal_uv; - return chip->prev_chg_soc; - } - - chg_soc = linear_interpolate(chip->soc_at_cv, chip->ibat_at_cv_ua, - 100, -1 * chip->chg_term_ua, - ibat_ua); - chg_soc = bound_soc(chg_soc); - - /* always report a higher soc */ - if (chg_soc > chip->prev_chg_soc) { - int new_ocv_uv; - int new_rc; - - chip->prev_chg_soc = chg_soc; - - find_ocv_for_soc(chip, batt_temp, chargecycles, - fcc_uah, uuc_uah, cc_uah, - chg_soc, - &new_rc, &new_ocv_uv); - the_chip->last_ocv_uv = new_ocv_uv; - pr_debug("CC CHG ADJ OCV = %d CHG SOC %d\n", - new_ocv_uv, - chip->prev_chg_soc); - } - - pr_debug("Reporting CHG SOC %d\n", chip->prev_chg_soc); - chip->prev_vbat_batt_terminal_uv = vbat_batt_terminal_uv; - return chip->prev_chg_soc; -} - -static void very_low_voltage_check(struct pm8921_bms_chip *chip, - int ibat_ua, int vbat_uv) -{ - int rc; - /* - * if battery is very low (v_cutoff voltage + 20mv) hold - * a wakelock untill soc = 0% - */ - if (vbat_uv <= (chip->alarm_low_mv + 20) * 1000 && - !wake_lock_active(&the_chip->low_voltage_wake_lock)) { - pr_debug("voltage = %d low holding wakelock\n", vbat_uv); - wake_lock(&chip->low_voltage_wake_lock); - chip->soc_calc_period = chip->low_voltage_calc_ms; - } - - if (vbat_uv > (chip->alarm_low_mv + 20 + BATT_ALARM_ACCURACY) * 1000 - && wake_lock_active(&the_chip->low_voltage_wake_lock)) { - pr_debug("voltage = %d releasing wakelock\n", vbat_uv); - chip->vbatt_cutoff_count = 0; - chip->soc_calc_period = chip->normal_voltage_calc_ms; - rc = pm8921_bms_enable_batt_alarm(chip); - if (rc) - pr_err("Unable to enable batt alarm\n"); - wake_unlock(&chip->low_voltage_wake_lock); - } -} - -static bool is_voltage_below_cutoff_window(struct pm8921_bms_chip *chip, - int ibat_ua, int vbat_uv) -{ - if (vbat_uv < (chip->v_cutoff * 1000) && ibat_ua > 0) { - chip->vbatt_cutoff_count++; - if (chip->vbatt_cutoff_count >= chip->vbatt_cutoff_retries) { - pr_debug("cutoff_count >= %d\n", - chip->vbatt_cutoff_retries); - return true; - } - } else { - chip->vbatt_cutoff_count = 0; - } - - return false; -} - -static int last_soc_est = -EINVAL; -static int adjust_soc(struct pm8921_bms_chip *chip, int soc, - int batt_temp, int chargecycles, - int rbatt, int fcc_uah, int uuc_uah, int cc_uah) -{ - int ibat_ua = 0, vbat_uv = 0; - int ocv_est_uv = 0, soc_est = 0, pc_est = 0, pc = 0; - int delta_ocv_uv = 0; - int n = 0; - int rc_new_uah = 0; - int pc_new = 0; - int soc_new = 0; - int m = 0; - int rc = 0; - int delta_ocv_uv_limit = 0; - int correction_limit_uv = 0; - - rc = pm8921_bms_get_simultaneous_battery_voltage_and_current( - &ibat_ua, - &vbat_uv); - if (rc < 0) { - pr_err("simultaneous vbat ibat failed err = %d\n", rc); - goto out; - } - - very_low_voltage_check(chip, ibat_ua, vbat_uv); - - if (chip->low_voltage_detect && - wake_lock_active(&chip->low_voltage_wake_lock)) { - if (is_voltage_below_cutoff_window(chip, ibat_ua, vbat_uv)) { - soc = 0; - pr_info("Voltage below cutoff, setting soc to 0\n"); - goto out; - } - } - - delta_ocv_uv_limit = DIV_ROUND_CLOSEST(ibat_ua, 1000); - - ocv_est_uv = vbat_uv + (ibat_ua * rbatt)/1000; - calc_current_max(chip, ocv_est_uv, rbatt); - pc_est = calculate_pc(chip, ocv_est_uv, batt_temp, last_chargecycles); - soc_est = div_s64((s64)fcc_uah * pc_est - uuc_uah*100, - (s64)fcc_uah - uuc_uah); - soc_est = bound_soc(soc_est); - - /* never adjust during bms reset mode */ - if (bms_reset) { - pr_debug("bms reset mode, SOC adjustment skipped\n"); - goto out; - } - - if (ibat_ua < 0 && pm8921_is_batfet_closed()) { - soc = charging_adjustments(chip, soc, vbat_uv, ibat_ua, - batt_temp, chargecycles, - fcc_uah, cc_uah, uuc_uah); - goto out; - } - - /* - * do not adjust - * if soc_est is same as what bms calculated - * OR if soc_est > 15 - * OR if soc it is above 90 because we might pull it low - * and cause a bad user experience - */ - if (soc_est == soc - || soc_est > 15 - || soc >= 90) - goto out; - - if (last_soc_est == -EINVAL) - last_soc_est = soc; - - n = min(200, max(1 , soc + soc_est + last_soc_est)); - /* remember the last soc_est in last_soc_est */ - last_soc_est = soc_est; - - pc = calculate_pc(chip, chip->last_ocv_uv, - chip->last_ocv_temp_decidegc, last_chargecycles); - if (pc > 0) { - pc_new = calculate_pc(chip, chip->last_ocv_uv - (++m * 1000), - chip->last_ocv_temp_decidegc, - last_chargecycles); - while (pc_new == pc) { - /* start taking 10mV steps */ - m = m + 10; - pc_new = calculate_pc(chip, - chip->last_ocv_uv - (m * 1000), - chip->last_ocv_temp_decidegc, - last_chargecycles); - } - } else { - /* - * pc is already at the lowest point, - * assume 1 millivolt translates to 1% pc - */ - pc = 1; - pc_new = 0; - m = 1; - } - - delta_ocv_uv = div_s64((soc - soc_est) * (s64)m * 1000, - n * (pc - pc_new)); - - if (abs(delta_ocv_uv) > delta_ocv_uv_limit) { - pr_debug("limiting delta ocv %d limit = %d\n", delta_ocv_uv, - delta_ocv_uv_limit); - - if (delta_ocv_uv > 0) - delta_ocv_uv = delta_ocv_uv_limit; - else - delta_ocv_uv = -1 * delta_ocv_uv_limit; - pr_debug("new delta ocv = %d\n", delta_ocv_uv); - } - - if (wake_lock_active(&chip->low_voltage_wake_lock)) { - pr_debug("Low Voltage, apply only ibat limited corrections\n"); - goto skip_limiting_corrections; - } - - if (chip->last_ocv_uv > 3800000) - correction_limit_uv = the_chip->high_ocv_correction_limit_uv; - else - correction_limit_uv = the_chip->low_ocv_correction_limit_uv; - - if (abs(delta_ocv_uv) > correction_limit_uv) { - pr_debug("limiting delta ocv %d limit = %d\n", delta_ocv_uv, - correction_limit_uv); - - if (delta_ocv_uv > 0) - delta_ocv_uv = correction_limit_uv; - else - delta_ocv_uv = -1 * correction_limit_uv; - pr_debug("new delta ocv = %d\n", delta_ocv_uv); - } - -skip_limiting_corrections: - chip->last_ocv_uv -= delta_ocv_uv; - - if (chip->last_ocv_uv >= chip->max_voltage_uv) - chip->last_ocv_uv = chip->max_voltage_uv; - - /* calculate the soc based on this new ocv */ - pc_new = calculate_pc(chip, chip->last_ocv_uv, - chip->last_ocv_temp_decidegc, last_chargecycles); - rc_new_uah = (fcc_uah * pc_new) / 100; - soc_new = (rc_new_uah - cc_uah - uuc_uah)*100 / (fcc_uah - uuc_uah); - soc_new = bound_soc(soc_new); - - /* - * if soc_new is ZERO force it higher so that phone doesnt report soc=0 - * soc = 0 should happen only when soc_est == 0 - */ - if (soc_new == 0 && soc_est >= the_chip->hold_soc_est) - soc_new = 1; - - soc = soc_new; - -out: - pr_debug("ibat_ua = %d, vbat_uv = %d, ocv_est_uv = %d, pc_est = %d, " - "soc_est = %d, n = %d, delta_ocv_uv = %d, last_ocv_uv = %d, " - "pc_new = %d, soc_new = %d, rbatt = %d, m = %d\n", - ibat_ua, vbat_uv, ocv_est_uv, pc_est, - soc_est, n, delta_ocv_uv, chip->last_ocv_uv, - pc_new, soc_new, rbatt, m); - - return soc; -} - -#define IGNORE_SOC_TEMP_DECIDEG 50 -#define IAVG_STEP_SIZE_MA 50 -#define IAVG_START 600 -#define SOC_ZERO 0xFF -static void backup_soc_and_iavg(struct pm8921_bms_chip *chip, int batt_temp, - int soc) -{ - u8 temp; - int iavg_ma = chip->prev_uuc_iavg_ma; - - if (iavg_ma > IAVG_START) - temp = (iavg_ma - IAVG_START) / IAVG_STEP_SIZE_MA; - else - temp = 0; - - pm_bms_masked_write(chip, TEMP_IAVG_STORAGE, - TEMP_IAVG_STORAGE_USE_MASK, temp); - - /* since only 6 bits are available for SOC, we store half the soc */ - if (soc == 0) - temp = SOC_ZERO; - else - temp = soc; - - /* don't store soc if temperature is below 5degC */ - if (batt_temp > IGNORE_SOC_TEMP_DECIDEG) - pm8xxx_writeb(the_chip->dev->parent, TEMP_SOC_STORAGE, temp); -} - -static void read_shutdown_soc_and_iavg(struct pm8921_bms_chip *chip) -{ - int rc; - u8 temp; - - rc = pm8xxx_readb(chip->dev->parent, TEMP_IAVG_STORAGE, &temp); - if (rc) { - pr_err("failed to read addr = %d %d assuming %d\n", - TEMP_IAVG_STORAGE, rc, IAVG_START); - chip->shutdown_iavg_ua = IAVG_START; - } else { - temp &= TEMP_IAVG_STORAGE_USE_MASK; - - if (temp == 0) { - chip->shutdown_iavg_ua = IAVG_START; - } else { - chip->shutdown_iavg_ua = IAVG_START - + IAVG_STEP_SIZE_MA * (temp + 1); - } - } - - rc = pm8xxx_readb(chip->dev->parent, TEMP_SOC_STORAGE, &temp); - if (rc) { - pr_err("failed to read addr = %d %d\n", TEMP_SOC_STORAGE, rc); - } else { - chip->shutdown_soc = temp; - - if (chip->shutdown_soc == 0) { - pr_debug("No shutdown soc available\n"); - shutdown_soc_invalid = 1; - chip->shutdown_iavg_ua = 0; - } else if (chip->shutdown_soc == SOC_ZERO) { - chip->shutdown_soc = 0; - } - } - - if (chip->ignore_shutdown_soc) { - shutdown_soc_invalid = 1; - chip->shutdown_soc = 0; - chip->shutdown_iavg_ua = 0; - } - - pr_debug("shutdown_soc = %d shutdown_iavg = %d shutdown_soc_invalid = %d\n", - chip->shutdown_soc, - chip->shutdown_iavg_ua, - shutdown_soc_invalid); -} - -#define SOC_CATCHUP_SEC_MAX 600 -#define SOC_CATCHUP_SEC_PER_PERCENT 60 -#define MAX_CATCHUP_SOC (SOC_CATCHUP_SEC_MAX/SOC_CATCHUP_SEC_PER_PERCENT) -static int scale_soc_while_chg(struct pm8921_bms_chip *chip, - int delta_time_us, int new_soc, int prev_soc) -{ - int chg_time_sec; - int catch_up_sec; - int scaled_soc; - int numerator; - - /* - * The device must be charging for reporting a higher soc, if - * not ignore this soc and continue reporting the prev_soc. - * Also don't report a high value immediately slowly scale the - * value from prev_soc to the new soc based on a charge time - * weighted average - */ - - /* if we are not charging return last soc */ - if (the_chip->start_percent == -EINVAL) - return prev_soc; - - /* do not scale at 100 */ - if (new_soc == 100) - return new_soc; - - chg_time_sec = DIV_ROUND_UP(the_chip->charge_time_us, USEC_PER_SEC); - catch_up_sec = DIV_ROUND_UP(the_chip->catch_up_time_us, USEC_PER_SEC); - if (catch_up_sec == 0) - return new_soc; - pr_debug("cts= %d catch_up_sec = %d\n", chg_time_sec, catch_up_sec); - - /* - * if we have been charging for more than catch_up time simply return - * new soc - */ - if (chg_time_sec > catch_up_sec) - return new_soc; - - numerator = (catch_up_sec - chg_time_sec) * prev_soc - + chg_time_sec * new_soc; - scaled_soc = numerator / catch_up_sec; - - pr_debug("cts = %d new_soc = %d prev_soc = %d scaled_soc = %d\n", - chg_time_sec, new_soc, prev_soc, scaled_soc); - - return scaled_soc; -} - -static bool is_shutdown_soc_within_limits(struct pm8921_bms_chip *chip, int soc) -{ - if (shutdown_soc_invalid) { - pr_debug("NOT forcing shutdown soc = %d\n", chip->shutdown_soc); - return 0; - } - - if (abs(chip->shutdown_soc - soc) > chip->shutdown_soc_valid_limit) { - pr_debug("rejecting shutdown soc = %d, soc = %d limit = %d\n", - chip->shutdown_soc, soc, - chip->shutdown_soc_valid_limit); - shutdown_soc_invalid = 1; - return 0; - } - - return 1; -} - -static void update_power_supply(struct pm8921_bms_chip *chip) -{ - if (chip->batt_psy == NULL || chip->batt_psy < 0) - chip->batt_psy = power_supply_get_by_name("battery"); - - if (chip->batt_psy > 0) - power_supply_changed(chip->batt_psy); -} - -#define MIN_DELTA_625_UV 1000 -static void calib_hkadc(struct pm8921_bms_chip *chip) -{ - int voltage, rc; - struct pm8xxx_adc_chan_result result; - int usb_chg; - int this_delta; - - mutex_lock(&chip->calib_mutex); - rc = pm8xxx_adc_read(the_chip->ref1p25v_channel, &result); - if (rc) { - pr_err("ADC failed for 1.25volts rc = %d\n", rc); - goto out; - } - voltage = xoadc_reading_to_microvolt(result.adc_code); - - pr_debug("result 1.25v = 0x%x, voltage = %duV adc_meas = %lld\n", - result.adc_code, voltage, result.measurement); - - chip->xoadc_v125 = voltage; - - rc = pm8xxx_adc_read(the_chip->ref625mv_channel, &result); - if (rc) { - pr_err("ADC failed for 1.25volts rc = %d\n", rc); - goto out; - } - voltage = xoadc_reading_to_microvolt(result.adc_code); - - usb_chg = usb_chg_plugged_in(chip); - pr_debug("result 0.625V = 0x%x, voltage = %duV adc_meas = %lld usb_chg = %d\n", - result.adc_code, voltage, result.measurement, - usb_chg); - - if (usb_chg) - chip->xoadc_v0625_usb_present = voltage; - else - chip->xoadc_v0625_usb_absent = voltage; - - chip->xoadc_v0625 = voltage; - if (chip->xoadc_v0625_usb_present && chip->xoadc_v0625_usb_absent) { - this_delta = chip->xoadc_v0625_usb_present - - chip->xoadc_v0625_usb_absent; - pr_debug("this_delta= %duV\n", this_delta); - if (this_delta > MIN_DELTA_625_UV) - last_usb_cal_delta_uv = this_delta; - pr_debug("625V_present= %d, 625V_absent= %d, delta = %duV\n", - chip->xoadc_v0625_usb_present, - chip->xoadc_v0625_usb_absent, - last_usb_cal_delta_uv); - } - pr_debug("calibration batt_temp = %d\n", chip->last_calib_temp); -out: - mutex_unlock(&chip->calib_mutex); -} - -#define HKADC_CALIB_DELAY_S 600 -#define HKADC_CALIB_DELTA_TEMP 20 -static void calib_hkadc_check(struct pm8921_bms_chip *chip, int batt_temp) -{ - unsigned long time_since_last_calib; - unsigned long tm_now_sec; - int delta_temp; - int rc; - - rc = get_current_time(&tm_now_sec); - if (rc) { - pr_err("Could not read current time: %d\n", rc); - return; - } - if (tm_now_sec > chip->last_calib_time) { - time_since_last_calib = tm_now_sec - chip->last_calib_time; - delta_temp = abs(chip->last_calib_temp - batt_temp); - pr_debug("time since last calib: %lu, temp diff = %d\n", - time_since_last_calib, delta_temp); - if (time_since_last_calib >= HKADC_CALIB_DELAY_S - || delta_temp > HKADC_CALIB_DELTA_TEMP) { - chip->last_calib_temp = batt_temp; - chip->last_calib_time = tm_now_sec; - calib_hkadc(chip); - } - } -} - -/* - * Remaining Usable Charge = remaining_charge (charge at ocv instance) - * - coloumb counter charge - * - unusable charge (due to battery resistance) - * SOC% = (remaining usable charge/ fcc - usable_charge); - */ -static int calculate_state_of_charge(struct pm8921_bms_chip *chip, - struct pm8921_soc_params *raw, - int batt_temp, int chargecycles) -{ - int remaining_usable_charge_uah, fcc_uah, unusable_charge_uah; - int remaining_charge_uah, soc; - int cc_uah; - int rbatt; - int iavg_ua; - int new_ocv; - int new_rc_uah; - int new_ucc_uah; - int new_rbatt; - int shutdown_soc; - int new_calculated_soc; - static int firsttime = 1; - - calculate_soc_params(chip, raw, batt_temp, chargecycles, - &fcc_uah, - &unusable_charge_uah, - &remaining_charge_uah, - &cc_uah, - &rbatt, - &iavg_ua); - - /* calculate remaining usable charge */ - remaining_usable_charge_uah = remaining_charge_uah - - cc_uah - - unusable_charge_uah; - - pr_debug("RUC = %duAh\n", remaining_usable_charge_uah); - if (fcc_uah - unusable_charge_uah <= 0) { - pr_debug("FCC = %duAh, UUC = %duAh forcing soc = 0\n", - fcc_uah, unusable_charge_uah); - soc = 0; - } else { - soc = DIV_ROUND_CLOSEST((remaining_usable_charge_uah * 100), - (fcc_uah - unusable_charge_uah)); - } - - if (firsttime && soc < 0) { - /* - * first time calcualtion and the pon ocv is too low resulting - * in a bad soc. Adjust ocv such that we get 0 soc - */ - pr_debug("soc is %d, adjusting pon ocv to make it 0\n", soc); - adjust_rc_and_uuc_for_specific_soc( - chip, - batt_temp, chargecycles, - 0, - fcc_uah, unusable_charge_uah, - cc_uah, remaining_charge_uah, - rbatt, - &new_ocv, - &new_rc_uah, &new_ucc_uah, - &new_rbatt); - chip->last_ocv_uv = new_ocv; - remaining_charge_uah = new_rc_uah; - unusable_charge_uah = new_ucc_uah; - rbatt = new_rbatt; - - remaining_usable_charge_uah = remaining_charge_uah - - cc_uah - - unusable_charge_uah; - - soc = DIV_ROUND_CLOSEST((remaining_usable_charge_uah * 100), - (fcc_uah - unusable_charge_uah)); - pr_debug("DONE for O soc is %d, pon ocv adjusted to %duV\n", - soc, chip->last_ocv_uv); - } - - if (soc > 100) - soc = 100; - - if (soc < 0) { - pr_debug("bad rem_usb_chg = %d rem_chg %d," - "cc_uah %d, unusb_chg %d\n", - remaining_usable_charge_uah, - remaining_charge_uah, - cc_uah, unusable_charge_uah); - - pr_debug("for bad rem_usb_chg last_ocv_uv = %d" - "chargecycles = %d, batt_temp = %d" - "fcc = %d soc =%d\n", - chip->last_ocv_uv, chargecycles, batt_temp, - fcc_uah, soc); - soc = 0; - } - - mutex_lock(&soc_invalidation_mutex); - shutdown_soc = chip->shutdown_soc; - - if (firsttime && soc != shutdown_soc - && is_shutdown_soc_within_limits(chip, soc)) { - /* - * soc for the first time - use shutdown soc - * to adjust pon ocv since it is a small percent away from - * the real soc - */ - pr_debug("soc = %d before forcing shutdown_soc = %d\n", - soc, shutdown_soc); - adjust_rc_and_uuc_for_specific_soc( - chip, - batt_temp, chargecycles, - shutdown_soc, - fcc_uah, unusable_charge_uah, - cc_uah, remaining_charge_uah, - rbatt, - &new_ocv, - &new_rc_uah, &new_ucc_uah, - &new_rbatt); - - chip->pon_ocv_uv = chip->last_ocv_uv; - chip->last_ocv_uv = new_ocv; - remaining_charge_uah = new_rc_uah; - unusable_charge_uah = new_ucc_uah; - rbatt = new_rbatt; - - remaining_usable_charge_uah = remaining_charge_uah - - cc_uah - - unusable_charge_uah; - - soc = DIV_ROUND_CLOSEST((remaining_usable_charge_uah * 100), - (fcc_uah - unusable_charge_uah)); - - pr_debug("DONE for shutdown_soc = %d soc is %d, adjusted ocv to %duV\n", - shutdown_soc, soc, chip->last_ocv_uv); - } - mutex_unlock(&soc_invalidation_mutex); - - pr_debug("SOC before adjustment = %d\n", soc); - new_calculated_soc = adjust_soc(chip, soc, batt_temp, chargecycles, - rbatt, fcc_uah, unusable_charge_uah, cc_uah); - - pr_debug("calculated SOC = %d\n", new_calculated_soc); - if (new_calculated_soc != calculated_soc) { - calculated_soc = new_calculated_soc; - update_power_supply(chip); - } - - firsttime = 0; - get_current_time(&chip->last_recalc_time); - - if (chip->disable_flat_portion_ocv) { - if (is_between(chip->ocv_dis_high_soc, chip->ocv_dis_low_soc, - calculated_soc)) { - pm8921_bms_stop_ocv_updates(); - } else { - pm8921_bms_start_ocv_updates(); - } - } - return calculated_soc; -} - -static int recalculate_soc(struct pm8921_bms_chip *chip) -{ - int batt_temp; - struct pm8921_soc_params raw; - int soc; - - wake_lock(&the_chip->soc_wake_lock); - get_batt_temp(chip, &batt_temp); - - mutex_lock(&chip->last_ocv_uv_mutex); - calib_hkadc_check(chip, batt_temp); - read_soc_params_raw(chip, &raw, batt_temp); - - soc = calculate_state_of_charge(chip, &raw, - batt_temp, last_chargecycles); - mutex_unlock(&chip->last_ocv_uv_mutex); - wake_unlock(&the_chip->soc_wake_lock); - return soc; -} - -static void calculate_soc_work(struct work_struct *work) -{ - struct delayed_work *dwork = to_delayed_work(work); - struct pm8921_bms_chip *chip = container_of(dwork, - struct pm8921_bms_chip, - calculate_soc_delayed_work); - - recalculate_soc(chip); - schedule_delayed_work(&chip->calculate_soc_delayed_work, - round_jiffies_relative(msecs_to_jiffies - (chip->soc_calc_period))); -} - -static int report_state_of_charge(struct pm8921_bms_chip *chip) -{ - int soc = calculated_soc; - int delta_time_us; - struct timespec now; - int batt_temp; - - if (bms_fake_battery != -EINVAL) { - pr_debug("Returning Fake SOC = %d%%\n", bms_fake_battery); - return bms_fake_battery; - } - - get_batt_temp(chip, &batt_temp); - - do_posix_clock_monotonic_gettime(&now); - if (chip->t_soc_queried.tv_sec != 0) { - delta_time_us - = (now.tv_sec - chip->t_soc_queried.tv_sec) * USEC_PER_SEC - + (now.tv_nsec - chip->t_soc_queried.tv_nsec) / 1000; - } else { - /* calculation for the first time */ - delta_time_us = 0; - } - - /* - * account for charge time - limit it to SOC_CATCHUP_SEC to - * avoid overflows when charging continues for extended periods - */ - if (the_chip->start_percent != -EINVAL) { - if (the_chip->charge_time_us == 0) { - /* - * calculating soc for the first time - * after start of chg. Initialize catchup time - */ - if (abs(soc - last_soc) < MAX_CATCHUP_SOC) - the_chip->catch_up_time_us = - (soc - last_soc) * SOC_CATCHUP_SEC_PER_PERCENT - * USEC_PER_SEC; - else - the_chip->catch_up_time_us = - SOC_CATCHUP_SEC_MAX * USEC_PER_SEC; - - if (the_chip->catch_up_time_us < 0) - the_chip->catch_up_time_us = 0; - } - - /* add charge time */ - if (the_chip->charge_time_us - < SOC_CATCHUP_SEC_MAX * USEC_PER_SEC) - chip->charge_time_us += delta_time_us; - - /* end catchup if calculated soc and last soc are same */ - if (last_soc == soc) - the_chip->catch_up_time_us = 0; - } - - /* last_soc < soc ... scale and catch up */ - if (last_soc != -EINVAL && last_soc < soc) - soc = scale_soc_while_chg(chip, delta_time_us, soc, last_soc); - - if (last_soc != -EINVAL) { - if (chip->first_report_after_suspend) { - chip->first_report_after_suspend = false; - if (chip->soc_updated_on_resume) { - /* coming here after a long suspend */ - chip->soc_updated_on_resume = false; - if (last_soc < soc) - /* if soc has falsely increased during - * suspend, set the soc_at_suspend - */ - soc = chip->last_soc_at_suspend; - } else { - /* - * suspended for a short time - * report the last_soc before suspend - */ - soc = chip->last_soc_at_suspend; - } - } else if (soc < last_soc && soc != 0) { - soc = last_soc - 1; - } else if (soc > last_soc && soc != 100) { - soc = last_soc + 1; - } - } - - last_soc = bound_soc(soc); - backup_soc_and_iavg(chip, batt_temp, last_soc); - pr_debug("Reported SOC = %d\n", last_soc); - chip->t_soc_queried = now; - - return last_soc; -} - -void pm8921_bms_battery_removed(void) -{ - if (!the_chip) { - pr_err("called before initialization\n"); - return; - } - pr_info("Battery Removed Cleaning up\n"); - - cancel_delayed_work_sync(&the_chip->calculate_soc_delayed_work); - calculated_soc = 0; - the_chip->start_percent = -EINVAL; - the_chip->end_percent = -EINVAL; - /* cleanup for charge time catchup */ - the_chip->charge_time_us = 0; - the_chip->catch_up_time_us = 0; - /* cleanup for charge time adjusting */ - the_chip->soc_at_cv = -EINVAL; - the_chip->soc_at_cv = -EINVAL; - the_chip->prev_chg_soc = -EINVAL; - the_chip->ibat_at_cv_ua = 0; - the_chip->prev_vbat_batt_terminal_uv = 0; - /* ocv cleanups */ - the_chip->ocv_reading_at_100 = OCV_RAW_UNINITIALIZED; - the_chip->prev_last_good_ocv_raw = OCV_RAW_UNINITIALIZED; - the_chip->last_ocv_temp_decidegc = -EINVAL; - - /* cleanup delta time */ - the_chip->tm_sec = 0; - - /* cc and avg current cleanups */ - the_chip->prev_iavg_ua = 0; - the_chip->last_cc_uah = INT_MIN; - - /* report SOC cleanups */ - the_chip->t_soc_queried.tv_sec = 0; - the_chip->t_soc_queried.tv_nsec = 0; - - last_soc = -EINVAL; - /* store invalid soc */ - pm8xxx_writeb(the_chip->dev->parent, TEMP_SOC_STORAGE, 0); - - /* fcc learning cleanup */ - if (the_chip->enable_fcc_learning) { - battery_removed = 1; - sysfs_notify(&the_chip->dev->kobj, NULL, "fcc_data"); - } - - /* UUC related data is left as is - use the same historical load avg */ - update_power_supply(the_chip); -} -EXPORT_SYMBOL(pm8921_bms_battery_removed); - -void pm8921_bms_battery_inserted(void) -{ - if (!the_chip) { - pr_err("called before initialization\n"); - return; - } - - pr_info("Battery Inserted\n"); - the_chip->last_ocv_uv = estimate_ocv(the_chip); - schedule_delayed_work(&the_chip->calculate_soc_delayed_work, 0); -} -EXPORT_SYMBOL(pm8921_bms_battery_inserted); - -void pm8921_bms_invalidate_shutdown_soc(void) -{ - int calculate_soc = 0; - struct pm8921_bms_chip *chip = the_chip; - - /* clean up the fcc learning table */ - if (!the_chip) - the_chip->adjusted_fcc_temp_lut = NULL; - last_fcc_update_count = 0; - last_real_fcc_mah = -EINVAL; - last_real_fcc_batt_temp = -EINVAL; - battery_removed = 1; - - pr_debug("Invalidating shutdown soc - the battery was removed\n"); - if (shutdown_soc_invalid) - return; - - mutex_lock(&soc_invalidation_mutex); - shutdown_soc_invalid = 1; - last_soc = -EINVAL; - if (the_chip) { - /* reset to pon ocv undoing what the adjusting did */ - if (the_chip->pon_ocv_uv) { - the_chip->last_ocv_uv = the_chip->pon_ocv_uv; - calculate_soc = 1; - pr_debug("resetting ocv to pon_ocv = %d\n", - the_chip->pon_ocv_uv); - } - } - mutex_unlock(&soc_invalidation_mutex); - if (!calculate_soc) - return; - recalculate_soc(chip); -} -EXPORT_SYMBOL(pm8921_bms_invalidate_shutdown_soc); - -static void calibrate_hkadc_work(struct work_struct *work) -{ - struct pm8921_bms_chip *chip = container_of(work, - struct pm8921_bms_chip, calib_hkadc_work); - - calib_hkadc(chip); -} - -void pm8921_bms_calibrate_hkadc(void) -{ - schedule_work(&the_chip->calib_hkadc_work); -} - -int pm8921_bms_get_vsense_avg(int *result) -{ - int rc = -EINVAL; - - if (the_chip) { - mutex_lock(&the_chip->bms_output_lock); - pm_bms_lock_output_data(the_chip); - rc = read_vsense_avg(the_chip, result); - pm_bms_unlock_output_data(the_chip); - mutex_unlock(&the_chip->bms_output_lock); - } - - pr_err("called before initialization\n"); - return rc; -} -EXPORT_SYMBOL(pm8921_bms_get_vsense_avg); - -int pm8921_bms_get_battery_current(int *result_ua) -{ - int vsense_uv; - int rc = 0; - - *result_ua = 0; - if (!the_chip) { - pr_err("called before initialization\n"); - return -EINVAL; - } - if (the_chip->r_sense_uohm == 0) { - pr_err("r_sense is zero\n"); - return -EINVAL; - } - - mutex_lock(&the_chip->bms_output_lock); - pm_bms_lock_output_data(the_chip); - rc = read_vsense_avg(the_chip, &vsense_uv); - pm_bms_unlock_output_data(the_chip); - mutex_unlock(&the_chip->bms_output_lock); - if (rc) { - pr_err("Unable to read vsense average\n"); - goto error_vsense; - } - pr_debug("vsense=%duV\n", vsense_uv); - /* cast for signed division */ - *result_ua = div_s64(vsense_uv * 1000000LL, the_chip->r_sense_uohm); - pr_debug("ibat=%duA\n", *result_ua); - -error_vsense: - return rc; -} -EXPORT_SYMBOL(pm8921_bms_get_battery_current); - -int pm8921_bms_get_percent_charge(void) -{ - if (!the_chip) { - pr_err("called before initialization\n"); - return -EINVAL; - } - - return report_state_of_charge(the_chip); -} -EXPORT_SYMBOL_GPL(pm8921_bms_get_percent_charge); - -int pm8921_bms_get_current_max(void) -{ - if (!the_chip) { - pr_err("called before initialization\n"); - return -EINVAL; - } - return the_chip->imax_ua; -} -EXPORT_SYMBOL_GPL(pm8921_bms_get_current_max); - -int pm8921_bms_get_fcc(void) -{ - int batt_temp; - - if (!the_chip) { - pr_err("called before initialization\n"); - return -EINVAL; - } - - get_batt_temp(the_chip, &batt_temp); - return calculate_fcc_uah(the_chip, batt_temp, last_chargecycles); -} -EXPORT_SYMBOL_GPL(pm8921_bms_get_fcc); - -static void calculate_real_soc(struct pm8921_bms_chip *chip, int *soc, - int batt_temp, struct pm8921_soc_params *raw, int cc_uah) -{ - int fcc_uah = 0, rc_uah = 0; - - fcc_uah = calculate_fcc_uah(chip, batt_temp, last_chargecycles); - rc_uah = calculate_remaining_charge_uah(chip, raw, - fcc_uah, batt_temp, last_chargecycles); - *soc = ((rc_uah - cc_uah) * 100) / fcc_uah; - pr_debug("fcc = %d, rc = %d, cc = %d Real SOC = %d\n", - fcc_uah, rc_uah, cc_uah, *soc); -} - -void pm8921_bms_charging_began(void) -{ - struct pm8921_soc_params raw; - int batt_temp; - - get_batt_temp(the_chip, &batt_temp); - - mutex_lock(&the_chip->last_ocv_uv_mutex); - calib_hkadc_check(the_chip, batt_temp); - read_soc_params_raw(the_chip, &raw, batt_temp); - mutex_unlock(&the_chip->last_ocv_uv_mutex); - - the_chip->start_percent = report_state_of_charge(the_chip); - - bms_start_percent = the_chip->start_percent; - bms_start_ocv_uv = raw.last_good_ocv_uv; - calculate_cc_uah(the_chip, raw.cc, &bms_start_cc_uah); - pm_bms_masked_write(the_chip, BMS_TOLERANCES, - IBAT_TOL_MASK, IBAT_TOL_DEFAULT); - the_chip->charge_time_us = 0; - the_chip->catch_up_time_us = 0; - - the_chip->soc_at_cv = -EINVAL; - the_chip->prev_chg_soc = -EINVAL; - if (the_chip->enable_fcc_learning) { - calculate_real_soc(the_chip, &the_chip->start_real_soc, - batt_temp, &raw, bms_start_cc_uah); - the_chip->pc_at_start_charge = - interpolate_pc(the_chip->pc_temp_ocv_lut, batt_temp, - bms_start_ocv_uv / 1000); - pr_debug("Start real soc = %d, start pc = %d\n", - the_chip->start_real_soc, the_chip->pc_at_start_charge); - } - - pr_debug("start_percent = %u%%\n", the_chip->start_percent); -} -EXPORT_SYMBOL_GPL(pm8921_bms_charging_began); - -static void invalidate_fcc(struct pm8921_bms_chip *chip) -{ - memset(chip->fcc_table, 0, chip->min_fcc_learning_samples * - sizeof(*(chip->fcc_table))); - last_fcc_update_count = 0; - chip->adjusted_fcc_temp_lut = NULL; - last_real_fcc_mah = -EINVAL; - last_real_fcc_batt_temp = -EINVAL; - last_chargecycles = 0; - last_charge_increase = 0; -} - -static void update_fcc_table_for_temp(struct pm8921_bms_chip *chip, - int batt_temp_final) -{ - int i, fcc_t1, fcc_t2, fcc_final; - struct fcc_data *ft; - - /* Interpolate all the FCC entries to the same temperature */ - for (i = 0; i < chip->min_fcc_learning_samples; i++) { - ft = &chip->fcc_table[i]; - if (ft->batt_temp == batt_temp_final) - continue; - fcc_t1 = interpolate_fcc(chip->fcc_temp_lut, ft->batt_temp); - fcc_t2 = interpolate_fcc(chip->fcc_temp_lut, batt_temp_final); - fcc_final = (ft->fcc_new / fcc_t1) * fcc_t2; - ft->fcc_new = fcc_final; - ft->batt_temp = batt_temp_final; - } -} - -static void update_fcc_learning_table(struct pm8921_bms_chip *chip, - int fcc_uah, int new_fcc_uah, int chargecycles, int batt_temp) -{ - int i, temp_fcc_avg = 0, new_fcc_avg = 0, temp_fcc_delta = 0, count; - struct fcc_data *ft; - - count = last_fcc_update_count % chip->min_fcc_learning_samples; - ft = &chip->fcc_table[count]; - ft->fcc_new = ft->fcc_real = new_fcc_uah; - ft->batt_temp = ft->temp_real = batt_temp; - ft->chargecycles = chargecycles; - chip->fcc_new = new_fcc_uah; - last_fcc_update_count++; - /* update userspace with the new data */ - sysfs_notify(&chip->dev->kobj, NULL, "fcc_data"); - - pr_debug("Updated fcc table. new_fcc=%d, chargecycle=%d, temp=%d fcc_update_count=%d\n", - new_fcc_uah, chargecycles, batt_temp, last_fcc_update_count); - - if (last_fcc_update_count < chip->min_fcc_learning_samples) { - pr_debug("Not enough FCC samples. Current count = %d\n", - last_fcc_update_count); - return; /* Not enough samples to update fcc */ - } - - /* reject entries if they are > 50 chargecycles apart */ - for (i = 0; i < chip->min_fcc_learning_samples; i++) { - if ((chip->fcc_table[i].chargecycles + VALID_FCC_CHGCYL_RANGE) - < chargecycles) { - pr_debug("Charge cycle too old (> %d cycles apart)\n", - VALID_FCC_CHGCYL_RANGE); - return; /* Samples old, > 50 cycles apart*/ - } - } - /* update the fcc table for temperature difference*/ - update_fcc_table_for_temp(chip, batt_temp); - - /* Calculate the avg. and SD for all the fcc entries */ - for (i = 0; i < chip->min_fcc_learning_samples; i++) - temp_fcc_avg += chip->fcc_table[i].fcc_new; - - temp_fcc_avg /= chip->min_fcc_learning_samples; - temp_fcc_delta = div_u64(temp_fcc_avg * DELTA_FCC_PERCENT, 100); - - /* fix the fcc if its an outlier i.e. > 5% of the average */ - for (i = 0; i < chip->min_fcc_learning_samples; i++) { - ft = &chip->fcc_table[i]; - if (abs(ft->fcc_new - temp_fcc_avg) > temp_fcc_delta) - ft->fcc_new = temp_fcc_avg; - new_fcc_avg += ft->fcc_new; - } - new_fcc_avg /= chip->min_fcc_learning_samples; - - last_real_fcc_mah = new_fcc_avg/1000; - last_real_fcc_batt_temp = batt_temp; - - pr_debug("FCC update: last_real_fcc_mah=%d, last_real_fcc_batt_temp=%d\n", - new_fcc_avg, batt_temp); - readjust_fcc_table(); - sysfs_notify(&chip->dev->kobj, NULL, "fcc_data"); -} - -static bool is_new_fcc_valid(int new_fcc_uah, int fcc_uah) -{ - /* reject the new fcc if < 50% and > 105% of nominal fcc */ - if ((new_fcc_uah >= (fcc_uah / 2)) && - ((new_fcc_uah * 100) <= (fcc_uah * 105))) - return true; - - pr_debug("FCC rejected - not within valid limit\n"); - return false; -} - -void pm8921_bms_charging_end(int is_battery_full) -{ - int batt_temp; - struct pm8921_soc_params raw; - - if (the_chip == NULL) - return; - - get_batt_temp(the_chip, &batt_temp); - - mutex_lock(&the_chip->last_ocv_uv_mutex); - - calib_hkadc_check(the_chip, batt_temp); - read_soc_params_raw(the_chip, &raw, batt_temp); - - calculate_cc_uah(the_chip, raw.cc, &bms_end_cc_uah); - - bms_end_ocv_uv = raw.last_good_ocv_uv; - - pr_debug("battery_full = %d, fcc_learning = %d, pc_start_chg = %d\n", - is_battery_full, the_chip->enable_fcc_learning, - the_chip->pc_at_start_charge); - if (is_battery_full && the_chip->enable_fcc_learning && - (the_chip->start_percent <= the_chip->min_fcc_learning_soc) && - (the_chip->pc_at_start_charge <= the_chip->min_fcc_ocv_pc)) { - - int fcc_uah, new_fcc_uah, delta_cc_uah, delta_soc; - /* new_fcc = (cc_end - cc_start) / (end_soc - start_soc) */ - delta_soc = 100 - the_chip->start_real_soc; - delta_cc_uah = abs(bms_end_cc_uah - bms_start_cc_uah); - new_fcc_uah = div_u64(delta_cc_uah * 100, delta_soc); - - fcc_uah = calculate_fcc_uah(the_chip, batt_temp, - last_chargecycles); - pr_info("start_real_soc = %d, end_real_soc = 100, start_cc = %d, end_cc = %d, nominal_fcc = %d, new_fcc = %d\n", - the_chip->start_real_soc, bms_start_cc_uah, - bms_end_cc_uah, fcc_uah, new_fcc_uah); - if (is_new_fcc_valid(new_fcc_uah, fcc_uah)) - update_fcc_learning_table(the_chip, fcc_uah, - new_fcc_uah, last_chargecycles, batt_temp); - } - - if (is_battery_full) { - the_chip->ocv_reading_at_100 = raw.last_good_ocv_raw; - - the_chip->last_ocv_uv = the_chip->max_voltage_uv; - raw.last_good_ocv_uv = the_chip->max_voltage_uv; - raw.cc = 0; - /* reset the cc in h/w */ - reset_cc(the_chip); - the_chip->last_ocv_temp_decidegc = batt_temp; - /* - * since we are treating this as an ocv event - * forget the old cc value - */ - the_chip->last_cc_uah = 0; - pr_debug("EOC BATT_FULL ocv_reading = 0x%x\n", - the_chip->ocv_reading_at_100); - } - - the_chip->end_percent = calculate_state_of_charge(the_chip, &raw, - batt_temp, last_chargecycles); - mutex_unlock(&the_chip->last_ocv_uv_mutex); - - bms_end_percent = the_chip->end_percent; - - if (the_chip->end_percent > the_chip->start_percent) { - last_charge_increase += - the_chip->end_percent - the_chip->start_percent; - if (last_charge_increase > 100) { - last_chargecycles++; - last_charge_increase = last_charge_increase % 100; - } - } - pr_debug("end_percent = %u%% last_charge_increase = %d" - "last_chargecycles = %d\n", - the_chip->end_percent, - last_charge_increase, - last_chargecycles); - the_chip->start_percent = -EINVAL; - the_chip->end_percent = -EINVAL; - the_chip->charge_time_us = 0; - the_chip->catch_up_time_us = 0; - the_chip->soc_at_cv = -EINVAL; - the_chip->prev_chg_soc = -EINVAL; - pm_bms_masked_write(the_chip, BMS_TOLERANCES, - IBAT_TOL_MASK, IBAT_TOL_NOCHG); -} -EXPORT_SYMBOL_GPL(pm8921_bms_charging_end); - -static irqreturn_t pm8921_bms_sbi_write_ok_handler(int irq, void *data) -{ - pr_debug("irq = %d triggered", irq); - return IRQ_HANDLED; -} - -static irqreturn_t pm8921_bms_cc_thr_handler(int irq, void *data) -{ - pr_debug("irq = %d triggered", irq); - return IRQ_HANDLED; -} - -static irqreturn_t pm8921_bms_vsense_thr_handler(int irq, void *data) -{ - pr_debug("irq = %d triggered", irq); - return IRQ_HANDLED; -} - -static irqreturn_t pm8921_bms_vsense_for_r_handler(int irq, void *data) -{ - pr_debug("irq = %d triggered", irq); - return IRQ_HANDLED; -} - -static irqreturn_t pm8921_bms_ocv_for_r_handler(int irq, void *data) -{ - struct pm8921_bms_chip *chip = data; - - pr_debug("irq = %d triggered", irq); - schedule_work(&chip->calib_hkadc_work); - return IRQ_HANDLED; -} - -static irqreturn_t pm8921_bms_good_ocv_handler(int irq, void *data) -{ - struct pm8921_bms_chip *chip = data; - - pr_debug("irq = %d triggered", irq); - schedule_work(&chip->calib_hkadc_work); - return IRQ_HANDLED; -} - -struct pm_bms_irq_init_data { - unsigned int irq_id; - char *name; - unsigned long flags; - irqreturn_t (*handler)(int, void *); -}; - -#define BMS_IRQ(_id, _flags, _handler) \ -{ \ - .irq_id = _id, \ - .name = #_id, \ - .flags = _flags, \ - .handler = _handler, \ -} - -struct pm_bms_irq_init_data bms_irq_data[] = { - BMS_IRQ(PM8921_BMS_SBI_WRITE_OK, IRQF_TRIGGER_RISING, - pm8921_bms_sbi_write_ok_handler), - BMS_IRQ(PM8921_BMS_CC_THR, IRQF_TRIGGER_RISING, - pm8921_bms_cc_thr_handler), - BMS_IRQ(PM8921_BMS_VSENSE_THR, IRQF_TRIGGER_RISING, - pm8921_bms_vsense_thr_handler), - BMS_IRQ(PM8921_BMS_VSENSE_FOR_R, IRQF_TRIGGER_RISING, - pm8921_bms_vsense_for_r_handler), - BMS_IRQ(PM8921_BMS_OCV_FOR_R, IRQF_TRIGGER_RISING, - pm8921_bms_ocv_for_r_handler), - BMS_IRQ(PM8921_BMS_GOOD_OCV, IRQF_TRIGGER_RISING, - pm8921_bms_good_ocv_handler), -}; - -static void free_irqs(struct pm8921_bms_chip *chip) -{ - int i; - - for (i = 0; i < PM_BMS_MAX_INTS; i++) - if (chip->pmic_bms_irq[i]) { - free_irq(chip->pmic_bms_irq[i], NULL); - chip->pmic_bms_irq[i] = 0; - } -} - -static int request_irqs(struct pm8921_bms_chip *chip, - struct platform_device *pdev) -{ - struct resource *res; - int ret, i; - - ret = 0; - bitmap_fill(chip->enabled_irqs, PM_BMS_MAX_INTS); - - for (i = 0; i < ARRAY_SIZE(bms_irq_data); i++) { - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - bms_irq_data[i].name); - if (res == NULL) { - pr_err("couldn't find %s\n", bms_irq_data[i].name); - goto err_out; - } - ret = request_irq(res->start, bms_irq_data[i].handler, - bms_irq_data[i].flags, - bms_irq_data[i].name, chip); - if (ret < 0) { - pr_err("couldn't request %d (%s) %d\n", res->start, - bms_irq_data[i].name, ret); - goto err_out; - } - chip->pmic_bms_irq[bms_irq_data[i].irq_id] = res->start; - pm8921_bms_disable_irq(chip, bms_irq_data[i].irq_id); - } - return 0; - -err_out: - free_irqs(chip); - return -EINVAL; -} - -#define EN_BMS_BIT BIT(7) -#define EN_PON_HS_BIT BIT(0) -static int pm8921_bms_hw_init(struct pm8921_bms_chip *chip) -{ - int rc; - - rc = pm_bms_masked_write(chip, BMS_CONTROL, - EN_BMS_BIT | EN_PON_HS_BIT, EN_BMS_BIT | EN_PON_HS_BIT); - if (rc) { - pr_err("failed to enable pon and bms addr = %d %d", - BMS_CONTROL, rc); - } - - /* The charger will call start charge later if usb is present */ - pm_bms_masked_write(chip, BMS_TOLERANCES, - IBAT_TOL_MASK, IBAT_TOL_NOCHG); - return 0; -} - -static void check_initial_ocv(struct pm8921_bms_chip *chip) -{ - int ocv_uv, rc; - int16_t ocv_raw; - int usb_chg; - - /* - * Check if a ocv is available in bms hw, - * if not compute it here at boot time and save it - * in the last_ocv_uv. - */ - ocv_uv = 0; - pm_bms_read_output_data(chip, LAST_GOOD_OCV_VALUE, &ocv_raw); - usb_chg = usb_chg_plugged_in(chip); - rc = convert_vbatt_raw_to_uv(chip, usb_chg, ocv_raw, &ocv_uv); - if (rc || ocv_uv == 0) { - rc = adc_based_ocv(chip, &ocv_uv); - if (rc) { - pr_err("failed to read adc based ocv_uv rc = %d\n", rc); - ocv_uv = DEFAULT_OCV_MICROVOLTS; - } - } - chip->last_ocv_uv = ocv_uv; - pr_debug("ocv_uv = %d last_ocv_uv = %d\n", ocv_uv, chip->last_ocv_uv); -} - -static int64_t read_battery_id(struct pm8921_bms_chip *chip) -{ - int rc; - struct pm8xxx_adc_chan_result result; - - rc = pm8xxx_adc_read(chip->batt_id_channel, &result); - if (rc) { - pr_err("error reading batt id channel = %d, rc = %d\n", - chip->vbat_channel, rc); - return rc; - } - pr_debug("batt_id phy = %lld meas = 0x%llx\n", result.physical, - result.measurement); - return result.adc_code; -} - -#define PALLADIUM_ID_MIN 0x7F40 -#define PALLADIUM_ID_MAX 0x7F5A -#define DESAY_5200_ID_MIN 0x7F7F -#define DESAY_5200_ID_MAX 0x802F -static int set_battery_data(struct pm8921_bms_chip *chip) -{ - int64_t battery_id; - - if (chip->batt_type == BATT_DESAY) - goto desay; - else if (chip->batt_type == BATT_PALLADIUM) - goto palladium; - - battery_id = read_battery_id(chip); - if (battery_id < 0) { - pr_err("cannot read battery id err = %lld\n", battery_id); - return battery_id; - } - - if (is_between(PALLADIUM_ID_MIN, PALLADIUM_ID_MAX, battery_id)) { - goto palladium; - } else if (is_between(DESAY_5200_ID_MIN, DESAY_5200_ID_MAX, - battery_id)) { - goto desay; - } else { - pr_warn("invalid battid, palladium 1500 assumed batt_id %llx\n", - battery_id); - goto palladium; - } - -palladium: - chip->fcc = palladium_1500_data.fcc; - chip->fcc_temp_lut = palladium_1500_data.fcc_temp_lut; - chip->fcc_sf_lut = palladium_1500_data.fcc_sf_lut; - chip->pc_temp_ocv_lut = palladium_1500_data.pc_temp_ocv_lut; - chip->pc_sf_lut = palladium_1500_data.pc_sf_lut; - chip->rbatt_sf_lut = palladium_1500_data.rbatt_sf_lut; - chip->default_rbatt_mohm - = palladium_1500_data.default_rbatt_mohm; - chip->delta_rbatt_mohm = palladium_1500_data.delta_rbatt_mohm; - chip->rbatt_capacitive_mohm - = palladium_1500_data.rbatt_capacitive_mohm; - return 0; -desay: - chip->fcc = desay_5200_data.fcc; - chip->fcc_temp_lut = desay_5200_data.fcc_temp_lut; - chip->pc_temp_ocv_lut = desay_5200_data.pc_temp_ocv_lut; - chip->pc_sf_lut = desay_5200_data.pc_sf_lut; - chip->rbatt_sf_lut = desay_5200_data.rbatt_sf_lut; - chip->default_rbatt_mohm = desay_5200_data.default_rbatt_mohm; - chip->delta_rbatt_mohm = desay_5200_data.delta_rbatt_mohm; - chip->rbatt_capacitive_mohm - = desay_5200_data.rbatt_capacitive_mohm; - return 0; -} - -enum bms_request_operation { - CALC_FCC, - CALC_PC, - CALC_SOC, - CALIB_HKADC, - CALIB_CCADC, - GET_VBAT_VSENSE_SIMULTANEOUS, - STOP_OCV, - START_OCV, - SET_OCV, - BATT_PRESENT, -}; - -static int test_batt_temp = 5; -static int test_chargecycle = 150; -static int test_ocv = 3900000; -enum { - TEST_BATT_TEMP, - TEST_CHARGE_CYCLE, - TEST_OCV, -}; -static int get_test_param(void *data, u64 * val) -{ - switch ((int)data) { - case TEST_BATT_TEMP: - *val = test_batt_temp; - break; - case TEST_CHARGE_CYCLE: - *val = test_chargecycle; - break; - case TEST_OCV: - *val = test_ocv; - break; - default: - return -EINVAL; - } - return 0; -} -static int set_test_param(void *data, u64 val) -{ - switch ((int)data) { - case TEST_BATT_TEMP: - test_batt_temp = (int)val; - break; - case TEST_CHARGE_CYCLE: - test_chargecycle = (int)val; - break; - case TEST_OCV: - test_ocv = (int)val; - break; - default: - return -EINVAL; - } - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(temp_fops, get_test_param, set_test_param, "%llu\n"); - -static int get_calc(void *data, u64 * val) -{ - int param = (int)data; - int ret = 0; - int ibat_ua, vbat_uv; - struct pm8921_soc_params raw; - - read_soc_params_raw(the_chip, &raw, 300); - - *val = 0; - - /* global irq number passed in via data */ - switch (param) { - case CALC_FCC: - *val = calculate_fcc_uah(the_chip, test_batt_temp, - test_chargecycle); - break; - case CALC_PC: - *val = calculate_pc(the_chip, test_ocv, test_batt_temp, - test_chargecycle); - break; - case CALC_SOC: - *val = calculate_state_of_charge(the_chip, &raw, - test_batt_temp, test_chargecycle); - break; - case CALIB_HKADC: - /* reading this will trigger calibration */ - *val = 0; - calib_hkadc(the_chip); - break; - case CALIB_CCADC: - /* reading this will trigger calibration */ - *val = 0; - pm8xxx_calib_ccadc(); - break; - case GET_VBAT_VSENSE_SIMULTANEOUS: - /* reading this will call simultaneous vbat and vsense */ - *val = - pm8921_bms_get_simultaneous_battery_voltage_and_current( - &ibat_ua, - &vbat_uv); - default: - ret = -EINVAL; - } - return ret; -} - -static int set_calc(void *data, u64 val) -{ - int param = (int)data; - int ret = 0; - - switch (param) { - case STOP_OCV: - pm8921_bms_stop_ocv_updates(); - break; - case START_OCV: - pm8921_bms_start_ocv_updates(); - break; - default: - ret = -EINVAL; - } - return ret; -} -DEFINE_SIMPLE_ATTRIBUTE(calc_fops, get_calc, set_calc, "%llu\n"); - -static int get_reading(void *data, u64 * val) -{ - int param = (int)data; - int ret = 0; - struct pm8921_soc_params raw; - - mutex_lock(&the_chip->last_ocv_uv_mutex); - read_soc_params_raw(the_chip, &raw, 300); - mutex_lock(&the_chip->last_ocv_uv_mutex); - - *val = 0; - - switch (param) { - case CC_MSB: - case CC_LSB: - *val = raw.cc; - break; - case LAST_GOOD_OCV_VALUE: - *val = raw.last_good_ocv_uv; - break; - case VSENSE_AVG: - read_vsense_avg(the_chip, (uint *)val); - break; - default: - ret = -EINVAL; - } - return ret; -} -DEFINE_SIMPLE_ATTRIBUTE(reading_fops, get_reading, NULL, "%lld\n"); - -static int get_rt_status(void *data, u64 * val) -{ - int i = (int)data; - int ret; - - /* global irq number passed in via data */ - ret = pm_bms_get_rt_status(the_chip, i); - *val = ret; - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(rt_fops, get_rt_status, NULL, "%llu\n"); - -static int get_reg(void *data, u64 * val) -{ - int addr = (int)data; - int ret; - u8 temp; - - ret = pm8xxx_readb(the_chip->dev->parent, addr, &temp); - if (ret) { - pr_err("pm8xxx_readb to %x value = %d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - *val = temp; - return 0; -} - -static int set_reg(void *data, u64 val) -{ - int addr = (int)data; - int ret; - u8 temp; - - temp = (u8) val; - ret = pm8xxx_writeb(the_chip->dev->parent, addr, temp); - if (ret) { - pr_err("pm8xxx_writeb to %x value = %d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(reg_fops, get_reg, set_reg, "0x%02llx\n"); - -static void create_debugfs_entries(struct pm8921_bms_chip *chip) -{ - int i; - - chip->dent = debugfs_create_dir("pm8921-bms", NULL); - - if (IS_ERR(chip->dent)) { - pr_err("pmic bms couldnt create debugfs dir\n"); - return; - } - - debugfs_create_file("BMS_CONTROL", 0644, chip->dent, - (void *)BMS_CONTROL, ®_fops); - debugfs_create_file("BMS_OUTPUT0", 0644, chip->dent, - (void *)BMS_OUTPUT0, ®_fops); - debugfs_create_file("BMS_OUTPUT1", 0644, chip->dent, - (void *)BMS_OUTPUT1, ®_fops); - debugfs_create_file("BMS_TEST1", 0644, chip->dent, - (void *)BMS_TEST1, ®_fops); - - debugfs_create_file("test_batt_temp", 0644, chip->dent, - (void *)TEST_BATT_TEMP, &temp_fops); - debugfs_create_file("test_chargecycle", 0644, chip->dent, - (void *)TEST_CHARGE_CYCLE, &temp_fops); - debugfs_create_file("test_ocv", 0644, chip->dent, - (void *)TEST_OCV, &temp_fops); - - debugfs_create_file("read_cc", 0644, chip->dent, - (void *)CC_MSB, &reading_fops); - debugfs_create_file("read_last_good_ocv", 0644, chip->dent, - (void *)LAST_GOOD_OCV_VALUE, &reading_fops); - debugfs_create_file("read_vbatt_for_rbatt", 0644, chip->dent, - (void *)VBATT_FOR_RBATT, &reading_fops); - debugfs_create_file("read_vsense_for_rbatt", 0644, chip->dent, - (void *)VSENSE_FOR_RBATT, &reading_fops); - debugfs_create_file("read_ocv_for_rbatt", 0644, chip->dent, - (void *)OCV_FOR_RBATT, &reading_fops); - debugfs_create_file("read_vsense_avg", 0644, chip->dent, - (void *)VSENSE_AVG, &reading_fops); - - debugfs_create_file("show_fcc", 0644, chip->dent, - (void *)CALC_FCC, &calc_fops); - debugfs_create_file("show_pc", 0644, chip->dent, - (void *)CALC_PC, &calc_fops); - debugfs_create_file("show_soc", 0644, chip->dent, - (void *)CALC_SOC, &calc_fops); - debugfs_create_file("calib_hkadc", 0644, chip->dent, - (void *)CALIB_HKADC, &calc_fops); - debugfs_create_file("calib_ccadc", 0644, chip->dent, - (void *)CALIB_CCADC, &calc_fops); - debugfs_create_file("stop_ocv", 0644, chip->dent, - (void *)STOP_OCV, &calc_fops); - debugfs_create_file("start_ocv", 0644, chip->dent, - (void *)START_OCV, &calc_fops); - debugfs_create_file("set_ocv", 0644, chip->dent, - (void *)SET_OCV, &calc_fops); - debugfs_create_file("batt_present", 0644, chip->dent, - (void *)BATT_PRESENT, &calc_fops); - - debugfs_create_file("simultaneous", 0644, chip->dent, - (void *)GET_VBAT_VSENSE_SIMULTANEOUS, &calc_fops); - - for (i = 0; i < ARRAY_SIZE(bms_irq_data); i++) { - if (chip->pmic_bms_irq[bms_irq_data[i].irq_id]) - debugfs_create_file(bms_irq_data[i].name, 0444, - chip->dent, - (void *)bms_irq_data[i].irq_id, - &rt_fops); - } -} - -static ssize_t fcc_data_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct pm8921_bms_chip *chip = dev_get_drvdata(dev); - static int i; - int fcc_new = 0, rc; - - if (battery_removed) { - pr_debug("Invalid FCC table. Possible battery removal\n"); - last_fcc_update_count = 0; - return count; - } - - i %= chip->min_fcc_learning_samples; - rc = sscanf(buf, "%d", &fcc_new); - if (rc != 1) - return -EINVAL; - chip->fcc_table[i].fcc_new = fcc_new; - chip->fcc_table[i].fcc_real = fcc_new; - pr_debug("Rcvd: [%d] fcc_new=%d\n", i, fcc_new); - i++; - - return count; -} - -static ssize_t fcc_data_get(struct device *dev, struct device_attribute *attr, - char *buf) -{ - int count = 0; - struct pm8921_bms_chip *chip = dev_get_drvdata(dev); - - if (battery_removed) { - pr_debug("Invalidate the fcc table\n"); - invalidate_fcc(chip); - battery_removed = 0; - return count; - } - - count = snprintf(buf, PAGE_SIZE, "%d", chip->fcc_new); - - pr_debug("Sent: fcc_new=%d\n", chip->fcc_new); - - return count; -} - -static ssize_t fcc_temp_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - static int i; - int batt_temp = 0, rc; - struct pm8921_bms_chip *chip = dev_get_drvdata(dev); - - i %= chip->min_fcc_learning_samples; - rc = sscanf(buf, "%d", &batt_temp); - if (rc != 1) - return -EINVAL; - chip->fcc_table[i].batt_temp = batt_temp; - chip->fcc_table[i].temp_real = batt_temp; - pr_debug("Rcvd: [%d] batt_temp=%d\n", i, batt_temp); - i++; - - return count; -} - -static ssize_t fcc_chgcyl_set(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - static int i; - int chargecycle = 0, rc; - struct pm8921_bms_chip *chip = dev_get_drvdata(dev); - - i %= chip->min_fcc_learning_samples; - rc = sscanf(buf, "%d", &chargecycle); - if (rc != 1) - return -EINVAL; - chip->fcc_table[i].chargecycles = chargecycle; - pr_debug("Rcvd: [%d] chargecycle=%d\n", i, chargecycle); - i++; - - return count; -} - -static ssize_t fcc_list_get(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct pm8921_bms_chip *chip = dev_get_drvdata(dev); - struct fcc_data *ft; - int i = 0, j, count = 0; - - if (last_fcc_update_count < chip->min_fcc_learning_samples) - i = last_fcc_update_count; - else - i = chip->min_fcc_learning_samples; - - for (j = 0; j < i; j++) { - ft = &chip->fcc_table[j]; - count += snprintf(buf + count, PAGE_SIZE - count, - "%d %d %d %d %d\n", ft->fcc_new, ft->chargecycles, - ft->batt_temp, ft->fcc_real, ft->temp_real); - } - - return count; -} - -static DEVICE_ATTR(fcc_data, 0664, fcc_data_get, fcc_data_set); -static DEVICE_ATTR(fcc_temp, 0664, NULL, fcc_temp_set); -static DEVICE_ATTR(fcc_chgcyl, 0664, NULL, fcc_chgcyl_set); -static DEVICE_ATTR(fcc_list, 0664, fcc_list_get, NULL); - -static struct attribute *fcc_attrs[] = { - &dev_attr_fcc_data.attr, - &dev_attr_fcc_temp.attr, - &dev_attr_fcc_chgcyl.attr, - &dev_attr_fcc_list.attr, - NULL -}; - -static const struct attribute_group fcc_attr_group = { - .attrs = fcc_attrs, -}; - -#define REG_SBI_CONFIG 0x04F -#define PAGE3_ENABLE_MASK 0x6 -#define PROGRAM_REV_MASK 0x0F -#define PROGRAM_REV 0x9 -static int read_ocv_trim(struct pm8921_bms_chip *chip) -{ - int rc; - u8 reg, sbi_config; - - rc = pm8xxx_readb(chip->dev->parent, REG_SBI_CONFIG, &sbi_config); - if (rc) { - pr_err("error = %d reading sbi config reg\n", rc); - return rc; - } - - reg = sbi_config | PAGE3_ENABLE_MASK; - rc = pm8xxx_writeb(chip->dev->parent, REG_SBI_CONFIG, reg); - if (rc) { - pr_err("error = %d writing sbi config reg\n", rc); - return rc; - } - - rc = pm8xxx_readb(chip->dev->parent, TEST_PROGRAM_REV, ®); - if (rc) - pr_err("Error %d reading %d addr %d\n", - rc, reg, TEST_PROGRAM_REV); - pr_err("program rev reg is 0x%x\n", reg); - reg &= PROGRAM_REV_MASK; - - /* If the revision is equal or higher do not adjust trim delta */ - if (reg >= PROGRAM_REV) { - chip->amux_2_trim_delta = 0; - goto restore_sbi_config; - } - - rc = pm8xxx_readb(chip->dev->parent, AMUX_TRIM_2, ®); - if (rc) { - pr_err("error = %d reading trim reg\n", rc); - return rc; - } - - pr_err("trim reg is 0x%x\n", reg); - chip->amux_2_trim_delta = abs(0x49 - reg); - pr_err("trim delta is %d\n", chip->amux_2_trim_delta); - -restore_sbi_config: - rc = pm8xxx_writeb(chip->dev->parent, REG_SBI_CONFIG, sbi_config); - if (rc) { - pr_err("error = %d writing sbi config reg\n", rc); - return rc; - } - - return 0; -} - -static int pm8921_bms_probe(struct platform_device *pdev) -{ - int rc = 0; - int vbatt; - struct pm8921_bms_chip *chip; - const struct pm8921_bms_platform_data *pdata - = pdev->dev.platform_data; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct pm8921_bms_chip), GFP_KERNEL); - if (!chip) { - pr_err("Cannot allocate pm_bms_chip\n"); - return -ENOMEM; - } - - mutex_init(&chip->bms_output_lock); - mutex_init(&chip->last_ocv_uv_mutex); - chip->dev = &pdev->dev; - chip->r_sense_uohm = pdata->r_sense_uohm; - chip->v_cutoff = pdata->v_cutoff; - chip->max_voltage_uv = pdata->max_voltage_uv; - chip->chg_term_ua = pdata->chg_term_ua; - chip->batt_type = pdata->battery_type; - chip->rconn_mohm = pdata->rconn_mohm; - chip->start_percent = -EINVAL; - chip->end_percent = -EINVAL; - chip->last_cc_uah = INT_MIN; - chip->ocv_reading_at_100 = OCV_RAW_UNINITIALIZED; - chip->prev_last_good_ocv_raw = OCV_RAW_UNINITIALIZED; - chip->shutdown_soc_valid_limit = pdata->shutdown_soc_valid_limit; - chip->adjust_soc_low_threshold = pdata->adjust_soc_low_threshold; - - chip->normal_voltage_calc_ms = pdata->normal_voltage_calc_ms; - chip->low_voltage_calc_ms = pdata->low_voltage_calc_ms; - - chip->soc_calc_period = pdata->normal_voltage_calc_ms; - - if (chip->adjust_soc_low_threshold >= 45) - chip->adjust_soc_low_threshold = 45; - - chip->prev_pc_unusable = -EINVAL; - chip->soc_at_cv = -EINVAL; - chip->imax_ua = -EINVAL; - - chip->ignore_shutdown_soc = pdata->ignore_shutdown_soc; - rc = set_battery_data(chip); - if (rc) { - pr_err("%s bad battery data %d\n", __func__, rc); - goto free_chip; - } - - if (chip->pc_temp_ocv_lut == NULL) { - pr_err("temp ocv lut table is NULL\n"); - rc = -EINVAL; - goto free_chip; - } - - /* set defaults in the battery data */ - if (chip->default_rbatt_mohm <= 0) - chip->default_rbatt_mohm = DEFAULT_RBATT_MOHMS; - - chip->batt_temp_channel = pdata->bms_cdata.batt_temp_channel; - chip->vbat_channel = pdata->bms_cdata.vbat_channel; - chip->ref625mv_channel = pdata->bms_cdata.ref625mv_channel; - chip->ref1p25v_channel = pdata->bms_cdata.ref1p25v_channel; - chip->batt_id_channel = pdata->bms_cdata.batt_id_channel; - chip->revision = pm8xxx_get_revision(chip->dev->parent); - chip->enable_fcc_learning = pdata->enable_fcc_learning; - chip->min_fcc_learning_soc = pdata->min_fcc_learning_soc; - chip->min_fcc_ocv_pc = pdata->min_fcc_ocv_pc; - chip->min_fcc_learning_samples = pdata->min_fcc_learning_samples; - if (chip->enable_fcc_learning) { - if (!chip->min_fcc_learning_soc) - chip->min_fcc_learning_soc = - MIN_START_PERCENT_FOR_LEARNING; - if (!chip->min_fcc_ocv_pc) - chip->min_fcc_ocv_pc = - MIN_START_OCV_PERCENT_FOR_LEARNING; - if (!chip->min_fcc_learning_samples || - chip->min_fcc_learning_samples > MAX_FCC_LEARNING_COUNT) - chip->min_fcc_learning_samples = MAX_FCC_LEARNING_COUNT; - - min_fcc_cycles = chip->min_fcc_learning_samples; - chip->fcc_table = kzalloc(sizeof(struct fcc_data) * - chip->min_fcc_learning_samples, GFP_KERNEL); - if (!chip->fcc_table) { - pr_err("Unable to allocate table for fcc learning\n"); - rc = -ENOMEM; - goto free_chip; - } - rc = sysfs_create_group(&pdev->dev.kobj, &fcc_attr_group); - if (rc) { - pr_err("Unable to create sysfs entries\n"); - goto free_chip; - } - } - - chip->disable_flat_portion_ocv = pdata->disable_flat_portion_ocv; - chip->ocv_dis_high_soc = pdata->ocv_dis_high_soc; - chip->ocv_dis_low_soc = pdata->ocv_dis_low_soc; - - chip->high_ocv_correction_limit_uv - = pdata->high_ocv_correction_limit_uv; - chip->low_ocv_correction_limit_uv = pdata->low_ocv_correction_limit_uv; - chip->hold_soc_est = pdata->hold_soc_est; - - chip->alarm_low_mv = pdata->alarm_low_mv; - chip->alarm_high_mv = pdata->alarm_high_mv; - chip->low_voltage_detect = pdata->low_voltage_detect; - chip->vbatt_cutoff_retries = pdata->vbatt_cutoff_retries; - - mutex_init(&chip->calib_mutex); - INIT_WORK(&chip->calib_hkadc_work, calibrate_hkadc_work); - - INIT_DELAYED_WORK(&chip->calculate_soc_delayed_work, - calculate_soc_work); - - wake_lock_init(&chip->soc_wake_lock, - WAKE_LOCK_SUSPEND, "pm8921_soc_lock"); - rc = request_irqs(chip, pdev); - if (rc) { - pr_err("couldn't register interrupts rc = %d\n", rc); - goto destroy_soc_wl; - } - - wake_lock_init(&chip->low_voltage_wake_lock, - WAKE_LOCK_SUSPEND, "pm8921_bms_low"); - - rc = pm8921_bms_hw_init(chip); - if (rc) { - pr_err("couldn't init hardware rc = %d\n", rc); - goto free_irqs; - } - - read_shutdown_soc_and_iavg(chip); - - platform_set_drvdata(pdev, chip); - the_chip = chip; - create_debugfs_entries(chip); - - rc = read_ocv_trim(chip); - if (rc) { - pr_err("couldn't adjust ocv_trim rc= %d\n", rc); - goto free_irqs; - } - check_initial_ocv(chip); - - /* enable the vbatt reading interrupts for scheduling hkadc calib */ - pm8921_bms_enable_irq(chip, PM8921_BMS_GOOD_OCV); - pm8921_bms_enable_irq(chip, PM8921_BMS_OCV_FOR_R); - - rc = pm8921_bms_configure_batt_alarm(chip); - if (rc) { - pr_err("Couldn't configure battery alarm! rc=%d\n", rc); - goto free_irqs; - } - - rc = pm8921_bms_enable_batt_alarm(chip); - if (rc) { - pr_err("Couldn't enable battery alarm! rc=%d\n", rc); - goto free_irqs; - } - - calculate_soc_work(&(chip->calculate_soc_delayed_work.work)); - - rc = get_battery_uvolts(chip, &vbatt); - if (!rc) - pr_info("OK battery_capacity_at_boot=%d volt = %d ocv = %d\n", - pm8921_bms_get_percent_charge(), - vbatt, chip->last_ocv_uv); - else - pr_info("Unable to read battery voltage at boot\n"); - - return 0; - -free_irqs: - wake_lock_destroy(&chip->low_voltage_wake_lock); - free_irqs(chip); -destroy_soc_wl: - wake_lock_destroy(&chip->soc_wake_lock); -free_chip: - kfree(chip); - return rc; -} - -static int pm8921_bms_remove(struct platform_device *pdev) -{ - struct pm8921_bms_chip *chip = platform_get_drvdata(pdev); - - free_irqs(chip); - kfree(chip->adjusted_fcc_temp_lut); - platform_set_drvdata(pdev, NULL); - the_chip = NULL; - kfree(chip); - return 0; -} - -static int pm8921_bms_suspend(struct device *dev) -{ - struct pm8921_bms_chip *chip = dev_get_drvdata(dev); - - cancel_delayed_work_sync(&chip->calculate_soc_delayed_work); - - chip->last_soc_at_suspend = last_soc; - - return 0; -} - -static int pm8921_bms_resume(struct device *dev) -{ - int rc; - unsigned long time_since_last_recalc; - unsigned long tm_now_sec; - struct pm8921_bms_chip *chip = dev_get_drvdata(dev); - - rc = get_current_time(&tm_now_sec); - if (rc) { - pr_err("Could not read current time: %d\n", rc); - return 0; - } - - if (tm_now_sec > chip->last_recalc_time) { - time_since_last_recalc = tm_now_sec - - chip->last_recalc_time; - pr_debug("Time since last recalc: %lu\n", - time_since_last_recalc); - if ((time_since_last_recalc * 1000) >= - chip->soc_calc_period) { - chip->last_recalc_time = tm_now_sec; - recalculate_soc(chip); - chip->soc_updated_on_resume = true; - } - } - chip->first_report_after_suspend = true; - update_power_supply(chip); - schedule_delayed_work(&chip->calculate_soc_delayed_work, - msecs_to_jiffies(chip->soc_calc_period)); - - return 0; -} - -static const struct dev_pm_ops pm8921_bms_pm_ops = { - .resume = pm8921_bms_resume, - .suspend = pm8921_bms_suspend, -}; - -static struct platform_driver pm8921_bms_driver = { - .probe = pm8921_bms_probe, - .remove = pm8921_bms_remove, - .driver = { - .name = PM8921_BMS_DEV_NAME, - .owner = THIS_MODULE, - .pm = &pm8921_bms_pm_ops, - }, -}; - -static int __init pm8921_bms_init(void) -{ - return platform_driver_register(&pm8921_bms_driver); -} - -static void __exit pm8921_bms_exit(void) -{ - platform_driver_unregister(&pm8921_bms_driver); -} - -late_initcall(pm8921_bms_init); -module_exit(pm8921_bms_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8921 bms driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8921_BMS_DEV_NAME); diff --git a/drivers/power/pm8921-charger.c b/drivers/power/pm8921-charger.c deleted file mode 100644 index 000d63e316a59b7f422beab2839733cb7c5146d4..0000000000000000000000000000000000000000 --- a/drivers/power/pm8921-charger.c +++ /dev/null @@ -1,4964 +0,0 @@ -/* Copyright (c) 2011-2013, 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. - * - */ -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define CHG_BUCK_CLOCK_CTRL 0x14 -#define CHG_BUCK_CLOCK_CTRL_8038 0xD - -#define PBL_ACCESS1 0x04 -#define PBL_ACCESS2 0x05 -#define SYS_CONFIG_1 0x06 -#define SYS_CONFIG_2 0x07 -#define CHG_CNTRL 0x204 -#define CHG_IBAT_MAX 0x205 -#define CHG_TEST 0x206 -#define CHG_BUCK_CTRL_TEST1 0x207 -#define CHG_BUCK_CTRL_TEST2 0x208 -#define CHG_BUCK_CTRL_TEST3 0x209 -#define COMPARATOR_OVERRIDE 0x20A -#define PSI_TXRX_SAMPLE_DATA_0 0x20B -#define PSI_TXRX_SAMPLE_DATA_1 0x20C -#define PSI_TXRX_SAMPLE_DATA_2 0x20D -#define PSI_TXRX_SAMPLE_DATA_3 0x20E -#define PSI_CONFIG_STATUS 0x20F -#define CHG_IBAT_SAFE 0x210 -#define CHG_ITRICKLE 0x211 -#define CHG_CNTRL_2 0x212 -#define CHG_VBAT_DET 0x213 -#define CHG_VTRICKLE 0x214 -#define CHG_ITERM 0x215 -#define CHG_CNTRL_3 0x216 -#define CHG_VIN_MIN 0x217 -#define CHG_TWDOG 0x218 -#define CHG_TTRKL_MAX 0x219 -#define CHG_TEMP_THRESH 0x21A -#define CHG_TCHG_MAX 0x21B -#define USB_OVP_CONTROL 0x21C -#define DC_OVP_CONTROL 0x21D -#define USB_OVP_TEST 0x21E -#define DC_OVP_TEST 0x21F -#define CHG_VDD_MAX 0x220 -#define CHG_VDD_SAFE 0x221 -#define CHG_VBAT_BOOT_THRESH 0x222 -#define USB_OVP_TRIM 0x355 -#define BUCK_CONTROL_TRIM1 0x356 -#define BUCK_CONTROL_TRIM2 0x357 -#define BUCK_CONTROL_TRIM3 0x358 -#define BUCK_CONTROL_TRIM4 0x359 -#define CHG_DEFAULTS_TRIM 0x35A -#define CHG_ITRIM 0x35B -#define CHG_TTRIM 0x35C -#define CHG_COMP_OVR 0x20A -#define IUSB_FINE_RES 0x2B6 -#define OVP_USB_UVD 0x2B7 -#define PM8921_USB_TRIM_SEL 0x339 - -/* check EOC every 10 seconds */ -#define EOC_CHECK_PERIOD_MS 10000 -/* check for USB unplug every 200 msecs */ -#define UNPLUG_CHECK_WAIT_PERIOD_MS 200 -#define UNPLUG_CHECK_RAMP_MS 25 -#define USB_TRIM_ENTRIES 16 - -enum chg_fsm_state { - FSM_STATE_OFF_0 = 0, - FSM_STATE_BATFETDET_START_12 = 12, - FSM_STATE_BATFETDET_END_16 = 16, - FSM_STATE_ON_CHG_HIGHI_1 = 1, - FSM_STATE_ATC_2A = 2, - FSM_STATE_ATC_2B = 18, - FSM_STATE_ON_BAT_3 = 3, - FSM_STATE_ATC_FAIL_4 = 4 , - FSM_STATE_DELAY_5 = 5, - FSM_STATE_ON_CHG_AND_BAT_6 = 6, - FSM_STATE_FAST_CHG_7 = 7, - FSM_STATE_TRKL_CHG_8 = 8, - FSM_STATE_CHG_FAIL_9 = 9, - FSM_STATE_EOC_10 = 10, - FSM_STATE_ON_CHG_VREGOK_11 = 11, - FSM_STATE_ATC_PAUSE_13 = 13, - FSM_STATE_FAST_CHG_PAUSE_14 = 14, - FSM_STATE_TRKL_CHG_PAUSE_15 = 15, - FSM_STATE_START_BOOT = 20, - FSM_STATE_FLCB_VREGOK = 21, - FSM_STATE_FLCB = 22, -}; - -struct fsm_state_to_batt_status { - enum chg_fsm_state fsm_state; - int batt_state; -}; - -static struct fsm_state_to_batt_status map[] = { - {FSM_STATE_OFF_0, POWER_SUPPLY_STATUS_UNKNOWN}, - {FSM_STATE_BATFETDET_START_12, POWER_SUPPLY_STATUS_UNKNOWN}, - {FSM_STATE_BATFETDET_END_16, POWER_SUPPLY_STATUS_UNKNOWN}, - /* - * for CHG_HIGHI_1 report NOT_CHARGING if battery missing, - * too hot/cold, charger too hot - */ - {FSM_STATE_ON_CHG_HIGHI_1, POWER_SUPPLY_STATUS_FULL}, - {FSM_STATE_ATC_2A, POWER_SUPPLY_STATUS_CHARGING}, - {FSM_STATE_ATC_2B, POWER_SUPPLY_STATUS_CHARGING}, - {FSM_STATE_ON_BAT_3, POWER_SUPPLY_STATUS_DISCHARGING}, - {FSM_STATE_ATC_FAIL_4, POWER_SUPPLY_STATUS_DISCHARGING}, - {FSM_STATE_DELAY_5, POWER_SUPPLY_STATUS_UNKNOWN }, - {FSM_STATE_ON_CHG_AND_BAT_6, POWER_SUPPLY_STATUS_CHARGING}, - {FSM_STATE_FAST_CHG_7, POWER_SUPPLY_STATUS_CHARGING}, - {FSM_STATE_TRKL_CHG_8, POWER_SUPPLY_STATUS_CHARGING}, - {FSM_STATE_CHG_FAIL_9, POWER_SUPPLY_STATUS_DISCHARGING}, - {FSM_STATE_EOC_10, POWER_SUPPLY_STATUS_FULL}, - {FSM_STATE_ON_CHG_VREGOK_11, POWER_SUPPLY_STATUS_NOT_CHARGING}, - {FSM_STATE_ATC_PAUSE_13, POWER_SUPPLY_STATUS_NOT_CHARGING}, - {FSM_STATE_FAST_CHG_PAUSE_14, POWER_SUPPLY_STATUS_NOT_CHARGING}, - {FSM_STATE_TRKL_CHG_PAUSE_15, POWER_SUPPLY_STATUS_NOT_CHARGING}, - {FSM_STATE_START_BOOT, POWER_SUPPLY_STATUS_NOT_CHARGING}, - {FSM_STATE_FLCB_VREGOK, POWER_SUPPLY_STATUS_NOT_CHARGING}, - {FSM_STATE_FLCB, POWER_SUPPLY_STATUS_NOT_CHARGING}, -}; - -enum chg_regulation_loop { - VDD_LOOP = BIT(3), - BAT_CURRENT_LOOP = BIT(2), - INPUT_CURRENT_LOOP = BIT(1), - INPUT_VOLTAGE_LOOP = BIT(0), - CHG_ALL_LOOPS = VDD_LOOP | BAT_CURRENT_LOOP - | INPUT_CURRENT_LOOP | INPUT_VOLTAGE_LOOP, -}; - -enum pmic_chg_interrupts { - USBIN_VALID_IRQ = 0, - USBIN_OV_IRQ, - BATT_INSERTED_IRQ, - VBATDET_LOW_IRQ, - USBIN_UV_IRQ, - VBAT_OV_IRQ, - CHGWDOG_IRQ, - VCP_IRQ, - ATCDONE_IRQ, - ATCFAIL_IRQ, - CHGDONE_IRQ, - CHGFAIL_IRQ, - CHGSTATE_IRQ, - LOOP_CHANGE_IRQ, - FASTCHG_IRQ, - TRKLCHG_IRQ, - BATT_REMOVED_IRQ, - BATTTEMP_HOT_IRQ, - CHGHOT_IRQ, - BATTTEMP_COLD_IRQ, - CHG_GONE_IRQ, - BAT_TEMP_OK_IRQ, - COARSE_DET_LOW_IRQ, - VDD_LOOP_IRQ, - VREG_OV_IRQ, - VBATDET_IRQ, - BATFET_IRQ, - PSI_IRQ, - DCIN_VALID_IRQ, - DCIN_OV_IRQ, - DCIN_UV_IRQ, - PM_CHG_MAX_INTS, -}; - -struct bms_notify { - int is_battery_full; - int is_charging; - struct work_struct work; -}; - -/** - * struct pm8921_chg_chip -device information - * @dev: device pointer to access the parent - * @usb_present: present status of usb - * @dc_present: present status of dc - * @usb_charger_current: usb current to charge the battery with used when - * the usb path is enabled or charging is resumed - * @update_time: how frequently the userland needs to be updated - * @max_voltage_mv: the max volts the batt should be charged up to - * @min_voltage_mv: the min battery voltage before turning the FETon - * @uvd_voltage_mv: (PM8917 only) the falling UVD threshold voltage - * @alarm_low_mv: the battery alarm voltage low - * @alarm_high_mv: the battery alarm voltage high - * @cool_temp_dc: the cool temp threshold in deciCelcius - * @warm_temp_dc: the warm temp threshold in deciCelcius - * @hysteresis_temp_dc: the hysteresis between temp thresholds in - * deciCelcius - * @resume_voltage_delta: the voltage delta from vdd max at which the - * battery should resume charging - * @term_current: The charging based term current - * - */ -struct pm8921_chg_chip { - struct device *dev; - unsigned int usb_present; - unsigned int dc_present; - unsigned int usb_charger_current; - unsigned int max_bat_chg_current; - unsigned int pmic_chg_irq[PM_CHG_MAX_INTS]; - unsigned int ttrkl_time; - unsigned int update_time; - unsigned int max_voltage_mv; - unsigned int min_voltage_mv; - unsigned int uvd_voltage_mv; - unsigned int safe_current_ma; - unsigned int alarm_low_mv; - unsigned int alarm_high_mv; - int cool_temp_dc; - int warm_temp_dc; - int hysteresis_temp_dc; - unsigned int temp_check_period; - unsigned int cool_bat_chg_current; - unsigned int warm_bat_chg_current; - unsigned int cool_bat_voltage; - unsigned int warm_bat_voltage; - unsigned int is_bat_cool; - unsigned int is_bat_warm; - unsigned int resume_voltage_delta; - int resume_charge_percent; - unsigned int term_current; - unsigned int vbat_channel; - unsigned int batt_temp_channel; - unsigned int batt_id_channel; - struct power_supply usb_psy; - struct power_supply dc_psy; - struct power_supply *ext_psy; - struct power_supply batt_psy; - struct dentry *dent; - struct bms_notify bms_notify; - int *usb_trim_table; - bool ext_charging; - bool ext_charge_done; - bool iusb_fine_res; - DECLARE_BITMAP(enabled_irqs, PM_CHG_MAX_INTS); - struct work_struct battery_id_valid_work; - int64_t batt_id_min; - int64_t batt_id_max; - int trkl_voltage; - int weak_voltage; - int trkl_current; - int weak_current; - int vin_min; - unsigned int *thermal_mitigation; - int thermal_levels; - struct delayed_work update_heartbeat_work; - struct delayed_work eoc_work; - struct delayed_work unplug_check_work; - struct delayed_work vin_collapse_check_work; - struct delayed_work btc_override_work; - struct wake_lock eoc_wake_lock; - enum pm8921_chg_cold_thr cold_thr; - enum pm8921_chg_hot_thr hot_thr; - int rconn_mohm; - enum pm8921_chg_led_src_config led_src_config; - bool host_mode; - bool has_dc_supply; - u8 active_path; - int recent_reported_soc; - int battery_less_hardware; - int ibatmax_max_adj_ma; - int btc_override; - int btc_override_cold_decidegc; - int btc_override_hot_decidegc; - int btc_delay_ms; - bool btc_panic_if_cant_stop_chg; - int stop_chg_upon_expiry; - bool disable_aicl; - int usb_type; - bool disable_chg_rmvl_wrkarnd; - bool enable_tcxo_warmup_delay; - struct msm_xo_voter *voter; -}; - -/* user space parameter to limit usb current */ -static unsigned int usb_max_current; -/* - * usb_target_ma is used for wall charger - * adaptive input current limiting only. Use - * pm_iusbmax_get() to get current maximum usb current setting. - */ -static int usb_target_ma; -static int charging_disabled; -static int thermal_mitigation; - -static struct pm8921_chg_chip *the_chip; -static void check_temp_thresholds(struct pm8921_chg_chip *chip); - -#define LPM_ENABLE_BIT BIT(2) -static int pm8921_chg_set_lpm(struct pm8921_chg_chip *chip, int enable) -{ - int rc; - u8 reg; - - rc = pm8xxx_readb(chip->dev->parent, CHG_CNTRL, ®); - if (rc) { - pr_err("pm8xxx_readb failed: addr=%03X, rc=%d\n", - CHG_CNTRL, rc); - return rc; - } - reg &= ~LPM_ENABLE_BIT; - reg |= (enable ? LPM_ENABLE_BIT : 0); - - rc = pm8xxx_writeb(chip->dev->parent, CHG_CNTRL, reg); - if (rc) { - pr_err("pm_chg_write failed: addr=%03X, rc=%d\n", - CHG_CNTRL, rc); - return rc; - } - - return rc; -} - -static int pm_chg_write(struct pm8921_chg_chip *chip, u16 addr, u8 reg) -{ - int rc; - - rc = pm8xxx_writeb(chip->dev->parent, addr, reg); - if (rc) - pr_err("failed: addr=%03X, rc=%d\n", addr, rc); - - return rc; -} - -static int pm_chg_masked_write(struct pm8921_chg_chip *chip, u16 addr, - u8 mask, u8 val) -{ - int rc; - u8 reg; - - rc = pm8xxx_readb(chip->dev->parent, addr, ®); - if (rc) { - pr_err("pm8xxx_readb failed: addr=%03X, rc=%d\n", addr, rc); - return rc; - } - reg &= ~mask; - reg |= val & mask; - rc = pm_chg_write(chip, addr, reg); - if (rc) { - pr_err("pm_chg_write failed: addr=%03X, rc=%d\n", addr, rc); - return rc; - } - return 0; -} - -static int pm_chg_get_rt_status(struct pm8921_chg_chip *chip, int irq_id) -{ - return pm8xxx_read_irq_stat(chip->dev->parent, - chip->pmic_chg_irq[irq_id]); -} - -/* Treat OverVoltage/UnderVoltage as source missing */ -static int is_usb_chg_plugged_in(struct pm8921_chg_chip *chip) -{ - return pm_chg_get_rt_status(chip, USBIN_VALID_IRQ); -} - -/* Treat OverVoltage/UnderVoltage as source missing */ -static int is_dc_chg_plugged_in(struct pm8921_chg_chip *chip) -{ - return pm_chg_get_rt_status(chip, DCIN_VALID_IRQ); -} - -static int is_batfet_closed(struct pm8921_chg_chip *chip) -{ - return pm_chg_get_rt_status(chip, BATFET_IRQ); -} -#define CAPTURE_FSM_STATE_CMD 0xC2 -#define READ_BANK_7 0x70 -#define READ_BANK_4 0x40 -static int pm_chg_get_fsm_state(struct pm8921_chg_chip *chip) -{ - u8 temp; - int err = 0, ret = 0; - - temp = CAPTURE_FSM_STATE_CMD; - err = pm8xxx_writeb(chip->dev->parent, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - goto err_out; - } - - temp = READ_BANK_7; - err = pm8xxx_writeb(chip->dev->parent, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - goto err_out; - } - - err = pm8xxx_readb(chip->dev->parent, CHG_TEST, &temp); - if (err) { - pr_err("pm8xxx_readb fail: addr=%03X, rc=%d\n", CHG_TEST, err); - goto err_out; - } - /* get the lower 4 bits */ - ret = temp & 0xF; - - temp = READ_BANK_4; - err = pm8xxx_writeb(chip->dev->parent, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - goto err_out; - } - - err = pm8xxx_readb(chip->dev->parent, CHG_TEST, &temp); - if (err) { - pr_err("pm8xxx_readb fail: addr=%03X, rc=%d\n", CHG_TEST, err); - goto err_out; - } - /* get the upper 1 bit */ - ret |= (temp & 0x1) << 4; - -err_out: - if (err) - return err; - - return ret; -} - -#define READ_BANK_6 0x60 -static int pm_chg_get_regulation_loop(struct pm8921_chg_chip *chip) -{ - u8 temp, data; - int err = 0; - - temp = READ_BANK_6; - err = pm8xxx_writeb(chip->dev->parent, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - goto err_out; - } - - err = pm8xxx_readb(chip->dev->parent, CHG_TEST, &data); - if (err) { - pr_err("pm8xxx_readb fail: addr=%03X, rc=%d\n", CHG_TEST, err); - goto err_out; - } - -err_out: - if (err) - return err; - - /* return the lower 4 bits */ - return data & CHG_ALL_LOOPS; -} - -#define CHG_USB_SUSPEND_BIT BIT(2) -static int pm_chg_usb_suspend_enable(struct pm8921_chg_chip *chip, int enable) -{ - return pm_chg_masked_write(chip, CHG_CNTRL_3, CHG_USB_SUSPEND_BIT, - enable ? CHG_USB_SUSPEND_BIT : 0); -} - -#define CHG_EN_BIT BIT(7) -static int pm_chg_auto_enable(struct pm8921_chg_chip *chip, int enable) -{ - return pm_chg_masked_write(chip, CHG_CNTRL_3, CHG_EN_BIT, - enable ? CHG_EN_BIT : 0); -} - -#define CHG_FAILED_CLEAR BIT(0) -#define ATC_FAILED_CLEAR BIT(1) -static int pm_chg_failed_clear(struct pm8921_chg_chip *chip, int clear) -{ - int rc; - - rc = pm_chg_masked_write(chip, CHG_CNTRL_3, ATC_FAILED_CLEAR, - clear ? ATC_FAILED_CLEAR : 0); - rc |= pm_chg_masked_write(chip, CHG_CNTRL_3, CHG_FAILED_CLEAR, - clear ? CHG_FAILED_CLEAR : 0); - return rc; -} - -#define CHG_CHARGE_DIS_BIT BIT(1) -static int pm_chg_charge_dis(struct pm8921_chg_chip *chip, int disable) -{ - return pm_chg_masked_write(chip, CHG_CNTRL, CHG_CHARGE_DIS_BIT, - disable ? CHG_CHARGE_DIS_BIT : 0); -} - -static int pm_is_chg_charge_dis(struct pm8921_chg_chip *chip) -{ - u8 temp; - - pm8xxx_readb(chip->dev->parent, CHG_CNTRL, &temp); - return temp & CHG_CHARGE_DIS_BIT; -} -#define PM8921_CHG_V_MIN_MV 3240 -#define PM8921_CHG_V_STEP_MV 20 -#define PM8921_CHG_V_STEP_10MV_OFFSET_BIT BIT(7) -#define PM8921_CHG_VDDMAX_MAX 4500 -#define PM8921_CHG_VDDMAX_MIN 3400 -#define PM8921_CHG_V_MASK 0x7F -static int __pm_chg_vddmax_set(struct pm8921_chg_chip *chip, int voltage) -{ - int remainder; - u8 temp = 0; - - if (voltage < PM8921_CHG_VDDMAX_MIN - || voltage > PM8921_CHG_VDDMAX_MAX) { - pr_err("bad mV=%d asked to set\n", voltage); - return -EINVAL; - } - - temp = (voltage - PM8921_CHG_V_MIN_MV) / PM8921_CHG_V_STEP_MV; - - remainder = voltage % 20; - if (remainder >= 10) { - temp |= PM8921_CHG_V_STEP_10MV_OFFSET_BIT; - } - - pr_debug("voltage=%d setting %02x\n", voltage, temp); - return pm_chg_write(chip, CHG_VDD_MAX, temp); -} - -static int pm_chg_vddmax_get(struct pm8921_chg_chip *chip, int *voltage) -{ - u8 temp; - int rc; - - rc = pm8xxx_readb(chip->dev->parent, CHG_VDD_MAX, &temp); - if (rc) { - pr_err("rc = %d while reading vdd max\n", rc); - *voltage = 0; - return rc; - } - *voltage = (int)(temp & PM8921_CHG_V_MASK) * PM8921_CHG_V_STEP_MV - + PM8921_CHG_V_MIN_MV; - if (temp & PM8921_CHG_V_STEP_10MV_OFFSET_BIT) - *voltage = *voltage + 10; - return 0; -} - -static int pm_chg_vddmax_set(struct pm8921_chg_chip *chip, int voltage) -{ - int current_mv, ret, steps, i; - bool increase; - - ret = 0; - - if (voltage < PM8921_CHG_VDDMAX_MIN - || voltage > PM8921_CHG_VDDMAX_MAX) { - pr_err("bad mV=%d asked to set\n", voltage); - return -EINVAL; - } - - ret = pm_chg_vddmax_get(chip, ¤t_mv); - if (ret) { - pr_err("Failed to read vddmax rc=%d\n", ret); - return -EINVAL; - } - if (current_mv == voltage) - return 0; - - /* Only change in increments when USB is present */ - if (is_usb_chg_plugged_in(chip)) { - if (current_mv < voltage) { - steps = (voltage - current_mv) / PM8921_CHG_V_STEP_MV; - increase = true; - } else { - steps = (current_mv - voltage) / PM8921_CHG_V_STEP_MV; - increase = false; - } - for (i = 0; i < steps; i++) { - if (increase) - current_mv += PM8921_CHG_V_STEP_MV; - else - current_mv -= PM8921_CHG_V_STEP_MV; - ret |= __pm_chg_vddmax_set(chip, current_mv); - } - } - ret |= __pm_chg_vddmax_set(chip, voltage); - return ret; -} - -#define PM8921_CHG_VDDSAFE_MIN 3400 -#define PM8921_CHG_VDDSAFE_MAX 4500 -static int pm_chg_vddsafe_set(struct pm8921_chg_chip *chip, int voltage) -{ - u8 temp; - - if (voltage < PM8921_CHG_VDDSAFE_MIN - || voltage > PM8921_CHG_VDDSAFE_MAX) { - pr_err("bad mV=%d asked to set\n", voltage); - return -EINVAL; - } - temp = (voltage - PM8921_CHG_V_MIN_MV) / PM8921_CHG_V_STEP_MV; - pr_debug("voltage=%d setting %02x\n", voltage, temp); - return pm_chg_masked_write(chip, CHG_VDD_SAFE, PM8921_CHG_V_MASK, temp); -} - -#define PM8921_CHG_VBATDET_MIN 3240 -#define PM8921_CHG_VBATDET_MAX 5780 -static int pm_chg_vbatdet_set(struct pm8921_chg_chip *chip, int voltage) -{ - u8 temp; - - if (voltage < PM8921_CHG_VBATDET_MIN - || voltage > PM8921_CHG_VBATDET_MAX) { - pr_err("bad mV=%d asked to set\n", voltage); - return -EINVAL; - } - temp = (voltage - PM8921_CHG_V_MIN_MV) / PM8921_CHG_V_STEP_MV; - pr_debug("voltage=%d setting %02x\n", voltage, temp); - return pm_chg_masked_write(chip, CHG_VBAT_DET, PM8921_CHG_V_MASK, temp); -} - -#define PM8921_CHG_VINMIN_MIN_MV 3800 -#define PM8921_CHG_VINMIN_STEP_MV 100 -#define PM8921_CHG_VINMIN_USABLE_MAX 6500 -#define PM8921_CHG_VINMIN_USABLE_MIN 4300 -#define PM8921_CHG_VINMIN_MASK 0x1F -static int pm_chg_vinmin_set(struct pm8921_chg_chip *chip, int voltage) -{ - u8 temp; - - if (voltage < PM8921_CHG_VINMIN_USABLE_MIN - || voltage > PM8921_CHG_VINMIN_USABLE_MAX) { - pr_err("bad mV=%d asked to set\n", voltage); - return -EINVAL; - } - temp = (voltage - PM8921_CHG_VINMIN_MIN_MV) / PM8921_CHG_VINMIN_STEP_MV; - pr_debug("voltage=%d setting %02x\n", voltage, temp); - return pm_chg_masked_write(chip, CHG_VIN_MIN, PM8921_CHG_VINMIN_MASK, - temp); -} - -static int pm_chg_vinmin_get(struct pm8921_chg_chip *chip) -{ - u8 temp; - int rc, voltage_mv; - - rc = pm8xxx_readb(chip->dev->parent, CHG_VIN_MIN, &temp); - temp &= PM8921_CHG_VINMIN_MASK; - - voltage_mv = PM8921_CHG_VINMIN_MIN_MV + - (int)temp * PM8921_CHG_VINMIN_STEP_MV; - - return voltage_mv; -} - -#define PM8917_USB_UVD_MIN_MV 3850 -#define PM8917_USB_UVD_MAX_MV 4350 -#define PM8917_USB_UVD_STEP_MV 100 -#define PM8917_USB_UVD_MASK 0x7 -static int pm_chg_uvd_threshold_set(struct pm8921_chg_chip *chip, int thresh_mv) -{ - u8 temp; - - if (thresh_mv < PM8917_USB_UVD_MIN_MV - || thresh_mv > PM8917_USB_UVD_MAX_MV) { - pr_err("bad mV=%d asked to set\n", thresh_mv); - return -EINVAL; - } - temp = (thresh_mv - PM8917_USB_UVD_MIN_MV) / PM8917_USB_UVD_STEP_MV; - return pm_chg_masked_write(chip, OVP_USB_UVD, - PM8917_USB_UVD_MASK, temp); -} - -#define PM8921_CHG_IBATMAX_MIN 325 -#define PM8921_CHG_IBATMAX_MAX 3025 -#define PM8921_CHG_I_MIN_MA 225 -#define PM8921_CHG_I_STEP_MA 50 -#define PM8921_CHG_I_MASK 0x3F -static int pm_chg_ibatmax_get(struct pm8921_chg_chip *chip, int *ibat_ma) -{ - u8 temp; - int rc; - - rc = pm8xxx_readb(chip->dev->parent, CHG_IBAT_MAX, &temp); - if (rc) { - pr_err("rc = %d while reading ibat max\n", rc); - *ibat_ma = 0; - return rc; - } - *ibat_ma = (int)(temp & PM8921_CHG_I_MASK) * PM8921_CHG_I_STEP_MA - + PM8921_CHG_I_MIN_MA; - return 0; -} - -static int pm_chg_ibatmax_set(struct pm8921_chg_chip *chip, int chg_current) -{ - u8 temp; - - if (chg_current < PM8921_CHG_IBATMAX_MIN - || chg_current > PM8921_CHG_IBATMAX_MAX) { - pr_err("bad mA=%d asked to set\n", chg_current); - return -EINVAL; - } - temp = (chg_current - PM8921_CHG_I_MIN_MA) / PM8921_CHG_I_STEP_MA; - return pm_chg_masked_write(chip, CHG_IBAT_MAX, PM8921_CHG_I_MASK, temp); -} - -#define PM8921_CHG_IBATSAFE_MIN 225 -#define PM8921_CHG_IBATSAFE_MAX 3375 -static int pm_chg_ibatsafe_set(struct pm8921_chg_chip *chip, int chg_current) -{ - u8 temp; - - if (chg_current < PM8921_CHG_IBATSAFE_MIN - || chg_current > PM8921_CHG_IBATSAFE_MAX) { - pr_err("bad mA=%d asked to set\n", chg_current); - return -EINVAL; - } - temp = (chg_current - PM8921_CHG_I_MIN_MA) / PM8921_CHG_I_STEP_MA; - return pm_chg_masked_write(chip, CHG_IBAT_SAFE, - PM8921_CHG_I_MASK, temp); -} - -#define PM8921_CHG_ITERM_MIN_MA 50 -#define PM8921_CHG_ITERM_MAX_MA 200 -#define PM8921_CHG_ITERM_STEP_MA 10 -#define PM8921_CHG_ITERM_MASK 0xF -static int pm_chg_iterm_set(struct pm8921_chg_chip *chip, int chg_current) -{ - u8 temp; - - if (chg_current < PM8921_CHG_ITERM_MIN_MA - || chg_current > PM8921_CHG_ITERM_MAX_MA) { - pr_err("bad mA=%d asked to set\n", chg_current); - return -EINVAL; - } - - temp = (chg_current - PM8921_CHG_ITERM_MIN_MA) - / PM8921_CHG_ITERM_STEP_MA; - return pm_chg_masked_write(chip, CHG_ITERM, PM8921_CHG_ITERM_MASK, - temp); -} - -static int pm_chg_iterm_get(struct pm8921_chg_chip *chip, int *chg_current) -{ - u8 temp; - int rc; - - rc = pm8xxx_readb(chip->dev->parent, CHG_ITERM, &temp); - if (rc) { - pr_err("err=%d reading CHG_ITEM\n", rc); - *chg_current = 0; - return rc; - } - temp &= PM8921_CHG_ITERM_MASK; - *chg_current = (int)temp * PM8921_CHG_ITERM_STEP_MA - + PM8921_CHG_ITERM_MIN_MA; - return 0; -} - -struct usb_ma_limit_entry { - int usb_ma; - u8 value; -}; - -/* USB Trim tables */ -static int usb_trim_pm8921_table_1[USB_TRIM_ENTRIES] = { - 0x0, - 0x0, - -0x5, - 0x0, - -0x7, - 0x0, - -0x9, - -0xA, - 0x0, - 0x0, - -0xE, - 0x0, - -0xF, - 0x0, - -0x10, - 0x0 -}; - -static int usb_trim_pm8921_table_2[USB_TRIM_ENTRIES] = { - 0x0, - 0x0, - -0x2, - 0x0, - -0x4, - 0x0, - -0x4, - -0x5, - 0x0, - 0x0, - -0x6, - 0x0, - -0x6, - 0x0, - -0x6, - 0x0 -}; - -static int usb_trim_8038_table[USB_TRIM_ENTRIES] = { - 0x0, - 0x0, - -0x9, - 0x0, - -0xD, - 0x0, - -0x10, - -0x11, - 0x0, - 0x0, - -0x25, - 0x0, - -0x28, - 0x0, - -0x32, - 0x0 -}; - -static int usb_trim_8917_table[USB_TRIM_ENTRIES] = { - 0x0, - 0x0, - 0xA, - 0xC, - 0x10, - 0x10, - 0x13, - 0x14, - 0x13, - 0x3, - 0x1A, - 0x1D, - 0x1D, - 0x21, - 0x24, - 0x26 -}; - -/* Maximum USB setting table */ -static struct usb_ma_limit_entry usb_ma_table[] = { - {100, 0x0}, - {200, 0x1}, - {500, 0x2}, - {600, 0x3}, - {700, 0x4}, - {800, 0x5}, - {850, 0x6}, - {900, 0x8}, - {950, 0x7}, - {1000, 0x9}, - {1100, 0xA}, - {1200, 0xB}, - {1300, 0xC}, - {1400, 0xD}, - {1500, 0xE}, - {1600, 0xF}, -}; - -#define REG_SBI_CONFIG 0x04F -#define PAGE3_ENABLE_MASK 0x6 -#define USB_OVP_TRIM_MASK 0x3F -#define USB_OVP_TRIM_PM8917_MASK 0x7F -#define USB_OVP_TRIM_MIN 0x00 -#define REG_USB_OVP_TRIM_ORIG_LSB 0x10A -#define REG_USB_OVP_TRIM_ORIG_MSB 0x09C -#define REG_USB_OVP_TRIM_PM8917 0x2B5 -#define REG_USB_OVP_TRIM_PM8917_BIT BIT(0) -#define USB_TRIM_MAX_DATA_PM8917 0x3F -#define USB_TRIM_POLARITY_PM8917_BIT BIT(6) -static int pm_chg_usb_trim(struct pm8921_chg_chip *chip, int index) -{ - u8 temp, sbi_config, msb, lsb, mask; - s8 trim; - int rc = 0; - static u8 usb_trim_reg_orig = 0xFF; - - /* No trim data for PM8921 */ - if (!chip->usb_trim_table) - return 0; - - if (usb_trim_reg_orig == 0xFF) { - rc = pm8xxx_readb(chip->dev->parent, - REG_USB_OVP_TRIM_ORIG_MSB, &msb); - if (rc) { - pr_err("error = %d reading sbi config reg\n", rc); - return rc; - } - - rc = pm8xxx_readb(chip->dev->parent, - REG_USB_OVP_TRIM_ORIG_LSB, &lsb); - if (rc) { - pr_err("error = %d reading sbi config reg\n", rc); - return rc; - } - - msb = msb >> 5; - lsb = lsb >> 5; - usb_trim_reg_orig = msb << 3 | lsb; - - if (pm8xxx_get_version(chip->dev->parent) - == PM8XXX_VERSION_8917) { - rc = pm8xxx_readb(chip->dev->parent, - REG_USB_OVP_TRIM_PM8917, &msb); - if (rc) { - pr_err("error = %d reading config reg\n", rc); - return rc; - } - - msb = msb & REG_USB_OVP_TRIM_PM8917_BIT; - usb_trim_reg_orig |= msb << 6; - } - } - - /* use the original trim value */ - trim = usb_trim_reg_orig; - - trim += chip->usb_trim_table[index]; - if (trim < 0) - trim = 0; - - pr_debug("trim_orig %d write 0x%x index=%d value 0x%x to USB_OVP_TRIM\n", - usb_trim_reg_orig, trim, index, chip->usb_trim_table[index]); - - rc = pm8xxx_readb(chip->dev->parent, REG_SBI_CONFIG, &sbi_config); - if (rc) { - pr_err("error = %d reading sbi config reg\n", rc); - return rc; - } - - temp = sbi_config | PAGE3_ENABLE_MASK; - rc = pm_chg_write(chip, REG_SBI_CONFIG, temp); - if (rc) { - pr_err("error = %d writing sbi config reg\n", rc); - return rc; - } - - mask = USB_OVP_TRIM_MASK; - - if (pm8xxx_get_version(chip->dev->parent) == PM8XXX_VERSION_8917) - mask = USB_OVP_TRIM_PM8917_MASK; - - rc = pm_chg_masked_write(chip, USB_OVP_TRIM, mask, trim); - if (rc) { - pr_err("error = %d writing USB_OVP_TRIM\n", rc); - return rc; - } - - rc = pm_chg_write(chip, REG_SBI_CONFIG, sbi_config); - if (rc) { - pr_err("error = %d writing sbi config reg\n", rc); - return rc; - } - return rc; -} - -#define PM8921_CHG_IUSB_MASK 0x1C -#define PM8921_CHG_IUSB_SHIFT 2 -#define PM8921_CHG_IUSB_MAX 7 -#define PM8921_CHG_IUSB_MIN 0 -#define PM8917_IUSB_FINE_RES BIT(0) -static int pm_chg_iusbmax_set(struct pm8921_chg_chip *chip, int index) -{ - u8 temp, fineres, reg_val; - int rc; - - reg_val = usb_ma_table[index].value >> 1; - fineres = PM8917_IUSB_FINE_RES & usb_ma_table[index].value; - - if (reg_val < PM8921_CHG_IUSB_MIN || reg_val > PM8921_CHG_IUSB_MAX) { - pr_err("bad mA=%d asked to set\n", reg_val); - return -EINVAL; - } - temp = reg_val << PM8921_CHG_IUSB_SHIFT; - - /* IUSB_FINE_RES */ - if (chip->iusb_fine_res) { - /* Clear IUSB_FINE_RES bit to avoid overshoot */ - rc = pm_chg_masked_write(chip, IUSB_FINE_RES, - PM8917_IUSB_FINE_RES, 0); - - rc |= pm_chg_masked_write(chip, PBL_ACCESS2, - PM8921_CHG_IUSB_MASK, temp); - - if (rc) { - pr_err("Failed to write PBL_ACCESS2 rc=%d\n", rc); - return rc; - } - - if (fineres) { - rc = pm_chg_masked_write(chip, IUSB_FINE_RES, - PM8917_IUSB_FINE_RES, fineres); - if (rc) { - pr_err("Failed to write ISUB_FINE_RES rc=%d\n", - rc); - return rc; - } - } - } else { - rc = pm_chg_masked_write(chip, PBL_ACCESS2, - PM8921_CHG_IUSB_MASK, temp); - if (rc) { - pr_err("Failed to write PBL_ACCESS2 rc=%d\n", rc); - return rc; - } - } - - rc = pm_chg_usb_trim(chip, index); - if (rc) - pr_err("unable to set usb trim rc = %d\n", rc); - - return rc; -} - -static int pm_chg_iusbmax_get(struct pm8921_chg_chip *chip, int *mA) -{ - u8 temp, fineres; - int rc, i; - - fineres = 0; - *mA = 0; - rc = pm8xxx_readb(chip->dev->parent, PBL_ACCESS2, &temp); - if (rc) { - pr_err("err=%d reading PBL_ACCESS2\n", rc); - return rc; - } - - if (chip->iusb_fine_res) { - rc = pm8xxx_readb(chip->dev->parent, IUSB_FINE_RES, &fineres); - if (rc) { - pr_err("err=%d reading IUSB_FINE_RES\n", rc); - return rc; - } - } - temp &= PM8921_CHG_IUSB_MASK; - temp = temp >> PM8921_CHG_IUSB_SHIFT; - - temp = (temp << 1) | (fineres & PM8917_IUSB_FINE_RES); - for (i = ARRAY_SIZE(usb_ma_table) - 1; i >= 0; i--) { - if (usb_ma_table[i].value == temp) - break; - } - - if (i < 0) { - pr_err("can't find %d in usb_ma_table. Use min.\n", temp); - i = 0; - } - - *mA = usb_ma_table[i].usb_ma; - - return rc; -} - -#define PM8921_CHG_WD_MASK 0x1F -static int pm_chg_disable_wd(struct pm8921_chg_chip *chip) -{ - /* writing 0 to the wd timer disables it */ - return pm_chg_masked_write(chip, CHG_TWDOG, PM8921_CHG_WD_MASK, 0); -} - -#define PM8921_CHG_TCHG_MASK 0x7F -#define PM8921_CHG_TCHG_MIN 4 -#define PM8921_CHG_TCHG_MAX 512 -#define PM8921_CHG_TCHG_STEP 4 -static int pm_chg_tchg_max_set(struct pm8921_chg_chip *chip, int minutes) -{ - u8 temp; - - if (minutes < PM8921_CHG_TCHG_MIN || minutes > PM8921_CHG_TCHG_MAX) { - pr_err("bad max minutes =%d asked to set\n", minutes); - return -EINVAL; - } - - temp = (minutes - 1)/PM8921_CHG_TCHG_STEP; - return pm_chg_masked_write(chip, CHG_TCHG_MAX, PM8921_CHG_TCHG_MASK, - temp); -} - -#define PM8921_CHG_TTRKL_MASK 0x3F -#define PM8921_CHG_TTRKL_MIN 1 -#define PM8921_CHG_TTRKL_MAX 64 -static int pm_chg_ttrkl_max_set(struct pm8921_chg_chip *chip, int minutes) -{ - u8 temp; - - if (minutes < PM8921_CHG_TTRKL_MIN || minutes > PM8921_CHG_TTRKL_MAX) { - pr_err("bad max minutes =%d asked to set\n", minutes); - return -EINVAL; - } - - temp = minutes - 1; - return pm_chg_masked_write(chip, CHG_TTRKL_MAX, PM8921_CHG_TTRKL_MASK, - temp); -} - -#define PM8921_CHG_VTRKL_MIN_MV 2050 -#define PM8921_CHG_VTRKL_MAX_MV 2800 -#define PM8921_CHG_VTRKL_STEP_MV 50 -#define PM8921_CHG_VTRKL_SHIFT 4 -#define PM8921_CHG_VTRKL_MASK 0xF0 -static int pm_chg_vtrkl_low_set(struct pm8921_chg_chip *chip, int millivolts) -{ - u8 temp; - - if (millivolts < PM8921_CHG_VTRKL_MIN_MV - || millivolts > PM8921_CHG_VTRKL_MAX_MV) { - pr_err("bad voltage = %dmV asked to set\n", millivolts); - return -EINVAL; - } - - temp = (millivolts - PM8921_CHG_VTRKL_MIN_MV)/PM8921_CHG_VTRKL_STEP_MV; - temp = temp << PM8921_CHG_VTRKL_SHIFT; - return pm_chg_masked_write(chip, CHG_VTRICKLE, PM8921_CHG_VTRKL_MASK, - temp); -} - -#define PM8921_CHG_VWEAK_MIN_MV 2100 -#define PM8921_CHG_VWEAK_MAX_MV 3600 -#define PM8921_CHG_VWEAK_STEP_MV 100 -#define PM8921_CHG_VWEAK_MASK 0x0F -static int pm_chg_vweak_set(struct pm8921_chg_chip *chip, int millivolts) -{ - u8 temp; - - if (millivolts < PM8921_CHG_VWEAK_MIN_MV - || millivolts > PM8921_CHG_VWEAK_MAX_MV) { - pr_err("bad voltage = %dmV asked to set\n", millivolts); - return -EINVAL; - } - - temp = (millivolts - PM8921_CHG_VWEAK_MIN_MV)/PM8921_CHG_VWEAK_STEP_MV; - return pm_chg_masked_write(chip, CHG_VTRICKLE, PM8921_CHG_VWEAK_MASK, - temp); -} - -#define PM8921_CHG_ITRKL_MIN_MA 50 -#define PM8921_CHG_ITRKL_MAX_MA 200 -#define PM8921_CHG_ITRKL_MASK 0x0F -#define PM8921_CHG_ITRKL_STEP_MA 10 -static int pm_chg_itrkl_set(struct pm8921_chg_chip *chip, int milliamps) -{ - u8 temp; - - if (milliamps < PM8921_CHG_ITRKL_MIN_MA - || milliamps > PM8921_CHG_ITRKL_MAX_MA) { - pr_err("bad current = %dmA asked to set\n", milliamps); - return -EINVAL; - } - - temp = (milliamps - PM8921_CHG_ITRKL_MIN_MA)/PM8921_CHG_ITRKL_STEP_MA; - - return pm_chg_masked_write(chip, CHG_ITRICKLE, PM8921_CHG_ITRKL_MASK, - temp); -} - -#define PM8921_CHG_IWEAK_MIN_MA 325 -#define PM8921_CHG_IWEAK_MAX_MA 525 -#define PM8921_CHG_IWEAK_SHIFT 7 -#define PM8921_CHG_IWEAK_MASK 0x80 -static int pm_chg_iweak_set(struct pm8921_chg_chip *chip, int milliamps) -{ - u8 temp; - - if (milliamps < PM8921_CHG_IWEAK_MIN_MA - || milliamps > PM8921_CHG_IWEAK_MAX_MA) { - pr_err("bad current = %dmA asked to set\n", milliamps); - return -EINVAL; - } - - if (milliamps < PM8921_CHG_IWEAK_MAX_MA) - temp = 0; - else - temp = 1; - - temp = temp << PM8921_CHG_IWEAK_SHIFT; - return pm_chg_masked_write(chip, CHG_ITRICKLE, PM8921_CHG_IWEAK_MASK, - temp); -} - -#define PM8921_CHG_BATT_TEMP_THR_COLD BIT(1) -#define PM8921_CHG_BATT_TEMP_THR_COLD_SHIFT 1 -static int pm_chg_batt_cold_temp_config(struct pm8921_chg_chip *chip, - enum pm8921_chg_cold_thr cold_thr) -{ - u8 temp; - - temp = cold_thr << PM8921_CHG_BATT_TEMP_THR_COLD_SHIFT; - temp = temp & PM8921_CHG_BATT_TEMP_THR_COLD; - return pm_chg_masked_write(chip, CHG_CNTRL_2, - PM8921_CHG_BATT_TEMP_THR_COLD, - temp); -} - -#define PM8921_CHG_BATT_TEMP_THR_HOT BIT(0) -#define PM8921_CHG_BATT_TEMP_THR_HOT_SHIFT 0 -static int pm_chg_batt_hot_temp_config(struct pm8921_chg_chip *chip, - enum pm8921_chg_hot_thr hot_thr) -{ - u8 temp; - - temp = hot_thr << PM8921_CHG_BATT_TEMP_THR_HOT_SHIFT; - temp = temp & PM8921_CHG_BATT_TEMP_THR_HOT; - return pm_chg_masked_write(chip, CHG_CNTRL_2, - PM8921_CHG_BATT_TEMP_THR_HOT, - temp); -} - -#define PM8921_CHG_LED_SRC_CONFIG_SHIFT 4 -#define PM8921_CHG_LED_SRC_CONFIG_MASK 0x30 -static int pm_chg_led_src_config(struct pm8921_chg_chip *chip, - enum pm8921_chg_led_src_config led_src_config) -{ - u8 temp; - - if (led_src_config < LED_SRC_GND || - led_src_config > LED_SRC_BYPASS) - return -EINVAL; - - if (led_src_config == LED_SRC_BYPASS) - return 0; - - temp = led_src_config << PM8921_CHG_LED_SRC_CONFIG_SHIFT; - - return pm_chg_masked_write(chip, CHG_CNTRL_3, - PM8921_CHG_LED_SRC_CONFIG_MASK, temp); -} - - -static int64_t read_battery_id(struct pm8921_chg_chip *chip) -{ - int rc; - struct pm8xxx_adc_chan_result result; - - rc = pm8xxx_adc_read(chip->batt_id_channel, &result); - if (rc) { - pr_err("error reading batt id channel = %d, rc = %d\n", - chip->vbat_channel, rc); - return rc; - } - pr_debug("batt_id phy = %lld meas = 0x%llx\n", result.physical, - result.measurement); - return result.physical; -} - -static int is_battery_valid(struct pm8921_chg_chip *chip) -{ - int64_t rc; - - if (chip->batt_id_min == 0 && chip->batt_id_max == 0) - return 1; - - rc = read_battery_id(chip); - if (rc < 0) { - pr_err("error reading batt id channel = %d, rc = %lld\n", - chip->vbat_channel, rc); - /* assume battery id is valid when adc error happens */ - return 1; - } - - if (rc < chip->batt_id_min || rc > chip->batt_id_max) { - pr_err("batt_id phy =%lld is not valid\n", rc); - return 0; - } - return 1; -} - -static void check_battery_valid(struct pm8921_chg_chip *chip) -{ - if (is_battery_valid(chip) == 0) { - pr_err("batt_id not valid, disbling charging\n"); - pm_chg_auto_enable(chip, 0); - } else { - pm_chg_auto_enable(chip, !charging_disabled); - } -} - -static void battery_id_valid(struct work_struct *work) -{ - struct pm8921_chg_chip *chip = container_of(work, - struct pm8921_chg_chip, battery_id_valid_work); - - check_battery_valid(chip); -} - -static void pm8921_chg_enable_irq(struct pm8921_chg_chip *chip, int interrupt) -{ - if (!__test_and_set_bit(interrupt, chip->enabled_irqs)) { - dev_dbg(chip->dev, "%d\n", chip->pmic_chg_irq[interrupt]); - enable_irq(chip->pmic_chg_irq[interrupt]); - } -} - -static void pm8921_chg_disable_irq(struct pm8921_chg_chip *chip, int interrupt) -{ - if (__test_and_clear_bit(interrupt, chip->enabled_irqs)) { - dev_dbg(chip->dev, "%d\n", chip->pmic_chg_irq[interrupt]); - disable_irq_nosync(chip->pmic_chg_irq[interrupt]); - } -} - -static int pm8921_chg_is_enabled(struct pm8921_chg_chip *chip, int interrupt) -{ - return test_bit(interrupt, chip->enabled_irqs); -} - -static bool is_ext_charging(struct pm8921_chg_chip *chip) -{ - union power_supply_propval ret = {0,}; - - if (!chip->ext_psy) - return false; - if (chip->ext_psy->get_property(chip->ext_psy, - POWER_SUPPLY_PROP_CHARGE_TYPE, &ret)) - return false; - if (ret.intval > POWER_SUPPLY_CHARGE_TYPE_NONE) - return ret.intval; - - return false; -} - -static bool is_ext_trickle_charging(struct pm8921_chg_chip *chip) -{ - union power_supply_propval ret = {0,}; - - if (!chip->ext_psy) - return false; - if (chip->ext_psy->get_property(chip->ext_psy, - POWER_SUPPLY_PROP_CHARGE_TYPE, &ret)) - return false; - if (ret.intval == POWER_SUPPLY_CHARGE_TYPE_TRICKLE) - return true; - - return false; -} - -static int is_battery_charging(int fsm_state) -{ - if (is_ext_charging(the_chip)) - return 1; - - switch (fsm_state) { - case FSM_STATE_ATC_2A: - case FSM_STATE_ATC_2B: - case FSM_STATE_ON_CHG_AND_BAT_6: - case FSM_STATE_FAST_CHG_7: - case FSM_STATE_TRKL_CHG_8: - return 1; - } - return 0; -} - -static void bms_notify(struct work_struct *work) -{ - struct bms_notify *n = container_of(work, struct bms_notify, work); - - if (n->is_charging) { - pm8921_bms_charging_began(); - } else { - pm8921_bms_charging_end(n->is_battery_full); - n->is_battery_full = 0; - } -} - -static void bms_notify_check(struct pm8921_chg_chip *chip) -{ - int fsm_state, new_is_charging; - - fsm_state = pm_chg_get_fsm_state(chip); - new_is_charging = is_battery_charging(fsm_state); - - if (chip->bms_notify.is_charging ^ new_is_charging) { - chip->bms_notify.is_charging = new_is_charging; - schedule_work(&(chip->bms_notify.work)); - } -} - -static enum power_supply_property pm_power_props_usb[] = { - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_ONLINE, - POWER_SUPPLY_PROP_CURRENT_MAX, - POWER_SUPPLY_PROP_SCOPE, - POWER_SUPPLY_PROP_HEALTH, -}; - -static enum power_supply_property pm_power_props_mains[] = { - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_ONLINE, -}; - -static char *pm_power_supplied_to[] = { - "battery", -}; - -#define USB_WALL_THRESHOLD_MA 500 -static int pm_power_get_property_mains(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - int type; - - /* Check if called before init */ - if (!the_chip) - return -EINVAL; - - switch (psp) { - case POWER_SUPPLY_PROP_PRESENT: - case POWER_SUPPLY_PROP_ONLINE: - val->intval = 0; - - if (the_chip->has_dc_supply) { - val->intval = 1; - return 0; - } - - if (the_chip->dc_present) { - val->intval = 1; - return 0; - } - - type = the_chip->usb_type; - if (type == POWER_SUPPLY_TYPE_USB_DCP || - type == POWER_SUPPLY_TYPE_USB_ACA || - type == POWER_SUPPLY_TYPE_USB_CDP) - val->intval = is_usb_chg_plugged_in(the_chip); - - break; - default: - return -EINVAL; - } - return 0; -} - -static int disable_aicl(int disable) -{ - if (disable != POWER_SUPPLY_HEALTH_UNKNOWN - && disable != POWER_SUPPLY_HEALTH_GOOD) { - pr_err("called with invalid param :%d\n", disable); - return -EINVAL; - } - - if (!the_chip) { - pr_err("%s called before init\n", __func__); - return -EINVAL; - } - - pr_debug("Disable AICL = %d\n", disable); - the_chip->disable_aicl = disable; - return 0; -} - -static int switch_usb_to_charge_mode(struct pm8921_chg_chip *chip) -{ - int rc; - - if (!chip->host_mode) - return 0; - - /* enable usbin valid comparator and remove force usb ovp fet off */ - rc = pm_chg_write(chip, USB_OVP_TEST, 0xB2); - if (rc < 0) { - pr_err("Failed to write 0xB2 to USB_OVP_TEST rc = %d\n", rc); - return rc; - } - - chip->host_mode = 0; - - return 0; -} - -static int switch_usb_to_host_mode(struct pm8921_chg_chip *chip) -{ - int rc; - - if (chip->host_mode) - return 0; - - /* disable usbin valid comparator and force usb ovp fet off */ - rc = pm_chg_write(chip, USB_OVP_TEST, 0xB3); - if (rc < 0) { - pr_err("Failed to write 0xB3 to USB_OVP_TEST rc = %d\n", rc); - return rc; - } - - chip->host_mode = 1; - - return 0; -} - -static int pm_power_set_property_usb(struct power_supply *psy, - enum power_supply_property psp, - const union power_supply_propval *val) -{ - /* Check if called before init */ - if (!the_chip) - return -EINVAL; - - switch (psp) { - case POWER_SUPPLY_PROP_SCOPE: - if (val->intval == POWER_SUPPLY_SCOPE_SYSTEM) - return switch_usb_to_host_mode(the_chip); - if (val->intval == POWER_SUPPLY_SCOPE_DEVICE) - return switch_usb_to_charge_mode(the_chip); - else - return -EINVAL; - break; - case POWER_SUPPLY_PROP_TYPE: - return pm8921_set_usb_power_supply_type(val->intval); - case POWER_SUPPLY_PROP_HEALTH: - /* UNKNOWN(0) means enable aicl, GOOD(1) means disable aicl */ - return disable_aicl(val->intval); - default: - return -EINVAL; - } - return 0; -} - -static int usb_property_is_writeable(struct power_supply *psy, - enum power_supply_property psp) -{ - switch (psp) { - case POWER_SUPPLY_PROP_HEALTH: - return 1; - default: - break; - } - - return 0; -} - -static int pm_power_get_property_usb(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - int current_max; - - /* Check if called before init */ - if (!the_chip) - return -EINVAL; - - switch (psp) { - case POWER_SUPPLY_PROP_CURRENT_MAX: - if (pm_is_chg_charge_dis(the_chip)) { - val->intval = 0; - } else { - pm_chg_iusbmax_get(the_chip, ¤t_max); - val->intval = current_max; - } - break; - case POWER_SUPPLY_PROP_PRESENT: - case POWER_SUPPLY_PROP_ONLINE: - val->intval = 0; - - if (the_chip->usb_type == POWER_SUPPLY_TYPE_USB) - val->intval = is_usb_chg_plugged_in(the_chip); - - break; - - case POWER_SUPPLY_PROP_SCOPE: - if (the_chip->host_mode) - val->intval = POWER_SUPPLY_SCOPE_SYSTEM; - else - val->intval = POWER_SUPPLY_SCOPE_DEVICE; - break; - case POWER_SUPPLY_PROP_HEALTH: - /* UNKNOWN(0) means enable aicl, GOOD(1) means disable aicl */ - val->intval = the_chip->disable_aicl; - break; - default: - return -EINVAL; - } - return 0; -} - -static enum power_supply_property msm_batt_power_props[] = { - POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_CHARGE_TYPE, - POWER_SUPPLY_PROP_HEALTH, - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_TECHNOLOGY, - POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_NOW, - POWER_SUPPLY_PROP_CAPACITY, - POWER_SUPPLY_PROP_CURRENT_MAX, - POWER_SUPPLY_PROP_CURRENT_NOW, - POWER_SUPPLY_PROP_TEMP, - POWER_SUPPLY_PROP_CHARGE_FULL, - POWER_SUPPLY_PROP_CHARGE_NOW, -}; - -static int get_prop_battery_uvolts(struct pm8921_chg_chip *chip) -{ - int rc; - struct pm8xxx_adc_chan_result result; - - rc = pm8xxx_adc_read(chip->vbat_channel, &result); - if (rc) { - pr_err("error reading adc channel = %d, rc = %d\n", - chip->vbat_channel, rc); - return rc; - } - pr_debug("mvolts phy = %lld meas = 0x%llx\n", result.physical, - result.measurement); - return (int)result.physical; -} - -static int voltage_based_capacity(struct pm8921_chg_chip *chip) -{ - int current_voltage_uv = get_prop_battery_uvolts(chip); - int current_voltage_mv = current_voltage_uv / 1000; - unsigned int low_voltage = chip->min_voltage_mv; - unsigned int high_voltage = chip->max_voltage_mv; - - if (current_voltage_uv < 0) { - pr_err("Error reading current voltage\n"); - return -EIO; - } - - if (current_voltage_mv <= low_voltage) - return 0; - else if (current_voltage_mv >= high_voltage) - return 100; - else - return (current_voltage_mv - low_voltage) * 100 - / (high_voltage - low_voltage); -} - -static int get_prop_batt_present(struct pm8921_chg_chip *chip) -{ - return pm_chg_get_rt_status(chip, BATT_INSERTED_IRQ); -} - -static int get_prop_batt_status(struct pm8921_chg_chip *chip) -{ - int batt_state = POWER_SUPPLY_STATUS_DISCHARGING; - int fsm_state = pm_chg_get_fsm_state(chip); - int i; - - if (chip->ext_psy) { - if (chip->ext_charge_done) - return POWER_SUPPLY_STATUS_FULL; - if (chip->ext_charging) - return POWER_SUPPLY_STATUS_CHARGING; - } - - for (i = 0; i < ARRAY_SIZE(map); i++) - if (map[i].fsm_state == fsm_state) - batt_state = map[i].batt_state; - - if (fsm_state == FSM_STATE_ON_CHG_HIGHI_1) { - if (!pm_chg_get_rt_status(chip, BATT_INSERTED_IRQ) - || !pm_chg_get_rt_status(chip, BAT_TEMP_OK_IRQ) - || pm_chg_get_rt_status(chip, CHGHOT_IRQ) - || pm_chg_get_rt_status(chip, VBATDET_LOW_IRQ)) - - batt_state = POWER_SUPPLY_STATUS_NOT_CHARGING; - } - return batt_state; -} - -static int get_prop_batt_capacity(struct pm8921_chg_chip *chip) -{ - int percent_soc; - - if (chip->battery_less_hardware) - return 100; - - if (!get_prop_batt_present(chip)) - percent_soc = voltage_based_capacity(chip); - else - percent_soc = pm8921_bms_get_percent_charge(); - - if (percent_soc == -ENXIO) - percent_soc = voltage_based_capacity(chip); - - if (percent_soc < 0) { - pr_err("Unable to read battery voltage\n"); - goto fail_voltage; - } - - if (percent_soc <= 10) - pr_warn_ratelimited("low battery charge = %d%%\n", - percent_soc); - - if (percent_soc <= chip->resume_charge_percent - && get_prop_batt_status(chip) == POWER_SUPPLY_STATUS_FULL) { - pr_debug("soc fell below %d. charging enabled.\n", - chip->resume_charge_percent); - if (chip->is_bat_warm) - pr_warn_ratelimited("battery is warm = %d, do not resume charging at %d%%.\n", - chip->is_bat_warm, - chip->resume_charge_percent); - else if (chip->is_bat_cool) - pr_warn_ratelimited("battery is cool = %d, do not resume charging at %d%%.\n", - chip->is_bat_cool, - chip->resume_charge_percent); - else - pm_chg_vbatdet_set(the_chip, PM8921_CHG_VBATDET_MAX); - } - -fail_voltage: - chip->recent_reported_soc = percent_soc; - return percent_soc; -} - -static int get_prop_batt_current_max(struct pm8921_chg_chip *chip, int *curr) -{ - *curr = 0; - *curr = pm8921_bms_get_current_max(); - if (*curr == -EINVAL) - return -EINVAL; - - return 0; -} - -static int get_prop_batt_current(struct pm8921_chg_chip *chip, int *curr) -{ - int rc; - - *curr = 0; - rc = pm8921_bms_get_battery_current(curr); - if (rc == -ENXIO) { - rc = pm8xxx_ccadc_get_battery_current(curr); - } - if (rc) - pr_err("unable to get batt current rc = %d\n", rc); - - return rc; -} - -static int get_prop_batt_fcc(struct pm8921_chg_chip *chip) -{ - int rc; - - rc = pm8921_bms_get_fcc(); - if (rc < 0) - pr_err("unable to get batt fcc rc = %d\n", rc); - return rc; -} - -static int get_prop_batt_charge_now(struct pm8921_chg_chip *chip, int *cc_uah) -{ - int rc; - - *cc_uah = 0; - rc = pm8921_bms_cc_uah(cc_uah); - if (rc) - pr_err("unable to get batt fcc rc = %d\n", rc); - - return rc; -} - -static int get_prop_batt_health(struct pm8921_chg_chip *chip) -{ - int temp; - - temp = pm_chg_get_rt_status(chip, BATTTEMP_HOT_IRQ); - if (temp) - return POWER_SUPPLY_HEALTH_OVERHEAT; - - temp = pm_chg_get_rt_status(chip, BATTTEMP_COLD_IRQ); - if (temp) - return POWER_SUPPLY_HEALTH_COLD; - - return POWER_SUPPLY_HEALTH_GOOD; -} - -static int get_prop_charge_type(struct pm8921_chg_chip *chip) -{ - int temp; - - if (!get_prop_batt_present(chip)) - return POWER_SUPPLY_CHARGE_TYPE_NONE; - - if (is_ext_trickle_charging(chip)) - return POWER_SUPPLY_CHARGE_TYPE_TRICKLE; - - if (is_ext_charging(chip)) - return POWER_SUPPLY_CHARGE_TYPE_FAST; - - temp = pm_chg_get_rt_status(chip, TRKLCHG_IRQ); - if (temp) - return POWER_SUPPLY_CHARGE_TYPE_TRICKLE; - - temp = pm_chg_get_rt_status(chip, FASTCHG_IRQ); - if (temp) - return POWER_SUPPLY_CHARGE_TYPE_FAST; - - return POWER_SUPPLY_CHARGE_TYPE_NONE; -} - -#define MAX_TOLERABLE_BATT_TEMP_DDC 680 -static int get_prop_batt_temp(struct pm8921_chg_chip *chip, int *temp) -{ - int rc; - struct pm8xxx_adc_chan_result result; - - if (chip->battery_less_hardware) { - *temp = 300; - return 0; - } - - rc = pm8xxx_adc_read(chip->batt_temp_channel, &result); - if (rc) { - pr_err("error reading adc channel = %d, rc = %d\n", - chip->vbat_channel, rc); - return rc; - } - pr_debug("batt_temp phy = %lld meas = 0x%llx\n", result.physical, - result.measurement); - if (result.physical > MAX_TOLERABLE_BATT_TEMP_DDC) - pr_err("BATT_TEMP= %d > 68degC, device will be shutdown\n", - (int) result.physical); - - *temp = (int)result.physical; - - return rc; -} - -static int pm_batt_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - int rc = 0; - int value; - struct pm8921_chg_chip *chip = container_of(psy, struct pm8921_chg_chip, - batt_psy); - switch (psp) { - case POWER_SUPPLY_PROP_STATUS: - val->intval = get_prop_batt_status(chip); - break; - case POWER_SUPPLY_PROP_CHARGE_TYPE: - val->intval = get_prop_charge_type(chip); - break; - case POWER_SUPPLY_PROP_HEALTH: - val->intval = get_prop_batt_health(chip); - break; - case POWER_SUPPLY_PROP_PRESENT: - rc = get_prop_batt_present(chip); - if (rc >= 0) { - val->intval = rc; - rc = 0; - } - break; - case POWER_SUPPLY_PROP_TECHNOLOGY: - val->intval = POWER_SUPPLY_TECHNOLOGY_LION; - break; - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: - val->intval = chip->max_voltage_mv * 1000; - break; - case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: - val->intval = chip->min_voltage_mv * 1000; - break; - case POWER_SUPPLY_PROP_VOLTAGE_NOW: - rc = get_prop_battery_uvolts(chip); - if (rc >= 0) { - val->intval = rc; - rc = 0; - } - break; - case POWER_SUPPLY_PROP_CAPACITY: - rc = get_prop_batt_capacity(chip); - if (rc >= 0) { - val->intval = rc; - rc = 0; - } - break; - case POWER_SUPPLY_PROP_CURRENT_NOW: - rc = get_prop_batt_current(chip, &value); - if (!rc) - val->intval = value; - break; - case POWER_SUPPLY_PROP_CURRENT_MAX: - rc = get_prop_batt_current_max(chip, &value); - if (!rc) - val->intval = value; - break; - case POWER_SUPPLY_PROP_TEMP: - rc = get_prop_batt_temp(chip, &value); - if (!rc) - val->intval = value; - break; - case POWER_SUPPLY_PROP_CHARGE_FULL: - rc = get_prop_batt_fcc(chip); - if (rc >= 0) { - val->intval = rc; - rc = 0; - } - break; - case POWER_SUPPLY_PROP_CHARGE_NOW: - rc = get_prop_batt_charge_now(chip, &value); - if (!rc) { - val->intval = value; - rc = 0; - } - break; - default: - rc = -EINVAL; - } - - return rc; -} - -static void (*notify_vbus_state_func_ptr)(int); -static int usb_chg_current; - -int pm8921_charger_register_vbus_sn(void (*callback)(int)) -{ - pr_debug("%p\n", callback); - notify_vbus_state_func_ptr = callback; - return 0; -} -EXPORT_SYMBOL_GPL(pm8921_charger_register_vbus_sn); - -/* this is passed to the hsusb via platform_data msm_otg_pdata */ -void pm8921_charger_unregister_vbus_sn(void (*callback)(int)) -{ - pr_debug("%p\n", callback); - notify_vbus_state_func_ptr = NULL; -} -EXPORT_SYMBOL_GPL(pm8921_charger_unregister_vbus_sn); - -static void notify_usb_of_the_plugin_event(int plugin) -{ - plugin = !!plugin; - if (notify_vbus_state_func_ptr) { - pr_debug("notifying plugin\n"); - (*notify_vbus_state_func_ptr) (plugin); - } else { - pr_debug("unable to notify plugin\n"); - } -} - -static void __pm8921_charger_vbus_draw(unsigned int mA) -{ - int i, rc; - if (!the_chip) { - pr_err("called before init\n"); - return; - } - - if (usb_max_current && mA > usb_max_current) { - pr_debug("restricting usb current to %d instead of %d\n", - usb_max_current, mA); - mA = usb_max_current; - } - - if (mA <= 2) { - usb_chg_current = 0; - rc = pm_chg_iusbmax_set(the_chip, 0); - if (rc) { - pr_err("unable to set iusb to %d rc = %d\n", 0, rc); - } - rc = pm_chg_usb_suspend_enable(the_chip, 1); - if (rc) - pr_err("fail to set suspend bit rc=%d\n", rc); - } else { - rc = pm_chg_usb_suspend_enable(the_chip, 0); - if (rc) - pr_err("fail to reset suspend bit rc=%d\n", rc); - for (i = ARRAY_SIZE(usb_ma_table) - 1; i >= 0; i--) { - if (usb_ma_table[i].usb_ma <= mA) - break; - } - - if (i < 0) { - pr_err("can't find %dmA in usb_ma_table. Use min.\n", - mA); - i = 0; - } - - /* Check if IUSB_FINE_RES is available */ - while ((usb_ma_table[i].value & PM8917_IUSB_FINE_RES) - && !the_chip->iusb_fine_res) - i--; - if (i < 0) - i = 0; - rc = pm_chg_iusbmax_set(the_chip, i); - if (rc) - pr_err("unable to set iusb to %d rc = %d\n", i, rc); - } -} - -/* USB calls these to tell us how much max usb current the system can draw */ -void pm8921_charger_vbus_draw(unsigned int mA) -{ - int set_usb_now_ma; - - pr_debug("Enter charge=%d\n", mA); - - /* - * Reject VBUS requests if USB connection is the only available - * power source. This makes sure that if booting without - * battery the iusb_max value is not decreased avoiding potential - * brown_outs. - * - * This would also apply when the battery has been - * removed from the running system. - */ - if (mA == 0 && the_chip && !get_prop_batt_present(the_chip) - && !is_dc_chg_plugged_in(the_chip)) { - if (!the_chip->has_dc_supply) { - pr_err("rejected: no other power source mA = %d\n", mA); - return; - } - } - - if (usb_max_current && mA > usb_max_current) { - pr_warn("restricting usb current to %d instead of %d\n", - usb_max_current, mA); - mA = usb_max_current; - } - if (usb_target_ma == 0 && mA > USB_WALL_THRESHOLD_MA) - usb_target_ma = mA; - - if (usb_target_ma) - usb_target_ma = mA; - - - if (mA > USB_WALL_THRESHOLD_MA) - set_usb_now_ma = USB_WALL_THRESHOLD_MA; - else - set_usb_now_ma = mA; - - if (the_chip && the_chip->disable_aicl) - set_usb_now_ma = mA; - - if (the_chip) - __pm8921_charger_vbus_draw(set_usb_now_ma); - else - /* - * called before pmic initialized, - * save this value and use it at probe - */ - usb_chg_current = set_usb_now_ma; -} -EXPORT_SYMBOL_GPL(pm8921_charger_vbus_draw); - -int pm8921_is_usb_chg_plugged_in(void) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - return is_usb_chg_plugged_in(the_chip); -} -EXPORT_SYMBOL(pm8921_is_usb_chg_plugged_in); - -int pm8921_is_dc_chg_plugged_in(void) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - return is_dc_chg_plugged_in(the_chip); -} -EXPORT_SYMBOL(pm8921_is_dc_chg_plugged_in); - -int pm8921_is_battery_present(void) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - return get_prop_batt_present(the_chip); -} -EXPORT_SYMBOL(pm8921_is_battery_present); - -int pm8921_is_batfet_closed(void) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - return is_batfet_closed(the_chip); -} -EXPORT_SYMBOL(pm8921_is_batfet_closed); -/* - * Disabling the charge current limit causes current - * current limits to have no monitoring. An adequate charger - * capable of supplying high current while sustaining VIN_MIN - * is required if the limiting is disabled. - */ -int pm8921_disable_input_current_limit(bool disable) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - if (disable) { - pr_warn("Disabling input current limit!\n"); - - return pm_chg_write(the_chip, CHG_BUCK_CTRL_TEST3, 0xF2); - } - return 0; -} -EXPORT_SYMBOL(pm8921_disable_input_current_limit); - -int pm8917_set_under_voltage_detection_threshold(int mv) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - return pm_chg_uvd_threshold_set(the_chip, mv); -} -EXPORT_SYMBOL(pm8917_set_under_voltage_detection_threshold); - -int pm8921_set_max_battery_charge_current(int ma) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - return pm_chg_ibatmax_set(the_chip, ma); -} -EXPORT_SYMBOL(pm8921_set_max_battery_charge_current); - -int pm8921_disable_source_current(bool disable) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - if (disable) - pr_warn("current drawn from chg=0, battery provides current\n"); - - pm_chg_usb_suspend_enable(the_chip, disable); - - return pm_chg_charge_dis(the_chip, disable); -} -EXPORT_SYMBOL(pm8921_disable_source_current); - -int pm8921_regulate_input_voltage(int voltage) -{ - int rc; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - rc = pm_chg_vinmin_set(the_chip, voltage); - - if (rc == 0) - the_chip->vin_min = voltage; - - return rc; -} - -#define USB_OV_THRESHOLD_MASK 0x60 -#define USB_OV_THRESHOLD_SHIFT 5 -int pm8921_usb_ovp_set_threshold(enum pm8921_usb_ov_threshold ov) -{ - u8 temp; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - - if (ov > PM_USB_OV_7V) { - pr_err("limiting to over voltage threshold to 7volts\n"); - ov = PM_USB_OV_7V; - } - - temp = USB_OV_THRESHOLD_MASK & (ov << USB_OV_THRESHOLD_SHIFT); - - return pm_chg_masked_write(the_chip, USB_OVP_CONTROL, - USB_OV_THRESHOLD_MASK, temp); -} -EXPORT_SYMBOL(pm8921_usb_ovp_set_threshold); - -#define USB_DEBOUNCE_TIME_MASK 0x06 -#define USB_DEBOUNCE_TIME_SHIFT 1 -int pm8921_usb_ovp_set_hystersis(enum pm8921_usb_debounce_time ms) -{ - u8 temp; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - - if (ms > PM_USB_DEBOUNCE_80P5MS) { - pr_err("limiting debounce to 80.5ms\n"); - ms = PM_USB_DEBOUNCE_80P5MS; - } - - temp = USB_DEBOUNCE_TIME_MASK & (ms << USB_DEBOUNCE_TIME_SHIFT); - - return pm_chg_masked_write(the_chip, USB_OVP_CONTROL, - USB_DEBOUNCE_TIME_MASK, temp); -} -EXPORT_SYMBOL(pm8921_usb_ovp_set_hystersis); - -#define USB_OVP_DISABLE_MASK 0x80 -int pm8921_usb_ovp_disable(int disable) -{ - u8 temp = 0; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - - if (disable) - temp = USB_OVP_DISABLE_MASK; - - return pm_chg_masked_write(the_chip, USB_OVP_CONTROL, - USB_OVP_DISABLE_MASK, temp); -} - -bool pm8921_is_battery_charging(int *source) -{ - int fsm_state, is_charging, dc_present, usb_present; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - fsm_state = pm_chg_get_fsm_state(the_chip); - is_charging = is_battery_charging(fsm_state); - if (is_charging == 0) { - *source = PM8921_CHG_SRC_NONE; - return is_charging; - } - - if (source == NULL) - return is_charging; - - /* the battery is charging, the source is requested, find it */ - dc_present = is_dc_chg_plugged_in(the_chip); - usb_present = is_usb_chg_plugged_in(the_chip); - - if (dc_present && !usb_present) - *source = PM8921_CHG_SRC_DC; - - if (usb_present && !dc_present) - *source = PM8921_CHG_SRC_USB; - - if (usb_present && dc_present) - /* - * The system always chooses dc for charging since it has - * higher priority. - */ - *source = PM8921_CHG_SRC_DC; - - return is_charging; -} -EXPORT_SYMBOL(pm8921_is_battery_charging); - -int pm8921_set_usb_power_supply_type(enum power_supply_type type) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - - if (type < POWER_SUPPLY_TYPE_USB && type > POWER_SUPPLY_TYPE_BATTERY) - return -EINVAL; - - the_chip->usb_type = type; - power_supply_changed(&the_chip->usb_psy); - power_supply_changed(&the_chip->dc_psy); - return 0; -} -EXPORT_SYMBOL_GPL(pm8921_set_usb_power_supply_type); - -int pm8921_batt_temperature(void) -{ - int temp = 0, rc = 0; - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - rc = get_prop_batt_temp(the_chip, &temp); - if (rc) { - pr_err("Unable to read temperature"); - return rc; - } - return temp; -} - -static void handle_usb_insertion_removal(struct pm8921_chg_chip *chip) -{ - int usb_present; - - pm_chg_failed_clear(chip, 1); - usb_present = is_usb_chg_plugged_in(chip); - if (chip->usb_present ^ usb_present) { - notify_usb_of_the_plugin_event(usb_present); - chip->usb_present = usb_present; - power_supply_changed(&chip->usb_psy); - power_supply_changed(&chip->batt_psy); - pm8921_bms_calibrate_hkadc(); - } - if (usb_present) { - schedule_delayed_work(&chip->unplug_check_work, - msecs_to_jiffies(UNPLUG_CHECK_RAMP_MS)); - pm8921_chg_enable_irq(chip, CHG_GONE_IRQ); - } else { - /* USB unplugged reset target current */ - usb_target_ma = 0; - pm8921_chg_disable_irq(chip, CHG_GONE_IRQ); - } - bms_notify_check(chip); -} - -static void handle_stop_ext_chg(struct pm8921_chg_chip *chip) -{ - if (!chip->ext_psy) { - pr_debug("external charger not registered.\n"); - return; - } - - if (!chip->ext_charging) { - pr_debug("already not charging.\n"); - return; - } - - power_supply_set_charge_type(chip->ext_psy, - POWER_SUPPLY_CHARGE_TYPE_NONE); - pm8921_disable_source_current(false); /* release BATFET */ - power_supply_changed(&chip->dc_psy); - chip->ext_charging = false; - chip->ext_charge_done = false; - bms_notify_check(chip); - /* Update battery charging LEDs and user space battery info */ - power_supply_changed(&chip->batt_psy); -} - -static void handle_start_ext_chg(struct pm8921_chg_chip *chip) -{ - int dc_present; - int batt_present; - int batt_temp_ok; - unsigned long delay = - round_jiffies_relative(msecs_to_jiffies(EOC_CHECK_PERIOD_MS)); - - if (!chip->ext_psy) { - pr_debug("external charger not registered.\n"); - return; - } - - if (chip->ext_charging) { - pr_debug("already charging.\n"); - return; - } - - dc_present = is_dc_chg_plugged_in(chip); - batt_present = pm_chg_get_rt_status(chip, BATT_INSERTED_IRQ); - batt_temp_ok = pm_chg_get_rt_status(chip, BAT_TEMP_OK_IRQ); - - if (!dc_present) { - pr_warn("%s. dc not present.\n", __func__); - return; - } - if (!batt_present) { - pr_warn("%s. battery not present.\n", __func__); - return; - } - if (!batt_temp_ok) { - pr_warn("%s. battery temperature not ok.\n", __func__); - return; - } - - /* Force BATFET=ON */ - pm8921_disable_source_current(true); - - schedule_delayed_work(&chip->unplug_check_work, - msecs_to_jiffies(UNPLUG_CHECK_RAMP_MS)); - - power_supply_set_online(chip->ext_psy, dc_present); - power_supply_set_charge_type(chip->ext_psy, - POWER_SUPPLY_CHARGE_TYPE_FAST); - chip->ext_charging = true; - chip->ext_charge_done = false; - bms_notify_check(chip); - /* - * since we wont get a fastchg irq from external charger - * use eoc worker to detect end of charging - */ - schedule_delayed_work(&chip->eoc_work, delay); - wake_lock(&chip->eoc_wake_lock); - if (chip->btc_override) - schedule_delayed_work(&chip->btc_override_work, - round_jiffies_relative(msecs_to_jiffies - (chip->btc_delay_ms))); - /* Update battery charging LEDs and user space battery info */ - power_supply_changed(&chip->batt_psy); -} - -static void turn_off_ovp_fet(struct pm8921_chg_chip *chip, u16 ovptestreg) -{ - u8 temp; - int rc; - - rc = pm_chg_write(chip, ovptestreg, 0x30); - if (rc) { - pr_err("Failed to write 0x30 to ovptestreg rc = %d\n", rc); - return; - } - rc = pm8xxx_readb(chip->dev->parent, ovptestreg, &temp); - if (rc) { - pr_err("Failed to read from ovptestreg rc = %d\n", rc); - return; - } - /* set ovp fet disable bit and the write bit */ - temp |= 0x81; - rc = pm_chg_write(chip, ovptestreg, temp); - if (rc) { - pr_err("Failed to write 0x%x ovptestreg rc=%d\n", temp, rc); - return; - } -} - -static void turn_on_ovp_fet(struct pm8921_chg_chip *chip, u16 ovptestreg) -{ - u8 temp; - int rc; - - rc = pm_chg_write(chip, ovptestreg, 0x30); - if (rc) { - pr_err("Failed to write 0x30 to OVP_TEST rc = %d\n", rc); - return; - } - rc = pm8xxx_readb(chip->dev->parent, ovptestreg, &temp); - if (rc) { - pr_err("Failed to read from OVP_TEST rc = %d\n", rc); - return; - } - /* unset ovp fet disable bit and set the write bit */ - temp &= 0xFE; - temp |= 0x80; - rc = pm_chg_write(chip, ovptestreg, temp); - if (rc) { - pr_err("Failed to write 0x%x to OVP_TEST rc = %d\n", - temp, rc); - return; - } -} - -static int param_open_ovp_counter = 10; -module_param(param_open_ovp_counter, int, 0644); - -#define USB_ACTIVE_BIT BIT(5) -#define DC_ACTIVE_BIT BIT(6) -static int is_active_chg_plugged_in(struct pm8921_chg_chip *chip, - u8 active_chg_mask) -{ - if (active_chg_mask & USB_ACTIVE_BIT) - return pm_chg_get_rt_status(chip, USBIN_VALID_IRQ); - else if (active_chg_mask & DC_ACTIVE_BIT) - return pm_chg_get_rt_status(chip, DCIN_VALID_IRQ); - else - return 0; -} - -#define WRITE_BANK_4 0xC0 -#define OVP_DEBOUNCE_TIME 0x06 -static void unplug_ovp_fet_open(struct pm8921_chg_chip *chip) -{ - int chg_gone = 0, active_chg_plugged_in = 0; - int count = 0; - u8 active_mask = 0; - u16 ovpreg, ovptestreg; - - if (is_usb_chg_plugged_in(chip) && - (chip->active_path & USB_ACTIVE_BIT)) { - ovpreg = USB_OVP_CONTROL; - ovptestreg = USB_OVP_TEST; - active_mask = USB_ACTIVE_BIT; - } else if (is_dc_chg_plugged_in(chip) && - (chip->active_path & DC_ACTIVE_BIT)) { - ovpreg = DC_OVP_CONTROL; - ovptestreg = DC_OVP_TEST; - active_mask = DC_ACTIVE_BIT; - } else { - return; - } - - while (count++ < param_open_ovp_counter) { - pm_chg_masked_write(chip, ovpreg, OVP_DEBOUNCE_TIME, 0x0); - usleep(10); - active_chg_plugged_in - = is_active_chg_plugged_in(chip, active_mask); - chg_gone = pm_chg_get_rt_status(chip, CHG_GONE_IRQ); - pr_debug("OVP FET count = %d chg_gone=%d, active_valid = %d\n", - count, chg_gone, active_chg_plugged_in); - - /* note usb_chg_plugged_in=0 => chg_gone=1 */ - if (chg_gone == 1 && active_chg_plugged_in == 1) { - pr_debug("since chg_gone = 1 dis ovp_fet for 20msec\n"); - turn_off_ovp_fet(chip, ovptestreg); - - msleep(20); - - turn_on_ovp_fet(chip, ovptestreg); - } else { - break; - } - } - if (pm8xxx_get_version(chip->dev->parent) == PM8XXX_VERSION_8917) - pm_chg_masked_write(chip, ovpreg, OVP_DEBOUNCE_TIME, 0x6); - else - pm_chg_masked_write(chip, ovpreg, OVP_DEBOUNCE_TIME, 0x2); - - pr_debug("Exit count=%d chg_gone=%d, active_valid=%d\n", - count, chg_gone, active_chg_plugged_in); - return; -} - -static int find_usb_ma_value(int value) -{ - int i; - - for (i = ARRAY_SIZE(usb_ma_table) - 1; i >= 0; i--) { - if (value >= usb_ma_table[i].usb_ma) - break; - } - - return i; -} - -static void decrease_usb_ma_value(int *value) -{ - int i; - - if (value) { - i = find_usb_ma_value(*value); - if (i > 0) - i--; - while (!the_chip->iusb_fine_res && i > 0 - && (usb_ma_table[i].value & PM8917_IUSB_FINE_RES)) - i--; - - if (i < 0) { - pr_err("can't find %dmA in usb_ma_table. Use min.\n", - *value); - i = 0; - } - - *value = usb_ma_table[i].usb_ma; - } -} - -static void increase_usb_ma_value(int *value) -{ - int i; - - if (value) { - i = find_usb_ma_value(*value); - - if (i < (ARRAY_SIZE(usb_ma_table) - 1)) - i++; - /* Get next correct entry if IUSB_FINE_RES is not available */ - while (!the_chip->iusb_fine_res - && (usb_ma_table[i].value & PM8917_IUSB_FINE_RES) - && i < (ARRAY_SIZE(usb_ma_table) - 1)) - i++; - - *value = usb_ma_table[i].usb_ma; - } -} - -static void vin_collapse_check_worker(struct work_struct *work) -{ - struct delayed_work *dwork = to_delayed_work(work); - struct pm8921_chg_chip *chip = container_of(dwork, - struct pm8921_chg_chip, vin_collapse_check_work); - - /* - * AICL only for wall-chargers. If the charger appears to be plugged - * back in now, the corresponding unplug must have been because of we - * were trying to draw more current than the charger can support. In - * such a case reset usb current to 500mA and decrease the target. - * The AICL algorithm will step up the current from 500mA to target - */ - if (is_usb_chg_plugged_in(chip) - && usb_target_ma > USB_WALL_THRESHOLD_MA - && !chip->disable_aicl) { - /* decrease usb_target_ma */ - decrease_usb_ma_value(&usb_target_ma); - /* reset here, increase in unplug_check_worker */ - __pm8921_charger_vbus_draw(USB_WALL_THRESHOLD_MA); - pr_debug("usb_now=%d, usb_target = %d\n", - USB_WALL_THRESHOLD_MA, usb_target_ma); - if (!delayed_work_pending(&chip->unplug_check_work)) - schedule_delayed_work(&chip->unplug_check_work, - msecs_to_jiffies - (UNPLUG_CHECK_WAIT_PERIOD_MS)); - } else { - handle_usb_insertion_removal(chip); - } -} - -#define VIN_MIN_COLLAPSE_CHECK_MS 50 -static irqreturn_t usbin_valid_irq_handler(int irq, void *data) -{ - if (usb_target_ma) - schedule_delayed_work(&the_chip->vin_collapse_check_work, - msecs_to_jiffies(VIN_MIN_COLLAPSE_CHECK_MS)); - else - handle_usb_insertion_removal(data); - return IRQ_HANDLED; -} - -static irqreturn_t batt_inserted_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - int status; - - status = pm_chg_get_rt_status(chip, BATT_INSERTED_IRQ); - schedule_work(&chip->battery_id_valid_work); - handle_start_ext_chg(chip); - pr_debug("battery present=%d", status); - power_supply_changed(&chip->batt_psy); - return IRQ_HANDLED; -} - -/* - * this interrupt used to restart charging a battery. - * - * Note: When DC-inserted the VBAT can't go low. - * VPH_PWR is provided by the ext-charger. - * After End-Of-Charging from DC, charging can be resumed only - * if DC is removed and then inserted after the battery was in use. - * Therefore the handle_start_ext_chg() is not called. - */ -static irqreturn_t vbatdet_low_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - int high_transition; - - high_transition = pm_chg_get_rt_status(chip, VBATDET_LOW_IRQ); - - if (high_transition) { - /* enable auto charging */ - pm_chg_auto_enable(chip, !charging_disabled); - pr_info("batt fell below resume voltage %s\n", - charging_disabled ? "" : "charger enabled"); - } - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - power_supply_changed(&chip->dc_psy); - - return IRQ_HANDLED; -} - -static irqreturn_t chgwdog_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t vcp_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t atcdone_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t atcfail_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t chgdone_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - pr_debug("state_changed_to=%d\n", pm_chg_get_fsm_state(data)); - - handle_stop_ext_chg(chip); - - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - power_supply_changed(&chip->dc_psy); - - bms_notify_check(chip); - - return IRQ_HANDLED; -} - -static irqreturn_t chgfail_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - int ret; - - if (!chip->stop_chg_upon_expiry) { - ret = pm_chg_failed_clear(chip, 1); - if (ret) - pr_err("Failed to write CHG_FAILED_CLEAR bit\n"); - } - - pr_err("batt_present = %d, batt_temp_ok = %d, state_changed_to=%d\n", - get_prop_batt_present(chip), - pm_chg_get_rt_status(chip, BAT_TEMP_OK_IRQ), - pm_chg_get_fsm_state(data)); - - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - power_supply_changed(&chip->dc_psy); - return IRQ_HANDLED; -} - -static irqreturn_t chgstate_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - pr_debug("state_changed_to=%d\n", pm_chg_get_fsm_state(data)); - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - power_supply_changed(&chip->dc_psy); - - bms_notify_check(chip); - - return IRQ_HANDLED; -} - -enum { - PON_TIME_25NS = 0x04, - PON_TIME_50NS = 0x08, - PON_TIME_100NS = 0x0C, -}; - -static void set_min_pon_time(struct pm8921_chg_chip *chip, int pon_time_ns) -{ - u8 temp; - int rc; - - rc = pm_chg_write(chip, CHG_BUCK_CTRL_TEST3, 0x40); - if (rc) { - pr_err("Failed to write 0x70 to CTRL_TEST3 rc = %d\n", rc); - return; - } - rc = pm8xxx_readb(chip->dev->parent, CHG_BUCK_CTRL_TEST3, &temp); - if (rc) { - pr_err("Failed to read CTRL_TEST3 rc = %d\n", rc); - return; - } - /* clear the min pon time select bit */ - temp &= 0xF3; - /* set the pon time */ - temp |= (u8)pon_time_ns; - /* write enable bank 4 */ - temp |= 0x80; - rc = pm_chg_write(chip, CHG_BUCK_CTRL_TEST3, temp); - if (rc) { - pr_err("Failed to write 0x%x to CTRL_TEST3 rc=%d\n", temp, rc); - return; - } -} - -static void attempt_reverse_boost_fix(struct pm8921_chg_chip *chip) -{ - pr_debug("Start\n"); - set_min_pon_time(chip, PON_TIME_100NS); - pm_chg_vinmin_set(chip, chip->vin_min + 200); - msleep(250); - pm_chg_vinmin_set(chip, chip->vin_min); - set_min_pon_time(chip, PON_TIME_25NS); - pr_debug("End\n"); -} - -#define VIN_ACTIVE_BIT BIT(0) -#define UNPLUG_WRKARND_RESTORE_WAIT_PERIOD_US 200 -#define VIN_MIN_INCREASE_MV 100 -static void unplug_check_worker(struct work_struct *work) -{ - struct delayed_work *dwork = to_delayed_work(work); - struct pm8921_chg_chip *chip = container_of(dwork, - struct pm8921_chg_chip, unplug_check_work); - u8 reg_loop = 0, active_path; - int rc, ibat, active_chg_plugged_in, usb_ma; - int chg_gone = 0; - bool ramp = false; - - rc = pm8xxx_readb(chip->dev->parent, PBL_ACCESS1, &active_path); - if (rc) { - pr_err("Failed to read PBL_ACCESS1 rc=%d\n", rc); - return; - } - - chip->active_path = active_path; - active_chg_plugged_in = is_active_chg_plugged_in(chip, active_path); - pr_debug("active_path = 0x%x, active_chg_plugged_in = %d\n", - active_path, active_chg_plugged_in); - if (active_path & USB_ACTIVE_BIT) { - pr_debug("USB charger active\n"); - - pm_chg_iusbmax_get(chip, &usb_ma); - - if (usb_ma <= 100) { - pr_debug( - "Unenumerated or suspended usb_ma = %d skip\n", - usb_ma); - goto check_again_later; - } - } else if (active_path & DC_ACTIVE_BIT) { - pr_debug("DC charger active\n"); - } else { - /* No charger active */ - if (!(is_usb_chg_plugged_in(chip) - && !(is_dc_chg_plugged_in(chip)))) { - get_prop_batt_current(chip, &ibat); - pr_debug( - "Stop: chg removed reg_loop = %d, fsm = %d ibat = %d\n", - pm_chg_get_regulation_loop(chip), - pm_chg_get_fsm_state(chip), ibat); - return; - } else { - goto check_again_later; - } - } - - /* AICL only for usb wall charger */ - if ((active_path & USB_ACTIVE_BIT) && usb_target_ma > 0 && - !chip->disable_aicl) { - reg_loop = pm_chg_get_regulation_loop(chip); - pr_debug("reg_loop=0x%x usb_ma = %d\n", reg_loop, usb_ma); - if ((reg_loop & VIN_ACTIVE_BIT) && - (usb_ma > USB_WALL_THRESHOLD_MA) - && !charging_disabled) { - decrease_usb_ma_value(&usb_ma); - usb_target_ma = usb_ma; - /* end AICL here */ - __pm8921_charger_vbus_draw(usb_ma); - pr_debug("usb_now=%d, usb_target = %d\n", - usb_ma, usb_target_ma); - } - } - - reg_loop = pm_chg_get_regulation_loop(chip); - pr_debug("reg_loop=0x%x usb_ma = %d\n", reg_loop, usb_ma); - - rc = get_prop_batt_current(chip, &ibat); - if ((reg_loop & VIN_ACTIVE_BIT) && !chip->disable_chg_rmvl_wrkarnd) { - if (ibat > 0 && !rc) { - pr_debug("revboost ibat = %d fsm = %d loop = 0x%x\n", - ibat, pm_chg_get_fsm_state(chip), reg_loop); - attempt_reverse_boost_fix(chip); - /* after reverse boost fix check if the active - * charger was detected as removed */ - active_chg_plugged_in - = is_active_chg_plugged_in(chip, - active_path); - pr_debug("revboost post: active_chg_plugged_in = %d\n", - active_chg_plugged_in); - } - } - - active_chg_plugged_in = is_active_chg_plugged_in(chip, active_path); - pr_debug("active_path = 0x%x, active_chg = %d\n", - active_path, active_chg_plugged_in); - chg_gone = pm_chg_get_rt_status(chip, CHG_GONE_IRQ); - - if (chg_gone == 1 && active_chg_plugged_in == 1 && - !chip->disable_chg_rmvl_wrkarnd) { - pr_debug("chg_gone=%d, active_chg_plugged_in = %d\n", - chg_gone, active_chg_plugged_in); - unplug_ovp_fet_open(chip); - } - - /* AICL only for usb wall charger */ - if (!(reg_loop & VIN_ACTIVE_BIT) && (active_path & USB_ACTIVE_BIT) - && usb_target_ma > 0 - && !charging_disabled - && !chip->disable_aicl) { - /* only increase iusb_max if vin loop not active */ - if (usb_ma < usb_target_ma) { - increase_usb_ma_value(&usb_ma); - if (usb_ma > usb_target_ma) - usb_ma = usb_target_ma; - __pm8921_charger_vbus_draw(usb_ma); - pr_debug("usb_now=%d, usb_target = %d\n", - usb_ma, usb_target_ma); - ramp = true; - } else { - usb_target_ma = usb_ma; - } - } -check_again_later: - pr_debug("ramp: %d\n", ramp); - /* schedule to check again later */ - if (ramp) - schedule_delayed_work(&chip->unplug_check_work, - msecs_to_jiffies(UNPLUG_CHECK_RAMP_MS)); - else - schedule_delayed_work(&chip->unplug_check_work, - msecs_to_jiffies(UNPLUG_CHECK_WAIT_PERIOD_MS)); -} - -static irqreturn_t loop_change_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - pr_debug("fsm_state=%d reg_loop=0x%x\n", - pm_chg_get_fsm_state(data), - pm_chg_get_regulation_loop(data)); - schedule_work(&chip->unplug_check_work.work); - return IRQ_HANDLED; -} - -struct ibatmax_max_adj_entry { - int ibat_max_ma; - int max_adj_ma; -}; - -static struct ibatmax_max_adj_entry ibatmax_adj_table[] = { - {975, 300}, - {1475, 150}, - {1975, 200}, - {2475, 250}, -}; - -static int find_ibat_max_adj_ma(int ibat_target_ma) -{ - int i = 0; - - for (i = ARRAY_SIZE(ibatmax_adj_table); i > 0; i--) { - if (ibat_target_ma >= ibatmax_adj_table[i - 1].ibat_max_ma) - break; - } - - if (i > 0) - i--; - - return ibatmax_adj_table[i].max_adj_ma; -} - -static irqreturn_t fastchg_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - int high_transition; - - high_transition = pm_chg_get_rt_status(chip, FASTCHG_IRQ); - if (high_transition && !delayed_work_pending(&chip->eoc_work)) { - wake_lock(&chip->eoc_wake_lock); - schedule_delayed_work(&chip->eoc_work, - round_jiffies_relative(msecs_to_jiffies - (EOC_CHECK_PERIOD_MS))); - } - if (high_transition - && chip->btc_override - && !delayed_work_pending(&chip->btc_override_work)) { - schedule_delayed_work(&chip->btc_override_work, - round_jiffies_relative(msecs_to_jiffies - (chip->btc_delay_ms))); - } - power_supply_changed(&chip->batt_psy); - bms_notify_check(chip); - return IRQ_HANDLED; -} - -static irqreturn_t trklchg_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - power_supply_changed(&chip->batt_psy); - return IRQ_HANDLED; -} - -static irqreturn_t batt_removed_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - int status; - - status = pm_chg_get_rt_status(chip, BATT_REMOVED_IRQ); - pr_debug("battery present=%d state=%d", !status, - pm_chg_get_fsm_state(data)); - handle_stop_ext_chg(chip); - power_supply_changed(&chip->batt_psy); - return IRQ_HANDLED; -} - -static irqreturn_t batttemp_hot_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - handle_stop_ext_chg(chip); - power_supply_changed(&chip->batt_psy); - return IRQ_HANDLED; -} - -static irqreturn_t chghot_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - pr_debug("Chg hot fsm_state=%d\n", pm_chg_get_fsm_state(data)); - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - handle_stop_ext_chg(chip); - return IRQ_HANDLED; -} - -static irqreturn_t batttemp_cold_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - pr_debug("Batt cold fsm_state=%d\n", pm_chg_get_fsm_state(data)); - handle_stop_ext_chg(chip); - - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - return IRQ_HANDLED; -} - -static irqreturn_t chg_gone_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - int chg_gone, usb_chg_plugged_in; - - usb_chg_plugged_in = is_usb_chg_plugged_in(chip); - chg_gone = pm_chg_get_rt_status(chip, CHG_GONE_IRQ); - - pr_debug("chg_gone=%d, usb_valid = %d\n", chg_gone, usb_chg_plugged_in); - pr_debug("Chg gone fsm_state=%d\n", pm_chg_get_fsm_state(data)); - - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - return IRQ_HANDLED; -} -/* - * - * bat_temp_ok_irq_handler - is edge triggered, hence it will - * fire for two cases: - * - * If the interrupt line switches to high temperature is okay - * and thus charging begins. - * If bat_temp_ok is low this means the temperature is now - * too hot or cold, so charging is stopped. - * - */ -static irqreturn_t bat_temp_ok_irq_handler(int irq, void *data) -{ - int bat_temp_ok; - struct pm8921_chg_chip *chip = data; - - bat_temp_ok = pm_chg_get_rt_status(chip, BAT_TEMP_OK_IRQ); - - pr_debug("batt_temp_ok = %d fsm_state%d\n", - bat_temp_ok, pm_chg_get_fsm_state(data)); - - if (bat_temp_ok) - handle_start_ext_chg(chip); - else - handle_stop_ext_chg(chip); - - power_supply_changed(&chip->batt_psy); - power_supply_changed(&chip->usb_psy); - bms_notify_check(chip); - return IRQ_HANDLED; -} - -static irqreturn_t coarse_det_low_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t vdd_loop_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t vreg_ov_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t vbatdet_irq_handler(int irq, void *data) -{ - pr_debug("fsm_state=%d\n", pm_chg_get_fsm_state(data)); - return IRQ_HANDLED; -} - -static irqreturn_t batfet_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - pr_debug("vreg ov\n"); - power_supply_changed(&chip->batt_psy); - return IRQ_HANDLED; -} - -static irqreturn_t dcin_valid_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - int dc_present; - - pm_chg_failed_clear(chip, 1); - dc_present = pm_chg_get_rt_status(chip, DCIN_VALID_IRQ); - - if (chip->dc_present ^ dc_present) - pm8921_bms_calibrate_hkadc(); - - if (dc_present) - pm8921_chg_enable_irq(chip, CHG_GONE_IRQ); - else - pm8921_chg_disable_irq(chip, CHG_GONE_IRQ); - - chip->dc_present = dc_present; - - if (chip->ext_psy) { - if (dc_present) - handle_start_ext_chg(chip); - else - handle_stop_ext_chg(chip); - } else { - if (dc_present) - schedule_delayed_work(&chip->unplug_check_work, - msecs_to_jiffies(UNPLUG_CHECK_WAIT_PERIOD_MS)); - power_supply_changed(&chip->dc_psy); - } - - power_supply_changed(&chip->batt_psy); - return IRQ_HANDLED; -} - -static irqreturn_t dcin_ov_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - handle_stop_ext_chg(chip); - return IRQ_HANDLED; -} - -static irqreturn_t dcin_uv_irq_handler(int irq, void *data) -{ - struct pm8921_chg_chip *chip = data; - - handle_stop_ext_chg(chip); - - return IRQ_HANDLED; -} - -static int __pm_batt_external_power_changed_work(struct device *dev, void *data) -{ - struct power_supply *psy = &the_chip->batt_psy; - struct power_supply *epsy = dev_get_drvdata(dev); - int i, dcin_irq; - - /* Only search for external supply if none is registered */ - if (!the_chip->ext_psy) { - dcin_irq = the_chip->pmic_chg_irq[DCIN_VALID_IRQ]; - for (i = 0; i < epsy->num_supplicants; i++) { - if (!strncmp(epsy->supplied_to[i], psy->name, 7)) { - if (!strncmp(epsy->name, "dc", 2)) { - the_chip->ext_psy = epsy; - dcin_valid_irq_handler(dcin_irq, - the_chip); - } - } - } - } - return 0; -} - -static void pm_batt_external_power_changed(struct power_supply *psy) -{ - if (!the_chip) - return; - - /* Only look for an external supply if it hasn't been registered */ - if (!the_chip->ext_psy) - class_for_each_device(power_supply_class, NULL, psy, - __pm_batt_external_power_changed_work); -} - -/** - * update_heartbeat - internal function to update userspace - * per update_time minutes - * - */ -#define LOW_SOC_HEARTBEAT_MS 20000 -static void update_heartbeat(struct work_struct *work) -{ - struct delayed_work *dwork = to_delayed_work(work); - struct pm8921_chg_chip *chip = container_of(dwork, - struct pm8921_chg_chip, update_heartbeat_work); - bool chg_present = chip->usb_present || chip->dc_present; - - /* for battery health when charger is not connected */ - if (chip->btc_override && !chg_present) - schedule_delayed_work(&chip->btc_override_work, - round_jiffies_relative(msecs_to_jiffies - (chip->btc_delay_ms))); - - /* - * check temp thresholds when charger is present and - * and battery is FULL. The temperature here can impact - * the charging restart conditions. - */ - if (chip->btc_override && chg_present && - !wake_lock_active(&chip->eoc_wake_lock)) - check_temp_thresholds(chip); - - power_supply_changed(&chip->batt_psy); - if (chip->recent_reported_soc <= 20) - schedule_delayed_work(&chip->update_heartbeat_work, - round_jiffies_relative(msecs_to_jiffies - (LOW_SOC_HEARTBEAT_MS))); - else - schedule_delayed_work(&chip->update_heartbeat_work, - round_jiffies_relative(msecs_to_jiffies - (chip->update_time))); -} -#define VDD_LOOP_ACTIVE_BIT BIT(3) -#define VDD_MAX_INCREASE_MV 400 -static int vdd_max_increase_mv = VDD_MAX_INCREASE_MV; -module_param(vdd_max_increase_mv, int, 0644); - -static int ichg_threshold_ua = -400000; -module_param(ichg_threshold_ua, int, 0644); - -#define MIN_DELTA_MV_TO_INCREASE_VDD_MAX 13 -#define PM8921_CHG_VDDMAX_RES_MV 10 -static void adjust_vdd_max_for_fastchg(struct pm8921_chg_chip *chip, - int vbat_batt_terminal_uv) -{ - int adj_vdd_max_mv, programmed_vdd_max; - int vbat_batt_terminal_mv; - int reg_loop; - int delta_mv = 0; - - if (chip->rconn_mohm == 0) { - pr_debug("Exiting as rconn_mohm is 0\n"); - return; - } - /* adjust vdd_max only in normal temperature zone */ - if (chip->is_bat_cool || chip->is_bat_warm) { - pr_debug("Exiting is_bat_cool = %d is_batt_warm = %d\n", - chip->is_bat_cool, chip->is_bat_warm); - return; - } - - reg_loop = pm_chg_get_regulation_loop(chip); - if (!(reg_loop & VDD_LOOP_ACTIVE_BIT)) { - pr_debug("Exiting Vdd loop is not active reg loop=0x%x\n", - reg_loop); - return; - } - vbat_batt_terminal_mv = vbat_batt_terminal_uv/1000; - pm_chg_vddmax_get(the_chip, &programmed_vdd_max); - - delta_mv = chip->max_voltage_mv - vbat_batt_terminal_mv; - - if (delta_mv > 0) /* meaning we want to increase the vddmax */ { - if (delta_mv < MIN_DELTA_MV_TO_INCREASE_VDD_MAX) { - pr_debug("vterm = %d is not low enough to inc vdd\n", - vbat_batt_terminal_mv); - return; - } - } - - adj_vdd_max_mv = programmed_vdd_max + delta_mv; - pr_debug("vdd_max needs to be changed by %d mv from %d to %d\n", - delta_mv, - programmed_vdd_max, - adj_vdd_max_mv); - - if (adj_vdd_max_mv < chip->max_voltage_mv) { - pr_debug("adj vdd_max lower than default max voltage\n"); - return; - } - - adj_vdd_max_mv = (adj_vdd_max_mv / PM8921_CHG_VDDMAX_RES_MV) - * PM8921_CHG_VDDMAX_RES_MV; - - if (adj_vdd_max_mv > (chip->max_voltage_mv + vdd_max_increase_mv)) - adj_vdd_max_mv = chip->max_voltage_mv + vdd_max_increase_mv; - pr_debug("adjusting vdd_max_mv to %d to make " - "vbat_batt_termial_uv = %d to %d\n", - adj_vdd_max_mv, vbat_batt_terminal_uv, chip->max_voltage_mv); - pm_chg_vddmax_set(chip, adj_vdd_max_mv); -} - -static void set_appropriate_vbatdet(struct pm8921_chg_chip *chip) -{ - if (chip->is_bat_cool) - pm_chg_vbatdet_set(the_chip, - the_chip->cool_bat_voltage - - the_chip->resume_voltage_delta); - else if (chip->is_bat_warm) - pm_chg_vbatdet_set(the_chip, - the_chip->warm_bat_voltage - - the_chip->resume_voltage_delta); - else - pm_chg_vbatdet_set(the_chip, - the_chip->max_voltage_mv - - the_chip->resume_voltage_delta); -} - -static void set_appropriate_battery_current(struct pm8921_chg_chip *chip) -{ - unsigned int chg_current = chip->max_bat_chg_current; - - if (chip->is_bat_cool) - chg_current = min(chg_current, chip->cool_bat_chg_current); - - if (chip->is_bat_warm) - chg_current = min(chg_current, chip->warm_bat_chg_current); - - if (thermal_mitigation != 0 && chip->thermal_mitigation) - chg_current = min(chg_current, - chip->thermal_mitigation[thermal_mitigation]); - - pm_chg_ibatmax_set(the_chip, chg_current); -} - -#define TEMP_HYSTERISIS_DECIDEGC 20 -static void battery_cool(bool enter) -{ - pr_debug("enter = %d\n", enter); - if (enter == the_chip->is_bat_cool) - return; - the_chip->is_bat_cool = enter; - if (enter) - pm_chg_vddmax_set(the_chip, the_chip->cool_bat_voltage); - else - pm_chg_vddmax_set(the_chip, the_chip->max_voltage_mv); - set_appropriate_battery_current(the_chip); - set_appropriate_vbatdet(the_chip); -} - -static void battery_warm(bool enter) -{ - pr_debug("enter = %d\n", enter); - if (enter == the_chip->is_bat_warm) - return; - the_chip->is_bat_warm = enter; - if (enter) - pm_chg_vddmax_set(the_chip, the_chip->warm_bat_voltage); - else - pm_chg_vddmax_set(the_chip, the_chip->max_voltage_mv); - - set_appropriate_battery_current(the_chip); - set_appropriate_vbatdet(the_chip); -} - -static void check_temp_thresholds(struct pm8921_chg_chip *chip) -{ - int temp = 0, rc; - - rc = get_prop_batt_temp(chip, &temp); - pr_debug("temp = %d, warm_thr_temp = %d, cool_thr_temp = %d\n", - temp, chip->warm_temp_dc, - chip->cool_temp_dc); - - if (chip->warm_temp_dc != INT_MIN) { - if (chip->is_bat_warm - && temp < chip->warm_temp_dc - chip->hysteresis_temp_dc) - battery_warm(false); - else if (!chip->is_bat_warm && temp >= chip->warm_temp_dc) - battery_warm(true); - } - - if (chip->cool_temp_dc != INT_MIN) { - if (chip->is_bat_cool - && temp > chip->cool_temp_dc + chip->hysteresis_temp_dc) - battery_cool(false); - else if (!chip->is_bat_cool && temp <= chip->cool_temp_dc) - battery_cool(true); - } -} - -enum { - CHG_IN_PROGRESS, - CHG_NOT_IN_PROGRESS, - CHG_FINISHED, -}; - -#define VBAT_TOLERANCE_MV 70 -#define CHG_DISABLE_MSLEEP 100 -static int is_charging_finished(struct pm8921_chg_chip *chip, - int vbat_batt_terminal_uv, int ichg_meas_ma) -{ - int vbat_programmed, iterm_programmed, vbat_intended; - int regulation_loop, fast_chg, vcp; - int rc; - static int last_vbat_programmed = -EINVAL; - - if (!is_ext_charging(chip)) { - /* return if the battery is not being fastcharged */ - fast_chg = pm_chg_get_rt_status(chip, FASTCHG_IRQ); - pr_debug("fast_chg = %d\n", fast_chg); - if (fast_chg == 0) - return CHG_NOT_IN_PROGRESS; - - vcp = pm_chg_get_rt_status(chip, VCP_IRQ); - pr_debug("vcp = %d\n", vcp); - if (vcp == 1) - return CHG_IN_PROGRESS; - - /* reset count if battery is hot/cold */ - rc = pm_chg_get_rt_status(chip, BAT_TEMP_OK_IRQ); - pr_debug("batt_temp_ok = %d\n", rc); - if (rc == 0) - return CHG_IN_PROGRESS; - - rc = pm_chg_vddmax_get(chip, &vbat_programmed); - if (rc) { - pr_err("couldnt read vddmax rc = %d\n", rc); - return CHG_IN_PROGRESS; - } - pr_debug("vddmax = %d vbat_batt_terminal_uv=%d\n", - vbat_programmed, vbat_batt_terminal_uv); - - if (last_vbat_programmed == -EINVAL) - last_vbat_programmed = vbat_programmed; - if (last_vbat_programmed != vbat_programmed) { - /* vddmax changed, reset and check again */ - pr_debug("vddmax = %d last_vdd_max=%d\n", - vbat_programmed, last_vbat_programmed); - last_vbat_programmed = vbat_programmed; - return CHG_IN_PROGRESS; - } - - if (chip->is_bat_cool) - vbat_intended = chip->cool_bat_voltage; - else if (chip->is_bat_warm) - vbat_intended = chip->warm_bat_voltage; - else - vbat_intended = chip->max_voltage_mv; - - if (vbat_batt_terminal_uv / 1000 - < vbat_intended - MIN_DELTA_MV_TO_INCREASE_VDD_MAX) { - pr_debug("terminal_uv:%d < vbat_intended:%d-hyst:%d\n", - vbat_batt_terminal_uv, - vbat_intended, - vbat_intended); - return CHG_IN_PROGRESS; - } - - regulation_loop = pm_chg_get_regulation_loop(chip); - if (regulation_loop < 0) { - pr_err("couldnt read the regulation loop err=%d\n", - regulation_loop); - return CHG_IN_PROGRESS; - } - pr_debug("regulation_loop=%d\n", regulation_loop); - - if (regulation_loop != 0 && regulation_loop != VDD_LOOP) - return CHG_IN_PROGRESS; - } /* !is_ext_charging */ - - /* reset count if battery chg current is more than iterm */ - rc = pm_chg_iterm_get(chip, &iterm_programmed); - if (rc) { - pr_err("couldnt read iterm rc = %d\n", rc); - return CHG_IN_PROGRESS; - } - - pr_debug("iterm_programmed = %d ichg_meas_ma=%d\n", - iterm_programmed, ichg_meas_ma); - /* - * ichg_meas_ma < 0 means battery is drawing current - * ichg_meas_ma > 0 means battery is providing current - */ - if (ichg_meas_ma > 0) - return CHG_IN_PROGRESS; - - if (ichg_meas_ma * -1 > iterm_programmed) - return CHG_IN_PROGRESS; - - return CHG_FINISHED; -} - -#define COMP_OVERRIDE_HOT_BANK 6 -#define COMP_OVERRIDE_COLD_BANK 7 -#define COMP_OVERRIDE_BIT BIT(1) -static int pm_chg_override_cold(struct pm8921_chg_chip *chip, int flag) -{ - u8 val; - int rc = 0; - - val = 0x80 | COMP_OVERRIDE_COLD_BANK << 2 | COMP_OVERRIDE_BIT; - - if (flag) - val |= 0x01; - - rc = pm_chg_write(chip, COMPARATOR_OVERRIDE, val); - if (rc < 0) - pr_err("Could not write 0x%x to override rc = %d\n", val, rc); - - pr_debug("btc cold = %d val = 0x%x\n", flag, val); - return rc; -} - -static int pm_chg_override_hot(struct pm8921_chg_chip *chip, int flag) -{ - u8 val; - int rc = 0; - - val = 0x80 | COMP_OVERRIDE_HOT_BANK << 2 | COMP_OVERRIDE_BIT; - - if (flag) - val |= 0x01; - - rc = pm_chg_write(chip, COMPARATOR_OVERRIDE, val); - if (rc < 0) - pr_err("Could not write 0x%x to override rc = %d\n", val, rc); - - pr_debug("btc hot = %d val = 0x%x\n", flag, val); - return rc; -} - -static void pm8921_chg_btc_override_init(struct pm8921_chg_chip *chip) -{ - int rc = 0; - u8 reg; - u8 val; - - val = COMP_OVERRIDE_HOT_BANK << 2; - rc = pm_chg_write(chip, COMPARATOR_OVERRIDE, val); - if (rc < 0) { - pr_err("Could not write 0x%x to override rc = %d\n", val, rc); - goto cold_init; - } - rc = pm8xxx_readb(chip->dev->parent, COMPARATOR_OVERRIDE, ®); - if (rc < 0) { - pr_err("Could not read bank %d of override rc = %d\n", - COMP_OVERRIDE_HOT_BANK, rc); - goto cold_init; - } - if ((reg & COMP_OVERRIDE_BIT) != COMP_OVERRIDE_BIT) { - /* for now override it as not hot */ - rc = pm_chg_override_hot(chip, 0); - if (rc < 0) - pr_err("Could not override hot rc = %d\n", rc); - } - -cold_init: - val = COMP_OVERRIDE_COLD_BANK << 2; - rc = pm_chg_write(chip, COMPARATOR_OVERRIDE, val); - if (rc < 0) { - pr_err("Could not write 0x%x to override rc = %d\n", val, rc); - return; - } - rc = pm8xxx_readb(chip->dev->parent, COMPARATOR_OVERRIDE, ®); - if (rc < 0) { - pr_err("Could not read bank %d of override rc = %d\n", - COMP_OVERRIDE_COLD_BANK, rc); - return; - } - if ((reg & COMP_OVERRIDE_BIT) != COMP_OVERRIDE_BIT) { - /* for now override it as not cold */ - rc = pm_chg_override_cold(chip, 0); - if (rc < 0) - pr_err("Could not override cold rc = %d\n", rc); - } -} - -static void btc_override_worker(struct work_struct *work) -{ - int decidegc; - int temp; - int rc = 0; - struct delayed_work *dwork = to_delayed_work(work); - struct pm8921_chg_chip *chip = container_of(dwork, - struct pm8921_chg_chip, btc_override_work); - - if (!chip->btc_override) { - pr_err("called when not enabled\n"); - return; - } - - rc = get_prop_batt_temp(chip, &decidegc); - if (rc) { - pr_info("Failed to read temperature\n"); - goto fail_btc_temp; - } - - pr_debug("temp=%d\n", decidegc); - - temp = pm_chg_get_rt_status(chip, BATTTEMP_HOT_IRQ); - if (temp) { - if (decidegc < chip->btc_override_hot_decidegc - - chip->hysteresis_temp_dc) - /* stop forcing batt hot */ - rc = pm_chg_override_hot(chip, 0); - if (rc) - pr_err("Couldnt write 0 to hot comp\n"); - } else { - if (decidegc >= chip->btc_override_hot_decidegc) - /* start forcing batt hot */ - rc = pm_chg_override_hot(chip, 1); - if (rc && chip->btc_panic_if_cant_stop_chg) - panic("Couldnt override comps to stop chg\n"); - } - - temp = pm_chg_get_rt_status(chip, BATTTEMP_COLD_IRQ); - if (temp) { - if (decidegc > chip->btc_override_cold_decidegc + - chip->hysteresis_temp_dc) - /* stop forcing batt cold */ - rc = pm_chg_override_cold(chip, 0); - if (rc) - pr_err("Couldnt write 0 to cold comp\n"); - } else { - if (decidegc <= chip->btc_override_cold_decidegc) - /* start forcing batt cold */ - rc = pm_chg_override_cold(chip, 1); - if (rc && chip->btc_panic_if_cant_stop_chg) - panic("Couldnt override comps to stop chg\n"); - } - - if ((is_dc_chg_plugged_in(the_chip) || is_usb_chg_plugged_in(the_chip)) - && get_prop_batt_status(chip) != POWER_SUPPLY_STATUS_FULL) { - schedule_delayed_work(&chip->btc_override_work, - round_jiffies_relative(msecs_to_jiffies - (chip->btc_delay_ms))); - return; - } - -fail_btc_temp: - rc = pm_chg_override_hot(chip, 0); - if (rc) - pr_err("Couldnt write 0 to hot comp\n"); - rc = pm_chg_override_cold(chip, 0); - if (rc) - pr_err("Couldnt write 0 to cold comp\n"); -} - -/** - * eoc_worker - internal function to check if battery EOC - * has happened - * - * If all conditions favouring, if the charge current is - * less than the term current for three consecutive times - * an EOC has happened. - * The wakelock is released if there is no need to reshedule - * - this happens when the battery is removed or EOC has - * happened - */ -#define CONSECUTIVE_COUNT 3 -static void eoc_worker(struct work_struct *work) -{ - struct delayed_work *dwork = to_delayed_work(work); - struct pm8921_chg_chip *chip = container_of(dwork, - struct pm8921_chg_chip, eoc_work); - static int count; - int end; - int vbat_meas_uv, vbat_meas_mv; - int ichg_meas_ua, ichg_meas_ma; - int vbat_batt_terminal_uv; - - pm8921_bms_get_simultaneous_battery_voltage_and_current( - &ichg_meas_ua, &vbat_meas_uv); - vbat_meas_mv = vbat_meas_uv / 1000; - /* rconn_mohm is in milliOhms */ - ichg_meas_ma = ichg_meas_ua / 1000; - vbat_batt_terminal_uv = vbat_meas_uv - + ichg_meas_ma - * the_chip->rconn_mohm; - - end = is_charging_finished(chip, vbat_batt_terminal_uv, ichg_meas_ma); - - if (end == CHG_NOT_IN_PROGRESS && (!chip->btc_override || - !(chip->usb_present || chip->dc_present))) { - count = 0; - goto eoc_worker_stop; - } - - if (end == CHG_FINISHED) { - count++; - } else { - count = 0; - } - - if (count == CONSECUTIVE_COUNT) { - count = 0; - pr_info("End of Charging\n"); - - pm_chg_auto_enable(chip, 0); - - if (is_ext_charging(chip)) - chip->ext_charge_done = true; - - if (chip->is_bat_warm || chip->is_bat_cool) - chip->bms_notify.is_battery_full = 0; - else - chip->bms_notify.is_battery_full = 1; - /* declare end of charging by invoking chgdone interrupt */ - chgdone_irq_handler(chip->pmic_chg_irq[CHGDONE_IRQ], chip); - } else { - check_temp_thresholds(chip); - if (end != CHG_NOT_IN_PROGRESS) - adjust_vdd_max_for_fastchg(chip, vbat_batt_terminal_uv); - pr_debug("EOC count = %d\n", count); - schedule_delayed_work(&chip->eoc_work, - round_jiffies_relative(msecs_to_jiffies - (EOC_CHECK_PERIOD_MS))); - return; - } - -eoc_worker_stop: - /* set the vbatdet back, in case it was changed to trigger charging */ - set_appropriate_vbatdet(chip); - wake_unlock(&chip->eoc_wake_lock); -} - -/** - * set_disable_status_param - - * - * Internal function to disable battery charging and also disable drawing - * any current from the source. The device is forced to run on a battery - * after this. - */ -static int set_disable_status_param(const char *val, struct kernel_param *kp) -{ - int ret; - struct pm8921_chg_chip *chip = the_chip; - - ret = param_set_int(val, kp); - if (ret) { - pr_err("error setting value %d\n", ret); - return ret; - } - pr_info("factory set disable param to %d\n", charging_disabled); - if (chip) { - pm_chg_auto_enable(chip, !charging_disabled); - pm_chg_charge_dis(chip, charging_disabled); - } - return 0; -} -module_param_call(disabled, set_disable_status_param, param_get_uint, - &charging_disabled, 0644); - -static int rconn_mohm; -static int set_rconn_mohm(const char *val, struct kernel_param *kp) -{ - int ret; - struct pm8921_chg_chip *chip = the_chip; - - ret = param_set_int(val, kp); - if (ret) { - pr_err("error setting value %d\n", ret); - return ret; - } - if (chip) - chip->rconn_mohm = rconn_mohm; - return 0; -} -module_param_call(rconn_mohm, set_rconn_mohm, param_get_uint, - &rconn_mohm, 0644); -/** - * set_thermal_mitigation_level - - * - * Internal function to control battery charging current to reduce - * temperature - */ -static int set_therm_mitigation_level(const char *val, struct kernel_param *kp) -{ - int ret; - struct pm8921_chg_chip *chip = the_chip; - - ret = param_set_int(val, kp); - if (ret) { - pr_err("error setting value %d\n", ret); - return ret; - } - - if (!chip) { - pr_err("called before init\n"); - return -EINVAL; - } - - if (!chip->thermal_mitigation) { - pr_err("no thermal mitigation\n"); - return -EINVAL; - } - - if (thermal_mitigation < 0 - || thermal_mitigation >= chip->thermal_levels) { - pr_err("out of bound level selected\n"); - return -EINVAL; - } - - set_appropriate_battery_current(chip); - return ret; -} -module_param_call(thermal_mitigation, set_therm_mitigation_level, - param_get_uint, - &thermal_mitigation, 0644); - -static int set_usb_max_current(const char *val, struct kernel_param *kp) -{ - int ret, mA; - struct pm8921_chg_chip *chip = the_chip; - - ret = param_set_int(val, kp); - if (ret) { - pr_err("error setting value %d\n", ret); - return ret; - } - if (chip) { - pr_warn("setting current max to %d\n", usb_max_current); - pm_chg_iusbmax_get(chip, &mA); - if (mA > usb_max_current) - pm8921_charger_vbus_draw(usb_max_current); - return 0; - } - return -EINVAL; -} -module_param_call(usb_max_current, set_usb_max_current, - param_get_uint, &usb_max_current, 0644); - -static void free_irqs(struct pm8921_chg_chip *chip) -{ - int i; - - for (i = 0; i < PM_CHG_MAX_INTS; i++) - if (chip->pmic_chg_irq[i]) { - free_irq(chip->pmic_chg_irq[i], chip); - chip->pmic_chg_irq[i] = 0; - } -} - -#define PM8921_USB_TRIM_SEL_BIT BIT(6) -/* determines the initial present states */ -static void determine_initial_state(struct pm8921_chg_chip *chip) -{ - int fsm_state; - int is_fast_chg; - int rc = 0; - u8 trim_sel_reg = 0, regsbi; - - chip->dc_present = !!is_dc_chg_plugged_in(chip); - chip->usb_present = !!is_usb_chg_plugged_in(chip); - - notify_usb_of_the_plugin_event(chip->usb_present); - if (chip->usb_present || chip->dc_present) { - schedule_delayed_work(&chip->unplug_check_work, - msecs_to_jiffies(UNPLUG_CHECK_WAIT_PERIOD_MS)); - pm8921_chg_enable_irq(chip, CHG_GONE_IRQ); - - if (chip->btc_override) - schedule_delayed_work(&chip->btc_override_work, - round_jiffies_relative(msecs_to_jiffies - (chip->btc_delay_ms))); - } - - pm8921_chg_enable_irq(chip, DCIN_VALID_IRQ); - pm8921_chg_enable_irq(chip, USBIN_VALID_IRQ); - pm8921_chg_enable_irq(chip, BATT_REMOVED_IRQ); - pm8921_chg_enable_irq(chip, BATT_INSERTED_IRQ); - pm8921_chg_enable_irq(chip, DCIN_OV_IRQ); - pm8921_chg_enable_irq(chip, DCIN_UV_IRQ); - pm8921_chg_enable_irq(chip, CHGFAIL_IRQ); - pm8921_chg_enable_irq(chip, FASTCHG_IRQ); - pm8921_chg_enable_irq(chip, VBATDET_LOW_IRQ); - pm8921_chg_enable_irq(chip, BAT_TEMP_OK_IRQ); - - if (get_prop_batt_present(the_chip) || is_dc_chg_plugged_in(the_chip)) - if (usb_chg_current) - /* - * Reissue a vbus draw call only if a battery - * or DC is present. We don't want to brown out the - * device if usb is its only source - */ - __pm8921_charger_vbus_draw(usb_chg_current); - usb_chg_current = 0; - - /* - * The bootloader could have started charging, a fastchg interrupt - * might not happen. Check the real time status and if it is fast - * charging invoke the handler so that the eoc worker could be - * started - */ - is_fast_chg = pm_chg_get_rt_status(chip, FASTCHG_IRQ); - if (is_fast_chg) - fastchg_irq_handler(chip->pmic_chg_irq[FASTCHG_IRQ], chip); - - fsm_state = pm_chg_get_fsm_state(chip); - if (is_battery_charging(fsm_state)) { - chip->bms_notify.is_charging = 1; - pm8921_bms_charging_began(); - } - - check_battery_valid(chip); - - pr_debug("usb = %d, dc = %d batt = %d state=%d\n", - chip->usb_present, - chip->dc_present, - get_prop_batt_present(chip), - fsm_state); - - /* Determine which USB trim column to use */ - if (pm8xxx_get_version(chip->dev->parent) == PM8XXX_VERSION_8917) { - chip->usb_trim_table = usb_trim_8917_table; - } else if (pm8xxx_get_version(chip->dev->parent) == - PM8XXX_VERSION_8038) { - chip->usb_trim_table = usb_trim_8038_table; - } else if (pm8xxx_get_version(chip->dev->parent) == - PM8XXX_VERSION_8921) { - rc = pm8xxx_readb(chip->dev->parent, REG_SBI_CONFIG, ®sbi); - rc |= pm8xxx_writeb(chip->dev->parent, REG_SBI_CONFIG, 0x5E); - rc |= pm8xxx_readb(chip->dev->parent, PM8921_USB_TRIM_SEL, - &trim_sel_reg); - rc |= pm8xxx_writeb(chip->dev->parent, REG_SBI_CONFIG, regsbi); - if (rc) - pr_err("Failed to read trim sel register rc=%d\n", rc); - - if (trim_sel_reg & PM8921_USB_TRIM_SEL_BIT) - chip->usb_trim_table = usb_trim_pm8921_table_1; - else - chip->usb_trim_table = usb_trim_pm8921_table_2; - } -} - -struct pm_chg_irq_init_data { - unsigned int irq_id; - char *name; - unsigned long flags; - irqreturn_t (*handler)(int, void *); -}; - -#define CHG_IRQ(_id, _flags, _handler) \ -{ \ - .irq_id = _id, \ - .name = #_id, \ - .flags = _flags, \ - .handler = _handler, \ -} -struct pm_chg_irq_init_data chg_irq_data[] = { - CHG_IRQ(USBIN_VALID_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - usbin_valid_irq_handler), - CHG_IRQ(BATT_INSERTED_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - batt_inserted_irq_handler), - CHG_IRQ(VBATDET_LOW_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - vbatdet_low_irq_handler), - CHG_IRQ(CHGWDOG_IRQ, IRQF_TRIGGER_RISING, chgwdog_irq_handler), - CHG_IRQ(VCP_IRQ, IRQF_TRIGGER_RISING, vcp_irq_handler), - CHG_IRQ(ATCDONE_IRQ, IRQF_TRIGGER_RISING, atcdone_irq_handler), - CHG_IRQ(ATCFAIL_IRQ, IRQF_TRIGGER_RISING, atcfail_irq_handler), - CHG_IRQ(CHGDONE_IRQ, IRQF_TRIGGER_RISING, chgdone_irq_handler), - CHG_IRQ(CHGFAIL_IRQ, IRQF_TRIGGER_RISING, chgfail_irq_handler), - CHG_IRQ(CHGSTATE_IRQ, IRQF_TRIGGER_RISING, chgstate_irq_handler), - CHG_IRQ(LOOP_CHANGE_IRQ, IRQF_TRIGGER_RISING, loop_change_irq_handler), - CHG_IRQ(FASTCHG_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - fastchg_irq_handler), - CHG_IRQ(TRKLCHG_IRQ, IRQF_TRIGGER_RISING, trklchg_irq_handler), - CHG_IRQ(BATT_REMOVED_IRQ, IRQF_TRIGGER_RISING, - batt_removed_irq_handler), - CHG_IRQ(BATTTEMP_HOT_IRQ, IRQF_TRIGGER_RISING, - batttemp_hot_irq_handler), - CHG_IRQ(CHGHOT_IRQ, IRQF_TRIGGER_RISING, chghot_irq_handler), - CHG_IRQ(BATTTEMP_COLD_IRQ, IRQF_TRIGGER_RISING, - batttemp_cold_irq_handler), - CHG_IRQ(CHG_GONE_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - chg_gone_irq_handler), - CHG_IRQ(BAT_TEMP_OK_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - bat_temp_ok_irq_handler), - CHG_IRQ(COARSE_DET_LOW_IRQ, IRQF_TRIGGER_RISING, - coarse_det_low_irq_handler), - CHG_IRQ(VDD_LOOP_IRQ, IRQF_TRIGGER_RISING, vdd_loop_irq_handler), - CHG_IRQ(VREG_OV_IRQ, IRQF_TRIGGER_RISING, vreg_ov_irq_handler), - CHG_IRQ(VBATDET_IRQ, IRQF_TRIGGER_RISING, vbatdet_irq_handler), - CHG_IRQ(BATFET_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - batfet_irq_handler), - CHG_IRQ(DCIN_VALID_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - dcin_valid_irq_handler), - CHG_IRQ(DCIN_OV_IRQ, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - dcin_ov_irq_handler), - CHG_IRQ(DCIN_UV_IRQ, IRQF_TRIGGER_RISING, dcin_uv_irq_handler), -}; - -static int request_irqs(struct pm8921_chg_chip *chip, - struct platform_device *pdev) -{ - struct resource *res; - int ret, i; - - ret = 0; - bitmap_fill(chip->enabled_irqs, PM_CHG_MAX_INTS); - - for (i = 0; i < ARRAY_SIZE(chg_irq_data); i++) { - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - chg_irq_data[i].name); - if (res == NULL) { - pr_err("couldn't find %s\n", chg_irq_data[i].name); - goto err_out; - } - chip->pmic_chg_irq[chg_irq_data[i].irq_id] = res->start; - ret = request_irq(res->start, chg_irq_data[i].handler, - chg_irq_data[i].flags, - chg_irq_data[i].name, chip); - if (ret < 0) { - pr_err("couldn't request %d (%s) %d\n", res->start, - chg_irq_data[i].name, ret); - chip->pmic_chg_irq[chg_irq_data[i].irq_id] = 0; - goto err_out; - } - pm8921_chg_disable_irq(chip, chg_irq_data[i].irq_id); - } - return 0; - -err_out: - free_irqs(chip); - return -EINVAL; -} - -#define TCXO_WARMUP_DELAY_MS 4 -static void pm8921_chg_force_19p2mhz_clk(struct pm8921_chg_chip *chip) -{ - int err; - u8 temp; - - msm_xo_mode_vote(chip->voter, MSM_XO_MODE_ON); - if (chip->enable_tcxo_warmup_delay) - msleep(TCXO_WARMUP_DELAY_MS); - - temp = 0xD1; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - temp = 0xD3; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - temp = 0xD1; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - temp = 0xD5; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - udelay(183); - - temp = 0xD1; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - temp = 0xD0; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - udelay(32); - - temp = 0xD1; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - temp = 0xD3; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - msm_xo_mode_vote(chip->voter, MSM_XO_MODE_OFF); -} - -static void pm8921_chg_set_hw_clk_switching(struct pm8921_chg_chip *chip) -{ - int err; - u8 temp; - - msm_xo_mode_vote(chip->voter, MSM_XO_MODE_ON); - if (chip->enable_tcxo_warmup_delay) - msleep(TCXO_WARMUP_DELAY_MS); - - temp = 0xD1; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - - temp = 0xD0; - err = pm_chg_write(chip, CHG_TEST, temp); - if (err) { - pr_err("Error %d writing %d to addr %d\n", err, temp, CHG_TEST); - return; - } - msm_xo_mode_vote(chip->voter, MSM_XO_MODE_OFF); -} - -#define VREF_BATT_THERM_FORCE_ON BIT(7) -static void detect_battery_removal(struct pm8921_chg_chip *chip) -{ - u8 temp; - - pm8xxx_readb(chip->dev->parent, CHG_CNTRL, &temp); - pr_debug("upon restart CHG_CNTRL = 0x%x\n", temp); - - if (!(temp & VREF_BATT_THERM_FORCE_ON)) - /* - * batt therm force on bit is battery backed and is default 0 - * The charger sets this bit at init time. If this bit is found - * 0 that means the battery was removed. Tell the bms about it - */ - pm8921_bms_invalidate_shutdown_soc(); -} - -#define ENUM_TIMER_STOP_BIT BIT(1) -#define BOOT_DONE_BIT BIT(6) -#define CHG_BATFET_ON_BIT BIT(3) -#define CHG_VCP_EN BIT(0) -#define CHG_BAT_TEMP_DIS_BIT BIT(2) -#define SAFE_CURRENT_MA 1500 -#define PM_SUB_REV 0x001 -#define MIN_CHARGE_CURRENT_MA 350 -#define DEFAULT_SAFETY_MINUTES 500 -static int pm8921_chg_hw_init(struct pm8921_chg_chip *chip) -{ - u8 subrev; - int rc, vdd_safe, fcc_uah, safety_time = DEFAULT_SAFETY_MINUTES; - - /* forcing 19p2mhz before accessing any charger registers */ - pm8921_chg_force_19p2mhz_clk(chip); - - detect_battery_removal(chip); - - rc = pm_chg_masked_write(chip, SYS_CONFIG_2, - BOOT_DONE_BIT, BOOT_DONE_BIT); - if (rc) { - pr_err("Failed to set BOOT_DONE_BIT rc=%d\n", rc); - return rc; - } - - vdd_safe = chip->max_voltage_mv + VDD_MAX_INCREASE_MV; - - if (vdd_safe > PM8921_CHG_VDDSAFE_MAX) - vdd_safe = PM8921_CHG_VDDSAFE_MAX; - - rc = pm_chg_vddsafe_set(chip, vdd_safe); - - if (rc) { - pr_err("Failed to set safe voltage to %d rc=%d\n", - chip->max_voltage_mv, rc); - return rc; - } - rc = pm_chg_vbatdet_set(chip, - chip->max_voltage_mv - - chip->resume_voltage_delta); - if (rc) { - pr_err("Failed to set vbatdet comprator voltage to %d rc=%d\n", - chip->max_voltage_mv - chip->resume_voltage_delta, rc); - return rc; - } - - rc = pm_chg_vddmax_set(chip, chip->max_voltage_mv); - if (rc) { - pr_err("Failed to set max voltage to %d rc=%d\n", - chip->max_voltage_mv, rc); - return rc; - } - - if (chip->safe_current_ma == 0) - chip->safe_current_ma = SAFE_CURRENT_MA; - - rc = pm_chg_ibatsafe_set(chip, chip->safe_current_ma); - if (rc) { - pr_err("Failed to set max voltage to %d rc=%d\n", - SAFE_CURRENT_MA, rc); - return rc; - } - - rc = pm_chg_ibatmax_set(chip, chip->max_bat_chg_current); - if (rc) { - pr_err("Failed to set max current to 400 rc=%d\n", rc); - return rc; - } - - rc = pm_chg_iterm_set(chip, chip->term_current); - if (rc) { - pr_err("Failed to set term current to %d rc=%d\n", - chip->term_current, rc); - return rc; - } - - /* Disable the ENUM TIMER */ - rc = pm_chg_masked_write(chip, PBL_ACCESS2, ENUM_TIMER_STOP_BIT, - ENUM_TIMER_STOP_BIT); - if (rc) { - pr_err("Failed to set enum timer stop rc=%d\n", rc); - return rc; - } - - fcc_uah = pm8921_bms_get_fcc(); - if (fcc_uah > 0) { - safety_time = div_s64((s64)fcc_uah * 60, - 1000 * MIN_CHARGE_CURRENT_MA); - /* add 20 minutes of buffer time */ - safety_time += 20; - - /* make sure we do not exceed the maximum programmable time */ - if (safety_time > PM8921_CHG_TCHG_MAX) - safety_time = PM8921_CHG_TCHG_MAX; - } - - rc = pm_chg_tchg_max_set(chip, safety_time); - if (rc) { - pr_err("Failed to set max time to %d minutes rc=%d\n", - safety_time, rc); - return rc; - } - - if (chip->ttrkl_time != 0) { - rc = pm_chg_ttrkl_max_set(chip, chip->ttrkl_time); - if (rc) { - pr_err("Failed to set trkl time to %d minutes rc=%d\n", - chip->ttrkl_time, rc); - return rc; - } - } - - if (chip->vin_min != 0) { - rc = pm_chg_vinmin_set(chip, chip->vin_min); - if (rc) { - pr_err("Failed to set vin min to %d mV rc=%d\n", - chip->vin_min, rc); - return rc; - } - } else { - chip->vin_min = pm_chg_vinmin_get(chip); - } - - rc = pm_chg_disable_wd(chip); - if (rc) { - pr_err("Failed to disable wd rc=%d\n", rc); - return rc; - } - - rc = pm_chg_masked_write(chip, CHG_CNTRL_2, - CHG_BAT_TEMP_DIS_BIT, 0); - if (rc) { - pr_err("Failed to enable temp control chg rc=%d\n", rc); - return rc; - } - /* switch to a 3.2Mhz for the buck */ - if (pm8xxx_get_revision(chip->dev->parent) >= PM8XXX_REVISION_8038_1p0) - rc = pm_chg_write(chip, - CHG_BUCK_CLOCK_CTRL_8038, 0x15); - else - rc = pm_chg_write(chip, - CHG_BUCK_CLOCK_CTRL, 0x15); - - if (rc) { - pr_err("Failed to switch buck clk rc=%d\n", rc); - return rc; - } - - if (chip->trkl_voltage != 0) { - rc = pm_chg_vtrkl_low_set(chip, chip->trkl_voltage); - if (rc) { - pr_err("Failed to set trkl voltage to %dmv rc=%d\n", - chip->trkl_voltage, rc); - return rc; - } - } - - if (chip->weak_voltage != 0) { - rc = pm_chg_vweak_set(chip, chip->weak_voltage); - if (rc) { - pr_err("Failed to set weak voltage to %dmv rc=%d\n", - chip->weak_voltage, rc); - return rc; - } - } - - if (chip->trkl_current != 0) { - rc = pm_chg_itrkl_set(chip, chip->trkl_current); - if (rc) { - pr_err("Failed to set trkl current to %dmA rc=%d\n", - chip->trkl_voltage, rc); - return rc; - } - } - - if (chip->weak_current != 0) { - rc = pm_chg_iweak_set(chip, chip->weak_current); - if (rc) { - pr_err("Failed to set weak current to %dmA rc=%d\n", - chip->weak_current, rc); - return rc; - } - } - - rc = pm_chg_batt_cold_temp_config(chip, chip->cold_thr); - if (rc) { - pr_err("Failed to set cold config %d rc=%d\n", - chip->cold_thr, rc); - } - - rc = pm_chg_batt_hot_temp_config(chip, chip->hot_thr); - if (rc) { - pr_err("Failed to set hot config %d rc=%d\n", - chip->hot_thr, rc); - } - - rc = pm_chg_led_src_config(chip, chip->led_src_config); - if (rc) { - pr_err("Failed to set charger LED src config %d rc=%d\n", - chip->led_src_config, rc); - } - - /* Workarounds for die 3.0 */ - if (pm8xxx_get_revision(chip->dev->parent) == PM8XXX_REVISION_8921_3p0 - && pm8xxx_get_version(chip->dev->parent) == PM8XXX_VERSION_8921) { - rc = pm8xxx_readb(chip->dev->parent, PM_SUB_REV, &subrev); - if (rc) { - pr_err("read failed: addr=%03X, rc=%d\n", - PM_SUB_REV, rc); - return rc; - } - /* Check if die 3.0.1 is present */ - if (subrev & 0x1) - pm_chg_write(chip, CHG_BUCK_CTRL_TEST3, 0xA4); - else - pm_chg_write(chip, CHG_BUCK_CTRL_TEST3, 0xAC); - } - - if (pm8xxx_get_version(chip->dev->parent) == PM8XXX_VERSION_8917) { - /* Set PM8917 USB_OVP debounce time to 15 ms */ - rc = pm_chg_masked_write(chip, USB_OVP_CONTROL, - OVP_DEBOUNCE_TIME, 0x6); - if (rc) { - pr_err("Failed to set USB OVP db rc=%d\n", rc); - return rc; - } - - /* Enable isub_fine resolution AICL for PM8917 */ - chip->iusb_fine_res = true; - if (chip->uvd_voltage_mv) { - rc = pm_chg_uvd_threshold_set(chip, - chip->uvd_voltage_mv); - if (rc) { - pr_err("Failed to set UVD threshold %drc=%d\n", - chip->uvd_voltage_mv, rc); - return rc; - } - } - } - - pm_chg_write(chip, CHG_BUCK_CTRL_TEST3, 0xD9); - - /* Disable EOC FSM processing */ - pm_chg_write(chip, CHG_BUCK_CTRL_TEST3, 0x91); - - rc = pm_chg_masked_write(chip, CHG_CNTRL, VREF_BATT_THERM_FORCE_ON, - VREF_BATT_THERM_FORCE_ON); - if (rc) - pr_err("Failed to Force Vref therm rc=%d\n", rc); - - rc = pm_chg_charge_dis(chip, charging_disabled); - if (rc) { - pr_err("Failed to disable CHG_CHARGE_DIS bit rc=%d\n", rc); - return rc; - } - - rc = pm_chg_auto_enable(chip, !charging_disabled); - if (rc) { - pr_err("Failed to enable charging rc=%d\n", rc); - return rc; - } - - return 0; -} - -static int get_rt_status(void *data, u64 * val) -{ - int i = (int)data; - int ret; - - /* global irq number is passed in via data */ - ret = pm_chg_get_rt_status(the_chip, i); - *val = ret; - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(rt_fops, get_rt_status, NULL, "%llu\n"); - -static int get_fsm_status(void *data, u64 * val) -{ - u8 temp; - - temp = pm_chg_get_fsm_state(the_chip); - *val = temp; - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(fsm_fops, get_fsm_status, NULL, "%llu\n"); - -static int get_reg_loop(void *data, u64 * val) -{ - u8 temp; - - if (!the_chip) { - pr_err("%s called before init\n", __func__); - return -EINVAL; - } - temp = pm_chg_get_regulation_loop(the_chip); - *val = temp; - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(reg_loop_fops, get_reg_loop, NULL, "0x%02llx\n"); - -static int get_reg(void *data, u64 * val) -{ - int addr = (int)data; - int ret; - u8 temp; - - ret = pm8xxx_readb(the_chip->dev->parent, addr, &temp); - if (ret) { - pr_err("pm8xxx_readb to %x value =%d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - *val = temp; - return 0; -} - -static int set_reg(void *data, u64 val) -{ - int addr = (int)data; - int ret; - u8 temp; - - temp = (u8) val; - ret = pm_chg_write(the_chip, addr, temp); - if (ret) { - pr_err("pm_chg_write to %x value =%d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(reg_fops, get_reg, set_reg, "0x%02llx\n"); - -static int reg_loop; -#define MAX_REG_LOOP_CHAR 10 -static int get_reg_loop_param(char *buf, struct kernel_param *kp) -{ - u8 temp; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - temp = pm_chg_get_regulation_loop(the_chip); - return snprintf(buf, MAX_REG_LOOP_CHAR, "%d", temp); -} -module_param_call(reg_loop, NULL, get_reg_loop_param, - ®_loop, 0644); - -static int max_chg_ma; -#define MAX_MA_CHAR 10 -static int get_max_chg_ma_param(char *buf, struct kernel_param *kp) -{ - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - return snprintf(buf, MAX_MA_CHAR, "%d", the_chip->max_bat_chg_current); -} -module_param_call(max_chg_ma, NULL, get_max_chg_ma_param, - &max_chg_ma, 0644); -static int ibatmax_ma; -static int set_ibat_max(const char *val, struct kernel_param *kp) -{ - int rc; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - - rc = param_set_int(val, kp); - if (rc) { - pr_err("error setting value %d\n", rc); - return rc; - } - - if (abs(ibatmax_ma - the_chip->max_bat_chg_current) - <= the_chip->ibatmax_max_adj_ma) { - rc = pm_chg_ibatmax_set(the_chip, ibatmax_ma); - if (rc) { - pr_err("Failed to set ibatmax rc = %d\n", rc); - return rc; - } - } - - return 0; -} -static int get_ibat_max(char *buf, struct kernel_param *kp) -{ - int ibat_ma; - int rc; - - if (!the_chip) { - pr_err("called before init\n"); - return -EINVAL; - } - - rc = pm_chg_ibatmax_get(the_chip, &ibat_ma); - if (rc) { - pr_err("ibatmax_get error = %d\n", rc); - return rc; - } - - return snprintf(buf, MAX_MA_CHAR, "%d", ibat_ma); -} -module_param_call(ibatmax_ma, set_ibat_max, get_ibat_max, - &ibatmax_ma, 0644); -enum { - BAT_WARM_ZONE, - BAT_COOL_ZONE, -}; -static int get_warm_cool(void *data, u64 * val) -{ - if (!the_chip) { - pr_err("%s called before init\n", __func__); - return -EINVAL; - } - if ((int)data == BAT_WARM_ZONE) - *val = the_chip->is_bat_warm; - if ((int)data == BAT_COOL_ZONE) - *val = the_chip->is_bat_cool; - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(warm_cool_fops, get_warm_cool, NULL, "0x%lld\n"); - -static void create_debugfs_entries(struct pm8921_chg_chip *chip) -{ - int i; - - chip->dent = debugfs_create_dir("pm8921_chg", NULL); - - if (IS_ERR(chip->dent)) { - pr_err("pmic charger couldnt create debugfs dir\n"); - return; - } - - debugfs_create_file("CHG_CNTRL", 0644, chip->dent, - (void *)CHG_CNTRL, ®_fops); - debugfs_create_file("CHG_CNTRL_2", 0644, chip->dent, - (void *)CHG_CNTRL_2, ®_fops); - debugfs_create_file("CHG_CNTRL_3", 0644, chip->dent, - (void *)CHG_CNTRL_3, ®_fops); - debugfs_create_file("PBL_ACCESS1", 0644, chip->dent, - (void *)PBL_ACCESS1, ®_fops); - debugfs_create_file("PBL_ACCESS2", 0644, chip->dent, - (void *)PBL_ACCESS2, ®_fops); - debugfs_create_file("SYS_CONFIG_1", 0644, chip->dent, - (void *)SYS_CONFIG_1, ®_fops); - debugfs_create_file("SYS_CONFIG_2", 0644, chip->dent, - (void *)SYS_CONFIG_2, ®_fops); - debugfs_create_file("CHG_VDD_MAX", 0644, chip->dent, - (void *)CHG_VDD_MAX, ®_fops); - debugfs_create_file("CHG_VDD_SAFE", 0644, chip->dent, - (void *)CHG_VDD_SAFE, ®_fops); - debugfs_create_file("CHG_VBAT_DET", 0644, chip->dent, - (void *)CHG_VBAT_DET, ®_fops); - debugfs_create_file("CHG_IBAT_MAX", 0644, chip->dent, - (void *)CHG_IBAT_MAX, ®_fops); - debugfs_create_file("CHG_IBAT_SAFE", 0644, chip->dent, - (void *)CHG_IBAT_SAFE, ®_fops); - debugfs_create_file("CHG_VIN_MIN", 0644, chip->dent, - (void *)CHG_VIN_MIN, ®_fops); - debugfs_create_file("CHG_VTRICKLE", 0644, chip->dent, - (void *)CHG_VTRICKLE, ®_fops); - debugfs_create_file("CHG_ITRICKLE", 0644, chip->dent, - (void *)CHG_ITRICKLE, ®_fops); - debugfs_create_file("CHG_ITERM", 0644, chip->dent, - (void *)CHG_ITERM, ®_fops); - debugfs_create_file("CHG_TCHG_MAX", 0644, chip->dent, - (void *)CHG_TCHG_MAX, ®_fops); - debugfs_create_file("CHG_TWDOG", 0644, chip->dent, - (void *)CHG_TWDOG, ®_fops); - debugfs_create_file("CHG_TEMP_THRESH", 0644, chip->dent, - (void *)CHG_TEMP_THRESH, ®_fops); - debugfs_create_file("CHG_COMP_OVR", 0644, chip->dent, - (void *)CHG_COMP_OVR, ®_fops); - debugfs_create_file("CHG_BUCK_CTRL_TEST1", 0644, chip->dent, - (void *)CHG_BUCK_CTRL_TEST1, ®_fops); - debugfs_create_file("CHG_BUCK_CTRL_TEST2", 0644, chip->dent, - (void *)CHG_BUCK_CTRL_TEST2, ®_fops); - debugfs_create_file("CHG_BUCK_CTRL_TEST3", 0644, chip->dent, - (void *)CHG_BUCK_CTRL_TEST3, ®_fops); - debugfs_create_file("CHG_TEST", 0644, chip->dent, - (void *)CHG_TEST, ®_fops); - - debugfs_create_file("FSM_STATE", 0644, chip->dent, NULL, - &fsm_fops); - - debugfs_create_file("REGULATION_LOOP_CONTROL", 0644, chip->dent, NULL, - ®_loop_fops); - - debugfs_create_file("BAT_WARM_ZONE", 0644, chip->dent, - (void *)BAT_WARM_ZONE, &warm_cool_fops); - debugfs_create_file("BAT_COOL_ZONE", 0644, chip->dent, - (void *)BAT_COOL_ZONE, &warm_cool_fops); - - for (i = 0; i < ARRAY_SIZE(chg_irq_data); i++) { - if (chip->pmic_chg_irq[chg_irq_data[i].irq_id]) - debugfs_create_file(chg_irq_data[i].name, 0444, - chip->dent, - (void *)chg_irq_data[i].irq_id, - &rt_fops); - } -} - -static int pm8921_charger_suspend_noirq(struct device *dev) -{ - int rc; - struct pm8921_chg_chip *chip = dev_get_drvdata(dev); - - rc = pm_chg_masked_write(chip, CHG_CNTRL, VREF_BATT_THERM_FORCE_ON, 0); - if (rc) - pr_err("Failed to Force Vref therm off rc=%d\n", rc); - - rc = pm8921_chg_set_lpm(chip, 1); - if (rc) - pr_err("Failed to set lpm rc=%d\n", rc); - - pm8921_chg_set_hw_clk_switching(chip); - - return 0; -} - -static int pm8921_charger_resume_noirq(struct device *dev) -{ - int rc; - struct pm8921_chg_chip *chip = dev_get_drvdata(dev); - - rc = pm8921_chg_set_lpm(chip, 0); - if (rc) - pr_err("Failed to set lpm rc=%d\n", rc); - - pm8921_chg_force_19p2mhz_clk(chip); - - rc = pm_chg_masked_write(chip, CHG_CNTRL, VREF_BATT_THERM_FORCE_ON, - VREF_BATT_THERM_FORCE_ON); - if (rc) - pr_err("Failed to Force Vref therm on rc=%d\n", rc); - return 0; -} - -static int pm8921_charger_resume(struct device *dev) -{ - struct pm8921_chg_chip *chip = dev_get_drvdata(dev); - - if (pm8921_chg_is_enabled(chip, LOOP_CHANGE_IRQ)) { - disable_irq_wake(chip->pmic_chg_irq[LOOP_CHANGE_IRQ]); - pm8921_chg_disable_irq(chip, LOOP_CHANGE_IRQ); - } - - if (chip->btc_override && (is_dc_chg_plugged_in(the_chip) || - is_usb_chg_plugged_in(the_chip))) - schedule_delayed_work(&chip->btc_override_work, 0); - - schedule_delayed_work(&chip->update_heartbeat_work, 0); - - return 0; -} - -static int pm8921_charger_suspend(struct device *dev) -{ - struct pm8921_chg_chip *chip = dev_get_drvdata(dev); - - cancel_delayed_work_sync(&chip->update_heartbeat_work); - - if (chip->btc_override) - cancel_delayed_work_sync(&chip->btc_override_work); - - if (is_usb_chg_plugged_in(chip)) { - pm8921_chg_enable_irq(chip, LOOP_CHANGE_IRQ); - enable_irq_wake(chip->pmic_chg_irq[LOOP_CHANGE_IRQ]); - } - - return 0; -} -static int pm8921_charger_probe(struct platform_device *pdev) -{ - int rc = 0; - struct pm8921_chg_chip *chip; - const struct pm8921_charger_platform_data *pdata - = pdev->dev.platform_data; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct pm8921_chg_chip), - GFP_KERNEL); - if (!chip) { - pr_err("Cannot allocate pm_chg_chip\n"); - return -ENOMEM; - } - - chip->dev = &pdev->dev; - chip->ttrkl_time = pdata->ttrkl_time; - chip->update_time = pdata->update_time; - chip->max_voltage_mv = pdata->max_voltage; - chip->alarm_low_mv = pdata->alarm_low_mv; - chip->alarm_high_mv = pdata->alarm_high_mv; - chip->min_voltage_mv = pdata->min_voltage; - chip->safe_current_ma = pdata->safe_current_ma; - chip->uvd_voltage_mv = pdata->uvd_thresh_voltage; - chip->resume_voltage_delta = pdata->resume_voltage_delta; - chip->resume_charge_percent = pdata->resume_charge_percent; - chip->term_current = pdata->term_current; - chip->vbat_channel = pdata->charger_cdata.vbat_channel; - chip->batt_temp_channel = pdata->charger_cdata.batt_temp_channel; - chip->batt_id_channel = pdata->charger_cdata.batt_id_channel; - chip->batt_id_min = pdata->batt_id_min; - chip->batt_id_max = pdata->batt_id_max; - if (pdata->cool_temp != INT_MIN) - chip->cool_temp_dc = pdata->cool_temp * 10; - else - chip->cool_temp_dc = INT_MIN; - - if (pdata->warm_temp != INT_MIN) - chip->warm_temp_dc = pdata->warm_temp * 10; - else - chip->warm_temp_dc = INT_MIN; - - if (pdata->hysteresis_temp) - chip->hysteresis_temp_dc = pdata->hysteresis_temp * 10; - else - chip->hysteresis_temp_dc = TEMP_HYSTERISIS_DECIDEGC; - - chip->temp_check_period = pdata->temp_check_period; - chip->max_bat_chg_current = pdata->max_bat_chg_current; - /* Assign to corresponding module parameter */ - usb_max_current = pdata->usb_max_current; - chip->cool_bat_chg_current = pdata->cool_bat_chg_current; - chip->warm_bat_chg_current = pdata->warm_bat_chg_current; - chip->cool_bat_voltage = pdata->cool_bat_voltage; - chip->warm_bat_voltage = pdata->warm_bat_voltage; - chip->trkl_voltage = pdata->trkl_voltage; - chip->weak_voltage = pdata->weak_voltage; - chip->trkl_current = pdata->trkl_current; - chip->weak_current = pdata->weak_current; - chip->vin_min = pdata->vin_min; - chip->thermal_mitigation = pdata->thermal_mitigation; - chip->thermal_levels = pdata->thermal_levels; - chip->disable_chg_rmvl_wrkarnd = pdata->disable_chg_rmvl_wrkarnd; - chip->enable_tcxo_warmup_delay = pdata->enable_tcxo_warmup_delay; - - chip->cold_thr = pdata->cold_thr; - chip->hot_thr = pdata->hot_thr; - chip->rconn_mohm = pdata->rconn_mohm; - chip->led_src_config = pdata->led_src_config; - chip->has_dc_supply = pdata->has_dc_supply; - chip->battery_less_hardware = pdata->battery_less_hardware; - chip->btc_override = pdata->btc_override; - if (chip->btc_override) { - chip->btc_delay_ms = pdata->btc_delay_ms; - chip->btc_override_cold_decidegc - = pdata->btc_override_cold_degc * 10; - chip->btc_override_hot_decidegc - = pdata->btc_override_hot_degc * 10; - chip->btc_panic_if_cant_stop_chg - = pdata->btc_panic_if_cant_stop_chg; - } - - if (chip->battery_less_hardware) - charging_disabled = 1; - - chip->ibatmax_max_adj_ma = find_ibat_max_adj_ma( - chip->max_bat_chg_current); - - chip->voter = msm_xo_get(MSM_XO_TCXO_D0, "pm8921_charger"); - rc = pm8921_chg_hw_init(chip); - if (rc) { - pr_err("couldn't init hardware rc=%d\n", rc); - goto free_chip; - } - - if (chip->btc_override) - pm8921_chg_btc_override_init(chip); - - chip->stop_chg_upon_expiry = pdata->stop_chg_upon_expiry; - chip->usb_type = POWER_SUPPLY_TYPE_UNKNOWN; - - chip->usb_psy.name = "usb"; - chip->usb_psy.type = POWER_SUPPLY_TYPE_USB; - chip->usb_psy.supplied_to = pm_power_supplied_to; - chip->usb_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to); - chip->usb_psy.properties = pm_power_props_usb; - chip->usb_psy.num_properties = ARRAY_SIZE(pm_power_props_usb); - chip->usb_psy.get_property = pm_power_get_property_usb; - chip->usb_psy.set_property = pm_power_set_property_usb; - chip->usb_psy.property_is_writeable = usb_property_is_writeable; - - chip->dc_psy.name = "pm8921-dc"; - chip->dc_psy.type = POWER_SUPPLY_TYPE_MAINS; - chip->dc_psy.supplied_to = pm_power_supplied_to; - chip->dc_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to); - chip->dc_psy.properties = pm_power_props_mains; - chip->dc_psy.num_properties = ARRAY_SIZE(pm_power_props_mains); - chip->dc_psy.get_property = pm_power_get_property_mains; - - chip->batt_psy.name = "battery"; - chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY; - chip->batt_psy.properties = msm_batt_power_props; - chip->batt_psy.num_properties = ARRAY_SIZE(msm_batt_power_props); - chip->batt_psy.get_property = pm_batt_power_get_property; - chip->batt_psy.external_power_changed = pm_batt_external_power_changed; - rc = power_supply_register(chip->dev, &chip->usb_psy); - if (rc < 0) { - pr_err("power_supply_register usb failed rc = %d\n", rc); - goto free_chip; - } - - rc = power_supply_register(chip->dev, &chip->dc_psy); - if (rc < 0) { - pr_err("power_supply_register usb failed rc = %d\n", rc); - goto unregister_usb; - } - - rc = power_supply_register(chip->dev, &chip->batt_psy); - if (rc < 0) { - pr_err("power_supply_register batt failed rc = %d\n", rc); - goto unregister_dc; - } - - platform_set_drvdata(pdev, chip); - the_chip = chip; - - wake_lock_init(&chip->eoc_wake_lock, WAKE_LOCK_SUSPEND, "pm8921_eoc"); - INIT_DELAYED_WORK(&chip->eoc_work, eoc_worker); - INIT_DELAYED_WORK(&chip->vin_collapse_check_work, - vin_collapse_check_worker); - INIT_DELAYED_WORK(&chip->unplug_check_work, unplug_check_worker); - - INIT_WORK(&chip->bms_notify.work, bms_notify); - INIT_WORK(&chip->battery_id_valid_work, battery_id_valid); - - INIT_DELAYED_WORK(&chip->update_heartbeat_work, update_heartbeat); - INIT_DELAYED_WORK(&chip->btc_override_work, btc_override_worker); - - rc = request_irqs(chip, pdev); - if (rc) { - pr_err("couldn't register interrupts rc=%d\n", rc); - goto unregister_batt; - } - - enable_irq_wake(chip->pmic_chg_irq[USBIN_VALID_IRQ]); - enable_irq_wake(chip->pmic_chg_irq[DCIN_VALID_IRQ]); - enable_irq_wake(chip->pmic_chg_irq[VBATDET_LOW_IRQ]); - enable_irq_wake(chip->pmic_chg_irq[FASTCHG_IRQ]); - - create_debugfs_entries(chip); - - /* determine what state the charger is in */ - determine_initial_state(chip); - - if (chip->update_time) - schedule_delayed_work(&chip->update_heartbeat_work, - round_jiffies_relative(msecs_to_jiffies - (chip->update_time))); - return 0; - -unregister_batt: - wake_lock_destroy(&chip->eoc_wake_lock); - power_supply_unregister(&chip->batt_psy); -unregister_dc: - power_supply_unregister(&chip->dc_psy); -unregister_usb: - power_supply_unregister(&chip->usb_psy); -free_chip: - kfree(chip); - return rc; -} - -static int pm8921_charger_remove(struct platform_device *pdev) -{ - struct pm8921_chg_chip *chip = platform_get_drvdata(pdev); - - free_irqs(chip); - platform_set_drvdata(pdev, NULL); - the_chip = NULL; - kfree(chip); - return 0; -} -static const struct dev_pm_ops pm8921_pm_ops = { - .suspend = pm8921_charger_suspend, - .suspend_noirq = pm8921_charger_suspend_noirq, - .resume_noirq = pm8921_charger_resume_noirq, - .resume = pm8921_charger_resume, -}; -static struct platform_driver pm8921_charger_driver = { - .probe = pm8921_charger_probe, - .remove = pm8921_charger_remove, - .driver = { - .name = PM8921_CHARGER_DEV_NAME, - .owner = THIS_MODULE, - .pm = &pm8921_pm_ops, - }, -}; - -static int __init pm8921_charger_init(void) -{ - return platform_driver_register(&pm8921_charger_driver); -} - -static void __exit pm8921_charger_exit(void) -{ - platform_driver_unregister(&pm8921_charger_driver); -} - -late_initcall(pm8921_charger_init); -module_exit(pm8921_charger_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8921 charger/battery driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8921_CHARGER_DEV_NAME); diff --git a/drivers/power/pm8xxx-ccadc.c b/drivers/power/pm8xxx-ccadc.c deleted file mode 100644 index 987592ececf6b57e958c2a13f97be07902ed0709..0000000000000000000000000000000000000000 --- a/drivers/power/pm8xxx-ccadc.c +++ /dev/null @@ -1,877 +0,0 @@ -/* Copyright (c) 2011-2013, 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. - * - */ -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CCADC_ANA_PARAM 0x240 -#define CCADC_DIG_PARAM 0x241 -#define CCADC_RSV 0x242 -#define CCADC_DATA0 0x244 -#define CCADC_DATA1 0x245 -#define CCADC_OFFSET_TRIM1 0x34A -#define CCADC_OFFSET_TRIM0 0x34B -#define CCADC_FULLSCALE_TRIM1 0x34C -#define CCADC_FULLSCALE_TRIM0 0x34D - -/* note : TRIM1 is the msb and TRIM0 is the lsb */ -#define ADC_ARB_SECP_CNTRL 0x190 -#define ADC_ARB_SECP_AMUX_CNTRL 0x191 -#define ADC_ARB_SECP_ANA_PARAM 0x192 -#define ADC_ARB_SECP_DIG_PARAM 0x193 -#define ADC_ARB_SECP_RSV 0x194 -#define ADC_ARB_SECP_DATA1 0x195 -#define ADC_ARB_SECP_DATA0 0x196 - -#define ADC_ARB_BMS_CNTRL 0x18D - -#define START_CONV_BIT BIT(7) -#define EOC_CONV_BIT BIT(6) -#define SEL_CCADC_BIT BIT(1) -#define EN_ARB_BIT BIT(0) - -#define CCADC_CALIB_DIG_PARAM 0xE3 -#define CCADC_CALIB_RSV_GND 0x40 -#define CCADC_CALIB_RSV_25MV 0x80 -#define CCADC_CALIB_ANA_PARAM 0x1B -#define SAMPLE_COUNT 16 -#define ADC_WAIT_COUNT 10 - -#define CCADC_MAX_25MV 30000 -#define CCADC_MIN_25MV 20000 -#define CCADC_MAX_0UV -4000 -#define CCADC_MIN_0UV -7000 - -#define CCADC_INTRINSIC_OFFSET 0xC000 - -struct pm8xxx_ccadc_chip { - struct device *dev; - struct dentry *dent; - unsigned int batt_temp_channel; - u16 ccadc_offset; - int ccadc_gain_uv; - unsigned int revision; - unsigned int calib_delay_ms; - unsigned long last_calib_time; - int last_calib_temp; - int eoc_irq; - int r_sense_uohm; - struct delayed_work calib_ccadc_work; - struct mutex calib_mutex; - bool periodic_wakeup; -}; - -static struct pm8xxx_ccadc_chip *the_chip; - -#ifdef DEBUG -static s64 microvolt_to_ccadc_reading(struct pm8xxx_ccadc_chip *chip, s64 cc) -{ - return div_s64(uv * CCADC_READING_RESOLUTION_D, - CCADC_READING_RESOLUTION_N); -} -#endif - -static int cc_adjust_for_offset(u16 raw) -{ - /* this has the intrinsic offset */ - return (int)raw - the_chip->ccadc_offset; -} - -#define GAIN_REFERENCE_UV 25000 -/* - * gain compensation for ccadc readings - common for vsense based and - * couloumb counter based readings - */ -s64 pm8xxx_cc_adjust_for_gain(s64 uv) -{ - if (the_chip == NULL || the_chip->ccadc_gain_uv == 0) - return uv; - - return div_s64(uv * GAIN_REFERENCE_UV, the_chip->ccadc_gain_uv); -} -EXPORT_SYMBOL(pm8xxx_cc_adjust_for_gain); - -static int pm_ccadc_masked_write(struct pm8xxx_ccadc_chip *chip, u16 addr, - u8 mask, u8 val) -{ - int rc; - u8 reg; - - rc = pm8xxx_readb(chip->dev->parent, addr, ®); - if (rc) { - pr_err("read failed addr = %03X, rc = %d\n", addr, rc); - return rc; - } - reg &= ~mask; - reg |= val & mask; - rc = pm8xxx_writeb(chip->dev->parent, addr, reg); - if (rc) { - pr_err("write failed addr = %03X, rc = %d\n", addr, rc); - return rc; - } - return 0; -} - -#define REG_SBI_CONFIG 0x04F -#define PAGE3_ENABLE_MASK 0x6 -static int calib_ccadc_enable_trim_access(struct pm8xxx_ccadc_chip *chip, - u8 *sbi_config) -{ - u8 reg; - int rc; - - rc = pm8xxx_readb(chip->dev->parent, REG_SBI_CONFIG, sbi_config); - if (rc) { - pr_err("error = %d reading sbi config reg\n", rc); - return rc; - } - - reg = *sbi_config | PAGE3_ENABLE_MASK; - return pm8xxx_writeb(chip->dev->parent, REG_SBI_CONFIG, reg); -} - -static int calib_ccadc_restore_trim_access(struct pm8xxx_ccadc_chip *chip, - u8 sbi_config) -{ - return pm8xxx_writeb(chip->dev->parent, REG_SBI_CONFIG, sbi_config); -} - -static int calib_ccadc_enable_arbiter(struct pm8xxx_ccadc_chip *chip) -{ - int rc; - - /* enable Arbiter, must be sent twice */ - rc = pm_ccadc_masked_write(chip, ADC_ARB_SECP_CNTRL, - SEL_CCADC_BIT | EN_ARB_BIT, SEL_CCADC_BIT | EN_ARB_BIT); - if (rc < 0) { - pr_err("error = %d enabling arbiter for offset\n", rc); - return rc; - } - rc = pm_ccadc_masked_write(chip, ADC_ARB_SECP_CNTRL, - SEL_CCADC_BIT | EN_ARB_BIT, SEL_CCADC_BIT | EN_ARB_BIT); - if (rc < 0) { - pr_err("error = %d writing ADC_ARB_SECP_CNTRL\n", rc); - return rc; - } - return 0; -} - -static int calib_start_conv(struct pm8xxx_ccadc_chip *chip, - u16 *result) -{ - int rc, i; - u8 data_msb, data_lsb, reg; - - /* Start conversion */ - rc = pm_ccadc_masked_write(chip, ADC_ARB_SECP_CNTRL, - START_CONV_BIT, START_CONV_BIT); - if (rc < 0) { - pr_err("error = %d starting offset meas\n", rc); - return rc; - } - - /* Wait for End of conversion */ - for (i = 0; i < ADC_WAIT_COUNT; i++) { - rc = pm8xxx_readb(chip->dev->parent, - ADC_ARB_SECP_CNTRL, ®); - if (rc < 0) { - pr_err("error = %d read eoc for offset\n", rc); - return rc; - } - if ((reg & (START_CONV_BIT | EOC_CONV_BIT)) != EOC_CONV_BIT) - msleep(20); - else - break; - } - if (i == ADC_WAIT_COUNT) { - pr_err("waited too long for offset eoc returning -EBUSY\n"); - return -EBUSY; - } - - rc = pm8xxx_readb(chip->dev->parent, ADC_ARB_SECP_DATA0, &data_lsb); - if (rc < 0) { - pr_err("error = %d reading offset lsb\n", rc); - return rc; - } - - rc = pm8xxx_readb(chip->dev->parent, ADC_ARB_SECP_DATA1, &data_msb); - if (rc < 0) { - pr_err("error = %d reading offset msb\n", rc); - return rc; - } - - *result = (data_msb << 8) | data_lsb; - return 0; -} - -static int calib_ccadc_read_trim(struct pm8xxx_ccadc_chip *chip, - int addr, u8 *data_msb, u8 *data_lsb) -{ - int rc; - u8 sbi_config; - - calib_ccadc_enable_trim_access(chip, &sbi_config); - rc = pm8xxx_readb(chip->dev->parent, addr, data_msb); - if (rc < 0) { - pr_err("error = %d read msb\n", rc); - return rc; - } - rc = pm8xxx_readb(chip->dev->parent, addr + 1, data_lsb); - if (rc < 0) { - pr_err("error = %d read lsb\n", rc); - return rc; - } - calib_ccadc_restore_trim_access(chip, sbi_config); - return 0; -} - -static void calib_ccadc_read_offset_and_gain(struct pm8xxx_ccadc_chip *chip, - int *gain, u16 *offset) -{ - u8 data_msb; - u8 data_lsb; - int rc; - - rc = calib_ccadc_read_trim(chip, CCADC_FULLSCALE_TRIM1, - &data_msb, &data_lsb); - *gain = (data_msb << 8) | data_lsb; - - rc = calib_ccadc_read_trim(chip, CCADC_OFFSET_TRIM1, - &data_msb, &data_lsb); - *offset = (data_msb << 8) | data_lsb; - - pr_debug("raw gain trim = 0x%x offset trim =0x%x\n", *gain, *offset); - *gain = pm8xxx_ccadc_reading_to_microvolt(chip->revision, - (s64)*gain - *offset); - pr_debug("gain uv = %duV offset=0x%x\n", *gain, *offset); -} - -#define CCADC_PROGRAM_TRIM_COUNT 2 -#define ADC_ARB_BMS_CNTRL_CCADC_SHIFT 4 -#define ADC_ARB_BMS_CNTRL_CONV_MASK 0x03 -#define BMS_CONV_IN_PROGRESS 0x2 - -static int calib_ccadc_program_trim(struct pm8xxx_ccadc_chip *chip, - int addr, u8 data_msb, u8 data_lsb, - int wait) -{ - int i, rc, loop; - u8 cntrl, sbi_config; - bool in_progress = 0; - - loop = wait ? CCADC_PROGRAM_TRIM_COUNT : 0; - - calib_ccadc_enable_trim_access(chip, &sbi_config); - - for (i = 0; i < loop; i++) { - rc = pm8xxx_readb(chip->dev->parent, ADC_ARB_BMS_CNTRL, &cntrl); - if (rc < 0) { - pr_err("error = %d reading ADC_ARB_BMS_CNTRL\n", rc); - return rc; - } - - /* break if a ccadc conversion is not happening */ - in_progress = (((cntrl >> ADC_ARB_BMS_CNTRL_CCADC_SHIFT) - & ADC_ARB_BMS_CNTRL_CONV_MASK) == BMS_CONV_IN_PROGRESS); - - if (!in_progress) - break; - } - - if (in_progress) { - pr_debug("conv in progress cannot write trim,returing EBUSY\n"); - return -EBUSY; - } - - rc = pm8xxx_writeb(chip->dev->parent, addr, data_msb); - if (rc < 0) { - pr_err("error = %d write msb = 0x%x\n", rc, data_msb); - return rc; - } - rc = pm8xxx_writeb(chip->dev->parent, addr + 1, data_lsb); - if (rc < 0) { - pr_err("error = %d write lsb = 0x%x\n", rc, data_lsb); - return rc; - } - calib_ccadc_restore_trim_access(chip, sbi_config); - return 0; -} - -static int get_batt_temp(struct pm8xxx_ccadc_chip *chip, int *batt_temp) -{ - int rc; - struct pm8xxx_adc_chan_result result; - - rc = pm8xxx_adc_read(chip->batt_temp_channel, &result); - if (rc) { - pr_err("error reading batt_temp_channel = %d, rc = %d\n", - chip->batt_temp_channel, rc); - return rc; - } - *batt_temp = result.physical; - pr_debug("batt_temp phy = %lld meas = 0x%llx\n", result.physical, - result.measurement); - return 0; -} - -static int get_current_time(unsigned long *now_tm_sec) -{ - struct rtc_time tm; - struct rtc_device *rtc; - int rc; - - rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); - if (rtc == NULL) { - pr_err("%s: unable to open rtc device (%s)\n", - __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); - return -EINVAL; - } - - rc = rtc_read_time(rtc, &tm); - if (rc) { - pr_err("Error reading rtc device (%s) : %d\n", - CONFIG_RTC_HCTOSYS_DEVICE, rc); - return rc; - } - - rc = rtc_valid_tm(&tm); - if (rc) { - pr_err("Invalid RTC time (%s): %d\n", - CONFIG_RTC_HCTOSYS_DEVICE, rc); - return rc; - } - rtc_tm_to_time(&tm, now_tm_sec); - - return 0; -} - -static void __pm8xxx_calib_ccadc(int sample_count) -{ - u8 data_msb, data_lsb, sec_cntrl; - int result_offset, result_gain; - u16 result; - int i, rc; - - if (!the_chip) { - pr_err("chip not initialized\n"); - return; - } - - pr_debug("sample_count = %d\n", sample_count); - - mutex_lock(&the_chip->calib_mutex); - rc = pm8xxx_readb(the_chip->dev->parent, - ADC_ARB_SECP_CNTRL, &sec_cntrl); - if (rc < 0) { - pr_err("error = %d reading ADC_ARB_SECP_CNTRL\n", rc); - goto calibration_unlock; - } - - rc = calib_ccadc_enable_arbiter(the_chip); - if (rc < 0) { - pr_err("error = %d enabling arbiter for offset\n", rc); - goto bail; - } - - /* - * Set decimation ratio to 4k, lower ratio may be used in order to speed - * up, pending verification through bench - */ - rc = pm8xxx_writeb(the_chip->dev->parent, ADC_ARB_SECP_DIG_PARAM, - CCADC_CALIB_DIG_PARAM); - if (rc < 0) { - pr_err("error = %d writing ADC_ARB_SECP_DIG_PARAM\n", rc); - goto bail; - } - - result_offset = 0; - for (i = 0; i < sample_count; i++) { - /* Short analog inputs to CCADC internally to ground */ - rc = pm8xxx_writeb(the_chip->dev->parent, ADC_ARB_SECP_RSV, - CCADC_CALIB_RSV_GND); - if (rc < 0) { - pr_err("error = %d selecting gnd voltage\n", rc); - goto bail; - } - - /* Enable CCADC */ - rc = pm8xxx_writeb(the_chip->dev->parent, - ADC_ARB_SECP_ANA_PARAM, CCADC_CALIB_ANA_PARAM); - if (rc < 0) { - pr_err("error = %d enabling ccadc\n", rc); - goto bail; - } - - rc = calib_start_conv(the_chip, &result); - if (rc < 0) { - pr_err("error = %d for zero volt measurement\n", rc); - goto bail; - } - - result_offset += result; - } - - result_offset = result_offset / sample_count; - - - pr_debug("offset result_offset = 0x%x, voltage = %llduV\n", - result_offset, - pm8xxx_ccadc_reading_to_microvolt(the_chip->revision, - ((s64)result_offset - CCADC_INTRINSIC_OFFSET))); - - the_chip->ccadc_offset = result_offset; - data_msb = the_chip->ccadc_offset >> 8; - data_lsb = the_chip->ccadc_offset; - - rc = calib_ccadc_program_trim(the_chip, CCADC_OFFSET_TRIM1, - data_msb, data_lsb, 1); - if (rc) { - pr_debug("error = %d programming offset trim 0x%02x 0x%02x\n", - rc, data_msb, data_lsb); - /* enable the interrupt and write it when it fires */ - enable_irq(the_chip->eoc_irq); - } - - rc = calib_ccadc_enable_arbiter(the_chip); - if (rc < 0) { - pr_err("error = %d enabling arbiter for gain\n", rc); - goto bail; - } - - /* - * Set decimation ratio to 4k, lower ratio may be used in order to speed - * up, pending verification through bench - */ - rc = pm8xxx_writeb(the_chip->dev->parent, ADC_ARB_SECP_DIG_PARAM, - CCADC_CALIB_DIG_PARAM); - if (rc < 0) { - pr_err("error = %d enabling decimation ration for gain\n", rc); - goto bail; - } - - result_gain = 0; - for (i = 0; i < sample_count; i++) { - rc = pm8xxx_writeb(the_chip->dev->parent, - ADC_ARB_SECP_RSV, CCADC_CALIB_RSV_25MV); - if (rc < 0) { - pr_err("error = %d selecting 25mV for gain\n", rc); - goto bail; - } - - /* Enable CCADC */ - rc = pm8xxx_writeb(the_chip->dev->parent, - ADC_ARB_SECP_ANA_PARAM, CCADC_CALIB_ANA_PARAM); - if (rc < 0) { - pr_err("error = %d enabling ccadc\n", rc); - goto bail; - } - - rc = calib_start_conv(the_chip, &result); - if (rc < 0) { - pr_err("error = %d for adc reading 25mV\n", rc); - goto bail; - } - - result_gain += result; - } - result_gain = result_gain / sample_count; - - /* - * result_offset includes INTRINSIC OFFSET - * the_chip->ccadc_gain_uv will be the actual voltage - * measured for 25000UV - */ - the_chip->ccadc_gain_uv = pm8xxx_ccadc_reading_to_microvolt( - the_chip->revision, - ((s64)result_gain - result_offset)); - - pr_debug("gain result_gain = 0x%x, voltage = %d microVolts\n", - result_gain, the_chip->ccadc_gain_uv); - - data_msb = result_gain >> 8; - data_lsb = result_gain; - rc = calib_ccadc_program_trim(the_chip, CCADC_FULLSCALE_TRIM1, - data_msb, data_lsb, 0); - if (rc) - pr_debug("error = %d programming gain trim\n", rc); -bail: - pm8xxx_writeb(the_chip->dev->parent, ADC_ARB_SECP_CNTRL, sec_cntrl); -calibration_unlock: - mutex_unlock(&the_chip->calib_mutex); -} - -static void pm8xxx_calib_ccadc_quick(void) -{ - __pm8xxx_calib_ccadc(2); -} - -void pm8xxx_calib_ccadc(void) -{ - __pm8xxx_calib_ccadc(SAMPLE_COUNT); -} -EXPORT_SYMBOL(pm8xxx_calib_ccadc); - -static void calibrate_ccadc_work(struct work_struct *work) -{ - struct pm8xxx_ccadc_chip *chip = container_of(work, - struct pm8xxx_ccadc_chip, calib_ccadc_work.work); - - pm8xxx_calib_ccadc(); - schedule_delayed_work(&chip->calib_ccadc_work, - round_jiffies_relative(msecs_to_jiffies - (chip->calib_delay_ms))); -} - -static irqreturn_t pm8921_bms_ccadc_eoc_handler(int irq, void *data) -{ - u8 data_msb, data_lsb; - struct pm8xxx_ccadc_chip *chip = data; - int rc; - - if (!the_chip) - goto out; - - pr_debug("irq = %d triggered\n", irq); - data_msb = chip->ccadc_offset >> 8; - data_lsb = chip->ccadc_offset; - - rc = calib_ccadc_program_trim(chip, CCADC_OFFSET_TRIM1, - data_msb, data_lsb, 0); - disable_irq_nosync(chip->eoc_irq); - -out: - return IRQ_HANDLED; -} - -#define CCADC_IBAT_DIG_PARAM 0xA3 -#define CCADC_IBAT_RSV 0x10 -#define CCADC_IBAT_ANA_PARAM 0x1A -static int ccadc_get_rsense_voltage(int *voltage_uv) -{ - u16 raw; - int result; - int rc = 0; - - rc = calib_ccadc_enable_arbiter(the_chip); - if (rc < 0) { - pr_err("error = %d enabling arbiter for offset\n", rc); - return rc; - } - - rc = pm8xxx_writeb(the_chip->dev->parent, ADC_ARB_SECP_DIG_PARAM, - CCADC_IBAT_DIG_PARAM); - if (rc < 0) { - pr_err("error = %d writing ADC_ARB_SECP_DIG_PARAM\n", rc); - return rc; - } - - rc = pm8xxx_writeb(the_chip->dev->parent, ADC_ARB_SECP_RSV, - CCADC_IBAT_RSV); - if (rc < 0) { - pr_err("error = %d selecting rsense\n", rc); - return rc; - } - - rc = pm8xxx_writeb(the_chip->dev->parent, - ADC_ARB_SECP_ANA_PARAM, CCADC_IBAT_ANA_PARAM); - if (rc < 0) { - pr_err("error = %d enabling ccadc\n", rc); - return rc; - } - - rc = calib_start_conv(the_chip, &raw); - if (rc < 0) { - pr_err("error = %d for zero volt measurement\n", rc); - return rc; - } - - pr_debug("Vsense raw = 0x%x\n", raw); - result = cc_adjust_for_offset(raw); - pr_debug("Vsense after offset raw = 0x%x offset=0x%x\n", - result, - the_chip->ccadc_offset); - *voltage_uv = pm8xxx_ccadc_reading_to_microvolt(the_chip->revision, - ((s64)result)); - pr_debug("Vsense before gain of %d = %d uV\n", the_chip->ccadc_gain_uv, - *voltage_uv); - *voltage_uv = pm8xxx_cc_adjust_for_gain(*voltage_uv); - - pr_debug("Vsense = %d uV\n", *voltage_uv); - return 0; -} - -int pm8xxx_ccadc_get_battery_current(int *bat_current_ua) -{ - int voltage_uv = 0, rc; - - rc = ccadc_get_rsense_voltage(&voltage_uv); - if (rc) { - pr_err("cant get voltage across rsense rc = %d\n", rc); - return rc; - } - - *bat_current_ua = div_s64((s64)voltage_uv * 1000000LL, - the_chip->r_sense_uohm); - /* - * ccadc reads +ve current when the battery is charging - * We need to return -ve if the battery is charging - */ - *bat_current_ua = -1 * (*bat_current_ua); - pr_debug("bat current = %d ma\n", *bat_current_ua); - return 0; -} -EXPORT_SYMBOL(pm8xxx_ccadc_get_battery_current); - -static int get_reg(void *data, u64 * val) -{ - int addr = (int)data; - int ret; - u8 temp; - - ret = pm8xxx_readb(the_chip->dev->parent, addr, &temp); - if (ret) { - pr_err("pm8xxx_readb to %x value = %d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - *val = temp; - return 0; -} - -static int set_reg(void *data, u64 val) -{ - int addr = (int)data; - int ret; - u8 temp; - - temp = (u8) val; - ret = pm8xxx_writeb(the_chip->dev->parent, addr, temp); - if (ret) { - pr_err("pm8xxx_writeb to %x value = %d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(reg_fops, get_reg, set_reg, "0x%02llx\n"); - -static int get_calc(void *data, u64 * val) -{ - int ibat, rc; - - rc = pm8xxx_ccadc_get_battery_current(&ibat); - *val = ibat; - return rc; -} -DEFINE_SIMPLE_ATTRIBUTE(calc_fops, get_calc, NULL, "%lld\n"); - -static void create_debugfs_entries(struct pm8xxx_ccadc_chip *chip) -{ - chip->dent = debugfs_create_dir("pm8xxx-ccadc", NULL); - - if (IS_ERR(chip->dent)) { - pr_err("ccadc couldnt create debugfs dir\n"); - return; - } - - debugfs_create_file("CCADC_ANA_PARAM", 0644, chip->dent, - (void *)CCADC_ANA_PARAM, ®_fops); - debugfs_create_file("CCADC_DIG_PARAM", 0644, chip->dent, - (void *)CCADC_DIG_PARAM, ®_fops); - debugfs_create_file("CCADC_RSV", 0644, chip->dent, - (void *)CCADC_RSV, ®_fops); - debugfs_create_file("CCADC_DATA0", 0644, chip->dent, - (void *)CCADC_DATA0, ®_fops); - debugfs_create_file("CCADC_DATA1", 0644, chip->dent, - (void *)CCADC_DATA1, ®_fops); - debugfs_create_file("CCADC_OFFSET_TRIM1", 0644, chip->dent, - (void *)CCADC_OFFSET_TRIM1, ®_fops); - debugfs_create_file("CCADC_OFFSET_TRIM0", 0644, chip->dent, - (void *)CCADC_OFFSET_TRIM0, ®_fops); - debugfs_create_file("CCADC_FULLSCALE_TRIM1", 0644, chip->dent, - (void *)CCADC_FULLSCALE_TRIM1, ®_fops); - debugfs_create_file("CCADC_FULLSCALE_TRIM0", 0644, chip->dent, - (void *)CCADC_FULLSCALE_TRIM0, ®_fops); - - debugfs_create_file("show_ibatt", 0644, chip->dent, - (void *)0, &calc_fops); -} - -static int pm8xxx_ccadc_probe(struct platform_device *pdev) -{ - int rc = 0; - struct pm8xxx_ccadc_chip *chip; - struct resource *res; - const struct pm8xxx_ccadc_platform_data *pdata - = pdev->dev.platform_data; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - "PM8921_BMS_CCADC_EOC"); - if (!res) { - pr_err("failed to get irq\n"); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct pm8xxx_ccadc_chip), GFP_KERNEL); - if (!chip) { - pr_err("Cannot allocate pm_bms_chip\n"); - return -ENOMEM; - } - chip->dev = &pdev->dev; - chip->revision = pm8xxx_get_revision(chip->dev->parent); - chip->eoc_irq = res->start; - chip->r_sense_uohm = pdata->r_sense_uohm; - chip->calib_delay_ms = pdata->calib_delay_ms; - chip->batt_temp_channel = pdata->ccadc_cdata.batt_temp_channel; - chip->periodic_wakeup = pdata->periodic_wakeup; - mutex_init(&chip->calib_mutex); - - calib_ccadc_read_offset_and_gain(chip, - &chip->ccadc_gain_uv, - &chip->ccadc_offset); - irq_set_status_flags(chip->eoc_irq, IRQ_NOAUTOEN); - rc = request_irq(chip->eoc_irq, - pm8921_bms_ccadc_eoc_handler, IRQF_TRIGGER_RISING, - "bms_eoc_ccadc", chip); - if (rc) { - pr_err("failed to request %d irq rc= %d\n", chip->eoc_irq, rc); - goto free_chip; - } - - platform_set_drvdata(pdev, chip); - the_chip = chip; - INIT_DELAYED_WORK(&chip->calib_ccadc_work, calibrate_ccadc_work); - schedule_delayed_work(&chip->calib_ccadc_work, 0); - - create_debugfs_entries(chip); - - return 0; - -free_chip: - mutex_destroy(&chip->calib_mutex); - kfree(chip); - return rc; -} - -static int pm8xxx_ccadc_remove(struct platform_device *pdev) -{ - struct pm8xxx_ccadc_chip *chip = platform_get_drvdata(pdev); - - debugfs_remove_recursive(chip->dent); - the_chip = NULL; - kfree(chip); - return 0; -} - -static int pm8xxx_ccadc_suspend(struct device *dev) -{ - struct pm8xxx_ccadc_chip *chip = dev_get_drvdata(dev); - - cancel_delayed_work_sync(&chip->calib_ccadc_work); - - return 0; -} - -#define CCADC_CALIB_TEMP_THRESH 20 -static int pm8xxx_ccadc_resume(struct device *dev) -{ - int rc, batt_temp, delta_temp; - unsigned long current_time_sec; - unsigned long time_since_last_calib; - - rc = get_batt_temp(the_chip, &batt_temp); - if (rc) { - pr_err("unable to get batt_temp: %d\n", rc); - return 0; - } - rc = get_current_time(¤t_time_sec); - if (rc) { - pr_err("unable to get current time: %d\n", rc); - return 0; - } - - if (the_chip->periodic_wakeup) { - pm8xxx_calib_ccadc_quick(); - return 0; - } - - if (current_time_sec > the_chip->last_calib_time) { - time_since_last_calib = current_time_sec - - the_chip->last_calib_time; - delta_temp = abs(batt_temp - the_chip->last_calib_temp); - pr_debug("time since last calib: %lu, delta_temp = %d\n", - time_since_last_calib, delta_temp); - if (time_since_last_calib >= the_chip->calib_delay_ms/1000 - || delta_temp > CCADC_CALIB_TEMP_THRESH) { - the_chip->last_calib_time = current_time_sec; - the_chip->last_calib_temp = batt_temp; - schedule_delayed_work(&the_chip->calib_ccadc_work, 0); - } else { - schedule_delayed_work(&the_chip->calib_ccadc_work, - msecs_to_jiffies(the_chip->calib_delay_ms - - (time_since_last_calib * 1000))); - } - } - - return 0; -} - -static const struct dev_pm_ops pm8xxx_ccadc_pm_ops = { - .suspend = pm8xxx_ccadc_suspend, - .resume = pm8xxx_ccadc_resume, -}; - -static struct platform_driver pm8xxx_ccadc_driver = { - .probe = pm8xxx_ccadc_probe, - .remove = pm8xxx_ccadc_remove, - .driver = { - .name = PM8XXX_CCADC_DEV_NAME, - .owner = THIS_MODULE, - .pm = &pm8xxx_ccadc_pm_ops, - }, -}; - -static int __init pm8xxx_ccadc_init(void) -{ - return platform_driver_register(&pm8xxx_ccadc_driver); -} - -static void __exit pm8xxx_ccadc_exit(void) -{ - platform_driver_unregister(&pm8xxx_ccadc_driver); -} - -module_init(pm8xxx_ccadc_init); -module_exit(pm8xxx_ccadc_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8XXX ccadc driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_CCADC_DEV_NAME); diff --git a/drivers/power/pmic8058-charger.c b/drivers/power/pmic8058-charger.c deleted file mode 100644 index a1af3296e4a9eaee98a6379c0e905e48b64ac810..0000000000000000000000000000000000000000 --- a/drivers/power/pmic8058-charger.c +++ /dev/null @@ -1,2047 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* Config Regs and their bits*/ -#define PM8058_CHG_TEST 0x75 -#define IGNORE_LL 2 -#define PM8058_CHG_TEST_2 0xEA -#define PM8058_CHG_TEST_3 0xEB -#define PM8058_OVP_TEST_REG 0xF6 -#define FORCE_OVP_OFF 3 - -#define PM8058_CHG_CNTRL 0x1E -#define CHG_TRICKLE_EN 7 -#define CHG_USB_SUSPEND 6 -#define CHG_IMON_CAL 5 -#define CHG_IMON_GAIN 4 -#define CHG_CHARGE_BAT 3 -#define CHG_VBUS_FROM_BOOST_OVRD 2 -#define CHG_CHARGE_DIS 1 -#define CHG_VCP_EN 0 - -#define PM8058_CHG_CNTRL_2 0xD8 -#define ATC_DIS 7 /* coincell backed */ -#define CHARGE_AUTO_DIS 6 -#define DUMB_CHG_OVRD 5 /* coincell backed */ -#define ENUM_DONE 4 -#define CHG_TEMP_MODE 3 -#define CHG_BATT_TEMP_DIS 1 /* coincell backed */ -#define CHG_FAILED_CLEAR 0 - -#define PM8058_CHG_VMAX_SEL 0x21 -#define PM8058_CHG_VBAT_DET 0xD9 -#define PM8058_CHG_IMAX 0x1F -#define PM8058_CHG_TRICKLE 0xDB -#define PM8058_CHG_ITERM 0xDC -#define PM8058_CHG_TTRKL_MAX 0xE1 -#define PM8058_CHG_TCHG_MAX 0xE4 -#define PM8058_CHG_TEMP_THRESH 0xE2 -#define PM8058_CHG_TEMP_REG 0xE3 -#define PM8058_CHG_PULSE 0x22 - -/* IRQ STATUS and CLEAR */ -#define PM8058_CHG_STATUS_CLEAR_IRQ_1 0x31 -#define PM8058_CHG_STATUS_CLEAR_IRQ_3 0x33 -#define PM8058_CHG_STATUS_CLEAR_IRQ_10 0xB3 -#define PM8058_CHG_STATUS_CLEAR_IRQ_11 0xB4 - -/* IRQ MASKS */ -#define PM8058_CHG_MASK_IRQ_1 0x38 - -#define PM8058_CHG_MASK_IRQ_3 0x3A -#define PM8058_CHG_MASK_IRQ_10 0xBA -#define PM8058_CHG_MASK_IRQ_11 0xBB - -/* IRQ Real time status regs */ -#define PM8058_CHG_STATUS_RT_1 0x3F -#define STATUS_RTCHGVAL 7 -#define STATUS_RTCHGINVAL 6 -#define STATUS_RTBATT_REPLACE 5 -#define STATUS_RTVBATDET_LOW 4 -#define STATUS_RTCHGILIM 3 -#define STATUS_RTPCTDONE 1 -#define STATUS_RTVCP 0 -#define PM8058_CHG_STATUS_RT_3 0x41 -#define PM8058_CHG_STATUS_RT_10 0xC1 -#define PM8058_CHG_STATUS_RT_11 0xC2 - -/* VTRIM */ -#define PM8058_CHG_VTRIM 0x1D -#define PM8058_CHG_VBATDET_TRIM 0x1E -#define PM8058_CHG_ITRIM 0x1F -#define PM8058_CHG_TTRIM 0x20 - -#define AUTO_CHARGING_VMAXSEL 4200 -#define AUTO_CHARGING_FAST_TIME_MAX_MINUTES 512 -#define AUTO_CHARGING_TRICKLE_TIME_MINUTES 30 -#define AUTO_CHARGING_VEOC_ITERM 100 -#define AUTO_CHARGING_IEOC_ITERM 160 -#define AUTO_CHARGING_RESUME_MV 4100 - -#define AUTO_CHARGING_VBATDET 4150 -#define AUTO_CHARGING_VBATDET_DEBOUNCE_TIME_MS 3000 -#define AUTO_CHARGING_VEOC_VBATDET 4100 -#define AUTO_CHARGING_VEOC_TCHG 16 -#define AUTO_CHARGING_VEOC_TCHG_FINAL_CYCLE 32 -#define AUTO_CHARGING_VEOC_BEGIN_TIME_MS 5400000 - -#define AUTO_CHARGING_VEOC_VBAT_LOW_CHECK_TIME_MS 60000 -#define AUTO_CHARGING_RESUME_CHARGE_DETECTION_COUNTER 5 - -#define AUTO_CHARGING_DONE_CHECK_TIME_MS 1000 - -#define PM8058_CHG_I_STEP_MA 50 -#define PM8058_CHG_I_MIN_MA 50 -#define PM8058_CHG_T_TCHG_SHIFT 2 -#define PM8058_CHG_I_TERM_STEP_MA 10 -#define PM8058_CHG_V_STEP_MV 25 -#define PM8058_CHG_V_MIN_MV 2400 -/* - * enum pmic_chg_interrupts: pmic interrupts - * @CHGVAL_IRQ: charger V between 3.3 and 7.9 - * @CHGINVAL_IRQ: charger V outside 3.3 and 7.9 - * @VBATDET_LOW_IRQ: VBAT < VBATDET - * @VCP_IRQ: VDD went below VBAT: BAT_FET is turned on - * @CHGILIM_IRQ: mA consumed>IMAXSEL: chgloop draws less mA - * @ATC_DONE_IRQ: Auto Trickle done - * @ATCFAIL_IRQ: Auto Trickle fail - * @AUTO_CHGDONE_IRQ: Auto chg done - * @AUTO_CHGFAIL_IRQ: time exceeded w/o reaching term current - * @CHGSTATE_IRQ: something happend causing a state change - * @FASTCHG_IRQ: trkl charging completed: moving to fastchg - * @CHG_END_IRQ: mA has dropped to termination current - * @BATTTEMP_IRQ: batt temp is out of range - * @CHGHOT_IRQ: the pass device is too hot - * @CHGTLIMIT_IRQ: unused - * @CHG_GONE_IRQ: charger was removed - * @VCPMAJOR_IRQ: vcp major - * @VBATDET_IRQ: VBAT >= VBATDET - * @BATFET_IRQ: BATFET closed - * @BATT_REPLACE_IRQ: - * @BATTCONNECT_IRQ: - */ -enum pmic_chg_interrupts { - CHGVAL_IRQ, - CHGINVAL_IRQ, - VBATDET_LOW_IRQ, - VCP_IRQ, - CHGILIM_IRQ, - ATC_DONE_IRQ, - ATCFAIL_IRQ, - AUTO_CHGDONE_IRQ, - AUTO_CHGFAIL_IRQ, - CHGSTATE_IRQ, - FASTCHG_IRQ, - CHG_END_IRQ, - BATTTEMP_IRQ, - CHGHOT_IRQ, - CHGTLIMIT_IRQ, - CHG_GONE_IRQ, - VCPMAJOR_IRQ, - VBATDET_IRQ, - BATFET_IRQ, - BATT_REPLACE_IRQ, - BATTCONNECT_IRQ, - PMIC_CHG_MAX_INTS -}; - -struct pm8058_charger { - struct pmic_charger_pdata *pdata; - struct device *dev; - - int pmic_chg_irq[PMIC_CHG_MAX_INTS]; - DECLARE_BITMAP(enabled_irqs, PMIC_CHG_MAX_INTS); - - struct delayed_work chg_done_check_work; - struct delayed_work check_vbat_low_work; - struct delayed_work veoc_begin_work; - struct delayed_work charging_check_work; - int waiting_for_topoff; - int waiting_for_veoc; - int vbatdet; - struct msm_hardware_charger hw_chg; - int current_charger_current; - int disabled; - - struct msm_xo_voter *voter; - struct dentry *dent; - - int inited; - int present; -}; - -static struct pm8058_charger pm8058_chg; -static struct msm_hardware_charger usb_hw_chg; -static struct pmic8058_charger_data chg_data; - -static int msm_battery_gauge_alarm_notify(struct notifier_block *nb, - unsigned long status, void *unused); - -static struct notifier_block alarm_notifier = { - .notifier_call = msm_battery_gauge_alarm_notify, -}; - -static int resume_mv = AUTO_CHARGING_RESUME_MV; -static DEFINE_MUTEX(batt_alarm_lock); -static int resume_mv_set(const char *val, struct kernel_param *kp); -module_param_call(resume_mv, resume_mv_set, param_get_int, - &resume_mv, S_IRUGO | S_IWUSR); - -static int resume_mv_set(const char *val, struct kernel_param *kp) -{ - int rc; - - mutex_lock(&batt_alarm_lock); - - rc = param_set_int(val, kp); - if (rc) - goto out; - - rc = pm8xxx_batt_alarm_threshold_set( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR, resume_mv); - if (!rc) - rc = pm8xxx_batt_alarm_threshold_set( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR, 4300); - -out: - mutex_unlock(&batt_alarm_lock); - return rc; -} - -static void pm8058_chg_enable_irq(int interrupt) -{ - if (!__test_and_set_bit(interrupt, pm8058_chg.enabled_irqs)) { - dev_dbg(pm8058_chg.dev, "%s %d\n", __func__, - pm8058_chg.pmic_chg_irq[interrupt]); - enable_irq(pm8058_chg.pmic_chg_irq[interrupt]); - } -} - -static void pm8058_chg_disable_irq(int interrupt) -{ - if (__test_and_clear_bit(interrupt, pm8058_chg.enabled_irqs)) { - dev_dbg(pm8058_chg.dev, "%s %d\n", __func__, - pm8058_chg.pmic_chg_irq[interrupt]); - disable_irq_nosync(pm8058_chg.pmic_chg_irq[interrupt]); - } -} - -static int pm_chg_get_rt_status(int irq) -{ - int ret; - - ret = pm8xxx_read_irq_stat(pm8058_chg.dev->parent, irq); - if (ret == -EAGAIN) - return 0; - else - return ret; -} - -static int is_chg_plugged_in(void) -{ - return pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGVAL_IRQ]); -} - -#ifdef DEBUG -static void __dump_chg_regs(void) -{ - u8 temp; - int temp2; - - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_CNTRL = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_CNTRL_2 = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_VMAX_SEL, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_VMAX_SEL = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_VBAT_DET, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_VBAT_DET = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_IMAX, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_IMAX = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TRICKLE, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_TRICKLE = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_ITERM, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_ITERM = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TTRKL_MAX, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_TTRKL_MAX = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TCHG_MAX, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_TCHG_MAX = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEMP_THRESH, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_TEMP_THRESH = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEMP_REG, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_TEMP_REG = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_PULSE, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_PULSE = 0x%x\n", temp); - - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_1, - &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_1 = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_3, - &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_3 = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_10, - &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_10 = 0x%x\n", - temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_STATUS_CLEAR_IRQ_11, - &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_STATUS_CLEAR_IRQ_11 = 0x%x\n", - temp); - - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_1, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_1 = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_3, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_3 = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_10, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_10 = 0x%x\n", temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_MASK_IRQ_11, &temp); - dev_dbg(pm8058_chg.dev, "PM8058_CHG_MASK_IRQ_11 = 0x%x\n", temp); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGVAL_IRQ]); - dev_dbg(pm8058_chg.dev, "CHGVAL_IRQ = %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGINVAL_IRQ]); - dev_dbg(pm8058_chg.dev, "CHGINVAL_IRQ = %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[VBATDET_LOW_IRQ]); - dev_dbg(pm8058_chg.dev, "VBATDET_LOW_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[VCP_IRQ]); - dev_dbg(pm8058_chg.dev, "VCP_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGILIM_IRQ]); - dev_dbg(pm8058_chg.dev, "CHGILIM_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[ATC_DONE_IRQ]); - dev_dbg(pm8058_chg.dev, "ATC_DONE_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[ATCFAIL_IRQ]); - dev_dbg(pm8058_chg.dev, "ATCFAIL_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[AUTO_CHGDONE_IRQ]); - dev_dbg(pm8058_chg.dev, "AUTO_CHGDONE_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[AUTO_CHGFAIL_IRQ]); - dev_dbg(pm8058_chg.dev, "AUTO_CHGFAIL_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGSTATE_IRQ]); - dev_dbg(pm8058_chg.dev, "CHGSTATE_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[FASTCHG_IRQ]); - dev_dbg(pm8058_chg.dev, "FASTCHG_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHG_END_IRQ]); - dev_dbg(pm8058_chg.dev, "CHG_END_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATTTEMP_IRQ]); - dev_dbg(pm8058_chg.dev, "BATTTEMP_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGHOT_IRQ]); - dev_dbg(pm8058_chg.dev, "CHGHOT_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHGTLIMIT_IRQ]); - dev_dbg(pm8058_chg.dev, "CHGTLIMIT_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[CHG_GONE_IRQ]); - dev_dbg(pm8058_chg.dev, "CHG_GONE_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[VCPMAJOR_IRQ]); - dev_dbg(pm8058_chg.dev, "VCPMAJOR_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[VBATDET_IRQ]); - dev_dbg(pm8058_chg.dev, "VBATDET_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATFET_IRQ]); - dev_dbg(pm8058_chg.dev, "BATFET_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATT_REPLACE_IRQ]); - dev_dbg(pm8058_chg.dev, "BATT_REPLACE_IRQ= %d\n", temp2); - - temp2 = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATTCONNECT_IRQ]); - dev_dbg(pm8058_chg.dev, "BATTCONNECT_IRQ= %d\n", temp2); -} -#else -static inline void __dump_chg_regs(void) -{ -} -#endif - -/* SSBI register access helper functions */ -static int pm_chg_suspend(int value) -{ - u8 temp; - int ret; - - ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp); - if (ret) - return ret; - if (value) - temp |= BIT(CHG_USB_SUSPEND); - else - temp &= ~BIT(CHG_USB_SUSPEND); - - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, temp); -} - -static int pm_chg_auto_disable(int value) -{ - u8 temp; - int ret; - - ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp); - if (ret) - return ret; - if (value) - temp |= BIT(CHARGE_AUTO_DIS); - else - temp &= ~BIT(CHARGE_AUTO_DIS); - - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp); -} - -static int pm_chg_batt_temp_disable(int value) -{ - u8 temp; - int ret; - - ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp); - if (ret) - return ret; - if (value) - temp |= BIT(CHG_BATT_TEMP_DIS); - else - temp &= ~BIT(CHG_BATT_TEMP_DIS); - - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp); -} - -static int pm_chg_vbatdet_set(int voltage) -{ - u8 temp; - int diff; - - diff = (voltage - PM8058_CHG_V_MIN_MV); - if (diff < 0) { - dev_warn(pm8058_chg.dev, "%s bad mV=%d asked to set\n", - __func__, voltage); - return -EINVAL; - } - - temp = diff / PM8058_CHG_V_STEP_MV; - dev_dbg(pm8058_chg.dev, "%s voltage=%d setting %02x\n", __func__, - voltage, temp); - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_VBAT_DET, temp); -} - -static int pm_chg_imaxsel_set(int chg_current) -{ - u8 temp; - int diff; - - diff = chg_current - PM8058_CHG_I_MIN_MA; - if (diff < 0) { - dev_warn(pm8058_chg.dev, "%s bad mA=%d asked to set\n", - __func__, chg_current); - return -EINVAL; - } - temp = diff / PM8058_CHG_I_STEP_MA; - /* make sure we arent writing more than 5 bits of data */ - if (temp > 31) { - dev_warn(pm8058_chg.dev, "%s max mA=1500 requested mA=%d\n", - __func__, chg_current); - temp = 31; - } - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_IMAX, temp); -} - -#define PM8058_CHG_VMAX_MIN 3300 -#define PM8058_CHG_VMAX_MAX 5500 -static int pm_chg_vmaxsel_set(int voltage) -{ - u8 temp; - - if (voltage < PM8058_CHG_VMAX_MIN || voltage > PM8058_CHG_VMAX_MAX) { - dev_warn(pm8058_chg.dev, "%s bad mV=%d asked to set\n", - __func__, voltage); - return -EINVAL; - } - temp = (voltage - PM8058_CHG_V_MIN_MV) / PM8058_CHG_V_STEP_MV; - dev_dbg(pm8058_chg.dev, "%s mV=%d setting %02x\n", __func__, voltage, - temp); - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_VMAX_SEL, temp); -} - -static int pm_chg_failed_clear(int value) -{ - u8 temp; - int ret; - - ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp); - if (ret) - return ret; - if (value) - temp |= BIT(CHG_FAILED_CLEAR); - else - temp &= ~BIT(CHG_FAILED_CLEAR); - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp); -} - -static int pm_chg_iterm_set(int chg_current) -{ - u8 temp; - - temp = (chg_current / PM8058_CHG_I_TERM_STEP_MA) - 1; - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_ITERM, temp); -} - -static int pm_chg_tchg_set(int minutes) -{ - u8 temp; - - temp = (minutes >> PM8058_CHG_T_TCHG_SHIFT) - 1; - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TCHG_MAX, temp); -} - -static int pm_chg_ttrkl_set(int minutes) -{ - u8 temp; - - temp = minutes - 1; - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TTRKL_MAX, - temp); -} - -static int pm_chg_enum_done_enable(int value) -{ - u8 temp; - int ret; - - ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, &temp); - if (ret) - return ret; - if (value) - temp |= BIT(ENUM_DONE); - else - temp &= ~BIT(ENUM_DONE); - - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL_2, temp); -} - -static uint32_t get_fsm_state(void) -{ - u8 temp; - - temp = 0x00; - pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, temp); - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, &temp); - return (uint32_t)temp; -} - -static int get_fsm_status(void *data, u64 * val) -{ - *val = get_fsm_state(); - return 0; -} - -enum pmic8058_chg_state pmic8058_get_fsm_state(void) -{ - if (!pm8058_chg.inited) { - pr_err("%s: called when not inited\n", __func__); - return -EINVAL; - } - - return get_fsm_state(); -} - -static int pm_chg_disable(int value) -{ - u8 temp; - int ret; - - ret = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp); - if (ret) - return ret; - if (value) - temp |= BIT(CHG_CHARGE_DIS); - else - temp &= ~BIT(CHG_CHARGE_DIS); - - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, temp); -} - -static void pm8058_start_system_current(struct msm_hardware_charger *hw_chg, - int max_current) -{ - int ret = 0; - - if (pm8058_chg.disabled) - return; - - ret = pm_chg_imaxsel_set(max_current); - ret |= pm_chg_enum_done_enable(1); - ret |= pm_chg_disable(0); - if (ret) - pr_err("%s: failed to turn on system power err=%d", - __func__, ret); -} - -static void pm8058_stop_system_current(struct msm_hardware_charger *hw_chg) -{ - int ret = 0; - - ret = pm_chg_enum_done_enable(0); - ret |= pm_chg_disable(1); - if (ret) - pr_err("%s: failed to turn off system power err=%d", - __func__, ret); -} - -static int __pm8058_start_charging(int chg_current, int termination_current, - int time) -{ - int ret = 0; - - if (pm8058_chg.disabled) - goto out; - - dev_info(pm8058_chg.dev, "%s %dmA %dmin\n", - __func__, chg_current, time); - - ret = pm_chg_auto_disable(1); - if (ret) - goto out; - - ret = pm_chg_suspend(0); - if (ret) - goto out; - - ret = pm_chg_imaxsel_set(chg_current); - if (ret) - goto out; - - ret = pm_chg_failed_clear(1); - if (ret) - goto out; - - ret = pm_chg_iterm_set(termination_current); - if (ret) - goto out; - - ret = pm_chg_tchg_set(time); - if (ret) - goto out; - - ret = pm_chg_ttrkl_set(AUTO_CHARGING_TRICKLE_TIME_MINUTES); - if (ret) - goto out; - - ret = pm_chg_batt_temp_disable(0); - if (ret) - goto out; - - if (pm8058_chg.voter == NULL) - pm8058_chg.voter = msm_xo_get(MSM_XO_TCXO_D1, "pm8058_charger"); - msm_xo_mode_vote(pm8058_chg.voter, MSM_XO_MODE_ON); - - ret = pm_chg_enum_done_enable(1); - if (ret) - goto out; - - wmb(); - - ret = pm_chg_auto_disable(0); - if (ret) - goto out; - - /* wait for the enable to update interrupt status*/ - msleep(20); - - pm8058_chg_enable_irq(AUTO_CHGFAIL_IRQ); - pm8058_chg_enable_irq(CHGHOT_IRQ); - pm8058_chg_enable_irq(AUTO_CHGDONE_IRQ); - pm8058_chg_enable_irq(CHG_END_IRQ); - pm8058_chg_enable_irq(CHGSTATE_IRQ); - -out: - return ret; -} - -static void chg_done_cleanup(void) -{ - dev_info(pm8058_chg.dev, "%s notify pm8058 charging completion" - "\n", __func__); - - pm8058_chg_disable_irq(AUTO_CHGDONE_IRQ); - cancel_delayed_work_sync(&pm8058_chg.veoc_begin_work); - cancel_delayed_work_sync(&pm8058_chg.check_vbat_low_work); - - pm8058_chg_disable_irq(CHG_END_IRQ); - - pm8058_chg_disable_irq(VBATDET_LOW_IRQ); - pm8058_chg_disable_irq(VBATDET_IRQ); - pm8058_chg.waiting_for_veoc = 0; - pm8058_chg.waiting_for_topoff = 0; - - pm_chg_auto_disable(1); - - msm_charger_notify_event(&usb_hw_chg, CHG_DONE_EVENT); -} - -static void chg_done_check_work(struct work_struct *work) -{ - chg_done_cleanup(); -} - -static void charging_check_work(struct work_struct *work) -{ - uint32_t fsm_state = get_fsm_state(); - int rc; - - switch (fsm_state) { - /* We're charging, so disarm alarm */ - case PMIC8058_CHG_STATE_ATC: - case PMIC8058_CHG_STATE_FAST_CHG: - case PMIC8058_CHG_STATE_TRKL_CHG: - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (rc) - dev_err(pm8058_chg.dev, - "%s: unable to set alarm state\n", __func__); - break; - default: - /* Still not charging, so update driver state */ - chg_done_cleanup(); - break; - }; -} - -static int pm8058_start_charging(struct msm_hardware_charger *hw_chg, - int chg_voltage, int chg_current) -{ - int vbat_higher_than_vbatdet; - int ret = 0; - - cancel_delayed_work_sync(&pm8058_chg.charging_check_work); - - /* - * adjust the max current for PC USB connection - set the higher limit - * to 450 and make sure we never cross it - */ - if (chg_current == 500) - chg_current = 450; - - if (hw_chg->type == CHG_TYPE_AC && chg_data.max_source_current) - chg_current = chg_data.max_source_current; - - pm8058_chg.current_charger_current = chg_current; - pm8058_chg_enable_irq(FASTCHG_IRQ); - - ret = pm_chg_vmaxsel_set(chg_voltage); - if (ret) - goto out; - - /* set vbat to CC to CV threshold */ - ret = pm_chg_vbatdet_set(AUTO_CHARGING_VBATDET); - if (ret) - goto out; - - pm8058_chg.vbatdet = AUTO_CHARGING_VBATDET; - /* - * get the state of vbat and if it is higher than - * AUTO_CHARGING_VBATDET we start the veoc start timer - * else wait for the voltage to go to AUTO_CHARGING_VBATDET - * and then start the 90 min timer - */ - vbat_higher_than_vbatdet = - pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[VBATDET_IRQ]); - if (vbat_higher_than_vbatdet) { - /* - * we are in constant voltage phase of charging - * IEOC should happen withing 90 mins of this instant - * else we enable VEOC - */ - dev_info(pm8058_chg.dev, "%s begin veoc timer\n", __func__); - schedule_delayed_work(&pm8058_chg.veoc_begin_work, - round_jiffies_relative(msecs_to_jiffies - (AUTO_CHARGING_VEOC_BEGIN_TIME_MS))); - } else - pm8058_chg_enable_irq(VBATDET_IRQ); - - ret = __pm8058_start_charging(chg_current, AUTO_CHARGING_IEOC_ITERM, - AUTO_CHARGING_FAST_TIME_MAX_MINUTES); - pm8058_chg.current_charger_current = chg_current; - - /* - * We want to check the FSM state to verify we're charging. We must - * wait before doing this to allow the VBATDET to settle. The worst - * case for this is two seconds. The batt alarm does not have this - * delay. - */ - schedule_delayed_work(&pm8058_chg.charging_check_work, - round_jiffies_relative(msecs_to_jiffies - (AUTO_CHARGING_VBATDET_DEBOUNCE_TIME_MS))); - -out: - return ret; -} - -static void veoc_begin_work(struct work_struct *work) -{ - /* we have been doing CV for 90mins with no signs of IEOC - * start checking for VEOC in addition with 16min charges*/ - dev_info(pm8058_chg.dev, "%s begin veoc detection\n", __func__); - pm8058_chg.waiting_for_veoc = 1; - /* - * disable VBATDET irq we dont need it unless we are at the end of - * charge cycle - */ - pm8058_chg_disable_irq(VBATDET_IRQ); - __pm8058_start_charging(pm8058_chg.current_charger_current, - AUTO_CHARGING_VEOC_ITERM, - AUTO_CHARGING_VEOC_TCHG); -} - -static void vbat_low_work(struct work_struct *work) -{ - /* - * It has been one minute and the battery still holds voltage - * start the final topoff - charging is almost done - */ - dev_info(pm8058_chg.dev, "%s vbatt maintains for a minute" - "starting topoff\n", __func__); - pm8058_chg.waiting_for_veoc = 0; - pm8058_chg.waiting_for_topoff = 1; - pm8058_chg_disable_irq(VBATDET_LOW_IRQ); - pm8058_chg_disable_irq(VBATDET_IRQ); - __pm8058_start_charging(pm8058_chg.current_charger_current, - AUTO_CHARGING_VEOC_ITERM, - AUTO_CHARGING_VEOC_TCHG_FINAL_CYCLE); -} - - -static irqreturn_t pm8058_chg_chgval_handler(int irq, void *dev_id) -{ - u8 old, temp; - int ret; - - if (is_chg_plugged_in()) { /* this debounces it */ - if (!pm8058_chg.present) { - msm_charger_notify_event(&usb_hw_chg, - CHG_INSERTED_EVENT); - pm8058_chg.present = 1; - } - } else { - if (pm8058_chg.present) { - ret = pm8xxx_readb(pm8058_chg.dev->parent, - PM8058_OVP_TEST_REG, - &old); - temp = old | BIT(FORCE_OVP_OFF); - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_OVP_TEST_REG, - temp); - temp = 0xFC; - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_CHG_TEST, temp); - /* 10 ms sleep is for the VCHG to discharge */ - msleep(10); - temp = 0xF0; - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_CHG_TEST, - temp); - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_OVP_TEST_REG, - old); - - pm_chg_enum_done_enable(0); - pm_chg_auto_disable(1); - msm_charger_notify_event(&usb_hw_chg, - CHG_REMOVED_EVENT); - pm8058_chg.present = 0; - } - } - - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_chginval_handler(int irq, void *dev_id) -{ - u8 old, temp; - int ret; - - if (pm8058_chg.present) { - pm8058_chg_disable_irq(CHGINVAL_IRQ); - - pm_chg_enum_done_enable(0); - pm_chg_auto_disable(1); - ret = pm8xxx_readb(pm8058_chg.dev->parent, - PM8058_OVP_TEST_REG, &old); - temp = old | BIT(FORCE_OVP_OFF); - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_OVP_TEST_REG, temp); - temp = 0xFC; - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_CHG_TEST, temp); - /* 10 ms sleep is for the VCHG to discharge */ - msleep(10); - temp = 0xF0; - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_CHG_TEST, temp); - ret = pm8xxx_writeb(pm8058_chg.dev->parent, - PM8058_OVP_TEST_REG, old); - - if (!is_chg_plugged_in()) { - msm_charger_notify_event(&usb_hw_chg, - CHG_REMOVED_EVENT); - pm8058_chg.present = 0; - } else { - /* was a fake */ - pm8058_chg_enable_irq(CHGINVAL_IRQ); - } - } - - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_auto_chgdone_handler(int irq, void *dev_id) -{ - dev_info(pm8058_chg.dev, "%s waiting a sec to confirm\n", - __func__); - pm8058_chg_disable_irq(AUTO_CHGDONE_IRQ); - pm8058_chg_disable_irq(VBATDET_IRQ); - if (!delayed_work_pending(&pm8058_chg.chg_done_check_work)) { - schedule_delayed_work(&pm8058_chg.chg_done_check_work, - round_jiffies_relative(msecs_to_jiffies - (AUTO_CHARGING_DONE_CHECK_TIME_MS))); - } - return IRQ_HANDLED; -} - -/* can only happen with the pmic charger when it has been charing - * for either 16 mins wating for VEOC or 32 mins for topoff - * without a IEOC indication */ -static irqreturn_t pm8058_chg_auto_chgfail_handler(int irq, void *dev_id) -{ - pm8058_chg_disable_irq(AUTO_CHGFAIL_IRQ); - - if (pm8058_chg.waiting_for_topoff == 1) { - dev_info(pm8058_chg.dev, "%s topoff done, charging done\n", - __func__); - pm8058_chg.waiting_for_topoff = 0; - /* notify we are done charging */ - msm_charger_notify_event(&usb_hw_chg, CHG_DONE_EVENT); - } else { - /* start one minute timer and monitor VBATDET_LOW */ - dev_info(pm8058_chg.dev, "%s monitoring vbat_low for a" - "minute\n", __func__); - schedule_delayed_work(&pm8058_chg.check_vbat_low_work, - round_jiffies_relative(msecs_to_jiffies - (AUTO_CHARGING_VEOC_VBAT_LOW_CHECK_TIME_MS))); - - /* note we are waiting on veoc */ - pm8058_chg.waiting_for_veoc = 1; - - pm_chg_vbatdet_set(AUTO_CHARGING_VEOC_VBATDET); - pm8058_chg.vbatdet = AUTO_CHARGING_VEOC_VBATDET; - pm8058_chg_enable_irq(VBATDET_LOW_IRQ); - } - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_chgstate_handler(int irq, void *dev_id) -{ - u8 temp; - - temp = 0x00; - if (!pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, temp)) { - pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEST_3, &temp); - dev_dbg(pm8058_chg.dev, "%s state=%d\n", __func__, temp); - } - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_fastchg_handler(int irq, void *dev_id) -{ - pm8058_chg_disable_irq(FASTCHG_IRQ); - - /* we have begun the fast charging state */ - dev_info(pm8058_chg.dev, "%s begin fast charging" - , __func__); - msm_charger_notify_event(&usb_hw_chg, CHG_BATT_BEGIN_FAST_CHARGING); - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_batttemp_handler(int irq, void *dev_id) -{ - int ret; - - /* we could get temperature - * interrupt when the battery is plugged out - */ - ret = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATTCONNECT_IRQ]); - if (ret) { - msm_charger_notify_event(&usb_hw_chg, CHG_BATT_REMOVED); - } else { - /* read status to determine we are inrange or outofrange */ - ret = - pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATTTEMP_IRQ]); - if (ret) - msm_charger_notify_event(&usb_hw_chg, - CHG_BATT_TEMP_OUTOFRANGE); - else - msm_charger_notify_event(&usb_hw_chg, - CHG_BATT_TEMP_INRANGE); - } - - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_vbatdet_handler(int irq, void *dev_id) -{ - int ret; - - /* settling time */ - msleep(20); - ret = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[VBATDET_IRQ]); - - if (ret) { - if (pm8058_chg.vbatdet == AUTO_CHARGING_VBATDET - && !delayed_work_pending(&pm8058_chg.veoc_begin_work)) { - /* - * we are in constant voltage phase of charging - * IEOC should happen withing 90 mins of this instant - * else we enable VEOC - */ - dev_info(pm8058_chg.dev, "%s entered constant voltage" - "begin veoc timer\n", __func__); - schedule_delayed_work(&pm8058_chg.veoc_begin_work, - round_jiffies_relative - (msecs_to_jiffies - (AUTO_CHARGING_VEOC_BEGIN_TIME_MS))); - } - } else { - if (pm8058_chg.vbatdet == AUTO_CHARGING_VEOC_VBATDET) { - cancel_delayed_work_sync( - &pm8058_chg.check_vbat_low_work); - - if (pm8058_chg.waiting_for_topoff - || pm8058_chg.waiting_for_veoc) { - /* - * the battery dropped its voltage below 4100 - * around a minute charge the battery for 16 - * mins and check vbat again for a minute - */ - dev_info(pm8058_chg.dev, "%s batt dropped vlt" - "within a minute\n", __func__); - pm8058_chg.waiting_for_topoff = 0; - pm8058_chg.waiting_for_veoc = 1; - pm8058_chg_disable_irq(VBATDET_IRQ); - __pm8058_start_charging(pm8058_chg. - current_charger_current, - AUTO_CHARGING_VEOC_ITERM, - AUTO_CHARGING_VEOC_TCHG); - } - } - } - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_batt_replace_handler(int irq, void *dev_id) -{ - int ret; - - pm8058_chg_disable_irq(BATT_REPLACE_IRQ); - ret = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATT_REPLACE_IRQ]); - if (ret) { - msm_charger_notify_event(&usb_hw_chg, CHG_BATT_INSERTED); - /* - * battery is present enable batt removal - * and batt temperatture interrupt - */ - pm8058_chg_enable_irq(BATTCONNECT_IRQ); - } - return IRQ_HANDLED; -} - -static irqreturn_t pm8058_chg_battconnect_handler(int irq, void *dev_id) -{ - int ret; - - ret = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[BATTCONNECT_IRQ]); - if (ret) { - msm_charger_notify_event(&usb_hw_chg, CHG_BATT_REMOVED); - } else { - msm_charger_notify_event(&usb_hw_chg, CHG_BATT_INSERTED); - pm8058_chg_enable_irq(BATTTEMP_IRQ); - } - - return IRQ_HANDLED; -} - -static int get_rt_status(void *data, u64 * val) -{ - int i = (int)data; - int ret; - - ret = pm_chg_get_rt_status(i); - *val = ret; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(rt_fops, get_rt_status, NULL, "%llu\n"); -DEFINE_SIMPLE_ATTRIBUTE(fsm_fops, get_fsm_status, NULL, "%llu\n"); - -static void free_irqs(void) -{ - int i; - - for (i = 0; i < PMIC_CHG_MAX_INTS; i++) - if (pm8058_chg.pmic_chg_irq[i]) { - free_irq(pm8058_chg.pmic_chg_irq[i], NULL); - pm8058_chg.pmic_chg_irq[i] = 0; - } -} - -static int request_irqs(struct platform_device *pdev) -{ - struct resource *res; - int ret; - - ret = 0; - bitmap_fill(pm8058_chg.enabled_irqs, PMIC_CHG_MAX_INTS); - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "CHGVAL"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource CHGVAL\n", __func__); - goto err_out; - } else { - ret = request_threaded_irq(res->start, NULL, - pm8058_chg_chgval_handler, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[CHGVAL_IRQ] = res->start; - pm8058_chg_disable_irq(CHGVAL_IRQ); - enable_irq_wake(pm8058_chg.pmic_chg_irq[CHGVAL_IRQ]); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "CHGINVAL"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource CHGINVAL\n", __func__); - goto err_out; - } else { - ret = request_threaded_irq(res->start, NULL, - pm8058_chg_chginval_handler, - IRQF_TRIGGER_RISING, res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[CHGINVAL_IRQ] = res->start; - pm8058_chg_disable_irq(CHGINVAL_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - "AUTO_CHGDONE"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource AUTO_CHGDONE\n", __func__); - goto err_out; - } else { - ret = request_irq(res->start, - pm8058_chg_auto_chgdone_handler, - IRQF_TRIGGER_RISING, - res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[AUTO_CHGDONE_IRQ] = res->start; - pm8058_chg_disable_irq(AUTO_CHGDONE_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - "AUTO_CHGFAIL"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource AUTO_CHGFAIL\n", __func__); - goto err_out; - } else { - ret = request_irq(res->start, - pm8058_chg_auto_chgfail_handler, - IRQF_TRIGGER_RISING, res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[AUTO_CHGFAIL_IRQ] = res->start; - pm8058_chg_disable_irq(AUTO_CHGFAIL_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "CHGSTATE"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource CHGSTATE\n", __func__); - goto err_out; - } else { - ret = request_irq(res->start, - pm8058_chg_chgstate_handler, - IRQF_TRIGGER_RISING, res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[CHGSTATE_IRQ] = res->start; - pm8058_chg_disable_irq(CHGSTATE_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "FASTCHG"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource FASTCHG\n", __func__); - goto err_out; - } else { - ret = request_irq(res->start, - pm8058_chg_fastchg_handler, - IRQF_TRIGGER_RISING, res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[FASTCHG_IRQ] = res->start; - pm8058_chg_disable_irq(FASTCHG_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "BATTTEMP"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource CHG_END\n", __func__); - goto err_out; - } else { - ret = request_irq(res->start, - pm8058_chg_batttemp_handler, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[BATTTEMP_IRQ] = res->start; - pm8058_chg_disable_irq(BATTTEMP_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - "BATT_REPLACE"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource BATT_REPLACE\n", __func__); - goto err_out; - } else { - ret = request_irq(res->start, - pm8058_chg_batt_replace_handler, - IRQF_TRIGGER_RISING, res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[BATT_REPLACE_IRQ] = res->start; - pm8058_chg_disable_irq(BATT_REPLACE_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "BATTCONNECT"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource BATTCONNECT\n", __func__); - goto err_out; - } else { - ret = request_irq(res->start, - pm8058_chg_battconnect_handler, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[BATTCONNECT_IRQ] = res->start; - pm8058_chg_disable_irq(BATTCONNECT_IRQ); - } - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "VBATDET"); - if (res == NULL) { - dev_err(pm8058_chg.dev, - "%s:couldnt find resource VBATDET\n", __func__); - goto err_out; - } else { - ret = request_threaded_irq(res->start, NULL, - pm8058_chg_vbatdet_handler, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, - res->name, NULL); - if (ret < 0) { - dev_err(pm8058_chg.dev, "%s:couldnt request %d %d\n", - __func__, res->start, ret); - goto err_out; - } else { - pm8058_chg.pmic_chg_irq[VBATDET_IRQ] = res->start; - pm8058_chg_disable_irq(VBATDET_IRQ); - } - } - - return 0; - -err_out: - free_irqs(); - return -EINVAL; -} - -static int pm8058_get_charge_batt(void) -{ - u8 temp; - int rc; - - rc = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp); - if (rc) - return rc; - - temp &= BIT(CHG_CHARGE_BAT); - if (temp) - temp = 1; - return temp; -} -EXPORT_SYMBOL(pm8058_get_charge_batt); - -static int pm8058_set_charge_batt(int on) -{ - u8 temp; - int rc; - - rc = pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, &temp); - if (rc) - return rc; - if (on) - temp |= BIT(CHG_CHARGE_BAT); - else - temp &= ~BIT(CHG_CHARGE_BAT); - - return pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_CNTRL, temp); - -} -EXPORT_SYMBOL(pm8058_set_charge_batt); - -static int get_charge_batt(void *data, u64 * val) -{ - int ret; - - ret = pm8058_get_charge_batt(); - if (ret < 0) - return ret; - - *val = ret; - return 0; -} - -static int set_charge_batt(void *data, u64 val) -{ - return pm8058_set_charge_batt(val); -} -DEFINE_SIMPLE_ATTRIBUTE(fet_fops, get_charge_batt, set_charge_batt, "%llu\n"); - -static void pm8058_chg_determine_initial_state(void) -{ - if (is_chg_plugged_in()) { - pm8058_chg.present = 1; - msm_charger_notify_event(&usb_hw_chg, CHG_INSERTED_EVENT); - dev_info(pm8058_chg.dev, "%s charger present\n", __func__); - } else { - pm8058_chg.present = 0; - dev_info(pm8058_chg.dev, "%s charger absent\n", __func__); - } - pm8058_chg_enable_irq(CHGVAL_IRQ); -} - -static int pm8058_stop_charging(struct msm_hardware_charger *hw_chg) -{ - int ret; - - dev_info(pm8058_chg.dev, "%s stopping charging\n", __func__); - - /* disable the irqs enabled while charging */ - pm8058_chg_disable_irq(AUTO_CHGFAIL_IRQ); - pm8058_chg_disable_irq(CHGHOT_IRQ); - pm8058_chg_disable_irq(AUTO_CHGDONE_IRQ); - pm8058_chg_disable_irq(FASTCHG_IRQ); - pm8058_chg_disable_irq(CHG_END_IRQ); - pm8058_chg_disable_irq(VBATDET_IRQ); - pm8058_chg_disable_irq(VBATDET_LOW_IRQ); - - cancel_delayed_work_sync(&pm8058_chg.veoc_begin_work); - cancel_delayed_work_sync(&pm8058_chg.check_vbat_low_work); - cancel_delayed_work_sync(&pm8058_chg.chg_done_check_work); - cancel_delayed_work_sync(&pm8058_chg.charging_check_work); - - ret = pm_chg_get_rt_status(pm8058_chg.pmic_chg_irq[FASTCHG_IRQ]); - if (ret == 1) - pm_chg_suspend(1); - else - dev_err(pm8058_chg.dev, - "%s called when not fast-charging\n", __func__); - - pm_chg_failed_clear(1); - - pm8058_chg.waiting_for_veoc = 0; - pm8058_chg.waiting_for_topoff = 0; - - if (pm8058_chg.voter) - msm_xo_mode_vote(pm8058_chg.voter, MSM_XO_MODE_OFF); - - return 0; -} - -static int get_status(void *data, u64 * val) -{ - *val = pm8058_chg.current_charger_current; - return 0; -} - -static int set_status(void *data, u64 val) -{ - - pm8058_chg.current_charger_current = val; - if (pm8058_chg.current_charger_current) - pm8058_start_charging(NULL, - AUTO_CHARGING_VMAXSEL, - pm8058_chg.current_charger_current); - else - pm8058_stop_charging(NULL); - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(chg_fops, get_status, set_status, "%llu\n"); - -static int set_disable_status_param(const char *val, struct kernel_param *kp) -{ - int ret; - - ret = param_set_int(val, kp); - if (ret) - return ret; - - if (pm8058_chg.inited && pm8058_chg.disabled) { - /* - * stop_charging is called during usb suspend - * act as the usb is removed by disabling auto and enum - */ - pm_chg_enum_done_enable(0); - pm_chg_auto_disable(1); - pm8058_stop_charging(NULL); - } - return 0; -} -module_param_call(disabled, set_disable_status_param, param_get_uint, - &(pm8058_chg.disabled), 0644); - -static int pm8058_charging_switched(struct msm_hardware_charger *hw_chg) -{ - u8 temp; - - temp = 0xA3; - pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_2, temp); - temp = 0x84; - pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_2, temp); - msleep(2); - temp = 0x80; - pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST_2, temp); - return 0; -} - -static int get_reg(void *data, u64 * val) -{ - int i = (int)data; - int ret; - u8 temp; - - ret = pm8xxx_readb(pm8058_chg.dev->parent, i, &temp); - if (ret) - return -EAGAIN; - *val = temp; - return 0; -} - -static int set_reg(void *data, u64 val) -{ - int i = (int)data; - int ret; - u8 temp; - - temp = (u8) val; - ret = pm8xxx_writeb(pm8058_chg.dev->parent, i, temp); - mb(); - if (ret) - return -EAGAIN; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(reg_fops, get_reg, set_reg, "%llu\n"); - -#ifdef CONFIG_DEBUG_FS -static void create_debugfs_entries(void) -{ - pm8058_chg.dent = debugfs_create_dir("pm8058_usb_chg", NULL); - - if (IS_ERR(pm8058_chg.dent)) { - pr_err("pmic charger couldnt create debugfs dir\n"); - return; - } - - debugfs_create_file("CHG_CNTRL", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_CNTRL, ®_fops); - debugfs_create_file("CHG_CNTRL_2", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_CNTRL_2, ®_fops); - debugfs_create_file("CHG_VMAX_SEL", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_VMAX_SEL, ®_fops); - debugfs_create_file("CHG_VBAT_DET", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_VBAT_DET, ®_fops); - debugfs_create_file("CHG_IMAX", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_IMAX, ®_fops); - debugfs_create_file("CHG_TRICKLE", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_TRICKLE, ®_fops); - debugfs_create_file("CHG_ITERM", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_ITERM, ®_fops); - debugfs_create_file("CHG_TTRKL_MAX", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_TTRKL_MAX, ®_fops); - debugfs_create_file("CHG_TCHG_MAX", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_TCHG_MAX, ®_fops); - debugfs_create_file("CHG_TEMP_THRESH", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_TEMP_THRESH, ®_fops); - debugfs_create_file("CHG_TEMP_REG", 0644, pm8058_chg.dent, - (void *)PM8058_CHG_TEMP_REG, ®_fops); - - debugfs_create_file("FSM_STATE", 0644, pm8058_chg.dent, NULL, - &fsm_fops); - - debugfs_create_file("stop", 0644, pm8058_chg.dent, NULL, - &chg_fops); - - if (pm8058_chg.pmic_chg_irq[CHGVAL_IRQ]) - debugfs_create_file("CHGVAL", 0444, pm8058_chg.dent, - (void *)pm8058_chg.pmic_chg_irq[CHGVAL_IRQ], - &rt_fops); - - if (pm8058_chg.pmic_chg_irq[CHGINVAL_IRQ]) - debugfs_create_file("CHGINVAL", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[CHGINVAL_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[CHGILIM_IRQ]) - debugfs_create_file("CHGILIM", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[CHGILIM_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[VCP_IRQ]) - debugfs_create_file("VCP", 0444, pm8058_chg.dent, - (void *)pm8058_chg.pmic_chg_irq[VCP_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[ATC_DONE_IRQ]) - debugfs_create_file("ATC_DONE", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[ATC_DONE_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[ATCFAIL_IRQ]) - debugfs_create_file("ATCFAIL", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[ATCFAIL_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[AUTO_CHGDONE_IRQ]) - debugfs_create_file("AUTO_CHGDONE", 0444, pm8058_chg.dent, - (void *) - pm8058_chg.pmic_chg_irq[AUTO_CHGDONE_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[AUTO_CHGFAIL_IRQ]) - debugfs_create_file("AUTO_CHGFAIL", 0444, pm8058_chg.dent, - (void *) - pm8058_chg.pmic_chg_irq[AUTO_CHGFAIL_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[CHGSTATE_IRQ]) - debugfs_create_file("CHGSTATE", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[CHGSTATE_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[FASTCHG_IRQ]) - debugfs_create_file("FASTCHG", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[FASTCHG_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[CHG_END_IRQ]) - debugfs_create_file("CHG_END", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[CHG_END_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[BATTTEMP_IRQ]) - debugfs_create_file("BATTTEMP", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[BATTTEMP_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[CHGHOT_IRQ]) - debugfs_create_file("CHGHOT", 0444, pm8058_chg.dent, - (void *)pm8058_chg.pmic_chg_irq[CHGHOT_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[CHGTLIMIT_IRQ]) - debugfs_create_file("CHGTLIMIT", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[CHGTLIMIT_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[CHG_GONE_IRQ]) - debugfs_create_file("CHG_GONE", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[CHG_GONE_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[VCPMAJOR_IRQ]) - debugfs_create_file("VCPMAJOR", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[VCPMAJOR_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[BATFET_IRQ]) - debugfs_create_file("BATFET", 0444, pm8058_chg.dent, - (void *)pm8058_chg.pmic_chg_irq[BATFET_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[BATT_REPLACE_IRQ]) - debugfs_create_file("BATT_REPLACE", 0444, pm8058_chg.dent, - (void *) - pm8058_chg.pmic_chg_irq[BATT_REPLACE_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[BATTCONNECT_IRQ]) - debugfs_create_file("BATTCONNECT", 0444, pm8058_chg.dent, - (void *) - pm8058_chg.pmic_chg_irq[BATTCONNECT_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[VBATDET_IRQ]) - debugfs_create_file("VBATDET", 0444, pm8058_chg.dent, (void *) - pm8058_chg.pmic_chg_irq[VBATDET_IRQ], - &rt_fops); - if (pm8058_chg.pmic_chg_irq[VBATDET_LOW_IRQ]) - debugfs_create_file("VBATDET_LOW", 0444, pm8058_chg.dent, - (void *) - pm8058_chg.pmic_chg_irq[VBATDET_LOW_IRQ], - &rt_fops); - debugfs_create_file("CHARGE_BATT", 0444, pm8058_chg.dent, - NULL, - &fet_fops); -} -#else -static inline void create_debugfs_entries(void) -{ -} -#endif - -static void remove_debugfs_entries(void) -{ - debugfs_remove_recursive(pm8058_chg.dent); -} - -static struct msm_hardware_charger usb_hw_chg = { - .type = CHG_TYPE_USB, - .rating = 1, - .name = "pm8058-usb", - .start_charging = pm8058_start_charging, - .stop_charging = pm8058_stop_charging, - .charging_switched = pm8058_charging_switched, - .start_system_current = pm8058_start_system_current, - .stop_system_current = pm8058_stop_system_current, -}; - -static int batt_read_adc(int channel, int *mv_reading) -{ - int ret; - void *h; - struct adc_chan_result adc_chan_result; - struct completion conv_complete_evt; - - pr_debug("%s: called for %d\n", __func__, channel); - ret = adc_channel_open(channel, &h); - if (ret) { - pr_err("%s: couldnt open channel %d ret=%d\n", - __func__, channel, ret); - goto out; - } - init_completion(&conv_complete_evt); - ret = adc_channel_request_conv(h, &conv_complete_evt); - if (ret) { - pr_err("%s: couldnt request conv channel %d ret=%d\n", - __func__, channel, ret); - goto out; - } - wait_for_completion(&conv_complete_evt); - ret = adc_channel_read_result(h, &adc_chan_result); - if (ret) { - pr_err("%s: couldnt read result channel %d ret=%d\n", - __func__, channel, ret); - goto out; - } - ret = adc_channel_close(h); - if (ret) { - pr_err("%s: couldnt close channel %d ret=%d\n", - __func__, channel, ret); - } - if (mv_reading) - *mv_reading = adc_chan_result.measurement; - - pr_debug("%s: done for %d\n", __func__, channel); - return adc_chan_result.physical; -out: - pr_debug("%s: done for %d\n", __func__, channel); - return -EINVAL; - -} - -#define BATT_THERM_OPEN_MV 2000 -static int pm8058_is_battery_present(void) -{ - int mv_reading; - - mv_reading = 0; - batt_read_adc(CHANNEL_ADC_BATT_THERM, &mv_reading); - pr_debug("%s: therm_raw is %d\n", __func__, mv_reading); - if (mv_reading > 0 && mv_reading < BATT_THERM_OPEN_MV) - return 1; - - return 0; -} - -static int pm8058_get_battery_temperature(void) -{ - return batt_read_adc(CHANNEL_ADC_BATT_THERM, NULL); -} - -#define BATT_THERM_OPERATIONAL_MAX_CELCIUS 40 -#define BATT_THERM_OPERATIONAL_MIN_CELCIUS 0 -static int pm8058_is_battery_temp_within_range(void) -{ - int therm_celcius; - - therm_celcius = pm8058_get_battery_temperature(); - pr_debug("%s: therm_celcius is %d\n", __func__, therm_celcius); - if (therm_celcius > 0 - && therm_celcius > BATT_THERM_OPERATIONAL_MIN_CELCIUS - && therm_celcius < BATT_THERM_OPERATIONAL_MAX_CELCIUS) - return 1; - - return 0; -} - -#define BATT_ID_MAX_MV 800 -#define BATT_ID_MIN_MV 600 -static int pm8058_is_battery_id_valid(void) -{ - int batt_id_mv; - - batt_id_mv = batt_read_adc(CHANNEL_ADC_BATT_ID, NULL); - pr_debug("%s: batt_id_mv is %d\n", __func__, batt_id_mv); - - /* - * The readings are not in range - * assume battery is present for now - */ - return 1; - - if (batt_id_mv > 0 - && batt_id_mv > BATT_ID_MIN_MV - && batt_id_mv < BATT_ID_MAX_MV) - return 1; - - return 0; -} - -/* returns voltage in mV */ -static int pm8058_get_battery_mvolts(void) -{ - int vbatt_mv; - - vbatt_mv = batt_read_adc(CHANNEL_ADC_VBATT, NULL); - pr_debug("%s: vbatt_mv is %d\n", __func__, vbatt_mv); - if (vbatt_mv > 0) - return vbatt_mv; - /* - * return 0 to tell the upper layers - * we couldnt read the battery voltage - */ - return 0; -} - -static int msm_battery_gauge_alarm_notify(struct notifier_block *nb, - unsigned long status, void *unused) -{ - int rc; - - pr_info("%s: status: %lu\n", __func__, status); - - switch (status) { - case 0: - dev_err(pm8058_chg.dev, - "%s: spurious interrupt\n", __func__); - break; - /* expected case - trip of low threshold */ - case 1: - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (rc) - dev_err(pm8058_chg.dev, - "%s: unable to set alarm state\n", __func__); - msm_charger_notify_event(NULL, CHG_BATT_NEEDS_RECHARGING); - break; - case 2: - dev_err(pm8058_chg.dev, - "%s: trip of high threshold\n", __func__); - break; - default: - dev_err(pm8058_chg.dev, - "%s: error received\n", __func__); - }; - - return 0; -} - -static int pm8058_monitor_for_recharging(void) -{ - int rc; - /* enable low comparator */ - rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (!rc) - return pm8xxx_batt_alarm_enable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - - return rc; - -} - -static struct msm_battery_gauge pm8058_batt_gauge = { - .get_battery_mvolts = pm8058_get_battery_mvolts, - .get_battery_temperature = pm8058_get_battery_temperature, - .is_battery_present = pm8058_is_battery_present, - .is_battery_temp_within_range = pm8058_is_battery_temp_within_range, - .is_battery_id_valid = pm8058_is_battery_id_valid, - .monitor_for_recharging = pm8058_monitor_for_recharging, -}; - -static int pm8058_usb_voltage_lower_limit(void) -{ - u8 temp, old; - int ret = 0; - - temp = 0x10; - ret |= pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST, temp); - ret |= pm8xxx_readb(pm8058_chg.dev->parent, PM8058_CHG_TEST, &old); - old = old & ~BIT(IGNORE_LL); - temp = 0x90 | (0xF & old); - ret |= pm8xxx_writeb(pm8058_chg.dev->parent, PM8058_CHG_TEST, temp); - - return ret; -} - -static int pm8058_charger_probe(struct platform_device *pdev) -{ - struct pmic8058_charger_data *pdata; - int rc = 0; - - pm8058_chg.pdata = pdev->dev.platform_data; - pm8058_chg.dev = &pdev->dev; - pdata = (struct pmic8058_charger_data *) pm8058_chg.pdata; - - if (pdata == NULL) { - pr_err("%s: pdata not present\n", __func__); - return -EINVAL; - } - - if (pdata->charger_data_valid) { - usb_hw_chg.type = pdata->charger_type; - chg_data.charger_type = pdata->charger_type; - chg_data.max_source_current = pdata->max_source_current; - } - - rc = request_irqs(pdev); - if (rc) { - pr_err("%s: couldnt register interrupts\n", __func__); - goto out; - } - - rc = pm8058_usb_voltage_lower_limit(); - if (rc) { - pr_err("%s: couldnt set ignore lower limit bit to 0\n", - __func__); - goto free_irq; - } - - rc = msm_charger_register(&usb_hw_chg); - if (rc) { - pr_err("%s: msm_charger_register failed ret=%d\n", - __func__, rc); - goto free_irq; - } - - pm_chg_batt_temp_disable(0); - msm_battery_gauge_register(&pm8058_batt_gauge); - __dump_chg_regs(); - - create_debugfs_entries(); - INIT_DELAYED_WORK(&pm8058_chg.veoc_begin_work, veoc_begin_work); - INIT_DELAYED_WORK(&pm8058_chg.check_vbat_low_work, vbat_low_work); - INIT_DELAYED_WORK(&pm8058_chg.chg_done_check_work, chg_done_check_work); - INIT_DELAYED_WORK(&pm8058_chg.charging_check_work, charging_check_work); - - /* determine what state the charger is in */ - pm8058_chg_determine_initial_state(); - - pm8058_chg_enable_irq(BATTTEMP_IRQ); - pm8058_chg_enable_irq(BATTCONNECT_IRQ); - - rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (rc) { - pr_err("%s: unable to set batt alarm state\n", __func__); - goto free_irq; - } - - /* - * The batt-alarm driver requires sane values for both min / max, - * regardless of whether they're both activated. - */ - rc = pm8xxx_batt_alarm_threshold_set( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR, resume_mv); - if (!rc) - rc = pm8xxx_batt_alarm_threshold_set( - PM8XXX_BATT_ALARM_UPPER_COMPARATOR, 4300); - if (rc) { - pr_err("%s: unable to set batt alarm threshold\n", __func__); - goto free_irq; - } - - rc = pm8xxx_batt_alarm_hold_time_set( - PM8XXX_BATT_ALARM_HOLD_TIME_16_MS); - if (rc) { - pr_err("%s: unable to set batt alarm hold time\n", __func__); - goto free_irq; - } - - /* PWM enabled at 2Hz */ - rc = pm8xxx_batt_alarm_pwm_rate_set(1, 7, 4); - if (rc) { - pr_err("%s: unable to set batt alarm pwm rate\n", __func__); - goto free_irq; - } - - rc = pm8xxx_batt_alarm_register_notifier(&alarm_notifier); - if (rc) { - pr_err("%s: unable to register alarm notifier\n", __func__); - goto free_irq; - } - - pm8058_chg.inited = 1; - - return 0; - -free_irq: - free_irqs(); -out: - return rc; -} - -static int pm8058_charger_remove(struct platform_device *pdev) -{ - struct pm8058_charger_chip *chip = platform_get_drvdata(pdev); - int rc; - - msm_charger_notify_event(&usb_hw_chg, CHG_REMOVED_EVENT); - msm_charger_unregister(&usb_hw_chg); - cancel_delayed_work_sync(&pm8058_chg.veoc_begin_work); - cancel_delayed_work_sync(&pm8058_chg.check_vbat_low_work); - cancel_delayed_work_sync(&pm8058_chg.charging_check_work); - free_irqs(); - remove_debugfs_entries(); - kfree(chip); - - rc = pm8xxx_batt_alarm_disable(PM8XXX_BATT_ALARM_UPPER_COMPARATOR); - if (!rc) - rc = pm8xxx_batt_alarm_disable( - PM8XXX_BATT_ALARM_LOWER_COMPARATOR); - if (rc) - pr_err("%s: unable to set batt alarm state\n", __func__); - - rc |= pm8xxx_batt_alarm_unregister_notifier(&alarm_notifier); - if (rc) - pr_err("%s: unable to register alarm notifier\n", __func__); - return rc; -} - -static struct platform_driver pm8058_charger_driver = { - .probe = pm8058_charger_probe, - .remove = pm8058_charger_remove, - .driver = { - .name = "pm8058-charger", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8058_charger_init(void) -{ - return platform_driver_register(&pm8058_charger_driver); -} - -static void __exit pm8058_charger_exit(void) -{ - platform_driver_unregister(&pm8058_charger_driver); -} - -late_initcall(pm8058_charger_init); -module_exit(pm8058_charger_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8058 BATTERY driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pm8058_charger"); diff --git a/drivers/power/qci_battery.c b/drivers/power/qci_battery.c deleted file mode 100644 index 724bcba27ae1bab624fc2688d5e91f95bcc27df1..0000000000000000000000000000000000000000 --- a/drivers/power/qci_battery.c +++ /dev/null @@ -1,662 +0,0 @@ -/* Quanta I2C Battery Driver - * - * Copyright (C) 2009 Quanta Computer Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -/* - * - * The Driver with I/O communications via the I2C Interface for ST15 platform. - * And it is only working on the nuvoTon WPCE775x Embedded Controller. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qci_battery.h" - -#define QCIBAT_DEFAULT_CHARGE_FULL_CAPACITY 2200 /* 2200 mAh */ -#define QCIBAT_DEFAULT_CHARGE_FULL_DESIGN 2200 -#define QCIBAT_DEFAULT_VOLTAGE_DESIGN 10800 /* 10.8 V */ -#define QCIBAT_STRING_SIZE 16 - -/* General structure to hold the driver data */ -struct i2cbat_drv_data { - struct i2c_client *bi2c_client; - struct work_struct work; - unsigned int qcibat_irq; - unsigned int qcibat_gpio; - u8 battery_state; - u8 battery_dev_name[QCIBAT_STRING_SIZE]; - u8 serial_number[QCIBAT_STRING_SIZE]; - u8 manufacturer_name[QCIBAT_STRING_SIZE]; - unsigned int charge_full; - unsigned int charge_full_design; - unsigned int voltage_full_design; - unsigned int energy_full; -}; - -static struct i2cbat_drv_data context; -static struct mutex qci_i2c_lock; -static struct mutex qci_transaction_lock; -/********************************************************************* - * Power - *********************************************************************/ - -static int get_bat_info(u8 ec_data) -{ - u8 byte_read; - - mutex_lock(&qci_i2c_lock); - i2c_smbus_write_byte(context.bi2c_client, ec_data); - byte_read = i2c_smbus_read_byte(context.bi2c_client); - mutex_unlock(&qci_i2c_lock); - return byte_read; -} - -static int qci_ac_get_prop(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - int ret = 0; - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - if (get_bat_info(ECRAM_POWER_SOURCE) & EC_FLAG_ADAPTER_IN) - val->intval = EC_ADAPTER_PRESENT; - else - val->intval = EC_ADAPTER_NOT_PRESENT; - break; - default: - ret = -EINVAL; - break; - } - return ret; -} - -static enum power_supply_property qci_ac_props[] = { - POWER_SUPPLY_PROP_ONLINE, -}; - -static enum power_supply_property qci_bat_props[] = { - POWER_SUPPLY_PROP_STATUS, - POWER_SUPPLY_PROP_PRESENT, - POWER_SUPPLY_PROP_HEALTH, - POWER_SUPPLY_PROP_TECHNOLOGY, - POWER_SUPPLY_PROP_VOLTAGE_AVG, - POWER_SUPPLY_PROP_CURRENT_AVG, - POWER_SUPPLY_PROP_CAPACITY, - POWER_SUPPLY_PROP_TEMP, - POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, - POWER_SUPPLY_PROP_CHARGE_FULL, - POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, - POWER_SUPPLY_PROP_TIME_TO_FULL_AVG, - POWER_SUPPLY_PROP_MODEL_NAME, - POWER_SUPPLY_PROP_MANUFACTURER, - POWER_SUPPLY_PROP_SERIAL_NUMBER, - POWER_SUPPLY_PROP_CHARGE_COUNTER, - POWER_SUPPLY_PROP_ENERGY_NOW, - POWER_SUPPLY_PROP_ENERGY_FULL, - POWER_SUPPLY_PROP_ENERGY_EMPTY, -}; - -static int read_data_from_battery(u8 smb_cmd, u8 smb_prtcl) -{ - if (context.battery_state & MAIN_BATTERY_STATUS_BAT_IN) { - mutex_lock(&qci_i2c_lock); - i2c_smbus_write_byte_data(context.bi2c_client, - ECRAM_SMB_STS, 0); - i2c_smbus_write_byte_data(context.bi2c_client, ECRAM_SMB_ADDR, - BATTERY_SLAVE_ADDRESS); - i2c_smbus_write_byte_data(context.bi2c_client, - ECRAM_SMB_CMD, smb_cmd); - i2c_smbus_write_byte_data(context.bi2c_client, - ECRAM_SMB_PRTCL, smb_prtcl); - mutex_unlock(&qci_i2c_lock); - msleep(100); - return get_bat_info(ECRAM_SMB_STS); - } else - return SMBUS_DEVICE_NOACK; -} - -static int qbat_get_status(union power_supply_propval *val) -{ - int status; - - status = get_bat_info(ECRAM_BATTERY_STATUS); - - if ((status & MAIN_BATTERY_STATUS_BAT_IN) == 0x0) - val->intval = POWER_SUPPLY_STATUS_UNKNOWN; - else if (status & MAIN_BATTERY_STATUS_BAT_CHARGING) - val->intval = POWER_SUPPLY_STATUS_CHARGING; - else if (status & MAIN_BATTERY_STATUS_BAT_FULL) - val->intval = POWER_SUPPLY_STATUS_FULL; - else if (status & MAIN_BATTERY_STATUS_BAT_DISCHRG) - val->intval = POWER_SUPPLY_STATUS_DISCHARGING; - else - val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; - - return 0; -} - -static int qbat_get_present(union power_supply_propval *val) -{ - if (context.battery_state & MAIN_BATTERY_STATUS_BAT_IN) - val->intval = EC_BAT_PRESENT; - else - val->intval = EC_BAT_NOT_PRESENT; - return 0; -} - -static int qbat_get_health(union power_supply_propval *val) -{ - u8 health; - - health = get_bat_info(ECRAM_CHARGER_ALARM); - if (!(context.battery_state & MAIN_BATTERY_STATUS_BAT_IN)) - val->intval = POWER_SUPPLY_HEALTH_UNKNOWN; - else if (health & ALARM_OVER_TEMP) - val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; - else if (health & ALARM_REMAIN_CAPACITY) - val->intval = POWER_SUPPLY_HEALTH_DEAD; - else if (health & ALARM_OVER_CHARGE) - val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; - else - val->intval = POWER_SUPPLY_HEALTH_GOOD; - return 0; -} - -static int qbat_get_voltage_avg(union power_supply_propval *val) -{ - val->intval = (get_bat_info(ECRAM_BATTERY_VOLTAGE_MSB) << 8 | - get_bat_info(ECRAM_BATTERY_VOLTAGE_LSB)) * 1000; - return 0; -} - -static int qbat_get_current_avg(union power_supply_propval *val) -{ - val->intval = (get_bat_info(ECRAM_BATTERY_CURRENT_MSB) << 8 | - get_bat_info(ECRAM_BATTERY_CURRENT_LSB)); - return 0; -} - -static int qbat_get_capacity(union power_supply_propval *val) -{ - if (!(context.battery_state & MAIN_BATTERY_STATUS_BAT_IN)) - val->intval = 0xFF; - else - val->intval = get_bat_info(ECRAM_BATTERY_CAPACITY); - return 0; -} - -static int qbat_get_temp_avg(union power_supply_propval *val) -{ - int temp; - int rc = 0; - - if (!(context.battery_state & MAIN_BATTERY_STATUS_BAT_IN)) { - val->intval = 0xFFFF; - rc = -ENODATA; - } else { - temp = (get_bat_info(ECRAM_BATTERY_TEMP_MSB) << 8) | - get_bat_info(ECRAM_BATTERY_TEMP_LSB); - val->intval = (temp - 2730) / 10; - } - return rc; -} - -static int qbat_get_charge_full_design(union power_supply_propval *val) -{ - val->intval = context.charge_full_design; - return 0; -} - -static int qbat_get_charge_full(union power_supply_propval *val) -{ - val->intval = context.charge_full; - return 0; -} - -static int qbat_get_charge_counter(union power_supply_propval *val) -{ - u16 charge = 0; - int rc = 0; - - mutex_lock(&qci_transaction_lock); - if (read_data_from_battery(BATTERY_CYCLE_COUNT, - SMBUS_READ_WORD_PRTCL) == SMBUS_DONE) { - charge = get_bat_info(ECRAM_SMB_DATA1); - charge = charge << 8; - charge |= get_bat_info(ECRAM_SMB_DATA0); - } else - rc = -ENODATA; - mutex_unlock(&qci_transaction_lock); - val->intval = charge; - return rc; -} - -static int qbat_get_time_empty_avg(union power_supply_propval *val) -{ - u16 avg = 0; - int rc = 0; - - mutex_lock(&qci_transaction_lock); - if (read_data_from_battery(BATTERY_AVERAGE_TIME_TO_EMPTY, - SMBUS_READ_WORD_PRTCL) == SMBUS_DONE) { - avg = get_bat_info(ECRAM_SMB_DATA1); - avg = avg << 8; - avg |= get_bat_info(ECRAM_SMB_DATA0); - } else - rc = -ENODATA; - mutex_unlock(&qci_transaction_lock); - val->intval = avg; - return rc; -} - -static int qbat_get_time_full_avg(union power_supply_propval *val) -{ - u16 avg = 0; - int rc = 0; - - mutex_lock(&qci_transaction_lock); - if (read_data_from_battery(BATTERY_AVERAGE_TIME_TO_FULL, - SMBUS_READ_WORD_PRTCL) == SMBUS_DONE) { - avg = get_bat_info(ECRAM_SMB_DATA1); - avg = avg << 8; - avg |= get_bat_info(ECRAM_SMB_DATA0); - } else - rc = -ENODATA; - mutex_unlock(&qci_transaction_lock); - val->intval = avg; - return rc; -} - -static int qbat_get_model_name(union power_supply_propval *val) -{ - unsigned char i, size; - - mutex_lock(&qci_transaction_lock); - if (read_data_from_battery(BATTERY_DEVICE_NAME, - SMBUS_READ_BLOCK_PRTCL) == SMBUS_DONE) { - size = min(get_bat_info(ECRAM_SMB_BCNT), QCIBAT_STRING_SIZE); - for (i = 0; i < size; i++) { - context.battery_dev_name[i] = - get_bat_info(ECRAM_SMB_DATA_START + i); - } - val->strval = context.battery_dev_name; - } else - val->strval = "Unknown"; - mutex_unlock(&qci_transaction_lock); - return 0; -} - -static int qbat_get_manufacturer_name(union power_supply_propval *val) -{ - val->strval = context.manufacturer_name; - return 0; -} - -static int qbat_get_serial_number(union power_supply_propval *val) -{ - val->strval = context.serial_number; - return 0; -} - -static int qbat_get_technology(union power_supply_propval *val) -{ - val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; - return 0; -} - -static int qbat_get_energy_now(union power_supply_propval *val) -{ - if (!(get_bat_info(ECRAM_BATTERY_STATUS) & MAIN_BATTERY_STATUS_BAT_IN)) - val->intval = 0; - else - val->intval = (get_bat_info(ECRAM_BATTERY_CAPACITY) * - context.energy_full) / 100; - return 0; -} - -static int qbat_get_energy_full(union power_supply_propval *val) -{ - val->intval = context.energy_full; - return 0; -} - -static int qbat_get_energy_empty(union power_supply_propval *val) -{ - val->intval = 0; - return 0; -} - -static void qbat_init_get_charge_full(void) -{ - u16 charge = QCIBAT_DEFAULT_CHARGE_FULL_CAPACITY; - - mutex_lock(&qci_transaction_lock); - if (read_data_from_battery(BATTERY_FULL_CAPACITY, - SMBUS_READ_WORD_PRTCL) == SMBUS_DONE) { - charge = get_bat_info(ECRAM_SMB_DATA1); - charge = charge << 8; - charge |= get_bat_info(ECRAM_SMB_DATA0); - } - mutex_unlock(&qci_transaction_lock); - context.charge_full = charge; -} - -static void qbat_init_get_charge_full_design(void) -{ - u16 charge = QCIBAT_DEFAULT_CHARGE_FULL_DESIGN; - - mutex_lock(&qci_transaction_lock); - if (read_data_from_battery(BATTERY_DESIGN_CAPACITY, - SMBUS_READ_WORD_PRTCL) == SMBUS_DONE) { - charge = get_bat_info(ECRAM_SMB_DATA1); - charge = charge << 8; - charge |= get_bat_info(ECRAM_SMB_DATA0); - } - mutex_unlock(&qci_transaction_lock); - context.charge_full_design = charge; -} - -static void qbat_init_get_voltage_full_design(void) -{ - u16 voltage = QCIBAT_DEFAULT_VOLTAGE_DESIGN; - - mutex_lock(&qci_transaction_lock); - if (read_data_from_battery(BATTERY_DESIGN_VOLTAGE, - SMBUS_READ_WORD_PRTCL) == SMBUS_DONE) { - voltage = get_bat_info(ECRAM_SMB_DATA1); - voltage = voltage << 8; - voltage |= get_bat_info(ECRAM_SMB_DATA0); - } - mutex_unlock(&qci_transaction_lock); - context.voltage_full_design = voltage; -} - -static void qbat_init_get_manufacturer_name(void) -{ - u8 size; - u8 i; - int rc; - - mutex_lock(&qci_transaction_lock); - rc = read_data_from_battery(BATTERY_MANUFACTURE_NAME, - SMBUS_READ_BLOCK_PRTCL); - if (rc == SMBUS_DONE) { - size = min(get_bat_info(ECRAM_SMB_BCNT), QCIBAT_STRING_SIZE); - for (i = 0; i < size; i++) { - context.manufacturer_name[i] = - get_bat_info(ECRAM_SMB_DATA_START + i); - } - } else - strcpy(context.manufacturer_name, "Unknown"); - mutex_unlock(&qci_transaction_lock); -} - -static void qbat_init_get_serial_number(void) -{ - u8 size; - u8 i; - int rc; - - mutex_lock(&qci_transaction_lock); - rc = read_data_from_battery(BATTERY_SERIAL_NUMBER, - SMBUS_READ_BLOCK_PRTCL); - if (rc == SMBUS_DONE) { - size = min(get_bat_info(ECRAM_SMB_BCNT), QCIBAT_STRING_SIZE); - for (i = 0; i < size; i++) { - context.serial_number[i] = - get_bat_info(ECRAM_SMB_DATA_START + i); - } - } else - strcpy(context.serial_number, "Unknown"); - mutex_unlock(&qci_transaction_lock); -} - -static void init_battery_stats(void) -{ - int i; - - context.battery_state = get_bat_info(ECRAM_BATTERY_STATUS); - if (!(context.battery_state & MAIN_BATTERY_STATUS_BAT_IN)) - return; - /* EC bug? needs some initial priming */ - for (i = 0; i < 5; i++) { - read_data_from_battery(BATTERY_DESIGN_CAPACITY, - SMBUS_READ_WORD_PRTCL); - } - - qbat_init_get_charge_full_design(); - qbat_init_get_charge_full(); - qbat_init_get_voltage_full_design(); - - context.energy_full = context.voltage_full_design * - context.charge_full; - - qbat_init_get_serial_number(); - qbat_init_get_manufacturer_name(); -} - -/********************************************************************* - * Battery properties - *********************************************************************/ -static int qbat_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - int ret = 0; - - switch (psp) { - case POWER_SUPPLY_PROP_STATUS: - ret = qbat_get_status(val); - break; - case POWER_SUPPLY_PROP_PRESENT: - ret = qbat_get_present(val); - break; - case POWER_SUPPLY_PROP_HEALTH: - ret = qbat_get_health(val); - break; - case POWER_SUPPLY_PROP_MANUFACTURER: - ret = qbat_get_manufacturer_name(val); - break; - case POWER_SUPPLY_PROP_TECHNOLOGY: - ret = qbat_get_technology(val); - break; - case POWER_SUPPLY_PROP_VOLTAGE_AVG: - ret = qbat_get_voltage_avg(val); - break; - case POWER_SUPPLY_PROP_CURRENT_AVG: - ret = qbat_get_current_avg(val); - break; - case POWER_SUPPLY_PROP_CAPACITY: - ret = qbat_get_capacity(val); - break; - case POWER_SUPPLY_PROP_TEMP: - ret = qbat_get_temp_avg(val); - break; - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: - ret = qbat_get_charge_full_design(val); - break; - case POWER_SUPPLY_PROP_CHARGE_FULL: - ret = qbat_get_charge_full(val); - break; - case POWER_SUPPLY_PROP_CHARGE_COUNTER: - ret = qbat_get_charge_counter(val); - break; - case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG: - ret = qbat_get_time_empty_avg(val); - break; - case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG: - ret = qbat_get_time_full_avg(val); - break; - case POWER_SUPPLY_PROP_MODEL_NAME: - ret = qbat_get_model_name(val); - break; - case POWER_SUPPLY_PROP_SERIAL_NUMBER: - ret = qbat_get_serial_number(val); - break; - case POWER_SUPPLY_PROP_ENERGY_NOW: - ret = qbat_get_energy_now(val); - break; - case POWER_SUPPLY_PROP_ENERGY_FULL: - ret = qbat_get_energy_full(val); - break; - case POWER_SUPPLY_PROP_ENERGY_EMPTY: - ret = qbat_get_energy_empty(val); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -/********************************************************************* - * Initialisation - *********************************************************************/ - -static struct power_supply qci_ac = { - .name = "ac", - .type = POWER_SUPPLY_TYPE_MAINS, - .properties = qci_ac_props, - .num_properties = ARRAY_SIZE(qci_ac_props), - .get_property = qci_ac_get_prop, -}; - -static struct power_supply qci_bat = { - .name = "battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = qci_bat_props, - .num_properties = ARRAY_SIZE(qci_bat_props), - .get_property = qbat_get_property, - .use_for_apm = 1, -}; - -static irqreturn_t qbat_interrupt(int irq, void *dev_id) -{ - struct i2cbat_drv_data *ibat_drv_data = dev_id; - schedule_work(&ibat_drv_data->work); - return IRQ_HANDLED; -} - -static void qbat_work(struct work_struct *_work) -{ - u8 status; - - status = get_bat_info(ECRAM_BATTERY_EVENTS); - if (status & EC_EVENT_AC) { - context.battery_state = get_bat_info(ECRAM_BATTERY_STATUS); - power_supply_changed(&qci_ac); - } - - if (status & (EC_EVENT_BATTERY | EC_EVENT_CHARGER | EC_EVENT_TIMER)) { - context.battery_state = get_bat_info(ECRAM_BATTERY_STATUS); - power_supply_changed(&qci_bat); - if (status & EC_EVENT_BATTERY) - init_battery_stats(); - } -} - -static struct platform_device *bat_pdev; - -static int __init qbat_init(void) -{ - int err = 0; - - mutex_init(&qci_i2c_lock); - mutex_init(&qci_transaction_lock); - - context.bi2c_client = wpce_get_i2c_client(); - if (context.bi2c_client == NULL) - return -1; - - i2c_set_clientdata(context.bi2c_client, &context); - context.qcibat_gpio = context.bi2c_client->irq; - - /*battery device register*/ - bat_pdev = platform_device_register_simple("battery", 0, NULL, 0); - if (IS_ERR(bat_pdev)) - return PTR_ERR(bat_pdev); - - err = power_supply_register(&bat_pdev->dev, &qci_ac); - if (err) - goto ac_failed; - - qci_bat.name = bat_pdev->name; - err = power_supply_register(&bat_pdev->dev, &qci_bat); - if (err) - goto battery_failed; - - /*battery irq configure*/ - INIT_WORK(&context.work, qbat_work); - err = gpio_request(context.qcibat_gpio, "qci-bat"); - if (err) { - dev_err(&context.bi2c_client->dev, - "[BAT] err gpio request\n"); - goto gpio_request_fail; - } - context.qcibat_irq = gpio_to_irq(context.qcibat_gpio); - err = request_irq(context.qcibat_irq, qbat_interrupt, - IRQF_TRIGGER_FALLING, BATTERY_ID_NAME, &context); - if (err) { - dev_err(&context.bi2c_client->dev, - "[BAT] unable to get IRQ\n"); - goto request_irq_fail; - } - - init_battery_stats(); - goto success; - -request_irq_fail: - gpio_free(context.qcibat_gpio); - -gpio_request_fail: - power_supply_unregister(&qci_bat); - -battery_failed: - power_supply_unregister(&qci_ac); - -ac_failed: - platform_device_unregister(bat_pdev); - - i2c_set_clientdata(context.bi2c_client, NULL); -success: - return err; -} - -static void __exit qbat_exit(void) -{ - free_irq(context.qcibat_irq, &context); - gpio_free(context.qcibat_gpio); - power_supply_unregister(&qci_bat); - power_supply_unregister(&qci_ac); - platform_device_unregister(bat_pdev); - i2c_set_clientdata(context.bi2c_client, NULL); -} - -late_initcall(qbat_init); -module_exit(qbat_exit); - -MODULE_AUTHOR("Quanta Computer Inc."); -MODULE_DESCRIPTION("Quanta Embedded Controller I2C Battery Driver"); -MODULE_LICENSE("GPL v2"); - diff --git a/drivers/power/qci_battery.h b/drivers/power/qci_battery.h deleted file mode 100644 index dcbb62b533145c45b7bf14570bc627d9e9c2310f..0000000000000000000000000000000000000000 --- a/drivers/power/qci_battery.h +++ /dev/null @@ -1,121 +0,0 @@ -/* Header file for Quanta I2C Battery Driver - * - * Copyright (C) 2009 Quanta Computer Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - - /* - * - * The Driver with I/O communications via the I2C Interface for ON2 of AP BU. - * And it is only working on the nuvoTon WPCE775x Embedded Controller. - * - */ - -#ifndef __QCI_BATTERY_H__ -#define __QCI_BATTERY_H__ - -#define BAT_I2C_ADDRESS 0x1A -#define BATTERY_ID_NAME "qci-i2cbat" -#define EC_FLAG_ADAPTER_IN 0x01 -#define EC_FLAG_POWER_ON 0x02 -#define EC_FLAG_ENTER_S3 0x04 -#define EC_FLAG_ENTER_S4 0x08 -#define EC_FLAG_IN_STANDBY 0x10 -#define EC_FLAG_SYSTEM_ON 0x20 -#define EC_FLAG_WAIT_HWPG 0x40 -#define EC_FLAG_S5_POWER_ON 0x80 - -#define MAIN_BATTERY_STATUS_BAT_DISCHRG 0x01 -#define MAIN_BATTERY_STATUS_BAT_CHARGING 0x02 -#define MAIN_BATTERY_STATUS_BAT_ABNORMAL 0x04 -#define MAIN_BATTERY_STATUS_BAT_IN 0x08 -#define MAIN_BATTERY_STATUS_BAT_FULL 0x10 -#define MAIN_BATTERY_STATUS_BAT_LOW 0x20 -#define MAIN_BATTERY_STATUS_BAT_SMB_VALID 0x80 - -#define CHG_STATUS_BAT_CHARGE 0x01 -#define CHG_STATUS_BAT_PRECHG 0x02 -#define CHG_STATUS_BAT_OVERTEMP 0x04 -#define CHG_STATUS_BAT_TYPE 0x08 -#define CHG_STATUS_BAT_GWROK 0x10 -#define CHG_STATUS_BAT_INCHARGE 0x20 -#define CHG_STATUS_BAT_WAKECHRG 0x40 -#define CHG_STATUS_BAT_CHGTIMEOUT 0x80 - -#define EC_ADAPTER_PRESENT 0x1 -#define EC_BAT_PRESENT 0x1 -#define EC_ADAPTER_NOT_PRESENT 0x0 -#define EC_BAT_NOT_PRESENT 0x0 - -#define ECRAM_POWER_SOURCE 0x40 -#define ECRAM_CHARGER_ALARM 0x42 -#define ECRAM_BATTERY_STATUS 0x82 -#define ECRAM_BATTERY_CURRENT_LSB 0x83 -#define ECRAM_BATTERY_CURRENT_MSB 0x84 -#define ECRAM_BATTERY_VOLTAGE_LSB 0x87 -#define ECRAM_BATTERY_VOLTAGE_MSB 0x88 -#define ECRAM_BATTERY_CAPACITY 0x89 -#define ECRAM_BATTERY_TEMP_LSB 0x8C -#define ECRAM_BATTERY_TEMP_MSB 0x8D -#define ECRAM_BATTERY_EVENTS 0x99 - -#define EC_EVENT_BATTERY 0x01 -#define EC_EVENT_CHARGER 0x02 -#define EC_EVENT_AC 0x10 -#define EC_EVENT_TIMER 0x40 - -/* smbus access */ -#define SMBUS_READ_BYTE_PRTCL 0x07 -#define SMBUS_READ_WORD_PRTCL 0x09 -#define SMBUS_READ_BLOCK_PRTCL 0x0B - -/* smbus status code */ -#define SMBUS_OK 0x00 -#define SMBUS_DONE 0x80 -#define SMBUS_ALARM 0x40 -#define SMBUS_UNKNOW_FAILURE 0x07 -#define SMBUS_DEVICE_NOACK 0x10 -#define SMBUS_DEVICE_ERROR 0x11 -#define SMBUS_UNKNOW_ERROR 0x13 -#define SMBUS_TIME_OUT 0x18 -#define SMBUS_BUSY 0x1A - -/* ec ram mapping */ -#define ECRAM_SMB_PRTCL 0 -#define ECRAM_SMB_STS 1 -#define ECRAM_SMB_ADDR 2 -#define ECRAM_SMB_CMD 3 -#define ECRAM_SMB_DATA_START 4 -#define ECRAM_SMB_DATA0 4 -#define ECRAM_SMB_DATA1 5 -#define ECRAM_SMB_BCNT 36 -#define ECRAM_SMB_ALARM_ADDR 37 -#define ECRAM_SMB_ALARM_DATA0 38 -#define ECRAM_SMB_ALARM_DATA1 39 - -/* smart battery commands */ -#define BATTERY_SLAVE_ADDRESS 0x16 -#define BATTERY_FULL_CAPACITY 0x10 -#define BATTERY_AVERAGE_TIME_TO_EMPTY 0x12 -#define BATTERY_AVERAGE_TIME_TO_FULL 0x13 -#define BATTERY_CYCLE_COUNT 0x17 -#define BATTERY_DESIGN_CAPACITY 0x18 -#define BATTERY_DESIGN_VOLTAGE 0x19 -#define BATTERY_SERIAL_NUMBER 0x1C -#define BATTERY_MANUFACTURE_NAME 0x20 -#define BATTERY_DEVICE_NAME 0x21 - -/* alarm bit */ -#define ALARM_REMAIN_CAPACITY 0x02 -#define ALARM_OVER_TEMP 0x10 -#define ALARM_OVER_CHARGE 0x80 -#endif diff --git a/drivers/power/smb137b.c b/drivers/power/smb137b.c deleted file mode 100644 index aa1180bfcff0390c4f38ef13053ca04d5dcd13f0..0000000000000000000000000000000000000000 --- a/drivers/power/smb137b.c +++ /dev/null @@ -1,857 +0,0 @@ -/* Copyright (c) 2010-2011 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SMB137B_MASK(BITS, POS) ((unsigned char)(((1 << BITS) - 1) << POS)) - -#define CHG_CURRENT_REG 0x00 -#define FAST_CHG_CURRENT_MASK SMB137B_MASK(3, 5) -#define PRE_CHG_CURRENT_MASK SMB137B_MASK(2, 3) -#define TERM_CHG_CURRENT_MASK SMB137B_MASK(2, 1) - -#define INPUT_CURRENT_LIMIT_REG 0x01 -#define IN_CURRENT_MASK SMB137B_MASK(3, 5) -#define IN_CURRENT_LIMIT_EN_BIT BIT(2) -#define IN_CURRENT_DET_THRESH_MASK SMB137B_MASK(2, 0) - -#define FLOAT_VOLTAGE_REG 0x02 -#define STAT_OUT_POLARITY_BIT BIT(7) -#define FLOAT_VOLTAGE_MASK SMB137B_MASK(7, 0) - -#define CONTROL_A_REG 0x03 -#define AUTO_RECHARGE_DIS_BIT BIT(7) -#define CURR_CYCLE_TERM_BIT BIT(6) -#define PRE_TO_FAST_V_MASK SMB137B_MASK(3, 3) -#define TEMP_BEHAV_BIT BIT(2) -#define THERM_NTC_CURR_MODE_BIT BIT(1) -#define THERM_NTC_47KOHM_BIT BIT(0) - -#define CONTROL_B_REG 0x04 -#define STAT_OUTPUT_MODE_MASK SMB137B_MASK(2, 6) -#define BATT_OV_ENDS_CYCLE_BIT BIT(5) -#define AUTO_PRE_TO_FAST_DIS_BIT BIT(4) -#define SAFETY_TIMER_EN_BIT BIT(3) -#define OTG_LBR_WD_EN_BIT BIT(2) -#define CHG_WD_TIMER_EN_BIT BIT(1) -#define IRQ_OP_MASK BIT(0) - -#define PIN_CTRL_REG 0x05 -#define AUTO_CHG_EN_BIT BIT(7) -#define AUTO_LBR_EN_BIT BIT(6) -#define OTG_LBR_BIT BIT(5) -#define I2C_PIN_BIT BIT(4) -#define PIN_EN_CTRL_MASK SMB137B_MASK(2, 2) -#define OTG_LBR_PIN_CTRL_MASK SMB137B_MASK(2, 0) - -#define OTG_LBR_CTRL_REG 0x06 -#define BATT_MISSING_DET_EN_BIT BIT(7) -#define AUTO_RECHARGE_THRESH_MASK BIT(6) -#define USB_DP_DN_DET_EN_MASK BIT(5) -#define OTG_LBR_BATT_CURRENT_LIMIT_MASK SMB137B_MASK(2, 3) -#define OTG_LBR_UVLO_THRESH_MASK SMB137B_MASK(3, 0) - -#define FAULT_INTR_REG 0x07 -#define SAFETY_TIMER_EXP_MASK SMB137B_MASK(1, 7) -#define BATT_TEMP_UNSAFE_MASK SMB137B_MASK(1, 6) -#define INPUT_OVLO_IVLO_MASK SMB137B_MASK(1, 5) -#define BATT_OVLO_MASK SMB137B_MASK(1, 4) -#define INTERNAL_OVER_TEMP_MASK SMB137B_MASK(1, 2) -#define ENTER_TAPER_CHG_MASK SMB137B_MASK(1, 1) -#define CHG_MASK SMB137B_MASK(1, 0) - -#define CELL_TEMP_MON_REG 0x08 -#define THERMISTOR_CURR_MASK SMB137B_MASK(2, 6) -#define LOW_TEMP_CHG_INHIBIT_MASK SMB137B_MASK(3, 3) -#define HIGH_TEMP_CHG_INHIBIT_MASK SMB137B_MASK(3, 0) - -#define SAFETY_TIMER_THERMAL_SHUTDOWN_REG 0x09 -#define DCIN_OVLO_SEL_MASK SMB137B_MASK(2, 7) -#define RELOAD_EN_INPUT_VOLTAGE_MASK SMB137B_MASK(1, 6) -#define THERM_SHUTDN_EN_MASK SMB137B_MASK(1, 5) -#define STANDBY_WD_TIMER_EN_MASK SMB137B_MASK(1, 4) -#define COMPLETE_CHG_TMOUT_MASK SMB137B_MASK(2, 2) -#define PRE_CHG_TMOUT_MASK SMB137B_MASK(2, 0) - -#define VSYS_REG 0x0A -#define VSYS_MASK SMB137B_MASK(3, 4) - -#define IRQ_RESET_REG 0x30 - -#define COMMAND_A_REG 0x31 -#define VOLATILE_REGS_WRITE_PERM_BIT BIT(7) -#define POR_BIT BIT(6) -#define FAST_CHG_SETTINGS_BIT BIT(5) -#define BATT_CHG_EN_BIT BIT(4) -#define USBIN_MODE_500_BIT BIT(3) -#define USBIN_MODE_HCMODE_BIT BIT(2) -#define OTG_LBR_EN_BIT BIT(1) -#define STAT_OE_BIT BIT(0) - -#define STATUS_A_REG 0x32 -#define INTERNAL_TEMP_IRQ_STAT BIT(4) -#define DCIN_OV_IRQ_STAT BIT(3) -#define DCIN_UV_IRQ_STAT BIT(2) -#define USBIN_OV_IRQ_STAT BIT(1) -#define USBIN_UV_IRQ_STAT BIT(0) - -#define STATUS_B_REG 0x33 -#define USB_PIN_STAT BIT(7) -#define USB51_MODE_STAT BIT(6) -#define USB51_HC_MODE_STAT BIT(5) -#define INTERNAL_TEMP_LIMIT_B_STAT BIT(4) -#define DC_IN_OV_STAT BIT(3) -#define DC_IN_UV_STAT BIT(2) -#define USB_IN_OV_STAT BIT(1) -#define USB_IN_UV_STAT BIT(0) - -#define STATUS_C_REG 0x34 -#define AUTO_IN_CURR_LIMIT_MASK SMB137B_MASK(4, 4) -#define AUTO_IN_CURR_LIMIT_STAT BIT(3) -#define AUTO_SOURCE_DET_COMP_STAT_MASK SMB137B_MASK(2, 1) -#define AUTO_SOURCE_DET_RESULT_STAT BIT(0) - -#define STATUS_D_REG 0x35 -#define VBATT_LESS_THAN_VSYS_STAT BIT(7) -#define USB_FAIL_STAT BIT(6) -#define BATT_TEMP_STAT_MASK SMB137B_MASK(2, 4) -#define INTERNAL_TEMP_LIMIT_STAT BIT(2) -#define OTG_LBR_MODE_EN_STAT BIT(1) -#define OTG_LBR_VBATT_UVLO_STAT BIT(0) - -#define STATUS_E_REG 0x36 -#define CHARGE_CYCLE_COUNT_STAT BIT(7) -#define CHARGER_TERM_STAT BIT(6) -#define SAFETY_TIMER_STAT_MASK SMB137B_MASK(2, 4) -#define CHARGER_ERROR_STAT BIT(3) -#define CHARGING_STAT_E SMB137B_MASK(2, 1) -#define CHARGING_EN BIT(0) - -#define STATUS_F_REG 0x37 -#define WD_IRQ_ACTIVE_STAT BIT(7) -#define OTG_OVERCURRENT_STAT BIT(6) -#define BATT_PRESENT_STAT BIT(4) -#define BATT_OV_LATCHED_STAT BIT(3) -#define CHARGER_OVLO_STAT BIT(2) -#define CHARGER_UVLO_STAT BIT(1) -#define BATT_LOW_STAT BIT(0) - -#define STATUS_G_REG 0x38 -#define CHARGE_TIMEOUT_IRQ_STAT BIT(7) -#define PRECHARGE_TIMEOUT_IRQ_STAT BIT(6) -#define BATT_HOT_IRQ_STAT BIT(5) -#define BATT_COLD_IRQ_STAT BIT(4) -#define BATT_OV_IRQ_STAT BIT(3) -#define TAPER_CHG_IRQ_STAT BIT(2) -#define FAST_CHG_IRQ_STAT BIT(1) -#define CHARGING_IRQ_STAT BIT(0) - -#define STATUS_H_REG 0x39 -#define CHARGE_TIMEOUT_STAT BIT(7) -#define PRECHARGE_TIMEOUT_STAT BIT(6) -#define BATT_HOT_STAT BIT(5) -#define BATT_COLD_STAT BIT(4) -#define BATT_OV_STAT BIT(3) -#define TAPER_CHG_STAT BIT(2) -#define FAST_CHG_STAT BIT(1) -#define CHARGING_STAT_H BIT(0) - -#define DEV_ID_REG 0x3B - -#define COMMAND_B_REG 0x3C -#define THERM_NTC_CURR_VERRIDE BIT(7) - -#define SMB137B_CHG_PERIOD ((HZ) * 150) - -#define INPUT_CURRENT_REG_DEFAULT 0xE1 -#define INPUT_CURRENT_REG_MIN 0x01 -#define COMMAND_A_REG_DEFAULT 0xA0 -#define COMMAND_A_REG_OTG_MODE 0xA2 - -#define PIN_CTRL_REG_DEFAULT 0x00 -#define PIN_CTRL_REG_CHG_OFF 0x04 - -#define FAST_CHG_E_STATUS 0x2 - -#define SMB137B_DEFAULT_BATT_RATING 950 -struct smb137b_data { - struct i2c_client *client; - struct delayed_work charge_work; - - bool charging; - int chgcurrent; - int cur_charging_mode; - int max_system_voltage; - int min_system_voltage; - - int valid_n_gpio; - - int batt_status; - int batt_chg_type; - int batt_present; - int min_design; - int max_design; - int batt_mah_rating; - - int usb_status; - - u8 dev_id_reg; - struct msm_hardware_charger adapter_hw_chg; -}; - -static unsigned int disabled; -static DEFINE_MUTEX(init_lock); -static unsigned int init_otg_power; - -enum charger_stat { - SMB137B_ABSENT, - SMB137B_PRESENT, - SMB137B_ENUMERATED, -}; - -static struct smb137b_data *usb_smb137b_chg; - -static int smb137b_read_reg(struct i2c_client *client, int reg, - u8 *val) -{ - s32 ret; - struct smb137b_data *smb137b_chg; - - smb137b_chg = i2c_get_clientdata(client); - ret = i2c_smbus_read_byte_data(smb137b_chg->client, reg); - if (ret < 0) { - dev_err(&smb137b_chg->client->dev, - "i2c read fail: can't read from %02x: %d\n", reg, ret); - return ret; - } else - *val = ret; - - return 0; -} - -static int smb137b_write_reg(struct i2c_client *client, int reg, - u8 val) -{ - s32 ret; - struct smb137b_data *smb137b_chg; - - smb137b_chg = i2c_get_clientdata(client); - ret = i2c_smbus_write_byte_data(smb137b_chg->client, reg, val); - if (ret < 0) { - dev_err(&smb137b_chg->client->dev, - "i2c write fail: can't write %02x to %02x: %d\n", - val, reg, ret); - return ret; - } - return 0; -} - -static ssize_t id_reg_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct smb137b_data *smb137b_chg; - - smb137b_chg = i2c_get_clientdata(to_i2c_client(dev)); - - return sprintf(buf, "%02x\n", smb137b_chg->dev_id_reg); -} -static DEVICE_ATTR(id_reg, S_IRUGO | S_IWUSR, id_reg_show, NULL); - -#ifdef DEBUG -static void smb137b_dbg_print_status_regs(struct smb137b_data *smb137b_chg) -{ - int ret; - u8 temp; - - ret = smb137b_read_reg(smb137b_chg->client, STATUS_A_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s A=0x%x\n", __func__, temp); - ret = smb137b_read_reg(smb137b_chg->client, STATUS_B_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s B=0x%x\n", __func__, temp); - ret = smb137b_read_reg(smb137b_chg->client, STATUS_C_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s C=0x%x\n", __func__, temp); - ret = smb137b_read_reg(smb137b_chg->client, STATUS_D_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s D=0x%x\n", __func__, temp); - ret = smb137b_read_reg(smb137b_chg->client, STATUS_E_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s E=0x%x\n", __func__, temp); - ret = smb137b_read_reg(smb137b_chg->client, STATUS_F_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s F=0x%x\n", __func__, temp); - ret = smb137b_read_reg(smb137b_chg->client, STATUS_G_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s G=0x%x\n", __func__, temp); - ret = smb137b_read_reg(smb137b_chg->client, STATUS_H_REG, &temp); - dev_dbg(&smb137b_chg->client->dev, "%s H=0x%x\n", __func__, temp); -} -#else -static void smb137b_dbg_print_status_regs(struct smb137b_data *smb137b_chg) -{ -} -#endif - -static int smb137b_start_charging(struct msm_hardware_charger *hw_chg, - int chg_voltage, int chg_current) -{ - int cmd_val = COMMAND_A_REG_DEFAULT; - u8 temp = 0; - int ret = 0; - struct smb137b_data *smb137b_chg; - - smb137b_chg = container_of(hw_chg, struct smb137b_data, adapter_hw_chg); - if (disabled) { - dev_err(&smb137b_chg->client->dev, - "%s called when disabled\n", __func__); - goto out; - } - - if (smb137b_chg->charging == true - && smb137b_chg->chgcurrent == chg_current) - /* we are already charging with the same current*/ - dev_err(&smb137b_chg->client->dev, - "%s charge with same current %d called again\n", - __func__, chg_current); - - dev_dbg(&smb137b_chg->client->dev, "%s\n", __func__); - if (chg_current < 500) - cmd_val &= ~USBIN_MODE_500_BIT; - else if (chg_current == 500) - cmd_val |= USBIN_MODE_500_BIT; - else - cmd_val |= USBIN_MODE_HCMODE_BIT; - - smb137b_chg->chgcurrent = chg_current; - smb137b_chg->cur_charging_mode = cmd_val; - - /* Due to non-volatile reload feature,always enable volatile - * mirror writes before modifying any 00h~09h control register. - * Current mode needs to be programmed according to what's detected - * Otherwise default 100mA mode might cause VOUTL drop and fail - * the system in case of dead battery. - */ - ret = smb137b_write_reg(smb137b_chg->client, - COMMAND_A_REG, cmd_val); - if (ret) { - dev_err(&smb137b_chg->client->dev, - "%s couldn't write to command_reg\n", __func__); - goto out; - } - ret = smb137b_write_reg(smb137b_chg->client, - PIN_CTRL_REG, PIN_CTRL_REG_DEFAULT); - if (ret) { - dev_err(&smb137b_chg->client->dev, - "%s couldn't write to pin ctrl reg\n", __func__); - goto out; - } - smb137b_chg->charging = true; - smb137b_chg->batt_status = POWER_SUPPLY_STATUS_CHARGING; - smb137b_chg->batt_chg_type = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; - - ret = smb137b_read_reg(smb137b_chg->client, STATUS_E_REG, &temp); - if (ret) { - dev_err(&smb137b_chg->client->dev, - "%s couldn't read status e reg %d\n", __func__, ret); - } else { - if (temp & CHARGER_ERROR_STAT) { - dev_err(&smb137b_chg->client->dev, - "%s chg error E=0x%x\n", __func__, temp); - smb137b_dbg_print_status_regs(smb137b_chg); - } - if (((temp & CHARGING_STAT_E) >> 1) >= FAST_CHG_E_STATUS) - smb137b_chg->batt_chg_type - = POWER_SUPPLY_CHARGE_TYPE_FAST; - } - /*schedule charge_work to keep track of battery charging state*/ - schedule_delayed_work(&smb137b_chg->charge_work, SMB137B_CHG_PERIOD); - -out: - return ret; -} - -static int smb137b_stop_charging(struct msm_hardware_charger *hw_chg) -{ - int ret = 0; - struct smb137b_data *smb137b_chg; - - smb137b_chg = container_of(hw_chg, struct smb137b_data, adapter_hw_chg); - - dev_dbg(&smb137b_chg->client->dev, "%s\n", __func__); - if (smb137b_chg->charging == false) - return 0; - - smb137b_chg->charging = false; - smb137b_chg->batt_status = POWER_SUPPLY_STATUS_DISCHARGING; - smb137b_chg->batt_chg_type = POWER_SUPPLY_CHARGE_TYPE_NONE; - - ret = smb137b_write_reg(smb137b_chg->client, COMMAND_A_REG, - smb137b_chg->cur_charging_mode); - if (ret) { - dev_err(&smb137b_chg->client->dev, - "%s couldn't write to command_reg\n", __func__); - goto out; - } - - ret = smb137b_write_reg(smb137b_chg->client, - PIN_CTRL_REG, PIN_CTRL_REG_CHG_OFF); - if (ret) - dev_err(&smb137b_chg->client->dev, - "%s couldn't write to pin ctrl reg\n", __func__); - -out: - return ret; -} - -static int smb137b_charger_switch(struct msm_hardware_charger *hw_chg) -{ - struct smb137b_data *smb137b_chg; - - smb137b_chg = container_of(hw_chg, struct smb137b_data, adapter_hw_chg); - dev_dbg(&smb137b_chg->client->dev, "%s\n", __func__); - return 0; -} - -static irqreturn_t smb137b_valid_handler(int irq, void *dev_id) -{ - int val; - struct smb137b_data *smb137b_chg; - struct i2c_client *client = dev_id; - - smb137b_chg = i2c_get_clientdata(client); - - pr_debug("%s Cable Detected USB inserted\n", __func__); - /*extra delay needed to allow CABLE_DET_N settling down and debounce - before trying to sample its correct value*/ - usleep_range(1000, 1200); - val = gpio_get_value_cansleep(smb137b_chg->valid_n_gpio); - if (val < 0) { - dev_err(&smb137b_chg->client->dev, - "%s gpio_get_value failed for %d ret=%d\n", __func__, - smb137b_chg->valid_n_gpio, val); - goto err; - } - dev_dbg(&smb137b_chg->client->dev, "%s val=%d\n", __func__, val); - - if (val) { - if (smb137b_chg->usb_status != SMB137B_ABSENT) { - smb137b_chg->usb_status = SMB137B_ABSENT; - msm_charger_notify_event(&smb137b_chg->adapter_hw_chg, - CHG_REMOVED_EVENT); - } - } else { - if (smb137b_chg->usb_status == SMB137B_ABSENT) { - smb137b_chg->usb_status = SMB137B_PRESENT; - msm_charger_notify_event(&smb137b_chg->adapter_hw_chg, - CHG_INSERTED_EVENT); - } - } -err: - return IRQ_HANDLED; -} - -#ifdef CONFIG_DEBUG_FS -static struct dentry *dent; -static int debug_fs_otg; -static int otg_get(void *data, u64 *value) -{ - *value = debug_fs_otg; - return 0; -} -static int otg_set(void *data, u64 value) -{ - smb137b_otg_power(debug_fs_otg); - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(smb137b_otg_fops, otg_get, otg_set, "%llu\n"); - -static void smb137b_create_debugfs_entries(struct smb137b_data *smb137b_chg) -{ - dent = debugfs_create_dir("smb137b", NULL); - if (dent) { - debugfs_create_file("otg", 0644, dent, NULL, &smb137b_otg_fops); - } -} -static void smb137b_destroy_debugfs_entries(void) -{ - if (dent) - debugfs_remove_recursive(dent); -} -#else -static void smb137b_create_debugfs_entries(struct smb137b_data *smb137b_chg) -{ -} -static void smb137b_destroy_debugfs_entries(void) -{ -} -#endif - -static int set_disable_status_param(const char *val, struct kernel_param *kp) -{ - int ret; - - ret = param_set_int(val, kp); - if (ret) - return ret; - - if (usb_smb137b_chg && disabled) - msm_charger_notify_event(&usb_smb137b_chg->adapter_hw_chg, - CHG_DONE_EVENT); - - pr_debug("%s disabled =%d\n", __func__, disabled); - return 0; -} -module_param_call(disabled, set_disable_status_param, param_get_uint, - &disabled, 0644); -static void smb137b_charge_sm(struct work_struct *smb137b_work) -{ - int ret; - struct smb137b_data *smb137b_chg; - u8 temp = 0; - int notify_batt_changed = 0; - - smb137b_chg = container_of(smb137b_work, struct smb137b_data, - charge_work.work); - - /*if not charging, exit smb137b charging state transition*/ - if (!smb137b_chg->charging) - return; - - dev_dbg(&smb137b_chg->client->dev, "%s\n", __func__); - - ret = smb137b_read_reg(smb137b_chg->client, STATUS_F_REG, &temp); - if (ret) { - dev_err(&smb137b_chg->client->dev, - "%s couldn't read status f reg %d\n", __func__, ret); - goto out; - } - if (smb137b_chg->batt_present != !(temp & BATT_PRESENT_STAT)) { - smb137b_chg->batt_present = !(temp & BATT_PRESENT_STAT); - notify_batt_changed = 1; - } - - if (!smb137b_chg->batt_present) - smb137b_chg->batt_chg_type = POWER_SUPPLY_CHARGE_TYPE_NONE; - - if (!smb137b_chg->batt_present && smb137b_chg->charging) - msm_charger_notify_event(&smb137b_chg->adapter_hw_chg, - CHG_DONE_EVENT); - - if (smb137b_chg->batt_present - && smb137b_chg->charging - && smb137b_chg->batt_chg_type - != POWER_SUPPLY_CHARGE_TYPE_FAST) { - ret = smb137b_read_reg(smb137b_chg->client, - STATUS_E_REG, &temp); - if (ret) { - dev_err(&smb137b_chg->client->dev, - "%s couldn't read cntrl reg\n", __func__); - goto out; - - } else { - if (temp & CHARGER_ERROR_STAT) { - dev_err(&smb137b_chg->client->dev, - "%s error E=0x%x\n", __func__, temp); - smb137b_dbg_print_status_regs(smb137b_chg); - } - if (((temp & CHARGING_STAT_E) >> 1) - >= FAST_CHG_E_STATUS) { - smb137b_chg->batt_chg_type - = POWER_SUPPLY_CHARGE_TYPE_FAST; - notify_batt_changed = 1; - msm_charger_notify_event( - &smb137b_chg->adapter_hw_chg, - CHG_BATT_BEGIN_FAST_CHARGING); - } else { - smb137b_chg->batt_chg_type - = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; - } - } - } - -out: - schedule_delayed_work(&smb137b_chg->charge_work, - SMB137B_CHG_PERIOD); -} - -static void __smb137b_otg_power(int on) -{ - int ret; - - if (on) { - ret = smb137b_write_reg(usb_smb137b_chg->client, - PIN_CTRL_REG, PIN_CTRL_REG_CHG_OFF); - if (ret) { - pr_err("%s turning off charging in pin_ctrl err=%d\n", - __func__, ret); - /* - * don't change the command register if charging in - * pin control cannot be turned off - */ - return; - } - - ret = smb137b_write_reg(usb_smb137b_chg->client, - COMMAND_A_REG, COMMAND_A_REG_OTG_MODE); - if (ret) - pr_err("%s failed turning on OTG mode ret=%d\n", - __func__, ret); - } else { - ret = smb137b_write_reg(usb_smb137b_chg->client, - COMMAND_A_REG, COMMAND_A_REG_DEFAULT); - if (ret) - pr_err("%s failed turning off OTG mode ret=%d\n", - __func__, ret); - ret = smb137b_write_reg(usb_smb137b_chg->client, - PIN_CTRL_REG, PIN_CTRL_REG_DEFAULT); - if (ret) - pr_err("%s failed writing to pn_ctrl ret=%d\n", - __func__, ret); - } -} -static int smb137b_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - const struct smb137b_platform_data *pdata; - struct smb137b_data *smb137b_chg; - int ret = 0; - - pdata = client->dev.platform_data; - - if (pdata == NULL) { - dev_err(&client->dev, "%s no platform data\n", __func__); - ret = -EINVAL; - goto out; - } - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - ret = -EIO; - goto out; - } - - smb137b_chg = kzalloc(sizeof(*smb137b_chg), GFP_KERNEL); - if (!smb137b_chg) { - ret = -ENOMEM; - goto out; - } - - INIT_DELAYED_WORK(&smb137b_chg->charge_work, smb137b_charge_sm); - smb137b_chg->client = client; - smb137b_chg->valid_n_gpio = pdata->valid_n_gpio; - smb137b_chg->batt_mah_rating = pdata->batt_mah_rating; - if (smb137b_chg->batt_mah_rating == 0) - smb137b_chg->batt_mah_rating = SMB137B_DEFAULT_BATT_RATING; - - /*It supports USB-WALL charger and PC USB charger */ - smb137b_chg->adapter_hw_chg.type = CHG_TYPE_USB; - smb137b_chg->adapter_hw_chg.rating = pdata->batt_mah_rating; - smb137b_chg->adapter_hw_chg.name = "smb137b-charger"; - smb137b_chg->adapter_hw_chg.start_charging = smb137b_start_charging; - smb137b_chg->adapter_hw_chg.stop_charging = smb137b_stop_charging; - smb137b_chg->adapter_hw_chg.charging_switched = smb137b_charger_switch; - - if (pdata->chg_detection_config) - ret = pdata->chg_detection_config(); - if (ret) { - dev_err(&client->dev, "%s valid config failed ret=%d\n", - __func__, ret); - goto free_smb137b_chg; - } - - ret = gpio_request(pdata->valid_n_gpio, "smb137b_charger_valid"); - if (ret) { - dev_err(&client->dev, "%s gpio_request failed for %d ret=%d\n", - __func__, pdata->valid_n_gpio, ret); - goto free_smb137b_chg; - } - - i2c_set_clientdata(client, smb137b_chg); - - ret = msm_charger_register(&smb137b_chg->adapter_hw_chg); - if (ret) { - dev_err(&client->dev, "%s msm_charger_register\ - failed for ret=%d\n", __func__, ret); - goto free_valid_gpio; - } - - ret = irq_set_irq_wake(client->irq, 1); - if (ret) { - dev_err(&client->dev, "%s failed for irq_set_irq_wake %d ret =%d\n", - __func__, client->irq, ret); - goto unregister_charger; - } - - ret = request_threaded_irq(client->irq, NULL, - smb137b_valid_handler, - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, - "smb137b_charger_valid", client); - if (ret) { - dev_err(&client->dev, - "%s request_threaded_irq failed for %d ret =%d\n", - __func__, client->irq, ret); - goto disable_irq_wake; - } - - ret = gpio_get_value_cansleep(smb137b_chg->valid_n_gpio); - if (ret < 0) { - dev_err(&client->dev, - "%s gpio_get_value failed for %d ret=%d\n", __func__, - pdata->valid_n_gpio, ret); - /* assume absent */ - ret = 1; - } - if (!ret) { - msm_charger_notify_event(&smb137b_chg->adapter_hw_chg, - CHG_INSERTED_EVENT); - smb137b_chg->usb_status = SMB137B_PRESENT; - } - - ret = smb137b_read_reg(smb137b_chg->client, DEV_ID_REG, - &smb137b_chg->dev_id_reg); - - ret = device_create_file(&smb137b_chg->client->dev, &dev_attr_id_reg); - - /* TODO read min_design and max_design from chip registers */ - smb137b_chg->min_design = 3200; - smb137b_chg->max_design = 4200; - - smb137b_chg->batt_status = POWER_SUPPLY_STATUS_DISCHARGING; - smb137b_chg->batt_chg_type = POWER_SUPPLY_CHARGE_TYPE_NONE; - - device_init_wakeup(&client->dev, 1); - - mutex_lock(&init_lock); - usb_smb137b_chg = smb137b_chg; - if (init_otg_power) - __smb137b_otg_power(init_otg_power); - mutex_unlock(&init_lock); - - smb137b_create_debugfs_entries(smb137b_chg); - dev_dbg(&client->dev, - "%s OK device_id = %x chg_state=%d\n", __func__, - smb137b_chg->dev_id_reg, smb137b_chg->usb_status); - return 0; - -disable_irq_wake: - irq_set_irq_wake(client->irq, 0); -unregister_charger: - msm_charger_unregister(&smb137b_chg->adapter_hw_chg); -free_valid_gpio: - gpio_free(pdata->valid_n_gpio); -free_smb137b_chg: - kfree(smb137b_chg); -out: - return ret; -} - -void smb137b_otg_power(int on) -{ - pr_debug("%s Enter on=%d\n", __func__, on); - - mutex_lock(&init_lock); - if (!usb_smb137b_chg) { - init_otg_power = !!on; - pr_warning("%s called when not initialized\n", __func__); - mutex_unlock(&init_lock); - return; - } - __smb137b_otg_power(on); - mutex_unlock(&init_lock); -} - -static int smb137b_remove(struct i2c_client *client) -{ - const struct smb137b_platform_data *pdata; - struct smb137b_data *smb137b_chg = i2c_get_clientdata(client); - - pdata = client->dev.platform_data; - device_init_wakeup(&client->dev, 0); - irq_set_irq_wake(client->irq, 0); - free_irq(client->irq, client); - gpio_free(pdata->valid_n_gpio); - cancel_delayed_work_sync(&smb137b_chg->charge_work); - - msm_charger_notify_event(&smb137b_chg->adapter_hw_chg, - CHG_REMOVED_EVENT); - msm_charger_unregister(&smb137b_chg->adapter_hw_chg); - smb137b_destroy_debugfs_entries(); - kfree(smb137b_chg); - return 0; -} - -#ifdef CONFIG_PM -static int smb137b_suspend(struct device *dev) -{ - struct smb137b_data *smb137b_chg = dev_get_drvdata(dev); - - dev_dbg(&smb137b_chg->client->dev, "%s\n", __func__); - if (smb137b_chg->charging) - return -EBUSY; - return 0; -} - -static int smb137b_resume(struct device *dev) -{ - struct smb137b_data *smb137b_chg = dev_get_drvdata(dev); - - dev_dbg(&smb137b_chg->client->dev, "%s\n", __func__); - return 0; -} - -static const struct dev_pm_ops smb137b_pm_ops = { - .suspend = smb137b_suspend, - .resume = smb137b_resume, -}; -#endif - -static const struct i2c_device_id smb137b_id[] = { - {"smb137b", 0}, - {}, -}; -MODULE_DEVICE_TABLE(i2c, smb137b_id); - -static struct i2c_driver smb137b_driver = { - .driver = { - .name = "smb137b", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &smb137b_pm_ops, -#endif - }, - .probe = smb137b_probe, - .remove = smb137b_remove, - .id_table = smb137b_id, -}; - -static int __init smb137b_init(void) -{ - return i2c_add_driver(&smb137b_driver); -} -module_init(smb137b_init); - -static void __exit smb137b_exit(void) -{ - return i2c_del_driver(&smb137b_driver); -} -module_exit(smb137b_exit); - -MODULE_AUTHOR("Abhijeet Dharmapurikar "); -MODULE_DESCRIPTION("Driver for SMB137B Charger chip"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("i2c:smb137b"); diff --git a/drivers/power/smb349.c b/drivers/power/smb349.c deleted file mode 100644 index 0137b85c394fd53b6a9af6857262ac93af5e6e04..0000000000000000000000000000000000000000 --- a/drivers/power/smb349.c +++ /dev/null @@ -1,706 +0,0 @@ -/* Copyright (c) 2012 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. - * - */ -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SMB349_MASK(BITS, POS) ((unsigned char)(((1 << BITS) - 1) << POS)) - -/* Register definitions */ -#define CHG_CURRENT_REG 0x00 -#define CHG_OTHER_CURRENT_REG 0x01 -#define VAR_FUNC_REG 0x02 -#define FLOAT_VOLTAGE_REG 0x03 -#define CHG_CTRL_REG 0x04 -#define STAT_TIMER_REG 0x05 -#define PIN_ENABLE_CTRL_REG 0x06 -#define THERM_CTRL_A_REG 0x07 -#define SYSOK_USB3_SELECT_REG 0x08 -#define CTRL_FUNCTIONS_REG 0x09 -#define OTG_TLIM_THERM_CNTRL_REG 0x0A -#define HARD_SOFT_LIMIT_CELL_TEMP_MONITOR_REG 0x0B -#define FAULT_IRQ_REG 0x0C -#define STATUS_IRQ_REG 0x0D -#define SYSOK_REG 0x0E -#define CMD_A_REG 0x30 -#define CMD_B_REG 0x31 -#define CMD_C_REG 0x33 -#define IRQ_A_REG 0x35 -#define IRQ_B_REG 0x36 -#define IRQ_C_REG 0x37 -#define IRQ_D_REG 0x38 -#define IRQ_E_REG 0x39 -#define IRQ_F_REG 0x3A -#define STATUS_A_REG 0x3B -#define STATUS_B_REG 0x3C -#define STATUS_C_REG 0x3D -#define STATUS_D_REG 0x3E -#define STATUS_E_REG 0x3F - -/* Status bits and masks */ -#define CHG_STATUS_MASK SMB349_MASK(2, 1) -#define CHG_ENABLE_STATUS_BIT BIT(0) - -/* Control bits and masks */ -#define FAST_CHG_CURRENT_MASK SMB349_MASK(4, 4) -#define AC_INPUT_CURRENT_LIMIT_MASK SMB349_MASK(4, 0) -#define PRE_CHG_CURRENT_MASK SMB349_MASK(3, 5) -#define TERMINATION_CURRENT_MASK SMB349_MASK(3, 2) -#define PRE_CHG_TO_FAST_CHG_THRESH_MASK SMB349_MASK(2, 6) -#define FLOAT_VOLTAGE_MASK SMB349_MASK(6, 0) -#define CHG_ENABLE_BIT BIT(1) -#define VOLATILE_W_PERM_BIT BIT(7) -#define USB_SELECTION_BIT BIT(1) -#define SYSTEM_FET_ENABLE_BIT BIT(7) -#define AUTOMATIC_INPUT_CURR_LIMIT_BIT BIT(4) -#define AUTOMATIC_POWER_SOURCE_DETECTION_BIT BIT(2) -#define BATT_OV_END_CHG_BIT BIT(1) -#define VCHG_FUNCTION BIT(0) -#define CURR_TERM_END_CHG_BIT BIT(6) - -struct smb349_struct { - struct i2c_client *client; - bool charging; - bool present; - int chg_current_ma; - - int en_n_gpio; - int chg_susp_gpio; - struct dentry *dent; - spinlock_t lock; - - struct work_struct chg_work; - struct power_supply dc_psy; -}; - -struct chg_ma_limit_entry { - int fast_chg_ma_limit; - int ac_input_ma_limit; - u8 chg_current_value; -}; - -static struct smb349_struct *the_smb349_chg; - -static int smb349_read_reg(struct i2c_client *client, int reg, - u8 *val) -{ - s32 ret; - struct smb349_struct *smb349_chg; - - smb349_chg = i2c_get_clientdata(client); - ret = i2c_smbus_read_byte_data(smb349_chg->client, reg); - if (ret < 0) { - dev_err(&smb349_chg->client->dev, - "i2c read fail: can't read from %02x: %d\n", reg, ret); - return ret; - } else { - *val = ret; - } - - return 0; -} - -static int smb349_write_reg(struct i2c_client *client, int reg, - u8 val) -{ - s32 ret; - struct smb349_struct *smb349_chg; - - smb349_chg = i2c_get_clientdata(client); - ret = i2c_smbus_write_byte_data(smb349_chg->client, reg, val); - if (ret < 0) { - dev_err(&smb349_chg->client->dev, - "i2c write fail: can't write %02x to %02x: %d\n", - val, reg, ret); - return ret; - } - return 0; -} - -static int smb349_masked_write(struct i2c_client *client, int reg, - u8 mask, u8 val) -{ - s32 rc; - u8 temp; - - rc = smb349_read_reg(client, reg, &temp); - if (rc) { - pr_err("smb349_read_reg failed: reg=%03X, rc=%d\n", reg, rc); - return rc; - } - temp &= ~mask; - temp |= val & mask; - rc = smb349_write_reg(client, reg, temp); - if (rc) { - pr_err("smb349_write failed: reg=%03X, rc=%d\n", reg, rc); - return rc; - } - return 0; -} - -static enum power_supply_property pm_power_props[] = { - POWER_SUPPLY_PROP_ONLINE, - POWER_SUPPLY_PROP_CURRENT_MAX, - POWER_SUPPLY_PROP_CHARGE_TYPE, -}; - -static char *pm_power_supplied_to[] = { - "battery", -}; - -static int get_prop_charge_type(struct smb349_struct *smb349_chg) -{ - if (smb349_chg->charging) - return POWER_SUPPLY_CHARGE_TYPE_FAST; - - return POWER_SUPPLY_CHARGE_TYPE_NONE; -} - -static int pm_power_get_property(struct power_supply *psy, - enum power_supply_property psp, - union power_supply_propval *val) -{ - struct smb349_struct *smb349_chg = container_of(psy, - struct smb349_struct, - dc_psy); - - switch (psp) { - case POWER_SUPPLY_PROP_CURRENT_MAX: - val->intval = smb349_chg->chg_current_ma; - break; - case POWER_SUPPLY_PROP_ONLINE: - val->intval = (int)smb349_chg->present; - break; - case POWER_SUPPLY_PROP_CHARGE_TYPE: - val->intval = get_prop_charge_type(smb349_chg); - break; - default: - return -EINVAL; - } - return 0; -} - -#define SMB349_FAST_CHG_MIN_MA 1000 -#define SMB349_FAST_CHG_STEP_MA 200 -#define SMB349_FAST_CHG_MAX_MA 4000 -#define SMB349_FAST_CHG_SHIFT 4 -static int chg_current_set(struct smb349_struct *smb349_chg) -{ - u8 temp; - - if ((smb349_chg->chg_current_ma < SMB349_FAST_CHG_MIN_MA) || - (smb349_chg->chg_current_ma > SMB349_FAST_CHG_MAX_MA)) { - pr_err("bad mA=%d asked to set\n", smb349_chg->chg_current_ma); - return -EINVAL; - } - - temp = (smb349_chg->chg_current_ma - SMB349_FAST_CHG_MIN_MA) - / SMB349_FAST_CHG_STEP_MA; - - temp = temp << SMB349_FAST_CHG_SHIFT; - pr_debug("fastchg limit=%d setting %02x\n", - smb349_chg->chg_current_ma, temp); - return smb349_masked_write(smb349_chg->client, CHG_CURRENT_REG, - FAST_CHG_CURRENT_MASK, temp); -} - -static int set_reg(void *data, u64 val) -{ - int addr = (int)data; - int ret; - u8 temp; - - temp = (u16) val; - ret = smb349_write_reg(the_smb349_chg->client, addr, temp); - - if (ret) { - pr_err("smb349_write_reg to %x value =%d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - return 0; -} -static int get_reg(void *data, u64 *val) -{ - int addr = (int)data; - int ret; - u8 temp = 0; - - ret = smb349_read_reg(the_smb349_chg->client, addr, &temp); - if (ret) { - pr_err("smb349_read_reg to %x value =%d errored = %d\n", - addr, temp, ret); - return -EAGAIN; - } - - *val = temp; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(reg_fops, get_reg, set_reg, "0x%02llx\n"); - -static void create_debugfs_entries(struct smb349_struct *smb349_chg) -{ - struct dentry *file; - smb349_chg->dent = debugfs_create_dir(SMB349_NAME, NULL); - if (IS_ERR(smb349_chg->dent)) { - pr_err("smb349 driver couldn't create debugfs dir\n"); - return; - } - - file = debugfs_create_file("CHG_CURRENT_REG", 0644, smb349_chg->dent, - (void *) CHG_CURRENT_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("CHG_OTHER_CURRENT_REG", 0644, - smb349_chg->dent, (void *) CHG_OTHER_CURRENT_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("VAR_FUNC_REG", 0644, smb349_chg->dent, - (void *) VAR_FUNC_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("FLOAT_VOLTAGE_REG", 0644, smb349_chg->dent, - (void *) FLOAT_VOLTAGE_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("CHG_CTRL_REG", 0644, smb349_chg->dent, - (void *) CHG_CTRL_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("STAT_TIMER_REG", 0644, smb349_chg->dent, - (void *) STAT_TIMER_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("PIN_ENABLE_CTRL_REG", 0644, - smb349_chg->dent, (void *) PIN_ENABLE_CTRL_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("PIN_ENABLE_CTRL_REG", 0644, - smb349_chg->dent, (void *) PIN_ENABLE_CTRL_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("PIN_ENABLE_CTRL_REG", 0644, - smb349_chg->dent, (void *) PIN_ENABLE_CTRL_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("THERM_CTRL_A_REG", 0644, smb349_chg->dent, - (void *) THERM_CTRL_A_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("SYSOK_USB3_SELECT_REG", 0644, - smb349_chg->dent, (void *) SYSOK_USB3_SELECT_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("CTRL_FUNCTIONS_REG", 0644, - smb349_chg->dent, (void *) CTRL_FUNCTIONS_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("OTG_TLIM_THERM_CNTRL_REG", 0644, - smb349_chg->dent, (void *) OTG_TLIM_THERM_CNTRL_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("HARD_SOFT_LIMIT_CELL_TEMP_MONITOR_REG", - 0644, smb349_chg->dent, - (void *) HARD_SOFT_LIMIT_CELL_TEMP_MONITOR_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("SYSOK_REG", 0644, smb349_chg->dent, - (void *) SYSOK_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("CMD_A_REG", 0644, smb349_chg->dent, - (void *) CMD_A_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("CMD_B_REG", 0644, smb349_chg->dent, - (void *) CMD_B_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("CMD_C_REG", 0644, smb349_chg->dent, - (void *) CMD_C_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("STATUS_A_REG", 0644, smb349_chg->dent, - (void *) STATUS_A_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("STATUS_B_REG", 0644, smb349_chg->dent, - (void *) STATUS_B_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("STATUS_C_REG", 0644, smb349_chg->dent, - (void *) STATUS_C_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("STATUS_D_REG", 0644, smb349_chg->dent, - (void *) STATUS_D_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } - file = debugfs_create_file("STATUS_E_REG", 0644, smb349_chg->dent, - (void *) STATUS_E_REG, ®_fops); - if (IS_ERR(file)) { - pr_err("smb349 driver couldn't create debugfs files\n"); - return; - } -} - -static void remove_debugfs_entries(struct smb349_struct *smb349_chg) -{ - if (smb349_chg->dent) - debugfs_remove_recursive(smb349_chg->dent); -} - -static int smb349_hwinit(struct smb349_struct *smb349_chg) -{ - int ret; - - ret = smb349_write_reg(smb349_chg->client, CMD_A_REG, - VOLATILE_W_PERM_BIT); - if (ret) { - pr_err("Failed to set VOLATILE_W_PERM_BIT rc=%d\n", ret); - return ret; - } - - ret = smb349_masked_write(smb349_chg->client, CHG_CTRL_REG, - CURR_TERM_END_CHG_BIT, CURR_TERM_END_CHG_BIT); - if (ret) { - pr_err("Failed to set CURR_TERM_END_CHG_BIT rc=%d\n", ret); - return ret; - } - - ret = chg_current_set(smb349_chg); - if (ret) { - pr_err("Failed to set FAST_CHG_CURRENT rc=%d\n", ret); - return ret; - } - - return 0; -} - -static int smb349_stop_charging(struct smb349_struct *smb349_chg) -{ - unsigned long flags; - int rc = 0; - - spin_lock_irqsave(&smb349_chg->lock, flags); - pr_debug("stop charging %d\n", smb349_chg->charging); - smb349_chg->charging = 0; - spin_unlock_irqrestore(&smb349_chg->lock, flags); - - if (smb349_chg->charging) - rc = schedule_work(&smb349_chg->chg_work); - - return rc; -} - -static int smb349_start_charging(struct smb349_struct *smb349_chg) -{ - unsigned long flags; - int rc; - - rc = 0; - spin_lock_irqsave(&smb349_chg->lock, flags); - pr_debug("start charging %d\n", smb349_chg->charging); - smb349_chg->charging = 1; - spin_unlock_irqrestore(&smb349_chg->lock, flags); - - if (!smb349_chg->charging) - rc = schedule_work(&smb349_chg->chg_work); - - return rc; -} - -static int pm_power_set_property(struct power_supply *psy, - enum power_supply_property psp, - const union power_supply_propval *val) -{ - struct smb349_struct *smb349_chg = container_of(psy, - struct smb349_struct, - dc_psy); - - switch (psp) { - case POWER_SUPPLY_PROP_ONLINE: - if (val->intval) { - smb349_chg->present = val->intval; - } else { - smb349_chg->present = 0; - if (smb349_chg->charging) - return smb349_stop_charging(smb349_chg); - } - break; - case POWER_SUPPLY_PROP_CURRENT_MAX: - if (val->intval) { - if (smb349_chg->chg_current_ma != val->intval) - return -EINVAL; - } - break; - case POWER_SUPPLY_PROP_CHARGE_TYPE: - if (val->intval && smb349_chg->present) { - if (val->intval == POWER_SUPPLY_CHARGE_TYPE_FAST) - return smb349_start_charging(smb349_chg); - if (val->intval == POWER_SUPPLY_CHARGE_TYPE_NONE) - return smb349_stop_charging(smb349_chg); - } else { - return -EINVAL; - } - break; - default: - return -EINVAL; - } - power_supply_changed(&smb349_chg->dc_psy); - return 0; -} - -static void chg_worker(struct work_struct *work) -{ - struct smb349_struct *smb349_chg = container_of(work, - struct smb349_struct, chg_work); - int ret = 0; - - gpio_set_value_cansleep(smb349_chg->en_n_gpio, smb349_chg->charging); - - /* - * Write non-default values, charger chip reloads from - * non-volatile memory if it was in suspend mode - * - */ - if (smb349_chg->charging) - ret = smb349_hwinit(smb349_chg); - if (ret) - pr_err("Failed to re-initilaze registers\n"); - - power_supply_changed(&smb349_chg->dc_psy); -} - -static int smb349_init_ext_chg(struct smb349_struct *smb349_chg) -{ - int ret; - - smb349_chg->dc_psy.name = "dc"; - smb349_chg->dc_psy.type = POWER_SUPPLY_TYPE_MAINS; - smb349_chg->dc_psy.supplied_to = pm_power_supplied_to; - smb349_chg->dc_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to); - smb349_chg->dc_psy.properties = pm_power_props; - smb349_chg->dc_psy.num_properties = ARRAY_SIZE(pm_power_props); - smb349_chg->dc_psy.get_property = pm_power_get_property; - smb349_chg->dc_psy.set_property = pm_power_set_property; - - ret = power_supply_register(&smb349_chg->client->dev, - &smb349_chg->dc_psy); - if (ret) { - pr_err("failed to register power_supply. ret=%d.\n", ret); - return ret; - } - - return 0; -} - -static int smb349_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - const struct smb349_platform_data *pdata; - struct smb349_struct *smb349_chg; - int ret = 0; - - pdata = client->dev.platform_data; - - if (pdata == NULL) { - dev_err(&client->dev, "%s no platform data\n", __func__); - ret = -EINVAL; - goto out; - } - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - ret = -EIO; - goto out; - } - - smb349_chg = kzalloc(sizeof(*smb349_chg), GFP_KERNEL); - if (!smb349_chg) { - ret = -ENOMEM; - goto out; - } - - smb349_chg->client = client; - smb349_chg->chg_current_ma = pdata->chg_current_ma; - ret = gpio_request(pdata->chg_susp_gpio, "smb349_suspend"); - if (ret) { - dev_err(&client->dev, "%s gpio_request failed for %d ret=%d\n", - __func__, pdata->chg_susp_gpio, ret); - goto free_smb349_chg; - } - smb349_chg->chg_susp_gpio = pdata->chg_susp_gpio; - - ret = gpio_request(pdata->en_n_gpio, "smb349_charger_enable"); - if (ret) { - dev_err(&client->dev, "%s gpio_request failed for %d ret=%d\n", - __func__, pdata->en_n_gpio, ret); - goto chg_susp_gpio_fail; - } - smb349_chg->en_n_gpio = pdata->en_n_gpio; - - i2c_set_clientdata(client, smb349_chg); - - ret = smb349_hwinit(smb349_chg); - if (ret) - goto free_smb349_chg; - - ret = smb349_init_ext_chg(smb349_chg); - if (ret) - goto chg_en_gpio_fail; - - the_smb349_chg = smb349_chg; - - spin_lock_init(&smb349_chg->lock); - - create_debugfs_entries(smb349_chg); - INIT_WORK(&smb349_chg->chg_work, chg_worker); - - pr_info("OK connector present = %d\n", smb349_chg->present); - return 0; - -chg_en_gpio_fail: - gpio_free(smb349_chg->en_n_gpio); -chg_susp_gpio_fail: - gpio_free(smb349_chg->chg_susp_gpio); -free_smb349_chg: - kfree(smb349_chg); -out: - return ret; -} - -static int smb349_remove(struct i2c_client *client) -{ - const struct smb349_platform_data *pdata; - struct smb349_struct *smb349_chg = i2c_get_clientdata(client); - - flush_work(&smb349_chg->chg_work); - pdata = client->dev.platform_data; - power_supply_unregister(&smb349_chg->dc_psy); - gpio_free(pdata->en_n_gpio); - gpio_free(pdata->chg_susp_gpio); - remove_debugfs_entries(smb349_chg); - kfree(smb349_chg); - return 0; -} - -static int smb349_suspend(struct device *dev) -{ - struct smb349_struct *smb349_chg = dev_get_drvdata(dev); - - pr_debug("suspend\n"); - if (smb349_chg->charging) - return -EBUSY; - return 0; -} - -static int smb349_resume(struct device *dev) -{ - pr_debug("resume\n"); - - return 0; -} - -static const struct dev_pm_ops smb349_pm_ops = { - .suspend = smb349_suspend, - .resume = smb349_resume, -}; - -static const struct i2c_device_id smb349_id[] = { - {SMB349_NAME, 0}, - {}, -}; -MODULE_DEVICE_TABLE(i2c, smb349_id); - -static struct i2c_driver smb349_driver = { - .driver = { - .name = SMB349_NAME, - .owner = THIS_MODULE, - .pm = &smb349_pm_ops, - }, - .probe = smb349_probe, - .remove = smb349_remove, - .id_table = smb349_id, -}; - -static int __init smb349_init(void) -{ - return i2c_add_driver(&smb349_driver); -} -module_init(smb349_init); - -static void __exit smb349_exit(void) -{ - return i2c_del_driver(&smb349_driver); -} -module_exit(smb349_exit); - -MODULE_DESCRIPTION("Driver for SMB349 charger chip"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("i2c:" SMB349_NAME); diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 9cb190fbddc2e98479016b27070805deac4f0c9f..25ed1fc7e2268dabae453ce71dc55b11ed76c6db 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -533,47 +533,6 @@ config REGULATOR_AS3711 This driver provides support for the voltage regulators on the AS3711 PMIC -config REGULATOR_PMIC8058 - tristate "PMIC8058 regulator driver" - depends on PMIC8058 && (ARCH_MSM8X60 || ARCH_FSM9XXX) - default y if PMIC8058 && (ARCH_MSM8X60 || ARCH_FSM9XXX) - help - Say Y here to support the voltage regulators on PMIC8058 - -config REGULATOR_PMIC8901 - tristate "PMIC8901 regulator driver" - depends on PMIC8901 && ARCH_MSM8X60 - default y if PMIC8901 && ARCH_MSM8X60 - help - Say Y here to support the voltage regulators on PMIC8901 - -config REGULATOR_PM8XXX - tristate "Qualcomm PM8XXX PMIC Voltage regulators" - depends on MFD_PM8XXX - help - This driver supports voltage regulators in Qualcomm PM8XXX PMIC chips. - PM8XXX chips provide several different varieties of LDO and switching - regulators. They also provide negative charge pumps and voltage - switches. - -config REGULATOR_MSM_GPIO - tristate "MSM GPIO regulator" - depends on GPIOLIB - help - This driver provides a regulator wrapper around a GPIO pin that is set - to output. It is intended to be used for GPIO pins that provide the - enable signal to a physical regulator. The GPIO enable signal can - be configured to be active high (default) or active low. - -config REGULATOR_PM8058_XO - tristate "PM8058 XO Buffer driver" - depends on PMIC8058 - default n - help - This driver supports xo buffer control in the Qualcomm PM8058 PMIC - chip. It is only supposed to be used when Linux on application - processor is the master in control of XO buffers. - config REGULATOR_STUB tristate "Stub Regulator" help diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 1ed57bd7db4a6cc609ded012892ce1d4a6554b12..064ea0a6161d088bbd93bace9be9ab1f44cd7382 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -62,11 +62,6 @@ obj-$(CONFIG_REGULATOR_TPS65217) += tps65217-regulator.o obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o -obj-$(CONFIG_REGULATOR_PMIC8058) += pmic8058-regulator.o -obj-$(CONFIG_REGULATOR_PMIC8901) += pmic8901-regulator.o -obj-$(CONFIG_REGULATOR_MSM_GPIO) += msm-gpio-regulator.o -obj-$(CONFIG_REGULATOR_PM8058_XO) += pm8058-xo.o -obj-$(CONFIG_REGULATOR_PM8XXX) += pm8xxx-regulator.o obj-$(CONFIG_REGULATOR_STUB) += stub-regulator.o obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o diff --git a/drivers/regulator/msm-gpio-regulator.c b/drivers/regulator/msm-gpio-regulator.c deleted file mode 100644 index 560cc4d0a563810d3b04a7f5dd50ae58670765c5..0000000000000000000000000000000000000000 --- a/drivers/regulator/msm-gpio-regulator.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct gpio_vreg { - struct regulator_desc desc; - struct regulator_dev *rdev; - char *gpio_label; - char *name; - unsigned gpio; - int active_low; - bool gpio_requested; -}; - -static int gpio_vreg_request_gpio(struct gpio_vreg *vreg) -{ - int rc = 0; - - /* Request GPIO now if it hasn't been requested before. */ - if (!vreg->gpio_requested) { - rc = gpio_request(vreg->gpio, vreg->gpio_label); - if (rc < 0) { - pr_err("failed to request gpio %u (%s), rc=%d\n", - vreg->gpio, vreg->gpio_label, rc); - return rc; - } else { - vreg->gpio_requested = true; - } - - rc = gpio_sysfs_set_active_low(vreg->gpio, vreg->active_low); - if (rc < 0) - pr_err("active_low=%d failed for gpio %u, rc=%d\n", - vreg->active_low, vreg->gpio, rc); - } - - return rc; -} - -static int gpio_vreg_is_enabled(struct regulator_dev *rdev) -{ - struct gpio_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = gpio_vreg_request_gpio(vreg); - if (rc < 0) - return rc; - - return (gpio_get_value_cansleep(vreg->gpio) ? 1 : 0) ^ vreg->active_low; -} - -static int gpio_vreg_enable(struct regulator_dev *rdev) -{ - struct gpio_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = gpio_vreg_request_gpio(vreg); - if (rc < 0) - return rc; - - return gpio_direction_output(vreg->gpio, !vreg->active_low); -} - -static int gpio_vreg_disable(struct regulator_dev *rdev) -{ - struct gpio_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = gpio_vreg_request_gpio(vreg); - if (rc < 0) - return rc; - - return gpio_direction_output(vreg->gpio, vreg->active_low); -} - -static struct regulator_ops gpio_vreg_ops = { - .enable = gpio_vreg_enable, - .disable = gpio_vreg_disable, - .is_enabled = gpio_vreg_is_enabled, -}; - -static int gpio_vreg_probe(struct platform_device *pdev) -{ - const struct gpio_regulator_platform_data *pdata; - struct gpio_vreg *vreg; - int rc = 0; - - pdata = pdev->dev.platform_data; - - if (!pdata) { - pr_err("platform data required.\n"); - return -EINVAL; - } - - if (!pdata->gpio_label) { - pr_err("gpio_label required.\n"); - return -EINVAL; - } - - if (!pdata->regulator_name) { - pr_err("regulator_name required.\n"); - return -EINVAL; - } - - vreg = kzalloc(sizeof(struct gpio_vreg), GFP_KERNEL); - if (!vreg) { - pr_err("kzalloc failed.\n"); - return -ENOMEM; - } - - vreg->name = kstrdup(pdata->regulator_name, GFP_KERNEL); - if (!vreg->name) { - pr_err("kzalloc failed.\n"); - rc = -ENOMEM; - goto free_vreg; - } - - vreg->gpio_label = kstrdup(pdata->gpio_label, GFP_KERNEL); - if (!vreg->gpio_label) { - pr_err("kzalloc failed.\n"); - rc = -ENOMEM; - goto free_name; - } - - vreg->gpio = pdata->gpio; - vreg->active_low = (pdata->active_low ? 1 : 0); - vreg->gpio_requested = false; - - vreg->desc.name = vreg->name; - vreg->desc.id = pdev->id; - vreg->desc.ops = &gpio_vreg_ops; - vreg->desc.type = REGULATOR_VOLTAGE; - vreg->desc.owner = THIS_MODULE; - - vreg->rdev = regulator_register(&vreg->desc, &pdev->dev, - &pdata->init_data, vreg, NULL); - if (IS_ERR(vreg->rdev)) { - rc = PTR_ERR(vreg->rdev); - pr_err("%s: regulator_register failed, rc=%d.\n", vreg->name, - rc); - goto free_gpio_label; - } - - platform_set_drvdata(pdev, vreg); - - pr_info("id=%d, name=%s, gpio=%u, gpio_label=%s\n", pdev->id, - vreg->name, vreg->gpio, vreg->gpio_label); - - return rc; - -free_gpio_label: - kfree(vreg->gpio_label); -free_name: - kfree(vreg->name); -free_vreg: - kfree(vreg); - - return rc; -} - -static int gpio_vreg_remove(struct platform_device *pdev) -{ - struct gpio_vreg *vreg = platform_get_drvdata(pdev); - - if (vreg->gpio_requested) - gpio_free(vreg->gpio); - - regulator_unregister(vreg->rdev); - kfree(vreg->name); - kfree(vreg->gpio_label); - kfree(vreg); - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver gpio_vreg_driver = { - .probe = gpio_vreg_probe, - .remove = gpio_vreg_remove, - .driver = { - .name = GPIO_REGULATOR_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init gpio_vreg_init(void) -{ - return platform_driver_register(&gpio_vreg_driver); -} - -static void __exit gpio_vreg_exit(void) -{ - platform_driver_unregister(&gpio_vreg_driver); -} - -postcore_initcall(gpio_vreg_init); -module_exit(gpio_vreg_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("GPIO regulator driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" GPIO_REGULATOR_DEV_NAME); diff --git a/drivers/regulator/pm8058-xo.c b/drivers/regulator/pm8058-xo.c deleted file mode 100644 index 31b3e5adb0db088bae620b7ad3cec74d2fb28e16..0000000000000000000000000000000000000000 --- a/drivers/regulator/pm8058-xo.c +++ /dev/null @@ -1,214 +0,0 @@ -/* Copyright (c) 2011, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* XO buffer masks and values */ - -#define XO_PULLDOWN_MASK 0x08 -#define XO_PULLDOWN_ENABLE 0x08 -#define XO_PULLDOWN_DISABLE 0x00 - -#define XO_BUFFER_MASK 0x04 -#define XO_BUFFER_ENABLE 0x04 -#define XO_BUFFER_DISABLE 0x00 - -#define XO_MODE_MASK 0x01 -#define XO_MODE_MANUAL 0x00 - -#define XO_ENABLE_MASK (XO_MODE_MASK | XO_BUFFER_MASK) -#define XO_ENABLE (XO_MODE_MANUAL | XO_BUFFER_ENABLE) -#define XO_DISABLE (XO_MODE_MANUAL | XO_BUFFER_DISABLE) - -struct pm8058_xo_buffer { - struct device *dev; - struct pm8058_xo_pdata *pdata; - struct regulator_dev *rdev; - u16 ctrl_addr; - u8 ctrl_reg; -}; - -#define XO_BUFFER(_id, _ctrl_addr) \ - [PM8058_XO_ID_##_id] = { \ - .ctrl_addr = _ctrl_addr, \ - } - -static struct pm8058_xo_buffer pm8058_xo_buffer[] = { - XO_BUFFER(A0, 0x185), - XO_BUFFER(A1, 0x186), -}; - -static int pm8058_xo_buffer_write(struct pm8058_xo_buffer *xo, - u16 addr, u8 val, u8 mask, u8 *reg_save) -{ - u8 reg; - int rc = 0; - - reg = (*reg_save & ~mask) | (val & mask); - if (reg != *reg_save) - rc = pm8xxx_writeb(xo->dev->parent, addr, reg); - - if (rc) - pr_err("FAIL: pm8xxx_write: rc=%d\n", rc); - else - *reg_save = reg; - return rc; -} - -static int pm8058_xo_buffer_enable(struct regulator_dev *dev) -{ - struct pm8058_xo_buffer *xo = rdev_get_drvdata(dev); - int rc; - - rc = pm8058_xo_buffer_write(xo, xo->ctrl_addr, XO_ENABLE, - XO_ENABLE_MASK, &xo->ctrl_reg); - if (rc) - pr_err("FAIL: pm8058_xo_buffer_write: rc=%d\n", rc); - - return rc; -} - -static int pm8058_xo_buffer_is_enabled(struct regulator_dev *dev) -{ - struct pm8058_xo_buffer *xo = rdev_get_drvdata(dev); - - if (xo->ctrl_reg & XO_BUFFER_ENABLE) - return 1; - else - return 0; -} - -static int pm8058_xo_buffer_disable(struct regulator_dev *dev) -{ - struct pm8058_xo_buffer *xo = rdev_get_drvdata(dev); - int rc; - - rc = pm8058_xo_buffer_write(xo, xo->ctrl_addr, XO_DISABLE, - XO_ENABLE_MASK, &xo->ctrl_reg); - if (rc) - pr_err("FAIL: pm8058_xo_buffer_write: rc=%d\n", rc); - - return rc; -} - -static struct regulator_ops pm8058_xo_ops = { - .enable = pm8058_xo_buffer_enable, - .disable = pm8058_xo_buffer_disable, - .is_enabled = pm8058_xo_buffer_is_enabled, -}; - -#define VREG_DESCRIP(_id, _name, _ops) \ - [_id] = { \ - .id = _id, \ - .name = _name, \ - .ops = _ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - } - -static struct regulator_desc pm8058_xo_buffer_desc[] = { - VREG_DESCRIP(PM8058_XO_ID_A0, "8058_xo_a0", &pm8058_xo_ops), - VREG_DESCRIP(PM8058_XO_ID_A1, "8058_xo_a1", &pm8058_xo_ops), -}; - -static int pm8058_init_xo_buffer(struct pm8058_xo_buffer *xo) -{ - int rc; - - /* Save the current control register state */ - rc = pm8xxx_readb(xo->dev->parent, xo->ctrl_addr, &xo->ctrl_reg); - - if (rc) - pr_err("FAIL: pm8xxx_read: rc=%d\n", rc); - return rc; -} - -static int pm8058_xo_buffer_probe(struct platform_device *pdev) -{ - struct regulator_desc *rdesc; - struct pm8058_xo_buffer *xo; - int rc = 0; - - if (pdev == NULL) - return -EINVAL; - - if (pdev->id >= 0 && pdev->id < PM8058_XO_ID_MAX) { - rdesc = &pm8058_xo_buffer_desc[pdev->id]; - xo = &pm8058_xo_buffer[pdev->id]; - xo->pdata = pdev->dev.platform_data; - xo->dev = &pdev->dev; - - rc = pm8058_init_xo_buffer(xo); - if (rc) - goto bail; - - xo->rdev = regulator_register(rdesc, &pdev->dev, - &xo->pdata->init_data, xo, NULL); - if (IS_ERR(xo->rdev)) { - rc = PTR_ERR(xo->rdev); - pr_err("FAIL: regulator_register(%s): rc=%d\n", - pm8058_xo_buffer_desc[pdev->id].name, rc); - } - } else { - rc = -ENODEV; - } - -bail: - if (rc) - pr_err("Error: xo-id=%d, rc=%d\n", pdev->id, rc); - - return rc; -} - -static int pm8058_xo_buffer_remove(struct platform_device *pdev) -{ - regulator_unregister(pm8058_xo_buffer[pdev->id].rdev); - return 0; -} - -static struct platform_driver pm8058_xo_buffer_driver = { - .probe = pm8058_xo_buffer_probe, - .remove = pm8058_xo_buffer_remove, - .driver = { - .name = PM8058_XO_BUFFER_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8058_xo_buffer_init(void) -{ - return platform_driver_register(&pm8058_xo_buffer_driver); -} - -static void __exit pm8058_xo_buffer_exit(void) -{ - platform_driver_unregister(&pm8058_xo_buffer_driver); -} - -subsys_initcall(pm8058_xo_buffer_init); -module_exit(pm8058_xo_buffer_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8058 XO buffer driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8058_XO_BUFFER_DEV_NAME); diff --git a/drivers/regulator/pm8xxx-regulator.c b/drivers/regulator/pm8xxx-regulator.c deleted file mode 100644 index e30c80409a72630faaf53765df6923f5d346c9ea..0000000000000000000000000000000000000000 --- a/drivers/regulator/pm8xxx-regulator.c +++ /dev/null @@ -1,3345 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Debug Flag Definitions */ -enum { - PM8XXX_VREG_DEBUG_REQUEST = BIT(0), - PM8XXX_VREG_DEBUG_DUPLICATE = BIT(1), - PM8XXX_VREG_DEBUG_INIT = BIT(2), - PM8XXX_VREG_DEBUG_WRITES = BIT(3), /* SSBI writes */ -}; - -static int pm8xxx_vreg_debug_mask; -module_param_named( - debug_mask, pm8xxx_vreg_debug_mask, int, S_IRUSR | S_IWUSR -); - -/* Common Masks */ -#define REGULATOR_ENABLE_MASK 0x80 -#define REGULATOR_ENABLE 0x80 -#define REGULATOR_DISABLE 0x00 - -#define REGULATOR_BANK_MASK 0xF0 -#define REGULATOR_BANK_SEL(n) ((n) << 4) -#define REGULATOR_BANK_WRITE 0x80 - -#define LDO_TEST_BANKS 7 -#define NLDO1200_TEST_BANKS 5 -#define SMPS_TEST_BANKS 8 - -/* - * This voltage in uV is returned by get_voltage functions when there is no way - * to determine the current voltage level. It is needed because the regulator - * framework treats a 0 uV voltage as an error. - */ -#define VOLTAGE_UNKNOWN 1 - -/* LDO masks and values */ - -/* CTRL register */ -#define LDO_ENABLE_MASK 0x80 -#define LDO_DISABLE 0x00 -#define LDO_ENABLE 0x80 -#define LDO_PULL_DOWN_ENABLE_MASK 0x40 -#define LDO_PULL_DOWN_ENABLE 0x40 - -#define LDO_CTRL_PM_MASK 0x20 -#define LDO_CTRL_PM_HPM 0x00 -#define LDO_CTRL_PM_LPM 0x20 - -#define LDO_CTRL_VPROG_MASK 0x1F - -/* TEST register bank 0 */ -#define LDO_TEST_LPM_MASK 0x04 -#define LDO_TEST_LPM_SEL_CTRL 0x00 -#define LDO_TEST_LPM_SEL_TCXO 0x04 - -/* TEST register bank 2 */ -#define LDO_TEST_VPROG_UPDATE_MASK 0x08 -#define LDO_TEST_RANGE_SEL_MASK 0x04 -#define LDO_TEST_FINE_STEP_MASK 0x02 -#define LDO_TEST_FINE_STEP_SHIFT 1 - -/* TEST register bank 4 */ -#define LDO_TEST_RANGE_EXT_MASK 0x01 - -/* TEST register bank 5 */ -#define LDO_TEST_PIN_CTRL_MASK 0x0F -#define LDO_TEST_PIN_CTRL_EN3 0x08 -#define LDO_TEST_PIN_CTRL_EN2 0x04 -#define LDO_TEST_PIN_CTRL_EN1 0x02 -#define LDO_TEST_PIN_CTRL_EN0 0x01 - -/* TEST register bank 6 */ -#define LDO_TEST_PIN_CTRL_LPM_MASK 0x0F - -/* - * If a given voltage could be output by two ranges, then the preferred one must - * be determined by the range limits. Specified voltage ranges should must - * not overlap. - * - * Allowable voltage ranges: - */ -#define PLDO_LOW_UV_MIN 750000 -#define PLDO_LOW_UV_MAX 1487500 -#define PLDO_LOW_UV_FINE_STEP 12500 - -#define PLDO_NORM_UV_MIN 1500000 -#define PLDO_NORM_UV_MAX 3075000 -#define PLDO_NORM_UV_FINE_STEP 25000 - -#define PLDO_HIGH_UV_MIN 1750000 -#define PLDO_HIGH_UV_SET_POINT_MIN 3100000 -#define PLDO_HIGH_UV_MAX 4900000 -#define PLDO_HIGH_UV_FINE_STEP 50000 - -#define PLDO_LOW_SET_POINTS ((PLDO_LOW_UV_MAX - PLDO_LOW_UV_MIN) \ - / PLDO_LOW_UV_FINE_STEP + 1) -#define PLDO_NORM_SET_POINTS ((PLDO_NORM_UV_MAX - PLDO_NORM_UV_MIN) \ - / PLDO_NORM_UV_FINE_STEP + 1) -#define PLDO_HIGH_SET_POINTS ((PLDO_HIGH_UV_MAX \ - - PLDO_HIGH_UV_SET_POINT_MIN) \ - / PLDO_HIGH_UV_FINE_STEP + 1) -#define PLDO_SET_POINTS (PLDO_LOW_SET_POINTS \ - + PLDO_NORM_SET_POINTS \ - + PLDO_HIGH_SET_POINTS) - -#define NLDO_UV_MIN 750000 -#define NLDO_UV_MAX 1537500 -#define NLDO_UV_FINE_STEP 12500 - -#define NLDO_SET_POINTS ((NLDO_UV_MAX - NLDO_UV_MIN) \ - / NLDO_UV_FINE_STEP + 1) - -/* NLDO1200 masks and values */ - -/* CTRL register */ -#define NLDO1200_ENABLE_MASK 0x80 -#define NLDO1200_DISABLE 0x00 -#define NLDO1200_ENABLE 0x80 - -/* Legacy mode */ -#define NLDO1200_LEGACY_PM_MASK 0x20 -#define NLDO1200_LEGACY_PM_HPM 0x00 -#define NLDO1200_LEGACY_PM_LPM 0x20 - -/* Advanced mode */ -#define NLDO1200_CTRL_RANGE_MASK 0x40 -#define NLDO1200_CTRL_RANGE_HIGH 0x00 -#define NLDO1200_CTRL_RANGE_LOW 0x40 -#define NLDO1200_CTRL_VPROG_MASK 0x3F - -#define NLDO1200_LOW_UV_MIN 375000 -#define NLDO1200_LOW_UV_MAX 743750 -#define NLDO1200_LOW_UV_STEP 6250 - -#define NLDO1200_HIGH_UV_MIN 750000 -#define NLDO1200_HIGH_UV_MAX 1537500 -#define NLDO1200_HIGH_UV_STEP 12500 - -#define NLDO1200_LOW_SET_POINTS ((NLDO1200_LOW_UV_MAX \ - - NLDO1200_LOW_UV_MIN) \ - / NLDO1200_LOW_UV_STEP + 1) -#define NLDO1200_HIGH_SET_POINTS ((NLDO1200_HIGH_UV_MAX \ - - NLDO1200_HIGH_UV_MIN) \ - / NLDO1200_HIGH_UV_STEP + 1) -#define NLDO1200_SET_POINTS (NLDO1200_LOW_SET_POINTS \ - + NLDO1200_HIGH_SET_POINTS) - -/* TEST register bank 0 */ -#define NLDO1200_TEST_LPM_MASK 0x04 -#define NLDO1200_TEST_LPM_SEL_CTRL 0x00 -#define NLDO1200_TEST_LPM_SEL_TCXO 0x04 - -/* TEST register bank 1 */ -#define NLDO1200_PULL_DOWN_ENABLE_MASK 0x02 -#define NLDO1200_PULL_DOWN_ENABLE 0x02 - -/* TEST register bank 2 */ -#define NLDO1200_ADVANCED_MODE_MASK 0x08 -#define NLDO1200_ADVANCED_MODE 0x00 -#define NLDO1200_LEGACY_MODE 0x08 - -/* Advanced mode power mode control */ -#define NLDO1200_ADVANCED_PM_MASK 0x02 -#define NLDO1200_ADVANCED_PM_HPM 0x00 -#define NLDO1200_ADVANCED_PM_LPM 0x02 - -#define NLDO1200_IN_ADVANCED_MODE(vreg) \ - ((vreg->test_reg[2] & NLDO1200_ADVANCED_MODE_MASK) \ - == NLDO1200_ADVANCED_MODE) - -/* SMPS masks and values */ - -/* CTRL register */ - -/* Legacy mode */ -#define SMPS_LEGACY_ENABLE_MASK 0x80 -#define SMPS_LEGACY_DISABLE 0x00 -#define SMPS_LEGACY_ENABLE 0x80 -#define SMPS_LEGACY_PULL_DOWN_ENABLE 0x40 -#define SMPS_LEGACY_VREF_SEL_MASK 0x20 -#define SMPS_LEGACY_VPROG_MASK 0x1F - -/* Advanced mode */ -#define SMPS_ADVANCED_BAND_MASK 0xC0 -#define SMPS_ADVANCED_BAND_OFF 0x00 -#define SMPS_ADVANCED_BAND_1 0x40 -#define SMPS_ADVANCED_BAND_2 0x80 -#define SMPS_ADVANCED_BAND_3 0xC0 -#define SMPS_ADVANCED_VPROG_MASK 0x3F - -/* Legacy mode voltage ranges */ -#define SMPS_MODE3_UV_MIN 375000 -#define SMPS_MODE3_UV_MAX 725000 -#define SMPS_MODE3_UV_STEP 25000 - -#define SMPS_MODE2_UV_MIN 750000 -#define SMPS_MODE2_UV_MAX 1475000 -#define SMPS_MODE2_UV_STEP 25000 - -#define SMPS_MODE1_UV_MIN 1500000 -#define SMPS_MODE1_UV_MAX 3050000 -#define SMPS_MODE1_UV_STEP 50000 - -#define SMPS_MODE3_SET_POINTS ((SMPS_MODE3_UV_MAX \ - - SMPS_MODE3_UV_MIN) \ - / SMPS_MODE3_UV_STEP + 1) -#define SMPS_MODE2_SET_POINTS ((SMPS_MODE2_UV_MAX \ - - SMPS_MODE2_UV_MIN) \ - / SMPS_MODE2_UV_STEP + 1) -#define SMPS_MODE1_SET_POINTS ((SMPS_MODE1_UV_MAX \ - - SMPS_MODE1_UV_MIN) \ - / SMPS_MODE1_UV_STEP + 1) -#define SMPS_LEGACY_SET_POINTS (SMPS_MODE3_SET_POINTS \ - + SMPS_MODE2_SET_POINTS \ - + SMPS_MODE1_SET_POINTS) - -/* Advanced mode voltage ranges */ -#define SMPS_BAND1_UV_MIN 375000 -#define SMPS_BAND1_UV_MAX 737500 -#define SMPS_BAND1_UV_STEP 12500 - -#define SMPS_BAND2_UV_MIN 750000 -#define SMPS_BAND2_UV_MAX 1487500 -#define SMPS_BAND2_UV_STEP 12500 - -#define SMPS_BAND3_UV_MIN 1500000 -#define SMPS_BAND3_UV_MAX 3075000 -#define SMPS_BAND3_UV_STEP 25000 - -#define SMPS_BAND1_SET_POINTS ((SMPS_BAND1_UV_MAX \ - - SMPS_BAND1_UV_MIN) \ - / SMPS_BAND1_UV_STEP + 1) -#define SMPS_BAND2_SET_POINTS ((SMPS_BAND2_UV_MAX \ - - SMPS_BAND2_UV_MIN) \ - / SMPS_BAND2_UV_STEP + 1) -#define SMPS_BAND3_SET_POINTS ((SMPS_BAND3_UV_MAX \ - - SMPS_BAND3_UV_MIN) \ - / SMPS_BAND3_UV_STEP + 1) -#define SMPS_ADVANCED_SET_POINTS (SMPS_BAND1_SET_POINTS \ - + SMPS_BAND2_SET_POINTS \ - + SMPS_BAND3_SET_POINTS) - -/* Test2 register bank 1 */ -#define SMPS_LEGACY_VLOW_SEL_MASK 0x01 - -/* Test2 register bank 6 */ -#define SMPS_ADVANCED_PULL_DOWN_ENABLE 0x08 - -/* Test2 register bank 7 */ -#define SMPS_ADVANCED_MODE_MASK 0x02 -#define SMPS_ADVANCED_MODE 0x02 -#define SMPS_LEGACY_MODE 0x00 - -#define SMPS_IN_ADVANCED_MODE(vreg) \ - ((vreg->test_reg[7] & SMPS_ADVANCED_MODE_MASK) == SMPS_ADVANCED_MODE) - -/* BUCK_SLEEP_CNTRL register */ -#define SMPS_PIN_CTRL_MASK 0xF0 -#define SMPS_PIN_CTRL_EN3 0x80 -#define SMPS_PIN_CTRL_EN2 0x40 -#define SMPS_PIN_CTRL_EN1 0x20 -#define SMPS_PIN_CTRL_EN0 0x10 - -#define SMPS_PIN_CTRL_LPM_MASK 0x0F -#define SMPS_PIN_CTRL_LPM_EN3 0x08 -#define SMPS_PIN_CTRL_LPM_EN2 0x04 -#define SMPS_PIN_CTRL_LPM_EN1 0x02 -#define SMPS_PIN_CTRL_LPM_EN0 0x01 - -/* BUCK_CLOCK_CNTRL register */ -#define SMPS_CLK_DIVIDE2 0x40 - -#define SMPS_CLK_CTRL_MASK 0x30 -#define SMPS_CLK_CTRL_FOLLOW_TCXO 0x00 -#define SMPS_CLK_CTRL_PWM 0x10 -#define SMPS_CLK_CTRL_PFM 0x20 - -/* FTSMPS masks and values */ - -/* CTRL register */ -#define FTSMPS_VCTRL_BAND_MASK 0xC0 -#define FTSMPS_VCTRL_BAND_OFF 0x00 -#define FTSMPS_VCTRL_BAND_1 0x40 -#define FTSMPS_VCTRL_BAND_2 0x80 -#define FTSMPS_VCTRL_BAND_3 0xC0 -#define FTSMPS_VCTRL_VPROG_MASK 0x3F - -#define FTSMPS_BAND1_UV_MIN 350000 -#define FTSMPS_BAND1_UV_MAX 650000 -/* 3 LSB's of program voltage must be 0 in band 1. */ -/* Logical step size */ -#define FTSMPS_BAND1_UV_LOG_STEP 50000 -/* Physical step size */ -#define FTSMPS_BAND1_UV_PHYS_STEP 6250 - -#define FTSMPS_BAND2_UV_MIN 700000 -#define FTSMPS_BAND2_UV_MAX 1400000 -#define FTSMPS_BAND2_UV_STEP 12500 - -#define FTSMPS_BAND3_UV_MIN 1400000 -#define FTSMPS_BAND3_UV_SET_POINT_MIN 1500000 -#define FTSMPS_BAND3_UV_MAX 3300000 -#define FTSMPS_BAND3_UV_STEP 50000 - -#define FTSMPS_BAND1_SET_POINTS ((FTSMPS_BAND1_UV_MAX \ - - FTSMPS_BAND1_UV_MIN) \ - / FTSMPS_BAND1_UV_LOG_STEP + 1) -#define FTSMPS_BAND2_SET_POINTS ((FTSMPS_BAND2_UV_MAX \ - - FTSMPS_BAND2_UV_MIN) \ - / FTSMPS_BAND2_UV_STEP + 1) -#define FTSMPS_BAND3_SET_POINTS ((FTSMPS_BAND3_UV_MAX \ - - FTSMPS_BAND3_UV_SET_POINT_MIN) \ - / FTSMPS_BAND3_UV_STEP + 1) -#define FTSMPS_SET_POINTS (FTSMPS_BAND1_SET_POINTS \ - + FTSMPS_BAND2_SET_POINTS \ - + FTSMPS_BAND3_SET_POINTS) - -/* FTS_CNFG1 register bank 0 */ -#define FTSMPS_CNFG1_PM_MASK 0x0C -#define FTSMPS_CNFG1_PM_PWM 0x00 -#define FTSMPS_CNFG1_PM_PFM 0x08 - -/* PWR_CNFG register */ -#define FTSMPS_PULL_DOWN_ENABLE_MASK 0x40 -#define FTSMPS_PULL_DOWN_ENABLE 0x40 - -/* VS masks and values */ - -/* CTRL register */ -#define VS_ENABLE_MASK 0x80 -#define VS_DISABLE 0x00 -#define VS_ENABLE 0x80 -#define VS_PULL_DOWN_ENABLE_MASK 0x40 -#define VS_PULL_DOWN_DISABLE 0x40 -#define VS_PULL_DOWN_ENABLE 0x00 - -#define VS_MODE_MASK 0x30 -#define VS_MODE_NORMAL 0x10 -#define VS_MODE_LPM 0x20 - -#define VS_PIN_CTRL_MASK 0x0F -#define VS_PIN_CTRL_EN0 0x08 -#define VS_PIN_CTRL_EN1 0x04 -#define VS_PIN_CTRL_EN2 0x02 -#define VS_PIN_CTRL_EN3 0x01 - -/* TEST register */ -#define VS_OCP_MASK 0x10 -#define VS_OCP_ENABLE 0x00 -#define VS_OCP_DISABLE 0x10 - -/* VS300 masks and values */ - -/* CTRL register */ -#define VS300_CTRL_ENABLE_MASK 0xC0 -#define VS300_CTRL_DISABLE 0x00 -#define VS300_CTRL_ENABLE 0x40 - -#define VS300_PULL_DOWN_ENABLE_MASK 0x20 -#define VS300_PULL_DOWN_ENABLE 0x20 - -#define VS300_MODE_MASK 0x18 -#define VS300_MODE_NORMAL 0x00 -#define VS300_MODE_LPM 0x08 - -/* NCP masks and values */ - -/* CTRL register */ -#define NCP_ENABLE_MASK 0x80 -#define NCP_DISABLE 0x00 -#define NCP_ENABLE 0x80 -#define NCP_VPROG_MASK 0x1F - -#define NCP_UV_MIN 1500000 -#define NCP_UV_MAX 3050000 -#define NCP_UV_STEP 50000 - -#define NCP_SET_POINTS ((NCP_UV_MAX - NCP_UV_MIN) \ - / NCP_UV_STEP + 1) - -/* Boost masks and values */ -#define BOOST_ENABLE_MASK 0x80 -#define BOOST_DISABLE 0x00 -#define BOOST_ENABLE 0x80 -#define BOOST_VPROG_MASK 0x1F - -#define BOOST_UV_MIN 4000000 -#define BOOST_UV_MAX 5550000 -#define BOOST_UV_STEP 50000 - -#define BOOST_SET_POINTS ((BOOST_UV_MAX - BOOST_UV_MIN) \ - / BOOST_UV_STEP + 1) - -#define vreg_err(vreg, fmt, ...) \ - pr_err("%s: " fmt, vreg->rdesc.name, ##__VA_ARGS__) - -/* Determines which label to add to the print. */ -enum pm8xxx_regulator_action { - PM8XXX_REGULATOR_ACTION_INIT, - PM8XXX_REGULATOR_ACTION_ENABLE, - PM8XXX_REGULATOR_ACTION_DISABLE, - PM8XXX_REGULATOR_ACTION_VOLTAGE, - PM8XXX_REGULATOR_ACTION_MODE, - PM8XXX_REGULATOR_ACTION_PIN_CTRL, -}; - -/* Debug state printing */ -static void pm8xxx_vreg_show_state(struct regulator_dev *rdev, - enum pm8xxx_regulator_action action); - -/* - * Perform a masked write to a PMIC register only if the new value differs - * from the last value written to the register. This removes redundant - * register writing. - * - * No locking is required because registers are not shared between regulators. - */ -static int pm8xxx_vreg_masked_write(struct pm8xxx_vreg *vreg, u16 addr, u8 val, - u8 mask, u8 *reg_save) -{ - int rc = 0; - u8 reg; - - reg = (*reg_save & ~mask) | (val & mask); - if (reg != *reg_save) { - rc = pm8xxx_writeb(vreg->dev->parent, addr, reg); - - if (rc) { - pr_err("%s: pm8xxx_writeb failed; addr=0x%03X, rc=%d\n", - vreg->rdesc.name, addr, rc); - } else { - *reg_save = reg; - vreg->write_count++; - if (pm8xxx_vreg_debug_mask & PM8XXX_VREG_DEBUG_WRITES) - pr_info("%s: write(0x%03X)=0x%02X\n", - vreg->rdesc.name, addr, reg); - } - } - - return rc; -} - -/* - * Perform a masked write to a PMIC register without checking the previously - * written value. This is needed for registers that must be rewritten even if - * the value hasn't changed in order for changes in other registers to take - * effect. - */ -static int pm8xxx_vreg_masked_write_forced(struct pm8xxx_vreg *vreg, u16 addr, - u8 val, u8 mask, u8 *reg_save) -{ - int rc = 0; - u8 reg; - - reg = (*reg_save & ~mask) | (val & mask); - rc = pm8xxx_writeb(vreg->dev->parent, addr, reg); - - if (rc) { - pr_err("%s: pm8xxx_writeb failed; addr=0x%03X, rc=%d\n", - vreg->rdesc.name, addr, rc); - } else { - *reg_save = reg; - vreg->write_count++; - if (pm8xxx_vreg_debug_mask & PM8XXX_VREG_DEBUG_WRITES) - pr_info("%s: write(0x%03X)=0x%02X\n", vreg->rdesc.name, - addr, reg); - } - - return rc; -} - -static int pm8xxx_vreg_is_pin_controlled(struct pm8xxx_vreg *vreg) -{ - int ret = 0; - - switch (vreg->type) { - case PM8XXX_REGULATOR_TYPE_PLDO: - case PM8XXX_REGULATOR_TYPE_NLDO: - ret = ((vreg->test_reg[5] & LDO_TEST_PIN_CTRL_MASK) << 4) - | (vreg->test_reg[6] & LDO_TEST_PIN_CTRL_LPM_MASK); - break; - case PM8XXX_REGULATOR_TYPE_SMPS: - ret = vreg->sleep_ctrl_reg - & (SMPS_PIN_CTRL_MASK | SMPS_PIN_CTRL_LPM_MASK); - break; - case PM8XXX_REGULATOR_TYPE_VS: - ret = vreg->ctrl_reg & VS_PIN_CTRL_MASK; - break; - default: - break; - } - - return ret; -} - -/* - * Returns the logical pin control enable state because the pin control options - * present in the hardware out of restart could be different from those desired - * by the consumer. - */ -static int pm8xxx_vreg_pin_control_is_enabled(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int enabled; - - mutex_lock(&vreg->pc_lock); - enabled = vreg->is_enabled_pc; - mutex_unlock(&vreg->pc_lock); - - return enabled; -} - -/* Returns the physical enable state of the regulator. */ -static int _pm8xxx_vreg_is_enabled(struct pm8xxx_vreg *vreg) -{ - int rc = 0; - - /* - * All regulator types except advanced mode SMPS, FTSMPS, and VS300 have - * enable bit in bit 7 of the control register. - */ - switch (vreg->type) { - case PM8XXX_REGULATOR_TYPE_FTSMPS: - if ((vreg->ctrl_reg & FTSMPS_VCTRL_BAND_MASK) - != FTSMPS_VCTRL_BAND_OFF) - rc = 1; - break; - case PM8XXX_REGULATOR_TYPE_VS300: - if ((vreg->ctrl_reg & VS300_CTRL_ENABLE_MASK) - != VS300_CTRL_DISABLE) - rc = 1; - break; - case PM8XXX_REGULATOR_TYPE_SMPS: - if (SMPS_IN_ADVANCED_MODE(vreg)) { - if ((vreg->ctrl_reg & SMPS_ADVANCED_BAND_MASK) - != SMPS_ADVANCED_BAND_OFF) - rc = 1; - break; - } - /* Fall through for legacy mode SMPS. */ - default: - if ((vreg->ctrl_reg & REGULATOR_ENABLE_MASK) - == REGULATOR_ENABLE) - rc = 1; - } - - return rc; -} - -/* - * Returns the logical enable state of the regulator which may be different from - * the physical enable state thanks to HPM/LPM pin control. - */ -static int pm8xxx_vreg_is_enabled(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int enabled; - - if (vreg->type == PM8XXX_REGULATOR_TYPE_PLDO - || vreg->type == PM8XXX_REGULATOR_TYPE_NLDO - || vreg->type == PM8XXX_REGULATOR_TYPE_SMPS - || vreg->type == PM8XXX_REGULATOR_TYPE_VS) { - /* Pin controllable */ - mutex_lock(&vreg->pc_lock); - enabled = vreg->is_enabled; - mutex_unlock(&vreg->pc_lock); - } else { - /* Not pin controlable */ - enabled = _pm8xxx_vreg_is_enabled(vreg); - } - - return enabled; -} - -/* - * Adds delay when increasing in voltage to account for the slew rate of - * the regulator. - */ -static void pm8xxx_vreg_delay_for_slew(struct pm8xxx_vreg *vreg, int prev_uV, - int new_uV) -{ - int delay; - - if (vreg->pdata.slew_rate == 0 || new_uV <= prev_uV || - !_pm8xxx_vreg_is_enabled(vreg)) - return; - - delay = DIV_ROUND_UP(new_uV - prev_uV, vreg->pdata.slew_rate); - - if (delay >= 1000) { - mdelay(delay / 1000); - udelay(delay % 1000); - } else { - udelay(delay); - } -} - -static int pm8xxx_pldo_get_voltage(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int vmin, fine_step; - u8 range_ext, range_sel, vprog, fine_step_reg; - - mutex_lock(&vreg->pc_lock); - - fine_step_reg = vreg->test_reg[2] & LDO_TEST_FINE_STEP_MASK; - range_sel = vreg->test_reg[2] & LDO_TEST_RANGE_SEL_MASK; - range_ext = vreg->test_reg[4] & LDO_TEST_RANGE_EXT_MASK; - vprog = vreg->ctrl_reg & LDO_CTRL_VPROG_MASK; - - mutex_unlock(&vreg->pc_lock); - - vprog = (vprog << 1) | (fine_step_reg >> LDO_TEST_FINE_STEP_SHIFT); - - if (range_sel) { - /* low range mode */ - fine_step = PLDO_LOW_UV_FINE_STEP; - vmin = PLDO_LOW_UV_MIN; - } else if (!range_ext) { - /* normal mode */ - fine_step = PLDO_NORM_UV_FINE_STEP; - vmin = PLDO_NORM_UV_MIN; - } else { - /* high range mode */ - fine_step = PLDO_HIGH_UV_FINE_STEP; - vmin = PLDO_HIGH_UV_MIN; - } - - return fine_step * vprog + vmin; -} - -static int pm8xxx_pldo_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - int uV; - - if (selector >= PLDO_SET_POINTS) - return 0; - - if (selector < PLDO_LOW_SET_POINTS) - uV = selector * PLDO_LOW_UV_FINE_STEP + PLDO_LOW_UV_MIN; - else if (selector < (PLDO_LOW_SET_POINTS + PLDO_NORM_SET_POINTS)) - uV = (selector - PLDO_LOW_SET_POINTS) * PLDO_NORM_UV_FINE_STEP - + PLDO_NORM_UV_MIN; - else - uV = (selector - PLDO_LOW_SET_POINTS - PLDO_NORM_SET_POINTS) - * PLDO_HIGH_UV_FINE_STEP - + PLDO_HIGH_UV_SET_POINT_MIN; - - return uV; -} - -static int pm8xxx_pldo_set_voltage(struct regulator_dev *rdev, int min_uV, - int max_uV, unsigned *selector) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0, uV = min_uV; - int vmin, prev_uV; - unsigned vprog, fine_step; - u8 range_ext, range_sel, fine_step_reg, prev_reg; - bool reg_changed = false; - - if (uV < PLDO_LOW_UV_MIN && max_uV >= PLDO_LOW_UV_MIN) - uV = PLDO_LOW_UV_MIN; - - if (uV < PLDO_LOW_UV_MIN || uV > PLDO_HIGH_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, PLDO_LOW_UV_MIN, PLDO_HIGH_UV_MAX); - return -EINVAL; - } - - if (uV > PLDO_NORM_UV_MAX) { - vmin = PLDO_HIGH_UV_MIN; - fine_step = PLDO_HIGH_UV_FINE_STEP; - range_ext = LDO_TEST_RANGE_EXT_MASK; - range_sel = 0; - } else if (uV > PLDO_LOW_UV_MAX) { - vmin = PLDO_NORM_UV_MIN; - fine_step = PLDO_NORM_UV_FINE_STEP; - range_ext = 0; - range_sel = 0; - } else { - vmin = PLDO_LOW_UV_MIN; - fine_step = PLDO_LOW_UV_FINE_STEP; - range_ext = 0; - range_sel = LDO_TEST_RANGE_SEL_MASK; - } - - vprog = (uV - vmin + fine_step - 1) / fine_step; - uV = vprog * fine_step + vmin; - fine_step_reg = (vprog & 1) << LDO_TEST_FINE_STEP_SHIFT; - vprog >>= 1; - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - prev_uV = pm8xxx_pldo_get_voltage(rdev); - - mutex_lock(&vreg->pc_lock); - - /* Write fine step, range select and program voltage update. */ - prev_reg = vreg->test_reg[2]; - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - fine_step_reg | range_sel | REGULATOR_BANK_SEL(2) - | REGULATOR_BANK_WRITE | LDO_TEST_VPROG_UPDATE_MASK, - LDO_TEST_FINE_STEP_MASK | LDO_TEST_RANGE_SEL_MASK - | REGULATOR_BANK_MASK | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); - if (rc) - goto bail; - if (prev_reg != vreg->test_reg[2]) - reg_changed = true; - - /* Write range extension. */ - prev_reg = vreg->test_reg[4]; - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - range_ext | REGULATOR_BANK_SEL(4) - | REGULATOR_BANK_WRITE, - LDO_TEST_RANGE_EXT_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[4]); - if (rc) - goto bail; - if (prev_reg != vreg->test_reg[4]) - reg_changed = true; - - /* Write new voltage. */ - if (reg_changed) { - /* - * Force a CTRL register write even if the value hasn't changed. - * This is neccessary because range select, range extension, and - * fine step will not update until a value is written into the - * control register. - */ - rc = pm8xxx_vreg_masked_write_forced(vreg, vreg->ctrl_addr, - vprog, LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - } else { - /* Only write to control register if new value is different. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, vprog, - LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - } -bail: - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else { - pm8xxx_vreg_delay_for_slew(vreg, prev_uV, uV); - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_VOLTAGE); - } - - return rc; -} - -static int pm8xxx_nldo_get_voltage(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - u8 vprog, fine_step_reg; - - mutex_lock(&vreg->pc_lock); - - fine_step_reg = vreg->test_reg[2] & LDO_TEST_FINE_STEP_MASK; - vprog = vreg->ctrl_reg & LDO_CTRL_VPROG_MASK; - - mutex_unlock(&vreg->pc_lock); - - vprog = (vprog << 1) | (fine_step_reg >> LDO_TEST_FINE_STEP_SHIFT); - - return NLDO_UV_FINE_STEP * vprog + NLDO_UV_MIN; -} - -static int pm8xxx_nldo_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - if (selector >= NLDO_SET_POINTS) - return 0; - - return selector * NLDO_UV_FINE_STEP + NLDO_UV_MIN; -} - -static int pm8xxx_nldo_set_voltage(struct regulator_dev *rdev, int min_uV, - int max_uV, unsigned *selector) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - unsigned vprog, fine_step_reg, prev_reg; - int rc, prev_uV; - int uV = min_uV; - - if (uV < NLDO_UV_MIN && max_uV >= NLDO_UV_MIN) - uV = NLDO_UV_MIN; - - if (uV < NLDO_UV_MIN || uV > NLDO_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, NLDO_UV_MIN, NLDO_UV_MAX); - return -EINVAL; - } - - vprog = (uV - NLDO_UV_MIN + NLDO_UV_FINE_STEP - 1) / NLDO_UV_FINE_STEP; - uV = vprog * NLDO_UV_FINE_STEP + NLDO_UV_MIN; - fine_step_reg = (vprog & 1) << LDO_TEST_FINE_STEP_SHIFT; - vprog >>= 1; - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - prev_uV = pm8xxx_nldo_get_voltage(rdev); - - mutex_lock(&vreg->pc_lock); - - /* Write fine step. */ - prev_reg = vreg->test_reg[2]; - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - fine_step_reg | REGULATOR_BANK_SEL(2) - | REGULATOR_BANK_WRITE | LDO_TEST_VPROG_UPDATE_MASK, - LDO_TEST_FINE_STEP_MASK | REGULATOR_BANK_MASK - | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); - if (rc) - goto bail; - - /* Write new voltage. */ - if (prev_reg != vreg->test_reg[2]) { - /* - * Force a CTRL register write even if the value hasn't changed. - * This is neccessary because fine step will not update until a - * value is written into the control register. - */ - rc = pm8xxx_vreg_masked_write_forced(vreg, vreg->ctrl_addr, - vprog, LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - } else { - /* Only write to control register if new value is different. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, vprog, - LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - } -bail: - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else { - pm8xxx_vreg_delay_for_slew(vreg, prev_uV, uV); - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_VOLTAGE); - } - - return rc; -} - -static int _pm8xxx_nldo1200_get_voltage(struct pm8xxx_vreg *vreg) -{ - int uV = 0; - int vprog; - - if (!NLDO1200_IN_ADVANCED_MODE(vreg)) { - pr_warn("%s: currently in legacy mode; voltage unknown.\n", - vreg->rdesc.name); - return vreg->save_uV; - } - - vprog = vreg->ctrl_reg & NLDO1200_CTRL_VPROG_MASK; - - if ((vreg->ctrl_reg & NLDO1200_CTRL_RANGE_MASK) - == NLDO1200_CTRL_RANGE_LOW) - uV = vprog * NLDO1200_LOW_UV_STEP + NLDO1200_LOW_UV_MIN; - else - uV = vprog * NLDO1200_HIGH_UV_STEP + NLDO1200_HIGH_UV_MIN; - - return uV; -} - -static int pm8xxx_nldo1200_get_voltage(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - - return _pm8xxx_nldo1200_get_voltage(vreg); -} - -static int pm8xxx_nldo1200_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - int uV; - - if (selector >= NLDO1200_SET_POINTS) - return 0; - - if (selector < NLDO1200_LOW_SET_POINTS) - uV = selector * NLDO1200_LOW_UV_STEP + NLDO1200_LOW_UV_MIN; - else - uV = (selector - NLDO1200_LOW_SET_POINTS) - * NLDO1200_HIGH_UV_STEP - + NLDO1200_HIGH_UV_MIN; - - return uV; -} - -static int _pm8xxx_nldo1200_set_voltage(struct pm8xxx_vreg *vreg, int min_uV, - int max_uV) -{ - u8 vprog, range; - int rc, prev_uV; - int uV = min_uV; - - if (uV < NLDO1200_LOW_UV_MIN && max_uV >= NLDO1200_LOW_UV_MIN) - uV = NLDO1200_LOW_UV_MIN; - - if (uV < NLDO1200_LOW_UV_MIN || uV > NLDO1200_HIGH_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, NLDO_UV_MIN, NLDO_UV_MAX); - return -EINVAL; - } - - if (uV > NLDO1200_LOW_UV_MAX) { - vprog = (uV - NLDO1200_HIGH_UV_MIN + NLDO1200_HIGH_UV_STEP - 1) - / NLDO1200_HIGH_UV_STEP; - uV = vprog * NLDO1200_HIGH_UV_STEP + NLDO1200_HIGH_UV_MIN; - vprog &= NLDO1200_CTRL_VPROG_MASK; - range = NLDO1200_CTRL_RANGE_HIGH; - } else { - vprog = (uV - NLDO1200_LOW_UV_MIN + NLDO1200_LOW_UV_STEP - 1) - / NLDO1200_LOW_UV_STEP; - uV = vprog * NLDO1200_LOW_UV_STEP + NLDO1200_LOW_UV_MIN; - vprog &= NLDO1200_CTRL_VPROG_MASK; - range = NLDO1200_CTRL_RANGE_LOW; - } - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - prev_uV = _pm8xxx_nldo1200_get_voltage(vreg); - - /* Set to advanced mode */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - NLDO1200_ADVANCED_MODE | REGULATOR_BANK_SEL(2) - | REGULATOR_BANK_WRITE, NLDO1200_ADVANCED_MODE_MASK - | REGULATOR_BANK_MASK, &vreg->test_reg[2]); - if (rc) - goto bail; - - /* Set voltage and range selection. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, vprog | range, - NLDO1200_CTRL_VPROG_MASK | NLDO1200_CTRL_RANGE_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - - vreg->save_uV = uV; - - pm8xxx_vreg_delay_for_slew(vreg, prev_uV, uV); -bail: - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_nldo1200_set_voltage(struct regulator_dev *rdev, int min_uV, - int max_uV, unsigned *selector) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = _pm8xxx_nldo1200_set_voltage(vreg, min_uV, max_uV); - - if (!rc) - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_VOLTAGE); - - return rc; -} - -static int pm8xxx_smps_get_voltage_advanced(struct pm8xxx_vreg *vreg) -{ - u8 vprog, band; - int uV = 0; - - vprog = vreg->ctrl_reg & SMPS_ADVANCED_VPROG_MASK; - band = vreg->ctrl_reg & SMPS_ADVANCED_BAND_MASK; - - if (band == SMPS_ADVANCED_BAND_1) - uV = vprog * SMPS_BAND1_UV_STEP + SMPS_BAND1_UV_MIN; - else if (band == SMPS_ADVANCED_BAND_2) - uV = vprog * SMPS_BAND2_UV_STEP + SMPS_BAND2_UV_MIN; - else if (band == SMPS_ADVANCED_BAND_3) - uV = vprog * SMPS_BAND3_UV_STEP + SMPS_BAND3_UV_MIN; - else if (vreg->save_uV > 0) - uV = vreg->save_uV; - else - uV = VOLTAGE_UNKNOWN; - - return uV; -} - -static int pm8xxx_smps_get_voltage_legacy(struct pm8xxx_vreg *vreg) -{ - u8 vlow, vref, vprog; - int uV; - - vlow = vreg->test_reg[1] & SMPS_LEGACY_VLOW_SEL_MASK; - vref = vreg->ctrl_reg & SMPS_LEGACY_VREF_SEL_MASK; - vprog = vreg->ctrl_reg & SMPS_LEGACY_VPROG_MASK; - - if (vlow && vref) { - /* mode 3 */ - uV = vprog * SMPS_MODE3_UV_STEP + SMPS_MODE3_UV_MIN; - } else if (vref) { - /* mode 2 */ - uV = vprog * SMPS_MODE2_UV_STEP + SMPS_MODE2_UV_MIN; - } else { - /* mode 1 */ - uV = vprog * SMPS_MODE1_UV_STEP + SMPS_MODE1_UV_MIN; - } - - return uV; -} - -static int _pm8xxx_smps_get_voltage(struct pm8xxx_vreg *vreg) -{ - if (SMPS_IN_ADVANCED_MODE(vreg)) - return pm8xxx_smps_get_voltage_advanced(vreg); - - return pm8xxx_smps_get_voltage_legacy(vreg); -} - -static int pm8xxx_smps_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - int uV; - - if (selector >= SMPS_ADVANCED_SET_POINTS) - return 0; - - if (selector < SMPS_BAND1_SET_POINTS) - uV = selector * SMPS_BAND1_UV_STEP + SMPS_BAND1_UV_MIN; - else if (selector < (SMPS_BAND1_SET_POINTS + SMPS_BAND2_SET_POINTS)) - uV = (selector - SMPS_BAND1_SET_POINTS) * SMPS_BAND2_UV_STEP - + SMPS_BAND2_UV_MIN; - else - uV = (selector - SMPS_BAND1_SET_POINTS - SMPS_BAND2_SET_POINTS) - * SMPS_BAND3_UV_STEP - + SMPS_BAND3_UV_MIN; - - return uV; -} - -static int pm8xxx_smps_get_voltage(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int uV; - - mutex_lock(&vreg->pc_lock); - uV = _pm8xxx_smps_get_voltage(vreg); - mutex_unlock(&vreg->pc_lock); - - return uV; -} - -static int pm8xxx_smps_set_voltage_advanced(struct pm8xxx_vreg *vreg, - int min_uV, int max_uV, int force_on) -{ - u8 vprog, band; - int rc; - int uV = min_uV; - - if (uV < SMPS_BAND1_UV_MIN && max_uV >= SMPS_BAND1_UV_MIN) - uV = SMPS_BAND1_UV_MIN; - - if (uV < SMPS_BAND1_UV_MIN || uV > SMPS_BAND3_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, SMPS_BAND1_UV_MIN, SMPS_BAND3_UV_MAX); - return -EINVAL; - } - - if (uV > SMPS_BAND2_UV_MAX) { - vprog = (uV - SMPS_BAND3_UV_MIN + SMPS_BAND3_UV_STEP - 1) - / SMPS_BAND3_UV_STEP; - band = SMPS_ADVANCED_BAND_3; - uV = SMPS_BAND3_UV_MIN + vprog * SMPS_BAND3_UV_STEP; - } else if (uV > SMPS_BAND1_UV_MAX) { - vprog = (uV - SMPS_BAND2_UV_MIN + SMPS_BAND2_UV_STEP - 1) - / SMPS_BAND2_UV_STEP; - band = SMPS_ADVANCED_BAND_2; - uV = SMPS_BAND2_UV_MIN + vprog * SMPS_BAND2_UV_STEP; - } else { - vprog = (uV - SMPS_BAND1_UV_MIN + SMPS_BAND1_UV_STEP - 1) - / SMPS_BAND1_UV_STEP; - band = SMPS_ADVANCED_BAND_1; - uV = SMPS_BAND1_UV_MIN + vprog * SMPS_BAND1_UV_STEP; - } - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - /* Do not set band if regulator currently disabled. */ - if (!_pm8xxx_vreg_is_enabled(vreg) && !force_on) - band = SMPS_ADVANCED_BAND_OFF; - - /* Set advanced mode bit to 1. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, SMPS_ADVANCED_MODE - | REGULATOR_BANK_WRITE | REGULATOR_BANK_SEL(7), - SMPS_ADVANCED_MODE_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[7]); - if (rc) - goto bail; - - /* Set voltage and voltage band. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, band | vprog, - SMPS_ADVANCED_BAND_MASK | SMPS_ADVANCED_VPROG_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - - vreg->save_uV = uV; - -bail: - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_smps_set_voltage_legacy(struct pm8xxx_vreg *vreg, int min_uV, - int max_uV) -{ - u8 vlow, vref, vprog, pd, en; - int rc; - int uV = min_uV; - - if (uV < SMPS_MODE3_UV_MIN && max_uV >= SMPS_MODE3_UV_MIN) - uV = SMPS_MODE3_UV_MIN; - - if (uV < SMPS_MODE3_UV_MIN || uV > SMPS_MODE1_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, SMPS_MODE3_UV_MIN, SMPS_MODE1_UV_MAX); - return -EINVAL; - } - - if (uV > SMPS_MODE2_UV_MAX) { - vprog = (uV - SMPS_MODE1_UV_MIN + SMPS_MODE1_UV_STEP - 1) - / SMPS_MODE1_UV_STEP; - vref = 0; - vlow = 0; - uV = SMPS_MODE1_UV_MIN + vprog * SMPS_MODE1_UV_STEP; - } else if (uV > SMPS_MODE3_UV_MAX) { - vprog = (uV - SMPS_MODE2_UV_MIN + SMPS_MODE2_UV_STEP - 1) - / SMPS_MODE2_UV_STEP; - vref = SMPS_LEGACY_VREF_SEL_MASK; - vlow = 0; - uV = SMPS_MODE2_UV_MIN + vprog * SMPS_MODE2_UV_STEP; - } else { - vprog = (uV - SMPS_MODE3_UV_MIN + SMPS_MODE3_UV_STEP - 1) - / SMPS_MODE3_UV_STEP; - vref = SMPS_LEGACY_VREF_SEL_MASK; - vlow = SMPS_LEGACY_VLOW_SEL_MASK; - uV = SMPS_MODE3_UV_MIN + vprog * SMPS_MODE3_UV_STEP; - } - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - /* set vlow bit for ultra low voltage mode */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - vlow | REGULATOR_BANK_WRITE | REGULATOR_BANK_SEL(1), - REGULATOR_BANK_MASK | SMPS_LEGACY_VLOW_SEL_MASK, - &vreg->test_reg[1]); - if (rc) - goto bail; - - /* Set advanced mode bit to 0. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, SMPS_LEGACY_MODE - | REGULATOR_BANK_WRITE | REGULATOR_BANK_SEL(7), - SMPS_ADVANCED_MODE_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[7]); - if (rc) - goto bail; - - en = (_pm8xxx_vreg_is_enabled(vreg) ? SMPS_LEGACY_ENABLE : 0); - pd = (vreg->pdata.pull_down_enable ? SMPS_LEGACY_PULL_DOWN_ENABLE : 0); - - /* Set voltage (and the rest of the control register). */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - en | pd | vref | vprog, - SMPS_LEGACY_ENABLE_MASK | SMPS_LEGACY_PULL_DOWN_ENABLE - | SMPS_LEGACY_VREF_SEL_MASK | SMPS_LEGACY_VPROG_MASK, - &vreg->ctrl_reg); - - vreg->save_uV = uV; - -bail: - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_smps_set_voltage(struct regulator_dev *rdev, int min_uV, - int max_uV, unsigned *selector) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - int prev_uV, new_uV; - - prev_uV = pm8xxx_smps_get_voltage(rdev); - - mutex_lock(&vreg->pc_lock); - - if (SMPS_IN_ADVANCED_MODE(vreg) || !pm8xxx_vreg_is_pin_controlled(vreg)) - rc = pm8xxx_smps_set_voltage_advanced(vreg, min_uV, max_uV, 0); - else - rc = pm8xxx_smps_set_voltage_legacy(vreg, min_uV, max_uV); - - mutex_unlock(&vreg->pc_lock); - - new_uV = pm8xxx_smps_get_voltage(rdev); - - if (!rc) { - pm8xxx_vreg_delay_for_slew(vreg, prev_uV, new_uV); - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_VOLTAGE); - } - - return rc; -} - -static int _pm8xxx_ftsmps_get_voltage(struct pm8xxx_vreg *vreg) -{ - u8 vprog, band; - int uV = 0; - - if ((vreg->test_reg[0] & FTSMPS_CNFG1_PM_MASK) == FTSMPS_CNFG1_PM_PFM) { - vprog = vreg->pfm_ctrl_reg & FTSMPS_VCTRL_VPROG_MASK; - band = vreg->pfm_ctrl_reg & FTSMPS_VCTRL_BAND_MASK; - if (band == FTSMPS_VCTRL_BAND_OFF && vprog == 0) { - /* PWM_VCTRL overrides PFM_VCTRL */ - vprog = vreg->ctrl_reg & FTSMPS_VCTRL_VPROG_MASK; - band = vreg->ctrl_reg & FTSMPS_VCTRL_BAND_MASK; - } - } else { - vprog = vreg->ctrl_reg & FTSMPS_VCTRL_VPROG_MASK; - band = vreg->ctrl_reg & FTSMPS_VCTRL_BAND_MASK; - } - - if (band == FTSMPS_VCTRL_BAND_1) - uV = vprog * FTSMPS_BAND1_UV_PHYS_STEP + FTSMPS_BAND1_UV_MIN; - else if (band == FTSMPS_VCTRL_BAND_2) - uV = vprog * FTSMPS_BAND2_UV_STEP + FTSMPS_BAND2_UV_MIN; - else if (band == FTSMPS_VCTRL_BAND_3) - uV = vprog * FTSMPS_BAND3_UV_STEP + FTSMPS_BAND3_UV_MIN; - else if (vreg->save_uV > 0) - uV = vreg->save_uV; - else - uV = VOLTAGE_UNKNOWN; - - return uV; -} - -static int pm8xxx_ftsmps_get_voltage(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - - return _pm8xxx_ftsmps_get_voltage(vreg); -} - -static int pm8xxx_ftsmps_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - int uV; - - if (selector >= FTSMPS_SET_POINTS) - return 0; - - if (selector < FTSMPS_BAND1_SET_POINTS) - uV = selector * FTSMPS_BAND1_UV_LOG_STEP + FTSMPS_BAND1_UV_MIN; - else if (selector < (FTSMPS_BAND1_SET_POINTS + FTSMPS_BAND2_SET_POINTS)) - uV = (selector - FTSMPS_BAND1_SET_POINTS) * FTSMPS_BAND2_UV_STEP - + FTSMPS_BAND2_UV_MIN; - else - uV = (selector - FTSMPS_BAND1_SET_POINTS - - FTSMPS_BAND2_SET_POINTS) - * FTSMPS_BAND3_UV_STEP - + FTSMPS_BAND3_UV_SET_POINT_MIN; - - return uV; -} - -static int _pm8xxx_ftsmps_set_voltage(struct pm8xxx_vreg *vreg, int min_uV, - int max_uV, int force_on) -{ - int rc = 0; - u8 vprog, band; - int uV = min_uV; - int prev_uV; - - if (uV < FTSMPS_BAND1_UV_MIN && max_uV >= FTSMPS_BAND1_UV_MIN) - uV = FTSMPS_BAND1_UV_MIN; - - if (uV < FTSMPS_BAND1_UV_MIN || uV > FTSMPS_BAND3_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, FTSMPS_BAND1_UV_MIN, - FTSMPS_BAND3_UV_MAX); - return -EINVAL; - } - - /* Round up for set points in the gaps between bands. */ - if (uV > FTSMPS_BAND1_UV_MAX && uV < FTSMPS_BAND2_UV_MIN) - uV = FTSMPS_BAND2_UV_MIN; - else if (uV > FTSMPS_BAND2_UV_MAX - && uV < FTSMPS_BAND3_UV_SET_POINT_MIN) - uV = FTSMPS_BAND3_UV_SET_POINT_MIN; - - if (uV > FTSMPS_BAND2_UV_MAX) { - vprog = (uV - FTSMPS_BAND3_UV_MIN + FTSMPS_BAND3_UV_STEP - 1) - / FTSMPS_BAND3_UV_STEP; - band = FTSMPS_VCTRL_BAND_3; - uV = FTSMPS_BAND3_UV_MIN + vprog * FTSMPS_BAND3_UV_STEP; - } else if (uV > FTSMPS_BAND1_UV_MAX) { - vprog = (uV - FTSMPS_BAND2_UV_MIN + FTSMPS_BAND2_UV_STEP - 1) - / FTSMPS_BAND2_UV_STEP; - band = FTSMPS_VCTRL_BAND_2; - uV = FTSMPS_BAND2_UV_MIN + vprog * FTSMPS_BAND2_UV_STEP; - } else { - vprog = (uV - FTSMPS_BAND1_UV_MIN - + FTSMPS_BAND1_UV_LOG_STEP - 1) - / FTSMPS_BAND1_UV_LOG_STEP; - uV = FTSMPS_BAND1_UV_MIN + vprog * FTSMPS_BAND1_UV_LOG_STEP; - vprog *= FTSMPS_BAND1_UV_LOG_STEP / FTSMPS_BAND1_UV_PHYS_STEP; - band = FTSMPS_VCTRL_BAND_1; - } - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - prev_uV = _pm8xxx_ftsmps_get_voltage(vreg); - - /* - * Do not set voltage if regulator is currently disabled because doing - * so will enable it. - */ - if (_pm8xxx_vreg_is_enabled(vreg) || force_on) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - band | vprog, - FTSMPS_VCTRL_BAND_MASK | FTSMPS_VCTRL_VPROG_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Program PFM_VCTRL as 0x00 so that PWM_VCTRL overrides it. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->pfm_ctrl_addr, 0x00, - FTSMPS_VCTRL_BAND_MASK | FTSMPS_VCTRL_VPROG_MASK, - &vreg->pfm_ctrl_reg); - if (rc) - goto bail; - } - - vreg->save_uV = uV; - - pm8xxx_vreg_delay_for_slew(vreg, prev_uV, uV); - -bail: - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_ftsmps_set_voltage(struct regulator_dev *rdev, int min_uV, - int max_uV, unsigned *selector) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = _pm8xxx_ftsmps_set_voltage(vreg, min_uV, max_uV, 0); - - if (!rc) - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_VOLTAGE); - - return rc; -} - -static int pm8xxx_ncp_get_voltage(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - u8 vprog; - - vprog = vreg->ctrl_reg & NCP_VPROG_MASK; - - return NCP_UV_MIN + vprog * NCP_UV_STEP; -} - -static int pm8xxx_ncp_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - if (selector >= NCP_SET_POINTS) - return 0; - - return selector * NCP_UV_STEP + NCP_UV_MIN; -} - -static int pm8xxx_ncp_set_voltage(struct regulator_dev *rdev, int min_uV, - int max_uV, unsigned *selector) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc, prev_uV; - int uV = min_uV; - u8 val; - - if (uV < NCP_UV_MIN && max_uV >= NCP_UV_MIN) - uV = NCP_UV_MIN; - - if (uV < NCP_UV_MIN || uV > NCP_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, NCP_UV_MIN, NCP_UV_MAX); - return -EINVAL; - } - - val = (uV - NCP_UV_MIN + NCP_UV_STEP - 1) / NCP_UV_STEP; - uV = val * NCP_UV_STEP + NCP_UV_MIN; - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - prev_uV = pm8xxx_ncp_get_voltage(rdev); - - /* voltage setting */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, val, - NCP_VPROG_MASK, &vreg->ctrl_reg); - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else { - pm8xxx_vreg_delay_for_slew(vreg, prev_uV, uV); - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_VOLTAGE); - } - - return rc; -} - -static int pm8xxx_boost_get_voltage(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - u8 vprog; - - vprog = vreg->ctrl_reg & BOOST_VPROG_MASK; - - return BOOST_UV_STEP * vprog + BOOST_UV_MIN; -} - -static int pm8xxx_boost_list_voltage(struct regulator_dev *rdev, - unsigned selector) -{ - if (selector >= BOOST_SET_POINTS) - return 0; - - return selector * BOOST_UV_STEP + BOOST_UV_MIN; -} - -static int pm8xxx_boost_set_voltage(struct regulator_dev *rdev, int min_uV, - int max_uV, unsigned *selector) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc, prev_uV; - int uV = min_uV; - u8 val; - - if (uV < BOOST_UV_MIN && max_uV >= BOOST_UV_MIN) - uV = BOOST_UV_MIN; - - if (uV < BOOST_UV_MIN || uV > BOOST_UV_MAX) { - vreg_err(vreg, - "request v=[%d, %d] is outside possible v=[%d, %d]\n", - min_uV, max_uV, BOOST_UV_MIN, BOOST_UV_MAX); - return -EINVAL; - } - - val = (uV - BOOST_UV_MIN + BOOST_UV_STEP - 1) / BOOST_UV_STEP; - uV = val * BOOST_UV_STEP + BOOST_UV_MIN; - - if (uV > max_uV) { - vreg_err(vreg, - "request v=[%d, %d] cannot be met by any set point\n", - min_uV, max_uV); - return -EINVAL; - } - - prev_uV = pm8xxx_boost_get_voltage(rdev); - - /* voltage setting */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, val, - BOOST_VPROG_MASK, &vreg->ctrl_reg); - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else { - pm8xxx_vreg_delay_for_slew(vreg, prev_uV, uV); - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_VOLTAGE); - } - - return rc; -} - -static unsigned int pm8xxx_ldo_get_mode(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - unsigned int mode = 0; - - mutex_lock(&vreg->pc_lock); - mode = vreg->mode; - mutex_unlock(&vreg->pc_lock); - - return mode; -} - -static int pm8xxx_ldo_set_mode(struct regulator_dev *rdev, unsigned int mode) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - - if (mode != REGULATOR_MODE_NORMAL && mode != REGULATOR_MODE_IDLE) { - vreg_err(vreg, "invalid mode: %u\n", mode); - return -EINVAL; - } - - mutex_lock(&vreg->pc_lock); - - if (mode == REGULATOR_MODE_NORMAL - || (vreg->is_enabled_pc - && vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE)) { - /* HPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - LDO_CTRL_PM_HPM, LDO_CTRL_PM_MASK, &vreg->ctrl_reg); - } else { - /* LPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - LDO_CTRL_PM_LPM, LDO_CTRL_PM_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - LDO_TEST_LPM_SEL_CTRL | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0), - LDO_TEST_LPM_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[0]); - } - -bail: - if (!rc) - vreg->mode = mode; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_MODE); - - return rc; -} - -static unsigned int pm8xxx_nldo1200_get_mode(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - unsigned int mode = 0; - - if (NLDO1200_IN_ADVANCED_MODE(vreg)) { - /* Advanced mode */ - if ((vreg->test_reg[2] & NLDO1200_ADVANCED_PM_MASK) - == NLDO1200_ADVANCED_PM_LPM) - mode = REGULATOR_MODE_IDLE; - else - mode = REGULATOR_MODE_NORMAL; - } else { - /* Legacy mode */ - if ((vreg->ctrl_reg & NLDO1200_LEGACY_PM_MASK) - == NLDO1200_LEGACY_PM_LPM) - mode = REGULATOR_MODE_IDLE; - else - mode = REGULATOR_MODE_NORMAL; - } - - return mode; -} - -static int pm8xxx_nldo1200_set_mode(struct regulator_dev *rdev, - unsigned int mode) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - - if (mode != REGULATOR_MODE_NORMAL && mode != REGULATOR_MODE_IDLE) { - vreg_err(vreg, "invalid mode: %u\n", mode); - return -EINVAL; - } - - /* - * Make sure that advanced mode is in use. If it isn't, then set it - * and update the voltage accordingly. - */ - if (!NLDO1200_IN_ADVANCED_MODE(vreg)) { - rc = _pm8xxx_nldo1200_set_voltage(vreg, vreg->save_uV, - vreg->save_uV); - if (rc) - goto bail; - } - - if (mode == REGULATOR_MODE_NORMAL) { - /* HPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - NLDO1200_ADVANCED_PM_HPM | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(2), NLDO1200_ADVANCED_PM_MASK - | REGULATOR_BANK_MASK, &vreg->test_reg[2]); - } else { - /* LPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - NLDO1200_ADVANCED_PM_LPM | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(2), NLDO1200_ADVANCED_PM_MASK - | REGULATOR_BANK_MASK, &vreg->test_reg[2]); - } - -bail: - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_MODE); - - return rc; -} - -static unsigned int pm8xxx_smps_get_mode(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - unsigned int mode = 0; - - mutex_lock(&vreg->pc_lock); - mode = vreg->mode; - mutex_unlock(&vreg->pc_lock); - - return mode; -} - -static int pm8xxx_smps_set_mode(struct regulator_dev *rdev, unsigned int mode) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - - if (mode != REGULATOR_MODE_NORMAL && mode != REGULATOR_MODE_IDLE) { - vreg_err(vreg, "invalid mode: %u\n", mode); - return -EINVAL; - } - - mutex_lock(&vreg->pc_lock); - - if (mode == REGULATOR_MODE_NORMAL - || (vreg->is_enabled_pc - && vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE)) { - /* HPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->clk_ctrl_addr, - SMPS_CLK_CTRL_PWM, SMPS_CLK_CTRL_MASK, - &vreg->clk_ctrl_reg); - } else { - /* LPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->clk_ctrl_addr, - SMPS_CLK_CTRL_PFM, SMPS_CLK_CTRL_MASK, - &vreg->clk_ctrl_reg); - } - - if (!rc) - vreg->mode = mode; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_MODE); - - return rc; -} - -static unsigned int pm8xxx_ftsmps_get_mode(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - unsigned int mode = 0; - - if ((vreg->test_reg[0] & FTSMPS_CNFG1_PM_MASK) == FTSMPS_CNFG1_PM_PFM) - mode = REGULATOR_MODE_IDLE; - else - mode = REGULATOR_MODE_NORMAL; - - return mode; -} - -static int pm8xxx_ftsmps_set_mode(struct regulator_dev *rdev, unsigned int mode) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - - if (mode == REGULATOR_MODE_NORMAL) { - /* HPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - FTSMPS_CNFG1_PM_PWM | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0), FTSMPS_CNFG1_PM_MASK - | REGULATOR_BANK_MASK, &vreg->test_reg[0]); - } else if (mode == REGULATOR_MODE_IDLE) { - /* LPM */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - FTSMPS_CNFG1_PM_PFM | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0), FTSMPS_CNFG1_PM_MASK - | REGULATOR_BANK_MASK, &vreg->test_reg[0]); - } else { - vreg_err(vreg, "invalid mode: %u\n", mode); - return -EINVAL; - } - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_MODE); - - return rc; -} - -static unsigned int pm8xxx_vreg_get_optimum_mode(struct regulator_dev *rdev, - int input_uV, int output_uV, int load_uA) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - unsigned int mode; - - if (load_uA + vreg->pdata.system_uA >= vreg->hpm_min_load) - mode = REGULATOR_MODE_NORMAL; - else - mode = REGULATOR_MODE_IDLE; - - return mode; -} - -static int pm8xxx_ldo_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc, val; - - mutex_lock(&vreg->pc_lock); - - /* - * Choose HPM if previously set to HPM or if pin control is enabled in - * on/off mode. - */ - val = LDO_CTRL_PM_LPM; - if (vreg->mode == REGULATOR_MODE_NORMAL - || (vreg->is_enabled_pc - && vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE)) - val = LDO_CTRL_PM_HPM; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, val | LDO_ENABLE, - LDO_ENABLE_MASK | LDO_CTRL_PM_MASK, &vreg->ctrl_reg); - - if (!rc) - vreg->is_enabled = true; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - - return rc; -} - -static int pm8xxx_ldo_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - mutex_lock(&vreg->pc_lock); - - /* - * Only disable the regulator if it isn't still required for HPM/LPM - * pin control. - */ - if (!vreg->is_enabled_pc - || vreg->pdata.pin_fn != PM8XXX_VREG_PIN_FN_MODE) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - LDO_DISABLE, LDO_ENABLE_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - } - - /* Change to LPM if HPM/LPM pin control is enabled. */ - if (vreg->is_enabled_pc - && vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_MODE) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - LDO_CTRL_PM_LPM, LDO_CTRL_PM_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - LDO_TEST_LPM_SEL_CTRL | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0), - LDO_TEST_LPM_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[0]); - } - - if (!rc) - vreg->is_enabled = false; -bail: - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_nldo1200_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, NLDO1200_ENABLE, - NLDO1200_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - - return rc; -} - -static int pm8xxx_nldo1200_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, NLDO1200_DISABLE, - NLDO1200_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_smps_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - int val; - - mutex_lock(&vreg->pc_lock); - - if (SMPS_IN_ADVANCED_MODE(vreg) - || !pm8xxx_vreg_is_pin_controlled(vreg)) { - /* Enable in advanced mode if not using pin control. */ - rc = pm8xxx_smps_set_voltage_advanced(vreg, vreg->save_uV, - vreg->save_uV, 1); - } else { - rc = pm8xxx_smps_set_voltage_legacy(vreg, vreg->save_uV, - vreg->save_uV); - if (rc) - goto bail; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - SMPS_LEGACY_ENABLE, SMPS_LEGACY_ENABLE_MASK, - &vreg->ctrl_reg); - } - - /* - * Choose HPM if previously set to HPM or if pin control is enabled in - * on/off mode. - */ - val = SMPS_CLK_CTRL_PFM; - if (vreg->mode == REGULATOR_MODE_NORMAL - || (vreg->is_enabled_pc - && vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE)) - val = SMPS_CLK_CTRL_PWM; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->clk_ctrl_addr, val, - SMPS_CLK_CTRL_MASK, &vreg->clk_ctrl_reg); - - if (!rc) - vreg->is_enabled = true; -bail: - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - - return rc; -} - -static int pm8xxx_smps_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - mutex_lock(&vreg->pc_lock); - - if (SMPS_IN_ADVANCED_MODE(vreg)) { - /* Change SMPS to legacy mode before disabling. */ - rc = pm8xxx_smps_set_voltage_legacy(vreg, vreg->save_uV, - vreg->save_uV); - if (rc) - goto bail; - } - - /* - * Only disable the regulator if it isn't still required for HPM/LPM - * pin control. - */ - if (!vreg->is_enabled_pc - || vreg->pdata.pin_fn != PM8XXX_VREG_PIN_FN_MODE) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - SMPS_LEGACY_DISABLE, SMPS_LEGACY_ENABLE_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - } - - /* Change to LPM if HPM/LPM pin control is enabled. */ - if (vreg->is_enabled_pc - && vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_MODE) - rc = pm8xxx_vreg_masked_write(vreg, vreg->clk_ctrl_addr, - SMPS_CLK_CTRL_PFM, SMPS_CLK_CTRL_MASK, - &vreg->clk_ctrl_reg); - - if (!rc) - vreg->is_enabled = false; - -bail: - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_ftsmps_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = _pm8xxx_ftsmps_set_voltage(vreg, vreg->save_uV, vreg->save_uV, 1); - - if (rc) - vreg_err(vreg, "set voltage failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - - return rc; -} - -static int pm8xxx_ftsmps_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - FTSMPS_VCTRL_BAND_OFF, FTSMPS_VCTRL_BAND_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->pfm_ctrl_addr, - FTSMPS_VCTRL_BAND_OFF, FTSMPS_VCTRL_BAND_MASK, - &vreg->pfm_ctrl_reg); -bail: - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_vs_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - mutex_lock(&vreg->pc_lock); - - if (vreg->pdata.ocp_enable) { - /* Disable OCP. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - VS_OCP_DISABLE, VS_OCP_MASK, &vreg->test_reg[0]); - if (rc) - goto done; - - /* Enable the switch while OCP is disabled. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - VS_ENABLE | VS_MODE_NORMAL, - VS_ENABLE_MASK | VS_MODE_MASK, - &vreg->ctrl_reg); - if (rc) - goto done; - - /* Wait for inrush current to subside, then enable OCP. */ - udelay(vreg->pdata.ocp_enable_time); - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - VS_OCP_ENABLE, VS_OCP_MASK, &vreg->test_reg[0]); - } else { - /* Enable the switch without touching OCP. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, VS_ENABLE, - VS_ENABLE_MASK, &vreg->ctrl_reg); - } - -done: - if (!rc) - vreg->is_enabled = true; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - - return rc; -} - -static int pm8xxx_vs_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - mutex_lock(&vreg->pc_lock); - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, VS_DISABLE, - VS_ENABLE_MASK, &vreg->ctrl_reg); - - if (!rc) - vreg->is_enabled = false; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_vs300_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - if (vreg->pdata.ocp_enable) { - /* Disable OCP. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - VS_OCP_DISABLE, VS_OCP_MASK, &vreg->test_reg[0]); - if (rc) - goto done; - - /* Enable the switch while OCP is disabled. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - VS300_CTRL_ENABLE | VS300_MODE_NORMAL, - VS300_CTRL_ENABLE_MASK | VS300_MODE_MASK, - &vreg->ctrl_reg); - if (rc) - goto done; - - /* Wait for inrush current to subside, then enable OCP. */ - udelay(vreg->pdata.ocp_enable_time); - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - VS_OCP_ENABLE, VS_OCP_MASK, &vreg->test_reg[0]); - } else { - /* Enable the regulator without touching OCP. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - VS300_CTRL_ENABLE, VS300_CTRL_ENABLE_MASK, - &vreg->ctrl_reg); - } - -done: - if (rc) { - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - } else { - vreg->is_enabled = true; - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - } - - return rc; -} - -static int pm8xxx_vs300_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, VS300_CTRL_DISABLE, - VS300_CTRL_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_ncp_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, NCP_ENABLE, - NCP_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - - return rc; -} - -static int pm8xxx_ncp_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, NCP_DISABLE, - NCP_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_boost_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, BOOST_ENABLE, - BOOST_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_ENABLE); - - return rc; -} - -static int pm8xxx_boost_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, BOOST_DISABLE, - BOOST_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_DISABLE); - - return rc; -} - -static int pm8xxx_ldo_pin_control_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - int bank; - u8 val = 0; - u8 mask; - - mutex_lock(&vreg->pc_lock); - - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN0) - val |= LDO_TEST_PIN_CTRL_EN0; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN1) - val |= LDO_TEST_PIN_CTRL_EN1; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN2) - val |= LDO_TEST_PIN_CTRL_EN2; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN3) - val |= LDO_TEST_PIN_CTRL_EN3; - - bank = (vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE ? 5 : 6); - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - val | REGULATOR_BANK_SEL(bank) | REGULATOR_BANK_WRITE, - LDO_TEST_PIN_CTRL_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[bank]); - if (rc) - goto bail; - - /* Unset pin control bits in unused bank. */ - bank = (bank == 5 ? 6 : 5); - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - REGULATOR_BANK_SEL(bank) | REGULATOR_BANK_WRITE, - LDO_TEST_PIN_CTRL_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[bank]); - if (rc) - goto bail; - - val = LDO_TEST_LPM_SEL_CTRL | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0); - mask = LDO_TEST_LPM_MASK | REGULATOR_BANK_MASK; - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, val, mask, - &vreg->test_reg[0]); - if (rc) - goto bail; - - if (vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE) { - /* Pin control ON/OFF */ - val = LDO_CTRL_PM_HPM; - /* Leave physically enabled if already enabled. */ - val |= (vreg->is_enabled ? LDO_ENABLE : LDO_DISABLE); - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, val, - LDO_ENABLE_MASK | LDO_CTRL_PM_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - } else { - /* Pin control LPM/HPM */ - val = LDO_ENABLE; - /* Leave in HPM if already enabled in HPM. */ - val |= (vreg->is_enabled && vreg->mode == REGULATOR_MODE_NORMAL - ? LDO_CTRL_PM_HPM : LDO_CTRL_PM_LPM); - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, val, - LDO_ENABLE_MASK | LDO_CTRL_PM_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - } - -bail: - if (!rc) - vreg->is_enabled_pc = true; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_PIN_CTRL); - - return rc; -} - -static int pm8xxx_ldo_pin_control_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - mutex_lock(&vreg->pc_lock); - - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - REGULATOR_BANK_SEL(5) | REGULATOR_BANK_WRITE, - LDO_TEST_PIN_CTRL_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[5]); - if (rc) - goto bail; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - REGULATOR_BANK_SEL(6) | REGULATOR_BANK_WRITE, - LDO_TEST_PIN_CTRL_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[6]); - - /* - * Physically disable the regulator if it was enabled in HPM/LPM pin - * control mode previously and it logically should not be enabled. - */ - if ((vreg->ctrl_reg & LDO_ENABLE_MASK) == LDO_ENABLE - && !vreg->is_enabled) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - LDO_DISABLE, LDO_ENABLE_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - } - - /* Change to LPM if LPM was enabled. */ - if (vreg->is_enabled && vreg->mode == REGULATOR_MODE_IDLE) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - LDO_CTRL_PM_LPM, LDO_CTRL_PM_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - LDO_TEST_LPM_SEL_CTRL | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0), - LDO_TEST_LPM_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[0]); - if (rc) - goto bail; - } - -bail: - if (!rc) - vreg->is_enabled_pc = false; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_PIN_CTRL); - - return rc; -} - -static int pm8xxx_smps_pin_control_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc = 0; - u8 val = 0; - - mutex_lock(&vreg->pc_lock); - - if (vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE) { - /* Pin control ON/OFF */ - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN0) - val |= SMPS_PIN_CTRL_EN0; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN1) - val |= SMPS_PIN_CTRL_EN1; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN2) - val |= SMPS_PIN_CTRL_EN2; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN3) - val |= SMPS_PIN_CTRL_EN3; - } else { - /* Pin control LPM/HPM */ - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN0) - val |= SMPS_PIN_CTRL_LPM_EN0; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN1) - val |= SMPS_PIN_CTRL_LPM_EN1; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN2) - val |= SMPS_PIN_CTRL_LPM_EN2; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN3) - val |= SMPS_PIN_CTRL_LPM_EN3; - } - - rc = pm8xxx_smps_set_voltage_legacy(vreg, vreg->save_uV, vreg->save_uV); - if (rc) - goto bail; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->sleep_ctrl_addr, val, - SMPS_PIN_CTRL_MASK | SMPS_PIN_CTRL_LPM_MASK, - &vreg->sleep_ctrl_reg); - if (rc) - goto bail; - - /* - * Physically enable the regulator if using HPM/LPM pin control mode or - * if the regulator should be logically left on. - */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - ((vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_MODE - || vreg->is_enabled) ? - SMPS_LEGACY_ENABLE : SMPS_LEGACY_DISABLE), - SMPS_LEGACY_ENABLE_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* - * Set regulator to HPM if using on/off pin control or if the regulator - * is already enabled in HPM. Otherwise, set it to LPM. - */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->clk_ctrl_addr, - (vreg->pdata.pin_fn == PM8XXX_VREG_PIN_FN_ENABLE - || (vreg->is_enabled - && vreg->mode == REGULATOR_MODE_NORMAL) - ? SMPS_CLK_CTRL_PWM : SMPS_CLK_CTRL_PFM), - SMPS_CLK_CTRL_MASK, &vreg->clk_ctrl_reg); - -bail: - if (!rc) - vreg->is_enabled_pc = true; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_PIN_CTRL); - - return rc; -} - -static int pm8xxx_smps_pin_control_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - mutex_lock(&vreg->pc_lock); - - rc = pm8xxx_vreg_masked_write(vreg, vreg->sleep_ctrl_addr, 0, - SMPS_PIN_CTRL_MASK | SMPS_PIN_CTRL_LPM_MASK, - &vreg->sleep_ctrl_reg); - if (rc) - goto bail; - - /* - * Physically disable the regulator if it was enabled in HPM/LPM pin - * control mode previously and it logically should not be enabled. - */ - if ((vreg->ctrl_reg & SMPS_LEGACY_ENABLE_MASK) == SMPS_LEGACY_ENABLE - && vreg->is_enabled == false) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - SMPS_LEGACY_DISABLE, SMPS_LEGACY_ENABLE_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - } - - /* Change to LPM if LPM was enabled. */ - if (vreg->is_enabled && vreg->mode == REGULATOR_MODE_IDLE) { - rc = pm8xxx_vreg_masked_write(vreg, vreg->clk_ctrl_addr, - SMPS_CLK_CTRL_PFM, SMPS_CLK_CTRL_MASK, - &vreg->clk_ctrl_reg); - if (rc) - goto bail; - } - - rc = pm8xxx_smps_set_voltage_advanced(vreg, vreg->save_uV, - vreg->save_uV, 0); - -bail: - if (!rc) - vreg->is_enabled_pc = false; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_PIN_CTRL); - - return rc; -} - -static int pm8xxx_vs_pin_control_enable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - u8 val = 0; - - mutex_lock(&vreg->pc_lock); - - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN0) - val |= VS_PIN_CTRL_EN0; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN1) - val |= VS_PIN_CTRL_EN1; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN2) - val |= VS_PIN_CTRL_EN2; - if (vreg->pdata.pin_ctrl & PM8XXX_VREG_PIN_CTRL_EN3) - val |= VS_PIN_CTRL_EN3; - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, val, - VS_PIN_CTRL_MASK | VS_ENABLE_MASK, &vreg->ctrl_reg); - - if (!rc) - vreg->is_enabled_pc = true; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_PIN_CTRL); - - return rc; -} - -static int pm8xxx_vs_pin_control_disable(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int rc; - - mutex_lock(&vreg->pc_lock); - - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, 0, - VS_PIN_CTRL_MASK, &vreg->ctrl_reg); - - if (!rc) - vreg->is_enabled_pc = false; - - mutex_unlock(&vreg->pc_lock); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - else - pm8xxx_vreg_show_state(rdev, PM8XXX_REGULATOR_ACTION_PIN_CTRL); - - return rc; -} - -static int pm8xxx_enable_time(struct regulator_dev *rdev) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - - return vreg->pdata.enable_time; -} - -static const char const *pm8xxx_print_actions[] = { - [PM8XXX_REGULATOR_ACTION_INIT] = "initial ", - [PM8XXX_REGULATOR_ACTION_ENABLE] = "enable ", - [PM8XXX_REGULATOR_ACTION_DISABLE] = "disable ", - [PM8XXX_REGULATOR_ACTION_VOLTAGE] = "set voltage", - [PM8XXX_REGULATOR_ACTION_MODE] = "set mode ", - [PM8XXX_REGULATOR_ACTION_PIN_CTRL] = "pin control", -}; - -static void pm8xxx_vreg_show_state(struct regulator_dev *rdev, - enum pm8xxx_regulator_action action) -{ - struct pm8xxx_vreg *vreg = rdev_get_drvdata(rdev); - int uV, pc; - unsigned int mode; - const char *pc_en0 = "", *pc_en1 = "", *pc_en2 = "", *pc_en3 = ""; - const char *pc_total = ""; - const char *action_label = pm8xxx_print_actions[action]; - const char *enable_label; - - mutex_lock(&vreg->pc_lock); - - /* - * Do not print unless REQUEST is specified and SSBI writes have taken - * place, or DUPLICATE is specified. - */ - if (!((pm8xxx_vreg_debug_mask & PM8XXX_VREG_DEBUG_DUPLICATE) - || ((pm8xxx_vreg_debug_mask & PM8XXX_VREG_DEBUG_REQUEST) - && (vreg->write_count != vreg->prev_write_count)))) { - mutex_unlock(&vreg->pc_lock); - return; - } - - vreg->prev_write_count = vreg->write_count; - - pc = vreg->pdata.pin_ctrl; - if (vreg->is_enabled_pc) { - if (pc & PM8XXX_VREG_PIN_CTRL_EN0) - pc_en0 = " EN0"; - if (pc & PM8XXX_VREG_PIN_CTRL_EN1) - pc_en1 = " EN1"; - if (pc & PM8XXX_VREG_PIN_CTRL_EN2) - pc_en2 = " EN2"; - if (pc & PM8XXX_VREG_PIN_CTRL_EN3) - pc_en3 = " EN3"; - if (pc == PM8XXX_VREG_PIN_CTRL_NONE) - pc_total = " none"; - } else { - pc_total = " none"; - } - - mutex_unlock(&vreg->pc_lock); - - enable_label = pm8xxx_vreg_is_enabled(rdev) ? "on " : "off"; - - switch (vreg->type) { - case PM8XXX_REGULATOR_TYPE_PLDO: - uV = pm8xxx_pldo_get_voltage(rdev); - mode = pm8xxx_ldo_get_mode(rdev); - pr_info("%s %-9s: %s, v=%7d uV, mode=%s, pc=%s%s%s%s%s\n", - action_label, vreg->rdesc.name, enable_label, uV, - (mode == REGULATOR_MODE_NORMAL ? "HPM" : "LPM"), - pc_en0, pc_en1, pc_en2, pc_en3, pc_total); - break; - case PM8XXX_REGULATOR_TYPE_NLDO: - uV = pm8xxx_nldo_get_voltage(rdev); - mode = pm8xxx_ldo_get_mode(rdev); - pr_info("%s %-9s: %s, v=%7d uV, mode=%s, pc=%s%s%s%s%s\n", - action_label, vreg->rdesc.name, enable_label, uV, - (mode == REGULATOR_MODE_NORMAL ? "HPM" : "LPM"), - pc_en0, pc_en1, pc_en2, pc_en3, pc_total); - break; - case PM8XXX_REGULATOR_TYPE_NLDO1200: - uV = pm8xxx_nldo1200_get_voltage(rdev); - mode = pm8xxx_nldo1200_get_mode(rdev); - pr_info("%s %-9s: %s, v=%7d uV, mode=%s\n", - action_label, vreg->rdesc.name, enable_label, uV, - (mode == REGULATOR_MODE_NORMAL ? "HPM" : "LPM")); - break; - case PM8XXX_REGULATOR_TYPE_SMPS: - uV = pm8xxx_smps_get_voltage(rdev); - mode = pm8xxx_smps_get_mode(rdev); - pr_info("%s %-9s: %s, v=%7d uV, mode=%s, pc=%s%s%s%s%s\n", - action_label, vreg->rdesc.name, enable_label, uV, - (mode == REGULATOR_MODE_NORMAL ? "HPM" : "LPM"), - pc_en0, pc_en1, pc_en2, pc_en3, pc_total); - break; - case PM8XXX_REGULATOR_TYPE_FTSMPS: - uV = pm8xxx_ftsmps_get_voltage(rdev); - mode = pm8xxx_ftsmps_get_mode(rdev); - pr_info("%s %-9s: %s, v=%7d uV, mode=%s\n", - action_label, vreg->rdesc.name, enable_label, uV, - (mode == REGULATOR_MODE_NORMAL ? "HPM" : "LPM")); - break; - case PM8XXX_REGULATOR_TYPE_VS: - pr_info("%s %-9s: %s, pc=%s%s%s%s%s\n", - action_label, vreg->rdesc.name, enable_label, - pc_en0, pc_en1, pc_en2, pc_en3, pc_total); - break; - case PM8XXX_REGULATOR_TYPE_VS300: - pr_info("%s %-9s: %s\n", - action_label, vreg->rdesc.name, enable_label); - break; - case PM8XXX_REGULATOR_TYPE_NCP: - uV = pm8xxx_ncp_get_voltage(rdev); - pr_info("%s %-9s: %s, v=%7d uV\n", - action_label, vreg->rdesc.name, enable_label, uV); - break; - case PM8XXX_REGULATOR_TYPE_BOOST: - uV = pm8xxx_boost_get_voltage(rdev); - pr_info("%s %-9s: %s, v=%7d uV\n", - action_label, vreg->rdesc.name, enable_label, uV); - break; - default: - break; - } -} - -/* Real regulator operations. */ -static struct regulator_ops pm8xxx_pldo_ops = { - .enable = pm8xxx_ldo_enable, - .disable = pm8xxx_ldo_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .set_voltage = pm8xxx_pldo_set_voltage, - .get_voltage = pm8xxx_pldo_get_voltage, - .list_voltage = pm8xxx_pldo_list_voltage, - .set_mode = pm8xxx_ldo_set_mode, - .get_mode = pm8xxx_ldo_get_mode, - .get_optimum_mode = pm8xxx_vreg_get_optimum_mode, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_nldo_ops = { - .enable = pm8xxx_ldo_enable, - .disable = pm8xxx_ldo_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .set_voltage = pm8xxx_nldo_set_voltage, - .get_voltage = pm8xxx_nldo_get_voltage, - .list_voltage = pm8xxx_nldo_list_voltage, - .set_mode = pm8xxx_ldo_set_mode, - .get_mode = pm8xxx_ldo_get_mode, - .get_optimum_mode = pm8xxx_vreg_get_optimum_mode, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_nldo1200_ops = { - .enable = pm8xxx_nldo1200_enable, - .disable = pm8xxx_nldo1200_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .set_voltage = pm8xxx_nldo1200_set_voltage, - .get_voltage = pm8xxx_nldo1200_get_voltage, - .list_voltage = pm8xxx_nldo1200_list_voltage, - .set_mode = pm8xxx_nldo1200_set_mode, - .get_mode = pm8xxx_nldo1200_get_mode, - .get_optimum_mode = pm8xxx_vreg_get_optimum_mode, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_smps_ops = { - .enable = pm8xxx_smps_enable, - .disable = pm8xxx_smps_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .set_voltage = pm8xxx_smps_set_voltage, - .get_voltage = pm8xxx_smps_get_voltage, - .list_voltage = pm8xxx_smps_list_voltage, - .set_mode = pm8xxx_smps_set_mode, - .get_mode = pm8xxx_smps_get_mode, - .get_optimum_mode = pm8xxx_vreg_get_optimum_mode, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_ftsmps_ops = { - .enable = pm8xxx_ftsmps_enable, - .disable = pm8xxx_ftsmps_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .set_voltage = pm8xxx_ftsmps_set_voltage, - .get_voltage = pm8xxx_ftsmps_get_voltage, - .list_voltage = pm8xxx_ftsmps_list_voltage, - .set_mode = pm8xxx_ftsmps_set_mode, - .get_mode = pm8xxx_ftsmps_get_mode, - .get_optimum_mode = pm8xxx_vreg_get_optimum_mode, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_vs_ops = { - .enable = pm8xxx_vs_enable, - .disable = pm8xxx_vs_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_vs300_ops = { - .enable = pm8xxx_vs300_enable, - .disable = pm8xxx_vs300_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_ncp_ops = { - .enable = pm8xxx_ncp_enable, - .disable = pm8xxx_ncp_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .set_voltage = pm8xxx_ncp_set_voltage, - .get_voltage = pm8xxx_ncp_get_voltage, - .list_voltage = pm8xxx_ncp_list_voltage, - .enable_time = pm8xxx_enable_time, -}; - -static struct regulator_ops pm8xxx_boost_ops = { - .enable = pm8xxx_boost_enable, - .disable = pm8xxx_boost_disable, - .is_enabled = pm8xxx_vreg_is_enabled, - .set_voltage = pm8xxx_boost_set_voltage, - .get_voltage = pm8xxx_boost_get_voltage, - .list_voltage = pm8xxx_boost_list_voltage, - .enable_time = pm8xxx_enable_time, -}; - -/* Pin control regulator operations. */ -static struct regulator_ops pm8xxx_ldo_pc_ops = { - .enable = pm8xxx_ldo_pin_control_enable, - .disable = pm8xxx_ldo_pin_control_disable, - .is_enabled = pm8xxx_vreg_pin_control_is_enabled, -}; - -static struct regulator_ops pm8xxx_smps_pc_ops = { - .enable = pm8xxx_smps_pin_control_enable, - .disable = pm8xxx_smps_pin_control_disable, - .is_enabled = pm8xxx_vreg_pin_control_is_enabled, -}; - -static struct regulator_ops pm8xxx_vs_pc_ops = { - .enable = pm8xxx_vs_pin_control_enable, - .disable = pm8xxx_vs_pin_control_disable, - .is_enabled = pm8xxx_vreg_pin_control_is_enabled, -}; - -static struct regulator_ops *pm8xxx_reg_ops[PM8XXX_REGULATOR_TYPE_MAX] = { - [PM8XXX_REGULATOR_TYPE_PLDO] = &pm8xxx_pldo_ops, - [PM8XXX_REGULATOR_TYPE_NLDO] = &pm8xxx_nldo_ops, - [PM8XXX_REGULATOR_TYPE_NLDO1200] = &pm8xxx_nldo1200_ops, - [PM8XXX_REGULATOR_TYPE_SMPS] = &pm8xxx_smps_ops, - [PM8XXX_REGULATOR_TYPE_FTSMPS] = &pm8xxx_ftsmps_ops, - [PM8XXX_REGULATOR_TYPE_VS] = &pm8xxx_vs_ops, - [PM8XXX_REGULATOR_TYPE_VS300] = &pm8xxx_vs300_ops, - [PM8XXX_REGULATOR_TYPE_NCP] = &pm8xxx_ncp_ops, - [PM8XXX_REGULATOR_TYPE_BOOST] = &pm8xxx_boost_ops, -}; - -static struct regulator_ops *pm8xxx_reg_pc_ops[PM8XXX_REGULATOR_TYPE_MAX] = { - [PM8XXX_REGULATOR_TYPE_PLDO] = &pm8xxx_ldo_pc_ops, - [PM8XXX_REGULATOR_TYPE_NLDO] = &pm8xxx_ldo_pc_ops, - [PM8XXX_REGULATOR_TYPE_SMPS] = &pm8xxx_smps_pc_ops, - [PM8XXX_REGULATOR_TYPE_VS] = &pm8xxx_vs_pc_ops, -}; - -static unsigned pm8xxx_n_voltages[PM8XXX_REGULATOR_TYPE_MAX] = { - [PM8XXX_REGULATOR_TYPE_PLDO] = PLDO_SET_POINTS, - [PM8XXX_REGULATOR_TYPE_NLDO] = NLDO_SET_POINTS, - [PM8XXX_REGULATOR_TYPE_NLDO1200] = NLDO1200_SET_POINTS, - [PM8XXX_REGULATOR_TYPE_SMPS] = SMPS_ADVANCED_SET_POINTS, - [PM8XXX_REGULATOR_TYPE_FTSMPS] = FTSMPS_SET_POINTS, - [PM8XXX_REGULATOR_TYPE_VS] = 0, - [PM8XXX_REGULATOR_TYPE_VS300] = 0, - [PM8XXX_REGULATOR_TYPE_NCP] = NCP_SET_POINTS, - [PM8XXX_REGULATOR_TYPE_BOOST] = BOOST_SET_POINTS, -}; - -static int pm8xxx_init_ldo(struct pm8xxx_vreg *vreg, bool is_real) -{ - int rc = 0; - int i; - u8 bank; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Save the current test register state. */ - for (i = 0; i < LDO_TEST_BANKS; i++) { - bank = REGULATOR_BANK_SEL(i); - rc = pm8xxx_writeb(vreg->dev->parent, vreg->test_addr, bank); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[i]); - if (rc) - goto bail; - vreg->test_reg[i] |= REGULATOR_BANK_WRITE; - } - - if (is_real) { - /* Set pull down enable based on platform data. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - (vreg->pdata.pull_down_enable ? LDO_PULL_DOWN_ENABLE : 0), - LDO_PULL_DOWN_ENABLE_MASK, &vreg->ctrl_reg); - - vreg->is_enabled = !!_pm8xxx_vreg_is_enabled(vreg); - - vreg->mode = ((vreg->ctrl_reg & LDO_CTRL_PM_MASK) - == LDO_CTRL_PM_LPM ? - REGULATOR_MODE_IDLE : REGULATOR_MODE_NORMAL); - } -bail: - if (rc) - vreg_err(vreg, "pm8xxx_readb/writeb failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_init_nldo1200(struct pm8xxx_vreg *vreg) -{ - int rc = 0; - int i; - u8 bank; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Save the current test register state. */ - for (i = 0; i < LDO_TEST_BANKS; i++) { - bank = REGULATOR_BANK_SEL(i); - rc = pm8xxx_writeb(vreg->dev->parent, vreg->test_addr, bank); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[i]); - if (rc) - goto bail; - vreg->test_reg[i] |= REGULATOR_BANK_WRITE; - } - - vreg->save_uV = _pm8xxx_nldo1200_get_voltage(vreg); - - /* Set pull down enable based on platform data. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - (vreg->pdata.pull_down_enable ? NLDO1200_PULL_DOWN_ENABLE : 0) - | REGULATOR_BANK_SEL(1) | REGULATOR_BANK_WRITE, - NLDO1200_PULL_DOWN_ENABLE_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[1]); - -bail: - if (rc) - vreg_err(vreg, "pm8xxx_readb/writeb failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_init_smps(struct pm8xxx_vreg *vreg, bool is_real) -{ - int rc = 0; - int i; - u8 bank; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Save the current test2 register state. */ - for (i = 0; i < SMPS_TEST_BANKS; i++) { - bank = REGULATOR_BANK_SEL(i); - rc = pm8xxx_writeb(vreg->dev->parent, vreg->test_addr, bank); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[i]); - if (rc) - goto bail; - vreg->test_reg[i] |= REGULATOR_BANK_WRITE; - } - - /* Save the current clock control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->clk_ctrl_addr, - &vreg->clk_ctrl_reg); - if (rc) - goto bail; - - /* Save the current sleep control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->sleep_ctrl_addr, - &vreg->sleep_ctrl_reg); - if (rc) - goto bail; - - vreg->save_uV = _pm8xxx_smps_get_voltage(vreg); - - if (is_real) { - /* Set advanced mode pull down enable based on platform data. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->test_addr, - (vreg->pdata.pull_down_enable - ? SMPS_ADVANCED_PULL_DOWN_ENABLE : 0) - | REGULATOR_BANK_SEL(6) | REGULATOR_BANK_WRITE, - REGULATOR_BANK_MASK | SMPS_ADVANCED_PULL_DOWN_ENABLE, - &vreg->test_reg[6]); - if (rc) - goto bail; - - vreg->is_enabled = !!_pm8xxx_vreg_is_enabled(vreg); - - vreg->mode = ((vreg->clk_ctrl_reg & SMPS_CLK_CTRL_MASK) - == SMPS_CLK_CTRL_PFM ? - REGULATOR_MODE_IDLE : REGULATOR_MODE_NORMAL); - } - - if (!SMPS_IN_ADVANCED_MODE(vreg) && is_real) { - /* Set legacy mode pull down enable based on platform data. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - (vreg->pdata.pull_down_enable - ? SMPS_LEGACY_PULL_DOWN_ENABLE : 0), - SMPS_LEGACY_PULL_DOWN_ENABLE, &vreg->ctrl_reg); - if (rc) - goto bail; - } - -bail: - if (rc) - vreg_err(vreg, "pm8xxx_readb/writeb failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_init_ftsmps(struct pm8xxx_vreg *vreg) -{ - int rc, i; - u8 bank; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Store current regulator register values. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->pfm_ctrl_addr, - &vreg->pfm_ctrl_reg); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->pwr_cnfg_addr, - &vreg->pwr_cnfg_reg); - if (rc) - goto bail; - - /* Save the current fts_cnfg1 register state (uses 'test' member). */ - for (i = 0; i < SMPS_TEST_BANKS; i++) { - bank = REGULATOR_BANK_SEL(i); - rc = pm8xxx_writeb(vreg->dev->parent, vreg->test_addr, bank); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[i]); - if (rc) - goto bail; - vreg->test_reg[i] |= REGULATOR_BANK_WRITE; - } - - vreg->save_uV = _pm8xxx_ftsmps_get_voltage(vreg); - - /* Set pull down enable based on platform data. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->pwr_cnfg_addr, - (vreg->pdata.pull_down_enable ? FTSMPS_PULL_DOWN_ENABLE : 0), - FTSMPS_PULL_DOWN_ENABLE_MASK, &vreg->pwr_cnfg_reg); - -bail: - if (rc) - vreg_err(vreg, "pm8xxx_readb/writeb failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_init_vs(struct pm8xxx_vreg *vreg, bool is_real) -{ - int rc = 0; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) { - vreg_err(vreg, "pm8xxx_readb failed, rc=%d\n", rc); - return rc; - } - - /* Save the current test register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[0]); - if (rc) { - vreg_err(vreg, "pm8xxx_readb failed, rc=%d\n", rc); - return rc; - } - - if (is_real) { - /* Set pull down enable based on platform data. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - (vreg->pdata.pull_down_enable ? VS_PULL_DOWN_ENABLE - : VS_PULL_DOWN_DISABLE), - VS_PULL_DOWN_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, - "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - - vreg->is_enabled = !!_pm8xxx_vreg_is_enabled(vreg); - } - - return rc; -} - -static int pm8xxx_init_vs300(struct pm8xxx_vreg *vreg) -{ - int rc; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) { - vreg_err(vreg, "pm8xxx_readb failed, rc=%d\n", rc); - return rc; - } - - /* Save the current test register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[0]); - if (rc) { - vreg_err(vreg, "pm8xxx_readb failed, rc=%d\n", rc); - return rc; - } - - /* Set pull down enable based on platform data. */ - rc = pm8xxx_vreg_masked_write(vreg, vreg->ctrl_addr, - (vreg->pdata.pull_down_enable ? VS300_PULL_DOWN_ENABLE : 0), - VS300_PULL_DOWN_ENABLE_MASK, &vreg->ctrl_reg); - - if (rc) - vreg_err(vreg, "pm8xxx_vreg_masked_write failed, rc=%d\n", rc); - - return rc; -} - -static int pm8xxx_init_ncp(struct pm8xxx_vreg *vreg) -{ - int rc; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) { - vreg_err(vreg, "pm8xxx_readb failed, rc=%d\n", rc); - return rc; - } - - return rc; -} - -static int pm8xxx_init_boost(struct pm8xxx_vreg *vreg) -{ - int rc; - - /* Save the current control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) { - vreg_err(vreg, "pm8xxx_readb failed, rc=%d\n", rc); - return rc; - } - - return rc; -} - -static int pm8xxx_vreg_probe(struct platform_device *pdev) -{ - struct pm8xxx_regulator_core_platform_data *core_data; - const struct pm8xxx_regulator_platform_data *pdata; - enum pm8xxx_vreg_pin_function pin_fn; - struct regulator_desc *rdesc; - struct pm8xxx_vreg *vreg; - unsigned pin_ctrl; - int rc = 0; - - if (pdev == NULL) { - pr_err("no platform device specified\n"); - return -EINVAL; - } - - core_data = pdev->dev.platform_data; - if (core_data == NULL) { - pr_err("no core data specified\n"); - return -EINVAL; - } - - pdata = core_data->pdata; - vreg = core_data->vreg; - if (pdata == NULL) { - pr_err("no pdata specified\n"); - return -EINVAL; - } else if (vreg == NULL) { - pr_err("no vreg specified\n"); - return -EINVAL; - } - - if (vreg->rdesc.name == NULL) { - pr_err("regulator name missing\n"); - return -EINVAL; - } else if (vreg->type < 0 || vreg->type >= PM8XXX_REGULATOR_TYPE_MAX) { - pr_err("%s: regulator type=%d is invalid\n", vreg->rdesc.name, - vreg->type); - return -EINVAL; - } else if (core_data->is_pin_controlled - && pm8xxx_reg_pc_ops[vreg->type] == NULL) { - pr_err("%s: regulator type=%d does not support pin control\n", - vreg->rdesc.name, vreg->type); - return -EINVAL; - } else if (core_data->is_pin_controlled - && vreg->rdesc_pc.name == NULL) { - pr_err("%s: regulator pin control name missing\n", - vreg->rdesc.name); - return -EINVAL; - } - - if (core_data->is_pin_controlled) - rdesc = &vreg->rdesc_pc; - else - rdesc = &vreg->rdesc; - if (!pdata) { - pr_err("%s requires platform data\n", vreg->rdesc.name); - return -EINVAL; - } - - rdesc->id = pdev->id; - rdesc->owner = THIS_MODULE; - rdesc->type = REGULATOR_VOLTAGE; - if (core_data->is_pin_controlled) { - rdesc->ops = pm8xxx_reg_pc_ops[vreg->type]; - rdesc->n_voltages = 0; - } else { - rdesc->ops = pm8xxx_reg_ops[vreg->type]; - rdesc->n_voltages = pm8xxx_n_voltages[vreg->type]; - } - - mutex_lock(&vreg->pc_lock); - - if (!core_data->is_pin_controlled) { - /* Do not modify pin control and pin function values. */ - pin_ctrl = vreg->pdata.pin_ctrl; - pin_fn = vreg->pdata.pin_fn; - memcpy(&(vreg->pdata), pdata, - sizeof(struct pm8xxx_regulator_platform_data)); - vreg->pdata.pin_ctrl = pin_ctrl; - vreg->pdata.pin_fn = pin_fn; - /* - * If slew_rate isn't specified but enable_time is, then set - * slew_rate = max_uV / enable_time. - */ - if (vreg->pdata.enable_time > 0 - && vreg->pdata.init_data.constraints.max_uV > 0 - && vreg->pdata.slew_rate <= 0) - vreg->pdata.slew_rate = - DIV_ROUND_UP(vreg->pdata.init_data.constraints.max_uV, - vreg->pdata.enable_time); - vreg->dev = &pdev->dev; - } else { - /* Pin control regulator */ - if ((pdata->pin_ctrl & PM8XXX_VREG_PIN_CTRL_ALL) - == PM8XXX_VREG_PIN_CTRL_NONE) { - pr_err("%s: no pin control input specified\n", - vreg->rdesc.name); - mutex_unlock(&vreg->pc_lock); - return -EINVAL; - } - vreg->pdata.pin_ctrl = pdata->pin_ctrl; - vreg->pdata.pin_fn = pdata->pin_fn; - vreg->dev_pc = &pdev->dev; - if (!vreg->dev) - vreg->dev = &pdev->dev; - } - - /* Initialize register values. */ - switch (vreg->type) { - case PM8XXX_REGULATOR_TYPE_PLDO: - case PM8XXX_REGULATOR_TYPE_NLDO: - rc = pm8xxx_init_ldo(vreg, !core_data->is_pin_controlled); - break; - case PM8XXX_REGULATOR_TYPE_NLDO1200: - rc = pm8xxx_init_nldo1200(vreg); - break; - case PM8XXX_REGULATOR_TYPE_SMPS: - rc = pm8xxx_init_smps(vreg, !core_data->is_pin_controlled); - break; - case PM8XXX_REGULATOR_TYPE_FTSMPS: - rc = pm8xxx_init_ftsmps(vreg); - break; - case PM8XXX_REGULATOR_TYPE_VS: - rc = pm8xxx_init_vs(vreg, !core_data->is_pin_controlled); - break; - case PM8XXX_REGULATOR_TYPE_VS300: - rc = pm8xxx_init_vs300(vreg); - break; - case PM8XXX_REGULATOR_TYPE_NCP: - rc = pm8xxx_init_ncp(vreg); - break; - case PM8XXX_REGULATOR_TYPE_BOOST: - rc = pm8xxx_init_boost(vreg); - break; - default: - break; - } - - mutex_unlock(&vreg->pc_lock); - - if (rc) - goto bail; - - if (!core_data->is_pin_controlled) { - vreg->rdev = regulator_register(rdesc, &pdev->dev, - &(pdata->init_data), vreg, NULL); - if (IS_ERR(vreg->rdev)) { - rc = PTR_ERR(vreg->rdev); - vreg->rdev = NULL; - pr_err("regulator_register failed: %s, rc=%d\n", - vreg->rdesc.name, rc); - } - } else { - vreg->rdev_pc = regulator_register(rdesc, &pdev->dev, - &(pdata->init_data), vreg, NULL); - if (IS_ERR(vreg->rdev_pc)) { - rc = PTR_ERR(vreg->rdev_pc); - vreg->rdev_pc = NULL; - pr_err("regulator_register failed: %s, rc=%d\n", - vreg->rdesc.name, rc); - } - } - if ((pm8xxx_vreg_debug_mask & PM8XXX_VREG_DEBUG_INIT) && !rc - && vreg->rdev) - pm8xxx_vreg_show_state(vreg->rdev, - PM8XXX_REGULATOR_ACTION_INIT); - - platform_set_drvdata(pdev, core_data); - -bail: - if (rc) - pr_err("error for %s, rc=%d\n", vreg->rdesc.name, rc); - - return rc; -} - -static int pm8xxx_vreg_remove(struct platform_device *pdev) -{ - struct pm8xxx_regulator_core_platform_data *core_data; - - core_data = platform_get_drvdata(pdev); - platform_set_drvdata(pdev, NULL); - - if (core_data) { - if (core_data->is_pin_controlled) - regulator_unregister(core_data->vreg->rdev_pc); - else - regulator_unregister(core_data->vreg->rdev); - } - - return 0; -} - -static struct platform_driver pm8xxx_vreg_driver = { - .probe = pm8xxx_vreg_probe, - .remove = pm8xxx_vreg_remove, - .driver = { - .name = PM8XXX_REGULATOR_DEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init pm8xxx_vreg_init(void) -{ - return platform_driver_register(&pm8xxx_vreg_driver); -} -postcore_initcall(pm8xxx_vreg_init); - -static void __exit pm8xxx_vreg_exit(void) -{ - platform_driver_unregister(&pm8xxx_vreg_driver); -} -module_exit(pm8xxx_vreg_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC PM8XXX regulator driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_REGULATOR_DEV_NAME); diff --git a/drivers/regulator/pmic8058-regulator.c b/drivers/regulator/pmic8058-regulator.c deleted file mode 100644 index 2f940764c3633a776fad5078c855ca4e3a2ac6f4..0000000000000000000000000000000000000000 --- a/drivers/regulator/pmic8058-regulator.c +++ /dev/null @@ -1,1756 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Regulator types */ -#define REGULATOR_TYPE_LDO 0 -#define REGULATOR_TYPE_SMPS 1 -#define REGULATOR_TYPE_LVS 2 -#define REGULATOR_TYPE_NCP 3 - -/* Common masks */ -#define REGULATOR_EN_MASK 0x80 - -#define REGULATOR_BANK_MASK 0xF0 -#define REGULATOR_BANK_SEL(n) ((n) << 4) -#define REGULATOR_BANK_WRITE 0x80 - -#define LDO_TEST_BANKS 7 -#define SMPS_TEST_BANKS 8 -#define REGULATOR_TEST_BANKS_MAX SMPS_TEST_BANKS - -/* LDO programming */ - -/* CTRL register */ -#define LDO_ENABLE_MASK 0x80 -#define LDO_ENABLE 0x80 -#define LDO_PULL_DOWN_ENABLE_MASK 0x40 -#define LDO_PULL_DOWN_ENABLE 0x40 - -#define LDO_CTRL_PM_MASK 0x20 -#define LDO_CTRL_PM_HPM 0x00 -#define LDO_CTRL_PM_LPM 0x20 - -#define LDO_CTRL_VPROG_MASK 0x1F - -/* TEST register bank 0 */ -#define LDO_TEST_LPM_MASK 0x40 -#define LDO_TEST_LPM_SEL_CTRL 0x00 -#define LDO_TEST_LPM_SEL_TCXO 0x40 - -/* TEST register bank 2 */ -#define LDO_TEST_VPROG_UPDATE_MASK 0x08 -#define LDO_TEST_RANGE_SEL_MASK 0x04 -#define LDO_TEST_FINE_STEP_MASK 0x02 -#define LDO_TEST_FINE_STEP_SHIFT 1 - -/* TEST register bank 4 */ -#define LDO_TEST_RANGE_EXT_MASK 0x01 - -/* TEST register bank 5 */ -#define LDO_TEST_PIN_CTRL_MASK 0x0F -#define LDO_TEST_PIN_CTRL_EN3 0x08 -#define LDO_TEST_PIN_CTRL_EN2 0x04 -#define LDO_TEST_PIN_CTRL_EN1 0x02 -#define LDO_TEST_PIN_CTRL_EN0 0x01 - -/* TEST register bank 6 */ -#define LDO_TEST_PIN_CTRL_LPM_MASK 0x0F - -/* Allowable voltage ranges */ -#define PLDO_LOW_UV_MIN 750000 -#define PLDO_LOW_UV_MAX 1537500 -#define PLDO_LOW_FINE_STEP_UV 12500 - -#define PLDO_NORM_UV_MIN 1500000 -#define PLDO_NORM_UV_MAX 3075000 -#define PLDO_NORM_FINE_STEP_UV 25000 - -#define PLDO_HIGH_UV_MIN 1750000 -#define PLDO_HIGH_UV_MAX 4900000 -#define PLDO_HIGH_FINE_STEP_UV 50000 - -#define NLDO_UV_MIN 750000 -#define NLDO_UV_MAX 1537500 -#define NLDO_FINE_STEP_UV 12500 - -/* SMPS masks and values */ - -/* CTRL register */ - -/* Legacy mode */ -#define SMPS_LEGACY_ENABLE 0x80 -#define SMPS_LEGACY_PULL_DOWN_ENABLE 0x40 -#define SMPS_LEGACY_VREF_SEL_MASK 0x20 -#define SMPS_LEGACY_VPROG_MASK 0x1F - -/* Advanced mode */ -#define SMPS_ADVANCED_BAND_MASK 0xC0 -#define SMPS_ADVANCED_BAND_OFF 0x00 -#define SMPS_ADVANCED_BAND_1 0x40 -#define SMPS_ADVANCED_BAND_2 0x80 -#define SMPS_ADVANCED_BAND_3 0xC0 -#define SMPS_ADVANCED_VPROG_MASK 0x3F - -/* Legacy mode voltage ranges */ -#define SMPS_MODE1_UV_MIN 1500000 -#define SMPS_MODE1_UV_MAX 3050000 -#define SMPS_MODE1_UV_STEP 50000 - -#define SMPS_MODE2_UV_MIN 750000 -#define SMPS_MODE2_UV_MAX 1525000 -#define SMPS_MODE2_UV_STEP 25000 - -#define SMPS_MODE3_UV_MIN 375000 -#define SMPS_MODE3_UV_MAX 1150000 -#define SMPS_MODE3_UV_STEP 25000 - -/* Advanced mode voltage ranges */ -#define SMPS_BAND3_UV_MIN 1500000 -#define SMPS_BAND3_UV_MAX 3075000 -#define SMPS_BAND3_UV_STEP 25000 - -#define SMPS_BAND2_UV_MIN 750000 -#define SMPS_BAND2_UV_MAX 1537500 -#define SMPS_BAND2_UV_STEP 12500 - -#define SMPS_BAND1_UV_MIN 375000 -#define SMPS_BAND1_UV_MAX 1162500 -#define SMPS_BAND1_UV_STEP 12500 - -#define SMPS_UV_MIN SMPS_MODE3_UV_MIN -#define SMPS_UV_MAX SMPS_MODE1_UV_MAX - -/* Test2 register bank 1 */ -#define SMPS_LEGACY_VLOW_SEL_MASK 0x01 - -/* Test2 register bank 6 */ -#define SMPS_ADVANCED_PULL_DOWN_ENABLE 0x08 - -/* Test2 register bank 7 */ -#define SMPS_ADVANCED_MODE_MASK 0x02 -#define SMPS_ADVANCED_MODE 0x02 -#define SMPS_LEGACY_MODE 0x00 - -#define SMPS_IN_ADVANCED_MODE(vreg) \ - ((vreg->test_reg[7] & SMPS_ADVANCED_MODE_MASK) == SMPS_ADVANCED_MODE) - -/* BUCK_SLEEP_CNTRL register */ -#define SMPS_PIN_CTRL_MASK 0xF0 -#define SMPS_PIN_CTRL_A1 0x80 -#define SMPS_PIN_CTRL_A0 0x40 -#define SMPS_PIN_CTRL_D1 0x20 -#define SMPS_PIN_CTRL_D0 0x10 - -#define SMPS_PIN_CTRL_LPM_MASK 0x0F -#define SMPS_PIN_CTRL_LPM_A1 0x08 -#define SMPS_PIN_CTRL_LPM_A0 0x04 -#define SMPS_PIN_CTRL_LPM_D1 0x02 -#define SMPS_PIN_CTRL_LPM_D0 0x01 - -/* BUCK_CLOCK_CNTRL register */ -#define SMPS_CLK_DIVIDE2 0x40 - -#define SMPS_CLK_CTRL_MASK 0x30 -#define SMPS_CLK_CTRL_FOLLOW_TCXO 0x00 -#define SMPS_CLK_CTRL_PWM 0x10 -#define SMPS_CLK_CTRL_PFM 0x20 - -/* LVS masks and values */ - -/* CTRL register */ -#define LVS_ENABLE_MASK 0x80 -#define LVS_ENABLE 0x80 -#define LVS_PULL_DOWN_ENABLE_MASK 0x40 -#define LVS_PULL_DOWN_ENABLE 0x00 -#define LVS_PULL_DOWN_DISABLE 0x40 - -#define LVS_PIN_CTRL_MASK 0x0F -#define LVS_PIN_CTRL_EN0 0x08 -#define LVS_PIN_CTRL_EN1 0x04 -#define LVS_PIN_CTRL_EN2 0x02 -#define LVS_PIN_CTRL_EN3 0x01 - -/* NCP masks and values */ - -/* CTRL register */ -#define NCP_VPROG_MASK 0x1F - -#define NCP_UV_MIN 1500000 -#define NCP_UV_MAX 3050000 -#define NCP_UV_STEP 50000 - -#define GLOBAL_ENABLE_MAX (2) -struct pm8058_enable { - u16 addr; - u8 reg; -}; - -struct pm8058_vreg { - struct device *dev; - struct pm8058_vreg_pdata *pdata; - struct regulator_dev *rdev; - struct pm8058_enable *global_enable[GLOBAL_ENABLE_MAX]; - int hpm_min_load; - int save_uV; - unsigned pc_vote; - unsigned optimum; - unsigned mode_initialized; - u16 ctrl_addr; - u16 test_addr; - u16 clk_ctrl_addr; - u16 sleep_ctrl_addr; - u8 type; - u8 ctrl_reg; - u8 test_reg[REGULATOR_TEST_BANKS_MAX]; - u8 clk_ctrl_reg; - u8 sleep_ctrl_reg; - u8 is_nmos; - u8 global_enable_mask[GLOBAL_ENABLE_MAX]; -}; - -#define LDO_M2(_id, _ctrl_addr, _test_addr, _is_nmos, _hpm_min_load, \ - _en0, _en0_mask, _en1, _en1_mask) \ - [PM8058_VREG_ID_##_id] = { \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .type = REGULATOR_TYPE_LDO, \ - .hpm_min_load = PM8058_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \ - .is_nmos = _is_nmos, \ - .global_enable = { \ - [0] = _en0, \ - [1] = _en1, \ - }, \ - .global_enable_mask = { \ - [0] = _en0_mask, \ - [1] = _en1_mask, \ - }, \ - } - -#define LDO(_id, _ctrl_addr, _test_addr, _is_nmos, _hpm_min_load, \ - _en0, _en0_mask) \ - LDO_M2(_id, _ctrl_addr, _test_addr, _is_nmos, _hpm_min_load, \ - _en0, _en0_mask, NULL, 0) - -#define SMPS(_id, _ctrl_addr, _test_addr, _clk_ctrl_addr, _sleep_ctrl_addr, \ - _hpm_min_load, _en0, _en0_mask) \ - [PM8058_VREG_ID_##_id] = { \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .clk_ctrl_addr = _clk_ctrl_addr, \ - .sleep_ctrl_addr = _sleep_ctrl_addr, \ - .type = REGULATOR_TYPE_SMPS, \ - .hpm_min_load = PM8058_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \ - .global_enable = { \ - [0] = _en0, \ - [1] = NULL, \ - }, \ - .global_enable_mask = { \ - [0] = _en0_mask, \ - [1] = 0, \ - }, \ - } - -#define LVS(_id, _ctrl_addr, _en0, _en0_mask) \ - [PM8058_VREG_ID_##_id] = { \ - .ctrl_addr = _ctrl_addr, \ - .type = REGULATOR_TYPE_LVS, \ - .global_enable = { \ - [0] = _en0, \ - [1] = NULL, \ - }, \ - .global_enable_mask = { \ - [0] = _en0_mask, \ - [1] = 0, \ - }, \ - } - -#define NCP(_id, _ctrl_addr, _test1) \ - [PM8058_VREG_ID_##_id] = { \ - .ctrl_addr = _ctrl_addr, \ - .type = REGULATOR_TYPE_NCP, \ - .test_addr = _test1, \ - .global_enable = { \ - [0] = NULL, \ - [1] = NULL, \ - }, \ - .global_enable_mask = { \ - [0] = 0, \ - [1] = 0, \ - }, \ - } - -#define MASTER_ENABLE_COUNT 6 - -#define EN_MSM 0 -#define EN_PH 1 -#define EN_RF 2 -#define EN_GRP_5_4 3 -#define EN_GRP_3_2 4 -#define EN_GRP_1_0 5 - -/* Master regulator control registers */ -static struct pm8058_enable m_en[MASTER_ENABLE_COUNT] = { - [EN_MSM] = { - .addr = 0x018, /* VREG_EN_MSM */ - }, - [EN_PH] = { - .addr = 0x019, /* VREG_EN_PH */ - }, - [EN_RF] = { - .addr = 0x01A, /* VREG_EN_RF */ - }, - [EN_GRP_5_4] = { - .addr = 0x1C8, /* VREG_EN_MSM_GRP_5-4 */ - }, - [EN_GRP_3_2] = { - .addr = 0x1C9, /* VREG_EN_MSM_GRP_3-2 */ - }, - [EN_GRP_1_0] = { - .addr = 0x1CA, /* VREG_EN_MSM_GRP_1-0 */ - }, -}; - - -static struct pm8058_vreg pm8058_vreg[] = { - /* id ctrl test n/p hpm_min m_en m_en_mask */ - LDO(L0, 0x009, 0x065, 1, LDO_150, &m_en[EN_GRP_5_4], BIT(3)), - LDO(L1, 0x00A, 0x066, 1, LDO_300, &m_en[EN_GRP_5_4], BIT(6) | BIT(2)), - LDO(L2, 0x00B, 0x067, 0, LDO_300, &m_en[EN_GRP_3_2], BIT(2)), - LDO(L3, 0x00C, 0x068, 0, LDO_150, &m_en[EN_GRP_1_0], BIT(1)), - LDO(L4, 0x00D, 0x069, 0, LDO_50, &m_en[EN_MSM], 0), - LDO(L5, 0x00E, 0x06A, 0, LDO_300, &m_en[EN_GRP_1_0], BIT(7)), - LDO(L6, 0x00F, 0x06B, 0, LDO_50, &m_en[EN_GRP_1_0], BIT(2)), - LDO(L7, 0x010, 0x06C, 0, LDO_50, &m_en[EN_GRP_3_2], BIT(3)), - LDO(L8, 0x011, 0x06D, 0, LDO_300, &m_en[EN_PH], BIT(7)), - LDO(L9, 0x012, 0x06E, 0, LDO_300, &m_en[EN_GRP_1_0], BIT(3)), - LDO(L10, 0x013, 0x06F, 0, LDO_300, &m_en[EN_GRP_3_2], BIT(4)), - LDO(L11, 0x014, 0x070, 0, LDO_150, &m_en[EN_PH], BIT(4)), - LDO(L12, 0x015, 0x071, 0, LDO_150, &m_en[EN_PH], BIT(3)), - LDO(L13, 0x016, 0x072, 0, LDO_300, &m_en[EN_GRP_3_2], BIT(1)), - LDO(L14, 0x017, 0x073, 0, LDO_300, &m_en[EN_GRP_1_0], BIT(5)), - LDO(L15, 0x089, 0x0E5, 0, LDO_300, &m_en[EN_GRP_1_0], BIT(4)), - LDO(L16, 0x08A, 0x0E6, 0, LDO_300, &m_en[EN_GRP_3_2], BIT(0)), - LDO(L17, 0x08B, 0x0E7, 0, LDO_150, &m_en[EN_RF], BIT(7)), - LDO(L18, 0x11D, 0x125, 0, LDO_150, &m_en[EN_RF], BIT(6)), - LDO(L19, 0x11E, 0x126, 0, LDO_150, &m_en[EN_RF], BIT(5)), - LDO(L20, 0x11F, 0x127, 0, LDO_150, &m_en[EN_RF], BIT(4)), - LDO_M2(L21, 0x120, 0x128, 1, LDO_150, &m_en[EN_GRP_5_4], BIT(1), - &m_en[EN_GRP_1_0], BIT(6)), - LDO(L22, 0x121, 0x129, 1, LDO_300, &m_en[EN_GRP_3_2], BIT(7)), - LDO(L23, 0x122, 0x12A, 1, LDO_300, &m_en[EN_GRP_5_4], BIT(0)), - LDO(L24, 0x123, 0x12B, 1, LDO_150, &m_en[EN_RF], BIT(3)), - LDO(L25, 0x124, 0x12C, 1, LDO_150, &m_en[EN_RF], BIT(2)), - - /* id ctrl test2 clk sleep hpm_min m_en m_en_mask */ - SMPS(S0, 0x004, 0x084, 0x1D1, 0x1D8, SMPS, &m_en[EN_MSM], BIT(7)), - SMPS(S1, 0x005, 0x085, 0x1D2, 0x1DB, SMPS, &m_en[EN_MSM], BIT(6)), - SMPS(S2, 0x110, 0x119, 0x1D3, 0x1DE, SMPS, &m_en[EN_GRP_5_4], BIT(5)), - SMPS(S3, 0x111, 0x11A, 0x1D4, 0x1E1, SMPS, &m_en[EN_GRP_5_4], - BIT(7) | BIT(4)), - SMPS(S4, 0x112, 0x11B, 0x1D5, 0x1E4, SMPS, &m_en[EN_GRP_3_2], BIT(5)), - - /* id ctrl m_en m_en_mask */ - LVS(LVS0, 0x12D, &m_en[EN_RF], BIT(1)), - LVS(LVS1, 0x12F, &m_en[EN_GRP_1_0], BIT(0)), - - /* id ctrl test1 */ - NCP(NCP, 0x090, 0x0EC), -}; - -static int pm8058_smps_set_voltage_advanced(struct pm8058_vreg *vreg, int uV, - int force_on); -static int pm8058_smps_set_voltage_legacy(struct pm8058_vreg *vreg, int uV); -static int _pm8058_vreg_is_enabled(struct pm8058_vreg *vreg); - -static unsigned int pm8058_vreg_get_mode(struct regulator_dev *dev); - -static void print_write_error(struct pm8058_vreg *vreg, int rc, - const char *func); - -static int pm8058_vreg_write(struct pm8058_vreg *vreg, - u16 addr, u8 val, u8 mask, u8 *reg_save) -{ - int rc = 0; - u8 reg; - - reg = (*reg_save & ~mask) | (val & mask); - if (reg != *reg_save) - rc = pm8xxx_writeb(vreg->dev->parent, addr, reg); - if (rc) - pr_err("%s: pm8xxx_write failed, rc=%d\n", __func__, rc); - else - *reg_save = reg; - return rc; -} - -static int pm8058_vreg_is_global_enabled(struct pm8058_vreg *vreg) -{ - int ret = 0, i; - - for (i = 0; - (i < GLOBAL_ENABLE_MAX) && !ret && vreg->global_enable[i]; i++) - ret = vreg->global_enable[i]->reg & - vreg->global_enable_mask[i]; - - return ret; -} - - -static int pm8058_vreg_set_global_enable(struct pm8058_vreg *vreg, int on) -{ - int rc = 0, i; - - for (i = 0; - (i < GLOBAL_ENABLE_MAX) && !rc && vreg->global_enable[i]; i++) - rc = pm8058_vreg_write(vreg, vreg->global_enable[i]->addr, - (on ? vreg->global_enable_mask[i] : 0), - vreg->global_enable_mask[i], - &vreg->global_enable[i]->reg); - - return rc; -} - -static int pm8058_vreg_using_pin_ctrl(struct pm8058_vreg *vreg) -{ - int ret = 0; - - switch (vreg->type) { - case REGULATOR_TYPE_LDO: - ret = ((vreg->test_reg[5] & LDO_TEST_PIN_CTRL_MASK) << 4) - | (vreg->test_reg[6] & LDO_TEST_PIN_CTRL_LPM_MASK); - break; - case REGULATOR_TYPE_SMPS: - ret = vreg->sleep_ctrl_reg - & (SMPS_PIN_CTRL_MASK | SMPS_PIN_CTRL_LPM_MASK); - break; - case REGULATOR_TYPE_LVS: - ret = vreg->ctrl_reg & LVS_PIN_CTRL_MASK; - break; - } - - return ret; -} - -static int pm8058_vreg_set_pin_ctrl(struct pm8058_vreg *vreg, int on) -{ - int rc = 0, bank; - u8 val = 0, mask; - unsigned pc = vreg->pdata->pin_ctrl; - unsigned pf = vreg->pdata->pin_fn; - - switch (vreg->type) { - case REGULATOR_TYPE_LDO: - if (on) { - if (pc & PM8058_VREG_PIN_CTRL_D0) - val |= LDO_TEST_PIN_CTRL_EN0; - if (pc & PM8058_VREG_PIN_CTRL_D1) - val |= LDO_TEST_PIN_CTRL_EN1; - if (pc & PM8058_VREG_PIN_CTRL_A0) - val |= LDO_TEST_PIN_CTRL_EN2; - if (pc & PM8058_VREG_PIN_CTRL_A1) - val |= LDO_TEST_PIN_CTRL_EN3; - - bank = (pf == PM8058_VREG_PIN_FN_ENABLE ? 5 : 6); - rc = pm8058_vreg_write(vreg, vreg->test_addr, - val | REGULATOR_BANK_SEL(bank) - | REGULATOR_BANK_WRITE, - LDO_TEST_PIN_CTRL_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[bank]); - if (rc) - goto bail; - - val = LDO_TEST_LPM_SEL_CTRL | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0); - mask = LDO_TEST_LPM_MASK | REGULATOR_BANK_MASK; - rc = pm8058_vreg_write(vreg, vreg->test_addr, val, mask, - &vreg->test_reg[0]); - if (rc) - goto bail; - - if (pf == PM8058_VREG_PIN_FN_ENABLE) { - /* Pin control ON/OFF */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - LDO_CTRL_PM_HPM, - LDO_ENABLE_MASK | LDO_CTRL_PM_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - rc = pm8058_vreg_set_global_enable(vreg, 0); - if (rc) - goto bail; - } else { - /* Pin control LPM/HPM */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - LDO_ENABLE | LDO_CTRL_PM_LPM, - LDO_ENABLE_MASK | LDO_CTRL_PM_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - } - } else { - /* Pin control off */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, - REGULATOR_BANK_SEL(5) | REGULATOR_BANK_WRITE, - LDO_TEST_PIN_CTRL_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[5]); - if (rc) - goto bail; - - rc = pm8058_vreg_write(vreg, vreg->test_addr, - REGULATOR_BANK_SEL(6) | REGULATOR_BANK_WRITE, - LDO_TEST_PIN_CTRL_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[6]); - if (rc) - goto bail; - } - break; - - case REGULATOR_TYPE_SMPS: - if (on) { - if (pf == PM8058_VREG_PIN_FN_ENABLE) { - /* Pin control ON/OFF */ - if (pc & PM8058_VREG_PIN_CTRL_D0) - val |= SMPS_PIN_CTRL_D0; - if (pc & PM8058_VREG_PIN_CTRL_D1) - val |= SMPS_PIN_CTRL_D1; - if (pc & PM8058_VREG_PIN_CTRL_A0) - val |= SMPS_PIN_CTRL_A0; - if (pc & PM8058_VREG_PIN_CTRL_A1) - val |= SMPS_PIN_CTRL_A1; - } else { - /* Pin control LPM/HPM */ - if (pc & PM8058_VREG_PIN_CTRL_D0) - val |= SMPS_PIN_CTRL_LPM_D0; - if (pc & PM8058_VREG_PIN_CTRL_D1) - val |= SMPS_PIN_CTRL_LPM_D1; - if (pc & PM8058_VREG_PIN_CTRL_A0) - val |= SMPS_PIN_CTRL_LPM_A0; - if (pc & PM8058_VREG_PIN_CTRL_A1) - val |= SMPS_PIN_CTRL_LPM_A1; - } - rc = pm8058_vreg_set_global_enable(vreg, 0); - if (rc) - goto bail; - - rc = pm8058_smps_set_voltage_legacy(vreg, - vreg->save_uV); - if (rc) - goto bail; - - rc = pm8058_vreg_write(vreg, vreg->sleep_ctrl_addr, val, - SMPS_PIN_CTRL_MASK | SMPS_PIN_CTRL_LPM_MASK, - &vreg->sleep_ctrl_reg); - if (rc) - goto bail; - - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - (pf == PM8058_VREG_PIN_FN_ENABLE - ? 0 : SMPS_LEGACY_ENABLE), - SMPS_LEGACY_ENABLE, &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8058_vreg_write(vreg, vreg->clk_ctrl_addr, - (pf == PM8058_VREG_PIN_FN_ENABLE - ? SMPS_CLK_CTRL_PWM : SMPS_CLK_CTRL_PFM), - SMPS_CLK_CTRL_MASK, &vreg->clk_ctrl_reg); - if (rc) - goto bail; - } else { - /* Pin control off */ - if (!SMPS_IN_ADVANCED_MODE(vreg)) { - if (_pm8058_vreg_is_enabled(vreg)) - val = SMPS_LEGACY_ENABLE; - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - val, SMPS_LEGACY_ENABLE, - &vreg->ctrl_reg); - if (rc) - goto bail; - } - - rc = pm8058_vreg_write(vreg, vreg->sleep_ctrl_addr, 0, - SMPS_PIN_CTRL_MASK | SMPS_PIN_CTRL_LPM_MASK, - &vreg->sleep_ctrl_reg); - if (rc) - goto bail; - - rc = pm8058_smps_set_voltage_advanced(vreg, - vreg->save_uV, 0); - if (rc) - goto bail; - } - break; - - case REGULATOR_TYPE_LVS: - if (on) { - if (pc & PM8058_VREG_PIN_CTRL_D0) - val |= LVS_PIN_CTRL_EN0; - if (pc & PM8058_VREG_PIN_CTRL_D1) - val |= LVS_PIN_CTRL_EN1; - if (pc & PM8058_VREG_PIN_CTRL_A0) - val |= LVS_PIN_CTRL_EN2; - if (pc & PM8058_VREG_PIN_CTRL_A1) - val |= LVS_PIN_CTRL_EN3; - - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, val, - LVS_PIN_CTRL_MASK | LVS_ENABLE_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8058_vreg_set_global_enable(vreg, 0); - if (rc) - goto bail; - } else { - /* Pin control off */ - if (_pm8058_vreg_is_enabled(vreg)) - val = LVS_ENABLE; - - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, val, - LVS_ENABLE_MASK | LVS_PIN_CTRL_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - - } - break; - } - -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_vreg_enable(struct regulator_dev *dev) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - int mode; - int rc = 0; - - mode = pm8058_vreg_get_mode(dev); - - if (mode == REGULATOR_MODE_IDLE) { - /* Turn on pin control. */ - rc = pm8058_vreg_set_pin_ctrl(vreg, 1); - if (rc) - goto bail; - return rc; - } - if (vreg->type == REGULATOR_TYPE_SMPS && SMPS_IN_ADVANCED_MODE(vreg)) - rc = pm8058_smps_set_voltage_advanced(vreg, vreg->save_uV, 1); - else - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, REGULATOR_EN_MASK, - REGULATOR_EN_MASK, &vreg->ctrl_reg); -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int _pm8058_vreg_is_enabled(struct pm8058_vreg *vreg) -{ - /* - * All regulator types except advanced mode SMPS have enable bit in - * bit 7 of the control register. Global enable and pin control also - * do not work for advanced mode SMPS. - */ - if (!(vreg->type == REGULATOR_TYPE_SMPS && SMPS_IN_ADVANCED_MODE(vreg)) - && ((vreg->ctrl_reg & REGULATOR_EN_MASK) - || pm8058_vreg_is_global_enabled(vreg) - || pm8058_vreg_using_pin_ctrl(vreg))) - return 1; - else if (vreg->type == REGULATOR_TYPE_SMPS - && SMPS_IN_ADVANCED_MODE(vreg) - && ((vreg->ctrl_reg & SMPS_ADVANCED_BAND_MASK) - != SMPS_ADVANCED_BAND_OFF)) - return 1; - - return 0; -} - -static int pm8058_vreg_is_enabled(struct regulator_dev *dev) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - - return _pm8058_vreg_is_enabled(vreg); -} - -static int pm8058_vreg_disable(struct regulator_dev *dev) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - int rc = 0; - - /* Disable in global control register. */ - rc = pm8058_vreg_set_global_enable(vreg, 0); - if (rc) - goto bail; - - /* Turn off pin control. */ - rc = pm8058_vreg_set_pin_ctrl(vreg, 0); - if (rc) - goto bail; - - /* Disable in local control register. */ - if (vreg->type == REGULATOR_TYPE_SMPS && SMPS_IN_ADVANCED_MODE(vreg)) - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - SMPS_ADVANCED_BAND_OFF, SMPS_ADVANCED_BAND_MASK, - &vreg->ctrl_reg); - else - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, 0, - REGULATOR_EN_MASK, &vreg->ctrl_reg); - -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_pldo_set_voltage(struct pm8058_vreg *vreg, int uV) -{ - int vmin, rc = 0; - unsigned vprog, fine_step; - u8 range_ext, range_sel, fine_step_reg; - - if (uV < PLDO_LOW_UV_MIN || uV > PLDO_HIGH_UV_MAX) - return -EINVAL; - - if (uV < PLDO_LOW_UV_MAX + PLDO_LOW_FINE_STEP_UV) { - vmin = PLDO_LOW_UV_MIN; - fine_step = PLDO_LOW_FINE_STEP_UV; - range_ext = 0; - range_sel = LDO_TEST_RANGE_SEL_MASK; - } else if (uV < PLDO_NORM_UV_MAX + PLDO_NORM_FINE_STEP_UV) { - vmin = PLDO_NORM_UV_MIN; - fine_step = PLDO_NORM_FINE_STEP_UV; - range_ext = 0; - range_sel = 0; - } else { - vmin = PLDO_HIGH_UV_MIN; - fine_step = PLDO_HIGH_FINE_STEP_UV; - range_ext = LDO_TEST_RANGE_EXT_MASK; - range_sel = 0; - } - - vprog = (uV - vmin) / fine_step; - fine_step_reg = (vprog & 1) << LDO_TEST_FINE_STEP_SHIFT; - vprog >>= 1; - - /* - * Disable program voltage update if range extension, range select, - * or fine step have changed and the regulator is enabled. - */ - if (_pm8058_vreg_is_enabled(vreg) && - (((range_ext ^ vreg->test_reg[4]) & LDO_TEST_RANGE_EXT_MASK) - || ((range_sel ^ vreg->test_reg[2]) & LDO_TEST_RANGE_SEL_MASK) - || ((fine_step_reg ^ vreg->test_reg[2]) - & LDO_TEST_FINE_STEP_MASK))) { - rc = pm8058_vreg_write(vreg, vreg->test_addr, - REGULATOR_BANK_SEL(2) | REGULATOR_BANK_WRITE, - REGULATOR_BANK_MASK | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); - if (rc) - goto bail; - } - - /* Write new voltage. */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, vprog, - LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Write range extension. */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, - range_ext | REGULATOR_BANK_SEL(4) - | REGULATOR_BANK_WRITE, - LDO_TEST_RANGE_EXT_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[4]); - if (rc) - goto bail; - - /* Write fine step, range select and program voltage update. */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, - fine_step_reg | range_sel | REGULATOR_BANK_SEL(2) - | REGULATOR_BANK_WRITE | LDO_TEST_VPROG_UPDATE_MASK, - LDO_TEST_FINE_STEP_MASK | LDO_TEST_RANGE_SEL_MASK - | REGULATOR_BANK_MASK | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_nldo_set_voltage(struct pm8058_vreg *vreg, int uV) -{ - unsigned vprog, fine_step_reg; - int rc; - - if (uV < NLDO_UV_MIN || uV > NLDO_UV_MAX) - return -EINVAL; - - vprog = (uV - NLDO_UV_MIN) / NLDO_FINE_STEP_UV; - fine_step_reg = (vprog & 1) << LDO_TEST_FINE_STEP_SHIFT; - vprog >>= 1; - - /* Write new voltage. */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, vprog, - LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Write fine step. */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, - fine_step_reg | REGULATOR_BANK_SEL(2) - | REGULATOR_BANK_WRITE | LDO_TEST_VPROG_UPDATE_MASK, - LDO_TEST_FINE_STEP_MASK | REGULATOR_BANK_MASK - | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_ldo_set_voltage(struct regulator_dev *dev, - int min_uV, int max_uV, unsigned *selector) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - - if (vreg->is_nmos) - return pm8058_nldo_set_voltage(vreg, min_uV); - else - return pm8058_pldo_set_voltage(vreg, min_uV); -} - -static int pm8058_pldo_get_voltage(struct pm8058_vreg *vreg) -{ - int vmin, fine_step; - u8 range_ext, range_sel, vprog, fine_step_reg; - - fine_step_reg = vreg->test_reg[2] & LDO_TEST_FINE_STEP_MASK; - range_sel = vreg->test_reg[2] & LDO_TEST_RANGE_SEL_MASK; - range_ext = vreg->test_reg[4] & LDO_TEST_RANGE_EXT_MASK; - vprog = vreg->ctrl_reg & LDO_CTRL_VPROG_MASK; - - vprog = (vprog << 1) | (fine_step_reg >> LDO_TEST_FINE_STEP_SHIFT); - - if (range_sel) { - /* low range mode */ - fine_step = PLDO_LOW_FINE_STEP_UV; - vmin = PLDO_LOW_UV_MIN; - } else if (!range_ext) { - /* normal mode */ - fine_step = PLDO_NORM_FINE_STEP_UV; - vmin = PLDO_NORM_UV_MIN; - } else { - /* high range mode */ - fine_step = PLDO_HIGH_FINE_STEP_UV; - vmin = PLDO_HIGH_UV_MIN; - } - - return fine_step * vprog + vmin; -} - -static int pm8058_nldo_get_voltage(struct pm8058_vreg *vreg) -{ - u8 vprog, fine_step_reg; - - fine_step_reg = vreg->test_reg[2] & LDO_TEST_FINE_STEP_MASK; - vprog = vreg->ctrl_reg & LDO_CTRL_VPROG_MASK; - - vprog = (vprog << 1) | (fine_step_reg >> LDO_TEST_FINE_STEP_SHIFT); - - return NLDO_FINE_STEP_UV * vprog + NLDO_UV_MIN; -} - -static int pm8058_ldo_get_voltage(struct regulator_dev *dev) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - - if (vreg->is_nmos) - return pm8058_nldo_get_voltage(vreg); - else - return pm8058_pldo_get_voltage(vreg); -} - -static int pm8058_smps_get_voltage_advanced(struct pm8058_vreg *vreg) -{ - u8 vprog, band; - int uV = 0; - - vprog = vreg->ctrl_reg & SMPS_ADVANCED_VPROG_MASK; - band = vreg->ctrl_reg & SMPS_ADVANCED_BAND_MASK; - - if (band == SMPS_ADVANCED_BAND_1) - uV = vprog * SMPS_BAND1_UV_STEP + SMPS_BAND1_UV_MIN; - else if (band == SMPS_ADVANCED_BAND_2) - uV = vprog * SMPS_BAND2_UV_STEP + SMPS_BAND2_UV_MIN; - else if (band == SMPS_ADVANCED_BAND_3) - uV = vprog * SMPS_BAND3_UV_STEP + SMPS_BAND3_UV_MIN; - else - uV = vreg->save_uV; - - return uV; -} - -static int pm8058_smps_get_voltage_legacy(struct pm8058_vreg *vreg) -{ - u8 vlow, vref, vprog; - int uV; - - vlow = vreg->test_reg[1] & SMPS_LEGACY_VLOW_SEL_MASK; - vref = vreg->ctrl_reg & SMPS_LEGACY_VREF_SEL_MASK; - vprog = vreg->ctrl_reg & SMPS_LEGACY_VPROG_MASK; - - if (vlow && vref) { - /* mode 3 */ - uV = vprog * SMPS_MODE3_UV_STEP + SMPS_MODE3_UV_MIN; - } else if (vref) { - /* mode 2 */ - uV = vprog * SMPS_MODE2_UV_STEP + SMPS_MODE2_UV_MIN; - } else { - /* mode 1 */ - uV = vprog * SMPS_MODE1_UV_STEP + SMPS_MODE1_UV_MIN; - } - - return uV; -} - -static int _pm8058_smps_get_voltage(struct pm8058_vreg *vreg) -{ - if (SMPS_IN_ADVANCED_MODE(vreg)) - return pm8058_smps_get_voltage_advanced(vreg); - - return pm8058_smps_get_voltage_legacy(vreg); -} - -static int pm8058_smps_get_voltage(struct regulator_dev *dev) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - - return _pm8058_smps_get_voltage(vreg); -} - -static int pm8058_smps_set_voltage_advanced(struct pm8058_vreg *vreg, - int uV, int force_on) -{ - u8 vprog, band; - int rc, new_uV; - - if (uV < SMPS_BAND1_UV_MAX + SMPS_BAND1_UV_STEP) { - vprog = ((uV - SMPS_BAND1_UV_MIN) / SMPS_BAND1_UV_STEP); - band = SMPS_ADVANCED_BAND_1; - new_uV = SMPS_BAND1_UV_MIN + vprog * SMPS_BAND1_UV_STEP; - } else if (uV < SMPS_BAND2_UV_MAX + SMPS_BAND2_UV_STEP) { - vprog = ((uV - SMPS_BAND2_UV_MIN) / SMPS_BAND2_UV_STEP); - band = SMPS_ADVANCED_BAND_2; - new_uV = SMPS_BAND2_UV_MIN + vprog * SMPS_BAND2_UV_STEP; - } else { - vprog = ((uV - SMPS_BAND3_UV_MIN) / SMPS_BAND3_UV_STEP); - band = SMPS_ADVANCED_BAND_3; - new_uV = SMPS_BAND3_UV_MIN + vprog * SMPS_BAND3_UV_STEP; - } - - /* Do not set band if regulator currently disabled. */ - if (!_pm8058_vreg_is_enabled(vreg) && !force_on) - band = SMPS_ADVANCED_BAND_OFF; - - /* Set advanced mode bit to 1. */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, SMPS_ADVANCED_MODE - | REGULATOR_BANK_WRITE | REGULATOR_BANK_SEL(7), - SMPS_ADVANCED_MODE_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[7]); - if (rc) - goto bail; - - /* Set voltage and voltage band. */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, band | vprog, - SMPS_ADVANCED_BAND_MASK | SMPS_ADVANCED_VPROG_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - - vreg->save_uV = new_uV; - -bail: - return rc; -} - -static int pm8058_smps_set_voltage_legacy(struct pm8058_vreg *vreg, int uV) -{ - u8 vlow, vref, vprog, pd, en; - int rc; - - if (uV < SMPS_MODE3_UV_MAX + SMPS_MODE3_UV_STEP) { - vprog = ((uV - SMPS_MODE3_UV_MIN) / SMPS_MODE3_UV_STEP); - vref = SMPS_LEGACY_VREF_SEL_MASK; - vlow = SMPS_LEGACY_VLOW_SEL_MASK; - } else if (uV < SMPS_MODE2_UV_MAX + SMPS_MODE2_UV_STEP) { - vprog = ((uV - SMPS_MODE2_UV_MIN) / SMPS_MODE2_UV_STEP); - vref = SMPS_LEGACY_VREF_SEL_MASK; - vlow = 0; - } else { - vprog = ((uV - SMPS_MODE1_UV_MIN) / SMPS_MODE1_UV_STEP); - vref = 0; - vlow = 0; - } - - /* set vlow bit for ultra low voltage mode */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, - vlow | REGULATOR_BANK_WRITE | REGULATOR_BANK_SEL(1), - REGULATOR_BANK_MASK | SMPS_LEGACY_VLOW_SEL_MASK, - &vreg->test_reg[1]); - if (rc) - goto bail; - - /* Set advanced mode bit to 0. */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, SMPS_LEGACY_MODE - | REGULATOR_BANK_WRITE | REGULATOR_BANK_SEL(7), - SMPS_ADVANCED_MODE_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[7]); - if (rc) - goto bail; - - en = (_pm8058_vreg_is_enabled(vreg) ? SMPS_LEGACY_ENABLE : 0); - pd = (vreg->pdata->pull_down_enable ? SMPS_LEGACY_PULL_DOWN_ENABLE : 0); - - /* Set voltage (and the rest of the control register). */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, en | pd | vref | vprog, - SMPS_LEGACY_ENABLE | SMPS_LEGACY_PULL_DOWN_ENABLE - | SMPS_LEGACY_VREF_SEL_MASK | SMPS_LEGACY_VPROG_MASK, - &vreg->ctrl_reg); - - vreg->save_uV = pm8058_smps_get_voltage_legacy(vreg); - -bail: - return rc; -} - -static int pm8058_smps_set_voltage(struct regulator_dev *dev, - int min_uV, int max_uV, unsigned *selector) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - int rc = 0; - - if (min_uV < SMPS_UV_MIN || min_uV > SMPS_UV_MAX) - return -EINVAL; - - if (SMPS_IN_ADVANCED_MODE(vreg)) - rc = pm8058_smps_set_voltage_advanced(vreg, min_uV, 0); - else - rc = pm8058_smps_set_voltage_legacy(vreg, min_uV); - - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_ncp_set_voltage(struct regulator_dev *dev, - int min_uV, int max_uV, unsigned *selector) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - int rc; - u8 val; - - if (min_uV < NCP_UV_MIN || min_uV > NCP_UV_MAX) - return -EINVAL; - - val = (min_uV - NCP_UV_MIN) / NCP_UV_STEP; - - /* voltage setting */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, val, NCP_VPROG_MASK, - &vreg->ctrl_reg); - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_ncp_get_voltage(struct regulator_dev *dev) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - u8 vprog = vreg->ctrl_reg & NCP_VPROG_MASK; - return NCP_UV_MIN + vprog * NCP_UV_STEP; -} - -static int pm8058_ldo_set_mode(struct pm8058_vreg *vreg, unsigned int mode) -{ - int rc = 0; - u8 mask, val; - - switch (mode) { - case REGULATOR_MODE_FAST: - /* HPM */ - val = (_pm8058_vreg_is_enabled(vreg) ? LDO_ENABLE : 0) - | LDO_CTRL_PM_HPM; - mask = LDO_ENABLE_MASK | LDO_CTRL_PM_MASK; - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, val, mask, - &vreg->ctrl_reg); - if (rc) - goto bail; - - if (pm8058_vreg_using_pin_ctrl(vreg)) - rc = pm8058_vreg_set_pin_ctrl(vreg, 0); - if (rc) - goto bail; - break; - - case REGULATOR_MODE_STANDBY: - /* LPM */ - val = (_pm8058_vreg_is_enabled(vreg) ? LDO_ENABLE : 0) - | LDO_CTRL_PM_LPM; - mask = LDO_ENABLE_MASK | LDO_CTRL_PM_MASK; - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, val, mask, - &vreg->ctrl_reg); - if (rc) - goto bail; - - val = LDO_TEST_LPM_SEL_CTRL | REGULATOR_BANK_WRITE - | REGULATOR_BANK_SEL(0); - mask = LDO_TEST_LPM_MASK | REGULATOR_BANK_MASK; - rc = pm8058_vreg_write(vreg, vreg->test_addr, val, mask, - &vreg->test_reg[0]); - if (rc) - goto bail; - - if (pm8058_vreg_using_pin_ctrl(vreg)) - rc = pm8058_vreg_set_pin_ctrl(vreg, 0); - if (rc) - goto bail; - break; - - case REGULATOR_MODE_IDLE: - /* Pin Control */ - if (_pm8058_vreg_is_enabled(vreg)) - rc = pm8058_vreg_set_pin_ctrl(vreg, 1); - if (rc) - goto bail; - break; - - default: - pr_err("%s: invalid mode: %u\n", __func__, mode); - return -EINVAL; - } - -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_smps_set_mode(struct pm8058_vreg *vreg, unsigned int mode) -{ - int rc = 0; - u8 mask, val; - - switch (mode) { - case REGULATOR_MODE_FAST: - /* HPM */ - val = SMPS_CLK_CTRL_PWM; - mask = SMPS_CLK_CTRL_MASK; - rc = pm8058_vreg_write(vreg, vreg->clk_ctrl_addr, val, mask, - &vreg->clk_ctrl_reg); - if (rc) - goto bail; - - if (pm8058_vreg_using_pin_ctrl(vreg)) - rc = pm8058_vreg_set_pin_ctrl(vreg, 0); - if (rc) - goto bail; - break; - - case REGULATOR_MODE_STANDBY: - /* LPM */ - val = SMPS_CLK_CTRL_PFM; - mask = SMPS_CLK_CTRL_MASK; - rc = pm8058_vreg_write(vreg, vreg->clk_ctrl_addr, val, mask, - &vreg->clk_ctrl_reg); - if (rc) - goto bail; - - if (pm8058_vreg_using_pin_ctrl(vreg)) - rc = pm8058_vreg_set_pin_ctrl(vreg, 0); - if (rc) - goto bail; - break; - - case REGULATOR_MODE_IDLE: - /* Pin Control */ - if (_pm8058_vreg_is_enabled(vreg)) - rc = pm8058_vreg_set_pin_ctrl(vreg, 1); - if (rc) - goto bail; - break; - - default: - pr_err("%s: invalid mode: %u\n", __func__, mode); - return -EINVAL; - } - -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8058_lvs_set_mode(struct pm8058_vreg *vreg, unsigned int mode) -{ - int rc = 0; - - if (mode == REGULATOR_MODE_IDLE) { - /* Use pin control. */ - if (_pm8058_vreg_is_enabled(vreg)) - rc = pm8058_vreg_set_pin_ctrl(vreg, 1); - } else { - /* Turn off pin control. */ - rc = pm8058_vreg_set_pin_ctrl(vreg, 0); - } - - return rc; -} - -/* - * Optimum mode programming: - * REGULATOR_MODE_FAST: Go to HPM (highest priority) - * REGULATOR_MODE_STANDBY: Go to pin ctrl mode if there are any pin ctrl - * votes, else go to LPM - * - * Pin ctrl mode voting via regulator set_mode: - * REGULATOR_MODE_IDLE: Go to pin ctrl mode if the optimum mode is LPM, else - * go to HPM - * REGULATOR_MODE_NORMAL: Go to LPM if it is the optimum mode, else go to HPM - */ -static int pm8058_vreg_set_mode(struct regulator_dev *dev, unsigned int mode) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - unsigned prev_optimum = vreg->optimum; - unsigned prev_pc_vote = vreg->pc_vote; - unsigned prev_mode_initialized = vreg->mode_initialized; - int new_mode = REGULATOR_MODE_FAST; - int rc = 0; - - /* Determine new mode to go into. */ - switch (mode) { - case REGULATOR_MODE_FAST: - new_mode = REGULATOR_MODE_FAST; - vreg->optimum = mode; - vreg->mode_initialized = 1; - break; - - case REGULATOR_MODE_STANDBY: - if (vreg->pc_vote) - new_mode = REGULATOR_MODE_IDLE; - else - new_mode = REGULATOR_MODE_STANDBY; - vreg->optimum = mode; - vreg->mode_initialized = 1; - break; - - case REGULATOR_MODE_IDLE: - if (vreg->pc_vote++) - goto done; /* already taken care of */ - - if (vreg->mode_initialized - && vreg->optimum == REGULATOR_MODE_FAST) - new_mode = REGULATOR_MODE_FAST; - else - new_mode = REGULATOR_MODE_IDLE; - break; - - case REGULATOR_MODE_NORMAL: - if (vreg->pc_vote && --(vreg->pc_vote)) - goto done; /* already taken care of */ - - if (vreg->optimum == REGULATOR_MODE_STANDBY) - new_mode = REGULATOR_MODE_STANDBY; - else - new_mode = REGULATOR_MODE_FAST; - break; - - default: - pr_err("%s: unknown mode, mode=%u\n", __func__, mode); - return -EINVAL; - } - - switch (vreg->type) { - case REGULATOR_TYPE_LDO: - rc = pm8058_ldo_set_mode(vreg, new_mode); - break; - case REGULATOR_TYPE_SMPS: - rc = pm8058_smps_set_mode(vreg, new_mode); - break; - case REGULATOR_TYPE_LVS: - rc = pm8058_lvs_set_mode(vreg, new_mode); - break; - } - - if (rc) { - print_write_error(vreg, rc, __func__); - vreg->mode_initialized = prev_mode_initialized; - vreg->optimum = prev_optimum; - vreg->pc_vote = prev_pc_vote; - return rc; - } - -done: - return 0; -} - -static unsigned int pm8058_vreg_get_mode(struct regulator_dev *dev) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - - if (!vreg->mode_initialized && vreg->pc_vote) - return REGULATOR_MODE_IDLE; - - /* Check physical pin control state. */ - switch (vreg->type) { - case REGULATOR_TYPE_LDO: - if (!(vreg->ctrl_reg & LDO_ENABLE_MASK) - && !pm8058_vreg_is_global_enabled(vreg) - && (vreg->test_reg[5] & LDO_TEST_PIN_CTRL_MASK)) - return REGULATOR_MODE_IDLE; - else if (((vreg->ctrl_reg & LDO_ENABLE_MASK) - || pm8058_vreg_is_global_enabled(vreg)) - && (vreg->ctrl_reg & LDO_CTRL_PM_MASK) - && (vreg->test_reg[6] & LDO_TEST_PIN_CTRL_LPM_MASK)) - return REGULATOR_MODE_IDLE; - break; - case REGULATOR_TYPE_SMPS: - if (!SMPS_IN_ADVANCED_MODE(vreg) - && !(vreg->ctrl_reg & REGULATOR_EN_MASK) - && !pm8058_vreg_is_global_enabled(vreg) - && (vreg->sleep_ctrl_reg & SMPS_PIN_CTRL_MASK)) - return REGULATOR_MODE_IDLE; - else if (!SMPS_IN_ADVANCED_MODE(vreg) - && ((vreg->ctrl_reg & REGULATOR_EN_MASK) - || pm8058_vreg_is_global_enabled(vreg)) - && ((vreg->clk_ctrl_reg & SMPS_CLK_CTRL_MASK) - == SMPS_CLK_CTRL_PFM) - && (vreg->sleep_ctrl_reg & SMPS_PIN_CTRL_LPM_MASK)) - return REGULATOR_MODE_IDLE; - break; - case REGULATOR_TYPE_LVS: - if (!(vreg->ctrl_reg & LVS_ENABLE_MASK) - && !pm8058_vreg_is_global_enabled(vreg) - && (vreg->ctrl_reg & LVS_PIN_CTRL_MASK)) - return REGULATOR_MODE_IDLE; - } - - if (vreg->optimum == REGULATOR_MODE_FAST) - return REGULATOR_MODE_FAST; - else if (vreg->pc_vote) - return REGULATOR_MODE_IDLE; - else if (vreg->optimum == REGULATOR_MODE_STANDBY) - return REGULATOR_MODE_STANDBY; - return REGULATOR_MODE_FAST; -} - -unsigned int pm8058_vreg_get_optimum_mode(struct regulator_dev *dev, - int input_uV, int output_uV, int load_uA) -{ - struct pm8058_vreg *vreg = rdev_get_drvdata(dev); - - if (load_uA <= 0) { - /* - * pm8058_vreg_get_optimum_mode is being called before consumers - * have specified their load currents via - * regulator_set_optimum_mode. Return whatever the existing mode - * is. - */ - return pm8058_vreg_get_mode(dev); - } - - if (load_uA >= vreg->hpm_min_load) - return REGULATOR_MODE_FAST; - return REGULATOR_MODE_STANDBY; -} - -static struct regulator_ops pm8058_ldo_ops = { - .enable = pm8058_vreg_enable, - .disable = pm8058_vreg_disable, - .is_enabled = pm8058_vreg_is_enabled, - .set_voltage = pm8058_ldo_set_voltage, - .get_voltage = pm8058_ldo_get_voltage, - .set_mode = pm8058_vreg_set_mode, - .get_mode = pm8058_vreg_get_mode, - .get_optimum_mode = pm8058_vreg_get_optimum_mode, -}; - -static struct regulator_ops pm8058_smps_ops = { - .enable = pm8058_vreg_enable, - .disable = pm8058_vreg_disable, - .is_enabled = pm8058_vreg_is_enabled, - .set_voltage = pm8058_smps_set_voltage, - .get_voltage = pm8058_smps_get_voltage, - .set_mode = pm8058_vreg_set_mode, - .get_mode = pm8058_vreg_get_mode, - .get_optimum_mode = pm8058_vreg_get_optimum_mode, -}; - -static struct regulator_ops pm8058_lvs_ops = { - .enable = pm8058_vreg_enable, - .disable = pm8058_vreg_disable, - .is_enabled = pm8058_vreg_is_enabled, - .set_mode = pm8058_vreg_set_mode, - .get_mode = pm8058_vreg_get_mode, -}; - -static struct regulator_ops pm8058_ncp_ops = { - .enable = pm8058_vreg_enable, - .disable = pm8058_vreg_disable, - .is_enabled = pm8058_vreg_is_enabled, - .set_voltage = pm8058_ncp_set_voltage, - .get_voltage = pm8058_ncp_get_voltage, -}; - -#define VREG_DESCRIP(_id, _name, _ops) \ - [_id] = { \ - .id = _id, \ - .name = _name, \ - .ops = _ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - } - -static struct regulator_desc pm8058_vreg_descrip[] = { - VREG_DESCRIP(PM8058_VREG_ID_L0, "8058_l0", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L1, "8058_l1", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L2, "8058_l2", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L3, "8058_l3", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L4, "8058_l4", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L5, "8058_l5", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L6, "8058_l6", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L7, "8058_l7", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L8, "8058_l8", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L9, "8058_l9", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L10, "8058_l10", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L11, "8058_l11", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L12, "8058_l12", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L13, "8058_l13", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L14, "8058_l14", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L15, "8058_l15", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L16, "8058_l16", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L17, "8058_l17", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L18, "8058_l18", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L19, "8058_l19", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L20, "8058_l20", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L21, "8058_l21", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L22, "8058_l22", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L23, "8058_l23", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L24, "8058_l24", &pm8058_ldo_ops), - VREG_DESCRIP(PM8058_VREG_ID_L25, "8058_l25", &pm8058_ldo_ops), - - VREG_DESCRIP(PM8058_VREG_ID_S0, "8058_s0", &pm8058_smps_ops), - VREG_DESCRIP(PM8058_VREG_ID_S1, "8058_s1", &pm8058_smps_ops), - VREG_DESCRIP(PM8058_VREG_ID_S2, "8058_s2", &pm8058_smps_ops), - VREG_DESCRIP(PM8058_VREG_ID_S3, "8058_s3", &pm8058_smps_ops), - VREG_DESCRIP(PM8058_VREG_ID_S4, "8058_s4", &pm8058_smps_ops), - - VREG_DESCRIP(PM8058_VREG_ID_LVS0, "8058_lvs0", &pm8058_lvs_ops), - VREG_DESCRIP(PM8058_VREG_ID_LVS1, "8058_lvs1", &pm8058_lvs_ops), - - VREG_DESCRIP(PM8058_VREG_ID_NCP, "8058_ncp", &pm8058_ncp_ops), -}; - -static int pm8058_master_enable_init(struct pm8058_vreg *vreg) -{ - int rc = 0, i; - - for (i = 0; i < MASTER_ENABLE_COUNT; i++) { - rc = pm8xxx_readb(vreg->dev->parent, m_en[i].addr, - &(m_en[i].reg)); - if (rc) - goto bail; - } - -bail: - if (rc) - pr_err("%s: pm8xxx_read failed, rc=%d\n", __func__, rc); - - return rc; -} - -static int pm8058_init_ldo(struct pm8058_vreg *vreg) -{ - int rc = 0, i; - u8 bank; - - /* Save the current test register state. */ - for (i = 0; i < LDO_TEST_BANKS; i++) { - bank = REGULATOR_BANK_SEL(i); - rc = pm8xxx_writeb(vreg->dev->parent, vreg->test_addr, bank); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[i]); - if (rc) - goto bail; - vreg->test_reg[i] |= REGULATOR_BANK_WRITE; - } - - if ((vreg->ctrl_reg & LDO_CTRL_PM_MASK) == LDO_CTRL_PM_LPM) - vreg->optimum = REGULATOR_MODE_STANDBY; - else - vreg->optimum = REGULATOR_MODE_FAST; - - /* Set pull down enable based on platform data. */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - (vreg->pdata->pull_down_enable ? LDO_PULL_DOWN_ENABLE : 0), - LDO_PULL_DOWN_ENABLE_MASK, &vreg->ctrl_reg); -bail: - return rc; -} - -static int pm8058_init_smps(struct pm8058_vreg *vreg) -{ - int rc = 0, i; - u8 bank; - - /* Save the current test2 register state. */ - for (i = 0; i < SMPS_TEST_BANKS; i++) { - bank = REGULATOR_BANK_SEL(i); - rc = pm8xxx_writeb(vreg->dev->parent, vreg->test_addr, bank); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[i]); - if (rc) - goto bail; - vreg->test_reg[i] |= REGULATOR_BANK_WRITE; - } - - /* Save the current clock control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->clk_ctrl_addr, - &vreg->clk_ctrl_reg); - if (rc) - goto bail; - - /* Save the current sleep control register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->sleep_ctrl_addr, - &vreg->sleep_ctrl_reg); - if (rc) - goto bail; - - vreg->save_uV = 1; /* This is not a no-op. */ - vreg->save_uV = _pm8058_smps_get_voltage(vreg); - - if ((vreg->clk_ctrl_reg & SMPS_CLK_CTRL_MASK) == SMPS_CLK_CTRL_PFM) - vreg->optimum = REGULATOR_MODE_STANDBY; - else - vreg->optimum = REGULATOR_MODE_FAST; - - /* Set advanced mode pull down enable based on platform data. */ - rc = pm8058_vreg_write(vreg, vreg->test_addr, - (vreg->pdata->pull_down_enable - ? SMPS_ADVANCED_PULL_DOWN_ENABLE : 0) - | REGULATOR_BANK_SEL(6) | REGULATOR_BANK_WRITE, - REGULATOR_BANK_MASK | SMPS_ADVANCED_PULL_DOWN_ENABLE, - &vreg->test_reg[6]); - if (rc) - goto bail; - - if (!SMPS_IN_ADVANCED_MODE(vreg)) { - /* Set legacy mode pull down enable based on platform data. */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - (vreg->pdata->pull_down_enable - ? SMPS_LEGACY_PULL_DOWN_ENABLE : 0), - SMPS_LEGACY_PULL_DOWN_ENABLE, &vreg->ctrl_reg); - if (rc) - goto bail; - } - -bail: - return rc; -} - -static int pm8058_init_lvs(struct pm8058_vreg *vreg) -{ - int rc = 0; - - vreg->optimum = REGULATOR_MODE_FAST; - - /* Set pull down enable based on platform data. */ - rc = pm8058_vreg_write(vreg, vreg->ctrl_addr, - (vreg->pdata->pull_down_enable - ? LVS_PULL_DOWN_ENABLE : LVS_PULL_DOWN_DISABLE), - LVS_PULL_DOWN_ENABLE_MASK, &vreg->ctrl_reg); - return rc; -} - -static int pm8058_init_ncp(struct pm8058_vreg *vreg) -{ - int rc = 0; - - /* Save the current test1 register state. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[0]); - if (rc) - goto bail; - - vreg->optimum = REGULATOR_MODE_FAST; - -bail: - return rc; -} - -static int pm8058_init_regulator(struct pm8058_vreg *vreg) -{ - static int master_enable_inited; - int rc = 0; - - vreg->mode_initialized = 0; - - if (!master_enable_inited) { - rc = pm8058_master_enable_init(vreg); - if (!rc) - master_enable_inited = 1; - } - - /* save the current control register state */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) - goto bail; - - switch (vreg->type) { - case REGULATOR_TYPE_LDO: - rc = pm8058_init_ldo(vreg); - break; - case REGULATOR_TYPE_SMPS: - rc = pm8058_init_smps(vreg); - break; - case REGULATOR_TYPE_LVS: - rc = pm8058_init_lvs(vreg); - break; - case REGULATOR_TYPE_NCP: - rc = pm8058_init_ncp(vreg); - break; - } - -bail: - if (rc) - pr_err("%s: pm8058_read/write failed; initial register states " - "unknown, rc=%d\n", __func__, rc); - return rc; -} - -static int pm8058_vreg_probe(struct platform_device *pdev) -{ - struct regulator_desc *rdesc; - struct pm8058_vreg *vreg; - const char *reg_name = NULL; - int rc = 0; - - if (pdev == NULL) - return -EINVAL; - - if (pdev->id >= 0 && pdev->id < PM8058_VREG_MAX) { - rdesc = &pm8058_vreg_descrip[pdev->id]; - vreg = &pm8058_vreg[pdev->id]; - vreg->pdata = pdev->dev.platform_data; - reg_name = pm8058_vreg_descrip[pdev->id].name; - vreg->dev = &pdev->dev; - - rc = pm8058_init_regulator(vreg); - if (rc) - goto bail; - - /* Disallow idle and normal modes if pin control isn't set. */ - if (vreg->pdata->pin_ctrl == 0) - vreg->pdata->init_data.constraints.valid_modes_mask - &= ~(REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE); - - vreg->rdev = regulator_register(rdesc, &pdev->dev, - &vreg->pdata->init_data, vreg, NULL); - if (IS_ERR(vreg->rdev)) { - rc = PTR_ERR(vreg->rdev); - pr_err("%s: regulator_register failed for %s, rc=%d\n", - __func__, reg_name, rc); - } - } else { - rc = -ENODEV; - } - -bail: - if (rc) - pr_err("%s: error for %s, rc=%d\n", __func__, reg_name, rc); - - return rc; -} - -static int pm8058_vreg_remove(struct platform_device *pdev) -{ - regulator_unregister(pm8058_vreg[pdev->id].rdev); - return 0; -} - -static struct platform_driver pm8058_vreg_driver = { - .probe = pm8058_vreg_probe, - .remove = pm8058_vreg_remove, - .driver = { - .name = "pm8058-regulator", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8058_vreg_init(void) -{ - return platform_driver_register(&pm8058_vreg_driver); -} - -static void __exit pm8058_vreg_exit(void) -{ - platform_driver_unregister(&pm8058_vreg_driver); -} - -static void print_write_error(struct pm8058_vreg *vreg, int rc, - const char *func) -{ - const char *reg_name = NULL; - ptrdiff_t id = vreg - pm8058_vreg; - - if (id >= 0 && id < PM8058_VREG_MAX) - reg_name = pm8058_vreg_descrip[id].name; - pr_err("%s: pm8058_vreg_write failed for %s, rc=%d\n", - func, reg_name, rc); -} - -subsys_initcall(pm8058_vreg_init); -module_exit(pm8058_vreg_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8058 regulator driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pm8058-regulator"); diff --git a/drivers/regulator/pmic8901-regulator.c b/drivers/regulator/pmic8901-regulator.c deleted file mode 100644 index c52a34bb31568ed028333af647aa465ab7b2c192..0000000000000000000000000000000000000000 --- a/drivers/regulator/pmic8901-regulator.c +++ /dev/null @@ -1,1018 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -/* Regulator types */ -#define REGULATOR_TYPE_LDO 0 -#define REGULATOR_TYPE_SMPS 1 -#define REGULATOR_TYPE_VS 2 - -/* Bank select/write macros */ -#define REGULATOR_BANK_SEL(n) ((n) << 4) -#define REGULATOR_BANK_WRITE 0x80 -#define LDO_TEST_BANKS 7 -#define REGULATOR_BANK_MASK 0xF0 - -/* Pin mask resource register programming */ -#define VREG_PMR_STATE_MASK 0x60 -#define VREG_PMR_STATE_HPM 0x60 -#define VREG_PMR_STATE_LPM 0x40 -#define VREG_PMR_STATE_OFF 0x20 -#define VREG_PMR_STATE_PIN_CTRL 0x20 - -#define VREG_PMR_MODE_ACTION_MASK 0x10 -#define VREG_PMR_MODE_ACTION_SLEEP 0x10 -#define VREG_PMR_MODE_ACTION_OFF 0x00 - -#define VREG_PMR_MODE_PIN_MASK 0x08 -#define VREG_PMR_MODE_PIN_MASKED 0x08 - -#define VREG_PMR_CTRL_PIN2_MASK 0x04 -#define VREG_PMR_CTRL_PIN2_MASKED 0x04 - -#define VREG_PMR_CTRL_PIN1_MASK 0x02 -#define VREG_PMR_CTRL_PIN1_MASKED 0x02 - -#define VREG_PMR_CTRL_PIN0_MASK 0x01 -#define VREG_PMR_CTRL_PIN0_MASKED 0x01 - -#define VREG_PMR_PIN_CTRL_ALL_MASK 0x1F -#define VREG_PMR_PIN_CTRL_ALL_MASKED 0x1F - -#define REGULATOR_IS_EN(pmr_reg) \ - ((pmr_reg & VREG_PMR_STATE_MASK) == VREG_PMR_STATE_HPM || \ - (pmr_reg & VREG_PMR_STATE_MASK) == VREG_PMR_STATE_LPM) - -/* FTSMPS programming */ - -/* CTRL register */ -#define SMPS_VCTRL_BAND_MASK 0xC0 -#define SMPS_VCTRL_BAND_OFF 0x00 -#define SMPS_VCTRL_BAND_1 0x40 -#define SMPS_VCTRL_BAND_2 0x80 -#define SMPS_VCTRL_BAND_3 0xC0 -#define SMPS_VCTRL_VPROG_MASK 0x3F - -#define SMPS_BAND_1_UV_MIN 350000 -#define SMPS_BAND_1_UV_MAX 650000 -#define SMPS_BAND_1_UV_STEP 6250 - -#define SMPS_BAND_2_UV_MIN 700000 -#define SMPS_BAND_2_UV_MAX 1400000 -#define SMPS_BAND_2_UV_STEP 12500 - -#define SMPS_BAND_3_UV_SETPOINT_MIN 1500000 -#define SMPS_BAND_3_UV_MIN 1400000 -#define SMPS_BAND_3_UV_MAX 3300000 -#define SMPS_BAND_3_UV_STEP 50000 - -#define SMPS_UV_MIN SMPS_BAND_1_UV_MIN -#define SMPS_UV_MAX SMPS_BAND_3_UV_MAX - -/* PWR_CNFG register */ -#define SMPS_PULL_DOWN_ENABLE_MASK 0x40 -#define SMPS_PULL_DOWN_ENABLE 0x40 - -/* LDO programming */ - -/* CTRL register */ -#define LDO_LOCAL_ENABLE_MASK 0x80 -#define LDO_LOCAL_ENABLE 0x80 - -#define LDO_PULL_DOWN_ENABLE_MASK 0x40 -#define LDO_PULL_DOWN_ENABLE 0x40 - -#define LDO_CTRL_VPROG_MASK 0x1F - -/* TEST register bank 2 */ -#define LDO_TEST_VPROG_UPDATE_MASK 0x08 -#define LDO_TEST_RANGE_SEL_MASK 0x04 -#define LDO_TEST_FINE_STEP_MASK 0x02 -#define LDO_TEST_FINE_STEP_SHIFT 1 - -/* TEST register bank 4 */ -#define LDO_TEST_RANGE_EXT_MASK 0x01 - -/* Allowable voltage ranges */ -#define PLDO_LOW_UV_MIN 750000 -#define PLDO_LOW_UV_MAX 1537500 -#define PLDO_LOW_FINE_STEP_UV 12500 - -#define PLDO_NORM_UV_MIN 1500000 -#define PLDO_NORM_UV_MAX 3075000 -#define PLDO_NORM_FINE_STEP_UV 25000 - -#define PLDO_HIGH_UV_MIN 1750000 -#define PLDO_HIGH_UV_MAX 4900000 -#define PLDO_HIGH_FINE_STEP_UV 50000 - -#define NLDO_UV_MIN 750000 -#define NLDO_UV_MAX 1537500 -#define NLDO_FINE_STEP_UV 12500 - -/* VS programming */ - -/* CTRL register */ -#define VS_CTRL_ENABLE_MASK 0xC0 -#define VS_CTRL_DISABLE 0x00 -#define VS_CTRL_ENABLE 0x40 -#define VS_CTRL_USE_PMR 0xC0 - -#define VS_PULL_DOWN_ENABLE_MASK 0x20 -#define VS_PULL_DOWN_ENABLE 0x20 - -struct pm8901_vreg { - struct device *dev; - struct pm8901_vreg_pdata *pdata; - struct regulator_dev *rdev; - int hpm_min_load; - unsigned pc_vote; - unsigned optimum; - unsigned mode_initialized; - u16 ctrl_addr; - u16 pmr_addr; - u16 test_addr; - u16 pfm_ctrl_addr; - u16 pwr_cnfg_addr; - u8 type; - u8 ctrl_reg; - u8 pmr_reg; - u8 test_reg[LDO_TEST_BANKS]; - u8 pfm_ctrl_reg; - u8 pwr_cnfg_reg; - u8 is_nmos; - u8 state; -}; - -/* - * These are used to compensate for the PMIC 8901 v1 FTS regulators which - * output ~10% higher than the programmed set point. - */ -#define IS_PMIC_8901_V1(rev) ((rev) == PM8XXX_REVISION_8901_1p0 || \ - (rev) == PM8XXX_REVISION_8901_1p1) - -#define PMIC_8901_V1_SCALE(uV) ((((uV) - 62100) * 23) / 25) - -#define PMIC_8901_V1_SCALE_INV(uV) (((uV) * 25) / 23 + 62100) - -/* - * Band 1 of PMIC 8901 SMPS regulators only supports set points with the 3 LSB's - * equal to 0. This is accomplished in the macro by truncating the bits. - */ -#define PM8901_SMPS_BAND_1_COMPENSATE(vprog) ((vprog) & 0xF8) - -#define LDO(_id, _ctrl_addr, _pmr_addr, _test_addr, _is_nmos) \ - [_id] = { \ - .ctrl_addr = _ctrl_addr, \ - .pmr_addr = _pmr_addr, \ - .test_addr = _test_addr, \ - .type = REGULATOR_TYPE_LDO, \ - .is_nmos = _is_nmos, \ - .hpm_min_load = PM8901_VREG_LDO_300_HPM_MIN_LOAD, \ - } - -#define SMPS(_id, _ctrl_addr, _pmr_addr, _pfm_ctrl_addr, _pwr_cnfg_addr) \ - [_id] = { \ - .ctrl_addr = _ctrl_addr, \ - .pmr_addr = _pmr_addr, \ - .pfm_ctrl_addr = _pfm_ctrl_addr, \ - .pwr_cnfg_addr = _pwr_cnfg_addr, \ - .type = REGULATOR_TYPE_SMPS, \ - .hpm_min_load = PM8901_VREG_FTSMPS_HPM_MIN_LOAD, \ - } - -#define VS(_id, _ctrl_addr, _pmr_addr) \ - [_id] = { \ - .ctrl_addr = _ctrl_addr, \ - .pmr_addr = _pmr_addr, \ - .type = REGULATOR_TYPE_VS, \ - } - -static struct pm8901_vreg pm8901_vreg[] = { - /* id ctrl pmr tst n/p */ - LDO(PM8901_VREG_ID_L0, 0x02F, 0x0AB, 0x030, 1), - LDO(PM8901_VREG_ID_L1, 0x031, 0x0AC, 0x032, 0), - LDO(PM8901_VREG_ID_L2, 0x033, 0x0AD, 0x034, 0), - LDO(PM8901_VREG_ID_L3, 0x035, 0x0AE, 0x036, 0), - LDO(PM8901_VREG_ID_L4, 0x037, 0x0AF, 0x038, 0), - LDO(PM8901_VREG_ID_L5, 0x039, 0x0B0, 0x03A, 0), - LDO(PM8901_VREG_ID_L6, 0x03B, 0x0B1, 0x03C, 0), - - /* id ctrl pmr pfm pwr */ - SMPS(PM8901_VREG_ID_S0, 0x05B, 0x0A6, 0x05C, 0x0E3), - SMPS(PM8901_VREG_ID_S1, 0x06A, 0x0A7, 0x06B, 0x0EC), - SMPS(PM8901_VREG_ID_S2, 0x079, 0x0A8, 0x07A, 0x0F1), - SMPS(PM8901_VREG_ID_S3, 0x088, 0x0A9, 0x089, 0x0F6), - SMPS(PM8901_VREG_ID_S4, 0x097, 0x0AA, 0x098, 0x0FB), - - /* id ctrl pmr */ - VS(PM8901_VREG_ID_LVS0, 0x046, 0x0B2), - VS(PM8901_VREG_ID_LVS1, 0x048, 0x0B3), - VS(PM8901_VREG_ID_LVS2, 0x04A, 0x0B4), - VS(PM8901_VREG_ID_LVS3, 0x04C, 0x0B5), - VS(PM8901_VREG_ID_MVS0, 0x052, 0x0B6), - VS(PM8901_VREG_ID_USB_OTG, 0x055, 0x0B7), - VS(PM8901_VREG_ID_HDMI_MVS, 0x058, 0x0B8), -}; - -static void print_write_error(struct pm8901_vreg *vreg, int rc, - const char *func); - -static int pm8901_vreg_write(struct pm8901_vreg *vreg, - u16 addr, u8 val, u8 mask, u8 *reg_save) -{ - int rc = 0; - u8 reg; - - reg = (*reg_save & ~mask) | (val & mask); - if (reg != *reg_save) - rc = pm8xxx_writeb(vreg->dev->parent, addr, reg); - if (!rc) - *reg_save = reg; - return rc; -} - -/* Set pin control bits based on new mode. */ -static int pm8901_vreg_select_pin_ctrl(struct pm8901_vreg *vreg, u8 *pmr_reg) -{ - *pmr_reg |= VREG_PMR_PIN_CTRL_ALL_MASKED; - - if ((*pmr_reg & VREG_PMR_STATE_MASK) == VREG_PMR_STATE_PIN_CTRL) { - if (vreg->pdata->pin_fn == PM8901_VREG_PIN_FN_MODE) - *pmr_reg = (*pmr_reg & ~VREG_PMR_STATE_MASK) - | VREG_PMR_STATE_LPM; - if (vreg->pdata->pin_ctrl & PM8901_VREG_PIN_CTRL_A0) - *pmr_reg &= ~VREG_PMR_CTRL_PIN0_MASKED; - if (vreg->pdata->pin_ctrl & PM8901_VREG_PIN_CTRL_A1) - *pmr_reg &= ~VREG_PMR_CTRL_PIN1_MASKED; - if (vreg->pdata->pin_ctrl & PM8901_VREG_PIN_CTRL_D0) - *pmr_reg &= ~VREG_PMR_CTRL_PIN2_MASKED; - } - - return 0; -} - -static int pm8901_vreg_enable(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - u8 val = VREG_PMR_STATE_HPM; - int rc; - - if (!vreg->mode_initialized && vreg->pc_vote) - val = VREG_PMR_STATE_PIN_CTRL; - else if (vreg->optimum == REGULATOR_MODE_FAST) - val = VREG_PMR_STATE_HPM; - else if (vreg->pc_vote) - val = VREG_PMR_STATE_PIN_CTRL; - else if (vreg->optimum == REGULATOR_MODE_STANDBY) - val = VREG_PMR_STATE_LPM; - - pm8901_vreg_select_pin_ctrl(vreg, &val); - - rc = pm8901_vreg_write(vreg, vreg->pmr_addr, - val, - VREG_PMR_STATE_MASK | VREG_PMR_PIN_CTRL_ALL_MASK, - &vreg->pmr_reg); - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8901_vreg_disable(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - int rc; - - rc = pm8901_vreg_write(vreg, vreg->pmr_addr, - VREG_PMR_STATE_OFF | VREG_PMR_PIN_CTRL_ALL_MASKED, - VREG_PMR_STATE_MASK | VREG_PMR_PIN_CTRL_ALL_MASK, - &vreg->pmr_reg); - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -/* - * Cases that count as enabled: - * - * 1. PMR register has mode == HPM or LPM. - * 2. Any pin control bits are unmasked. - * 3. The regulator is an LDO and its local enable bit is set. - */ -static int _pm8901_vreg_is_enabled(struct pm8901_vreg *vreg) -{ - if ((vreg->type == REGULATOR_TYPE_LDO) - && (vreg->ctrl_reg & LDO_LOCAL_ENABLE_MASK)) - return 1; - else if (vreg->type == REGULATOR_TYPE_VS) { - if ((vreg->ctrl_reg & VS_CTRL_ENABLE_MASK) == VS_CTRL_ENABLE) - return 1; - else if ((vreg->ctrl_reg & VS_CTRL_ENABLE_MASK) - == VS_CTRL_DISABLE) - return 0; - } - - return REGULATOR_IS_EN(vreg->pmr_reg) - || ((vreg->pmr_reg & VREG_PMR_PIN_CTRL_ALL_MASK) - != VREG_PMR_PIN_CTRL_ALL_MASKED); -} - -static int pm8901_vreg_is_enabled(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - - return _pm8901_vreg_is_enabled(vreg); -} - -static int pm8901_ldo_disable(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - int rc; - - /* Disassert local enable bit in CTRL register. */ - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, 0, LDO_LOCAL_ENABLE_MASK, - &vreg->ctrl_reg); - if (rc) - print_write_error(vreg, rc, __func__); - - /* Disassert enable bit in PMR register. */ - rc = pm8901_vreg_disable(dev); - - return rc; -} - -static int pm8901_pldo_set_voltage(struct pm8901_vreg *vreg, int uV) -{ - int vmin, rc = 0; - unsigned vprog, fine_step; - u8 range_ext, range_sel, fine_step_reg; - - if (uV < PLDO_LOW_UV_MIN || uV > PLDO_HIGH_UV_MAX) - return -EINVAL; - - if (uV < PLDO_LOW_UV_MAX + PLDO_LOW_FINE_STEP_UV) { - vmin = PLDO_LOW_UV_MIN; - fine_step = PLDO_LOW_FINE_STEP_UV; - range_ext = 0; - range_sel = LDO_TEST_RANGE_SEL_MASK; - } else if (uV < PLDO_NORM_UV_MAX + PLDO_NORM_FINE_STEP_UV) { - vmin = PLDO_NORM_UV_MIN; - fine_step = PLDO_NORM_FINE_STEP_UV; - range_ext = 0; - range_sel = 0; - } else { - vmin = PLDO_HIGH_UV_MIN; - fine_step = PLDO_HIGH_FINE_STEP_UV; - range_ext = LDO_TEST_RANGE_EXT_MASK; - range_sel = 0; - } - - vprog = (uV - vmin) / fine_step; - fine_step_reg = (vprog & 1) << LDO_TEST_FINE_STEP_SHIFT; - vprog >>= 1; - - /* - * Disable program voltage update if range extension, range select, - * or fine step have changed and the regulator is enabled. - */ - if (_pm8901_vreg_is_enabled(vreg) && - (((range_ext ^ vreg->test_reg[4]) & LDO_TEST_RANGE_EXT_MASK) - || ((range_sel ^ vreg->test_reg[2]) & LDO_TEST_RANGE_SEL_MASK) - || ((fine_step_reg ^ vreg->test_reg[2]) - & LDO_TEST_FINE_STEP_MASK))) { - rc = pm8901_vreg_write(vreg, vreg->test_addr, - REGULATOR_BANK_SEL(2) | REGULATOR_BANK_WRITE, - REGULATOR_BANK_MASK | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); - if (rc) - goto bail; - } - - /* Write new voltage. */ - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, vprog, - LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - if (rc) - goto bail; - - /* Write range extension. */ - rc = pm8901_vreg_write(vreg, vreg->test_addr, - range_ext | REGULATOR_BANK_SEL(4) - | REGULATOR_BANK_WRITE, - LDO_TEST_RANGE_EXT_MASK | REGULATOR_BANK_MASK, - &vreg->test_reg[4]); - if (rc) - goto bail; - - /* Write fine step, range select and program voltage update. */ - rc = pm8901_vreg_write(vreg, vreg->test_addr, - fine_step_reg | range_sel | REGULATOR_BANK_SEL(2) - | REGULATOR_BANK_WRITE | LDO_TEST_VPROG_UPDATE_MASK, - LDO_TEST_FINE_STEP_MASK | LDO_TEST_RANGE_SEL_MASK - | REGULATOR_BANK_MASK | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8901_nldo_set_voltage(struct pm8901_vreg *vreg, int uV) -{ - unsigned vprog, fine_step_reg; - int rc; - - if (uV < NLDO_UV_MIN || uV > NLDO_UV_MAX) - return -EINVAL; - - vprog = (uV - NLDO_UV_MIN) / NLDO_FINE_STEP_UV; - fine_step_reg = (vprog & 1) << LDO_TEST_FINE_STEP_SHIFT; - vprog >>= 1; - - /* Write new voltage. */ - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, vprog, - LDO_CTRL_VPROG_MASK, &vreg->ctrl_reg); - if (rc) - print_write_error(vreg, rc, __func__); - - /* Write fine step. */ - rc = pm8901_vreg_write(vreg, vreg->test_addr, - fine_step_reg | REGULATOR_BANK_SEL(2) - | REGULATOR_BANK_WRITE | LDO_TEST_VPROG_UPDATE_MASK, - LDO_TEST_FINE_STEP_MASK | REGULATOR_BANK_MASK - | LDO_TEST_VPROG_UPDATE_MASK, - &vreg->test_reg[2]); - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8901_ldo_set_voltage(struct regulator_dev *dev, - int min_uV, int max_uV, unsigned *selector) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - - if (vreg->is_nmos) - return pm8901_nldo_set_voltage(vreg, min_uV); - else - return pm8901_pldo_set_voltage(vreg, min_uV); -} - -static int pm8901_pldo_get_voltage(struct pm8901_vreg *vreg) -{ - int vmin, fine_step; - u8 range_ext, range_sel, vprog, fine_step_reg; - - fine_step_reg = vreg->test_reg[2] & LDO_TEST_FINE_STEP_MASK; - range_sel = vreg->test_reg[2] & LDO_TEST_RANGE_SEL_MASK; - range_ext = vreg->test_reg[4] & LDO_TEST_RANGE_EXT_MASK; - vprog = vreg->ctrl_reg & LDO_CTRL_VPROG_MASK; - - vprog = (vprog << 1) | (fine_step_reg >> LDO_TEST_FINE_STEP_SHIFT); - - if (range_sel) { - /* low range mode */ - fine_step = PLDO_LOW_FINE_STEP_UV; - vmin = PLDO_LOW_UV_MIN; - } else if (!range_ext) { - /* normal mode */ - fine_step = PLDO_NORM_FINE_STEP_UV; - vmin = PLDO_NORM_UV_MIN; - } else { - /* high range mode */ - fine_step = PLDO_HIGH_FINE_STEP_UV; - vmin = PLDO_HIGH_UV_MIN; - } - - return fine_step * vprog + vmin; -} - -static int pm8901_nldo_get_voltage(struct pm8901_vreg *vreg) -{ - u8 vprog, fine_step_reg; - - fine_step_reg = vreg->test_reg[2] & LDO_TEST_FINE_STEP_MASK; - vprog = vreg->ctrl_reg & LDO_CTRL_VPROG_MASK; - - vprog = (vprog << 1) | (fine_step_reg >> LDO_TEST_FINE_STEP_SHIFT); - - return NLDO_FINE_STEP_UV * vprog + NLDO_UV_MIN; -} - -static int pm8901_ldo_get_voltage(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - - if (vreg->is_nmos) - return pm8901_nldo_get_voltage(vreg); - else - return pm8901_pldo_get_voltage(vreg); -} - -/* - * Optimum mode programming: - * REGULATOR_MODE_FAST: Go to HPM (highest priority) - * REGULATOR_MODE_STANDBY: Go to pin ctrl mode if there are any pin ctrl - * votes, else go to LPM - * - * Pin ctrl mode voting via regulator set_mode: - * REGULATOR_MODE_IDLE: Go to pin ctrl mode if the optimum mode is LPM, else - * go to HPM - * REGULATOR_MODE_NORMAL: Go to LPM if it is the optimum mode, else go to HPM - */ -static int pm8901_vreg_set_mode(struct regulator_dev *dev, unsigned int mode) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - unsigned optimum = vreg->optimum; - unsigned pc_vote = vreg->pc_vote; - unsigned mode_initialized = vreg->mode_initialized; - u8 val = 0; - int rc = 0; - - /* Determine new mode to go into. */ - switch (mode) { - case REGULATOR_MODE_FAST: - val = VREG_PMR_STATE_HPM; - optimum = mode; - mode_initialized = 1; - break; - - case REGULATOR_MODE_STANDBY: - if (pc_vote) - val = VREG_PMR_STATE_PIN_CTRL; - else - val = VREG_PMR_STATE_LPM; - optimum = mode; - mode_initialized = 1; - break; - - case REGULATOR_MODE_IDLE: - if (pc_vote++) - goto done; /* already taken care of */ - - if (mode_initialized && optimum == REGULATOR_MODE_FAST) - val = VREG_PMR_STATE_HPM; - else - val = VREG_PMR_STATE_PIN_CTRL; - break; - - case REGULATOR_MODE_NORMAL: - if (pc_vote && --pc_vote) - goto done; /* already taken care of */ - - if (optimum == REGULATOR_MODE_STANDBY) - val = VREG_PMR_STATE_LPM; - else - val = VREG_PMR_STATE_HPM; - break; - - default: - pr_err("%s: unknown mode, mode=%u\n", __func__, mode); - return -EINVAL; - } - - /* Set pin control bits based on new mode. */ - pm8901_vreg_select_pin_ctrl(vreg, &val); - - /* Only apply mode setting to hardware if currently enabled. */ - if (pm8901_vreg_is_enabled(dev)) - rc = pm8901_vreg_write(vreg, vreg->pmr_addr, val, - VREG_PMR_STATE_MASK | VREG_PMR_PIN_CTRL_ALL_MASK, - &vreg->pmr_reg); - - if (rc) { - print_write_error(vreg, rc, __func__); - return rc; - } - -done: - vreg->mode_initialized = mode_initialized; - vreg->optimum = optimum; - vreg->pc_vote = pc_vote; - - return 0; -} - -static unsigned int pm8901_vreg_get_mode(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - int pin_mask = VREG_PMR_CTRL_PIN0_MASK | VREG_PMR_CTRL_PIN1_MASK - | VREG_PMR_CTRL_PIN2_MASK; - - if (!vreg->mode_initialized && vreg->pc_vote) - return REGULATOR_MODE_IDLE; - else if (((vreg->pmr_reg & VREG_PMR_STATE_MASK) == VREG_PMR_STATE_OFF) - && ((vreg->pmr_reg & pin_mask) != pin_mask)) - return REGULATOR_MODE_IDLE; - else if (((vreg->pmr_reg & VREG_PMR_STATE_MASK) == VREG_PMR_STATE_LPM) - && ((vreg->pmr_reg & pin_mask) != pin_mask)) - return REGULATOR_MODE_IDLE; - else if (vreg->optimum == REGULATOR_MODE_FAST) - return REGULATOR_MODE_FAST; - else if (vreg->pc_vote) - return REGULATOR_MODE_IDLE; - else if (vreg->optimum == REGULATOR_MODE_STANDBY) - return REGULATOR_MODE_STANDBY; - return REGULATOR_MODE_FAST; -} - -unsigned int pm8901_vreg_get_optimum_mode(struct regulator_dev *dev, - int input_uV, int output_uV, int load_uA) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - - if (load_uA <= 0) { - /* - * pm8901_vreg_get_optimum_mode is being called before consumers - * have specified their load currents via - * regulator_set_optimum_mode. Return whatever the existing mode - * is. - */ - return pm8901_vreg_get_mode(dev); - } - - if (load_uA >= vreg->hpm_min_load) - return REGULATOR_MODE_FAST; - return REGULATOR_MODE_STANDBY; -} - -static int pm8901_smps_set_voltage(struct regulator_dev *dev, - int min_uV, int max_uV, unsigned *selector) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - int rc; - u8 val, band; - - if (IS_PMIC_8901_V1(pm8xxx_get_revision(vreg->dev->parent))) - min_uV = PMIC_8901_V1_SCALE(min_uV); - - if (min_uV < SMPS_BAND_1_UV_MIN || min_uV > SMPS_BAND_3_UV_MAX) - return -EINVAL; - - /* Round down for set points in the gaps between bands. */ - if (min_uV > SMPS_BAND_1_UV_MAX && min_uV < SMPS_BAND_2_UV_MIN) - min_uV = SMPS_BAND_1_UV_MAX; - else if (min_uV > SMPS_BAND_2_UV_MAX - && min_uV < SMPS_BAND_3_UV_SETPOINT_MIN) - min_uV = SMPS_BAND_2_UV_MAX; - - if (min_uV < SMPS_BAND_2_UV_MIN) { - val = ((min_uV - SMPS_BAND_1_UV_MIN) / SMPS_BAND_1_UV_STEP); - val = PM8901_SMPS_BAND_1_COMPENSATE(val); - band = SMPS_VCTRL_BAND_1; - } else if (min_uV < SMPS_BAND_3_UV_SETPOINT_MIN) { - val = ((min_uV - SMPS_BAND_2_UV_MIN) / SMPS_BAND_2_UV_STEP); - band = SMPS_VCTRL_BAND_2; - } else { - val = ((min_uV - SMPS_BAND_3_UV_MIN) / SMPS_BAND_3_UV_STEP); - band = SMPS_VCTRL_BAND_3; - } - - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, band | val, - SMPS_VCTRL_BAND_MASK | SMPS_VCTRL_VPROG_MASK, - &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8901_vreg_write(vreg, vreg->pfm_ctrl_addr, band | val, - SMPS_VCTRL_BAND_MASK | SMPS_VCTRL_VPROG_MASK, - &vreg->pfm_ctrl_reg); -bail: - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8901_smps_get_voltage(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - u8 vprog, band; - int ret = 0; - - if ((vreg->pmr_reg & VREG_PMR_STATE_MASK) == VREG_PMR_STATE_LPM) { - vprog = vreg->pfm_ctrl_reg & SMPS_VCTRL_VPROG_MASK; - band = vreg->pfm_ctrl_reg & SMPS_VCTRL_BAND_MASK; - } else { - vprog = vreg->ctrl_reg & SMPS_VCTRL_VPROG_MASK; - band = vreg->ctrl_reg & SMPS_VCTRL_BAND_MASK; - } - - if (band == SMPS_VCTRL_BAND_1) - ret = vprog * SMPS_BAND_1_UV_STEP + SMPS_BAND_1_UV_MIN; - else if (band == SMPS_VCTRL_BAND_2) - ret = vprog * SMPS_BAND_2_UV_STEP + SMPS_BAND_2_UV_MIN; - else - ret = vprog * SMPS_BAND_3_UV_STEP + SMPS_BAND_3_UV_MIN; - - if (IS_PMIC_8901_V1(pm8xxx_get_revision(vreg->dev->parent))) - ret = PMIC_8901_V1_SCALE_INV(ret); - - return ret; -} - -static int pm8901_vs_enable(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - int rc; - - /* Assert enable bit in PMR register. */ - rc = pm8901_vreg_enable(dev); - - /* Make sure that switch is controlled via PMR register */ - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, VS_CTRL_USE_PMR, - VS_CTRL_ENABLE_MASK, &vreg->ctrl_reg); - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static int pm8901_vs_disable(struct regulator_dev *dev) -{ - struct pm8901_vreg *vreg = rdev_get_drvdata(dev); - int rc; - - /* Disassert enable bit in PMR register. */ - rc = pm8901_vreg_disable(dev); - - /* Make sure that switch is controlled via PMR register */ - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, VS_CTRL_USE_PMR, - VS_CTRL_ENABLE_MASK, &vreg->ctrl_reg); - if (rc) - print_write_error(vreg, rc, __func__); - - return rc; -} - -static struct regulator_ops pm8901_ldo_ops = { - .enable = pm8901_vreg_enable, - .disable = pm8901_ldo_disable, - .is_enabled = pm8901_vreg_is_enabled, - .set_voltage = pm8901_ldo_set_voltage, - .get_voltage = pm8901_ldo_get_voltage, - .set_mode = pm8901_vreg_set_mode, - .get_mode = pm8901_vreg_get_mode, - .get_optimum_mode = pm8901_vreg_get_optimum_mode, -}; - -static struct regulator_ops pm8901_smps_ops = { - .enable = pm8901_vreg_enable, - .disable = pm8901_vreg_disable, - .is_enabled = pm8901_vreg_is_enabled, - .set_voltage = pm8901_smps_set_voltage, - .get_voltage = pm8901_smps_get_voltage, - .set_mode = pm8901_vreg_set_mode, - .get_mode = pm8901_vreg_get_mode, - .get_optimum_mode = pm8901_vreg_get_optimum_mode, -}; - -static struct regulator_ops pm8901_vs_ops = { - .enable = pm8901_vs_enable, - .disable = pm8901_vs_disable, - .is_enabled = pm8901_vreg_is_enabled, - .set_mode = pm8901_vreg_set_mode, - .get_mode = pm8901_vreg_get_mode, -}; - -#define VREG_DESCRIP(_id, _name, _ops) \ - [_id] = { \ - .name = _name, \ - .id = _id, \ - .ops = _ops, \ - .type = REGULATOR_VOLTAGE, \ - .owner = THIS_MODULE, \ - } - -static struct regulator_desc pm8901_vreg_descrip[] = { - VREG_DESCRIP(PM8901_VREG_ID_L0, "8901_l0", &pm8901_ldo_ops), - VREG_DESCRIP(PM8901_VREG_ID_L1, "8901_l1", &pm8901_ldo_ops), - VREG_DESCRIP(PM8901_VREG_ID_L2, "8901_l2", &pm8901_ldo_ops), - VREG_DESCRIP(PM8901_VREG_ID_L3, "8901_l3", &pm8901_ldo_ops), - VREG_DESCRIP(PM8901_VREG_ID_L4, "8901_l4", &pm8901_ldo_ops), - VREG_DESCRIP(PM8901_VREG_ID_L5, "8901_l5", &pm8901_ldo_ops), - VREG_DESCRIP(PM8901_VREG_ID_L6, "8901_l6", &pm8901_ldo_ops), - - VREG_DESCRIP(PM8901_VREG_ID_S0, "8901_s0", &pm8901_smps_ops), - VREG_DESCRIP(PM8901_VREG_ID_S1, "8901_s1", &pm8901_smps_ops), - VREG_DESCRIP(PM8901_VREG_ID_S2, "8901_s2", &pm8901_smps_ops), - VREG_DESCRIP(PM8901_VREG_ID_S3, "8901_s3", &pm8901_smps_ops), - VREG_DESCRIP(PM8901_VREG_ID_S4, "8901_s4", &pm8901_smps_ops), - - VREG_DESCRIP(PM8901_VREG_ID_LVS0, "8901_lvs0", &pm8901_vs_ops), - VREG_DESCRIP(PM8901_VREG_ID_LVS1, "8901_lvs1", &pm8901_vs_ops), - VREG_DESCRIP(PM8901_VREG_ID_LVS2, "8901_lvs2", &pm8901_vs_ops), - VREG_DESCRIP(PM8901_VREG_ID_LVS3, "8901_lvs3", &pm8901_vs_ops), - VREG_DESCRIP(PM8901_VREG_ID_MVS0, "8901_mvs0", &pm8901_vs_ops), - VREG_DESCRIP(PM8901_VREG_ID_USB_OTG, "8901_usb_otg", &pm8901_vs_ops), - VREG_DESCRIP(PM8901_VREG_ID_HDMI_MVS, "8901_hdmi_mvs", &pm8901_vs_ops), -}; - -static int pm8901_init_ldo(struct pm8901_vreg *vreg) -{ - int rc = 0, i; - u8 bank; - - /* Store current regulator register values. */ - for (i = 0; i < LDO_TEST_BANKS; i++) { - bank = REGULATOR_BANK_SEL(i); - rc = pm8xxx_writeb(vreg->dev->parent, vreg->test_addr, bank); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->test_addr, - &vreg->test_reg[i]); - if (rc) - goto bail; - - vreg->test_reg[i] |= REGULATOR_BANK_WRITE; - } - - /* Set pull down enable based on platform data. */ - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, - (vreg->pdata->pull_down_enable ? LDO_PULL_DOWN_ENABLE : 0), - LDO_PULL_DOWN_ENABLE_MASK, &vreg->ctrl_reg); -bail: - return rc; -} - -static int pm8901_init_smps(struct pm8901_vreg *vreg) -{ - int rc; - - /* Store current regulator register values. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->pfm_ctrl_addr, - &vreg->pfm_ctrl_reg); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->pwr_cnfg_addr, - &vreg->pwr_cnfg_reg); - if (rc) - goto bail; - - /* Set pull down enable based on platform data. */ - rc = pm8901_vreg_write(vreg, vreg->pwr_cnfg_addr, - (vreg->pdata->pull_down_enable ? SMPS_PULL_DOWN_ENABLE : 0), - SMPS_PULL_DOWN_ENABLE_MASK, &vreg->pwr_cnfg_reg); - -bail: - return rc; -} - -static int pm8901_init_vs(struct pm8901_vreg *vreg) -{ - int rc = 0; - - /* Set pull down enable based on platform data. */ - rc = pm8901_vreg_write(vreg, vreg->ctrl_addr, - (vreg->pdata->pull_down_enable ? VS_PULL_DOWN_ENABLE : 0), - VS_PULL_DOWN_ENABLE_MASK, &vreg->ctrl_reg); - - return rc; -} - -static int pm8901_init_regulator(struct pm8901_vreg *vreg) -{ - int rc; - - /* Store current regulator register values. */ - rc = pm8xxx_readb(vreg->dev->parent, vreg->ctrl_addr, &vreg->ctrl_reg); - if (rc) - goto bail; - - rc = pm8xxx_readb(vreg->dev->parent, vreg->pmr_addr, &vreg->pmr_reg); - if (rc) - goto bail; - - /* Set initial mode based on hardware state. */ - if ((vreg->pmr_reg & VREG_PMR_STATE_MASK) == VREG_PMR_STATE_LPM) - vreg->optimum = REGULATOR_MODE_STANDBY; - else - vreg->optimum = REGULATOR_MODE_FAST; - - vreg->mode_initialized = 0; - - if (vreg->type == REGULATOR_TYPE_LDO) - rc = pm8901_init_ldo(vreg); - else if (vreg->type == REGULATOR_TYPE_SMPS) - rc = pm8901_init_smps(vreg); - else if (vreg->type == REGULATOR_TYPE_VS) - rc = pm8901_init_vs(vreg); -bail: - if (rc) - pr_err("%s: pm8901_read/write failed; initial register states " - "unknown, rc=%d\n", __func__, rc); - - return rc; -} - -static int pm8901_vreg_probe(struct platform_device *pdev) -{ - struct regulator_desc *rdesc; - struct pm8901_vreg *vreg; - const char *reg_name = NULL; - int rc = 0; - - if (pdev == NULL) - return -EINVAL; - - if (pdev->id >= 0 && pdev->id < PM8901_VREG_MAX) { - rdesc = &pm8901_vreg_descrip[pdev->id]; - vreg = &pm8901_vreg[pdev->id]; - vreg->pdata = pdev->dev.platform_data; - reg_name = pm8901_vreg_descrip[pdev->id].name; - vreg->dev = &pdev->dev; - - rc = pm8901_init_regulator(vreg); - if (rc) - goto bail; - - /* Disallow idle and normal modes if pin control isn't set. */ - if (vreg->pdata->pin_ctrl == 0) - vreg->pdata->init_data.constraints.valid_modes_mask - &= ~(REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE); - - vreg->rdev = regulator_register(rdesc, &pdev->dev, - &vreg->pdata->init_data, vreg, NULL); - if (IS_ERR(vreg->rdev)) { - rc = PTR_ERR(vreg->rdev); - pr_err("%s: regulator_register failed for %s, rc=%d\n", - __func__, reg_name, rc); - } - } else { - rc = -ENODEV; - } - -bail: - if (rc) - pr_err("%s: error for %s, rc=%d\n", __func__, reg_name, rc); - - return rc; -} - -static int pm8901_vreg_remove(struct platform_device *pdev) -{ - regulator_unregister(pm8901_vreg[pdev->id].rdev); - return 0; -} - -static struct platform_driver pm8901_vreg_driver = { - .probe = pm8901_vreg_probe, - .remove = pm8901_vreg_remove, - .driver = { - .name = "pm8901-regulator", - .owner = THIS_MODULE, - }, -}; - -static int __init pm8901_vreg_init(void) -{ - return platform_driver_register(&pm8901_vreg_driver); -} - -static void __exit pm8901_vreg_exit(void) -{ - platform_driver_unregister(&pm8901_vreg_driver); -} - -static void print_write_error(struct pm8901_vreg *vreg, int rc, - const char *func) -{ - const char *reg_name = NULL; - ptrdiff_t id = vreg - pm8901_vreg; - - if (id >= 0 && id < PM8901_VREG_MAX) - reg_name = pm8901_vreg_descrip[id].name; - pr_err("%s: pm8901_vreg_write failed for %s, rc=%d\n", - func, reg_name, rc); -} - -subsys_initcall(pm8901_vreg_init); -module_exit(pm8901_vreg_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PMIC8901 regulator driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:pm8901-regulator"); diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index f9e03ef12026c42c9b7f5aead393c5502c5d2699..8569cdf7181262b8a82482728b3f19e5dd6e5bc8 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -843,14 +843,6 @@ config RTC_DRV_NUC900 comment "on-CPU RTC drivers" -config RTC_DRV_MSM - tristate "RTC on Qualcomm Chipsets" - depends on ARCH_MSM - default y - help - RTC driver for Qualcomm chipsets - - config RTC_SECURE_TIME_SUPPORT bool "Support for secure time on Qualcomm Chipsets" depends on RTC_DRV_MSM = y @@ -867,13 +859,6 @@ config RTC_ASYNC_MODEM_SUPPORT Say yes here to have the system time updated if there is an asynchronous MODEM boot. -config RTC_DRV_MSM7X00A - tristate "MSM7X00A" - depends on ARCH_MSM - default n - help - RTC driver for Qualcomm MSM7K chipsets - config RTC_DRV_DAVINCI tristate "TI DaVinci RTC" depends on ARCH_DAVINCI_DM365 diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 7f9a3b23832c1845d0a619133f9596032417a553..250e64d5b08d7d5697f805e4da4a8ac6c007a5cb 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -76,8 +76,6 @@ obj-$(CONFIG_RTC_DRV_MAX8997) += rtc-max8997.o obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o obj-$(CONFIG_RTC_DRV_MAX77686) += rtc-max77686.o obj-$(CONFIG_RTC_DRV_MC13XXX) += rtc-mc13xxx.o -obj-$(CONFIG_RTC_DRV_MSM) += rtc-msm.o -obj-$(CONFIG_RTC_DRV_MSM7X00A) += rtc-msm7x00a.o obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o diff --git a/drivers/rtc/rtc-msm.c b/drivers/rtc/rtc-msm.c deleted file mode 100644 index 0825ef5a9614c1dbba95526e21bb9db39b4de30b..0000000000000000000000000000000000000000 --- a/drivers/rtc/rtc-msm.c +++ /dev/null @@ -1,819 +0,0 @@ -/* - * Copyright (C) 2008 Google, Inc. - * Copyright (c) 2009-2011 The Linux Foundation. All rights reserved. - * Author: San Mehat - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define APP_TIMEREMOTE_PDEV_NAME "rs00000000" - -#define TIMEREMOTE_PROCEEDURE_SET_JULIAN 6 -#define TIMEREMOTE_PROCEEDURE_GET_JULIAN 7 -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT -#define TIMEREMOTE_PROCEEDURE_GET_SECURE_JULIAN 11 -#define TIMEREMOTE_PROCEEDURE_SET_SECURE_JULIAN 16 -#endif -#define TIMEREMOTE_PROG_NUMBER 0x30000048 -#define TIMEREMOTE_PROG_VER_1 0x00010001 -#define TIMEREMOTE_PROG_VER_2 0x00040001 - -#define RTC_REQUEST_CB_PROC 0x17 -#define RTC_CLIENT_INIT_PROC 0x12 -#define RTC_EVENT_CB_PROC 0x1 -#define RTC_CB_ID 0x1 - -/* Client request errors */ -enum rtc_rpc_err { - ERR_NONE, - ERR_CLIENT_ID_PTR, /* Invalid client ID pointer */ - ERR_CLIENT_TYPE, /* Invalid client type */ - ERR_CLIENT_ID, /* Invalid client ID */ - ERR_TASK_NOT_READY, /* task is not ready for clients */ - ERR_INVALID_PROCESSOR, /* Invalid processor id */ - ERR_UNSUPPORTED, /* Unsupported request */ - ERR_GENERAL, /* Any General Error */ - ERR_RPC, /* Any ONCRPC Error */ - ERR_ALREADY_REG, /* Client already registered */ - ERR_MAX -}; - -enum processor_type { - CLIENT_PROCESSOR_NONE = 0, - CLIENT_PROCESSOR_MODEM, - CLIENT_PROCESSOR_APP1, - CLIENT_PROCESSOR_APP2, - CLIENT_PROCESSOR_MAX -}; - -/* Client types */ -enum client_type { - CLIENT_TYPE_GEN1 = 0, - CLIENT_FLOATING1, - CLIENT_FLOATING2, - CLIENT_TYPE_INTERNAL, - CLIENT_TYPE_GENOFF_UPDATE, - CLIENT_TYPE_MAX -}; - -/* Event types */ -enum event_type { - EVENT_TOD_CHANGE = 0, - EVENT_GENOFF_CHANGE, - EVENT_MAX -}; - -struct tod_update_info { - uint32_t tick; - uint64_t stamp; - uint32_t freq; -}; - -enum time_bases_info { - TIME_RTC = 0, - TIME_TOD, - TIME_USER, - TIME_SECURE, - TIME_INVALID -}; - -struct genoff_update_info { - enum time_bases_info time_base; - uint64_t offset; -}; - -union cb_info { - struct tod_update_info tod_update; - struct genoff_update_info genoff_update; -}; - -struct rtc_cb_recv { - uint32_t client_cb_id; - enum event_type event; - uint32_t cb_info_ptr; - union cb_info cb_info_data; -}; - -struct msm_rtc { - int proc; - struct msm_rpc_client *rpc_client; - u8 client_id; - struct rtc_device *rtc; -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT - struct rtc_device *rtcsecure; -#endif - unsigned long rtcalarm_time; -}; - -struct rpc_time_julian { - uint32_t year; - uint32_t month; - uint32_t day; - uint32_t hour; - uint32_t minute; - uint32_t second; - uint32_t day_of_week; -}; - -struct rtc_tod_args { - int proc; - struct rtc_time *tm; -}; - -#ifdef CONFIG_PM -struct suspend_state_info { - atomic_t state; - int64_t tick_at_suspend; -}; - -static struct suspend_state_info suspend_state = {ATOMIC_INIT(0), 0}; - -void msmrtc_updateatsuspend(struct timespec *ts) -{ - int64_t now, sleep, sclk_max; - - if (atomic_read(&suspend_state.state)) { - now = msm_timer_get_sclk_time(&sclk_max); - - if (now && suspend_state.tick_at_suspend) { - if (now < suspend_state.tick_at_suspend) { - sleep = sclk_max - - suspend_state.tick_at_suspend + now; - } else - sleep = now - suspend_state.tick_at_suspend; - - timespec_add_ns(ts, sleep); - suspend_state.tick_at_suspend = now; - } else - pr_err("%s: Invalid ticks from SCLK now=%lld" - "tick_at_suspend=%lld", __func__, now, - suspend_state.tick_at_suspend); - } - -} -#else -void msmrtc_updateatsuspend(struct timespec *ts) { } -#endif -EXPORT_SYMBOL(msmrtc_updateatsuspend); - -static int msmrtc_tod_proc_args(struct msm_rpc_client *client, void *buff, - void *data) -{ - struct rtc_tod_args *rtc_args = data; - - if ((rtc_args->proc == TIMEREMOTE_PROCEEDURE_SET_JULIAN) -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT - || (rtc_args->proc == TIMEREMOTE_PROCEEDURE_SET_SECURE_JULIAN) -#endif - ) { - struct timeremote_set_julian_req { - uint32_t opt_arg; - struct rpc_time_julian time; - }; - struct timeremote_set_julian_req *set_req = buff; - - set_req->opt_arg = cpu_to_be32(0x1); - set_req->time.year = cpu_to_be32(rtc_args->tm->tm_year); - set_req->time.month = cpu_to_be32(rtc_args->tm->tm_mon + 1); - set_req->time.day = cpu_to_be32(rtc_args->tm->tm_mday); - set_req->time.hour = cpu_to_be32(rtc_args->tm->tm_hour); - set_req->time.minute = cpu_to_be32(rtc_args->tm->tm_min); - set_req->time.second = cpu_to_be32(rtc_args->tm->tm_sec); - set_req->time.day_of_week = cpu_to_be32(rtc_args->tm->tm_wday); - - return sizeof(*set_req); - - } else if ((rtc_args->proc == TIMEREMOTE_PROCEEDURE_GET_JULIAN) -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT - || (rtc_args->proc == TIMEREMOTE_PROCEEDURE_GET_SECURE_JULIAN) -#endif - ) { - *(uint32_t *)buff = (uint32_t) cpu_to_be32(0x1); - - return sizeof(uint32_t); - } else - return 0; -} - -static bool rtc_check_overflow(struct rtc_time *tm) -{ - if (tm->tm_year < 138) - return false; - - if (tm->tm_year > 138) - return true; - - if ((tm->tm_year == 138) && (tm->tm_mon == 0) && (tm->tm_mday < 19)) - return false; - - return true; -} - -static int msmrtc_tod_proc_result(struct msm_rpc_client *client, void *buff, - void *data) -{ - struct rtc_tod_args *rtc_args = data; - - if ((rtc_args->proc == TIMEREMOTE_PROCEEDURE_GET_JULIAN) -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT - || (rtc_args->proc == TIMEREMOTE_PROCEEDURE_GET_SECURE_JULIAN) -#endif - ) { - struct timeremote_get_julian_rep { - uint32_t opt_arg; - struct rpc_time_julian time; - }; - struct timeremote_get_julian_rep *result = buff; - - if (be32_to_cpu(result->opt_arg) != 0x1) - return -ENODATA; - - rtc_args->tm->tm_year = be32_to_cpu(result->time.year); - rtc_args->tm->tm_mon = be32_to_cpu(result->time.month); - rtc_args->tm->tm_mday = be32_to_cpu(result->time.day); - rtc_args->tm->tm_hour = be32_to_cpu(result->time.hour); - rtc_args->tm->tm_min = be32_to_cpu(result->time.minute); - rtc_args->tm->tm_sec = be32_to_cpu(result->time.second); - rtc_args->tm->tm_wday = be32_to_cpu(result->time.day_of_week); - - pr_debug("%s: %.2u/%.2u/%.4u %.2u:%.2u:%.2u (%.2u)\n", - __func__, rtc_args->tm->tm_mon, rtc_args->tm->tm_mday, - rtc_args->tm->tm_year, rtc_args->tm->tm_hour, - rtc_args->tm->tm_min, rtc_args->tm->tm_sec, - rtc_args->tm->tm_wday); - - /* RTC layer expects years to start at 1900 */ - rtc_args->tm->tm_year -= 1900; - /* RTC layer expects mons to be 0 based */ - rtc_args->tm->tm_mon--; - - if (rtc_valid_tm(rtc_args->tm) < 0) { - pr_err("%s: Retrieved data/time not valid\n", __func__); - rtc_time_to_tm(0, rtc_args->tm); - } - - /* - * Check if the time received is > 01-19-2038, to prevent - * overflow. In such a case, return the EPOCH time. - */ - if (rtc_check_overflow(rtc_args->tm) == true) { - pr_err("Invalid time (year > 2038)\n"); - rtc_time_to_tm(0, rtc_args->tm); - } - - return 0; - } else - return 0; -} - -static int -msmrtc_timeremote_set_time(struct device *dev, struct rtc_time *tm) -{ - int rc; - struct rtc_tod_args rtc_args; - struct msm_rtc *rtc_pdata = dev_get_drvdata(dev); - - if (tm->tm_year < 1900) - tm->tm_year += 1900; - - if (tm->tm_year < 1970) - return -EINVAL; - - dev_dbg(dev, "%s: %.2u/%.2u/%.4u %.2u:%.2u:%.2u (%.2u)\n", - __func__, tm->tm_mon, tm->tm_mday, tm->tm_year, - tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); - - rtc_args.proc = TIMEREMOTE_PROCEEDURE_SET_JULIAN; - rtc_args.tm = tm; - rc = msm_rpc_client_req(rtc_pdata->rpc_client, - TIMEREMOTE_PROCEEDURE_SET_JULIAN, - msmrtc_tod_proc_args, &rtc_args, - NULL, NULL, -1); - if (rc) { - dev_err(dev, "%s: rtc time (TOD) could not be set\n", __func__); - return rc; - } - - return 0; -} - -static int -msmrtc_timeremote_read_time(struct device *dev, struct rtc_time *tm) -{ - int rc; - struct rtc_tod_args rtc_args; - struct msm_rtc *rtc_pdata = dev_get_drvdata(dev); - - rtc_args.proc = TIMEREMOTE_PROCEEDURE_GET_JULIAN; - rtc_args.tm = tm; - - rc = msm_rpc_client_req(rtc_pdata->rpc_client, - TIMEREMOTE_PROCEEDURE_GET_JULIAN, - msmrtc_tod_proc_args, &rtc_args, - msmrtc_tod_proc_result, &rtc_args, -1); - - if (rc) { - dev_err(dev, "%s: Error retrieving rtc (TOD) time\n", __func__); - return rc; - } - - return 0; -} - -static int -msmrtc_virtual_alarm_set(struct device *dev, struct rtc_wkalrm *a) -{ - struct msm_rtc *rtc_pdata = dev_get_drvdata(dev); - unsigned long now = get_seconds(); - - if (!a->enabled) { - rtc_pdata->rtcalarm_time = 0; - return 0; - } else - rtc_tm_to_time(&a->time, &(rtc_pdata->rtcalarm_time)); - - if (now > rtc_pdata->rtcalarm_time) { - dev_err(dev, "%s: Attempt to set alarm in the past\n", - __func__); - rtc_pdata->rtcalarm_time = 0; - return -EINVAL; - } - - return 0; -} - -static struct rtc_class_ops msm_rtc_ops = { - .read_time = msmrtc_timeremote_read_time, - .set_time = msmrtc_timeremote_set_time, - .set_alarm = msmrtc_virtual_alarm_set, -}; - -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT -static int -msmrtc_timeremote_set_time_secure(struct device *dev, struct rtc_time *tm) -{ - int rc; - struct rtc_tod_args rtc_args; - struct msm_rtc *rtc_pdata = dev_get_drvdata(dev); - - if (tm->tm_year < 1900) - tm->tm_year += 1900; - - if (tm->tm_year < 1970) - return -EINVAL; - - dev_dbg(dev, "%s: %.2u/%.2u/%.4u %.2u:%.2u:%.2u (%.2u)\n", - __func__, tm->tm_mon, tm->tm_mday, tm->tm_year, - tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); - - rtc_args.proc = TIMEREMOTE_PROCEEDURE_SET_SECURE_JULIAN; - rtc_args.tm = tm; - - rc = msm_rpc_client_req(rtc_pdata->rpc_client, - TIMEREMOTE_PROCEEDURE_SET_SECURE_JULIAN, - msmrtc_tod_proc_args, &rtc_args, - NULL, NULL, -1); - if (rc) { - dev_err(dev, - "%s: rtc secure time could not be set\n", __func__); - return rc; - } - - return 0; -} - -static int -msmrtc_timeremote_read_time_secure(struct device *dev, struct rtc_time *tm) -{ - int rc; - struct rtc_tod_args rtc_args; - struct msm_rtc *rtc_pdata = dev_get_drvdata(dev); - rtc_args.proc = TIMEREMOTE_PROCEEDURE_GET_SECURE_JULIAN; - rtc_args.tm = tm; - - rc = msm_rpc_client_req(rtc_pdata->rpc_client, - TIMEREMOTE_PROCEEDURE_GET_SECURE_JULIAN, msmrtc_tod_proc_args, - &rtc_args, msmrtc_tod_proc_result, &rtc_args, -1); - - if (rc) { - dev_err(dev, - "%s: Error retrieving secure rtc time\n", __func__); - return rc; - } - - return 0; -} - -static struct rtc_class_ops msm_rtc_ops_secure = { - .read_time = msmrtc_timeremote_read_time_secure, - .set_time = msmrtc_timeremote_set_time_secure, -}; -#endif - -static void process_cb_request(void *buffer) -{ - struct rtc_cb_recv *rtc_cb = buffer; - struct timespec ts, tv; - - rtc_cb->client_cb_id = be32_to_cpu(rtc_cb->client_cb_id); - rtc_cb->event = be32_to_cpu(rtc_cb->event); - rtc_cb->cb_info_ptr = be32_to_cpu(rtc_cb->cb_info_ptr); - - if (rtc_cb->event == EVENT_TOD_CHANGE) { - /* A TOD update has been received from the Modem */ - rtc_cb->cb_info_data.tod_update.tick = - be32_to_cpu(rtc_cb->cb_info_data.tod_update.tick); - rtc_cb->cb_info_data.tod_update.stamp = - be64_to_cpu(rtc_cb->cb_info_data.tod_update.stamp); - rtc_cb->cb_info_data.tod_update.freq = - be32_to_cpu(rtc_cb->cb_info_data.tod_update.freq); - pr_info("RPC CALL -- TOD TIME UPDATE: ttick = %d\n" - "stamp=%lld, freq = %d\n", - rtc_cb->cb_info_data.tod_update.tick, - rtc_cb->cb_info_data.tod_update.stamp, - rtc_cb->cb_info_data.tod_update.freq); - - getnstimeofday(&ts); - msmrtc_updateatsuspend(&ts); - rtc_hctosys(); - getnstimeofday(&tv); - /* Update the alarm information with the new time info. */ - alarm_update_timedelta(ts, tv); - - } else - pr_err("%s: Unknown event EVENT=%x\n", - __func__, rtc_cb->event); -} - -static int msmrtc_cb_func(struct msm_rpc_client *client, void *buffer, int size) -{ - int rc = -1; - struct rpc_request_hdr *recv = buffer; - - recv->xid = be32_to_cpu(recv->xid); - recv->type = be32_to_cpu(recv->type); - recv->rpc_vers = be32_to_cpu(recv->rpc_vers); - recv->prog = be32_to_cpu(recv->prog); - recv->vers = be32_to_cpu(recv->vers); - recv->procedure = be32_to_cpu(recv->procedure); - - if (recv->procedure == RTC_EVENT_CB_PROC) - process_cb_request((void *) (recv + 1)); - - msm_rpc_start_accepted_reply(client, recv->xid, - RPC_ACCEPTSTAT_SUCCESS); - - rc = msm_rpc_send_accepted_reply(client, 0); - if (rc) { - pr_debug("%s: sending reply failed: %d\n", __func__, rc); - return rc; - } - - return 0; -} - -static int msmrtc_rpc_proc_args(struct msm_rpc_client *client, void *buff, - void *data) -{ - struct msm_rtc *rtc_pdata = data; - - if (rtc_pdata->proc == RTC_CLIENT_INIT_PROC) { - /* arguments passed to the client_init function */ - struct rtc_client_init_req { - enum client_type client; - uint32_t client_id_ptr; - u8 client_id; - enum processor_type processor; - }; - struct rtc_client_init_req *req_1 = buff; - - req_1->client = cpu_to_be32(CLIENT_TYPE_INTERNAL); - req_1->client_id_ptr = cpu_to_be32(0x1); - req_1->client_id = (u8) cpu_to_be32(0x1); - req_1->processor = cpu_to_be32(CLIENT_PROCESSOR_APP1); - - return sizeof(*req_1); - - } else if (rtc_pdata->proc == RTC_REQUEST_CB_PROC) { - /* arguments passed to the request_cb function */ - struct rtc_event_req { - u8 client_id; - uint32_t rtc_cb_id; - }; - struct rtc_event_req *req_2 = buff; - - req_2->client_id = (u8) cpu_to_be32(rtc_pdata->client_id); - req_2->rtc_cb_id = cpu_to_be32(RTC_CB_ID); - - return sizeof(*req_2); - } else - return 0; -} - -static int msmrtc_rpc_proc_result(struct msm_rpc_client *client, void *buff, - void *data) -{ - uint32_t result = -EINVAL; - struct msm_rtc *rtc_pdata = data; - - if (rtc_pdata->proc == RTC_CLIENT_INIT_PROC) { - /* process reply received from client_init function */ - uint32_t client_id_ptr; - result = be32_to_cpu(*(uint32_t *)buff); - buff += sizeof(uint32_t); - client_id_ptr = be32_to_cpu(*(uint32_t *)(buff)); - buff += sizeof(uint32_t); - if (client_id_ptr == 1) - rtc_pdata->client_id = (u8) - be32_to_cpu(*(uint32_t *)(buff)); - else { - pr_debug("%s: Client-id not received from Modem\n", - __func__); - return -EINVAL; - } - } else if (rtc_pdata->proc == RTC_REQUEST_CB_PROC) { - /* process reply received from request_cb function */ - result = be32_to_cpu(*(uint32_t *)buff); - } - - if (result == ERR_NONE) { - pr_debug("%s: RPC client reply for PROC=%x success\n", - __func__, rtc_pdata->proc); - return 0; - } - - pr_debug("%s: RPC client registration failed ERROR=%x\n", - __func__, result); - return -EINVAL; -} - -static int msmrtc_setup_cb(struct msm_rtc *rtc_pdata) -{ - int rc; - - /* Register with the server with client specific info */ - rtc_pdata->proc = RTC_CLIENT_INIT_PROC; - rc = msm_rpc_client_req(rtc_pdata->rpc_client, RTC_CLIENT_INIT_PROC, - msmrtc_rpc_proc_args, rtc_pdata, - msmrtc_rpc_proc_result, rtc_pdata, -1); - if (rc) { - pr_debug("%s: RPC client registration for PROC:%x failed\n", - __func__, RTC_CLIENT_INIT_PROC); - return rc; - } - - /* Register with server for the callback event */ - rtc_pdata->proc = RTC_REQUEST_CB_PROC; - rc = msm_rpc_client_req(rtc_pdata->rpc_client, RTC_REQUEST_CB_PROC, - msmrtc_rpc_proc_args, rtc_pdata, - msmrtc_rpc_proc_result, rtc_pdata, -1); - if (rc) { - pr_debug("%s: RPC client registration for PROC:%x failed\n", - __func__, RTC_REQUEST_CB_PROC); - } - - return rc; -} - -static int -msmrtc_probe(struct platform_device *pdev) -{ - int rc; - struct msm_rtc *rtc_pdata = NULL; - struct rpcsvr_platform_device *rdev = - container_of(pdev, struct rpcsvr_platform_device, base); - uint32_t prog_version; - - - if (pdev->id == (TIMEREMOTE_PROG_VER_1 & RPC_VERSION_MAJOR_MASK)) - prog_version = TIMEREMOTE_PROG_VER_1; - else if (pdev->id == (TIMEREMOTE_PROG_VER_2 & - RPC_VERSION_MAJOR_MASK)) - prog_version = TIMEREMOTE_PROG_VER_2; - else - return -EINVAL; - - rtc_pdata = kzalloc(sizeof(*rtc_pdata), GFP_KERNEL); - if (rtc_pdata == NULL) { - dev_err(&pdev->dev, - "%s: Unable to allocate memory\n", __func__); - return -ENOMEM; - } - rtc_pdata->rpc_client = msm_rpc_register_client("rtc", rdev->prog, - prog_version, 1, msmrtc_cb_func); - if (IS_ERR(rtc_pdata->rpc_client)) { - dev_err(&pdev->dev, - "%s: init RPC failed! VERS = %x\n", __func__, - prog_version); - rc = PTR_ERR(rtc_pdata->rpc_client); - kfree(rtc_pdata); - return rc; - } - - /* - * Set up the callback client. - * For older targets this initialization will fail - */ - rc = msmrtc_setup_cb(rtc_pdata); - if (rc) - dev_dbg(&pdev->dev, "%s: Could not initialize RPC callback\n", - __func__); - - rtc_pdata->rtcalarm_time = 0; - platform_set_drvdata(pdev, rtc_pdata); - - rtc_pdata->rtc = rtc_device_register("msm_rtc", - &pdev->dev, - &msm_rtc_ops, - THIS_MODULE); - if (IS_ERR(rtc_pdata->rtc)) { - dev_err(&pdev->dev, "%s: Can't register RTC device (%ld)\n", - pdev->name, PTR_ERR(rtc_pdata->rtc)); - rc = PTR_ERR(rtc_pdata->rtc); - goto fail_cb_setup; - } - -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT - rtc_pdata->rtcsecure = rtc_device_register("msm_rtc_secure", - &pdev->dev, - &msm_rtc_ops_secure, - THIS_MODULE); - - if (IS_ERR(rtc_pdata->rtcsecure)) { - dev_err(&pdev->dev, - "%s: Can't register RTC Secure device (%ld)\n", - pdev->name, PTR_ERR(rtc_pdata->rtcsecure)); - rtc_device_unregister(rtc_pdata->rtc); - rc = PTR_ERR(rtc_pdata->rtcsecure); - goto fail_cb_setup; - } -#endif - -#ifdef CONFIG_RTC_ASYNC_MODEM_SUPPORT - rtc_hctosys(); -#endif - - return 0; - -fail_cb_setup: - msm_rpc_unregister_client(rtc_pdata->rpc_client); - kfree(rtc_pdata); - return rc; -} - - -#ifdef CONFIG_PM - -static void -msmrtc_alarmtimer_expired(unsigned long _data, - struct msm_rtc *rtc_pdata) -{ - pr_debug("%s: Generating alarm event (src %lu)\n", - rtc_pdata->rtc->name, _data); - - rtc_update_irq(rtc_pdata->rtc, 1, RTC_IRQF | RTC_AF); - rtc_pdata->rtcalarm_time = 0; -} - -static int -msmrtc_suspend(struct platform_device *dev, pm_message_t state) -{ - int rc, diff; - struct rtc_time tm; - unsigned long now; - struct msm_rtc *rtc_pdata = platform_get_drvdata(dev); - - suspend_state.tick_at_suspend = msm_timer_get_sclk_time(NULL); - if (rtc_pdata->rtcalarm_time) { - rc = msmrtc_timeremote_read_time(&dev->dev, &tm); - if (rc) { - dev_err(&dev->dev, - "%s: Unable to read from RTC\n", __func__); - return rc; - } - rtc_tm_to_time(&tm, &now); - diff = rtc_pdata->rtcalarm_time - now; - if (diff <= 0) { - msmrtc_alarmtimer_expired(1 , rtc_pdata); - msm_pm_set_max_sleep_time(0); - atomic_inc(&suspend_state.state); - return 0; - } - msm_pm_set_max_sleep_time((int64_t) - ((int64_t) diff * NSEC_PER_SEC)); - } else - msm_pm_set_max_sleep_time(0); - atomic_inc(&suspend_state.state); - return 0; -} - -static int -msmrtc_resume(struct platform_device *dev) -{ - int rc, diff; - struct rtc_time tm; - unsigned long now; - struct msm_rtc *rtc_pdata = platform_get_drvdata(dev); - - if (rtc_pdata->rtcalarm_time) { - rc = msmrtc_timeremote_read_time(&dev->dev, &tm); - if (rc) { - dev_err(&dev->dev, - "%s: Unable to read from RTC\n", __func__); - return rc; - } - rtc_tm_to_time(&tm, &now); - diff = rtc_pdata->rtcalarm_time - now; - if (diff <= 0) - msmrtc_alarmtimer_expired(2 , rtc_pdata); - } - suspend_state.tick_at_suspend = 0; - atomic_dec(&suspend_state.state); - return 0; -} -#else -#define msmrtc_suspend NULL -#define msmrtc_resume NULL -#endif - -static int msmrtc_remove(struct platform_device *pdev) -{ - struct msm_rtc *rtc_pdata = platform_get_drvdata(pdev); - - rtc_device_unregister(rtc_pdata->rtc); -#ifdef CONFIG_RTC_SECURE_TIME_SUPPORT - rtc_device_unregister(rtc_pdata->rtcsecure); -#endif - msm_rpc_unregister_client(rtc_pdata->rpc_client); - kfree(rtc_pdata); - - return 0; -} - -static struct platform_driver msmrtc_driver = { - .probe = msmrtc_probe, - .suspend = msmrtc_suspend, - .resume = msmrtc_resume, - .remove = msmrtc_remove, - .driver = { - .name = APP_TIMEREMOTE_PDEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init msmrtc_init(void) -{ - int rc; - - /* - * For backward compatibility, register multiple platform - * drivers with the RPC PROG_VERS to be supported. - * - * Explicit cast away of 'constness' for driver.name in order to - * initialize it here. - */ - snprintf((char *)msmrtc_driver.driver.name, - strlen(msmrtc_driver.driver.name)+1, - "rs%08x", TIMEREMOTE_PROG_NUMBER); - pr_debug("RTC Registering with %s\n", msmrtc_driver.driver.name); - - rc = platform_driver_register(&msmrtc_driver); - if (rc) - pr_err("%s: platfrom_driver_register failed\n", __func__); - - return rc; -} - -static void __exit msmrtc_exit(void) -{ - platform_driver_unregister(&msmrtc_driver); -} - -module_init(msmrtc_init); -module_exit(msmrtc_exit); - -MODULE_DESCRIPTION("RTC driver for Qualcomm MSM7x00a chipsets"); -MODULE_AUTHOR("San Mehat "); -MODULE_LICENSE("GPL"); diff --git a/drivers/rtc/rtc-msm7x00a.c b/drivers/rtc/rtc-msm7x00a.c deleted file mode 100644 index 690bc398cd6c00aa6237fa00fb64b8dd1fef1330..0000000000000000000000000000000000000000 --- a/drivers/rtc/rtc-msm7x00a.c +++ /dev/null @@ -1,280 +0,0 @@ -/* drivers/rtc/rtc-msm7x00a.c - * - * Copyright (C) 2008 Google, Inc. - * Author: San Mehat - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include - -#include -#include -#include -#include -#include -#include - -#include - -#define RTC_DEBUG 0 - -extern void msm_pm_set_max_sleep_time(int64_t sleep_time_ns); - -#if CONFIG_MSM_AMSS_VERSION >= 6350 || defined(CONFIG_ARCH_QSD8X50) -#define APP_TIMEREMOTE_PDEV_NAME "rs30000048:00010000" -#else -#define APP_TIMEREMOTE_PDEV_NAME "rs30000048:0da5b528" -#endif - -#define TIMEREMOTE_PROCEEDURE_SET_JULIAN 6 -#define TIMEREMOTE_PROCEEDURE_GET_JULIAN 7 - -struct rpc_time_julian { - uint32_t year; - uint32_t month; - uint32_t day; - uint32_t hour; - uint32_t minute; - uint32_t second; - uint32_t day_of_week; -}; - -static struct msm_rpc_endpoint *ep; -static struct rtc_device *rtc; -static unsigned long rtcalarm_time; - -static int -msmrtc_timeremote_set_time(struct device *dev, struct rtc_time *tm) -{ - int rc; - - struct timeremote_set_julian_req { - struct rpc_request_hdr hdr; - uint32_t opt_arg; - - struct rpc_time_julian time; - } req; - - struct timeremote_set_julian_rep { - struct rpc_reply_hdr hdr; - } rep; - - if (tm->tm_year < 1900) - tm->tm_year += 1900; - - if (tm->tm_year < 1970) - return -EINVAL; - -#if RTC_DEBUG - printk(KERN_DEBUG "%s: %.2u/%.2u/%.4u %.2u:%.2u:%.2u (%.2u)\n", - __func__, tm->tm_mon, tm->tm_mday, tm->tm_year, - tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); -#endif - - req.opt_arg = cpu_to_be32(1); - req.time.year = cpu_to_be32(tm->tm_year); - req.time.month = cpu_to_be32(tm->tm_mon + 1); - req.time.day = cpu_to_be32(tm->tm_mday); - req.time.hour = cpu_to_be32(tm->tm_hour); - req.time.minute = cpu_to_be32(tm->tm_min); - req.time.second = cpu_to_be32(tm->tm_sec); - req.time.day_of_week = cpu_to_be32(tm->tm_wday); - - - rc = msm_rpc_call_reply(ep, TIMEREMOTE_PROCEEDURE_SET_JULIAN, - &req, sizeof(req), - &rep, sizeof(rep), - 5 * HZ); - return rc; -} - -static int -msmrtc_timeremote_read_time(struct device *dev, struct rtc_time *tm) -{ - int rc; - - struct timeremote_get_julian_req { - struct rpc_request_hdr hdr; - uint32_t julian_time_not_null; - } req; - - struct timeremote_get_julian_rep { - struct rpc_reply_hdr hdr; - uint32_t opt_arg; - struct rpc_time_julian time; - } rep; - - req.julian_time_not_null = cpu_to_be32(1); - - rc = msm_rpc_call_reply(ep, TIMEREMOTE_PROCEEDURE_GET_JULIAN, - &req, sizeof(req), - &rep, sizeof(rep), - 5 * HZ); - if (rc < 0) - return rc; - - if (!be32_to_cpu(rep.opt_arg)) { - printk(KERN_ERR "%s: No data from RTC\n", __func__); - return -ENODATA; - } - - tm->tm_year = be32_to_cpu(rep.time.year); - tm->tm_mon = be32_to_cpu(rep.time.month); - tm->tm_mday = be32_to_cpu(rep.time.day); - tm->tm_hour = be32_to_cpu(rep.time.hour); - tm->tm_min = be32_to_cpu(rep.time.minute); - tm->tm_sec = be32_to_cpu(rep.time.second); - tm->tm_wday = be32_to_cpu(rep.time.day_of_week); - -#if RTC_DEBUG - printk(KERN_DEBUG "%s: %.2u/%.2u/%.4u %.2u:%.2u:%.2u (%.2u)\n", - __func__, tm->tm_mon, tm->tm_mday, tm->tm_year, - tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); -#endif - - tm->tm_year -= 1900; /* RTC layer expects years to start at 1900 */ - tm->tm_mon--; /* RTC layer expects mons to be 0 based */ - - if (rtc_valid_tm(tm) < 0) { - dev_err(dev, "retrieved date/time is not valid.\n"); - rtc_time_to_tm(0, tm); - } - - return 0; -} - - -static int -msmrtc_virtual_alarm_set(struct device *dev, struct rtc_wkalrm *a) -{ - unsigned long now = get_seconds(); - - if (!a->enabled) { - rtcalarm_time = 0; - return 0; - } else - rtc_tm_to_time(&a->time, &rtcalarm_time); - - if (now > rtcalarm_time) { - printk(KERN_ERR "%s: Attempt to set alarm in the past\n", - __func__); - rtcalarm_time = 0; - return -EINVAL; - } - - return 0; -} - -static struct rtc_class_ops msm_rtc_ops = { - .read_time = msmrtc_timeremote_read_time, - .set_time = msmrtc_timeremote_set_time, - .set_alarm = msmrtc_virtual_alarm_set, -}; - -static void -msmrtc_alarmtimer_expired(unsigned long _data) -{ -#if RTC_DEBUG - printk(KERN_DEBUG "%s: Generating alarm event (src %lu)\n", - rtc->name, _data); -#endif - rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF); - rtcalarm_time = 0; -} - -static int -msmrtc_probe(struct platform_device *pdev) -{ - struct rpcsvr_platform_device *rdev = - container_of(pdev, struct rpcsvr_platform_device, base); - - ep = msm_rpc_connect(rdev->prog, rdev->vers, 0); - if (IS_ERR(ep)) { - printk(KERN_ERR "%s: init rpc failed! rc = %ld\n", - __func__, PTR_ERR(ep)); - return PTR_ERR(ep); - } - - rtc = rtc_device_register("msm_rtc", - &pdev->dev, - &msm_rtc_ops, - THIS_MODULE); - if (IS_ERR(rtc)) { - printk(KERN_ERR "%s: Can't register RTC device (%ld)\n", - pdev->name, PTR_ERR(rtc)); - return PTR_ERR(rtc); - } - return 0; -} - - -static unsigned long msmrtc_get_seconds(void) -{ - struct rtc_time tm; - unsigned long now; - - msmrtc_timeremote_read_time(NULL, &tm); - rtc_tm_to_time(&tm, &now); - return now; -} - -static int -msmrtc_suspend(struct platform_device *dev, pm_message_t state) -{ - if (rtcalarm_time) { - unsigned long now = msmrtc_get_seconds(); - int diff = rtcalarm_time - now; - if (diff <= 0) { - msmrtc_alarmtimer_expired(1); - msm_pm_set_max_sleep_time(0); - return 0; - } - msm_pm_set_max_sleep_time((int64_t) ((int64_t) diff * NSEC_PER_SEC)); - } else - msm_pm_set_max_sleep_time(0); - return 0; -} - -static int -msmrtc_resume(struct platform_device *dev) -{ - if (rtcalarm_time) { - unsigned long now = msmrtc_get_seconds(); - int diff = rtcalarm_time - now; - if (diff <= 0) - msmrtc_alarmtimer_expired(2); - } - return 0; -} - -static struct platform_driver msmrtc_driver = { - .probe = msmrtc_probe, - .suspend = msmrtc_suspend, - .resume = msmrtc_resume, - .driver = { - .name = APP_TIMEREMOTE_PDEV_NAME, - .owner = THIS_MODULE, - }, -}; - -static int __init msmrtc_init(void) -{ - rtcalarm_time = 0; - return platform_driver_register(&msmrtc_driver); -} - -module_init(msmrtc_init); - -MODULE_DESCRIPTION("RTC driver for Qualcomm MSM7x00a chipsets"); -MODULE_AUTHOR("San Mehat "); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 415772ea306dd160a9c19477b557ff16fd746fe6..5f3c10934aac78fb13658c8888a620e7c51cbeb4 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -46,7 +46,6 @@ obj-$(CONFIG_BCM_WIMAX) += bcm/ obj-$(CONFIG_FT1000) += ft1000/ obj-$(CONFIG_SPEAKUP) += speakup/ obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217) += cptm1217/ -obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4) += ste_rmi4/ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/ diff --git a/drivers/staging/gobi/QCUSBNet2k/Makefile b/drivers/staging/gobi/QCUSBNet2k/Makefile index 66c1590d3933655f5100349ae7c840057b70b667..948fa9291bb7e848f3965db6b08c0af3918eccd8 100644 --- a/drivers/staging/gobi/QCUSBNet2k/Makefile +++ b/drivers/staging/gobi/QCUSBNet2k/Makefile @@ -1,2 +1 @@ obj-$(CONFIG_GOBI_USBNET) += QCUSBNet2k.o -QCUSBNet2k-objs += QCUSBNet.o QMIDevice.o QMI.o diff --git a/drivers/staging/gobi/QCUSBNet2k/QCUSBNet.c b/drivers/staging/gobi/QCUSBNet2k/QCUSBNet.c deleted file mode 100644 index d4b4663fca1a27a0950b03bde7be2132c07ffe29..0000000000000000000000000000000000000000 --- a/drivers/staging/gobi/QCUSBNet2k/QCUSBNet.c +++ /dev/null @@ -1,1227 +0,0 @@ -/*=========================================================================== -FILE: - QCUSBNet.c - -DESCRIPTION: - Qualcomm USB Network device for Gobi 2000 - -FUNCTIONS: - QCSuspend - QCResume - QCNetDriverBind - QCNetDriverUnbind - QCUSBNetURBCallback - QCUSBNetTXTimeout - QCUSBNetAutoPMThread - QCUSBNetStartXmit - QCUSBNetOpen - QCUSBNetStop - QCUSBNetProbe - QCUSBNetModInit - QCUSBNetModExit - -Copyright (c) 2010, 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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- - -#include "Structs.h" -#include "QMIDevice.h" -#include "QMI.h" - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -// Version Information -#define DRIVER_VERSION "1.0.110" -#define DRIVER_DESC "QCUSBNet2k" - -// Debug flag -int debug; - -// Class should be created during module init, so needs to be global -static struct class * gpClass; - -/*=========================================================================== -METHOD: - QCSuspend (Public Method) - -DESCRIPTION: - Stops QMI traffic while device is suspended - -PARAMETERS - pIntf [ I ] - Pointer to interface - powerEvent [ I ] - Power management event - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -int QCSuspend( - struct usb_interface * pIntf, - pm_message_t powerEvent ) -{ - struct usbnet * pDev; - sQCUSBNet * pQCDev; - - if (pIntf == 0) - { - return -ENOMEM; - } - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 )) - pDev = usb_get_intfdata( pIntf ); -#else - pDev = (struct usbnet *)pIntf->dev.platform_data; -#endif - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - return -ENXIO; - } - - pQCDev = (sQCUSBNet *)pDev->data[0]; - if (pQCDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - // Is this autosuspend or system suspend? - // do we allow remote wakeup? -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) - if (pDev->udev->auto_pm == 0) -#else - if ((powerEvent.event & PM_EVENT_AUTO) == 0) -#endif - { - DBG( "device suspended to power level %d\n", - powerEvent.event ); - QSetDownReason( pQCDev, DRIVER_SUSPENDED ); - } - else - { - DBG( "device autosuspend\n" ); - } - - if (powerEvent.event & PM_EVENT_SUSPEND) - { - // Stop QMI read callbacks - KillRead( pQCDev ); - pDev->udev->reset_resume = 0; - - // Store power state to avoid duplicate resumes - pIntf->dev.power.power_state.event = powerEvent.event; - } - else - { - // Other power modes cause QMI connection to be lost - pDev->udev->reset_resume = 1; - } - - // Run usbnet's suspend function - return usbnet_suspend( pIntf, powerEvent ); -} - -/*=========================================================================== -METHOD: - QCResume (Public Method) - -DESCRIPTION: - Resume QMI traffic or recreate QMI device - -PARAMETERS - pIntf [ I ] - Pointer to interface - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -int QCResume( struct usb_interface * pIntf ) -{ - struct usbnet * pDev; - sQCUSBNet * pQCDev; - int nRet; - int oldPowerState; - - if (pIntf == 0) - { - return -ENOMEM; - } - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 )) - pDev = usb_get_intfdata( pIntf ); -#else - pDev = (struct usbnet *)pIntf->dev.platform_data; -#endif - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - return -ENXIO; - } - - pQCDev = (sQCUSBNet *)pDev->data[0]; - if (pQCDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - oldPowerState = pIntf->dev.power.power_state.event; - pIntf->dev.power.power_state.event = PM_EVENT_ON; - DBG( "resuming from power mode %d\n", oldPowerState ); - - if (oldPowerState & PM_EVENT_SUSPEND) - { - // It doesn't matter if this is autoresume or system resume - QClearDownReason( pQCDev, DRIVER_SUSPENDED ); - - nRet = usbnet_resume( pIntf ); - if (nRet != 0) - { - DBG( "usbnet_resume error %d\n", nRet ); - return nRet; - } - - // Restart QMI read callbacks - nRet = StartRead( pQCDev ); - if (nRet != 0) - { - DBG( "StartRead error %d\n", nRet ); - return nRet; - } - - // Kick Auto PM thread to process any queued URBs - up( &pQCDev->mAutoPM.mThreadDoWork ); - } - else - { - DBG( "nothing to resume\n" ); - return 0; - } - - return nRet; -} - -/*=========================================================================== -METHOD: - QCNetDriverBind (Public Method) - -DESCRIPTION: - Setup in and out pipes - -PARAMETERS - pDev [ I ] - Pointer to usbnet device - pIntf [ I ] - Pointer to interface - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QCNetDriverBind( - struct usbnet * pDev, - struct usb_interface * pIntf ) -{ - int numEndpoints; - int endpointIndex; - struct usb_host_endpoint * pEndpoint = NULL; - struct usb_host_endpoint * pIn = NULL; - struct usb_host_endpoint * pOut = NULL; - - // Verify one altsetting - if (pIntf->num_altsetting != 1) - { - DBG( "invalid num_altsetting %u\n", pIntf->num_altsetting ); - return -EINVAL; - } - - // Verify correct interface (0) - if (pIntf->cur_altsetting->desc.bInterfaceNumber != 0) - { - DBG( "invalid interface %d\n", - pIntf->cur_altsetting->desc.bInterfaceNumber ); - return -EINVAL; - } - - // Collect In and Out endpoints - numEndpoints = pIntf->cur_altsetting->desc.bNumEndpoints; - for (endpointIndex = 0; endpointIndex < numEndpoints; endpointIndex++) - { - pEndpoint = pIntf->cur_altsetting->endpoint + endpointIndex; - if (pEndpoint == NULL) - { - DBG( "invalid endpoint %u\n", endpointIndex ); - return -EINVAL; - } - - if (usb_endpoint_dir_in( &pEndpoint->desc ) == true - && usb_endpoint_xfer_int( &pEndpoint->desc ) == false) - { - pIn = pEndpoint; - } - else if (usb_endpoint_dir_out( &pEndpoint->desc ) == true) - { - pOut = pEndpoint; - } - } - - if (pIn == NULL || pOut == NULL) - { - DBG( "invalid endpoints\n" ); - return -EINVAL; - } - - if (usb_set_interface( pDev->udev, - pIntf->cur_altsetting->desc.bInterfaceNumber, - 0 ) != 0) - { - DBG( "unable to set interface\n" ); - return -EINVAL; - } - - pDev->in = usb_rcvbulkpipe( pDev->udev, - pIn->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); - pDev->out = usb_sndbulkpipe( pDev->udev, - pOut->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); - - DBG( "in %x, out %x\n", - pIn->desc.bEndpointAddress, - pOut->desc.bEndpointAddress ); - - // In later versions of the kernel, usbnet helps with this -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,23 )) - pIntf->dev.platform_data = (void *)pDev; -#endif - - return 0; -} - -/*=========================================================================== -METHOD: - QCNetDriverUnbind (Public Method) - -DESCRIPTION: - Deregisters QMI device (Registration happened in the probe function) - -PARAMETERS - pDev [ I ] - Pointer to usbnet device - pIntfUnused [ I ] - Pointer to interface - -RETURN VALUE: - None -===========================================================================*/ -static void QCNetDriverUnbind( - struct usbnet * pDev, - struct usb_interface * pIntf) -{ - sQCUSBNet * pQCDev = (sQCUSBNet *)pDev->data[0]; - - // Should already be down, but just in case... - netif_carrier_off( pDev->net ); - - DeregisterQMIDevice( pQCDev ); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,29 )) - kfree( pDev->net->netdev_ops ); - pDev->net->netdev_ops = NULL; -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,23 )) - pIntf->dev.platform_data = NULL; -#endif - - kfree( pQCDev ); - pQCDev = NULL; -} - -/*=========================================================================== -METHOD: - QCUSBNetURBCallback (Public Method) - -DESCRIPTION: - Write is complete, cleanup and signal that we're ready for next packet - -PARAMETERS - pURB [ I ] - Pointer to sAutoPM struct - -RETURN VALUE: - None -===========================================================================*/ -void QCUSBNetURBCallback( struct urb * pURB ) -{ - unsigned long activeURBflags; - sAutoPM * pAutoPM = (sAutoPM *)pURB->context; - if (pAutoPM == NULL) - { - // Should never happen - DBG( "bad context\n" ); - return; - } - - if (pURB->status != 0) - { - // Note that in case of an error, the behaviour is no different - DBG( "urb finished with error %d\n", pURB->status ); - } - - // Remove activeURB (memory to be freed later) - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - - // EAGAIN used to signify callback is done - pAutoPM->mpActiveURB = ERR_PTR( -EAGAIN ); - - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - up( &pAutoPM->mThreadDoWork ); - - usb_free_urb( pURB ); -} - -/*=========================================================================== -METHOD: - QCUSBNetTXTimeout (Public Method) - -DESCRIPTION: - Timeout declared by the net driver. Stop all transfers - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - None -===========================================================================*/ -void QCUSBNetTXTimeout( struct net_device * pNet ) -{ - struct sQCUSBNet * pQCDev; - sAutoPM * pAutoPM; - sURBList * pURBListEntry; - unsigned long activeURBflags, URBListFlags; - struct usbnet * pDev = netdev_priv( pNet ); - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get usbnet device\n" ); - return; - } - - pQCDev = (sQCUSBNet *)pDev->data[0]; - if (pQCDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return; - } - pAutoPM = &pQCDev->mAutoPM; - - DBG( "\n" ); - - // Stop activeURB - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - - if (pAutoPM->mpActiveURB != NULL) - { - usb_kill_urb( pAutoPM->mpActiveURB ); - } - - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // Cleanup URB List - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - - pURBListEntry = pAutoPM->mpURBList; - while (pURBListEntry != NULL) - { - pAutoPM->mpURBList = pAutoPM->mpURBList->mpNext; - usb_free_urb( pURBListEntry->mpURB ); - kfree( pURBListEntry ); - pURBListEntry = pAutoPM->mpURBList; - } - - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - up( &pAutoPM->mThreadDoWork ); - - return; -} - -/*=========================================================================== -METHOD: - QCUSBNetAutoPMThread (Public Method) - -DESCRIPTION: - Handle device Auto PM state asynchronously - Handle network packet transmission asynchronously - -PARAMETERS - pData [ I ] - Pointer to sAutoPM struct - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QCUSBNetAutoPMThread( void * pData ) -{ - unsigned long activeURBflags, URBListFlags; - sURBList * pURBListEntry; - int status; - struct usb_device * pUdev; - sAutoPM * pAutoPM = (sAutoPM *)pData; - if (pAutoPM == NULL) - { - DBG( "passed null pointer\n" ); - return -EINVAL; - } - - pUdev = interface_to_usbdev( pAutoPM->mpIntf ); - - DBG( "traffic thread started\n" ); - - while (pAutoPM->mbExit == false) - { - // Wait for someone to poke us - down( &pAutoPM->mThreadDoWork ); - - // Time to exit? - if (pAutoPM->mbExit == true) - { - // Stop activeURB - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - - if (pAutoPM->mpActiveURB != NULL) - { - usb_kill_urb( pAutoPM->mpActiveURB ); - } - // Will be freed in callback function - - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // Cleanup URB List - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - - pURBListEntry = pAutoPM->mpURBList; - while (pURBListEntry != NULL) - { - pAutoPM->mpURBList = pAutoPM->mpURBList->mpNext; - usb_free_urb( pURBListEntry->mpURB ); - kfree( pURBListEntry ); - pURBListEntry = pAutoPM->mpURBList; - } - - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - break; - } - - // Is our URB active? - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - - // EAGAIN used to signify callback is done - if (IS_ERR( pAutoPM->mpActiveURB ) - && PTR_ERR( pAutoPM->mpActiveURB ) == -EAGAIN ) - { - pAutoPM->mpActiveURB = NULL; - - // Restore IRQs so task can sleep - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // URB is done, decrement the Auto PM usage count - usb_autopm_put_interface( pAutoPM->mpIntf ); - - // Lock ActiveURB again - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - } - - if (pAutoPM->mpActiveURB != NULL) - { - // There is already a URB active, go back to sleep - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - continue; - } - - // Is there a URB waiting to be submitted? - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - if (pAutoPM->mpURBList == NULL) - { - // No more URBs to submit, go back to sleep - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - continue; - } - - // Pop an element - pURBListEntry = pAutoPM->mpURBList; - pAutoPM->mpURBList = pAutoPM->mpURBList->mpNext; - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - // Set ActiveURB - pAutoPM->mpActiveURB = pURBListEntry->mpURB; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // Tell autopm core we need device woken up - status = usb_autopm_get_interface( pAutoPM->mpIntf ); - if (status < 0) - { - DBG( "unable to autoresume interface: %d\n", status ); - - // likely caused by device going from autosuspend -> full suspend - if (status == -EPERM) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) - pUdev->auto_pm = 0; -#endif - QCSuspend( pAutoPM->mpIntf, PMSG_SUSPEND ); - } - - // Add pURBListEntry back onto pAutoPM->mpURBList - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - pURBListEntry->mpNext = pAutoPM->mpURBList; - pAutoPM->mpURBList = pURBListEntry; - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - pAutoPM->mpActiveURB = NULL; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // Go back to sleep - continue; - } - - // Submit URB - status = usb_submit_urb( pAutoPM->mpActiveURB, GFP_KERNEL ); - if (status < 0) - { - // Could happen for a number of reasons - DBG( "Failed to submit URB: %d. Packet dropped\n", status ); - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - usb_free_urb( pAutoPM->mpActiveURB ); - pAutoPM->mpActiveURB = NULL; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - usb_autopm_put_interface( pAutoPM->mpIntf ); - - // Loop again - up( &pAutoPM->mThreadDoWork ); - } - - kfree( pURBListEntry ); - } - - DBG( "traffic thread exiting\n" ); - pAutoPM->mpThread = NULL; - return 0; -} - -/*=========================================================================== -METHOD: - QCUSBNetStartXmit (Public Method) - -DESCRIPTION: - Convert sk_buff to usb URB and queue for transmit - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - NETDEV_TX_OK on success - NETDEV_TX_BUSY on error -===========================================================================*/ -int QCUSBNetStartXmit( - struct sk_buff * pSKB, - struct net_device * pNet ) -{ - unsigned long URBListFlags; - struct sQCUSBNet * pQCDev; - sAutoPM * pAutoPM; - sURBList * pURBListEntry, ** ppURBListEnd; - void * pURBData; - struct usbnet * pDev = netdev_priv( pNet ); - - DBG( "\n" ); - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get usbnet device\n" ); - return NETDEV_TX_BUSY; - } - - pQCDev = (sQCUSBNet *)pDev->data[0]; - if (pQCDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return NETDEV_TX_BUSY; - } - pAutoPM = &pQCDev->mAutoPM; - - if (QTestDownReason( pQCDev, DRIVER_SUSPENDED ) == true) - { - // Should not happen - DBG( "device is suspended\n" ); - dump_stack(); - return NETDEV_TX_BUSY; - } - - // Convert the sk_buff into a URB - - // Allocate URBListEntry - pURBListEntry = kmalloc( sizeof( sURBList ), GFP_ATOMIC ); - if (pURBListEntry == NULL) - { - DBG( "unable to allocate URBList memory\n" ); - return NETDEV_TX_BUSY; - } - pURBListEntry->mpNext = NULL; - - // Allocate URB - pURBListEntry->mpURB = usb_alloc_urb( 0, GFP_ATOMIC ); - if (pURBListEntry->mpURB == NULL) - { - DBG( "unable to allocate URB\n" ); - return NETDEV_TX_BUSY; - } - - // Allocate URB transfer_buffer - pURBData = kmalloc( pSKB->len, GFP_ATOMIC ); - if (pURBData == NULL) - { - DBG( "unable to allocate URB data\n" ); - return NETDEV_TX_BUSY; - } - // Fill will SKB's data - memcpy( pURBData, pSKB->data, pSKB->len ); - - usb_fill_bulk_urb( pURBListEntry->mpURB, - pQCDev->mpNetDev->udev, - pQCDev->mpNetDev->out, - pURBData, - pSKB->len, - QCUSBNetURBCallback, - pAutoPM ); - - // Aquire lock on URBList - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - - // Add URB to end of list - ppURBListEnd = &pAutoPM->mpURBList; - while ((*ppURBListEnd) != NULL) - { - ppURBListEnd = &(*ppURBListEnd)->mpNext; - } - *ppURBListEnd = pURBListEntry; - - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - up( &pAutoPM->mThreadDoWork ); - - // Start transfer timer - pNet->trans_start = jiffies; - // Free SKB - dev_kfree_skb_any( pSKB ); - - return NETDEV_TX_OK; -} - -/*=========================================================================== -METHOD: - QCUSBNetOpen (Public Method) - -DESCRIPTION: - Wrapper to usbnet_open, correctly handling autosuspend - Start AutoPM thread - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int QCUSBNetOpen( struct net_device * pNet ) -{ - int status = 0; - struct sQCUSBNet * pQCDev; - struct usbnet * pDev = netdev_priv( pNet ); - - if (pDev == NULL) - { - DBG( "failed to get usbnet device\n" ); - return -ENXIO; - } - - pQCDev = (sQCUSBNet *)pDev->data[0]; - if (pQCDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - DBG( "\n" ); - - // Start the AutoPM thread - pQCDev->mAutoPM.mpIntf = pQCDev->mpIntf; - pQCDev->mAutoPM.mbExit = false; - pQCDev->mAutoPM.mpURBList = NULL; - pQCDev->mAutoPM.mpActiveURB = NULL; - spin_lock_init( &pQCDev->mAutoPM.mURBListLock ); - spin_lock_init( &pQCDev->mAutoPM.mActiveURBLock ); - sema_init( &pQCDev->mAutoPM.mThreadDoWork, 0 ); - - pQCDev->mAutoPM.mpThread = kthread_run( QCUSBNetAutoPMThread, - &pQCDev->mAutoPM, - "QCUSBNetAutoPMThread" ); - if (IS_ERR( pQCDev->mAutoPM.mpThread )) - { - DBG( "AutoPM thread creation error\n" ); - return PTR_ERR( pQCDev->mAutoPM.mpThread ); - } - - // Allow traffic - QClearDownReason( pQCDev, NET_IFACE_STOPPED ); - - // Pass to usbnet_open if defined - if (pQCDev->mpUSBNetOpen != NULL) - { - status = pQCDev->mpUSBNetOpen( pNet ); - - // If usbnet_open was successful enable Auto PM - if (status == 0) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) - usb_autopm_enable( pQCDev->mpIntf ); -#else - usb_autopm_put_interface( pQCDev->mpIntf ); -#endif - } - } - else - { - DBG( "no USBNetOpen defined\n" ); - } - - return status; -} - -/*=========================================================================== -METHOD: - QCUSBNetStop (Public Method) - -DESCRIPTION: - Wrapper to usbnet_stop, correctly handling autosuspend - Stop AutoPM thread - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int QCUSBNetStop( struct net_device * pNet ) -{ - struct sQCUSBNet * pQCDev; - struct usbnet * pDev = netdev_priv( pNet ); - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - return -ENXIO; - } - - pQCDev = (sQCUSBNet *)pDev->data[0]; - if (pQCDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - // Stop traffic - QSetDownReason( pQCDev, NET_IFACE_STOPPED ); - - // Tell traffic thread to exit - pQCDev->mAutoPM.mbExit = true; - up( &pQCDev->mAutoPM.mThreadDoWork ); - - // Wait for it to exit - while( pQCDev->mAutoPM.mpThread != NULL ) - { - msleep( 100 ); - } - DBG( "thread stopped\n" ); - - // Pass to usbnet_stop, if defined - if (pQCDev->mpUSBNetStop != NULL) - { - return pQCDev->mpUSBNetStop( pNet ); - } - else - { - return 0; - } -} - -/*=========================================================================*/ -// Struct driver_info -/*=========================================================================*/ -static const struct driver_info QCNetInfo = -{ - .description = "QCUSBNet Ethernet Device", - .flags = FLAG_ETHER, - .bind = QCNetDriverBind, - .unbind = QCNetDriverUnbind, - .data = 0, -}; - -/*=========================================================================*/ -// Qualcomm Gobi 2000 VID/PIDs -/*=========================================================================*/ -static const struct usb_device_id QCVIDPIDTable [] = -{ - // Acer Gobi 2000 - { - USB_DEVICE( 0x05c6, 0x9215 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Asus Gobi 2000 - { - USB_DEVICE( 0x05c6, 0x9265 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // CMOTech Gobi 2000 - { - USB_DEVICE( 0x16d8, 0x8002 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Dell Gobi 2000 - { - USB_DEVICE( 0x413c, 0x8186 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Entourage Gobi 2000 - { - USB_DEVICE( 0x1410, 0xa010 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Entourage Gobi 2000 - { - USB_DEVICE( 0x1410, 0xa011 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Entourage Gobi 2000 - { - USB_DEVICE( 0x1410, 0xa012 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Entourage Gobi 2000 - { - USB_DEVICE( 0x1410, 0xa013 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // HP Gobi 2000 - { - USB_DEVICE( 0x03f0, 0x251d ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Lenovo Gobi 2000 - { - USB_DEVICE( 0x05c6, 0x9205 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Panasonic Gobi 2000 - { - USB_DEVICE( 0x04da, 0x250f ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Samsung Gobi 2000 - { - USB_DEVICE( 0x05c6, 0x9245 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9001 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9002 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9003 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9004 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9005 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9006 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9007 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9008 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x9009 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sierra Wireless Gobi 2000 - { - USB_DEVICE( 0x1199, 0x900a ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Sony Gobi 2000 - { - USB_DEVICE( 0x05c6, 0x9225 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Top Global Gobi 2000 - { - USB_DEVICE( 0x05c6, 0x9235 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // iRex Technologies Gobi 2000 - { - USB_DEVICE( 0x05c6, 0x9275 ), - .driver_info = (unsigned long)&QCNetInfo - }, - // Generic Gobi 2000 - { - USB_DEVICE( 0x5c6, 0x920B ), - .driver_info = (unsigned long)&QCNetInfo - }, - - //Terminating entry - { } -}; - -MODULE_DEVICE_TABLE( usb, QCVIDPIDTable ); - -/*=========================================================================== -METHOD: - QCUSBNetProbe (Public Method) - -DESCRIPTION: - Run usbnet_probe - Setup QMI device - -PARAMETERS - pIntf [ I ] - Pointer to interface - pVIDPIDs [ I ] - Pointer to VID/PID table - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int QCUSBNetProbe( - struct usb_interface * pIntf, - const struct usb_device_id * pVIDPIDs ) -{ - int status; - struct usbnet * pDev; - sQCUSBNet * pQCDev; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,29 )) - struct net_device_ops * pNetDevOps; -#endif - - status = usbnet_probe( pIntf, pVIDPIDs ); - if(status < 0 ) - { - DBG( "usbnet_probe failed %d\n", status ); - return status; - } - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 )) - pDev = usb_get_intfdata( pIntf ); -#else - pDev = (struct usbnet *)pIntf->dev.platform_data; -#endif - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - return -ENXIO; - } - - pQCDev = kmalloc( sizeof( sQCUSBNet ), GFP_KERNEL ); - if (pQCDev == NULL) - { - DBG( "falied to allocate device buffers" ); - return -ENOMEM; - } - - pDev->data[0] = (unsigned long)pQCDev; - - pQCDev->mpNetDev = pDev; - - // Overload PM related network functions -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - pQCDev->mpUSBNetOpen = pDev->net->open; - pDev->net->open = QCUSBNetOpen; - pQCDev->mpUSBNetStop = pDev->net->stop; - pDev->net->stop = QCUSBNetStop; - pDev->net->hard_start_xmit = QCUSBNetStartXmit; - pDev->net->tx_timeout = QCUSBNetTXTimeout; -#else - pNetDevOps = kmalloc( sizeof( struct net_device_ops ), GFP_KERNEL ); - if (pNetDevOps == NULL) - { - DBG( "falied to allocate net device ops" ); - return -ENOMEM; - } - memcpy( pNetDevOps, pDev->net->netdev_ops, sizeof( struct net_device_ops ) ); - - pQCDev->mpUSBNetOpen = pNetDevOps->ndo_open; - pNetDevOps->ndo_open = QCUSBNetOpen; - pQCDev->mpUSBNetStop = pNetDevOps->ndo_stop; - pNetDevOps->ndo_stop = QCUSBNetStop; - pNetDevOps->ndo_start_xmit = QCUSBNetStartXmit; - pNetDevOps->ndo_tx_timeout = QCUSBNetTXTimeout; - - pDev->net->netdev_ops = pNetDevOps; -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,31 )) - memset( &(pQCDev->mpNetDev->stats), 0, sizeof( struct net_device_stats ) ); -#else - memset( &(pQCDev->mpNetDev->net->stats), 0, sizeof( struct net_device_stats ) ); -#endif - - pQCDev->mpIntf = pIntf; - memset( &(pQCDev->mMEID), '0', 14 ); - - DBG( "Mac Address:\n" ); - PrintHex( &pQCDev->mpNetDev->net->dev_addr[0], 6 ); - - pQCDev->mbQMIValid = false; - memset( &pQCDev->mQMIDev, 0, sizeof( sQMIDev ) ); - - pQCDev->mQMIDev.mpDevClass = gpClass; - - sema_init( &pQCDev->mAutoPM.mThreadDoWork, 0 ); - spin_lock_init( &pQCDev->mQMIDev.mClientMemLock ); - - // Default to device down - pQCDev->mDownReason = 0; - QSetDownReason( pQCDev, NO_NDIS_CONNECTION ); - QSetDownReason( pQCDev, NET_IFACE_STOPPED ); - - // Register QMI - status = RegisterQMIDevice( pQCDev ); - if (status != 0) - { - // Clean up - DeregisterQMIDevice( pQCDev ); - return status; - } - - // Success - return status; -} - -EXPORT_SYMBOL_GPL( QCUSBNetProbe ); - -static struct usb_driver QCUSBNet = -{ - .name = "QCUSBNet2k", - .id_table = QCVIDPIDTable, - .probe = QCUSBNetProbe, - .disconnect = usbnet_disconnect, - .suspend = QCSuspend, - .resume = QCResume, - .supports_autosuspend = true, -}; - -/*=========================================================================== -METHOD: - QCUSBNetModInit (Public Method) - -DESCRIPTION: - Initialize module - Create device class - Register out usb_driver struct - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int __init QCUSBNetModInit( void ) -{ - gpClass = class_create( THIS_MODULE, "QCQMI" ); - if (IS_ERR( gpClass ) == true) - { - DBG( "error at class_create %ld\n", - PTR_ERR( gpClass ) ); - return -ENOMEM; - } - - // This will be shown whenever driver is loaded - printk( KERN_INFO "%s: %s\n", DRIVER_DESC, DRIVER_VERSION ); - - return usb_register( &QCUSBNet ); -} -module_init( QCUSBNetModInit ); - -/*=========================================================================== -METHOD: - QCUSBNetModExit (Public Method) - -DESCRIPTION: - Deregister module - Destroy device class - -RETURN VALUE: - void -===========================================================================*/ -static void __exit QCUSBNetModExit( void ) -{ - usb_deregister( &QCUSBNet ); - - class_destroy( gpClass ); -} -module_exit( QCUSBNetModExit ); - -#ifdef bool -#undef bool -#endif - -MODULE_VERSION( DRIVER_VERSION ); -MODULE_DESCRIPTION( DRIVER_DESC ); -MODULE_LICENSE( "GPL v2" ); - -module_param( debug, bool, S_IRUGO | S_IWUSR ); -MODULE_PARM_DESC( debug, "Debuging enabled or not" ); - diff --git a/drivers/staging/gobi/QCUSBNet2k/QMI.c b/drivers/staging/gobi/QCUSBNet2k/QMI.c deleted file mode 100644 index fb880927ffe6a47f3614d289c4fabcc57d545812..0000000000000000000000000000000000000000 --- a/drivers/staging/gobi/QCUSBNet2k/QMI.c +++ /dev/null @@ -1,954 +0,0 @@ -/*=========================================================================== -FILE: - QMI.c - -DESCRIPTION: - Qualcomm QMI driver code - -FUNCTIONS: - Generic QMUX functions - ParseQMUX - FillQMUX - - Generic QMI functions - GetTLV - ValidQMIMessage - GetQMIMessageID - - Fill Buffers with QMI requests - QMICTLGetClientIDReq - QMICTLReleaseClientIDReq - QMICTLReadyReq - QMIWDSSetEventReportReq - QMIWDSGetPKGSRVCStatusReq - QMIDMSGetMEIDReq - - Parse data from QMI responses - QMICTLGetClientIDResp - QMICTLReleaseClientIDResp - QMIWDSEventResp - QMIDMSGetMEIDResp - -Copyright (c) 2010, 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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include "QMI.h" - - -/*=========================================================================*/ -// Get sizes of buffers needed by QMI requests -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMUXHeaderSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -u16 QMUXHeaderSize( void ) -{ - return sizeof( sQMUX ); -} - -/*=========================================================================== -METHOD: - QMICTLGetClientIDReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLGetClientIDReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -u16 QMICTLGetClientIDReqSize( void ) -{ - return sizeof( sQMUX ) + 10; -} - -/*=========================================================================== -METHOD: - QMICTLReleaseClientIDReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLReleaseClientIDReq - -RETURN VALUE: - u16 - size of header -===========================================================================*/ -u16 QMICTLReleaseClientIDReqSize( void ) -{ - return sizeof( sQMUX ) + 11; -} - -/*=========================================================================== -METHOD: - QMICTLReadyReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLReadyReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -u16 QMICTLReadyReqSize( void ) -{ - return sizeof( sQMUX ) + 6; -} - -/*=========================================================================== -METHOD: - QMIWDSSetEventReportReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMIWDSSetEventReportReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -u16 QMIWDSSetEventReportReqSize( void ) -{ - return sizeof( sQMUX ) + 15; -} - -/*=========================================================================== -METHOD: - QMIWDSGetPKGSRVCStatusReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMIWDSGetPKGSRVCStatusReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -u16 QMIWDSGetPKGSRVCStatusReqSize( void ) -{ - return sizeof( sQMUX ) + 7; -} - -/*=========================================================================== -METHOD: - QMIDMSGetMEIDReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMIDMSGetMEIDReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -u16 QMIDMSGetMEIDReqSize( void ) -{ - return sizeof( sQMUX ) + 7; -} - -/*=========================================================================*/ -// Generic QMUX functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - ParseQMUX (Public Method) - -DESCRIPTION: - Remove QMUX headers from a buffer - -PARAMETERS - pClientID [ O ] - On success, will point to Client ID - pBuffer [ I ] - Full Message passed in - buffSize [ I ] - Size of pBuffer - -RETURN VALUE: - int - Positive for size of QMUX header - Negative errno for error -===========================================================================*/ -int ParseQMUX( - u16 * pClientID, - void * pBuffer, - u16 buffSize ) -{ - sQMUX * pQMUXHeader; - - if (pBuffer == 0 || buffSize < 12) - { - return -ENOMEM; - } - - // QMUX Header - pQMUXHeader = (sQMUX *)pBuffer; - - if (pQMUXHeader->mTF != 1 - || pQMUXHeader->mLength != buffSize - 1 - || pQMUXHeader->mCtrlFlag != 0x80 ) - { - return -EINVAL; - } - - // Client ID - *pClientID = (pQMUXHeader->mQMIClientID << 8) - + pQMUXHeader->mQMIService; - - return sizeof( sQMUX ); -} - -/*=========================================================================== -METHOD: - FillQMUX (Public Method) - -DESCRIPTION: - Fill buffer with QMUX headers - -PARAMETERS - clientID [ I ] - Client ID - pBuffer [ O ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer (must be at least 6) - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int FillQMUX( - u16 clientID, - void * pBuffer, - u16 buffSize ) -{ - sQMUX * pQMUXHeader; - - if (pBuffer == 0 || buffSize < sizeof( sQMUX )) - { - return -ENOMEM; - } - - // QMUX Header - pQMUXHeader = (sQMUX *)pBuffer; - - pQMUXHeader->mTF = 1; - pQMUXHeader->mLength = buffSize - 1; - pQMUXHeader->mCtrlFlag = 0; - - // Service and Client ID - pQMUXHeader->mQMIService = clientID & 0xff; - pQMUXHeader->mQMIClientID = clientID >> 8; - - return 0; -} - -/*=========================================================================*/ -// Generic QMI functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - GetTLV (Public Method) - -DESCRIPTION: - Get data bufffer of a specified TLV from a QMI message - - QMI Message shall NOT include SDU - -PARAMETERS - pQMIMessage [ I ] - QMI Message buffer - messageLen [ I ] - Size of QMI Message buffer - type [ I ] - Desired Type - pOutDataBuf [ O ] - Buffer to be filled with TLV - messageLen [ I ] - Size of QMI Message buffer - -RETURN VALUE: - u16 - Size of TLV for success - Negative errno for error -===========================================================================*/ -u16 GetTLV( - void * pQMIMessage, - u16 messageLen, - u8 type, - void * pOutDataBuf, - u16 bufferLen ) -{ - u16 pos; - u16 tlvSize = 0; - u16 cpyCount; - - if (pQMIMessage == 0 || pOutDataBuf == 0) - { - return -ENOMEM; - } - - for (pos = 4; - pos + 3 < messageLen; - pos += tlvSize + 3) - { - tlvSize = *(u16 *)(pQMIMessage + pos + 1); - if (*(u8 *)(pQMIMessage + pos) == type) - { - if (bufferLen < tlvSize) - { - return -ENOMEM; - } - - /* replacement memcpy - memcpy( pOutDataBuf, - pQMIMessage + pos + 3, - tlvSize ); */ - - for (cpyCount = 0; cpyCount < tlvSize; cpyCount++) - { - *((char*)(pOutDataBuf + cpyCount)) = *((char*)(pQMIMessage + pos + 3 + cpyCount)); - } - - return tlvSize; - } - } - - return -ENOMSG; -} - -/*=========================================================================== -METHOD: - ValidQMIMessage (Public Method) - -DESCRIPTION: - Check mandatory TLV in a QMI message - - QMI Message shall NOT include SDU - -PARAMETERS - pQMIMessage [ I ] - QMI Message buffer - messageLen [ I ] - Size of QMI Message buffer - -RETURN VALUE: - int - 0 for success (no error) - Negative errno for error - Positive for QMI error code -===========================================================================*/ -int ValidQMIMessage( - void * pQMIMessage, - u16 messageLen ) -{ - char mandTLV[4]; - - if (GetTLV( pQMIMessage, messageLen, 2, &mandTLV[0], 4 ) == 4) - { - // Found TLV - if (*(u16 *)&mandTLV[0] != 0) - { - return *(u16 *)&mandTLV[2]; - } - else - { - return 0; - } - } - else - { - return -ENOMSG; - } -} - -/*=========================================================================== -METHOD: - GetQMIMessageID (Public Method) - -DESCRIPTION: - Get the message ID of a QMI message - - QMI Message shall NOT include SDU - -PARAMETERS - pQMIMessage [ I ] - QMI Message buffer - messageLen [ I ] - Size of QMI Message buffer - -RETURN VALUE: - int - Positive for message ID - Negative errno for error -===========================================================================*/ -int GetQMIMessageID( - void * pQMIMessage, - u16 messageLen ) -{ - if (messageLen < 2) - { - return -ENODATA; - } - else - { - return *(u16 *)pQMIMessage; - } -} - -/*=========================================================================*/ -// Fill Buffers with QMI requests -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMICTLGetClientIDReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Get Client ID Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - serviceType [ I ] - Service type requested - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -int QMICTLGetClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u8 serviceType ) -{ - if (pBuffer == 0 || buffSize < QMICTLGetClientIDReqSize() ) - { - return -ENOMEM; - } - - // QMI CTL GET CLIENT ID - // Request - *(u8 *)(pBuffer + sizeof( sQMUX ))= 0x00; - // Transaction ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 2) = 0x0022; - // Size of TLV's - *(u16 *)(pBuffer + sizeof( sQMUX ) + 4) = 0x0004; - // QMI Service Type - *(u8 *)(pBuffer + sizeof( sQMUX ) + 6) = 0x01; - // Size - *(u16 *)(pBuffer + sizeof( sQMUX ) + 7) = 0x0001; - // QMI svc type - *(u8 *)(pBuffer + sizeof( sQMUX ) + 9) = serviceType; - - // success - return sizeof( sQMUX ) + 10; -} - -/*=========================================================================== -METHOD: - QMICTLReleaseClientIDReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Release Client ID Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - clientID [ I ] - Service type requested - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -int QMICTLReleaseClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u16 clientID ) -{ - if (pBuffer == 0 || buffSize < QMICTLReleaseClientIDReqSize() ) - { - return -ENOMEM; - } - - // QMI CTL RELEASE CLIENT ID REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1 ) = transactionID; - // Message ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 2) = 0x0023; - // Size of TLV's - *(u16 *)(pBuffer + sizeof( sQMUX ) + 4) = 0x0005; - // Release client ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 6) = 0x01; - // Size - *(u16 *)(pBuffer + sizeof( sQMUX ) + 7) = 0x0002; - // QMI svs type / Client ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 9) = clientID; - - // success - return sizeof( sQMUX ) + 11; -} - -/*=========================================================================== -METHOD: - QMICTLReadyReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Get Version Info Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -int QMICTLReadyReq( - void * pBuffer, - u16 buffSize, - u8 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMICTLReadyReqSize() ) - { - return -ENOMEM; - } - - // QMI CTL GET VERSION INFO REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 2) = 0x0021; - // Size of TLV's - *(u16 *)(pBuffer + sizeof( sQMUX ) + 4) = 0x0000; - - // success - return sizeof( sQMUX ) + 6; -} - -/*=========================================================================== -METHOD: - QMIWDSSetEventReportReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI WDS Set Event Report Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -int QMIWDSSetEventReportReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMIWDSSetEventReportReqSize() ) - { - return -ENOMEM; - } - - // QMI WDS SET EVENT REPORT REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 3) = 0x0001; - // Size of TLV's - *(u16 *)(pBuffer + sizeof( sQMUX ) + 5) = 0x0008; - // Report channel rate TLV - *(u8 *)(pBuffer + sizeof( sQMUX ) + 7) = 0x11; - // Size - *(u16 *)(pBuffer + sizeof( sQMUX ) + 8) = 0x0005; - // Stats period - *(u8 *)(pBuffer + sizeof( sQMUX ) + 10) = 0x01; - // Stats mask - *(u32 *)(pBuffer + sizeof( sQMUX ) + 11) = 0x000000ff; - - // success - return sizeof( sQMUX ) + 15; -} - -/*=========================================================================== -METHOD: - QMIWDSGetPKGSRVCStatusReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI WDS Get PKG SRVC Status Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -int QMIWDSGetPKGSRVCStatusReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMIWDSGetPKGSRVCStatusReqSize() ) - { - return -ENOMEM; - } - - // QMI WDS Get PKG SRVC Status REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 3) = 0x0022; - // Size of TLV's - *(u16 *)(pBuffer + sizeof( sQMUX ) + 5) = 0x0000; - - // success - return sizeof( sQMUX ) + 7; -} - -/*=========================================================================== -METHOD: - QMIDMSGetMEIDReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI DMS Get Serial Numbers Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -int QMIDMSGetMEIDReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMIDMSGetMEIDReqSize() ) - { - return -ENOMEM; - } - - // QMI DMS GET SERIAL NUMBERS REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - *(u16 *)(pBuffer + sizeof( sQMUX ) + 3) = 0x0025; - // Size of TLV's - *(u16 *)(pBuffer + sizeof( sQMUX ) + 5) = 0x0000; - - // success - return sizeof( sQMUX ) + 7; -} - -/*=========================================================================*/ -// Parse data from QMI responses -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMICTLGetClientIDResp (Public Method) - -DESCRIPTION: - Parse the QMI CTL Get Client ID Resp - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - pClientID [ 0 ] - Recieved client ID - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int QMICTLGetClientIDResp( - void * pBuffer, - u16 buffSize, - u16 * pClientID ) -{ - int result; - - // Ignore QMUX and SDU - // QMI CTL SDU is 2 bytes, not 3 - u8 offset = sizeof( sQMUX ) + 2; - - if (pBuffer == 0 || buffSize < offset ) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x22) - { - return -EFAULT; - } - - result = ValidQMIMessage( pBuffer, buffSize ); - if (result != 0) - { - return -EFAULT; - } - - result = GetTLV( pBuffer, buffSize, 0x01, pClientID, 2 ); - if (result != 2) - { - return -EFAULT; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMICTLReleaseClientIDResp (Public Method) - -DESCRIPTION: - Verify the QMI CTL Release Client ID Resp is valid - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int QMICTLReleaseClientIDResp( - void * pBuffer, - u16 buffSize ) -{ - int result; - - // Ignore QMUX and SDU - // QMI CTL SDU is 2 bytes, not 3 - u8 offset = sizeof( sQMUX ) + 2; - - if (pBuffer == 0 || buffSize < offset ) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x23) - { - return -EFAULT; - } - - result = ValidQMIMessage( pBuffer, buffSize ); - if (result != 0) - { - return -EFAULT; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMIWDSEventResp (Public Method) - -DESCRIPTION: - Parse the QMI WDS Set Event Report Resp/Indication or - QMI WDS Get PKG SRVC Status Resp/Indication - - Return parameters will only be updated if value was received - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - pTXOk [ O ] - Number of transmitted packets without errors - pRXOk [ O ] - Number of recieved packets without errors - pTXErr [ O ] - Number of transmitted packets with framing errors - pRXErr [ O ] - Number of recieved packets with framing errors - pTXOfl [ O ] - Number of transmitted packets dropped due to overflow - pRXOfl [ O ] - Number of recieved packets dropped due to overflow - pTXBytesOk [ O ] - Number of transmitted bytes without errors - pRXBytesOk [ O ] - Number of recieved bytes without errors - pbLinkState [ 0 ] - Is the link active? - pbReconfigure [ 0 ] - Must interface be reconfigured? (reset IP address) - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int QMIWDSEventResp( - void * pBuffer, - u16 buffSize, - u32 * pTXOk, - u32 * pRXOk, - u32 * pTXErr, - u32 * pRXErr, - u32 * pTXOfl, - u32 * pRXOfl, - u64 * pTXBytesOk, - u64 * pRXBytesOk, - bool * pbLinkState, - bool * pbReconfigure ) -{ - int result; - u8 pktStatusRead[2]; - - // Ignore QMUX and SDU - u8 offset = sizeof( sQMUX ) + 3; - - if (pBuffer == 0 - || buffSize < offset - || pTXOk == 0 - || pRXOk == 0 - || pTXErr == 0 - || pRXErr == 0 - || pTXOfl == 0 - || pRXOfl == 0 - || pTXBytesOk == 0 - || pRXBytesOk == 0 - || pbLinkState == 0 - || pbReconfigure == 0 ) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - // Note: Indications. No Mandatory TLV required - - result = GetQMIMessageID( pBuffer, buffSize ); - // QMI WDS Set Event Report Resp - if (result == 0x01) - { - // TLV's are not mandatory - GetTLV( pBuffer, buffSize, 0x10, (void*)pTXOk, 4 ); - GetTLV( pBuffer, buffSize, 0x11, (void*)pRXOk, 4 ); - GetTLV( pBuffer, buffSize, 0x12, (void*)pTXErr, 4 ); - GetTLV( pBuffer, buffSize, 0x13, (void*)pRXErr, 4 ); - GetTLV( pBuffer, buffSize, 0x14, (void*)pTXOfl, 4 ); - GetTLV( pBuffer, buffSize, 0x15, (void*)pRXOfl, 4 ); - GetTLV( pBuffer, buffSize, 0x19, (void*)pTXBytesOk, 8 ); - GetTLV( pBuffer, buffSize, 0x1A, (void*)pRXBytesOk, 8 ); - } - // QMI WDS Get PKG SRVC Status Resp - else if (result == 0x22) - { - result = GetTLV( pBuffer, buffSize, 0x01, &pktStatusRead[0], 2 ); - // 1 or 2 bytes may be received - if (result >= 1) - { - if (pktStatusRead[0] == 0x02) - { - *pbLinkState = true; - } - else - { - *pbLinkState = false; - } - } - if (result == 2) - { - if (pktStatusRead[1] == 0x01) - { - *pbReconfigure = true; - } - else - { - *pbReconfigure = false; - } - } - - if (result < 0) - { - return result; - } - } - else - { - return -EFAULT; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMIDMSGetMEIDResp (Public Method) - -DESCRIPTION: - Parse the QMI DMS Get Serial Numbers Resp - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - pMEID [ O ] - Device MEID - meidSize [ I ] - Size of MEID buffer (at least 14) - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -int QMIDMSGetMEIDResp( - void * pBuffer, - u16 buffSize, - char * pMEID, - int meidSize ) -{ - int result; - - // Ignore QMUX and SDU - u8 offset = sizeof( sQMUX ) + 3; - - if (pBuffer == 0 || buffSize < offset || meidSize < 14 ) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x25) - { - return -EFAULT; - } - - result = ValidQMIMessage( pBuffer, buffSize ); - if (result != 0) - { - return -EFAULT; - } - - result = GetTLV( pBuffer, buffSize, 0x12, (void*)pMEID, 14 ); - if (result != 14) - { - return -EFAULT; - } - - return 0; -} - diff --git a/drivers/staging/gobi/QCUSBNet2k/QMI.h b/drivers/staging/gobi/QCUSBNet2k/QMI.h deleted file mode 100644 index 633d2983bc870740d72cc7548c0f7578d02fb00b..0000000000000000000000000000000000000000 --- a/drivers/staging/gobi/QCUSBNet2k/QMI.h +++ /dev/null @@ -1,251 +0,0 @@ -/*=========================================================================== -FILE: - QMI.h - -DESCRIPTION: - Qualcomm QMI driver header - -FUNCTIONS: - Generic QMUX functions - ParseQMUX - FillQMUX - - Generic QMI functions - GetTLV - ValidQMIMessage - GetQMIMessageID - - Get sizes of buffers needed by QMI requests - QMUXHeaderSize - QMICTLGetClientIDReqSize - QMICTLReleaseClientIDReqSize - QMICTLReadyReqSize - QMIWDSSetEventReportReqSize - QMIWDSGetPKGSRVCStatusReqSize - QMIDMSGetMEIDReqSize - - Fill Buffers with QMI requests - QMICTLGetClientIDReq - QMICTLReleaseClientIDReq - QMICTLReadyReq - QMIWDSSetEventReportReq - QMIWDSGetPKGSRVCStatusReq - QMIDMSGetMEIDReq - - Parse data from QMI responses - QMICTLGetClientIDResp - QMICTLReleaseClientIDResp - QMIWDSEventResp - QMIDMSGetMEIDResp - -Copyright (c) 2010, 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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -===========================================================================*/ - -#pragma once - -/*=========================================================================*/ -// Definitions -/*=========================================================================*/ - -// QMI Service Types -#define QMICTL 0 -#define QMIWDS 1 -#define QMIDMS 2 - -#define u8 unsigned char -#define u16 unsigned short -#define u32 unsigned int -#define u64 unsigned long long - -#define bool u8 -#define true 1 -#define false 0 - -#define ENOMEM 12 -#define EFAULT 14 -#define EINVAL 22 -#define ENOMSG 42 -#define ENODATA 61 - -/*=========================================================================*/ -// Struct sQMUX -// -// Structure that defines a QMUX header -/*=========================================================================*/ -typedef struct sQMUX -{ - /* T\F, always 1 */ - u8 mTF; - - /* Size of message */ - u16 mLength; - - /* Control flag */ - u8 mCtrlFlag; - - /* Service Type */ - u8 mQMIService; - - /* Client ID */ - u8 mQMIClientID; - -}__attribute__((__packed__)) sQMUX; - -/*=========================================================================*/ -// Generic QMUX functions -/*=========================================================================*/ - -// Remove QMUX headers from a buffer -int ParseQMUX( - u16 * pClientID, - void * pBuffer, - u16 buffSize ); - -// Fill buffer with QMUX headers -int FillQMUX( - u16 clientID, - void * pBuffer, - u16 buffSize ); - -/*=========================================================================*/ -// Generic QMI functions -/*=========================================================================*/ - -// Get data bufffer of a specified TLV from a QMI message -u16 GetTLV( - void * pQMIMessage, - u16 messageLen, - u8 type, - void * pOutDataBuf, - u16 bufferLen ); - -// Check mandatory TLV in a QMI message -int ValidQMIMessage( - void * pQMIMessage, - u16 messageLen ); - -// Get the message ID of a QMI message -int GetQMIMessageID( - void * pQMIMessage, - u16 messageLen ); - -/*=========================================================================*/ -// Get sizes of buffers needed by QMI requests -/*=========================================================================*/ - -// Get size of buffer needed for QMUX -u16 QMUXHeaderSize( void ); - -// Get size of buffer needed for QMUX + QMICTLGetClientIDReq -u16 QMICTLGetClientIDReqSize( void ); - -// Get size of buffer needed for QMUX + QMICTLReleaseClientIDReq -u16 QMICTLReleaseClientIDReqSize( void ); - -// Get size of buffer needed for QMUX + QMICTLReadyReq -u16 QMICTLReadyReqSize( void ); - -// Get size of buffer needed for QMUX + QMIWDSSetEventReportReq -u16 QMIWDSSetEventReportReqSize( void ); - -// Get size of buffer needed for QMUX + QMIWDSGetPKGSRVCStatusReq -u16 QMIWDSGetPKGSRVCStatusReqSize( void ); - -// Get size of buffer needed for QMUX + QMIDMSGetMEIDReq -u16 QMIDMSGetMEIDReqSize( void ); - -/*=========================================================================*/ -// Fill Buffers with QMI requests -/*=========================================================================*/ - -// Fill buffer with QMI CTL Get Client ID Request -int QMICTLGetClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u8 serviceType ); - -// Fill buffer with QMI CTL Release Client ID Request -int QMICTLReleaseClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u16 clientID ); - -// Fill buffer with QMI CTL Get Version Info Request -int QMICTLReadyReq( - void * pBuffer, - u16 buffSize, - u8 transactionID ); - -// Fill buffer with QMI WDS Set Event Report Request -int QMIWDSSetEventReportReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); - -// Fill buffer with QMI WDS Get PKG SRVC Status Request -int QMIWDSGetPKGSRVCStatusReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); - -// Fill buffer with QMI DMS Get Serial Numbers Request -int QMIDMSGetMEIDReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); - -/*=========================================================================*/ -// Parse data from QMI responses -/*=========================================================================*/ - -// Parse the QMI CTL Get Client ID Resp -int QMICTLGetClientIDResp( - void * pBuffer, - u16 buffSize, - u16 * pClientID ); - -// Verify the QMI CTL Release Client ID Resp is valid -int QMICTLReleaseClientIDResp( - void * pBuffer, - u16 buffSize ); - -// Parse the QMI WDS Set Event Report Resp/Indication or -// QMI WDS Get PKG SRVC Status Resp/Indication -int QMIWDSEventResp( - void * pBuffer, - u16 buffSize, - u32 * pTXOk, - u32 * pRXOk, - u32 * pTXErr, - u32 * pRXErr, - u32 * pTXOfl, - u32 * pRXOfl, - u64 * pTXBytesOk, - u64 * pRXBytesOk, - bool * pbLinkState, - bool * pbReconfigure ); - -// Parse the QMI DMS Get Serial Numbers Resp -int QMIDMSGetMEIDResp( - void * pBuffer, - u16 buffSize, - char * pMEID, - int meidSize ); - diff --git a/drivers/staging/gobi/QCUSBNet2k/QMIDevice.c b/drivers/staging/gobi/QCUSBNet2k/QMIDevice.c deleted file mode 100644 index dbe4bb27c56efcce777c3e5dad7096ad986eb87a..0000000000000000000000000000000000000000 --- a/drivers/staging/gobi/QCUSBNet2k/QMIDevice.c +++ /dev/null @@ -1,3129 +0,0 @@ -/*=========================================================================== -FILE: - QMIDevice.c - -DESCRIPTION: - Functions related to the QMI interface device - -FUNCTIONS: - Generic functions - IsDeviceValid - PrintHex - QSetDownReason - QClearDownReason - QTestDownReason - - Driver level asynchronous read functions - ReadCallback - IntCallback - StartRead - KillRead - - Internal read/write functions - ReadAsync - UpSem - ReadSync - WriteSyncCallback - WriteSync - - Internal memory management functions - GetClientID - ReleaseClientID - FindClientMem - AddToReadMemList - PopFromReadMemList - AddToNotifyList - NotifyAndPopNotifyList - AddToURBList - PopFromURBList - - Userspace wrappers - UserspaceOpen - UserspaceIOCTL - UserspaceClose - UserspaceRead - UserspaceWrite - - Initializer and destructor - RegisterQMIDevice - DeregisterQMIDevice - - Driver level client management - QMIReady - QMIWDSCallback - SetupQMIWDSCallback - QMIDMSGetMEID - -Copyright (c) 2010, 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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include "QMIDevice.h" - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -extern int debug; - -// Prototype to QCSuspend function -int QCSuspend( - struct usb_interface * pIntf, - pm_message_t powerEvent ); - -// IOCTL to generate a client ID for this service type -#define IOCTL_QMI_GET_SERVICE_FILE 0x8BE0 + 1 - -// IOCTL to get the VIDPID of the device -#define IOCTL_QMI_GET_DEVICE_VIDPID 0x8BE0 + 2 - -// IOCTL to get the MEID of the device -#define IOCTL_QMI_GET_DEVICE_MEID 0x8BE0 + 3 - -// CDC GET_ENCAPSULATED_RESPONSE packet -#define CDC_GET_ENCAPSULATED_RESPONSE 0x01A1ll - -// CDC CONNECTION_SPEED_CHANGE indication packet -#define CDC_CONNECTION_SPEED_CHANGE 0x08000000002AA1ll - -/*=========================================================================*/ -// UserspaceQMIFops -// QMI device's userspace file operations -/*=========================================================================*/ -struct file_operations UserspaceQMIFops = -{ - .owner = THIS_MODULE, - .read = UserspaceRead, - .write = UserspaceWrite, - .ioctl = UserspaceIOCTL, - .open = UserspaceOpen, - .flush = UserspaceClose, -}; - -/*=========================================================================*/ -// Generic functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - IsDeviceValid (Public Method) - -DESCRIPTION: - Basic test to see if device memory is valid - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - bool -===========================================================================*/ -bool IsDeviceValid( sQCUSBNet * pDev ) -{ - if (pDev == NULL) - { - return false; - } - - if (pDev->mbQMIValid == false) - { - return false; - } - - return true; -} - -/*=========================================================================== -METHOD: - PrintHex (Public Method) - -DESCRIPTION: - Print Hex data, for debug purposes - -PARAMETERS: - pBuffer [ I ] - Data buffer - bufSize [ I ] - Size of data buffer - -RETURN VALUE: - None -===========================================================================*/ -void PrintHex( - void * pBuffer, - u16 bufSize ) -{ - char * pPrintBuf; - u16 pos; - int status; - - pPrintBuf = kmalloc( bufSize * 3 + 1, GFP_ATOMIC ); - if (pPrintBuf == NULL) - { - DBG( "Unable to allocate buffer\n" ); - return; - } - memset( pPrintBuf, 0 , bufSize * 3 + 1 ); - - for (pos = 0; pos < bufSize; pos++) - { - status = snprintf( (pPrintBuf + (pos * 3)), - 4, - "%02X ", - *(u8 *)(pBuffer + pos) ); - if (status != 3) - { - DBG( "snprintf error %d\n", status ); - return; - } - } - - DBG( " : %s\n", pPrintBuf ); - - kfree( pPrintBuf ); - pPrintBuf = NULL; - return; -} - -/*=========================================================================== -METHOD: - QSetDownReason (Public Method) - -DESCRIPTION: - Sets mDownReason and turns carrier off - -PARAMETERS - pDev [ I ] - Device specific memory - reason [ I ] - Reason device is down - -RETURN VALUE: - None -===========================================================================*/ -void QSetDownReason( - sQCUSBNet * pDev, - u8 reason ) -{ - set_bit( reason, &pDev->mDownReason ); - - netif_carrier_off( pDev->mpNetDev->net ); -} - -/*=========================================================================== -METHOD: - QClearDownReason (Public Method) - -DESCRIPTION: - Clear mDownReason and may turn carrier on - -PARAMETERS - pDev [ I ] - Device specific memory - reason [ I ] - Reason device is no longer down - -RETURN VALUE: - None -===========================================================================*/ -void QClearDownReason( - sQCUSBNet * pDev, - u8 reason ) -{ - clear_bit( reason, &pDev->mDownReason ); - - if (pDev->mDownReason == 0) - { - netif_carrier_on( pDev->mpNetDev->net ); - } -} - -/*=========================================================================== -METHOD: - QTestDownReason (Public Method) - -DESCRIPTION: - Test mDownReason and returns whether reason is set - -PARAMETERS - pDev [ I ] - Device specific memory - reason [ I ] - Reason device is down - -RETURN VALUE: - bool -===========================================================================*/ -bool QTestDownReason( - sQCUSBNet * pDev, - u8 reason ) -{ - return test_bit( reason, &pDev->mDownReason ); -} - -/*=========================================================================*/ -// Driver level asynchronous read functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - ReadCallback (Public Method) - -DESCRIPTION: - Put the data in storage and notify anyone waiting for data - -PARAMETERS - pReadURB [ I ] - URB this callback is run for - -RETURN VALUE: - None -===========================================================================*/ -void ReadCallback( struct urb * pReadURB ) -{ - int result; - u16 clientID; - sClientMemList * pClientMem; - void * pData; - void * pDataCopy; - u16 dataSize; - sQCUSBNet * pDev; - unsigned long flags; - u16 transactionID; - - if (pReadURB == NULL) - { - DBG( "bad read URB\n" ); - return; - } - - pDev = pReadURB->context; - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return; - } - - if (pReadURB->status != 0) - { - DBG( "Read status = %d\n", pReadURB->status ); - return; - } - DBG( "Read %d bytes\n", pReadURB->actual_length ); - - pData = pReadURB->transfer_buffer; - dataSize = pReadURB->actual_length; - - PrintHex( pData, dataSize ); - - result = ParseQMUX( &clientID, - pData, - dataSize ); - if (result < 0) - { - DBG( "Read error parsing QMUX %d\n", result ); - return; - } - - // Grab transaction ID - - // Data large enough? - if (dataSize < result + 3) - { - DBG( "Data buffer too small to parse\n" ); - return; - } - - // Transaction ID size is 1 for QMICTL, 2 for others - if (clientID == QMICTL) - { - transactionID = *(u8*)(pData + result + 1); - } - else - { - transactionID = *(u16*)(pData + result + 1); - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Find memory storage for this service and Client ID - // Not using FindClientMem because it can't handle broadcasts - pClientMem = pDev->mQMIDev.mpClientMemList; - while (pClientMem != NULL) - { - if (pClientMem->mClientID == clientID - || (pClientMem->mClientID | 0xff00) == clientID) - { - // Make copy of pData - pDataCopy = kmalloc( dataSize, GFP_ATOMIC ); - memcpy( pDataCopy, pData, dataSize ); - - if (AddToReadMemList( pDev, - pClientMem->mClientID, - transactionID, - pDataCopy, - dataSize ) == false) - { - DBG( "Error allocating pReadMemListEntry " - "read will be discarded\n" ); - kfree( pDataCopy ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return; - } - - // Success - DBG( "Creating new readListEntry for client 0x%04X, TID %x\n", - clientID, - transactionID ); - - // Notify this client data exists - NotifyAndPopNotifyList( pDev, - pClientMem->mClientID, - transactionID ); - - // Not a broadcast - if (clientID >> 8 != 0xff) - { - break; - } - } - - // Next element - pClientMem = pClientMem->mpNext; - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); -} - -/*=========================================================================== -METHOD: - IntCallback (Public Method) - -DESCRIPTION: - Data is available, fire off a read URB - -PARAMETERS - pIntURB [ I ] - URB this callback is run for - -RETURN VALUE: - None -===========================================================================*/ -void IntCallback( struct urb * pIntURB ) -{ - int status; - int interval; - - sQCUSBNet * pDev = (sQCUSBNet *)pIntURB->context; - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return; - } - - // Verify this was a normal interrupt - if (pIntURB->status != 0) - { - DBG( "Int status = %d\n", pIntURB->status ); - - // Ignore EOVERFLOW errors - if (pIntURB->status != -EOVERFLOW) - { - // Read 'thread' dies here - return; - } - } - else - { - // CDC GET_ENCAPSULATED_RESPONSE - if ((pIntURB->actual_length == 8) - && (*(u64*)pIntURB->transfer_buffer == CDC_GET_ENCAPSULATED_RESPONSE)) - { - // Time to read - usb_fill_control_urb( pDev->mQMIDev.mpReadURB, - pDev->mpNetDev->udev, - usb_rcvctrlpipe( pDev->mpNetDev->udev, 0 ), - (unsigned char *)pDev->mQMIDev.mpReadSetupPacket, - pDev->mQMIDev.mpReadBuffer, - DEFAULT_READ_URB_LENGTH, - ReadCallback, - pDev ); - status = usb_submit_urb( pDev->mQMIDev.mpReadURB, GFP_ATOMIC ); - if (status != 0) - { - DBG( "Error submitting Read URB %d\n", status ); - return; - } - } - // CDC CONNECTION_SPEED_CHANGE - else if ((pIntURB->actual_length == 16) - && (*(u64*)pIntURB->transfer_buffer == CDC_CONNECTION_SPEED_CHANGE)) - { - // if upstream or downstream is 0, stop traffic. Otherwise resume it - if ((*(u32*)(pIntURB->transfer_buffer + 8) == 0) - || (*(u32*)(pIntURB->transfer_buffer + 12) == 0)) - { - QSetDownReason( pDev, CDC_CONNECTION_SPEED ); - DBG( "traffic stopping due to CONNECTION_SPEED_CHANGE\n" ); - } - else - { - QClearDownReason( pDev, CDC_CONNECTION_SPEED ); - DBG( "resuming traffic due to CONNECTION_SPEED_CHANGE\n" ); - } - } - else - { - DBG( "ignoring invalid interrupt in packet\n" ); - PrintHex( pIntURB->transfer_buffer, pIntURB->actual_length ); - } - } - - interval = (pDev->mpNetDev->udev->speed == USB_SPEED_HIGH) ? 7 : 3; - - // Reschedule interrupt URB - usb_fill_int_urb( pIntURB, - pIntURB->dev, - pIntURB->pipe, - pIntURB->transfer_buffer, - pIntURB->transfer_buffer_length, - pIntURB->complete, - pIntURB->context, - interval ); - status = usb_submit_urb( pIntURB, GFP_ATOMIC ); - if (status != 0) - { - DBG( "Error re-submitting Int URB %d\n", status ); - } - return; -} - -/*=========================================================================== -METHOD: - StartRead (Public Method) - -DESCRIPTION: - Start continuous read "thread" (callback driven) - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -int StartRead( sQCUSBNet * pDev ) -{ - int interval; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Allocate URB buffers - pDev->mQMIDev.mpReadURB = usb_alloc_urb( 0, GFP_KERNEL ); - if (pDev->mQMIDev.mpReadURB == NULL) - { - DBG( "Error allocating read urb\n" ); - return -ENOMEM; - } - - pDev->mQMIDev.mpIntURB = usb_alloc_urb( 0, GFP_KERNEL ); - if (pDev->mQMIDev.mpIntURB == NULL) - { - DBG( "Error allocating int urb\n" ); - return -ENOMEM; - } - - // Create data buffers - pDev->mQMIDev.mpReadBuffer = kmalloc( DEFAULT_READ_URB_LENGTH, GFP_KERNEL ); - if (pDev->mQMIDev.mpReadBuffer == NULL) - { - DBG( "Error allocating read buffer\n" ); - return -ENOMEM; - } - - pDev->mQMIDev.mpIntBuffer = kmalloc( DEFAULT_READ_URB_LENGTH, GFP_KERNEL ); - if (pDev->mQMIDev.mpIntBuffer == NULL) - { - DBG( "Error allocating int buffer\n" ); - return -ENOMEM; - } - - pDev->mQMIDev.mpReadSetupPacket = kmalloc( sizeof( sURBSetupPacket ), - GFP_KERNEL ); - if (pDev->mQMIDev.mpReadSetupPacket == NULL) - { - DBG( "Error allocating setup packet buffer\n" ); - return -ENOMEM; - } - - // CDC Get Encapsulated Response packet - pDev->mQMIDev.mpReadSetupPacket->mRequestType = 0xA1; - pDev->mQMIDev.mpReadSetupPacket->mRequestCode = 1; - pDev->mQMIDev.mpReadSetupPacket->mValue = 0; - pDev->mQMIDev.mpReadSetupPacket->mIndex = 0; - pDev->mQMIDev.mpReadSetupPacket->mLength = DEFAULT_READ_URB_LENGTH; - - interval = (pDev->mpNetDev->udev->speed == USB_SPEED_HIGH) ? 7 : 3; - - // Schedule interrupt URB - usb_fill_int_urb( pDev->mQMIDev.mpIntURB, - pDev->mpNetDev->udev, - usb_rcvintpipe( pDev->mpNetDev->udev, 0x81 ), - pDev->mQMIDev.mpIntBuffer, - DEFAULT_READ_URB_LENGTH, - IntCallback, - pDev, - interval ); - return usb_submit_urb( pDev->mQMIDev.mpIntURB, GFP_KERNEL ); -} - -/*=========================================================================== -METHOD: - KillRead (Public Method) - -DESCRIPTION: - Kill continuous read "thread" - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - None -===========================================================================*/ -void KillRead( sQCUSBNet * pDev ) -{ - // Stop reading - if (pDev->mQMIDev.mpReadURB != NULL) - { - DBG( "Killng read URB\n" ); - usb_kill_urb( pDev->mQMIDev.mpReadURB ); - } - - if (pDev->mQMIDev.mpIntURB != NULL) - { - DBG( "Killng int URB\n" ); - usb_kill_urb( pDev->mQMIDev.mpIntURB ); - } - - // Release buffers - kfree( pDev->mQMIDev.mpReadSetupPacket ); - pDev->mQMIDev.mpReadSetupPacket = NULL; - kfree( pDev->mQMIDev.mpReadBuffer ); - pDev->mQMIDev.mpReadBuffer = NULL; - kfree( pDev->mQMIDev.mpIntBuffer ); - pDev->mQMIDev.mpIntBuffer = NULL; - - // Release URB's - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - usb_free_urb( pDev->mQMIDev.mpIntURB ); - pDev->mQMIDev.mpIntURB = NULL; -} - -/*=========================================================================*/ -// Internal read/write functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - ReadAsync (Public Method) - -DESCRIPTION: - Start asynchronous read - NOTE: Reading client's data store, not device - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - pCallback [ I ] - Callback to be executed when data is available - pData [ I ] - Data buffer that willl be passed (unmodified) - to callback - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -int ReadAsync( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (*pCallback)(sQCUSBNet*, u16, void *), - void * pData ) -{ - sClientMemList * pClientMem; - sReadMemList ** ppReadMemList; - - unsigned long flags; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Find memory storage for this client ID - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find matching client ID 0x%04X\n", - clientID ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ENXIO; - } - - ppReadMemList = &(pClientMem->mpList); - - // Does data already exist? - while (*ppReadMemList != NULL) - { - // Is this element our data? - if (transactionID == 0 - || transactionID == (*ppReadMemList)->mTransactionID) - { - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Run our own callback - pCallback( pDev, clientID, pData ); - - return 0; - } - - // Next - ppReadMemList = &(*ppReadMemList)->mpNext; - } - - // Data not found, add ourself to list of waiters - if (AddToNotifyList( pDev, - clientID, - transactionID, - pCallback, - pData ) == false) - { - DBG( "Unable to register for notification\n" ); - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Success - return 0; -} - -/*=========================================================================== -METHOD: - UpSem (Public Method) - -DESCRIPTION: - Notification function for synchronous read - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - pData [ I ] - Buffer that holds semaphore to be up()-ed - -RETURN VALUE: - None -===========================================================================*/ -void UpSem( - sQCUSBNet * pDev, - u16 clientID, - void * pData ) -{ - DBG( "0x%04X\n", clientID ); - - up( (struct semaphore *)pData ); - return; -} - -/*=========================================================================== -METHOD: - ReadSync (Public Method) - -DESCRIPTION: - Start synchronous read - NOTE: Reading client's data store, not device - -PARAMETERS: - pDev [ I ] - Device specific memory - ppOutBuffer [I/O] - On success, will be filled with a - pointer to read buffer - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - -RETURN VALUE: - int - size of data read for success - negative errno for failure -===========================================================================*/ -int ReadSync( - sQCUSBNet * pDev, - void ** ppOutBuffer, - u16 clientID, - u16 transactionID ) -{ - int result; - sClientMemList * pClientMem; - sNotifyList ** ppNotifyList, * pDelNotifyListEntry; - struct semaphore readSem; - void * pData; - unsigned long flags; - u16 dataSize; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Find memory storage for this Client ID - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find matching client ID 0x%04X\n", - clientID ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ENXIO; - } - - // Note: in cases where read is interrupted, - // this will verify client is still valid - while (PopFromReadMemList( pDev, - clientID, - transactionID, - &pData, - &dataSize ) == false) - { - // Data does not yet exist, wait - sema_init( &readSem, 0 ); - - // Add ourself to list of waiters - if (AddToNotifyList( pDev, - clientID, - transactionID, - UpSem, - &readSem ) == false) - { - DBG( "unable to register for notification\n" ); - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -EFAULT; - } - - // End critical section while we block - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Wait for notification - result = down_interruptible( &readSem ); - if (result != 0) - { - DBG( "Interrupted %d\n", result ); - - // readSem will fall out of scope, - // remove from notify list so it's not referenced - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - ppNotifyList = &(pClientMem->mpReadNotifyList); - pDelNotifyListEntry = NULL; - - // Find and delete matching entry - while (*ppNotifyList != NULL) - { - if ((*ppNotifyList)->mpData == &readSem) - { - pDelNotifyListEntry = *ppNotifyList; - *ppNotifyList = (*ppNotifyList)->mpNext; - kfree( pDelNotifyListEntry ); - break; - } - - // Next - ppNotifyList = &(*ppNotifyList)->mpNext; - } - - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -EINTR; - } - - // Verify device is still valid - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Restart critical section and continue loop - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - } - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Success - *ppOutBuffer = pData; - - return dataSize; -} - -/*=========================================================================== -METHOD: - WriteSyncCallback (Public Method) - -DESCRIPTION: - Write callback - -PARAMETERS - pWriteURB [ I ] - URB this callback is run for - -RETURN VALUE: - None -===========================================================================*/ -void WriteSyncCallback( struct urb * pWriteURB ) -{ - if (pWriteURB == NULL) - { - DBG( "null urb\n" ); - return; - } - - DBG( "Write status/size %d/%d\n", - pWriteURB->status, - pWriteURB->actual_length ); - - // Notify that write has completed by up()-ing semeaphore - up( (struct semaphore * )pWriteURB->context ); - - return; -} - -/*=========================================================================== -METHOD: - WriteSync (Public Method) - -DESCRIPTION: - Start synchronous write - -PARAMETERS: - pDev [ I ] - Device specific memory - pWriteBuffer [ I ] - Data to be written - writeBufferSize [ I ] - Size of data to be written - clientID [ I ] - Client ID of requester - -RETURN VALUE: - int - write size (includes QMUX) - negative errno for failure -===========================================================================*/ -int WriteSync( - sQCUSBNet * pDev, - char * pWriteBuffer, - int writeBufferSize, - u16 clientID ) -{ - int result; - struct semaphore writeSem; - struct urb * pWriteURB; - sURBSetupPacket writeSetup; - unsigned long flags; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - pWriteURB = usb_alloc_urb( 0, GFP_KERNEL ); - if (pWriteURB == NULL) - { - DBG( "URB mem error\n" ); - return -ENOMEM; - } - - // Fill writeBuffer with QMUX - result = FillQMUX( clientID, pWriteBuffer, writeBufferSize ); - if (result < 0) - { - usb_free_urb( pWriteURB ); - return result; - } - - // CDC Send Encapsulated Request packet - writeSetup.mRequestType = 0x21; - writeSetup.mRequestCode = 0; - writeSetup.mValue = 0; - writeSetup.mIndex = 0; - writeSetup.mLength = 0; - writeSetup.mLength = writeBufferSize; - - // Create URB - usb_fill_control_urb( pWriteURB, - pDev->mpNetDev->udev, - usb_sndctrlpipe( pDev->mpNetDev->udev, 0 ), - (unsigned char *)&writeSetup, - (void*)pWriteBuffer, - writeBufferSize, - NULL, - pDev ); - - DBG( "Actual Write:\n" ); - PrintHex( pWriteBuffer, writeBufferSize ); - - sema_init( &writeSem, 0 ); - - pWriteURB->complete = WriteSyncCallback; - pWriteURB->context = &writeSem; - - // Wake device - result = usb_autopm_get_interface( pDev->mpIntf ); - if (result < 0) - { - DBG( "unable to resume interface: %d\n", result ); - - // Likely caused by device going from autosuspend -> full suspend - if (result == -EPERM) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) - pDev->mpNetDev->udev->auto_pm = 0; -#endif - QCSuspend( pDev->mpIntf, PMSG_SUSPEND ); - } - - return result; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - if (AddToURBList( pDev, clientID, pWriteURB ) == false) - { - usb_free_urb( pWriteURB ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - usb_autopm_put_interface( pDev->mpIntf ); - return -EINVAL; - } - - result = usb_submit_urb( pWriteURB, GFP_KERNEL ); - if (result < 0) - { - DBG( "submit URB error %d\n", result ); - - // Get URB back so we can destroy it - if (PopFromURBList( pDev, clientID ) != pWriteURB) - { - // This shouldn't happen - DBG( "Didn't get write URB back\n" ); - } - - usb_free_urb( pWriteURB ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - usb_autopm_put_interface( pDev->mpIntf ); - return result; - } - - // End critical section while we block - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Wait for write to finish - result = down_interruptible( &writeSem ); - - // Verify device is still valid - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Write is done, release device - usb_autopm_put_interface( pDev->mpIntf ); - - // Restart critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Get URB back so we can destroy it - if (PopFromURBList( pDev, clientID ) != pWriteURB) - { - // This shouldn't happen - DBG( "Didn't get write URB back\n" ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -EINVAL; - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - if (result == 0) - { - // Write is finished - if (pWriteURB->status == 0) - { - // Return number of bytes that were supposed to have been written, - // not size of QMI request - result = writeBufferSize; - } - else - { - DBG( "bad status = %d\n", pWriteURB->status ); - - // Return error value - result = pWriteURB->status; - } - } - else - { - // We have been forcibly interrupted - DBG( "Interrupted %d !!!\n", result ); - DBG( "Device may be in bad state and need reset !!!\n" ); - - // URB has not finished - usb_kill_urb( pWriteURB ); - } - - usb_free_urb( pWriteURB ); - - return result; -} - -/*=========================================================================*/ -// Internal memory management functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - GetClientID (Public Method) - -DESCRIPTION: - Construct object/load file into memory - -PARAMETERS: - pDev [ I ] - Device specific memory - serviceType [ I ] - Desired QMI service type - -RETURN VALUE: - int - Client ID for success (positive) - Negative errno for error -===========================================================================*/ -int GetClientID( - sQCUSBNet * pDev, - u8 serviceType ) -{ - u16 clientID; - sClientMemList ** ppClientMem; - int result; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - unsigned long flags; - u8 transactionID; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Run QMI request to be asigned a Client ID - if (serviceType != 0) - { - writeBufferSize = QMICTLGetClientIDReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - transactionID = atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID ); - if (transactionID == 0) - { - atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID ); - } - result = QMICTLGetClientIDReq( pWriteBuffer, - writeBufferSize, - transactionID, - serviceType ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - QMICTL ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - result = ReadSync( pDev, - &pReadBuffer, - QMICTL, - transactionID ); - if (result < 0) - { - DBG( "bad read data %d\n", result ); - return result; - } - readBufferSize = result; - - result = QMICTLGetClientIDResp( pReadBuffer, - readBufferSize, - &clientID ); - kfree( pReadBuffer ); - - if (result < 0) - { - return result; - } - } - else - { - // QMI CTL will always have client ID 0 - clientID = 0; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Verify client is not already allocated - if (FindClientMem( pDev, clientID ) != NULL) - { - DBG( "Client memory already exists\n" ); - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ETOOMANYREFS; - } - - // Go to last entry in client mem list - ppClientMem = &pDev->mQMIDev.mpClientMemList; - while (*ppClientMem != NULL) - { - ppClientMem = &(*ppClientMem)->mpNext; - } - - // Create locations for read to place data into - *ppClientMem = kmalloc( sizeof( sClientMemList ), GFP_ATOMIC ); - if (*ppClientMem == NULL) - { - DBG( "Error allocating read list\n" ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ENOMEM; - } - - (*ppClientMem)->mClientID = clientID; - (*ppClientMem)->mpList = NULL; - (*ppClientMem)->mpReadNotifyList = NULL; - (*ppClientMem)->mpURBList = NULL; - (*ppClientMem)->mpNext = NULL; - - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - return clientID; -} - -/*=========================================================================== -METHOD: - ReleaseClientID (Public Method) - -DESCRIPTION: - Release QMI client and free memory - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - -RETURN VALUE: - None -===========================================================================*/ -void ReleaseClientID( - sQCUSBNet * pDev, - u16 clientID ) -{ - int result; - sClientMemList ** ppDelClientMem; - sClientMemList * pNextClientMem; - struct urb * pDelURB; - void * pDelData; - u16 dataSize; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - unsigned long flags; - u8 transactionID; - - // Is device is still valid? - if (IsDeviceValid( pDev ) == false) - { - DBG( "invalid device\n" ); - return; - } - - DBG( "releasing 0x%04X\n", clientID ); - - // Run QMI ReleaseClientID if this isn't QMICTL - if (clientID != QMICTL) - { - // Note: all errors are non fatal, as we always want to delete - // client memory in latter part of function - - writeBufferSize = QMICTLReleaseClientIDReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - DBG( "memory error\n" ); - } - else - { - transactionID = atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID ); - if (transactionID == 0) - { - transactionID = atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID ); - } - result = QMICTLReleaseClientIDReq( pWriteBuffer, - writeBufferSize, - transactionID, - clientID ); - if (result < 0) - { - kfree( pWriteBuffer ); - DBG( "error %d filling req buffer\n", result ); - } - else - { - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - QMICTL ); - kfree( pWriteBuffer ); - - if (result < 0) - { - DBG( "bad write status %d\n", result ); - } - else - { - result = ReadSync( pDev, - &pReadBuffer, - QMICTL, - transactionID ); - if (result < 0) - { - DBG( "bad read status %d\n", result ); - } - else - { - readBufferSize = result; - - result = QMICTLReleaseClientIDResp( pReadBuffer, - readBufferSize ); - kfree( pReadBuffer ); - - if (result < 0) - { - DBG( "error %d parsing response\n", result ); - } - } - } - } - } - } - - // Cleaning up client memory - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Can't use FindClientMem, I need to keep pointer of previous - ppDelClientMem = &pDev->mQMIDev.mpClientMemList; - while (*ppDelClientMem != NULL) - { - if ((*ppDelClientMem)->mClientID == clientID) - { - pNextClientMem = (*ppDelClientMem)->mpNext; - - // Notify all clients - while (NotifyAndPopNotifyList( pDev, - clientID, - 0 ) == true ); - - // Kill and free all URB's - pDelURB = PopFromURBList( pDev, clientID ); - while (pDelURB != NULL) - { - usb_kill_urb( pDelURB ); - usb_free_urb( pDelURB ); - pDelURB = PopFromURBList( pDev, clientID ); - } - - // Free any unread data - while (PopFromReadMemList( pDev, - clientID, - 0, - &pDelData, - &dataSize ) == true ) - { - kfree( pDelData ); - } - - // Delete client Mem - kfree( *ppDelClientMem ); - - // Overwrite the pointer that was to this client mem - *ppDelClientMem = pNextClientMem; - } - else - { - // I now point to ( a pointer of ((the node I was at)'s mpNext)) - ppDelClientMem = &(*ppDelClientMem)->mpNext; - } - } - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - return; -} - -/*=========================================================================== -METHOD: - FindClientMem (Public Method) - -DESCRIPTION: - Find this client's memory - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - -RETURN VALUE: - sClientMemList - Pointer to requested sClientMemList for success - NULL for error -===========================================================================*/ -sClientMemList * FindClientMem( - sQCUSBNet * pDev, - u16 clientID ) -{ - sClientMemList * pClientMem; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return NULL; - } - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - pClientMem = pDev->mQMIDev.mpClientMemList; - while (pClientMem != NULL) - { - if (pClientMem->mClientID == clientID) - { - // Success - //DBG( "Found client mem %p\n", pClientMem ); - return pClientMem; - } - - pClientMem = pClientMem->mpNext; - } - - DBG( "Could not find client mem 0x%04X\n", clientID ); - return NULL; -} - -/*=========================================================================== -METHOD: - AddToReadMemList (Public Method) - -DESCRIPTION: - Add Data to this client's ReadMem list - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - pData [ I ] - Data to add - dataSize [ I ] - Size of data to add - -RETURN VALUE: - bool -===========================================================================*/ -bool AddToReadMemList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void * pData, - u16 dataSize ) -{ - sClientMemList * pClientMem; - sReadMemList ** ppThisReadMemList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", - clientID ); - - return false; - } - - // Go to last ReadMemList entry - ppThisReadMemList = &pClientMem->mpList; - while (*ppThisReadMemList != NULL) - { - ppThisReadMemList = &(*ppThisReadMemList)->mpNext; - } - - *ppThisReadMemList = kmalloc( sizeof( sReadMemList ), GFP_ATOMIC ); - if (*ppThisReadMemList == NULL) - { - DBG( "Mem error\n" ); - - return false; - } - - (*ppThisReadMemList)->mpNext = NULL; - (*ppThisReadMemList)->mpData = pData; - (*ppThisReadMemList)->mDataSize = dataSize; - (*ppThisReadMemList)->mTransactionID = transactionID; - - return true; -} - -/*=========================================================================== -METHOD: - PopFromReadMemList (Public Method) - -DESCRIPTION: - Remove data from this client's ReadMem list if it matches - the specified transaction ID. - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - ppData [I/O] - On success, will be filled with a - pointer to read buffer - pDataSize [I/O] - On succces, will be filled with the - read buffer's size - -RETURN VALUE: - bool -===========================================================================*/ -bool PopFromReadMemList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void ** ppData, - u16 * pDataSize ) -{ - sClientMemList * pClientMem; - sReadMemList * pDelReadMemList, ** ppReadMemList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", - clientID ); - - return false; - } - - ppReadMemList = &(pClientMem->mpList); - pDelReadMemList = NULL; - - // Find first message that matches this transaction ID - while (*ppReadMemList != NULL) - { - // Do we care about transaction ID? - if (transactionID == 0 - || transactionID == (*ppReadMemList)->mTransactionID ) - { - pDelReadMemList = *ppReadMemList; - break; - } - - DBG( "skipping 0x%04X data TID = %x\n", clientID, (*ppReadMemList)->mTransactionID ); - - // Next - ppReadMemList = &(*ppReadMemList)->mpNext; - } - - if (pDelReadMemList != NULL) - { - *ppReadMemList = (*ppReadMemList)->mpNext; - - // Copy to output - *ppData = pDelReadMemList->mpData; - *pDataSize = pDelReadMemList->mDataSize; - - // Free memory - kfree( pDelReadMemList ); - - return true; - } - else - { - DBG( "No read memory to pop, Client 0x%04X, TID = %x\n", - clientID, - transactionID ); - return false; - } -} - -/*=========================================================================== -METHOD: - AddToNotifyList (Public Method) - -DESCRIPTION: - Add Notify entry to this client's notify List - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - pNotifyFunct [ I ] - Callback function to be run when data is available - pData [ I ] - Data buffer that willl be passed (unmodified) - to callback - -RETURN VALUE: - bool -===========================================================================*/ -bool AddToNotifyList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (* pNotifyFunct)(sQCUSBNet *, u16, void *), - void * pData ) -{ - sClientMemList * pClientMem; - sNotifyList ** ppThisNotifyList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return false; - } - - // Go to last URBList entry - ppThisNotifyList = &pClientMem->mpReadNotifyList; - while (*ppThisNotifyList != NULL) - { - ppThisNotifyList = &(*ppThisNotifyList)->mpNext; - } - - *ppThisNotifyList = kmalloc( sizeof( sNotifyList ), GFP_ATOMIC ); - if (*ppThisNotifyList == NULL) - { - DBG( "Mem error\n" ); - return false; - } - - (*ppThisNotifyList)->mpNext = NULL; - (*ppThisNotifyList)->mpNotifyFunct = pNotifyFunct; - (*ppThisNotifyList)->mpData = pData; - (*ppThisNotifyList)->mTransactionID = transactionID; - - return true; -} - -/*=========================================================================== -METHOD: - NotifyAndPopNotifyList (Public Method) - -DESCRIPTION: - Remove first Notify entry from this client's notify list - and Run function - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - -RETURN VALUE: - bool -===========================================================================*/ -bool NotifyAndPopNotifyList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID ) -{ - sClientMemList * pClientMem; - sNotifyList * pDelNotifyList, ** ppNotifyList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return false; - } - - ppNotifyList = &(pClientMem->mpReadNotifyList); - pDelNotifyList = NULL; - - // Remove from list - while (*ppNotifyList != NULL) - { - // Do we care about transaction ID? - if (transactionID == 0 - || (*ppNotifyList)->mTransactionID == 0 - || transactionID == (*ppNotifyList)->mTransactionID) - { - pDelNotifyList = *ppNotifyList; - break; - } - - DBG( "skipping data TID = %x\n", (*ppNotifyList)->mTransactionID ); - - // next - ppNotifyList = &(*ppNotifyList)->mpNext; - } - - if (pDelNotifyList != NULL) - { - // Remove element - *ppNotifyList = (*ppNotifyList)->mpNext; - - // Run notification function - if (pDelNotifyList->mpNotifyFunct != NULL) - { - // Unlock for callback - spin_unlock( &pDev->mQMIDev.mClientMemLock ); - - pDelNotifyList->mpNotifyFunct( pDev, - clientID, - pDelNotifyList->mpData ); - - // Restore lock - spin_lock( &pDev->mQMIDev.mClientMemLock ); - } - - // Delete memory - kfree( pDelNotifyList ); - - return true; - } - else - { - DBG( "no one to notify for TID %x\n", transactionID ); - - return false; - } -} - -/*=========================================================================== -METHOD: - AddToURBList (Public Method) - -DESCRIPTION: - Add URB to this client's URB list - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - pURB [ I ] - URB to be added - -RETURN VALUE: - bool -===========================================================================*/ -bool AddToURBList( - sQCUSBNet * pDev, - u16 clientID, - struct urb * pURB ) -{ - sClientMemList * pClientMem; - sURBList ** ppThisURBList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return false; - } - - // Go to last URBList entry - ppThisURBList = &pClientMem->mpURBList; - while (*ppThisURBList != NULL) - { - ppThisURBList = &(*ppThisURBList)->mpNext; - } - - *ppThisURBList = kmalloc( sizeof( sURBList ), GFP_ATOMIC ); - if (*ppThisURBList == NULL) - { - DBG( "Mem error\n" ); - return false; - } - - (*ppThisURBList)->mpNext = NULL; - (*ppThisURBList)->mpURB = pURB; - - return true; -} - -/*=========================================================================== -METHOD: - PopFromURBList (Public Method) - -DESCRIPTION: - Remove URB from this client's URB list - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - -RETURN VALUE: - struct urb - Pointer to requested client's URB - NULL for error -===========================================================================*/ -struct urb * PopFromURBList( - sQCUSBNet * pDev, - u16 clientID ) -{ - sClientMemList * pClientMem; - sURBList * pDelURBList; - struct urb * pURB; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return NULL; - } - - // Remove from list - if (pClientMem->mpURBList != NULL) - { - pDelURBList = pClientMem->mpURBList; - pClientMem->mpURBList = pClientMem->mpURBList->mpNext; - - // Copy to output - pURB = pDelURBList->mpURB; - - // Delete memory - kfree( pDelURBList ); - - return pURB; - } - else - { - DBG( "No URB's to pop\n" ); - - return NULL; - } -} - -/*=========================================================================*/ -// Userspace wrappers -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - UserspaceOpen (Public Method) - -DESCRIPTION: - Userspace open - IOCTL must be called before reads or writes - -PARAMETERS - pInode [ I ] - kernel file descriptor - pFilp [ I ] - userspace file descriptor - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -int UserspaceOpen( - struct inode * pInode, - struct file * pFilp ) -{ - sQMIFilpStorage * pFilpData; - - // Optain device pointer from pInode - sQMIDev * pQMIDev = container_of( pInode->i_cdev, - sQMIDev, - mCdev ); - sQCUSBNet * pDev = container_of( pQMIDev, - sQCUSBNet, - mQMIDev ); - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -ENXIO; - } - - // Setup data in pFilp->private_data - pFilp->private_data = kmalloc( sizeof( sQMIFilpStorage ), GFP_KERNEL ); - if (pFilp->private_data == NULL) - { - DBG( "Mem error\n" ); - return -ENOMEM; - } - - pFilpData = (sQMIFilpStorage *)pFilp->private_data; - pFilpData->mClientID = (u16)-1; - pFilpData->mpDev = pDev; - - return 0; -} - -/*=========================================================================== -METHOD: - UserspaceIOCTL (Public Method) - -DESCRIPTION: - Userspace IOCTL functions - -PARAMETERS - pUnusedInode [ I ] - (unused) kernel file descriptor - pFilp [ I ] - userspace file descriptor - cmd [ I ] - IOCTL command - arg [ I ] - IOCTL argument - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -int UserspaceIOCTL( - struct inode * pUnusedInode, - struct file * pFilp, - unsigned int cmd, - unsigned long arg ) -{ - int result; - u32 devVIDPID; - - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - - if (pFilpData == NULL) - { - DBG( "Bad file data\n" ); - return -EBADF; - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - switch (cmd) - { - case IOCTL_QMI_GET_SERVICE_FILE: - - DBG( "Setting up QMI for service %lu\n", arg ); - if ((u8)arg == 0) - { - DBG( "Cannot use QMICTL from userspace\n" ); - return -EINVAL; - } - - // Connection is already setup - if (pFilpData->mClientID != (u16)-1) - { - DBG( "Close the current connection before opening a new one\n" ); - return -EBADR; - } - - result = GetClientID( pFilpData->mpDev, (u8)arg ); - if (result < 0) - { - return result; - } - pFilpData->mClientID = result; - - return 0; - break; - - - case IOCTL_QMI_GET_DEVICE_VIDPID: - if (arg == 0) - { - DBG( "Bad VIDPID buffer\n" ); - return -EINVAL; - } - - // Extra verification - if (pFilpData->mpDev->mpNetDev == 0) - { - DBG( "Bad mpNetDev\n" ); - return -ENOMEM; - } - if (pFilpData->mpDev->mpNetDev->udev == 0) - { - DBG( "Bad udev\n" ); - return -ENOMEM; - } - - devVIDPID = ((le16_to_cpu( pFilpData->mpDev->mpNetDev->udev->descriptor.idVendor ) << 16) - + le16_to_cpu( pFilpData->mpDev->mpNetDev->udev->descriptor.idProduct ) ); - - result = copy_to_user( (unsigned int *)arg, &devVIDPID, 4 ); - if (result != 0) - { - DBG( "Copy to userspace failure\n" ); - } - - return result; - - break; - - case IOCTL_QMI_GET_DEVICE_MEID: - if (arg == 0) - { - DBG( "Bad MEID buffer\n" ); - return -EINVAL; - } - - result = copy_to_user( (unsigned int *)arg, &pFilpData->mpDev->mMEID[0], 14 ); - if (result != 0) - { - DBG( "copy to userspace failure\n" ); - } - - return result; - - break; - - default: - return -EBADRQC; - } -} - -/*=========================================================================== -METHOD: - UserspaceClose (Public Method) - -DESCRIPTION: - Userspace close - Release client ID and free memory - -PARAMETERS - pFilp [ I ] - userspace file descriptor - unusedFileTable [ I ] - (unused) file table - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -int UserspaceClose( - struct file * pFilp, - fl_owner_t unusedFileTable ) -{ - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - struct list_head * pTasks; - struct task_struct * pEachTask; - struct fdtable * pFDT; - int count = 0; - int used = 0; - unsigned long flags; - - if (pFilpData == NULL) - { - DBG( "bad file data\n" ); - return -EBADF; - } - - // Fallthough. If f_count == 1 no need to do more checks - if (atomic_read( &pFilp->f_count ) != 1) - { - // "group_leader" points to the main process' task, which resides in - // the global "tasks" list. - list_for_each( pTasks, ¤t->group_leader->tasks ) - { - pEachTask = container_of( pTasks, struct task_struct, tasks ); - if (pEachTask == NULL || pEachTask->files == NULL) - { - // Some tasks may not have files (e.g. Xsession) - continue; - } - spin_lock_irqsave( &pEachTask->files->file_lock, flags ); - pFDT = files_fdtable( pEachTask->files ); - for (count = 0; count < pFDT->max_fds; count++) - { - // Before this function was called, this file was removed - // from our task's file table so if we find it in a file - // table then it is being used by another task - if (pFDT->fd[count] == pFilp) - { - used++; - break; - } - } - spin_unlock_irqrestore( &pEachTask->files->file_lock, flags ); - } - - if (used > 0) - { - DBG( "not closing, as this FD is open by %d other process\n", used ); - return 0; - } - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - DBG( "0x%04X\n", pFilpData->mClientID ); - - // Disable pFilpData so they can't keep sending read or write - // should this function hang - // Note: memory pointer is still saved in pFilpData to be deleted later - pFilp->private_data = NULL; - - if (pFilpData->mClientID != (u16)-1) - { - ReleaseClientID( pFilpData->mpDev, - pFilpData->mClientID ); - } - - kfree( pFilpData ); - return 0; -} - -/*=========================================================================== -METHOD: - UserspaceRead (Public Method) - -DESCRIPTION: - Userspace read (synchronous) - -PARAMETERS - pFilp [ I ] - userspace file descriptor - pBuf [ I ] - read buffer - size [ I ] - size of read buffer - pUnusedFpos [ I ] - (unused) file position - -RETURN VALUE: - ssize_t - Number of bytes read for success - Negative errno for failure -===========================================================================*/ -ssize_t UserspaceRead( - struct file * pFilp, - char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ) -{ - int result; - void * pReadData = NULL; - void * pSmallReadData; - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - - if (pFilpData == NULL) - { - DBG( "Bad file data\n" ); - return -EBADF; - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - if (pFilpData->mClientID == (u16)-1) - { - DBG( "Client ID must be set before reading 0x%04X\n", - pFilpData->mClientID ); - return -EBADR; - } - - // Perform synchronous read - result = ReadSync( pFilpData->mpDev, - &pReadData, - pFilpData->mClientID, - 0 ); - if (result <= 0) - { - return result; - } - - // Discard QMUX header - result -= QMUXHeaderSize(); - pSmallReadData = pReadData + QMUXHeaderSize(); - - if (result > size) - { - DBG( "Read data is too large for amount user has requested\n" ); - kfree( pReadData ); - return -EOVERFLOW; - } - - if (copy_to_user( pBuf, pSmallReadData, result ) != 0) - { - DBG( "Error copying read data to user\n" ); - result = -EFAULT; - } - - // Reader is responsible for freeing read buffer - kfree( pReadData ); - - return result; -} - -/*=========================================================================== -METHOD: - UserspaceWrite (Public Method) - -DESCRIPTION: - Userspace write (synchronous) - -PARAMETERS - pFilp [ I ] - userspace file descriptor - pBuf [ I ] - write buffer - size [ I ] - size of write buffer - pUnusedFpos [ I ] - (unused) file position - -RETURN VALUE: - ssize_t - Number of bytes read for success - Negative errno for failure -===========================================================================*/ -ssize_t UserspaceWrite ( - struct file * pFilp, - const char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ) -{ - int status; - void * pWriteBuffer; - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - - if (pFilpData == NULL) - { - DBG( "Bad file data\n" ); - return -EBADF; - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - if (pFilpData->mClientID == (u16)-1) - { - DBG( "Client ID must be set before writing 0x%04X\n", - pFilpData->mClientID ); - return -EBADR; - } - - // Copy data from user to kernel space - pWriteBuffer = kmalloc( size + QMUXHeaderSize(), GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - status = copy_from_user( pWriteBuffer + QMUXHeaderSize(), pBuf, size ); - if (status != 0) - { - DBG( "Unable to copy data from userspace %d\n", status ); - kfree( pWriteBuffer ); - return status; - } - - status = WriteSync( pFilpData->mpDev, - pWriteBuffer, - size + QMUXHeaderSize(), - pFilpData->mClientID ); - - kfree( pWriteBuffer ); - - // On success, return requested size, not full QMI reqest size - if (status == size + QMUXHeaderSize()) - { - return size; - } - else - { - return status; - } -} - -/*=========================================================================*/ -// Initializer and destructor -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - RegisterQMIDevice (Public Method) - -DESCRIPTION: - QMI Device initialization function - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -int RegisterQMIDevice( sQCUSBNet * pDev ) -{ - int result; - int QCQMIIndex = 0; - dev_t devno; - char * pDevName; - - pDev->mbQMIValid = true; - - // Set up for QMICTL - // (does not send QMI message, just sets up memory) - result = GetClientID( pDev, QMICTL ); - if (result != 0) - { - pDev->mbQMIValid = false; - return result; - } - atomic_set( &pDev->mQMIDev.mQMICTLTransactionID, 1 ); - - // Start Async reading - result = StartRead( pDev ); - if (result != 0) - { - pDev->mbQMIValid = false; - return result; - } - - // Device is not ready for QMI connections right away - // Wait up to 30 seconds before failing - if (QMIReady( pDev, 30000 ) == false) - { - DBG( "Device unresponsive to QMI\n" ); - return -ETIMEDOUT; - } - - // Setup WDS callback - result = SetupQMIWDSCallback( pDev ); - if (result != 0) - { - pDev->mbQMIValid = false; - return result; - } - - // Fill MEID for device - result = QMIDMSGetMEID( pDev ); - if (result != 0) - { - pDev->mbQMIValid = false; - return result; - } - - // allocate and fill devno with numbers - result = alloc_chrdev_region( &devno, 0, 1, "qcqmi" ); - if (result < 0) - { - return result; - } - - // Create cdev - cdev_init( &pDev->mQMIDev.mCdev, &UserspaceQMIFops ); - pDev->mQMIDev.mCdev.owner = THIS_MODULE; - pDev->mQMIDev.mCdev.ops = &UserspaceQMIFops; - - result = cdev_add( &pDev->mQMIDev.mCdev, devno, 1 ); - if (result != 0) - { - DBG( "error adding cdev\n" ); - return result; - } - - // Match interface number (usb#) - pDevName = strstr( pDev->mpNetDev->net->name, "usb" ); - if (pDevName == NULL) - { - DBG( "Bad net name: %s\n", pDev->mpNetDev->net->name ); - return -ENXIO; - } - pDevName += strlen("usb"); - QCQMIIndex = simple_strtoul( pDevName, NULL, 10 ); - if(QCQMIIndex < 0 ) - { - DBG( "Bad minor number\n" ); - return -ENXIO; - } - - // Always print this output - printk( KERN_INFO "creating qcqmi%d\n", - QCQMIIndex ); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,27 )) - // kernel 2.6.27 added a new fourth parameter to device_create - // void * drvdata : the data to be added to the device for callbacks - device_create( pDev->mQMIDev.mpDevClass, - NULL, - devno, - NULL, - "qcqmi%d", - QCQMIIndex ); -#else - device_create( pDev->mQMIDev.mpDevClass, - NULL, - devno, - "qcqmi%d", - QCQMIIndex ); -#endif - - pDev->mQMIDev.mDevNum = devno; - - // Success - return 0; -} - -/*=========================================================================== -METHOD: - DeregisterQMIDevice (Public Method) - -DESCRIPTION: - QMI Device cleanup function - - NOTE: When this function is run the device is no longer valid - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - None -===========================================================================*/ -void DeregisterQMIDevice( sQCUSBNet * pDev ) -{ - struct inode * pOpenInode; - struct list_head * pInodeList; - struct list_head * pTasks; - struct task_struct * pEachTask; - struct fdtable * pFDT; - struct file * pFilp; - unsigned long flags; - int count = 0; - - // Should never happen, but check anyway - if (IsDeviceValid( pDev ) == false) - { - DBG( "wrong device\n" ); - return; - } - - // Release all clients - while (pDev->mQMIDev.mpClientMemList != NULL) - { - DBG( "release 0x%04X\n", pDev->mQMIDev.mpClientMemList->mClientID ); - - ReleaseClientID( pDev, - pDev->mQMIDev.mpClientMemList->mClientID ); - // NOTE: pDev->mQMIDev.mpClientMemList will - // be updated in ReleaseClientID() - } - - // Stop all reads - KillRead( pDev ); - - pDev->mbQMIValid = false; - - // Find each open file handle, and manually close it - - // Generally there will only be only one inode, but more are possible - list_for_each( pInodeList, &pDev->mQMIDev.mCdev.list ) - { - // Get the inode - pOpenInode = container_of( pInodeList, struct inode, i_devices ); - if (pOpenInode != NULL && (IS_ERR( pOpenInode ) == false)) - { - // Look for this inode in each task - - // "group_leader" points to the main process' task, which resides in - // the global "tasks" list. - list_for_each( pTasks, ¤t->group_leader->tasks ) - { - pEachTask = container_of( pTasks, struct task_struct, tasks ); - if (pEachTask == NULL || pEachTask->files == NULL) - { - // Some tasks may not have files (e.g. Xsession) - continue; - } - // For each file this task has open, check if it's referencing - // our inode. - spin_lock_irqsave( &pEachTask->files->file_lock, flags ); - pFDT = files_fdtable( pEachTask->files ); - for (count = 0; count < pFDT->max_fds; count++) - { - pFilp = pFDT->fd[count]; - if (pFilp != NULL && pFilp->f_dentry != NULL ) - { - if (pFilp->f_dentry->d_inode == pOpenInode) - { - // Close this file handle - rcu_assign_pointer( pFDT->fd[count], NULL ); - spin_unlock_irqrestore( &pEachTask->files->file_lock, flags ); - - DBG( "forcing close of open file handle\n" ); - filp_close( pFilp, pEachTask->files ); - - spin_lock_irqsave( &pEachTask->files->file_lock, flags ); - } - } - } - spin_unlock_irqrestore( &pEachTask->files->file_lock, flags ); - } - } - } - - // Remove device (so no more calls can be made by users) - if (IS_ERR(pDev->mQMIDev.mpDevClass) == false) - { - device_destroy( pDev->mQMIDev.mpDevClass, - pDev->mQMIDev.mDevNum ); - } - cdev_del( &pDev->mQMIDev.mCdev ); - - unregister_chrdev_region( pDev->mQMIDev.mDevNum, 1 ); - - return; -} - -/*=========================================================================*/ -// Driver level client management -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMIReady (Public Method) - -DESCRIPTION: - Send QMI CTL GET VERSION INFO REQ - Wait for response or timeout - -PARAMETERS: - pDev [ I ] - Device specific memory - timeout [ I ] - Milliseconds to wait for response - -RETURN VALUE: - bool -===========================================================================*/ -bool QMIReady( - sQCUSBNet * pDev, - u16 timeout ) -{ - int result; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - struct semaphore readSem; - u16 curTime; - unsigned long flags; - u8 transactionID; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -EFAULT; - } - - writeBufferSize = QMICTLReadyReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - // An implimentation of down_timeout has not been agreed on, - // so it's been added and removed from the kernel several times. - // We're just going to ignore it and poll the semaphore. - - // Send a write every 100 ms and see if we get a response - for (curTime = 0; curTime < timeout; curTime += 100) - { - // Start read - sema_init( &readSem, 0 ); - - transactionID = atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID ); - if (transactionID == 0) - { - transactionID = atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID ); - } - result = ReadAsync( pDev, QMICTL, transactionID, UpSem, &readSem ); - if (result != 0) - { - return false; - } - - // Fill buffer - result = QMICTLReadyReq( pWriteBuffer, - writeBufferSize, - transactionID ); - if (result < 0) - { - kfree( pWriteBuffer ); - return false; - } - - // Disregard status. On errors, just try again - WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - QMICTL ); - - msleep( 100 ); - if (down_trylock( &readSem ) == 0) - { - // Enter critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Pop the read data - if (PopFromReadMemList( pDev, - QMICTL, - transactionID, - &pReadBuffer, - &readBufferSize ) == true) - { - // Success - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // We don't care about the result - kfree( pReadBuffer ); - - break; - } - } - else - { - // Enter critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Timeout, remove the async read - NotifyAndPopNotifyList( pDev, QMICTL, transactionID ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - } - } - - kfree( pWriteBuffer ); - - // Did we time out? - if (curTime >= timeout) - { - return false; - } - - DBG( "QMI Ready after %u milliseconds\n", curTime ); - - // TODO: 3580 and newer firmware does not require this delay - msleep( 5000 ); - - // Success - return true; -} - -/*=========================================================================== -METHOD: - QMIWDSCallback (Public Method) - -DESCRIPTION: - QMI WDS callback function - Update net stats or link state - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Client ID - pData [ I ] - Callback data (unused) - -RETURN VALUE: - None -===========================================================================*/ -void QMIWDSCallback( - sQCUSBNet * pDev, - u16 clientID, - void * pData ) -{ - bool bRet; - int result; - void * pReadBuffer; - u16 readBufferSize; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,31 )) - struct net_device_stats * pStats = &(pDev->mpNetDev->stats); -#else - struct net_device_stats * pStats = &(pDev->mpNetDev->net->stats); -#endif - - u32 TXOk = (u32)-1; - u32 RXOk = (u32)-1; - u32 TXErr = (u32)-1; - u32 RXErr = (u32)-1; - u32 TXOfl = (u32)-1; - u32 RXOfl = (u32)-1; - u64 TXBytesOk = (u64)-1; - u64 RXBytesOk = (u64)-1; - bool bLinkState; - bool bReconfigure; - unsigned long flags; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - bRet = PopFromReadMemList( pDev, - clientID, - 0, - &pReadBuffer, - &readBufferSize ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - if (bRet == false) - { - DBG( "WDS callback failed to get data\n" ); - return; - } - - // Default values - bLinkState = ! QTestDownReason( pDev, NO_NDIS_CONNECTION ); - bReconfigure = false; - - result = QMIWDSEventResp( pReadBuffer, - readBufferSize, - &TXOk, - &RXOk, - &TXErr, - &RXErr, - &TXOfl, - &RXOfl, - &TXBytesOk, - &RXBytesOk, - &bLinkState, - &bReconfigure ); - if (result < 0) - { - DBG( "bad WDS packet\n" ); - } - else - { - - // Fill in new values, ignore max values - if (TXOfl != (u32)-1) - { - pStats->tx_fifo_errors = TXOfl; - } - - if (RXOfl != (u32)-1) - { - pStats->rx_fifo_errors = RXOfl; - } - - if (TXErr != (u32)-1) - { - pStats->tx_errors = TXErr; - } - - if (RXErr != (u32)-1) - { - pStats->rx_errors = RXErr; - } - - if (TXOk != (u32)-1) - { - pStats->tx_packets = TXOk + pStats->tx_errors; - } - - if (RXOk != (u32)-1) - { - pStats->rx_packets = RXOk + pStats->rx_errors; - } - - if (TXBytesOk != (u64)-1) - { - pStats->tx_bytes = TXBytesOk; - } - - if (RXBytesOk != (u64)-1) - { - pStats->rx_bytes = RXBytesOk; - } - - if (bReconfigure == true) - { - DBG( "Net device link reset\n" ); - QSetDownReason( pDev, NO_NDIS_CONNECTION ); - QClearDownReason( pDev, NO_NDIS_CONNECTION ); - } - else - { - if (bLinkState == true) - { - DBG( "Net device link is connected\n" ); - QClearDownReason( pDev, NO_NDIS_CONNECTION ); - } - else - { - DBG( "Net device link is disconnected\n" ); - QSetDownReason( pDev, NO_NDIS_CONNECTION ); - } - } - } - - kfree( pReadBuffer ); - - // Setup next read - result = ReadAsync( pDev, - clientID, - 0, - QMIWDSCallback, - pData ); - if (result != 0) - { - DBG( "unable to setup next async read\n" ); - } - - return; -} - -/*=========================================================================== -METHOD: - SetupQMIWDSCallback (Public Method) - -DESCRIPTION: - Request client and fire off reqests and start async read for - QMI WDS callback - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -int SetupQMIWDSCallback( sQCUSBNet * pDev ) -{ - int result; - void * pWriteBuffer; - u16 writeBufferSize; - u16 WDSClientID; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -EFAULT; - } - - result = GetClientID( pDev, QMIWDS ); - if (result < 0) - { - return result; - } - WDSClientID = result; - - // QMI WDS Set Event Report - writeBufferSize = QMIWDSSetEventReportReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIWDSSetEventReportReq( pWriteBuffer, - writeBufferSize, - 1 ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - WDSClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - // QMI WDS Get PKG SRVC Status - writeBufferSize = QMIWDSGetPKGSRVCStatusReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIWDSGetPKGSRVCStatusReq( pWriteBuffer, - writeBufferSize, - 2 ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - WDSClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - // Setup asnyc read callback - result = ReadAsync( pDev, - WDSClientID, - 0, - QMIWDSCallback, - NULL ); - if (result != 0) - { - DBG( "unable to setup async read\n" ); - return result; - } - - // Send SetControlLineState request (USB_CDC) - // Required for Autoconnect - result = usb_control_msg( pDev->mpNetDev->udev, - usb_sndctrlpipe( pDev->mpNetDev->udev, 0 ), - 0x22, - 0x21, - 1, // DTR present - 0, - NULL, - 0, - 100 ); - if (result < 0) - { - DBG( "Bad SetControlLineState status %d\n", result ); - return result; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMIDMSGetMEID (Public Method) - -DESCRIPTION: - Register DMS client - send MEID req and parse response - Release DMS client - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - None -===========================================================================*/ -int QMIDMSGetMEID( sQCUSBNet * pDev ) -{ - int result; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - u16 DMSClientID; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -EFAULT; - } - - result = GetClientID( pDev, QMIDMS ); - if (result < 0) - { - return result; - } - DMSClientID = result; - - // QMI DMS Get Serial numbers Req - writeBufferSize = QMIDMSGetMEIDReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIDMSGetMEIDReq( pWriteBuffer, - writeBufferSize, - 1 ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - DMSClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - // QMI DMS Get Serial numbers Resp - result = ReadSync( pDev, - &pReadBuffer, - DMSClientID, - 1 ); - if (result < 0) - { - return result; - } - readBufferSize = result; - - result = QMIDMSGetMEIDResp( pReadBuffer, - readBufferSize, - &pDev->mMEID[0], - 14 ); - kfree( pReadBuffer ); - - if (result < 0) - { - DBG( "bad get MEID resp\n" ); - - // Non fatal error, device did not return any MEID - // Fill with 0's - memset( &pDev->mMEID[0], '0', 14 ); - } - - ReleaseClientID( pDev, DMSClientID ); - - // Success - return 0; -} diff --git a/drivers/staging/gobi/QCUSBNet2k/QMIDevice.h b/drivers/staging/gobi/QCUSBNet2k/QMIDevice.h deleted file mode 100644 index 29cc2692fe74e57bdcbdc13b35ca09c4546df2b6..0000000000000000000000000000000000000000 --- a/drivers/staging/gobi/QCUSBNet2k/QMIDevice.h +++ /dev/null @@ -1,297 +0,0 @@ -/*=========================================================================== -FILE: - QMIDevice.h - -DESCRIPTION: - Functions related to the QMI interface device - -FUNCTIONS: - Generic functions - IsDeviceValid - PrintHex - QSetDownReason - QClearDownReason - QTestDownReason - - Driver level asynchronous read functions - ReadCallback - IntCallback - StartRead - KillRead - - Internal read/write functions - ReadAsync - UpSem - ReadSync - WriteSyncCallback - WriteSync - - Internal memory management functions - GetClientID - ReleaseClientID - FindClientMem - AddToReadMemList - PopFromReadMemList - AddToNotifyList - NotifyAndPopNotifyList - AddToURBList - PopFromURBList - - Userspace wrappers - UserspaceOpen - UserspaceIOCTL - UserspaceClose - UserspaceRead - UserspaceWrite - - Initializer and destructor - RegisterQMIDevice - DeregisterQMIDevice - - Driver level client management - QMIReady - QMIWDSCallback - SetupQMIWDSCallback - QMIDMSGetMEID - -Copyright (c) 2010, 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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Pragmas -//--------------------------------------------------------------------------- -#pragma once - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include "Structs.h" -#include "QMI.h" - -/*=========================================================================*/ -// Generic functions -/*=========================================================================*/ - -// Basic test to see if device memory is valid -bool IsDeviceValid( sQCUSBNet * pDev ); - -// Print Hex data, for debug purposes -void PrintHex( - void * pBuffer, - u16 bufSize ); - -// Sets mDownReason and turns carrier off -void QSetDownReason( - sQCUSBNet * pDev, - u8 reason ); - -// Clear mDownReason and may turn carrier on -void QClearDownReason( - sQCUSBNet * pDev, - u8 reason ); - -// Tests mDownReason and returns whether reason is set -bool QTestDownReason( - sQCUSBNet * pDev, - u8 reason ); - -/*=========================================================================*/ -// Driver level asynchronous read functions -/*=========================================================================*/ - -// Read callback -// Put the data in storage and notify anyone waiting for data -void ReadCallback( struct urb * pReadURB ); - -// Inturrupt callback -// Data is available, start a read URB -void IntCallback( struct urb * pIntURB ); - -// Start continuous read "thread" -int StartRead( sQCUSBNet * pDev ); - -// Kill continuous read "thread" -void KillRead( sQCUSBNet * pDev ); - -/*=========================================================================*/ -// Internal read/write functions -/*=========================================================================*/ - -// Start asynchronous read -// Reading client's data store, not device -int ReadAsync( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (*pCallback)(sQCUSBNet *, u16, void *), - void * pData ); - -// Notification function for synchronous read -void UpSem( - sQCUSBNet * pDev, - u16 clientID, - void * pData ); - -// Start synchronous read -// Reading client's data store, not device -int ReadSync( - sQCUSBNet * pDev, - void ** ppOutBuffer, - u16 clientID, - u16 transactionID ); - -// Write callback -void WriteSyncCallback( struct urb * pWriteURB ); - -// Start synchronous write -int WriteSync( - sQCUSBNet * pDev, - char * pInWriteBuffer, - int size, - u16 clientID ); - -/*=========================================================================*/ -// Internal memory management functions -/*=========================================================================*/ - -// Create client and allocate memory -int GetClientID( - sQCUSBNet * pDev, - u8 serviceType ); - -// Release client and free memory -void ReleaseClientID( - sQCUSBNet * pDev, - u16 clientID ); - -// Find this client's memory -sClientMemList * FindClientMem( - sQCUSBNet * pDev, - u16 clientID ); - -// Add Data to this client's ReadMem list -bool AddToReadMemList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void * pData, - u16 dataSize ); - -// Remove data from this client's ReadMem list if it matches -// the specified transaction ID. -bool PopFromReadMemList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void ** ppData, - u16 * pDataSize ); - -// Add Notify entry to this client's notify List -bool AddToNotifyList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (* pNotifyFunct)(sQCUSBNet *, u16, void *), - void * pData ); - -// Remove first Notify entry from this client's notify list -// and Run function -bool NotifyAndPopNotifyList( - sQCUSBNet * pDev, - u16 clientID, - u16 transactionID ); - -// Add URB to this client's URB list -bool AddToURBList( - sQCUSBNet * pDev, - u16 clientID, - struct urb * pURB ); - -// Remove URB from this client's URB list -struct urb * PopFromURBList( - sQCUSBNet * pDev, - u16 clientID ); - -/*=========================================================================*/ -// Userspace wrappers -/*=========================================================================*/ - -// Userspace open -int UserspaceOpen( - struct inode * pInode, - struct file * pFilp ); - -// Userspace ioctl -int UserspaceIOCTL( - struct inode * pUnusedInode, - struct file * pFilp, - unsigned int cmd, - unsigned long arg ); - -// Userspace close -int UserspaceClose( - struct file * pFilp, - fl_owner_t unusedFileTable ); - -// Userspace read (synchronous) -ssize_t UserspaceRead( - struct file * pFilp, - char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ); - -// Userspace write (synchronous) -ssize_t UserspaceWrite( - struct file * pFilp, - const char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ); - -/*=========================================================================*/ -// Initializer and destructor -/*=========================================================================*/ - -// QMI Device initialization function -int RegisterQMIDevice( sQCUSBNet * pDev ); - -// QMI Device cleanup function -void DeregisterQMIDevice( sQCUSBNet * pDev ); - -/*=========================================================================*/ -// Driver level client management -/*=========================================================================*/ - -// Check if QMI is ready for use -bool QMIReady( - sQCUSBNet * pDev, - u16 timeout ); - -// QMI WDS callback function -void QMIWDSCallback( - sQCUSBNet * pDev, - u16 clientID, - void * pData ); - -// Fire off reqests and start async read for QMI WDS callback -int SetupQMIWDSCallback( sQCUSBNet * pDev ); - -// Register client, send req and parse MEID response, release client -int QMIDMSGetMEID( sQCUSBNet * pDev ); - - - diff --git a/drivers/staging/gobi/QCUSBNet2k/Structs.h b/drivers/staging/gobi/QCUSBNet2k/Structs.h deleted file mode 100644 index 7c9350339c70f4f11c71339b882ba373bd5577ac..0000000000000000000000000000000000000000 --- a/drivers/staging/gobi/QCUSBNet2k/Structs.h +++ /dev/null @@ -1,318 +0,0 @@ -/*=========================================================================== -FILE: - Structs.h - -DESCRIPTION: - Declaration of structures used by the Qualcomm Linux USB Network driver - -FUNCTIONS: - none - -Copyright (c) 2010, 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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301, USA. - -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Pragmas -//--------------------------------------------------------------------------- -#pragma once - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,24 )) - #include "usbnet.h" -#else - #include -#endif - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,25 )) - #include -#else - #include -#endif - -// DBG macro -#define DBG( format, arg... ) \ - if (debug == 1)\ - { \ - printk( KERN_INFO "QCUSBNet2k::%s " format, __FUNCTION__, ## arg ); \ - } \ - - -// Used in recursion, defined later below -struct sQCUSBNet; - -/*=========================================================================*/ -// Struct sReadMemList -// -// Structure that defines an entry in a Read Memory linked list -/*=========================================================================*/ -typedef struct sReadMemList -{ - /* Data buffer */ - void * mpData; - - /* Transaction ID */ - u16 mTransactionID; - - /* Size of data buffer */ - u16 mDataSize; - - /* Next entry in linked list */ - struct sReadMemList * mpNext; - -} sReadMemList; - -/*=========================================================================*/ -// Struct sNotifyList -// -// Structure that defines an entry in a Notification linked list -/*=========================================================================*/ -typedef struct sNotifyList -{ - /* Function to be run when data becomes available */ - void (* mpNotifyFunct)(struct sQCUSBNet *, u16, void *); - - /* Transaction ID */ - u16 mTransactionID; - - /* Data to provide as parameter to mpNotifyFunct */ - void * mpData; - - /* Next entry in linked list */ - struct sNotifyList * mpNext; - -} sNotifyList; - -/*=========================================================================*/ -// Struct sURBList -// -// Structure that defines an entry in a URB linked list -/*=========================================================================*/ -typedef struct sURBList -{ - /* The current URB */ - struct urb * mpURB; - - /* Next entry in linked list */ - struct sURBList * mpNext; - -} sURBList; - -/*=========================================================================*/ -// Struct sClientMemList -// -// Structure that defines an entry in a Client Memory linked list -// Stores data specific to a Service Type and Client ID -/*=========================================================================*/ -typedef struct sClientMemList -{ - /* Client ID for this Client */ - u16 mClientID; - - /* Linked list of Read entries */ - /* Stores data read from device before sending to client */ - sReadMemList * mpList; - - /* Linked list of Notification entries */ - /* Stores notification functions to be run as data becomes - available or the device is removed */ - sNotifyList * mpReadNotifyList; - - /* Linked list of URB entries */ - /* Stores pointers to outstanding URBs which need canceled - when the client is deregistered or the device is removed */ - sURBList * mpURBList; - - /* Next entry in linked list */ - struct sClientMemList * mpNext; - -} sClientMemList; - -/*=========================================================================*/ -// Struct sURBSetupPacket -// -// Structure that defines a USB Setup packet for Control URBs -// Taken from USB CDC specifications -/*=========================================================================*/ -typedef struct sURBSetupPacket -{ - /* Request type */ - u8 mRequestType; - - /* Request code */ - u8 mRequestCode; - - /* Value */ - u16 mValue; - - /* Index */ - u16 mIndex; - - /* Length of Control URB */ - u16 mLength; - -} sURBSetupPacket; - -// Common value for sURBSetupPacket.mLength -#define DEFAULT_READ_URB_LENGTH 0x1000 - - -/*=========================================================================*/ -// Struct sAutoPM -// -// Structure used to manage AutoPM thread which determines whether the -// device is in use or may enter autosuspend. Also submits net -// transmissions asynchronously. -/*=========================================================================*/ -typedef struct sAutoPM -{ - /* Thread for atomic autopm function */ - struct task_struct * mpThread; - - /* Up this semaphore when it's time for the thread to work */ - struct semaphore mThreadDoWork; - - /* Time to exit? */ - bool mbExit; - - /* List of URB's queued to be sent to the device */ - sURBList * mpURBList; - - /* URB list lock (for adding and removing elements) */ - spinlock_t mURBListLock; - - /* Active URB */ - struct urb * mpActiveURB; - - /* Active URB lock (for adding and removing elements) */ - spinlock_t mActiveURBLock; - - /* Duplicate pointer to USB device interface */ - struct usb_interface * mpIntf; - -} sAutoPM; - - -/*=========================================================================*/ -// Struct sQMIDev -// -// Structure that defines the data for the QMI device -/*=========================================================================*/ -typedef struct sQMIDev -{ - /* Device number */ - dev_t mDevNum; - - /* Device class */ - struct class * mpDevClass; - - /* cdev struct */ - struct cdev mCdev; - - /* Pointer to read URB */ - struct urb * mpReadURB; - - /* Read setup packet */ - sURBSetupPacket * mpReadSetupPacket; - - /* Read buffer attached to current read URB */ - void * mpReadBuffer; - - /* Inturrupt URB */ - /* Used to asynchronously notify when read data is available */ - struct urb * mpIntURB; - - /* Buffer used by Inturrupt URB */ - void * mpIntBuffer; - - /* Pointer to memory linked list for all clients */ - sClientMemList * mpClientMemList; - - /* Spinlock for client Memory entries */ - spinlock_t mClientMemLock; - - /* Transaction ID associated with QMICTL "client" */ - atomic_t mQMICTLTransactionID; - -} sQMIDev; - -/*=========================================================================*/ -// Struct sQCUSBNet -// -// Structure that defines the data associated with the Qualcomm USB device -/*=========================================================================*/ -typedef struct sQCUSBNet -{ - /* Net device structure */ - struct usbnet * mpNetDev; - - /* Usb device interface */ - struct usb_interface * mpIntf; - - /* Pointers to usbnet_open and usbnet_stop functions */ - int (* mpUSBNetOpen)(struct net_device *); - int (* mpUSBNetStop)(struct net_device *); - - /* Reason(s) why interface is down */ - /* Used by Q*DownReason */ - unsigned long mDownReason; -#define NO_NDIS_CONNECTION 0 -#define CDC_CONNECTION_SPEED 1 -#define DRIVER_SUSPENDED 2 -#define NET_IFACE_STOPPED 3 - - /* QMI "device" status */ - bool mbQMIValid; - - /* QMI "device" memory */ - sQMIDev mQMIDev; - - /* Device MEID */ - char mMEID[14]; - - /* AutoPM thread */ - sAutoPM mAutoPM; - -} sQCUSBNet; - -/*=========================================================================*/ -// Struct sQMIFilpStorage -// -// Structure that defines the storage each file handle contains -// Relates the file handle to a client -/*=========================================================================*/ -typedef struct sQMIFilpStorage -{ - /* Client ID */ - u16 mClientID; - - /* Device pointer */ - sQCUSBNet * mpDev; - -} sQMIFilpStorage; - - diff --git a/drivers/staging/ste_rmi4/Kconfig b/drivers/staging/ste_rmi4/Kconfig index 6570368db1a8d681c53410d761674fc5164f5cc3..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/drivers/staging/ste_rmi4/Kconfig +++ b/drivers/staging/ste_rmi4/Kconfig @@ -1,12 +0,0 @@ -config TOUCHSCREEN_SYNAPTICS_I2C_RMI4_STAGING - tristate "Synaptics i2c rmi4 touchscreen staging" - depends on I2C && INPUT - help - Say Y here if you have a Synaptics RMI4 and - want to enable support for the built-in touchscreen - through staging driver. Not to be confused with - TOUCHSCREEN_SYNAPTICS_I2C_RMI4 in - drivers/input/touchscreen directory. - - To compile this driver as a module, choose M here: the - module will be called synaptics_rmi4_ts. diff --git a/drivers/staging/ste_rmi4/Makefile b/drivers/staging/ste_rmi4/Makefile deleted file mode 100644 index 2b61278b91707a027e76d2cf5a36d199840d06fd..0000000000000000000000000000000000000000 --- a/drivers/staging/ste_rmi4/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# -# Makefile for the RMI4 touchscreen driver. -# -obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4_STAGING) \ - += synaptics_i2c_rmi4_staging.o diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4_staging.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4_staging.c deleted file mode 100644 index 4bb9e4c213200358a6d3b9d5638a24a788dcb16d..0000000000000000000000000000000000000000 --- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4_staging.c +++ /dev/null @@ -1,1145 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) I2C Physical Layer Driver. - * Copyright (c) 2007-2010, Synaptics Incorporated - * - * Author: Js HA for ST-Ericsson - * Author: Naveen Kumar G for ST-Ericsson - * Copyright 2010 (c) ST-Ericsson AB - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 -#include -#include -#include -#include -#include -#include -#include "synaptics_i2c_rmi4_staging.h" - -/* TODO: for multiple device support will need a per-device mutex */ -#define DRIVER_NAME "synaptics_rmi4_i2c" - -#define MAX_ERROR_REPORT 6 -#define MAX_TOUCH_MAJOR 15 -#define MAX_RETRY_COUNT 5 -#define STD_QUERY_LEN 21 -#define PAGE_LEN 2 -#define DATA_BUF_LEN 32 -#define BUF_LEN 37 -#define QUERY_LEN 9 -#define DATA_LEN 12 -#define HAS_TAP 0x01 -#define HAS_PALMDETECT 0x01 -#define HAS_ROTATE 0x02 -#define HAS_TAPANDHOLD 0x02 -#define HAS_DOUBLETAP 0x04 -#define HAS_EARLYTAP 0x08 -#define HAS_RELEASE 0x08 -#define HAS_FLICK 0x10 -#define HAS_PRESS 0x20 -#define HAS_PINCH 0x40 - -#define MASK_16BIT 0xFFFF -#define MASK_8BIT 0xFF -#define MASK_7BIT 0x7F -#define MASK_5BIT 0x1F -#define MASK_4BIT 0x0F -#define MASK_3BIT 0x07 -#define MASK_2BIT 0x03 -#define TOUCHPAD_CTRL_INTR 0x8 -#define PDT_START_SCAN_LOCATION (0x00E9) -#define PDT_END_SCAN_LOCATION (0x000A) -#define PDT_ENTRY_SIZE (0x0006) -#define SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM (0x11) -#define SYNAPTICS_RMI4_DEVICE_CONTROL_FUNC_NUM (0x01) - -/** - * struct synaptics_rmi4_fn_desc - contains the function descriptor information - * @query_base_addr: base address for query - * @cmd_base_addr: base address for command - * @ctrl_base_addr: base address for control - * @data_base_addr: base address for data - * @intr_src_count: count for the interrupt source - * @fn_number: function number - * - * This structure is used to gives the function descriptor information - * of the particular functionality. - */ -struct synaptics_rmi4_fn_desc { - unsigned char query_base_addr; - unsigned char cmd_base_addr; - unsigned char ctrl_base_addr; - unsigned char data_base_addr; - unsigned char intr_src_count; - unsigned char fn_number; -}; - -/** - * struct synaptics_rmi4_fn - contains the function information - * @fn_number: function number - * @num_of_data_sources: number of data sources - * @num_of_data_points: number of fingers touched - * @size_of_data_register_block: data register block size - * @index_to_intr_reg: index for interrupt register - * @intr_mask: interrupt mask value - * @fn_desc: variable for function descriptor structure - * @link: linked list for function descriptors - * - * This structure gives information about the number of data sources and - * the number of data registers associated with the function. - */ -struct synaptics_rmi4_fn { - unsigned char fn_number; - unsigned char num_of_data_sources; - unsigned char num_of_data_points; - unsigned char size_of_data_register_block; - unsigned char index_to_intr_reg; - unsigned char intr_mask; - struct synaptics_rmi4_fn_desc fn_desc; - struct list_head link; -}; - -/** - * struct synaptics_rmi4_device_info - contains the rmi4 device information - * @version_major: protocol major version number - * @version_minor: protocol minor version number - * @manufacturer_id: manufacturer identification byte - * @product_props: product properties information - * @product_info: product info array - * @date_code: device manufacture date - * @tester_id: tester id array - * @serial_number: serial number for that device - * @product_id_string: product id for the device - * @support_fn_list: linked list for device information - * - * This structure gives information about the number of data sources and - * the number of data registers associated with the function. - */ -struct synaptics_rmi4_device_info { - unsigned int version_major; - unsigned int version_minor; - unsigned char manufacturer_id; - unsigned char product_props; - unsigned char product_info[2]; - unsigned char date_code[3]; - unsigned short tester_id; - unsigned short serial_number; - unsigned char product_id_string[11]; - struct list_head support_fn_list; -}; - -/** - * struct synaptics_rmi4_data - contains the rmi4 device data - * @rmi4_mod_info: structure variable for rmi4 device info - * @input_dev: pointer for input device - * @i2c_client: pointer for i2c client - * @board: constant pointer for touch platform data - * @fn_list_mutex: mutex for function list - * @rmi4_page_mutex: mutex for rmi4 page - * @current_page: variable for integer - * @number_of_interrupt_register: interrupt registers count - * @fn01_ctrl_base_addr: control base address for fn01 - * @fn01_query_base_addr: query base address for fn01 - * @fn01_data_base_addr: data base address for fn01 - * @sensor_max_x: sensor maximum x value - * @sensor_max_y: sensor maximum y value - * @regulator: pointer to the regulator structure - * @wait: wait queue structure variable - * @touch_stopped: flag to stop the thread function - * @fingers_supported: maximum supported fingers - * - * This structure gives the device data information. - */ -struct synaptics_rmi4_data { - struct synaptics_rmi4_device_info rmi4_mod_info; - struct input_dev *input_dev; - struct i2c_client *i2c_client; - const struct synaptics_rmi4_platform_data *board; - struct mutex fn_list_mutex; - struct mutex rmi4_page_mutex; - int current_page; - unsigned int number_of_interrupt_register; - unsigned short fn01_ctrl_base_addr; - unsigned short fn01_query_base_addr; - unsigned short fn01_data_base_addr; - int sensor_max_x; - int sensor_max_y; - struct regulator *regulator; - wait_queue_head_t wait; - bool touch_stopped; - unsigned char fingers_supported; -}; - -/** - * synaptics_rmi4_set_page() - sets the page - * @pdata: pointer to synaptics_rmi4_data structure - * @address: set the address of the page - * - * This function is used to set the page and returns integer. - */ -static int synaptics_rmi4_set_page(struct synaptics_rmi4_data *pdata, - unsigned int address) -{ - unsigned char txbuf[PAGE_LEN]; - int retval; - unsigned int page; - struct i2c_client *i2c = pdata->i2c_client; - - page = ((address >> 8) & MASK_8BIT); - if (page != pdata->current_page) { - txbuf[0] = MASK_8BIT; - txbuf[1] = page; - retval = i2c_master_send(i2c, txbuf, PAGE_LEN); - if (retval != PAGE_LEN) - dev_err(&i2c->dev, "%s:failed:%d\n", __func__, retval); - else - pdata->current_page = page; - } else - retval = PAGE_LEN; - return retval; -} -/** - * synaptics_rmi4_i2c_block_read() - read the block of data - * @pdata: pointer to synaptics_rmi4_data structure - * @address: read the block of data from this offset - * @valp: pointer to a buffer containing the data to be read - * @size: number of bytes to read - * - * This function is to read the block of data and returns integer. - */ -static int synaptics_rmi4_i2c_block_read(struct synaptics_rmi4_data *pdata, - unsigned short address, - unsigned char *valp, int size) -{ - int retval = 0; - int retry_count = 0; - int index; - struct i2c_client *i2c = pdata->i2c_client; - - mutex_lock(&(pdata->rmi4_page_mutex)); - retval = synaptics_rmi4_set_page(pdata, address); - if (retval != PAGE_LEN) - goto exit; - index = address & MASK_8BIT; -retry: - retval = i2c_smbus_read_i2c_block_data(i2c, index, size, valp); - if (retval != size) { - if (++retry_count == MAX_RETRY_COUNT) - dev_err(&i2c->dev, - "%s:address 0x%04x size %d failed:%d\n", - __func__, address, size, retval); - else { - synaptics_rmi4_set_page(pdata, address); - goto retry; - } - } -exit: - mutex_unlock(&(pdata->rmi4_page_mutex)); - return retval; -} - -/** - * synaptics_rmi4_i2c_byte_write() - write the single byte data - * @pdata: pointer to synaptics_rmi4_data structure - * @address: write the block of data from this offset - * @data: data to be write - * - * This function is to write the single byte data and returns integer. - */ -static int synaptics_rmi4_i2c_byte_write(struct synaptics_rmi4_data *pdata, - unsigned short address, - unsigned char data) -{ - unsigned char txbuf[2]; - int retval = 0; - struct i2c_client *i2c = pdata->i2c_client; - - /* Can't have anyone else changing the page behind our backs */ - mutex_lock(&(pdata->rmi4_page_mutex)); - - retval = synaptics_rmi4_set_page(pdata, address); - if (retval != PAGE_LEN) - goto exit; - txbuf[0] = address & MASK_8BIT; - txbuf[1] = data; - retval = i2c_master_send(pdata->i2c_client, txbuf, 2); - /* Add in retry on writes only in certain error return values */ - if (retval != 2) { - dev_err(&i2c->dev, "%s:failed:%d\n", __func__, retval); - retval = -EIO; - } else - retval = 1; -exit: - mutex_unlock(&(pdata->rmi4_page_mutex)); - return retval; -} - -/** - * synpatics_rmi4_touchpad_report() - reports for the rmi4 touchpad device - * @pdata: pointer to synaptics_rmi4_data structure - * @rfi: pointer to synaptics_rmi4_fn structure - * - * This function calls to reports for the rmi4 touchpad device - */ -static int synpatics_rmi4_touchpad_report(struct synaptics_rmi4_data *pdata, - struct synaptics_rmi4_fn *rfi) -{ - /* number of touch points - fingers down in this case */ - int touch_count = 0; - int finger; - int finger_registers; - int reg; - int finger_shift; - int finger_status; - int retval; - int x, y; - int wx, wy; - unsigned short data_base_addr; - unsigned short data_offset; - unsigned char data_reg_blk_size; - unsigned char values[2]; - unsigned char data[DATA_LEN]; - unsigned char fingers_supported = pdata->fingers_supported; - struct i2c_client *client = pdata->i2c_client; - struct input_dev *input_dev = pdata->input_dev; - - /* get 2D sensor finger data */ - /* - * First get the finger status field - the size of the finger status - * field is determined by the number of finger supporte - 2 bits per - * finger, so the number of registers to read is: - * registerCount = ceil(numberOfFingers/4). - * Read the required number of registers and check each 2 bit field to - * determine if a finger is down: - * 00 = finger not present, - * 01 = finger present and data accurate, - * 10 = finger present but data may not be accurate, - * 11 = reserved for product use. - */ - finger_registers = (fingers_supported + 3)/4; - data_base_addr = rfi->fn_desc.data_base_addr; - retval = synaptics_rmi4_i2c_block_read(pdata, data_base_addr, values, - finger_registers); - if (retval != finger_registers) { - dev_err(&client->dev, "%s:read status registers failed\n", - __func__); - return 0; - } - /* - * For each finger present, read the proper number of registers - * to get absolute data. - */ - data_reg_blk_size = rfi->size_of_data_register_block; - for (finger = 0; finger < fingers_supported; finger++) { - /* determine which data byte the finger status is in */ - reg = finger/4; - /* bit shift to get finger's status */ - finger_shift = (finger % 4) * 2; - finger_status = (values[reg] >> finger_shift) & 3; - /* - * if finger status indicates a finger is present then - * read the finger data and report it - */ - input_mt_slot(input_dev, finger); - input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, - finger_status != 0); - - if (finger_status) { - /* Read the finger data */ - data_offset = data_base_addr + - ((finger * data_reg_blk_size) + - finger_registers); - retval = synaptics_rmi4_i2c_block_read(pdata, - data_offset, data, - data_reg_blk_size); - if (retval != data_reg_blk_size) { - dev_err(&client->dev, "%s:read data failed\n", - __func__); - return 0; - } - x = (data[0] << 4) | (data[2] & MASK_4BIT); - y = (data[1] << 4) | ((data[2] >> 4) & MASK_4BIT); - wy = (data[3] >> 4) & MASK_4BIT; - wx = (data[3] & MASK_4BIT); - - if (pdata->board->x_flip) - x = pdata->sensor_max_x - x; - if (pdata->board->y_flip) - y = pdata->sensor_max_y - y; - - input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, - max(wx, wy)); - input_report_abs(input_dev, ABS_MT_POSITION_X, x); - input_report_abs(input_dev, ABS_MT_POSITION_Y, y); - - /* number of active touch points */ - touch_count++; - } - } - - /* sync after groups of events */ - input_mt_sync_frame(input_dev); - input_sync(input_dev); - /* return the number of touch points */ - return touch_count; -} - -/** - * synaptics_rmi4_report_device() - reports the rmi4 device - * @pdata: pointer to synaptics_rmi4_data structure - * @rfi: pointer to synaptics_rmi4_fn - * - * This function is used to call the report function of the rmi4 device. - */ -static int synaptics_rmi4_report_device(struct synaptics_rmi4_data *pdata, - struct synaptics_rmi4_fn *rfi) -{ - int touch = 0; - struct i2c_client *client = pdata->i2c_client; - static int num_error_reports; - if (rfi->fn_number != SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM) { - num_error_reports++; - if (num_error_reports < MAX_ERROR_REPORT) - dev_err(&client->dev, "%s:report not supported\n", - __func__); - } else - touch = synpatics_rmi4_touchpad_report(pdata, rfi); - return touch; -} -/** - * synaptics_rmi4_sensor_report() - reports to input subsystem - * @pdata: pointer to synaptics_rmi4_data structure - * - * This function is used to reads in all data sources and reports - * them to the input subsystem. - */ -static int synaptics_rmi4_sensor_report(struct synaptics_rmi4_data *pdata) -{ - unsigned char intr_status[4]; - /* number of touch points - fingers or buttons */ - int touch = 0; - unsigned int retval; - struct synaptics_rmi4_fn *rfi; - struct synaptics_rmi4_device_info *rmi; - struct i2c_client *client = pdata->i2c_client; - - /* - * Get the interrupt status from the function $01 - * control register+1 to find which source(s) were interrupting - * so we can read the data from the source(s) (2D sensor, buttons..) - */ - retval = synaptics_rmi4_i2c_block_read(pdata, - pdata->fn01_data_base_addr + 1, - intr_status, - pdata->number_of_interrupt_register); - if (retval != pdata->number_of_interrupt_register) { - dev_err(&client->dev, - "could not read interrupt status registers\n"); - return 0; - } - /* - * check each function that has data sources and if the interrupt for - * that triggered then call that RMI4 functions report() function to - * gather data and report it to the input subsystem - */ - rmi = &(pdata->rmi4_mod_info); - list_for_each_entry(rfi, &rmi->support_fn_list, link) { - if (rfi->num_of_data_sources) { - if (intr_status[rfi->index_to_intr_reg] & - rfi->intr_mask) - touch = synaptics_rmi4_report_device(pdata, - rfi); - } - } - /* return the number of touch points */ - return touch; -} - -/** - * synaptics_rmi4_irq() - thread function for rmi4 attention line - * @irq: irq value - * @data: void pointer - * - * This function is interrupt thread function. It just notifies the - * application layer that attention is required. - */ -static irqreturn_t synaptics_rmi4_irq(int irq, void *data) -{ - struct synaptics_rmi4_data *pdata = data; - int touch_count; - do { - touch_count = synaptics_rmi4_sensor_report(pdata); - if (touch_count) - wait_event_timeout(pdata->wait, pdata->touch_stopped, - msecs_to_jiffies(1)); - else - break; - } while (!pdata->touch_stopped); - return IRQ_HANDLED; -} - -/** - * synpatics_rmi4_touchpad_detect() - detects the rmi4 touchpad device - * @pdata: pointer to synaptics_rmi4_data structure - * @rfi: pointer to synaptics_rmi4_fn structure - * @fd: pointer to synaptics_rmi4_fn_desc structure - * @interruptcount: count the number of interrupts - * - * This function calls to detects the rmi4 touchpad device - */ -static int synpatics_rmi4_touchpad_detect(struct synaptics_rmi4_data *pdata, - struct synaptics_rmi4_fn *rfi, - struct synaptics_rmi4_fn_desc *fd, - unsigned int interruptcount) -{ - unsigned char queries[QUERY_LEN]; - unsigned short intr_offset; - unsigned char abs_data_size; - unsigned char abs_data_blk_size; - unsigned char egr_0, egr_1; - unsigned int all_data_blk_size; - int has_pinch, has_flick, has_tap; - int has_tapandhold, has_doubletap; - int has_earlytap, has_press; - int has_palmdetect, has_rotate; - int has_rel; - int i; - int retval; - struct i2c_client *client = pdata->i2c_client; - - rfi->fn_desc.query_base_addr = fd->query_base_addr; - rfi->fn_desc.data_base_addr = fd->data_base_addr; - rfi->fn_desc.intr_src_count = fd->intr_src_count; - rfi->fn_desc.fn_number = fd->fn_number; - rfi->fn_number = fd->fn_number; - rfi->num_of_data_sources = fd->intr_src_count; - rfi->fn_desc.ctrl_base_addr = fd->ctrl_base_addr; - rfi->fn_desc.cmd_base_addr = fd->cmd_base_addr; - - /* - * need to get number of fingers supported, data size, etc. - * to be used when getting data since the number of registers to - * read depends on the number of fingers supported and data size. - */ - retval = synaptics_rmi4_i2c_block_read(pdata, fd->query_base_addr, - queries, - sizeof(queries)); - if (retval != sizeof(queries)) { - dev_err(&client->dev, "%s:read function query registers\n", - __func__); - return retval; - } - /* - * 2D data sources have only 3 bits for the number of fingers - * supported - so the encoding is a bit weird. - */ - if ((queries[1] & MASK_3BIT) <= 4) - /* add 1 since zero based */ - rfi->num_of_data_points = (queries[1] & MASK_3BIT) + 1; - else { - /* - * a value of 5 is up to 10 fingers - 6 and 7 are reserved - * (shouldn't get these i int retval;n a normal 2D source). - */ - if ((queries[1] & MASK_3BIT) == 5) - rfi->num_of_data_points = 10; - } - pdata->fingers_supported = rfi->num_of_data_points; - /* Need to get interrupt info for handling interrupts */ - rfi->index_to_intr_reg = (interruptcount + 7)/8; - if (rfi->index_to_intr_reg != 0) - rfi->index_to_intr_reg -= 1; - /* - * loop through interrupts for each source in fn $11 - * and or in a bit to the interrupt mask for each. - */ - intr_offset = interruptcount % 8; - rfi->intr_mask = 0; - for (i = intr_offset; - i < ((fd->intr_src_count & MASK_3BIT) + intr_offset); i++) - rfi->intr_mask |= 1 << i; - - /* Size of just the absolute data for one finger */ - abs_data_size = queries[5] & MASK_2BIT; - /* One each for X and Y, one for LSB for X & Y, one for W, one for Z */ - abs_data_blk_size = 3 + (2 * (abs_data_size == 0 ? 1 : 0)); - rfi->size_of_data_register_block = abs_data_blk_size; - - /* - * need to determine the size of data to read - this depends on - * conditions such as whether Relative data is reported and if Gesture - * data is reported. - */ - egr_0 = queries[7]; - egr_1 = queries[8]; - - /* - * Get info about what EGR data is supported, whether it has - * Relative data supported, etc. - */ - has_pinch = egr_0 & HAS_PINCH; - has_flick = egr_0 & HAS_FLICK; - has_tap = egr_0 & HAS_TAP; - has_earlytap = egr_0 & HAS_EARLYTAP; - has_press = egr_0 & HAS_PRESS; - has_rotate = egr_1 & HAS_ROTATE; - has_rel = queries[1] & HAS_RELEASE; - has_tapandhold = egr_0 & HAS_TAPANDHOLD; - has_doubletap = egr_0 & HAS_DOUBLETAP; - has_palmdetect = egr_1 & HAS_PALMDETECT; - - /* - * Size of all data including finger status, absolute data for each - * finger, relative data and EGR data - */ - all_data_blk_size = - /* finger status, four fingers per register */ - ((rfi->num_of_data_points + 3) / 4) + - /* absolute data, per finger times number of fingers */ - (abs_data_blk_size * rfi->num_of_data_points) + - /* - * two relative registers (if relative is being reported) - */ - 2 * has_rel + - /* - * F11_2D_data8 is only present if the egr_0 - * register is non-zero. - */ - !!(egr_0) + - /* - * F11_2D_data9 is only present if either egr_0 or - * egr_1 registers are non-zero. - */ - (egr_0 || egr_1) + - /* - * F11_2D_data10 is only present if EGR_PINCH or EGR_FLICK of - * egr_0 reports as 1. - */ - !!(has_pinch | has_flick) + - /* - * F11_2D_data11 and F11_2D_data12 are only present if - * EGR_FLICK of egr_0 reports as 1. - */ - 2 * !!(has_flick); - return retval; -} - -/** - * synaptics_rmi4_touchpad_config() - configures the rmi4 touchpad device - * @pdata: pointer to synaptics_rmi4_data structure - * @rfi: pointer to synaptics_rmi4_fn structure - * - * This function calls to configures the rmi4 touchpad device - */ -static int synaptics_rmi4_touchpad_config(struct synaptics_rmi4_data *pdata, - struct synaptics_rmi4_fn *rfi) -{ - /* - * For the data source - print info and do any - * source specific configuration. - */ - unsigned char data[BUF_LEN]; - int retval = 0; - struct i2c_client *client = pdata->i2c_client; - - /* Get and print some info about the data source... */ - /* To Query 2D devices we need to read from the address obtained - * from the function descriptor stored in the RMI function info. - */ - retval = synaptics_rmi4_i2c_block_read(pdata, - rfi->fn_desc.query_base_addr, - data, QUERY_LEN); - if (retval != QUERY_LEN) - dev_err(&client->dev, "%s:read query registers failed\n", - __func__); - else { - retval = synaptics_rmi4_i2c_block_read(pdata, - rfi->fn_desc.ctrl_base_addr, - data, DATA_BUF_LEN); - if (retval != DATA_BUF_LEN) { - dev_err(&client->dev, - "%s:read control registers failed\n", - __func__); - return retval; - } - /* Store these for use later*/ - pdata->sensor_max_x = ((data[6] & MASK_8BIT) << 0) | - ((data[7] & MASK_4BIT) << 8); - pdata->sensor_max_y = ((data[8] & MASK_5BIT) << 0) | - ((data[9] & MASK_4BIT) << 8); - } - return retval; -} - -/** - * synaptics_rmi4_i2c_query_device() - query the rmi4 device - * @pdata: pointer to synaptics_rmi4_data structure - * - * This function is used to query the rmi4 device. - */ -static int synaptics_rmi4_i2c_query_device(struct synaptics_rmi4_data *pdata) -{ - int i; - int retval; - unsigned char std_queries[STD_QUERY_LEN]; - unsigned char intr_count = 0; - int data_sources = 0; - unsigned int ctrl_offset; - struct synaptics_rmi4_fn *rfi; - struct synaptics_rmi4_fn_desc rmi_fd; - struct synaptics_rmi4_device_info *rmi; - struct i2c_client *client = pdata->i2c_client; - - /* - * init the physical drivers RMI module - * info list of functions - */ - INIT_LIST_HEAD(&pdata->rmi4_mod_info.support_fn_list); - - /* - * Read the Page Descriptor Table to determine what functions - * are present - */ - for (i = PDT_START_SCAN_LOCATION; i > PDT_END_SCAN_LOCATION; - i -= PDT_ENTRY_SIZE) { - retval = synaptics_rmi4_i2c_block_read(pdata, i, - (unsigned char *)&rmi_fd, - sizeof(rmi_fd)); - if (retval != sizeof(rmi_fd)) { - /* failed to read next PDT entry */ - dev_err(&client->dev, "%s: read error\n", __func__); - return -EIO; - } - rfi = NULL; - if (rmi_fd.fn_number) { - switch (rmi_fd.fn_number & MASK_8BIT) { - case SYNAPTICS_RMI4_DEVICE_CONTROL_FUNC_NUM: - pdata->fn01_query_base_addr = - rmi_fd.query_base_addr; - pdata->fn01_ctrl_base_addr = - rmi_fd.ctrl_base_addr; - pdata->fn01_data_base_addr = - rmi_fd.data_base_addr; - break; - case SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM: - if (rmi_fd.intr_src_count) { - rfi = kmalloc(sizeof(*rfi), - GFP_KERNEL); - if (!rfi) - return -ENOMEM; - retval = synpatics_rmi4_touchpad_detect - (pdata, rfi, - &rmi_fd, - intr_count); - if (retval < 0) { - kfree(rfi); - return retval; - } - } - break; - } - /* interrupt count for next iteration */ - intr_count += (rmi_fd.intr_src_count & MASK_3BIT); - /* - * We only want to add functions to the list - * that have data associated with them. - */ - if (rfi && rmi_fd.intr_src_count) { - /* link this function info to the RMI module */ - mutex_lock(&(pdata->fn_list_mutex)); - list_add_tail(&rfi->link, - &pdata->rmi4_mod_info.support_fn_list); - mutex_unlock(&(pdata->fn_list_mutex)); - } - } else { - /* - * A zero in the function number - * signals the end of the PDT - */ - dev_dbg(&client->dev, - "%s:end of PDT\n", __func__); - break; - } - } - /* - * calculate the interrupt register count - used in the - * ISR to read the correct number of interrupt registers - */ - pdata->number_of_interrupt_register = (intr_count + 7) / 8; - /* - * Function $01 will be used to query the product properties, - * and product ID so we had to read the PDT above first to get - * the Fn $01 query address and prior to filling in the product - * info. NOTE: Even an unflashed device will still have FN $01. - */ - - /* Load up the standard queries and get the RMI4 module info */ - retval = synaptics_rmi4_i2c_block_read(pdata, - pdata->fn01_query_base_addr, - std_queries, - sizeof(std_queries)); - if (retval != sizeof(std_queries)) { - dev_err(&client->dev, "%s:Failed reading queries\n", - __func__); - return -EIO; - } - - /* Currently supported RMI version is 4.0 */ - pdata->rmi4_mod_info.version_major = 4; - pdata->rmi4_mod_info.version_minor = 0; - /* - * get manufacturer id, product_props, product info, - * date code, tester id, serial num and product id (name) - */ - pdata->rmi4_mod_info.manufacturer_id = std_queries[0]; - pdata->rmi4_mod_info.product_props = std_queries[1]; - pdata->rmi4_mod_info.product_info[0] = std_queries[2]; - pdata->rmi4_mod_info.product_info[1] = std_queries[3]; - /* year - 2001-2032 */ - pdata->rmi4_mod_info.date_code[0] = std_queries[4] & MASK_5BIT; - /* month - 1-12 */ - pdata->rmi4_mod_info.date_code[1] = std_queries[5] & MASK_4BIT; - /* day - 1-31 */ - pdata->rmi4_mod_info.date_code[2] = std_queries[6] & MASK_5BIT; - pdata->rmi4_mod_info.tester_id = ((std_queries[7] & MASK_7BIT) << 8) | - (std_queries[8] & MASK_7BIT); - pdata->rmi4_mod_info.serial_number = - ((std_queries[9] & MASK_7BIT) << 8) | - (std_queries[10] & MASK_7BIT); - memcpy(pdata->rmi4_mod_info.product_id_string, &std_queries[11], 10); - - /* Check if this is a Synaptics device - report if not. */ - if (pdata->rmi4_mod_info.manufacturer_id != 1) - dev_err(&client->dev, "%s: non-Synaptics mfg id:%d\n", - __func__, pdata->rmi4_mod_info.manufacturer_id); - - list_for_each_entry(rfi, &pdata->rmi4_mod_info.support_fn_list, link) - data_sources += rfi->num_of_data_sources; - if (data_sources) { - rmi = &(pdata->rmi4_mod_info); - list_for_each_entry(rfi, &rmi->support_fn_list, link) { - if (rfi->num_of_data_sources) { - if (rfi->fn_number == - SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM) { - retval = synaptics_rmi4_touchpad_config - (pdata, rfi); - if (retval < 0) - return retval; - } else - dev_err(&client->dev, - "%s:fn_number not supported\n", - __func__); - /* - * Turn on interrupts for this - * function's data sources. - */ - ctrl_offset = pdata->fn01_ctrl_base_addr + 1 + - rfi->index_to_intr_reg; - retval = synaptics_rmi4_i2c_byte_write(pdata, - ctrl_offset, - rfi->intr_mask); - if (retval < 0) - return retval; - } - } - } - return 0; -} - -/* - * Descriptor structure. - * Describes the number of i2c devices on the bus that speak RMI. - */ -static struct synaptics_rmi4_platform_data synaptics_rmi4_platformdata = { - .irq_type = (IRQF_TRIGGER_FALLING | IRQF_SHARED), - .x_flip = false, - .y_flip = true, -}; - -/** - * synaptics_rmi4_probe() - Initialze the i2c-client touchscreen driver - * @i2c: i2c client structure pointer - * @id:i2c device id pointer - * - * This function will allocate and initialize the instance - * data and request the irq and set the instance data as the clients - * platform data then register the physical driver which will do a scan of - * the rmi4 Physical Device Table and enumerate any rmi4 functions that - * have data sources associated with them. - */ -static int synaptics_rmi4_probe - (struct i2c_client *client, const struct i2c_device_id *dev_id) -{ - int retval; - unsigned char intr_status[4]; - struct synaptics_rmi4_data *rmi4_data; - const struct synaptics_rmi4_platform_data *platformdata = - client->dev.platform_data; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&client->dev, "i2c smbus byte data not supported\n"); - return -EIO; - } - - if (!platformdata) - platformdata = &synaptics_rmi4_platformdata; - - /* Allocate and initialize the instance data for this client */ - rmi4_data = kcalloc(2, sizeof(struct synaptics_rmi4_data), - GFP_KERNEL); - if (!rmi4_data) - return -ENOMEM; - - rmi4_data->input_dev = input_allocate_device(); - if (rmi4_data->input_dev == NULL) { - dev_err(&client->dev, "%s:input device alloc failed\n", - __func__); - retval = -ENOMEM; - goto err_input; - } - - rmi4_data->regulator = regulator_get(&client->dev, "vdd"); - if (IS_ERR(rmi4_data->regulator)) { - dev_err(&client->dev, "%s:get regulator failed\n", - __func__); - retval = PTR_ERR(rmi4_data->regulator); - goto err_get_regulator; - } - retval = regulator_enable(rmi4_data->regulator); - if (retval < 0) { - dev_err(&client->dev, "%s:regulator enable failed\n", - __func__); - goto err_regulator_enable; - } - init_waitqueue_head(&rmi4_data->wait); - /* - * Copy i2c_client pointer into RTID's i2c_client pointer for - * later use in rmi4_read, rmi4_write, etc. - */ - rmi4_data->i2c_client = client; - /* So we set the page correctly the first time */ - rmi4_data->current_page = MASK_16BIT; - rmi4_data->board = platformdata; - rmi4_data->touch_stopped = false; - - /* init the mutexes for maintain the lists */ - mutex_init(&(rmi4_data->fn_list_mutex)); - mutex_init(&(rmi4_data->rmi4_page_mutex)); - - /* - * Register physical driver - this will call the detect function that - * will then scan the device and determine the supported - * rmi4 functions. - */ - retval = synaptics_rmi4_i2c_query_device(rmi4_data); - if (retval) { - dev_err(&client->dev, "%s: rmi4 query device failed\n", - __func__); - goto err_query_dev; - } - - /* Store the instance data in the i2c_client */ - i2c_set_clientdata(client, rmi4_data); - - /*initialize the input device parameters */ - rmi4_data->input_dev->name = DRIVER_NAME; - rmi4_data->input_dev->phys = "Synaptics_Clearpad"; - rmi4_data->input_dev->id.bustype = BUS_I2C; - rmi4_data->input_dev->dev.parent = &client->dev; - input_set_drvdata(rmi4_data->input_dev, rmi4_data); - - /* Initialize the function handlers for rmi4 */ - set_bit(EV_SYN, rmi4_data->input_dev->evbit); - set_bit(EV_KEY, rmi4_data->input_dev->evbit); - set_bit(EV_ABS, rmi4_data->input_dev->evbit); - - input_set_abs_params(rmi4_data->input_dev, ABS_MT_POSITION_X, 0, - rmi4_data->sensor_max_x, 0, 0); - input_set_abs_params(rmi4_data->input_dev, ABS_MT_POSITION_Y, 0, - rmi4_data->sensor_max_y, 0, 0); - input_set_abs_params(rmi4_data->input_dev, ABS_MT_TOUCH_MAJOR, 0, - MAX_TOUCH_MAJOR, 0, 0); - input_mt_init_slots(rmi4_data->input_dev, - rmi4_data->fingers_supported, 0); - - /* Clear interrupts */ - synaptics_rmi4_i2c_block_read(rmi4_data, - rmi4_data->fn01_data_base_addr + 1, intr_status, - rmi4_data->number_of_interrupt_register); - retval = request_threaded_irq(client->irq, NULL, - synaptics_rmi4_irq, - platformdata->irq_type, - DRIVER_NAME, rmi4_data); - if (retval) { - dev_err(&client->dev, "%s:Unable to get attn irq %d\n", - __func__, client->irq); - goto err_query_dev; - } - - retval = input_register_device(rmi4_data->input_dev); - if (retval) { - dev_err(&client->dev, "%s:input register failed\n", __func__); - goto err_free_irq; - } - - return retval; - -err_free_irq: - free_irq(client->irq, rmi4_data); -err_query_dev: - regulator_disable(rmi4_data->regulator); -err_regulator_enable: - regulator_put(rmi4_data->regulator); -err_get_regulator: - input_free_device(rmi4_data->input_dev); - rmi4_data->input_dev = NULL; -err_input: - kfree(rmi4_data); - - return retval; -} -/** - * synaptics_rmi4_remove() - Removes the i2c-client touchscreen driver - * @client: i2c client structure pointer - * - * This function uses to remove the i2c-client - * touchscreen driver and returns integer. - */ -static int synaptics_rmi4_remove(struct i2c_client *client) -{ - struct synaptics_rmi4_data *rmi4_data = i2c_get_clientdata(client); - - rmi4_data->touch_stopped = true; - wake_up(&rmi4_data->wait); - free_irq(client->irq, rmi4_data); - input_unregister_device(rmi4_data->input_dev); - regulator_disable(rmi4_data->regulator); - regulator_put(rmi4_data->regulator); - kfree(rmi4_data); - - return 0; -} - -#ifdef CONFIG_PM -/** - * synaptics_rmi4_suspend() - suspend the touch screen controller - * @dev: pointer to device structure - * - * This function is used to suspend the - * touch panel controller and returns integer - */ -static int synaptics_rmi4_suspend(struct device *dev) -{ - /* Touch sleep mode */ - int retval; - unsigned char intr_status; - struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev); - - rmi4_data->touch_stopped = true; - disable_irq(rmi4_data->i2c_client->irq); - - retval = synaptics_rmi4_i2c_block_read(rmi4_data, - rmi4_data->fn01_data_base_addr + 1, - &intr_status, - rmi4_data->number_of_interrupt_register); - if (retval < 0) - return retval; - - retval = synaptics_rmi4_i2c_byte_write(rmi4_data, - rmi4_data->fn01_ctrl_base_addr + 1, - (intr_status & ~TOUCHPAD_CTRL_INTR)); - if (retval < 0) - return retval; - - regulator_disable(rmi4_data->regulator); - - return 0; -} -/** - * synaptics_rmi4_resume() - resume the touch screen controller - * @dev: pointer to device structure - * - * This function is used to resume the touch panel - * controller and returns integer. - */ -static int synaptics_rmi4_resume(struct device *dev) -{ - int retval; - unsigned char intr_status; - struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev); - - retval = regulator_enable(rmi4_data->regulator); - if (retval) { - dev_err(dev, "Regulator enable failed (%d)\n", retval); - return retval; - } - - enable_irq(rmi4_data->i2c_client->irq); - rmi4_data->touch_stopped = false; - - retval = synaptics_rmi4_i2c_block_read(rmi4_data, - rmi4_data->fn01_data_base_addr + 1, - &intr_status, - rmi4_data->number_of_interrupt_register); - if (retval < 0) - return retval; - - retval = synaptics_rmi4_i2c_byte_write(rmi4_data, - rmi4_data->fn01_ctrl_base_addr + 1, - (intr_status | TOUCHPAD_CTRL_INTR)); - if (retval < 0) - return retval; - - return 0; -} - -static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = { - .suspend = synaptics_rmi4_suspend, - .resume = synaptics_rmi4_resume, -}; -#endif - -static const struct i2c_device_id synaptics_rmi4_id_table[] = { - { DRIVER_NAME, 0 }, - { }, -}; -MODULE_DEVICE_TABLE(i2c, synaptics_rmi4_id_table); - -static struct i2c_driver synaptics_rmi4_driver = { - .driver = { - .name = DRIVER_NAME, - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &synaptics_rmi4_dev_pm_ops, -#endif - }, - .probe = synaptics_rmi4_probe, - .remove = synaptics_rmi4_remove, - .id_table = synaptics_rmi4_id_table, -}; - -module_i2c_driver(synaptics_rmi4_driver); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("naveen.gaddipati@stericsson.com, js.ha@stericsson.com"); -MODULE_DESCRIPTION("synaptics rmi4 i2c touch Driver"); -MODULE_ALIAS("i2c:synaptics_rmi4_ts"); diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4_staging.h b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4_staging.h deleted file mode 100644 index 8c9166ba71c7d59d9c1e41cce18b492225716999..0000000000000000000000000000000000000000 --- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4_staging.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - * Synaptics Register Mapped Interface (RMI4) I2C Physical Layer Driver. - * Copyright (c) 2007-2010, Synaptics Incorporated - * - * Author: Js HA for ST-Ericsson - * Author: Naveen Kumar G for ST-Ericsson - * Copyright 2010 (c) ST-Ericsson AB - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _SYNAPTICS_RMI4_H_INCLUDED_ -#define _SYNAPTICS_RMI4_H_INCLUDED_ - -/** - * struct synaptics_rmi4_platform_data - contains the rmi4 platform data - * @irq_number: irq number - * @irq_type: irq type - * @x flip: x flip flag - * @y flip: y flip flag - * - * This structure gives platform data for rmi4. - */ -struct synaptics_rmi4_platform_data { - int irq_type; - bool x_flip; - bool y_flip; -}; - -#endif diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 712d5a2d416d7a19a9b5848f99956e082fcf235a..e6e5b1cf527b9b7adba09a3b8a9dfdf520f94d7b 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -91,39 +91,6 @@ config THERMAL_EMULATION because userland can easily disable the thermal policy by simply flooding this sysfs node with low temperature values. -config THERMAL_MSM_POPMEM - tristate "Qualcomm MSM POP memory temperature sensor" - depends on THERMAL - default n - help - This enables a thermal sysfs driver for MSM POP memory. It shows up in - sysfs as a thermal zone with one trip point. Due to hardware - limitations, the temperatures are reported as "Low Temperature" (20 C) - "Normal Temperature" (50 C) and "Out of Spec High Temperature" (85 C). - This driver is designed to be used in conjunction with a user space - application to make all policy decisions. - -config THERMAL_TSENS - tristate "Qualcomm Tsens Temperature Alarm" - depends on THERMAL - default n - help - This enables the thermal sysfs driver for the Tsens device. It shows - up in Sysfs as a thermal zone with mutiple trip points. Disabling the - thermal zone device via the mode file results in disabling the sensor. - Also able to set threshold temperature for both hot and cold and update - when a threshold is reached. - -config THERMAL_TSENS8960 - tristate "Qualcomm 8960 Tsens Temperature Alarm" - depends on THERMAL - help - This enables the thermal sysfs driver for the Tsens device. It shows - up in Sysfs as a thermal zone with mutiple trip points. Disabling the - thermal zone device via the mode file results in disabling the sensor. - Also able to set threshold temperature for both hot and cold and update - when a threshold is reached. - config THERMAL_TSENS8974 tristate "Qualcomm 8974 TSENS Temperature driver" depends on THERMAL @@ -134,17 +101,6 @@ config THERMAL_TSENS8974 thermal userspace client when a threshold is reached. Warm/Cool temperature thresholds can be set independently for each sensor. -config THERMAL_PM8XXX - tristate "Qualcomm PMIC PM8xxx Temperature Alarm" - depends on THERMAL - depends on MFD_PM8XXX - help - This enables a thermal Sysfs driver for the PMIC PM8xxx devices. It - shows up in Sysfs as a thermal zone with multiple trip points. - Enabling the thermal zone device via the mode file results in - shifting over temperature shutdown control of the PMIC from hardware - to software. - config THERMAL_MONITOR bool "Monitor thermal state and limit CPU Frequency" depends on THERMAL_TSENS8960 || THERMAL_TSENS8974 diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 74443fa45cdb108155d6abc4047b5802b171f140..5b2442fcae12a73f24157f9a52036a921dca3f2b 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -23,10 +23,6 @@ obj-$(CONFIG_DB8500_THERMAL) += db8500_thermal.o obj-$(CONFIG_ARMADA_THERMAL) += armada_thermal.o obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o obj-$(CONFIG_INTEL_POWERCLAMP) += intel_powerclamp.o -obj-$(CONFIG_THERMAL_MSM_POPMEM) += msm_popmem-tm.o -obj-$(CONFIG_THERMAL_TSENS) += msm_tsens.o -obj-$(CONFIG_THERMAL_TSENS8960) += msm8960_tsens.o -obj-$(CONFIG_THERMAL_PM8XXX) += pm8xxx-tm.o obj-$(CONFIG_THERMAL_MONITOR) += msm_thermal.o obj-$(CONFIG_THERMAL_TSENS8974) += msm8974-tsens.o obj-$(CONFIG_THERMAL_QPNP) += qpnp-temp-alarm.o diff --git a/drivers/thermal/msm8960_tsens.c b/drivers/thermal/msm8960_tsens.c deleted file mode 100644 index ba94b5ef0a6c5f716064b13610c8b0738e9123cd..0000000000000000000000000000000000000000 --- a/drivers/thermal/msm8960_tsens.c +++ /dev/null @@ -1,1104 +0,0 @@ -/* Copyright (c) 2011-2013, 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. - * - */ -/* - * Qualcomm MSM8960 TSENS driver - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* Trips: from very hot to very cold */ -enum tsens_trip_type { - TSENS_TRIP_STAGE3 = 0, - TSENS_TRIP_STAGE2, - TSENS_TRIP_STAGE1, - TSENS_TRIP_STAGE0, - TSENS_TRIP_NUM, -}; - -/* MSM8960 TSENS register info */ -#define TSENS_CAL_DEGC 30 -#define TSENS_MAIN_SENSOR 0 - -#define TSENS_8960_QFPROM_ADDR0 (MSM_QFPROM_BASE + 0x00000404) -#define TSENS_8960_QFPROM_SPARE_ADDR0 (MSM_QFPROM_BASE + 0x00000414) -#define TSENS_8960_CONFIG 0x9b -#define TSENS_8960_CONFIG_SHIFT 0 -#define TSENS_8960_CONFIG_MASK (0xf << TSENS_8960_CONFIG_SHIFT) -#define TSENS_CNTL_ADDR (MSM_CLK_CTL_BASE + 0x00003620) -#define TSENS_EN BIT(0) -#define TSENS_SW_RST BIT(1) -#define TSENS_ADC_CLK_SEL BIT(2) -#define SENSOR0_EN BIT(3) -#define SENSOR1_EN BIT(4) -#define SENSOR2_EN BIT(5) -#define SENSOR3_EN BIT(6) -#define SENSOR4_EN BIT(7) -#define SENSORS_EN (SENSOR0_EN | SENSOR1_EN | \ - SENSOR2_EN | SENSOR3_EN | SENSOR4_EN) -#define TSENS_STATUS_CNTL_OFFSET 8 -#define TSENS_MIN_STATUS_MASK BIT((tsens_status_cntl_start)) -#define TSENS_LOWER_STATUS_CLR BIT((tsens_status_cntl_start + 1)) -#define TSENS_UPPER_STATUS_CLR BIT((tsens_status_cntl_start + 2)) -#define TSENS_MAX_STATUS_MASK BIT((tsens_status_cntl_start + 3)) - -#define TSENS_MEASURE_PERIOD 1 -#define TSENS_8960_SLP_CLK_ENA BIT(26) - -#define TSENS_THRESHOLD_ADDR (MSM_CLK_CTL_BASE + 0x00003624) -#define TSENS_THRESHOLD_MAX_CODE 0xff -#define TSENS_THRESHOLD_MIN_CODE 0 -#define TSENS_THRESHOLD_MAX_LIMIT_SHIFT 24 -#define TSENS_THRESHOLD_MIN_LIMIT_SHIFT 16 -#define TSENS_THRESHOLD_UPPER_LIMIT_SHIFT 8 -#define TSENS_THRESHOLD_LOWER_LIMIT_SHIFT 0 -#define TSENS_THRESHOLD_MAX_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << \ - TSENS_THRESHOLD_MAX_LIMIT_SHIFT) -#define TSENS_THRESHOLD_MIN_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << \ - TSENS_THRESHOLD_MIN_LIMIT_SHIFT) -#define TSENS_THRESHOLD_UPPER_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << \ - TSENS_THRESHOLD_UPPER_LIMIT_SHIFT) -#define TSENS_THRESHOLD_LOWER_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << \ - TSENS_THRESHOLD_LOWER_LIMIT_SHIFT) -/* Initial temperature threshold values */ -#define TSENS_LOWER_LIMIT_TH 0x50 -#define TSENS_UPPER_LIMIT_TH 0x9a -#define TSENS_MIN_LIMIT_TH 0x0 -#define TSENS_MAX_LIMIT_TH 0xff - -#define TSENS_S0_STATUS_ADDR (MSM_CLK_CTL_BASE + 0x00003628) -#define TSENS_STATUS_ADDR_OFFSET 2 -#define TSENS_SENSOR_STATUS_SIZE 4 -#define TSENS_INT_STATUS_ADDR (MSM_CLK_CTL_BASE + 0x0000363c) - -#define TSENS_LOWER_INT_MASK BIT(1) -#define TSENS_UPPER_INT_MASK BIT(2) -#define TSENS_MAX_INT_MASK BIT(3) -#define TSENS_TRDY_MASK BIT(7) - -#define TSENS_8960_CONFIG_ADDR (MSM_CLK_CTL_BASE + 0x00003640) -#define TSENS_TRDY_RDY_MIN_TIME 1000 -#define TSENS_TRDY_RDY_MAX_TIME 1100 -#define TSENS_SENSOR_SHIFT 16 -#define TSENS_RED_SHIFT 8 -#define TSENS_8960_QFPROM_SHIFT 4 -#define TSENS_SENSOR_QFPROM_SHIFT 2 -#define TSENS_SENSOR0_SHIFT 3 -#define TSENS_MASK1 1 - -#define TSENS_8660_QFPROM_ADDR (MSM_QFPROM_BASE + 0x000000bc) -#define TSENS_8660_QFPROM_RED_TEMP_SENSOR0_SHIFT 24 -#define TSENS_8660_QFPROM_TEMP_SENSOR0_SHIFT 16 -#define TSENS_8660_QFPROM_TEMP_SENSOR0_MASK (255 \ - << TSENS_8660_QFPROM_TEMP_SENSOR0_SHIFT) -#define TSENS_8660_CONFIG 01 -#define TSENS_8660_CONFIG_SHIFT 28 -#define TSENS_8660_CONFIG_MASK (3 << TSENS_8660_CONFIG_SHIFT) -#define TSENS_8660_SLP_CLK_ENA BIT(24) - -#define TSENS_8064_SENSOR5_EN BIT(8) -#define TSENS_8064_SENSOR6_EN BIT(9) -#define TSENS_8064_SENSOR7_EN BIT(10) -#define TSENS_8064_SENSOR8_EN BIT(11) -#define TSENS_8064_SENSOR9_EN BIT(12) -#define TSENS_8064_SENSOR10_EN BIT(13) -#define TSENS_8064_SENSORS_EN (SENSORS_EN | \ - TSENS_8064_SENSOR5_EN | \ - TSENS_8064_SENSOR6_EN | \ - TSENS_8064_SENSOR7_EN | \ - TSENS_8064_SENSOR8_EN | \ - TSENS_8064_SENSOR9_EN | \ - TSENS_8064_SENSOR10_EN) -#define TSENS_8064_STATUS_CNTL (MSM_CLK_CTL_BASE + 0x00003660) -#define TSENS_8064_S5_STATUS_ADDR (MSM_CLK_CTL_BASE + 0x00003664) -#define TSENS_8064_SEQ_SENSORS 5 -#define TSENS_8064_S4_S5_OFFSET 40 -#define TSENS_CNTL_RESUME_MASK 0xfffffff9 -#define TSENS_8960_SENSOR_MASK 0xf8 -#define TSENS_8064_SENSOR_MASK 0x3ff8 -#define TSENS_8064_MAX_INT_MASK_EN (true) -#define TSENS_8064_MAX_LIMIT_TEMP 135 - -static int tsens_status_cntl_start; - -struct tsens_tm_device_sensor { - struct thermal_zone_device *tz_dev; - enum thermal_device_mode mode; - unsigned int sensor_num; - struct work_struct work; - int offset; - int calib_data; - int calib_data_backup; - uint32_t slope_mul_tsens_factor; -}; - -struct tsens_tm_device { - bool prev_reading_avail; - int tsens_factor; - uint32_t tsens_num_sensor; - enum platform_type hw_type; - int pm_tsens_thr_data; - int pm_tsens_cntl; - struct work_struct tsens_work; - struct tsens_tm_device_sensor sensor[0]; -}; - -struct tsens_tm_device *tmdev; - -/* Temperature on y axis and ADC-code on x-axis */ -static int tsens_tz_code_to_degC(int adc_code, int sensor_num) -{ - int degcbeforefactor, degc; - degcbeforefactor = (adc_code * - tmdev->sensor[sensor_num].slope_mul_tsens_factor - + tmdev->sensor[sensor_num].offset); - - if (degcbeforefactor == 0) - degc = degcbeforefactor; - else if (degcbeforefactor > 0) - degc = (degcbeforefactor + tmdev->tsens_factor/2) - / tmdev->tsens_factor; - else - degc = (degcbeforefactor - tmdev->tsens_factor/2) - / tmdev->tsens_factor; - pr_debug("%s: sensor=%d code=0x%x degc=%d\n", - __func__, sensor_num, adc_code, degc); - return degc; -} - -static int tsens_tz_degC_to_code(int degC, int sensor_num) -{ - int code = (degC * tmdev->tsens_factor - - tmdev->sensor[sensor_num].offset - + tmdev->sensor[sensor_num].slope_mul_tsens_factor/2) - / tmdev->sensor[sensor_num].slope_mul_tsens_factor; - - if (code > TSENS_THRESHOLD_MAX_CODE) - code = TSENS_THRESHOLD_MAX_CODE; - else if (code < TSENS_THRESHOLD_MIN_CODE) - code = TSENS_THRESHOLD_MIN_CODE; - pr_debug("%s: sensor=%d degc=%d code=0x%x\n", - __func__, sensor_num, degC, code); - return code; -} - -static void tsens8960_get_temp(int sensor_num, unsigned long *temp) -{ - unsigned int code, offset = 0, sensor_addr; - - if (!tmdev->prev_reading_avail) { - while (!(readl_relaxed(TSENS_INT_STATUS_ADDR) - & TSENS_TRDY_MASK)) - usleep_range(TSENS_TRDY_RDY_MIN_TIME, - TSENS_TRDY_RDY_MAX_TIME); - tmdev->prev_reading_avail = true; - } - - sensor_addr = (unsigned int)TSENS_S0_STATUS_ADDR; - if (tmdev->hw_type == APQ_8064 && - sensor_num >= TSENS_8064_SEQ_SENSORS) - offset = TSENS_8064_S4_S5_OFFSET; - code = readl_relaxed(sensor_addr + offset + - (sensor_num << TSENS_STATUS_ADDR_OFFSET)); - *temp = tsens_tz_code_to_degC(code, sensor_num); -} - -static int tsens_tz_get_temp(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - - if (!tm_sensor || tm_sensor->mode != THERMAL_DEVICE_ENABLED || !temp) - return -EINVAL; - - tsens8960_get_temp(tm_sensor->sensor_num, temp); - - return 0; -} - -int tsens_get_temp(struct tsens_device *device, unsigned long *temp) -{ - if (!tmdev) - return -ENODEV; - - tsens8960_get_temp(device->sensor_num, temp); - - return 0; -} -EXPORT_SYMBOL(tsens_get_temp); - -int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors) -{ - if (!tmdev) - return -ENODEV; - - *tsens_num_sensors = tmdev->tsens_num_sensor; - - return 0; -} -EXPORT_SYMBOL(tsens_get_max_sensor_num); - -static int tsens_tz_get_mode(struct thermal_zone_device *thermal, - enum thermal_device_mode *mode) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - - if (!tm_sensor || !mode) - return -EINVAL; - - *mode = tm_sensor->mode; - - return 0; -} - -/* Function to enable the mode. - * If the main sensor is disabled all the sensors are disable and - * the clock is disabled. - * If the main sensor is not enabled and sub sensor is enabled - * returns with an error stating the main sensor is not enabled. - */ -static int tsens_tz_set_mode(struct thermal_zone_device *thermal, - enum thermal_device_mode mode) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg, mask, i; - - if (!tm_sensor) - return -EINVAL; - - if (mode != tm_sensor->mode) { - reg = readl_relaxed(TSENS_CNTL_ADDR); - - mask = 1 << (tm_sensor->sensor_num + TSENS_SENSOR0_SHIFT); - if (mode == THERMAL_DEVICE_ENABLED) { - if ((mask != SENSOR0_EN) && !(reg & SENSOR0_EN)) { - pr_info("Main sensor not enabled\n"); - return -EINVAL; - } - writel_relaxed(reg | TSENS_SW_RST, TSENS_CNTL_ADDR); - if (tmdev->hw_type == MSM_8960 || - tmdev->hw_type == MDM_9615 || - tmdev->hw_type == APQ_8064) - reg |= mask | TSENS_8960_SLP_CLK_ENA - | TSENS_EN; - else - reg |= mask | TSENS_8660_SLP_CLK_ENA - | TSENS_EN; - tmdev->prev_reading_avail = false; - } else { - reg &= ~mask; - if (!(reg & SENSOR0_EN)) { - if (tmdev->hw_type == APQ_8064) - reg &= ~(TSENS_8064_SENSORS_EN | - TSENS_8960_SLP_CLK_ENA | - TSENS_EN); - else if (tmdev->hw_type == MSM_8960 || - tmdev->hw_type == MDM_9615) - reg &= ~(SENSORS_EN | - TSENS_8960_SLP_CLK_ENA | - TSENS_EN); - else - reg &= ~(SENSORS_EN | - TSENS_8660_SLP_CLK_ENA | - TSENS_EN); - - for (i = 1; i < tmdev->tsens_num_sensor; i++) - tmdev->sensor[i].mode = mode; - - } - } - writel_relaxed(reg, TSENS_CNTL_ADDR); - } - tm_sensor->mode = mode; - - return 0; -} - -static int tsens_tz_get_trip_type(struct thermal_zone_device *thermal, - int trip, enum thermal_trip_type *type) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - - if (!tm_sensor || trip < 0 || !type) - return -EINVAL; - - switch (trip) { - case TSENS_TRIP_STAGE3: - *type = THERMAL_TRIP_CRITICAL; - break; - case TSENS_TRIP_STAGE2: - *type = THERMAL_TRIP_CONFIGURABLE_HI; - break; - case TSENS_TRIP_STAGE1: - *type = THERMAL_TRIP_CONFIGURABLE_LOW; - break; - case TSENS_TRIP_STAGE0: - *type = THERMAL_TRIP_CRITICAL_LOW; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int tsens_tz_activate_trip_type(struct thermal_zone_device *thermal, - int trip, enum thermal_trip_activation_mode mode) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg_cntl, reg_th, code, hi_code, lo_code, mask; - - if (!tm_sensor || trip < 0) - return -EINVAL; - - lo_code = TSENS_THRESHOLD_MIN_CODE; - hi_code = TSENS_THRESHOLD_MAX_CODE; - - if (tmdev->hw_type == APQ_8064) - reg_cntl = readl_relaxed(TSENS_8064_STATUS_CNTL); - else - reg_cntl = readl_relaxed(TSENS_CNTL_ADDR); - - reg_th = readl_relaxed(TSENS_THRESHOLD_ADDR); - switch (trip) { - case TSENS_TRIP_STAGE3: - code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - mask = TSENS_MAX_STATUS_MASK; - - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE2: - code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - mask = TSENS_UPPER_STATUS_CLR; - - if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE1: - code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - mask = TSENS_LOWER_STATUS_CLR; - - if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE0: - code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - mask = TSENS_MIN_STATUS_MASK; - - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - break; - default: - return -EINVAL; - } - - if (mode == THERMAL_TRIP_ACTIVATION_DISABLED) { - if (tmdev->hw_type == APQ_8064) - writel_relaxed(reg_cntl | mask, TSENS_8064_STATUS_CNTL); - else - writel_relaxed(reg_cntl | mask, TSENS_CNTL_ADDR); - } else { - if (code < lo_code || code > hi_code) { - pr_info("%s with invalid code %x\n", __func__, code); - return -EINVAL; - } - if (tmdev->hw_type == APQ_8064) - writel_relaxed(reg_cntl & ~mask, - TSENS_8064_STATUS_CNTL); - else - writel_relaxed(reg_cntl & ~mask, TSENS_CNTL_ADDR); - } - mb(); - pr_debug("%s: trip=0x%x reg_th=0x%x reg_cntl=0x%x mode=%d\n", - __func__, trip, reg_th, - readl_relaxed(TSENS_8064_STATUS_CNTL), - mode == THERMAL_TRIP_ACTIVATION_DISABLED ? 0 : 1); - return 0; -} - -static int tsens_tz_get_trip_temp(struct thermal_zone_device *thermal, - int trip, unsigned long *temp) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg; - - if (!tm_sensor || trip < 0 || !temp) - return -EINVAL; - - reg = readl_relaxed(TSENS_THRESHOLD_ADDR); - switch (trip) { - case TSENS_TRIP_STAGE3: - reg = (reg & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE2: - reg = (reg & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE1: - reg = (reg & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE0: - reg = (reg & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - break; - default: - return -EINVAL; - } - - *temp = tsens_tz_code_to_degC(reg, tm_sensor->sensor_num); - - return 0; -} - -static int tsens_tz_get_crit_temp(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - return tsens_tz_get_trip_temp(thermal, TSENS_TRIP_STAGE3, temp); -} - -static int tsens_tz_notify(struct thermal_zone_device *thermal, - int count, enum thermal_trip_type type) -{ - /* TSENS driver does not shutdown the device. - All Thermal notification are sent to the - thermal daemon to take appropriate action */ - return 1; -} - -static int tsens_tz_set_trip_temp(struct thermal_zone_device *thermal, - int trip, long temp) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg_th, reg_cntl; - int code, hi_code, lo_code, code_err_chk; - - code_err_chk = code = tsens_tz_degC_to_code(temp, - tm_sensor->sensor_num); - if (!tm_sensor || trip < 0) - return -EINVAL; - - lo_code = TSENS_THRESHOLD_MIN_CODE; - hi_code = TSENS_THRESHOLD_MAX_CODE; - - if (tmdev->hw_type == APQ_8064) - reg_cntl = readl_relaxed(TSENS_8064_STATUS_CNTL); - else - reg_cntl = readl_relaxed(TSENS_CNTL_ADDR); - reg_th = readl_relaxed(TSENS_THRESHOLD_ADDR); - switch (trip) { - case TSENS_TRIP_STAGE3: - code <<= TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - reg_th &= ~TSENS_THRESHOLD_MAX_LIMIT_MASK; - - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE2: - code <<= TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - reg_th &= ~TSENS_THRESHOLD_UPPER_LIMIT_MASK; - - if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE1: - code <<= TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - reg_th &= ~TSENS_THRESHOLD_LOWER_LIMIT_MASK; - - if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - break; - case TSENS_TRIP_STAGE0: - code <<= TSENS_THRESHOLD_MIN_LIMIT_SHIFT; - reg_th &= ~TSENS_THRESHOLD_MIN_LIMIT_MASK; - - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> TSENS_THRESHOLD_MAX_LIMIT_SHIFT; - break; - default: - return -EINVAL; - } - - - if (code_err_chk < lo_code || code_err_chk > hi_code) { - pr_err("%s: Failed to set the threshold for trip=0x%x\n", - __func__, trip); - return -EINVAL; - } - - writel_relaxed(reg_th | code, TSENS_THRESHOLD_ADDR); - - pr_debug("%s: trip=0x%x reg_cntl=0x%x reg_th=0x%x\n", - __func__, trip, reg_cntl, - readl_relaxed(TSENS_THRESHOLD_ADDR)); - return 0; -} - -static struct thermal_zone_device_ops tsens_thermal_zone_ops = { - .get_temp = tsens_tz_get_temp, - .get_mode = tsens_tz_get_mode, - .set_mode = tsens_tz_set_mode, - .get_trip_type = tsens_tz_get_trip_type, - .activate_trip_type = tsens_tz_activate_trip_type, - .get_trip_temp = tsens_tz_get_trip_temp, - .set_trip_temp = tsens_tz_set_trip_temp, - .get_crit_temp = tsens_tz_get_crit_temp, - .notify = tsens_tz_notify, -}; - -static void notify_uspace_tsens_fn(struct work_struct *work) -{ - struct tsens_tm_device_sensor *tm = container_of(work, - struct tsens_tm_device_sensor, work); - - sysfs_notify(&tm->tz_dev->device.kobj, - NULL, "type"); -} - -static void tsens_scheduler_fn(struct work_struct *work) -{ - struct tsens_tm_device *tm = container_of(work, struct tsens_tm_device, - tsens_work); - unsigned int threshold, threshold_low, i, code, reg, sensor, mask; - unsigned int sensor_addr; - bool upper_th_x, lower_th_x; - int adc_code; - - if (tmdev->hw_type == APQ_8064) { - reg = readl_relaxed(TSENS_8064_STATUS_CNTL); - writel_relaxed(reg | TSENS_LOWER_STATUS_CLR | - TSENS_UPPER_STATUS_CLR, TSENS_8064_STATUS_CNTL); - } else { - reg = readl_relaxed(TSENS_CNTL_ADDR); - writel_relaxed(reg | TSENS_LOWER_STATUS_CLR | - TSENS_UPPER_STATUS_CLR, TSENS_CNTL_ADDR); - } - - mask = ~(TSENS_LOWER_STATUS_CLR | TSENS_UPPER_STATUS_CLR); - threshold = readl_relaxed(TSENS_THRESHOLD_ADDR); - threshold_low = (threshold & TSENS_THRESHOLD_LOWER_LIMIT_MASK) - >> TSENS_THRESHOLD_LOWER_LIMIT_SHIFT; - threshold = (threshold & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> TSENS_THRESHOLD_UPPER_LIMIT_SHIFT; - sensor = readl_relaxed(TSENS_CNTL_ADDR); - if (tmdev->hw_type == APQ_8064) { - reg = readl_relaxed(TSENS_8064_STATUS_CNTL); - sensor &= (uint32_t) TSENS_8064_SENSORS_EN; - } else { - reg = sensor; - sensor &= (uint32_t) SENSORS_EN; - } - sensor >>= TSENS_SENSOR0_SHIFT; - sensor_addr = (unsigned int)TSENS_S0_STATUS_ADDR; - for (i = 0; i < tmdev->tsens_num_sensor; i++) { - if (i == TSENS_8064_SEQ_SENSORS) - sensor_addr += TSENS_8064_S4_S5_OFFSET; - if (sensor & TSENS_MASK1) { - code = readl_relaxed(sensor_addr); - upper_th_x = code >= threshold; - lower_th_x = code <= threshold_low; - if (upper_th_x) - mask |= TSENS_UPPER_STATUS_CLR; - if (lower_th_x) - mask |= TSENS_LOWER_STATUS_CLR; - if (upper_th_x || lower_th_x) { - /* Notify user space */ - schedule_work(&tm->sensor[i].work); - adc_code = readl_relaxed(sensor_addr); - pr_debug("Trigger (%d degrees) for sensor %d\n", - tsens_tz_code_to_degC(adc_code, i), i); - } - } - sensor >>= 1; - sensor_addr += TSENS_SENSOR_STATUS_SIZE; - } - if (tmdev->hw_type == APQ_8064) - writel_relaxed(reg & mask, TSENS_8064_STATUS_CNTL); - else - writel_relaxed(reg & mask, TSENS_CNTL_ADDR); - mb(); -} - -static irqreturn_t tsens_isr(int irq, void *data) -{ - schedule_work(&tmdev->tsens_work); - - return IRQ_HANDLED; -} - -#ifdef CONFIG_PM -static int tsens_suspend(struct device *dev) -{ - int i = 0; - pr_debug("%s\n", __func__); - tmdev->pm_tsens_thr_data = readl_relaxed(TSENS_THRESHOLD_ADDR); - tmdev->pm_tsens_cntl = readl_relaxed(TSENS_CNTL_ADDR); - writel_relaxed(tmdev->pm_tsens_cntl & - ~(TSENS_8960_SLP_CLK_ENA | TSENS_EN), TSENS_CNTL_ADDR); - tmdev->prev_reading_avail = 0; - for (i = 0; i < tmdev->tsens_num_sensor; i++) - tmdev->sensor[i].mode = THERMAL_DEVICE_DISABLED; - disable_irq_nosync(TSENS_UPPER_LOWER_INT); - mb(); - return 0; -} - -static int tsens_resume(struct device *dev) -{ - unsigned int reg_cntl = 0, reg_cfg = 0, reg_sensor_mask = 0; - unsigned int reg_status_cntl = 0, reg_thr_data = 0, i = 0; - bool max_interrupt_mask_en = TSENS_8064_MAX_INT_MASK_EN; - - pr_debug("%s\n", __func__); - - reg_cntl = readl_relaxed(TSENS_CNTL_ADDR); - writel_relaxed(reg_cntl | TSENS_SW_RST, TSENS_CNTL_ADDR); - - if (tmdev->hw_type == MSM_8960 || tmdev->hw_type == MDM_9615) { - reg_cntl |= TSENS_8960_SLP_CLK_ENA | - (TSENS_MEASURE_PERIOD << 18) | - TSENS_MIN_STATUS_MASK | TSENS_MAX_STATUS_MASK | - SENSORS_EN; - writel_relaxed(reg_cntl, TSENS_CNTL_ADDR); - } else if (tmdev->hw_type == APQ_8064) { - reg_cntl |= TSENS_8960_SLP_CLK_ENA | - (TSENS_MEASURE_PERIOD << 18) | - (((1 << tmdev->tsens_num_sensor) - 1) - << TSENS_SENSOR0_SHIFT); - writel_relaxed(reg_cntl, TSENS_CNTL_ADDR); - reg_status_cntl = readl_relaxed(TSENS_8064_STATUS_CNTL); - reg_status_cntl = max_interrupt_mask_en ? - (reg_status_cntl | TSENS_MAX_STATUS_MASK) : - (reg_status_cntl & ~TSENS_MAX_STATUS_MASK); - writel_relaxed(reg_status_cntl, TSENS_8064_STATUS_CNTL); - pr_debug("%s: max_int_mask_en=%d tsens_status_cntl=0x%x\n", - __func__, max_interrupt_mask_en, - readl_relaxed(TSENS_8064_STATUS_CNTL)); - } - - reg_cfg = readl_relaxed(TSENS_8960_CONFIG_ADDR); - reg_cfg = (reg_cfg & ~TSENS_8960_CONFIG_MASK) | - (TSENS_8960_CONFIG << TSENS_8960_CONFIG_SHIFT); - writel_relaxed(reg_cfg, TSENS_8960_CONFIG_ADDR); - - writel_relaxed((tmdev->pm_tsens_cntl & TSENS_CNTL_RESUME_MASK), - TSENS_CNTL_ADDR); - reg_cntl = readl_relaxed(TSENS_CNTL_ADDR); - writel_relaxed(tmdev->pm_tsens_thr_data, TSENS_THRESHOLD_ADDR); - reg_thr_data = readl_relaxed(TSENS_THRESHOLD_ADDR); - if (tmdev->hw_type == MSM_8960 || tmdev->hw_type == MDM_9615) - reg_sensor_mask = ((reg_cntl & TSENS_8960_SENSOR_MASK) - >> TSENS_SENSOR0_SHIFT); - else { - reg_sensor_mask = ((reg_cntl & TSENS_8064_SENSOR_MASK) - >> TSENS_SENSOR0_SHIFT); - } - - for (i = 0; i < tmdev->tsens_num_sensor; i++) { - if (reg_sensor_mask & TSENS_MASK1) - tmdev->sensor[i].mode = THERMAL_DEVICE_ENABLED; - reg_sensor_mask >>= 1; - } - - enable_irq(TSENS_UPPER_LOWER_INT); - mb(); - return 0; -} - -static const struct dev_pm_ops tsens_pm_ops = { - .suspend = tsens_suspend, - .resume = tsens_resume, -}; -#endif - -static void tsens_disable_mode(void) -{ - unsigned int reg_cntl = 0; - - reg_cntl = readl_relaxed(TSENS_CNTL_ADDR); - if (tmdev->hw_type == MSM_8960 || tmdev->hw_type == MDM_9615 || - tmdev->hw_type == APQ_8064) - writel_relaxed(reg_cntl & - ~((((1 << tmdev->tsens_num_sensor) - 1) << - TSENS_SENSOR0_SHIFT) | TSENS_8960_SLP_CLK_ENA - | TSENS_EN), TSENS_CNTL_ADDR); - else if (tmdev->hw_type == MSM_8660) - writel_relaxed(reg_cntl & - ~((((1 << tmdev->tsens_num_sensor) - 1) << - TSENS_SENSOR0_SHIFT) | TSENS_8660_SLP_CLK_ENA - | TSENS_EN), TSENS_CNTL_ADDR); -} - -static void tsens_hw_init(void) -{ - unsigned int reg_cntl = 0, reg_cfg = 0, reg_thr = 0; - unsigned int reg_status_cntl = 0; - unsigned int max_limit_thr = TSENS_MAX_LIMIT_TH; - bool max_interrupt_mask_en = TSENS_8064_MAX_INT_MASK_EN; - - reg_cntl = readl_relaxed(TSENS_CNTL_ADDR); - writel_relaxed(reg_cntl | TSENS_SW_RST, TSENS_CNTL_ADDR); - - if (tmdev->hw_type == MSM_8960 || tmdev->hw_type == MDM_9615) { - reg_cntl |= TSENS_8960_SLP_CLK_ENA | - (TSENS_MEASURE_PERIOD << 18) | - TSENS_LOWER_STATUS_CLR | TSENS_UPPER_STATUS_CLR | - TSENS_MIN_STATUS_MASK | TSENS_MAX_STATUS_MASK | - SENSORS_EN; - writel_relaxed(reg_cntl, TSENS_CNTL_ADDR); - reg_cntl |= TSENS_EN; - writel_relaxed(reg_cntl, TSENS_CNTL_ADDR); - - reg_cfg = readl_relaxed(TSENS_8960_CONFIG_ADDR); - reg_cfg = (reg_cfg & ~TSENS_8960_CONFIG_MASK) | - (TSENS_8960_CONFIG << TSENS_8960_CONFIG_SHIFT); - writel_relaxed(reg_cfg, TSENS_8960_CONFIG_ADDR); - } else if (tmdev->hw_type == MSM_8660) { - reg_cntl |= TSENS_8660_SLP_CLK_ENA | TSENS_EN | - (TSENS_MEASURE_PERIOD << 16) | - TSENS_LOWER_STATUS_CLR | TSENS_UPPER_STATUS_CLR | - TSENS_MIN_STATUS_MASK | TSENS_MAX_STATUS_MASK | - (((1 << tmdev->tsens_num_sensor) - 1) << - TSENS_SENSOR0_SHIFT); - - /* set TSENS_CONFIG bits (bits 29:28 of TSENS_CNTL) to '01'; - this setting found to be optimal. */ - reg_cntl = (reg_cntl & ~TSENS_8660_CONFIG_MASK) | - (TSENS_8660_CONFIG << TSENS_8660_CONFIG_SHIFT); - - writel_relaxed(reg_cntl, TSENS_CNTL_ADDR); - } else if (tmdev->hw_type == APQ_8064) { - reg_cntl |= TSENS_8960_SLP_CLK_ENA | - (TSENS_MEASURE_PERIOD << 18) | - (((1 << tmdev->tsens_num_sensor) - 1) - << TSENS_SENSOR0_SHIFT); - writel_relaxed(reg_cntl, TSENS_CNTL_ADDR); - reg_status_cntl = readl_relaxed(TSENS_8064_STATUS_CNTL); - reg_status_cntl |= TSENS_LOWER_STATUS_CLR | - TSENS_UPPER_STATUS_CLR | TSENS_MIN_STATUS_MASK; - - reg_status_cntl = max_interrupt_mask_en ? - (reg_status_cntl | TSENS_MAX_STATUS_MASK) : - (reg_status_cntl & ~TSENS_MAX_STATUS_MASK); - - writel_relaxed(reg_status_cntl, TSENS_8064_STATUS_CNTL); - reg_cntl |= TSENS_EN; - writel_relaxed(reg_cntl, TSENS_CNTL_ADDR); - pr_debug("%s: max_int_mask_en=%d tsens_status_cntl=0x%x\n", - __func__, max_interrupt_mask_en, - readl_relaxed(TSENS_8064_STATUS_CNTL)); - - reg_cfg = readl_relaxed(TSENS_8960_CONFIG_ADDR); - reg_cfg = (reg_cfg & ~TSENS_8960_CONFIG_MASK) | - (TSENS_8960_CONFIG << TSENS_8960_CONFIG_SHIFT); - writel_relaxed(reg_cfg, TSENS_8960_CONFIG_ADDR); - - /* set max limit threshold for sensor7 */ - if (!max_interrupt_mask_en) { - max_limit_thr = - tsens_tz_degC_to_code(TSENS_8064_MAX_LIMIT_TEMP, 7); - } - } - - reg_thr |= (TSENS_LOWER_LIMIT_TH << TSENS_THRESHOLD_LOWER_LIMIT_SHIFT) | - (TSENS_UPPER_LIMIT_TH << TSENS_THRESHOLD_UPPER_LIMIT_SHIFT) | - (TSENS_MIN_LIMIT_TH << TSENS_THRESHOLD_MIN_LIMIT_SHIFT) | - (max_limit_thr << TSENS_THRESHOLD_MAX_LIMIT_SHIFT); - writel_relaxed(reg_thr, TSENS_THRESHOLD_ADDR); - pr_debug("%s: tsens_threshold_reg=0x%x\n", - __func__, readl_relaxed(TSENS_THRESHOLD_ADDR)); -} - -static int tsens_calib_sensors8660(void) -{ - uint32_t *main_sensor_addr, sensor_shift, red_sensor_shift; - uint32_t sensor_mask, red_sensor_mask; - - main_sensor_addr = TSENS_8660_QFPROM_ADDR; - sensor_shift = TSENS_SENSOR_SHIFT; - red_sensor_shift = sensor_shift + TSENS_RED_SHIFT; - sensor_mask = TSENS_THRESHOLD_MAX_CODE << sensor_shift; - red_sensor_mask = TSENS_THRESHOLD_MAX_CODE << red_sensor_shift; - tmdev->sensor[TSENS_MAIN_SENSOR].calib_data = - (readl_relaxed(main_sensor_addr) & sensor_mask) - >> sensor_shift; - tmdev->sensor[TSENS_MAIN_SENSOR].calib_data_backup = - (readl_relaxed(main_sensor_addr) - & red_sensor_mask) >> red_sensor_shift; - if (tmdev->sensor[TSENS_MAIN_SENSOR].calib_data_backup) - tmdev->sensor[TSENS_MAIN_SENSOR].calib_data = - tmdev->sensor[TSENS_MAIN_SENSOR].calib_data_backup; - if (!tmdev->sensor[TSENS_MAIN_SENSOR].calib_data) { - pr_err("QFPROM TSENS calibration data not present\n"); - return -ENODEV; - } - - tmdev->sensor[TSENS_MAIN_SENSOR].offset = tmdev->tsens_factor * - TSENS_CAL_DEGC - - tmdev->sensor[TSENS_MAIN_SENSOR].slope_mul_tsens_factor * - tmdev->sensor[TSENS_MAIN_SENSOR].calib_data; - - tmdev->prev_reading_avail = false; - INIT_WORK(&tmdev->sensor[TSENS_MAIN_SENSOR].work, - notify_uspace_tsens_fn); - - return 0; -} - -static int tsens_calib_sensors8960(void) -{ - uint32_t i; - uint8_t *main_sensor_addr, *backup_sensor_addr; - for (i = 0; i < tmdev->tsens_num_sensor; i++) { - main_sensor_addr = TSENS_8960_QFPROM_ADDR0 + i; - backup_sensor_addr = TSENS_8960_QFPROM_SPARE_ADDR0 + i; - - tmdev->sensor[i].calib_data = readb_relaxed(main_sensor_addr); - tmdev->sensor[i].calib_data_backup = - readb_relaxed(backup_sensor_addr); - if (tmdev->sensor[i].calib_data_backup) - tmdev->sensor[i].calib_data = - tmdev->sensor[i].calib_data_backup; - if (!tmdev->sensor[i].calib_data) { - pr_err("QFPROM TSENS calibration data not present\n"); - return -ENODEV; - } - tmdev->sensor[i].offset = (TSENS_CAL_DEGC * - tmdev->tsens_factor) - - (tmdev->sensor[i].calib_data * - tmdev->sensor[i].slope_mul_tsens_factor); - tmdev->prev_reading_avail = false; - INIT_WORK(&tmdev->sensor[i].work, notify_uspace_tsens_fn); - } - - return 0; -} - -static int tsens_calib_sensors(void) -{ - int rc = -ENODEV; - - if (tmdev->hw_type == MSM_8660) - rc = tsens_calib_sensors8660(); - else if (tmdev->hw_type == MSM_8960 || tmdev->hw_type == MDM_9615 || - tmdev->hw_type == APQ_8064) - rc = tsens_calib_sensors8960(); - - return rc; -} - -int msm_tsens_early_init(struct tsens_platform_data *pdata) -{ - int rc = 0, i; - - if (!pdata) { - pr_err("No TSENS Platform data\n"); - return -EINVAL; - } - - tmdev = kzalloc(sizeof(struct tsens_tm_device) + - pdata->tsens_num_sensor * - sizeof(struct tsens_tm_device_sensor), - GFP_ATOMIC); - if (tmdev == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - return -ENOMEM; - } - - for (i = 0; i < pdata->tsens_num_sensor; i++) - tmdev->sensor[i].slope_mul_tsens_factor = pdata->slope[i]; - tmdev->tsens_factor = pdata->tsens_factor; - tmdev->tsens_num_sensor = pdata->tsens_num_sensor; - tmdev->hw_type = pdata->hw_type; - - rc = tsens_calib_sensors(); - if (rc < 0) { - kfree(tmdev); - tmdev = NULL; - return rc; - } - - if (tmdev->hw_type == APQ_8064) - tsens_status_cntl_start = 0; - else - tsens_status_cntl_start = TSENS_STATUS_CNTL_OFFSET; - - tsens_hw_init(); - - pr_debug("msm_tsens_early_init: done\n"); - - return rc; -} - -static int tsens_tm_probe(struct platform_device *pdev) -{ - int rc, i; - - if (!tmdev) { - pr_info("%s : TSENS early init not done.\n", __func__); - return -EFAULT; - } - - for (i = 0; i < tmdev->tsens_num_sensor; i++) { - char name[18]; - snprintf(name, sizeof(name), "tsens_tz_sensor%d", i); - tmdev->sensor[i].mode = THERMAL_DEVICE_ENABLED; - tmdev->sensor[i].sensor_num = i; - tmdev->sensor[i].tz_dev = thermal_zone_device_register(name, - TSENS_TRIP_NUM, &tmdev->sensor[i], - &tsens_thermal_zone_ops, 0, 0, 0, 0); - if (IS_ERR(tmdev->sensor[i].tz_dev)) { - pr_err("%s: thermal_zone_device_register() failed.\n", - __func__); - rc = -ENODEV; - goto fail; - } - } - - rc = request_irq(TSENS_UPPER_LOWER_INT, tsens_isr, - IRQF_TRIGGER_RISING, "tsens_interrupt", tmdev); - if (rc < 0) { - pr_err("%s: request_irq FAIL: %d\n", __func__, rc); - for (i = 0; i < tmdev->tsens_num_sensor; i++) - thermal_zone_device_unregister(tmdev->sensor[i].tz_dev); - goto fail; - } - INIT_WORK(&tmdev->tsens_work, tsens_scheduler_fn); - - pr_debug("%s: OK\n", __func__); - mb(); - return 0; -fail: - tsens_disable_mode(); - kfree(tmdev); - tmdev = NULL; - mb(); - return rc; -} - -static int tsens_tm_remove(struct platform_device *pdev) -{ - int i; - - tsens_disable_mode(); - mb(); - free_irq(TSENS_UPPER_LOWER_INT, tmdev); - for (i = 0; i < tmdev->tsens_num_sensor; i++) - thermal_zone_device_unregister(tmdev->sensor[i].tz_dev); - kfree(tmdev); - tmdev = NULL; - return 0; -} - -static struct platform_driver tsens_tm_driver = { - .probe = tsens_tm_probe, - .remove = tsens_tm_remove, - .driver = { - .name = "tsens8960-tm", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &tsens_pm_ops, -#endif - }, -}; - -static int __init _tsens_tm_init(void) -{ - return platform_driver_register(&tsens_tm_driver); -} -module_init(_tsens_tm_init); - -static void __exit _tsens_tm_remove(void) -{ - platform_driver_unregister(&tsens_tm_driver); -} -module_exit(_tsens_tm_remove); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("MSM8960 Temperature Sensor driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:tsens8960-tm"); diff --git a/drivers/thermal/msm_popmem-tm.c b/drivers/thermal/msm_popmem-tm.c deleted file mode 100644 index b4be5982c692d17d65eef5577cd51633abbca608..0000000000000000000000000000000000000000 --- a/drivers/thermal/msm_popmem-tm.c +++ /dev/null @@ -1,284 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include -#include -#include -#include -#include - -#define POP_MEM_LPDDR1_REFRESH_MASK 0x00000700 -#define POP_MEM_LPDDR1_REFRESH_SHIFT 0x8 - -#define POP_MEM_LPDDR2_REFRESH_MASK 0x00000007 -#define POP_MEM_LPDDR2_REFRESH_SHIFT 0x0 - -#define POP_MEM_REFRESH_REG 0x3C - -#define POP_MEM_LOW_TEMPERATURE 25000 -#define POP_MEM_NORMAL_TEMPERATURE 50000 -#define POP_MEM_HIGH_TEMPERATURE 85000 - -#define POP_MEM_TRIP_OUT_OF_SPEC 0 -#define POP_MEM_TRIP_NUM 1 - -struct pop_mem_tm_device { - unsigned long baseaddr; - struct thermal_zone_device *tz_dev; - unsigned long refresh_mask; - unsigned int refresh_shift; -}; - - -static int pop_mem_tm_read_refresh(struct pop_mem_tm_device *tm, - unsigned int *ref_rate){ - unsigned int ref; - - ref = __raw_readl(tm->baseaddr + POP_MEM_REFRESH_REG); - *ref_rate = (ref & tm->refresh_mask) >> tm->refresh_shift; - - return 0; -} - - -static int pop_mem_tm_get_temperature(struct thermal_zone_device *thermal, - unsigned long *temperature) -{ - struct pop_mem_tm_device *tm = thermal->devdata; - unsigned int ref_rate; - int rc; - - if (!tm || !temperature) - return -EINVAL; - - rc = pop_mem_tm_read_refresh(tm, &ref_rate); - if (rc < 0) - return rc; - - switch (ref_rate) { - case 0: - case 1: - case 2: - *temperature = POP_MEM_LOW_TEMPERATURE; - break; - case 3: - case 4: - *temperature = POP_MEM_NORMAL_TEMPERATURE; - break; - case 5: - case 6: - case 7: - *temperature = POP_MEM_HIGH_TEMPERATURE; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int pop_mem_tm_get_trip_type(struct thermal_zone_device *thermal, - int trip, enum thermal_trip_type *type) -{ - struct pop_mem_tm_device *tm = thermal->devdata; - - if (!tm || trip < 0 || !type) - return -EINVAL; - - if (trip == POP_MEM_TRIP_OUT_OF_SPEC) - *type = THERMAL_TRIP_CRITICAL; - else - return -EINVAL; - - return 0; -} - -static int pop_mem_tm_get_trip_temperature(struct thermal_zone_device *thermal, - int trip, unsigned long *temperature) -{ - struct pop_mem_tm_device *tm = thermal->devdata; - - if (!tm || trip < 0 || !temperature) - return -EINVAL; - - if (trip == POP_MEM_TRIP_OUT_OF_SPEC) - *temperature = POP_MEM_HIGH_TEMPERATURE; - else - return -EINVAL; - - return 0; -} - - -static int pop_mem_tm_get_crit_temperature(struct thermal_zone_device *thermal, - unsigned long *temperature) -{ - struct pop_mem_tm_device *tm = thermal->devdata; - - if (!tm || !temperature) - return -EINVAL; - - *temperature = POP_MEM_HIGH_TEMPERATURE; - - return 0; -} - - -static struct thermal_zone_device_ops pop_mem_thermal_zone_ops = { - .get_temp = pop_mem_tm_get_temperature, - .get_trip_type = pop_mem_tm_get_trip_type, - .get_trip_temp = pop_mem_tm_get_trip_temperature, - .get_crit_temp = pop_mem_tm_get_crit_temperature, -}; - - -static int pop_mem_tm_probe(struct platform_device *pdev) -{ - int rc, len, numcontrollers; - struct resource *controller_mem = NULL; - struct resource *res_mem = NULL; - struct pop_mem_tm_device *tmdev = NULL; - void __iomem *base = NULL; - - rc = len = 0; - numcontrollers = get_num_populated_chipselects(); - - if (pdev->id >= numcontrollers) { - pr_err("%s: memory controller %d does not exist", __func__, - pdev->id); - rc = -ENODEV; - goto fail; - } - - controller_mem = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "physbase"); - if (!controller_mem) { - pr_err("%s: could not get resources for controller %d", - __func__, pdev->id); - rc = -EFAULT; - goto fail; - } - - len = controller_mem->end - controller_mem->start + 1; - - res_mem = request_mem_region(controller_mem->start, len, - controller_mem->name); - if (!res_mem) { - pr_err("%s: Could not request memory region: " - "start=%p, len=%d\n", __func__, - (void *) controller_mem->start, len); - rc = -EBUSY; - goto fail; - - } - - base = ioremap(res_mem->start, len); - if (!base) { - pr_err("%s: Could not ioremap: start=%p, len=%d\n", - __func__, (void *) controller_mem->start, len); - rc = -EBUSY; - goto fail; - - } - - tmdev = kzalloc(sizeof(*tmdev), GFP_KERNEL); - if (tmdev == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - rc = -ENOMEM; - goto fail; - } - - if (numcontrollers == 1) { - tmdev->refresh_mask = POP_MEM_LPDDR1_REFRESH_MASK; - tmdev->refresh_shift = POP_MEM_LPDDR1_REFRESH_SHIFT; - } else { - tmdev->refresh_mask = POP_MEM_LPDDR2_REFRESH_MASK; - tmdev->refresh_shift = POP_MEM_LPDDR2_REFRESH_SHIFT; - } - tmdev->baseaddr = (unsigned long) base; - tmdev->tz_dev = thermal_zone_device_register("msm_popmem_tz", - POP_MEM_TRIP_NUM, tmdev, - &pop_mem_thermal_zone_ops, - 0, 0, 0, 0); - - if (tmdev->tz_dev == NULL) { - pr_err("%s: thermal_zone_device_register() failed.\n", - __func__); - goto fail; - } - - platform_set_drvdata(pdev, tmdev); - - pr_notice("%s: device %d probed successfully\n", __func__, pdev->id); - - return rc; - -fail: - if (base) - iounmap(base); - if (res_mem) - release_mem_region(controller_mem->start, len); - kfree(tmdev); - - return rc; -} - -static int pop_mem_tm_remove(struct platform_device *pdev) -{ - - int len; - struct pop_mem_tm_device *tmdev = platform_get_drvdata(pdev); - struct resource *controller_mem; - - iounmap((void __iomem *)tmdev->baseaddr); - - controller_mem = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "physbase"); - len = controller_mem->end - controller_mem->start + 1; - release_mem_region(controller_mem->start, len); - - thermal_zone_device_unregister(tmdev->tz_dev); - platform_set_drvdata(pdev, NULL); - kfree(tmdev); - - return 0; -} - -static struct platform_driver pop_mem_tm_driver = { - .probe = pop_mem_tm_probe, - .remove = pop_mem_tm_remove, - .driver = { - .name = "msm_popmem-tm", - .owner = THIS_MODULE - }, -}; - -static int __init pop_mem_tm_init(void) -{ - return platform_driver_register(&pop_mem_tm_driver); -} - -static void __exit pop_mem_tm_exit(void) -{ - platform_driver_unregister(&pop_mem_tm_driver); -} - -module_init(pop_mem_tm_init); -module_exit(pop_mem_tm_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Pop memory thermal manager driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:popmem-tm"); diff --git a/drivers/thermal/msm_tsens.c b/drivers/thermal/msm_tsens.c deleted file mode 100644 index 531ba226019544d72a761c51f89ebf09a62fa1a8..0000000000000000000000000000000000000000 --- a/drivers/thermal/msm_tsens.c +++ /dev/null @@ -1,665 +0,0 @@ -/* Copyright (c) 2010-2011, 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. - * - */ -/* - * Qualcomm TSENS Thermal Manager driver - * - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* Trips: from very hot to very cold */ -enum tsens_trip_type { - TSENS_TRIP_STAGE3 = 0, - TSENS_TRIP_STAGE2, - TSENS_TRIP_STAGE1, - TSENS_TRIP_STAGE0, - TSENS_TRIP_NUM, -}; - -#define TSENS_NUM_SENSORS 1 /* There are 5 but only 1 is useful now */ -#define TSENS_CAL_DEGC 30 /* degree C used for calibration */ -#define TSENS_QFPROM_ADDR (MSM_QFPROM_BASE + 0x000000bc) -#define TSENS_QFPROM_RED_TEMP_SENSOR0_SHIFT 24 -#define TSENS_QFPROM_TEMP_SENSOR0_SHIFT 16 -#define TSENS_QFPROM_TEMP_SENSOR0_MASK (255 << TSENS_QFPROM_TEMP_SENSOR0_SHIFT) -#define TSENS_SLOPE (0.702) /* slope in (degrees_C / ADC_code) */ -#define TSENS_FACTOR (1000) /* convert floating-point into integer */ -#define TSENS_CONFIG 01 /* this setting found to be optimal */ -#define TSENS_CONFIG_SHIFT 28 -#define TSENS_CONFIG_MASK (3 << TSENS_CONFIG_SHIFT) -#define TSENS_CNTL_ADDR (MSM_CLK_CTL_BASE + 0x00003620) -#define TSENS_EN (1 << 0) -#define TSENS_SW_RST (1 << 1) -#define SENSOR0_EN (1 << 3) -#define SENSOR1_EN (1 << 4) -#define SENSOR2_EN (1 << 5) -#define SENSOR3_EN (1 << 6) -#define SENSOR4_EN (1 << 7) -#define TSENS_MIN_STATUS_MASK (1 << 8) -#define TSENS_LOWER_STATUS_CLR (1 << 9) -#define TSENS_UPPER_STATUS_CLR (1 << 10) -#define TSENS_MAX_STATUS_MASK (1 << 11) -#define TSENS_MEASURE_PERIOD 4 /* 1 sec. default as required by Willie */ -#define TSENS_SLP_CLK_ENA (1 << 24) -#define TSENS_THRESHOLD_ADDR (MSM_CLK_CTL_BASE + 0x00003624) -#define TSENS_THRESHOLD_MAX_CODE (0xff) -#define TSENS_THRESHOLD_MAX_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << 24) -#define TSENS_THRESHOLD_MIN_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << 16) -#define TSENS_THRESHOLD_UPPER_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << 8) -#define TSENS_THRESHOLD_LOWER_LIMIT_MASK (TSENS_THRESHOLD_MAX_CODE << 0) -/* Initial temperature threshold values */ -#define TSENS_LOWER_LIMIT_TH 0x50 -#define TSENS_UPPER_LIMIT_TH 0xdf -#define TSENS_MIN_LIMIT_TH 0x38 -#define TSENS_MAX_LIMIT_TH 0xff - -#define TSENS_S0_STATUS_ADDR (MSM_CLK_CTL_BASE + 0x00003628) -#define TSENS_INT_STATUS_ADDR (MSM_CLK_CTL_BASE + 0x0000363c) -#define TSENS_LOWER_INT_MASK (1 << 1) -#define TSENS_UPPER_INT_MASK (1 << 2) -#define TSENS_TRDY_MASK (1 << 7) - -struct tsens_tm_device_sensor { - struct thermal_zone_device *tz_dev; - enum thermal_device_mode mode; - unsigned int sensor_num; -}; - -struct tsens_tm_device { - struct tsens_tm_device_sensor sensor[TSENS_NUM_SENSORS]; - bool prev_reading_avail; - int offset; - struct work_struct work; - uint32_t pm_tsens_thr_data; -}; - -struct tsens_tm_device *tmdev; - -/* Temperature on y axis and ADC-code on x-axis */ -static int tsens_tz_code_to_degC(int adc_code) -{ - int degC, degcbeforefactor; - degcbeforefactor = adc_code * (int)(TSENS_SLOPE * TSENS_FACTOR) - + tmdev->offset; - if (degcbeforefactor == 0) - degC = degcbeforefactor; - else if (degcbeforefactor > 0) - degC = (degcbeforefactor + TSENS_FACTOR/2) / TSENS_FACTOR; - else /* rounding for negative degrees */ - degC = (degcbeforefactor - TSENS_FACTOR/2) / TSENS_FACTOR; - return degC; -} - -static int tsens_tz_degC_to_code(int degC) -{ - int code = (degC * TSENS_FACTOR - tmdev->offset - + (int)(TSENS_FACTOR * TSENS_SLOPE)/2) - / (int)(TSENS_FACTOR * TSENS_SLOPE); - if (code > 255) /* upper bound */ - code = 255; - else if (code < 0) /* lower bound */ - code = 0; - return code; -} - -static int tsens_tz_get_temp(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int code; - - if (!tm_sensor || tm_sensor->mode != THERMAL_DEVICE_ENABLED || !temp) - return -EINVAL; - - if (!tmdev->prev_reading_avail) { - while (!(readl(TSENS_INT_STATUS_ADDR) & TSENS_TRDY_MASK)) - msleep(1); - tmdev->prev_reading_avail = 1; - } - - code = readl(TSENS_S0_STATUS_ADDR + (tm_sensor->sensor_num << 2)); - *temp = tsens_tz_code_to_degC(code); - - return 0; -} - -static int tsens_tz_get_mode(struct thermal_zone_device *thermal, - enum thermal_device_mode *mode) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - - if (!tm_sensor || !mode) - return -EINVAL; - - *mode = tm_sensor->mode; - - return 0; -} - -static int tsens_tz_set_mode(struct thermal_zone_device *thermal, - enum thermal_device_mode mode) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg, mask; - - if (!tm_sensor) - return -EINVAL; - - if (mode != tm_sensor->mode) { - pr_info("%s: mode: %d --> %d\n", __func__, tm_sensor->mode, - mode); - - reg = readl(TSENS_CNTL_ADDR); - mask = 1 << (tm_sensor->sensor_num + 3); - if (mode == THERMAL_DEVICE_ENABLED) { - writel(reg | TSENS_SW_RST, TSENS_CNTL_ADDR); - reg |= mask | TSENS_SLP_CLK_ENA | TSENS_EN; - tmdev->prev_reading_avail = 0; - } else { - reg &= ~mask; - if (!(reg & (((1 << TSENS_NUM_SENSORS) - 1) << 3))) - reg &= ~(TSENS_SLP_CLK_ENA | TSENS_EN); - } - - writel(reg, TSENS_CNTL_ADDR); - } - tm_sensor->mode = mode; - - return 0; -} - -static int tsens_tz_get_trip_type(struct thermal_zone_device *thermal, - int trip, enum thermal_trip_type *type) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - - if (!tm_sensor || trip < 0 || !type) - return -EINVAL; - - switch (trip) { - case TSENS_TRIP_STAGE3: - *type = THERMAL_TRIP_CRITICAL; - break; - case TSENS_TRIP_STAGE2: - *type = THERMAL_TRIP_CONFIGURABLE_HI; - break; - case TSENS_TRIP_STAGE1: - *type = THERMAL_TRIP_CONFIGURABLE_LOW; - break; - case TSENS_TRIP_STAGE0: - *type = THERMAL_TRIP_CRITICAL_LOW; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int tsens_tz_activate_trip_type(struct thermal_zone_device *thermal, - int trip, enum thermal_trip_activation_mode mode) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg_cntl, reg_th, code, hi_code, lo_code, mask; - - if (!tm_sensor || trip < 0) - return -EINVAL; - - lo_code = 0; - hi_code = TSENS_THRESHOLD_MAX_CODE; - - reg_cntl = readl(TSENS_CNTL_ADDR); - reg_th = readl(TSENS_THRESHOLD_ADDR); - switch (trip) { - case TSENS_TRIP_STAGE3: - code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) >> 24; - mask = TSENS_MAX_STATUS_MASK; - - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> 8; - else if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK); - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> 16; - break; - case TSENS_TRIP_STAGE2: - code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) >> 8; - mask = TSENS_UPPER_STATUS_CLR; - - if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> 24; - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK); - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> 16; - break; - case TSENS_TRIP_STAGE1: - code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK) >> 0; - mask = TSENS_LOWER_STATUS_CLR; - - if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> 16; - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> 8; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> 24; - break; - case TSENS_TRIP_STAGE0: - code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) >> 16; - mask = TSENS_MIN_STATUS_MASK; - - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK); - else if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> 8; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> 24; - break; - default: - return -EINVAL; - } - - if (mode == THERMAL_TRIP_ACTIVATION_DISABLED) - writel(reg_cntl | mask, TSENS_CNTL_ADDR); - else { - if (code < lo_code || code > hi_code) - return -EINVAL; - writel(reg_cntl & ~mask, TSENS_CNTL_ADDR); - } - - return 0; -} - -static int tsens_tz_get_trip_temp(struct thermal_zone_device *thermal, - int trip, unsigned long *temp) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg; - - if (!tm_sensor || trip < 0 || !temp) - return -EINVAL; - - reg = readl(TSENS_THRESHOLD_ADDR); - switch (trip) { - case TSENS_TRIP_STAGE3: - reg = (reg & TSENS_THRESHOLD_MAX_LIMIT_MASK) >> 24; - break; - case TSENS_TRIP_STAGE2: - reg = (reg & TSENS_THRESHOLD_UPPER_LIMIT_MASK) >> 8; - break; - case TSENS_TRIP_STAGE1: - reg = (reg & TSENS_THRESHOLD_LOWER_LIMIT_MASK) >> 0; - break; - case TSENS_TRIP_STAGE0: - reg = (reg & TSENS_THRESHOLD_MIN_LIMIT_MASK) >> 16; - break; - default: - return -EINVAL; - } - - *temp = tsens_tz_code_to_degC(reg); - - return 0; -} - -static int tsens_tz_get_crit_temp(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - return tsens_tz_get_trip_temp(thermal, TSENS_TRIP_STAGE3, temp); -} - -static int tsens_tz_set_trip_temp(struct thermal_zone_device *thermal, - int trip, long temp) -{ - struct tsens_tm_device_sensor *tm_sensor = thermal->devdata; - unsigned int reg_th, reg_cntl; - int code, hi_code, lo_code, code_err_chk; - - code_err_chk = code = tsens_tz_degC_to_code(temp); - if (!tm_sensor || trip < 0) - return -EINVAL; - - lo_code = 0; - hi_code = TSENS_THRESHOLD_MAX_CODE; - - reg_cntl = readl(TSENS_CNTL_ADDR); - reg_th = readl(TSENS_THRESHOLD_ADDR); - switch (trip) { - case TSENS_TRIP_STAGE3: - code <<= 24; - reg_th &= ~TSENS_THRESHOLD_MAX_LIMIT_MASK; - - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> 8; - else if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK); - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> 16; - break; - case TSENS_TRIP_STAGE2: - code <<= 8; - reg_th &= ~TSENS_THRESHOLD_UPPER_LIMIT_MASK; - - if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> 24; - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - lo_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK); - else if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> 16; - break; - case TSENS_TRIP_STAGE1: - reg_th &= ~TSENS_THRESHOLD_LOWER_LIMIT_MASK; - - if (!(reg_cntl & TSENS_MIN_STATUS_MASK)) - lo_code = (reg_th & TSENS_THRESHOLD_MIN_LIMIT_MASK) - >> 16; - if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> 8; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> 24; - break; - case TSENS_TRIP_STAGE0: - code <<= 16; - reg_th &= ~TSENS_THRESHOLD_MIN_LIMIT_MASK; - - if (!(reg_cntl & TSENS_LOWER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_LOWER_LIMIT_MASK); - else if (!(reg_cntl & TSENS_UPPER_STATUS_CLR)) - hi_code = (reg_th & TSENS_THRESHOLD_UPPER_LIMIT_MASK) - >> 8; - else if (!(reg_cntl & TSENS_MAX_STATUS_MASK)) - hi_code = (reg_th & TSENS_THRESHOLD_MAX_LIMIT_MASK) - >> 24; - break; - default: - return -EINVAL; - } - - if (code_err_chk < lo_code || code_err_chk > hi_code) - return -EINVAL; - - writel(reg_th | code, TSENS_THRESHOLD_ADDR); - return 0; -} - -static struct thermal_zone_device_ops tsens_thermal_zone_ops = { - .get_temp = tsens_tz_get_temp, - .get_mode = tsens_tz_get_mode, - .set_mode = tsens_tz_set_mode, - .get_trip_type = tsens_tz_get_trip_type, - .activate_trip_type = tsens_tz_activate_trip_type, - .get_trip_temp = tsens_tz_get_trip_temp, - .set_trip_temp = tsens_tz_set_trip_temp, - .get_crit_temp = tsens_tz_get_crit_temp, -}; - -static void notify_uspace_tsens_fn(struct work_struct *work) -{ - struct tsens_tm_device *tm = container_of(work, struct tsens_tm_device, - work); - /* Currently only Sensor0 is supported. We added support - to notify only the supported Sensor and this portion - needs to be revisited once other sensors are supported */ - sysfs_notify(&tm->sensor[0].tz_dev->device.kobj, - NULL, "type"); -} - -static irqreturn_t tsens_isr(int irq, void *data) -{ - unsigned int reg = readl(TSENS_CNTL_ADDR); - - writel(reg | TSENS_LOWER_STATUS_CLR | TSENS_UPPER_STATUS_CLR, - TSENS_CNTL_ADDR); - - return IRQ_WAKE_THREAD; -} - -static irqreturn_t tsens_isr_thread(int irq, void *data) -{ - struct tsens_tm_device *tm = data; - unsigned int threshold, threshold_low, i, code, reg, sensor, mask; - bool upper_th_x, lower_th_x; - int adc_code; - - mask = ~(TSENS_LOWER_STATUS_CLR | TSENS_UPPER_STATUS_CLR); - threshold = readl(TSENS_THRESHOLD_ADDR); - threshold_low = threshold & TSENS_THRESHOLD_LOWER_LIMIT_MASK; - threshold = (threshold & TSENS_THRESHOLD_UPPER_LIMIT_MASK) >> 8; - reg = sensor = readl(TSENS_CNTL_ADDR); - sensor &= (SENSOR0_EN | SENSOR1_EN | SENSOR2_EN | - SENSOR3_EN | SENSOR4_EN); - sensor >>= 3; - for (i = 0; i < TSENS_NUM_SENSORS; i++) { - if (sensor & 1) { - code = readl(TSENS_S0_STATUS_ADDR + (i << 2)); - upper_th_x = code >= threshold; - lower_th_x = code <= threshold_low; - if (upper_th_x) - mask |= TSENS_UPPER_STATUS_CLR; - if (lower_th_x) - mask |= TSENS_LOWER_STATUS_CLR; - if (upper_th_x || lower_th_x) { - /* Notify user space */ - schedule_work(&tm->work); - adc_code = readl(TSENS_S0_STATUS_ADDR - + (i << 2)); - printk(KERN_INFO"\nTrip point triggered by " - "current temperature (%d degrees) " - "measured by Temperature-Sensor %d\n", - tsens_tz_code_to_degC(adc_code), i); - } - } - sensor >>= 1; - } - writel(reg & mask, TSENS_CNTL_ADDR); - return IRQ_HANDLED; -} - -#ifdef CONFIG_PM -static int tsens_suspend(struct device *dev) -{ - unsigned int reg; - - tmdev->pm_tsens_thr_data = readl_relaxed(TSENS_THRESHOLD_ADDR); - reg = readl_relaxed(TSENS_CNTL_ADDR); - writel_relaxed(reg & ~(TSENS_SLP_CLK_ENA | TSENS_EN), TSENS_CNTL_ADDR); - tmdev->prev_reading_avail = 0; - - disable_irq_nosync(TSENS_UPPER_LOWER_INT); - mb(); - return 0; -} - -static int tsens_resume(struct device *dev) -{ - unsigned int reg; - - reg = readl_relaxed(TSENS_CNTL_ADDR); - writel_relaxed(reg | TSENS_SW_RST, TSENS_CNTL_ADDR); - reg |= TSENS_SLP_CLK_ENA | TSENS_EN | (TSENS_MEASURE_PERIOD << 16) | - TSENS_MIN_STATUS_MASK | TSENS_MAX_STATUS_MASK | - (((1 << TSENS_NUM_SENSORS) - 1) << 3); - - reg = (reg & ~TSENS_CONFIG_MASK) | (TSENS_CONFIG << TSENS_CONFIG_SHIFT); - writel_relaxed(reg, TSENS_CNTL_ADDR); - - if (tmdev->sensor->mode == THERMAL_DEVICE_DISABLED) { - writel_relaxed(reg & ~((((1 << TSENS_NUM_SENSORS) - 1) << 3) - | TSENS_SLP_CLK_ENA | TSENS_EN), TSENS_CNTL_ADDR); - } - - writel_relaxed(tmdev->pm_tsens_thr_data, TSENS_THRESHOLD_ADDR); - - enable_irq(TSENS_UPPER_LOWER_INT); - mb(); - return 0; -} - -static const struct dev_pm_ops tsens_pm_ops = { - .suspend = tsens_suspend, - .resume = tsens_resume, -}; -#endif - -static int tsens_tm_probe(struct platform_device *pdev) -{ - unsigned int reg, i, calib_data, calib_data_backup; - int rc; - - calib_data = (readl(TSENS_QFPROM_ADDR) & TSENS_QFPROM_TEMP_SENSOR0_MASK) - >> TSENS_QFPROM_TEMP_SENSOR0_SHIFT; - calib_data_backup = readl(TSENS_QFPROM_ADDR) - >> TSENS_QFPROM_RED_TEMP_SENSOR0_SHIFT; - - if (calib_data_backup) - calib_data = calib_data_backup; - - if (!calib_data) { - pr_err("%s: No temperature sensor data for calibration" - " in QFPROM!\n", __func__); - return -ENODEV; - } - - tmdev = kzalloc(sizeof(struct tsens_tm_device), GFP_KERNEL); - if (tmdev == NULL) { - pr_err("%s: kzalloc() failed.\n", __func__); - return -ENOMEM; - } - - platform_set_drvdata(pdev, tmdev); - - tmdev->offset = TSENS_FACTOR * TSENS_CAL_DEGC - - (int)(TSENS_FACTOR * TSENS_SLOPE) * calib_data; - tmdev->prev_reading_avail = 0; - - INIT_WORK(&tmdev->work, notify_uspace_tsens_fn); - - reg = readl(TSENS_CNTL_ADDR); - writel(reg | TSENS_SW_RST, TSENS_CNTL_ADDR); - reg |= TSENS_SLP_CLK_ENA | TSENS_EN | (TSENS_MEASURE_PERIOD << 16) | - TSENS_LOWER_STATUS_CLR | TSENS_UPPER_STATUS_CLR | - TSENS_MIN_STATUS_MASK | TSENS_MAX_STATUS_MASK | - (((1 << TSENS_NUM_SENSORS) - 1) << 3); - - /* set TSENS_CONFIG bits (bits 29:28 of TSENS_CNTL) to '01'; - this setting found to be optimal. */ - reg = (reg & ~TSENS_CONFIG_MASK) | (TSENS_CONFIG << TSENS_CONFIG_SHIFT); - - writel(reg, TSENS_CNTL_ADDR); - - writel((TSENS_LOWER_LIMIT_TH << 0) | (TSENS_UPPER_LIMIT_TH << 8) | - (TSENS_MIN_LIMIT_TH << 16) | (TSENS_MAX_LIMIT_TH << 24), - TSENS_THRESHOLD_ADDR); - - for (i = 0; i < TSENS_NUM_SENSORS; i++) { - char name[17]; - sprintf(name, "tsens_tz_sensor%d", i); - - tmdev->sensor[i].mode = THERMAL_DEVICE_ENABLED; - tmdev->sensor[i].tz_dev = thermal_zone_device_register(name, - TSENS_TRIP_NUM, &tmdev->sensor[i], - &tsens_thermal_zone_ops, 0, 0, 0, 0); - if (tmdev->sensor[i].tz_dev == NULL) { - pr_err("%s: thermal_zone_device_register() failed.\n", - __func__); - kfree(tmdev); - return -ENODEV; - } - tmdev->sensor[i].sensor_num = i; - tmdev->sensor[i].mode = THERMAL_DEVICE_DISABLED; - } - - rc = request_threaded_irq(TSENS_UPPER_LOWER_INT, tsens_isr, - tsens_isr_thread, 0, "tsens", tmdev); - if (rc < 0) { - pr_err("%s: request_irq FAIL: %d\n", __func__, rc); - kfree(tmdev); - return rc; - } - - writel(reg & ~((((1 << TSENS_NUM_SENSORS) - 1) << 3) - | TSENS_SLP_CLK_ENA | TSENS_EN), TSENS_CNTL_ADDR); - pr_notice("%s: OK\n", __func__); - return 0; -} - -static int tsens_tm_remove(struct platform_device *pdev) -{ - struct tsens_tm_device *tmdev = platform_get_drvdata(pdev); - unsigned int reg, i; - - reg = readl(TSENS_CNTL_ADDR); - writel(reg & ~(TSENS_SLP_CLK_ENA | TSENS_EN), TSENS_CNTL_ADDR); - - for (i = 0; i < TSENS_NUM_SENSORS; i++) - thermal_zone_device_unregister(tmdev->sensor[i].tz_dev); - platform_set_drvdata(pdev, NULL); - free_irq(TSENS_UPPER_LOWER_INT, tmdev); - kfree(tmdev); - - return 0; -} - -static struct platform_driver tsens_tm_driver = { - .probe = tsens_tm_probe, - .remove = tsens_tm_remove, - .driver = { - .name = "tsens-tm", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &tsens_pm_ops, -#endif - }, -}; - -static int __init tsens_init(void) -{ - return platform_driver_register(&tsens_tm_driver); -} - -static void __exit tsens_exit(void) -{ - platform_driver_unregister(&tsens_tm_driver); -} - -module_init(tsens_init); -module_exit(tsens_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("MSM Temperature Sensor driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:tsens-tm"); diff --git a/drivers/thermal/pm8xxx-tm.c b/drivers/thermal/pm8xxx-tm.c deleted file mode 100644 index 5add595b7d4be6c9d16f3a8b2b678af118d9bcc8..0000000000000000000000000000000000000000 --- a/drivers/thermal/pm8xxx-tm.c +++ /dev/null @@ -1,753 +0,0 @@ -/* - * Copyright (c) 2011-2013, 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. - */ - -/* - * Qualcomm PMIC PM8xxx Thermal Manager driver - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Register TEMP_ALARM_CTRL bits */ -#define TEMP_ALARM_CTRL_ST3_SD 0x80 -#define TEMP_ALARM_CTRL_ST2_SD 0x40 -#define TEMP_ALARM_CTRL_STATUS_MASK 0x30 -#define TEMP_ALARM_CTRL_STATUS_SHIFT 4 -#define TEMP_ALARM_CTRL_THRESH_MASK 0x0C -#define TEMP_ALARM_CTRL_THRESH_SHIFT 2 -#define TEMP_ALARM_CTRL_OVRD_ST3 0x02 -#define TEMP_ALARM_CTRL_OVRD_ST2 0x01 -#define TEMP_ALARM_CTRL_OVRD_MASK 0x03 - -#define TEMP_STAGE_STEP 20000 /* Stage step: 20.000 C */ -#define TEMP_STAGE_HYSTERESIS 2000 - -#define TEMP_THRESH_MIN 105000 /* Threshold Min: 105 C */ -#define TEMP_THRESH_STEP 5000 /* Threshold step: 5 C */ - -/* Register TEMP_ALARM_PWM bits */ -#define TEMP_ALARM_PWM_EN_MASK 0xC0 -#define TEMP_ALARM_PWM_EN_NEVER 0x00 -#define TEMP_ALARM_PWM_EN_SLEEP_B 0x40 -#define TEMP_ALARM_PWM_EN_PWM 0x80 -#define TEMP_ALARM_PWM_EN_ALWAYS 0xC0 -#define TEMP_ALARM_PWM_PER_PRE_MASK 0x38 -#define TEMP_ALARM_PWM_PER_PRE_SHIFT 3 -#define TEMP_ALARM_PWM_PER_DIV_MASK 0x07 -#define TEMP_ALARM_PWM_PER_DIV_SHIFT 0 - -/* Trips: from critical to less critical */ -#define TRIP_STAGE3 0 -#define TRIP_STAGE2 1 -#define TRIP_STAGE1 2 -#define TRIP_NUM 3 - -struct pm8xxx_tm_chip { - struct pm8xxx_tm_core_data cdata; - struct delayed_work irq_work; - struct device *dev; - struct thermal_zone_device *tz_dev; - unsigned long temp; - unsigned int prev_stage; - enum thermal_device_mode mode; - unsigned int thresh; - unsigned int stage; - unsigned int tempstat_irq; - unsigned int overtemp_irq; - void *adc_handle; -}; - -enum pmic_thermal_override_mode { - SOFTWARE_OVERRIDE_DISABLED = 0, - SOFTWARE_OVERRIDE_ENABLED, -}; - -/* Delay between TEMP_STAT IRQ going high and status value changing in ms. */ -#define STATUS_REGISTER_DELAY_MS 40 - -static inline int pm8xxx_tm_read_ctrl(struct pm8xxx_tm_chip *chip, u8 *reg) -{ - int rc; - - rc = pm8xxx_readb(chip->dev->parent, - chip->cdata.reg_addr_temp_alarm_ctrl, reg); - if (rc) - pr_err("%s: pm8xxx_readb(0x%03X) failed, rc=%d\n", - chip->cdata.tm_name, - chip->cdata.reg_addr_temp_alarm_ctrl, rc); - - return rc; -} - -static inline int pm8xxx_tm_write_ctrl(struct pm8xxx_tm_chip *chip, u8 reg) -{ - int rc; - - rc = pm8xxx_writeb(chip->dev->parent, - chip->cdata.reg_addr_temp_alarm_ctrl, reg); - if (rc) - pr_err("%s: pm8xxx_writeb(0x%03X)=0x%02X failed, rc=%d\n", - chip->cdata.tm_name, - chip->cdata.reg_addr_temp_alarm_ctrl, reg, rc); - - return rc; -} - -static inline int pm8xxx_tm_write_pwm(struct pm8xxx_tm_chip *chip, u8 reg) -{ - int rc; - - rc = pm8xxx_writeb(chip->dev->parent, - chip->cdata.reg_addr_temp_alarm_pwm, reg); - if (rc) - pr_err("%s: pm8xxx_writeb(0x%03X)=0x%02X failed, rc=%d\n", - chip->cdata.tm_name, - chip->cdata.reg_addr_temp_alarm_pwm, reg, rc); - - return rc; -} - -static inline int -pm8xxx_tm_shutdown_override(struct pm8xxx_tm_chip *chip, - enum pmic_thermal_override_mode mode) -{ - int rc; - u8 reg; - - rc = pm8xxx_tm_read_ctrl(chip, ®); - if (rc < 0) - return rc; - - reg &= ~(TEMP_ALARM_CTRL_OVRD_MASK | TEMP_ALARM_CTRL_STATUS_MASK); - if (mode == SOFTWARE_OVERRIDE_ENABLED) - reg |= (TEMP_ALARM_CTRL_OVRD_ST3 | TEMP_ALARM_CTRL_OVRD_ST2) & - TEMP_ALARM_CTRL_OVRD_MASK; - - rc = pm8xxx_tm_write_ctrl(chip, reg); - - return rc; -} - -/* - * This function initializes the internal temperature value based on only the - * current thermal stage and threshold. - */ -static int pm8xxx_tm_init_temp_no_adc(struct pm8xxx_tm_chip *chip) -{ - int rc; - u8 reg; - - rc = pm8xxx_tm_read_ctrl(chip, ®); - if (rc < 0) - return rc; - - chip->stage = (reg & TEMP_ALARM_CTRL_STATUS_MASK) - >> TEMP_ALARM_CTRL_STATUS_SHIFT; - chip->thresh = (reg & TEMP_ALARM_CTRL_THRESH_MASK) - >> TEMP_ALARM_CTRL_THRESH_SHIFT; - - if (chip->stage) - chip->temp = chip->thresh * TEMP_THRESH_MIN + - (chip->stage - 1) * TEMP_STAGE_STEP + - TEMP_THRESH_MIN; - else - chip->temp = chip->cdata.default_no_adc_temp; - - return 0; -} - -/* - * This function updates the internal temperature value based on the - * current thermal stage and threshold as well as the previous stage - */ -static int pm8xxx_tm_update_temp_no_adc(struct pm8xxx_tm_chip *chip) -{ - unsigned int stage; - int rc; - u8 reg; - - rc = pm8xxx_tm_read_ctrl(chip, ®); - if (rc < 0) - return rc; - - stage = (reg & TEMP_ALARM_CTRL_STATUS_MASK) - >> TEMP_ALARM_CTRL_STATUS_SHIFT; - chip->thresh = (reg & TEMP_ALARM_CTRL_THRESH_MASK) - >> TEMP_ALARM_CTRL_THRESH_SHIFT; - - if (stage > chip->stage) { - /* increasing stage, use lower bound */ - chip->temp = (stage - 1) * TEMP_STAGE_STEP - + chip->thresh * TEMP_THRESH_STEP - + TEMP_STAGE_HYSTERESIS + TEMP_THRESH_MIN; - } else if (stage < chip->stage) { - /* decreasing stage, use upper bound */ - chip->temp = stage * TEMP_STAGE_STEP - + chip->thresh * TEMP_THRESH_STEP - - TEMP_STAGE_HYSTERESIS + TEMP_THRESH_MIN; - } - - chip->stage = stage; - - return 0; -} - -static int pm8xxx_tz_get_temp_no_adc(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - struct pm8xxx_tm_chip *chip = thermal->devdata; - int rc; - - if (!chip || !temp) - return -EINVAL; - - rc = pm8xxx_tm_update_temp_no_adc(chip); - if (rc < 0) - return rc; - - *temp = chip->temp; - - return 0; -} - -static int pm8xxx_tz_get_temp_pm8058_adc(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - struct pm8xxx_tm_chip *chip = thermal->devdata; - DECLARE_COMPLETION_ONSTACK(wait); - struct adc_chan_result adc_result = { - .physical = 0lu, - }; - int rc; - - if (!chip || !temp) - return -EINVAL; - - *temp = chip->temp; - - rc = adc_channel_request_conv(chip->adc_handle, &wait); - if (rc < 0) { - pr_err("%s: adc_channel_request_conv() failed, rc = %d\n", - __func__, rc); - return rc; - } - - wait_for_completion(&wait); - - rc = adc_channel_read_result(chip->adc_handle, &adc_result); - if (rc < 0) { - pr_err("%s: adc_channel_read_result() failed, rc = %d\n", - __func__, rc); - return rc; - } - - *temp = adc_result.physical; - chip->temp = adc_result.physical; - - return 0; -} - -static int pm8xxx_tz_get_temp_pm8xxx_adc(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - struct pm8xxx_tm_chip *chip = thermal->devdata; - struct pm8xxx_adc_chan_result result = { - .physical = 0lu, - }; - int rc; - - if (!chip || !temp) - return -EINVAL; - - *temp = chip->temp; - - rc = pm8xxx_adc_read(chip->cdata.adc_channel, &result); - if (rc < 0) { - pr_err("%s: adc_channel_read_result() failed, rc = %d\n", - chip->cdata.tm_name, rc); - return rc; - } - - *temp = result.physical; - chip->temp = result.physical; - - return 0; -} - -static int pm8xxx_tz_get_mode(struct thermal_zone_device *thermal, - enum thermal_device_mode *mode) -{ - struct pm8xxx_tm_chip *chip = thermal->devdata; - - if (!chip || !mode) - return -EINVAL; - - *mode = chip->mode; - - return 0; -} - -static int pm8xxx_tz_set_mode(struct thermal_zone_device *thermal, - enum thermal_device_mode mode) -{ - struct pm8xxx_tm_chip *chip = thermal->devdata; - - if (!chip) - return -EINVAL; - - /* Mask software override requests if they are not allowed. */ - if (!chip->cdata.allow_software_override) - mode = THERMAL_DEVICE_DISABLED; - - if (mode != chip->mode) { - if (mode == THERMAL_DEVICE_ENABLED) - pm8xxx_tm_shutdown_override(chip, - SOFTWARE_OVERRIDE_ENABLED); - else - pm8xxx_tm_shutdown_override(chip, - SOFTWARE_OVERRIDE_DISABLED); - } - chip->mode = mode; - - return 0; -} - -static int pm8xxx_tz_get_trip_type(struct thermal_zone_device *thermal, - int trip, enum thermal_trip_type *type) -{ - if (trip < 0 || !type) - return -EINVAL; - - switch (trip) { - case TRIP_STAGE3: - *type = THERMAL_TRIP_CRITICAL; - break; - case TRIP_STAGE2: - *type = THERMAL_TRIP_HOT; - break; - case TRIP_STAGE1: - *type = THERMAL_TRIP_HOT; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int pm8xxx_tz_get_trip_temp(struct thermal_zone_device *thermal, - int trip, unsigned long *temp) -{ - struct pm8xxx_tm_chip *chip = thermal->devdata; - int thresh_temp; - - if (!chip || trip < 0 || !temp) - return -EINVAL; - - thresh_temp = chip->thresh * TEMP_THRESH_STEP + - TEMP_THRESH_MIN; - - switch (trip) { - case TRIP_STAGE3: - thresh_temp += 2 * TEMP_STAGE_STEP; - break; - case TRIP_STAGE2: - thresh_temp += TEMP_STAGE_STEP; - break; - case TRIP_STAGE1: - break; - default: - return -EINVAL; - } - - *temp = thresh_temp; - - return 0; -} - -static int pm8xxx_tz_get_crit_temp(struct thermal_zone_device *thermal, - unsigned long *temp) -{ - struct pm8xxx_tm_chip *chip = thermal->devdata; - - if (!chip || !temp) - return -EINVAL; - - *temp = chip->thresh * TEMP_THRESH_STEP + TEMP_THRESH_MIN + - 2 * TEMP_STAGE_STEP; - - return 0; -} - -static struct thermal_zone_device_ops pm8xxx_thermal_zone_ops_no_adc = { - .get_temp = pm8xxx_tz_get_temp_no_adc, - .get_mode = pm8xxx_tz_get_mode, - .set_mode = pm8xxx_tz_set_mode, - .get_trip_type = pm8xxx_tz_get_trip_type, - .get_trip_temp = pm8xxx_tz_get_trip_temp, - .get_crit_temp = pm8xxx_tz_get_crit_temp, -}; - -static struct thermal_zone_device_ops pm8xxx_thermal_zone_ops_pm8xxx_adc = { - .get_temp = pm8xxx_tz_get_temp_pm8xxx_adc, - .get_mode = pm8xxx_tz_get_mode, - .set_mode = pm8xxx_tz_set_mode, - .get_trip_type = pm8xxx_tz_get_trip_type, - .get_trip_temp = pm8xxx_tz_get_trip_temp, - .get_crit_temp = pm8xxx_tz_get_crit_temp, -}; - -static struct thermal_zone_device_ops pm8xxx_thermal_zone_ops_pm8058_adc = { - .get_temp = pm8xxx_tz_get_temp_pm8058_adc, - .get_mode = pm8xxx_tz_get_mode, - .set_mode = pm8xxx_tz_set_mode, - .get_trip_type = pm8xxx_tz_get_trip_type, - .get_trip_temp = pm8xxx_tz_get_trip_temp, - .get_crit_temp = pm8xxx_tz_get_crit_temp, -}; - -static void pm8xxx_tm_work(struct work_struct *work) -{ - struct delayed_work *dwork - = container_of(work, struct delayed_work, work); - struct pm8xxx_tm_chip *chip - = container_of(dwork, struct pm8xxx_tm_chip, irq_work); - unsigned long temp = 0; - int rc, stage, thresh; - u8 reg; - - rc = pm8xxx_tm_read_ctrl(chip, ®); - if (rc < 0) - goto bail; - - /* Clear status bits. */ - if (reg & (TEMP_ALARM_CTRL_ST2_SD | TEMP_ALARM_CTRL_ST3_SD)) { - reg &= ~(TEMP_ALARM_CTRL_ST2_SD | TEMP_ALARM_CTRL_ST3_SD - | TEMP_ALARM_CTRL_STATUS_MASK); - - pm8xxx_tm_write_ctrl(chip, reg); - } - - stage = (reg & TEMP_ALARM_CTRL_STATUS_MASK) - >> TEMP_ALARM_CTRL_STATUS_SHIFT; - thresh = (reg & TEMP_ALARM_CTRL_THRESH_MASK) - >> TEMP_ALARM_CTRL_THRESH_SHIFT; - - thermal_zone_device_update(chip->tz_dev); - - if (stage != chip->prev_stage) { - chip->prev_stage = stage; - - switch (chip->cdata.adc_type) { - case PM8XXX_TM_ADC_NONE: - rc = pm8xxx_tz_get_temp_no_adc(chip->tz_dev, &temp); - break; - case PM8XXX_TM_ADC_PM8058_ADC: - rc = pm8xxx_tz_get_temp_pm8058_adc(chip->tz_dev, &temp); - break; - case PM8XXX_TM_ADC_PM8XXX_ADC: - rc = pm8xxx_tz_get_temp_pm8xxx_adc(chip->tz_dev, &temp); - break; - } - if (rc < 0) - goto bail; - - pr_crit("%s: PMIC Temp Alarm - stage=%u, threshold=%u, temp=%lu mC\n", - chip->cdata.tm_name, stage, thresh, temp); - - /* Notify user space */ - sysfs_notify(&chip->tz_dev->device.kobj, NULL, "type"); - } - -bail: - return; -} - -static irqreturn_t pm8xxx_tm_isr(int irq, void *data) -{ - struct pm8xxx_tm_chip *chip = data; - - schedule_delayed_work(&chip->irq_work, - msecs_to_jiffies(STATUS_REGISTER_DELAY_MS) + 1); - - return IRQ_HANDLED; -} - -static int pm8xxx_tm_init_reg(struct pm8xxx_tm_chip *chip) -{ - int rc; - u8 reg; - - rc = pm8xxx_tm_read_ctrl(chip, ®); - if (rc < 0) - return rc; - - chip->stage = (reg & TEMP_ALARM_CTRL_STATUS_MASK) - >> TEMP_ALARM_CTRL_STATUS_SHIFT; - chip->temp = 0; - - /* Use temperature threshold set 0: (105, 125, 145) */ - chip->thresh = 0; - reg = (chip->thresh << TEMP_ALARM_CTRL_THRESH_SHIFT) - & TEMP_ALARM_CTRL_THRESH_MASK; - rc = pm8xxx_tm_write_ctrl(chip, reg); - if (rc < 0) - return rc; - - /* - * Set the PMIC temperature alarm module to be always on. This ensures - * that die temperature monitoring is active even if CXO is disabled - * (i.e. when sleep_b is low). This is necessary since CXO can be - * disabled while the system is still heavily loaded. Also, using - * the alway-on instead of PWM-enabled configurations ensures that the - * die temperature can be measured by the PMIC ADC without reconfiguring - * the temperature alarm module first. - */ - rc = pm8xxx_tm_write_pwm(chip, TEMP_ALARM_PWM_EN_ALWAYS); - - return rc; -} - -static int pm8xxx_init_adc(struct pm8xxx_tm_chip *chip, bool enable) -{ - int rc = 0; - - if (chip->cdata.adc_type == PM8XXX_TM_ADC_PM8058_ADC) { - if (enable) { - rc = adc_channel_open(chip->cdata.adc_channel, - &(chip->adc_handle)); - if (rc < 0) - pr_err("adc_channel_open() failed.\n"); - } else { - adc_channel_close(chip->adc_handle); - } - } - - return rc; -} - -static int pm8xxx_tm_probe(struct platform_device *pdev) -{ - const struct pm8xxx_tm_core_data *cdata = pdev->dev.platform_data; - struct thermal_zone_device_ops *tz_ops; - struct pm8xxx_tm_chip *chip; - struct resource *res; - int rc = 0; - - if (!cdata) { - pr_err("missing core data\n"); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct pm8xxx_tm_chip), GFP_KERNEL); - if (chip == NULL) { - pr_err("kzalloc() failed.\n"); - return -ENOMEM; - } - - chip->dev = &pdev->dev; - memcpy(&(chip->cdata), cdata, sizeof(struct pm8xxx_tm_core_data)); - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - chip->cdata.irq_name_temp_stat); - if (res) { - chip->tempstat_irq = res->start; - } else { - pr_err("temp stat IRQ not specified\n"); - goto err_free_chip; - } - - res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, - chip->cdata.irq_name_over_temp); - if (res) { - chip->overtemp_irq = res->start; - } else { - pr_err("over temp IRQ not specified\n"); - goto err_free_chip; - } - - rc = pm8xxx_init_adc(chip, true); - if (rc < 0) { - pr_err("Unable to initialize adc\n"); - goto err_free_chip; - } - - /* Select proper thermal zone ops functions based on ADC type. */ - if (chip->cdata.adc_type == PM8XXX_TM_ADC_PM8XXX_ADC) - tz_ops = &pm8xxx_thermal_zone_ops_pm8xxx_adc; - else if (chip->cdata.adc_type == PM8XXX_TM_ADC_PM8058_ADC) - tz_ops = &pm8xxx_thermal_zone_ops_pm8058_adc; - else - tz_ops = &pm8xxx_thermal_zone_ops_no_adc; - - chip->tz_dev = thermal_zone_device_register(chip->cdata.tm_name, - TRIP_NUM, chip, tz_ops, 0, 0, 0, 0); - - if (chip->tz_dev == NULL) { - pr_err("thermal_zone_device_register() failed.\n"); - rc = -ENODEV; - goto err_fail_adc; - } - - rc = pm8xxx_tm_init_reg(chip); - if (rc < 0) - goto err_free_tz; - rc = pm8xxx_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); - if (rc < 0) - goto err_free_tz; - - if (chip->cdata.adc_type == PM8XXX_TM_ADC_NONE) { - rc = pm8xxx_tm_init_temp_no_adc(chip); - if (rc < 0) - goto err_free_tz; - } - - /* Start in HW control; switch to SW control when user changes mode. */ - chip->mode = THERMAL_DEVICE_DISABLED; - thermal_zone_device_update(chip->tz_dev); - - INIT_DELAYED_WORK(&chip->irq_work, pm8xxx_tm_work); - - rc = request_irq(chip->tempstat_irq, pm8xxx_tm_isr, IRQF_TRIGGER_RISING, - chip->cdata.irq_name_temp_stat, chip); - if (rc < 0) { - pr_err("request_irq(%d) failed: %d\n", chip->tempstat_irq, rc); - goto err_cancel_work; - } - - rc = request_irq(chip->overtemp_irq, pm8xxx_tm_isr, IRQF_TRIGGER_RISING, - chip->cdata.irq_name_over_temp, chip); - if (rc < 0) { - pr_err("request_irq(%d) failed: %d\n", chip->overtemp_irq, rc); - goto err_free_irq_tempstat; - } - - platform_set_drvdata(pdev, chip); - - pr_info("OK\n"); - - return 0; - -err_free_irq_tempstat: - free_irq(chip->tempstat_irq, chip); -err_cancel_work: - cancel_delayed_work_sync(&chip->irq_work); -err_free_tz: - thermal_zone_device_unregister(chip->tz_dev); -err_fail_adc: - pm8xxx_init_adc(chip, false); -err_free_chip: - kfree(chip); - return rc; -} - -static int pm8xxx_tm_remove(struct platform_device *pdev) -{ - struct pm8xxx_tm_chip *chip = platform_get_drvdata(pdev); - - if (chip) { - platform_set_drvdata(pdev, NULL); - cancel_delayed_work_sync(&chip->irq_work); - free_irq(chip->overtemp_irq, chip); - free_irq(chip->tempstat_irq, chip); - pm8xxx_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); - pm8xxx_init_adc(chip, false); - thermal_zone_device_unregister(chip->tz_dev); - kfree(chip); - } - return 0; -} - -static void pm8xxx_tm_shutdown(struct platform_device *pdev) -{ - struct pm8xxx_tm_chip *chip = platform_get_drvdata(pdev); - - pm8xxx_tm_write_pwm(chip, TEMP_ALARM_PWM_EN_NEVER); -} - -#ifdef CONFIG_PM -static int pm8xxx_tm_suspend(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct pm8xxx_tm_chip *chip = platform_get_drvdata(pdev); - - /* Clear override bits in suspend to allow hardware control */ - pm8xxx_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); - - return 0; -} - -static int pm8xxx_tm_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct pm8xxx_tm_chip *chip = platform_get_drvdata(pdev); - - /* Override hardware actions so software can control */ - if (chip->mode == THERMAL_DEVICE_ENABLED) - pm8xxx_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_ENABLED); - - return 0; -} - -static const struct dev_pm_ops pm8xxx_tm_pm_ops = { - .suspend = pm8xxx_tm_suspend, - .resume = pm8xxx_tm_resume, -}; - -#define PM8XXX_TM_PM_OPS (&pm8xxx_tm_pm_ops) -#else -#define PM8XXX_TM_PM_OPS NULL -#endif - -static struct platform_driver pm8xxx_tm_driver = { - .probe = pm8xxx_tm_probe, - .remove = pm8xxx_tm_remove, - .shutdown = pm8xxx_tm_shutdown, - .driver = { - .name = PM8XXX_TM_DEV_NAME, - .owner = THIS_MODULE, - .pm = PM8XXX_TM_PM_OPS, - }, -}; - -static int __init pm8xxx_tm_init(void) -{ - return platform_driver_register(&pm8xxx_tm_driver); -} - -static void __exit pm8xxx_tm_exit(void) -{ - platform_driver_unregister(&pm8xxx_tm_driver); -} - -module_init(pm8xxx_tm_init); -module_exit(pm8xxx_tm_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("PM8xxx Thermal Manager driver"); -MODULE_VERSION("1.0"); -MODULE_ALIAS("platform:" PM8XXX_TM_DEV_NAME); diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 900b5878c1c4cba8110dfe72514f8a820a4de332..66484f5755261519fb9a9c58536f67b92cbc5e5b 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -59,7 +59,6 @@ obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o obj-$(CONFIG_SERIAL_MSM) += msm_serial.o obj-$(CONFIG_SERIAL_MSM_HS) += msm_serial_hs.o obj-$(CONFIG_SERIAL_MSM_HSL) += msm_serial_hs_lite.o -obj-$(CONFIG_MSM_SERIAL_DEBUGGER) += msm_serial_debugger.o obj-$(CONFIG_SERIAL_NETX) += netx-serial.o obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o diff --git a/drivers/tty/serial/msm_serial_debugger.c b/drivers/tty/serial/msm_serial_debugger.c deleted file mode 100644 index 88b67840852434cdeb89d83fe6f7c1bc69d3125b..0000000000000000000000000000000000000000 --- a/drivers/tty/serial/msm_serial_debugger.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * drivers/serial/msm_serial_debuger.c - * - * Serial Debugger Interface for MSM7K - * - * Copyright (C) 2008 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "msm_serial.h" - -static unsigned int debug_port_base; -static int debug_signal_irq; -static struct clk *debug_clk; -static int debug_enable; -static int debugger_enable; -static struct { - unsigned int base; - int irq; - struct device *clk_device; - int signal_irq; -} init_data; - -static inline void msm_write(unsigned int val, unsigned int off) -{ - __raw_writel(val, debug_port_base + off); -} - -static inline unsigned int msm_read(unsigned int off) -{ - return __raw_readl(debug_port_base + off); -} - -static void debug_port_init(void) -{ - /* reset everything */ - msm_write(UART_CR_CMD_RESET_RX, UART_CR); - msm_write(UART_CR_CMD_RESET_TX, UART_CR); - msm_write(UART_CR_CMD_RESET_ERR, UART_CR); - msm_write(UART_CR_CMD_RESET_BREAK_INT, UART_CR); - msm_write(UART_CR_CMD_RESET_CTS, UART_CR); - msm_write(UART_CR_CMD_SET_RFR, UART_CR); - - /* setup clock dividers */ - if (clk_get_rate(debug_clk) == 19200000) { - /* clock is TCXO (19.2MHz) */ - msm_write(0x06, UART_MREG); - msm_write(0xF1, UART_NREG); - msm_write(0x0F, UART_DREG); - msm_write(0x1A, UART_MNDREG); - } else { - /* clock must be TCXO/4 */ - msm_write(0x18, UART_MREG); - msm_write(0xF6, UART_NREG); - msm_write(0x0F, UART_DREG); - msm_write(0x0A, UART_MNDREG); - } - - msm_write(UART_CSR_115200, UART_CSR); - - /* rx interrupt on every character -- keep it simple */ - msm_write(0, UART_RFWR); - - /* enable TX and RX */ - msm_write(0x05, UART_CR); - - /* enable RX interrupt */ - msm_write(UART_IMR_RXLEV, UART_IMR); -} - -static inline int debug_getc(void) -{ - if (msm_read(UART_SR) & UART_SR_RX_READY) { - return msm_read(UART_RF); - } else { - return -1; - } -} - -static inline void debug_putc(unsigned int c) -{ - while (!(msm_read(UART_SR) & UART_SR_TX_READY)) ; - msm_write(c, UART_TF); -} - -static inline void debug_flush(void) -{ - while (!(msm_read(UART_SR) & UART_SR_TX_EMPTY)) ; -} - -static void debug_puts(char *s) -{ - unsigned c; - while ((c = *s++)) { - if (c == '\n') - debug_putc('\r'); - debug_putc(c); - } -} - -static void debug_prompt(void) -{ - debug_puts("debug> "); -} - -int log_buf_copy(char *dest, int idx, int len); -static void dump_kernel_log(void) -{ - char buf[1024]; - int idx = 0; - int ret; - int saved_oip; - - /* setting oops_in_progress prevents log_buf_copy() - * from trying to take a spinlock which will make it - * very unhappy in some cases... - */ - saved_oip = oops_in_progress; - oops_in_progress = 1; - for (;;) { - ret = log_buf_copy(buf, idx, 1023); - if (ret <= 0) - break; - buf[ret] = 0; - debug_puts(buf); - idx += ret; - } - oops_in_progress = saved_oip; -} - -static char *mode_name(unsigned cpsr) -{ - switch (cpsr & MODE_MASK) { - case USR_MODE: return "USR"; - case FIQ_MODE: return "FIQ"; - case IRQ_MODE: return "IRQ"; - case SVC_MODE: return "SVC"; - case ABT_MODE: return "ABT"; - case UND_MODE: return "UND"; - case SYSTEM_MODE: return "SYS"; - default: return "???"; - } -} - -#define DEBUG_MAX 64 -static char debug_cmd[DEBUG_MAX]; -static int debug_busy; -static int debug_abort; - -static int debug_printf(void *cookie, const char *fmt, ...) -{ - char buf[256]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buf, 128, fmt, ap); - va_end(ap); - - debug_puts(buf); - return debug_abort; -} - -/* Safe outside fiq context */ -static int debug_printf_nfiq(void *cookie, const char *fmt, ...) -{ - char buf[256]; - va_list ap; - unsigned long irq_flags; - - va_start(ap, fmt); - vsnprintf(buf, 128, fmt, ap); - va_end(ap); - - local_irq_save(irq_flags); - debug_puts(buf); - debug_flush(); - local_irq_restore(irq_flags); - return debug_abort; -} - -#define dprintf(fmt...) debug_printf(0, fmt) - -unsigned int last_irqs[NR_IRQS]; - -static void dump_irqs(void) -{ - int n; - dprintf("irqnr total since-last status name\n"); - for (n = 1; n < NR_IRQS; n++) { - struct irqaction *act = irq_desc[n].action; - if (!act && !kstat_cpu(0).irqs[n]) - continue; - dprintf("%5d: %10u %11u %8x %s\n", n, - kstat_cpu(0).irqs[n], - kstat_cpu(0).irqs[n] - last_irqs[n], - irq_desc[n].status, - (act && act->name) ? act->name : "???"); - last_irqs[n] = kstat_cpu(0).irqs[n]; - } -} - -static void debug_exec(const char *cmd, unsigned *regs) -{ - if (!strcmp(cmd, "pc")) { - dprintf(" pc %08x cpsr %08x mode %s\n", - regs[15], regs[16], mode_name(regs[16])); - } else if (!strcmp(cmd, "regs")) { - dprintf(" r0 %08x r1 %08x r2 %08x r3 %08x\n", - regs[0], regs[1], regs[2], regs[3]); - dprintf(" r4 %08x r5 %08x r6 %08x r7 %08x\n", - regs[4], regs[5], regs[6], regs[7]); - dprintf(" r8 %08x r9 %08x r10 %08x r11 %08x mode %s\n", - regs[8], regs[9], regs[10], regs[11], - mode_name(regs[16])); - dprintf(" ip %08x sp %08x lr %08x pc %08x cpsr %08x\n", - regs[10], regs[13], regs[14], regs[15], regs[16]); - } else if (!strcmp(cmd, "reboot")) { - if (msm_hw_reset_hook) - msm_hw_reset_hook(); - } else if (!strcmp(cmd, "irqs")) { - dump_irqs(); - } else if (!strcmp(cmd, "kmsg")) { - dump_kernel_log(); - } else if (!strcmp(cmd, "version")) { - dprintf("%s\n", linux_banner); - } else { - if (debug_busy) { - dprintf("command processor busy. trying to abort.\n"); - debug_abort = -1; - } else { - strcpy(debug_cmd, cmd); - debug_busy = 1; - } - msm_trigger_irq(debug_signal_irq); - return; - } - debug_prompt(); -} - -static irqreturn_t debug_irq(int irq, void *dev) -{ - if (debug_busy) { - struct kdbg_ctxt ctxt; - - ctxt.printf = debug_printf_nfiq; - kernel_debugger(&ctxt, debug_cmd); - debug_prompt(); - - debug_busy = 0; - } - return IRQ_HANDLED; -} - -static char debug_buf[DEBUG_MAX]; -static int debug_count; - -static void debug_fiq(void *data, void *regs) -{ - int c; - static int last_c; - - while ((c = debug_getc()) != -1) { - if (!debug_enable) { - if ((c == 13) || (c == 10)) { - debug_enable = true; - debug_count = 0; - debug_prompt(); - } - } else if ((c >= ' ') && (c < 127)) { - if (debug_count < (DEBUG_MAX - 1)) { - debug_buf[debug_count++] = c; - debug_putc(c); - } - } else if ((c == 8) || (c == 127)) { - if (debug_count > 0) { - debug_count--; - debug_putc(8); - debug_putc(' '); - debug_putc(8); - } - } else if ((c == 13) || (c == 10)) { - if (c == '\r' || (c == '\n' && last_c != '\r')) { - debug_putc('\r'); - debug_putc('\n'); - } - if (debug_count) { - debug_buf[debug_count] = 0; - debug_count = 0; - debug_exec(debug_buf, regs); - } else { - debug_prompt(); - } - } - last_c = c; - } - debug_flush(); -} - -#if defined(CONFIG_MSM_SERIAL_DEBUGGER_CONSOLE) -static void debug_console_write(struct console *co, - const char *s, unsigned int count) -{ - unsigned long irq_flags; - - /* disable irq's while TXing outside of FIQ context */ - local_irq_save(irq_flags); - while (count--) { - if (*s == '\n') - debug_putc('\r'); - debug_putc(*s++); - } - debug_flush(); - local_irq_restore(irq_flags); -} - -static struct console msm_serial_debug_console = { - .name = "debug_console", - .write = debug_console_write, - .flags = CON_PRINTBUFFER | CON_ANYTIME | CON_ENABLED, -}; -#endif - -void msm_serial_debug_enable(int enable) { - debug_enable = enable; -} - -void msm_serial_debug_init(unsigned int base, int irq, - struct device *clk_device, int signal_irq) -{ - int ret; - void *port; - - debug_clk = clk_get(clk_device, "uart_clk"); - if (debug_clk) - clk_enable(debug_clk); - - port = ioremap(base, 4096); - if (!port) - return; - - init_data.base = base; - init_data.irq = irq; - init_data.clk_device = clk_device; - init_data.signal_irq = signal_irq; - debug_port_base = (unsigned int) port; - debug_signal_irq = signal_irq; - debug_port_init(); - - debug_prompt(); - - msm_fiq_select(irq); - msm_fiq_set_handler(debug_fiq, 0); - msm_fiq_enable(irq); - - ret = request_irq(signal_irq, debug_irq, - IRQF_TRIGGER_RISING, "debug", 0); - if (ret) - printk(KERN_ERR - "serial_debugger: could not install signal_irq"); - -#if defined(CONFIG_MSM_SERIAL_DEBUGGER_CONSOLE) - register_console(&msm_serial_debug_console); -#endif - debugger_enable = 1; -} -static int msm_serial_debug_remove(const char *val, struct kernel_param *kp) -{ - int ret; - static int pre_stat = 1; - ret = param_set_bool(val, kp); - if (ret) - return ret; - - if (pre_stat == *(int *)kp->arg) - return 0; - - pre_stat = *(int *)kp->arg; - - if (*(int *)kp->arg) { - msm_serial_debug_init(init_data.base, init_data.irq, - init_data.clk_device, init_data.signal_irq); - printk(KERN_INFO "enable FIQ serial debugger\n"); - return 0; - } - -#if defined(CONFIG_MSM_SERIAL_DEBUGGER_CONSOLE) - unregister_console(&msm_serial_debug_console); -#endif - free_irq(init_data.signal_irq, 0); - msm_fiq_set_handler(NULL, 0); - msm_fiq_disable(init_data.irq); - msm_fiq_unselect(init_data.irq); - clk_disable(debug_clk); - printk(KERN_INFO "disable FIQ serial debugger\n"); - return 0; -} -module_param_call(enable, msm_serial_debug_remove, param_get_bool, - &debugger_enable, S_IWUSR | S_IRUGO); diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index 892f2520a19e705e24b96010397b4868a5028d6d..544a4b6236693bb5f2fa69d059d57c315f72bdda 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -70,7 +70,6 @@ #include "u_ether.c" #include "u_qc_ether.c" #ifdef CONFIG_TARGET_CORE -#include "f_tcm.c" #endif #ifdef CONFIG_SND_PCM #include "u_uac1.c" diff --git a/drivers/usb/gadget/f_diag.h b/drivers/usb/gadget/f_diag.h deleted file mode 100644 index 90497b6966a1494eaa9ebc584bb3626628f563dc..0000000000000000000000000000000000000000 --- a/drivers/usb/gadget/f_diag.h +++ /dev/null @@ -1,24 +0,0 @@ -/* drivers/usb/gadget/f_diag.h - * - * Diag Function Device - Route DIAG frames between SMD and USB - * - * Copyright (C) 2008-2009 Google, Inc. - * Copyright (c) 2009, The Linux Foundation. All rights reserved. - * Author: Brian Swetland - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __F_DIAG_H -#define __F_DIAG_H - -int diag_function_add(struct usb_configuration *c, const char *); - -#endif /* __F_DIAG_H */ - diff --git a/drivers/usb/gadget/f_rmnet.h b/drivers/usb/gadget/f_rmnet.h deleted file mode 100644 index f4375ba14160b3909635a9422d3b23b76052a8e7..0000000000000000000000000000000000000000 --- a/drivers/usb/gadget/f_rmnet.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (c) 2010, 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 __F_RMNET_H -#define __F_RMNET_H - -int rmnet_function_add(struct usb_configuration *c); - -#endif /* __F_RMNET_H */ diff --git a/drivers/usb/gadget/f_tcm.c b/drivers/usb/gadget/f_tcm.c deleted file mode 100644 index 6aaffc787a29f16fc94fcf88c5ca7545e84143aa..0000000000000000000000000000000000000000 --- a/drivers/usb/gadget/f_tcm.c +++ /dev/null @@ -1,2404 +0,0 @@ -/* Target based USB-Gadget Function - * - * UAS protocol handling, target callbacks, configfs handling, - * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling. - * - * Author: Sebastian Andrzej Siewior - * License: GPLv2 as published by FSF. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "f_tcm.h" - -USB_GADGET_COMPOSITE_OPTIONS(); - -static struct target_fabric_configfs *usbg_fabric_configfs; -static int (*usbg_connect_cb) (bool connect); - -static inline struct f_uas *to_f_uas(struct usb_function *f) -{ - return container_of(f, struct f_uas, function); -} - -static void usbg_cmd_release(struct kref *); - -static inline void usbg_cleanup_cmd(struct usbg_cmd *cmd) -{ - kref_put(&cmd->ref, usbg_cmd_release); -} - -/* Start bot.c code */ - -static int bot_enqueue_cmd_cbw(struct f_uas *fu) -{ - int ret; - - if (fu->flags & USBG_BOT_CMD_PEND) - return 0; - - ret = usb_ep_queue(fu->ep_out, fu->cmd.req, GFP_ATOMIC); - if (!ret) - fu->flags |= USBG_BOT_CMD_PEND; - return ret; -} - -static void bot_status_complete(struct usb_ep *ep, struct usb_request *req) -{ - struct usbg_cmd *cmd = req->context; - struct f_uas *fu = cmd->fu; - - usbg_cleanup_cmd(cmd); - if (req->status < 0) { - pr_err("ERR %s(%d)\n", __func__, __LINE__); - return; - } - - /* CSW completed, wait for next CBW */ - bot_enqueue_cmd_cbw(fu); -} - -static void bot_enqueue_sense_code(struct f_uas *fu, struct usbg_cmd *cmd) -{ - struct bulk_cs_wrap *csw = &fu->bot_status.csw; - int ret; - u8 *sense; - unsigned int csw_stat; - - csw_stat = cmd->csw_code; - - /* - * We can't send SENSE as a response. So we take ASC & ASCQ from our - * sense buffer and queue it and hope the host sends a REQUEST_SENSE - * command where it learns why we failed. - */ - sense = cmd->sense_iu.sense; - - csw->Tag = cmd->bot_tag; - csw->Status = csw_stat; - fu->bot_status.req->context = cmd; - ret = usb_ep_queue(fu->ep_in, fu->bot_status.req, GFP_ATOMIC); - if (ret) - pr_err("%s(%d) ERR: %d\n", __func__, __LINE__, ret); -} - -static void bot_err_compl(struct usb_ep *ep, struct usb_request *req) -{ - struct usbg_cmd *cmd = req->context; - struct f_uas *fu = cmd->fu; - - if (req->status < 0) - pr_err("ERR %s(%d)\n", __func__, __LINE__); - - if (cmd->data_len) { - if (cmd->data_len > ep->maxpacket) { - req->length = ep->maxpacket; - cmd->data_len -= ep->maxpacket; - } else { - req->length = cmd->data_len; - cmd->data_len = 0; - } - - usb_ep_queue(ep, req, GFP_ATOMIC); - return ; - } - bot_enqueue_sense_code(fu, cmd); -} - -static void bot_send_bad_status(struct usbg_cmd *cmd) -{ - struct f_uas *fu = cmd->fu; - struct bulk_cs_wrap *csw = &fu->bot_status.csw; - struct usb_request *req; - struct usb_ep *ep; - - csw->Residue = cpu_to_le32(cmd->data_len); - - if (cmd->data_len) { - if (cmd->is_read) { - ep = fu->ep_in; - req = fu->bot_req_in; - } else { - ep = fu->ep_out; - req = fu->bot_req_out; - } - - if (cmd->data_len > fu->ep_in->maxpacket) { - req->length = ep->maxpacket; - cmd->data_len -= ep->maxpacket; - } else { - req->length = cmd->data_len; - cmd->data_len = 0; - } - req->complete = bot_err_compl; - req->context = cmd; - req->buf = fu->cmd.buf; - usb_ep_queue(ep, req, GFP_KERNEL); - } else { - bot_enqueue_sense_code(fu, cmd); - } -} - -static int bot_send_status(struct usbg_cmd *cmd, bool moved_data) -{ - struct f_uas *fu = cmd->fu; - struct bulk_cs_wrap *csw = &fu->bot_status.csw; - int ret; - - if (cmd->se_cmd.scsi_status == SAM_STAT_GOOD) { - if (!moved_data && cmd->data_len) { - /* - * the host wants to move data, we don't. Fill / empty - * the pipe and then send the csw with reside set. - */ - cmd->csw_code = US_BULK_STAT_OK; - bot_send_bad_status(cmd); - return 0; - } - - csw->Tag = cmd->bot_tag; - csw->Residue = cpu_to_le32(0); - csw->Status = US_BULK_STAT_OK; - fu->bot_status.req->context = cmd; - - ret = usb_ep_queue(fu->ep_in, fu->bot_status.req, GFP_KERNEL); - if (ret) - pr_err("%s(%d) ERR: %d\n", __func__, __LINE__, ret); - } else { - cmd->csw_code = US_BULK_STAT_FAIL; - bot_send_bad_status(cmd); - } - return 0; -} - -/* - * Called after command (no data transfer) or after the write (to device) - * operation is completed - */ -static int bot_send_status_response(struct usbg_cmd *cmd) -{ - bool moved_data = false; - - if (!cmd->is_read) - moved_data = true; - return bot_send_status(cmd, moved_data); -} - -/* Read request completed, now we have to send the CSW */ -static void bot_read_compl(struct usb_ep *ep, struct usb_request *req) -{ - struct usbg_cmd *cmd = req->context; - - if (req->status < 0) - pr_err("ERR %s(%d)\n", __func__, __LINE__); - - bot_send_status(cmd, true); -} - -static int bot_send_read_response(struct usbg_cmd *cmd) -{ - struct f_uas *fu = cmd->fu; - struct se_cmd *se_cmd = &cmd->se_cmd; - struct usb_gadget *gadget = fuas_to_gadget(fu); - int ret; - - if (!cmd->data_len) { - cmd->csw_code = US_BULK_STAT_PHASE; - bot_send_bad_status(cmd); - return 0; - } - - if (!gadget->sg_supported) { - cmd->data_buf = kmalloc(se_cmd->data_length, GFP_ATOMIC); - if (!cmd->data_buf) - return -ENOMEM; - - sg_copy_to_buffer(se_cmd->t_data_sg, - se_cmd->t_data_nents, - cmd->data_buf, - se_cmd->data_length); - - fu->bot_req_in->buf = cmd->data_buf; - } else { - fu->bot_req_in->buf = NULL; - fu->bot_req_in->num_sgs = se_cmd->t_data_nents; - fu->bot_req_in->sg = se_cmd->t_data_sg; - } - - fu->bot_req_in->complete = bot_read_compl; - fu->bot_req_in->length = se_cmd->data_length; - fu->bot_req_in->context = cmd; - ret = usb_ep_queue(fu->ep_in, fu->bot_req_in, GFP_ATOMIC); - if (ret) - pr_err("%s(%d)\n", __func__, __LINE__); - return 0; -} - -static void usbg_data_write_cmpl(struct usb_ep *, struct usb_request *); -static int usbg_prepare_w_request(struct usbg_cmd *, struct usb_request *); - -static int bot_send_write_request(struct usbg_cmd *cmd) -{ - struct f_uas *fu = cmd->fu; - struct se_cmd *se_cmd = &cmd->se_cmd; - int ret; - - init_completion(&cmd->write_complete); - cmd->fu = fu; - - if (!cmd->data_len) { - cmd->csw_code = US_BULK_STAT_PHASE; - return -EINVAL; - } - - ret = usbg_prepare_w_request(cmd, fu->bot_req_out); - if (ret) - goto cleanup; - ret = usb_ep_queue(fu->ep_out, fu->bot_req_out, GFP_KERNEL); - if (ret) - pr_err("%s(%d)\n", __func__, __LINE__); - - wait_for_completion(&cmd->write_complete); - target_execute_cmd(se_cmd); -cleanup: - return ret; -} - -static int bot_submit_command(struct f_uas *, void *, unsigned int); - -static void bot_cmd_complete(struct usb_ep *ep, struct usb_request *req) -{ - struct f_uas *fu = req->context; - int ret; - - fu->flags &= ~USBG_BOT_CMD_PEND; - - if (req->status < 0) - return; - - ret = bot_submit_command(fu, req->buf, req->actual); - if (ret) - pr_err("%s(%d): %d\n", __func__, __LINE__, ret); -} - -static int bot_prepare_reqs(struct f_uas *fu) -{ - int ret; - - fu->bot_req_in = usb_ep_alloc_request(fu->ep_in, GFP_KERNEL); - if (!fu->bot_req_in) - goto err; - - fu->bot_req_out = usb_ep_alloc_request(fu->ep_out, GFP_KERNEL); - if (!fu->bot_req_out) - goto err_out; - - fu->cmd.req = usb_ep_alloc_request(fu->ep_out, GFP_KERNEL); - if (!fu->cmd.req) - goto err_cmd; - - fu->bot_status.req = usb_ep_alloc_request(fu->ep_in, GFP_KERNEL); - if (!fu->bot_status.req) - goto err_sts; - - fu->bot_status.req->buf = &fu->bot_status.csw; - fu->bot_status.req->length = US_BULK_CS_WRAP_LEN; - fu->bot_status.req->complete = bot_status_complete; - fu->bot_status.csw.Signature = cpu_to_le32(US_BULK_CS_SIGN); - - fu->cmd.buf = kmalloc(fu->ep_out->maxpacket, GFP_KERNEL); - if (!fu->cmd.buf) - goto err_buf; - - fu->cmd.req->complete = bot_cmd_complete; - fu->cmd.req->buf = fu->cmd.buf; - fu->cmd.req->length = fu->ep_out->maxpacket; - fu->cmd.req->context = fu; - - ret = bot_enqueue_cmd_cbw(fu); - if (ret) - goto err_queue; - return 0; -err_queue: - kfree(fu->cmd.buf); - fu->cmd.buf = NULL; -err_buf: - usb_ep_free_request(fu->ep_in, fu->bot_status.req); -err_sts: - usb_ep_free_request(fu->ep_out, fu->cmd.req); - fu->cmd.req = NULL; -err_cmd: - usb_ep_free_request(fu->ep_out, fu->bot_req_out); - fu->bot_req_out = NULL; -err_out: - usb_ep_free_request(fu->ep_in, fu->bot_req_in); - fu->bot_req_in = NULL; -err: - pr_err("BOT: endpoint setup failed\n"); - return -ENOMEM; -} - -void bot_cleanup_old_alt(struct f_uas *fu) -{ - if (!(fu->flags & USBG_ENABLED)) - return; - - usb_ep_disable(fu->ep_in); - usb_ep_disable(fu->ep_out); - - if (!fu->bot_req_in) - return; - - usb_ep_free_request(fu->ep_in, fu->bot_req_in); - usb_ep_free_request(fu->ep_out, fu->bot_req_out); - usb_ep_free_request(fu->ep_out, fu->cmd.req); - usb_ep_free_request(fu->ep_out, fu->bot_status.req); - - kfree(fu->cmd.buf); - - fu->bot_req_in = NULL; - fu->bot_req_out = NULL; - fu->cmd.req = NULL; - fu->bot_status.req = NULL; - fu->cmd.buf = NULL; -} - -static void bot_set_alt(struct f_uas *fu) -{ - struct usb_function *f = &fu->function; - struct usb_gadget *gadget = f->config->cdev->gadget; - int ret; - - fu->flags = USBG_IS_BOT; - - config_ep_by_speed(gadget, f, fu->ep_in); - ret = usb_ep_enable(fu->ep_in); - if (ret) - goto err_b_in; - - config_ep_by_speed(gadget, f, fu->ep_out); - ret = usb_ep_enable(fu->ep_out); - if (ret) - goto err_b_out; - - ret = bot_prepare_reqs(fu); - if (ret) - goto err_wq; - fu->flags |= USBG_ENABLED; - pr_info("Using the BOT protocol\n"); - return; -err_wq: - usb_ep_disable(fu->ep_out); -err_b_out: - usb_ep_disable(fu->ep_in); -err_b_in: - fu->flags = USBG_IS_BOT; -} - -static int usbg_bot_setup(struct usb_function *f, - const struct usb_ctrlrequest *ctrl) -{ - struct f_uas *fu = to_f_uas(f); - struct usb_composite_dev *cdev = f->config->cdev; - u16 w_value = le16_to_cpu(ctrl->wValue); - u16 w_length = le16_to_cpu(ctrl->wLength); - int luns; - u8 *ret_lun; - - switch (ctrl->bRequest) { - case US_BULK_GET_MAX_LUN: - if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_CLASS | - USB_RECIP_INTERFACE)) - return -ENOTSUPP; - - if (w_length < 1) - return -EINVAL; - if (w_value != 0) - return -EINVAL; - luns = atomic_read(&fu->tpg->tpg_port_count); - if (!luns) { - pr_err("No LUNs configured?\n"); - return -EINVAL; - } - /* - * If 4 LUNs are present we return 3 i.e. LUN 0..3 can be - * accessed. The upper limit is 0xf - */ - luns--; - if (luns > 0xf) { - pr_info_once("Limiting the number of luns to 16\n"); - luns = 0xf; - } - ret_lun = cdev->req->buf; - *ret_lun = luns; - cdev->req->length = 1; - return usb_ep_queue(cdev->gadget->ep0, cdev->req, GFP_ATOMIC); - break; - - case US_BULK_RESET_REQUEST: - /* XXX maybe we should remove previous requests for IN + OUT */ - bot_enqueue_cmd_cbw(fu); - return 0; - break; - }; - return -ENOTSUPP; -} - -/* Start uas.c code */ - -static void uasp_cleanup_one_stream(struct f_uas *fu, struct uas_stream *stream) -{ - /* We have either all three allocated or none */ - if (!stream->req_in) - return; - - usb_ep_free_request(fu->ep_in, stream->req_in); - usb_ep_free_request(fu->ep_out, stream->req_out); - usb_ep_free_request(fu->ep_status, stream->req_status); - - stream->req_in = NULL; - stream->req_out = NULL; - stream->req_status = NULL; -} - -static void uasp_free_cmdreq(struct f_uas *fu) -{ - usb_ep_free_request(fu->ep_cmd, fu->cmd.req); - kfree(fu->cmd.buf); - fu->cmd.req = NULL; - fu->cmd.buf = NULL; -} - -static void uasp_cleanup_old_alt(struct f_uas *fu) -{ - int i; - - if (!(fu->flags & USBG_ENABLED)) - return; - - usb_ep_disable(fu->ep_in); - usb_ep_disable(fu->ep_out); - usb_ep_disable(fu->ep_status); - usb_ep_disable(fu->ep_cmd); - - for (i = 0; i < UASP_SS_EP_COMP_NUM_STREAMS; i++) - uasp_cleanup_one_stream(fu, &fu->stream[i]); - uasp_free_cmdreq(fu); -} - -static void uasp_status_data_cmpl(struct usb_ep *ep, struct usb_request *req); - -static int uasp_prepare_r_request(struct usbg_cmd *cmd) -{ - struct se_cmd *se_cmd = &cmd->se_cmd; - struct f_uas *fu = cmd->fu; - struct usb_gadget *gadget = fuas_to_gadget(fu); - struct uas_stream *stream = cmd->stream; - - if (!gadget->sg_supported) { - cmd->data_buf = kmalloc(se_cmd->data_length, GFP_ATOMIC); - if (!cmd->data_buf) - return -ENOMEM; - - sg_copy_to_buffer(se_cmd->t_data_sg, - se_cmd->t_data_nents, - cmd->data_buf, - se_cmd->data_length); - - stream->req_in->buf = cmd->data_buf; - } else { - stream->req_in->buf = NULL; - stream->req_in->num_sgs = se_cmd->t_data_nents; - stream->req_in->sg = se_cmd->t_data_sg; - } - - stream->req_in->complete = uasp_status_data_cmpl; - stream->req_in->length = se_cmd->data_length; - stream->req_in->context = cmd; - - cmd->state = UASP_SEND_STATUS; - return 0; -} - -static void uasp_prepare_status(struct usbg_cmd *cmd) -{ - struct se_cmd *se_cmd = &cmd->se_cmd; - struct sense_iu *iu = &cmd->sense_iu; - struct uas_stream *stream = cmd->stream; - - cmd->state = UASP_QUEUE_COMMAND; - iu->iu_id = IU_ID_STATUS; - iu->tag = cpu_to_be16(cmd->tag); - - /* - * iu->status_qual = cpu_to_be16(STATUS QUALIFIER SAM-4. Where R U?); - */ - iu->len = cpu_to_be16(se_cmd->scsi_sense_length); - iu->status = se_cmd->scsi_status; - stream->req_status->context = cmd; - stream->req_status->length = se_cmd->scsi_sense_length + 16; - stream->req_status->buf = iu; - stream->req_status->complete = uasp_status_data_cmpl; -} - -static void uasp_status_data_cmpl(struct usb_ep *ep, struct usb_request *req) -{ - struct usbg_cmd *cmd = req->context; - struct uas_stream *stream = cmd->stream; - struct f_uas *fu = cmd->fu; - int ret; - - if (req->status < 0) - goto cleanup; - - switch (cmd->state) { - case UASP_SEND_DATA: - ret = uasp_prepare_r_request(cmd); - if (ret) - goto cleanup; - ret = usb_ep_queue(fu->ep_in, stream->req_in, GFP_ATOMIC); - if (ret) - pr_err("%s(%d) => %d\n", __func__, __LINE__, ret); - break; - - case UASP_RECEIVE_DATA: - ret = usbg_prepare_w_request(cmd, stream->req_out); - if (ret) - goto cleanup; - ret = usb_ep_queue(fu->ep_out, stream->req_out, GFP_ATOMIC); - if (ret) - pr_err("%s(%d) => %d\n", __func__, __LINE__, ret); - break; - - case UASP_SEND_STATUS: - uasp_prepare_status(cmd); - ret = usb_ep_queue(fu->ep_status, stream->req_status, - GFP_ATOMIC); - if (ret) - pr_err("%s(%d) => %d\n", __func__, __LINE__, ret); - break; - - case UASP_QUEUE_COMMAND: - usbg_cleanup_cmd(cmd); - usb_ep_queue(fu->ep_cmd, fu->cmd.req, GFP_ATOMIC); - break; - - default: - BUG(); - }; - return; - -cleanup: - usbg_cleanup_cmd(cmd); -} - -static int uasp_send_status_response(struct usbg_cmd *cmd) -{ - struct f_uas *fu = cmd->fu; - struct uas_stream *stream = cmd->stream; - struct sense_iu *iu = &cmd->sense_iu; - - iu->tag = cpu_to_be16(cmd->tag); - stream->req_status->complete = uasp_status_data_cmpl; - stream->req_status->context = cmd; - cmd->fu = fu; - uasp_prepare_status(cmd); - return usb_ep_queue(fu->ep_status, stream->req_status, GFP_ATOMIC); -} - -static int uasp_send_read_response(struct usbg_cmd *cmd) -{ - struct f_uas *fu = cmd->fu; - struct uas_stream *stream = cmd->stream; - struct sense_iu *iu = &cmd->sense_iu; - int ret; - - cmd->fu = fu; - - iu->tag = cpu_to_be16(cmd->tag); - if (fu->flags & USBG_USE_STREAMS) { - - ret = uasp_prepare_r_request(cmd); - if (ret) - goto out; - ret = usb_ep_queue(fu->ep_in, stream->req_in, GFP_ATOMIC); - if (ret) { - pr_err("%s(%d) => %d\n", __func__, __LINE__, ret); - kfree(cmd->data_buf); - cmd->data_buf = NULL; - } - - } else { - - iu->iu_id = IU_ID_READ_READY; - iu->tag = cpu_to_be16(cmd->tag); - - stream->req_status->complete = uasp_status_data_cmpl; - stream->req_status->context = cmd; - - cmd->state = UASP_SEND_DATA; - stream->req_status->buf = iu; - stream->req_status->length = sizeof(struct iu); - - ret = usb_ep_queue(fu->ep_status, stream->req_status, - GFP_ATOMIC); - if (ret) - pr_err("%s(%d) => %d\n", __func__, __LINE__, ret); - } -out: - return ret; -} - -static int uasp_send_write_request(struct usbg_cmd *cmd) -{ - struct f_uas *fu = cmd->fu; - struct se_cmd *se_cmd = &cmd->se_cmd; - struct uas_stream *stream = cmd->stream; - struct sense_iu *iu = &cmd->sense_iu; - int ret; - - init_completion(&cmd->write_complete); - cmd->fu = fu; - - iu->tag = cpu_to_be16(cmd->tag); - - if (fu->flags & USBG_USE_STREAMS) { - - ret = usbg_prepare_w_request(cmd, stream->req_out); - if (ret) - goto cleanup; - ret = usb_ep_queue(fu->ep_out, stream->req_out, GFP_ATOMIC); - if (ret) - pr_err("%s(%d)\n", __func__, __LINE__); - - } else { - - iu->iu_id = IU_ID_WRITE_READY; - iu->tag = cpu_to_be16(cmd->tag); - - stream->req_status->complete = uasp_status_data_cmpl; - stream->req_status->context = cmd; - - cmd->state = UASP_RECEIVE_DATA; - stream->req_status->buf = iu; - stream->req_status->length = sizeof(struct iu); - - ret = usb_ep_queue(fu->ep_status, stream->req_status, - GFP_ATOMIC); - if (ret) - pr_err("%s(%d)\n", __func__, __LINE__); - } - - wait_for_completion(&cmd->write_complete); - target_execute_cmd(se_cmd); -cleanup: - return ret; -} - -static int usbg_submit_command(struct f_uas *, void *, unsigned int); - -static void uasp_cmd_complete(struct usb_ep *ep, struct usb_request *req) -{ - struct f_uas *fu = req->context; - int ret; - - if (req->status < 0) - return; - - ret = usbg_submit_command(fu, req->buf, req->actual); - /* - * Once we tune for performance enqueue the command req here again so - * we can receive a second command while we processing this one. Pay - * attention to properly sync STAUS endpoint with DATA IN + OUT so you - * don't break HS. - */ - if (!ret) - return; - usb_ep_queue(fu->ep_cmd, fu->cmd.req, GFP_ATOMIC); -} - -static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream) -{ - stream->req_in = usb_ep_alloc_request(fu->ep_in, GFP_KERNEL); - if (!stream->req_in) - goto out; - - stream->req_out = usb_ep_alloc_request(fu->ep_out, GFP_KERNEL); - if (!stream->req_out) - goto err_out; - - stream->req_status = usb_ep_alloc_request(fu->ep_status, GFP_KERNEL); - if (!stream->req_status) - goto err_sts; - - return 0; -err_sts: - usb_ep_free_request(fu->ep_status, stream->req_status); - stream->req_status = NULL; -err_out: - usb_ep_free_request(fu->ep_out, stream->req_out); - stream->req_out = NULL; -out: - return -ENOMEM; -} - -static int uasp_alloc_cmd(struct f_uas *fu) -{ - fu->cmd.req = usb_ep_alloc_request(fu->ep_cmd, GFP_KERNEL); - if (!fu->cmd.req) - goto err; - - fu->cmd.buf = kmalloc(fu->ep_cmd->maxpacket, GFP_KERNEL); - if (!fu->cmd.buf) - goto err_buf; - - fu->cmd.req->complete = uasp_cmd_complete; - fu->cmd.req->buf = fu->cmd.buf; - fu->cmd.req->length = fu->ep_cmd->maxpacket; - fu->cmd.req->context = fu; - return 0; - -err_buf: - usb_ep_free_request(fu->ep_cmd, fu->cmd.req); -err: - return -ENOMEM; -} - -static void uasp_setup_stream_res(struct f_uas *fu, int max_streams) -{ - int i; - - for (i = 0; i < max_streams; i++) { - struct uas_stream *s = &fu->stream[i]; - - s->req_in->stream_id = i + 1; - s->req_out->stream_id = i + 1; - s->req_status->stream_id = i + 1; - } -} - -static int uasp_prepare_reqs(struct f_uas *fu) -{ - int ret; - int i; - int max_streams; - - if (fu->flags & USBG_USE_STREAMS) - max_streams = UASP_SS_EP_COMP_NUM_STREAMS; - else - max_streams = 1; - - for (i = 0; i < max_streams; i++) { - ret = uasp_alloc_stream_res(fu, &fu->stream[i]); - if (ret) - goto err_cleanup; - } - - ret = uasp_alloc_cmd(fu); - if (ret) - goto err_free_stream; - uasp_setup_stream_res(fu, max_streams); - - ret = usb_ep_queue(fu->ep_cmd, fu->cmd.req, GFP_ATOMIC); - if (ret) - goto err_free_stream; - - return 0; - -err_free_stream: - uasp_free_cmdreq(fu); - -err_cleanup: - if (i) { - do { - uasp_cleanup_one_stream(fu, &fu->stream[i - 1]); - i--; - } while (i); - } - pr_err("UASP: endpoint setup failed\n"); - return ret; -} - -static void uasp_set_alt(struct f_uas *fu) -{ - struct usb_function *f = &fu->function; - struct usb_gadget *gadget = f->config->cdev->gadget; - int ret; - - fu->flags = USBG_IS_UAS; - - if (gadget->speed == USB_SPEED_SUPER) - fu->flags |= USBG_USE_STREAMS; - - config_ep_by_speed(gadget, f, fu->ep_in); - ret = usb_ep_enable(fu->ep_in); - if (ret) - goto err_b_in; - - config_ep_by_speed(gadget, f, fu->ep_out); - ret = usb_ep_enable(fu->ep_out); - if (ret) - goto err_b_out; - - config_ep_by_speed(gadget, f, fu->ep_cmd); - ret = usb_ep_enable(fu->ep_cmd); - if (ret) - goto err_cmd; - config_ep_by_speed(gadget, f, fu->ep_status); - ret = usb_ep_enable(fu->ep_status); - if (ret) - goto err_status; - - ret = uasp_prepare_reqs(fu); - if (ret) - goto err_wq; - fu->flags |= USBG_ENABLED; - - pr_info("Using the UAS protocol\n"); - return; -err_wq: - usb_ep_disable(fu->ep_status); -err_status: - usb_ep_disable(fu->ep_cmd); -err_cmd: - usb_ep_disable(fu->ep_out); -err_b_out: - usb_ep_disable(fu->ep_in); -err_b_in: - fu->flags = 0; -} - -static int get_cmd_dir(const unsigned char *cdb) -{ - int ret; - - switch (cdb[0]) { - case READ_6: - case READ_10: - case READ_12: - case READ_16: - case INQUIRY: - case MODE_SENSE: - case MODE_SENSE_10: - case SERVICE_ACTION_IN: - case MAINTENANCE_IN: - case PERSISTENT_RESERVE_IN: - case SECURITY_PROTOCOL_IN: - case ACCESS_CONTROL_IN: - case REPORT_LUNS: - case READ_BLOCK_LIMITS: - case READ_POSITION: - case READ_CAPACITY: - case READ_TOC: - case READ_FORMAT_CAPACITIES: - case REQUEST_SENSE: - ret = DMA_FROM_DEVICE; - break; - - case WRITE_6: - case WRITE_10: - case WRITE_12: - case WRITE_16: - case MODE_SELECT: - case MODE_SELECT_10: - case WRITE_VERIFY: - case WRITE_VERIFY_12: - case PERSISTENT_RESERVE_OUT: - case MAINTENANCE_OUT: - case SECURITY_PROTOCOL_OUT: - case ACCESS_CONTROL_OUT: - ret = DMA_TO_DEVICE; - break; - case ALLOW_MEDIUM_REMOVAL: - case TEST_UNIT_READY: - case SYNCHRONIZE_CACHE: - case START_STOP: - case ERASE: - case REZERO_UNIT: - case SEEK_10: - case SPACE: - case VERIFY: - case WRITE_FILEMARKS: - ret = DMA_NONE; - break; - default: - pr_warn("target: Unknown data direction for SCSI Opcode " - "0x%02x\n", cdb[0]); - ret = -EINVAL; - } - return ret; -} - -static void usbg_data_write_cmpl(struct usb_ep *ep, struct usb_request *req) -{ - struct usbg_cmd *cmd = req->context; - struct se_cmd *se_cmd = &cmd->se_cmd; - - if (req->status < 0) { - pr_err("%s() state %d transfer failed\n", __func__, cmd->state); - goto cleanup; - } - - if (req->num_sgs == 0) { - sg_copy_from_buffer(se_cmd->t_data_sg, - se_cmd->t_data_nents, - cmd->data_buf, - se_cmd->data_length); - } - - complete(&cmd->write_complete); - return; - -cleanup: - usbg_cleanup_cmd(cmd); -} - -static int usbg_prepare_w_request(struct usbg_cmd *cmd, struct usb_request *req) -{ - struct se_cmd *se_cmd = &cmd->se_cmd; - struct f_uas *fu = cmd->fu; - struct usb_gadget *gadget = fuas_to_gadget(fu); - - if (!gadget->sg_supported) { - cmd->data_buf = kmalloc(se_cmd->data_length, GFP_ATOMIC); - if (!cmd->data_buf) - return -ENOMEM; - - req->buf = cmd->data_buf; - } else { - req->buf = NULL; - req->num_sgs = se_cmd->t_data_nents; - req->sg = se_cmd->t_data_sg; - } - - req->complete = usbg_data_write_cmpl; - req->length = se_cmd->data_length; - req->context = cmd; - return 0; -} - -static int usbg_send_status_response(struct se_cmd *se_cmd) -{ - struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, - se_cmd); - struct f_uas *fu = cmd->fu; - - if (fu->flags & USBG_IS_BOT) - return bot_send_status_response(cmd); - else - return uasp_send_status_response(cmd); -} - -static int usbg_send_write_request(struct se_cmd *se_cmd) -{ - struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, - se_cmd); - struct f_uas *fu = cmd->fu; - - if (fu->flags & USBG_IS_BOT) - return bot_send_write_request(cmd); - else - return uasp_send_write_request(cmd); -} - -static int usbg_send_read_response(struct se_cmd *se_cmd) -{ - struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, - se_cmd); - struct f_uas *fu = cmd->fu; - - if (fu->flags & USBG_IS_BOT) - return bot_send_read_response(cmd); - else - return uasp_send_read_response(cmd); -} - -static void usbg_cmd_work(struct work_struct *work) -{ - struct usbg_cmd *cmd = container_of(work, struct usbg_cmd, work); - struct se_cmd *se_cmd; - struct tcm_usbg_nexus *tv_nexus; - struct usbg_tpg *tpg; - int dir; - - se_cmd = &cmd->se_cmd; - tpg = cmd->fu->tpg; - tv_nexus = tpg->tpg_nexus; - dir = get_cmd_dir(cmd->cmd_buf); - if (dir < 0) { - transport_init_se_cmd(se_cmd, - tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, - tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE, - cmd->prio_attr, cmd->sense_iu.sense); - goto out; - } - - if (target_submit_cmd(se_cmd, tv_nexus->tvn_se_sess, - cmd->cmd_buf, cmd->sense_iu.sense, cmd->unpacked_lun, - 0, cmd->prio_attr, dir, TARGET_SCF_UNKNOWN_SIZE) < 0) - goto out; - - return; - -out: - transport_send_check_condition_and_sense(se_cmd, - TCM_UNSUPPORTED_SCSI_OPCODE, 1); - usbg_cleanup_cmd(cmd); -} - -static int usbg_submit_command(struct f_uas *fu, - void *cmdbuf, unsigned int len) -{ - struct command_iu *cmd_iu = cmdbuf; - struct usbg_cmd *cmd; - struct usbg_tpg *tpg; - struct se_cmd *se_cmd; - struct tcm_usbg_nexus *tv_nexus; - u32 cmd_len; - int ret; - - if (cmd_iu->iu_id != IU_ID_COMMAND) { - pr_err("Unsupported type %d\n", cmd_iu->iu_id); - return -EINVAL; - } - - cmd = kzalloc(sizeof *cmd, GFP_ATOMIC); - if (!cmd) - return -ENOMEM; - - cmd->fu = fu; - - /* XXX until I figure out why I can't free in on complete */ - kref_init(&cmd->ref); - kref_get(&cmd->ref); - - tpg = fu->tpg; - cmd_len = (cmd_iu->len & ~0x3) + 16; - if (cmd_len > USBG_MAX_CMD) - goto err; - - memcpy(cmd->cmd_buf, cmd_iu->cdb, cmd_len); - - cmd->tag = be16_to_cpup(&cmd_iu->tag); - if (fu->flags & USBG_USE_STREAMS) { - if (cmd->tag > UASP_SS_EP_COMP_NUM_STREAMS) - goto err; - if (!cmd->tag) - cmd->stream = &fu->stream[0]; - else - cmd->stream = &fu->stream[cmd->tag - 1]; - } else { - cmd->stream = &fu->stream[0]; - } - - tv_nexus = tpg->tpg_nexus; - if (!tv_nexus) { - pr_err("Missing nexus, ignoring command\n"); - goto err; - } - - switch (cmd_iu->prio_attr & 0x7) { - case UAS_HEAD_TAG: - cmd->prio_attr = MSG_HEAD_TAG; - break; - case UAS_ORDERED_TAG: - cmd->prio_attr = MSG_ORDERED_TAG; - break; - case UAS_ACA: - cmd->prio_attr = MSG_ACA_TAG; - break; - default: - pr_debug_once("Unsupported prio_attr: %02x.\n", - cmd_iu->prio_attr); - case UAS_SIMPLE_TAG: - cmd->prio_attr = MSG_SIMPLE_TAG; - break; - } - - se_cmd = &cmd->se_cmd; - cmd->unpacked_lun = scsilun_to_int(&cmd_iu->lun); - - INIT_WORK(&cmd->work, usbg_cmd_work); - ret = queue_work(tpg->workqueue, &cmd->work); - if (ret < 0) - goto err; - - return 0; -err: - kfree(cmd); - return -EINVAL; -} - -static void bot_cmd_work(struct work_struct *work) -{ - struct usbg_cmd *cmd = container_of(work, struct usbg_cmd, work); - struct se_cmd *se_cmd; - struct tcm_usbg_nexus *tv_nexus; - struct usbg_tpg *tpg; - int dir; - - se_cmd = &cmd->se_cmd; - tpg = cmd->fu->tpg; - tv_nexus = tpg->tpg_nexus; - dir = get_cmd_dir(cmd->cmd_buf); - if (dir < 0) { - transport_init_se_cmd(se_cmd, - tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, - tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE, - cmd->prio_attr, cmd->sense_iu.sense); - goto out; - } - - if (target_submit_cmd(se_cmd, tv_nexus->tvn_se_sess, - cmd->cmd_buf, cmd->sense_iu.sense, cmd->unpacked_lun, - cmd->data_len, cmd->prio_attr, dir, 0) < 0) - goto out; - - return; - -out: - transport_send_check_condition_and_sense(se_cmd, - TCM_UNSUPPORTED_SCSI_OPCODE, 1); - usbg_cleanup_cmd(cmd); -} - -static int bot_submit_command(struct f_uas *fu, - void *cmdbuf, unsigned int len) -{ - struct bulk_cb_wrap *cbw = cmdbuf; - struct usbg_cmd *cmd; - struct usbg_tpg *tpg; - struct se_cmd *se_cmd; - struct tcm_usbg_nexus *tv_nexus; - u32 cmd_len; - int ret; - - if (cbw->Signature != cpu_to_le32(US_BULK_CB_SIGN)) { - pr_err("Wrong signature on CBW\n"); - return -EINVAL; - } - if (len != 31) { - pr_err("Wrong length for CBW\n"); - return -EINVAL; - } - - cmd_len = cbw->Length; - if (cmd_len < 1 || cmd_len > 16) - return -EINVAL; - - cmd = kzalloc(sizeof *cmd, GFP_ATOMIC); - if (!cmd) - return -ENOMEM; - - cmd->fu = fu; - - /* XXX until I figure out why I can't free in on complete */ - kref_init(&cmd->ref); - kref_get(&cmd->ref); - - tpg = fu->tpg; - - memcpy(cmd->cmd_buf, cbw->CDB, cmd_len); - - cmd->bot_tag = cbw->Tag; - - tv_nexus = tpg->tpg_nexus; - if (!tv_nexus) { - pr_err("Missing nexus, ignoring command\n"); - goto err; - } - - cmd->prio_attr = MSG_SIMPLE_TAG; - se_cmd = &cmd->se_cmd; - cmd->unpacked_lun = cbw->Lun; - cmd->is_read = cbw->Flags & US_BULK_FLAG_IN ? 1 : 0; - cmd->data_len = le32_to_cpu(cbw->DataTransferLength); - - INIT_WORK(&cmd->work, bot_cmd_work); - ret = queue_work(tpg->workqueue, &cmd->work); - if (ret < 0) - goto err; - - return 0; -err: - kfree(cmd); - return -EINVAL; -} - -/* Start fabric.c code */ - -static int usbg_check_true(struct se_portal_group *se_tpg) -{ - return 1; -} - -static int usbg_check_false(struct se_portal_group *se_tpg) -{ - return 0; -} - -static char *usbg_get_fabric_name(void) -{ - return "usb_gadget"; -} - -static u8 usbg_get_fabric_proto_ident(struct se_portal_group *se_tpg) -{ - struct usbg_tpg *tpg = container_of(se_tpg, - struct usbg_tpg, se_tpg); - struct usbg_tport *tport = tpg->tport; - u8 proto_id; - - switch (tport->tport_proto_id) { - case SCSI_PROTOCOL_SAS: - default: - proto_id = sas_get_fabric_proto_ident(se_tpg); - break; - } - - return proto_id; -} - -static char *usbg_get_fabric_wwn(struct se_portal_group *se_tpg) -{ - struct usbg_tpg *tpg = container_of(se_tpg, - struct usbg_tpg, se_tpg); - struct usbg_tport *tport = tpg->tport; - - return &tport->tport_name[0]; -} - -static u16 usbg_get_tag(struct se_portal_group *se_tpg) -{ - struct usbg_tpg *tpg = container_of(se_tpg, - struct usbg_tpg, se_tpg); - return tpg->tport_tpgt; -} - -static u32 usbg_get_default_depth(struct se_portal_group *se_tpg) -{ - return 1; -} - -static u32 usbg_get_pr_transport_id( - struct se_portal_group *se_tpg, - struct se_node_acl *se_nacl, - struct t10_pr_registration *pr_reg, - int *format_code, - unsigned char *buf) -{ - struct usbg_tpg *tpg = container_of(se_tpg, - struct usbg_tpg, se_tpg); - struct usbg_tport *tport = tpg->tport; - int ret = 0; - - switch (tport->tport_proto_id) { - case SCSI_PROTOCOL_SAS: - default: - ret = sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg, - format_code, buf); - break; - } - - return ret; -} - -static u32 usbg_get_pr_transport_id_len( - struct se_portal_group *se_tpg, - struct se_node_acl *se_nacl, - struct t10_pr_registration *pr_reg, - int *format_code) -{ - struct usbg_tpg *tpg = container_of(se_tpg, - struct usbg_tpg, se_tpg); - struct usbg_tport *tport = tpg->tport; - int ret = 0; - - switch (tport->tport_proto_id) { - case SCSI_PROTOCOL_SAS: - default: - ret = sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, - format_code); - break; - } - - return ret; -} - -static char *usbg_parse_pr_out_transport_id( - struct se_portal_group *se_tpg, - const char *buf, - u32 *out_tid_len, - char **port_nexus_ptr) -{ - struct usbg_tpg *tpg = container_of(se_tpg, - struct usbg_tpg, se_tpg); - struct usbg_tport *tport = tpg->tport; - char *tid = NULL; - - switch (tport->tport_proto_id) { - case SCSI_PROTOCOL_SAS: - default: - tid = sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, - port_nexus_ptr); - } - - return tid; -} - -static struct se_node_acl *usbg_alloc_fabric_acl(struct se_portal_group *se_tpg) -{ - struct usbg_nacl *nacl; - - nacl = kzalloc(sizeof(struct usbg_nacl), GFP_KERNEL); - if (!nacl) { - printk(KERN_ERR "Unable to allocate struct usbg_nacl\n"); - return NULL; - } - - return &nacl->se_node_acl; -} - -static void usbg_release_fabric_acl( - struct se_portal_group *se_tpg, - struct se_node_acl *se_nacl) -{ - struct usbg_nacl *nacl = container_of(se_nacl, - struct usbg_nacl, se_node_acl); - kfree(nacl); -} - -static u32 usbg_tpg_get_inst_index(struct se_portal_group *se_tpg) -{ - return 1; -} - -static void usbg_cmd_release(struct kref *ref) -{ - struct usbg_cmd *cmd = container_of(ref, struct usbg_cmd, - ref); - - transport_generic_free_cmd(&cmd->se_cmd, 0); -} - -static void usbg_release_cmd(struct se_cmd *se_cmd) -{ - struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, - se_cmd); - kfree(cmd->data_buf); - kfree(cmd); - return; -} - -static int usbg_shutdown_session(struct se_session *se_sess) -{ - return 0; -} - -static void usbg_close_session(struct se_session *se_sess) -{ - return; -} - -static u32 usbg_sess_get_index(struct se_session *se_sess) -{ - return 0; -} - -/* - * XXX Error recovery: return != 0 if we expect writes. Dunno when that could be - */ -static int usbg_write_pending_status(struct se_cmd *se_cmd) -{ - return 0; -} - -static void usbg_set_default_node_attrs(struct se_node_acl *nacl) -{ - return; -} - -static u32 usbg_get_task_tag(struct se_cmd *se_cmd) -{ - struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, - se_cmd); - struct f_uas *fu = cmd->fu; - - if (fu->flags & USBG_IS_BOT) - return le32_to_cpu(cmd->bot_tag); - else - return cmd->tag; -} - -static int usbg_get_cmd_state(struct se_cmd *se_cmd) -{ - return 0; -} - -static int usbg_queue_tm_rsp(struct se_cmd *se_cmd) -{ - return 0; -} - -static const char *usbg_check_wwn(const char *name) -{ - const char *n; - unsigned int len; - - n = strstr(name, "naa."); - if (!n) - return NULL; - n += 4; - len = strlen(n); - if (len == 0 || len > USBG_NAMELEN - 1) - return NULL; - return n; -} - -static struct se_node_acl *usbg_make_nodeacl( - struct se_portal_group *se_tpg, - struct config_group *group, - const char *name) -{ - struct se_node_acl *se_nacl, *se_nacl_new; - struct usbg_nacl *nacl; - u64 wwpn = 0; - u32 nexus_depth; - const char *wnn_name; - - wnn_name = usbg_check_wwn(name); - if (!wnn_name) - return ERR_PTR(-EINVAL); - se_nacl_new = usbg_alloc_fabric_acl(se_tpg); - if (!(se_nacl_new)) - return ERR_PTR(-ENOMEM); - - nexus_depth = 1; - /* - * se_nacl_new may be released by core_tpg_add_initiator_node_acl() - * when converting a NodeACL from demo mode -> explict - */ - se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new, - name, nexus_depth); - if (IS_ERR(se_nacl)) { - usbg_release_fabric_acl(se_tpg, se_nacl_new); - return se_nacl; - } - /* - * Locate our struct usbg_nacl and set the FC Nport WWPN - */ - nacl = container_of(se_nacl, struct usbg_nacl, se_node_acl); - nacl->iport_wwpn = wwpn; - snprintf(nacl->iport_name, sizeof(nacl->iport_name), "%s", name); - return se_nacl; -} - -static void usbg_drop_nodeacl(struct se_node_acl *se_acl) -{ - struct usbg_nacl *nacl = container_of(se_acl, - struct usbg_nacl, se_node_acl); - core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1); - kfree(nacl); -} - -struct usbg_tpg *the_only_tpg_I_currently_have; - -static struct se_portal_group *usbg_make_tpg( - struct se_wwn *wwn, - struct config_group *group, - const char *name) -{ - struct usbg_tport *tport = container_of(wwn, struct usbg_tport, - tport_wwn); - struct usbg_tpg *tpg; - unsigned long tpgt; - int ret; - - if (strstr(name, "tpgt_") != name) - return ERR_PTR(-EINVAL); - if (kstrtoul(name + 5, 0, &tpgt) || tpgt > UINT_MAX) - return ERR_PTR(-EINVAL); - if (the_only_tpg_I_currently_have) { - pr_err("Until the gadget framework can't handle multiple\n"); - pr_err("gadgets, you can't do this here.\n"); - return ERR_PTR(-EBUSY); - } - - tpg = kzalloc(sizeof(struct usbg_tpg), GFP_KERNEL); - if (!tpg) { - printk(KERN_ERR "Unable to allocate struct usbg_tpg"); - return ERR_PTR(-ENOMEM); - } - mutex_init(&tpg->tpg_mutex); - atomic_set(&tpg->tpg_port_count, 0); - tpg->workqueue = alloc_workqueue("tcm_usb_gadget", 0, 1); - if (!tpg->workqueue) { - kfree(tpg); - return NULL; - } - - tpg->tport = tport; - tpg->tport_tpgt = tpgt; - - ret = core_tpg_register(&usbg_fabric_configfs->tf_ops, wwn, - &tpg->se_tpg, tpg, - TRANSPORT_TPG_TYPE_NORMAL); - if (ret < 0) { - destroy_workqueue(tpg->workqueue); - kfree(tpg); - return NULL; - } - the_only_tpg_I_currently_have = tpg; - return &tpg->se_tpg; -} - -static void usbg_drop_tpg(struct se_portal_group *se_tpg) -{ - struct usbg_tpg *tpg = container_of(se_tpg, - struct usbg_tpg, se_tpg); - - core_tpg_deregister(se_tpg); - destroy_workqueue(tpg->workqueue); - kfree(tpg); - the_only_tpg_I_currently_have = NULL; -} - -static struct se_wwn *usbg_make_tport( - struct target_fabric_configfs *tf, - struct config_group *group, - const char *name) -{ - struct usbg_tport *tport; - const char *wnn_name; - u64 wwpn = 0; - - wnn_name = usbg_check_wwn(name); - if (!wnn_name) - return ERR_PTR(-EINVAL); - - tport = kzalloc(sizeof(struct usbg_tport), GFP_KERNEL); - if (!(tport)) { - printk(KERN_ERR "Unable to allocate struct usbg_tport"); - return ERR_PTR(-ENOMEM); - } - tport->tport_wwpn = wwpn; - snprintf(tport->tport_name, sizeof(tport->tport_name), wnn_name); - return &tport->tport_wwn; -} - -static void usbg_drop_tport(struct se_wwn *wwn) -{ - struct usbg_tport *tport = container_of(wwn, - struct usbg_tport, tport_wwn); - kfree(tport); -} - -/* - * If somebody feels like dropping the version property, go ahead. - */ -static ssize_t usbg_wwn_show_attr_version( - struct target_fabric_configfs *tf, - char *page) -{ - return sprintf(page, "usb-gadget fabric module\n"); -} -TF_WWN_ATTR_RO(usbg, version); - -static struct configfs_attribute *usbg_wwn_attrs[] = { - &usbg_wwn_version.attr, - NULL, -}; - -static ssize_t tcm_usbg_tpg_show_enable( - struct se_portal_group *se_tpg, - char *page) -{ - struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); - - return snprintf(page, PAGE_SIZE, "%u\n", tpg->gadget_connect); -} - -static int usbg_attach(struct usbg_tpg *tpg) -{ - return usbg_connect_cb(true); -} - -static void usbg_detach(struct usbg_tpg *tpg) -{ - usbg_connect_cb(false); -} - -static ssize_t tcm_usbg_tpg_store_enable( - struct se_portal_group *se_tpg, - const char *page, - size_t count) -{ - struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); - unsigned long op; - ssize_t ret; - - ret = kstrtoul(page, 0, &op); - if (ret < 0) - return -EINVAL; - if (op > 1) - return -EINVAL; - - if (op && tpg->gadget_connect) - goto out; - if (!op && !tpg->gadget_connect) - goto out; - - if (op) { - ret = usbg_attach(tpg); - if (ret) - goto out; - } else { - usbg_detach(tpg); - } - tpg->gadget_connect = op; -out: - return count; -} -TF_TPG_BASE_ATTR(tcm_usbg, enable, S_IRUGO | S_IWUSR); - -static ssize_t tcm_usbg_tpg_show_nexus( - struct se_portal_group *se_tpg, - char *page) -{ - struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); - struct tcm_usbg_nexus *tv_nexus; - ssize_t ret; - - mutex_lock(&tpg->tpg_mutex); - tv_nexus = tpg->tpg_nexus; - if (!tv_nexus) { - ret = -ENODEV; - goto out; - } - ret = snprintf(page, PAGE_SIZE, "%s\n", - tv_nexus->tvn_se_sess->se_node_acl->initiatorname); -out: - mutex_unlock(&tpg->tpg_mutex); - return ret; -} - -static int tcm_usbg_make_nexus(struct usbg_tpg *tpg, char *name) -{ - struct se_portal_group *se_tpg; - struct tcm_usbg_nexus *tv_nexus; - int ret; - - mutex_lock(&tpg->tpg_mutex); - if (tpg->tpg_nexus) { - ret = -EEXIST; - pr_debug("tpg->tpg_nexus already exists\n"); - goto err_unlock; - } - se_tpg = &tpg->se_tpg; - - ret = -ENOMEM; - tv_nexus = kzalloc(sizeof(*tv_nexus), GFP_KERNEL); - if (!tv_nexus) { - pr_err("Unable to allocate struct tcm_vhost_nexus\n"); - goto err_unlock; - } - tv_nexus->tvn_se_sess = transport_init_session(); - if (IS_ERR(tv_nexus->tvn_se_sess)) - goto err_free; - - /* - * Since we are running in 'demo mode' this call with generate a - * struct se_node_acl for the tcm_vhost struct se_portal_group with - * the SCSI Initiator port name of the passed configfs group 'name'. - */ - tv_nexus->tvn_se_sess->se_node_acl = core_tpg_check_initiator_node_acl( - se_tpg, name); - if (!tv_nexus->tvn_se_sess->se_node_acl) { - pr_debug("core_tpg_check_initiator_node_acl() failed" - " for %s\n", name); - goto err_session; - } - /* - * Now register the TCM vHost virtual I_T Nexus as active with the - * call to __transport_register_session() - */ - __transport_register_session(se_tpg, tv_nexus->tvn_se_sess->se_node_acl, - tv_nexus->tvn_se_sess, tv_nexus); - tpg->tpg_nexus = tv_nexus; - mutex_unlock(&tpg->tpg_mutex); - return 0; - -err_session: - transport_free_session(tv_nexus->tvn_se_sess); -err_free: - kfree(tv_nexus); -err_unlock: - mutex_unlock(&tpg->tpg_mutex); - return ret; -} - -static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg) -{ - struct se_session *se_sess; - struct tcm_usbg_nexus *tv_nexus; - int ret = -ENODEV; - - mutex_lock(&tpg->tpg_mutex); - tv_nexus = tpg->tpg_nexus; - if (!tv_nexus) - goto out; - - se_sess = tv_nexus->tvn_se_sess; - if (!se_sess) - goto out; - - if (atomic_read(&tpg->tpg_port_count)) { - ret = -EPERM; - pr_err("Unable to remove Host I_T Nexus with" - " active TPG port count: %d\n", - atomic_read(&tpg->tpg_port_count)); - goto out; - } - - pr_debug("Removing I_T Nexus to Initiator Port: %s\n", - tv_nexus->tvn_se_sess->se_node_acl->initiatorname); - /* - * Release the SCSI I_T Nexus to the emulated vHost Target Port - */ - transport_deregister_session(tv_nexus->tvn_se_sess); - tpg->tpg_nexus = NULL; - - kfree(tv_nexus); - ret = 0; -out: - mutex_unlock(&tpg->tpg_mutex); - return ret; -} - -static ssize_t tcm_usbg_tpg_store_nexus( - struct se_portal_group *se_tpg, - const char *page, - size_t count) -{ - struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); - unsigned char i_port[USBG_NAMELEN], *ptr; - int ret; - - if (!strncmp(page, "NULL", 4)) { - ret = tcm_usbg_drop_nexus(tpg); - return (!ret) ? count : ret; - } - if (strlen(page) >= USBG_NAMELEN) { - pr_err("Emulated NAA Sas Address: %s, exceeds" - " max: %d\n", page, USBG_NAMELEN); - return -EINVAL; - } - snprintf(i_port, USBG_NAMELEN, "%s", page); - - ptr = strstr(i_port, "naa."); - if (!ptr) { - pr_err("Missing 'naa.' prefix\n"); - return -EINVAL; - } - - if (i_port[strlen(i_port) - 1] == '\n') - i_port[strlen(i_port) - 1] = '\0'; - - ret = tcm_usbg_make_nexus(tpg, &i_port[4]); - if (ret < 0) - return ret; - return count; -} -TF_TPG_BASE_ATTR(tcm_usbg, nexus, S_IRUGO | S_IWUSR); - -static struct configfs_attribute *usbg_base_attrs[] = { - &tcm_usbg_tpg_enable.attr, - &tcm_usbg_tpg_nexus.attr, - NULL, -}; - -static int usbg_port_link(struct se_portal_group *se_tpg, struct se_lun *lun) -{ - struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); - - atomic_inc(&tpg->tpg_port_count); - smp_mb__after_atomic_inc(); - return 0; -} - -static void usbg_port_unlink(struct se_portal_group *se_tpg, - struct se_lun *se_lun) -{ - struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); - - atomic_dec(&tpg->tpg_port_count); - smp_mb__after_atomic_dec(); -} - -static int usbg_check_stop_free(struct se_cmd *se_cmd) -{ - struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd, - se_cmd); - - kref_put(&cmd->ref, usbg_cmd_release); - return 1; -} - -static struct target_core_fabric_ops usbg_ops = { - .get_fabric_name = usbg_get_fabric_name, - .get_fabric_proto_ident = usbg_get_fabric_proto_ident, - .tpg_get_wwn = usbg_get_fabric_wwn, - .tpg_get_tag = usbg_get_tag, - .tpg_get_default_depth = usbg_get_default_depth, - .tpg_get_pr_transport_id = usbg_get_pr_transport_id, - .tpg_get_pr_transport_id_len = usbg_get_pr_transport_id_len, - .tpg_parse_pr_out_transport_id = usbg_parse_pr_out_transport_id, - .tpg_check_demo_mode = usbg_check_true, - .tpg_check_demo_mode_cache = usbg_check_false, - .tpg_check_demo_mode_write_protect = usbg_check_false, - .tpg_check_prod_mode_write_protect = usbg_check_false, - .tpg_alloc_fabric_acl = usbg_alloc_fabric_acl, - .tpg_release_fabric_acl = usbg_release_fabric_acl, - .tpg_get_inst_index = usbg_tpg_get_inst_index, - .release_cmd = usbg_release_cmd, - .shutdown_session = usbg_shutdown_session, - .close_session = usbg_close_session, - .sess_get_index = usbg_sess_get_index, - .sess_get_initiator_sid = NULL, - .write_pending = usbg_send_write_request, - .write_pending_status = usbg_write_pending_status, - .set_default_node_attributes = usbg_set_default_node_attrs, - .get_task_tag = usbg_get_task_tag, - .get_cmd_state = usbg_get_cmd_state, - .queue_data_in = usbg_send_read_response, - .queue_status = usbg_send_status_response, - .queue_tm_rsp = usbg_queue_tm_rsp, - .check_stop_free = usbg_check_stop_free, - - .fabric_make_wwn = usbg_make_tport, - .fabric_drop_wwn = usbg_drop_tport, - .fabric_make_tpg = usbg_make_tpg, - .fabric_drop_tpg = usbg_drop_tpg, - .fabric_post_link = usbg_port_link, - .fabric_pre_unlink = usbg_port_unlink, - .fabric_make_np = NULL, - .fabric_drop_np = NULL, - .fabric_make_nodeacl = usbg_make_nodeacl, - .fabric_drop_nodeacl = usbg_drop_nodeacl, -}; - -static int usbg_register_configfs(void) -{ - struct target_fabric_configfs *fabric; - int ret; - - fabric = target_fabric_configfs_init(THIS_MODULE, "usb_gadget"); - if (IS_ERR(fabric)) { - printk(KERN_ERR "target_fabric_configfs_init() failed\n"); - return PTR_ERR(fabric); - } - - fabric->tf_ops = usbg_ops; - TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = usbg_wwn_attrs; - TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = usbg_base_attrs; - TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL; - TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL; - TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL; - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL; - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL; - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL; - TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL; - ret = target_fabric_configfs_register(fabric); - if (ret < 0) { - printk(KERN_ERR "target_fabric_configfs_register() failed" - " for usb-gadget\n"); - return ret; - } - usbg_fabric_configfs = fabric; - return 0; -}; - -static void usbg_deregister_configfs(void) -{ - if (!(usbg_fabric_configfs)) - return; - - target_fabric_configfs_deregister(usbg_fabric_configfs); - usbg_fabric_configfs = NULL; -}; - -/* Start gadget.c code */ - -static struct usb_interface_descriptor bot_intf_desc = { - .bLength = sizeof(bot_intf_desc), - .bDescriptorType = USB_DT_INTERFACE, - .bNumEndpoints = 2, - .bAlternateSetting = USB_G_ALT_INT_BBB, - .bInterfaceClass = USB_CLASS_MASS_STORAGE, - .bInterfaceSubClass = USB_SC_SCSI, - .bInterfaceProtocol = USB_PR_BULK, -}; - -static struct usb_interface_descriptor uasp_intf_desc = { - .bLength = sizeof(uasp_intf_desc), - .bDescriptorType = USB_DT_INTERFACE, - .bNumEndpoints = 4, - .bAlternateSetting = USB_G_ALT_INT_UAS, - .bInterfaceClass = USB_CLASS_MASS_STORAGE, - .bInterfaceSubClass = USB_SC_SCSI, - .bInterfaceProtocol = USB_PR_UAS, -}; - -static struct usb_endpoint_descriptor uasp_bi_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_IN, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(512), -}; - -static struct usb_endpoint_descriptor uasp_fs_bi_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_IN, - .bmAttributes = USB_ENDPOINT_XFER_BULK, -}; - -static struct usb_pipe_usage_descriptor uasp_bi_pipe_desc = { - .bLength = sizeof(uasp_bi_pipe_desc), - .bDescriptorType = USB_DT_PIPE_USAGE, - .bPipeID = DATA_IN_PIPE_ID, -}; - -static struct usb_endpoint_descriptor uasp_ss_bi_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_IN, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(1024), -}; - -static struct usb_ss_ep_comp_descriptor uasp_bi_ep_comp_desc = { - .bLength = sizeof(uasp_bi_ep_comp_desc), - .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, - .bMaxBurst = 0, - .bmAttributes = UASP_SS_EP_COMP_LOG_STREAMS, - .wBytesPerInterval = 0, -}; - -static struct usb_ss_ep_comp_descriptor bot_bi_ep_comp_desc = { - .bLength = sizeof(bot_bi_ep_comp_desc), - .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, - .bMaxBurst = 0, -}; - -static struct usb_endpoint_descriptor uasp_bo_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_OUT, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(512), -}; - -static struct usb_endpoint_descriptor uasp_fs_bo_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_OUT, - .bmAttributes = USB_ENDPOINT_XFER_BULK, -}; - -static struct usb_pipe_usage_descriptor uasp_bo_pipe_desc = { - .bLength = sizeof(uasp_bo_pipe_desc), - .bDescriptorType = USB_DT_PIPE_USAGE, - .bPipeID = DATA_OUT_PIPE_ID, -}; - -static struct usb_endpoint_descriptor uasp_ss_bo_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_OUT, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(0x400), -}; - -static struct usb_ss_ep_comp_descriptor uasp_bo_ep_comp_desc = { - .bLength = sizeof(uasp_bo_ep_comp_desc), - .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, - .bmAttributes = UASP_SS_EP_COMP_LOG_STREAMS, -}; - -static struct usb_ss_ep_comp_descriptor bot_bo_ep_comp_desc = { - .bLength = sizeof(bot_bo_ep_comp_desc), - .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, -}; - -static struct usb_endpoint_descriptor uasp_status_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_IN, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(512), -}; - -static struct usb_endpoint_descriptor uasp_fs_status_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_IN, - .bmAttributes = USB_ENDPOINT_XFER_BULK, -}; - -static struct usb_pipe_usage_descriptor uasp_status_pipe_desc = { - .bLength = sizeof(uasp_status_pipe_desc), - .bDescriptorType = USB_DT_PIPE_USAGE, - .bPipeID = STATUS_PIPE_ID, -}; - -static struct usb_endpoint_descriptor uasp_ss_status_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_IN, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(1024), -}; - -static struct usb_ss_ep_comp_descriptor uasp_status_in_ep_comp_desc = { - .bLength = sizeof(uasp_status_in_ep_comp_desc), - .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, - .bmAttributes = UASP_SS_EP_COMP_LOG_STREAMS, -}; - -static struct usb_endpoint_descriptor uasp_cmd_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_OUT, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(512), -}; - -static struct usb_endpoint_descriptor uasp_fs_cmd_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_OUT, - .bmAttributes = USB_ENDPOINT_XFER_BULK, -}; - -static struct usb_pipe_usage_descriptor uasp_cmd_pipe_desc = { - .bLength = sizeof(uasp_cmd_pipe_desc), - .bDescriptorType = USB_DT_PIPE_USAGE, - .bPipeID = CMD_PIPE_ID, -}; - -static struct usb_endpoint_descriptor uasp_ss_cmd_desc = { - .bLength = USB_DT_ENDPOINT_SIZE, - .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = USB_DIR_OUT, - .bmAttributes = USB_ENDPOINT_XFER_BULK, - .wMaxPacketSize = cpu_to_le16(1024), -}; - -static struct usb_ss_ep_comp_descriptor uasp_cmd_comp_desc = { - .bLength = sizeof(uasp_cmd_comp_desc), - .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, -}; - -static struct usb_descriptor_header *uasp_fs_function_desc[] = { - (struct usb_descriptor_header *) &bot_intf_desc, - (struct usb_descriptor_header *) &uasp_fs_bi_desc, - (struct usb_descriptor_header *) &uasp_fs_bo_desc, - - (struct usb_descriptor_header *) &uasp_intf_desc, - (struct usb_descriptor_header *) &uasp_fs_bi_desc, - (struct usb_descriptor_header *) &uasp_bi_pipe_desc, - (struct usb_descriptor_header *) &uasp_fs_bo_desc, - (struct usb_descriptor_header *) &uasp_bo_pipe_desc, - (struct usb_descriptor_header *) &uasp_fs_status_desc, - (struct usb_descriptor_header *) &uasp_status_pipe_desc, - (struct usb_descriptor_header *) &uasp_fs_cmd_desc, - (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, - NULL, -}; - -static struct usb_descriptor_header *uasp_hs_function_desc[] = { - (struct usb_descriptor_header *) &bot_intf_desc, - (struct usb_descriptor_header *) &uasp_bi_desc, - (struct usb_descriptor_header *) &uasp_bo_desc, - - (struct usb_descriptor_header *) &uasp_intf_desc, - (struct usb_descriptor_header *) &uasp_bi_desc, - (struct usb_descriptor_header *) &uasp_bi_pipe_desc, - (struct usb_descriptor_header *) &uasp_bo_desc, - (struct usb_descriptor_header *) &uasp_bo_pipe_desc, - (struct usb_descriptor_header *) &uasp_status_desc, - (struct usb_descriptor_header *) &uasp_status_pipe_desc, - (struct usb_descriptor_header *) &uasp_cmd_desc, - (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, - NULL, -}; - -static struct usb_descriptor_header *uasp_ss_function_desc[] = { - (struct usb_descriptor_header *) &bot_intf_desc, - (struct usb_descriptor_header *) &uasp_ss_bi_desc, - (struct usb_descriptor_header *) &bot_bi_ep_comp_desc, - (struct usb_descriptor_header *) &uasp_ss_bo_desc, - (struct usb_descriptor_header *) &bot_bo_ep_comp_desc, - - (struct usb_descriptor_header *) &uasp_intf_desc, - (struct usb_descriptor_header *) &uasp_ss_bi_desc, - (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc, - (struct usb_descriptor_header *) &uasp_bi_pipe_desc, - (struct usb_descriptor_header *) &uasp_ss_bo_desc, - (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc, - (struct usb_descriptor_header *) &uasp_bo_pipe_desc, - (struct usb_descriptor_header *) &uasp_ss_status_desc, - (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc, - (struct usb_descriptor_header *) &uasp_status_pipe_desc, - (struct usb_descriptor_header *) &uasp_ss_cmd_desc, - (struct usb_descriptor_header *) &uasp_cmd_comp_desc, - (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, - NULL, -}; - -static struct usb_string tcm_us_strings[] = { - [0].s = "Bulk Only Transport", - [1].s = "USB Attached SCSI", - { }, /* end of list */ -}; - -static struct usb_gadget_strings tcm_stringtab = { - .language = 0x0409, - .strings = tcm_us_strings, -}; - -static struct usb_gadget_strings *tcm_strings[] = { - &tcm_stringtab, - NULL, -}; - -static void give_back_ep(struct usb_ep **pep) -{ - struct usb_ep *ep = *pep; - if (!ep) - return; - ep->driver_data = NULL; -} - -static int usbg_bind(struct usb_configuration *c, struct usb_function *f) -{ - struct f_uas *fu = to_f_uas(f); - struct usb_gadget *gadget = c->cdev->gadget; - struct usb_ep *ep; - int iface; - int ret; - - iface = usb_interface_id(c, f); - if (iface < 0) - return iface; - - bot_intf_desc.bInterfaceNumber = iface; - uasp_intf_desc.bInterfaceNumber = iface; - fu->iface = iface; - ep = usb_ep_autoconfig_ss(gadget, &uasp_ss_bi_desc, - &uasp_bi_ep_comp_desc); - if (!ep) - goto ep_fail; - - ep->driver_data = fu; - fu->ep_in = ep; - - ep = usb_ep_autoconfig_ss(gadget, &uasp_ss_bo_desc, - &uasp_bo_ep_comp_desc); - if (!ep) - goto ep_fail; - ep->driver_data = fu; - fu->ep_out = ep; - - ep = usb_ep_autoconfig_ss(gadget, &uasp_ss_status_desc, - &uasp_status_in_ep_comp_desc); - if (!ep) - goto ep_fail; - ep->driver_data = fu; - fu->ep_status = ep; - - ep = usb_ep_autoconfig_ss(gadget, &uasp_ss_cmd_desc, - &uasp_cmd_comp_desc); - if (!ep) - goto ep_fail; - ep->driver_data = fu; - fu->ep_cmd = ep; - - /* Assume endpoint addresses are the same for both speeds */ - uasp_bi_desc.bEndpointAddress = uasp_ss_bi_desc.bEndpointAddress; - uasp_bo_desc.bEndpointAddress = uasp_ss_bo_desc.bEndpointAddress; - uasp_status_desc.bEndpointAddress = - uasp_ss_status_desc.bEndpointAddress; - uasp_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; - - uasp_fs_bi_desc.bEndpointAddress = uasp_ss_bi_desc.bEndpointAddress; - uasp_fs_bo_desc.bEndpointAddress = uasp_ss_bo_desc.bEndpointAddress; - uasp_fs_status_desc.bEndpointAddress = - uasp_ss_status_desc.bEndpointAddress; - uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; - - ret = usb_assign_descriptors(f, uasp_fs_function_desc, - uasp_hs_function_desc, uasp_ss_function_desc); - if (ret) - goto ep_fail; - - return 0; -ep_fail: - pr_err("Can't claim all required eps\n"); - - give_back_ep(&fu->ep_in); - give_back_ep(&fu->ep_out); - give_back_ep(&fu->ep_status); - give_back_ep(&fu->ep_cmd); - return -ENOTSUPP; -} - -static void usbg_unbind(struct usb_configuration *c, struct usb_function *f) -{ - struct f_uas *fu = to_f_uas(f); - - usb_free_all_descriptors(f); - kfree(fu); -} - -struct guas_setup_wq { - struct work_struct work; - struct f_uas *fu; - unsigned int alt; -}; - -static void usbg_delayed_set_alt(struct work_struct *wq) -{ - struct guas_setup_wq *work = container_of(wq, struct guas_setup_wq, - work); - struct f_uas *fu = work->fu; - int alt = work->alt; - - kfree(work); - - if (fu->flags & USBG_IS_BOT) - bot_cleanup_old_alt(fu); - if (fu->flags & USBG_IS_UAS) - uasp_cleanup_old_alt(fu); - - if (alt == USB_G_ALT_INT_BBB) - bot_set_alt(fu); - else if (alt == USB_G_ALT_INT_UAS) - uasp_set_alt(fu); - usb_composite_setup_continue(fu->function.config->cdev); -} - -static int usbg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) -{ - struct f_uas *fu = to_f_uas(f); - - if ((alt == USB_G_ALT_INT_BBB) || (alt == USB_G_ALT_INT_UAS)) { - struct guas_setup_wq *work; - - work = kmalloc(sizeof(*work), GFP_ATOMIC); - if (!work) - return -ENOMEM; - INIT_WORK(&work->work, usbg_delayed_set_alt); - work->fu = fu; - work->alt = alt; - schedule_work(&work->work); - return USB_GADGET_DELAYED_STATUS; - } - return -EOPNOTSUPP; -} - -static void usbg_disable(struct usb_function *f) -{ - struct f_uas *fu = to_f_uas(f); - - if (fu->flags & USBG_IS_UAS) - uasp_cleanup_old_alt(fu); - else if (fu->flags & USBG_IS_BOT) - bot_cleanup_old_alt(fu); - fu->flags = 0; -} - -static int usbg_setup(struct usb_function *f, - const struct usb_ctrlrequest *ctrl) -{ - struct f_uas *fu = to_f_uas(f); - - if (!(fu->flags & USBG_IS_BOT)) - return -EOPNOTSUPP; - - return usbg_bot_setup(f, ctrl); -} - -static int tcm_bind_config(struct usb_configuration *c) -{ - struct f_uas *fu; - int ret; - - fu = kzalloc(sizeof(*fu), GFP_KERNEL); - if (!fu) - return -ENOMEM; - fu->function.name = "Target Function"; - fu->function.strings = tcm_strings; - fu->function.bind = usbg_bind; - fu->function.unbind = usbg_unbind; - fu->function.set_alt = usbg_set_alt; - fu->function.setup = usbg_setup; - fu->function.disable = usbg_disable; - fu->tpg = the_only_tpg_I_currently_have; - - /* BOT interface string */ - ret = usb_string_id(c->cdev); - if (ret < 0) - goto err; - tcm_us_strings[0].id = ret; - bot_intf_desc.iInterface = ret; - - /* data interface label */ - ret = usb_string_id(c->cdev); - if (ret < 0) - goto err; - tcm_us_strings[1].id = ret; - uasp_intf_desc.iInterface = ret; - - ret = usb_add_function(c, &fu->function); - if (ret) - goto err; - - return 0; -err: - kfree(fu); - return ret; -} - -static int f_tcm_init(int (*connect_cb)(bool connect)) -{ - int ret; - - usbg_connect_cb = connect_cb; - ret = usbg_register_configfs(); - return ret; -} - -static void f_tcm_exit(void) -{ - usbg_deregister_configfs(); - usbg_connect_cb = NULL; -} diff --git a/drivers/usb/gadget/f_tcm.h b/drivers/usb/gadget/f_tcm.h deleted file mode 100644 index bed84355bc66d27eae28e798147097133d09c14d..0000000000000000000000000000000000000000 --- a/drivers/usb/gadget/f_tcm.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef __TARGET_USB_GADGET_H__ -#define __TARGET_USB_GADGET_H__ - -#include -/* #include */ -#include -#include -#include -#include -#include -#include - -#define USBG_NAMELEN 32 - -#define fuas_to_gadget(f) (f->function.config->cdev->gadget) -#define UASP_SS_EP_COMP_LOG_STREAMS 4 -#define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS) - -#define USB_G_ALT_INT_BBB 0 -#define USB_G_ALT_INT_UAS 1 - -struct usbg_nacl { - /* Binary World Wide unique Port Name for SAS Initiator port */ - u64 iport_wwpn; - /* ASCII formatted WWPN for Sas Initiator port */ - char iport_name[USBG_NAMELEN]; - /* Returned by usbg_make_nodeacl() */ - struct se_node_acl se_node_acl; -}; - -struct tcm_usbg_nexus { - struct se_session *tvn_se_sess; -}; - -struct usbg_tpg { - struct mutex tpg_mutex; - /* SAS port target portal group tag for TCM */ - u16 tport_tpgt; - /* Pointer back to usbg_tport */ - struct usbg_tport *tport; - struct workqueue_struct *workqueue; - /* Returned by usbg_make_tpg() */ - struct se_portal_group se_tpg; - u32 gadget_connect; - struct tcm_usbg_nexus *tpg_nexus; - atomic_t tpg_port_count; -}; - -struct usbg_tport { - /* SCSI protocol the tport is providing */ - u8 tport_proto_id; - /* Binary World Wide unique Port Name for SAS Target port */ - u64 tport_wwpn; - /* ASCII formatted WWPN for SAS Target port */ - char tport_name[USBG_NAMELEN]; - /* Returned by usbg_make_tport() */ - struct se_wwn tport_wwn; -}; - -enum uas_state { - UASP_SEND_DATA, - UASP_RECEIVE_DATA, - UASP_SEND_STATUS, - UASP_QUEUE_COMMAND, -}; - -#define USBG_MAX_CMD 64 -struct usbg_cmd { - /* common */ - u8 cmd_buf[USBG_MAX_CMD]; - u32 data_len; - struct work_struct work; - int unpacked_lun; - struct se_cmd se_cmd; - void *data_buf; /* used if no sg support available */ - struct f_uas *fu; - struct completion write_complete; - struct kref ref; - - /* UAS only */ - u16 tag; - u16 prio_attr; - struct sense_iu sense_iu; - enum uas_state state; - struct uas_stream *stream; - - /* BOT only */ - __le32 bot_tag; - unsigned int csw_code; - unsigned is_read:1; - -}; - -struct uas_stream { - struct usb_request *req_in; - struct usb_request *req_out; - struct usb_request *req_status; -}; - -struct usbg_cdb { - struct usb_request *req; - void *buf; -}; - -struct bot_status { - struct usb_request *req; - struct bulk_cs_wrap csw; -}; - -struct f_uas { - struct usbg_tpg *tpg; - struct usb_function function; - u16 iface; - - u32 flags; -#define USBG_ENABLED (1 << 0) -#define USBG_IS_UAS (1 << 1) -#define USBG_USE_STREAMS (1 << 2) -#define USBG_IS_BOT (1 << 3) -#define USBG_BOT_CMD_PEND (1 << 4) - - struct usbg_cdb cmd; - struct usb_ep *ep_in; - struct usb_ep *ep_out; - - /* UAS */ - struct usb_ep *ep_status; - struct usb_ep *ep_cmd; - struct uas_stream stream[UASP_SS_EP_COMP_NUM_STREAMS]; - - /* BOT */ - struct bot_status bot_status; - struct usb_request *bot_req_in; - struct usb_request *bot_req_out; -}; - -extern struct usbg_tpg *the_only_tpg_I_currently_have; - -#endif diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 7d780b8698dd2a5c8a127b7d64385d09217b6e7b..1cd972c734f85c30766ec9478f2c49e6cc73e601 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -18,7 +18,6 @@ #include "config.c" #include "composite.c" -#include "f_tcm.c" #define UAS_VENDOR_ID 0x0525 /* NetChip */ #define UAS_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 17e25f8fc09414bb594f97d256c3c12f8398f9e3..6f0fdaaf0bf34253416bc117ef6e51d5c55cd6c9 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -263,18 +263,6 @@ config USB_QCOM_DIAG_BRIDGE To compile this driver as a module, choose M here: the module will be called diag_bridge. If unsure, choose N. -config USB_QCOM_DIAG_BRIDGE_TEST - tristate "USB Qualcomm diagnostic bridge driver test" - depends on USB && USB_QCOM_DIAG_BRIDGE - help - Say Y here if you want to enable the test hook for the - Qualcomm diag bridge driver. When enabled, this will create - a debugfs file entry named "diag_bridge_test" which can be used - to send a ping command to the diag port of the modem over USB. - - To compile this driver as a module, choose M here: the - module will be called diag_bridge_test. If unsure, choose N. - config USB_QCOM_MDM_BRIDGE tristate "USB Qualcomm modem bridge driver for DUN and RMNET" depends on USB diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 993c3c91b34873cd9e8e0722a00ea1fd5b308ed9..6770181534757e0654313b17de71eb58c88ccd0d 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile @@ -32,7 +32,6 @@ obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE) += diag_bridge.o -obj-$(CONFIG_USB_QCOM_DIAG_BRIDGE_TEST) += diag_bridge_test.o mdm_bridge-y := mdm_ctrl_bridge.o mdm_data_bridge.o obj-$(CONFIG_USB_QCOM_MDM_BRIDGE) += mdm_bridge.o obj-$(CONFIG_USB_QCOM_KS_BRIDGE) += ks_bridge.o diff --git a/drivers/usb/misc/diag_bridge_test.c b/drivers/usb/misc/diag_bridge_test.c deleted file mode 100644 index 18d8a51c3efaf468539da3610d78cfeb5f5ffba6..0000000000000000000000000000000000000000 --- a/drivers/usb/misc/diag_bridge_test.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2011, 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 -#include -#include -#include -#include -#include -#include - -#define DRIVER_DESC "USB host diag bridge driver test" -#define DRIVER_VERSION "1.0" - -#define RD_BUF_SIZE 2048 -#define DIAG_TEST_CONNECTED 0 - -struct diag_test_dev { - char *read_buf; - struct work_struct read_w; - unsigned long flags; - - struct diag_bridge_ops ops; -}; -static struct diag_test_dev *__dev; -static struct dentry *dent; - -static void -diag_test_read_complete_cb(void *d, char *buf, size_t size, size_t actual) -{ - if (actual < 0) { - pr_err("%s: read complete err\n", __func__); - return; - } - - print_hex_dump(KERN_INFO, "to_host:", 0, 1, 1, buf, actual, false); -} -static void diag_test_read_work(struct work_struct *w) -{ - struct diag_test_dev *dev = - container_of(w, struct diag_test_dev, read_w); - - memset(dev->read_buf, 0, RD_BUF_SIZE); - diag_bridge_read(dev->read_buf, RD_BUF_SIZE); -} - -static void -diag_test_write_complete_cb(void *d, char *buf, size_t size, size_t actual) -{ - struct diag_test_dev *dev = d; - - if (actual > 0) - schedule_work(&dev->read_w); -} - -#if defined(CONFIG_DEBUG_FS) -#define DEBUG_BUF_SIZE 1024 -static ssize_t send_ping_cmd(struct file *file, const char __user *ubuf, - size_t count, loff_t *ppos) -{ - struct diag_test_dev *dev = __dev; - unsigned char *buf; - int temp = sizeof(unsigned char) * 4; - - if (!dev) - return -ENODEV; - - buf = kmalloc(temp, GFP_KERNEL); - if (!buf) { - pr_err("%s: unable to allocate mem for ping cmd\n", - __func__); - return -ENOMEM; - } - - /* hdlc encoded ping command */ - buf[0] = 0x0C; - buf[1] = 0x14; - buf[2] = 0x3A; - buf[3] = 0x7E; - - diag_bridge_write(buf, temp); - - return count; -} - -const struct file_operations diag_test_ping_ops = { - .write = send_ping_cmd, -}; - -static void diag_test_debug_init(void) -{ - struct dentry *dfile; - - dent = debugfs_create_dir("diag_test", 0); - if (IS_ERR(dent)) - return; - - dfile = debugfs_create_file("send_ping", 0444, dent, - 0, &diag_test_ping_ops); - if (!dfile || IS_ERR(dfile)) - debugfs_remove(dent); -} -#else -static void diag_test_debug_init(void) { } -#endif - -static int diag_test_remove(struct platform_device *pdev) -{ - diag_bridge_close(); - - if (dent) { - debugfs_remove_recursive(dent); - dent = NULL; - } - - return 0; -} - -static int diag_test_probe(struct platform_device *pdev) -{ - struct diag_test_dev *dev = __dev; - int ret = 0; - - pr_info("%s:\n", __func__); - - ret = diag_bridge_open(&dev->ops); - if (ret) - pr_err("diag open failed: %d", ret); - - - diag_test_debug_init(); - - return ret; -} - -static struct platform_driver diag_test = { - .remove = diag_test_remove, - .probe = diag_test_probe, - .driver = { - .name = "diag_bridge", - .owner = THIS_MODULE, - }, -}; - -static int __init diag_test_init(void) -{ - struct diag_test_dev *dev; - int ret = 0; - - pr_info("%s\n", __func__); - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; - - __dev = dev; - - dev->ops.read_complete_cb = diag_test_read_complete_cb; - dev->ops.write_complete_cb = diag_test_write_complete_cb; - dev->read_buf = kmalloc(RD_BUF_SIZE, GFP_KERNEL); - if (!dev->read_buf) { - pr_err("%s: unable to allocate read buffer\n", __func__); - kfree(dev); - return -ENOMEM; - } - - dev->ops.ctxt = dev; - INIT_WORK(&dev->read_w, diag_test_read_work); - - ret = platform_driver_register(&diag_test); - if (ret) - pr_err("%s: platform driver %s register failed %d\n", - __func__, diag_test.driver.name, ret); - - return ret; -} - -static void __exit diag_test_exit(void) -{ - struct diag_test_dev *dev = __dev; - - pr_info("%s:\n", __func__); - - if (test_bit(DIAG_TEST_CONNECTED, &dev->flags)) - diag_bridge_close(); - - kfree(dev->read_buf); - kfree(dev); - -} - -module_init(diag_test_init); -module_exit(diag_test_exit); - -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_VERSION(DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index fc4bffde15a8e1dfbc062147a4a274d5c5da27a6..35541b60d5c3b9383944b1e78d79afe8a47d56b3 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -222,13 +222,6 @@ config FB_MACMODES depends on FB default n -config FB_BACKLIGHT - bool - depends on FB - select BACKLIGHT_LCD_SUPPORT - select BACKLIGHT_CLASS_DEVICE - default n - config FB_MODE_HELPERS bool "Enable Video Mode Handling Helpers" depends on FB @@ -1021,7 +1014,6 @@ config FB_ATMEL_STN config FB_NVIDIA tristate "nVidia Framebuffer Support" depends on FB && PCI - select FB_BACKLIGHT if FB_NVIDIA_BACKLIGHT select FB_MODE_HELPERS select FB_CFB_FILLRECT select FB_CFB_COPYAREA @@ -1069,7 +1061,6 @@ config FB_NVIDIA_BACKLIGHT config FB_RIVA tristate "nVidia Riva support" depends on FB && PCI - select FB_BACKLIGHT if FB_RIVA_BACKLIGHT select FB_MODE_HELPERS select FB_CFB_FILLRECT select FB_CFB_COPYAREA @@ -1347,7 +1338,6 @@ config FB_MATROX_MAVEN config FB_RADEON tristate "ATI Radeon display support" depends on FB && PCI - select FB_BACKLIGHT if FB_RADEON_BACKLIGHT select FB_MODE_HELPERS select FB_CFB_FILLRECT select FB_CFB_COPYAREA @@ -1391,7 +1381,6 @@ config FB_ATY128 select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_BACKLIGHT if FB_ATY128_BACKLIGHT select FB_MACMODES if PPC_PMAC help This driver supports graphics boards with the ATI Rage128 chips. @@ -1414,7 +1403,6 @@ config FB_ATY select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_BACKLIGHT if FB_ATY_BACKLIGHT select FB_MACMODES if PPC help This driver supports graphics boards with the ATI Mach64 chips. @@ -2003,7 +1991,6 @@ config FB_SH_MOBILE_LCDC select FB_SYS_IMAGEBLIT select FB_SYS_FOPS select FB_DEFERRED_IO - select FB_BACKLIGHT select SH_MIPI_DSI if SH_LCD_MIPI_DSI ---help--- Frame buffer driver for the on-chip SH-Mobile LCD controller. diff --git a/drivers/video/msm/Kconfig b/drivers/video/msm/Kconfig index 590723a58d3ca2972f053a9f3d53ea8e7ac0c7a0..67f81988a9da5f8d77c5bfe807d6e3cb9df1a7ee 100644 --- a/drivers/video/msm/Kconfig +++ b/drivers/video/msm/Kconfig @@ -4,7 +4,6 @@ source "drivers/video/msm/vidc/Kconfig" config FB_MSM tristate "MSM Framebuffer support" depends on FB && ARCH_MSM - select FB_BACKLIGHT if FB_MSM_BACKLIGHT select NEW_LEDS select LEDS_CLASS select FB_CFB_FILLRECT @@ -23,12 +22,6 @@ config FB_MSM_BACKLIGHT ---help--- Say Y here if you want to control the backlight of your display. -config FB_MSM_LOGO - bool "MSM Frame Buffer Logo" - default n - ---help--- - Show /initlogo.rle during boot. - config FB_MSM_LCDC_HW bool default n @@ -62,17 +55,6 @@ config FB_MSM_MDP30 Support for MSM MDP HW revision 3.0 Say Y here if this is msm7x25 variant platform. -config FB_MSM_MDP303 - depends on FB_MSM_MDP30 - select FB_MSM_MDP_HW - bool "MDP HW ver3.03" - default n - ---help--- - Support for MSM MDP HW revision 3.03. This is a new version of - MDP3.0 which has the required functionality to support the features - required for msm7x2xA platform. - Say Y here if this is msm7x2xA variant platform. - config FB_MSM_MDP31 select FB_MSM_LCDC_HW select FB_MSM_MDP_HW @@ -111,10 +93,6 @@ config FB_MSM_QPIC bool select FB_MSM_MDSS_COMMON -config FB_MSM_EBI2 - bool - default n - config FB_MSM_MDDI bool default n @@ -123,14 +101,6 @@ config FB_MSM_MIPI_DSI bool default n -config FB_MSM_LCDC - bool - default n - -config FB_MSM_LVDS - bool - default n - config FB_MSM_OVERLAY depends on FB_MSM_MDP40 bool "MDP4 overlay support" @@ -145,30 +115,6 @@ config FB_MSM_EXTMDDI bool default n -config FB_MSM_TVOUT - bool - default n - -config FB_MSM_MDDI_TOSHIBA_COMMON - bool - select FB_MSM_MDDI - default n - -config FB_MSM_MDDI_TOSHIBA_COMMON_VGA - bool - select FB_MSM_MDDI_TOSHIBA_COMMON - default n - -config FB_MSM_MDDI_ORISE - bool - select FB_MSM_MDDI - default n - -config FB_MSM_MDDI_QUICKVX - bool - select FB_MSM_MDDI - default n - config FB_MSM_MDDI_AUTO_DETECT bool select FB_MSM_MDDI @@ -176,245 +122,22 @@ config FB_MSM_MDDI_AUTO_DETECT config FB_MSM_LCDC_AUTO_DETECT bool - select FB_MSM_LCDC - default n - -config FB_MSM_LCDC_PANEL - bool - select FB_MSM_LCDC - default n - -config FB_MSM_MIPI_DSI_TOSHIBA - bool - select FB_MSM_MIPI_DSI - default n - -config FB_MSM_MIPI_DSI_RENESAS - bool - select FB_MSM_MIPI_DSI - default n - -config FB_MSM_MIPI_DSI_TRULY - bool - select FB_MSM_MIPI_DSI - -config FB_MSM_MIPI_DSI_SIMULATOR - bool - select FB_MSM_MIPI_DSI default n -config FB_MSM_MIPI_DSI_NOVATEK - bool - select FB_MSM_MIPI_DSI - default n - -config FB_MSM_MIPI_DSI_NT35510 - bool - select FB_MSM_MIPI_DSI - -config FB_MSM_MIPI_DSI_ORISE - bool - select FB_MSM_MIPI_DSI - default n - -config FB_MSM_MIPI_DSI_NT35516 - bool - select FB_MSM_MIPI_DSI - -config FB_MSM_MIPI_DSI_TC358764_DSI2LVDS - bool - select FB_MSM_MIPI_DSI - ---help--- - Support for Toshiba MIPI DSI-to-LVDS bridge. - The chip supports 1366x768 24-bit - using a single LVDS link - and up to WUXGA 1920x1200 18-bit - using a dual LVDS link. - -config FB_MSM_LCDC_ST15_WXGA - bool - select FB_MSM_LCDC_PANEL - default n - config FB_MSM_LCDC_ST15_PANEL depends on FB_MSM_LCDC_HW bool "LCDC ST1.5 Panel" - select FB_MSM_LCDC_ST15_WXGA ---help--- Support for ST1.5 WXGA (1366x768) panel -config FB_MSM_LCDC_PRISM_WVGA - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_SAMSUNG_WSVGA - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_CHIMEI_WXGA - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_GORDON_VGA - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_TOSHIBA_WVGA_PT - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_TOSHIBA_FWVGA_PT - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_SHARP_WVGA_PT - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_AUO_WVGA - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_TRULY_HVGA_IPS3P2335 - bool - select FB_MSM_LCDC_PANEL - default n - config FB_MSM_LCDC_TRULY_HVGA_IPS3P2335_PT_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Truly HVGA PT Panel" - select FB_MSM_LCDC_TRULY_HVGA_IPS3P2335 default n ---help--- Support for LCDC Truly HVGA PT panel -config FB_MSM_LCDC_SAMSUNG_OLED_PT - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_NT35582_WVGA - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LCDC_WXGA - bool - select FB_MSM_LCDC_PANEL - default n - -config FB_MSM_LVDS_CHIMEI_WXGA - bool - select FB_MSM_LVDS - default n - -config FB_MSM_LVDS_FRC_FHD - bool - select FB_MSM_LVDS - default n - -config FB_MSM_MIPI_TOSHIBA_VIDEO_WVGA_PT - bool - select FB_MSM_MIPI_DSI_TOSHIBA - default n - -config FB_MSM_MIPI_TOSHIBA_VIDEO_WSVGA_PT - bool - select FB_MSM_MIPI_DSI_TOSHIBA - default n - -config FB_MSM_MIPI_TOSHIBA_VIDEO_WUXGA - bool - select FB_MSM_MIPI_DSI_TOSHIBA - default n - -config FB_MSM_MIPI_NOVATEK_VIDEO_QHD_PT - bool - select FB_MSM_MIPI_DSI_NOVATEK - default n - -config FB_MSM_MIPI_NOVATEK_CMD_QHD_PT - bool - select FB_MSM_MIPI_DSI_NOVATEK - default n - -config FB_MSM_MIPI_ORISE_VIDEO_720P_PT - bool - select FB_MSM_MIPI_DSI_ORISE - default n - -config FB_MSM_MIPI_ORISE_CMD_720P_PT - bool - select FB_MSM_MIPI_DSI_ORISE - default n - -config FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT - bool - select FB_MSM_MIPI_DSI_RENESAS - default n - -config FB_MSM_MIPI_RENESAS_CMD_FWVGA_PT - bool - select FB_MSM_MIPI_DSI_RENESAS - default n - -config FB_MSM_MIPI_NT35510_VIDEO_WVGA_PT - bool - select FB_MSM_MIPI_DSI_NT35510 - default n - -config FB_MSM_MIPI_NT35510_CMD_WVGA_PT - bool - select FB_MSM_MIPI_DSI_NT35510 - default n - -config FB_MSM_MIPI_NT35516_VIDEO_QHD_PT - bool - select FB_MSM_MIPI_DSI_NT35516 - default n - -config FB_MSM_MIPI_NT35516_CMD_QHD_PT - bool - select FB_MSM_MIPI_DSI_NT35516 - default n - - -config FB_MSM_MIPI_CHIMEI_WXGA - bool "LVDS Chimei WXGA Panel using Toshiba MIPI DSI-to-LVDS bridge." - select FB_MSM_MIPI_DSI_TC358764_DSI2LVDS - ---help--- - Support for Chimei WXGA (1366x768) panel. - The panel is using a serial LVDS input. - The panel is connected to the host - via Toshiba DSI-to-LVDS bridge. - -config FB_MSM_MIPI_CHIMEI_WUXGA - bool "LVDS Chimei WUXGA Panel using Toshiba MIPI DSI-to-LVDS bridge." - select FB_MSM_MIPI_DSI_TC358764_DSI2LVDS - ---help--- - Support for Chimei WUXGA (1920x1200) panel. - The panel is using a serial LVDS input. - The panel is connected to the host - via Toshiba DSI-to-LVDS bridge. - -config FB_MSM_MIPI_TRULY_VIDEO_WVGA_PT - bool - select FB_MSM_MIPI_DSI_TRULY - -config FB_MSM_MIPI_SIMULATOR_VIDEO - bool - select FB_MSM_MIPI_DSI_SIMULATOR - default n - config FB_MSM_NO_MDP_PIPE_CTRL depends on FB_MSM_OVERLAY bool "Do not use mdp_pipe_ctrl" @@ -449,42 +172,36 @@ choice config FB_MSM_LCDC_PRISM_WVGA_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Prism WVGA Panel" - select FB_MSM_LCDC_PRISM_WVGA ---help--- Support for LCDC Prism WVGA (800x480) panel config FB_MSM_LCDC_SAMSUNG_WSVGA_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Samsung WSVGA Panel" - select FB_MSM_LCDC_SAMSUNG_WSVGA ---help--- Support for LCDC Samsung WSVGA (1024x600) panel config FB_MSM_LCDC_CHIMEI_WXGA_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Chimei WXGA Panel" - select FB_MSM_LCDC_CHIMEI_WXGA ---help--- Support for LCDC Chimei WXGA (1366x768) panel config FB_MSM_LCDC_GORDON_VGA_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Gordon VGA Panel" - select FB_MSM_LCDC_GORDON_VGA ---help--- Support for LCDC Gordon VGA (480x640) panel config FB_MSM_LCDC_TOSHIBA_WVGA_PT_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Toshiba WVGA PT Panel" - select FB_MSM_LCDC_TOSHIBA_WVGA_PT ---help--- Support for LCDC Toshiba WVGA PT (480x800) panel config FB_MSM_LCDC_TOSHIBA_FWVGA_PT_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Toshiba FWVGA PT Panel" - select FB_MSM_LCDC_TOSHIBA_FWVGA_PT ---help--- Support for LCDC Toshiba FWVGA PT (480x864) panel. This configuration has to be selected to support the Toshiba @@ -493,40 +210,34 @@ config FB_MSM_LCDC_TOSHIBA_FWVGA_PT_PANEL config FB_MSM_LCDC_SHARP_WVGA_PT_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Sharp WVGA PT Panel" - select FB_MSM_LCDC_SHARP_WVGA_PT ---help--- Support for LCDC Sharp WVGA PT (480x800) panel config FB_MSM_LCDC_AUO_WVGA_PANEL depends on FB_MSM_LCDC_HW bool "LCDC AUO WVGA Panel" - select FB_MSM_LCDC_AUO_WVGA ---help--- Support for LCDC AUO WVGA(480x800) panel config FB_MSM_LCDC_NT35582_PANEL depends on FB_MSM_LCDC_HW bool "LCDC NT35582 WVGA Panel" - select FB_MSM_LCDC_NT35582_WVGA ---help--- Support for LCDC NT35582 WVGA(480x800) panel config FB_MSM_LCDC_SAMSUNG_OLED_PT_PANEL depends on FB_MSM_LCDC_HW bool "LCDC Samsung OLED PT Panel" - select FB_MSM_LCDC_SAMSUNG_OLED_PT ---help--- Support for LCDC Samsung OLED PT (480x800) panel config FB_MSM_LVDS_CHIMEI_WXGA_PANEL bool "LVDS Chimei WXGA Panel" - select FB_MSM_LVDS_CHIMEI_WXGA ---help--- Support for LVDS Chimei WXGA(1366x768) panel config FB_MSM_LVDS_FRC_FHD_PANEL bool "LVDS FRC FHD Panel" - select FB_MSM_LVDS_FRC_FHD ---help--- Support for LVDS Frc FHD(1920x1080) panel FRC(Frame Rate Converter) uses LVDS as input @@ -537,36 +248,12 @@ config FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM depends on FB_MSM_LCDC_HW bool "MDDI Panel Auto Detect + LCDC Prism WVGA" select FB_MSM_MDDI_AUTO_DETECT - select FB_MSM_LCDC_PRISM_WVGA - select FB_MSM_LCDC_GORDON_VGA - select FB_MSM_LCDC_WXGA - select FB_MSM_LCDC_TOSHIBA_WVGA_PT - select FB_MSM_LCDC_TOSHIBA_FWVGA_PT - select FB_MSM_LCDC_SHARP_WVGA_PT - select FB_MSM_LCDC_ST15_WXGA ---help--- Support for MDDI panel auto detect. If it can't find any MDDI panel, it will load an LCDC panel. config FB_MSM_MIPI_PANEL_DETECT bool "MIPI Panel Detect" - select FB_MSM_MIPI_TOSHIBA_VIDEO_WVGA_PT - select FB_MSM_MIPI_TOSHIBA_VIDEO_WSVGA_PT - select FB_MSM_MIPI_TOSHIBA_VIDEO_WUXGA - select FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT - select FB_MSM_MIPI_RENESAS_CMD_FWVGA_PT - select FB_MSM_MIPI_TRULY_VIDEO_WVGA_PT - select FB_MSM_MIPI_NOVATEK_VIDEO_QHD_PT - select FB_MSM_MIPI_NOVATEK_CMD_QHD_PT - select FB_MSM_MIPI_NT35510_VIDEO_WVGA_PT - select FB_MSM_MIPI_NT35510_CMD_WVGA_PT - select FB_MSM_MIPI_ORISE_VIDEO_720P_PT - select FB_MSM_MIPI_ORISE_CMD_720P_PT - select FB_MSM_MIPI_NT35516_VIDEO_QHD_PT - select FB_MSM_MIPI_NT35516_CMD_QHD_PT - select FB_MSM_MIPI_SIMULATOR_VIDEO - select FB_MSM_MIPI_CHIMEI_WXGA - select FB_MSM_MIPI_CHIMEI_WUXGA ---help--- Support for MIPI panel auto detect @@ -579,160 +266,76 @@ config FB_MSM_MDDI_PANEL_AUTO_DETECT config FB_MSM_LCDC_PANEL_AUTO_DETECT bool "LCDC Panel Auto Detect" select FB_MSM_LCDC_AUTO_DETECT - select FB_MSM_LCDC_SAMSUNG_WSVGA - select FB_MSM_LCDC_AUO_WVGA - select FB_MSM_LCDC_NT35582_WVGA - select FB_MSM_LCDC_SAMSUNG_OLED_PT ---help--- Support for LCDC panel auto detect config FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT bool "LCDC + MIPI Panel Auto Detect" select FB_MSM_LCDC_AUTO_DETECT - select FB_MSM_LCDC_SAMSUNG_WSVGA - select FB_MSM_LCDC_AUO_WVGA - select FB_MSM_LCDC_SAMSUNG_OLED_PT - select FB_MSM_LCDC_NT35582_WVGA - select FB_MSM_LCDC_TOSHIBA_FWVGA_PT - select FB_MSM_MIPI_TOSHIBA_VIDEO_WVGA_PT - select FB_MSM_MIPI_TOSHIBA_VIDEO_WSVGA_PT - select FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT - select FB_MSM_MIPI_RENESAS_CMD_FWVGA_PT - select FB_MSM_MIPI_NOVATEK_VIDEO_QHD_PT - select FB_MSM_MIPI_NOVATEK_CMD_QHD_PT - select FB_MSM_MIPI_NT35510_VIDEO_WVGA_PT - select FB_MSM_MIPI_NT35510_CMD_WVGA_PT - select FB_MSM_MIPI_NT35516_VIDEO_QHD_PT select FM_MSM_MIPI_NT35516_CMD_QHD_PT - select FB_MSM_MIPI_SIMULATOR_VIDEO ---help--- Support for LCDC + MIPI panel auto detect config FB_MSM_LVDS_MIPI_PANEL_DETECT bool "LVDS + MIPI Panel Auto Detect" - select FB_MSM_LVDS_CHIMEI_WXGA - select FB_MSM_LVDS_FRC_FHD - select FB_MSM_MIPI_TOSHIBA_VIDEO_WVGA_PT - select FB_MSM_MIPI_TOSHIBA_VIDEO_WSVGA_PT - select FB_MSM_MIPI_TOSHIBA_VIDEO_WUXGA - select FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT - select FB_MSM_MIPI_RENESAS_CMD_FWVGA_PT - select FB_MSM_MIPI_TRULY_VIDEO_WVGA_PT - select FB_MSM_MIPI_NOVATEK_VIDEO_QHD_PT - select FB_MSM_MIPI_NOVATEK_CMD_QHD_PT - select FB_MSM_MIPI_NT35510_VIDEO_WVGA_PT - select FB_MSM_MIPI_NT35510_CMD_WVGA_PT - select FB_MSM_MIPI_ORISE_VIDEO_720P_PT - select FB_MSM_MIPI_ORISE_CMD_720P_PT - select FB_MSM_MIPI_SIMULATOR_VIDEO - select FB_MSM_MIPI_CHIMEI_WXGA - select FB_MSM_MIPI_CHIMEI_WUXGA ---help--- Support for LVDS + MIPI panel auto detect -config FB_MSM_MDDI_PRISM_WVGA - bool "MDDI Prism WVGA Panel" - select FB_MSM_MDDI - ---help--- - Support for MDDI Prism WVGA (800x480) panel - -config FB_MSM_MDDI_TOSHIBA_WVGA_PORTRAIT - bool "MDDI Toshiba WVGA Portrait Panel" - select FB_MSM_MDDI_TOSHIBA_COMMON - ---help--- - Support for MDDI Toshiba WVGA (480x800) panel - config FB_MSM_MDDI_TOSHIBA_VGA bool "MDDI Toshiba VGA Panel" - select FB_MSM_MDDI_TOSHIBA_COMMON_VGA ---help--- Support for MDDI Toshiba VGA (480x640) and QCIF (176x220) panel -config FB_MSM_MDDI_TOSHIBA_WVGA - bool "MDDI Toshiba WVGA panel" - select FB_MSM_MDDI_TOSHIBA_COMMON - ---help--- - Support for MDDI Toshiba (800x480) WVGA panel - -config FB_MSM_MDDI_SHARP_QVGA_128x128 - bool "MDDI Sharp QVGA Dual Panel" - select FB_MSM_MDDI - ---help--- - Support for MDDI Sharp QVGA (240x320) and 128x128 dual panel - config FB_MSM_MIPI_TOSHIBA_VIDEO_WVGA_PT_PANEL bool "MIPI Toshiba WVGA PT Panel" - select FB_MSM_MIPI_TOSHIBA_VIDEO_WVGA_PT config FB_MSM_MIPI_TOSHIBA_VIDEO_WSVGA_PT_PANEL bool "MIPI Toshiba WSVGA PT Panel" - select FB_MSM_MIPI_TOSHIBA_VIDEO_WSVGA_PT config FB_MSM_MIPI_TOSHIBA_VIDEO_WUXGA_PANEL bool "MIPI Toshiba WUXGA (1920x1200) Panel" - select FB_MSM_MIPI_TOSHIBA_VIDEO_WUXGA config FB_MSM_MIPI_NOVATEK_VIDEO_QHD_PT_PANEL bool "MIPI NOVATEK VIDEO QHD PT Panel" - select FB_MSM_MIPI_NOVATEK_VIDEO_QHD_PT config FB_MSM_MIPI_NOVATEK_CMD_QHD_PT_PANEL bool "MIPI NOVATEK CMD QHD PT Panel" - select FB_MSM_MIPI_NOVATEK_CMD_QHD_PT config FB_MSM_MIPI_ORISE_VIDEO_720P_PT_PANEL bool "MIPI ORISE VIDEO 720P PT Panel" - select FB_MSM_MIPI_ORISE_VIDEO_720P_PT config FB_MSM_MIPI_ORISE_CMD_720P_PT_PANEL bool "MIPI ORISE CMD 720P PT Panel" - select FB_MSM_MIPI_ORISE_CMD_720P_PT config FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT_PANEL bool "MIPI Renesas Video FWVGA PT Panel" - select FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT config FB_MSM_MIPI_RENESAS_CMD_FWVGA_PT_PANEL bool "MIPI Renesas Command FWVGA PT Panel" - select FB_MSM_MIPI_RENESAS_CMD_FWVGA_PT config FB_MSM_MIPI_CHIMEI_WXGA_PANEL bool "MIPI Chimei WXGA PT Panel" - select FB_MSM_MIPI_CHIMEI_WXGA config FB_MSM_MIPI_CHIMEI_WUXGA_PANEL bool "MIPI Chimei WUXGA Panel" - select FB_MSM_MIPI_CHIMEI_WUXGA config FB_MSM_MIPI_TRULY_VIDEO_WVGA_PT_PANEL bool "MIPI Truly Video WVGA PT Panel" - select FB_MSM_MIPI_TRULY_VIDEO_WVGA_PT config FB_MSM_MIPI_NT35510_VIDEO_WVGA_PT_PANEL bool "MIPI NT35510 Video WVGA PT Panel" - select FB_MSM_MIPI_NT35510_VIDEO_WVGA_PT config FB_MSM_MIPI_NT35510_CMD_WVGA_PT_PANEL bool "MIPI NT35510 Command WVGA PT Panel" - select FB_MSM_MIPI_NT35510_CMD_WVGA_PT config FB_MSM_MIPI_NT35516_VIDEO_QHD_PT_PANEL bool "MIPI NT35516 Video qHD PT Panel" - select FB_MSM_MIPI_NT35516_VIDEO_QHD_PT config FB_MSM_MIPI_NT35516_CMD_QHD_PT_PANEL bool "MIPI NT35516 Command qHD PT Panel" - select FB_MSM_MIPI_NT35516_CMD_QHD_PT config FB_MSM_MIPI_SIMULATOR_VIDEO_PANEL bool "MIPI Simulator Video Panel" - select FB_MSM_MIPI_SIMULATOR_VIDEO - -config FB_MSM_EBI2_TMD_QVGA_EPSON_QCIF - bool "EBI2 TMD QVGA Epson QCIF Dual Panel" - select FB_MSM_EBI2 - ---help--- - Support for EBI2 TMD QVGA (240x320) and Epson QCIF (176x220) panel config FB_MSM_HDMI_AS_PRIMARY depends on FB_MSM_HDMI_COMMON @@ -751,21 +354,6 @@ choice depends on FB_MSM_MDP31 default FB_MSM_SECONDARY_PANEL_NONE -config FB_MSM_LCDC_EXTERNAL_WXGA - depends on FB_MSM_MDP31 - bool "External WXGA on LCDC" - select FB_MSM_LCDC_PANEL - ---help--- - Support for external WXGA display (1280x720) - -config FB_MSM_HDMI_SII_EXTERNAL_720P - depends on FB_MSM_MDP31 - bool "External SiI9022 HDMI 720P" - select FB_MSM_LCDC_PANEL - ---help--- - Support for external HDMI 720p display (1280x720p) - Using SiI9022 chipset - config FB_MSM_SECONDARY_PANEL_NONE bool "NONE" ---help--- @@ -781,10 +369,6 @@ config FB_MSM_LCDC_DSUB display shares the same video bus as the primary LCDC attached display. Typically only one of the two displays can be used at one time. -config FB_MSM_EXT_INTERFACE_COMMON - bool - default n - config FB_MSM_HDMI_COMMON bool default n @@ -793,16 +377,6 @@ config FB_MSM_HDMI_3D bool default n -config FB_MSM_HDMI_ADV7520_PANEL - depends on FB_MSM_MDP40 && FB_MSM_OVERLAY - bool "LCDC HDMI ADV7520 720p Panel" - select FB_MSM_DTV - select FB_MSM_EXT_INTERFACE_COMMON - select FB_MSM_HDMI_COMMON - default n - ---help--- - Support for LCDC 720p HDMI panel attached to ADV7520 - config FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT depends on FB_MSM_HDMI_ADV7520_PANEL bool "Use HDCP mode" @@ -812,17 +386,6 @@ config FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT Choose to enable HDCP -config FB_MSM_HDMI_MSM_PANEL - depends on FB_MSM_MDP40 - bool "MSM HDMI 1080p Panel" - select FB_MSM_DTV - select FB_MSM_EXT_INTERFACE_COMMON - select FB_MSM_HDMI_COMMON - select FB_MSM_HDMI_3D - default n - ---help--- - Support for 480p/720p/1080i/1080p output through MSM HDMI - config FB_MSM_HDMI_MSM_PANEL_DVI_SUPPORT depends on FB_MSM_HDMI_MSM_PANEL bool "Use DVI mode" @@ -863,36 +426,26 @@ choice config FB_MSM_TVOUT_NTSC_M bool "NTSC M" - select FB_MSM_TVOUT - select FB_MSM_EXT_INTERFACE_COMMON ---help--- Support for NTSC M region (North American and Korea) config FB_MSM_TVOUT_NTSC_J bool "NTSC J" - select FB_MSM_TVOUT - select FB_MSM_EXT_INTERFACE_COMMON ---help--- Support for NTSC J region (Japan) config FB_MSM_TVOUT_PAL_BDGHIN bool "PAL BDGHIN" - select FB_MSM_TVOUT - select FB_MSM_EXT_INTERFACE_COMMON ---help--- Support for PAL BDGHIN region (Non-argentina PAL-N) config FB_MSM_TVOUT_PAL_M bool "PAL M" - select FB_MSM_TVOUT - select FB_MSM_EXT_INTERFACE_COMMON ---help--- Support for PAL M region config FB_MSM_TVOUT_PAL_N bool "PAL N" - select FB_MSM_TVOUT - select FB_MSM_EXT_INTERFACE_COMMON ---help--- Support for PAL N region (Argentina PAL-N) @@ -915,13 +468,6 @@ choice prompt "External MDDI" default FB_MSM_EXTMDDI_SVGA -config FB_MSM_EXTMDDI_SVGA - bool "External MDDI SVGA" - select FB_MSM_MDDI - select FB_MSM_EXTMDDI - ---help--- - Support for MSM SVGA (800x600) external MDDI panel - config FB_MSM_EXTMDDI_NONE bool "NONE" ---help--- @@ -944,16 +490,8 @@ config FB_MSM_DEFAULT_DEPTH_RGBA8888 endchoice -config FB_MSM_EBI2_EPSON_S1D_QVGA_PANEL - bool "EBI2 Epson QVGA Panel" - select FB_MSM_EBI2 - default n - ---help--- - Support for EBI2 Epson QVGA (240x320) panel - config FB_MSM_EBI2_PANEL_DETECT bool "EBI2 Panel Detect" - select FB_MSM_EBI2_EPSON_S1D_QVGA_PANEL default n ---help--- Support for EBI2 panel auto detect diff --git a/drivers/video/msm/Makefile b/drivers/video/msm/Makefile index 67c6b480a5a6419f6b3a740deda1efd80fd76b17..5b3cafa0ea0ab18dbf41ef0cd1e14880d9175c3f 100644 --- a/drivers/video/msm/Makefile +++ b/drivers/video/msm/Makefile @@ -3,191 +3,57 @@ obj-y += mdss/ else obj-y := msm_fb.o -obj-$(CONFIG_FB_MSM_LOGO) += logo.o -obj-$(CONFIG_FB_BACKLIGHT) += msm_fb_bl.o ifeq ($(CONFIG_FB_MSM_MDP_HW),y) # MDP obj-y += mdp.o -obj-$(CONFIG_DEBUG_FS) += mdp_debugfs.o ifeq ($(CONFIG_FB_MSM_MDP40),y) -obj-y += mdp4_util.o else -obj-y += mdp_hw_init.o obj-y += mdp_ppp.o ifeq ($(CONFIG_FB_MSM_MDP31),y) -obj-y += mdp_ppp_v31.o -else -obj-y += mdp_ppp_v20.o endif endif - ifeq ($(CONFIG_FB_MSM_OVERLAY),y) -obj-y += mdp4_overlay.o -obj-y += mdp4_overlay_lcdc.o ifeq ($(CONFIG_FB_MSM_MIPI_DSI),y) -obj-y += mdp4_overlay_dsi_video.o -obj-y += mdp4_overlay_dsi_cmd.o -else -obj-y += mdp4_overlay_mddi.o endif else -obj-y += mdp_dma_lcdc.o endif -obj-$(CONFIG_FB_MSM_MDP303) += mdp_dma_dsi_video.o -ifeq ($(CONFIG_FB_MSM_DTV),y) -obj-y += mdp4_dtv.o -obj-y += mdp4_overlay_dtv.o -endif - -obj-y += mdp_dma.o -obj-y += mdp_dma_s.o -obj-y += mdp_vsync.o -obj-y += mdp_cursor.o -obj-y += mdp_dma_tv.o -obj-$(CONFIG_ARCH_MSM7X27A) += msm_dss_io_7x27a.o -obj-$(CONFIG_ARCH_MSM8X60) += msm_dss_io_8x60.o -obj-$(CONFIG_ARCH_MSM8960) += msm_dss_io_8960.o # EBI2 -obj-$(CONFIG_FB_MSM_EBI2) += ebi2_lcd.o # LCDC -obj-$(CONFIG_FB_MSM_LCDC) += lcdc.o # LVDS -obj-$(CONFIG_FB_MSM_LVDS) += lvds.o # MDDI -msm_mddi-objs := mddi.o mddihost.o mddihosti.o +msm_mddi-objs := mddi.o obj-$(CONFIG_FB_MSM_MDDI) += msm_mddi.o # External MDDI -msm_mddi_ext-objs := mddihost_e.o mddi_ext.o obj-$(CONFIG_FB_MSM_EXTMDDI) += msm_mddi_ext.o # MIPI gereric -msm_mipi-objs := mipi_dsi.o mipi_dsi_host.o obj-$(CONFIG_FB_MSM_MIPI_DSI) += msm_mipi.o # MIPI manufacture -obj-$(CONFIG_FB_MSM_MIPI_DSI_TOSHIBA) += mipi_toshiba.o -obj-$(CONFIG_FB_MSM_MIPI_DSI_NOVATEK) += mipi_novatek.o -obj-$(CONFIG_FB_MSM_MIPI_DSI_ORISE) += mipi_orise.o -obj-$(CONFIG_FB_MSM_MIPI_DSI_RENESAS) += mipi_renesas.o -obj-$(CONFIG_FB_MSM_MIPI_DSI_TRULY) += mipi_truly.o -obj-$(CONFIG_FB_MSM_MIPI_DSI_NT35510) += mipi_NT35510.o -obj-$(CONFIG_FB_MSM_MIPI_DSI_NT35516) += mipi_truly_tft540960_1_e.o -obj-$(CONFIG_FB_MSM_MIPI_DSI_SIMULATOR) += mipi_simulator.o # MIPI Bridge -obj-$(CONFIG_FB_MSM_MIPI_DSI_TC358764_DSI2LVDS) += mipi_tc358764_dsi2lvds.o # TVEnc -obj-$(CONFIG_FB_MSM_TVOUT) += tvenc.o -ifeq ($(CONFIG_FB_MSM_OVERLAY),y) -obj-$(CONFIG_FB_MSM_TVOUT) += mdp4_overlay_atv.o -endif # MSM FB Panel -obj-y += msm_fb_panel.o -obj-$(CONFIG_FB_MSM_EBI2_TMD_QVGA_EPSON_QCIF) += ebi2_tmd20.o -obj-$(CONFIG_FB_MSM_EBI2_TMD_QVGA_EPSON_QCIF) += ebi2_l2f.o - -ifeq ($(CONFIG_FB_MSM_MDDI_AUTO_DETECT),y) -obj-y += mddi_prism.o -obj-y += mddi_toshiba.o -obj-y += mddi_toshiba_vga.o -obj-y += mddi_toshiba_wvga_pt.o -obj-y += mddi_toshiba_wvga.o -obj-y += mddi_sharp.o -obj-y += mddi_orise.o -obj-y += mddi_quickvx.o -else -obj-$(CONFIG_FB_MSM_MDDI_PRISM_WVGA) += mddi_prism.o -obj-$(CONFIG_FB_MSM_MDDI_TOSHIBA_COMMON) += mddi_toshiba.o -obj-$(CONFIG_FB_MSM_MDDI_TOSHIBA_COMMON_VGA) += mddi_toshiba_vga.o -obj-$(CONFIG_FB_MSM_MDDI_TOSHIBA_WVGA_PORTRAIT) += mddi_toshiba_wvga_pt.o -obj-$(CONFIG_FB_MSM_MDDI_TOSHIBA_WVGA) += mddi_toshiba_wvga.o -obj-$(CONFIG_FB_MSM_MDDI_SHARP_QVGA_128x128) += mddi_sharp.o -obj-$(CONFIG_FB_MSM_MDDI_ORISE) += mddi_orise.o -obj-$(CONFIG_FB_MSM_MDDI_QUICKVX) += mddi_quickvx.o -endif -ifeq ($(CONFIG_FB_MSM_MIPI_PANEL_DETECT),y) -obj-y += mipi_toshiba_video_wvga_pt.o mipi_toshiba_video_wsvga_pt.o mipi_toshiba_video_wuxga.o -obj-y += mipi_novatek_video_qhd_pt.o mipi_novatek_cmd_qhd_pt.o -obj-y += mipi_orise_video_720p_pt.o mipi_orise_cmd_720p_pt.o -obj-y += mipi_renesas_video_fwvga_pt.o mipi_renesas_cmd_fwvga_pt.o -obj-y += mipi_NT35510_video_wvga_pt.o mipi_NT35510_cmd_wvga_pt.o -obj-y += mipi_truly_tft540960_1_e_video_qhd_pt.o mipi_truly_tft540960_1_e_cmd_qhd_pt.o -obj-y += mipi_chimei_wxga_pt.o -obj-y += mipi_chimei_wuxga.o -obj-y += mipi_truly_video_wvga_pt.o -else -obj-$(CONFIG_FB_MSM_MIPI_TOSHIBA_VIDEO_WVGA_PT) += mipi_toshiba_video_wvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_TOSHIBA_VIDEO_WSVGA_PT) += mipi_toshiba_video_wsvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_TOSHIBA_VIDEO_WUXGA) += mipi_toshiba_video_wuxga.o -obj-$(CONFIG_FB_MSM_MIPI_NOVATEK_VIDEO_QHD_PT) += mipi_novatek_video_qhd_pt.o -obj-$(CONFIG_FB_MSM_MIPI_ORISE_VIDEO_720P_PT) += mipi_orise_video_720p_pt.o -obj-$(CONFIG_FB_MSM_MIPI_ORISE_CMD_720P_PT) += mipi_orise_cmd_720p_pt.o -obj-$(CONFIG_FB_MSM_MIPI_NOVATEK_CMD_QHD_PT) += mipi_novatek_cmd_qhd_pt.o -obj-$(CONFIG_FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT) += mipi_renesas_video_fwvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_RENESAS_CMD_FWVGA_PT) += mipi_renesas_cmd_fwvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_RENESAS_VIDEO_FWVGA_PT) += mipi_renesas_video_fwvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_TRULY_VIDEO_WVGA_PT) += mipi_truly_video_wvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_NT35510_CMD_WVGA_PT) += mipi_NT35510_cmd_wvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_NT35510_VIDEO_WVGA_PT) += mipi_NT35510_video_wvga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_NT35516_CMD_QHD_PT) += mipi_truly_tft540960_1_e_cmd_qhd_pt.o -obj-$(CONFIG_FB_MSM_MIPI_NT35516_VIDEO_QHD_PT) += mipi_truly_tft540960_1_e_video_qhd_pt.o -obj-$(CONFIG_FB_MSM_MIPI_SIMULATOR_VIDEO) += mipi_simulator_video.o -obj-$(CONFIG_FB_MSM_MIPI_CHIMEI_WXGA) += mipi_chimei_wxga_pt.o -obj-$(CONFIG_FB_MSM_MIPI_CHIMEI_WUXGA) += mipi_chimei_wuxga.o -endif -obj-$(CONFIG_FB_MSM_LCDC_PANEL) += lcdc_panel.o -obj-$(CONFIG_FB_MSM_LCDC_PRISM_WVGA) += lcdc_prism.o -obj-$(CONFIG_FB_MSM_LCDC_SAMSUNG_WSVGA) += lcdc_samsung_wsvga.o -obj-$(CONFIG_FB_MSM_LCDC_CHIMEI_WXGA) += lcdc_chimei_wxga.o -obj-$(CONFIG_FB_MSM_LCDC_NT35582_WVGA) += lcdc_nt35582_wvga.o -obj-$(CONFIG_FB_MSM_LCDC_EXTERNAL_WXGA) += lcdc_external.o -obj-$(CONFIG_FB_MSM_HDMI_SII_EXTERNAL_720P) += hdmi_sii9022.o -obj-$(CONFIG_FB_MSM_LCDC_GORDON_VGA) += lcdc_gordon.o -obj-$(CONFIG_FB_MSM_LCDC_WXGA) += lcdc_wxga.o -obj-$(CONFIG_FB_MSM_LCDC_TOSHIBA_WVGA_PT) += lcdc_toshiba_wvga_pt.o -obj-$(CONFIG_FB_MSM_LCDC_TOSHIBA_FWVGA_PT) += lcdc_toshiba_fwvga_pt.o -obj-$(CONFIG_FB_MSM_LCDC_SHARP_WVGA_PT) += lcdc_sharp_wvga_pt.o -obj-$(CONFIG_FB_MSM_LCDC_AUO_WVGA) += lcdc_auo_wvga.o -obj-$(CONFIG_FB_MSM_LCDC_SAMSUNG_OLED_PT) += lcdc_samsung_oled_pt.o -obj-$(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) += adv7520.o -obj-$(CONFIG_FB_MSM_LCDC_ST15_WXGA) += lcdc_st15.o -obj-$(CONFIG_FB_MSM_LVDS_CHIMEI_WXGA) += lvds_chimei_wxga.o -obj-$(CONFIG_FB_MSM_LVDS_FRC_FHD) += lvds_frc_fhd.o -obj-$(CONFIG_FB_MSM_HDMI_MSM_PANEL) += hdmi_msm.o -obj-$(CONFIG_FB_MSM_EXT_INTERFACE_COMMON) += external_common.o -obj-$(CONFIG_FB_MSM_LCDC_TRULY_HVGA_IPS3P2335) += lcdc_truly_ips3p2335.o - -obj-$(CONFIG_FB_MSM_TVOUT) += tvout_msm.o ccflags-y := -I$(src)/mhl obj-$(CONFIG_FB_MSM_HDMI_MHL_8334) += mhl-8334.o -mhl-8334-objs += mhl/mhl_8334.o -mhl-8334-objs += mhl/mhl_i2c_utils.o -obj-$(CONFIG_FB_MSM_EXTMDDI_SVGA) += mddi_ext_lcd.o -obj-$(CONFIG_FB_MSM_WRITEBACK_MSM_PANEL) += mdp4_wfd_writeback_panel.o -obj-$(CONFIG_FB_MSM_WRITEBACK_MSM_PANEL) += mdp4_wfd_writeback.o -obj-$(CONFIG_FB_MSM_WRITEBACK_MSM_PANEL) += mdp4_overlay_writeback.o else -obj-$(CONFIG_FB_MSM_EBI2) += ebi2_host.o -obj-$(CONFIG_FB_MSM_EBI2) += ebi2_lcd.o -obj-y += msm_fb_panel.o -obj-$(CONFIG_FB_MSM_EBI2_EPSON_S1D_QVGA_PANEL) += ebi2_epson_s1d_qvga.o endif endif diff --git a/drivers/video/msm/adv7520.c b/drivers/video/msm/adv7520.c deleted file mode 100644 index 2ac22de838a5d3eb7ca6f6b589a557553cc3cccb..0000000000000000000000000000000000000000 --- a/drivers/video/msm/adv7520.c +++ /dev/null @@ -1,1035 +0,0 @@ -/* Copyright (c) 2010,2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include "msm_fb.h" - -#define DEBUG -#define DEV_DBG_PREFIX "HDMI: " - -#include "external_common.h" - -/* #define PORT_DEBUG */ -/* #define TESTING_FORCE_480p */ - -#define HPD_DUTY_CYCLE 4 /*secs*/ - -static struct external_common_state_type hdmi_common; - -static struct i2c_client *hclient; -static struct clk *tv_enc_clk; - -static bool chip_power_on = FALSE; /* For chip power on/off */ -static bool enable_5v_on = FALSE; -static bool hpd_power_on = FALSE; -static atomic_t comm_power_on; /* For dtv power on/off (I2C) */ -static int suspend_count; - -static u8 reg[256]; /* HDMI panel registers */ - -struct hdmi_data { - struct msm_hdmi_platform_data *pd; - struct work_struct isr_work; -}; -static struct hdmi_data *dd; -static struct work_struct hpd_timer_work; - -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT -static struct work_struct hdcp_handle_work; -static int hdcp_activating; -static DEFINE_MUTEX(hdcp_state_mutex); -static int has_hdcp_hw_support = true; -#endif - -static struct timer_list hpd_timer; -static struct timer_list hpd_duty_timer; -static struct work_struct hpd_duty_work; -static unsigned int monitor_sense; -static boolean hpd_cable_chg_detected; - -static struct pm_qos_request pm_qos_req; - -/* Change HDMI state */ -static void change_hdmi_state(int online) -{ - if (!external_common_state) - return; - - mutex_lock(&external_common_state_hpd_mutex); - external_common_state->hpd_state = online; - mutex_unlock(&external_common_state_hpd_mutex); - - if (!external_common_state->uevent_kobj) - return; - - if (online) { - kobject_uevent(external_common_state->uevent_kobj, - KOBJ_ONLINE); - switch_set_state(&external_common_state->sdev, 1); - } else { - kobject_uevent(external_common_state->uevent_kobj, - KOBJ_OFFLINE); - switch_set_state(&external_common_state->sdev, 0); - } - DEV_INFO("adv7520_uevent: %d [suspend# %d]\n", online, suspend_count); -} - - -/* - * Read a value from a register on ADV7520 device - * If sucessfull returns value read , otherwise error. - */ -static u8 adv7520_read_reg(struct i2c_client *client, u8 reg) -{ - int err; - struct i2c_msg msg[2]; - u8 reg_buf[] = { reg }; - u8 data_buf[] = { 0 }; - - if (!client->adapter) - return -ENODEV; - if (!atomic_read(&comm_power_on)) { - DEV_WARN("%s: WARN: missing GPIO power\n", __func__); - return -ENODEV; - } - - msg[0].addr = client->addr; - msg[0].flags = 0; - msg[0].len = 1; - msg[0].buf = reg_buf; - - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].len = 1; - msg[1].buf = data_buf; - - err = i2c_transfer(client->adapter, msg, 2); - - if (err < 0) { - DEV_INFO("%s: I2C err: %d\n", __func__, err); - return err; - } - -#ifdef PORT_DEBUG - DEV_INFO("HDMI[%02x] [R] %02x\n", reg, data); -#endif - return *data_buf; -} - -/* - * Write a value to a register on adv7520 device. - * Returns zero if successful, or non-zero otherwise. - */ -static int adv7520_write_reg(struct i2c_client *client, u8 reg, u8 val) -{ - int err; - struct i2c_msg msg[1]; - unsigned char data[2]; - - if (!client->adapter) - return -ENODEV; - if (!atomic_read(&comm_power_on)) { - DEV_WARN("%s: WARN: missing GPIO power\n", __func__); - return -ENODEV; - } - - msg->addr = client->addr; - msg->flags = 0; - msg->len = 2; - msg->buf = data; - data[0] = reg; - data[1] = val; - - err = i2c_transfer(client->adapter, msg, 1); - if (err >= 0) - return 0; -#ifdef PORT_DEBUG - DEV_INFO("HDMI[%02x] [W] %02x [%d]\n", reg, val, err); -#endif - return err; -} - -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT -static void adv7520_close_hdcp_link(void) -{ - if (!external_common_state->hdcp_active && !hdcp_activating) - return; - - DEV_INFO("HDCP: Close link\n"); - - reg[0xD5] = adv7520_read_reg(hclient, 0xD5); - reg[0xD5] &= 0xFE; - adv7520_write_reg(hclient, 0xD5, (u8)reg[0xD5]); - - reg[0x16] = adv7520_read_reg(hclient, 0x16); - reg[0x16] &= 0xFE; - adv7520_write_reg(hclient, 0x16, (u8)reg[0x16]); - - /* UnMute Audio */ - adv7520_write_reg(hclient, 0x0C, (u8)0x84); - - external_common_state->hdcp_active = FALSE; - mutex_lock(&hdcp_state_mutex); - hdcp_activating = FALSE; - mutex_unlock(&hdcp_state_mutex); -} - -static void adv7520_comm_power(int on, int show); -static void adv7520_hdcp_enable(struct work_struct *work) -{ - DEV_INFO("HDCP: Start reg[0xaf]=%02x (mute audio)\n", reg[0xaf]); - - adv7520_comm_power(1, 1); - - /* Mute Audio */ - adv7520_write_reg(hclient, 0x0C, (u8)0xC3); - - msleep(200); - /* Wait for BKSV ready interrupt */ - /* Read BKSV's keys from HDTV */ - reg[0xBF] = adv7520_read_reg(hclient, 0xBF); - reg[0xC0] = adv7520_read_reg(hclient, 0xC0); - reg[0xC1] = adv7520_read_reg(hclient, 0xC1); - reg[0xC2] = adv7520_read_reg(hclient, 0xC2); - reg[0xc3] = adv7520_read_reg(hclient, 0xC3); - - DEV_DBG("HDCP: BKSV={%02x,%02x,%02x,%02x,%02x}\n", reg[0xbf], reg[0xc0], - reg[0xc1], reg[0xc2], reg[0xc3]); - - /* Is SINK repeater */ - reg[0xBE] = adv7520_read_reg(hclient, 0xBE); - if (~(reg[0xBE] & 0x40)) { - ; /* compare with revocation list */ - /* Check 20 1's and 20 zero's */ - } else { - /* Don't implement HDCP if sink as a repeater */ - adv7520_write_reg(hclient, 0x0C, (u8)0x84); - mutex_lock(&hdcp_state_mutex); - hdcp_activating = FALSE; - mutex_unlock(&hdcp_state_mutex); - DEV_WARN("HDCP: Sink Repeater (%02x), (unmute audio)\n", - reg[0xbe]); - - adv7520_comm_power(0, 1); - return; - } - - msleep(200); - reg[0xB8] = adv7520_read_reg(hclient, 0xB8); - DEV_INFO("HDCP: Status reg[0xB8] is %02x\n", reg[0xb8]); - if (reg[0xb8] & 0x40) { - /* UnMute Audio */ - adv7520_write_reg(hclient, 0x0C, (u8)0x84); - DEV_INFO("HDCP: A/V content Encrypted (unmute audio)\n"); - external_common_state->hdcp_active = TRUE; - } - adv7520_comm_power(0, 1); - - mutex_lock(&hdcp_state_mutex); - hdcp_activating = FALSE; - mutex_unlock(&hdcp_state_mutex); -} -#endif - -static int adv7520_read_edid_block(int block, uint8 *edid_buf) -{ - u8 r = 0; - int ret; - struct i2c_msg msg[] = { - { .addr = reg[0x43] >> 1, - .flags = 0, - .len = 1, - .buf = &r }, - { .addr = reg[0x43] >> 1, - .flags = I2C_M_RD, - .len = 0x100, - .buf = edid_buf } }; - - if (block > 0) - return 0; - ret = i2c_transfer(hclient->adapter, msg, 2); - DEV_DBG("EDID block: addr=%02x, ret=%d\n", reg[0x43] >> 1, ret); - return (ret < 2) ? -ENODEV : 0; -} - -static void adv7520_read_edid(void) -{ - external_common_state->read_edid_block = adv7520_read_edid_block; - if (hdmi_common_read_edid()) { - u8 timeout; - DEV_INFO("%s: retry\n", __func__); - adv7520_write_reg(hclient, 0xc9, 0x13); - msleep(500); - timeout = (adv7520_read_reg(hclient, 0x96) & (1 << 2)); - if (timeout) { - hdmi_common_read_edid(); - } - } -} - -static void adv7520_chip_on(void) -{ - if (!chip_power_on) { - /* Get the current register holding the power bit. */ - unsigned long reg0xaf = adv7520_read_reg(hclient, 0xaf); - - dd->pd->core_power(1, 1); - - /* Set the HDMI select bit. */ - set_bit(1, ®0xaf); - DEV_INFO("%s: turn on chip power\n", __func__); - adv7520_write_reg(hclient, 0x41, 0x10); - adv7520_write_reg(hclient, 0xaf, (u8)reg0xaf); - chip_power_on = TRUE; - } else - DEV_INFO("%s: chip already has power\n", __func__); -} - -static void adv7520_chip_off(void) -{ - if (chip_power_on) { -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - if (has_hdcp_hw_support) - adv7520_close_hdcp_link(); -#endif - - DEV_INFO("%s: turn off chip power\n", __func__); - adv7520_write_reg(hclient, 0x41, 0x50); - dd->pd->core_power(0, 1); - chip_power_on = FALSE; - } else - DEV_INFO("%s: chip is already off\n", __func__); - - monitor_sense = 0; - hpd_cable_chg_detected = FALSE; - - if (enable_5v_on) { - dd->pd->enable_5v(0); - enable_5v_on = FALSE; - } -} - -/* Power ON/OFF ADV7520 chip */ -static void adv7520_isr_w(struct work_struct *work); -static void adv7520_comm_power(int on, int show) -{ - if (!on) - atomic_dec(&comm_power_on); - dd->pd->comm_power(on, 0/*show*/); - if (on) - atomic_inc(&comm_power_on); -} - -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT -static void adv7520_start_hdcp(void); -#endif -static int adv7520_power_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - - clk_prepare_enable(tv_enc_clk); - external_common_state->dev = &pdev->dev; - if (mfd != NULL) { - DEV_INFO("adv7520_power: ON (%dx%d %d)\n", - mfd->var_xres, mfd->var_yres, mfd->var_pixclock); - hdmi_common_get_video_format_from_drv_data(mfd); - } - - adv7520_comm_power(1, 1); - /* Check if HPD is signaled */ - if (adv7520_read_reg(hclient, 0x42) & (1 << 6)) { - DEV_INFO("power_on: cable detected\n"); - monitor_sense = adv7520_read_reg(hclient, 0xC6); -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - if (has_hdcp_hw_support) { - if (!hdcp_activating) - adv7520_start_hdcp(); - } -#endif - } else - DEV_INFO("power_on: cable NOT detected\n"); - adv7520_comm_power(0, 1); - pm_qos_update_request(&pm_qos_req, msm_cpuidle_get_deep_idle_latency()); - - return 0; -} - -static int adv7520_power_off(struct platform_device *pdev) -{ - DEV_INFO("power_off\n"); - adv7520_comm_power(1, 1); - adv7520_chip_off(); - pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE); - adv7520_comm_power(0, 1); - clk_disable_unprepare(tv_enc_clk); - return 0; -} - - -/* AV7520 chip specific initialization */ -static void adv7520_chip_init(void) -{ - /* Initialize the variables used to read/write the ADV7520 chip. */ - memset(®, 0xff, sizeof(reg)); - - /* Get the values from the "Fixed Registers That Must Be Set". */ - reg[0x98] = adv7520_read_reg(hclient, 0x98); - reg[0x9c] = adv7520_read_reg(hclient, 0x9c); - reg[0x9d] = adv7520_read_reg(hclient, 0x9d); - reg[0xa2] = adv7520_read_reg(hclient, 0xa2); - reg[0xa3] = adv7520_read_reg(hclient, 0xa3); - reg[0xde] = adv7520_read_reg(hclient, 0xde); - - /* Get the "HDMI/DVI Selection" register. */ - reg[0xaf] = adv7520_read_reg(hclient, 0xaf); - - /* Read Packet Memory I2C Address */ - reg[0x45] = adv7520_read_reg(hclient, 0x45); - - /* Hard coded values provided by ADV7520 data sheet. */ - reg[0x98] = 0x03; - reg[0x9c] = 0x38; - reg[0x9d] = 0x61; - reg[0xa2] = 0x94; - reg[0xa3] = 0x94; - reg[0xde] = 0x88; - - /* Set the HDMI select bit. */ - reg[0xaf] |= 0x16; - - /* Set the audio related registers. */ - reg[0x01] = 0x00; - reg[0x02] = 0x2d; - reg[0x03] = 0x80; - reg[0x0a] = 0x4d; - reg[0x0b] = 0x0e; - reg[0x0c] = 0x84; - reg[0x0d] = 0x10; - reg[0x12] = 0x00; - reg[0x14] = 0x00; - reg[0x15] = 0x20; - reg[0x44] = 0x79; - reg[0x73] = 0x01; - reg[0x76] = 0x00; - - /* Set 720p display related registers */ - reg[0x16] = 0x00; - - reg[0x18] = 0x46; - reg[0x55] = 0x00; - reg[0x3c] = 0x04; - - /* Set Interrupt Mask register for HPD/HDCP */ - reg[0x94] = 0xC0; -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - if (has_hdcp_hw_support) - reg[0x95] = 0xC0; - else - reg[0x95] = 0x00; -#else - reg[0x95] = 0x00; -#endif - adv7520_write_reg(hclient, 0x94, reg[0x94]); - adv7520_write_reg(hclient, 0x95, reg[0x95]); - - /* Set Packet Memory I2C Address */ - reg[0x45] = 0x74; - - /* Set the values from the "Fixed Registers That Must Be Set". */ - adv7520_write_reg(hclient, 0x98, reg[0x98]); - adv7520_write_reg(hclient, 0x9c, reg[0x9c]); - adv7520_write_reg(hclient, 0x9d, reg[0x9d]); - adv7520_write_reg(hclient, 0xa2, reg[0xa2]); - adv7520_write_reg(hclient, 0xa3, reg[0xa3]); - adv7520_write_reg(hclient, 0xde, reg[0xde]); - - /* Set the "HDMI/DVI Selection" register. */ - adv7520_write_reg(hclient, 0xaf, reg[0xaf]); - - /* Set EDID Monitor address */ - reg[0x43] = 0x7E; - adv7520_write_reg(hclient, 0x43, reg[0x43]); - - /* Enable the i2s audio input. */ - adv7520_write_reg(hclient, 0x01, reg[0x01]); - adv7520_write_reg(hclient, 0x02, reg[0x02]); - adv7520_write_reg(hclient, 0x03, reg[0x03]); - adv7520_write_reg(hclient, 0x0a, reg[0x0a]); - adv7520_write_reg(hclient, 0x0b, reg[0x0b]); - adv7520_write_reg(hclient, 0x0c, reg[0x0c]); - adv7520_write_reg(hclient, 0x0d, reg[0x0d]); - adv7520_write_reg(hclient, 0x12, reg[0x12]); - adv7520_write_reg(hclient, 0x14, reg[0x14]); - adv7520_write_reg(hclient, 0x15, reg[0x15]); - adv7520_write_reg(hclient, 0x44, reg[0x44]); - adv7520_write_reg(hclient, 0x73, reg[0x73]); - adv7520_write_reg(hclient, 0x76, reg[0x76]); - - /* Enable 720p display */ - adv7520_write_reg(hclient, 0x16, reg[0x16]); - adv7520_write_reg(hclient, 0x18, reg[0x18]); - adv7520_write_reg(hclient, 0x55, reg[0x55]); - adv7520_write_reg(hclient, 0x3c, reg[0x3c]); - - /* Set Packet Memory address to avoid conflict - with Bosch Accelerometer */ - adv7520_write_reg(hclient, 0x45, reg[0x45]); - - /* Ensure chip is in low-power state */ - adv7520_write_reg(hclient, 0x41, 0x50); -} - -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT -static void adv7520_start_hdcp(void) -{ - mutex_lock(&hdcp_state_mutex); - if (hdcp_activating) { - DEV_WARN("adv7520_timer: HDCP already" - " activating, skipping\n"); - mutex_unlock(&hdcp_state_mutex); - return; - } - hdcp_activating = TRUE; - mutex_unlock(&hdcp_state_mutex); - - del_timer(&hpd_duty_timer); - - adv7520_comm_power(1, 1); - - if (!enable_5v_on) { - dd->pd->enable_5v(1); - enable_5v_on = TRUE; - adv7520_chip_on(); - } - - /* request for HDCP */ - reg[0xaf] = adv7520_read_reg(hclient, 0xaf); - reg[0xaf] |= 0x90; - adv7520_write_reg(hclient, 0xaf, reg[0xaf]); - reg[0xaf] = adv7520_read_reg(hclient, 0xaf); - - reg[0xba] = adv7520_read_reg(hclient, 0xba); - reg[0xba] |= 0x10; - adv7520_write_reg(hclient, 0xba, reg[0xba]); - reg[0xba] = adv7520_read_reg(hclient, 0xba); - adv7520_comm_power(0, 1); - - DEV_INFO("HDCP: reg[0xaf]=0x%02x, reg[0xba]=0x%02x, waiting for BKSV\n", - reg[0xaf], reg[0xba]); - - /* will check for HDCP Error or BKSV ready */ - mod_timer(&hpd_duty_timer, jiffies + HZ/2); -} -#endif - -static void adv7520_hpd_timer_w(struct work_struct *work) -{ - if (!external_common_state->hpd_feature_on) { - DEV_INFO("adv7520_timer: skipping, feature off\n"); - return; - } - - if ((monitor_sense & 0x4) && !external_common_state->hpd_state) { - int timeout; - DEV_DBG("adv7520_timer: Cable Detected\n"); - adv7520_comm_power(1, 1); - adv7520_chip_on(); - - if (hpd_cable_chg_detected) { - hpd_cable_chg_detected = FALSE; - /* Ensure 5V to read EDID */ - if (!enable_5v_on) { - dd->pd->enable_5v(1); - enable_5v_on = TRUE; - } - msleep(500); - timeout = (adv7520_read_reg(hclient, 0x96) & (1 << 2)); - if (timeout) { - DEV_DBG("adv7520_timer: EDID-Ready..\n"); - adv7520_read_edid(); - } else - DEV_DBG("adv7520_timer: EDID TIMEOUT (C9=%02x)" - "\n", adv7520_read_reg(hclient, 0xC9)); - } -#ifdef TESTING_FORCE_480p - external_common_state->disp_mode_list.num_of_elements = 1; - external_common_state->disp_mode_list.disp_mode_list[0] = - HDMI_VFRMT_720x480p60_16_9; -#endif - adv7520_comm_power(0, 1); -#ifndef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - /* HDMI_5V_EN not needed anymore */ - if (enable_5v_on) { - DEV_DBG("adv7520_timer: EDID done, no HDCP, 5V not " - "needed anymore\n"); - dd->pd->enable_5v(0); - enable_5v_on = FALSE; - } -#endif - change_hdmi_state(1); - } else if (external_common_state->hpd_state) { - adv7520_comm_power(1, 1); - adv7520_chip_off(); - adv7520_comm_power(0, 1); - DEV_DBG("adv7520_timer: Cable Removed\n"); - change_hdmi_state(0); - } -} - -static void adv7520_hpd_timer_f(unsigned long data) -{ - schedule_work(&hpd_timer_work); -} - -static void adv7520_isr_w(struct work_struct *work) -{ - static int state_count; - static u8 last_reg0x96; - u8 reg0xc8; - u8 reg0x96; -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - static u8 last_reg0x97; - u8 reg0x97 = 0; -#endif - if (!external_common_state->hpd_feature_on) { - DEV_DBG("adv7520_irq: skipping, hpd off\n"); - return; - } - - adv7520_comm_power(1, 1); - reg0x96 = adv7520_read_reg(hclient, 0x96); -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - if (has_hdcp_hw_support) { - reg0x97 = adv7520_read_reg(hclient, 0x97); - /* Clearing the Interrupts */ - adv7520_write_reg(hclient, 0x97, reg0x97); - } -#endif - /* Clearing the Interrupts */ - adv7520_write_reg(hclient, 0x96, reg0x96); - - if ((reg0x96 == 0xC0) || (reg0x96 & 0x40)) { -#ifdef DEBUG - unsigned int hpd_state = adv7520_read_reg(hclient, 0x42); -#endif - monitor_sense = adv7520_read_reg(hclient, 0xC6); - DEV_DBG("adv7520_irq: reg[0x42]=%02x && reg[0xC6]=%02x\n", - hpd_state, monitor_sense); - - if (!enable_5v_on) { - dd->pd->enable_5v(1); - enable_5v_on = TRUE; - } - if (!hpd_power_on) { - dd->pd->core_power(1, 1); - hpd_power_on = TRUE; - } - - /* Timer for catching interrupt debouning */ - DEV_DBG("adv7520_irq: Timer in .5sec\n"); - hpd_cable_chg_detected = TRUE; - mod_timer(&hpd_timer, jiffies + HZ/2); - } -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - if (has_hdcp_hw_support) { - if (hdcp_activating) { - /* HDCP controller error Interrupt */ - if (reg0x97 & 0x80) { - DEV_ERR("adv7520_irq: HDCP_ERROR\n"); - state_count = 0; - adv7520_close_hdcp_link(); - /* BKSV Ready interrupts */ - } else if (reg0x97 & 0x40) { - DEV_INFO("adv7520_irq: BKSV keys ready, Begin" - " HDCP encryption\n"); - state_count = 0; - schedule_work(&hdcp_handle_work); - } else if (++state_count > 2 && (monitor_sense & 0x4)) { - DEV_INFO("adv7520_irq: Still waiting for BKSV," - "restart HDCP\n"); - hdcp_activating = FALSE; - state_count = 0; - adv7520_chip_off(); - adv7520_start_hdcp(); - } - reg0xc8 = adv7520_read_reg(hclient, 0xc8); - DEV_INFO("adv7520_irq: DDC controller reg[0xC8]=0x%02x," - "state_count=%d, monitor_sense=%x\n", - reg0xc8, state_count, monitor_sense); - } else if (!external_common_state->hdcp_active - && (monitor_sense & 0x4)) { - DEV_INFO("adv7520_irq: start HDCP with" - " monitor sense\n"); - state_count = 0; - adv7520_start_hdcp(); - } else - state_count = 0; - if (last_reg0x97 != reg0x97 || last_reg0x96 != reg0x96) - DEV_DBG("adv7520_irq: reg[0x96]=%02x " - "reg[0x97]=%02x: HDCP: %d\n", reg0x96, reg0x97, - external_common_state->hdcp_active); - last_reg0x97 = reg0x97; - } else { - if (last_reg0x96 != reg0x96) - DEV_DBG("adv7520_irq: reg[0x96]=%02x\n", reg0x96); - } -#else - if (last_reg0x96 != reg0x96) - DEV_DBG("adv7520_irq: reg[0x96]=%02x\n", reg0x96); -#endif - last_reg0x96 = reg0x96; - adv7520_comm_power(0, 1); -} - -static void adv7520_hpd_duty_work(struct work_struct *work) -{ - if (!external_common_state->hpd_feature_on) { - DEV_WARN("%s: hpd feature is off, skipping\n", __func__); - return; - } - - dd->pd->core_power(1, 0); - msleep(10); - adv7520_isr_w(NULL); - dd->pd->core_power(0, 0); -} - -static void adv7520_hpd_duty_timer_f(unsigned long data) -{ - if (!external_common_state->hpd_feature_on) { - DEV_WARN("%s: hpd feature is off, skipping\n", __func__); - return; - } - - mod_timer(&hpd_duty_timer, jiffies + HPD_DUTY_CYCLE*HZ); - schedule_work(&hpd_duty_work); -} - -static const struct i2c_device_id adv7520_id[] = { - { ADV7520_DRV_NAME , 0}, - {} -}; - -static struct msm_fb_panel_data hdmi_panel_data = { - .on = adv7520_power_on, - .off = adv7520_power_off, -}; - -static struct platform_device hdmi_device = { - .name = ADV7520_DRV_NAME , - .id = 2, - .dev = { - .platform_data = &hdmi_panel_data, - } -}; - -static void adv7520_ensure_init(void) -{ - static boolean init_done; - if (!init_done) { - int rc = dd->pd->init_irq(); - if (rc) { - DEV_ERR("adv7520_init: init_irq: %d\n", rc); - return; - } - - init_done = TRUE; - } - DEV_INFO("adv7520_init: chip init\n"); - adv7520_comm_power(1, 1); - adv7520_chip_init(); - adv7520_comm_power(0, 1); -} - -static int adv7520_hpd_feature(int on) -{ - int rc = 0; - - if (!on) { - if (enable_5v_on) { - dd->pd->enable_5v(0); - enable_5v_on = FALSE; - } - if (hpd_power_on) { - dd->pd->core_power(0, 1); - hpd_power_on = FALSE; - } - - DEV_DBG("adv7520_hpd: %d: stop duty timer\n", on); - del_timer(&hpd_timer); - del_timer(&hpd_duty_timer); - external_common_state->hpd_state = 0; - } - - if (on) { - dd->pd->core_power(1, 0); - adv7520_ensure_init(); - - adv7520_comm_power(1, 1); - monitor_sense = adv7520_read_reg(hclient, 0xC6); - DEV_DBG("adv7520_irq: reg[0xC6]=%02x\n", monitor_sense); - adv7520_comm_power(0, 1); - dd->pd->core_power(0, 0); - - if (monitor_sense & 0x4) { - if (!enable_5v_on) { - dd->pd->enable_5v(1); - enable_5v_on = TRUE; - } - if (!hpd_power_on) { - dd->pd->core_power(1, 1); - hpd_power_on = TRUE; - } - - hpd_cable_chg_detected = TRUE; - mod_timer(&hpd_timer, jiffies + HZ/2); - } - - DEV_DBG("adv7520_hpd: %d start duty timer\n", on); - mod_timer(&hpd_duty_timer, jiffies + HZ/100); - } - - DEV_INFO("adv7520_hpd: %d\n", on); - return rc; -} - -static int - adv7520_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - int rc; - struct platform_device *fb_dev; - - dd = kzalloc(sizeof *dd, GFP_KERNEL); - if (!dd) { - rc = -ENOMEM; - goto probe_exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) - return -ENODEV; - - external_common_state->dev = &client->dev; - - /* Init real i2c_client */ - hclient = client; - - i2c_set_clientdata(client, dd); - dd->pd = client->dev.platform_data; - if (!dd->pd) { - rc = -ENODEV; - goto probe_free; - } - - INIT_WORK(&dd->isr_work, adv7520_isr_w); - INIT_WORK(&hpd_timer_work, adv7520_hpd_timer_w); -#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL_HDCP_SUPPORT - if (dd->pd->check_hdcp_hw_support) - has_hdcp_hw_support = dd->pd->check_hdcp_hw_support(); - - if (has_hdcp_hw_support) - INIT_WORK(&hdcp_handle_work, adv7520_hdcp_enable); - else - DEV_INFO("%s: no hdcp hw support.\n", __func__); -#endif - - init_timer(&hpd_timer); - hpd_timer.function = adv7520_hpd_timer_f; - hpd_timer.data = (unsigned long)NULL; - hpd_timer.expires = 0xffffffff; - add_timer(&hpd_timer); - - external_common_state->hpd_feature = adv7520_hpd_feature; - DEV_INFO("adv7520_probe: HPD detection on request\n"); - init_timer(&hpd_duty_timer); - hpd_duty_timer.function = adv7520_hpd_duty_timer_f; - hpd_duty_timer.data = (unsigned long)NULL; - hpd_duty_timer.expires = 0xffffffff; - add_timer(&hpd_duty_timer); - INIT_WORK(&hpd_duty_work, adv7520_hpd_duty_work); - DEV_INFO("adv7520_probe: HPD detection ON (duty)\n"); - - fb_dev = msm_fb_add_device(&hdmi_device); - - if (fb_dev) { - rc = external_common_state_create(fb_dev); - if (rc) - goto probe_free; - } else - DEV_ERR("adv7520_probe: failed to add fb device\n"); - - if (hdmi_prim_display) - external_common_state->sdev.name = "hdmi_as_primary"; - else - external_common_state->sdev.name = "hdmi"; - - if (switch_dev_register(&external_common_state->sdev) < 0) - DEV_ERR("Hdmi switch registration failed\n"); - - return 0; - -probe_free: - kfree(dd); - dd = NULL; -probe_exit: - return rc; - -} - -static int adv7520_remove(struct i2c_client *client) -{ - if (!client->adapter) { - DEV_ERR("%s: No HDMI Device\n", __func__); - return -ENODEV; - } - switch_dev_unregister(&external_common_state->sdev); - pm_qos_remove_request(&pm_qos_req); - kfree(dd); - dd = NULL; - return 0; -} - -#ifdef CONFIG_SUSPEND -static int adv7520_i2c_suspend(struct device *dev) -{ - DEV_INFO("%s\n", __func__); - - ++suspend_count; - - if (external_common_state->hpd_feature_on) { - DEV_DBG("%s: stop duty timer\n", __func__); - del_timer(&hpd_duty_timer); - del_timer(&hpd_timer); - } - - /* Turn off LDO8 and go into low-power state */ - if (chip_power_on) { - DEV_DBG("%s: turn off power\n", __func__); - adv7520_comm_power(1, 1); - adv7520_write_reg(hclient, 0x41, 0x50); - adv7520_comm_power(0, 1); - dd->pd->core_power(0, 1); - } - - return 0; -} - -static int adv7520_i2c_resume(struct device *dev) -{ - DEV_INFO("%s\n", __func__); - - /* Turn on LDO8 and go into normal-power state */ - if (chip_power_on) { - DEV_DBG("%s: turn on power\n", __func__); - dd->pd->core_power(1, 1); - adv7520_comm_power(1, 1); - adv7520_write_reg(hclient, 0x41, 0x10); - adv7520_comm_power(0, 1); - } - - if (external_common_state->hpd_feature_on) { - DEV_DBG("%s: start duty timer\n", __func__); - mod_timer(&hpd_duty_timer, jiffies + HPD_DUTY_CYCLE*HZ); - } - - return 0; -} -#else -#define adv7520_i2c_suspend NULL -#define adv7520_i2c_resume NULL -#endif - -static const struct dev_pm_ops adv7520_device_pm_ops = { - .suspend = adv7520_i2c_suspend, - .resume = adv7520_i2c_resume, -}; - -static struct i2c_driver hdmi_i2c_driver = { - .driver = { - .name = ADV7520_DRV_NAME, - .owner = THIS_MODULE, - .pm = &adv7520_device_pm_ops, - }, - .probe = adv7520_probe, - .id_table = adv7520_id, - .remove = adv7520_remove, -}; - -static int __init adv7520_init(void) -{ - int rc; - - pr_info("%s\n", __func__); - external_common_state = &hdmi_common; - external_common_state->video_resolution = HDMI_VFRMT_1280x720p60_16_9; - - tv_enc_clk = clk_get(NULL, "tv_enc_clk"); - if (IS_ERR(tv_enc_clk)) { - printk(KERN_ERR "error: can't get tv_enc_clk!\n"); - return IS_ERR(tv_enc_clk); - } - - HDMI_SETUP_LUT(640x480p60_4_3); /* 25.20MHz */ - HDMI_SETUP_LUT(720x480p60_16_9); /* 27.03MHz */ - HDMI_SETUP_LUT(1280x720p60_16_9); /* 74.25MHz */ - - HDMI_SETUP_LUT(720x576p50_16_9); /* 27.00MHz */ - HDMI_SETUP_LUT(1280x720p50_16_9); /* 74.25MHz */ - - hdmi_common_init_panel_info(&hdmi_panel_data.panel_info); - - rc = i2c_add_driver(&hdmi_i2c_driver); - if (rc) { - pr_err("hdmi_init FAILED: i2c_add_driver rc=%d\n", rc); - goto init_exit; - } - - if (machine_is_msm7x30_surf() || machine_is_msm8x55_surf()) { - short *hdtv_mux = (short *)ioremap(0x8e000170 , 0x100); - *hdtv_mux++ = 0x020b; - *hdtv_mux = 0x8000; - iounmap(hdtv_mux); - } - pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); - - return 0; - -init_exit: - if (tv_enc_clk) - clk_put(tv_enc_clk); - return rc; -} - -static void __exit adv7520_exit(void) -{ - i2c_del_driver(&hdmi_i2c_driver); -} - -module_init(adv7520_init); -module_exit(adv7520_exit); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("0.1"); -MODULE_AUTHOR("Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("ADV7520 HDMI driver"); diff --git a/drivers/video/msm/ebi2_epson_s1d_qvga.c b/drivers/video/msm/ebi2_epson_s1d_qvga.c deleted file mode 100644 index ba4740078c6ee3d9d757f6f04d5a680f8434df06..0000000000000000000000000000000000000000 --- a/drivers/video/msm/ebi2_epson_s1d_qvga.c +++ /dev/null @@ -1,371 +0,0 @@ -/* Copyright (c) 2012-2013, 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 "msm_fb.h" - -#include -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" - -#include - -#include -#include - -#define CMD_NOP_C 0x00 -#define CMD_SOFT_RESET_C 0x99 -#define CMD_DISPLAY_ON_C 0xAF -#define CMD_DISPLAY_OFF_C 0xAE -#define CMD_SET_DISPLAY_C 0xCA -#define CMD_SET_DISPLAY_TIMING_C 0xA1 -#define CMD_SET_DATA_C 0xBC -#define CMD_SET_START_ADDRESS_C 0x15 -#define CMD_SET_END_ADDRESS_C 0x75 -#define CMD_RAM_WRITE_C 0x5C -#define CMD_RAM_READ_C 0x5D -#define CMD_SET_AREA_SCROLLING_C 0xAA -#define CMD_SET_DISPLAY_START_LINE_C 0xAB -#define CMD_PARTIAL_DISPLAY_IN_C 0xA8 -#define CMD_PARTIAL_DISPLAY_OUT_C 0xA9 -#define CMD_SET_DISPLAY_DATA_INTERFACE_C 0x31 -#define CMD_SET_DISPLAY_COLOR_MODE_C 0x8B -#define CMD_SELECT_MTP_ROM_MODE_C 0x65 -#define CMD_MTP_ROM_MODE_IN_C 0x67 -#define CMD_MTP_ROM_MODE_OUT_C 0x68 -#define CMD_MTP_ROM_OPERATION_IN_C 0x69 -#define CMD_MTP_ROM_OPERATION_OUT_C 0x70 -#define CMD_GATE_LINE_SCAN_MODE_C 0x6F -#define CMD_SET_AC_OPERATION_DRIVE_C 0x8C -#define CMD_SET_ELECTRONIC_CONTROL_C 0x20 -#define CMD_SET_POSITIVE_CORRECTION_CHARS_C 0x22 -#define CMD_SET_NEGATIVE_CORRECTION_CHARS_C 0x25 -#define CMD_SET_POWER_CONTROL_C 0x21 -#define CMD_SET_PARTIAL_POWER_CONTROL_C 0x23 -#define CMD_SET_8_COLOR_CONTROL_C 0x24 -#define CMD_SLEEP_IN_C 0x95 -#define CMD_SLEEP_OUT_C 0x94 -#define CMD_VDD_OFF_C 0x97 -#define CMD_VDD_ON_C 0x96 -#define CMD_STOP_OSCILLATION_C 0x93 -#define CMD_START_OSCILLATION_C 0x92 -#define CMD_TEST_SOURCE_C 0xFD -#define CMD_TEST_FUSE_C 0xFE -#define CMD_TEST_C 0xFF -#define CMD_STATUS_READ_C 0xE8 -#define CMD_REVISION_READ_C 0xE9 - -#define PANEL_WIDTH 240 -#define PANEL_HEIGHT 320 -#define ACTIVE_WIN_WIDTH PANEL_WIDTH -#define ACTIVE_WIN_HEIGHT PANEL_HEIGHT - -#define ACTIVE_WIN_H_START 0 -#define ACTIVE_WIN_V_START 0 - -#define DISP_CMD_OUT(cmd) outpw(DISP_CMD_PORT, (cmd << 1)); -#define DISP_DATA_OUT(data) outpw(DISP_DATA_PORT, (data << 1)); -#define DISP_DATA_IN() inpw(DISP_DATA_PORT); - -static void *DISP_CMD_PORT; -static void *DISP_DATA_PORT; -static boolean disp_initialized; -static boolean display_on; -static struct msm_panel_common_pdata *ebi2_epson_pdata; - -static void epson_s1d_disp_init(struct platform_device *pdev); -static int epson_s1d_disp_off(struct platform_device *pdev); -static int epson_s1d_disp_on(struct platform_device *pdev); -static void epson_s1d_disp_set_rect(int x, int y, int xres, int yres); - -static void epson_s1d_disp_set_rect(int x, int y, int xres, int yres) -{ - int right, bottom; - - if (!disp_initialized) - return; - - right = x + xres - 1; - bottom = y + yres - 1; - - x += ACTIVE_WIN_H_START; - y += ACTIVE_WIN_V_START; - right += ACTIVE_WIN_H_START; - bottom += ACTIVE_WIN_V_START; - - if ((PANEL_WIDTH > x) && - (PANEL_HEIGHT > y) && - (PANEL_WIDTH > right) && - (PANEL_HEIGHT > bottom)) { - DISP_CMD_OUT(CMD_SET_START_ADDRESS_C); - DISP_DATA_OUT((uint8)x); - DISP_DATA_OUT((uint8)(y>>8)); - DISP_DATA_OUT((uint8)y); - - DISP_CMD_OUT(CMD_SET_END_ADDRESS_C); - DISP_DATA_OUT((uint8)right); - DISP_DATA_OUT((uint8)(bottom>>8)); - DISP_DATA_OUT((uint8)bottom); - DISP_CMD_OUT(CMD_RAM_WRITE_C); - } -} - -static void epson_s1d_disp_init(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - if (disp_initialized) - return; - - mfd = platform_get_drvdata(pdev); - - DISP_CMD_PORT = mfd->cmd_port; - DISP_DATA_PORT = mfd->data_port; - - disp_initialized = TRUE; -} - -static int epson_s1d_disp_off(struct platform_device *pdev) -{ - if (!disp_initialized) - epson_s1d_disp_init(pdev); - - if (display_on) { - DISP_CMD_OUT(CMD_SOFT_RESET_C); - DISP_CMD_OUT(CMD_VDD_OFF_C); - display_on = FALSE; - } - - return 0; -} - -static int epson_s1d_disp_on(struct platform_device *pdev) -{ - int i; - if (!disp_initialized) - epson_s1d_disp_init(pdev); - - if (!display_on) { - /* Enable Vdd regulator */ - DISP_CMD_OUT(CMD_VDD_ON_C); - msleep(20); - - /* Soft Reset before configuring display */ - DISP_CMD_OUT(CMD_SOFT_RESET_C); - msleep(20); - - /* Set display attributes */ - - /* GATESCAN */ - DISP_CMD_OUT(CMD_GATE_LINE_SCAN_MODE_C); - DISP_DATA_OUT(0x0); - - /* DISSET */ - DISP_CMD_OUT(CMD_SET_DISPLAY_C); - DISP_DATA_OUT(0x31); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT((uint8)((PANEL_HEIGHT - 1)>>8)); - DISP_DATA_OUT((uint8)(PANEL_HEIGHT - 1)); - DISP_DATA_OUT(0x03); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x08); - - /* VOLSET */ - DISP_CMD_OUT( - CMD_SET_ELECTRONIC_CONTROL_C); - DISP_DATA_OUT(0x10); - DISP_DATA_OUT(0x80); - DISP_DATA_OUT(0x11); - DISP_DATA_OUT(0x1B); - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x0D); - DISP_DATA_OUT(0x00); - - /* PWRCTL */ - DISP_CMD_OUT(CMD_SET_POWER_CONTROL_C); - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x24); - DISP_DATA_OUT(0x0F); - DISP_DATA_OUT(0xFE); - DISP_DATA_OUT(0x33); - DISP_DATA_OUT(0x31); - DISP_DATA_OUT(0xFF); - DISP_DATA_OUT(0x03); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x77); - DISP_DATA_OUT(0x33); - DISP_DATA_OUT(0x11); - DISP_DATA_OUT(0x44); - DISP_DATA_OUT(0x00); - - /* PPWRCTL */ - DISP_CMD_OUT(CMD_SET_PARTIAL_POWER_CONTROL_C); - DISP_DATA_OUT(0x33); - DISP_DATA_OUT(0xFF); - DISP_DATA_OUT(0x03); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x44); - DISP_DATA_OUT(0x00); - - /* SPLOUT */ - DISP_CMD_OUT(CMD_SLEEP_OUT_C); - msleep(100); - - /* DATSET */ - DISP_CMD_OUT(CMD_SET_DATA_C); - DISP_DATA_OUT(0x00); - - /* DISTMEMSET */ - DISP_CMD_OUT(CMD_SET_DISPLAY_TIMING_C); - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x2E); - DISP_DATA_OUT(0x0A); - DISP_DATA_OUT(0x2C); - DISP_DATA_OUT(0x23); - DISP_DATA_OUT(0x2F); - DISP_DATA_OUT(0x00); - - /* GAMSETP */ - DISP_CMD_OUT(CMD_SET_POSITIVE_CORRECTION_CHARS_C); - DISP_DATA_OUT(0x37); - DISP_DATA_OUT(0xFF); - DISP_DATA_OUT(0x7F); - DISP_DATA_OUT(0x15); - DISP_DATA_OUT(0x37); - DISP_DATA_OUT(0x05); - - /* GAMSETN */ - DISP_CMD_OUT(CMD_SET_NEGATIVE_CORRECTION_CHARS_C); - DISP_DATA_OUT(0x37); - DISP_DATA_OUT(0xFF); - DISP_DATA_OUT(0x7F); - DISP_DATA_OUT(0x15); - DISP_DATA_OUT(0x37); - DISP_DATA_OUT(0x05); - - /* ACDRIVE */ - DISP_CMD_OUT(CMD_SET_AC_OPERATION_DRIVE_C); - DISP_DATA_OUT(0x00); - - /* TEST */ - DISP_CMD_OUT(CMD_TEST_C); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x01); - - /* COLMOD */ - DISP_CMD_OUT(CMD_SET_DISPLAY_COLOR_MODE_C); - DISP_DATA_OUT(0x00); - - /* STADDSET */ - DISP_CMD_OUT(CMD_SET_START_ADDRESS_C); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x00); - - /* EDADDSET */ - DISP_CMD_OUT(CMD_SET_END_ADDRESS_C); - DISP_DATA_OUT(0xEF); - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x3F); - - /* Set Display Start Line */ - DISP_CMD_OUT(CMD_SET_DISPLAY_START_LINE_C); - DISP_DATA_OUT(0x00); - - /* Set Display Data Interface */ - DISP_CMD_OUT(CMD_SET_DISPLAY_DATA_INTERFACE_C); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x04); - - epson_s1d_disp_set_rect(0, - 0, - ACTIVE_WIN_WIDTH, - ACTIVE_WIN_HEIGHT); - - for (i = 0; i < (ACTIVE_WIN_WIDTH * ACTIVE_WIN_HEIGHT); i++) - outpdw(DISP_DATA_PORT, 0); - - /* DISON */ - DISP_CMD_OUT(CMD_DISPLAY_ON_C); - msleep(60); - - display_on = TRUE; - } - - return 0; -} - -static int epson_s1d_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - ebi2_epson_pdata = pdev->dev.platform_data; - return 0; - } - - msm_fb_add_device(pdev); - return 0; -} - -static struct platform_driver this_driver = { - .probe = epson_s1d_probe, - .driver = { - .name = "ebi2_epson_s1d_qvga", - }, -}; - -static struct msm_fb_panel_data epson_s1d_panel_data = { - .on = epson_s1d_disp_on, - .off = epson_s1d_disp_off, - .set_rect = epson_s1d_disp_set_rect, -}; - -static struct platform_device this_device = { - .name = "ebi2_epson_s1d_qvga", - .id = 1, - .dev = { - .platform_data = &epson_s1d_panel_data, - } -}; - -static int __init epson_s1d_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - ret = platform_driver_register(&this_driver); - if (!ret) { - pinfo = &epson_s1d_panel_data.panel_info; - pinfo->xres = PANEL_WIDTH; - pinfo->yres = PANEL_HEIGHT; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = EBI2_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0x048423E8; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->lcd.vsync_enable = FALSE; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - } - - return ret; -} - -module_init(epson_s1d_init); diff --git a/drivers/video/msm/ebi2_host.c b/drivers/video/msm/ebi2_host.c deleted file mode 100644 index b21e28a15c6804c6c5a2ba6130980a58dd9d9d8e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/ebi2_host.c +++ /dev/null @@ -1,305 +0,0 @@ -/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm_fb.h" - -struct mdp_ccs mdp_ccs_rgb2yuv; -struct mdp_ccs mdp_ccs_yuv2rgb; - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; -static int ebi2_host_resource_initialized; -static struct msm_panel_common_pdata *ebi2_host_pdata; - -static int ebi2_host_probe(struct platform_device *pdev); -static int ebi2_host_remove(struct platform_device *pdev); - -static int ebi2_host_runtime_suspend(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: suspending...\n"); - return 0; -} - -static int ebi2_host_runtime_resume(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: resuming...\n"); - return 0; -} - -static const struct dev_pm_ops ebi2_host_dev_pm_ops = { - .runtime_suspend = ebi2_host_runtime_suspend, - .runtime_resume = ebi2_host_runtime_resume, -}; - - -static struct platform_driver ebi2_host_driver = { - .probe = ebi2_host_probe, - .remove = ebi2_host_remove, - .shutdown = NULL, - .driver = { - /* - * Simulate mdp hw - */ - .name = "mdp", - .pm = &ebi2_host_dev_pm_ops, - }, -}; - -void mdp_pipe_ctrl(MDP_BLOCK_TYPE block, MDP_BLOCK_POWER_STATE state, - boolean isr) -{ - return; -} -int mdp_ppp_blit(struct fb_info *info, struct mdp_blit_req *req) -{ - return 0; -} -int mdp_start_histogram(struct fb_info *info) -{ - return 0; -} -int mdp_stop_histogram(struct fb_info *info) -{ - return 0; -} -void mdp_refresh_screen(unsigned long data) -{ - return; -} - -static int ebi2_host_off(struct platform_device *pdev) -{ - int ret; - ret = panel_next_off(pdev); - return ret; -} - -static int ebi2_host_on(struct platform_device *pdev) -{ - int ret; - ret = panel_next_on(pdev); - return ret; -} - - -static int ebi2_host_probe(struct platform_device *pdev) -{ - struct platform_device *msm_fb_dev = NULL; - struct msm_fb_data_type *mfd; - struct msm_fb_panel_data *pdata = NULL; - int rc; - - if ((pdev->id == 0) && (pdev->num_resources > 0)) { - - ebi2_host_pdata = pdev->dev.platform_data; - - ebi2_host_resource_initialized = 1; - return 0; - } - - ebi2_host_resource_initialized = 1; - if (!ebi2_host_resource_initialized) - return -EPERM; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - msm_fb_dev = platform_device_alloc("msm_fb", pdev->id); - if (!msm_fb_dev) - return -ENOMEM; - - /* link to the latest pdev */ - mfd->pdev = msm_fb_dev; - - if (ebi2_host_pdata) { - mfd->mdp_rev = ebi2_host_pdata->mdp_rev; - mfd->mem_hid = ebi2_host_pdata->mem_hid; - } - - /* add panel data */ - if (platform_device_add_data - (msm_fb_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - pr_err("ebi2_host_probe: platform_device_add_data failed!\n"); - rc = -ENOMEM; - goto ebi2_host_probe_err; - } - /* data chain */ - pdata = msm_fb_dev->dev.platform_data; - pdata->on = ebi2_host_on; - pdata->off = ebi2_host_off; - pdata->next = pdev; - - /* set driver data */ - platform_set_drvdata(msm_fb_dev, mfd); - - rc = platform_device_add(msm_fb_dev); - if (rc) - goto ebi2_host_probe_err; - - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - - pdev_list[pdev_list_cnt++] = pdev; - return 0; - -ebi2_host_probe_err: - platform_device_put(msm_fb_dev); - return rc; -} - -void mdp_set_dma_pan_info(struct fb_info *info, struct mdp_dirty_region *dirty, - boolean sync) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct fb_info *fbi = mfd->fbi; - struct msm_panel_info *panel_info = &mfd->panel_info; - MDPIBUF *iBuf; - int bpp = info->var.bits_per_pixel / 8; - int yres, remainder; - - if (panel_info->mode2_yres != 0) { - yres = panel_info->mode2_yres; - remainder = (fbi->fix.line_length*yres)%PAGE_SIZE; - } else { - yres = panel_info->yres; - remainder = (fbi->fix.line_length*yres)%PAGE_SIZE; - } - - if (!remainder) - remainder = PAGE_SIZE; - - down(&mfd->sem); - - iBuf = &mfd->ibuf; - /* use virtual address */ - iBuf->buf = (uint8 *) fbi->screen_base; - - if (fbi->var.yoffset < yres) { - iBuf->buf += fbi->var.xoffset * bpp; - } else if (fbi->var.yoffset >= yres && fbi->var.yoffset < 2 * yres) { - iBuf->buf += fbi->var.xoffset * bpp + yres * - fbi->fix.line_length + PAGE_SIZE - remainder; - } else { - iBuf->buf += fbi->var.xoffset * bpp + 2 * yres * - fbi->fix.line_length + 2 * (PAGE_SIZE - remainder); - } - - iBuf->ibuf_width = info->var.xres_virtual; - iBuf->bpp = bpp; - - iBuf->vsync_enable = sync; - - if (dirty) { - /* - * ToDo: dirty region check inside var.xoffset+xres - * <-> var.yoffset+yres - */ - iBuf->dma_x = dirty->xoffset % info->var.xres; - iBuf->dma_y = dirty->yoffset % info->var.yres; - iBuf->dma_w = dirty->width; - iBuf->dma_h = dirty->height; - } else { - iBuf->dma_x = 0; - iBuf->dma_y = 0; - iBuf->dma_w = info->var.xres; - iBuf->dma_h = info->var.yres; - } - mfd->ibuf_flushed = FALSE; - up(&mfd->sem); -} - -void mdp_dma_pan_update(struct fb_info *info) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - MDPIBUF *iBuf; - int i, j; - uint32 data; - uint8 *src; - struct msm_fb_panel_data *pdata = - (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; - struct fb_info *fbi = mfd->fbi; - - iBuf = &mfd->ibuf; - - invalidate_caches((unsigned long)fbi->screen_base, - (unsigned long)info->fix.smem_len, - (unsigned long)info->fix.smem_start); - - pdata->set_rect(iBuf->dma_x, iBuf->dma_y, iBuf->dma_w, - iBuf->dma_h); - for (i = 0; i < iBuf->dma_h; i++) { - src = iBuf->buf + (fbi->fix.line_length * (iBuf->dma_y + i)) - + (iBuf->dma_x * iBuf->bpp); - for (j = 0; j < iBuf->dma_w; j++) { - data = (uint32)(*src++ >> 2) << 12; - data |= (uint32)(*src++ >> 2) << 6; - data |= (uint32)(*src++ >> 2); - data = ((data&0x1FF)<<16) | ((data&0x3FE00)>>9); - outpdw(mfd->data_port, data); - } - } -} - -static int ebi2_host_remove(struct platform_device *pdev) -{ - pm_runtime_disable(&pdev->dev); - - return 0; -} - -static int ebi2_host_register_driver(void) -{ - return platform_driver_register(&ebi2_host_driver); -} - -static int __init ebi2_host_driver_init(void) -{ - int ret; - - ret = ebi2_host_register_driver(); - if (ret) { - pr_err("ebi2_host_register_driver() failed!\n"); - return ret; - } - - return 0; -} - -module_init(ebi2_host_driver_init); diff --git a/drivers/video/msm/ebi2_l2f.c b/drivers/video/msm/ebi2_l2f.c deleted file mode 100644 index 8a925270409f8708fcd5a606485102a6ef915461..0000000000000000000000000000000000000000 --- a/drivers/video/msm/ebi2_l2f.c +++ /dev/null @@ -1,563 +0,0 @@ -/* Copyright (c) 2008-2010, 2013, 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 "msm_fb.h" - -#include -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" - -#include - -#include -#include - -/* The following are for MSM5100 on Gator -*/ -#ifdef FEATURE_PM1000 -#include "pm1000.h" -#endif /* FEATURE_PM1000 */ -/* The following are for MSM6050 on Bambi -*/ -#ifdef FEATURE_PMIC_LCDKBD_LED_DRIVER -#include "pm.h" -#endif /* FEATURE_PMIC_LCDKBD_LED_DRIVER */ - -#ifdef DISP_DEVICE_18BPP -#undef DISP_DEVICE_18BPP -#define DISP_DEVICE_16BPP -#endif - -#define QCIF_WIDTH 176 -#define QCIF_HEIGHT 220 - -static void *DISP_CMD_PORT; -static void *DISP_DATA_PORT; - -#define DISP_CMD_DISON 0xaf -#define DISP_CMD_DISOFF 0xae -#define DISP_CMD_DISNOR 0xa6 -#define DISP_CMD_DISINV 0xa7 -#define DISP_CMD_DISCTL 0xca -#define DISP_CMD_GCP64 0xcb -#define DISP_CMD_GCP16 0xcc -#define DISP_CMD_GSSET 0xcd -#define DISP_GS_2 0x02 -#define DISP_GS_16 0x01 -#define DISP_GS_64 0x00 -#define DISP_CMD_SLPIN 0x95 -#define DISP_CMD_SLPOUT 0x94 -#define DISP_CMD_SD_PSET 0x75 -#define DISP_CMD_MD_PSET 0x76 -#define DISP_CMD_SD_CSET 0x15 -#define DISP_CMD_MD_CSET 0x16 -#define DISP_CMD_DATCTL 0xbc -#define DISP_DATCTL_666 0x08 -#define DISP_DATCTL_565 0x28 -#define DISP_DATCTL_444 0x38 -#define DISP_CMD_RAMWR 0x5c -#define DISP_CMD_RAMRD 0x5d -#define DISP_CMD_PTLIN 0xa8 -#define DISP_CMD_PTLOUT 0xa9 -#define DISP_CMD_ASCSET 0xaa -#define DISP_CMD_SCSTART 0xab -#define DISP_CMD_VOLCTL 0xc6 -#define DISP_VOLCTL_TONE 0x80 -#define DISP_CMD_NOp 0x25 -#define DISP_CMD_OSSEL 0xd0 -#define DISP_CMD_3500KSET 0xd1 -#define DISP_CMD_3500KEND 0xd2 -#define DISP_CMD_14MSET 0xd3 -#define DISP_CMD_14MEND 0xd4 - -#define DISP_CMD_OUT(cmd) outpw(DISP_CMD_PORT, cmd); - -#define DISP_DATA_OUT(data) outpw(DISP_DATA_PORT, data); - -#define DISP_DATA_IN() inpw(DISP_DATA_PORT); - -/* Epson device column number starts at 2 -*/ -#define DISP_SET_RECT(ulhc_row, lrhc_row, ulhc_col, lrhc_col) \ - DISP_CMD_OUT(DISP_CMD_SD_PSET) \ - DISP_DATA_OUT((ulhc_row) & 0xFF) \ - DISP_DATA_OUT((ulhc_row) >> 8) \ - DISP_DATA_OUT((lrhc_row) & 0xFF) \ - DISP_DATA_OUT((lrhc_row) >> 8) \ - DISP_CMD_OUT(DISP_CMD_SD_CSET) \ - DISP_DATA_OUT(((ulhc_col)+2) & 0xFF) \ - DISP_DATA_OUT(((ulhc_col)+2) >> 8) \ - DISP_DATA_OUT(((lrhc_col)+2) & 0xFF) \ - DISP_DATA_OUT(((lrhc_col)+2) >> 8) - -#define DISP_MIN_CONTRAST 0 -#define DISP_MAX_CONTRAST 127 -#define DISP_DEFAULT_CONTRAST 80 - -#define DISP_MIN_BACKLIGHT 0 -#define DISP_MAX_BACKLIGHT 15 -#define DISP_DEFAULT_BACKLIGHT 2 - -#define WAIT_SEC(sec) mdelay((sec)/1000) - -static word disp_area_start_row; -static word disp_area_end_row; -static byte disp_contrast = DISP_DEFAULT_CONTRAST; -static boolean disp_powered_up; -static boolean disp_initialized = FALSE; -/* For some reason the contrast set at init time is not good. Need to do - * it again - */ -static boolean display_on = FALSE; -static void epsonQcif_disp_init(struct platform_device *pdev); -static void epsonQcif_disp_set_contrast(word contrast); -static void epsonQcif_disp_set_display_area(word start_row, word end_row); -static int epsonQcif_disp_off(struct platform_device *pdev); -static int epsonQcif_disp_on(struct platform_device *pdev); -static void epsonQcif_disp_set_rect(int x, int y, int xres, int yres); - -volatile word databack; -static void epsonQcif_disp_init(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - int i; - - if (disp_initialized) - return; - - mfd = platform_get_drvdata(pdev); - - DISP_CMD_PORT = mfd->cmd_port; - DISP_DATA_PORT = mfd->data_port; - - /* Sleep in */ - DISP_CMD_OUT(DISP_CMD_SLPIN); - - /* Display off */ - DISP_CMD_OUT(DISP_CMD_DISOFF); - - /* Display normal */ - DISP_CMD_OUT(DISP_CMD_DISNOR); - - /* Set data mode */ - DISP_CMD_OUT(DISP_CMD_DATCTL); - DISP_DATA_OUT(DISP_DATCTL_565); - - /* Set display timing */ - DISP_CMD_OUT(DISP_CMD_DISCTL); - DISP_DATA_OUT(0x1c); /* p1 */ - DISP_DATA_OUT(0x02); /* p1 */ - DISP_DATA_OUT(0x82); /* p2 */ - DISP_DATA_OUT(0x00); /* p3 */ - DISP_DATA_OUT(0x00); /* p4 */ - DISP_DATA_OUT(0xe0); /* p5 */ - DISP_DATA_OUT(0x00); /* p5 */ - DISP_DATA_OUT(0xdc); /* p6 */ - DISP_DATA_OUT(0x00); /* p6 */ - DISP_DATA_OUT(0x02); /* p7 */ - DISP_DATA_OUT(0x00); /* p8 */ - - /* Set 64 gray scale level */ - DISP_CMD_OUT(DISP_CMD_GCP64); - DISP_DATA_OUT(0x08); /* p01 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x2a); /* p02 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x4e); /* p03 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x6b); /* p04 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x88); /* p05 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0xa3); /* p06 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0xba); /* p07 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0xd1); /* p08 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0xe5); /* p09 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0xf3); /* p10 */ - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x03); /* p11 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x13); /* p12 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x22); /* p13 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x2f); /* p14 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x3b); /* p15 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x46); /* p16 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x51); /* p17 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x5b); /* p18 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x64); /* p19 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x6c); /* p20 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x74); /* p21 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x7c); /* p22 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x83); /* p23 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x8a); /* p24 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x91); /* p25 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x98); /* p26 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x9f); /* p27 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xa6); /* p28 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xac); /* p29 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xb2); /* p30 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xb7); /* p31 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xbc); /* p32 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xc1); /* p33 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xc6); /* p34 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xcb); /* p35 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xd0); /* p36 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xd4); /* p37 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xd8); /* p38 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xdc); /* p39 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xe0); /* p40 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xe4); /* p41 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xe8); /* p42 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xec); /* p43 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xf0); /* p44 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xf4); /* p45 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xf8); /* p46 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xfb); /* p47 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xfe); /* p48 */ - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0x01); /* p49 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x03); /* p50 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x05); /* p51 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x07); /* p52 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x09); /* p53 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x0b); /* p54 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x0d); /* p55 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x0f); /* p56 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x11); /* p57 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x13); /* p58 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x15); /* p59 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x17); /* p60 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x19); /* p61 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x1b); /* p62 */ - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x1c); /* p63 */ - DISP_DATA_OUT(0x02); - - /* Set 16 gray scale level */ - DISP_CMD_OUT(DISP_CMD_GCP16); - DISP_DATA_OUT(0x1a); /* p01 */ - DISP_DATA_OUT(0x32); /* p02 */ - DISP_DATA_OUT(0x42); /* p03 */ - DISP_DATA_OUT(0x4c); /* p04 */ - DISP_DATA_OUT(0x58); /* p05 */ - DISP_DATA_OUT(0x5f); /* p06 */ - DISP_DATA_OUT(0x66); /* p07 */ - DISP_DATA_OUT(0x6b); /* p08 */ - DISP_DATA_OUT(0x70); /* p09 */ - DISP_DATA_OUT(0x74); /* p10 */ - DISP_DATA_OUT(0x78); /* p11 */ - DISP_DATA_OUT(0x7b); /* p12 */ - DISP_DATA_OUT(0x7e); /* p13 */ - DISP_DATA_OUT(0x80); /* p14 */ - DISP_DATA_OUT(0x82); /* p15 */ - - /* Set DSP column */ - DISP_CMD_OUT(DISP_CMD_MD_CSET); - DISP_DATA_OUT(0xff); - DISP_DATA_OUT(0x03); - DISP_DATA_OUT(0xff); - DISP_DATA_OUT(0x03); - - /* Set DSP page */ - DISP_CMD_OUT(DISP_CMD_MD_PSET); - DISP_DATA_OUT(0xff); - DISP_DATA_OUT(0x01); - DISP_DATA_OUT(0xff); - DISP_DATA_OUT(0x01); - - /* Set ARM column */ - DISP_CMD_OUT(DISP_CMD_SD_CSET); - DISP_DATA_OUT(0x02); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT((QCIF_WIDTH + 1) & 0xFF); - DISP_DATA_OUT((QCIF_WIDTH + 1) >> 8); - - /* Set ARM page */ - DISP_CMD_OUT(DISP_CMD_SD_PSET); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT(0x00); - DISP_DATA_OUT((QCIF_HEIGHT - 1) & 0xFF); - DISP_DATA_OUT((QCIF_HEIGHT - 1) >> 8); - - /* Set 64 gray scales */ - DISP_CMD_OUT(DISP_CMD_GSSET); - DISP_DATA_OUT(DISP_GS_64); - - DISP_CMD_OUT(DISP_CMD_OSSEL); - DISP_DATA_OUT(0); - - /* Sleep out */ - DISP_CMD_OUT(DISP_CMD_SLPOUT); - - WAIT_SEC(40000); - - /* Initialize power IC */ - DISP_CMD_OUT(DISP_CMD_VOLCTL); - DISP_DATA_OUT(DISP_VOLCTL_TONE); - - WAIT_SEC(40000); - - /* Set electronic volume, d'xx */ - DISP_CMD_OUT(DISP_CMD_VOLCTL); - DISP_DATA_OUT(DISP_DEFAULT_CONTRAST); /* value from 0 to 127 */ - - /* Initialize display data */ - DISP_SET_RECT(0, (QCIF_HEIGHT - 1), 0, (QCIF_WIDTH - 1)); - DISP_CMD_OUT(DISP_CMD_RAMWR); - for (i = 0; i < QCIF_HEIGHT * QCIF_WIDTH; i++) - DISP_DATA_OUT(0xffff); - - DISP_CMD_OUT(DISP_CMD_RAMRD); - databack = DISP_DATA_IN(); - databack = DISP_DATA_IN(); - databack = DISP_DATA_IN(); - databack = DISP_DATA_IN(); - - WAIT_SEC(80000); - - DISP_CMD_OUT(DISP_CMD_DISON); - - disp_area_start_row = 0; - disp_area_end_row = QCIF_HEIGHT - 1; - disp_powered_up = TRUE; - disp_initialized = TRUE; - epsonQcif_disp_set_display_area(0, QCIF_HEIGHT - 1); - display_on = TRUE; -} - -static void epsonQcif_disp_set_rect(int x, int y, int xres, int yres) -{ - if (!disp_initialized) - return; - - DISP_SET_RECT(y, y + yres - 1, x, x + xres - 1); - DISP_CMD_OUT(DISP_CMD_RAMWR); -} - -static void epsonQcif_disp_set_display_area(word start_row, word end_row) -{ - if (!disp_initialized) - return; - - if ((start_row == disp_area_start_row) - && (end_row == disp_area_end_row)) - return; - disp_area_start_row = start_row; - disp_area_end_row = end_row; - - /* Range checking - */ - if (end_row >= QCIF_HEIGHT) - end_row = QCIF_HEIGHT - 1; - if (start_row > end_row) - start_row = end_row; - - /* When display is not the full screen, gray scale is set to - ** 2; otherwise it is set to 64. - */ - if ((start_row == 0) && (end_row == (QCIF_HEIGHT - 1))) { - /* The whole screen */ - DISP_CMD_OUT(DISP_CMD_PTLOUT); - WAIT_SEC(10000); - DISP_CMD_OUT(DISP_CMD_DISOFF); - WAIT_SEC(100000); - DISP_CMD_OUT(DISP_CMD_GSSET); - DISP_DATA_OUT(DISP_GS_64); - WAIT_SEC(100000); - DISP_CMD_OUT(DISP_CMD_DISON); - } else { - /* partial screen */ - DISP_CMD_OUT(DISP_CMD_PTLIN); - DISP_DATA_OUT(start_row); - DISP_DATA_OUT(start_row >> 8); - DISP_DATA_OUT(end_row); - DISP_DATA_OUT(end_row >> 8); - DISP_CMD_OUT(DISP_CMD_GSSET); - DISP_DATA_OUT(DISP_GS_2); - } -} - -static int epsonQcif_disp_off(struct platform_device *pdev) -{ - if (!disp_initialized) - epsonQcif_disp_init(pdev); - - if (display_on) { - DISP_CMD_OUT(DISP_CMD_DISOFF); - DISP_CMD_OUT(DISP_CMD_SLPIN); - display_on = FALSE; - } - - return 0; -} - -static int epsonQcif_disp_on(struct platform_device *pdev) -{ - if (!disp_initialized) - epsonQcif_disp_init(pdev); - - if (!display_on) { - DISP_CMD_OUT(DISP_CMD_SLPOUT); - WAIT_SEC(40000); - DISP_CMD_OUT(DISP_CMD_DISON); - epsonQcif_disp_set_contrast(disp_contrast); - display_on = TRUE; - } - - return 0; -} - -static void epsonQcif_disp_set_contrast(word contrast) -{ - if (!disp_initialized) - return; - - /* Initialize power IC, d'24 */ - DISP_CMD_OUT(DISP_CMD_VOLCTL); - DISP_DATA_OUT(DISP_VOLCTL_TONE); - - WAIT_SEC(40000); - - /* Set electronic volume, d'xx */ - DISP_CMD_OUT(DISP_CMD_VOLCTL); - if (contrast > 127) - contrast = 127; - DISP_DATA_OUT(contrast); /* value from 0 to 127 */ - disp_contrast = (byte) contrast; -} /* End disp_set_contrast */ - -static void epsonQcif_disp_clear_screen_area( - word start_row, word end_row, word start_column, word end_column) { - int32 i; - - /* Clear the display screen */ - DISP_SET_RECT(start_row, end_row, start_column, end_column); - DISP_CMD_OUT(DISP_CMD_RAMWR); - i = (end_row - start_row + 1) * (end_column - start_column + 1); - for (; i > 0; i--) - DISP_DATA_OUT(0xffff); -} - -static int __init epsonQcif_probe(struct platform_device *pdev) -{ - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = epsonQcif_probe, - .driver = { - .name = "ebi2_epson_qcif", - }, -}; - -static struct msm_fb_panel_data epsonQcif_panel_data = { - .on = epsonQcif_disp_on, - .off = epsonQcif_disp_off, - .set_rect = epsonQcif_disp_set_rect, -}; - -static struct platform_device this_device = { - .name = "ebi2_epson_qcif", - .id = 0, - .dev = { - .platform_data = &epsonQcif_panel_data, - } -}; - -static int __init epsonQcif_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - ret = platform_driver_register(&this_driver); - if (!ret) { - pinfo = &epsonQcif_panel_data.panel_info; - pinfo->xres = QCIF_WIDTH; - pinfo->yres = QCIF_HEIGHT; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = EBI2_PANEL; - pinfo->pdest = DISPLAY_2; - pinfo->wait_cycle = 0x808000; - pinfo->bpp = 16; - pinfo->fb_num = 2; - pinfo->lcd.vsync_enable = FALSE; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - } - - return ret; -} - -module_init(epsonQcif_init); diff --git a/drivers/video/msm/ebi2_lcd.c b/drivers/video/msm/ebi2_lcd.c deleted file mode 100644 index a19763c4666de8cefa846a968413a3cbcafe9d60..0000000000000000000000000000000000000000 --- a/drivers/video/msm/ebi2_lcd.c +++ /dev/null @@ -1,308 +0,0 @@ -/* Copyright (c) 2008-2009, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" - -static int ebi2_lcd_probe(struct platform_device *pdev); -static int ebi2_lcd_remove(struct platform_device *pdev); - -static int ebi2_lcd_runtime_suspend(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: suspending...\n"); - return 0; -} - -static int ebi2_lcd_runtime_resume(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: resuming...\n"); - return 0; -} - -static struct dev_pm_ops ebi2_lcd_dev_pm_ops = { - .runtime_suspend = ebi2_lcd_runtime_suspend, - .runtime_resume = ebi2_lcd_runtime_resume, -}; - -static struct platform_driver ebi2_lcd_driver = { - .probe = ebi2_lcd_probe, - .remove = ebi2_lcd_remove, - .suspend = NULL, - .resume = NULL, - .shutdown = NULL, - .driver = { - .name = "ebi2_lcd", - .pm = &ebi2_lcd_dev_pm_ops, - }, -}; - -static void *ebi2_base; -static void *ebi2_lcd_cfg0; -static void *ebi2_lcd_cfg1; -static void __iomem *lcd01_base; -static void __iomem *lcd02_base; -static int lcd01_base_phys; -static int ebi2_lcd_resource_initialized; - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; -static struct lcdc_platform_data *ebi2_pdata; - -static int ebi2_lcd_on(struct platform_device *pdev) -{ - int ret; - - if (ebi2_pdata && ebi2_pdata->lcdc_power_save) - ebi2_pdata->lcdc_power_save(1); - - ret = panel_next_on(pdev); - return ret; -} - -static int ebi2_lcd_off(struct platform_device *pdev) -{ - int ret; - - ret = panel_next_off(pdev); - - if (ebi2_pdata && ebi2_pdata->lcdc_power_save) - ebi2_pdata->lcdc_power_save(0); - - return ret; -} - -static int ebi2_lcd_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc, i, hw_version; - - if (pdev->id == 0) { - for (i = 0; i < pdev->num_resources; i++) { - if (!strncmp(pdev->resource[i].name, "base", 4)) { - ebi2_base = ioremap(pdev->resource[i].start, - pdev->resource[i].end - - pdev->resource[i].start + 1); - if (!ebi2_base) { - printk(KERN_ERR - "ebi2_base ioremap failed!\n"); - return -ENOMEM; - } - ebi2_lcd_cfg0 = (void *)(ebi2_base + 0x20); - ebi2_lcd_cfg1 = (void *)(ebi2_base + 0x24); - } else if (!strncmp(pdev->resource[i].name, - "lcd01", 5)) { - lcd01_base_phys = pdev->resource[i].start; - lcd01_base = ioremap(pdev->resource[i].start, - pdev->resource[i].end - - pdev->resource[i].start + 1); - if (!lcd01_base) { - printk(KERN_ERR - "lcd01_base ioremap failed!\n"); - return -ENOMEM; - } - } else if (!strncmp(pdev->resource[i].name, - "lcd02", 5)) { - lcd02_base = ioremap(pdev->resource[i].start, - pdev->resource[i].end - - pdev->resource[i].start + 1); - if (!lcd02_base) { - printk(KERN_ERR - "lcd02_base ioremap failed!\n"); - return -ENOMEM; - } - } - } - ebi2_pdata = pdev->dev.platform_data; - ebi2_lcd_resource_initialized = 1; - - return 0; - } - - if (!ebi2_lcd_resource_initialized) - return -EPERM; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - if (ebi2_base == NULL) - return -ENOMEM; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - - /* link to the latest pdev */ - mfd->pdev = mdp_dev; - mfd->dest = DISPLAY_LCD; - - /* add panel data */ - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - printk(KERN_ERR "ebi2_lcd_probe: platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - - /* data chain */ - pdata = mdp_dev->dev.platform_data; - pdata->on = ebi2_lcd_on; - pdata->off = ebi2_lcd_off; - pdata->next = pdev; - - /* get/set panel specific fb info */ - mfd->panel_info = pdata->panel_info; - - hw_version = inp32((int)ebi2_base + 8); - - if (mfd->panel_info.bpp == 24) - mfd->fb_imgType = MDP_RGB_888; - else if (mfd->panel_info.bpp == 18) - mfd->fb_imgType = MDP_RGB_888; - else - mfd->fb_imgType = MDP_RGB_565; - - /* config msm ebi2 lcd register */ - if (mfd->panel_info.pdest == DISPLAY_1) { - outp32(ebi2_base, - (inp32(ebi2_base) & (~(EBI2_PRIM_LCD_CLR))) | - EBI2_PRIM_LCD_SEL); - /* - * current design has one set of cfg0/1 register to control - * both EBI2 channels. so, we're using the PRIM channel to - * configure both. - */ - outp32(ebi2_lcd_cfg0, mfd->panel_info.wait_cycle); - if (hw_version < 0x2020) { - if (mfd->panel_info.bpp == 18) - outp32(ebi2_lcd_cfg1, 0x01000000); - else - outp32(ebi2_lcd_cfg1, 0x0); - } - } else { -#ifdef DEBUG_EBI2_LCD - /* - * confliting with QCOM SURF FPGA CS. - * OEM should enable below for their CS mapping - */ - outp32(ebi2_base, (inp32(ebi2_base)&(~(EBI2_SECD_LCD_CLR))) - |EBI2_SECD_LCD_SEL); -#endif - } - - /* - * map cs (chip select) address - */ - if (mfd->panel_info.pdest == DISPLAY_1) { - mfd->cmd_port = lcd01_base; - if (hw_version >= 0x2020) { - mfd->data_port = - (void *)((uint32) mfd->cmd_port + 0x80); - mfd->data_port_phys = - (void *)(lcd01_base_phys + 0x80); - } else { - mfd->data_port = - (void *)((uint32) mfd->cmd_port + - EBI2_PRIM_LCD_RS_PIN); - mfd->data_port_phys = - (void *)(LCD_PRIM_BASE_PHYS + EBI2_PRIM_LCD_RS_PIN); - } - } else { - mfd->cmd_port = lcd01_base; - mfd->data_port = - (void *)((uint32) mfd->cmd_port + EBI2_SECD_LCD_RS_PIN); - mfd->data_port_phys = - (void *)(LCD_SECD_BASE_PHYS + EBI2_SECD_LCD_RS_PIN); - } - - /* - * set driver data - */ - platform_set_drvdata(mdp_dev, mfd); - - /* - * register in mdp driver - */ - rc = platform_device_add(mdp_dev); - if (rc) { - goto ebi2_lcd_probe_err; - } - - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - - - pdev_list[pdev_list_cnt++] = pdev; - return 0; - - ebi2_lcd_probe_err: - platform_device_put(mdp_dev); - return rc; -} - -static int ebi2_lcd_remove(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return 0; - - if (mfd->key != MFD_KEY) - return 0; - - iounmap(mfd->cmd_port); - pm_runtime_disable(&pdev->dev); - return 0; -} - -static int ebi2_lcd_register_driver(void) -{ - return platform_driver_register(&ebi2_lcd_driver); -} - -static int __init ebi2_lcd_driver_init(void) -{ - return ebi2_lcd_register_driver(); -} - -module_init(ebi2_lcd_driver_init); diff --git a/drivers/video/msm/ebi2_tmd20.c b/drivers/video/msm/ebi2_tmd20.c deleted file mode 100644 index 72ba49343b44a0aa3d3bed74b021fc310f4a0a23..0000000000000000000000000000000000000000 --- a/drivers/video/msm/ebi2_tmd20.c +++ /dev/null @@ -1,1117 +0,0 @@ -/* Copyright (c) 2008-2010, 2013, 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 "msm_fb.h" - -#include -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" - -#include - -#include -#include - -/* #define TMD20QVGA_LCD_18BPP */ -#define QVGA_WIDTH 240 -#define QVGA_HEIGHT 320 - -#ifdef TMD20QVGA_LCD_18BPP -#define DISP_QVGA_18BPP(x) ((((x)<<2) & 0x3FC00)|(( (x)<<1)& 0x1FE)) -#define DISP_REG(name) uint32 register_##name; -#define OUTPORT(x, y) outpdw(x, y) -#define INPORT(x) inpdw(x) -#else -#define DISP_QVGA_18BPP(x) (x) -#define DISP_REG(name) uint16 register_##name; -#define OUTPORT(x, y) outpw(x, y) -#define INPORT(x) intpw(x) -#endif - -static void *DISP_CMD_PORT; -static void *DISP_DATA_PORT; - -#define DISP_RNTI 0x10 - -#define DISP_CMD_OUT(cmd) OUTPORT(DISP_CMD_PORT, DISP_QVGA_18BPP(cmd)) -#define DISP_DATA_OUT(data) OUTPORT(DISP_DATA_PORT, data) -#define DISP_DATA_IN() INPORT(DISP_DATA_PORT) - -#if (defined(TMD20QVGA_LCD_18BPP)) -#define DISP_DATA_OUT_16TO18BPP(x) \ - DISP_DATA_OUT((((x)&0xf800)<<2|((x)&0x80000)>>3) \ - | (((x)&0x7e0)<<1) \ - | (((x)&0x1F)<<1|((x)&0x10)>>4)) -#else -#define DISP_DATA_OUT_16TO18BPP(x) \ - DISP_DATA_OUT(x) -#endif - -#define DISP_WRITE_OUT(addr, data) \ - register_##addr = DISP_QVGA_18BPP(data); \ - DISP_CMD_OUT(addr); \ - DISP_DATA_OUT(register_##addr); - -#define DISP_UPDATE_VALUE(addr, bitmask, data) \ - DISP_WRITE_OUT(##addr, (register_##addr & ~(bitmask)) | (data)); - -#define DISP_VAL_IF(bitvalue, bitmask) \ - ((bitvalue) ? (bitmask) : 0) - -/* QVGA = 256 x 320 */ -/* actual display is 240 x 320...offset by 0x10 */ -#define DISP_ROW_COL_TO_ADDR(row, col) ((row) * 0x100 + col) -#define DISP_SET_RECT(ulhc_row, lrhc_row, ulhc_col, lrhc_col) \ - { \ - DISP_WRITE_OUT(DISP_HORZ_RAM_ADDR_POS_1_ADDR, (ulhc_col) + tmd20qvga_panel_offset); \ - DISP_WRITE_OUT(DISP_HORZ_RAM_ADDR_POS_2_ADDR, (lrhc_col) + tmd20qvga_panel_offset); \ - DISP_WRITE_OUT(DISP_VERT_RAM_ADDR_POS_1_ADDR, (ulhc_row)); \ - DISP_WRITE_OUT(DISP_VERT_RAM_ADDR_POS_2_ADDR, (lrhc_row)); \ - DISP_WRITE_OUT(DISP_RAM_ADDR_SET_1_ADDR, (ulhc_col) + tmd20qvga_panel_offset); \ - DISP_WRITE_OUT(DISP_RAM_ADDR_SET_2_ADDR, (ulhc_row)); \ - } - -#define WAIT_MSEC(msec) mdelay(msec) - -/* - * TMD QVGA Address - */ -/* Display Control */ -#define DISP_START_OSCILLATION_ADDR 0x000 -DISP_REG(DISP_START_OSCILLATION_ADDR) -#define DISP_DRIVER_OUTPUT_CTL_ADDR 0x001 - DISP_REG(DISP_DRIVER_OUTPUT_CTL_ADDR) -#define DISP_LCD_DRIVING_SIG_ADDR 0x002 - DISP_REG(DISP_LCD_DRIVING_SIG_ADDR) -#define DISP_ENTRY_MODE_ADDR 0x003 - DISP_REG(DISP_ENTRY_MODE_ADDR) -#define DISP_DISPLAY_CTL_1_ADDR 0x007 - DISP_REG(DISP_DISPLAY_CTL_1_ADDR) -#define DISP_DISPLAY_CTL_2_ADDR 0x008 - DISP_REG(DISP_DISPLAY_CTL_2_ADDR) - -/* DISPLAY MODE 0x009 partial display not supported */ -#define DISP_POWER_SUPPLY_INTF_ADDR 0x00A - DISP_REG(DISP_POWER_SUPPLY_INTF_ADDR) - -/* DISPLAY MODE 0x00B xZoom feature is not supported */ -#define DISP_EXT_DISPLAY_CTL_1_ADDR 0x00C - DISP_REG(DISP_EXT_DISPLAY_CTL_1_ADDR) - -#define DISP_FRAME_CYCLE_CTL_ADDR 0x00D - DISP_REG(DISP_FRAME_CYCLE_CTL_ADDR) - -#define DISP_EXT_DISPLAY_CTL_2_ADDR 0x00E - DISP_REG(DISP_EXT_DISPLAY_CTL_2_ADDR) - -#define DISP_EXT_DISPLAY_CTL_3_ADDR 0x00F - DISP_REG(DISP_EXT_DISPLAY_CTL_3_ADDR) - -#define DISP_LTPS_CTL_1_ADDR 0x012 - DISP_REG(DISP_LTPS_CTL_1_ADDR) -#define DISP_LTPS_CTL_2_ADDR 0x013 - DISP_REG(DISP_LTPS_CTL_2_ADDR) -#define DISP_LTPS_CTL_3_ADDR 0x014 - DISP_REG(DISP_LTPS_CTL_3_ADDR) -#define DISP_LTPS_CTL_4_ADDR 0x018 - DISP_REG(DISP_LTPS_CTL_4_ADDR) -#define DISP_LTPS_CTL_5_ADDR 0x019 - DISP_REG(DISP_LTPS_CTL_5_ADDR) -#define DISP_LTPS_CTL_6_ADDR 0x01A - DISP_REG(DISP_LTPS_CTL_6_ADDR) -#define DISP_AMP_SETTING_ADDR 0x01C - DISP_REG(DISP_AMP_SETTING_ADDR) -#define DISP_MODE_SETTING_ADDR 0x01D - DISP_REG(DISP_MODE_SETTING_ADDR) -#define DISP_POFF_LN_SETTING_ADDR 0x01E - DISP_REG(DISP_POFF_LN_SETTING_ADDR) -/* Power Contol */ -#define DISP_POWER_CTL_1_ADDR 0x100 - DISP_REG(DISP_POWER_CTL_1_ADDR) -#define DISP_POWER_CTL_2_ADDR 0x101 - DISP_REG(DISP_POWER_CTL_2_ADDR) -#define DISP_POWER_CTL_3_ADDR 0x102 - DISP_REG(DISP_POWER_CTL_3_ADDR) -#define DISP_POWER_CTL_4_ADDR 0x103 - DISP_REG(DISP_POWER_CTL_4_ADDR) -#define DISP_POWER_CTL_5_ADDR 0x104 - DISP_REG(DISP_POWER_CTL_5_ADDR) -#define DISP_POWER_CTL_6_ADDR 0x105 - DISP_REG(DISP_POWER_CTL_6_ADDR) -#define DISP_POWER_CTL_7_ADDR 0x106 - DISP_REG(DISP_POWER_CTL_7_ADDR) -/* RAM Access */ -#define DISP_RAM_ADDR_SET_1_ADDR 0x200 - DISP_REG(DISP_RAM_ADDR_SET_1_ADDR) -#define DISP_RAM_ADDR_SET_2_ADDR 0x201 - DISP_REG(DISP_RAM_ADDR_SET_2_ADDR) -#define DISP_CMD_RAMRD DISP_CMD_RAMWR -#define DISP_CMD_RAMWR 0x202 - DISP_REG(DISP_CMD_RAMWR) -#define DISP_RAM_DATA_MASK_1_ADDR 0x203 - DISP_REG(DISP_RAM_DATA_MASK_1_ADDR) -#define DISP_RAM_DATA_MASK_2_ADDR 0x204 - DISP_REG(DISP_RAM_DATA_MASK_2_ADDR) -/* Gamma Control, Contrast, Gray Scale Setting */ -#define DISP_GAMMA_CONTROL_1_ADDR 0x300 - DISP_REG(DISP_GAMMA_CONTROL_1_ADDR) -#define DISP_GAMMA_CONTROL_2_ADDR 0x301 - DISP_REG(DISP_GAMMA_CONTROL_2_ADDR) -#define DISP_GAMMA_CONTROL_3_ADDR 0x302 - DISP_REG(DISP_GAMMA_CONTROL_3_ADDR) -#define DISP_GAMMA_CONTROL_4_ADDR 0x303 - DISP_REG(DISP_GAMMA_CONTROL_4_ADDR) -#define DISP_GAMMA_CONTROL_5_ADDR 0x304 - DISP_REG(DISP_GAMMA_CONTROL_5_ADDR) -/* Coordinate Control */ -#define DISP_VERT_SCROLL_CTL_1_ADDR 0x400 - DISP_REG(DISP_VERT_SCROLL_CTL_1_ADDR) -#define DISP_VERT_SCROLL_CTL_2_ADDR 0x401 - DISP_REG(DISP_VERT_SCROLL_CTL_2_ADDR) -#define DISP_SCREEN_1_DRV_POS_1_ADDR 0x402 - DISP_REG(DISP_SCREEN_1_DRV_POS_1_ADDR) -#define DISP_SCREEN_1_DRV_POS_2_ADDR 0x403 - DISP_REG(DISP_SCREEN_1_DRV_POS_2_ADDR) -#define DISP_SCREEN_2_DRV_POS_1_ADDR 0x404 - DISP_REG(DISP_SCREEN_2_DRV_POS_1_ADDR) -#define DISP_SCREEN_2_DRV_POS_2_ADDR 0x405 - DISP_REG(DISP_SCREEN_2_DRV_POS_2_ADDR) -#define DISP_HORZ_RAM_ADDR_POS_1_ADDR 0x406 - DISP_REG(DISP_HORZ_RAM_ADDR_POS_1_ADDR) -#define DISP_HORZ_RAM_ADDR_POS_2_ADDR 0x407 - DISP_REG(DISP_HORZ_RAM_ADDR_POS_2_ADDR) -#define DISP_VERT_RAM_ADDR_POS_1_ADDR 0x408 - DISP_REG(DISP_VERT_RAM_ADDR_POS_1_ADDR) -#define DISP_VERT_RAM_ADDR_POS_2_ADDR 0x409 - DISP_REG(DISP_VERT_RAM_ADDR_POS_2_ADDR) -#define DISP_TMD_700_ADDR 0x700 /* 0x700 */ - DISP_REG(DISP_TMD_700_ADDR) -#define DISP_TMD_015_ADDR 0x015 /* 0x700 */ - DISP_REG(DISP_TMD_015_ADDR) -#define DISP_TMD_305_ADDR 0x305 /* 0x700 */ - DISP_REG(DISP_TMD_305_ADDR) - -/* - * TMD QVGA Bit Definations - */ - -#define DISP_BIT_IB15 0x8000 -#define DISP_BIT_IB14 0x4000 -#define DISP_BIT_IB13 0x2000 -#define DISP_BIT_IB12 0x1000 -#define DISP_BIT_IB11 0x0800 -#define DISP_BIT_IB10 0x0400 -#define DISP_BIT_IB09 0x0200 -#define DISP_BIT_IB08 0x0100 -#define DISP_BIT_IB07 0x0080 -#define DISP_BIT_IB06 0x0040 -#define DISP_BIT_IB05 0x0020 -#define DISP_BIT_IB04 0x0010 -#define DISP_BIT_IB03 0x0008 -#define DISP_BIT_IB02 0x0004 -#define DISP_BIT_IB01 0x0002 -#define DISP_BIT_IB00 0x0001 -/* - * Display Control - * DISP_START_OSCILLATION_ADDR Start Oscillation - * DISP_DRIVER_OUTPUT_CTL_ADDR Driver Output Control - */ -#define DISP_BITMASK_SS DISP_BIT_IB08 -#define DISP_BITMASK_NL5 DISP_BIT_IB05 -#define DISP_BITMASK_NL4 DISP_BIT_IB04 -#define DISP_BITMASK_NL3 DISP_BIT_IB03 -#define DISP_BITMASK_NL2 DISP_BIT_IB02 -#define DISP_BITMASK_NL1 DISP_BIT_IB01 -#define DISP_BITMASK_NL0 DISP_BIT_IB00 -/* DISP_LCD_DRIVING_SIG_ADDR LCD Driving Signal Setting */ -#define DISP_BITMASK_BC DISP_BIT_IB09 -/* DISP_ENTRY_MODE_ADDR Entry Mode */ -#define DISP_BITMASK_TRI DISP_BIT_IB15 -#define DISP_BITMASK_DFM1 DISP_BIT_IB14 -#define DISP_BITMASK_DFM0 DISP_BIT_IB13 -#define DISP_BITMASK_BGR DISP_BIT_IB12 -#define DISP_BITMASK_HWM0 DISP_BIT_IB08 -#define DISP_BITMASK_ID1 DISP_BIT_IB05 -#define DISP_BITMASK_ID0 DISP_BIT_IB04 -#define DISP_BITMASK_AM DISP_BIT_IB03 -/* DISP_DISPLAY_CTL_1_ADDR Display Control (1) */ -#define DISP_BITMASK_COL1 DISP_BIT_IB15 -#define DISP_BITMASK_COL0 DISP_BIT_IB14 -#define DISP_BITMASK_VLE2 DISP_BIT_IB10 -#define DISP_BITMASK_VLE1 DISP_BIT_IB09 -#define DISP_BITMASK_SPT DISP_BIT_IB08 -#define DISP_BITMASK_PT1 DISP_BIT_IB07 -#define DISP_BITMASK_PT0 DISP_BIT_IB06 -#define DISP_BITMASK_REV DISP_BIT_IB02 -/* DISP_DISPLAY_CTL_2_ADDR Display Control (2) */ -#define DISP_BITMASK_FP3 DISP_BIT_IB11 -#define DISP_BITMASK_FP2 DISP_BIT_IB10 -#define DISP_BITMASK_FP1 DISP_BIT_IB09 -#define DISP_BITMASK_FP0 DISP_BIT_IB08 -#define DISP_BITMASK_BP3 DISP_BIT_IB03 -#define DISP_BITMASK_BP2 DISP_BIT_IB02 -#define DISP_BITMASK_BP1 DISP_BIT_IB01 -#define DISP_BITMASK_BP0 DISP_BIT_IB00 -/* DISP_POWER_SUPPLY_INTF_ADDR Power Supply IC Interface Control */ -#define DISP_BITMASK_CSE DISP_BIT_IB12 -#define DISP_BITMASK_TE DISP_BIT_IB08 -#define DISP_BITMASK_IX3 DISP_BIT_IB03 -#define DISP_BITMASK_IX2 DISP_BIT_IB02 -#define DISP_BITMASK_IX1 DISP_BIT_IB01 -#define DISP_BITMASK_IX0 DISP_BIT_IB00 -/* DISP_EXT_DISPLAY_CTL_1_ADDR External Display Interface Control (1) */ -#define DISP_BITMASK_RM DISP_BIT_IB08 -#define DISP_BITMASK_DM1 DISP_BIT_IB05 -#define DISP_BITMASK_DM0 DISP_BIT_IB04 -#define DISP_BITMASK_RIM1 DISP_BIT_IB01 -#define DISP_BITMASK_RIM0 DISP_BIT_IB00 -/* DISP_FRAME_CYCLE_CTL_ADDR Frame Frequency Adjustment Control */ -#define DISP_BITMASK_DIVI1 DISP_BIT_IB09 -#define DISP_BITMASK_DIVI0 DISP_BIT_IB08 -#define DISP_BITMASK_RTNI4 DISP_BIT_IB04 -#define DISP_BITMASK_RTNI3 DISP_BIT_IB03 -#define DISP_BITMASK_RTNI2 DISP_BIT_IB02 -#define DISP_BITMASK_RTNI1 DISP_BIT_IB01 -#define DISP_BITMASK_RTNI0 DISP_BIT_IB00 -/* DISP_EXT_DISPLAY_CTL_2_ADDR External Display Interface Control (2) */ -#define DISP_BITMASK_DIVE1 DISP_BIT_IB09 -#define DISP_BITMASK_DIVE0 DISP_BIT_IB08 -#define DISP_BITMASK_RTNE7 DISP_BIT_IB07 -#define DISP_BITMASK_RTNE6 DISP_BIT_IB06 -#define DISP_BITMASK_RTNE5 DISP_BIT_IB05 -#define DISP_BITMASK_RTNE4 DISP_BIT_IB04 -#define DISP_BITMASK_RTNE3 DISP_BIT_IB03 -#define DISP_BITMASK_RTNE2 DISP_BIT_IB02 -#define DISP_BITMASK_RTNE1 DISP_BIT_IB01 -#define DISP_BITMASK_RTNE0 DISP_BIT_IB00 -/* DISP_EXT_DISPLAY_CTL_3_ADDR External Display Interface Control (3) */ -#define DISP_BITMASK_VSPL DISP_BIT_IB04 -#define DISP_BITMASK_HSPL DISP_BIT_IB03 -#define DISP_BITMASK_VPL DISP_BIT_IB02 -#define DISP_BITMASK_EPL DISP_BIT_IB01 -#define DISP_BITMASK_DPL DISP_BIT_IB00 -/* DISP_LTPS_CTL_1_ADDR LTPS Interface Control (1) */ -#define DISP_BITMASK_CLWI3 DISP_BIT_IB11 -#define DISP_BITMASK_CLWI2 DISP_BIT_IB10 -#define DISP_BITMASK_CLWI1 DISP_BIT_IB09 -#define DISP_BITMASK_CLWI0 DISP_BIT_IB08 -#define DISP_BITMASK_CLTI1 DISP_BIT_IB01 -#define DISP_BITMASK_CLTI0 DISP_BIT_IB00 -/* DISP_LTPS_CTL_2_ADDR LTPS Interface Control (2) */ -#define DISP_BITMASK_OEVBI1 DISP_BIT_IB09 -#define DISP_BITMASK_OEVBI0 DISP_BIT_IB08 -#define DISP_BITMASK_OEVFI1 DISP_BIT_IB01 -#define DISP_BITMASK_OEVFI0 DISP_BIT_IB00 -/* DISP_LTPS_CTL_3_ADDR LTPS Interface Control (3) */ -#define DISP_BITMASK_SHI1 DISP_BIT_IB01 -#define DISP_BITMASK_SHI0 DISP_BIT_IB00 -/* DISP_LTPS_CTL_4_ADDR LTPS Interface Control (4) */ -#define DISP_BITMASK_CLWE5 DISP_BIT_IB13 -#define DISP_BITMASK_CLWE4 DISP_BIT_IB12 -#define DISP_BITMASK_CLWE3 DISP_BIT_IB11 -#define DISP_BITMASK_CLWE2 DISP_BIT_IB10 -#define DISP_BITMASK_CLWE1 DISP_BIT_IB09 -#define DISP_BITMASK_CLWE0 DISP_BIT_IB08 -#define DISP_BITMASK_CLTE3 DISP_BIT_IB03 -#define DISP_BITMASK_CLTE2 DISP_BIT_IB02 -#define DISP_BITMASK_CLTE1 DISP_BIT_IB01 -#define DISP_BITMASK_CLTE0 DISP_BIT_IB00 -/* DISP_LTPS_CTL_5_ADDR LTPS Interface Control (5) */ -#define DISP_BITMASK_OEVBE3 DISP_BIT_IB11 -#define DISP_BITMASK_OEVBE2 DISP_BIT_IB10 -#define DISP_BITMASK_OEVBE1 DISP_BIT_IB09 -#define DISP_BITMASK_OEVBE0 DISP_BIT_IB08 -#define DISP_BITMASK_OEVFE3 DISP_BIT_IB03 -#define DISP_BITMASK_OEVFE2 DISP_BIT_IB02 -#define DISP_BITMASK_OEVFE1 DISP_BIT_IB01 -#define DISP_BITMASK_OEVFE0 DISP_BIT_IB00 -/* DISP_LTPS_CTL_6_ADDR LTPS Interface Control (6) */ -#define DISP_BITMASK_SHE3 DISP_BIT_IB03 -#define DISP_BITMASK_SHE2 DISP_BIT_IB02 -#define DISP_BITMASK_SHE1 DISP_BIT_IB01 -#define DISP_BITMASK_SHE0 DISP_BIT_IB00 -/* DISP_AMP_SETTING_ADDR Amplify Setting */ -#define DISP_BITMASK_ABSW1 DISP_BIT_IB01 -#define DISP_BITMASK_ABSW0 DISP_BIT_IB00 -/* DISP_MODE_SETTING_ADDR Mode Setting */ -#define DISP_BITMASK_DSTB DISP_BIT_IB02 -#define DISP_BITMASK_STB DISP_BIT_IB00 -/* DISP_POFF_LN_SETTING_ADDR Power Off Line Setting */ -#define DISP_BITMASK_POFH3 DISP_BIT_IB03 -#define DISP_BITMASK_POFH2 DISP_BIT_IB02 -#define DISP_BITMASK_POFH1 DISP_BIT_IB01 -#define DISP_BITMASK_POFH0 DISP_BIT_IB00 - -/* Power Contol */ -/* DISP_POWER_CTL_1_ADDR Power Control (1) */ -#define DISP_BITMASK_PO DISP_BIT_IB11 -#define DISP_BITMASK_VCD DISP_BIT_IB09 -#define DISP_BITMASK_VSC DISP_BIT_IB08 -#define DISP_BITMASK_CON DISP_BIT_IB07 -#define DISP_BITMASK_ASW1 DISP_BIT_IB06 -#define DISP_BITMASK_ASW0 DISP_BIT_IB05 -#define DISP_BITMASK_OEV DISP_BIT_IB04 -#define DISP_BITMASK_OEVE DISP_BIT_IB03 -#define DISP_BITMASK_FR DISP_BIT_IB02 -#define DISP_BITMASK_D1 DISP_BIT_IB01 -#define DISP_BITMASK_D0 DISP_BIT_IB00 -/* DISP_POWER_CTL_2_ADDR Power Control (2) */ -#define DISP_BITMASK_DC4 DISP_BIT_IB15 -#define DISP_BITMASK_DC3 DISP_BIT_IB14 -#define DISP_BITMASK_SAP2 DISP_BIT_IB13 -#define DISP_BITMASK_SAP1 DISP_BIT_IB12 -#define DISP_BITMASK_SAP0 DISP_BIT_IB11 -#define DISP_BITMASK_BT2 DISP_BIT_IB10 -#define DISP_BITMASK_BT1 DISP_BIT_IB09 -#define DISP_BITMASK_BT0 DISP_BIT_IB08 -#define DISP_BITMASK_DC2 DISP_BIT_IB07 -#define DISP_BITMASK_DC1 DISP_BIT_IB06 -#define DISP_BITMASK_DC0 DISP_BIT_IB05 -#define DISP_BITMASK_AP2 DISP_BIT_IB04 -#define DISP_BITMASK_AP1 DISP_BIT_IB03 -#define DISP_BITMASK_AP0 DISP_BIT_IB02 -/* DISP_POWER_CTL_3_ADDR Power Control (3) */ -#define DISP_BITMASK_VGL4 DISP_BIT_IB10 -#define DISP_BITMASK_VGL3 DISP_BIT_IB09 -#define DISP_BITMASK_VGL2 DISP_BIT_IB08 -#define DISP_BITMASK_VGL1 DISP_BIT_IB07 -#define DISP_BITMASK_VGL0 DISP_BIT_IB06 -#define DISP_BITMASK_VGH4 DISP_BIT_IB04 -#define DISP_BITMASK_VGH3 DISP_BIT_IB03 -#define DISP_BITMASK_VGH2 DISP_BIT_IB02 -#define DISP_BITMASK_VGH1 DISP_BIT_IB01 -#define DISP_BITMASK_VGH0 DISP_BIT_IB00 -/* DISP_POWER_CTL_4_ADDR Power Control (4) */ -#define DISP_BITMASK_VC2 DISP_BIT_IB02 -#define DISP_BITMASK_VC1 DISP_BIT_IB01 -#define DISP_BITMASK_VC0 DISP_BIT_IB00 -/* DISP_POWER_CTL_5_ADDR Power Control (5) */ -#define DISP_BITMASK_VRL3 DISP_BIT_IB11 -#define DISP_BITMASK_VRL2 DISP_BIT_IB10 -#define DISP_BITMASK_VRL1 DISP_BIT_IB09 -#define DISP_BITMASK_VRL0 DISP_BIT_IB08 -#define DISP_BITMASK_PON DISP_BIT_IB04 -#define DISP_BITMASK_VRH3 DISP_BIT_IB03 -#define DISP_BITMASK_VRH2 DISP_BIT_IB02 -#define DISP_BITMASK_VRH1 DISP_BIT_IB01 -#define DISP_BITMASK_VRH0 DISP_BIT_IB00 -/* DISP_POWER_CTL_6_ADDR Power Control (6) */ -#define DISP_BITMASK_VCOMG DISP_BIT_IB13 -#define DISP_BITMASK_VDV4 DISP_BIT_IB12 -#define DISP_BITMASK_VDV3 DISP_BIT_IB11 -#define DISP_BITMASK_VDV2 DISP_BIT_IB10 -#define DISP_BITMASK_VDV1 DISP_BIT_IB09 -#define DISP_BITMASK_VDV0 DISP_BIT_IB08 -#define DISP_BITMASK_VCM4 DISP_BIT_IB04 -#define DISP_BITMASK_VCM3 DISP_BIT_IB03 -#define DISP_BITMASK_VCM2 DISP_BIT_IB02 -#define DISP_BITMASK_VCM1 DISP_BIT_IB01 -#define DISP_BITMASK_VCM0 DISP_BIT_IB00 -/* RAM Access */ -/* DISP_RAM_ADDR_SET_1_ADDR RAM Address Set (1) */ -#define DISP_BITMASK_AD7 DISP_BIT_IB07 -#define DISP_BITMASK_AD6 DISP_BIT_IB06 -#define DISP_BITMASK_AD5 DISP_BIT_IB05 -#define DISP_BITMASK_AD4 DISP_BIT_IB04 -#define DISP_BITMASK_AD3 DISP_BIT_IB03 -#define DISP_BITMASK_AD2 DISP_BIT_IB02 -#define DISP_BITMASK_AD1 DISP_BIT_IB01 -#define DISP_BITMASK_AD0 DISP_BIT_IB00 -/* DISP_RAM_ADDR_SET_2_ADDR RAM Address Set (2) */ -#define DISP_BITMASK_AD16 DISP_BIT_IB08 -#define DISP_BITMASK_AD15 DISP_BIT_IB07 -#define DISP_BITMASK_AD14 DISP_BIT_IB06 -#define DISP_BITMASK_AD13 DISP_BIT_IB05 -#define DISP_BITMASK_AD12 DISP_BIT_IB04 -#define DISP_BITMASK_AD11 DISP_BIT_IB03 -#define DISP_BITMASK_AD10 DISP_BIT_IB02 -#define DISP_BITMASK_AD9 DISP_BIT_IB01 -#define DISP_BITMASK_AD8 DISP_BIT_IB00 -/* - * DISP_CMD_RAMWR RAM Data Read/Write - * Use Data Bit Configuration - */ -/* DISP_RAM_DATA_MASK_1_ADDR RAM Write Data Mask (1) */ -#define DISP_BITMASK_WM11 DISP_BIT_IB13 -#define DISP_BITMASK_WM10 DISP_BIT_IB12 -#define DISP_BITMASK_WM9 DISP_BIT_IB11 -#define DISP_BITMASK_WM8 DISP_BIT_IB10 -#define DISP_BITMASK_WM7 DISP_BIT_IB09 -#define DISP_BITMASK_WM6 DISP_BIT_IB08 -#define DISP_BITMASK_WM5 DISP_BIT_IB05 -#define DISP_BITMASK_WM4 DISP_BIT_IB04 -#define DISP_BITMASK_WM3 DISP_BIT_IB03 -#define DISP_BITMASK_WM2 DISP_BIT_IB02 -#define DISP_BITMASK_WM1 DISP_BIT_IB01 -#define DISP_BITMASK_WM0 DISP_BIT_IB00 -/* DISP_RAM_DATA_MASK_2_ADDR RAM Write Data Mask (2) */ -#define DISP_BITMASK_WM17 DISP_BIT_IB05 -#define DISP_BITMASK_WM16 DISP_BIT_IB04 -#define DISP_BITMASK_WM15 DISP_BIT_IB03 -#define DISP_BITMASK_WM14 DISP_BIT_IB02 -#define DISP_BITMASK_WM13 DISP_BIT_IB01 -#define DISP_BITMASK_WM12 DISP_BIT_IB00 -/*Gamma Control */ -/* DISP_GAMMA_CONTROL_1_ADDR Gamma Control (1) */ -#define DISP_BITMASK_PKP12 DISP_BIT_IB10 -#define DISP_BITMASK_PKP11 DISP_BIT_IB08 -#define DISP_BITMASK_PKP10 DISP_BIT_IB09 -#define DISP_BITMASK_PKP02 DISP_BIT_IB02 -#define DISP_BITMASK_PKP01 DISP_BIT_IB01 -#define DISP_BITMASK_PKP00 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_2_ADDR Gamma Control (2) */ -#define DISP_BITMASK_PKP32 DISP_BIT_IB10 -#define DISP_BITMASK_PKP31 DISP_BIT_IB09 -#define DISP_BITMASK_PKP30 DISP_BIT_IB08 -#define DISP_BITMASK_PKP22 DISP_BIT_IB02 -#define DISP_BITMASK_PKP21 DISP_BIT_IB01 -#define DISP_BITMASK_PKP20 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_3_ADDR Gamma Control (3) */ -#define DISP_BITMASK_PKP52 DISP_BIT_IB10 -#define DISP_BITMASK_PKP51 DISP_BIT_IB09 -#define DISP_BITMASK_PKP50 DISP_BIT_IB08 -#define DISP_BITMASK_PKP42 DISP_BIT_IB02 -#define DISP_BITMASK_PKP41 DISP_BIT_IB01 -#define DISP_BITMASK_PKP40 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_4_ADDR Gamma Control (4) */ -#define DISP_BITMASK_PRP12 DISP_BIT_IB10 -#define DISP_BITMASK_PRP11 DISP_BIT_IB08 -#define DISP_BITMASK_PRP10 DISP_BIT_IB09 -#define DISP_BITMASK_PRP02 DISP_BIT_IB02 -#define DISP_BITMASK_PRP01 DISP_BIT_IB01 -#define DISP_BITMASK_PRP00 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_5_ADDR Gamma Control (5) */ -#define DISP_BITMASK_VRP14 DISP_BIT_IB12 -#define DISP_BITMASK_VRP13 DISP_BIT_IB11 -#define DISP_BITMASK_VRP12 DISP_BIT_IB10 -#define DISP_BITMASK_VRP11 DISP_BIT_IB08 -#define DISP_BITMASK_VRP10 DISP_BIT_IB09 -#define DISP_BITMASK_VRP03 DISP_BIT_IB03 -#define DISP_BITMASK_VRP02 DISP_BIT_IB02 -#define DISP_BITMASK_VRP01 DISP_BIT_IB01 -#define DISP_BITMASK_VRP00 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_6_ADDR Gamma Control (6) */ -#define DISP_BITMASK_PKN12 DISP_BIT_IB10 -#define DISP_BITMASK_PKN11 DISP_BIT_IB08 -#define DISP_BITMASK_PKN10 DISP_BIT_IB09 -#define DISP_BITMASK_PKN02 DISP_BIT_IB02 -#define DISP_BITMASK_PKN01 DISP_BIT_IB01 -#define DISP_BITMASK_PKN00 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_7_ADDR Gamma Control (7) */ -#define DISP_BITMASK_PKN32 DISP_BIT_IB10 -#define DISP_BITMASK_PKN31 DISP_BIT_IB08 -#define DISP_BITMASK_PKN30 DISP_BIT_IB09 -#define DISP_BITMASK_PKN22 DISP_BIT_IB02 -#define DISP_BITMASK_PKN21 DISP_BIT_IB01 -#define DISP_BITMASK_PKN20 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_8_ADDR Gamma Control (8) */ -#define DISP_BITMASK_PKN52 DISP_BIT_IB10 -#define DISP_BITMASK_PKN51 DISP_BIT_IB08 -#define DISP_BITMASK_PKN50 DISP_BIT_IB09 -#define DISP_BITMASK_PKN42 DISP_BIT_IB02 -#define DISP_BITMASK_PKN41 DISP_BIT_IB01 -#define DISP_BITMASK_PKN40 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_9_ADDR Gamma Control (9) */ -#define DISP_BITMASK_PRN12 DISP_BIT_IB10 -#define DISP_BITMASK_PRN11 DISP_BIT_IB08 -#define DISP_BITMASK_PRN10 DISP_BIT_IB09 -#define DISP_BITMASK_PRN02 DISP_BIT_IB02 -#define DISP_BITMASK_PRN01 DISP_BIT_IB01 -#define DISP_BITMASK_PRN00 DISP_BIT_IB00 -/* DISP_GAMMA_CONTROL_10_ADDR Gamma Control (10) */ -#define DISP_BITMASK_VRN14 DISP_BIT_IB12 -#define DISP_BITMASK_VRN13 DISP_BIT_IB11 -#define DISP_BITMASK_VRN12 DISP_BIT_IB10 -#define DISP_BITMASK_VRN11 DISP_BIT_IB08 -#define DISP_BITMASK_VRN10 DISP_BIT_IB09 -#define DISP_BITMASK_VRN03 DISP_BIT_IB03 -#define DISP_BITMASK_VRN02 DISP_BIT_IB02 -#define DISP_BITMASK_VRN01 DISP_BIT_IB01 -#define DISP_BITMASK_VRN00 DISP_BIT_IB00 -/* Coordinate Control */ -/* DISP_VERT_SCROLL_CTL_1_ADDR Vertical Scroll Control (1) */ -#define DISP_BITMASK_VL18 DISP_BIT_IB08 -#define DISP_BITMASK_VL17 DISP_BIT_IB07 -#define DISP_BITMASK_VL16 DISP_BIT_IB06 -#define DISP_BITMASK_VL15 DISP_BIT_IB05 -#define DISP_BITMASK_VL14 DISP_BIT_IB04 -#define DISP_BITMASK_VL13 DISP_BIT_IB03 -#define DISP_BITMASK_VL12 DISP_BIT_IB02 -#define DISP_BITMASK_VL11 DISP_BIT_IB01 -#define DISP_BITMASK_VL10 DISP_BIT_IB00 -/* DISP_VERT_SCROLL_CTL_2_ADDR Vertical Scroll Control (2) */ -#define DISP_BITMASK_VL28 DISP_BIT_IB08 -#define DISP_BITMASK_VL27 DISP_BIT_IB07 -#define DISP_BITMASK_VL26 DISP_BIT_IB06 -#define DISP_BITMASK_VL25 DISP_BIT_IB05 -#define DISP_BITMASK_VL24 DISP_BIT_IB04 -#define DISP_BITMASK_VL23 DISP_BIT_IB03 -#define DISP_BITMASK_VL22 DISP_BIT_IB02 -#define DISP_BITMASK_VL21 DISP_BIT_IB01 -#define DISP_BITMASK_VL20 DISP_BIT_IB00 -/* DISP_SCREEN_1_DRV_POS_1_ADDR First Screen Driving Position (1) */ -#define DISP_BITMASK_SS18 DISP_BIT_IB08 -#define DISP_BITMASK_SS17 DISP_BIT_IB07 -#define DISP_BITMASK_SS16 DISP_BIT_IB06 -#define DISP_BITMASK_SS15 DISP_BIT_IB05 -#define DISP_BITMASK_SS14 DISP_BIT_IB04 -#define DISP_BITMASK_SS13 DISP_BIT_IB03 -#define DISP_BITMASK_SS12 DISP_BIT_IB02 -#define DISP_BITMASK_SS11 DISP_BIT_IB01 -#define DISP_BITMASK_SS10 DISP_BIT_IB00 -/* DISP_SCREEN_1_DRV_POS_2_ADDR First Screen Driving Position (2) */ -#define DISP_BITMASK_SE18 DISP_BIT_IB08 -#define DISP_BITMASK_SE17 DISP_BIT_IB07 -#define DISP_BITMASK_SE16 DISP_BIT_IB06 -#define DISP_BITMASK_SE15 DISP_BIT_IB05 -#define DISP_BITMASK_SE14 DISP_BIT_IB04 -#define DISP_BITMASK_SE13 DISP_BIT_IB03 -#define DISP_BITMASK_SE12 DISP_BIT_IB02 -#define DISP_BITMASK_SE11 DISP_BIT_IB01 -#define DISP_BITMASK_SE10 DISP_BIT_IB00 -/* DISP_SCREEN_2_DRV_POS_1_ADDR Second Screen Driving Position (1) */ -#define DISP_BITMASK_SS28 DISP_BIT_IB08 -#define DISP_BITMASK_SS27 DISP_BIT_IB07 -#define DISP_BITMASK_SS26 DISP_BIT_IB06 -#define DISP_BITMASK_SS25 DISP_BIT_IB05 -#define DISP_BITMASK_SS24 DISP_BIT_IB04 -#define DISP_BITMASK_SS23 DISP_BIT_IB03 -#define DISP_BITMASK_SS22 DISP_BIT_IB02 -#define DISP_BITMASK_SS21 DISP_BIT_IB01 -#define DISP_BITMASK_SS20 DISP_BIT_IB00 -/* DISP_SCREEN_3_DRV_POS_2_ADDR Second Screen Driving Position (2) */ -#define DISP_BITMASK_SE28 DISP_BIT_IB08 -#define DISP_BITMASK_SE27 DISP_BIT_IB07 -#define DISP_BITMASK_SE26 DISP_BIT_IB06 -#define DISP_BITMASK_SE25 DISP_BIT_IB05 -#define DISP_BITMASK_SE24 DISP_BIT_IB04 -#define DISP_BITMASK_SE23 DISP_BIT_IB03 -#define DISP_BITMASK_SE22 DISP_BIT_IB02 -#define DISP_BITMASK_SE21 DISP_BIT_IB01 -#define DISP_BITMASK_SE20 DISP_BIT_IB00 -/* DISP_HORZ_RAM_ADDR_POS_1_ADDR Horizontal RAM Address Position (1) */ -#define DISP_BITMASK_HSA7 DISP_BIT_IB07 -#define DISP_BITMASK_HSA6 DISP_BIT_IB06 -#define DISP_BITMASK_HSA5 DISP_BIT_IB05 -#define DISP_BITMASK_HSA4 DISP_BIT_IB04 -#define DISP_BITMASK_HSA3 DISP_BIT_IB03 -#define DISP_BITMASK_HSA2 DISP_BIT_IB02 -#define DISP_BITMASK_HSA1 DISP_BIT_IB01 -#define DISP_BITMASK_HSA0 DISP_BIT_IB00 -/* DISP_HORZ_RAM_ADDR_POS_2_ADDR Horizontal RAM Address Position (2) */ -#define DISP_BITMASK_HEA7 DISP_BIT_IB07 -#define DISP_BITMASK_HEA6 DISP_BIT_IB06 -#define DISP_BITMASK_HEA5 DISP_BIT_IB05 -#define DISP_BITMASK_HEA4 DISP_BIT_IB04 -#define DISP_BITMASK_HEA3 DISP_BIT_IB03 -#define DISP_BITMASK_HEA2 DISP_BIT_IB02 -#define DISP_BITMASK_HEA1 DISP_BIT_IB01 -#define DISP_BITMASK_HEA0 DISP_BIT_IB00 -/* DISP_VERT_RAM_ADDR_POS_1_ADDR Vertical RAM Address Position (1) */ -#define DISP_BITMASK_VSA8 DISP_BIT_IB08 -#define DISP_BITMASK_VSA7 DISP_BIT_IB07 -#define DISP_BITMASK_VSA6 DISP_BIT_IB06 -#define DISP_BITMASK_VSA5 DISP_BIT_IB05 -#define DISP_BITMASK_VSA4 DISP_BIT_IB04 -#define DISP_BITMASK_VSA3 DISP_BIT_IB03 -#define DISP_BITMASK_VSA2 DISP_BIT_IB02 -#define DISP_BITMASK_VSA1 DISP_BIT_IB01 -#define DISP_BITMASK_VSA0 DISP_BIT_IB00 -/* DISP_VERT_RAM_ADDR_POS_2_ADDR Vertical RAM Address Position (2) */ -#define DISP_BITMASK_VEA8 DISP_BIT_IB08 -#define DISP_BITMASK_VEA7 DISP_BIT_IB07 -#define DISP_BITMASK_VEA6 DISP_BIT_IB06 -#define DISP_BITMASK_VEA5 DISP_BIT_IB05 -#define DISP_BITMASK_VEA4 DISP_BIT_IB04 -#define DISP_BITMASK_VEA3 DISP_BIT_IB03 -#define DISP_BITMASK_VEA2 DISP_BIT_IB02 -#define DISP_BITMASK_VEA1 DISP_BIT_IB01 -#define DISP_BITMASK_VEA0 DISP_BIT_IB00 -static word disp_area_start_row; -static word disp_area_end_row; -static boolean disp_initialized = FALSE; -/* For some reason the contrast set at init time is not good. Need to do -* it again -*/ -static boolean display_on = FALSE; - -static uint32 tmd20qvga_lcd_rev; -uint16 tmd20qvga_panel_offset; - -#ifdef DISP_DEVICE_8BPP -static word convert_8_to_16_tbl[256] = { - 0x0000, 0x2000, 0x4000, 0x6000, 0x8000, 0xA000, 0xC000, 0xE000, - 0x0100, 0x2100, 0x4100, 0x6100, 0x8100, 0xA100, 0xC100, 0xE100, - 0x0200, 0x2200, 0x4200, 0x6200, 0x8200, 0xA200, 0xC200, 0xE200, - 0x0300, 0x2300, 0x4300, 0x6300, 0x8300, 0xA300, 0xC300, 0xE300, - 0x0400, 0x2400, 0x4400, 0x6400, 0x8400, 0xA400, 0xC400, 0xE400, - 0x0500, 0x2500, 0x4500, 0x6500, 0x8500, 0xA500, 0xC500, 0xE500, - 0x0600, 0x2600, 0x4600, 0x6600, 0x8600, 0xA600, 0xC600, 0xE600, - 0x0700, 0x2700, 0x4700, 0x6700, 0x8700, 0xA700, 0xC700, 0xE700, - 0x0008, 0x2008, 0x4008, 0x6008, 0x8008, 0xA008, 0xC008, 0xE008, - 0x0108, 0x2108, 0x4108, 0x6108, 0x8108, 0xA108, 0xC108, 0xE108, - 0x0208, 0x2208, 0x4208, 0x6208, 0x8208, 0xA208, 0xC208, 0xE208, - 0x0308, 0x2308, 0x4308, 0x6308, 0x8308, 0xA308, 0xC308, 0xE308, - 0x0408, 0x2408, 0x4408, 0x6408, 0x8408, 0xA408, 0xC408, 0xE408, - 0x0508, 0x2508, 0x4508, 0x6508, 0x8508, 0xA508, 0xC508, 0xE508, - 0x0608, 0x2608, 0x4608, 0x6608, 0x8608, 0xA608, 0xC608, 0xE608, - 0x0708, 0x2708, 0x4708, 0x6708, 0x8708, 0xA708, 0xC708, 0xE708, - 0x0010, 0x2010, 0x4010, 0x6010, 0x8010, 0xA010, 0xC010, 0xE010, - 0x0110, 0x2110, 0x4110, 0x6110, 0x8110, 0xA110, 0xC110, 0xE110, - 0x0210, 0x2210, 0x4210, 0x6210, 0x8210, 0xA210, 0xC210, 0xE210, - 0x0310, 0x2310, 0x4310, 0x6310, 0x8310, 0xA310, 0xC310, 0xE310, - 0x0410, 0x2410, 0x4410, 0x6410, 0x8410, 0xA410, 0xC410, 0xE410, - 0x0510, 0x2510, 0x4510, 0x6510, 0x8510, 0xA510, 0xC510, 0xE510, - 0x0610, 0x2610, 0x4610, 0x6610, 0x8610, 0xA610, 0xC610, 0xE610, - 0x0710, 0x2710, 0x4710, 0x6710, 0x8710, 0xA710, 0xC710, 0xE710, - 0x0018, 0x2018, 0x4018, 0x6018, 0x8018, 0xA018, 0xC018, 0xE018, - 0x0118, 0x2118, 0x4118, 0x6118, 0x8118, 0xA118, 0xC118, 0xE118, - 0x0218, 0x2218, 0x4218, 0x6218, 0x8218, 0xA218, 0xC218, 0xE218, - 0x0318, 0x2318, 0x4318, 0x6318, 0x8318, 0xA318, 0xC318, 0xE318, - 0x0418, 0x2418, 0x4418, 0x6418, 0x8418, 0xA418, 0xC418, 0xE418, - 0x0518, 0x2518, 0x4518, 0x6518, 0x8518, 0xA518, 0xC518, 0xE518, - 0x0618, 0x2618, 0x4618, 0x6618, 0x8618, 0xA618, 0xC618, 0xE618, - 0x0718, 0x2718, 0x4718, 0x6718, 0x8718, 0xA718, 0xC718, 0xE718 -}; -#endif /* DISP_DEVICE_8BPP */ - -static void tmd20qvga_disp_set_rect(int x, int y, int xres, int yres); -static void tmd20qvga_disp_init(struct platform_device *pdev); -static void tmd20qvga_disp_set_contrast(void); -static void tmd20qvga_disp_set_display_area(word start_row, word end_row); -static int tmd20qvga_disp_off(struct platform_device *pdev); -static int tmd20qvga_disp_on(struct platform_device *pdev); -static void tmd20qvga_set_revId(int); - -/* future use */ -void tmd20qvga_disp_clear_screen_area(word start_row, word end_row, - word start_column, word end_column); - -static void tmd20qvga_set_revId(int id) -{ - - tmd20qvga_lcd_rev = id; - - if (tmd20qvga_lcd_rev == 1) - tmd20qvga_panel_offset = 0x10; - else - tmd20qvga_panel_offset = 0; -} - -static void tmd20qvga_disp_init(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - if (disp_initialized) - return; - - mfd = platform_get_drvdata(pdev); - - DISP_CMD_PORT = mfd->cmd_port; - DISP_DATA_PORT = mfd->data_port; - -#ifdef TMD20QVGA_LCD_18BPP - tmd20qvga_set_revId(2); -#else - tmd20qvga_set_revId(1); -#endif - - disp_initialized = TRUE; - tmd20qvga_disp_set_contrast(); - tmd20qvga_disp_set_display_area(0, QVGA_HEIGHT - 1); -} - -static void tmd20qvga_disp_set_rect(int x, int y, int xres, int yres) -{ - if (!disp_initialized) - return; - - DISP_SET_RECT(y, y + yres - 1, x, x + xres - 1); - - DISP_CMD_OUT(DISP_CMD_RAMWR); -} - -static void tmd20qvga_disp_set_display_area(word start_row, word end_row) -{ - word start_driving = start_row; - word end_driving = end_row; - - if (!disp_initialized) - return; - - /* Range checking - */ - if (end_driving >= QVGA_HEIGHT) - end_driving = QVGA_HEIGHT - 1; - if (start_driving > end_driving) { - /* Probably Backwards Switch */ - start_driving = end_driving; - end_driving = start_row; /* Has not changed */ - if (end_driving >= QVGA_HEIGHT) - end_driving = QVGA_HEIGHT - 1; - } - - if ((start_driving == disp_area_start_row) - && (end_driving == disp_area_end_row)) - return; - - disp_area_start_row = start_driving; - disp_area_end_row = end_driving; - - DISP_WRITE_OUT(DISP_SCREEN_1_DRV_POS_1_ADDR, - DISP_VAL_IF(start_driving & 0x100, - DISP_BITMASK_SS18) | - DISP_VAL_IF(start_driving & 0x080, - DISP_BITMASK_SS17) | - DISP_VAL_IF(start_driving & 0x040, - DISP_BITMASK_SS16) | - DISP_VAL_IF(start_driving & 0x020, - DISP_BITMASK_SS15) | - DISP_VAL_IF(start_driving & 0x010, - DISP_BITMASK_SS14) | - DISP_VAL_IF(start_driving & 0x008, - DISP_BITMASK_SS13) | - DISP_VAL_IF(start_driving & 0x004, - DISP_BITMASK_SS12) | - DISP_VAL_IF(start_driving & 0x002, - DISP_BITMASK_SS11) | - DISP_VAL_IF(start_driving & 0x001, DISP_BITMASK_SS10)); - - DISP_WRITE_OUT(DISP_SCREEN_1_DRV_POS_2_ADDR, - DISP_VAL_IF(end_driving & 0x100, DISP_BITMASK_SE18) | - DISP_VAL_IF(end_driving & 0x080, DISP_BITMASK_SE17) | - DISP_VAL_IF(end_driving & 0x040, DISP_BITMASK_SE16) | - DISP_VAL_IF(end_driving & 0x020, DISP_BITMASK_SE15) | - DISP_VAL_IF(end_driving & 0x010, DISP_BITMASK_SE14) | - DISP_VAL_IF(end_driving & 0x008, DISP_BITMASK_SE13) | - DISP_VAL_IF(end_driving & 0x004, DISP_BITMASK_SE12) | - DISP_VAL_IF(end_driving & 0x002, DISP_BITMASK_SE11) | - DISP_VAL_IF(end_driving & 0x001, DISP_BITMASK_SE10)); -} - -static int tmd20qvga_disp_off(struct platform_device *pdev) -{ - if (!disp_initialized) - tmd20qvga_disp_init(pdev); - - if (display_on) { - if (tmd20qvga_lcd_rev == 2) { - DISP_WRITE_OUT(DISP_POFF_LN_SETTING_ADDR, 0x000A); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0xFFEE); - WAIT_MSEC(40); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0xF812); - WAIT_MSEC(40); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0xE811); - WAIT_MSEC(40); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0xC011); - WAIT_MSEC(40); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x4011); - WAIT_MSEC(20); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x0010); - - } else { - DISP_WRITE_OUT(DISP_POFF_LN_SETTING_ADDR, 0x000F); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x0BFE); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0100); - WAIT_MSEC(40); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x0BED); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0100); - WAIT_MSEC(40); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x00CD); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0100); - WAIT_MSEC(20); - DISP_WRITE_OUT(DISP_START_OSCILLATION_ADDR, 0x0); - } - - DISP_WRITE_OUT(DISP_MODE_SETTING_ADDR, 0x0004); - DISP_WRITE_OUT(DISP_MODE_SETTING_ADDR, 0x0000); - - display_on = FALSE; - } - - return 0; -} - -static int tmd20qvga_disp_on(struct platform_device *pdev) -{ - if (!disp_initialized) - tmd20qvga_disp_init(pdev); - - if (!display_on) { - /* Deep Stand-by -> Stand-by */ - DISP_CMD_OUT(DISP_START_OSCILLATION_ADDR); - WAIT_MSEC(1); - DISP_CMD_OUT(DISP_START_OSCILLATION_ADDR); - WAIT_MSEC(1); - DISP_CMD_OUT(DISP_START_OSCILLATION_ADDR); - WAIT_MSEC(1); - - /* OFF -> Deep Stan-By -> Stand-by */ - /* let's change the state from "Stand-by" to "Sleep" */ - DISP_WRITE_OUT(DISP_MODE_SETTING_ADDR, 0x0005); - WAIT_MSEC(1); - - /* Sleep -> Displaying */ - DISP_WRITE_OUT(DISP_START_OSCILLATION_ADDR, 0x0001); - DISP_WRITE_OUT(DISP_DRIVER_OUTPUT_CTL_ADDR, 0x0127); - DISP_WRITE_OUT(DISP_LCD_DRIVING_SIG_ADDR, 0x200); - /* fast write mode */ - DISP_WRITE_OUT(DISP_ENTRY_MODE_ADDR, 0x0130); - if (tmd20qvga_lcd_rev == 2) - DISP_WRITE_OUT(DISP_TMD_700_ADDR, 0x0003); - /* back porch = 14 + front porch = 2 --> 16 lines */ - if (tmd20qvga_lcd_rev == 2) { -#ifdef TMD20QVGA_LCD_18BPP - /* 256k color */ - DISP_WRITE_OUT(DISP_DISPLAY_CTL_1_ADDR, 0x0000); -#else - /* 65k color */ - DISP_WRITE_OUT(DISP_DISPLAY_CTL_1_ADDR, 0x4000); -#endif - DISP_WRITE_OUT(DISP_DISPLAY_CTL_2_ADDR, 0x0302); - } else { -#ifdef TMD20QVGA_LCD_18BPP - /* 256k color */ - DISP_WRITE_OUT(DISP_DISPLAY_CTL_1_ADDR, 0x0004); -#else - /* 65k color */ - DISP_WRITE_OUT(DISP_DISPLAY_CTL_1_ADDR, 0x4004); -#endif - DISP_WRITE_OUT(DISP_DISPLAY_CTL_2_ADDR, 0x020E); - } - /* 16 bit one transfer */ - if (tmd20qvga_lcd_rev == 2) { - DISP_WRITE_OUT(DISP_EXT_DISPLAY_CTL_1_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_FRAME_CYCLE_CTL_ADDR, 0x0010); - DISP_WRITE_OUT(DISP_LTPS_CTL_1_ADDR, 0x0302); - DISP_WRITE_OUT(DISP_LTPS_CTL_2_ADDR, 0x0102); - DISP_WRITE_OUT(DISP_LTPS_CTL_3_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_TMD_015_ADDR, 0x2000); - - DISP_WRITE_OUT(DISP_AMP_SETTING_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_1_ADDR, 0x0403); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_2_ADDR, 0x0304); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_3_ADDR, 0x0403); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_4_ADDR, 0x0303); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_5_ADDR, 0x0101); - DISP_WRITE_OUT(DISP_TMD_305_ADDR, 0); - - DISP_WRITE_OUT(DISP_SCREEN_1_DRV_POS_1_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_SCREEN_1_DRV_POS_2_ADDR, 0x013F); - - DISP_WRITE_OUT(DISP_POWER_CTL_3_ADDR, 0x077D); - - DISP_WRITE_OUT(DISP_POWER_CTL_4_ADDR, 0x0005); - DISP_WRITE_OUT(DISP_POWER_CTL_5_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_POWER_CTL_6_ADDR, 0x0015); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0xC010); - WAIT_MSEC(1); - - DISP_WRITE_OUT(DISP_POWER_CTL_2_ADDR, 0x0001); - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0xFFFE); - WAIT_MSEC(60); - } else { - DISP_WRITE_OUT(DISP_EXT_DISPLAY_CTL_1_ADDR, 0x0001); - DISP_WRITE_OUT(DISP_FRAME_CYCLE_CTL_ADDR, 0x0010); - DISP_WRITE_OUT(DISP_LTPS_CTL_1_ADDR, 0x0301); - DISP_WRITE_OUT(DISP_LTPS_CTL_2_ADDR, 0x0001); - DISP_WRITE_OUT(DISP_LTPS_CTL_3_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_AMP_SETTING_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_1_ADDR, 0x0507); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_2_ADDR, 0x0405); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_3_ADDR, 0x0607); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_4_ADDR, 0x0502); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_5_ADDR, 0x0301); - DISP_WRITE_OUT(DISP_SCREEN_1_DRV_POS_1_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_SCREEN_1_DRV_POS_2_ADDR, 0x013F); - DISP_WRITE_OUT(DISP_POWER_CTL_3_ADDR, 0x0795); - - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0102); - WAIT_MSEC(1); - - DISP_WRITE_OUT(DISP_POWER_CTL_4_ADDR, 0x0450); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0103); - WAIT_MSEC(1); - - DISP_WRITE_OUT(DISP_POWER_CTL_5_ADDR, 0x0008); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0104); - WAIT_MSEC(1); - - DISP_WRITE_OUT(DISP_POWER_CTL_6_ADDR, 0x0C00); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0105); - WAIT_MSEC(1); - - DISP_WRITE_OUT(DISP_POWER_CTL_7_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0106); - WAIT_MSEC(1); - - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x0801); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0100); - WAIT_MSEC(1); - - DISP_WRITE_OUT(DISP_POWER_CTL_2_ADDR, 0x001F); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0101); - WAIT_MSEC(60); - - DISP_WRITE_OUT(DISP_POWER_CTL_2_ADDR, 0x009F); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0101); - WAIT_MSEC(10); - - DISP_WRITE_OUT(DISP_HORZ_RAM_ADDR_POS_1_ADDR, 0x0010); - DISP_WRITE_OUT(DISP_HORZ_RAM_ADDR_POS_2_ADDR, 0x00FF); - DISP_WRITE_OUT(DISP_VERT_RAM_ADDR_POS_1_ADDR, 0x0000); - DISP_WRITE_OUT(DISP_VERT_RAM_ADDR_POS_2_ADDR, 0x013F); - /* RAM starts at address 0x10 */ - DISP_WRITE_OUT(DISP_RAM_ADDR_SET_1_ADDR, 0x0010); - DISP_WRITE_OUT(DISP_RAM_ADDR_SET_2_ADDR, 0x0000); - - /* lcd controller uses internal clock, not ext. vsync */ - DISP_CMD_OUT(DISP_CMD_RAMWR); - - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x0881); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0100); - WAIT_MSEC(40); - - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x0BE1); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0100); - WAIT_MSEC(40); - - DISP_WRITE_OUT(DISP_POWER_CTL_1_ADDR, 0x0BFF); - DISP_WRITE_OUT(DISP_POWER_SUPPLY_INTF_ADDR, 0x0100); - } - display_on = TRUE; - } - - return 0; -} - -static void tmd20qvga_disp_set_contrast(void) -{ -#if (defined(TMD20QVGA_LCD_18BPP)) - - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_1_ADDR, 0x0403); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_2_ADDR, 0x0302); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_3_ADDR, 0x0403); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_4_ADDR, 0x0303); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_5_ADDR, 0x0F07); - -#else - int newcontrast = 0x46; - - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_1_ADDR, 0x0403); - - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_2_ADDR, - DISP_VAL_IF(newcontrast & 0x0001, DISP_BITMASK_PKP20) | - DISP_VAL_IF(newcontrast & 0x0002, DISP_BITMASK_PKP21) | - DISP_VAL_IF(newcontrast & 0x0004, DISP_BITMASK_PKP22) | - DISP_VAL_IF(newcontrast & 0x0010, DISP_BITMASK_PKP30) | - DISP_VAL_IF(newcontrast & 0x0020, DISP_BITMASK_PKP31) | - DISP_VAL_IF(newcontrast & 0x0040, DISP_BITMASK_PKP32)); - - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_3_ADDR, - DISP_VAL_IF(newcontrast & 0x0010, DISP_BITMASK_PKP40) | - DISP_VAL_IF(newcontrast & 0x0020, DISP_BITMASK_PKP41) | - DISP_VAL_IF(newcontrast & 0x0040, DISP_BITMASK_PKP42) | - DISP_VAL_IF(newcontrast & 0x0001, DISP_BITMASK_PKP50) | - DISP_VAL_IF(newcontrast & 0x0002, DISP_BITMASK_PKP51) | - DISP_VAL_IF(newcontrast & 0x0004, DISP_BITMASK_PKP52)); - - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_4_ADDR, 0x0303); - DISP_WRITE_OUT(DISP_GAMMA_CONTROL_5_ADDR, 0x0F07); - -#endif /* defined(TMD20QVGA_LCD_18BPP) */ - -} /* End disp_set_contrast */ - -void tmd20qvga_disp_clear_screen_area - (word start_row, word end_row, word start_column, word end_column) { - int32 i; - - /* Clear the display screen */ - DISP_SET_RECT(start_row, end_row, start_column, end_column); - DISP_CMD_OUT(DISP_CMD_RAMWR); - i = (end_row - start_row + 1) * (end_column - start_column + 1); - for (; i > 0; i--) - DISP_DATA_OUT_16TO18BPP(0x0); -} - -static int __init tmd20qvga_probe(struct platform_device *pdev) -{ - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = tmd20qvga_probe, - .driver = { - .name = "ebi2_tmd_qvga", - }, -}; - -static struct msm_fb_panel_data tmd20qvga_panel_data = { - .on = tmd20qvga_disp_on, - .off = tmd20qvga_disp_off, - .set_rect = tmd20qvga_disp_set_rect, -}; - -static struct platform_device this_device = { - .name = "ebi2_tmd_qvga", - .id = 0, - .dev = { - .platform_data = &tmd20qvga_panel_data, - } -}; - -static int __init tmd20qvga_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - ret = platform_driver_register(&this_driver); - if (!ret) { - pinfo = &tmd20qvga_panel_data.panel_info; - pinfo->xres = 240; - pinfo->yres = 320; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = EBI2_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0x808000; -#ifdef TMD20QVGA_LCD_18BPP - pinfo->bpp = 18; -#else - pinfo->bpp = 16; -#endif - pinfo->fb_num = 2; - pinfo->lcd.vsync_enable = TRUE; - pinfo->lcd.refx100 = 6000; - pinfo->lcd.v_back_porch = 16; - pinfo->lcd.v_front_porch = 4; - pinfo->lcd.v_pulse_width = 0; - pinfo->lcd.hw_vsync_mode = FALSE; - pinfo->lcd.vsync_notifier_period = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - } - - return ret; -} - -module_init(tmd20qvga_init); - diff --git a/drivers/video/msm/external_common.c b/drivers/video/msm/external_common.c deleted file mode 100644 index 7aeca6e861b96e5b90379f1461f0138579400692..0000000000000000000000000000000000000000 --- a/drivers/video/msm/external_common.c +++ /dev/null @@ -1,2269 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include - -/* #define DEBUG */ -#define DEV_DBG_PREFIX "EXT_COMMON: " - -/* The start of the data block collection within the CEA Extension Version 3 */ -#define DBC_START_OFFSET 4 - -#include "msm_fb.h" -#include "hdmi_msm.h" -#include "external_common.h" -#include "mhl_api.h" - -#include "mdp.h" - -struct external_common_state_type *external_common_state; -EXPORT_SYMBOL(external_common_state); -DEFINE_MUTEX(external_common_state_hpd_mutex); -EXPORT_SYMBOL(external_common_state_hpd_mutex); - - -static int atoi(const char *name) -{ - int val = 0; - - for (;; name++) { - switch (*name) { - case '0' ... '9': - val = 10*val+(*name-'0'); - break; - default: - return val; - } - } -} - -#ifdef DEBUG_EDID -/* - * Block 0 - 1920x1080p, 1360x768p - * Block 1 - 1280x720p, 1920x540i, 720x480p - */ -const char edid_blk0[0x100] = { -0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x4C, 0x2D, 0x03, 0x05, 0x00, -0x00, 0x00, 0x00, 0x30, 0x12, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78, 0x0A, 0xEE, -0x91, 0xA3, 0x54, 0x4C, 0x99, 0x26, 0x0F, 0x50, 0x54, 0xBD, 0xEF, 0x80, 0x71, -0x4F, 0x81, 0x00, 0x81, 0x40, 0x81, 0x80, 0x95, 0x00, 0x95, 0x0F, 0xB3, 0x00, -0xA9, 0x40, 0x02, 0x3A, 0x80, 0x18, 0x71, 0x38, 0x2D, 0x40, 0x58, 0x2C, 0x45, -0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x66, 0x21, 0x50, 0xB0, 0x51, 0x00, -0x1B, 0x30, 0x40, 0x70, 0x36, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x00, -0x00, 0x00, 0xFD, 0x00, 0x18, 0x4B, 0x1A, 0x51, 0x17, 0x00, 0x0A, 0x20, 0x20, -0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x53, 0x41, 0x4D, 0x53, -0x55, 0x4E, 0x47, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x8F}; - -const char edid_blk1[0x100] = { -0x02, 0x03, 0x1E, 0xF1, 0x46, 0x90, 0x04, 0x05, 0x03, 0x20, 0x22, 0x23, 0x09, -0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0xE2, 0x00, 0x0F, 0x67, 0x03, 0x0C, 0x00, -0x10, 0x00, 0xB8, 0x2D, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0, 0x1E, 0x20, 0x6E, -0x28, 0x55, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x80, 0x18, -0x71, 0x1C, 0x16, 0x20, 0x58, 0x2C, 0x25, 0x00, 0xA0, 0x5A, 0x00, 0x00, 0x00, -0x9E, 0x8C, 0x0A, 0xD0, 0x8A, 0x20, 0xE0, 0x2D, 0x10, 0x10, 0x3E, 0x96, 0x00, -0xA0, 0x5A, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDF}; -#endif /* DEBUG_EDID */ - -#define DMA_E_BASE 0xB0000 -void mdp_vid_quant_set(void) -{ - if ((external_common_state->video_resolution == \ - HDMI_VFRMT_720x480p60_4_3) || \ - (external_common_state->video_resolution == \ - HDMI_VFRMT_720x480p60_16_9)) { - MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x70, 0x00EB0010); - MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x74, 0x00EB0010); - MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x78, 0x00EB0010); - } else { - MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x70, 0x00FF0000); - MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x74, 0x00FF0000); - MDP_OUTP(MDP_BASE + DMA_E_BASE + 0x78, 0x00FF0000); - } -} - -const char *video_format_2string(uint32 format) -{ - switch (format) { - default: -#ifdef CONFIG_FB_MSM_HDMI_COMMON - case HDMI_VFRMT_640x480p60_4_3: return " 640x 480 p60 4/3"; - case HDMI_VFRMT_720x480p60_4_3: return " 720x 480 p60 4/3"; - case HDMI_VFRMT_720x480p60_16_9: return " 720x 480 p60 16/9"; - case HDMI_VFRMT_1280x720p60_16_9: return "1280x 720 p60 16/9"; - case HDMI_VFRMT_1920x1080i60_16_9: return "1920x1080 i60 16/9"; - case HDMI_VFRMT_1440x480i60_4_3: return "1440x 480 i60 4/3"; - case HDMI_VFRMT_1440x480i60_16_9: return "1440x 480 i60 16/9"; - case HDMI_VFRMT_1440x240p60_4_3: return "1440x 240 p60 4/3"; - case HDMI_VFRMT_1440x240p60_16_9: return "1440x 240 p60 16/9"; - case HDMI_VFRMT_2880x480i60_4_3: return "2880x 480 i60 4/3"; - case HDMI_VFRMT_2880x480i60_16_9: return "2880x 480 i60 16/9"; - case HDMI_VFRMT_2880x240p60_4_3: return "2880x 240 p60 4/3"; - case HDMI_VFRMT_2880x240p60_16_9: return "2880x 240 p60 16/9"; - case HDMI_VFRMT_1440x480p60_4_3: return "1440x 480 p60 4/3"; - case HDMI_VFRMT_1440x480p60_16_9: return "1440x 480 p60 16/9"; - case HDMI_VFRMT_1920x1080p60_16_9: return "1920x1080 p60 16/9"; - case HDMI_VFRMT_720x576p50_4_3: return " 720x 576 p50 4/3"; - case HDMI_VFRMT_720x576p50_16_9: return " 720x 576 p50 16/9"; - case HDMI_VFRMT_1280x720p50_16_9: return "1280x 720 p50 16/9"; - case HDMI_VFRMT_1920x1080i50_16_9: return "1920x1080 i50 16/9"; - case HDMI_VFRMT_1440x576i50_4_3: return "1440x 576 i50 4/3"; - case HDMI_VFRMT_1440x576i50_16_9: return "1440x 576 i50 16/9"; - case HDMI_VFRMT_1440x288p50_4_3: return "1440x 288 p50 4/3"; - case HDMI_VFRMT_1440x288p50_16_9: return "1440x 288 p50 16/9"; - case HDMI_VFRMT_2880x576i50_4_3: return "2880x 576 i50 4/3"; - case HDMI_VFRMT_2880x576i50_16_9: return "2880x 576 i50 16/9"; - case HDMI_VFRMT_2880x288p50_4_3: return "2880x 288 p50 4/3"; - case HDMI_VFRMT_2880x288p50_16_9: return "2880x 288 p50 16/9"; - case HDMI_VFRMT_1440x576p50_4_3: return "1440x 576 p50 4/3"; - case HDMI_VFRMT_1440x576p50_16_9: return "1440x 576 p50 16/9"; - case HDMI_VFRMT_1920x1080p50_16_9: return "1920x1080 p50 16/9"; - case HDMI_VFRMT_1920x1080p24_16_9: return "1920x1080 p24 16/9"; - case HDMI_VFRMT_1920x1080p25_16_9: return "1920x1080 p25 16/9"; - case HDMI_VFRMT_1920x1080p30_16_9: return "1920x1080 p30 16/9"; - case HDMI_VFRMT_2880x480p60_4_3: return "2880x 480 p60 4/3"; - case HDMI_VFRMT_2880x480p60_16_9: return "2880x 480 p60 16/9"; - case HDMI_VFRMT_2880x576p50_4_3: return "2880x 576 p50 4/3"; - case HDMI_VFRMT_2880x576p50_16_9: return "2880x 576 p50 16/9"; - case HDMI_VFRMT_1920x1250i50_16_9: return "1920x1250 i50 16/9"; - case HDMI_VFRMT_1920x1080i100_16_9:return "1920x1080 i100 16/9"; - case HDMI_VFRMT_1280x720p100_16_9: return "1280x 720 p100 16/9"; - case HDMI_VFRMT_720x576p100_4_3: return " 720x 576 p100 4/3"; - case HDMI_VFRMT_720x576p100_16_9: return " 720x 576 p100 16/9"; - case HDMI_VFRMT_1440x576i100_4_3: return "1440x 576 i100 4/3"; - case HDMI_VFRMT_1440x576i100_16_9: return "1440x 576 i100 16/9"; - case HDMI_VFRMT_1920x1080i120_16_9:return "1920x1080 i120 16/9"; - case HDMI_VFRMT_1280x720p120_16_9: return "1280x 720 p120 16/9"; - case HDMI_VFRMT_720x480p120_4_3: return " 720x 480 p120 4/3"; - case HDMI_VFRMT_720x480p120_16_9: return " 720x 480 p120 16/9"; - case HDMI_VFRMT_1440x480i120_4_3: return "1440x 480 i120 4/3"; - case HDMI_VFRMT_1440x480i120_16_9: return "1440x 480 i120 16/9"; - case HDMI_VFRMT_720x576p200_4_3: return " 720x 576 p200 4/3"; - case HDMI_VFRMT_720x576p200_16_9: return " 720x 576 p200 16/9"; - case HDMI_VFRMT_1440x576i200_4_3: return "1440x 576 i200 4/3"; - case HDMI_VFRMT_1440x576i200_16_9: return "1440x 576 i200 16/9"; - case HDMI_VFRMT_720x480p240_4_3: return " 720x 480 p240 4/3"; - case HDMI_VFRMT_720x480p240_16_9: return " 720x 480 p240 16/9"; - case HDMI_VFRMT_1440x480i240_4_3: return "1440x 480 i240 4/3"; - case HDMI_VFRMT_1440x480i240_16_9: return "1440x 480 i240 16/9"; -#elif defined(CONFIG_FB_MSM_TVOUT) - case TVOUT_VFRMT_NTSC_M_720x480i: return "NTSC_M_720x480i"; - case TVOUT_VFRMT_NTSC_J_720x480i: return "NTSC_J_720x480i"; - case TVOUT_VFRMT_PAL_BDGHIN_720x576i: return "PAL_BDGHIN_720x576i"; - case TVOUT_VFRMT_PAL_M_720x480i: return "PAL_M_720x480i"; - case TVOUT_VFRMT_PAL_N_720x480i: return "PAL_N_720x480i"; -#endif - - } -} -EXPORT_SYMBOL(video_format_2string); - -static ssize_t external_common_rda_video_mode_str(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n", - video_format_2string(external_common_state->video_resolution)); - DEV_DBG("%s: '%s'\n", __func__, - video_format_2string(external_common_state->video_resolution)); - return ret; -} - -#ifdef CONFIG_FB_MSM_HDMI_COMMON -struct hdmi_disp_mode_timing_type - hdmi_common_supported_video_mode_lut[HDMI_VFRMT_MAX] = { - HDMI_SETTINGS_640x480p60_4_3, - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p24_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p25_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p30_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1250i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x1024p60_5_4) -}; -EXPORT_SYMBOL(hdmi_common_supported_video_mode_lut); - -struct hdmi_disp_mode_timing_type - hdmi_mhl_supported_video_mode_lut[HDMI_VFRMT_MAX] = { - HDMI_SETTINGS_640x480p60_4_3, - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p60_16_9), - HDMI_SETTINGS_1280x720p60_16_9, - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x240p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480i60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x240p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x288p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x288p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080p50_16_9), - HDMI_SETTINGS_1920x1080p24_16_9, - HDMI_SETTINGS_1920x1080p25_16_9, - HDMI_SETTINGS_1920x1080p30_16_9, - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x480p60_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_2880x576p50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1250i50_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i100_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1920x1080i120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1280x720p120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i120_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x576p200_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x576i200_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_720x480p240_16_9), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_4_3), - VFRMT_NOT_SUPPORTED(HDMI_VFRMT_1440x480i240_16_9), - HDMI_SETTINGS_1280x1024p60_5_4 -}; -EXPORT_SYMBOL(hdmi_mhl_supported_video_mode_lut); - -static ssize_t hdmi_common_rda_edid_modes(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = 0; - int i; - - buf[0] = 0; - if (external_common_state->disp_mode_list.num_of_elements) { - uint32 *video_mode = external_common_state->disp_mode_list - .disp_mode_list; - for (i = 0; i < external_common_state->disp_mode_list - .num_of_elements; ++i) { - if (ret > 0) - ret += snprintf(buf+ret, PAGE_SIZE-ret, ",%d", - *video_mode++ + 1); - else - ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d", - *video_mode++ + 1); - } - } else - ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d", - external_common_state->video_resolution+1); - - DEV_DBG("%s: '%s'\n", __func__, buf); - ret += snprintf(buf+ret, PAGE_SIZE-ret, "\n"); - return ret; -} - -static ssize_t hdmi_common_rda_edid_physical_address(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->physical_address); - - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->physical_address); - return ret; -} - - -static ssize_t hdmi_common_rda_edid_scan_info(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d, %d, %d\n", - external_common_state->pt_scan_info, - external_common_state->it_scan_info, - external_common_state->ce_scan_info); - DEV_DBG("%s: '%s'\n", __func__, buf); - return ret; -} - -static ssize_t hdmi_common_wta_vendor_name(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - uint8 *s = (uint8 *) buf; - uint8 *d = external_common_state->spd_vendor_name; - ssize_t ret = strnlen(buf, PAGE_SIZE); - ret = (ret > 8) ? 8 : ret; - - memset(external_common_state->spd_vendor_name, 0, 8); - while (*s) { - if (*s & 0x60 && *s ^ 0x7f) { - *d = *s; - } else { - /* stop copying if control character found */ - break; - } - - if (++s > (uint8 *) (buf + ret)) - break; - - d++; - } - - DEV_DBG("%s: '%s'\n", __func__, - external_common_state->spd_vendor_name); - - return ret; -} - -static ssize_t hdmi_common_rda_vendor_name(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n", - external_common_state->spd_vendor_name); - DEV_DBG("%s: '%s'\n", __func__, - external_common_state->spd_vendor_name); - - return ret; -} - -static ssize_t hdmi_common_wta_product_description(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - uint8 *s = (uint8 *) buf; - uint8 *d = external_common_state->spd_product_description; - ssize_t ret = strnlen(buf, PAGE_SIZE); - ret = (ret > 16) ? 16 : ret; - - memset(external_common_state->spd_product_description, 0, 16); - while (*s) { - if (*s & 0x60 && *s ^ 0x7f) { - *d = *s; - } else { - /* stop copying if control character found */ - break; - } - - if (++s > (uint8 *) (buf + ret)) - break; - - d++; - } - - DEV_DBG("%s: '%s'\n", __func__, - external_common_state->spd_product_description); - - return ret; -} - -static ssize_t hdmi_common_rda_product_description(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%s\n", - external_common_state->spd_product_description); - DEV_DBG("%s: '%s'\n", __func__, - external_common_state->spd_product_description); - - return ret; -} - -static ssize_t hdmi_common_rda_edid_3d_modes(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = 0; - int i; - char buff_3d[128]; - - buf[0] = 0; - if (external_common_state->disp_mode_list.num_of_elements) { - uint32 *video_mode = external_common_state->disp_mode_list - .disp_mode_list; - uint32 *video_3d_mode = external_common_state->disp_mode_list - .disp_3d_mode_list; - for (i = 0; i < external_common_state->disp_mode_list - .num_of_elements; ++i) { - video_3d_format_2string(*video_3d_mode++, buff_3d); - if (ret > 0) - ret += snprintf(buf+ret, PAGE_SIZE-ret, - ",%d=%s", - *video_mode++ + 1, buff_3d); - else - ret += snprintf(buf+ret, PAGE_SIZE-ret, - "%d=%s", - *video_mode++ + 1, buff_3d); - } - } else - ret += snprintf(buf+ret, PAGE_SIZE-ret, "%d", - external_common_state->video_resolution+1); - - DEV_DBG("%s: '%s'\n", __func__, buf); - ret += snprintf(buf+ret, PAGE_SIZE-ret, "\n"); - return ret; -} - -static ssize_t hdmi_common_rda_hdcp(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->hdcp_active); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->hdcp_active); - return ret; -} - -static ssize_t hdmi_common_rda_hpd(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret; - if (external_common_state->hpd_feature) { - ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->hpd_feature_on); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->hpd_feature_on); - } else { - ret = snprintf(buf, PAGE_SIZE, "-1\n"); - DEV_DBG("%s: 'not supported'\n", __func__); - } - return ret; -} - -static ssize_t hdmi_common_wta_hpd(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int hpd; - if (hdmi_prim_display) - hpd = 1; - else - hpd = atoi(buf); - - if (external_common_state->hpd_feature) { - if (hpd == 0 && external_common_state->hpd_feature_on) { - external_common_state->hpd_feature(0); - external_common_state->hpd_feature_on = 0; - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->hpd_feature_on); - } else if (hpd == 1 && !external_common_state->hpd_feature_on) { - external_common_state->hpd_feature(1); - external_common_state->hpd_feature_on = 1; - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->hpd_feature_on); - } else { - DEV_DBG("%s: '%d' (unchanged)\n", __func__, - external_common_state->hpd_feature_on); - } - } else { - DEV_DBG("%s: 'not supported'\n", __func__); - } - - return ret; -} - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT -/* - * This interface for CEC feature is defined to suit - * the current requirements. However, the actual functionality is - * added to accommodate different interfaces - */ -static ssize_t hdmi_msm_rda_cec(struct device *dev, - struct device_attribute *attr, char *buf) -{ - /* 0x028C CEC_CTRL */ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - (HDMI_INP(0x028C) & BIT(0))); - return ret; -} - -static ssize_t hdmi_msm_wta_cec(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int cec = atoi(buf); - - if (cec != 0) { - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->cec_enabled = true; - hdmi_msm_state->cec_logical_addr = 4; - - /* flush CEC queue */ - hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start; - hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start; - hdmi_msm_state->cec_queue_full = false; - memset(hdmi_msm_state->cec_queue_rd, 0, - sizeof(struct hdmi_msm_cec_msg)*CEC_QUEUE_SIZE); - - mutex_unlock(&hdmi_msm_state_mutex); - hdmi_msm_cec_init(); - hdmi_msm_cec_write_logical_addr( - hdmi_msm_state->cec_logical_addr); - DEV_DBG("CEC enabled\n"); - } else { - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->cec_enabled = false; - hdmi_msm_state->cec_logical_addr = 15; - mutex_unlock(&hdmi_msm_state_mutex); - hdmi_msm_cec_write_logical_addr( - hdmi_msm_state->cec_logical_addr); - /* 0x028C CEC_CTRL */ - HDMI_OUTP(0x028C, 0); - DEV_DBG("CEC disabled\n"); - } - return ret; -} - -static ssize_t hdmi_msm_rda_cec_logical_addr(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret; - - mutex_lock(&hdmi_msm_state_mutex); - ret = snprintf(buf, PAGE_SIZE, "%d\n", - hdmi_msm_state->cec_logical_addr); - mutex_unlock(&hdmi_msm_state_mutex); - return ret; -} - -static ssize_t hdmi_msm_wta_cec_logical_addr(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - -#ifdef DRVR_ONLY_CECT_NO_DAEMON - /* - * Only for testing - */ - hdmi_msm_cec_one_touch_play(); - return 0; -#else - ssize_t ret = strnlen(buf, PAGE_SIZE); - int logical_addr = atoi(buf); - - if (logical_addr < 0 || logical_addr > 15) - return -EINVAL; - - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->cec_logical_addr = logical_addr; - mutex_unlock(&hdmi_msm_state_mutex); - - hdmi_msm_cec_write_logical_addr(logical_addr); - - return ret; -#endif -} - -static ssize_t hdmi_msm_rda_cec_frame(struct device *dev, - struct device_attribute *attr, char *buf) -{ - mutex_lock(&hdmi_msm_state_mutex); - if (hdmi_msm_state->cec_queue_rd == hdmi_msm_state->cec_queue_wr - && !hdmi_msm_state->cec_queue_full) { - mutex_unlock(&hdmi_msm_state_mutex); - DEV_ERR("CEC message queue is empty\n"); - return -EBUSY; - } - memcpy(buf, hdmi_msm_state->cec_queue_rd++, - sizeof(struct hdmi_msm_cec_msg)); - hdmi_msm_state->cec_queue_full = false; - if (hdmi_msm_state->cec_queue_rd == CEC_QUEUE_END) - hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start; - mutex_unlock(&hdmi_msm_state_mutex); - - return sizeof(struct hdmi_msm_cec_msg); -} - -static ssize_t hdmi_msm_wta_cec_frame(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - int i; - int retry = ((struct hdmi_msm_cec_msg *) buf)->retransmit; - - for (i = 0; i < RETRANSMIT_MAX_NUM; i++) { - hdmi_msm_cec_msg_send((struct hdmi_msm_cec_msg *) buf); - if (hdmi_msm_state->cec_frame_wr_status - & CEC_STATUS_WR_ERROR && retry--) { - mutex_lock(&hdmi_msm_state_mutex); - if (hdmi_msm_state->fsm_reset_done) - retry++; - mutex_unlock(&hdmi_msm_state_mutex); - msleep(20); - } else - break; - } - - if (hdmi_msm_state->cec_frame_wr_status & CEC_STATUS_WR_DONE) - return sizeof(struct hdmi_msm_cec_msg); - else - return -EINVAL; -} -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - -static ssize_t hdmi_common_rda_3d_present(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->present_3d); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->present_3d); - return ret; -} - -static ssize_t hdmi_common_rda_hdcp_present(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->present_hdcp); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->present_hdcp); - return ret; -} -#endif - -#ifdef CONFIG_FB_MSM_HDMI_3D -static ssize_t hdmi_3d_rda_format_3d(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->format_3d); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->format_3d); - return ret; -} - -static ssize_t hdmi_3d_wta_format_3d(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int format_3d = atoi(buf); - - if (format_3d >= 0 && format_3d <= 2) { - if (format_3d != external_common_state->format_3d) { - external_common_state->format_3d = format_3d; - if (external_common_state->switch_3d) - external_common_state->switch_3d(format_3d); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->format_3d); - } else { - DEV_DBG("%s: '%d' (unchanged)\n", __func__, - external_common_state->format_3d); - } - } else { - DEV_DBG("%s: '%d' (unknown)\n", __func__, format_3d); - } - - return ret; -} -#endif - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT -static DEVICE_ATTR(cec, S_IRUGO | S_IWUSR, - hdmi_msm_rda_cec, - hdmi_msm_wta_cec); - -static DEVICE_ATTR(cec_logical_addr, S_IRUGO | S_IWUSR, - hdmi_msm_rda_cec_logical_addr, - hdmi_msm_wta_cec_logical_addr); - -static DEVICE_ATTR(cec_rd_frame, S_IRUGO, - hdmi_msm_rda_cec_frame, NULL); - -static DEVICE_ATTR(cec_wr_frame, S_IWUSR, - NULL, hdmi_msm_wta_cec_frame); -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - - -static ssize_t external_common_rda_video_mode(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->video_resolution+1); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->video_resolution+1); - return ret; -} - -static ssize_t external_common_wta_video_mode(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - uint32 video_mode; -#ifdef CONFIG_FB_MSM_HDMI_COMMON - const struct hdmi_disp_mode_timing_type *disp_mode; -#endif - mutex_lock(&external_common_state_hpd_mutex); - if (!external_common_state->hpd_state) { - mutex_unlock(&external_common_state_hpd_mutex); - DEV_INFO("%s: FAILED: display off or cable disconnected\n", - __func__); - return ret; - } - mutex_unlock(&external_common_state_hpd_mutex); - - video_mode = atoi(buf)-1; - DEV_INFO("%s: video_mode is %d\n", __func__, video_mode); - kobject_uevent(external_common_state->uevent_kobj, KOBJ_OFFLINE); -#ifdef CONFIG_FB_MSM_HDMI_COMMON - disp_mode = hdmi_common_get_supported_mode(video_mode); - if (!disp_mode) { - DEV_INFO("%s: FAILED: mode not supported (%d)\n", - __func__, video_mode); - return ret; - } - external_common_state->disp_mode_list.num_of_elements = 1; - external_common_state->disp_mode_list.disp_mode_list[0] = video_mode; -#elif defined(CONFIG_FB_MSM_TVOUT) - external_common_state->video_resolution = video_mode; -#endif - DEV_DBG("%s: 'mode=%d %s' successful (sending OFF/ONLINE)\n", __func__, - video_mode, video_format_2string(video_mode)); - kobject_uevent(external_common_state->uevent_kobj, KOBJ_ONLINE); - return ret; -} - -static ssize_t external_common_rda_connected(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret; - mutex_lock(&external_common_state_hpd_mutex); - ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->hpd_state); - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->hpd_state); - mutex_unlock(&external_common_state_hpd_mutex); - return ret; -} - -static ssize_t external_common_rda_hdmi_mode(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret; - - ret = snprintf(buf, PAGE_SIZE, "%d\n", - external_common_state->hdmi_sink); - - DEV_DBG("%s: '%d'\n", __func__, - external_common_state->hdmi_sink); - - return ret; -} - -static ssize_t hdmi_common_rda_hdmi_primary(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "%d\n", - hdmi_prim_display); - DEV_DBG("%s: '%d'\n", __func__, hdmi_prim_display); - return ret; -} - -static ssize_t hdmi_common_rda_audio_data_block(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int adb_size = 0; - int adb_count = 0; - ssize_t ret = 0; - char *data = buf; - - if (!external_common_state) - return 0; - - adb_count = 1; - adb_size = external_common_state->adb_size; - ret = sizeof(adb_count) + sizeof(adb_size) + adb_size; - - if (ret > PAGE_SIZE) { - DEV_DBG("%s: Insufficient buffer size\n", __func__); - return 0; - } - - /* Currently only extracting one audio data block */ - memcpy(data, &adb_count, sizeof(adb_count)); - data += sizeof(adb_count); - memcpy(data, &adb_size, sizeof(adb_size)); - data += sizeof(adb_size); - memcpy(data, external_common_state->audio_data_block, - external_common_state->adb_size); - - print_hex_dump(KERN_DEBUG, "AUDIO DATA BLOCK: ", DUMP_PREFIX_NONE, - 32, 8, buf, ret, false); - - return ret; -} - -static ssize_t hdmi_common_rda_spkr_alloc_data_block(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int sadb_size = 0; - int sadb_count = 0; - ssize_t ret = 0; - char *data = buf; - - if (!external_common_state) - return 0; - - sadb_count = 1; - sadb_size = external_common_state->sadb_size; - ret = sizeof(sadb_count) + sizeof(sadb_size) + sadb_size; - - if (ret > PAGE_SIZE) { - DEV_DBG("%s: Insufficient buffer size\n", __func__); - return 0; - } - - /* Currently only extracting one speaker allocation data block */ - memcpy(data, &sadb_count, sizeof(sadb_count)); - data += sizeof(sadb_count); - memcpy(data, &sadb_size, sizeof(sadb_size)); - data += sizeof(sadb_size); - memcpy(data, external_common_state->spkr_alloc_data_block, - external_common_state->sadb_size); - - print_hex_dump(KERN_DEBUG, "SPKR ALLOC DATA BLOCK: ", DUMP_PREFIX_NONE, - 32, 8, buf, ret, false); - - return ret; -} - -static DEVICE_ATTR(video_mode, S_IRUGO | S_IWUGO, - external_common_rda_video_mode, external_common_wta_video_mode); -static DEVICE_ATTR(video_mode_str, S_IRUGO, external_common_rda_video_mode_str, - NULL); -static DEVICE_ATTR(connected, S_IRUGO, external_common_rda_connected, NULL); -static DEVICE_ATTR(hdmi_mode, S_IRUGO, external_common_rda_hdmi_mode, NULL); -#ifdef CONFIG_FB_MSM_HDMI_COMMON -static DEVICE_ATTR(edid_modes, S_IRUGO, hdmi_common_rda_edid_modes, NULL); -static DEVICE_ATTR(hpd, S_IRUGO | S_IWUGO, hdmi_common_rda_hpd, - hdmi_common_wta_hpd); -static DEVICE_ATTR(hdcp, S_IRUGO, hdmi_common_rda_hdcp, NULL); -static DEVICE_ATTR(pa, S_IRUGO, - hdmi_common_rda_edid_physical_address, NULL); -static DEVICE_ATTR(scan_info, S_IRUGO, - hdmi_common_rda_edid_scan_info, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO | S_IWUSR, hdmi_common_rda_vendor_name, - hdmi_common_wta_vendor_name); -static DEVICE_ATTR(product_description, S_IRUGO | S_IWUSR, - hdmi_common_rda_product_description, - hdmi_common_wta_product_description); -static DEVICE_ATTR(edid_3d_modes, S_IRUGO, - hdmi_common_rda_edid_3d_modes, NULL); -static DEVICE_ATTR(3d_present, S_IRUGO, hdmi_common_rda_3d_present, NULL); -static DEVICE_ATTR(hdcp_present, S_IRUGO, hdmi_common_rda_hdcp_present, NULL); -#endif -#ifdef CONFIG_FB_MSM_HDMI_3D -static DEVICE_ATTR(format_3d, S_IRUGO | S_IWUGO, hdmi_3d_rda_format_3d, - hdmi_3d_wta_format_3d); -#endif -static DEVICE_ATTR(hdmi_primary, S_IRUGO, hdmi_common_rda_hdmi_primary, NULL); -static DEVICE_ATTR(audio_data_block, S_IRUGO, hdmi_common_rda_audio_data_block, - NULL); -static DEVICE_ATTR(spkr_alloc_data_block, S_IRUGO, - hdmi_common_rda_spkr_alloc_data_block, NULL); - -static struct attribute *external_common_fs_attrs[] = { - &dev_attr_video_mode.attr, - &dev_attr_video_mode_str.attr, - &dev_attr_connected.attr, - &dev_attr_hdmi_mode.attr, -#ifdef CONFIG_FB_MSM_HDMI_COMMON - &dev_attr_edid_modes.attr, - &dev_attr_hdcp.attr, - &dev_attr_hpd.attr, - &dev_attr_pa.attr, - &dev_attr_scan_info.attr, - &dev_attr_vendor_name.attr, - &dev_attr_product_description.attr, - &dev_attr_edid_3d_modes.attr, - &dev_attr_3d_present.attr, - &dev_attr_hdcp_present.attr, -#endif -#ifdef CONFIG_FB_MSM_HDMI_3D - &dev_attr_format_3d.attr, -#endif -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - &dev_attr_cec.attr, - &dev_attr_cec_logical_addr.attr, - &dev_attr_cec_rd_frame.attr, - &dev_attr_cec_wr_frame.attr, -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - &dev_attr_hdmi_primary.attr, - &dev_attr_audio_data_block.attr, - &dev_attr_spkr_alloc_data_block.attr, - NULL, -}; -static struct attribute_group external_common_fs_attr_group = { - .attrs = external_common_fs_attrs, -}; - -/* create external interface kobject and initialize */ -int external_common_state_create(struct platform_device *pdev) -{ - int rc; - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - if (!mfd) { - DEV_ERR("%s: mfd not found\n", __func__); - return -ENODEV; - } - if (!mfd->fbi) { - DEV_ERR("%s: mfd->fbi not found\n", __func__); - return -ENODEV; - } - if (!mfd->fbi->dev) { - DEV_ERR("%s: mfd->fbi->dev not found\n", __func__); - return -ENODEV; - } - rc = sysfs_create_group(&mfd->fbi->dev->kobj, - &external_common_fs_attr_group); - if (rc) { - DEV_ERR("%s: sysfs group creation failed, rc=%d\n", __func__, - rc); - return rc; - } - external_common_state->uevent_kobj = &mfd->fbi->dev->kobj; - DEV_ERR("%s: sysfs group %p\n", __func__, - external_common_state->uevent_kobj); - - kobject_uevent(external_common_state->uevent_kobj, KOBJ_ADD); - DEV_DBG("%s: kobject_uevent(KOBJ_ADD)\n", __func__); - return 0; -} -EXPORT_SYMBOL(external_common_state_create); - -void external_common_state_remove(void) -{ - if (external_common_state->uevent_kobj) - sysfs_remove_group(external_common_state->uevent_kobj, - &external_common_fs_attr_group); - external_common_state->uevent_kobj = NULL; -} -EXPORT_SYMBOL(external_common_state_remove); - -#ifdef CONFIG_FB_MSM_HDMI_COMMON -/* The Logic ID for HDMI TX Core. Currently only support 1 HDMI TX Core. */ -struct hdmi_edid_video_mode_property_type { - uint32 video_code; - uint32 active_h; - uint32 active_v; - boolean interlaced; - uint32 total_h; - uint32 total_blank_h; - uint32 total_v; - uint32 total_blank_v; - /* Must divide by 1000 to get the frequency */ - uint32 freq_h; - /* Must divide by 1000 to get the frequency */ - uint32 freq_v; - /* Must divide by 1000 to get the frequency */ - uint32 pixel_freq; - /* Must divide by 1000 to get the frequency */ - uint32 refresh_rate; - boolean aspect_ratio_4_3; -}; - -/* LUT is sorted from lowest Active H to highest Active H - ease searching */ -static struct hdmi_edid_video_mode_property_type - hdmi_edid_disp_mode_lut[] = { - - /* All 640 H Active */ - {HDMI_VFRMT_640x480p60_4_3, 640, 480, FALSE, 800, 160, 525, 45, - 31465, 59940, 25175, 59940, TRUE}, - {HDMI_VFRMT_640x480p60_4_3, 640, 480, FALSE, 800, 160, 525, 45, - 31500, 60000, 25200, 60000, TRUE}, - - /* All 720 H Active */ - {HDMI_VFRMT_720x576p50_4_3, 720, 576, FALSE, 864, 144, 625, 49, - 31250, 50000, 27000, 50000, TRUE}, - {HDMI_VFRMT_720x480p60_4_3, 720, 480, FALSE, 858, 138, 525, 45, - 31465, 59940, 27000, 59940, TRUE}, - {HDMI_VFRMT_720x480p60_4_3, 720, 480, FALSE, 858, 138, 525, 45, - 31500, 60000, 27030, 60000, TRUE}, - {HDMI_VFRMT_720x576p100_4_3, 720, 576, FALSE, 864, 144, 625, 49, - 62500, 100000, 54000, 100000, TRUE}, - {HDMI_VFRMT_720x480p120_4_3, 720, 480, FALSE, 858, 138, 525, 45, - 62937, 119880, 54000, 119880, TRUE}, - {HDMI_VFRMT_720x480p120_4_3, 720, 480, FALSE, 858, 138, 525, 45, - 63000, 120000, 54054, 120000, TRUE}, - {HDMI_VFRMT_720x576p200_4_3, 720, 576, FALSE, 864, 144, 625, 49, - 125000, 200000, 108000, 200000, TRUE}, - {HDMI_VFRMT_720x480p240_4_3, 720, 480, FALSE, 858, 138, 525, 45, - 125874, 239760, 108000, 239000, TRUE}, - {HDMI_VFRMT_720x480p240_4_3, 720, 480, FALSE, 858, 138, 525, 45, - 126000, 240000, 108108, 240000, TRUE}, - - /* All 1280 H Active */ - {HDMI_VFRMT_1280x720p50_16_9, 1280, 720, FALSE, 1980, 700, 750, 30, - 37500, 50000, 74250, 50000, FALSE}, - {HDMI_VFRMT_1280x720p60_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, - 44955, 59940, 74176, 59940, FALSE}, - {HDMI_VFRMT_1280x720p60_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, - 45000, 60000, 74250, 60000, FALSE}, - {HDMI_VFRMT_1280x720p100_16_9, 1280, 720, FALSE, 1980, 700, 750, 30, - 75000, 100000, 148500, 100000, FALSE}, - {HDMI_VFRMT_1280x720p120_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, - 89909, 119880, 148352, 119880, FALSE}, - {HDMI_VFRMT_1280x720p120_16_9, 1280, 720, FALSE, 1650, 370, 750, 30, - 90000, 120000, 148500, 120000, FALSE}, - {HDMI_VFRMT_1280x1024p60_5_4, 1280, 1024, FALSE, 1688, 408, 1066, 42, - 63981, 60020, 108000, 60000, FALSE}, - - /* All 1440 H Active */ - {HDMI_VFRMT_1440x576i50_4_3, 1440, 576, TRUE, 1728, 288, 625, 24, - 15625, 50000, 27000, 50000, TRUE}, - {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 312, 24, - 15625, 50080, 27000, 50000, TRUE}, - {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 313, 25, - 15625, 49920, 27000, 50000, TRUE}, - {HDMI_VFRMT_720x288p50_4_3, 1440, 288, FALSE, 1728, 288, 314, 26, - 15625, 49761, 27000, 50000, TRUE}, - {HDMI_VFRMT_1440x576p50_4_3, 1440, 576, FALSE, 1728, 288, 625, 49, - 31250, 50000, 54000, 50000, TRUE}, - {HDMI_VFRMT_1440x480i60_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, - 15734, 59940, 27000, 59940, TRUE}, - {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 262, 22, - 15734, 60054, 27000, 59940, TRUE}, - {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 263, 23, - 15734, 59826, 27000, 59940, TRUE}, - {HDMI_VFRMT_1440x480p60_4_3, 1440, 480, FALSE, 1716, 276, 525, 45, - 31469, 59940, 54000, 59940, TRUE}, - {HDMI_VFRMT_1440x480i60_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, - 15750, 60000, 27027, 60000, TRUE}, - {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 262, 22, - 15750, 60115, 27027, 60000, TRUE}, - {HDMI_VFRMT_1440x240p60_4_3, 1440, 240, FALSE, 1716, 276, 263, 23, - 15750, 59886, 27027, 60000, TRUE}, - {HDMI_VFRMT_1440x480p60_4_3, 1440, 480, FALSE, 1716, 276, 525, 45, - 31500, 60000, 54054, 60000, TRUE}, - {HDMI_VFRMT_1440x576i100_4_3, 1440, 576, TRUE, 1728, 288, 625, 24, - 31250, 100000, 54000, 100000, TRUE}, - {HDMI_VFRMT_1440x480i120_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, - 31469, 119880, 54000, 119880, TRUE}, - {HDMI_VFRMT_1440x480i120_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, - 31500, 120000, 54054, 120000, TRUE}, - {HDMI_VFRMT_1440x576i200_4_3, 1440, 576, TRUE, 1728, 288, 625, 24, - 62500, 200000, 108000, 200000, TRUE}, - {HDMI_VFRMT_1440x480i240_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, - 62937, 239760, 108000, 239000, TRUE}, - {HDMI_VFRMT_1440x480i240_4_3, 1440, 480, TRUE, 1716, 276, 525, 22, - 63000, 240000, 108108, 240000, TRUE}, - - /* All 1920 H Active */ - {HDMI_VFRMT_1920x1080p60_16_9, 1920, 1080, FALSE, 2200, 280, 1125, - 45, 67433, 59940, 148352, 59940, FALSE}, - {HDMI_VFRMT_1920x1080p60_16_9, 1920, 1080, TRUE, 2200, 280, 1125, - 45, 67500, 60000, 148500, 60000, FALSE}, - {HDMI_VFRMT_1920x1080p50_16_9, 1920, 1080, FALSE, 2640, 720, 1125, - 45, 56250, 50000, 148500, 50000, FALSE}, - {HDMI_VFRMT_1920x1080p24_16_9, 1920, 1080, FALSE, 2750, 830, 1125, - 45, 26973, 23976, 74176, 24000, FALSE}, - {HDMI_VFRMT_1920x1080p24_16_9, 1920, 1080, FALSE, 2750, 830, 1125, - 45, 27000, 24000, 74250, 24000, FALSE}, - {HDMI_VFRMT_1920x1080p25_16_9, 1920, 1080, FALSE, 2640, 720, 1125, - 45, 28125, 25000, 74250, 25000, FALSE}, - {HDMI_VFRMT_1920x1080p30_16_9, 1920, 1080, FALSE, 2200, 280, 1125, - 45, 33716, 29970, 74176, 30000, FALSE}, - {HDMI_VFRMT_1920x1080p30_16_9, 1920, 1080, FALSE, 2200, 280, 1125, - 45, 33750, 30000, 74250, 30000, FALSE}, - {HDMI_VFRMT_1920x1080i50_16_9, 1920, 1080, TRUE, 2304, 384, 1250, - 85, 31250, 50000, 72000, 50000, FALSE}, - {HDMI_VFRMT_1920x1080i60_16_9, 1920, 1080, TRUE, 2200, 280, 1125, - 22, 33716, 59940, 74176, 59940, FALSE}, - {HDMI_VFRMT_1920x1080i60_16_9, 1920, 1080, TRUE, 2200, 280, 1125, - 22, 33750, 60000, 74250, 60000, FALSE}, - {HDMI_VFRMT_1920x1080i100_16_9, 1920, 1080, TRUE, 2640, 720, 1125, - 22, 56250, 100000, 148500, 100000, FALSE}, - {HDMI_VFRMT_1920x1080i120_16_9, 1920, 1080, TRUE, 2200, 280, 1125, - 22, 67432, 119880, 148352, 119980, FALSE}, - {HDMI_VFRMT_1920x1080i120_16_9, 1920, 1080, TRUE, 2200, 280, 1125, - 22, 67500, 120000, 148500, 120000, FALSE}, - - /* All 2880 H Active */ - {HDMI_VFRMT_2880x576i50_4_3, 2880, 576, TRUE, 3456, 576, 625, 24, - 15625, 50000, 54000, 50000, TRUE}, - {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 312, 24, - 15625, 50080, 54000, 50000, TRUE}, - {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 313, 25, - 15625, 49920, 54000, 50000, TRUE}, - {HDMI_VFRMT_2880x288p50_4_3, 2880, 576, FALSE, 3456, 576, 314, 26, - 15625, 49761, 54000, 50000, TRUE}, - {HDMI_VFRMT_2880x576p50_4_3, 2880, 576, FALSE, 3456, 576, 625, 49, - 31250, 50000, 108000, 50000, TRUE}, - {HDMI_VFRMT_2880x480i60_4_3, 2880, 480, TRUE, 3432, 552, 525, 22, - 15734, 59940, 54000, 59940, TRUE}, - {HDMI_VFRMT_2880x240p60_4_3, 2880, 480, FALSE, 3432, 552, 262, 22, - 15734, 60054, 54000, 59940, TRUE}, - {HDMI_VFRMT_2880x240p60_4_3, 2880, 480, FALSE, 3432, 552, 263, 23, - 15734, 59940, 54000, 59940, TRUE}, - {HDMI_VFRMT_2880x480p60_4_3, 2880, 480, FALSE, 3432, 552, 525, 45, - 31469, 59940, 108000, 59940, TRUE}, - {HDMI_VFRMT_2880x480i60_4_3, 2880, 480, TRUE, 3432, 552, 525, 22, - 15750, 60000, 54054, 60000, TRUE}, - {HDMI_VFRMT_2880x240p60_4_3, 2880, 240, FALSE, 3432, 552, 262, 22, - 15750, 60115, 54054, 60000, TRUE}, - {HDMI_VFRMT_2880x240p60_4_3, 2880, 240, FALSE, 3432, 552, 262, 23, - 15750, 59886, 54054, 60000, TRUE}, - {HDMI_VFRMT_2880x480p60_4_3, 2880, 480, FALSE, 3432, 552, 525, 45, - 31500, 60000, 108108, 60000, TRUE}, -}; - -static const uint8 *hdmi_edid_find_block(const uint8 *in_buf, - uint32 start_offset, uint8 type, uint8 *len) -{ - /* the start of data block collection, start of Video Data Block */ - uint32 offset = start_offset; - uint32 end_dbc_offset = in_buf[2]; - - *len = 0; - - /*edid buffer 1, byte 2 being 4 means no non-DTD/Data block collection - present. - edid buffer 1, byte 2 being 0 menas no non-DTD/DATA block collection - present and no DTD data present.*/ - if ((end_dbc_offset == 0) || (end_dbc_offset == 4)) { - DEV_WARN("EDID: no DTD or non-DTD data present\n"); - return NULL; - } - while (offset < end_dbc_offset) { - uint8 block_len = in_buf[offset] & 0x1F; - if ((in_buf[offset] >> 5) == type) { - *len = block_len; - DEV_DBG("EDID: block=%d found @ %d with length=%d\n", - type, offset, block_len); - return in_buf+offset; - } - offset += 1 + block_len; - } - DEV_WARN("EDID: type=%d block not found in EDID block\n", type); - return NULL; -} - -static void hdmi_edid_extract_vendor_id(const uint8 *in_buf, - char *vendor_id) -{ - uint32 id_codes = ((uint32)in_buf[8] << 8) + in_buf[9]; - - vendor_id[0] = 'A' - 1 + ((id_codes >> 10) & 0x1F); - vendor_id[1] = 'A' - 1 + ((id_codes >> 5) & 0x1F); - vendor_id[2] = 'A' - 1 + (id_codes & 0x1F); - vendor_id[3] = 0; -} - -static uint32 hdmi_edid_extract_ieee_reg_id(const uint8 *in_buf) -{ - uint8 len; - const uint8 *vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3, - &len); - - if (vsd == NULL) - return 0; - - DEV_DBG("EDID: VSD PhyAddr=%04x, MaxTMDS=%dMHz\n", - ((uint32)vsd[4] << 8) + (uint32)vsd[5], (uint32)vsd[7] * 5); - external_common_state->physical_address = - ((uint16)vsd[4] << 8) + (uint16)vsd[5]; - return ((uint32)vsd[3] << 16) + ((uint32)vsd[2] << 8) + (uint32)vsd[1]; -} - -#define HDMI_VSDB_3D_DATA_OFFSET(vsd) \ - (!((vsd)[8] & BIT(7)) ? 9 : (!((vsd)[8] & BIT(6)) ? 11 : 13)) - -static void hdmi_edid_extract_3d_present(const uint8 *in_buf) -{ - uint8 len, offset; - const uint8 *vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3, - &len); - - external_common_state->present_3d = 0; - if (vsd == NULL || len < 9) { - DEV_DBG("EDID[3D]: block-id 3 not found or not long enough\n"); - return; - } - - offset = HDMI_VSDB_3D_DATA_OFFSET(vsd); - DEV_DBG("EDID: 3D present @ %d = %02x\n", offset, vsd[offset]); - if (vsd[offset] >> 7) { /* 3D format indication present */ - DEV_INFO("EDID: 3D present, 3D-len=%d\n", vsd[offset+1] & 0x1F); - external_common_state->present_3d = 1; - } -} - - -static void hdmi_edid_extract_latency_fields(const uint8 *in_buf) -{ - uint8 len; - const uint8 *vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3, - &len); - - if (vsd == NULL || len < 12 || !(vsd[8] & BIT(7))) { - external_common_state->video_latency = (uint16)-1; - external_common_state->audio_latency = (uint16)-1; - DEV_DBG("EDID: No audio/video latency present\n"); - } else { - external_common_state->video_latency = vsd[9]; - external_common_state->audio_latency = vsd[10]; - DEV_DBG("EDID: video-latency=%04x, audio-latency=%04x\n", - external_common_state->video_latency, - external_common_state->audio_latency); - } -} - -static void hdmi_edid_extract_speaker_allocation_data(const uint8 *in_buf) -{ - uint8 len; - const uint8 *sadb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 4, - &len); - - if (sadb == NULL) - return; - - if (len != MAX_SPKR_ALLOC_DATA_BLOCK_SIZE) - return; - - memcpy(external_common_state->spkr_alloc_data_block, sadb + 1, len); - external_common_state->sadb_size = len; -} - -static void hdmi_edid_extract_audio_data_blocks(const uint8 *in_buf) -{ - uint8 len; - const uint8 *adb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 1, - &len); - - if (external_common_state->audio_data_block == NULL) - return; - - if (len > MAX_AUDIO_DATA_BLOCK_SIZE) - return; - - memcpy(external_common_state->audio_data_block, adb + 1, len); - external_common_state->adb_size = len; -} - -static void hdmi_edid_extract_extended_data_blocks(const uint8 *in_buf) -{ - uint8 len = 0; - uint32 start_offset = DBC_START_OFFSET; - - /* A Tage code of 7 identifies extended data blocks */ - uint8 const *etag = hdmi_edid_find_block(in_buf, start_offset, 7, &len); - - while (etag != NULL) { - /* The extended data block should at least be 2 bytes long */ - if (len < 2) { - DEV_DBG("EDID: Found an extended data block of length" - "less than 2 bytes. Ignoring ...\n"); - } else { - /* - * The second byte of the extended data block has the - * extended tag code - */ - switch (etag[1]) { - case 0: - /* Video Capability Data Block */ - DEV_DBG("EDID: VCDB=%02X %02X\n", etag[1], - etag[2]); - - /* - * Check if the sink specifies underscan - * support for: - * BIT 5: preferred video format - * BIT 3: IT video format - * BIT 1: CE video format - */ - external_common_state->pt_scan_info = (etag[2] & - (BIT(4) | BIT(5))) >> 4; - external_common_state->it_scan_info = (etag[2] & - (BIT(3) | BIT(2))) >> 2; - external_common_state->ce_scan_info = etag[2] & - (BIT(1) | BIT(0)); - DEV_DBG("EDID: Scan Information (pt|it|ce): " - "(%d|%d|%d)", - external_common_state->pt_scan_info, - external_common_state->it_scan_info, - external_common_state->ce_scan_info); - break; - default: - DEV_DBG("EDID: Extend Tag Code %d not" - "supported\n", etag[1]); - break; - } - } - - /* There could be more that one extended data block */ - start_offset = etag - in_buf + len + 1; - etag = hdmi_edid_find_block(in_buf, start_offset, 7, &len); - } -} - -static void hdmi_edid_detail_desc(const uint8 *data_buf, uint32 *disp_mode) -{ - boolean aspect_ratio_4_3 = FALSE; - boolean interlaced = FALSE; - uint32 active_h = 0; - uint32 active_v = 0; - uint32 blank_h = 0; - uint32 blank_v = 0; - uint32 ndx = 0; - uint32 max_num_of_elements = 0; - uint32 img_size_h = 0; - uint32 img_size_v = 0; - - /* See VESA Spec */ - /* EDID_TIMING_DESC_UPPER_H_NIBBLE[0x4]: Relative Offset to the EDID - * detailed timing descriptors - Upper 4 bit for each H active/blank - * field */ - /* EDID_TIMING_DESC_H_ACTIVE[0x2]: Relative Offset to the EDID detailed - * timing descriptors - H active */ - active_h = ((((uint32)data_buf[0x4] >> 0x4) & 0xF) << 8) - | data_buf[0x2]; - - /* EDID_TIMING_DESC_H_BLANK[0x3]: Relative Offset to the EDID detailed - * timing descriptors - H blank */ - blank_h = (((uint32)data_buf[0x4] & 0xF) << 8) - | data_buf[0x3]; - - /* EDID_TIMING_DESC_UPPER_V_NIBBLE[0x7]: Relative Offset to the EDID - * detailed timing descriptors - Upper 4 bit for each V active/blank - * field */ - /* EDID_TIMING_DESC_V_ACTIVE[0x5]: Relative Offset to the EDID detailed - * timing descriptors - V active */ - active_v = ((((uint32)data_buf[0x7] >> 0x4) & 0xF) << 8) - | data_buf[0x5]; - - /* EDID_TIMING_DESC_V_BLANK[0x6]: Relative Offset to the EDID detailed - * timing descriptors - V blank */ - blank_v = (((uint32)data_buf[0x7] & 0xF) << 8) - | data_buf[0x6]; - - /* EDID_TIMING_DESC_IMAGE_SIZE_UPPER_NIBBLE[0xE]: Relative Offset to the - * EDID detailed timing descriptors - Image Size upper nibble - * V and H */ - /* EDID_TIMING_DESC_H_IMAGE_SIZE[0xC]: Relative Offset to the EDID - * detailed timing descriptors - H image size */ - /* EDID_TIMING_DESC_V_IMAGE_SIZE[0xD]: Relative Offset to the EDID - * detailed timing descriptors - V image size */ - img_size_h = ((((uint32)data_buf[0xE] >> 0x4) & 0xF) << 8) - | data_buf[0xC]; - img_size_v = (((uint32)data_buf[0xE] & 0xF) << 8) - | data_buf[0xD]; - - /* - * aspect ratio as 4:3 if within specificed range , rathaer than being - * absolute value - */ - aspect_ratio_4_3 = (abs(img_size_h * 3 - img_size_v * 4) < 5) ? 1 : 0; - - max_num_of_elements = sizeof(hdmi_edid_disp_mode_lut) - / sizeof(*hdmi_edid_disp_mode_lut); - - /* EDID_TIMING_DESC_INTERLACE[0x11:7]: Relative Offset to the EDID - * detailed timing descriptors - Interlace flag */ - DEV_DBG("Interlaced mode byte data_buf[0x11]=[%x]\n", data_buf[0x11]); - /* - * CEA 861-D: interlaced bit is bit[7] of byte[0x11] - */ - interlaced = (data_buf[0x11] & 0x80) >> 7; - - DEV_DBG("%s: A[%ux%u] B[%ux%u] V[%ux%u] %s\n", __func__, - active_h, active_v, blank_h, blank_v, img_size_h, img_size_v, - interlaced ? "i" : "p"); - - *disp_mode = HDMI_VFRMT_FORCE_32BIT; - while (ndx < max_num_of_elements) { - const struct hdmi_edid_video_mode_property_type *edid = - hdmi_edid_disp_mode_lut+ndx; - - if ((interlaced == edid->interlaced) && - (active_h == edid->active_h) && - (blank_h == edid->total_blank_h) && - (blank_v == edid->total_blank_v) && - ((active_v == edid->active_v) || - (active_v == (edid->active_v + 1))) - ) { - if (edid->aspect_ratio_4_3 && !aspect_ratio_4_3) - /* Aspect ratio 16:9 */ - *disp_mode = edid->video_code + 1; - else - /* Aspect ratio 4:3 */ - *disp_mode = edid->video_code; - - DEV_DBG("%s: mode found:%d\n", __func__, *disp_mode); - break; - } - ++ndx; - } - if (ndx == max_num_of_elements) - DEV_INFO("%s: *no mode* found\n", __func__); -} - -static void add_supported_video_format( - struct hdmi_disp_mode_list_type *disp_mode_list, - uint32 video_format) -{ - const struct hdmi_disp_mode_timing_type *timing; - boolean supported = false; - boolean mhl_supported = true; - - if (video_format >= HDMI_VFRMT_MAX) - return; - - timing = hdmi_common_get_supported_mode(video_format); - supported = timing != NULL; - DEV_DBG("EDID: format: %d [%s], %s\n", - video_format, video_format_2string(video_format), - supported ? "Supported" : "Not-Supported"); - - if (mhl_is_enabled()) { - const struct hdmi_disp_mode_timing_type *mhl_timing = - hdmi_mhl_get_supported_mode(video_format); - mhl_supported = mhl_timing != NULL; - DEV_DBG("EDID: format: %d [%s], %s by MHL\n", - video_format, video_format_2string(video_format), - mhl_supported ? "Supported" : "Not-Supported"); - } - - if (supported && mhl_supported) { - disp_mode_list->disp_mode_list[ - disp_mode_list->num_of_elements++] = video_format; - if (video_format == external_common_state->video_resolution) { - DEV_DBG("%s: Default resolution %d [%s] supported\n", - __func__, video_format, - video_format_2string(video_format)); - external_common_state->default_res_supported = true; - } - } -} - -const char *single_video_3d_format_2string(uint32 format) -{ - switch (format) { - case TOP_AND_BOTTOM: return "TAB"; - case FRAME_PACKING: return "FP"; - case SIDE_BY_SIDE_HALF: return "SSH"; - } - return ""; -} - -ssize_t video_3d_format_2string(uint32 format, char *buf) -{ - ssize_t ret, len = 0; - ret = snprintf(buf, PAGE_SIZE, "%s", - single_video_3d_format_2string(format & FRAME_PACKING)); - len += ret; - - if (len && (format & TOP_AND_BOTTOM)) - ret = snprintf(buf + len, PAGE_SIZE - len, ":%s", - single_video_3d_format_2string( - format & TOP_AND_BOTTOM)); - else - ret = snprintf(buf + len, PAGE_SIZE - len, "%s", - single_video_3d_format_2string( - format & TOP_AND_BOTTOM)); - len += ret; - - if (len && (format & SIDE_BY_SIDE_HALF)) - ret = snprintf(buf + len, PAGE_SIZE - len, ":%s", - single_video_3d_format_2string( - format & SIDE_BY_SIDE_HALF)); - else - ret = snprintf(buf + len, PAGE_SIZE - len, "%s", - single_video_3d_format_2string( - format & SIDE_BY_SIDE_HALF)); - len += ret; - - return len; -} - -static void add_supported_3d_format( - struct hdmi_disp_mode_list_type *disp_mode_list, - uint32 video_format, - uint32 video_3d_format) -{ - char string[128]; - boolean added = FALSE; - int i; - for (i = 0; i < disp_mode_list->num_of_elements; ++i) { - if (disp_mode_list->disp_mode_list[i] == video_format) { - disp_mode_list->disp_3d_mode_list[i] |= - video_3d_format; - added = TRUE; - break; - } - } - video_3d_format_2string(video_3d_format, string); - DEV_DBG("EDID[3D]: format: %d [%s], %s %s\n", - video_format, video_format_2string(video_format), - string, added ? "added" : "NOT added"); -} - -static void hdmi_edid_get_display_vsd_3d_mode(const uint8 *data_buf, - struct hdmi_disp_mode_list_type *disp_mode_list, - uint32 num_og_cea_blocks) -{ - uint8 len, offset, present_multi_3d, hdmi_vic_len; - int hdmi_3d_len; - uint16 structure_all, structure_mask; - const uint8 *vsd = num_og_cea_blocks ? - hdmi_edid_find_block(data_buf+0x80, DBC_START_OFFSET, - 3, &len) : NULL; - int i; - - offset = HDMI_VSDB_3D_DATA_OFFSET(vsd); - present_multi_3d = (vsd[offset] & 0x60) >> 5; - - offset += 1; - hdmi_vic_len = (vsd[offset] >> 5) & 0x7; - hdmi_3d_len = vsd[offset] & 0x1F; - DEV_DBG("EDID[3D]: HDMI_VIC_LEN = %d, HDMI_3D_LEN = %d\n", - hdmi_vic_len, hdmi_3d_len); - - offset += (hdmi_vic_len + 1); - if (present_multi_3d == 1 || present_multi_3d == 2) { - DEV_DBG("EDID[3D]: multi 3D present (%d)\n", present_multi_3d); - /* 3d_structure_all */ - structure_all = (vsd[offset] << 8) | vsd[offset + 1]; - offset += 2; - hdmi_3d_len -= 2; - if (present_multi_3d == 2) { - /* 3d_structure_mask */ - structure_mask = (vsd[offset] << 8) | vsd[offset + 1]; - offset += 2; - hdmi_3d_len -= 2; - } else - structure_mask = 0xffff; - - i = 0; - while (i < 16) { - if (i >= disp_mode_list->disp_multi_3d_mode_list_cnt) - break; - - if (!(structure_mask & BIT(i))) { - ++i; - continue; - } - - /* BIT0: FRAME PACKING */ - if (structure_all & BIT(0)) - add_supported_3d_format(disp_mode_list, - disp_mode_list-> - disp_multi_3d_mode_list[i], - FRAME_PACKING); - - /* BIT6: TOP AND BOTTOM */ - if (structure_all & BIT(6)) - add_supported_3d_format(disp_mode_list, - disp_mode_list-> - disp_multi_3d_mode_list[i], - TOP_AND_BOTTOM); - - /* BIT8: SIDE BY SIDE HALF */ - if (structure_all & BIT(8)) - add_supported_3d_format(disp_mode_list, - disp_mode_list-> - disp_multi_3d_mode_list[i], - SIDE_BY_SIDE_HALF); - - ++i; - } - } - - i = 0; - while (hdmi_3d_len > 0) { - DEV_DBG("EDID[3D]: 3D_Structure_%d @ %d: %02x\n", - i + 1, offset, vsd[offset]); - - if ((vsd[offset] >> 4) >= - disp_mode_list->disp_multi_3d_mode_list_cnt) { - if ((vsd[offset] & 0x0F) >= 8) { - offset += 1; - hdmi_3d_len -= 1; - DEV_DBG("EDID[3D]: 3D_Detail_%d @ %d: %02x\n", - i + 1, offset, vsd[offset]); - } - i += 1; - offset += 1; - hdmi_3d_len -= 1; - continue; - } - - switch (vsd[offset] & 0x0F) { - case 0: - /* 0000b: FRAME PACKING */ - add_supported_3d_format(disp_mode_list, - disp_mode_list->disp_multi_3d_mode_list - [vsd[offset] >> 4], - FRAME_PACKING); - break; - case 6: - /* 0110b: TOP AND BOTTOM */ - add_supported_3d_format(disp_mode_list, - disp_mode_list->disp_multi_3d_mode_list - [vsd[offset] >> 4], - TOP_AND_BOTTOM); - break; - case 8: - /* 1000b: SIDE BY SIDE HALF */ - add_supported_3d_format(disp_mode_list, - disp_mode_list->disp_multi_3d_mode_list - [vsd[offset] >> 4], - SIDE_BY_SIDE_HALF); - break; - } - if ((vsd[offset] & 0x0F) >= 8) { - offset += 1; - hdmi_3d_len -= 1; - DEV_DBG("EDID[3D]: 3D_Detail_%d @ %d: %02x\n", - i + 1, offset, vsd[offset]); - } - i += 1; - offset += 1; - hdmi_3d_len -= 1; - } -} - -static void hdmi_edid_get_display_mode(const uint8 *data_buf, - struct hdmi_disp_mode_list_type *disp_mode_list, - uint32 num_og_cea_blocks) -{ - uint8 i = 0, offset = 0, std_blk = 0; - uint32 video_format = HDMI_VFRMT_640x480p60_4_3; - boolean has480p = FALSE; - uint8 len; - const uint8 *edid_blk0 = &data_buf[0x0]; - const uint8 *edid_blk1 = &data_buf[0x80]; - const uint8 *svd = num_og_cea_blocks ? - hdmi_edid_find_block(data_buf+0x80, DBC_START_OFFSET, - 2, &len) : NULL; - boolean has60hz_mode = FALSE; - boolean has50hz_mode = FALSE; - - - disp_mode_list->num_of_elements = 0; - disp_mode_list->disp_multi_3d_mode_list_cnt = 0; - if (svd != NULL) { - ++svd; - for (i = 0; i < len; ++i, ++svd) { - /* Subtract 1 because it is zero based in the driver, - * while the Video identification code is 1 based in the - * CEA_861D spec */ - video_format = (*svd & 0x7F) - 1; - add_supported_video_format(disp_mode_list, - video_format); - /* Make a note of the preferred video format */ - if (i == 0) { - external_common_state->preferred_video_format = - video_format; - } - if (i < 16) { - disp_mode_list->disp_multi_3d_mode_list[i] - = video_format; - disp_mode_list->disp_multi_3d_mode_list_cnt++; - } - - if (video_format <= HDMI_VFRMT_1920x1080p60_16_9 || - video_format == HDMI_VFRMT_2880x480p60_4_3 || - video_format == HDMI_VFRMT_2880x480p60_16_9) - has60hz_mode = TRUE; - - if ((video_format >= HDMI_VFRMT_720x576p50_4_3 && - video_format <= HDMI_VFRMT_1920x1080p50_16_9) || - video_format == HDMI_VFRMT_2880x576p50_4_3 || - video_format == HDMI_VFRMT_2880x576p50_16_9 || - video_format == HDMI_VFRMT_1920x1250i50_16_9) - has50hz_mode = TRUE; - if (video_format == HDMI_VFRMT_640x480p60_4_3) - has480p = TRUE; - } - } else if (!num_og_cea_blocks) { - /* Detailed timing descriptors */ - uint32 desc_offset = 0; - /* Maximum 4 timing descriptor in block 0 - No CEA - * extension in this case */ - /* EDID_FIRST_TIMING_DESC[0x36] - 1st detailed timing - * descriptor */ - /* EDID_DETAIL_TIMING_DESC_BLCK_SZ[0x12] - Each detailed timing - * descriptor has block size of 18 */ - while (4 > i && 0 != edid_blk0[0x36+desc_offset]) { - hdmi_edid_detail_desc(edid_blk0+0x36+desc_offset, - &video_format); - DEV_DBG("[%s:%d] Block-0 Adding vid fmt = [%s]\n", - __func__, __LINE__, - video_format_2string(video_format)); - add_supported_video_format(disp_mode_list, - video_format); - if (video_format == HDMI_VFRMT_640x480p60_4_3) - has480p = TRUE; - /* Make a note of the preferred video format */ - if (i == 0) { - external_common_state->preferred_video_format = - video_format; - } - desc_offset += 0x12; - ++i; - } - } else if (1 == num_og_cea_blocks) { - uint32 desc_offset = 0; - - /* - * Read from both block 0 and block 1 - * Read EDID block[0] as above - */ - while (4 > i && 0 != edid_blk0[0x36+desc_offset]) { - hdmi_edid_detail_desc(edid_blk0+0x36+desc_offset, - &video_format); - DEV_DBG("[%s:%d] Block-0 Adding vid fmt = [%s]\n", - __func__, __LINE__, - video_format_2string(video_format)); - add_supported_video_format(disp_mode_list, - video_format); - if (video_format == HDMI_VFRMT_640x480p60_4_3) - has480p = TRUE; - /* Make a note of the preferred video format */ - if (i == 0) { - external_common_state->preferred_video_format = - video_format; - } - desc_offset += 0x12; - ++i; - } - - /* Parse block 1 - CEA extension byte offset of first - * detailed timing generation - offset is relevant to - * the offset of block 1 */ - - /* EDID_CEA_EXTENSION_FIRST_DESC[0x82]: Offset to CEA - * extension first timing desc - indicate the offset of - * the first detailed timing descriptor */ - /* EDID_BLOCK_SIZE = 0x80 Each page size in the EDID ROM */ - desc_offset = edid_blk1[0x02]; - while (0 != edid_blk1[desc_offset]) { - hdmi_edid_detail_desc(edid_blk1+desc_offset, - &video_format); - DEV_DBG("[%s:%d] Block-1 Adding vid fmt = [%s]\n", - __func__, __LINE__, - video_format_2string(video_format)); - add_supported_video_format(disp_mode_list, - video_format); - if (video_format == HDMI_VFRMT_640x480p60_4_3) - has480p = TRUE; - /* Make a note of the preferred video format */ - if (i == 0) { - external_common_state->preferred_video_format = - video_format; - } - desc_offset += 0x12; - ++i; - } - } - - - /* - * Check SD Timings if it contains 1280x1024@60Hz. - * SD Timing can be max 8 with 2 byte in size. - */ - std_blk = 0; - offset = 0; - while (std_blk < 8) { - if ((edid_blk0[0x26 + offset] == 0x81) && - (edid_blk0[0x26 + offset + 1] == 0x80)) { - add_supported_video_format(disp_mode_list, - HDMI_VFRMT_1280x1024p60_5_4); - break; - } else { - offset += 2; - } - std_blk++; - } - - /* check if the EDID revision is 4 (version 1.4) */ - if (edid_blk0[0x13] == 4) { - uint8 start = 0x36; - - i = 0; - - /* Check each of 4 - 18 bytes descriptors */ - while (i < 4) { - uint8 itrate = start; - uint32 header_1 = 0; - uint8 header_2 = 0; - - /* - * First 5 bytes are header. - * If they match 0x000000F700, it means its an - * established Timing III descriptor. - */ - header_1 = edid_blk0[itrate++]; - header_1 = header_1 << 8 | edid_blk0[itrate++]; - header_1 = header_1 << 8 | edid_blk0[itrate++]; - header_1 = header_1 << 8 | edid_blk0[itrate++]; - header_2 = edid_blk0[itrate]; - - if (header_1 == 0x000000F7 && - header_2 == 0x00) { - itrate++; /* VESA DMT Standard Version (0x0A)*/ - itrate++; /* First set of supported formats */ - itrate++; /* Second set of supported formats */ - /* BIT(1) indicates 1280x1024@60Hz */ - if (edid_blk0[itrate] & 0x02) { - add_supported_video_format( - disp_mode_list, - HDMI_VFRMT_1280x1024p60_5_4); - break; - } - } - i++; - start += 0x12; - } - } - - /* mandaroty 3d format */ - if (external_common_state->present_3d) { - if (has60hz_mode) { - add_supported_3d_format(disp_mode_list, - HDMI_VFRMT_1920x1080p24_16_9, - FRAME_PACKING | TOP_AND_BOTTOM); - add_supported_3d_format(disp_mode_list, - HDMI_VFRMT_1280x720p60_16_9, - FRAME_PACKING | TOP_AND_BOTTOM); - add_supported_3d_format(disp_mode_list, - HDMI_VFRMT_1920x1080i60_16_9, - SIDE_BY_SIDE_HALF); - } - if (has50hz_mode) { - add_supported_3d_format(disp_mode_list, - HDMI_VFRMT_1920x1080p24_16_9, - FRAME_PACKING | TOP_AND_BOTTOM); - add_supported_3d_format(disp_mode_list, - HDMI_VFRMT_1280x720p50_16_9, - FRAME_PACKING | TOP_AND_BOTTOM); - add_supported_3d_format(disp_mode_list, - HDMI_VFRMT_1920x1080i50_16_9, - SIDE_BY_SIDE_HALF); - } - - /* 3d format described in Vendor Specific Data */ - hdmi_edid_get_display_vsd_3d_mode(data_buf, disp_mode_list, - num_og_cea_blocks); - } - - if (!has480p) - /* Need to add default 640 by 480 timings, in case not described - * in the EDID structure. - * All DTV sink devices should support this mode */ - add_supported_video_format(disp_mode_list, - HDMI_VFRMT_640x480p60_4_3); -} - -static int hdmi_common_read_edid_block(int block, uint8 *edid_buf) -{ - uint32 ndx, check_sum, print_len; -#ifdef DEBUG - const u8 *b = edid_buf; -#endif - int status = external_common_state->read_edid_block(block, edid_buf); - if (status) - goto error; - - /* Calculate checksum */ - check_sum = 0; - for (ndx = 0; ndx < 0x80; ++ndx) - check_sum += edid_buf[ndx]; - - if (check_sum & 0xFF) { - DEV_ERR("%s: failed CHECKSUM (read:%x, expected:%x)\n", - __func__, (uint8)edid_buf[0x7F], (uint8)check_sum); -#ifdef DEBUG - for (ndx = 0; ndx < 0x100; ndx += 16) - DEV_DBG("EDID[%02x-%02x] %02x %02x %02x %02x " - "%02x %02x %02x %02x %02x %02x %02x %02x " - "%02x %02x %02x %02x\n", ndx, ndx+15, - b[ndx+0], b[ndx+1], b[ndx+2], b[ndx+3], - b[ndx+4], b[ndx+5], b[ndx+6], b[ndx+7], - b[ndx+8], b[ndx+9], b[ndx+10], b[ndx+11], - b[ndx+12], b[ndx+13], b[ndx+14], b[ndx+15]); -#endif - status = -EPROTO; - goto error; - } - print_len = 0x80; - for (ndx = 0; ndx < print_len; ndx += 16) - DEV_DBG("EDID[%02x-%02x] %02x %02x %02x %02x " - "%02x %02x %02x %02x %02x %02x %02x %02x " - "%02x %02x %02x %02x\n", ndx, ndx+15, - b[ndx+0], b[ndx+1], b[ndx+2], b[ndx+3], - b[ndx+4], b[ndx+5], b[ndx+6], b[ndx+7], - b[ndx+8], b[ndx+9], b[ndx+10], b[ndx+11], - b[ndx+12], b[ndx+13], b[ndx+14], b[ndx+15]); - - -error: - return status; -} - -static boolean check_edid_header(const uint8 *edid_buf) -{ - return (edid_buf[0] == 0x00) && (edid_buf[1] == 0xff) - && (edid_buf[2] == 0xff) && (edid_buf[3] == 0xff) - && (edid_buf[4] == 0xff) && (edid_buf[5] == 0xff) - && (edid_buf[6] == 0xff) && (edid_buf[7] == 0x00); -} - -int hdmi_common_read_edid(void) -{ - int status = 0; - uint32 cea_extension_ver = 0; - uint32 num_og_cea_blocks = 0; - uint32 ieee_reg_id = 0; - uint32 i = 1; - char vendor_id[5]; - /* EDID_BLOCK_SIZE[0x80] Each page size in the EDID ROM */ - uint8 edid_buf[0x80 * 4]; - - external_common_state->pt_scan_info = 0; - external_common_state->it_scan_info = 0; - external_common_state->ce_scan_info = 0; - external_common_state->preferred_video_format = 0; - external_common_state->present_3d = 0; - memset(&external_common_state->disp_mode_list, 0, - sizeof(external_common_state->disp_mode_list)); - memset(edid_buf, 0, sizeof(edid_buf)); - external_common_state->default_res_supported = false; - memset(external_common_state->audio_data_block, 0, - sizeof(external_common_state->audio_data_block)); - memset(external_common_state->spkr_alloc_data_block, 0, - sizeof(external_common_state->spkr_alloc_data_block)); - external_common_state->adb_size = 0; - external_common_state->sadb_size = 0; - - status = hdmi_common_read_edid_block(0, edid_buf); - if (status || !check_edid_header(edid_buf)) { - if (!status) - status = -EPROTO; - DEV_ERR("%s: edid read block(0) failed: %d " - "[%02x%02x%02x%02x%02x%02x%02x%02x]\n", __func__, - status, - edid_buf[0], edid_buf[1], edid_buf[2], edid_buf[3], - edid_buf[4], edid_buf[5], edid_buf[6], edid_buf[7]); - goto error; - } - hdmi_edid_extract_vendor_id(edid_buf, vendor_id); - - /* EDID_CEA_EXTENSION_FLAG[0x7E] - CEC extension byte */ - num_og_cea_blocks = edid_buf[0x7E]; - - DEV_DBG("[JSR] (%s): No. of CEA blocks is [%u]\n", __func__, - num_og_cea_blocks); - /* Find out any CEA extension blocks following block 0 */ - switch (num_og_cea_blocks) { - case 0: /* No CEA extension */ - external_common_state->hdmi_sink = false; - DEV_DBG("HDMI DVI mode: %s\n", - external_common_state->hdmi_sink ? "no" : "yes"); - break; - case 1: /* Read block 1 */ - status = hdmi_common_read_edid_block(1, &edid_buf[0x80]); - if (status) { - DEV_ERR("%s: ddc read block(1) failed: %d\n", __func__, - status); - goto error; - } - if (edid_buf[0x80] != 2) - num_og_cea_blocks = 0; - if (num_og_cea_blocks) { - ieee_reg_id = - hdmi_edid_extract_ieee_reg_id(edid_buf+0x80); - if (ieee_reg_id == 0x0c03) - external_common_state->hdmi_sink = TRUE ; - else - external_common_state->hdmi_sink = FALSE ; - hdmi_edid_extract_latency_fields(edid_buf+0x80); - hdmi_edid_extract_speaker_allocation_data( - edid_buf+0x80); - hdmi_edid_extract_audio_data_blocks(edid_buf+0x80); - hdmi_edid_extract_3d_present(edid_buf+0x80); - hdmi_edid_extract_extended_data_blocks(edid_buf+0x80); - } - break; - case 2: - case 3: - case 4: - for (i = 1; i <= num_og_cea_blocks; i++) { - if (!(i % 2)) { - status = hdmi_common_read_edid_block(i, - edid_buf+0x00); - if (status) { - DEV_ERR("%s: ddc read block(%d)" - "failed: %d\n", __func__, i, - status); - goto error; - } - } else { - status = hdmi_common_read_edid_block(i, - edid_buf+0x80); - if (status) { - DEV_ERR("%s: ddc read block(%d)" - "failed:%d\n", __func__, i, - status); - goto error; - } - } - } - break; - default: - DEV_ERR("%s: ddc read failed, not supported multi-blocks: %d\n", - __func__, num_og_cea_blocks); - status = -EPROTO; - goto error; - } - - if (num_og_cea_blocks) { - /* EDID_CEA_EXTENSION_VERSION[0x81]: Offset to CEA extension - * version number - v1,v2,v3 (v1 is seldom, v2 is obsolete, - * v3 most common) */ - cea_extension_ver = edid_buf[0x81]; - } - - /* EDID_VERSION[0x12] - EDID Version */ - /* EDID_REVISION[0x13] - EDID Revision */ - DEV_INFO("EDID (V=%d.%d, #CEABlocks=%d[V%d], ID=%s, IEEE=%04x, " - "EDID-Ext=0x%02x)\n", edid_buf[0x12], edid_buf[0x13], - num_og_cea_blocks, cea_extension_ver, vendor_id, ieee_reg_id, - edid_buf[0x80]); - - hdmi_edid_get_display_mode(edid_buf, - &external_common_state->disp_mode_list, num_og_cea_blocks); - - return 0; - -error: - external_common_state->disp_mode_list.num_of_elements = 1; - external_common_state->disp_mode_list.disp_mode_list[0] = - external_common_state->video_resolution; - return status; -} -EXPORT_SYMBOL(hdmi_common_read_edid); - -bool hdmi_common_get_video_format_from_drv_data(struct msm_fb_data_type *mfd) -{ - uint32 format = external_common_state->video_resolution; - struct fb_var_screeninfo *var = &mfd->fbi->var; - bool changed = TRUE; - - if (var->reserved[3]) { - format = var->reserved[3]-1; - DEV_DBG("reserved format is %d\n", format); - } else if (hdmi_prim_resolution) { - format = hdmi_prim_resolution - 1; - } else { - DEV_DBG("detecting resolution from %dx%d use var->reserved[3]" - " to specify mode", mfd->var_xres, mfd->var_yres); - switch (mfd->var_xres) { - default: - case 640: - format = HDMI_VFRMT_640x480p60_4_3; - break; - case 720: - format = (mfd->var_yres == 480) - ? HDMI_VFRMT_720x480p60_16_9 - : HDMI_VFRMT_720x576p50_16_9; - break; - case 1280: - if (mfd->var_yres == 1024) - format = HDMI_VFRMT_1280x1024p60_5_4; - else if (mfd->var_frame_rate == 50000) - format = HDMI_VFRMT_1280x720p50_16_9; - else - format = HDMI_VFRMT_1280x720p60_16_9; - break; - case 1440: - format = (mfd->var_yres == 240) /* interlaced has half - of y res. - */ - ? HDMI_VFRMT_1440x480i60_16_9 - : HDMI_VFRMT_1440x576i50_16_9; - break; - case 1920: - if (mfd->var_yres == 540) {/* interlaced */ - format = HDMI_VFRMT_1920x1080i60_16_9; - } else if (mfd->var_yres == 1080) { - if (mfd->var_frame_rate == 50000) - format = HDMI_VFRMT_1920x1080p50_16_9; - else if (mfd->var_frame_rate == 24000) - format = HDMI_VFRMT_1920x1080p24_16_9; - else if (mfd->var_frame_rate == 25000) - format = HDMI_VFRMT_1920x1080p25_16_9; - else if (mfd->var_frame_rate == 30000) - format = HDMI_VFRMT_1920x1080p30_16_9; - else - format = HDMI_VFRMT_1920x1080p60_16_9; - } - break; - } - } - - changed = external_common_state->video_resolution != format; - if (external_common_state->video_resolution != format) - DEV_DBG("switching %s => %s", video_format_2string( - external_common_state->video_resolution), - video_format_2string(format)); - else - DEV_DBG("resolution %s", video_format_2string( - external_common_state->video_resolution)); - external_common_state->video_resolution = format; - return changed; -} -EXPORT_SYMBOL(hdmi_common_get_video_format_from_drv_data); - -const struct hdmi_disp_mode_timing_type *hdmi_common_get_mode(uint32 mode) -{ - if (mode >= HDMI_VFRMT_MAX) - return NULL; - - return &hdmi_common_supported_video_mode_lut[mode]; -} -EXPORT_SYMBOL(hdmi_common_get_mode); - -const struct hdmi_disp_mode_timing_type *hdmi_common_get_supported_mode( - uint32 mode) -{ - const struct hdmi_disp_mode_timing_type *ret - = hdmi_common_get_mode(mode); - - if (ret == NULL || !ret->supported) - return NULL; - return ret; -} -EXPORT_SYMBOL(hdmi_common_get_supported_mode); - -const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_mode(uint32 mode) -{ - if (mode >= HDMI_VFRMT_MAX) - return NULL; - - return &hdmi_mhl_supported_video_mode_lut[mode]; -} -EXPORT_SYMBOL(hdmi_mhl_get_mode); - -const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_supported_mode( - uint32 mode) -{ - const struct hdmi_disp_mode_timing_type *ret - = hdmi_mhl_get_mode(mode); - - if (ret == NULL || !ret->supported) - return NULL; - return ret; -} -EXPORT_SYMBOL(hdmi_mhl_get_supported_mode); - -void hdmi_common_init_panel_info(struct msm_panel_info *pinfo) -{ - const struct hdmi_disp_mode_timing_type *timing = - hdmi_common_get_supported_mode( - external_common_state->video_resolution); - - if (timing == NULL) - return; - - pinfo->xres = timing->active_h; - pinfo->yres = timing->active_v; - pinfo->clk_rate = timing->pixel_freq*1000; - pinfo->frame_rate = 60; - - pinfo->lcdc.h_back_porch = timing->back_porch_h; - pinfo->lcdc.h_front_porch = timing->front_porch_h; - pinfo->lcdc.h_pulse_width = timing->pulse_width_h; - pinfo->lcdc.v_back_porch = timing->back_porch_v; - pinfo->lcdc.v_front_porch = timing->front_porch_v; - pinfo->lcdc.v_pulse_width = timing->pulse_width_v; - - pinfo->type = DTV_PANEL; - pinfo->pdest = DISPLAY_2; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - if (hdmi_prim_display) - pinfo->fb_num = 2; - else - pinfo->fb_num = 1; - - /* blk */ - pinfo->lcdc.border_clr = 0; - /* blue */ - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; -} -EXPORT_SYMBOL(hdmi_common_init_panel_info); -#endif diff --git a/drivers/video/msm/external_common.h b/drivers/video/msm/external_common.h deleted file mode 100644 index d1178982e4e65e65b0bb105002fb3e32fde3de7e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/external_common.h +++ /dev/null @@ -1,298 +0,0 @@ -/* Copyright (c) 2010-2013, 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 __EXTERNAL_COMMON_H__ -#define __EXTERNAL_COMMON_H__ -#include - -#ifdef DEBUG -#ifndef DEV_DBG_PREFIX -#define DEV_DBG_PREFIX "EXT_INTERFACE: " -#endif -#define DEV_DBG(args...) pr_debug(DEV_DBG_PREFIX args) -#else -#define DEV_DBG(args...) (void)0 -#endif /* DEBUG */ -#define DEV_INFO(args...) dev_info(external_common_state->dev, args) -#define DEV_WARN(args...) dev_warn(external_common_state->dev, args) -#define DEV_ERR(args...) dev_err(external_common_state->dev, args) - -#ifdef CONFIG_FB_MSM_TVOUT -#define TVOUT_VFRMT_NTSC_M_720x480i 0 -#define TVOUT_VFRMT_NTSC_J_720x480i 1 -#define TVOUT_VFRMT_PAL_BDGHIN_720x576i 2 -#define TVOUT_VFRMT_PAL_M_720x480i 3 -#define TVOUT_VFRMT_PAL_N_720x480i 4 -#elif defined(CONFIG_FB_MSM_HDMI_COMMON) -/* all video formats defined by EIA CEA 861D */ -#define HDMI_VFRMT_640x480p60_4_3 0 -#define HDMI_VFRMT_720x480p60_4_3 1 -#define HDMI_VFRMT_720x480p60_16_9 2 -#define HDMI_VFRMT_1280x720p60_16_9 3 -#define HDMI_VFRMT_1920x1080i60_16_9 4 -#define HDMI_VFRMT_720x480i60_4_3 5 -#define HDMI_VFRMT_1440x480i60_4_3 HDMI_VFRMT_720x480i60_4_3 -#define HDMI_VFRMT_720x480i60_16_9 6 -#define HDMI_VFRMT_1440x480i60_16_9 HDMI_VFRMT_720x480i60_16_9 -#define HDMI_VFRMT_720x240p60_4_3 7 -#define HDMI_VFRMT_1440x240p60_4_3 HDMI_VFRMT_720x240p60_4_3 -#define HDMI_VFRMT_720x240p60_16_9 8 -#define HDMI_VFRMT_1440x240p60_16_9 HDMI_VFRMT_720x240p60_16_9 -#define HDMI_VFRMT_2880x480i60_4_3 9 -#define HDMI_VFRMT_2880x480i60_16_9 10 -#define HDMI_VFRMT_2880x240p60_4_3 11 -#define HDMI_VFRMT_2880x240p60_16_9 12 -#define HDMI_VFRMT_1440x480p60_4_3 13 -#define HDMI_VFRMT_1440x480p60_16_9 14 -#define HDMI_VFRMT_1920x1080p60_16_9 15 -#define HDMI_VFRMT_720x576p50_4_3 16 -#define HDMI_VFRMT_720x576p50_16_9 17 -#define HDMI_VFRMT_1280x720p50_16_9 18 -#define HDMI_VFRMT_1920x1080i50_16_9 19 -#define HDMI_VFRMT_720x576i50_4_3 20 -#define HDMI_VFRMT_1440x576i50_4_3 HDMI_VFRMT_720x576i50_4_3 -#define HDMI_VFRMT_720x576i50_16_9 21 -#define HDMI_VFRMT_1440x576i50_16_9 HDMI_VFRMT_720x576i50_16_9 -#define HDMI_VFRMT_720x288p50_4_3 22 -#define HDMI_VFRMT_1440x288p50_4_3 HDMI_VFRMT_720x288p50_4_3 -#define HDMI_VFRMT_720x288p50_16_9 23 -#define HDMI_VFRMT_1440x288p50_16_9 HDMI_VFRMT_720x288p50_16_9 -#define HDMI_VFRMT_2880x576i50_4_3 24 -#define HDMI_VFRMT_2880x576i50_16_9 25 -#define HDMI_VFRMT_2880x288p50_4_3 26 -#define HDMI_VFRMT_2880x288p50_16_9 27 -#define HDMI_VFRMT_1440x576p50_4_3 28 -#define HDMI_VFRMT_1440x576p50_16_9 29 -#define HDMI_VFRMT_1920x1080p50_16_9 30 -#define HDMI_VFRMT_1920x1080p24_16_9 31 -#define HDMI_VFRMT_1920x1080p25_16_9 32 -#define HDMI_VFRMT_1920x1080p30_16_9 33 -#define HDMI_VFRMT_2880x480p60_4_3 34 -#define HDMI_VFRMT_2880x480p60_16_9 35 -#define HDMI_VFRMT_2880x576p50_4_3 36 -#define HDMI_VFRMT_2880x576p50_16_9 37 -#define HDMI_VFRMT_1920x1250i50_16_9 38 -#define HDMI_VFRMT_1920x1080i100_16_9 39 -#define HDMI_VFRMT_1280x720p100_16_9 40 -#define HDMI_VFRMT_720x576p100_4_3 41 -#define HDMI_VFRMT_720x576p100_16_9 42 -#define HDMI_VFRMT_720x576i100_4_3 43 -#define HDMI_VFRMT_1440x576i100_4_3 HDMI_VFRMT_720x576i100_4_3 -#define HDMI_VFRMT_720x576i100_16_9 44 -#define HDMI_VFRMT_1440x576i100_16_9 HDMI_VFRMT_720x576i100_16_9 -#define HDMI_VFRMT_1920x1080i120_16_9 45 -#define HDMI_VFRMT_1280x720p120_16_9 46 -#define HDMI_VFRMT_720x480p120_4_3 47 -#define HDMI_VFRMT_720x480p120_16_9 48 -#define HDMI_VFRMT_720x480i120_4_3 49 -#define HDMI_VFRMT_1440x480i120_4_3 HDMI_VFRMT_720x480i120_4_3 -#define HDMI_VFRMT_720x480i120_16_9 50 -#define HDMI_VFRMT_1440x480i120_16_9 HDMI_VFRMT_720x480i120_16_9 -#define HDMI_VFRMT_720x576p200_4_3 51 -#define HDMI_VFRMT_720x576p200_16_9 52 -#define HDMI_VFRMT_720x576i200_4_3 53 -#define HDMI_VFRMT_1440x576i200_4_3 HDMI_VFRMT_720x576i200_4_3 -#define HDMI_VFRMT_720x576i200_16_9 54 -#define HDMI_VFRMT_1440x576i200_16_9 HDMI_VFRMT_720x576i200_16_9 -#define HDMI_VFRMT_720x480p240_4_3 55 -#define HDMI_VFRMT_720x480p240_16_9 56 -#define HDMI_VFRMT_720x480i240_4_3 57 -#define HDMI_VFRMT_1440x480i240_4_3 HDMI_VFRMT_720x480i240_4_3 -#define HDMI_VFRMT_720x480i240_16_9 58 -#define HDMI_VFRMT_1440x480i240_16_9 HDMI_VFRMT_720x480i240_16_9 -#define HDMI_VFRMT_FORCE_32BIT 0x7FFFFFFF - -/* Video Identification Codes from 65-127 are reserved for the future */ -#define HDMI_VFRMT_END 127 - -/* VESA DMT TIMINGS */ -/* DMT ID: 23h, STD code: (81h, 80h), also a part of Established Timing III */ -#define HDMI_VFRMT_1280x1024p60_5_4 (HDMI_VFRMT_END + 1) -#define DMT_VFRMT_END HDMI_VFRMT_1280x1024p60_5_4 - -#define HDMI_VFRMT_MAX (DMT_VFRMT_END + 1) - - -extern int ext_resolution; - -struct hdmi_disp_mode_timing_type { - uint32 video_format; - uint32 active_h; - uint32 front_porch_h; - uint32 pulse_width_h; - uint32 back_porch_h; - boolean active_low_h; - uint32 active_v; - uint32 front_porch_v; - uint32 pulse_width_v; - uint32 back_porch_v; - boolean active_low_v; - /* Must divide by 1000 to get the actual frequency in MHZ */ - uint32 pixel_freq; - /* Must divide by 1000 to get the actual frequency in HZ */ - uint32 refresh_rate; - boolean interlaced; - boolean supported; -}; - -#define HDMI_SETTINGS_640x480p60_4_3 \ - {HDMI_VFRMT_640x480p60_4_3, 640, 16, 96, 48, TRUE, \ - 480, 10, 2, 33, TRUE, 25200, 60000, FALSE, TRUE} -#define HDMI_SETTINGS_720x480p60_4_3 \ - {HDMI_VFRMT_720x480p60_4_3, 720, 16, 62, 60, TRUE, \ - 480, 9, 6, 30, TRUE, 27030, 60000, FALSE, TRUE} -#define HDMI_SETTINGS_720x480p60_16_9 \ - {HDMI_VFRMT_720x480p60_16_9, 720, 16, 62, 60, TRUE, \ - 480, 9, 6, 30, TRUE, 27030, 60000, FALSE, TRUE} -#define HDMI_SETTINGS_1280x720p60_16_9 \ - {HDMI_VFRMT_1280x720p60_16_9, 1280, 110, 40, 220, FALSE, \ - 720, 5, 5, 20, FALSE, 74250, 60000, FALSE, TRUE} -#define HDMI_SETTINGS_1920x1080i60_16_9 \ - {HDMI_VFRMT_1920x1080i60_16_9, 1920, 88, 44, 148, FALSE, \ - 540, 2, 5, 5, FALSE, 74250, 60000, FALSE, TRUE} -#define HDMI_SETTINGS_1440x480i60_4_3 \ - {HDMI_VFRMT_1440x480i60_4_3, 1440, 38, 124, 114, TRUE, \ - 240, 4, 3, 15, TRUE, 27000, 60000, TRUE, TRUE} -#define HDMI_SETTINGS_1440x480i60_16_9 \ - {HDMI_VFRMT_1440x480i60_16_9, 1440, 38, 124, 114, TRUE, \ - 240, 4, 3, 15, TRUE, 27000, 60000, TRUE, TRUE} -#define HDMI_SETTINGS_1920x1080p60_16_9 \ - {HDMI_VFRMT_1920x1080p60_16_9, 1920, 88, 44, 148, FALSE, \ - 1080, 4, 5, 36, FALSE, 148500, 60000, FALSE, TRUE} -#define HDMI_SETTINGS_720x576p50_4_3 \ - {HDMI_VFRMT_720x576p50_4_3, 720, 12, 64, 68, TRUE, \ - 576, 5, 5, 39, TRUE, 27000, 50000, FALSE, TRUE} -#define HDMI_SETTINGS_720x576p50_16_9 \ - {HDMI_VFRMT_720x576p50_16_9, 720, 12, 64, 68, TRUE, \ - 576, 5, 5, 39, TRUE, 27000, 50000, FALSE, TRUE} -#define HDMI_SETTINGS_1280x720p50_16_9 \ - {HDMI_VFRMT_1280x720p50_16_9, 1280, 440, 40, 220, FALSE, \ - 720, 5, 5, 20, FALSE, 74250, 50000, FALSE, TRUE} -#define HDMI_SETTINGS_1440x576i50_4_3 \ - {HDMI_VFRMT_1440x576i50_4_3, 1440, 24, 126, 138, TRUE, \ - 288, 2, 3, 19, TRUE, 27000, 50000, TRUE, TRUE} -#define HDMI_SETTINGS_1440x576i50_16_9 \ - {HDMI_VFRMT_1440x576i50_16_9, 1440, 24, 126, 138, TRUE, \ - 288, 2, 3, 19, TRUE, 27000, 50000, TRUE, TRUE} -#define HDMI_SETTINGS_1920x1080p50_16_9 \ - {HDMI_VFRMT_1920x1080p50_16_9, 1920, 528, 44, 148, FALSE, \ - 1080, 4, 5, 36, FALSE, 148500, 50000, FALSE, TRUE} -#define HDMI_SETTINGS_1920x1080p24_16_9 \ - {HDMI_VFRMT_1920x1080p24_16_9, 1920, 638, 44, 148, FALSE, \ - 1080, 4, 5, 36, FALSE, 74250, 24000, FALSE, TRUE} -#define HDMI_SETTINGS_1920x1080p25_16_9 \ - {HDMI_VFRMT_1920x1080p25_16_9, 1920, 528, 44, 148, FALSE, \ - 1080, 4, 5, 36, FALSE, 74250, 25000, FALSE, TRUE} -#define HDMI_SETTINGS_1920x1080p30_16_9 \ - {HDMI_VFRMT_1920x1080p30_16_9, 1920, 88, 44, 148, FALSE, \ - 1080, 4, 5, 36, FALSE, 74250, 30000, FALSE, TRUE} -#define HDMI_SETTINGS_1280x1024p60_5_4 \ - {HDMI_VFRMT_1280x1024p60_5_4, 1280, 48, 112, 248, FALSE, \ - 1024, 1, 3, 38, FALSE, 108000, 60000, FALSE, TRUE} - -/* A lookup table for all the supported display modes by the HDMI - * hardware and driver. Use HDMI_SETUP_LUT in the module init to - * setup the LUT with the supported modes. */ -extern struct hdmi_disp_mode_timing_type - hdmi_common_supported_video_mode_lut[HDMI_VFRMT_MAX]; - -/* Structure that encapsulates all the supported display modes by the HDMI sink - * device */ -struct hdmi_disp_mode_list_type { - uint32 disp_mode_list[HDMI_VFRMT_MAX]; -#define TOP_AND_BOTTOM 0x10 -#define FRAME_PACKING 0x20 -#define SIDE_BY_SIDE_HALF 0x40 - uint32 disp_3d_mode_list[HDMI_VFRMT_MAX]; - uint32 disp_multi_3d_mode_list[16]; - uint32 disp_multi_3d_mode_list_cnt; - uint32 num_of_elements; -}; -#endif - -/* - * As per the CEA-861E spec, there can be a total of 10 short audio - * descriptors with each SAD being 3 bytes long. - * Thus, the maximum length of the audio data block would be 30 bytes - */ -#define MAX_AUDIO_DATA_BLOCK_SIZE 30 -#define MAX_SPKR_ALLOC_DATA_BLOCK_SIZE 3 - -struct external_common_state_type { - boolean hpd_state; - struct kobject *uevent_kobj; - uint32 video_resolution; - boolean default_res_supported; - struct device *dev; - struct switch_dev sdev; - struct switch_dev audio_sdev; -#ifdef CONFIG_FB_MSM_HDMI_3D - boolean format_3d; - void (*switch_3d)(boolean on); -#endif -#ifdef CONFIG_FB_MSM_HDMI_COMMON - boolean hdcp_active; - boolean hpd_feature_on; - boolean hdmi_sink; - struct hdmi_disp_mode_list_type disp_mode_list; - uint16 video_latency, audio_latency; - uint16 physical_address; - uint32 preferred_video_format; - uint8 pt_scan_info; - uint8 it_scan_info; - uint8 ce_scan_info; - uint8 spd_vendor_name[8]; - uint8 spd_product_description[16]; - boolean present_3d; - boolean present_hdcp; - uint8 audio_data_block[MAX_AUDIO_DATA_BLOCK_SIZE]; - int adb_size; - uint8 spkr_alloc_data_block[MAX_SPKR_ALLOC_DATA_BLOCK_SIZE]; - int sadb_size; - int (*read_edid_block)(int block, uint8 *edid_buf); - int (*hpd_feature)(int on); -#endif -}; - -/* The external interface driver needs to initialize the common state. */ -extern struct external_common_state_type *external_common_state; -extern struct mutex external_common_state_hpd_mutex; -extern struct mutex hdmi_msm_state_mutex; - -#ifdef CONFIG_FB_MSM_HDMI_COMMON -#define VFRMT_NOT_SUPPORTED(VFRMT) \ - {VFRMT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FALSE} -#define HDMI_SETUP_LUT(MODE) do { \ - struct hdmi_disp_mode_timing_type mode \ - = HDMI_SETTINGS_ ## MODE; \ - hdmi_common_supported_video_mode_lut[mode.video_format] \ - = mode; \ - } while (0) - -int hdmi_common_read_edid(void); -const char *video_format_2string(uint32 format); -bool hdmi_common_get_video_format_from_drv_data(struct msm_fb_data_type *mfd); -const struct hdmi_disp_mode_timing_type *hdmi_common_get_mode(uint32 mode); -const struct hdmi_disp_mode_timing_type *hdmi_common_get_supported_mode( - uint32 mode); -const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_mode(uint32 mode); -const struct hdmi_disp_mode_timing_type *hdmi_mhl_get_supported_mode( - uint32 mode); -void hdmi_common_init_panel_info(struct msm_panel_info *pinfo); - -ssize_t video_3d_format_2string(uint32 format, char *buf); -#endif - -int external_common_state_create(struct platform_device *pdev); -void external_common_state_remove(void); - -#endif /* __EXTERNAL_COMMON_H__ */ diff --git a/drivers/video/msm/hdmi_msm.c b/drivers/video/msm/hdmi_msm.c deleted file mode 100644 index a124d00c6486d57040777e81ad934daf84c36694..0000000000000000000000000000000000000000 --- a/drivers/video/msm/hdmi_msm.c +++ /dev/null @@ -1,4989 +0,0 @@ -/* Copyright (c) 2010-2013, 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. - * - */ - -/* #define DEBUG */ -#define DEV_DBG_PREFIX "HDMI: " -/* #define REG_DUMP */ - -#define CEC_MSG_PRINT -#define TOGGLE_CEC_HARDWARE_FSM - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "hdmi_msm.h" - -/* Supported HDMI Audio channels */ -#define MSM_HDMI_AUDIO_CHANNEL_2 0 -#define MSM_HDMI_AUDIO_CHANNEL_4 1 -#define MSM_HDMI_AUDIO_CHANNEL_6 2 -#define MSM_HDMI_AUDIO_CHANNEL_8 3 -#define MSM_HDMI_AUDIO_CHANNEL_MAX 4 -#define MSM_HDMI_AUDIO_CHANNEL_FORCE_32BIT 0x7FFFFFFF - -/* Supported HDMI Audio sample rates */ -#define MSM_HDMI_SAMPLE_RATE_32KHZ 0 -#define MSM_HDMI_SAMPLE_RATE_44_1KHZ 1 -#define MSM_HDMI_SAMPLE_RATE_48KHZ 2 -#define MSM_HDMI_SAMPLE_RATE_88_2KHZ 3 -#define MSM_HDMI_SAMPLE_RATE_96KHZ 4 -#define MSM_HDMI_SAMPLE_RATE_176_4KHZ 5 -#define MSM_HDMI_SAMPLE_RATE_192KHZ 6 -#define MSM_HDMI_SAMPLE_RATE_MAX 7 -#define MSM_HDMI_SAMPLE_RATE_FORCE_32BIT 0x7FFFFFFF - -static int msm_hdmi_sample_rate = MSM_HDMI_SAMPLE_RATE_48KHZ; - -/* HDMI/HDCP Registers */ -#define HDCP_DDC_STATUS 0x0128 -#define HDCP_DDC_CTRL_0 0x0120 -#define HDCP_DDC_CTRL_1 0x0124 -#define HDMI_DDC_CTRL 0x020C - -#define HPD_EVENT_OFFLINE 0 -#define HPD_EVENT_ONLINE 1 - -#define SWITCH_SET_HDMI_AUDIO(d, force) \ - do {\ - if (!hdmi_msm_is_dvi_mode() &&\ - ((force) ||\ - (external_common_state->audio_sdev.state != (d)))) {\ - switch_set_state(&external_common_state->audio_sdev,\ - (d));\ - DEV_INFO("%s: hdmi_audio state switched to %d\n",\ - __func__,\ - external_common_state->audio_sdev.state);\ - } \ - } while (0) - -struct workqueue_struct *hdmi_work_queue; -struct hdmi_msm_state_type *hdmi_msm_state; - -/* Enable HDCP by default */ -static bool hdcp_feature_on = true; - -DEFINE_MUTEX(hdmi_msm_state_mutex); -EXPORT_SYMBOL(hdmi_msm_state_mutex); -static DEFINE_MUTEX(hdcp_auth_state_mutex); - -static void hdmi_msm_dump_regs(const char *prefix); - -static void hdmi_msm_hdcp_enable(void); -static void hdmi_msm_turn_on(void); -static int hdmi_msm_audio_off(void); -static int hdmi_msm_read_edid(void); -static void hdmi_msm_hpd_off(void); -static boolean hdmi_msm_is_dvi_mode(void); - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - -static void hdmi_msm_cec_line_latch_detect(void); - -#ifdef TOGGLE_CEC_HARDWARE_FSM -static boolean msg_send_complete = TRUE; -static boolean msg_recv_complete = TRUE; -#endif - -#define HDMI_MSM_CEC_REFTIMER_REFTIMER_ENABLE BIT(16) -#define HDMI_MSM_CEC_REFTIMER_REFTIMER(___t) (((___t)&0xFFFF) << 0) - -#define HDMI_MSM_CEC_TIME_SIGNAL_FREE_TIME(___t) (((___t)&0x1FF) << 7) -#define HDMI_MSM_CEC_TIME_ENABLE BIT(0) - -#define HDMI_MSM_CEC_ADDR_LOGICAL_ADDR(___la) (((___la)&0xFF) << 0) - -#define HDMI_MSM_CEC_CTRL_LINE_OE BIT(9) -#define HDMI_MSM_CEC_CTRL_FRAME_SIZE(___sz) (((___sz)&0x1F) << 4) -#define HDMI_MSM_CEC_CTRL_SOFT_RESET BIT(2) -#define HDMI_MSM_CEC_CTRL_SEND_TRIG BIT(1) -#define HDMI_MSM_CEC_CTRL_ENABLE BIT(0) - -#define HDMI_MSM_CEC_INT_FRAME_RD_DONE_MASK BIT(7) -#define HDMI_MSM_CEC_INT_FRAME_RD_DONE_ACK BIT(6) -#define HDMI_MSM_CEC_INT_FRAME_RD_DONE_INT BIT(6) -#define HDMI_MSM_CEC_INT_MONITOR_MASK BIT(5) -#define HDMI_MSM_CEC_INT_MONITOR_ACK BIT(4) -#define HDMI_MSM_CEC_INT_MONITOR_INT BIT(4) -#define HDMI_MSM_CEC_INT_FRAME_ERROR_MASK BIT(3) -#define HDMI_MSM_CEC_INT_FRAME_ERROR_ACK BIT(2) -#define HDMI_MSM_CEC_INT_FRAME_ERROR_INT BIT(2) -#define HDMI_MSM_CEC_INT_FRAME_WR_DONE_MASK BIT(1) -#define HDMI_MSM_CEC_INT_FRAME_WR_DONE_ACK BIT(0) -#define HDMI_MSM_CEC_INT_FRAME_WR_DONE_INT BIT(0) - -#define HDMI_MSM_CEC_FRAME_WR_SUCCESS(___st) (((___st)&0xB) ==\ - (HDMI_MSM_CEC_INT_FRAME_WR_DONE_INT |\ - HDMI_MSM_CEC_INT_FRAME_WR_DONE_MASK |\ - HDMI_MSM_CEC_INT_FRAME_ERROR_MASK)) - -#define HDMI_MSM_CEC_RETRANSMIT_NUM(___num) (((___num)&0xF) << 4) -#define HDMI_MSM_CEC_RETRANSMIT_ENABLE BIT(0) - -#define HDMI_MSM_CEC_WR_DATA_DATA(___d) (((___d)&0xFF) << 8) - - -void hdmi_msm_cec_init(void) -{ - /* 0x02A8 CEC_REFTIMER */ - HDMI_OUTP(0x02A8, - HDMI_MSM_CEC_REFTIMER_REFTIMER_ENABLE - | HDMI_MSM_CEC_REFTIMER_REFTIMER(27 * 50) - ); - - /* - * 0x02A0 CEC_ADDR - * Starting with a default address of 4 - */ - HDMI_OUTP(0x02A0, HDMI_MSM_CEC_ADDR_LOGICAL_ADDR(4)); - - hdmi_msm_state->first_monitor = 0; - hdmi_msm_state->fsm_reset_done = false; - - /* 0x029C CEC_INT */ - /* Enable CEC interrupts */ - HDMI_OUTP(0x029C, \ - HDMI_MSM_CEC_INT_FRAME_WR_DONE_MASK \ - | HDMI_MSM_CEC_INT_FRAME_ERROR_MASK \ - | HDMI_MSM_CEC_INT_MONITOR_MASK \ - | HDMI_MSM_CEC_INT_FRAME_RD_DONE_MASK); - - HDMI_OUTP(0x02B0, 0x7FF << 4 | 1); - - /* - * Slight adjustment to logic 1 low periods on read, - * CEC Test 8.2-3 was failing, 8 for the - * BIT_1_ERR_RANGE_HI = 8 => 750us, the test used 775us, - * so increased this to 9 which => 800us. - */ - /* - * CEC latch up issue - To fire monitor interrupt - * for every start of message - */ - HDMI_OUTP(0x02E0, 0x880000); - - /* - * Slight adjustment to logic 0 low period on write - */ - HDMI_OUTP(0x02DC, 0x8888A888); - - /* - * Enable Signal Free Time counter and set to 7 bit periods - */ - HDMI_OUTP(0x02A4, 0x1 | (7 * 0x30) << 7); - - /* 0x028C CEC_CTRL */ - HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE); -} - -void hdmi_msm_cec_write_logical_addr(int addr) -{ - /* 0x02A0 CEC_ADDR - * LOGICAL_ADDR 7:0 NUM - */ - HDMI_OUTP(0x02A0, addr & 0xFF); -} - -void hdmi_msm_dump_cec_msg(struct hdmi_msm_cec_msg *msg) -{ -#ifdef CEC_MSG_PRINT - int i; - DEV_DBG("sender_id : %d", msg->sender_id); - DEV_DBG("recvr_id : %d", msg->recvr_id); - if (msg->frame_size < 2) { - DEV_DBG("polling message"); - return; - } - DEV_DBG("opcode : %02x", msg->opcode); - for (i = 0; i < msg->frame_size - 2; i++) - DEV_DBG("operand(%2d) : %02x", i + 1, msg->operand[i]); -#endif /* CEC_MSG_PRINT */ -} - -void hdmi_msm_cec_msg_send(struct hdmi_msm_cec_msg *msg) -{ - int i; - uint32 timeout_count = 1; - int retry = 10; - - boolean frameType = (msg->recvr_id == 15 ? BIT(0) : 0); - - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->fsm_reset_done = false; - mutex_unlock(&hdmi_msm_state_mutex); -#ifdef TOGGLE_CEC_HARDWARE_FSM - msg_send_complete = FALSE; -#endif - - INIT_COMPLETION(hdmi_msm_state->cec_frame_wr_done); - hdmi_msm_state->cec_frame_wr_status = 0; - - /* 0x0294 HDMI_MSM_CEC_RETRANSMIT */ - HDMI_OUTP(0x0294, -#ifdef DRVR_ONLY_CECT_NO_DAEMON - HDMI_MSM_CEC_RETRANSMIT_NUM(msg->retransmit) - | (msg->retransmit > 0) ? HDMI_MSM_CEC_RETRANSMIT_ENABLE : 0); -#else - HDMI_MSM_CEC_RETRANSMIT_NUM(0) | - HDMI_MSM_CEC_RETRANSMIT_ENABLE); -#endif - - /* 0x028C CEC_CTRL */ - HDMI_OUTP(0x028C, 0x1 | msg->frame_size << 4); - - /* 0x0290 CEC_WR_DATA */ - - /* header block */ - HDMI_OUTP(0x0290, - HDMI_MSM_CEC_WR_DATA_DATA(msg->sender_id << 4 | msg->recvr_id) - | frameType); - - /* data block 0 : opcode */ - HDMI_OUTP(0x0290, - HDMI_MSM_CEC_WR_DATA_DATA(msg->frame_size < 2 ? 0 : msg->opcode) - | frameType); - - /* data block 1-14 : operand 0-13 */ - for (i = 0; i < msg->frame_size - 1; i++) - HDMI_OUTP(0x0290, - HDMI_MSM_CEC_WR_DATA_DATA(msg->operand[i]) - | (msg->recvr_id == 15 ? BIT(0) : 0)); - - for (; i < 14; i++) - HDMI_OUTP(0x0290, - HDMI_MSM_CEC_WR_DATA_DATA(0) - | (msg->recvr_id == 15 ? BIT(0) : 0)); - - while ((HDMI_INP(0x0298) & 1) && retry--) { - DEV_DBG("CEC line is busy(%d)\n", retry); - schedule(); - } - - /* 0x028C CEC_CTRL */ - HDMI_OUTP(0x028C, - HDMI_MSM_CEC_CTRL_LINE_OE - | HDMI_MSM_CEC_CTRL_FRAME_SIZE(msg->frame_size) - | HDMI_MSM_CEC_CTRL_SEND_TRIG - | HDMI_MSM_CEC_CTRL_ENABLE); - - timeout_count = wait_for_completion_interruptible_timeout( - &hdmi_msm_state->cec_frame_wr_done, HZ); - - if (!timeout_count) { - hdmi_msm_state->cec_frame_wr_status |= CEC_STATUS_WR_TMOUT; - DEV_ERR("%s: timedout", __func__); - hdmi_msm_dump_cec_msg(msg); - } else { - DEV_DBG("CEC write frame done (frame len=%d)", - msg->frame_size); - hdmi_msm_dump_cec_msg(msg); - } - -#ifdef TOGGLE_CEC_HARDWARE_FSM - if (!msg_recv_complete) { - /* Toggle CEC hardware FSM */ - HDMI_OUTP(0x028C, 0x0); - HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE); - msg_recv_complete = TRUE; - } - msg_send_complete = TRUE; -#else - HDMI_OUTP(0x028C, 0x0); - HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE); -#endif -} - -void hdmi_msm_cec_line_latch_detect(void) -{ - /* - * CECT 9-5-1 - * The timer period needs to be changed to appropriate value - */ - /* - * Timedout without RD_DONE, WR_DONE or ERR_INT - * Toggle CEC hardware FSM - */ - mutex_lock(&hdmi_msm_state_mutex); - if (hdmi_msm_state->first_monitor == 1) { - DEV_WARN("CEC line is probably latched up - CECT 9-5-1"); - if (!msg_recv_complete) - hdmi_msm_state->fsm_reset_done = true; - HDMI_OUTP(0x028C, 0x0); - HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE); - hdmi_msm_state->first_monitor = 0; - } - mutex_unlock(&hdmi_msm_state_mutex); -} - -void hdmi_msm_cec_msg_recv(void) -{ - uint32 data; - int i; -#ifdef DRVR_ONLY_CECT_NO_DAEMON - struct hdmi_msm_cec_msg temp_msg; -#endif - mutex_lock(&hdmi_msm_state_mutex); - if (hdmi_msm_state->cec_queue_wr == hdmi_msm_state->cec_queue_rd - && hdmi_msm_state->cec_queue_full) { - mutex_unlock(&hdmi_msm_state_mutex); - DEV_ERR("CEC message queue is overflowing\n"); -#ifdef DRVR_ONLY_CECT_NO_DAEMON - /* - * Without CEC daemon: - * Compliance tests fail once the queue gets filled up. - * so reset the pointers to the start of the queue. - */ - hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start; - hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start; - hdmi_msm_state->cec_queue_full = false; -#else - return; -#endif - } - if (hdmi_msm_state->cec_queue_wr == NULL) { - DEV_ERR("%s: wp is NULL\n", __func__); - return; - } - mutex_unlock(&hdmi_msm_state_mutex); - - /* 0x02AC CEC_RD_DATA */ - data = HDMI_INP(0x02AC); - - hdmi_msm_state->cec_queue_wr->sender_id = (data & 0xF0) >> 4; - hdmi_msm_state->cec_queue_wr->recvr_id = (data & 0x0F); - hdmi_msm_state->cec_queue_wr->frame_size = (data & 0x1F00) >> 8; - DEV_DBG("Recvd init=[%u] dest=[%u] size=[%u]\n", - hdmi_msm_state->cec_queue_wr->sender_id, - hdmi_msm_state->cec_queue_wr->recvr_id, - hdmi_msm_state->cec_queue_wr->frame_size); - - if (hdmi_msm_state->cec_queue_wr->frame_size < 1) { - DEV_ERR("%s: invalid message (frame length = %d)", - __func__, hdmi_msm_state->cec_queue_wr->frame_size); - return; - } else if (hdmi_msm_state->cec_queue_wr->frame_size == 1) { - DEV_DBG("%s: polling message (dest[%x] <- init[%x])", - __func__, - hdmi_msm_state->cec_queue_wr->recvr_id, - hdmi_msm_state->cec_queue_wr->sender_id); - return; - } - - /* data block 0 : opcode */ - data = HDMI_INP(0x02AC); - hdmi_msm_state->cec_queue_wr->opcode = data & 0xFF; - - /* data block 1-14 : operand 0-13 */ - for (i = 0; i < hdmi_msm_state->cec_queue_wr->frame_size - 2; i++) { - data = HDMI_INP(0x02AC); - hdmi_msm_state->cec_queue_wr->operand[i] = data & 0xFF; - } - - for (; i < 14; i++) - hdmi_msm_state->cec_queue_wr->operand[i] = 0; - - DEV_DBG("CEC read frame done\n"); - DEV_DBG("=======================================\n"); - hdmi_msm_dump_cec_msg(hdmi_msm_state->cec_queue_wr); - DEV_DBG("=======================================\n"); - -#ifdef DRVR_ONLY_CECT_NO_DAEMON - switch (hdmi_msm_state->cec_queue_wr->opcode) { - case 0x64: - /* Set OSD String */ - DEV_INFO("Recvd OSD Str=[%x]\n",\ - hdmi_msm_state->cec_queue_wr->operand[3]); - break; - case 0x83: - /* Give Phy Addr */ - DEV_INFO("Recvd a Give Phy Addr cmd\n"); - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - /* Setup a frame for sending out phy addr */ - temp_msg.sender_id = 0x4; - - /* Broadcast */ - temp_msg.recvr_id = 0xf; - temp_msg.opcode = 0x84; - i = 0; - temp_msg.operand[i++] = 0x10; - temp_msg.operand[i++] = 0x00; - temp_msg.operand[i++] = 0x04; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - break; - case 0xFF: - /* Abort */ - DEV_INFO("Recvd an abort cmd 0xFF\n"); - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id; - i = 0; - - /*feature abort */ - temp_msg.opcode = 0x00; - temp_msg.operand[i++] = - hdmi_msm_state->cec_queue_wr->opcode; - - /*reason for abort = "Refused" */ - temp_msg.operand[i++] = 0x04; - temp_msg.frame_size = i + 2; - hdmi_msm_dump_cec_msg(&temp_msg); - hdmi_msm_cec_msg_send(&temp_msg); - break; - case 0x046: - /* Give OSD name */ - DEV_INFO("Recvd cmd 0x046\n"); - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id; - i = 0; - - /* OSD Name */ - temp_msg.opcode = 0x47; - - /* Display control byte */ - temp_msg.operand[i++] = 0x00; - temp_msg.operand[i++] = 'H'; - temp_msg.operand[i++] = 'e'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'o'; - temp_msg.operand[i++] = ' '; - temp_msg.operand[i++] = 'W'; - temp_msg.operand[i++] = 'o'; - temp_msg.operand[i++] = 'r'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'd'; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - break; - case 0x08F: - /* Give Device Power status */ - DEV_INFO("Recvd a Power status message\n"); - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id; - i = 0; - - /* OSD String */ - temp_msg.opcode = 0x90; - temp_msg.operand[i++] = 'H'; - temp_msg.operand[i++] = 'e'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'o'; - temp_msg.operand[i++] = ' '; - temp_msg.operand[i++] = 'W'; - temp_msg.operand[i++] = 'o'; - temp_msg.operand[i++] = 'r'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'd'; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - break; - case 0x080: - /* Routing Change cmd */ - case 0x086: - /* Set Stream Path */ - DEV_INFO("Recvd Set Stream\n"); - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - - /*Broadcast this message*/ - temp_msg.recvr_id = 0xf; - i = 0; - temp_msg.opcode = 0x82; /* Active Source */ - temp_msg.operand[i++] = 0x10; - temp_msg.operand[i++] = 0x00; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - - /* - * sending message - */ - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id; - i = 0; - /* opcode for Image View On */ - temp_msg.opcode = 0x04; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - break; - case 0x44: - /* User Control Pressed */ - DEV_INFO("User Control Pressed\n"); - break; - case 0x45: - /* User Control Released */ - DEV_INFO("User Control Released\n"); - break; - default: - DEV_INFO("Recvd an unknown cmd = [%u]\n", - hdmi_msm_state->cec_queue_wr->opcode); -#ifdef __SEND_ABORT__ - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id; - i = 0; - /* opcode for feature abort */ - temp_msg.opcode = 0x00; - temp_msg.operand[i++] = - hdmi_msm_state->cec_queue_wr->opcode; - /*reason for abort = "Unrecognized opcode" */ - temp_msg.operand[i++] = 0x00; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - break; -#else - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id; - i = 0; - /* OSD String */ - temp_msg.opcode = 0x64; - temp_msg.operand[i++] = 0x0; - temp_msg.operand[i++] = 'H'; - temp_msg.operand[i++] = 'e'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'o'; - temp_msg.operand[i++] = ' '; - temp_msg.operand[i++] = 'W'; - temp_msg.operand[i++] = 'o'; - temp_msg.operand[i++] = 'r'; - temp_msg.operand[i++] = 'l'; - temp_msg.operand[i++] = 'd'; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - break; -#endif /* __SEND_ABORT__ */ - } - -#endif /* DRVR_ONLY_CECT_NO_DAEMON */ - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->cec_queue_wr++; - if (hdmi_msm_state->cec_queue_wr == CEC_QUEUE_END) - hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start; - if (hdmi_msm_state->cec_queue_wr == hdmi_msm_state->cec_queue_rd) - hdmi_msm_state->cec_queue_full = true; - mutex_unlock(&hdmi_msm_state_mutex); - DEV_DBG("Exiting %s()\n", __func__); -} - -void hdmi_msm_cec_one_touch_play(void) -{ - struct hdmi_msm_cec_msg temp_msg; - uint32 i = 0; - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - /* - * Broadcast this message - */ - temp_msg.recvr_id = 0xf; - i = 0; - /* Active Source */ - temp_msg.opcode = 0x82; - temp_msg.operand[i++] = 0x10; - temp_msg.operand[i++] = 0x00; - /*temp_msg.operand[i++] = 0x04;*/ - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - /* - * sending message - */ - memset(&temp_msg, 0x00, sizeof(struct hdmi_msm_cec_msg)); - temp_msg.sender_id = 0x4; - temp_msg.recvr_id = hdmi_msm_state->cec_queue_wr->sender_id; - i = 0; - /* Image View On */ - temp_msg.opcode = 0x04; - temp_msg.frame_size = i + 2; - hdmi_msm_cec_msg_send(&temp_msg); - -} -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - -uint32 hdmi_msm_get_io_base(void) -{ - return (uint32)MSM_HDMI_BASE; -} -EXPORT_SYMBOL(hdmi_msm_get_io_base); - -/* Table indicating the video format supported by the HDMI TX Core v1.0 */ -/* Valid Pixel-Clock rates: 25.2MHz, 27MHz, 27.03MHz, 74.25MHz, 148.5MHz */ -static void hdmi_msm_setup_video_mode_lut(void) -{ - HDMI_SETUP_LUT(640x480p60_4_3); - HDMI_SETUP_LUT(720x480p60_4_3); - HDMI_SETUP_LUT(720x480p60_16_9); - HDMI_SETUP_LUT(1280x720p60_16_9); - HDMI_SETUP_LUT(1920x1080i60_16_9); - HDMI_SETUP_LUT(1440x480i60_4_3); - HDMI_SETUP_LUT(1440x480i60_16_9); - HDMI_SETUP_LUT(1920x1080p60_16_9); - HDMI_SETUP_LUT(720x576p50_4_3); - HDMI_SETUP_LUT(720x576p50_16_9); - HDMI_SETUP_LUT(1280x720p50_16_9); - HDMI_SETUP_LUT(1440x576i50_4_3); - HDMI_SETUP_LUT(1440x576i50_16_9); - HDMI_SETUP_LUT(1920x1080p50_16_9); - HDMI_SETUP_LUT(1920x1080p24_16_9); - HDMI_SETUP_LUT(1920x1080p25_16_9); - HDMI_SETUP_LUT(1920x1080p30_16_9); - HDMI_SETUP_LUT(1280x1024p60_5_4); -} - -#ifdef PORT_DEBUG -const char *hdmi_msm_name(uint32 offset) -{ - switch (offset) { - case 0x0000: return "CTRL"; - case 0x0020: return "AUDIO_PKT_CTRL1"; - case 0x0024: return "ACR_PKT_CTRL"; - case 0x0028: return "VBI_PKT_CTRL"; - case 0x002C: return "INFOFRAME_CTRL0"; -#ifdef CONFIG_FB_MSM_HDMI_3D - case 0x0034: return "GEN_PKT_CTRL"; -#endif - case 0x003C: return "ACP"; - case 0x0040: return "GC"; - case 0x0044: return "AUDIO_PKT_CTRL2"; - case 0x0048: return "ISRC1_0"; - case 0x004C: return "ISRC1_1"; - case 0x0050: return "ISRC1_2"; - case 0x0054: return "ISRC1_3"; - case 0x0058: return "ISRC1_4"; - case 0x005C: return "ISRC2_0"; - case 0x0060: return "ISRC2_1"; - case 0x0064: return "ISRC2_2"; - case 0x0068: return "ISRC2_3"; - case 0x006C: return "AVI_INFO0"; - case 0x0070: return "AVI_INFO1"; - case 0x0074: return "AVI_INFO2"; - case 0x0078: return "AVI_INFO3"; -#ifdef CONFIG_FB_MSM_HDMI_3D - case 0x0084: return "GENERIC0_HDR"; - case 0x0088: return "GENERIC0_0"; - case 0x008C: return "GENERIC0_1"; -#endif - case 0x00C4: return "ACR_32_0"; - case 0x00C8: return "ACR_32_1"; - case 0x00CC: return "ACR_44_0"; - case 0x00D0: return "ACR_44_1"; - case 0x00D4: return "ACR_48_0"; - case 0x00D8: return "ACR_48_1"; - case 0x00E4: return "AUDIO_INFO0"; - case 0x00E8: return "AUDIO_INFO1"; - case 0x0110: return "HDCP_CTRL"; - case 0x0114: return "HDCP_DEBUG_CTRL"; - case 0x0118: return "HDCP_INT_CTRL"; - case 0x011C: return "HDCP_LINK0_STATUS"; - case 0x012C: return "HDCP_ENTROPY_CTRL0"; - case 0x0130: return "HDCP_RESET"; - case 0x0134: return "HDCP_RCVPORT_DATA0"; - case 0x0138: return "HDCP_RCVPORT_DATA1"; - case 0x013C: return "HDCP_RCVPORT_DATA2"; - case 0x0144: return "HDCP_RCVPORT_DATA3"; - case 0x0148: return "HDCP_RCVPORT_DATA4"; - case 0x014C: return "HDCP_RCVPORT_DATA5"; - case 0x0150: return "HDCP_RCVPORT_DATA6"; - case 0x0168: return "HDCP_RCVPORT_DATA12"; - case 0x01D0: return "AUDIO_CFG"; - case 0x0208: return "USEC_REFTIMER"; - case 0x020C: return "DDC_CTRL"; - case 0x0214: return "DDC_INT_CTRL"; - case 0x0218: return "DDC_SW_STATUS"; - case 0x021C: return "DDC_HW_STATUS"; - case 0x0220: return "DDC_SPEED"; - case 0x0224: return "DDC_SETUP"; - case 0x0228: return "DDC_TRANS0"; - case 0x022C: return "DDC_TRANS1"; - case 0x0238: return "DDC_DATA"; - case 0x0250: return "HPD_INT_STATUS"; - case 0x0254: return "HPD_INT_CTRL"; - case 0x0258: return "HPD_CTRL"; - case 0x025C: return "HDCP_ENTROPY_CTRL1"; - case 0x027C: return "DDC_REF"; - case 0x0284: return "HDCP_SW_UPPER_AKSV"; - case 0x0288: return "HDCP_SW_LOWER_AKSV"; - case 0x02B4: return "ACTIVE_H"; - case 0x02B8: return "ACTIVE_V"; - case 0x02BC: return "ACTIVE_V_F2"; - case 0x02C0: return "TOTAL"; - case 0x02C4: return "V_TOTAL_F2"; - case 0x02C8: return "FRAME_CTRL"; - case 0x02CC: return "AUD_INT"; - case 0x0300: return "PHY_REG0"; - case 0x0304: return "PHY_REG1"; - case 0x0308: return "PHY_REG2"; - case 0x030C: return "PHY_REG3"; - case 0x0310: return "PHY_REG4"; - case 0x0314: return "PHY_REG5"; - case 0x0318: return "PHY_REG6"; - case 0x031C: return "PHY_REG7"; - case 0x0320: return "PHY_REG8"; - case 0x0324: return "PHY_REG9"; - case 0x0328: return "PHY_REG10"; - case 0x032C: return "PHY_REG11"; - case 0x0330: return "PHY_REG12"; - default: return "???"; - } -} - -void hdmi_outp(uint32 offset, uint32 value) -{ - uint32 in_val; - - outpdw(MSM_HDMI_BASE+offset, value); - in_val = inpdw(MSM_HDMI_BASE+offset); - DEV_DBG("HDMI[%04x] => %08x [%08x] %s\n", - offset, value, in_val, hdmi_msm_name(offset)); -} - -uint32 hdmi_inp(uint32 offset) -{ - uint32 value = inpdw(MSM_HDMI_BASE+offset); - DEV_DBG("HDMI[%04x] <= %08x %s\n", - offset, value, hdmi_msm_name(offset)); - return value; -} -#endif /* DEBUG */ - -static void hdmi_msm_turn_on(void); -static int hdmi_msm_audio_off(void); -static int hdmi_msm_read_edid(void); -static void hdmi_msm_hpd_off(void); - -static bool hdmi_ready(void) -{ - return MSM_HDMI_BASE && - hdmi_msm_state && - hdmi_msm_state->hdmi_app_clk && - hdmi_msm_state->hpd_initialized; -} - -static void hdmi_msm_send_event(boolean on) -{ - char *envp[2]; - - /* QDSP OFF preceding the HPD event notification */ - envp[0] = "HDCP_STATE=FAIL"; - envp[1] = NULL; - DEV_ERR("hdmi: HDMI HPD: QDSP OFF\n"); - kobject_uevent_env(external_common_state->uevent_kobj, - KOBJ_CHANGE, envp); - - if (on) { - /* Build EDID table */ - hdmi_msm_read_edid(); - switch_set_state(&external_common_state->sdev, 1); - DEV_INFO("%s: hdmi state switched to %d\n", __func__, - external_common_state->sdev.state); - - DEV_INFO("HDMI HPD: CONNECTED: send ONLINE\n"); - kobject_uevent(external_common_state->uevent_kobj, KOBJ_ONLINE); - if (!hdmi_msm_state->hdcp_enable) { - /* Send Audio for HDMI Compliance Cases*/ - envp[0] = "HDCP_STATE=PASS"; - envp[1] = NULL; - DEV_INFO("HDMI HPD: sense : send HDCP_PASS\n"); - kobject_uevent_env(external_common_state->uevent_kobj, - KOBJ_CHANGE, envp); - } - } else { - switch_set_state(&external_common_state->sdev, 0); - DEV_INFO("%s: hdmi state switch to %d\n", __func__, - external_common_state->sdev.state); - DEV_INFO("hdmi: HDMI HPD: sense DISCONNECTED: send OFFLINE\n"); - kobject_uevent(external_common_state->uevent_kobj, - KOBJ_OFFLINE); - } - - if (!completion_done(&hdmi_msm_state->hpd_event_processed)) - complete(&hdmi_msm_state->hpd_event_processed); -} - -static void hdmi_msm_hpd_state_work(struct work_struct *work) -{ - if (!hdmi_ready()) { - DEV_ERR("hdmi: %s: ignored, probe failed\n", __func__); - return; - } - - hdmi_msm_send_event(external_common_state->hpd_state); -} - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT -static void hdmi_msm_cec_latch_work(struct work_struct *work) -{ - hdmi_msm_cec_line_latch_detect(); -} -#endif - -static void hdcp_deauthenticate(void); -static void hdmi_msm_hdcp_reauth_work(struct work_struct *work) -{ - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return; - } - - /* Don't process recursive actions */ - mutex_lock(&hdmi_msm_state_mutex); - if (hdmi_msm_state->hdcp_activating) { - mutex_unlock(&hdmi_msm_state_mutex); - return; - } - mutex_unlock(&hdmi_msm_state_mutex); - - /* - * Reauth=>deauth, hdcp_auth - * hdcp_auth=>turn_on() which calls - * HDMI Core reset without informing the Audio QDSP - * this can do bad things to video playback on the HDTV - * Therefore, as surprising as it may sound do reauth - * only if the device is HDCP-capable - */ - hdcp_deauthenticate(); - mutex_lock(&hdcp_auth_state_mutex); - hdmi_msm_state->reauth = TRUE; - mutex_unlock(&hdcp_auth_state_mutex); - mod_timer(&hdmi_msm_state->hdcp_timer, jiffies + HZ/2); -} - -static void hdmi_msm_hdcp_work(struct work_struct *work) -{ - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return; - } - - /* Only re-enable if cable still connected */ - mutex_lock(&external_common_state_hpd_mutex); - if (external_common_state->hpd_state && - !(hdmi_msm_state->full_auth_done)) { - mutex_unlock(&external_common_state_hpd_mutex); - if (hdmi_msm_state->reauth == TRUE) { - DEV_DBG("%s: Starting HDCP re-authentication\n", - __func__); - hdmi_msm_turn_on(); - } else { - DEV_DBG("%s: Starting HDCP authentication\n", __func__); - hdmi_msm_hdcp_enable(); - } - } else { - mutex_unlock(&external_common_state_hpd_mutex); - DEV_DBG("%s: HDMI not connected or HDCP already active\n", - __func__); - hdmi_msm_state->reauth = FALSE; - } -} - -int hdmi_msm_process_hdcp_interrupts(void) -{ - int rc = -1; - uint32 hdcp_int_val; - char *envp[2]; - - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return -EINVAL; - } - - /* HDCP_INT_CTRL[0x0118] - * [0] AUTH_SUCCESS_INT [R] HDCP Authentication Success - * interrupt status - * [1] AUTH_SUCCESS_ACK [W] Acknowledge bit for HDCP - * Authentication Success bit - write 1 to clear - * [2] AUTH_SUCCESS_MASK [R/W] Mask bit for HDCP Authentication - * Success interrupt - set to 1 to enable interrupt */ - hdcp_int_val = HDMI_INP_ND(0x0118); - if ((hdcp_int_val & (1 << 2)) && (hdcp_int_val & (1 << 0))) { - /* AUTH_SUCCESS_INT */ - HDMI_OUTP(0x0118, (hdcp_int_val | (1 << 1)) & ~(1 << 0)); - DEV_INFO("HDCP: AUTH_SUCCESS_INT received\n"); - complete_all(&hdmi_msm_state->hdcp_success_done); - return 0; - } - - /* [4] AUTH_FAIL_INT [R] HDCP Authentication Lost - * interrupt Status - * [5] AUTH_FAIL_ACK [W] Acknowledge bit for HDCP - * Authentication Lost bit - write 1 to clear - * [6] AUTH_FAIL_MASK [R/W] Mask bit fo HDCP Authentication - * Lost interrupt set to 1 to enable interrupt - * [7] AUTH_FAIL_INFO_ACK [W] Acknowledge bit for HDCP - * Authentication Failure Info field - write 1 to clear */ - if ((hdcp_int_val & (1 << 6)) && (hdcp_int_val & (1 << 4))) { - /* AUTH_FAIL_INT */ - /* Clear and Disable */ - uint32 link_status = HDMI_INP_ND(0x011C); - HDMI_OUTP(0x0118, (hdcp_int_val | (1 << 5)) - & ~((1 << 6) | (1 << 4))); - DEV_INFO("HDCP: AUTH_FAIL_INT received, LINK0_STATUS=0x%08x\n", - link_status); - if (hdmi_msm_state->full_auth_done) { - SWITCH_SET_HDMI_AUDIO(0, 0); - - envp[0] = "HDCP_STATE=FAIL"; - envp[1] = NULL; - DEV_INFO("HDMI HPD:QDSP OFF\n"); - kobject_uevent_env(external_common_state->uevent_kobj, - KOBJ_CHANGE, envp); - - mutex_lock(&hdcp_auth_state_mutex); - hdmi_msm_state->full_auth_done = FALSE; - mutex_unlock(&hdcp_auth_state_mutex); - /* Calling reauth only when authentication - * is sucessful or else we always go into - * the reauth loop. Also, No need to reauthenticate - * if authentication failed because of cable disconnect - */ - if (((link_status & 0xF0) >> 4) != 0x7) { - DEV_DBG("Reauthenticate From %s HDCP FAIL INT ", - __func__); - queue_work(hdmi_work_queue, - &hdmi_msm_state->hdcp_reauth_work); - } else { - DEV_INFO("HDCP: HDMI cable disconnected\n"); - } - } - - /* Clear AUTH_FAIL_INFO as well */ - HDMI_OUTP(0x0118, (hdcp_int_val | (1 << 7))); - return 0; - } - - /* [8] DDC_XFER_REQ_INT [R] HDCP DDC Transfer Request - * interrupt status - * [9] DDC_XFER_REQ_ACK [W] Acknowledge bit for HDCP DDC - * Transfer Request bit - write 1 to clear - * [10] DDC_XFER_REQ_MASK [R/W] Mask bit for HDCP DDC Transfer - * Request interrupt - set to 1 to enable interrupt */ - if ((hdcp_int_val & (1 << 10)) && (hdcp_int_val & (1 << 8))) { - /* DDC_XFER_REQ_INT */ - HDMI_OUTP_ND(0x0118, (hdcp_int_val | (1 << 9)) & ~(1 << 8)); - if (!(hdcp_int_val & (1 << 12))) - return 0; - } - /* [12] DDC_XFER_DONE_INT [R] HDCP DDC Transfer done interrupt - * status - * [13] DDC_XFER_DONE_ACK [W] Acknowledge bit for HDCP DDC - * Transfer done bit - write 1 to clear - * [14] DDC_XFER_DONE_MASK [R/W] Mask bit for HDCP DDC Transfer - * done interrupt - set to 1 to enable interrupt */ - if ((hdcp_int_val & (1 << 14)) && (hdcp_int_val & (1 << 12))) { - /* DDC_XFER_DONE_INT */ - HDMI_OUTP_ND(0x0118, (hdcp_int_val | (1 << 13)) & ~(1 << 12)); - DEV_INFO("HDCP: DDC_XFER_DONE received\n"); - return 0; - } - - return rc; -} - -static irqreturn_t hdmi_msm_isr(int irq, void *dev_id) -{ - uint32 hpd_int_status; - uint32 hpd_int_ctrl; -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - uint32 cec_intr_status; -#endif - uint32 ddc_int_ctrl; - uint32 audio_int_val; - static uint32 fifo_urun_int_occurred; - static uint32 sample_drop_int_occurred; - const uint32 occurrence_limit = 5; - - if (!hdmi_ready()) { - DEV_DBG("ISR ignored, probe failed\n"); - return IRQ_HANDLED; - } - - /* Process HPD Interrupt */ - /* HDMI_HPD_INT_STATUS[0x0250] */ - hpd_int_status = HDMI_INP_ND(0x0250); - /* HDMI_HPD_INT_CTRL[0x0254] */ - hpd_int_ctrl = HDMI_INP_ND(0x0254); - if ((hpd_int_ctrl & (1 << 2)) && (hpd_int_status & (1 << 0))) { - /* - * Got HPD interrupt. Ack the interrupt and disable any - * further HPD interrupts until we process this interrupt. - */ - HDMI_OUTP(0x0254, ((hpd_int_ctrl | (BIT(0))) & ~BIT(2))); - - external_common_state->hpd_state = - (HDMI_INP(0x0250) & BIT(1)) >> 1; - DEV_DBG("%s: Queuing work to handle HPD %s event\n", __func__, - external_common_state->hpd_state ? "connect" : - "disconnect"); - queue_work(hdmi_work_queue, &hdmi_msm_state->hpd_state_work); - return IRQ_HANDLED; - } - - /* Process DDC Interrupts */ - /* HDMI_DDC_INT_CTRL[0x0214] */ - ddc_int_ctrl = HDMI_INP_ND(0x0214); - if ((ddc_int_ctrl & (1 << 2)) && (ddc_int_ctrl & (1 << 0))) { - /* SW_DONE INT occured, clr it */ - HDMI_OUTP_ND(0x0214, ddc_int_ctrl | (1 << 1)); - complete(&hdmi_msm_state->ddc_sw_done); - return IRQ_HANDLED; - } - - /* FIFO Underrun Int is enabled */ - /* HDMI_AUD_INT[0x02CC] - * [3] AUD_SAM_DROP_MASK [R/W] - * [2] AUD_SAM_DROP_ACK [W], AUD_SAM_DROP_INT [R] - * [1] AUD_FIFO_URUN_MASK [R/W] - * [0] AUD_FIFO_URUN_ACK [W], AUD_FIFO_URUN_INT [R] */ - audio_int_val = HDMI_INP_ND(0x02CC); - if ((audio_int_val & (1 << 1)) && (audio_int_val & (1 << 0))) { - /* FIFO Underrun occured, clr it */ - HDMI_OUTP(0x02CC, audio_int_val | (1 << 0)); - - ++fifo_urun_int_occurred; - DEV_INFO("HDMI AUD_FIFO_URUN: %d\n", fifo_urun_int_occurred); - - if (fifo_urun_int_occurred >= occurrence_limit) { - HDMI_OUTP(0x02CC, HDMI_INP(0x02CC) & ~(1 << 1)); - DEV_INFO("HDMI AUD_FIFO_URUN: INT has been disabled " - "by the ISR after %d occurences...\n", - fifo_urun_int_occurred); - } - return IRQ_HANDLED; - } - - /* Audio Sample Drop int is enabled */ - if ((audio_int_val & (1 << 3)) && (audio_int_val & (1 << 2))) { - /* Audio Sample Drop occured, clr it */ - HDMI_OUTP(0x02CC, audio_int_val | (1 << 2)); - DEV_DBG("%s: AUD_SAM_DROP", __func__); - - ++sample_drop_int_occurred; - if (sample_drop_int_occurred >= occurrence_limit) { - HDMI_OUTP(0x02CC, HDMI_INP(0x02CC) & ~(1 << 3)); - DEV_INFO("HDMI AUD_SAM_DROP: INT has been disabled " - "by the ISR after %d occurences...\n", - sample_drop_int_occurred); - } - return IRQ_HANDLED; - } - - if (!hdmi_msm_process_hdcp_interrupts()) - return IRQ_HANDLED; - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - /* Process CEC Interrupt */ - /* HDMI_MSM_CEC_INT[0x029C] */ - cec_intr_status = HDMI_INP_ND(0x029C); - - DEV_DBG("cec interrupt status is [%u]\n", cec_intr_status); - - if (HDMI_MSM_CEC_FRAME_WR_SUCCESS(cec_intr_status)) { - DEV_DBG("CEC_IRQ_FRAME_WR_DONE\n"); - HDMI_OUTP(0x029C, cec_intr_status | - HDMI_MSM_CEC_INT_FRAME_WR_DONE_ACK); - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->cec_frame_wr_status |= CEC_STATUS_WR_DONE; - hdmi_msm_state->first_monitor = 0; - del_timer(&hdmi_msm_state->cec_read_timer); - mutex_unlock(&hdmi_msm_state_mutex); - complete(&hdmi_msm_state->cec_frame_wr_done); - return IRQ_HANDLED; - } - if ((cec_intr_status & (1 << 2)) && (cec_intr_status & (1 << 3))) { - DEV_DBG("CEC_IRQ_FRAME_ERROR\n"); -#ifdef TOGGLE_CEC_HARDWARE_FSM - /* Toggle CEC hardware FSM */ - HDMI_OUTP(0x028C, 0x0); - HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE); -#endif - HDMI_OUTP(0x029C, cec_intr_status); - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->first_monitor = 0; - del_timer(&hdmi_msm_state->cec_read_timer); - hdmi_msm_state->cec_frame_wr_status |= CEC_STATUS_WR_ERROR; - mutex_unlock(&hdmi_msm_state_mutex); - complete(&hdmi_msm_state->cec_frame_wr_done); - return IRQ_HANDLED; - } - - if ((cec_intr_status & (1 << 4)) && (cec_intr_status & (1 << 5))) { - DEV_DBG("CEC_IRQ_MONITOR\n"); - HDMI_OUTP(0x029C, cec_intr_status | - HDMI_MSM_CEC_INT_MONITOR_ACK); - - /* - * CECT 9-5-1 - * On the first occassion start a timer - * for few hundred ms, if it expires then - * reset the CEC block else go on with - * frame transactions as usual. - * Below adds hdmi_msm_cec_msg_recv() as an - * item into the work queue instead of running in - * interrupt context - */ - mutex_lock(&hdmi_msm_state_mutex); - if (hdmi_msm_state->first_monitor == 0) { - /* This timer might have to be changed - * worst case theoritical = - * 16 bytes * 8 * 2.7msec = 346 msec - */ - mod_timer(&hdmi_msm_state->cec_read_timer, - jiffies + HZ/2); - hdmi_msm_state->first_monitor = 1; - } - mutex_unlock(&hdmi_msm_state_mutex); - return IRQ_HANDLED; - } - - if ((cec_intr_status & (1 << 6)) && (cec_intr_status & (1 << 7))) { - DEV_DBG("CEC_IRQ_FRAME_RD_DONE\n"); - - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->first_monitor = 0; - del_timer(&hdmi_msm_state->cec_read_timer); - mutex_unlock(&hdmi_msm_state_mutex); - HDMI_OUTP(0x029C, cec_intr_status | - HDMI_MSM_CEC_INT_FRAME_RD_DONE_ACK); - hdmi_msm_cec_msg_recv(); - -#ifdef TOGGLE_CEC_HARDWARE_FSM - if (!msg_send_complete) - msg_recv_complete = FALSE; - else { - /* Toggle CEC hardware FSM */ - HDMI_OUTP(0x028C, 0x0); - HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE); - } -#else - HDMI_OUTP(0x028C, 0x0); - HDMI_OUTP(0x028C, HDMI_MSM_CEC_CTRL_ENABLE); -#endif - - return IRQ_HANDLED; - } -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - - DEV_DBG("%s: HPD, ddc_int_ctrl=%04x, " - "aud_int=%04x, cec_intr_status=%04x\n", __func__, hpd_int_ctrl, - hpd_int_status, ddc_int_ctrl, audio_int_val, - HDMI_INP_ND(0x029C)); - - return IRQ_HANDLED; -} - -static int check_hdmi_features(void) -{ - /* RAW_FEAT_CONFIG_ROW0_LSB */ - uint32 val = inpdw(QFPROM_BASE + 0x0238); - /* HDMI_DISABLE */ - boolean hdmi_disabled = (val & 0x00200000) >> 21; - /* HDCP_DISABLE */ - boolean hdcp_disabled = (val & 0x00400000) >> 22; - - DEV_DBG("Features \n", val, - hdmi_disabled ? "OFF" : "ON", hdcp_disabled ? "OFF" : "ON"); - if (hdmi_disabled) { - DEV_ERR("ERROR: HDMI disabled\n"); - return -ENODEV; - } - - if (hdcp_disabled) - DEV_WARN("WARNING: HDCP disabled\n"); - - return 0; -} - -static boolean hdmi_msm_has_hdcp(void) -{ - /* RAW_FEAT_CONFIG_ROW0_LSB, HDCP_DISABLE */ - return (inpdw(QFPROM_BASE + 0x0238) & 0x00400000) ? FALSE : TRUE; -} - -static boolean hdmi_msm_is_power_on(void) -{ - /* HDMI_CTRL, ENABLE */ - return (HDMI_INP_ND(0x0000) & 0x00000001) ? TRUE : FALSE; -} - -/* 1.2.1.2.1 DVI Operation - * HDMI compliance requires the HDMI core to support DVI as well. The - * HDMI core also supports DVI. In DVI operation there are no preambles - * and guardbands transmitted. THe TMDS encoding of video data remains - * the same as HDMI. There are no VBI or audio packets transmitted. In - * order to enable DVI mode in HDMI core, HDMI_DVI_SEL field of - * HDMI_CTRL register needs to be programmed to 0. */ -static boolean hdmi_msm_is_dvi_mode(void) -{ - /* HDMI_CTRL, HDMI_DVI_SEL */ - return (HDMI_INP_ND(0x0000) & 0x00000002) ? FALSE : TRUE; -} - -void hdmi_msm_set_mode(boolean power_on) -{ - uint32 reg_val = 0; - if (power_on) { - /* ENABLE */ - reg_val |= 0x00000001; /* Enable the block */ - if (external_common_state->hdmi_sink == 0) { - /* HDMI_DVI_SEL */ - reg_val |= 0x00000002; - if (hdmi_msm_state->hdcp_enable) - /* HDMI Encryption */ - reg_val |= 0x00000004; - /* HDMI_CTRL */ - HDMI_OUTP(0x0000, reg_val); - /* HDMI_DVI_SEL */ - reg_val &= ~0x00000002; - } else { - if (hdmi_msm_state->hdcp_enable) - /* HDMI_Encryption_ON */ - reg_val |= 0x00000006; - else - reg_val |= 0x00000002; - } - } else - reg_val = 0x00000002; - - /* HDMI_CTRL */ - HDMI_OUTP(0x0000, reg_val); - DEV_DBG("HDMI Core: %s, HDMI_CTRL=0x%08x\n", - power_on ? "Enable" : "Disable", reg_val); -} - -static void msm_hdmi_init_ddc(void) -{ - /* 0x0220 HDMI_DDC_SPEED - [31:16] PRESCALE prescale = (m * xtal_frequency) / - (desired_i2c_speed), where m is multiply - factor, default: m = 1 - [1:0] THRESHOLD Select threshold to use to determine whether value - sampled on SDA is a 1 or 0. Specified in terms of the ratio - between the number of sampled ones and the total number of times - SDA is sampled. - * 0x0: >0 - * 0x1: 1/4 of total samples - * 0x2: 1/2 of total samples - * 0x3: 3/4 of total samples */ - /* Configure the Pre-Scale multiplier - * Configure the Threshold */ - HDMI_OUTP_ND(0x0220, (10 << 16) | (2 << 0)); - - /* - * 0x0224 HDMI_DDC_SETUP - * Setting 31:24 bits : Time units to wait before timeout - * when clock is being stalled by external sink device - */ - HDMI_OUTP_ND(0x0224, 0xff000000); - - /* 0x027C HDMI_DDC_REF - [6] REFTIMER_ENABLE Enable the timer - * 0: Disable - * 1: Enable - [15:0] REFTIMER Value to set the register in order to generate - DDC strobe. This register counts on HDCP application clock */ - /* Enable reference timer - * 27 micro-seconds */ - HDMI_OUTP_ND(0x027C, (1 << 16) | (27 << 0)); -} - -static int hdmi_msm_ddc_clear_irq(const char *what) -{ - const uint32 time_out = 0xFFFF; - uint32 time_out_count, reg_val; - - /* clear pending and enable interrupt */ - time_out_count = time_out; - do { - --time_out_count; - /* HDMI_DDC_INT_CTRL[0x0214] - [2] SW_DONE_MK Mask bit for SW_DONE_INT. Set to 1 to enable - interrupt. - [1] SW_DONE_ACK WRITE ONLY. Acknowledge bit for SW_DONE_INT. - Write 1 to clear interrupt. - [0] SW_DONE_INT READ ONLY. SW_DONE interrupt status */ - /* Clear and Enable DDC interrupt */ - /* Write */ - HDMI_OUTP_ND(0x0214, (1 << 2) | (1 << 1)); - /* Read back */ - reg_val = HDMI_INP_ND(0x0214); - } while ((reg_val & 0x1) && time_out_count); - if (!time_out_count) { - DEV_ERR("%s[%s]: timedout\n", __func__, what); - return -ETIMEDOUT; - } - - return 0; -} - -static int hdmi_msm_ddc_write(uint32 dev_addr, uint32 offset, - const uint8 *data_buf, uint32 data_len, const char *what) -{ - uint32 reg_val, ndx; - int status = 0, retry = 10; - uint32 time_out_count; - - if (NULL == data_buf) { - status = -EINVAL; - DEV_ERR("%s[%s]: invalid input paramter\n", __func__, what); - goto error; - } - -again: - status = hdmi_msm_ddc_clear_irq(what); - if (status) - goto error; - - /* Ensure Device Address has LSB set to 0 to indicate Slave addr read */ - dev_addr &= 0xFE; - - /* 0x0238 HDMI_DDC_DATA - [31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to - 1 while writing HDMI_DDC_DATA. - [23:16] INDEX Use to set index into DDC buffer for next read or - current write, or to read index of current read or next write. - Writable only when INDEX_WRITE=1. - [15:8] DATA Use to fill or read the DDC buffer - [0] DATA_RW Select whether buffer access will be a read or write. - For writes, address auto-increments on write to HDMI_DDC_DATA. - For reads, address autoincrements on reads to HDMI_DDC_DATA. - * 0: Write - * 1: Read */ - - /* 1. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #1 - * DATA_RW = 0x1 (write) - * DATA = linkAddress (primary link address and writing) - * INDEX = 0x0 (initial offset into buffer) - * INDEX_WRITE = 0x1 (setting initial offset) */ - HDMI_OUTP_ND(0x0238, (0x1UL << 31) | (dev_addr << 8)); - - /* 2. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #2 - * DATA_RW = 0x0 (write) - * DATA = offsetAddress - * INDEX = 0x0 - * INDEX_WRITE = 0x0 (auto-increment by hardware) */ - HDMI_OUTP_ND(0x0238, offset << 8); - - /* 3. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #3 - * DATA_RW = 0x0 (write) - * DATA = data_buf[ndx] - * INDEX = 0x0 - * INDEX_WRITE = 0x0 (auto-increment by hardware) */ - for (ndx = 0; ndx < data_len; ++ndx) - HDMI_OUTP_ND(0x0238, ((uint32)data_buf[ndx]) << 8); - - /* Data setup is complete, now setup the transaction characteristics */ - - /* 0x0228 HDMI_DDC_TRANS0 - [23:16] CNT0 Byte count for first transaction (excluding the first - byte, which is usually the address). - [13] STOP0 Determines whether a stop bit will be sent after the first - transaction - * 0: NO STOP - * 1: STOP - [12] START0 Determines whether a start bit will be sent before the - first transaction - * 0: NO START - * 1: START - [8] STOP_ON_NACK0 Determines whether the current transfer will stop - if a NACK is received during the first transaction (current - transaction always stops). - * 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION - * 1: STOP ALL TRANSACTIONS, SEND STOP BIT - [0] RW0 Read/write indicator for first transaction - set to 0 for - write, 1 for read. This bit only controls HDMI_DDC behaviour - - the R/W bit in the transaction is programmed into the DDC buffer - as the LSB of the address byte. - * 0: WRITE - * 1: READ */ - - /* 4. Write to HDMI_I2C_TRANSACTION0 with the following fields set in - order to handle characteristics of portion #1 and portion #2 - * RW0 = 0x0 (write) - * START0 = 0x1 (insert START bit) - * STOP0 = 0x0 (do NOT insert STOP bit) - * CNT0 = 0x1 (single byte transaction excluding address) */ - HDMI_OUTP_ND(0x0228, (1 << 12) | (1 << 16)); - - /* 0x022C HDMI_DDC_TRANS1 - [23:16] CNT1 Byte count for second transaction (excluding the first - byte, which is usually the address). - [13] STOP1 Determines whether a stop bit will be sent after the second - transaction - * 0: NO STOP - * 1: STOP - [12] START1 Determines whether a start bit will be sent before the - second transaction - * 0: NO START - * 1: START - [8] STOP_ON_NACK1 Determines whether the current transfer will stop if - a NACK is received during the second transaction (current - transaction always stops). - * 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION - * 1: STOP ALL TRANSACTIONS, SEND STOP BIT - [0] RW1 Read/write indicator for second transaction - set to 0 for - write, 1 for read. This bit only controls HDMI_DDC behaviour - - the R/W bit in the transaction is programmed into the DDC buffer - as the LSB of the address byte. - * 0: WRITE - * 1: READ */ - - /* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in - order to handle characteristics of portion #3 - * RW1 = 0x1 (read) - * START1 = 0x1 (insert START bit) - * STOP1 = 0x1 (insert STOP bit) - * CNT1 = data_len (0xN (write N bytes of data)) - * Byte count for second transition (excluding the first - * Byte which is usually the address) */ - HDMI_OUTP_ND(0x022C, (1 << 13) | ((data_len-1) << 16)); - - /* Trigger the I2C transfer */ - /* 0x020C HDMI_DDC_CTRL - [21:20] TRANSACTION_CNT - Number of transactions to be done in current transfer. - * 0x0: transaction0 only - * 0x1: transaction0, transaction1 - * 0x2: transaction0, transaction1, transaction2 - * 0x3: transaction0, transaction1, transaction2, transaction3 - [3] SW_STATUS_RESET - Write 1 to reset HDMI_DDC_SW_STATUS flags, will reset SW_DONE, - ABORTED, TIMEOUT, SW_INTERRUPTED, BUFFER_OVERFLOW, - STOPPED_ON_NACK, NACK0, NACK1, NACK2, NACK3 - [2] SEND_RESET Set to 1 to send reset sequence (9 clocks with no - data) at start of transfer. This sequence is sent after GO is - written to 1, before the first transaction only. - [1] SOFT_RESET Write 1 to reset DDC controller - [0] GO WRITE ONLY. Write 1 to start DDC transfer. */ - - /* 6. Write to HDMI_I2C_CONTROL to kick off the hardware. - * Note that NOTHING has been transmitted on the DDC lines up to this - * point. - * TRANSACTION_CNT = 0x1 (execute transaction0 followed by - * transaction1) - * GO = 0x1 (kicks off hardware) */ - INIT_COMPLETION(hdmi_msm_state->ddc_sw_done); - HDMI_OUTP_ND(0x020C, (1 << 0) | (1 << 20)); - - time_out_count = wait_for_completion_interruptible_timeout( - &hdmi_msm_state->ddc_sw_done, HZ/2); - HDMI_OUTP_ND(0x0214, 0x2); - if (!time_out_count) { - if (retry-- > 0) { - DEV_INFO("%s[%s]: failed timout, retry=%d\n", __func__, - what, retry); - goto again; - } - status = -ETIMEDOUT; - DEV_ERR("%s[%s]: timedout, DDC SW Status=%08x, HW " - "Status=%08x, Int Ctrl=%08x\n", __func__, what, - HDMI_INP_ND(0x0218), HDMI_INP_ND(0x021C), - HDMI_INP_ND(0x0214)); - goto error; - } - - /* Read DDC status */ - reg_val = HDMI_INP_ND(0x0218); - reg_val &= 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000; - - /* Check if any NACK occurred */ - if (reg_val) { - if (retry > 1) - HDMI_OUTP_ND(0x020C, BIT(3)); /* SW_STATUS_RESET */ - else - HDMI_OUTP_ND(0x020C, BIT(1)); /* SOFT_RESET */ - if (retry-- > 0) { - DEV_DBG("%s[%s]: failed NACK=%08x, retry=%d\n", - __func__, what, reg_val, retry); - msleep(100); - goto again; - } - status = -EIO; - DEV_ERR("%s[%s]: failed NACK: %08x\n", __func__, what, reg_val); - goto error; - } - - DEV_DBG("%s[%s] success\n", __func__, what); - -error: - return status; -} - -static int hdmi_msm_ddc_read_retry(uint32 dev_addr, uint32 offset, - uint8 *data_buf, uint32 data_len, uint32 request_len, int retry, - const char *what) -{ - uint32 reg_val, ndx; - int status = 0; - uint32 time_out_count; - int log_retry_fail = retry != 1; - - if (NULL == data_buf) { - status = -EINVAL; - DEV_ERR("%s: invalid input paramter\n", __func__); - goto error; - } - -again: - status = hdmi_msm_ddc_clear_irq(what); - if (status) - goto error; - - /* Ensure Device Address has LSB set to 0 to indicate Slave addr read */ - dev_addr &= 0xFE; - - /* 0x0238 HDMI_DDC_DATA - [31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to - 1 while writing HDMI_DDC_DATA. - [23:16] INDEX Use to set index into DDC buffer for next read or - current write, or to read index of current read or next write. - Writable only when INDEX_WRITE=1. - [15:8] DATA Use to fill or read the DDC buffer - [0] DATA_RW Select whether buffer access will be a read or write. - For writes, address auto-increments on write to HDMI_DDC_DATA. - For reads, address autoincrements on reads to HDMI_DDC_DATA. - * 0: Write - * 1: Read */ - - /* 1. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #1 - * DATA_RW = 0x0 (write) - * DATA = linkAddress (primary link address and writing) - * INDEX = 0x0 (initial offset into buffer) - * INDEX_WRITE = 0x1 (setting initial offset) */ - HDMI_OUTP_ND(0x0238, (0x1UL << 31) | (dev_addr << 8)); - - /* 2. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #2 - * DATA_RW = 0x0 (write) - * DATA = offsetAddress - * INDEX = 0x0 - * INDEX_WRITE = 0x0 (auto-increment by hardware) */ - HDMI_OUTP_ND(0x0238, offset << 8); - - /* 3. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #3 - * DATA_RW = 0x0 (write) - * DATA = linkAddress + 1 (primary link address 0x74 and reading) - * INDEX = 0x0 - * INDEX_WRITE = 0x0 (auto-increment by hardware) */ - HDMI_OUTP_ND(0x0238, (dev_addr | 1) << 8); - - /* Data setup is complete, now setup the transaction characteristics */ - - /* 0x0228 HDMI_DDC_TRANS0 - [23:16] CNT0 Byte count for first transaction (excluding the first - byte, which is usually the address). - [13] STOP0 Determines whether a stop bit will be sent after the first - transaction - * 0: NO STOP - * 1: STOP - [12] START0 Determines whether a start bit will be sent before the - first transaction - * 0: NO START - * 1: START - [8] STOP_ON_NACK0 Determines whether the current transfer will stop - if a NACK is received during the first transaction (current - transaction always stops). - * 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION - * 1: STOP ALL TRANSACTIONS, SEND STOP BIT - [0] RW0 Read/write indicator for first transaction - set to 0 for - write, 1 for read. This bit only controls HDMI_DDC behaviour - - the R/W bit in the transaction is programmed into the DDC buffer - as the LSB of the address byte. - * 0: WRITE - * 1: READ */ - - /* 4. Write to HDMI_I2C_TRANSACTION0 with the following fields set in - order to handle characteristics of portion #1 and portion #2 - * RW0 = 0x0 (write) - * START0 = 0x1 (insert START bit) - * STOP0 = 0x0 (do NOT insert STOP bit) - * CNT0 = 0x1 (single byte transaction excluding address) */ - HDMI_OUTP_ND(0x0228, (1 << 12) | (1 << 16)); - - /* 0x022C HDMI_DDC_TRANS1 - [23:16] CNT1 Byte count for second transaction (excluding the first - byte, which is usually the address). - [13] STOP1 Determines whether a stop bit will be sent after the second - transaction - * 0: NO STOP - * 1: STOP - [12] START1 Determines whether a start bit will be sent before the - second transaction - * 0: NO START - * 1: START - [8] STOP_ON_NACK1 Determines whether the current transfer will stop if - a NACK is received during the second transaction (current - transaction always stops). - * 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION - * 1: STOP ALL TRANSACTIONS, SEND STOP BIT - [0] RW1 Read/write indicator for second transaction - set to 0 for - write, 1 for read. This bit only controls HDMI_DDC behaviour - - the R/W bit in the transaction is programmed into the DDC buffer - as the LSB of the address byte. - * 0: WRITE - * 1: READ */ - - /* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in - order to handle characteristics of portion #3 - * RW1 = 0x1 (read) - * START1 = 0x1 (insert START bit) - * STOP1 = 0x1 (insert STOP bit) - * CNT1 = data_len (it's 128 (0x80) for a blk read) */ - HDMI_OUTP_ND(0x022C, 1 | (1 << 12) | (1 << 13) | (request_len << 16)); - - /* Trigger the I2C transfer */ - /* 0x020C HDMI_DDC_CTRL - [21:20] TRANSACTION_CNT - Number of transactions to be done in current transfer. - * 0x0: transaction0 only - * 0x1: transaction0, transaction1 - * 0x2: transaction0, transaction1, transaction2 - * 0x3: transaction0, transaction1, transaction2, transaction3 - [3] SW_STATUS_RESET - Write 1 to reset HDMI_DDC_SW_STATUS flags, will reset SW_DONE, - ABORTED, TIMEOUT, SW_INTERRUPTED, BUFFER_OVERFLOW, - STOPPED_ON_NACK, NACK0, NACK1, NACK2, NACK3 - [2] SEND_RESET Set to 1 to send reset sequence (9 clocks with no - data) at start of transfer. This sequence is sent after GO is - written to 1, before the first transaction only. - [1] SOFT_RESET Write 1 to reset DDC controller - [0] GO WRITE ONLY. Write 1 to start DDC transfer. */ - - /* 6. Write to HDMI_I2C_CONTROL to kick off the hardware. - * Note that NOTHING has been transmitted on the DDC lines up to this - * point. - * TRANSACTION_CNT = 0x1 (execute transaction0 followed by - * transaction1) - * SEND_RESET = Set to 1 to send reset sequence - * GO = 0x1 (kicks off hardware) */ - INIT_COMPLETION(hdmi_msm_state->ddc_sw_done); - HDMI_OUTP_ND(0x020C, (1 << 0) | (1 << 20)); - - time_out_count = wait_for_completion_interruptible_timeout( - &hdmi_msm_state->ddc_sw_done, HZ/2); - HDMI_OUTP_ND(0x0214, 0x2); - if (!time_out_count) { - if (retry-- > 0) { - DEV_INFO("%s: failed timout, retry=%d\n", __func__, - retry); - goto again; - } - status = -ETIMEDOUT; - DEV_ERR("%s: timedout(7), DDC SW Status=%08x, HW " - "Status=%08x, Int Ctrl=%08x\n", __func__, - HDMI_INP(0x0218), HDMI_INP(0x021C), HDMI_INP(0x0214)); - goto error; - } - - /* Read DDC status */ - reg_val = HDMI_INP_ND(0x0218); - reg_val &= 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000; - - /* Check if any NACK occurred */ - if (reg_val) { - HDMI_OUTP_ND(0x020C, BIT(3)); /* SW_STATUS_RESET */ - if (retry == 1) - HDMI_OUTP_ND(0x020C, BIT(1)); /* SOFT_RESET */ - if (retry-- > 0) { - DEV_DBG("%s(%s): failed NACK=0x%08x, retry=%d, " - "dev-addr=0x%02x, offset=0x%02x, " - "length=%d\n", __func__, what, - reg_val, retry, dev_addr, - offset, data_len); - goto again; - } - status = -EIO; - if (log_retry_fail) - DEV_ERR("%s(%s): failed NACK=0x%08x, dev-addr=0x%02x, " - "offset=0x%02x, length=%d\n", __func__, what, - reg_val, dev_addr, offset, data_len); - goto error; - } - - /* 0x0238 HDMI_DDC_DATA - [31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to 1 - while writing HDMI_DDC_DATA. - [23:16] INDEX Use to set index into DDC buffer for next read or - current write, or to read index of current read or next write. - Writable only when INDEX_WRITE=1. - [15:8] DATA Use to fill or read the DDC buffer - [0] DATA_RW Select whether buffer access will be a read or write. - For writes, address auto-increments on write to HDMI_DDC_DATA. - For reads, address autoincrements on reads to HDMI_DDC_DATA. - * 0: Write - * 1: Read */ - - /* 8. ALL data is now available and waiting in the DDC buffer. - * Read HDMI_I2C_DATA with the following fields set - * RW = 0x1 (read) - * DATA = BCAPS (this is field where data is pulled from) - * INDEX = 0x3 (where the data has been placed in buffer by hardware) - * INDEX_WRITE = 0x1 (explicitly define offset) */ - /* Write this data to DDC buffer */ - HDMI_OUTP_ND(0x0238, 0x1 | (3 << 16) | (1 << 31)); - - /* Discard first byte */ - HDMI_INP_ND(0x0238); - for (ndx = 0; ndx < data_len; ++ndx) { - reg_val = HDMI_INP_ND(0x0238); - data_buf[ndx] = (uint8) ((reg_val & 0x0000FF00) >> 8); - } - - DEV_DBG("%s[%s] success\n", __func__, what); - -error: - return status; -} - -static int hdmi_msm_ddc_read_edid_seg(uint32 dev_addr, uint32 offset, - uint8 *data_buf, uint32 data_len, uint32 request_len, int retry, - const char *what) -{ - uint32 reg_val, ndx; - int status = 0; - uint32 time_out_count; - int log_retry_fail = retry != 1; - int seg_addr = 0x60, seg_num = 0x01; - - if (NULL == data_buf) { - status = -EINVAL; - DEV_ERR("%s: invalid input paramter\n", __func__); - goto error; - } - -again: - status = hdmi_msm_ddc_clear_irq(what); - if (status) - goto error; - - /* Ensure Device Address has LSB set to 0 to indicate Slave addr read */ - dev_addr &= 0xFE; - - /* 0x0238 HDMI_DDC_DATA - [31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to - 1 while writing HDMI_DDC_DATA. - [23:16] INDEX Use to set index into DDC buffer for next read or - current write, or to read index of current read or next write. - Writable only when INDEX_WRITE=1. - [15:8] DATA Use to fill or read the DDC buffer - [0] DATA_RW Select whether buffer access will be a read or write. - For writes, address auto-increments on write to HDMI_DDC_DATA. - For reads, address autoincrements on reads to HDMI_DDC_DATA. - * 0: Write - * 1: Read */ - - /* 1. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #1 - * DATA_RW = 0x0 (write) - * DATA = linkAddress (primary link address and writing) - * INDEX = 0x0 (initial offset into buffer) - * INDEX_WRITE = 0x1 (setting initial offset) */ - HDMI_OUTP_ND(0x0238, (0x1UL << 31) | (seg_addr << 8)); - - /* 2. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #2 - * DATA_RW = 0x0 (write) - * DATA = offsetAddress - * INDEX = 0x0 - * INDEX_WRITE = 0x0 (auto-increment by hardware) */ - HDMI_OUTP_ND(0x0238, seg_num << 8); - - /* 3. Write to HDMI_I2C_DATA with the following fields set in order to - * handle portion #3 - * DATA_RW = 0x0 (write) - * DATA = linkAddress + 1 (primary link address 0x74 and reading) - * INDEX = 0x0 - * INDEX_WRITE = 0x0 (auto-increment by hardware) */ - HDMI_OUTP_ND(0x0238, dev_addr << 8); - HDMI_OUTP_ND(0x0238, offset << 8); - HDMI_OUTP_ND(0x0238, (dev_addr | 1) << 8); - - /* Data setup is complete, now setup the transaction characteristics */ - - /* 0x0228 HDMI_DDC_TRANS0 - [23:16] CNT0 Byte count for first transaction (excluding the first - byte, which is usually the address). - [13] STOP0 Determines whether a stop bit will be sent after the first - transaction - * 0: NO STOP - * 1: STOP - [12] START0 Determines whether a start bit will be sent before the - first transaction - * 0: NO START - * 1: START - [8] STOP_ON_NACK0 Determines whether the current transfer will stop - if a NACK is received during the first transaction (current - transaction always stops). - * 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION - * 1: STOP ALL TRANSACTIONS, SEND STOP BIT - [0] RW0 Read/write indicator for first transaction - set to 0 for - write, 1 for read. This bit only controls HDMI_DDC behaviour - - the R/W bit in the transaction is programmed into the DDC buffer - as the LSB of the address byte. - * 0: WRITE - * 1: READ */ - - /* 4. Write to HDMI_I2C_TRANSACTION0 with the following fields set in - order to handle characteristics of portion #1 and portion #2 - * RW0 = 0x0 (write) - * START0 = 0x1 (insert START bit) - * STOP0 = 0x0 (do NOT insert STOP bit) - * CNT0 = 0x1 (single byte transaction excluding address) */ - HDMI_OUTP_ND(0x0228, (1 << 12) | (1 << 16)); - - /* 0x022C HDMI_DDC_TRANS1 - [23:16] CNT1 Byte count for second transaction (excluding the first - byte, which is usually the address). - [13] STOP1 Determines whether a stop bit will be sent after the second - transaction - * 0: NO STOP - * 1: STOP - [12] START1 Determines whether a start bit will be sent before the - second transaction - * 0: NO START - * 1: START - [8] STOP_ON_NACK1 Determines whether the current transfer will stop if - a NACK is received during the second transaction (current - transaction always stops). - * 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION - * 1: STOP ALL TRANSACTIONS, SEND STOP BIT - [0] RW1 Read/write indicator for second transaction - set to 0 for - write, 1 for read. This bit only controls HDMI_DDC behaviour - - the R/W bit in the transaction is programmed into the DDC buffer - as the LSB of the address byte. - * 0: WRITE - * 1: READ */ - - /* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in - order to handle characteristics of portion #3 - * RW1 = 0x1 (read) - * START1 = 0x1 (insert START bit) - * STOP1 = 0x1 (insert STOP bit) - * CNT1 = data_len (it's 128 (0x80) for a blk read) */ - HDMI_OUTP_ND(0x022C, (1 << 12) | (1 << 16)); - - /* 0x022C HDMI_DDC_TRANS2 - [23:16] CNT1 Byte count for second transaction (excluding the first - byte, which is usually the address). - [13] STOP1 Determines whether a stop bit will be sent after the second - transaction - * 0: NO STOP - * 1: STOP - [12] START1 Determines whether a start bit will be sent before the - second transaction - * 0: NO START - * 1: START - [8] STOP_ON_NACK1 Determines whether the current transfer will stop if - a NACK is received during the second transaction (current - transaction always stops). - * 0: STOP CURRENT TRANSACTION, GO TO NEXT TRANSACTION - * 1: STOP ALL TRANSACTIONS, SEND STOP BIT - [0] RW1 Read/write indicator for second transaction - set to 0 for - write, 1 for read. This bit only controls HDMI_DDC behaviour - - the R/W bit in the transaction is programmed into the DDC buffer - as the LSB of the address byte. - * 0: WRITE - * 1: READ */ - - /* 5. Write to HDMI_I2C_TRANSACTION1 with the following fields set in - order to handle characteristics of portion #3 - * RW1 = 0x1 (read) - * START1 = 0x1 (insert START bit) - * STOP1 = 0x1 (insert STOP bit) - * CNT1 = data_len (it's 128 (0x80) for a blk read) */ - HDMI_OUTP_ND(0x0230, 1 | (1 << 12) | (1 << 13) | (request_len << 16)); - - /* Trigger the I2C transfer */ - /* 0x020C HDMI_DDC_CTRL - [21:20] TRANSACTION_CNT - Number of transactions to be done in current transfer. - * 0x0: transaction0 only - * 0x1: transaction0, transaction1 - * 0x2: transaction0, transaction1, transaction2 - * 0x3: transaction0, transaction1, transaction2, transaction3 - [3] SW_STATUS_RESET - Write 1 to reset HDMI_DDC_SW_STATUS flags, will reset SW_DONE, - ABORTED, TIMEOUT, SW_INTERRUPTED, BUFFER_OVERFLOW, - STOPPED_ON_NACK, NACK0, NACK1, NACK2, NACK3 - [2] SEND_RESET Set to 1 to send reset sequence (9 clocks with no - data) at start of transfer. This sequence is sent after GO is - written to 1, before the first transaction only. - [1] SOFT_RESET Write 1 to reset DDC controller - [0] GO WRITE ONLY. Write 1 to start DDC transfer. */ - - /* 6. Write to HDMI_I2C_CONTROL to kick off the hardware. - * Note that NOTHING has been transmitted on the DDC lines up to this - * point. - * TRANSACTION_CNT = 0x2 (execute transaction0 followed by - * transaction1) - * GO = 0x1 (kicks off hardware) */ - INIT_COMPLETION(hdmi_msm_state->ddc_sw_done); - HDMI_OUTP_ND(0x020C, (1 << 0) | (2 << 20)); - - time_out_count = wait_for_completion_interruptible_timeout( - &hdmi_msm_state->ddc_sw_done, HZ/2); - HDMI_OUTP_ND(0x0214, 0x2); - if (!time_out_count) { - if (retry-- > 0) { - DEV_INFO("%s: failed timout, retry=%d\n", __func__, - retry); - goto again; - } - status = -ETIMEDOUT; - DEV_ERR("%s: timedout(7), DDC SW Status=%08x, HW " - "Status=%08x, Int Ctrl=%08x\n", __func__, - HDMI_INP(0x0218), HDMI_INP(0x021C), HDMI_INP(0x0214)); - goto error; - } - - /* Read DDC status */ - reg_val = HDMI_INP_ND(0x0218); - reg_val &= 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000; - - /* Check if any NACK occurred */ - if (reg_val) { - HDMI_OUTP_ND(0x020C, BIT(3)); /* SW_STATUS_RESET */ - if (retry == 1) - HDMI_OUTP_ND(0x020C, BIT(1)); /* SOFT_RESET */ - if (retry-- > 0) { - DEV_DBG("%s(%s): failed NACK=0x%08x, retry=%d, " - "dev-addr=0x%02x, offset=0x%02x, " - "length=%d\n", __func__, what, - reg_val, retry, dev_addr, - offset, data_len); - goto again; - } - status = -EIO; - if (log_retry_fail) - DEV_ERR("%s(%s): failed NACK=0x%08x, dev-addr=0x%02x, " - "offset=0x%02x, length=%d\n", __func__, what, - reg_val, dev_addr, offset, data_len); - goto error; - } - - /* 0x0238 HDMI_DDC_DATA - [31] INDEX_WRITE WRITE ONLY. To write index field, set this bit to 1 - while writing HDMI_DDC_DATA. - [23:16] INDEX Use to set index into DDC buffer for next read or - current write, or to read index of current read or next write. - Writable only when INDEX_WRITE=1. - [15:8] DATA Use to fill or read the DDC buffer - [0] DATA_RW Select whether buffer access will be a read or write. - For writes, address auto-increments on write to HDMI_DDC_DATA. - For reads, address autoincrements on reads to HDMI_DDC_DATA. - * 0: Write - * 1: Read */ - - /* 8. ALL data is now available and waiting in the DDC buffer. - * Read HDMI_I2C_DATA with the following fields set - * RW = 0x1 (read) - * DATA = BCAPS (this is field where data is pulled from) - * INDEX = 0x5 (where the data has been placed in buffer by hardware) - * INDEX_WRITE = 0x1 (explicitly define offset) */ - /* Write this data to DDC buffer */ - HDMI_OUTP_ND(0x0238, 0x1 | (5 << 16) | (1 << 31)); - - /* Discard first byte */ - HDMI_INP_ND(0x0238); - - for (ndx = 0; ndx < data_len; ++ndx) { - reg_val = HDMI_INP_ND(0x0238); - data_buf[ndx] = (uint8) ((reg_val & 0x0000FF00) >> 8); - } - - DEV_DBG("%s[%s] success\n", __func__, what); - -error: - return status; -} - - -static int hdmi_msm_ddc_read(uint32 dev_addr, uint32 offset, uint8 *data_buf, - uint32 data_len, int retry, const char *what, boolean no_align) -{ - int ret = hdmi_msm_ddc_read_retry(dev_addr, offset, data_buf, data_len, - data_len, retry, what); - if (!ret) - return 0; - if (no_align) { - return hdmi_msm_ddc_read_retry(dev_addr, offset, data_buf, - data_len, data_len, retry, what); - } else { - return hdmi_msm_ddc_read_retry(dev_addr, offset, data_buf, - data_len, 32 * ((data_len + 31) / 32), retry, what); - } -} - - -static int hdmi_msm_read_edid_block(int block, uint8 *edid_buf) -{ - int i, rc = 0; - int block_size = 0x80; - - do { - DEV_DBG("EDID: reading block(%d) with block-size=%d\n", - block, block_size); - for (i = 0; i < 0x80; i += block_size) { - /*Read EDID twice with 32bit alighnment too */ - if (block < 2) { - rc = hdmi_msm_ddc_read(0xA0, block*0x80 + i, - edid_buf+i, block_size, 1, - "EDID", FALSE); - } else { - rc = hdmi_msm_ddc_read_edid_seg(0xA0, - block*0x80 + i, edid_buf+i, block_size, - block_size, 1, "EDID"); - } - if (rc) - break; - } - - block_size /= 2; - } while (rc && (block_size >= 16)); - - return rc; -} - -static int hdmi_msm_read_edid(void) -{ - int status; - - msm_hdmi_init_ddc(); - /* Looks like we need to turn on HDMI engine before any - * DDC transaction */ - if (!hdmi_msm_is_power_on()) { - DEV_ERR("%s: failed: HDMI power is off", __func__); - status = -ENXIO; - goto error; - } - - external_common_state->read_edid_block = hdmi_msm_read_edid_block; - status = hdmi_common_read_edid(); - if (!status) - DEV_DBG("EDID: successfully read\n"); - -error: - return status; -} - -static void hdcp_auth_info(uint32 auth_info) -{ - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return; - } - - switch (auth_info) { - case 0: - DEV_INFO("%s: None", __func__); - break; - case 1: - DEV_INFO("%s: Software Disabled Authentication", __func__); - break; - case 2: - DEV_INFO("%s: An Written", __func__); - break; - case 3: - DEV_INFO("%s: Invalid Aksv", __func__); - break; - case 4: - DEV_INFO("%s: Invalid Bksv", __func__); - break; - case 5: - DEV_INFO("%s: RI Mismatch (including RO)", __func__); - break; - case 6: - DEV_INFO("%s: consecutive Pj Mismatches", __func__); - break; - case 7: - DEV_INFO("%s: HPD Disconnect", __func__); - break; - case 8: - default: - DEV_INFO("%s: Reserved", __func__); - break; - } -} - -static void hdcp_key_state(uint32 key_state) -{ - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return; - } - - switch (key_state) { - case 0: - DEV_WARN("%s: No HDCP Keys", __func__); - break; - case 1: - DEV_WARN("%s: Not Checked", __func__); - break; - case 2: - DEV_DBG("%s: Checking", __func__); - break; - case 3: - DEV_DBG("%s: HDCP Keys Valid", __func__); - break; - case 4: - DEV_WARN("%s: AKSV not valid", __func__); - break; - case 5: - DEV_WARN("%s: Checksum Mismatch", __func__); - break; - case 6: - DEV_DBG("%s: Production AKSV" - "with ENABLE_USER_DEFINED_AN=1", __func__); - break; - case 7: - default: - DEV_INFO("%s: Reserved", __func__); - break; - } -} - -static int hdmi_msm_count_one(uint8 *array, uint8 len) -{ - int i, j, count = 0; - for (i = 0; i < len; i++) - for (j = 0; j < 8; j++) - count += (((array[i] >> j) & 0x1) ? 1 : 0); - return count; -} - -static void hdcp_deauthenticate(void) -{ - int hdcp_link_status = HDMI_INP(0x011C); - - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return; - } - - /* Disable HDCP interrupts */ - HDMI_OUTP(0x0118, 0x0); - - mutex_lock(&hdcp_auth_state_mutex); - external_common_state->hdcp_active = FALSE; - mutex_unlock(&hdcp_auth_state_mutex); - /* 0x0130 HDCP_RESET - [0] LINK0_DEAUTHENTICATE */ - HDMI_OUTP(0x0130, 0x1); - - /* 0x0110 HDCP_CTRL - [8] ENCRYPTION_ENABLE - [0] ENABLE */ - /* encryption_enable = 0 | hdcp block enable = 1 */ - HDMI_OUTP(0x0110, 0x0); - - if (hdcp_link_status & 0x00000004) - hdcp_auth_info((hdcp_link_status & 0x000000F0) >> 4); -} - -static void check_and_clear_HDCP_DDC_Failure(void) -{ - int hdcp_ddc_ctrl1_reg; - int hdcp_ddc_status; - int failure; - int nack0; - - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return; - } - - /* - * Check for any DDC transfer failures - * 0x0128 HDCP_DDC_STATUS - * [16] FAILED Indicates that the last HDCP HW DDC transer - * failed. This occurs when a transfer is - * attempted with HDCP DDC disabled - * (HDCP_DDC_DISABLE=1) or the number of retries - * match HDCP_DDC_RETRY_CNT - * - * [14] NACK0 Indicates that the last HDCP HW DDC transfer - * was aborted due to a NACK on the first - * transaction - cleared by writing 0 to GO bit - */ - hdcp_ddc_status = HDMI_INP(HDCP_DDC_STATUS); - failure = (hdcp_ddc_status >> 16) & 0x1; - nack0 = (hdcp_ddc_status >> 14) & 0x1; - DEV_DBG("%s: On Entry: HDCP_DDC_STATUS = 0x%x, FAILURE = %d," - "NACK0 = %d\n", __func__ , hdcp_ddc_status, failure, nack0); - - if (failure == 0x1) { - /* - * Indicates that the last HDCP HW DDC transfer failed. - * This occurs when a transfer is attempted with HDCP DDC - * disabled (HDCP_DDC_DISABLE=1) or the number of retries - * matches HDCP_DDC_RETRY_CNT. - * Failure occured, let's clear it. - */ - DEV_INFO("%s: DDC failure detected. HDCP_DDC_STATUS=0x%08x\n", - __func__, hdcp_ddc_status); - /* - * First, Disable DDC - * 0x0120 HDCP_DDC_CTRL_0 - * [0] DDC_DISABLE Determines whether HDCP Ri and Pj reads - * are done unassisted by hardware or by - * software via HDMI_DDC (HDCP provides - * interrupts to request software - * transfers) - * 0 : Use Hardware DDC - * 1 : Use Software DDC - */ - HDMI_OUTP(HDCP_DDC_CTRL_0, 0x1); - - /* - * ACK the Failure to Clear it - * 0x0124 HDCP_DDC_CTRL_1 - * [0] DDC_FAILED_ACK Write 1 to clear - * HDCP_STATUS.HDCP_DDC_FAILED - */ - hdcp_ddc_ctrl1_reg = HDMI_INP(HDCP_DDC_CTRL_1); - HDMI_OUTP(HDCP_DDC_CTRL_1, hdcp_ddc_ctrl1_reg | 0x1); - - /* Check if the FAILURE got Cleared */ - hdcp_ddc_status = HDMI_INP(HDCP_DDC_STATUS); - hdcp_ddc_status = (hdcp_ddc_status >> 16) & 0x1; - if (hdcp_ddc_status == 0x0) { - DEV_INFO("%s: HDCP DDC Failure has been cleared\n", - __func__); - } else { - DEV_WARN("%s: Error: HDCP DDC Failure DID NOT get" - "cleared\n", __func__); - } - - /* Re-Enable HDCP DDC */ - HDMI_OUTP(HDCP_DDC_CTRL_0, 0x0); - } - - if (nack0 == 0x1) { - /* - * 0x020C HDMI_DDC_CTRL - * [3] SW_STATUS_RESET Write 1 to reset HDMI_DDC_SW_STATUS - * flags, will reset SW_DONE, ABORTED, - * TIMEOUT, SW_INTERRUPTED, - * BUFFER_OVERFLOW, STOPPED_ON_NACK, NACK0, - * NACK1, NACK2, NACK3 - */ - HDMI_OUTP_ND(HDMI_DDC_CTRL, - HDMI_INP(HDMI_DDC_CTRL) | (0x1 << 3)); - msleep(20); - HDMI_OUTP_ND(HDMI_DDC_CTRL, - HDMI_INP(HDMI_DDC_CTRL) & ~(0x1 << 3)); - } - - hdcp_ddc_status = HDMI_INP(HDCP_DDC_STATUS); - - failure = (hdcp_ddc_status >> 16) & 0x1; - nack0 = (hdcp_ddc_status >> 14) & 0x1; - DEV_DBG("%s: On Exit: HDCP_DDC_STATUS = 0x%x, FAILURE = %d," - "NACK0 = %d\n", __func__ , hdcp_ddc_status, failure, nack0); -} - - -static int hdcp_authentication_part1(void) -{ - int ret = 0; - boolean is_match; - boolean is_part1_done = FALSE; - uint32 timeout_count; - uint8 bcaps; - uint8 aksv[5]; - uint32 qfprom_aksv_0, qfprom_aksv_1, link0_aksv_0, link0_aksv_1; - uint8 bksv[5]; - uint32 link0_bksv_0, link0_bksv_1; - uint8 an[8]; - uint32 link0_an_0, link0_an_1; - uint32 hpd_int_status, hpd_int_ctrl; - - - static uint8 buf[0xFF]; - memset(buf, 0, sizeof(buf)); - - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return 0; - } - - if (!is_part1_done) { - is_part1_done = TRUE; - - /* Fetch aksv from QFprom, this info should be public. */ - qfprom_aksv_0 = inpdw(QFPROM_BASE + 0x000060D8); - qfprom_aksv_1 = inpdw(QFPROM_BASE + 0x000060DC); - - /* copy an and aksv to byte arrays for transmission */ - aksv[0] = qfprom_aksv_0 & 0xFF; - aksv[1] = (qfprom_aksv_0 >> 8) & 0xFF; - aksv[2] = (qfprom_aksv_0 >> 16) & 0xFF; - aksv[3] = (qfprom_aksv_0 >> 24) & 0xFF; - aksv[4] = qfprom_aksv_1 & 0xFF; - /* check there are 20 ones in AKSV */ - if (hdmi_msm_count_one(aksv, 5) != 20) { - DEV_ERR("HDCP: AKSV read from QFPROM doesn't have " - "20 1's and 20 0's, FAIL (AKSV=%02x%08x)\n", - qfprom_aksv_1, qfprom_aksv_0); - ret = -EINVAL; - goto error; - } - DEV_DBG("HDCP: AKSV=%02x%08x\n", qfprom_aksv_1, qfprom_aksv_0); - - /* 0x0288 HDCP_SW_LOWER_AKSV - [31:0] LOWER_AKSV */ - /* 0x0284 HDCP_SW_UPPER_AKSV - [7:0] UPPER_AKSV */ - - /* This is the lower 32 bits of the SW - * injected AKSV value(AKSV[31:0]) read - * from the EFUSE. It is needed for HDCP - * authentication and must be written - * before enabling HDCP. */ - HDMI_OUTP(0x0288, qfprom_aksv_0); - HDMI_OUTP(0x0284, qfprom_aksv_1); - - msm_hdmi_init_ddc(); - - /* read Bcaps at 0x40 in HDCP Port */ - ret = hdmi_msm_ddc_read(0x74, 0x40, &bcaps, 1, 5, "Bcaps", - TRUE); - if (ret) { - DEV_ERR("%s(%d): Read Bcaps failed", __func__, - __LINE__); - goto error; - } - DEV_DBG("HDCP: Bcaps=%02x\n", bcaps); - - /* HDCP setup prior to HDCP enabled */ - - /* 0x0148 HDCP_RCVPORT_DATA4 - [15:8] LINK0_AINFO - [7:0] LINK0_AKSV_1 */ - /* LINK0_AINFO = 0x2 FEATURE 1.1 on. - * = 0x0 FEATURE 1.1 off*/ - HDMI_OUTP(0x0148, 0x0); - - /* 0x012C HDCP_ENTROPY_CTRL0 - [31:0] BITS_OF_INFLUENCE_0 */ - /* 0x025C HDCP_ENTROPY_CTRL1 - [31:0] BITS_OF_INFLUENCE_1 */ - HDMI_OUTP(0x012C, 0xB1FFB0FF); - HDMI_OUTP(0x025C, 0xF00DFACE); - - /* 0x0114 HDCP_DEBUG_CTRL - [2] DEBUG_RNG_CIPHER - else default 0 */ - HDMI_OUTP(0x0114, HDMI_INP(0x0114) & 0xFFFFFFFB); - - /* 0x0110 HDCP_CTRL - [8] ENCRYPTION_ENABLE - [0] ENABLE */ - /* Enable HDCP. Encryption should be enabled after reading R0 */ - HDMI_OUTP(0x0110, BIT(0)); - - /* - * Check to see if a HDCP DDC Failure is indicated in - * HDCP_DDC_STATUS. If yes, clear it. - */ - check_and_clear_HDCP_DDC_Failure(); - - /* 0x0118 HDCP_INT_CTRL - * [2] AUTH_SUCCESS_MASK [R/W] Mask bit for\ - * HDCP Authentication - * Success interrupt - set to 1 to enable interrupt - * - * [6] AUTH_FAIL_MASK [R/W] Mask bit for HDCP - * Authentication - * Lost interrupt set to 1 to enable interrupt - * - * [7] AUTH_FAIL_INFO_ACK [W] Acknwledge bit for HDCP - * Auth Failure Info field - write 1 to clear - * - * [10] DDC_XFER_REQ_MASK [R/W] Mask bit for HDCP\ - * DDC Transfer - * Request interrupt - set to 1 to enable interrupt - * - * [14] DDC_XFER_DONE_MASK [R/W] Mask bit for HDCP\ - * DDC Transfer - * done interrupt - set to 1 to enable interrupt */ - /* enable all HDCP ints */ - HDMI_OUTP(0x0118, (1 << 2) | (1 << 6) | (1 << 7)); - - /* 0x011C HDCP_LINK0_STATUS - [8] AN_0_READY - [9] AN_1_READY */ - /* wait for an0 and an1 ready bits to be set in LINK0_STATUS */ - - mutex_lock(&hdcp_auth_state_mutex); - timeout_count = 100; - while (((HDMI_INP_ND(0x011C) & (0x3 << 8)) != (0x3 << 8)) - && timeout_count--) - msleep(20); - if (!timeout_count) { - ret = -ETIMEDOUT; - DEV_ERR("%s(%d): timedout, An0=%d, An1=%d\n", - __func__, __LINE__, - (HDMI_INP_ND(0x011C) & BIT(8)) >> 8, - (HDMI_INP_ND(0x011C) & BIT(9)) >> 9); - mutex_unlock(&hdcp_auth_state_mutex); - goto error; - } - - /* 0x0168 HDCP_RCVPORT_DATA12 - [23:8] BSTATUS - [7:0] BCAPS */ - HDMI_OUTP(0x0168, bcaps); - - /* 0x014C HDCP_RCVPORT_DATA5 - [31:0] LINK0_AN_0 */ - /* read an0 calculation */ - link0_an_0 = HDMI_INP(0x014C); - - /* 0x0150 HDCP_RCVPORT_DATA6 - [31:0] LINK0_AN_1 */ - /* read an1 calculation */ - link0_an_1 = HDMI_INP(0x0150); - mutex_unlock(&hdcp_auth_state_mutex); - - /* three bits 28..30 */ - hdcp_key_state((HDMI_INP(0x011C) >> 28) & 0x7); - - /* 0x0144 HDCP_RCVPORT_DATA3 - [31:0] LINK0_AKSV_0 public key - 0x0148 HDCP_RCVPORT_DATA4 - [15:8] LINK0_AINFO - [7:0] LINK0_AKSV_1 public key */ - link0_aksv_0 = HDMI_INP(0x0144); - link0_aksv_1 = HDMI_INP(0x0148); - - /* copy an and aksv to byte arrays for transmission */ - aksv[0] = link0_aksv_0 & 0xFF; - aksv[1] = (link0_aksv_0 >> 8) & 0xFF; - aksv[2] = (link0_aksv_0 >> 16) & 0xFF; - aksv[3] = (link0_aksv_0 >> 24) & 0xFF; - aksv[4] = link0_aksv_1 & 0xFF; - - an[0] = link0_an_0 & 0xFF; - an[1] = (link0_an_0 >> 8) & 0xFF; - an[2] = (link0_an_0 >> 16) & 0xFF; - an[3] = (link0_an_0 >> 24) & 0xFF; - an[4] = link0_an_1 & 0xFF; - an[5] = (link0_an_1 >> 8) & 0xFF; - an[6] = (link0_an_1 >> 16) & 0xFF; - an[7] = (link0_an_1 >> 24) & 0xFF; - - /* Write An 8 bytes to offset 0x18 */ - ret = hdmi_msm_ddc_write(0x74, 0x18, an, 8, "An"); - if (ret) { - DEV_ERR("%s(%d): Write An failed", __func__, __LINE__); - goto error; - } - - /* Write Aksv 5 bytes to offset 0x10 */ - ret = hdmi_msm_ddc_write(0x74, 0x10, aksv, 5, "Aksv"); - if (ret) { - DEV_ERR("%s(%d): Write Aksv failed", __func__, - __LINE__); - goto error; - } - DEV_DBG("HDCP: Link0-AKSV=%02x%08x\n", - link0_aksv_1 & 0xFF, link0_aksv_0); - - /* Read Bksv 5 bytes at 0x00 in HDCP port */ - ret = hdmi_msm_ddc_read(0x74, 0x00, bksv, 5, 5, "Bksv", TRUE); - if (ret) { - DEV_ERR("%s(%d): Read BKSV failed", __func__, __LINE__); - goto error; - } - /* check there are 20 ones in BKSV */ - if (hdmi_msm_count_one(bksv, 5) != 20) { - DEV_ERR("HDCP: BKSV read from Sink doesn't have " - "20 1's and 20 0's, FAIL (BKSV=" - "%02x%02x%02x%02x%02x)\n", - bksv[4], bksv[3], bksv[2], bksv[1], bksv[0]); - ret = -EINVAL; - goto error; - } - - link0_bksv_0 = bksv[3]; - link0_bksv_0 = (link0_bksv_0 << 8) | bksv[2]; - link0_bksv_0 = (link0_bksv_0 << 8) | bksv[1]; - link0_bksv_0 = (link0_bksv_0 << 8) | bksv[0]; - link0_bksv_1 = bksv[4]; - DEV_DBG("HDCP: BKSV=%02x%08x\n", link0_bksv_1, link0_bksv_0); - - /* 0x0134 HDCP_RCVPORT_DATA0 - [31:0] LINK0_BKSV_0 */ - HDMI_OUTP(0x0134, link0_bksv_0); - /* 0x0138 HDCP_RCVPORT_DATA1 - [31:0] LINK0_BKSV_1 */ - HDMI_OUTP(0x0138, link0_bksv_1); - DEV_DBG("HDCP: Link0-BKSV=%02x%08x\n", link0_bksv_1, - link0_bksv_0); - - /* HDMI_HPD_INT_STATUS[0x0250] */ - hpd_int_status = HDMI_INP_ND(0x0250); - /* HDMI_HPD_INT_CTRL[0x0254] */ - hpd_int_ctrl = HDMI_INP_ND(0x0254); - DEV_DBG("[SR-DEUG]: HPD_INTR_CTRL=[%u] HPD_INTR_STATUS=[%u] " - "before reading R0'\n", hpd_int_ctrl, hpd_int_status); - - /* - * HDCP Compliace Test case 1B-01: - * Wait here until all the ksv bytes have been - * read from the KSV FIFO register. - */ - msleep(125); - - /* Reading R0' 2 bytes at offset 0x08 */ - ret = hdmi_msm_ddc_read(0x74, 0x08, buf, 2, 5, "RO'", TRUE); - if (ret) { - DEV_ERR("%s(%d): Read RO's failed", __func__, - __LINE__); - goto error; - } - - DEV_DBG("HDCP: R0'=%02x%02x\n", buf[1], buf[0]); - INIT_COMPLETION(hdmi_msm_state->hdcp_success_done); - /* 0x013C HDCP_RCVPORT_DATA2_0 - [15:0] LINK0_RI */ - HDMI_OUTP(0x013C, (((uint32)buf[1]) << 8) | buf[0]); - - timeout_count = wait_for_completion_interruptible_timeout( - &hdmi_msm_state->hdcp_success_done, HZ*2); - - if (!timeout_count) { - ret = -ETIMEDOUT; - is_match = HDMI_INP(0x011C) & BIT(12); - DEV_ERR("%s(%d): timedout, Link0=<%s>\n", __func__, - __LINE__, - is_match ? "RI_MATCH" : "No RI Match INTR in time"); - if (!is_match) - goto error; - } - - /* 0x011C HDCP_LINK0_STATUS - [12] RI_MATCHES [0] MISMATCH, [1] MATCH - [0] AUTH_SUCCESS */ - /* Checking for RI, R0 Match */ - /* RI_MATCHES */ - if ((HDMI_INP(0x011C) & BIT(12)) != BIT(12)) { - ret = -EINVAL; - DEV_ERR("%s: HDCP_LINK0_STATUS[RI_MATCHES]: MISMATCH\n", - __func__); - goto error; - } - - /* Enable HDCP Encryption */ - HDMI_OUTP(0x0110, BIT(0) | BIT(8)); - - DEV_INFO("HDCP: authentication part I, successful\n"); - is_part1_done = FALSE; - return 0; -error: - DEV_ERR("[%s]: HDCP Reauthentication\n", __func__); - is_part1_done = FALSE; - return ret; - } else { - return 1; - } -} - -static int hdmi_msm_transfer_v_h(void) -{ - /* Read V'.HO 4 Byte at offset 0x20 */ - char what[20]; - int ret; - uint8 buf[4]; - - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return 0; - } - - snprintf(what, sizeof(what), "V' H0"); - ret = hdmi_msm_ddc_read(0x74, 0x20, buf, 4, 5, what, TRUE); - if (ret) { - DEV_ERR("%s: Read %s failed", __func__, what); - return ret; - } - DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ", - buf[0] , buf[1] , buf[2] , buf[3]); - - /* 0x0154 HDCP_RCVPORT_DATA7 - [31:0] V_HO */ - HDMI_OUTP(0x0154 , - (buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0])); - - snprintf(what, sizeof(what), "V' H1"); - ret = hdmi_msm_ddc_read(0x74, 0x24, buf, 4, 5, what, TRUE); - if (ret) { - DEV_ERR("%s: Read %s failed", __func__, what); - return ret; - } - DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ", - buf[0] , buf[1] , buf[2] , buf[3]); - - /* 0x0158 HDCP_RCVPORT_ DATA8 - [31:0] V_H1 */ - HDMI_OUTP(0x0158, - (buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0])); - - - snprintf(what, sizeof(what), "V' H2"); - ret = hdmi_msm_ddc_read(0x74, 0x28, buf, 4, 5, what, TRUE); - if (ret) { - DEV_ERR("%s: Read %s failed", __func__, what); - return ret; - } - DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ", - buf[0] , buf[1] , buf[2] , buf[3]); - - /* 0x015c HDCP_RCVPORT_DATA9 - [31:0] V_H2 */ - HDMI_OUTP(0x015c , - (buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0])); - - snprintf(what, sizeof(what), "V' H3"); - ret = hdmi_msm_ddc_read(0x74, 0x2c, buf, 4, 5, what, TRUE); - if (ret) { - DEV_ERR("%s: Read %s failed", __func__, what); - return ret; - } - DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ", - buf[0] , buf[1] , buf[2] , buf[3]); - - /* 0x0160 HDCP_RCVPORT_DATA10 - [31:0] V_H3 */ - HDMI_OUTP(0x0160, - (buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0])); - - snprintf(what, sizeof(what), "V' H4"); - ret = hdmi_msm_ddc_read(0x74, 0x30, buf, 4, 5, what, TRUE); - if (ret) { - DEV_ERR("%s: Read %s failed", __func__, what); - return ret; - } - DEV_DBG("buf[0]= %x , buf[1] = %x , buf[2] = %x , buf[3] = %x\n ", - buf[0] , buf[1] , buf[2] , buf[3]); - /* 0x0164 HDCP_RCVPORT_DATA11 - [31:0] V_H4 */ - HDMI_OUTP(0x0164, - (buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0])); - - return 0; -} - -static int hdcp_authentication_part2(void) -{ - int ret = 0; - uint32 timeout_count; - int i = 0; - int cnt = 0; - uint bstatus; - uint8 bcaps; - uint32 down_stream_devices; - uint32 ksv_bytes; - - static uint8 buf[0xFF]; - static uint8 kvs_fifo[5 * 127]; - - boolean max_devs_exceeded = 0; - boolean max_cascade_exceeded = 0; - - boolean ksv_done = FALSE; - - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return 0; - } - - memset(buf, 0, sizeof(buf)); - memset(kvs_fifo, 0, sizeof(kvs_fifo)); - - /* wait until READY bit is set in bcaps */ - timeout_count = 50; - do { - timeout_count--; - /* read bcaps 1 Byte at offset 0x40 */ - ret = hdmi_msm_ddc_read(0x74, 0x40, &bcaps, 1, 1, - "Bcaps", FALSE); - if (ret) { - DEV_ERR("%s(%d): Read Bcaps failed", __func__, - __LINE__); - goto error; - } - msleep(100); - } while ((0 == (bcaps & 0x20)) && timeout_count); /* READY (Bit 5) */ - if (!timeout_count) { - ret = -ETIMEDOUT; - DEV_ERR("%s:timedout(1)", __func__); - goto error; - } - - /* read bstatus 2 bytes at offset 0x41 */ - - ret = hdmi_msm_ddc_read(0x74, 0x41, buf, 2, 5, "Bstatus", FALSE); - if (ret) { - DEV_ERR("%s(%d): Read Bstatus failed", __func__, __LINE__); - goto error; - } - bstatus = buf[1]; - bstatus = (bstatus << 8) | buf[0]; - /* 0x0168 DCP_RCVPORT_DATA12 - [7:0] BCAPS - [23:8 BSTATUS */ - HDMI_OUTP(0x0168, bcaps | (bstatus << 8)); - /* BSTATUS [6:0] DEVICE_COUNT Number of HDMI device attached to repeater - * - see HDCP spec */ - down_stream_devices = bstatus & 0x7F; - - if (down_stream_devices == 0x0) { - /* There isn't any devices attaced to the Repeater */ - DEV_ERR("%s: there isn't any devices attached to the " - "Repeater\n", __func__); - ret = -EINVAL; - goto error; - } - - /* - * HDCP Compliance 1B-05: - * Check if no. of devices connected to repeater - * exceed max_devices_connected from bit 7 of Bstatus. - */ - max_devs_exceeded = (bstatus & 0x80) >> 7; - if (max_devs_exceeded == 0x01) { - DEV_ERR("%s: Number of devs connected to repeater " - "exceeds max_devs\n", __func__); - ret = -EINVAL; - goto hdcp_error; - } - - /* - * HDCP Compliance 1B-06: - * Check if no. of cascade connected to repeater - * exceed max_cascade_connected from bit 11 of Bstatus. - */ - max_cascade_exceeded = (bstatus & 0x800) >> 11; - if (max_cascade_exceeded == 0x01) { - DEV_ERR("%s: Number of cascade connected to repeater " - "exceeds max_cascade\n", __func__); - ret = -EINVAL; - goto hdcp_error; - } - - /* Read KSV FIFO over DDC - * Key Slection vector FIFO - * Used to pull downstream KSVs from HDCP Repeaters. - * All bytes (DEVICE_COUNT * 5) must be read in a single, - * auto incrementing access. - * All bytes read as 0x00 for HDCP Receivers that are not - * HDCP Repeaters (REPEATER == 0). */ - ksv_bytes = 5 * down_stream_devices; - /* Reading KSV FIFO / KSV FIFO */ - ksv_done = FALSE; - - ret = hdmi_msm_ddc_read(0x74, 0x43, kvs_fifo, ksv_bytes, 5, - "KSV FIFO", TRUE); - do { - if (ret) { - DEV_ERR("%s(%d): Read KSV FIFO failed", - __func__, __LINE__); - /* - * HDCP Compliace Test case 1B-01: - * Wait here until all the ksv bytes have been - * read from the KSV FIFO register. - */ - msleep(25); - } else { - ksv_done = TRUE; - } - cnt++; - } while (!ksv_done && cnt != 20); - - if (ksv_done == FALSE) - goto error; - - ret = hdmi_msm_transfer_v_h(); - if (ret) - goto error; - - /* Next: Write KSV FIFO to HDCP_SHA_DATA. - * This is done 1 byte at time starting with the LSB. - * On the very last byte write, - * the HDCP_SHA_DATA_DONE bit[0] - */ - - /* 0x023C HDCP_SHA_CTRL - [0] RESET [0] Enable, [1] Reset - [4] SELECT [0] DIGA_HDCP, [1] DIGB_HDCP */ - /* reset SHA engine */ - HDMI_OUTP(0x023C, 1); - /* enable SHA engine, SEL=DIGA_HDCP */ - HDMI_OUTP(0x023C, 0); - - for (i = 0; i < ksv_bytes - 1; i++) { - /* Write KSV byte and do not set DONE bit[0] */ - HDMI_OUTP_ND(0x0244, kvs_fifo[i] << 16); - - /* Once 64 bytes have been written, we need to poll for - * HDCP_SHA_BLOCK_DONE before writing any further - */ - if (i && !((i+1)%64)) { - timeout_count = 100; - while (!(HDMI_INP_ND(0x0240) & 0x1) - && (--timeout_count)) { - DEV_DBG("HDCP Auth Part II: Waiting for the " - "computation of the current 64 byte to " - "complete. HDCP_SHA_STATUS=%08x. " - "timeout_count=%d\n", - HDMI_INP_ND(0x0240), timeout_count); - msleep(20); - } - if (!timeout_count) { - ret = -ETIMEDOUT; - DEV_ERR("%s(%d): timedout", __func__, __LINE__); - goto error; - } - } - - } - - /* Write l to DONE bit[0] */ - HDMI_OUTP_ND(0x0244, (kvs_fifo[ksv_bytes - 1] << 16) | 0x1); - - /* 0x0240 HDCP_SHA_STATUS - [4] COMP_DONE */ - /* Now wait for HDCP_SHA_COMP_DONE */ - timeout_count = 100; - while ((0x10 != (HDMI_INP_ND(0x0240) & 0xFFFFFF10)) && --timeout_count) - msleep(20); - - if (!timeout_count) { - ret = -ETIMEDOUT; - DEV_ERR("%s(%d): timedout", __func__, __LINE__); - goto error; - } - - /* 0x011C HDCP_LINK0_STATUS - [20] V_MATCHES */ - timeout_count = 100; - while (((HDMI_INP_ND(0x011C) & (1 << 20)) != (1 << 20)) - && --timeout_count) { - msleep(20); - } - - if (!timeout_count) { - ret = -ETIMEDOUT; - DEV_ERR("%s(%d): timedout", __func__, __LINE__); - goto error; - } - - DEV_INFO("HDCP: authentication part II, successful\n"); - -hdcp_error: -error: - return ret; -} - -static int hdcp_authentication_part3(uint32 found_repeater) -{ - int ret = 0; - int poll = 3000; - - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return 0; - } - - while (poll) { - /* 0x011C HDCP_LINK0_STATUS - [30:28] KEYS_STATE = 3 = "Valid" - [24] RO_COMPUTATION_DONE [0] Not Done, [1] Done - [20] V_MATCHES [0] Mismtach, [1] Match - [12] RI_MATCHES [0] Mismatch, [1] Match - [0] AUTH_SUCCESS */ - if (HDMI_INP_ND(0x011C) != (0x31001001 | - (found_repeater << 20))) { - DEV_ERR("HDCP: autentication part III, FAILED, " - "Link Status=%08x\n", HDMI_INP(0x011C)); - ret = -EINVAL; - goto error; - } - poll--; - } - - DEV_INFO("HDCP: authentication part III, successful\n"); - -error: - return ret; -} - -static void hdmi_msm_hdcp_enable(void) -{ - int ret = 0; - uint8 bcaps; - uint32 found_repeater = 0x0; - char *envp[2]; - - if (!hdmi_msm_state->hdcp_enable) { - DEV_INFO("%s: HDCP NOT ENABLED\n", __func__); - return; - } - - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->hdcp_activating = TRUE; - mutex_unlock(&hdmi_msm_state_mutex); - - mutex_lock(&hdcp_auth_state_mutex); - /* This flag prevents other threads from re-authenticating - * after we've just authenticated (i.e., finished part3) - * We probably need to protect this in a mutex lock */ - hdmi_msm_state->full_auth_done = FALSE; - mutex_unlock(&hdcp_auth_state_mutex); - - /* Disable HDCP before we start part1 */ - HDMI_OUTP(0x0110, 0x0); - - /* PART I Authentication*/ - ret = hdcp_authentication_part1(); - if (ret) - goto error; - - /* PART II Authentication*/ - /* read Bcaps at 0x40 in HDCP Port */ - ret = hdmi_msm_ddc_read(0x74, 0x40, &bcaps, 1, 5, "Bcaps", FALSE); - if (ret) { - DEV_ERR("%s(%d): Read Bcaps failed\n", __func__, __LINE__); - goto error; - } - DEV_DBG("HDCP: Bcaps=0x%02x (%s)\n", bcaps, - (bcaps & BIT(6)) ? "repeater" : "no repeater"); - - /* if REPEATER (Bit 6), perform Part2 Authentication */ - if (bcaps & BIT(6)) { - found_repeater = 0x1; - ret = hdcp_authentication_part2(); - if (ret) - goto error; - } else - DEV_INFO("HDCP: authentication part II skipped, no repeater\n"); - - /* PART III Authentication*/ - ret = hdcp_authentication_part3(found_repeater); - if (ret) - goto error; - - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->hdcp_activating = FALSE; - mutex_unlock(&hdmi_msm_state_mutex); - - mutex_lock(&hdcp_auth_state_mutex); - /* - * This flag prevents other threads from re-authenticating - * after we've just authenticated (i.e., finished part3) - */ - hdmi_msm_state->full_auth_done = TRUE; - external_common_state->hdcp_active = TRUE; - mutex_unlock(&hdcp_auth_state_mutex); - - if (!hdmi_msm_is_dvi_mode()) { - DEV_INFO("HDMI HPD: sense : send HDCP_PASS\n"); - envp[0] = "HDCP_STATE=PASS"; - envp[1] = NULL; - kobject_uevent_env(external_common_state->uevent_kobj, - KOBJ_CHANGE, envp); - - SWITCH_SET_HDMI_AUDIO(1, 0); - } - - return; - -error: - if (hdmi_msm_state->hpd_during_auth) { - DEV_WARN("Calling Deauthentication: HPD occured during " - "authentication from [%s]\n", __func__); - hdcp_deauthenticate(); - mutex_lock(&hdcp_auth_state_mutex); - hdmi_msm_state->hpd_during_auth = FALSE; - mutex_unlock(&hdcp_auth_state_mutex); - } else { - DEV_WARN("[DEV_DBG]: Calling reauth from [%s]\n", __func__); - if (hdmi_msm_state->panel_power_on) - queue_work(hdmi_work_queue, - &hdmi_msm_state->hdcp_reauth_work); - } - mutex_lock(&hdmi_msm_state_mutex); - hdmi_msm_state->hdcp_activating = FALSE; - mutex_unlock(&hdmi_msm_state_mutex); -} - -static void hdmi_msm_video_setup(int video_format) -{ - uint32 total_v = 0; - uint32 total_h = 0; - uint32 start_h = 0; - uint32 end_h = 0; - uint32 start_v = 0; - uint32 end_v = 0; - const struct hdmi_disp_mode_timing_type *timing = - hdmi_common_get_supported_mode(video_format); - - /* timing register setup */ - if (timing == NULL) { - DEV_ERR("video format not supported: %d\n", video_format); - return; - } - - /* Hsync Total and Vsync Total */ - total_h = timing->active_h + timing->front_porch_h - + timing->back_porch_h + timing->pulse_width_h - 1; - total_v = timing->active_v + timing->front_porch_v - + timing->back_porch_v + timing->pulse_width_v - 1; - /* 0x02C0 HDMI_TOTAL - [27:16] V_TOTAL Vertical Total - [11:0] H_TOTAL Horizontal Total */ - HDMI_OUTP(0x02C0, ((total_v << 16) & 0x0FFF0000) - | ((total_h << 0) & 0x00000FFF)); - - /* Hsync Start and Hsync End */ - start_h = timing->back_porch_h + timing->pulse_width_h; - end_h = (total_h + 1) - timing->front_porch_h; - /* 0x02B4 HDMI_ACTIVE_H - [27:16] END Horizontal end - [11:0] START Horizontal start */ - HDMI_OUTP(0x02B4, ((end_h << 16) & 0x0FFF0000) - | ((start_h << 0) & 0x00000FFF)); - - start_v = timing->back_porch_v + timing->pulse_width_v - 1; - end_v = total_v - timing->front_porch_v; - /* 0x02B8 HDMI_ACTIVE_V - [27:16] END Vertical end - [11:0] START Vertical start */ - HDMI_OUTP(0x02B8, ((end_v << 16) & 0x0FFF0000) - | ((start_v << 0) & 0x00000FFF)); - - if (timing->interlaced) { - /* 0x02C4 HDMI_V_TOTAL_F2 - [11:0] V_TOTAL_F2 Vertical total for field2 */ - HDMI_OUTP(0x02C4, ((total_v + 1) << 0) & 0x00000FFF); - - /* 0x02BC HDMI_ACTIVE_V_F2 - [27:16] END_F2 Vertical end for field2 - [11:0] START_F2 Vertical start for Field2 */ - HDMI_OUTP(0x02BC, - (((start_v + 1) << 0) & 0x00000FFF) - | (((end_v + 1) << 16) & 0x0FFF0000)); - } else { - /* HDMI_V_TOTAL_F2 */ - HDMI_OUTP(0x02C4, 0); - /* HDMI_ACTIVE_V_F2 */ - HDMI_OUTP(0x02BC, 0); - } - - hdmi_frame_ctrl_cfg(timing); -} - -struct hdmi_msm_audio_acr { - uint32 n; /* N parameter for clock regeneration */ - uint32 cts; /* CTS parameter for clock regeneration */ -}; - -struct hdmi_msm_audio_arcs { - uint32 pclk; - struct hdmi_msm_audio_acr lut[MSM_HDMI_SAMPLE_RATE_MAX]; -}; - -#define HDMI_MSM_AUDIO_ARCS(pclk, ...) { pclk, __VA_ARGS__ } - -/* Audio constants lookup table for hdmi_msm_audio_acr_setup */ -/* Valid Pixel-Clock rates: 25.2MHz, 27MHz, 27.03MHz, 74.25MHz, 148.5MHz */ -static const struct hdmi_msm_audio_arcs hdmi_msm_audio_acr_lut[] = { - /* 25.200MHz */ - HDMI_MSM_AUDIO_ARCS(25200, { - {4096, 25200}, {6272, 28000}, {6144, 25200}, {12544, 28000}, - {12288, 25200}, {25088, 28000}, {24576, 25200} }), - /* 27.000MHz */ - HDMI_MSM_AUDIO_ARCS(27000, { - {4096, 27000}, {6272, 30000}, {6144, 27000}, {12544, 30000}, - {12288, 27000}, {25088, 30000}, {24576, 27000} }), - /* 27.027MHz */ - HDMI_MSM_AUDIO_ARCS(27030, { - {4096, 27027}, {6272, 30030}, {6144, 27027}, {12544, 30030}, - {12288, 27027}, {25088, 30030}, {24576, 27027} }), - /* 74.250MHz */ - HDMI_MSM_AUDIO_ARCS(74250, { - {4096, 74250}, {6272, 82500}, {6144, 74250}, {12544, 82500}, - {12288, 74250}, {25088, 82500}, {24576, 74250} }), - /* 148.500MHz */ - HDMI_MSM_AUDIO_ARCS(148500, { - {4096, 148500}, {6272, 165000}, {6144, 148500}, {12544, 165000}, - {12288, 148500}, {25088, 165000}, {24576, 148500} }), -}; - -static void hdmi_msm_audio_acr_setup(boolean enabled, int video_format, - int audio_sample_rate, int num_of_channels) -{ - /* Read first before writing */ - /* HDMI_ACR_PKT_CTRL[0x0024] */ - uint32 acr_pck_ctrl_reg = HDMI_INP(0x0024); - - /* Clear N/CTS selection bits */ - acr_pck_ctrl_reg &= ~(3 << 4); - - if (enabled) { - const struct hdmi_disp_mode_timing_type *timing = - hdmi_common_get_supported_mode(video_format); - const struct hdmi_msm_audio_arcs *audio_arc = - &hdmi_msm_audio_acr_lut[0]; - const int lut_size = sizeof(hdmi_msm_audio_acr_lut) - /sizeof(*hdmi_msm_audio_acr_lut); - uint32 i, n, cts, layout, multiplier, aud_pck_ctrl_2_reg; - - if (timing == NULL) { - DEV_WARN("%s: video format %d not supported\n", - __func__, video_format); - return; - } - - for (i = 0; i < lut_size; - audio_arc = &hdmi_msm_audio_acr_lut[++i]) { - if (audio_arc->pclk == timing->pixel_freq) - break; - } - if (i >= lut_size) { - DEV_WARN("%s: pixel clock %d not supported\n", __func__, - timing->pixel_freq); - return; - } - - n = audio_arc->lut[audio_sample_rate].n; - cts = audio_arc->lut[audio_sample_rate].cts; - layout = (MSM_HDMI_AUDIO_CHANNEL_2 == num_of_channels) ? 0 : 1; - - if ((MSM_HDMI_SAMPLE_RATE_192KHZ == audio_sample_rate) || - (MSM_HDMI_SAMPLE_RATE_176_4KHZ == audio_sample_rate)) { - multiplier = 4; - n >>= 2; /* divide N by 4 and use multiplier */ - } else if ((MSM_HDMI_SAMPLE_RATE_96KHZ == audio_sample_rate) || - (MSM_HDMI_SAMPLE_RATE_88_2KHZ == audio_sample_rate)) { - multiplier = 2; - n >>= 1; /* divide N by 2 and use multiplier */ - } else { - multiplier = 1; - } - DEV_DBG("%s: n=%u, cts=%u, layout=%u\n", __func__, n, cts, - layout); - - /* AUDIO_PRIORITY | SOURCE */ - acr_pck_ctrl_reg |= 0x80000100; - /* N_MULTIPLE(multiplier) */ - acr_pck_ctrl_reg |= (multiplier & 7) << 16; - - if ((MSM_HDMI_SAMPLE_RATE_48KHZ == audio_sample_rate) || - (MSM_HDMI_SAMPLE_RATE_96KHZ == audio_sample_rate) || - (MSM_HDMI_SAMPLE_RATE_192KHZ == audio_sample_rate)) { - /* SELECT(3) */ - acr_pck_ctrl_reg |= 3 << 4; - /* CTS_48 */ - cts <<= 12; - - /* CTS: need to determine how many fractional bits */ - /* HDMI_ACR_48_0 */ - HDMI_OUTP(0x00D4, cts); - /* N */ - /* HDMI_ACR_48_1 */ - HDMI_OUTP(0x00D8, n); - } else if ((MSM_HDMI_SAMPLE_RATE_44_1KHZ == audio_sample_rate) - || (MSM_HDMI_SAMPLE_RATE_88_2KHZ == - audio_sample_rate) - || (MSM_HDMI_SAMPLE_RATE_176_4KHZ == - audio_sample_rate)) { - /* SELECT(2) */ - acr_pck_ctrl_reg |= 2 << 4; - /* CTS_44 */ - cts <<= 12; - - /* CTS: need to determine how many fractional bits */ - /* HDMI_ACR_44_0 */ - HDMI_OUTP(0x00CC, cts); - /* N */ - /* HDMI_ACR_44_1 */ - HDMI_OUTP(0x00D0, n); - } else { /* default to 32k */ - /* SELECT(1) */ - acr_pck_ctrl_reg |= 1 << 4; - /* CTS_32 */ - cts <<= 12; - - /* CTS: need to determine how many fractional bits */ - /* HDMI_ACR_32_0 */ - HDMI_OUTP(0x00C4, cts); - /* N */ - /* HDMI_ACR_32_1 */ - HDMI_OUTP(0x00C8, n); - } - /* Payload layout depends on number of audio channels */ - /* LAYOUT_SEL(layout) */ - aud_pck_ctrl_2_reg = 1 | (layout << 1); - /* override | layout */ - /* HDMI_AUDIO_PKT_CTRL2[0x00044] */ - HDMI_OUTP(0x00044, aud_pck_ctrl_2_reg); - - /* SEND | CONT */ - acr_pck_ctrl_reg |= 0x00000003; - } else { - /* ~(SEND | CONT) */ - acr_pck_ctrl_reg &= ~0x00000003; - } - /* HDMI_ACR_PKT_CTRL[0x0024] */ - HDMI_OUTP(0x0024, acr_pck_ctrl_reg); -} - -static void hdmi_msm_outpdw_chk(uint32 offset, uint32 data) -{ - uint32 check, i = 0; - -#ifdef DEBUG - HDMI_OUTP(offset, data); -#endif - do { - outpdw(MSM_HDMI_BASE+offset, data); - check = inpdw(MSM_HDMI_BASE+offset); - } while (check != data && i++ < 10); - - if (check != data) - DEV_ERR("%s: failed addr=%08x, data=%x, check=%x", - __func__, offset, data, check); -} - -static void hdmi_msm_rmw32or(uint32 offset, uint32 data) -{ - uint32 reg_data; - reg_data = inpdw(MSM_HDMI_BASE+offset); - reg_data = inpdw(MSM_HDMI_BASE+offset); - hdmi_msm_outpdw_chk(offset, reg_data | data); -} - - -#define HDMI_AUDIO_CFG 0x01D0 -#define HDMI_AUDIO_ENGINE_ENABLE 1 -#define HDMI_AUDIO_FIFO_MASK 0x000000F0 -#define HDMI_AUDIO_FIFO_WATERMARK_SHIFT 4 -#define HDMI_AUDIO_FIFO_MAX_WATER_MARK 8 - - -int hdmi_audio_enable(bool on , u32 fifo_water_mark) -{ - u32 hdmi_audio_config; - - hdmi_audio_config = HDMI_INP(HDMI_AUDIO_CFG); - - if (on) { - - if (fifo_water_mark > HDMI_AUDIO_FIFO_MAX_WATER_MARK) { - pr_err("%s : HDMI audio fifo water mark can not be more" - " than %u\n", __func__, - HDMI_AUDIO_FIFO_MAX_WATER_MARK); - return -EINVAL; - } - - /* - * Enable HDMI Audio engine. - * MUST be enabled after Audio DMA is enabled. - */ - hdmi_audio_config &= ~(HDMI_AUDIO_FIFO_MASK); - - hdmi_audio_config |= (HDMI_AUDIO_ENGINE_ENABLE | - (fifo_water_mark << HDMI_AUDIO_FIFO_WATERMARK_SHIFT)); - - } else - hdmi_audio_config &= ~(HDMI_AUDIO_ENGINE_ENABLE); - - HDMI_OUTP(HDMI_AUDIO_CFG, hdmi_audio_config); - - mb(); - pr_info("%s :HDMI_AUDIO_CFG 0x%08x\n", __func__, - HDMI_INP(HDMI_AUDIO_CFG)); - - return 0; -} -EXPORT_SYMBOL(hdmi_audio_enable); - -#define HDMI_AUDIO_PKT_CTRL 0x0020 -#define HDMI_AUDIO_SAMPLE_SEND_ENABLE 1 - -int hdmi_audio_packet_enable(bool on) -{ - u32 hdmi_audio_pkt_ctrl; - hdmi_audio_pkt_ctrl = HDMI_INP(HDMI_AUDIO_PKT_CTRL); - - if (on) - hdmi_audio_pkt_ctrl |= HDMI_AUDIO_SAMPLE_SEND_ENABLE; - else - hdmi_audio_pkt_ctrl &= ~(HDMI_AUDIO_SAMPLE_SEND_ENABLE); - - HDMI_OUTP(HDMI_AUDIO_PKT_CTRL, hdmi_audio_pkt_ctrl); - - mb(); - pr_info("%s : HDMI_AUDIO_PKT_CTRL 0x%08x\n", __func__, - HDMI_INP(HDMI_AUDIO_PKT_CTRL)); - return 0; -} -EXPORT_SYMBOL(hdmi_audio_packet_enable); - - -/* TO-DO: return -EINVAL when num_of_channels and channel_allocation - * does not match CEA 861-D spec. -*/ -int hdmi_msm_audio_info_setup(bool enabled, u32 num_of_channels, - u32 channel_allocation, u32 level_shift, bool down_mix) -{ - uint32 channel_count = 1; /* Default to 2 channels - -> See Table 17 in CEA-D spec */ - uint32 check_sum, audio_info_0_reg, audio_info_1_reg; - uint32 audio_info_ctrl_reg; - u32 aud_pck_ctrl_2_reg; - u32 layout; - - layout = (MSM_HDMI_AUDIO_CHANNEL_2 == num_of_channels) ? 0 : 1; - aud_pck_ctrl_2_reg = 1 | (layout << 1); - HDMI_OUTP(0x00044, aud_pck_ctrl_2_reg); - - /* Please see table 20 Audio InfoFrame in HDMI spec - FL = front left - FC = front Center - FR = front right - FLC = front left center - FRC = front right center - RL = rear left - RC = rear center - RR = rear right - RLC = rear left center - RRC = rear right center - LFE = low frequency effect - */ - - /* Read first then write because it is bundled with other controls */ - /* HDMI_INFOFRAME_CTRL0[0x002C] */ - audio_info_ctrl_reg = HDMI_INP(0x002C); - - if (enabled) { - switch (num_of_channels) { - case MSM_HDMI_AUDIO_CHANNEL_2: - channel_allocation = 0; /* Default to FR,FL */ - break; - case MSM_HDMI_AUDIO_CHANNEL_4: - channel_count = 3; - /* FC,LFE,FR,FL */ - channel_allocation = 0x3; - break; - case MSM_HDMI_AUDIO_CHANNEL_6: - channel_count = 5; - /* RR,RL,FC,LFE,FR,FL */ - channel_allocation = 0xB; - break; - case MSM_HDMI_AUDIO_CHANNEL_8: - channel_count = 7; - /* FRC,FLC,RR,RL,FC,LFE,FR,FL */ - channel_allocation = 0x1f; - break; - default: - pr_err("%s(): Unsupported num_of_channels = %u\n", - __func__, num_of_channels); - return -EINVAL; - break; - } - - /* Program the Channel-Speaker allocation */ - audio_info_1_reg = 0; - /* CA(channel_allocation) */ - audio_info_1_reg |= channel_allocation & 0xff; - /* Program the Level shifter */ - /* LSV(level_shift) */ - audio_info_1_reg |= (level_shift << 11) & 0x00007800; - /* Program the Down-mix Inhibit Flag */ - /* DM_INH(down_mix) */ - audio_info_1_reg |= (down_mix << 15) & 0x00008000; - - /* HDMI_AUDIO_INFO1[0x00E8] */ - HDMI_OUTP(0x00E8, audio_info_1_reg); - - /* Calculate CheckSum - Sum of all the bytes in the Audio Info Packet bytes - (See table 8.4 in HDMI spec) */ - check_sum = 0; - /* HDMI_AUDIO_INFO_FRAME_PACKET_HEADER_TYPE[0x84] */ - check_sum += 0x84; - /* HDMI_AUDIO_INFO_FRAME_PACKET_HEADER_VERSION[0x01] */ - check_sum += 1; - /* HDMI_AUDIO_INFO_FRAME_PACKET_LENGTH[0x0A] */ - check_sum += 0x0A; - check_sum += channel_count; - check_sum += channel_allocation; - /* See Table 8.5 in HDMI spec */ - check_sum += (level_shift & 0xF) << 3 | (down_mix & 0x1) << 7; - check_sum &= 0xFF; - check_sum = (uint8) (256 - check_sum); - - audio_info_0_reg = 0; - /* CHECKSUM(check_sum) */ - audio_info_0_reg |= check_sum & 0xff; - /* CC(channel_count) */ - audio_info_0_reg |= (channel_count << 8) & 0x00000700; - - /* HDMI_AUDIO_INFO0[0x00E4] */ - HDMI_OUTP(0x00E4, audio_info_0_reg); - - /* Set these flags */ - /* AUDIO_INFO_UPDATE | AUDIO_INFO_SOURCE | AUDIO_INFO_CONT - | AUDIO_INFO_SEND */ - audio_info_ctrl_reg |= 0x000000F0; - } else { - /* Clear these flags */ - /* ~(AUDIO_INFO_UPDATE | AUDIO_INFO_SOURCE | AUDIO_INFO_CONT - | AUDIO_INFO_SEND) */ - audio_info_ctrl_reg &= ~0x000000F0; - } - /* HDMI_INFOFRAME_CTRL0[0x002C] */ - HDMI_OUTP(0x002C, audio_info_ctrl_reg); - - - hdmi_msm_dump_regs("HDMI-AUDIO-ON: "); - - return 0; - -} -EXPORT_SYMBOL(hdmi_msm_audio_info_setup); - -static void hdmi_msm_en_gc_packet(boolean av_mute_is_requested) -{ - /* HDMI_GC[0x0040] */ - HDMI_OUTP(0x0040, av_mute_is_requested ? 1 : 0); - - /* GC packet enable (every frame) */ - /* HDMI_VBI_PKT_CTRL[0x0028] */ - hdmi_msm_rmw32or(0x0028, 3 << 4); -} - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_ISRC_ACP_SUPPORT -static void hdmi_msm_en_isrc_packet(boolean isrc_is_continued) -{ - static const char isrc_psuedo_data[] = - "ISRC1:0123456789isrc2=ABCDEFGHIJ"; - const uint32 * isrc_data = (const uint32 *) isrc_psuedo_data; - - /* ISRC_STATUS =0b010 | ISRC_CONTINUE | ISRC_VALID */ - /* HDMI_ISRC1_0[0x00048] */ - HDMI_OUTP(0x00048, 2 | (isrc_is_continued ? 1 : 0) << 6 | 0 << 7); - - /* HDMI_ISRC1_1[0x004C] */ - HDMI_OUTP(0x004C, *isrc_data++); - /* HDMI_ISRC1_2[0x0050] */ - HDMI_OUTP(0x0050, *isrc_data++); - /* HDMI_ISRC1_3[0x0054] */ - HDMI_OUTP(0x0054, *isrc_data++); - /* HDMI_ISRC1_4[0x0058] */ - HDMI_OUTP(0x0058, *isrc_data++); - - /* HDMI_ISRC2_0[0x005C] */ - HDMI_OUTP(0x005C, *isrc_data++); - /* HDMI_ISRC2_1[0x0060] */ - HDMI_OUTP(0x0060, *isrc_data++); - /* HDMI_ISRC2_2[0x0064] */ - HDMI_OUTP(0x0064, *isrc_data++); - /* HDMI_ISRC2_3[0x0068] */ - HDMI_OUTP(0x0068, *isrc_data); - - /* HDMI_VBI_PKT_CTRL[0x0028] */ - /* ISRC Send + Continuous */ - hdmi_msm_rmw32or(0x0028, 3 << 8); -} -#else -static void hdmi_msm_en_isrc_packet(boolean isrc_is_continued) -{ - /* - * Until end-to-end support for various audio packets - */ -} -#endif - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_ISRC_ACP_SUPPORT -static void hdmi_msm_en_acp_packet(uint32 byte1) -{ - /* HDMI_ACP[0x003C] */ - HDMI_OUTP(0x003C, 2 | 1 << 8 | byte1 << 16); - - /* HDMI_VBI_PKT_CTRL[0x0028] */ - /* ACP send, s/w source */ - hdmi_msm_rmw32or(0x0028, 3 << 12); -} -#else -static void hdmi_msm_en_acp_packet(uint32 byte1) -{ - /* - * Until end-to-end support for various audio packets - */ -} -#endif - -int hdmi_msm_audio_get_sample_rate(void) -{ - return msm_hdmi_sample_rate; -} -EXPORT_SYMBOL(hdmi_msm_audio_get_sample_rate); - -void hdmi_msm_audio_sample_rate_reset(int rate) -{ - if (msm_hdmi_sample_rate == rate) - return; - - msm_hdmi_sample_rate = rate; - - if (hdmi_msm_state->hdcp_enable) - hdcp_deauthenticate(); - else - hdmi_msm_turn_on(); -} -EXPORT_SYMBOL(hdmi_msm_audio_sample_rate_reset); - -static void hdmi_msm_audio_setup(void) -{ - const int channels = MSM_HDMI_AUDIO_CHANNEL_2; - - /* (0) for clr_avmute, (1) for set_avmute */ - hdmi_msm_en_gc_packet(0); - /* (0) for isrc1 only, (1) for isrc1 and isrc2 */ - hdmi_msm_en_isrc_packet(1); - /* arbitrary bit pattern for byte1 */ - hdmi_msm_en_acp_packet(0x5a); - DEV_DBG("Not setting ACP, ISRC1, ISRC2 packets\n"); - hdmi_msm_audio_acr_setup(TRUE, - external_common_state->video_resolution, - msm_hdmi_sample_rate, channels); - hdmi_msm_audio_info_setup(TRUE, channels, 0, 0, FALSE); - - /* Turn on Audio FIFO and SAM DROP ISR */ - HDMI_OUTP(0x02CC, HDMI_INP(0x02CC) | BIT(1) | BIT(3)); - DEV_INFO("HDMI Audio: Enabled\n"); -} - -static int hdmi_msm_audio_off(void) -{ - uint32 audio_cfg; - int i, timeout_val = 50; - - for (i = 0; (i < timeout_val) && - ((audio_cfg = HDMI_INP_ND(0x01D0)) & BIT(0)); i++) { - DEV_DBG("%s: %d times: AUDIO CFG is %08xi\n", __func__, - i+1, audio_cfg); - if (!((i+1) % 10)) { - DEV_ERR("%s: audio still on after %d sec. try again\n", - __func__, (i+1)/10); - SWITCH_SET_HDMI_AUDIO(0, 1); - } - msleep(100); - } - - if (i == timeout_val) - DEV_ERR("%s: Error: cannot turn off audio engine\n", __func__); - - hdmi_msm_audio_info_setup(FALSE, 0, 0, 0, FALSE); - hdmi_msm_audio_acr_setup(FALSE, 0, 0, 0); - DEV_INFO("HDMI Audio: Disabled\n"); - return 0; -} - -static uint8 hdmi_msm_avi_iframe_lut[][17] = { -/* 480p60 480i60 576p50 576i50 720p60 720p50 1080p60 1080i60 1080p50 - 1080i50 1080p24 1080p30 1080p25 640x480p 480p60_16_9 576p50_4_3 */ - {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, /*00*/ - {0x18, 0x18, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, - 0x28, 0x28, 0x28, 0x28, 0x18, 0x28, 0x18, 0x08}, /*01*/ - {0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x88, 0x00, 0x04, 0x04}, /*02*/ - {0x02, 0x06, 0x11, 0x15, 0x04, 0x13, 0x10, 0x05, 0x1F, - 0x14, 0x20, 0x22, 0x21, 0x01, 0x03, 0x11, 0x00}, /*03*/ - {0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*04*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*05*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*06*/ - {0xE1, 0xE1, 0x41, 0x41, 0xD1, 0xd1, 0x39, 0x39, 0x39, - 0x39, 0x39, 0x39, 0x39, 0xe1, 0xE1, 0x41, 0x01}, /*07*/ - {0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x01, 0x01, 0x02, 0x04}, /*08*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*09*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*10*/ - {0xD1, 0xD1, 0xD1, 0xD1, 0x01, 0x01, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0xD1, 0xD1, 0x01}, /*11*/ - {0x02, 0x02, 0x02, 0x02, 0x05, 0x05, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x02, 0x02, 0x02, 0x05} /*12*/ -}; - -static void hdmi_msm_avi_info_frame(void) -{ - /* two header + length + 13 data */ - uint8 aviInfoFrame[16]; - uint8 checksum; - uint32 sum; - uint32 regVal; - int i; - int mode = 0; - boolean use_ce_scan_info = TRUE; - - switch (external_common_state->video_resolution) { - case HDMI_VFRMT_720x480p60_4_3: - mode = 0; - break; - case HDMI_VFRMT_720x480i60_16_9: - mode = 1; - break; - case HDMI_VFRMT_720x576p50_16_9: - mode = 2; - break; - case HDMI_VFRMT_720x576i50_16_9: - mode = 3; - break; - case HDMI_VFRMT_1280x720p60_16_9: - mode = 4; - break; - case HDMI_VFRMT_1280x720p50_16_9: - mode = 5; - break; - case HDMI_VFRMT_1920x1080p60_16_9: - mode = 6; - break; - case HDMI_VFRMT_1920x1080i60_16_9: - mode = 7; - break; - case HDMI_VFRMT_1920x1080p50_16_9: - mode = 8; - break; - case HDMI_VFRMT_1920x1080i50_16_9: - mode = 9; - break; - case HDMI_VFRMT_1920x1080p24_16_9: - mode = 10; - break; - case HDMI_VFRMT_1920x1080p30_16_9: - mode = 11; - break; - case HDMI_VFRMT_1920x1080p25_16_9: - mode = 12; - break; - case HDMI_VFRMT_640x480p60_4_3: - mode = 13; - break; - case HDMI_VFRMT_720x480p60_16_9: - mode = 14; - break; - case HDMI_VFRMT_720x576p50_4_3: - mode = 15; - break; - case HDMI_VFRMT_1280x1024p60_5_4: - mode = 16; - break; - default: - DEV_INFO("%s: mode %d not supported\n", __func__, - external_common_state->video_resolution); - return; - } - - /* InfoFrame Type = 82 */ - aviInfoFrame[0] = 0x82; - /* Version = 2 */ - aviInfoFrame[1] = 2; - /* Length of AVI InfoFrame = 13 */ - aviInfoFrame[2] = 13; - - /* Data Byte 01: 0 Y1 Y0 A0 B1 B0 S1 S0 */ - aviInfoFrame[3] = hdmi_msm_avi_iframe_lut[0][mode]; - - /* - * If the sink specified support for both underscan/overscan - * then, by default, set the underscan bit. - * Only checking underscan support for preferred format and cea formats - */ - if ((external_common_state->video_resolution == - external_common_state->preferred_video_format)) { - use_ce_scan_info = FALSE; - switch (external_common_state->pt_scan_info) { - case 0: - /* - * Need to use the info specified for the corresponding - * IT or CE format - */ - DEV_DBG("%s: No underscan information specified for the" - " preferred video format\n", __func__); - use_ce_scan_info = TRUE; - break; - case 3: - DEV_DBG("%s: Setting underscan bit for the preferred" - " video format\n", __func__); - aviInfoFrame[3] |= 0x02; - break; - default: - DEV_DBG("%s: Underscan information not set for the" - " preferred video format\n", __func__); - break; - } - } - - if (use_ce_scan_info) { - if (3 == external_common_state->ce_scan_info) { - DEV_DBG("%s: Setting underscan bit for the CE video" - " format\n", __func__); - aviInfoFrame[3] |= 0x02; - } else { - DEV_DBG("%s: Not setting underscan bit for the CE video" - " format\n", __func__); - } - } - - /* Data Byte 02: C1 C0 M1 M0 R3 R2 R1 R0 */ - aviInfoFrame[4] = hdmi_msm_avi_iframe_lut[1][mode]; - /* Data Byte 03: ITC EC2 EC1 EC0 Q1 Q0 SC1 SC0 */ - aviInfoFrame[5] = hdmi_msm_avi_iframe_lut[2][mode]; - /* Data Byte 04: 0 VIC6 VIC5 VIC4 VIC3 VIC2 VIC1 VIC0 */ - aviInfoFrame[6] = hdmi_msm_avi_iframe_lut[3][mode]; - /* Data Byte 05: 0 0 0 0 PR3 PR2 PR1 PR0 */ - aviInfoFrame[7] = hdmi_msm_avi_iframe_lut[4][mode]; - /* Data Byte 06: LSB Line No of End of Top Bar */ - aviInfoFrame[8] = hdmi_msm_avi_iframe_lut[5][mode]; - /* Data Byte 07: MSB Line No of End of Top Bar */ - aviInfoFrame[9] = hdmi_msm_avi_iframe_lut[6][mode]; - /* Data Byte 08: LSB Line No of Start of Bottom Bar */ - aviInfoFrame[10] = hdmi_msm_avi_iframe_lut[7][mode]; - /* Data Byte 09: MSB Line No of Start of Bottom Bar */ - aviInfoFrame[11] = hdmi_msm_avi_iframe_lut[8][mode]; - /* Data Byte 10: LSB Pixel Number of End of Left Bar */ - aviInfoFrame[12] = hdmi_msm_avi_iframe_lut[9][mode]; - /* Data Byte 11: MSB Pixel Number of End of Left Bar */ - aviInfoFrame[13] = hdmi_msm_avi_iframe_lut[10][mode]; - /* Data Byte 12: LSB Pixel Number of Start of Right Bar */ - aviInfoFrame[14] = hdmi_msm_avi_iframe_lut[11][mode]; - /* Data Byte 13: MSB Pixel Number of Start of Right Bar */ - aviInfoFrame[15] = hdmi_msm_avi_iframe_lut[12][mode]; - - sum = 0; - for (i = 0; i < 16; i++) - sum += aviInfoFrame[i]; - sum &= 0xFF; - sum = 256 - sum; - checksum = (uint8) sum; - - regVal = aviInfoFrame[5]; - regVal = regVal << 8 | aviInfoFrame[4]; - regVal = regVal << 8 | aviInfoFrame[3]; - regVal = regVal << 8 | checksum; - HDMI_OUTP(0x006C, regVal); - - regVal = aviInfoFrame[9]; - regVal = regVal << 8 | aviInfoFrame[8]; - regVal = regVal << 8 | aviInfoFrame[7]; - regVal = regVal << 8 | aviInfoFrame[6]; - HDMI_OUTP(0x0070, regVal); - - regVal = aviInfoFrame[13]; - regVal = regVal << 8 | aviInfoFrame[12]; - regVal = regVal << 8 | aviInfoFrame[11]; - regVal = regVal << 8 | aviInfoFrame[10]; - HDMI_OUTP(0x0074, regVal); - - regVal = aviInfoFrame[1]; - regVal = regVal << 16 | aviInfoFrame[15]; - regVal = regVal << 8 | aviInfoFrame[14]; - HDMI_OUTP(0x0078, regVal); - - /* INFOFRAME_CTRL0[0x002C] */ - /* 0x3 for AVI InfFrame enable (every frame) */ - HDMI_OUTP(0x002C, HDMI_INP(0x002C) | 0x00000003L); -} - -#ifdef CONFIG_FB_MSM_HDMI_3D -static void hdmi_msm_vendor_infoframe_packetsetup(void) -{ - uint32 packet_header = 0; - uint32 check_sum = 0; - uint32 packet_payload = 0; - - if (!external_common_state->format_3d) { - HDMI_OUTP(0x0034, 0); - return; - } - - /* 0x0084 GENERIC0_HDR - * HB0 7:0 NUM - * HB1 15:8 NUM - * HB2 23:16 NUM */ - /* Setup Packet header and payload */ - /* 0x81 VS_INFO_FRAME_ID - 0x01 VS_INFO_FRAME_VERSION - 0x1B VS_INFO_FRAME_PAYLOAD_LENGTH */ - packet_header = 0x81 | (0x01 << 8) | (0x1B << 16); - HDMI_OUTP(0x0084, packet_header); - - check_sum = packet_header & 0xff; - check_sum += (packet_header >> 8) & 0xff; - check_sum += (packet_header >> 16) & 0xff; - - /* 0x008C GENERIC0_1 - * BYTE4 7:0 NUM - * BYTE5 15:8 NUM - * BYTE6 23:16 NUM - * BYTE7 31:24 NUM */ - /* 0x02 VS_INFO_FRAME_3D_PRESENT */ - packet_payload = 0x02 << 5; - switch (external_common_state->format_3d) { - case 1: - /* 0b1000 VIDEO_3D_FORMAT_SIDE_BY_SIDE_HALF */ - packet_payload |= (0x08 << 8) << 4; - break; - case 2: - /* 0b0110 VIDEO_3D_FORMAT_TOP_AND_BOTTOM_HALF */ - packet_payload |= (0x06 << 8) << 4; - break; - } - HDMI_OUTP(0x008C, packet_payload); - - check_sum += packet_payload & 0xff; - check_sum += (packet_payload >> 8) & 0xff; - - #define IEEE_REGISTRATION_ID 0xC03 - /* Next 3 bytes are IEEE Registration Identifcation */ - /* 0x0088 GENERIC0_0 - * BYTE0 7:0 NUM (checksum) - * BYTE1 15:8 NUM - * BYTE2 23:16 NUM - * BYTE3 31:24 NUM */ - check_sum += IEEE_REGISTRATION_ID & 0xff; - check_sum += (IEEE_REGISTRATION_ID >> 8) & 0xff; - check_sum += (IEEE_REGISTRATION_ID >> 16) & 0xff; - - HDMI_OUTP(0x0088, (0x100 - (0xff & check_sum)) - | ((IEEE_REGISTRATION_ID & 0xff) << 8) - | (((IEEE_REGISTRATION_ID >> 8) & 0xff) << 16) - | (((IEEE_REGISTRATION_ID >> 16) & 0xff) << 24)); - - /* 0x0034 GEN_PKT_CTRL - * GENERIC0_SEND 0 0 = Disable Generic0 Packet Transmission - * 1 = Enable Generic0 Packet Transmission - * GENERIC0_CONT 1 0 = Send Generic0 Packet on next frame only - * 1 = Send Generic0 Packet on every frame - * GENERIC0_UPDATE 2 NUM - * GENERIC1_SEND 4 0 = Disable Generic1 Packet Transmission - * 1 = Enable Generic1 Packet Transmission - * GENERIC1_CONT 5 0 = Send Generic1 Packet on next frame only - * 1 = Send Generic1 Packet on every frame - * GENERIC0_LINE 21:16 NUM - * GENERIC1_LINE 29:24 NUM - */ - /* GENERIC0_LINE | GENERIC0_UPDATE | GENERIC0_CONT | GENERIC0_SEND - * Setup HDMI TX generic packet control - * Enable this packet to transmit every frame - * Enable this packet to transmit every frame - * Enable HDMI TX engine to transmit Generic packet 0 */ - HDMI_OUTP(0x0034, (1 << 16) | (1 << 2) | BIT(1) | BIT(0)); -} - -static void hdmi_msm_switch_3d(boolean on) -{ - mutex_lock(&external_common_state_hpd_mutex); - if (external_common_state->hpd_state) - hdmi_msm_vendor_infoframe_packetsetup(); - mutex_unlock(&external_common_state_hpd_mutex); -} -#endif - -#define IFRAME_CHECKSUM_32(d) \ - ((d & 0xff) + ((d >> 8) & 0xff) + \ - ((d >> 16) & 0xff) + ((d >> 24) & 0xff)) - -static void hdmi_msm_spd_infoframe_packetsetup(void) -{ - uint32 packet_header = 0; - uint32 check_sum = 0; - uint32 packet_payload = 0; - uint32 packet_control = 0; - - uint8 *vendor_name = external_common_state->spd_vendor_name; - uint8 *product_description = - external_common_state->spd_product_description; - - /* 0x00A4 GENERIC1_HDR - * HB0 7:0 NUM - * HB1 15:8 NUM - * HB2 23:16 NUM */ - /* Setup Packet header and payload */ - /* 0x83 InfoFrame Type Code - 0x01 InfoFrame Version Number - 0x19 Length of Source Product Description InfoFrame - */ - packet_header = 0x83 | (0x01 << 8) | (0x19 << 16); - HDMI_OUTP(0x00A4, packet_header); - check_sum += IFRAME_CHECKSUM_32(packet_header); - - /* 0x00AC GENERIC1_1 - * BYTE4 7:0 VENDOR_NAME[3] - * BYTE5 15:8 VENDOR_NAME[4] - * BYTE6 23:16 VENDOR_NAME[5] - * BYTE7 31:24 VENDOR_NAME[6] */ - packet_payload = (vendor_name[3] & 0x7f) - | ((vendor_name[4] & 0x7f) << 8) - | ((vendor_name[5] & 0x7f) << 16) - | ((vendor_name[6] & 0x7f) << 24); - HDMI_OUTP(0x00AC, packet_payload); - check_sum += IFRAME_CHECKSUM_32(packet_payload); - - /* Product Description (7-bit ASCII code) */ - /* 0x00B0 GENERIC1_2 - * BYTE8 7:0 VENDOR_NAME[7] - * BYTE9 15:8 PRODUCT_NAME[ 0] - * BYTE10 23:16 PRODUCT_NAME[ 1] - * BYTE11 31:24 PRODUCT_NAME[ 2] */ - packet_payload = (vendor_name[7] & 0x7f) - | ((product_description[0] & 0x7f) << 8) - | ((product_description[1] & 0x7f) << 16) - | ((product_description[2] & 0x7f) << 24); - HDMI_OUTP(0x00B0, packet_payload); - check_sum += IFRAME_CHECKSUM_32(packet_payload); - - /* 0x00B4 GENERIC1_3 - * BYTE12 7:0 PRODUCT_NAME[ 3] - * BYTE13 15:8 PRODUCT_NAME[ 4] - * BYTE14 23:16 PRODUCT_NAME[ 5] - * BYTE15 31:24 PRODUCT_NAME[ 6] */ - packet_payload = (product_description[3] & 0x7f) - | ((product_description[4] & 0x7f) << 8) - | ((product_description[5] & 0x7f) << 16) - | ((product_description[6] & 0x7f) << 24); - HDMI_OUTP(0x00B4, packet_payload); - check_sum += IFRAME_CHECKSUM_32(packet_payload); - - /* 0x00B8 GENERIC1_4 - * BYTE16 7:0 PRODUCT_NAME[ 7] - * BYTE17 15:8 PRODUCT_NAME[ 8] - * BYTE18 23:16 PRODUCT_NAME[ 9] - * BYTE19 31:24 PRODUCT_NAME[10] */ - packet_payload = (product_description[7] & 0x7f) - | ((product_description[8] & 0x7f) << 8) - | ((product_description[9] & 0x7f) << 16) - | ((product_description[10] & 0x7f) << 24); - HDMI_OUTP(0x00B8, packet_payload); - check_sum += IFRAME_CHECKSUM_32(packet_payload); - - /* 0x00BC GENERIC1_5 - * BYTE20 7:0 PRODUCT_NAME[11] - * BYTE21 15:8 PRODUCT_NAME[12] - * BYTE22 23:16 PRODUCT_NAME[13] - * BYTE23 31:24 PRODUCT_NAME[14] */ - packet_payload = (product_description[11] & 0x7f) - | ((product_description[12] & 0x7f) << 8) - | ((product_description[13] & 0x7f) << 16) - | ((product_description[14] & 0x7f) << 24); - HDMI_OUTP(0x00BC, packet_payload); - check_sum += IFRAME_CHECKSUM_32(packet_payload); - - /* 0x00C0 GENERIC1_6 - * BYTE24 7:0 PRODUCT_NAME[15] - * BYTE25 15:8 Source Device Information - * BYTE26 23:16 NUM - * BYTE27 31:24 NUM */ - /* Source Device Information - * 00h unknown - * 01h Digital STB - * 02h DVD - * 03h D-VHS - * 04h HDD Video - * 05h DVC - * 06h DSC - * 07h Video CD - * 08h Game - * 09h PC general */ - packet_payload = (product_description[15] & 0x7f) | 0x00 << 8; - HDMI_OUTP(0x00C0, packet_payload); - check_sum += IFRAME_CHECKSUM_32(packet_payload); - - /* Vendor Name (7bit ASCII code) */ - /* 0x00A8 GENERIC1_0 - * BYTE0 7:0 CheckSum - * BYTE1 15:8 VENDOR_NAME[0] - * BYTE2 23:16 VENDOR_NAME[1] - * BYTE3 31:24 VENDOR_NAME[2] */ - packet_payload = ((vendor_name[0] & 0x7f) << 8) - | ((vendor_name[1] & 0x7f) << 16) - | ((vendor_name[2] & 0x7f) << 24); - check_sum += IFRAME_CHECKSUM_32(packet_payload); - packet_payload |= ((0x100 - (0xff & check_sum)) & 0xff); - HDMI_OUTP(0x00A8, packet_payload); - - /* GENERIC1_LINE | GENERIC1_CONT | GENERIC1_SEND - * Setup HDMI TX generic packet control - * Enable this packet to transmit every frame - * Enable HDMI TX engine to transmit Generic packet 1 */ - packet_control = HDMI_INP_ND(0x0034); - packet_control |= ((0x1 << 24) | (1 << 5) | (1 << 4)); - HDMI_OUTP(0x0034, packet_control); -} - -int hdmi_msm_clk(int on) -{ - int rc; - - DEV_DBG("HDMI Clk: %s\n", on ? "Enable" : "Disable"); - if (on) { - rc = clk_prepare_enable(hdmi_msm_state->hdmi_app_clk); - if (rc) { - DEV_ERR("'hdmi_app_clk' clock enable failed, rc=%d\n", - rc); - return rc; - } - - rc = clk_prepare_enable(hdmi_msm_state->hdmi_m_pclk); - if (rc) { - DEV_ERR("'hdmi_m_pclk' clock enable failed, rc=%d\n", - rc); - return rc; - } - - rc = clk_prepare_enable(hdmi_msm_state->hdmi_s_pclk); - if (rc) { - DEV_ERR("'hdmi_s_pclk' clock enable failed, rc=%d\n", - rc); - return rc; - } - } else { - clk_disable_unprepare(hdmi_msm_state->hdmi_app_clk); - clk_disable_unprepare(hdmi_msm_state->hdmi_m_pclk); - clk_disable_unprepare(hdmi_msm_state->hdmi_s_pclk); - } - - return 0; -} - -static void hdmi_msm_turn_on(void) -{ - uint32 audio_pkt_ctrl, audio_cfg; - /* - * Number of wait iterations for QDSP to disable Audio Engine - * before resetting HDMI core - */ - int i = 10; - audio_pkt_ctrl = HDMI_INP_ND(0x0020); - audio_cfg = HDMI_INP_ND(0x01D0); - - /* - * Checking BIT[0] of AUDIO PACKET CONTROL and - * AUDIO CONFIGURATION register - */ - while (((audio_pkt_ctrl & 0x00000001) || (audio_cfg & 0x00000001)) - && (i--)) { - audio_pkt_ctrl = HDMI_INP_ND(0x0020); - audio_cfg = HDMI_INP_ND(0x01D0); - DEV_DBG("%d times :: HDMI AUDIO PACKET is %08x and " - "AUDIO CFG is %08x", i, audio_pkt_ctrl, audio_cfg); - msleep(20); - } - - hdmi_msm_set_mode(FALSE); - mutex_lock(&hdcp_auth_state_mutex); - hdmi_msm_reset_core(); - mutex_unlock(&hdcp_auth_state_mutex); - - hdmi_msm_init_phy(external_common_state->video_resolution); - /* HDMI_USEC_REFTIMER[0x0208] */ - HDMI_OUTP(0x0208, 0x0001001B); - - hdmi_msm_set_mode(TRUE); - - hdmi_msm_video_setup(external_common_state->video_resolution); - if (!hdmi_msm_is_dvi_mode()) { - hdmi_msm_audio_setup(); - - /* - * Send the audio switch device notification if HDCP is - * not enabled. Otherwise, the notification would be - * sent after HDCP authentication is successful. - */ - if (!hdmi_msm_state->hdcp_enable) - SWITCH_SET_HDMI_AUDIO(1, 0); - } - hdmi_msm_avi_info_frame(); -#ifdef CONFIG_FB_MSM_HDMI_3D - hdmi_msm_vendor_infoframe_packetsetup(); -#endif - hdmi_msm_spd_infoframe_packetsetup(); - - if (hdmi_msm_state->hdcp_enable && hdmi_msm_state->reauth) { - hdmi_msm_hdcp_enable(); - hdmi_msm_state->reauth = FALSE ; - } - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - /* re-initialize CEC if enabled */ - mutex_lock(&hdmi_msm_state_mutex); - if (hdmi_msm_state->cec_enabled == true) { - hdmi_msm_cec_init(); - hdmi_msm_cec_write_logical_addr( - hdmi_msm_state->cec_logical_addr); - } - mutex_unlock(&hdmi_msm_state_mutex); -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - DEV_INFO("HDMI Core: Initialized\n"); -} - -static void hdmi_msm_hdcp_timer(unsigned long data) -{ - if (!hdmi_msm_state->hdcp_enable) { - DEV_DBG("%s: HDCP not enabled\n", __func__); - return; - } - - queue_work(hdmi_work_queue, &hdmi_msm_state->hdcp_work); -} - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT -static void hdmi_msm_cec_read_timer_func(unsigned long data) -{ - queue_work(hdmi_work_queue, &hdmi_msm_state->cec_latch_detect_work); -} -#endif - -static void hdmi_msm_hpd_polarity_setup(void) -{ - u32 cable_sense; - bool polarity = !external_common_state->hpd_state; - bool trigger = false; - - if (polarity) - HDMI_OUTP(0x0254, BIT(2) | BIT(1)); - else - HDMI_OUTP(0x0254, BIT(2)); - - cable_sense = (HDMI_INP(0x0250) & BIT(1)) >> 1; - - if (cable_sense == polarity) - trigger = true; - - DEV_DBG("%s: listen=%s, sense=%s, trigger=%s\n", __func__, - polarity ? "connect" : "disconnect", - cable_sense ? "connect" : "disconnect", - trigger ? "Yes" : "No"); - - if (trigger) { - u32 reg_val = HDMI_INP(0x0258); - - /* Toggle HPD circuit to trigger HPD sense */ - HDMI_OUTP(0x0258, reg_val & ~BIT(28)); - HDMI_OUTP(0x0258, reg_val | BIT(28)); - } -} - -static void hdmi_msm_hpd_off(void) -{ - int rc = 0; - - if (!hdmi_msm_state->hpd_initialized) { - DEV_DBG("%s: HPD is already OFF, returning\n", __func__); - return; - } - - DEV_DBG("%s: (timer, 5V, IRQ off)\n", __func__); - disable_irq(hdmi_msm_state->irq); - - /* Disable HPD interrupt */ - HDMI_OUTP(0x0254, 0); - DEV_DBG("%s: Disabling HPD_CTRLd\n", __func__); - - hdmi_msm_set_mode(FALSE); - hdmi_msm_state->pd->enable_5v(0); - hdmi_msm_clk(0); - rc = hdmi_msm_state->pd->gpio_config(0); - if (rc != 0) - DEV_INFO("%s: Failed to disable GPIOs. Error=%d\n", - __func__, rc); - hdmi_msm_state->hpd_initialized = FALSE; -} - -static void hdmi_msm_dump_regs(const char *prefix) -{ -#ifdef REG_DUMP - print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET, 32, 4, - (void *)MSM_HDMI_BASE, 0x0334, false); -#endif -} - -static int hdmi_msm_hpd_on(void) -{ - static int phy_reset_done; - uint32 hpd_ctrl; - int rc = 0; - - if (hdmi_msm_state->hpd_initialized) { - DEV_DBG("%s: HPD is already ON\n", __func__); - } else { - rc = hdmi_msm_state->pd->gpio_config(1); - if (rc) { - DEV_ERR("%s: Failed to enable GPIOs. Error=%d\n", - __func__, rc); - goto error1; - } - - rc = hdmi_msm_clk(1); - if (rc) { - DEV_ERR("%s: Failed to enable clocks. Error=%d\n", - __func__, rc); - goto error2; - } - - rc = hdmi_msm_state->pd->enable_5v(1); - if (rc) { - DEV_ERR("%s: Failed to enable 5V regulator. Error=%d\n", - __func__, rc); - goto error3; - } - hdmi_msm_dump_regs("HDMI-INIT: "); - - hdmi_msm_set_mode(FALSE); - if (!phy_reset_done) { - hdmi_phy_reset(); - phy_reset_done = 1; - } - hdmi_msm_set_mode(TRUE); - - /* HDMI_USEC_REFTIMER[0x0208] */ - HDMI_OUTP(0x0208, 0x0001001B); - - /* Set up HPD state variables */ - mutex_lock(&external_common_state_hpd_mutex); - external_common_state->hpd_state = 0; - mutex_unlock(&external_common_state_hpd_mutex); - mutex_lock(&hdmi_msm_state_mutex); - mutex_unlock(&hdmi_msm_state_mutex); - - enable_irq(hdmi_msm_state->irq); - - hdmi_msm_state->hpd_initialized = TRUE; - - /* set timeout to 4.1ms (max) for hardware debounce */ - hpd_ctrl = HDMI_INP(0x0258) | 0x1FFF; - - /* Turn on HPD HW circuit */ - HDMI_OUTP(0x0258, hpd_ctrl | BIT(28)); - - /* Set HPD cable sense polarity */ - hdmi_msm_hpd_polarity_setup(); - } - - DEV_DBG("%s: (IRQ, 5V on)\n", __func__); - return 0; - -error3: - hdmi_msm_clk(0); -error2: - hdmi_msm_state->pd->gpio_config(0); -error1: - return rc; -} - -static int hdmi_msm_power_ctrl(boolean enable) -{ - int rc = 0; - int time = 0; - - if (enable) { - /* - * Enable HPD only if the UI option is on or if - * HDMI is configured as the primary display - */ - if (hdmi_prim_display || - external_common_state->hpd_feature_on) { - DEV_DBG("%s: Turning HPD ciruitry on\n", __func__); - - rc = hdmi_msm_hpd_on(); - if (rc) { - DEV_ERR("%s: HPD ON FAILED\n", __func__); - return rc; - } - - /* Wait for HPD initialization to complete */ - INIT_COMPLETION(hdmi_msm_state->hpd_event_processed); - time = wait_for_completion_interruptible_timeout( - &hdmi_msm_state->hpd_event_processed, HZ); - if (!time && !external_common_state->hpd_state) { - DEV_DBG("%s: cable not detected\n", __func__); - queue_work(hdmi_work_queue, - &hdmi_msm_state->hpd_state_work); - } - } - } else { - DEV_DBG("%s: Turning HPD ciruitry off\n", __func__); - hdmi_msm_hpd_off(); - } - - return rc; -} - -static int hdmi_msm_power_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - int ret = 0; - bool changed; - - if (!hdmi_ready()) { - DEV_ERR("%s: HDMI/HPD not initialized\n", __func__); - return ret; - } - - if (!external_common_state->hpd_state) { - DEV_DBG("%s:HDMI cable not connected\n", __func__); - goto error; - } - - /* Only start transmission with supported resolution */ - changed = hdmi_common_get_video_format_from_drv_data(mfd); - if (changed || external_common_state->default_res_supported) { - mutex_lock(&external_common_state_hpd_mutex); - if (external_common_state->hpd_state && - hdmi_msm_is_power_on()) { - mutex_unlock(&external_common_state_hpd_mutex); - - DEV_INFO("HDMI cable connected %s(%dx%d, %d)\n", - __func__, mfd->var_xres, mfd->var_yres, - mfd->var_pixclock); - - hdmi_msm_turn_on(); - hdmi_msm_state->panel_power_on = TRUE; - - if (hdmi_msm_state->hdcp_enable) { - /* Kick off HDCP Authentication */ - mutex_lock(&hdcp_auth_state_mutex); - hdmi_msm_state->reauth = FALSE; - hdmi_msm_state->full_auth_done = FALSE; - mutex_unlock(&hdcp_auth_state_mutex); - mod_timer(&hdmi_msm_state->hdcp_timer, - jiffies + HZ/2); - } - } else { - mutex_unlock(&external_common_state_hpd_mutex); - } - - hdmi_msm_dump_regs("HDMI-ON: "); - DEV_INFO("power=%s DVI= %s\n", - hdmi_msm_is_power_on() ? "ON" : "OFF" , - hdmi_msm_is_dvi_mode() ? "ON" : "OFF"); - } else { - DEV_ERR("%s: Video fmt %d not supp. Returning\n", - __func__, - external_common_state->video_resolution); - } - -error: - /* Set HPD cable sense polarity */ - hdmi_msm_hpd_polarity_setup(); - - return ret; -} - -void mhl_connect_api(boolean on) -{ - char *envp[2]; - - /* Simulating a HPD event based on MHL event */ - if (on) { - hdmi_msm_read_edid(); - hdmi_msm_state->reauth = FALSE ; - /* Build EDID table */ - hdmi_msm_turn_on(); - DEV_INFO("HDMI HPD: CONNECTED: send ONLINE\n"); - kobject_uevent(external_common_state->uevent_kobj, - KOBJ_ONLINE); - envp[0] = 0; - if (!hdmi_msm_state->hdcp_enable) { - /* Send Audio for HDMI Compliance Cases*/ - envp[0] = "HDCP_STATE=PASS"; - envp[1] = NULL; - DEV_INFO("HDMI HPD: sense : send HDCP_PASS\n"); - kobject_uevent_env(external_common_state->uevent_kobj, - KOBJ_CHANGE, envp); - switch_set_state(&external_common_state->sdev, 1); - DEV_INFO("%s: hdmi state switched to %d\n", - __func__, external_common_state->sdev.state); - } else { - hdmi_msm_hdcp_enable(); - } - } else { - DEV_INFO("HDMI HPD: DISCONNECTED: send OFFLINE\n"); - kobject_uevent(external_common_state->uevent_kobj, - KOBJ_OFFLINE); - switch_set_state(&external_common_state->sdev, 0); - DEV_INFO("%s: hdmi state switched to %d\n", __func__, - external_common_state->sdev.state); - } -} -EXPORT_SYMBOL(mhl_connect_api); - -/* Note that power-off will also be called when the cable-remove event is - * processed on the user-space and as a result the framebuffer is powered - * down. However, we are still required to be able to detect a cable-insert - * event; so for now leave the HDMI engine running; so that the HPD IRQ is - * still being processed. - */ -static int hdmi_msm_power_off(struct platform_device *pdev) -{ - int ret = 0; - - if (!hdmi_ready()) { - DEV_ERR("%s: HDMI/HPD not initialized\n", __func__); - return ret; - } - - if (!hdmi_msm_state->panel_power_on) { - DEV_DBG("%s: panel not ON\n", __func__); - goto error; - } - - if (hdmi_msm_state->hdcp_enable) { - if (hdmi_msm_state->hdcp_activating) { - /* - * Let the HDCP work know that we got an HPD - * disconnect so that it can stop the - * reauthentication loop. - */ - mutex_lock(&hdcp_auth_state_mutex); - hdmi_msm_state->hpd_during_auth = TRUE; - mutex_unlock(&hdcp_auth_state_mutex); - } - - /* - * Cancel any pending reauth attempts. - * If one is ongoing, wait for it to finish - */ - cancel_work_sync(&hdmi_msm_state->hdcp_reauth_work); - cancel_work_sync(&hdmi_msm_state->hdcp_work); - del_timer_sync(&hdmi_msm_state->hdcp_timer); - hdmi_msm_state->reauth = FALSE; - - hdcp_deauthenticate(); - } - - SWITCH_SET_HDMI_AUDIO(0, 0); - - if (!hdmi_msm_is_dvi_mode()) - hdmi_msm_audio_off(); - - hdmi_msm_powerdown_phy(); - - hdmi_msm_state->panel_power_on = FALSE; - DEV_INFO("power: OFF (audio off)\n"); - - if (!completion_done(&hdmi_msm_state->hpd_event_processed)) - complete(&hdmi_msm_state->hpd_event_processed); -error: - /* Set HPD cable sense polarity */ - hdmi_msm_hpd_polarity_setup(); - - return ret; -} - -bool mhl_is_enabled(void) -{ - return hdmi_msm_state->is_mhl_enabled; -} - -void hdmi_msm_config_hdcp_feature(void) -{ - if (hdcp_feature_on && hdmi_msm_has_hdcp()) { - init_timer(&hdmi_msm_state->hdcp_timer); - hdmi_msm_state->hdcp_timer.function = hdmi_msm_hdcp_timer; - hdmi_msm_state->hdcp_timer.data = (uint32)NULL; - hdmi_msm_state->hdcp_timer.expires = 0xffffffffL; - - init_completion(&hdmi_msm_state->hdcp_success_done); - INIT_WORK(&hdmi_msm_state->hdcp_reauth_work, - hdmi_msm_hdcp_reauth_work); - INIT_WORK(&hdmi_msm_state->hdcp_work, hdmi_msm_hdcp_work); - hdmi_msm_state->hdcp_enable = TRUE; - } else { - del_timer(&hdmi_msm_state->hdcp_timer); - hdmi_msm_state->hdcp_enable = FALSE; - } - external_common_state->present_hdcp = hdmi_msm_state->hdcp_enable; - DEV_INFO("%s: HDCP Feature: %s\n", __func__, - hdmi_msm_state->hdcp_enable ? "Enabled" : "Disabled"); -} - -static void hdmi_msm_update_panel_info(struct msm_fb_data_type *mfd) -{ - if (!mfd) - return; - - if (hdmi_common_get_video_format_from_drv_data(mfd)) - hdmi_common_init_panel_info(&mfd->panel_info); -} - -static bool hdmi_msm_cable_connected(void) -{ - return hdmi_msm_state->hpd_initialized && - external_common_state->hpd_state; -} - -static int hdmi_msm_probe(struct platform_device *pdev) -{ - int rc; - struct platform_device *fb_dev; - struct msm_fb_data_type *mfd = NULL; - - if (!hdmi_msm_state) { - pr_err("%s: hdmi_msm_state is NULL\n", __func__); - return -ENOMEM; - } - - external_common_state->dev = &pdev->dev; - DEV_DBG("probe\n"); - if (pdev->id == 0) { - struct resource *res; - - #define GET_RES(name, mode) do { \ - res = platform_get_resource_byname(pdev, mode, name); \ - if (!res) { \ - DEV_ERR("'" name "' resource not found\n"); \ - rc = -ENODEV; \ - goto error; \ - } \ - } while (0) - - #define IO_REMAP(var, name) do { \ - GET_RES(name, IORESOURCE_MEM); \ - var = ioremap(res->start, resource_size(res)); \ - if (!var) { \ - DEV_ERR("'" name "' ioremap failed\n"); \ - rc = -ENOMEM; \ - goto error; \ - } \ - } while (0) - - #define GET_IRQ(var, name) do { \ - GET_RES(name, IORESOURCE_IRQ); \ - var = res->start; \ - } while (0) - - IO_REMAP(hdmi_msm_state->qfprom_io, "hdmi_msm_qfprom_addr"); - hdmi_msm_state->hdmi_io = MSM_HDMI_BASE; - GET_IRQ(hdmi_msm_state->irq, "hdmi_msm_irq"); - - hdmi_msm_state->pd = pdev->dev.platform_data; - - #undef GET_RES - #undef IO_REMAP - #undef GET_IRQ - return 0; - } - - hdmi_msm_state->hdmi_app_clk = clk_get(&pdev->dev, "core_clk"); - if (IS_ERR(hdmi_msm_state->hdmi_app_clk)) { - DEV_ERR("'core_clk' clk not found\n"); - rc = IS_ERR(hdmi_msm_state->hdmi_app_clk); - goto error; - } - - hdmi_msm_state->hdmi_m_pclk = clk_get(&pdev->dev, "master_iface_clk"); - if (IS_ERR(hdmi_msm_state->hdmi_m_pclk)) { - DEV_ERR("'master_iface_clk' clk not found\n"); - rc = IS_ERR(hdmi_msm_state->hdmi_m_pclk); - goto error; - } - - hdmi_msm_state->hdmi_s_pclk = clk_get(&pdev->dev, "slave_iface_clk"); - if (IS_ERR(hdmi_msm_state->hdmi_s_pclk)) { - DEV_ERR("'slave_iface_clk' clk not found\n"); - rc = IS_ERR(hdmi_msm_state->hdmi_s_pclk); - goto error; - } - - hdmi_msm_state->is_mhl_enabled = hdmi_msm_state->pd->is_mhl_enabled; - - rc = check_hdmi_features(); - if (rc) { - DEV_ERR("Init FAILED: check_hdmi_features rc=%d\n", rc); - goto error; - } - - if (!hdmi_msm_state->pd->core_power) { - DEV_ERR("Init FAILED: core_power function missing\n"); - rc = -ENODEV; - goto error; - } - if (!hdmi_msm_state->pd->enable_5v) { - DEV_ERR("Init FAILED: enable_5v function missing\n"); - rc = -ENODEV; - goto error; - } - - if (!hdmi_msm_state->pd->cec_power) { - DEV_ERR("Init FAILED: cec_power function missing\n"); - rc = -ENODEV; - goto error; - } - - rc = request_threaded_irq(hdmi_msm_state->irq, NULL, &hdmi_msm_isr, - IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "hdmi_msm_isr", NULL); - if (rc) { - DEV_ERR("Init FAILED: IRQ request, rc=%d\n", rc); - goto error; - } - disable_irq(hdmi_msm_state->irq); - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - init_timer(&hdmi_msm_state->cec_read_timer); - hdmi_msm_state->cec_read_timer.function = - hdmi_msm_cec_read_timer_func; - hdmi_msm_state->cec_read_timer.data = (uint32)NULL; - - hdmi_msm_state->cec_read_timer.expires = 0xffffffffL; - #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - - fb_dev = msm_fb_add_device(pdev); - if (fb_dev) { - rc = external_common_state_create(fb_dev); - if (rc) { - DEV_ERR("Init FAILED: hdmi_msm_state_create, rc=%d\n", - rc); - goto error; - } - } else - DEV_ERR("Init FAILED: failed to add fb device\n"); - - mfd = platform_get_drvdata(fb_dev); - mfd->update_panel_info = hdmi_msm_update_panel_info; - mfd->is_panel_ready = hdmi_msm_cable_connected; - - if (hdmi_prim_display) { - rc = hdmi_msm_hpd_on(); - if (rc) - goto error; - } - - hdmi_msm_config_hdcp_feature(); - - /* Initialize hdmi node and register with switch driver */ - if (hdmi_prim_display) - external_common_state->sdev.name = "hdmi_as_primary"; - else - external_common_state->sdev.name = "hdmi"; - if (switch_dev_register(&external_common_state->sdev) < 0) { - DEV_ERR("Hdmi switch registration failed\n"); - rc = -ENODEV; - goto error; - } - - external_common_state->audio_sdev.name = "hdmi_audio"; - if (switch_dev_register(&external_common_state->audio_sdev) < 0) { - DEV_ERR("Hdmi audio switch registration failed\n"); - switch_dev_unregister(&external_common_state->sdev); - rc = -ENODEV; - goto error; - } - - /* Set the default video resolution for MHL-enabled display */ - if (hdmi_msm_state->is_mhl_enabled) { - DEV_DBG("MHL Enabled. Restricting default video resolution\n"); - external_common_state->video_resolution = - HDMI_VFRMT_1920x1080p30_16_9; - } - return 0; - -error: - if (hdmi_msm_state->qfprom_io) - iounmap(hdmi_msm_state->qfprom_io); - hdmi_msm_state->qfprom_io = NULL; - - if (hdmi_msm_state->hdmi_io) - iounmap(hdmi_msm_state->hdmi_io); - hdmi_msm_state->hdmi_io = NULL; - - external_common_state_remove(); - - if (hdmi_msm_state->hdmi_app_clk) - clk_put(hdmi_msm_state->hdmi_app_clk); - if (hdmi_msm_state->hdmi_m_pclk) - clk_put(hdmi_msm_state->hdmi_m_pclk); - if (hdmi_msm_state->hdmi_s_pclk) - clk_put(hdmi_msm_state->hdmi_s_pclk); - - hdmi_msm_state->hdmi_app_clk = NULL; - hdmi_msm_state->hdmi_m_pclk = NULL; - hdmi_msm_state->hdmi_s_pclk = NULL; - - return rc; -} - -static int hdmi_msm_remove(struct platform_device *pdev) -{ - DEV_INFO("HDMI device: remove\n"); - - DEV_INFO("HDMI HPD: OFF\n"); - - /* Unregister hdmi node from switch driver */ - switch_dev_unregister(&external_common_state->sdev); - switch_dev_unregister(&external_common_state->audio_sdev); - - hdmi_msm_hpd_off(); - free_irq(hdmi_msm_state->irq, NULL); - - if (hdmi_msm_state->qfprom_io) - iounmap(hdmi_msm_state->qfprom_io); - hdmi_msm_state->qfprom_io = NULL; - - if (hdmi_msm_state->hdmi_io) - iounmap(hdmi_msm_state->hdmi_io); - hdmi_msm_state->hdmi_io = NULL; - - external_common_state_remove(); - - if (hdmi_msm_state->hdmi_app_clk) - clk_put(hdmi_msm_state->hdmi_app_clk); - if (hdmi_msm_state->hdmi_m_pclk) - clk_put(hdmi_msm_state->hdmi_m_pclk); - if (hdmi_msm_state->hdmi_s_pclk) - clk_put(hdmi_msm_state->hdmi_s_pclk); - - hdmi_msm_state->hdmi_app_clk = NULL; - hdmi_msm_state->hdmi_m_pclk = NULL; - hdmi_msm_state->hdmi_s_pclk = NULL; - - kfree(hdmi_msm_state); - hdmi_msm_state = NULL; - - return 0; -} - -static int hdmi_msm_hpd_feature(int on) -{ - int rc = 0; - - DEV_INFO("%s: %d\n", __func__, on); - if (on) { - rc = hdmi_msm_hpd_on(); - } else { - if (external_common_state->hpd_state) { - external_common_state->hpd_state = 0; - - /* Send offline event to switch OFF HDMI and HAL FD */ - hdmi_msm_send_event(HPD_EVENT_OFFLINE); - - /* Wait for HDMI and FD to close */ - INIT_COMPLETION(hdmi_msm_state->hpd_event_processed); - wait_for_completion_interruptible_timeout( - &hdmi_msm_state->hpd_event_processed, HZ); - } - - hdmi_msm_hpd_off(); - - /* Set HDMI switch node to 0 on HPD feature disable */ - switch_set_state(&external_common_state->sdev, 0); - DEV_INFO("%s: hdmi state switched to %d\n", __func__, - external_common_state->sdev.state); - } - - return rc; -} - -static struct platform_driver this_driver = { - .probe = hdmi_msm_probe, - .remove = hdmi_msm_remove, - .driver.name = "hdmi_msm", -}; - -static struct msm_fb_panel_data hdmi_msm_panel_data = { - .on = hdmi_msm_power_on, - .off = hdmi_msm_power_off, - .power_ctrl = hdmi_msm_power_ctrl, -}; - -static struct platform_device this_device = { - .name = "hdmi_msm", - .id = 1, - .dev.platform_data = &hdmi_msm_panel_data, -}; - -static int __init hdmi_msm_init(void) -{ - int rc; - - if (msm_fb_detect_client("hdmi_msm")) - return 0; - -#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY - hdmi_prim_display = 1; -#endif - - hdmi_msm_setup_video_mode_lut(); - hdmi_msm_state = kzalloc(sizeof(*hdmi_msm_state), GFP_KERNEL); - if (!hdmi_msm_state) { - pr_err("hdmi_msm_init FAILED: out of memory\n"); - rc = -ENOMEM; - goto init_exit; - } - - external_common_state = &hdmi_msm_state->common; - - if (hdmi_prim_display && hdmi_prim_resolution) - external_common_state->video_resolution = - hdmi_prim_resolution - 1; - else - external_common_state->video_resolution = - HDMI_VFRMT_1920x1080p60_16_9; - -#ifdef CONFIG_FB_MSM_HDMI_3D - external_common_state->switch_3d = hdmi_msm_switch_3d; -#endif - memset(external_common_state->spd_vendor_name, 0, - sizeof(external_common_state->spd_vendor_name)); - memset(external_common_state->spd_product_description, 0, - sizeof(external_common_state->spd_product_description)); - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - hdmi_msm_state->cec_queue_start = - kzalloc(sizeof(struct hdmi_msm_cec_msg)*CEC_QUEUE_SIZE, - GFP_KERNEL); - if (!hdmi_msm_state->cec_queue_start) { - pr_err("hdmi_msm_init FAILED: CEC queue out of memory\n"); - rc = -ENOMEM; - goto init_exit; - } - - hdmi_msm_state->cec_queue_wr = hdmi_msm_state->cec_queue_start; - hdmi_msm_state->cec_queue_rd = hdmi_msm_state->cec_queue_start; - hdmi_msm_state->cec_queue_full = false; -#endif - - /* - * Create your work queue - * allocs and returns ptr - */ - hdmi_work_queue = create_workqueue("hdmi_hdcp"); - external_common_state->hpd_feature = hdmi_msm_hpd_feature; - - rc = platform_driver_register(&this_driver); - if (rc) { - pr_err("hdmi_msm_init FAILED: platform_driver_register rc=%d\n", - rc); - goto init_exit; - } - - hdmi_common_init_panel_info(&hdmi_msm_panel_data.panel_info); - init_completion(&hdmi_msm_state->ddc_sw_done); - init_completion(&hdmi_msm_state->hpd_event_processed); - INIT_WORK(&hdmi_msm_state->hpd_state_work, hdmi_msm_hpd_state_work); - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - INIT_WORK(&hdmi_msm_state->cec_latch_detect_work, - hdmi_msm_cec_latch_work); - init_completion(&hdmi_msm_state->cec_frame_wr_done); - init_completion(&hdmi_msm_state->cec_line_latch_wait); -#endif - - rc = platform_device_register(&this_device); - if (rc) { - pr_err("hdmi_msm_init FAILED: platform_device_register rc=%d\n", - rc); - platform_driver_unregister(&this_driver); - goto init_exit; - } - - pr_debug("%s: success:" -#ifdef DEBUG - " DEBUG" -#else - " RELEASE" -#endif - " AUDIO EDID HPD HDCP" - " DVI" -#ifndef CONFIG_FB_MSM_HDMI_MSM_PANEL_DVI_SUPPORT - ":0" -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_DVI_SUPPORT */ - "\n", __func__); - - return 0; - -init_exit: - kfree(hdmi_msm_state); - hdmi_msm_state = NULL; - - return rc; -} - -static void __exit hdmi_msm_exit(void) -{ - platform_device_unregister(&this_device); - platform_driver_unregister(&this_driver); -} - -static int set_hdcp_feature_on(const char *val, const struct kernel_param *kp) -{ - int rv = param_set_bool(val, kp); - - if (rv) - return rv; - - pr_debug("%s: HDCP feature = %d\n", __func__, hdcp_feature_on); - if (hdmi_msm_state) { - if ((HDMI_INP(0x0250) & 0x2)) { - pr_err("%s: Unable to set HDCP feature", __func__); - pr_err("%s: HDMI panel is currently turned on", - __func__); - } else if (hdcp_feature_on != hdmi_msm_state->hdcp_enable) { - hdmi_msm_config_hdcp_feature(); - } - } - - return 0; -} - -static struct kernel_param_ops hdcp_feature_on_param_ops = { - .set = set_hdcp_feature_on, - .get = param_get_bool, -}; - -module_param_cb(hdcp, &hdcp_feature_on_param_ops, &hdcp_feature_on, - S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(hdcp, "Enable or Disable HDCP"); - -module_init(hdmi_msm_init); -module_exit(hdmi_msm_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("0.3"); -MODULE_AUTHOR("Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("HDMI MSM TX driver"); diff --git a/drivers/video/msm/hdmi_msm.h b/drivers/video/msm/hdmi_msm.h deleted file mode 100644 index ce018303a0dd6e32f11f59a2161d26891fd5739d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/hdmi_msm.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (c) 2010-2012, 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 __HDMI_MSM_H__ -#define __HDMI_MSM_H__ - -#include -#include "external_common.h" -/* #define PORT_DEBUG */ - -#ifdef PORT_DEBUG -const char *hdmi_msm_name(uint32 offset); -void hdmi_outp(uint32 offset, uint32 value); -uint32 hdmi_inp(uint32 offset); - -#define HDMI_OUTP_ND(offset, value) outpdw(MSM_HDMI_BASE+(offset), (value)) -#define HDMI_OUTP(offset, value) hdmi_outp((offset), (value)) -#define HDMI_INP_ND(offset) inpdw(MSM_HDMI_BASE+(offset)) -#define HDMI_INP(offset) hdmi_inp((offset)) -#else -#define HDMI_OUTP_ND(offset, value) outpdw(MSM_HDMI_BASE+(offset), (value)) -#define HDMI_OUTP(offset, value) outpdw(MSM_HDMI_BASE+(offset), (value)) -#define HDMI_INP_ND(offset) inpdw(MSM_HDMI_BASE+(offset)) -#define HDMI_INP(offset) inpdw(MSM_HDMI_BASE+(offset)) -#endif - - -/* - * Ref. HDMI 1.4a - * Supplement-1 CEC Section 6, 7 - */ -struct hdmi_msm_cec_msg { - uint8 sender_id; - uint8 recvr_id; - uint8 opcode; - uint8 operand[15]; - uint8 frame_size; - uint8 retransmit; -}; - -#define QFPROM_BASE ((uint32)hdmi_msm_state->qfprom_io) -#define HDMI_BASE ((uint32)hdmi_msm_state->hdmi_io) - -struct hdmi_msm_state_type { - boolean panel_power_on; - boolean hpd_initialized; -#ifdef CONFIG_SUSPEND - boolean pm_suspended; -#endif - boolean full_auth_done; - boolean hpd_during_auth; - struct work_struct hpd_state_work; - struct completion ddc_sw_done; - - bool hdcp_enable; - boolean hdcp_activating; - boolean reauth ; - struct work_struct hdcp_reauth_work, hdcp_work; - struct completion hdcp_success_done; - struct timer_list hdcp_timer; - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT - boolean cec_enabled; - unsigned int first_monitor; - int cec_logical_addr; - struct completion cec_frame_wr_done; - struct timer_list cec_read_timer; -#define CEC_STATUS_WR_ERROR 0x0001 -#define CEC_STATUS_WR_DONE 0x0002 -#define CEC_STATUS_WR_TMOUT 0x0004 - uint32 cec_frame_wr_status; - - struct hdmi_msm_cec_msg *cec_queue_start; - struct hdmi_msm_cec_msg *cec_queue_wr; - struct hdmi_msm_cec_msg *cec_queue_rd; - boolean cec_queue_full; - boolean fsm_reset_done; - - /* - * CECT 9-5-1 - */ - struct completion cec_line_latch_wait; - struct work_struct cec_latch_detect_work; - -#define CEC_QUEUE_SIZE 16 -#define CEC_QUEUE_END (hdmi_msm_state->cec_queue_start + CEC_QUEUE_SIZE) -#define RETRANSMIT_MAX_NUM 5 -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ - - int irq; - struct msm_hdmi_platform_data *pd; - struct clk *hdmi_app_clk; - struct clk *hdmi_m_pclk; - struct clk *hdmi_s_pclk; - void __iomem *qfprom_io; - void __iomem *hdmi_io; - - struct external_common_state_type common; - boolean is_mhl_enabled; - struct completion hpd_event_processed; -}; - -extern struct hdmi_msm_state_type *hdmi_msm_state; - -uint32 hdmi_msm_get_io_base(void); - -#ifdef CONFIG_FB_MSM_HDMI_COMMON -void hdmi_msm_set_mode(boolean power_on); -int hdmi_msm_clk(int on); -void hdmi_phy_reset(void); -void hdmi_msm_reset_core(void); -void hdmi_msm_init_phy(int video_format); -void hdmi_msm_powerdown_phy(void); -void hdmi_frame_ctrl_cfg(const struct hdmi_disp_mode_timing_type *timing); -void hdmi_msm_phy_status_poll(void); -#endif - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT -void hdmi_msm_cec_init(void); -void hdmi_msm_cec_write_logical_addr(int addr); -void hdmi_msm_cec_msg_recv(void); -void hdmi_msm_cec_one_touch_play(void); -void hdmi_msm_cec_msg_send(struct hdmi_msm_cec_msg *msg); -#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL_CEC_SUPPORT */ -void mhl_connect_api(boolean on); -#endif /* __HDMI_MSM_H__ */ diff --git a/drivers/video/msm/hdmi_sii9022.c b/drivers/video/msm/hdmi_sii9022.c deleted file mode 100644 index c1b5e03caf94823eae57a9ff252ab79ed1808f56..0000000000000000000000000000000000000000 --- a/drivers/video/msm/hdmi_sii9022.c +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright (c) 2009-2010, 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 -#include -#include "msm_fb.h" - -#define DEVICE_NAME "sii9022" -#define SII9022_DEVICE_ID 0xB0 - -struct sii9022_i2c_addr_data{ - u8 addr; - u8 data; -}; - -/* video mode data */ -static u8 video_mode_data[] = { - 0x00, - 0xF9, 0x1C, 0x70, 0x17, 0x72, 0x06, 0xEE, 0x02, -}; - -static u8 avi_io_format[] = { - 0x09, - 0x00, 0x00, -}; - -/* power state */ -static struct sii9022_i2c_addr_data regset0[] = { - { 0x60, 0x04 }, - { 0x63, 0x00 }, - { 0x1E, 0x00 }, -}; - -static u8 video_infoframe[] = { - 0x0C, - 0xF0, 0x00, 0x68, 0x00, 0x04, 0x00, 0x19, 0x00, - 0xE9, 0x02, 0x04, 0x01, 0x04, 0x06, -}; - -/* configure audio */ -static struct sii9022_i2c_addr_data regset1[] = { - { 0x26, 0x90 }, - { 0x20, 0x90 }, - { 0x1F, 0x80 }, - { 0x26, 0x80 }, - { 0x24, 0x02 }, - { 0x25, 0x0B }, - { 0xBC, 0x02 }, - { 0xBD, 0x24 }, - { 0xBE, 0x02 }, -}; - -/* enable audio */ -static u8 misc_infoframe[] = { - 0xBF, - 0xC2, 0x84, 0x01, 0x0A, 0x6F, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -/* set HDMI, active */ -static struct sii9022_i2c_addr_data regset2[] = { - { 0x1A, 0x01 }, - { 0x3D, 0x00 }, -}; - -static int send_i2c_data(struct i2c_client *client, - struct sii9022_i2c_addr_data *regset, - int size) -{ - int i; - int rc = 0; - - for (i = 0; i < size; i++) { - rc = i2c_smbus_write_byte_data( - client, - regset[i].addr, regset[i].data); - if (rc) - break; - } - return rc; -} - -static int hdmi_sii_enable(struct i2c_client *client) -{ - int rc; - int retries = 10; - int count; - - rc = i2c_smbus_write_byte_data(client, 0xC7, 0x00); - if (rc) - goto enable_exit; - - do { - msleep(1); - rc = i2c_smbus_read_byte_data(client, 0x1B); - } while ((rc != SII9022_DEVICE_ID) && retries--); - - if (rc != SII9022_DEVICE_ID) - return -ENODEV; - - rc = i2c_smbus_write_byte_data(client, 0x1A, 0x11); - if (rc) - goto enable_exit; - - count = ARRAY_SIZE(video_mode_data); - rc = i2c_master_send(client, video_mode_data, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = i2c_smbus_write_byte_data(client, 0x08, 0x20); - if (rc) - goto enable_exit; - count = ARRAY_SIZE(avi_io_format); - rc = i2c_master_send(client, avi_io_format, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = send_i2c_data(client, regset0, ARRAY_SIZE(regset0)); - if (rc) - goto enable_exit; - - count = ARRAY_SIZE(video_infoframe); - rc = i2c_master_send(client, video_infoframe, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = send_i2c_data(client, regset1, ARRAY_SIZE(regset1)); - if (rc) - goto enable_exit; - - count = ARRAY_SIZE(misc_infoframe); - rc = i2c_master_send(client, misc_infoframe, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = send_i2c_data(client, regset2, ARRAY_SIZE(regset2)); - if (rc) - goto enable_exit; - - return 0; -enable_exit: - printk(KERN_ERR "%s: exited rc=%d\n", __func__, rc); - return rc; -} - -static const struct i2c_device_id hmdi_sii_id[] = { - { DEVICE_NAME, 0 }, - { } -}; - -static int hdmi_sii_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int rc; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C)) - return -ENODEV; - rc = hdmi_sii_enable(client); - return rc; -} - - -static struct i2c_driver hdmi_sii_i2c_driver = { - .driver = { - .name = DEVICE_NAME, - .owner = THIS_MODULE, - }, - .probe = hdmi_sii_probe, - .remove = __exit_p(hdmi_sii_remove), - .id_table = hmdi_sii_id, -}; - -static int __init hdmi_sii_init(void) -{ - int ret; - struct msm_panel_info pinfo; - - if (msm_fb_detect_client("hdmi_sii9022")) - return 0; - - pinfo.xres = 1280; - pinfo.yres = 720; - MSM_FB_SINGLE_MODE_PANEL(&pinfo); - pinfo.type = HDMI_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 18; - pinfo.fb_num = 2; - pinfo.clk_rate = 74250000; - - pinfo.lcdc.h_back_porch = 124; - pinfo.lcdc.h_front_porch = 110; - pinfo.lcdc.h_pulse_width = 136; - pinfo.lcdc.v_back_porch = 19; - pinfo.lcdc.v_front_porch = 5; - pinfo.lcdc.v_pulse_width = 6; - pinfo.lcdc.border_clr = 0; - pinfo.lcdc.underflow_clr = 0xff; - pinfo.lcdc.hsync_skew = 0; - - ret = lcdc_device_register(&pinfo); - if (ret) { - printk(KERN_ERR "%s: failed to register device\n", __func__); - goto init_exit; - } - - ret = i2c_add_driver(&hdmi_sii_i2c_driver); - if (ret) - printk(KERN_ERR "%s: failed to add i2c driver\n", __func__); - -init_exit: - return ret; -} - -static void __exit hdmi_sii_exit(void) -{ - i2c_del_driver(&hdmi_sii_i2c_driver); -} - -module_init(hdmi_sii_init); -module_exit(hdmi_sii_exit); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("0.1"); -MODULE_AUTHOR("Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("SiI9022 HDMI driver"); -MODULE_ALIAS("platform:hdmi-sii9022"); diff --git a/drivers/video/msm/lcdc.c b/drivers/video/msm/lcdc.c deleted file mode 100644 index 6fdc04ca4071e8abcdbe795574e67d1cd27deefc..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc.c +++ /dev/null @@ -1,302 +0,0 @@ -/* Copyright (c) 2008-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "msm_fb.h" - -static int lcdc_probe(struct platform_device *pdev); -static int lcdc_remove(struct platform_device *pdev); - -static int lcdc_off(struct platform_device *pdev); -static int lcdc_on(struct platform_device *pdev); -static void cont_splash_clk_ctrl(int enable); - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; - -static struct clk *pixel_mdp_clk; /* drives the lcdc block in mdp */ -static struct clk *pixel_lcdc_clk; /* drives the lcdc interface */ - -static struct platform_driver lcdc_driver = { - .probe = lcdc_probe, - .remove = lcdc_remove, - .suspend = NULL, - .resume = NULL, - .shutdown = NULL, - .driver = { - .name = "lcdc", - }, -}; - -static struct lcdc_platform_data *lcdc_pdata; - -static int lcdc_off(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - ret = panel_next_off(pdev); - - clk_disable_unprepare(pixel_mdp_clk); - clk_disable_unprepare(pixel_lcdc_clk); - - if (lcdc_pdata && lcdc_pdata->lcdc_power_save) - lcdc_pdata->lcdc_power_save(0); - - if (lcdc_pdata && lcdc_pdata->lcdc_gpio_config) - ret = lcdc_pdata->lcdc_gpio_config(0); - -#ifndef CONFIG_MSM_BUS_SCALING - if (mfd->ebi1_clk) { - if (mdp_rev == MDP_REV_303) { - if (clk_set_rate(mfd->ebi1_clk, 0)) - pr_err("%s: ebi1_lcdc_clk set rate failed\n", - __func__); - } - clk_disable_unprepare(mfd->ebi1_clk); - } -#endif - - return ret; -} - -static int lcdc_on(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd; - unsigned long panel_pixclock_freq = 0; -#ifndef CONFIG_MSM_BUS_SCALING - unsigned long pm_qos_rate; -#endif - mfd = platform_get_drvdata(pdev); - - cont_splash_clk_ctrl(0); - - if (lcdc_pdata && lcdc_pdata->lcdc_get_clk) - panel_pixclock_freq = lcdc_pdata->lcdc_get_clk(); - - if (!panel_pixclock_freq) - panel_pixclock_freq = mfd->fbi->var.pixclock; -#ifndef CONFIG_MSM_BUS_SCALING - if (panel_pixclock_freq > 65000000) - /* pm_qos_rate should be in Khz */ - pm_qos_rate = panel_pixclock_freq / 1000 ; - else - pm_qos_rate = 65000; - - if (mfd->ebi1_clk) { - if (mdp_rev == MDP_REV_303) { - if (clk_set_rate(mfd->ebi1_clk, 65000000)) - pr_err("%s: ebi1_lcdc_clk set rate failed\n", - __func__); - } else { - clk_set_rate(mfd->ebi1_clk, pm_qos_rate * 1000); - } - clk_prepare_enable(mfd->ebi1_clk); - } - -#endif - mfd = platform_get_drvdata(pdev); - - mfd->fbi->var.pixclock = clk_round_rate(pixel_mdp_clk, - mfd->fbi->var.pixclock); - ret = clk_set_rate(pixel_mdp_clk, mfd->fbi->var.pixclock); - if (ret) { - pr_err("%s: Can't set MDP LCDC pixel clock to rate %u\n", - __func__, mfd->fbi->var.pixclock); - goto out; - } - - clk_prepare_enable(pixel_mdp_clk); - clk_prepare_enable(pixel_lcdc_clk); - - if (lcdc_pdata && lcdc_pdata->lcdc_power_save) - lcdc_pdata->lcdc_power_save(1); - if (lcdc_pdata && lcdc_pdata->lcdc_gpio_config) - ret = lcdc_pdata->lcdc_gpio_config(1); - - ret = panel_next_on(pdev); - -out: - return ret; -} - -static void cont_splash_clk_ctrl(int enable) -{ - static int cont_splash_clks_enabled; - if (enable && !cont_splash_clks_enabled) { - clk_prepare_enable(pixel_mdp_clk); - clk_prepare_enable(pixel_lcdc_clk); - cont_splash_clks_enabled = 1; - } else if (!enable && cont_splash_clks_enabled) { - clk_disable_unprepare(pixel_mdp_clk); - clk_disable_unprepare(pixel_lcdc_clk); - cont_splash_clks_enabled = 0; - } -} - -static int lcdc_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct fb_info *fbi; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc; - struct clk *ebi1_clk = NULL; - - if (pdev->id == 0) { - lcdc_pdata = pdev->dev.platform_data; - pixel_mdp_clk = clk_get(&pdev->dev, "mdp_clk"); - if (IS_ERR(pixel_mdp_clk)) { - pr_err("Couldnt find pixel_mdp_clk\n"); - return -EINVAL; - } - - pixel_lcdc_clk = clk_get(&pdev->dev, "lcdc_clk"); - if (IS_ERR(pixel_lcdc_clk)) { - pr_err("Couldnt find pixel_lcdc_clk\n"); - return -EINVAL; - } - -#ifndef CONFIG_MSM_BUS_SCALING - ebi1_clk = clk_get(&pdev->dev, "mem_clk"); - if (IS_ERR(ebi1_clk)) - return PTR_ERR(ebi1_clk); -#endif - - return 0; - } - - mfd = platform_get_drvdata(pdev); - mfd->ebi1_clk = ebi1_clk; - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - - cont_splash_clk_ctrl(1); - - /* - * link to the latest pdev - */ - mfd->pdev = mdp_dev; - mfd->dest = DISPLAY_LCDC; - - /* - * alloc panel device data - */ - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - pr_err("lcdc_probe: platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - /* - * data chain - */ - pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; - pdata->on = lcdc_on; - pdata->off = lcdc_off; - pdata->next = pdev; - - /* - * get/set panel specific fb info - */ - mfd->panel_info = pdata->panel_info; - - if (mfd->index == 0) - mfd->fb_imgType = MSMFB_DEFAULT_TYPE; - else - mfd->fb_imgType = MDP_RGB_565; - - fbi = mfd->fbi; - fbi->var.pixclock = clk_round_rate(pixel_mdp_clk, - mfd->panel_info.clk_rate); - fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; - fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; - fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; - fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; - fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; - fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; - - /* - * set driver data - */ - platform_set_drvdata(mdp_dev, mfd); - /* - * register in mdp driver - */ - rc = platform_device_add(mdp_dev); - if (rc) - goto lcdc_probe_err; - - pdev_list[pdev_list_cnt++] = pdev; - - return 0; - -lcdc_probe_err: - platform_device_put(mdp_dev); - return rc; -} - -static int lcdc_remove(struct platform_device *pdev) -{ -#ifndef CONFIG_MSM_BUS_SCALING - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - - clk_put(mfd->ebi1_clk); -#endif - return 0; -} - -static int lcdc_register_driver(void) -{ - return platform_driver_register(&lcdc_driver); -} - -static int __init lcdc_driver_init(void) -{ - - return lcdc_register_driver(); -} - -module_init(lcdc_driver_init); diff --git a/drivers/video/msm/lcdc_auo_wvga.c b/drivers/video/msm/lcdc_auo_wvga.c deleted file mode 100644 index f346c459c3b5cfdfbc5b8792c97cd42e2e07e2c7..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_auo_wvga.c +++ /dev/null @@ -1,411 +0,0 @@ -/* Copyright (c) 2011, 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 -#include -#ifdef CONFIG_SPI_QUP -#include -#else -#include -#endif -#include "msm_fb.h" - -#define MAX_BACKLIGHT_LEVEL 15 -#define PANEL_CMD_BACKLIGHT_LEVEL 0x6A18 -#define PANEL_CMD_FORMAT 0x3A00 -#define PANEL_CMD_RGBCTRL 0x3B00 -#define PANEL_CMD_BCTRL 0x5300 -#define PANEL_CMD_PWM_EN 0x6A17 - -#define PANEL_CMD_SLEEP_OUT 0x1100 -#define PANEL_CMD_DISP_ON 0x2900 -#define PANEL_CMD_DISP_OFF 0x2800 -#define PANEL_CMD_SLEEP_IN 0x1000 - -#define LCDC_AUO_PANEL_NAME "lcdc_auo_wvga" - -#ifdef CONFIG_SPI_QUP -#define LCDC_AUO_SPI_DEVICE_NAME "lcdc_auo_nt35582" -static struct spi_device *lcdc_spi_client; -#else -static int spi_cs; -static int spi_sclk; -static int spi_mosi; -#endif - -struct auo_state_type { - boolean display_on; - int bl_level; -}; - - -static struct auo_state_type auo_state = { .bl_level = 10 }; -static struct msm_panel_common_pdata *lcdc_auo_pdata; - -#ifndef CONFIG_SPI_QUP -static void auo_spi_write_byte(u8 data) -{ - uint32 bit; - int bnum; - - bnum = 8; /* 8 data bits */ - bit = 0x80; - while (bnum--) { - gpio_set_value(spi_sclk, 0); /* clk low */ - gpio_set_value(spi_mosi, (data & bit) ? 1 : 0); - udelay(1); - gpio_set_value(spi_sclk, 1); /* clk high */ - udelay(1); - bit >>= 1; - } - gpio_set_value(spi_mosi, 0); -} - -static void auo_spi_read_byte(u16 cmd_16, u8 *data) -{ - int bnum; - u8 cmd_hi = (u8)(cmd_16 >> 8); - u8 cmd_low = (u8)(cmd_16); - - /* Chip Select - low */ - gpio_set_value(spi_cs, 0); - udelay(2); - - /* command byte first */ - auo_spi_write_byte(0x20); - udelay(2); - auo_spi_write_byte(cmd_hi); - udelay(2); - auo_spi_write_byte(0x00); - udelay(2); - auo_spi_write_byte(cmd_low); - udelay(2); - auo_spi_write_byte(0xc0); - udelay(2); - - gpio_direction_input(spi_mosi); - - /* followed by data bytes */ - bnum = 1 * 8; /* number of bits */ - *data = 0; - while (bnum) { - gpio_set_value(spi_sclk, 0); /* clk low */ - udelay(1); - *data <<= 1; - *data |= gpio_get_value(spi_mosi) ? 1 : 0; - gpio_set_value(spi_sclk, 1); /* clk high */ - udelay(1); - --bnum; - if ((bnum % 8) == 0) - ++data; - } - - gpio_direction_output(spi_mosi, 0); - - /* Chip Select - high */ - udelay(2); - gpio_set_value(spi_cs, 1); -} -#endif - -static int auo_serigo(u8 *input_data, int input_len) -{ -#ifdef CONFIG_SPI_QUP - int rc; - struct spi_message m; - struct spi_transfer t; - - if (!lcdc_spi_client) { - pr_err("%s lcdc_spi_client is NULL\n", __func__); - return -EINVAL; - } - - memset(&t, 0, sizeof t); - - t.tx_buf = input_data; - t.len = input_len; - t.bits_per_word = 16; - - spi_setup(lcdc_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - rc = spi_sync(lcdc_spi_client, &m); - - return rc; -#else - int i; - - /* Chip Select - low */ - gpio_set_value(spi_cs, 0); - udelay(2); - - for (i = 0; i < input_len; ++i) { - auo_spi_write_byte(input_data[i]); - udelay(2); - } - - /* Chip Select - high */ - gpio_set_value(spi_cs, 1); - - return 0; -#endif -} - -#ifndef CONFIG_SPI_QUP -static void auo_spi_init(void) -{ - spi_sclk = *(lcdc_auo_pdata->gpio_num); - spi_cs = *(lcdc_auo_pdata->gpio_num + 1); - spi_mosi = *(lcdc_auo_pdata->gpio_num + 2); - - /* Set the output so that we don't disturb the slave device */ - gpio_set_value(spi_sclk, 1); - gpio_set_value(spi_mosi, 0); - - /* Set the Chip Select deasserted (active low) */ - gpio_set_value(spi_cs, 1); -} -#endif - -static struct work_struct disp_on_delayed_work; -static void auo_write_cmd(u16 cmd) -{ - u8 local_data[4]; - - local_data[0] = 0x20; - local_data[1] = (u8)(cmd >> 8); - local_data[2] = 0; - local_data[3] = (u8)cmd; - auo_serigo(local_data, 4); -} -static void auo_write_cmd_1param(u16 cmd, u8 para1) -{ - u8 local_data[6]; - - local_data[0] = 0x20; - local_data[1] = (u8)(cmd >> 8); - local_data[2] = 0; - local_data[3] = (u8)cmd; - local_data[4] = 0x40; - local_data[5] = para1; - auo_serigo(local_data, 6); -} -static void lcdc_auo_set_backlight(struct msm_fb_data_type *mfd) -{ - int bl_level; - - bl_level = mfd->bl_level; - if (auo_state.display_on) { - auo_write_cmd_1param(PANEL_CMD_BACKLIGHT_LEVEL, - bl_level * 255 / MAX_BACKLIGHT_LEVEL); - auo_state.bl_level = bl_level; - } - -} -static void auo_disp_on_delayed_work(struct work_struct *work_ptr) -{ - /* 0x1100: Sleep Out */ - auo_write_cmd(PANEL_CMD_SLEEP_OUT); - - msleep(180); - - /* SET_PIXEL_FORMAT: Set how many bits per pixel are used (3A00h)*/ - auo_write_cmd_1param(PANEL_CMD_FORMAT, 0x66); /* 18 bits */ - - /* RGBCTRL: RGB Interface Signal Control (3B00h) */ - auo_write_cmd_1param(PANEL_CMD_RGBCTRL, 0x2B); - - /* Display ON command */ - auo_write_cmd(PANEL_CMD_DISP_ON); - msleep(20); - - /*Backlight on */ - auo_write_cmd_1param(PANEL_CMD_BCTRL, 0x24); /*BCTRL, BL */ - auo_write_cmd_1param(PANEL_CMD_PWM_EN, 0x01); /*Enable PWM Level */ - - msleep(20); -} - -static void auo_disp_on(void) -{ - if (!auo_state.display_on) { - INIT_WORK(&disp_on_delayed_work, auo_disp_on_delayed_work); -#ifdef CONFIG_SPI_QUP - if (lcdc_spi_client) -#endif - schedule_work(&disp_on_delayed_work); - auo_state.display_on = TRUE; - } -} - -static int lcdc_auo_panel_on(struct platform_device *pdev) -{ - pr_info("%s\n", __func__); - if (!auo_state.display_on) { -#ifndef CONFIG_SPI_QUP - lcdc_auo_pdata->panel_config_gpio(1); - auo_spi_init(); -#endif - auo_disp_on(); - } - return 0; -} - -static int lcdc_auo_panel_off(struct platform_device *pdev) -{ - pr_info("%s\n", __func__); - if (auo_state.display_on) { - /* 0x2800: Display Off */ - auo_write_cmd(PANEL_CMD_DISP_OFF); - msleep(120); - /* 0x1000: Sleep In */ - auo_write_cmd(PANEL_CMD_SLEEP_IN); - msleep(120); - - auo_state.display_on = FALSE; - } - return 0; -} - -static int auo_probe(struct platform_device *pdev) -{ - pr_info("%s: id=%d\n", __func__, pdev->id); - if (pdev->id == 0) { - lcdc_auo_pdata = pdev->dev.platform_data; - return 0; - } - - msm_fb_add_device(pdev); - - return 0; -} - -#ifdef CONFIG_SPI_QUP -static int lcdc_auo_spi_probe(struct spi_device *spi) -{ - pr_info("%s\n", __func__); - lcdc_spi_client = spi; - lcdc_spi_client->bits_per_word = 32; - if (auo_state.display_on) - schedule_work(&disp_on_delayed_work); - return 0; -} -static int lcdc_auo_spi_remove(struct spi_device *spi) -{ - lcdc_spi_client = NULL; - return 0; -} -static struct spi_driver lcdc_auo_spi_driver = { - .driver.name = LCDC_AUO_SPI_DEVICE_NAME, - .driver.owner = THIS_MODULE, - .probe = lcdc_auo_spi_probe, - .remove = lcdc_auo_spi_remove, -}; -#endif - -static struct platform_driver this_driver = { - .probe = auo_probe, - .driver.name = LCDC_AUO_PANEL_NAME, -}; - -static struct msm_fb_panel_data auo_panel_data = { - .on = lcdc_auo_panel_on, - .off = lcdc_auo_panel_off, - .set_backlight = lcdc_auo_set_backlight, -}; - -static struct platform_device this_device = { - .name = LCDC_AUO_PANEL_NAME, - .id = 1, - .dev.platform_data = &auo_panel_data, -}; - -static int __init lcdc_auo_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - if (msm_fb_detect_client(LCDC_AUO_PANEL_NAME)) { - pr_err("%s: detect failed\n", __func__); - return 0; - } - - ret = platform_driver_register(&this_driver); - if (ret) { - pr_err("%s: driver register failed, rc=%d\n", __func__, ret); - return ret; - } - - pinfo = &auo_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 800; - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->clk_rate = 25600000; - pinfo->bl_max = MAX_BACKLIGHT_LEVEL; - pinfo->bl_min = 1; - - pinfo->lcdc.h_back_porch = 16-2; /* HBP-HLW */ - pinfo->lcdc.h_front_porch = 16; - pinfo->lcdc.h_pulse_width = 2; - - pinfo->lcdc.v_back_porch = 3-2; /* VBP-VLW */ - pinfo->lcdc.v_front_porch = 28; - pinfo->lcdc.v_pulse_width = 2; - - pinfo->lcdc.border_clr = 0; - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) { - pr_err("%s: device register failed, rc=%d\n", __func__, ret); - goto fail_driver; - } -#ifdef CONFIG_SPI_QUP - ret = spi_register_driver(&lcdc_auo_spi_driver); - - if (ret) { - pr_err("%s: spi register failed: rc=%d\n", __func__, ret); - goto fail_device; - } - pr_info("%s: SUCCESS (SPI)\n", __func__); -#else - pr_info("%s: SUCCESS (BitBang)\n", __func__); -#endif - return ret; - -#ifdef CONFIG_SPI_QUP -fail_device: - platform_device_unregister(&this_device); -#endif -fail_driver: - platform_driver_unregister(&this_driver); - - return ret; -} - -module_init(lcdc_auo_panel_init); -static void __exit lcdc_auo_panel_exit(void) -{ - pr_info("%s\n", __func__); - platform_device_unregister(&this_device); - platform_driver_unregister(&this_driver); -#ifdef CONFIG_SPI_QUP - spi_unregister_driver(&lcdc_auo_spi_driver); -#endif -} -module_exit(lcdc_auo_panel_exit); diff --git a/drivers/video/msm/lcdc_chimei_wxga.c b/drivers/video/msm/lcdc_chimei_wxga.c deleted file mode 100644 index 20edd9c8c0a0f01daa2b34a9b9203808cd6b5789..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_chimei_wxga.c +++ /dev/null @@ -1,238 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#ifdef CONFIG_PMIC8058_PWM -#include -#include -#endif -#include -#include "msm_fb.h" - - - - -static struct pwm_device *bl_pwm; - -#define PWM_FREQ_HZ 210 -#define PWM_PERIOD_USEC (USEC_PER_SEC / PWM_FREQ_HZ) -#define PWM_DUTY_LEVEL (PWM_PERIOD_USEC / PWM_LEVEL) -#define PWM_LEVEL 15 - -static struct msm_panel_common_pdata *cm_pdata; -static struct platform_device *cm_fbpdev; -static int led_pwm; /* pm8058 gpio 24, channel 0 */ -static int led_en; /* pm8058 gpio 1 */ -static int lvds_pwr_down; /* msm gpio 30 */ -static int chimei_bl_level = 1; -static int is_pwm_enabled; - -static void lcdc_chimei_set_backlight(int level) -{ - int ret; - - if (bl_pwm) { - ret = pwm_config(bl_pwm, PWM_DUTY_LEVEL * level, - PWM_PERIOD_USEC); - if (ret) { - pr_err("%s: pwm_config on pwm failed %d\n", - __func__, ret); - return; - } - - if (is_pwm_enabled) { - pwm_disable(bl_pwm); - is_pwm_enabled = 0; - } - - ret = pwm_enable(bl_pwm); - if (ret) { - pr_err("%s: pwm_enable on pwm failed %d\n", - __func__, ret); - return; - } - - is_pwm_enabled = 1; - } - - chimei_bl_level = level; -} - -static int lcdc_chimei_panel_on(struct platform_device *pdev) -{ - int ret; - - /* panel powered on here */ - - ret = gpio_request(lvds_pwr_down, "lvds_pwr_down"); - if (ret == 0) { - /* output, pull high to enable */ - gpio_direction_output(lvds_pwr_down, 1); - } else { - pr_err("%s: lvds_pwr_down=%d, gpio_request failed\n", - __func__, lvds_pwr_down); - } - - msleep(200); - /* power on led pwm power >= 200 ms */ - - if (chimei_bl_level == 0) - chimei_bl_level = 1; - lcdc_chimei_set_backlight(chimei_bl_level); - - msleep(10); - - ret = gpio_request(led_en, "led_en"); - if (ret == 0) { - /* output, pull high */ - gpio_direction_output(led_en, 1); - } else { - pr_err("%s: led_en=%d, gpio_request failed\n", - __func__, led_en); - } - return ret; -} - -static int lcdc_chimei_panel_off(struct platform_device *pdev) -{ - /* pull low to disable */ - gpio_set_value_cansleep(led_en, 0); - gpio_free(led_en); - - msleep(10); - - lcdc_chimei_set_backlight(0); - - msleep(200); - /* power off led pwm power >= 200 ms */ - - /* pull low to shut down lvds */ - gpio_set_value_cansleep(lvds_pwr_down, 0); - gpio_free(lvds_pwr_down); - - /* panel power off here */ - - return 0; -} - -static void lcdc_chimei_panel_backlight(struct msm_fb_data_type *mfd) -{ - lcdc_chimei_set_backlight(mfd->bl_level); -} - -static int chimei_probe(struct platform_device *pdev) -{ - int rc = 0; - - if (pdev->id == 0) { - cm_pdata = pdev->dev.platform_data; - if (cm_pdata == NULL) { - pr_err("%s: no PWM gpio specified\n", __func__); - return 0; - } - led_pwm = cm_pdata->gpio_num[0]; - led_en = cm_pdata->gpio_num[1]; - lvds_pwr_down = cm_pdata->gpio_num[2]; - pr_info("%s: led_pwm=%d led_en=%d lvds_pwr_down=%d\n", - __func__, led_pwm, led_en, lvds_pwr_down); - return 0; - } - - if (cm_pdata == NULL) - return -ENODEV; - - bl_pwm = pwm_request(led_pwm, "backlight"); - if (bl_pwm == NULL || IS_ERR(bl_pwm)) { - pr_err("%s pwm_request() failed\n", __func__); - bl_pwm = NULL; - } - - cm_fbpdev = msm_fb_add_device(pdev); - if (!cm_fbpdev) { - dev_err(&pdev->dev, "failed to add msm_fb device\n"); - rc = -ENODEV; - goto probe_exit; - } - -probe_exit: - return rc; -} - -static struct platform_driver this_driver = { - .probe = chimei_probe, - .driver = { - .name = "lcdc_chimei_lvds_wxga", - }, -}; - -static struct msm_fb_panel_data chimei_panel_data = { - .on = lcdc_chimei_panel_on, - .off = lcdc_chimei_panel_off, - .set_backlight = lcdc_chimei_panel_backlight, -}; - -static struct platform_device this_device = { - .name = "lcdc_chimei_lvds_wxga", - .id = 1, - .dev = { - .platform_data = &chimei_panel_data, - } -}; - -static int __init lcdc_chimei_lvds_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - if (msm_fb_detect_client("lcdc_chimei_wxga")) - return 0; - - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &chimei_panel_data.panel_info; - pinfo->xres = 1366; - pinfo->yres = 768; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->clk_rate = 69300000; - pinfo->bl_max = PWM_LEVEL; - pinfo->bl_min = 1; - - /* - * this panel is operated by de, - * vsycn and hsync are ignored - */ - pinfo->lcdc.h_back_porch = 108; - pinfo->lcdc.h_front_porch = 0; - pinfo->lcdc.h_pulse_width = 1; - pinfo->lcdc.v_back_porch = 0; - pinfo->lcdc.v_front_porch = 16; - pinfo->lcdc.v_pulse_width = 1; - pinfo->lcdc.border_clr = 0; - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - - return ret; -} - -module_init(lcdc_chimei_lvds_panel_init); diff --git a/drivers/video/msm/lcdc_external.c b/drivers/video/msm/lcdc_external.c deleted file mode 100644 index b699610f51077fda4568a25d8506c69d7a345658..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_external.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2009-2010, 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 "msm_fb.h" - -static int __init lcdc_external_init(void) -{ - int ret; - struct msm_panel_info pinfo; - - if (msm_fb_detect_client("lcdc_external")) - return 0; - - pinfo.xres = 1280; - pinfo.yres = 720; - MSM_FB_SINGLE_MODE_PANEL(&pinfo); - pinfo.type = LCDC_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.fb_num = 2; - pinfo.clk_rate = 74250000; - - pinfo.lcdc.h_back_porch = 124; - pinfo.lcdc.h_front_porch = 110; - pinfo.lcdc.h_pulse_width = 136; - pinfo.lcdc.v_back_porch = 19; - pinfo.lcdc.v_front_porch = 5; - pinfo.lcdc.v_pulse_width = 6; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - - ret = lcdc_device_register(&pinfo); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(lcdc_external_init); diff --git a/drivers/video/msm/lcdc_gordon.c b/drivers/video/msm/lcdc_gordon.c deleted file mode 100644 index 1b6d5f0446372399cf6fdc0c5293f02e5a0dc729..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_gordon.c +++ /dev/null @@ -1,457 +0,0 @@ -/* Copyright (c) 2009-2010, 2012 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 -#include -#include "msm_fb.h" - -/* registers */ -#define GORDON_REG_NOP 0x00 -#define GORDON_REG_IMGCTL1 0x10 -#define GORDON_REG_IMGCTL2 0x11 -#define GORDON_REG_IMGSET1 0x12 -#define GORDON_REG_IMGSET2 0x13 -#define GORDON_REG_IVBP1 0x14 -#define GORDON_REG_IHBP1 0x15 -#define GORDON_REG_IVNUM1 0x16 -#define GORDON_REG_IHNUM1 0x17 -#define GORDON_REG_IVBP2 0x18 -#define GORDON_REG_IHBP2 0x19 -#define GORDON_REG_IVNUM2 0x1A -#define GORDON_REG_IHNUM2 0x1B -#define GORDON_REG_LCDIFCTL1 0x30 -#define GORDON_REG_VALTRAN 0x31 -#define GORDON_REG_AVCTL 0x33 -#define GORDON_REG_LCDIFCTL2 0x34 -#define GORDON_REG_LCDIFCTL3 0x35 -#define GORDON_REG_LCDIFSET1 0x36 -#define GORDON_REG_PCCTL 0x3C -#define GORDON_REG_TPARAM1 0x40 -#define GORDON_REG_TLCDIF1 0x41 -#define GORDON_REG_TSSPB_ST1 0x42 -#define GORDON_REG_TSSPB_ED1 0x43 -#define GORDON_REG_TSCK_ST1 0x44 -#define GORDON_REG_TSCK_WD1 0x45 -#define GORDON_REG_TGSPB_VST1 0x46 -#define GORDON_REG_TGSPB_VED1 0x47 -#define GORDON_REG_TGSPB_CH1 0x48 -#define GORDON_REG_TGCK_ST1 0x49 -#define GORDON_REG_TGCK_ED1 0x4A -#define GORDON_REG_TPCTL_ST1 0x4B -#define GORDON_REG_TPCTL_ED1 0x4C -#define GORDON_REG_TPCHG_ED1 0x4D -#define GORDON_REG_TCOM_CH1 0x4E -#define GORDON_REG_THBP1 0x4F -#define GORDON_REG_TPHCTL1 0x50 -#define GORDON_REG_EVPH1 0x51 -#define GORDON_REG_EVPL1 0x52 -#define GORDON_REG_EVNH1 0x53 -#define GORDON_REG_EVNL1 0x54 -#define GORDON_REG_TBIAS1 0x55 -#define GORDON_REG_TPARAM2 0x56 -#define GORDON_REG_TLCDIF2 0x57 -#define GORDON_REG_TSSPB_ST2 0x58 -#define GORDON_REG_TSSPB_ED2 0x59 -#define GORDON_REG_TSCK_ST2 0x5A -#define GORDON_REG_TSCK_WD2 0x5B -#define GORDON_REG_TGSPB_VST2 0x5C -#define GORDON_REG_TGSPB_VED2 0x5D -#define GORDON_REG_TGSPB_CH2 0x5E -#define GORDON_REG_TGCK_ST2 0x5F -#define GORDON_REG_TGCK_ED2 0x60 -#define GORDON_REG_TPCTL_ST2 0x61 -#define GORDON_REG_TPCTL_ED2 0x62 -#define GORDON_REG_TPCHG_ED2 0x63 -#define GORDON_REG_TCOM_CH2 0x64 -#define GORDON_REG_THBP2 0x65 -#define GORDON_REG_TPHCTL2 0x66 -#define GORDON_REG_POWCTL 0x80 - -static int lcdc_gordon_panel_off(struct platform_device *pdev); - -static int spi_cs; -static int spi_sclk; -static int spi_sdo; -static int spi_sdi; -static int spi_dac; -static int bl_level; -static unsigned char bit_shift[8] = { (1 << 7), /* MSB */ - (1 << 6), - (1 << 5), - (1 << 4), - (1 << 3), - (1 << 2), - (1 << 1), - (1 << 0) /* LSB */ -}; - -struct gordon_state_type{ - boolean disp_initialized; - boolean display_on; - boolean disp_powered_up; -}; - -static struct gordon_state_type gordon_state = { 0 }; -static struct msm_panel_common_pdata *lcdc_gordon_pdata; - -static void serigo(uint16 reg, uint8 data) -{ - unsigned int tx_val = ((0x00FF & reg) << 8) | data; - unsigned char i, val = 0; - - /* Enable the Chip Select */ - gpio_set_value(spi_cs, 1); - udelay(33); - - /* Transmit it in two parts, Higher Byte first, then Lower Byte */ - val = (unsigned char)((tx_val & 0xFF00) >> 8); - - /* Clock should be Low before entering ! */ - for (i = 0; i < 8; i++) { - /* #1: Drive the Data (High or Low) */ - if (val & bit_shift[i]) - gpio_set_value(spi_sdi, 1); - else - gpio_set_value(spi_sdi, 0); - - /* #2: Drive the Clk High and then Low */ - udelay(33); - gpio_set_value(spi_sclk, 1); - udelay(33); - gpio_set_value(spi_sclk, 0); - } - - /* Idle state of SDO (MOSI) is Low */ - gpio_set_value(spi_sdi, 0); - /* ..then Lower Byte */ - val = (uint8) (tx_val & 0x00FF); - /* Before we enter here the Clock should be Low ! */ - - for (i = 0; i < 8; i++) { - /* #1: Drive the Data (High or Low) */ - if (val & bit_shift[i]) - gpio_set_value(spi_sdi, 1); - else - gpio_set_value(spi_sdi, 0); - - /* #2: Drive the Clk High and then Low */ - udelay(33); - - gpio_set_value(spi_sclk, 1); - udelay(33); - gpio_set_value(spi_sclk, 0); - } - - /* Idle state of SDO (MOSI) is Low */ - gpio_set_value(spi_sdi, 0); - - /* Now Disable the Chip Select */ - udelay(33); - gpio_set_value(spi_cs, 0); -} - -static void spi_init(void) -{ - /* Setting the Default GPIO's */ - spi_sclk = *(lcdc_gordon_pdata->gpio_num); - spi_cs = *(lcdc_gordon_pdata->gpio_num + 1); - spi_sdi = *(lcdc_gordon_pdata->gpio_num + 2); - spi_sdo = *(lcdc_gordon_pdata->gpio_num + 3); - - /* Set the output so that we dont disturb the slave device */ - gpio_set_value(spi_sclk, 0); - gpio_set_value(spi_sdi, 0); - - /* Set the Chip Select De-asserted */ - gpio_set_value(spi_cs, 0); - -} - -static void gordon_disp_powerup(void) -{ - if (!gordon_state.disp_powered_up && !gordon_state.display_on) { - /* Reset the hardware first */ - /* Include DAC power up implementation here */ - gordon_state.disp_powered_up = TRUE; - } -} - -static void gordon_init(void) -{ - /* Image interface settings */ - serigo(GORDON_REG_IMGCTL2, 0x00); - serigo(GORDON_REG_IMGSET1, 0x00); - - /* Exchange the RGB signal for J510(Softbank mobile) */ - serigo(GORDON_REG_IMGSET2, 0x12); - serigo(GORDON_REG_LCDIFSET1, 0x00); - - /* Pre-charge settings */ - serigo(GORDON_REG_PCCTL, 0x09); - serigo(GORDON_REG_LCDIFCTL2, 0x7B); - - mdelay(1); -} - -static void gordon_disp_on(void) -{ - if (gordon_state.disp_powered_up && !gordon_state.display_on) { - gordon_init(); - mdelay(20); - /* gordon_dispmode setting */ - serigo(GORDON_REG_TPARAM1, 0x30); - serigo(GORDON_REG_TLCDIF1, 0x00); - serigo(GORDON_REG_TSSPB_ST1, 0x8B); - serigo(GORDON_REG_TSSPB_ED1, 0x93); - serigo(GORDON_REG_TSCK_ST1, 0x88); - serigo(GORDON_REG_TSCK_WD1, 0x00); - serigo(GORDON_REG_TGSPB_VST1, 0x01); - serigo(GORDON_REG_TGSPB_VED1, 0x02); - serigo(GORDON_REG_TGSPB_CH1, 0x5E); - serigo(GORDON_REG_TGCK_ST1, 0x80); - serigo(GORDON_REG_TGCK_ED1, 0x3C); - serigo(GORDON_REG_TPCTL_ST1, 0x50); - serigo(GORDON_REG_TPCTL_ED1, 0x74); - serigo(GORDON_REG_TPCHG_ED1, 0x78); - serigo(GORDON_REG_TCOM_CH1, 0x50); - serigo(GORDON_REG_THBP1, 0x84); - serigo(GORDON_REG_TPHCTL1, 0x00); - serigo(GORDON_REG_EVPH1, 0x70); - serigo(GORDON_REG_EVPL1, 0x64); - serigo(GORDON_REG_EVNH1, 0x56); - serigo(GORDON_REG_EVNL1, 0x48); - serigo(GORDON_REG_TBIAS1, 0x88); - - /* QVGA settings */ - serigo(GORDON_REG_TPARAM2, 0x28); - serigo(GORDON_REG_TLCDIF2, 0x14); - serigo(GORDON_REG_TSSPB_ST2, 0x49); - serigo(GORDON_REG_TSSPB_ED2, 0x4B); - serigo(GORDON_REG_TSCK_ST2, 0x4A); - serigo(GORDON_REG_TSCK_WD2, 0x02); - serigo(GORDON_REG_TGSPB_VST2, 0x02); - serigo(GORDON_REG_TGSPB_VED2, 0x03); - serigo(GORDON_REG_TGSPB_CH2, 0x2F); - serigo(GORDON_REG_TGCK_ST2, 0x40); - serigo(GORDON_REG_TGCK_ED2, 0x1E); - serigo(GORDON_REG_TPCTL_ST2, 0x2C); - serigo(GORDON_REG_TPCTL_ED2, 0x3A); - serigo(GORDON_REG_TPCHG_ED2, 0x3C); - serigo(GORDON_REG_TCOM_CH2, 0x28); - serigo(GORDON_REG_THBP2, 0x4D); - serigo(GORDON_REG_TPHCTL2, 0x1A); - - /* VGA settings */ - serigo(GORDON_REG_IVBP1, 0x02); - serigo(GORDON_REG_IHBP1, 0x90); - serigo(GORDON_REG_IVNUM1, 0xA0); - serigo(GORDON_REG_IHNUM1, 0x78); - - /* QVGA settings */ - serigo(GORDON_REG_IVBP2, 0x02); - serigo(GORDON_REG_IHBP2, 0x48); - serigo(GORDON_REG_IVNUM2, 0x50); - serigo(GORDON_REG_IHNUM2, 0x3C); - - /* Gordon Charge pump settings and ON */ - serigo(GORDON_REG_POWCTL, 0x03); - mdelay(15); - serigo(GORDON_REG_POWCTL, 0x07); - mdelay(15); - - serigo(GORDON_REG_POWCTL, 0x0F); - mdelay(15); - - serigo(GORDON_REG_AVCTL, 0x03); - mdelay(15); - - serigo(GORDON_REG_POWCTL, 0x1F); - mdelay(15); - - serigo(GORDON_REG_POWCTL, 0x5F); - mdelay(15); - - serigo(GORDON_REG_POWCTL, 0x7F); - mdelay(15); - - serigo(GORDON_REG_LCDIFCTL1, 0x02); - mdelay(15); - - serigo(GORDON_REG_IMGCTL1, 0x00); - mdelay(15); - - serigo(GORDON_REG_LCDIFCTL3, 0x00); - mdelay(15); - - serigo(GORDON_REG_VALTRAN, 0x01); - mdelay(15); - - serigo(GORDON_REG_LCDIFCTL1, 0x03); - mdelay(1); - gordon_state.display_on = TRUE; - } -} - -static int lcdc_gordon_panel_on(struct platform_device *pdev) -{ - if (!gordon_state.disp_initialized) { - /* Configure reset GPIO that drives DAC */ - lcdc_gordon_pdata->panel_config_gpio(1); - spi_dac = *(lcdc_gordon_pdata->gpio_num + 4); - gpio_set_value(spi_dac, 0); - udelay(15); - gpio_set_value(spi_dac, 1); - spi_init(); /* LCD needs SPI */ - gordon_disp_powerup(); - gordon_disp_on(); - if (bl_level <= 1) { - /* keep back light OFF */ - serigo(GORDON_REG_LCDIFCTL2, 0x0B); - udelay(15); - serigo(GORDON_REG_VALTRAN, 0x01); - } else { - /* keep back light ON */ - serigo(GORDON_REG_LCDIFCTL2, 0x7B); - udelay(15); - serigo(GORDON_REG_VALTRAN, 0x01); - } - gordon_state.disp_initialized = TRUE; - } - return 0; -} - -static int lcdc_gordon_panel_off(struct platform_device *pdev) -{ - if (gordon_state.disp_powered_up && gordon_state.display_on) { - serigo(GORDON_REG_LCDIFCTL2, 0x7B); - serigo(GORDON_REG_VALTRAN, 0x01); - serigo(GORDON_REG_LCDIFCTL1, 0x02); - serigo(GORDON_REG_LCDIFCTL3, 0x01); - mdelay(20); - serigo(GORDON_REG_VALTRAN, 0x01); - serigo(GORDON_REG_IMGCTL1, 0x01); - serigo(GORDON_REG_LCDIFCTL1, 0x00); - mdelay(20); - - serigo(GORDON_REG_POWCTL, 0x1F); - mdelay(40); - - serigo(GORDON_REG_POWCTL, 0x07); - mdelay(40); - - serigo(GORDON_REG_POWCTL, 0x03); - mdelay(40); - - serigo(GORDON_REG_POWCTL, 0x00); - mdelay(40); - lcdc_gordon_pdata->panel_config_gpio(0); - gordon_state.display_on = FALSE; - gordon_state.disp_initialized = FALSE; - } - return 0; -} - -static void lcdc_gordon_set_backlight(struct msm_fb_data_type *mfd) -{ - bl_level = mfd->bl_level; - - if (gordon_state.disp_initialized) { - if (bl_level <= 1) { - /* keep back light OFF */ - serigo(GORDON_REG_LCDIFCTL2, 0x0B); - udelay(15); - serigo(GORDON_REG_VALTRAN, 0x01); - } else { - /* keep back light ON */ - serigo(GORDON_REG_LCDIFCTL2, 0x7B); - udelay(15); - serigo(GORDON_REG_VALTRAN, 0x01); - } - } -} - -static int gordon_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - lcdc_gordon_pdata = pdev->dev.platform_data; - return 0; - } - msm_fb_add_device(pdev); - return 0; -} - -static struct platform_driver this_driver = { - .probe = gordon_probe, - .driver = { - .name = "lcdc_gordon_vga", - }, -}; - -static struct msm_fb_panel_data gordon_panel_data = { - .on = lcdc_gordon_panel_on, - .off = lcdc_gordon_panel_off, - .set_backlight = lcdc_gordon_set_backlight, -}; - -static struct platform_device this_device = { - .name = "lcdc_gordon_vga", - .id = 1, - .dev = { - .platform_data = &gordon_panel_data, - } -}; - -static int __init lcdc_gordon_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - -#ifdef CONFIG_FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM - if (msm_fb_detect_client("lcdc_gordon_vga")) - return 0; -#endif - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &gordon_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 640; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - pinfo->fb_num = 2; - pinfo->clk_rate = 24500000; - pinfo->bl_max = 4; - pinfo->bl_min = 1; - - pinfo->lcdc.h_back_porch = 84; - pinfo->lcdc.h_front_porch = 33; - pinfo->lcdc.h_pulse_width = 60; - pinfo->lcdc.v_back_porch = 0; - pinfo->lcdc.v_front_porch = 2; - pinfo->lcdc.v_pulse_width = 2; - pinfo->lcdc.border_clr = 0; /* blk */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - - return ret; -} - -module_init(lcdc_gordon_panel_init); diff --git a/drivers/video/msm/lcdc_nt35582_wvga.c b/drivers/video/msm/lcdc_nt35582_wvga.c deleted file mode 100644 index db7fd34dc1d9eb66c43d9806644dba1291d159e8..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_nt35582_wvga.c +++ /dev/null @@ -1,472 +0,0 @@ -/* Copyright (c) 2011, 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. - * - */ - -#define pr_fmt(fmt) "%s: " fmt, __func__ - -#include -#include -#ifdef CONFIG_SPI_QUP -#include -#endif -#include -#include -#include "msm_fb.h" - -#define LCDC_NT35582_PANEL_NAME "lcdc_nt35582_wvga" - -#define WRITE_FIRST_TRANS 0x20 -#define WRITE_SECOND_TRANS 0x00 -#define WRITE_THIRD_TRANS 0x40 -#define READ_FIRST_TRANS 0x20 -#define READ_SECOND_TRANS 0x00 -#define READ_THIRD_TRANS 0xC0 - -#ifdef CONFIG_SPI_QUP -#define LCDC_NT35582_SPI_DEVICE_NAME "lcdc_nt35582_spi" -static struct spi_device *spi_client; -#endif - -struct nt35582_state_type { - boolean display_on; - int bl_level; -}; - -static struct nt35582_state_type nt35582_state = { 0 }; -static int gpio_backlight_en; -static struct msm_panel_common_pdata *lcdc_nt35582_pdata; - -static int spi_write_2bytes(struct spi_device *spi, - unsigned char reg_high_addr, unsigned char reg_low_addr) -{ - char tx_buf[4]; - int rc; - struct spi_message m; - struct spi_transfer t; - - memset(&t, 0, sizeof t); - t.tx_buf = tx_buf; - - spi_setup(spi); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - tx_buf[0] = WRITE_FIRST_TRANS; - tx_buf[1] = reg_high_addr; - tx_buf[2] = WRITE_SECOND_TRANS; - tx_buf[3] = reg_low_addr; - t.rx_buf = NULL; - t.len = 4; - t.bits_per_word = 16; - rc = spi_sync(spi, &m); - if (rc) - pr_err("write spi command failed!\n"); - - return rc; -} - -static int spi_write_3bytes(struct spi_device *spi, unsigned char reg_high_addr, - unsigned char reg_low_addr, unsigned char write_data) -{ - char tx_buf[6]; - int rc; - struct spi_message m; - struct spi_transfer t; - - memset(&t, 0, sizeof t); - t.tx_buf = tx_buf; - - spi_setup(spi); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - tx_buf[0] = WRITE_FIRST_TRANS; - tx_buf[1] = reg_high_addr; - tx_buf[2] = WRITE_SECOND_TRANS; - tx_buf[3] = reg_low_addr; - tx_buf[4] = WRITE_THIRD_TRANS; - tx_buf[5] = write_data; - t.rx_buf = NULL; - t.len = 6; - t.bits_per_word = 16; - rc = spi_sync(spi, &m); - - if (rc) - pr_err("write spi command failed!\n"); - - return rc; -} - -static int spi_read_bytes(struct spi_device *spi, unsigned char reg_high_addr, - unsigned char reg_low_addr, unsigned char *read_value) -{ - char tx_buf[6]; - char rx_buf[6]; - int rc; - struct spi_message m; - struct spi_transfer t; - - memset(&t, 0, sizeof t); - t.tx_buf = tx_buf; - - spi_setup(spi); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - tx_buf[0] = READ_FIRST_TRANS; - tx_buf[1] = reg_high_addr; - tx_buf[2] = READ_SECOND_TRANS; - tx_buf[3] = reg_low_addr; - tx_buf[4] = READ_THIRD_TRANS; - tx_buf[5] = 0x00; - - t.rx_buf = rx_buf; - t.len = 6; - t.bits_per_word = 16; - rc = spi_sync(spi, &m); - - if (rc) - pr_err("write spi command failed!\n"); - else - *read_value = rx_buf[5]; - - return rc; -} - -static void nt35582_disp_on(void) -{ - uint32 panel_id1 = 0, panel_id2 = 0; - - if (!nt35582_state.display_on) { - - /* GVDD setting */ - spi_write_3bytes(spi_client, 0xC0, 0x00, 0xC0); - spi_write_3bytes(spi_client, 0xC0, 0x01, 0x00); - spi_write_3bytes(spi_client, 0xC0, 0x02, 0xC0); - spi_write_3bytes(spi_client, 0xC0, 0x03, 0x00); - /* Power setting */ - spi_write_3bytes(spi_client, 0xC1, 0x00, 0x40); - spi_write_3bytes(spi_client, 0xC2, 0x00, 0x21); - spi_write_3bytes(spi_client, 0xC2, 0x02, 0x02); - - /* Gamma setting */ - spi_write_3bytes(spi_client, 0xE0, 0x00, 0x0E); - spi_write_3bytes(spi_client, 0xE0, 0x01, 0x54); - spi_write_3bytes(spi_client, 0xE0, 0x02, 0x63); - spi_write_3bytes(spi_client, 0xE0, 0x03, 0x76); - spi_write_3bytes(spi_client, 0xE0, 0x04, 0x1F); - spi_write_3bytes(spi_client, 0xE0, 0x05, 0x31); - spi_write_3bytes(spi_client, 0xE0, 0x06, 0x62); - spi_write_3bytes(spi_client, 0xE0, 0x07, 0x78); - spi_write_3bytes(spi_client, 0xE0, 0x08, 0x1F); - spi_write_3bytes(spi_client, 0xE0, 0x09, 0x25); - spi_write_3bytes(spi_client, 0xE0, 0x0A, 0xB3); - spi_write_3bytes(spi_client, 0xE0, 0x0B, 0x17); - spi_write_3bytes(spi_client, 0xE0, 0x0C, 0x38); - spi_write_3bytes(spi_client, 0xE0, 0x0D, 0x5A); - spi_write_3bytes(spi_client, 0xE0, 0x0E, 0xA2); - spi_write_3bytes(spi_client, 0xE0, 0x0F, 0xA2); - spi_write_3bytes(spi_client, 0xE0, 0x10, 0x24); - spi_write_3bytes(spi_client, 0xE0, 0x11, 0x57); - - spi_write_3bytes(spi_client, 0xE1, 0x00, 0x0E); - spi_write_3bytes(spi_client, 0xE1, 0x01, 0x54); - spi_write_3bytes(spi_client, 0xE1, 0x02, 0x63); - spi_write_3bytes(spi_client, 0xE1, 0x03, 0x76); - spi_write_3bytes(spi_client, 0xE1, 0x04, 0x1F); - spi_write_3bytes(spi_client, 0xE1, 0x05, 0x31); - spi_write_3bytes(spi_client, 0xE1, 0x06, 0X62); - spi_write_3bytes(spi_client, 0xE1, 0x07, 0x78); - spi_write_3bytes(spi_client, 0xE1, 0x08, 0x1F); - spi_write_3bytes(spi_client, 0xE1, 0x09, 0x25); - spi_write_3bytes(spi_client, 0xE1, 0x0A, 0xB3); - spi_write_3bytes(spi_client, 0xE1, 0x0B, 0x17); - spi_write_3bytes(spi_client, 0xE1, 0x0C, 0x38); - spi_write_3bytes(spi_client, 0xE1, 0x0D, 0x5A); - spi_write_3bytes(spi_client, 0xE1, 0x0E, 0xA2); - spi_write_3bytes(spi_client, 0xE1, 0x0F, 0xA2); - spi_write_3bytes(spi_client, 0xE1, 0x10, 0x24); - spi_write_3bytes(spi_client, 0xE1, 0x11, 0x57); - - spi_write_3bytes(spi_client, 0xE2, 0x00, 0x0E); - spi_write_3bytes(spi_client, 0xE2, 0x01, 0x54); - spi_write_3bytes(spi_client, 0xE2, 0x02, 0x63); - spi_write_3bytes(spi_client, 0xE2, 0x03, 0x76); - spi_write_3bytes(spi_client, 0xE2, 0x04, 0x1F); - spi_write_3bytes(spi_client, 0xE2, 0x05, 0x31); - spi_write_3bytes(spi_client, 0xE2, 0x06, 0x62); - spi_write_3bytes(spi_client, 0xE2, 0x07, 0x78); - spi_write_3bytes(spi_client, 0xE2, 0x08, 0x1F); - spi_write_3bytes(spi_client, 0xE2, 0x09, 0x25); - spi_write_3bytes(spi_client, 0xE2, 0x0A, 0xB3); - spi_write_3bytes(spi_client, 0xE2, 0x0B, 0x17); - spi_write_3bytes(spi_client, 0xE2, 0x0C, 0x38); - spi_write_3bytes(spi_client, 0xE2, 0x0D, 0x5A); - spi_write_3bytes(spi_client, 0xE2, 0x0E, 0xA2); - spi_write_3bytes(spi_client, 0xE2, 0x0F, 0xA2); - spi_write_3bytes(spi_client, 0xE2, 0x10, 0x24); - spi_write_3bytes(spi_client, 0xE2, 0x11, 0x57); - - spi_write_3bytes(spi_client, 0xE3, 0x00, 0x0E); - spi_write_3bytes(spi_client, 0xE3, 0x01, 0x54); - spi_write_3bytes(spi_client, 0xE3, 0x02, 0x63); - spi_write_3bytes(spi_client, 0xE3, 0x03, 0x76); - spi_write_3bytes(spi_client, 0xE3, 0x04, 0x1F); - spi_write_3bytes(spi_client, 0xE3, 0x05, 0x31); - spi_write_3bytes(spi_client, 0xE3, 0x06, 0x62); - spi_write_3bytes(spi_client, 0xE3, 0x07, 0x78); - spi_write_3bytes(spi_client, 0xE3, 0x08, 0x1F); - spi_write_3bytes(spi_client, 0xE3, 0x09, 0x25); - spi_write_3bytes(spi_client, 0xE3, 0x0A, 0xB3); - spi_write_3bytes(spi_client, 0xE3, 0x0B, 0x17); - spi_write_3bytes(spi_client, 0xE3, 0x0C, 0x38); - spi_write_3bytes(spi_client, 0xE3, 0x0D, 0x5A); - spi_write_3bytes(spi_client, 0xE3, 0x0E, 0xA2); - spi_write_3bytes(spi_client, 0xE3, 0x0F, 0xA2); - spi_write_3bytes(spi_client, 0xE3, 0x10, 0x24); - spi_write_3bytes(spi_client, 0xE3, 0x11, 0x57); - - spi_write_3bytes(spi_client, 0xE4, 0x00, 0x48); - spi_write_3bytes(spi_client, 0xE4, 0x01, 0x6B); - spi_write_3bytes(spi_client, 0xE4, 0x02, 0x84); - spi_write_3bytes(spi_client, 0xE4, 0x03, 0x9B); - spi_write_3bytes(spi_client, 0xE4, 0x04, 0x1F); - spi_write_3bytes(spi_client, 0xE4, 0x05, 0x31); - spi_write_3bytes(spi_client, 0xE4, 0x06, 0x62); - spi_write_3bytes(spi_client, 0xE4, 0x07, 0x78); - spi_write_3bytes(spi_client, 0xE4, 0x08, 0x1F); - spi_write_3bytes(spi_client, 0xE4, 0x09, 0x25); - spi_write_3bytes(spi_client, 0xE4, 0x0A, 0xB3); - spi_write_3bytes(spi_client, 0xE4, 0x0B, 0x17); - spi_write_3bytes(spi_client, 0xE4, 0x0C, 0x38); - spi_write_3bytes(spi_client, 0xE4, 0x0D, 0x5A); - spi_write_3bytes(spi_client, 0xE4, 0x0E, 0xA2); - spi_write_3bytes(spi_client, 0xE4, 0x0F, 0xA2); - spi_write_3bytes(spi_client, 0xE4, 0x10, 0x24); - spi_write_3bytes(spi_client, 0xE4, 0x11, 0x57); - - spi_write_3bytes(spi_client, 0xE5, 0x00, 0x48); - spi_write_3bytes(spi_client, 0xE5, 0x01, 0x6B); - spi_write_3bytes(spi_client, 0xE5, 0x02, 0x84); - spi_write_3bytes(spi_client, 0xE5, 0x03, 0x9B); - spi_write_3bytes(spi_client, 0xE5, 0x04, 0x1F); - spi_write_3bytes(spi_client, 0xE5, 0x05, 0x31); - spi_write_3bytes(spi_client, 0xE5, 0x06, 0x62); - spi_write_3bytes(spi_client, 0xE5, 0x07, 0x78); - spi_write_3bytes(spi_client, 0xE5, 0x08, 0x1F); - spi_write_3bytes(spi_client, 0xE5, 0x09, 0x25); - spi_write_3bytes(spi_client, 0xE5, 0x0A, 0xB3); - spi_write_3bytes(spi_client, 0xE5, 0x0B, 0x17); - spi_write_3bytes(spi_client, 0xE5, 0x0C, 0x38); - spi_write_3bytes(spi_client, 0xE5, 0x0D, 0x5A); - spi_write_3bytes(spi_client, 0xE5, 0x0E, 0xA2); - spi_write_3bytes(spi_client, 0xE5, 0x0F, 0xA2); - spi_write_3bytes(spi_client, 0xE5, 0x10, 0x24); - spi_write_3bytes(spi_client, 0xE5, 0x11, 0x57); - - /* Data format setting */ - spi_write_3bytes(spi_client, 0x3A, 0x00, 0x70); - - /* Reverse PCLK signal of LCM to meet Qualcomm's platform */ - spi_write_3bytes(spi_client, 0x3B, 0x00, 0x2B); - - /* Scan direstion setting */ - spi_write_3bytes(spi_client, 0x36, 0x00, 0x00); - - /* Sleep out */ - spi_write_2bytes(spi_client, 0x11, 0x00); - - msleep(120); - - /* Display on */ - spi_write_2bytes(spi_client, 0x29, 0x00); - - pr_info("%s: LCM SPI display on CMD finished...\n", __func__); - - msleep(200); - - nt35582_state.display_on = TRUE; - } - - /* Test to read RDDID. It should be 0x0055h and 0x0082h */ - spi_read_bytes(spi_client, 0x10, 0x80, (unsigned char *)&panel_id1); - spi_read_bytes(spi_client, 0x11, 0x80, (unsigned char *)&panel_id2); - - pr_info(KERN_INFO "nt35582_disp_on: LCM_ID=[0x%x, 0x%x]\n", - panel_id1, panel_id2); -} - -static int lcdc_nt35582_panel_on(struct platform_device *pdev) -{ - nt35582_disp_on(); - return 0; -} - -static int lcdc_nt35582_panel_off(struct platform_device *pdev) -{ - nt35582_state.display_on = FALSE; - return 0; -} - -static void lcdc_nt35582_set_backlight(struct msm_fb_data_type *mfd) -{ - int bl_level; - int i = 0, step = 0; - - bl_level = mfd->bl_level; - if (bl_level == nt35582_state.bl_level) - return; - else - nt35582_state.bl_level = bl_level; - - if (bl_level == 0) { - gpio_set_value_cansleep(gpio_backlight_en, 0); - return; - } - - /* Level:0~31 mapping to step 32~1 */ - step = 32 - bl_level; - for (i = 0; i < step; i++) { - gpio_set_value_cansleep(gpio_backlight_en, 0); - ndelay(5); - gpio_set_value_cansleep(gpio_backlight_en, 1); - ndelay(5); - } -} - -static int nt35582_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - lcdc_nt35582_pdata = pdev->dev.platform_data; - return 0; - } - - gpio_backlight_en = *(lcdc_nt35582_pdata->gpio_num); - - msm_fb_add_device(pdev); - return 0; -} - -#ifdef CONFIG_SPI_QUP -static int lcdc_nt35582_spi_probe(struct spi_device *spi) -{ - spi_client = spi; - spi_client->bits_per_word = 16; - spi_client->chip_select = 0; - spi_client->max_speed_hz = 1100000; - spi_client->mode = SPI_MODE_0; - spi_setup(spi_client); - - return 0; -} - -static int lcdc_nt35582_spi_remove(struct spi_device *spi) -{ - spi_client = NULL; - return 0; -} - -static struct spi_driver lcdc_nt35582_spi_driver = { - .driver = { - .name = LCDC_NT35582_SPI_DEVICE_NAME, - .owner = THIS_MODULE, - }, - .probe = lcdc_nt35582_spi_probe, - .remove = lcdc_nt35582_spi_remove, -}; -#endif -static struct platform_driver this_driver = { - .probe = nt35582_probe, - .driver = { - .name = LCDC_NT35582_PANEL_NAME, - }, -}; - -static struct msm_fb_panel_data nt35582_panel_data = { - .on = lcdc_nt35582_panel_on, - .off = lcdc_nt35582_panel_off, - .set_backlight = lcdc_nt35582_set_backlight, -}; - -static struct platform_device this_device = { - .name = LCDC_NT35582_PANEL_NAME, - .id = 1, - .dev = { - .platform_data = &nt35582_panel_data, - } -}; - -static int __init lcdc_nt35582_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - -#ifdef CONFIG_FB_MSM_LCDC_AUTO_DETECT - if (msm_fb_detect_client(LCDC_NT35582_PANEL_NAME)) { - pr_err("detect failed\n"); - return 0; - } -#endif - ret = platform_driver_register(&this_driver); - if (ret) { - pr_err("Fails to platform_driver_register...\n"); - return ret; - } - - pinfo = &nt35582_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 800; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - pinfo->fb_num = 2; - pinfo->clk_rate = 25600000; - pinfo->bl_max = 31; - pinfo->bl_min = 1; - - pinfo->lcdc.h_back_porch = 10; /* hsw = 8 + hbp=184 */ - pinfo->lcdc.h_front_porch = 10; - pinfo->lcdc.h_pulse_width = 2; - pinfo->lcdc.v_back_porch = 4; /* vsw=1 + vbp = 2 */ - pinfo->lcdc.v_front_porch = 10; - pinfo->lcdc.v_pulse_width = 2; - pinfo->lcdc.border_clr = 0; /* blk */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) { - pr_err("not able to register the device\n"); - goto fail_driver; - } -#ifdef CONFIG_SPI_QUP - ret = spi_register_driver(&lcdc_nt35582_spi_driver); - - if (ret) { - pr_err("not able to register spi\n"); - goto fail_device; - } -#endif - return ret; - -#ifdef CONFIG_SPI_QUP -fail_device: - platform_device_unregister(&this_device); -#endif -fail_driver: - platform_driver_unregister(&this_driver); - return ret; -} - -device_initcall(lcdc_nt35582_panel_init); diff --git a/drivers/video/msm/lcdc_panel.c b/drivers/video/msm/lcdc_panel.c deleted file mode 100644 index 16d6855e1b2f87d775fc83e34017e83959765c16..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_panel.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2008-2009, 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 "msm_fb.h" - -static int lcdc_panel_on(struct platform_device *pdev) -{ - return 0; -} - -static int lcdc_panel_off(struct platform_device *pdev) -{ - return 0; -} - -static int lcdc_panel_probe(struct platform_device *pdev) -{ - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = lcdc_panel_probe, - .driver = { - .name = "lcdc_panel", - }, -}; - -static struct msm_fb_panel_data lcdc_panel_data = { - .on = lcdc_panel_on, - .off = lcdc_panel_off, -}; - -static int lcdc_dev_id; - -int lcdc_device_register(struct msm_panel_info *pinfo) -{ - struct platform_device *pdev = NULL; - int ret; - - pdev = platform_device_alloc("lcdc_panel", ++lcdc_dev_id); - if (!pdev) - return -ENOMEM; - - lcdc_panel_data.panel_info = *pinfo; - ret = platform_device_add_data(pdev, &lcdc_panel_data, - sizeof(lcdc_panel_data)); - if (ret) { - printk(KERN_ERR - "%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - printk(KERN_ERR - "%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int __init lcdc_panel_init(void) -{ - return platform_driver_register(&this_driver); -} - -module_init(lcdc_panel_init); diff --git a/drivers/video/msm/lcdc_prism.c b/drivers/video/msm/lcdc_prism.c deleted file mode 100644 index fb040ca76890ccc16b3a6263b51bb29052640c86..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_prism.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (c) 2009-2010, 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 "msm_fb.h" - -#ifdef CONFIG_FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM -#include "mddihosti.h" -#endif - -static int __init lcdc_prism_init(void) -{ - int ret; - struct msm_panel_info pinfo; - -#ifdef CONFIG_FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM - ret = msm_fb_detect_client("lcdc_prism_wvga"); - if (ret == -ENODEV) - return 0; - - if (ret && (mddi_get_client_id() != 0)) - return 0; -#endif - - pinfo.xres = 800; - pinfo.yres = 480; - MSM_FB_SINGLE_MODE_PANEL(&pinfo); - pinfo.type = LCDC_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.fb_num = 2; - pinfo.clk_rate = 30720000; - - pinfo.lcdc.h_back_porch = 21; - pinfo.lcdc.h_front_porch = 81; - pinfo.lcdc.h_pulse_width = 60; - pinfo.lcdc.v_back_porch = 18; - pinfo.lcdc.v_front_porch = 27; - pinfo.lcdc.v_pulse_width = 2; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - - ret = lcdc_device_register(&pinfo); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(lcdc_prism_init); diff --git a/drivers/video/msm/lcdc_samsung_oled_pt.c b/drivers/video/msm/lcdc_samsung_oled_pt.c deleted file mode 100644 index 00656ebe70c8907c2f14fb026305af1f41c1e6f4..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_samsung_oled_pt.c +++ /dev/null @@ -1,588 +0,0 @@ -/* Copyright (c) 2009-2010, 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 -#include -#ifdef CONFIG_SPI_QUP -#include -#else -#include -#endif -#include "msm_fb.h" - -#define DEBUG -/* #define SYSFS_DEBUG_CMD */ - -#ifdef CONFIG_SPI_QUP -#define LCDC_SAMSUNG_SPI_DEVICE_NAME "lcdc_samsung_ams367pe02" -static struct spi_device *lcdc_spi_client; -#else -static int spi_cs; -static int spi_sclk; -static int spi_mosi; -#endif - -struct samsung_state_type { - boolean disp_initialized; - boolean display_on; - boolean disp_powered_up; - int brightness; -}; - -struct samsung_spi_data { - u8 addr; - u8 len; - u8 data[22]; -}; - -static struct samsung_spi_data panel_sequence[] = { - { .addr = 0xf8, .len = 14, .data = { 0x01, 0x27, 0x27, 0x07, 0x07, - 0x54, 0x9f, 0x63, 0x86, 0x1a, 0x33, 0x0d, 0x00, 0x00 } }, -}; -static struct samsung_spi_data display_sequence[] = { - { .addr = 0xf2, .len = 5, .data = { 0x02, 0x03, 0x1c, 0x10, 0x10 } }, - { .addr = 0xf7, .len = 3, .data = { 0x00, 0x00, 0x30 } }, -}; - -/* lum=300 cd/m2 */ -static struct samsung_spi_data gamma_sequence_300[] = { - { .addr = 0xfa, .len = 22, .data = { 0x02, 0x18, 0x08, 0x24, 0x7d, 0x77, - 0x5b, 0xbe, 0xc1, 0xb1, 0xb3, 0xb7, 0xa6, 0xc3, 0xc5, 0xb9, 0x00, 0xb3, - 0x00, 0xaf, 0x00, 0xe8 } }, - { .addr = 0xFA, .len = 1, .data = { 0x03 } }, -}; -/* lum = 180 cd/m2*/ -static struct samsung_spi_data gamma_sequence_180[] = { - { .addr = 0xfa, .len = 22, .data = { 0x02, 0x18, 0x08, 0x24, 0x83, 0x78, - 0x60, 0xc5, 0xc6, 0xb8, 0xba, 0xbe, 0xad, 0xcb, 0xcd, 0xc2, 0x00, 0x92, - 0x00, 0x8e, 0x00, 0xbc } }, - { .addr = 0xFA, .len = 1, .data = { 0x03 } }, -}; -/* lum = 80 cd/m2*/ -static struct samsung_spi_data gamma_sequence_80[] = { - { .addr = 0xfa, .len = 22, .data = { 0x02, 0x18, 0x08, 0x24, 0x94, 0x73, - 0x6c, 0xcb, 0xca, 0xbe, 0xc4, 0xc7, 0xb8, 0xd3, 0xd5, 0xcb, 0x00, 0x6d, - 0x00, 0x69, 0x00, 0x8b } }, - { .addr = 0xFA, .len = 1, .data = { 0x03 } }, -}; - -static struct samsung_spi_data etc_sequence[] = { - { .addr = 0xF6, .len = 3, .data = { 0x00, 0x8e, 0x07 } }, - { .addr = 0xB3, .len = 1, .data = { 0x0C } }, -}; - -static struct samsung_state_type samsung_state = { .brightness = 180 }; -static struct msm_panel_common_pdata *lcdc_samsung_pdata; - -#ifndef CONFIG_SPI_QUP -static void samsung_spi_write_byte(boolean dc, u8 data) -{ - uint32 bit; - int bnum; - - gpio_set_value(spi_sclk, 0); - gpio_set_value(spi_mosi, dc ? 1 : 0); - udelay(1); /* at least 20 ns */ - gpio_set_value(spi_sclk, 1); /* clk high */ - udelay(1); /* at least 20 ns */ - - bnum = 8; /* 8 data bits */ - bit = 0x80; - while (bnum--) { - gpio_set_value(spi_sclk, 0); /* clk low */ - gpio_set_value(spi_mosi, (data & bit) ? 1 : 0); - udelay(1); - gpio_set_value(spi_sclk, 1); /* clk high */ - udelay(1); - bit >>= 1; - } - gpio_set_value(spi_mosi, 0); - -} - -static void samsung_spi_read_bytes(u8 cmd, u8 *data, int num) -{ - int bnum; - - /* Chip Select - low */ - gpio_set_value(spi_cs, 0); - udelay(2); - - /* command byte first */ - samsung_spi_write_byte(0, cmd); - udelay(2); - - gpio_direction_input(spi_mosi); - - if (num > 1) { - /* extra dummy clock */ - gpio_set_value(spi_sclk, 0); - udelay(1); - gpio_set_value(spi_sclk, 1); - udelay(1); - } - - /* followed by data bytes */ - bnum = num * 8; /* number of bits */ - *data = 0; - while (bnum) { - gpio_set_value(spi_sclk, 0); /* clk low */ - udelay(1); - *data <<= 1; - *data |= gpio_get_value(spi_mosi) ? 1 : 0; - gpio_set_value(spi_sclk, 1); /* clk high */ - udelay(1); - --bnum; - if ((bnum % 8) == 0) - ++data; - } - - gpio_direction_output(spi_mosi, 0); - - /* Chip Select - high */ - udelay(2); - gpio_set_value(spi_cs, 1); -} -#endif - -#ifdef DEBUG -static const char *byte_to_binary(const u8 *buf, int len) -{ - static char b[32*8+1]; - char *p = b; - int i, z; - - for (i = 0; i < len; ++i) { - u8 val = *buf++; - for (z = 1 << 7; z > 0; z >>= 1) - *p++ = (val & z) ? '1' : '0'; - } - *p = 0; - - return b; -} -#endif - -#define BIT_OFFSET (bit_size % 8) -#define ADD_BIT(val) do { \ - tx_buf[bit_size / 8] |= \ - (u8)((val ? 1 : 0) << (7 - BIT_OFFSET)); \ - ++bit_size; \ - } while (0) - -#define ADD_BYTE(data) do { \ - tx_buf[bit_size / 8] |= (u8)(data >> BIT_OFFSET); \ - bit_size += 8; \ - if (BIT_OFFSET != 0) \ - tx_buf[bit_size / 8] |= (u8)(data << (8 - BIT_OFFSET));\ - } while (0) - -static int samsung_serigo(struct samsung_spi_data data) -{ -#ifdef CONFIG_SPI_QUP - char tx_buf[32]; - int bit_size = 0, i, rc; - struct spi_message m; - struct spi_transfer t; - - if (!lcdc_spi_client) { - pr_err("%s lcdc_spi_client is NULL\n", __func__); - return -EINVAL; - } - - memset(&t, 0, sizeof t); - memset(tx_buf, 0, sizeof tx_buf); - t.tx_buf = tx_buf; - spi_setup(lcdc_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - ADD_BIT(FALSE); - ADD_BYTE(data.addr); - for (i = 0; i < data.len; ++i) { - ADD_BIT(TRUE); - ADD_BYTE(data.data[i]); - } - - /* add padding bits so we round to next byte */ - t.len = (bit_size+7) / 8; - if (t.len <= 4) - t.bits_per_word = bit_size; - - rc = spi_sync(lcdc_spi_client, &m); -#ifdef DEBUG - pr_info("%s: addr=0x%02x, #args=%d[%d] [%s], rc=%d\n", - __func__, data.addr, t.len, t.bits_per_word, - byte_to_binary(tx_buf, t.len), rc); -#endif - return rc; -#else - int i; - - /* Chip Select - low */ - gpio_set_value(spi_cs, 0); - udelay(2); - - samsung_spi_write_byte(FALSE, data.addr); - udelay(2); - - for (i = 0; i < data.len; ++i) { - samsung_spi_write_byte(TRUE, data.data[i]); - udelay(2); - } - - /* Chip Select - high */ - gpio_set_value(spi_cs, 1); -#ifdef DEBUG - pr_info("%s: cmd=0x%02x, #args=%d\n", __func__, data.addr, data.len); -#endif - return 0; -#endif -} - -static int samsung_write_cmd(u8 cmd) -{ -#ifdef CONFIG_SPI_QUP - char tx_buf[2]; - int bit_size = 0, rc; - struct spi_message m; - struct spi_transfer t; - - if (!lcdc_spi_client) { - pr_err("%s lcdc_spi_client is NULL\n", __func__); - return -EINVAL; - } - - memset(&t, 0, sizeof t); - memset(tx_buf, 0, sizeof tx_buf); - t.tx_buf = tx_buf; - spi_setup(lcdc_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - ADD_BIT(FALSE); - ADD_BYTE(cmd); - - t.len = 2; - t.bits_per_word = 9; - - rc = spi_sync(lcdc_spi_client, &m); -#ifdef DEBUG - pr_info("%s: addr=0x%02x, #args=%d[%d] [%s], rc=%d\n", - __func__, cmd, t.len, t.bits_per_word, - byte_to_binary(tx_buf, t.len), rc); -#endif - return rc; -#else - /* Chip Select - low */ - gpio_set_value(spi_cs, 0); - udelay(2); - - samsung_spi_write_byte(FALSE, cmd); - - /* Chip Select - high */ - udelay(2); - gpio_set_value(spi_cs, 1); -#ifdef DEBUG - pr_info("%s: cmd=0x%02x\n", __func__, cmd); -#endif - return 0; -#endif -} - -static int samsung_serigo_list(struct samsung_spi_data *data, int count) -{ - int i, rc; - for (i = 0; i < count; ++i, ++data) { - rc = samsung_serigo(*data); - if (rc) - return rc; - msleep(10); - } - return 0; -} - -#ifndef CONFIG_SPI_QUP -static void samsung_spi_init(void) -{ - spi_sclk = *(lcdc_samsung_pdata->gpio_num); - spi_cs = *(lcdc_samsung_pdata->gpio_num + 1); - spi_mosi = *(lcdc_samsung_pdata->gpio_num + 2); - - /* Set the output so that we don't disturb the slave device */ - gpio_set_value(spi_sclk, 1); - gpio_set_value(spi_mosi, 0); - - /* Set the Chip Select deasserted (active low) */ - gpio_set_value(spi_cs, 1); -} -#endif - -static void samsung_disp_powerup(void) -{ - if (!samsung_state.disp_powered_up && !samsung_state.display_on) - samsung_state.disp_powered_up = TRUE; -} - -static struct work_struct disp_on_delayed_work; -static void samsung_disp_on_delayed_work(struct work_struct *work_ptr) -{ - /* 0x01: Software Reset */ - samsung_write_cmd(0x01); - msleep(120); - - msleep(300); - samsung_serigo_list(panel_sequence, - sizeof(panel_sequence)/sizeof(*panel_sequence)); - samsung_serigo_list(display_sequence, - sizeof(display_sequence)/sizeof(*display_sequence)); - - switch (samsung_state.brightness) { - case 300: - samsung_serigo_list(gamma_sequence_300, - sizeof(gamma_sequence_300)/sizeof(*gamma_sequence_300)); - break; - case 180: - default: - samsung_serigo_list(gamma_sequence_180, - sizeof(gamma_sequence_180)/sizeof(*gamma_sequence_180)); - break; - case 80: - samsung_serigo_list(gamma_sequence_80, - sizeof(gamma_sequence_80)/sizeof(*gamma_sequence_80)); - break; - } - - samsung_serigo_list(etc_sequence, - sizeof(etc_sequence)/sizeof(*etc_sequence)); - - /* 0x11: Sleep Out */ - samsung_write_cmd(0x11); - msleep(120); - /* 0x13: Normal Mode On */ - samsung_write_cmd(0x13); - -#ifndef CONFIG_SPI_QUP - { - u8 data; - - msleep(120); - /* 0x0A: Read Display Power Mode */ - samsung_spi_read_bytes(0x0A, &data, 1); - pr_info("%s: power=[%s]\n", __func__, - byte_to_binary(&data, 1)); - - msleep(120); - /* 0x0C: Read Display Pixel Format */ - samsung_spi_read_bytes(0x0C, &data, 1); - pr_info("%s: pixel-format=[%s]\n", __func__, - byte_to_binary(&data, 1)); - } -#endif - msleep(120); - /* 0x29: Display On */ - samsung_write_cmd(0x29); -} - -static void samsung_disp_on(void) -{ - if (samsung_state.disp_powered_up && !samsung_state.display_on) { - INIT_WORK(&disp_on_delayed_work, samsung_disp_on_delayed_work); - schedule_work(&disp_on_delayed_work); - - samsung_state.display_on = TRUE; - } -} - -static int lcdc_samsung_panel_on(struct platform_device *pdev) -{ - pr_info("%s\n", __func__); - if (!samsung_state.disp_initialized) { -#ifndef CONFIG_SPI_QUP - lcdc_samsung_pdata->panel_config_gpio(1); - samsung_spi_init(); -#endif - samsung_disp_powerup(); - samsung_disp_on(); - samsung_state.disp_initialized = TRUE; - } - return 0; -} - -static int lcdc_samsung_panel_off(struct platform_device *pdev) -{ - pr_info("%s\n", __func__); - if (samsung_state.disp_powered_up && samsung_state.display_on) { - /* 0x10: Sleep In */ - samsung_write_cmd(0x10); - msleep(120); - - samsung_state.display_on = FALSE; - samsung_state.disp_initialized = FALSE; - } - return 0; -} - -#ifdef SYSFS_DEBUG_CMD -static ssize_t samsung_rda_cmd(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = snprintf(buf, PAGE_SIZE, "n/a\n"); - pr_info("%s: 'n/a'\n", __func__); - return ret; -} - -static ssize_t samsung_wta_cmd(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - uint32 cmd; - - sscanf(buf, "%x", &cmd); - samsung_write_cmd((u8)cmd); - - return ret; -} - -static DEVICE_ATTR(cmd, S_IRUGO | S_IWUGO, samsung_rda_cmd, samsung_wta_cmd); -static struct attribute *fs_attrs[] = { - &dev_attr_cmd.attr, - NULL, -}; -static struct attribute_group fs_attr_group = { - .attrs = fs_attrs, -}; -#endif - -static struct msm_fb_panel_data samsung_panel_data = { - .on = lcdc_samsung_panel_on, - .off = lcdc_samsung_panel_off, -}; - -static int samsung_probe(struct platform_device *pdev) -{ - struct msm_panel_info *pinfo; -#ifdef SYSFS_DEBUG_CMD - struct platform_device *fb_dev; - struct msm_fb_data_type *mfd; - int rc; -#endif - - pr_info("%s: id=%d\n", __func__, pdev->id); - lcdc_samsung_pdata = pdev->dev.platform_data; - - pinfo = &samsung_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 800; - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - pinfo->fb_num = 2; - pinfo->clk_rate = 25600000; /* Max 27.77MHz */ - pinfo->bl_max = 15; - pinfo->bl_min = 1; - - /* AMS367PE02 Operation Manual, Page 7 */ - pinfo->lcdc.h_back_porch = 16-2; /* HBP-HLW */ - pinfo->lcdc.h_front_porch = 16; - pinfo->lcdc.h_pulse_width = 2; - /* AMS367PE02 Operation Manual, Page 6 */ - pinfo->lcdc.v_back_porch = 3-2; /* VBP-VLW */ - pinfo->lcdc.v_front_porch = 28; - pinfo->lcdc.v_pulse_width = 2; - - pinfo->lcdc.border_clr = 0; - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; - pdev->dev.platform_data = &samsung_panel_data; - -#ifndef SYSFS_DEBUG_CMD - msm_fb_add_device(pdev); -#else - fb_dev = msm_fb_add_device(pdev); - mfd = platform_get_drvdata(fb_dev); - rc = sysfs_create_group(&mfd->fbi->dev->kobj, &fs_attr_group); - if (rc) { - pr_err("%s: sysfs group creation failed, rc=%d\n", __func__, - rc); - return rc; - } -#endif - return 0; -} - -#ifdef CONFIG_SPI_QUP -static int lcdc_samsung_spi_probe(struct spi_device *spi) -{ - pr_info("%s\n", __func__); - lcdc_spi_client = spi; - lcdc_spi_client->bits_per_word = 32; - return 0; -} -static int lcdc_samsung_spi_remove(struct spi_device *spi) -{ - lcdc_spi_client = NULL; - return 0; -} -static struct spi_driver lcdc_samsung_spi_driver = { - .driver.name = LCDC_SAMSUNG_SPI_DEVICE_NAME, - .driver.owner = THIS_MODULE, - .probe = lcdc_samsung_spi_probe, - .remove = lcdc_samsung_spi_remove, -}; -#endif - -static struct platform_driver this_driver = { - .probe = samsung_probe, - .driver.name = "lcdc_samsung_oled", -}; - -static int __init lcdc_samsung_panel_init(void) -{ - int ret; - - if (msm_fb_detect_client("lcdc_samsung_oled")) { - pr_err("%s: detect failed\n", __func__); - return 0; - } - - ret = platform_driver_register(&this_driver); - if (ret) { - pr_err("%s: driver register failed, rc=%d\n", __func__, ret); - return ret; - } - -#ifdef CONFIG_SPI_QUP - ret = spi_register_driver(&lcdc_samsung_spi_driver); - - if (ret) { - pr_err("%s: spi register failed: rc=%d\n", __func__, ret); - platform_driver_unregister(&this_driver); - } else - pr_info("%s: SUCCESS (SPI)\n", __func__); -#else - pr_info("%s: SUCCESS (BitBang)\n", __func__); -#endif - return ret; -} - -module_init(lcdc_samsung_panel_init); -static void __exit lcdc_samsung_panel_exit(void) -{ - pr_info("%s\n", __func__); -#ifdef CONFIG_SPI_QUP - spi_unregister_driver(&lcdc_samsung_spi_driver); -#endif - platform_driver_unregister(&this_driver); -} -module_exit(lcdc_samsung_panel_exit); diff --git a/drivers/video/msm/lcdc_samsung_wsvga.c b/drivers/video/msm/lcdc_samsung_wsvga.c deleted file mode 100644 index f287283c8446347b64abbc480e3f7583893b1765..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_samsung_wsvga.c +++ /dev/null @@ -1,286 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#ifdef CONFIG_PMIC8058_PWM -#include -#include -#endif -#include -#include "msm_fb.h" - - - -#ifdef CONFIG_PMIC8058_PWM -static struct pwm_device *bl_pwm0; -static struct pwm_device *bl_pwm1; -static int is_pwm0_enabled; -static int is_pwm1_enabled; - -/* for samsung panel 300hz was the minimum freq where flickering wasnt - * observed as the screen was dimmed - */ - -#define PWM_FREQ_HZ 300 -#define PWM_PERIOD_USEC (USEC_PER_SEC / PWM_FREQ_HZ) -#define PWM_LEVEL 100 -#define PWM_DUTY_LEVEL (PWM_PERIOD_USEC / PWM_LEVEL) -#endif - -struct lcdc_samsung_data { - struct msm_panel_common_pdata *pdata; -#ifdef CONFIG_FB_MSM_LCDC_DSUB - int vga_enabled; -#endif - struct platform_device *fbpdev; -}; - -static struct lcdc_samsung_data *dd; - - -static void lcdc_samsung_panel_set_backlight(struct msm_fb_data_type *mfd) -{ -#ifdef CONFIG_PMIC8058_PWM - int bl_level; - int ret; - - bl_level = mfd->bl_level; - - if (bl_pwm0) { - ret = pwm_config(bl_pwm0, PWM_DUTY_LEVEL * bl_level, - PWM_PERIOD_USEC); - if (ret) - printk(KERN_ERR "pwm_config on pwm 0 failed %d\n", ret); - } - - if (bl_pwm1) { - ret = pwm_config(bl_pwm1, - PWM_PERIOD_USEC - (PWM_DUTY_LEVEL * bl_level), - PWM_PERIOD_USEC); - if (ret) - printk(KERN_ERR "pwm_config on pwm 1 failed %d\n", ret); - } - - if (bl_pwm0) { - if (is_pwm0_enabled) { - pwm_disable(bl_pwm0); - is_pwm0_enabled = 0; - } - - ret = pwm_enable(bl_pwm0); - if (ret) - printk(KERN_ERR "pwm_enable on pwm 0 failed %d\n", ret); - else - is_pwm0_enabled = 1; - } - - if (bl_pwm1) { - if (is_pwm1_enabled) { - pwm_disable(bl_pwm1); - is_pwm1_enabled = 0; - } - - ret = pwm_enable(bl_pwm1); - if (ret) - printk(KERN_ERR "pwm_enable on pwm 1 failed %d\n", ret); - else - is_pwm1_enabled = 1; - } -#endif - -} - -#ifdef CONFIG_FB_MSM_LCDC_DSUB -static ssize_t show_vga_enable(struct device *device, - struct device_attribute *attr, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%d\n", dd->vga_enabled); -} - -static ssize_t store_vga_enable(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - unsigned long enable; - int rc; - - rc = strict_strtoul(buf, 10, &enable); - if (rc) - return -EINVAL; - - if (dd->pdata && dd->pdata->vga_switch) - rc = dd->pdata->vga_switch(enable); - else - rc = -ENODEV; - if (!rc) { - dd->vga_enabled = enable; - rc = count; - } - return rc; -} - -static DEVICE_ATTR(vga_enable, S_IRUGO|S_IWUSR, show_vga_enable, - store_vga_enable); -static struct attribute *attrs[] = { - &dev_attr_vga_enable.attr, - NULL, -}; -static struct attribute_group attr_group = { - .attrs = attrs, -}; -#endif - -static int samsung_probe(struct platform_device *pdev) -{ - int rc = 0; -#ifdef CONFIG_FB_MSM_LCDC_DSUB - struct msm_fb_data_type *mfd; -#endif - - if (pdev->id == 0) { - dd = kzalloc(sizeof *dd, GFP_KERNEL); - if (!dd) - return -ENOMEM; -#ifdef CONFIG_FB_MSM_LCDC_DSUB - dd->vga_enabled = 0; -#endif - dd->pdata = pdev->dev.platform_data; - return 0; - } else if (!dd) - return -ENODEV; - -#ifdef CONFIG_PMIC8058_PWM - bl_pwm0 = pwm_request(dd->pdata->gpio_num[0], "backlight1"); - if (bl_pwm0 == NULL || IS_ERR(bl_pwm0)) { - pr_err("%s pwm_request() failed\n", __func__); - bl_pwm0 = NULL; - } - - bl_pwm1 = pwm_request(dd->pdata->gpio_num[1], "backlight2"); - if (bl_pwm1 == NULL || IS_ERR(bl_pwm1)) { - pr_err("%s pwm_request() failed\n", __func__); - bl_pwm1 = NULL; - } - - pr_debug("samsung_probe: bl_pwm0=%p LPG_chan0=%d " - "bl_pwm1=%p LPG_chan1=%d\n", - bl_pwm0, (int)dd->pdata->gpio_num[0], - bl_pwm1, (int)dd->pdata->gpio_num[1] - ); -#endif - - - dd->fbpdev = msm_fb_add_device(pdev); - if (!dd->fbpdev) { - dev_err(&pdev->dev, "failed to add msm_fb device\n"); - rc = -ENODEV; - goto probe_exit; - } - -#ifdef CONFIG_FB_MSM_LCDC_DSUB - mfd = platform_get_drvdata(dd->fbpdev); - if (mfd && mfd->fbi && mfd->fbi->dev) { - rc = sysfs_create_group(&mfd->fbi->dev->kobj, &attr_group); - if (rc) - dev_err(&pdev->dev, "failed to create sysfs group\n"); - } else { - dev_err(&pdev->dev, "no dev to create sysfs group\n"); - rc = -ENODEV; - } -#endif - -probe_exit: - return rc; -} - -#ifdef CONFIG_FB_MSM_LCDC_DSUB -static int samsung_remove(struct platform_device *pdev) -{ - sysfs_remove_group(&dd->fbpdev->dev.kobj, &attr_group); - return 0; -} -#endif - -static struct platform_driver this_driver = { - .probe = samsung_probe, -#ifdef CONFIG_FB_MSM_LCDC_DSUB - .remove = samsung_remove, -#endif - .driver = { - .name = "lcdc_samsung_wsvga", - }, -}; - -static struct msm_fb_panel_data samsung_panel_data = { - .set_backlight = lcdc_samsung_panel_set_backlight, -}; - -static struct platform_device this_device = { - .name = "lcdc_samsung_wsvga", - .id = 1, - .dev = { - .platform_data = &samsung_panel_data, - } -}; - -static int __init lcdc_samsung_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - if (msm_fb_detect_client("lcdc_samsung_wsvga")) - return 0; - - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &samsung_panel_data.panel_info; - pinfo->xres = 1024; - pinfo->yres = 600; -#ifdef CONFIG_FB_MSM_LCDC_DSUB - /* DSUB (VGA) is on the same bus, this allows us to allocate for the - * max resolution of the DSUB display */ - pinfo->mode2_xres = 1440; - pinfo->mode2_yres = 900; - pinfo->mode2_bpp = 16; -#else - MSM_FB_SINGLE_MODE_PANEL(pinfo); -#endif - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->clk_rate = 43192000; - pinfo->bl_max = PWM_LEVEL; - pinfo->bl_min = 1; - - pinfo->lcdc.h_back_porch = 80; - pinfo->lcdc.h_front_porch = 48; - pinfo->lcdc.h_pulse_width = 32; - pinfo->lcdc.v_back_porch = 4; - pinfo->lcdc.v_front_porch = 3; - pinfo->lcdc.v_pulse_width = 1; - pinfo->lcdc.border_clr = 0; - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - - return ret; -} - -module_init(lcdc_samsung_panel_init); diff --git a/drivers/video/msm/lcdc_sharp_wvga_pt.c b/drivers/video/msm/lcdc_sharp_wvga_pt.c deleted file mode 100644 index 58aaa8d7e649fa50332cb37fd769e2a3c89898ea..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_sharp_wvga_pt.c +++ /dev/null @@ -1,422 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#ifdef CONFIG_PMIC8058_PWM -#include -#include -#endif -#ifdef CONFIG_SPI_QSD -#include -#endif -#include -#include "msm_fb.h" - -#ifdef CONFIG_SPI_QSD -#define LCDC_SHARP_SPI_DEVICE_NAME "lcdc_sharp_ls038y7dx01" -static struct spi_device *lcdc_spi_client; -#endif -static int lcdc_sharp_panel_off(struct platform_device *pdev); - -#define BL_MAX 16 - -#ifdef CONFIG_PMIC8058_PWM -static struct pwm_device *bl_pwm; - -#define PWM_PERIOD 1000 /* us, period of 1Khz */ -#define DUTY_LEVEL (PWM_PERIOD / BL_MAX) -#endif - -#ifndef CONFIG_SPI_QSD -static int spi_cs; -static int spi_sclk; -static int spi_mosi; -static int spi_miso; -static unsigned char bit_shift[8] = { (1 << 7), /* MSB */ - (1 << 6), - (1 << 5), - (1 << 4), - (1 << 3), - (1 << 2), - (1 << 1), - (1 << 0) /* LSB */ -}; -#endif - -struct sharp_state_type { - boolean disp_initialized; - boolean display_on; - boolean disp_powered_up; -}; - -struct sharp_spi_data { - u8 addr; - u8 data; -}; - -static struct sharp_spi_data init_sequence[] = { - { 15, 0x01 }, - { 5, 0x01 }, - { 7, 0x10 }, - { 9, 0x1E }, - { 10, 0x04 }, - { 17, 0xFF }, - { 21, 0x8A }, - { 22, 0x00 }, - { 23, 0x82 }, - { 24, 0x24 }, - { 25, 0x22 }, - { 26, 0x6D }, - { 27, 0xEB }, - { 28, 0xB9 }, - { 29, 0x3A }, - { 49, 0x1A }, - { 50, 0x16 }, - { 51, 0x05 }, - { 55, 0x7F }, - { 56, 0x15 }, - { 57, 0x7B }, - { 60, 0x05 }, - { 61, 0x0C }, - { 62, 0x80 }, - { 63, 0x00 }, - { 92, 0x90 }, - { 97, 0x01 }, - { 98, 0xFF }, - { 113, 0x11 }, - { 114, 0x02 }, - { 115, 0x08 }, - { 123, 0xAB }, - { 124, 0x04 }, - { 6, 0x02 }, - { 133, 0x00 }, - { 134, 0xFE }, - { 135, 0x22 }, - { 136, 0x0B }, - { 137, 0xFF }, - { 138, 0x0F }, - { 139, 0x00 }, - { 140, 0xFE }, - { 141, 0x22 }, - { 142, 0x0B }, - { 143, 0xFF }, - { 144, 0x0F }, - { 145, 0x00 }, - { 146, 0xFE }, - { 147, 0x22 }, - { 148, 0x0B }, - { 149, 0xFF }, - { 150, 0x0F }, - { 202, 0x30 }, - { 30, 0x01 }, - { 4, 0x01 }, - { 31, 0x41 }, -}; - -static struct sharp_state_type sharp_state = { 0 }; -static struct msm_panel_common_pdata *lcdc_sharp_pdata; - -#ifndef CONFIG_SPI_QSD -static void sharp_spi_write_byte(u8 val) -{ - int i; - - /* Clock should be Low before entering */ - for (i = 0; i < 8; i++) { - /* #1: Drive the Data (High or Low) */ - if (val & bit_shift[i]) - gpio_set_value(spi_mosi, 1); - else - gpio_set_value(spi_mosi, 0); - - /* #2: Drive the Clk High and then Low */ - gpio_set_value(spi_sclk, 1); - gpio_set_value(spi_sclk, 0); - } -} -#endif - -static int serigo(u8 reg, u8 data) -{ -#ifdef CONFIG_SPI_QSD - char tx_buf[2]; - int rc; - struct spi_message m; - struct spi_transfer t; - - if (!lcdc_spi_client) { - printk(KERN_ERR "%s lcdc_spi_client is NULL\n", __func__); - return -EINVAL; - } - - memset(&t, 0, sizeof t); - t.tx_buf = tx_buf; - spi_setup(lcdc_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - tx_buf[0] = reg; - tx_buf[1] = data; - t.rx_buf = NULL; - t.len = 2; - rc = spi_sync(lcdc_spi_client, &m); - return rc; -#else - /* Enable the Chip Select - low */ - gpio_set_value(spi_cs, 0); - udelay(1); - - /* Transmit register address first, then data */ - sharp_spi_write_byte(reg); - - /* Idle state of MOSI is Low */ - gpio_set_value(spi_mosi, 0); - udelay(1); - sharp_spi_write_byte(data); - - gpio_set_value(spi_mosi, 0); - gpio_set_value(spi_cs, 1); - return 0; -#endif -} - -#ifndef CONFIG_SPI_QSD -static void sharp_spi_init(void) -{ - spi_sclk = *(lcdc_sharp_pdata->gpio_num); - spi_cs = *(lcdc_sharp_pdata->gpio_num + 1); - spi_mosi = *(lcdc_sharp_pdata->gpio_num + 2); - spi_miso = *(lcdc_sharp_pdata->gpio_num + 3); - - /* Set the output so that we don't disturb the slave device */ - gpio_set_value(spi_sclk, 0); - gpio_set_value(spi_mosi, 0); - - /* Set the Chip Select deasserted (active low) */ - gpio_set_value(spi_cs, 1); -} -#endif - -static void sharp_disp_powerup(void) -{ - if (!sharp_state.disp_powered_up && !sharp_state.display_on) - sharp_state.disp_powered_up = TRUE; -} - -static void sharp_disp_on(void) -{ - int i; - - if (sharp_state.disp_powered_up && !sharp_state.display_on) { - for (i = 0; i < ARRAY_SIZE(init_sequence); i++) { - serigo(init_sequence[i].addr, - init_sequence[i].data); - } - mdelay(10); - serigo(31, 0xC1); - mdelay(10); - serigo(31, 0xD9); - serigo(31, 0xDF); - - sharp_state.display_on = TRUE; - } -} - -static int lcdc_sharp_panel_on(struct platform_device *pdev) -{ - if (!sharp_state.disp_initialized) { -#ifndef CONFIG_SPI_QSD - lcdc_sharp_pdata->panel_config_gpio(1); - sharp_spi_init(); -#endif - sharp_disp_powerup(); - sharp_disp_on(); - sharp_state.disp_initialized = TRUE; - } - return 0; -} - -static int lcdc_sharp_panel_off(struct platform_device *pdev) -{ - if (sharp_state.disp_powered_up && sharp_state.display_on) { - serigo(4, 0x00); - mdelay(40); - serigo(31, 0xC1); - mdelay(40); - serigo(31, 0x00); - msleep(16); - sharp_state.display_on = FALSE; - sharp_state.disp_initialized = FALSE; - } - return 0; -} - -static void lcdc_sharp_panel_set_backlight(struct msm_fb_data_type *mfd) -{ - int bl_level, rc; - static bool is_pwm_enabled; - - bl_level = mfd->bl_level; - -#ifdef CONFIG_PMIC8058_PWM - if (bl_pwm) { - pwm_config(bl_pwm, DUTY_LEVEL * bl_level, PWM_PERIOD); - if (is_pwm_enabled) { - pwm_disable(bl_pwm); - is_pwm_enabled = 0; - } - - rc = pwm_enable(bl_pwm); - if (!rc) - is_pwm_enabled = 1; - } -#endif -} - -static int sharp_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - lcdc_sharp_pdata = pdev->dev.platform_data; - return 0; - } - -#ifdef CONFIG_PMIC8058_PWM - bl_pwm = pwm_request(lcdc_sharp_pdata->gpio, "backlight"); - if (bl_pwm == NULL || IS_ERR(bl_pwm)) { - pr_err("%s pwm_request() failed\n", __func__); - bl_pwm = NULL; - } - - printk(KERN_INFO "sharp_probe: bl_pwm=%x LPG_chan=%d\n", - (int) bl_pwm, (int)lcdc_sharp_pdata->gpio); -#endif - - msm_fb_add_device(pdev); - - return 0; -} - -#ifdef CONFIG_SPI_QSD -static int lcdc_sharp_spi_probe(struct spi_device *spi) -{ - lcdc_spi_client = spi; - lcdc_spi_client->bits_per_word = 32; - return 0; -} -static int lcdc_sharp_spi_remove(struct spi_device *spi) -{ - lcdc_spi_client = NULL; - return 0; -} -static struct spi_driver lcdc_sharp_spi_driver = { - .driver = { - .name = LCDC_SHARP_SPI_DEVICE_NAME, - .owner = THIS_MODULE, - }, - .probe = lcdc_sharp_spi_probe, - .remove = lcdc_sharp_spi_remove, -}; -#endif -static struct platform_driver this_driver = { - .probe = sharp_probe, - .driver = { - .name = "lcdc_sharp_wvga", - }, -}; - -static struct msm_fb_panel_data sharp_panel_data = { - .on = lcdc_sharp_panel_on, - .off = lcdc_sharp_panel_off, - .set_backlight = lcdc_sharp_panel_set_backlight, -}; - -static struct platform_device this_device = { - .name = "lcdc_sharp_wvga", - .id = 1, - .dev = { - .platform_data = &sharp_panel_data, - } -}; - -static int __init lcdc_sharp_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - if (msm_fb_detect_client("lcdc_sharp_wvga_pt")) - return 0; -#endif - - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &sharp_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 800; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->clk_rate = 24500000; - pinfo->bl_max = BL_MAX; - pinfo->bl_min = 1; - - pinfo->lcdc.h_back_porch = 20; - pinfo->lcdc.h_front_porch = 10; - pinfo->lcdc.h_pulse_width = 10; - pinfo->lcdc.v_back_porch = 2; - pinfo->lcdc.v_front_porch = 2; - pinfo->lcdc.v_pulse_width = 2; - pinfo->lcdc.border_clr = 0; - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) { - printk(KERN_ERR "%s not able to register the device\n", - __func__); - goto fail_driver; - } -#ifdef CONFIG_SPI_QSD - ret = spi_register_driver(&lcdc_sharp_spi_driver); - - if (ret) { - printk(KERN_ERR "%s not able to register spi\n", __func__); - goto fail_device; - } -#endif - return ret; -#ifdef CONFIG_SPI_QSD -fail_device: - platform_device_unregister(&this_device); -#endif -fail_driver: - platform_driver_unregister(&this_driver); - - return ret; -} - -module_init(lcdc_sharp_panel_init); -#ifdef CONFIG_SPI_QSD -static void __exit lcdc_sharp_panel_exit(void) -{ - spi_unregister_driver(&lcdc_sharp_spi_driver); -} -module_exit(lcdc_sharp_panel_exit); -#endif - diff --git a/drivers/video/msm/lcdc_st15.c b/drivers/video/msm/lcdc_st15.c deleted file mode 100644 index 597a08f8cf2d1a79dd1c7aa648b4814a33972c3a..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_st15.c +++ /dev/null @@ -1,413 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include "msm_fb.h" - -#define DEVICE_NAME "sii9022" -#define SII9022_DEVICE_ID 0xB0 -#define SII9022_ISR 0x3D -#define SII9022_ISR_RXS_STATUS 0x08 - -static int lcdc_sii9022_panel_on(struct platform_device *pdev); -static int lcdc_sii9022_panel_off(struct platform_device *pdev); - -static struct i2c_client *sii9022_i2c_client; - -struct sii9022_data { - struct msm_hdmi_platform_data *pd; - struct platform_device *pdev; - struct work_struct work; - int x_res; - int y_res; - int sysfs_entry_created; - int hdmi_attached; -}; -static struct sii9022_data *dd; - -struct sii9022_i2c_addr_data{ - u8 addr; - u8 data; -}; - -/* video mode data */ -static u8 video_mode_data[] = { - 0x00, - 0xF9, 0x1C, 0x70, 0x17, 0x72, 0x06, 0xEE, 0x02, -}; - -static u8 avi_io_format[] = { - 0x09, - 0x00, 0x00, -}; - -/* power state */ -static struct sii9022_i2c_addr_data regset0[] = { - { 0x60, 0x04 }, - { 0x63, 0x00 }, - { 0x1E, 0x00 }, -}; - -static u8 video_infoframe[] = { - 0x0C, - 0xF0, 0x00, 0x68, 0x00, 0x04, 0x00, 0x19, 0x00, - 0xE9, 0x02, 0x04, 0x01, 0x04, 0x06, -}; - -/* configure audio */ -static struct sii9022_i2c_addr_data regset1[] = { - { 0x26, 0x90 }, - { 0x20, 0x90 }, - { 0x1F, 0x80 }, - { 0x26, 0x80 }, - { 0x24, 0x02 }, - { 0x25, 0x0B }, - { 0xBC, 0x02 }, - { 0xBD, 0x24 }, - { 0xBE, 0x02 }, -}; - -/* enable audio */ -static u8 misc_infoframe[] = { - 0xBF, - 0xC2, 0x84, 0x01, 0x0A, 0x6F, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -/* set HDMI, active */ -static struct sii9022_i2c_addr_data regset2[] = { - { 0x1A, 0x01 }, - { 0x3D, 0x00 }, - { 0x3C, 0x02 }, -}; - -static struct msm_fb_panel_data sii9022_panel_data = { - .on = lcdc_sii9022_panel_on, - .off = lcdc_sii9022_panel_off, -}; - -static struct platform_device sii9022_device = { - .name = DEVICE_NAME, - .id = 1, - .dev = { - .platform_data = &sii9022_panel_data, - } -}; - -static int send_i2c_data(struct i2c_client *client, - struct sii9022_i2c_addr_data *regset, - int size) -{ - int i; - int rc = 0; - - for (i = 0; i < size; i++) { - rc = i2c_smbus_write_byte_data( - client, - regset[i].addr, regset[i].data); - if (rc) - break; - } - return rc; -} - -static void sii9022_work_f(struct work_struct *work) -{ - int isr; - - isr = i2c_smbus_read_byte_data(sii9022_i2c_client, SII9022_ISR); - if (isr < 0) { - dev_err(&sii9022_i2c_client->dev, - "i2c read of isr failed rc = 0x%x\n", isr); - return; - } - if (isr == 0) - return; - - /* reset any set bits */ - i2c_smbus_write_byte_data(sii9022_i2c_client, SII9022_ISR, isr); - dd->hdmi_attached = isr & SII9022_ISR_RXS_STATUS; - if (dd->pd->cable_detect) - dd->pd->cable_detect(dd->hdmi_attached); - if (dd->hdmi_attached) { - dd->x_res = 1280; - dd->y_res = 720; - } else { - dd->x_res = sii9022_panel_data.panel_info.xres; - dd->y_res = sii9022_panel_data.panel_info.yres; - } -} - -static irqreturn_t sii9022_interrupt(int irq, void *dev_id) -{ - struct sii9022_data *dd = dev_id; - - schedule_work(&dd->work); - return IRQ_HANDLED; -} - -static int hdmi_sii_enable(struct i2c_client *client) -{ - int rc; - int retries = 10; - int count; - - rc = i2c_smbus_write_byte_data(client, 0xC7, 0x00); - if (rc) - goto enable_exit; - - do { - msleep(1); - rc = i2c_smbus_read_byte_data(client, 0x1B); - } while ((rc != SII9022_DEVICE_ID) && retries--); - - if (rc != SII9022_DEVICE_ID) - return -ENODEV; - - rc = i2c_smbus_write_byte_data(client, 0x1A, 0x11); - if (rc) - goto enable_exit; - - count = ARRAY_SIZE(video_mode_data); - rc = i2c_master_send(client, video_mode_data, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = i2c_smbus_write_byte_data(client, 0x08, 0x20); - if (rc) - goto enable_exit; - count = ARRAY_SIZE(avi_io_format); - rc = i2c_master_send(client, avi_io_format, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = send_i2c_data(client, regset0, ARRAY_SIZE(regset0)); - if (rc) - goto enable_exit; - - count = ARRAY_SIZE(video_infoframe); - rc = i2c_master_send(client, video_infoframe, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = send_i2c_data(client, regset1, ARRAY_SIZE(regset1)); - if (rc) - goto enable_exit; - - count = ARRAY_SIZE(misc_infoframe); - rc = i2c_master_send(client, misc_infoframe, count); - if (rc != count) { - rc = -EIO; - goto enable_exit; - } - - rc = send_i2c_data(client, regset2, ARRAY_SIZE(regset2)); - if (rc) - goto enable_exit; - - return 0; -enable_exit: - printk(KERN_ERR "%s: exited rc=%d\n", __func__, rc); - return rc; -} - -static ssize_t show_res(struct device *device, - struct device_attribute *attr, char *buf) -{ - return snprintf(buf, PAGE_SIZE, "%dx%d\n", dd->x_res, dd->y_res); -} - -static struct device_attribute device_attrs[] = { - __ATTR(screen_resolution, S_IRUGO|S_IWUSR, show_res, NULL), -}; - -static int lcdc_sii9022_panel_on(struct platform_device *pdev) -{ - int rc; - if (!dd->sysfs_entry_created) { - dd->pdev = pdev; - rc = device_create_file(&pdev->dev, &device_attrs[0]); - if (!rc) - dd->sysfs_entry_created = 1; - } - - rc = hdmi_sii_enable(sii9022_i2c_client); - if (rc) { - dd->hdmi_attached = 0; - dd->x_res = sii9022_panel_data.panel_info.xres; - dd->y_res = sii9022_panel_data.panel_info.yres; - } - if (dd->pd->irq) - enable_irq(dd->pd->irq); - /* Don't return the value from hdmi_sii_enable(). - * It may fail on some ST1.5s, but we must return 0 from this - * function in order for the on-board display to turn on. - */ - return 0; -} - -static int lcdc_sii9022_panel_off(struct platform_device *pdev) -{ - if (dd->pd->irq) - disable_irq(dd->pd->irq); - return 0; -} - -static const struct i2c_device_id hmdi_sii_id[] = { - { DEVICE_NAME, 0 }, - { } -}; - -static int hdmi_sii_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int rc; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C)) - return -ENODEV; - - dd = kzalloc(sizeof *dd, GFP_KERNEL); - if (!dd) { - rc = -ENOMEM; - goto probe_exit; - } - sii9022_i2c_client = client; - i2c_set_clientdata(client, dd); - dd->pd = client->dev.platform_data; - if (!dd->pd) { - rc = -ENODEV; - goto probe_free; - } - if (dd->pd->irq) { - INIT_WORK(&dd->work, sii9022_work_f); - rc = request_irq(dd->pd->irq, - &sii9022_interrupt, - IRQF_TRIGGER_FALLING, - "sii9022_cable", dd); - if (rc) - goto probe_free; - disable_irq(dd->pd->irq); - } - msm_fb_add_device(&sii9022_device); - dd->x_res = sii9022_panel_data.panel_info.xres; - dd->y_res = sii9022_panel_data.panel_info.yres; - - return 0; - -probe_free: - i2c_set_clientdata(client, NULL); - kfree(dd); -probe_exit: - return rc; -} - -static int hdmi_sii_remove(struct i2c_client *client) -{ - int err = 0 ; - struct msm_hdmi_platform_data *pd; - - if (dd->sysfs_entry_created) - device_remove_file(&dd->pdev->dev, &device_attrs[0]); - pd = client->dev.platform_data; - if (pd && pd->irq) - free_irq(pd->irq, dd); - i2c_set_clientdata(client, NULL); - kfree(dd); - - return err ; -} - -#ifdef CONFIG_PM -static int sii9022_suspend(struct device *dev) -{ - if (dd && dd->pd && dd->pd->irq) - disable_irq(dd->pd->irq); - return 0; -} - -static int sii9022_resume(struct device *dev) -{ - if (dd && dd->pd && dd->pd->irq) - enable_irq(dd->pd->irq); - return 0; -} - -static struct dev_pm_ops sii9022_pm_ops = { - .suspend = sii9022_suspend, - .resume = sii9022_resume, -}; -#endif - -static struct i2c_driver hdmi_sii_i2c_driver = { - .driver = { - .name = DEVICE_NAME, - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &sii9022_pm_ops, -#endif - }, - .probe = hdmi_sii_probe, - .remove = __exit_p(hdmi_sii_remove), - .id_table = hmdi_sii_id, -}; - -static int __init lcdc_st15_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - if (msm_fb_detect_client("lcdc_st15")) - return 0; - - pinfo = &sii9022_panel_data.panel_info; - pinfo->xres = 1366; - pinfo->yres = 768; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - pinfo->fb_num = 2; - pinfo->clk_rate = 74250000; - - pinfo->lcdc.h_back_porch = 120; - pinfo->lcdc.h_front_porch = 20; - pinfo->lcdc.h_pulse_width = 40; - pinfo->lcdc.v_back_porch = 25; - pinfo->lcdc.v_front_porch = 1; - pinfo->lcdc.v_pulse_width = 7; - pinfo->lcdc.border_clr = 0; /* blk */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - pinfo->lcdc.hsync_skew = 0; - - ret = i2c_add_driver(&hdmi_sii_i2c_driver); - if (ret) - printk(KERN_ERR "%s: failed to add i2c driver\n", __func__); - - return ret; -} - -static void __exit hdmi_sii_exit(void) -{ - i2c_del_driver(&hdmi_sii_i2c_driver); -} - -module_init(lcdc_st15_init); -module_exit(hdmi_sii_exit); diff --git a/drivers/video/msm/lcdc_toshiba_fwvga_pt.c b/drivers/video/msm/lcdc_toshiba_fwvga_pt.c deleted file mode 100644 index db13c73d0410203a24ab9ef8773d1f802d29de33..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_toshiba_fwvga_pt.c +++ /dev/null @@ -1,471 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include -#include -#include -#include "msm_fb.h" - -static int spi_cs0_N; -static int spi_sclk; -static int spi_mosi; -static int spi_miso; - -struct toshiba_state_type { - boolean disp_initialized; - boolean display_on; - boolean disp_powered_up; -}; - -static struct toshiba_state_type toshiba_state = { 0 }; -static struct msm_panel_common_pdata *lcdc_toshiba_pdata; - -static int toshiba_spi_write(char data1, char data2, int rs) -{ - uint32 bitdata = 0, bnum = 24, bmask = 0x800000; - - gpio_set_value_cansleep(spi_cs0_N, 0); /* cs* low */ - udelay(1); - - if (rs) - bitdata = (0x72 << 16); - else - bitdata = (0x70 << 16); - - bitdata |= ((data1 << 8) | data2); - - while (bnum) { - gpio_set_value_cansleep(spi_sclk, 0); /* clk low */ - udelay(1); - - if (bitdata & bmask) - gpio_set_value_cansleep(spi_mosi, 1); - else - gpio_set_value_cansleep(spi_mosi, 0); - - udelay(1); - gpio_set_value_cansleep(spi_sclk, 1); /* clk high */ - udelay(1); - bmask >>= 1; - bnum--; - } - - gpio_set_value_cansleep(spi_cs0_N, 1); /* cs* high */ - udelay(1); - return 0; -} - -static void spi_pin_assign(void) -{ - /* Setting the Default GPIO's */ - spi_mosi = *(lcdc_toshiba_pdata->gpio_num); - spi_miso = *(lcdc_toshiba_pdata->gpio_num + 1); - spi_sclk = *(lcdc_toshiba_pdata->gpio_num + 2); - spi_cs0_N = *(lcdc_toshiba_pdata->gpio_num + 3); -} - -static void toshiba_disp_powerup(void) -{ - if (!toshiba_state.disp_powered_up && !toshiba_state.display_on) { - /* Reset the hardware first */ - /* Include DAC power up implementation here */ - toshiba_state.disp_powered_up = TRUE; - } -} - -static void toshiba_disp_on(void) -{ - if (toshiba_state.disp_powered_up && !toshiba_state.display_on) { - toshiba_spi_write(0x01, 0x00, 0); - toshiba_spi_write(0x30, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x01, 0x01, 0); - toshiba_spi_write(0x40, 0x10, 1); - -#ifdef TOSHIBA_FWVGA_FULL_INIT - udelay(500); - toshiba_spi_write(0x01, 0x06, 0); - toshiba_spi_write(0x00, 0x00, 1); - msleep(20); - - toshiba_spi_write(0x00, 0x01, 0); - toshiba_spi_write(0x03, 0x10, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x02, 0); - toshiba_spi_write(0x01, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x03, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x07, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x08, 0); - toshiba_spi_write(0x00, 0x04, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x09, 0); - toshiba_spi_write(0x00, 0x0c, 1); -#endif - udelay(500); - toshiba_spi_write(0x00, 0x0c, 0); - toshiba_spi_write(0x40, 0x10, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x0e, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x20, 0); - toshiba_spi_write(0x01, 0x3f, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x22, 0); - toshiba_spi_write(0x76, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x23, 0); - toshiba_spi_write(0x1c, 0x0a, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x24, 0); - toshiba_spi_write(0x1c, 0x2c, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x25, 0); - toshiba_spi_write(0x1c, 0x4e, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x27, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x28, 0); - toshiba_spi_write(0x76, 0x0c, 1); - -#ifdef TOSHIBA_FWVGA_FULL_INIT - udelay(500); - toshiba_spi_write(0x03, 0x00, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x01, 0); - toshiba_spi_write(0x05, 0x02, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x02, 0); - toshiba_spi_write(0x07, 0x05, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x03, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x04, 0); - toshiba_spi_write(0x02, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x05, 0); - toshiba_spi_write(0x07, 0x07, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x06, 0); - toshiba_spi_write(0x10, 0x10, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x07, 0); - toshiba_spi_write(0x02, 0x02, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x08, 0); - toshiba_spi_write(0x07, 0x04, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x09, 0); - toshiba_spi_write(0x07, 0x07, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x0a, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x0b, 0); - toshiba_spi_write(0x00, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x0c, 0); - toshiba_spi_write(0x07, 0x07, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x0d, 0); - toshiba_spi_write(0x10, 0x10, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x10, 0); - toshiba_spi_write(0x01, 0x04, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x11, 0); - toshiba_spi_write(0x05, 0x03, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x12, 0); - toshiba_spi_write(0x03, 0x04, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x15, 0); - toshiba_spi_write(0x03, 0x04, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x16, 0); - toshiba_spi_write(0x03, 0x1c, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x17, 0); - toshiba_spi_write(0x02, 0x04, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x18, 0); - toshiba_spi_write(0x04, 0x02, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x19, 0); - toshiba_spi_write(0x03, 0x05, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x1c, 0); - toshiba_spi_write(0x07, 0x07, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x1d, 0); - toshiba_spi_write(0x02, 0x1f, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x20, 0); - toshiba_spi_write(0x05, 0x07, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x21, 0); - toshiba_spi_write(0x06, 0x04, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x22, 0); - toshiba_spi_write(0x04, 0x05, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x27, 0); - toshiba_spi_write(0x02, 0x03, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x28, 0); - toshiba_spi_write(0x03, 0x00, 1); - - udelay(500); - toshiba_spi_write(0x03, 0x29, 0); - toshiba_spi_write(0x00, 0x02, 1); - -#endif - udelay(500); - toshiba_spi_write(0x01, 0x00, 0); - toshiba_spi_write(0x36, 0x3c, 1); - udelay(500); - - toshiba_spi_write(0x01, 0x01, 0); - toshiba_spi_write(0x40, 0x03, 1); - - udelay(500); - toshiba_spi_write(0x01, 0x02, 0); - toshiba_spi_write(0x00, 0x01, 1); - - udelay(500); - toshiba_spi_write(0x01, 0x03, 0); - toshiba_spi_write(0x3c, 0x58, 1); - - udelay(500); - toshiba_spi_write(0x01, 0x0c, 0); - toshiba_spi_write(0x01, 0x35, 1); - - udelay(500); - toshiba_spi_write(0x01, 0x06, 0); - toshiba_spi_write(0x00, 0x02, 1); - - udelay(500); - toshiba_spi_write(0x00, 0x29, 0); - toshiba_spi_write(0x03, 0xbf, 1); - - udelay(500); - toshiba_spi_write(0x01, 0x06, 0); - toshiba_spi_write(0x00, 0x03, 1); - msleep(32); - - toshiba_spi_write(0x01, 0x01, 0); - toshiba_spi_write(0x40, 0x10, 1); - msleep(80); - - toshiba_state.display_on = TRUE; - } -} - -static int lcdc_toshiba_panel_on(struct platform_device *pdev) -{ - if (!toshiba_state.disp_initialized) { - /* Configure reset GPIO that drives DAC */ - if (lcdc_toshiba_pdata->panel_config_gpio) - lcdc_toshiba_pdata->panel_config_gpio(1); - toshiba_disp_powerup(); - toshiba_disp_on(); - toshiba_state.disp_initialized = TRUE; - } - return 0; -} - -static int lcdc_toshiba_panel_off(struct platform_device *pdev) -{ - if (toshiba_state.disp_powered_up && toshiba_state.display_on) { - toshiba_spi_write(0x01, 0x06, 1); - toshiba_spi_write(0x00, 0x02, 1); - msleep(80); - - toshiba_spi_write(0x01, 0x06, 1); - toshiba_spi_write(0x00, 0x00, 1); - - toshiba_spi_write(0x00, 0x29, 1); - toshiba_spi_write(0x00, 0x02, 1); - - toshiba_spi_write(0x01, 0x00, 1); - toshiba_spi_write(0x30, 0x00, 1); - - if (lcdc_toshiba_pdata->panel_config_gpio) - lcdc_toshiba_pdata->panel_config_gpio(0); - toshiba_state.display_on = FALSE; - toshiba_state.disp_initialized = FALSE; - } - - return 0; -} - -static void lcdc_toshiba_set_backlight(struct msm_fb_data_type *mfd) -{ - int ret; - int bl_level; - - bl_level = mfd->bl_level; - - if (lcdc_toshiba_pdata && lcdc_toshiba_pdata->pmic_backlight) - ret = lcdc_toshiba_pdata->pmic_backlight(bl_level); - else - pr_err("%s(): Backlight level set failed", __func__); - - return; -} - -static int toshiba_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - lcdc_toshiba_pdata = pdev->dev.platform_data; - spi_pin_assign(); - return 0; - } - msm_fb_add_device(pdev); - return 0; -} - -static struct platform_driver this_driver = { - .probe = toshiba_probe, - .driver = { - .name = "lcdc_toshiba_fwvga_pt", - }, -}; - -static struct msm_fb_panel_data toshiba_panel_data = { - .on = lcdc_toshiba_panel_on, - .off = lcdc_toshiba_panel_off, - .set_backlight = lcdc_toshiba_set_backlight, -}; - -static struct platform_device this_device = { - .name = "lcdc_toshiba_fwvga_pt", - .id = 1, - .dev = { - .platform_data = &toshiba_panel_data, - } -}; - -static int __init lcdc_toshiba_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - ret = msm_fb_detect_client("lcdc_toshiba_fwvga_pt"); - if (ret) - return 0; - - - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &toshiba_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 864; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - /* 30Mhz mdp_lcdc_pclk and mdp_lcdc_pad_pcl */ - pinfo->clk_rate = 30720000; - pinfo->bl_max = 100; - pinfo->bl_min = 1; - - if (cpu_is_msm7x25a() || cpu_is_msm7x25aa() || cpu_is_msm7x25ab()) { - pinfo->yres = 320; - pinfo->lcdc.h_back_porch = 10; - pinfo->lcdc.h_front_porch = 21; - pinfo->lcdc.h_pulse_width = 5; - pinfo->lcdc.v_back_porch = 8; - pinfo->lcdc.v_front_porch = 540; - pinfo->lcdc.v_pulse_width = 42; - pinfo->lcdc.border_clr = 0; /* blk */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - pinfo->lcdc.hsync_skew = 0; - } else { - pinfo->lcdc.h_back_porch = 8; - pinfo->lcdc.h_front_porch = 16; - pinfo->lcdc.h_pulse_width = 8; - pinfo->lcdc.v_back_porch = 2; - pinfo->lcdc.v_front_porch = 2; - pinfo->lcdc.v_pulse_width = 2; - pinfo->lcdc.border_clr = 0; /* blk */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - pinfo->lcdc.hsync_skew = 0; - } - - ret = platform_device_register(&this_device); - if (ret) { - printk(KERN_ERR "%s not able to register the device\n", - __func__); - platform_driver_unregister(&this_driver); - } - return ret; -} - -device_initcall(lcdc_toshiba_panel_init); diff --git a/drivers/video/msm/lcdc_toshiba_wvga_pt.c b/drivers/video/msm/lcdc_toshiba_wvga_pt.c deleted file mode 100644 index f9f4f5c27bd47d20c6c073d2cafec54b7d589fb5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_toshiba_wvga_pt.c +++ /dev/null @@ -1,519 +0,0 @@ -/* Copyright (c) 2009-2010, 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 -#include -#ifdef CONFIG_SPI_QSD -#include -#endif -#include -#include -#include "msm_fb.h" - -#ifdef CONFIG_FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM -#include "mddihosti.h" -#endif - -#ifdef CONFIG_SPI_QSD -#define LCDC_TOSHIBA_SPI_DEVICE_NAME "lcdc_toshiba_ltm030dd40" -static struct spi_device *lcdc_toshiba_spi_client; -#else -static int spi_cs; -static int spi_sclk; -static int spi_mosi; -static int spi_miso; -#endif -struct toshiba_state_type{ - boolean disp_initialized; - boolean display_on; - boolean disp_powered_up; -}; - -static struct toshiba_state_type toshiba_state = { 0 }; -static struct msm_panel_common_pdata *lcdc_toshiba_pdata; - -#ifndef CONFIG_SPI_QSD -static void toshiba_spi_write_byte(char dc, uint8 data) -{ - uint32 bit; - int bnum; - - gpio_set_value(spi_sclk, 0); /* clk low */ - /* dc: 0 for command, 1 for parameter */ - gpio_set_value(spi_mosi, dc); - udelay(1); /* at least 20 ns */ - gpio_set_value(spi_sclk, 1); /* clk high */ - udelay(1); /* at least 20 ns */ - bnum = 8; /* 8 data bits */ - bit = 0x80; - while (bnum) { - gpio_set_value(spi_sclk, 0); /* clk low */ - if (data & bit) - gpio_set_value(spi_mosi, 1); - else - gpio_set_value(spi_mosi, 0); - udelay(1); - gpio_set_value(spi_sclk, 1); /* clk high */ - udelay(1); - bit >>= 1; - bnum--; - } -} -#endif - -static int toshiba_spi_write(char cmd, uint32 data, int num) -{ - char *bp; -#ifdef CONFIG_SPI_QSD - char tx_buf[4]; - int rc, i; - struct spi_message m; - struct spi_transfer t; - uint32 final_data = 0; - - if (!lcdc_toshiba_spi_client) { - printk(KERN_ERR "%s lcdc_toshiba_spi_client is NULL\n", - __func__); - return -EINVAL; - } - - memset(&t, 0, sizeof t); - t.tx_buf = tx_buf; - spi_setup(lcdc_toshiba_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - /* command byte first */ - final_data |= cmd << 23; - t.len = num + 2; - if (t.len < 4) - t.bits_per_word = 8 * t.len; - /* followed by parameter bytes */ - if (num) { - bp = (char *)&data;; - bp += (num - 1); - i = 1; - while (num) { - final_data |= 1 << (((4 - i) << 3) - i - 1); - final_data |= *bp << (((4 - i - 1) << 3) - i - 1); - num--; - bp--; - i++; - } - } - - bp = (char *)&final_data; - for (i = 0; i < t.len; i++) - tx_buf[i] = bp[3 - i]; - t.rx_buf = NULL; - rc = spi_sync(lcdc_toshiba_spi_client, &m); - if (rc) - printk(KERN_ERR "spi_sync _write failed %d\n", rc); - return rc; -#else - gpio_set_value(spi_cs, 1); /* cs high */ - - /* command byte first */ - toshiba_spi_write_byte(0, cmd); - - /* followed by parameter bytes */ - if (num) { - bp = (char *)&data;; - bp += (num - 1); - while (num) { - toshiba_spi_write_byte(1, *bp); - num--; - bp--; - } - } - - gpio_set_value(spi_cs, 0); /* cs low */ - udelay(1); - return 0; -#endif -} - -static int toshiba_spi_read_bytes(char cmd, uint32 *data, int num) -{ -#ifdef CONFIG_SPI_QSD - char tx_buf[5]; - char rx_buf[5]; - int rc; - struct spi_message m; - struct spi_transfer t; - - if (!lcdc_toshiba_spi_client) { - printk(KERN_ERR "%s lcdc_toshiba_spi_client is NULL\n", - __func__); - return -EINVAL; - } - - memset(&t, 0, sizeof t); - t.tx_buf = tx_buf; - t.rx_buf = rx_buf; - spi_setup(lcdc_toshiba_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - /* command byte first */ - tx_buf[0] = 0 | ((cmd >> 1) & 0x7f); - tx_buf[1] = (cmd & 0x01) << 7; - tx_buf[2] = 0; - tx_buf[3] = 0; - tx_buf[4] = 0; - - t.len = 5; - - rc = spi_sync(lcdc_toshiba_spi_client, &m); - *data = 0; - *data = ((rx_buf[1] & 0x1f) << 19) | (rx_buf[2] << 11) | - (rx_buf[3] << 3) | ((rx_buf[4] & 0xe0) >> 5); - if (rc) - printk(KERN_ERR "spi_sync _read failed %d\n", rc); - return rc; -#else - uint32 dbit, bits; - int bnum; - - gpio_set_value(spi_cs, 1); /* cs high */ - - /* command byte first */ - toshiba_spi_write_byte(0, cmd); - - if (num > 1) { - /* extra dc bit */ - gpio_set_value(spi_sclk, 0); /* clk low */ - udelay(1); - dbit = gpio_get_value(spi_miso);/* dc bit */ - udelay(1); - gpio_set_value(spi_sclk, 1); /* clk high */ - } - - /* followed by data bytes */ - bnum = num * 8; /* number of bits */ - bits = 0; - while (bnum) { - bits <<= 1; - gpio_set_value(spi_sclk, 0); /* clk low */ - udelay(1); - dbit = gpio_get_value(spi_miso); - udelay(1); - gpio_set_value(spi_sclk, 1); /* clk high */ - bits |= dbit; - bnum--; - } - - *data = bits; - - udelay(1); - gpio_set_value(spi_cs, 0); /* cs low */ - udelay(1); - return 0; -#endif -} - -#ifndef CONFIG_SPI_QSD -static void spi_pin_assign(void) -{ - /* Setting the Default GPIO's */ - spi_sclk = *(lcdc_toshiba_pdata->gpio_num); - spi_cs = *(lcdc_toshiba_pdata->gpio_num + 1); - spi_mosi = *(lcdc_toshiba_pdata->gpio_num + 2); - spi_miso = *(lcdc_toshiba_pdata->gpio_num + 3); -} -#endif - -static void toshiba_disp_powerup(void) -{ - if (!toshiba_state.disp_powered_up && !toshiba_state.display_on) { - /* Reset the hardware first */ - /* Include DAC power up implementation here */ - toshiba_state.disp_powered_up = TRUE; - } -} - -static void toshiba_disp_on(void) -{ - uint32 data; - -#ifndef CONFIG_SPI_QSD - gpio_set_value(spi_cs, 0); /* low */ - gpio_set_value(spi_sclk, 1); /* high */ - gpio_set_value(spi_mosi, 0); - gpio_set_value(spi_miso, 0); -#endif - - if (toshiba_state.disp_powered_up && !toshiba_state.display_on) { - toshiba_spi_write(0, 0, 0); - mdelay(7); - toshiba_spi_write(0, 0, 0); - mdelay(7); - toshiba_spi_write(0, 0, 0); - mdelay(7); - toshiba_spi_write(0xba, 0x11, 1); - toshiba_spi_write(0x36, 0x00, 1); - mdelay(1); - toshiba_spi_write(0x3a, 0x60, 1); - toshiba_spi_write(0xb1, 0x5d, 1); - mdelay(1); - toshiba_spi_write(0xb2, 0x33, 1); - toshiba_spi_write(0xb3, 0x22, 1); - mdelay(1); - toshiba_spi_write(0xb4, 0x02, 1); - toshiba_spi_write(0xb5, 0x1e, 1); /* vcs -- adjust brightness */ - mdelay(1); - toshiba_spi_write(0xb6, 0x27, 1); - toshiba_spi_write(0xb7, 0x03, 1); - mdelay(1); - toshiba_spi_write(0xb9, 0x24, 1); - toshiba_spi_write(0xbd, 0xa1, 1); - mdelay(1); - toshiba_spi_write(0xbb, 0x00, 1); - toshiba_spi_write(0xbf, 0x01, 1); - mdelay(1); - toshiba_spi_write(0xbe, 0x00, 1); - toshiba_spi_write(0xc0, 0x11, 1); - mdelay(1); - toshiba_spi_write(0xc1, 0x11, 1); - toshiba_spi_write(0xc2, 0x11, 1); - mdelay(1); - toshiba_spi_write(0xc3, 0x3232, 2); - mdelay(1); - toshiba_spi_write(0xc4, 0x3232, 2); - mdelay(1); - toshiba_spi_write(0xc5, 0x3232, 2); - mdelay(1); - toshiba_spi_write(0xc6, 0x3232, 2); - mdelay(1); - toshiba_spi_write(0xc7, 0x6445, 2); - mdelay(1); - toshiba_spi_write(0xc8, 0x44, 1); - toshiba_spi_write(0xc9, 0x52, 1); - mdelay(1); - toshiba_spi_write(0xca, 0x00, 1); - mdelay(1); - toshiba_spi_write(0xec, 0x02a4, 2); /* 0x02a4 */ - mdelay(1); - toshiba_spi_write(0xcf, 0x01, 1); - mdelay(1); - toshiba_spi_write(0xd0, 0xc003, 2); /* c003 */ - mdelay(1); - toshiba_spi_write(0xd1, 0x01, 1); - mdelay(1); - toshiba_spi_write(0xd2, 0x0028, 2); - mdelay(1); - toshiba_spi_write(0xd3, 0x0028, 2); - mdelay(1); - toshiba_spi_write(0xd4, 0x26a4, 2); - mdelay(1); - toshiba_spi_write(0xd5, 0x20, 1); - mdelay(1); - toshiba_spi_write(0xef, 0x3200, 2); - mdelay(32); - toshiba_spi_write(0xbc, 0x80, 1); /* wvga pass through */ - toshiba_spi_write(0x3b, 0x00, 1); - mdelay(1); - toshiba_spi_write(0xb0, 0x16, 1); - mdelay(1); - toshiba_spi_write(0xb8, 0xfff5, 2); - mdelay(1); - toshiba_spi_write(0x11, 0, 0); - mdelay(5); - toshiba_spi_write(0x29, 0, 0); - mdelay(5); - toshiba_state.display_on = TRUE; - } - - data = 0; - toshiba_spi_read_bytes(0x04, &data, 3); - printk(KERN_INFO "toshiba_disp_on: id=%x\n", data); - -} - -static int lcdc_toshiba_panel_on(struct platform_device *pdev) -{ - if (!toshiba_state.disp_initialized) { - /* Configure reset GPIO that drives DAC */ - if (lcdc_toshiba_pdata->panel_config_gpio) - lcdc_toshiba_pdata->panel_config_gpio(1); - toshiba_disp_powerup(); - toshiba_disp_on(); - toshiba_state.disp_initialized = TRUE; - } - return 0; -} - -static int lcdc_toshiba_panel_off(struct platform_device *pdev) -{ - if (toshiba_state.disp_powered_up && toshiba_state.display_on) { - /* Main panel power off (Deep standby in) */ - - toshiba_spi_write(0x28, 0, 0); /* display off */ - mdelay(1); - toshiba_spi_write(0xb8, 0x8002, 2); /* output control */ - mdelay(1); - toshiba_spi_write(0x10, 0x00, 1); /* sleep mode in */ - mdelay(85); /* wait 85 msec */ - toshiba_spi_write(0xb0, 0x00, 1); /* deep standby in */ - mdelay(1); - if (lcdc_toshiba_pdata->panel_config_gpio) - lcdc_toshiba_pdata->panel_config_gpio(0); - toshiba_state.display_on = FALSE; - toshiba_state.disp_initialized = FALSE; - } - return 0; -} - -static void lcdc_toshiba_set_backlight(struct msm_fb_data_type *mfd) -{ - int bl_level; - int ret = -EPERM; - int i = 0; - - bl_level = mfd->bl_level; - - while (i++ < 3) { - ret = pmic_set_led_intensity(LED_LCD, bl_level); - if (ret == 0) - return; - msleep(10); - } - - printk(KERN_WARNING "%s: can't set lcd backlight!\n", - __func__); -} - -static int toshiba_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - lcdc_toshiba_pdata = pdev->dev.platform_data; -#ifndef CONFIG_SPI_QSD - spi_pin_assign(); -#endif - return 0; - } - msm_fb_add_device(pdev); - return 0; -} - -#ifdef CONFIG_SPI_QSD -static int lcdc_toshiba_spi_probe(struct spi_device *spi) -{ - lcdc_toshiba_spi_client = spi; - lcdc_toshiba_spi_client->bits_per_word = 32; - return 0; -} -static int lcdc_toshiba_spi_remove(struct spi_device *spi) -{ - lcdc_toshiba_spi_client = NULL; - return 0; -} - -static struct spi_driver lcdc_toshiba_spi_driver = { - .driver = { - .name = LCDC_TOSHIBA_SPI_DEVICE_NAME, - .owner = THIS_MODULE, - }, - .probe = lcdc_toshiba_spi_probe, - .remove = lcdc_toshiba_spi_remove, -}; -#endif -static struct platform_driver this_driver = { - .probe = toshiba_probe, - .driver = { - .name = "lcdc_toshiba_wvga", - }, -}; - -static struct msm_fb_panel_data toshiba_panel_data = { - .on = lcdc_toshiba_panel_on, - .off = lcdc_toshiba_panel_off, - .set_backlight = lcdc_toshiba_set_backlight, -}; - -static struct platform_device this_device = { - .name = "lcdc_toshiba_wvga", - .id = 1, - .dev = { - .platform_data = &toshiba_panel_data, - } -}; - -static int __init lcdc_toshiba_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; -#ifdef CONFIG_FB_MSM_TRY_MDDI_CATCH_LCDC_PRISM - if (mddi_get_client_id() != 0) - return 0; - - ret = msm_fb_detect_client("lcdc_toshiba_wvga_pt"); - if (ret) - return 0; - -#endif - - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &toshiba_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 800; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - /* 30Mhz mdp_lcdc_pclk and mdp_lcdc_pad_pcl */ - pinfo->clk_rate = 30720000; - pinfo->bl_max = 15; - pinfo->bl_min = 1; - - pinfo->lcdc.h_back_porch = 184; /* hsw = 8 + hbp=184 */ - pinfo->lcdc.h_front_porch = 4; - pinfo->lcdc.h_pulse_width = 8; - pinfo->lcdc.v_back_porch = 2; /* vsw=1 + vbp = 2 */ - pinfo->lcdc.v_front_porch = 3; - pinfo->lcdc.v_pulse_width = 1; - pinfo->lcdc.border_clr = 0; /* blk */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) { - printk(KERN_ERR "%s not able to register the device\n", - __func__); - goto fail_driver; - } -#ifdef CONFIG_SPI_QSD - ret = spi_register_driver(&lcdc_toshiba_spi_driver); - - if (ret) { - printk(KERN_ERR "%s not able to register spi\n", __func__); - goto fail_device; - } -#endif - return ret; - -#ifdef CONFIG_SPI_QSD -fail_device: - platform_device_unregister(&this_device); -#endif -fail_driver: - platform_driver_unregister(&this_driver); - return ret; -} - -device_initcall(lcdc_toshiba_panel_init); diff --git a/drivers/video/msm/lcdc_truly_ips3p2335.c b/drivers/video/msm/lcdc_truly_ips3p2335.c deleted file mode 100644 index cf0b78b149c91121c0c762a06fdac57e63a62fc9..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_truly_ips3p2335.c +++ /dev/null @@ -1,312 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include "msm_fb.h" - -static int prev_bl = 17; - -static int spi_cs; -static int spi_sclk; -static int spi_mosi; -static int gpio_backlight_en; -static int gpio_display_reset; - -struct truly_state_type { - boolean disp_initialized; - boolean display_on; - boolean disp_powered_up; -}; - -static struct truly_state_type truly_state = { 0 }; -static struct msm_panel_common_pdata *lcdc_truly_pdata; - -static char init_item_v1[] = { 0xff, 0x83, 0x57, }; -static char init_item_v2[] = { 0x03, }; -static char init_item_v3[] = { 0x00, 0x13, 0x1C, 0x1C, 0x83, 0x48, }; -static char init_item_v4[] = { 0x43, 0x06, 0x06, 0x06, }; -static char init_item_v5[] = { 0x53, }; -static char init_item_v6[] = { 0x02, 0x40, 0x00, 0x2a, 0x2a, 0x0d, 0x3f, }; -static char init_item_v7[] = { 0x70, 0x50, 0x01, 0x3c, 0xe8, 0x08, }; -static char init_item_v8[] = { 0x17, 0x0f, }; -static char init_item_v9[] = { 0x60}; -static char init_item_v10[] = { 0x00, 0x13, 0x1a, 0x29, 0x2d, 0x41, 0x49, - 0x52, 0x48, 0x41, 0x3c, 0x33, 0x30, 0x1c, - 0x19, 0x03, 0x00, 0x13, 0x1a, 0x29, 0x2d, - 0x41, 0x49, 0x52, 0x48, 0x41, 0x3c, 0x33, - 0x31, 0x1c, 0x19, 0x03, 0x00, 0x01, - }; -static char init_item_v11[] = { 0x40, }; - -static inline void truly_spi_write_byte(char dc, uint8 data) -{ - uint32 bit; - int bnum; - - gpio_set_value_cansleep(spi_sclk, 0); /* clk low */ - /* dc: 0 for command, 1 for parameter */ - gpio_set_value_cansleep(spi_mosi, dc); - udelay(1); /* at least 20 ns */ - gpio_set_value_cansleep(spi_sclk, 1); /* clk high */ - udelay(1); /* at least 20 ns */ - bnum = 8; /* 8 data bits */ - bit = 0x80; - while (bnum) { - gpio_set_value_cansleep(spi_sclk, 0); /* clk low */ - if (data & bit) - gpio_set_value_cansleep(spi_mosi, 1); - else - gpio_set_value_cansleep(spi_mosi, 0); - udelay(1); - gpio_set_value_cansleep(spi_sclk, 1); /* clk high */ - udelay(1); - bit >>= 1; - bnum--; - } -} - -static inline int truly_spi_write(char cmd, char *data, int num) -{ - int i; - - gpio_set_value_cansleep(spi_cs, 0); /* cs low */ - /* command byte first */ - truly_spi_write_byte(0, cmd); - /* followed by parameter bytes */ - for (i = 0; i < num; i++) { - if (data) - truly_spi_write_byte(1, data[i]); - } - gpio_set_value_cansleep(spi_mosi, 1); /* mosi high */ - gpio_set_value_cansleep(spi_cs, 1); /* cs high */ - udelay(10); - return 0; -} - -static void spi_pin_assign(void) -{ - /* Setting the Default GPIO's */ - spi_mosi = *(lcdc_truly_pdata->gpio_num); - spi_sclk = *(lcdc_truly_pdata->gpio_num + 1); - spi_cs = *(lcdc_truly_pdata->gpio_num + 2); - gpio_backlight_en = *(lcdc_truly_pdata->gpio_num + 3); - gpio_display_reset = *(lcdc_truly_pdata->gpio_num + 4); - pr_debug("spi_mosi:%d spi_sclk:%d spi_cs:%d backlight:%d reset:%d\n", - spi_mosi, spi_sclk, spi_cs, gpio_backlight_en, - gpio_display_reset); - -} - -static void truly_disp_powerup(void) -{ - /* Reset the hardware first */ - /* Include DAC power up implementation here */ - if (!truly_state.disp_powered_up && !truly_state.display_on) - truly_state.disp_powered_up = TRUE; -} - -static void truly_disp_reginit(void) -{ - pr_debug("%s disp_powered_up:%d display_on:%d\n", __func__, - truly_state.disp_powered_up, truly_state.display_on); - if (truly_state.disp_powered_up && !truly_state.display_on) { - gpio_set_value_cansleep(spi_cs, 1); /* cs high */ - - truly_spi_write(0xb9, init_item_v1, sizeof(init_item_v1)); - msleep(20); - truly_spi_write(0xcc, init_item_v2, sizeof(init_item_v2)); - truly_spi_write(0xb1, init_item_v3, sizeof(init_item_v3)); - truly_spi_write(0xb3, init_item_v4, sizeof(init_item_v4)); - truly_spi_write(0xb6, init_item_v5, sizeof(init_item_v5)); - truly_spi_write(0xb4, init_item_v6, sizeof(init_item_v6)); - truly_spi_write(0xc0, init_item_v7, sizeof(init_item_v7)); - truly_spi_write(0xe3, init_item_v8, sizeof(init_item_v8)); - truly_spi_write(0x3a, init_item_v9, sizeof(init_item_v9)); - truly_spi_write(0xe0, init_item_v10, sizeof(init_item_v10)); - truly_spi_write(0x36, init_item_v11, sizeof(init_item_v11)); - truly_spi_write(0x11, NULL, 0); - msleep(150); - truly_spi_write(0x29, NULL, 0); - msleep(25); - - truly_state.display_on = TRUE; - } -} - -static int lcdc_truly_panel_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - - if (!mfd->cont_splash_done) { - mfd->cont_splash_done = 1; - return 0; - } - - /* Configure reset GPIO that drives DAC */ - if (lcdc_truly_pdata->panel_config_gpio) - lcdc_truly_pdata->panel_config_gpio(1); - gpio_set_value_cansleep(gpio_display_reset, 1); - truly_disp_powerup(); - truly_disp_reginit(); - truly_state.disp_initialized = TRUE; - return 0; -} - -static int lcdc_truly_panel_off(struct platform_device *pdev) -{ - if (truly_state.disp_powered_up && truly_state.display_on) { - /* Main panel power off (Pull down reset) */ - gpio_set_value_cansleep(gpio_display_reset, 0); - truly_state.display_on = FALSE; - truly_state.disp_initialized = FALSE; - } - return 0; -} - -static void lcdc_truly_set_backlight(struct msm_fb_data_type *mfd) -{ - int step = 0, i = 0; - unsigned long flags; - int bl_level = mfd->bl_level; - - /* real backlight level, 1 - max, 16 - min, 17 - off */ - bl_level = 17 - bl_level; - - if (bl_level > prev_bl) { - step = bl_level - prev_bl; - if (bl_level == 17) - step--; - } else if (bl_level < prev_bl) { - step = bl_level + 16 - prev_bl; - } else { - pr_info("%s: no change\n", __func__); - return; - } - - if (bl_level == 17) { - /* turn off backlight */ - gpio_set_value(gpio_backlight_en, 0); - } else { - local_irq_save(flags); - - if (prev_bl == 17) { - /* turn on backlight */ - gpio_set_value(gpio_backlight_en, 1); - udelay(30); - } - - /* adjust backlight level */ - for (i = 0; i < step; i++) { - gpio_set_value(gpio_backlight_en, 0); - udelay(1); - gpio_set_value(gpio_backlight_en, 1); - udelay(1); - } - - local_irq_restore(flags); - } - msleep(20); - prev_bl = bl_level; - - return; -} - -static int truly_probe(struct platform_device *pdev) -{ - - if (pdev->id == 0) { - lcdc_truly_pdata = pdev->dev.platform_data; - - if (!lcdc_truly_pdata) - pr_err("%s pdata is null\n", __func__); - - spi_pin_assign(); - return 0; - } - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = truly_probe, - .driver = { - .name = "lcdc_truly_hvga_ips3p2335_pt", - }, -}; - -static struct msm_fb_panel_data truly_panel_data = { - .on = lcdc_truly_panel_on, - .off = lcdc_truly_panel_off, - .set_backlight = lcdc_truly_set_backlight, -}; - -static struct platform_device this_device = { - .name = "lcdc_truly_hvga_ips3p2335_pt", - .id = 1, - .dev = { - .platform_data = &truly_panel_data, - } -}; - -static int __init lcdc_truly_panel_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - ret = msm_fb_detect_client("lcdc_truly_hvga_ips3p2335_pt"); - if (ret) - return 0; - - ret = platform_driver_register(&this_driver); - if (ret) { - pr_err("%s() driver registration failed", __func__); - return ret; - } - - pinfo = &truly_panel_data.panel_info; - pinfo->xres = 320; - pinfo->yres = 480; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LCDC_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - /* 10Mhz mdp_lcdc_pclk and mdp_lcdc_pad_pcl */ - pinfo->clk_rate = 10240000; - pinfo->bl_max = 16; - pinfo->bl_min = 1; - - pinfo->lcdc.h_back_porch = 16; /* hsw = 8 + hbp=16 */ - pinfo->lcdc.h_front_porch = 4; - pinfo->lcdc.h_pulse_width = 8; - pinfo->lcdc.v_back_porch = 7; /* vsw=1 + vbp = 7 */ - pinfo->lcdc.v_front_porch = 3; - pinfo->lcdc.v_pulse_width = 1; - pinfo->lcdc.border_clr = 0; /* blk */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - pinfo->lcdc.hsync_skew = 0; - - ret = platform_device_register(&this_device); - if (ret) { - pr_err("%s not able to register the device\n", __func__); - platform_driver_unregister(&this_driver); - } - return ret; -} - -device_initcall(lcdc_truly_panel_init); diff --git a/drivers/video/msm/lcdc_wxga.c b/drivers/video/msm/lcdc_wxga.c deleted file mode 100644 index dca57dee34d14b5dfe3ee4fccc875c0c3deeaacd..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lcdc_wxga.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2009-2010, 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 "msm_fb.h" - -static int __init lcdc_wxga_init(void) -{ - int ret; - struct msm_panel_info pinfo; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - if (msm_fb_detect_client("lcdc_wxga")) - return 0; -#endif - - pinfo.xres = 1280; - pinfo.yres = 720; - MSM_FB_SINGLE_MODE_PANEL(&pinfo); - pinfo.type = LCDC_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.fb_num = 2; - pinfo.clk_rate = 74250000; - - pinfo.lcdc.h_back_porch = 124; - pinfo.lcdc.h_front_porch = 110; - pinfo.lcdc.h_pulse_width = 136; - pinfo.lcdc.v_back_porch = 19; - pinfo.lcdc.v_front_porch = 5; - pinfo.lcdc.v_pulse_width = 6; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - - ret = lcdc_device_register(&pinfo); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(lcdc_wxga_init); diff --git a/drivers/video/msm/logo.c b/drivers/video/msm/logo.c deleted file mode 100644 index ea65b20803a95de1ada3620978b2371efcda6562..0000000000000000000000000000000000000000 --- a/drivers/video/msm/logo.c +++ /dev/null @@ -1,102 +0,0 @@ -/* drivers/video/msm/logo.c - * - * Show Logo in RLE 565 format - * - * Copyright (C) 2008 Google Incorporated - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include - -#include - -#define fb_width(fb) ((fb)->var.xres) -#define fb_height(fb) ((fb)->var.yres) -#define fb_size(fb) ((fb)->var.xres * (fb)->var.yres * 2) - -static void memset16(void *_ptr, unsigned short val, unsigned count) -{ - unsigned short *ptr = _ptr; - count >>= 1; - while (count--) - *ptr++ = val; -} - -/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ -int load_565rle_image(char *filename, bool bf_supported) -{ - struct fb_info *info; - int fd, count, err = 0; - unsigned max; - unsigned short *data, *bits, *ptr; - - info = registered_fb[0]; - if (!info) { - printk(KERN_WARNING "%s: Can not access framebuffer\n", - __func__); - return -ENODEV; - } - - fd = sys_open(filename, O_RDONLY, 0); - if (fd < 0) { - printk(KERN_WARNING "%s: Can not open %s\n", - __func__, filename); - return -ENOENT; - } - count = sys_lseek(fd, (off_t)0, 2); - if (count <= 0) { - err = -EIO; - goto err_logo_close_file; - } - sys_lseek(fd, (off_t)0, 0); - data = kmalloc(count, GFP_KERNEL); - if (!data) { - printk(KERN_WARNING "%s: Can not alloc data\n", __func__); - err = -ENOMEM; - goto err_logo_close_file; - } - if (sys_read(fd, (char *)data, count) != count) { - err = -EIO; - goto err_logo_free_data; - } - - max = fb_width(info) * fb_height(info); - ptr = data; - if (bf_supported && (info->node == 1 || info->node == 2)) { - err = -EPERM; - pr_err("%s:%d no info->creen_base on fb%d!\n", - __func__, __LINE__, info->node); - goto err_logo_free_data; - } - bits = (unsigned short *)(info->screen_base); - while (count > 3) { - unsigned n = ptr[0]; - if (n > max) - break; - memset16(bits, ptr[1], n << 1); - bits += n; - max -= n; - ptr += 2; - count -= 4; - } - -err_logo_free_data: - kfree(data); -err_logo_close_file: - sys_close(fd); - return err; -} -EXPORT_SYMBOL(load_565rle_image); diff --git a/drivers/video/msm/lvds.c b/drivers/video/msm/lvds.c deleted file mode 100644 index 42dcfb2c9679f894b7b623fdc9b245935cbebe96..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lvds.c +++ /dev/null @@ -1,412 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "mdp4.h" - -#define LVDS_PIXEL_MAP_PATTERN_2 2 - -static int lvds_probe(struct platform_device *pdev); -static int lvds_remove(struct platform_device *pdev); - -static int lvds_off(struct platform_device *pdev); -static int lvds_on(struct platform_device *pdev); - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; - -static struct clk *lvds_clk; - -static struct platform_driver lvds_driver = { - .probe = lvds_probe, - .remove = lvds_remove, - .suspend = NULL, - .resume = NULL, - .shutdown = NULL, - .driver = { - .name = "lvds", - }, -}; - -static struct lcdc_platform_data *lvds_pdata; - -static void lvds_init(struct msm_fb_data_type *mfd) -{ - unsigned int lvds_intf = 0, lvds_phy_cfg0 = 0; - - MDP_OUTP(MDP_BASE + 0xc2034, 0x33); - usleep(1000); - - /* LVDS PHY PLL configuration */ - if (mfd->panel_info.clk_rate == 74250000) { - MDP_OUTP(MDP_BASE + 0xc3000, 0x08); - MDP_OUTP(MDP_BASE + 0xc3004, 0x4c); - MDP_OUTP(MDP_BASE + 0xc3008, 0x30); - MDP_OUTP(MDP_BASE + 0xc300c, 0xc3); - MDP_OUTP(MDP_BASE + 0xc3014, 0x10); - MDP_OUTP(MDP_BASE + 0xc3018, 0x04); - MDP_OUTP(MDP_BASE + 0xc301c, 0x62); - MDP_OUTP(MDP_BASE + 0xc3020, 0x41); - MDP_OUTP(MDP_BASE + 0xc3024, 0x0d); - MDP_OUTP(MDP_BASE + 0xc3028, 0x07); - MDP_OUTP(MDP_BASE + 0xc302c, 0x00); - MDP_OUTP(MDP_BASE + 0xc3030, 0x1c); - MDP_OUTP(MDP_BASE + 0xc3034, 0x01); - MDP_OUTP(MDP_BASE + 0xc3038, 0x00); - MDP_OUTP(MDP_BASE + 0xc3040, 0xC0); - MDP_OUTP(MDP_BASE + 0xc3044, 0x00); - MDP_OUTP(MDP_BASE + 0xc3048, 0x30); - MDP_OUTP(MDP_BASE + 0xc304c, 0x00); - - MDP_OUTP(MDP_BASE + 0xc3000, 0x11); - MDP_OUTP(MDP_BASE + 0xc3064, 0x05); - MDP_OUTP(MDP_BASE + 0xc3050, 0x20); - } else { - MDP_OUTP(MDP_BASE + 0xc3004, 0x8f); - MDP_OUTP(MDP_BASE + 0xc3008, 0x30); - MDP_OUTP(MDP_BASE + 0xc300c, 0xc6); - MDP_OUTP(MDP_BASE + 0xc3014, 0x10); - MDP_OUTP(MDP_BASE + 0xc3018, 0x07); - MDP_OUTP(MDP_BASE + 0xc301c, 0x62); - MDP_OUTP(MDP_BASE + 0xc3020, 0x41); - MDP_OUTP(MDP_BASE + 0xc3024, 0x0d); - } - - MDP_OUTP(MDP_BASE + 0xc3000, 0x01); - /* Wait until LVDS PLL is locked and ready */ - while (!readl_relaxed(MDP_BASE + 0xc3080)) - cpu_relax(); - - writel_relaxed(0x00, mmss_cc_base + 0x0264); - writel_relaxed(0x00, mmss_cc_base + 0x0094); - - writel_relaxed(0x02, mmss_cc_base + 0x00E4); - - writel_relaxed((0x80 | readl_relaxed(mmss_cc_base + 0x00E4)), - mmss_cc_base + 0x00E4); - usleep(1000); - writel_relaxed((~0x80 & readl_relaxed(mmss_cc_base + 0x00E4)), - mmss_cc_base + 0x00E4); - - writel_relaxed(0x05, mmss_cc_base + 0x0094); - writel_relaxed(0x02, mmss_cc_base + 0x0264); - /* Wait until LVDS pixel clock output is enabled */ - mb(); - - if (mfd->panel_info.bpp == 24) { - if (lvds_pdata && - lvds_pdata->lvds_pixel_remap && - lvds_pdata->lvds_pixel_remap()) { - if (lvds_pdata->lvds_pixel_remap() == - LVDS_PIXEL_MAP_PATTERN_2) { - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2014, 0x070A1B1B); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2018, 0x00040506); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc201c, 0x12131B1B); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2020, 0x000B0C0D); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2024, 0x191A1B1B); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2028, 0x00141518); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D3_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc202c, 0x171B1B1B); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D3_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2030, 0x000e0f16); - } else { - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2014, 0x05080001); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2018, 0x00020304); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc201c, 0x1011090a); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2020, 0x000b0c0d); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2024, 0x191a1213); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2028, 0x00141518); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D3_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc202c, 0x171b0607); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D3_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2030, 0x000e0f16); - } - } else { - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2014, 0x03040508); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2018, 0x00000102); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc201c, 0x0c0d1011); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2020, 0x00090a0b); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2024, 0x1518191a); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2028, 0x00121314); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D3_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc202c, 0x0f16171b); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D3_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2030, 0x0006070e); - } - if (mfd->panel_info.lvds.channel_mode == - LVDS_DUAL_CHANNEL_MODE) { - lvds_intf = 0x0003ff80; - lvds_phy_cfg0 = BIT(6) | BIT(7); - if (mfd->panel_info.lvds.channel_swap) - lvds_intf |= BIT(4); - } else { - lvds_intf = 0x00010f84; - lvds_phy_cfg0 = BIT(6); - } - } else if (mfd->panel_info.bpp == 18) { - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2014, 0x03040508); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D0_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2018, 0x00000102); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc201c, 0x0c0d1011); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D1_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2020, 0x00090a0b); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_3_TO_0 */ - MDP_OUTP(MDP_BASE + 0xc2024, 0x1518191a); - /* MDP_LCDC_LVDS_MUX_CTL_FOR_D2_6_TO_4 */ - MDP_OUTP(MDP_BASE + 0xc2028, 0x00121314); - - if (mfd->panel_info.lvds.channel_mode == - LVDS_DUAL_CHANNEL_MODE) { - lvds_intf = 0x00037788; - lvds_phy_cfg0 = BIT(6) | BIT(7); - if (mfd->panel_info.lvds.channel_swap) - lvds_intf |= BIT(4); - } else { - lvds_intf = 0x0001078c; - lvds_phy_cfg0 = BIT(6); - } - } else { - BUG(); - } - - /* MDP_LVDSPHY_CFG0 */ - MDP_OUTP(MDP_BASE + 0xc3100, lvds_phy_cfg0); - /* MDP_LCDC_LVDS_INTF_CTL */ - MDP_OUTP(MDP_BASE + 0xc2000, lvds_intf); - MDP_OUTP(MDP_BASE + 0xc3108, 0x30); - lvds_phy_cfg0 |= BIT(4); - - /* Wait until LVDS PHY registers are configured */ - mb(); - usleep(1); - /* MDP_LVDSPHY_CFG0, enable serialization */ - MDP_OUTP(MDP_BASE + 0xc3100, lvds_phy_cfg0); -} - -static int lvds_off(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - ret = panel_next_off(pdev); - - if (lvds_clk) - clk_disable_unprepare(lvds_clk); - - MDP_OUTP(MDP_BASE + 0xc3100, 0x0); - MDP_OUTP(MDP_BASE + 0xc3000, 0x0); - usleep(10); - - if (lvds_pdata && lvds_pdata->lcdc_power_save) - lvds_pdata->lcdc_power_save(0); - - if (lvds_pdata && lvds_pdata->lcdc_gpio_config) - ret = lvds_pdata->lcdc_gpio_config(0); - - return ret; -} - -static int lvds_on(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd; - unsigned long panel_pixclock_freq = 0; - mfd = platform_get_drvdata(pdev); - - if (lvds_pdata && lvds_pdata->lcdc_get_clk) - panel_pixclock_freq = lvds_pdata->lcdc_get_clk(); - - if (!panel_pixclock_freq) - panel_pixclock_freq = mfd->fbi->var.pixclock; - mfd = platform_get_drvdata(pdev); - - if (lvds_clk) { - mfd->fbi->var.pixclock = clk_round_rate(lvds_clk, - mfd->fbi->var.pixclock); - ret = clk_set_rate(lvds_clk, mfd->fbi->var.pixclock); - if (ret) { - pr_err("%s: Can't set lvds clock to rate %u\n", - __func__, mfd->fbi->var.pixclock); - goto out; - } - clk_prepare_enable(lvds_clk); - } - - if (lvds_pdata && lvds_pdata->lcdc_power_save) - lvds_pdata->lcdc_power_save(1); - if (lvds_pdata && lvds_pdata->lcdc_gpio_config) - ret = lvds_pdata->lcdc_gpio_config(1); - - lvds_init(mfd); - ret = panel_next_on(pdev); - -out: - return ret; -} - -static int lvds_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct fb_info *fbi; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc; - - if (pdev->id == 0) { - lvds_pdata = pdev->dev.platform_data; - - lvds_clk = clk_get(&pdev->dev, "lvds_clk"); - if (IS_ERR_OR_NULL(lvds_clk)) { - pr_err("Couldnt find lvds_clk\n"); - lvds_clk = NULL; - } - return 0; - } - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - - /* - * link to the latest pdev - */ - mfd->pdev = mdp_dev; - mfd->dest = DISPLAY_LCDC; - - /* - * alloc panel device data - */ - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - pr_err("lvds_probe: platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - /* - * data chain - */ - pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; - pdata->on = lvds_on; - pdata->off = lvds_off; - pdata->next = pdev; - - /* - * get/set panel specific fb info - */ - mfd->panel_info = pdata->panel_info; - - if (mfd->index == 0) - mfd->fb_imgType = MSMFB_DEFAULT_TYPE; - else - mfd->fb_imgType = MDP_RGB_565; - - fbi = mfd->fbi; - if (lvds_clk) { - fbi->var.pixclock = clk_round_rate(lvds_clk, - mfd->panel_info.clk_rate); - } - - fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; - fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; - fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; - fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; - fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; - fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; - - /* - * set driver data - */ - platform_set_drvdata(mdp_dev, mfd); - /* - * register in mdp driver - */ - rc = platform_device_add(mdp_dev); - if (rc) - goto lvds_probe_err; - - pdev_list[pdev_list_cnt++] = pdev; - - return 0; - -lvds_probe_err: - platform_device_put(mdp_dev); - return rc; -} - -static int lvds_remove(struct platform_device *pdev) -{ - return 0; -} - -static int lvds_register_driver(void) -{ - return platform_driver_register(&lvds_driver); -} - -static int __init lvds_driver_init(void) -{ - return lvds_register_driver(); -} - -module_init(lvds_driver_init); diff --git a/drivers/video/msm/lvds_chimei_wxga.c b/drivers/video/msm/lvds_chimei_wxga.c deleted file mode 100644 index eae314d8add887510e4bf25a4d8c92fb3f7973dd..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lvds_chimei_wxga.c +++ /dev/null @@ -1,176 +0,0 @@ -/* Copyright (c) 2012-2013, 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 "msm_fb.h" -#include -#include - -#define LVDS_CHIMEI_PWM_FREQ_HZ 300 -#define LVDS_CHIMEI_PWM_PERIOD_USEC (USEC_PER_SEC / LVDS_CHIMEI_PWM_FREQ_HZ) -#define LVDS_CHIMEI_PWM_LEVEL 255 -#define LVDS_CHIMEI_PWM_DUTY_LEVEL \ - (LVDS_CHIMEI_PWM_PERIOD_USEC / LVDS_CHIMEI_PWM_LEVEL) - - -static struct lvds_panel_platform_data *cm_pdata; -static struct platform_device *cm_fbpdev; -static struct pwm_device *bl_lpm; - -static int lvds_chimei_panel_on(struct platform_device *pdev) -{ - return 0; -} - -static int lvds_chimei_panel_off(struct platform_device *pdev) -{ - return 0; -} - -static void lvds_chimei_set_backlight(struct msm_fb_data_type *mfd) -{ - int ret; - static bool is_pwm_enabled; - - pr_debug("%s: back light level %d\n", __func__, mfd->bl_level); - - if (bl_lpm) { - ret = pwm_config(bl_lpm, LVDS_CHIMEI_PWM_DUTY_LEVEL * - mfd->bl_level, LVDS_CHIMEI_PWM_PERIOD_USEC); - if (ret) { - pr_err("pwm_config on lpm failed %d\n", ret); - return; - } - if (mfd->bl_level) { - if (is_pwm_enabled) { - pwm_disable(bl_lpm); - is_pwm_enabled = 0; - } - - ret = pwm_enable(bl_lpm); - if (ret) - pr_err("pwm enable/disable on lpm failed" - "for bl %d\n", mfd->bl_level); - else - is_pwm_enabled = 1; - } else { - pwm_disable(bl_lpm); - is_pwm_enabled = 0; - } - } -} - -static int lvds_chimei_probe(struct platform_device *pdev) -{ - int rc = 0; - - if (pdev->id == 0) { - cm_pdata = pdev->dev.platform_data; - if (cm_pdata == NULL) - pr_err("%s: no PWM gpio specified\n", __func__); - return 0; - } - - if (cm_pdata != NULL) - bl_lpm = pwm_request(cm_pdata->gpio[0], - "backlight"); - - if (bl_lpm == NULL || IS_ERR(bl_lpm)) { - pr_err("%s pwm_request() failed\n", __func__); - bl_lpm = NULL; - } - pr_debug("bl_lpm = %p lpm = %d\n", bl_lpm, - cm_pdata->gpio[0]); - - cm_fbpdev = msm_fb_add_device(pdev); - if (!cm_fbpdev) { - dev_err(&pdev->dev, "failed to add msm_fb device\n"); - rc = -ENODEV; - goto probe_exit; - } - -probe_exit: - return rc; -} - -static struct platform_driver this_driver = { - .probe = lvds_chimei_probe, - .driver = { - .name = "lvds_chimei_wxga", - }, -}; - -static struct msm_fb_panel_data lvds_chimei_panel_data = { - .on = lvds_chimei_panel_on, - .off = lvds_chimei_panel_off, - .set_backlight = lvds_chimei_set_backlight, -}; - -static struct platform_device this_device = { - .name = "lvds_chimei_wxga", - .id = 1, - .dev = { - .platform_data = &lvds_chimei_panel_data, - } -}; - -static int __init lvds_chimei_wxga_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - if (msm_fb_detect_client("lvds_chimei_wxga")) - return 0; - - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &lvds_chimei_panel_data.panel_info; - pinfo->xres = 1366; - pinfo->yres = 768; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LVDS_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - pinfo->fb_num = 2; - pinfo->clk_rate = 79400000; - pinfo->bl_max = 255; - pinfo->bl_min = 1; - - /* - * this panel is operated by de, - * vsycn and hsync are ignored - */ - pinfo->lcdc.h_back_porch = 0; - pinfo->lcdc.h_front_porch = 194; - pinfo->lcdc.h_pulse_width = 40; - pinfo->lcdc.v_back_porch = 0; - pinfo->lcdc.v_front_porch = 38; - pinfo->lcdc.v_pulse_width = 20; - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; - pinfo->lvds.channel_mode = LVDS_SINGLE_CHANNEL_MODE; - - /* Set border color, padding only for reducing active display region */ - pinfo->lcdc.border_clr = 0x0; - pinfo->lcdc.xres_pad = 0; - pinfo->lcdc.yres_pad = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - - return ret; -} - -module_init(lvds_chimei_wxga_init); diff --git a/drivers/video/msm/lvds_frc_fhd.c b/drivers/video/msm/lvds_frc_fhd.c deleted file mode 100644 index fd4d2c52788cacbe7afb48a1ef6a313ac5ac36a5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/lvds_frc_fhd.c +++ /dev/null @@ -1,201 +0,0 @@ -/* Copyright (c) 2012, 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 -#include "msm_fb.h" - -static struct lvds_panel_platform_data *frc_pdata; -static struct platform_device *frc_fbpdev; -static int gpio_update; /* 268 */ -static int gpio_reset; /* 269 */ -static int gpio_pwr; /* 270 */ - -static int lvds_frc_panel_on(struct platform_device *pdev) -{ - int ret; - - ret = gpio_request(gpio_pwr, "frc_pwr"); - if (ret) { - pr_err("%s: gpio_pwr=%d, gpio_request failed\n", - __func__, gpio_pwr); - goto panel_on_exit; - } - ret = gpio_request(gpio_update, "frc_update"); - if (ret) { - pr_err("%s: gpio_update=%d, gpio_request failed\n", - __func__, gpio_update); - goto panel_on_exit1; - } - ret = gpio_request(gpio_reset, "frc_reset"); - if (ret) { - pr_err("%s: gpio_reset=%d, gpio_request failed\n", - __func__, gpio_reset); - goto panel_on_exit2; - } - - gpio_direction_output(gpio_reset, 1); - gpio_direction_output(gpio_pwr, 0); - gpio_direction_output(gpio_update, 0); - usleep(1000); - gpio_direction_output(gpio_reset, 0); - usleep(1000); - gpio_direction_output(gpio_pwr, 1); - usleep(1000); - gpio_direction_output(gpio_update, 1); - usleep(1000); - gpio_direction_output(gpio_reset, 1); - usleep(1000); - gpio_free(gpio_reset); -panel_on_exit2: - gpio_free(gpio_update); -panel_on_exit1: - gpio_free(gpio_pwr); -panel_on_exit: - return ret; -} - -static int lvds_frc_panel_off(struct platform_device *pdev) -{ - int ret; - - ret = gpio_request(gpio_pwr, "frc_pwr"); - if (ret) { - pr_err("%s: gpio_pwr=%d, gpio_request failed\n", - __func__, gpio_pwr); - goto panel_off_exit; - } - ret = gpio_request(gpio_update, "frc_update"); - if (ret) { - pr_err("%s: gpio_update=%d, gpio_request failed\n", - __func__, gpio_update); - goto panel_off_exit1; - } - ret = gpio_request(gpio_reset, "frc_reset"); - if (ret) { - pr_err("%s: gpio_reset=%d, gpio_request failed\n", - __func__, gpio_reset); - goto panel_off_exit2; - } - gpio_direction_output(gpio_reset, 0); - usleep(1000); - gpio_direction_output(gpio_update, 0); - usleep(1000); - gpio_direction_output(gpio_pwr, 0); - usleep(1000); - gpio_free(gpio_reset); -panel_off_exit2: - gpio_free(gpio_update); -panel_off_exit1: - gpio_free(gpio_pwr); -panel_off_exit: - return ret; -} - -static int lvds_frc_probe(struct platform_device *pdev) -{ - int rc = 0; - - if (pdev->id == 0) { - frc_pdata = pdev->dev.platform_data; - if (frc_pdata != NULL) { - gpio_update = frc_pdata->gpio[0]; - gpio_reset = frc_pdata->gpio[1]; - gpio_pwr = frc_pdata->gpio[2]; - pr_info("%s: power=%d update=%d reset=%d\n", - __func__, gpio_pwr, gpio_update, gpio_reset); - } - return 0; - } - - frc_fbpdev = msm_fb_add_device(pdev); - if (!frc_fbpdev) { - dev_err(&pdev->dev, "failed to add msm_fb device\n"); - rc = -ENODEV; - goto probe_exit; - } - -probe_exit: - return rc; -} - -static struct platform_driver this_driver = { - .probe = lvds_frc_probe, - .driver = { - .name = "lvds_frc_fhd", - }, -}; - -static struct msm_fb_panel_data lvds_frc_panel_data = { - .on = lvds_frc_panel_on, - .off = lvds_frc_panel_off, -}; - -static struct platform_device this_device = { - .name = "lvds_frc_fhd", - .id = 1, - .dev = { - .platform_data = &lvds_frc_panel_data, - } -}; - -static int __init lvds_frc_fhd_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - if (msm_fb_detect_client("lvds_frc_fhd")) - return 0; - - ret = platform_driver_register(&this_driver); - if (ret) - return ret; - - pinfo = &lvds_frc_panel_data.panel_info; - pinfo->xres = 1920; - pinfo->yres = 1080; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = LVDS_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - pinfo->fb_num = 2; - pinfo->clk_rate = 74250000; - pinfo->bl_max = 255; - pinfo->bl_min = 1; - - /* - * use hdmi 1080p60 setting, for dual channel mode, - * horizontal length is half. - */ - pinfo->lcdc.h_back_porch = 148/2; - pinfo->lcdc.h_front_porch = 88/2; - pinfo->lcdc.h_pulse_width = 44/2; - pinfo->lcdc.v_back_porch = 36; - pinfo->lcdc.v_front_porch = 4; - pinfo->lcdc.v_pulse_width = 5; - pinfo->lcdc.underflow_clr = 0xff; - pinfo->lcdc.hsync_skew = 0; - pinfo->lvds.channel_mode = LVDS_DUAL_CHANNEL_MODE; - pinfo->lcdc.is_sync_active_high = TRUE; - - /* Set border color, padding only for reducing active display region */ - pinfo->lcdc.border_clr = 0x0; - pinfo->lcdc.xres_pad = 0; - pinfo->lcdc.yres_pad = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - - return ret; -} - -module_init(lvds_frc_fhd_init); diff --git a/drivers/video/msm/mddi.c b/drivers/video/msm/mddi.c index a53a7b51fdc2beed0850948763d536254f719b94..bf5322087ae2bb8b60a428523d2752cbf6ef9393 100644 --- a/drivers/video/msm/mddi.c +++ b/drivers/video/msm/mddi.c @@ -31,9 +31,6 @@ #include #include #include -#include "msm_fb.h" -#include "mddihosti.h" -#include "mddihost.h" #include #include diff --git a/drivers/video/msm/mddi_ext.c b/drivers/video/msm/mddi_ext.c deleted file mode 100644 index a35ac13031a2106b086683248155cda552009704..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_ext.c +++ /dev/null @@ -1,352 +0,0 @@ -/* Copyright (c) 2008-2009, 2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "mddihosti.h" - -static int mddi_ext_probe(struct platform_device *pdev); -static int mddi_ext_remove(struct platform_device *pdev); - -static int mddi_ext_off(struct platform_device *pdev); -static int mddi_ext_on(struct platform_device *pdev); - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; - -static int mddi_ext_suspend(struct platform_device *pdev, pm_message_t state); -static int mddi_ext_resume(struct platform_device *pdev); - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void mddi_ext_early_suspend(struct early_suspend *h); -static void mddi_ext_early_resume(struct early_suspend *h); -#endif - -static int mddi_ext_runtime_suspend(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: suspending...\n"); - return 0; -} - -static int mddi_ext_runtime_resume(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: resuming...\n"); - return 0; -} - -static int mddi_ext_runtime_idle(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: idling...\n"); - return 0; -} -static struct dev_pm_ops mddi_ext_dev_pm_ops = { - .runtime_suspend = mddi_ext_runtime_suspend, - .runtime_resume = mddi_ext_runtime_resume, - .runtime_idle = mddi_ext_runtime_idle, -}; - -static struct platform_driver mddi_ext_driver = { - .probe = mddi_ext_probe, - .remove = mddi_ext_remove, -#ifndef CONFIG_HAS_EARLYSUSPEND -#ifdef CONFIG_PM - .suspend = mddi_ext_suspend, - .resume = mddi_ext_resume, -#endif -#endif - .resume_early = NULL, - .resume = NULL, - .shutdown = NULL, - .driver = { - .name = "mddi_ext", - .pm = &mddi_ext_dev_pm_ops, - }, -}; - -static struct clk *mddi_ext_clk; -static struct clk *mddi_ext_pclk; -static struct mddi_platform_data *mddi_ext_pdata; - -extern int int_mddi_ext_flag; - -static int mddi_ext_off(struct platform_device *pdev) -{ - int ret = 0; - - ret = panel_next_off(pdev); - mddi_host_stop_ext_display(); - pm_runtime_put(&pdev->dev); - return ret; -} - -static int mddi_ext_on(struct platform_device *pdev) -{ - int ret = 0; - u32 clk_rate; - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - pm_runtime_get(&pdev->dev); - clk_rate = mfd->fbi->var.pixclock; - clk_rate = min(clk_rate, mfd->panel_info.clk_max); - - if (mddi_ext_pdata && - mddi_ext_pdata->mddi_sel_clk && - mddi_ext_pdata->mddi_sel_clk(&clk_rate)) - printk(KERN_ERR - "%s: can't select mddi io clk targate rate = %d\n", - __func__, clk_rate); - - clk_rate = clk_round_rate(mddi_ext_clk, clk_rate); - if (clk_set_rate(mddi_ext_clk, clk_rate) < 0) - printk(KERN_ERR "%s: clk_set_rate failed\n", - __func__); - - mddi_host_start_ext_display(); - ret = panel_next_on(pdev); - - return ret; -} - -static int mddi_ext_resource_initialized; - -static int mddi_ext_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc; - resource_size_t size ; - u32 clk_rate; - - if ((pdev->id == 0) && (pdev->num_resources >= 0)) { - mddi_ext_pdata = pdev->dev.platform_data; - mddi_ext_clk = clk_get(&pdev->dev, "core_clk"); - if (IS_ERR(mddi_ext_clk)) { - pr_err("can't find emdh_clk\n"); - return PTR_ERR(mddi_ext_clk); - } - clk_prepare_enable(mddi_ext_clk); - - mddi_ext_pclk = clk_get(&pdev->dev, "iface_clk"); - if (IS_ERR(mddi_ext_pclk)) - mddi_ext_pclk = NULL; - else - clk_prepare_enable(mddi_ext_pclk); - - size = resource_size(&pdev->resource[0]); - msm_emdh_base = ioremap(pdev->resource[0].start, size); - - MSM_FB_INFO("external mddi base address = 0x%x\n", - pdev->resource[0].start); - - if (unlikely(!msm_emdh_base)) - return -ENOMEM; - - mddi_ext_resource_initialized = 1; - return 0; - } - - if (!mddi_ext_resource_initialized) - return -EPERM; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - - /* - * link to the latest pdev - */ - mfd->pdev = mdp_dev; - mfd->dest = DISPLAY_EXT_MDDI; - - /* - * alloc panel device data - */ - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - printk(KERN_ERR "mddi_ext_probe: platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - /* - * data chain - */ - pdata = mdp_dev->dev.platform_data; - pdata->on = mddi_ext_on; - pdata->off = mddi_ext_off; - pdata->next = pdev; - - /* - * get/set panel specific fb info - */ - mfd->panel_info = pdata->panel_info; - mfd->fb_imgType = MDP_RGB_565; - - clk_rate = mfd->panel_info.clk_max; - if (mddi_ext_pdata && - mddi_ext_pdata->mddi_sel_clk && - mddi_ext_pdata->mddi_sel_clk(&clk_rate)) - printk(KERN_ERR - "%s: can't select mddi io clk targate rate = %d\n", - __func__, clk_rate); - - if (clk_set_max_rate(mddi_ext_clk, clk_rate) < 0) - printk(KERN_ERR "%s: clk_set_max_rate failed\n", __func__); - mfd->panel_info.clk_rate = mfd->panel_info.clk_min; - - /* - * set driver data - */ - platform_set_drvdata(mdp_dev, mfd); - rc = pm_runtime_set_active(&pdev->dev); - if (rc < 0) - printk(KERN_ERR "pm_runtime: fail to set active\n"); - - rc = 0; - pm_runtime_enable(&pdev->dev); - /* - * register in mdp driver - */ - rc = platform_device_add(mdp_dev); - if (rc) - goto mddi_ext_probe_err; - - pdev_list[pdev_list_cnt++] = pdev; - -#ifdef CONFIG_HAS_EARLYSUSPEND - mfd->mddi_ext_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; - mfd->mddi_ext_early_suspend.suspend = mddi_ext_early_suspend; - mfd->mddi_ext_early_suspend.resume = mddi_ext_early_resume; - register_early_suspend(&mfd->mddi_ext_early_suspend); -#endif - - return 0; - -mddi_ext_probe_err: - platform_device_put(mdp_dev); - return rc; -} - -static int mddi_ext_is_in_suspend; - -static int mddi_ext_suspend(struct platform_device *pdev, pm_message_t state) -{ - if (mddi_ext_is_in_suspend) - return 0; - - mddi_ext_is_in_suspend = 1; - - clk_disable_unprepare(mddi_ext_clk); - if (mddi_ext_pclk) - clk_disable_unprepare(mddi_ext_pclk); - - disable_irq(INT_MDDI_EXT); - - return 0; -} - -static int mddi_ext_resume(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - - if (!mddi_ext_is_in_suspend) - return 0; - - mddi_ext_is_in_suspend = 0; - enable_irq(INT_MDDI_EXT); - - clk_prepare_enable(mddi_ext_clk); - if (mddi_ext_pclk) - clk_prepare_enable(mddi_ext_pclk); - - return 0; -} - -#ifdef CONFIG_HAS_EARLYSUSPEND -static void mddi_ext_early_suspend(struct early_suspend *h) -{ - pm_message_t state; - struct msm_fb_data_type *mfd = container_of(h, struct msm_fb_data_type, - mddi_ext_early_suspend); - - state.event = PM_EVENT_SUSPEND; - mddi_ext_suspend(mfd->pdev, state); -} - -static void mddi_ext_early_resume(struct early_suspend *h) -{ - struct msm_fb_data_type *mfd = container_of(h, struct msm_fb_data_type, - mddi_ext_early_suspend); - mddi_ext_resume(mfd->pdev); -} -#endif - -static int mddi_ext_remove(struct platform_device *pdev) -{ - pm_runtim_disable(&pdev->dev); - iounmap(msm_emdh_base); - return 0; -} - -static int mddi_ext_register_driver(void) -{ - return platform_driver_register(&mddi_ext_driver); -} - -static int __init mddi_ext_driver_init(void) -{ - int ret; - - ret = mddi_ext_register_driver(); - if (ret) { - printk(KERN_ERR "mddi_ext_register_driver() failed!\n"); - return ret; - } - mddi_init(); - - return ret; -} - -module_init(mddi_ext_driver_init); diff --git a/drivers/video/msm/mddi_ext_lcd.c b/drivers/video/msm/mddi_ext_lcd.c deleted file mode 100644 index aa4d48425995ca4d35494158b67d34743c254b44..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_ext_lcd.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) 2008-2010, 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 "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" - -static int mddi_ext_lcd_on(struct platform_device *pdev); -static int mddi_ext_lcd_off(struct platform_device *pdev); - -static int mddi_ext_lcd_on(struct platform_device *pdev) -{ - return 0; -} - -static int mddi_ext_lcd_off(struct platform_device *pdev) -{ - return 0; -} - -static int __init mddi_ext_lcd_probe(struct platform_device *pdev) -{ - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = mddi_ext_lcd_probe, - .driver = { - .name = "extmddi_svga", - }, -}; - -static struct msm_fb_panel_data mddi_ext_lcd_panel_data = { - .panel_info.xres = 800, - .panel_info.yres = 600, - .panel_info.mode2_xres = 0; - .panel_info.mode2_yres = 0; - .panel_info.mode2_bpp = 0; - .panel_info.type = EXT_MDDI_PANEL, - .panel_info.pdest = DISPLAY_1, - .panel_info.wait_cycle = 0, - .panel_info.bpp = 18, - .panel_info.fb_num = 2, - .panel_info.clk_rate = 122880000, - .panel_info.clk_min = 120000000, - .panel_info.clk_max = 125000000, - .on = mddi_ext_lcd_on, - .off = mddi_ext_lcd_off, -}; - -static struct platform_device this_device = { - .name = "extmddi_svga", - .id = 0, - .dev = { - .platform_data = &mddi_ext_lcd_panel_data, - } -}; - -static int __init mddi_ext_lcd_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - - ret = platform_driver_register(&this_driver); - if (!ret) { - pinfo = &mddi_ext_lcd_panel_data.panel_info; - pinfo->lcd.vsync_enable = FALSE; - pinfo->mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - } - - return ret; -} - -module_init(mddi_ext_lcd_init); diff --git a/drivers/video/msm/mddi_orise.c b/drivers/video/msm/mddi_orise.c deleted file mode 100644 index bf9f1fa10e98c5ac7a66c58fe97336b2d665f685..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_orise.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright (c) 2010, 2012 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 "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" - -#define MDDI_ORISE_1_2 1 -#define write_client_reg(__X, __Y, __Z) {\ - mddi_queue_register_write(__X, __Y, TRUE, 0);\ -} - -static int mddi_orise_lcd_on(struct platform_device *pdev); -static int mddi_orise_lcd_off(struct platform_device *pdev); -static int __init mddi_orise_probe(struct platform_device *pdev); -static int __init mddi_orise_init(void); - -/* function used to turn on the display */ -static void mddi_orise_prim_lcd_init(void) -{ - write_client_reg(0x00110000, 0, TRUE); - mddi_wait(150); - write_client_reg(0x00290000, 0, TRUE); -} - -static struct platform_driver this_driver = { - .driver = { - .name = "mddi_orise", - }, -}; - -static struct msm_fb_panel_data mddi_orise_panel_data = { - .on = mddi_orise_lcd_on, - .off = mddi_orise_lcd_off, -}; - -static struct platform_device this_device = { - .name = "mddi_orise", - .id = MDDI_ORISE_1_2, - .dev = { - .platform_data = &mddi_orise_panel_data, - } -}; - -static int mddi_orise_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - mfd = platform_get_drvdata(pdev); - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - mddi_orise_prim_lcd_init(); - - return 0; -} - -static int mddi_orise_lcd_off(struct platform_device *pdev) -{ - return 0; -} - -static int __init mddi_orise_probe(struct platform_device *pdev) -{ - msm_fb_add_device(pdev); - return 0; -} - -static int __init mddi_orise_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - u32 id; - ret = msm_fb_detect_client("mddi_orise"); - if (ret == -ENODEV) - return 0; - - if (ret) { - id = mddi_get_client_id(); - if (((id >> 16) != 0xbe8d) || ((id & 0xffff) != 0x8031)) - return 0; - } -#endif - ret = platform_driver_probe(&this_driver, mddi_orise_probe); - if (!ret) { - pinfo = &mddi_orise_panel_data.panel_info; - pinfo->xres = 480; - pinfo->yres = 800; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = MDDI_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->mddi.is_type1 = TRUE; - pinfo->mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->clk_rate = 192000000; - pinfo->clk_min = 192000000; - pinfo->clk_max = 192000000; - pinfo->lcd.rev = 2; - pinfo->lcd.vsync_enable = FALSE; - pinfo->lcd.refx100 = 6050; - pinfo->lcd.v_back_porch = 2; - pinfo->lcd.v_front_porch = 2; - pinfo->lcd.v_pulse_width = 105; - pinfo->lcd.hw_vsync_mode = TRUE; - pinfo->lcd.vsync_notifier_period = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - } - return ret; -} -module_init(mddi_orise_init); diff --git a/drivers/video/msm/mddi_prism.c b/drivers/video/msm/mddi_prism.c deleted file mode 100644 index c85b800a18460e4d2fc5ed32e06b2b7affd61bfb..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_prism.c +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright (c) 2008-2010, 2012 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 "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" - -static int prism_lcd_on(struct platform_device *pdev); -static int prism_lcd_off(struct platform_device *pdev); - -static int prism_lcd_on(struct platform_device *pdev) -{ - /* Set the MDP pixel data attributes for Primary Display */ - mddi_host_write_pix_attr_reg(0x00C3); - - return 0; -} - -static int prism_lcd_off(struct platform_device *pdev) -{ - return 0; -} - -static int prism_probe(struct platform_device *pdev) -{ - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = prism_probe, - .driver = { - .name = "mddi_prism_wvga", - }, -}; - -static struct msm_fb_panel_data prism_panel_data = { - .on = prism_lcd_on, - .off = prism_lcd_off, -}; - -static struct platform_device this_device = { - .name = "mddi_prism_wvga", - .id = 0, - .dev = { - .platform_data = &prism_panel_data, - } -}; - -static int __init prism_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - u32 id; - - ret = msm_fb_detect_client("mddi_prism_wvga"); - if (ret == -ENODEV) - return 0; - - if (ret) { - id = mddi_get_client_id(); - - if (((id >> 16) != 0x4474) || ((id & 0xffff) == 0x8960)) - return 0; - } -#endif - ret = platform_driver_register(&this_driver); - if (!ret) { - pinfo = &prism_panel_data.panel_info; - pinfo->xres = 800; - pinfo->yres = 480; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = MDDI_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - pinfo->wait_cycle = 0; - pinfo->mddi.is_type1 = TRUE; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->clk_rate = 153600000; - pinfo->clk_min = 140000000; - pinfo->clk_max = 160000000; - pinfo->lcd.vsync_enable = TRUE; - pinfo->lcd.refx100 = 6050; - pinfo->lcd.v_back_porch = 23; - pinfo->lcd.v_front_porch = 20; - pinfo->lcd.v_pulse_width = 105; - pinfo->lcd.hw_vsync_mode = TRUE; - pinfo->lcd.vsync_notifier_period = 0; - - ret = platform_device_register(&this_device); - if (ret) - platform_driver_unregister(&this_driver); - } - - return ret; -} - -module_init(prism_init); diff --git a/drivers/video/msm/mddi_quickvx.c b/drivers/video/msm/mddi_quickvx.c deleted file mode 100644 index 10a48d8e6282deec04709669bd217d70f9e1d886..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_quickvx.c +++ /dev/null @@ -1,646 +0,0 @@ -/* Copyright (c) 2010, 2012 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 -#include "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" - -/* WVGA Primary Display */ -#define MDDI_QUICKVX_1_2 1 -/* MDDI Manufacturer Code */ -#define QUICKVX_MDDI_MFR_CODE 0xc583 -/* MDDI Product Code */ -#define QUICKVX_MDDI_PRD_CODE 0x5800 - -/* Register Address Maps */ -/* MDDI Address Anti-fuse values for bits [31:22] */ -#define QUICKVX_ADDR_31_22_AF (0X000 << 22) - -/* MDDI Address Maps */ -/* VEE Block Address Base */ -#define QUICKVX_VEE_BASE (QUICKVX_ADDR_31_22_AF | 0x00000000) -/* SPI Block Address Base */ -#define QUICKVX_SPI_BASE (QUICKVX_ADDR_31_22_AF | 0x00010000) -/* Clock and Reset (CAR) Address Base */ -#define QUICKVX_CAR_BASE (QUICKVX_ADDR_31_22_AF | 0x00020000) -/* Register Control Block (RCB) Address Base */ -#define QUICKVX_RCB_BASE (QUICKVX_ADDR_31_22_AF | 0x00030000) -/* Cellular RAM Address Base */ -#define QUICKVX_CELLRAM_BASE (QUICKVX_ADDR_31_22_AF | 0x00100000) -/* FB through A2F Address Base */ -#define QUICKVX_FB_A2F_BASE (QUICKVX_ADDR_31_22_AF | 0x00200000) - - -/*************************************************** - * Common Registers in Register Control Block (RCB) Registers - ***************************************************/ - /* CellRAM Configuration RCR Register */ -#define QUICKVX_RCB_RCR_REG (QUICKVX_RCB_BASE | 0x00000000) -/* Image Effect Register */ -#define QUICKVX_RCB_IER_REG (QUICKVX_RCB_BASE | 0x00000004) -/* Row Number Register */ -#define QUICKVX_RCB_ROWNUM_REG (QUICKVX_RCB_BASE | 0x00000008) -/* TCON Timing0 Register */ -#define QUICKVX_RCB_TCON0_REG (QUICKVX_RCB_BASE | 0x0000000C) -/* TCON Timing1 Register */ -#define QUICKVX_RCB_TCON1_REG (QUICKVX_RCB_BASE | 0x00000010) -/* TCON Timing2 Register */ -#define QUICKVX_RCB_TCON2_REG (QUICKVX_RCB_BASE | 0x00000014) -/* PWM Control Register */ -#define QUICKVX_RCB_PWMC_REG (QUICKVX_RCB_BASE | 0x00000018) -/* PWM Width Register */ -#define QUICKVX_RCB_PWMW_REG (QUICKVX_RCB_BASE | 0x0000001C) -/* VEE Configuration Register */ -#define QUICKVX_RCB_VEECONF_REG (QUICKVX_RCB_BASE | 0x00000020) -/* CellRAM Configuration BCR Register */ -#define QUICKVX_RCB_CELLBCR_REG (QUICKVX_RCB_BASE | 0x00000024) -/* CellRAM Configuration Control Register */ -#define QUICKVX_RCB_CELLCC_REG (QUICKVX_RCB_BASE | 0x00000028) -/* Use Case Register */ -#define QUICKVX_RCB_USECASE_REG (QUICKVX_RCB_BASE | 0x00000100) -/* Video Parameter Register */ -#define QUICKVX_RCB_VPARM_REG (QUICKVX_RCB_BASE | 0x00000104) -/* MDDI Client Wake-up Register */ -#define QUICKVX_RCB_MCW_REG (QUICKVX_RCB_BASE | 0x00000108) -/* Burst Length Register */ -#define QUICKVX_RCB_BURSTLN_REG (QUICKVX_RCB_BASE | 0x0000010C) -/* Display Attributes Register */ -#define QUICKVX_RCB_DISPATTR_REG (QUICKVX_RCB_BASE | 0x00000110) -/* Error Status Register */ -#define QUICKVX_RCB_ERRSTAT_REG (QUICKVX_RCB_BASE | 0x00000114) -/* Error Mask Register */ -#define QUICKVX_RCB_ERRMSK_REG (QUICKVX_RCB_BASE | 0x00000118) -/* MDDI ASSP FIFO Overflow Address Register */ -#define QUICKVX_RCB_ASSPFOA_REG (QUICKVX_RCB_BASE | 0x0000011C) -/* MDDI Fabric FIFO Overflow Address Register */ -#define QUICKVX_RCB_FABFOA_REG (QUICKVX_RCB_BASE | 0x00000120) -/* Incoming RGB FIFO Overflow Address Register */ -#define QUICKVX_RCB_IRFOA_REG (QUICKVX_RCB_BASE | 0x00000124) -/* SPI Overflow Address Register */ -#define QUICKVX_RCB_SPIOA_REG (QUICKVX_RCB_BASE | 0x00000128) -/* Ping Buffer Address Register */ -#define QUICKVX_RCB_PINGBA_REG (QUICKVX_RCB_BASE | 0x0000012C) -/* Pong Buffer Address Register */ -#define QUICKVX_RCB_PONGBA_REG (QUICKVX_RCB_BASE | 0x00000130) -/* Configuration Done Register */ -#define QUICKVX_RCB_CONFDONE_REG (QUICKVX_RCB_BASE | 0x00000134) -/* FIFO Flush Register */ -#define QUICKVX_RCB_FFLUSH_REG (QUICKVX_RCB_BASE | 0x00000138) - - -/*************************************************** - * SPI Block Registers - ***************************************************/ -/* SPI Rx0 Register */ -#define QUICKVX_SPI_RX0_REG (QUICKVX_SPI_BASE | 0x00000000) -/* SPI Rx1 Register */ -#define QUICKVX_SPI_RX1_REG (QUICKVX_SPI_BASE | 0x00000004) -/* SPI Rx2 Register */ -#define QUICKVX_SPI_RX2_REG (QUICKVX_SPI_BASE | 0x00000008) -/* SPI Rx3 Register */ -#define QUICKVX_SPI_RX3_REG (QUICKVX_SPI_BASE | 0x0000000C) -/* SPI Rx4 Register */ -#define QUICKVX_SPI_RX4_REG (QUICKVX_SPI_BASE | 0x00000010) -/* SPI Rx5 Register */ -#define QUICKVX_SPI_RX5_REG (QUICKVX_SPI_BASE | 0x00000014) -/* SPI Rx6 Register */ -#define QUICKVX_SPI_RX6_REG (QUICKVX_SPI_BASE | 0x00000018) -/* SPI Rx7 Register */ -#define QUICKVX_SPI_RX7_REG (QUICKVX_SPI_BASE | 0x0000001C) -/* SPI Tx0 Register */ -#define QUICKVX_SPI_TX0_REG (QUICKVX_SPI_BASE | 0x00000020) -/* SPI Tx1 Register */ -#define QUICKVX_SPI_TX1_REG (QUICKVX_SPI_BASE | 0x00000024) -/* SPI Tx2 Register */ -#define QUICKVX_SPI_TX2_REG (QUICKVX_SPI_BASE | 0x00000028) -/* SPI Tx3 Register */ -#define QUICKVX_SPI_TX3_REG (QUICKVX_SPI_BASE | 0x0000002C) -/* SPI Tx4 Register */ -#define QUICKVX_SPI_TX4_REG (QUICKVX_SPI_BASE | 0x00000030) -/* SPI Tx5 Register */ -#define QUICKVX_SPI_TX5_REG (QUICKVX_SPI_BASE | 0x00000034) -/* SPI Tx6 Register */ -#define QUICKVX_SPI_TX6_REG (QUICKVX_SPI_BASE | 0x00000038) -/* SPI Tx7 Register */ -#define QUICKVX_SPI_TX7_REG (QUICKVX_SPI_BASE | 0x0000003C) -/* SPI Control Register */ -#define QUICKVX_SPI_CTRL_REG (QUICKVX_SPI_BASE | 0x00000040) -/* SPI Transfer Length Register */ -#define QUICKVX_SPI_TLEN_REG (QUICKVX_SPI_BASE | 0x00000044) - - -/*************************************************** - * Clock and Reset (CAR) Block Registers - ***************************************************/ -/* ASSP Global Clock Enable Register */ -#define QUICKVX_CAR_ASSP_GCE_REG (QUICKVX_CAR_BASE | 0x00000000) -/* VLP Control1 Register */ -#define QUICKVX_CAR_VLPCTRL1_REG (QUICKVX_CAR_BASE | 0x00000004) -/* VLP Control2 Register */ -#define QUICKVX_CAR_VLPCTRL2_REG (QUICKVX_CAR_BASE | 0x00000008) -/* Clock Selection Register */ -#define QUICKVX_CAR_CLKSEL_REG (QUICKVX_CAR_BASE | 0x0000000C) -/* PLL Control Register */ -#define QUICKVX_CAR_PLLCTRL_REG (QUICKVX_CAR_BASE | 0x00000010) -/* PLL Clock Ratio Register */ -#define QUICKVX_CAR_PLLCLKRATIO_REG (QUICKVX_CAR_BASE | 0x00000014) - - -/*************************************************** - * VEE Block Registers - ***************************************************/ -/* VEE Control Register */ -#define QUICKVX_VEE_VEECTRL_REG (QUICKVX_VEE_BASE | 0x00000000) -/* Strength Register */ -#define QUICKVX_VEE_STRENGTH_REG (QUICKVX_VEE_BASE | 0x0000000C) -/* Variance Register */ -#define QUICKVX_VEE_VARIANCE_REG (QUICKVX_VEE_BASE | 0x00000010) -/* Slope Register */ -#define QUICKVX_VEE_SLOPE_REG (QUICKVX_VEE_BASE | 0x00000014) -/* Sharpen Control0 Register */ -#define QUICKVX_VEE_SHRPCTRL0_REG (QUICKVX_VEE_BASE | 0x0000001C) -/* Sharpen Control1 Register */ -#define QUICKVX_VEE_SHRPCTRL1_REG (QUICKVX_VEE_BASE | 0x00000020) -/* Upper Horizontal Positon Register */ -#define QUICKVX_VEE_UHPOS_REG (QUICKVX_VEE_BASE | 0x00000024) -/* Lower Horizontal Positon Register */ -#define QUICKVX_VEE_LHPOS_REG (QUICKVX_VEE_BASE | 0x00000028) -/* Upper Vertical Positon Register */ -#define QUICKVX_VEE_UVPOS_REG (QUICKVX_VEE_BASE | 0x0000002C) -/* Lower Vertical Positon Register */ -#define QUICKVX_VEE_LVPOS_REG (QUICKVX_VEE_BASE | 0x00000030) -/* Upper Frame Width Register */ -#define QUICKVX_VEE_UFWDTH_REG (QUICKVX_VEE_BASE | 0x00000034) -/* Lower Frame Width Register */ -#define QUICKVX_VEE_LFWDTH_REG (QUICKVX_VEE_BASE | 0x00000038) -/* Upper Frame Height Register */ -#define QUICKVX_VEE_UFHGHT_REG (QUICKVX_VEE_BASE | 0x0000003C) -/* Lower Frame Height Register */ -#define QUICKVX_VEE_LFHGHT_REG (QUICKVX_VEE_BASE | 0x00000040) -/* Control0 Register */ -#define QUICKVX_VEE_CTRL0_REG (QUICKVX_VEE_BASE | 0x00000044) -/* Control1 Register */ -#define QUICKVX_VEE_CTRL1_REG (QUICKVX_VEE_BASE | 0x00000048) -/* Video Enhancement Enable Register */ -#define QUICKVX_VEE_VDOEEN_REG (QUICKVX_VEE_BASE | 0x0000004C) -/* Black Level Register */ -#define QUICKVX_VEE_BLCKLEV_REG (QUICKVX_VEE_BASE | 0x00000050) -/* White Level Register */ -#define QUICKVX_VEE_WHTLEV_REG (QUICKVX_VEE_BASE | 0x00000054) -/* Amplification Limits Register */ -#define QUICKVX_VEE_AMPLMTS_REG (QUICKVX_VEE_BASE | 0x00000060) -/* Dithering Mode Register */ -#define QUICKVX_VEE_DITHMOD_REG (QUICKVX_VEE_BASE | 0x00000064) -/* Upper Look-up Data Register */ -#define QUICKVX_VEE_ULUD_REG (QUICKVX_VEE_BASE | 0x00000080) -/* Lower Look-up Data Register */ -#define QUICKVX_VEE_LLUD_REG (QUICKVX_VEE_BASE | 0x00000084) -/* Look-up Address Register */ -#define QUICKVX_VEE_LUADDR_REG (QUICKVX_VEE_BASE | 0x00000088) -/* Look-up Write Enable Register */ -#define QUICKVX_VEE_LUWREN_REG (QUICKVX_VEE_BASE | 0x0000008C) -/* VEE ID Register */ -#define QUICKVX_VEE_VEEID_REG (QUICKVX_VEE_BASE | 0x000003FC) -/* M_11 Register */ -#define QUICKVX_VEE_M_11_REG (QUICKVX_VEE_BASE | 0x000000C0) -/* M_12 Register */ -#define QUICKVX_VEE_M_12_REG (QUICKVX_VEE_BASE | 0x000000C4) -/* M_13 Register */ -#define QUICKVX_VEE_M_13_REG (QUICKVX_VEE_BASE | 0x000000C8) -/* M_21 Register */ -#define QUICKVX_VEE_M_21_REG (QUICKVX_VEE_BASE | 0x000000CC) -/* M_22 Register */ -#define QUICKVX_VEE_M_22_REG (QUICKVX_VEE_BASE | 0x000000D0) -/* M_23 Register */ -#define QUICKVX_VEE_M_23_REG (QUICKVX_VEE_BASE | 0x000000D4) -/* M_31 Register */ -#define QUICKVX_VEE_M_31_REG (QUICKVX_VEE_BASE | 0x000000D8) -/* M_32 Register */ -#define QUICKVX_VEE_M_32_REG (QUICKVX_VEE_BASE | 0x000000DC) -/* M_33 Register */ -#define QUICKVX_VEE_M_33_REG (QUICKVX_VEE_BASE | 0x000000E0) -/* R Offset Register */ -#define QUICKVX_VEE_OFFSET_R_REG (QUICKVX_VEE_BASE | 0x000000E8) -/* G Offset Register */ -#define QUICKVX_VEE_OFFSET_G_REG (QUICKVX_VEE_BASE | 0x000000EC) -/* B Offset Register */ -#define QUICKVX_VEE_OFFSET_B_REG (QUICKVX_VEE_BASE | 0x000000F0) - -/* LCD Reset Register */ -#define QUICKVX_FB_A2F_LCD_RESET_REG (QUICKVX_FB_A2F_BASE | 0x00000000) - -/* Register bit defines */ -/* PLL Lock bit in the PLL Control Register */ -#define QUICKVX_PLL_LOCK_BIT (1 << 7) - -#define QL_SPI_CTRL_rSPISTart(x) (x) -#define QL_SPI_CTRL_rCPHA(x) (x << 1) -#define QL_SPI_CTRL_rCPOL(x) (x << 2) -#define QL_SPI_CTRL_rLSB(x) (x << 3) -#define QL_SPI_CTRL_rSLVSEL(x) (x << 4) -#define QL_SPI_CTRL_MASK_rTxDone (1 << 9) - -#define QL_SPI_LCD_DEV_ID 0x1c -#define QL_SPI_LCD_RS(x) (x << 1) -#define QL_SPI_LCD_RW(x) (x) -#define QL_SPI_LCD_INDEX_START_BYTE ((QL_SPI_LCD_DEV_ID << 2) | \ - QL_SPI_LCD_RS(0) | QL_SPI_LCD_RW(0)) -#define QL_SPI_LCD_CMD_START_BYTE ((QL_SPI_LCD_DEV_ID << 2) | \ - QL_SPI_LCD_RS(1) | QL_SPI_LCD_RW(0)) -#define QL_SPI_CTRL_LCD_START (QL_SPI_CTRL_rSPISTart(1) | \ - QL_SPI_CTRL_rCPHA(1) | QL_SPI_CTRL_rCPOL(1) | \ - QL_SPI_CTRL_rLSB(0) | QL_SPI_CTRL_rSLVSEL(0)) - -int ql_mddi_write(uint32 address, uint32 value) -{ - int ret = 0; - - ret = mddi_queue_register_write(address, value, TRUE, 0); - - return ret; -} - -int ql_mddi_read(uint32 address, uint32 *regval) -{ - int ret = 0; - - ret = mddi_queue_register_read(address, regval, TRUE, 0); - MDDI_MSG_DEBUG("\nql_mddi_read[0x%x]=0x%x", address, *regval); - - return ret; -} - -int ql_send_spi_cmd_to_lcd(uint32 index, uint32 cmd) -{ - - MDDI_MSG_DEBUG("\n %s(): index 0x%x, cmd 0x%x", __func__, index, cmd); - /* do the index phase */ - /* send 24 bits in the index phase */ - ql_mddi_write(QUICKVX_SPI_TLEN_REG, 23); - - /* send 24 bits in the index phase, starting at bit 23 of TX0 reg */ - ql_mddi_write(QUICKVX_SPI_TX0_REG, - (QL_SPI_LCD_INDEX_START_BYTE << 16) | index); - - /* set start */ - ql_mddi_write(QUICKVX_SPI_CTRL_REG, QL_SPI_CTRL_LCD_START); - - /* do the command phase */ - /* send 24 bits in the cmd phase */ - ql_mddi_write(QUICKVX_SPI_TLEN_REG, 23); - - /* send 24 bits in the cmd phase, starting at bit 23 of TX0 reg. */ - ql_mddi_write(QUICKVX_SPI_TX0_REG, - (QL_SPI_LCD_CMD_START_BYTE << 16) | cmd); - - /* set start */ - ql_mddi_write(QUICKVX_SPI_CTRL_REG, QL_SPI_CTRL_LCD_START); - - return 0; -} - - -int ql_send_spi_data_from_lcd(uint32 index, uint32 *value) -{ - - MDDI_MSG_DEBUG("\n %s(): index 0x%x", __func__, index); - /* do the index phase */ - /* send 24 bits in the index phase */ - ql_mddi_write(QUICKVX_SPI_TLEN_REG, 23); - - /* send 24 bits in the index phase, starting at bit 23 of TX0 reg */ - ql_mddi_write(QUICKVX_SPI_TX0_REG, - (QL_SPI_LCD_INDEX_START_BYTE << 16) | index); - - /* set start */ - ql_mddi_write(QUICKVX_SPI_CTRL_REG, QL_SPI_CTRL_LCD_START); - /* do the command phase */ - /* send 8 bits and read 24 bits in the cmd phase, so total 32 bits */ - ql_mddi_write(QUICKVX_SPI_TLEN_REG, 31); - - /* send 24 bits in the cmd phase, starting at bit 31 of TX0 reg */ - ql_mddi_write(QUICKVX_SPI_TX0_REG, - ((QL_SPI_LCD_CMD_START_BYTE << 16)) << 8); - - /* set start */ - ql_mddi_write(QUICKVX_SPI_CTRL_REG, QL_SPI_CTRL_LCD_START); - - return 0; - -} - -/* Global Variables */ -static uint32 mddi_quickvx_rows_per_second; -static uint32 mddi_quickvx_usecs_per_refresh; -static uint32 mddi_quickvx_rows_per_refresh; - -void mddi_quickvx_configure_registers(void) -{ - MDDI_MSG_DEBUG("\n%s(): ", __func__); - ql_mddi_write(QUICKVX_CAR_CLKSEL_REG, 0x00007000); - - ql_mddi_write(QUICKVX_RCB_PWMW_REG, 0x0000FFFF); - - ql_mddi_write(QUICKVX_RCB_PWMC_REG, 0x00000001); - - ql_mddi_write(QUICKVX_RCB_CONFDONE_REG, 0x00000000); - - /* display is x width = 480, y width = 864 */ - ql_mddi_write(QUICKVX_RCB_TCON0_REG, 0x035f01df); - - /* VFP=2, VBP=4, HFP=16, HBP=16 */ - ql_mddi_write(QUICKVX_RCB_TCON1_REG, 0x01e301e1); - - /* VSW =2, HSW=8 */ - ql_mddi_write(QUICKVX_RCB_TCON2_REG, 0x000000e1); - - ql_mddi_write(QUICKVX_RCB_DISPATTR_REG, 0x00000000); - - ql_mddi_write(QUICKVX_RCB_USECASE_REG, 0x00000025); - - ql_mddi_write(QUICKVX_RCB_VPARM_REG, 0x00000888); - - ql_mddi_write(QUICKVX_RCB_VEECONF_REG, 0x00000001); - - ql_mddi_write(QUICKVX_RCB_IER_REG, 0x00000000); - - ql_mddi_write(QUICKVX_RCB_RCR_REG, 0x80000010); - - ql_mddi_write(QUICKVX_RCB_CELLBCR_REG, 0x8008746F); - - ql_mddi_write(QUICKVX_RCB_CELLCC_REG, 0x800000A3); - - ql_mddi_write(QUICKVX_RCB_CONFDONE_REG, 0x00000001); -} - -void mddi_quickvx_prim_lcd_init(void) -{ - uint32 value; - - MDDI_MSG_DEBUG("\n%s(): ", __func__); - ql_send_spi_data_from_lcd(0, &value); - - ql_send_spi_cmd_to_lcd(0x0100, 0x3000); /* power control1 */ - ql_send_spi_cmd_to_lcd(0x0101, 0x4010); /* power control2 */ - ql_send_spi_cmd_to_lcd(0x0106, 0x0000); /* auto seq setting */ - mddi_wait(3); - - ql_mddi_write(QUICKVX_FB_A2F_LCD_RESET_REG, 0x00000001); - mddi_wait(1); - ql_mddi_write(QUICKVX_FB_A2F_LCD_RESET_REG, 0x00000000); - mddi_wait(1); - ql_mddi_write(QUICKVX_FB_A2F_LCD_RESET_REG, 0x00000001); - mddi_wait(10); - - ql_send_spi_cmd_to_lcd(0x0001, 0x0310); /* driver out control */ - ql_send_spi_cmd_to_lcd(0x0002, 0x0100); /* lcd ac control */ - ql_send_spi_cmd_to_lcd(0x0003, 0x0000); /* entry mode */ - ql_send_spi_cmd_to_lcd(0x0007, 0x0000); /* disp cont1 */ - ql_send_spi_cmd_to_lcd(0x0008, 0x0004); /* disp cont2 */ - ql_send_spi_cmd_to_lcd(0x0009, 0x000C); /* disp cont3 */ - ql_send_spi_cmd_to_lcd(0x000C, 0x4010); /* disp if cont1 */ - ql_send_spi_cmd_to_lcd(0x000E, 0x0000); /* disp if cont2 */ - ql_send_spi_cmd_to_lcd(0x0020, 0x013F); /* panel if cont1 */ - ql_send_spi_cmd_to_lcd(0x0022, 0x7600); /* panel if cont3 */ - ql_send_spi_cmd_to_lcd(0x0023, 0x1C0A); /* panel if cont4 */ - ql_send_spi_cmd_to_lcd(0x0024, 0x1C2C); /* panel if cont5 */ - ql_send_spi_cmd_to_lcd(0x0025, 0x1C4E); /* panel if cont6 */ - ql_send_spi_cmd_to_lcd(0x0027, 0x0000); /* panel if cont8 */ - ql_send_spi_cmd_to_lcd(0x0028, 0x760C); /* panel if cont9 */ - ql_send_spi_cmd_to_lcd(0x0300, 0x0000); /* gamma adj0 */ - ql_send_spi_cmd_to_lcd(0x0301, 0x0502); /* gamma adj1 */ - ql_send_spi_cmd_to_lcd(0x0302, 0x0705); /* gamma adj2 */ - ql_send_spi_cmd_to_lcd(0x0303, 0x0000); /* gamma adj3 */ - ql_send_spi_cmd_to_lcd(0x0304, 0x0200); /* gamma adj4 */ - ql_send_spi_cmd_to_lcd(0x0305, 0x0707); /* gamma adj5 */ - ql_send_spi_cmd_to_lcd(0x0306, 0x1010); /* gamma adj6 */ - ql_send_spi_cmd_to_lcd(0x0307, 0x0202); /* gamma adj7 */ - ql_send_spi_cmd_to_lcd(0x0308, 0x0704); /* gamma adj8 */ - ql_send_spi_cmd_to_lcd(0x0309, 0x0707); /* gamma adj9 */ - ql_send_spi_cmd_to_lcd(0x030A, 0x0000); /* gamma adja */ - ql_send_spi_cmd_to_lcd(0x030B, 0x0000); /* gamma adjb */ - ql_send_spi_cmd_to_lcd(0x030C, 0x0707); /* gamma adjc */ - ql_send_spi_cmd_to_lcd(0x030D, 0x1010); /* gamma adjd */ - ql_send_spi_cmd_to_lcd(0x0310, 0x0104); /* gamma adj10 */ - ql_send_spi_cmd_to_lcd(0x0311, 0x0503); /* gamma adj11 */ - ql_send_spi_cmd_to_lcd(0x0312, 0x0304); /* gamma adj12 */ - ql_send_spi_cmd_to_lcd(0x0315, 0x0304); /* gamma adj15 */ - ql_send_spi_cmd_to_lcd(0x0316, 0x031C); /* gamma adj16 */ - ql_send_spi_cmd_to_lcd(0x0317, 0x0204); /* gamma adj17 */ - ql_send_spi_cmd_to_lcd(0x0318, 0x0402); /* gamma adj18 */ - ql_send_spi_cmd_to_lcd(0x0319, 0x0305); /* gamma adj19 */ - ql_send_spi_cmd_to_lcd(0x031C, 0x0707); /* gamma adj1c */ - ql_send_spi_cmd_to_lcd(0x031D, 0x021F); /* gamma adj1d */ - ql_send_spi_cmd_to_lcd(0x0320, 0x0507); /* gamma adj20 */ - ql_send_spi_cmd_to_lcd(0x0321, 0x0604); /* gamma adj21 */ - ql_send_spi_cmd_to_lcd(0x0322, 0x0405); /* gamma adj22 */ - ql_send_spi_cmd_to_lcd(0x0327, 0x0203); /* gamma adj27 */ - ql_send_spi_cmd_to_lcd(0x0328, 0x0300); /* gamma adj28 */ - ql_send_spi_cmd_to_lcd(0x0329, 0x0002); /* gamma adj29 */ - ql_send_spi_cmd_to_lcd(0x0100, 0x363C); /* power cont1 */ - mddi_wait(1); - ql_send_spi_cmd_to_lcd(0x0101, 0x4003); /* power cont2 */ - ql_send_spi_cmd_to_lcd(0x0102, 0x0001); /* power cont3 */ - ql_send_spi_cmd_to_lcd(0x0103, 0x3C58); /* power cont4 */ - ql_send_spi_cmd_to_lcd(0x010C, 0x0135); /* power cont6 */ - ql_send_spi_cmd_to_lcd(0x0106, 0x0002); /* auto seq */ - ql_send_spi_cmd_to_lcd(0x0029, 0x03BF); /* panel if cont10 */ - ql_send_spi_cmd_to_lcd(0x0106, 0x0003); /* auto seq */ - mddi_wait(5); - ql_send_spi_cmd_to_lcd(0x0101, 0x4010); /* power cont2 */ - mddi_wait(10); -} - -/* Function to Power On the Primary and Secondary LCD panels */ -static int mddi_quickvx_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - MDDI_MSG_DEBUG("\n%s(): ", __func__); - mfd = platform_get_drvdata(pdev); - - if (!mfd) { - MDDI_MSG_DEBUG("\n mddi_quickvx_lcd_on: Device not found!"); - return -ENODEV; - } - - if (mfd->key != MFD_KEY) { - MDDI_MSG_DEBUG("\n mddi_quickvx_lcd_on: Invalid MFD key!"); - return -EINVAL; - } - - mddi_host_client_cnt_reset(); - mddi_quickvx_configure_registers(); - mddi_quickvx_prim_lcd_init(); - - return 0; -} - - -/* Function to Power Off the Primary and Secondary LCD panels */ -static int mddi_quickvx_lcd_off(struct platform_device *pdev) -{ - MDDI_MSG_DEBUG("\n%s(): ", __func__); - mddi_wait(1); - ql_send_spi_cmd_to_lcd(0x0106, 0x0002); /* Auto Sequencer setting */ - mddi_wait(10); - ql_send_spi_cmd_to_lcd(0x0106, 0x0000); /* Auto Sequencer setting */ - ql_send_spi_cmd_to_lcd(0x0029, 0x0002); /* Panel IF control 10 */ - ql_send_spi_cmd_to_lcd(0x0100, 0x300D); /* Power Control 1 */ - mddi_wait(1); - - return 0; -} - -/* Function to set the Backlight brightness level */ -static void mddi_quickvx_lcd_set_backlight(struct msm_fb_data_type *mfd) -{ - int32 level, i = 0, ret; - - MDDI_MSG_DEBUG("%s(): ", __func__); - - level = mfd->bl_level; - MDDI_MSG_DEBUG("\n level = %d", level); - if (level < 0) { - MDDI_MSG_DEBUG("mddi_quickvx_lcd_set_backlight: " - "Invalid backlight level (%d)!\n", level); - return; - } - while (i++ < 3) { - ret = pmic_set_led_intensity(LED_LCD, level); - if (ret == 0) - return; - msleep(10); - } - - MDDI_MSG_DEBUG("%s: can't set lcd backlight!\n", - __func__); -} - -/* Driver Probe function */ -static int mddi_quickvx_lcd_probe(struct platform_device *pdev) -{ - MDDI_MSG_DEBUG("\n%s(): id is %d", __func__, pdev->id); - msm_fb_add_device(pdev); - return 0; -} - -/* Driver data structure */ -static struct platform_driver this_driver = { - .probe = mddi_quickvx_lcd_probe, - .driver = { - .name = "mddi_quickvx", - }, -}; - - -/* Primary LCD panel data structure */ -static struct msm_fb_panel_data mddi_quickvx_panel_data0 = { - .on = mddi_quickvx_lcd_on, - .off = mddi_quickvx_lcd_off, - .set_backlight = mddi_quickvx_lcd_set_backlight, -}; - - -/* Primary LCD panel device structure */ -static struct platform_device this_device0 = { - .name = "mddi_quickvx", - .id = MDDI_QUICKVX_1_2, - .dev = { - .platform_data = &mddi_quickvx_panel_data0, - } -}; - -/* Module init - driver main entry point */ -static int __init mddi_quickvx_lcd_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - u32 cid; - MDDI_MSG_DEBUG("\n%s(): ", __func__); - - ret = msm_fb_detect_client("mddi_quickvx"); - - if (ret == -ENODEV) { - /* Device not found */ - MDDI_MSG_DEBUG("\n mddi_quickvx_lcd_init: No device found!"); - return 0; - } - - if (ret) { - cid = mddi_get_client_id(); - - MDDI_MSG_DEBUG("\n cid = 0x%x", cid); - if (((cid >> 16) != QUICKVX_MDDI_MFR_CODE) || - ((cid & 0xFFFF) != QUICKVX_MDDI_PRD_CODE)) { - /* MDDI Client ID not matching */ - MDDI_MSG_DEBUG("\n mddi_quickvx_lcd_init: " - "Client ID missmatch!"); - - return 0; - } - MDDI_MSG_DEBUG("\n mddi_quickvx_lcd_init: " - "QuickVX LCD panel detected!"); - } - -#endif /* CONFIG_FB_MSM_MDDI_AUTO_DETECT */ - - mddi_quickvx_rows_per_refresh = 872; - mddi_quickvx_rows_per_second = 52364; - mddi_quickvx_usecs_per_refresh = 16574; - - ret = platform_driver_register(&this_driver); - - if (!ret) { - pinfo = &mddi_quickvx_panel_data0.panel_info; - pinfo->xres = 480; - pinfo->yres = 864; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = MDDI_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - pinfo->wait_cycle = 0; - pinfo->bpp = 24; - pinfo->fb_num = 2; - - pinfo->clk_rate = 192000000; - pinfo->clk_min = 192000000; - pinfo->clk_max = 200000000; - pinfo->lcd.rev = 1; - pinfo->lcd.vsync_enable = TRUE; - pinfo->lcd.refx100 = (mddi_quickvx_rows_per_second \ - * 100)/mddi_quickvx_rows_per_refresh; - pinfo->mddi.is_type1 = TRUE; - pinfo->lcd.v_back_porch = 4; - pinfo->lcd.v_front_porch = 2; - pinfo->lcd.v_pulse_width = 2; - pinfo->lcd.hw_vsync_mode = TRUE; - pinfo->lcd.vsync_notifier_period = (1 * HZ); - pinfo->bl_max = 10; - pinfo->bl_min = 0; - - ret = platform_device_register(&this_device0); - if (ret) { - platform_driver_unregister(&this_driver); - MDDI_MSG_DEBUG("mddi_quickvx_lcd_init: " - "Primary device registration failed!\n"); - } - } - - return ret; -} - -module_init(mddi_quickvx_lcd_init); - diff --git a/drivers/video/msm/mddi_sharp.c b/drivers/video/msm/mddi_sharp.c deleted file mode 100644 index 7efd638e3c2453381d2c854f6f1acf7dc9a919a9..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_sharp.c +++ /dev/null @@ -1,901 +0,0 @@ -/* Copyright (c) 2008-2010, 2012 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 "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" - -#define SHARP_QVGA_PRIM 1 -#define SHARP_128X128_SECD 2 - -extern uint32 mddi_host_core_version; -static boolean mddi_debug_prim_wait = FALSE; -static boolean mddi_sharp_vsync_wake = TRUE; -static boolean mddi_sharp_monitor_refresh_value = TRUE; -static boolean mddi_sharp_report_refresh_measurements = FALSE; -static uint32 mddi_sharp_rows_per_second = 13830; /* 5200000/376 */ -static uint32 mddi_sharp_rows_per_refresh = 338; -static uint32 mddi_sharp_usecs_per_refresh = 24440; /* (376+338)/5200000 */ -static boolean mddi_sharp_debug_60hz_refresh = FALSE; - -extern mddi_gpio_info_type mddi_gpio; -extern boolean mddi_vsync_detect_enabled; -static msm_fb_vsync_handler_type mddi_sharp_vsync_handler; -static void *mddi_sharp_vsync_handler_arg; -static uint16 mddi_sharp_vsync_attempts; - -static void mddi_sharp_prim_lcd_init(void); -static void mddi_sharp_sub_lcd_init(void); -static void mddi_sharp_lcd_set_backlight(struct msm_fb_data_type *mfd); -static void mddi_sharp_vsync_set_handler(msm_fb_vsync_handler_type handler, - void *); -static void mddi_sharp_lcd_vsync_detected(boolean detected); -static struct msm_panel_common_pdata *mddi_sharp_pdata; - -#define REG_SYSCTL 0x0000 -#define REG_INTR 0x0006 -#define REG_CLKCNF 0x000C -#define REG_CLKDIV1 0x000E -#define REG_CLKDIV2 0x0010 - -#define REG_GIOD 0x0040 -#define REG_GIOA 0x0042 - -#define REG_AGM 0x010A -#define REG_FLFT 0x0110 -#define REG_FRGT 0x0112 -#define REG_FTOP 0x0114 -#define REG_FBTM 0x0116 -#define REG_FSTRX 0x0118 -#define REG_FSTRY 0x011A -#define REG_VRAM 0x0202 -#define REG_SSDCTL 0x0330 -#define REG_SSD0 0x0332 -#define REG_PSTCTL1 0x0400 -#define REG_PSTCTL2 0x0402 -#define REG_PTGCTL 0x042A -#define REG_PTHP 0x042C -#define REG_PTHB 0x042E -#define REG_PTHW 0x0430 -#define REG_PTHF 0x0432 -#define REG_PTVP 0x0434 -#define REG_PTVB 0x0436 -#define REG_PTVW 0x0438 -#define REG_PTVF 0x043A -#define REG_VBLKS 0x0458 -#define REG_VBLKE 0x045A -#define REG_SUBCTL 0x0700 -#define REG_SUBTCMD 0x0702 -#define REG_SUBTCMDD 0x0704 -#define REG_REVBYTE 0x0A02 -#define REG_REVCNT 0x0A04 -#define REG_REVATTR 0x0A06 -#define REG_REVFMT 0x0A08 - -#define SHARP_SUB_UNKNOWN 0xffffffff -#define SHARP_SUB_HYNIX 1 -#define SHARP_SUB_ROHM 2 - -static uint32 sharp_subpanel_type = SHARP_SUB_UNKNOWN; - -static void sub_through_write(int sub_rs, uint32 sub_data) -{ - mddi_queue_register_write(REG_SUBTCMDD, sub_data, FALSE, 0); - - /* CS=1,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x000e | sub_rs, FALSE, 0); - - /* CS=0,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x0006 | sub_rs, FALSE, 0); - - /* CS=0,RD=1,WE=0,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x0004 | sub_rs, FALSE, 0); - - /* CS=0,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x0006 | sub_rs, FALSE, 0); - - /* CS=1,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x000e | sub_rs, TRUE, 0); -} - -static uint32 sub_through_read(int sub_rs) -{ - uint32 sub_data; - - /* CS=1,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x000e | sub_rs, FALSE, 0); - - /* CS=0,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x0006 | sub_rs, FALSE, 0); - - /* CS=0,RD=1,WE=0,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x0002 | sub_rs, TRUE, 0); - - mddi_queue_register_read(REG_SUBTCMDD, &sub_data, TRUE, 0); - - /* CS=0,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x0006 | sub_rs, FALSE, 0); - - /* CS=1,RD=1,WE=1,RS=sub_rs */ - mddi_queue_register_write(REG_SUBTCMD, 0x000e | sub_rs, TRUE, 0); - - return sub_data; -} - -static void serigo(uint32 ssd) -{ - uint32 ssdctl; - - mddi_queue_register_read(REG_SSDCTL, &ssdctl, TRUE, 0); - ssdctl = ((ssdctl & 0xE7) | 0x02); - - mddi_queue_register_write(REG_SSD0, ssd, FALSE, 0); - mddi_queue_register_write(REG_SSDCTL, ssdctl, TRUE, 0); - - do { - mddi_queue_register_read(REG_SSDCTL, &ssdctl, TRUE, 0); - } while ((ssdctl & 0x0002) != 0); - - if (mddi_debug_prim_wait) - mddi_wait(2); -} - -static void mddi_sharp_lcd_powerdown(void) -{ - serigo(0x0131); - serigo(0x0300); - mddi_wait(40); - serigo(0x0135); - mddi_wait(20); - serigo(0x2122); - mddi_wait(20); - serigo(0x0201); - mddi_wait(20); - serigo(0x2100); - mddi_wait(20); - serigo(0x2000); - mddi_wait(20); - - mddi_queue_register_write(REG_PSTCTL1, 0x1, TRUE, 0); - mddi_wait(100); - mddi_queue_register_write(REG_PSTCTL1, 0x0, TRUE, 0); - mddi_wait(2); - mddi_queue_register_write(REG_SYSCTL, 0x1, TRUE, 0); - mddi_wait(2); - mddi_queue_register_write(REG_CLKDIV1, 0x3, TRUE, 0); - mddi_wait(2); - mddi_queue_register_write(REG_SSDCTL, 0x0000, TRUE, 0); /* SSDRESET */ - mddi_queue_register_write(REG_SYSCTL, 0x0, TRUE, 0); - mddi_wait(2); -} - -static void mddi_sharp_lcd_set_backlight(struct msm_fb_data_type *mfd) -{ - uint32 regdata; - int32 level; - int max = mfd->panel_info.bl_max; - int min = mfd->panel_info.bl_min; - - if (mddi_sharp_pdata && mddi_sharp_pdata->backlight_level) { - level = mddi_sharp_pdata->backlight_level(mfd->bl_level, - max, - min); - - if (level < 0) - return; - - /* use Rodem GPIO(2:0) to give 8 levels of backlight (7-0) */ - /* Set lower 3 GPIOs as Outputs (set to 0) */ - mddi_queue_register_read(REG_GIOA, ®data, TRUE, 0); - mddi_queue_register_write(REG_GIOA, regdata & 0xfff8, TRUE, 0); - - /* Set lower 3 GPIOs as level */ - mddi_queue_register_read(REG_GIOD, ®data, TRUE, 0); - mddi_queue_register_write(REG_GIOD, - (regdata & 0xfff8) | (0x07 & level), TRUE, 0); - } -} - -static void mddi_sharp_prim_lcd_init(void) -{ - mddi_queue_register_write(REG_SYSCTL, 0x4000, TRUE, 0); - mddi_wait(1); - mddi_queue_register_write(REG_SYSCTL, 0x0000, TRUE, 0); - mddi_wait(5); - mddi_queue_register_write(REG_SYSCTL, 0x0001, FALSE, 0); - mddi_queue_register_write(REG_CLKDIV1, 0x000b, FALSE, 0); - - /* new reg write below */ - if (mddi_sharp_debug_60hz_refresh) - mddi_queue_register_write(REG_CLKCNF, 0x070d, FALSE, 0); - else - mddi_queue_register_write(REG_CLKCNF, 0x0708, FALSE, 0); - - mddi_queue_register_write(REG_SYSCTL, 0x0201, FALSE, 0); - mddi_queue_register_write(REG_PTGCTL, 0x0010, FALSE, 0); - mddi_queue_register_write(REG_PTHP, 4, FALSE, 0); - mddi_queue_register_write(REG_PTHB, 40, FALSE, 0); - mddi_queue_register_write(REG_PTHW, 240, FALSE, 0); - if (mddi_sharp_debug_60hz_refresh) - mddi_queue_register_write(REG_PTHF, 12, FALSE, 0); - else - mddi_queue_register_write(REG_PTHF, 92, FALSE, 0); - - mddi_wait(1); - - mddi_queue_register_write(REG_PTVP, 1, FALSE, 0); - mddi_queue_register_write(REG_PTVB, 2, FALSE, 0); - mddi_queue_register_write(REG_PTVW, 320, FALSE, 0); - mddi_queue_register_write(REG_PTVF, 15, FALSE, 0); - - mddi_wait(1); - - /* vram_color set REG_AGM???? */ - mddi_queue_register_write(REG_AGM, 0x0000, TRUE, 0); - - mddi_queue_register_write(REG_SSDCTL, 0x0000, FALSE, 0); - mddi_queue_register_write(REG_SSDCTL, 0x0001, TRUE, 0); - mddi_wait(1); - mddi_queue_register_write(REG_PSTCTL1, 0x0001, TRUE, 0); - mddi_wait(10); - - serigo(0x0701); - /* software reset */ - mddi_wait(1); - /* Wait over 50us */ - - serigo(0x0400); - /* DCLK~ACHSYNC~ACVSYNC polarity setting */ - serigo(0x2900); - /* EEPROM start read address setting */ - serigo(0x2606); - /* EEPROM start read register setting */ - mddi_wait(20); - /* Wait over 20ms */ - - serigo(0x0503); - /* Horizontal timing setting */ - serigo(0x062C); - /* Veritical timing setting */ - serigo(0x2001); - /* power initialize setting(VDC2) */ - mddi_wait(20); - /* Wait over 20ms */ - - serigo(0x2120); - /* Initialize power setting(CPS) */ - mddi_wait(20); - /* Wait over 20ms */ - - serigo(0x2130); - /* Initialize power setting(CPS) */ - mddi_wait(20); - /* Wait over 20ms */ - - serigo(0x2132); - /* Initialize power setting(CPS) */ - mddi_wait(10); - /* Wait over 10ms */ - - serigo(0x2133); - /* Initialize power setting(CPS) */ - mddi_wait(20); - /* Wait over 20ms */ - - serigo(0x0200); - /* Panel initialize release(INIT) */ - mddi_wait(1); - /* Wait over 1ms */ - - serigo(0x0131); - /* Panel setting(CPS) */ - mddi_wait(1); - /* Wait over 1ms */ - - mddi_queue_register_write(REG_PSTCTL1, 0x0003, TRUE, 0); - - /* if (FFA LCD is upside down) -> serigo(0x0100); */ - serigo(0x0130); - - /* Black mask release(display ON) */ - mddi_wait(1); - /* Wait over 1ms */ - - if (mddi_sharp_vsync_wake) { - mddi_queue_register_write(REG_VBLKS, 0x1001, TRUE, 0); - mddi_queue_register_write(REG_VBLKE, 0x1002, TRUE, 0); - } - - /* Set the MDP pixel data attributes for Primary Display */ - mddi_host_write_pix_attr_reg(0x00C3); - return; - -} - -void mddi_sharp_sub_lcd_init(void) -{ - - mddi_queue_register_write(REG_SYSCTL, 0x4000, FALSE, 0); - mddi_queue_register_write(REG_SYSCTL, 0x0000, TRUE, 0); - mddi_wait(100); - - mddi_queue_register_write(REG_SYSCTL, 0x0001, FALSE, 0); - mddi_queue_register_write(REG_CLKDIV1, 0x000b, FALSE, 0); - mddi_queue_register_write(REG_CLKCNF, 0x0708, FALSE, 0); - mddi_queue_register_write(REG_SYSCTL, 0x0201, FALSE, 0); - mddi_queue_register_write(REG_PTGCTL, 0x0010, FALSE, 0); - mddi_queue_register_write(REG_PTHP, 4, FALSE, 0); - mddi_queue_register_write(REG_PTHB, 40, FALSE, 0); - mddi_queue_register_write(REG_PTHW, 128, FALSE, 0); - mddi_queue_register_write(REG_PTHF, 92, FALSE, 0); - mddi_queue_register_write(REG_PTVP, 1, FALSE, 0); - mddi_queue_register_write(REG_PTVB, 2, FALSE, 0); - mddi_queue_register_write(REG_PTVW, 128, FALSE, 0); - mddi_queue_register_write(REG_PTVF, 15, FALSE, 0); - - /* Now the sub display..... */ - /* Reset High */ - mddi_queue_register_write(REG_SUBCTL, 0x0200, FALSE, 0); - /* CS=1,RD=1,WE=1,RS=1 */ - mddi_queue_register_write(REG_SUBTCMD, 0x000f, TRUE, 0); - mddi_wait(1); - /* Wait 5us */ - - if (sharp_subpanel_type == SHARP_SUB_UNKNOWN) { - uint32 data; - - sub_through_write(1, 0x05); - sub_through_write(1, 0x6A); - sub_through_write(1, 0x1D); - sub_through_write(1, 0x05); - data = sub_through_read(1); - if (data == 0x6A) { - sharp_subpanel_type = SHARP_SUB_HYNIX; - } else { - sub_through_write(0, 0x36); - sub_through_write(1, 0xA8); - sub_through_write(0, 0x09); - data = sub_through_read(1); - data = sub_through_read(1); - if (data == 0x54) { - sub_through_write(0, 0x36); - sub_through_write(1, 0x00); - sharp_subpanel_type = SHARP_SUB_ROHM; - } - } - } - - if (sharp_subpanel_type == SHARP_SUB_HYNIX) { - sub_through_write(1, 0x00); /* Display setting 1 */ - sub_through_write(1, 0x04); - sub_through_write(1, 0x01); - sub_through_write(1, 0x05); - sub_through_write(1, 0x0280); - sub_through_write(1, 0x0301); - sub_through_write(1, 0x0402); - sub_through_write(1, 0x0500); - sub_through_write(1, 0x0681); - sub_through_write(1, 0x077F); - sub_through_write(1, 0x08C0); - sub_through_write(1, 0x0905); - sub_through_write(1, 0x0A02); - sub_through_write(1, 0x0B00); - sub_through_write(1, 0x0C00); - sub_through_write(1, 0x0D00); - sub_through_write(1, 0x0E00); - sub_through_write(1, 0x0F00); - - sub_through_write(1, 0x100B); /* Display setting 2 */ - sub_through_write(1, 0x1103); - sub_through_write(1, 0x1237); - sub_through_write(1, 0x1300); - sub_through_write(1, 0x1400); - sub_through_write(1, 0x1500); - sub_through_write(1, 0x1605); - sub_through_write(1, 0x1700); - sub_through_write(1, 0x1800); - sub_through_write(1, 0x192E); - sub_through_write(1, 0x1A00); - sub_through_write(1, 0x1B00); - sub_through_write(1, 0x1C00); - - sub_through_write(1, 0x151A); /* Power setting */ - - sub_through_write(1, 0x2002); /* Gradation Palette setting */ - sub_through_write(1, 0x2107); - sub_through_write(1, 0x220C); - sub_through_write(1, 0x2310); - sub_through_write(1, 0x2414); - sub_through_write(1, 0x2518); - sub_through_write(1, 0x261C); - sub_through_write(1, 0x2720); - sub_through_write(1, 0x2824); - sub_through_write(1, 0x2928); - sub_through_write(1, 0x2A2B); - sub_through_write(1, 0x2B2E); - sub_through_write(1, 0x2C31); - sub_through_write(1, 0x2D34); - sub_through_write(1, 0x2E37); - sub_through_write(1, 0x2F3A); - sub_through_write(1, 0x303C); - sub_through_write(1, 0x313E); - sub_through_write(1, 0x323F); - sub_through_write(1, 0x3340); - sub_through_write(1, 0x3441); - sub_through_write(1, 0x3543); - sub_through_write(1, 0x3646); - sub_through_write(1, 0x3749); - sub_through_write(1, 0x384C); - sub_through_write(1, 0x394F); - sub_through_write(1, 0x3A52); - sub_through_write(1, 0x3B59); - sub_through_write(1, 0x3C60); - sub_through_write(1, 0x3D67); - sub_through_write(1, 0x3E6E); - sub_through_write(1, 0x3F7F); - sub_through_write(1, 0x4001); - sub_through_write(1, 0x4107); - sub_through_write(1, 0x420C); - sub_through_write(1, 0x4310); - sub_through_write(1, 0x4414); - sub_through_write(1, 0x4518); - sub_through_write(1, 0x461C); - sub_through_write(1, 0x4720); - sub_through_write(1, 0x4824); - sub_through_write(1, 0x4928); - sub_through_write(1, 0x4A2B); - sub_through_write(1, 0x4B2E); - sub_through_write(1, 0x4C31); - sub_through_write(1, 0x4D34); - sub_through_write(1, 0x4E37); - sub_through_write(1, 0x4F3A); - sub_through_write(1, 0x503C); - sub_through_write(1, 0x513E); - sub_through_write(1, 0x523F); - sub_through_write(1, 0x5340); - sub_through_write(1, 0x5441); - sub_through_write(1, 0x5543); - sub_through_write(1, 0x5646); - sub_through_write(1, 0x5749); - sub_through_write(1, 0x584C); - sub_through_write(1, 0x594F); - sub_through_write(1, 0x5A52); - sub_through_write(1, 0x5B59); - sub_through_write(1, 0x5C60); - sub_through_write(1, 0x5D67); - sub_through_write(1, 0x5E6E); - sub_through_write(1, 0x5F7E); - sub_through_write(1, 0x6000); - sub_through_write(1, 0x6107); - sub_through_write(1, 0x620C); - sub_through_write(1, 0x6310); - sub_through_write(1, 0x6414); - sub_through_write(1, 0x6518); - sub_through_write(1, 0x661C); - sub_through_write(1, 0x6720); - sub_through_write(1, 0x6824); - sub_through_write(1, 0x6928); - sub_through_write(1, 0x6A2B); - sub_through_write(1, 0x6B2E); - sub_through_write(1, 0x6C31); - sub_through_write(1, 0x6D34); - sub_through_write(1, 0x6E37); - sub_through_write(1, 0x6F3A); - sub_through_write(1, 0x703C); - sub_through_write(1, 0x713E); - sub_through_write(1, 0x723F); - sub_through_write(1, 0x7340); - sub_through_write(1, 0x7441); - sub_through_write(1, 0x7543); - sub_through_write(1, 0x7646); - sub_through_write(1, 0x7749); - sub_through_write(1, 0x784C); - sub_through_write(1, 0x794F); - sub_through_write(1, 0x7A52); - sub_through_write(1, 0x7B59); - sub_through_write(1, 0x7C60); - sub_through_write(1, 0x7D67); - sub_through_write(1, 0x7E6E); - sub_through_write(1, 0x7F7D); - - sub_through_write(1, 0x1851); /* Display on */ - - mddi_queue_register_write(REG_AGM, 0x0000, TRUE, 0); - - /* 1 pixel / 1 post clock */ - mddi_queue_register_write(REG_CLKDIV2, 0x3b00, FALSE, 0); - - /* SUB LCD select */ - mddi_queue_register_write(REG_PSTCTL2, 0x0080, FALSE, 0); - - /* RS=0,command initiate number=0,select master mode */ - mddi_queue_register_write(REG_SUBCTL, 0x0202, FALSE, 0); - - /* Sub LCD Data transform start */ - mddi_queue_register_write(REG_PSTCTL1, 0x0003, FALSE, 0); - - } else if (sharp_subpanel_type == SHARP_SUB_ROHM) { - - sub_through_write(0, 0x01); /* Display setting */ - sub_through_write(1, 0x00); - - mddi_wait(1); - /* Wait 100us <----- ******* Update 2005/01/24 */ - - sub_through_write(0, 0xB6); - sub_through_write(1, 0x0C); - sub_through_write(1, 0x4A); - sub_through_write(1, 0x20); - sub_through_write(0, 0x3A); - sub_through_write(1, 0x05); - sub_through_write(0, 0xB7); - sub_through_write(1, 0x01); - sub_through_write(0, 0xBA); - sub_through_write(1, 0x20); - sub_through_write(1, 0x02); - sub_through_write(0, 0x25); - sub_through_write(1, 0x4F); - sub_through_write(0, 0xBB); - sub_through_write(1, 0x00); - sub_through_write(0, 0x36); - sub_through_write(1, 0x00); - sub_through_write(0, 0xB1); - sub_through_write(1, 0x05); - sub_through_write(0, 0xBE); - sub_through_write(1, 0x80); - sub_through_write(0, 0x26); - sub_through_write(1, 0x01); - sub_through_write(0, 0x2A); - sub_through_write(1, 0x02); - sub_through_write(1, 0x81); - sub_through_write(0, 0x2B); - sub_through_write(1, 0x00); - sub_through_write(1, 0x7F); - - sub_through_write(0, 0x2C); - sub_through_write(0, 0x11); /* Sleep mode off */ - - mddi_wait(1); - /* Wait 100 ms <----- ******* Update 2005/01/24 */ - - sub_through_write(0, 0x29); /* Display on */ - sub_through_write(0, 0xB3); - sub_through_write(1, 0x20); - sub_through_write(1, 0xAA); - sub_through_write(1, 0xA0); - sub_through_write(1, 0x20); - sub_through_write(1, 0x30); - sub_through_write(1, 0xA6); - sub_through_write(1, 0xFF); - sub_through_write(1, 0x9A); - sub_through_write(1, 0x9F); - sub_through_write(1, 0xAF); - sub_through_write(1, 0xBC); - sub_through_write(1, 0xCF); - sub_through_write(1, 0xDF); - sub_through_write(1, 0x20); - sub_through_write(1, 0x9C); - sub_through_write(1, 0x8A); - - sub_through_write(0, 0x002C); /* Display on */ - - /* 1 pixel / 2 post clock */ - mddi_queue_register_write(REG_CLKDIV2, 0x7b00, FALSE, 0); - - /* SUB LCD select */ - mddi_queue_register_write(REG_PSTCTL2, 0x0080, FALSE, 0); - - /* RS=1,command initiate number=0,select master mode */ - mddi_queue_register_write(REG_SUBCTL, 0x0242, FALSE, 0); - - /* Sub LCD Data transform start */ - mddi_queue_register_write(REG_PSTCTL1, 0x0003, FALSE, 0); - - } - - /* Set the MDP pixel data attributes for Sub Display */ - mddi_host_write_pix_attr_reg(0x00C0); -} - -void mddi_sharp_lcd_vsync_detected(boolean detected) -{ - /* static timetick_type start_time = 0; */ - static struct timeval start_time; - static boolean first_time = TRUE; - /* uint32 mdp_cnt_val = 0; */ - /* timetick_type elapsed_us; */ - struct timeval now; - uint32 elapsed_us; - uint32 num_vsyncs; - - if ((detected) || (mddi_sharp_vsync_attempts > 5)) { - if ((detected) && (mddi_sharp_monitor_refresh_value)) { - /* if (start_time != 0) */ - if (!first_time) { - jiffies_to_timeval(jiffies, &now); - elapsed_us = - (now.tv_sec - start_time.tv_sec) * 1000000 + - now.tv_usec - start_time.tv_usec; - /* - * LCD is configured for a refresh every usecs, - * so to determine the number of vsyncs that - * have occurred since the last measurement add - * half that to the time difference and divide - * by the refresh rate. - */ - num_vsyncs = (elapsed_us + - (mddi_sharp_usecs_per_refresh >> - 1)) / - mddi_sharp_usecs_per_refresh; - /* - * LCD is configured for * hsyncs (rows) per - * refresh cycle. Calculate new rows_per_second - * value based upon these new measurements. - * MDP can update with this new value. - */ - mddi_sharp_rows_per_second = - (mddi_sharp_rows_per_refresh * 1000 * - num_vsyncs) / (elapsed_us / 1000); - } - /* start_time = timetick_get(); */ - first_time = FALSE; - jiffies_to_timeval(jiffies, &start_time); - if (mddi_sharp_report_refresh_measurements) { - /* mdp_cnt_val = MDP_LINE_COUNT; */ - } - } - /* if detected = TRUE, client initiated wakeup was detected */ - if (mddi_sharp_vsync_handler != NULL) { - (*mddi_sharp_vsync_handler) - (mddi_sharp_vsync_handler_arg); - mddi_sharp_vsync_handler = NULL; - } - mddi_vsync_detect_enabled = FALSE; - mddi_sharp_vsync_attempts = 0; - /* need to clear this vsync wakeup */ - if (!mddi_queue_register_write_int(REG_INTR, 0x0000)) { - MDDI_MSG_ERR("Vsync interrupt clear failed!\n"); - } - if (!detected) { - /* give up after 5 failed attempts but show error */ - MDDI_MSG_NOTICE("Vsync detection failed!\n"); - } else if ((mddi_sharp_monitor_refresh_value) && - (mddi_sharp_report_refresh_measurements)) { - MDDI_MSG_NOTICE(" Lines Per Second=%d!\n", - mddi_sharp_rows_per_second); - } - } else - /* if detected = FALSE, we woke up from hibernation, but did not - * detect client initiated wakeup. - */ - mddi_sharp_vsync_attempts++; -} - -/* ISR to be executed */ -void mddi_sharp_vsync_set_handler(msm_fb_vsync_handler_type handler, void *arg) -{ - boolean error = FALSE; - unsigned long flags; - - /* Disable interrupts */ - spin_lock_irqsave(&mddi_host_spin_lock, flags); - /* INTLOCK(); */ - - if (mddi_sharp_vsync_handler != NULL) - error = TRUE; - - /* Register the handler for this particular GROUP interrupt source */ - mddi_sharp_vsync_handler = handler; - mddi_sharp_vsync_handler_arg = arg; - - /* Restore interrupts */ - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - /* INTFREE(); */ - - if (error) - MDDI_MSG_ERR("MDDI: Previous Vsync handler never called\n"); - - /* Enable the vsync wakeup */ - mddi_queue_register_write(REG_INTR, 0x8100, FALSE, 0); - - mddi_sharp_vsync_attempts = 1; - mddi_vsync_detect_enabled = TRUE; -} /* mddi_sharp_vsync_set_handler */ - -static int mddi_sharp_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - mddi_host_client_cnt_reset(); - - if (mfd->panel.id == SHARP_QVGA_PRIM) - mddi_sharp_prim_lcd_init(); - else - mddi_sharp_sub_lcd_init(); - - return 0; -} - -static int mddi_sharp_lcd_off(struct platform_device *pdev) -{ - if (mddi_sharp_vsync_handler != NULL) { - (*mddi_sharp_vsync_handler) - (mddi_sharp_vsync_handler_arg); - mddi_sharp_vsync_handler = NULL; - printk(KERN_INFO "%s: clean up vsyn_handler=%x\n", __func__, - (int)mddi_sharp_vsync_handler); - } - - mddi_sharp_lcd_powerdown(); - return 0; -} - -static int mddi_sharp_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - mddi_sharp_pdata = pdev->dev.platform_data; - return 0; - } - - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = mddi_sharp_probe, - .driver = { - .name = "mddi_sharp_qvga", - }, -}; - -static struct msm_fb_panel_data mddi_sharp_panel_data0 = { - .on = mddi_sharp_lcd_on, - .off = mddi_sharp_lcd_off, - .set_backlight = mddi_sharp_lcd_set_backlight, - .set_vsync_notifier = mddi_sharp_vsync_set_handler, -}; - -static struct platform_device this_device_0 = { - .name = "mddi_sharp_qvga", - .id = SHARP_QVGA_PRIM, - .dev = { - .platform_data = &mddi_sharp_panel_data0, - } -}; - -static struct msm_fb_panel_data mddi_sharp_panel_data1 = { - .on = mddi_sharp_lcd_on, - .off = mddi_sharp_lcd_off, -}; - -static struct platform_device this_device_1 = { - .name = "mddi_sharp_qvga", - .id = SHARP_128X128_SECD, - .dev = { - .platform_data = &mddi_sharp_panel_data1, - } -}; - -static int __init mddi_sharp_init(void) -{ - int ret; - struct msm_panel_info *pinfo; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - u32 id; - - ret = msm_fb_detect_client("mddi_sharp_qvga"); - if (ret == -ENODEV) - return 0; - - if (ret) { - id = mddi_get_client_id(); - - if (((id >> 16) != 0x0) || ((id & 0xffff) != 0x8835)) - return 0; - } -#endif - if (mddi_host_core_version > 8) { - /* can use faster refresh with newer hw revisions */ - mddi_sharp_debug_60hz_refresh = TRUE; - - /* Timing variables for tracking vsync */ - /* dot_clock = 6.00MHz - * horizontal count = 296 - * vertical count = 338 - * refresh rate = 6000000/(296+338) = 60Hz - */ - mddi_sharp_rows_per_second = 20270; /* 6000000/296 */ - mddi_sharp_rows_per_refresh = 338; - mddi_sharp_usecs_per_refresh = 16674; /* (296+338)/6000000 */ - } else { - /* Timing variables for tracking vsync */ - /* dot_clock = 5.20MHz - * horizontal count = 376 - * vertical count = 338 - * refresh rate = 5200000/(376+338) = 41Hz - */ - mddi_sharp_rows_per_second = 13830; /* 5200000/376 */ - mddi_sharp_rows_per_refresh = 338; - mddi_sharp_usecs_per_refresh = 24440; /* (376+338)/5200000 */ - } - - ret = platform_driver_register(&this_driver); - if (!ret) { - pinfo = &mddi_sharp_panel_data0.panel_info; - pinfo->xres = 240; - pinfo->yres = 320; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = MDDI_PANEL; - pinfo->pdest = DISPLAY_1; - pinfo->mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->fb_num = 2; - pinfo->clk_rate = 122880000; - pinfo->clk_min = 120000000; - pinfo->clk_max = 125000000; - pinfo->lcd.vsync_enable = TRUE; - pinfo->mddi.is_type1 = TRUE; - pinfo->lcd.refx100 = - (mddi_sharp_rows_per_second * 100) / - mddi_sharp_rows_per_refresh; - pinfo->lcd.v_back_porch = 12; - pinfo->lcd.v_front_porch = 6; - pinfo->lcd.v_pulse_width = 0; - pinfo->lcd.hw_vsync_mode = FALSE; - pinfo->lcd.vsync_notifier_period = (1 * HZ); - pinfo->bl_max = 7; - pinfo->bl_min = 1; - - ret = platform_device_register(&this_device_0); - if (ret) - platform_driver_unregister(&this_driver); - - pinfo = &mddi_sharp_panel_data1.panel_info; - pinfo->xres = 128; - pinfo->yres = 128; - MSM_FB_SINGLE_MODE_PANEL(pinfo); - pinfo->type = MDDI_PANEL; - pinfo->pdest = DISPLAY_2; - pinfo->mddi.vdopkt = 0x400; - pinfo->wait_cycle = 0; - pinfo->bpp = 18; - pinfo->clk_rate = 122880000; - pinfo->clk_min = 120000000; - pinfo->clk_max = 125000000; - pinfo->fb_num = 2; - - ret = platform_device_register(&this_device_1); - if (ret) { - platform_device_unregister(&this_device_0); - platform_driver_unregister(&this_driver); - } - } - - if (!ret) - mddi_lcd.vsync_detected = mddi_sharp_lcd_vsync_detected; - - return ret; -} - -module_init(mddi_sharp_init); diff --git a/drivers/video/msm/mddi_toshiba.c b/drivers/video/msm/mddi_toshiba.c deleted file mode 100644 index bba83866a7560f971f08d3d89579d609543add2d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_toshiba.c +++ /dev/null @@ -1,1753 +0,0 @@ -/* Copyright (c) 2008-2009, 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 "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" -#include "mddi_toshiba.h" - -#define TM_GET_DID(id) ((id) & 0xff) -#define TM_GET_PID(id) (((id) & 0xff00)>>8) - -#define MDDI_CLIENT_CORE_BASE 0x108000 -#define LCD_CONTROL_BLOCK_BASE 0x110000 -#define SPI_BLOCK_BASE 0x120000 -#define PWM_BLOCK_BASE 0x140000 -#define SYSTEM_BLOCK1_BASE 0x160000 - -#define TTBUSSEL (MDDI_CLIENT_CORE_BASE|0x18) -#define DPSET0 (MDDI_CLIENT_CORE_BASE|0x1C) -#define DPSET1 (MDDI_CLIENT_CORE_BASE|0x20) -#define DPSUS (MDDI_CLIENT_CORE_BASE|0x24) -#define DPRUN (MDDI_CLIENT_CORE_BASE|0x28) -#define SYSCKENA (MDDI_CLIENT_CORE_BASE|0x2C) - -#define BITMAP0 (MDDI_CLIENT_CORE_BASE|0x44) -#define BITMAP1 (MDDI_CLIENT_CORE_BASE|0x48) -#define BITMAP2 (MDDI_CLIENT_CORE_BASE|0x4C) -#define BITMAP3 (MDDI_CLIENT_CORE_BASE|0x50) -#define BITMAP4 (MDDI_CLIENT_CORE_BASE|0x54) - -#define SRST (LCD_CONTROL_BLOCK_BASE|0x00) -#define PORT_ENB (LCD_CONTROL_BLOCK_BASE|0x04) -#define START (LCD_CONTROL_BLOCK_BASE|0x08) -#define PORT (LCD_CONTROL_BLOCK_BASE|0x0C) - -#define INTFLG (LCD_CONTROL_BLOCK_BASE|0x18) -#define INTMSK (LCD_CONTROL_BLOCK_BASE|0x1C) -#define MPLFBUF (LCD_CONTROL_BLOCK_BASE|0x20) - -#define PXL (LCD_CONTROL_BLOCK_BASE|0x30) -#define HCYCLE (LCD_CONTROL_BLOCK_BASE|0x34) -#define HSW (LCD_CONTROL_BLOCK_BASE|0x38) -#define HDE_START (LCD_CONTROL_BLOCK_BASE|0x3C) -#define HDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x40) -#define VCYCLE (LCD_CONTROL_BLOCK_BASE|0x44) -#define VSW (LCD_CONTROL_BLOCK_BASE|0x48) -#define VDE_START (LCD_CONTROL_BLOCK_BASE|0x4C) -#define VDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x50) -#define WAKEUP (LCD_CONTROL_BLOCK_BASE|0x54) -#define REGENB (LCD_CONTROL_BLOCK_BASE|0x5C) -#define VSYNIF (LCD_CONTROL_BLOCK_BASE|0x60) -#define WRSTB (LCD_CONTROL_BLOCK_BASE|0x64) -#define RDSTB (LCD_CONTROL_BLOCK_BASE|0x68) -#define ASY_DATA (LCD_CONTROL_BLOCK_BASE|0x6C) -#define ASY_DATB (LCD_CONTROL_BLOCK_BASE|0x70) -#define ASY_DATC (LCD_CONTROL_BLOCK_BASE|0x74) -#define ASY_DATD (LCD_CONTROL_BLOCK_BASE|0x78) -#define ASY_DATE (LCD_CONTROL_BLOCK_BASE|0x7C) -#define ASY_DATF (LCD_CONTROL_BLOCK_BASE|0x80) -#define ASY_DATG (LCD_CONTROL_BLOCK_BASE|0x84) -#define ASY_DATH (LCD_CONTROL_BLOCK_BASE|0x88) -#define ASY_CMDSET (LCD_CONTROL_BLOCK_BASE|0x8C) -#define MONI (LCD_CONTROL_BLOCK_BASE|0xB0) -#define VPOS (LCD_CONTROL_BLOCK_BASE|0xC0) - -#define SSICTL (SPI_BLOCK_BASE|0x00) -#define SSITIME (SPI_BLOCK_BASE|0x04) -#define SSITX (SPI_BLOCK_BASE|0x08) -#define SSIINTS (SPI_BLOCK_BASE|0x14) - -#define TIMER0LOAD (PWM_BLOCK_BASE|0x00) -#define TIMER0CTRL (PWM_BLOCK_BASE|0x08) -#define PWM0OFF (PWM_BLOCK_BASE|0x1C) -#define TIMER1LOAD (PWM_BLOCK_BASE|0x20) -#define TIMER1CTRL (PWM_BLOCK_BASE|0x28) -#define PWM1OFF (PWM_BLOCK_BASE|0x3C) -#define TIMER2LOAD (PWM_BLOCK_BASE|0x40) -#define TIMER2CTRL (PWM_BLOCK_BASE|0x48) -#define PWM2OFF (PWM_BLOCK_BASE|0x5C) -#define PWMCR (PWM_BLOCK_BASE|0x68) - -#define GPIOIS (GPIO_BLOCK_BASE|0x08) -#define GPIOIEV (GPIO_BLOCK_BASE|0x10) -#define GPIOIC (GPIO_BLOCK_BASE|0x20) - -#define WKREQ (SYSTEM_BLOCK1_BASE|0x00) -#define CLKENB (SYSTEM_BLOCK1_BASE|0x04) -#define DRAMPWR (SYSTEM_BLOCK1_BASE|0x08) -#define INTMASK (SYSTEM_BLOCK1_BASE|0x0C) -#define CNT_DIS (SYSTEM_BLOCK1_BASE|0x10) - -typedef enum { - TOSHIBA_STATE_OFF, - TOSHIBA_STATE_PRIM_SEC_STANDBY, - TOSHIBA_STATE_PRIM_SEC_READY, - TOSHIBA_STATE_PRIM_NORMAL_MODE, - TOSHIBA_STATE_SEC_NORMAL_MODE -} mddi_toshiba_state_t; - -static uint32 mddi_toshiba_curr_vpos; -static boolean mddi_toshiba_monitor_refresh_value = FALSE; -static boolean mddi_toshiba_report_refresh_measurements = FALSE; - -boolean mddi_toshiba_61Hz_refresh = TRUE; - -/* Modifications to timing to increase refresh rate to > 60Hz. - * 20MHz dot clock. - * 646 total rows. - * 506 total columns. - * refresh rate = 61.19Hz - */ -static uint32 mddi_toshiba_rows_per_second = 39526; -static uint32 mddi_toshiba_usecs_per_refresh = 16344; -static uint32 mddi_toshiba_rows_per_refresh = 646; -extern boolean mddi_vsync_detect_enabled; - -static msm_fb_vsync_handler_type mddi_toshiba_vsync_handler; -static void *mddi_toshiba_vsync_handler_arg; -static uint16 mddi_toshiba_vsync_attempts; - -static mddi_toshiba_state_t toshiba_state = TOSHIBA_STATE_OFF; - -static struct msm_panel_common_pdata *mddi_toshiba_pdata; - -static int mddi_toshiba_lcd_on(struct platform_device *pdev); -static int mddi_toshiba_lcd_off(struct platform_device *pdev); - -static void mddi_toshiba_state_transition(mddi_toshiba_state_t a, - mddi_toshiba_state_t b) -{ - if (toshiba_state != a) { - MDDI_MSG_ERR("toshiba state trans. (%d->%d) found %d\n", a, b, - toshiba_state); - } - toshiba_state = b; -} - -#define GORDON_REG_IMGCTL1 0x10 /* Image interface control 1 */ -#define GORDON_REG_IMGCTL2 0x11 /* Image interface control 2 */ -#define GORDON_REG_IMGSET1 0x12 /* Image interface settings 1 */ -#define GORDON_REG_IMGSET2 0x13 /* Image interface settings 2 */ -#define GORDON_REG_IVBP1 0x14 /* DM0: Vert back porch */ -#define GORDON_REG_IHBP1 0x15 /* DM0: Horiz back porch */ -#define GORDON_REG_IVNUM1 0x16 /* DM0: Num of vert lines */ -#define GORDON_REG_IHNUM1 0x17 /* DM0: Num of pixels per line */ -#define GORDON_REG_IVBP2 0x18 /* DM1: Vert back porch */ -#define GORDON_REG_IHBP2 0x19 /* DM1: Horiz back porch */ -#define GORDON_REG_IVNUM2 0x1A /* DM1: Num of vert lines */ -#define GORDON_REG_IHNUM2 0x1B /* DM1: Num of pixels per line */ -#define GORDON_REG_LCDIFCTL1 0x30 /* LCD interface control 1 */ -#define GORDON_REG_VALTRAN 0x31 /* LCD IF ctl: VALTRAN sync flag */ -#define GORDON_REG_AVCTL 0x33 -#define GORDON_REG_LCDIFCTL2 0x34 /* LCD interface control 2 */ -#define GORDON_REG_LCDIFCTL3 0x35 /* LCD interface control 3 */ -#define GORDON_REG_LCDIFSET1 0x36 /* LCD interface settings 1 */ -#define GORDON_REG_PCCTL 0x3C -#define GORDON_REG_TPARAM1 0x40 -#define GORDON_REG_TLCDIF1 0x41 -#define GORDON_REG_TSSPB_ST1 0x42 -#define GORDON_REG_TSSPB_ED1 0x43 -#define GORDON_REG_TSCK_ST1 0x44 -#define GORDON_REG_TSCK_WD1 0x45 -#define GORDON_REG_TGSPB_VST1 0x46 -#define GORDON_REG_TGSPB_VED1 0x47 -#define GORDON_REG_TGSPB_CH1 0x48 -#define GORDON_REG_TGCK_ST1 0x49 -#define GORDON_REG_TGCK_ED1 0x4A -#define GORDON_REG_TPCTL_ST1 0x4B -#define GORDON_REG_TPCTL_ED1 0x4C -#define GORDON_REG_TPCHG_ED1 0x4D -#define GORDON_REG_TCOM_CH1 0x4E -#define GORDON_REG_THBP1 0x4F -#define GORDON_REG_TPHCTL1 0x50 -#define GORDON_REG_EVPH1 0x51 -#define GORDON_REG_EVPL1 0x52 -#define GORDON_REG_EVNH1 0x53 -#define GORDON_REG_EVNL1 0x54 -#define GORDON_REG_TBIAS1 0x55 -#define GORDON_REG_TPARAM2 0x56 -#define GORDON_REG_TLCDIF2 0x57 -#define GORDON_REG_TSSPB_ST2 0x58 -#define GORDON_REG_TSSPB_ED2 0x59 -#define GORDON_REG_TSCK_ST2 0x5A -#define GORDON_REG_TSCK_WD2 0x5B -#define GORDON_REG_TGSPB_VST2 0x5C -#define GORDON_REG_TGSPB_VED2 0x5D -#define GORDON_REG_TGSPB_CH2 0x5E -#define GORDON_REG_TGCK_ST2 0x5F -#define GORDON_REG_TGCK_ED2 0x60 -#define GORDON_REG_TPCTL_ST2 0x61 -#define GORDON_REG_TPCTL_ED2 0x62 -#define GORDON_REG_TPCHG_ED2 0x63 -#define GORDON_REG_TCOM_CH2 0x64 -#define GORDON_REG_THBP2 0x65 -#define GORDON_REG_TPHCTL2 0x66 -#define GORDON_REG_EVPH2 0x67 -#define GORDON_REG_EVPL2 0x68 -#define GORDON_REG_EVNH2 0x69 -#define GORDON_REG_EVNL2 0x6A -#define GORDON_REG_TBIAS2 0x6B -#define GORDON_REG_POWCTL 0x80 -#define GORDON_REG_POWOSC1 0x81 -#define GORDON_REG_POWOSC2 0x82 -#define GORDON_REG_POWSET 0x83 -#define GORDON_REG_POWTRM1 0x85 -#define GORDON_REG_POWTRM2 0x86 -#define GORDON_REG_POWTRM3 0x87 -#define GORDON_REG_POWTRMSEL 0x88 -#define GORDON_REG_POWHIZ 0x89 - -void serigo(uint16 reg, uint8 data) -{ - uint32 mddi_val = 0; - mddi_queue_register_read(SSIINTS, &mddi_val, TRUE, 0); - if (mddi_val & (1 << 8)) - mddi_wait(1); - /* No De-assert of CS and send 2 bytes */ - mddi_val = 0x90000 | ((0x00FF & reg) << 8) | data; - mddi_queue_register_write(SSITX, mddi_val, TRUE, 0); -} - -void gordon_init(void) -{ - /* Image interface settings ***/ - serigo(GORDON_REG_IMGCTL2, 0x00); - serigo(GORDON_REG_IMGSET1, 0x01); - - /* Exchange the RGB signal for J510(Softbank mobile) */ - serigo(GORDON_REG_IMGSET2, 0x12); - serigo(GORDON_REG_LCDIFSET1, 0x00); - mddi_wait(2); - - /* Pre-charge settings */ - serigo(GORDON_REG_PCCTL, 0x09); - serigo(GORDON_REG_LCDIFCTL2, 0x1B); - mddi_wait(1); -} - -void gordon_disp_on(void) -{ - /*gordon_dispmode setting */ - /*VGA settings */ - serigo(GORDON_REG_TPARAM1, 0x30); - serigo(GORDON_REG_TLCDIF1, 0x00); - serigo(GORDON_REG_TSSPB_ST1, 0x8B); - serigo(GORDON_REG_TSSPB_ED1, 0x93); - mddi_wait(2); - serigo(GORDON_REG_TSCK_ST1, 0x88); - serigo(GORDON_REG_TSCK_WD1, 0x00); - serigo(GORDON_REG_TGSPB_VST1, 0x01); - serigo(GORDON_REG_TGSPB_VED1, 0x02); - mddi_wait(2); - serigo(GORDON_REG_TGSPB_CH1, 0x5E); - serigo(GORDON_REG_TGCK_ST1, 0x80); - serigo(GORDON_REG_TGCK_ED1, 0x3C); - serigo(GORDON_REG_TPCTL_ST1, 0x50); - mddi_wait(2); - serigo(GORDON_REG_TPCTL_ED1, 0x74); - serigo(GORDON_REG_TPCHG_ED1, 0x78); - serigo(GORDON_REG_TCOM_CH1, 0x50); - serigo(GORDON_REG_THBP1, 0x84); - mddi_wait(2); - serigo(GORDON_REG_TPHCTL1, 0x00); - serigo(GORDON_REG_EVPH1, 0x70); - serigo(GORDON_REG_EVPL1, 0x64); - serigo(GORDON_REG_EVNH1, 0x56); - mddi_wait(2); - serigo(GORDON_REG_EVNL1, 0x48); - serigo(GORDON_REG_TBIAS1, 0x88); - mddi_wait(2); - serigo(GORDON_REG_TPARAM2, 0x28); - serigo(GORDON_REG_TLCDIF2, 0x14); - serigo(GORDON_REG_TSSPB_ST2, 0x49); - serigo(GORDON_REG_TSSPB_ED2, 0x4B); - mddi_wait(2); - serigo(GORDON_REG_TSCK_ST2, 0x4A); - serigo(GORDON_REG_TSCK_WD2, 0x02); - serigo(GORDON_REG_TGSPB_VST2, 0x02); - serigo(GORDON_REG_TGSPB_VED2, 0x03); - mddi_wait(2); - serigo(GORDON_REG_TGSPB_CH2, 0x2F); - serigo(GORDON_REG_TGCK_ST2, 0x40); - serigo(GORDON_REG_TGCK_ED2, 0x1E); - serigo(GORDON_REG_TPCTL_ST2, 0x2C); - mddi_wait(2); - serigo(GORDON_REG_TPCTL_ED2, 0x3A); - serigo(GORDON_REG_TPCHG_ED2, 0x3C); - serigo(GORDON_REG_TCOM_CH2, 0x28); - serigo(GORDON_REG_THBP2, 0x4D); - mddi_wait(2); - serigo(GORDON_REG_TPHCTL2, 0x1A); - mddi_wait(2); - serigo(GORDON_REG_IVBP1, 0x02); - serigo(GORDON_REG_IHBP1, 0x90); - serigo(GORDON_REG_IVNUM1, 0xA0); - serigo(GORDON_REG_IHNUM1, 0x78); - mddi_wait(2); - serigo(GORDON_REG_IVBP2, 0x02); - serigo(GORDON_REG_IHBP2, 0x48); - serigo(GORDON_REG_IVNUM2, 0x50); - serigo(GORDON_REG_IHNUM2, 0x3C); - mddi_wait(2); - serigo(GORDON_REG_POWCTL, 0x03); - mddi_wait(15); - serigo(GORDON_REG_POWCTL, 0x07); - mddi_wait(15); - serigo(GORDON_REG_POWCTL, 0x0F); - mddi_wait(15); - serigo(GORDON_REG_AVCTL, 0x03); - mddi_wait(15); - serigo(GORDON_REG_POWCTL, 0x1F); - mddi_wait(15); - serigo(GORDON_REG_POWCTL, 0x5F); - mddi_wait(15); - serigo(GORDON_REG_POWCTL, 0x7F); - mddi_wait(15); - serigo(GORDON_REG_LCDIFCTL1, 0x02); - mddi_wait(15); - serigo(GORDON_REG_IMGCTL1, 0x00); - mddi_wait(15); - serigo(GORDON_REG_LCDIFCTL3, 0x00); - mddi_wait(15); - serigo(GORDON_REG_VALTRAN, 0x01); - mddi_wait(15); - serigo(GORDON_REG_LCDIFCTL1, 0x03); - serigo(GORDON_REG_LCDIFCTL1, 0x03); - mddi_wait(1); -} - -void gordon_disp_off(void) -{ - serigo(GORDON_REG_LCDIFCTL2, 0x7B); - serigo(GORDON_REG_VALTRAN, 0x01); - serigo(GORDON_REG_LCDIFCTL1, 0x02); - serigo(GORDON_REG_LCDIFCTL3, 0x01); - mddi_wait(20); - serigo(GORDON_REG_VALTRAN, 0x01); - serigo(GORDON_REG_IMGCTL1, 0x01); - serigo(GORDON_REG_LCDIFCTL1, 0x00); - mddi_wait(20); - serigo(GORDON_REG_POWCTL, 0x1F); - mddi_wait(40); - serigo(GORDON_REG_POWCTL, 0x07); - mddi_wait(40); - serigo(GORDON_REG_POWCTL, 0x03); - mddi_wait(40); - serigo(GORDON_REG_POWCTL, 0x00); - mddi_wait(40); -} - -void gordon_disp_init(void) -{ - gordon_init(); - mddi_wait(20); - gordon_disp_on(); -} - -static void toshiba_common_initial_setup(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) { - write_client_reg(DPSET0 , 0x4bec0066, TRUE); - write_client_reg(DPSET1 , 0x00000113, TRUE); - write_client_reg(DPSUS , 0x00000000, TRUE); - write_client_reg(DPRUN , 0x00000001, TRUE); - mddi_wait(5); - write_client_reg(SYSCKENA , 0x00000001, TRUE); - write_client_reg(CLKENB , 0x0000a0e9, TRUE); - - write_client_reg(GPIODATA , 0x03FF0000, TRUE); - write_client_reg(GPIODIR , 0x0000024D, TRUE); - write_client_reg(GPIOSEL , 0x00000173, TRUE); - write_client_reg(GPIOPC , 0x03C300C0, TRUE); - write_client_reg(WKREQ , 0x00000000, TRUE); - write_client_reg(GPIOIS , 0x00000000, TRUE); - write_client_reg(GPIOIEV , 0x00000001, TRUE); - write_client_reg(GPIOIC , 0x000003FF, TRUE); - write_client_reg(GPIODATA , 0x00040004, TRUE); - - write_client_reg(GPIODATA , 0x00080008, TRUE); - write_client_reg(DRAMPWR , 0x00000001, TRUE); - write_client_reg(CLKENB , 0x0000a0eb, TRUE); - write_client_reg(PWMCR , 0x00000000, TRUE); - mddi_wait(1); - - write_client_reg(SSICTL , 0x00060399, TRUE); - write_client_reg(SSITIME , 0x00000100, TRUE); - write_client_reg(CNT_DIS , 0x00000002, TRUE); - write_client_reg(SSICTL , 0x0006039b, TRUE); - - write_client_reg(SSITX , 0x00000000, TRUE); - mddi_wait(7); - write_client_reg(SSITX , 0x00000000, TRUE); - mddi_wait(7); - write_client_reg(SSITX , 0x00000000, TRUE); - mddi_wait(7); - - write_client_reg(SSITX , 0x000800BA, TRUE); - write_client_reg(SSITX , 0x00000111, TRUE); - write_client_reg(SSITX , 0x00080036, TRUE); - write_client_reg(SSITX , 0x00000100, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x0008003A, TRUE); - write_client_reg(SSITX , 0x00000160, TRUE); - write_client_reg(SSITX , 0x000800B1, TRUE); - write_client_reg(SSITX , 0x0000015D, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800B2, TRUE); - write_client_reg(SSITX , 0x00000133, TRUE); - write_client_reg(SSITX , 0x000800B3, TRUE); - write_client_reg(SSITX , 0x00000122, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800B4, TRUE); - write_client_reg(SSITX , 0x00000102, TRUE); - write_client_reg(SSITX , 0x000800B5, TRUE); - write_client_reg(SSITX , 0x0000011E, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800B6, TRUE); - write_client_reg(SSITX , 0x00000127, TRUE); - write_client_reg(SSITX , 0x000800B7, TRUE); - write_client_reg(SSITX , 0x00000103, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800B9, TRUE); - write_client_reg(SSITX , 0x00000124, TRUE); - write_client_reg(SSITX , 0x000800BD, TRUE); - write_client_reg(SSITX , 0x000001A1, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800BB, TRUE); - write_client_reg(SSITX , 0x00000100, TRUE); - write_client_reg(SSITX , 0x000800BF, TRUE); - write_client_reg(SSITX , 0x00000101, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800BE, TRUE); - write_client_reg(SSITX , 0x00000100, TRUE); - write_client_reg(SSITX , 0x000800C0, TRUE); - write_client_reg(SSITX , 0x00000111, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800C1, TRUE); - write_client_reg(SSITX , 0x00000111, TRUE); - write_client_reg(SSITX , 0x000800C2, TRUE); - write_client_reg(SSITX , 0x00000111, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800C3, TRUE); - write_client_reg(SSITX , 0x00080132, TRUE); - write_client_reg(SSITX , 0x00000132, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800C4, TRUE); - write_client_reg(SSITX , 0x00080132, TRUE); - write_client_reg(SSITX , 0x00000132, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800C5, TRUE); - write_client_reg(SSITX , 0x00080132, TRUE); - write_client_reg(SSITX , 0x00000132, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800C6, TRUE); - write_client_reg(SSITX , 0x00080132, TRUE); - write_client_reg(SSITX , 0x00000132, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800C7, TRUE); - write_client_reg(SSITX , 0x00080164, TRUE); - write_client_reg(SSITX , 0x00000145, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800C8, TRUE); - write_client_reg(SSITX , 0x00000144, TRUE); - write_client_reg(SSITX , 0x000800C9, TRUE); - write_client_reg(SSITX , 0x00000152, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800CA, TRUE); - write_client_reg(SSITX , 0x00000100, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800EC, TRUE); - write_client_reg(SSITX , 0x00080101, TRUE); - write_client_reg(SSITX , 0x000001FC, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800CF, TRUE); - write_client_reg(SSITX , 0x00000101, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800D0, TRUE); - write_client_reg(SSITX , 0x00080110, TRUE); - write_client_reg(SSITX , 0x00000104, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800D1, TRUE); - write_client_reg(SSITX , 0x00000101, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800D2, TRUE); - write_client_reg(SSITX , 0x00080100, TRUE); - write_client_reg(SSITX , 0x00000128, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800D3, TRUE); - write_client_reg(SSITX , 0x00080100, TRUE); - write_client_reg(SSITX , 0x00000128, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800D4, TRUE); - write_client_reg(SSITX , 0x00080126, TRUE); - write_client_reg(SSITX , 0x000001A4, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800D5, TRUE); - write_client_reg(SSITX , 0x00000120, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800EF, TRUE); - write_client_reg(SSITX , 0x00080132, TRUE); - write_client_reg(SSITX , 0x00000100, TRUE); - mddi_wait(1); - - write_client_reg(BITMAP0 , 0x032001E0, TRUE); - write_client_reg(BITMAP1 , 0x032001E0, TRUE); - write_client_reg(BITMAP2 , 0x014000F0, TRUE); - write_client_reg(BITMAP3 , 0x014000F0, TRUE); - write_client_reg(BITMAP4 , 0x014000F0, TRUE); - write_client_reg(CLKENB , 0x0000A1EB, TRUE); - write_client_reg(PORT_ENB , 0x00000001, TRUE); - write_client_reg(PORT , 0x00000004, TRUE); - write_client_reg(PXL , 0x00000002, TRUE); - write_client_reg(MPLFBUF , 0x00000000, TRUE); - write_client_reg(HCYCLE , 0x000000FD, TRUE); - write_client_reg(HSW , 0x00000003, TRUE); - write_client_reg(HDE_START , 0x00000007, TRUE); - write_client_reg(HDE_SIZE , 0x000000EF, TRUE); - write_client_reg(VCYCLE , 0x00000325, TRUE); - write_client_reg(VSW , 0x00000001, TRUE); - write_client_reg(VDE_START , 0x00000003, TRUE); - write_client_reg(VDE_SIZE , 0x0000031F, TRUE); - write_client_reg(START , 0x00000001, TRUE); - mddi_wait(32); - write_client_reg(SSITX , 0x000800BC, TRUE); - write_client_reg(SSITX , 0x00000180, TRUE); - write_client_reg(SSITX , 0x0008003B, TRUE); - write_client_reg(SSITX , 0x00000100, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800B0, TRUE); - write_client_reg(SSITX , 0x00000116, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x000800B8, TRUE); - write_client_reg(SSITX , 0x000801FF, TRUE); - write_client_reg(SSITX , 0x000001F5, TRUE); - mddi_wait(1); - write_client_reg(SSITX , 0x00000011, TRUE); - mddi_wait(5); - write_client_reg(SSITX , 0x00000029, TRUE); - return; - } - - if (TM_GET_PID(mfd->panel.id) == LCD_SHARP_2P4_VGA) { - write_client_reg(DPSET0, 0x4BEC0066, TRUE); - write_client_reg(DPSET1, 0x00000113, TRUE); - write_client_reg(DPSUS, 0x00000000, TRUE); - write_client_reg(DPRUN, 0x00000001, TRUE); - mddi_wait(14); - write_client_reg(SYSCKENA, 0x00000001, TRUE); - write_client_reg(CLKENB, 0x000000EF, TRUE); - write_client_reg(GPIO_BLOCK_BASE, 0x03FF0000, TRUE); - write_client_reg(GPIODIR, 0x0000024D, TRUE); - write_client_reg(SYSTEM_BLOCK2_BASE, 0x00000173, TRUE); - write_client_reg(GPIOPC, 0x03C300C0, TRUE); - write_client_reg(SYSTEM_BLOCK1_BASE, 0x00000000, TRUE); - write_client_reg(GPIOIS, 0x00000000, TRUE); - write_client_reg(GPIOIEV, 0x00000001, TRUE); - write_client_reg(GPIOIC, 0x000003FF, TRUE); - write_client_reg(GPIO_BLOCK_BASE, 0x00060006, TRUE); - write_client_reg(GPIO_BLOCK_BASE, 0x00080008, TRUE); - write_client_reg(GPIO_BLOCK_BASE, 0x02000200, TRUE); - write_client_reg(DRAMPWR, 0x00000001, TRUE); - write_client_reg(TIMER0CTRL, 0x00000060, TRUE); - write_client_reg(PWM_BLOCK_BASE, 0x00001388, TRUE); - write_client_reg(PWM0OFF, 0x00001387, TRUE); - write_client_reg(TIMER1CTRL, 0x00000060, TRUE); - write_client_reg(TIMER1LOAD, 0x00001388, TRUE); - write_client_reg(PWM1OFF, 0x00001387, TRUE); - write_client_reg(TIMER0CTRL, 0x000000E0, TRUE); - write_client_reg(TIMER1CTRL, 0x000000E0, TRUE); - write_client_reg(PWMCR, 0x00000003, TRUE); - mddi_wait(1); - write_client_reg(SPI_BLOCK_BASE, 0x00063111, TRUE); - write_client_reg(SSITIME, 0x00000100, TRUE); - write_client_reg(SPI_BLOCK_BASE, 0x00063113, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x00000000, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x00000000, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x00000000, TRUE); - mddi_wait(1); - write_client_reg(CLKENB, 0x0000A1EF, TRUE); - write_client_reg(START, 0x00000000, TRUE); - write_client_reg(WRSTB, 0x0000003F, TRUE); - write_client_reg(RDSTB, 0x00000432, TRUE); - write_client_reg(PORT_ENB, 0x00000002, TRUE); - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000000, TRUE); - write_client_reg(ASY_DATB, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(10); - write_client_reg(ASY_DATA, 0x80000000, TRUE); - write_client_reg(ASY_DATB, 0x80000000, TRUE); - write_client_reg(ASY_DATC, 0x80000000, TRUE); - write_client_reg(ASY_DATD, 0x80000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000009, TRUE); - write_client_reg(ASY_CMDSET, 0x00000008, TRUE); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(20); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - - write_client_reg(VSYNIF, 0x00000001, TRUE); - write_client_reg(PORT_ENB, 0x00000001, TRUE); - } else { - write_client_reg(DPSET0, 0x4BEC0066, TRUE); - write_client_reg(DPSET1, 0x00000113, TRUE); - write_client_reg(DPSUS, 0x00000000, TRUE); - write_client_reg(DPRUN, 0x00000001, TRUE); - mddi_wait(14); - write_client_reg(SYSCKENA, 0x00000001, TRUE); - write_client_reg(CLKENB, 0x000000EF, TRUE); - write_client_reg(GPIODATA, 0x03FF0000, TRUE); - write_client_reg(GPIODIR, 0x0000024D, TRUE); - write_client_reg(GPIOSEL, 0x00000173, TRUE); - write_client_reg(GPIOPC, 0x03C300C0, TRUE); - write_client_reg(WKREQ, 0x00000000, TRUE); - write_client_reg(GPIOIS, 0x00000000, TRUE); - write_client_reg(GPIOIEV, 0x00000001, TRUE); - write_client_reg(GPIOIC, 0x000003FF, TRUE); - write_client_reg(GPIODATA, 0x00060006, TRUE); - write_client_reg(GPIODATA, 0x00080008, TRUE); - write_client_reg(GPIODATA, 0x02000200, TRUE); - - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA) { - mddi_wait(400); - write_client_reg(DRAMPWR, 0x00000001, TRUE); - - write_client_reg(CNT_DIS, 0x00000002, TRUE); - write_client_reg(BITMAP0, 0x01E00320, TRUE); - write_client_reg(PORT_ENB, 0x00000001, TRUE); - write_client_reg(PORT, 0x00000004, TRUE); - write_client_reg(PXL, 0x0000003A, TRUE); - write_client_reg(MPLFBUF, 0x00000000, TRUE); - write_client_reg(HCYCLE, 0x00000253, TRUE); - write_client_reg(HSW, 0x00000003, TRUE); - write_client_reg(HDE_START, 0x00000017, TRUE); - write_client_reg(HDE_SIZE, 0x0000018F, TRUE); - write_client_reg(VCYCLE, 0x000001FF, TRUE); - write_client_reg(VSW, 0x00000001, TRUE); - write_client_reg(VDE_START, 0x00000003, TRUE); - write_client_reg(VDE_SIZE, 0x000001DF, TRUE); - write_client_reg(START, 0x00000001, TRUE); - mddi_wait(1); - write_client_reg(TIMER0CTRL, 0x00000060, TRUE); - write_client_reg(TIMER0LOAD, 0x00001388, TRUE); - write_client_reg(TIMER1CTRL, 0x00000060, TRUE); - write_client_reg(TIMER1LOAD, 0x00001388, TRUE); - write_client_reg(PWM1OFF, 0x00000087, TRUE); - } else { - write_client_reg(DRAMPWR, 0x00000001, TRUE); - write_client_reg(TIMER0CTRL, 0x00000060, TRUE); - write_client_reg(TIMER0LOAD, 0x00001388, TRUE); - write_client_reg(TIMER1CTRL, 0x00000060, TRUE); - write_client_reg(TIMER1LOAD, 0x00001388, TRUE); - write_client_reg(PWM1OFF, 0x00001387, TRUE); - } - - write_client_reg(TIMER0CTRL, 0x000000E0, TRUE); - write_client_reg(TIMER1CTRL, 0x000000E0, TRUE); - write_client_reg(PWMCR, 0x00000003, TRUE); - mddi_wait(1); - write_client_reg(SSICTL, 0x00000799, TRUE); - write_client_reg(SSITIME, 0x00000100, TRUE); - write_client_reg(SSICTL, 0x0000079b, TRUE); - write_client_reg(SSITX, 0x00000000, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x00000000, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x00000000, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x000800BA, TRUE); - write_client_reg(SSITX, 0x00000111, TRUE); - write_client_reg(SSITX, 0x00080036, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800BB, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - write_client_reg(SSITX, 0x0008003A, TRUE); - write_client_reg(SSITX, 0x00000160, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800BF, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - write_client_reg(SSITX, 0x000800B1, TRUE); - write_client_reg(SSITX, 0x0000015D, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800B2, TRUE); - write_client_reg(SSITX, 0x00000133, TRUE); - write_client_reg(SSITX, 0x000800B3, TRUE); - write_client_reg(SSITX, 0x00000122, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800B4, TRUE); - write_client_reg(SSITX, 0x00000102, TRUE); - write_client_reg(SSITX, 0x000800B5, TRUE); - write_client_reg(SSITX, 0x0000011F, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800B6, TRUE); - write_client_reg(SSITX, 0x00000128, TRUE); - write_client_reg(SSITX, 0x000800B7, TRUE); - write_client_reg(SSITX, 0x00000103, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800B9, TRUE); - write_client_reg(SSITX, 0x00000120, TRUE); - write_client_reg(SSITX, 0x000800BD, TRUE); - write_client_reg(SSITX, 0x00000102, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800BE, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - write_client_reg(SSITX, 0x000800C0, TRUE); - write_client_reg(SSITX, 0x00000111, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800C1, TRUE); - write_client_reg(SSITX, 0x00000111, TRUE); - write_client_reg(SSITX, 0x000800C2, TRUE); - write_client_reg(SSITX, 0x00000111, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800C3, TRUE); - write_client_reg(SSITX, 0x0008010A, TRUE); - write_client_reg(SSITX, 0x0000010A, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800C4, TRUE); - write_client_reg(SSITX, 0x00080160, TRUE); - write_client_reg(SSITX, 0x00000160, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800C5, TRUE); - write_client_reg(SSITX, 0x00080160, TRUE); - write_client_reg(SSITX, 0x00000160, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800C6, TRUE); - write_client_reg(SSITX, 0x00080160, TRUE); - write_client_reg(SSITX, 0x00000160, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800C7, TRUE); - write_client_reg(SSITX, 0x00080133, TRUE); - write_client_reg(SSITX, 0x00000143, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800C8, TRUE); - write_client_reg(SSITX, 0x00000144, TRUE); - write_client_reg(SSITX, 0x000800C9, TRUE); - write_client_reg(SSITX, 0x00000133, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800CA, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800EC, TRUE); - write_client_reg(SSITX, 0x00080102, TRUE); - write_client_reg(SSITX, 0x00000118, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800CF, TRUE); - write_client_reg(SSITX, 0x00000101, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D0, TRUE); - write_client_reg(SSITX, 0x00080110, TRUE); - write_client_reg(SSITX, 0x00000104, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D1, TRUE); - write_client_reg(SSITX, 0x00000101, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D2, TRUE); - write_client_reg(SSITX, 0x00080100, TRUE); - write_client_reg(SSITX, 0x0000013A, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D3, TRUE); - write_client_reg(SSITX, 0x00080100, TRUE); - write_client_reg(SSITX, 0x0000013A, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D4, TRUE); - write_client_reg(SSITX, 0x00080124, TRUE); - write_client_reg(SSITX, 0x0000016E, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x000800D5, TRUE); - write_client_reg(SSITX, 0x00000124, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800ED, TRUE); - write_client_reg(SSITX, 0x00080101, TRUE); - write_client_reg(SSITX, 0x0000010A, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D6, TRUE); - write_client_reg(SSITX, 0x00000101, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D7, TRUE); - write_client_reg(SSITX, 0x00080110, TRUE); - write_client_reg(SSITX, 0x0000010A, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D8, TRUE); - write_client_reg(SSITX, 0x00000101, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800D9, TRUE); - write_client_reg(SSITX, 0x00080100, TRUE); - write_client_reg(SSITX, 0x00000114, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800DE, TRUE); - write_client_reg(SSITX, 0x00080100, TRUE); - write_client_reg(SSITX, 0x00000114, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800DF, TRUE); - write_client_reg(SSITX, 0x00080112, TRUE); - write_client_reg(SSITX, 0x0000013F, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800E0, TRUE); - write_client_reg(SSITX, 0x0000010B, TRUE); - write_client_reg(SSITX, 0x000800E2, TRUE); - write_client_reg(SSITX, 0x00000101, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800E3, TRUE); - write_client_reg(SSITX, 0x00000136, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800E4, TRUE); - write_client_reg(SSITX, 0x00080100, TRUE); - write_client_reg(SSITX, 0x00000103, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800E5, TRUE); - write_client_reg(SSITX, 0x00080102, TRUE); - write_client_reg(SSITX, 0x00000104, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800E6, TRUE); - write_client_reg(SSITX, 0x00000103, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800E7, TRUE); - write_client_reg(SSITX, 0x00080104, TRUE); - write_client_reg(SSITX, 0x0000010A, TRUE); - mddi_wait(2); - write_client_reg(SSITX, 0x000800E8, TRUE); - write_client_reg(SSITX, 0x00000104, TRUE); - write_client_reg(CLKENB, 0x000001EF, TRUE); - write_client_reg(START, 0x00000000, TRUE); - write_client_reg(WRSTB, 0x0000003F, TRUE); - write_client_reg(RDSTB, 0x00000432, TRUE); - write_client_reg(PORT_ENB, 0x00000002, TRUE); - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000000, TRUE); - write_client_reg(ASY_DATB, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(10); - write_client_reg(ASY_DATA, 0x80000000, TRUE); - write_client_reg(ASY_DATB, 0x80000000, TRUE); - write_client_reg(ASY_DATC, 0x80000000, TRUE); - write_client_reg(ASY_DATD, 0x80000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000009, TRUE); - write_client_reg(ASY_CMDSET, 0x00000008, TRUE); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(20); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - write_client_reg(VSYNIF, 0x00000001, TRUE); - write_client_reg(PORT_ENB, 0x00000001, TRUE); - } - - mddi_toshiba_state_transition(TOSHIBA_STATE_PRIM_SEC_STANDBY, - TOSHIBA_STATE_PRIM_SEC_READY); -} - -static void toshiba_prim_start(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - if (TM_GET_PID(mfd->panel.id) == LCD_SHARP_2P4_VGA) { - write_client_reg(BITMAP1, 0x01E000F0, TRUE); - write_client_reg(BITMAP2, 0x01E000F0, TRUE); - write_client_reg(BITMAP3, 0x01E000F0, TRUE); - write_client_reg(BITMAP4, 0x00DC00B0, TRUE); - write_client_reg(CLKENB, 0x000001EF, TRUE); - write_client_reg(PORT_ENB, 0x00000001, TRUE); - write_client_reg(PORT, 0x00000016, TRUE); - write_client_reg(PXL, 0x00000002, TRUE); - write_client_reg(MPLFBUF, 0x00000000, TRUE); - write_client_reg(HCYCLE, 0x00000185, TRUE); - write_client_reg(HSW, 0x00000018, TRUE); - write_client_reg(HDE_START, 0x0000004A, TRUE); - write_client_reg(HDE_SIZE, 0x000000EF, TRUE); - write_client_reg(VCYCLE, 0x0000028E, TRUE); - write_client_reg(VSW, 0x00000004, TRUE); - write_client_reg(VDE_START, 0x00000009, TRUE); - write_client_reg(VDE_SIZE, 0x0000027F, TRUE); - write_client_reg(START, 0x00000001, TRUE); - write_client_reg(SYSTEM_BLOCK1_BASE, 0x00000002, TRUE); - } else{ - - write_client_reg(VSYNIF, 0x00000001, TRUE); - write_client_reg(PORT_ENB, 0x00000001, TRUE); - write_client_reg(BITMAP1, 0x01E000F0, TRUE); - write_client_reg(BITMAP2, 0x01E000F0, TRUE); - write_client_reg(BITMAP3, 0x01E000F0, TRUE); - write_client_reg(BITMAP4, 0x00DC00B0, TRUE); - write_client_reg(CLKENB, 0x000001EF, TRUE); - write_client_reg(PORT_ENB, 0x00000001, TRUE); - write_client_reg(PORT, 0x00000004, TRUE); - write_client_reg(PXL, 0x00000002, TRUE); - write_client_reg(MPLFBUF, 0x00000000, TRUE); - - if (mddi_toshiba_61Hz_refresh) { - write_client_reg(HCYCLE, 0x000000FC, TRUE); - mddi_toshiba_rows_per_second = 39526; - mddi_toshiba_rows_per_refresh = 646; - mddi_toshiba_usecs_per_refresh = 16344; - } else { - write_client_reg(HCYCLE, 0x0000010b, TRUE); - mddi_toshiba_rows_per_second = 37313; - mddi_toshiba_rows_per_refresh = 646; - mddi_toshiba_usecs_per_refresh = 17313; - } - - write_client_reg(HSW, 0x00000003, TRUE); - write_client_reg(HDE_START, 0x00000007, TRUE); - write_client_reg(HDE_SIZE, 0x000000EF, TRUE); - write_client_reg(VCYCLE, 0x00000285, TRUE); - write_client_reg(VSW, 0x00000001, TRUE); - write_client_reg(VDE_START, 0x00000003, TRUE); - write_client_reg(VDE_SIZE, 0x0000027F, TRUE); - write_client_reg(START, 0x00000001, TRUE); - mddi_wait(10); - write_client_reg(SSITX, 0x000800BC, TRUE); - write_client_reg(SSITX, 0x00000180, TRUE); - write_client_reg(SSITX, 0x0008003B, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x000800B0, TRUE); - write_client_reg(SSITX, 0x00000116, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x000800B8, TRUE); - write_client_reg(SSITX, 0x000801FF, TRUE); - write_client_reg(SSITX, 0x000001F5, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x00000011, TRUE); - write_client_reg(SSITX, 0x00000029, TRUE); - write_client_reg(WKREQ, 0x00000000, TRUE); - write_client_reg(WAKEUP, 0x00000000, TRUE); - write_client_reg(INTMSK, 0x00000001, TRUE); - } - - mddi_toshiba_state_transition(TOSHIBA_STATE_PRIM_SEC_READY, - TOSHIBA_STATE_PRIM_NORMAL_MODE); -} - -static void toshiba_sec_start(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(PORT_ENB, 0x00000002, TRUE); - write_client_reg(CLKENB, 0x000011EF, TRUE); - write_client_reg(BITMAP0, 0x028001E0, TRUE); - write_client_reg(BITMAP1, 0x00000000, TRUE); - write_client_reg(BITMAP2, 0x00000000, TRUE); - write_client_reg(BITMAP3, 0x00000000, TRUE); - write_client_reg(BITMAP4, 0x00DC00B0, TRUE); - write_client_reg(PORT, 0x00000000, TRUE); - write_client_reg(PXL, 0x00000000, TRUE); - write_client_reg(MPLFBUF, 0x00000004, TRUE); - write_client_reg(HCYCLE, 0x0000006B, TRUE); - write_client_reg(HSW, 0x00000003, TRUE); - write_client_reg(HDE_START, 0x00000007, TRUE); - write_client_reg(HDE_SIZE, 0x00000057, TRUE); - write_client_reg(VCYCLE, 0x000000E6, TRUE); - write_client_reg(VSW, 0x00000001, TRUE); - write_client_reg(VDE_START, 0x00000003, TRUE); - write_client_reg(VDE_SIZE, 0x000000DB, TRUE); - write_client_reg(ASY_DATA, 0x80000001, TRUE); - write_client_reg(ASY_DATB, 0x0000011B, TRUE); - write_client_reg(ASY_DATC, 0x80000002, TRUE); - write_client_reg(ASY_DATD, 0x00000700, TRUE); - write_client_reg(ASY_DATE, 0x80000003, TRUE); - write_client_reg(ASY_DATF, 0x00000230, TRUE); - write_client_reg(ASY_DATG, 0x80000008, TRUE); - write_client_reg(ASY_DATH, 0x00000402, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000009, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_DATC, 0x8000000B, TRUE); - write_client_reg(ASY_DATD, 0x00000000, TRUE); - write_client_reg(ASY_DATE, 0x8000000C, TRUE); - write_client_reg(ASY_DATF, 0x00000000, TRUE); - write_client_reg(ASY_DATG, 0x8000000D, TRUE); - write_client_reg(ASY_DATH, 0x00000409, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x8000000E, TRUE); - write_client_reg(ASY_DATB, 0x00000409, TRUE); - write_client_reg(ASY_DATC, 0x80000030, TRUE); - write_client_reg(ASY_DATD, 0x00000000, TRUE); - write_client_reg(ASY_DATE, 0x80000031, TRUE); - write_client_reg(ASY_DATF, 0x00000100, TRUE); - write_client_reg(ASY_DATG, 0x80000032, TRUE); - write_client_reg(ASY_DATH, 0x00000104, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000033, TRUE); - write_client_reg(ASY_DATB, 0x00000400, TRUE); - write_client_reg(ASY_DATC, 0x80000034, TRUE); - write_client_reg(ASY_DATD, 0x00000306, TRUE); - write_client_reg(ASY_DATE, 0x80000035, TRUE); - write_client_reg(ASY_DATF, 0x00000706, TRUE); - write_client_reg(ASY_DATG, 0x80000036, TRUE); - write_client_reg(ASY_DATH, 0x00000707, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000037, TRUE); - write_client_reg(ASY_DATB, 0x00000004, TRUE); - write_client_reg(ASY_DATC, 0x80000038, TRUE); - write_client_reg(ASY_DATD, 0x00000000, TRUE); - write_client_reg(ASY_DATE, 0x80000039, TRUE); - write_client_reg(ASY_DATF, 0x00000000, TRUE); - write_client_reg(ASY_DATG, 0x8000003A, TRUE); - write_client_reg(ASY_DATH, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000044, TRUE); - write_client_reg(ASY_DATB, 0x0000AF00, TRUE); - write_client_reg(ASY_DATC, 0x80000045, TRUE); - write_client_reg(ASY_DATD, 0x0000DB00, TRUE); - write_client_reg(ASY_DATE, 0x08000042, TRUE); - write_client_reg(ASY_DATF, 0x0000DB00, TRUE); - write_client_reg(ASY_DATG, 0x80000021, TRUE); - write_client_reg(ASY_DATH, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(PXL, 0x0000000C, TRUE); - write_client_reg(VSYNIF, 0x00000001, TRUE); - write_client_reg(ASY_DATA, 0x80000022, TRUE); - write_client_reg(ASY_CMDSET, 0x00000003, TRUE); - write_client_reg(START, 0x00000001, TRUE); - mddi_wait(60); - write_client_reg(PXL, 0x00000000, TRUE); - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(START, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000050, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_DATC, 0x80000051, TRUE); - write_client_reg(ASY_DATD, 0x00000E00, TRUE); - write_client_reg(ASY_DATE, 0x80000052, TRUE); - write_client_reg(ASY_DATF, 0x00000D01, TRUE); - write_client_reg(ASY_DATG, 0x80000053, TRUE); - write_client_reg(ASY_DATH, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - write_client_reg(ASY_DATA, 0x80000058, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_DATC, 0x8000005A, TRUE); - write_client_reg(ASY_DATD, 0x00000E01, TRUE); - write_client_reg(ASY_CMDSET, 0x00000009, TRUE); - write_client_reg(ASY_CMDSET, 0x00000008, TRUE); - write_client_reg(ASY_DATA, 0x80000011, TRUE); - write_client_reg(ASY_DATB, 0x00000812, TRUE); - write_client_reg(ASY_DATC, 0x80000012, TRUE); - write_client_reg(ASY_DATD, 0x00000003, TRUE); - write_client_reg(ASY_DATE, 0x80000013, TRUE); - write_client_reg(ASY_DATF, 0x00000909, TRUE); - write_client_reg(ASY_DATG, 0x80000010, TRUE); - write_client_reg(ASY_DATH, 0x00000040, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - mddi_wait(40); - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00000340, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(60); - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00003340, TRUE); - write_client_reg(ASY_DATC, 0x80000007, TRUE); - write_client_reg(ASY_DATD, 0x00004007, TRUE); - write_client_reg(ASY_CMDSET, 0x00000009, TRUE); - write_client_reg(ASY_CMDSET, 0x00000008, TRUE); - mddi_wait(1); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004017, TRUE); - write_client_reg(ASY_DATC, 0x8000005B, TRUE); - write_client_reg(ASY_DATD, 0x00000000, TRUE); - write_client_reg(ASY_DATE, 0x80000059, TRUE); - write_client_reg(ASY_DATF, 0x00000011, TRUE); - write_client_reg(ASY_CMDSET, 0x0000000D, TRUE); - write_client_reg(ASY_CMDSET, 0x0000000C, TRUE); - mddi_wait(20); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - /* LTPS I/F control */ - write_client_reg(ASY_DATB, 0x00000019, TRUE); - /* Direct cmd transfer enable */ - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - /* Direct cmd transfer disable */ - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(20); - /* Index setting of SUB LCDD */ - write_client_reg(ASY_DATA, 0x80000059, TRUE); - /* LTPS I/F control */ - write_client_reg(ASY_DATB, 0x00000079, TRUE); - /* Direct cmd transfer enable */ - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - /* Direct cmd transfer disable */ - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(20); - /* Index setting of SUB LCDD */ - write_client_reg(ASY_DATA, 0x80000059, TRUE); - /* LTPS I/F control */ - write_client_reg(ASY_DATB, 0x000003FD, TRUE); - /* Direct cmd transfer enable */ - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - /* Direct cmd transfer disable */ - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(20); - mddi_toshiba_state_transition(TOSHIBA_STATE_PRIM_SEC_READY, - TOSHIBA_STATE_SEC_NORMAL_MODE); -} - -static void toshiba_prim_lcd_off(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_SHARP_2P4_VGA) { - gordon_disp_off(); - } else{ - - /* Main panel power off (Deep standby in) */ - write_client_reg(SSITX, 0x000800BC, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - write_client_reg(SSITX, 0x00000028, TRUE); - mddi_wait(1); - write_client_reg(SSITX, 0x000800B8, TRUE); - write_client_reg(SSITX, 0x00000180, TRUE); - write_client_reg(SSITX, 0x00000102, TRUE); - write_client_reg(SSITX, 0x00000010, TRUE); - } - write_client_reg(PORT, 0x00000003, TRUE); - write_client_reg(REGENB, 0x00000001, TRUE); - mddi_wait(1); - write_client_reg(PXL, 0x00000000, TRUE); - write_client_reg(START, 0x00000000, TRUE); - write_client_reg(REGENB, 0x00000001, TRUE); - mddi_wait(3); - if (TM_GET_PID(mfd->panel.id) != LCD_SHARP_2P4_VGA) { - write_client_reg(SSITX, 0x000800B0, TRUE); - write_client_reg(SSITX, 0x00000100, TRUE); - } - mddi_toshiba_state_transition(TOSHIBA_STATE_PRIM_NORMAL_MODE, - TOSHIBA_STATE_PRIM_SEC_STANDBY); -} - -static void toshiba_sec_lcd_off(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(PORT_ENB, 0x00000002, TRUE); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004016, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000019, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x0000000B, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000002, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(4); - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00000300, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(4); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004004, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(PORT, 0x00000000, TRUE); - write_client_reg(PXL, 0x00000000, TRUE); - write_client_reg(START, 0x00000000, TRUE); - write_client_reg(VSYNIF, 0x00000001, TRUE); - write_client_reg(PORT_ENB, 0x00000001, TRUE); - write_client_reg(REGENB, 0x00000001, TRUE); - mddi_toshiba_state_transition(TOSHIBA_STATE_SEC_NORMAL_MODE, - TOSHIBA_STATE_PRIM_SEC_STANDBY); -} - -static void toshiba_sec_cont_update_start(struct msm_fb_data_type *mfd) -{ - - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(PORT_ENB, 0x00000002, TRUE); - write_client_reg(INTMASK, 0x00000001, TRUE); - write_client_reg(TTBUSSEL, 0x0000000B, TRUE); - write_client_reg(MONI, 0x00000008, TRUE); - write_client_reg(CLKENB, 0x000000EF, TRUE); - write_client_reg(CLKENB, 0x000010EF, TRUE); - write_client_reg(CLKENB, 0x000011EF, TRUE); - write_client_reg(BITMAP4, 0x00DC00B0, TRUE); - write_client_reg(HCYCLE, 0x0000006B, TRUE); - write_client_reg(HSW, 0x00000003, TRUE); - write_client_reg(HDE_START, 0x00000002, TRUE); - write_client_reg(HDE_SIZE, 0x00000057, TRUE); - write_client_reg(VCYCLE, 0x000000E6, TRUE); - write_client_reg(VSW, 0x00000001, TRUE); - write_client_reg(VDE_START, 0x00000003, TRUE); - write_client_reg(VDE_SIZE, 0x000000DB, TRUE); - write_client_reg(WRSTB, 0x00000015, TRUE); - write_client_reg(MPLFBUF, 0x00000004, TRUE); - write_client_reg(ASY_DATA, 0x80000021, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_DATC, 0x80000022, TRUE); - write_client_reg(ASY_CMDSET, 0x00000007, TRUE); - write_client_reg(PXL, 0x00000089, TRUE); - write_client_reg(VSYNIF, 0x00000001, TRUE); - mddi_wait(2); -} - -static void toshiba_sec_cont_update_stop(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - write_client_reg(PXL, 0x00000000, TRUE); - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(START, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - mddi_wait(3); - write_client_reg(SRST, 0x00000002, TRUE); - mddi_wait(3); - write_client_reg(SRST, 0x00000003, TRUE); -} - -static void toshiba_sec_backlight_on(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - write_client_reg(TIMER0CTRL, 0x00000060, TRUE); - write_client_reg(TIMER0LOAD, 0x00001388, TRUE); - write_client_reg(PWM0OFF, 0x00000001, TRUE); - write_client_reg(TIMER1CTRL, 0x00000060, TRUE); - write_client_reg(TIMER1LOAD, 0x00001388, TRUE); - write_client_reg(PWM1OFF, 0x00001387, TRUE); - write_client_reg(TIMER0CTRL, 0x000000E0, TRUE); - write_client_reg(TIMER1CTRL, 0x000000E0, TRUE); - write_client_reg(PWMCR, 0x00000003, TRUE); -} - -static void toshiba_sec_sleep_in(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(PORT_ENB, 0x00000002, TRUE); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004016, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000019, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x0000000B, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000002, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(4); - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00000300, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(4); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000000, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004004, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(PORT, 0x00000000, TRUE); - write_client_reg(PXL, 0x00000000, TRUE); - write_client_reg(START, 0x00000000, TRUE); - write_client_reg(REGENB, 0x00000001, TRUE); - /* Sleep in sequence */ - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00000302, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); -} - -static void toshiba_sec_sleep_out(struct msm_fb_data_type *mfd) -{ - if (TM_GET_PID(mfd->panel.id) == LCD_TOSHIBA_2P4_WVGA_PT) - return; - - write_client_reg(VSYNIF, 0x00000000, TRUE); - write_client_reg(PORT_ENB, 0x00000002, TRUE); - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00000300, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - /* Display ON sequence */ - write_client_reg(ASY_DATA, 0x80000011, TRUE); - write_client_reg(ASY_DATB, 0x00000812, TRUE); - write_client_reg(ASY_DATC, 0x80000012, TRUE); - write_client_reg(ASY_DATD, 0x00000003, TRUE); - write_client_reg(ASY_DATE, 0x80000013, TRUE); - write_client_reg(ASY_DATF, 0x00000909, TRUE); - write_client_reg(ASY_DATG, 0x80000010, TRUE); - write_client_reg(ASY_DATH, 0x00000040, TRUE); - write_client_reg(ASY_CMDSET, 0x00000001, TRUE); - write_client_reg(ASY_CMDSET, 0x00000000, TRUE); - mddi_wait(4); - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00000340, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(6); - write_client_reg(ASY_DATA, 0x80000010, TRUE); - write_client_reg(ASY_DATB, 0x00003340, TRUE); - write_client_reg(ASY_DATC, 0x80000007, TRUE); - write_client_reg(ASY_DATD, 0x00004007, TRUE); - write_client_reg(ASY_CMDSET, 0x00000009, TRUE); - write_client_reg(ASY_CMDSET, 0x00000008, TRUE); - mddi_wait(1); - write_client_reg(ASY_DATA, 0x80000007, TRUE); - write_client_reg(ASY_DATB, 0x00004017, TRUE); - write_client_reg(ASY_DATC, 0x8000005B, TRUE); - write_client_reg(ASY_DATD, 0x00000000, TRUE); - write_client_reg(ASY_DATE, 0x80000059, TRUE); - write_client_reg(ASY_DATF, 0x00000011, TRUE); - write_client_reg(ASY_CMDSET, 0x0000000D, TRUE); - write_client_reg(ASY_CMDSET, 0x0000000C, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000019, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x00000079, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); - write_client_reg(ASY_DATA, 0x80000059, TRUE); - write_client_reg(ASY_DATB, 0x000003FD, TRUE); - write_client_reg(ASY_CMDSET, 0x00000005, TRUE); - write_client_reg(ASY_CMDSET, 0x00000004, TRUE); - mddi_wait(2); -} - -static void mddi_toshiba_lcd_set_backlight(struct msm_fb_data_type *mfd) -{ - int32 level; - int ret = -EPERM; - int max = mfd->panel_info.bl_max; - int min = mfd->panel_info.bl_min; - int i = 0; - - if (mddi_toshiba_pdata && mddi_toshiba_pdata->pmic_backlight) { - while (i++ < 3) { - ret = mddi_toshiba_pdata->pmic_backlight(mfd->bl_level); - if (!ret) - return; - msleep(10); - } - printk(KERN_WARNING "%s: pmic_backlight Failed\n", __func__); - } - - - if (ret && mddi_toshiba_pdata && mddi_toshiba_pdata->backlight_level) { - level = mddi_toshiba_pdata->backlight_level(mfd->bl_level, - max, min); - - if (level < 0) - return; - - if (TM_GET_PID(mfd->panel.id) == LCD_SHARP_2P4_VGA) - write_client_reg(TIMER0LOAD, 0x00001388, TRUE); - } else { - if (!max) - level = 0; - else - level = (mfd->bl_level * 4999) / max; - } - - write_client_reg(PWM0OFF, level, TRUE); -} - -static void mddi_toshiba_vsync_set_handler(msm_fb_vsync_handler_type handler, /* ISR to be executed */ - void *arg) -{ - boolean error = FALSE; - unsigned long flags; - - /* Disable interrupts */ - spin_lock_irqsave(&mddi_host_spin_lock, flags); - /* INTLOCK(); */ - - if (mddi_toshiba_vsync_handler != NULL) { - error = TRUE; - } else { - /* Register the handler for this particular GROUP interrupt source */ - mddi_toshiba_vsync_handler = handler; - mddi_toshiba_vsync_handler_arg = arg; - } - - /* Restore interrupts */ - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - /* MDDI_INTFREE(); */ - if (error) { - MDDI_MSG_ERR("MDDI: Previous Vsync handler never called\n"); - } else { - /* Enable the vsync wakeup */ - mddi_queue_register_write(INTMSK, 0x0000, FALSE, 0); - - mddi_toshiba_vsync_attempts = 1; - mddi_vsync_detect_enabled = TRUE; - } -} /* mddi_toshiba_vsync_set_handler */ - -static void mddi_toshiba_lcd_vsync_detected(boolean detected) -{ - /* static timetick_type start_time = 0; */ - static struct timeval start_time; - static boolean first_time = TRUE; - /* uint32 mdp_cnt_val = 0; */ - /* timetick_type elapsed_us; */ - struct timeval now; - uint32 elapsed_us; - uint32 num_vsyncs; - - if ((detected) || (mddi_toshiba_vsync_attempts > 5)) { - if ((detected) && (mddi_toshiba_monitor_refresh_value)) { - /* if (start_time != 0) */ - if (!first_time) { - jiffies_to_timeval(jiffies, &now); - elapsed_us = - (now.tv_sec - start_time.tv_sec) * 1000000 + - now.tv_usec - start_time.tv_usec; - /* - * LCD is configured for a refresh every usecs, - * so to determine the number of vsyncs that - * have occurred since the last measurement - * add half that to the time difference and - * divide by the refresh rate. - */ - num_vsyncs = (elapsed_us + - (mddi_toshiba_usecs_per_refresh >> - 1)) / - mddi_toshiba_usecs_per_refresh; - /* - * LCD is configured for * hsyncs (rows) per - * refresh cycle. Calculate new rows_per_second - * value based upon these new measurements. - * MDP can update with this new value. - */ - mddi_toshiba_rows_per_second = - (mddi_toshiba_rows_per_refresh * 1000 * - num_vsyncs) / (elapsed_us / 1000); - } - /* start_time = timetick_get(); */ - first_time = FALSE; - jiffies_to_timeval(jiffies, &start_time); - if (mddi_toshiba_report_refresh_measurements) { - (void)mddi_queue_register_read_int(VPOS, - &mddi_toshiba_curr_vpos); - /* mdp_cnt_val = MDP_LINE_COUNT; */ - } - } - /* if detected = TRUE, client initiated wakeup was detected */ - if (mddi_toshiba_vsync_handler != NULL) { - (*mddi_toshiba_vsync_handler) - (mddi_toshiba_vsync_handler_arg); - mddi_toshiba_vsync_handler = NULL; - } - mddi_vsync_detect_enabled = FALSE; - mddi_toshiba_vsync_attempts = 0; - /* need to disable the interrupt wakeup */ - if (!mddi_queue_register_write_int(INTMSK, 0x0001)) - MDDI_MSG_ERR("Vsync interrupt disable failed!\n"); - if (!detected) { - /* give up after 5 failed attempts but show error */ - MDDI_MSG_NOTICE("Vsync detection failed!\n"); - } else if ((mddi_toshiba_monitor_refresh_value) && - (mddi_toshiba_report_refresh_measurements)) { - MDDI_MSG_NOTICE(" Last Line Counter=%d!\n", - mddi_toshiba_curr_vpos); - /* MDDI_MSG_NOTICE(" MDP Line Counter=%d!\n",mdp_cnt_val); */ - MDDI_MSG_NOTICE(" Lines Per Second=%d!\n", - mddi_toshiba_rows_per_second); - } - /* clear the interrupt */ - if (!mddi_queue_register_write_int(INTFLG, 0x0001)) - MDDI_MSG_ERR("Vsync interrupt clear failed!\n"); - } else { - /* if detected = FALSE, we woke up from hibernation, but did not - * detect client initiated wakeup. - */ - mddi_toshiba_vsync_attempts++; - } -} - -static void mddi_toshiba_prim_init(struct msm_fb_data_type *mfd) -{ - - switch (toshiba_state) { - case TOSHIBA_STATE_PRIM_SEC_READY: - break; - case TOSHIBA_STATE_OFF: - toshiba_state = TOSHIBA_STATE_PRIM_SEC_STANDBY; - toshiba_common_initial_setup(mfd); - break; - case TOSHIBA_STATE_PRIM_SEC_STANDBY: - toshiba_common_initial_setup(mfd); - break; - case TOSHIBA_STATE_SEC_NORMAL_MODE: - toshiba_sec_cont_update_stop(mfd); - toshiba_sec_sleep_in(mfd); - toshiba_sec_sleep_out(mfd); - toshiba_sec_lcd_off(mfd); - toshiba_common_initial_setup(mfd); - break; - default: - MDDI_MSG_ERR("mddi_toshiba_prim_init from state %d\n", - toshiba_state); - } - - toshiba_prim_start(mfd); - if (TM_GET_PID(mfd->panel.id) == LCD_SHARP_2P4_VGA) - gordon_disp_init(); - mddi_host_write_pix_attr_reg(0x00C3); -} - -static void mddi_toshiba_sec_init(struct msm_fb_data_type *mfd) -{ - - switch (toshiba_state) { - case TOSHIBA_STATE_PRIM_SEC_READY: - break; - case TOSHIBA_STATE_PRIM_SEC_STANDBY: - toshiba_common_initial_setup(mfd); - break; - case TOSHIBA_STATE_PRIM_NORMAL_MODE: - toshiba_prim_lcd_off(mfd); - toshiba_common_initial_setup(mfd); - break; - default: - MDDI_MSG_ERR("mddi_toshiba_sec_init from state %d\n", - toshiba_state); - } - - toshiba_sec_start(mfd); - toshiba_sec_backlight_on(mfd); - toshiba_sec_cont_update_start(mfd); - mddi_host_write_pix_attr_reg(0x0400); -} - -static void mddi_toshiba_lcd_powerdown(struct msm_fb_data_type *mfd) -{ - switch (toshiba_state) { - case TOSHIBA_STATE_PRIM_SEC_READY: - mddi_toshiba_prim_init(mfd); - mddi_toshiba_lcd_powerdown(mfd); - return; - case TOSHIBA_STATE_PRIM_SEC_STANDBY: - break; - case TOSHIBA_STATE_PRIM_NORMAL_MODE: - toshiba_prim_lcd_off(mfd); - break; - case TOSHIBA_STATE_SEC_NORMAL_MODE: - toshiba_sec_cont_update_stop(mfd); - toshiba_sec_sleep_in(mfd); - toshiba_sec_sleep_out(mfd); - toshiba_sec_lcd_off(mfd); - break; - default: - MDDI_MSG_ERR("mddi_toshiba_lcd_powerdown from state %d\n", - toshiba_state); - } -} - -static int mddi_sharpgordon_firsttime = 1; - -static int mddi_toshiba_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - mfd = platform_get_drvdata(pdev); - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - mddi_host_client_cnt_reset(); - - if (TM_GET_DID(mfd->panel.id) == TOSHIBA_VGA_PRIM) - mddi_toshiba_prim_init(mfd); - else - mddi_toshiba_sec_init(mfd); - if (TM_GET_PID(mfd->panel.id) == LCD_SHARP_2P4_VGA) { - if (mddi_sharpgordon_firsttime) { - mddi_sharpgordon_firsttime = 0; - write_client_reg(REGENB, 0x00000001, TRUE); - } - } - return 0; -} - -static int mddi_toshiba_lcd_off(struct platform_device *pdev) -{ - if (mddi_toshiba_vsync_handler != NULL) { - (*mddi_toshiba_vsync_handler) - (mddi_toshiba_vsync_handler_arg); - mddi_toshiba_vsync_handler = NULL; - printk(KERN_INFO "%s: clean up vsyn_handler=%x\n", __func__, - (int)mddi_toshiba_vsync_handler); - } - - mddi_toshiba_lcd_powerdown(platform_get_drvdata(pdev)); - return 0; -} - -static int mddi_toshiba_lcd_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - mddi_toshiba_pdata = pdev->dev.platform_data; - return 0; - } - - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = mddi_toshiba_lcd_probe, - .driver = { - .name = "mddi_toshiba", - }, -}; - -static struct msm_fb_panel_data toshiba_panel_data = { - .on = mddi_toshiba_lcd_on, - .off = mddi_toshiba_lcd_off, -}; - -static int ch_used[3]; - -int mddi_toshiba_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - if ((channel != TOSHIBA_VGA_PRIM) && - mddi_toshiba_pdata && mddi_toshiba_pdata->panel_num) - if (mddi_toshiba_pdata->panel_num() < 2) - return -ENODEV; - - ch_used[channel] = TRUE; - - pdev = platform_device_alloc("mddi_toshiba", (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - if (channel == TOSHIBA_VGA_PRIM) { - toshiba_panel_data.set_backlight = - mddi_toshiba_lcd_set_backlight; - - if (pinfo->lcd.vsync_enable) { - toshiba_panel_data.set_vsync_notifier = - mddi_toshiba_vsync_set_handler; - mddi_lcd.vsync_detected = - mddi_toshiba_lcd_vsync_detected; - } - } else { - toshiba_panel_data.set_backlight = NULL; - toshiba_panel_data.set_vsync_notifier = NULL; - } - - toshiba_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &toshiba_panel_data, - sizeof(toshiba_panel_data)); - if (ret) { - printk(KERN_ERR - "%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - printk(KERN_ERR - "%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int __init mddi_toshiba_lcd_init(void) -{ - return platform_driver_register(&this_driver); -} - -module_init(mddi_toshiba_lcd_init); diff --git a/drivers/video/msm/mddi_toshiba.h b/drivers/video/msm/mddi_toshiba.h deleted file mode 100644 index 854817fb6b5b108d0213f3bbb06cc3a536a206ab..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_toshiba.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2009, 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 MDDI_TOSHIBA_H -#define MDDI_TOSHIBA_H - -#define TOSHIBA_VGA_PRIM 1 -#define TOSHIBA_VGA_SECD 2 - -#define LCD_TOSHIBA_2P4_VGA 0 -#define LCD_TOSHIBA_2P4_WVGA 1 -#define LCD_TOSHIBA_2P4_WVGA_PT 2 -#define LCD_SHARP_2P4_VGA 3 - -#define GPIO_BLOCK_BASE 0x150000 -#define SYSTEM_BLOCK2_BASE 0x170000 - -#define GPIODIR (GPIO_BLOCK_BASE|0x04) -#define GPIOSEL (SYSTEM_BLOCK2_BASE|0x00) -#define GPIOPC (GPIO_BLOCK_BASE|0x28) -#define GPIODATA (GPIO_BLOCK_BASE|0x00) - -#define write_client_reg(__X, __Y, __Z) {\ - mddi_queue_register_write(__X, __Y, TRUE, 0);\ -} - -#endif /* MDDI_TOSHIBA_H */ diff --git a/drivers/video/msm/mddi_toshiba_vga.c b/drivers/video/msm/mddi_toshiba_vga.c deleted file mode 100644 index 3b4a85d8bb96e682722dc15f408ac0929e2d7601..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_toshiba_vga.c +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright (c) 2009-2010, 2012 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 "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" -#include "mddi_toshiba.h" - -static uint32 read_client_reg(uint32 addr) -{ - uint32 val; - mddi_queue_register_read(addr, &val, TRUE, 0); - return val; -} - -static uint32 toshiba_lcd_gpio_read(void) -{ - uint32 val; - - write_client_reg(GPIODIR, 0x0000000C, TRUE); - write_client_reg(GPIOSEL, 0x00000000, TRUE); - write_client_reg(GPIOSEL, 0x00000000, TRUE); - write_client_reg(GPIOPC, 0x03CF00C0, TRUE); - val = read_client_reg(GPIODATA) & 0x2C0; - - return val; -} - -static u32 mddi_toshiba_panel_detect(void) -{ - mddi_host_type host_idx = MDDI_HOST_PRIM; - uint32 lcd_gpio; - u32 mddi_toshiba_lcd = LCD_TOSHIBA_2P4_VGA; - - /* Toshiba display requires larger drive_lo value */ - mddi_host_reg_out(DRIVE_LO, 0x0050); - - lcd_gpio = toshiba_lcd_gpio_read(); - switch (lcd_gpio) { - case 0x0080: - mddi_toshiba_lcd = LCD_SHARP_2P4_VGA; - break; - - case 0x00C0: - default: - mddi_toshiba_lcd = LCD_TOSHIBA_2P4_VGA; - break; - } - - return mddi_toshiba_lcd; -} - -static int __init mddi_toshiba_vga_init(void) -{ - int ret; - struct msm_panel_info pinfo; - u32 panel; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - u32 id; - - ret = msm_fb_detect_client("mddi_toshiba_vga"); - if (ret == -ENODEV) - return 0; - - if (ret) { - id = mddi_get_client_id(); - if ((id >> 16) != 0xD263) - return 0; - } -#endif - - panel = mddi_toshiba_panel_detect(); - - pinfo.xres = 480; - pinfo.yres = 640; - pinfo.type = MDDI_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - pinfo.wait_cycle = 0; - pinfo.bpp = 18; - pinfo.lcd.vsync_enable = TRUE; - pinfo.mddi.is_type1 = TRUE; - pinfo.lcd.refx100 = 6118; - pinfo.lcd.v_back_porch = 6; - pinfo.lcd.v_front_porch = 0; - pinfo.lcd.v_pulse_width = 0; - pinfo.lcd.hw_vsync_mode = FALSE; - pinfo.lcd.vsync_notifier_period = (1 * HZ); - pinfo.bl_max = 99; - pinfo.bl_min = 1; - pinfo.clk_rate = 122880000; - pinfo.clk_min = 120000000; - pinfo.clk_max = 200000000; - pinfo.fb_num = 2; - - ret = mddi_toshiba_device_register(&pinfo, TOSHIBA_VGA_PRIM, panel); - if (ret) { - printk(KERN_ERR "%s: failed to register device!\n", __func__); - return ret; - } - - pinfo.xres = 176; - pinfo.yres = 220; - MSM_FB_SINGLE_MODE_PANEL(&pinfo); - pinfo.type = MDDI_PANEL; - pinfo.pdest = DISPLAY_2; - pinfo.mddi.vdopkt = 0x400; - pinfo.wait_cycle = 0; - pinfo.bpp = 18; - pinfo.clk_rate = 122880000; - pinfo.clk_min = 120000000; - pinfo.clk_max = 200000000; - pinfo.fb_num = 2; - - ret = mddi_toshiba_device_register(&pinfo, TOSHIBA_VGA_SECD, panel); - if (ret) - printk(KERN_WARNING - "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mddi_toshiba_vga_init); diff --git a/drivers/video/msm/mddi_toshiba_wvga.c b/drivers/video/msm/mddi_toshiba_wvga.c deleted file mode 100644 index 7e7b0363cada93e39aa78f164bd7878d3a1752b6..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_toshiba_wvga.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (c) 2009-2010, 2012 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 "msm_fb.h" -#include "mddihost.h" -#include "mddi_toshiba.h" - -static int __init mddi_toshiba_wvga_init(void) -{ - int ret; - struct msm_panel_info pinfo; - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - if (msm_fb_detect_client("mddi_toshiba_wvga")) - return 0; -#endif - - pinfo.xres = 800; - pinfo.yres = 480; - MSM_FB_SINGLE_MODE_PANEL(&pinfo); - pinfo.pdest = DISPLAY_2; - pinfo.type = MDDI_PANEL; - pinfo.mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - pinfo.wait_cycle = 0; - pinfo.bpp = 18; - pinfo.lcd.vsync_enable = TRUE; - pinfo.mddi.is_type1 = TRUE; - pinfo.lcd.refx100 = 6118; - pinfo.lcd.v_back_porch = 6; - pinfo.lcd.v_front_porch = 0; - pinfo.lcd.v_pulse_width = 0; - pinfo.lcd.hw_vsync_mode = FALSE; - pinfo.lcd.vsync_notifier_period = (1 * HZ); - pinfo.bl_max = 4; - pinfo.bl_min = 1; - pinfo.clk_rate = 192000000; - pinfo.clk_min = 190000000; - pinfo.clk_max = 200000000; - pinfo.fb_num = 2; - - ret = mddi_toshiba_device_register(&pinfo, TOSHIBA_VGA_PRIM, - LCD_TOSHIBA_2P4_WVGA); - if (ret) { - printk(KERN_ERR "%s: failed to register device!\n", __func__); - return ret; - } - - return ret; -} - -module_init(mddi_toshiba_wvga_init); diff --git a/drivers/video/msm/mddi_toshiba_wvga_pt.c b/drivers/video/msm/mddi_toshiba_wvga_pt.c deleted file mode 100644 index bdb04ff062d825fa6eb3abf939814f255375be24..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddi_toshiba_wvga_pt.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (c) 2009-2012, 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 "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" -#include "mddi_toshiba.h" - -static struct msm_panel_info pinfo; - -static int __init mddi_toshiba_wvga_pt_init(void) -{ - int ret; -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT - uint id; - - ret = msm_fb_detect_client("mddi_toshiba_wvga_pt"); - if (ret == -ENODEV) - return 0; - - if (ret) { - id = mddi_get_client_id(); - if (id != 0xd2638722) - return 0; - } -#endif - - pinfo.xres = 480; - pinfo.yres = 800; - MSM_FB_SINGLE_MODE_PANEL(&pinfo); - pinfo.type = MDDI_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.mddi.vdopkt = MDDI_DEFAULT_PRIM_PIX_ATTR; - pinfo.wait_cycle = 0; - pinfo.bpp = 18; - pinfo.lcd.vsync_enable = TRUE; - pinfo.lcd.refx100 = 6102; /* adjust refx100 to prevent tearing */ - pinfo.mddi.is_type1 = TRUE; - pinfo.lcd.v_back_porch = 8; /* vsw=10 + vbp = 8 */ - pinfo.lcd.v_front_porch = 2; - pinfo.lcd.v_pulse_width = 10; - pinfo.lcd.hw_vsync_mode = FALSE; - pinfo.lcd.vsync_notifier_period = (1 * HZ); - pinfo.bl_max = 15; - pinfo.bl_min = 1; - pinfo.clk_rate = 222750000; - pinfo.clk_min = 200000000; - pinfo.clk_max = 240000000; - pinfo.fb_num = 2; - - ret = mddi_toshiba_device_register(&pinfo, TOSHIBA_VGA_PRIM, - LCD_TOSHIBA_2P4_WVGA_PT); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mddi_toshiba_wvga_pt_init); diff --git a/drivers/video/msm/mddihost.c b/drivers/video/msm/mddihost.c deleted file mode 100644 index c2a7af3d70cd0a19e0bad4653590b8d1371053bd..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddihost.c +++ /dev/null @@ -1,626 +0,0 @@ -/* Copyright (c) 2008-2009, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" - -#include -#include - -struct semaphore mddi_host_mutex; - -struct clk *mddi_io_clk; -static boolean mddi_host_powered = FALSE; -static boolean mddi_host_initialized = FALSE; -extern uint32 *mddi_reg_read_value_ptr; - -mddi_lcd_func_type mddi_lcd; - -extern mddi_client_capability_type mddi_client_capability_pkt; - -#ifdef MDDI_HOST_WINDOW_WORKAROUND -/* Tables showing number of rows that would cause a packet length - * ending in 0x02, for each number of columns. These tables have - * been generated for MDDI packets that have 16 and 16 bits-per-pixel. - * This is a work-around for MDDI clients that declare a CRC error - * on MDDI packets where ((length & 0x00ff) == 0x02). - */ -static uint16 error_vals_16bpp[] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 10, 0, 0, 0, 14, 0, 0, 0, 2, 0, 0, 4, 6, 12, 0, -0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, -0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 11, 4, 0, 12, 0, -0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, -0, 10, 0, 1, 0, 14, 0, 0, 0, 2, 0, 3, 4, 6, 12, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 12, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 10, 0, 0, 0, 14, 0, 0, 0, 2, 0, 0, 4, 6, 12, 0, -0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, -0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 11, 4, 0, 12, 0, -0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, -}; - -static uint16 error_vals_18bpp[] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 14, -0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 9, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 7, -0, 0, 0, 0, 0, 0, 1, 0, 0, 16, 0, 0, 0, 0, 0, 6, -14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, 4, 0, 16, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -0, 7, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 9, 0 -}; -#endif - -#ifdef FEATURE_MDDI_HITACHI -extern void mddi_hitachi_window_adjust(uint16 x1, - uint16 x2, uint16 y1, uint16 y2); -#endif - -extern void mddi_toshiba_lcd_init(void); - -#ifdef FEATURE_MDDI_S6D0142 -extern void mddi_s6d0142_lcd_init(void); -extern void mddi_s6d0142_window_adjust(uint16 x1, - uint16 x2, - uint16 y1, - uint16 y2, - mddi_llist_done_cb_type done_cb); -#endif - -void mddi_init(void) -{ - if (mddi_host_initialized) - return; - - mddi_host_initialized = TRUE; - - sema_init(&mddi_host_mutex, 1); - - if (!mddi_host_powered) { - down(&mddi_host_mutex); - mddi_host_init(MDDI_HOST_PRIM); - mddi_host_powered = TRUE; - up(&mddi_host_mutex); - mdelay(10); - } -} - -int mddi_host_register_read(uint32 reg_addr, - uint32 *reg_value_ptr, boolean wait, mddi_host_type host) { - mddi_linked_list_type *curr_llist_ptr; - mddi_register_access_packet_type *regacc_pkt_ptr; - uint16 curr_llist_idx; - int ret = 0; - - if (in_interrupt()) - MDDI_MSG_CRIT("Called from ISR context\n"); - - if (!mddi_host_powered) { - MDDI_MSG_ERR("MDDI powered down!\n"); - mddi_init(); - } - - down(&mddi_host_mutex); - - mddi_reg_read_value_ptr = reg_value_ptr; - curr_llist_idx = mddi_get_reg_read_llist_item(host, TRUE); - if (curr_llist_idx == UNASSIGNED_INDEX) { - up(&mddi_host_mutex); - - /* need to change this to some sort of wait */ - MDDI_MSG_ERR("Attempting to queue up more than 1 reg read\n"); - return -EINVAL; - } - - curr_llist_ptr = &llist_extern[host][curr_llist_idx]; - curr_llist_ptr->link_controller_flags = 0x11; - curr_llist_ptr->packet_header_count = 14; - curr_llist_ptr->packet_data_count = 0; - - curr_llist_ptr->next_packet_pointer = NULL; - curr_llist_ptr->packet_data_pointer = NULL; - curr_llist_ptr->reserved = 0; - - regacc_pkt_ptr = &curr_llist_ptr->packet_header.register_pkt; - - regacc_pkt_ptr->packet_length = curr_llist_ptr->packet_header_count; - regacc_pkt_ptr->packet_type = 146; /* register access packet */ - regacc_pkt_ptr->bClient_ID = 0; - regacc_pkt_ptr->read_write_info = 0x8001; - regacc_pkt_ptr->register_address = reg_addr; - - /* now adjust pointers */ - mddi_queue_forward_packets(curr_llist_idx, curr_llist_idx, wait, - NULL, host); - /* need to check if we can write the pointer or not */ - - up(&mddi_host_mutex); - - if (wait) { - int wait_ret; - - mddi_linked_list_notify_type *llist_notify_ptr; - llist_notify_ptr = &llist_extern_notify[host][curr_llist_idx]; - wait_ret = wait_for_completion_timeout( - &(llist_notify_ptr->done_comp), 5 * HZ); - - if (wait_ret <= 0) - ret = -EBUSY; - - if (wait_ret < 0) - printk(KERN_ERR "%s: failed to wait for completion!\n", - __func__); - else if (!wait_ret) - printk(KERN_ERR "%s: Timed out waiting!\n", __func__); - - if (!ret && (mddi_reg_read_value_ptr == reg_value_ptr) && - (*reg_value_ptr == -EBUSY)) { - printk(KERN_ERR "%s - failed to get data from client", - __func__); - mddi_reg_read_value_ptr = NULL; - ret = -EBUSY; - } - } - - MDDI_MSG_DEBUG("Reg Read value=0x%x\n", *reg_value_ptr); - - return ret; -} /* mddi_host_register_read */ - -int mddi_host_register_write(uint32 reg_addr, - uint32 reg_val, enum mddi_data_packet_size_type packet_size, - boolean wait, mddi_llist_done_cb_type done_cb, mddi_host_type host) { - mddi_linked_list_type *curr_llist_ptr; - mddi_linked_list_type *curr_llist_dma_ptr; - mddi_register_access_packet_type *regacc_pkt_ptr; - uint16 curr_llist_idx; - int ret = 0; - - if (in_interrupt()) - MDDI_MSG_CRIT("Called from ISR context\n"); - - if (!mddi_host_powered) { - MDDI_MSG_ERR("MDDI powered down!\n"); - mddi_init(); - } - - down(&mddi_host_mutex); - - curr_llist_idx = mddi_get_next_free_llist_item(host, TRUE); - curr_llist_ptr = &llist_extern[host][curr_llist_idx]; - curr_llist_dma_ptr = &llist_dma_extern[host][curr_llist_idx]; - - curr_llist_ptr->link_controller_flags = 1; - curr_llist_ptr->packet_header_count = 14; - curr_llist_ptr->packet_data_count = 4; - - curr_llist_ptr->next_packet_pointer = NULL; - curr_llist_ptr->reserved = 0; - - regacc_pkt_ptr = &curr_llist_ptr->packet_header.register_pkt; - - regacc_pkt_ptr->packet_length = curr_llist_ptr->packet_header_count + - (uint16)packet_size; - regacc_pkt_ptr->packet_type = 146; /* register access packet */ - regacc_pkt_ptr->bClient_ID = 0; - regacc_pkt_ptr->read_write_info = 0x0001; - regacc_pkt_ptr->register_address = reg_addr; - regacc_pkt_ptr->register_data_list[0] = reg_val; - - MDDI_MSG_DEBUG("Reg Access write reg=0x%x, value=0x%x\n", - regacc_pkt_ptr->register_address, - regacc_pkt_ptr->register_data_list[0]); - - regacc_pkt_ptr = &curr_llist_dma_ptr->packet_header.register_pkt; - curr_llist_ptr->packet_data_pointer = - (void *)(®acc_pkt_ptr->register_data_list[0]); - - /* now adjust pointers */ - mddi_queue_forward_packets(curr_llist_idx, curr_llist_idx, wait, - done_cb, host); - - up(&mddi_host_mutex); - - if (wait) { - int wait_ret; - - mddi_linked_list_notify_type *llist_notify_ptr; - llist_notify_ptr = &llist_extern_notify[host][curr_llist_idx]; - wait_ret = wait_for_completion_timeout( - &(llist_notify_ptr->done_comp), 5 * HZ); - - if (wait_ret <= 0) - ret = -EBUSY; - - if (wait_ret < 0) - printk(KERN_ERR "%s: failed to wait for completion!\n", - __func__); - else if (!wait_ret) - printk(KERN_ERR "%s: Timed out waiting!\n", __func__); - } - - return ret; -} /* mddi_host_register_write */ - -boolean mddi_host_register_read_int - (uint32 reg_addr, uint32 *reg_value_ptr, mddi_host_type host) { - mddi_linked_list_type *curr_llist_ptr; - mddi_register_access_packet_type *regacc_pkt_ptr; - uint16 curr_llist_idx; - - if (!in_interrupt()) - MDDI_MSG_CRIT("Called from TASK context\n"); - - if (!mddi_host_powered) { - MDDI_MSG_ERR("MDDI powered down!\n"); - return FALSE; - } - - if (down_trylock(&mddi_host_mutex) != 0) - return FALSE; - - mddi_reg_read_value_ptr = reg_value_ptr; - curr_llist_idx = mddi_get_reg_read_llist_item(host, FALSE); - if (curr_llist_idx == UNASSIGNED_INDEX) { - up(&mddi_host_mutex); - return FALSE; - } - - curr_llist_ptr = &llist_extern[host][curr_llist_idx]; - curr_llist_ptr->link_controller_flags = 0x11; - curr_llist_ptr->packet_header_count = 14; - curr_llist_ptr->packet_data_count = 0; - - curr_llist_ptr->next_packet_pointer = NULL; - curr_llist_ptr->packet_data_pointer = NULL; - curr_llist_ptr->reserved = 0; - - regacc_pkt_ptr = &curr_llist_ptr->packet_header.register_pkt; - - regacc_pkt_ptr->packet_length = curr_llist_ptr->packet_header_count; - regacc_pkt_ptr->packet_type = 146; /* register access packet */ - regacc_pkt_ptr->bClient_ID = 0; - regacc_pkt_ptr->read_write_info = 0x8001; - regacc_pkt_ptr->register_address = reg_addr; - - /* now adjust pointers */ - mddi_queue_forward_packets(curr_llist_idx, curr_llist_idx, FALSE, - NULL, host); - /* need to check if we can write the pointer or not */ - - up(&mddi_host_mutex); - - return TRUE; - -} /* mddi_host_register_read */ - -boolean mddi_host_register_write_int - (uint32 reg_addr, - uint32 reg_val, mddi_llist_done_cb_type done_cb, mddi_host_type host) { - mddi_linked_list_type *curr_llist_ptr; - mddi_linked_list_type *curr_llist_dma_ptr; - mddi_register_access_packet_type *regacc_pkt_ptr; - uint16 curr_llist_idx; - - if (!in_interrupt()) - MDDI_MSG_CRIT("Called from TASK context\n"); - - if (!mddi_host_powered) { - MDDI_MSG_ERR("MDDI powered down!\n"); - return FALSE; - } - - if (down_trylock(&mddi_host_mutex) != 0) - return FALSE; - - curr_llist_idx = mddi_get_next_free_llist_item(host, FALSE); - if (curr_llist_idx == UNASSIGNED_INDEX) { - up(&mddi_host_mutex); - return FALSE; - } - - curr_llist_ptr = &llist_extern[host][curr_llist_idx]; - curr_llist_dma_ptr = &llist_dma_extern[host][curr_llist_idx]; - - curr_llist_ptr->link_controller_flags = 1; - curr_llist_ptr->packet_header_count = 14; - curr_llist_ptr->packet_data_count = 4; - - curr_llist_ptr->next_packet_pointer = NULL; - curr_llist_ptr->reserved = 0; - - regacc_pkt_ptr = &curr_llist_ptr->packet_header.register_pkt; - - regacc_pkt_ptr->packet_length = curr_llist_ptr->packet_header_count + 4; - regacc_pkt_ptr->packet_type = 146; /* register access packet */ - regacc_pkt_ptr->bClient_ID = 0; - regacc_pkt_ptr->read_write_info = 0x0001; - regacc_pkt_ptr->register_address = reg_addr; - regacc_pkt_ptr->register_data_list[0] = reg_val; - - regacc_pkt_ptr = &curr_llist_dma_ptr->packet_header.register_pkt; - curr_llist_ptr->packet_data_pointer = - (void *)(&(regacc_pkt_ptr->register_data_list[0])); - - /* now adjust pointers */ - mddi_queue_forward_packets(curr_llist_idx, curr_llist_idx, FALSE, - done_cb, host); - up(&mddi_host_mutex); - - return TRUE; - -} /* mddi_host_register_write */ - -void mddi_wait(uint16 time_ms) -{ - mdelay(time_ms); -} - -void mddi_client_lcd_vsync_detected(boolean detected) -{ - if (mddi_lcd.vsync_detected) - (*mddi_lcd.vsync_detected) (detected); -} - -/* extended version of function includes done callback */ -void mddi_window_adjust_ext(struct msm_fb_data_type *mfd, - uint16 x1, - uint16 x2, - uint16 y1, - uint16 y2, mddi_llist_done_cb_type done_cb) -{ -#ifdef FEATURE_MDDI_HITACHI - if (mfd->panel.id == HITACHI) - mddi_hitachi_window_adjust(x1, x2, y1, y2); -#elif defined(FEATURE_MDDI_S6D0142) - if (mfd->panel.id == MDDI_LCD_S6D0142) - mddi_s6d0142_window_adjust(x1, x2, y1, y2, done_cb); -#else - /* Do nothing then... except avoid lint/compiler warnings */ - (void)x1; - (void)x2; - (void)y1; - (void)y2; - (void)done_cb; -#endif -} - -void mddi_window_adjust(struct msm_fb_data_type *mfd, - uint16 x1, uint16 x2, uint16 y1, uint16 y2) -{ - mddi_window_adjust_ext(mfd, x1, x2, y1, y2, NULL); -} - -#ifdef MDDI_HOST_WINDOW_WORKAROUND -uint16 mddi_assign_pkt_height(uint16 pkt_width, - uint16 pkt_height, uint16 bpp) -{ - uint16 new_pkt_height; - uint16 problem_height = 0; - - if (pkt_width <= 240) { - if (bpp == 16) - problem_height = error_vals_16bpp[pkt_width-1]; - else if (bpp == 18) - problem_height = error_vals_18bpp[pkt_width-1]; - else { - printk(KERN_ERR"Invalid bpp value"); - return -EINVAL; - } - } - if (problem_height == pkt_height) - new_pkt_height = problem_height - 1; - else - new_pkt_height = pkt_height; - - return new_pkt_height; -} -#endif - -#ifdef ENABLE_MDDI_MULTI_READ_WRITE -int mddi_host_register_multiwrite(uint32 reg_addr, - uint32 *value_list_ptr, - uint32 value_count, boolean wait, mddi_llist_done_cb_type done_cb, - mddi_host_type host) -{ - mddi_linked_list_type *curr_llist_ptr; - mddi_linked_list_type *curr_llist_dma_ptr; - mddi_register_access_packet_type *regacc_pkt_ptr; - uint16 curr_llist_idx; - int ret = 0; - - if (!value_list_ptr || !value_count || - value_count > MDDI_HOST_MAX_CLIENT_REG_IN_SAME_ADDR) { - MDDI_MSG_ERR("\n Invalid value_list or value_count"); - return -EINVAL; - } - - if (in_interrupt()) - MDDI_MSG_CRIT("Called from ISR context\n"); - - if (!mddi_host_powered) { - MDDI_MSG_ERR("MDDI powered down!\n"); - mddi_init(); - } - - down(&mddi_host_mutex); - - curr_llist_idx = mddi_get_next_free_llist_item(host, TRUE); - curr_llist_ptr = &llist_extern[host][curr_llist_idx]; - curr_llist_dma_ptr = &llist_dma_extern[host][curr_llist_idx]; - - curr_llist_ptr->link_controller_flags = 1; - curr_llist_ptr->packet_header_count = 14; - curr_llist_ptr->packet_data_count = - (uint16)(value_count * 4); - - curr_llist_ptr->next_packet_pointer = NULL; - curr_llist_ptr->reserved = 0; - - regacc_pkt_ptr = &curr_llist_ptr->packet_header.register_pkt; - - regacc_pkt_ptr->packet_length = curr_llist_ptr->packet_header_count - + curr_llist_ptr->packet_data_count; - regacc_pkt_ptr->packet_type = 146; /* register access packet */ - regacc_pkt_ptr->bClient_ID = 0; - regacc_pkt_ptr->read_write_info = value_count; - regacc_pkt_ptr->register_address = reg_addr; - memcpy((void *)®acc_pkt_ptr->register_data_list[0], value_list_ptr, - curr_llist_ptr->packet_data_count); - - regacc_pkt_ptr = &curr_llist_dma_ptr->packet_header.register_pkt; - curr_llist_ptr->packet_data_pointer = - (void *)(®acc_pkt_ptr->register_data_list[0]); - MDDI_MSG_DEBUG("MultiReg Access write reg=0x%x, value[0]=0x%x\n", - regacc_pkt_ptr->register_address, - regacc_pkt_ptr->register_data_list[0]); - - /* now adjust pointers */ - mddi_queue_forward_packets(curr_llist_idx, curr_llist_idx, wait, - done_cb, host); - - up(&mddi_host_mutex); - - if (wait) { - int wait_ret; - - mddi_linked_list_notify_type *llist_notify_ptr; - llist_notify_ptr = &llist_extern_notify[host][curr_llist_idx]; - wait_ret = wait_for_completion_timeout( - &(llist_notify_ptr->done_comp), 5 * HZ); - - if (wait_ret <= 0) - ret = -EBUSY; - - if (wait_ret < 0) - printk(KERN_ERR "%s: failed to wait for completion!\n", - __func__); - else if (!wait_ret) - printk(KERN_ERR "%s: Timed out waiting!\n", __func__); - } - - return ret; -} - -int mddi_host_register_multiread(uint32 reg_addr, - uint32 *value_list_ptr, uint32 value_count, - boolean wait, mddi_host_type host) { - mddi_linked_list_type *curr_llist_ptr; - mddi_register_access_packet_type *regacc_pkt_ptr; - uint16 curr_llist_idx; - int ret = 0; - - if (!value_list_ptr || !value_count || - value_count >= MDDI_HOST_MAX_CLIENT_REG_IN_SAME_ADDR) { - MDDI_MSG_ERR("\n Invalid value_list or value_count"); - return -EINVAL; - } - - if (in_interrupt()) - MDDI_MSG_CRIT("Called from ISR context\n"); - - if (!mddi_host_powered) { - MDDI_MSG_ERR("MDDI powered down!\n"); - mddi_init(); - } - - down(&mddi_host_mutex); - - mddi_reg_read_value_ptr = value_list_ptr; - curr_llist_idx = mddi_get_reg_read_llist_item(host, TRUE); - if (curr_llist_idx == UNASSIGNED_INDEX) { - up(&mddi_host_mutex); - - /* need to change this to some sort of wait */ - MDDI_MSG_ERR("Attempting to queue up more than 1 reg read\n"); - return -EINVAL; - } - - curr_llist_ptr = &llist_extern[host][curr_llist_idx]; - curr_llist_ptr->link_controller_flags = 0x11; - curr_llist_ptr->packet_header_count = 14; - curr_llist_ptr->packet_data_count = 0; - - curr_llist_ptr->next_packet_pointer = NULL; - curr_llist_ptr->packet_data_pointer = NULL; - curr_llist_ptr->reserved = 0; - - regacc_pkt_ptr = &curr_llist_ptr->packet_header.register_pkt; - - regacc_pkt_ptr->packet_length = curr_llist_ptr->packet_header_count; - regacc_pkt_ptr->packet_type = 146; /* register access packet */ - regacc_pkt_ptr->bClient_ID = 0; - regacc_pkt_ptr->read_write_info = 0x8000 | value_count; - regacc_pkt_ptr->register_address = reg_addr; - - /* now adjust pointers */ - mddi_queue_forward_packets(curr_llist_idx, curr_llist_idx, wait, - NULL, host); - /* need to check if we can write the pointer or not */ - - up(&mddi_host_mutex); - - if (wait) { - int wait_ret; - - mddi_linked_list_notify_type *llist_notify_ptr; - llist_notify_ptr = &llist_extern_notify[host][curr_llist_idx]; - wait_ret = wait_for_completion_timeout( - &(llist_notify_ptr->done_comp), 5 * HZ); - - if (wait_ret <= 0) - ret = -EBUSY; - - if (wait_ret < 0) - printk(KERN_ERR "%s: failed to wait for completion!\n", - __func__); - else if (!wait_ret) - printk(KERN_ERR "%s: Timed out waiting!\n", __func__); - - if (!ret && (mddi_reg_read_value_ptr == value_list_ptr) && - (*value_list_ptr == -EBUSY)) { - printk(KERN_ERR "%s - failed to get data from client", - __func__); - mddi_reg_read_value_ptr = NULL; - ret = -EBUSY; - } - } - - MDDI_MSG_DEBUG("MultiReg Read value[0]=0x%x\n", *value_list_ptr); - - return ret; -} -#endif diff --git a/drivers/video/msm/mddihost.h b/drivers/video/msm/mddihost.h deleted file mode 100644 index b055493907f4a50ed9c08447abde81636697abb3..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddihost.h +++ /dev/null @@ -1,229 +0,0 @@ -/* Copyright (c) 2008-2009, 2013, 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 MDDIHOST_H -#define MDDIHOST_H - -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" -#include -#include -#include - -#include -#include - -#include -#include - -#include "msm_fb_panel.h" - -#undef FEATURE_MDDI_MC4 -#undef FEATURE_MDDI_S6D0142 -#undef FEATURE_MDDI_HITACHI -#define FEATURE_MDDI_SHARP -#define FEATURE_MDDI_TOSHIBA -#undef FEATURE_MDDI_E751 -#define FEATURE_MDDI_CORONA -#define FEATURE_MDDI_PRISM - -#define T_MSM7500 - -typedef enum { - format_16bpp, - format_18bpp, - format_24bpp -} mddi_video_format; - -typedef enum { - MDDI_LCD_NONE = 0, - MDDI_LCD_MC4, - MDDI_LCD_S6D0142, - MDDI_LCD_SHARP, - MDDI_LCD_E751, - MDDI_LCD_CORONA, - MDDI_LCD_HITACHI, - MDDI_LCD_TOSHIBA, - MDDI_LCD_PRISM, - MDDI_LCD_TP2, - MDDI_NUM_LCD_TYPES, - MDDI_LCD_DEFAULT = MDDI_LCD_TOSHIBA -} mddi_lcd_type; - -typedef enum { - MDDI_HOST_PRIM = 0, - MDDI_HOST_EXT, - MDDI_NUM_HOST_CORES -} mddi_host_type; - -typedef enum { - MDDI_DRIVER_RESET, /* host core registers have not been written. */ - MDDI_DRIVER_DISABLED, /* registers written, interrupts disabled. */ - MDDI_DRIVER_ENABLED /* registers written, interrupts enabled. */ -} mddi_host_driver_state_type; - -typedef enum { - MDDI_GPIO_INT_0 = 0, - MDDI_GPIO_INT_1, - MDDI_GPIO_INT_2, - MDDI_GPIO_INT_3, - MDDI_GPIO_INT_4, - MDDI_GPIO_INT_5, - MDDI_GPIO_INT_6, - MDDI_GPIO_INT_7, - MDDI_GPIO_INT_8, - MDDI_GPIO_INT_9, - MDDI_GPIO_INT_10, - MDDI_GPIO_INT_11, - MDDI_GPIO_INT_12, - MDDI_GPIO_INT_13, - MDDI_GPIO_INT_14, - MDDI_GPIO_INT_15, - MDDI_GPIO_NUM_INTS -} mddi_gpio_int_type; - -enum mddi_data_packet_size_type { - MDDI_DATA_PACKET_4_BYTES = 4, - MDDI_DATA_PACKET_8_BYTES = 8, - MDDI_DATA_PACKET_12_BYTES = 12, - MDDI_DATA_PACKET_16_BYTES = 16, - MDDI_DATA_PACKET_24_BYTES = 24 -}; - -typedef struct { - uint32 addr; - uint32 value; -} mddi_reg_write_type; - -boolean mddi_vsync_set_handler(msm_fb_vsync_handler_type handler, void *arg); - -typedef void (*mddi_llist_done_cb_type) (void); - -typedef void (*mddi_rev_handler_type) (void *); - -boolean mddi_set_rev_handler(mddi_rev_handler_type handler, uint16 pkt_type); - -#define MDDI_DEFAULT_PRIM_PIX_ATTR 0xC3 -#define MDDI_DEFAULT_SECD_PIX_ATTR 0xC0 - -typedef int gpio_int_polarity_type; -typedef int gpio_int_handler_type; - -typedef struct { - void (*vsync_detected) (boolean); -} mddi_lcd_func_type; - -extern mddi_lcd_func_type mddi_lcd; -extern int irq_enabled; -extern unsigned char mddi_timer_shutdown_flag; -extern struct mutex mddi_timer_lock; - -void mddi_init(void); -void mddi_powerdown(void); - -void mddi_host_start_ext_display(void); -void mddi_host_stop_ext_display(void); - -extern spinlock_t mddi_host_spin_lock; -#ifdef T_MSM7500 -void mddi_reset(void); -#ifdef FEATURE_DUAL_PROC_MODEM_DISPLAY -void mddi_host_switch_proc_control(boolean on); -#endif -#endif -void mddi_host_exit_power_collapse(void); - -void mddi_queue_splash_screen - (void *buf_ptr, - boolean clear_area, - int16 src_width, - int16 src_starting_row, - int16 src_starting_column, - int16 num_of_rows, - int16 num_of_columns, int16 dst_starting_row, int16 dst_starting_column); - -void mddi_queue_image - (void *buf_ptr, - uint8 stereo_video, - boolean clear_area, - int16 src_width, - int16 src_starting_row, - int16 src_starting_column, - int16 num_of_rows, - int16 num_of_columns, int16 dst_starting_row, int16 dst_starting_column); - -int mddi_host_register_read - (uint32 reg_addr, - uint32 *reg_value_ptr, boolean wait, mddi_host_type host_idx); -int mddi_host_register_write - (uint32 reg_addr, uint32 reg_val, - enum mddi_data_packet_size_type packet_size, - boolean wait, mddi_llist_done_cb_type done_cb, mddi_host_type host); -boolean mddi_host_register_write_int - (uint32 reg_addr, - uint32 reg_val, mddi_llist_done_cb_type done_cb, mddi_host_type host); -boolean mddi_host_register_read_int - (uint32 reg_addr, uint32 *reg_value_ptr, mddi_host_type host_idx); -void mddi_queue_register_write_static - (uint32 reg_addr, - uint32 reg_val, boolean wait, mddi_llist_done_cb_type done_cb); -void mddi_queue_static_window_adjust - (const mddi_reg_write_type *reg_write, - uint16 num_writes, mddi_llist_done_cb_type done_cb); - -#ifdef ENABLE_MDDI_MULTI_READ_WRITE -int mddi_host_register_multiwrite(uint32 reg_addr, - uint32 *value_list_ptr, uint32 value_count, - boolean wait, mddi_llist_done_cb_type done_cb, - mddi_host_type host); -int mddi_host_register_multiread(uint32 reg_addr, - uint32 *value_list_ptr, uint32 value_count, - boolean wait, mddi_host_type host); -#endif - -#define mddi_queue_register_read(reg, val_ptr, wait, sig) \ - mddi_host_register_read(reg, val_ptr, wait, MDDI_HOST_PRIM) -#define mddi_queue_register_write(reg, val, wait, sig) \ - mddi_host_register_write(reg, val, MDDI_DATA_PACKET_4_BYTES,\ - wait, NULL, MDDI_HOST_PRIM) -#define mddi_queue_register_write_extn(reg, val, pkt_size, wait, sig) \ - mddi_host_register_write(reg, val, pkt_size, \ - wait, NULL, MDDI_HOST_PRIM) -#define mddi_queue_register_write_int(reg, val) \ - mddi_host_register_write_int(reg, val, NULL, MDDI_HOST_PRIM) -#define mddi_queue_register_read_int(reg, val_ptr) \ - mddi_host_register_read_int(reg, val_ptr, MDDI_HOST_PRIM) -#define mddi_queue_register_writes(reg_ptr, val, wait, sig) \ - mddi_host_register_writes(reg_ptr, val, wait, sig, MDDI_HOST_PRIM) - -void mddi_wait(uint16 time_ms); -void mddi_assign_max_pkt_dimensions(uint16 image_cols, - uint16 image_rows, - uint16 bpp, - uint16 *max_cols, uint16 * max_rows); -#ifdef MDDI_HOST_WINDOW_WORKAROUND -uint16 mddi_assign_pkt_height(uint16 pkt_width, uint16 pkt_height, uint16 bpp); -#endif -void mddi_queue_reverse_encapsulation(boolean wait); -int mddi_client_power(unsigned int client_id); -void mddi_disable(int lock); -void mddi_window_adjust(struct msm_fb_data_type *mfd, - uint16 x1, uint16 x2, uint16 y1, uint16 y2); -void mddi_send_fw_link_skew_cal(mddi_host_type host_idx); -int pmdh_clk_func(int enable); - -#endif /* MDDIHOST_H */ diff --git a/drivers/video/msm/mddihost_e.c b/drivers/video/msm/mddihost_e.c deleted file mode 100644 index 275e4ee1c5d8715fa7ecb670f2f44c7dd51be2fb..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddihost_e.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) 2008-2009, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "mddihost.h" -#include "mddihosti.h" - -#include -#include - -extern struct semaphore mddi_host_mutex; -static boolean mddi_host_ext_powered = FALSE; - -void mddi_host_start_ext_display(void) -{ - down(&mddi_host_mutex); - - if (!mddi_host_ext_powered) { - mddi_host_init(MDDI_HOST_EXT); - - mddi_host_ext_powered = TRUE; - } - - up(&mddi_host_mutex); -} - -void mddi_host_stop_ext_display(void) -{ - down(&mddi_host_mutex); - - if (mddi_host_ext_powered) { - mddi_host_powerdown(MDDI_HOST_EXT); - - mddi_host_ext_powered = FALSE; - } - - up(&mddi_host_mutex); -} diff --git a/drivers/video/msm/mddihosti.c b/drivers/video/msm/mddihosti.c deleted file mode 100644 index b4429f6bcf87a00f8c26541fa1fa314cdbd26f85..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddihosti.c +++ /dev/null @@ -1,2268 +0,0 @@ -/* Copyright (c) 2008-2010, 2012 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb_panel.h" -#include "mddihost.h" -#include "mddihosti.h" - -#define FEATURE_MDDI_UNDERRUN_RECOVERY -#ifndef FEATURE_MDDI_DISABLE_REVERSE -static void mddi_read_rev_packet(byte *data_ptr); -#endif - -struct timer_list mddi_host_timer; - -#define MDDI_DEFAULT_TIMER_LENGTH 5000 /* 5 seconds */ -uint32 mddi_rtd_frequency = 60000; /* send RTD every 60 seconds */ -uint32 mddi_client_status_frequency = 60000; /* get status pkt every 60 secs */ - -boolean mddi_vsync_detect_enabled = FALSE; -mddi_gpio_info_type mddi_gpio; - -uint32 mddi_host_core_version; -boolean mddi_debug_log_statistics = FALSE; -/* #define FEATURE_MDDI_HOST_ENABLE_EARLY_HIBERNATION */ -/* default to TRUE in case MDP does not vote */ -static boolean mddi_host_mdp_active_flag = TRUE; -static uint32 mddi_log_stats_counter; -uint32 mddi_log_stats_frequency = 4000; -int32 mddi_client_type; - -#define MDDI_DEFAULT_REV_PKT_SIZE 0x20 - -#ifndef FEATURE_MDDI_DISABLE_REVERSE -static boolean mddi_rev_ptr_workaround = TRUE; -static uint32 mddi_reg_read_retry; -static uint32 mddi_reg_read_retry_max = 20; -static boolean mddi_enable_reg_read_retry = TRUE; -static boolean mddi_enable_reg_read_retry_once = FALSE; - -#define MDDI_MAX_REV_PKT_SIZE 0x60 - -#define MDDI_CLIENT_CAPABILITY_REV_PKT_SIZE 0x60 - -#define MDDI_VIDEO_REV_PKT_SIZE 0x40 -#define MDDI_REV_BUFFER_SIZE MDDI_MAX_REV_PKT_SIZE -static byte rev_packet_data[MDDI_MAX_REV_PKT_SIZE]; -#endif /* FEATURE_MDDI_DISABLE_REVERSE */ -/* leave these variables so graphics will compile */ - -#define MDDI_MAX_REV_DATA_SIZE 128 -/*lint -d__align(x) */ -boolean mddi_debug_clear_rev_data = TRUE; - -uint32 *mddi_reg_read_value_ptr; - -mddi_client_capability_type mddi_client_capability_pkt; -static boolean mddi_client_capability_request = FALSE; - -#ifndef FEATURE_MDDI_DISABLE_REVERSE - -#define MAX_MDDI_REV_HANDLERS 2 -#define INVALID_PKT_TYPE 0xFFFF - -typedef struct { - mddi_rev_handler_type handler; /* ISR to be executed */ - uint16 pkt_type; -} mddi_rev_pkt_handler_type; -static mddi_rev_pkt_handler_type mddi_rev_pkt_handler[MAX_MDDI_REV_HANDLERS] = - { {NULL, INVALID_PKT_TYPE}, {NULL, INVALID_PKT_TYPE} }; - -static boolean mddi_rev_encap_user_request = FALSE; -static mddi_linked_list_notify_type mddi_rev_user; - -spinlock_t mddi_host_spin_lock; -extern uint32 mdp_in_processing; -#endif - -typedef enum { - MDDI_REV_IDLE -#ifndef FEATURE_MDDI_DISABLE_REVERSE - , MDDI_REV_REG_READ_ISSUED, - MDDI_REV_REG_READ_SENT, - MDDI_REV_ENCAP_ISSUED, - MDDI_REV_STATUS_REQ_ISSUED, - MDDI_REV_CLIENT_CAP_ISSUED -#endif -} mddi_rev_link_state_type; - -typedef enum { - MDDI_LINK_DISABLED, - MDDI_LINK_HIBERNATING, - MDDI_LINK_ACTIVATING, - MDDI_LINK_ACTIVE -} mddi_host_link_state_type; - -typedef struct { - uint32 count; - uint32 in_count; - uint32 disp_req_count; - uint32 state_change_count; - uint32 ll_done_count; - uint32 rev_avail_count; - uint32 error_count; - uint32 rev_encap_count; - uint32 llist_ptr_write_1; - uint32 llist_ptr_write_2; -} mddi_host_int_type; - -typedef struct { - uint32 fwd_crc_count; - uint32 rev_crc_count; - uint32 pri_underflow; - uint32 sec_underflow; - uint32 rev_overflow; - uint32 pri_overwrite; - uint32 sec_overwrite; - uint32 rev_overwrite; - uint32 dma_failure; - uint32 rtd_failure; - uint32 reg_read_failure; -#ifdef FEATURE_MDDI_UNDERRUN_RECOVERY - uint32 pri_underrun_detected; -#endif -} mddi_host_stat_type; - -typedef struct { - uint32 rtd_cnt; - uint32 rev_enc_cnt; - uint32 vid_cnt; - uint32 reg_acc_cnt; - uint32 cli_stat_cnt; - uint32 cli_cap_cnt; - uint32 reg_read_cnt; - uint32 link_active_cnt; - uint32 link_hibernate_cnt; - uint32 vsync_response_cnt; - uint32 fwd_crc_cnt; - uint32 rev_crc_cnt; -} mddi_log_params_struct_type; - -typedef struct { - uint32 rtd_value; - uint32 rtd_counter; - uint32 client_status_cnt; - boolean rev_ptr_written; - uint8 *rev_ptr_start; - uint8 *rev_ptr_curr; - uint32 mddi_rev_ptr_write_val; - dma_addr_t rev_data_dma_addr; - uint16 rev_pkt_size; - mddi_rev_link_state_type rev_state; - mddi_host_link_state_type link_state; - mddi_host_driver_state_type driver_state; - boolean disable_hibernation; - uint32 saved_int_reg; - uint32 saved_int_en; - mddi_linked_list_type *llist_ptr; - dma_addr_t llist_dma_addr; - mddi_linked_list_type *llist_dma_ptr; - uint32 *rev_data_buf; - struct completion mddi_llist_avail_comp; - boolean mddi_waiting_for_llist_avail; - mddi_host_int_type int_type; - mddi_host_stat_type stats; - mddi_log_params_struct_type log_parms; - mddi_llist_info_type llist_info; - mddi_linked_list_notify_type llist_notify[MDDI_MAX_NUM_LLIST_ITEMS]; -} mddi_host_cntl_type; - -static mddi_host_type mddi_curr_host = MDDI_HOST_PRIM; -static mddi_host_cntl_type mhctl[MDDI_NUM_HOST_CORES]; -mddi_linked_list_type *llist_extern[MDDI_NUM_HOST_CORES]; -mddi_linked_list_type *llist_dma_extern[MDDI_NUM_HOST_CORES]; -mddi_linked_list_notify_type *llist_extern_notify[MDDI_NUM_HOST_CORES]; -static mddi_log_params_struct_type prev_parms[MDDI_NUM_HOST_CORES]; - -extern uint32 mdp_total_vdopkts; - -static boolean mddi_host_io_clock_on = FALSE; -static boolean mddi_host_hclk_on = FALSE; - -int int_mddi_pri_flag = FALSE; -int int_mddi_ext_flag = FALSE; - -static void mddi_report_errors(uint32 int_reg) -{ - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - if (int_reg & MDDI_INT_PRI_UNDERFLOW) { - pmhctl->stats.pri_underflow++; - MDDI_MSG_ERR("!!! MDDI Primary Underflow !!!\n"); - } - if (int_reg & MDDI_INT_SEC_UNDERFLOW) { - pmhctl->stats.sec_underflow++; - MDDI_MSG_ERR("!!! MDDI Secondary Underflow !!!\n"); - } -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (int_reg & MDDI_INT_REV_OVERFLOW) { - pmhctl->stats.rev_overflow++; - MDDI_MSG_ERR("!!! MDDI Reverse Overflow !!!\n"); - pmhctl->rev_ptr_curr = pmhctl->rev_ptr_start; - mddi_host_reg_out(REV_PTR, pmhctl->mddi_rev_ptr_write_val); - - } - if (int_reg & MDDI_INT_CRC_ERROR) - MDDI_MSG_ERR("!!! MDDI Reverse CRC Error !!!\n"); -#endif - if (int_reg & MDDI_INT_PRI_OVERWRITE) { - pmhctl->stats.pri_overwrite++; - MDDI_MSG_ERR("!!! MDDI Primary Overwrite !!!\n"); - } - if (int_reg & MDDI_INT_SEC_OVERWRITE) { - pmhctl->stats.sec_overwrite++; - MDDI_MSG_ERR("!!! MDDI Secondary Overwrite !!!\n"); - } -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (int_reg & MDDI_INT_REV_OVERWRITE) { - pmhctl->stats.rev_overwrite++; - /* This will show up normally and is not a problem */ - MDDI_MSG_DEBUG("MDDI Reverse Overwrite!\n"); - } - if (int_reg & MDDI_INT_RTD_FAILURE) { - mddi_host_reg_outm(INTEN, MDDI_INT_RTD_FAILURE, 0); - pmhctl->stats.rtd_failure++; - MDDI_MSG_ERR("!!! MDDI RTD Failure !!!\n"); - } -#endif - if (int_reg & MDDI_INT_DMA_FAILURE) { - pmhctl->stats.dma_failure++; - MDDI_MSG_ERR("!!! MDDI DMA Abort !!!\n"); - } -} - -static void mddi_host_enable_io_clock(void) -{ - if (!MDDI_HOST_IS_IO_CLOCK_ON) - MDDI_HOST_ENABLE_IO_CLOCK; -} - -static void mddi_host_enable_hclk(void) -{ - - if (!MDDI_HOST_IS_HCLK_ON) - MDDI_HOST_ENABLE_HCLK; -} - -static void mddi_host_disable_io_clock(void) -{ -#ifndef FEATURE_MDDI_HOST_IO_CLOCK_CONTROL_DISABLE - if (MDDI_HOST_IS_IO_CLOCK_ON) - MDDI_HOST_DISABLE_IO_CLOCK; -#endif -} - -static void mddi_host_disable_hclk(void) -{ -#ifndef FEATURE_MDDI_HOST_HCLK_CONTROL_DISABLE - if (MDDI_HOST_IS_HCLK_ON) - MDDI_HOST_DISABLE_HCLK; -#endif -} - -static void mddi_vote_to_sleep(mddi_host_type host_idx, boolean sleep) -{ - uint16 vote_mask; - - if (host_idx == MDDI_HOST_PRIM) - vote_mask = 0x01; - else - vote_mask = 0x02; -} - -static void mddi_report_state_change(uint32 int_reg) -{ - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - if ((pmhctl->saved_int_reg & MDDI_INT_IN_HIBERNATION) && - (pmhctl->saved_int_reg & MDDI_INT_LINK_ACTIVE)) { - /* recover from condition where the io_clock was turned off by the - clock driver during a transition to hibernation. The io_clock - disable is to prevent MDP/MDDI underruns when changing ARM - clock speeds. In the process of halting the ARM, the hclk - divider needs to be set to 1. When it is set to 1, there is - a small time (usecs) when hclk is off or slow, and this can - cause an underrun. To prevent the underrun, clock driver turns - off the MDDI io_clock before making the change. */ - mddi_host_reg_out(CMD, MDDI_CMD_POWERUP); - } - - if (int_reg & MDDI_INT_LINK_ACTIVE) { - pmhctl->link_state = MDDI_LINK_ACTIVE; - pmhctl->log_parms.link_active_cnt++; - pmhctl->rtd_value = mddi_host_reg_in(RTD_VAL); - MDDI_MSG_DEBUG("!!! MDDI Active RTD:0x%x!!!\n", - pmhctl->rtd_value); - /* now interrupt on hibernation */ - mddi_host_reg_outm(INTEN, - (MDDI_INT_IN_HIBERNATION | - MDDI_INT_LINK_ACTIVE), - MDDI_INT_IN_HIBERNATION); - -#ifdef DEBUG_MDDIHOSTI - /* if gpio interrupt is enabled, start polling at fastest - * registered rate - */ - if (mddi_gpio.polling_enabled) { - timer_reg(&mddi_gpio_poll_timer, - mddi_gpio_poll_timer_cb, 0, mddi_gpio.polling_interval, 0); - } -#endif -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (mddi_rev_ptr_workaround) { - /* HW CR: need to reset reverse register stuff */ - pmhctl->rev_ptr_written = FALSE; - pmhctl->rev_ptr_curr = pmhctl->rev_ptr_start; - } -#endif - /* vote on sleep */ - mddi_vote_to_sleep(host_idx, FALSE); - - if (host_idx == MDDI_HOST_PRIM) { - if (mddi_vsync_detect_enabled) { - /* - * Indicate to client specific code that vsync - * was enabled, but we did not detect a client - * intiated wakeup. The client specific - * handler can either reassert vsync detection, - * or treat this as a valid vsync. - */ - mddi_client_lcd_vsync_detected(FALSE); - pmhctl->log_parms.vsync_response_cnt++; - } - } - } - if (int_reg & MDDI_INT_IN_HIBERNATION) { - pmhctl->link_state = MDDI_LINK_HIBERNATING; - pmhctl->log_parms.link_hibernate_cnt++; - MDDI_MSG_DEBUG("!!! MDDI Hibernating !!!\n"); - - if (mddi_client_type == 2) { - mddi_host_reg_out(PAD_CTL, 0x402a850f); - mddi_host_reg_out(PAD_CAL, 0x10220020); - mddi_host_reg_out(TA1_LEN, 0x0010); - mddi_host_reg_out(TA2_LEN, 0x0040); - } - /* now interrupt on link_active */ -#ifdef FEATURE_MDDI_DISABLE_REVERSE - mddi_host_reg_outm(INTEN, - (MDDI_INT_MDDI_IN | - MDDI_INT_IN_HIBERNATION | - MDDI_INT_LINK_ACTIVE), - MDDI_INT_LINK_ACTIVE); -#else - mddi_host_reg_outm(INTEN, - (MDDI_INT_MDDI_IN | - MDDI_INT_IN_HIBERNATION | - MDDI_INT_LINK_ACTIVE), - (MDDI_INT_MDDI_IN | MDDI_INT_LINK_ACTIVE)); - - pmhctl->rtd_counter = mddi_rtd_frequency; - - if (pmhctl->rev_state != MDDI_REV_IDLE) { - /* a rev_encap will not wake up the link, so we do that here */ - pmhctl->link_state = MDDI_LINK_ACTIVATING; - mddi_host_reg_out(CMD, MDDI_CMD_LINK_ACTIVE); - } -#endif - - if (pmhctl->disable_hibernation) { - mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE); - mddi_host_reg_out(CMD, MDDI_CMD_LINK_ACTIVE); - pmhctl->link_state = MDDI_LINK_ACTIVATING; - } -#ifdef FEATURE_MDDI_UNDERRUN_RECOVERY - if ((pmhctl->llist_info.transmitting_start_idx != - UNASSIGNED_INDEX) - && - ((pmhctl-> - saved_int_reg & (MDDI_INT_PRI_LINK_LIST_DONE | - MDDI_INT_PRI_PTR_READ)) == - MDDI_INT_PRI_PTR_READ)) { - mddi_linked_list_type *llist_dma; - llist_dma = pmhctl->llist_dma_ptr; - /* - * All indications are that we have not received a - * linked list done interrupt, due to an underrun - * condition. Recovery attempt is to send again. - */ - dma_coherent_pre_ops(); - /* Write to primary pointer register again */ - mddi_host_reg_out(PRI_PTR, - &llist_dma[pmhctl->llist_info. - transmitting_start_idx]); - pmhctl->stats.pri_underrun_detected++; - } -#endif - - /* vote on sleep */ - if (pmhctl->link_state == MDDI_LINK_HIBERNATING) { - mddi_vote_to_sleep(host_idx, TRUE); - } - -#ifdef DEBUG_MDDIHOSTI - /* need to stop polling timer */ - if (mddi_gpio.polling_enabled) { - (void) timer_clr(&mddi_gpio_poll_timer, T_NONE); - } -#endif - } -} - -void mddi_host_timer_service(unsigned long data) -{ -#ifndef FEATURE_MDDI_DISABLE_REVERSE - unsigned long flags; -#endif - mddi_host_type host_idx; - mddi_host_cntl_type *pmhctl; - - unsigned long time_ms = MDDI_DEFAULT_TIMER_LENGTH; - init_timer(&mddi_host_timer); - for (host_idx = MDDI_HOST_PRIM; host_idx < MDDI_NUM_HOST_CORES; - host_idx++) { - pmhctl = &(mhctl[host_idx]); - mddi_log_stats_counter += (uint32) time_ms; -#ifndef FEATURE_MDDI_DISABLE_REVERSE - pmhctl->rtd_counter += (uint32) time_ms; - pmhctl->client_status_cnt += (uint32) time_ms; - - if (host_idx == MDDI_HOST_PRIM) { - if (pmhctl->client_status_cnt >= - mddi_client_status_frequency) { - if ((pmhctl->link_state == - MDDI_LINK_HIBERNATING) - && (pmhctl->client_status_cnt > - mddi_client_status_frequency)) { - /* - * special case where we are hibernating - * and mddi_host_isr is not firing, so - * kick the link so that the status can - * be retrieved - */ - - /* need to wake up link before issuing - * rev encap command - */ - MDDI_MSG_INFO("wake up link!\n"); - spin_lock_irqsave(&mddi_host_spin_lock, - flags); - mddi_host_enable_hclk(); - mddi_host_enable_io_clock(); - pmhctl->link_state = - MDDI_LINK_ACTIVATING; - mddi_host_reg_out(CMD, - MDDI_CMD_LINK_ACTIVE); - spin_unlock_irqrestore - (&mddi_host_spin_lock, flags); - } else - if ((pmhctl->link_state == MDDI_LINK_ACTIVE) - && pmhctl->disable_hibernation) { - /* - * special case where we have disabled - * hibernation and mddi_host_isr - * is not firing, so enable interrupt - * for no pkts pending, which will - * generate an interrupt - */ - MDDI_MSG_INFO("kick isr!\n"); - spin_lock_irqsave(&mddi_host_spin_lock, - flags); - mddi_host_enable_hclk(); - mddi_host_reg_outm(INTEN, - MDDI_INT_NO_CMD_PKTS_PEND, - MDDI_INT_NO_CMD_PKTS_PEND); - spin_unlock_irqrestore - (&mddi_host_spin_lock, flags); - } - } - } -#endif /* #ifndef FEATURE_MDDI_DISABLE_REVERSE */ - } - - /* Check if logging is turned on */ - for (host_idx = MDDI_HOST_PRIM; host_idx < MDDI_NUM_HOST_CORES; - host_idx++) { - mddi_log_params_struct_type *prev_ptr = &(prev_parms[host_idx]); - pmhctl = &(mhctl[host_idx]); - - if (mddi_debug_log_statistics) { - - /* get video pkt count from MDP, since MDDI sw cannot know this */ - pmhctl->log_parms.vid_cnt = mdp_total_vdopkts; - - if (mddi_log_stats_counter >= mddi_log_stats_frequency) { - /* mddi_log_stats_counter = 0; */ - if (mddi_debug_log_statistics) { - MDDI_MSG_NOTICE - ("MDDI Statistics since last report:\n"); - MDDI_MSG_NOTICE(" Packets sent:\n"); - MDDI_MSG_NOTICE - (" %d RTD packet(s)\n", - pmhctl->log_parms.rtd_cnt - - prev_ptr->rtd_cnt); - if (prev_ptr->rtd_cnt != - pmhctl->log_parms.rtd_cnt) { - unsigned long flags; - spin_lock_irqsave - (&mddi_host_spin_lock, - flags); - mddi_host_enable_hclk(); - pmhctl->rtd_value = - mddi_host_reg_in(RTD_VAL); - spin_unlock_irqrestore - (&mddi_host_spin_lock, - flags); - MDDI_MSG_NOTICE - (" RTD value=%d\n", - pmhctl->rtd_value); - } - MDDI_MSG_NOTICE - (" %d VIDEO packets\n", - pmhctl->log_parms.vid_cnt - - prev_ptr->vid_cnt); - MDDI_MSG_NOTICE - (" %d Register Access packets\n", - pmhctl->log_parms.reg_acc_cnt - - prev_ptr->reg_acc_cnt); - MDDI_MSG_NOTICE - (" %d Reverse Encapsulation packet(s)\n", - pmhctl->log_parms.rev_enc_cnt - - prev_ptr->rev_enc_cnt); - if (prev_ptr->rev_enc_cnt != - pmhctl->log_parms.rev_enc_cnt) { - /* report # of reverse CRC errors */ - MDDI_MSG_NOTICE - (" %d reverse CRC errors detected\n", - pmhctl->log_parms. - rev_crc_cnt - - prev_ptr->rev_crc_cnt); - } - MDDI_MSG_NOTICE - (" Packets received:\n"); - MDDI_MSG_NOTICE - (" %d Client Status packets", - pmhctl->log_parms.cli_stat_cnt - - prev_ptr->cli_stat_cnt); - if (prev_ptr->cli_stat_cnt != - pmhctl->log_parms.cli_stat_cnt) { - MDDI_MSG_NOTICE - (" %d forward CRC errors reported\n", - pmhctl->log_parms. - fwd_crc_cnt - - prev_ptr->fwd_crc_cnt); - } - MDDI_MSG_NOTICE - (" %d Register Access Read packets\n", - pmhctl->log_parms.reg_read_cnt - - prev_ptr->reg_read_cnt); - - if (pmhctl->link_state == - MDDI_LINK_ACTIVE) { - MDDI_MSG_NOTICE - (" Current Link Status: Active\n"); - } else - if ((pmhctl->link_state == - MDDI_LINK_HIBERNATING) - || (pmhctl->link_state == - MDDI_LINK_ACTIVATING)) { - MDDI_MSG_NOTICE - (" Current Link Status: Hibernation\n"); - } else { - MDDI_MSG_NOTICE - (" Current Link Status: Inactive\n"); - } - MDDI_MSG_NOTICE - (" Active state entered %d times\n", - pmhctl->log_parms.link_active_cnt - - prev_ptr->link_active_cnt); - MDDI_MSG_NOTICE - (" Hibernation state entered %d times\n", - pmhctl->log_parms. - link_hibernate_cnt - - prev_ptr->link_hibernate_cnt); - } - } - prev_parms[host_idx] = pmhctl->log_parms; - } - } - if (mddi_log_stats_counter >= mddi_log_stats_frequency) - mddi_log_stats_counter = 0; - - mutex_lock(&mddi_timer_lock); - if (!mddi_timer_shutdown_flag) { - mddi_host_timer.function = mddi_host_timer_service; - mddi_host_timer.data = 0; - mddi_host_timer.expires = jiffies + ((time_ms * HZ) / 1000); - add_timer(&mddi_host_timer); - } - mutex_unlock(&mddi_timer_lock); - - return; -} /* mddi_host_timer_cb */ - -static void mddi_process_link_list_done(void) -{ - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - /* normal forward linked list packet(s) were sent */ - if (pmhctl->llist_info.transmitting_start_idx == UNASSIGNED_INDEX) { - MDDI_MSG_ERR("**** getting LL done, but no list ****\n"); - } else { - uint16 idx; - -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (pmhctl->rev_state == MDDI_REV_REG_READ_ISSUED) { - /* special case where a register read packet was sent */ - pmhctl->rev_state = MDDI_REV_REG_READ_SENT; - if (pmhctl->llist_info.reg_read_idx == UNASSIGNED_INDEX) { - MDDI_MSG_ERR - ("**** getting LL done, but no list ****\n"); - } - } -#endif - for (idx = pmhctl->llist_info.transmitting_start_idx;;) { - uint16 next_idx = pmhctl->llist_notify[idx].next_idx; - /* with reg read we don't release the waiting tcb until after - * the reverse encapsulation has completed. - */ - if (idx != pmhctl->llist_info.reg_read_idx) { - /* notify task that may be waiting on this completion */ - if (pmhctl->llist_notify[idx].waiting) { - complete(& - (pmhctl->llist_notify[idx]. - done_comp)); - } - if (pmhctl->llist_notify[idx].done_cb != NULL) { - (*(pmhctl->llist_notify[idx].done_cb)) - (); - } - - pmhctl->llist_notify[idx].in_use = FALSE; - pmhctl->llist_notify[idx].waiting = FALSE; - pmhctl->llist_notify[idx].done_cb = NULL; - if (idx < MDDI_NUM_DYNAMIC_LLIST_ITEMS) { - /* static LLIST items are configured only once */ - pmhctl->llist_notify[idx].next_idx = - UNASSIGNED_INDEX; - } - /* - * currently, all linked list packets are - * register access, so we can increment the - * counter for that packet type here. - */ - pmhctl->log_parms.reg_acc_cnt++; - } - if (idx == pmhctl->llist_info.transmitting_end_idx) - break; - idx = next_idx; - if (idx == UNASSIGNED_INDEX) - MDDI_MSG_CRIT("MDDI linked list corruption!\n"); - } - - pmhctl->llist_info.transmitting_start_idx = UNASSIGNED_INDEX; - pmhctl->llist_info.transmitting_end_idx = UNASSIGNED_INDEX; - - if (pmhctl->mddi_waiting_for_llist_avail) { - if (! - (pmhctl-> - llist_notify[pmhctl->llist_info.next_free_idx]. - in_use)) { - pmhctl->mddi_waiting_for_llist_avail = FALSE; - complete(&(pmhctl->mddi_llist_avail_comp)); - } - } - } - - /* Turn off MDDI_INT_PRI_LINK_LIST_DONE interrupt */ - mddi_host_reg_outm(INTEN, MDDI_INT_PRI_LINK_LIST_DONE, 0); - -} - -static void mddi_queue_forward_linked_list(void) -{ - uint16 first_pkt_index; - mddi_linked_list_type *llist_dma; - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - llist_dma = pmhctl->llist_dma_ptr; - - first_pkt_index = UNASSIGNED_INDEX; - - if (pmhctl->llist_info.transmitting_start_idx == UNASSIGNED_INDEX) { -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (pmhctl->llist_info.reg_read_waiting) { - if (pmhctl->rev_state == MDDI_REV_IDLE) { - /* - * we have a register read to send and - * can send it now - */ - pmhctl->rev_state = MDDI_REV_REG_READ_ISSUED; - mddi_reg_read_retry = 0; - first_pkt_index = - pmhctl->llist_info.waiting_start_idx; - pmhctl->llist_info.reg_read_waiting = FALSE; - } - } else -#endif - { - /* - * not register read to worry about, go ahead and write - * anything that may be on the waiting list. - */ - first_pkt_index = pmhctl->llist_info.waiting_start_idx; - } - } - - if (first_pkt_index != UNASSIGNED_INDEX) { - pmhctl->llist_info.transmitting_start_idx = - pmhctl->llist_info.waiting_start_idx; - pmhctl->llist_info.transmitting_end_idx = - pmhctl->llist_info.waiting_end_idx; - pmhctl->llist_info.waiting_start_idx = UNASSIGNED_INDEX; - pmhctl->llist_info.waiting_end_idx = UNASSIGNED_INDEX; - - /* write to the primary pointer register */ - MDDI_MSG_DEBUG("MDDI writing primary ptr with idx=%d\n", - first_pkt_index); - - pmhctl->int_type.llist_ptr_write_2++; - - dma_coherent_pre_ops(); - mddi_host_reg_out(PRI_PTR, &llist_dma[first_pkt_index]); - - /* enable interrupt when complete */ - mddi_host_reg_outm(INTEN, MDDI_INT_PRI_LINK_LIST_DONE, - MDDI_INT_PRI_LINK_LIST_DONE); - - } - -} - -#ifndef FEATURE_MDDI_DISABLE_REVERSE -static void mddi_read_rev_packet(byte *data_ptr) -{ - uint16 i, length; - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - uint8 *rev_ptr_overflow = - (pmhctl->rev_ptr_start + MDDI_REV_BUFFER_SIZE); - - /* first determine the length and handle invalid lengths */ - length = *pmhctl->rev_ptr_curr++; - if (pmhctl->rev_ptr_curr >= rev_ptr_overflow) - pmhctl->rev_ptr_curr = pmhctl->rev_ptr_start; - length |= ((*pmhctl->rev_ptr_curr++) << 8); - if (pmhctl->rev_ptr_curr >= rev_ptr_overflow) - pmhctl->rev_ptr_curr = pmhctl->rev_ptr_start; - if (length > (pmhctl->rev_pkt_size - 2)) { - MDDI_MSG_ERR("Invalid rev pkt length %d\n", length); - /* rev_pkt_size should always be <= rev_ptr_size so limit to packet size */ - length = pmhctl->rev_pkt_size - 2; - } - - /* If the data pointer is NULL, just increment the pmhctl->rev_ptr_curr. - * Loop around if necessary. Don't bother reading the data. - */ - if (data_ptr == NULL) { - pmhctl->rev_ptr_curr += length; - if (pmhctl->rev_ptr_curr >= rev_ptr_overflow) - pmhctl->rev_ptr_curr -= MDDI_REV_BUFFER_SIZE; - return; - } - - data_ptr[0] = length & 0x0ff; - data_ptr[1] = length >> 8; - data_ptr += 2; - /* copy the data to data_ptr byte-at-a-time */ - for (i = 0; (i < length) && (pmhctl->rev_ptr_curr < rev_ptr_overflow); - i++) - *data_ptr++ = *pmhctl->rev_ptr_curr++; - if (pmhctl->rev_ptr_curr >= rev_ptr_overflow) - pmhctl->rev_ptr_curr = pmhctl->rev_ptr_start; - for (; (i < length) && (pmhctl->rev_ptr_curr < rev_ptr_overflow); i++) - *data_ptr++ = *pmhctl->rev_ptr_curr++; -} - -static void mddi_process_rev_packets(void) -{ - uint32 rev_packet_count; - word i; - uint32 crc_errors; - boolean mddi_reg_read_successful = FALSE; - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - pmhctl->log_parms.rev_enc_cnt++; - if ((pmhctl->rev_state != MDDI_REV_ENCAP_ISSUED) && - (pmhctl->rev_state != MDDI_REV_STATUS_REQ_ISSUED) && - (pmhctl->rev_state != MDDI_REV_CLIENT_CAP_ISSUED)) { - MDDI_MSG_ERR("Wrong state %d for reverse int\n", - pmhctl->rev_state); - } - /* Turn off MDDI_INT_REV_AVAIL interrupt */ - mddi_host_reg_outm(INTEN, MDDI_INT_REV_DATA_AVAIL, 0); - - /* Clear rev data avail int */ - mddi_host_reg_out(INT, MDDI_INT_REV_DATA_AVAIL); - - /* Get Number of packets */ - rev_packet_count = mddi_host_reg_in(REV_PKT_CNT); - -#ifndef T_MSM7500 - /* Clear out rev packet counter */ - mddi_host_reg_out(REV_PKT_CNT, 0x0000); -#endif - -#if defined(CONFIG_FB_MSM_MDP31) || defined(CONFIG_FB_MSM_MDP40) - if ((pmhctl->rev_state == MDDI_REV_CLIENT_CAP_ISSUED) && - (rev_packet_count > 0) && - (mddi_host_core_version == 0x28 || - mddi_host_core_version == 0x30)) { - - uint32 int_reg; - uint32 max_count = 0; - - mddi_host_reg_out(REV_PTR, pmhctl->mddi_rev_ptr_write_val); - int_reg = mddi_host_reg_in(INT); - while ((int_reg & 0x100000) == 0) { - udelay(3); - int_reg = mddi_host_reg_in(INT); - if (++max_count > 100) - break; - } - } -#endif - - /* Get CRC error count */ - crc_errors = mddi_host_reg_in(REV_CRC_ERR); - if (crc_errors != 0) { - pmhctl->log_parms.rev_crc_cnt += crc_errors; - pmhctl->stats.rev_crc_count += crc_errors; - MDDI_MSG_ERR("!!! MDDI %d Reverse CRC Error(s) !!!\n", - crc_errors); -#ifndef T_MSM7500 - /* Clear CRC error count */ - mddi_host_reg_out(REV_CRC_ERR, 0x0000); -#endif - /* also issue an RTD to attempt recovery */ - pmhctl->rtd_counter = mddi_rtd_frequency; - } - - pmhctl->rtd_value = mddi_host_reg_in(RTD_VAL); - - MDDI_MSG_DEBUG("MDDI rev pkt cnt=%d, ptr=0x%x, RTD:0x%x\n", - rev_packet_count, - pmhctl->rev_ptr_curr - pmhctl->rev_ptr_start, - pmhctl->rtd_value); - - if (rev_packet_count >= 1) { - mddi_invalidate_cache_lines((uint32 *) pmhctl->rev_ptr_start, - MDDI_REV_BUFFER_SIZE); - } else { - MDDI_MSG_ERR("Reverse pkt sent, no data rxd\n"); - if (mddi_reg_read_value_ptr) - *mddi_reg_read_value_ptr = -EBUSY; - } - /* order the reads */ - dma_coherent_post_ops(); - for (i = 0; i < rev_packet_count; i++) { - mddi_rev_packet_type *rev_pkt_ptr; - - mddi_read_rev_packet(rev_packet_data); - - rev_pkt_ptr = (mddi_rev_packet_type *) rev_packet_data; - - if (rev_pkt_ptr->packet_length > pmhctl->rev_pkt_size) { - MDDI_MSG_ERR("!!!invalid packet size: %d\n", - rev_pkt_ptr->packet_length); - } - - MDDI_MSG_DEBUG("MDDI rev pkt 0x%x size 0x%x\n", - rev_pkt_ptr->packet_type, - rev_pkt_ptr->packet_length); - - /* Do whatever you want to do with the data based on the packet type */ - switch (rev_pkt_ptr->packet_type) { - case 66: /* Client Capability */ - { - mddi_client_capability_type - *client_capability_pkt_ptr; - - client_capability_pkt_ptr = - (mddi_client_capability_type *) - rev_packet_data; - MDDI_MSG_NOTICE - ("Client Capability: Week=%d, Year=%d\n", - client_capability_pkt_ptr-> - Week_of_Manufacture, - client_capability_pkt_ptr-> - Year_of_Manufacture); - memcpy((void *)&mddi_client_capability_pkt, - (void *)rev_packet_data, - sizeof(mddi_client_capability_type)); - pmhctl->log_parms.cli_cap_cnt++; - } - break; - - case 70: /* Display Status */ - { - mddi_client_status_type *client_status_pkt_ptr; - - client_status_pkt_ptr = - (mddi_client_status_type *) rev_packet_data; - if ((client_status_pkt_ptr->crc_error_count != - 0) - || (client_status_pkt_ptr-> - reverse_link_request != 0)) { - MDDI_MSG_ERR - ("Client Status: RevReq=%d, CrcErr=%d\n", - client_status_pkt_ptr-> - reverse_link_request, - client_status_pkt_ptr-> - crc_error_count); - } else { - MDDI_MSG_DEBUG - ("Client Status: RevReq=%d, CrcErr=%d\n", - client_status_pkt_ptr-> - reverse_link_request, - client_status_pkt_ptr-> - crc_error_count); - } - pmhctl->log_parms.fwd_crc_cnt += - client_status_pkt_ptr->crc_error_count; - pmhctl->stats.fwd_crc_count += - client_status_pkt_ptr->crc_error_count; - pmhctl->log_parms.cli_stat_cnt++; - } - break; - - case 146: /* register access packet */ - { - mddi_register_access_packet_type - * regacc_pkt_ptr; - uint32 data_count; - - regacc_pkt_ptr = - (mddi_register_access_packet_type *) - rev_packet_data; - - /* Bits[0:13] - read data count */ - data_count = regacc_pkt_ptr->read_write_info - & 0x3FFF; - MDDI_MSG_DEBUG("\n MDDI rev read: 0x%x", - regacc_pkt_ptr->read_write_info); - MDDI_MSG_DEBUG("Reg Acc parse reg=0x%x," - "value=0x%x\n", regacc_pkt_ptr-> - register_address, regacc_pkt_ptr-> - register_data_list[0]); - - /* Copy register value to location passed in */ - if (mddi_reg_read_value_ptr) { -#if defined(T_MSM6280) && !defined(T_MSM7200) - /* only least significant 16 bits are valid with 6280 */ - *mddi_reg_read_value_ptr = - regacc_pkt_ptr-> - register_data_list[0] & 0x0000ffff; - mddi_reg_read_successful = TRUE; - mddi_reg_read_value_ptr = NULL; -#else - if (data_count && data_count <= - MDDI_HOST_MAX_CLIENT_REG_IN_SAME_ADDR) { - memcpy(mddi_reg_read_value_ptr, - (void *)®acc_pkt_ptr-> - register_data_list[0], - data_count * 4); - mddi_reg_read_successful = TRUE; - mddi_reg_read_value_ptr = NULL; - } -#endif - } - -#ifdef DEBUG_MDDIHOSTI - if ((mddi_gpio.polling_enabled) && - (regacc_pkt_ptr->register_address == - mddi_gpio.polling_reg)) { - /* - * ToDo: need to call Linux GPIO call - * here... - */ - mddi_client_lcd_gpio_poll( - regacc_pkt_ptr->register_data_list[0]); - } -#endif - pmhctl->log_parms.reg_read_cnt++; - } - break; - - case INVALID_PKT_TYPE: /* 0xFFFF */ - MDDI_MSG_ERR("!!!INVALID_PKT_TYPE rcvd\n"); - break; - - default: /* any other packet */ - { - uint16 hdlr; - - for (hdlr = 0; hdlr < MAX_MDDI_REV_HANDLERS; - hdlr++) { - if (mddi_rev_pkt_handler[hdlr]. - handler == NULL) - continue; - if (mddi_rev_pkt_handler[hdlr]. - pkt_type == - rev_pkt_ptr->packet_type) { - (*(mddi_rev_pkt_handler[hdlr]. - handler)) (rev_pkt_ptr); - /* pmhctl->rev_state = MDDI_REV_IDLE; */ - break; - } - } - if (hdlr >= MAX_MDDI_REV_HANDLERS) - MDDI_MSG_ERR("MDDI unknown rev pkt\n"); - } - break; - } - } - if ((pmhctl->rev_ptr_curr + pmhctl->rev_pkt_size) >= - (pmhctl->rev_ptr_start + MDDI_REV_BUFFER_SIZE)) { - pmhctl->rev_ptr_written = FALSE; - } - - if (pmhctl->rev_state == MDDI_REV_ENCAP_ISSUED) { - pmhctl->rev_state = MDDI_REV_IDLE; - if (mddi_rev_user.waiting) { - mddi_rev_user.waiting = FALSE; - complete(&(mddi_rev_user.done_comp)); - } else if (pmhctl->llist_info.reg_read_idx == UNASSIGNED_INDEX) { - MDDI_MSG_ERR - ("Reverse Encap state, but no reg read in progress\n"); - } else { - if ((!mddi_reg_read_successful) && - (mddi_reg_read_retry < mddi_reg_read_retry_max) && - (mddi_enable_reg_read_retry)) { - /* - * There is a race condition that can happen - * where the reverse encapsulation message is - * sent out by the MDDI host before the register - * read packet is sent. As a work-around for - * that problem we issue the reverse - * encapsulation one more time before giving up. - */ - if (mddi_enable_reg_read_retry_once) - mddi_reg_read_retry = - mddi_reg_read_retry_max; - else - mddi_reg_read_retry++; - pmhctl->rev_state = MDDI_REV_REG_READ_SENT; - pmhctl->stats.reg_read_failure++; - } else { - uint16 reg_read_idx = - pmhctl->llist_info.reg_read_idx; - - mddi_reg_read_retry = 0; - if (pmhctl->llist_notify[reg_read_idx].waiting) { - complete(& - (pmhctl-> - llist_notify[reg_read_idx]. - done_comp)); - } - pmhctl->llist_info.reg_read_idx = - UNASSIGNED_INDEX; - if (pmhctl->llist_notify[reg_read_idx]. - done_cb != NULL) { - (* - (pmhctl->llist_notify[reg_read_idx]. - done_cb)) (); - } - pmhctl->llist_notify[reg_read_idx].next_idx = - UNASSIGNED_INDEX; - pmhctl->llist_notify[reg_read_idx].in_use = - FALSE; - pmhctl->llist_notify[reg_read_idx].waiting = - FALSE; - pmhctl->llist_notify[reg_read_idx].done_cb = - NULL; - if (!mddi_reg_read_successful) - pmhctl->stats.reg_read_failure++; - } - } - } else if (pmhctl->rev_state == MDDI_REV_CLIENT_CAP_ISSUED) { -#if defined(CONFIG_FB_MSM_MDP31) || defined(CONFIG_FB_MSM_MDP40) - if (mddi_host_core_version == 0x28 || - mddi_host_core_version == 0x30) { - mddi_host_reg_out(FIFO_ALLOC, 0x00); - pmhctl->rev_ptr_written = TRUE; - mddi_host_reg_out(REV_PTR, - pmhctl->mddi_rev_ptr_write_val); - pmhctl->rev_ptr_curr = pmhctl->rev_ptr_start; - mddi_host_reg_out(CMD, 0xC00); - } -#endif - - if (mddi_rev_user.waiting) { - mddi_rev_user.waiting = FALSE; - complete(&(mddi_rev_user.done_comp)); - } - pmhctl->rev_state = MDDI_REV_IDLE; - } else { - pmhctl->rev_state = MDDI_REV_IDLE; - } - - /* pmhctl->rev_state = MDDI_REV_IDLE; */ - - /* Re-enable interrupt */ - mddi_host_reg_outm(INTEN, MDDI_INT_REV_DATA_AVAIL, - MDDI_INT_REV_DATA_AVAIL); - -} - -static void mddi_issue_reverse_encapsulation(void) -{ - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - /* Only issue a reverse encapsulation packet if: - * 1) another reverse is not in progress (MDDI_REV_IDLE). - * 2) a register read has been sent (MDDI_REV_REG_READ_SENT). - * 3) forward is not in progress, because of a hw bug in client that - * causes forward crc errors on packet immediately after rev encap. - */ - if (((pmhctl->rev_state == MDDI_REV_IDLE) || - (pmhctl->rev_state == MDDI_REV_REG_READ_SENT)) && - (pmhctl->llist_info.transmitting_start_idx == UNASSIGNED_INDEX) && - (!mdp_in_processing)) { - uint32 mddi_command = MDDI_CMD_SEND_REV_ENCAP; - - if ((pmhctl->rev_state == MDDI_REV_REG_READ_SENT) || - (mddi_rev_encap_user_request == TRUE)) { - mddi_host_enable_io_clock(); - if (pmhctl->link_state == MDDI_LINK_HIBERNATING) { - /* need to wake up link before issuing rev encap command */ - MDDI_MSG_DEBUG("wake up link!\n"); - pmhctl->link_state = MDDI_LINK_ACTIVATING; - mddi_host_reg_out(CMD, MDDI_CMD_LINK_ACTIVE); - } else { - if (pmhctl->rtd_counter >= mddi_rtd_frequency) { - MDDI_MSG_DEBUG - ("mddi sending RTD command!\n"); - mddi_host_reg_out(CMD, - MDDI_CMD_SEND_RTD); - pmhctl->rtd_counter = 0; - pmhctl->log_parms.rtd_cnt++; - } - if (pmhctl->rev_state != MDDI_REV_REG_READ_SENT) { - /* this is generic reverse request by user, so - * reset the waiting flag. */ - mddi_rev_encap_user_request = FALSE; - } - /* link is active so send reverse encap to get register read results */ - pmhctl->rev_state = MDDI_REV_ENCAP_ISSUED; - mddi_command = MDDI_CMD_SEND_REV_ENCAP; - MDDI_MSG_DEBUG("sending rev encap!\n"); - } - } else - if ((pmhctl->client_status_cnt >= - mddi_client_status_frequency) - || mddi_client_capability_request) { - mddi_host_enable_io_clock(); - if (pmhctl->link_state == MDDI_LINK_HIBERNATING) { - /* only wake up the link if it client status is overdue */ - if ((pmhctl->client_status_cnt >= - (mddi_client_status_frequency * 2)) - || mddi_client_capability_request) { - /* need to wake up link before issuing rev encap command */ - MDDI_MSG_DEBUG("wake up link!\n"); - pmhctl->link_state = - MDDI_LINK_ACTIVATING; - mddi_host_reg_out(CMD, - MDDI_CMD_LINK_ACTIVE); - } - } else { - if (pmhctl->rtd_counter >= mddi_rtd_frequency) { - MDDI_MSG_DEBUG - ("mddi sending RTD command!\n"); - mddi_host_reg_out(CMD, - MDDI_CMD_SEND_RTD); - pmhctl->rtd_counter = 0; - pmhctl->log_parms.rtd_cnt++; - } - /* periodically get client status */ - MDDI_MSG_DEBUG - ("mddi sending rev enc! (get status)\n"); - if (mddi_client_capability_request) { - pmhctl->rev_state = - MDDI_REV_CLIENT_CAP_ISSUED; - mddi_command = MDDI_CMD_GET_CLIENT_CAP; - mddi_client_capability_request = FALSE; - } else { - pmhctl->rev_state = - MDDI_REV_STATUS_REQ_ISSUED; - pmhctl->client_status_cnt = 0; - mddi_command = - MDDI_CMD_GET_CLIENT_STATUS; - } - } - } - if ((pmhctl->rev_state == MDDI_REV_ENCAP_ISSUED) || - (pmhctl->rev_state == MDDI_REV_STATUS_REQ_ISSUED) || - (pmhctl->rev_state == MDDI_REV_CLIENT_CAP_ISSUED)) { - pmhctl->int_type.rev_encap_count++; -#if defined(T_MSM6280) && !defined(T_MSM7200) - mddi_rev_pointer_written = TRUE; - mddi_host_reg_out(REV_PTR, mddi_rev_ptr_write_val); - mddi_rev_ptr_curr = mddi_rev_ptr_start; - /* force new rev ptr command */ - mddi_host_reg_out(CMD, 0xC00); -#else - if (!pmhctl->rev_ptr_written) { - MDDI_MSG_DEBUG("writing reverse pointer!\n"); - pmhctl->rev_ptr_written = TRUE; -#if defined(CONFIG_FB_MSM_MDP31) || defined(CONFIG_FB_MSM_MDP40) - if ((pmhctl->rev_state == - MDDI_REV_CLIENT_CAP_ISSUED) && - (mddi_host_core_version == 0x28 || - mddi_host_core_version == 0x30)) { - pmhctl->rev_ptr_written = FALSE; - mddi_host_reg_out(FIFO_ALLOC, 0x02); - } else - mddi_host_reg_out(REV_PTR, - pmhctl-> - mddi_rev_ptr_write_val); -#else - mddi_host_reg_out(REV_PTR, - pmhctl-> - mddi_rev_ptr_write_val); -#endif - } -#endif - if (mddi_debug_clear_rev_data) { - uint16 i; - for (i = 0; i < MDDI_MAX_REV_DATA_SIZE / 4; i++) - pmhctl->rev_data_buf[i] = 0xdddddddd; - /* clean cache */ - mddi_flush_cache_lines(pmhctl->rev_data_buf, - MDDI_MAX_REV_DATA_SIZE); - } - - /* send reverse encapsulation to get needed data */ - mddi_host_reg_out(CMD, mddi_command); - } - } - -} - -static void mddi_process_client_initiated_wakeup(void) -{ - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - /* Disable MDDI_INT Interrupt, we detect client initiated wakeup one - * time for each entry into hibernation */ - mddi_host_reg_outm(INTEN, MDDI_INT_MDDI_IN, 0); - - if (host_idx == MDDI_HOST_PRIM) { - if (mddi_vsync_detect_enabled) { - mddi_host_enable_io_clock(); -#ifndef MDDI_HOST_DISP_LISTEN - /* issue command to bring up link */ - /* need to do this to clear the vsync condition */ - if (pmhctl->link_state == MDDI_LINK_HIBERNATING) { - pmhctl->link_state = MDDI_LINK_ACTIVATING; - mddi_host_reg_out(CMD, MDDI_CMD_LINK_ACTIVE); - } -#endif - /* - * Indicate to client specific code that vsync was - * enabled, and we did not detect a client initiated - * wakeup. The client specific handler can clear the - * condition if necessary to prevent subsequent - * client initiated wakeups. - */ - mddi_client_lcd_vsync_detected(TRUE); - pmhctl->log_parms.vsync_response_cnt++; - MDDI_MSG_NOTICE("MDDI_INT_IN condition\n"); - - } - } - - if (mddi_gpio.polling_enabled) { - mddi_host_enable_io_clock(); - /* check interrupt status now */ - (void)mddi_queue_register_read_int(mddi_gpio.polling_reg, - &mddi_gpio.polling_val); - } -} -#endif /* FEATURE_MDDI_DISABLE_REVERSE */ - -static void mddi_host_isr(void) -{ - uint32 int_reg, int_en; -#ifndef FEATURE_MDDI_DISABLE_REVERSE - uint32 status_reg; -#endif - mddi_host_type host_idx = mddi_curr_host; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - if (!MDDI_HOST_IS_HCLK_ON) { - MDDI_HOST_ENABLE_HCLK; - } - int_reg = mddi_host_reg_in(INT); - int_en = mddi_host_reg_in(INTEN); - pmhctl->saved_int_reg = int_reg; - pmhctl->saved_int_en = int_en; - int_reg = int_reg & int_en; - pmhctl->int_type.count++; - - -#ifndef FEATURE_MDDI_DISABLE_REVERSE - status_reg = mddi_host_reg_in(STAT); - - if ((int_reg & MDDI_INT_MDDI_IN) || - ((int_en & MDDI_INT_MDDI_IN) && - ((int_reg == 0) || (status_reg & MDDI_STAT_CLIENT_WAKEUP_REQ)))) { - /* - * The MDDI_IN condition will clear itself, and so it is - * possible that MDDI_IN was the reason for the isr firing, - * even though the interrupt register does not have the - * MDDI_IN bit set. To check if this was the case we need to - * look at the status register bit that signifies a client - * initiated wakeup. If the status register bit is set, as well - * as the MDDI_IN interrupt enabled, then we treat this as a - * client initiated wakeup. - */ - if (int_reg & MDDI_INT_MDDI_IN) - pmhctl->int_type.in_count++; - mddi_process_client_initiated_wakeup(); - } -#endif - - if (int_reg & MDDI_INT_LINK_STATE_CHANGES) { - pmhctl->int_type.state_change_count++; - mddi_report_state_change(int_reg); - } - - if (int_reg & MDDI_INT_PRI_LINK_LIST_DONE) { - pmhctl->int_type.ll_done_count++; - mddi_process_link_list_done(); - } -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (int_reg & MDDI_INT_REV_DATA_AVAIL) { - pmhctl->int_type.rev_avail_count++; - mddi_process_rev_packets(); - } -#endif - - if (int_reg & MDDI_INT_ERROR_CONDITIONS) { - pmhctl->int_type.error_count++; - mddi_report_errors(int_reg); - - mddi_host_reg_out(INT, int_reg & MDDI_INT_ERROR_CONDITIONS); - } -#ifndef FEATURE_MDDI_DISABLE_REVERSE - mddi_issue_reverse_encapsulation(); - - if ((pmhctl->rev_state != MDDI_REV_ENCAP_ISSUED) && - (pmhctl->rev_state != MDDI_REV_STATUS_REQ_ISSUED)) -#endif - /* don't want simultaneous reverse and forward with Eagle */ - mddi_queue_forward_linked_list(); - - if (int_reg & MDDI_INT_NO_CMD_PKTS_PEND) { - /* this interrupt is used to kick the isr when hibernation is disabled */ - mddi_host_reg_outm(INTEN, MDDI_INT_NO_CMD_PKTS_PEND, 0); - } - - if ((!mddi_host_mdp_active_flag) && - (!mddi_vsync_detect_enabled) && - (pmhctl->llist_info.transmitting_start_idx == UNASSIGNED_INDEX) && - (pmhctl->llist_info.waiting_start_idx == UNASSIGNED_INDEX) && - (pmhctl->rev_state == MDDI_REV_IDLE)) { - if (pmhctl->link_state == MDDI_LINK_HIBERNATING) { - mddi_host_disable_io_clock(); - mddi_host_disable_hclk(); - } -#ifdef FEATURE_MDDI_HOST_ENABLE_EARLY_HIBERNATION - else if ((pmhctl->link_state == MDDI_LINK_ACTIVE) && - (!pmhctl->disable_hibernation)) { - mddi_host_reg_out(CMD, MDDI_CMD_POWERDOWN); - } -#endif - } -} - -static void mddi_host_isr_primary(void) -{ - mddi_curr_host = MDDI_HOST_PRIM; - mddi_host_isr(); -} - -irqreturn_t mddi_pmdh_isr_proxy(int irq, void *ptr) -{ - mddi_host_isr_primary(); - return IRQ_HANDLED; -} - -static void mddi_host_isr_external(void) -{ - mddi_curr_host = MDDI_HOST_EXT; - mddi_host_isr(); - mddi_curr_host = MDDI_HOST_PRIM; -} - -irqreturn_t mddi_emdh_isr_proxy(int irq, void *ptr) -{ - mddi_host_isr_external(); - return IRQ_HANDLED; -} - -static void mddi_host_initialize_registers(mddi_host_type host_idx) -{ - uint32 pad_reg_val; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - if (pmhctl->driver_state == MDDI_DRIVER_ENABLED) - return; - - /* turn on HCLK to MDDI host core */ - mddi_host_enable_hclk(); - - /* MDDI Reset command */ - mddi_host_reg_out(CMD, MDDI_CMD_RESET); - - /* Version register (= 0x01) */ - mddi_host_reg_out(VERSION, 0x0001); - - /* Bytes per subframe register */ - mddi_host_reg_out(BPS, MDDI_HOST_BYTES_PER_SUBFRAME); - - /* Subframes per media frames register (= 0x03) */ - mddi_host_reg_out(SPM, 0x0003); - - /* Turn Around 1 register (= 0x05) */ - mddi_host_reg_out(TA1_LEN, 0x0005); - - /* Turn Around 2 register (= 0x0C) */ - mddi_host_reg_out(TA2_LEN, MDDI_HOST_TA2_LEN); - - /* Drive hi register (= 0x96) */ - mddi_host_reg_out(DRIVE_HI, 0x0096); - - /* Drive lo register (= 0x32) */ - mddi_host_reg_out(DRIVE_LO, 0x0032); - - /* Display wakeup count register (= 0x3c) */ - mddi_host_reg_out(DISP_WAKE, 0x003c); - - /* Reverse Rate Divisor register (= 0x2) */ - mddi_host_reg_out(REV_RATE_DIV, MDDI_HOST_REV_RATE_DIV); - -#ifndef FEATURE_MDDI_DISABLE_REVERSE - /* Reverse Pointer Size */ - mddi_host_reg_out(REV_SIZE, MDDI_REV_BUFFER_SIZE); - - /* Rev Encap Size */ - mddi_host_reg_out(REV_ENCAP_SZ, pmhctl->rev_pkt_size); -#endif - - /* Periodic Rev Encap */ - /* don't send periodically */ - mddi_host_reg_out(CMD, MDDI_CMD_PERIODIC_REV_ENCAP); - - pad_reg_val = mddi_host_reg_in(PAD_CTL); - if (pad_reg_val == 0) { - /* If we are turning on band gap, need to wait 5us before turning - * on the rest of the PAD */ - mddi_host_reg_out(PAD_CTL, 0x08000); - udelay(5); - } -#ifdef T_MSM7200 - /* Recommendation from PAD hw team */ - mddi_host_reg_out(PAD_CTL, 0xa850a); -#else - /* Recommendation from PAD hw team */ - mddi_host_reg_out(PAD_CTL, 0xa850f); -#endif - - pad_reg_val = 0x00220020; - -#if defined(CONFIG_FB_MSM_MDP31) || defined(CONFIG_FB_MSM_MDP40) - mddi_host_reg_out(PAD_IO_CTL, 0x00320000); - mddi_host_reg_out(PAD_CAL, pad_reg_val); -#endif - - mddi_host_core_version = mddi_host_reg_inm(CORE_VER, 0xffff); - -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (mddi_host_core_version >= 8) - mddi_rev_ptr_workaround = FALSE; - pmhctl->rev_ptr_curr = pmhctl->rev_ptr_start; -#endif - - if ((mddi_host_core_version > 8) && (mddi_host_core_version < 0x19)) - mddi_host_reg_out(TEST, 0x2); - - /* Need an even number for counts */ - mddi_host_reg_out(DRIVER_START_CNT, 0x60006); - -#ifndef T_MSM7500 - /* Setup defaults for MDP related register */ - mddi_host_reg_out(MDP_VID_FMT_DES, 0x5666); - mddi_host_reg_out(MDP_VID_PIX_ATTR, 0x00C3); - mddi_host_reg_out(MDP_VID_CLIENTID, 0); -#endif - - /* automatically hibernate after 1 empty subframe */ - if (pmhctl->disable_hibernation) - mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE); - else - mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE | 1); - - /* Bring up link if display (client) requests it */ -#ifdef MDDI_HOST_DISP_LISTEN - mddi_host_reg_out(CMD, MDDI_CMD_DISP_LISTEN); -#else - mddi_host_reg_out(CMD, MDDI_CMD_DISP_IGNORE); -#endif - -} - -void mddi_host_configure_interrupts(mddi_host_type host_idx, boolean enable) -{ - unsigned long flags; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - spin_lock_irqsave(&mddi_host_spin_lock, flags); - - /* turn on HCLK to MDDI host core if it has been disabled */ - mddi_host_enable_hclk(); - /* Clear MDDI Interrupt enable reg */ - mddi_host_reg_out(INTEN, 0); - - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - - if (enable) { - pmhctl->driver_state = MDDI_DRIVER_ENABLED; - - if (host_idx == MDDI_HOST_PRIM) { - if (request_irq - (INT_MDDI_PRI, mddi_pmdh_isr_proxy, IRQF_DISABLED, - "PMDH", 0) != 0) - printk(KERN_ERR - "a mddi: unable to request_irq\n"); - else { - int_mddi_pri_flag = TRUE; - irq_enabled = 1; - } - } else { - if (request_irq - (INT_MDDI_EXT, mddi_emdh_isr_proxy, IRQF_DISABLED, - "EMDH", 0) != 0) - printk(KERN_ERR - "b mddi: unable to request_irq\n"); - else - int_mddi_ext_flag = TRUE; - } - - /* Set MDDI Interrupt enable reg -- Enable Reverse data avail */ -#ifdef FEATURE_MDDI_DISABLE_REVERSE - mddi_host_reg_out(INTEN, - MDDI_INT_ERROR_CONDITIONS | - MDDI_INT_LINK_STATE_CHANGES); -#else - /* Reverse Pointer register */ - pmhctl->rev_ptr_written = FALSE; - - mddi_host_reg_out(INTEN, - MDDI_INT_REV_DATA_AVAIL | - MDDI_INT_ERROR_CONDITIONS | - MDDI_INT_LINK_STATE_CHANGES); - pmhctl->rtd_counter = mddi_rtd_frequency; - pmhctl->client_status_cnt = 0; -#endif - } else { - if (pmhctl->driver_state == MDDI_DRIVER_ENABLED) - pmhctl->driver_state = MDDI_DRIVER_DISABLED; - } - -} - -/* - * mddi_host_client_cnt_reset: - * reset client_status_cnt to 0 to make sure host does not - * send RTD cmd to client right after resume before mddi - * client be powered up. this fix "MDDI RTD Failure" problem - */ -void mddi_host_client_cnt_reset(void) -{ - unsigned long flags; - mddi_host_cntl_type *pmhctl; - - pmhctl = &(mhctl[MDDI_HOST_PRIM]); - spin_lock_irqsave(&mddi_host_spin_lock, flags); - pmhctl->client_status_cnt = 0; - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); -} - -static void mddi_host_powerup(mddi_host_type host_idx) -{ - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - if (pmhctl->link_state != MDDI_LINK_DISABLED) - return; - - /* enable IO_CLK and hclk to MDDI host core */ - mddi_host_enable_io_clock(); - - mddi_host_initialize_registers(host_idx); - mddi_host_configure_interrupts(host_idx, TRUE); - - pmhctl->link_state = MDDI_LINK_ACTIVATING; - - /* Link activate command */ - mddi_host_reg_out(CMD, MDDI_CMD_LINK_ACTIVE); - -#ifdef CLKRGM_MDDI_IO_CLOCK_IN_MHZ - MDDI_MSG_NOTICE("MDDI Host: Activating Link %d Mbps\n", - CLKRGM_MDDI_IO_CLOCK_IN_MHZ * 2); -#else - MDDI_MSG_NOTICE("MDDI Host: Activating Link\n"); -#endif - - /* Initialize the timer */ - if (host_idx == MDDI_HOST_PRIM) - mddi_host_timer_service(0); -} - -void mddi_send_fw_link_skew_cal(mddi_host_type host_idx) -{ - mddi_host_reg_out(CMD, MDDI_CMD_FW_LINK_SKEW_CAL); - MDDI_MSG_DEBUG("%s: Skew Calibration done!!\n", __func__); -} - - -void mddi_host_init(mddi_host_type host_idx) -/* Write out the MDDI configuration registers */ -{ - static boolean initialized = FALSE; - mddi_host_cntl_type *pmhctl; - - if (host_idx >= MDDI_NUM_HOST_CORES) { - MDDI_MSG_ERR("Invalid host core index\n"); - return; - } - - if (!initialized) { - uint16 idx; - mddi_host_type host; - - for (host = MDDI_HOST_PRIM; host < MDDI_NUM_HOST_CORES; host++) { - pmhctl = &(mhctl[host]); - initialized = TRUE; - - pmhctl->llist_ptr = - dma_alloc_coherent(NULL, MDDI_LLIST_POOL_SIZE, - &(pmhctl->llist_dma_addr), - GFP_KERNEL); - pmhctl->llist_dma_ptr = - (mddi_linked_list_type *) (void *)pmhctl-> - llist_dma_addr; -#ifdef FEATURE_MDDI_DISABLE_REVERSE - pmhctl->rev_data_buf = NULL; - if (pmhctl->llist_ptr == NULL) -#else - mddi_rev_user.waiting = FALSE; - init_completion(&(mddi_rev_user.done_comp)); - pmhctl->rev_data_buf = - dma_alloc_coherent(NULL, MDDI_MAX_REV_DATA_SIZE, - &(pmhctl->rev_data_dma_addr), - GFP_KERNEL); - if ((pmhctl->llist_ptr == NULL) - || (pmhctl->rev_data_buf == NULL)) -#endif - { - MDDI_MSG_CRIT - ("unable to alloc non-cached memory\n"); - } - llist_extern[host] = pmhctl->llist_ptr; - llist_dma_extern[host] = pmhctl->llist_dma_ptr; - llist_extern_notify[host] = pmhctl->llist_notify; - - for (idx = 0; idx < UNASSIGNED_INDEX; idx++) { - init_completion(& - (pmhctl->llist_notify[idx]. - done_comp)); - } - init_completion(&(pmhctl->mddi_llist_avail_comp)); - spin_lock_init(&mddi_host_spin_lock); - pmhctl->mddi_waiting_for_llist_avail = FALSE; - pmhctl->mddi_rev_ptr_write_val = - (uint32) (void *)(pmhctl->rev_data_dma_addr); - pmhctl->rev_ptr_start = (void *)pmhctl->rev_data_buf; - - pmhctl->rev_pkt_size = MDDI_DEFAULT_REV_PKT_SIZE; - pmhctl->rev_state = MDDI_REV_IDLE; -#ifdef IMAGE_MODEM_PROC - /* assume hibernation state is last state from APPS proc, so that - * we don't reinitialize the host core */ - pmhctl->link_state = MDDI_LINK_HIBERNATING; -#else - pmhctl->link_state = MDDI_LINK_DISABLED; -#endif - pmhctl->driver_state = MDDI_DRIVER_DISABLED; - pmhctl->disable_hibernation = FALSE; - - /* initialize llist variables */ - pmhctl->llist_info.transmitting_start_idx = - UNASSIGNED_INDEX; - pmhctl->llist_info.transmitting_end_idx = - UNASSIGNED_INDEX; - pmhctl->llist_info.waiting_start_idx = UNASSIGNED_INDEX; - pmhctl->llist_info.waiting_end_idx = UNASSIGNED_INDEX; - pmhctl->llist_info.reg_read_idx = UNASSIGNED_INDEX; - pmhctl->llist_info.next_free_idx = - MDDI_FIRST_DYNAMIC_LLIST_IDX; - pmhctl->llist_info.reg_read_waiting = FALSE; - - mddi_vsync_detect_enabled = FALSE; - mddi_gpio.polling_enabled = FALSE; - - pmhctl->int_type.count = 0; - pmhctl->int_type.in_count = 0; - pmhctl->int_type.disp_req_count = 0; - pmhctl->int_type.state_change_count = 0; - pmhctl->int_type.ll_done_count = 0; - pmhctl->int_type.rev_avail_count = 0; - pmhctl->int_type.error_count = 0; - pmhctl->int_type.rev_encap_count = 0; - pmhctl->int_type.llist_ptr_write_1 = 0; - pmhctl->int_type.llist_ptr_write_2 = 0; - - pmhctl->stats.fwd_crc_count = 0; - pmhctl->stats.rev_crc_count = 0; - pmhctl->stats.pri_underflow = 0; - pmhctl->stats.sec_underflow = 0; - pmhctl->stats.rev_overflow = 0; - pmhctl->stats.pri_overwrite = 0; - pmhctl->stats.sec_overwrite = 0; - pmhctl->stats.rev_overwrite = 0; - pmhctl->stats.dma_failure = 0; - pmhctl->stats.rtd_failure = 0; - pmhctl->stats.reg_read_failure = 0; -#ifdef FEATURE_MDDI_UNDERRUN_RECOVERY - pmhctl->stats.pri_underrun_detected = 0; -#endif - - pmhctl->log_parms.rtd_cnt = 0; - pmhctl->log_parms.rev_enc_cnt = 0; - pmhctl->log_parms.vid_cnt = 0; - pmhctl->log_parms.reg_acc_cnt = 0; - pmhctl->log_parms.cli_stat_cnt = 0; - pmhctl->log_parms.cli_cap_cnt = 0; - pmhctl->log_parms.reg_read_cnt = 0; - pmhctl->log_parms.link_active_cnt = 0; - pmhctl->log_parms.link_hibernate_cnt = 0; - pmhctl->log_parms.fwd_crc_cnt = 0; - pmhctl->log_parms.rev_crc_cnt = 0; - pmhctl->log_parms.vsync_response_cnt = 0; - - prev_parms[host_idx] = pmhctl->log_parms; - mddi_client_capability_pkt.packet_length = 0; - } - -#ifndef T_MSM7500 - /* tell clock driver we are user of this PLL */ - MDDI_HOST_ENABLE_IO_CLOCK; -#endif - } - - mddi_host_powerup(host_idx); - pmhctl = &(mhctl[host_idx]); -} - -#ifdef CONFIG_FB_MSM_MDDI_AUTO_DETECT -static uint32 mddi_client_id; - -uint32 mddi_get_client_id(void) -{ - -#ifndef FEATURE_MDDI_DISABLE_REVERSE - mddi_host_type host_idx = MDDI_HOST_PRIM; - static boolean client_detection_try = FALSE; - mddi_host_cntl_type *pmhctl; - unsigned long flags; - uint16 saved_rev_pkt_size; - int ret; - - if (!client_detection_try) { - /* Toshiba display requires larger drive_lo value */ - mddi_host_reg_out(DRIVE_LO, 0x0050); - - pmhctl = &(mhctl[MDDI_HOST_PRIM]); - - saved_rev_pkt_size = pmhctl->rev_pkt_size; - - /* Increase Rev Encap Size */ - pmhctl->rev_pkt_size = MDDI_CLIENT_CAPABILITY_REV_PKT_SIZE; - mddi_host_reg_out(REV_ENCAP_SZ, pmhctl->rev_pkt_size); - - /* disable hibernation temporarily */ - if (!pmhctl->disable_hibernation) - mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE); - - mddi_rev_user.waiting = TRUE; - INIT_COMPLETION(mddi_rev_user.done_comp); - - spin_lock_irqsave(&mddi_host_spin_lock, flags); - - /* turn on clock(s), if they have been disabled */ - mddi_host_enable_hclk(); - mddi_host_enable_io_clock(); - - mddi_client_capability_request = TRUE; - - if (pmhctl->rev_state == MDDI_REV_IDLE) { - /* attempt to send the reverse encapsulation now */ - mddi_issue_reverse_encapsulation(); - } - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - - wait_for_completion_killable(&(mddi_rev_user.done_comp)); - - /* Set Rev Encap Size back to its original value */ - pmhctl->rev_pkt_size = saved_rev_pkt_size; - mddi_host_reg_out(REV_ENCAP_SZ, pmhctl->rev_pkt_size); - - /* reenable auto-hibernate */ - if (!pmhctl->disable_hibernation) - mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE | 1); - - mddi_host_reg_out(DRIVE_LO, 0x0032); - client_detection_try = TRUE; - - mddi_client_id = (mddi_client_capability_pkt.Mfr_Name<<16) | - mddi_client_capability_pkt.Product_Code; - - if (!mddi_client_id) - mddi_disable(1); - - ret = mddi_client_power(mddi_client_id); - if (ret < 0) - MDDI_MSG_ERR("mddi_client_power return %d", ret); - } - -#endif - - return mddi_client_id; -} -#endif - -void mddi_host_powerdown(mddi_host_type host_idx) -{ - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - if (host_idx >= MDDI_NUM_HOST_CORES) { - MDDI_MSG_ERR("Invalid host core index\n"); - return; - } - - if (pmhctl->driver_state == MDDI_DRIVER_RESET) { - return; - } - - if (host_idx == MDDI_HOST_PRIM) { - /* disable timer */ - del_timer(&mddi_host_timer); - } - - mddi_host_configure_interrupts(host_idx, FALSE); - - /* turn on HCLK to MDDI host core if it has been disabled */ - mddi_host_enable_hclk(); - - /* MDDI Reset command */ - mddi_host_reg_out(CMD, MDDI_CMD_RESET); - - /* Pad Control Register */ - mddi_host_reg_out(PAD_CTL, 0x0); - - /* disable IO_CLK and hclk to MDDI host core */ - mddi_host_disable_io_clock(); - mddi_host_disable_hclk(); - - pmhctl->link_state = MDDI_LINK_DISABLED; - pmhctl->driver_state = MDDI_DRIVER_RESET; - - MDDI_MSG_NOTICE("MDDI Host: Disabling Link\n"); - -} - -uint16 mddi_get_next_free_llist_item(mddi_host_type host_idx, boolean wait) -{ - unsigned long flags; - uint16 ret_idx; - boolean forced_wait = FALSE; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - ret_idx = pmhctl->llist_info.next_free_idx; - - pmhctl->llist_info.next_free_idx++; - if (pmhctl->llist_info.next_free_idx >= MDDI_NUM_DYNAMIC_LLIST_ITEMS) - pmhctl->llist_info.next_free_idx = MDDI_FIRST_DYNAMIC_LLIST_IDX; - spin_lock_irqsave(&mddi_host_spin_lock, flags); - if (pmhctl->llist_notify[ret_idx].in_use) { - if (!wait) { - pmhctl->llist_info.next_free_idx = ret_idx; - ret_idx = UNASSIGNED_INDEX; - } else { - forced_wait = TRUE; - INIT_COMPLETION(pmhctl->mddi_llist_avail_comp); - } - } - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - - if (forced_wait) { - wait_for_completion_killable(& - (pmhctl-> - mddi_llist_avail_comp)); - MDDI_MSG_ERR("task waiting on mddi llist item\n"); - } - - if (ret_idx != UNASSIGNED_INDEX) { - pmhctl->llist_notify[ret_idx].waiting = FALSE; - pmhctl->llist_notify[ret_idx].done_cb = NULL; - pmhctl->llist_notify[ret_idx].in_use = TRUE; - pmhctl->llist_notify[ret_idx].next_idx = UNASSIGNED_INDEX; - } - - return ret_idx; -} - -uint16 mddi_get_reg_read_llist_item(mddi_host_type host_idx, boolean wait) -{ -#ifdef FEATURE_MDDI_DISABLE_REVERSE - MDDI_MSG_CRIT("No reverse link available\n"); - (void)wait; - return FALSE; -#else - unsigned long flags; - uint16 ret_idx; - boolean error = FALSE; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - spin_lock_irqsave(&mddi_host_spin_lock, flags); - if (pmhctl->llist_info.reg_read_idx != UNASSIGNED_INDEX) { - /* need to block here or is this an error condition? */ - error = TRUE; - ret_idx = UNASSIGNED_INDEX; - } - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - - if (!error) { - ret_idx = pmhctl->llist_info.reg_read_idx = - mddi_get_next_free_llist_item(host_idx, wait); - /* clear the reg_read_waiting flag */ - pmhctl->llist_info.reg_read_waiting = FALSE; - } - - if (error) - MDDI_MSG_ERR("***** Reg read still in progress! ****\n"); - return ret_idx; -#endif - -} - -void mddi_queue_forward_packets(uint16 first_llist_idx, - uint16 last_llist_idx, - boolean wait, - mddi_llist_done_cb_type llist_done_cb, - mddi_host_type host_idx) -{ - unsigned long flags; - mddi_linked_list_type *llist; - mddi_linked_list_type *llist_dma; - mddi_host_cntl_type *pmhctl = &(mhctl[host_idx]); - - if ((first_llist_idx >= UNASSIGNED_INDEX) || - (last_llist_idx >= UNASSIGNED_INDEX)) { - MDDI_MSG_ERR("MDDI queueing invalid linked list\n"); - return; - } - - if (pmhctl->link_state == MDDI_LINK_DISABLED) - MDDI_MSG_CRIT("MDDI host powered down!\n"); - - llist = pmhctl->llist_ptr; - llist_dma = pmhctl->llist_dma_ptr; - - /* clean cache so MDDI host can read data */ - memory_barrier(); - - pmhctl->llist_notify[last_llist_idx].waiting = wait; - if (wait) - INIT_COMPLETION(pmhctl->llist_notify[last_llist_idx].done_comp); - pmhctl->llist_notify[last_llist_idx].done_cb = llist_done_cb; - - spin_lock_irqsave(&mddi_host_spin_lock, flags); - - if ((pmhctl->llist_info.transmitting_start_idx == UNASSIGNED_INDEX) && - (pmhctl->llist_info.waiting_start_idx == UNASSIGNED_INDEX) && - (pmhctl->rev_state == MDDI_REV_IDLE)) { - /* no packets are currently transmitting */ -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (first_llist_idx == pmhctl->llist_info.reg_read_idx) { - /* This is the special case where the packet is a register read. */ - pmhctl->rev_state = MDDI_REV_REG_READ_ISSUED; - mddi_reg_read_retry = 0; - /* mddi_rev_reg_read_attempt = 1; */ - } -#endif - /* assign transmitting index values */ - pmhctl->llist_info.transmitting_start_idx = first_llist_idx; - pmhctl->llist_info.transmitting_end_idx = last_llist_idx; - - /* turn on clock(s), if they have been disabled */ - mddi_host_enable_hclk(); - mddi_host_enable_io_clock(); - pmhctl->int_type.llist_ptr_write_1++; - /* Write to primary pointer register */ - dma_coherent_pre_ops(); - mddi_host_reg_out(PRI_PTR, &llist_dma[first_llist_idx]); - - /* enable interrupt when complete */ - mddi_host_reg_outm(INTEN, MDDI_INT_PRI_LINK_LIST_DONE, - MDDI_INT_PRI_LINK_LIST_DONE); - - } else if (pmhctl->llist_info.waiting_start_idx == UNASSIGNED_INDEX) { -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (first_llist_idx == pmhctl->llist_info.reg_read_idx) { - /* - * we have a register read to send but need to wait - * for current reverse activity to end or there are - * packets currently transmitting - */ - /* mddi_rev_reg_read_attempt = 0; */ - pmhctl->llist_info.reg_read_waiting = TRUE; - } -#endif - - /* assign waiting index values */ - pmhctl->llist_info.waiting_start_idx = first_llist_idx; - pmhctl->llist_info.waiting_end_idx = last_llist_idx; - } else { - uint16 prev_end_idx = pmhctl->llist_info.waiting_end_idx; -#ifndef FEATURE_MDDI_DISABLE_REVERSE - if (first_llist_idx == pmhctl->llist_info.reg_read_idx) { - /* - * we have a register read to send but need to wait - * for current reverse activity to end or there are - * packets currently transmitting - */ - /* mddi_rev_reg_read_attempt = 0; */ - pmhctl->llist_info.reg_read_waiting = TRUE; - } -#endif - - llist = pmhctl->llist_ptr; - - /* clear end flag in previous last packet */ - llist[prev_end_idx].link_controller_flags = 0; - pmhctl->llist_notify[prev_end_idx].next_idx = first_llist_idx; - - /* set the next_packet_pointer of the previous last packet */ - llist[prev_end_idx].next_packet_pointer = - (void *)(&llist_dma[first_llist_idx]); - - /* clean cache so MDDI host can read data */ - memory_barrier(); - - /* assign new waiting last index value */ - pmhctl->llist_info.waiting_end_idx = last_llist_idx; - } - - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - -} - -void mddi_host_write_pix_attr_reg(uint32 value) -{ - (void)value; -} - -void mddi_queue_reverse_encapsulation(boolean wait) -{ -#ifdef FEATURE_MDDI_DISABLE_REVERSE - MDDI_MSG_CRIT("No reverse link available\n"); - (void)wait; -#else - unsigned long flags; - boolean error = FALSE; - mddi_host_type host_idx = MDDI_HOST_PRIM; - mddi_host_cntl_type *pmhctl = &(mhctl[MDDI_HOST_PRIM]); - - spin_lock_irqsave(&mddi_host_spin_lock, flags); - - /* turn on clock(s), if they have been disabled */ - mddi_host_enable_hclk(); - mddi_host_enable_io_clock(); - - if (wait) { - if (!mddi_rev_user.waiting) { - mddi_rev_user.waiting = TRUE; - INIT_COMPLETION(mddi_rev_user.done_comp); - } else - error = TRUE; - } - mddi_rev_encap_user_request = TRUE; - - if (pmhctl->rev_state == MDDI_REV_IDLE) { - /* attempt to send the reverse encapsulation now */ - mddi_host_type orig_host_idx = mddi_curr_host; - mddi_curr_host = host_idx; - mddi_issue_reverse_encapsulation(); - mddi_curr_host = orig_host_idx; - } - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - - if (error) { - MDDI_MSG_ERR("Reverse Encap request already in progress\n"); - } else if (wait) - wait_for_completion_killable(&(mddi_rev_user.done_comp)); -#endif -} - -/* ISR to be executed */ -boolean mddi_set_rev_handler(mddi_rev_handler_type handler, uint16 pkt_type) -{ -#ifdef FEATURE_MDDI_DISABLE_REVERSE - MDDI_MSG_CRIT("No reverse link available\n"); - (void)handler; - (void)pkt_type; - return (FALSE); -#else - unsigned long flags; - uint16 hdlr; - boolean handler_set = FALSE; - boolean overwrite = FALSE; - mddi_host_type host_idx = MDDI_HOST_PRIM; - mddi_host_cntl_type *pmhctl = &(mhctl[MDDI_HOST_PRIM]); - - /* Disable interrupts */ - spin_lock_irqsave(&mddi_host_spin_lock, flags); - - for (hdlr = 0; hdlr < MAX_MDDI_REV_HANDLERS; hdlr++) { - if (mddi_rev_pkt_handler[hdlr].pkt_type == pkt_type) { - mddi_rev_pkt_handler[hdlr].handler = handler; - if (handler == NULL) { - /* clearing handler from table */ - mddi_rev_pkt_handler[hdlr].pkt_type = - INVALID_PKT_TYPE; - handler_set = TRUE; - if (pkt_type == 0x10) { /* video stream packet */ - /* ensure HCLK on to MDDI host core before register write */ - mddi_host_enable_hclk(); - /* No longer getting video, so reset rev encap size to default */ - pmhctl->rev_pkt_size = - MDDI_DEFAULT_REV_PKT_SIZE; - mddi_host_reg_out(REV_ENCAP_SZ, - pmhctl->rev_pkt_size); - } - } else { - /* already a handler for this packet */ - overwrite = TRUE; - } - break; - } - } - if ((hdlr >= MAX_MDDI_REV_HANDLERS) && (handler != NULL)) { - /* assigning new handler */ - for (hdlr = 0; hdlr < MAX_MDDI_REV_HANDLERS; hdlr++) { - if (mddi_rev_pkt_handler[hdlr].pkt_type == - INVALID_PKT_TYPE) { - if ((pkt_type == 0x10) && /* video stream packet */ - (pmhctl->rev_pkt_size < - MDDI_VIDEO_REV_PKT_SIZE)) { - /* ensure HCLK on to MDDI host core before register write */ - mddi_host_enable_hclk(); - /* Increase Rev Encap Size */ - pmhctl->rev_pkt_size = - MDDI_VIDEO_REV_PKT_SIZE; - mddi_host_reg_out(REV_ENCAP_SZ, - pmhctl->rev_pkt_size); - } - mddi_rev_pkt_handler[hdlr].handler = handler; - mddi_rev_pkt_handler[hdlr].pkt_type = pkt_type; - handler_set = TRUE; - break; - } - } - } - - /* Restore interrupts */ - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - - if (overwrite) - MDDI_MSG_ERR("Overwriting previous rev packet handler\n"); - - return handler_set; - -#endif -} /* mddi_set_rev_handler */ - -void mddi_host_disable_hibernation(boolean disable) -{ - mddi_host_type host_idx = MDDI_HOST_PRIM; - mddi_host_cntl_type *pmhctl = &(mhctl[MDDI_HOST_PRIM]); - - if (disable) { - pmhctl->disable_hibernation = TRUE; - /* hibernation will be turned off by isr next time it is entered */ - } else { - if (pmhctl->disable_hibernation) { - unsigned long flags; - spin_lock_irqsave(&mddi_host_spin_lock, flags); - if (!MDDI_HOST_IS_HCLK_ON) - MDDI_HOST_ENABLE_HCLK; - mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE | 1); - spin_unlock_irqrestore(&mddi_host_spin_lock, flags); - pmhctl->disable_hibernation = FALSE; - } - } -} - -void mddi_mhctl_remove(mddi_host_type host_idx) -{ - mddi_host_cntl_type *pmhctl; - - pmhctl = &(mhctl[host_idx]); - - dma_free_coherent(NULL, MDDI_LLIST_POOL_SIZE, (void *)pmhctl->llist_ptr, - pmhctl->llist_dma_addr); - - dma_free_coherent(NULL, MDDI_MAX_REV_DATA_SIZE, - (void *)pmhctl->rev_data_buf, - pmhctl->rev_data_dma_addr); -} diff --git a/drivers/video/msm/mddihosti.h b/drivers/video/msm/mddihosti.h deleted file mode 100644 index 96675a0b77c3b537037311206b62ec8ae01769b6..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mddihosti.h +++ /dev/null @@ -1,552 +0,0 @@ -/* Copyright (c) 2008-2010, 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 MDDIHOSTI_H -#define MDDIHOSTI_H - -#include "msm_fb.h" -#include "mddihost.h" -#include - -/* Register offsets in MDDI, applies to both msm_pmdh_base and - * (u32)msm_emdh_base. */ -#define MDDI_CMD 0x0000 -#define MDDI_VERSION 0x0004 -#define MDDI_PRI_PTR 0x0008 -#define MDDI_BPS 0x0010 -#define MDDI_SPM 0x0014 -#define MDDI_INT 0x0018 -#define MDDI_INTEN 0x001c -#define MDDI_REV_PTR 0x0020 -#define MDDI_REV_SIZE 0x0024 -#define MDDI_STAT 0x0028 -#define MDDI_REV_RATE_DIV 0x002c -#define MDDI_REV_CRC_ERR 0x0030 -#define MDDI_TA1_LEN 0x0034 -#define MDDI_TA2_LEN 0x0038 -#define MDDI_TEST 0x0040 -#define MDDI_REV_PKT_CNT 0x0044 -#define MDDI_DRIVE_HI 0x0048 -#define MDDI_DRIVE_LO 0x004c -#define MDDI_DISP_WAKE 0x0050 -#define MDDI_REV_ENCAP_SZ 0x0054 -#define MDDI_RTD_VAL 0x0058 -#define MDDI_PAD_CTL 0x0068 -#define MDDI_DRIVER_START_CNT 0x006c -#define MDDI_CORE_VER 0x008c -#define MDDI_FIFO_ALLOC 0x0090 -#define MDDI_PAD_IO_CTL 0x00a0 -#define MDDI_PAD_CAL 0x00a4 - -#ifdef ENABLE_MDDI_MULTI_READ_WRITE -#define MDDI_HOST_MAX_CLIENT_REG_IN_SAME_ADDR 128 -#else -#define MDDI_HOST_MAX_CLIENT_REG_IN_SAME_ADDR 1 -#endif - -extern int32 mddi_client_type; -extern u32 mddi_msg_level; - -/* No longer need to write to clear these registers */ -#define xxxx_mddi_host_reg_outm(reg, mask, val) \ -do { \ - if (host_idx == MDDI_HOST_PRIM) \ - mddi_host_reg_outm_pmdh(reg, mask, val); \ - else \ - mddi_host_reg_outm_emdh(reg, mask, val); \ -} while (0) - -#define mddi_host_reg_outm(reg, mask, val) \ -do { \ - unsigned long __addr; \ - if (host_idx == MDDI_HOST_PRIM) \ - __addr = (u32)msm_pmdh_base + MDDI_##reg; \ - else \ - __addr = (u32)msm_emdh_base + MDDI_##reg; \ - writel((readl(__addr) & ~(mask)) | ((val) & (mask)), __addr); \ -} while (0) - -#define xxxx_mddi_host_reg_out(reg, val) \ -do { \ - if (host_idx == MDDI_HOST_PRIM) \ - mddi_host_reg_out_pmdh(reg, val); \ - else \ - mddi_host_reg_out_emdh(reg, val); \ - } while (0) - -#define mddi_host_reg_out(reg, val) \ -do { \ - if (host_idx == MDDI_HOST_PRIM) \ - writel(val, (u32)msm_pmdh_base + MDDI_##reg); \ - else \ - writel(val, (u32)msm_emdh_base + MDDI_##reg); \ -} while (0) - -#define xxxx_mddi_host_reg_in(reg) \ - ((host_idx) ? \ - mddi_host_reg_in_emdh(reg) : mddi_host_reg_in_pmdh(reg)); - -#define mddi_host_reg_in(reg) \ -((host_idx) ? \ - readl((u32)msm_emdh_base + MDDI_##reg) : \ - readl((u32)msm_pmdh_base + MDDI_##reg)) \ - -#define xxxx_mddi_host_reg_inm(reg, mask) \ - ((host_idx) ? \ - mddi_host_reg_inm_emdh(reg, mask) : \ - mddi_host_reg_inm_pmdh(reg, mask);) - -#define mddi_host_reg_inm(reg, mask) \ -((host_idx) ? \ - readl((u32)msm_emdh_base + MDDI_##reg) & (mask) : \ - readl((u32)msm_pmdh_base + MDDI_##reg) & (mask)) \ - -/* Using non-cacheable pmem, so do nothing */ -#define mddi_invalidate_cache_lines(addr_start, num_bytes) -/* - * Using non-cacheable pmem, so do nothing with cache - * but, ensure write goes out to memory - */ -#define mddi_flush_cache_lines(addr_start, num_bytes) \ - (void) addr_start; \ - (void) num_bytes; \ - memory_barrier() - -/* Since this translates to Remote Procedure Calls to check on clock status -* just use a local variable to keep track of io_clock */ -#define MDDI_HOST_IS_IO_CLOCK_ON mddi_host_io_clock_on -#define MDDI_HOST_ENABLE_IO_CLOCK -#define MDDI_HOST_DISABLE_IO_CLOCK -#define MDDI_HOST_IS_HCLK_ON mddi_host_hclk_on -#define MDDI_HOST_ENABLE_HCLK -#define MDDI_HOST_DISABLE_HCLK -#define FEATURE_MDDI_HOST_IO_CLOCK_CONTROL_DISABLE -#define FEATURE_MDDI_HOST_HCLK_CONTROL_DISABLE - -#define TRAMP_MDDI_HOST_ISR TRAMP_MDDI_PRI_ISR -#define TRAMP_MDDI_HOST_EXT_ISR TRAMP_MDDI_EXT_ISR -#define MDP_LINE_COUNT_BMSK 0x3ff -#define MDP_SYNC_STATUS 0x000c -#define MDP_LINE_COUNT \ -(readl(msm_mdp_base + MDP_SYNC_STATUS) & MDP_LINE_COUNT_BMSK) - -/* MDP sends 256 pixel packets, so lower value hibernates more without -* significantly increasing latency of waiting for next subframe */ -#define MDDI_HOST_BYTES_PER_SUBFRAME 0x3C00 - -#if defined(CONFIG_FB_MSM_MDP31) || defined(CONFIG_FB_MSM_MDP40) -#define MDDI_HOST_TA2_LEN 0x001a -#define MDDI_HOST_REV_RATE_DIV 0x0004 -#else -#define MDDI_HOST_TA2_LEN 0x000c -#define MDDI_HOST_REV_RATE_DIV 0x0002 -#endif - -#define MDDI_MSG_EMERG(msg, ...) \ - if (mddi_msg_level > 0) \ - printk(KERN_EMERG msg, ## __VA_ARGS__); -#define MDDI_MSG_ALERT(msg, ...) \ - if (mddi_msg_level > 1) \ - printk(KERN_ALERT msg, ## __VA_ARGS__); -#define MDDI_MSG_CRIT(msg, ...) \ - if (mddi_msg_level > 2) \ - printk(KERN_CRIT msg, ## __VA_ARGS__); -#define MDDI_MSG_ERR(msg, ...) \ - if (mddi_msg_level > 3) \ - printk(KERN_ERR msg, ## __VA_ARGS__); -#define MDDI_MSG_WARNING(msg, ...) \ - if (mddi_msg_level > 4) \ - printk(KERN_WARNING msg, ## __VA_ARGS__); -#define MDDI_MSG_NOTICE(msg, ...) \ - if (mddi_msg_level > 5) \ - printk(KERN_NOTICE msg, ## __VA_ARGS__); -#define MDDI_MSG_INFO(msg, ...) \ - if (mddi_msg_level > 6) \ - printk(KERN_INFO msg, ## __VA_ARGS__); -#define MDDI_MSG_DEBUG(msg, ...) \ - if (mddi_msg_level > 7) \ - printk(KERN_DEBUG msg, ## __VA_ARGS__); - -#define GCC_PACKED __attribute__((packed)) -typedef struct GCC_PACKED { - uint16 packet_length; - /* total # of bytes in the packet not including - the packet_length field. */ - - uint16 packet_type; - /* A Packet Type of 70 identifies the packet as - a Client status Packet. */ - - uint16 bClient_ID; - /* This field is reserved for future use and shall - be set to zero. */ - -} mddi_rev_packet_type; - -typedef struct GCC_PACKED { - uint16 packet_length; - /* total # of bytes in the packet not including - the packet_length field. */ - - uint16 packet_type; - /* A Packet Type of 70 identifies the packet as - a Client status Packet. */ - - uint16 bClient_ID; - /* This field is reserved for future use and shall - be set to zero. */ - - uint16 reverse_link_request; - /* 16 bit unsigned integer with number of bytes client - needs in the * reverse encapsulation message - to transmit data. */ - - uint8 crc_error_count; - uint8 capability_change; - uint16 graphics_busy_flags; - - uint16 parameter_CRC; - /* 16-bit CRC of all the bytes in the packet - including Packet Length. */ - -} mddi_client_status_type; - -typedef struct GCC_PACKED { - uint16 packet_length; - /* total # of bytes in the packet not including - the packet_length field. */ - - uint16 packet_type; - /* A Packet Type of 66 identifies the packet as - a Client Capability Packet. */ - - uint16 bClient_ID; - /* This field is reserved for future use and - shall be set to zero. */ - - uint16 Protocol_Version; - uint16 Minimum_Protocol_Version; - uint16 Data_Rate_Capability; - uint8 Interface_Type_Capability; - uint8 Number_of_Alt_Displays; - uint16 PostCal_Data_Rate; - uint16 Bitmap_Width; - uint16 Bitmap_Height; - uint16 Display_Window_Width; - uint16 Display_Window_Height; - uint32 Color_Map_Size; - uint16 Color_Map_RGB_Width; - uint16 RGB_Capability; - uint8 Monochrome_Capability; - uint8 Reserved_1; - uint16 Y_Cb_Cr_Capability; - uint16 Bayer_Capability; - uint16 Alpha_Cursor_Image_Planes; - uint32 Client_Feature_Capability_Indicators; - uint8 Maximum_Video_Frame_Rate_Capability; - uint8 Minimum_Video_Frame_Rate_Capability; - uint16 Minimum_Sub_frame_Rate; - uint16 Audio_Buffer_Depth; - uint16 Audio_Channel_Capability; - uint16 Audio_Sample_Rate_Capability; - uint8 Audio_Sample_Resolution; - uint8 Mic_Audio_Sample_Resolution; - uint16 Mic_Sample_Rate_Capability; - uint8 Keyboard_Data_Format; - uint8 pointing_device_data_format; - uint16 content_protection_type; - uint16 Mfr_Name; - uint16 Product_Code; - uint16 Reserved_3; - uint32 Serial_Number; - uint8 Week_of_Manufacture; - uint8 Year_of_Manufacture; - - uint16 parameter_CRC; - /* 16-bit CRC of all the bytes in the packet including Packet Length. */ - -} mddi_client_capability_type; - -typedef struct GCC_PACKED { - uint16 packet_length; - /* total # of bytes in the packet not including the packet_length field. */ - - uint16 packet_type; - /* A Packet Type of 16 identifies the packet as a Video Stream Packet. */ - - uint16 bClient_ID; - /* This field is reserved for future use and shall be set to zero. */ - - uint16 video_data_format_descriptor; - /* format of each pixel in the Pixel Data in the present stream in the - * present packet. - * If bits [15:13] = 000 monochrome - * If bits [15:13] = 001 color pixels (palette). - * If bits [15:13] = 010 color pixels in raw RGB - * If bits [15:13] = 011 data in 4:2:2 Y Cb Cr format - * If bits [15:13] = 100 Bayer pixels - */ - - uint16 pixel_data_attributes; - /* interpreted as follows: - * Bits [1:0] = 11 pixel data is displayed to both eyes - * Bits [1:0] = 10 pixel data is routed to the left eye only. - * Bits [1:0] = 01 pixel data is routed to the right eye only. - * Bits [1:0] = 00 pixel data is routed to the alternate display. - * Bit 2 is 0 Pixel Data is in the standard progressive format. - * Bit 2 is 1 Pixel Data is in interlace format. - * Bit 3 is 0 Pixel Data is in the standard progressive format. - * Bit 3 is 1 Pixel Data is in alternate pixel format. - * Bit 4 is 0 Pixel Data is to or from the display frame buffer. - * Bit 4 is 1 Pixel Data is to or from the camera. - * Bit 5 is 0 pixel data contains the next consecutive row of pixels. - * Bit 5 is 1 X Left Edge, Y Top Edge, X Right Edge, Y Bottom Edge, - * X Start, and Y Start parameters are not defined and - * shall be ignored by the client. - * Bits [7:6] = 01 Pixel data is written to the offline image buffer. - * Bits [7:6] = 00 Pixel data is written to the buffer to refresh display. - * Bits [7:6] = 11 Pixel data is written to all image buffers. - * Bits [7:6] = 10 Invalid. Reserved for future use. - * Bits 8 through 11 alternate display number. - * Bits 12 through 14 are reserved for future use and shall be set to zero. - * Bit 15 is 1 the row of pixels is the last row of pixels in a frame. - */ - - uint16 x_left_edge; - uint16 y_top_edge; - /* X,Y coordinate of the top left edge of the screen window */ - - uint16 x_right_edge; - uint16 y_bottom_edge; - /* X,Y coordinate of the bottom right edge of the window being updated. */ - - uint16 x_start; - uint16 y_start; - /* (X Start, Y Start) is the first pixel in the Pixel Data field below. */ - - uint16 pixel_count; - /* number of pixels in the Pixel Data field below. */ - - uint16 parameter_CRC; - /* 16-bit CRC of all bytes from the Packet Length to the Pixel Count. */ - - uint16 reserved; - /* 16-bit variable to make structure align on 4 byte boundary */ - -} mddi_video_stream_packet_type; - -typedef struct GCC_PACKED { - uint16 packet_length; - /* total # of bytes in the packet not including the packet_length field. */ - - uint16 packet_type; - /* A Packet Type of 146 identifies the packet as a Register Access Packet. */ - - uint16 bClient_ID; - /* This field is reserved for future use and shall be set to zero. */ - - uint16 read_write_info; - /* Bits 13:0 a 14-bit unsigned integer that specifies the number of - * 32-bit Register Data List items to be transferred in the - * Register Data List field. - * Bits[15:14] = 00 Write to register(s); - * Bits[15:14] = 10 Read from register(s); - * Bits[15:14] = 11 Response to a Read. - * Bits[15:14] = 01 this value is reserved for future use. */ - - uint32 register_address; - /* the register address that is to be written to or read from. */ - - uint16 parameter_CRC; - /* 16-bit CRC of all bytes from the Packet Length to the Register Address. */ - - uint32 register_data_list[MDDI_HOST_MAX_CLIENT_REG_IN_SAME_ADDR]; - /* list of 4-byte register data values for/from client registers */ - /* For multi-read/write, 512(128 * 4) bytes of data available */ - -} mddi_register_access_packet_type; - -typedef union GCC_PACKED { - mddi_video_stream_packet_type video_pkt; - mddi_register_access_packet_type register_pkt; -#ifdef ENABLE_MDDI_MULTI_READ_WRITE - /* add 1008 byte pad to ensure 1024 byte llist struct, that can be - * manipulated easily with cache */ - uint32 alignment_pad[252]; /* 1008 bytes */ -#else - /* add 48 byte pad to ensure 64 byte llist struct, that can be - * manipulated easily with cache */ - uint32 alignment_pad[12]; /* 48 bytes */ -#endif -} mddi_packet_header_type; - -typedef struct GCC_PACKED mddi_host_llist_struct { - uint16 link_controller_flags; - uint16 packet_header_count; - uint16 packet_data_count; - void *packet_data_pointer; - struct mddi_host_llist_struct *next_packet_pointer; - uint16 reserved; - mddi_packet_header_type packet_header; -} mddi_linked_list_type; - -typedef struct { - struct completion done_comp; - mddi_llist_done_cb_type done_cb; - uint16 next_idx; - boolean waiting; - boolean in_use; -} mddi_linked_list_notify_type; - -#ifdef ENABLE_MDDI_MULTI_READ_WRITE -#define MDDI_LLIST_POOL_SIZE 0x10000 -#else -#define MDDI_LLIST_POOL_SIZE 0x1000 -#endif -#define MDDI_MAX_NUM_LLIST_ITEMS (MDDI_LLIST_POOL_SIZE / \ - sizeof(mddi_linked_list_type)) -#define UNASSIGNED_INDEX MDDI_MAX_NUM_LLIST_ITEMS -#define MDDI_FIRST_DYNAMIC_LLIST_IDX 0 - -/* Static llist items can be used for applications that frequently send - * the same set of packets using the linked list interface. */ -/* Here we configure for 6 static linked list items: - * The 1st is used for a the adaptive backlight setting. - * and the remaining 5 are used for sending window adjustments for - * MDDI clients that need windowing info sent separate from video - * packets. */ -#define MDDI_NUM_STATIC_ABL_ITEMS 1 -#define MDDI_NUM_STATIC_WINDOW_ITEMS 5 -#define MDDI_NUM_STATIC_LLIST_ITEMS (MDDI_NUM_STATIC_ABL_ITEMS + \ - MDDI_NUM_STATIC_WINDOW_ITEMS) -#define MDDI_NUM_DYNAMIC_LLIST_ITEMS (MDDI_MAX_NUM_LLIST_ITEMS - \ - MDDI_NUM_STATIC_LLIST_ITEMS) - -#define MDDI_FIRST_STATIC_LLIST_IDX MDDI_NUM_DYNAMIC_LLIST_ITEMS -#define MDDI_FIRST_STATIC_ABL_IDX MDDI_FIRST_STATIC_LLIST_IDX -#define MDDI_FIRST_STATIC_WINDOW_IDX (MDDI_FIRST_STATIC_LLIST_IDX + \ - MDDI_NUM_STATIC_ABL_ITEMS) - -/* GPIO registers */ -#define VSYNC_WAKEUP_REG 0x80 -#define GPIO_REG 0x81 -#define GPIO_OUTPUT_REG 0x82 -#define GPIO_INTERRUPT_REG 0x83 -#define GPIO_INTERRUPT_ENABLE_REG 0x84 -#define GPIO_POLARITY_REG 0x85 - -/* Interrupt Bits */ -#define MDDI_INT_PRI_PTR_READ 0x0001 -#define MDDI_INT_SEC_PTR_READ 0x0002 -#define MDDI_INT_REV_DATA_AVAIL 0x0004 -#define MDDI_INT_DISP_REQ 0x0008 -#define MDDI_INT_PRI_UNDERFLOW 0x0010 -#define MDDI_INT_SEC_UNDERFLOW 0x0020 -#define MDDI_INT_REV_OVERFLOW 0x0040 -#define MDDI_INT_CRC_ERROR 0x0080 -#define MDDI_INT_MDDI_IN 0x0100 -#define MDDI_INT_PRI_OVERWRITE 0x0200 -#define MDDI_INT_SEC_OVERWRITE 0x0400 -#define MDDI_INT_REV_OVERWRITE 0x0800 -#define MDDI_INT_DMA_FAILURE 0x1000 -#define MDDI_INT_LINK_ACTIVE 0x2000 -#define MDDI_INT_IN_HIBERNATION 0x4000 -#define MDDI_INT_PRI_LINK_LIST_DONE 0x8000 -#define MDDI_INT_SEC_LINK_LIST_DONE 0x10000 -#define MDDI_INT_NO_CMD_PKTS_PEND 0x20000 -#define MDDI_INT_RTD_FAILURE 0x40000 - -#define MDDI_INT_ERROR_CONDITIONS ( \ - MDDI_INT_PRI_UNDERFLOW | MDDI_INT_SEC_UNDERFLOW | \ - MDDI_INT_REV_OVERFLOW | MDDI_INT_CRC_ERROR | \ - MDDI_INT_PRI_OVERWRITE | MDDI_INT_SEC_OVERWRITE | \ - MDDI_INT_RTD_FAILURE | \ - MDDI_INT_REV_OVERWRITE | MDDI_INT_DMA_FAILURE) - -#define MDDI_INT_LINK_STATE_CHANGES ( \ - MDDI_INT_LINK_ACTIVE | MDDI_INT_IN_HIBERNATION) - -/* Status Bits */ -#define MDDI_STAT_LINK_ACTIVE 0x0001 -#define MDDI_STAT_NEW_REV_PTR 0x0002 -#define MDDI_STAT_NEW_PRI_PTR 0x0004 -#define MDDI_STAT_NEW_SEC_PTR 0x0008 -#define MDDI_STAT_IN_HIBERNATION 0x0010 -#define MDDI_STAT_PRI_LINK_LIST_DONE 0x0020 -#define MDDI_STAT_SEC_LINK_LIST_DONE 0x0040 -#define MDDI_STAT_PENDING_TIMING_PKT 0x0080 -#define MDDI_STAT_PENDING_REV_ENCAP 0x0100 -#define MDDI_STAT_PENDING_POWERDOWN 0x0200 -#define MDDI_STAT_RTD_MEAS_FAIL 0x0800 -#define MDDI_STAT_CLIENT_WAKEUP_REQ 0x1000 - -/* Command Bits */ -#define MDDI_CMD_POWERDOWN 0x0100 -#define MDDI_CMD_POWERUP 0x0200 -#define MDDI_CMD_HIBERNATE 0x0300 -#define MDDI_CMD_RESET 0x0400 -#define MDDI_CMD_DISP_IGNORE 0x0501 -#define MDDI_CMD_DISP_LISTEN 0x0500 -#define MDDI_CMD_SEND_REV_ENCAP 0x0600 -#define MDDI_CMD_GET_CLIENT_CAP 0x0601 -#define MDDI_CMD_GET_CLIENT_STATUS 0x0602 -#define MDDI_CMD_SEND_RTD 0x0700 -#define MDDI_CMD_LINK_ACTIVE 0x0900 -#define MDDI_CMD_PERIODIC_REV_ENCAP 0x0A00 -#define MDDI_CMD_FW_LINK_SKEW_CAL 0x0D00 - -extern void mddi_host_init(mddi_host_type host); -extern void mddi_host_powerdown(mddi_host_type host); -extern uint16 mddi_get_next_free_llist_item(mddi_host_type host, boolean wait); -extern uint16 mddi_get_reg_read_llist_item(mddi_host_type host, boolean wait); -extern void mddi_queue_forward_packets(uint16 first_llist_idx, - uint16 last_llist_idx, - boolean wait, - mddi_llist_done_cb_type llist_done_cb, - mddi_host_type host); - -extern void mddi_host_write_pix_attr_reg(uint32 value); -extern void mddi_client_lcd_gpio_poll(uint32 poll_reg_val); -extern void mddi_client_lcd_vsync_detected(boolean detected); -extern void mddi_host_disable_hibernation(boolean disable); - -extern mddi_linked_list_type *llist_extern[]; -extern mddi_linked_list_type *llist_dma_extern[]; -extern mddi_linked_list_notify_type *llist_extern_notify[]; -extern struct timer_list mddi_host_timer; - -typedef struct { - uint16 transmitting_start_idx; - uint16 transmitting_end_idx; - uint16 waiting_start_idx; - uint16 waiting_end_idx; - uint16 reg_read_idx; - uint16 next_free_idx; - boolean reg_read_waiting; -} mddi_llist_info_type; - -extern mddi_llist_info_type mddi_llist; - -#define MDDI_GPIO_DEFAULT_POLLING_INTERVAL 200 -typedef struct { - uint32 polling_reg; - uint32 polling_val; - uint32 polling_interval; - boolean polling_enabled; -} mddi_gpio_info_type; - -uint32 mddi_get_client_id(void); -void mddi_mhctl_remove(mddi_host_type host_idx); -void mddi_host_timer_service(unsigned long data); -void mddi_host_client_cnt_reset(void); -#endif /* MDDIHOSTI_H */ diff --git a/drivers/video/msm/mdp.c b/drivers/video/msm/mdp.c index e5fa88333e8346524ed08daf259dc7ad6f13873e..ebdf3c62aadfaf99ec0cbececcf3654334577a7d 100644 --- a/drivers/video/msm/mdp.c +++ b/drivers/video/msm/mdp.c @@ -35,12 +35,8 @@ #include #include #include -#include "mdp.h" -#include "msm_fb.h" #ifdef CONFIG_FB_MSM_MDP40 -#include "mdp4.h" #endif -#include "mipi_dsi.h" uint32 mdp4_extn_disp; @@ -108,10 +104,8 @@ struct mdp_dma_data dma_e_data; #else static struct mdp_dma_data dma2_data; static struct mdp_dma_data dma_s_data; -#ifndef CONFIG_FB_MSM_MDP303 static struct mdp_dma_data dma_e_data; #endif -#endif #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL struct mdp_dma_data dma_wb_data; @@ -1324,13 +1318,6 @@ error: } #endif -#ifdef CONFIG_FB_MSM_MDP303 -/* vsync_isr_handler: Called from isr context*/ -static void vsync_isr_handler(void) -{ - vsync_cntrl.vsync_time = ktime_get(); -} -#endif ssize_t mdp_dma_show_event(struct device *dev, struct device_attribute *attr, char *buf) @@ -1588,13 +1575,6 @@ void mdp_pipe_kickoff(uint32 term, struct msm_fb_data_type *mfd) #else outpdw(MDP_BASE + 0x0044, 0x0); /* start DMA */ -#ifdef CONFIG_FB_MSM_MDP303 - -#ifdef CONFIG_FB_MSM_MIPI_DSI - mipi_dsi_cmd_mdp_start(); -#endif - -#endif #endif #endif @@ -2035,25 +2015,12 @@ irqreturn_t mdp_isr(int irq, void *ptr) mdp_dma2_timeval.tv_usec = now.tv_usec - mdp_dma2_timeval.tv_usec; } -#ifndef CONFIG_FB_MSM_MDP303 dma = &dma2_data; spin_lock_irqsave(&mdp_spin_lock, flag); dma->busy = FALSE; spin_unlock_irqrestore(&mdp_spin_lock, flag); mdp_pipe_ctrl(MDP_DMA2_BLOCK, MDP_BLOCK_POWER_OFF, TRUE); complete(&dma->comp); -#else - if (mdp_prim_panel_type == MIPI_CMD_PANEL) { - dma = &dma2_data; - spin_lock_irqsave(&mdp_spin_lock, flag); - dma->busy = FALSE; - spin_unlock_irqrestore(&mdp_spin_lock, flag); - mdp_pipe_ctrl(MDP_DMA2_BLOCK, MDP_BLOCK_POWER_OFF, - TRUE); - mdp_disable_irq_nosync(MDP_DMA2_TERM); - complete(&dma->comp); - } -#endif } /* PPP Complete */ @@ -2117,12 +2084,10 @@ static void mdp_drv_init(void) init_completion(&dma_s_data.comp); sema_init(&dma_s_data.mutex, 1); -#ifndef CONFIG_FB_MSM_MDP303 dma_e_data.busy = FALSE; dma_e_data.waiting = FALSE; init_completion(&dma_e_data.comp); mutex_init(&dma_e_data.ov_mutex); -#endif #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL dma_wb_data.busy = FALSE; dma_wb_data.waiting = FALSE; @@ -2162,14 +2127,6 @@ static void mdp_drv_init(void) msm_fb_debugfs_file_create(mdp_dir, "mdp_current_clk_on", (u32 *) &mdp_current_clk_on); -#ifdef CONFIG_FB_MSM_LCDC - msm_fb_debugfs_file_create(mdp_dir, - "lcdc_start_x", - (u32 *) &first_pixel_start_x); - msm_fb_debugfs_file_create(mdp_dir, - "lcdc_start_y", - (u32 *) &first_pixel_start_y); -#endif } } } @@ -2250,17 +2207,6 @@ static int mdp_off(struct platform_device *pdev) return ret; } -#ifdef CONFIG_FB_MSM_MDP303 -unsigned is_mdp4_hw_reset(void) -{ - return 0; -} -void mdp4_hw_init(void) -{ - /* empty */ -} - -#endif static int mdp_on(struct platform_device *pdev) { int ret = 0; @@ -2827,7 +2773,6 @@ static int mdp_probe(struct platform_device *pdev) #ifdef CONFIG_FB_MSM_MIPI_DSI case MIPI_VIDEO_PANEL: -#ifndef CONFIG_FB_MSM_MDP303 mipi = &mfd->panel_info.mipi; mfd->vsync_init = mdp4_dsi_vsync_init; mfd->vsync_show = mdp4_dsi_video_show_event; @@ -2845,26 +2790,6 @@ static int mdp_probe(struct platform_device *pdev) mfd->dma = &dma_e_data; } mdp4_display_intf_sel(if_no, DSI_VIDEO_INTF); -#else - pdata->on = mdp_dsi_video_on; - pdata->off = mdp_dsi_video_off; - mfd->hw_refresh = TRUE; - mfd->dma_fnc = mdp_dsi_video_update; - mfd->do_histogram = mdp_do_histogram; - mfd->start_histogram = mdp_histogram_start; - mfd->stop_histogram = mdp_histogram_stop; - mfd->vsync_ctrl = mdp_dma_video_vsync_ctrl; - mfd->vsync_show = mdp_dma_video_show_event; - if (mfd->panel_info.pdest == DISPLAY_1) - mfd->dma = &dma2_data; - else { - printk(KERN_ERR "Invalid Selection of destination panel\n"); - rc = -ENODEV; - mdp_clk_ctrl(0); - goto mdp_probe_err; - } - -#endif if (mdp_rev >= MDP_REV_40) mfd->cursor_update = mdp_hw_cursor_sync_update; else @@ -2872,7 +2797,6 @@ static int mdp_probe(struct platform_device *pdev) break; case MIPI_CMD_PANEL: -#ifndef CONFIG_FB_MSM_MDP303 mfd->dma_fnc = mdp4_dsi_cmd_overlay; mipi = &mfd->panel_info.mipi; mfd->vsync_init = mdp4_dsi_rdptr_init; @@ -2889,24 +2813,6 @@ static int mdp_probe(struct platform_device *pdev) mfd->start_histogram = mdp_histogram_start; mfd->stop_histogram = mdp_histogram_stop; mdp4_display_intf_sel(if_no, DSI_CMD_INTF); -#else - mfd->dma_fnc = mdp_dma2_update; - mfd->do_histogram = mdp_do_histogram; - mfd->start_histogram = mdp_histogram_start; - mfd->stop_histogram = mdp_histogram_stop; - mfd->vsync_ctrl = mdp_dma_vsync_ctrl; - mfd->vsync_show = mdp_dma_show_event; - if (mfd->panel_info.pdest == DISPLAY_1) - mfd->dma = &dma2_data; - else { - printk(KERN_ERR "Invalid Selection of destination panel\n"); - rc = -ENODEV; - mdp_clk_ctrl(0); - goto mdp_probe_err; - } - INIT_WORK(&mfd->dma_update_worker, - mdp_lcd_update_workqueue_handler); -#endif mdp_config_vsync(mdp_init_pdev, mfd); break; #endif @@ -2930,10 +2836,6 @@ static int mdp_probe(struct platform_device *pdev) case HDMI_PANEL: case LCDC_PANEL: case LVDS_PANEL: -#ifdef CONFIG_FB_MSM_MDP303 - pdata->on = mdp_lcdc_on; - pdata->off = mdp_lcdc_off; -#endif mfd->hw_refresh = TRUE; #if defined(CONFIG_FB_MSM_OVERLAY) && defined(CONFIG_FB_MSM_MDP40) mfd->cursor_update = mdp_hw_cursor_sync_update; @@ -2974,19 +2876,11 @@ static int mdp_probe(struct platform_device *pdev) break; case TV_PANEL: -#if defined(CONFIG_FB_MSM_OVERLAY) && defined(CONFIG_FB_MSM_TVOUT) - pdata->on = mdp4_atv_on; - pdata->off = mdp4_atv_off; - mfd->dma_fnc = mdp4_atv_overlay; - mfd->dma = &dma_e_data; - mdp4_display_intf_sel(EXTERNAL_INTF_SEL, TV_INTF); -#else pdata->on = mdp_dma3_on; pdata->off = mdp_dma3_off; mfd->hw_refresh = TRUE; mfd->dma_fnc = mdp_dma3_update; mfd->dma = &dma3_data; -#endif break; #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL diff --git a/drivers/video/msm/mdp.h b/drivers/video/msm/mdp.h deleted file mode 100644 index a66ade116887c139ce7c814bf8a2e4bd2e2589c2..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp.h +++ /dev/null @@ -1,943 +0,0 @@ -/* Copyright (c) 2008-2013, 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 MDP_H -#define MDP_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_MSM_BUS_SCALING -#include -#include -#endif - -#include - -#include "msm_fb_panel.h" - -extern uint32 mdp_hw_revision; -extern ulong mdp4_display_intf; -extern spinlock_t mdp_spin_lock; -extern int mdp_rev; -extern int mdp_iommu_split_domain; -extern struct mdp_csc_cfg mdp_csc_convert[4]; -extern struct mdp_csc_cfg_data csc_cfg_matrix[]; -extern struct workqueue_struct *mdp_hist_wq; - -extern uint32 mdp_intr_mask; - -#define MDP4_REVISION_V1 0 -#define MDP4_REVISION_V2 1 -#define MDP4_REVISION_V2_1 2 -#define MDP4_REVISION_NONE 0xffffffff - -#ifdef BIT -#undef BIT -#endif - -#define BIT(x) (1<<(x)) - -#define MDPOP_NOP 0 -#define MDPOP_LR BIT(0) /* left to right flip */ -#define MDPOP_UD BIT(1) /* up and down flip */ -#define MDPOP_ROT90 BIT(2) /* rotate image to 90 degree */ -#define MDPOP_ROT180 (MDPOP_UD|MDPOP_LR) -#define MDPOP_ROT270 (MDPOP_ROT90|MDPOP_UD|MDPOP_LR) -#define MDPOP_ASCALE BIT(7) -#define MDPOP_ALPHAB BIT(8) /* enable alpha blending */ -#define MDPOP_TRANSP BIT(9) /* enable transparency */ -#define MDPOP_DITHER BIT(10) /* enable dither */ -#define MDPOP_SHARPENING BIT(11) /* enable sharpening */ -#define MDPOP_BLUR BIT(12) /* enable blur */ -#define MDPOP_FG_PM_ALPHA BIT(13) -#define MDPOP_LAYER_IS_FG BIT(14) -#define MDP_ALLOC(x) kmalloc(x, GFP_KERNEL) - -struct mdp_buf_type { - struct ion_handle *ihdl; - u32 write_addr; - u32 read_addr; - u32 size; -}; - -struct mdp_table_entry { - uint32_t reg; - uint32_t val; -}; - -extern struct mdp_ccs mdp_ccs_yuv2rgb ; -extern struct mdp_ccs mdp_ccs_rgb2yuv ; -extern unsigned char hdmi_prim_display; -extern unsigned char hdmi_prim_resolution; - -struct vsync { - ktime_t vsync_time; - struct completion vsync_comp; - struct device *dev; - struct work_struct vsync_work; - int vsync_irq_enabled; - int vsync_dma_enabled; - int disabled_clocks; - struct completion vsync_wait; - atomic_t suspend; - atomic_t vsync_resume; - int sysfs_created; -}; - -extern struct vsync vsync_cntrl; - -/* - * MDP Image Structure - */ -typedef struct mdpImg_ { - uint32 imgType; /* Image type */ - uint32 *bmy_addr; /* bitmap or y addr */ - uint32 *cbcr_addr; /* cbcr addr */ - uint32 width; /* image width */ - uint32 mdpOp; /* image opertion (rotation,flip up/down, alpha/tp) */ - uint32 tpVal; /* transparency color */ - uint32 alpha; /* alpha percentage 0%(0x0) ~ 100%(0x100) */ - int sp_value; /* sharpening strength */ -} MDPIMG; - -#define MDP_OUTP(addr, data) outpdw((addr), (data)) - -#define MDP_BASE msm_mdp_base - -typedef enum { - MDP_BC_SCALE_POINT2_POINT4, - MDP_BC_SCALE_POINT4_POINT6, - MDP_BC_SCALE_POINT6_POINT8, - MDP_BC_SCALE_POINT8_1, - MDP_BC_SCALE_UP, - MDP_PR_SCALE_POINT2_POINT4, - MDP_PR_SCALE_POINT4_POINT6, - MDP_PR_SCALE_POINT6_POINT8, - MDP_PR_SCALE_POINT8_1, - MDP_PR_SCALE_UP, - MDP_SCALE_BLUR, - MDP_INIT_SCALE -} MDP_SCALE_MODE; - -typedef enum { - MDP_BLOCK_POWER_OFF, - MDP_BLOCK_POWER_ON -} MDP_BLOCK_POWER_STATE; - -typedef enum { - MDP_CMD_BLOCK, - MDP_OVERLAY0_BLOCK, - MDP_MASTER_BLOCK, - MDP_PPP_BLOCK, - MDP_DMA2_BLOCK, - MDP_DMA3_BLOCK, - MDP_DMA_S_BLOCK, - MDP_DMA_E_BLOCK, - MDP_OVERLAY1_BLOCK, - MDP_OVERLAY2_BLOCK, - MDP_MAX_BLOCK -} MDP_BLOCK_TYPE; - -/* Let's keep Q Factor power of 2 for optimization */ -#define MDP_SCALE_Q_FACTOR 512 - -#ifdef CONFIG_FB_MSM_MDP31 -#define MDP_MAX_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*8) -#define MDP_MIN_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/8) -#define MDP_MAX_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*8) -#define MDP_MIN_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/8) -#else -#define MDP_MAX_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*4) -#define MDP_MIN_X_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/4) -#define MDP_MAX_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR*4) -#define MDP_MIN_Y_SCALE_FACTOR (MDP_SCALE_Q_FACTOR/4) -#endif - -/* SHIM Q Factor */ -#define PHI_Q_FACTOR 29 -#define PQF_PLUS_5 (PHI_Q_FACTOR + 5) /* due to 32 phases */ -#define PQF_PLUS_4 (PHI_Q_FACTOR + 4) -#define PQF_PLUS_2 (PHI_Q_FACTOR + 2) /* to get 4.0 */ -#define PQF_MINUS_2 (PHI_Q_FACTOR - 2) /* to get 0.25 */ -#define PQF_PLUS_5_PLUS_2 (PQF_PLUS_5 + 2) -#define PQF_PLUS_5_MINUS_2 (PQF_PLUS_5 - 2) - -#define MDP_CONVTP(tpVal) (((tpVal&0xF800)<<8)|((tpVal&0x7E0)<<5)|((tpVal&0x1F)<<3)) - -#define MDPOP_ROTATION (MDPOP_ROT90|MDPOP_LR|MDPOP_UD) -#define MDP_CHKBIT(val, bit) ((bit) == ((val) & (bit))) - -/* overlay interface API defines */ -typedef enum { - MORE_IBUF, - FINAL_IBUF, - COMPLETE_IBUF -} MDP_IBUF_STATE; - -struct mdp_dirty_region { - __u32 xoffset; /* source origin in the x-axis */ - __u32 yoffset; /* source origin in the y-axis */ - __u32 width; /* number of pixels in the x-axis */ - __u32 height; /* number of pixels in the y-axis */ -}; - -/* - * MDP extended data types - */ -typedef struct mdp_roi_s { - uint32 x; - uint32 y; - uint32 width; - uint32 height; - int32 lcd_x; - int32 lcd_y; - uint32 dst_width; - uint32 dst_height; -} MDP_ROI; - -typedef struct mdp_ibuf_s { - uint8 *buf; - uint32 bpp; - uint32 ibuf_type; - uint32 ibuf_width; - uint32 ibuf_height; - - MDP_ROI roi; - MDPIMG mdpImg; - - int32 dma_x; - int32 dma_y; - uint32 dma_w; - uint32 dma_h; - - uint32 vsync_enable; -} MDPIBUF; - -struct mdp_dma_data { - boolean busy; - boolean dmap_busy; - boolean waiting; - struct mutex ov_mutex; - struct semaphore mutex; - struct completion comp; - struct completion dmap_comp; -}; - -extern struct list_head mdp_hist_lut_list; -extern struct mutex mdp_hist_lut_list_mutex; -struct mdp_hist_lut_mgmt { - uint32_t block; - struct mutex lock; - struct list_head list; -}; - -struct mdp_hist_lut_info { - uint32_t block; - boolean is_enabled, has_sel_update; - int bank_sel; -}; - -struct mdp_hist_mgmt { - uint32_t block; - uint32_t irq_term; - uint32_t intr; - uint32_t base; - struct completion mdp_hist_comp; - struct mutex mdp_hist_mutex; - struct mutex mdp_do_hist_mutex; - boolean mdp_is_hist_start, mdp_is_hist_data; - boolean mdp_is_hist_valid, mdp_is_hist_init; - uint8_t frame_cnt, bit_mask, num_bins; - struct work_struct mdp_histogram_worker; - struct mdp_histogram_data *hist; - uint32_t *c0, *c1, *c2; - uint32_t *extra_info; -}; - -enum { - MDP_HIST_MGMT_DMA_P = 0, - MDP_HIST_MGMT_DMA_S, - MDP_HIST_MGMT_VG_1, - MDP_HIST_MGMT_VG_2, - MDP_HIST_MGMT_MAX, -}; - -extern struct mdp_hist_mgmt *mdp_hist_mgmt_array[]; - -#define MDP_CMD_DEBUG_ACCESS_BASE (MDP_BASE+0x10000) - -#define MDP_DMA2_TERM 0x1 -#define MDP_DMA3_TERM 0x2 -#define MDP_PPP_TERM 0x4 -#define MDP_DMA_S_TERM 0x8 -#define MDP_DMA_E_TERM 0x10 -#ifdef CONFIG_FB_MSM_MDP40 -#define MDP_OVERLAY0_TERM 0x20 -#define MDP_OVERLAY1_TERM 0x40 -#define MDP_DMAP_TERM MDP_DMA2_TERM /* dmap == dma2 */ -#define MDP_PRIM_VSYNC_TERM 0x100 -#define MDP_EXTER_VSYNC_TERM 0x200 -#define MDP_PRIM_RDPTR_TERM 0x400 -#endif -#define MDP_OVERLAY2_TERM 0x80 -#define MDP_HISTOGRAM_TERM_DMA_P 0x10000 -#define MDP_HISTOGRAM_TERM_DMA_S 0x20000 -#define MDP_HISTOGRAM_TERM_VG_1 0x40000 -#define MDP_HISTOGRAM_TERM_VG_2 0x80000 -#define MDP_VSYNC_TERM 0x1000 - -#define ACTIVE_START_X_EN BIT(31) -#define ACTIVE_START_Y_EN BIT(31) -#define ACTIVE_HIGH 0 -#define ACTIVE_LOW 1 -#define MDP_DMA_S_DONE BIT(2) -#define MDP_DMA_E_DONE BIT(3) -#define LCDC_FRAME_START BIT(15) -#define LCDC_UNDERFLOW BIT(16) - -#ifdef CONFIG_FB_MSM_MDP22 -#define MDP_DMA_P_DONE BIT(2) -#else -#define MDP_DMA_P_DONE BIT(14) -#endif - -#define MDP_PPP_DONE BIT(0) -#define TV_OUT_DMA3_DONE BIT(6) -#define TV_ENC_UNDERRUN BIT(7) -#define MDP_PRIM_RDPTR BIT(8) -#define TV_OUT_DMA3_START BIT(13) -#define MDP_HIST_DONE BIT(20) - -/*MDP4 MDP histogram interrupts*/ -/*note: these are only applicable on MDP4+ targets*/ -#define INTR_VG1_HISTOGRAM BIT(5) -#define INTR_VG2_HISTOGRAM BIT(6) -#define INTR_DMA_P_HISTOGRAM BIT(17) -#define INTR_DMA_S_HISTOGRAM BIT(26) -/*end MDP4 MDP histogram interrupts*/ - -/* histogram interrupts */ -#define INTR_HIST_DONE BIT(1) -#define INTR_HIST_RESET_SEQ_DONE BIT(0) - -#ifdef CONFIG_FB_MSM_MDP22 -#define MDP_ANY_INTR_MASK (MDP_PPP_DONE| \ - MDP_DMA_P_DONE| \ - TV_ENC_UNDERRUN) -#else -#define MDP_ANY_INTR_MASK (MDP_PPP_DONE| \ - MDP_DMA_P_DONE| \ - MDP_DMA_S_DONE| \ - MDP_DMA_E_DONE| \ - LCDC_UNDERFLOW| \ - TV_ENC_UNDERRUN) -#endif - -#define MDP_TOP_LUMA 16 -#define MDP_TOP_CHROMA 0 -#define MDP_BOTTOM_LUMA 19 -#define MDP_BOTTOM_CHROMA 3 -#define MDP_LEFT_LUMA 22 -#define MDP_LEFT_CHROMA 6 -#define MDP_RIGHT_LUMA 25 -#define MDP_RIGHT_CHROMA 9 - -#define CLR_G 0x0 -#define CLR_B 0x1 -#define CLR_R 0x2 -#define CLR_ALPHA 0x3 - -#define CLR_Y CLR_G -#define CLR_CB CLR_B -#define CLR_CR CLR_R - -/* from lsb to msb */ -#define MDP_GET_PACK_PATTERN(a,x,y,z,bit) (((a)<<(bit*3))|((x)<<(bit*2))|((y)< -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "mdp4.h" - -static int dtv_probe(struct platform_device *pdev); -static int dtv_remove(struct platform_device *pdev); - -static int dtv_off(struct platform_device *pdev); -static int dtv_on(struct platform_device *pdev); -static int dtv_off_sub(void); - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; - -static struct clk *tv_src_clk; -static struct clk *hdmi_clk; -static struct clk *mdp_tv_clk; -static struct platform_device *dtv_pdev; -static struct workqueue_struct *dtv_work_queue; -static struct work_struct dtv_off_work; - - -static int mdp4_dtv_runtime_suspend(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: suspending...\n"); - return 0; -} - -static int mdp4_dtv_runtime_resume(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: resuming...\n"); - return 0; -} - -static const struct dev_pm_ops mdp4_dtv_dev_pm_ops = { - .runtime_suspend = mdp4_dtv_runtime_suspend, - .runtime_resume = mdp4_dtv_runtime_resume, -}; - -static struct platform_driver dtv_driver = { - .probe = dtv_probe, - .remove = dtv_remove, - .suspend = NULL, - .resume = NULL, - .shutdown = NULL, - .driver = { - .name = "dtv", - .pm = &mdp4_dtv_dev_pm_ops, - }, -}; - -static struct lcdc_platform_data *dtv_pdata; -#ifdef CONFIG_MSM_BUS_SCALING -static uint32_t dtv_bus_scale_handle; -#else -static struct clk *ebi1_clk; -#endif - -static int dtv_off(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd = NULL; - - if (!pdev) { - pr_err("%s: FAILED: invalid arg\n", __func__); - return -EINVAL; - } - - mfd = platform_get_drvdata(pdev); - if (!mfd) { - pr_err("%s: FAILED: invalid mfd\n", __func__); - return -EINVAL; - } - - dtv_pdev = pdev; - /* - * If it's a suspend operation then handle the device - * power down synchronously. - * Otherwise, queue work item to handle power down sequence. - * This is needed since we need to wait for the audio engine - * to shutdown first before we turn off the DTV device. - */ - if (!mfd->suspend.op_suspend) { - pr_debug("%s: Queuing work to turn off HDMI core\n", __func__); - queue_work(dtv_work_queue, &dtv_off_work); - } else { - pr_debug("%s: turning off HDMI core\n", __func__); - ret = dtv_off_sub(); - } - - return ret; -} - -static int dtv_off_sub(void) -{ - int ret = 0; - - if (!dtv_pdev) { - pr_err("%s: FAILED: invalid arg\n", __func__); - return -EINVAL; - } - - ret = panel_next_off(dtv_pdev); - - pr_info("%s\n", __func__); - - clk_disable_unprepare(hdmi_clk); - if (mdp_tv_clk) - clk_disable_unprepare(mdp_tv_clk); - - if (dtv_pdata && dtv_pdata->lcdc_power_save) - dtv_pdata->lcdc_power_save(0); - - if (dtv_pdata && dtv_pdata->lcdc_gpio_config) - ret = dtv_pdata->lcdc_gpio_config(0); -#ifdef CONFIG_MSM_BUS_SCALING - if (dtv_bus_scale_handle > 0) - msm_bus_scale_client_update_request(dtv_bus_scale_handle, - 0); -#else - if (ebi1_clk) - clk_disable_unprepare(ebi1_clk); -#endif - mdp4_extn_disp = 0; - return ret; -} - -static void dtv_off_work_func(struct work_struct *work) -{ - dtv_off_sub(); -} - -static int dtv_on(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd; - unsigned long panel_pixclock_freq , pm_qos_rate; - - /* If a power down is already underway, wait for it to finish */ - flush_work_sync(&dtv_off_work); - - mfd = platform_get_drvdata(pdev); - panel_pixclock_freq = mfd->fbi->var.pixclock; - - if (panel_pixclock_freq > 58000000) - /* pm_qos_rate should be in Khz */ - pm_qos_rate = panel_pixclock_freq / 1000 ; - else - pm_qos_rate = 58000; - mdp4_extn_disp = 1; -#ifdef CONFIG_MSM_BUS_SCALING - if (dtv_bus_scale_handle > 0) - msm_bus_scale_client_update_request(dtv_bus_scale_handle, - 1); -#else - if (ebi1_clk) { - clk_set_rate(ebi1_clk, pm_qos_rate * 1000); - clk_prepare_enable(ebi1_clk); - } -#endif - - if (dtv_pdata && dtv_pdata->lcdc_power_save) - dtv_pdata->lcdc_power_save(1); - if (dtv_pdata && dtv_pdata->lcdc_gpio_config) - ret = dtv_pdata->lcdc_gpio_config(1); - - mfd = platform_get_drvdata(pdev); - - ret = clk_set_rate(tv_src_clk, mfd->fbi->var.pixclock); - if (ret) { - pr_info("%s: clk_set_rate(%d) failed\n", __func__, - mfd->fbi->var.pixclock); - if (mfd->fbi->var.pixclock == 27030000) - mfd->fbi->var.pixclock = 27000000; - ret = clk_set_rate(tv_src_clk, mfd->fbi->var.pixclock); - } - pr_info("%s: tv_src_clk=%dkHz, pm_qos_rate=%ldkHz, [%d]\n", __func__, - mfd->fbi->var.pixclock/1000, pm_qos_rate, ret); - mfd->panel_info.clk_rate = mfd->fbi->var.pixclock; - clk_prepare_enable(hdmi_clk); - clk_reset(hdmi_clk, CLK_RESET_ASSERT); - udelay(20); - clk_reset(hdmi_clk, CLK_RESET_DEASSERT); - - if (mdp_tv_clk) - clk_prepare_enable(mdp_tv_clk); - - ret = panel_next_on(pdev); - return ret; -} - -static int dtv_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct fb_info *fbi; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc; - - if (pdev->id == 0) { - dtv_pdata = pdev->dev.platform_data; -#ifdef CONFIG_MSM_BUS_SCALING - if (!dtv_bus_scale_handle && dtv_pdata && - dtv_pdata->bus_scale_table) { - dtv_bus_scale_handle = - msm_bus_scale_register_client( - dtv_pdata->bus_scale_table); - if (!dtv_bus_scale_handle) { - pr_err("%s not able to get bus scale\n", - __func__); - } - } -#else - ebi1_clk = clk_get(&pdev->dev, "mem_clk"); - if (IS_ERR(ebi1_clk)) { - ebi1_clk = NULL; - pr_warning("%s: Couldn't get ebi1 clock\n", __func__); - } -#endif - tv_src_clk = clk_get(&pdev->dev, "src_clk"); - if (IS_ERR(tv_src_clk)) { - pr_err("error: can't get tv_src_clk!\n"); - return IS_ERR(tv_src_clk); - } - - hdmi_clk = clk_get(&pdev->dev, "hdmi_clk"); - if (IS_ERR(hdmi_clk)) { - pr_err("error: can't get hdmi_clk!\n"); - return IS_ERR(hdmi_clk); - } - - mdp_tv_clk = clk_get(&pdev->dev, "mdp_clk"); - if (IS_ERR(mdp_tv_clk)) - mdp_tv_clk = NULL; - - return 0; - } - - dtv_work_queue = create_singlethread_workqueue("dtv_work"); - INIT_WORK(&dtv_off_work, dtv_off_work_func); - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - - /* - * link to the latest pdev - */ - mfd->pdev = mdp_dev; - mfd->dest = DISPLAY_LCDC; - - /* - * alloc panel device data - */ - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - pr_err("dtv_probe: platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - /* - * data chain - */ - pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; - pdata->on = dtv_on; - pdata->off = dtv_off; - pdata->next = pdev; - - /* - * get/set panel specific fb info - */ - mfd->panel_info = pdata->panel_info; - if (hdmi_prim_display) - mfd->fb_imgType = MSMFB_DEFAULT_TYPE; - else - mfd->fb_imgType = MDP_RGB_565; - - fbi = mfd->fbi; - fbi->var.pixclock = mfd->panel_info.clk_rate; - fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; - fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; - fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; - fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; - fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; - fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; - - /* - * set driver data - */ - platform_set_drvdata(mdp_dev, mfd); - - /* - * register in mdp driver - */ - rc = platform_device_add(mdp_dev); - if (rc) - goto dtv_probe_err; - - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - - pdev_list[pdev_list_cnt++] = pdev; - return 0; - -dtv_probe_err: -#ifdef CONFIG_MSM_BUS_SCALING - if (dtv_pdata && dtv_pdata->bus_scale_table && - dtv_bus_scale_handle > 0) - msm_bus_scale_unregister_client(dtv_bus_scale_handle); -#endif - platform_device_put(mdp_dev); - return rc; -} - -static int dtv_remove(struct platform_device *pdev) -{ - if (dtv_work_queue) - destroy_workqueue(dtv_work_queue); -#ifdef CONFIG_MSM_BUS_SCALING - if (dtv_pdata && dtv_pdata->bus_scale_table && - dtv_bus_scale_handle > 0) - msm_bus_scale_unregister_client(dtv_bus_scale_handle); -#else - if (ebi1_clk) - clk_put(ebi1_clk); -#endif - pm_runtime_disable(&pdev->dev); - return 0; -} - -static int dtv_register_driver(void) -{ - return platform_driver_register(&dtv_driver); -} - -static int __init dtv_driver_init(void) -{ - return dtv_register_driver(); -} - -module_init(dtv_driver_init); diff --git a/drivers/video/msm/mdp4_overlay.c b/drivers/video/msm/mdp4_overlay.c deleted file mode 100644 index 3101a95c91be9121c77f2ca97f62917e639e50b6..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay.c +++ /dev/null @@ -1,3989 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" - -#define VERSION_KEY_MASK 0xFFFFFF00 - -struct mdp4_overlay_ctrl { - struct mdp4_overlay_pipe plist[OVERLAY_PIPE_MAX]; - struct mdp4_overlay_pipe *stage[MDP4_MIXER_MAX][MDP4_MIXER_STAGE_MAX]; - struct mdp4_overlay_pipe *baselayer[MDP4_MIXER_MAX]; - struct blend_cfg blend[MDP4_MIXER_MAX][MDP4_MIXER_STAGE_MAX]; - struct mdp4_overlay_pipe sf_plist[MDP4_MIXER_MAX][OVERLAY_PIPE_MAX]; - struct mdp_mixer_cfg mdp_mixer_cfg[MDP4_MIXER_MAX]; - uint32 mixer_cfg[MDP4_MIXER_MAX]; - uint32 flush[MDP4_MIXER_MAX]; - struct iommu_free_list iommu_free[MDP4_MIXER_MAX]; - uint32 cs_controller; - uint32 panel_3d; - uint32 panel_mode; - uint32 mixer0_played; - uint32 mixer1_played; - uint32 mixer2_played; -} mdp4_overlay_db = { - .cs_controller = CS_CONTROLLER_0, - .plist = { - { - .pipe_type = OVERLAY_TYPE_RGB, - .pipe_num = OVERLAY_PIPE_RGB1, - .pipe_ndx = 1, - }, - { - .pipe_type = OVERLAY_TYPE_RGB, - .pipe_num = OVERLAY_PIPE_RGB2, - .pipe_ndx = 2, - }, - { - .pipe_type = OVERLAY_TYPE_VIDEO, - .pipe_num = OVERLAY_PIPE_VG1, - .pipe_ndx = 3, - }, - { - .pipe_type = OVERLAY_TYPE_VIDEO, - .pipe_num = OVERLAY_PIPE_VG2, - .pipe_ndx = 4, - }, - { - .pipe_type = OVERLAY_TYPE_BF, - .pipe_num = OVERLAY_PIPE_RGB3, - .pipe_ndx = 5, - .mixer_num = MDP4_MIXER0, - }, - { - .pipe_type = OVERLAY_TYPE_BF, - .pipe_num = OVERLAY_PIPE_VG3, - .pipe_ndx = 6, - .mixer_num = MDP4_MIXER1, - }, - { - .pipe_type = OVERLAY_TYPE_BF, - .pipe_num = OVERLAY_PIPE_VG4, - .pipe_ndx = 7, - .mixer_num = MDP4_MIXER2, - }, - }, -}; - -static DEFINE_MUTEX(iommu_mutex); -static struct mdp4_overlay_ctrl *ctrl = &mdp4_overlay_db; - -struct mdp4_overlay_perf { - u32 mdp_clk_rate; - u32 use_ov_blt[MDP4_MIXER_MAX]; - u64 mdp_ov_ab_bw[MDP4_MIXER_MAX]; - u64 mdp_ov_ib_bw[MDP4_MIXER_MAX]; - u32 mdp_ab_bw; - u32 mdp_ib_bw; -}; - -struct mdp4_overlay_perf perf_request; -struct mdp4_overlay_perf perf_current; - -static struct ion_client *display_iclient; - -static void mdp4_overlay_bg_solidfill(struct blend_cfg *blend); - -/* - * mdp4_overlay_iommu_unmap_freelist() - * mdp4_overlay_iommu_2freelist() - * mdp4_overlay_iommu_pipe_free() - * above three functiosns need to be called from same thread and - * in order so that no mutex are needed. - */ -void mdp4_overlay_iommu_unmap_freelist(int mixer) -{ - int i; - struct ion_handle *ihdl; - struct iommu_free_list *flist; - - mutex_lock(&iommu_mutex); - flist = &ctrl->iommu_free[mixer]; - if (flist->total == 0) { - mutex_unlock(&iommu_mutex); - return; - } - for (i = 0; i < IOMMU_FREE_LIST_MAX; i++) { - ihdl = flist->ihdl[i]; - if (ihdl == NULL) - continue; - pr_debug("%s: mixer=%d i=%d ihdl=0x%p\n", __func__, - mixer, i, ihdl); - ion_unmap_iommu(display_iclient, ihdl, DISPLAY_READ_DOMAIN, - GEN_POOL); - mdp4_stat.iommu_unmap++; - pr_debug("%s: map=%d unmap=%d drop=%d\n", __func__, - (int)mdp4_stat.iommu_map, (int)mdp4_stat.iommu_unmap, - (int)mdp4_stat.iommu_drop); - ion_free(display_iclient, ihdl); - flist->ihdl[i] = NULL; - } - - flist->fndx = 0; - flist->total = 0; - mutex_unlock(&iommu_mutex); -} - -void mdp4_overlay_iommu_2freelist(int mixer, struct ion_handle *ihdl) -{ - struct iommu_free_list *flist; - - flist = &ctrl->iommu_free[mixer]; - if (flist->fndx >= IOMMU_FREE_LIST_MAX) { - pr_err("%s: Error, mixer=%d iommu fndx=%d\n", - __func__, mixer, flist->fndx); - mdp4_stat.iommu_drop++; - return; - } - - pr_debug("%s: add mixer=%d fndx=%d ihdl=0x%p\n", __func__, - mixer, flist->fndx, ihdl); - - flist->total++; - flist->ihdl[flist->fndx++] = ihdl; -} - -void mdp4_overlay_iommu_pipe_free(int ndx, int all) -{ - struct mdp4_overlay_pipe *pipe; - struct mdp4_iommu_pipe_info *iom; - int plane, mixer; - - pipe = mdp4_overlay_ndx2pipe(ndx); - if (pipe == NULL) - return; - - if (pipe->flags & MDP_MEMORY_ID_TYPE_FB) { - pipe->flags &= ~MDP_MEMORY_ID_TYPE_FB; - if (pipe->put0_need) { - fput_light(pipe->srcp0_file, pipe->put0_need); - pipe->put0_need = 0; - } - if (pipe->put1_need) { - fput_light(pipe->srcp1_file, pipe->put1_need); - pipe->put1_need = 0; - } - if (pipe->put2_need) { - fput_light(pipe->srcp2_file, pipe->put2_need); - pipe->put2_need = 0; - } - - pr_debug("%s: ndx=%d flags=%x put=%d\n", __func__, - pipe->pipe_ndx, pipe->flags, pipe->put0_need); - return; - } - - mutex_lock(&iommu_mutex); - mixer = pipe->mixer_num; - iom = &pipe->iommu; - pr_debug("%s: mixer=%d ndx=%d all=%d\n", __func__, - mixer, pipe->pipe_ndx, all); - for (plane = 0; plane < MDP4_MAX_PLANE; plane++) { - if (iom->prev_ihdl[plane]) { - mdp4_overlay_iommu_2freelist(mixer, - iom->prev_ihdl[plane]); - iom->prev_ihdl[plane] = NULL; - } - if (all && iom->ihdl[plane]) { - mdp4_overlay_iommu_2freelist(mixer, iom->ihdl[plane]); - iom->ihdl[plane] = NULL; - } - } - mutex_unlock(&iommu_mutex); -} - -int mdp4_overlay_iommu_map_buf(int mem_id, - struct mdp4_overlay_pipe *pipe, unsigned int plane, - unsigned long *start, unsigned long *len, - struct ion_handle **srcp_ihdl) -{ - struct mdp4_iommu_pipe_info *iom; - - if (!display_iclient) - return -EINVAL; - - *srcp_ihdl = ion_import_dma_buf(display_iclient, mem_id); - if (IS_ERR_OR_NULL(*srcp_ihdl)) { - pr_err("ion_import_dma_buf() failed\n"); - return PTR_ERR(*srcp_ihdl); - } - pr_debug("%s(): ion_hdl %p, ion_buf %d\n", __func__, *srcp_ihdl, - mem_id); - pr_debug("mixer %u, pipe %u, plane %u\n", pipe->mixer_num, - pipe->pipe_ndx, plane); - if (ion_map_iommu(display_iclient, *srcp_ihdl, - DISPLAY_READ_DOMAIN, GEN_POOL, SZ_4K, 0, - (dma_addr_t *)start, - len, 0, 0)) { - ion_free(display_iclient, *srcp_ihdl); - pr_err("ion_map_iommu() failed\n"); - return -EINVAL; - } - - mutex_lock(&iommu_mutex); - iom = &pipe->iommu; - if (iom->prev_ihdl[plane]) { - mdp4_overlay_iommu_2freelist(pipe->mixer_num, - iom->prev_ihdl[plane]); - mdp4_stat.iommu_drop++; - pr_err("%s: dropped, ndx=%d plane=%d\n", __func__, - pipe->pipe_ndx, plane); - } - iom->prev_ihdl[plane] = iom->ihdl[plane]; - iom->ihdl[plane] = *srcp_ihdl; - mdp4_stat.iommu_map++; - - pr_debug("%s: ndx=%d plane=%d prev=0x%p cur=0x%p start=0x%lx len=%lx\n", - __func__, pipe->pipe_ndx, plane, iom->prev_ihdl[plane], - iom->ihdl[plane], *start, *len); - mutex_unlock(&iommu_mutex); - return 0; -} - -static struct mdp4_iommu_pipe_info mdp_iommu[MDP4_MIXER_MAX][OVERLAY_PIPE_MAX]; - -void mdp4_iommu_unmap(struct mdp4_overlay_pipe *pipe) -{ - struct mdp4_iommu_pipe_info *iom_pipe_info; - unsigned char i, j; - - if (!display_iclient) - return; - - for (j = 0; j < OVERLAY_PIPE_MAX; j++) { - iom_pipe_info = &mdp_iommu[pipe->mixer_num][j]; - for (i = 0; i < MDP4_MAX_PLANE; i++) { - if (iom_pipe_info->prev_ihdl[i]) { - pr_debug("%s(): mixer %u, pipe %u, plane %u, " - "prev_ihdl %p\n", __func__, - pipe->mixer_num, j + 1, i, - iom_pipe_info->prev_ihdl[i]); - ion_unmap_iommu(display_iclient, - iom_pipe_info->prev_ihdl[i], - DISPLAY_READ_DOMAIN, GEN_POOL); - ion_free(display_iclient, - iom_pipe_info->prev_ihdl[i]); - iom_pipe_info->prev_ihdl[i] = NULL; - } - - if (iom_pipe_info->mark_unmap) { - if (iom_pipe_info->ihdl[i]) { - pr_debug("%s(): MARK, mixer %u, pipe %u, plane %u, " - "ihdl %p\n", __func__, - pipe->mixer_num, j + 1, i, - iom_pipe_info->ihdl[i]); - ion_unmap_iommu(display_iclient, - iom_pipe_info->ihdl[i], - DISPLAY_READ_DOMAIN, GEN_POOL); - ion_free(display_iclient, - iom_pipe_info->ihdl[i]); - iom_pipe_info->ihdl[i] = NULL; - } - } - } - iom_pipe_info->mark_unmap = 0; - } -} - -int mdp4_overlay_mixer_play(int mixer_num) -{ - if (mixer_num == MDP4_MIXER2) - return ctrl->mixer2_played; - else if (mixer_num == MDP4_MIXER1) - return ctrl->mixer1_played; - else - return ctrl->mixer0_played; -} - -void mdp4_overlay_panel_3d(int mixer_num, uint32 panel_3d) -{ - ctrl->panel_3d = panel_3d; -} - -void mdp4_overlay_panel_mode(int mixer_num, uint32 mode) -{ - ctrl->panel_mode |= mode; -} - -void mdp4_overlay_panel_mode_unset(int mixer_num, uint32 mode) -{ - ctrl->panel_mode &= ~mode; -} - -uint32 mdp4_overlay_panel_list(void) -{ - return ctrl->panel_mode; -} - -int mdp4_overlay_borderfill_supported(void) -{ - return (mdp_rev >= MDP_REV_42); -} - -void mdp4_overlay_dmae_cfg(struct msm_fb_data_type *mfd, int atv) -{ - uint32 dmae_cfg_reg; - - if (atv) - dmae_cfg_reg = DMA_DEFLKR_EN; - else - dmae_cfg_reg = 0; - - if (mfd->fb_imgType == MDP_BGR_565) - dmae_cfg_reg |= DMA_PACK_PATTERN_BGR; - else - dmae_cfg_reg |= DMA_PACK_PATTERN_RGB; - - - if (mfd->panel_info.bpp == 18) { - dmae_cfg_reg |= DMA_DSTC0G_6BITS | /* 666 18BPP */ - DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - } else if (mfd->panel_info.bpp == 16) { - dmae_cfg_reg |= DMA_DSTC0G_6BITS | /* 565 16BPP */ - DMA_DSTC1B_5BITS | DMA_DSTC2R_5BITS; - } else { - dmae_cfg_reg |= DMA_DSTC0G_8BITS | /* 888 16BPP */ - DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS; - } - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* dma2 config register */ - MDP_OUTP(MDP_BASE + 0xb0000, dmae_cfg_reg); - if (atv) { - MDP_OUTP(MDP_BASE + 0xb0070, 0xeb0010); - MDP_OUTP(MDP_BASE + 0xb0074, 0xf00010); - MDP_OUTP(MDP_BASE + 0xb0078, 0xf00010); - MDP_OUTP(MDP_BASE + 0xb3000, 0x80); - MDP_OUTP(MDP_BASE + 0xb3010, 0x1800040); - MDP_OUTP(MDP_BASE + 0xb3014, 0x1000080); - MDP_OUTP(MDP_BASE + 0xb4004, 0x67686970); - } else { - mdp_vid_quant_set(); - } - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -void fill_black_screen(bool on, uint8 pipe_num, uint8 mixer_num) -{ - uint32 reg_base = 0x010000; - uint32 const_color_reg = reg_base * (pipe_num + 2) + 0x1008; - uint32 src_fmt_reg = reg_base * (pipe_num + 2) + 0x50; - uint32 color = 0x00000000; - uint32 temp_src_format = 0x00000000; - uint8 bit = pipe_num + 2; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* Fill constant color */ - MDP_OUTP(MDP_BASE + const_color_reg, color); - - /* Update source format for pipe */ - temp_src_format = inpdw(MDP_BASE + src_fmt_reg); - - if (on) - MDP_OUTP(MDP_BASE + src_fmt_reg, temp_src_format | BIT(22)); - else - MDP_OUTP(MDP_BASE + src_fmt_reg, temp_src_format | (~BIT(22))); - - /* MDP_OVERLAY_REG_FLUSH for pipe*/ - MDP_OUTP(MDP_BASE + 0x18000, BIT(bit) | BIT(mixer_num)); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return; -} - -void mdp4_overlay_dmae_xy(struct mdp4_overlay_pipe *pipe) -{ - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - MDP_OUTP(MDP_BASE + 0xb0004, - (pipe->src_height << 16 | pipe->src_width)); - if (pipe->dma_blt_addr) { - uint32 off, bpp; -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - MDP_OUTP(MDP_BASE + 0xb0008, pipe->dma_blt_addr + off); - /* RGB888, output of overlay blending */ - MDP_OUTP(MDP_BASE + 0xb000c, pipe->src_width * bpp); - } else { - /* dma_e source */ - MDP_OUTP(MDP_BASE + 0xb0008, pipe->srcp0_addr); - MDP_OUTP(MDP_BASE + 0xb000c, pipe->srcp0_ystride); - } - /* dma_e dest */ - MDP_OUTP(MDP_BASE + 0xb0010, (pipe->dst_y << 16 | pipe->dst_x)); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -void mdp4_overlay_dmap_cfg(struct msm_fb_data_type *mfd, int lcdc) -{ - uint32 dma2_cfg_reg; - uint32 mask, curr; - - dma2_cfg_reg = DMA_DITHER_EN; -#ifdef BLT_RGB565 - /* RGB888 is 0 */ - dma2_cfg_reg |= DMA_BUF_FORMAT_RGB565; /* blt only */ -#endif - - if (mfd->fb_imgType == MDP_BGR_565) - dma2_cfg_reg |= DMA_PACK_PATTERN_BGR; - else - dma2_cfg_reg |= DMA_PACK_PATTERN_RGB; - - - if ((mfd->panel_info.type == MIPI_CMD_PANEL) || - (mfd->panel_info.type == MIPI_VIDEO_PANEL)) { - dma2_cfg_reg |= DMA_DSTC0G_8BITS | /* 888 24BPP */ - DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS; - } else if (mfd->panel_info.bpp == 18) { - dma2_cfg_reg |= DMA_DSTC0G_6BITS | /* 666 18BPP */ - DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - } else if (mfd->panel_info.bpp == 16) { - dma2_cfg_reg |= DMA_DSTC0G_6BITS | /* 565 16BPP */ - DMA_DSTC1B_5BITS | DMA_DSTC2R_5BITS; - } else { - dma2_cfg_reg |= DMA_DSTC0G_8BITS | /* 888 24BPP */ - DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS; - } - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - -#ifndef CONFIG_FB_MSM_LCDC_CHIMEI_WXGA_PANEL - if (lcdc) - dma2_cfg_reg |= DMA_PACK_ALIGN_MSB; -#endif - - /* dma2 config register */ - curr = inpdw(MDP_BASE + 0x90000); - mask = 0x0FFFFFFF; - dma2_cfg_reg = (dma2_cfg_reg & mask) | (curr & ~mask); - MDP_OUTP(MDP_BASE + 0x90000, dma2_cfg_reg); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -/* - * mdp4_overlay_dmap_xy: called form baselayer only - */ -void mdp4_overlay_dmap_xy(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, bpp; - - if (!in_interrupt()) - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - if (pipe->dma_blt_addr) { -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->dmap_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - MDP_OUTP(MDP_BASE + 0x90008, pipe->dma_blt_addr + off); - /* RGB888, output of overlay blending */ - MDP_OUTP(MDP_BASE + 0x9000c, pipe->src_width * bpp); - } else { - MDP_OUTP(MDP_BASE + 0x90008, pipe->srcp0_addr); - MDP_OUTP(MDP_BASE + 0x9000c, pipe->srcp0_ystride); - } - /* dma_p source */ - MDP_OUTP(MDP_BASE + 0x90004, - (pipe->src_height << 16 | pipe->src_width)); - - /* dma_p dest */ - MDP_OUTP(MDP_BASE + 0x90010, (pipe->dst_y << 16 | pipe->dst_x)); - - if (!in_interrupt()) - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -#define MDP4_VG_PHASE_STEP_DEFAULT 0x20000000 -#define MDP4_VG_PHASE_STEP_SHIFT 29 - -static int mdp4_leading_0(uint32 num) -{ - uint32 bit = 0x80000000; - int i; - - for (i = 0; i < 32; i++) { - if (bit & num) - return i; - bit >>= 1; - } - - return i; -} - -static uint32 mdp4_scale_phase_step(int f_num, uint32 src, uint32 dst) -{ - uint32 val, s; - int n; - - n = mdp4_leading_0(src); - if (n > f_num) - n = f_num; - s = src << n; /* maximum to reduce lose of resolution */ - val = s / dst; - if (n < f_num) { - n = f_num - n; - val <<= n; - val |= ((s % dst) << n) / dst; - } - - return val; -} - -static void mdp4_scale_setup(struct mdp4_overlay_pipe *pipe) -{ - pipe->phasex_step = MDP4_VG_PHASE_STEP_DEFAULT; - pipe->phasey_step = MDP4_VG_PHASE_STEP_DEFAULT; - - if (pipe->dst_h && pipe->src_h != pipe->dst_h) { - u32 upscale_max; - upscale_max = (mdp_rev >= MDP_REV_41) ? - MDP4_REV41_OR_LATER_UP_SCALING_MAX : - MDP4_REV40_UP_SCALING_MAX; - if (pipe->dst_h > pipe->src_h * upscale_max) - return; - - pipe->op_mode |= MDP4_OP_SCALEY_EN; - - if (pipe->pipe_type == OVERLAY_TYPE_VIDEO) { - if (pipe->flags & MDP_BACKEND_COMPOSITION && - pipe->alpha_enable && pipe->dst_h > pipe->src_h) - pipe->op_mode |= MDP4_OP_SCALEY_PIXEL_RPT; - else if (pipe->dst_h <= (pipe->src_h / 4)) - pipe->op_mode |= MDP4_OP_SCALEY_MN_PHASE; - else - pipe->op_mode |= MDP4_OP_SCALEY_FIR; - } else { /* RGB pipe */ - pipe->op_mode |= MDP4_OP_SCALE_RGB_ENHANCED | - MDP4_OP_SCALE_RGB_BILINEAR | - MDP4_OP_SCALE_ALPHA_BILINEAR; - } - - pipe->phasey_step = mdp4_scale_phase_step(29, - pipe->src_h, pipe->dst_h); - } - - if (pipe->dst_w && pipe->src_w != pipe->dst_w) { - u32 upscale_max; - upscale_max = (mdp_rev >= MDP_REV_41) ? - MDP4_REV41_OR_LATER_UP_SCALING_MAX : - MDP4_REV40_UP_SCALING_MAX; - - if (pipe->dst_w > pipe->src_w * upscale_max) - return; - pipe->op_mode |= MDP4_OP_SCALEX_EN; - if (pipe->pipe_type == OVERLAY_TYPE_VIDEO) { - if (pipe->flags & MDP_BACKEND_COMPOSITION && - pipe->alpha_enable && pipe->dst_w > pipe->src_w) - pipe->op_mode |= MDP4_OP_SCALEX_PIXEL_RPT; - else if (pipe->dst_w <= (pipe->src_w / 4)) - pipe->op_mode |= MDP4_OP_SCALEX_MN_PHASE; - else - pipe->op_mode |= MDP4_OP_SCALEX_FIR; - } else { /* RGB pipe */ - pipe->op_mode |= MDP4_OP_SCALE_RGB_ENHANCED | - MDP4_OP_SCALE_RGB_BILINEAR | - MDP4_OP_SCALE_ALPHA_BILINEAR; - } - - pipe->phasex_step = mdp4_scale_phase_step(29, - pipe->src_w, pipe->dst_w); - } -} - -void mdp4_overlay_rgb_setup(struct mdp4_overlay_pipe *pipe) -{ - char *rgb_base; - uint32 src_size, src_xy, dst_size, dst_xy; - uint32 format, pattern; - uint32 curr, mask; - uint32 offset = 0; - int pnum; - - pnum = pipe->pipe_num - OVERLAY_PIPE_RGB1; /* start from 0 */ - rgb_base = MDP_BASE + MDP4_RGB_BASE; - rgb_base += (MDP4_RGB_OFF * pnum); - - src_size = ((pipe->src_h << 16) | pipe->src_w); - src_xy = ((pipe->src_y << 16) | pipe->src_x); - dst_size = ((pipe->dst_h << 16) | pipe->dst_w); - dst_xy = ((pipe->dst_y << 16) | pipe->dst_x); - - if ((pipe->src_x + pipe->src_w) > 0x7FF) { - offset += pipe->src_x * pipe->bpp; - src_xy &= 0xFFFF0000; - } - - if ((pipe->src_y + pipe->src_h) > 0x7FF) { - offset += pipe->src_y * pipe->src_width * pipe->bpp; - src_xy &= 0x0000FFFF; - } - - format = mdp4_overlay_format(pipe); - pattern = mdp4_overlay_unpack_pattern(pipe); - -#ifdef MDP4_IGC_LUT_ENABLE - pipe->op_mode |= MDP4_OP_IGC_LUT_EN; -#endif - - mdp4_scale_setup(pipe); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* Ensure proper covert matrix loaded when color space swaps */ - curr = inpdw(rgb_base + 0x0058); - /* Don't touch bits you don't want to configure*/ - mask = 0xFFFEFFFF; - pipe->op_mode = (pipe->op_mode & mask) | (curr & ~mask); - - outpdw(rgb_base + 0x0000, src_size); /* MDP_RGB_SRC_SIZE */ - outpdw(rgb_base + 0x0004, src_xy); /* MDP_RGB_SRC_XY */ - outpdw(rgb_base + 0x0008, dst_size); /* MDP_RGB_DST_SIZE */ - outpdw(rgb_base + 0x000c, dst_xy); /* MDP_RGB_DST_XY */ - - outpdw(rgb_base + 0x0010, pipe->srcp0_addr + offset); - outpdw(rgb_base + 0x0040, pipe->srcp0_ystride); - - outpdw(rgb_base + 0x0050, format);/* MDP_RGB_SRC_FORMAT */ - outpdw(rgb_base + 0x0054, pattern);/* MDP_RGB_SRC_UNPACK_PATTERN */ - if (format & MDP4_FORMAT_SOLID_FILL) { - u32 op_mode = pipe->op_mode; - op_mode &= ~(MDP4_OP_FLIP_LR + MDP4_OP_SCALEX_EN); - op_mode &= ~(MDP4_OP_FLIP_UD + MDP4_OP_SCALEY_EN); - outpdw(rgb_base + 0x0058, op_mode);/* MDP_RGB_OP_MODE */ - } else { - if (pipe->op_mode & MDP4_OP_FLIP_LR && mdp_rev >= MDP_REV_42) { - /* Enable x-scaling bit to enable LR flip */ - /* for MDP > 4.2 targets */ - pipe->op_mode |= 0x01; - } - outpdw(rgb_base + 0x0058, pipe->op_mode);/* MDP_RGB_OP_MODE */ - } - outpdw(rgb_base + 0x005c, pipe->phasex_step); - outpdw(rgb_base + 0x0060, pipe->phasey_step); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - mdp4_stat.pipe[pipe->pipe_num]++; -} - - -static void mdp4_overlay_vg_get_src_offset(struct mdp4_overlay_pipe *pipe, - char *vg_base, uint32 *luma_off, uint32 *chroma_off) -{ - uint32 src_xy; - *luma_off = 0; - *chroma_off = 0; - - if ((pipe->src_x || pipe->src_y) && (pipe->frame_format == - MDP4_FRAME_FORMAT_LINEAR)) { - src_xy = 0; - outpdw(vg_base + 0x0004, src_xy); /* MDP_RGB_SRC_XY */ - - switch (pipe->src_format) { - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CB_CR_H2V2: - *luma_off = pipe->src_x + - (pipe->src_y * pipe->srcp0_ystride); - *chroma_off = pipe->src_x / 2 + - ((pipe->src_y / 2) * pipe->srcp1_ystride); - break; - - case MDP_Y_CBCR_H2V2_TILE: - case MDP_Y_CRCB_H2V2_TILE: - case MDP_Y_CBCR_H2V2: - case MDP_Y_CRCB_H2V2: - *luma_off = pipe->src_x + - (pipe->src_y * pipe->srcp0_ystride); - *chroma_off = pipe->src_x + - ((pipe->src_y / 2) * pipe->srcp1_ystride); - break; - - case MDP_Y_CRCB_H1V1: - case MDP_Y_CBCR_H1V1: - *luma_off = pipe->src_x + - (pipe->src_y * pipe->srcp0_ystride); - *chroma_off = pipe->src_x + - ((pipe->src_y * 2) * pipe->srcp1_ystride); - break; - - case MDP_Y_CRCB_H2V1: - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H1V2: - case MDP_Y_CBCR_H1V2: - *luma_off = pipe->src_x + - (pipe->src_y * pipe->srcp0_ystride); - *chroma_off = pipe->src_x + - (pipe->src_y * pipe->srcp1_ystride); - break; - - case MDP_YCRYCB_H2V1: - case MDP_CBYCRY_H2V1: - if (pipe->src_x & 0x1) - pipe->src_x += 1; - *luma_off += pipe->src_x * 2 + - ((pipe->src_y * 2) * pipe->srcp0_ystride); - break; - - case MDP_ARGB_8888: - case MDP_RGBA_8888: - case MDP_BGRA_8888: - case MDP_BGRX_8888: - case MDP_RGBX_8888: - case MDP_RGB_565: - case MDP_BGR_565: - case MDP_XRGB_8888: - case MDP_RGB_888: - case MDP_YCBCR_H1V1: - case MDP_YCRCB_H1V1: - *luma_off = (pipe->src_x * pipe->bpp) + - (pipe->src_y * pipe->srcp0_ystride); - break; - - default: - pr_err("%s: fmt %u not supported for adjustment\n", - __func__, pipe->src_format); - break; - } - } -} - -void mdp4_overlay_vg_setup(struct mdp4_overlay_pipe *pipe) -{ - char *vg_base; - uint32 frame_size, src_size, src_xy, dst_size, dst_xy; - uint32 format, pattern, luma_offset, chroma_offset; - uint32 mask; - int pnum, ptype, i; - uint32_t block; - - pnum = pipe->pipe_num - OVERLAY_PIPE_VG1; /* start from 0 */ - vg_base = MDP_BASE + MDP4_VIDEO_BASE; - vg_base += (MDP4_VIDEO_OFF * pnum); - - frame_size = ((pipe->src_height << 16) | pipe->src_width); - src_size = ((pipe->src_h << 16) | pipe->src_w); - src_xy = ((pipe->src_y << 16) | pipe->src_x); - dst_size = ((pipe->dst_h << 16) | pipe->dst_w); - dst_xy = ((pipe->dst_y << 16) | pipe->dst_x); - - ptype = mdp4_overlay_format2type(pipe->src_format); - format = mdp4_overlay_format(pipe); - pattern = mdp4_overlay_unpack_pattern(pipe); - - /* CSC Post Processing enabled? */ - if (pipe->flags & MDP_OVERLAY_PP_CFG_EN) { - if (pipe->pp_cfg.config_ops & MDP_OVERLAY_PP_CSC_CFG) { - if (pipe->pp_cfg.csc_cfg.flags & MDP_CSC_FLAG_ENABLE) - pipe->op_mode |= MDP4_OP_CSC_EN; - if (pipe->pp_cfg.csc_cfg.flags & MDP_CSC_FLAG_YUV_IN) - pipe->op_mode |= MDP4_OP_SRC_DATA_YCBCR; - if (pipe->pp_cfg.csc_cfg.flags & MDP_CSC_FLAG_YUV_OUT) - pipe->op_mode |= MDP4_OP_DST_DATA_YCBCR; - - mdp4_csc_write(&pipe->pp_cfg.csc_cfg, - (uint32_t) (vg_base + MDP4_VIDEO_CSC_OFF)); - - if (pipe->pipe_num == OVERLAY_PIPE_VG1) - block = MDP_BLOCK_VG_1; - else - block = MDP_BLOCK_VG_2; - - for (i = 0; i < CSC_MAX_BLOCKS; i++) { - if (block == csc_cfg_matrix[i].block) { - memcpy(&csc_cfg_matrix[i].csc_data, - &(pipe->pp_cfg.csc_cfg), - sizeof(struct mdp_csc_cfg)); - break; - } - } - } - if (pipe->pp_cfg.config_ops & MDP_OVERLAY_PP_QSEED_CFG) { - mdp4_qseed_access_cfg(&pipe->pp_cfg.qseed_cfg[0], - (uint32_t) vg_base); - mdp4_qseed_access_cfg(&pipe->pp_cfg.qseed_cfg[1], - (uint32_t) vg_base); - } - } - /* not RGB use VG pipe, pure VG pipe */ - if (ptype != OVERLAY_TYPE_RGB) - pipe->op_mode |= (MDP4_OP_CSC_EN | MDP4_OP_SRC_DATA_YCBCR); - -#ifdef MDP4_IGC_LUT_ENABLE - pipe->op_mode |= MDP4_OP_IGC_LUT_EN; -#endif - - mdp4_scale_setup(pipe); - - luma_offset = 0; - chroma_offset = 0; - - if (ptype == OVERLAY_TYPE_RGB) { - if ((pipe->src_y + pipe->src_h) > 0x7FF) { - luma_offset = pipe->src_y * pipe->src_width * pipe->bpp; - src_xy &= 0x0000FFFF; - } - - if ((pipe->src_x + pipe->src_w) > 0x7FF) { - luma_offset += pipe->src_x * pipe->bpp; - src_xy &= 0xFFFF0000; - } - } - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - outpdw(vg_base + 0x0000, src_size); /* MDP_RGB_SRC_SIZE */ - outpdw(vg_base + 0x0004, src_xy); /* MDP_RGB_SRC_XY */ - outpdw(vg_base + 0x0008, dst_size); /* MDP_RGB_DST_SIZE */ - outpdw(vg_base + 0x000c, dst_xy); /* MDP_RGB_DST_XY */ - - if (pipe->frame_format != MDP4_FRAME_FORMAT_LINEAR) - outpdw(vg_base + 0x0048, frame_size); /* TILE frame size */ - - /* - * Adjust src X offset to avoid MDP from overfetching pixels - * present before the offset. This is required for video - * frames coming with unused green pixels along the left margin - */ - /* not RGB use VG pipe, pure VG pipe */ - if (ptype != OVERLAY_TYPE_RGB) { - mdp4_overlay_vg_get_src_offset(pipe, vg_base, &luma_offset, - &chroma_offset); - } - - /* luma component plane */ - outpdw(vg_base + 0x0010, pipe->srcp0_addr + luma_offset); - - /* chroma component plane or planar color 1 */ - outpdw(vg_base + 0x0014, pipe->srcp1_addr + chroma_offset); - - /* planar color 2 */ - outpdw(vg_base + 0x0018, pipe->srcp2_addr + chroma_offset); - - outpdw(vg_base + 0x0040, - pipe->srcp1_ystride << 16 | pipe->srcp0_ystride); - - outpdw(vg_base + 0x0044, - pipe->srcp3_ystride << 16 | pipe->srcp2_ystride); - - outpdw(vg_base + 0x0050, format); /* MDP_RGB_SRC_FORMAT */ - outpdw(vg_base + 0x0054, pattern); /* MDP_RGB_SRC_UNPACK_PATTERN */ - if (format & MDP4_FORMAT_SOLID_FILL) { - u32 op_mode = pipe->op_mode; - op_mode &= ~(MDP4_OP_FLIP_LR + MDP4_OP_SCALEX_EN); - op_mode &= ~(MDP4_OP_FLIP_UD + MDP4_OP_SCALEY_EN); - outpdw(vg_base + 0x0058, op_mode);/* MDP_RGB_OP_MODE */ - } else - outpdw(vg_base + 0x0058, pipe->op_mode);/* MDP_RGB_OP_MODE */ - outpdw(vg_base + 0x005c, pipe->phasex_step); - outpdw(vg_base + 0x0060, pipe->phasey_step); - - if (pipe->op_mode & MDP4_OP_DITHER_EN) { - outpdw(vg_base + 0x0068, - pipe->r_bit << 4 | pipe->b_bit << 2 | pipe->g_bit); - } - - if (mdp_rev > MDP_REV_41) { - /* mdp chip select controller */ - mask = 0; - if (pipe->pipe_num == OVERLAY_PIPE_VG1) - mask = 0x020; /* bit 5 */ - else if (pipe->pipe_num == OVERLAY_PIPE_VG2) - mask = 0x02000; /* bit 13 */ - if (mask) { - if (pipe->op_mode & MDP4_OP_SCALEY_MN_PHASE) - ctrl->cs_controller &= ~mask; - else - ctrl->cs_controller |= mask; - /* NOT double buffered */ - outpdw(MDP_BASE + 0x00c0, ctrl->cs_controller); - } - } - - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - mdp4_stat.pipe[pipe->pipe_num]++; -} - -int mdp4_overlay_format2type(uint32 format) -{ - switch (format) { - case MDP_RGB_565: - case MDP_RGB_888: - case MDP_BGR_565: - case MDP_XRGB_8888: - case MDP_ARGB_8888: - case MDP_RGBA_8888: - case MDP_BGRA_8888: - case MDP_BGRX_8888: - case MDP_RGBX_8888: - return OVERLAY_TYPE_RGB; - case MDP_YCRYCB_H2V1: - case MDP_CBYCRY_H2V1: - case MDP_Y_CRCB_H2V1: - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H1V2: - case MDP_Y_CBCR_H1V2: - case MDP_Y_CRCB_H2V2: - case MDP_Y_CBCR_H2V2: - case MDP_Y_CBCR_H2V2_TILE: - case MDP_Y_CRCB_H2V2_TILE: - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CB_CR_H2V2: - case MDP_Y_CRCB_H1V1: - case MDP_Y_CBCR_H1V1: - case MDP_YCRCB_H1V1: - case MDP_YCBCR_H1V1: - return OVERLAY_TYPE_VIDEO; - case MDP_RGB_BORDERFILL: - return OVERLAY_TYPE_BF; - default: - mdp4_stat.err_format++; - return -ERANGE; - } - -} - -#define C3_ALPHA 3 /* alpha */ -#define C2_R_Cr 2 /* R/Cr */ -#define C1_B_Cb 1 /* B/Cb */ -#define C0_G_Y 0 /* G/luma */ -#define YUV_444_MAX_WIDTH 1280 /* Max width for YUV 444*/ - -int mdp4_overlay_format2pipe(struct mdp4_overlay_pipe *pipe) -{ - switch (pipe->src_format) { - case MDP_RGB_565: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 0; - pipe->r_bit = 1; /* R, 5 bits */ - pipe->b_bit = 1; /* B, 5 bits */ - pipe->g_bit = 2; /* G, 6 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 2; - pipe->element2 = C2_R_Cr; /* R */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C1_B_Cb; /* B */ - pipe->bpp = 2; /* 2 bpp */ - break; - case MDP_RGB_888: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 0; - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 2; - pipe->element2 = C1_B_Cb; /* B */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C2_R_Cr; /* R */ - pipe->bpp = 3; /* 3 bpp */ - break; - case MDP_BGR_565: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 0; - pipe->r_bit = 1; /* R, 5 bits */ - pipe->b_bit = 1; /* B, 5 bits */ - pipe->g_bit = 2; /* G, 6 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 2; - pipe->element2 = C1_B_Cb; /* B */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C2_R_Cr; /* R */ - pipe->bpp = 2; /* 2 bpp */ - break; - case MDP_XRGB_8888: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 3; /* alpha, 4 bits */ - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C1_B_Cb; /* B */ - pipe->element2 = C0_G_Y; /* G */ - pipe->element1 = C2_R_Cr; /* R */ - pipe->element0 = C3_ALPHA; /* alpha */ - pipe->bpp = 4; /* 4 bpp */ - break; - case MDP_ARGB_8888: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 3; /* alpha, 4 bits */ - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 1; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C1_B_Cb; /* B */ - pipe->element2 = C0_G_Y; /* G */ - pipe->element1 = C2_R_Cr; /* R */ - pipe->element0 = C3_ALPHA; /* alpha */ - pipe->bpp = 4; /* 4 bpp */ - break; - case MDP_RGBA_8888: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 3; /* alpha, 4 bits */ - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 1; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C3_ALPHA; /* alpha */ - pipe->element2 = C1_B_Cb; /* B */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C2_R_Cr; /* R */ - pipe->bpp = 4; /* 4 bpp */ - break; - case MDP_RGBX_8888: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 3; - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C3_ALPHA; /* alpha */ - pipe->element2 = C1_B_Cb; /* B */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C2_R_Cr; /* R */ - pipe->bpp = 4; /* 4 bpp */ - break; - case MDP_BGRA_8888: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 3; /* alpha, 4 bits */ - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 1; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C3_ALPHA; /* alpha */ - pipe->element2 = C2_R_Cr; /* R */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C1_B_Cb; /* B */ - pipe->bpp = 4; /* 4 bpp */ - break; - case MDP_BGRX_8888: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 3; /* alpha, 4 bits */ - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C3_ALPHA; /* alpha */ - pipe->element2 = C2_R_Cr; /* R */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C1_B_Cb; /* B */ - pipe->bpp = 4; /* 4 bpp */ - break; - case MDP_YCRYCB_H2V1: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 0; /* alpha, 4 bits */ - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C1_B_Cb; /* B */ - pipe->element2 = C0_G_Y; /* G */ - pipe->element1 = C2_R_Cr; /* R */ - pipe->element0 = C0_G_Y; /* G */ - pipe->bpp = 2; /* 2 bpp */ - pipe->chroma_sample = MDP4_CHROMA_H2V1; - break; - case MDP_CBYCRY_H2V1: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 0; /* alpha, 4 bits */ - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 3; - pipe->element3 = C0_G_Y; /* G */ - pipe->element2 = C2_R_Cr; /* R */ - pipe->element1 = C0_G_Y; /* G */ - pipe->element0 = C1_B_Cb; /* B */ - pipe->bpp = 2; /* 2 bpp */ - pipe->chroma_sample = MDP4_CHROMA_H2V1; - break; - case MDP_Y_CRCB_H2V1: - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H1V2: - case MDP_Y_CBCR_H1V2: - case MDP_Y_CRCB_H2V2: - case MDP_Y_CBCR_H2V2: - case MDP_Y_CRCB_H1V1: - case MDP_Y_CBCR_H1V1: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_PSEUDO_PLANAR; - pipe->a_bit = 0; - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 1; /* 2 */ - if (pipe->src_format == MDP_Y_CRCB_H2V1) { - pipe->element1 = C1_B_Cb; - pipe->element0 = C2_R_Cr; - pipe->chroma_sample = MDP4_CHROMA_H2V1; - } else if (pipe->src_format == MDP_Y_CRCB_H1V1) { - pipe->element1 = C1_B_Cb; - pipe->element0 = C2_R_Cr; - if (pipe->src_width > YUV_444_MAX_WIDTH) - pipe->chroma_sample = MDP4_CHROMA_H1V2; - else - pipe->chroma_sample = MDP4_CHROMA_RGB; - } else if (pipe->src_format == MDP_Y_CBCR_H2V1) { - pipe->element1 = C2_R_Cr; - pipe->element0 = C1_B_Cb; - pipe->chroma_sample = MDP4_CHROMA_H2V1; - } else if (pipe->src_format == MDP_Y_CBCR_H1V1) { - pipe->element1 = C2_R_Cr; - pipe->element0 = C1_B_Cb; - if (pipe->src_width > YUV_444_MAX_WIDTH) - pipe->chroma_sample = MDP4_CHROMA_H1V2; - else - pipe->chroma_sample = MDP4_CHROMA_RGB; - } else if (pipe->src_format == MDP_Y_CRCB_H1V2) { - pipe->element1 = C1_B_Cb; - pipe->element0 = C2_R_Cr; - pipe->chroma_sample = MDP4_CHROMA_H1V2; - } else if (pipe->src_format == MDP_Y_CBCR_H1V2) { - pipe->element1 = C2_R_Cr; - pipe->element0 = C1_B_Cb; - pipe->chroma_sample = MDP4_CHROMA_H1V2; - } else if (pipe->src_format == MDP_Y_CRCB_H2V2) { - pipe->element1 = C1_B_Cb; - pipe->element0 = C2_R_Cr; - pipe->chroma_sample = MDP4_CHROMA_420; - } else if (pipe->src_format == MDP_Y_CBCR_H2V2) { - pipe->element1 = C2_R_Cr; - pipe->element0 = C1_B_Cb; - pipe->chroma_sample = MDP4_CHROMA_420; - } - pipe->bpp = 2; /* 2 bpp */ - break; - case MDP_Y_CBCR_H2V2_TILE: - case MDP_Y_CRCB_H2V2_TILE: - pipe->frame_format = MDP4_FRAME_FORMAT_VIDEO_SUPERTILE; - pipe->fetch_plane = OVERLAY_PLANE_PSEUDO_PLANAR; - pipe->a_bit = 0; - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 1; /* 2 */ - if (pipe->src_format == MDP_Y_CRCB_H2V2_TILE) { - pipe->element1 = C1_B_Cb; /* B */ - pipe->element0 = C2_R_Cr; /* R */ - pipe->chroma_sample = MDP4_CHROMA_420; - } else if (pipe->src_format == MDP_Y_CBCR_H2V2_TILE) { - pipe->element1 = C2_R_Cr; /* R */ - pipe->element0 = C1_B_Cb; /* B */ - pipe->chroma_sample = MDP4_CHROMA_420; - } - pipe->bpp = 2; /* 2 bpp */ - break; - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CB_CR_H2V2: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_PLANAR; - pipe->a_bit = 0; - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->chroma_sample = MDP4_CHROMA_420; - pipe->bpp = 2; /* 2 bpp */ - break; - case MDP_YCBCR_H1V1: - case MDP_YCRCB_H1V1: - pipe->frame_format = MDP4_FRAME_FORMAT_LINEAR; - pipe->fetch_plane = OVERLAY_PLANE_INTERLEAVED; - pipe->a_bit = 0; - pipe->r_bit = 3; /* R, 8 bits */ - pipe->b_bit = 3; /* B, 8 bits */ - pipe->g_bit = 3; /* G, 8 bits */ - pipe->alpha_enable = 0; - pipe->unpack_tight = 1; - pipe->unpack_align_msb = 0; - pipe->unpack_count = 2; - pipe->element0 = C0_G_Y; /* G */ - if (pipe->src_format == MDP_YCRCB_H1V1) { - pipe->element1 = C2_R_Cr; /* R */ - pipe->element2 = C1_B_Cb; /* B */ - } else { - pipe->element1 = C1_B_Cb; /* B */ - pipe->element2 = C2_R_Cr; /* R */ - } - pipe->bpp = 3; /* 3 bpp */ - case MDP_RGB_BORDERFILL: - pipe->alpha_enable = 0; - pipe->alpha = 0; - break; - default: - /* not likely */ - mdp4_stat.err_format++; - return -ERANGE; - } - - return 0; -} - -/* - * color_key_convert: output with 12 bits color key - */ -static uint32 color_key_convert(int start, int num, uint32 color) -{ - uint32 data; - - data = (color >> start) & ((1 << num) - 1); - - /* convert to 8 bits */ - if (num == 5) - data = ((data << 3) | (data >> 2)); - else if (num == 6) - data = ((data << 2) | (data >> 4)); - - /* convert 8 bits to 12 bits */ - data = (data << 4) | (data >> 4); - - return data; -} - -void transp_color_key(int format, uint32 transp, - uint32 *c0, uint32 *c1, uint32 *c2) -{ - int b_start, g_start, r_start; - int b_num, g_num, r_num; - - switch (format) { - case MDP_RGB_565: - b_start = 0; - g_start = 5; - r_start = 11; - r_num = 5; - g_num = 6; - b_num = 5; - break; - case MDP_RGB_888: - case MDP_XRGB_8888: - case MDP_ARGB_8888: - case MDP_BGRA_8888: - case MDP_BGRX_8888: - b_start = 0; - g_start = 8; - r_start = 16; - r_num = 8; - g_num = 8; - b_num = 8; - break; - case MDP_RGBA_8888: - case MDP_RGBX_8888: - b_start = 16; - g_start = 8; - r_start = 0; - r_num = 8; - g_num = 8; - b_num = 8; - break; - case MDP_BGR_565: - b_start = 11; - g_start = 5; - r_start = 0; - r_num = 5; - g_num = 6; - b_num = 5; - break; - case MDP_Y_CB_CR_H2V2: - case MDP_Y_CBCR_H2V2: - case MDP_Y_CBCR_H2V1: - case MDP_YCBCR_H1V1: - b_start = 8; - g_start = 16; - r_start = 0; - r_num = 8; - g_num = 8; - b_num = 8; - break; - case MDP_Y_CR_CB_H2V2: - case MDP_Y_CR_CB_GH2V2: - case MDP_Y_CRCB_H2V2: - case MDP_Y_CRCB_H2V1: - case MDP_Y_CRCB_H1V2: - case MDP_Y_CBCR_H1V2: - case MDP_Y_CRCB_H1V1: - case MDP_Y_CBCR_H1V1: - case MDP_YCRCB_H1V1: - b_start = 0; - g_start = 16; - r_start = 8; - r_num = 8; - g_num = 8; - b_num = 8; - break; - default: - b_start = 0; - g_start = 8; - r_start = 16; - r_num = 8; - g_num = 8; - b_num = 8; - break; - } - - *c0 = color_key_convert(g_start, g_num, transp); - *c1 = color_key_convert(b_start, b_num, transp); - *c2 = color_key_convert(r_start, r_num, transp); -} - -uint32 mdp4_overlay_format(struct mdp4_overlay_pipe *pipe) -{ - uint32 format; - - format = 0; - - if (pipe->solid_fill) - format |= MDP4_FORMAT_SOLID_FILL; - - if (pipe->unpack_align_msb) - format |= MDP4_FORMAT_UNPACK_ALIGN_MSB; - - if (pipe->unpack_tight) - format |= MDP4_FORMAT_UNPACK_TIGHT; - - if (pipe->alpha_enable) - format |= MDP4_FORMAT_ALPHA_ENABLE; - - if (pipe->flags & MDP_SOURCE_ROTATED_90) - format |= MDP4_FORMAT_90_ROTATED; - format |= (pipe->unpack_count << 13); - format |= ((pipe->bpp - 1) << 9); - format |= (pipe->a_bit << 6); - format |= (pipe->r_bit << 4); - format |= (pipe->b_bit << 2); - format |= pipe->g_bit; - - format |= (pipe->frame_format << 29); - - if (pipe->fetch_plane == OVERLAY_PLANE_PSEUDO_PLANAR || - pipe->fetch_plane == OVERLAY_PLANE_PLANAR) { - /* video/graphic */ - format |= (pipe->fetch_plane << 19); - format |= (pipe->chroma_site << 28); - format |= (pipe->chroma_sample << 26); - } - - return format; -} - -uint32 mdp4_overlay_unpack_pattern(struct mdp4_overlay_pipe *pipe) -{ - return (pipe->element3 << 24) | (pipe->element2 << 16) | - (pipe->element1 << 8) | pipe->element0; -} - -static uint32 mdp4_overlayproc_cfg_wb_panel(struct mdp4_overlay_pipe *pipe, - char *overlay_base, uint32 curr) -{ - int off, bpp; - uint32 flag; - bool is_rgb = false; - struct mdp_mixer_cfg *mixer_cfg; - - off = 0; - mixer_cfg = &ctrl->mdp_mixer_cfg[MDP4_MIXER2]; - - switch (mixer_cfg->writeback_format) { - case WB_FORMAT_RGB_888: - bpp = 3; /* RGB888 */ - flag = 0x0; - is_rgb = true; - break; - case WB_FORMAT_RGB_565: - bpp = 2; /* RGB565 */ - flag = 0x1; - is_rgb = true; - break; - case WB_FORMAT_xRGB_8888: - bpp = 4; /* xRGB8888 */ - flag = 0x3; - is_rgb = true; - break; - case WB_FORMAT_ARGB_8888: - bpp = 4; /* ARGB8888 */ - flag = 0x80000003; - is_rgb = true; - break; - case WB_FORMAT_ARGB_8888_INPUT_ALPHA: - pr_warn("currently not supported ARGB_8888_INPUT_ALPHA\n"); - default: - bpp = 1; /* NV12 */ - is_rgb = false; - break; - } - - if (is_rgb == true) { - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - - outpdw(overlay_base + 0x000c, pipe->ov_blt_addr + off); - /* overlay ouput is RGB888 */ - outpdw(overlay_base + 0x0010, pipe->src_width * bpp); - outpdw(overlay_base + 0x001c, pipe->ov_blt_addr + off); - /* MDDI - BLT + on demand */ - outpdw(overlay_base + 0x0004, 0x08); - - curr = inpdw(overlay_base + 0x0014); - curr &= 0x4; - - outpdw(overlay_base + 0x0014, curr | flag); - } else { - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - - outpdw(overlay_base + 0x000c, pipe->ov_blt_addr + off); - /* overlay ouput is RGB888 */ - outpdw(overlay_base + 0x0010, ((pipe->src_width << 16) | - pipe->src_width)); - outpdw(overlay_base + 0x001c, pipe->ov_blt_addr + off); - off = pipe->src_height * pipe->src_width; - /* align chroma to 2k address */ - off = (off + 2047) & ~2047; - /* UV plane adress */ - outpdw(overlay_base + 0x0020, pipe->ov_blt_addr + off); - /* MDDI - BLT + on demand */ - outpdw(overlay_base + 0x0004, 0x08); - /* pseudo planar + writeback */ - curr = inpdw(overlay_base + 0x0014); - curr &= 0x4; - outpdw(overlay_base + 0x0014, curr | 0x012); - /* rgb->yuv */ - outpdw(overlay_base + 0x0200, 0x05); - } - return curr; -} - -/* - * mdp4_overlayproc_cfg: only be called from base layer - */ -void mdp4_overlayproc_cfg(struct mdp4_overlay_pipe *pipe) -{ - uint32 data, intf; - char *overlay_base; - uint32 curr; - - intf = 0; - if (pipe->mixer_num == MDP4_MIXER2) - overlay_base = MDP_BASE + MDP4_OVERLAYPROC2_BASE; - else if (pipe->mixer_num == MDP4_MIXER1) { - overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;/* 0x18000 */ - intf = inpdw(MDP_BASE + 0x0038); /* MDP_DISP_INTF_SEL */ - intf >>= 4; - intf &= 0x03; - } else - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - - if (!in_interrupt()) - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* - * BLT support both primary and external external - */ - if (pipe->ov_blt_addr) { - int off, bpp; -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - data = pipe->src_height; - data <<= 16; - data |= pipe->src_width; - outpdw(overlay_base + 0x0008, data); /* ROI, height + width */ - if (pipe->mixer_num == MDP4_MIXER0 || - pipe->mixer_num == MDP4_MIXER1) { - off = 0; - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - - outpdw(overlay_base + 0x000c, pipe->ov_blt_addr + off); - /* overlay ouput is RGB888 */ - outpdw(overlay_base + 0x0010, pipe->src_width * bpp); - outpdw(overlay_base + 0x001c, pipe->ov_blt_addr + off); - /* MDDI - BLT + on demand */ - outpdw(overlay_base + 0x0004, 0x08); - - curr = inpdw(overlay_base + 0x0014); - curr &= 0x4; -#ifdef BLT_RGB565 - outpdw(overlay_base + 0x0014, curr | 0x1); /* RGB565 */ -#else - outpdw(overlay_base + 0x0014, curr | 0x0); /* RGB888 */ -#endif - } else if (pipe->mixer_num == MDP4_MIXER2) { - if (ctrl->panel_mode & MDP4_PANEL_WRITEBACK) { - curr = mdp4_overlayproc_cfg_wb_panel(pipe, - overlay_base, curr); - } - } - } else { - data = pipe->src_height; - data <<= 16; - data |= pipe->src_width; - outpdw(overlay_base + 0x0008, data); /* ROI, height + width */ - outpdw(overlay_base + 0x000c, pipe->srcp0_addr); - outpdw(overlay_base + 0x0010, pipe->srcp0_ystride); - outpdw(overlay_base + 0x0004, 0x01); /* directout */ - } - - if (pipe->mixer_num == MDP4_MIXER1) { - if (intf == TV_INTF) { - curr = inpdw(overlay_base + 0x0014); - curr &= 0x4; - outpdw(overlay_base + 0x0014, 0x02); /* yuv422 */ - /* overlay1 CSC config */ - outpdw(overlay_base + 0x0200, 0x05); /* rgb->yuv */ - } - } - -#ifdef MDP4_IGC_LUT_ENABLE - curr = inpdw(overlay_base + 0x0014); - curr &= ~0x4; - outpdw(overlay_base + 0x0014, curr | 0x4); /* GC_LUT_EN, 888 */ -#endif - - if (!in_interrupt()) - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -int mdp4_overlay_pipe_staged(struct mdp4_overlay_pipe *pipe) -{ - uint32 data, mask; - int mixer; - - mixer = pipe->mixer_num; - data = ctrl->mixer_cfg[mixer]; - - mask = 0x0f; - mask <<= (4 * pipe->pipe_num); - data &= mask; - - return data; -} - -int mdp4_mixer_info(int mixer_num, struct mdp_mixer_info *info) -{ - - int ndx, cnt; - struct mdp4_overlay_pipe *pipe; - - if (mixer_num > MDP4_MIXER_MAX) - return -ENODEV; - - cnt = 0; - ndx = MDP4_MIXER_STAGE_BASE; - for ( ; ndx < MDP4_MIXER_STAGE_MAX; ndx++) { - pipe = ctrl->stage[mixer_num][ndx]; - if (pipe == NULL) - continue; - info->z_order = pipe->mixer_stage - MDP4_MIXER_STAGE0; - /* z_order == -1, means base layer */ - info->ptype = pipe->pipe_type; - info->pnum = pipe->pipe_num; - info->pndx = pipe->pipe_ndx; - info->mixer_num = pipe->mixer_num; - info++; - cnt++; - } - return cnt; -} - -void mdp4_solidfill_commit(int mixer) -{ - struct blend_cfg bcfg; - struct mdp4_overlay_pipe *pp = NULL; - int i = 0; - - for (i = 0; i < OVERLAY_PIPE_MAX; i++) { - pp = &ctrl->sf_plist[mixer][i]; - if (pp->pipe_ndx && pp->solid_fill) { - bcfg.solidfill = 1; - bcfg.solidfill_pipe = pp; - mdp4_overlay_bg_solidfill(&bcfg); - mdp4_overlay_reg_flush(pp, 1); - mdp4_mixer_stage_up(pp, 0); - } - } - mdp4_mixer_stage_commit(MDP4_MIXER1); - - for (i = 0; i < OVERLAY_PIPE_MAX; i++) { - pp = &ctrl->sf_plist[mixer][i]; - if (pp->pipe_ndx && pp->solid_fill) { - mdp4_overlay_reg_flush(pp, 1); - mdp4_mixer_stage_down(pp, 0); - pp->solid_fill = 0; - } - } - mdp4_mixer_stage_commit(MDP4_MIXER1); -} - -void mdp4_mixer_stage_commit(int mixer) -{ - struct mdp4_overlay_pipe *pipe; - int i, num; - u32 data, stage; - int off; - unsigned long flags; - - data = 0; - for (i = MDP4_MIXER_STAGE_BASE; i < MDP4_MIXER_STAGE_MAX; i++) { - pipe = ctrl->stage[mixer][i]; - if (pipe == NULL) - continue; - pr_debug("%s: mixer=%d ndx=%d stage=%d\n", __func__, - mixer, pipe->pipe_ndx, i); - stage = pipe->mixer_stage; - if (mixer >= MDP4_MIXER1) - stage += 8; - stage <<= (4 * pipe->pipe_num); - data |= stage; - } - - /* - * stage_commit may be called from overlay_unset - * for command panel, mdp clocks may be off at this time. - * so mdp clock enabled is necessary - */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - mdp_clk_ctrl(1); - - mdp4_mixer_blend_setup(mixer); - - off = 0; - if (data != ctrl->mixer_cfg[mixer]) { - ctrl->mixer_cfg[mixer] = data; - if (mixer >= MDP4_MIXER2) { - /* MDP_LAYERMIXER2_IN_CFG */ - off = 0x100f0; - } else { - /* mixer 0 or 1 */ - num = mixer + 1; - num &= 0x01; - data |= ctrl->mixer_cfg[num]; - off = 0x10100; - } - pr_debug("%s: mixer=%d data=%x flush=%x pid=%d\n", __func__, - mixer, data, ctrl->flush[mixer], current->pid); - } - - local_irq_save(flags); - if (off) - outpdw(MDP_BASE + off, data); - - if (ctrl->flush[mixer]) { - outpdw(MDP_BASE + 0x18000, ctrl->flush[mixer]); - ctrl->flush[mixer] = 0; - } - local_irq_restore(flags); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - mdp_clk_ctrl(0); -} - - -void mdp4_mixer_stage_up(struct mdp4_overlay_pipe *pipe, int commit) -{ - struct mdp4_overlay_pipe *pp; - int i, mixer; - - mixer = pipe->mixer_num; - - for (i = MDP4_MIXER_STAGE_BASE; i < MDP4_MIXER_STAGE_MAX; i++) { - pp = ctrl->stage[mixer][i]; - if (pp && pp->pipe_ndx == pipe->pipe_ndx) { - ctrl->stage[mixer][i] = NULL; - break; - } - } - - ctrl->stage[mixer][pipe->mixer_stage] = pipe; /* keep it */ - - if (commit) - mdp4_mixer_stage_commit(mixer); -} - -void mdp4_mixer_stage_down(struct mdp4_overlay_pipe *pipe, int commit) -{ - struct mdp4_overlay_pipe *pp; - int i, mixer; - - mixer = pipe->mixer_num; - - for (i = MDP4_MIXER_STAGE_BASE; i < MDP4_MIXER_STAGE_MAX; i++) { - pp = ctrl->stage[mixer][i]; - if (pp && pp->pipe_ndx == pipe->pipe_ndx) - ctrl->stage[mixer][i] = NULL; /* clear it */ - } - - if (commit || ((mixer == 1) && !hdmi_prim_display) || - (mixer == 2)) - mdp4_mixer_stage_commit(mixer); -} -/* - * mixer0: rgb3: border color at register 0x15004, 0x15008 - * mixer1: vg3: border color at register 0x1D004, 0x1D008 - * mixer2: xxx: border color at register 0x8D004, 0x8D008 - */ -void mdp4_overlay_borderfill_stage_up(struct mdp4_overlay_pipe *pipe) -{ - struct mdp4_overlay_pipe *bspipe; - int ptype, pnum, pndx, mixer; - int format, alpha_enable, alpha; - - if (pipe->pipe_type != OVERLAY_TYPE_BF) - return; - - mixer = pipe->mixer_num; - - if (ctrl->baselayer[mixer]) - return; - - bspipe = ctrl->stage[mixer][MDP4_MIXER_STAGE_BASE]; - - /* - * bspipe is clone here - * get real pipe - */ - bspipe = mdp4_overlay_ndx2pipe(bspipe->pipe_ndx); - - /* save original base layer */ - ctrl->baselayer[mixer] = bspipe; - - pipe->alpha = 0; /* make sure bf pipe has alpha 0 */ - ptype = pipe->pipe_type; - pnum = pipe->pipe_num; - pndx = pipe->pipe_ndx; - format = pipe->src_format; - alpha_enable = pipe->alpha_enable; - alpha = pipe->alpha; - *pipe = *bspipe; /* keep base layer configuration */ - pipe->pipe_type = ptype; - pipe->pipe_num = pnum; - pipe->pipe_ndx = pndx; - pipe->src_format = format; - pipe->alpha_enable = alpha_enable; - pipe->alpha = alpha; - - /* free original base layer pipe to be sued as normal pipe */ - bspipe->pipe_used = 0; - - if (ctrl->panel_mode & MDP4_PANEL_DSI_VIDEO) - mdp4_dsi_video_base_swap(0, pipe); - else if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - mdp4_dsi_cmd_base_swap(0, pipe); - else if (ctrl->panel_mode & MDP4_PANEL_LCDC) - mdp4_lcdc_base_swap(0, pipe); - else if (ctrl->panel_mode & MDP4_PANEL_DTV) - mdp4_dtv_base_swap(0, pipe); - - mdp4_overlay_reg_flush(bspipe, 1); - /* borderfill pipe as base layer */ - mdp4_mixer_stage_up(pipe, 0); -} - -void mdp4_overlay_borderfill_stage_down(struct mdp4_overlay_pipe *pipe) -{ - struct mdp4_overlay_pipe *bspipe; - int ptype, pnum, pndx, mixer; - int format, alpha_enable, alpha; - struct mdp4_iommu_pipe_info iom; - - if (pipe->pipe_type != OVERLAY_TYPE_BF) - return; - - mixer = pipe->mixer_num; - - /* retrieve original base layer */ - bspipe = ctrl->baselayer[mixer]; - if (bspipe == NULL) { - pr_err("%s: no base layer at mixer=%d\n", - __func__, mixer); - return; - } - - iom = bspipe->iommu; - ptype = bspipe->pipe_type; - pnum = bspipe->pipe_num; - pndx = bspipe->pipe_ndx; - format = bspipe->src_format; - alpha_enable = bspipe->alpha_enable; - alpha = bspipe->alpha; - *bspipe = *pipe; /* restore base layer configuration */ - bspipe->pipe_type = ptype; - bspipe->pipe_num = pnum; - bspipe->pipe_ndx = pndx; - bspipe->src_format = format; - bspipe->alpha_enable = alpha_enable; - bspipe->alpha = alpha; - bspipe->iommu = iom; - - bspipe->pipe_used++; /* mark base layer pipe used */ - - ctrl->baselayer[mixer] = NULL; - - /* free borderfill pipe */ - pipe->pipe_used = 0; - - if (ctrl->panel_mode & MDP4_PANEL_DSI_VIDEO) - mdp4_dsi_video_base_swap(0, bspipe); - else if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - mdp4_dsi_cmd_base_swap(0, bspipe); - else if (ctrl->panel_mode & MDP4_PANEL_LCDC) - mdp4_lcdc_base_swap(0, bspipe); - else if (ctrl->panel_mode & MDP4_PANEL_DTV) - mdp4_dtv_base_swap(0, bspipe); - - /* free borderfill pipe */ - mdp4_overlay_reg_flush(pipe, 1); - mdp4_mixer_stage_down(pipe, 0); /* commit will happen for bspipe up */ - mdp4_overlay_pipe_free(pipe); - - /* stage up base layer */ - mdp4_overlay_reg_flush(bspipe, 1); - /* restore original base layer */ - mdp4_mixer_stage_up(bspipe, 1); -} - - -static struct mdp4_overlay_pipe *mdp4_background_layer(int mixer, - struct mdp4_overlay_pipe *sp) -{ - struct mdp4_overlay_pipe *pp; - struct mdp4_overlay_pipe *kp; - int i; - - kp = ctrl->stage[mixer][MDP4_MIXER_STAGE_BASE]; - for (i = MDP4_MIXER_STAGE_BASE; i < MDP4_MIXER_STAGE_MAX; i++) { - pp = ctrl->stage[mixer][i]; - if (pp == NULL) - continue; - if (pp == sp) - break; - - if ((pp->dst_x <= sp->dst_x) && - ((pp->dst_x + pp->dst_w) >= (sp->dst_x + sp->dst_w))) { - if ((pp->dst_y <= sp->dst_y) && - ((pp->dst_y + pp->dst_h) >= - (sp->dst_y + sp->dst_h))) { - kp = pp; - } - } - } - return kp; -} - -static void mdp4_overlay_bg_solidfill(struct blend_cfg *blend) -{ - struct mdp4_overlay_pipe *pipe; - char *base; - u32 op_mode, format; - int pnum, ptype; - - pipe = blend->solidfill_pipe; - if (pipe == NULL) - return; - - if (pipe->pipe_type == OVERLAY_TYPE_BF) - return; - - ptype = mdp4_overlay_format2type(pipe->src_format); - if (ptype == OVERLAY_TYPE_RGB) { - pnum = pipe->pipe_num - OVERLAY_PIPE_RGB1; - base = MDP_BASE + MDP4_RGB_BASE; - base += MDP4_RGB_OFF * pnum; - } else { - pnum = pipe->pipe_num - OVERLAY_PIPE_VG1; - base = MDP_BASE + MDP4_VIDEO_BASE; - base += MDP4_VIDEO_OFF * pnum; - } - - format = inpdw(base + 0x50); - if (blend->solidfill) { - format |= MDP4_FORMAT_SOLID_FILL; - /* - * If solid fill is enabled, flip and scale - * have to be disabled. otherwise, h/w - * underruns. - */ - op_mode = inpdw(base + 0x0058); - op_mode &= ~(MDP4_OP_FLIP_LR + MDP4_OP_SCALEX_EN); - op_mode &= ~(MDP4_OP_FLIP_UD + MDP4_OP_SCALEY_EN); - outpdw(base + 0x0058, op_mode); - outpdw(base + 0x1008, 0); /* black */ - /* - * Set src size and dst size same to avoid underruns - */ - outpdw(base + 0x0000, inpdw(base + 0x0008)); - } else { - u32 src_size = ((pipe->src_h << 16) | pipe->src_w); - outpdw(base + 0x0000, src_size); - format &= ~MDP4_FORMAT_SOLID_FILL; - blend->solidfill_pipe = NULL; - } - - outpdw(base + 0x50, format); - - mdp4_overlay_reg_flush(pipe, 0); -} - -void mdp4_mixer_blend_cfg(int mixer) -{ - int i, off; - unsigned char *overlay_base; - struct blend_cfg *blend; - - if (mixer == MDP4_MIXER2) - overlay_base = MDP_BASE + MDP4_OVERLAYPROC2_BASE; - else if (mixer == MDP4_MIXER1) - overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE; - else - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE; - - blend = &ctrl->blend[mixer][MDP4_MIXER_STAGE_BASE]; - blend++; /* stage0 */ - - for (i = MDP4_MIXER_STAGE0; i < MDP4_MIXER_STAGE_MAX; i++) { - off = 20 * i; - off = 0x20 * (i - MDP4_MIXER_STAGE0); - if (i == MDP4_MIXER_STAGE3) - off -= 4; - outpdw(overlay_base + off + 0x104, blend->op); - blend++; - } -} - -/* - * D(i+1) = Ks * S + Kd * D(i) - */ -void mdp4_mixer_blend_setup(int mixer) -{ - struct mdp4_overlay_pipe *d_pipe; - struct mdp4_overlay_pipe *s_pipe; - struct blend_cfg *blend; - int i, off, alpha_drop; - int d_alpha, s_alpha; - unsigned char *overlay_base; - uint32 c0, c1, c2, base_premulti; - - - d_pipe = ctrl->stage[mixer][MDP4_MIXER_STAGE_BASE]; - if (d_pipe == NULL) { - pr_err("%s: Error: no bg_pipe at mixer=%d\n", __func__, mixer); - return; - } - - blend = &ctrl->blend[mixer][MDP4_MIXER_STAGE0]; - base_premulti = ctrl->blend[mixer][MDP4_MIXER_STAGE_BASE].op & - MDP4_BLEND_FG_ALPHA_BG_CONST; - for (i = MDP4_MIXER_STAGE0; i < MDP4_MIXER_STAGE_MAX; i++) { - blend->solidfill = 0; - blend->op = (MDP4_BLEND_FG_ALPHA_FG_CONST | - MDP4_BLEND_BG_ALPHA_BG_CONST); - s_pipe = ctrl->stage[mixer][i]; - if (s_pipe == NULL) { - blend++; - d_pipe = NULL; - d_alpha = 0; - continue; - } - alpha_drop = 0; /* per stage */ - /* alpha channel is lost on VG pipe when using QSEED or M/N */ - if (s_pipe->pipe_type == OVERLAY_TYPE_VIDEO && - s_pipe->alpha_enable && - ((s_pipe->op_mode & MDP4_OP_SCALEY_EN) || - (s_pipe->op_mode & MDP4_OP_SCALEX_EN)) && - !(s_pipe->op_mode & (MDP4_OP_SCALEX_PIXEL_RPT | - MDP4_OP_SCALEY_PIXEL_RPT))) - alpha_drop = 1; - - d_pipe = mdp4_background_layer(mixer, s_pipe); - d_alpha = d_pipe->alpha_enable; - s_alpha = s_pipe->alpha_enable; - pr_debug("%s: stage=%d: bg: ndx=%d da=%d dalpha=%x " - "fg: ndx=%d sa=%d salpha=%x is_fg=%d alpha_drop=%d\n", - __func__, i-2, d_pipe->pipe_ndx, d_alpha, d_pipe->alpha, - s_pipe->pipe_ndx, s_alpha, s_pipe->alpha, s_pipe->is_fg, - alpha_drop); - - /* base on fg's alpha */ - blend->bg_alpha = 0x0ff - s_pipe->alpha; - blend->fg_alpha = s_pipe->alpha; - blend->co3_sel = 1; /* use fg alpha */ - pr_debug("%s: bg alpha %d, fg alpha %d\n", - __func__, blend->bg_alpha, blend->fg_alpha); - if (s_pipe->is_fg) { - if (s_pipe->alpha == 0xff) { - blend->solidfill = 1; - blend->solidfill_pipe = d_pipe; - } - } else if (s_alpha) { - if (!alpha_drop) { - blend->op = MDP4_BLEND_BG_ALPHA_FG_PIXEL; - if ((!(s_pipe->flags & MDP_BLEND_FG_PREMULT)) && - ((i != MDP4_MIXER_STAGE0) || - (!base_premulti))) - blend->op |= - MDP4_BLEND_FG_ALPHA_FG_PIXEL; - else - blend->fg_alpha = 0xff; - blend->op |= MDP4_BLEND_BG_INV_ALPHA; - } else - blend->op = MDP4_BLEND_BG_ALPHA_FG_CONST; - } else if (d_alpha) { - blend->op = (MDP4_BLEND_FG_ALPHA_BG_PIXEL | - MDP4_BLEND_FG_INV_ALPHA); - if ((!(d_pipe->flags & MDP_BLEND_FG_PREMULT)) && - ((i != MDP4_MIXER_STAGE0) || - (!base_premulti))) - blend->op |= - MDP4_BLEND_BG_ALPHA_BG_PIXEL; - else - blend->fg_alpha = 0xff; - - blend->co3_sel = 0; /* use bg alpha */ - } - - if (s_pipe->transp != MDP_TRANSP_NOP) { - if (s_pipe->is_fg) { - transp_color_key(s_pipe->src_format, - s_pipe->transp, &c0, &c1, &c2); - /* Fg blocked */ - blend->op |= MDP4_BLEND_FG_TRANSP_EN; - /* lower limit */ - blend->transp_low0 = (c1 << 16 | c0); - blend->transp_low1 = c2; - /* upper limit */ - blend->transp_high0 = (c1 << 16 | c0); - blend->transp_high1 = c2; - } else { - transp_color_key(d_pipe->src_format, - s_pipe->transp, &c0, &c1, &c2); - /* Fg blocked */ - blend->op |= MDP4_BLEND_BG_TRANSP_EN; - blend--; /* one stage back */ - /* lower limit */ - blend->transp_low0 = (c1 << 16 | c0); - blend->transp_low1 = c2; - /* upper limit */ - blend->transp_high0 = (c1 << 16 | c0); - blend->transp_high1 = c2; - blend++; /* back to original stage */ - } - } - blend++; - } - - /* mixer numer, /dev/fb0, /dev/fb1, /dev/fb2 */ - if (mixer == MDP4_MIXER2) - overlay_base = MDP_BASE + MDP4_OVERLAYPROC2_BASE;/* 0x88000 */ - else if (mixer == MDP4_MIXER1) - overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;/* 0x18000 */ - else - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - blend = &ctrl->blend[mixer][MDP4_MIXER_STAGE_BASE]; - /* lower limit */ - outpdw(overlay_base + 0x180, blend->transp_low0); - outpdw(overlay_base + 0x184, blend->transp_low1); - /* upper limit */ - outpdw(overlay_base + 0x188, blend->transp_high0); - outpdw(overlay_base + 0x18c, blend->transp_high1); - blend++; /* stage0 */ - for (i = MDP4_MIXER_STAGE0; i < MDP4_MIXER_STAGE_MAX; i++) { - off = 20 * i; - off = 0x20 * (i - MDP4_MIXER_STAGE0); - if (i == MDP4_MIXER_STAGE3) - off -= 4; - - if (blend->solidfill_pipe) - mdp4_overlay_bg_solidfill(blend); - - outpdw(overlay_base + off + 0x108, blend->fg_alpha); - outpdw(overlay_base + off + 0x10c, blend->bg_alpha); - - if (mdp_rev >= MDP_REV_42 || - ctrl->panel_mode & MDP4_PANEL_MDDI || - ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - outpdw(overlay_base + off + 0x104, blend->op); - - outpdw(overlay_base + (off << 5) + 0x1004, blend->co3_sel); - outpdw(overlay_base + off + 0x110, blend->transp_low0);/* low */ - outpdw(overlay_base + off + 0x114, blend->transp_low1);/* low */ - /* upper limit */ - outpdw(overlay_base + off + 0x118, blend->transp_high0); - outpdw(overlay_base + off + 0x11c, blend->transp_high1); - blend++; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -void mdp4_overlay_reg_flush(struct mdp4_overlay_pipe *pipe, int all) -{ - int mixer; - uint32 *reg; - - mixer = pipe->mixer_num; - reg = &ctrl->flush[mixer]; - *reg |= (1 << (2 + pipe->pipe_num)); - - if (all) { - if (mixer == MDP4_MIXER0) - *reg |= 0x01; - else - *reg |= 0x02; - } -} - -void mdp4_overlay_flush_piggyback(int m0, int m1) -{ - u32 data; - - data = ctrl->flush[m0] | ctrl->flush[m1]; - ctrl->flush[m0] = data; -} - -void mdp4_overlay_reg_flush_reset(struct mdp4_overlay_pipe *pipe) -{ - int mixer; - - mixer = pipe->mixer_num; - ctrl->flush[mixer] = 0; -} - -struct mdp4_overlay_pipe *mdp4_overlay_stage_pipe(int mixer, int stage) -{ - return ctrl->stage[mixer][stage]; -} - -struct mdp4_overlay_pipe *mdp4_overlay_ndx2pipe(int ndx) -{ - struct mdp4_overlay_pipe *pipe; - - if (ndx <= 0 || ndx > OVERLAY_PIPE_MAX) - return NULL; - - pipe = &ctrl->plist[ndx - 1]; /* ndx start from 1 */ - - if (pipe->pipe_used == 0) - return NULL; - - return pipe; -} - -struct mdp4_overlay_pipe *mdp4_overlay_pipe_alloc(int ptype, int mixer) -{ - int i; - struct mdp4_overlay_pipe *pipe; - - if (ptype == OVERLAY_TYPE_BF) { - if (!mdp4_overlay_borderfill_supported()) - return NULL; - } - - for (i = 0; i < OVERLAY_PIPE_MAX; i++) { - pipe = &ctrl->plist[i]; - if ((pipe->pipe_used == 0) && ((pipe->pipe_type == ptype) || - (ptype == OVERLAY_TYPE_RGB && - pipe->pipe_type == OVERLAY_TYPE_VIDEO))) { - if (ptype == OVERLAY_TYPE_BF && - mixer != pipe->mixer_num) - continue; - init_completion(&pipe->comp); - init_completion(&pipe->dmas_comp); - pr_debug("%s: pipe=%x ndx=%d num=%d\n", __func__, - (int)pipe, pipe->pipe_ndx, pipe->pipe_num); - return pipe; - } - } - - pr_err("%s: ptype=%d FAILED\n", __func__, ptype); - - return NULL; -} - - -void mdp4_overlay_pipe_free(struct mdp4_overlay_pipe *pipe) -{ - uint32 ptype, num, ndx, mixer; - struct mdp4_iommu_pipe_info iom; - - pr_debug("%s: pipe=%x ndx=%d\n", __func__, (int)pipe, pipe->pipe_ndx); - - ptype = pipe->pipe_type; - num = pipe->pipe_num; - ndx = pipe->pipe_ndx; - mixer = pipe->mixer_num; - - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 0); - - iom = pipe->iommu; - - memset(pipe, 0, sizeof(*pipe)); - pipe->pipe_type = ptype; - pipe->pipe_num = num; - pipe->pipe_ndx = ndx; - pipe->mixer_num = mixer; - pipe->iommu = iom; - -} - -static int mdp4_overlay_req2pipe(struct mdp_overlay *req, int mixer, - struct mdp4_overlay_pipe **ppipe, - struct msm_fb_data_type *mfd) -{ - struct mdp4_overlay_pipe *pipe; - int ret, ptype; - - u32 upscale_max; - upscale_max = (mdp_rev >= MDP_REV_41) ? - MDP4_REV41_OR_LATER_UP_SCALING_MAX : - MDP4_REV40_UP_SCALING_MAX; - - if (mfd == NULL) { - pr_err("%s: mfd == NULL, -ENODEV\n", __func__); - return -ENODEV; - } - - if (mixer >= MDP4_MIXER_MAX) { - pr_err("%s: mixer out of range!\n", __func__); - mdp4_stat.err_mixer++; - return -ERANGE; - } - - if (req->z_order < 0 || req->z_order > 3) { - pr_err("%s: z_order=%d out of range!\n", __func__, - req->z_order); - mdp4_stat.err_zorder++; - return -ERANGE; - } - - if (req->src_rect.h > 0xFFF) { - pr_err("%s: src_h is out of range: 0X%x!\n", - __func__, req->src_rect.h); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->src_rect.w > 0xFFF) { - pr_err("%s: src_w is out of range: 0X%x!\n", - __func__, req->src_rect.w); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->src_rect.x > 0xFFF) { - pr_err("%s: src_x is out of range: 0X%x!\n", - __func__, req->src_rect.x); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->src_rect.y > 0xFFF) { - pr_err("%s: src_y is out of range: 0X%x!\n", - __func__, req->src_rect.y); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->dst_rect.h > 0xFFF) { - pr_err("%s: dst_h is out of range: 0X%x!\n", - __func__, req->dst_rect.h); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->dst_rect.w > 0xFFF) { - pr_err("%s: dst_w is out of range: 0X%x!\n", - __func__, req->dst_rect.w); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->dst_rect.x > 0xFFF) { - pr_err("%s: dst_x is out of range: 0X%x!\n", - __func__, req->dst_rect.x); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->dst_rect.y > 0xFFF) { - pr_err("%s: dst_y is out of range: 0X%x!\n", - __func__, req->dst_rect.y); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->src_rect.h == 0 || req->src_rect.w == 0) { - pr_err("%s: src img of zero size!\n", __func__); - mdp4_stat.err_size++; - return -EINVAL; - } - - if (req->dst_rect.h > (req->src_rect.h * upscale_max)) { - mdp4_stat.err_scale++; - pr_err("%s: scale up, too much (h)!\n", __func__); - return -ERANGE; - } - - if (req->src_rect.h > (req->dst_rect.h * 8)) { /* too little */ - mdp4_stat.err_scale++; - pr_err("%s: scale down, too little (h)!\n", __func__); - return -ERANGE; - } - - if (req->dst_rect.w > (req->src_rect.w * upscale_max)) { - mdp4_stat.err_scale++; - pr_err("%s: scale up, too much (w)!\n", __func__); - return -ERANGE; - } - - if (req->src_rect.w > (req->dst_rect.w * 8)) { /* too little */ - mdp4_stat.err_scale++; - pr_err("%s: scale down, too little (w)!\n", __func__); - return -ERANGE; - } - - if (mdp_rev <= MDP_REV_41) { - if ((mdp4_overlay_format2type(req->src.format) == - OVERLAY_TYPE_RGB) && - !(req->flags & MDP_OV_PIPE_SHARE) && - ((req->src_rect.w > req->dst_rect.w) || - (req->src_rect.h > req->dst_rect.h))) { - mdp4_stat.err_size++; - pr_err("%s: downscale on RGB pipe!\n", __func__); - return -EINVAL; - } - } - - if (mdp_hw_revision == MDP4_REVISION_V1) { - /* non integer down saceling ratio smaller than 1/4 - * is not supportted - */ - if (req->src_rect.h > (req->dst_rect.h * 4)) { - if (req->src_rect.h % req->dst_rect.h) { - mdp4_stat.err_scale++; - pr_err("%s: need integer (h)!\n", __func__); - return -ERANGE; - } - } - - if (req->src_rect.w > (req->dst_rect.w * 4)) { - if (req->src_rect.w % req->dst_rect.w) { - mdp4_stat.err_scale++; - pr_err("%s: need integer (w)!\n", __func__); - return -ERANGE; - } - } - } - - if (((req->src_rect.x + req->src_rect.w) > req->src.width) || - ((req->src_rect.y + req->src_rect.h) > req->src.height)) { - mdp4_stat.err_size++; - pr_err("%s invalid src rectangle\n", __func__); - return -ERANGE; - } - - if (ctrl->panel_3d != MDP4_3D_SIDE_BY_SIDE) { - int xres; - int yres; - - xres = mfd->panel_info.xres; - yres = mfd->panel_info.yres; - - if (((req->dst_rect.x + req->dst_rect.w) > xres) || - ((req->dst_rect.y + req->dst_rect.h) > yres)) { - mdp4_stat.err_size++; - pr_err("%s invalid dst rectangle\n", __func__); - return -ERANGE; - } - } - - ptype = mdp4_overlay_format2type(req->src.format); - if (ptype < 0) { - pr_err("%s: mdp4_overlay_format2type!\n", __func__); - return ptype; - } - - if (req->flags & MDP_OV_PIPE_SHARE) - ptype = OVERLAY_TYPE_VIDEO; /* VG pipe supports both RGB+YUV */ - - if (req->id == MSMFB_NEW_REQUEST) /* new request */ - pipe = mdp4_overlay_pipe_alloc(ptype, mixer); - else - pipe = mdp4_overlay_ndx2pipe(req->id); - - if (pipe == NULL) { - pr_err("%s: pipe == NULL!\n", __func__); - return -ENOMEM; - } - - if (!display_iclient && !IS_ERR_OR_NULL(mfd->iclient)) { - display_iclient = mfd->iclient; - pr_debug("%s(): display_iclient %p\n", __func__, - display_iclient); - } - - pipe->src_format = req->src.format; - ret = mdp4_overlay_format2pipe(pipe); - - if (ret < 0) { - pr_err("%s: mdp4_overlay_format2pipe!\n", __func__); - return ret; - } - - /* - * base layer == 1, reserved for frame buffer - * zorder 0 == stage 0 == 2 - * zorder 1 == stage 1 == 3 - * zorder 2 == stage 2 == 4 - */ - if (req->id == MSMFB_NEW_REQUEST) { /* new request */ - if (mdp4_overlay_pipe_staged(pipe)) { - pr_err("%s: ndx=%d still staged\n", __func__, - pipe->pipe_ndx); - return -EPERM; - } - pipe->pipe_used++; - pipe->mixer_num = mixer; - pr_debug("%s: zorder=%d pipe ndx=%d num=%d\n", __func__, - req->z_order, pipe->pipe_ndx, pipe->pipe_num); - - } - - pipe->mixer_stage = req->z_order + MDP4_MIXER_STAGE0; - pipe->src_width = req->src.width & 0x1fff; /* source img width */ - pipe->src_height = req->src.height & 0x1fff; /* source img height */ - pipe->src_h = req->src_rect.h & 0x07ff; - pipe->src_w = req->src_rect.w & 0x07ff; - pipe->src_y = req->src_rect.y & 0x07ff; - pipe->src_x = req->src_rect.x & 0x07ff; - pipe->dst_h = req->dst_rect.h & 0x07ff; - pipe->dst_w = req->dst_rect.w & 0x07ff; - pipe->dst_y = req->dst_rect.y & 0x07ff; - pipe->dst_x = req->dst_rect.x & 0x07ff; - - pipe->op_mode = 0; - - if (req->flags & MDP_FLIP_LR) - pipe->op_mode |= MDP4_OP_FLIP_LR; - - if (req->flags & MDP_FLIP_UD) - pipe->op_mode |= MDP4_OP_FLIP_UD; - - if (req->flags & MDP_DITHER) - pipe->op_mode |= MDP4_OP_DITHER_EN; - - if (req->flags & MDP_DEINTERLACE) - pipe->op_mode |= MDP4_OP_DEINT_EN; - - if (req->flags & MDP_DEINTERLACE_ODD) - pipe->op_mode |= MDP4_OP_DEINT_ODD_REF; - - pipe->is_fg = req->is_fg;/* control alpha and color key */ - - pipe->alpha = req->alpha & 0x0ff; - - pipe->transp = req->transp_mask; - - pipe->flags = req->flags; - - *ppipe = pipe; - - return 0; -} - -static int mdp4_calc_pipe_mdp_clk(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe) -{ - u32 pclk; - u32 xscale, yscale; - u32 hsync = 0; - u32 shift = 16; - u64 rst; - int ret = -EINVAL; - - if (!pipe) { - pr_err("%s: pipe is null!\n", __func__); - return ret; - } - if (!mfd) { - pr_err("%s: mfd is null!\n", __func__); - return ret; - } - - pr_debug("%s: pipe sets: panel res(x,y)=(%d,%d)\n", - __func__, mfd->panel_info.xres, mfd->panel_info.yres); - pr_debug("%s: src(w,h)(%d,%d),src(x,y)(%d,%d)\n", - __func__, pipe->src_w, pipe->src_h, pipe->src_x, pipe->src_y); - pr_debug("%s: dst(w,h)(%d,%d),dst(x,y)(%d,%d)\n", - __func__, pipe->dst_w, pipe->dst_h, pipe->dst_x, pipe->dst_y); - - pclk = (mfd->panel_info.type == MIPI_VIDEO_PANEL || - mfd->panel_info.type == MIPI_CMD_PANEL) ? - mfd->panel_info.mipi.dsi_pclk_rate : - mfd->panel_info.clk_rate; - - if (mfd->panel_info.type == LVDS_PANEL && - mfd->panel_info.lvds.channel_mode == LVDS_DUAL_CHANNEL_MODE) - pclk = pclk << 1; - - if (!pclk) { - pipe->req_clk = mdp_max_clk; - pr_err("%s panel pixel clk is zero!\n", __func__); - return ret; - } - pr_debug("%s: mdp panel pixel clk is %d.\n", - __func__, pclk); - - if (!pipe->dst_h) { - pr_err("%s: pipe dst_h is zero!\n", __func__); - pipe->req_clk = mdp_max_clk; - return ret; - } - - if (!pipe->src_h) { - pr_err("%s: pipe src_h is zero!\n", __func__); - pipe->req_clk = mdp_max_clk; - return ret; - } - - if (!pipe->dst_w) { - pr_err("%s: pipe dst_w is zero!\n", __func__); - pipe->req_clk = mdp_max_clk; - return ret; - } - - if (!pipe->dst_h) { - pr_err("%s: pipe dst_h is zero!\n", __func__); - pipe->req_clk = mdp_max_clk; - return ret; - } - - /* - * For the scaling cases, make more margin by removing porch - * values and adding extra 20%. - */ - if ((pipe->src_h != pipe->dst_h) || - (pipe->src_w != pipe->dst_w)) { - hsync = mfd->panel_info.xres; - hsync *= 100; - hsync /= 120; - pr_debug("%s: panel hsync is %d. with scaling\n", - __func__, hsync); - - } else { - hsync = mfd->panel_info.lcdc.h_back_porch + - mfd->panel_info.lcdc.h_front_porch + - mfd->panel_info.lcdc.h_pulse_width + - mfd->panel_info.xres; - pr_debug("%s: panel hsync is %d.\n", - __func__, hsync); - } - - if (!hsync) { - pipe->req_clk = mdp_max_clk; - pr_err("%s: panel hsync is zero!\n", __func__); - return 0; - } - - xscale = mfd->panel_info.xres; - xscale += pipe->src_w; - - if (xscale < pipe->dst_w) { - pipe->req_clk = mdp_max_clk; - pr_err("%s: xres+src_w cannot be less than dst_w!\n", - __func__); - return ret; - } - - xscale -= pipe->dst_w; - xscale <<= shift; - xscale /= hsync; - pr_debug("%s: the right %d shifted xscale is %d.\n", - __func__, shift, xscale); - - if (pipe->src_h > pipe->dst_h) { - yscale = pipe->src_h; - yscale <<= shift; - yscale /= pipe->dst_h; - } else { /* upscale */ - yscale = pipe->dst_h; - yscale <<= shift; - yscale /= pipe->src_h; - } - - yscale *= pipe->src_w; - yscale /= hsync; - - pr_debug("%s: the right %d shifted yscale is %d.\n", - __func__, shift, yscale); - - rst = pclk; - if (yscale > xscale) - rst *= yscale; - else - rst *= xscale; - - rst >>= shift; - - /* - * There is one special case for the panels that have low - * v_back_porch (<=4), mdp clk should be fast enough to buffer - * 4 lines input during back porch time if scaling is - * required(FIR). - */ - if ((mfd->panel_info.lcdc.v_back_porch <= 4) && - (pipe->src_h != pipe->dst_h) && - (mfd->panel_info.lcdc.v_back_porch)) { - u32 clk = 0; - clk = 4 * (pclk >> shift) / mfd->panel_info.lcdc.v_back_porch; - clk <<= shift; - pr_debug("%s: mdp clk rate %d based on low vbp %d\n", - __func__, clk, mfd->panel_info.lcdc.v_back_porch); - rst = (rst > clk) ? rst : clk; - } - - /* - * If the calculated mdp clk is less than panel pixel clk, - * most likely due to upscaling, mdp clk rate will be set to - * greater than pclk. Now the driver uses 1.15 as the - * factor. Ideally this factor is passed from board file. - */ - if (rst < pclk) { - rst = ((pclk >> shift) * 23 / 20) << shift; - pr_debug("%s calculated mdp clk is less than pclk.\n", - __func__); - } - - /* - * Interlaced videos require the max mdp clk but cannot - * be explained by mdp clk equation. - */ - if (pipe->flags & MDP_DEINTERLACE) { - rst = (rst > mdp_max_clk) ? rst : mdp_max_clk; - pr_info("%s deinterlace requires max mdp clk.\n", - __func__); - } - - pipe->req_clk = (u32) rst; - - pr_debug("%s: required mdp clk %d mixer %d pipe ndx %d\n", - __func__, pipe->req_clk, pipe->mixer_num, pipe->pipe_ndx); - - return 0; -} - -static int mdp4_calc_pipe_mdp_bw(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe) -{ - u32 fps; - int ret = -EINVAL; - u32 quota; - u32 shift = 16; - - if (!pipe) { - pr_err("%s: pipe is null!\n", __func__); - return ret; - } - if (!mfd) { - pr_err("%s: mfd is null!\n", __func__); - return ret; - } - - fps = mdp_get_panel_framerate(mfd); - quota = pipe->src_w * pipe->src_h * fps * pipe->bpp; - - quota >>= shift; - /* factor 1.15 for ab */ - pipe->bw_ab_quota = quota * MDP4_BW_AB_FACTOR / 100; - /* factor 1.25 for ib */ - pipe->bw_ib_quota = quota * MDP4_BW_IB_FACTOR / 100; - /* down scaling factor for ib */ - if ((!pipe->dst_h) && (!pipe->src_h) && - (pipe->src_h > pipe->dst_h)) { - u64 ib = quota; - ib *= pipe->src_h; - ib /= pipe->dst_h; - pipe->bw_ib_quota = max(ib, pipe->bw_ib_quota); - pr_debug("%s: src_h=%d dst_h=%d mdp ib %llu, ib_quota=%llu\n", - __func__, pipe->src_h, pipe->dst_h, - ib<bw_ib_quota<bw_ab_quota <<= shift; - pipe->bw_ib_quota <<= shift; - - pr_debug("%s: pipe ndx=%d src(h,w)(%d, %d) fps=%d bpp=%d\n", - __func__, pipe->pipe_ndx, pipe->src_h, pipe->src_w, - fps, pipe->bpp); - pr_debug("%s: ab_quota=%llu ib_quota=%llu\n", __func__, - pipe->bw_ab_quota, pipe->bw_ib_quota); - - return 0; -} - -int mdp4_calc_blt_mdp_bw(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe) -{ - struct mdp4_overlay_perf *perf_req = &perf_request; - u32 fps; - int bpp; - int ret = -EINVAL; - u32 quota; - u32 shift = 16; - if (!pipe) { - pr_err("%s: pipe is null!\n", __func__); - return ret; - } - if (!mfd) { - pr_err("%s: mfd is null!\n", __func__); - return ret; - } - - bpp = BLT_BPP; - fps = mdp_get_panel_framerate(mfd); - - /* read and write bw*/ - quota = pipe->dst_w * pipe->dst_h * fps * bpp * 2; - quota >>= shift; - - perf_req->mdp_ov_ab_bw[pipe->mixer_num] = - quota * MDP4_BW_AB_FACTOR / 100; - - perf_req->mdp_ov_ib_bw[pipe->mixer_num] = - quota * MDP4_BW_IB_FACTOR / 100; - - perf_req->mdp_ov_ab_bw[pipe->mixer_num] <<= shift; - perf_req->mdp_ov_ib_bw[pipe->mixer_num] <<= shift; - - pr_debug("%s: pipe ndx=%d dst(h,w)(%d, %d) fps=%d bpp=%d\n", - __func__, pipe->pipe_ndx, pipe->dst_h, pipe->dst_w, - fps, bpp); - pr_debug("%s: overlay=%d ab_bw=%llu ib_bw=%llu\n", __func__, - pipe->mixer_num, - perf_req->mdp_ov_ab_bw[pipe->mixer_num], - perf_req->mdp_ov_ib_bw[pipe->mixer_num]); - - return 0; -} - -int mdp4_overlay_mdp_perf_req(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *plist) -{ - u32 worst_mdp_clk = 0; - int i; - struct mdp4_overlay_perf *perf_req = &perf_request; - struct mdp4_overlay_pipe *pipe = plist; - u32 cnt = 0; - int ret = -EINVAL; - u64 ab_quota_total = 0, ib_quota_total = 0; - - if (!mfd) { - pr_err("%s: mfd is null!\n", __func__); - return ret; - } - - if (!plist) { - pr_err("%s: plist is null!\n", __func__); - return ret; - } - - for (i = 0; i < MDP4_MIXER_MAX; i++) - perf_req->use_ov_blt[i] = 0; - - for (i = 0; i < OVERLAY_PIPE_MAX; i++, pipe++) { - - if (!pipe) - return ret; - - if (!pipe->pipe_used) - continue; - cnt++; - if (worst_mdp_clk < pipe->req_clk) - worst_mdp_clk = pipe->req_clk; - - if (pipe->req_clk > mdp_max_clk) - perf_req->use_ov_blt[pipe->mixer_num] = 1; - - if (pipe->mixer_num == MDP4_MIXER2) - perf_req->use_ov_blt[MDP4_MIXER2] = 1; - - if (pipe->pipe_type != OVERLAY_TYPE_BF) { - ab_quota_total += pipe->bw_ab_quota; - ib_quota_total += pipe->bw_ib_quota; - } - - if (mfd->mdp_rev == MDP_REV_41) { - /* - * writeback (blt) mode to provide work around - * for dsi cmd mode interface hardware bug. - */ - if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) { - if (pipe->dst_x != 0) - perf_req->use_ov_blt[MDP4_MIXER0] = 1; - } - if ((mfd->panel_info.xres > 1280) && - (mfd->panel_info.type != DTV_PANEL)) { - perf_req->use_ov_blt[MDP4_MIXER0] = 1; - } - } - } - - perf_req->mdp_clk_rate = min(worst_mdp_clk, mdp_max_clk); - perf_req->mdp_clk_rate = mdp_clk_round_rate(perf_req->mdp_clk_rate); - - for (i = 0; i < MDP4_MIXER_MAX; i++) { - if (perf_req->use_ov_blt[i]) { - ab_quota_total += perf_req->mdp_ov_ab_bw[i]; - ib_quota_total += perf_req->mdp_ov_ib_bw[i]; - } - } - - perf_req->mdp_ab_bw = roundup(ab_quota_total, MDP_BUS_SCALE_AB_STEP); - perf_req->mdp_ib_bw = roundup(ib_quota_total, MDP_BUS_SCALE_AB_STEP); - - pr_debug("%s %d: ab_quota_total=(%llu, %d) ib_quota_total=(%llu, %d)\n", - __func__, __LINE__, - ab_quota_total, perf_req->mdp_ab_bw, - ib_quota_total, perf_req->mdp_ib_bw); - - if (ab_quota_total > mdp_max_bw) - pr_warn("%s: req ab bw=%llu is larger than max bw=%llu", - __func__, ab_quota_total, mdp_max_bw); - if (ib_quota_total > mdp_max_bw) - pr_warn("%s: req ib bw=%llu is larger than max bw=%llu", - __func__, ib_quota_total, mdp_max_bw); - - pr_debug("%s %d: pid %d cnt %d clk %d ov0_blt %d, ov1_blt %d\n", - __func__, __LINE__, current->pid, cnt, - perf_req->mdp_clk_rate, - perf_req->use_ov_blt[0], - perf_req->use_ov_blt[1]); - - return 0; -} - -int mdp4_overlay_mdp_pipe_req(struct mdp4_overlay_pipe *pipe, - struct msm_fb_data_type *mfd) -{ - int ret = 0; - - if (mdp4_calc_pipe_mdp_clk(mfd, pipe)) { - pr_err("%s unable to calc mdp pipe clk rate ret=%d\n", - __func__, ret); - ret = -EINVAL; - } - if (mdp4_calc_pipe_mdp_bw(mfd, pipe)) { - pr_err("%s unable to calc mdp pipe bandwidth ret=%d\n", - __func__, ret); - ret = -EINVAL; - } - return ret; -} - -void mdp4_overlay_mdp_perf_upd(struct msm_fb_data_type *mfd, - int flag) -{ - struct mdp4_overlay_perf *perf_req = &perf_request; - struct mdp4_overlay_perf *perf_cur = &perf_current; - - pr_debug("%s %d: req mdp clk %d, cur mdp clk %d flag %d\n", - __func__, __LINE__, - perf_req->mdp_clk_rate, - perf_cur->mdp_clk_rate, - flag); - - if (!mdp4_extn_disp) - perf_cur->use_ov_blt[1] = 0; - - if (flag) { - if (perf_req->mdp_clk_rate > perf_cur->mdp_clk_rate) { - mdp_set_core_clk(perf_req->mdp_clk_rate); - pr_info("%s mdp clk is changed [%d] from %d to %d\n", - __func__, - flag, - perf_cur->mdp_clk_rate, - perf_req->mdp_clk_rate); - perf_cur->mdp_clk_rate = - perf_req->mdp_clk_rate; - } - if ((perf_req->mdp_ab_bw > perf_cur->mdp_ab_bw) || - (perf_req->mdp_ib_bw > perf_cur->mdp_ib_bw)) { - mdp_bus_scale_update_request - (perf_req->mdp_ab_bw, perf_req->mdp_ib_bw); - pr_debug("%s mdp ab_bw is changed [%d] from %d to %d\n", - __func__, - flag, - perf_cur->mdp_ab_bw, - perf_req->mdp_ab_bw); - pr_debug("%s mdp ib_bw is changed [%d] from %d to %d\n", - __func__, - flag, - perf_cur->mdp_ib_bw, - perf_req->mdp_ib_bw); - perf_cur->mdp_ab_bw = perf_req->mdp_ab_bw; - perf_cur->mdp_ib_bw = perf_req->mdp_ib_bw; - } - - if ((mfd->panel_info.pdest == DISPLAY_1 && - perf_req->use_ov_blt[0] && !perf_cur->use_ov_blt[0]) || - dbg_force_ov0_blt) { - if (mfd->panel_info.type == LCDC_PANEL || - mfd->panel_info.type == LVDS_PANEL) - mdp4_lcdc_overlay_blt_start(mfd); - else if (mfd->panel_info.type == MIPI_VIDEO_PANEL) - mdp4_dsi_video_blt_start(mfd); - else if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - mdp4_dsi_cmd_blt_start(mfd); - else if (ctrl->panel_mode & MDP4_PANEL_MDDI) - mdp4_mddi_blt_start(mfd); - pr_debug("%s mixer0 start blt [%d] from %d to %d.\n", - __func__, - flag, - perf_cur->use_ov_blt[0], - perf_req->use_ov_blt[0]); - perf_cur->use_ov_blt[0] = perf_req->use_ov_blt[0]; - } - if ((mfd->panel_info.pdest == DISPLAY_2 && - perf_req->use_ov_blt[1] && !perf_cur->use_ov_blt[1]) || - dbg_force_ov1_blt) { - mdp4_dtv_overlay_blt_start(mfd); - pr_debug("%s mixer1 start blt [%d] from %d to %d.\n", - __func__, - flag, - perf_cur->use_ov_blt[1], - perf_req->use_ov_blt[1]); - perf_cur->use_ov_blt[1] = perf_req->use_ov_blt[1]; - } - } else { - if (perf_req->mdp_clk_rate < perf_cur->mdp_clk_rate) { - pr_info("%s mdp clk is changed [%d] from %d to %d\n", - __func__, - flag, - perf_cur->mdp_clk_rate, - perf_req->mdp_clk_rate); - mdp_set_core_clk(perf_req->mdp_clk_rate); - perf_cur->mdp_clk_rate = - perf_req->mdp_clk_rate; - } - if (perf_req->mdp_ab_bw < perf_cur->mdp_ab_bw || - perf_req->mdp_ib_bw < perf_cur->mdp_ib_bw) { - mdp_bus_scale_update_request - (perf_req->mdp_ab_bw, perf_req->mdp_ib_bw); - pr_debug("%s mdp ab bw is changed [%d] from %d to %d\n", - __func__, - flag, - perf_cur->mdp_ab_bw, - perf_req->mdp_ab_bw); - pr_debug("%s mdp ib bw is changed [%d] from %d to %d\n", - __func__, - flag, - perf_cur->mdp_ib_bw, - perf_req->mdp_ib_bw); - perf_cur->mdp_ab_bw = perf_req->mdp_ab_bw; - perf_cur->mdp_ib_bw = perf_req->mdp_ib_bw; - } - if ((mfd->panel_info.pdest == DISPLAY_1 && - !perf_req->use_ov_blt[0] && perf_cur->use_ov_blt[0]) || - dbg_force_ov0_blt) { - if (mfd->panel_info.type == LCDC_PANEL || - mfd->panel_info.type == LVDS_PANEL) - mdp4_lcdc_overlay_blt_stop(mfd); - else if (mfd->panel_info.type == MIPI_VIDEO_PANEL) - mdp4_dsi_video_blt_stop(mfd); - else if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - mdp4_dsi_cmd_blt_stop(mfd); - else if (ctrl->panel_mode & MDP4_PANEL_MDDI) - mdp4_mddi_blt_stop(mfd); - pr_debug("%s mixer0 stop blt [%d] from %d to %d.\n", - __func__, - flag, - perf_cur->use_ov_blt[0], - perf_req->use_ov_blt[0]); - perf_cur->use_ov_blt[0] = perf_req->use_ov_blt[0]; - } - if ((mfd->panel_info.pdest == DISPLAY_2 && - !perf_req->use_ov_blt[1] && perf_cur->use_ov_blt[1]) || - dbg_force_ov1_blt) { - mdp4_dtv_overlay_blt_stop(mfd); - pr_debug("%s mixer1 stop blt [%d] from %d to %d.\n", - __func__, - flag, - perf_cur->use_ov_blt[1], - perf_req->use_ov_blt[1]); - perf_cur->use_ov_blt[1] = perf_req->use_ov_blt[1]; - } - } - return; -} - -static int get_img(struct msmfb_data *img, struct fb_info *info, - struct mdp4_overlay_pipe *pipe, unsigned int plane, - unsigned long *start, unsigned long *len, struct file **srcp_file, - int *p_need, struct ion_handle **srcp_ihdl) -{ - struct file *file; - int put_needed, ret = 0, fb_num; - *p_need = 0; - - if (img->flags & MDP_BLIT_SRC_GEM) { - *srcp_file = NULL; - return kgsl_gem_obj_addr(img->memory_id, (int) img->priv, - start, len); - } - - if (img->flags & MDP_MEMORY_ID_TYPE_FB) { - file = fget_light(img->memory_id, &put_needed); - if (file == NULL) - return -EINVAL; - - pipe->flags |= MDP_MEMORY_ID_TYPE_FB; - if (MAJOR(file->f_dentry->d_inode->i_rdev) == FB_MAJOR) { - fb_num = MINOR(file->f_dentry->d_inode->i_rdev); - if (get_fb_phys_info(start, len, fb_num, - DISPLAY_SUBSYSTEM_ID)) { - ret = -1; - } else { - *srcp_file = file; - *p_need = put_needed; - } - } else - ret = -1; - if (ret) - fput_light(file, put_needed); - return ret; - } - -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - return mdp4_overlay_iommu_map_buf(img->memory_id, pipe, plane, - start, len, srcp_ihdl); -#endif -} - -#ifdef CONFIG_FB_MSM_MIPI_DSI -int mdp4_overlay_3d_sbys(struct fb_info *info, struct msmfb_overlay_3d *req) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - int ret = -EPERM; - - if (mutex_lock_interruptible(&mfd->dma->ov_mutex)) - return -EINTR; - - if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) { - mdp4_dsi_cmd_3d_sbys(mfd, req); - ret = 0; - } else if (ctrl->panel_mode & MDP4_PANEL_DSI_VIDEO) { - mdp4_dsi_video_3d_sbys(mfd, req); - ret = 0; - } - mutex_unlock(&mfd->dma->ov_mutex); - - return ret; -} -#else -int mdp4_overlay_3d_sbys(struct fb_info *info, struct msmfb_overlay_3d *req) -{ - /* do nothing */ - return -EPERM; -} -#endif - -int mdp4_overlay_blt(struct fb_info *info, struct msmfb_overlay_blt *req) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - - if (mfd == NULL) - return -ENODEV; - - if (mutex_lock_interruptible(&mfd->dma->ov_mutex)) - return -EINTR; - - if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - mdp4_dsi_cmd_overlay_blt(mfd, req); - else if (ctrl->panel_mode & MDP4_PANEL_DSI_VIDEO) - mdp4_dsi_video_overlay_blt(mfd, req); - else if (ctrl->panel_mode & MDP4_PANEL_LCDC) - mdp4_lcdc_overlay_blt(mfd, req); - else if (ctrl->panel_mode & MDP4_PANEL_MDDI) - mdp4_mddi_overlay_blt(mfd, req); - - mutex_unlock(&mfd->dma->ov_mutex); - - return 0; -} - -int mdp4_overlay_get(struct fb_info *info, struct mdp_overlay *req) -{ - struct mdp4_overlay_pipe *pipe; - - pipe = mdp4_overlay_ndx2pipe(req->id); - if (pipe == NULL) - return -ENODEV; - - *req = pipe->req_data; - - if (mdp4_overlay_borderfill_supported()) - req->flags |= MDP_BORDERFILL_SUPPORTED; - - return 0; -} - -int mdp4_overlay_set(struct fb_info *info, struct mdp_overlay *req) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - int ret, mixer; - struct mdp4_overlay_pipe *pipe; - - if (mfd == NULL) { - pr_err("%s: mfd == NULL, -ENODEV\n", __func__); - return -ENODEV; - } - - if (info->node != 0 || mfd->cont_splash_done) /* primary */ - if (!mfd->panel_power_on) /* suspended */ - return -EPERM; - - if (req->src.format == MDP_FB_FORMAT) - req->src.format = mfd->fb_imgType; - - if (mutex_lock_interruptible(&mfd->dma->ov_mutex)) { - pr_err("%s: mutex_lock_interruptible, -EINTR\n", __func__); - return -EINTR; - } - - mixer = mfd->panel_info.pdest; /* DISPLAY_1 or DISPLAY_2 */ - - ret = mdp4_overlay_req2pipe(req, mixer, &pipe, mfd); - - if (ret < 0) { - mutex_unlock(&mfd->dma->ov_mutex); - pr_err("%s: mdp4_overlay_req2pipe, ret=%d\n", __func__, ret); - return ret; - } - - /* return id back to user */ - req->id = pipe->pipe_ndx; /* pipe_ndx start from 1 */ - pipe->req_data = *req; /* keep original req */ - - if (!IS_ERR_OR_NULL(mfd->iclient)) { - pr_debug("pipe->flags 0x%x\n", pipe->flags); - if (pipe->flags & MDP_SECURE_OVERLAY_SESSION) { - mfd->mem_hid &= ~BIT(ION_IOMMU_HEAP_ID); - mfd->mem_hid |= ION_FLAG_SECURE; - } else { - mfd->mem_hid |= BIT(ION_IOMMU_HEAP_ID); - mfd->mem_hid &= ~ION_FLAG_SECURE; - } - } - - mdp4_stat.overlay_set[pipe->mixer_num]++; - - if (pipe->flags & MDP_OVERLAY_PP_CFG_EN) { - if (pipe->pipe_num <= OVERLAY_PIPE_VG2) - memcpy(&pipe->pp_cfg, &req->overlay_pp_cfg, - sizeof(struct mdp_overlay_pp_params)); - else - pr_debug("%s: RGB Pipes don't support CSC/QSEED\n", - __func__); - } - - mdp4_overlay_mdp_pipe_req(pipe, mfd); - - mutex_unlock(&mfd->dma->ov_mutex); - - return 0; -} - -int mdp4_overlay_unset_mixer(int mixer) -{ - struct mdp4_overlay_pipe *pipe; - struct mdp4_overlay_pipe *orgpipe; - int i, cnt = 0; - - /* free pipe besides base layer pipe */ - for (i = MDP4_MIXER_STAGE3; i > MDP4_MIXER_STAGE_BASE; i--) { - pipe = ctrl->stage[mixer][i]; - if (pipe == NULL) - continue; - pipe->flags &= ~MDP_OV_PLAY_NOWAIT; - mdp4_overlay_reg_flush(pipe, 1); - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - /*Clear real pipe attributes as well */ - orgpipe = mdp4_overlay_ndx2pipe(pipe->pipe_ndx); - if (orgpipe != NULL) - orgpipe->pipe_used = 0; - cnt++; - } - - return cnt; -} - -int mdp4_overlay_unset(struct fb_info *info, int ndx) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct mdp4_overlay_pipe *pipe; - - if (mfd == NULL) - return -ENODEV; - - if (mutex_lock_interruptible(&mfd->dma->ov_mutex)) - return -EINTR; - - pipe = mdp4_overlay_ndx2pipe(ndx); - - if (pipe == NULL) { - mutex_unlock(&mfd->dma->ov_mutex); - return -ENODEV; - } - - if (pipe->pipe_type == OVERLAY_TYPE_BF) { - mdp4_overlay_borderfill_stage_down(pipe); - mutex_unlock(&mfd->dma->ov_mutex); - return 0; - } - - if (pipe->mixer_num == MDP4_MIXER2) - ctrl->mixer2_played = 0; - else if (pipe->mixer_num == MDP4_MIXER1) - ctrl->mixer1_played = 0; - else { - /* mixer 0 */ - ctrl->mixer0_played = 0; - - } - - mdp4_overlay_reg_flush(pipe, 1); - mdp4_mixer_stage_down(pipe, 0); - - if (pipe->mixer_num == MDP4_MIXER0) { - - } else { /* mixer1, DTV, ATV */ - if (ctrl->panel_mode & MDP4_PANEL_DTV) { - if (hdmi_prim_display) { - struct mdp4_overlay_pipe *pp; - pp = &ctrl->sf_plist[pipe->mixer_num] - [pipe->pipe_ndx - 1]; - *pp = *pipe; /* clone it */ - pp->solid_fill = 1; - } - mdp4_overlay_dtv_unset(mfd, pipe); - } - } - - mdp4_stat.overlay_unset[pipe->mixer_num]++; - - mdp4_overlay_pipe_free(pipe); - - mutex_unlock(&mfd->dma->ov_mutex); - - return 0; -} - -int mdp4_overlay_wait4vsync(struct fb_info *info, long long *vtime) -{ - if (!hdmi_prim_display && info->node == 0) { - if (ctrl->panel_mode & MDP4_PANEL_DSI_VIDEO) - mdp4_dsi_video_wait4vsync(0, vtime); - else if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - mdp4_dsi_cmd_wait4vsync(0, vtime); - else if (ctrl->panel_mode & MDP4_PANEL_LCDC) - mdp4_lcdc_wait4vsync(0, vtime); - else if (ctrl->panel_mode & MDP4_PANEL_MDDI) - mdp4_mddi_wait4vsync(0, vtime); - } else if (hdmi_prim_display || info->node == 1) { - mdp4_dtv_wait4vsync(0, vtime); - } - - return 0; -} - -int mdp4_overlay_vsync_ctrl(struct fb_info *info, int enable) -{ - int cmd; - - if (enable) - cmd = 1; - else - cmd = 0; - - if (!hdmi_prim_display && info->node == 0) { - if (ctrl->panel_mode & MDP4_PANEL_DSI_VIDEO) - mdp4_dsi_video_vsync_ctrl(info, cmd); - else if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) - mdp4_dsi_cmd_vsync_ctrl(info, cmd); - else if (ctrl->panel_mode & MDP4_PANEL_LCDC) - mdp4_lcdc_vsync_ctrl(info, cmd); - else if (ctrl->panel_mode & MDP4_PANEL_MDDI) - mdp4_mddi_vsync_ctrl(info, cmd); - } else if (hdmi_prim_display || info->node == 1) - mdp4_dtv_vsync_ctrl(info, cmd); - - return 0; -} - - -struct tile_desc { - uint32 width; /* tile's width */ - uint32 height; /* tile's height */ - uint32 row_tile_w; /* tiles per row's width */ - uint32 row_tile_h; /* tiles per row's height */ -}; - -void tile_samsung(struct tile_desc *tp) -{ - /* - * each row of samsung tile consists of two tiles in height - * and two tiles in width which means width should align to - * 64 x 2 bytes and height should align to 32 x 2 bytes. - * video decoder generate two tiles in width and one tile - * in height which ends up height align to 32 X 1 bytes. - */ - tp->width = 64; /* 64 bytes */ - tp->row_tile_w = 2; /* 2 tiles per row's width */ - tp->height = 32; /* 32 bytes */ - tp->row_tile_h = 1; /* 1 tiles per row's height */ -} - -uint32 tile_mem_size(struct mdp4_overlay_pipe *pipe, struct tile_desc *tp) -{ - uint32 tile_w, tile_h; - uint32 row_num_w, row_num_h; - - - tile_w = tp->width * tp->row_tile_w; - tile_h = tp->height * tp->row_tile_h; - - row_num_w = (pipe->src_width + tile_w - 1) / tile_w; - row_num_h = (pipe->src_height + tile_h - 1) / tile_h; - return ((row_num_w * row_num_h * tile_w * tile_h) + 8191) & ~8191; -} - -int mdp4_overlay_play_wait(struct fb_info *info, struct msmfb_overlay_data *req) -{ - return 0; -} - -/* - * mdp4_overlay_dma_commit: called from dma_done isr - * No mutex/sleep allowed - */ -void mdp4_overlay_dma_commit(int mixer) -{ - /* - * non double buffer register update here - * perf level, new clock rate should be done here - */ -} - -/* - * mdp4_overlay_vsync_commit: called from tasklet context - * No mutex/sleep allowed - */ -void mdp4_overlay_vsync_commit(struct mdp4_overlay_pipe *pipe) -{ - if (pipe->pipe_type == OVERLAY_TYPE_VIDEO) - mdp4_overlay_vg_setup(pipe); /* video/graphic pipe */ - else - mdp4_overlay_rgb_setup(pipe); /* rgb pipe */ - - pr_debug("%s: pipe=%x ndx=%d num=%d used=%d\n", __func__, - (int) pipe, pipe->pipe_ndx, pipe->pipe_num, pipe->pipe_used); - mdp4_overlay_reg_flush(pipe, 1); - mdp4_mixer_stage_up(pipe, 0); -} - -int mdp4_overlay_play(struct fb_info *info, struct msmfb_overlay_data *req) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct msmfb_data *img; - struct mdp4_overlay_pipe *pipe; - ulong start, addr; - ulong len = 0; - struct ion_handle *srcp0_ihdl = NULL; - struct ion_handle *srcp1_ihdl = NULL, *srcp2_ihdl = NULL; - uint32_t overlay_version = 0; - int ret = 0; - - if (mfd == NULL) - return -ENODEV; - - if (!mfd->panel_power_on) /* suspended */ - return -EPERM; - - pipe = mdp4_overlay_ndx2pipe(req->id); - if (pipe == NULL) { - mdp4_stat.err_play++; - return -ENODEV; - } - - if (pipe->pipe_type == OVERLAY_TYPE_BF) { - mdp4_overlay_borderfill_stage_up(pipe); - mdp4_mixer_stage_commit(pipe->mixer_num); - return 0; - } - - mutex_lock(&mfd->dma->ov_mutex); - - img = &req->data; - get_img(img, info, pipe, 0, &start, &len, &pipe->srcp0_file, - &pipe->put0_need, &srcp0_ihdl); - if (len == 0) { - pr_err("%s: pmem Error\n", __func__); - ret = -1; - goto end; - } - - addr = start + img->offset; - pipe->srcp0_addr = addr; - pipe->srcp0_ystride = pipe->src_width * pipe->bpp; - - - pr_debug("%s: mixer=%d ndx=%x addr=%x flags=%x pid=%d\n", __func__, - pipe->mixer_num, pipe->pipe_ndx, (int)addr, pipe->flags, - current->pid); - - if ((req->version_key & VERSION_KEY_MASK) == 0xF9E8D700) - overlay_version = (req->version_key & ~VERSION_KEY_MASK); - - if (pipe->fetch_plane == OVERLAY_PLANE_PSEUDO_PLANAR) { - if (overlay_version > 0) { - img = &req->plane1_data; - get_img(img, info, pipe, 1, &start, &len, - &pipe->srcp1_file, &pipe->put1_need, - &srcp1_ihdl); - if (len == 0) { - pr_err("%s: Error to get plane1\n", __func__); - ret = -EINVAL; - goto end; - } - pipe->srcp1_addr = start + img->offset; - } else if (pipe->frame_format == - MDP4_FRAME_FORMAT_VIDEO_SUPERTILE) { - struct tile_desc tile; - - tile_samsung(&tile); - pipe->srcp1_addr = addr + tile_mem_size(pipe, &tile); - } else { - pipe->srcp1_addr = addr + (pipe->src_width * - pipe->src_height); - } - pipe->srcp0_ystride = pipe->src_width; - if ((pipe->src_format == MDP_Y_CRCB_H1V1) || - (pipe->src_format == MDP_Y_CBCR_H1V1) || - (pipe->src_format == MDP_Y_CRCB_H1V2) || - (pipe->src_format == MDP_Y_CBCR_H1V2)) { - if (pipe->src_width > YUV_444_MAX_WIDTH) - pipe->srcp1_ystride = pipe->src_width << 2; - else - pipe->srcp1_ystride = pipe->src_width << 1; - } else - pipe->srcp1_ystride = pipe->src_width; - - } else if (pipe->fetch_plane == OVERLAY_PLANE_PLANAR) { - if (overlay_version > 0) { - img = &req->plane1_data; - get_img(img, info, pipe, 1, &start, &len, - &pipe->srcp1_file, &pipe->put1_need, - &srcp1_ihdl); - if (len == 0) { - pr_err("%s: Error to get plane1\n", __func__); - ret = -EINVAL; - goto end; - } - pipe->srcp1_addr = start + img->offset; - - img = &req->plane2_data; - get_img(img, info, pipe, 2, &start, &len, - &pipe->srcp2_file, &pipe->put2_need, - &srcp2_ihdl); - if (len == 0) { - pr_err("%s: Error to get plane2\n", __func__); - ret = -EINVAL; - goto end; - } - pipe->srcp2_addr = start + img->offset; - } else { - if (pipe->src_format == MDP_Y_CR_CB_GH2V2) { - addr += (ALIGN(pipe->src_width, 16) * - pipe->src_height); - pipe->srcp1_addr = addr; - addr += ((ALIGN((pipe->src_width / 2), 16)) * - (pipe->src_height / 2)); - pipe->srcp2_addr = addr; - } else { - addr += (pipe->src_width * pipe->src_height); - pipe->srcp1_addr = addr; - addr += ((pipe->src_width / 2) * - (pipe->src_height / 2)); - pipe->srcp2_addr = addr; - } - } - /* mdp planar format expects Cb in srcp1 and Cr in p2 */ - if ((pipe->src_format == MDP_Y_CR_CB_H2V2) || - (pipe->src_format == MDP_Y_CR_CB_GH2V2)) - swap(pipe->srcp1_addr, pipe->srcp2_addr); - - if (pipe->src_format == MDP_Y_CR_CB_GH2V2) { - pipe->srcp0_ystride = ALIGN(pipe->src_width, 16); - pipe->srcp1_ystride = ALIGN(pipe->src_width / 2, 16); - pipe->srcp2_ystride = ALIGN(pipe->src_width / 2, 16); - } else { - pipe->srcp0_ystride = pipe->src_width; - pipe->srcp1_ystride = pipe->src_width / 2; - pipe->srcp2_ystride = pipe->src_width / 2; - } - } - - mdp4_overlay_mdp_perf_req(mfd, ctrl->plist); - - if (pipe->mixer_num == MDP4_MIXER0) { - if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) { - /* cndx = 0 */ - mdp4_dsi_cmd_pipe_queue(0, pipe); - } else if (ctrl->panel_mode & MDP4_PANEL_DSI_VIDEO) { - /* cndx = 0 */ - mdp4_dsi_video_pipe_queue(0, pipe); - } else if (ctrl->panel_mode & MDP4_PANEL_LCDC) { - /* cndx = 0 */ - mdp4_lcdc_pipe_queue(0, pipe); - } - if (ctrl->panel_mode & MDP4_PANEL_MDDI) { - /* cndx = 0 */ - mdp4_mddi_pipe_queue(0, pipe); - } - } else if (pipe->mixer_num == MDP4_MIXER1) { - if (ctrl->panel_mode & MDP4_PANEL_DTV) { - mdp4_dtv_pipe_queue(0, pipe);/* cndx = 0 */ - mdp4_dtv_set_avparams(pipe, img->memory_id); - } - } else if (pipe->mixer_num == MDP4_MIXER2) { - ctrl->mixer2_played++; - if (ctrl->panel_mode & MDP4_PANEL_WRITEBACK) - mdp4_wfd_pipe_queue(0, pipe);/* cndx = 0 */ - } - - mutex_unlock(&mfd->dma->ov_mutex); - return ret; - -end: - mutex_unlock(&mfd->dma->ov_mutex); - - return ret; -} - -int mdp4_overlay_commit(struct fb_info *info) -{ - int ret = 0; - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - - if (mfd == NULL) - return -ENODEV; - - if (!mfd->panel_power_on) /* suspended */ - return -EINVAL; - - mutex_lock(&mfd->dma->ov_mutex); - - mdp4_overlay_mdp_perf_upd(mfd, 1); - - msm_fb_wait_for_fence(mfd); - - switch (mfd->panel.type) { - case MIPI_CMD_PANEL: - mdp4_dsi_cmd_pipe_commit(0, 1); - break; - case MIPI_VIDEO_PANEL: - mdp4_dsi_video_pipe_commit(0, 1); - break; - case LCDC_PANEL: - mdp4_lcdc_pipe_commit(0, 1); - break; - case DTV_PANEL: - mdp4_dtv_pipe_commit(0, 1); - break; - case WRITEBACK_PANEL: - mdp4_wfd_pipe_commit(mfd, 0, 1); - break; - default: - pr_err("Panel Not Supported for Commit"); - ret = -EINVAL; - break; - } - msm_fb_signal_timeline(mfd); - - mdp4_overlay_mdp_perf_upd(mfd, 0); - - mutex_unlock(&mfd->dma->ov_mutex); - - return ret; -} - -struct msm_iommu_ctx { - char *name; - int domain; -}; - -static struct msm_iommu_ctx msm_iommu_ctx_names[] = { - /* Display read*/ - { - .name = "mdp_port0_cb0", - .domain = DISPLAY_READ_DOMAIN, - }, - /* Display read*/ - { - .name = "mdp_port0_cb1", - .domain = DISPLAY_READ_DOMAIN, - }, - /* Display write */ - { - .name = "mdp_port1_cb0", - .domain = DISPLAY_READ_DOMAIN, - }, - /* Display write */ - { - .name = "mdp_port1_cb1", - .domain = DISPLAY_READ_DOMAIN, - }, -}; - -static struct msm_iommu_ctx msm_iommu_split_ctx_names[] = { - /* Display read*/ - { - .name = "mdp_port0_cb0", - .domain = DISPLAY_READ_DOMAIN, - }, - /* Display read*/ - { - .name = "mdp_port0_cb1", - .domain = DISPLAY_WRITE_DOMAIN, - }, - /* Display write */ - { - .name = "mdp_port1_cb0", - .domain = DISPLAY_READ_DOMAIN, - }, - /* Display write */ - { - .name = "mdp_port1_cb1", - .domain = DISPLAY_WRITE_DOMAIN, - }, -}; - -void mdp4_iommu_attach(void) -{ - static int done; - struct msm_iommu_ctx *ctx_names; - struct iommu_domain *domain; - int i, arr_size; - - if (!done) { - if (mdp_iommu_split_domain) { - ctx_names = msm_iommu_split_ctx_names; - arr_size = ARRAY_SIZE(msm_iommu_split_ctx_names); - } else { - ctx_names = msm_iommu_ctx_names; - arr_size = ARRAY_SIZE(msm_iommu_ctx_names); - } - - for (i = 0; i < arr_size; i++) { - int domain_idx; - struct device *ctx = msm_iommu_get_ctx( - ctx_names[i].name); - - if (!ctx) - continue; - - domain_idx = ctx_names[i].domain; - - domain = msm_get_iommu_domain(domain_idx); - if (!domain) - continue; - - if (iommu_attach_device(domain, ctx)) { - WARN(1, "%s: could not attach domain %d to context %s." - " iommu programming will not occur.\n", - __func__, domain_idx, - ctx_names[i].name); - continue; - } - } - done = 1; - } -} - -int mdp4_v4l2_overlay_set(struct fb_info *info, struct mdp_overlay *req, - struct mdp4_overlay_pipe **ppipe) -{ - struct mdp4_overlay_pipe *pipe; - int err; - struct msm_fb_data_type *mfb = info->par; - - req->z_order = 0; - req->id = MSMFB_NEW_REQUEST; - req->is_fg = false; - req->alpha = 0xff; - err = mdp4_overlay_req2pipe(req, MDP4_MIXER0, &pipe, mfb); - if (err < 0) { - pr_err("%s:Could not allocate MDP overlay pipe\n", __func__); - return err; - } - - mdp4_mixer_blend_setup(pipe->mixer_num); - *ppipe = pipe; - - return 0; -} - -void mdp4_v4l2_overlay_clear(struct mdp4_overlay_pipe *pipe) -{ - mdp4_overlay_reg_flush(pipe, 1); - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); -} - -int mdp4_v4l2_overlay_play(struct fb_info *info, struct mdp4_overlay_pipe *pipe, - unsigned long srcp0_addr, unsigned long srcp1_addr, - unsigned long srcp2_addr) -{ - struct msm_fb_data_type *mfd = info->par; - int err; - - if (mutex_lock_interruptible(&mfd->dma->ov_mutex)) - return -EINTR; - - switch (pipe->src_format) { - case MDP_Y_CR_CB_H2V2: - /* YUV420 */ - pipe->srcp0_addr = srcp0_addr; - pipe->srcp0_ystride = pipe->src_width; - /* - * For YUV420, the luma plane is 1 byte per pixel times - * num of pixels in the image Also, the planes are - * switched in MDP, srcp2 is actually first chroma plane - */ - pipe->srcp2_addr = srcp1_addr ? srcp1_addr : - pipe->srcp0_addr + (pipe->src_width * pipe->src_height); - pipe->srcp2_ystride = pipe->src_width/2; - /* - * The chroma planes are half the size of the luma - * planes - */ - pipe->srcp1_addr = srcp2_addr ? srcp2_addr : - pipe->srcp2_addr + - (pipe->src_width * pipe->src_height / 4); - pipe->srcp1_ystride = pipe->src_width/2; - break; - case MDP_Y_CRCB_H2V2: - /* NV12 */ - pipe->srcp0_addr = srcp0_addr; - pipe->srcp0_ystride = pipe->src_width; - pipe->srcp1_addr = srcp1_addr ? srcp1_addr : - pipe->srcp0_addr + - (pipe->src_width * pipe->src_height); - pipe->srcp1_ystride = pipe->src_width; - break; - default: - pr_err("%s: format (%u) is not supported\n", __func__, - pipe->src_format); - err = -EINVAL; - goto done; - } - - pr_debug("%s: pipe ndx=%d stage=%d format=%x\n", __func__, - pipe->pipe_ndx, pipe->mixer_stage, pipe->src_format); - - if (pipe->pipe_type == OVERLAY_TYPE_VIDEO) - mdp4_overlay_vg_setup(pipe); - else - mdp4_overlay_rgb_setup(pipe); - - if (ctrl->panel_mode & MDP4_PANEL_LCDC) - mdp4_overlay_reg_flush(pipe, 1); - - mdp4_mixer_stage_up(pipe, 0); /* mixer stage commit commits this */ - mdp4_mixer_stage_commit(pipe->mixer_num); - -#ifdef V4L2_VSYNC - /* - * TODO: incorporate v4l2 into vsycn driven mechanism - */ - if (ctrl->panel_mode & MDP4_PANEL_LCDC) { - mdp4_overlay_lcdc_vsync_push(mfd, pipe); - } else { -#ifdef CONFIG_FB_MSM_MIPI_DSI - if (ctrl->panel_mode & MDP4_PANEL_DSI_CMD) { - mdp4_dsi_cmd_dma_busy_wait(mfd); - mdp4_dsi_cmd_kickoff_video(mfd, pipe); - } -#else - if (ctrl->panel_mode & MDP4_PANEL_MDDI) { - mdp4_mddi_dma_busy_wait(mfd); - mdp4_mddi_kickoff_video(mfd, pipe); - } -#endif - } -#endif - -done: - mutex_unlock(&mfd->dma->ov_mutex); - return err; -} - -int mdp4_update_writeback_format(struct msm_fb_data_type *mfd, - struct mdp_mixer_cfg *mdp_mixer_cfg) -{ - int ret = 0; - u32 mixer_num; - struct mdp_mixer_cfg *mixer; - - mixer_num = mdp4_get_mixer_num(mfd->panel_info.type); - if (!ctrl) { - pr_warn("mdp4_overlay_ctrl is NULL\n"); - return -EPERM; - } - mixer = &ctrl->mdp_mixer_cfg[mixer_num]; - - switch (mdp_mixer_cfg->writeback_format) { - case WB_FORMAT_RGB_888: - case WB_FORMAT_RGB_565: - case WB_FORMAT_NV12: - case WB_FORMAT_xRGB_8888: - case WB_FORMAT_ARGB_8888: - mixer->writeback_format = mdp_mixer_cfg->writeback_format; - break; - case WB_FORMAT_ARGB_8888_INPUT_ALPHA: - mixer->writeback_format = mdp_mixer_cfg->writeback_format; - mixer->alpha = mdp_mixer_cfg->alpha; - break; - default: - mixer->writeback_format = WB_FORMAT_NV12; - pr_warn("Unsupported format request, setting to NV12\n"); - ret = -EINVAL; - break; - } - return ret; -} - -int mdp4_update_base_blend(struct msm_fb_data_type *mfd, - struct mdp_blend_cfg *mdp_blend_cfg) -{ - int ret = 0; - u32 mixer_num; - struct blend_cfg *blend; - mixer_num = mdp4_get_mixer_num(mfd->panel_info.type); - if (!ctrl) - return -EPERM; - blend = &ctrl->blend[mixer_num][MDP4_MIXER_STAGE_BASE]; - if (mdp_blend_cfg->is_premultiplied) { - blend->bg_alpha = 0xFF; - blend->op = MDP4_BLEND_FG_ALPHA_BG_CONST; - } else { - blend->op = MDP4_BLEND_FG_ALPHA_FG_PIXEL; - blend->bg_alpha = 0; - } - return ret; -} diff --git a/drivers/video/msm/mdp4_overlay_atv.c b/drivers/video/msm/mdp4_overlay_atv.c deleted file mode 100644 index 777074a81a13c17446061dc6b20e8c398025e254..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay_atv.c +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (c) 2010, 2012-2013 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" - - -static struct mdp4_overlay_pipe *atv_pipe; - -int mdp4_atv_on(struct platform_device *pdev) -{ - uint8 *buf; - unsigned int buf_offset; - int bpp, ptype; - struct fb_info *fbi; - struct fb_var_screeninfo *var; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *pipe; - int ret; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - fbi = mfd->fbi; - var = &fbi->var; - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = calc_fb_offset(mfd, fbi, bpp); - - if (atv_pipe == NULL) { - ptype = mdp4_overlay_format2type(mfd->fb_imgType); - pipe = mdp4_overlay_pipe_alloc(ptype, MDP4_MIXER1); - if (pipe == NULL) - return -EBUSY; - pipe->pipe_used++; - pipe->mixer_stage = MDP4_MIXER_STAGE_BASE; - pipe->mixer_num = MDP4_MIXER1; - pipe->src_format = mfd->fb_imgType; - mdp4_overlay_panel_mode(pipe->mixer_num, MDP4_PANEL_ATV); - mdp4_overlay_format2pipe(pipe); - - atv_pipe = pipe; /* keep it */ - } else { - pipe = atv_pipe; - } - - printk(KERN_INFO "mdp4_atv_overlay: pipe=%x ndx=%d\n", - (int)pipe, pipe->pipe_ndx); - - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* Turn the next panel on, get correct resolution - before configuring overlay pipe */ - ret = panel_next_on(pdev); - - pr_info("%s: fbi->var.yres: %d | fbi->var.xres: %d", - __func__, fbi->var.yres, fbi->var.xres); - - /* MDP4 Config */ - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->src_y = 0; - pipe->src_x = 0; - if (mfd->map_buffer) { - pipe->srcp0_addr = (unsigned int)mfd->map_buffer->iova[0] + \ - buf_offset; - pr_debug("start 0x%lx srcp0_addr 0x%x\n", mfd-> - map_buffer->iova[0], pipe->srcp0_addr); - } else { - pipe->srcp0_addr = (uint32)(buf + buf_offset); - } - - pipe->srcp0_ystride = fbi->fix.line_length; - - mdp4_overlay_dmae_xy(pipe); /* dma_e */ - mdp4_overlay_dmae_cfg(mfd, 1); - mdp4_overlay_rgb_setup(pipe); - - mdp4_overlayproc_cfg(pipe); - - mdp4_overlay_reg_flush(pipe, 1); - - mdp4_mixer_stage_up(pipe, 0); - mdp4_mixer_stage_commit(pipe->mixer_num); - - if (ret == 0) - mdp_pipe_ctrl(MDP_OVERLAY1_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return ret; -} - -int mdp4_atv_off(struct platform_device *pdev) -{ - int ret = 0; - - mdp_pipe_ctrl(MDP_OVERLAY1_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - ret = panel_next_off(pdev); - - /* delay to make sure the last frame finishes */ - msleep(100); - - /* dis-engage rgb2 from mixer1 */ - if (atv_pipe) { - mdp4_mixer_stage_down(atv_pipe, 1); - mdp4_iommu_unmap(atv_pipe); - } - - return ret; -} - -/* - * mdp4_overlay1_done_atv: called from isr - */ -void mdp4_overlay1_done_atv() -{ - complete(&atv_pipe->comp); -} - -void mdp4_atv_overlay(struct msm_fb_data_type *mfd) -{ - struct fb_info *fbi = mfd->fbi; - uint8 *buf; - unsigned int buf_offset; - int bpp; - unsigned long flag; - struct mdp4_overlay_pipe *pipe; - - if (!mfd->panel_power_on) - return; - - /* no need to power on cmd block since it's lcdc mode */ - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = calc_fb_offset(mfd, fbi, bpp); - - mutex_lock(&mfd->dma->ov_mutex); - - pipe = atv_pipe; - if (mfd->map_buffer) { - pipe->srcp0_addr = (unsigned int)mfd->map_buffer->iova[0] + \ - buf_offset; - pr_debug("start 0x%lx srcp0_addr 0x%x\n", mfd-> - map_buffer->iova[0], pipe->srcp0_addr); - } else { - pipe->srcp0_addr = (uint32)(buf + buf_offset); - } - mdp_update_pm(mfd, vsync_ctrl_db[0].vsync_time); - - mdp4_overlay_mdp_perf_req(pipe, mfd); - mdp4_overlay_mdp_perf_upd(mfd, 1); - mdp4_overlay_rgb_setup(pipe); - - mdp4_overlay_reg_flush(pipe, 0); - mdp4_mixer_stage_up(pipe, 0); - mdp4_mixer_stage_commit(pipe->mixer_num); - printk(KERN_INFO "mdp4_atv_overlay: pipe=%x ndx=%d\n", - (int)pipe, pipe->pipe_ndx); - - /* enable irq */ - spin_lock_irqsave(&mdp_spin_lock, flag); - mdp_enable_irq(MDP_OVERLAY1_TERM); - INIT_COMPLETION(atv_pipe->comp); - mfd->dma->waiting = TRUE; - outp32(MDP_INTR_CLEAR, INTR_OVERLAY1_DONE); - mdp_intr_mask |= INTR_OVERLAY1_DONE; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - wait_for_completion_killable(&atv_pipe->comp); - mdp_disable_irq(MDP_OVERLAY1_TERM); - mdp4_overlay_mdp_perf_upd(mfd, 0); - mdp4_stat.kickoff_atv++; - mutex_unlock(&mfd->dma->ov_mutex); -} diff --git a/drivers/video/msm/mdp4_overlay_dsi_cmd.c b/drivers/video/msm/mdp4_overlay_dsi_cmd.c deleted file mode 100644 index 8be051dbe48f1b43c18cede1354e815d46fb5f95..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay_dsi_cmd.c +++ /dev/null @@ -1,1186 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mipi_dsi.h" -#include "mdp4.h" - -static int vsync_start_y_adjust = 4; - -#define MAX_CONTROLLER 1 - -/* - * VSYNC_EXPIRE_TICK == 0 means clock always on - * VSYNC_EXPIRE_TICK == 4 is recommended - */ -#define VSYNC_EXPIRE_TICK 4 - -static struct vsycn_ctrl { - struct device *dev; - int inited; - int update_ndx; - int expire_tick; - int blt_wait; - u32 ov_koff; - u32 ov_done; - u32 dmap_koff; - u32 dmap_done; - u32 pan_display; - uint32 rdptr_intr_tot; - uint32 rdptr_sirq_tot; - atomic_t suspend; - int wait_vsync_cnt; - int blt_change; - int blt_free; - int blt_end; - int sysfs_created; - struct mutex update_lock; - struct completion ov_comp; - struct completion dmap_comp; - struct completion vsync_comp; - spinlock_t spin_lock; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *base_pipe; - struct vsync_update vlist[2]; - int vsync_enabled; - int clk_enabled; - int new_update; - int clk_control; - ktime_t vsync_time; - struct work_struct clk_work; -} vsync_ctrl_db[MAX_CONTROLLER]; - -static void vsync_irq_enable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - /* no need to clrear other interrupts for comamnd mode */ - mdp_intr_mask |= intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -static void vsync_irq_disable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - /* no need to clrear other interrupts for comamnd mode */ - mdp_intr_mask &= ~intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_disable_irq_nosync(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -static void mdp4_dsi_cmd_blt_ov_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - char *overlay_base; - - if (pipe->ov_blt_addr == 0) - return; - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->ov_blt_addr + off; - /* overlay 0 */ - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - outpdw(overlay_base + 0x000c, addr); - outpdw(overlay_base + 0x001c, addr); -} - -static void mdp4_dsi_cmd_blt_dmap_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - - if (pipe->ov_blt_addr == 0) - return; - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->dmap_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->dma_blt_addr + off; - - /* dmap */ - MDP_OUTP(MDP_BASE + 0x90008, addr); -} - -static void mdp4_dsi_cmd_wait4dmap(int cndx); -static void mdp4_dsi_cmd_wait4ov(int cndx); - -static void mdp4_dsi_cmd_do_blt(struct msm_fb_data_type *mfd, int enable) -{ - unsigned long flags; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int need_wait; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0); - - if (mfd->ov0_wb_buf->write_addr == 0) { - pr_err("%s: no blt_base assigned\n", __func__); - return; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (enable && pipe->ov_blt_addr == 0) { - vctrl->blt_change++; - if (vctrl->dmap_koff != vctrl->dmap_done) { - INIT_COMPLETION(vctrl->dmap_comp); - need_wait = 1; - } - } else if (enable == 0 && pipe->ov_blt_addr) { - vctrl->blt_change++; - if (vctrl->ov_koff != vctrl->dmap_done) { - INIT_COMPLETION(vctrl->dmap_comp); - need_wait = 1; - } - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - if (need_wait) - mdp4_dsi_cmd_wait4dmap(0); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (enable && pipe->ov_blt_addr == 0) { - pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr; - pipe->dma_blt_addr = mfd->ov0_wb_buf->read_addr; - pipe->ov_cnt = 0; - pipe->dmap_cnt = 0; - vctrl->ov_koff = vctrl->dmap_koff; - vctrl->ov_done = vctrl->dmap_done; - vctrl->blt_free = 0; - vctrl->blt_wait = 0; - vctrl->blt_end = 0; - mdp4_stat.blt_dsi_video++; - } else if (enable == 0 && pipe->ov_blt_addr) { - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - vctrl->blt_end = 1; - vctrl->blt_free = 4; /* 4 commits to free wb buf */ - } - - pr_debug("%s: changed=%d enable=%d ov_blt_addr=%x\n", __func__, - vctrl->blt_change, enable, (int)pipe->ov_blt_addr); - - spin_unlock_irqrestore(&vctrl->spin_lock, flags); -} - -/* - * mdp4_dsi_cmd_do_update: - * called from thread context - */ -void mdp4_dsi_cmd_pipe_queue(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pp; - int undx; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend)) { - pr_err("%s: suspended, no more pipe queue\n", __func__); - return; - } - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - - pp = &vp->plist[pipe->pipe_ndx - 1]; /* ndx start form 1 */ - - pr_debug("%s: vndx=%d pipe_ndx=%d expire=%x pid=%d\n", __func__, - undx, pipe->pipe_ndx, vctrl->expire_tick, current->pid); - - *pp = *pipe; /* clone it */ - vp->update_cnt++; - - mutex_unlock(&vctrl->update_lock); - mdp4_stat.overlay_play[pipe->mixer_num]++; -} - -static void mdp4_dsi_cmd_blt_ov_update(struct mdp4_overlay_pipe *pipe); - -int mdp4_dsi_cmd_pipe_commit(int cndx, int wait) -{ - int i, undx; - int mixer = 0; - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pipe; - struct mdp4_overlay_pipe *real_pipe; - unsigned long flags; - int need_dmap_wait = 0; - int need_ov_wait = 0; - int cnt = 0; - - vctrl = &vsync_ctrl_db[0]; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - pipe = vctrl->base_pipe; - mixer = pipe->mixer_num; - - mdp_update_pm(vctrl->mfd, vctrl->vsync_time); - - if (vp->update_cnt == 0) { - mutex_unlock(&vctrl->update_lock); - return cnt; - } - - vctrl->update_ndx++; - vctrl->update_ndx &= 0x01; - vp->update_cnt = 0; /* reset */ - if (vctrl->blt_free) { - vctrl->blt_free--; - if (vctrl->blt_free == 0) - mdp4_free_writeback_buf(vctrl->mfd, mixer); - } - mutex_unlock(&vctrl->update_lock); - - /* free previous committed iommu back to pool */ - mdp4_overlay_iommu_unmap_freelist(mixer); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (pipe->ov_blt_addr) { - /* Blt */ - if (vctrl->blt_wait) - need_dmap_wait = 1; - if (vctrl->ov_koff != vctrl->ov_done) { - INIT_COMPLETION(vctrl->ov_comp); - need_ov_wait = 1; - } - } else { - /* direct out */ - if (vctrl->dmap_koff != vctrl->dmap_done) { - INIT_COMPLETION(vctrl->dmap_comp); - pr_debug("%s: wait, ok=%d od=%d dk=%d dd=%d cpu=%d\n", - __func__, vctrl->ov_koff, vctrl->ov_done, - vctrl->dmap_koff, vctrl->dmap_done, smp_processor_id()); - need_dmap_wait = 1; - } - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - if (need_dmap_wait) { - pr_debug("%s: wait4dmap\n", __func__); - mdp4_dsi_cmd_wait4dmap(0); - } - - if (need_ov_wait) { - pr_debug("%s: wait4ov\n", __func__); - mdp4_dsi_cmd_wait4ov(0); - } - - if (pipe->ov_blt_addr) { - if (vctrl->blt_end) { - vctrl->blt_end = 0; - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - } - } - - if (vctrl->blt_change) { - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmap_xy(pipe); - vctrl->blt_change = 0; - } - - pipe = vp->plist; - for (i = 0; i < OVERLAY_PIPE_MAX; i++, pipe++) { - if (pipe->pipe_used) { - cnt++; - real_pipe = mdp4_overlay_ndx2pipe(pipe->pipe_ndx); - if (real_pipe && real_pipe->pipe_used) { - /* pipe not unset */ - mdp4_overlay_vsync_commit(pipe); - } - /* free previous iommu to freelist - * which will be freed at next - * pipe_commit - */ - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 0); - pipe->pipe_used = 0; /* clear */ - } - } - - /* tx dcs command if had any */ - mipi_dsi_cmdlist_commit(1); - - mdp4_mixer_stage_commit(mixer); - - pipe = vctrl->base_pipe; - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (pipe->ov_blt_addr) { - mdp4_dsi_cmd_blt_ov_update(pipe); - pipe->ov_cnt++; - vctrl->ov_koff++; - INIT_COMPLETION(vctrl->ov_comp); - vsync_irq_enable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - } else { - INIT_COMPLETION(vctrl->dmap_comp); - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - vctrl->dmap_koff++; - } - pr_debug("%s: kickoff, pid=%d\n", __func__, current->pid); - /* kickoff overlay engine */ - mdp4_stat.kickoff_ov0++; - outpdw(MDP_BASE + 0x0004, 0); - mb(); /* make sure kickoff ececuted */ - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - mdp4_stat.overlay_commit[pipe->mixer_num]++; - - if (wait) { - long long tick; - - mdp4_dsi_cmd_wait4vsync(cndx, &tick); - } - - return cnt; -} - -static void mdp4_overlay_update_dsi_cmd(struct msm_fb_data_type *mfd); - -void mdp4_dsi_cmd_vsync_ctrl(struct fb_info *info, int enable) -{ - struct vsycn_ctrl *vctrl; - unsigned long flags; - int cndx = 0; - int clk_set_on = 0; - - vctrl = &vsync_ctrl_db[cndx]; - - mutex_lock(&vctrl->update_lock); - pr_debug("%s: clk_enabled=%d vsync_enabled=%d req=%d\n", __func__, - vctrl->clk_enabled, vctrl->vsync_enabled, enable); - - if (vctrl->vsync_enabled == enable) { - mutex_unlock(&vctrl->update_lock); - return; - } - - vctrl->vsync_enabled = enable; - - if (enable) { - spin_lock_irqsave(&vctrl->spin_lock, flags); - vctrl->clk_control = 0; - vctrl->expire_tick = 0; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - if (vctrl->clk_enabled == 0) { - pr_debug("%s: SET_CLK_ON\n", __func__); - mipi_dsi_clk_cfg(1); - mdp_clk_ctrl(1); - vctrl->clk_enabled = 1; - vctrl->new_update = 1; - clk_set_on = 1; - } - if (clk_set_on) { - vsync_irq_enable(INTR_PRIMARY_RDPTR, - MDP_PRIM_RDPTR_TERM); - } - } else { - spin_lock_irqsave(&vctrl->spin_lock, flags); - vctrl->expire_tick = VSYNC_EXPIRE_TICK; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - } - mutex_unlock(&vctrl->update_lock); -} - -void mdp4_dsi_cmd_wait4vsync(int cndx, long long *vtime) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - unsigned long flags; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (atomic_read(&vctrl->suspend) > 0) { - *vtime = -1; - return; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - wait_for_completion(&vctrl->vsync_comp); - mdp4_stat.wait4vsync0++; - - *vtime = ktime_to_ns(vctrl->vsync_time); -} - -static void mdp4_dsi_cmd_wait4dmap(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->dmap_comp); -} - -static void mdp4_dsi_cmd_wait4ov(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->ov_comp); -} - -/* - * primary_rdptr_isr: - * called from interrupt context - */ - -static void primary_rdptr_isr(int cndx) -{ - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[cndx]; - pr_debug("%s: ISR, tick=%d pan=%d cpu=%d\n", __func__, - vctrl->expire_tick, vctrl->pan_display, smp_processor_id()); - vctrl->rdptr_intr_tot++; - - spin_lock(&vctrl->spin_lock); - vctrl->vsync_time = ktime_get(); - - if (vctrl->new_update) { - vctrl->new_update = 0; - spin_unlock(&vctrl->spin_lock); - return; - } - - complete_all(&vctrl->vsync_comp); - vctrl->wait_vsync_cnt = 0; - - if (vctrl->expire_tick) { - vctrl->expire_tick--; - if (vctrl->expire_tick == 0) { - if (vctrl->pan_display <= 0) { - vctrl->clk_control = 1; - schedule_work(&vctrl->clk_work); - } else { - /* wait one more vsycn */ - vctrl->expire_tick += 1; - } - } - } - spin_unlock(&vctrl->spin_lock); -} - -void mdp4_dmap_done_dsi_cmd(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int diff; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - - /* blt enabled */ - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - vctrl->dmap_done++; - - if (vctrl->pan_display) - vctrl->pan_display--; - - diff = vctrl->ov_done - vctrl->dmap_done; - pr_debug("%s: ov_koff=%d ov_done=%d dmap_koff=%d dmap_done=%d cpu=%d\n", - __func__, vctrl->ov_koff, vctrl->ov_done, vctrl->dmap_koff, - vctrl->dmap_done, smp_processor_id()); - complete(&vctrl->dmap_comp); - if (diff <= 0) { - if (vctrl->blt_wait) - vctrl->blt_wait = 0; - spin_unlock(&vctrl->spin_lock); - return; - } - - /* kick dmap */ - mdp4_dsi_cmd_blt_dmap_update(pipe); - pipe->dmap_cnt++; - mdp4_stat.kickoff_dmap++; - vctrl->dmap_koff++; - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - outpdw(MDP_BASE + 0x000c, 0); /* kickoff dmap engine */ - mb(); /* make sure kickoff executed */ - spin_unlock(&vctrl->spin_lock); -} - -/* - * mdp4_overlay0_done_dsi_cmd: called from isr - */ -void mdp4_overlay0_done_dsi_cmd(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int diff; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - vctrl->ov_done++; - complete(&vctrl->ov_comp); - diff = vctrl->ov_done - vctrl->dmap_done; - - pr_debug("%s: ov_koff=%d ov_done=%d dmap_koff=%d dmap_done=%d cpu=%d\n", - __func__, vctrl->ov_koff, vctrl->ov_done, vctrl->dmap_koff, - vctrl->dmap_done, smp_processor_id()); - - if (pipe->ov_blt_addr == 0) { - /* blt disabled */ - spin_unlock(&vctrl->spin_lock); - return; - } - - if (diff > 1) { - /* - * two overlay_done and none dmap_done yet - * let dmap_done kickoff dmap - * and put pipe_commit to wait - */ - vctrl->blt_wait = 1; - pr_debug("%s: blt_wait set\n", __func__); - spin_unlock(&vctrl->spin_lock); - return; - } - mdp4_dsi_cmd_blt_dmap_update(pipe); - pipe->dmap_cnt++; - mdp4_stat.kickoff_dmap++; - vctrl->dmap_koff++; - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - outpdw(MDP_BASE + 0x000c, 0); /* kickoff dmap engine */ - mb(); /* make sure kickoff executed */ - spin_unlock(&vctrl->spin_lock); -} - -static void clk_ctrl_work(struct work_struct *work) -{ - unsigned long flags; - struct vsycn_ctrl *vctrl = - container_of(work, typeof(*vctrl), clk_work); - - mutex_lock(&vctrl->update_lock); - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->clk_control && vctrl->clk_enabled) { - vsync_irq_disable(INTR_PRIMARY_RDPTR, MDP_PRIM_RDPTR_TERM); - vctrl->clk_enabled = 0; - vctrl->clk_control = 0; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - /* make sure dsi link is idle */ - mipi_dsi_mdp_busy_wait(); - mipi_dsi_clk_cfg(0); - mdp_clk_ctrl(0); - pr_debug("%s: SET_CLK_OFF, pid=%d\n", __func__, current->pid); - } else { - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - } - mutex_unlock(&vctrl->update_lock); -} - -ssize_t mdp4_dsi_cmd_show_event(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int cndx; - struct vsycn_ctrl *vctrl; - ssize_t ret = 0; - unsigned long flags; - u64 vsync_tick; - - cndx = 0; - vctrl = &vsync_ctrl_db[0]; - - if (atomic_read(&vctrl->suspend) > 0) - return 0; - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - ret = wait_for_completion_interruptible_timeout(&vctrl->vsync_comp, - msecs_to_jiffies(VSYNC_PERIOD * 4)); - if (ret <= 0) { - vctrl->wait_vsync_cnt = 0; - vsync_tick = ktime_to_ns(ktime_get()); - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick); - buf[strlen(buf) + 1] = '\0'; - return ret; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - vsync_tick = ktime_to_ns(vctrl->vsync_time); - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick); - pr_debug("%s: UEVENT\n", __func__); - - buf[strlen(buf) + 1] = '\0'; - return ret; -} - -void mdp4_dsi_rdptr_init(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->inited) - return; - - vctrl->inited = 1; - vctrl->update_ndx = 0; - mutex_init(&vctrl->update_lock); - init_completion(&vctrl->ov_comp); - init_completion(&vctrl->dmap_comp); - init_completion(&vctrl->vsync_comp); - spin_lock_init(&vctrl->spin_lock); - atomic_set(&vctrl->suspend, 1); - INIT_WORK(&vctrl->clk_work, clk_ctrl_work); -} - -void mdp4_primary_rdptr(void) -{ - primary_rdptr_isr(0); -} - -static __u32 msm_fb_line_length(__u32 fb_index, __u32 xres, int bpp) -{ - /* - * The adreno GPU hardware requires that the pitch be aligned to - * 32 pixels for color buffers, so for the cases where the GPU - * is writing directly to fb0, the framebuffer pitch - * also needs to be 32 pixel aligned - */ - - if (fb_index == 0) - return ALIGN(xres, 32) * bpp; - else - return xres * bpp; -} - -void mdp4_mipi_vsync_enable(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe, int which) -{ - uint32 start_y, data, tear_en; - - tear_en = (1 << which); - - if ((mfd->use_mdp_vsync) && (mfd->ibuf.vsync_enable) && - (mfd->panel_info.lcd.vsync_enable)) { - - if (vsync_start_y_adjust <= pipe->dst_y) - start_y = pipe->dst_y - vsync_start_y_adjust; - else - start_y = (mfd->total_lcd_lines - 1) - - (vsync_start_y_adjust - pipe->dst_y); - if (which == 0) - MDP_OUTP(MDP_BASE + 0x210, start_y); /* primary */ - else - MDP_OUTP(MDP_BASE + 0x214, start_y); /* secondary */ - - data = inpdw(MDP_BASE + 0x20c); - data |= tear_en; - MDP_OUTP(MDP_BASE + 0x20c, data); - } else { - data = inpdw(MDP_BASE + 0x20c); - data &= ~tear_en; - MDP_OUTP(MDP_BASE + 0x20c, data); - } -} - -void mdp4_dsi_cmd_base_swap(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->base_pipe = pipe; -} - -static void mdp4_overlay_setup_pipe_addr(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe) -{ - MDPIBUF *iBuf = &mfd->ibuf; - struct fb_info *fbi; - int bpp; - uint8 *src; - - /* whole screen for base layer */ - src = (uint8 *) iBuf->buf; - fbi = mfd->fbi; - - if (pipe->is_3d) { - bpp = fbi->var.bits_per_pixel / 8; - pipe->src_height = pipe->src_height_3d; - pipe->src_width = pipe->src_width_3d; - pipe->src_h = pipe->src_height_3d; - pipe->src_w = pipe->src_width_3d; - pipe->dst_h = pipe->src_height_3d; - pipe->dst_w = pipe->src_width_3d; - pipe->srcp0_ystride = msm_fb_line_length(0, - pipe->src_width, bpp); - } else { - /* 2D */ - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->srcp0_ystride = fbi->fix.line_length; - } - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_y = 0; - pipe->dst_x = 0; - pipe->srcp0_addr = (uint32)src; -} - -static void mdp4_overlay_update_dsi_cmd(struct msm_fb_data_type *mfd) -{ - int ptype; - struct mdp4_overlay_pipe *pipe; - int ret; - int cndx = 0; - struct vsycn_ctrl *vctrl; - - - if (mfd->key != MFD_KEY) - return; - - vctrl = &vsync_ctrl_db[cndx]; - - if (vctrl->base_pipe == NULL) { - ptype = mdp4_overlay_format2type(mfd->fb_imgType); - if (ptype < 0) - printk(KERN_INFO "%s: format2type failed\n", __func__); - pipe = mdp4_overlay_pipe_alloc(ptype, MDP4_MIXER0); - if (pipe == NULL) { - printk(KERN_INFO "%s: pipe_alloc failed\n", __func__); - return; - } - pipe->pipe_used++; - pipe->mixer_stage = MDP4_MIXER_STAGE_BASE; - pipe->mixer_num = MDP4_MIXER0; - pipe->src_format = mfd->fb_imgType; - mdp4_overlay_panel_mode(pipe->mixer_num, MDP4_PANEL_DSI_CMD); - ret = mdp4_overlay_format2pipe(pipe); - if (ret < 0) - printk(KERN_INFO "%s: format2type failed\n", __func__); - - vctrl->base_pipe = pipe; /* keep it */ - mdp4_init_writeback_buf(mfd, MDP4_MIXER0); - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - } else { - pipe = vctrl->base_pipe; - } - - /* TE enabled */ - mdp4_mipi_vsync_enable(mfd, pipe, 0); - - MDP_OUTP(MDP_BASE + 0x021c, 10); /* read pointer */ - - /* - * configure dsi stream id - * dma_p = 0, dma_s = 1 - */ - MDP_OUTP(MDP_BASE + 0x000a0, 0x10); - /* disable dsi trigger */ - MDP_OUTP(MDP_BASE + 0x000a4, 0x00); - - mdp4_overlay_setup_pipe_addr(mfd, pipe); - - mdp4_overlay_rgb_setup(pipe); - - mdp4_overlay_reg_flush(pipe, 1); - - mdp4_mixer_stage_up(pipe, 0); - - mdp4_overlayproc_cfg(pipe); - - mdp4_overlay_dmap_xy(pipe); - - mdp4_overlay_dmap_cfg(mfd, 0); - - wmb(); -} - -/* 3D side by side */ -void mdp4_dsi_cmd_3d_sbys(struct msm_fb_data_type *mfd, - struct msmfb_overlay_3d *r3d) -{ - struct fb_info *fbi; - int bpp; - uint8 *src = NULL; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (pipe == NULL) - return; - - if (pipe->pipe_used == 0 || - pipe->mixer_stage != MDP4_MIXER_STAGE_BASE) { - pr_err("%s: NOT baselayer\n", __func__); - return; - } - - pipe->is_3d = r3d->is_3d; - pipe->src_height_3d = r3d->height; - pipe->src_width_3d = r3d->width; - - if (pipe->is_3d) - mdp4_overlay_panel_3d(pipe->mixer_num, MDP4_3D_SIDE_BY_SIDE); - else - mdp4_overlay_panel_3d(pipe->mixer_num, MDP4_3D_NONE); - - fbi = mfd->fbi; - if (pipe->is_3d) { - bpp = fbi->var.bits_per_pixel / 8; - pipe->src_height = pipe->src_height_3d; - pipe->src_width = pipe->src_width_3d; - pipe->src_h = pipe->src_height_3d; - pipe->src_w = pipe->src_width_3d; - pipe->dst_h = pipe->src_height_3d; - pipe->dst_w = pipe->src_width_3d; - pipe->srcp0_ystride = msm_fb_line_length(0, - pipe->src_width, bpp); - } else { - /* 2D */ - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->srcp0_ystride = fbi->fix.line_length; - } - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_y = 0; - pipe->dst_x = 0; - pipe->srcp0_addr = (uint32)src; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - mdp_clk_ctrl(1); - - mdp4_overlay_rgb_setup(pipe); - - mdp4_overlay_reg_flush(pipe, 1); - - mdp4_mixer_stage_up(pipe, 0); - - mdp4_overlayproc_cfg(pipe); - - mdp4_overlay_dmap_xy(pipe); - - mdp4_overlay_dmap_cfg(mfd, 0); - - mdp4_mixer_stage_commit(pipe->mixer_num); - /* MDP cmd block disable */ - mdp_clk_ctrl(0); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -void mdp4_dsi_cmd_blt_start(struct msm_fb_data_type *mfd) -{ - mdp4_dsi_cmd_do_blt(mfd, 1); -} - -void mdp4_dsi_cmd_blt_stop(struct msm_fb_data_type *mfd) -{ - mdp4_dsi_cmd_do_blt(mfd, 0); -} - -void mdp4_dsi_cmd_overlay_blt(struct msm_fb_data_type *mfd, - struct msmfb_overlay_blt *req) -{ - mdp4_dsi_cmd_do_blt(mfd, req->enable); -} - -int mdp4_dsi_cmd_on(struct platform_device *pdev) -{ - int ret = 0; - int cndx = 0; - struct msm_fb_data_type *mfd; - struct vsycn_ctrl *vctrl; - - pr_debug("%s+: pid=%d\n", __func__, current->pid); - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - mfd->cont_splash_done = 1; - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->mfd = mfd; - vctrl->dev = mfd->fbi->dev; - - mdp_clk_ctrl(1); - mdp4_overlay_update_dsi_cmd(mfd); - mdp_clk_ctrl(0); - - mdp4_iommu_attach(); - - atomic_set(&vctrl->suspend, 0); - - pr_debug("%s-:\n", __func__); - return ret; -} - -int mdp4_dsi_cmd_off(struct platform_device *pdev) -{ - int ret = 0; - int cndx = 0; - struct msm_fb_data_type *mfd; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - struct vsync_update *vp; - int undx; - int need_wait, cnt; - unsigned long flags; - - pr_debug("%s+: pid=%d\n", __func__, current->pid); - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) { - pr_err("%s: NO base pipe\n", __func__); - return ret; - } - - need_wait = 0; - mutex_lock(&vctrl->update_lock); - atomic_set(&vctrl->suspend, 1); - - complete_all(&vctrl->vsync_comp); - - pr_debug("%s: clk=%d pan=%d\n", __func__, - vctrl->clk_enabled, vctrl->pan_display); - if (vctrl->clk_enabled) - need_wait = 1; - mutex_unlock(&vctrl->update_lock); - - cnt = 0; - if (need_wait) { - while (vctrl->clk_enabled) { - msleep(20); - cnt++; - if (cnt > 10) - break; - } - } - - if (cnt > 10) { - spin_lock_irqsave(&vctrl->spin_lock, flags); - vctrl->clk_control = 0; - vctrl->clk_enabled = 0; - vctrl->expire_tick = 0; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - mipi_dsi_clk_cfg(0); - mdp_clk_ctrl(0); - pr_err("%s: Error, SET_CLK_OFF by force\n", __func__); - } - - /* sanity check, free pipes besides base layer */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - vctrl->base_pipe = NULL; - - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - if (vp->update_cnt) { - /* - * pipe's iommu will be freed at next overlay play - * and iommu_drop statistic will be increased by one - */ - vp->update_cnt = 0; /* empty queue */ - } - - pr_debug("%s-:\n", __func__); - return ret; -} - -void mdp_dsi_cmd_overlay_suspend(struct msm_fb_data_type *mfd) -{ - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - /* dis-engage rgb0 from mixer0 */ - if (pipe) { - if (mfd->ref_cnt == 0) { - /* adb stop */ - if (pipe->pipe_type == OVERLAY_TYPE_BF) - mdp4_overlay_borderfill_stage_down(pipe); - - /* pipe == rgb1 */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - vctrl->base_pipe = NULL; - } else { - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 1); - } - } -} - -void mdp4_dsi_cmd_overlay(struct msm_fb_data_type *mfd) -{ - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - unsigned long flags; - int clk_set_on = 0; - - mutex_lock(&mfd->dma->ov_mutex); - vctrl = &vsync_ctrl_db[cndx]; - - if (!mfd->panel_power_on) { - mutex_unlock(&mfd->dma->ov_mutex); - return; - } - - pipe = vctrl->base_pipe; - if (pipe == NULL) { - pr_err("%s: NO base pipe\n", __func__); - mutex_unlock(&mfd->dma->ov_mutex); - return; - } - - mutex_lock(&vctrl->update_lock); - if (atomic_read(&vctrl->suspend)) { - mutex_unlock(&vctrl->update_lock); - mutex_unlock(&mfd->dma->ov_mutex); - pr_err("%s: suspended, no more pan display\n", __func__); - return; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - vctrl->clk_control = 0; - vctrl->pan_display++; - if (!vctrl->clk_enabled) { - clk_set_on = 1; - vctrl->clk_enabled = 1; - vctrl->expire_tick = VSYNC_EXPIRE_TICK; - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - if (clk_set_on) { - pr_debug("%s: SET_CLK_ON\n", __func__); - mipi_dsi_clk_cfg(1); - mdp_clk_ctrl(1); - vsync_irq_enable(INTR_PRIMARY_RDPTR, MDP_PRIM_RDPTR_TERM); - } - - mutex_unlock(&vctrl->update_lock); - - if (pipe->mixer_stage == MDP4_MIXER_STAGE_BASE) { - mdp4_mipi_vsync_enable(mfd, pipe, 0); - mdp4_overlay_setup_pipe_addr(mfd, pipe); - mdp4_dsi_cmd_pipe_queue(0, pipe); - } - - mdp4_overlay_mdp_perf_upd(mfd, 1); - mdp4_dsi_cmd_pipe_commit(cndx, 0); - mdp4_overlay_mdp_perf_upd(mfd, 0); - mutex_unlock(&mfd->dma->ov_mutex); -} diff --git a/drivers/video/msm/mdp4_overlay_dsi_video.c b/drivers/video/msm/mdp4_overlay_dsi_video.c deleted file mode 100644 index 3fdf9899fb5df9eb411145104eb8f981dd63049f..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay_dsi_video.c +++ /dev/null @@ -1,1142 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" -#include "mipi_dsi.h" - -#include - -#define DSI_VIDEO_BASE 0xE0000 - -static int first_pixel_start_x; -static int first_pixel_start_y; -static int dsi_video_enabled; - -#define MAX_CONTROLLER 1 - -static struct vsycn_ctrl { - struct device *dev; - int inited; - int update_ndx; - int ov_koff; - int ov_done; - atomic_t suspend; - atomic_t vsync_resume; - int wait_vsync_cnt; - int blt_change; - int blt_free; - u32 blt_ctrl; - u32 blt_mode; - int sysfs_created; - struct mutex update_lock; - struct completion ov_comp; - struct completion dmap_comp; - struct completion vsync_comp; - spinlock_t spin_lock; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *base_pipe; - struct vsync_update vlist[2]; - int vsync_irq_enabled; - ktime_t vsync_time; -} vsync_ctrl_db[MAX_CONTROLLER]; - -static void vsync_irq_enable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, intr); - mdp_intr_mask |= intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - pr_debug("%s: IRQ-en done, term=%x\n", __func__, term); -} - -static void vsync_irq_disable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, intr); - mdp_intr_mask &= ~intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_disable_irq_nosync(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - pr_debug("%s: IRQ-dis done, term=%x\n", __func__, term); -} - -static void mdp4_overlay_dsi_video_start(void) -{ - if (!dsi_video_enabled) { - /* enable DSI block */ - mdp4_iommu_attach(); - mdp_pipe_ctrl(MDP_OVERLAY0_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 1); - dsi_video_enabled = 1; - } -} - -/* - * mdp4_dsi_video_pipe_queue: - * called from thread context - */ -void mdp4_dsi_video_pipe_queue(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pp; - int undx; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - - pp = &vp->plist[pipe->pipe_ndx - 1]; /* ndx start form 1 */ - - pr_debug("%s: vndx=%d pipe=%x ndx=%d num=%d pid=%d\n", - __func__, undx, (int)pipe, pipe->pipe_ndx, pipe->pipe_num, - current->pid); - - *pp = *pipe; /* clone it */ - vp->update_cnt++; - mutex_unlock(&vctrl->update_lock); - mdp4_stat.overlay_play[pipe->mixer_num]++; -} - -static void mdp4_dsi_video_blt_ov_update(struct mdp4_overlay_pipe *pipe); -static void mdp4_dsi_video_wait4dmap(int cndx); -static void mdp4_dsi_video_wait4ov(int cndx); - -int mdp4_dsi_video_pipe_commit(int cndx, int wait) -{ - - int i, undx; - int mixer = 0; - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pipe; - struct mdp4_overlay_pipe *real_pipe; - unsigned long flags; - int cnt = 0; - - vctrl = &vsync_ctrl_db[cndx]; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - pipe = vctrl->base_pipe; - mixer = pipe->mixer_num; - - mdp_update_pm(vctrl->mfd, vctrl->vsync_time); - - if (vp->update_cnt == 0) { - mutex_unlock(&vctrl->update_lock); - return cnt; - } - - vctrl->update_ndx++; - vctrl->update_ndx &= 0x01; - vp->update_cnt = 0; /* reset */ - if (vctrl->blt_free) { - vctrl->blt_free--; - if (vctrl->blt_free == 0) - mdp4_free_writeback_buf(vctrl->mfd, mixer); - } - mutex_unlock(&vctrl->update_lock); - - /* free previous committed iommu back to pool */ - mdp4_overlay_iommu_unmap_freelist(mixer); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->ov_koff != vctrl->ov_done) { - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - pr_err("%s: Error, frame dropped %d %d\n", __func__, - vctrl->ov_koff, vctrl->ov_done); - return 0; - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - pipe = vp->plist; - - for (i = 0; i < OVERLAY_PIPE_MAX; i++, pipe++) { - if (pipe->pipe_used) { - cnt++; - real_pipe = mdp4_overlay_ndx2pipe(pipe->pipe_ndx); - if (real_pipe && real_pipe->pipe_used) { - /* pipe not unset */ - mdp4_overlay_vsync_commit(pipe); - } - /* free previous iommu to freelist - * which will be freed at next - * pipe_commit - */ - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 0); - pipe->pipe_used = 0; /* clear */ - } - } - - mdp4_mixer_stage_commit(mixer); - - /* start timing generator & mmu if they are not started yet */ - mdp4_overlay_dsi_video_start(); - - pipe = vctrl->base_pipe; - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (pipe->ov_blt_addr) { - mdp4_dsi_video_blt_ov_update(pipe); - pipe->ov_cnt++; - INIT_COMPLETION(vctrl->ov_comp); - vsync_irq_enable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - mb(); - vctrl->ov_koff++; - /* kickoff overlay engine */ - mdp4_stat.kickoff_ov0++; - outpdw(MDP_BASE + 0x0004, 0); - } else { - /* schedule second phase update at dmap */ - INIT_COMPLETION(vctrl->dmap_comp); - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - mdp4_stat.overlay_commit[pipe->mixer_num]++; - - if (wait) { - if (pipe->ov_blt_addr) - mdp4_dsi_video_wait4ov(cndx); - else - mdp4_dsi_video_wait4dmap(cndx); - } - - return cnt; -} - -void mdp4_dsi_video_vsync_ctrl(struct fb_info *info, int enable) -{ - struct vsycn_ctrl *vctrl; - int cndx = 0; - - vctrl = &vsync_ctrl_db[cndx]; - - if (vctrl->vsync_irq_enabled == enable) - return; - - pr_debug("%s: vsync enable=%d\n", __func__, enable); - - vctrl->vsync_irq_enabled = enable; - - if (enable) - vsync_irq_enable(INTR_PRIMARY_VSYNC, MDP_PRIM_VSYNC_TERM); - else - vsync_irq_disable(INTR_PRIMARY_VSYNC, MDP_PRIM_VSYNC_TERM); - - if (vctrl->vsync_irq_enabled && atomic_read(&vctrl->suspend) == 0) - atomic_set(&vctrl->vsync_resume, 1); -} - -void mdp4_dsi_video_wait4vsync(int cndx, long long *vtime) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - unsigned long flags; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (atomic_read(&vctrl->suspend) > 0) { - *vtime = -1; - return; - } - - /* start timing generator & mmu if they are not started yet */ - mdp4_overlay_dsi_video_start(); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - wait_for_completion(&vctrl->vsync_comp); - mdp4_stat.wait4vsync0++; - - *vtime = ktime_to_ns(vctrl->vsync_time); -} - -static void mdp4_dsi_video_wait4dmap(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->dmap_comp); -} - - -static void mdp4_dsi_video_wait4dmap_done(int cndx) -{ - unsigned long flags; - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - vctrl = &vsync_ctrl_db[cndx]; - - spin_lock_irqsave(&vctrl->spin_lock, flags); - INIT_COMPLETION(vctrl->dmap_comp); - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - mdp4_dsi_video_wait4dmap(cndx); -} - - -static void mdp4_dsi_video_wait4ov(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->ov_comp); -} - -ssize_t mdp4_dsi_video_show_event(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int cndx; - struct vsycn_ctrl *vctrl; - ssize_t ret = 0; - unsigned long flags; - u64 vsync_tick; - - cndx = 0; - vctrl = &vsync_ctrl_db[0]; - - if (atomic_read(&vctrl->suspend) > 0 || - atomic_read(&vctrl->vsync_resume) == 0) - return 0; - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - ret = wait_for_completion_interruptible_timeout(&vctrl->vsync_comp, - msecs_to_jiffies(VSYNC_PERIOD * 4)); - if (ret <= 0) { - vctrl->wait_vsync_cnt = 0; - vsync_tick = ktime_to_ns(ktime_get()); - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick); - buf[strlen(buf) + 1] = '\0'; - return ret; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - vsync_tick = ktime_to_ns(vctrl->vsync_time); - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick); - buf[strlen(buf) + 1] = '\0'; - return ret; -} - -void mdp4_dsi_vsync_init(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - pr_debug("%s: ndx=%d\n", __func__, cndx); - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->inited) - return; - - vctrl->inited = 1; - vctrl->update_ndx = 0; - mutex_init(&vctrl->update_lock); - init_completion(&vctrl->vsync_comp); - init_completion(&vctrl->dmap_comp); - init_completion(&vctrl->ov_comp); - atomic_set(&vctrl->suspend, 1); - atomic_set(&vctrl->vsync_resume, 1); - spin_lock_init(&vctrl->spin_lock); -} - -void mdp4_dsi_video_base_swap(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->base_pipe = pipe; -} - -int mdp4_dsi_video_on(struct platform_device *pdev) -{ - int dsi_width; - int dsi_height; - int dsi_bpp; - int dsi_border_clr; - int dsi_underflow_clr; - int dsi_hsync_skew; - - int hsync_period; - int hsync_ctrl; - int vsync_period; - int display_hctl; - int display_v_start; - int display_v_end; - int active_hctl; - int active_h_start; - int active_h_end; - int active_v_start; - int active_v_end; - int ctrl_polarity; - int h_back_porch; - int h_front_porch; - int v_back_porch; - int v_front_porch; - int hsync_pulse_width; - int vsync_pulse_width; - int hsync_polarity; - int vsync_polarity; - int data_en_polarity; - int hsync_start_x; - int hsync_end_x; - uint8 *buf; - unsigned int buf_offset; - int bpp, ptype; - struct fb_info *fbi; - struct fb_var_screeninfo *var; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *pipe; - int ret = 0; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct msm_panel_info *pinfo; - - vctrl = &vsync_ctrl_db[cndx]; - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - vctrl->mfd = mfd; - vctrl->dev = mfd->fbi->dev; - pinfo = &mfd->panel_info; - vctrl->blt_ctrl = pinfo->lcd.blt_ctrl; - vctrl->blt_mode = pinfo->lcd.blt_mode; - - /* mdp clock on */ - mdp_clk_ctrl(1); - - fbi = mfd->fbi; - var = &fbi->var; - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = calc_fb_offset(mfd, fbi, bpp); - - if (vctrl->base_pipe == NULL) { - ptype = mdp4_overlay_format2type(mfd->fb_imgType); - if (ptype < 0) - printk(KERN_INFO "%s: format2type failed\n", __func__); - pipe = mdp4_overlay_pipe_alloc(ptype, MDP4_MIXER0); - if (pipe == NULL) { - printk(KERN_INFO "%s: pipe_alloc failed\n", __func__); - return -EBUSY; - } - pipe->pipe_used++; - pipe->mixer_stage = MDP4_MIXER_STAGE_BASE; - pipe->mixer_num = MDP4_MIXER0; - pipe->src_format = mfd->fb_imgType; - mdp4_overlay_panel_mode(pipe->mixer_num, MDP4_PANEL_DSI_VIDEO); - ret = mdp4_overlay_format2pipe(pipe); - if (ret < 0) - printk(KERN_INFO "%s: format2type failed\n", __func__); - - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - vctrl->base_pipe = pipe; /* keep it */ - mdp4_init_writeback_buf(mfd, MDP4_MIXER0); - - } else { - pipe = vctrl->base_pipe; - } - - if (!(mfd->cont_splash_done)) { - mfd->cont_splash_done = 1; - mdp4_dsi_video_wait4dmap_done(0); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 0); - dsi_video_enabled = 0; - mipi_dsi_controller_cfg(0); - /* Clks are enabled in probe. - Disabling clocks now */ - mdp_clk_ctrl(0); - } - - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->srcp0_ystride = fbi->fix.line_length; - pipe->bpp = bpp; - - if (mfd->display_iova) - pipe->srcp0_addr = mfd->display_iova + buf_offset; - else - pipe->srcp0_addr = (uint32)(buf + buf_offset); - - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - - mdp4_overlay_mdp_pipe_req(pipe, mfd); - mdp4_calc_blt_mdp_bw(mfd, pipe); - - atomic_set(&vctrl->suspend, 0); - - mdp4_overlay_dmap_xy(pipe); /* dma_p */ - mdp4_overlay_dmap_cfg(mfd, 1); - mdp4_overlay_rgb_setup(pipe); - mdp4_overlayproc_cfg(pipe); - - mdp4_overlay_reg_flush(pipe, 1); - - mdp4_mixer_stage_up(pipe, 0); - mdp4_mixer_stage_commit(pipe->mixer_num); - - /* - * DSI timing setting - */ - h_back_porch = var->left_margin; - h_front_porch = var->right_margin; - v_back_porch = var->upper_margin; - v_front_porch = var->lower_margin; - hsync_pulse_width = var->hsync_len; - vsync_pulse_width = var->vsync_len; - dsi_border_clr = mfd->panel_info.lcdc.border_clr; - dsi_underflow_clr = mfd->panel_info.lcdc.underflow_clr; - dsi_hsync_skew = mfd->panel_info.lcdc.hsync_skew; - dsi_width = mfd->panel_info.xres + - mfd->panel_info.lcdc.xres_pad; - dsi_height = mfd->panel_info.yres + - mfd->panel_info.lcdc.yres_pad; - dsi_bpp = mfd->panel_info.bpp; - - hsync_period = hsync_pulse_width + h_back_porch + dsi_width - + h_front_porch; - hsync_ctrl = (hsync_period << 16) | hsync_pulse_width; - hsync_start_x = h_back_porch + hsync_pulse_width; - hsync_end_x = hsync_period - h_front_porch - 1; - display_hctl = (hsync_end_x << 16) | hsync_start_x; - - vsync_period = - (vsync_pulse_width + v_back_porch + dsi_height + v_front_porch); - display_v_start = ((vsync_pulse_width + v_back_porch) * hsync_period) - + dsi_hsync_skew; - display_v_end = - ((vsync_period - v_front_porch) * hsync_period) + dsi_hsync_skew - 1; - - if (dsi_width != var->xres) { - active_h_start = hsync_start_x + first_pixel_start_x; - active_h_end = active_h_start + var->xres - 1; - active_hctl = - ACTIVE_START_X_EN | (active_h_end << 16) | active_h_start; - } else { - active_hctl = 0; - } - - if (dsi_height != var->yres) { - active_v_start = - display_v_start + first_pixel_start_y * hsync_period; - active_v_end = active_v_start + (var->yres) * hsync_period - 1; - active_v_start |= ACTIVE_START_Y_EN; - } else { - active_v_start = 0; - active_v_end = 0; - } - - dsi_underflow_clr |= 0x80000000; /* enable recovery */ - hsync_polarity = 0; - vsync_polarity = 0; - data_en_polarity = 0; - - ctrl_polarity = - (data_en_polarity << 2) | (vsync_polarity << 1) | (hsync_polarity); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x4, hsync_ctrl); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x8, vsync_period * hsync_period); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0xc, - vsync_pulse_width * hsync_period); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x10, display_hctl); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x14, display_v_start); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x18, display_v_end); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x1c, active_hctl); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x20, active_v_start); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x24, active_v_end); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x28, dsi_border_clr); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x2c, dsi_underflow_clr); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x30, dsi_hsync_skew); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x38, ctrl_polarity); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - mdp_histogram_ctrl_all(TRUE); - - return ret; -} - -int mdp4_dsi_video_off(struct platform_device *pdev) -{ - int ret = 0; - int cndx = 0; - struct msm_fb_data_type *mfd; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - struct vsync_update *vp; - unsigned long flags; - int undx, need_wait = 0; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - atomic_set(&vctrl->suspend, 1); - atomic_set(&vctrl->vsync_resume, 0); - - msleep(20); /* >= 17 ms */ - - complete_all(&vctrl->vsync_comp); - - if (pipe->ov_blt_addr) { - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->ov_koff != vctrl->ov_done) - need_wait = 1; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - if (need_wait) - mdp4_dsi_video_wait4ov(0); - } - - mdp_histogram_ctrl_all(FALSE); - - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 0); - - dsi_video_enabled = 0; - - if (vctrl->vsync_irq_enabled) { - vctrl->vsync_irq_enabled = 0; - vsync_irq_disable(INTR_PRIMARY_VSYNC, MDP_PRIM_VSYNC_TERM); - } - - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - if (vp->update_cnt) { - /* - * pipe's iommu will be freed at next overlay play - * and iommu_drop statistic will be increased by one - */ - vp->update_cnt = 0; /* empty queue */ - } - - if (pipe) { - /* sanity check, free pipes besides base layer */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - if (mfd->ref_cnt == 0) { - /* adb stop */ - if (pipe->pipe_type == OVERLAY_TYPE_BF) - mdp4_overlay_borderfill_stage_down(pipe); - - /* base pipe may change after borderfill_stage_down */ - pipe = vctrl->base_pipe; - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - vctrl->base_pipe = NULL; - } else { - /* system suspending */ - mdp4_mixer_stage_down(vctrl->base_pipe, 1); - mdp4_overlay_iommu_pipe_free( - vctrl->base_pipe->pipe_ndx, 1); - } - } - - /* mdp clock off */ - mdp_clk_ctrl(0); - mdp_pipe_ctrl(MDP_OVERLAY0_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return ret; -} - -static __u32 msm_fb_line_length(__u32 fb_index, __u32 xres, int bpp) -{ - /* - * The adreno GPU hardware requires that the pitch be aligned to - * 32 pixels for color buffers, so for the cases where the GPU - * is writing directly to fb0, the framebuffer pitch - * also needs to be 32 pixel aligned - */ - - if (fb_index == 0) - return ALIGN(xres, 32) * bpp; - else - return xres * bpp; -} - -/* 3D side by side */ -void mdp4_dsi_video_3d_sbys(struct msm_fb_data_type *mfd, - struct msmfb_overlay_3d *r3d) -{ - struct fb_info *fbi; - unsigned int buf_offset; - int bpp; - uint8 *buf = NULL; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (vctrl->base_pipe == NULL) - return; - - pipe = vctrl->base_pipe; - pipe->is_3d = r3d->is_3d; - pipe->src_height_3d = r3d->height; - pipe->src_width_3d = r3d->width; - - if (pipe->is_3d) - mdp4_overlay_panel_3d(pipe->mixer_num, MDP4_3D_SIDE_BY_SIDE); - else - mdp4_overlay_panel_3d(pipe->mixer_num, MDP4_3D_NONE); - - fbi = mfd->fbi; - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = calc_fb_offset(mfd, fbi, bpp); - - if (pipe->is_3d) { - pipe->src_height = pipe->src_height_3d; - pipe->src_width = pipe->src_width_3d; - pipe->src_h = pipe->src_height_3d; - pipe->src_w = pipe->src_width_3d; - pipe->dst_h = pipe->src_height_3d; - pipe->dst_w = pipe->src_width_3d; - pipe->srcp0_ystride = msm_fb_line_length(0, - pipe->src_width, bpp); - } else { - /* 2D */ - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->srcp0_ystride = fbi->fix.line_length; - } - - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_y = 0; - pipe->dst_x = 0; - - if (mfd->display_iova) - pipe->srcp0_addr = mfd->display_iova + buf_offset; - else - pipe->srcp0_addr = (uint32)(buf + buf_offset); - - mdp4_overlay_rgb_setup(pipe); - - mdp4_overlayproc_cfg(pipe); - - mdp4_overlay_dmap_xy(pipe); - - mdp4_overlay_dmap_cfg(mfd, 1); - - mdp4_overlay_reg_flush(pipe, 1); - - mdp4_mixer_stage_up(pipe, 0); - - mdp4_mixer_stage_commit(pipe->mixer_num); - - mb(); -} - -static void mdp4_dsi_video_blt_ov_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - char *overlay_base; - - if (pipe->ov_blt_addr == 0) - return; - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->ov_blt_addr + off; - - /* overlay 0 */ - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - outpdw(overlay_base + 0x000c, addr); - outpdw(overlay_base + 0x001c, addr); -} - -static void mdp4_dsi_video_blt_dmap_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - - if (pipe->ov_blt_addr == 0) - return; - - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->dmap_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->dma_blt_addr + off; - - /* dmap */ - MDP_OUTP(MDP_BASE + 0x90008, addr); -} - -/* - * mdp4_primary_vsync_dsi_video: called from isr - */ -void mdp4_primary_vsync_dsi_video(void) -{ - int cndx; - struct vsycn_ctrl *vctrl; - - - cndx = 0; - vctrl = &vsync_ctrl_db[cndx]; - pr_debug("%s: cpu=%d\n", __func__, smp_processor_id()); - - spin_lock(&vctrl->spin_lock); - vctrl->vsync_time = ktime_get(); - - if (vctrl->wait_vsync_cnt) { - complete_all(&vctrl->vsync_comp); - vctrl->wait_vsync_cnt = 0; - } - spin_unlock(&vctrl->spin_lock); -} - - /* - * mdp4_dmap_done_dsi_video: called from isr - */ -void mdp4_dmap_done_dsi_video(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - if (vctrl->blt_change) { - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmap_xy(pipe); - vctrl->blt_change = 0; - } - complete_all(&vctrl->dmap_comp); - mdp4_overlay_dma_commit(cndx); - spin_unlock(&vctrl->spin_lock); -} - -/* - * mdp4_overlay0_done_dsi: called from isr - */ -void mdp4_overlay0_done_dsi_video(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - vctrl->ov_done++; - complete_all(&vctrl->ov_comp); - if (pipe->ov_blt_addr == 0) { - spin_unlock(&vctrl->spin_lock); - return; - } - - mdp4_dsi_video_blt_dmap_update(pipe); - pipe->dmap_cnt++; - spin_unlock(&vctrl->spin_lock); -} - -/* - * make sure the MIPI_DSI_WRITEBACK_SIZE defined at boardfile - * has enough space h * w * 3 * 2 - */ -static void mdp4_dsi_video_do_blt(struct msm_fb_data_type *mfd, int enable) -{ - unsigned long flag; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - long long vtime; - u32 mode, ctrl; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - mode = (dbg_force_ov0_blt & 0x0f) ? - (dbg_force_ov0_blt & 0x0f) : vctrl->blt_mode; - ctrl = (dbg_force_ov0_blt >> 4) ? - (dbg_force_ov0_blt >> 4) : vctrl->blt_ctrl; - - pr_debug("%s: mode=%d, enable=%d ov_blt_addr=%x\n", - __func__, mode, enable, (int)pipe->ov_blt_addr); - - if ((mode == MDP4_OVERLAY_MODE_BLT_ALWAYS_OFF) && - !pipe->ov_blt_addr) - return; - else if ((mode == MDP4_OVERLAY_MODE_BLT_ALWAYS_ON) && - pipe->ov_blt_addr) - return; - else if (enable && pipe->ov_blt_addr) - return; - else if (!enable && !pipe->ov_blt_addr) - return; - - if (pipe->ov_blt_addr == 0) { - mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0); - if (mfd->ov0_wb_buf->write_addr == 0) { - pr_warning("%s: no blt_base assigned\n", __func__); - return; - } - } - - pr_debug("%s: mode=%d, enable=%d ov_blt_addr=%x\n", - __func__, mode, enable, (int)pipe->ov_blt_addr); - - spin_lock_irqsave(&vctrl->spin_lock, flag); - if (pipe->ov_blt_addr == 0) { - pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr; - pipe->dma_blt_addr = mfd->ov0_wb_buf->read_addr; - pipe->ov_cnt = 0; - pipe->dmap_cnt = 0; - vctrl->ov_koff = 0; - vctrl->ov_done = 0; - vctrl->blt_free = 0; - mdp4_stat.blt_dsi_video++; - } else { - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - vctrl->blt_free = 4; /* 4 commits to free wb buf */ - } - spin_unlock_irqrestore(&vctrl->spin_lock, flag); - - if (ctrl == MDP4_OVERLAY_BLT_SWITCH_TG_ON) { - spin_lock_irqsave(&vctrl->spin_lock, flag); - if (!dsi_video_enabled) { - pr_debug("%s: blt switched not in ISR dsi_video_enabled=%d\n", - __func__, dsi_video_enabled); - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmap_xy(pipe); - } else { - pr_debug("%s: blt switched in ISR dsi_video_enabled=%d\n", - __func__, dsi_video_enabled); - vctrl->blt_change++; - } - spin_unlock_irqrestore(&vctrl->spin_lock, flag); - if (dsi_video_enabled) - mdp4_dsi_video_wait4dmap_done(0); - } else if (ctrl == MDP4_OVERLAY_BLT_SWITCH_TG_OFF) { - pr_debug("%s: blt switched by turning TG off\n", __func__); - if (dsi_video_enabled) { - mdp4_dsi_video_wait4vsync(0, &vtime); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 0); - mdp4_dsi_video_wait4dmap_done(0); - } - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmap_xy(pipe); - if (dsi_video_enabled) { - /* - * need wait for more than 1 ms to - * make sure dsi lanes' fifo is empty and - * lanes in stop state befroe reset - * controller - */ - usleep(2000); - mipi_dsi_sw_reset(); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 1); - } - } else if (ctrl == MDP4_OVERLAY_BLT_SWITCH_POLL) { - pr_debug("%s: blt switched by polling mdp status\n", __func__); - if (dsi_video_enabled) - while (inpdw(MDP_BASE + 0x0018) & 0x05) - cpu_relax(); - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmap_xy(pipe); - } else - pr_err("%s: ctrl=%d is not supported\n", __func__, ctrl); -} - -void mdp4_dsi_video_overlay_blt(struct msm_fb_data_type *mfd, - struct msmfb_overlay_blt *req) -{ - mdp4_dsi_video_do_blt(mfd, req->enable); -} - -void mdp4_dsi_video_blt_start(struct msm_fb_data_type *mfd) -{ - mdp4_dsi_video_do_blt(mfd, 1); -} - -void mdp4_dsi_video_blt_stop(struct msm_fb_data_type *mfd) -{ - mdp4_dsi_video_do_blt(mfd, 0); -} - -void mdp4_dsi_video_overlay(struct msm_fb_data_type *mfd) -{ - struct fb_info *fbi = mfd->fbi; - uint8 *buf; - unsigned int buf_offset; - int bpp; - int cnt, cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - mutex_lock(&mfd->dma->ov_mutex); - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (!pipe || !mfd->panel_power_on) { - mutex_unlock(&mfd->dma->ov_mutex); - return; - } - - pr_debug("%s: cpu=%d pid=%d\n", __func__, - smp_processor_id(), current->pid); - if (pipe->pipe_type == OVERLAY_TYPE_RGB) { - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = calc_fb_offset(mfd, fbi, bpp); - - if (mfd->display_iova) - pipe->srcp0_addr = mfd->display_iova + buf_offset; - else - pipe->srcp0_addr = (uint32)(buf + buf_offset); - - mdp4_dsi_video_pipe_queue(0, pipe); - } - - mdp4_overlay_mdp_perf_upd(mfd, 1); - - cnt = mdp4_dsi_video_pipe_commit(cndx, 0); - if (cnt) { - if (pipe->ov_blt_addr) - mdp4_dsi_video_wait4ov(cndx); - else - mdp4_dsi_video_wait4dmap(cndx); - } - - mdp4_overlay_mdp_perf_upd(mfd, 0); - mutex_unlock(&mfd->dma->ov_mutex); -} diff --git a/drivers/video/msm/mdp4_overlay_dtv.c b/drivers/video/msm/mdp4_overlay_dtv.c deleted file mode 100644 index 4a0db560f2d291fe69e95df0d28db75e8b536f9c..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay_dtv.c +++ /dev/null @@ -1,1258 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "hdmi_msm.h" -#include "mdp4.h" - -#define DTV_BASE 0xD0000 -static int dtv_enabled; - -/*#define DEBUG*/ -#ifdef DEBUG -static void __mdp_outp(uint32 port, uint32 value) -{ - uint32 in_val; - - outpdw(port, value); - in_val = inpdw(port); - printk(KERN_INFO "MDP-DTV[%04x] => %08x [%08x]\n", - port-(uint32)(MDP_BASE + DTV_BASE), value, in_val); -} - -#undef MDP_OUTP -#define MDP_OUTP(port, value) __mdp_outp((uint32)(port), (value)) -#endif - -static int first_pixel_start_x; -static int first_pixel_start_y; - -#define MAX_CONTROLLER 1 - -static struct vsycn_ctrl { - struct device *dev; - int inited; - int update_ndx; - int dmae_intr_cnt; - atomic_t suspend; - atomic_t vsync_resume; - int dmae_wait_cnt; - int wait_vsync_cnt; - int blt_change; - int blt_ctrl; - int blt_mode; - int blt_free; - int sysfs_created; - struct mutex update_lock; - struct completion ov_comp; - struct completion dmae_comp; - struct completion vsync_comp; - spinlock_t spin_lock; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *base_pipe; - struct vsync_update vlist[2]; - int vsync_irq_enabled; - ktime_t vsync_time; - uint32 *avtimer; - int vg1fd; - int vg2fd; - unsigned long long avtimer_tick; -} vsync_ctrl_db[MAX_CONTROLLER]; - -static void vsync_irq_enable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, intr); - mdp_intr_mask |= intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - pr_debug("%s: IRQ-en done, term=%x\n", __func__, term); -} - -static void vsync_irq_disable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, intr); - mdp_intr_mask &= ~intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_disable_irq_nosync(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - pr_debug("%s: IRQ-dis done, term=%x\n", __func__, term); -} - -void mdp4_overlay_dtv_start(void) -{ - if (!dtv_enabled) { - /* enable DTV block */ - mdp4_iommu_attach(); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + DTV_BASE, 1); - mdp_pipe_ctrl(MDP_OVERLAY1_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - dtv_enabled = 1; - } -} - -/* - * mdp4_dtv_vsync_do_update: - * called from thread context - */ -void mdp4_dtv_pipe_queue(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pp; - int undx; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - - pp = &vp->plist[pipe->pipe_ndx - 1]; /* ndx start form 1 */ - - pr_debug("%s: vndx=%d pipe_ndx=%d flags=%x pid=%d\n", - __func__, undx, pipe->pipe_ndx, pipe->flags, current->pid); - - *pp = *pipe; /* clone it */ - vp->update_cnt++; - mutex_unlock(&vctrl->update_lock); - mdp4_stat.overlay_play[pipe->mixer_num]++; -} - -static void mdp4_dtv_blt_ov_update(struct mdp4_overlay_pipe *pipe); -static void mdp4_dtv_wait4ov(int cndx); -static void mdp4_dtv_wait4dmae(int cndx); - -int mdp4_dtv_pipe_commit(int cndx, int wait) -{ - - int i, undx; - int mixer = 0; - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pipe; - struct mdp4_overlay_pipe *real_pipe; - unsigned long flags; - int cnt = 0; - - vctrl = &vsync_ctrl_db[cndx]; - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - pipe = vctrl->base_pipe; - mixer = pipe->mixer_num; - mdp4_overlay_iommu_unmap_freelist(mixer); - - mdp_update_pm(vctrl->mfd, vctrl->vsync_time); - - if (vp->update_cnt == 0) { - mutex_unlock(&vctrl->update_lock); - return 0; - } - - vctrl->update_ndx++; - vctrl->update_ndx &= 0x01; - vp->update_cnt = 0; /* reset */ - - if (vctrl->blt_free) { - vctrl->blt_free--; - if (vctrl->blt_free == 0) - mdp4_free_writeback_buf(vctrl->mfd, mixer); - } - - mutex_unlock(&vctrl->update_lock); - - pipe = vp->plist; - for (i = 0; i < OVERLAY_PIPE_MAX; i++, pipe++) { - if (pipe->pipe_used) { - cnt++; - real_pipe = mdp4_overlay_ndx2pipe(pipe->pipe_ndx); - if (real_pipe && real_pipe->pipe_used) { - /* pipe not unset */ - mdp4_overlay_vsync_commit(pipe); - } - /* free previous iommu to freelist - * which will be freed at next - * pipe_commit - */ - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 0); - pipe->pipe_used = 0; /* clear */ - } - } - mdp4_mixer_stage_commit(mixer); - - /* start timing generator & mmu if they are not started yet */ - mdp4_overlay_dtv_start(); - - pipe = vctrl->base_pipe; - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (pipe->ov_blt_addr) { - mdp4_dtv_blt_ov_update(pipe); - pipe->blt_ov_done++; - INIT_COMPLETION(vctrl->ov_comp); - vsync_irq_enable(INTR_OVERLAY1_DONE, MDP_OVERLAY1_TERM); - mb(); - pipe->blt_ov_koff++; - /* kickoff overlay1 engine */ - mdp4_stat.kickoff_ov1++; - outpdw(MDP_BASE + 0x0008, 0); - } else { - /* schedule second phase update at dmap */ - INIT_COMPLETION(vctrl->dmae_comp); - vsync_irq_enable(INTR_DMA_E_DONE, MDP_DMA_E_TERM); - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - mdp4_stat.overlay_commit[pipe->mixer_num]++; - - if (wait) { - if (pipe->ov_blt_addr) - mdp4_dtv_wait4ov(cndx); - else - mdp4_dtv_wait4dmae(cndx); - } - return cnt; -} - -void mdp4_dtv_vsync_ctrl(struct fb_info *info, int enable) -{ - struct vsycn_ctrl *vctrl; - int cndx = 0; - - vctrl = &vsync_ctrl_db[cndx]; - - if (!external_common_state->hpd_state) - complete_all(&vctrl->vsync_comp); - - if (vctrl->vsync_irq_enabled == enable) - return; - - pr_debug("%s: vsync enable=%d\n", __func__, enable); - - vctrl->vsync_irq_enabled = enable; - - if (enable) - vsync_irq_enable(INTR_EXTERNAL_VSYNC, MDP_EXTER_VSYNC_TERM); - else - vsync_irq_disable(INTR_EXTERNAL_VSYNC, MDP_EXTER_VSYNC_TERM); - - if (vctrl->vsync_irq_enabled && atomic_read(&vctrl->suspend) == 0) - atomic_set(&vctrl->vsync_resume, 1); -} - -void mdp4_dtv_wait4vsync(int cndx, long long *vtime) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - unsigned long flags; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - spin_lock_irqsave(&vctrl->spin_lock, flags); - - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - wait_for_completion(&vctrl->vsync_comp); - mdp4_stat.wait4vsync1++; - - *vtime = ktime_to_ns(vctrl->vsync_time); -} - -static void mdp4_dtv_wait4ov(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->ov_comp); -} - -static void mdp4_dtv_wait4dmae(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->dmae_comp); -} - -ssize_t mdp4_dtv_show_event(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int cndx; - struct vsycn_ctrl *vctrl; - ssize_t ret = 0; - unsigned long flags; - char ch = '\0'; - int vg1fd = -1, vg2fd = -1; - unsigned long long avtimer_tick = 0; - u64 vsync_tick = 0; - - cndx = 0; - vctrl = &vsync_ctrl_db[0]; - memset(buf, 0, 64); - - if (atomic_read(&vctrl->suspend) > 0 || - !external_common_state->hpd_state || - atomic_read(&vctrl->vsync_resume) == 0) - return 0; - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - ret = wait_for_completion_interruptible_timeout(&vctrl->vsync_comp, - msecs_to_jiffies(VSYNC_PERIOD * 4)); - if (ret <= 0) { - vctrl->wait_vsync_cnt = 0; - vsync_tick = ktime_to_ns(ktime_get()); - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick); - buf[strlen(buf) + 1] = '\0'; - return ret; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - vg1fd = vctrl->vg1fd; - vg2fd = vctrl->vg2fd; - avtimer_tick = vctrl->avtimer_tick; - vsync_tick = ktime_to_ns(vctrl->vsync_time); - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - ret = snprintf(buf, PAGE_SIZE, - "VSYNC=%llu%c" - "AVSYNCTP=%llu%c" - "VG1MEMID=%d%c" - "VG2MEMID=%d", - vsync_tick, - ch, avtimer_tick, - ch, vg1fd, - ch, vg2fd); - - return ret; -} - -static void mdp4_dtv_wait4dmae_done(int cndx) -{ - unsigned long flags; - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - spin_lock_irqsave(&vctrl->spin_lock, flags); - INIT_COMPLETION(vctrl->dmae_comp); - vsync_irq_enable(INTR_DMA_E_DONE, MDP_DMA_E_TERM); - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - mdp4_dtv_wait4dmae(cndx); -} - -void mdp4_dtv_vsync_init(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - pr_info("%s: ndx=%d\n", __func__, cndx); - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->inited) - return; - - vctrl->inited = 1; - vctrl->update_ndx = 0; - mutex_init(&vctrl->update_lock); - init_completion(&vctrl->vsync_comp); - init_completion(&vctrl->ov_comp); - init_completion(&vctrl->dmae_comp); - atomic_set(&vctrl->suspend, 1); - atomic_set(&vctrl->vsync_resume, 1); - spin_lock_init(&vctrl->spin_lock); -} - -void mdp4_dtv_base_swap(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - - if (!hdmi_prim_display) { - pr_err("%s: failed, hdmi is not primary\n", __func__); - return; - } - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->base_pipe = pipe; -} - -static int mdp4_dtv_start(struct msm_fb_data_type *mfd) -{ - int dtv_width; - int dtv_height; - int dtv_bpp; - int dtv_border_clr; - int dtv_underflow_clr; - int dtv_hsync_skew; - - int hsync_period; - int hsync_ctrl; - int vsync_period; - int display_hctl; - int display_v_start; - int display_v_end; - int active_hctl; - int active_h_start; - int active_h_end; - int active_v_start; - int active_v_end; - int ctrl_polarity; - int h_back_porch; - int h_front_porch; - int v_back_porch; - int v_front_porch; - int hsync_pulse_width; - int vsync_pulse_width; - int hsync_polarity; - int vsync_polarity; - int data_en_polarity; - int hsync_start_x; - int hsync_end_x; - struct fb_info *fbi; - struct fb_var_screeninfo *var; - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[0]; - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - fbi = mfd->fbi; - var = &fbi->var; - - vctrl->mfd = mfd; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - if (hdmi_prim_display) { - if (is_mdp4_hw_reset()) { - mdp4_hw_init(); - outpdw(MDP_BASE + 0x0038, mdp4_display_intf); - } - } - mdp4_overlay_dmae_cfg(mfd, 0); - - /* - * DTV timing setting - */ - h_back_porch = var->left_margin; - h_front_porch = var->right_margin; - v_back_porch = var->upper_margin; - v_front_porch = var->lower_margin; - hsync_pulse_width = var->hsync_len; - vsync_pulse_width = var->vsync_len; - dtv_border_clr = mfd->panel_info.lcdc.border_clr; - dtv_underflow_clr = mfd->panel_info.lcdc.underflow_clr; - dtv_hsync_skew = mfd->panel_info.lcdc.hsync_skew; - - pr_info("%s: \n", __func__, - var->reserved[3], var->xres, var->yres, - var->right_margin, var->hsync_len, var->left_margin, - var->lower_margin, var->vsync_len, var->upper_margin, - var->pixclock/1000/1000); - - dtv_width = var->xres; - dtv_height = var->yres; - dtv_bpp = mfd->panel_info.bpp; - - hsync_period = - hsync_pulse_width + h_back_porch + dtv_width + h_front_porch; - hsync_ctrl = (hsync_period << 16) | hsync_pulse_width; - hsync_start_x = hsync_pulse_width + h_back_porch; - hsync_end_x = hsync_period - h_front_porch - 1; - display_hctl = (hsync_end_x << 16) | hsync_start_x; - - vsync_period = - (vsync_pulse_width + v_back_porch + dtv_height + - v_front_porch) * hsync_period; - display_v_start = - (vsync_pulse_width + v_back_porch) * hsync_period + dtv_hsync_skew; - display_v_end = - vsync_period - (v_front_porch * hsync_period) + dtv_hsync_skew - 1; - - if (dtv_width != var->xres) { - active_h_start = hsync_start_x + first_pixel_start_x; - active_h_end = active_h_start + var->xres - 1; - active_hctl = - ACTIVE_START_X_EN | (active_h_end << 16) | active_h_start; - } else { - active_hctl = 0; - } - - if (dtv_height != var->yres) { - active_v_start = - display_v_start + first_pixel_start_y * hsync_period; - active_v_end = active_v_start + (var->yres) * hsync_period - 1; - active_v_start |= ACTIVE_START_Y_EN; - } else { - active_v_start = 0; - active_v_end = 0; - } - - dtv_underflow_clr |= 0x80000000; /* enable recovery */ - hsync_polarity = fbi->var.yres >= 720 ? 0 : 1; - vsync_polarity = fbi->var.yres >= 720 ? 0 : 1; - data_en_polarity = 0; - - ctrl_polarity = - (data_en_polarity << 2) | (vsync_polarity << 1) | (hsync_polarity); - - - MDP_OUTP(MDP_BASE + DTV_BASE + 0x4, hsync_ctrl); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x8, vsync_period); - MDP_OUTP(MDP_BASE + DTV_BASE + 0xc, vsync_pulse_width * hsync_period); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x18, display_hctl); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x1c, display_v_start); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x20, display_v_end); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x40, dtv_border_clr); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x44, dtv_underflow_clr); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x48, dtv_hsync_skew); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x50, ctrl_polarity); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x2c, active_hctl); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x30, active_v_start); - MDP_OUTP(MDP_BASE + DTV_BASE + 0x38, active_v_end); - - /* Test pattern 8 x 8 pixel */ - /* MDP_OUTP(MDP_BASE + DTV_BASE + 0x4C, 0x80000808); */ - - /* enable DTV block */ - MDP_OUTP(MDP_BASE + DTV_BASE, 1); - dtv_enabled = 1; - - return 0; -} - -static int mdp4_dtv_stop(struct msm_fb_data_type *mfd) -{ - int cndx = 0; - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->base_pipe == NULL) - return -EINVAL; - - MDP_OUTP(MDP_BASE + DTV_BASE, 0); - dtv_enabled = 0; - - return 0; -} - -int mdp4_dtv_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - int ret = 0; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct msm_panel_info *pinfo; - - vctrl = &vsync_ctrl_db[cndx]; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - vctrl->mfd = mfd; - vctrl->dev = mfd->fbi->dev; - pinfo = &mfd->panel_info; - - vctrl->blt_ctrl = pinfo->lcd.blt_ctrl; - vctrl->blt_mode = pinfo->lcd.blt_mode; - - mdp_footswitch_ctrl(TRUE); - /* Mdp clock enable */ - mdp_clk_ctrl(1); - - mdp4_overlay_panel_mode(MDP4_MIXER1, MDP4_PANEL_DTV); - - /* Allocate dtv_pipe at dtv_on*/ - if (vctrl->base_pipe == NULL) { - if (mdp4_overlay_dtv_set(mfd, NULL)) { - pr_warn("%s: dtv_pipe is NULL, dtv_set failed\n", - __func__); - return -EINVAL; - } - } - - ret = panel_next_on(pdev); - if (ret != 0) - pr_warn("%s: panel_next_on failed", __func__); - - atomic_set(&vctrl->suspend, 0); - if (mfd->avtimer_phy && (vctrl->avtimer == NULL)) { - vctrl->avtimer = (uint32 *)ioremap(mfd->avtimer_phy, 8); - if (vctrl->avtimer == NULL) - pr_err(" avtimer ioremap fail\n"); - } - - pr_info("%s:\n", __func__); - - return ret; -} - -int mdp4_dtv_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - int ret = 0; - int cndx = 0; - int undx; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - struct vsync_update *vp; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - vctrl = &vsync_ctrl_db[cndx]; - - atomic_set(&vctrl->suspend, 1); - atomic_set(&vctrl->vsync_resume, 0); - - /* wait for one vsycn time to make sure - * previous stage_commit had been kicked in - */ - msleep(20); /* >= 17 ms */ - - complete_all(&vctrl->vsync_comp); - - pipe = vctrl->base_pipe; - if (pipe != NULL) { - mdp4_dtv_stop(mfd); - /* sanity check, free pipes besides base layer */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - if (hdmi_prim_display && mfd->ref_cnt == 0) { - /* adb stop */ - if (pipe->pipe_type == OVERLAY_TYPE_BF) - mdp4_overlay_borderfill_stage_down(pipe); - - /* base pipe may change after borderfill_stage_down */ - pipe = vctrl->base_pipe; - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - /* pipe == rgb2 */ - vctrl->base_pipe = NULL; - } else { - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - vctrl->base_pipe = NULL; - } - } - - mdp4_overlay_panel_mode_unset(MDP4_MIXER1, MDP4_PANEL_DTV); - - if (vctrl->vsync_irq_enabled) { - vctrl->vsync_irq_enabled = 0; - vsync_irq_disable(INTR_EXTERNAL_VSYNC, MDP_EXTER_VSYNC_TERM); - } - - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - if (vp->update_cnt) { - /* - * pipe's iommu will be freed at next overlay play - * and iommu_drop statistic will be increased by one - */ - vp->update_cnt = 0; /* empty queue */ - } - - if (vctrl->avtimer != NULL) { - iounmap(vctrl->avtimer); - vctrl->avtimer = NULL; - } - - ret = panel_next_off(pdev); - mdp_footswitch_ctrl(FALSE); - - /* Mdp clock disable */ - mdp_clk_ctrl(0); - - pr_info("%s:\n", __func__); - return ret; -} - -static void mdp4_dtv_blt_ov_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - char *overlay_base; - - if (pipe->ov_blt_addr == 0) - return; - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->blt_ov_done & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->ov_blt_addr + off; - - /* overlay 1 */ - overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;/* 0x10000 */ - outpdw(overlay_base + 0x000c, addr); - outpdw(overlay_base + 0x001c, addr); -} - -static void mdp4_dtv_blt_dmae_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - - if (pipe->ov_blt_addr == 0) - return; - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->blt_dmap_done & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->dma_blt_addr + off; - - /* dmae */ - MDP_OUTP(MDP_BASE + 0xb0008, addr); -} - -static void mdp4_overlay_dtv_alloc_pipe(struct msm_fb_data_type *mfd, - int32 ptype, struct vsycn_ctrl *vctrl) -{ - int ret = 0; - struct fb_info *fbi = mfd->fbi; - struct mdp4_overlay_pipe *pipe; - - if (vctrl->base_pipe != NULL) - return; - - pipe = mdp4_overlay_pipe_alloc(ptype, MDP4_MIXER1); - if (pipe == NULL) { - pr_err("%s: pipe_alloc failed\n", __func__); - return; - } - pipe->pipe_used++; - pipe->mixer_stage = MDP4_MIXER_STAGE_BASE; - pipe->mixer_num = MDP4_MIXER1; - - if (ptype == OVERLAY_TYPE_BF) { - /* LSP_BORDER_COLOR */ - MDP_OUTP(MDP_BASE + MDP4_OVERLAYPROC1_BASE + 0x5004, - ((0x0 & 0xFFF) << 16) | /* 12-bit B */ - (0x0 & 0xFFF)); /* 12-bit G */ - /* MSP_BORDER_COLOR */ - MDP_OUTP(MDP_BASE + MDP4_OVERLAYPROC1_BASE + 0x5008, - (0x0 & 0xFFF)); /* 12-bit R */ - pipe->src_format = MDP_ARGB_8888; - } else { - switch (mfd->ibuf.bpp) { - case 2: - pipe->src_format = MDP_RGB_565; - break; - case 3: - pipe->src_format = MDP_RGB_888; - break; - case 4: - default: - if (hdmi_prim_display) - pipe->src_format = MSMFB_DEFAULT_TYPE; - else - pipe->src_format = MDP_ARGB_8888; - break; - } - } - - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->srcp0_ystride = fbi->fix.line_length; - - mdp4_overlay_mdp_pipe_req(pipe, mfd); - mdp4_calc_blt_mdp_bw(mfd, pipe); - - ret = mdp4_overlay_format2pipe(pipe); - if (ret < 0) - pr_warn("%s: format2type failed\n", __func__); - - mdp4_overlay_dmae_xy(pipe); /* dma_e */ - mdp4_overlayproc_cfg(pipe); - - if (pipe->pipe_type == OVERLAY_TYPE_RGB) { - pipe->srcp0_addr = (uint32) mfd->ibuf.buf; - mdp4_overlay_rgb_setup(pipe); - } - - mdp4_overlay_reg_flush(pipe, 1); - mdp4_mixer_stage_up(pipe, 0); - mdp4_mixer_stage_commit(pipe->mixer_num); - - vctrl->base_pipe = pipe; /* keep it */ -} - -int mdp4_overlay_dtv_set(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe) -{ - int cndx = 0; - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->base_pipe != NULL) - return 0; - - if (pipe != NULL && pipe->mixer_stage == MDP4_MIXER_STAGE_BASE && - pipe->pipe_type == OVERLAY_TYPE_RGB) - vctrl->base_pipe = pipe; /* keep it */ - else if (!hdmi_prim_display && mdp4_overlay_borderfill_supported()) - mdp4_overlay_dtv_alloc_pipe(mfd, OVERLAY_TYPE_BF, vctrl); - else - mdp4_overlay_dtv_alloc_pipe(mfd, OVERLAY_TYPE_RGB, vctrl); - - - if (vctrl->base_pipe == NULL) - return -ENODEV; - - mdp4_init_writeback_buf(mfd, MDP4_MIXER1); - vctrl->base_pipe->ov_blt_addr = 0; - vctrl->base_pipe->dma_blt_addr = 0; - - return mdp4_dtv_start(mfd); -} - -int mdp4_overlay_dtv_unset(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe) -{ - int result = 0; - int cndx = 0; - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->base_pipe == NULL) - return 0; - - if (pipe->mixer_stage == MDP4_MIXER_STAGE_BASE && - pipe->pipe_type == OVERLAY_TYPE_RGB) { - result = mdp4_dtv_stop(mfd); - vctrl->base_pipe = NULL; - } - - if (pipe->pipe_num == OVERLAY_PIPE_VG1) - vctrl->vg1fd = -1; - else if (pipe->pipe_num == OVERLAY_PIPE_VG2) - vctrl->vg2fd = -1; - - return result; -} - -/* TODO: dtv writeback need to be added later */ - -void mdp4_external_vsync_dtv(void) -{ - int cndx; - struct vsycn_ctrl *vctrl; - uint32 *tp, LSW; - - cndx = 0; - vctrl = &vsync_ctrl_db[cndx]; - pr_debug("%s: cpu=%d\n", __func__, smp_processor_id()); - - spin_lock(&vctrl->spin_lock); - vctrl->vsync_time = ktime_get(); - vctrl->avtimer_tick = 0; - - if (vctrl->avtimer && ((vctrl->vg1fd > 0) || (vctrl->vg2fd > 0))) { - tp = vctrl->avtimer; - LSW = inpdw(tp); - tp++; - vctrl->avtimer_tick = (unsigned long long) inpdw(tp); - vctrl->avtimer_tick = ((vctrl->avtimer_tick << 32) | LSW); - } - - if (vctrl->wait_vsync_cnt) { - complete_all(&vctrl->vsync_comp); - vctrl->wait_vsync_cnt = 0; - } - spin_unlock(&vctrl->spin_lock); -} - -/* - * mdp4_dmae_done_dtv: called from isr - */ -void mdp4_dmae_done_dtv(void) -{ - int cndx; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - cndx = 0; - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - pr_debug("%s: cpu=%d\n", __func__, smp_processor_id()); - - spin_lock(&vctrl->spin_lock); - if (vctrl->blt_change) { - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmae_xy(pipe); - vctrl->blt_change = 0; - } - - if (mdp_rev <= MDP_REV_41) - mdp4_mixer_blend_cfg(MDP4_MIXER1); - - complete_all(&vctrl->dmae_comp); - mdp4_overlay_dma_commit(MDP4_MIXER1); - - vsync_irq_disable(INTR_DMA_E_DONE, MDP_DMA_E_TERM); - spin_unlock(&vctrl->spin_lock); -} - -/* - * mdp4_overlay1_done_dtv: called from isr - */ -void mdp4_overlay1_done_dtv(void) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int cndx = 0; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - - spin_lock(&vctrl->spin_lock); - if (pipe->ov_blt_addr == 0) { - spin_unlock(&vctrl->spin_lock); - return; - } - - mdp4_dtv_blt_dmae_update(pipe); - complete_all(&vctrl->ov_comp); - pipe->blt_dmap_done++; - vsync_irq_disable(INTR_OVERLAY1_DONE, MDP_OVERLAY1_TERM); - spin_unlock(&vctrl->spin_lock); -} - -void mdp4_dtv_set_black_screen() -{ - char *rgb_base; - /*Black color*/ - uint32 color = 0x00000000; - uint32 temp_src_format; - int commit = 1, cndx = 0; - int pipe_num = OVERLAY_PIPE_RGB1; - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[cndx]; - if (!hdmi_prim_display) - return; - - if (vctrl->base_pipe == NULL) - commit = 0; - else - pipe_num = vctrl->base_pipe->pipe_num; - - rgb_base = MDP_BASE; - rgb_base += (MDP4_RGB_OFF * (pipe_num + 2)); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* RGB Constant Color */ - MDP_OUTP(rgb_base + 0x1008, color); - - /* MDP_RGB_SRC_FORMAT */ - temp_src_format = inpdw(rgb_base + 0x0050); - MDP_OUTP(rgb_base + 0x0050, temp_src_format | BIT(22)); - - if (commit) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - mdp4_overlay_reg_flush(vctrl->base_pipe, 1); - mdp4_mixer_stage_up(vctrl->base_pipe, 0); - mdp4_mixer_stage_commit(vctrl->base_pipe->mixer_num); - } else { - /* MDP_OVERLAY_REG_FLUSH for pipe*/ - MDP_OUTP(MDP_BASE + 0x18000, - BIT(pipe_num + 2) | BIT(MDP4_MIXER1)); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - } -} - -static void mdp4_dtv_do_blt(struct msm_fb_data_type *mfd, int enable) -{ - unsigned long flag; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - u32 mode, ctrl; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - mode = (dbg_force_ov1_blt & 0x0f) ? - (dbg_force_ov1_blt & 0x0f) : vctrl->blt_mode; - ctrl = (dbg_force_ov1_blt >> 4) ? - (dbg_force_ov1_blt >> 4) : vctrl->blt_ctrl; - - pr_debug("%s: mode=%d, ctrl = %d, enable=%d ov_blt_addr=%x\n", - __func__, mode, ctrl, enable, (int)pipe->ov_blt_addr); - - if ((mode == MDP4_OVERLAY_MODE_BLT_ALWAYS_OFF) && - !pipe->ov_blt_addr) - return; - else if ((mode == MDP4_OVERLAY_MODE_BLT_ALWAYS_ON) && - pipe->ov_blt_addr) - return; - else if (enable && pipe->ov_blt_addr) - return; - else if (!enable && !pipe->ov_blt_addr) - return; - - if (pipe->ov_blt_addr == 0) { - mdp4_allocate_writeback_buf(vctrl->mfd, MDP4_MIXER1); - if (!vctrl->mfd->ov1_wb_buf->write_addr) { - pr_warning("%s: ctrl=%d blt_base NOT assigned\n", - __func__, cndx); - return; - } - } - - pr_debug("%s: mode=%d, ctrl=%d, enable=%d ov_blt_addr=%x\n", - __func__, mode, ctrl, enable, (int)pipe->ov_blt_addr); - - spin_lock_irqsave(&vctrl->spin_lock, flag); - if (enable && pipe->ov_blt_addr == 0) { - pipe->ov_blt_addr = vctrl->mfd->ov1_wb_buf->write_addr; - pipe->dma_blt_addr = vctrl->mfd->ov1_wb_buf->read_addr; - pipe->blt_cnt = 0; - pipe->ov_cnt = 0; - pipe->blt_dmap_done = 0; - pipe->blt_ov_koff = 0; - pipe->blt_ov_done = 0; - mdp4_stat.blt_dtv++; - vctrl->blt_free = 0; - } else if (enable == 0 && pipe->ov_blt_addr) { - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - vctrl->blt_free = 4; - } - spin_unlock_irqrestore(&vctrl->spin_lock, flag); - - if (ctrl == MDP4_OVERLAY_BLT_SWITCH_TG_ON) { - spin_lock_irqsave(&vctrl->spin_lock, flag); - if (!dtv_enabled) { - pr_debug("%s: blt switched not in isr dtv_enabled=%d\n", - __func__, dtv_enabled); - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmae_xy(pipe); - } else { - pr_debug("%s: blt switched in ISR dtv_enabled=%d\n", - __func__, dtv_enabled); - vctrl->blt_change++; - - } - spin_unlock_irqrestore(&vctrl->spin_lock, flag); - if (dtv_enabled) - mdp4_dtv_wait4dmae_done(0); - } else if (ctrl == MDP4_OVERLAY_BLT_SWITCH_TG_OFF) { - pr_debug("%s: dtv blt switched by turning TG off\n", - __func__); - if (dtv_enabled) { - mdp4_dtv_wait4dmae_done(0); - MDP_OUTP(MDP_BASE + DTV_BASE, 0); - msleep(20); - } - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmae_xy(pipe); - if (dtv_enabled) - MDP_OUTP(MDP_BASE + DTV_BASE, 1); - } else if (ctrl == MDP4_OVERLAY_BLT_SWITCH_POLL) { - pr_debug("%s: dtv blt change by polling status\n", - __func__); - while (inpdw(MDP_BASE + 0x0018) & 0x12) - cpu_relax(); - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmae_xy(pipe); - } else - pr_err("%s: ctrl=%d is not supported\n", __func__, ctrl); -} - -void mdp4_dtv_overlay_blt_start(struct msm_fb_data_type *mfd) -{ - mdp4_dtv_do_blt(mfd, 1); -} - -void mdp4_dtv_overlay_blt_stop(struct msm_fb_data_type *mfd) -{ - mdp4_dtv_do_blt(mfd, 0); -} - -void mdp4_dtv_overlay(struct msm_fb_data_type *mfd) -{ - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int wait = 0; - - mutex_lock(&mfd->dma->ov_mutex); - if (!mfd->panel_power_on) { - mutex_unlock(&mfd->dma->ov_mutex); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->base_pipe == NULL) - mdp4_overlay_dtv_set(mfd, NULL); - - pipe = vctrl->base_pipe; - - if (pipe == NULL) { - pr_warn("%s: dtv_pipe == NULL\n", __func__); - mutex_unlock(&mfd->dma->ov_mutex); - return; - } - - if (hdmi_prim_display && (pipe->pipe_used == 0 || - pipe->mixer_stage != MDP4_MIXER_STAGE_BASE)) { - pr_err("%s: NOT baselayer\n", __func__); - mutex_unlock(&mfd->dma->ov_mutex); - return; - } - - if (pipe->pipe_type == OVERLAY_TYPE_RGB) { - pipe->srcp0_addr = (uint32)mfd->ibuf.buf; - mdp4_dtv_pipe_queue(0, pipe); - } - - if (hdmi_prim_display) - wait = 1; - - mdp4_overlay_mdp_perf_upd(mfd, 1); - mdp4_dtv_pipe_commit(cndx, wait); - mdp4_overlay_mdp_perf_upd(mfd, 0); - mutex_unlock(&mfd->dma->ov_mutex); -} - -void mdp4_dtv_set_avparams(struct mdp4_overlay_pipe *pipe, int id) -{ - struct vsycn_ctrl *vctrl; - - if (pipe == NULL) { - pr_warn("%s: dtv_pipe == NULL\n", __func__); - return; - } - vctrl = &vsync_ctrl_db[0]; - if (pipe->pipe_num == OVERLAY_PIPE_VG1) - vctrl->vg1fd = id; - else if (pipe->pipe_num == OVERLAY_PIPE_VG2) - vctrl->vg2fd = id; -} - diff --git a/drivers/video/msm/mdp4_overlay_lcdc.c b/drivers/video/msm/mdp4_overlay_lcdc.c deleted file mode 100644 index 8c00cffac20d80f8768d2b4011ea24aae3645815..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay_lcdc.c +++ /dev/null @@ -1,989 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" - -#ifdef CONFIG_FB_MSM_MDP40 -#define LCDC_BASE 0xC0000 -#else -#define LCDC_BASE 0xE0000 -#endif - -int first_pixel_start_x; -int first_pixel_start_y; - -static int lcdc_enabled; - -#define MAX_CONTROLLER 1 - -static struct vsycn_ctrl { - struct device *dev; - int inited; - int update_ndx; - int ov_koff; - int ov_done; - atomic_t suspend; - atomic_t vsync_resume; - int wait_vsync_cnt; - int blt_change; - int blt_free; - int sysfs_created; - struct mutex update_lock; - struct completion ov_comp; - struct completion dmap_comp; - struct completion vsync_comp; - spinlock_t spin_lock; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *base_pipe; - struct vsync_update vlist[2]; - int vsync_irq_enabled; - ktime_t vsync_time; -} vsync_ctrl_db[MAX_CONTROLLER]; - - -/******************************************************* -to do: -1) move vsync_irq_enable/vsync_irq_disable to mdp.c to be shared -*******************************************************/ -static void vsync_irq_enable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, intr); - mdp_intr_mask |= intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - pr_debug("%s: IRQ-en done, term=%x\n", __func__, term); -} - -static void vsync_irq_disable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, intr); - mdp_intr_mask &= ~intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_disable_irq_nosync(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - pr_debug("%s: IRQ-dis done, term=%x\n", __func__, term); -} - -static void mdp4_overlay_lcdc_start(void) -{ - if (!lcdc_enabled) { - /* enable DSI block */ - mdp4_iommu_attach(); - mdp_pipe_ctrl(MDP_OVERLAY0_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + LCDC_BASE, 1); - lcdc_enabled = 1; - } -} - -/* - * mdp4_lcdc_pipe_queue: - * called from thread context - */ -void mdp4_lcdc_pipe_queue(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pp; - int undx; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - - pp = &vp->plist[pipe->pipe_ndx - 1]; /* ndx start form 1 */ - - pr_debug("%s: vndx=%d pipe_ndx=%d pid=%d\n", __func__, - undx, pipe->pipe_ndx, current->pid); - - *pp = *pipe; /* clone it */ - vp->update_cnt++; - mutex_unlock(&vctrl->update_lock); - mdp4_stat.overlay_play[pipe->mixer_num]++; -} - -static void mdp4_lcdc_blt_ov_update(struct mdp4_overlay_pipe *pipe); -static void mdp4_lcdc_wait4dmap(int cndx); -static void mdp4_lcdc_wait4ov(int cndx); - -int mdp4_lcdc_pipe_commit(int cndx, int wait) -{ - - int i, undx; - int mixer = 0; - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pipe; - struct mdp4_overlay_pipe *real_pipe; - unsigned long flags; - int cnt = 0; - - vctrl = &vsync_ctrl_db[cndx]; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - pipe = vctrl->base_pipe; - mixer = pipe->mixer_num; - - mdp_update_pm(vctrl->mfd, vctrl->vsync_time); - - if (vp->update_cnt == 0) { - mutex_unlock(&vctrl->update_lock); - return 0; - } - - vctrl->update_ndx++; - vctrl->update_ndx &= 0x01; - vp->update_cnt = 0; /* reset */ - if (vctrl->blt_free) { - vctrl->blt_free--; - if (vctrl->blt_free == 0) - mdp4_free_writeback_buf(vctrl->mfd, mixer); - } - mutex_unlock(&vctrl->update_lock); - - /* free previous committed iommu back to pool */ - mdp4_overlay_iommu_unmap_freelist(mixer); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->ov_koff != vctrl->ov_done) { - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - pr_err("%s: Error, frame dropped %d %d\n", __func__, - vctrl->ov_koff, vctrl->ov_done); - return 0; - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - mdp4_overlay_mdp_perf_upd(vctrl->mfd, 1); - - if (vctrl->blt_change) { - pipe = vctrl->base_pipe; - spin_lock_irqsave(&vctrl->spin_lock, flags); - INIT_COMPLETION(vctrl->dmap_comp); - INIT_COMPLETION(vctrl->ov_comp); - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - mdp4_lcdc_wait4dmap(0); - if (pipe->ov_blt_addr) - mdp4_lcdc_wait4ov(0); - } - - pipe = vp->plist; - for (i = 0; i < OVERLAY_PIPE_MAX; i++, pipe++) { - if (pipe->pipe_used) { - cnt++; - real_pipe = mdp4_overlay_ndx2pipe(pipe->pipe_ndx); - if (real_pipe && real_pipe->pipe_used) { - /* pipe not unset */ - mdp4_overlay_vsync_commit(pipe); - } - /* free previous iommu to freelist - * which will be freed at next - * pipe_commit - */ - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 0); - pipe->pipe_used = 0; /* clear */ - } - } - - mdp4_mixer_stage_commit(mixer); - - /* start timing generator & mmu if they are not started yet */ - mdp4_overlay_lcdc_start(); - - pipe = vctrl->base_pipe; - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (pipe->ov_blt_addr) { - mdp4_lcdc_blt_ov_update(pipe); - pipe->ov_cnt++; - INIT_COMPLETION(vctrl->ov_comp); - vsync_irq_enable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - mb(); - vctrl->ov_koff++; - /* kickoff overlay engine */ - mdp4_stat.kickoff_ov0++; - outpdw(MDP_BASE + 0x0004, 0); - } else { - /* schedule second phase update at dmap */ - INIT_COMPLETION(vctrl->dmap_comp); - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - mdp4_stat.overlay_commit[pipe->mixer_num]++; - - if (wait) { - if (pipe->ov_blt_addr) - mdp4_lcdc_wait4ov(cndx); - else - mdp4_lcdc_wait4dmap(cndx); - } - - return cnt; -} - -void mdp4_lcdc_vsync_ctrl(struct fb_info *info, int enable) -{ - struct vsycn_ctrl *vctrl; - int cndx = 0; - - vctrl = &vsync_ctrl_db[cndx]; - - if (vctrl->vsync_irq_enabled == enable) - return; - - pr_debug("%s: vsync enable=%d\n", __func__, enable); - - vctrl->vsync_irq_enabled = enable; - - if (enable) - vsync_irq_enable(INTR_PRIMARY_VSYNC, MDP_PRIM_VSYNC_TERM); - else - vsync_irq_disable(INTR_PRIMARY_VSYNC, MDP_PRIM_VSYNC_TERM); - - if (vctrl->vsync_irq_enabled && atomic_read(&vctrl->suspend) == 0) - atomic_set(&vctrl->vsync_resume, 1); -} - -void mdp4_lcdc_wait4vsync(int cndx, long long *vtime) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - unsigned long flags; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (atomic_read(&vctrl->suspend) > 0) { - *vtime = -1; - return; - } - - /* start timing generator & mmu if they are not started yet */ - mdp4_overlay_lcdc_start(); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - wait_for_completion(&vctrl->vsync_comp); - mdp4_stat.wait4vsync0++; - - *vtime = vctrl->vsync_time.tv64; -} - -static void mdp4_lcdc_wait4dmap(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->dmap_comp); -} - -static void mdp4_lcdc_wait4ov(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->ov_comp); -} - -ssize_t mdp4_lcdc_show_event(struct device *dev, - struct device_attribute *attr, char *buf) -{ - int cndx; - struct vsycn_ctrl *vctrl; - ssize_t ret = 0; - unsigned long flags; - u64 vsync_tick; - - cndx = 0; - vctrl = &vsync_ctrl_db[0]; - - if (atomic_read(&vctrl->suspend) > 0 || - atomic_read(&vctrl->vsync_resume) == 0) - return 0; - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - ret = wait_for_completion_interruptible_timeout(&vctrl->vsync_comp, - msecs_to_jiffies(VSYNC_PERIOD * 4)); - if (ret <= 0) { - vctrl->wait_vsync_cnt = 0; - vsync_tick = ktime_to_ns(ktime_get()); - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick); - buf[strlen(buf) + 1] = '\0'; - return ret; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - vsync_tick = ktime_to_ns(vctrl->vsync_time); - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick); - buf[strlen(buf) + 1] = '\0'; - return ret; -} - -void mdp4_lcdc_vsync_init(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - pr_info("%s: ndx=%d\n", __func__, cndx); - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->inited) - return; - - vctrl->inited = 1; - vctrl->update_ndx = 0; - mutex_init(&vctrl->update_lock); - init_completion(&vctrl->vsync_comp); - init_completion(&vctrl->dmap_comp); - init_completion(&vctrl->ov_comp); - atomic_set(&vctrl->suspend, 1); - atomic_set(&vctrl->vsync_resume, 1); - spin_lock_init(&vctrl->spin_lock); -} - -void mdp4_lcdc_base_swap(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->base_pipe = pipe; -} - -int mdp4_lcdc_on(struct platform_device *pdev) -{ - int lcdc_width; - int lcdc_height; - int lcdc_bpp; - int lcdc_border_clr; - int lcdc_underflow_clr; - int lcdc_hsync_skew; - - int hsync_period; - int hsync_ctrl; - int vsync_period; - int display_hctl; - int display_v_start; - int display_v_end; - int active_hctl; - int active_h_start; - int active_h_end; - int active_v_start; - int active_v_end; - int ctrl_polarity; - int h_back_porch; - int h_front_porch; - int v_back_porch; - int v_front_porch; - int hsync_pulse_width; - int vsync_pulse_width; - int hsync_polarity; - int vsync_polarity; - int data_en_polarity; - int hsync_start_x; - int hsync_end_x; - uint8 *buf; - unsigned int buf_offset; - int bpp, ptype; - struct fb_info *fbi; - struct fb_var_screeninfo *var; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *pipe; - int ret = 0; - int cndx = 0; - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[cndx]; - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - vctrl->mfd = mfd; - vctrl->dev = mfd->fbi->dev; - - /* mdp clock on */ - mdp_clk_ctrl(1); - - fbi = mfd->fbi; - var = &fbi->var; - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = calc_fb_offset(mfd, fbi, bpp); - - if (vctrl->base_pipe == NULL) { - ptype = mdp4_overlay_format2type(mfd->fb_imgType); - if (ptype < 0) - printk(KERN_INFO "%s: format2type failed\n", __func__); - pipe = mdp4_overlay_pipe_alloc(ptype, MDP4_MIXER0); - if (pipe == NULL) - printk(KERN_INFO "%s: pipe_alloc failed\n", __func__); - pipe->pipe_used++; - pipe->mixer_stage = MDP4_MIXER_STAGE_BASE; - pipe->mixer_num = MDP4_MIXER0; - pipe->src_format = mfd->fb_imgType; - mdp4_overlay_panel_mode(pipe->mixer_num, MDP4_PANEL_LCDC); - ret = mdp4_overlay_format2pipe(pipe); - if (ret < 0) - printk(KERN_INFO "%s: format2pipe failed\n", __func__); - - mdp4_init_writeback_buf(mfd, MDP4_MIXER0); - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - - vctrl->base_pipe = pipe; /* keep it */ - } else { - pipe = vctrl->base_pipe; - } - - - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - - if (mfd->display_iova) - pipe->srcp0_addr = mfd->display_iova + buf_offset; - else - pipe->srcp0_addr = (uint32)(buf + buf_offset); - - pipe->srcp0_ystride = fbi->fix.line_length; - pipe->bpp = bpp; - - mdp4_overlay_mdp_pipe_req(pipe, mfd); - mdp4_calc_blt_mdp_bw(mfd, pipe); - - atomic_set(&vctrl->suspend, 0); - - mdp4_overlay_dmap_xy(pipe); - mdp4_overlay_dmap_cfg(mfd, 1); - mdp4_overlay_rgb_setup(pipe); - mdp4_overlayproc_cfg(pipe); - - mdp4_overlay_reg_flush(pipe, 1); - mdp4_mixer_stage_up(pipe, 0); - - - /* - * LCDC timing setting - */ - h_back_porch = var->left_margin; - h_front_porch = var->right_margin; - v_back_porch = var->upper_margin; - v_front_porch = var->lower_margin; - hsync_pulse_width = var->hsync_len; - vsync_pulse_width = var->vsync_len; - lcdc_border_clr = mfd->panel_info.lcdc.border_clr; - lcdc_underflow_clr = mfd->panel_info.lcdc.underflow_clr; - lcdc_hsync_skew = mfd->panel_info.lcdc.hsync_skew; - - lcdc_width = var->xres + mfd->panel_info.lcdc.xres_pad; - lcdc_height = var->yres + mfd->panel_info.lcdc.yres_pad; - lcdc_bpp = mfd->panel_info.bpp; - - hsync_period = - hsync_pulse_width + h_back_porch + h_front_porch; - if ((mfd->panel_info.type == LVDS_PANEL) && - (mfd->panel_info.lvds.channel_mode == LVDS_DUAL_CHANNEL_MODE)) - hsync_period += lcdc_width / 2; - else - hsync_period += lcdc_width; - hsync_ctrl = (hsync_period << 16) | hsync_pulse_width; - hsync_start_x = hsync_pulse_width + h_back_porch; - hsync_end_x = hsync_period - h_front_porch - 1; - display_hctl = (hsync_end_x << 16) | hsync_start_x; - - vsync_period = - (vsync_pulse_width + v_back_porch + lcdc_height + - v_front_porch) * hsync_period; - display_v_start = - (vsync_pulse_width + v_back_porch) * hsync_period + lcdc_hsync_skew; - display_v_end = - vsync_period - (v_front_porch * hsync_period) + lcdc_hsync_skew - 1; - - if (lcdc_width != var->xres) { - active_h_start = hsync_start_x + first_pixel_start_x; - active_h_end = active_h_start + var->xres - 1; - active_hctl = - ACTIVE_START_X_EN | (active_h_end << 16) | active_h_start; - } else { - active_hctl = 0; - } - - if (lcdc_height != var->yres) { - active_v_start = - display_v_start + first_pixel_start_y * hsync_period; - active_v_end = active_v_start + (var->yres) * hsync_period - 1; - active_v_start |= ACTIVE_START_Y_EN; - } else { - active_v_start = 0; - active_v_end = 0; - } - - -#ifdef CONFIG_FB_MSM_MDP40 - if (mfd->panel_info.lcdc.is_sync_active_high) { - hsync_polarity = 0; - vsync_polarity = 0; - } else { - hsync_polarity = 1; - vsync_polarity = 1; - } - lcdc_underflow_clr |= 0x80000000; /* enable recovery */ -#else - hsync_polarity = 0; - vsync_polarity = 0; -#endif - data_en_polarity = 0; - - ctrl_polarity = - (data_en_polarity << 2) | (vsync_polarity << 1) | (hsync_polarity); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x4, hsync_ctrl); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x8, vsync_period); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0xc, vsync_pulse_width * hsync_period); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x10, display_hctl); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x14, display_v_start); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x18, display_v_end); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x28, lcdc_border_clr); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x2c, lcdc_underflow_clr); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x30, lcdc_hsync_skew); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x38, ctrl_polarity); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x1c, active_hctl); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x20, active_v_start); - MDP_OUTP(MDP_BASE + LCDC_BASE + 0x24, active_v_end); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - mdp_histogram_ctrl_all(TRUE); - - return ret; -} - -int mdp4_lcdc_off(struct platform_device *pdev) -{ - int ret = 0; - int cndx = 0; - struct msm_fb_data_type *mfd; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - struct vsync_update *vp; - unsigned long flags; - int undx, need_wait = 0; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - atomic_set(&vctrl->suspend, 1); - atomic_set(&vctrl->vsync_resume, 0); - - msleep(20); /* >= 17 ms */ - - complete_all(&vctrl->vsync_comp); - - if (pipe->ov_blt_addr) { - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->ov_koff != vctrl->ov_done) - need_wait = 1; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - if (need_wait) - mdp4_lcdc_wait4ov(0); - } - - mdp_histogram_ctrl_all(FALSE); - - MDP_OUTP(MDP_BASE + LCDC_BASE, 0); - - lcdc_enabled = 0; - - if (vctrl->vsync_irq_enabled) { - vctrl->vsync_irq_enabled = 0; - vsync_irq_disable(INTR_PRIMARY_VSYNC, MDP_PRIM_VSYNC_TERM); - } - - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - if (vp->update_cnt) { - /* - * pipe's iommu will be freed at next overlay play - * and iommu_drop statistic will be increased by one - */ - vp->update_cnt = 0; /* empty queue */ - } - - if (pipe) { - /* sanity check, free pipes besides base layer */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - if (mfd->ref_cnt == 0) { - /* adb stop */ - if (pipe->pipe_type == OVERLAY_TYPE_BF) - mdp4_overlay_borderfill_stage_down(pipe); - - /* base pipe may change after borderfill_stage_down */ - pipe = vctrl->base_pipe; - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - vctrl->base_pipe = NULL; - } else { - /* system suspending */ - mdp4_mixer_stage_down(vctrl->base_pipe, 1); - mdp4_overlay_iommu_pipe_free( - vctrl->base_pipe->pipe_ndx, 1); - } - } - - /* MDP clock disable */ - mdp_clk_ctrl(0); - mdp_pipe_ctrl(MDP_OVERLAY0_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return ret; -} - -static void mdp4_lcdc_blt_ov_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - char *overlay_base; - - if (pipe->ov_blt_addr == 0) - return; - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->ov_blt_addr + off; - - /* overlay 0 */ - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - outpdw(overlay_base + 0x000c, addr); - outpdw(overlay_base + 0x001c, addr); -} - -static void mdp4_lcdc_blt_dmap_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - - if (pipe->ov_blt_addr == 0) - return; - -#ifdef BLT_RGB565 - bpp = 2; /* overlay ouput is RGB565 */ -#else - bpp = 3; /* overlay ouput is RGB888 */ -#endif - off = 0; - if (pipe->dmap_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->dma_blt_addr + off; - - /* dmap */ - MDP_OUTP(MDP_BASE + 0x90008, addr); -} - -/* - * mdp4_primary_vsync_lcdc: called from isr - */ -void mdp4_primary_vsync_lcdc(void) -{ - int cndx; - struct vsycn_ctrl *vctrl; - - cndx = 0; - vctrl = &vsync_ctrl_db[cndx]; - pr_debug("%s: cpu=%d\n", __func__, smp_processor_id()); - - spin_lock(&vctrl->spin_lock); - vctrl->vsync_time = ktime_get(); - - if (vctrl->wait_vsync_cnt) { - complete_all(&vctrl->vsync_comp); - vctrl->wait_vsync_cnt = 0; - } - - spin_unlock(&vctrl->spin_lock); -} - -/* - * mdp4_dma_p_done_lcdc: called from isr - */ -void mdp4_dmap_done_lcdc(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - if (vctrl->blt_change) { - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmap_xy(pipe); - if (pipe->ov_blt_addr) { - mdp4_lcdc_blt_ov_update(pipe); - pipe->ov_cnt++; - /* Prefill one frame */ - vsync_irq_enable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - /* kickoff overlay0 engine */ - mdp4_stat.kickoff_ov0++; - vctrl->ov_koff++; /* make up for prefill */ - outpdw(MDP_BASE + 0x0004, 0); - } - vctrl->blt_change = 0; - } - - complete_all(&vctrl->dmap_comp); - - if (mdp_rev <= MDP_REV_41) - mdp4_mixer_blend_cfg(MDP4_MIXER0); - - mdp4_overlay_dma_commit(cndx); - spin_unlock(&vctrl->spin_lock); -} - -/* - * mdp4_overlay0_done_lcdc: called from isr - */ -void mdp4_overlay0_done_lcdc(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) - return; - - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - vctrl->ov_done++; - complete_all(&vctrl->ov_comp); - if (pipe->ov_blt_addr == 0) { - spin_unlock(&vctrl->spin_lock); - return; - } - - mdp4_lcdc_blt_dmap_update(pipe); - pipe->dmap_cnt++; - spin_unlock(&vctrl->spin_lock); -} - -static void mdp4_lcdc_do_blt(struct msm_fb_data_type *mfd, int enable) -{ - unsigned long flag; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0); - - if (mfd->ov0_wb_buf->write_addr == 0) { - pr_info("%s: no blt_base assigned\n", __func__); - return; - } - - spin_lock_irqsave(&vctrl->spin_lock, flag); - if (enable && pipe->ov_blt_addr == 0) { - pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr; - pipe->dma_blt_addr = mfd->ov0_wb_buf->read_addr; - pipe->ov_cnt = 0; - pipe->dmap_cnt = 0; - vctrl->ov_koff = 0; - vctrl->ov_done = 0; - vctrl->blt_free = 0; - mdp4_stat.blt_lcdc++; - vctrl->blt_change++; - } else if (enable == 0 && pipe->ov_blt_addr) { - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - vctrl->blt_free = 4; /* 4 commits to free wb buf */ - vctrl->blt_change++; - } - - pr_info("%s: enable=%d change=%d blt_addr=%x\n", __func__, - vctrl->blt_change, enable, (int)pipe->ov_blt_addr); - - if (!vctrl->blt_change) { - spin_unlock_irqrestore(&vctrl->spin_lock, flag); - return; - } - - spin_unlock_irqrestore(&vctrl->spin_lock, flag); -} - -void mdp4_lcdc_overlay_blt(struct msm_fb_data_type *mfd, - struct msmfb_overlay_blt *req) -{ - mdp4_lcdc_do_blt(mfd, req->enable); -} - -void mdp4_lcdc_overlay_blt_start(struct msm_fb_data_type *mfd) -{ - mdp4_lcdc_do_blt(mfd, 1); -} - -void mdp4_lcdc_overlay_blt_stop(struct msm_fb_data_type *mfd) -{ - mdp4_lcdc_do_blt(mfd, 0); -} - -void mdp4_lcdc_overlay(struct msm_fb_data_type *mfd) -{ - struct fb_info *fbi = mfd->fbi; - uint8 *buf; - unsigned int buf_offset; - int bpp; - int cnt, cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - mutex_lock(&mfd->dma->ov_mutex); - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (!pipe || !mfd->panel_power_on) { - mutex_unlock(&mfd->dma->ov_mutex); - return; - } - - pr_debug("%s: cpu=%d pid=%d\n", __func__, - smp_processor_id(), current->pid); - if (pipe->pipe_type == OVERLAY_TYPE_RGB) { - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = calc_fb_offset(mfd, fbi, bpp); - - if (mfd->display_iova) - pipe->srcp0_addr = mfd->display_iova + buf_offset; - else - pipe->srcp0_addr = (uint32)(buf + buf_offset); - - mdp4_lcdc_pipe_queue(0, pipe); - } - - mdp4_overlay_mdp_perf_upd(mfd, 1); - - cnt = mdp4_lcdc_pipe_commit(cndx, 0); - if (cnt) { - if (pipe->ov_blt_addr) - mdp4_lcdc_wait4ov(cndx); - else - mdp4_lcdc_wait4dmap(cndx); - } - - mdp4_overlay_mdp_perf_upd(mfd, 0); - mutex_unlock(&mfd->dma->ov_mutex); -} diff --git a/drivers/video/msm/mdp4_overlay_mddi.c b/drivers/video/msm/mdp4_overlay_mddi.c deleted file mode 100644 index f785316b86f1cf6173562213ca677901f3aedef9..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay_mddi.c +++ /dev/null @@ -1,1066 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" - -static int mddi_state; - -#define TOUT_PERIOD HZ /* 1 second */ -#define MS_100 (HZ/10) /* 100 ms */ - -static int vsync_start_y_adjust = 4; - -#define MAX_CONTROLLER 1 -#define VSYNC_EXPIRE_TICK 8 - -static struct vsycn_ctrl { - struct device *dev; - int inited; - int update_ndx; - int expire_tick; - int blt_wait; - u32 ov_koff; - u32 ov_done; - u32 dmap_koff; - u32 dmap_done; - uint32 rdptr_intr_tot; - uint32 rdptr_sirq_tot; - atomic_t suspend; - int wait_vsync_cnt; - int blt_change; - int blt_free; - int blt_end; - int uevent; - struct mutex update_lock; - struct completion ov_comp; - struct completion dmap_comp; - struct completion vsync_comp; - spinlock_t spin_lock; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *base_pipe; - struct vsync_update vlist[2]; - int vsync_enabled; - int clk_enabled; - int clk_control; - int new_update; - ktime_t vsync_time; - struct work_struct vsync_work; - struct work_struct clk_work; -} vsync_ctrl_db[MAX_CONTROLLER]; - -static void vsync_irq_enable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - /* no need to clear other interrupts for comamnd mode */ - mdp_intr_mask |= intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -static void vsync_irq_disable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - /* no need to clrear other interrupts for comamnd mode */ - mdp_intr_mask &= ~intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_disable_irq_nosync(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -static void mdp4_mddi_blt_ov_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - char *overlay_base; - - if (pipe->ov_blt_addr == 0) - return; - - bpp = 3; /* overlay ouput is RGB888 */ - off = 0; - if (pipe->ov_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->ov_blt_addr + off; - /* overlay 0 */ - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - outpdw(overlay_base + 0x000c, addr); - outpdw(overlay_base + 0x001c, addr); -} - -static void mdp4_mddi_blt_dmap_update(struct mdp4_overlay_pipe *pipe) -{ - uint32 off, addr; - int bpp; - - if (pipe->ov_blt_addr == 0) - return; - - bpp = 3; /* overlay ouput is RGB888 */ - off = 0; - if (pipe->dmap_cnt & 0x01) - off = pipe->src_height * pipe->src_width * bpp; - addr = pipe->dma_blt_addr + off; - - /* dmap */ - MDP_OUTP(MDP_BASE + 0x90008, addr); -} - -static void mdp4_mddi_wait4dmap(int cndx); -static void mdp4_mddi_wait4ov(int cndx); - -static void mdp4_mddi_do_blt(struct msm_fb_data_type *mfd, int enable) -{ - unsigned long flags; - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int need_wait; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - mdp4_allocate_writeback_buf(mfd, MDP4_MIXER0); - - if (mfd->ov0_wb_buf->write_addr == 0) { - pr_err("%s: no blt_base assigned\n", __func__); - return; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (enable && pipe->ov_blt_addr == 0) { - vctrl->blt_change++; - if (vctrl->dmap_koff != vctrl->dmap_done) { - INIT_COMPLETION(vctrl->dmap_comp); - need_wait = 1; - } - } else if (enable == 0 && pipe->ov_blt_addr) { - vctrl->blt_change++; - if (vctrl->ov_koff != vctrl->dmap_done) { - INIT_COMPLETION(vctrl->dmap_comp); - need_wait = 1; - } - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - if (need_wait) - mdp4_mddi_wait4dmap(0); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (enable && pipe->ov_blt_addr == 0) { - pipe->ov_blt_addr = mfd->ov0_wb_buf->write_addr; - pipe->dma_blt_addr = mfd->ov0_wb_buf->read_addr; - pipe->ov_cnt = 0; - pipe->dmap_cnt = 0; - vctrl->ov_koff = vctrl->dmap_koff; - vctrl->ov_done = vctrl->dmap_done; - vctrl->blt_free = 0; - vctrl->blt_wait = 0; - vctrl->blt_end = 0; - mdp4_stat.blt_mddi++; - } else if (enable == 0 && pipe->ov_blt_addr) { - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - vctrl->blt_end = 1; - vctrl->blt_free = 4; /* 4 commits to free wb buf */ - } - - pr_debug("%s: changed=%d enable=%d ov_blt_addr=%x\n", __func__, - vctrl->blt_change, enable, (int)pipe->ov_blt_addr); - - spin_unlock_irqrestore(&vctrl->spin_lock, flags); -} - -/* - * mdp4_mddi_do_update: - * called from thread context - */ -void mdp4_mddi_pipe_queue(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pp; - int undx; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - - pp = &vp->plist[pipe->pipe_ndx - 1]; /* ndx start form 1 */ - - pr_debug("%s: vndx=%d pipe_ndx=%d expire=%x pid=%d\n", __func__, - undx, pipe->pipe_ndx, vctrl->expire_tick, current->pid); - - *pp = *pipe; /* clone it */ - vp->update_cnt++; - - mutex_unlock(&vctrl->update_lock); - mdp4_stat.overlay_play[pipe->mixer_num]++; -} - -static void mdp4_mddi_blt_ov_update(struct mdp4_overlay_pipe *pipe); - -int mdp4_mddi_pipe_commit(void) -{ - int i, undx; - int mixer = 0; - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pipe; - struct mdp4_overlay_pipe *real_pipe; - unsigned long flags; - int need_dmap_wait = 0; - int need_ov_wait = 0; - int cnt = 0; - - vctrl = &vsync_ctrl_db[0]; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - pipe = vctrl->base_pipe; - mixer = pipe->mixer_num; - - if (vp->update_cnt == 0) { - mutex_unlock(&vctrl->update_lock); - return cnt; - } - - vctrl->update_ndx++; - vctrl->update_ndx &= 0x01; - vp->update_cnt = 0; /* reset */ - if (vctrl->blt_free) { - vctrl->blt_free--; - if (vctrl->blt_free == 0) - mdp4_free_writeback_buf(vctrl->mfd, mixer); - } - mutex_unlock(&vctrl->update_lock); - - /* free previous committed iommu back to pool */ - mdp4_overlay_iommu_unmap_freelist(mixer); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (pipe->ov_blt_addr) { - /* Blt */ - if (vctrl->blt_wait) - need_dmap_wait = 1; - if (vctrl->ov_koff != vctrl->ov_done) { - INIT_COMPLETION(vctrl->ov_comp); - need_ov_wait = 1; - } - } else { - /* direct out */ - if (vctrl->dmap_koff != vctrl->dmap_done) { - INIT_COMPLETION(vctrl->dmap_comp); - pr_debug("%s: wait, ok=%d od=%d dk=%d dd=%d cpu=%d\n", - __func__, vctrl->ov_koff, vctrl->ov_done, - vctrl->dmap_koff, vctrl->dmap_done, smp_processor_id()); - need_dmap_wait = 1; - } - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - if (need_dmap_wait) { - pr_debug("%s: wait4dmap\n", __func__); - mdp4_mddi_wait4dmap(0); - } - - if (need_ov_wait) { - pr_debug("%s: wait4ov\n", __func__); - mdp4_mddi_wait4ov(0); - } - - if (pipe->ov_blt_addr) { - if (vctrl->blt_end) { - vctrl->blt_end = 0; - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - } - } - - if (vctrl->blt_change) { - mdp4_overlayproc_cfg(pipe); - mdp4_overlay_dmap_xy(pipe); - vctrl->blt_change = 0; - } - - pipe = vp->plist; - for (i = 0; i < OVERLAY_PIPE_MAX; i++, pipe++) { - if (pipe->pipe_used) { - cnt++; - real_pipe = mdp4_overlay_ndx2pipe(pipe->pipe_ndx); - if (real_pipe && real_pipe->pipe_used) { - /* pipe not unset */ - mdp4_overlay_vsync_commit(pipe); - } - /* free previous iommu to freelist - * which will be freed at next - * pipe_commit - */ - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 0); - pipe->pipe_used = 0; /* clear */ - } - } - - mdp4_mixer_stage_commit(mixer); - - pipe = vctrl->base_pipe; - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (pipe->ov_blt_addr) { - mdp4_mddi_blt_ov_update(pipe); - pipe->ov_cnt++; - vctrl->ov_koff++; - vsync_irq_enable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - } else { - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - vctrl->dmap_koff++; - } - pr_debug("%s: kickoff\n", __func__); - /* kickoff overlay engine */ - mdp4_stat.kickoff_ov0++; - outpdw(MDP_BASE + 0x0004, 0); - mb(); /* make sure kickoff ececuted */ - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - mdp4_stat.overlay_commit[pipe->mixer_num]++; - - return cnt; -} - -void mdp4_mddi_vsync_ctrl(struct fb_info *info, int enable) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct vsycn_ctrl *vctrl; - unsigned long flags; - int clk_set_on = 0; - int cndx = 0; - - vctrl = &vsync_ctrl_db[cndx]; - - pr_debug("%s: clk_enabled=%d vsycn_enabeld=%d req=%d\n", __func__, - vctrl->clk_enabled, vctrl->vsync_enabled, enable); - - mutex_lock(&vctrl->update_lock); - - if (vctrl->vsync_enabled == enable) { - mutex_unlock(&vctrl->update_lock); - return; - } - - vctrl->vsync_enabled = enable; - - if (enable) { - if (vctrl->clk_enabled == 0) { - pr_debug("%s: SET_CLK_ON\n", __func__); - mdp_clk_ctrl(1); - vctrl->clk_enabled = 1; - clk_set_on = 1; - } - spin_lock_irqsave(&vctrl->spin_lock, flags); - vctrl->clk_control = 0; - vctrl->expire_tick = 0; - vctrl->uevent = 1; - vctrl->new_update = 1; - if (clk_set_on) { - vsync_irq_enable(INTR_PRIMARY_RDPTR, - MDP_PRIM_RDPTR_TERM); - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - mdp4_overlay_update_mddi(mfd); - } else { - spin_lock_irqsave(&vctrl->spin_lock, flags); - vctrl->clk_control = 1; - vctrl->uevent = 0; - if (vctrl->clk_enabled) - vctrl->expire_tick = VSYNC_EXPIRE_TICK; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - } - mutex_unlock(&vctrl->update_lock); -} - -void mdp4_mddi_wait4vsync(int cndx, long long *vtime) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - unsigned long flags; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - if (atomic_read(&vctrl->suspend) > 0) { - *vtime = -1; - return; - } - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->wait_vsync_cnt == 0) - INIT_COMPLETION(vctrl->vsync_comp); - vctrl->wait_vsync_cnt++; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - wait_for_completion(&vctrl->vsync_comp); - mdp4_stat.wait4vsync0++; - - *vtime = ktime_to_ns(vctrl->vsync_time); -} - -static void mdp4_mddi_wait4dmap(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->dmap_comp); -} - -static void mdp4_mddi_wait4ov(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->ov_comp); -} - -/* - * primary_rdptr_isr: - * called from interrupt context - */ -static void primary_rdptr_isr(int cndx) -{ - struct vsycn_ctrl *vctrl; - - vctrl = &vsync_ctrl_db[cndx]; - pr_debug("%s: ISR, cpu=%d\n", __func__, smp_processor_id()); - vctrl->rdptr_intr_tot++; - vctrl->vsync_time = ktime_get(); - - spin_lock(&vctrl->spin_lock); - - if (vctrl->uevent) - schedule_work(&vctrl->vsync_work); - - if (vctrl->wait_vsync_cnt) { - complete(&vctrl->vsync_comp); - vctrl->wait_vsync_cnt = 0; - } - - if (vctrl->expire_tick) { - vctrl->expire_tick--; - if (vctrl->expire_tick == 0) - schedule_work(&vctrl->clk_work); - } - spin_unlock(&vctrl->spin_lock); -} - -void mdp4_dmap_done_mddi(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int diff; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - /* blt enabled */ - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - vctrl->dmap_done++; - diff = vctrl->ov_done - vctrl->dmap_done; - pr_debug("%s: ov_koff=%d ov_done=%d dmap_koff=%d dmap_done=%d cpu=%d\n", - __func__, vctrl->ov_koff, vctrl->ov_done, vctrl->dmap_koff, - vctrl->dmap_done, smp_processor_id()); - complete_all(&vctrl->dmap_comp); - if (diff <= 0) { - if (vctrl->blt_wait) - vctrl->blt_wait = 0; - spin_unlock(&vctrl->spin_lock); - return; - } - - /* kick dmap */ - mdp4_mddi_blt_dmap_update(pipe); - pipe->dmap_cnt++; - mdp4_stat.kickoff_dmap++; - vctrl->dmap_koff++; - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - outpdw(MDP_BASE + 0x000c, 0); /* kickoff dmap engine */ - mb(); /* make sure kickoff executed */ - spin_unlock(&vctrl->spin_lock); -} - -/* - * mdp4_overlay0_done_mddi: called from isr - */ -void mdp4_overlay0_done_mddi(int cndx) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int diff; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_OVERLAY0_DONE, MDP_OVERLAY0_TERM); - vctrl->ov_done++; - complete_all(&vctrl->ov_comp); - diff = vctrl->ov_done - vctrl->dmap_done; - - pr_debug("%s: ov_koff=%d ov_done=%d dmap_koff=%d dmap_done=%d cpu=%d\n", - __func__, vctrl->ov_koff, vctrl->ov_done, vctrl->dmap_koff, - vctrl->dmap_done, smp_processor_id()); - - if (pipe->ov_blt_addr == 0) { - /* blt disabled */ - spin_unlock(&vctrl->spin_lock); - return; - } - - if (diff > 1) { - /* - * two overlay_done and none dmap_done yet - * let dmap_done kickoff dmap - * and put pipe_commit to wait - */ - vctrl->blt_wait = 1; - pr_debug("%s: blt_wait set\n", __func__); - spin_unlock(&vctrl->spin_lock); - return; - } - mdp4_mddi_blt_dmap_update(pipe); - pipe->dmap_cnt++; - mdp4_stat.kickoff_dmap++; - vctrl->dmap_koff++; - vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM); - outpdw(MDP_BASE + 0x000c, 0); /* kickoff dmap engine */ - mb(); /* make sure kickoff executed */ - spin_unlock(&vctrl->spin_lock); -} - -static void clk_ctrl_work(struct work_struct *work) -{ - struct vsycn_ctrl *vctrl = - container_of(work, typeof(*vctrl), clk_work); - unsigned long flags; - - mutex_lock(&vctrl->update_lock); - if (vctrl->clk_control && vctrl->clk_enabled) { - pr_debug("%s: SET_CLK_OFF\n", __func__); - mdp_clk_ctrl(0); - spin_lock_irqsave(&vctrl->spin_lock, flags); - vsync_irq_disable(INTR_PRIMARY_RDPTR, MDP_PRIM_RDPTR_TERM); - vctrl->clk_enabled = 0; - vctrl->clk_control = 0; - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - } - mutex_unlock(&vctrl->update_lock); -} - -static void send_vsync_work(struct work_struct *work) -{ - struct vsycn_ctrl *vctrl = - container_of(work, typeof(*vctrl), vsync_work); - char buf[64]; - char *envp[2]; - - snprintf(buf, sizeof(buf), "VSYNC=%llu", - ktime_to_ns(vctrl->vsync_time)); - envp[0] = buf; - envp[1] = NULL; - kobject_uevent_env(&vctrl->dev->kobj, KOBJ_CHANGE, envp); -} - - -void mdp4_mddi_rdptr_init(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->inited) - return; - - vctrl->inited = 1; - vctrl->update_ndx = 0; - mutex_init(&vctrl->update_lock); - init_completion(&vctrl->ov_comp); - init_completion(&vctrl->dmap_comp); - init_completion(&vctrl->vsync_comp); - spin_lock_init(&vctrl->spin_lock); - INIT_WORK(&vctrl->vsync_work, send_vsync_work); - INIT_WORK(&vctrl->clk_work, clk_ctrl_work); -} - -void mdp4_primary_rdptr(void) -{ - primary_rdptr_isr(0); -} - -void mdp4_overlay_mddi_state_set(int state) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - mddi_state = state; - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -int mdp4_overlay_mddi_state_get(void) -{ - return mddi_state; -} - -static __u32 msm_fb_line_length(__u32 fb_index, __u32 xres, int bpp) -{ - /* - * The adreno GPU hardware requires that the pitch be aligned to - * 32 pixels for color buffers, so for the cases where the GPU - * is writing directly to fb0, the framebuffer pitch - * also needs to be 32 pixel aligned - */ - - if (fb_index == 0) - return ALIGN(xres, 32) * bpp; - else - return xres * bpp; -} - -void mdp4_mddi_vsync_enable(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe, int which) -{ - uint32 start_y, data, tear_en; - - tear_en = (1 << which); - - if ((mfd->use_mdp_vsync) && (mfd->ibuf.vsync_enable) && - (mfd->panel_info.lcd.vsync_enable)) { - - if (vsync_start_y_adjust <= pipe->dst_y) - start_y = pipe->dst_y - vsync_start_y_adjust; - else - start_y = (mfd->total_lcd_lines - 1) - - (vsync_start_y_adjust - pipe->dst_y); - if (which == 0) - MDP_OUTP(MDP_BASE + 0x210, start_y); /* primary */ - else - MDP_OUTP(MDP_BASE + 0x214, start_y); /* secondary */ - - data = inpdw(MDP_BASE + 0x20c); - data |= tear_en; - MDP_OUTP(MDP_BASE + 0x20c, data); - } else { - data = inpdw(MDP_BASE + 0x20c); - data &= ~tear_en; - MDP_OUTP(MDP_BASE + 0x20c, data); - } -} - -void mdp4_mddi_base_swap(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->base_pipe = pipe; -} - -static void mdp4_overlay_setup_pipe_addr(struct msm_fb_data_type *mfd, - struct mdp4_overlay_pipe *pipe) -{ - MDPIBUF *iBuf = &mfd->ibuf; - struct fb_info *fbi; - int bpp; - uint8 *src; - - /* whole screen for base layer */ - src = (uint8 *) iBuf->buf; - fbi = mfd->fbi; - - if (pipe->is_3d) { - bpp = fbi->var.bits_per_pixel / 8; - pipe->src_height = pipe->src_height_3d; - pipe->src_width = pipe->src_width_3d; - pipe->src_h = pipe->src_height_3d; - pipe->src_w = pipe->src_width_3d; - pipe->dst_h = pipe->src_height_3d; - pipe->dst_w = pipe->src_width_3d; - pipe->srcp0_ystride = msm_fb_line_length(0, - pipe->src_width, bpp); - } else { - /* 2D */ - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->srcp0_ystride = fbi->fix.line_length; - } - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_y = 0; - pipe->dst_x = 0; - pipe->srcp0_addr = (uint32)src; -} - -void mdp4_overlay_update_mddi(struct msm_fb_data_type *mfd) -{ - int ptype; - uint32 mddi_ld_param; - uint16 mddi_vdo_packet_reg; - struct mdp4_overlay_pipe *pipe; - uint32 data; - int ret; - int cndx = 0; - struct vsycn_ctrl *vctrl; - - if (mfd->key != MFD_KEY) - return; - - vctrl = &vsync_ctrl_db[cndx]; - - if (vctrl->base_pipe == NULL) { - ptype = mdp4_overlay_format2type(mfd->fb_imgType); - - if (ptype < 0) - pr_err("%s: format2type failed\n", __func__); - - pipe = mdp4_overlay_pipe_alloc(ptype, MDP4_MIXER0); - if (pipe == NULL) { - pr_err("%s: pipe_alloc failed\n", __func__); - return; - } - pipe->pipe_used++; - pipe->mixer_stage = MDP4_MIXER_STAGE_BASE; - pipe->mixer_num = MDP4_MIXER0; - pipe->src_format = mfd->fb_imgType; - mdp4_overlay_panel_mode(pipe->mixer_num, MDP4_PANEL_MDDI); - ret = mdp4_overlay_format2pipe(pipe); - if (ret < 0) - pr_err("%s: format2type failed\n", __func__); - - vctrl->base_pipe = pipe; /* keep it */ - mdp4_init_writeback_buf(mfd, MDP4_MIXER0); - pipe->ov_blt_addr = 0; - pipe->dma_blt_addr = 0; - } else { - pipe = vctrl->base_pipe; - } - - MDP_OUTP(MDP_BASE + 0x021c, 10); /* read pointer */ - - mddi_ld_param = 0; - mddi_vdo_packet_reg = mfd->panel_info.mddi.vdopkt; - - if (mdp_hw_revision == MDP4_REVISION_V2_1) { - data = inpdw(MDP_BASE + 0x0028); - data &= ~0x0300; /* bit 8, 9, MASTER4 */ - if (mfd->fbi->var.xres == 540) /* qHD, 540x960 */ - data |= 0x0200; - else - data |= 0x0100; - - MDP_OUTP(MDP_BASE + 0x00028, data); - } - - if (mfd->panel_info.type == MDDI_PANEL) { - if (mfd->panel_info.pdest == DISPLAY_1) - mddi_ld_param = 0; - else - mddi_ld_param = 1; - } else { - mddi_ld_param = 2; - } - - MDP_OUTP(MDP_BASE + 0x00090, mddi_ld_param); - - if (mfd->panel_info.bpp == 24) - MDP_OUTP(MDP_BASE + 0x00094, - (MDDI_VDO_PACKET_DESC_24 << 16) | mddi_vdo_packet_reg); - else if (mfd->panel_info.bpp == 16) - MDP_OUTP(MDP_BASE + 0x00094, - (MDDI_VDO_PACKET_DESC_16 << 16) | mddi_vdo_packet_reg); - else - MDP_OUTP(MDP_BASE + 0x00094, - (MDDI_VDO_PACKET_DESC << 16) | mddi_vdo_packet_reg); - - MDP_OUTP(MDP_BASE + 0x00098, 0x01); - - - mdp4_overlay_setup_pipe_addr(mfd, pipe); - - mdp4_overlay_rgb_setup(pipe); - - mdp4_overlay_reg_flush(pipe, 1); - - mdp4_mixer_stage_up(pipe, 0); - - mdp4_overlayproc_cfg(pipe); - - mdp4_overlay_dmap_xy(pipe); - - mdp4_overlay_dmap_cfg(mfd, 0); - - mdp4_mixer_stage_commit(pipe->mixer_num); - - wmb(); -} - -void mdp4_mddi_blt_start(struct msm_fb_data_type *mfd) -{ - mdp4_mddi_do_blt(mfd, 1); -} - -void mdp4_mddi_blt_stop(struct msm_fb_data_type *mfd) -{ - mdp4_mddi_do_blt(mfd, 0); -} - -void mdp4_mddi_overlay_blt(struct msm_fb_data_type *mfd, - struct msmfb_overlay_blt *req) -{ - mdp4_mddi_do_blt(mfd, req->enable); -} - -int mdp4_mddi_on(struct platform_device *pdev) -{ - int ret = 0; - int cndx = 0; - struct msm_fb_data_type *mfd; - struct vsycn_ctrl *vctrl; - - pr_debug("%s+:\n", __func__); - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->mfd = mfd; - vctrl->dev = mfd->fbi->dev; - - mdp_clk_ctrl(1); - mdp4_overlay_update_mddi(mfd); - mdp_clk_ctrl(0); - - mdp4_iommu_attach(); - - atomic_set(&vctrl->suspend, 0); - pr_debug("%s-:\n", __func__); - - return ret; -} - -int mdp4_mddi_off(struct platform_device *pdev) -{ - int ret = 0; - int cndx = 0; - struct msm_fb_data_type *mfd; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - pr_debug("%s+:\n", __func__); - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) { - pr_err("%s: NO base pipe\n", __func__); - return ret; - } - - atomic_set(&vctrl->suspend, 1); - - /* sanity check, free pipes besides base layer */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - vctrl->base_pipe = NULL; - - if (vctrl->clk_enabled) { - /* - * in case of suspend, vsycn_ctrl off is not - * received from frame work which left clock on - * then, clock need to be turned off here - */ - mdp_clk_ctrl(0); - } - - vctrl->clk_enabled = 0; - vctrl->vsync_enabled = 0; - vctrl->clk_control = 0; - vctrl->expire_tick = 0; - vctrl->uevent = 0; - - vsync_irq_disable(INTR_PRIMARY_RDPTR, MDP_PRIM_RDPTR_TERM); - - pr_debug("%s-:\n", __func__); - - /* - * footswitch off - * this will casue all mdp register - * to be reset to default - * after footswitch on later - */ - - return ret; -} - -void mdp_mddi_overlay_suspend(struct msm_fb_data_type *mfd) -{ - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - /* dis-engage rgb0 from mixer0 */ - if (pipe) { - if (mfd->ref_cnt == 0) { - /* adb stop */ - if (pipe->pipe_type == OVERLAY_TYPE_BF) - mdp4_overlay_borderfill_stage_down(pipe); - - /* pipe == rgb1 */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - vctrl->base_pipe = NULL; - } else { - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 1); - } - } -} - -void mdp4_mddi_overlay(struct msm_fb_data_type *mfd) -{ - int cndx = 0; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - unsigned long flags; - long long xx; - - vctrl = &vsync_ctrl_db[cndx]; - - if (!mfd->panel_power_on) - return; - - pipe = vctrl->base_pipe; - if (pipe == NULL) { - pr_err("%s: NO base pipe\n", __func__); - return; - } - - mutex_lock(&vctrl->update_lock); - if (!vctrl->clk_enabled) { - pr_err("%s: mdp clocks disabled\n", __func__); - mutex_unlock(&vctrl->update_lock); - return; - - } - mutex_unlock(&vctrl->update_lock); - - spin_lock_irqsave(&vctrl->spin_lock, flags); - if (vctrl->expire_tick) { - /* - * in the middle of shutting clocks down - * delay to allow pan display to go through - */ - vctrl->expire_tick = VSYNC_EXPIRE_TICK; - } - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - if (pipe->mixer_stage == MDP4_MIXER_STAGE_BASE) { - mdp4_mddi_vsync_enable(mfd, pipe, 0); - mdp4_overlay_setup_pipe_addr(mfd, pipe); - mdp4_mddi_pipe_queue(0, pipe); - } - - mdp4_overlay_mdp_perf_upd(mfd, 1); - - mutex_lock(&mfd->dma->ov_mutex); - mdp4_mddi_pipe_commit(); - mutex_unlock(&mfd->dma->ov_mutex); - mdp4_mddi_wait4vsync(0, &xx); - - mdp4_overlay_mdp_perf_upd(mfd, 0); -} - -int mdp4_mddi_overlay_cursor(struct fb_info *info, struct fb_cursor *cursor) -{ - struct msm_fb_data_type *mfd = info->par; - mutex_lock(&mfd->dma->ov_mutex); - if (mfd && mfd->panel_power_on) { - mdp_hw_cursor_update(info, cursor); - } - mutex_unlock(&mfd->dma->ov_mutex); - return 0; -} diff --git a/drivers/video/msm/mdp4_overlay_writeback.c b/drivers/video/msm/mdp4_overlay_writeback.c deleted file mode 100644 index 04f148c9452211453d6b765f4312f3a6966f1c8e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_overlay_writeback.c +++ /dev/null @@ -1,827 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" -enum { - WB_OPEN, - WB_START, - WB_STOPING, - WB_STOP -}; -enum { - REGISTERED, - IN_FREE_QUEUE, - IN_BUSY_QUEUE, - WITH_CLIENT -}; - -#define MAX_CONTROLLER 1 -#define VSYNC_EXPIRE_TICK 0 - -static struct vsycn_ctrl { - struct device *dev; - int inited; - int update_ndx; - u32 ov_koff; - u32 ov_done; - atomic_t suspend; - struct mutex update_lock; - struct completion ov_comp; - spinlock_t spin_lock; - struct msm_fb_data_type *mfd; - struct mdp4_overlay_pipe *base_pipe; - struct vsync_update vlist[2]; - struct work_struct clk_work; -} vsync_ctrl_db[MAX_CONTROLLER]; - -static void vsync_irq_enable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - /* no need to clrear other interrupts for comamnd mode */ - mdp_intr_mask |= intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -static void vsync_irq_disable(int intr, int term) -{ - unsigned long flag; - - spin_lock_irqsave(&mdp_spin_lock, flag); - /* no need to clrear other interrupts for comamnd mode */ - mdp_intr_mask &= ~intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_disable_irq_nosync(term); - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -static int mdp4_overlay_writeback_update(struct msm_fb_data_type *mfd); -static void mdp4_wfd_queue_wakeup(struct msm_fb_data_type *mfd, - struct msmfb_writeback_data_list *node); -static void mdp4_wfd_dequeue_update(struct msm_fb_data_type *mfd, - struct msmfb_writeback_data_list **wfdnode); - -int mdp4_overlay_writeback_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct fb_info *fbi; - uint8 *buf; - struct mdp4_overlay_pipe *pipe; - int bpp; - int ret; - uint32 data; - struct vsycn_ctrl *vctrl; - int cndx = 0; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - vctrl = &vsync_ctrl_db[cndx]; - vctrl->mfd = mfd; - vctrl->dev = mfd->fbi->dev; - - fbi = mfd->fbi; - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf += fbi->var.xoffset * bpp + - fbi->var.yoffset * fbi->fix.line_length; - - /* MDP cmd block enable */ - mdp_clk_ctrl(1); - - if (vctrl->base_pipe == NULL) { - pipe = mdp4_overlay_pipe_alloc(OVERLAY_TYPE_BF, MDP4_MIXER2); - if (pipe == NULL) { - pr_info("%s: pipe_alloc failed\n", __func__); - return -EIO; - } - pipe->pipe_used++; - pipe->mixer_stage = MDP4_MIXER_STAGE_BASE; - pipe->mixer_num = MDP4_MIXER2; - pipe->src_format = MDP_ARGB_8888; - mdp4_overlay_panel_mode(pipe->mixer_num, MDP4_PANEL_WRITEBACK); - ret = mdp4_overlay_format2pipe(pipe); - if (ret < 0) - pr_info("%s: format2type failed\n", __func__); - - vctrl->base_pipe = pipe; /* keep it */ - - } else { - pipe = vctrl->base_pipe; - } - - ret = panel_next_on(pdev); - - /* MDP_LAYERMIXER_WB_MUX_SEL to use mixer1 axi for mixer2 writeback */ - if (hdmi_prim_display) - data = 0x01; - else - data = 0x02; - outpdw(MDP_BASE + 0x100F4, data); - - MDP_OUTP(MDP_BASE + MDP4_OVERLAYPROC1_BASE + 0x5004, - ((0x0 & 0xFFF) << 16) | /* 12-bit B */ - (0x0 & 0xFFF)); /* 12-bit G */ - /* MSP_BORDER_COLOR */ - MDP_OUTP(MDP_BASE + MDP4_OVERLAYPROC1_BASE + 0x5008, - (0x0 & 0xFFF)); /* 12-bit R */ - - mdp_clk_ctrl(0); - return ret; -} - -int mdp4_overlay_writeback_off(struct platform_device *pdev) -{ - int cndx = 0; - struct msm_fb_data_type *mfd; - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int ret = 0; - int undx; - struct vsync_update *vp; - - pr_debug("%s+:\n", __func__); - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - if (pipe == NULL) { - pr_err("%s: NO base pipe\n", __func__); - return ret; - } - - /* sanity check, free pipes besides base layer */ - mdp4_overlay_unset_mixer(pipe->mixer_num); - mdp4_mixer_stage_down(pipe, 1); - mdp4_overlay_pipe_free(pipe); - vctrl->base_pipe = NULL; - - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - if (vp->update_cnt) { - /* - * pipe's iommu will be freed at next overlay play - * and iommu_drop statistic will be increased by one - */ - vp->update_cnt = 0; /* empty queue */ - } - - ret = panel_next_off(pdev); - - mdp_clk_ctrl(1); - /* MDP_LAYERMIXER_WB_MUX_SEL to restore to default cfg*/ - outpdw(MDP_BASE + 0x100F4, 0x0); - mdp_clk_ctrl(0); - pr_debug("%s-:\n", __func__); - return ret; -} - -static int mdp4_overlay_writeback_update(struct msm_fb_data_type *mfd) -{ - struct fb_info *fbi; - uint8 *buf; - unsigned int buf_offset; - struct mdp4_overlay_pipe *pipe; - int bpp; - int cndx = 0; - struct vsycn_ctrl *vctrl; - - if (mfd->key != MFD_KEY) - return -ENODEV; - - - fbi = mfd->fbi; - - vctrl = &vsync_ctrl_db[cndx]; - - pipe = vctrl->base_pipe; - if (!pipe) { - pr_err("%s: no base layer pipe\n", __func__); - return -EINVAL; - } - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - buf_offset = fbi->var.xoffset * bpp + - fbi->var.yoffset * fbi->fix.line_length; - - /* MDP cmd block enable */ - mdp_clk_ctrl(1); - - pipe->src_height = fbi->var.yres; - pipe->src_width = fbi->var.xres; - pipe->src_h = fbi->var.yres; - pipe->src_w = fbi->var.xres; - pipe->dst_h = fbi->var.yres; - pipe->dst_w = fbi->var.xres; - pipe->srcp0_ystride = fbi->fix.line_length; - pipe->src_y = 0; - pipe->src_x = 0; - pipe->dst_y = 0; - pipe->dst_x = 0; - - mdp4_overlay_mdp_pipe_req(pipe, mfd); - mdp4_calc_blt_mdp_bw(mfd, pipe); - - if (mfd->display_iova) - pipe->srcp0_addr = mfd->display_iova + buf_offset; - else - pipe->srcp0_addr = (uint32)(buf + buf_offset); - - mdp4_mixer_stage_up(pipe, 0); - - mdp4_overlayproc_cfg(pipe); - - if (hdmi_prim_display) - outpdw(MDP_BASE + 0x100F4, 0x01); - else - outpdw(MDP_BASE + 0x100F4, 0x02); - - /* MDP cmd block disable */ - mdp_clk_ctrl(0); - - wmb(); - return 0; -} - -/* - * mdp4_wfd_piep_queue: - * called from thread context - */ -void mdp4_wfd_pipe_queue(int cndx, struct mdp4_overlay_pipe *pipe) -{ - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pp; - int undx; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - - pp = &vp->plist[pipe->pipe_ndx - 1]; /* ndx start form 1 */ - - pr_debug("%s: vndx=%d pipe_ndx=%d pid=%d\n", __func__, - undx, pipe->pipe_ndx, current->pid); - - *pp = *pipe; /* clone it */ - vp->update_cnt++; - - mutex_unlock(&vctrl->update_lock); - mdp4_stat.overlay_play[pipe->mixer_num]++; -} - -static void mdp4_wfd_wait4ov(int cndx); - -int mdp4_wfd_pipe_commit(struct msm_fb_data_type *mfd, - int cndx, int wait) -{ - int i, undx; - int mixer = 0; - struct vsycn_ctrl *vctrl; - struct vsync_update *vp; - struct mdp4_overlay_pipe *pipe; - struct mdp4_overlay_pipe *real_pipe; - unsigned long flags; - int cnt = 0; - struct msmfb_writeback_data_list *node = NULL; - - vctrl = &vsync_ctrl_db[cndx]; - - mutex_lock(&vctrl->update_lock); - undx = vctrl->update_ndx; - vp = &vctrl->vlist[undx]; - pipe = vctrl->base_pipe; - mixer = pipe->mixer_num; - - if (vp->update_cnt == 0) { - mutex_unlock(&vctrl->update_lock); - return cnt; - } - - vctrl->update_ndx++; - vctrl->update_ndx &= 0x01; - vp->update_cnt = 0; /* reset */ - mutex_unlock(&vctrl->update_lock); - - mdp4_wfd_dequeue_update(mfd, &node); - - /* free previous committed iommu back to pool */ - mdp4_overlay_iommu_unmap_freelist(mixer); - - pipe = vp->plist; - for (i = 0; i < OVERLAY_PIPE_MAX; i++, pipe++) { - if (pipe->pipe_used) { - cnt++; - real_pipe = mdp4_overlay_ndx2pipe(pipe->pipe_ndx); - if (real_pipe && real_pipe->pipe_used) { - /* pipe not unset */ - mdp4_overlay_vsync_commit(pipe); - } - /* free previous iommu to freelist - * which will be freed at next - * pipe_commit - */ - mdp4_overlay_iommu_pipe_free(pipe->pipe_ndx, 0); - pipe->pipe_used = 0; /* clear */ - } - } - - mdp_clk_ctrl(1); - - mdp4_mixer_stage_commit(mixer); - - pipe = vctrl->base_pipe; - spin_lock_irqsave(&vctrl->spin_lock, flags); - vctrl->ov_koff++; - INIT_COMPLETION(vctrl->ov_comp); - vsync_irq_enable(INTR_OVERLAY2_DONE, MDP_OVERLAY2_TERM); - pr_debug("%s: kickoff\n", __func__); - /* kickoff overlay engine */ - mdp4_stat.kickoff_ov2++; - outpdw(MDP_BASE + 0x00D0, 0); - mb(); /* make sure kickoff executed */ - spin_unlock_irqrestore(&vctrl->spin_lock, flags); - - mdp4_stat.overlay_commit[pipe->mixer_num]++; - - if (wait) - mdp4_wfd_wait4ov(cndx); - - mdp4_wfd_queue_wakeup(mfd, node); - - return cnt; -} - -static void clk_ctrl_work(struct work_struct *work) -{ - struct vsycn_ctrl *vctrl = - container_of(work, typeof(*vctrl), clk_work); - mdp_clk_ctrl(0); -} - -void mdp4_wfd_init(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - if (vctrl->inited) - return; - - vctrl->inited = 1; - vctrl->update_ndx = 0; - mutex_init(&vctrl->update_lock); - init_completion(&vctrl->ov_comp); - spin_lock_init(&vctrl->spin_lock); - INIT_WORK(&vctrl->clk_work, clk_ctrl_work); -} - -static void mdp4_wfd_wait4ov(int cndx) -{ - struct vsycn_ctrl *vctrl; - - if (cndx >= MAX_CONTROLLER) { - pr_err("%s: out or range: cndx=%d\n", __func__, cndx); - return; - } - - vctrl = &vsync_ctrl_db[cndx]; - - if (atomic_read(&vctrl->suspend) > 0) - return; - - wait_for_completion(&vctrl->ov_comp); -} - - -void mdp4_overlay2_done_wfd(struct mdp_dma_data *dma) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - int cndx = 0; - - vctrl = &vsync_ctrl_db[cndx]; - pipe = vctrl->base_pipe; - - spin_lock(&vctrl->spin_lock); - vsync_irq_disable(INTR_OVERLAY2_DONE, MDP_OVERLAY2_TERM); - vctrl->ov_done++; - complete(&vctrl->ov_comp); - schedule_work(&vctrl->clk_work); - pr_debug("%s ovdone interrupt\n", __func__); - spin_unlock(&vctrl->spin_lock); -} - -void mdp4_writeback_overlay(struct msm_fb_data_type *mfd) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - - if (mfd && !mfd->panel_power_on) - return; - - pr_debug("%s:+ mfd=%x\n", __func__, (int)mfd); - - vctrl = &vsync_ctrl_db[0]; - pipe = vctrl->base_pipe; - - mutex_lock(&mfd->dma->ov_mutex); - - if (pipe->pipe_type == OVERLAY_TYPE_RGB) - mdp4_wfd_pipe_queue(0, pipe); - - mdp4_overlay_mdp_perf_upd(mfd, 1); - - mdp4_wfd_pipe_commit(mfd, 0, 1); - - mdp4_overlay_mdp_perf_upd(mfd, 0); - - mutex_unlock(&mfd->dma->ov_mutex); -} - -static int mdp4_overlay_writeback_register_buffer( - struct msm_fb_data_type *mfd, struct msmfb_writeback_data_list *node) -{ - if (!node) { - pr_err("Cannot register a NULL node\n"); - return -EINVAL; - } - node->state = REGISTERED; - list_add_tail(&node->registered_entry, &mfd->writeback_register_queue); - return 0; -} -static struct msmfb_writeback_data_list *get_if_registered( - struct msm_fb_data_type *mfd, struct msmfb_data *data) -{ - struct msmfb_writeback_data_list *temp; - bool found = false; - int domain; - - if (!list_empty(&mfd->writeback_register_queue)) { - list_for_each_entry(temp, - &mfd->writeback_register_queue, - registered_entry) { - if (temp && temp->buf_info.iova == data->iova) { - found = true; - break; - } - } - } - if (!found) { - temp = kzalloc(sizeof(struct msmfb_writeback_data_list), - GFP_KERNEL); - if (temp == NULL) { - pr_err("%s: out of memory\n", __func__); - goto register_alloc_fail; - } - temp->ihdl = NULL; - if (data->iova) - temp->addr = (data->iova + data->offset); - else if (mfd->iclient) { - struct ion_handle *srcp_ihdl; - ulong len; - srcp_ihdl = ion_import_dma_buf(mfd->iclient, - data->memory_id); - if (IS_ERR_OR_NULL(srcp_ihdl)) { - pr_err("%s: ion import fd failed\n", __func__); - goto register_ion_fail; - } - - if (mdp_iommu_split_domain) - domain = DISPLAY_WRITE_DOMAIN; - else - domain = DISPLAY_READ_DOMAIN; - - if (ion_map_iommu(mfd->iclient, - srcp_ihdl, - domain, - GEN_POOL, - SZ_4K, - 0, - &temp->addr, - (ulong *)&len, - 0, - ION_IOMMU_UNMAP_DELAYED)) { - ion_free(mfd->iclient, srcp_ihdl); - pr_err("%s: unable to get ion mapping addr\n", - __func__); - goto register_ion_fail; - } - temp->addr += data->offset; - temp->ihdl = srcp_ihdl; - } - else { - pr_err("%s: only support ion memory\n", __func__); - goto register_ion_fail; - } - - memcpy(&temp->buf_info, data, sizeof(struct msmfb_data)); - if (mdp4_overlay_writeback_register_buffer(mfd, temp)) { - pr_err("%s: error registering node\n", __func__); - goto register_ion_fail; - } - } - return temp; - register_ion_fail: - kfree(temp); - register_alloc_fail: - return NULL; -} -int mdp4_writeback_start( - struct fb_info *info) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - mutex_lock(&mfd->writeback_mutex); - mfd->writeback_state = WB_START; - mutex_unlock(&mfd->writeback_mutex); - wake_up(&mfd->wait_q); - return 0; -} - -int mdp4_writeback_queue_buffer(struct fb_info *info, struct msmfb_data *data) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct msmfb_writeback_data_list *node = NULL; - int rv = 0; - - mutex_lock(&mfd->writeback_mutex); - node = get_if_registered(mfd, data); - if (!node || node->state == IN_BUSY_QUEUE || - node->state == IN_FREE_QUEUE) { - pr_err("memory not registered or Buffer already with us\n"); - rv = -EINVAL; - goto exit; - } - - list_add_tail(&node->active_entry, &mfd->writeback_free_queue); - node->state = IN_FREE_QUEUE; - -exit: - mutex_unlock(&mfd->writeback_mutex); - return rv; -} -static int is_buffer_ready(struct msm_fb_data_type *mfd) -{ - int rc; - mutex_lock(&mfd->writeback_mutex); - rc = !list_empty(&mfd->writeback_busy_queue) || - (mfd->writeback_state == WB_STOPING); - mutex_unlock(&mfd->writeback_mutex); - return rc; -} -int mdp4_writeback_dequeue_buffer(struct fb_info *info, struct msmfb_data *data) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct msmfb_writeback_data_list *node = NULL; - int rc = 0, domain; - - rc = wait_event_interruptible(mfd->wait_q, is_buffer_ready(mfd)); - if (rc) { - pr_err("failed to get dequeued buffer\n"); - return -ENOBUFS; - } - mutex_lock(&mfd->writeback_mutex); - if (mfd->writeback_state == WB_STOPING) { - mfd->writeback_state = WB_STOP; - mutex_unlock(&mfd->writeback_mutex); - return -ENOBUFS; - } else if (!list_empty(&mfd->writeback_busy_queue)) { - node = list_first_entry(&mfd->writeback_busy_queue, - struct msmfb_writeback_data_list, active_entry); - } - if (node) { - list_del(&node->active_entry); - node->state = WITH_CLIENT; - memcpy(data, &node->buf_info, sizeof(struct msmfb_data)); - if (!data->iova) - if (mfd->iclient && node->ihdl) { - if (mdp_iommu_split_domain) - domain = DISPLAY_WRITE_DOMAIN; - else - domain = DISPLAY_READ_DOMAIN; - - ion_unmap_iommu(mfd->iclient, - node->ihdl, - domain, - GEN_POOL); - ion_free(mfd->iclient, - node->ihdl); - } - } else { - pr_err("node is NULL. Somebody else dequeued?\n"); - rc = -ENOBUFS; - } - mutex_unlock(&mfd->writeback_mutex); - return rc; -} - -static bool is_writeback_inactive(struct msm_fb_data_type *mfd) -{ - bool active; - mutex_lock(&mfd->writeback_mutex); - active = !mfd->writeback_active_cnt; - mutex_unlock(&mfd->writeback_mutex); - return active; -} -int mdp4_writeback_stop(struct fb_info *info) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - mutex_lock(&mfd->writeback_mutex); - mfd->writeback_state = WB_STOPING; - mutex_unlock(&mfd->writeback_mutex); - /* Wait for all pending writebacks to finish */ - wait_event_interruptible(mfd->wait_q, is_writeback_inactive(mfd)); - - /* Wake up dequeue thread in case of no UI update*/ - wake_up(&mfd->wait_q); - - return 0; -} -int mdp4_writeback_init(struct fb_info *info) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - mutex_init(&mfd->writeback_mutex); - mutex_init(&mfd->unregister_mutex); - INIT_LIST_HEAD(&mfd->writeback_free_queue); - INIT_LIST_HEAD(&mfd->writeback_busy_queue); - INIT_LIST_HEAD(&mfd->writeback_register_queue); - mfd->writeback_state = WB_OPEN; - init_waitqueue_head(&mfd->wait_q); - return 0; -} -int mdp4_writeback_terminate(struct fb_info *info) -{ - struct list_head *ptr, *next; - struct msmfb_writeback_data_list *temp; - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - int rc = 0; - - mutex_lock(&mfd->unregister_mutex); - mutex_lock(&mfd->writeback_mutex); - - if (mfd->writeback_state != WB_STOPING && - mfd->writeback_state != WB_STOP) { - pr_err("%s called without stopping\n", __func__); - rc = -EPERM; - goto terminate_err; - - } - - if (!list_empty(&mfd->writeback_register_queue)) { - list_for_each_safe(ptr, next, - &mfd->writeback_register_queue) { - temp = list_entry(ptr, - struct msmfb_writeback_data_list, - registered_entry); - list_del(&temp->registered_entry); - kfree(temp); - } - } - INIT_LIST_HEAD(&mfd->writeback_register_queue); - INIT_LIST_HEAD(&mfd->writeback_busy_queue); - INIT_LIST_HEAD(&mfd->writeback_free_queue); - - -terminate_err: - mutex_unlock(&mfd->writeback_mutex); - mutex_unlock(&mfd->unregister_mutex); - return rc; -} - -static void mdp4_wfd_dequeue_update(struct msm_fb_data_type *mfd, - struct msmfb_writeback_data_list **wfdnode) -{ - struct vsycn_ctrl *vctrl; - struct mdp4_overlay_pipe *pipe; - struct msmfb_writeback_data_list *node = NULL; - - if (mfd && !mfd->panel_power_on) - return; - - pr_debug("%s:+ mfd=%x\n", __func__, (int)mfd); - - vctrl = &vsync_ctrl_db[0]; - pipe = vctrl->base_pipe; - - mutex_lock(&mfd->unregister_mutex); - mutex_lock(&mfd->writeback_mutex); - if (!list_empty(&mfd->writeback_free_queue) - && mfd->writeback_state != WB_STOPING - && mfd->writeback_state != WB_STOP) { - node = list_first_entry(&mfd->writeback_free_queue, - struct msmfb_writeback_data_list, active_entry); - } - if (node) { - list_del(&(node->active_entry)); - node->state = IN_BUSY_QUEUE; - mfd->writeback_active_cnt++; - } - mutex_unlock(&mfd->writeback_mutex); - - pipe->ov_blt_addr = (node ? node->addr : 0); - - if (!pipe->ov_blt_addr) { - pr_err("%s: no writeback buffer 0x%x, %p\n", __func__, - (unsigned int)pipe->ov_blt_addr, node); - mutex_unlock(&mfd->unregister_mutex); - return; - } - - mdp4_overlay_writeback_update(mfd); - - *wfdnode = node; - - mutex_unlock(&mfd->unregister_mutex); -} - -static void mdp4_wfd_queue_wakeup(struct msm_fb_data_type *mfd, - struct msmfb_writeback_data_list *node) -{ - - if (mfd && !mfd->panel_power_on) - return; - - if (node == NULL) - return; - - pr_debug("%s: mfd=%x node: %p", __func__, (int)mfd, node); - - mutex_lock(&mfd->writeback_mutex); - list_add_tail(&node->active_entry, &mfd->writeback_busy_queue); - mfd->writeback_active_cnt--; - mutex_unlock(&mfd->writeback_mutex); - wake_up(&mfd->wait_q); -} - -int mdp4_writeback_set_mirroring_hint(struct fb_info *info, int hint) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - - if (mfd->panel.type != WRITEBACK_PANEL) - return -ENOTSUPP; - - switch (hint) { - case MDP_WRITEBACK_MIRROR_ON: - case MDP_WRITEBACK_MIRROR_PAUSE: - case MDP_WRITEBACK_MIRROR_RESUME: - case MDP_WRITEBACK_MIRROR_OFF: - pr_info("wfd state switched to %d\n", hint); - switch_set_state(&mfd->writeback_sdev, hint); - return 0; - default: - return -EINVAL; - } -} diff --git a/drivers/video/msm/mdp4_util.c b/drivers/video/msm/mdp4_util.c deleted file mode 100644 index 3b333aa626226f38dc9698787efc4defe2ede983..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_util.c +++ /dev/null @@ -1,3194 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" - -struct mdp4_statistic mdp4_stat; - -struct mdp_csc_cfg_data csc_cfg_matrix[CSC_MAX_BLOCKS] = { - { - .block = MDP_BLOCK_VG_1, - .csc_data = { - (MDP_CSC_FLAG_YUV_OUT), - { - 0x0254, 0x0000, 0x0331, - 0x0254, 0xff37, 0xfe60, - 0x0254, 0x0409, 0x0000, - }, - { - 0xfff0, 0xff80, 0xff80, - }, - { - 0, 0, 0, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - }, - }, - { - .block = MDP_BLOCK_VG_2, - .csc_data = { - (MDP_CSC_FLAG_YUV_OUT), - { - 0x0254, 0x0000, 0x0331, - 0x0254, 0xff37, 0xfe60, - 0x0254, 0x0409, 0x0000, - }, - { - 0xfff0, 0xff80, 0xff80, - }, - { - 0, 0, 0, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - }, - }, - { - .block = MDP_BLOCK_DMA_P, - .csc_data = { - (0), - { - 0x0200, 0x0000, 0x0000, - 0x0000, 0x0200, 0x0000, - 0x0000, 0x0000, 0x0200, - }, - { - 0x0, 0x0, 0x0, - }, - { - 0, 0, 0, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - }, - }, - { - .block = MDP_BLOCK_OVERLAY_1, - .csc_data = { - (0), - { - 0x0083, 0x0102, 0x0032, - 0x1fb5, 0x1f6c, 0x00e1, - 0x00e1, 0x1f45, 0x1fdc, - }, - { - 0x0, 0x0, 0x0, - }, - { - 0x0010, 0x0080, 0x0080, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - { - 0x0010, 0x00eb, 0x0010, - 0x00f0, 0x0010, 0x00f0, - }, - }, - }, - { - .block = MDP_BLOCK_OVERLAY_2, - .csc_data = { - (0), - { - 0x0083, 0x0102, 0x0032, - 0x1fb5, 0x1f6c, 0x00e1, - 0x00e1, 0x1f45, 0x1fdc, - }, - { - 0x0, 0x0, 0x0, - }, - { - 0x0010, 0x0080, 0x0080, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - { - 0x0010, 0x00eb, 0x0010, - 0x00f0, 0x0010, 0x00f0, - }, - }, - }, - { - .block = MDP_BLOCK_DMA_S, - .csc_data = { - (0), - { - 0x0200, 0x0000, 0x0000, - 0x0000, 0x0200, 0x0000, - 0x0000, 0x0000, 0x0200, - }, - { - 0x0, 0x0, 0x0, - }, - { - 0, 0, 0, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - { - 0, 0xff, 0, 0xff, 0, 0xff, - }, - }, - }, -}; - -unsigned is_mdp4_hw_reset(void) -{ - unsigned hw_reset = 0; - - /* Only revisions > v2.1 may be reset or powered off/on at runtime */ - if (mdp_hw_revision > MDP4_REVISION_V2_1) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - hw_reset = !inpdw(MDP_BASE + 0x003c); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - } - - return hw_reset; -} - -void mdp4_sw_reset(ulong bits) -{ - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - bits &= 0x1f; /* 5 bits */ - outpdw(MDP_BASE + 0x001c, bits); /* MDP_SW_RESET */ - - while (inpdw(MDP_BASE + 0x001c) & bits) /* self clear when complete */ - ; - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - MSM_FB_DEBUG("mdp4_sw_reset: 0x%x\n", (int)bits); -} - -void mdp4_overlay_cfg(int overlayer, int blt_mode, int refresh, int direct_out) -{ - ulong bits = 0; - - if (blt_mode) - bits |= (1 << 3); - refresh &= 0x03; /* 2 bites */ - bits |= (refresh << 1); - direct_out &= 0x01; - bits |= direct_out; - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - - if (overlayer == MDP4_MIXER0) - outpdw(MDP_BASE + 0x10004, bits); /* MDP_OVERLAY0_CFG */ - else if (overlayer == MDP4_MIXER1) - outpdw(MDP_BASE + 0x18004, bits); /* MDP_OVERLAY1_CFG */ - - MSM_FB_DEBUG("mdp4_overlay_cfg: 0x%x\n", - (int)inpdw(MDP_BASE + 0x10004)); - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -void mdp4_display_intf_sel(int output, ulong intf) -{ - ulong bits, mask, data; - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - bits = inpdw(MDP_BASE + 0x0038); /* MDP_DISP_INTF_SEL */ - - if (intf == DSI_VIDEO_INTF) { - data = 0x40; /* bit 6 */ - intf = MDDI_LCDC_INTF; - if (output == SECONDARY_INTF_SEL) { - MSM_FB_INFO("%s: Illegal INTF selected, output=%d \ - intf=%d\n", __func__, output, (int)intf); - } - } else if (intf == DSI_CMD_INTF) { - data = 0x80; /* bit 7 */ - intf = MDDI_INTF; - if (output == EXTERNAL_INTF_SEL) { - MSM_FB_INFO("%s: Illegal INTF selected, output=%d \ - intf=%d\n", __func__, output, (int)intf); - } - } else - data = 0; - - mask = 0x03; /* 2 bits */ - intf &= 0x03; /* 2 bits */ - - switch (output) { - case EXTERNAL_INTF_SEL: - intf <<= 4; - mask <<= 4; - break; - case SECONDARY_INTF_SEL: - intf &= 0x02; /* only MDDI and EBI2 support */ - intf <<= 2; - mask <<= 2; - break; - default: - break; - } - - intf |= data; - mask |= data; - - bits &= ~mask; - bits |= intf; - - outpdw(MDP_BASE + 0x0038, bits); /* MDP_DISP_INTF_SEL */ - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - MSM_FB_DEBUG("mdp4_display_intf_sel: 0x%x\n", (int)inpdw(MDP_BASE + 0x0038)); -} - -unsigned long mdp4_display_status(void) -{ - ulong status; - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - status = inpdw(MDP_BASE + 0x0018) & 0x3ff; /* MDP_DISPLAY_STATUS */ - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - return status; -} - -void mdp4_ebi2_lcd_setup(int lcd, ulong base, int ystride) -{ - /* always use memory map */ - ystride &= 0x01fff; /* 13 bits */ - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - if (lcd == EBI2_LCD0) { - outpdw(MDP_BASE + 0x0060, base);/* MDP_EBI2_LCD0 */ - outpdw(MDP_BASE + 0x0068, ystride);/* MDP_EBI2_LCD0_YSTRIDE */ - } else { - outpdw(MDP_BASE + 0x0064, base);/* MDP_EBI2_LCD1 */ - outpdw(MDP_BASE + 0x006c, ystride);/* MDP_EBI2_LCD1_YSTRIDE */ - } - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -void mdp4_mddi_setup(int mddi, unsigned long id) -{ - ulong bits; - - if (mddi == MDDI_EXTERNAL_SET) - bits = 0x02; - else if (mddi == MDDI_SECONDARY_SET) - bits = 0x01; - else - bits = 0; /* PRIMARY_SET */ - - id <<= 16; - - bits |= id; - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - outpdw(MDP_BASE + 0x0090, bits); /* MDP_MDDI_PARAM_WR_SEL */ - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -int mdp_ppp_blit(struct fb_info *info, struct mdp_blit_req *req) -{ - - /* not implemented yet */ - return -1; -} - -void mdp4_fetch_cfg(uint32 core_clk) -{ - uint32 dmap_data, vg_data; - char *base; - int i; - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - if (mdp_rev >= MDP_REV_41 || core_clk >= 90000000) { /* 90 Mhz */ - dmap_data = 0x47; /* 16 bytes-burst x 8 req */ - vg_data = 0x47; /* 16 bytes-burs x 8 req */ - } else { - dmap_data = 0x27; /* 8 bytes-burst x 8 req */ - vg_data = 0x43; /* 16 bytes-burst x 4 req */ - } - - MSM_FB_DEBUG("mdp4_fetch_cfg: dmap=%x vg=%x\n", - dmap_data, vg_data); - - /* dma_p fetch config */ - outpdw(MDP_BASE + 0x91004, dmap_data); - /* dma_e fetch config */ - outpdw(MDP_BASE + 0xB1004, dmap_data); - - /* - * set up two vg pipes and two rgb pipes - */ - base = MDP_BASE + MDP4_VIDEO_BASE; - for (i = 0; i < 4; i++) { - outpdw(base + 0x1004, vg_data); - base += MDP4_VIDEO_OFF; - } - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -void mdp4_hw_init(void) -{ - ulong bits; - uint32 clk_rate; - int i; - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - mdp_bus_scale_update_request - (MDP_BUS_SCALE_INIT, MDP_BUS_SCALE_INIT); - -#ifdef MDP4_ERROR - /* - * Issue software reset on DMA_P will casue DMA_P dma engine stall - * on LCDC mode. However DMA_P does not stall at MDDI mode. - * This need further investigation. - */ - mdp4_sw_reset(0x17); -#endif - - if (mdp_rev > MDP_REV_41) { - /* mdp chip select controller */ - outpdw(MDP_BASE + 0x00c0, CS_CONTROLLER_0); - outpdw(MDP_BASE + 0x00c4, CS_CONTROLLER_1); - } - - mdp4_clear_lcdc(); - - mdp4_mixer_blend_init(0); - mdp4_mixer_blend_init(1); - mdp4_vg_qseed_init(0); - mdp4_vg_qseed_init(1); - - for (i = 0; i < CSC_MAX_BLOCKS; i++) - mdp4_csc_config(&csc_cfg_matrix[i]); - - if (mdp_rev <= MDP_REV_41) { - mdp4_mixer_gc_lut_setup(0); - mdp4_mixer_gc_lut_setup(1); - } - - mdp4_vg_igc_lut_setup(0); - mdp4_vg_igc_lut_setup(1); - - mdp4_rgb_igc_lut_setup(0); - mdp4_rgb_igc_lut_setup(1); - - outp32(MDP_EBI2_PORTMAP_MODE, 0x3); - - /* system interrupts */ - - bits = mdp_intr_mask; - outpdw(MDP_BASE + 0x0050, bits);/* enable specififed interrupts */ - - /* For the max read pending cmd config below, if the MDP clock */ - /* is less than the AXI clock, then we must use 3 pending */ - /* pending requests. Otherwise, we should use 8 pending requests. */ - /* In the future we should do this detection automatically. */ - - /* max read pending cmd config */ - outpdw(MDP_BASE + 0x004c, 0x02222); /* 3 pending requests */ - -#ifndef CONFIG_FB_MSM_OVERLAY - /* both REFRESH_MODE and DIRECT_OUT are ignored at BLT mode */ - mdp4_overlay_cfg(MDP4_MIXER0, OVERLAY_MODE_BLT, 0, 0); - mdp4_overlay_cfg(MDP4_MIXER1, OVERLAY_MODE_BLT, 0, 0); -#endif - - clk_rate = mdp_get_core_clk(); - mdp4_fetch_cfg(clk_rate); - - /* Mark hardware as initialized. Only revisions > v2.1 have a register - * for tracking core reset status. */ - if (mdp_hw_revision > MDP4_REVISION_V2_1) - outpdw(MDP_BASE + 0x003c, 1); - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - - -void mdp4_clear_lcdc(void) -{ - uint32 bits; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - bits = inpdw(MDP_BASE + 0xc0000); - if (bits & 0x01) { /* enabled already */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - return; - } - - outpdw(MDP_BASE + 0xc0004, 0); /* vsync ctrl out */ - outpdw(MDP_BASE + 0xc0008, 0); /* vsync period */ - outpdw(MDP_BASE + 0xc000c, 0); /* vsync pusle width */ - outpdw(MDP_BASE + 0xc0010, 0); /* lcdc display HCTL */ - outpdw(MDP_BASE + 0xc0014, 0); /* lcdc display v start */ - outpdw(MDP_BASE + 0xc0018, 0); /* lcdc display v end */ - outpdw(MDP_BASE + 0xc001c, 0); /* lcdc active hctl */ - outpdw(MDP_BASE + 0xc0020, 0); /* lcdc active v start */ - outpdw(MDP_BASE + 0xc0024, 0); /* lcdc active v end */ - outpdw(MDP_BASE + 0xc0028, 0); /* lcdc board color */ - outpdw(MDP_BASE + 0xc002c, 0); /* lcdc underflow ctrl */ - outpdw(MDP_BASE + 0xc0030, 0); /* lcdc hsync skew */ - outpdw(MDP_BASE + 0xc0034, 0); /* lcdc test ctl */ - outpdw(MDP_BASE + 0xc0038, 0); /* lcdc ctl polarity */ - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -irqreturn_t mdp4_isr(int irq, void *ptr) -{ - uint32 isr, mask, panel; - struct mdp_dma_data *dma; - struct mdp_hist_mgmt *mgmt = NULL; - int i, ret; - - mdp_is_in_isr = TRUE; - - /* complete all the reads before reading the interrupt - * status register - eliminate effects of speculative - * reads by the cpu - */ - rmb(); - isr = inpdw(MDP_INTR_STATUS); - if (isr == 0) - goto out; - - mdp4_stat.intr_tot++; - mask = inpdw(MDP_INTR_ENABLE); - outpdw(MDP_INTR_CLEAR, isr); - - if (isr & INTR_PRIMARY_INTF_UDERRUN) { - pr_debug("%s: UNDERRUN -- primary\n", __func__); - mdp4_stat.intr_underrun_p++; - /* When underun occurs mdp clear the histogram registers - that are set before in hw_init so restore them back so - that histogram works.*/ - for (i = 0; i < MDP_HIST_MGMT_MAX; i++) { - mgmt = mdp_hist_mgmt_array[i]; - if (!mgmt) - continue; - mgmt->mdp_is_hist_valid = FALSE; - } - } - - if (isr & INTR_EXTERNAL_INTF_UDERRUN) { - pr_debug("%s: UNDERRUN -- external\n", __func__); - mdp4_stat.intr_underrun_e++; - } - - isr &= mask; - - if (isr == 0) - goto out; - - panel = mdp4_overlay_panel_list(); - - if (isr & INTR_DMA_P_DONE) { - mdp4_stat.intr_dma_p++; - dma = &dma2_data; - if (panel & MDP4_PANEL_LCDC) - mdp4_dmap_done_lcdc(0); -#ifdef CONFIG_FB_MSM_OVERLAY -#ifdef CONFIG_FB_MSM_MIPI_DSI - else if (panel & MDP4_PANEL_DSI_VIDEO) - mdp4_dmap_done_dsi_video(0); - else if (panel & MDP4_PANEL_DSI_CMD) - mdp4_dmap_done_dsi_cmd(0); -#else - else { /* MDDI */ - mdp4_dmap_done_mddi(0); - mdp_pipe_ctrl(MDP_DMA2_BLOCK, - MDP_BLOCK_POWER_OFF, TRUE); - complete(&dma->comp); - } -#endif -#else - else { - spin_lock(&mdp_spin_lock); - dma->busy = FALSE; - spin_unlock(&mdp_spin_lock); - complete(&dma->comp); - } -#endif - } - if (isr & INTR_DMA_S_DONE) { - mdp4_stat.intr_dma_s++; -#if defined(CONFIG_FB_MSM_OVERLAY) && defined(CONFIG_FB_MSM_MDDI) - dma = &dma2_data; -#else - dma = &dma_s_data; -#endif - - dma->busy = FALSE; - mdp_pipe_ctrl(MDP_DMA_S_BLOCK, - MDP_BLOCK_POWER_OFF, TRUE); - complete(&dma->comp); - } - if (isr & INTR_DMA_E_DONE) { - mdp4_stat.intr_dma_e++; - if (panel & MDP4_PANEL_DTV) - mdp4_dmae_done_dtv(); - } -#ifdef CONFIG_FB_MSM_OVERLAY - if (isr & INTR_OVERLAY0_DONE) { - mdp4_stat.intr_overlay0++; - dma = &dma2_data; - if (panel & (MDP4_PANEL_LCDC | MDP4_PANEL_DSI_VIDEO)) { - /* disable LCDC interrupt */ - if (panel & MDP4_PANEL_LCDC) - mdp4_overlay0_done_lcdc(0); -#ifdef CONFIG_FB_MSM_MIPI_DSI - else if (panel & MDP4_PANEL_DSI_VIDEO) - mdp4_overlay0_done_dsi_video(0); -#endif - } else { /* MDDI, DSI_CMD */ -#ifdef CONFIG_FB_MSM_MIPI_DSI - if (panel & MDP4_PANEL_DSI_CMD) - mdp4_overlay0_done_dsi_cmd(0); -#else - if (panel & MDP4_PANEL_MDDI) - mdp4_overlay0_done_mddi(0); -#endif - } - mdp_hw_cursor_done(); - } - if (isr & INTR_OVERLAY1_DONE) { - mdp4_stat.intr_overlay1++; - /* disable DTV interrupt */ - dma = &dma_e_data; - spin_lock(&mdp_spin_lock); - mdp_intr_mask &= ~INTR_OVERLAY1_DONE; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - dma->waiting = FALSE; - spin_unlock(&mdp_spin_lock); -#if defined(CONFIG_FB_MSM_DTV) - if (panel & MDP4_PANEL_DTV) - mdp4_overlay1_done_dtv(); -#endif -#if defined(CONFIG_FB_MSM_TVOUT) - if (panel & MDP4_PANEL_ATV) - mdp4_overlay1_done_atv(); -#endif - mdp_hw_cursor_done(); - } -#if defined(CONFIG_FB_MSM_WRITEBACK_MSM_PANEL) - if (isr & INTR_OVERLAY2_DONE) { - mdp4_stat.intr_overlay2++; - mdp_pipe_ctrl(MDP_OVERLAY2_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - /* disable DTV interrupt */ - if (panel & MDP4_PANEL_WRITEBACK) - mdp4_overlay2_done_wfd(&dma_wb_data); - } -#endif -#endif /* OVERLAY */ - - if (isr & INTR_PRIMARY_VSYNC) { - mdp4_stat.intr_vsync_p++; - if (panel & MDP4_PANEL_LCDC) - mdp4_primary_vsync_lcdc(); - else if (panel & MDP4_PANEL_DSI_VIDEO) - mdp4_primary_vsync_dsi_video(); - } -#ifdef CONFIG_FB_MSM_DTV - if (isr & INTR_EXTERNAL_VSYNC) { - mdp4_stat.intr_vsync_e++; - if (panel & MDP4_PANEL_DTV) - mdp4_external_vsync_dtv(); - } -#endif - if (isr & INTR_DMA_P_HISTOGRAM) { - mdp4_stat.intr_histogram++; - ret = mdp_histogram_block2mgmt(MDP_BLOCK_DMA_P, &mgmt); - if (!ret) - mdp_histogram_handle_isr(mgmt); - } - if (isr & INTR_DMA_S_HISTOGRAM) { - mdp4_stat.intr_histogram++; - ret = mdp_histogram_block2mgmt(MDP_BLOCK_DMA_S, &mgmt); - if (!ret) - mdp_histogram_handle_isr(mgmt); - } - if (isr & INTR_VG1_HISTOGRAM) { - mdp4_stat.intr_histogram++; - ret = mdp_histogram_block2mgmt(MDP_BLOCK_VG_1, &mgmt); - if (!ret) - mdp_histogram_handle_isr(mgmt); - } - if (isr & INTR_VG2_HISTOGRAM) { - mdp4_stat.intr_histogram++; - ret = mdp_histogram_block2mgmt(MDP_BLOCK_VG_2, &mgmt); - if (!ret) - mdp_histogram_handle_isr(mgmt); - } - if (isr & INTR_PRIMARY_RDPTR) { - mdp4_stat.intr_rdptr++; - mdp4_primary_rdptr(); - } - -out: - mdp_is_in_isr = FALSE; - - return IRQ_HANDLED; -} - - -/* - * QSEED tables - */ - -static uint32 vg_qseed_table0[] = { - 0x5556aaff, 0x00000000, 0x00000000, 0x00000000 -}; - -static uint32 vg_qseed_table1[] = { - 0x00000000, 0x20000000, -}; - -static uint32 vg_qseed_table2[] = { - 0x02000000, 0x00000000, 0x01ff0ff9, 0x00000008, - 0x01fb0ff2, 0x00000013, 0x01f50fed, 0x0ffe0020, - 0x01ed0fe8, 0x0ffd002e, 0x01e30fe4, 0x0ffb003e, - 0x01d80fe1, 0x0ff9004e, 0x01cb0fde, 0x0ff70060, - 0x01bc0fdc, 0x0ff40074, 0x01ac0fdb, 0x0ff20087, - 0x019a0fdb, 0x0fef009c, 0x01870fdb, 0x0fed00b1, - 0x01740fdb, 0x0fea00c7, 0x01600fdc, 0x0fe700dd, - 0x014b0fdd, 0x0fe500f3, 0x01350fdf, 0x0fe30109, - 0x01200fe0, 0x0fe00120, 0x01090fe3, 0x0fdf0135, - 0x00f30fe5, 0x0fdd014b, 0x00dd0fe7, 0x0fdc0160, - 0x00c70fea, 0x0fdb0174, 0x00b10fed, 0x0fdb0187, - 0x009c0fef, 0x0fdb019a, 0x00870ff2, 0x0fdb01ac, - 0x00740ff4, 0x0fdc01bc, 0x00600ff7, 0x0fde01cb, - 0x004e0ff9, 0x0fe101d8, 0x003e0ffb, 0x0fe401e3, - 0x002e0ffd, 0x0fe801ed, 0x00200ffe, 0x0fed01f5, - 0x00130000, 0x0ff201fb, 0x00080000, 0x0ff901ff, - - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - - 0x02000000, 0x00000000, 0x01fc0ff9, 0x0ffe000d, - 0x01f60ff3, 0x0ffb001c, 0x01ef0fed, 0x0ff9002b, - 0x01e60fe8, 0x0ff6003c, 0x01dc0fe4, 0x0ff3004d, - 0x01d00fe0, 0x0ff1005f, 0x01c30fde, 0x0fee0071, - 0x01b50fdb, 0x0feb0085, 0x01a70fd9, 0x0fe80098, - 0x01960fd8, 0x0fe600ac, 0x01850fd7, 0x0fe300c1, - 0x01730fd7, 0x0fe100d5, 0x01610fd7, 0x0fdf00e9, - 0x014e0fd8, 0x0fdd00fd, 0x013b0fd8, 0x0fdb0112, - 0x01250fda, 0x0fda0127, 0x01120fdb, 0x0fd8013b, - 0x00fd0fdd, 0x0fd8014e, 0x00e90fdf, 0x0fd70161, - 0x00d50fe1, 0x0fd70173, 0x00c10fe3, 0x0fd70185, - 0x00ac0fe6, 0x0fd80196, 0x00980fe8, 0x0fd901a7, - 0x00850feb, 0x0fdb01b5, 0x00710fee, 0x0fde01c3, - 0x005f0ff1, 0x0fe001d0, 0x004d0ff3, 0x0fe401dc, - 0x003c0ff6, 0x0fe801e6, 0x002b0ff9, 0x0fed01ef, - 0x001c0ffb, 0x0ff301f6, 0x000d0ffe, 0x0ff901fc, - - 0x020f0034, 0x0f7a0043, 0x01e80023, 0x0fa8004d, - 0x01d30016, 0x0fbe0059, 0x01c6000a, 0x0fc90067, - 0x01bd0000, 0x0fce0075, 0x01b50ff7, 0x0fcf0085, - 0x01ae0fee, 0x0fcf0095, 0x01a70fe6, 0x0fcd00a6, - 0x019d0fe0, 0x0fcb00b8, 0x01940fd9, 0x0fc900ca, - 0x01890fd4, 0x0fc700dc, 0x017d0fcf, 0x0fc600ee, - 0x01700fcc, 0x0fc40100, 0x01620fc9, 0x0fc40111, - 0x01540fc6, 0x0fc30123, 0x01430fc5, 0x0fc40134, - 0x01340fc4, 0x0fc50143, 0x01230fc3, 0x0fc60154, - 0x01110fc4, 0x0fc90162, 0x01000fc4, 0x0fcc0170, - 0x00ee0fc6, 0x0fcf017d, 0x00dc0fc7, 0x0fd40189, - 0x00ca0fc9, 0x0fd90194, 0x00b80fcb, 0x0fe0019d, - 0x00a60fcd, 0x0fe601a7, 0x00950fcf, 0x0fee01ae, - 0x00850fcf, 0x0ff701b5, 0x00750fce, 0x000001bd, - 0x00670fc9, 0x000a01c6, 0x00590fbe, 0x001601d3, - 0x004d0fa8, 0x002301e8, 0x00430f7a, 0x0034020f, - - 0x015c005e, 0x0fde0068, 0x015c0054, 0x0fdd0073, - 0x015b004b, 0x0fdc007e, 0x015a0042, 0x0fdb0089, - 0x01590039, 0x0fda0094, 0x01560030, 0x0fda00a0, - 0x01530028, 0x0fda00ab, 0x014f0020, 0x0fda00b7, - 0x014a0019, 0x0fdb00c2, 0x01450011, 0x0fdc00ce, - 0x013e000b, 0x0fde00d9, 0x01390004, 0x0fdf00e4, - 0x01310ffe, 0x0fe200ef, 0x01290ff9, 0x0fe400fa, - 0x01200ff4, 0x0fe80104, 0x01180fef, 0x0feb010e, - 0x010e0feb, 0x0fef0118, 0x01040fe8, 0x0ff40120, - 0x00fa0fe4, 0x0ff90129, 0x00ef0fe2, 0x0ffe0131, - 0x00e40fdf, 0x00040139, 0x00d90fde, 0x000b013e, - 0x00ce0fdc, 0x00110145, 0x00c20fdb, 0x0019014a, - 0x00b70fda, 0x0020014f, 0x00ab0fda, 0x00280153, - 0x00a00fda, 0x00300156, 0x00940fda, 0x00390159, - 0x00890fdb, 0x0042015a, 0x007e0fdc, 0x004b015b, - 0x00730fdd, 0x0054015c, 0x00680fde, 0x005e015c, - - 0x01300068, 0x0ff80070, 0x01300060, 0x0ff80078, - 0x012f0059, 0x0ff80080, 0x012d0052, 0x0ff80089, - 0x012b004b, 0x0ff90091, 0x01290044, 0x0ff9009a, - 0x0126003d, 0x0ffa00a3, 0x01220037, 0x0ffb00ac, - 0x011f0031, 0x0ffc00b4, 0x011a002b, 0x0ffe00bd, - 0x01150026, 0x000000c5, 0x010f0021, 0x000200ce, - 0x010a001c, 0x000400d6, 0x01030018, 0x000600df, - 0x00fd0014, 0x000900e6, 0x00f60010, 0x000c00ee, - 0x00ee000c, 0x001000f6, 0x00e60009, 0x001400fd, - 0x00df0006, 0x00180103, 0x00d60004, 0x001c010a, - 0x00ce0002, 0x0021010f, 0x00c50000, 0x00260115, - 0x00bd0ffe, 0x002b011a, 0x00b40ffc, 0x0031011f, - 0x00ac0ffb, 0x00370122, 0x00a30ffa, 0x003d0126, - 0x009a0ff9, 0x00440129, 0x00910ff9, 0x004b012b, - 0x00890ff8, 0x0052012d, 0x00800ff8, 0x0059012f, - 0x00780ff8, 0x00600130, 0x00700ff8, 0x00680130, - - 0x01050079, 0x0003007f, 0x01040073, 0x00030086, - 0x0103006d, 0x0004008c, 0x01030066, 0x00050092, - 0x01010060, 0x00060099, 0x0100005a, 0x0007009f, - 0x00fe0054, 0x000900a5, 0x00fa004f, 0x000b00ac, - 0x00f80049, 0x000d00b2, 0x00f50044, 0x000f00b8, - 0x00f2003f, 0x001200bd, 0x00ef0039, 0x001500c3, - 0x00ea0035, 0x001800c9, 0x00e60030, 0x001c00ce, - 0x00e3002b, 0x001f00d3, 0x00dd0027, 0x002300d9, - 0x00d90023, 0x002700dd, 0x00d3001f, 0x002b00e3, - 0x00ce001c, 0x003000e6, 0x00c90018, 0x003500ea, - 0x00c30015, 0x003900ef, 0x00bd0012, 0x003f00f2, - 0x00b8000f, 0x004400f5, 0x00b2000d, 0x004900f8, - 0x00ac000b, 0x004f00fa, 0x00a50009, 0x005400fe, - 0x009f0007, 0x005a0100, 0x00990006, 0x00600101, - 0x00920005, 0x00660103, 0x008c0004, 0x006d0103, - 0x00860003, 0x00730104, 0x007f0003, 0x00790105, - - 0x00cf0088, 0x001d008c, 0x00ce0084, 0x0020008e, - 0x00cd0080, 0x00210092, 0x00cd007b, 0x00240094, - 0x00ca0077, 0x00270098, 0x00c90073, 0x0029009b, - 0x00c8006f, 0x002c009d, 0x00c6006b, 0x002f00a0, - 0x00c50067, 0x003200a2, 0x00c30062, 0x003600a5, - 0x00c0005f, 0x003900a8, 0x00c0005b, 0x003b00aa, - 0x00be0057, 0x003e00ad, 0x00ba0054, 0x004200b0, - 0x00b90050, 0x004500b2, 0x00b7004c, 0x004900b4, - 0x00b40049, 0x004c00b7, 0x00b20045, 0x005000b9, - 0x00b00042, 0x005400ba, 0x00ad003e, 0x005700be, - 0x00aa003b, 0x005b00c0, 0x00a80039, 0x005f00c0, - 0x00a50036, 0x006200c3, 0x00a20032, 0x006700c5, - 0x00a0002f, 0x006b00c6, 0x009d002c, 0x006f00c8, - 0x009b0029, 0x007300c9, 0x00980027, 0x007700ca, - 0x00940024, 0x007b00cd, 0x00920021, 0x008000cd, - 0x008e0020, 0x008400ce, 0x008c001d, 0x008800cf, - - 0x008e0083, 0x006b0084, 0x008d0083, 0x006c0084, - 0x008d0082, 0x006d0084, 0x008d0081, 0x006d0085, - 0x008d0080, 0x006e0085, 0x008c007f, 0x006f0086, - 0x008b007f, 0x00700086, 0x008b007e, 0x00710086, - 0x008b007d, 0x00720086, 0x008a007d, 0x00730086, - 0x008a007c, 0x00730087, 0x008a007b, 0x00740087, - 0x0089007b, 0x00750087, 0x008a0079, 0x00750088, - 0x008a0078, 0x00760088, 0x008a0077, 0x00770088, - 0x00880077, 0x0077008a, 0x00880076, 0x0078008a, - 0x00880075, 0x0079008a, 0x00870075, 0x007b0089, - 0x00870074, 0x007b008a, 0x00870073, 0x007c008a, - 0x00860073, 0x007d008a, 0x00860072, 0x007d008b, - 0x00860071, 0x007e008b, 0x00860070, 0x007f008b, - 0x0086006f, 0x007f008c, 0x0085006e, 0x0080008d, - 0x0085006d, 0x0081008d, 0x0084006d, 0x0082008d, - 0x0084006c, 0x0083008d, 0x0084006b, 0x0083008e, - - 0x023c0fe2, 0x00000fe2, 0x023a0fdb, 0x00000feb, - 0x02360fd3, 0x0fff0ff8, 0x022e0fcf, 0x0ffc0007, - 0x02250fca, 0x0ffa0017, 0x021a0fc6, 0x0ff70029, - 0x020c0fc4, 0x0ff4003c, 0x01fd0fc1, 0x0ff10051, - 0x01eb0fc0, 0x0fed0068, 0x01d80fc0, 0x0fe9007f, - 0x01c30fc1, 0x0fe50097, 0x01ac0fc2, 0x0fe200b0, - 0x01960fc3, 0x0fdd00ca, 0x017e0fc5, 0x0fd900e4, - 0x01650fc8, 0x0fd500fe, 0x014b0fcb, 0x0fd20118, - 0x01330fcd, 0x0fcd0133, 0x01180fd2, 0x0fcb014b, - 0x00fe0fd5, 0x0fc80165, 0x00e40fd9, 0x0fc5017e, - 0x00ca0fdd, 0x0fc30196, 0x00b00fe2, 0x0fc201ac, - 0x00970fe5, 0x0fc101c3, 0x007f0fe9, 0x0fc001d8, - 0x00680fed, 0x0fc001eb, 0x00510ff1, 0x0fc101fd, - 0x003c0ff4, 0x0fc4020c, 0x00290ff7, 0x0fc6021a, - 0x00170ffa, 0x0fca0225, 0x00070ffc, 0x0fcf022e, - 0x0ff80fff, 0x0fd30236, 0x0feb0000, 0x0fdb023a, - - 0x02780fc4, 0x00000fc4, 0x02770fbc, 0x0fff0fce, - 0x02710fb5, 0x0ffe0fdc, 0x02690fb0, 0x0ffa0fed, - 0x025f0fab, 0x0ff70fff, 0x02500fa8, 0x0ff30015, - 0x02410fa6, 0x0fef002a, 0x022f0fa4, 0x0feb0042, - 0x021a0fa4, 0x0fe5005d, 0x02040fa5, 0x0fe10076, - 0x01eb0fa7, 0x0fdb0093, 0x01d20fa9, 0x0fd600af, - 0x01b80fab, 0x0fd000cd, 0x019d0faf, 0x0fca00ea, - 0x01810fb2, 0x0fc50108, 0x01620fb7, 0x0fc10126, - 0x01440fbb, 0x0fbb0146, 0x01260fc1, 0x0fb70162, - 0x01080fc5, 0x0fb20181, 0x00ea0fca, 0x0faf019d, - 0x00cd0fd0, 0x0fab01b8, 0x00af0fd6, 0x0fa901d2, - 0x00930fdb, 0x0fa701eb, 0x00760fe1, 0x0fa50204, - 0x005d0fe5, 0x0fa4021a, 0x00420feb, 0x0fa4022f, - 0x002a0fef, 0x0fa60241, 0x00150ff3, 0x0fa80250, - 0x0fff0ff7, 0x0fab025f, 0x0fed0ffa, 0x0fb00269, - 0x0fdc0ffe, 0x0fb50271, 0x0fce0fff, 0x0fbc0277, - - 0x02a00fb0, 0x00000fb0, 0x029e0fa8, 0x0fff0fbb, - 0x02980fa1, 0x0ffd0fca, 0x028f0f9c, 0x0ff90fdc, - 0x02840f97, 0x0ff50ff0, 0x02740f94, 0x0ff10007, - 0x02640f92, 0x0fec001e, 0x02500f91, 0x0fe70038, - 0x023a0f91, 0x0fe00055, 0x02220f92, 0x0fdb0071, - 0x02080f95, 0x0fd4008f, 0x01ec0f98, 0x0fce00ae, - 0x01cf0f9b, 0x0fc700cf, 0x01b10f9f, 0x0fc100ef, - 0x01920fa4, 0x0fbb010f, 0x01710faa, 0x0fb50130, - 0x01520fae, 0x0fae0152, 0x01300fb5, 0x0faa0171, - 0x010f0fbb, 0x0fa40192, 0x00ef0fc1, 0x0f9f01b1, - 0x00cf0fc7, 0x0f9b01cf, 0x00ae0fce, 0x0f9801ec, - 0x008f0fd4, 0x0f950208, 0x00710fdb, 0x0f920222, - 0x00550fe0, 0x0f91023a, 0x00380fe7, 0x0f910250, - 0x001e0fec, 0x0f920264, 0x00070ff1, 0x0f940274, - 0x0ff00ff5, 0x0f970284, 0x0fdc0ff9, 0x0f9c028f, - 0x0fca0ffd, 0x0fa10298, 0x0fbb0fff, 0x0fa8029e, - - 0x02c80f9c, 0x00000f9c, 0x02c70f94, 0x0ffe0fa7, - 0x02c10f8c, 0x0ffc0fb7, 0x02b70f87, 0x0ff70fcb, - 0x02aa0f83, 0x0ff30fe0, 0x02990f80, 0x0fee0ff9, - 0x02870f7f, 0x0fe80012, 0x02720f7e, 0x0fe2002e, - 0x025a0f7e, 0x0fdb004d, 0x02400f80, 0x0fd5006b, - 0x02230f84, 0x0fcd008c, 0x02050f87, 0x0fc700ad, - 0x01e60f8b, 0x0fbf00d0, 0x01c60f90, 0x0fb700f3, - 0x01a30f96, 0x0fb00117, 0x01800f9c, 0x0faa013a, - 0x015d0fa2, 0x0fa2015f, 0x013a0faa, 0x0f9c0180, - 0x01170fb0, 0x0f9601a3, 0x00f30fb7, 0x0f9001c6, - 0x00d00fbf, 0x0f8b01e6, 0x00ad0fc7, 0x0f870205, - 0x008c0fcd, 0x0f840223, 0x006b0fd5, 0x0f800240, - 0x004d0fdb, 0x0f7e025a, 0x002e0fe2, 0x0f7e0272, - 0x00120fe8, 0x0f7f0287, 0x0ff90fee, 0x0f800299, - 0x0fe00ff3, 0x0f8302aa, 0x0fcb0ff7, 0x0f8702b7, - 0x0fb70ffc, 0x0f8c02c1, 0x0fa70ffe, 0x0f9402c7, - - 0x02f00f88, 0x00000f88, 0x02ee0f80, 0x0ffe0f94, - 0x02e70f78, 0x0ffc0fa5, 0x02dd0f73, 0x0ff60fba, - 0x02ce0f6f, 0x0ff20fd1, 0x02be0f6c, 0x0feb0feb, - 0x02aa0f6b, 0x0fe50006, 0x02940f6a, 0x0fde0024, - 0x02790f6c, 0x0fd60045, 0x025e0f6e, 0x0fcf0065, - 0x023f0f72, 0x0fc60089, 0x021d0f77, 0x0fbf00ad, - 0x01fd0f7b, 0x0fb600d2, 0x01da0f81, 0x0fad00f8, - 0x01b50f87, 0x0fa6011e, 0x018f0f8f, 0x0f9e0144, - 0x016b0f95, 0x0f95016b, 0x01440f9e, 0x0f8f018f, - 0x011e0fa6, 0x0f8701b5, 0x00f80fad, 0x0f8101da, - 0x00d20fb6, 0x0f7b01fd, 0x00ad0fbf, 0x0f77021d, - 0x00890fc6, 0x0f72023f, 0x00650fcf, 0x0f6e025e, - 0x00450fd6, 0x0f6c0279, 0x00240fde, 0x0f6a0294, - 0x00060fe5, 0x0f6b02aa, 0x0feb0feb, 0x0f6c02be, - 0x0fd10ff2, 0x0f6f02ce, 0x0fba0ff6, 0x0f7302dd, - 0x0fa50ffc, 0x0f7802e7, 0x0f940ffe, 0x0f8002ee, - - 0x03180f74, 0x00000f74, 0x03160f6b, 0x0ffe0f81, - 0x030e0f64, 0x0ffb0f93, 0x03030f5f, 0x0ff50fa9, - 0x02f40f5b, 0x0ff00fc1, 0x02e20f58, 0x0fe90fdd, - 0x02cd0f57, 0x0fe20ffa, 0x02b60f57, 0x0fda0019, - 0x02990f59, 0x0fd1003d, 0x027b0f5c, 0x0fc90060, - 0x02590f61, 0x0fc00086, 0x02370f66, 0x0fb700ac, - 0x02130f6b, 0x0fae00d4, 0x01ee0f72, 0x0fa400fc, - 0x01c70f79, 0x0f9b0125, 0x019f0f81, 0x0f93014d, - 0x01760f89, 0x0f890178, 0x014d0f93, 0x0f81019f, - 0x01250f9b, 0x0f7901c7, 0x00fc0fa4, 0x0f7201ee, - 0x00d40fae, 0x0f6b0213, 0x00ac0fb7, 0x0f660237, - 0x00860fc0, 0x0f610259, 0x00600fc9, 0x0f5c027b, - 0x003d0fd1, 0x0f590299, 0x00190fda, 0x0f5702b6, - 0x0ffa0fe2, 0x0f5702cd, 0x0fdd0fe9, 0x0f5802e2, - 0x0fc10ff0, 0x0f5b02f4, 0x0fa90ff5, 0x0f5f0303, - 0x0f930ffb, 0x0f64030e, 0x0f810ffe, 0x0f6b0316, - - 0x03400f60, 0x00000f60, 0x033e0f57, 0x0ffe0f6d, - 0x03370f4f, 0x0ffa0f80, 0x032a0f4b, 0x0ff30f98, - 0x031a0f46, 0x0fee0fb2, 0x03070f44, 0x0fe60fcf, - 0x02f10f44, 0x0fde0fed, 0x02d70f44, 0x0fd6000f, - 0x02b80f46, 0x0fcc0036, 0x02990f4a, 0x0fc3005a, - 0x02750f4f, 0x0fb90083, 0x02500f55, 0x0fb000ab, - 0x022a0f5b, 0x0fa500d6, 0x02020f63, 0x0f9a0101, - 0x01d80f6b, 0x0f91012c, 0x01ae0f74, 0x0f870157, - 0x01840f7c, 0x0f7c0184, 0x01570f87, 0x0f7401ae, - 0x012c0f91, 0x0f6b01d8, 0x01010f9a, 0x0f630202, - 0x00d60fa5, 0x0f5b022a, 0x00ab0fb0, 0x0f550250, - 0x00830fb9, 0x0f4f0275, 0x005a0fc3, 0x0f4a0299, - 0x00360fcc, 0x0f4602b8, 0x000f0fd6, 0x0f4402d7, - 0x0fed0fde, 0x0f4402f1, 0x0fcf0fe6, 0x0f440307, - 0x0fb20fee, 0x0f46031a, 0x0f980ff3, 0x0f4b032a, - 0x0f800ffa, 0x0f4f0337, 0x0f6d0ffe, 0x0f57033e, - - 0x02000000, 0x00000000, 0x01ff0ff9, 0x00000008, - 0x01fb0ff2, 0x00000013, 0x01f50fed, 0x0ffe0020, - 0x01ed0fe8, 0x0ffd002e, 0x01e30fe4, 0x0ffb003e, - 0x01d80fe1, 0x0ff9004e, 0x01cb0fde, 0x0ff70060, - 0x01bc0fdc, 0x0ff40074, 0x01ac0fdb, 0x0ff20087, - 0x019a0fdb, 0x0fef009c, 0x01870fdb, 0x0fed00b1, - 0x01740fdb, 0x0fea00c7, 0x01600fdc, 0x0fe700dd, - 0x014b0fdd, 0x0fe500f3, 0x01350fdf, 0x0fe30109, - 0x01200fe0, 0x0fe00120, 0x01090fe3, 0x0fdf0135, - 0x00f30fe5, 0x0fdd014b, 0x00dd0fe7, 0x0fdc0160, - 0x00c70fea, 0x0fdb0174, 0x00b10fed, 0x0fdb0187, - 0x009c0fef, 0x0fdb019a, 0x00870ff2, 0x0fdb01ac, - 0x00740ff4, 0x0fdc01bc, 0x00600ff7, 0x0fde01cb, - 0x004e0ff9, 0x0fe101d8, 0x003e0ffb, 0x0fe401e3, - 0x002e0ffd, 0x0fe801ed, 0x00200ffe, 0x0fed01f5, - 0x00130000, 0x0ff201fb, 0x00080000, 0x0ff901ff, - - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - 0x02000000, 0x00000000, 0x02000000, 0x00000000, - - 0x02000000, 0x00000000, 0x01fc0ff9, 0x0ffe000d, - 0x01f60ff3, 0x0ffb001c, 0x01ef0fed, 0x0ff9002b, - 0x01e60fe8, 0x0ff6003c, 0x01dc0fe4, 0x0ff3004d, - 0x01d00fe0, 0x0ff1005f, 0x01c30fde, 0x0fee0071, - 0x01b50fdb, 0x0feb0085, 0x01a70fd9, 0x0fe80098, - 0x01960fd8, 0x0fe600ac, 0x01850fd7, 0x0fe300c1, - 0x01730fd7, 0x0fe100d5, 0x01610fd7, 0x0fdf00e9, - 0x014e0fd8, 0x0fdd00fd, 0x013b0fd8, 0x0fdb0112, - 0x01250fda, 0x0fda0127, 0x01120fdb, 0x0fd8013b, - 0x00fd0fdd, 0x0fd8014e, 0x00e90fdf, 0x0fd70161, - 0x00d50fe1, 0x0fd70173, 0x00c10fe3, 0x0fd70185, - 0x00ac0fe6, 0x0fd80196, 0x00980fe8, 0x0fd901a7, - 0x00850feb, 0x0fdb01b5, 0x00710fee, 0x0fde01c3, - 0x005f0ff1, 0x0fe001d0, 0x004d0ff3, 0x0fe401dc, - 0x003c0ff6, 0x0fe801e6, 0x002b0ff9, 0x0fed01ef, - 0x001c0ffb, 0x0ff301f6, 0x000d0ffe, 0x0ff901fc, - - 0x020f0034, 0x0f7a0043, 0x01e80023, 0x0fa8004d, - 0x01d30016, 0x0fbe0059, 0x01c6000a, 0x0fc90067, - 0x01bd0000, 0x0fce0075, 0x01b50ff7, 0x0fcf0085, - 0x01ae0fee, 0x0fcf0095, 0x01a70fe6, 0x0fcd00a6, - 0x019d0fe0, 0x0fcb00b8, 0x01940fd9, 0x0fc900ca, - 0x01890fd4, 0x0fc700dc, 0x017d0fcf, 0x0fc600ee, - 0x01700fcc, 0x0fc40100, 0x01620fc9, 0x0fc40111, - 0x01540fc6, 0x0fc30123, 0x01430fc5, 0x0fc40134, - 0x01340fc4, 0x0fc50143, 0x01230fc3, 0x0fc60154, - 0x01110fc4, 0x0fc90162, 0x01000fc4, 0x0fcc0170, - 0x00ee0fc6, 0x0fcf017d, 0x00dc0fc7, 0x0fd40189, - 0x00ca0fc9, 0x0fd90194, 0x00b80fcb, 0x0fe0019d, - 0x00a60fcd, 0x0fe601a7, 0x00950fcf, 0x0fee01ae, - 0x00850fcf, 0x0ff701b5, 0x00750fce, 0x000001bd, - 0x00670fc9, 0x000a01c6, 0x00590fbe, 0x001601d3, - 0x004d0fa8, 0x002301e8, 0x00430f7a, 0x0034020f, - - 0x015c005e, 0x0fde0068, 0x015c0054, 0x0fdd0073, - 0x015b004b, 0x0fdc007e, 0x015a0042, 0x0fdb0089, - 0x01590039, 0x0fda0094, 0x01560030, 0x0fda00a0, - 0x01530028, 0x0fda00ab, 0x014f0020, 0x0fda00b7, - 0x014a0019, 0x0fdb00c2, 0x01450011, 0x0fdc00ce, - 0x013e000b, 0x0fde00d9, 0x01390004, 0x0fdf00e4, - 0x01310ffe, 0x0fe200ef, 0x01290ff9, 0x0fe400fa, - 0x01200ff4, 0x0fe80104, 0x01180fef, 0x0feb010e, - 0x010e0feb, 0x0fef0118, 0x01040fe8, 0x0ff40120, - 0x00fa0fe4, 0x0ff90129, 0x00ef0fe2, 0x0ffe0131, - 0x00e40fdf, 0x00040139, 0x00d90fde, 0x000b013e, - 0x00ce0fdc, 0x00110145, 0x00c20fdb, 0x0019014a, - 0x00b70fda, 0x0020014f, 0x00ab0fda, 0x00280153, - 0x00a00fda, 0x00300156, 0x00940fda, 0x00390159, - 0x00890fdb, 0x0042015a, 0x007e0fdc, 0x004b015b, - 0x00730fdd, 0x0054015c, 0x00680fde, 0x005e015c, - - 0x01300068, 0x0ff80070, 0x01300060, 0x0ff80078, - 0x012f0059, 0x0ff80080, 0x012d0052, 0x0ff80089, - 0x012b004b, 0x0ff90091, 0x01290044, 0x0ff9009a, - 0x0126003d, 0x0ffa00a3, 0x01220037, 0x0ffb00ac, - 0x011f0031, 0x0ffc00b4, 0x011a002b, 0x0ffe00bd, - 0x01150026, 0x000000c5, 0x010f0021, 0x000200ce, - 0x010a001c, 0x000400d6, 0x01030018, 0x000600df, - 0x00fd0014, 0x000900e6, 0x00f60010, 0x000c00ee, - 0x00ee000c, 0x001000f6, 0x00e60009, 0x001400fd, - 0x00df0006, 0x00180103, 0x00d60004, 0x001c010a, - 0x00ce0002, 0x0021010f, 0x00c50000, 0x00260115, - 0x00bd0ffe, 0x002b011a, 0x00b40ffc, 0x0031011f, - 0x00ac0ffb, 0x00370122, 0x00a30ffa, 0x003d0126, - 0x009a0ff9, 0x00440129, 0x00910ff9, 0x004b012b, - 0x00890ff8, 0x0052012d, 0x00800ff8, 0x0059012f, - 0x00780ff8, 0x00600130, 0x00700ff8, 0x00680130, - - 0x01050079, 0x0003007f, 0x01040073, 0x00030086, - 0x0103006d, 0x0004008c, 0x01030066, 0x00050092, - 0x01010060, 0x00060099, 0x0100005a, 0x0007009f, - 0x00fe0054, 0x000900a5, 0x00fa004f, 0x000b00ac, - 0x00f80049, 0x000d00b2, 0x00f50044, 0x000f00b8, - 0x00f2003f, 0x001200bd, 0x00ef0039, 0x001500c3, - 0x00ea0035, 0x001800c9, 0x00e60030, 0x001c00ce, - 0x00e3002b, 0x001f00d3, 0x00dd0027, 0x002300d9, - 0x00d90023, 0x002700dd, 0x00d3001f, 0x002b00e3, - 0x00ce001c, 0x003000e6, 0x00c90018, 0x003500ea, - 0x00c30015, 0x003900ef, 0x00bd0012, 0x003f00f2, - 0x00b8000f, 0x004400f5, 0x00b2000d, 0x004900f8, - 0x00ac000b, 0x004f00fa, 0x00a50009, 0x005400fe, - 0x009f0007, 0x005a0100, 0x00990006, 0x00600101, - 0x00920005, 0x00660103, 0x008c0004, 0x006d0103, - 0x00860003, 0x00730104, 0x007f0003, 0x00790105, - - 0x00cf0088, 0x001d008c, 0x00ce0084, 0x0020008e, - 0x00cd0080, 0x00210092, 0x00cd007b, 0x00240094, - 0x00ca0077, 0x00270098, 0x00c90073, 0x0029009b, - 0x00c8006f, 0x002c009d, 0x00c6006b, 0x002f00a0, - 0x00c50067, 0x003200a2, 0x00c30062, 0x003600a5, - 0x00c0005f, 0x003900a8, 0x00c0005b, 0x003b00aa, - 0x00be0057, 0x003e00ad, 0x00ba0054, 0x004200b0, - 0x00b90050, 0x004500b2, 0x00b7004c, 0x004900b4, - 0x00b40049, 0x004c00b7, 0x00b20045, 0x005000b9, - 0x00b00042, 0x005400ba, 0x00ad003e, 0x005700be, - 0x00aa003b, 0x005b00c0, 0x00a80039, 0x005f00c0, - 0x00a50036, 0x006200c3, 0x00a20032, 0x006700c5, - 0x00a0002f, 0x006b00c6, 0x009d002c, 0x006f00c8, - 0x009b0029, 0x007300c9, 0x00980027, 0x007700ca, - 0x00940024, 0x007b00cd, 0x00920021, 0x008000cd, - 0x008e0020, 0x008400ce, 0x008c001d, 0x008800cf, - - 0x008e0083, 0x006b0084, 0x008d0083, 0x006c0084, - 0x008d0082, 0x006d0084, 0x008d0081, 0x006d0085, - 0x008d0080, 0x006e0085, 0x008c007f, 0x006f0086, - 0x008b007f, 0x00700086, 0x008b007e, 0x00710086, - 0x008b007d, 0x00720086, 0x008a007d, 0x00730086, - 0x008a007c, 0x00730087, 0x008a007b, 0x00740087, - 0x0089007b, 0x00750087, 0x008a0079, 0x00750088, - 0x008a0078, 0x00760088, 0x008a0077, 0x00770088, - 0x00880077, 0x0077008a, 0x00880076, 0x0078008a, - 0x00880075, 0x0079008a, 0x00870075, 0x007b0089, - 0x00870074, 0x007b008a, 0x00870073, 0x007c008a, - 0x00860073, 0x007d008a, 0x00860072, 0x007d008b, - 0x00860071, 0x007e008b, 0x00860070, 0x007f008b, - 0x0086006f, 0x007f008c, 0x0085006e, 0x0080008d, - 0x0085006d, 0x0081008d, 0x0084006d, 0x0082008d, - 0x0084006c, 0x0083008d, 0x0084006b, 0x0083008e, - - 0x023c0fe2, 0x00000fe2, 0x023a0fdb, 0x00000feb, - 0x02360fd3, 0x0fff0ff8, 0x022e0fcf, 0x0ffc0007, - 0x02250fca, 0x0ffa0017, 0x021a0fc6, 0x0ff70029, - 0x020c0fc4, 0x0ff4003c, 0x01fd0fc1, 0x0ff10051, - 0x01eb0fc0, 0x0fed0068, 0x01d80fc0, 0x0fe9007f, - 0x01c30fc1, 0x0fe50097, 0x01ac0fc2, 0x0fe200b0, - 0x01960fc3, 0x0fdd00ca, 0x017e0fc5, 0x0fd900e4, - 0x01650fc8, 0x0fd500fe, 0x014b0fcb, 0x0fd20118, - 0x01330fcd, 0x0fcd0133, 0x01180fd2, 0x0fcb014b, - 0x00fe0fd5, 0x0fc80165, 0x00e40fd9, 0x0fc5017e, - 0x00ca0fdd, 0x0fc30196, 0x00b00fe2, 0x0fc201ac, - 0x00970fe5, 0x0fc101c3, 0x007f0fe9, 0x0fc001d8, - 0x00680fed, 0x0fc001eb, 0x00510ff1, 0x0fc101fd, - 0x003c0ff4, 0x0fc4020c, 0x00290ff7, 0x0fc6021a, - 0x00170ffa, 0x0fca0225, 0x00070ffc, 0x0fcf022e, - 0x0ff80fff, 0x0fd30236, 0x0feb0000, 0x0fdb023a, - - 0x02780fc4, 0x00000fc4, 0x02770fbc, 0x0fff0fce, - 0x02710fb5, 0x0ffe0fdc, 0x02690fb0, 0x0ffa0fed, - 0x025f0fab, 0x0ff70fff, 0x02500fa8, 0x0ff30015, - 0x02410fa6, 0x0fef002a, 0x022f0fa4, 0x0feb0042, - 0x021a0fa4, 0x0fe5005d, 0x02040fa5, 0x0fe10076, - 0x01eb0fa7, 0x0fdb0093, 0x01d20fa9, 0x0fd600af, - 0x01b80fab, 0x0fd000cd, 0x019d0faf, 0x0fca00ea, - 0x01810fb2, 0x0fc50108, 0x01620fb7, 0x0fc10126, - 0x01440fbb, 0x0fbb0146, 0x01260fc1, 0x0fb70162, - 0x01080fc5, 0x0fb20181, 0x00ea0fca, 0x0faf019d, - 0x00cd0fd0, 0x0fab01b8, 0x00af0fd6, 0x0fa901d2, - 0x00930fdb, 0x0fa701eb, 0x00760fe1, 0x0fa50204, - 0x005d0fe5, 0x0fa4021a, 0x00420feb, 0x0fa4022f, - 0x002a0fef, 0x0fa60241, 0x00150ff3, 0x0fa80250, - 0x0fff0ff7, 0x0fab025f, 0x0fed0ffa, 0x0fb00269, - 0x0fdc0ffe, 0x0fb50271, 0x0fce0fff, 0x0fbc0277, - - 0x02a00fb0, 0x00000fb0, 0x029e0fa8, 0x0fff0fbb, - 0x02980fa1, 0x0ffd0fca, 0x028f0f9c, 0x0ff90fdc, - 0x02840f97, 0x0ff50ff0, 0x02740f94, 0x0ff10007, - 0x02640f92, 0x0fec001e, 0x02500f91, 0x0fe70038, - 0x023a0f91, 0x0fe00055, 0x02220f92, 0x0fdb0071, - 0x02080f95, 0x0fd4008f, 0x01ec0f98, 0x0fce00ae, - 0x01cf0f9b, 0x0fc700cf, 0x01b10f9f, 0x0fc100ef, - 0x01920fa4, 0x0fbb010f, 0x01710faa, 0x0fb50130, - 0x01520fae, 0x0fae0152, 0x01300fb5, 0x0faa0171, - 0x010f0fbb, 0x0fa40192, 0x00ef0fc1, 0x0f9f01b1, - 0x00cf0fc7, 0x0f9b01cf, 0x00ae0fce, 0x0f9801ec, - 0x008f0fd4, 0x0f950208, 0x00710fdb, 0x0f920222, - 0x00550fe0, 0x0f91023a, 0x00380fe7, 0x0f910250, - 0x001e0fec, 0x0f920264, 0x00070ff1, 0x0f940274, - 0x0ff00ff5, 0x0f970284, 0x0fdc0ff9, 0x0f9c028f, - 0x0fca0ffd, 0x0fa10298, 0x0fbb0fff, 0x0fa8029e, - - 0x02c80f9c, 0x00000f9c, 0x02c70f94, 0x0ffe0fa7, - 0x02c10f8c, 0x0ffc0fb7, 0x02b70f87, 0x0ff70fcb, - 0x02aa0f83, 0x0ff30fe0, 0x02990f80, 0x0fee0ff9, - 0x02870f7f, 0x0fe80012, 0x02720f7e, 0x0fe2002e, - 0x025a0f7e, 0x0fdb004d, 0x02400f80, 0x0fd5006b, - 0x02230f84, 0x0fcd008c, 0x02050f87, 0x0fc700ad, - 0x01e60f8b, 0x0fbf00d0, 0x01c60f90, 0x0fb700f3, - 0x01a30f96, 0x0fb00117, 0x01800f9c, 0x0faa013a, - 0x015d0fa2, 0x0fa2015f, 0x013a0faa, 0x0f9c0180, - 0x01170fb0, 0x0f9601a3, 0x00f30fb7, 0x0f9001c6, - 0x00d00fbf, 0x0f8b01e6, 0x00ad0fc7, 0x0f870205, - 0x008c0fcd, 0x0f840223, 0x006b0fd5, 0x0f800240, - 0x004d0fdb, 0x0f7e025a, 0x002e0fe2, 0x0f7e0272, - 0x00120fe8, 0x0f7f0287, 0x0ff90fee, 0x0f800299, - 0x0fe00ff3, 0x0f8302aa, 0x0fcb0ff7, 0x0f8702b7, - 0x0fb70ffc, 0x0f8c02c1, 0x0fa70ffe, 0x0f9402c7, - - 0x02f00f88, 0x00000f88, 0x02ee0f80, 0x0ffe0f94, - 0x02e70f78, 0x0ffc0fa5, 0x02dd0f73, 0x0ff60fba, - 0x02ce0f6f, 0x0ff20fd1, 0x02be0f6c, 0x0feb0feb, - 0x02aa0f6b, 0x0fe50006, 0x02940f6a, 0x0fde0024, - 0x02790f6c, 0x0fd60045, 0x025e0f6e, 0x0fcf0065, - 0x023f0f72, 0x0fc60089, 0x021d0f77, 0x0fbf00ad, - 0x01fd0f7b, 0x0fb600d2, 0x01da0f81, 0x0fad00f8, - 0x01b50f87, 0x0fa6011e, 0x018f0f8f, 0x0f9e0144, - 0x016b0f95, 0x0f95016b, 0x01440f9e, 0x0f8f018f, - 0x011e0fa6, 0x0f8701b5, 0x00f80fad, 0x0f8101da, - 0x00d20fb6, 0x0f7b01fd, 0x00ad0fbf, 0x0f77021d, - 0x00890fc6, 0x0f72023f, 0x00650fcf, 0x0f6e025e, - 0x00450fd6, 0x0f6c0279, 0x00240fde, 0x0f6a0294, - 0x00060fe5, 0x0f6b02aa, 0x0feb0feb, 0x0f6c02be, - 0x0fd10ff2, 0x0f6f02ce, 0x0fba0ff6, 0x0f7302dd, - 0x0fa50ffc, 0x0f7802e7, 0x0f940ffe, 0x0f8002ee, - - 0x03180f74, 0x00000f74, 0x03160f6b, 0x0ffe0f81, - 0x030e0f64, 0x0ffb0f93, 0x03030f5f, 0x0ff50fa9, - 0x02f40f5b, 0x0ff00fc1, 0x02e20f58, 0x0fe90fdd, - 0x02cd0f57, 0x0fe20ffa, 0x02b60f57, 0x0fda0019, - 0x02990f59, 0x0fd1003d, 0x027b0f5c, 0x0fc90060, - 0x02590f61, 0x0fc00086, 0x02370f66, 0x0fb700ac, - 0x02130f6b, 0x0fae00d4, 0x01ee0f72, 0x0fa400fc, - 0x01c70f79, 0x0f9b0125, 0x019f0f81, 0x0f93014d, - 0x01760f89, 0x0f890178, 0x014d0f93, 0x0f81019f, - 0x01250f9b, 0x0f7901c7, 0x00fc0fa4, 0x0f7201ee, - 0x00d40fae, 0x0f6b0213, 0x00ac0fb7, 0x0f660237, - 0x00860fc0, 0x0f610259, 0x00600fc9, 0x0f5c027b, - 0x003d0fd1, 0x0f590299, 0x00190fda, 0x0f5702b6, - 0x0ffa0fe2, 0x0f5702cd, 0x0fdd0fe9, 0x0f5802e2, - 0x0fc10ff0, 0x0f5b02f4, 0x0fa90ff5, 0x0f5f0303, - 0x0f930ffb, 0x0f64030e, 0x0f810ffe, 0x0f6b0316, - - 0x03400f60, 0x00000f60, 0x033e0f57, 0x0ffe0f6d, - 0x03370f4f, 0x0ffa0f80, 0x032a0f4b, 0x0ff30f98, - 0x031a0f46, 0x0fee0fb2, 0x03070f44, 0x0fe60fcf, - 0x02f10f44, 0x0fde0fed, 0x02d70f44, 0x0fd6000f, - 0x02b80f46, 0x0fcc0036, 0x02990f4a, 0x0fc3005a, - 0x02750f4f, 0x0fb90083, 0x02500f55, 0x0fb000ab, - 0x022a0f5b, 0x0fa500d6, 0x02020f63, 0x0f9a0101, - 0x01d80f6b, 0x0f91012c, 0x01ae0f74, 0x0f870157, - 0x01840f7c, 0x0f7c0184, 0x01570f87, 0x0f7401ae, - 0x012c0f91, 0x0f6b01d8, 0x01010f9a, 0x0f630202, - 0x00d60fa5, 0x0f5b022a, 0x00ab0fb0, 0x0f550250, - 0x00830fb9, 0x0f4f0275, 0x005a0fc3, 0x0f4a0299, - 0x00360fcc, 0x0f4602b8, 0x000f0fd6, 0x0f4402d7, - 0x0fed0fde, 0x0f4402f1, 0x0fcf0fe6, 0x0f440307, - 0x0fb20fee, 0x0f46031a, 0x0f980ff3, 0x0f4b032a, - 0x0f800ffa, 0x0f4f0337, 0x0f6d0ffe, 0x0f57033e -}; - - -#define MDP4_QSEED_TABLE0_OFF 0x8100 -#define MDP4_QSEED_TABLE1_OFF 0x8200 -#define MDP4_QSEED_TABLE2_OFF 0x9000 - -void mdp4_vg_qseed_init(int vp_num) -{ - uint32 *off; - int i, voff; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - voff = MDP4_VIDEO_OFF * vp_num; - off = (uint32 *)(MDP_BASE + MDP4_VIDEO_BASE + voff + - MDP4_QSEED_TABLE0_OFF); - for (i = 0; i < (sizeof(vg_qseed_table0) / sizeof(uint32)); i++) { - outpdw(off, vg_qseed_table0[i]); - off++; - /* This code is added to workaround the 1K Boundary AXI - Interleave operations from Scorpion that can potentially - corrupt the QSEED table. The idea is to complete the prevous - to the buffer before making the next write when address is - 1KB aligned to ensure the write has been committed prior to - next instruction write that can go out from the secondary AXI - port.This happens also because of the expected write sequence - from QSEED table, where LSP has to be written first then the - MSP to trigger both to write out to SRAM, if this has not been - the expectation, then corruption wouldn't have happened.*/ - - if (!((uint32)off & 0x3FF)) - wmb(); - } - - off = (uint32 *)(MDP_BASE + MDP4_VIDEO_BASE + voff + - MDP4_QSEED_TABLE1_OFF); - for (i = 0; i < (sizeof(vg_qseed_table1) / sizeof(uint32)); i++) { - outpdw(off, vg_qseed_table1[i]); - off++; - if (!((uint32)off & 0x3FF)) - wmb(); - } - - off = (uint32 *)(MDP_BASE + MDP4_VIDEO_BASE + voff + - MDP4_QSEED_TABLE2_OFF); - for (i = 0; i < (sizeof(vg_qseed_table2) / sizeof(uint32)); i++) { - outpdw(off, vg_qseed_table2[i]); - off++; - if (!((uint32)off & 0x3FF)) - wmb(); - } - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - -} - -void mdp4_mixer_blend_init(mixer_num) -{ - unsigned char *overlay_base; - int off; - - if (mixer_num) /* mixer number, /dev/fb0, /dev/fb1 */ - overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;/* 0x18000 */ - else - overlay_base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* stage 0 to stage 2 */ - off = 0; - outpdw(overlay_base + off + 0x104, 0x010); - outpdw(overlay_base + off + 0x108, 0xff);/* FG */ - outpdw(overlay_base + off + 0x10c, 0x00);/* BG */ - - off += 0x20; - outpdw(overlay_base + off + 0x104, 0x010); - outpdw(overlay_base + off + 0x108, 0xff);/* FG */ - outpdw(overlay_base + off + 0x10c, 0x00);/* BG */ - - off += 0x20; - outpdw(overlay_base + off + 0x104, 0x010); - outpdw(overlay_base + off + 0x108, 0xff);/* FG */ - outpdw(overlay_base + off + 0x10c, 0x00);/* BG */ - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -struct mdp_csc_cfg mdp_csc_convert[4] = { - { /*RGB2RGB*/ - 0, - { - 0x0200, 0x0000, 0x0000, - 0x0000, 0x0200, 0x0000, - 0x0000, 0x0000, 0x0200, - }, - { 0x0, 0x0, 0x0, }, - { 0x0, 0x0, 0x0, }, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, }, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, }, - }, - { /*YUV2RGB*/ - 0, - { - 0x0254, 0x0000, 0x0331, - 0x0254, 0xff37, 0xfe60, - 0x0254, 0x0409, 0x0000, - }, - { 0xfff0, 0xff80, 0xff80, }, - { 0x0, 0x0, 0x0, }, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, }, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, }, - }, - { /*RGB2YUV*/ - 0, - { - 0x0083, 0x0102, 0x0032, - 0x1fb5, 0x1f6c, 0x00e1, - 0x00e1, 0x1f45, 0x1fdc - }, - { 0x0, 0x0, 0x0, }, - { 0x0010, 0x0080, 0x0080, }, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, }, - { 0x0010, 0x00eb, 0x0010, 0x00f0, 0x0010, 0x00f0, }, - }, - { /*YUV2YUV ???*/ - 0, - { - 0x0200, 0x0000, 0x0000, - 0x0000, 0x0200, 0x0000, - 0x0000, 0x0000, 0x0200, - }, - { 0x0, 0x0, 0x0, }, - { 0x0, 0x0, 0x0, }, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, }, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, }, - }, -}; - - -void mdp4_vg_csc_update(struct mdp_csc *p) -{ - struct mdp4_overlay_pipe *pipe; - uint32_t block = 0; - int i = 0; - - pipe = mdp4_overlay_ndx2pipe(p->id); - if (pipe == NULL) { - pr_err("%s: p->id = %d Error\n", __func__, p->id); - return; - } - if (pipe->pipe_num == OVERLAY_PIPE_VG1) - block = MDP_BLOCK_VG_1; - else if (pipe->pipe_num == OVERLAY_PIPE_VG2) - block = MDP_BLOCK_VG_2; - else - return; - - for (i = 0; i < CSC_MAX_BLOCKS; i++) { - if (csc_cfg_matrix[i].block == block) - break; - } - if (i == CSC_MAX_BLOCKS) - return; - - memcpy(&csc_cfg_matrix[i].csc_data.csc_mv, p->csc_mv, - sizeof(p->csc_mv)); - memcpy(&csc_cfg_matrix[i].csc_data.csc_pre_bv, p->csc_pre_bv, - sizeof(p->csc_pre_bv)); - memcpy(&csc_cfg_matrix[i].csc_data.csc_post_bv, p->csc_post_bv, - sizeof(p->csc_post_bv)); - memcpy(&csc_cfg_matrix[i].csc_data.csc_pre_lv, p->csc_pre_lv, - sizeof(p->csc_pre_lv)); - memcpy(&csc_cfg_matrix[i].csc_data.csc_post_lv, p->csc_post_lv, - sizeof(p->csc_post_lv)); - csc_cfg_matrix[i].csc_data.flags = MDP_CSC_FLAG_YUV_OUT; - - mdp4_csc_config(&csc_cfg_matrix[i]); - -} - -char gc_lut[] = { - 0x0, 0x1, 0x2, 0x2, 0x3, 0x4, 0x5, 0x6, - 0x6, 0x7, 0x8, 0x9, 0xA, 0xA, 0xB, 0xC, - 0xD, 0xD, 0xE, 0xF, 0xF, 0x10, 0x10, 0x11, - 0x12, 0x12, 0x13, 0x13, 0x14, 0x14, 0x15, 0x15, - 0x16, 0x16, 0x17, 0x17, 0x17, 0x18, 0x18, 0x19, - 0x19, 0x19, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1C, - 0x1C, 0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1F, - 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, - 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, - 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, - 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, 0x28, 0x28, - 0x28, 0x29, 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2A, - 0x2A, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, - 0x2C, 0x2C, 0x2D, 0x2D, 0x2D, 0x2D, 0x2E, 0x2E, - 0x2E, 0x2E, 0x2E, 0x2F, 0x2F, 0x2F, 0x2F, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x31, - 0x31, 0x32, 0x32, 0x32, 0x32, 0x32, 0x33, 0x33, - 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x34, 0x34, - 0x35, 0x35, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, - 0x38, 0x38, 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, - 0x39, 0x39, 0x39, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, - 0x3A, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3C, - 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3D, 0x3D, 0x3D, - 0x3D, 0x3D, 0x3D, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, - 0x3E, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x40, - 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41, - 0x41, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x42, - 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x43, 0x43, - 0x43, 0x43, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, - 0x44, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, - 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x47, - 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x48, 0x48, - 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49, - 0x49, 0x49, 0x49, 0x49, 0x49, 0x4A, 0x4A, 0x4A, - 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C, 0x4C, - 0x4C, 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, - 0x4D, 0x4D, 0x4D, 0x4D, 0x4E, 0x4E, 0x4E, 0x4E, - 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, - 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x50, - 0x50, 0x50, 0x50, 0x50, 0x50, 0x51, 0x51, 0x51, - 0x51, 0x51, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, - 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, - 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, - 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, 0x54, - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - 0x55, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, 0x56, - 0x56, 0x56, 0x57, 0x57, 0x57, 0x57, 0x57, 0x57, - 0x57, 0x57, 0x57, 0x58, 0x58, 0x58, 0x58, 0x58, - 0x58, 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x5A, 0x5A, - 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, - 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, - 0x5B, 0x5B, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5D, 0x5D, 0x5D, 0x5D, - 0x5D, 0x5D, 0x5D, 0x5D, 0x5D, 0x5D, 0x5E, 0x5E, - 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, - 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, - 0x5F, 0x5F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, - 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x61, 0x61, - 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x62, - 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, 0x62, - 0x62, 0x62, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, 0x63, 0x64, 0x64, 0x64, - 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, - 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x65, - 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x67, 0x67, - 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, - 0x67, 0x67, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, - 0x68, 0x68, 0x68, 0x68, 0x68, 0x69, 0x69, 0x69, - 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, - 0x69, 0x6A, 0x6A, 0x6A, 0x6A, 0x6A, 0x6A, 0x6A, - 0x6A, 0x6A, 0x6A, 0x6A, 0x6A, 0x6B, 0x6B, 0x6B, - 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, - 0x6B, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, - 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, - 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, - 0x6D, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, - 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x6F, 0x6F, 0x6F, - 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, - 0x6F, 0x6F, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, - 0x71, 0x71, 0x71, 0x72, 0x72, 0x72, 0x72, 0x72, - 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, - 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, - 0x73, 0x73, 0x73, 0x73, 0x73, 0x74, 0x74, 0x74, - 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, - 0x74, 0x74, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, - 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, - 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, - 0x76, 0x76, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, - 0x77, 0x77, 0x77, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, - 0x78, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, - 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x7A, 0x7A, - 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, - 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7B, 0x7B, 0x7B, - 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, - 0x7B, 0x7B, 0x7B, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, - 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, - 0x7C, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, - 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, - 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, - 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7F, 0x7F, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, - 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, - 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9B, 0x9B, 0x9B, - 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, - 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, - 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, - 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, - 0x9C, 0x9C, 0x9C, 0x9C, 0x9D, 0x9D, 0x9D, 0x9D, - 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, - 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9E, - 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, - 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, - 0x9E, 0x9E, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, - 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, - 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0xA0, 0xA0, - 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, - 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, - 0xA0, 0xA0, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, - 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, - 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA2, 0xA2, - 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, - 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, - 0xA2, 0xA2, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, - 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, - 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA4, 0xA4, - 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, - 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, - 0xA4, 0xA4, 0xA4, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, - 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, - 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, - 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, - 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, - 0xA6, 0xA6, 0xA6, 0xA6, 0xA7, 0xA7, 0xA7, 0xA7, - 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, - 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, - 0xA7, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, - 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, - 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA9, - 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, - 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, - 0xA9, 0xA9, 0xA9, 0xA9, 0xAA, 0xAA, 0xAA, 0xAA, - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0xAA, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, - 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, - 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAC, - 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, - 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, - 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAD, 0xAD, 0xAD, - 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, - 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, - 0xAD, 0xAD, 0xAD, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, - 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, - 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, - 0xAE, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, - 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, - 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xB0, - 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, - 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, - 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB1, 0xB1, - 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, - 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, - 0xB1, 0xB1, 0xB1, 0xB1, 0xB2, 0xB2, 0xB2, 0xB2, - 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, - 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, - 0xB2, 0xB2, 0xB2, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, - 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, - 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, - 0xB3, 0xB3, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, - 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, - 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, - 0xB4, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, - 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, - 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, - 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, - 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, - 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, - 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, - 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, - 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB8, - 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, - 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, - 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB9, - 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, - 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, - 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xBA, - 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, - 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, - 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBB, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, - 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, - 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, - 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, - 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, - 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, - 0xBD, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, - 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, - 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, - 0xBE, 0xBE, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, - 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, - 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, - 0xBF, 0xBF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0xC1, 0xC1, 0xC1, - 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, - 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, - 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC2, 0xC2, 0xC2, - 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, - 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, - 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC3, 0xC3, - 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, - 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, - 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, - 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, - 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, - 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, - 0xC4, 0xC4, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, - 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, - 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, - 0xC5, 0xC5, 0xC5, 0xC5, 0xC6, 0xC6, 0xC6, 0xC6, - 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, - 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, - 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC7, 0xC7, - 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, - 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, - 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, - 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - 0xC8, 0xC8, 0xC8, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, - 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, - 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, - 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xCA, 0xCA, - 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, - 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, - 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, - 0xCA, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, - 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, - 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, - 0xCB, 0xCB, 0xCB, 0xCB, 0xCC, 0xCC, 0xCC, 0xCC, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCD, - 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, - 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, - 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, - 0xCD, 0xCD, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, - 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, - 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, - 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCF, 0xCF, - 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, - 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, - 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, - 0xCF, 0xCF, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, - 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, - 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, - 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD1, 0xD1, 0xD1, - 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, - 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, - 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, - 0xD1, 0xD1, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, - 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, - 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, - 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD3, 0xD3, - 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, - 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, - 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, - 0xD3, 0xD3, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, - 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, - 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, - 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD5, - 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, - 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, - 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, - 0xD5, 0xD5, 0xD5, 0xD5, 0xD6, 0xD6, 0xD6, 0xD6, - 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, - 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, - 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, - 0xD6, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, - 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, - 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, - 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD8, 0xD8, - 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, - 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, - 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, - 0xD8, 0xD8, 0xD8, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, - 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, - 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, - 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, - 0xD9, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, - 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, - 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, - 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDB, 0xDB, - 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, - 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, - 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, - 0xDB, 0xDB, 0xDB, 0xDB, 0xDC, 0xDC, 0xDC, 0xDC, - 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, - 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, - 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, - 0xDC, 0xDC, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, - 0xDD, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, - 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, - 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, - 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDF, - 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, - 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, - 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, - 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xE0, 0xE0, - 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, - 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, - 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, - 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 0xE1, 0xE1, 0xE1, - 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, - 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, - 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, - 0xE1, 0xE1, 0xE1, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, - 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, - 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, - 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, - 0xE2, 0xE2, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, - 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, - 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, - 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, - 0xE3, 0xE3, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, - 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, - 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, - 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, - 0xE4, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, - 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, - 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, - 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, - 0xE5, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, - 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, - 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, - 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, - 0xE6, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, - 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, - 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, - 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, - 0xE7, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, - 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, - 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, - 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, - 0xE8, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, - 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, - 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, - 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, - 0xE9, 0xE9, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, - 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, - 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, - 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, - 0xEA, 0xEA, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, - 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, - 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, - 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, - 0xEB, 0xEB, 0xEB, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, - 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, - 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, - 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, - 0xEC, 0xEC, 0xEC, 0xEC, 0xED, 0xED, 0xED, 0xED, - 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, - 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, - 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, - 0xED, 0xED, 0xED, 0xED, 0xED, 0xEE, 0xEE, 0xEE, - 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, - 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, - 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, - 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEF, 0xEF, - 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, - 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, - 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, - 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, - 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, - 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, - 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, - 0xF1, 0xF1, 0xF1, 0xF1, 0xF2, 0xF2, 0xF2, 0xF2, - 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, - 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, - 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, - 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF3, 0xF3, - 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, - 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, - 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, - 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, - 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, - 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, - 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, - 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, - 0xF4, 0xF4, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, - 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, - 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, - 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, - 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF6, 0xF6, 0xF6, - 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, - 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, - 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, - 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, - 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, - 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, - 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, - 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, - 0xF7, 0xF7, 0xF7, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, - 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, - 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, - 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, - 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF9, 0xF9, - 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, - 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, - 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, - 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, - 0xF9, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, - 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, - 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, - 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, - 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFB, 0xFB, 0xFB, - 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, - 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, - 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, - 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, - 0xFB, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, - 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, - 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, - 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, - 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFD, 0xFD, 0xFD, - 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, - 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, - 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, - 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, - 0xFD, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, - 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, - 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, - 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, - 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -}; - -void mdp4_mixer_gc_lut_setup(int mixer_num) -{ - unsigned char *base; - uint32 data; - char val; - int i, off; - - if (mixer_num) /* mixer number, /dev/fb0, /dev/fb1 */ - base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;/* 0x18000 */ - else - base = MDP_BASE + MDP4_OVERLAYPROC0_BASE;/* 0x10000 */ - - base += 0x4000; /* GC_LUT offset */ - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - off = 0; - for (i = 0; i < 4096; i++) { - val = gc_lut[i]; - data = (val << 16 | val << 8 | val); /* R, B, and G are same */ - outpdw(base + off, data); - off += 4; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -uint32 igc_video_lut[] = { /* non linear */ - 0x0, 0x1, 0x2, 0x4, 0x5, 0x6, 0x7, 0x9, - 0xA, 0xB, 0xC, 0xE, 0xF, 0x10, 0x12, 0x14, - 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F, 0x21, 0x23, - 0x25, 0x28, 0x2A, 0x2D, 0x30, 0x32, 0x35, 0x38, - 0x3B, 0x3E, 0x42, 0x45, 0x48, 0x4C, 0x4F, 0x53, - 0x57, 0x5B, 0x5F, 0x63, 0x67, 0x6B, 0x70, 0x74, - 0x79, 0x7E, 0x83, 0x88, 0x8D, 0x92, 0x97, 0x9C, - 0xA2, 0xA8, 0xAD, 0xB3, 0xB9, 0xBF, 0xC5, 0xCC, - 0xD2, 0xD8, 0xDF, 0xE6, 0xED, 0xF4, 0xFB, 0x102, - 0x109, 0x111, 0x118, 0x120, 0x128, 0x130, 0x138, 0x140, - 0x149, 0x151, 0x15A, 0x162, 0x16B, 0x174, 0x17D, 0x186, - 0x190, 0x199, 0x1A3, 0x1AC, 0x1B6, 0x1C0, 0x1CA, 0x1D5, - 0x1DF, 0x1EA, 0x1F4, 0x1FF, 0x20A, 0x215, 0x220, 0x22B, - 0x237, 0x242, 0x24E, 0x25A, 0x266, 0x272, 0x27F, 0x28B, - 0x298, 0x2A4, 0x2B1, 0x2BE, 0x2CB, 0x2D8, 0x2E6, 0x2F3, - 0x301, 0x30F, 0x31D, 0x32B, 0x339, 0x348, 0x356, 0x365, - 0x374, 0x383, 0x392, 0x3A1, 0x3B1, 0x3C0, 0x3D0, 0x3E0, - 0x3F0, 0x400, 0x411, 0x421, 0x432, 0x443, 0x454, 0x465, - 0x476, 0x487, 0x499, 0x4AB, 0x4BD, 0x4CF, 0x4E1, 0x4F3, - 0x506, 0x518, 0x52B, 0x53E, 0x551, 0x565, 0x578, 0x58C, - 0x5A0, 0x5B3, 0x5C8, 0x5DC, 0x5F0, 0x605, 0x61A, 0x62E, - 0x643, 0x659, 0x66E, 0x684, 0x699, 0x6AF, 0x6C5, 0x6DB, - 0x6F2, 0x708, 0x71F, 0x736, 0x74D, 0x764, 0x77C, 0x793, - 0x7AB, 0x7C3, 0x7DB, 0x7F3, 0x80B, 0x824, 0x83D, 0x855, - 0x86F, 0x888, 0x8A1, 0x8BB, 0x8D4, 0x8EE, 0x908, 0x923, - 0x93D, 0x958, 0x973, 0x98E, 0x9A9, 0x9C4, 0x9DF, 0x9FB, - 0xA17, 0xA33, 0xA4F, 0xA6C, 0xA88, 0xAA5, 0xAC2, 0xADF, - 0xAFC, 0xB19, 0xB37, 0xB55, 0xB73, 0xB91, 0xBAF, 0xBCE, - 0xBEC, 0xC0B, 0xC2A, 0xC4A, 0xC69, 0xC89, 0xCA8, 0xCC8, - 0xCE8, 0xD09, 0xD29, 0xD4A, 0xD6B, 0xD8C, 0xDAD, 0xDCF, - 0xDF0, 0xE12, 0xE34, 0xE56, 0xE79, 0xE9B, 0xEBE, 0xEE1, - 0xF04, 0xF27, 0xF4B, 0xF6E, 0xF92, 0xFB6, 0xFDB, 0xFFF, -}; - -void mdp4_vg_igc_lut_setup(int vp_num) -{ - unsigned char *base; - int i, voff, off; - uint32 data, val; - - voff = MDP4_VIDEO_OFF * vp_num; - base = MDP_BASE + MDP4_VIDEO_BASE + voff + 0x5000; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - off = 0; - for (i = 0; i < 256; i++) { - val = igc_video_lut[i]; - data = (val << 16 | val); /* color 0 and 1 */ - outpdw(base + off, data); - outpdw(base + off + 0x800, val); /* color 2 */ - off += 4; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -uint32 igc_rgb_lut[] = { /* linear */ - 0x0, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x80, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, - 0x101, 0x111, 0x121, 0x131, 0x141, 0x151, 0x161, 0x171, - 0x181, 0x191, 0x1A2, 0x1B2, 0x1C2, 0x1D2, 0x1E2, 0x1F2, - 0x202, 0x212, 0x222, 0x232, 0x242, 0x252, 0x262, 0x272, - 0x282, 0x292, 0x2A2, 0x2B3, 0x2C3, 0x2D3, 0x2E3, 0x2F3, - 0x303, 0x313, 0x323, 0x333, 0x343, 0x353, 0x363, 0x373, - 0x383, 0x393, 0x3A3, 0x3B3, 0x3C4, 0x3D4, 0x3E4, 0x3F4, - 0x404, 0x414, 0x424, 0x434, 0x444, 0x454, 0x464, 0x474, - 0x484, 0x494, 0x4A4, 0x4B4, 0x4C4, 0x4D5, 0x4E5, 0x4F5, - 0x505, 0x515, 0x525, 0x535, 0x545, 0x555, 0x565, 0x575, - 0x585, 0x595, 0x5A5, 0x5B5, 0x5C5, 0x5D5, 0x5E6, 0x5F6, - 0x606, 0x616, 0x626, 0x636, 0x646, 0x656, 0x666, 0x676, - 0x686, 0x696, 0x6A6, 0x6B6, 0x6C6, 0x6D6, 0x6E6, 0x6F7, - 0x707, 0x717, 0x727, 0x737, 0x747, 0x757, 0x767, 0x777, - 0x787, 0x797, 0x7A7, 0x7B7, 0x7C7, 0x7D7, 0x7E7, 0x7F7, - 0x808, 0x818, 0x828, 0x838, 0x848, 0x858, 0x868, 0x878, - 0x888, 0x898, 0x8A8, 0x8B8, 0x8C8, 0x8D8, 0x8E8, 0x8F8, - 0x908, 0x919, 0x929, 0x939, 0x949, 0x959, 0x969, 0x979, - 0x989, 0x999, 0x9A9, 0x9B9, 0x9C9, 0x9D9, 0x9E9, 0x9F9, - 0xA09, 0xA19, 0xA2A, 0xA3A, 0xA4A, 0xA5A, 0xA6A, 0xA7A, - 0xA8A, 0xA9A, 0xAAA, 0xABA, 0xACA, 0xADA, 0xAEA, 0xAFA, - 0xB0A, 0xB1A, 0xB2A, 0xB3B, 0xB4B, 0xB5B, 0xB6B, 0xB7B, - 0xB8B, 0xB9B, 0xBAB, 0xBBB, 0xBCB, 0xBDB, 0xBEB, 0xBFB, - 0xC0B, 0xC1B, 0xC2B, 0xC3B, 0xC4C, 0xC5C, 0xC6C, 0xC7C, - 0xC8C, 0xC9C, 0xCAC, 0xCBC, 0xCCC, 0xCDC, 0xCEC, 0xCFC, - 0xD0C, 0xD1C, 0xD2C, 0xD3C, 0xD4C, 0xD5D, 0xD6D, 0xD7D, - 0xD8D, 0xD9D, 0xDAD, 0xDBD, 0xDCD, 0xDDD, 0xDED, 0xDFD, - 0xE0D, 0xE1D, 0xE2D, 0xE3D, 0xE4D, 0xE5D, 0xE6E, 0xE7E, - 0xE8E, 0xE9E, 0xEAE, 0xEBE, 0xECE, 0xEDE, 0xEEE, 0xEFE, - 0xF0E, 0xF1E, 0xF2E, 0xF3E, 0xF4E, 0xF5E, 0xF6E, 0xF7F, - 0xF8F, 0xF9F, 0xFAF, 0xFBF, 0xFCF, 0xFDF, 0xFEF, 0xFFF, -}; - -void mdp4_rgb_igc_lut_setup(int num) -{ - unsigned char *base; - int i, voff, off; - uint32 data, val; - - voff = MDP4_RGB_OFF * num; - base = MDP_BASE + MDP4_RGB_BASE + voff + 0x5000; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - off = 0; - for (i = 0; i < 256; i++) { - val = igc_rgb_lut[i]; - data = (val << 16 | val); /* color 0 and 1 */ - outpdw(base + off, data); - outpdw(base + off + 0x800, val); /* color 2 */ - off += 4; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -uint32 mdp4_rgb_igc_lut_cvt(uint32 ndx) -{ - return igc_rgb_lut[ndx & 0x0ff]; -} - -uint32_t mdp4_ss_table_value(int8_t value, int8_t index) -{ - uint32_t out = 0x0; - int8_t level = -1; - uint32_t mask = 0xffffffff; - - if (value < 0) { - if (value == -128) - value = 127; - else - value = -value; - out = 0x11111111; - } else { - out = 0x88888888; - mask = 0x0fffffff; - } - - if (value == 0) - level = 0; - else { - while (value > 0 && level < 7) { - level++; - value -= 16; - } - } - - if (level == 0) { - if (index == 0) - out = 0x0; - else - out = 0x20000000; - } else { - out += (0x11111111 * level); - if (index == 1) - out &= mask; - } - - return out; -} - -static uint32_t mdp4_csc_block2base(uint32_t block) -{ - uint32_t base = 0x0; - switch (block) { - case MDP_BLOCK_OVERLAY_1: - base = 0x1A000; - break; - case MDP_BLOCK_OVERLAY_2: - base = (mdp_rev >= MDP_REV_43) ? 0x8A000 : 0x0; - break; - case MDP_BLOCK_VG_1: - base = 0x24000; - break; - case MDP_BLOCK_VG_2: - base = 0x34000; - break; - case MDP_BLOCK_DMA_P: - base = 0x93000; - break; - case MDP_BLOCK_DMA_S: - base = (mdp_rev >= MDP_REV_42) ? 0xA3000 : 0x0; - default: - break; - } - return base; -} - -int mdp4_csc_enable(struct mdp_csc_cfg_data *config) -{ - uint32_t output, base, temp, mask; - - switch (config->block) { - case MDP_BLOCK_DMA_P: - base = 0x90070; - output = (config->csc_data.flags << 3) & (0x08); - temp = (config->csc_data.flags << 10) & (0x1800); - output |= temp; - mask = 0x08 | 0x1800; - break; - case MDP_BLOCK_DMA_S: - base = 0xA0028; - output = (config->csc_data.flags << 3) & (0x08); - temp = (config->csc_data.flags << 10) & (0x1800); - output |= temp; - mask = 0x08 | 0x1800; - break; - case MDP_BLOCK_VG_1: - base = 0x20058; - output = (config->csc_data.flags << 11) & (0x800); - temp = (config->csc_data.flags << 8) & (0x600); - output |= temp; - mask = 0x800 | 0x600; - break; - case MDP_BLOCK_VG_2: - base = 0x30058; - output = (config->csc_data.flags << 11) & (0x800); - temp = (config->csc_data.flags << 8) & (0x600); - output |= temp; - mask = 0x800 | 0x600; - break; - case MDP_BLOCK_OVERLAY_1: - base = 0x18200; - output = config->csc_data.flags; - mask = 0x07; - break; - case MDP_BLOCK_OVERLAY_2: - base = 0x88200; - output = config->csc_data.flags; - mask = 0x07; - break; - default: - pr_err("%s - CSC block does not exist on MDP_BLOCK = %d\n", - __func__, config->block); - return -EINVAL; - } - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - temp = inpdw(MDP_BASE + base) & ~mask; - output |= temp; - outpdw(MDP_BASE + base, output); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - return 0; -} - -#define CSC_MV_OFF 0x400 -#define CSC_BV_OFF 0x500 -#define CSC_LV_OFF 0x600 -#define CSC_POST_OFF 0x80 - -void mdp4_csc_write(struct mdp_csc_cfg *data, uint32_t base) -{ - int i; - uint32_t *off; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - off = (uint32_t *) ((uint32_t) base + CSC_MV_OFF); - for (i = 0; i < 9; i++) { - outpdw(off, data->csc_mv[i]); - off++; - } - - off = (uint32_t *) ((uint32_t) base + CSC_BV_OFF); - for (i = 0; i < 3; i++) { - outpdw(off, data->csc_pre_bv[i]); - outpdw((uint32_t *)((uint32_t)off + CSC_POST_OFF), - data->csc_post_bv[i]); - off++; - } - - off = (uint32_t *) ((uint32_t) base + CSC_LV_OFF); - for (i = 0; i < 6; i++) { - outpdw(off, data->csc_pre_lv[i]); - outpdw((uint32_t *)((uint32_t)off + CSC_POST_OFF), - data->csc_post_lv[i]); - off++; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -int mdp4_csc_config(struct mdp_csc_cfg_data *config) -{ - int ret = 0; - uint32_t base; - - base = mdp4_csc_block2base(config->block); - if (!base) { - pr_warn("%s: Block type %d isn't supported by CSC.\n", - __func__, config->block); - return -EINVAL; - } - - mdp4_csc_write(&config->csc_data, (uint32_t) (MDP_BASE + base)); - - ret = mdp4_csc_enable(config); - - return ret; -} - -void mdp4_init_writeback_buf(struct msm_fb_data_type *mfd, u32 mix_num) -{ - struct mdp_buf_type *buf; - - if (mix_num == MDP4_MIXER0) - buf = mfd->ov0_wb_buf; - else - buf = mfd->ov1_wb_buf; - - buf->ihdl = NULL; - buf->write_addr = 0; - buf->read_addr = 0; -} - -u32 mdp4_allocate_writeback_buf(struct msm_fb_data_type *mfd, u32 mix_num) -{ - struct mdp_buf_type *buf; - ion_phys_addr_t addr, read_addr = 0; - size_t buffer_size; - unsigned long len; - - if (mix_num == MDP4_MIXER0) - buf = mfd->ov0_wb_buf; - else - buf = mfd->ov1_wb_buf; - - if (buf->write_addr || !IS_ERR_OR_NULL(buf->ihdl)) - return 0; - - if (!buf->size) { - pr_err("%s:%d In valid size\n", __func__, __LINE__); - return -EINVAL; - } - - buffer_size = roundup(mfd->panel_info.xres * \ - mfd->panel_info.yres * 3 * 2, SZ_4K); - - if (!IS_ERR_OR_NULL(mfd->iclient)) { - pr_info("%s:%d ion based allocation mfd->mem_hid 0x%x\n", - __func__, __LINE__, mfd->mem_hid); - buf->ihdl = ion_alloc(mfd->iclient, buffer_size, SZ_4K, - mfd->mem_hid, 0); - if (!IS_ERR_OR_NULL(buf->ihdl)) { - if (mdp_iommu_split_domain) { - if (ion_map_iommu(mfd->iclient, buf->ihdl, - DISPLAY_READ_DOMAIN, GEN_POOL, SZ_4K, - 0, &read_addr, &len, 0, 0)) { - pr_err("ion_map_iommu() read failed\n"); - return -ENOMEM; - } - if (mfd->mem_hid & ION_FLAG_SECURE) { - if (ion_phys(mfd->iclient, buf->ihdl, - &addr, (size_t *)&len)) { - pr_err("%s:%d: ion_phys map failed\n", - __func__, __LINE__); - return -ENOMEM; - } - } else { - if (ion_map_iommu(mfd->iclient, - buf->ihdl, DISPLAY_WRITE_DOMAIN, - GEN_POOL, SZ_4K, 0, &addr, &len, - 0, 0)) { - pr_err("ion_map_iommu() failed\n"); - return -ENOMEM; - } - } - } else { - if (ion_map_iommu(mfd->iclient, buf->ihdl, - DISPLAY_READ_DOMAIN, GEN_POOL, SZ_4K, - 0, &addr, &len, 0, 0)) { - pr_err("ion_map_iommu() write failed\n"); - return -ENOMEM; - } - } - } else { - pr_err("%s:%d: ion_alloc failed\n", __func__, - __LINE__); - return -ENOMEM; - } - } else { - addr = allocate_contiguous_memory_nomap(buffer_size, - mfd->mem_hid, 4); - } - if (addr) { - pr_info("allocating %d bytes at %x for mdp writeback\n", - buffer_size, (u32) addr); - buf->write_addr = addr; - - if (read_addr) - buf->read_addr = read_addr; - else - buf->read_addr = buf->write_addr; - - return 0; - } else { - pr_err("%s cannot allocate memory for mdp writeback!\n", - __func__); - return -ENOMEM; - } -} - -void mdp4_free_writeback_buf(struct msm_fb_data_type *mfd, u32 mix_num) -{ - struct mdp_buf_type *buf; - - if (mix_num == MDP4_MIXER0) - buf = mfd->ov0_wb_buf; - else - buf = mfd->ov1_wb_buf; - - if (!IS_ERR_OR_NULL(mfd->iclient)) { - if (!IS_ERR_OR_NULL(buf->ihdl)) { - if (mdp_iommu_split_domain) { - if (!(mfd->mem_hid & ION_FLAG_SECURE)) - ion_unmap_iommu(mfd->iclient, buf->ihdl, - DISPLAY_WRITE_DOMAIN, GEN_POOL); - ion_unmap_iommu(mfd->iclient, buf->ihdl, - DISPLAY_READ_DOMAIN, GEN_POOL); - } else { - ion_unmap_iommu(mfd->iclient, buf->ihdl, - DISPLAY_READ_DOMAIN, GEN_POOL); - } - ion_free(mfd->iclient, buf->ihdl); - buf->ihdl = NULL; - pr_info("%s:%d free ION writeback imem", - __func__, __LINE__); - } - } else { - if (buf->write_addr) { - free_contiguous_memory_by_paddr(buf->write_addr); - pr_debug("%s:%d free writeback pmem\n", __func__, - __LINE__); - } - } - buf->write_addr = 0; - buf->read_addr = 0; -} - -static int mdp4_update_pcc_regs(uint32_t offset, - struct mdp_pcc_cfg_data *cfg_ptr) -{ - int ret = -1; - - if (offset && cfg_ptr) { - - outpdw(offset, cfg_ptr->r.c); - outpdw(offset + 0x30, cfg_ptr->g.c); - outpdw(offset + 0x60, cfg_ptr->b.c); - offset += 4; - - outpdw(offset, cfg_ptr->r.r); - outpdw(offset + 0x30, cfg_ptr->g.r); - outpdw(offset + 0x60, cfg_ptr->b.r); - offset += 4; - - outpdw(offset, cfg_ptr->r.g); - outpdw(offset + 0x30, cfg_ptr->g.g); - outpdw(offset + 0x60, cfg_ptr->b.g); - offset += 4; - - outpdw(offset, cfg_ptr->r.b); - outpdw(offset + 0x30, cfg_ptr->g.b); - outpdw(offset + 0x60, cfg_ptr->b.b); - offset += 4; - - outpdw(offset, cfg_ptr->r.rr); - outpdw(offset + 0x30, cfg_ptr->g.rr); - outpdw(offset + 0x60, cfg_ptr->b.rr); - offset += 4; - - outpdw(offset, cfg_ptr->r.gg); - outpdw(offset + 0x30, cfg_ptr->g.gg); - outpdw(offset + 0x60, cfg_ptr->b.gg); - offset += 4; - - outpdw(offset, cfg_ptr->r.bb); - outpdw(offset + 0x30, cfg_ptr->g.bb); - outpdw(offset + 0x60, cfg_ptr->b.bb); - offset += 4; - - outpdw(offset, cfg_ptr->r.rg); - outpdw(offset + 0x30, cfg_ptr->g.rg); - outpdw(offset + 0x60, cfg_ptr->b.rg); - offset += 4; - - outpdw(offset, cfg_ptr->r.gb); - outpdw(offset + 0x30, cfg_ptr->g.gb); - outpdw(offset + 0x60, cfg_ptr->b.gb); - offset += 4; - - outpdw(offset, cfg_ptr->r.rb); - outpdw(offset + 0x30, cfg_ptr->g.rb); - outpdw(offset + 0x60, cfg_ptr->b.rb); - offset += 4; - - outpdw(offset, cfg_ptr->r.rgb_0); - outpdw(offset + 0x30, cfg_ptr->g.rgb_0); - outpdw(offset + 0x60, cfg_ptr->b.rgb_0); - offset += 4; - - outpdw(offset, cfg_ptr->r.rgb_1); - outpdw(offset + 0x30, cfg_ptr->g.rgb_1); - outpdw(offset + 0x60, cfg_ptr->b.rgb_1); - - ret = 0; - } - - return ret; -} - -static int mdp4_read_pcc_regs(uint32_t offset, - struct mdp_pcc_cfg_data *cfg_ptr) -{ - int ret = -1; - - if (offset && cfg_ptr) { - cfg_ptr->r.c = inpdw(offset); - cfg_ptr->g.c = inpdw(offset + 0x30); - cfg_ptr->b.c = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.r = inpdw(offset); - cfg_ptr->g.r = inpdw(offset + 0x30); - cfg_ptr->b.r = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.g = inpdw(offset); - cfg_ptr->g.g = inpdw(offset + 0x30); - cfg_ptr->b.g = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.b = inpdw(offset); - cfg_ptr->g.b = inpdw(offset + 0x30); - cfg_ptr->b.b = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.rr = inpdw(offset); - cfg_ptr->g.rr = inpdw(offset + 0x30); - cfg_ptr->b.rr = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.gg = inpdw(offset); - cfg_ptr->g.gg = inpdw(offset + 0x30); - cfg_ptr->b.gg = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.bb = inpdw(offset); - cfg_ptr->g.bb = inpdw(offset + 0x30); - cfg_ptr->b.bb = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.rg = inpdw(offset); - cfg_ptr->g.rg = inpdw(offset + 0x30); - cfg_ptr->b.rg = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.gb = inpdw(offset); - cfg_ptr->g.gb = inpdw(offset + 0x30); - cfg_ptr->b.gb = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.rb = inpdw(offset); - cfg_ptr->g.rb = inpdw(offset + 0x30); - cfg_ptr->b.rb = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.rgb_0 = inpdw(offset); - cfg_ptr->g.rgb_0 = inpdw(offset + 0x30); - cfg_ptr->b.rgb_0 = inpdw(offset + 0x60); - offset += 4; - - cfg_ptr->r.rgb_1 = inpdw(offset); - cfg_ptr->g.rgb_1 = inpdw(offset + 0x30); - cfg_ptr->b.rgb_1 = inpdw(offset + 0x60); - - ret = 0; - } - - return ret; -} - - -#define MDP_PCC_OFFSET 0xA000 -#define MDP_DMA_GC_OFFSET 0x8800 -#define MDP_LM_GC_OFFSET 0x4800 - -#define MDP_DMA_P_OP_MODE_OFFSET 0x70 -#define MDP_DMA_S_OP_MODE_OFFSET 0x28 -#define MDP_LM_OP_MODE_OFFSET 0x14 - -#define DMA_PCC_R2_OFFSET 0x100 - -#define MDP_GC_COLOR_OFFSET 0x100 -#define MDP_GC_PARMS_OFFSET 0x80 - -#define MDP_AR_GC_MAX_STAGES 16 - -static uint32_t mdp_pp_block2pcc(uint32_t block) -{ - uint32_t valid = 0; - - switch (block) { - case MDP_BLOCK_DMA_P: - case MDP_BLOCK_DMA_S: - valid = (mdp_rev >= MDP_REV_42) ? 1 : 0; - break; - - default: - break; - } - - return valid; -} - -int mdp4_pcc_cfg(struct mdp_pcc_cfg_data *cfg_ptr) -{ - int ret = -1; - uint32_t pcc_offset = 0, mdp_cfg_offset = 0; - uint32_t mdp_dma_op_mode = 0; - uint32_t blockbase; - - if (!mdp_pp_block2pcc(cfg_ptr->block)) - return ret; - - blockbase = mdp_block2base(cfg_ptr->block); - if (!blockbase) - return ret; - - blockbase += (uint32_t) MDP_BASE; - - switch (cfg_ptr->block) { - case MDP_BLOCK_DMA_P: - case MDP_BLOCK_DMA_S: - pcc_offset = blockbase + MDP_PCC_OFFSET; - mdp_cfg_offset = blockbase; - mdp_dma_op_mode = blockbase + - (MDP_BLOCK_DMA_P == cfg_ptr->block ? - MDP_DMA_P_OP_MODE_OFFSET - : MDP_DMA_S_OP_MODE_OFFSET); - break; - - default: - break; - } - - if (0x8 & cfg_ptr->ops) - pcc_offset += DMA_PCC_R2_OFFSET; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - switch ((0x6 & cfg_ptr->ops)>>1) { - case 0x1: - ret = mdp4_read_pcc_regs(pcc_offset, cfg_ptr); - break; - - case 0x2: - ret = mdp4_update_pcc_regs(pcc_offset, cfg_ptr); - break; - - default: - break; - } - - if (0x8 & cfg_ptr->ops) - outpdw(mdp_dma_op_mode, - ((inpdw(mdp_dma_op_mode) & ~(0x1<<10)) | - ((0x8 & cfg_ptr->ops)<<10))); - - outpdw(mdp_cfg_offset, - ((inpdw(mdp_cfg_offset) & ~(0x1<<29)) | - ((cfg_ptr->ops & 0x1)<<29))); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return ret; -} - -static uint32_t mdp_pp_block2argc(uint32_t block) -{ - uint32_t valid = 0; - - switch (block) { - case MDP_BLOCK_DMA_P: - case MDP_BLOCK_DMA_S: - case MDP_BLOCK_OVERLAY_0: - case MDP_BLOCK_OVERLAY_1: - valid = (mdp_rev >= MDP_REV_42) ? 1 : 0; - break; - - case MDP_BLOCK_OVERLAY_2: - valid = (mdp_rev >= MDP_REV_43) ? 1 : 0; - break; - - default: - break; - } - - return valid; -} - -static int update_ar_gc_lut(uint32_t *offset, struct mdp_pgc_lut_data *lut_data) -{ - int count = 0; - - uint32_t *c0_offset = offset; - uint32_t *c0_params_offset = (uint32_t *)((uint32_t)c0_offset - + MDP_GC_PARMS_OFFSET); - - uint32_t *c1_offset = (uint32_t *)((uint32_t)offset - + MDP_GC_COLOR_OFFSET); - - uint32_t *c1_params_offset = (uint32_t *)((uint32_t)c1_offset - + MDP_GC_PARMS_OFFSET); - - uint32_t *c2_offset = (uint32_t *)((uint32_t)offset - + 2*MDP_GC_COLOR_OFFSET); - - uint32_t *c2_params_offset = (uint32_t *)((uint32_t)c2_offset - +MDP_GC_PARMS_OFFSET); - - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - for (count = 0; count < MDP_AR_GC_MAX_STAGES; count++) { - if (count < lut_data->num_r_stages) { - outpdw(c0_offset+count, - ((0xfff & lut_data->r_data[count].x_start) - | 0x10000)); - - outpdw(c0_params_offset+count, - ((0x7fff & lut_data->r_data[count].slope) - | ((0xffff - & lut_data->r_data[count].offset) - << 16))); - } else - outpdw(c0_offset+count, 0); - - if (count < lut_data->num_b_stages) { - outpdw(c1_offset+count, - ((0xfff & lut_data->b_data[count].x_start) - | 0x10000)); - - outpdw(c1_params_offset+count, - ((0x7fff & lut_data->b_data[count].slope) - | ((0xffff - & lut_data->b_data[count].offset) - << 16))); - } else - outpdw(c1_offset+count, 0); - - if (count < lut_data->num_g_stages) { - outpdw(c2_offset+count, - ((0xfff & lut_data->g_data[count].x_start) - | 0x10000)); - - outpdw(c2_params_offset+count, - ((0x7fff & lut_data->g_data[count].slope) - | ((0xffff - & lut_data->g_data[count].offset) - << 16))); - } else - outpdw(c2_offset+count, 0); - } - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return 0; -} - -static int mdp4_argc_process_write_req(uint32_t *offset, - struct mdp_pgc_lut_data *pgc_ptr) -{ - int ret = -1; - struct mdp_ar_gc_lut_data r[MDP_AR_GC_MAX_STAGES]; - struct mdp_ar_gc_lut_data g[MDP_AR_GC_MAX_STAGES]; - struct mdp_ar_gc_lut_data b[MDP_AR_GC_MAX_STAGES]; - - ret = copy_from_user(&r[0], pgc_ptr->r_data, - pgc_ptr->num_r_stages * sizeof(struct mdp_ar_gc_lut_data)); - - if (!ret) { - ret = copy_from_user(&g[0], - pgc_ptr->g_data, - pgc_ptr->num_g_stages - * sizeof(struct mdp_ar_gc_lut_data)); - if (!ret) - ret = copy_from_user(&b[0], - pgc_ptr->b_data, - pgc_ptr->num_b_stages - * sizeof(struct mdp_ar_gc_lut_data)); - } - - if (ret) - return ret; - - pgc_ptr->r_data = &r[0]; - pgc_ptr->g_data = &g[0]; - pgc_ptr->b_data = &b[0]; - - ret = update_ar_gc_lut(offset, pgc_ptr); - return ret; -} - -int mdp4_argc_cfg(struct mdp_pgc_lut_data *pgc_ptr) -{ - int ret = -1; - uint32_t *offset = 0, *pgc_enable_offset = 0, lshift_bits = 0; - uint32_t blockbase; - - if (!mdp_pp_block2argc(pgc_ptr->block)) - return ret; - - blockbase = mdp_block2base(pgc_ptr->block); - if (!blockbase) - return ret; - - blockbase += (uint32_t) MDP_BASE; - ret = 0; - - switch (pgc_ptr->block) { - case MDP_BLOCK_DMA_P: - case MDP_BLOCK_DMA_S: - offset = (uint32_t *)(blockbase + MDP_DMA_GC_OFFSET); - pgc_enable_offset = (uint32_t *) blockbase; - lshift_bits = 28; - break; - - case MDP_BLOCK_OVERLAY_0: - case MDP_BLOCK_OVERLAY_1: - case MDP_BLOCK_OVERLAY_2: - offset = (uint32_t *)(blockbase + MDP_LM_GC_OFFSET); - pgc_enable_offset = (uint32_t *)(blockbase - + MDP_LM_OP_MODE_OFFSET); - lshift_bits = 2; - break; - - default: - ret = -1; - break; - } - - if (!ret) { - - switch ((0x6 & pgc_ptr->flags)>>1) { - case 0x1: - ret = -ENOTTY; - break; - - case 0x2: - ret = mdp4_argc_process_write_req(offset, pgc_ptr); - break; - - default: - break; - } - - if (!ret) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - outpdw(pgc_enable_offset, (inpdw(pgc_enable_offset) & - ~(0x1<flags) << lshift_bits)); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, - FALSE); - } - } - - return ret; -} - -static uint32_t mdp4_pp_block2igc(uint32_t block) -{ - uint32_t valid = 0; - switch (block) { - case MDP_BLOCK_VG_1: - valid = 0x1; - break; - case MDP_BLOCK_VG_2: - valid = 0x1; - break; - case MDP_BLOCK_RGB_1: - valid = 0x1; - break; - case MDP_BLOCK_RGB_2: - valid = 0x1; - break; - case MDP_BLOCK_DMA_P: - valid = (mdp_rev >= MDP_REV_40) ? 1 : 0; - break; - case MDP_BLOCK_DMA_S: - valid = (mdp_rev >= MDP_REV_40) ? 1 : 0; - break; - default: - break; - } - return valid; -} - -static int mdp4_igc_lut_write(struct mdp_igc_lut_data *cfg, uint32_t en_off, - uint32_t lut_off) -{ - int i; - uint32_t base, *off_low, *off_high; - uint32_t low[cfg->len]; - uint32_t high[cfg->len]; - - base = mdp_block2base(cfg->block); - - if (cfg->len != 256) - return -EINVAL; - - off_low = (uint32_t *)(MDP_BASE + base + lut_off); - off_high = (uint32_t *)(MDP_BASE + base + lut_off + 0x800); - if (copy_from_user(&low, cfg->c0_c1_data, cfg->len * sizeof(uint32_t))) - return -EFAULT; - if (copy_from_user(&high, cfg->c2_data, cfg->len * sizeof(uint32_t))) - return -EFAULT; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - for (i = 0; i < cfg->len; i++) { - MDP_OUTP(off_low++, low[i]); - /*low address write should occur before high address write*/ - wmb(); - MDP_OUTP(off_high++, high[i]); - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - return 0; -} - -static int mdp4_igc_lut_ctrl(struct mdp_igc_lut_data *cfg) -{ - uint32_t mask, out; - uint32_t base = mdp_block2base(cfg->block); - int8_t shift = 0; - - switch (cfg->block) { - case MDP_BLOCK_DMA_P: - case MDP_BLOCK_DMA_S: - base = base; - shift = 30; - break; - case MDP_BLOCK_VG_1: - case MDP_BLOCK_VG_2: - case MDP_BLOCK_RGB_1: - case MDP_BLOCK_RGB_2: - base += 0x58; - shift = 16; - break; - default: - return -EINVAL; - - } - out = 1<ops & 0x1)<block) { - case MDP_BLOCK_DMA_P: - case MDP_BLOCK_DMA_S: - ret = mdp4_igc_lut_write(cfg, 0x00, 0x9000); - break; - case MDP_BLOCK_VG_1: - case MDP_BLOCK_VG_2: - case MDP_BLOCK_RGB_1: - case MDP_BLOCK_RGB_2: - ret = mdp4_igc_lut_write(cfg, 0x58, 0x5000); - break; - default: - ret = -EINVAL; - } - - return ret; -} - -int mdp4_igc_lut_config(struct mdp_igc_lut_data *cfg) -{ - int ret = 0; - - if (!mdp4_pp_block2igc(cfg->block)) { - ret = -ENOTTY; - goto error; - } - - switch ((cfg->ops & 0x6) >> 1) { - case 0x1: - pr_info("%s: IGC LUT read not supported\n", __func__); - break; - case 0x2: - ret = mdp4_igc_lut_write_cfg(cfg); - if (ret) - goto error; - break; - default: - break; - } - - ret = mdp4_igc_lut_ctrl(cfg); - -error: - return ret; -} - -#define QSEED_TABLE_1_COUNT 2 -#define QSEED_TABLE_2_COUNT 1024 - -static uint32_t mdp4_pp_block2qseed(uint32_t block) -{ - uint32_t valid = 0; - switch (block) { - case MDP_BLOCK_VG_1: - case MDP_BLOCK_VG_2: - valid = 0x1; - break; - default: - break; - } - return valid; -} - -int mdp4_qseed_access_cfg(struct mdp_qseed_cfg *config, uint32_t base) -{ - int i, ret = 0; - uint32_t *values; - - if ((config->table_num != 1) && (config->table_num != 2)) { - ret = -ENOTTY; - goto error; - } - - if (((config->table_num == 1) && (config->len != QSEED_TABLE_1_COUNT)) - || ((config->table_num == 2) && - (config->len != QSEED_TABLE_2_COUNT))) { - ret = -EINVAL; - goto error; - } - - values = kmalloc(config->len * sizeof(uint32_t), GFP_KERNEL); - if (!values) { - ret = -ENOMEM; - goto error; - } - - base += (config->table_num == 1) ? MDP4_QSEED_TABLE1_OFF : - MDP4_QSEED_TABLE2_OFF; - - if (config->ops & MDP_PP_OPS_WRITE) { - ret = copy_from_user(values, config->data, - sizeof(uint32_t) * config->len); - if (ret) { - pr_warn("%s: Error copying from user, %d", __func__, - ret); - ret = -EINVAL; - goto err_mem; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - for (i = 0; i < config->len; i++) { - if (!(base & 0x3FF)) - wmb(); - MDP_OUTP(base , values[i]); - base += sizeof(uint32_t); - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - } else if (config->ops & MDP_PP_OPS_READ) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - for (i = 0; i < config->len; i++) { - values[i] = inpdw(base); - if (!(base & 0x3FF)) - rmb(); - base += sizeof(uint32_t); - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - ret = copy_to_user(config->data, values, - sizeof(uint32_t) * config->len); - if (ret) { - pr_warn("%s: Error copying to user, %d", __func__, ret); - ret = -EINVAL; - goto err_mem; - } - } - -err_mem: - kfree(values); -error: - return ret; -} - -int mdp4_qseed_cfg(struct mdp_qseed_cfg_data *config) -{ - int ret = 0; - struct mdp_qseed_cfg *cfg = &config->qseed_data; - uint32_t base; - - if (!mdp4_pp_block2qseed(config->block)) { - ret = -ENOTTY; - goto error; - } - - if ((cfg->ops & MDP_PP_OPS_READ) && (cfg->ops & MDP_PP_OPS_WRITE)) { - ret = -EPERM; - pr_warn("%s: Cannot read and write on the same request\n", - __func__); - goto error; - } - base = (uint32_t) (MDP_BASE + mdp_block2base(config->block)); - ret = mdp4_qseed_access_cfg(cfg, base); - -error: - return ret; -} - -static int is_valid_calib_addr(void *addr) -{ - int ret = 0; - unsigned int ptr; - - ptr = (unsigned int) addr; - - if (mdp_rev >= MDP_REV_30 && mdp_rev < MDP_REV_40) { - /* if request is outside the MDP reg-map or is not aligned 4 */ - if (ptr == 0x0 || ptr > 0xF0600 || ptr % 0x4) - goto end; - - if (ptr >= 0x90000 && ptr < 0x94000) { - if (ptr == 0x90000 || ptr == 0x90070) - ret = 1; - else if (ptr >= 0x93400 && ptr <= 0x93420) - ret = 1; - else if (ptr >= 0x93500 && ptr <= 0x93508) - ret = 1; - else if (ptr >= 0x93580 && ptr <= 0x93588) - ret = 1; - else if (ptr >= 0x93600 && ptr <= 0x93614) - ret = 1; - else if (ptr >= 0x93680 && ptr <= 0x93694) - ret = 1; - else if (ptr >= 0x93800 && ptr <= 0x93BFC) - ret = 1; - } - } else if (mdp_rev >= MDP_REV_40 && mdp_rev <= MDP_REV_44) { - /* if request is outside the MDP reg-map or is not aligned 4 */ - if (ptr > 0xF0600 || ptr % 0x4) - goto end; - - if (ptr < 0x90000) { - if (ptr == 0x0 || ptr == 0x4 || ptr == 0x28200 || - ptr == 0x28204) - ret = 1; - } else if (ptr < 0x95000) { - if (ptr == 0x90000 || ptr == 0x90070) - ret = 1; - else if (ptr >= 0x93400 && ptr <= 0x93420) - ret = 1; - else if (ptr >= 0x93500 && ptr <= 0x93508) - ret = 1; - else if (ptr >= 0x93580 && ptr <= 0x93588) - ret = 1; - else if (ptr >= 0x93600 && ptr <= 0x93614) - ret = 1; - else if (ptr >= 0x93680 && ptr <= 0x93694) - ret = 1; - else if (ptr >= 0x94800 && ptr <= 0x94BFC) - ret = 1; - } else if (ptr < 0x9A000) { - if (ptr >= 0x98800 && ptr <= 0x9883C) - ret = 1; - else if (ptr >= 0x98880 && ptr <= 0x988AC) - ret = 1; - else if (ptr >= 0x98900 && ptr <= 0x9893C) - ret = 1; - else if (ptr >= 0x98980 && ptr <= 0x989BC) - ret = 1; - else if (ptr >= 0x98A00 && ptr <= 0x98A3C) - ret = 1; - else if (ptr >= 0x98A80 && ptr <= 0x98ABC) - ret = 1; - else if (ptr >= 0x99000 && ptr <= 0x993FC) - ret = 1; - else if (ptr >= 0x99800 && ptr <= 0x99BFC) - ret = 1; - } else if (ptr >= 0x9A000 && ptr <= 0x9a08c) { - ret = 1; - } - } -end: - return ret; -} - -int mdp4_calib_config(struct mdp_calib_config_data *cfg) -{ - int ret = -1; - void *ptr = (void *) cfg->addr; - - if (is_valid_calib_addr(ptr)) - ret = 0; - else - return ret; - - ptr = (void *)(((unsigned int) ptr) + MDP_BASE); - mdp_clk_ctrl(1); - if (cfg->ops & MDP_PP_OPS_READ) { - cfg->data = inpdw(ptr); - ret = 1; - } else if (cfg->ops & MDP_PP_OPS_WRITE) { - outpdw(ptr, cfg->data); - } - mdp_clk_ctrl(0); - return ret; -} - -u32 mdp4_get_mixer_num(u32 panel_type) -{ - u32 mixer_num; - if ((panel_type == TV_PANEL) || - (panel_type == DTV_PANEL)) - mixer_num = MDP4_MIXER1; - else if (panel_type == WRITEBACK_PANEL) { - mixer_num = MDP4_MIXER2; - } else { - mixer_num = MDP4_MIXER0; - } - return mixer_num; -} diff --git a/drivers/video/msm/mdp4_wfd_writeback.c b/drivers/video/msm/mdp4_wfd_writeback.c deleted file mode 100644 index ba6c78bbd94f3ebb0e832ba54fd15e16f579feac..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_wfd_writeback.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include - -#include "mdp4_wfd_writeback_util.h" -#include "msm_fb.h" - -static int writeback_on(struct platform_device *pdev) -{ - return 0; -} -static int writeback_off(struct platform_device *pdev) -{ - return 0; -} -static int writeback_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc = 0; - - WRITEBACK_MSG_ERR("Inside writeback_probe\n"); - mfd = platform_get_drvdata(pdev); - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - /* - * link to the latest pdev - */ - mfd->pdev = mdp_dev; - mfd->dest = DISPLAY_LCD; - - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - pr_err("writeback_probe: " - "platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; - pdata->on = writeback_on; - pdata->off = writeback_off; - pdata->next = pdev; - - /* - * get/set panel specific fb info - */ - mfd->panel_info = pdata->panel_info; - - mfd->fb_imgType = MDP_RGB_565; - - platform_set_drvdata(mdp_dev, mfd); - - mfd->writeback_sdev.name = "wfd"; - rc = switch_dev_register(&mfd->writeback_sdev); - if (rc) { - pr_err("Failed to setup switch dev for writeback panel"); - return rc; - } - - rc = platform_device_add(mdp_dev); - if (rc) { - WRITEBACK_MSG_ERR("failed to add device"); - platform_device_put(mdp_dev); - return rc; - } - return rc; -} - -static int writeback_remove(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - switch_dev_unregister(&mfd->writeback_sdev); - return 0; -} - -static struct platform_driver writeback_driver = { - .probe = writeback_probe, - .remove = writeback_remove, - .driver = { - .name = "writeback", - }, -}; - -static int __init writeback_driver_init(void) -{ - int rc = 0; - WRITEBACK_MSG_ERR("Inside writeback_driver_init\n"); - rc = platform_driver_register(&writeback_driver); - return rc; -} - -module_init(writeback_driver_init); diff --git a/drivers/video/msm/mdp4_wfd_writeback_panel.c b/drivers/video/msm/mdp4_wfd_writeback_panel.c deleted file mode 100644 index 454556fbba6b72d802d06c1c07bfa03642493a08..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_wfd_writeback_panel.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 2011, 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 -#include -#include -#include -#include -#include -#include - -#include "mdp4_wfd_writeback_util.h" -#include "msm_fb.h" - -static int writeback_panel_probe(struct platform_device *pdev) -{ - int rc = 0; - if (pdev->id == 0) - return 0; - - if (!msm_fb_add_device(pdev)) { - WRITEBACK_MSG_ERR("Failed to add fd device\n"); - rc = -ENOMEM; - } - return rc; -} -static struct msm_fb_panel_data writeback_msm_panel_data = { - .panel_info = { - .type = WRITEBACK_PANEL, - .xres = 1280, - .yres = 720, - .pdest = DISPLAY_3, - .wait_cycle = 0, - .bpp = 24, - .fb_num = 1, - .clk_rate = 74250000, - }, -}; - -static struct platform_device writeback_panel_device = { - .name = "writeback_panel", - .id = 1, - .dev.platform_data = &writeback_msm_panel_data, -}; -static struct platform_driver writeback_panel_driver = { - .probe = writeback_panel_probe, - .driver = { - .name = "writeback_panel" - } -}; - -static int __init writeback_panel_init(void) -{ - int rc = 0; - rc = platform_driver_register(&writeback_panel_driver); - if (rc) { - WRITEBACK_MSG_ERR("Failed to register platform driver\n"); - goto fail_driver_registration; - } - rc = platform_device_register(&writeback_panel_device); - if (rc) { - WRITEBACK_MSG_ERR("Failed to register " - "writeback_panel_device\n"); - goto fail_device_registration; - } - return rc; -fail_device_registration: - platform_driver_unregister(&writeback_panel_driver); -fail_driver_registration: - return rc; -} - -module_init(writeback_panel_init); diff --git a/drivers/video/msm/mdp4_wfd_writeback_util.h b/drivers/video/msm/mdp4_wfd_writeback_util.h deleted file mode 100644 index 582d198b2d5613b4244f835d004fa98b27e9248b..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp4_wfd_writeback_util.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2011, 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 _WRITEBACK_UTIL_H_ -#define _WRITEBACK_UTIL_H_ - -#define DEBUG - -#ifdef DEBUG - #define WRITEBACK_MSG_INFO(fmt...) pr_info(fmt) - #define WRITEBACK_MSG_WARN(fmt...) pr_warning(fmt) -#else - #define WRITEBACK_MSG_INFO(fmt...) - #define WRITEBACK_MSG_WARN(fmt...) -#endif - #define WRITEBACK_MSG_ERR(fmt...) pr_err(fmt) - #define WRITEBACK_MSG_CRIT(fmt...) pr_crit(fmt) -#endif diff --git a/drivers/video/msm/mdp_cursor.c b/drivers/video/msm/mdp_cursor.c deleted file mode 100644 index 153fcf26cfbced12bc4ebc72b559304f2a3788a9..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_cursor.c +++ /dev/null @@ -1,289 +0,0 @@ -/* Copyright (c) 2008-2009, 2013, 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include "mdp.h" -#include "msm_fb.h" - -static int cursor_enabled; - -#include "mdp4.h" - -#if defined(CONFIG_FB_MSM_OVERLAY) && defined(CONFIG_FB_MSM_MDP40) -static struct workqueue_struct *mdp_cursor_ctrl_wq; -static struct work_struct mdp_cursor_ctrl_worker; - -/* cursor configuration */ -static void *cursor_buf_phys; -static __u32 width, height, bg_color; -static int calpha_en, transp_en, alpha; -static int sync_disabled = -1; - -void mdp_cursor_ctrl_workqueue_handler(struct work_struct *work) -{ - unsigned long flag; - - /* disable vsync */ - spin_lock_irqsave(&mdp_spin_lock, flag); - if (hdmi_prim_display) - mdp_disable_irq(MDP_OVERLAY1_TERM); - else - mdp_disable_irq(MDP_OVERLAY0_TERM); - - spin_unlock_irqrestore(&mdp_spin_lock, flag); -} - -void mdp_hw_cursor_init(void) -{ - mdp_cursor_ctrl_wq = - create_singlethread_workqueue("mdp_cursor_ctrl_wq"); - INIT_WORK(&mdp_cursor_ctrl_worker, mdp_cursor_ctrl_workqueue_handler); -} - -void mdp_hw_cursor_done(void) -{ - /* Cursor configuration: - * - * This is done in DMA_P_DONE ISR because the following registers are - * not double buffered in hardware: - * - * MDP_DMA_P_CURSOR_SIZE, address = 0x90044 - * MDP_DMA_P_CURSOR_BLEND_CONFIG, address = 0x90060 - * MDP_DMA_P_CURSOR_BLEND_PARAM, address = 0x90064 - * MDP_DMA_P_CURSOR_BLEND_TRANS_LOW, address = 0x90068 - * MDP_DMA_P_CURSOR_BLEND_TRANS_HIG, address = 0x9006C - * - * Moving this code out of the ISR will cause the MDP to underrun! - */ - uint32_t base = 0; - - if (hdmi_prim_display) - base = ((uint32_t)(MDP_BASE + 0xB0000)); - else - base = ((uint32_t)(MDP_BASE + 0x90000)); - - - spin_lock(&mdp_spin_lock); - if (sync_disabled) { - spin_unlock(&mdp_spin_lock); - return; - } - - MDP_OUTP(base + 0x44, (height << 16) | width); - MDP_OUTP(base + 0x48, cursor_buf_phys); - - MDP_OUTP(base + 0x60, - (transp_en << 3) | (calpha_en << 1) | - (inp32(base + 0x60) & 0x1)); - - MDP_OUTP(base + 0x64, (alpha << 24)); - MDP_OUTP(base + 0x68, (0xffffff & bg_color)); - MDP_OUTP(base + 0x6C, (0xffffff & bg_color)); - - /* enable/disable the cursor as per the last request */ - if (cursor_enabled && !(inp32(base + 0x60) & (0x1))) - MDP_OUTP(base + 0x60, inp32(base + 0x60) | 0x1); - else if (!cursor_enabled && (inp32(base + 0x60) & (0x1))) - MDP_OUTP(base + 0x60, - inp32(base + 0x60) & (~0x1)); - - /* enqueue the task to disable MDP interrupts */ - queue_work(mdp_cursor_ctrl_wq, &mdp_cursor_ctrl_worker); - - /* update done */ - sync_disabled = 1; - spin_unlock(&mdp_spin_lock); -} - -static void mdp_hw_cursor_enable_vsync(void) -{ - /* if the cursor registers were updated (once or more) since the - * last vsync, enable the vsync interrupt (if not already enabled) - * for the next update - */ - if (sync_disabled) { - - /* cancel pending task to disable MDP interrupts */ - if (work_pending(&mdp_cursor_ctrl_worker)) { - cancel_work_sync(&mdp_cursor_ctrl_worker); - } else { - /* enable irq */ - if (hdmi_prim_display) - mdp_enable_irq(MDP_OVERLAY1_TERM); - else - mdp_enable_irq(MDP_OVERLAY0_TERM); - } - - sync_disabled = 0; - - /* enable vsync intr */ - if (hdmi_prim_display) { - outp32(MDP_INTR_CLEAR, INTR_OVERLAY1_DONE); - mdp_intr_mask |= INTR_OVERLAY1_DONE; - } else { - outp32(MDP_INTR_CLEAR, INTR_OVERLAY0_DONE); - mdp_intr_mask |= INTR_OVERLAY0_DONE; - } - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - } -} - -int mdp_hw_cursor_sync_update(struct fb_info *info, struct fb_cursor *cursor) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct fb_image *img = &cursor->image; - unsigned long flag; - int sync_needed = 0, ret = 0; - uint32_t base = 0; - - if ((img->width > MDP_CURSOR_WIDTH) || - (img->height > MDP_CURSOR_HEIGHT) || - (img->depth != 32)) - return -EINVAL; - - if (hdmi_prim_display) - base = ((uint32_t)(MDP_BASE + 0xB0000)); - else - base = ((uint32_t)(MDP_BASE + 0x90000)); - - if (cursor->set & FB_CUR_SETPOS) - MDP_OUTP(base + 0x4c, (img->dy << 16) | img->dx); - - if (cursor->set & FB_CUR_SETIMAGE) { - ret = copy_from_user(mfd->cursor_buf, img->data, - img->width*img->height*4); - if (ret) - return ret; - - spin_lock_irqsave(&mdp_spin_lock, flag); - if (img->bg_color == 0xffffffff) - transp_en = 0; - else - transp_en = 1; - - alpha = (img->fg_color & 0xff000000) >> 24; - - if (alpha) - calpha_en = 0x2; /* xrgb */ - else - calpha_en = 0x1; /* argb */ - - /* cursor parameters */ - height = img->height; - width = img->width; - bg_color = img->bg_color; - cursor_buf_phys = mfd->cursor_buf_phys; - - sync_needed = 1; - } else - spin_lock_irqsave(&mdp_spin_lock, flag); - - if ((cursor->enable) && (!cursor_enabled)) { - cursor_enabled = 1; - sync_needed = 1; - } else if ((!cursor->enable) && (cursor_enabled)) { - cursor_enabled = 0; - sync_needed = 1; - } - - /* if sync cursor update is needed, enable vsync */ - if (sync_needed) - mdp_hw_cursor_enable_vsync(); - - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - return 0; -} -#endif /* CONFIG_FB_MSM_OVERLAY && CONFIG_FB_MSM_MDP40 */ - -int mdp_hw_cursor_update(struct fb_info *info, struct fb_cursor *cursor) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct fb_image *img = &cursor->image; - int calpha_en, transp_en; - int alpha; - int ret = 0; - - if ((img->width > MDP_CURSOR_WIDTH) || - (img->height > MDP_CURSOR_HEIGHT) || - (img->depth != 32)) - return -EINVAL; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - if (cursor->set & FB_CUR_SETPOS) - MDP_OUTP(MDP_BASE + 0x9004c, (img->dy << 16) | img->dx); - - if (cursor->set & FB_CUR_SETIMAGE) { - ret = copy_from_user(mfd->cursor_buf, img->data, - img->width*img->height*4); - if (ret) - return ret; - - if (img->bg_color == 0xffffffff) - transp_en = 0; - else - transp_en = 1; - - alpha = (img->fg_color & 0xff000000) >> 24; - - if (alpha) - calpha_en = 0x2; /* xrgb */ - else - calpha_en = 0x1; /* argb */ - - MDP_OUTP(MDP_BASE + 0x90044, (img->height << 16) | img->width); - MDP_OUTP(MDP_BASE + 0x90048, mfd->cursor_buf_phys); - /* order the writes the cursor_buf before updating the - * hardware */ - dma_coherent_pre_ops(); - MDP_OUTP(MDP_BASE + 0x90060, - (transp_en << 3) | (calpha_en << 1) | - (inp32(MDP_BASE + 0x90060) & 0x1)); -#ifdef CONFIG_FB_MSM_MDP40 - MDP_OUTP(MDP_BASE + 0x90064, (alpha << 24)); - MDP_OUTP(MDP_BASE + 0x90068, (0xffffff & img->bg_color)); - MDP_OUTP(MDP_BASE + 0x9006C, (0xffffff & img->bg_color)); -#else - MDP_OUTP(MDP_BASE + 0x90064, - (alpha << 24) | (0xffffff & img->bg_color)); - MDP_OUTP(MDP_BASE + 0x90068, 0); -#endif - } - - if ((cursor->enable) && (!cursor_enabled)) { - cursor_enabled = 1; - MDP_OUTP(MDP_BASE + 0x90060, inp32(MDP_BASE + 0x90060) | 0x1); - } else if ((!cursor->enable) && (cursor_enabled)) { - cursor_enabled = 0; - MDP_OUTP(MDP_BASE + 0x90060, - inp32(MDP_BASE + 0x90060) & (~0x1)); - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return 0; -} diff --git a/drivers/video/msm/mdp_debugfs.c b/drivers/video/msm/mdp_debugfs.c deleted file mode 100644 index 95794d98ef05611bf525b1213c4d33e984e204dc..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_debugfs.c +++ /dev/null @@ -1,1479 +0,0 @@ -/* Copyright (c) 2009-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mdp.h" -#include "msm_fb.h" -#ifdef CONFIG_FB_MSM_MDP40 -#include "mdp4.h" -#endif -#include "mddihosti.h" -#include "tvenc.h" -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL -#include "hdmi_msm.h" -#endif - -#define MDP_DEBUG_BUF 2048 - -static uint32 mdp_offset; -static uint32 mdp_count; - -static char debug_buf[MDP_DEBUG_BUF]; - -/* - * MDP4 - * - */ - -static int mdp_offset_open(struct inode *inode, struct file *file) -{ - /* non-seekable */ - file->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); - return 0; -} - -static int mdp_offset_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static ssize_t mdp_offset_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - sscanf(debug_buf, "%x %d", &off, &cnt); - - if (cnt <= 0) - cnt = 1; - - mdp_offset = off; - mdp_count = cnt; - - printk(KERN_INFO "%s: offset=%x cnt=%d\n", __func__, - mdp_offset, mdp_count); - - return count; -} - -static ssize_t mdp_offset_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - - - if (*ppos) - return 0; /* the end */ - - len = snprintf(debug_buf, sizeof(debug_buf), "0x%08x %d\n", - mdp_offset, mdp_count); - if (len < 0) - return 0; - - if (copy_to_user(buff, debug_buf, len)) - return -EFAULT; - - *ppos += len; /* increase offset */ - - return len; -} - -static const struct file_operations mdp_off_fops = { - .open = mdp_offset_open, - .release = mdp_offset_release, - .read = mdp_offset_read, - .write = mdp_offset_write, -}; - -static int mdp_reg_open(struct inode *inode, struct file *file) -{ - /* non-seekable */ - file->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); - return 0; -} - -static int mdp_reg_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static ssize_t mdp_reg_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, data; - int cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x %x", &off, &data); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - outpdw(MDP_BASE + off, data); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - printk(KERN_INFO "%s: addr=%x data=%x\n", __func__, off, data); - - return count; -} - -static ssize_t mdp_reg_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - uint32 data; - int i, j, off, dlen, num; - char *bp, *cp; - int tot = 0; - - - if (*ppos) - return 0; /* the end */ - - j = 0; - num = 0; - bp = debug_buf; - cp = MDP_BASE + mdp_offset; - dlen = sizeof(debug_buf); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - while (j++ < 8) { - len = snprintf(bp, dlen, "0x%08x: ", (int)cp); - tot += len; - bp += len; - dlen -= len; - off = 0; - i = 0; - while (i++ < 4) { - data = inpdw(cp + off); - len = snprintf(bp, dlen, "%08x ", data); - tot += len; - bp += len; - dlen -= len; - off += 4; - num++; - if (num >= mdp_count) - break; - } - *bp++ = '\n'; - --dlen; - tot++; - cp += off; - if (num >= mdp_count) - break; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - *bp = 0; - tot++; - - if (copy_to_user(buff, debug_buf, tot)) - return -EFAULT; - - *ppos += tot; /* increase offset */ - - return tot; -} - - -static const struct file_operations mdp_reg_fops = { - .open = mdp_reg_open, - .release = mdp_reg_release, - .read = mdp_reg_read, - .write = mdp_reg_write, -}; - -#ifdef CONFIG_FB_MSM_MDP40 -static int mdp_stat_open(struct inode *inode, struct file *file) -{ - /* non-seekable */ - file->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); - return 0; -} - -static int mdp_stat_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static ssize_t mdp_stat_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - unsigned long flag; - - if (count > sizeof(debug_buf)) - return -EFAULT; - - spin_lock_irqsave(&mdp_spin_lock, flag); - memset((char *)&mdp4_stat, 0 , sizeof(mdp4_stat)); /* reset */ - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - return count; -} - -static ssize_t mdp_stat_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - int tot = 0; - int dlen; - char *bp; - - - if (*ppos) - return 0; /* the end */ - - bp = debug_buf; - dlen = sizeof(debug_buf); - - len = snprintf(bp, dlen, "\nmdp:\n"); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "int_total: %08lu\t", - mdp4_stat.intr_tot); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "int_overlay0: %08lu\t", - mdp4_stat.intr_overlay0); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "int_overlay1: %08lu\n", - mdp4_stat.intr_overlay1); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "int_overlay1: %08lu\n", - mdp4_stat.intr_overlay2); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "int_dmap: %08lu\t", - mdp4_stat.intr_dma_p); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "int_dmas: %08lu\t", - mdp4_stat.intr_dma_s); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "int_dmae: %08lu\n", - mdp4_stat.intr_dma_e); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "primary: vsync: %08lu\t", - mdp4_stat.intr_vsync_p); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "underrun: %08lu\n", - mdp4_stat.intr_underrun_p); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "external: vsync: %08lu\t", - mdp4_stat.intr_vsync_e); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "underrun: %08lu\n", - mdp4_stat.intr_underrun_e); - - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "histogram: %08lu\t", - mdp4_stat.intr_histogram); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "read_ptr: %08lu\n\n", - mdp4_stat.intr_rdptr); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "dsi:\n"); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "int_total: %08lu\tmdp_start: %08lu\n", - mdp4_stat.intr_dsi, mdp4_stat.dsi_mdp_start); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "int_cmd: %08lu\t", - mdp4_stat.intr_dsi_cmd); - - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "int_mdp: %08lu\t", - mdp4_stat.intr_dsi_mdp); - - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "int_err: %08lu\n", - mdp4_stat.intr_dsi_err); - - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "clk_on : %08lu\t", - mdp4_stat.dsi_clk_on); - - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "clk_off: %08lu\n\n", - mdp4_stat.dsi_clk_off); - - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "kickoff:\n"); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "overlay0: %08lu\t", - mdp4_stat.kickoff_ov0); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "dmap: %08lu\t", - mdp4_stat.kickoff_dmap); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "dmas: %08lu\n", - mdp4_stat.kickoff_dmas); - - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "overlay1: %08lu\t", - mdp4_stat.kickoff_ov1); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "dmae: %08lu\n\n", - mdp4_stat.kickoff_dmae); - - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "overlay0_play:\n"); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "set: %08lu\t", - mdp4_stat.overlay_set[0]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "unset: %08lu\t", - mdp4_stat.overlay_unset[0]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "play: %08lu\t", - mdp4_stat.overlay_play[0]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "commit: %08lu\n", - mdp4_stat.overlay_commit[0]); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "overlay1_play:\n"); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "set: %08lu\t", - mdp4_stat.overlay_set[1]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "unset: %08lu\t", - mdp4_stat.overlay_unset[1]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "play: %08lu\t", - mdp4_stat.overlay_play[1]); - - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "commit: %08lu\n\n", - mdp4_stat.overlay_commit[1]); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "frame_push:\n"); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "vg1 : %08lu\t", mdp4_stat.pipe[0]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "vg2 : %08lu\t", mdp4_stat.pipe[1]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "vg3 : %08lu\n", mdp4_stat.pipe[5]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "rgb1: %08lu\t", mdp4_stat.pipe[2]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "rgb2: %08lu\t", mdp4_stat.pipe[3]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "rgb3: %08lu\n\n", mdp4_stat.pipe[4]); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "wait4vsync: "); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "mixer0 : %08lu\t", mdp4_stat.wait4vsync0); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "mixer1: %08lu\n\n", mdp4_stat.wait4vsync1); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "iommu: "); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "map : %08lu\t", mdp4_stat.iommu_map); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "unmap: %08lu\t", mdp4_stat.iommu_unmap); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "drop: %08lu\n\n", mdp4_stat.iommu_drop); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "err_mixer : %08lu\t", mdp4_stat.err_mixer); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "err_size : %08lu\n", mdp4_stat.err_size); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "err_scale : %08lu\t", mdp4_stat.err_scale); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "err_format: %08lu\n", mdp4_stat.err_format); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "err_play : %08lu\t", mdp4_stat.err_play); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "err_stage : %08lu\n", mdp4_stat.err_stage); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "err_underflow: %08lu\n\n", - mdp4_stat.err_underflow); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "writeback:\n"); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "dsi_cmd: %08lu\t", - mdp4_stat.blt_dsi_cmd); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "dsi_video: %08lu\n", - mdp4_stat.blt_dsi_video); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "lcdc: %08lu\t", - mdp4_stat.blt_lcdc); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "dtv: %08lu\t", - mdp4_stat.blt_dtv); - bp += len; - dlen -= len; - - len = snprintf(bp, dlen, "mddi: %08lu\n\n", - mdp4_stat.blt_mddi); - bp += len; - dlen -= len; - - tot = (uint32)bp - (uint32)debug_buf; - *bp = 0; - tot++; - - if (tot < 0) - return 0; - if (copy_to_user(buff, debug_buf, tot)) - return -EFAULT; - - *ppos += tot; /* increase offset */ - - return tot; -} - -static const struct file_operations mdp_stat_fops = { - .open = mdp_stat_open, - .release = mdp_stat_release, - .read = mdp_stat_read, - .write = mdp_stat_write, -}; -#endif - -/* - * MDDI - * - */ - -struct mddi_reg { - char *name; - int off; -}; - -static struct mddi_reg mddi_regs_list[] = { - {"MDDI_CMD", MDDI_CMD}, /* 0x0000 */ - {"MDDI_VERSION", MDDI_VERSION}, /* 0x0004 */ - {"MDDI_PRI_PTR", MDDI_PRI_PTR}, /* 0x0008 */ - {"MDDI_BPS", MDDI_BPS}, /* 0x0010 */ - {"MDDI_SPM", MDDI_SPM}, /* 0x0014 */ - {"MDDI_INT", MDDI_INT}, /* 0x0018 */ - {"MDDI_INTEN", MDDI_INTEN}, /* 0x001c */ - {"MDDI_REV_PTR", MDDI_REV_PTR}, /* 0x0020 */ - {"MDDI_ REV_SIZE", MDDI_REV_SIZE},/* 0x0024 */ - {"MDDI_STAT", MDDI_STAT}, /* 0x0028 */ - {"MDDI_REV_RATE_DIV", MDDI_REV_RATE_DIV}, /* 0x002c */ - {"MDDI_REV_CRC_ERR", MDDI_REV_CRC_ERR}, /* 0x0030 */ - {"MDDI_TA1_LEN", MDDI_TA1_LEN}, /* 0x0034 */ - {"MDDI_TA2_LEN", MDDI_TA2_LEN}, /* 0x0038 */ - {"MDDI_TEST", MDDI_TEST}, /* 0x0040 */ - {"MDDI_REV_PKT_CNT", MDDI_REV_PKT_CNT}, /* 0x0044 */ - {"MDDI_DRIVE_HI", MDDI_DRIVE_HI},/* 0x0048 */ - {"MDDI_DRIVE_LO", MDDI_DRIVE_LO}, /* 0x004c */ - {"MDDI_DISP_WAKE", MDDI_DISP_WAKE},/* 0x0050 */ - {"MDDI_REV_ENCAP_SZ", MDDI_REV_ENCAP_SZ}, /* 0x0054 */ - {"MDDI_RTD_VAL", MDDI_RTD_VAL}, /* 0x0058 */ - {"MDDI_PAD_CTL", MDDI_PAD_CTL}, /* 0x0068 */ - {"MDDI_DRIVER_START_CNT", MDDI_DRIVER_START_CNT}, /* 0x006c */ - {"MDDI_CORE_VER", MDDI_CORE_VER}, /* 0x008c */ - {"MDDI_FIFO_ALLOC", MDDI_FIFO_ALLOC}, /* 0x0090 */ - {"MDDI_PAD_IO_CTL", MDDI_PAD_IO_CTL}, /* 0x00a0 */ - {"MDDI_PAD_CAL", MDDI_PAD_CAL}, /* 0x00a4 */ - {0, 0} -}; - -static int mddi_reg_open(struct inode *inode, struct file *file) -{ - /* non-seekable */ - file->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); - return 0; -} - -static int mddi_reg_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static void mddi_reg_write(int ndx, uint32 off, uint32 data) -{ - char *base; - - if (ndx) - base = (char *)msm_emdh_base; - else - base = (char *)msm_pmdh_base; - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - writel(data, base + off); - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - printk(KERN_INFO "%s: addr=%x data=%x\n", - __func__, (int)(base+off), (int)data); -} - -static int mddi_reg_read(int ndx) -{ - struct mddi_reg *reg; - unsigned char *base; - int data; - char *bp; - int len = 0; - int tot = 0; - int dlen; - - if (ndx) - base = msm_emdh_base; - else - base = msm_pmdh_base; - - reg = mddi_regs_list; - bp = debug_buf; - dlen = sizeof(debug_buf); - - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - while (reg->name) { - data = readl((u32)base + reg->off); - len = snprintf(bp, dlen, "%s:0x%08x\t\t= 0x%08x\n", - reg->name, reg->off, data); - tot += len; - bp += len; - dlen -= len; - reg++; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - *bp = 0; - tot++; - - return tot; -} - -static ssize_t pmdh_reg_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, data; - int cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x %x", &off, &data); - - mddi_reg_write(0, off, data); - - return count; -} - -static ssize_t pmdh_reg_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int tot = 0; - - if (*ppos) - return 0; /* the end */ - - tot = mddi_reg_read(0); /* pmdh */ - - if (tot < 0) - return 0; - if (copy_to_user(buff, debug_buf, tot)) - return -EFAULT; - - *ppos += tot; /* increase offset */ - - return tot; -} - - -static const struct file_operations pmdh_fops = { - .open = mddi_reg_open, - .release = mddi_reg_release, - .read = pmdh_reg_read, - .write = pmdh_reg_write, -}; - -static ssize_t emdh_reg_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, data; - int cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x %x", &off, &data); - - mddi_reg_write(1, off, data); - - return count; -} - -static ssize_t emdh_reg_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int tot = 0; - - if (*ppos) - return 0; /* the end */ - - tot = mddi_reg_read(1); /* emdh */ - - if (tot < 0) - return 0; - if (copy_to_user(buff, debug_buf, tot)) - return -EFAULT; - - *ppos += tot; /* increase offset */ - - return tot; -} - -static const struct file_operations emdh_fops = { - .open = mddi_reg_open, - .release = mddi_reg_release, - .read = emdh_reg_read, - .write = emdh_reg_write, -}; - - -uint32 dbg_offset; -uint32 dbg_count; -char *dbg_base; - - -static int dbg_open(struct inode *inode, struct file *file) -{ - /* non-seekable */ - file->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); - return 0; -} - -static int dbg_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static ssize_t dbg_base_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - return count; -} - -static ssize_t dbg_base_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - int tot = 0; - int dlen; - char *bp; - - - if (*ppos) - return 0; /* the end */ - - - bp = debug_buf; - dlen = sizeof(debug_buf); - - len = snprintf(bp, dlen, "mdp_base : %08x\n", - (int)msm_mdp_base); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "mddi_base : %08x\n", - (int)msm_pmdh_base); - bp += len; - dlen -= len; - len = snprintf(bp, dlen, "emdh_base : %08x\n", - (int)msm_emdh_base); - bp += len; - dlen -= len; -#ifdef CONFIG_FB_MSM_TVOUT - len = snprintf(bp, dlen, "tvenv_base: %08x\n", - (int)tvenc_base); - bp += len; - dlen -= len; -#endif - -#ifdef CONFIG_FB_MSM_MIPI_DSI - len = snprintf(bp, dlen, "mipi_dsi_base: %08x\n", - (int)mipi_dsi_base); - bp += len; - dlen -= len; -#endif - - tot = (uint32)bp - (uint32)debug_buf; - *bp = 0; - tot++; - - if (tot < 0) - return 0; - if (copy_to_user(buff, debug_buf, tot)) - return -EFAULT; - - *ppos += tot; /* increase offset */ - - return tot; -} - -static const struct file_operations dbg_base_fops = { - .open = dbg_open, - .release = dbg_release, - .read = dbg_base_read, - .write = dbg_base_write, -}; - -static ssize_t dbg_offset_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, cnt, num, base; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x %d %x", &off, &num, &base); - - if (cnt < 0) - cnt = 0; - - if (cnt >= 1) - dbg_offset = off; - if (cnt >= 2) - dbg_count = num; - if (cnt >= 3) - dbg_base = (char *)base; - - printk(KERN_INFO "%s: offset=%x cnt=%d base=%x\n", __func__, - dbg_offset, dbg_count, (int)dbg_base); - - return count; -} - -static ssize_t dbg_offset_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - - - if (*ppos) - return 0; /* the end */ - - len = snprintf(debug_buf, sizeof(debug_buf), "0x%08x %d 0x%08x\n", - dbg_offset, dbg_count, (int)dbg_base); - if (len < 0) - return 0; - - if (copy_to_user(buff, debug_buf, len)) - return -EFAULT; - - *ppos += len; /* increase offset */ - - return len; -} - -static const struct file_operations dbg_off_fops = { - .open = dbg_open, - .release = dbg_release, - .read = dbg_offset_read, - .write = dbg_offset_write, -}; - - -static ssize_t dbg_reg_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, data; - int cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x %x", &off, &data); - - writel(data, dbg_base + off); - - printk(KERN_INFO "%s: addr=%x data=%x\n", - __func__, (int)(dbg_base+off), (int)data); - - return count; -} - -static ssize_t dbg_reg_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - uint32 data; - int i, j, off, dlen, num; - char *bp, *cp; - int tot = 0; - - - if (*ppos) - return 0; /* the end */ - - if (dbg_base == 0) - return 0; /* nothing to read */ - - j = 0; - num = 0; - bp = debug_buf; - cp = (char *)(dbg_base + dbg_offset); - dlen = sizeof(debug_buf); - while (j++ < 16) { - len = snprintf(bp, dlen, "0x%08x: ", (int)cp); - tot += len; - bp += len; - dlen -= len; - off = 0; - i = 0; - while (i++ < 4) { - data = readl(cp + off); - len = snprintf(bp, dlen, "%08x ", data); - tot += len; - bp += len; - dlen -= len; - off += 4; - num++; - if (num >= dbg_count) - break; - } - data = readl((u32)cp + off); - *bp++ = '\n'; - --dlen; - tot++; - cp += off; - if (num >= dbg_count) - break; - } - *bp = 0; - tot++; - - if (copy_to_user(buff, debug_buf, tot)) - return -EFAULT; - - *ppos += tot; /* increase offset */ - - return tot; -} - - -static const struct file_operations dbg_reg_fops = { - .open = dbg_open, - .release = dbg_release, - .read = dbg_reg_read, - .write = dbg_reg_write, -}; - -u32 dbg_force_ov0_blt; -u32 dbg_force_ov1_blt; - -static ssize_t dbg_force_ov0_blt_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) { - int len; - - if (*ppos) - return 0; - - len = snprintf(debug_buf, sizeof(debug_buf), - "%d\n", dbg_force_ov0_blt); - - if (len < 0) - return 0; - - if (copy_to_user(buff, debug_buf, len)) - return -EFAULT; - - *ppos += len; - - return len; -} - -static ssize_t dbg_force_ov0_blt_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - u32 cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x", &dbg_force_ov0_blt); - - pr_info("%s: dbg_force_ov0_blt = %x\n", - __func__, dbg_force_ov0_blt); - - if ((dbg_force_ov0_blt & 0x0f) > 2) - pr_err("%s: invalid dbg_force_ov0_blt = %d\n", - __func__, dbg_force_ov0_blt); - - if ((dbg_force_ov0_blt >> 4) > 2) - pr_err("%s: invalid dbg_force_ov0_blt = %d\n", - __func__, dbg_force_ov0_blt); - - return count; -} - -static const struct file_operations dbg_force_ov0_blt_fops = { - .open = dbg_open, - .release = dbg_release, - .read = dbg_force_ov0_blt_read, - .write = dbg_force_ov0_blt_write, -}; - -static ssize_t dbg_force_ov1_blt_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) { - int len; - - if (*ppos) - return 0; - - len = snprintf(debug_buf, sizeof(debug_buf), - "%x\n", dbg_force_ov1_blt); - - if (len < 0) - return 0; - - if (copy_to_user(buff, debug_buf, len)) - return -EFAULT; - - *ppos += len; - - return len; -} - -static ssize_t dbg_force_ov1_blt_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - u32 cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x", &dbg_force_ov1_blt); - - pr_info("%s: dbg_force_ov1_blt = %x\n", - __func__, dbg_force_ov1_blt); - - if ((dbg_force_ov1_blt & 0x0f) > 2) - pr_err("%s: invalid dbg_force_ov1_blt = %x\n", - __func__, dbg_force_ov1_blt); - - if ((dbg_force_ov1_blt >> 4) > 2) - pr_err("%s: invalid dbg_force_ov1_blt = %d\n", - __func__, dbg_force_ov1_blt); - - return count; -} - -static const struct file_operations dbg_force_ov1_blt_fops = { - .open = dbg_open, - .release = dbg_release, - .read = dbg_force_ov1_blt_read, - .write = dbg_force_ov1_blt_write, -}; - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL -static uint32 hdmi_offset; -static uint32 hdmi_count; - -static int hdmi_open(struct inode *inode, struct file *file) -{ - /* non-seekable */ - file->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); - return 0; -} - -static int hdmi_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static ssize_t hdmi_offset_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, cnt, num; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x %d", &off, &num); - - if (cnt < 0) - cnt = 0; - - if (cnt >= 1) - hdmi_offset = off; - if (cnt >= 2) - hdmi_count = num; - - printk(KERN_INFO "%s: offset=%x cnt=%d\n", __func__, - hdmi_offset, hdmi_count); - - return count; -} - -static ssize_t hdmi_offset_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - - - if (*ppos) - return 0; /* the end */ - - len = snprintf(debug_buf, sizeof(debug_buf), "0x%08x %d\n", - hdmi_offset, hdmi_count); - if (len < 0) - return 0; - - if (copy_to_user(buff, debug_buf, len)) - return -EFAULT; - - *ppos += len; /* increase offset */ - - return len; -} - -static const struct file_operations hdmi_off_fops = { - .open = hdmi_open, - .release = hdmi_release, - .read = hdmi_offset_read, - .write = hdmi_offset_write, -}; - - -static ssize_t hdmi_reg_write( - struct file *file, - const char __user *buff, - size_t count, - loff_t *ppos) -{ - uint32 off, data, base; - int cnt; - - if (count >= sizeof(debug_buf)) - return -EFAULT; - - if (copy_from_user(debug_buf, buff, count)) - return -EFAULT; - - base = hdmi_msm_get_io_base(); - if (base == 0) - return -EFAULT; - - debug_buf[count] = 0; /* end of string */ - - cnt = sscanf(debug_buf, "%x %x", &off, &data); - - writel(data, base + off); - - printk(KERN_INFO "%s: addr=%x data=%x\n", - __func__, (int)(base+off), (int)data); - - return count; -} - -static ssize_t hdmi_reg_read( - struct file *file, - char __user *buff, - size_t count, - loff_t *ppos) -{ - int len = 0; - uint32 data; - int i, j, off, dlen, num; - char *bp, *cp; - int tot = 0; - - - if (*ppos) - return 0; /* the end */ - - if (hdmi_msm_get_io_base() == 0) - return 0; /* nothing to read */ - - j = 0; - num = 0; - bp = debug_buf; - cp = (char *)(hdmi_msm_get_io_base() + hdmi_offset); - dlen = sizeof(debug_buf); - while (j++ < 16) { - len = snprintf(bp, dlen, "0x%08x: ", (int)cp); - tot += len; - bp += len; - dlen -= len; - off = 0; - i = 0; - while (i++ < 4) { - data = readl(cp + off); - len = snprintf(bp, dlen, "%08x ", data); - tot += len; - bp += len; - dlen -= len; - off += 4; - num++; - if (num >= hdmi_count) - break; - } - data = readl((u32)cp + off); - *bp++ = '\n'; - --dlen; - tot++; - cp += off; - if (num >= hdmi_count) - break; - } - *bp = 0; - tot++; - - if (copy_to_user(buff, debug_buf, tot)) - return -EFAULT; - - *ppos += tot; /* increase offset */ - - return tot; -} - - -static const struct file_operations hdmi_reg_fops = { - .open = hdmi_open, - .release = hdmi_release, - .read = hdmi_reg_read, - .write = hdmi_reg_write, -}; -#endif - -/* - * debugfs - * - */ - -int mdp_debugfs_init(void) -{ - struct dentry *dent = debugfs_create_dir("mdp", NULL); - - if (IS_ERR(dent)) { - printk(KERN_ERR "%s(%d): debugfs_create_dir fail, error %ld\n", - __FILE__, __LINE__, PTR_ERR(dent)); - return -1; - } - - if (debugfs_create_file("off", 0644, dent, 0, &mdp_off_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: index fail\n", - __FILE__, __LINE__); - return -1; - } - - if (debugfs_create_file("reg", 0644, dent, 0, &mdp_reg_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: debug fail\n", - __FILE__, __LINE__); - return -1; - } - -#ifdef CONFIG_FB_MSM_MDP40 - if (debugfs_create_file("stat", 0644, dent, 0, &mdp_stat_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: debug fail\n", - __FILE__, __LINE__); - return -1; - } -#endif - - if (debugfs_create_file("force_ov0_blt", 0644, dent, 0, - &dbg_force_ov0_blt_fops) - == NULL) { - pr_err("%s(%d): debugfs_create_file: debug fail\n", - __FILE__, __LINE__); - return -EFAULT; - } - - if (debugfs_create_file("force_ov1_blt", 0644, dent, 0, - &dbg_force_ov1_blt_fops) - == NULL) { - pr_err("%s(%d): debugfs_create_file: debug fail\n", - __FILE__, __LINE__); - return -EFAULT; - } - - dent = debugfs_create_dir("mddi", NULL); - - if (IS_ERR(dent)) { - printk(KERN_ERR "%s(%d): debugfs_create_dir fail, error %ld\n", - __FILE__, __LINE__, PTR_ERR(dent)); - return -1; - } - - if (debugfs_create_file("reg", 0644, dent, 0, &pmdh_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: debug fail\n", - __FILE__, __LINE__); - return -1; - } - - dent = debugfs_create_dir("emdh", NULL); - - if (IS_ERR(dent)) { - printk(KERN_ERR "%s(%d): debugfs_create_dir fail, error %ld\n", - __FILE__, __LINE__, PTR_ERR(dent)); - return -1; - } - - if (debugfs_create_file("reg", 0644, dent, 0, &emdh_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: debug fail\n", - __FILE__, __LINE__); - return -1; - } - - dent = debugfs_create_dir("mdp-dbg", NULL); - - if (IS_ERR(dent)) { - printk(KERN_ERR "%s(%d): debugfs_create_dir fail, error %ld\n", - __FILE__, __LINE__, PTR_ERR(dent)); - return -1; - } - - if (debugfs_create_file("base", 0644, dent, 0, &dbg_base_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: index fail\n", - __FILE__, __LINE__); - return -1; - } - - if (debugfs_create_file("off", 0644, dent, 0, &dbg_off_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: index fail\n", - __FILE__, __LINE__); - return -1; - } - - if (debugfs_create_file("reg", 0644, dent, 0, &dbg_reg_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: debug fail\n", - __FILE__, __LINE__); - return -1; - } - -#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL - dent = debugfs_create_dir("hdmi", NULL); - - if (IS_ERR(dent)) { - printk(KERN_ERR "%s(%d): debugfs_create_dir fail, error %ld\n", - __FILE__, __LINE__, PTR_ERR(dent)); - return PTR_ERR(dent); - } - - if (debugfs_create_file("off", 0644, dent, 0, &hdmi_off_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: 'off' fail\n", - __FILE__, __LINE__); - return -ENOENT; - } - - if (debugfs_create_file("reg", 0644, dent, 0, &hdmi_reg_fops) - == NULL) { - printk(KERN_ERR "%s(%d): debugfs_create_file: 'reg' fail\n", - __FILE__, __LINE__); - return -ENOENT; - } -#endif - - return 0; -} diff --git a/drivers/video/msm/mdp_dma.c b/drivers/video/msm/mdp_dma.c deleted file mode 100644 index 7e35ca4863e19a2a8057f9219f3d1eaf03267afe..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_dma.c +++ /dev/null @@ -1,677 +0,0 @@ -/* Copyright (c) 2008-2013, 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mddihost.h" - -static uint32 mdp_last_dma2_update_width; -static uint32 mdp_last_dma2_update_height; -static uint32 mdp_curr_dma2_update_width; -static uint32 mdp_curr_dma2_update_height; - -ktime_t mdp_dma2_last_update_time = { 0 }; - -int mdp_lcd_rd_cnt_offset_slow = 20; -int mdp_lcd_rd_cnt_offset_fast = 20; -int mdp_vsync_usec_wait_line_too_short = 5; -uint32 mdp_dma2_update_time_in_usec; -uint32 mdp_total_vdopkts; - -extern u32 msm_fb_debug_enabled; -extern struct workqueue_struct *mdp_dma_wq; - -int vsync_start_y_adjust = 4; - -static void mdp_dma2_update_lcd(struct msm_fb_data_type *mfd) -{ - MDPIBUF *iBuf = &mfd->ibuf; - int mddi_dest = FALSE; - int cmd_mode = FALSE; - uint32 outBpp = iBuf->bpp; - uint32 dma2_cfg_reg; - uint8 *src; - uint32 mddi_ld_param; - uint16 mddi_vdo_packet_reg; -#ifndef CONFIG_FB_MSM_MDP303 - struct msm_fb_panel_data *pdata = - (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; -#endif - uint32 ystride = mfd->fbi->fix.line_length; - uint32 mddi_pkt_desc; - - dma2_cfg_reg = DMA_PACK_ALIGN_LSB | - DMA_OUT_SEL_AHB | DMA_IBUF_NONCONTIGUOUS; - -#ifdef CONFIG_FB_MSM_MDP22 - dma2_cfg_reg |= DMA_PACK_TIGHT; -#endif - -#ifdef CONFIG_FB_MSM_MDP30 - /* - * Software workaround: On 7x25/7x27, the MDP will not - * respond if dma_w is 1 pixel. Set the update width to - * 2 pixels and adjust the x offset if needed. - */ - if (iBuf->dma_w == 1) { - iBuf->dma_w = 2; - if (iBuf->dma_x == (iBuf->ibuf_width - 2)) - iBuf->dma_x--; - } -#endif - - if (mfd->fb_imgType == MDP_BGR_565) - dma2_cfg_reg |= DMA_PACK_PATTERN_BGR; - else if (mfd->fb_imgType == MDP_RGBA_8888) - dma2_cfg_reg |= DMA_PACK_PATTERN_BGR; - else - dma2_cfg_reg |= DMA_PACK_PATTERN_RGB; - - if (outBpp == 4) { - dma2_cfg_reg |= DMA_IBUF_C3ALPHA_EN; - dma2_cfg_reg |= DMA_IBUF_FORMAT_xRGB8888_OR_ARGB8888; - } - - if (outBpp == 2) - dma2_cfg_reg |= DMA_IBUF_FORMAT_RGB565; - - mddi_ld_param = 0; - mddi_vdo_packet_reg = mfd->panel_info.mddi.vdopkt; - - if ((mfd->panel_info.type == MDDI_PANEL) || - (mfd->panel_info.type == EXT_MDDI_PANEL)) { - dma2_cfg_reg |= DMA_OUT_SEL_MDDI; - mddi_dest = TRUE; - - if (mfd->panel_info.type == MDDI_PANEL) { - mdp_total_vdopkts++; - if (mfd->panel_info.pdest == DISPLAY_1) { - dma2_cfg_reg |= DMA_MDDI_DMAOUT_LCD_SEL_PRIMARY; - mddi_ld_param = 0; -#ifdef MDDI_HOST_WINDOW_WORKAROUND - mddi_window_adjust(mfd, iBuf->dma_x, - iBuf->dma_w - 1, iBuf->dma_y, - iBuf->dma_h - 1); -#endif - } else { - dma2_cfg_reg |= - DMA_MDDI_DMAOUT_LCD_SEL_SECONDARY; - mddi_ld_param = 1; -#ifdef MDDI_HOST_WINDOW_WORKAROUND - mddi_window_adjust(mfd, iBuf->dma_x, - iBuf->dma_w - 1, iBuf->dma_y, - iBuf->dma_h - 1); -#endif - } - } else { - dma2_cfg_reg |= DMA_MDDI_DMAOUT_LCD_SEL_EXTERNAL; - mddi_ld_param = 2; - } -#ifdef CONFIG_FB_MSM_MDP303 - } else if (mfd->panel_info.type == MIPI_CMD_PANEL) { - cmd_mode = TRUE; - dma2_cfg_reg |= DMA_OUT_SEL_DSI_CMD; -#endif - } else { - if (mfd->panel_info.pdest == DISPLAY_1) { - dma2_cfg_reg |= DMA_AHBM_LCD_SEL_PRIMARY; - outp32(MDP_EBI2_LCD0, mfd->data_port_phys); - } else { - dma2_cfg_reg |= DMA_AHBM_LCD_SEL_SECONDARY; - outp32(MDP_EBI2_LCD1, mfd->data_port_phys); - } - } - - src = (uint8 *) iBuf->buf; - /* starting input address */ - src += iBuf->dma_x * outBpp + iBuf->dma_y * ystride; - - mdp_curr_dma2_update_width = iBuf->dma_w; - mdp_curr_dma2_update_height = iBuf->dma_h; - - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - -#ifdef CONFIG_FB_MSM_MDP22 - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0184, - (iBuf->dma_h << 16 | iBuf->dma_w)); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0188, src); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x018C, ystride); -#else - if (cmd_mode) - MDP_OUTP(MDP_BASE + 0x90004, - (mfd->panel_info.yres << 16 | mfd->panel_info.xres)); - else - MDP_OUTP(MDP_BASE + 0x90004, (iBuf->dma_h << 16 | iBuf->dma_w)); - - MDP_OUTP(MDP_BASE + 0x90008, src); - MDP_OUTP(MDP_BASE + 0x9000c, ystride); -#endif - - if (mfd->panel_info.bpp == 18) { - mddi_pkt_desc = MDDI_VDO_PACKET_DESC; - dma2_cfg_reg |= DMA_DSTC0G_6BITS | /* 666 18BPP */ - DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - } else if (mfd->panel_info.bpp == 24) { - mddi_pkt_desc = MDDI_VDO_PACKET_DESC_24; - dma2_cfg_reg |= DMA_DSTC0G_8BITS | /* 888 24BPP */ - DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS; - } else { - mddi_pkt_desc = MDDI_VDO_PACKET_DESC_16; - dma2_cfg_reg |= DMA_DSTC0G_6BITS | /* 565 16BPP */ - DMA_DSTC1B_5BITS | DMA_DSTC2R_5BITS; - } - -#ifndef CONFIG_FB_MSM_MDP303 - - if (mddi_dest) { -#ifdef CONFIG_FB_MSM_MDP22 - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0194, - (iBuf->dma_y << 16) | iBuf->dma_x); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01a0, mddi_ld_param); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01a4, - (mddi_pkt_desc << 16) | mddi_vdo_packet_reg); -#else - MDP_OUTP(MDP_BASE + 0x90010, (iBuf->dma_y << 16) | iBuf->dma_x); - MDP_OUTP(MDP_BASE + 0x00090, mddi_ld_param); - MDP_OUTP(MDP_BASE + 0x00094, - (mddi_pkt_desc << 16) | mddi_vdo_packet_reg); -#endif - } else { - /* setting EBI2 LCDC write window */ - pdata->set_rect(iBuf->dma_x, iBuf->dma_y, iBuf->dma_w, - iBuf->dma_h); - } -#else - if (mfd->panel_info.type == MIPI_CMD_PANEL) { - /* dma_p = 0, dma_s = 1 */ - MDP_OUTP(MDP_BASE + 0xF1000, 0x10); - /* enable dsi trigger on dma_p */ - MDP_OUTP(MDP_BASE + 0xF1004, 0x01); - } -#endif - - /* dma2 config register */ -#ifdef MDP_HW_VSYNC - MDP_OUTP(MDP_BASE + 0x90000, dma2_cfg_reg); - - if ((mfd->use_mdp_vsync) && - (mfd->ibuf.vsync_enable) && (mfd->panel_info.lcd.vsync_enable)) { - uint32 start_y; - - if (vsync_start_y_adjust <= iBuf->dma_y) - start_y = iBuf->dma_y - vsync_start_y_adjust; - else - start_y = - (mfd->total_lcd_lines - 1) - (vsync_start_y_adjust - - iBuf->dma_y); - - /* - * MDP VSYNC clock must be On by now so, we don't have to - * re-enable it - */ - MDP_OUTP(MDP_BASE + 0x210, start_y); - MDP_OUTP(MDP_BASE + 0x20c, 1); /* enable prim vsync */ - } else { - MDP_OUTP(MDP_BASE + 0x20c, 0); /* disable prim vsync */ - } -#else -#ifdef CONFIG_FB_MSM_MDP22 - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0180, dma2_cfg_reg); -#else - MDP_OUTP(MDP_BASE + 0x90000, dma2_cfg_reg); -#endif -#endif /* MDP_HW_VSYNC */ - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} - -static ktime_t vt = { 0 }; -int mdp_usec_diff_threshold = 100; -int mdp_expected_usec_wait; - -enum hrtimer_restart mdp_dma2_vsync_hrtimer_handler(struct hrtimer *ht) -{ - struct msm_fb_data_type *mfd = NULL; - - mfd = container_of(ht, struct msm_fb_data_type, dma_hrtimer); - - mdp_pipe_kickoff(MDP_DMA2_TERM, mfd); - - if (msm_fb_debug_enabled) { - ktime_t t; - int usec_diff; - int actual_wait; - - t = ktime_get_real(); - - actual_wait = ktime_to_us(ktime_sub(t, vt)); - usec_diff = actual_wait - mdp_expected_usec_wait; - - if ((mdp_usec_diff_threshold < usec_diff) || (usec_diff < 0)) - MSM_FB_DEBUG - ("HRT Diff = %d usec Exp=%d usec Act=%d usec\n", - usec_diff, mdp_expected_usec_wait, actual_wait); - } - - return HRTIMER_NORESTART; -} - - -#ifdef CONFIG_FB_MSM_MDP303 -static int busy_wait_cnt; - -void mdp3_dsi_cmd_dma_busy_wait(struct msm_fb_data_type *mfd) -{ - unsigned long flag; - int need_wait = 0; - -#ifdef DSI_CLK_CTRL - mod_timer(&dsi_clock_timer, jiffies + HZ); /* one second */ -#endif - - spin_lock_irqsave(&mdp_spin_lock, flag); -#ifdef DSI_CLK_CTRL - - spin_lock_bh(&dsi_clk_lock); - if (mipi_dsi_clk_on == 0) - mipi_dsi_turn_on_clks(); - spin_unlock_bh(&dsi_clk_lock); -#endif - - if (mfd->dma->busy == TRUE) { - if (busy_wait_cnt == 0) - INIT_COMPLETION(mfd->dma->comp); - busy_wait_cnt++; - need_wait++; - } - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - if (need_wait) { - /* wait until DMA finishes the current job */ - wait_for_completion(&mfd->dma->comp); - } -} -#endif - -static void mdp_dma_schedule(struct msm_fb_data_type *mfd, uint32 term) -{ - /* - * dma2 configure VSYNC block - * vsync supported on Primary LCD only for now - */ - int32 mdp_lcd_rd_cnt; - uint32 usec_wait_time; - uint32 start_y; - - /* - * ToDo: if we can move HRT timer callback to workqueue, we can - * move DMA2 power on under mdp_pipe_kickoff(). - * This will save a power for hrt time wait. - * However if the latency for context switch (hrt irq -> workqueue) - * is too big, we will miss the vsync timing. - */ - if (term == MDP_DMA2_TERM) - mdp_pipe_ctrl(MDP_DMA2_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - mdp_dma2_update_time_in_usec = ktime_to_us(mdp_dma2_last_update_time); - - if ((!mfd->ibuf.vsync_enable) || (!mfd->panel_info.lcd.vsync_enable) - || (mfd->use_mdp_vsync)) { - mdp_pipe_kickoff(term, mfd); - return; - } - /* SW vsync logic starts here */ - - /* get current rd counter */ - mdp_lcd_rd_cnt = mdp_get_lcd_line_counter(mfd); - if (mdp_dma2_update_time_in_usec != 0) { - uint32 num, den; - - /* - * roi width boundary calculation to know the size of pixel - * width that MDP can send faster or slower than LCD read - * pointer - */ - - num = mdp_last_dma2_update_width * mdp_last_dma2_update_height; - den = - (((mfd->panel_info.lcd.refx100 * mfd->total_lcd_lines) / - 1000) * (mdp_dma2_update_time_in_usec / 100)) / 1000; - - if (den == 0) - mfd->vsync_width_boundary[mdp_last_dma2_update_width] = - mfd->panel_info.xres + 1; - else - mfd->vsync_width_boundary[mdp_last_dma2_update_width] = - (int)(num / den); - } - - if (mfd->vsync_width_boundary[mdp_last_dma2_update_width] > - mdp_curr_dma2_update_width) { - /* MDP wrp is faster than LCD rdp */ - mdp_lcd_rd_cnt += mdp_lcd_rd_cnt_offset_fast; - } else { - /* MDP wrp is slower than LCD rdp */ - mdp_lcd_rd_cnt -= mdp_lcd_rd_cnt_offset_slow; - } - - if (mdp_lcd_rd_cnt < 0) - mdp_lcd_rd_cnt = mfd->total_lcd_lines + mdp_lcd_rd_cnt; - else if (mdp_lcd_rd_cnt > mfd->total_lcd_lines) - mdp_lcd_rd_cnt = mdp_lcd_rd_cnt - mfd->total_lcd_lines - 1; - - /* get wrt pointer position */ - start_y = mfd->ibuf.dma_y; - - /* measure line difference between start_y and rd counter */ - if (start_y > mdp_lcd_rd_cnt) { - /* - * *100 for lcd_ref_hzx100 was already multiplied by 100 - * *1000000 is for usec conversion - */ - - if ((start_y - mdp_lcd_rd_cnt) <= - mdp_vsync_usec_wait_line_too_short) - usec_wait_time = 0; - else - usec_wait_time = - ((start_y - - mdp_lcd_rd_cnt) * 1000000) / - ((mfd->total_lcd_lines * - mfd->panel_info.lcd.refx100) / 100); - } else { - if ((start_y + (mfd->total_lcd_lines - mdp_lcd_rd_cnt)) <= - mdp_vsync_usec_wait_line_too_short) - usec_wait_time = 0; - else - usec_wait_time = - ((start_y + - (mfd->total_lcd_lines - - mdp_lcd_rd_cnt)) * 1000000) / - ((mfd->total_lcd_lines * - mfd->panel_info.lcd.refx100) / 100); - } - - mdp_last_dma2_update_width = mdp_curr_dma2_update_width; - mdp_last_dma2_update_height = mdp_curr_dma2_update_height; - - if (usec_wait_time == 0) { - mdp_pipe_kickoff(term, mfd); - } else { - ktime_t wait_time; - - wait_time = ns_to_ktime(usec_wait_time * 1000); - - if (msm_fb_debug_enabled) { - vt = ktime_get_real(); - mdp_expected_usec_wait = usec_wait_time; - } - hrtimer_start(&mfd->dma_hrtimer, wait_time, HRTIMER_MODE_REL); - } -} - -#ifdef MDDI_HOST_WINDOW_WORKAROUND -static void mdp_dma2_update_sub(struct msm_fb_data_type *mfd); -void mdp_dma2_update(struct msm_fb_data_type *mfd) -{ - MDPIBUF *iBuf; - uint32 upper_height; - - if (mfd->panel.type == EXT_MDDI_PANEL) { - mdp_dma2_update_sub(mfd); - return; - } - - iBuf = &mfd->ibuf; - - upper_height = - (uint32) mddi_assign_pkt_height((uint16) iBuf->dma_w, - (uint16) iBuf->dma_h, 18); - - if (upper_height >= iBuf->dma_h) { - mdp_dma2_update_sub(mfd); - } else { - uint32 lower_height; - - /* sending the upper region first */ - lower_height = iBuf->dma_h - upper_height; - iBuf->dma_h = upper_height; - mdp_dma2_update_sub(mfd); - - /* sending the lower region second */ - iBuf->dma_h = lower_height; - iBuf->dma_y += lower_height; - iBuf->vsync_enable = FALSE; - mdp_dma2_update_sub(mfd); - } -} - -static void mdp_dma2_update_sub(struct msm_fb_data_type *mfd) -#else -void mdp_dma2_update(struct msm_fb_data_type *mfd) -#endif -{ - unsigned long flag; - static int first_vsync; - int need_wait = 0; - - down(&mfd->dma->mutex); - if ((mfd) && (mfd->panel_power_on)) { - down(&mfd->sem); - spin_lock_irqsave(&mdp_spin_lock, flag); - if (mfd->dma->busy == TRUE) - need_wait++; - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - if (need_wait) - wait_for_completion_killable(&mfd->dma->comp); - - /* schedule DMA to start */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - mfd->ibuf_flushed = TRUE; - mdp_dma2_update_lcd(mfd); - - spin_lock_irqsave(&mdp_spin_lock, flag); - mdp_enable_irq(MDP_DMA2_TERM); - mfd->dma->busy = TRUE; - INIT_COMPLETION(mfd->dma->comp); - INIT_COMPLETION(vsync_cntrl.vsync_comp); - if (!vsync_cntrl.vsync_irq_enabled && - vsync_cntrl.disabled_clocks) { - MDP_OUTP(MDP_BASE + 0x021c, 0x10); /* read pointer */ - outp32(MDP_INTR_CLEAR, MDP_PRIM_RDPTR); - mdp_intr_mask |= MDP_PRIM_RDPTR; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(MDP_VSYNC_TERM); - vsync_cntrl.vsync_dma_enabled = 1; - } - spin_unlock_irqrestore(&mdp_spin_lock, flag); - /* schedule DMA to start */ - mdp_dma_schedule(mfd, MDP_DMA2_TERM); - up(&mfd->sem); - - /* wait until Vsync finishes the current job */ - if (first_vsync) { - if (!wait_for_completion_killable_timeout - (&vsync_cntrl.vsync_comp, HZ/10)) - pr_err("Timedout DMA %s %d", __func__, - __LINE__); - } else { - first_vsync = 1; - } - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - /* signal if pan function is waiting for the update completion */ - if (mfd->pan_waiting) { - mfd->pan_waiting = FALSE; - complete(&mfd->pan_comp); - } - } - up(&mfd->dma->mutex); -} - -void mdp_dma_vsync_ctrl(int enable) -{ - unsigned long flag; - int disabled_clocks; - if (vsync_cntrl.vsync_irq_enabled == enable) - return; - - spin_lock_irqsave(&mdp_spin_lock, flag); - if (!enable) - INIT_COMPLETION(vsync_cntrl.vsync_wait); - - vsync_cntrl.vsync_irq_enabled = enable; - disabled_clocks = vsync_cntrl.disabled_clocks; - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - if (enable && disabled_clocks) - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - spin_lock_irqsave(&mdp_spin_lock, flag); - if (enable && vsync_cntrl.disabled_clocks && - !vsync_cntrl.vsync_dma_enabled) { - MDP_OUTP(MDP_BASE + 0x021c, 0x10); /* read pointer */ - outp32(MDP_INTR_CLEAR, MDP_PRIM_RDPTR); - mdp_intr_mask |= MDP_PRIM_RDPTR; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(MDP_VSYNC_TERM); - vsync_cntrl.disabled_clocks = 0; - } else if (enable && vsync_cntrl.disabled_clocks) { - vsync_cntrl.disabled_clocks = 0; - } - spin_unlock_irqrestore(&mdp_spin_lock, flag); - if (vsync_cntrl.vsync_irq_enabled && - atomic_read(&vsync_cntrl.suspend) == 0) - atomic_set(&vsync_cntrl.vsync_resume, 1); -} - -void mdp_lcd_update_workqueue_handler(struct work_struct *work) -{ - struct msm_fb_data_type *mfd = NULL; - - mfd = container_of(work, struct msm_fb_data_type, dma_update_worker); - if (mfd) - mfd->dma_fnc(mfd); -} - -void mdp_set_dma_pan_info(struct fb_info *info, struct mdp_dirty_region *dirty, - boolean sync) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - struct fb_info *fbi = mfd->fbi; - MDPIBUF *iBuf; - int bpp = info->var.bits_per_pixel / 8; - - down(&mfd->sem); - - iBuf = &mfd->ibuf; - - if (mfd->display_iova) - iBuf->buf = (uint8 *)mfd->display_iova; - else - iBuf->buf = (uint8 *) info->fix.smem_start; - - iBuf->buf += calc_fb_offset(mfd, fbi, bpp); - - iBuf->ibuf_width = info->var.xres_virtual; - iBuf->bpp = bpp; - - iBuf->vsync_enable = sync; - - if (dirty) { - /* - * ToDo: dirty region check inside var.xoffset+xres - * <-> var.yoffset+yres - */ - iBuf->dma_x = dirty->xoffset % info->var.xres; - iBuf->dma_y = dirty->yoffset % info->var.yres; - iBuf->dma_w = dirty->width; - iBuf->dma_h = dirty->height; - } else { - iBuf->dma_x = 0; - iBuf->dma_y = 0; - iBuf->dma_w = info->var.xres; - iBuf->dma_h = info->var.yres; - } - mfd->ibuf_flushed = FALSE; - up(&mfd->sem); -} - -void mdp_dma_pan_update(struct fb_info *info) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par; - MDPIBUF *iBuf; - - iBuf = &mfd->ibuf; - - if (mfd->sw_currently_refreshing) { - /* we need to wait for the pending update */ - mfd->pan_waiting = TRUE; - if (!mfd->ibuf_flushed) { - wait_for_completion_killable(&mfd->pan_comp); - } - /* waiting for this update to complete */ - mfd->pan_waiting = TRUE; - wait_for_completion_killable(&mfd->pan_comp); - } else - mfd->dma_fnc(mfd); -} - -void mdp_refresh_screen(unsigned long data) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)data; - - if ((mfd->sw_currently_refreshing) && (mfd->sw_refreshing_enable)) { - init_timer(&mfd->refresh_timer); - mfd->refresh_timer.function = mdp_refresh_screen; - mfd->refresh_timer.data = data; - - if (mfd->dma->busy) - /* come back in 1 msec */ - mfd->refresh_timer.expires = jiffies + (HZ / 1000); - else - mfd->refresh_timer.expires = - jiffies + mfd->refresh_timer_duration; - - add_timer(&mfd->refresh_timer); - - if (!mfd->dma->busy) { - if (!queue_work(mdp_dma_wq, &mfd->dma_update_worker)) { - MSM_FB_DEBUG("mdp_dma: can't queue_work! -> \ - MDP/MDDI/LCD clock speed needs to be increased\n"); - } - } - } else { - if (!mfd->hw_refresh) - complete(&mfd->refresher_comp); - } -} diff --git a/drivers/video/msm/mdp_dma_dsi_video.c b/drivers/video/msm/mdp_dma_dsi_video.c deleted file mode 100644 index c2e6bebd001fe68b79f8121243b63baeb1e35e82..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_dma_dsi_video.c +++ /dev/null @@ -1,338 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" -#include "mipi_dsi.h" - -#define DSI_VIDEO_BASE 0xF0000 -#define DMA_P_BASE 0x90000 - -static int first_pixel_start_x; -static int first_pixel_start_y; - -ssize_t mdp_dma_video_show_event(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = 0; - - INIT_COMPLETION(vsync_cntrl.vsync_wait); - - if (atomic_read(&vsync_cntrl.suspend) > 0 || - atomic_read(&vsync_cntrl.vsync_resume) == 0) - return 0; - - wait_for_completion(&vsync_cntrl.vsync_wait); - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", - ktime_to_ns(vsync_cntrl.vsync_time)); - buf[strlen(buf) + 1] = '\0'; - return ret; -} - -int mdp_dsi_video_on(struct platform_device *pdev) -{ - int dsi_width; - int dsi_height; - int dsi_bpp; - int dsi_border_clr; - int dsi_underflow_clr; - int dsi_hsync_skew; - - int hsync_period; - int hsync_ctrl; - int vsync_period; - int display_hctl; - int display_v_start; - int display_v_end; - int active_hctl; - int active_h_start; - int active_h_end; - int active_v_start; - int active_v_end; - int ctrl_polarity; - int h_back_porch; - int h_front_porch; - int v_back_porch; - int v_front_porch; - int hsync_pulse_width; - int vsync_pulse_width; - int hsync_polarity; - int vsync_polarity; - int data_en_polarity; - int hsync_start_x; - int hsync_end_x; - uint8 *buf; - uint32 dma2_cfg_reg; - - int bpp; - struct fb_info *fbi; - struct fb_var_screeninfo *var; - struct msm_fb_data_type *mfd; - int ret; - uint32_t mask, curr; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - fbi = mfd->fbi; - var = &fbi->var; - - vsync_cntrl.dev = mfd->fbi->dev; - atomic_set(&vsync_cntrl.suspend, 0); - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - - buf += calc_fb_offset(mfd, fbi, bpp); - - dma2_cfg_reg = DMA_PACK_ALIGN_LSB | DMA_OUT_SEL_DSI_VIDEO; - - if (mfd->fb_imgType == MDP_BGR_565) - dma2_cfg_reg |= DMA_PACK_PATTERN_BGR; - else if (mfd->fb_imgType == MDP_RGBA_8888) - dma2_cfg_reg |= DMA_PACK_PATTERN_BGR; - else - dma2_cfg_reg |= DMA_PACK_PATTERN_RGB; - - if (bpp == 2) - dma2_cfg_reg |= DMA_IBUF_FORMAT_RGB565; - else if (bpp == 3) - dma2_cfg_reg |= DMA_IBUF_FORMAT_RGB888; - else - dma2_cfg_reg |= DMA_IBUF_FORMAT_xRGB8888_OR_ARGB8888; - - switch (mfd->panel_info.bpp) { - case 24: - dma2_cfg_reg |= DMA_DSTC0G_8BITS | - DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS; - break; - case 18: - dma2_cfg_reg |= DMA_DSTC0G_6BITS | - DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - break; - case 16: - dma2_cfg_reg |= DMA_DSTC0G_6BITS | - DMA_DSTC1B_5BITS | DMA_DSTC2R_5BITS; - break; - default: - printk(KERN_ERR "mdp lcdc can't support format %d bpp!\n", - mfd->panel_info.bpp); - return -ENODEV; - } - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - - /* starting address */ - MDP_OUTP(MDP_BASE + DMA_P_BASE + 0x8, (uint32) buf); - - /* active window width and height */ - MDP_OUTP(MDP_BASE + DMA_P_BASE + 0x4, ((fbi->var.yres) << 16) | - (fbi->var.xres)); - - /* buffer ystride */ - MDP_OUTP(MDP_BASE + DMA_P_BASE + 0xc, fbi->fix.line_length); - - /* x/y coordinate = always 0 for lcdc */ - MDP_OUTP(MDP_BASE + DMA_P_BASE + 0x10, 0); - - /* dma config */ - curr = inpdw(MDP_BASE + DMA_P_BASE); - mask = 0x0FFFFFFF; - dma2_cfg_reg = (dma2_cfg_reg & mask) | (curr & ~mask); - MDP_OUTP(MDP_BASE + DMA_P_BASE, dma2_cfg_reg); - - /* - * DSI timing setting - */ - h_back_porch = var->left_margin; - h_front_porch = var->right_margin; - v_back_porch = var->upper_margin; - v_front_porch = var->lower_margin; - hsync_pulse_width = var->hsync_len; - vsync_pulse_width = var->vsync_len; - dsi_border_clr = mfd->panel_info.lcdc.border_clr; - dsi_underflow_clr = mfd->panel_info.lcdc.underflow_clr; - dsi_hsync_skew = mfd->panel_info.lcdc.hsync_skew; - dsi_width = mfd->panel_info.xres; - dsi_height = mfd->panel_info.yres; - dsi_bpp = mfd->panel_info.bpp; - hsync_period = h_back_porch + dsi_width + h_front_porch + 1; - hsync_ctrl = (hsync_period << 16) | hsync_pulse_width; - hsync_start_x = h_back_porch; - hsync_end_x = dsi_width + h_back_porch - 1; - display_hctl = (hsync_end_x << 16) | hsync_start_x; - - vsync_period = - (v_back_porch + dsi_height + v_front_porch + 1) * hsync_period; - display_v_start = v_back_porch * hsync_period + dsi_hsync_skew; - display_v_end = (dsi_height + v_back_porch) * hsync_period; - - active_h_start = hsync_start_x + first_pixel_start_x; - active_h_end = active_h_start + var->xres - 1; - active_hctl = ACTIVE_START_X_EN | - (active_h_end << 16) | active_h_start; - - active_v_start = display_v_start + - first_pixel_start_y * hsync_period; - active_v_end = active_v_start + (var->yres) * hsync_period - 1; - active_v_start |= ACTIVE_START_Y_EN; - - dsi_underflow_clr |= 0x80000000; /* enable recovery */ - hsync_polarity = 0; - vsync_polarity = 0; - data_en_polarity = 0; - - ctrl_polarity = (data_en_polarity << 2) | - (vsync_polarity << 1) | (hsync_polarity); - - if (!(mfd->cont_splash_done)) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, - MDP_BLOCK_POWER_OFF, FALSE); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 0); - mipi_dsi_controller_cfg(0); - } - - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x4, hsync_ctrl); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x8, vsync_period); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0xc, vsync_pulse_width); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x10, display_hctl); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x14, display_v_start); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x18, display_v_end); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x1c, active_hctl); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x20, active_v_start); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x24, active_v_end); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x28, dsi_border_clr); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x2c, dsi_underflow_clr); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x30, dsi_hsync_skew); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE + 0x38, ctrl_polarity); - - ret = panel_next_on(pdev); - if (ret == 0) { - /* enable DSI block */ - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 1); - /*Turning on DMA_P block*/ - mdp_pipe_ctrl(MDP_DMA2_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - } - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return ret; -} - -int mdp_dsi_video_off(struct platform_device *pdev) -{ - int ret = 0; - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + DSI_VIDEO_BASE, 0); - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - /*Turning off DMA_P block*/ - mdp_pipe_ctrl(MDP_DMA2_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - ret = panel_next_off(pdev); - - atomic_set(&vsync_cntrl.suspend, 1); - atomic_set(&vsync_cntrl.vsync_resume, 0); - complete_all(&vsync_cntrl.vsync_wait); - /* delay to make sure the last frame finishes */ - msleep(20); - - return ret; -} - -void mdp_dma_video_vsync_ctrl(int enable) -{ - unsigned long flag; - int disabled_clocks; - if (vsync_cntrl.vsync_irq_enabled == enable) - return; - - spin_lock_irqsave(&mdp_spin_lock, flag); - if (!enable) - INIT_COMPLETION(vsync_cntrl.vsync_wait); - - vsync_cntrl.vsync_irq_enabled = enable; - if (!enable) - vsync_cntrl.disabled_clocks = 0; - disabled_clocks = vsync_cntrl.disabled_clocks; - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - if (enable && disabled_clocks) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, LCDC_FRAME_START); - mdp_intr_mask |= LCDC_FRAME_START; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(MDP_VSYNC_TERM); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - } - if (vsync_cntrl.vsync_irq_enabled && - atomic_read(&vsync_cntrl.suspend) == 0) - atomic_set(&vsync_cntrl.vsync_resume, 1); -} - -void mdp_dsi_video_update(struct msm_fb_data_type *mfd) -{ - struct fb_info *fbi = mfd->fbi; - uint8 *buf; - int bpp; - unsigned long flag; - int irq_block = MDP_DMA2_TERM; - - if (!mfd->panel_power_on) - return; - - down(&mfd->dma->mutex); - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - - buf += calc_fb_offset(mfd, fbi, bpp); - - /* no need to power on cmd block since it's dsi mode */ - /* starting address */ - MDP_OUTP(MDP_BASE + DMA_P_BASE + 0x8, (uint32) buf); - /* enable irq */ - spin_lock_irqsave(&mdp_spin_lock, flag); - mdp_enable_irq(irq_block); - INIT_COMPLETION(mfd->dma->comp); - mfd->dma->waiting = TRUE; - - outp32(MDP_INTR_CLEAR, LCDC_FRAME_START); - mdp_intr_mask |= LCDC_FRAME_START; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - - spin_unlock_irqrestore(&mdp_spin_lock, flag); - wait_for_completion_killable(&mfd->dma->comp); - mdp_disable_irq(irq_block); - up(&mfd->dma->mutex); -} diff --git a/drivers/video/msm/mdp_dma_lcdc.c b/drivers/video/msm/mdp_dma_lcdc.c deleted file mode 100644 index cae1dc8365a509ad445887b761a4bd77e949fa68..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_dma_lcdc.c +++ /dev/null @@ -1,436 +0,0 @@ -/* Copyright (c) 2008-2009, 2012-2013 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mdp4.h" - -#ifdef CONFIG_FB_MSM_MDP40 -#define LCDC_BASE 0xC0000 -#define DTV_BASE 0xD0000 -#define DMA_E_BASE 0xB0000 -#else -#define LCDC_BASE 0xE0000 -#endif - -#define DMA_P_BASE 0x90000 - -extern spinlock_t mdp_spin_lock; -#ifndef CONFIG_FB_MSM_MDP40 -extern uint32 mdp_intr_mask; -#endif - -int first_pixel_start_x; -int first_pixel_start_y; - -ssize_t mdp_dma_lcdc_show_event(struct device *dev, - struct device_attribute *attr, char *buf) -{ - ssize_t ret = 0; - - if (atomic_read(&vsync_cntrl.suspend) > 0 || - atomic_read(&vsync_cntrl.vsync_resume) == 0) - return 0; - - INIT_COMPLETION(vsync_cntrl.vsync_wait); - - wait_for_completion(&vsync_cntrl.vsync_wait); - ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", - ktime_to_ns(vsync_cntrl.vsync_time)); - buf[strlen(buf) + 1] = '\0'; - return ret; -} - -int mdp_lcdc_on(struct platform_device *pdev) -{ - int lcdc_width; - int lcdc_height; - int lcdc_bpp; - int lcdc_border_clr; - int lcdc_underflow_clr; - int lcdc_hsync_skew; - - int hsync_period; - int hsync_ctrl; - int vsync_period; - int display_hctl; - int display_v_start; - int display_v_end; - int active_hctl; - int active_h_start; - int active_h_end; - int active_v_start; - int active_v_end; - int ctrl_polarity; - int h_back_porch; - int h_front_porch; - int v_back_porch; - int v_front_porch; - int hsync_pulse_width; - int vsync_pulse_width; - int hsync_polarity; - int vsync_polarity; - int data_en_polarity; - int hsync_start_x; - int hsync_end_x; - uint8 *buf; - int bpp; - uint32 dma2_cfg_reg; - struct fb_info *fbi; - struct fb_var_screeninfo *var; - struct msm_fb_data_type *mfd; - uint32 dma_base; - uint32 timer_base = LCDC_BASE; - uint32 block = MDP_DMA2_BLOCK; - int ret; - uint32_t mask, curr; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - fbi = mfd->fbi; - var = &fbi->var; - vsync_cntrl.dev = mfd->fbi->dev; - atomic_set(&vsync_cntrl.suspend, 0); - - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - - buf += calc_fb_offset(mfd, fbi, bpp); - - dma2_cfg_reg = DMA_PACK_ALIGN_LSB | DMA_OUT_SEL_LCDC; - - if (mfd->fb_imgType == MDP_BGR_565) - dma2_cfg_reg |= DMA_PACK_PATTERN_BGR; - else if (mfd->fb_imgType == MDP_RGBA_8888) - dma2_cfg_reg |= DMA_PACK_PATTERN_BGR; - else - dma2_cfg_reg |= DMA_PACK_PATTERN_RGB; - - if (bpp == 2) - dma2_cfg_reg |= DMA_IBUF_FORMAT_RGB565; - else if (bpp == 3) - dma2_cfg_reg |= DMA_IBUF_FORMAT_RGB888; - else - dma2_cfg_reg |= DMA_IBUF_FORMAT_xRGB8888_OR_ARGB8888; - - switch (mfd->panel_info.bpp) { - case 24: - dma2_cfg_reg |= DMA_DSTC0G_8BITS | - DMA_DSTC1B_8BITS | DMA_DSTC2R_8BITS; - break; - - case 18: - dma2_cfg_reg |= DMA_DSTC0G_6BITS | - DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - break; - - case 16: - dma2_cfg_reg |= DMA_DSTC0G_6BITS | - DMA_DSTC1B_5BITS | DMA_DSTC2R_5BITS; - break; - - default: - printk(KERN_ERR "mdp lcdc can't support format %d bpp!\n", - mfd->panel_info.bpp); - return -ENODEV; - } - - /* DMA register config */ - - dma_base = DMA_P_BASE; - -#ifdef CONFIG_FB_MSM_MDP40 - if (mfd->panel.type == HDMI_PANEL) - dma_base = DMA_E_BASE; -#endif - - /* starting address */ - MDP_OUTP(MDP_BASE + dma_base + 0x8, (uint32) buf); - /* active window width and height */ - MDP_OUTP(MDP_BASE + dma_base + 0x4, ((fbi->var.yres) << 16) | - (fbi->var.xres)); - /* buffer ystride */ - MDP_OUTP(MDP_BASE + dma_base + 0xc, fbi->fix.line_length); - /* x/y coordinate = always 0 for lcdc */ - MDP_OUTP(MDP_BASE + dma_base + 0x10, 0); - /* dma config */ - curr = inpdw(MDP_BASE + DMA_P_BASE); - mask = 0x0FFFFFFF; - dma2_cfg_reg = (dma2_cfg_reg & mask) | (curr & ~mask); - MDP_OUTP(MDP_BASE + dma_base, dma2_cfg_reg); - - /* - * LCDC timing setting - */ - h_back_porch = var->left_margin; - h_front_porch = var->right_margin; - v_back_porch = var->upper_margin; - v_front_porch = var->lower_margin; - hsync_pulse_width = var->hsync_len; - vsync_pulse_width = var->vsync_len; - lcdc_border_clr = mfd->panel_info.lcdc.border_clr; - lcdc_underflow_clr = mfd->panel_info.lcdc.underflow_clr; - lcdc_hsync_skew = mfd->panel_info.lcdc.hsync_skew; - - lcdc_width = mfd->panel_info.xres; - lcdc_height = mfd->panel_info.yres; - lcdc_bpp = mfd->panel_info.bpp; - - hsync_period = - hsync_pulse_width + h_back_porch + lcdc_width + h_front_porch; - hsync_ctrl = (hsync_period << 16) | hsync_pulse_width; - hsync_start_x = hsync_pulse_width + h_back_porch; - hsync_end_x = hsync_period - h_front_porch - 1; - display_hctl = (hsync_end_x << 16) | hsync_start_x; - - vsync_period = - (vsync_pulse_width + v_back_porch + lcdc_height + - v_front_porch) * hsync_period; - display_v_start = - (vsync_pulse_width + v_back_porch) * hsync_period + lcdc_hsync_skew; - display_v_end = - vsync_period - (v_front_porch * hsync_period) + lcdc_hsync_skew - 1; - - if (lcdc_width != var->xres) { - active_h_start = hsync_start_x + first_pixel_start_x; - active_h_end = active_h_start + var->xres - 1; - active_hctl = - ACTIVE_START_X_EN | (active_h_end << 16) | active_h_start; - } else { - active_hctl = 0; - } - - if (lcdc_height != var->yres) { - active_v_start = - display_v_start + first_pixel_start_y * hsync_period; - active_v_end = active_v_start + (var->yres) * hsync_period - 1; - active_v_start |= ACTIVE_START_Y_EN; - } else { - active_v_start = 0; - active_v_end = 0; - } - - -#ifdef CONFIG_FB_MSM_MDP40 - if (mfd->panel.type == HDMI_PANEL) { - block = MDP_DMA_E_BLOCK; - timer_base = DTV_BASE; - hsync_polarity = 0; - vsync_polarity = 0; - } else { - hsync_polarity = 1; - vsync_polarity = 1; - } - - lcdc_underflow_clr |= 0x80000000; /* enable recovery */ -#else - hsync_polarity = 0; - vsync_polarity = 0; -#endif - data_en_polarity = 0; - - ctrl_polarity = - (data_en_polarity << 2) | (vsync_polarity << 1) | (hsync_polarity); - - if (!(mfd->cont_splash_done)) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, - MDP_BLOCK_POWER_OFF, FALSE); - MDP_OUTP(MDP_BASE + timer_base, 0); - } - - MDP_OUTP(MDP_BASE + timer_base + 0x4, hsync_ctrl); - MDP_OUTP(MDP_BASE + timer_base + 0x8, vsync_period); - MDP_OUTP(MDP_BASE + timer_base + 0xc, vsync_pulse_width * hsync_period); - if (timer_base == LCDC_BASE) { - MDP_OUTP(MDP_BASE + timer_base + 0x10, display_hctl); - MDP_OUTP(MDP_BASE + timer_base + 0x14, display_v_start); - MDP_OUTP(MDP_BASE + timer_base + 0x18, display_v_end); - MDP_OUTP(MDP_BASE + timer_base + 0x28, lcdc_border_clr); - MDP_OUTP(MDP_BASE + timer_base + 0x2c, lcdc_underflow_clr); - MDP_OUTP(MDP_BASE + timer_base + 0x30, lcdc_hsync_skew); - MDP_OUTP(MDP_BASE + timer_base + 0x38, ctrl_polarity); - MDP_OUTP(MDP_BASE + timer_base + 0x1c, active_hctl); - MDP_OUTP(MDP_BASE + timer_base + 0x20, active_v_start); - MDP_OUTP(MDP_BASE + timer_base + 0x24, active_v_end); - } else { - MDP_OUTP(MDP_BASE + timer_base + 0x18, display_hctl); - MDP_OUTP(MDP_BASE + timer_base + 0x1c, display_v_start); - MDP_OUTP(MDP_BASE + timer_base + 0x20, display_v_end); - MDP_OUTP(MDP_BASE + timer_base + 0x40, lcdc_border_clr); - MDP_OUTP(MDP_BASE + timer_base + 0x44, lcdc_underflow_clr); - MDP_OUTP(MDP_BASE + timer_base + 0x48, lcdc_hsync_skew); - MDP_OUTP(MDP_BASE + timer_base + 0x50, ctrl_polarity); - MDP_OUTP(MDP_BASE + timer_base + 0x2c, active_hctl); - MDP_OUTP(MDP_BASE + timer_base + 0x30, active_v_start); - MDP_OUTP(MDP_BASE + timer_base + 0x38, active_v_end); - } - - ret = panel_next_on(pdev); - if (ret == 0) { - /* enable LCDC block */ - MDP_OUTP(MDP_BASE + timer_base, 1); - mdp_pipe_ctrl(block, MDP_BLOCK_POWER_ON, FALSE); - } - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - return ret; -} - -int mdp_lcdc_off(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd; - uint32 timer_base = LCDC_BASE; - uint32 block = MDP_DMA2_BLOCK; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - -#ifdef CONFIG_FB_MSM_MDP40 - if (mfd->panel.type == HDMI_PANEL) { - block = MDP_DMA_E_BLOCK; - timer_base = DTV_BASE; - } -#endif - - down(&mfd->dma->mutex); - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + timer_base, 0); - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - mdp_pipe_ctrl(block, MDP_BLOCK_POWER_OFF, FALSE); - - ret = panel_next_off(pdev); - up(&mfd->dma->mutex); - atomic_set(&vsync_cntrl.suspend, 1); - atomic_set(&vsync_cntrl.vsync_resume, 0); - complete_all(&vsync_cntrl.vsync_wait); - - /* delay to make sure the last frame finishes */ - msleep(16); - - return ret; -} - -void mdp_dma_lcdc_vsync_ctrl(int enable) -{ - unsigned long flag; - int disabled_clocks; - if (vsync_cntrl.vsync_irq_enabled == enable) - return; - - spin_lock_irqsave(&mdp_spin_lock, flag); - if (!enable) - INIT_COMPLETION(vsync_cntrl.vsync_wait); - - vsync_cntrl.vsync_irq_enabled = enable; - if (!enable) - vsync_cntrl.disabled_clocks = 0; - disabled_clocks = vsync_cntrl.disabled_clocks; - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - if (enable && disabled_clocks) { - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - spin_lock_irqsave(&mdp_spin_lock, flag); - outp32(MDP_INTR_CLEAR, LCDC_FRAME_START); - mdp_intr_mask |= LCDC_FRAME_START; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - mdp_enable_irq(MDP_VSYNC_TERM); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - } - - if (vsync_cntrl.vsync_irq_enabled && - atomic_read(&vsync_cntrl.suspend) == 0) - atomic_set(&vsync_cntrl.vsync_resume, 1); -} - -void mdp_lcdc_update(struct msm_fb_data_type *mfd) -{ - struct fb_info *fbi = mfd->fbi; - uint8 *buf; - int bpp; - unsigned long flag; - uint32 dma_base; - int irq_block = MDP_DMA2_TERM; -#ifdef CONFIG_FB_MSM_MDP40 - int intr = INTR_DMA_P_DONE; -#endif - - if (!mfd->panel_power_on) - return; - - down(&mfd->dma->mutex); - /* no need to power on cmd block since it's lcdc mode */ - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - - buf += calc_fb_offset(mfd, fbi, bpp); - - dma_base = DMA_P_BASE; - -#ifdef CONFIG_FB_MSM_MDP40 - if (mfd->panel.type == HDMI_PANEL) { - intr = INTR_DMA_E_DONE; - irq_block = MDP_DMA_E_TERM; - dma_base = DMA_E_BASE; - } -#endif - - /* starting address */ - MDP_OUTP(MDP_BASE + dma_base + 0x8, (uint32) buf); - - /* enable LCDC irq */ - spin_lock_irqsave(&mdp_spin_lock, flag); - mdp_enable_irq(irq_block); - INIT_COMPLETION(mfd->dma->comp); - mfd->dma->waiting = TRUE; -#ifdef CONFIG_FB_MSM_MDP40 - outp32(MDP_INTR_CLEAR, intr); - mdp_intr_mask |= intr; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); -#else - outp32(MDP_INTR_CLEAR, LCDC_FRAME_START); - mdp_intr_mask |= LCDC_FRAME_START; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); -#endif - spin_unlock_irqrestore(&mdp_spin_lock, flag); - wait_for_completion_killable(&mfd->dma->comp); - mdp_disable_irq(irq_block); - up(&mfd->dma->mutex); -} diff --git a/drivers/video/msm/mdp_dma_s.c b/drivers/video/msm/mdp_dma_s.c deleted file mode 100644 index f5a7258275b313620767c055d3f97bc03f55a763..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_dma_s.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright (c) 2008-2009, 2013, 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include "mdp.h" -#include "msm_fb.h" - -static void mdp_dma_s_update_lcd(struct msm_fb_data_type *mfd) -{ - MDPIBUF *iBuf = &mfd->ibuf; - int mddi_dest = FALSE; - uint32 outBpp = iBuf->bpp; - uint32 dma_s_cfg_reg; - uint8 *src; - struct msm_fb_panel_data *pdata = - (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; - - dma_s_cfg_reg = DMA_PACK_TIGHT | DMA_PACK_ALIGN_LSB | - DMA_OUT_SEL_AHB | DMA_IBUF_NONCONTIGUOUS; - - if (mfd->fb_imgType == MDP_BGR_565) - dma_s_cfg_reg |= DMA_PACK_PATTERN_BGR; - else - dma_s_cfg_reg |= DMA_PACK_PATTERN_RGB; - - if (outBpp == 4) - dma_s_cfg_reg |= DMA_IBUF_C3ALPHA_EN; - - if (outBpp == 2) - dma_s_cfg_reg |= DMA_IBUF_FORMAT_RGB565; - - if (mfd->panel_info.pdest != DISPLAY_2) { - printk(KERN_ERR "error: non-secondary type through dma_s!\n"); - return; - } - - if (mfd->panel_info.type == MDDI_PANEL || - mfd->panel_info.type == EXT_MDDI_PANEL) { - dma_s_cfg_reg |= DMA_OUT_SEL_MDDI; - mddi_dest = TRUE; - } else { - dma_s_cfg_reg |= DMA_AHBM_LCD_SEL_SECONDARY; - outp32(MDP_EBI2_LCD1, mfd->data_port_phys); - } - - src = (uint8 *) iBuf->buf; - /* starting input address */ - src += (iBuf->dma_x + iBuf->dma_y * iBuf->ibuf_width) * outBpp; - - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - /* PIXELSIZE */ - if (mfd->panel_info.type == MDDI_PANEL) { - MDP_OUTP(MDP_BASE + 0xa0004, - (iBuf->dma_h << 16 | iBuf->dma_w)); - MDP_OUTP(MDP_BASE + 0xa0008, src); /* ibuf address */ - MDP_OUTP(MDP_BASE + 0xa000c, - iBuf->ibuf_width * outBpp);/* ystride */ - } else { - MDP_OUTP(MDP_BASE + 0xb0004, - (iBuf->dma_h << 16 | iBuf->dma_w)); - MDP_OUTP(MDP_BASE + 0xb0008, src); /* ibuf address */ - MDP_OUTP(MDP_BASE + 0xb000c, - iBuf->ibuf_width * outBpp);/* ystride */ - } - - if (mfd->panel_info.bpp == 18) { - dma_s_cfg_reg |= DMA_DSTC0G_6BITS | /* 666 18BPP */ - DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - } else { - dma_s_cfg_reg |= DMA_DSTC0G_6BITS | /* 565 16BPP */ - DMA_DSTC1B_5BITS | DMA_DSTC2R_5BITS; - } - - if (mddi_dest) { - if (mfd->panel_info.type == MDDI_PANEL) { - MDP_OUTP(MDP_BASE + 0xa0010, - (iBuf->dma_y << 16) | iBuf->dma_x); - MDP_OUTP(MDP_BASE + 0x00090, 1); - } else { - MDP_OUTP(MDP_BASE + 0xb0010, - (iBuf->dma_y << 16) | iBuf->dma_x); - MDP_OUTP(MDP_BASE + 0x00090, 2); - } - MDP_OUTP(MDP_BASE + 0x00094, - (MDDI_VDO_PACKET_DESC << 16) | - mfd->panel_info.mddi.vdopkt); - } else { - /* setting LCDC write window */ - pdata->set_rect(iBuf->dma_x, iBuf->dma_y, iBuf->dma_w, - iBuf->dma_h); - } - - if (mfd->panel_info.type == MDDI_PANEL) - MDP_OUTP(MDP_BASE + 0xa0000, dma_s_cfg_reg); - else - MDP_OUTP(MDP_BASE + 0xb0000, dma_s_cfg_reg); - - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - if (mfd->panel_info.type == MDDI_PANEL) - mdp_pipe_kickoff(MDP_DMA_S_TERM, mfd); - else - mdp_pipe_kickoff(MDP_DMA_E_TERM, mfd); - -} - -void mdp_dma_s_update(struct msm_fb_data_type *mfd) -{ - down(&mfd->dma->mutex); - if ((mfd) && (!mfd->dma->busy) && (mfd->panel_power_on)) { - down(&mfd->sem); - mdp_enable_irq(MDP_DMA_S_TERM); - if (mfd->panel_info.type == MDDI_PANEL) - mdp_enable_irq(MDP_DMA_S_TERM); - else - mdp_enable_irq(MDP_DMA_E_TERM); - mfd->dma->busy = TRUE; - INIT_COMPLETION(mfd->dma->comp); - mfd->ibuf_flushed = TRUE; - mdp_dma_s_update_lcd(mfd); - up(&mfd->sem); - - /* wait until DMA finishes the current job */ - wait_for_completion_killable(&mfd->dma->comp); - if (mfd->panel_info.type == MDDI_PANEL) - mdp_disable_irq(MDP_DMA_S_TERM); - else - mdp_disable_irq(MDP_DMA_E_TERM); - - /* signal if pan function is waiting for the update completion */ - if (mfd->pan_waiting) { - mfd->pan_waiting = FALSE; - complete(&mfd->pan_comp); - } - } - up(&mfd->dma->mutex); -} diff --git a/drivers/video/msm/mdp_dma_tv.c b/drivers/video/msm/mdp_dma_tv.c deleted file mode 100644 index cc75531c652a8451c121ef016fd3575e702c8bb6..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_dma_tv.c +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright (c) 2008-2009, 2012-2013 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include "mdp.h" -#include "msm_fb.h" - -extern spinlock_t mdp_spin_lock; -extern uint32 mdp_intr_mask; - -int mdp_dma3_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct fb_info *fbi; - uint8 *buf; - int bpp; - int ret = 0; - - mfd = (struct msm_fb_data_type *)platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - fbi = mfd->fbi; - - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - - buf += calc_fb_offset(mfd, fbi, bpp); - - /* starting address[31..8] of Video frame buffer is CS0 */ - MDP_OUTP(MDP_BASE + 0xC0008, (uint32) buf >> 3); - - mdp_pipe_ctrl(MDP_DMA3_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - MDP_OUTP(MDP_BASE + 0xC0004, 0x4c60674); /* flicker filter enabled */ - MDP_OUTP(MDP_BASE + 0xC0010, 0x20); /* sobel treshold */ - - MDP_OUTP(MDP_BASE + 0xC0018, 0xeb0010); /* Y Max, Y min */ - MDP_OUTP(MDP_BASE + 0xC001C, 0xf00010); /* Cb Max, Cb min */ - MDP_OUTP(MDP_BASE + 0xC0020, 0xf00010); /* Cb Max, Cb min */ - - MDP_OUTP(MDP_BASE + 0xC000C, 0x67686970); /* add a few chars for CC */ - MDP_OUTP(MDP_BASE + 0xC0000, 0x1); /* MDP tv out enable */ - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - ret = panel_next_on(pdev); - - return ret; -} - -int mdp_dma3_off(struct platform_device *pdev) -{ - int ret = 0; - - ret = panel_next_off(pdev); - if (ret) - return ret; - - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - MDP_OUTP(MDP_BASE + 0xC0000, 0x0); - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - mdp_pipe_ctrl(MDP_DMA3_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); - - /* delay to make sure the last frame finishes */ - msleep(16); - - return ret; -} - -void mdp_dma3_update(struct msm_fb_data_type *mfd) -{ - struct fb_info *fbi = mfd->fbi; - uint8 *buf; - int bpp; - unsigned long flag; - - if (!mfd->panel_power_on) - return; - - /* no need to power on cmd block since dma3 is running */ - bpp = fbi->var.bits_per_pixel / 8; - buf = (uint8 *) fbi->fix.smem_start; - - buf += calc_fb_offset(mfd, fbi, bpp); - - MDP_OUTP(MDP_BASE + 0xC0008, (uint32) buf >> 3); - - spin_lock_irqsave(&mdp_spin_lock, flag); - mdp_enable_irq(MDP_DMA3_TERM); - INIT_COMPLETION(mfd->dma->comp); - mfd->dma->waiting = TRUE; - - outp32(MDP_INTR_CLEAR, TV_OUT_DMA3_START); - mdp_intr_mask |= TV_OUT_DMA3_START; - outp32(MDP_INTR_ENABLE, mdp_intr_mask); - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - wait_for_completion_killable(&mfd->dma->comp); - mdp_disable_irq(MDP_DMA3_TERM); -} diff --git a/drivers/video/msm/mdp_hw40.c b/drivers/video/msm/mdp_hw40.c deleted file mode 100644 index 3290ab9d1fd7538a4d085acad2877e8c2ffb5a41..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_hw40.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2010 Google, Inc. - * Author: Dima Zavin - * - * Based on code from The Linux Foundation. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include - -#include "mdp_hw.h" - -static void mdp_dma_to_mddi(void *priv, uint32_t addr, uint32_t stride, - uint32_t width, uint32_t height, uint32_t x, - uint32_t y) -{ - struct mdp_info *mdp = priv; - uint32_t dma2_cfg; - uint16_t ld_param = 0; /* 0=PRIM, 1=SECD, 2=EXT */ - - dma2_cfg = DMA_PACK_TIGHT | - DMA_PACK_ALIGN_LSB; - - dma2_cfg |= mdp->dma_format; - dma2_cfg |= mdp->dma_pack_pattern; - dma2_cfg |= DMA_DITHER_EN; - - /* 666 18BPP */ - dma2_cfg |= DMA_DSTC0G_6BITS | DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - - /* setup size, address, and stride */ - mdp_writel(mdp, (height << 16) | (width), MDP_DMA_P_SIZE); - mdp_writel(mdp, addr, MDP_DMA_P_IBUF_ADDR); - mdp_writel(mdp, stride, MDP_DMA_P_IBUF_Y_STRIDE); - - /* set y & x offset and MDDI transaction parameters */ - mdp_writel(mdp, (y << 16) | (x), MDP_DMA_P_OUT_XY); - mdp_writel(mdp, ld_param, MDP_MDDI_PARAM_WR_SEL); - mdp_writel(mdp, (MDDI_VDO_PACKET_DESC << 16) | MDDI_VDO_PACKET_PRIM, - MDP_MDDI_PARAM); - - mdp_writel(mdp, 0x1, MDP_MDDI_DATA_XFR); - mdp_writel(mdp, dma2_cfg, MDP_DMA_P_CONFIG); - mdp_writel(mdp, 0, MDP_DMA_P_START); -} - -int mdp_hw_init(struct mdp_info *mdp) -{ - int ret; - - ret = mdp_out_if_register(&mdp->mdp_dev, MSM_MDDI_PMDH_INTERFACE, mdp, - MDP_DMA_P_DONE, mdp_dma_to_mddi); - if (ret) - return ret; - - mdp_writel(mdp, 0, MDP_INTR_ENABLE); - mdp_writel(mdp, 0, MDP_DMA_P_HIST_INTR_ENABLE); - - /* XXX: why set this? QCT says it should be > mdp_pclk, - * but they never set the clkrate of pclk */ - clk_set_rate(mdp->clk, 122880000); /* 122.88 Mhz */ - pr_info("%s: mdp_clk=%lu\n", __func__, clk_get_rate(mdp->clk)); - - /* TODO: Configure the VG/RGB pipes fetch data */ - - /* this should work for any mdp_clk freq. - * TODO: use different value for mdp_clk freqs >= 90Mhz */ - mdp_writel(mdp, 0x27, MDP_DMA_P_FETCH_CFG); /* 8 bytes-burst x 8 req */ - - mdp_writel(mdp, 0x3, MDP_EBI2_PORTMAP_MODE); - - /* 3 pending requests */ - mdp_writel(mdp, 0x02222, MDP_MAX_RD_PENDING_CMD_CONFIG); - - /* no overlay processing, sw controls everything */ - mdp_writel(mdp, 0, MDP_LAYERMIXER_IN_CFG); - mdp_writel(mdp, 1 << 3, MDP_OVERLAYPROC0_CFG); - mdp_writel(mdp, 1 << 3, MDP_OVERLAYPROC1_CFG); - - /* XXX: HACK! hardcode to do mddi on primary */ - mdp_writel(mdp, 0x2, MDP_DISP_INTF_SEL); - return 0; -} - diff --git a/drivers/video/msm/mdp_hw_init.c b/drivers/video/msm/mdp_hw_init.c deleted file mode 100644 index ad2789b2bddada75f4c88d815f079eda01474335..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_hw_init.c +++ /dev/null @@ -1,715 +0,0 @@ -/* Copyright (c) 2008-2009, 2012 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 "mdp.h" - -/* mdp primary csc limit vector */ -uint32 mdp_plv[] = { 0x10, 0xeb, 0x10, 0xf0 }; - -/* Color Coefficient matrix for YUV -> RGB */ -struct mdp_ccs mdp_ccs_yuv2rgb = { - MDP_CCS_YUV2RGB, - { - 0x254, - 0x000, - 0x331, - 0x254, - 0xff38, - 0xfe61, - 0x254, - 0x409, - 0x000, - }, - { -#ifdef CONFIG_FB_MSM_MDP31 - 0x1f0, - 0x180, - 0x180 -#else - 0x10, - 0x80, - 0x80 -#endif - } -}; - -/* Color Coefficient matrix for RGB -> YUV */ -struct mdp_ccs mdp_ccs_rgb2yuv = { - MDP_CCS_RGB2YUV, - { - 0x83, - 0x102, - 0x32, - 0xffb5, - 0xff6c, - 0xe1, - 0xe1, - 0xff45, - 0xffdc, - }, -#ifdef CONFIG_FB_MSM_MDP31 - { - 0x10, - 0x80, - 0x80 - } -#endif -}; - -static void mdp_load_lut_param(void) -{ - outpdw(MDP_BASE + 0x40800, 0x0); - outpdw(MDP_BASE + 0x40804, 0x151515); - outpdw(MDP_BASE + 0x40808, 0x1d1d1d); - outpdw(MDP_BASE + 0x4080c, 0x232323); - outpdw(MDP_BASE + 0x40810, 0x272727); - outpdw(MDP_BASE + 0x40814, 0x2b2b2b); - outpdw(MDP_BASE + 0x40818, 0x2f2f2f); - outpdw(MDP_BASE + 0x4081c, 0x333333); - outpdw(MDP_BASE + 0x40820, 0x363636); - outpdw(MDP_BASE + 0x40824, 0x393939); - outpdw(MDP_BASE + 0x40828, 0x3b3b3b); - outpdw(MDP_BASE + 0x4082c, 0x3e3e3e); - outpdw(MDP_BASE + 0x40830, 0x404040); - outpdw(MDP_BASE + 0x40834, 0x434343); - outpdw(MDP_BASE + 0x40838, 0x454545); - outpdw(MDP_BASE + 0x4083c, 0x474747); - outpdw(MDP_BASE + 0x40840, 0x494949); - outpdw(MDP_BASE + 0x40844, 0x4b4b4b); - outpdw(MDP_BASE + 0x40848, 0x4d4d4d); - outpdw(MDP_BASE + 0x4084c, 0x4f4f4f); - outpdw(MDP_BASE + 0x40850, 0x515151); - outpdw(MDP_BASE + 0x40854, 0x535353); - outpdw(MDP_BASE + 0x40858, 0x555555); - outpdw(MDP_BASE + 0x4085c, 0x565656); - outpdw(MDP_BASE + 0x40860, 0x585858); - outpdw(MDP_BASE + 0x40864, 0x5a5a5a); - outpdw(MDP_BASE + 0x40868, 0x5b5b5b); - outpdw(MDP_BASE + 0x4086c, 0x5d5d5d); - outpdw(MDP_BASE + 0x40870, 0x5e5e5e); - outpdw(MDP_BASE + 0x40874, 0x606060); - outpdw(MDP_BASE + 0x40878, 0x616161); - outpdw(MDP_BASE + 0x4087c, 0x636363); - outpdw(MDP_BASE + 0x40880, 0x646464); - outpdw(MDP_BASE + 0x40884, 0x666666); - outpdw(MDP_BASE + 0x40888, 0x676767); - outpdw(MDP_BASE + 0x4088c, 0x686868); - outpdw(MDP_BASE + 0x40890, 0x6a6a6a); - outpdw(MDP_BASE + 0x40894, 0x6b6b6b); - outpdw(MDP_BASE + 0x40898, 0x6c6c6c); - outpdw(MDP_BASE + 0x4089c, 0x6e6e6e); - outpdw(MDP_BASE + 0x408a0, 0x6f6f6f); - outpdw(MDP_BASE + 0x408a4, 0x707070); - outpdw(MDP_BASE + 0x408a8, 0x717171); - outpdw(MDP_BASE + 0x408ac, 0x727272); - outpdw(MDP_BASE + 0x408b0, 0x747474); - outpdw(MDP_BASE + 0x408b4, 0x757575); - outpdw(MDP_BASE + 0x408b8, 0x767676); - outpdw(MDP_BASE + 0x408bc, 0x777777); - outpdw(MDP_BASE + 0x408c0, 0x787878); - outpdw(MDP_BASE + 0x408c4, 0x797979); - outpdw(MDP_BASE + 0x408c8, 0x7a7a7a); - outpdw(MDP_BASE + 0x408cc, 0x7c7c7c); - outpdw(MDP_BASE + 0x408d0, 0x7d7d7d); - outpdw(MDP_BASE + 0x408d4, 0x7e7e7e); - outpdw(MDP_BASE + 0x408d8, 0x7f7f7f); - outpdw(MDP_BASE + 0x408dc, 0x808080); - outpdw(MDP_BASE + 0x408e0, 0x818181); - outpdw(MDP_BASE + 0x408e4, 0x828282); - outpdw(MDP_BASE + 0x408e8, 0x838383); - outpdw(MDP_BASE + 0x408ec, 0x848484); - outpdw(MDP_BASE + 0x408f0, 0x858585); - outpdw(MDP_BASE + 0x408f4, 0x868686); - outpdw(MDP_BASE + 0x408f8, 0x878787); - outpdw(MDP_BASE + 0x408fc, 0x888888); - outpdw(MDP_BASE + 0x40900, 0x898989); - outpdw(MDP_BASE + 0x40904, 0x8a8a8a); - outpdw(MDP_BASE + 0x40908, 0x8b8b8b); - outpdw(MDP_BASE + 0x4090c, 0x8c8c8c); - outpdw(MDP_BASE + 0x40910, 0x8d8d8d); - outpdw(MDP_BASE + 0x40914, 0x8e8e8e); - outpdw(MDP_BASE + 0x40918, 0x8f8f8f); - outpdw(MDP_BASE + 0x4091c, 0x8f8f8f); - outpdw(MDP_BASE + 0x40920, 0x909090); - outpdw(MDP_BASE + 0x40924, 0x919191); - outpdw(MDP_BASE + 0x40928, 0x929292); - outpdw(MDP_BASE + 0x4092c, 0x939393); - outpdw(MDP_BASE + 0x40930, 0x949494); - outpdw(MDP_BASE + 0x40934, 0x959595); - outpdw(MDP_BASE + 0x40938, 0x969696); - outpdw(MDP_BASE + 0x4093c, 0x969696); - outpdw(MDP_BASE + 0x40940, 0x979797); - outpdw(MDP_BASE + 0x40944, 0x989898); - outpdw(MDP_BASE + 0x40948, 0x999999); - outpdw(MDP_BASE + 0x4094c, 0x9a9a9a); - outpdw(MDP_BASE + 0x40950, 0x9b9b9b); - outpdw(MDP_BASE + 0x40954, 0x9c9c9c); - outpdw(MDP_BASE + 0x40958, 0x9c9c9c); - outpdw(MDP_BASE + 0x4095c, 0x9d9d9d); - outpdw(MDP_BASE + 0x40960, 0x9e9e9e); - outpdw(MDP_BASE + 0x40964, 0x9f9f9f); - outpdw(MDP_BASE + 0x40968, 0xa0a0a0); - outpdw(MDP_BASE + 0x4096c, 0xa0a0a0); - outpdw(MDP_BASE + 0x40970, 0xa1a1a1); - outpdw(MDP_BASE + 0x40974, 0xa2a2a2); - outpdw(MDP_BASE + 0x40978, 0xa3a3a3); - outpdw(MDP_BASE + 0x4097c, 0xa4a4a4); - outpdw(MDP_BASE + 0x40980, 0xa4a4a4); - outpdw(MDP_BASE + 0x40984, 0xa5a5a5); - outpdw(MDP_BASE + 0x40988, 0xa6a6a6); - outpdw(MDP_BASE + 0x4098c, 0xa7a7a7); - outpdw(MDP_BASE + 0x40990, 0xa7a7a7); - outpdw(MDP_BASE + 0x40994, 0xa8a8a8); - outpdw(MDP_BASE + 0x40998, 0xa9a9a9); - outpdw(MDP_BASE + 0x4099c, 0xaaaaaa); - outpdw(MDP_BASE + 0x409a0, 0xaaaaaa); - outpdw(MDP_BASE + 0x409a4, 0xababab); - outpdw(MDP_BASE + 0x409a8, 0xacacac); - outpdw(MDP_BASE + 0x409ac, 0xadadad); - outpdw(MDP_BASE + 0x409b0, 0xadadad); - outpdw(MDP_BASE + 0x409b4, 0xaeaeae); - outpdw(MDP_BASE + 0x409b8, 0xafafaf); - outpdw(MDP_BASE + 0x409bc, 0xafafaf); - outpdw(MDP_BASE + 0x409c0, 0xb0b0b0); - outpdw(MDP_BASE + 0x409c4, 0xb1b1b1); - outpdw(MDP_BASE + 0x409c8, 0xb2b2b2); - outpdw(MDP_BASE + 0x409cc, 0xb2b2b2); - outpdw(MDP_BASE + 0x409d0, 0xb3b3b3); - outpdw(MDP_BASE + 0x409d4, 0xb4b4b4); - outpdw(MDP_BASE + 0x409d8, 0xb4b4b4); - outpdw(MDP_BASE + 0x409dc, 0xb5b5b5); - outpdw(MDP_BASE + 0x409e0, 0xb6b6b6); - outpdw(MDP_BASE + 0x409e4, 0xb6b6b6); - outpdw(MDP_BASE + 0x409e8, 0xb7b7b7); - outpdw(MDP_BASE + 0x409ec, 0xb8b8b8); - outpdw(MDP_BASE + 0x409f0, 0xb8b8b8); - outpdw(MDP_BASE + 0x409f4, 0xb9b9b9); - outpdw(MDP_BASE + 0x409f8, 0xbababa); - outpdw(MDP_BASE + 0x409fc, 0xbababa); - outpdw(MDP_BASE + 0x40a00, 0xbbbbbb); - outpdw(MDP_BASE + 0x40a04, 0xbcbcbc); - outpdw(MDP_BASE + 0x40a08, 0xbcbcbc); - outpdw(MDP_BASE + 0x40a0c, 0xbdbdbd); - outpdw(MDP_BASE + 0x40a10, 0xbebebe); - outpdw(MDP_BASE + 0x40a14, 0xbebebe); - outpdw(MDP_BASE + 0x40a18, 0xbfbfbf); - outpdw(MDP_BASE + 0x40a1c, 0xc0c0c0); - outpdw(MDP_BASE + 0x40a20, 0xc0c0c0); - outpdw(MDP_BASE + 0x40a24, 0xc1c1c1); - outpdw(MDP_BASE + 0x40a28, 0xc1c1c1); - outpdw(MDP_BASE + 0x40a2c, 0xc2c2c2); - outpdw(MDP_BASE + 0x40a30, 0xc3c3c3); - outpdw(MDP_BASE + 0x40a34, 0xc3c3c3); - outpdw(MDP_BASE + 0x40a38, 0xc4c4c4); - outpdw(MDP_BASE + 0x40a3c, 0xc5c5c5); - outpdw(MDP_BASE + 0x40a40, 0xc5c5c5); - outpdw(MDP_BASE + 0x40a44, 0xc6c6c6); - outpdw(MDP_BASE + 0x40a48, 0xc6c6c6); - outpdw(MDP_BASE + 0x40a4c, 0xc7c7c7); - outpdw(MDP_BASE + 0x40a50, 0xc8c8c8); - outpdw(MDP_BASE + 0x40a54, 0xc8c8c8); - outpdw(MDP_BASE + 0x40a58, 0xc9c9c9); - outpdw(MDP_BASE + 0x40a5c, 0xc9c9c9); - outpdw(MDP_BASE + 0x40a60, 0xcacaca); - outpdw(MDP_BASE + 0x40a64, 0xcbcbcb); - outpdw(MDP_BASE + 0x40a68, 0xcbcbcb); - outpdw(MDP_BASE + 0x40a6c, 0xcccccc); - outpdw(MDP_BASE + 0x40a70, 0xcccccc); - outpdw(MDP_BASE + 0x40a74, 0xcdcdcd); - outpdw(MDP_BASE + 0x40a78, 0xcecece); - outpdw(MDP_BASE + 0x40a7c, 0xcecece); - outpdw(MDP_BASE + 0x40a80, 0xcfcfcf); - outpdw(MDP_BASE + 0x40a84, 0xcfcfcf); - outpdw(MDP_BASE + 0x40a88, 0xd0d0d0); - outpdw(MDP_BASE + 0x40a8c, 0xd0d0d0); - outpdw(MDP_BASE + 0x40a90, 0xd1d1d1); - outpdw(MDP_BASE + 0x40a94, 0xd2d2d2); - outpdw(MDP_BASE + 0x40a98, 0xd2d2d2); - outpdw(MDP_BASE + 0x40a9c, 0xd3d3d3); - outpdw(MDP_BASE + 0x40aa0, 0xd3d3d3); - outpdw(MDP_BASE + 0x40aa4, 0xd4d4d4); - outpdw(MDP_BASE + 0x40aa8, 0xd4d4d4); - outpdw(MDP_BASE + 0x40aac, 0xd5d5d5); - outpdw(MDP_BASE + 0x40ab0, 0xd6d6d6); - outpdw(MDP_BASE + 0x40ab4, 0xd6d6d6); - outpdw(MDP_BASE + 0x40ab8, 0xd7d7d7); - outpdw(MDP_BASE + 0x40abc, 0xd7d7d7); - outpdw(MDP_BASE + 0x40ac0, 0xd8d8d8); - outpdw(MDP_BASE + 0x40ac4, 0xd8d8d8); - outpdw(MDP_BASE + 0x40ac8, 0xd9d9d9); - outpdw(MDP_BASE + 0x40acc, 0xd9d9d9); - outpdw(MDP_BASE + 0x40ad0, 0xdadada); - outpdw(MDP_BASE + 0x40ad4, 0xdbdbdb); - outpdw(MDP_BASE + 0x40ad8, 0xdbdbdb); - outpdw(MDP_BASE + 0x40adc, 0xdcdcdc); - outpdw(MDP_BASE + 0x40ae0, 0xdcdcdc); - outpdw(MDP_BASE + 0x40ae4, 0xdddddd); - outpdw(MDP_BASE + 0x40ae8, 0xdddddd); - outpdw(MDP_BASE + 0x40aec, 0xdedede); - outpdw(MDP_BASE + 0x40af0, 0xdedede); - outpdw(MDP_BASE + 0x40af4, 0xdfdfdf); - outpdw(MDP_BASE + 0x40af8, 0xdfdfdf); - outpdw(MDP_BASE + 0x40afc, 0xe0e0e0); - outpdw(MDP_BASE + 0x40b00, 0xe0e0e0); - outpdw(MDP_BASE + 0x40b04, 0xe1e1e1); - outpdw(MDP_BASE + 0x40b08, 0xe1e1e1); - outpdw(MDP_BASE + 0x40b0c, 0xe2e2e2); - outpdw(MDP_BASE + 0x40b10, 0xe3e3e3); - outpdw(MDP_BASE + 0x40b14, 0xe3e3e3); - outpdw(MDP_BASE + 0x40b18, 0xe4e4e4); - outpdw(MDP_BASE + 0x40b1c, 0xe4e4e4); - outpdw(MDP_BASE + 0x40b20, 0xe5e5e5); - outpdw(MDP_BASE + 0x40b24, 0xe5e5e5); - outpdw(MDP_BASE + 0x40b28, 0xe6e6e6); - outpdw(MDP_BASE + 0x40b2c, 0xe6e6e6); - outpdw(MDP_BASE + 0x40b30, 0xe7e7e7); - outpdw(MDP_BASE + 0x40b34, 0xe7e7e7); - outpdw(MDP_BASE + 0x40b38, 0xe8e8e8); - outpdw(MDP_BASE + 0x40b3c, 0xe8e8e8); - outpdw(MDP_BASE + 0x40b40, 0xe9e9e9); - outpdw(MDP_BASE + 0x40b44, 0xe9e9e9); - outpdw(MDP_BASE + 0x40b48, 0xeaeaea); - outpdw(MDP_BASE + 0x40b4c, 0xeaeaea); - outpdw(MDP_BASE + 0x40b50, 0xebebeb); - outpdw(MDP_BASE + 0x40b54, 0xebebeb); - outpdw(MDP_BASE + 0x40b58, 0xececec); - outpdw(MDP_BASE + 0x40b5c, 0xececec); - outpdw(MDP_BASE + 0x40b60, 0xededed); - outpdw(MDP_BASE + 0x40b64, 0xededed); - outpdw(MDP_BASE + 0x40b68, 0xeeeeee); - outpdw(MDP_BASE + 0x40b6c, 0xeeeeee); - outpdw(MDP_BASE + 0x40b70, 0xefefef); - outpdw(MDP_BASE + 0x40b74, 0xefefef); - outpdw(MDP_BASE + 0x40b78, 0xf0f0f0); - outpdw(MDP_BASE + 0x40b7c, 0xf0f0f0); - outpdw(MDP_BASE + 0x40b80, 0xf1f1f1); - outpdw(MDP_BASE + 0x40b84, 0xf1f1f1); - outpdw(MDP_BASE + 0x40b88, 0xf2f2f2); - outpdw(MDP_BASE + 0x40b8c, 0xf2f2f2); - outpdw(MDP_BASE + 0x40b90, 0xf2f2f2); - outpdw(MDP_BASE + 0x40b94, 0xf3f3f3); - outpdw(MDP_BASE + 0x40b98, 0xf3f3f3); - outpdw(MDP_BASE + 0x40b9c, 0xf4f4f4); - outpdw(MDP_BASE + 0x40ba0, 0xf4f4f4); - outpdw(MDP_BASE + 0x40ba4, 0xf5f5f5); - outpdw(MDP_BASE + 0x40ba8, 0xf5f5f5); - outpdw(MDP_BASE + 0x40bac, 0xf6f6f6); - outpdw(MDP_BASE + 0x40bb0, 0xf6f6f6); - outpdw(MDP_BASE + 0x40bb4, 0xf7f7f7); - outpdw(MDP_BASE + 0x40bb8, 0xf7f7f7); - outpdw(MDP_BASE + 0x40bbc, 0xf8f8f8); - outpdw(MDP_BASE + 0x40bc0, 0xf8f8f8); - outpdw(MDP_BASE + 0x40bc4, 0xf9f9f9); - outpdw(MDP_BASE + 0x40bc8, 0xf9f9f9); - outpdw(MDP_BASE + 0x40bcc, 0xfafafa); - outpdw(MDP_BASE + 0x40bd0, 0xfafafa); - outpdw(MDP_BASE + 0x40bd4, 0xfafafa); - outpdw(MDP_BASE + 0x40bd8, 0xfbfbfb); - outpdw(MDP_BASE + 0x40bdc, 0xfbfbfb); - outpdw(MDP_BASE + 0x40be0, 0xfcfcfc); - outpdw(MDP_BASE + 0x40be4, 0xfcfcfc); - outpdw(MDP_BASE + 0x40be8, 0xfdfdfd); - outpdw(MDP_BASE + 0x40bec, 0xfdfdfd); - outpdw(MDP_BASE + 0x40bf0, 0xfefefe); - outpdw(MDP_BASE + 0x40bf4, 0xfefefe); - outpdw(MDP_BASE + 0x40bf8, 0xffffff); - outpdw(MDP_BASE + 0x40bfc, 0xffffff); - outpdw(MDP_BASE + 0x40c00, 0x0); - outpdw(MDP_BASE + 0x40c04, 0x0); - outpdw(MDP_BASE + 0x40c08, 0x0); - outpdw(MDP_BASE + 0x40c0c, 0x0); - outpdw(MDP_BASE + 0x40c10, 0x0); - outpdw(MDP_BASE + 0x40c14, 0x0); - outpdw(MDP_BASE + 0x40c18, 0x0); - outpdw(MDP_BASE + 0x40c1c, 0x0); - outpdw(MDP_BASE + 0x40c20, 0x0); - outpdw(MDP_BASE + 0x40c24, 0x0); - outpdw(MDP_BASE + 0x40c28, 0x0); - outpdw(MDP_BASE + 0x40c2c, 0x0); - outpdw(MDP_BASE + 0x40c30, 0x0); - outpdw(MDP_BASE + 0x40c34, 0x0); - outpdw(MDP_BASE + 0x40c38, 0x0); - outpdw(MDP_BASE + 0x40c3c, 0x0); - outpdw(MDP_BASE + 0x40c40, 0x10101); - outpdw(MDP_BASE + 0x40c44, 0x10101); - outpdw(MDP_BASE + 0x40c48, 0x10101); - outpdw(MDP_BASE + 0x40c4c, 0x10101); - outpdw(MDP_BASE + 0x40c50, 0x10101); - outpdw(MDP_BASE + 0x40c54, 0x10101); - outpdw(MDP_BASE + 0x40c58, 0x10101); - outpdw(MDP_BASE + 0x40c5c, 0x10101); - outpdw(MDP_BASE + 0x40c60, 0x10101); - outpdw(MDP_BASE + 0x40c64, 0x10101); - outpdw(MDP_BASE + 0x40c68, 0x20202); - outpdw(MDP_BASE + 0x40c6c, 0x20202); - outpdw(MDP_BASE + 0x40c70, 0x20202); - outpdw(MDP_BASE + 0x40c74, 0x20202); - outpdw(MDP_BASE + 0x40c78, 0x20202); - outpdw(MDP_BASE + 0x40c7c, 0x20202); - outpdw(MDP_BASE + 0x40c80, 0x30303); - outpdw(MDP_BASE + 0x40c84, 0x30303); - outpdw(MDP_BASE + 0x40c88, 0x30303); - outpdw(MDP_BASE + 0x40c8c, 0x30303); - outpdw(MDP_BASE + 0x40c90, 0x30303); - outpdw(MDP_BASE + 0x40c94, 0x40404); - outpdw(MDP_BASE + 0x40c98, 0x40404); - outpdw(MDP_BASE + 0x40c9c, 0x40404); - outpdw(MDP_BASE + 0x40ca0, 0x40404); - outpdw(MDP_BASE + 0x40ca4, 0x40404); - outpdw(MDP_BASE + 0x40ca8, 0x50505); - outpdw(MDP_BASE + 0x40cac, 0x50505); - outpdw(MDP_BASE + 0x40cb0, 0x50505); - outpdw(MDP_BASE + 0x40cb4, 0x50505); - outpdw(MDP_BASE + 0x40cb8, 0x60606); - outpdw(MDP_BASE + 0x40cbc, 0x60606); - outpdw(MDP_BASE + 0x40cc0, 0x60606); - outpdw(MDP_BASE + 0x40cc4, 0x70707); - outpdw(MDP_BASE + 0x40cc8, 0x70707); - outpdw(MDP_BASE + 0x40ccc, 0x70707); - outpdw(MDP_BASE + 0x40cd0, 0x70707); - outpdw(MDP_BASE + 0x40cd4, 0x80808); - outpdw(MDP_BASE + 0x40cd8, 0x80808); - outpdw(MDP_BASE + 0x40cdc, 0x80808); - outpdw(MDP_BASE + 0x40ce0, 0x90909); - outpdw(MDP_BASE + 0x40ce4, 0x90909); - outpdw(MDP_BASE + 0x40ce8, 0xa0a0a); - outpdw(MDP_BASE + 0x40cec, 0xa0a0a); - outpdw(MDP_BASE + 0x40cf0, 0xa0a0a); - outpdw(MDP_BASE + 0x40cf4, 0xb0b0b); - outpdw(MDP_BASE + 0x40cf8, 0xb0b0b); - outpdw(MDP_BASE + 0x40cfc, 0xb0b0b); - outpdw(MDP_BASE + 0x40d00, 0xc0c0c); - outpdw(MDP_BASE + 0x40d04, 0xc0c0c); - outpdw(MDP_BASE + 0x40d08, 0xd0d0d); - outpdw(MDP_BASE + 0x40d0c, 0xd0d0d); - outpdw(MDP_BASE + 0x40d10, 0xe0e0e); - outpdw(MDP_BASE + 0x40d14, 0xe0e0e); - outpdw(MDP_BASE + 0x40d18, 0xe0e0e); - outpdw(MDP_BASE + 0x40d1c, 0xf0f0f); - outpdw(MDP_BASE + 0x40d20, 0xf0f0f); - outpdw(MDP_BASE + 0x40d24, 0x101010); - outpdw(MDP_BASE + 0x40d28, 0x101010); - outpdw(MDP_BASE + 0x40d2c, 0x111111); - outpdw(MDP_BASE + 0x40d30, 0x111111); - outpdw(MDP_BASE + 0x40d34, 0x121212); - outpdw(MDP_BASE + 0x40d38, 0x121212); - outpdw(MDP_BASE + 0x40d3c, 0x131313); - outpdw(MDP_BASE + 0x40d40, 0x131313); - outpdw(MDP_BASE + 0x40d44, 0x141414); - outpdw(MDP_BASE + 0x40d48, 0x151515); - outpdw(MDP_BASE + 0x40d4c, 0x151515); - outpdw(MDP_BASE + 0x40d50, 0x161616); - outpdw(MDP_BASE + 0x40d54, 0x161616); - outpdw(MDP_BASE + 0x40d58, 0x171717); - outpdw(MDP_BASE + 0x40d5c, 0x171717); - outpdw(MDP_BASE + 0x40d60, 0x181818); - outpdw(MDP_BASE + 0x40d64, 0x191919); - outpdw(MDP_BASE + 0x40d68, 0x191919); - outpdw(MDP_BASE + 0x40d6c, 0x1a1a1a); - outpdw(MDP_BASE + 0x40d70, 0x1b1b1b); - outpdw(MDP_BASE + 0x40d74, 0x1b1b1b); - outpdw(MDP_BASE + 0x40d78, 0x1c1c1c); - outpdw(MDP_BASE + 0x40d7c, 0x1c1c1c); - outpdw(MDP_BASE + 0x40d80, 0x1d1d1d); - outpdw(MDP_BASE + 0x40d84, 0x1e1e1e); - outpdw(MDP_BASE + 0x40d88, 0x1f1f1f); - outpdw(MDP_BASE + 0x40d8c, 0x1f1f1f); - outpdw(MDP_BASE + 0x40d90, 0x202020); - outpdw(MDP_BASE + 0x40d94, 0x212121); - outpdw(MDP_BASE + 0x40d98, 0x212121); - outpdw(MDP_BASE + 0x40d9c, 0x222222); - outpdw(MDP_BASE + 0x40da0, 0x232323); - outpdw(MDP_BASE + 0x40da4, 0x242424); - outpdw(MDP_BASE + 0x40da8, 0x242424); - outpdw(MDP_BASE + 0x40dac, 0x252525); - outpdw(MDP_BASE + 0x40db0, 0x262626); - outpdw(MDP_BASE + 0x40db4, 0x272727); - outpdw(MDP_BASE + 0x40db8, 0x272727); - outpdw(MDP_BASE + 0x40dbc, 0x282828); - outpdw(MDP_BASE + 0x40dc0, 0x292929); - outpdw(MDP_BASE + 0x40dc4, 0x2a2a2a); - outpdw(MDP_BASE + 0x40dc8, 0x2b2b2b); - outpdw(MDP_BASE + 0x40dcc, 0x2c2c2c); - outpdw(MDP_BASE + 0x40dd0, 0x2c2c2c); - outpdw(MDP_BASE + 0x40dd4, 0x2d2d2d); - outpdw(MDP_BASE + 0x40dd8, 0x2e2e2e); - outpdw(MDP_BASE + 0x40ddc, 0x2f2f2f); - outpdw(MDP_BASE + 0x40de0, 0x303030); - outpdw(MDP_BASE + 0x40de4, 0x313131); - outpdw(MDP_BASE + 0x40de8, 0x323232); - outpdw(MDP_BASE + 0x40dec, 0x333333); - outpdw(MDP_BASE + 0x40df0, 0x333333); - outpdw(MDP_BASE + 0x40df4, 0x343434); - outpdw(MDP_BASE + 0x40df8, 0x353535); - outpdw(MDP_BASE + 0x40dfc, 0x363636); - outpdw(MDP_BASE + 0x40e00, 0x373737); - outpdw(MDP_BASE + 0x40e04, 0x383838); - outpdw(MDP_BASE + 0x40e08, 0x393939); - outpdw(MDP_BASE + 0x40e0c, 0x3a3a3a); - outpdw(MDP_BASE + 0x40e10, 0x3b3b3b); - outpdw(MDP_BASE + 0x40e14, 0x3c3c3c); - outpdw(MDP_BASE + 0x40e18, 0x3d3d3d); - outpdw(MDP_BASE + 0x40e1c, 0x3e3e3e); - outpdw(MDP_BASE + 0x40e20, 0x3f3f3f); - outpdw(MDP_BASE + 0x40e24, 0x404040); - outpdw(MDP_BASE + 0x40e28, 0x414141); - outpdw(MDP_BASE + 0x40e2c, 0x424242); - outpdw(MDP_BASE + 0x40e30, 0x434343); - outpdw(MDP_BASE + 0x40e34, 0x444444); - outpdw(MDP_BASE + 0x40e38, 0x464646); - outpdw(MDP_BASE + 0x40e3c, 0x474747); - outpdw(MDP_BASE + 0x40e40, 0x484848); - outpdw(MDP_BASE + 0x40e44, 0x494949); - outpdw(MDP_BASE + 0x40e48, 0x4a4a4a); - outpdw(MDP_BASE + 0x40e4c, 0x4b4b4b); - outpdw(MDP_BASE + 0x40e50, 0x4c4c4c); - outpdw(MDP_BASE + 0x40e54, 0x4d4d4d); - outpdw(MDP_BASE + 0x40e58, 0x4f4f4f); - outpdw(MDP_BASE + 0x40e5c, 0x505050); - outpdw(MDP_BASE + 0x40e60, 0x515151); - outpdw(MDP_BASE + 0x40e64, 0x525252); - outpdw(MDP_BASE + 0x40e68, 0x535353); - outpdw(MDP_BASE + 0x40e6c, 0x545454); - outpdw(MDP_BASE + 0x40e70, 0x565656); - outpdw(MDP_BASE + 0x40e74, 0x575757); - outpdw(MDP_BASE + 0x40e78, 0x585858); - outpdw(MDP_BASE + 0x40e7c, 0x595959); - outpdw(MDP_BASE + 0x40e80, 0x5b5b5b); - outpdw(MDP_BASE + 0x40e84, 0x5c5c5c); - outpdw(MDP_BASE + 0x40e88, 0x5d5d5d); - outpdw(MDP_BASE + 0x40e8c, 0x5e5e5e); - outpdw(MDP_BASE + 0x40e90, 0x606060); - outpdw(MDP_BASE + 0x40e94, 0x616161); - outpdw(MDP_BASE + 0x40e98, 0x626262); - outpdw(MDP_BASE + 0x40e9c, 0x646464); - outpdw(MDP_BASE + 0x40ea0, 0x656565); - outpdw(MDP_BASE + 0x40ea4, 0x666666); - outpdw(MDP_BASE + 0x40ea8, 0x686868); - outpdw(MDP_BASE + 0x40eac, 0x696969); - outpdw(MDP_BASE + 0x40eb0, 0x6a6a6a); - outpdw(MDP_BASE + 0x40eb4, 0x6c6c6c); - outpdw(MDP_BASE + 0x40eb8, 0x6d6d6d); - outpdw(MDP_BASE + 0x40ebc, 0x6f6f6f); - outpdw(MDP_BASE + 0x40ec0, 0x707070); - outpdw(MDP_BASE + 0x40ec4, 0x717171); - outpdw(MDP_BASE + 0x40ec8, 0x737373); - outpdw(MDP_BASE + 0x40ecc, 0x747474); - outpdw(MDP_BASE + 0x40ed0, 0x767676); - outpdw(MDP_BASE + 0x40ed4, 0x777777); - outpdw(MDP_BASE + 0x40ed8, 0x797979); - outpdw(MDP_BASE + 0x40edc, 0x7a7a7a); - outpdw(MDP_BASE + 0x40ee0, 0x7c7c7c); - outpdw(MDP_BASE + 0x40ee4, 0x7d7d7d); - outpdw(MDP_BASE + 0x40ee8, 0x7f7f7f); - outpdw(MDP_BASE + 0x40eec, 0x808080); - outpdw(MDP_BASE + 0x40ef0, 0x828282); - outpdw(MDP_BASE + 0x40ef4, 0x838383); - outpdw(MDP_BASE + 0x40ef8, 0x858585); - outpdw(MDP_BASE + 0x40efc, 0x868686); - outpdw(MDP_BASE + 0x40f00, 0x888888); - outpdw(MDP_BASE + 0x40f04, 0x898989); - outpdw(MDP_BASE + 0x40f08, 0x8b8b8b); - outpdw(MDP_BASE + 0x40f0c, 0x8d8d8d); - outpdw(MDP_BASE + 0x40f10, 0x8e8e8e); - outpdw(MDP_BASE + 0x40f14, 0x909090); - outpdw(MDP_BASE + 0x40f18, 0x919191); - outpdw(MDP_BASE + 0x40f1c, 0x939393); - outpdw(MDP_BASE + 0x40f20, 0x959595); - outpdw(MDP_BASE + 0x40f24, 0x969696); - outpdw(MDP_BASE + 0x40f28, 0x989898); - outpdw(MDP_BASE + 0x40f2c, 0x9a9a9a); - outpdw(MDP_BASE + 0x40f30, 0x9b9b9b); - outpdw(MDP_BASE + 0x40f34, 0x9d9d9d); - outpdw(MDP_BASE + 0x40f38, 0x9f9f9f); - outpdw(MDP_BASE + 0x40f3c, 0xa1a1a1); - outpdw(MDP_BASE + 0x40f40, 0xa2a2a2); - outpdw(MDP_BASE + 0x40f44, 0xa4a4a4); - outpdw(MDP_BASE + 0x40f48, 0xa6a6a6); - outpdw(MDP_BASE + 0x40f4c, 0xa7a7a7); - outpdw(MDP_BASE + 0x40f50, 0xa9a9a9); - outpdw(MDP_BASE + 0x40f54, 0xababab); - outpdw(MDP_BASE + 0x40f58, 0xadadad); - outpdw(MDP_BASE + 0x40f5c, 0xafafaf); - outpdw(MDP_BASE + 0x40f60, 0xb0b0b0); - outpdw(MDP_BASE + 0x40f64, 0xb2b2b2); - outpdw(MDP_BASE + 0x40f68, 0xb4b4b4); - outpdw(MDP_BASE + 0x40f6c, 0xb6b6b6); - outpdw(MDP_BASE + 0x40f70, 0xb8b8b8); - outpdw(MDP_BASE + 0x40f74, 0xbababa); - outpdw(MDP_BASE + 0x40f78, 0xbbbbbb); - outpdw(MDP_BASE + 0x40f7c, 0xbdbdbd); - outpdw(MDP_BASE + 0x40f80, 0xbfbfbf); - outpdw(MDP_BASE + 0x40f84, 0xc1c1c1); - outpdw(MDP_BASE + 0x40f88, 0xc3c3c3); - outpdw(MDP_BASE + 0x40f8c, 0xc5c5c5); - outpdw(MDP_BASE + 0x40f90, 0xc7c7c7); - outpdw(MDP_BASE + 0x40f94, 0xc9c9c9); - outpdw(MDP_BASE + 0x40f98, 0xcbcbcb); - outpdw(MDP_BASE + 0x40f9c, 0xcdcdcd); - outpdw(MDP_BASE + 0x40fa0, 0xcfcfcf); - outpdw(MDP_BASE + 0x40fa4, 0xd1d1d1); - outpdw(MDP_BASE + 0x40fa8, 0xd3d3d3); - outpdw(MDP_BASE + 0x40fac, 0xd5d5d5); - outpdw(MDP_BASE + 0x40fb0, 0xd7d7d7); - outpdw(MDP_BASE + 0x40fb4, 0xd9d9d9); - outpdw(MDP_BASE + 0x40fb8, 0xdbdbdb); - outpdw(MDP_BASE + 0x40fbc, 0xdddddd); - outpdw(MDP_BASE + 0x40fc0, 0xdfdfdf); - outpdw(MDP_BASE + 0x40fc4, 0xe1e1e1); - outpdw(MDP_BASE + 0x40fc8, 0xe3e3e3); - outpdw(MDP_BASE + 0x40fcc, 0xe5e5e5); - outpdw(MDP_BASE + 0x40fd0, 0xe7e7e7); - outpdw(MDP_BASE + 0x40fd4, 0xe9e9e9); - outpdw(MDP_BASE + 0x40fd8, 0xebebeb); - outpdw(MDP_BASE + 0x40fdc, 0xeeeeee); - outpdw(MDP_BASE + 0x40fe0, 0xf0f0f0); - outpdw(MDP_BASE + 0x40fe4, 0xf2f2f2); - outpdw(MDP_BASE + 0x40fe8, 0xf4f4f4); - outpdw(MDP_BASE + 0x40fec, 0xf6f6f6); - outpdw(MDP_BASE + 0x40ff0, 0xf8f8f8); - outpdw(MDP_BASE + 0x40ff4, 0xfbfbfb); - outpdw(MDP_BASE + 0x40ff8, 0xfdfdfd); - outpdw(MDP_BASE + 0x40ffc, 0xffffff); -} - -#define IRQ_EN_1__MDP_IRQ___M 0x00000800 - -void mdp_hw_init(int splash) -{ - int i; - - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, FALSE); - - /* debug interface write access */ - outpdw(MDP_BASE + 0x60, 1); - - outp32(MDP_INTR_ENABLE, MDP_ANY_INTR_MASK); - outp32(MDP_EBI2_PORTMAP_MODE, 0x3); - outpdw(MDP_CMD_DEBUG_ACCESS_BASE + 0x01f8, 0x0); - outpdw(MDP_CMD_DEBUG_ACCESS_BASE + 0x01fc, 0x0); - outpdw(MDP_BASE + 0x60, 0x1); - mdp_load_lut_param(); - - /* - * clear up unused fg/main registers - */ - /* comp.plane 2&3 ystride */ - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0120, 0x0); - /* unpacked pattern */ - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x012c, 0x0); - /* unpacked pattern */ - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0130, 0x0); - /* unpacked pattern */ - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0134, 0x0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0158, 0x0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x15c, 0x0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0160, 0x0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0170, 0x0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0174, 0x0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x017c, 0x0); - - /* comp.plane 2 */ - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0114, 0x0); - /* comp.plane 3 */ - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0118, 0x0); - - /* clear up unused bg registers */ - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01c8, 0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01d0, 0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01dc, 0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01e0, 0); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01e4, 0); - -#ifndef CONFIG_FB_MSM_MDP22 - if (!splash) - MDP_OUTP(MDP_BASE + 0xE0000, 0); - MDP_OUTP(MDP_BASE + 0x100, 0xffffffff); - MDP_OUTP(MDP_BASE + 0x90070, 0); -#endif - - /* - * limit vector - * pre gets applied before color matrix conversion - * post is after ccs - */ - writel(mdp_plv[0], MDP_CSC_PRE_LV1n(0)); - writel(mdp_plv[1], MDP_CSC_PRE_LV1n(1)); - writel(mdp_plv[2], MDP_CSC_PRE_LV1n(2)); - writel(mdp_plv[3], MDP_CSC_PRE_LV1n(3)); - -#ifdef CONFIG_FB_MSM_MDP31 - writel(mdp_plv[2], MDP_CSC_PRE_LV1n(4)); - writel(mdp_plv[3], MDP_CSC_PRE_LV1n(5)); - - writel(0, MDP_CSC_POST_LV1n(0)); - writel(0xff, MDP_CSC_POST_LV1n(1)); - writel(0, MDP_CSC_POST_LV1n(2)); - writel(0xff, MDP_CSC_POST_LV1n(3)); - writel(0, MDP_CSC_POST_LV1n(4)); - writel(0xff, MDP_CSC_POST_LV1n(5)); - - writel(0, MDP_CSC_PRE_LV2n(0)); - writel(0xff, MDP_CSC_PRE_LV2n(1)); - writel(0, MDP_CSC_PRE_LV2n(2)); - writel(0xff, MDP_CSC_PRE_LV2n(3)); - writel(0, MDP_CSC_PRE_LV2n(4)); - writel(0xff, MDP_CSC_PRE_LV2n(5)); - - writel(mdp_plv[0], MDP_CSC_POST_LV2n(0)); - writel(mdp_plv[1], MDP_CSC_POST_LV2n(1)); - writel(mdp_plv[2], MDP_CSC_POST_LV2n(2)); - writel(mdp_plv[3], MDP_CSC_POST_LV2n(3)); - writel(mdp_plv[2], MDP_CSC_POST_LV2n(4)); - writel(mdp_plv[3], MDP_CSC_POST_LV2n(5)); -#endif - - /* primary forward matrix */ - for (i = 0; i < MDP_CCS_SIZE; i++) - writel(mdp_ccs_rgb2yuv.ccs[i], MDP_CSC_PFMVn(i)); - -#ifdef CONFIG_FB_MSM_MDP31 - for (i = 0; i < MDP_BV_SIZE; i++) - writel(mdp_ccs_rgb2yuv.bv[i], MDP_CSC_POST_BV2n(i)); - - writel(0, MDP_CSC_PRE_BV2n(0)); - writel(0, MDP_CSC_PRE_BV2n(1)); - writel(0, MDP_CSC_PRE_BV2n(2)); -#endif - /* primary reverse matrix */ - for (i = 0; i < MDP_CCS_SIZE; i++) - writel(mdp_ccs_yuv2rgb.ccs[i], MDP_CSC_PRMVn(i)); - - for (i = 0; i < MDP_BV_SIZE; i++) - writel(mdp_ccs_yuv2rgb.bv[i], MDP_CSC_PRE_BV1n(i)); - -#ifdef CONFIG_FB_MSM_MDP31 - writel(0, MDP_CSC_POST_BV1n(0)); - writel(0, MDP_CSC_POST_BV1n(1)); - writel(0, MDP_CSC_POST_BV1n(2)); - - outpdw(MDP_BASE + 0x30010, 0x03e0); - outpdw(MDP_BASE + 0x30014, 0x0360); - outpdw(MDP_BASE + 0x30018, 0x0120); - outpdw(MDP_BASE + 0x3001c, 0x0140); -#endif - mdp_init_scale_table(); - -#ifndef CONFIG_FB_MSM_MDP31 - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0104, - ((16 << 6) << 16) | (16) << 6); -#endif - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} diff --git a/drivers/video/msm/mdp_lcdc.c b/drivers/video/msm/mdp_lcdc.c deleted file mode 100644 index f05c9ebd58c662c89d733d06e11c61d10cc45bac..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_lcdc.c +++ /dev/null @@ -1,431 +0,0 @@ -/* drivers/video/msm/mdp_lcdc.c - * - * Copyright (c) 2009 Google Inc. - * Copyright (c) 2009,2013 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - * Author: Dima Zavin - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include "mdp_hw.h" - -struct mdp_lcdc_info { - struct mdp_info *mdp; - struct clk *mdp_clk; - struct clk *pclk; - struct clk *pad_pclk; - struct msm_panel_data fb_panel_data; - struct platform_device fb_pdev; - struct msm_lcdc_platform_data *pdata; - uint32_t fb_start; - - struct msmfb_callback frame_start_cb; - wait_queue_head_t vsync_waitq; - int got_vsync; - - struct { - uint32_t clk_rate; - uint32_t hsync_ctl; - uint32_t vsync_period; - uint32_t vsync_pulse_width; - uint32_t display_hctl; - uint32_t display_vstart; - uint32_t display_vend; - uint32_t hsync_skew; - uint32_t polarity; - } parms; -}; - -static struct mdp_device *mdp_dev; - -#define panel_to_lcdc(p) container_of((p), struct mdp_lcdc_info, fb_panel_data) - -static int lcdc_unblank(struct msm_panel_data *fb_panel) -{ - struct mdp_lcdc_info *lcdc = panel_to_lcdc(fb_panel); - struct msm_lcdc_panel_ops *panel_ops = lcdc->pdata->panel_ops; - - pr_info("%s: ()\n", __func__); - panel_ops->unblank(panel_ops); - - return 0; -} - -static int lcdc_blank(struct msm_panel_data *fb_panel) -{ - struct mdp_lcdc_info *lcdc = panel_to_lcdc(fb_panel); - struct msm_lcdc_panel_ops *panel_ops = lcdc->pdata->panel_ops; - - pr_info("%s: ()\n", __func__); - panel_ops->blank(panel_ops); - - return 0; -} - -static int lcdc_suspend(struct msm_panel_data *fb_panel) -{ - struct mdp_lcdc_info *lcdc = panel_to_lcdc(fb_panel); - - pr_info("%s: suspending\n", __func__); - - mdp_writel(lcdc->mdp, 0, MDP_LCDC_EN); - clk_disable_unprepare(lcdc->pad_pclk); - clk_disable_unprepare(lcdc->pclk); - clk_disable_unprepare(lcdc->mdp_clk); - - return 0; -} - -static int lcdc_resume(struct msm_panel_data *fb_panel) -{ - struct mdp_lcdc_info *lcdc = panel_to_lcdc(fb_panel); - - pr_info("%s: resuming\n", __func__); - - clk_prepare_enable(lcdc->mdp_clk); - clk_prepare_enable(lcdc->pclk); - clk_prepare_enable(lcdc->pad_pclk); - mdp_writel(lcdc->mdp, 1, MDP_LCDC_EN); - - return 0; -} - -static int lcdc_hw_init(struct mdp_lcdc_info *lcdc) -{ - struct msm_panel_data *fb_panel = &lcdc->fb_panel_data; - uint32_t dma_cfg; - - clk_prepare_enable(lcdc->mdp_clk); - clk_prepare_enable(lcdc->pclk); - clk_prepare_enable(lcdc->pad_pclk); - - clk_set_rate(lcdc->pclk, lcdc->parms.clk_rate); - clk_set_rate(lcdc->pad_pclk, lcdc->parms.clk_rate); - - /* write the lcdc params */ - mdp_writel(lcdc->mdp, lcdc->parms.hsync_ctl, MDP_LCDC_HSYNC_CTL); - mdp_writel(lcdc->mdp, lcdc->parms.vsync_period, MDP_LCDC_VSYNC_PERIOD); - mdp_writel(lcdc->mdp, lcdc->parms.vsync_pulse_width, - MDP_LCDC_VSYNC_PULSE_WIDTH); - mdp_writel(lcdc->mdp, lcdc->parms.display_hctl, MDP_LCDC_DISPLAY_HCTL); - mdp_writel(lcdc->mdp, lcdc->parms.display_vstart, - MDP_LCDC_DISPLAY_V_START); - mdp_writel(lcdc->mdp, lcdc->parms.display_vend, MDP_LCDC_DISPLAY_V_END); - mdp_writel(lcdc->mdp, lcdc->parms.hsync_skew, MDP_LCDC_HSYNC_SKEW); - - mdp_writel(lcdc->mdp, 0, MDP_LCDC_BORDER_CLR); - mdp_writel(lcdc->mdp, 0xff, MDP_LCDC_UNDERFLOW_CTL); - mdp_writel(lcdc->mdp, 0, MDP_LCDC_ACTIVE_HCTL); - mdp_writel(lcdc->mdp, 0, MDP_LCDC_ACTIVE_V_START); - mdp_writel(lcdc->mdp, 0, MDP_LCDC_ACTIVE_V_END); - mdp_writel(lcdc->mdp, lcdc->parms.polarity, MDP_LCDC_CTL_POLARITY); - - /* config the dma_p block that drives the lcdc data */ - mdp_writel(lcdc->mdp, lcdc->fb_start, MDP_DMA_P_IBUF_ADDR); - mdp_writel(lcdc->mdp, (((fb_panel->fb_data->yres & 0x7ff) << 16) | - (fb_panel->fb_data->xres & 0x7ff)), - MDP_DMA_P_SIZE); - - mdp_writel(lcdc->mdp, 0, MDP_DMA_P_OUT_XY); - - dma_cfg = mdp_readl(lcdc->mdp, MDP_DMA_P_CONFIG); - dma_cfg |= (DMA_PACK_ALIGN_LSB | - DMA_PACK_PATTERN_RGB | - DMA_DITHER_EN); - dma_cfg |= DMA_OUT_SEL_LCDC; - dma_cfg &= ~DMA_DST_BITS_MASK; - - if (fb_panel->fb_data->output_format == MSM_MDP_OUT_IF_FMT_RGB666) - dma_cfg |= DMA_DSTC0G_6BITS | DMA_DSTC1B_6BITS | DMA_DSTC2R_6BITS; - else - dma_cfg |= DMA_DSTC0G_6BITS | DMA_DSTC1B_5BITS | DMA_DSTC2R_5BITS; - - mdp_writel(lcdc->mdp, dma_cfg, MDP_DMA_P_CONFIG); - - /* enable the lcdc timing generation */ - mdp_writel(lcdc->mdp, 1, MDP_LCDC_EN); - - return 0; -} - -static void lcdc_wait_vsync(struct msm_panel_data *panel) -{ - struct mdp_lcdc_info *lcdc = panel_to_lcdc(panel); - int ret; - - ret = wait_event_timeout(lcdc->vsync_waitq, lcdc->got_vsync, HZ / 2); - if (!ret && !lcdc->got_vsync) - pr_err("%s: timeout waiting for VSYNC\n", __func__); - lcdc->got_vsync = 0; -} - -static void lcdc_request_vsync(struct msm_panel_data *fb_panel, - struct msmfb_callback *vsync_cb) -{ - struct mdp_lcdc_info *lcdc = panel_to_lcdc(fb_panel); - - /* the vsync callback will start the dma */ - vsync_cb->func(vsync_cb); - lcdc->got_vsync = 0; - mdp_out_if_req_irq(mdp_dev, MSM_LCDC_INTERFACE, MDP_LCDC_FRAME_START, - &lcdc->frame_start_cb); - lcdc_wait_vsync(fb_panel); -} - -static void lcdc_clear_vsync(struct msm_panel_data *fb_panel) -{ - struct mdp_lcdc_info *lcdc = panel_to_lcdc(fb_panel); - lcdc->got_vsync = 0; - mdp_out_if_req_irq(mdp_dev, MSM_LCDC_INTERFACE, 0, NULL); -} - -/* called in irq context with mdp lock held, when mdp gets the - * MDP_LCDC_FRAME_START interrupt */ -static void lcdc_frame_start(struct msmfb_callback *cb) -{ - struct mdp_lcdc_info *lcdc; - - lcdc = container_of(cb, struct mdp_lcdc_info, frame_start_cb); - - lcdc->got_vsync = 1; - wake_up(&lcdc->vsync_waitq); -} - -static void lcdc_dma_start(void *priv, uint32_t addr, uint32_t stride, - uint32_t width, uint32_t height, uint32_t x, - uint32_t y) -{ - struct mdp_lcdc_info *lcdc = priv; - - struct mdp_info *mdp = container_of(mdp_dev, struct mdp_info, mdp_dev); - if (mdp->dma_config_dirty) - { - mdp_writel(lcdc->mdp, 0, MDP_LCDC_EN); - mdelay(20); - mdp_dev->configure_dma(mdp_dev); - mdp_writel(lcdc->mdp, 1, MDP_LCDC_EN); - } - mdp_writel(lcdc->mdp, stride, MDP_DMA_P_IBUF_Y_STRIDE); - mdp_writel(lcdc->mdp, addr, MDP_DMA_P_IBUF_ADDR); -} - -static void precompute_timing_parms(struct mdp_lcdc_info *lcdc) -{ - struct msm_lcdc_timing *timing = lcdc->pdata->timing; - struct msm_fb_data *fb_data = lcdc->pdata->fb_data; - unsigned int hsync_period; - unsigned int hsync_start_x; - unsigned int hsync_end_x; - unsigned int vsync_period; - unsigned int display_vstart; - unsigned int display_vend; - - hsync_period = (timing->hsync_back_porch + - fb_data->xres + timing->hsync_front_porch); - hsync_start_x = timing->hsync_back_porch; - hsync_end_x = hsync_start_x + fb_data->xres - 1; - - vsync_period = (timing->vsync_back_porch + - fb_data->yres + timing->vsync_front_porch); - vsync_period *= hsync_period; - - display_vstart = timing->vsync_back_porch; - display_vstart *= hsync_period; - display_vstart += timing->hsync_skew; - - display_vend = (timing->vsync_back_porch + fb_data->yres) * - hsync_period; - display_vend += timing->hsync_skew - 1; - - /* register values we pre-compute at init time from the timing - * information in the panel info */ - lcdc->parms.hsync_ctl = (((hsync_period & 0xfff) << 16) | - (timing->hsync_pulse_width & 0xfff)); - lcdc->parms.vsync_period = vsync_period & 0xffffff; - lcdc->parms.vsync_pulse_width = (timing->vsync_pulse_width * - hsync_period) & 0xffffff; - - lcdc->parms.display_hctl = (((hsync_end_x & 0xfff) << 16) | - (hsync_start_x & 0xfff)); - lcdc->parms.display_vstart = display_vstart & 0xffffff; - lcdc->parms.display_vend = display_vend & 0xffffff; - lcdc->parms.hsync_skew = timing->hsync_skew & 0xfff; - lcdc->parms.polarity = ((timing->hsync_act_low << 0) | - (timing->vsync_act_low << 1) | - (timing->den_act_low << 2)); - lcdc->parms.clk_rate = timing->clk_rate; -} - -static int mdp_lcdc_probe(struct platform_device *pdev) -{ - struct msm_lcdc_platform_data *pdata = pdev->dev.platform_data; - struct mdp_lcdc_info *lcdc; - int ret = 0; - - if (!pdata) { - pr_err("%s: no LCDC platform data found\n", __func__); - return -EINVAL; - } - - lcdc = kzalloc(sizeof(struct mdp_lcdc_info), GFP_KERNEL); - if (!lcdc) - return -ENOMEM; - - /* We don't actually own the clocks, the mdp does. */ - lcdc->mdp_clk = clk_get(mdp_dev->dev.parent, "mdp_clk"); - if (IS_ERR(lcdc->mdp_clk)) { - pr_err("%s: failed to get mdp_clk\n", __func__); - ret = PTR_ERR(lcdc->mdp_clk); - goto err_get_mdp_clk; - } - - lcdc->pclk = clk_get(mdp_dev->dev.parent, "lcdc_pclk_clk"); - if (IS_ERR(lcdc->pclk)) { - pr_err("%s: failed to get lcdc_pclk\n", __func__); - ret = PTR_ERR(lcdc->pclk); - goto err_get_pclk; - } - - lcdc->pad_pclk = clk_get(mdp_dev->dev.parent, "lcdc_pad_pclk_clk"); - if (IS_ERR(lcdc->pad_pclk)) { - pr_err("%s: failed to get lcdc_pad_pclk\n", __func__); - ret = PTR_ERR(lcdc->pad_pclk); - goto err_get_pad_pclk; - } - - init_waitqueue_head(&lcdc->vsync_waitq); - lcdc->pdata = pdata; - lcdc->frame_start_cb.func = lcdc_frame_start; - - platform_set_drvdata(pdev, lcdc); - - mdp_out_if_register(mdp_dev, MSM_LCDC_INTERFACE, lcdc, MDP_DMA_P_DONE, - lcdc_dma_start); - - precompute_timing_parms(lcdc); - - lcdc->fb_start = pdata->fb_resource->start; - lcdc->mdp = container_of(mdp_dev, struct mdp_info, mdp_dev); - - lcdc->fb_panel_data.suspend = lcdc_suspend; - lcdc->fb_panel_data.resume = lcdc_resume; - lcdc->fb_panel_data.wait_vsync = lcdc_wait_vsync; - lcdc->fb_panel_data.request_vsync = lcdc_request_vsync; - lcdc->fb_panel_data.clear_vsync = lcdc_clear_vsync; - lcdc->fb_panel_data.blank = lcdc_blank; - lcdc->fb_panel_data.unblank = lcdc_unblank; - lcdc->fb_panel_data.fb_data = pdata->fb_data; - lcdc->fb_panel_data.interface_type = MSM_LCDC_INTERFACE; - - ret = lcdc_hw_init(lcdc); - if (ret) { - pr_err("%s: Cannot initialize the mdp_lcdc\n", __func__); - goto err_hw_init; - } - - lcdc->fb_pdev.name = "msm_panel"; - lcdc->fb_pdev.id = pdata->fb_id; - lcdc->fb_pdev.resource = pdata->fb_resource; - lcdc->fb_pdev.num_resources = 1; - lcdc->fb_pdev.dev.platform_data = &lcdc->fb_panel_data; - - if (pdata->panel_ops->init) - pdata->panel_ops->init(pdata->panel_ops); - - ret = platform_device_register(&lcdc->fb_pdev); - if (ret) { - pr_err("%s: Cannot register msm_panel pdev\n", __func__); - goto err_plat_dev_reg; - } - - pr_info("%s: initialized\n", __func__); - - return 0; - -err_plat_dev_reg: -err_hw_init: - platform_set_drvdata(pdev, NULL); - clk_put(lcdc->pad_pclk); -err_get_pad_pclk: - clk_put(lcdc->pclk); -err_get_pclk: - clk_put(lcdc->mdp_clk); -err_get_mdp_clk: - kfree(lcdc); - return ret; -} - -static int mdp_lcdc_remove(struct platform_device *pdev) -{ - struct mdp_lcdc_info *lcdc = platform_get_drvdata(pdev); - - platform_set_drvdata(pdev, NULL); - - clk_put(lcdc->pclk); - clk_put(lcdc->pad_pclk); - kfree(lcdc); - - return 0; -} - -static struct platform_driver mdp_lcdc_driver = { - .probe = mdp_lcdc_probe, - .remove = mdp_lcdc_remove, - .driver = { - .name = "msm_mdp_lcdc", - .owner = THIS_MODULE, - }, -}; - -static int mdp_lcdc_add_mdp_device(struct device *dev, - struct class_interface *class_intf) -{ - /* might need locking if mulitple mdp devices */ - if (mdp_dev) - return 0; - mdp_dev = container_of(dev, struct mdp_device, dev); - return platform_driver_register(&mdp_lcdc_driver); -} - -static void mdp_lcdc_remove_mdp_device(struct device *dev, - struct class_interface *class_intf) -{ - /* might need locking if mulitple mdp devices */ - if (dev != &mdp_dev->dev) - return; - platform_driver_unregister(&mdp_lcdc_driver); - mdp_dev = NULL; -} - -static struct class_interface mdp_lcdc_interface = { - .add_dev = &mdp_lcdc_add_mdp_device, - .remove_dev = &mdp_lcdc_remove_mdp_device, -}; - -static int __init mdp_lcdc_init(void) -{ - return register_mdp_client(&mdp_lcdc_interface); -} - -module_init(mdp_lcdc_init); diff --git a/drivers/video/msm/mdp_ppp.c b/drivers/video/msm/mdp_ppp.c index 754d0efe18bf9bd3af45e602aacee9770d81adda..c847a50acf6faef21008c4285e33343d2a703612 100644 --- a/drivers/video/msm/mdp_ppp.c +++ b/drivers/video/msm/mdp_ppp.c @@ -32,8 +32,6 @@ #include #include -#include "mdp.h" -#include "msm_fb.h" #define MDP_IS_IMGTYPE_BAD(x) (((x) >= MDP_IMGTYPE_LIMIT) && \ (((x) < MDP_IMGTYPE2_START) || \ @@ -1384,7 +1382,7 @@ static int mdp_ppp_blit_addr(struct fb_info *info, struct mdp_blit_req *req, iBuf.mdpImg.mdpOp |= MDPOP_DITHER; if (req->flags & MDP_BLEND_FG_PREMULT) { -#if defined(CONFIG_FB_MSM_MDP31) || defined(CONFIG_FB_MSM_MDP303) +#if defined(CONFIG_FB_MSM_MDP31) iBuf.mdpImg.mdpOp |= MDPOP_FG_PM_ALPHA; #else put_img(p_src_file, *src_ihdl); diff --git a/drivers/video/msm/mdp_ppp.h b/drivers/video/msm/mdp_ppp.h deleted file mode 100644 index e04564347bdfe16c450c138bf6dfe8be2f118d2d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_ppp.h +++ /dev/null @@ -1,82 +0,0 @@ -/* drivers/video/msm/mdp_ppp.h - * - * Copyright (C) 2009 Google Incorporated - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 _VIDEO_MSM_MDP_PPP_H_ -#define _VIDEO_MSM_MDP_PPP_H_ - -#include - -struct ppp_regs { - uint32_t src0; - uint32_t src1; - uint32_t dst0; - uint32_t dst1; - uint32_t src_cfg; - uint32_t dst_cfg; - uint32_t src_pack; - uint32_t dst_pack; - uint32_t src_rect; - uint32_t dst_rect; - uint32_t src_ystride; - uint32_t dst_ystride; - uint32_t op; - uint32_t src_bpp; - uint32_t dst_bpp; - uint32_t edge; - uint32_t phasex_init; - uint32_t phasey_init; - uint32_t phasex_step; - uint32_t phasey_step; - - uint32_t bg0; - uint32_t bg1; - uint32_t bg_cfg; - uint32_t bg_bpp; - uint32_t bg_pack; - uint32_t bg_ystride; - -#ifdef CONFIG_MSM_MDP31 - uint32_t src_xy; - uint32_t src_img_sz; - uint32_t dst_xy; - uint32_t bg_xy; - uint32_t bg_img_sz; - uint32_t bg_alpha_sel; - - uint32_t scale_cfg; - uint32_t csc_cfg; -#endif -}; - -struct mdp_info; -struct mdp_rect; -struct mdp_blit_req; - -void mdp_ppp_init_scale(const struct mdp_info *mdp); -int mdp_ppp_cfg_scale(const struct mdp_info *mdp, struct ppp_regs *regs, - struct mdp_rect *src_rect, struct mdp_rect *dst_rect, - uint32_t src_format, uint32_t dst_format); -int mdp_ppp_load_blur(const struct mdp_info *mdp); - -#ifndef CONFIG_MSM_MDP31 -int mdp_ppp_cfg_edge_cond(struct mdp_blit_req *req, struct ppp_regs *regs); -#else -static inline int mdp_ppp_cfg_edge_cond(struct mdp_blit_req *req, - struct ppp_regs *regs) -{ - return 0; -} -#endif - -#endif /* _VIDEO_MSM_MDP_PPP_H_ */ diff --git a/drivers/video/msm/mdp_ppp22.c b/drivers/video/msm/mdp_ppp22.c deleted file mode 100644 index 799ce524f8363d47cd4c3626fa7e1de6614ee9a9..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_ppp22.c +++ /dev/null @@ -1,1091 +0,0 @@ -/* drivers/video/msm/mdp_ppp22.c - * - * Copyright (C) 2007 The Linux Foundation. All rights reserved. - * Copyright (C) 2007 Google Incorporated - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include - -#include "mdp_hw.h" -#include "mdp_ppp.h" - -struct mdp_table_entry { - uint32_t reg; - uint32_t val; -}; - -enum { - MDP_DOWNSCALE_PT2TOPT4, - MDP_DOWNSCALE_PT4TOPT6, - MDP_DOWNSCALE_PT6TOPT8, - MDP_DOWNSCALE_PT8TO1, - MDP_DOWNSCALE_MAX, - - /* not technically in the downscale table list */ - MDP_DOWNSCALE_BLUR, -}; - -static int downscale_x_table; -static int downscale_y_table; - -static struct mdp_table_entry mdp_upscale_table[] = { - { 0x5fffc, 0x0 }, - { 0x50200, 0x7fc00000 }, - { 0x5fffc, 0xff80000d }, - { 0x50204, 0x7ec003f9 }, - { 0x5fffc, 0xfec0001c }, - { 0x50208, 0x7d4003f3 }, - { 0x5fffc, 0xfe40002b }, - { 0x5020c, 0x7b8003ed }, - { 0x5fffc, 0xfd80003c }, - { 0x50210, 0x794003e8 }, - { 0x5fffc, 0xfcc0004d }, - { 0x50214, 0x76c003e4 }, - { 0x5fffc, 0xfc40005f }, - { 0x50218, 0x73c003e0 }, - { 0x5fffc, 0xfb800071 }, - { 0x5021c, 0x708003de }, - { 0x5fffc, 0xfac00085 }, - { 0x50220, 0x6d0003db }, - { 0x5fffc, 0xfa000098 }, - { 0x50224, 0x698003d9 }, - { 0x5fffc, 0xf98000ac }, - { 0x50228, 0x654003d8 }, - { 0x5fffc, 0xf8c000c1 }, - { 0x5022c, 0x610003d7 }, - { 0x5fffc, 0xf84000d5 }, - { 0x50230, 0x5c8003d7 }, - { 0x5fffc, 0xf7c000e9 }, - { 0x50234, 0x580003d7 }, - { 0x5fffc, 0xf74000fd }, - { 0x50238, 0x534003d8 }, - { 0x5fffc, 0xf6c00112 }, - { 0x5023c, 0x4e8003d8 }, - { 0x5fffc, 0xf6800126 }, - { 0x50240, 0x494003da }, - { 0x5fffc, 0xf600013a }, - { 0x50244, 0x448003db }, - { 0x5fffc, 0xf600014d }, - { 0x50248, 0x3f4003dd }, - { 0x5fffc, 0xf5c00160 }, - { 0x5024c, 0x3a4003df }, - { 0x5fffc, 0xf5c00172 }, - { 0x50250, 0x354003e1 }, - { 0x5fffc, 0xf5c00184 }, - { 0x50254, 0x304003e3 }, - { 0x5fffc, 0xf6000195 }, - { 0x50258, 0x2b0003e6 }, - { 0x5fffc, 0xf64001a6 }, - { 0x5025c, 0x260003e8 }, - { 0x5fffc, 0xf6c001b4 }, - { 0x50260, 0x214003eb }, - { 0x5fffc, 0xf78001c2 }, - { 0x50264, 0x1c4003ee }, - { 0x5fffc, 0xf80001cf }, - { 0x50268, 0x17c003f1 }, - { 0x5fffc, 0xf90001db }, - { 0x5026c, 0x134003f3 }, - { 0x5fffc, 0xfa0001e5 }, - { 0x50270, 0xf0003f6 }, - { 0x5fffc, 0xfb4001ee }, - { 0x50274, 0xac003f9 }, - { 0x5fffc, 0xfcc001f5 }, - { 0x50278, 0x70003fb }, - { 0x5fffc, 0xfe4001fb }, - { 0x5027c, 0x34003fe }, -}; - -static struct mdp_table_entry mdp_downscale_x_table_PT2TOPT4[] = { - { 0x5fffc, 0x740008c }, - { 0x50280, 0x33800088 }, - { 0x5fffc, 0x800008e }, - { 0x50284, 0x33400084 }, - { 0x5fffc, 0x8400092 }, - { 0x50288, 0x33000080 }, - { 0x5fffc, 0x9000094 }, - { 0x5028c, 0x3300007b }, - { 0x5fffc, 0x9c00098 }, - { 0x50290, 0x32400077 }, - { 0x5fffc, 0xa40009b }, - { 0x50294, 0x32000073 }, - { 0x5fffc, 0xb00009d }, - { 0x50298, 0x31c0006f }, - { 0x5fffc, 0xbc000a0 }, - { 0x5029c, 0x3140006b }, - { 0x5fffc, 0xc8000a2 }, - { 0x502a0, 0x31000067 }, - { 0x5fffc, 0xd8000a5 }, - { 0x502a4, 0x30800062 }, - { 0x5fffc, 0xe4000a8 }, - { 0x502a8, 0x2fc0005f }, - { 0x5fffc, 0xec000aa }, - { 0x502ac, 0x2fc0005b }, - { 0x5fffc, 0xf8000ad }, - { 0x502b0, 0x2f400057 }, - { 0x5fffc, 0x108000b0 }, - { 0x502b4, 0x2e400054 }, - { 0x5fffc, 0x114000b2 }, - { 0x502b8, 0x2e000050 }, - { 0x5fffc, 0x124000b4 }, - { 0x502bc, 0x2d80004c }, - { 0x5fffc, 0x130000b6 }, - { 0x502c0, 0x2d000049 }, - { 0x5fffc, 0x140000b8 }, - { 0x502c4, 0x2c800045 }, - { 0x5fffc, 0x150000b9 }, - { 0x502c8, 0x2c000042 }, - { 0x5fffc, 0x15c000bd }, - { 0x502cc, 0x2b40003e }, - { 0x5fffc, 0x16c000bf }, - { 0x502d0, 0x2a80003b }, - { 0x5fffc, 0x17c000bf }, - { 0x502d4, 0x2a000039 }, - { 0x5fffc, 0x188000c2 }, - { 0x502d8, 0x29400036 }, - { 0x5fffc, 0x19c000c4 }, - { 0x502dc, 0x28800032 }, - { 0x5fffc, 0x1ac000c5 }, - { 0x502e0, 0x2800002f }, - { 0x5fffc, 0x1bc000c7 }, - { 0x502e4, 0x2740002c }, - { 0x5fffc, 0x1cc000c8 }, - { 0x502e8, 0x26c00029 }, - { 0x5fffc, 0x1dc000c9 }, - { 0x502ec, 0x26000027 }, - { 0x5fffc, 0x1ec000cc }, - { 0x502f0, 0x25000024 }, - { 0x5fffc, 0x200000cc }, - { 0x502f4, 0x24800021 }, - { 0x5fffc, 0x210000cd }, - { 0x502f8, 0x23800020 }, - { 0x5fffc, 0x220000ce }, - { 0x502fc, 0x2300001d }, -}; - -static struct mdp_table_entry mdp_downscale_x_table_PT4TOPT6[] = { - { 0x5fffc, 0x740008c }, - { 0x50280, 0x33800088 }, - { 0x5fffc, 0x800008e }, - { 0x50284, 0x33400084 }, - { 0x5fffc, 0x8400092 }, - { 0x50288, 0x33000080 }, - { 0x5fffc, 0x9000094 }, - { 0x5028c, 0x3300007b }, - { 0x5fffc, 0x9c00098 }, - { 0x50290, 0x32400077 }, - { 0x5fffc, 0xa40009b }, - { 0x50294, 0x32000073 }, - { 0x5fffc, 0xb00009d }, - { 0x50298, 0x31c0006f }, - { 0x5fffc, 0xbc000a0 }, - { 0x5029c, 0x3140006b }, - { 0x5fffc, 0xc8000a2 }, - { 0x502a0, 0x31000067 }, - { 0x5fffc, 0xd8000a5 }, - { 0x502a4, 0x30800062 }, - { 0x5fffc, 0xe4000a8 }, - { 0x502a8, 0x2fc0005f }, - { 0x5fffc, 0xec000aa }, - { 0x502ac, 0x2fc0005b }, - { 0x5fffc, 0xf8000ad }, - { 0x502b0, 0x2f400057 }, - { 0x5fffc, 0x108000b0 }, - { 0x502b4, 0x2e400054 }, - { 0x5fffc, 0x114000b2 }, - { 0x502b8, 0x2e000050 }, - { 0x5fffc, 0x124000b4 }, - { 0x502bc, 0x2d80004c }, - { 0x5fffc, 0x130000b6 }, - { 0x502c0, 0x2d000049 }, - { 0x5fffc, 0x140000b8 }, - { 0x502c4, 0x2c800045 }, - { 0x5fffc, 0x150000b9 }, - { 0x502c8, 0x2c000042 }, - { 0x5fffc, 0x15c000bd }, - { 0x502cc, 0x2b40003e }, - { 0x5fffc, 0x16c000bf }, - { 0x502d0, 0x2a80003b }, - { 0x5fffc, 0x17c000bf }, - { 0x502d4, 0x2a000039 }, - { 0x5fffc, 0x188000c2 }, - { 0x502d8, 0x29400036 }, - { 0x5fffc, 0x19c000c4 }, - { 0x502dc, 0x28800032 }, - { 0x5fffc, 0x1ac000c5 }, - { 0x502e0, 0x2800002f }, - { 0x5fffc, 0x1bc000c7 }, - { 0x502e4, 0x2740002c }, - { 0x5fffc, 0x1cc000c8 }, - { 0x502e8, 0x26c00029 }, - { 0x5fffc, 0x1dc000c9 }, - { 0x502ec, 0x26000027 }, - { 0x5fffc, 0x1ec000cc }, - { 0x502f0, 0x25000024 }, - { 0x5fffc, 0x200000cc }, - { 0x502f4, 0x24800021 }, - { 0x5fffc, 0x210000cd }, - { 0x502f8, 0x23800020 }, - { 0x5fffc, 0x220000ce }, - { 0x502fc, 0x2300001d }, -}; - -static struct mdp_table_entry mdp_downscale_x_table_PT6TOPT8[] = { - { 0x5fffc, 0xfe000070 }, - { 0x50280, 0x4bc00068 }, - { 0x5fffc, 0xfe000078 }, - { 0x50284, 0x4bc00060 }, - { 0x5fffc, 0xfe000080 }, - { 0x50288, 0x4b800059 }, - { 0x5fffc, 0xfe000089 }, - { 0x5028c, 0x4b000052 }, - { 0x5fffc, 0xfe400091 }, - { 0x50290, 0x4a80004b }, - { 0x5fffc, 0xfe40009a }, - { 0x50294, 0x4a000044 }, - { 0x5fffc, 0xfe8000a3 }, - { 0x50298, 0x4940003d }, - { 0x5fffc, 0xfec000ac }, - { 0x5029c, 0x48400037 }, - { 0x5fffc, 0xff0000b4 }, - { 0x502a0, 0x47800031 }, - { 0x5fffc, 0xff8000bd }, - { 0x502a4, 0x4640002b }, - { 0x5fffc, 0xc5 }, - { 0x502a8, 0x45000026 }, - { 0x5fffc, 0x8000ce }, - { 0x502ac, 0x43800021 }, - { 0x5fffc, 0x10000d6 }, - { 0x502b0, 0x4240001c }, - { 0x5fffc, 0x18000df }, - { 0x502b4, 0x40800018 }, - { 0x5fffc, 0x24000e6 }, - { 0x502b8, 0x3f000014 }, - { 0x5fffc, 0x30000ee }, - { 0x502bc, 0x3d400010 }, - { 0x5fffc, 0x40000f5 }, - { 0x502c0, 0x3b80000c }, - { 0x5fffc, 0x50000fc }, - { 0x502c4, 0x39800009 }, - { 0x5fffc, 0x6000102 }, - { 0x502c8, 0x37c00006 }, - { 0x5fffc, 0x7000109 }, - { 0x502cc, 0x35800004 }, - { 0x5fffc, 0x840010e }, - { 0x502d0, 0x33800002 }, - { 0x5fffc, 0x9800114 }, - { 0x502d4, 0x31400000 }, - { 0x5fffc, 0xac00119 }, - { 0x502d8, 0x2f4003fe }, - { 0x5fffc, 0xc40011e }, - { 0x502dc, 0x2d0003fc }, - { 0x5fffc, 0xdc00121 }, - { 0x502e0, 0x2b0003fb }, - { 0x5fffc, 0xf400125 }, - { 0x502e4, 0x28c003fa }, - { 0x5fffc, 0x11000128 }, - { 0x502e8, 0x268003f9 }, - { 0x5fffc, 0x12c0012a }, - { 0x502ec, 0x244003f9 }, - { 0x5fffc, 0x1480012c }, - { 0x502f0, 0x224003f8 }, - { 0x5fffc, 0x1640012e }, - { 0x502f4, 0x200003f8 }, - { 0x5fffc, 0x1800012f }, - { 0x502f8, 0x1e0003f8 }, - { 0x5fffc, 0x1a00012f }, - { 0x502fc, 0x1c0003f8 }, -}; - -static struct mdp_table_entry mdp_downscale_x_table_PT8TO1[] = { - { 0x5fffc, 0x0 }, - { 0x50280, 0x7fc00000 }, - { 0x5fffc, 0xff80000d }, - { 0x50284, 0x7ec003f9 }, - { 0x5fffc, 0xfec0001c }, - { 0x50288, 0x7d4003f3 }, - { 0x5fffc, 0xfe40002b }, - { 0x5028c, 0x7b8003ed }, - { 0x5fffc, 0xfd80003c }, - { 0x50290, 0x794003e8 }, - { 0x5fffc, 0xfcc0004d }, - { 0x50294, 0x76c003e4 }, - { 0x5fffc, 0xfc40005f }, - { 0x50298, 0x73c003e0 }, - { 0x5fffc, 0xfb800071 }, - { 0x5029c, 0x708003de }, - { 0x5fffc, 0xfac00085 }, - { 0x502a0, 0x6d0003db }, - { 0x5fffc, 0xfa000098 }, - { 0x502a4, 0x698003d9 }, - { 0x5fffc, 0xf98000ac }, - { 0x502a8, 0x654003d8 }, - { 0x5fffc, 0xf8c000c1 }, - { 0x502ac, 0x610003d7 }, - { 0x5fffc, 0xf84000d5 }, - { 0x502b0, 0x5c8003d7 }, - { 0x5fffc, 0xf7c000e9 }, - { 0x502b4, 0x580003d7 }, - { 0x5fffc, 0xf74000fd }, - { 0x502b8, 0x534003d8 }, - { 0x5fffc, 0xf6c00112 }, - { 0x502bc, 0x4e8003d8 }, - { 0x5fffc, 0xf6800126 }, - { 0x502c0, 0x494003da }, - { 0x5fffc, 0xf600013a }, - { 0x502c4, 0x448003db }, - { 0x5fffc, 0xf600014d }, - { 0x502c8, 0x3f4003dd }, - { 0x5fffc, 0xf5c00160 }, - { 0x502cc, 0x3a4003df }, - { 0x5fffc, 0xf5c00172 }, - { 0x502d0, 0x354003e1 }, - { 0x5fffc, 0xf5c00184 }, - { 0x502d4, 0x304003e3 }, - { 0x5fffc, 0xf6000195 }, - { 0x502d8, 0x2b0003e6 }, - { 0x5fffc, 0xf64001a6 }, - { 0x502dc, 0x260003e8 }, - { 0x5fffc, 0xf6c001b4 }, - { 0x502e0, 0x214003eb }, - { 0x5fffc, 0xf78001c2 }, - { 0x502e4, 0x1c4003ee }, - { 0x5fffc, 0xf80001cf }, - { 0x502e8, 0x17c003f1 }, - { 0x5fffc, 0xf90001db }, - { 0x502ec, 0x134003f3 }, - { 0x5fffc, 0xfa0001e5 }, - { 0x502f0, 0xf0003f6 }, - { 0x5fffc, 0xfb4001ee }, - { 0x502f4, 0xac003f9 }, - { 0x5fffc, 0xfcc001f5 }, - { 0x502f8, 0x70003fb }, - { 0x5fffc, 0xfe4001fb }, - { 0x502fc, 0x34003fe }, -}; - -struct mdp_table_entry *mdp_downscale_x_table[MDP_DOWNSCALE_MAX] = { - [MDP_DOWNSCALE_PT2TOPT4] = mdp_downscale_x_table_PT2TOPT4, - [MDP_DOWNSCALE_PT4TOPT6] = mdp_downscale_x_table_PT4TOPT6, - [MDP_DOWNSCALE_PT6TOPT8] = mdp_downscale_x_table_PT6TOPT8, - [MDP_DOWNSCALE_PT8TO1] = mdp_downscale_x_table_PT8TO1, -}; - -static struct mdp_table_entry mdp_downscale_y_table_PT2TOPT4[] = { - { 0x5fffc, 0x740008c }, - { 0x50300, 0x33800088 }, - { 0x5fffc, 0x800008e }, - { 0x50304, 0x33400084 }, - { 0x5fffc, 0x8400092 }, - { 0x50308, 0x33000080 }, - { 0x5fffc, 0x9000094 }, - { 0x5030c, 0x3300007b }, - { 0x5fffc, 0x9c00098 }, - { 0x50310, 0x32400077 }, - { 0x5fffc, 0xa40009b }, - { 0x50314, 0x32000073 }, - { 0x5fffc, 0xb00009d }, - { 0x50318, 0x31c0006f }, - { 0x5fffc, 0xbc000a0 }, - { 0x5031c, 0x3140006b }, - { 0x5fffc, 0xc8000a2 }, - { 0x50320, 0x31000067 }, - { 0x5fffc, 0xd8000a5 }, - { 0x50324, 0x30800062 }, - { 0x5fffc, 0xe4000a8 }, - { 0x50328, 0x2fc0005f }, - { 0x5fffc, 0xec000aa }, - { 0x5032c, 0x2fc0005b }, - { 0x5fffc, 0xf8000ad }, - { 0x50330, 0x2f400057 }, - { 0x5fffc, 0x108000b0 }, - { 0x50334, 0x2e400054 }, - { 0x5fffc, 0x114000b2 }, - { 0x50338, 0x2e000050 }, - { 0x5fffc, 0x124000b4 }, - { 0x5033c, 0x2d80004c }, - { 0x5fffc, 0x130000b6 }, - { 0x50340, 0x2d000049 }, - { 0x5fffc, 0x140000b8 }, - { 0x50344, 0x2c800045 }, - { 0x5fffc, 0x150000b9 }, - { 0x50348, 0x2c000042 }, - { 0x5fffc, 0x15c000bd }, - { 0x5034c, 0x2b40003e }, - { 0x5fffc, 0x16c000bf }, - { 0x50350, 0x2a80003b }, - { 0x5fffc, 0x17c000bf }, - { 0x50354, 0x2a000039 }, - { 0x5fffc, 0x188000c2 }, - { 0x50358, 0x29400036 }, - { 0x5fffc, 0x19c000c4 }, - { 0x5035c, 0x28800032 }, - { 0x5fffc, 0x1ac000c5 }, - { 0x50360, 0x2800002f }, - { 0x5fffc, 0x1bc000c7 }, - { 0x50364, 0x2740002c }, - { 0x5fffc, 0x1cc000c8 }, - { 0x50368, 0x26c00029 }, - { 0x5fffc, 0x1dc000c9 }, - { 0x5036c, 0x26000027 }, - { 0x5fffc, 0x1ec000cc }, - { 0x50370, 0x25000024 }, - { 0x5fffc, 0x200000cc }, - { 0x50374, 0x24800021 }, - { 0x5fffc, 0x210000cd }, - { 0x50378, 0x23800020 }, - { 0x5fffc, 0x220000ce }, - { 0x5037c, 0x2300001d }, -}; - -static struct mdp_table_entry mdp_downscale_y_table_PT4TOPT6[] = { - { 0x5fffc, 0x740008c }, - { 0x50300, 0x33800088 }, - { 0x5fffc, 0x800008e }, - { 0x50304, 0x33400084 }, - { 0x5fffc, 0x8400092 }, - { 0x50308, 0x33000080 }, - { 0x5fffc, 0x9000094 }, - { 0x5030c, 0x3300007b }, - { 0x5fffc, 0x9c00098 }, - { 0x50310, 0x32400077 }, - { 0x5fffc, 0xa40009b }, - { 0x50314, 0x32000073 }, - { 0x5fffc, 0xb00009d }, - { 0x50318, 0x31c0006f }, - { 0x5fffc, 0xbc000a0 }, - { 0x5031c, 0x3140006b }, - { 0x5fffc, 0xc8000a2 }, - { 0x50320, 0x31000067 }, - { 0x5fffc, 0xd8000a5 }, - { 0x50324, 0x30800062 }, - { 0x5fffc, 0xe4000a8 }, - { 0x50328, 0x2fc0005f }, - { 0x5fffc, 0xec000aa }, - { 0x5032c, 0x2fc0005b }, - { 0x5fffc, 0xf8000ad }, - { 0x50330, 0x2f400057 }, - { 0x5fffc, 0x108000b0 }, - { 0x50334, 0x2e400054 }, - { 0x5fffc, 0x114000b2 }, - { 0x50338, 0x2e000050 }, - { 0x5fffc, 0x124000b4 }, - { 0x5033c, 0x2d80004c }, - { 0x5fffc, 0x130000b6 }, - { 0x50340, 0x2d000049 }, - { 0x5fffc, 0x140000b8 }, - { 0x50344, 0x2c800045 }, - { 0x5fffc, 0x150000b9 }, - { 0x50348, 0x2c000042 }, - { 0x5fffc, 0x15c000bd }, - { 0x5034c, 0x2b40003e }, - { 0x5fffc, 0x16c000bf }, - { 0x50350, 0x2a80003b }, - { 0x5fffc, 0x17c000bf }, - { 0x50354, 0x2a000039 }, - { 0x5fffc, 0x188000c2 }, - { 0x50358, 0x29400036 }, - { 0x5fffc, 0x19c000c4 }, - { 0x5035c, 0x28800032 }, - { 0x5fffc, 0x1ac000c5 }, - { 0x50360, 0x2800002f }, - { 0x5fffc, 0x1bc000c7 }, - { 0x50364, 0x2740002c }, - { 0x5fffc, 0x1cc000c8 }, - { 0x50368, 0x26c00029 }, - { 0x5fffc, 0x1dc000c9 }, - { 0x5036c, 0x26000027 }, - { 0x5fffc, 0x1ec000cc }, - { 0x50370, 0x25000024 }, - { 0x5fffc, 0x200000cc }, - { 0x50374, 0x24800021 }, - { 0x5fffc, 0x210000cd }, - { 0x50378, 0x23800020 }, - { 0x5fffc, 0x220000ce }, - { 0x5037c, 0x2300001d }, -}; - -static struct mdp_table_entry mdp_downscale_y_table_PT6TOPT8[] = { - { 0x5fffc, 0xfe000070 }, - { 0x50300, 0x4bc00068 }, - { 0x5fffc, 0xfe000078 }, - { 0x50304, 0x4bc00060 }, - { 0x5fffc, 0xfe000080 }, - { 0x50308, 0x4b800059 }, - { 0x5fffc, 0xfe000089 }, - { 0x5030c, 0x4b000052 }, - { 0x5fffc, 0xfe400091 }, - { 0x50310, 0x4a80004b }, - { 0x5fffc, 0xfe40009a }, - { 0x50314, 0x4a000044 }, - { 0x5fffc, 0xfe8000a3 }, - { 0x50318, 0x4940003d }, - { 0x5fffc, 0xfec000ac }, - { 0x5031c, 0x48400037 }, - { 0x5fffc, 0xff0000b4 }, - { 0x50320, 0x47800031 }, - { 0x5fffc, 0xff8000bd }, - { 0x50324, 0x4640002b }, - { 0x5fffc, 0xc5 }, - { 0x50328, 0x45000026 }, - { 0x5fffc, 0x8000ce }, - { 0x5032c, 0x43800021 }, - { 0x5fffc, 0x10000d6 }, - { 0x50330, 0x4240001c }, - { 0x5fffc, 0x18000df }, - { 0x50334, 0x40800018 }, - { 0x5fffc, 0x24000e6 }, - { 0x50338, 0x3f000014 }, - { 0x5fffc, 0x30000ee }, - { 0x5033c, 0x3d400010 }, - { 0x5fffc, 0x40000f5 }, - { 0x50340, 0x3b80000c }, - { 0x5fffc, 0x50000fc }, - { 0x50344, 0x39800009 }, - { 0x5fffc, 0x6000102 }, - { 0x50348, 0x37c00006 }, - { 0x5fffc, 0x7000109 }, - { 0x5034c, 0x35800004 }, - { 0x5fffc, 0x840010e }, - { 0x50350, 0x33800002 }, - { 0x5fffc, 0x9800114 }, - { 0x50354, 0x31400000 }, - { 0x5fffc, 0xac00119 }, - { 0x50358, 0x2f4003fe }, - { 0x5fffc, 0xc40011e }, - { 0x5035c, 0x2d0003fc }, - { 0x5fffc, 0xdc00121 }, - { 0x50360, 0x2b0003fb }, - { 0x5fffc, 0xf400125 }, - { 0x50364, 0x28c003fa }, - { 0x5fffc, 0x11000128 }, - { 0x50368, 0x268003f9 }, - { 0x5fffc, 0x12c0012a }, - { 0x5036c, 0x244003f9 }, - { 0x5fffc, 0x1480012c }, - { 0x50370, 0x224003f8 }, - { 0x5fffc, 0x1640012e }, - { 0x50374, 0x200003f8 }, - { 0x5fffc, 0x1800012f }, - { 0x50378, 0x1e0003f8 }, - { 0x5fffc, 0x1a00012f }, - { 0x5037c, 0x1c0003f8 }, -}; - -static struct mdp_table_entry mdp_downscale_y_table_PT8TO1[] = { - { 0x5fffc, 0x0 }, - { 0x50300, 0x7fc00000 }, - { 0x5fffc, 0xff80000d }, - { 0x50304, 0x7ec003f9 }, - { 0x5fffc, 0xfec0001c }, - { 0x50308, 0x7d4003f3 }, - { 0x5fffc, 0xfe40002b }, - { 0x5030c, 0x7b8003ed }, - { 0x5fffc, 0xfd80003c }, - { 0x50310, 0x794003e8 }, - { 0x5fffc, 0xfcc0004d }, - { 0x50314, 0x76c003e4 }, - { 0x5fffc, 0xfc40005f }, - { 0x50318, 0x73c003e0 }, - { 0x5fffc, 0xfb800071 }, - { 0x5031c, 0x708003de }, - { 0x5fffc, 0xfac00085 }, - { 0x50320, 0x6d0003db }, - { 0x5fffc, 0xfa000098 }, - { 0x50324, 0x698003d9 }, - { 0x5fffc, 0xf98000ac }, - { 0x50328, 0x654003d8 }, - { 0x5fffc, 0xf8c000c1 }, - { 0x5032c, 0x610003d7 }, - { 0x5fffc, 0xf84000d5 }, - { 0x50330, 0x5c8003d7 }, - { 0x5fffc, 0xf7c000e9 }, - { 0x50334, 0x580003d7 }, - { 0x5fffc, 0xf74000fd }, - { 0x50338, 0x534003d8 }, - { 0x5fffc, 0xf6c00112 }, - { 0x5033c, 0x4e8003d8 }, - { 0x5fffc, 0xf6800126 }, - { 0x50340, 0x494003da }, - { 0x5fffc, 0xf600013a }, - { 0x50344, 0x448003db }, - { 0x5fffc, 0xf600014d }, - { 0x50348, 0x3f4003dd }, - { 0x5fffc, 0xf5c00160 }, - { 0x5034c, 0x3a4003df }, - { 0x5fffc, 0xf5c00172 }, - { 0x50350, 0x354003e1 }, - { 0x5fffc, 0xf5c00184 }, - { 0x50354, 0x304003e3 }, - { 0x5fffc, 0xf6000195 }, - { 0x50358, 0x2b0003e6 }, - { 0x5fffc, 0xf64001a6 }, - { 0x5035c, 0x260003e8 }, - { 0x5fffc, 0xf6c001b4 }, - { 0x50360, 0x214003eb }, - { 0x5fffc, 0xf78001c2 }, - { 0x50364, 0x1c4003ee }, - { 0x5fffc, 0xf80001cf }, - { 0x50368, 0x17c003f1 }, - { 0x5fffc, 0xf90001db }, - { 0x5036c, 0x134003f3 }, - { 0x5fffc, 0xfa0001e5 }, - { 0x50370, 0xf0003f6 }, - { 0x5fffc, 0xfb4001ee }, - { 0x50374, 0xac003f9 }, - { 0x5fffc, 0xfcc001f5 }, - { 0x50378, 0x70003fb }, - { 0x5fffc, 0xfe4001fb }, - { 0x5037c, 0x34003fe }, -}; - -struct mdp_table_entry *mdp_downscale_y_table[MDP_DOWNSCALE_MAX] = { - [MDP_DOWNSCALE_PT2TOPT4] = mdp_downscale_y_table_PT2TOPT4, - [MDP_DOWNSCALE_PT4TOPT6] = mdp_downscale_y_table_PT4TOPT6, - [MDP_DOWNSCALE_PT6TOPT8] = mdp_downscale_y_table_PT6TOPT8, - [MDP_DOWNSCALE_PT8TO1] = mdp_downscale_y_table_PT8TO1, -}; - -struct mdp_table_entry mdp_gaussian_blur_table[] = { - /* max variance */ - { 0x5fffc, 0x20000080 }, - { 0x50280, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50284, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50288, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5028c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50290, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50294, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50298, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5029c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502a0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502a4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502a8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502ac, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502b0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502b4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502b8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502bc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502c0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502c4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502c8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502cc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502d0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502d4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502d8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502dc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502e0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502e4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502e8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502ec, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502f0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502f4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502f8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502fc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50300, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50304, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50308, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5030c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50310, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50314, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50318, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5031c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50320, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50324, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50328, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5032c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50330, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50334, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50338, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5033c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50340, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50344, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50348, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5034c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50350, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50354, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50358, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5035c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50360, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50364, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50368, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5036c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50370, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50374, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50378, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5037c, 0x20000080 }, -}; - -static void load_table(const struct mdp_info *mdp, - struct mdp_table_entry *table, int len) -{ - int i; - for (i = 0; i < len; i++) - mdp_writel(mdp, table[i].val, table[i].reg); -} - -enum { - IMG_LEFT, - IMG_RIGHT, - IMG_TOP, - IMG_BOTTOM, -}; - -static void get_edge_info(uint32_t src, uint32_t src_coord, uint32_t dst, - uint32_t *interp1, uint32_t *interp2, - uint32_t *repeat1, uint32_t *repeat2) { - if (src > 3 * dst) { - *interp1 = 0; - *interp2 = src - 1; - *repeat1 = 0; - *repeat2 = 0; - } else if (src == 3 * dst) { - *interp1 = 0; - *interp2 = src; - *repeat1 = 0; - *repeat2 = 1; - } else if (src > dst && src < 3 * dst) { - *interp1 = -1; - *interp2 = src; - *repeat1 = 1; - *repeat2 = 1; - } else if (src == dst) { - *interp1 = -1; - *interp2 = src + 1; - *repeat1 = 1; - *repeat2 = 2; - } else { - *interp1 = -2; - *interp2 = src + 1; - *repeat1 = 2; - *repeat2 = 2; - } - *interp1 += src_coord; - *interp2 += src_coord; -} - -int mdp_ppp_cfg_edge_cond(struct mdp_blit_req *req, struct ppp_regs *regs) -{ - int32_t luma_interp[4]; - int32_t luma_repeat[4]; - int32_t chroma_interp[4]; - int32_t chroma_bound[4]; - int32_t chroma_repeat[4]; - uint32_t dst_w, dst_h; - - memset(&luma_interp, 0, sizeof(int32_t) * 4); - memset(&luma_repeat, 0, sizeof(int32_t) * 4); - memset(&chroma_interp, 0, sizeof(int32_t) * 4); - memset(&chroma_bound, 0, sizeof(int32_t) * 4); - memset(&chroma_repeat, 0, sizeof(int32_t) * 4); - regs->edge = 0; - - if (req->flags & MDP_ROT_90) { - dst_w = req->dst_rect.h; - dst_h = req->dst_rect.w; - } else { - dst_w = req->dst_rect.w; - dst_h = req->dst_rect.h; - } - - if (regs->op & (PPP_OP_SCALE_Y_ON | PPP_OP_SCALE_X_ON)) { - get_edge_info(req->src_rect.h, req->src_rect.y, dst_h, - &luma_interp[IMG_TOP], &luma_interp[IMG_BOTTOM], - &luma_repeat[IMG_TOP], &luma_repeat[IMG_BOTTOM]); - get_edge_info(req->src_rect.w, req->src_rect.x, dst_w, - &luma_interp[IMG_LEFT], &luma_interp[IMG_RIGHT], - &luma_repeat[IMG_LEFT], &luma_repeat[IMG_RIGHT]); - } else { - luma_interp[IMG_LEFT] = req->src_rect.x; - luma_interp[IMG_RIGHT] = req->src_rect.x + req->src_rect.w - 1; - luma_interp[IMG_TOP] = req->src_rect.y; - luma_interp[IMG_BOTTOM] = req->src_rect.y + req->src_rect.h - 1; - luma_repeat[IMG_LEFT] = 0; - luma_repeat[IMG_TOP] = 0; - luma_repeat[IMG_RIGHT] = 0; - luma_repeat[IMG_BOTTOM] = 0; - } - - chroma_interp[IMG_LEFT] = luma_interp[IMG_LEFT]; - chroma_interp[IMG_RIGHT] = luma_interp[IMG_RIGHT]; - chroma_interp[IMG_TOP] = luma_interp[IMG_TOP]; - chroma_interp[IMG_BOTTOM] = luma_interp[IMG_BOTTOM]; - - chroma_bound[IMG_LEFT] = req->src_rect.x; - chroma_bound[IMG_RIGHT] = req->src_rect.x + req->src_rect.w - 1; - chroma_bound[IMG_TOP] = req->src_rect.y; - chroma_bound[IMG_BOTTOM] = req->src_rect.y + req->src_rect.h - 1; - - if (IS_YCRCB(req->src.format)) { - chroma_interp[IMG_LEFT] = chroma_interp[IMG_LEFT] >> 1; - chroma_interp[IMG_RIGHT] = (chroma_interp[IMG_RIGHT] + 1) >> 1; - - chroma_bound[IMG_LEFT] = chroma_bound[IMG_LEFT] >> 1; - chroma_bound[IMG_RIGHT] = chroma_bound[IMG_RIGHT] >> 1; - } - - if (req->src.format == MDP_Y_CBCR_H2V2 || - req->src.format == MDP_Y_CRCB_H2V2) { - chroma_interp[IMG_TOP] = (chroma_interp[IMG_TOP] - 1) >> 1; - chroma_interp[IMG_BOTTOM] = (chroma_interp[IMG_BOTTOM] + 1) - >> 1; - chroma_bound[IMG_TOP] = (chroma_bound[IMG_TOP] + 1) >> 1; - chroma_bound[IMG_BOTTOM] = chroma_bound[IMG_BOTTOM] >> 1; - } - - chroma_repeat[IMG_LEFT] = chroma_bound[IMG_LEFT] - - chroma_interp[IMG_LEFT]; - chroma_repeat[IMG_RIGHT] = chroma_interp[IMG_RIGHT] - - chroma_bound[IMG_RIGHT]; - chroma_repeat[IMG_TOP] = chroma_bound[IMG_TOP] - - chroma_interp[IMG_TOP]; - chroma_repeat[IMG_BOTTOM] = chroma_interp[IMG_BOTTOM] - - chroma_bound[IMG_BOTTOM]; - - if (chroma_repeat[IMG_LEFT] < 0 || chroma_repeat[IMG_LEFT] > 3 || - chroma_repeat[IMG_RIGHT] < 0 || chroma_repeat[IMG_RIGHT] > 3 || - chroma_repeat[IMG_TOP] < 0 || chroma_repeat[IMG_TOP] > 3 || - chroma_repeat[IMG_BOTTOM] < 0 || chroma_repeat[IMG_BOTTOM] > 3 || - luma_repeat[IMG_LEFT] < 0 || luma_repeat[IMG_LEFT] > 3 || - luma_repeat[IMG_RIGHT] < 0 || luma_repeat[IMG_RIGHT] > 3 || - luma_repeat[IMG_TOP] < 0 || luma_repeat[IMG_TOP] > 3 || - luma_repeat[IMG_BOTTOM] < 0 || luma_repeat[IMG_BOTTOM] > 3) - return -1; - - regs->edge |= (chroma_repeat[IMG_LEFT] & 3) << MDP_LEFT_CHROMA; - regs->edge |= (chroma_repeat[IMG_RIGHT] & 3) << MDP_RIGHT_CHROMA; - regs->edge |= (chroma_repeat[IMG_TOP] & 3) << MDP_TOP_CHROMA; - regs->edge |= (chroma_repeat[IMG_BOTTOM] & 3) << MDP_BOTTOM_CHROMA; - regs->edge |= (luma_repeat[IMG_LEFT] & 3) << MDP_LEFT_LUMA; - regs->edge |= (luma_repeat[IMG_RIGHT] & 3) << MDP_RIGHT_LUMA; - regs->edge |= (luma_repeat[IMG_TOP] & 3) << MDP_TOP_LUMA; - regs->edge |= (luma_repeat[IMG_BOTTOM] & 3) << MDP_BOTTOM_LUMA; - return 0; -} - -#define ONE_HALF (1LL << 32) -#define ONE (1LL << 33) -#define TWO (2LL << 33) -#define THREE (3LL << 33) -#define FRAC_MASK (ONE - 1) -#define INT_MASK (~FRAC_MASK) - -static int scale_params(uint32_t dim_in, uint32_t dim_out, uint32_t origin, - uint32_t *phase_init, uint32_t *phase_step) -{ - /* to improve precicsion calculations are done in U31.33 and converted - * to U3.29 at the end */ - int64_t k1, k2, k3, k4, tmp; - uint64_t n, d, os, os_p, od, od_p, oreq; - unsigned rpa = 0; - int64_t ip64, delta; - - if (dim_out % 3 == 0) - rpa = !(dim_in % (dim_out / 3)); - - n = ((uint64_t)dim_out) << 34; - d = dim_in; - if (!d) - return -1; - do_div(n, d); - k3 = (n + 1) >> 1; - if ((k3 >> 4) < (1LL << 27) || (k3 >> 4) > (1LL << 31)) - return -1; - - n = ((uint64_t)dim_in) << 34; - d = (uint64_t)dim_out; - if (!d) - return -1; - do_div(n, d); - k1 = (n + 1) >> 1; - k2 = (k1 - ONE) >> 1; - - *phase_init = (int)(k2 >> 4); - k4 = (k3 - ONE) >> 1; - - if (rpa) { - os = ((uint64_t)origin << 33) - ONE_HALF; - tmp = (dim_out * os) + ONE_HALF; - if (!dim_in) - return -1; - do_div(tmp, dim_in); - od = tmp - ONE_HALF; - } else { - os = ((uint64_t)origin << 1) - 1; - od = (((k3 * os) >> 1) + k4); - } - - od_p = od & INT_MASK; - if (od_p != od) - od_p += ONE; - - if (rpa) { - tmp = (dim_in * od_p) + ONE_HALF; - if (!dim_in) - return -1; - do_div(tmp, dim_in); - os_p = tmp - ONE_HALF; - } else { - os_p = ((k1 * (od_p >> 33)) + k2); - } - - oreq = (os_p & INT_MASK) - ONE; - - ip64 = os_p - oreq; - delta = ((int64_t)(origin) << 33) - oreq; - ip64 -= delta; - /* limit to valid range before the left shift */ - delta = (ip64 & (1LL << 63)) ? 4 : -4; - delta <<= 33; - while (abs((int)(ip64 >> 33)) > 4) - ip64 += delta; - *phase_init = (int)(ip64 >> 4); - *phase_step = (uint32_t)(k1 >> 4); - return 0; -} - -int mdp_ppp_cfg_scale(const struct mdp_info *mdp, struct ppp_regs *regs, - struct mdp_rect *src_rect, struct mdp_rect *dst_rect, - uint32_t src_format, uint32_t dst_format) -{ - int downscale; - uint32_t phase_init_x, phase_init_y, phase_step_x, phase_step_y; - uint32_t scale_factor_x, scale_factor_y; - - if (scale_params(src_rect->w, dst_rect->w, 1, &phase_init_x, - &phase_step_x) || - scale_params(src_rect->h, dst_rect->h, 1, &phase_init_y, - &phase_step_y)) - return -1; - - regs->phasex_init = phase_init_x; - regs->phasey_init = phase_init_y; - regs->phasex_step = phase_step_x; - regs->phasey_step = phase_step_y; - - scale_factor_x = (dst_rect->w * 10) / src_rect->w; - scale_factor_y = (dst_rect->h * 10) / src_rect->h; - - if (scale_factor_x > 8) - downscale = MDP_DOWNSCALE_PT8TO1; - else if (scale_factor_x > 6) - downscale = MDP_DOWNSCALE_PT6TOPT8; - else if (scale_factor_x > 4) - downscale = MDP_DOWNSCALE_PT4TOPT6; - else - downscale = MDP_DOWNSCALE_PT2TOPT4; - - if (downscale != downscale_x_table) { - load_table(mdp, mdp_downscale_x_table[downscale], 64); - downscale_x_table = downscale; - } - - if (scale_factor_y > 8) - downscale = MDP_DOWNSCALE_PT8TO1; - else if (scale_factor_y > 6) - downscale = MDP_DOWNSCALE_PT6TOPT8; - else if (scale_factor_y > 4) - downscale = MDP_DOWNSCALE_PT4TOPT6; - else - downscale = MDP_DOWNSCALE_PT2TOPT4; - - if (downscale != downscale_y_table) { - load_table(mdp, mdp_downscale_y_table[downscale], 64); - downscale_y_table = downscale; - } - - return 0; -} - - -int mdp_ppp_load_blur(const struct mdp_info *mdp) -{ - if (!(downscale_x_table == MDP_DOWNSCALE_BLUR && - downscale_y_table == MDP_DOWNSCALE_BLUR)) { - load_table(mdp, mdp_gaussian_blur_table, 128); - downscale_x_table = MDP_DOWNSCALE_BLUR; - downscale_y_table = MDP_DOWNSCALE_BLUR; - } - - return 0; -} - -void mdp_ppp_init_scale(const struct mdp_info *mdp) -{ - downscale_x_table = MDP_DOWNSCALE_MAX; - downscale_y_table = MDP_DOWNSCALE_MAX; - - load_table(mdp, mdp_upscale_table, ARRAY_SIZE(mdp_upscale_table)); -} diff --git a/drivers/video/msm/mdp_ppp31.c b/drivers/video/msm/mdp_ppp31.c deleted file mode 100644 index 2d28358fe2df53bac615c5a9fed8cec283f13eb7..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_ppp31.c +++ /dev/null @@ -1,332 +0,0 @@ -/* drivers/video/msm/mdp_ppp31.c - * - * Copyright (C) 2009 The Linux Foundation. All rights reserved. - * Copyright (C) 2009 Google Incorporated - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include - -#include "mdp_hw.h" -#include "mdp_ppp.h" - -#define NUM_COEFFS 32 - -struct mdp_scale_coeffs { - uint16_t c[4][NUM_COEFFS]; -}; - -struct mdp_scale_tbl_info { - uint16_t offset; - uint32_t set:2; - int use_pr; - struct mdp_scale_coeffs coeffs; -}; - -enum { - MDP_SCALE_PT2TOPT4, - MDP_SCALE_PT4TOPT6, - MDP_SCALE_PT6TOPT8, - MDP_SCALE_PT8TO8, - MDP_SCALE_MAX, -}; - -static struct mdp_scale_coeffs mdp_scale_pr_coeffs = { - .c = { - [0] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }, - [1] = { - 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }, - [2] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, - }, - [3] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - }, - }, -}; - -static struct mdp_scale_tbl_info mdp_scale_tbl[MDP_SCALE_MAX] = { - [ MDP_SCALE_PT2TOPT4 ] = { - .offset = 0, - .set = MDP_PPP_SCALE_COEFF_D0_SET, - .use_pr = -1, - .coeffs.c = { - [0] = { - 131, 131, 130, 129, 128, 127, 127, 126, - 125, 125, 124, 123, 123, 121, 120, 119, - 119, 118, 117, 117, 116, 115, 115, 114, - 113, 112, 111, 110, 109, 109, 108, 107, - }, - [1] = { - 141, 140, 140, 140, 140, 139, 138, 138, - 138, 137, 137, 137, 136, 137, 137, 137, - 136, 136, 136, 135, 135, 135, 134, 134, - 134, 134, 134, 133, 133, 132, 132, 132, - }, - [2] = { - 132, 132, 132, 133, 133, 134, 134, 134, - 134, 134, 135, 135, 135, 136, 136, 136, - 137, 137, 137, 136, 137, 137, 137, 138, - 138, 138, 139, 140, 140, 140, 140, 141, - }, - [3] = { - 107, 108, 109, 109, 110, 111, 112, 113, - 114, 115, 115, 116, 117, 117, 118, 119, - 119, 120, 121, 123, 123, 124, 125, 125, - 126, 127, 127, 128, 129, 130, 131, 131, - } - }, - }, - [ MDP_SCALE_PT4TOPT6 ] = { - .offset = 32, - .set = MDP_PPP_SCALE_COEFF_D1_SET, - .use_pr = -1, - .coeffs.c = { - [0] = { - 136, 132, 128, 123, 119, 115, 111, 107, - 103, 98, 95, 91, 87, 84, 80, 76, - 73, 69, 66, 62, 59, 57, 54, 50, - 47, 44, 41, 39, 36, 33, 32, 29, - }, - [1] = { - 206, 205, 204, 204, 201, 200, 199, 197, - 196, 194, 191, 191, 189, 185, 184, 182, - 180, 178, 176, 173, 170, 168, 165, 162, - 160, 157, 155, 152, 148, 146, 142, 140, - }, - [2] = { - 140, 142, 146, 148, 152, 155, 157, 160, - 162, 165, 168, 170, 173, 176, 178, 180, - 182, 184, 185, 189, 191, 191, 194, 196, - 197, 199, 200, 201, 204, 204, 205, 206, - }, - [3] = { - 29, 32, 33, 36, 39, 41, 44, 47, - 50, 54, 57, 59, 62, 66, 69, 73, - 76, 80, 84, 87, 91, 95, 98, 103, - 107, 111, 115, 119, 123, 128, 132, 136, - }, - }, - }, - [ MDP_SCALE_PT6TOPT8 ] = { - .offset = 64, - .set = MDP_PPP_SCALE_COEFF_D2_SET, - .use_pr = -1, - .coeffs.c = { - [0] = { - 104, 96, 89, 82, 75, 68, 61, 55, - 49, 43, 38, 33, 28, 24, 20, 16, - 12, 9, 6, 4, 2, 0, -2, -4, - -5, -6, -7, -7, -8, -8, -8, -8, - }, - [1] = { - 303, 303, 302, 300, 298, 296, 293, 289, - 286, 281, 276, 270, 265, 258, 252, 245, - 238, 230, 223, 214, 206, 197, 189, 180, - 172, 163, 154, 145, 137, 128, 120, 112, - }, - [2] = { - 112, 120, 128, 137, 145, 154, 163, 172, - 180, 189, 197, 206, 214, 223, 230, 238, - 245, 252, 258, 265, 270, 276, 281, 286, - 289, 293, 296, 298, 300, 302, 303, 303, - }, - [3] = { - -8, -8, -8, -8, -7, -7, -6, -5, - -4, -2, 0, 2, 4, 6, 9, 12, - 16, 20, 24, 28, 33, 38, 43, 49, - 55, 61, 68, 75, 82, 89, 96, 104, - }, - }, - }, - [ MDP_SCALE_PT8TO8 ] = { - .offset = 96, - .set = MDP_PPP_SCALE_COEFF_U1_SET, - .use_pr = -1, - .coeffs.c = { - [0] = { - 0, -7, -13, -19, -24, -28, -32, -34, - -37, -39, -40, -41, -41, -41, -40, -40, - -38, -37, -35, -33, -31, -29, -26, -24, - -21, -18, -15, -13, -10, -7, -5, -2, - }, - [1] = { - 511, 507, 501, 494, 485, 475, 463, 450, - 436, 422, 405, 388, 370, 352, 333, 314, - 293, 274, 253, 233, 213, 193, 172, 152, - 133, 113, 95, 77, 60, 43, 28, 13, - }, - [2] = { - 0, 13, 28, 43, 60, 77, 95, 113, - 133, 152, 172, 193, 213, 233, 253, 274, - 294, 314, 333, 352, 370, 388, 405, 422, - 436, 450, 463, 475, 485, 494, 501, 507, - }, - [3] = { - 0, -2, -5, -7, -10, -13, -15, -18, - -21, -24, -26, -29, -31, -33, -35, -37, - -38, -40, -40, -41, -41, -41, -40, -39, - -37, -34, -32, -28, -24, -19, -13, -7, - }, - }, - }, -}; - -static void load_table(const struct mdp_info *mdp, int scale, int use_pr) -{ - int i; - uint32_t val; - struct mdp_scale_coeffs *coeffs; - struct mdp_scale_tbl_info *tbl = &mdp_scale_tbl[scale]; - - if (use_pr == tbl->use_pr) - return; - - tbl->use_pr = use_pr; - if (!use_pr) - coeffs = &tbl->coeffs; - else - coeffs = &mdp_scale_pr_coeffs; - - for (i = 0; i < NUM_COEFFS; ++i) { - val = ((coeffs->c[1][i] & 0x3ff) << 16) | - (coeffs->c[0][i] & 0x3ff); - mdp_writel(mdp, val, MDP_PPP_SCALE_COEFF_LSBn(tbl->offset + i)); - - val = ((coeffs->c[3][i] & 0x3ff) << 16) | - (coeffs->c[2][i] & 0x3ff); - mdp_writel(mdp, val, MDP_PPP_SCALE_COEFF_MSBn(tbl->offset + i)); - } -} - -#define SCALER_PHASE_BITS 29 -static void scale_params(uint32_t dim_in, uint32_t dim_out, uint32_t scaler, - uint32_t *phase_init, uint32_t *phase_step) -{ - uint64_t src = dim_in; - uint64_t dst = dim_out; - uint64_t numer; - uint64_t denom; - - *phase_init = 0; - - if (dst == 1) { - /* if destination is 1 pixel wide, the value of phase_step - * is unimportant. */ - *phase_step = (uint32_t) (src << SCALER_PHASE_BITS); - if (scaler == MDP_PPP_SCALER_FIR) - *phase_init = - (uint32_t) ((src - 1) << SCALER_PHASE_BITS); - return; - } - - if (scaler == MDP_PPP_SCALER_FIR) { - numer = (src - 1) << SCALER_PHASE_BITS; - denom = dst - 1; - /* we want to round up the result*/ - numer += denom - 1; - } else { - numer = src << SCALER_PHASE_BITS; - denom = dst; - } - - do_div(numer, denom); - *phase_step = (uint32_t) numer; -} - -static int scale_idx(int factor) -{ - int idx; - - if (factor > 80) - idx = MDP_SCALE_PT8TO8; - else if (factor > 60) - idx = MDP_SCALE_PT6TOPT8; - else if (factor > 40) - idx = MDP_SCALE_PT4TOPT6; - else - idx = MDP_SCALE_PT2TOPT4; - - return idx; -} - -int mdp_ppp_cfg_scale(const struct mdp_info *mdp, struct ppp_regs *regs, - struct mdp_rect *src_rect, struct mdp_rect *dst_rect, - uint32_t src_format, uint32_t dst_format) -{ - uint32_t x_fac; - uint32_t y_fac; - uint32_t scaler_x = MDP_PPP_SCALER_FIR; - uint32_t scaler_y = MDP_PPP_SCALER_FIR; - // Don't use pixel repeat mode, it looks bad - int use_pr = 0; - int x_idx; - int y_idx; - - if (unlikely(src_rect->w > 2048 || src_rect->h > 2048)) - return -ENOTSUPP; - - x_fac = (dst_rect->w * 100) / src_rect->w; - y_fac = (dst_rect->h * 100) / src_rect->h; - - /* if down-scaling by a factor smaller than 1/4, use M/N */ - scaler_x = x_fac <= 25 ? MDP_PPP_SCALER_MN : MDP_PPP_SCALER_FIR; - scaler_y = y_fac <= 25 ? MDP_PPP_SCALER_MN : MDP_PPP_SCALER_FIR; - scale_params(src_rect->w, dst_rect->w, scaler_x, ®s->phasex_init, - ®s->phasex_step); - scale_params(src_rect->h, dst_rect->h, scaler_y, ®s->phasey_init, - ®s->phasey_step); - - x_idx = scale_idx(x_fac); - y_idx = scale_idx(y_fac); - load_table(mdp, x_idx, use_pr); - load_table(mdp, y_idx, use_pr); - - regs->scale_cfg = 0; - // Enable SVI when source or destination is YUV - if (!IS_RGB(src_format) && !IS_RGB(dst_format)) - regs->scale_cfg |= (1 << 6); - regs->scale_cfg |= (mdp_scale_tbl[x_idx].set << 2) | - (mdp_scale_tbl[x_idx].set << 4); - regs->scale_cfg |= (scaler_x << 0) | (scaler_y << 1); - - return 0; -} - -int mdp_ppp_load_blur(const struct mdp_info *mdp) -{ - return -ENOTSUPP; -} - -void mdp_ppp_init_scale(const struct mdp_info *mdp) -{ - int scale; - for (scale = 0; scale < MDP_SCALE_MAX; ++scale) - load_table(mdp, scale, 0); -} diff --git a/drivers/video/msm/mdp_ppp_v20.c b/drivers/video/msm/mdp_ppp_v20.c deleted file mode 100644 index e816f0aa0127d683b9fe7241d4d590118a2795fc..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_ppp_v20.c +++ /dev/null @@ -1,2545 +0,0 @@ -/* Copyright (c) 2008-2009, 2012-2013 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 -#include -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" - -#include -#include - -#include -#include - -#include "mdp.h" -#include "msm_fb.h" - -static MDP_SCALE_MODE mdp_curr_up_scale_xy; -static MDP_SCALE_MODE mdp_curr_down_scale_x; -static MDP_SCALE_MODE mdp_curr_down_scale_y; - -static long long mdp_do_div(long long num, long long den) -{ - do_div(num, den); - return num; -} - -struct mdp_table_entry mdp_gaussian_blur_table[] = { - /* max variance */ - { 0x5fffc, 0x20000080 }, - { 0x50280, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50284, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50288, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5028c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50290, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50294, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50298, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5029c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502a0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502a4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502a8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502ac, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502b0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502b4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502b8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502bc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502c0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502c4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502c8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502cc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502d0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502d4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502d8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502dc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502e0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502e4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502e8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502ec, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502f0, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502f4, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502f8, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x502fc, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50300, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50304, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50308, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5030c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50310, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50314, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50318, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5031c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50320, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50324, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50328, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5032c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50330, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50334, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50338, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5033c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50340, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50344, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50348, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5034c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50350, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50354, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50358, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5035c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50360, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50364, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50368, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5036c, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50370, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50374, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x50378, 0x20000080 }, - { 0x5fffc, 0x20000080 }, - { 0x5037c, 0x20000080 }, -}; - -static void load_scale_table( - struct mdp_table_entry *table, int len) -{ - int i; - for (i = 0; i < len; i++) - MDP_OUTP(MDP_BASE + table[i].reg, table[i].val); -} - -static void mdp_load_pr_upscale_table(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50200, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50204, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50208, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5020c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50210, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50214, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50218, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5021c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50220, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50224, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50228, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5022c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50230, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50234, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50238, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5023c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50240, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50244, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50248, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5024c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50250, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50254, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50258, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5025c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50260, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50264, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50268, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5026c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50270, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50274, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50278, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5027c, 0x0); -} - -static void mdp_load_pr_downscale_table_x_point2TOpoint4(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502cc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502dc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502ec, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502fc, 0x0); -} - -static void mdp_load_pr_downscale_table_y_point2TOpoint4(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50340, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50344, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50348, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5034c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50350, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50354, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50358, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5035c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50360, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50364, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50368, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5036c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50370, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50374, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50378, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5037c, 0x0); -} - -static void mdp_load_pr_downscale_table_x_point4TOpoint6(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502cc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502dc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502ec, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502fc, 0x0); -} - -static void mdp_load_pr_downscale_table_y_point4TOpoint6(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50340, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50344, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50348, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5034c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50350, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50354, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50358, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5035c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50360, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50364, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50368, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5036c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50370, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50374, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50378, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5037c, 0x0); -} - -static void mdp_load_pr_downscale_table_x_point6TOpoint8(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502cc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502dc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502ec, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502fc, 0x0); -} - -static void mdp_load_pr_downscale_table_y_point6TOpoint8(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50340, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50344, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50348, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5034c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50350, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50354, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50358, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5035c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50360, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50364, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50368, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5036c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50370, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50374, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50378, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5037c, 0x0); -} - -static void mdp_load_pr_downscale_table_x_point8TO1(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50284, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50288, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5028c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50290, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50294, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50298, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5029c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502a8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502ac, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b0, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b4, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502b8, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x502bc, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502c8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502cc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502d8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502dc, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502e8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502ec, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f0, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f4, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502f8, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x502fc, 0x0); -} - -static void mdp_load_pr_downscale_table_y_point8TO1(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50304, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50308, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5030c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50310, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50314, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50318, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5031c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50320, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50324, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50328, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5032c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50330, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50334, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50338, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x5033c, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50340, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50344, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50348, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5034c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50350, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50354, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50358, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5035c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50360, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50364, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50368, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5036c, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50370, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50374, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x50378, 0x0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ff); - MDP_OUTP(MDP_BASE + 0x5037c, 0x0); -} - -static void mdp_load_bc_upscale_table(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50200, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xff80000d); - MDP_OUTP(MDP_BASE + 0x50204, 0x7ec003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec0001c); - MDP_OUTP(MDP_BASE + 0x50208, 0x7d4003f3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40002b); - MDP_OUTP(MDP_BASE + 0x5020c, 0x7b8003ed); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfd80003c); - MDP_OUTP(MDP_BASE + 0x50210, 0x794003e8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc0004d); - MDP_OUTP(MDP_BASE + 0x50214, 0x76c003e4); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfc40005f); - MDP_OUTP(MDP_BASE + 0x50218, 0x73c003e0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb800071); - MDP_OUTP(MDP_BASE + 0x5021c, 0x708003de); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfac00085); - MDP_OUTP(MDP_BASE + 0x50220, 0x6d0003db); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa000098); - MDP_OUTP(MDP_BASE + 0x50224, 0x698003d9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf98000ac); - MDP_OUTP(MDP_BASE + 0x50228, 0x654003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8c000c1); - MDP_OUTP(MDP_BASE + 0x5022c, 0x610003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf84000d5); - MDP_OUTP(MDP_BASE + 0x50230, 0x5c8003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf7c000e9); - MDP_OUTP(MDP_BASE + 0x50234, 0x580003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf74000fd); - MDP_OUTP(MDP_BASE + 0x50238, 0x534003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c00112); - MDP_OUTP(MDP_BASE + 0x5023c, 0x4e8003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6800126); - MDP_OUTP(MDP_BASE + 0x50240, 0x494003da); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600013a); - MDP_OUTP(MDP_BASE + 0x50244, 0x448003db); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600014d); - MDP_OUTP(MDP_BASE + 0x50248, 0x3f4003dd); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00160); - MDP_OUTP(MDP_BASE + 0x5024c, 0x3a4003df); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00172); - MDP_OUTP(MDP_BASE + 0x50250, 0x354003e1); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00184); - MDP_OUTP(MDP_BASE + 0x50254, 0x304003e3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6000195); - MDP_OUTP(MDP_BASE + 0x50258, 0x2b0003e6); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf64001a6); - MDP_OUTP(MDP_BASE + 0x5025c, 0x260003e8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c001b4); - MDP_OUTP(MDP_BASE + 0x50260, 0x214003eb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf78001c2); - MDP_OUTP(MDP_BASE + 0x50264, 0x1c4003ee); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf80001cf); - MDP_OUTP(MDP_BASE + 0x50268, 0x17c003f1); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf90001db); - MDP_OUTP(MDP_BASE + 0x5026c, 0x134003f3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa0001e5); - MDP_OUTP(MDP_BASE + 0x50270, 0xf0003f6); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb4001ee); - MDP_OUTP(MDP_BASE + 0x50274, 0xac003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc001f5); - MDP_OUTP(MDP_BASE + 0x50278, 0x70003fb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe4001fb); - MDP_OUTP(MDP_BASE + 0x5027c, 0x34003fe); -} - -static void mdp_load_bc_downscale_table_x_point2TOpoint4(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac00084); - MDP_OUTP(MDP_BASE + 0x50280, 0x23400083); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b000084); - MDP_OUTP(MDP_BASE + 0x50284, 0x23000083); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400084); - MDP_OUTP(MDP_BASE + 0x50288, 0x23000082); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400085); - MDP_OUTP(MDP_BASE + 0x5028c, 0x23000081); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b800085); - MDP_OUTP(MDP_BASE + 0x50290, 0x23000080); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc00086); - MDP_OUTP(MDP_BASE + 0x50294, 0x22c0007f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c000086); - MDP_OUTP(MDP_BASE + 0x50298, 0x2280007f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c400086); - MDP_OUTP(MDP_BASE + 0x5029c, 0x2280007e); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c800086); - MDP_OUTP(MDP_BASE + 0x502a0, 0x2280007d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00086); - MDP_OUTP(MDP_BASE + 0x502a4, 0x2240007d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00087); - MDP_OUTP(MDP_BASE + 0x502a8, 0x2240007c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d000087); - MDP_OUTP(MDP_BASE + 0x502ac, 0x2240007b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400087); - MDP_OUTP(MDP_BASE + 0x502b0, 0x2200007b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400088); - MDP_OUTP(MDP_BASE + 0x502b4, 0x22400079); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d800088); - MDP_OUTP(MDP_BASE + 0x502b8, 0x22400078); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00088); - MDP_OUTP(MDP_BASE + 0x502bc, 0x22400077); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00089); - MDP_OUTP(MDP_BASE + 0x502c0, 0x22000077); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e000089); - MDP_OUTP(MDP_BASE + 0x502c4, 0x22000076); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e400089); - MDP_OUTP(MDP_BASE + 0x502c8, 0x22000075); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00088); - MDP_OUTP(MDP_BASE + 0x502cc, 0x21c00075); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00089); - MDP_OUTP(MDP_BASE + 0x502d0, 0x21c00074); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f000089); - MDP_OUTP(MDP_BASE + 0x502d4, 0x21c00073); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f400089); - MDP_OUTP(MDP_BASE + 0x502d8, 0x21800073); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f40008a); - MDP_OUTP(MDP_BASE + 0x502dc, 0x21800072); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f80008a); - MDP_OUTP(MDP_BASE + 0x502e0, 0x21800071); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008a); - MDP_OUTP(MDP_BASE + 0x502e4, 0x21800070); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008b); - MDP_OUTP(MDP_BASE + 0x502e8, 0x2180006f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x2000008c); - MDP_OUTP(MDP_BASE + 0x502ec, 0x2140006e); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x2040008c); - MDP_OUTP(MDP_BASE + 0x502f0, 0x2140006d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x2080008c); - MDP_OUTP(MDP_BASE + 0x502f4, 0x2100006d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008c); - MDP_OUTP(MDP_BASE + 0x502f8, 0x2100006c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008d); - MDP_OUTP(MDP_BASE + 0x502fc, 0x2100006b); -} - -static void mdp_load_bc_downscale_table_y_point2TOpoint4(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac00084); - MDP_OUTP(MDP_BASE + 0x50300, 0x23400083); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b000084); - MDP_OUTP(MDP_BASE + 0x50304, 0x23000083); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400084); - MDP_OUTP(MDP_BASE + 0x50308, 0x23000082); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b400085); - MDP_OUTP(MDP_BASE + 0x5030c, 0x23000081); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1b800085); - MDP_OUTP(MDP_BASE + 0x50310, 0x23000080); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc00086); - MDP_OUTP(MDP_BASE + 0x50314, 0x22c0007f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c000086); - MDP_OUTP(MDP_BASE + 0x50318, 0x2280007f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c400086); - MDP_OUTP(MDP_BASE + 0x5031c, 0x2280007e); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1c800086); - MDP_OUTP(MDP_BASE + 0x50320, 0x2280007d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00086); - MDP_OUTP(MDP_BASE + 0x50324, 0x2240007d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc00087); - MDP_OUTP(MDP_BASE + 0x50328, 0x2240007c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d000087); - MDP_OUTP(MDP_BASE + 0x5032c, 0x2240007b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400087); - MDP_OUTP(MDP_BASE + 0x50330, 0x2200007b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d400088); - MDP_OUTP(MDP_BASE + 0x50334, 0x22400079); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1d800088); - MDP_OUTP(MDP_BASE + 0x50338, 0x22400078); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00088); - MDP_OUTP(MDP_BASE + 0x5033c, 0x22400077); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc00089); - MDP_OUTP(MDP_BASE + 0x50340, 0x22000077); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e000089); - MDP_OUTP(MDP_BASE + 0x50344, 0x22000076); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1e400089); - MDP_OUTP(MDP_BASE + 0x50348, 0x22000075); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00088); - MDP_OUTP(MDP_BASE + 0x5034c, 0x21c00075); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec00089); - MDP_OUTP(MDP_BASE + 0x50350, 0x21c00074); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f000089); - MDP_OUTP(MDP_BASE + 0x50354, 0x21c00073); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f400089); - MDP_OUTP(MDP_BASE + 0x50358, 0x21800073); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f40008a); - MDP_OUTP(MDP_BASE + 0x5035c, 0x21800072); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1f80008a); - MDP_OUTP(MDP_BASE + 0x50360, 0x21800071); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008a); - MDP_OUTP(MDP_BASE + 0x50364, 0x21800070); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1fc0008b); - MDP_OUTP(MDP_BASE + 0x50368, 0x2180006f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x2000008c); - MDP_OUTP(MDP_BASE + 0x5036c, 0x2140006e); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x2040008c); - MDP_OUTP(MDP_BASE + 0x50370, 0x2140006d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x2080008c); - MDP_OUTP(MDP_BASE + 0x50374, 0x2100006d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008c); - MDP_OUTP(MDP_BASE + 0x50378, 0x2100006c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x20c0008d); - MDP_OUTP(MDP_BASE + 0x5037c, 0x2100006b); -} - -static void mdp_load_bc_downscale_table_x_point4TOpoint6(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x740008c); - MDP_OUTP(MDP_BASE + 0x50280, 0x33800088); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x800008e); - MDP_OUTP(MDP_BASE + 0x50284, 0x33400084); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x8400092); - MDP_OUTP(MDP_BASE + 0x50288, 0x33000080); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x9000094); - MDP_OUTP(MDP_BASE + 0x5028c, 0x3300007b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x9c00098); - MDP_OUTP(MDP_BASE + 0x50290, 0x32400077); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xa40009b); - MDP_OUTP(MDP_BASE + 0x50294, 0x32000073); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xb00009d); - MDP_OUTP(MDP_BASE + 0x50298, 0x31c0006f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xbc000a0); - MDP_OUTP(MDP_BASE + 0x5029c, 0x3140006b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xc8000a2); - MDP_OUTP(MDP_BASE + 0x502a0, 0x31000067); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xd8000a5); - MDP_OUTP(MDP_BASE + 0x502a4, 0x30800062); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xe4000a8); - MDP_OUTP(MDP_BASE + 0x502a8, 0x2fc0005f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xec000aa); - MDP_OUTP(MDP_BASE + 0x502ac, 0x2fc0005b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8000ad); - MDP_OUTP(MDP_BASE + 0x502b0, 0x2f400057); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x108000b0); - MDP_OUTP(MDP_BASE + 0x502b4, 0x2e400054); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x114000b2); - MDP_OUTP(MDP_BASE + 0x502b8, 0x2e000050); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x124000b4); - MDP_OUTP(MDP_BASE + 0x502bc, 0x2d80004c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x130000b6); - MDP_OUTP(MDP_BASE + 0x502c0, 0x2d000049); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x140000b8); - MDP_OUTP(MDP_BASE + 0x502c4, 0x2c800045); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x150000b9); - MDP_OUTP(MDP_BASE + 0x502c8, 0x2c000042); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x15c000bd); - MDP_OUTP(MDP_BASE + 0x502cc, 0x2b40003e); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x16c000bf); - MDP_OUTP(MDP_BASE + 0x502d0, 0x2a80003b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x17c000bf); - MDP_OUTP(MDP_BASE + 0x502d4, 0x2a000039); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x188000c2); - MDP_OUTP(MDP_BASE + 0x502d8, 0x29400036); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x19c000c4); - MDP_OUTP(MDP_BASE + 0x502dc, 0x28800032); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac000c5); - MDP_OUTP(MDP_BASE + 0x502e0, 0x2800002f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc000c7); - MDP_OUTP(MDP_BASE + 0x502e4, 0x2740002c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc000c8); - MDP_OUTP(MDP_BASE + 0x502e8, 0x26c00029); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc000c9); - MDP_OUTP(MDP_BASE + 0x502ec, 0x26000027); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec000cc); - MDP_OUTP(MDP_BASE + 0x502f0, 0x25000024); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x200000cc); - MDP_OUTP(MDP_BASE + 0x502f4, 0x24800021); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x210000cd); - MDP_OUTP(MDP_BASE + 0x502f8, 0x23800020); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x220000ce); - MDP_OUTP(MDP_BASE + 0x502fc, 0x2300001d); -} - -static void mdp_load_bc_downscale_table_y_point4TOpoint6(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x740008c); - MDP_OUTP(MDP_BASE + 0x50300, 0x33800088); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x800008e); - MDP_OUTP(MDP_BASE + 0x50304, 0x33400084); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x8400092); - MDP_OUTP(MDP_BASE + 0x50308, 0x33000080); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x9000094); - MDP_OUTP(MDP_BASE + 0x5030c, 0x3300007b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x9c00098); - MDP_OUTP(MDP_BASE + 0x50310, 0x32400077); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xa40009b); - MDP_OUTP(MDP_BASE + 0x50314, 0x32000073); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xb00009d); - MDP_OUTP(MDP_BASE + 0x50318, 0x31c0006f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xbc000a0); - MDP_OUTP(MDP_BASE + 0x5031c, 0x3140006b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xc8000a2); - MDP_OUTP(MDP_BASE + 0x50320, 0x31000067); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xd8000a5); - MDP_OUTP(MDP_BASE + 0x50324, 0x30800062); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xe4000a8); - MDP_OUTP(MDP_BASE + 0x50328, 0x2fc0005f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xec000aa); - MDP_OUTP(MDP_BASE + 0x5032c, 0x2fc0005b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8000ad); - MDP_OUTP(MDP_BASE + 0x50330, 0x2f400057); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x108000b0); - MDP_OUTP(MDP_BASE + 0x50334, 0x2e400054); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x114000b2); - MDP_OUTP(MDP_BASE + 0x50338, 0x2e000050); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x124000b4); - MDP_OUTP(MDP_BASE + 0x5033c, 0x2d80004c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x130000b6); - MDP_OUTP(MDP_BASE + 0x50340, 0x2d000049); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x140000b8); - MDP_OUTP(MDP_BASE + 0x50344, 0x2c800045); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x150000b9); - MDP_OUTP(MDP_BASE + 0x50348, 0x2c000042); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x15c000bd); - MDP_OUTP(MDP_BASE + 0x5034c, 0x2b40003e); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x16c000bf); - MDP_OUTP(MDP_BASE + 0x50350, 0x2a80003b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x17c000bf); - MDP_OUTP(MDP_BASE + 0x50354, 0x2a000039); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x188000c2); - MDP_OUTP(MDP_BASE + 0x50358, 0x29400036); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x19c000c4); - MDP_OUTP(MDP_BASE + 0x5035c, 0x28800032); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ac000c5); - MDP_OUTP(MDP_BASE + 0x50360, 0x2800002f); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1bc000c7); - MDP_OUTP(MDP_BASE + 0x50364, 0x2740002c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1cc000c8); - MDP_OUTP(MDP_BASE + 0x50368, 0x26c00029); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1dc000c9); - MDP_OUTP(MDP_BASE + 0x5036c, 0x26000027); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1ec000cc); - MDP_OUTP(MDP_BASE + 0x50370, 0x25000024); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x200000cc); - MDP_OUTP(MDP_BASE + 0x50374, 0x24800021); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x210000cd); - MDP_OUTP(MDP_BASE + 0x50378, 0x23800020); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x220000ce); - MDP_OUTP(MDP_BASE + 0x5037c, 0x2300001d); -} - -static void mdp_load_bc_downscale_table_x_point6TOpoint8(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000070); - MDP_OUTP(MDP_BASE + 0x50280, 0x4bc00068); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000078); - MDP_OUTP(MDP_BASE + 0x50284, 0x4bc00060); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000080); - MDP_OUTP(MDP_BASE + 0x50288, 0x4b800059); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000089); - MDP_OUTP(MDP_BASE + 0x5028c, 0x4b000052); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe400091); - MDP_OUTP(MDP_BASE + 0x50290, 0x4a80004b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40009a); - MDP_OUTP(MDP_BASE + 0x50294, 0x4a000044); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe8000a3); - MDP_OUTP(MDP_BASE + 0x50298, 0x4940003d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec000ac); - MDP_OUTP(MDP_BASE + 0x5029c, 0x48400037); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xff0000b4); - MDP_OUTP(MDP_BASE + 0x502a0, 0x47800031); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xff8000bd); - MDP_OUTP(MDP_BASE + 0x502a4, 0x4640002b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xc5); - MDP_OUTP(MDP_BASE + 0x502a8, 0x45000026); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x8000ce); - MDP_OUTP(MDP_BASE + 0x502ac, 0x43800021); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x10000d6); - MDP_OUTP(MDP_BASE + 0x502b0, 0x4240001c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x18000df); - MDP_OUTP(MDP_BASE + 0x502b4, 0x40800018); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x24000e6); - MDP_OUTP(MDP_BASE + 0x502b8, 0x3f000014); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x30000ee); - MDP_OUTP(MDP_BASE + 0x502bc, 0x3d400010); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x40000f5); - MDP_OUTP(MDP_BASE + 0x502c0, 0x3b80000c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x50000fc); - MDP_OUTP(MDP_BASE + 0x502c4, 0x39800009); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x6000102); - MDP_OUTP(MDP_BASE + 0x502c8, 0x37c00006); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x7000109); - MDP_OUTP(MDP_BASE + 0x502cc, 0x35800004); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x840010e); - MDP_OUTP(MDP_BASE + 0x502d0, 0x33800002); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x9800114); - MDP_OUTP(MDP_BASE + 0x502d4, 0x31400000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xac00119); - MDP_OUTP(MDP_BASE + 0x502d8, 0x2f4003fe); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xc40011e); - MDP_OUTP(MDP_BASE + 0x502dc, 0x2d0003fc); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xdc00121); - MDP_OUTP(MDP_BASE + 0x502e0, 0x2b0003fb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf400125); - MDP_OUTP(MDP_BASE + 0x502e4, 0x28c003fa); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x11000128); - MDP_OUTP(MDP_BASE + 0x502e8, 0x268003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x12c0012a); - MDP_OUTP(MDP_BASE + 0x502ec, 0x244003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1480012c); - MDP_OUTP(MDP_BASE + 0x502f0, 0x224003f8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1640012e); - MDP_OUTP(MDP_BASE + 0x502f4, 0x200003f8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1800012f); - MDP_OUTP(MDP_BASE + 0x502f8, 0x1e0003f8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1a00012f); - MDP_OUTP(MDP_BASE + 0x502fc, 0x1c0003f8); -} - -static void mdp_load_bc_downscale_table_y_point6TOpoint8(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000070); - MDP_OUTP(MDP_BASE + 0x50300, 0x4bc00068); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000078); - MDP_OUTP(MDP_BASE + 0x50304, 0x4bc00060); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000080); - MDP_OUTP(MDP_BASE + 0x50308, 0x4b800059); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe000089); - MDP_OUTP(MDP_BASE + 0x5030c, 0x4b000052); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe400091); - MDP_OUTP(MDP_BASE + 0x50310, 0x4a80004b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40009a); - MDP_OUTP(MDP_BASE + 0x50314, 0x4a000044); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe8000a3); - MDP_OUTP(MDP_BASE + 0x50318, 0x4940003d); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec000ac); - MDP_OUTP(MDP_BASE + 0x5031c, 0x48400037); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xff0000b4); - MDP_OUTP(MDP_BASE + 0x50320, 0x47800031); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xff8000bd); - MDP_OUTP(MDP_BASE + 0x50324, 0x4640002b); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xc5); - MDP_OUTP(MDP_BASE + 0x50328, 0x45000026); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x8000ce); - MDP_OUTP(MDP_BASE + 0x5032c, 0x43800021); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x10000d6); - MDP_OUTP(MDP_BASE + 0x50330, 0x4240001c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x18000df); - MDP_OUTP(MDP_BASE + 0x50334, 0x40800018); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x24000e6); - MDP_OUTP(MDP_BASE + 0x50338, 0x3f000014); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x30000ee); - MDP_OUTP(MDP_BASE + 0x5033c, 0x3d400010); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x40000f5); - MDP_OUTP(MDP_BASE + 0x50340, 0x3b80000c); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x50000fc); - MDP_OUTP(MDP_BASE + 0x50344, 0x39800009); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x6000102); - MDP_OUTP(MDP_BASE + 0x50348, 0x37c00006); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x7000109); - MDP_OUTP(MDP_BASE + 0x5034c, 0x35800004); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x840010e); - MDP_OUTP(MDP_BASE + 0x50350, 0x33800002); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x9800114); - MDP_OUTP(MDP_BASE + 0x50354, 0x31400000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xac00119); - MDP_OUTP(MDP_BASE + 0x50358, 0x2f4003fe); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xc40011e); - MDP_OUTP(MDP_BASE + 0x5035c, 0x2d0003fc); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xdc00121); - MDP_OUTP(MDP_BASE + 0x50360, 0x2b0003fb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf400125); - MDP_OUTP(MDP_BASE + 0x50364, 0x28c003fa); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x11000128); - MDP_OUTP(MDP_BASE + 0x50368, 0x268003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x12c0012a); - MDP_OUTP(MDP_BASE + 0x5036c, 0x244003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1480012c); - MDP_OUTP(MDP_BASE + 0x50370, 0x224003f8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1640012e); - MDP_OUTP(MDP_BASE + 0x50374, 0x200003f8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1800012f); - MDP_OUTP(MDP_BASE + 0x50378, 0x1e0003f8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0x1a00012f); - MDP_OUTP(MDP_BASE + 0x5037c, 0x1c0003f8); -} - -static void mdp_load_bc_downscale_table_x_point8TO1(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50280, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xff80000d); - MDP_OUTP(MDP_BASE + 0x50284, 0x7ec003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec0001c); - MDP_OUTP(MDP_BASE + 0x50288, 0x7d4003f3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40002b); - MDP_OUTP(MDP_BASE + 0x5028c, 0x7b8003ed); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfd80003c); - MDP_OUTP(MDP_BASE + 0x50290, 0x794003e8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc0004d); - MDP_OUTP(MDP_BASE + 0x50294, 0x76c003e4); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfc40005f); - MDP_OUTP(MDP_BASE + 0x50298, 0x73c003e0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb800071); - MDP_OUTP(MDP_BASE + 0x5029c, 0x708003de); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfac00085); - MDP_OUTP(MDP_BASE + 0x502a0, 0x6d0003db); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa000098); - MDP_OUTP(MDP_BASE + 0x502a4, 0x698003d9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf98000ac); - MDP_OUTP(MDP_BASE + 0x502a8, 0x654003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8c000c1); - MDP_OUTP(MDP_BASE + 0x502ac, 0x610003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf84000d5); - MDP_OUTP(MDP_BASE + 0x502b0, 0x5c8003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf7c000e9); - MDP_OUTP(MDP_BASE + 0x502b4, 0x580003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf74000fd); - MDP_OUTP(MDP_BASE + 0x502b8, 0x534003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c00112); - MDP_OUTP(MDP_BASE + 0x502bc, 0x4e8003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6800126); - MDP_OUTP(MDP_BASE + 0x502c0, 0x494003da); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600013a); - MDP_OUTP(MDP_BASE + 0x502c4, 0x448003db); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600014d); - MDP_OUTP(MDP_BASE + 0x502c8, 0x3f4003dd); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00160); - MDP_OUTP(MDP_BASE + 0x502cc, 0x3a4003df); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00172); - MDP_OUTP(MDP_BASE + 0x502d0, 0x354003e1); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00184); - MDP_OUTP(MDP_BASE + 0x502d4, 0x304003e3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6000195); - MDP_OUTP(MDP_BASE + 0x502d8, 0x2b0003e6); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf64001a6); - MDP_OUTP(MDP_BASE + 0x502dc, 0x260003e8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c001b4); - MDP_OUTP(MDP_BASE + 0x502e0, 0x214003eb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf78001c2); - MDP_OUTP(MDP_BASE + 0x502e4, 0x1c4003ee); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf80001cf); - MDP_OUTP(MDP_BASE + 0x502e8, 0x17c003f1); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf90001db); - MDP_OUTP(MDP_BASE + 0x502ec, 0x134003f3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa0001e5); - MDP_OUTP(MDP_BASE + 0x502f0, 0xf0003f6); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb4001ee); - MDP_OUTP(MDP_BASE + 0x502f4, 0xac003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc001f5); - MDP_OUTP(MDP_BASE + 0x502f8, 0x70003fb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe4001fb); - MDP_OUTP(MDP_BASE + 0x502fc, 0x34003fe); -} - -static void mdp_load_bc_downscale_table_y_point8TO1(void) -{ - MDP_OUTP(MDP_BASE + 0x5fffc, 0x0); - MDP_OUTP(MDP_BASE + 0x50300, 0x7fc00000); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xff80000d); - MDP_OUTP(MDP_BASE + 0x50304, 0x7ec003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfec0001c); - MDP_OUTP(MDP_BASE + 0x50308, 0x7d4003f3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe40002b); - MDP_OUTP(MDP_BASE + 0x5030c, 0x7b8003ed); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfd80003c); - MDP_OUTP(MDP_BASE + 0x50310, 0x794003e8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc0004d); - MDP_OUTP(MDP_BASE + 0x50314, 0x76c003e4); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfc40005f); - MDP_OUTP(MDP_BASE + 0x50318, 0x73c003e0); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb800071); - MDP_OUTP(MDP_BASE + 0x5031c, 0x708003de); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfac00085); - MDP_OUTP(MDP_BASE + 0x50320, 0x6d0003db); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa000098); - MDP_OUTP(MDP_BASE + 0x50324, 0x698003d9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf98000ac); - MDP_OUTP(MDP_BASE + 0x50328, 0x654003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf8c000c1); - MDP_OUTP(MDP_BASE + 0x5032c, 0x610003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf84000d5); - MDP_OUTP(MDP_BASE + 0x50330, 0x5c8003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf7c000e9); - MDP_OUTP(MDP_BASE + 0x50334, 0x580003d7); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf74000fd); - MDP_OUTP(MDP_BASE + 0x50338, 0x534003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c00112); - MDP_OUTP(MDP_BASE + 0x5033c, 0x4e8003d8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6800126); - MDP_OUTP(MDP_BASE + 0x50340, 0x494003da); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600013a); - MDP_OUTP(MDP_BASE + 0x50344, 0x448003db); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf600014d); - MDP_OUTP(MDP_BASE + 0x50348, 0x3f4003dd); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00160); - MDP_OUTP(MDP_BASE + 0x5034c, 0x3a4003df); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00172); - MDP_OUTP(MDP_BASE + 0x50350, 0x354003e1); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf5c00184); - MDP_OUTP(MDP_BASE + 0x50354, 0x304003e3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6000195); - MDP_OUTP(MDP_BASE + 0x50358, 0x2b0003e6); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf64001a6); - MDP_OUTP(MDP_BASE + 0x5035c, 0x260003e8); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf6c001b4); - MDP_OUTP(MDP_BASE + 0x50360, 0x214003eb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf78001c2); - MDP_OUTP(MDP_BASE + 0x50364, 0x1c4003ee); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf80001cf); - MDP_OUTP(MDP_BASE + 0x50368, 0x17c003f1); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xf90001db); - MDP_OUTP(MDP_BASE + 0x5036c, 0x134003f3); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfa0001e5); - MDP_OUTP(MDP_BASE + 0x50370, 0xf0003f6); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfb4001ee); - MDP_OUTP(MDP_BASE + 0x50374, 0xac003f9); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfcc001f5); - MDP_OUTP(MDP_BASE + 0x50378, 0x70003fb); - MDP_OUTP(MDP_BASE + 0x5fffc, 0xfe4001fb); - MDP_OUTP(MDP_BASE + 0x5037c, 0x34003fe); -} - -static int mdp_get_edge_cond(MDPIBUF *iBuf, uint32 *dup, uint32 *dup2) -{ - uint32 reg; - uint32 dst_roi_width; /* Dimensions of DST ROI. */ - uint32 dst_roi_height; /* Used to calculate scaling ratios. */ - - /* - * positions of the luma pixel(relative to the image ) required for - * scaling the ROI - */ - int32 luma_interp_point_left = 0; /* left-most luma pixel needed */ - int32 luma_interp_point_right = 0; /* right-most luma pixel needed */ - int32 luma_interp_point_top = 0; /* top-most luma pixel needed */ - int32 luma_interp_point_bottom = 0; /* bottom-most luma pixel needed */ - - /* - * positions of the chroma pixel(relative to the image ) required for - * interpolating a chroma value at all required luma positions - */ - /* left-most chroma pixel needed */ - int32 chroma_interp_point_left = 0; - /* right-most chroma pixel needed */ - int32 chroma_interp_point_right = 0; - /* top-most chroma pixel needed */ - int32 chroma_interp_point_top = 0; - /* bottom-most chroma pixel needed */ - int32 chroma_interp_point_bottom = 0; - - /* - * a rectangular region within the chroma plane of the "image". - * Chroma pixels falling inside of this rectangle belongs to the ROI - */ - int32 chroma_bound_left = 0; - int32 chroma_bound_right = 0; - int32 chroma_bound_top = 0; - int32 chroma_bound_bottom = 0; - - /* - * number of chroma pixels to replicate on the left, right, - * top and bottom edge of the ROI. - */ - int32 chroma_repeat_left = 0; - int32 chroma_repeat_right = 0; - int32 chroma_repeat_top = 0; - int32 chroma_repeat_bottom = 0; - - /* - * number of luma pixels to replicate on the left, right, - * top and bottom edge of the ROI. - */ - int32 luma_repeat_left = 0; - int32 luma_repeat_right = 0; - int32 luma_repeat_top = 0; - int32 luma_repeat_bottom = 0; - - boolean chroma_edge_enable; - - uint32 _is_scale_enabled = 0; - uint32 _is_yuv_offsite_vertical = 0; - - /* fg edge duplicate */ - reg = 0x0; - - if (iBuf->mdpImg.mdpOp & MDPOP_ASCALE) { /* if scaling enabled */ - - _is_scale_enabled = 1; - - /* - * if rotation mode involves a 90 deg rotation, flip - * dst_roi_width with dst_roi_height. - * Scaling ratios is based on source ROI dimensions, and - * dst ROI dimensions before rotation. - */ - if (iBuf->mdpImg.mdpOp & MDPOP_ROT90) { - dst_roi_width = iBuf->roi.dst_height; - dst_roi_height = iBuf->roi.dst_width; - } else { - dst_roi_width = iBuf->roi.dst_width; - dst_roi_height = iBuf->roi.dst_height; - } - - /* - * Find out the luma pixels needed for scaling in the - * x direction (LEFT and RIGHT). Locations of pixels are - * relative to the ROI. Upper-left corner of ROI corresponds - * to coordinates (0,0). Also set the number of luma pixel - * to repeat. - */ - if (iBuf->roi.width > 3 * dst_roi_width) { - /* scale factor < 1/3 */ - luma_interp_point_left = 0; - luma_interp_point_right = (iBuf->roi.width - 1); - luma_repeat_left = 0; - luma_repeat_right = 0; - } else if (iBuf->roi.width == 3 * dst_roi_width) { - /* scale factor == 1/3 */ - luma_interp_point_left = 0; - luma_interp_point_right = (iBuf->roi.width - 1) + 1; - luma_repeat_left = 0; - luma_repeat_right = 1; - } else if ((iBuf->roi.width > dst_roi_width) && - (iBuf->roi.width < 3 * dst_roi_width)) { - /* 1/3 < scale factor < 1 */ - luma_interp_point_left = -1; - luma_interp_point_right = (iBuf->roi.width - 1) + 1; - luma_repeat_left = 1; - luma_repeat_right = 1; - } - - else if (iBuf->roi.width == dst_roi_width) { - /* scale factor == 1 */ - luma_interp_point_left = -1; - luma_interp_point_right = (iBuf->roi.width - 1) + 2; - luma_repeat_left = 1; - luma_repeat_right = 2; - } else { /* (iBuf->roi.width < dst_roi_width) */ - /* scale factor > 1 */ - luma_interp_point_left = -2; - luma_interp_point_right = (iBuf->roi.width - 1) + 2; - luma_repeat_left = 2; - luma_repeat_right = 2; - } - - /* - * Find out the number of pixels needed for scaling in the - * y direction (TOP and BOTTOM). Locations of pixels are - * relative to the ROI. Upper-left corner of ROI corresponds - * to coordinates (0,0). Also set the number of luma pixel - * to repeat. - */ - if (iBuf->roi.height > 3 * dst_roi_height) { - /* scale factor < 1/3 */ - luma_interp_point_top = 0; - luma_interp_point_bottom = (iBuf->roi.height - 1); - luma_repeat_top = 0; - luma_repeat_bottom = 0; - } else if (iBuf->roi.height == 3 * dst_roi_height) { - /* scale factor == 1/3 */ - luma_interp_point_top = 0; - luma_interp_point_bottom = (iBuf->roi.height - 1) + 1; - luma_repeat_top = 0; - luma_repeat_bottom = 1; - } else if ((iBuf->roi.height > dst_roi_height) && - (iBuf->roi.height < 3 * dst_roi_height)) { - /* 1/3 < scale factor < 1 */ - luma_interp_point_top = -1; - luma_interp_point_bottom = (iBuf->roi.height - 1) + 1; - luma_repeat_top = 1; - luma_repeat_bottom = 1; - } else if (iBuf->roi.height == dst_roi_height) { - /* scale factor == 1 */ - luma_interp_point_top = -1; - luma_interp_point_bottom = (iBuf->roi.height - 1) + 2; - luma_repeat_top = 1; - luma_repeat_bottom = 2; - } else { /* (iBuf->roi.height < dst_roi_height) */ - /* scale factor > 1 */ - luma_interp_point_top = -2; - luma_interp_point_bottom = (iBuf->roi.height - 1) + 2; - luma_repeat_top = 2; - luma_repeat_bottom = 2; - } - } /* if (iBuf->scale.scale_flag) */ - else { /* scaling disabled */ - /* - * Since no scaling needed, Tile Fetch does not require any - * more luma pixel than what the ROI contains. - */ - luma_interp_point_left = (int32) 0; - luma_interp_point_right = (int32) (iBuf->roi.width - 1); - luma_interp_point_top = (int32) 0; - luma_interp_point_bottom = (int32) (iBuf->roi.height - 1); - - luma_repeat_left = 0; - luma_repeat_right = 0; - luma_repeat_top = 0; - luma_repeat_bottom = 0; - } - - /* After adding the ROI offsets, we have locations of - * luma_interp_points relative to the image. - */ - luma_interp_point_left += (int32) (iBuf->roi.x); - luma_interp_point_right += (int32) (iBuf->roi.x); - luma_interp_point_top += (int32) (iBuf->roi.y); - luma_interp_point_bottom += (int32) (iBuf->roi.y); - - /* - * After adding the ROI offsets, we have locations of - * chroma_interp_points relative to the image. - */ - chroma_interp_point_left = luma_interp_point_left; - chroma_interp_point_right = luma_interp_point_right; - chroma_interp_point_top = luma_interp_point_top; - chroma_interp_point_bottom = luma_interp_point_bottom; - - chroma_edge_enable = TRUE; - /* find out which chroma pixels are needed for chroma upsampling. */ - switch (iBuf->mdpImg.imgType) { - /* - * cosite in horizontal axis - * fully sampled in vertical axis - */ - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H2V1: - case MDP_YCRYCB_H2V1: - /* floor( luma_interp_point_left / 2 ); */ - chroma_interp_point_left = luma_interp_point_left >> 1; - /* floor( ( luma_interp_point_right + 1 ) / 2 ); */ - chroma_interp_point_right = (luma_interp_point_right + 1) >> 1; - - chroma_interp_point_top = luma_interp_point_top; - chroma_interp_point_bottom = luma_interp_point_bottom; - break; - - /* - * cosite in horizontal axis - * offsite in vertical axis - */ - case MDP_Y_CBCR_H2V2: - case MDP_Y_CBCR_H2V2_ADRENO: - case MDP_Y_CRCB_H2V2: - /* floor( luma_interp_point_left / 2) */ - chroma_interp_point_left = luma_interp_point_left >> 1; - - /* floor( ( luma_interp_point_right + 1 )/ 2 ) */ - chroma_interp_point_right = (luma_interp_point_right + 1) >> 1; - - /* floor( (luma_interp_point_top - 1 ) / 2 ) */ - chroma_interp_point_top = (luma_interp_point_top - 1) >> 1; - - /* floor( ( luma_interp_point_bottom + 1 ) / 2 ) */ - chroma_interp_point_bottom = - (luma_interp_point_bottom + 1) >> 1; - - _is_yuv_offsite_vertical = 1; - break; - - default: - chroma_edge_enable = FALSE; - chroma_interp_point_left = luma_interp_point_left; - chroma_interp_point_right = luma_interp_point_right; - chroma_interp_point_top = luma_interp_point_top; - chroma_interp_point_bottom = luma_interp_point_bottom; - - break; - } - - /* only if the image type is in YUV domain, we calculate chroma edge */ - if (chroma_edge_enable) { - /* Defines which chroma pixels belongs to the roi */ - switch (iBuf->mdpImg.imgType) { - /* - * Cosite in horizontal direction, and fully sampled - * in vertical direction. - */ - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H2V1: - case MDP_YCRYCB_H2V1: - /* - * width of chroma ROI is 1/2 of size of luma ROI - * height of chroma ROI same as size of luma ROI - */ - chroma_bound_left = iBuf->roi.x / 2; - - /* there are half as many chroma pixel as luma pixels */ - chroma_bound_right = - (iBuf->roi.width + iBuf->roi.x - 1) / 2; - chroma_bound_top = iBuf->roi.y; - chroma_bound_bottom = - (iBuf->roi.height + iBuf->roi.y - 1); - break; - - case MDP_Y_CBCR_H2V2: - case MDP_Y_CBCR_H2V2_ADRENO: - case MDP_Y_CRCB_H2V2: - /* - * cosite in horizontal dir, and offsite in vertical dir - * width of chroma ROI is 1/2 of size of luma ROI - * height of chroma ROI is 1/2 of size of luma ROI - */ - - chroma_bound_left = iBuf->roi.x / 2; - chroma_bound_right = - (iBuf->roi.width + iBuf->roi.x - 1) / 2; - chroma_bound_top = iBuf->roi.y / 2; - chroma_bound_bottom = - (iBuf->roi.height + iBuf->roi.y - 1) / 2; - break; - - default: - /* - * If no valid chroma sub-sampling format specified, - * assume 4:4:4 ( i.e. fully sampled). Set ROI - * boundaries for chroma same as ROI boundaries for - * luma. - */ - chroma_bound_left = iBuf->roi.x; - chroma_bound_right = iBuf->roi.width + iBuf->roi.x - 1; - chroma_bound_top = iBuf->roi.y; - chroma_bound_bottom = - (iBuf->roi.height + iBuf->roi.y - 1); - break; - } - - /* - * Knowing which chroma pixels are needed, and which chroma - * pixels belong to the ROI (i.e. available for fetching ), - * calculate how many chroma pixels Tile Fetch needs to - * duplicate. If any required chroma pixels falls outside - * of the ROI, Tile Fetch must obtain them by replicating - * pixels. - */ - if (chroma_bound_left > chroma_interp_point_left) - chroma_repeat_left = - chroma_bound_left - chroma_interp_point_left; - else - chroma_repeat_left = 0; - - if (chroma_interp_point_right > chroma_bound_right) - chroma_repeat_right = - chroma_interp_point_right - chroma_bound_right; - else - chroma_repeat_right = 0; - - if (chroma_bound_top > chroma_interp_point_top) - chroma_repeat_top = - chroma_bound_top - chroma_interp_point_top; - else - chroma_repeat_top = 0; - - if (chroma_interp_point_bottom > chroma_bound_bottom) - chroma_repeat_bottom = - chroma_interp_point_bottom - chroma_bound_bottom; - else - chroma_repeat_bottom = 0; - - if (_is_scale_enabled && (iBuf->roi.height == 1) - && _is_yuv_offsite_vertical) { - chroma_repeat_bottom = 3; - chroma_repeat_top = 0; - } - } - /* make sure chroma repeats are non-negative */ - if ((chroma_repeat_left < 0) || (chroma_repeat_right < 0) || - (chroma_repeat_top < 0) || (chroma_repeat_bottom < 0)) - return -1; - - /* make sure chroma repeats are no larger than 3 pixels */ - if ((chroma_repeat_left > 3) || (chroma_repeat_right > 3) || - (chroma_repeat_top > 3) || (chroma_repeat_bottom > 3)) - return -1; - - /* make sure luma repeats are non-negative */ - if ((luma_repeat_left < 0) || (luma_repeat_right < 0) || - (luma_repeat_top < 0) || (luma_repeat_bottom < 0)) - return -1; - - /* make sure luma repeats are no larger than 3 pixels */ - if ((luma_repeat_left > 3) || (luma_repeat_right > 3) || - (luma_repeat_top > 3) || (luma_repeat_bottom > 3)) - return -1; - - /* write chroma_repeat_left to register */ - reg |= (chroma_repeat_left & 3) << MDP_LEFT_CHROMA; - - /* write chroma_repeat_right to register */ - reg |= (chroma_repeat_right & 3) << MDP_RIGHT_CHROMA; - - /* write chroma_repeat_top to register */ - reg |= (chroma_repeat_top & 3) << MDP_TOP_CHROMA; - - /* write chroma_repeat_bottom to register */ - reg |= (chroma_repeat_bottom & 3) << MDP_BOTTOM_CHROMA; - - /* write luma_repeat_left to register */ - reg |= (luma_repeat_left & 3) << MDP_LEFT_LUMA; - - /* write luma_repeat_right to register */ - reg |= (luma_repeat_right & 3) << MDP_RIGHT_LUMA; - - /* write luma_repeat_top to register */ - reg |= (luma_repeat_top & 3) << MDP_TOP_LUMA; - - /* write luma_repeat_bottom to register */ - reg |= (luma_repeat_bottom & 3) << MDP_BOTTOM_LUMA; - - /* done with reg */ - *dup = reg; - - /* bg edge duplicate */ - reg = 0x0; - - switch (iBuf->ibuf_type) { - case MDP_Y_CBCR_H2V2: - case MDP_Y_CRCB_H2V2: - /* - * Edge condition for MDP_Y_CRCB/CBCR_H2V2 cosite only. - * For 420 cosite, 1 chroma replicated on all sides except - * left, so reg 101b8 should be 0x0209. For 420 offsite, - * 1 chroma replicated all sides. - */ - if (iBuf->roi.lcd_y == 0) { - reg |= BIT(MDP_TOP_CHROMA); - } - - if ((iBuf->roi.lcd_y + iBuf->roi.dst_height) == - iBuf->ibuf_height) { - reg |= BIT(MDP_BOTTOM_CHROMA); - } - - if (((iBuf->roi.lcd_x + iBuf->roi.dst_width) == - iBuf->ibuf_width) && ((iBuf->roi.dst_width % 2) == 0)) { - reg |= BIT(MDP_RIGHT_CHROMA); - } - - break; - - case MDP_Y_CBCR_H2V1: - case MDP_Y_CRCB_H2V1: - case MDP_YCRYCB_H2V1: - if (((iBuf->roi.lcd_x + iBuf->roi.dst_width) == - iBuf->ibuf_width) && ((iBuf->roi.dst_width % 2) == 0)) { - reg |= BIT(MDP_RIGHT_CHROMA); - } - break; - default: - break; - } - - *dup2 = reg; - - return 0; -} - -#define ADJUST_IP /* for 1/3 scale factor fix */ - -static int mdp_calc_scale_params( -/* ROI origin coordinate for the dimension */ - uint32 org, -/* src ROI dimension */ - uint32 dim_in, -/* scaled ROI dimension*/ - uint32 dim_out, -/* is this ROI width dimension? */ - boolean is_W, -/* initial phase location address */ - int32 *phase_init_ptr, -/* phase increment location address */ - uint32 *phase_step_ptr, -/* ROI start over-fetch location address */ - uint32 *num_repl_beg_ptr, -/* ROI end over-fetch location address */ - uint32 *num_repl_end_ptr) -{ - boolean rpa_on = FALSE; - int init_phase = 0; - uint32 beg_of = 0; - uint32 end_of = 0; - uint64 numer = 0; - uint64 denom = 0; - /*uint64 inverter = 1; */ - int64 point5 = 1; - int64 one = 1; - int64 k1, k2, k3, k4; /* linear equation coefficients */ - uint64 int_mask; - uint64 fract_mask; - uint64 Os; - int64 Osprime; - int64 Od; - int64 Odprime; - int64 Oreq; - uint64 Es; - uint64 Ed; - uint64 Ereq; -#ifdef ADJUST_IP - int64 IP64; - int64 delta; -#endif - uint32 mult; - - /* - * The phase accumulator should really be rational for all cases in a - * general purpose polyphase scaler for a tiled architecture with - * non-zero * origin capability because there is no way to represent - * certain scale factors in fixed point regardless of precision. - * The error incurred in attempting to use fixed point is most - * eggregious for SF where 1/SF is an integral multiple of 1/3. - * - * However, since the MDP2 has already been committed to HW, we - * only use the rational phase accumulator (RPA) when 1/SF is an - * integral multiple of 1/3. This will help minimize regressions in - * matching the HW to the C-Sim. - */ - /* - * Set the RPA flag for this dimension. - * - * In order for 1/SF (dim_in/dim_out) to be an integral multiple of - * 1/3, dim_out must be an integral multiple of 3. - */ - if (!(dim_out % 3)) { - mult = dim_out / 3; - rpa_on = (!(dim_in % mult)); - } - - numer = dim_out; - denom = dim_in; - - /* - * convert to U30.34 before division - * - * The K vectors carry 4 extra bits of precision - * and are rounded. - * - * We initially go 5 bits over then round by adding - * 1 and right shifting by 1 - * so final result is U31.33 - */ - numer <<= PQF_PLUS_5; - - /* now calculate the scale factor (aka k3) */ - k3 = ((mdp_do_div(numer, denom) + 1) >> 1); - - /* check scale factor for legal range [0.25 - 4.0] */ - if (((k3 >> 4) < (1LL << PQF_MINUS_2)) || - ((k3 >> 4) > (1LL << PQF_PLUS_2))) { - return -1; - } - - /* calculate inverse scale factor (aka k1) for phase init */ - numer = dim_in; - denom = dim_out; - numer <<= PQF_PLUS_5; - k1 = ((mdp_do_div(numer, denom) + 1) >> 1); - - /* - * calculate initial phase and ROI overfetch - */ - /* convert point5 & one to S39.24 (will always be positive) */ - point5 <<= (PQF_PLUS_4 - 1); - one <<= PQF_PLUS_4; - k2 = ((k1 - one) >> 1); - init_phase = (int)(k2 >> 4); - k4 = ((k3 - one) >> 1); - if (k3 == one) { - /* the simple case; SF = 1.0 */ - beg_of = 1; - end_of = 2; - } else { - /* calculate the masks */ - fract_mask = one - 1; - int_mask = ~fract_mask; - - if (!rpa_on) { - /* - * FIXED POINT IMPLEMENTATION - */ - if (!org) { - /* A fairly simple case; ROI origin = 0 */ - if (k1 < one) { - /* upscaling */ - beg_of = end_of = 2; - } - /* 0.33 <= SF < 1.0 */ - else if (k1 < (3LL << PQF_PLUS_4)) - beg_of = end_of = 1; - /* 0.33 == SF */ - else if (k1 == (3LL << PQF_PLUS_4)) { - beg_of = 0; - end_of = 1; - } - /* 0.25 <= SF < 0.33 */ - else - beg_of = end_of = 0; - } else { - /* - * The complicated case; ROI origin != 0 - * init_phase needs to be adjusted - * OF is also position dependent - */ - - /* map (org - .5) into destination space */ - Os = ((uint64) org << 1) - 1; - Od = ((k3 * Os) >> 1) + k4; - - /* take the ceiling */ - Odprime = (Od & int_mask); - if (Odprime != Od) - Odprime += one; - - /* now map that back to source space */ - Osprime = (k1 * (Odprime >> PQF_PLUS_4)) + k2; - - /* then floor & decrement to calculate the required - starting coordinate */ - Oreq = (Osprime & int_mask) - one; - - /* calculate end coord in destination space then map to - source space */ - Ed = Odprime + - ((uint64) dim_out << PQF_PLUS_4) - one; - Es = (k1 * (Ed >> PQF_PLUS_4)) + k2; - - /* now floor & increment by 2 to calculate the required - ending coordinate */ - Ereq = (Es & int_mask) + (one << 1); - - /* calculate initial phase */ -#ifdef ADJUST_IP - - IP64 = Osprime - Oreq; - delta = ((int64) (org) << PQF_PLUS_4) - Oreq; - IP64 -= delta; - - /* limit to valid range before the left shift */ - delta = (IP64 & (1LL << 63)) ? 4 : -4; - delta <<= PQF_PLUS_4; - while (abs((int)(IP64 >> PQF_PLUS_4)) > 4) - IP64 += delta; - - /* right shift to account for extra bits of precision */ - init_phase = (int)(IP64 >> 4); - -#else /* ADJUST_IP */ - - /* just calculate the real initial phase */ - init_phase = (int)((Osprime - Oreq) >> 4); - -#endif /* ADJUST_IP */ - - /* calculate the overfetch */ - beg_of = org - (uint32) (Oreq >> PQF_PLUS_4); - end_of = - (uint32) (Ereq >> PQF_PLUS_4) - (org + - dim_in - - 1); - } - } else { - /* - * RPA IMPLEMENTATION - * - * init_phase needs to be calculated in all RPA_on cases - * because it's a numerator, not a fixed point value. - */ - - /* map (org - .5) into destination space */ - Os = ((uint64) org << PQF_PLUS_4) - point5; - Od = mdp_do_div((dim_out * (Os + point5)), - dim_in) - point5; - - /* take the ceiling */ - Odprime = (Od & int_mask); - if (Odprime != Od) - Odprime += one; - - /* now map that back to source space */ - Osprime = - mdp_do_div((dim_in * (Odprime + point5)), - dim_out) - point5; - - /* then floor & decrement to calculate the required - starting coordinate */ - Oreq = (Osprime & int_mask) - one; - - /* calculate end coord in destination space then map to - source space */ - Ed = Odprime + ((uint64) dim_out << PQF_PLUS_4) - one; - Es = mdp_do_div((dim_in * (Ed + point5)), - dim_out) - point5; - - /* now floor & increment by 2 to calculate the required - ending coordinate */ - Ereq = (Es & int_mask) + (one << 1); - - /* calculate initial phase */ - -#ifdef ADJUST_IP - - IP64 = Osprime - Oreq; - delta = ((int64) (org) << PQF_PLUS_4) - Oreq; - IP64 -= delta; - - /* limit to valid range before the left shift */ - delta = (IP64 & (1LL << 63)) ? 4 : -4; - delta <<= PQF_PLUS_4; - while (abs((int)(IP64 >> PQF_PLUS_4)) > 4) - IP64 += delta; - - /* right shift to account for extra bits of precision */ - init_phase = (int)(IP64 >> 4); - -#else /* ADJUST_IP */ - - /* just calculate the real initial phase */ - init_phase = (int)((Osprime - Oreq) >> 4); - -#endif /* ADJUST_IP */ - - /* calculate the overfetch */ - beg_of = org - (uint32) (Oreq >> PQF_PLUS_4); - end_of = - (uint32) (Ereq >> PQF_PLUS_4) - (org + dim_in - 1); - } - } - - /* return the scale parameters */ - *phase_init_ptr = init_phase; - *phase_step_ptr = (uint32) (k1 >> 4); - *num_repl_beg_ptr = beg_of; - *num_repl_end_ptr = end_of; - - return 0; -} - -static uint8 *mdp_adjust_rot_addr(MDPIBUF *iBuf, uint8 *addr, uint32 uv) -{ - uint32 dest_ystride = iBuf->ibuf_width * iBuf->bpp; - uint32 h_slice = 1; - - if (uv && ((iBuf->ibuf_type == MDP_Y_CBCR_H2V2) || - (iBuf->ibuf_type == MDP_Y_CRCB_H2V2))) - h_slice = 2; - - if (MDP_CHKBIT(iBuf->mdpImg.mdpOp, MDPOP_ROT90) ^ - MDP_CHKBIT(iBuf->mdpImg.mdpOp, MDPOP_LR)) { - addr = - addr + (iBuf->roi.dst_width - - MIN(16, iBuf->roi.dst_width)) * iBuf->bpp; - } - if (MDP_CHKBIT(iBuf->mdpImg.mdpOp, MDPOP_UD)) { - addr = - addr + ((iBuf->roi.dst_height - - MIN(16, iBuf->roi.dst_height))/h_slice) * dest_ystride; - } - - return addr; -} - -void mdp_set_scale(MDPIBUF *iBuf, - uint32 dst_roi_width, - uint32 dst_roi_height, - boolean inputRGB, boolean outputRGB, uint32 *pppop_reg_ptr) -{ - uint32 dst_roi_width_scale; - uint32 dst_roi_height_scale; - boolean use_pr; - uint32 phasex_step = 0; - uint32 phasey_step = 0; - int32 phasex_init = 0; - int32 phasey_init = 0; - uint32 lines_dup = 0; - uint32 lines_dup_bg = 0; - uint32 dummy; - uint32 mdp_blur = 0; - - if (iBuf->mdpImg.mdpOp & MDPOP_ASCALE) { - if (iBuf->mdpImg.mdpOp & MDPOP_ROT90) { - dst_roi_width_scale = dst_roi_height; - dst_roi_height_scale = dst_roi_width; - } else { - dst_roi_width_scale = dst_roi_width; - dst_roi_height_scale = dst_roi_height; - } - - mdp_blur = iBuf->mdpImg.mdpOp & MDPOP_BLUR; - - if ((dst_roi_width_scale != iBuf->roi.width) || - (dst_roi_height_scale != iBuf->roi.height) || - mdp_blur) { - *pppop_reg_ptr |= - (PPP_OP_SCALE_Y_ON | PPP_OP_SCALE_X_ON); - - /* let's use SHIM logic to calculate the - partial ROI scaling */ - mdp_calc_scale_params(iBuf->roi.x, iBuf->roi.width, - dst_roi_width_scale, 1, - &phasex_init, &phasex_step, - &dummy, &dummy); - mdp_calc_scale_params(iBuf->roi.y, iBuf->roi.height, - dst_roi_height_scale, 0, - &phasey_init, &phasey_step, - &dummy, &dummy); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x013c, - phasex_init); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0140, - phasey_init); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0144, - phasex_step); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0148, - phasey_step); - - /* disable the pixel repeat option for scaling */ - use_pr = false; - - if ((dst_roi_width_scale > iBuf->roi.width) || - (dst_roi_height_scale > iBuf->roi.height)) { - if ((use_pr) - && (mdp_curr_up_scale_xy != - MDP_PR_SCALE_UP)) { - mdp_load_pr_upscale_table(); - mdp_curr_up_scale_xy = MDP_PR_SCALE_UP; - } else if ((!use_pr) - && (mdp_curr_up_scale_xy != - MDP_BC_SCALE_UP)) { - mdp_load_bc_upscale_table(); - mdp_curr_up_scale_xy = MDP_BC_SCALE_UP; - } - } - - if (mdp_blur) { - load_scale_table(mdp_gaussian_blur_table, - ARRAY_SIZE(mdp_gaussian_blur_table)); - mdp_curr_down_scale_x = MDP_SCALE_BLUR; - mdp_curr_down_scale_y = MDP_SCALE_BLUR; - } - - /* 0.2 < x <= 1 scaling factor */ - if ((dst_roi_width_scale <= iBuf->roi.width) && - !mdp_blur) { - if (((dst_roi_width_scale * 10) / - iBuf->roi.width) > 8) { - if ((use_pr) - && (mdp_curr_down_scale_x != - MDP_PR_SCALE_POINT8_1)) { - mdp_load_pr_downscale_table_x_point8TO1 - (); - mdp_curr_down_scale_x = - MDP_PR_SCALE_POINT8_1; - } else if ((!use_pr) - && (mdp_curr_down_scale_x != - MDP_BC_SCALE_POINT8_1)) { - mdp_load_bc_downscale_table_x_point8TO1 - (); - mdp_curr_down_scale_x = - MDP_BC_SCALE_POINT8_1; - } - } else - if (((dst_roi_width_scale * 10) / - iBuf->roi.width) > 6) { - if ((use_pr) - && (mdp_curr_down_scale_x != - MDP_PR_SCALE_POINT6_POINT8)) { - mdp_load_pr_downscale_table_x_point6TOpoint8 - (); - mdp_curr_down_scale_x = - MDP_PR_SCALE_POINT6_POINT8; - } else if ((!use_pr) - && (mdp_curr_down_scale_x != - MDP_BC_SCALE_POINT6_POINT8)) - { - mdp_load_bc_downscale_table_x_point6TOpoint8 - (); - mdp_curr_down_scale_x = - MDP_BC_SCALE_POINT6_POINT8; - } - } else - if (((dst_roi_width_scale * 10) / - iBuf->roi.width) > 4) { - if ((use_pr) - && (mdp_curr_down_scale_x != - MDP_PR_SCALE_POINT4_POINT6)) { - mdp_load_pr_downscale_table_x_point4TOpoint6 - (); - mdp_curr_down_scale_x = - MDP_PR_SCALE_POINT4_POINT6; - } else if ((!use_pr) - && (mdp_curr_down_scale_x != - MDP_BC_SCALE_POINT4_POINT6)) - { - mdp_load_bc_downscale_table_x_point4TOpoint6 - (); - mdp_curr_down_scale_x = - MDP_BC_SCALE_POINT4_POINT6; - } - } else { - if ((use_pr) - && (mdp_curr_down_scale_x != - MDP_PR_SCALE_POINT2_POINT4)) { - mdp_load_pr_downscale_table_x_point2TOpoint4 - (); - mdp_curr_down_scale_x = - MDP_PR_SCALE_POINT2_POINT4; - } else if ((!use_pr) - && (mdp_curr_down_scale_x != - MDP_BC_SCALE_POINT2_POINT4)) - { - mdp_load_bc_downscale_table_x_point2TOpoint4 - (); - mdp_curr_down_scale_x = - MDP_BC_SCALE_POINT2_POINT4; - } - } - } - /* 0.2 < y <= 1 scaling factor */ - if ((dst_roi_height_scale <= iBuf->roi.height) && - !mdp_blur) { - if (((dst_roi_height_scale * 10) / - iBuf->roi.height) > 8) { - if ((use_pr) - && (mdp_curr_down_scale_y != - MDP_PR_SCALE_POINT8_1)) { - mdp_load_pr_downscale_table_y_point8TO1 - (); - mdp_curr_down_scale_y = - MDP_PR_SCALE_POINT8_1; - } else if ((!use_pr) - && (mdp_curr_down_scale_y != - MDP_BC_SCALE_POINT8_1)) { - mdp_load_bc_downscale_table_y_point8TO1 - (); - mdp_curr_down_scale_y = - MDP_BC_SCALE_POINT8_1; - } - } else - if (((dst_roi_height_scale * 10) / - iBuf->roi.height) > 6) { - if ((use_pr) - && (mdp_curr_down_scale_y != - MDP_PR_SCALE_POINT6_POINT8)) { - mdp_load_pr_downscale_table_y_point6TOpoint8 - (); - mdp_curr_down_scale_y = - MDP_PR_SCALE_POINT6_POINT8; - } else if ((!use_pr) - && (mdp_curr_down_scale_y != - MDP_BC_SCALE_POINT6_POINT8)) - { - mdp_load_bc_downscale_table_y_point6TOpoint8 - (); - mdp_curr_down_scale_y = - MDP_BC_SCALE_POINT6_POINT8; - } - } else - if (((dst_roi_height_scale * 10) / - iBuf->roi.height) > 4) { - if ((use_pr) - && (mdp_curr_down_scale_y != - MDP_PR_SCALE_POINT4_POINT6)) { - mdp_load_pr_downscale_table_y_point4TOpoint6 - (); - mdp_curr_down_scale_y = - MDP_PR_SCALE_POINT4_POINT6; - } else if ((!use_pr) - && (mdp_curr_down_scale_y != - MDP_BC_SCALE_POINT4_POINT6)) - { - mdp_load_bc_downscale_table_y_point4TOpoint6 - (); - mdp_curr_down_scale_y = - MDP_BC_SCALE_POINT4_POINT6; - } - } else { - if ((use_pr) - && (mdp_curr_down_scale_y != - MDP_PR_SCALE_POINT2_POINT4)) { - mdp_load_pr_downscale_table_y_point2TOpoint4 - (); - mdp_curr_down_scale_y = - MDP_PR_SCALE_POINT2_POINT4; - } else if ((!use_pr) - && (mdp_curr_down_scale_y != - MDP_BC_SCALE_POINT2_POINT4)) - { - mdp_load_bc_downscale_table_y_point2TOpoint4 - (); - mdp_curr_down_scale_y = - MDP_BC_SCALE_POINT2_POINT4; - } - } - } - } else { - iBuf->mdpImg.mdpOp &= ~(MDPOP_ASCALE); - } - } - /* setting edge condition here after scaling check */ - if (mdp_get_edge_cond(iBuf, &lines_dup, &lines_dup_bg)) - printk(KERN_ERR "msm_fb: mdp_get_edge_cond() error!\n"); - - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01b8, lines_dup); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x01bc, lines_dup_bg); -} - -void mdp_init_scale_table(void) -{ - mdp_curr_up_scale_xy = MDP_INIT_SCALE; - mdp_curr_down_scale_x = MDP_INIT_SCALE; - mdp_curr_down_scale_y = MDP_INIT_SCALE; -} - -void mdp_adjust_start_addr(uint8 **src0, - uint8 **src1, - int v_slice, - int h_slice, - int x, - int y, - uint32 width, - uint32 height, int bpp, MDPIBUF *iBuf, int layer) -{ - if (iBuf->mdpImg.imgType == MDP_Y_CBCR_H2V2_ADRENO && layer == 0) - *src0 += (x + y * ALIGN(width, 32)) * bpp; - else - *src0 += (x + y * width) * bpp; - - /* if it's dest/bg buffer, we need to adjust it for rotation */ - if (layer != 0) - *src0 = mdp_adjust_rot_addr(iBuf, *src0, 0); - - if (*src1) { - /* - * MDP_Y_CBCR_H2V2/MDP_Y_CRCB_H2V2 cosite for now - * we need to shift x direction same as y dir for offsite - */ - if (iBuf->mdpImg.imgType == MDP_Y_CBCR_H2V2_ADRENO - && layer == 0) - *src1 += ((x / h_slice) * h_slice + ((y == 0) ? 0 : - (((y + 1) / v_slice - 1) * (ALIGN(width/2, 32) * 2)))) - * bpp; - else - *src1 += ((x / h_slice) * h_slice + - ((y == 0) ? 0 : ((y + 1) / v_slice - 1) * width)) * bpp; - - /* if it's dest/bg buffer, we need to adjust it for rotation */ - if (layer != 0) - *src1 = mdp_adjust_rot_addr(iBuf, *src1, 1); - } -} - -void mdp_set_blend_attr(MDPIBUF *iBuf, - uint32 *alpha, - uint32 *tpVal, - uint32 perPixelAlpha, uint32 *pppop_reg_ptr) -{ - if (mdp_rev == MDP_REV_303) { - int bg_alpha; - - *alpha = iBuf->mdpImg.alpha; - *tpVal = iBuf->mdpImg.tpVal; - - if (iBuf->mdpImg.mdpOp & MDPOP_FG_PM_ALPHA) { - if (perPixelAlpha) { - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | - PPP_OP_BLEND_CONSTANT_ALPHA; - } else { - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - && (iBuf->mdpImg.alpha == 0xff)) { - iBuf->mdpImg.mdpOp &= ~(MDPOP_ALPHAB); - } - - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - || (iBuf->mdpImg.mdpOp & MDPOP_TRANSP)) { - - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | - PPP_OP_BLEND_CONSTANT_ALPHA | - PPP_OP_BLEND_ALPHA_BLEND_NORMAL; - } - } - - bg_alpha = PPP_BLEND_BG_USE_ALPHA_SEL | - PPP_BLEND_BG_ALPHA_REVERSE; - - if ((perPixelAlpha) && !(iBuf->mdpImg.mdpOp & - MDPOP_LAYER_IS_FG)) { - bg_alpha |= PPP_BLEND_BG_SRCPIXEL_ALPHA; - } else { - bg_alpha |= PPP_BLEND_BG_CONSTANT_ALPHA; - bg_alpha |= iBuf->mdpImg.alpha << 24; - } - outpdw(MDP_BASE + 0x70010, bg_alpha); - - if (iBuf->mdpImg.mdpOp & MDPOP_TRANSP) - *pppop_reg_ptr |= PPP_BLEND_CALPHA_TRNASP; - } else if (perPixelAlpha) { - if (iBuf->mdpImg.mdpOp & MDPOP_LAYER_IS_FG) - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | - PPP_OP_BLEND_CONSTANT_ALPHA; - else - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | - PPP_OP_BLEND_SRCPIXEL_ALPHA; - outpdw(MDP_BASE + 0x70010, 0); - } else { - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - && (iBuf->mdpImg.alpha == 0xff)) { - iBuf->mdpImg.mdpOp &= - ~(MDPOP_ALPHAB); - } - - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - || (iBuf->mdpImg.mdpOp & MDPOP_TRANSP)) { - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | - PPP_OP_BLEND_CONSTANT_ALPHA | - PPP_OP_BLEND_ALPHA_BLEND_NORMAL; - } - - if (iBuf->mdpImg.mdpOp & MDPOP_TRANSP) - *pppop_reg_ptr |= - PPP_BLEND_CALPHA_TRNASP; - outpdw(MDP_BASE + 0x70010, 0); - } - } else { - if (perPixelAlpha) { - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | PPP_OP_BLEND_SRCPIXEL_ALPHA; - } else { - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - && (iBuf->mdpImg.alpha == 0xff)) { - iBuf->mdpImg.mdpOp &= ~(MDPOP_ALPHAB); - } - - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - && (iBuf->mdpImg.mdpOp & MDPOP_TRANSP)) { - *pppop_reg_ptr |= - PPP_OP_ROT_ON | PPP_OP_BLEND_ON | - PPP_OP_BLEND_CONSTANT_ALPHA | - PPP_OP_BLEND_ALPHA_BLEND_NORMAL | - PPP_BLEND_CALPHA_TRNASP; - - *alpha = iBuf->mdpImg.alpha; - *tpVal = iBuf->mdpImg.tpVal; - } else { - if (iBuf->mdpImg.mdpOp & MDPOP_TRANSP) { - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | - PPP_OP_BLEND_SRCPIXEL_TRANSP; - *tpVal = iBuf->mdpImg.tpVal; - } else if (iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) { - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | - PPP_OP_BLEND_ALPHA_BLEND_NORMAL | - PPP_OP_BLEND_CONSTANT_ALPHA; - *alpha = iBuf->mdpImg.alpha; - } - } - } - } -} diff --git a/drivers/video/msm/mdp_ppp_v31.c b/drivers/video/msm/mdp_ppp_v31.c deleted file mode 100644 index 419cae5d7d7e3c9953dbabe8a283ddc9056e90d2..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_ppp_v31.c +++ /dev/null @@ -1,842 +0,0 @@ -/* Copyright (c) 2008-2009, 2013, 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 -#include -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" - -#include -#include - -#include -#include - -#include "mdp.h" -#include "msm_fb.h" - -#define MDP_SCALE_COEFF_NUM 32 -#define MDP_SCALE_0P2_TO_0P4_INDEX 0 -#define MDP_SCALE_0P4_TO_0P6_INDEX 32 -#define MDP_SCALE_0P6_TO_0P8_INDEX 64 -#define MDP_SCALE_0P8_TO_8P0_INDEX 96 -#define MDP_SCALE_COEFF_MASK 0x3ff - -#define MDP_SCALE_PR 0 -#define MDP_SCALE_FIR 1 - -static uint32 mdp_scale_0p8_to_8p0_mode; -static uint32 mdp_scale_0p6_to_0p8_mode; -static uint32 mdp_scale_0p4_to_0p6_mode; -static uint32 mdp_scale_0p2_to_0p4_mode; - -/* -------- All scaling range, "pixel repeat" -------- */ -static int16 mdp_scale_pixel_repeat_C0[MDP_SCALE_COEFF_NUM] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static int16 mdp_scale_pixel_repeat_C1[MDP_SCALE_COEFF_NUM] = { - 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511, - 511, 511, 511, 511, 511, 511, 511, 511 -}; - -static int16 mdp_scale_pixel_repeat_C2[MDP_SCALE_COEFF_NUM] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static int16 mdp_scale_pixel_repeat_C3[MDP_SCALE_COEFF_NUM] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* --------------------------- FIR ------------------------------------- */ -/* -------- Downscale, ranging from 0.8x to 8.0x of original size -------- */ - -static int16 mdp_scale_0p8_to_8p0_C0[MDP_SCALE_COEFF_NUM] = { - 0, -7, -13, -19, -24, -28, -32, -34, -37, -39, - -40, -41, -41, -41, -40, -40, -38, -37, -35, -33, - -31, -29, -26, -24, -21, -18, -15, -13, -10, -7, - -5, -2 -}; - -static int16 mdp_scale_0p8_to_8p0_C1[MDP_SCALE_COEFF_NUM] = { - 511, 507, 501, 494, 485, 475, 463, 450, 436, 422, - 405, 388, 370, 352, 333, 314, 293, 274, 253, 233, - 213, 193, 172, 152, 133, 113, 95, 77, 60, 43, - 28, 13 -}; - -static int16 mdp_scale_0p8_to_8p0_C2[MDP_SCALE_COEFF_NUM] = { - 0, 13, 28, 43, 60, 77, 95, 113, 133, 152, - 172, 193, 213, 233, 253, 274, 294, 314, 333, 352, - 370, 388, 405, 422, 436, 450, 463, 475, 485, 494, - 501, 507, -}; - -static int16 mdp_scale_0p8_to_8p0_C3[MDP_SCALE_COEFF_NUM] = { - 0, -2, -5, -7, -10, -13, -15, -18, -21, -24, - -26, -29, -31, -33, -35, -37, -38, -40, -40, -41, - -41, -41, -40, -39, -37, -34, -32, -28, -24, -19, - -13, -7 -}; - -/* -------- Downscale, ranging from 0.6x to 0.8x of original size -------- */ - -static int16 mdp_scale_0p6_to_0p8_C0[MDP_SCALE_COEFF_NUM] = { - 104, 96, 89, 82, 75, 68, 61, 55, 49, 43, - 38, 33, 28, 24, 20, 16, 12, 9, 6, 4, - 2, 0, -2, -4, -5, -6, -7, -7, -8, -8, - -8, -8 -}; - -static int16 mdp_scale_0p6_to_0p8_C1[MDP_SCALE_COEFF_NUM] = { - 303, 303, 302, 300, 298, 296, 293, 289, 286, 281, - 276, 270, 265, 258, 252, 245, 238, 230, 223, 214, - 206, 197, 189, 180, 172, 163, 154, 145, 137, 128, - 120, 112 -}; - -static int16 mdp_scale_0p6_to_0p8_C2[MDP_SCALE_COEFF_NUM] = { - 112, 120, 128, 137, 145, 154, 163, 172, 180, 189, - 197, 206, 214, 223, 230, 238, 245, 252, 258, 265, - 270, 276, 281, 286, 289, 293, 296, 298, 300, 302, - 303, 303 -}; - -static int16 mdp_scale_0p6_to_0p8_C3[MDP_SCALE_COEFF_NUM] = { - -8, -8, -8, -8, -7, -7, -6, -5, -4, -2, - 0, 2, 4, 6, 9, 12, 16, 20, 24, 28, - 33, 38, 43, 49, 55, 61, 68, 75, 82, 89, - 96, 104 -}; - -/* -------- Downscale, ranging from 0.4x to 0.6x of original size -------- */ - -static int16 mdp_scale_0p4_to_0p6_C0[MDP_SCALE_COEFF_NUM] = { - 136, 132, 128, 123, 119, 115, 111, 107, 103, 98, - 95, 91, 87, 84, 80, 76, 73, 69, 66, 62, - 59, 57, 54, 50, 47, 44, 41, 39, 36, 33, - 32, 29 -}; - -static int16 mdp_scale_0p4_to_0p6_C1[MDP_SCALE_COEFF_NUM] = { - 206, 205, 204, 204, 201, 200, 199, 197, 196, 194, - 191, 191, 189, 185, 184, 182, 180, 178, 176, 173, - 170, 168, 165, 162, 160, 157, 155, 152, 148, 146, - 142, 140 -}; - -static int16 mdp_scale_0p4_to_0p6_C2[MDP_SCALE_COEFF_NUM] = { - 140, 142, 146, 148, 152, 155, 157, 160, 162, 165, - 168, 170, 173, 176, 178, 180, 182, 184, 185, 189, - 191, 191, 194, 196, 197, 199, 200, 201, 204, 204, - 205, 206 -}; - -static int16 mdp_scale_0p4_to_0p6_C3[MDP_SCALE_COEFF_NUM] = { - 29, 32, 33, 36, 39, 41, 44, 47, 50, 54, - 57, 59, 62, 66, 69, 73, 76, 80, 84, 87, - 91, 95, 98, 103, 107, 111, 115, 119, 123, 128, - 132, 136 -}; - -/* -------- Downscale, ranging from 0.2x to 0.4x of original size -------- */ - -static int16 mdp_scale_0p2_to_0p4_C0[MDP_SCALE_COEFF_NUM] = { - 131, 131, 130, 129, 128, 127, 127, 126, 125, 125, - 124, 123, 123, 121, 120, 119, 119, 118, 117, 117, - 116, 115, 115, 114, 113, 112, 111, 110, 109, 109, - 108, 107 -}; - -static int16 mdp_scale_0p2_to_0p4_C1[MDP_SCALE_COEFF_NUM] = { - 141, 140, 140, 140, 140, 139, 138, 138, 138, 137, - 137, 137, 136, 137, 137, 137, 136, 136, 136, 135, - 135, 135, 134, 134, 134, 134, 134, 133, 133, 132, - 132, 132 -}; - -static int16 mdp_scale_0p2_to_0p4_C2[MDP_SCALE_COEFF_NUM] = { - 132, 132, 132, 133, 133, 134, 134, 134, 134, 134, - 135, 135, 135, 136, 136, 136, 137, 137, 137, 136, - 137, 137, 137, 138, 138, 138, 139, 140, 140, 140, - 140, 141 -}; - -static int16 mdp_scale_0p2_to_0p4_C3[MDP_SCALE_COEFF_NUM] = { - 107, 108, 109, 109, 110, 111, 112, 113, 114, 115, - 115, 116, 117, 117, 118, 119, 119, 120, 121, 123, - 123, 124, 125, 125, 126, 127, 127, 128, 129, 130, - 131, 131 -}; - -static void mdp_update_scale_table(int index, int16 *c0, int16 *c1, - int16 *c2, int16 *c3) -{ - int i, val; - - for (i = 0; i < MDP_SCALE_COEFF_NUM; i++) { - val = - ((MDP_SCALE_COEFF_MASK & c1[i]) << 16) | - (MDP_SCALE_COEFF_MASK & c0[i]); - writel(val, MDP_PPP_SCALE_COEFF_LSBn(index)); - val = - ((MDP_SCALE_COEFF_MASK & c3[i]) << 16) | - (MDP_SCALE_COEFF_MASK & c2[i]); - writel(val, MDP_PPP_SCALE_COEFF_MSBn(index)); - index++; - } -} - -void mdp_init_scale_table(void) -{ - mdp_scale_0p2_to_0p4_mode = MDP_SCALE_FIR; - mdp_update_scale_table(MDP_SCALE_0P2_TO_0P4_INDEX, - mdp_scale_0p2_to_0p4_C0, - mdp_scale_0p2_to_0p4_C1, - mdp_scale_0p2_to_0p4_C2, - mdp_scale_0p2_to_0p4_C3); - - mdp_scale_0p4_to_0p6_mode = MDP_SCALE_FIR; - mdp_update_scale_table(MDP_SCALE_0P4_TO_0P6_INDEX, - mdp_scale_0p4_to_0p6_C0, - mdp_scale_0p4_to_0p6_C1, - mdp_scale_0p4_to_0p6_C2, - mdp_scale_0p4_to_0p6_C3); - - mdp_scale_0p6_to_0p8_mode = MDP_SCALE_FIR; - mdp_update_scale_table(MDP_SCALE_0P6_TO_0P8_INDEX, - mdp_scale_0p6_to_0p8_C0, - mdp_scale_0p6_to_0p8_C1, - mdp_scale_0p6_to_0p8_C2, - mdp_scale_0p6_to_0p8_C3); - - mdp_scale_0p8_to_8p0_mode = MDP_SCALE_FIR; - mdp_update_scale_table(MDP_SCALE_0P8_TO_8P0_INDEX, - mdp_scale_0p8_to_8p0_C0, - mdp_scale_0p8_to_8p0_C1, - mdp_scale_0p8_to_8p0_C2, - mdp_scale_0p8_to_8p0_C3); -} - -static long long mdp_do_div(long long num, long long den) -{ - do_div(num, den); - return num; -} - -#define SCALER_PHASE_BITS 29 -#define HAL_MDP_PHASE_STEP_2P50 0x50000000 -#define HAL_MDP_PHASE_STEP_1P66 0x35555555 -#define HAL_MDP_PHASE_STEP_1P25 0x28000000 - -struct phase_val { - int phase_init_x; - int phase_init_y; - int phase_step_x; - int phase_step_y; -}; - -static void mdp_calc_scaleInitPhase_3p1(uint32 in_w, - uint32 in_h, - uint32 out_w, - uint32 out_h, - boolean is_rotate, - boolean is_pp_x, - boolean is_pp_y, struct phase_val *pval) -{ - uint64 dst_ROI_width; - uint64 dst_ROI_height; - uint64 src_ROI_width; - uint64 src_ROI_height; - - /* - * phase_step_x, phase_step_y, phase_init_x and phase_init_y - * are represented in fixed-point, unsigned 3.29 format - */ - uint32 phase_step_x = 0; - uint32 phase_step_y = 0; - uint32 phase_init_x = 0; - uint32 phase_init_y = 0; - uint32 yscale_filter_sel, xscale_filter_sel; - uint32 scale_unit_sel_x, scale_unit_sel_y; - - uint64 numerator, denominator; - uint64 temp_dim; - - src_ROI_width = in_w; - src_ROI_height = in_h; - dst_ROI_width = out_w; - dst_ROI_height = out_h; - - /* if there is a 90 degree rotation */ - if (is_rotate) { - /* decide whether to use FIR or M/N for scaling */ - - /* if down-scaling by a factor smaller than 1/4 */ - if ((dst_ROI_height == 1 && src_ROI_width < 4) || - (src_ROI_width < 4 * dst_ROI_height - 3)) - scale_unit_sel_x = 0;/* use FIR scalar */ - else - scale_unit_sel_x = 1;/* use M/N scalar */ - - /* if down-scaling by a factor smaller than 1/4 */ - if ((dst_ROI_width == 1 && src_ROI_height < 4) || - (src_ROI_height < 4 * dst_ROI_width - 3)) - scale_unit_sel_y = 0;/* use FIR scalar */ - else - scale_unit_sel_y = 1;/* use M/N scalar */ - } else { - /* decide whether to use FIR or M/N for scaling */ - if ((dst_ROI_width == 1 && src_ROI_width < 4) || - (src_ROI_width < 4 * dst_ROI_width - 3)) - scale_unit_sel_x = 0;/* use FIR scalar */ - else - scale_unit_sel_x = 1;/* use M/N scalar */ - - if ((dst_ROI_height == 1 && src_ROI_height < 4) || - (src_ROI_height < 4 * dst_ROI_height - 3)) - scale_unit_sel_y = 0;/* use FIR scalar */ - else - scale_unit_sel_y = 1;/* use M/N scalar */ - } - - /* if there is a 90 degree rotation */ - if (is_rotate) { - /* swap the width and height of dst ROI */ - temp_dim = dst_ROI_width; - dst_ROI_width = dst_ROI_height; - dst_ROI_height = temp_dim; - } - - /* calculate phase step for the x direction */ - - /* if destination is only 1 pixel wide, the value of phase_step_x - is unimportant. Assigning phase_step_x to src ROI width - as an arbitrary value. */ - if (dst_ROI_width == 1) - phase_step_x = (uint32) ((src_ROI_width) << SCALER_PHASE_BITS); - - /* if using FIR scalar */ - else if (scale_unit_sel_x == 0) { - - /* Calculate the quotient ( src_ROI_width - 1 ) / ( dst_ROI_width - 1) - with u3.29 precision. Quotient is rounded up to the larger - 29th decimal point. */ - numerator = (src_ROI_width - 1) << SCALER_PHASE_BITS; - denominator = (dst_ROI_width - 1); /* never equals to 0 because of the "( dst_ROI_width == 1 ) case" */ - phase_step_x = (uint32) mdp_do_div((numerator + denominator - 1), denominator); /* divide and round up to the larger 29th decimal point. */ - - } - - /* if M/N scalar */ - else if (scale_unit_sel_x == 1) { - /* Calculate the quotient ( src_ROI_width ) / ( dst_ROI_width) - with u3.29 precision. Quotient is rounded down to the - smaller 29th decimal point. */ - numerator = (src_ROI_width) << SCALER_PHASE_BITS; - denominator = (dst_ROI_width); - phase_step_x = (uint32) mdp_do_div(numerator, denominator); - } - /* calculate phase step for the y direction */ - - /* if destination is only 1 pixel wide, the value of - phase_step_x is unimportant. Assigning phase_step_x - to src ROI width as an arbitrary value. */ - if (dst_ROI_height == 1) - phase_step_y = (uint32) ((src_ROI_height) << SCALER_PHASE_BITS); - - /* if FIR scalar */ - else if (scale_unit_sel_y == 0) { - /* Calculate the quotient ( src_ROI_height - 1 ) / ( dst_ROI_height - 1) - with u3.29 precision. Quotient is rounded up to the larger - 29th decimal point. */ - numerator = (src_ROI_height - 1) << SCALER_PHASE_BITS; - denominator = (dst_ROI_height - 1); /* never equals to 0 because of the "( dst_ROI_height == 1 )" case */ - phase_step_y = (uint32) mdp_do_div((numerator + denominator - 1), denominator); /* Quotient is rounded up to the larger 29th decimal point. */ - - } - - /* if M/N scalar */ - else if (scale_unit_sel_y == 1) { - /* Calculate the quotient ( src_ROI_height ) / ( dst_ROI_height) - with u3.29 precision. Quotient is rounded down to the smaller - 29th decimal point. */ - numerator = (src_ROI_height) << SCALER_PHASE_BITS; - denominator = (dst_ROI_height); - phase_step_y = (uint32) mdp_do_div(numerator, denominator); - } - - /* decide which set of FIR coefficients to use */ - if (phase_step_x > HAL_MDP_PHASE_STEP_2P50) - xscale_filter_sel = 0; - else if (phase_step_x > HAL_MDP_PHASE_STEP_1P66) - xscale_filter_sel = 1; - else if (phase_step_x > HAL_MDP_PHASE_STEP_1P25) - xscale_filter_sel = 2; - else - xscale_filter_sel = 3; - - if (phase_step_y > HAL_MDP_PHASE_STEP_2P50) - yscale_filter_sel = 0; - else if (phase_step_y > HAL_MDP_PHASE_STEP_1P66) - yscale_filter_sel = 1; - else if (phase_step_y > HAL_MDP_PHASE_STEP_1P25) - yscale_filter_sel = 2; - else - yscale_filter_sel = 3; - - /* calculate phase init for the x direction */ - - /* if using FIR scalar */ - if (scale_unit_sel_x == 0) { - if (dst_ROI_width == 1) - phase_init_x = - (uint32) ((src_ROI_width - 1) << SCALER_PHASE_BITS); - else - phase_init_x = 0; - - } - /* M over N scalar */ - else if (scale_unit_sel_x == 1) - phase_init_x = 0; - - /* calculate phase init for the y direction - if using FIR scalar */ - if (scale_unit_sel_y == 0) { - if (dst_ROI_height == 1) - phase_init_y = - (uint32) ((src_ROI_height - - 1) << SCALER_PHASE_BITS); - else - phase_init_y = 0; - - } - /* M over N scalar */ - else if (scale_unit_sel_y == 1) - phase_init_y = 0; - - /* write registers */ - pval->phase_step_x = (uint32) phase_step_x; - pval->phase_step_y = (uint32) phase_step_y; - pval->phase_init_x = (uint32) phase_init_x; - pval->phase_init_y = (uint32) phase_init_y; - - return; -} - -void mdp_set_scale(MDPIBUF *iBuf, - uint32 dst_roi_width, - uint32 dst_roi_height, - boolean inputRGB, boolean outputRGB, uint32 *pppop_reg_ptr) -{ - uint32 dst_roi_width_scale; - uint32 dst_roi_height_scale; - struct phase_val pval; - boolean use_pr; - uint32 ppp_scale_config = 0; - - if (!inputRGB) - ppp_scale_config |= BIT(6); - - if (iBuf->mdpImg.mdpOp & MDPOP_ASCALE) { - if (iBuf->mdpImg.mdpOp & MDPOP_ROT90) { - dst_roi_width_scale = dst_roi_height; - dst_roi_height_scale = dst_roi_width; - } else { - dst_roi_width_scale = dst_roi_width; - dst_roi_height_scale = dst_roi_height; - } - - if ((dst_roi_width_scale != iBuf->roi.width) || - (dst_roi_height_scale != iBuf->roi.height) || - (iBuf->mdpImg.mdpOp & MDPOP_SHARPENING)) { - *pppop_reg_ptr |= - (PPP_OP_SCALE_Y_ON | PPP_OP_SCALE_X_ON); - - mdp_calc_scaleInitPhase_3p1(iBuf->roi.width, - iBuf->roi.height, - dst_roi_width, - dst_roi_height, - iBuf->mdpImg. - mdpOp & MDPOP_ROT90, 1, 1, - &pval); - - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x013c, - pval.phase_init_x); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0140, - pval.phase_init_y); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0144, - pval.phase_step_x); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0148, - pval.phase_step_y); - - /* disable the pixel repeat option for scaling */ - use_pr = false; - - /* x-direction */ - if ((dst_roi_width_scale == iBuf->roi.width) && - !(iBuf->mdpImg.mdpOp & MDPOP_SHARPENING)) { - *pppop_reg_ptr &= ~PPP_OP_SCALE_X_ON; - } else - if (((dst_roi_width_scale * 10) / iBuf->roi.width) > - 8) { - if ((use_pr) - && (mdp_scale_0p8_to_8p0_mode != - MDP_SCALE_PR)) { - mdp_scale_0p8_to_8p0_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P8_TO_8P0_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p8_to_8p0_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p8_to_8p0_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P8_TO_8P0_INDEX, - mdp_scale_0p8_to_8p0_C0, - mdp_scale_0p8_to_8p0_C1, - mdp_scale_0p8_to_8p0_C2, - mdp_scale_0p8_to_8p0_C3); - } - ppp_scale_config |= (SCALE_U1_SET << 2); - } else - if (((dst_roi_width_scale * 10) / iBuf->roi.width) > - 6) { - if ((use_pr) - && (mdp_scale_0p6_to_0p8_mode != - MDP_SCALE_PR)) { - mdp_scale_0p6_to_0p8_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P6_TO_0P8_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p6_to_0p8_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p6_to_0p8_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P6_TO_0P8_INDEX, - mdp_scale_0p6_to_0p8_C0, - mdp_scale_0p6_to_0p8_C1, - mdp_scale_0p6_to_0p8_C2, - mdp_scale_0p6_to_0p8_C3); - } - ppp_scale_config |= (SCALE_D2_SET << 2); - } else - if (((dst_roi_width_scale * 10) / iBuf->roi.width) > - 4) { - if ((use_pr) - && (mdp_scale_0p4_to_0p6_mode != - MDP_SCALE_PR)) { - mdp_scale_0p4_to_0p6_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P4_TO_0P6_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p4_to_0p6_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p4_to_0p6_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P4_TO_0P6_INDEX, - mdp_scale_0p4_to_0p6_C0, - mdp_scale_0p4_to_0p6_C1, - mdp_scale_0p4_to_0p6_C2, - mdp_scale_0p4_to_0p6_C3); - } - ppp_scale_config |= (SCALE_D1_SET << 2); - } else - if ((dst_roi_width_scale == 1 && iBuf->roi.width < 4) || - (iBuf->roi.width < 4 * dst_roi_width_scale - 3)) { - if ((use_pr) - && (mdp_scale_0p2_to_0p4_mode != - MDP_SCALE_PR)) { - mdp_scale_0p2_to_0p4_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P2_TO_0P4_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p2_to_0p4_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p2_to_0p4_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P2_TO_0P4_INDEX, - mdp_scale_0p2_to_0p4_C0, - mdp_scale_0p2_to_0p4_C1, - mdp_scale_0p2_to_0p4_C2, - mdp_scale_0p2_to_0p4_C3); - } - ppp_scale_config |= (SCALE_D0_SET << 2); - } else - ppp_scale_config |= BIT(0); - - /* y-direction */ - if ((dst_roi_height_scale == iBuf->roi.height) && - !(iBuf->mdpImg.mdpOp & MDPOP_SHARPENING)) { - *pppop_reg_ptr &= ~PPP_OP_SCALE_Y_ON; - } else if (((dst_roi_height_scale * 10) / - iBuf->roi.height) > 8) { - if ((use_pr) - && (mdp_scale_0p8_to_8p0_mode != - MDP_SCALE_PR)) { - mdp_scale_0p8_to_8p0_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P8_TO_8P0_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p8_to_8p0_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p8_to_8p0_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P8_TO_8P0_INDEX, - mdp_scale_0p8_to_8p0_C0, - mdp_scale_0p8_to_8p0_C1, - mdp_scale_0p8_to_8p0_C2, - mdp_scale_0p8_to_8p0_C3); - } - ppp_scale_config |= (SCALE_U1_SET << 4); - } else - if (((dst_roi_height_scale * 10) / - iBuf->roi.height) > 6) { - if ((use_pr) - && (mdp_scale_0p6_to_0p8_mode != - MDP_SCALE_PR)) { - mdp_scale_0p6_to_0p8_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P6_TO_0P8_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p6_to_0p8_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p6_to_0p8_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P6_TO_0P8_INDEX, - mdp_scale_0p6_to_0p8_C0, - mdp_scale_0p6_to_0p8_C1, - mdp_scale_0p6_to_0p8_C2, - mdp_scale_0p6_to_0p8_C3); - } - ppp_scale_config |= (SCALE_D2_SET << 4); - } else - if (((dst_roi_height_scale * 10) / - iBuf->roi.height) > 4) { - if ((use_pr) - && (mdp_scale_0p4_to_0p6_mode != - MDP_SCALE_PR)) { - mdp_scale_0p4_to_0p6_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P4_TO_0P6_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p4_to_0p6_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p4_to_0p6_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P4_TO_0P6_INDEX, - mdp_scale_0p4_to_0p6_C0, - mdp_scale_0p4_to_0p6_C1, - mdp_scale_0p4_to_0p6_C2, - mdp_scale_0p4_to_0p6_C3); - } - ppp_scale_config |= (SCALE_D1_SET << 4); - } else if ((dst_roi_height_scale == 1 && - iBuf->roi.height < 4) || - (iBuf->roi.height < 4 * dst_roi_height_scale - 3)) { - if ((use_pr) - && (mdp_scale_0p2_to_0p4_mode != - MDP_SCALE_PR)) { - mdp_scale_0p2_to_0p4_mode = - MDP_SCALE_PR; - mdp_update_scale_table - (MDP_SCALE_0P2_TO_0P4_INDEX, - mdp_scale_pixel_repeat_C0, - mdp_scale_pixel_repeat_C1, - mdp_scale_pixel_repeat_C2, - mdp_scale_pixel_repeat_C3); - } else if ((!use_pr) - && (mdp_scale_0p2_to_0p4_mode != - MDP_SCALE_FIR)) { - mdp_scale_0p2_to_0p4_mode = - MDP_SCALE_FIR; - mdp_update_scale_table - (MDP_SCALE_0P2_TO_0P4_INDEX, - mdp_scale_0p2_to_0p4_C0, - mdp_scale_0p2_to_0p4_C1, - mdp_scale_0p2_to_0p4_C2, - mdp_scale_0p2_to_0p4_C3); - } - ppp_scale_config |= (SCALE_D0_SET << 4); - } else - ppp_scale_config |= BIT(1); - - if (iBuf->mdpImg.mdpOp & MDPOP_SHARPENING) { - ppp_scale_config |= BIT(7); - MDP_OUTP(MDP_BASE + 0x50020, - iBuf->mdpImg.sp_value); - } - - MDP_OUTP(MDP_BASE + 0x10230, ppp_scale_config); - } else { - iBuf->mdpImg.mdpOp &= ~(MDPOP_ASCALE); - } - } -} - -void mdp_adjust_start_addr(uint8 **src0, - uint8 **src1, - int v_slice, - int h_slice, - int x, - int y, - uint32 width, - uint32 height, int bpp, MDPIBUF *iBuf, int layer) -{ - switch (layer) { - case 0: - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0200, (y << 16) | (x)); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0208, - (height << 16) | (width)); - break; - - case 1: - /* MDP 3.1 HW bug workaround */ - if (iBuf->ibuf_type == MDP_YCRYCB_H2V1) { - *src0 += (x + y * width) * bpp; - x = y = 0; - width = iBuf->roi.dst_width; - height = iBuf->roi.dst_height; - } - - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x0204, (y << 16) | (x)); - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x020c, - (height << 16) | (width)); - break; - - case 2: - MDP_OUTP(MDP_CMD_DEBUG_ACCESS_BASE + 0x019c, (y << 16) | (x)); - break; - } -} - -void mdp_set_blend_attr(MDPIBUF *iBuf, - uint32 *alpha, - uint32 *tpVal, - uint32 perPixelAlpha, uint32 *pppop_reg_ptr) -{ - int bg_alpha; - - *alpha = iBuf->mdpImg.alpha; - *tpVal = iBuf->mdpImg.tpVal; - - if (iBuf->mdpImg.mdpOp & MDPOP_FG_PM_ALPHA) { - if (perPixelAlpha) { - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | PPP_OP_BLEND_CONSTANT_ALPHA; - } - else { - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - && (iBuf->mdpImg.alpha == 0xff)) { - iBuf->mdpImg.mdpOp &= ~(MDPOP_ALPHAB); - } - - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - || (iBuf->mdpImg.mdpOp & MDPOP_TRANSP)) { - *pppop_reg_ptr |= - PPP_OP_ROT_ON | PPP_OP_BLEND_ON | - PPP_OP_BLEND_CONSTANT_ALPHA | - PPP_OP_BLEND_ALPHA_BLEND_NORMAL; - } - } - - bg_alpha = PPP_BLEND_BG_USE_ALPHA_SEL | - PPP_BLEND_BG_ALPHA_REVERSE; - - if (perPixelAlpha) - bg_alpha |= PPP_BLEND_BG_SRCPIXEL_ALPHA; - else { - bg_alpha |= PPP_BLEND_BG_CONSTANT_ALPHA; - bg_alpha |= iBuf->mdpImg.alpha << 24; - } - outpdw(MDP_BASE + 0x70010, bg_alpha); - - if (iBuf->mdpImg.mdpOp & MDPOP_TRANSP) - *pppop_reg_ptr |= PPP_BLEND_CALPHA_TRNASP; - } else if (perPixelAlpha) { - *pppop_reg_ptr |= PPP_OP_ROT_ON | - PPP_OP_BLEND_ON | PPP_OP_BLEND_SRCPIXEL_ALPHA; - } else { - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - && (iBuf->mdpImg.alpha == 0xff)) { - iBuf->mdpImg.mdpOp &= ~(MDPOP_ALPHAB); - } - - if ((iBuf->mdpImg.mdpOp & MDPOP_ALPHAB) - || (iBuf->mdpImg.mdpOp & MDPOP_TRANSP)) { - *pppop_reg_ptr |= - PPP_OP_ROT_ON | PPP_OP_BLEND_ON | - PPP_OP_BLEND_CONSTANT_ALPHA | - PPP_OP_BLEND_ALPHA_BLEND_NORMAL; - } - - if (iBuf->mdpImg.mdpOp & MDPOP_TRANSP) - *pppop_reg_ptr |= PPP_BLEND_CALPHA_TRNASP; - } -} diff --git a/drivers/video/msm/mdp_vsync.c b/drivers/video/msm/mdp_vsync.c deleted file mode 100644 index 70f22f4647dcdef4646bcab458256c1502d299b4..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mdp_vsync.c +++ /dev/null @@ -1,502 +0,0 @@ -/* Copyright (c) 2008-2009, 2012-2013 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include "mdp.h" -#include "msm_fb.h" -#include "mddihost.h" - -#ifdef CONFIG_FB_MSM_MDP40 -#include "mdp4.h" - -#define MDP_SYNC_CFG_0 0x100 -#define MDP_SYNC_STATUS_0 0x10c -#define MDP_SYNC_CFG_1 0x104 -#define MDP_SYNC_STATUS_1 0x110 -#define MDP_PRIM_VSYNC_OUT_CTRL 0x118 -#define MDP_SEC_VSYNC_OUT_CTRL 0x11C -#define MDP_VSYNC_SEL 0x124 -#define MDP_PRIM_VSYNC_INIT_VAL 0x128 -#define MDP_SEC_VSYNC_INIT_VAL 0x12C -#else -#define MDP_SYNC_CFG_0 0x300 -#define MDP_SYNC_STATUS_0 0x30c -#define MDP_PRIM_VSYNC_OUT_CTRL 0x318 -#define MDP_PRIM_VSYNC_INIT_VAL 0x328 -#endif - -extern mddi_lcd_type mddi_lcd_idx; -extern spinlock_t mdp_spin_lock; -extern struct workqueue_struct *mdp_vsync_wq; -extern int lcdc_mode; -extern int vsync_mode; - -#ifdef MDP_HW_VSYNC -int vsync_above_th = 4; -int vsync_start_th = 1; -int vsync_load_cnt; -int vsync_clk_status; -DEFINE_MUTEX(vsync_clk_lock); -static DEFINE_SPINLOCK(vsync_timer_lock); - -static struct clk *mdp_vsync_clk; -static struct msm_fb_data_type *vsync_mfd; -static unsigned char timer_shutdown_flag; -static uint32 vsync_cnt_cfg; - - -void vsync_clk_prepare_enable(void) -{ - if (mdp_vsync_clk) - clk_prepare_enable(mdp_vsync_clk); -} - -void vsync_clk_disable_unprepare(void) -{ - if (mdp_vsync_clk) - clk_disable_unprepare(mdp_vsync_clk); -} - -void mdp_hw_vsync_clk_enable(struct msm_fb_data_type *mfd) -{ - if (vsync_clk_status == 1) - return; - mutex_lock(&vsync_clk_lock); - if (mfd->use_mdp_vsync) { - clk_prepare_enable(mdp_vsync_clk); - vsync_clk_status = 1; - } - mutex_unlock(&vsync_clk_lock); -} - -void mdp_hw_vsync_clk_disable(struct msm_fb_data_type *mfd) -{ - if (vsync_clk_status == 0) - return; - mutex_lock(&vsync_clk_lock); - if (mfd->use_mdp_vsync) { - clk_disable_unprepare(mdp_vsync_clk); - vsync_clk_status = 0; - } - mutex_unlock(&vsync_clk_lock); -} - -static void mdp_set_vsync(unsigned long data); -void mdp_vsync_clk_enable(void) -{ - if (vsync_mfd) { - mdp_hw_vsync_clk_enable(vsync_mfd); - if (!vsync_mfd->vsync_resync_timer.function) - mdp_set_vsync((unsigned long) vsync_mfd); - } -} - -void mdp_vsync_clk_disable(void) -{ - if (vsync_mfd) { - if (vsync_mfd->vsync_resync_timer.function) { - spin_lock(&vsync_timer_lock); - timer_shutdown_flag = 1; - spin_unlock(&vsync_timer_lock); - del_timer_sync(&vsync_mfd->vsync_resync_timer); - spin_lock(&vsync_timer_lock); - timer_shutdown_flag = 0; - spin_unlock(&vsync_timer_lock); - vsync_mfd->vsync_resync_timer.function = NULL; - } - - mdp_hw_vsync_clk_disable(vsync_mfd); - } -} -#endif - -static void mdp_set_vsync(unsigned long data) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)data; - struct msm_fb_panel_data *pdata = NULL; - - pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; - - vsync_mfd = mfd; - init_timer(&mfd->vsync_resync_timer); - - if ((pdata) && (pdata->set_vsync_notifier == NULL)) - return; - - if ((mfd->panel_info.lcd.vsync_enable) && (mfd->panel_power_on) - && (!mfd->vsync_handler_pending)) { - mfd->vsync_handler_pending = TRUE; - if (!queue_work(mdp_vsync_wq, &mfd->vsync_resync_worker)) { - MSM_FB_INFO - ("mdp_set_vsync: can't queue_work! -> needs to increase vsync_resync_timer_duration\n"); - } - } else { - MSM_FB_DEBUG - ("mdp_set_vsync failed! EN:%d PWR:%d PENDING:%d\n", - mfd->panel_info.lcd.vsync_enable, mfd->panel_power_on, - mfd->vsync_handler_pending); - } - - spin_lock(&vsync_timer_lock); - if (!timer_shutdown_flag) { - mfd->vsync_resync_timer.function = mdp_set_vsync; - mfd->vsync_resync_timer.data = data; - mfd->vsync_resync_timer.expires = - jiffies + mfd->panel_info.lcd.vsync_notifier_period; - add_timer(&mfd->vsync_resync_timer); - } - spin_unlock(&vsync_timer_lock); -} - -static void mdp_vsync_handler(void *data) -{ - struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)data; - - if (vsync_clk_status == 0) { - pr_debug("Warning: vsync clk is disabled\n"); - mfd->vsync_handler_pending = FALSE; - return; - } - - if (mfd->use_mdp_vsync) { -#ifdef MDP_HW_VSYNC - if (mfd->panel_power_on) { - MDP_OUTP(MDP_BASE + MDP_SYNC_STATUS_0, vsync_load_cnt); - -#ifdef CONFIG_FB_MSM_MDP40 - if (mdp_hw_revision < MDP4_REVISION_V2_1) - MDP_OUTP(MDP_BASE + MDP_SYNC_STATUS_1, - vsync_load_cnt); -#endif - } - -#endif - } else { - mfd->last_vsync_timetick = ktime_get_real(); - } - - mfd->vsync_handler_pending = FALSE; -} - -irqreturn_t mdp_hw_vsync_handler_proxy(int irq, void *data) -{ - /* - * ToDo: tried enabling/disabling GPIO MDP HW VSYNC interrupt - * but getting inaccurate timing in mdp_vsync_handler() - * disable_irq(MDP_HW_VSYNC_IRQ); - */ - mdp_vsync_handler(data); - - return IRQ_HANDLED; -} - -#ifdef MDP_HW_VSYNC -static void mdp_set_sync_cfg_0(struct msm_fb_data_type *mfd, int vsync_cnt) -{ - unsigned long cfg; - - cfg = mfd->total_lcd_lines - 1; - cfg <<= MDP_SYNCFG_HGT_LOC; - if (mfd->panel_info.lcd.hw_vsync_mode) - cfg |= MDP_SYNCFG_VSYNC_EXT_EN; - cfg |= (MDP_SYNCFG_VSYNC_INT_EN | vsync_cnt); - - MDP_OUTP(MDP_BASE + MDP_SYNC_CFG_0, cfg); -} - -#ifdef CONFIG_FB_MSM_MDP40 -static void mdp_set_sync_cfg_1(struct msm_fb_data_type *mfd, int vsync_cnt) -{ - unsigned long cfg; - - cfg = mfd->total_lcd_lines - 1; - cfg <<= MDP_SYNCFG_HGT_LOC; - if (mfd->panel_info.lcd.hw_vsync_mode) - cfg |= MDP_SYNCFG_VSYNC_EXT_EN; - cfg |= (MDP_SYNCFG_VSYNC_INT_EN | vsync_cnt); - - MDP_OUTP(MDP_BASE + MDP_SYNC_CFG_1, cfg); -} -#endif - -void mdp_vsync_cfg_regs(struct msm_fb_data_type *mfd, - boolean first_time) -{ - /* MDP cmd block enable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON, - FALSE); - if (first_time) - mdp_hw_vsync_clk_enable(mfd); - - mdp_set_sync_cfg_0(mfd, vsync_cnt_cfg); - -#ifdef CONFIG_FB_MSM_MDP40 - if (mdp_hw_revision < MDP4_REVISION_V2_1) - mdp_set_sync_cfg_1(mfd, vsync_cnt_cfg); -#endif - - /* - * load the last line + 1 to be in the - * safety zone - */ - vsync_load_cnt = mfd->panel_info.yres; - - /* line counter init value at the next pulse */ - MDP_OUTP(MDP_BASE + MDP_PRIM_VSYNC_INIT_VAL, - vsync_load_cnt); -#ifdef CONFIG_FB_MSM_MDP40 - if (mdp_hw_revision < MDP4_REVISION_V2_1) { - MDP_OUTP(MDP_BASE + MDP_SEC_VSYNC_INIT_VAL, - vsync_load_cnt); - } -#endif - - /* - * external vsync source pulse width and - * polarity flip - */ - MDP_OUTP(MDP_BASE + MDP_PRIM_VSYNC_OUT_CTRL, BIT(0)); -#ifdef CONFIG_FB_MSM_MDP40 - if (mdp_hw_revision < MDP4_REVISION_V2_1) { - MDP_OUTP(MDP_BASE + MDP_SEC_VSYNC_OUT_CTRL, BIT(0)); - MDP_OUTP(MDP_BASE + MDP_VSYNC_SEL, 0x20); - } -#endif - - /* threshold */ - MDP_OUTP(MDP_BASE + 0x200, (vsync_above_th << 16) | - (vsync_start_th)); - - if (first_time) - mdp_hw_vsync_clk_disable(mfd); - - /* MDP cmd block disable */ - mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_OFF, FALSE); -} -#endif - -void mdp_config_vsync(struct platform_device *pdev, - struct msm_fb_data_type *mfd) -{ - /* vsync on primary lcd only for now */ - if ((mfd->dest != DISPLAY_LCD) || (mfd->panel_info.pdest != DISPLAY_1) - || (!vsync_mode)) { - goto err_handle; - } - - vsync_clk_status = 0; - if (mfd->panel_info.lcd.vsync_enable) { - mfd->total_porch_lines = mfd->panel_info.lcd.v_back_porch + - mfd->panel_info.lcd.v_front_porch + - mfd->panel_info.lcd.v_pulse_width; - mfd->total_lcd_lines = - mfd->panel_info.yres + mfd->total_porch_lines; - mfd->lcd_ref_usec_time = - 100000000 / mfd->panel_info.lcd.refx100; - mfd->vsync_handler_pending = FALSE; - - mfd->last_vsync_timetick.tv64 = 0; - -#ifdef MDP_HW_VSYNC - if (mdp_vsync_clk == NULL) - mdp_vsync_clk = clk_get(&pdev->dev, "vsync_clk"); - - if (IS_ERR(mdp_vsync_clk)) { - printk(KERN_ERR "error: can't get mdp_vsync_clk!\n"); - mfd->use_mdp_vsync = 0; - } else - mfd->use_mdp_vsync = 1; - - if (mfd->use_mdp_vsync) { - uint32 vsync_cnt_cfg_dem; - uint32 mdp_vsync_clk_speed_hz; - - mdp_vsync_clk_speed_hz = clk_get_rate(mdp_vsync_clk); - - if (mdp_vsync_clk_speed_hz == 0) { - mfd->use_mdp_vsync = 0; - } else { - /* - * Do this calculation in 2 steps for - * rounding uint32 properly. - */ - vsync_cnt_cfg_dem = - (mfd->panel_info.lcd.refx100 * - mfd->total_lcd_lines) / 100; - vsync_cnt_cfg = - (mdp_vsync_clk_speed_hz) / - vsync_cnt_cfg_dem; - mdp_vsync_cfg_regs(mfd, TRUE); - } - } -#else - mfd->use_mdp_vsync = 0; - hrtimer_init(&mfd->dma_hrtimer, CLOCK_MONOTONIC, - HRTIMER_MODE_REL); - mfd->dma_hrtimer.function = mdp_dma2_vsync_hrtimer_handler; - mfd->vsync_width_boundary = vmalloc(mfd->panel_info.xres * 4); -#endif - -#ifdef CONFIG_FB_MSM_MDDI - mfd->channel_irq = 0; - if (mfd->panel_info.lcd.hw_vsync_mode) { - u32 vsync_gpio = mfd->vsync_gpio; - u32 ret; - - if (vsync_gpio == -1) { - MSM_FB_INFO("vsync_gpio not defined!\n"); - goto err_handle; - } - - ret = gpio_tlmm_config(GPIO_CFG - (vsync_gpio, - (mfd->use_mdp_vsync) ? 1 : 0, - GPIO_CFG_INPUT, - GPIO_CFG_PULL_DOWN, - GPIO_CFG_2MA), - GPIO_CFG_ENABLE); - if (ret) - goto err_handle; - - /* - * if use_mdp_vsync, then no interrupt need since - * mdp_vsync is feed directly to mdp to reset the - * write pointer counter. therefore no irq_handler - * need to reset write pointer counter. - */ - if (!mfd->use_mdp_vsync) { - mfd->channel_irq = MSM_GPIO_TO_INT(vsync_gpio); - if (request_irq - (mfd->channel_irq, - &mdp_hw_vsync_handler_proxy, - IRQF_TRIGGER_FALLING, "VSYNC_GPIO", - (void *)mfd)) { - MSM_FB_INFO - ("irq=%d failed! vsync_gpio=%d\n", - mfd->channel_irq, - vsync_gpio); - goto err_handle; - } - } - } -#endif - mdp_hw_vsync_clk_enable(mfd); - mdp_set_vsync((unsigned long)mfd); - } - - return; - -err_handle: - if (mfd->vsync_width_boundary) - vfree(mfd->vsync_width_boundary); - mfd->panel_info.lcd.vsync_enable = FALSE; - printk(KERN_ERR "%s: failed!\n", __func__); -} - -void mdp_vsync_resync_workqueue_handler(struct work_struct *work) -{ - struct msm_fb_data_type *mfd = NULL; - int vsync_fnc_enabled = FALSE; - struct msm_fb_panel_data *pdata = NULL; - - mfd = container_of(work, struct msm_fb_data_type, vsync_resync_worker); - - if (mfd) { - if (mfd->panel_power_on) { - pdata = - (struct msm_fb_panel_data *)mfd->pdev->dev. - platform_data; - - if (pdata->set_vsync_notifier != NULL) { - if (pdata->clk_func && !pdata->clk_func(2)) { - mfd->vsync_handler_pending = FALSE; - return; - } - - pdata->set_vsync_notifier( - mdp_vsync_handler, - (void *)mfd); - vsync_fnc_enabled = TRUE; - } - } - } - - if ((mfd) && (!vsync_fnc_enabled)) - mfd->vsync_handler_pending = FALSE; -} - -boolean mdp_hw_vsync_set_handler(msm_fb_vsync_handler_type handler, void *data) -{ - /* - * ToDo: tried enabling/disabling GPIO MDP HW VSYNC interrupt - * but getting inaccurate timing in mdp_vsync_handler() - * enable_irq(MDP_HW_VSYNC_IRQ); - */ - - return TRUE; -} - -uint32 mdp_get_lcd_line_counter(struct msm_fb_data_type *mfd) -{ - uint32 elapsed_usec_time; - uint32 lcd_line; - ktime_t last_vsync_timetick_local; - ktime_t curr_time; - unsigned long flag; - - if ((!mfd->panel_info.lcd.vsync_enable) || (!vsync_mode)) - return 0; - - spin_lock_irqsave(&mdp_spin_lock, flag); - last_vsync_timetick_local = mfd->last_vsync_timetick; - spin_unlock_irqrestore(&mdp_spin_lock, flag); - - curr_time = ktime_get_real(); - elapsed_usec_time = ktime_to_us(ktime_sub(curr_time, - last_vsync_timetick_local)); - - elapsed_usec_time = elapsed_usec_time % mfd->lcd_ref_usec_time; - - /* lcd line calculation referencing to line counter = 0 */ - lcd_line = - (elapsed_usec_time * mfd->total_lcd_lines) / mfd->lcd_ref_usec_time; - - /* lcd line adjusment referencing to the actual line counter at vsync */ - lcd_line = - (mfd->total_lcd_lines - mfd->panel_info.lcd.v_back_porch + - lcd_line) % (mfd->total_lcd_lines + 1); - - if (lcd_line > mfd->total_lcd_lines) { - MSM_FB_INFO - ("mdp_get_lcd_line_counter: mdp_lcd_rd_cnt >= mfd->total_lcd_lines error!\n"); - } - - return lcd_line; -} diff --git a/drivers/video/msm/mdss/mdss_dsi.h b/drivers/video/msm/mdss/mdss_dsi.h index f4fdfcf01660e20aab36dc1287477d5935e301ce..4c7b03b0a0d29239788d0e2365530969422a435c 100644 --- a/drivers/video/msm/mdss/mdss_dsi.h +++ b/drivers/video/msm/mdss/mdss_dsi.h @@ -25,13 +25,8 @@ #define MIPI_OUTP(addr, data) writel_relaxed((data), (addr)) #define MIPI_INP(addr) readl_relaxed(addr) -#ifdef CONFIG_MSM_SECURE_IO -#define MIPI_OUTP_SECURE(addr, data) secure_writel((data), (addr)) -#define MIPI_INP_SECURE(addr) secure_readl(addr) -#else #define MIPI_OUTP_SECURE(addr, data) writel_relaxed((data), (addr)) #define MIPI_INP_SECURE(addr) readl_relaxed(addr) -#endif #define MIPI_DSI_PRIM 1 #define MIPI_DSI_SECD 2 diff --git a/drivers/video/msm/mhl/mhl_8334.c b/drivers/video/msm/mhl/mhl_8334.c deleted file mode 100644 index 2acf6f47c20ab4ff8c06312980a24899d3e0434a..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mhl/mhl_8334.c +++ /dev/null @@ -1,1720 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "external_common.h" -#include "hdmi_msm.h" -#include "mhl_i2c_utils.h" - -#define MSC_START_BIT_MSC_CMD (0x01 << 0) -#define MSC_START_BIT_VS_CMD (0x01 << 1) -#define MSC_START_BIT_READ_REG (0x01 << 2) -#define MSC_START_BIT_WRITE_REG (0x01 << 3) -#define MSC_START_BIT_WRITE_BURST (0x01 << 4) - -static struct i2c_device_id mhl_sii_i2c_id[] = { - { MHL_DRIVER_NAME, 0 }, - { } -}; - -struct mhl_msm_state_t *mhl_msm_state; -spinlock_t mhl_state_lock; -struct workqueue_struct *msc_send_workqueue; - -static int mhl_i2c_probe(struct i2c_client *client,\ - const struct i2c_device_id *id); -static int mhl_i2c_remove(struct i2c_client *client); -static void force_usb_switch_open(void); -static void release_usb_switch_open(void); -static void switch_mode(enum mhl_st_type to_mode); -static irqreturn_t mhl_tx_isr(int irq, void *dev_id); -void (*notify_usb_online)(int online); -static void mhl_drive_hpd(uint8_t to_state); -static int mhl_send_msc_command(struct msc_command_struct *req); -static void list_cmd_put(struct msc_command_struct *cmd); -static struct msc_command_struct *list_cmd_get(void); -static void mhl_msc_send_work(struct work_struct *work); - -static struct i2c_driver mhl_sii_i2c_driver = { - .driver = { - .name = MHL_DRIVER_NAME, - .owner = THIS_MODULE, - }, - .probe = mhl_i2c_probe, - /*.remove = __exit_p(mhl_i2c_remove),*/ - .remove = mhl_i2c_remove, - .id_table = mhl_sii_i2c_id, -}; - -static void mhl_sii_reset_pin(int on) -{ - gpio_set_value(mhl_msm_state->mhl_data->gpio_mhl_reset, on); - return; -} - -static int mhl_sii_reg_enable(void) -{ - static struct regulator *reg_8038_l20; - static struct regulator *reg_8038_l11; - int rc; - - pr_debug("Inside %s\n", __func__); - if (!reg_8038_l20) { - reg_8038_l20 = regulator_get(&mhl_msm_state->i2c_client->dev, - "mhl_avcc12"); - if (IS_ERR(reg_8038_l20)) { - pr_err("could not get reg_8038_l20, rc = %ld\n", - PTR_ERR(reg_8038_l20)); - return -ENODEV; - } - rc = regulator_enable(reg_8038_l20); - if (rc) { - pr_err("'%s' regulator enable failed, rc=%d\n", - "mhl_l20", rc); - return rc; - } else - pr_debug("REGULATOR L20 ENABLED\n"); - } - - if (!reg_8038_l11) { - reg_8038_l11 = regulator_get(&mhl_msm_state->i2c_client->dev, - "mhl_iovcc18"); - if (IS_ERR(reg_8038_l11)) { - pr_err("could not get reg_8038_l11, rc = %ld\n", - PTR_ERR(reg_8038_l11)); - return -ENODEV; - } - rc = regulator_enable(reg_8038_l11); - if (rc) { - pr_err("'%s' regulator enable failed, rc=%d\n", - "mhl_l11", rc); - return rc; - } else - pr_debug("REGULATOR L11 ENABLED\n"); - } - - return rc; -} - - -static void mhl_sii_power_on(void) -{ - int ret; - pr_debug("MHL SII POWER ON\n"); - if (!mhl_msm_state->mhl_data->gpio_mhl_power) { - pr_warn("%s: no power reqd for this platform\n", __func__); - return; - } - - ret = gpio_request(mhl_msm_state->mhl_data->gpio_mhl_power, "W_PWR"); - if (ret < 0) { - pr_err("MHL_POWER_GPIO req failed: %d\n", - ret); - return; - } - ret = gpio_direction_output(mhl_msm_state->mhl_data->gpio_mhl_power, - 1); - if (ret < 0) { - pr_err( - "SET GPIO MHL_POWER_GPIO direction failed: %d\n", - ret); - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_power); - return; - } - gpio_set_value(mhl_msm_state->mhl_data->gpio_mhl_power, 1); - - if (mhl_sii_reg_enable()) - pr_err("Regulator enable failed\n"); - - pr_debug("MHL SII POWER ON Successful\n"); - return; -} - -/* - * Request for GPIO allocations - * Set appropriate GPIO directions - */ -static int mhl_sii_gpio_setup(int on) -{ - int ret; - if (on) { - if (mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux) { - ret = gpio_request(mhl_msm_state->\ - mhl_data->gpio_hdmi_mhl_mux, "W_MUX"); - if (ret < 0) { - pr_err("GPIO HDMI_MHL MUX req failed:%d\n", - ret); - return -EBUSY; - } - ret = gpio_direction_output( - mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux, 0); - if (ret < 0) { - pr_err("SET GPIO HDMI_MHL dir failed:%d\n", - ret); - gpio_free(mhl_msm_state->\ - mhl_data->gpio_hdmi_mhl_mux); - return -EBUSY; - } - msleep(50); - gpio_set_value(mhl_msm_state->\ - mhl_data->gpio_hdmi_mhl_mux, 0); - pr_debug("SET GPIO HDMI MHL MUX %d to 0\n", - mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux); - } - - ret = gpio_request(mhl_msm_state->mhl_data->gpio_mhl_reset, - "W_RST#"); - if (ret < 0) { - pr_err("GPIO RESET request failed: %d\n", ret); - return -EBUSY; - } - ret = gpio_direction_output(mhl_msm_state->\ - mhl_data->gpio_mhl_reset, 1); - if (ret < 0) { - pr_err("SET GPIO RESET direction failed: %d\n", ret); - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset); - gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux); - return -EBUSY; - } - ret = gpio_request(mhl_msm_state->mhl_data->gpio_mhl_int, - "W_INT"); - if (ret < 0) { - pr_err("GPIO INT request failed: %d\n", ret); - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset); - gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux); - return -EBUSY; - } - ret = gpio_direction_input(mhl_msm_state->\ - mhl_data->gpio_mhl_int); - if (ret < 0) { - pr_err("SET GPIO INTR direction failed: %d\n", ret); - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset); - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_int); - gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux); - return -EBUSY; - } - } else { - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_reset); - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_int); - gpio_free(mhl_msm_state->mhl_data->gpio_hdmi_mhl_mux); - gpio_free(mhl_msm_state->mhl_data->gpio_mhl_power); - } - - return 0; -} - -/* USB_HANDSHAKING FUNCTIONS */ - -int mhl_device_discovery(const char *name, int *result) - -{ - int timeout ; - mhl_i2c_reg_write(TX_PAGE_3, 0x0010, 0x27); - msleep(50); - if (mhl_msm_state->cur_state == POWER_STATE_D3) { - /* give MHL driver chance to handle RGND interrupt */ - INIT_COMPLETION(mhl_msm_state->rgnd_done); - timeout = wait_for_completion_interruptible_timeout - (&mhl_msm_state->rgnd_done, HZ/2); - if (!timeout) { - /* most likely nothing plugged in USB */ - /* USB HOST connected or already in USB mode */ - pr_debug("Timedout Returning from discovery mode\n"); - *result = MHL_DISCOVERY_RESULT_USB; - return 0; - } - *result = mhl_msm_state->mhl_mode ? - MHL_DISCOVERY_RESULT_MHL : MHL_DISCOVERY_RESULT_USB; - } else - /* not in D3. already in MHL mode */ - *result = MHL_DISCOVERY_RESULT_MHL; - - return 0; -} -EXPORT_SYMBOL(mhl_device_discovery); - -int mhl_register_callback(const char *name, void (*callback)(int online)) -{ - pr_debug("%s\n", __func__); - if (!callback) - return -EINVAL; - if (!notify_usb_online) - notify_usb_online = callback; - return 0; -} -EXPORT_SYMBOL(mhl_register_callback); - -int mhl_unregister_callback(const char *name) -{ - pr_debug("%s\n", __func__); - if (notify_usb_online) - notify_usb_online = NULL; - return 0; -} -EXPORT_SYMBOL(mhl_unregister_callback); - - -static void cbus_reset(void) -{ - uint8_t i; - - /* - * REG_SRST - */ - mhl_i2c_reg_modify(TX_PAGE_3, 0x0000, BIT3, BIT3); - msleep(20); - mhl_i2c_reg_modify(TX_PAGE_3, 0x0000, BIT3, 0x00); - /* - * REG_INTR1 and REG_INTR4 - */ - mhl_i2c_reg_write(TX_PAGE_L0, 0x0075, BIT6); - mhl_i2c_reg_write(TX_PAGE_3, 0x0022, - BIT0 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6); - /* REG5 */ - if (mhl_msm_state->chip_rev_id < 1) - mhl_i2c_reg_write(TX_PAGE_3, 0x0024, BIT3 | BIT4); - else - /*REG5 Mask disabled due to auto FIFO reset ??*/ - mhl_i2c_reg_write(TX_PAGE_3, 0x0024, 0x00); - - /* Unmask CBUS1 Intrs */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0009, - BIT2 | BIT3 | BIT4 | BIT5 | BIT6); - - /* Unmask CBUS2 Intrs */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x001F, BIT2 | BIT3); - - for (i = 0; i < 4; i++) { - /* - * Enable WRITE_STAT interrupt for writes to - * all 4 MSC Status registers. - */ - mhl_i2c_reg_write(TX_PAGE_CBUS, (0xE0 + i), 0xFF); - - /* - * Enable SET_INT interrupt for writes to - * all 4 MSC Interrupt registers. - */ - mhl_i2c_reg_write(TX_PAGE_CBUS, (0xF0 + i), 0xFF); - } -} - -static void init_cbus_regs(void) -{ - uint8_t regval; - - /* Increase DDC translation layer timer*/ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0007, 0xF2); - /* Drive High Time */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0036, 0x03); - /* Use programmed timing */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0039, 0x30); - /* CBUS Drive Strength */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0040, 0x03); - /* - * Write initial default settings - * to devcap regs: default settings - */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_DEV_STATE, - DEVCAP_VAL_DEV_STATE); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_MHL_VERSION, - DEVCAP_VAL_MHL_VERSION); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_DEV_CAT, - DEVCAP_VAL_DEV_CAT); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_ADOPTER_ID_H, - DEVCAP_VAL_ADOPTER_ID_H); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_ADOPTER_ID_L, - DEVCAP_VAL_ADOPTER_ID_L); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_VID_LINK_MODE, - DEVCAP_VAL_VID_LINK_MODE); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_AUD_LINK_MODE, - DEVCAP_VAL_AUD_LINK_MODE); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_VIDEO_TYPE, - DEVCAP_VAL_VIDEO_TYPE); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_LOG_DEV_MAP, - DEVCAP_VAL_LOG_DEV_MAP); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_BANDWIDTH, - DEVCAP_VAL_BANDWIDTH); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_FEATURE_FLAG, - DEVCAP_VAL_FEATURE_FLAG); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_DEVICE_ID_H, - DEVCAP_VAL_DEVICE_ID_H); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_DEVICE_ID_L, - DEVCAP_VAL_DEVICE_ID_L); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_SCRATCHPAD_SIZE, - DEVCAP_VAL_SCRATCHPAD_SIZE); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_INT_STAT_SIZE, - DEVCAP_VAL_INT_STAT_SIZE); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0080 | DEVCAP_OFFSET_RESERVED, - DEVCAP_VAL_RESERVED); - - /* Make bits 2,3 (initiator timeout) to 1,1 - * for register CBUS_LINK_CONTROL_2 - * REG_CBUS_LINK_CONTROL_2 - */ - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0031); - regval = (regval | 0x0C); - /* REG_CBUS_LINK_CONTROL_2 */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0031, regval); - /* REG_MSC_TIMEOUT_LIMIT */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0022, 0x0F); - /* REG_CBUS_LINK_CONTROL_1 */ - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0030, 0x01); - /* disallow vendor specific commands */ - mhl_i2c_reg_modify(TX_PAGE_CBUS, 0x002E, BIT4, BIT4); -} - -/* - * Configure the initial reg settings - */ -static void mhl_init_reg_settings(bool mhl_disc_en) -{ - - /* - * ============================================ - * POWER UP - * ============================================ - */ - - /* Power up 1.2V core */ - mhl_i2c_reg_write(TX_PAGE_L1, 0x003D, 0x3F); - /* - * Wait for the source power to be enabled - * before enabling pll clocks. - */ - msleep(50); - /* Enable Tx PLL Clock */ - mhl_i2c_reg_write(TX_PAGE_2, 0x0011, 0x01); - /* Enable Tx Clock Path and Equalizer */ - mhl_i2c_reg_write(TX_PAGE_2, 0x0012, 0x11); - /* Tx Source Termination ON */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0030, 0x10); - /* Enable 1X MHL Clock output */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0035, 0xAC); - /* Tx Differential Driver Config */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0031, 0x3C); - mhl_i2c_reg_write(TX_PAGE_3, 0x0033, 0xD9); - /* PLL Bandwidth Control */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0037, 0x02); - /* - * ============================================ - * Analog PLL Control - * ============================================ - */ - /* Enable Rx PLL clock */ - mhl_i2c_reg_write(TX_PAGE_L0, 0x0080, 0x00); - mhl_i2c_reg_write(TX_PAGE_L0, 0x00F8, 0x0C); - mhl_i2c_reg_write(TX_PAGE_L0, 0x0085, 0x02); - mhl_i2c_reg_write(TX_PAGE_2, 0x0000, 0x00); - mhl_i2c_reg_write(TX_PAGE_2, 0x0013, 0x60); - /* PLL Cal ref sel */ - mhl_i2c_reg_write(TX_PAGE_2, 0x0017, 0x03); - /* VCO Cal */ - mhl_i2c_reg_write(TX_PAGE_2, 0x001A, 0x20); - /* Auto EQ */ - mhl_i2c_reg_write(TX_PAGE_2, 0x0022, 0xE0); - mhl_i2c_reg_write(TX_PAGE_2, 0x0023, 0xC0); - mhl_i2c_reg_write(TX_PAGE_2, 0x0024, 0xA0); - mhl_i2c_reg_write(TX_PAGE_2, 0x0025, 0x80); - mhl_i2c_reg_write(TX_PAGE_2, 0x0026, 0x60); - mhl_i2c_reg_write(TX_PAGE_2, 0x0027, 0x40); - mhl_i2c_reg_write(TX_PAGE_2, 0x0028, 0x20); - mhl_i2c_reg_write(TX_PAGE_2, 0x0029, 0x00); - /* Rx PLL Bandwidth 4MHz */ - mhl_i2c_reg_write(TX_PAGE_2, 0x0031, 0x0A); - /* Rx PLL Bandwidth value from I2C */ - mhl_i2c_reg_write(TX_PAGE_2, 0x0045, 0x06); - mhl_i2c_reg_write(TX_PAGE_2, 0x004B, 0x06); - /* Manual zone control */ - mhl_i2c_reg_write(TX_PAGE_2, 0x004C, 0xE0); - /* PLL Mode value */ - mhl_i2c_reg_write(TX_PAGE_2, 0x004D, 0x00); - mhl_i2c_reg_write(TX_PAGE_L0, 0x0008, 0x35); - /* - * Discovery Control and Status regs - * Setting De-glitch time to 50 ms (default) - * Switch Control Disabled - */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0011, 0xAD); - /* 1.8V CBUS VTH */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0014, 0x55); - /* RGND and single Discovery attempt */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0015, 0x11); - /* Ignore VBUS */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0017, 0x82); - mhl_i2c_reg_write(TX_PAGE_3, 0x0018, 0x24); - /* Pull-up resistance off for IDLE state */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0013, 0x8C); - /* Enable CBUS Discovery */ - if (mhl_disc_en) - /* Enable MHL Discovery */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0010, 0x27); - else - /* Disable MHL Discovery */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0010, 0x26); - mhl_i2c_reg_write(TX_PAGE_3, 0x0016, 0x20); - /* MHL CBUS Discovery - immediate comm. */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0012, 0x86); - /* Do not force HPD to 0 during wake-up from D3 */ - if (mhl_msm_state->cur_state != POWER_STATE_D0_MHL) - mhl_drive_hpd(HPD_DOWN); - - /* Enable Auto Soft RESET */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0000, 0x084); - /* HDMI Transcode mode enable */ - mhl_i2c_reg_write(TX_PAGE_L0, 0x000D, 0x1C); - - cbus_reset(); - init_cbus_regs(); -} - -static int mhl_chip_init(void) -{ - /* Read the chip rev ID */ - mhl_msm_state->chip_rev_id = mhl_i2c_reg_read(TX_PAGE_L0, 0x04); - pr_debug("MHL: chip rev ID read=[%x]\n", mhl_msm_state->chip_rev_id); - - /* Reset the TX chip */ - mhl_sii_reset_pin(1); - msleep(20); - mhl_sii_reset_pin(0); - msleep(20); - mhl_sii_reset_pin(1); - /* MHL spec requires a 100 ms wait here. */ - msleep(100); - - /* - * Need to disable MHL discovery - */ - mhl_init_reg_settings(true); - - /* - * Power down the chip to the - * D3 - a low power standby mode - * cable impedance measurement logic is operational - */ - switch_mode(POWER_STATE_D3); - return 0; -} - -/* - * I2C probe - */ -static int mhl_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - struct msm_mhl_platform_data *tmp = client->dev.platform_data; - if (!tmp->mhl_enabled) { - ret = -ENODEV; - pr_warn("MHL feautre left disabled\n"); - goto probe_early_exit; - } - mhl_msm_state->mhl_data = kzalloc(sizeof(struct msm_mhl_platform_data), - GFP_KERNEL); - if (!(mhl_msm_state->mhl_data)) { - ret = -ENOMEM; - pr_err("MHL I2C Probe failed - no mem\n"); - goto probe_early_exit; - } - mhl_msm_state->i2c_client = client; - spin_lock_init(&mhl_state_lock); - i2c_set_clientdata(client, mhl_msm_state); - mhl_msm_state->mhl_data = client->dev.platform_data; - pr_debug("MHL: mhl_msm_state->mhl_data->irq=[%d]\n", - mhl_msm_state->mhl_data->irq); - msc_send_workqueue = create_workqueue("mhl_msc_cmd_queue"); - - mhl_msm_state->cur_state = POWER_STATE_D0_MHL; - /* Init GPIO stuff here */ - ret = mhl_sii_gpio_setup(1); - if (ret) { - pr_err("MHL: mhl_gpio_init has failed\n"); - ret = -ENODEV; - goto probe_early_exit; - } - mhl_sii_power_on(); - /* MHL SII 8334 chip specific init */ - mhl_chip_init(); - init_completion(&mhl_msm_state->rgnd_done); - /* Request IRQ stuff here */ - pr_debug("MHL: mhl_msm_state->mhl_data->irq=[%d]\n", - mhl_msm_state->mhl_data->irq); - ret = request_threaded_irq(mhl_msm_state->mhl_data->irq, NULL, - &mhl_tx_isr, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "mhl_tx_isr", mhl_msm_state); - if (ret) { - pr_err("request_threaded_irq failed, status: %d\n", - ret); - goto probe_exit; - } else { - pr_debug("request_threaded_irq succeeded\n"); - } - - INIT_WORK(&mhl_msm_state->mhl_msc_send_work, mhl_msc_send_work); - INIT_LIST_HEAD(&mhl_msm_state->list_cmd); - mhl_msm_state->msc_command_put_work = list_cmd_put; - mhl_msm_state->msc_command_get_work = list_cmd_get; - init_completion(&mhl_msm_state->msc_cmd_done); - - pr_debug("i2c probe successful\n"); - return 0; - -probe_exit: - if (mhl_msm_state->mhl_data) { - /* free the gpios */ - mhl_sii_gpio_setup(0); - kfree(mhl_msm_state->mhl_data); - mhl_msm_state->mhl_data = NULL; - } -probe_early_exit: - return ret; -} - -static int mhl_i2c_remove(struct i2c_client *client) -{ - pr_debug("%s\n", __func__); - mhl_sii_gpio_setup(0); - kfree(mhl_msm_state->mhl_data); - return 0; -} - -static void list_cmd_put(struct msc_command_struct *cmd) -{ - struct msc_cmd_envelope *new_cmd; - new_cmd = vmalloc(sizeof(struct msc_cmd_envelope)); - memcpy(&new_cmd->msc_cmd_msg, cmd, - sizeof(struct msc_command_struct)); - /* Need to check for queue getting filled up */ - list_add_tail(&new_cmd->msc_queue_envelope, &mhl_msm_state->list_cmd); -} - -static struct msc_command_struct *list_cmd_get(void) -{ - struct msc_cmd_envelope *cmd_env = - list_first_entry(&mhl_msm_state->list_cmd, - struct msc_cmd_envelope, msc_queue_envelope); - list_del(&cmd_env->msc_queue_envelope); - return &cmd_env->msc_cmd_msg; -} - -static void mhl_msc_send_work(struct work_struct *work) -{ - int ret; - /* - * Remove item from the queue - * and schedule it - */ - struct msc_command_struct *req; - while (!list_empty(&mhl_msm_state->list_cmd)) { - req = mhl_msm_state->msc_command_get_work(); - ret = mhl_send_msc_command(req); - if (ret == -EAGAIN) - pr_err("MHL: Queue still busy!!\n"); - else { - vfree(req); - pr_debug("MESSAGE SENT!!!!\n"); - } - } -} - - -static int __init mhl_msm_init(void) -{ - int32_t ret; - - pr_debug("%s\n", __func__); - mhl_msm_state = kzalloc(sizeof(struct mhl_msm_state_t), GFP_KERNEL); - if (!mhl_msm_state) { - pr_err("mhl_msm_init FAILED: out of memory\n"); - ret = -ENOMEM; - goto init_exit; - } - mhl_msm_state->i2c_client = NULL; - ret = i2c_add_driver(&mhl_sii_i2c_driver); - if (ret) { - pr_err("MHL: I2C driver add failed: %d\n", ret); - ret = -ENODEV; - goto init_exit; - } else { - if (mhl_msm_state->i2c_client == NULL) { - i2c_del_driver(&mhl_sii_i2c_driver); - pr_err("MHL: I2C driver add failed\n"); - ret = -ENODEV; - goto init_exit; - } - pr_info("MHL: I2C driver added\n"); - } - - return 0; -init_exit: - pr_err("Exiting from the init with err\n"); - if (!mhl_msm_state) { - kfree(mhl_msm_state); - mhl_msm_state = NULL; - } - return ret; -} - -static void mhl_msc_sched_work(struct msc_command_struct *req) -{ - /* - * Put an item to the queue - * and schedule work - */ - mhl_msm_state->msc_command_put_work(req); - queue_work(msc_send_workqueue, &mhl_msm_state->mhl_msc_send_work); -} - -static void switch_mode(enum mhl_st_type to_mode) -{ - unsigned long flags; - - switch (to_mode) { - case POWER_STATE_D0_NO_MHL: - break; - case POWER_STATE_D0_MHL: - mhl_init_reg_settings(true); - /* REG_DISC_CTRL1 */ - mhl_i2c_reg_modify(TX_PAGE_3, 0x0010, BIT1 | BIT0, BIT0); - - /* - * TPI_DEVICE_POWER_STATE_CTRL_REG - * TX_POWER_STATE_MASK = BIT1 | BIT0 - */ - mhl_i2c_reg_modify(TX_PAGE_TPI, 0x001E, BIT1 | BIT0, 0x00); - break; - case POWER_STATE_D3: - if (mhl_msm_state->cur_state != POWER_STATE_D3) { - /* Force HPD to 0 when not in MHL mode. */ - mhl_drive_hpd(HPD_DOWN); - /* - * Change TMDS termination to high impedance - * on disconnection. - */ - mhl_i2c_reg_write(TX_PAGE_3, 0x0030, 0xD0); - msleep(50); - mhl_i2c_reg_modify(TX_PAGE_3, 0x0010, - BIT1 | BIT0, 0x00); - mhl_i2c_reg_modify(TX_PAGE_3, 0x003D, BIT0, 0x00); - spin_lock_irqsave(&mhl_state_lock, flags); - mhl_msm_state->cur_state = POWER_STATE_D3; - spin_unlock_irqrestore(&mhl_state_lock, flags); - } - break; - default: - break; - } -} - -static void mhl_drive_hpd(uint8_t to_state) -{ - if (mhl_msm_state->cur_state != POWER_STATE_D0_MHL) { - pr_err("MHL: invalid state to ctrl HPD\n"); - return; - } - - pr_debug("%s: To state=[0x%x]\n", __func__, to_state); - if (to_state == HPD_UP) { - /* - * Drive HPD to UP state - * - * The below two reg configs combined - * enable TMDS output. - */ - - /* Enable TMDS on TMDS_CCTRL */ - mhl_i2c_reg_modify(TX_PAGE_L0, 0x0080, BIT4, BIT4); - - /* - * Set HPD_OUT_OVR_EN = HPD State - * EDID read and Un-force HPD (from low) - * propogate to src let HPD float by clearing - * HPD OUT OVRRD EN - */ - mhl_i2c_reg_modify(TX_PAGE_3, 0x0020, BIT4, 0x00); - } else { - /* - * Drive HPD to DOWN state - * Disable TMDS Output on REG_TMDS_CCTRL - * Enable/Disable TMDS output (MHL TMDS output only) - */ - mhl_i2c_reg_modify(TX_PAGE_3, 0x20, BIT4 | BIT5, BIT4); - mhl_i2c_reg_modify(TX_PAGE_L0, 0x0080, BIT4, 0x00); - } - return; -} - -static void mhl_msm_connection(void) -{ - uint8_t val; - unsigned long flags; - - pr_debug("%s: cur state = [0x%x]\n", __func__, - mhl_msm_state->cur_state); - - if (mhl_msm_state->cur_state == POWER_STATE_D0_MHL) { - /* Already in D0 - MHL power state */ - return; - } - spin_lock_irqsave(&mhl_state_lock, flags); - mhl_msm_state->cur_state = POWER_STATE_D0_MHL; - spin_unlock_irqrestore(&mhl_state_lock, flags); - - mhl_i2c_reg_write(TX_PAGE_3, 0x30, 0x10); - - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x07, 0xF2); - - /* - * Keep the discovery enabled. Need RGND interrupt - * Possibly chip disables discovery after MHL_EST?? - * Need to re-enable here - */ - val = mhl_i2c_reg_read(TX_PAGE_3, 0x10); - mhl_i2c_reg_write(TX_PAGE_3, 0x10, val | BIT0); - - return; -} - -static void mhl_msm_disconnection(void) -{ - /* - * MHL TX CTL1 - * Disabling Tx termination - */ - mhl_i2c_reg_write(TX_PAGE_3, 0x30, 0xD0); - /* Change HPD line to drive it low */ - mhl_drive_hpd(HPD_DOWN); - /* switch power state to D3 */ - switch_mode(POWER_STATE_D3); - return; -} - -/* - * If hardware detected a change in impedance and raised an INTR - * We check the range of this impedance to infer if the connected - * device is MHL or USB and take appropriate actions. - */ -static int mhl_msm_read_rgnd_int(void) -{ - uint8_t rgnd_imp; - - /* - * DISC STATUS REG 2 - * 1:0 RGND - * 00 - open (USB) - * 01 - 2 kOHM (USB) - * 10 - 1 kOHM ***(MHL)**** It's range 800 - 1200 OHM from MHL spec - * 11 - short (USB) - */ - rgnd_imp = (mhl_i2c_reg_read(TX_PAGE_3, 0x001C) & (BIT1 | BIT0)); - pr_debug("Imp Range read = %02X\n", (int)rgnd_imp); - - if (0x02 == rgnd_imp) { - pr_debug("MHL: MHL DEVICE!!!\n"); - mhl_i2c_reg_modify(TX_PAGE_3, 0x0018, BIT0, BIT0); - mhl_msm_state->mhl_mode = TRUE; - if (notify_usb_online) - notify_usb_online(1); - } else { - pr_debug("MHL: NON-MHL DEVICE!!!\n"); - mhl_msm_state->mhl_mode = FALSE; - mhl_i2c_reg_modify(TX_PAGE_3, 0x0018, BIT3, BIT3); - switch_mode(POWER_STATE_D3); - } - complete(&mhl_msm_state->rgnd_done); - return mhl_msm_state->mhl_mode ? - MHL_DISCOVERY_RESULT_MHL : MHL_DISCOVERY_RESULT_USB; -} - -static void force_usb_switch_open(void) -{ - /*DISABLE_DISCOVERY*/ - mhl_i2c_reg_modify(TX_PAGE_3, 0x0010, BIT0, 0); - /* Force USB ID switch to open*/ - mhl_i2c_reg_modify(TX_PAGE_3, 0x0015, BIT6, BIT6); - mhl_i2c_reg_write(TX_PAGE_3, 0x0012, 0x86); - /* Force HPD to 0 when not in Mobile HD mode. */ - mhl_i2c_reg_modify(TX_PAGE_3, 0x0020, BIT5 | BIT4, BIT4); -} - -static void release_usb_switch_open(void) -{ - msleep(50); - mhl_i2c_reg_modify(TX_PAGE_3, 0x0015, BIT6, 0x00); - mhl_i2c_reg_modify(TX_PAGE_3, 0x0010, BIT0, BIT0); -} - -static void int_4_isr(void) -{ - uint8_t status, reg ; - - /* INTR_STATUS4 */ - status = mhl_i2c_reg_read(TX_PAGE_3, 0x0021); - - /* - * When I2C is inoperational (D3) and - * a previous interrupt brought us here, - * do nothing. - */ - if ((0x00 == status) && (mhl_msm_state->cur_state == POWER_STATE_D3)) { - pr_debug("MHL: spurious interrupt\n"); - return; - } - if (0xFF != status) { - if ((status & BIT0) && (mhl_msm_state->chip_rev_id < 1)) { - uint8_t tmds_cstat; - uint8_t mhl_fifo_status; - - /* TMDS CSTAT */ - tmds_cstat = mhl_i2c_reg_read(TX_PAGE_3, 0x0040); - - pr_debug("TMDS CSTAT: 0x%02x\n", tmds_cstat); - - if (tmds_cstat & 0x02) { - mhl_fifo_status = mhl_i2c_reg_read(TX_PAGE_3, - 0x0023); - pr_debug("MHL FIFO status: 0x%02x\n", - mhl_fifo_status); - if (mhl_fifo_status & 0x0C) { - mhl_i2c_reg_write(TX_PAGE_3, 0x0023, - 0x0C); - - pr_debug("Apply MHL FIFO Reset\n"); - mhl_i2c_reg_write(TX_PAGE_3, 0x0000, - 0x94); - mhl_i2c_reg_write(TX_PAGE_3, 0x0000, - 0x84); - } - } - } - - if (status & BIT1) - pr_debug("MHL: INT4 BIT1 is set\n"); - - /* MHL_EST interrupt */ - if (status & BIT2) { - pr_debug("mhl_msm_connection() from ISR\n"); - mhl_connect_api(true); - mhl_msm_connection(); - pr_debug("MHL Connect Drv: INT4 Status = %02X\n", - (int) status); - } else if (status & BIT3) { - pr_debug("MHL: uUSB-A type device detected.\n"); - mhl_i2c_reg_write(TX_PAGE_3, 0x001C, 0x80); - switch_mode(POWER_STATE_D3); - } - - if (status & BIT5) { - mhl_connect_api(false); - /* Clear interrupts - REG INTR4 */ - reg = mhl_i2c_reg_read(TX_PAGE_3, 0x0021); - mhl_i2c_reg_write(TX_PAGE_3, 0x0021, reg); - mhl_msm_disconnection(); - if (notify_usb_online) - notify_usb_online(0); - pr_debug("MHL Disconnect Drv: INT4 Status = %02X\n", - (int)status); - } - - if ((mhl_msm_state->cur_state != POWER_STATE_D0_MHL) &&\ - (status & BIT6)) { - /* RGND READY Intr */ - switch_mode(POWER_STATE_D0_MHL); - mhl_msm_read_rgnd_int(); - } - - /* Can't succeed at these in D3 */ - if (mhl_msm_state->cur_state != POWER_STATE_D3) { - /* CBUS Lockout interrupt? */ - /* - * Hardware detection mechanism figures that - * CBUS line is latched and raises this intr - * where we force usb switch open and release - */ - if (status & BIT4) { - force_usb_switch_open(); - release_usb_switch_open(); - } - } - } - pr_debug("MHL END Drv: INT4 Status = %02X\n", (int) status); - mhl_i2c_reg_write(TX_PAGE_3, 0x0021, status); - - return; -} - -static void int_5_isr(void) -{ - uint8_t intr_5_stat; - - /* - * Clear INT 5 - * INTR5 is related to FIFO underflow/overflow reset - * which is handled in 8334 by auto FIFO reset - */ - intr_5_stat = mhl_i2c_reg_read(TX_PAGE_3, 0x0023); - mhl_i2c_reg_write(TX_PAGE_3, 0x0023, intr_5_stat); -} - - -static void int_1_isr(void) -{ - /* This ISR mainly handles the HPD status changes */ - uint8_t intr_1_stat; - uint8_t cbus_stat; - - /* INTR STATUS 1 */ - intr_1_stat = mhl_i2c_reg_read(TX_PAGE_L0, 0x0071); - - if (intr_1_stat) { - /* Clear interrupts */ - mhl_i2c_reg_write(TX_PAGE_L0, 0x0071, intr_1_stat); - if (BIT6 & intr_1_stat) { - /* - * HPD status change event is pending - * Read CBUS HPD status for this info - */ - - /* MSC REQ ABRT REASON */ - cbus_stat = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0D); - if (BIT6 & cbus_stat) - mhl_drive_hpd(HPD_UP); - } - } - return; -} - -static void mhl_cbus_process_errors(u8 int_status) -{ - u8 abort_reason = 0; - if (int_status & BIT2) { - abort_reason = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0B); - pr_debug("%s: CBUS DDC Abort Reason(0x%02x)\n", - __func__, abort_reason); - } - if (int_status & BIT5) { - abort_reason = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0D); - pr_debug("%s: CBUS MSC Requestor Abort Reason(0x%02x)\n", - __func__, abort_reason); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0D, 0xFF); - } - if (int_status & BIT6) { - abort_reason = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0E); - pr_debug("%s: CBUS MSC Responder Abort Reason(0x%02x)\n", - __func__, abort_reason); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0E, 0xFF); - } -} - -static int mhl_msc_command_done(struct msc_command_struct *req) -{ - switch (req->command) { - case MHL_WRITE_STAT: - if (req->offset == MHL_STATUS_REG_LINK_MODE) { - if (req->payload.data[0] - & MHL_STATUS_PATH_ENABLED) { - /* Enable TMDS output */ - mhl_i2c_reg_modify(TX_PAGE_L0, 0x0080, - BIT4, BIT4); - } else - /* Disable TMDS output */ - mhl_i2c_reg_modify(TX_PAGE_L0, 0x0080, - BIT4, BIT4); - } - break; - case MHL_READ_DEVCAP: - mhl_msm_state->devcap_state |= BIT(req->offset); - switch (req->offset) { - case MHL_DEV_CATEGORY_OFFSET: - if (req->retval & MHL_DEV_CATEGORY_POW_BIT) { - /* - * Enable charging - */ - } else { - /* - * Disable charging - */ - } - break; - case DEVCAP_OFFSET_MHL_VERSION: - case DEVCAP_OFFSET_INT_STAT_SIZE: - break; - } - - break; - } - return 0; -} - -static int mhl_send_msc_command(struct msc_command_struct *req) -{ - int timeout; - u8 start_bit = 0x00; - u8 *burst_data; - int i; - - if (mhl_msm_state->cur_state != POWER_STATE_D0_MHL) { - pr_debug("%s: power_state:%02x CBUS(0x0A):%02x\n", - __func__, - mhl_msm_state->cur_state, mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0A)); - return -EFAULT; - } - - if (!req) - return -EFAULT; - - pr_debug("%s: command=0x%02x offset=0x%02x %02x %02x", - __func__, - req->command, - req->offset, - req->payload.data[0], - req->payload.data[1]); - - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x13, req->offset); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x14, req->payload.data[0]); - - switch (req->command) { - case MHL_SET_INT: - case MHL_WRITE_STAT: - start_bit = MSC_START_BIT_WRITE_REG; - break; - case MHL_READ_DEVCAP: - start_bit = MSC_START_BIT_READ_REG; - break; - case MHL_GET_STATE: - case MHL_GET_VENDOR_ID: - case MHL_SET_HPD: - case MHL_CLR_HPD: - case MHL_GET_SC1_ERRORCODE: - case MHL_GET_DDC_ERRORCODE: - case MHL_GET_MSC_ERRORCODE: - case MHL_GET_SC3_ERRORCODE: - start_bit = MSC_START_BIT_MSC_CMD; - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x13, req->command); - break; - case MHL_MSC_MSG: - start_bit = MSC_START_BIT_VS_CMD; - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x15, req->payload.data[1]); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x13, req->command); - break; - case MHL_WRITE_BURST: - start_bit = MSC_START_BIT_WRITE_BURST; - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x20, req->length - 1); - if (!(req->payload.burst_data)) { - pr_err("%s: burst data is null!\n", __func__); - goto cbus_send_fail; - } - burst_data = req->payload.burst_data; - for (i = 0; i < req->length; i++, burst_data++) - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xC0 + i, *burst_data); - break; - default: - pr_err("%s: unknown command! (%02x)\n", - __func__, req->command); - goto cbus_send_fail; - } - - INIT_COMPLETION(mhl_msm_state->msc_cmd_done); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x12, start_bit); - timeout = wait_for_completion_interruptible_timeout - (&mhl_msm_state->msc_cmd_done, HZ); - if (!timeout) { - pr_err("%s: cbus_command_send timed out!\n", __func__); - goto cbus_send_fail; - } - - switch (req->command) { - case MHL_READ_DEVCAP: - /* devcap */ - req->retval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x16); - pr_debug("Read CBUS[0x16]=[%02x]\n", req->retval); - break; - case MHL_MSC_MSG: - /* check if MSC_MSG NACKed */ - if (mhl_i2c_reg_read(TX_PAGE_CBUS, 0x20) & BIT6) - return -EAGAIN; - default: - req->retval = 0; - break; - } - mhl_msc_command_done(req); - pr_debug("%s: msc cmd done\n", __func__); - return 0; - -cbus_send_fail: - return -EFAULT; -} - -static int mhl_msc_send_set_int(u8 offset, u8 mask) -{ - struct msc_command_struct req; - req.command = MHL_SET_INT; - req.offset = offset; - req.payload.data[0] = mask; - mhl_msc_sched_work(&req); - return 0; -} - -static int mhl_msc_send_write_stat(u8 offset, u8 value) -{ - struct msc_command_struct req; - req.command = MHL_WRITE_STAT; - req.offset = offset; - req.payload.data[0] = value; - mhl_msc_sched_work(&req); - return 0; -} - -static int mhl_msc_send_msc_msg(u8 sub_cmd, u8 cmd_data) -{ - struct msc_command_struct req; - req.command = MHL_MSC_MSG; - req.payload.data[0] = sub_cmd; - req.payload.data[1] = cmd_data; - mhl_msc_sched_work(&req); - return 0; -} - -static int mhl_msc_read_devcap(u8 offset) -{ - struct msc_command_struct req; - if (offset < 0 || offset > 15) - return -EFAULT; - req.command = MHL_READ_DEVCAP; - req.offset = offset; - req.payload.data[0] = 0; - mhl_msc_sched_work(&req); - return 0; -} - -static int mhl_msc_read_devcap_all(void) -{ - int offset; - int ret; - - for (offset = 0; offset < DEVCAP_SIZE; offset++) { - ret = mhl_msc_read_devcap(offset); - msleep(200); - if (ret == -EFAULT) { - pr_err("%s: queue busy!\n", __func__); - return -EBUSY; - } - } - - return 0; -} - -/* supported RCP key code */ -static const u8 rcp_key_code_tbl[] = { - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00~0x07 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08~0x0f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10~0x17 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x18~0x1f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20~0x27 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28~0x2f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30~0x37 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x38~0x3f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40~0x47 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48~0x4f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50~0x57 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x58~0x5f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60~0x67 */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68~0x6f */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70~0x77 */ - 0, 0, 0, 0, 0, 0, 0, 0 /* 0x78~0x7f */ -}; - -static int mhl_rcp_recv(u8 key_code) -{ - int rc; - if (rcp_key_code_tbl[(key_code & 0x7f)]) { - /* - * TODO: Take action for the RCP cmd - */ - - /* send ack to rcp cmd*/ - rc = mhl_msc_send_msc_msg( - MHL_MSC_MSG_RCPK, - key_code); - } else { - /* send rcp error */ - rc = mhl_msc_send_msc_msg( - MHL_MSC_MSG_RCPE, - MHL_RCPE_UNSUPPORTED_KEY_CODE); - if (rc) - return rc; - /* send rcpk after rcpe send */ - rc = mhl_msc_send_msc_msg( - MHL_MSC_MSG_RCPK, - key_code); - } - return rc; -} - -static int mhl_rap_action(u8 action_code) -{ - switch (action_code) { - case MHL_RAP_CONTENT_ON: - /* - * Enable TMDS on TMDS_CCTRL - */ - mhl_i2c_reg_modify(TX_PAGE_L0, 0x0080, BIT4, BIT4); - break; - case MHL_RAP_CONTENT_OFF: - /* - * Disable TMDS on TMDS_CCTRL - */ - mhl_i2c_reg_modify(TX_PAGE_L0, 0x0080, BIT4, 0x00); - break; - default: - break; - } - return 0; -} - -static int mhl_rap_recv(u8 action_code) -{ - u8 error_code; - - switch (action_code) { - /*case MHL_RAP_POLL:*/ - case MHL_RAP_CONTENT_ON: - case MHL_RAP_CONTENT_OFF: - mhl_rap_action(action_code); - error_code = MHL_RAPK_NO_ERROR; - /* notify userspace */ - break; - default: - error_code = MHL_RAPK_UNRECOGNIZED_ACTION_CODE; - break; - } - /* prior send rapk */ - return mhl_msc_send_msc_msg( - MHL_MSC_MSG_RAPK, - error_code); -} - -static int mhl_msc_recv_msc_msg(u8 sub_cmd, u8 cmd_data) -{ - int rc = 0; - switch (sub_cmd) { - case MHL_MSC_MSG_RCP: - pr_debug("MHL: receive RCP(0x%02x)\n", cmd_data); - rc = mhl_rcp_recv(cmd_data); - break; - case MHL_MSC_MSG_RCPK: - pr_debug("MHL: receive RCPK(0x%02x)\n", cmd_data); - break; - case MHL_MSC_MSG_RCPE: - pr_debug("MHL: receive RCPE(0x%02x)\n", cmd_data); - break; - case MHL_MSC_MSG_RAP: - pr_debug("MHL: receive RAP(0x%02x)\n", cmd_data); - rc = mhl_rap_recv(cmd_data); - break; - case MHL_MSC_MSG_RAPK: - pr_debug("MHL: receive RAPK(0x%02x)\n", cmd_data); - break; - default: - break; - } - return rc; -} - -static int mhl_msc_recv_set_int(u8 offset, u8 set_int) -{ - if (offset >= 2) - return -EFAULT; - - switch (offset) { - case 0: - /* DCAP_CHG */ - if (set_int & MHL_INT_DCAP_CHG) { - /* peer dcap has changed */ - if (mhl_msc_read_devcap_all() == -EBUSY) { - pr_err("READ DEVCAP FAILED to send successfully\n"); - break; - } - } - /* DSCR_CHG */ - if (set_int & MHL_INT_DSCR_CHG) - ; - /* REQ_WRT */ - if (set_int & MHL_INT_REQ_WRT) { - /* SET_INT: GRT_WRT */ - mhl_msc_send_set_int( - MHL_RCHANGE_INT, - MHL_INT_GRT_WRT); - } - /* GRT_WRT */ - if (set_int & MHL_INT_GRT_WRT) - ; - break; - case 1: - /* EDID_CHG */ - if (set_int & MHL_INT_EDID_CHG) { - /* peer EDID has changed. - * toggle HPD to read EDID again - * In 8x30 FLUID HDMI HPD line - * is not connected - * with MHL 8334 transmitter - */ - } - } - return 0; -} - -static int mhl_msc_recv_write_stat(u8 offset, u8 value) -{ - if (offset >= 2) - return -EFAULT; - - switch (offset) { - case 0: - /* DCAP_RDY */ - /* - * Connected Device bits changed and DEVCAP READY - */ - pr_debug("MHL: value [0x%02x]\n", value); - pr_debug("MHL: offset [0x%02x]\n", offset); - pr_debug("MHL: devcap state [0x%02x]\n", - mhl_msm_state->devcap_state); - pr_debug("MHL: MHL_STATUS_DCAP_RDY [0x%02x]\n", - MHL_STATUS_DCAP_RDY); - if (((value ^ mhl_msm_state->devcap_state) & - MHL_STATUS_DCAP_RDY)) { - if (value & MHL_STATUS_DCAP_RDY) { - if (mhl_msc_read_devcap_all() == -EBUSY) { - pr_err("READ DEVCAP FAILED to send successfully\n"); - break; - } - } else { - /* peer dcap turned not ready */ - /* - * Clear DEVCAP READY state - */ - } - } - break; - case 1: - /* PATH_EN */ - /* - * Connected Device bits changed and PATH ENABLED - */ - if ((value ^ mhl_msm_state->path_en_state) - & MHL_STATUS_PATH_ENABLED) { - if (value & MHL_STATUS_PATH_ENABLED) { - mhl_msm_state->path_en_state - |= (MHL_STATUS_PATH_ENABLED | - MHL_STATUS_CLK_MODE_NORMAL); - mhl_msc_send_write_stat( - MHL_STATUS_REG_LINK_MODE, - mhl_msm_state->path_en_state); - } else { - mhl_msm_state->path_en_state - &= ~(MHL_STATUS_PATH_ENABLED | - MHL_STATUS_CLK_MODE_NORMAL); - mhl_msc_send_write_stat( - MHL_STATUS_REG_LINK_MODE, - mhl_msm_state->path_en_state); - } - } - break; - } - mhl_msm_state->path_en_state = value; - return 0; -} - - -/* MSC, RCP, RAP messages - mandatory for compliance */ -static void mhl_cbus_isr(void) -{ - uint8_t regval; - int req_done = FALSE; - uint8_t sub_cmd = 0x0; - uint8_t cmd_data = 0x0; - int msc_msg_recved = FALSE; - int rc = -1; - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x08); - if (regval == 0xff) - return; - - /* - * clear all interrupts that were raised - * even if we did not process - */ - if (regval) - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x08, regval); - - pr_debug("%s: CBUS_INT = %02x\n", __func__, regval); - - /* MSC_MSG (RCP/RAP) */ - if (regval & BIT3) { - sub_cmd = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x18); - cmd_data = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x19); - msc_msg_recved = TRUE; - } - /* MSC_MT_ABRT/MSC_MR_ABRT/DDC_ABORT */ - if (regval & (BIT6 | BIT5 | BIT2)) - mhl_cbus_process_errors(regval); - - /* MSC_REQ_DONE */ - if (regval & BIT4) - req_done = TRUE; - - /* Now look for interrupts on CBUS_MSC_INT2 */ - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x1E); - - /* clear all interrupts that were raised */ - /* even if we did not process */ - if (regval) - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x1E, regval); - - pr_debug("%s: CBUS_MSC_INT2 = %02x\n", __func__, regval); - - /* received SET_INT */ - if (regval & BIT2) { - uint8_t intr; - intr = mhl_i2c_reg_read(TX_PAGE_CBUS, 0xA0); - mhl_msc_recv_set_int(0, intr); - - pr_debug("%s: MHL_INT_0 = %02x\n", __func__, intr); - intr = mhl_i2c_reg_read(TX_PAGE_CBUS, 0xA1); - mhl_msc_recv_set_int(1, intr); - - pr_debug("%s: MHL_INT_1 = %02x\n", __func__, intr); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xA0, 0xFF); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xA1, 0xFF); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xA2, 0xFF); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xA3, 0xFF); - } - - /* received WRITE_STAT */ - if (regval & BIT3) { - uint8_t stat; - stat = mhl_i2c_reg_read(TX_PAGE_CBUS, 0xB0); - mhl_msc_recv_write_stat(0, stat); - - pr_debug("%s: MHL_STATUS_0 = %02x\n", __func__, stat); - stat = mhl_i2c_reg_read(TX_PAGE_CBUS, 0xB1); - mhl_msc_recv_write_stat(1, stat); - pr_debug("%s: MHL_STATUS_1 = %02x\n", __func__, stat); - - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xB0, 0xFF); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xB1, 0xFF); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xB2, 0xFF); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0xB3, 0xFF); - } - - /* received MSC_MSG */ - if (msc_msg_recved) { - /*mhl msc recv msc msg*/ - rc = mhl_msc_recv_msc_msg(sub_cmd, cmd_data); - if (rc) - pr_err("MHL: mhl msc recv msc msg failed(%d)!\n", rc); - } - /* complete last command */ - if (req_done) - complete_all(&mhl_msm_state->msc_cmd_done); - - return; -} - -static void clear_all_intrs(void) -{ - uint8_t regval = 0x00; - /* - * intr status debug - */ - pr_debug("********* EXITING ISR MASK CHECK ?? *************\n"); - pr_debug("Drv: INT1 MASK = %02X\n", - (int) mhl_i2c_reg_read(TX_PAGE_L0, 0x0071)); - pr_debug("Drv: INT3 MASK = %02X\n", - (int) mhl_i2c_reg_read(TX_PAGE_L0, 0x0077)); - pr_debug("Drv: INT4 MASK = %02X\n", - (int) mhl_i2c_reg_read(TX_PAGE_3, 0x0021)); - pr_debug("Drv: INT5 MASK = %02X\n", - (int) mhl_i2c_reg_read(TX_PAGE_3, 0x0023)); - pr_debug("Drv: CBUS1 MASK = %02X\n", - (int) mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0009)); - pr_debug("Drv: CBUS2 MASK = %02X\n", - (int) mhl_i2c_reg_read(TX_PAGE_CBUS, 0x001F)); - pr_debug("********* END OF ISR MASK CHECK *************\n"); - - pr_debug("********* EXITING IN ISR ?? *************\n"); - regval = mhl_i2c_reg_read(TX_PAGE_L0, 0x0071); - pr_debug("Drv: INT1 Status = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_L0, 0x0071, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_L0, 0x0072); - pr_debug("Drv: INT2 Status = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_L0, 0x0072, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_L0, 0x0073); - pr_debug("Drv: INT3 Status = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_L0, 0x0073, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_3, 0x0021); - pr_debug("Drv: INT4 Status = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_3, 0x0021, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_3, 0x0023); - pr_debug("Drv: INT5 Status = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_3, 0x0023, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x0008); - pr_debug("Drv: cbusInt Status = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x0008, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x001E); - pr_debug("Drv: CBUS INTR_2: %d\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x001E, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00A0); - pr_debug("Drv: A0 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00A0, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00A1); - pr_debug("Drv: A1 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00A1, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00A2); - pr_debug("Drv: A2 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00A2, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00A3); - pr_debug("Drv: A3 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00A3, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00B0); - pr_debug("Drv: B0 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00B0, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00B1); - pr_debug("Drv: B1 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00B1, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00B2); - pr_debug("Drv: B2 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00B2, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00B3); - pr_debug("Drv: B3 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00B3, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00E0); - pr_debug("Drv: E0 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00E0, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00E1); - pr_debug("Drv: E1 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00E1, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00E2); - pr_debug("Drv: E2 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00E2, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00E3); - pr_debug("Drv: E3 STATUS Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00E3, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00F0); - pr_debug("Drv: F0 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00F0, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00F1); - pr_debug("Drv: F1 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00F1, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00F2); - pr_debug("Drv: F2 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00F2, regval); - - regval = mhl_i2c_reg_read(TX_PAGE_CBUS, 0x00F3); - pr_debug("Drv: F3 INT Set = %02X\n", (int)regval); - mhl_i2c_reg_write(TX_PAGE_CBUS, 0x00F3, regval); - pr_debug("********* END OF EXITING IN ISR *************\n"); -} - -static irqreturn_t mhl_tx_isr(int irq, void *dev_id) -{ - /* - * Check RGND, MHL_EST, CBUS_LOCKOUT, SCDT - * interrupts. In D3, we get only RGND - */ - int_4_isr(); - - pr_debug("MHL: Current POWER state is [0x%x]\n", - mhl_msm_state->cur_state); - if (mhl_msm_state->cur_state == POWER_STATE_D0_MHL) { - /* - * If int_4_isr() didn't move the tx to D3 - * on disconnect, continue to check other - * interrupt sources. - */ - int_5_isr(); - - /* - * Check for any peer messages for DCAP_CHG etc - * Dispatch to have the CBUS module working only - * once connected. - */ - mhl_cbus_isr(); - int_1_isr(); - } - clear_all_intrs(); - return IRQ_HANDLED; -} - -static void __exit mhl_msm_exit(void) -{ - pr_warn("MHL: Exiting, Bye\n"); - /* - * Delete driver if i2c client structure is NULL - */ - i2c_del_driver(&mhl_sii_i2c_driver); - if (!mhl_msm_state) { - kfree(mhl_msm_state); - mhl_msm_state = NULL; - } -} - -module_init(mhl_msm_init); -module_exit(mhl_msm_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("MHL SII 8334 TX driver"); diff --git a/drivers/video/msm/mhl/mhl_i2c_utils.c b/drivers/video/msm/mhl/mhl_i2c_utils.c deleted file mode 100644 index d3eec749d06eac2e12f1194a06bbd4cd57b425e6..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mhl/mhl_i2c_utils.c +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (c) 2012, 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 -#include - -#include "mhl_i2c_utils.h" - -uint8_t slave_addrs[MAX_PAGES] = { - DEV_PAGE_TPI_0 , - DEV_PAGE_TX_L0_0 , - DEV_PAGE_TX_L1_0 , - DEV_PAGE_TX_2_0 , - DEV_PAGE_TX_3_0 , - DEV_PAGE_CBUS , - DEV_PAGE_DDC_EDID , - DEV_PAGE_DDC_SEGM , -}; - -int mhl_i2c_reg_read(uint8_t slave_addr_index, uint8_t reg_offset) -{ - struct i2c_msg msgs[2]; - uint8_t buffer = 0; - int ret = -1; - - pr_debug("MRR: Reading from slave_addr_index=[%x] and offset=[%x]\n", - slave_addr_index, reg_offset); - pr_debug("MRR: Addr slave_addr_index=[%x]\n", - slave_addrs[slave_addr_index]); - - /* Slave addr */ - msgs[0].addr = slave_addrs[slave_addr_index] >> 1; - msgs[1].addr = slave_addrs[slave_addr_index] >> 1; - - /* Write Command */ - msgs[0].flags = 0; - msgs[1].flags = I2C_M_RD; - - /* Register offset for the next transaction */ - msgs[0].buf = ®_offset; - msgs[1].buf = &buffer; - - /* Offset is 1 Byte long */ - msgs[0].len = 1; - msgs[1].len = 1; - - ret = i2c_transfer(mhl_msm_state->i2c_client->adapter, msgs, 2); - if (ret < 1) { - pr_err("I2C READ FAILED=[%d]\n", ret); - return -EACCES; - } - pr_debug("Buffer is [%x]\n", buffer); - return buffer; -} - - -int mhl_i2c_reg_write(uint8_t slave_addr_index, uint8_t reg_offset, - uint8_t value) -{ - return mhl_i2c_reg_write_cmds(slave_addr_index, reg_offset, &value, 1); -} - -int mhl_i2c_reg_write_cmds(uint8_t slave_addr_index, uint8_t reg_offset, - uint8_t *value, uint16_t count) -{ - struct i2c_msg msgs[1]; - uint8_t data[2]; - int status = -EACCES; - - msgs[0].addr = slave_addrs[slave_addr_index] >> 1; - msgs[0].flags = 0; - msgs[0].len = 2; - msgs[0].buf = data; - data[0] = reg_offset; - data[1] = *value; - - status = i2c_transfer(mhl_msm_state->i2c_client->adapter, msgs, 1); - if (status < 1) { - pr_err("I2C WRITE FAILED=[%d]\n", status); - return -EACCES; - } - - return status; -} - -void mhl_i2c_reg_modify(uint8_t slave_addr_index, uint8_t reg_offset, - uint8_t mask, uint8_t val) -{ - uint8_t temp; - - temp = mhl_i2c_reg_read(slave_addr_index, reg_offset); - temp &= (~mask); - temp |= (mask & val); - mhl_i2c_reg_write(slave_addr_index, reg_offset, temp); -} - diff --git a/drivers/video/msm/mhl/mhl_i2c_utils.h b/drivers/video/msm/mhl/mhl_i2c_utils.h deleted file mode 100644 index 9e4a4fa2ba67f28d703b64a0f44f8c88fa7f7bad..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mhl/mhl_i2c_utils.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2012, 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 __MHL_I2C_UTILS_H__ -#define __MHL_I2C_UTILS_H__ - -#include -#include -#include - -/* - * I2C command to the adapter to append - * the buffer from next msg to this one. - */ -#define I2C_M_APPND_NXT_WR 0x0002 - -extern uint8_t slave_addrs[MAX_PAGES]; -extern struct mhl_msm_state_t *mhl_msm_state; - -int mhl_i2c_reg_read(uint8_t slave_addr_index, uint8_t reg_offset); -int mhl_i2c_reg_write(uint8_t slave_addr_index, uint8_t reg_offset, - uint8_t value); -int mhl_i2c_reg_write_cmds(uint8_t slave_addr_index, uint8_t reg_offset, - uint8_t *value, uint16_t count); -void mhl_i2c_reg_modify(uint8_t slave_addr_index, uint8_t reg_offset, - uint8_t mask, uint8_t val); - -#endif /* __MHL_I2C_UTILS_H__ */ diff --git a/drivers/video/msm/mhl_api.h b/drivers/video/msm/mhl_api.h deleted file mode 100644 index 691771a7d8b8bb9d688f94b593d827ea188a07b3..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mhl_api.h +++ /dev/null @@ -1,26 +0,0 @@ - -/* Copyright (c) 2011, 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 __MHL_API_H__ -#define __MHL_API_H__ - -#ifdef CONFIG_FB_MSM_HDMI_MHL_8334 -bool mhl_is_enabled(void); -#else -static bool mhl_is_enabled(void) -{ - return false; -} -#endif - -#endif /* __MHL_API_H__ */ diff --git a/drivers/video/msm/mipi_NT35510.c b/drivers/video/msm/mipi_NT35510.c deleted file mode 100644 index ab15feeed612ba46ef6491ea65245da5e40738c4..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_NT35510.c +++ /dev/null @@ -1,740 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_NT35510.h" - -static struct msm_panel_common_pdata *mipi_nt35510_pdata; -static struct dsi_buf nt35510_tx_buf; -static struct dsi_buf nt35510_rx_buf; - -static int mipi_nt35510_bl_ctrl; - -#define NT35510_SLEEP_OFF_DELAY 150 -#define NT35510_DISPLAY_ON_DELAY 150 - -/* common setting */ -static char exit_sleep[2] = {0x11, 0x00}; -static char display_on[2] = {0x29, 0x00}; -static char display_off[2] = {0x28, 0x00}; -static char enter_sleep[2] = {0x10, 0x00}; -static char write_ram[2] = {0x2c, 0x00}; /* write ram */ - -static struct dsi_cmd_desc nt35510_display_off_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 50, sizeof(display_off), display_off}, - {DTYPE_DCS_WRITE, 1, 0, 0, 50, sizeof(enter_sleep), enter_sleep} -}; - -static char cmd0[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x01, -}; -static char cmd1[4] = { - 0xBC, 0x00, 0xA0, 0x00, -}; -static char cmd2[4] = { - 0xBD, 0x00, 0xA0, 0x00, -}; -static char cmd3[3] = { - 0xBE, 0x00, 0x79, -}; -static char cmd4[53] = { - 0xD1, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char cmd5[53] = { - 0xD2, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char cmd6[53] = { - 0xD3, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char cmd7[53] = { - 0xD4, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char cmd8[53] = { - 0xD5, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char cmd9[53] = { - 0xD6, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char cmd10[4] = { - 0xB0, 0x0A, 0x0A, 0x0A, -}; -static char cmd11[4] = { - 0xB1, 0x0A, 0x0A, 0x0A, -}; -static char cmd12[4] = { - 0xBA, 0x24, 0x24, 0x24, -}; -static char cmd13[4] = { - 0xB9, 0x24, 0x24, 0x24, -}; -static char cmd14[4] = { - 0xB8, 0x24, 0x24, 0x24, -}; -static char cmd15[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x00, -}; -static char cmd16[2] = { - 0xB3, 0x00, -}; -static char cmd17[2] = { - 0xB4, 0x10, -}; -static char cmd18[2] = { - 0xB6, 0x02, -}; -static char cmd19[3] = { - 0xB1, 0xEC, 0x00, -}; -static char cmd19_rotate[3] = { - 0xB1, 0xEC, 0x06, -}; -static char cmd20[4] = { - 0xBC, 0x05, 0x05, 0x05, -}; -static char cmd21[3] = { - 0xB7, 0x20, 0x20, -}; -static char cmd22[5] = { - 0xB8, 0x01, 0x03, 0x03, - 0x03, -}; -static char cmd23[19] = { - 0xC8, 0x01, 0x00, 0x78, - 0x50, 0x78, 0x50, 0x78, - 0x50, 0x78, 0x50, 0xC8, - 0x3C, 0x3C, 0xC8, 0xC8, - 0x3C, 0x3C, 0xC8, -}; -static char cmd24[6] = { - 0xBD, 0x01, 0x84, 0x07, - 0x31, 0x00, -}; -static char cmd25[6] = { - 0xBE, 0x01, 0x84, 0x07, - 0x31, 0x00, -}; -static char cmd26[6] = { - 0xBF, 0x01, 0x84, 0x07, - 0x31, 0x00, -}; -static char cmd27[2] = { - 0x35, 0x00, -}; -static char config_MADCTL[2] = {0x36, 0x00}; -static struct dsi_cmd_desc nt35510_cmd_display_on_cmds[] = { - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd0), cmd0}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd1), cmd1}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd2), cmd2}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd3), cmd3}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd4), cmd4}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd5), cmd5}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd6), cmd6}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd7), cmd7}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd8), cmd8}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd9), cmd9}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd10), cmd10}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd11), cmd11}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd12), cmd12}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd13), cmd13}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd14), cmd14}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd15), cmd15}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd16), cmd16}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd17), cmd17}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd18), cmd18}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd19), cmd19}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd20), cmd20}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd21), cmd21}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd22), cmd22}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd23), cmd23}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd24), cmd24}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd25), cmd25}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd26), cmd26}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd27), cmd27}, - - {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(display_on), display_on}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, 0, - sizeof(config_MADCTL), config_MADCTL}, - - {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(write_ram), write_ram}, -}; - -static struct dsi_cmd_desc nt35510_cmd_display_on_cmds_rotate[] = { - {DTYPE_DCS_LWRITE, 1, 0, 0, 0, - sizeof(cmd19_rotate), cmd19_rotate}, -}; - -static char video0[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x01, -}; -static char video1[4] = { - 0xBC, 0x00, 0xA0, 0x00, -}; -static char video2[4] = { - 0xBD, 0x00, 0xA0, 0x00, -}; -static char video3[3] = { - 0xBE, 0x00, 0x79, -}; -static char video4[53] = { - 0xD1, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char video5[53] = { - 0xD2, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char video6[53] = { - 0xD3, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char video7[53] = { - 0xD4, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char video8[53] = { - 0xD5, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char video9[53] = { - 0xD6, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x32, 0x00, - 0x4F, 0x00, 0x65, 0x00, - 0x8B, 0x00, 0xA8, 0x00, - 0xD5, 0x00, 0xF7, 0x01, - 0x2B, 0x01, 0x54, 0x01, - 0x8E, 0x01, 0xBB, 0x01, - 0xBC, 0x01, 0xE3, 0x02, - 0x08, 0x02, 0x1C, 0x02, - 0x39, 0x02, 0x4F, 0x02, - 0x76, 0x02, 0xA3, 0x02, - 0xE3, 0x03, 0x12, 0x03, - 0x4C, 0x03, 0x66, 0x03, - 0x9A, -}; -static char video10[4] = { - 0xB0, 0x0A, 0x0A, 0x0A, -}; -static char video11[4] = { - 0xB1, 0x0A, 0x0A, 0x0A, -}; -static char video12[4] = { - 0xBA, 0x24, 0x24, 0x24, -}; -static char video13[4] = { - 0xB9, 0x24, 0x24, 0x24, -}; -static char video14[4] = { - 0xB8, 0x24, 0x24, 0x24, -}; -static char video15[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x00, -}; -static char video16[2] = { - 0xB3, 0x00, -}; -static char video17[2] = { - 0xB4, 0x10, -}; -static char video18[2] = { - 0xB6, 0x02, -}; -static char video19[3] = { - 0xB1, 0xFC, 0x00, -}; -static char video20[4] = { - 0xBC, 0x05, 0x05, 0x05, -}; -static char video21[3] = { - 0xB7, 0x20, 0x20, -}; -static char video22[5] = { - 0xB8, 0x01, 0x03, 0x03, - 0x03, -}; -static char video23[19] = { - 0xC8, 0x01, 0x00, 0x78, - 0x50, 0x78, 0x50, 0x78, - 0x50, 0x78, 0x50, 0xC8, - 0x3C, 0x3C, 0xC8, 0xC8, - 0x3C, 0x3C, 0xC8, -}; -static char video24[6] = { - 0xBD, 0x01, 0x84, 0x07, - 0x31, 0x00, -}; -static char video25[6] = { - 0xBE, 0x01, 0x84, 0x07, - 0x31, 0x00, -}; -static char video26[6] = { - 0xBF, 0x01, 0x84, 0x07, - 0x31, 0x00, -}; -static char video27[2] = { - 0x35, 0x00, -}; -static char config_video_MADCTL[2] = {0x36, 0xC0}; -static struct dsi_cmd_desc nt35510_video_display_on_cmds[] = { - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video0), video0}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video1), video1}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video2), video2}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video3), video3}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video4), video4}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video5), video5}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video6), video6}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video7), video7}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video8), video8}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video9), video9}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video10), video10}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video11), video11}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video12), video12}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video13), video13}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video14), video14}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video15), video15}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video16), video16}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video17), video17}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video18), video18}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video19), video19}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video20), video20}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video21), video21}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video22), video22}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video23), video23}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video24), video24}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video25), video25}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video26), video26}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video27), video27}, - {DTYPE_DCS_WRITE, 1, 0, 0, NT35510_SLEEP_OFF_DELAY, sizeof(exit_sleep), - exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, NT35510_DISPLAY_ON_DELAY, sizeof(display_on), - display_on}, -}; - -static struct dsi_cmd_desc nt35510_video_display_on_cmds_rotate[] = { - {DTYPE_DCS_WRITE1, 1, 0, 0, 0, - sizeof(config_video_MADCTL), config_video_MADCTL}, -}; -static int mipi_nt35510_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - static int rotate; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - mipi = &mfd->panel_info.mipi; - - if (!mfd->cont_splash_done) { - mfd->cont_splash_done = 1; - return 0; - } - - if (mipi_nt35510_pdata && mipi_nt35510_pdata->rotate_panel) - rotate = mipi_nt35510_pdata->rotate_panel(); - - memset(&cmdreq, 0, sizeof(cmdreq)); - if (mipi->mode == DSI_VIDEO_MODE) { - cmdreq.cmds = nt35510_video_display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(nt35510_video_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - if (rotate) { - cmdreq.cmds = nt35510_video_display_on_cmds_rotate; - cmdreq.cmds_cnt = - ARRAY_SIZE(nt35510_video_display_on_cmds_rotate); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } - } else if (mipi->mode == DSI_CMD_MODE) { - cmdreq.cmds = nt35510_cmd_display_on_cmds; - cmdreq.cmds_cnt = - ARRAY_SIZE(nt35510_cmd_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - if (rotate) { - cmdreq.cmds = nt35510_cmd_display_on_cmds_rotate; - cmdreq.cmds_cnt = - ARRAY_SIZE(nt35510_cmd_display_on_cmds_rotate); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } - } - - return 0; -} - -static int mipi_nt35510_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - pr_debug("mipi_nt35510_lcd_off E\n"); - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = nt35510_display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(nt35510_display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - pr_debug("mipi_nt35510_lcd_off X\n"); - return 0; -} - -static ssize_t mipi_nt35510_wta_bl_ctrl(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int err; - - err = kstrtoint(buf, 0, &mipi_nt35510_bl_ctrl); - if (err) - return ret; - - pr_info("%s: bl ctrl set to %d\n", __func__, mipi_nt35510_bl_ctrl); - - return ret; -} - -static DEVICE_ATTR(bl_ctrl, S_IWUSR, NULL, mipi_nt35510_wta_bl_ctrl); - -static struct attribute *mipi_nt35510_fs_attrs[] = { - &dev_attr_bl_ctrl.attr, - NULL, -}; - -static struct attribute_group mipi_nt35510_fs_attr_group = { - .attrs = mipi_nt35510_fs_attrs, -}; - -static int mipi_nt35510_create_sysfs(struct platform_device *pdev) -{ - int rc; - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - - if (!mfd) { - pr_err("%s: mfd not found\n", __func__); - return -ENODEV; - } - if (!mfd->fbi) { - pr_err("%s: mfd->fbi not found\n", __func__); - return -ENODEV; - } - if (!mfd->fbi->dev) { - pr_err("%s: mfd->fbi->dev not found\n", __func__); - return -ENODEV; - } - rc = sysfs_create_group(&mfd->fbi->dev->kobj, - &mipi_nt35510_fs_attr_group); - if (rc) { - pr_err("%s: sysfs group creation failed, rc=%d\n", - __func__, rc); - return rc; - } - - return 0; -} - -static int mipi_nt35510_lcd_probe(struct platform_device *pdev) -{ - struct platform_device *pthisdev = NULL; - struct msm_fb_panel_data *pdata; - pr_debug("%s\n", __func__); - - if (pdev->id == 0) { - mipi_nt35510_pdata = pdev->dev.platform_data; - if (mipi_nt35510_pdata->bl_lock) - spin_lock_init(&mipi_nt35510_pdata->bl_spinlock); - return 0; - } - - pdata = pdev->dev.platform_data; - if (mipi_nt35510_pdata && mipi_nt35510_pdata->rotate_panel() - && pdata->panel_info.type == MIPI_CMD_PANEL) - pdata->panel_info.lcd.refx100 = 6200; - - pthisdev = msm_fb_add_device(pdev); - mipi_nt35510_create_sysfs(pthisdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = mipi_nt35510_lcd_probe, - .driver = { - .name = "mipi_NT35510", - }, -}; - -static int old_bl_level; - -static void mipi_nt35510_set_backlight(struct msm_fb_data_type *mfd) -{ - int bl_level; - unsigned long flags; - bl_level = mfd->bl_level; - - if (mipi_nt35510_pdata->bl_lock) { - if (!mipi_nt35510_bl_ctrl) { - /* Level received is of range 1 to bl_max, - We need to convert the levels to 1 - to 31 */ - bl_level = (2 * bl_level * 31 + mfd->panel_info.bl_max) - /(2 * mfd->panel_info.bl_max); - if (bl_level == old_bl_level) - return; - - if (bl_level == 0) - mipi_nt35510_pdata->backlight(0, 1); - - if (old_bl_level == 0) - mipi_nt35510_pdata->backlight(50, 1); - - spin_lock_irqsave(&mipi_nt35510_pdata->bl_spinlock, - flags); - mipi_nt35510_pdata->backlight(bl_level, 0); - spin_unlock_irqrestore(&mipi_nt35510_pdata->bl_spinlock, - flags); - old_bl_level = bl_level; - } else { - mipi_nt35510_pdata->backlight(bl_level, 1); - } - } else { - mipi_nt35510_pdata->backlight(bl_level, mipi_nt35510_bl_ctrl); - } -} - -static struct msm_fb_panel_data nt35510_panel_data = { - .on = mipi_nt35510_lcd_on, - .off = mipi_nt35510_lcd_off, - .set_backlight = mipi_nt35510_set_backlight, -}; - -static int ch_used[3]; - -static int mipi_nt35510_lcd_init(void) -{ - mipi_dsi_buf_alloc(&nt35510_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&nt35510_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} -int mipi_nt35510_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - ret = mipi_nt35510_lcd_init(); - if (ret) { - pr_err("mipi_nt35510_lcd_init() failed with ret %u\n", ret); - return ret; - } - - pdev = platform_device_alloc("mipi_NT35510", (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - nt35510_panel_data.panel_info = *pinfo; - ret = platform_device_add_data(pdev, &nt35510_panel_data, - sizeof(nt35510_panel_data)); - if (ret) { - pr_debug("%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - pr_debug("%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} diff --git a/drivers/video/msm/mipi_NT35510.h b/drivers/video/msm/mipi_NT35510.h deleted file mode 100644 index 58ac05a5435591909781dc6a3d2241c51510d14b..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_NT35510.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2012, 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 MIPI_NT35510_H -#define MIPI_NT35510_H - -int mipi_nt35510_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MIPI_NT35510_H */ diff --git a/drivers/video/msm/mipi_NT35510_cmd_wvga_pt.c b/drivers/video/msm/mipi_NT35510_cmd_wvga_pt.c deleted file mode 100644 index 0f9fece081039f2f83751c7252ce7da7316e5135..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_NT35510_cmd_wvga_pt.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_NT35510.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_cmd_mode_phy_db = { - /* DSI Bit Clock at 500 MHz, 2 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, 0x90, - 0x18, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xbb, 0x02, 0x06, 0x00}, - /* pll control */ - {0x01, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, - 0x01, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, -}; - -static int mipi_cmd_nt35510_wvga_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_cmd_nt35510_wvga")) - return 0; - - pinfo.xres = 480; - pinfo.yres = 800; - pinfo.type = MIPI_CMD_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 100; - pinfo.lcdc.h_front_porch = 100; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 20; - pinfo.lcdc.v_front_porch = 20; - pinfo.lcdc.v_pulse_width = 1; - - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 255; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.clk_rate = 499000000; - - pinfo.lcd.vsync_enable = TRUE; - pinfo.lcd.hw_vsync_mode = TRUE; - pinfo.lcd.refx100 = 6000; /* adjust refx100 to prevent tearing */ - - pinfo.mipi.mode = DSI_CMD_MODE; - pinfo.mipi.dst_format = DSI_CMD_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.t_clk_post = 0x20; - pinfo.mipi.t_clk_pre = 0x2F; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.te_sel = 1; /* TE from vsync gpio */ - pinfo.mipi.interleave_max = 1; - pinfo.mipi.insert_dcs_cmd = TRUE; - pinfo.mipi.wr_mem_continue = 0x3c; - pinfo.mipi.wr_mem_start = 0x2c; - pinfo.mipi.dsi_phy_db = &dsi_cmd_mode_phy_db; - pinfo.mipi.tx_eot_append = 0x01; - pinfo.mipi.rx_eot_ignore = 0x0; - pinfo.mipi.dlane_swap = 0x01; - - ret = mipi_nt35510_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WVGA_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_cmd_nt35510_wvga_pt_init); diff --git a/drivers/video/msm/mipi_NT35510_video_wvga_pt.c b/drivers/video/msm/mipi_NT35510_video_wvga_pt.c deleted file mode 100644 index 6f2a372a96736689705afac5d6b6744f445400b0..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_NT35510_video_wvga_pt.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_NT35510.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* DSI Bit Clock at 500 MHz, 2 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, 0x90, - 0x18, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xbb, 0x02, 0x06, 0x00}, - /* pll control */ - {0x00, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, - 0x01, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, -}; - -static int mipi_video_nt35510_wvga_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_nt35510_wvga")) - return 0; - - pinfo.xres = 480; - pinfo.yres = 800; - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 100; - pinfo.lcdc.h_front_porch = 100; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 20; - pinfo.lcdc.v_front_porch = 20; - pinfo.lcdc.v_pulse_width = 1; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - /* number of dot_clk cycles HSYNC active edge is - delayed from VSYNC active edge */ - pinfo.lcdc.hsync_skew = 0; - pinfo.clk_rate = 499000000; - pinfo.bl_max = 255; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - /* send HSA and HE following VS/VE packet */ - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = TRUE; /* LP-11 during the HFP period */ - pinfo.mipi.hbp_power_stop = TRUE; /* LP-11 during the HBP period */ - pinfo.mipi.hsa_power_stop = TRUE; /* LP-11 during the HSA period */ - /* LP-11 or let Command Mode Engine send packets in - HS or LP mode for the BLLP of the last line of a frame */ - pinfo.mipi.eof_bllp_power_stop = TRUE; - /* LP-11 or let Command Mode Engine send packets in - HS or LP mode for packets sent during BLLP period */ - pinfo.mipi.bllp_power_stop = TRUE; - - pinfo.mipi.traffic_mode = DSI_BURST_MODE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; /* RGB */ - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - - pinfo.mipi.t_clk_post = 0x20; - pinfo.mipi.t_clk_pre = 0x2f; - - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; /* FIXME */ - - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - pinfo.mipi.dlane_swap = 0x01; - /* append EOT at the end of data burst */ - pinfo.mipi.tx_eot_append = 0x01; - - ret = mipi_nt35510_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WVGA_PT); - - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_nt35510_wvga_pt_init); diff --git a/drivers/video/msm/mipi_chimei_wuxga.c b/drivers/video/msm/mipi_chimei_wuxga.c deleted file mode 100644 index 3645d61d08673ae4bae4444acb4d2fb77efb60d2..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_chimei_wuxga.c +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (c) 2012, 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. - * - */ - -/* - * Chimei WUXGA LVDS Panel driver. - * The panel model is N101JSF-L21. - * - * The panel interface includes: - * 1. LVDS input for video (clock & data). - * 2. few configuration pins to control 3D module: Enable, Mode (2D/3D). - * 3. Backlight LED control (PWM 200 HZ). - * - * This panel is controled via the Toshiba DSI-to-LVDS bridge. - * - */ - -/* #define DEBUG 1 */ - -#include "msm_fb.h" -#include "msm_fb_panel.h" -#include "mipi_dsi.h" -#include "mipi_tc358764_dsi2lvds.h" - -#define MHZ (1000*1000) - -/** - * Panel info parameters. - * The panel info is passed to the mipi framebuffer driver. - */ -static struct msm_panel_info chimei_wuxga_pinfo; - -/** - * The mipi_dsi_phy_ctrl is calculated according to the - * "dsi_timing_program.xlsm" excel sheet. - * Output is based on: 1200x1920, RGB565, 4 lanes , 58 frames - * per second. - */ -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* DSIPHY_REGULATOR_CTRL */ - .regulator = {0x03, 0x0a, 0x04, 0x00, 0x20}, /* common 8960 */ - /* DSIPHY_CTRL */ - .ctrl = {0x5f, 0x00, 0x00, 0x10}, /* common 8960 */ - /* DSIPHY_STRENGTH_CTRL */ - .strength = {0xff, 0x00, 0x06, 0x00}, /* common 8960 */ - /* DSIPHY_TIMING_CTRL */ - .timing = { 0xC9, 0x92, 0x29, /* panel specific */ - 0, /* DSIPHY_TIMING_CTRL_3 = 0 */ - 0x2D, 0x9B, 0x2B, 0x94, 0x2D, 0x03, 0x04}, /* panel specific */ - - /* DSIPHY_PLL_CTRL */ - .pll = { 0x00, /* common 8960 */ - /* VCO */ - 0x30, (0x01 | 0x30) , (0x19 | 0xC0), /* panel specific */ - 0x00, 0x50, 0x48, 0x63, - 0x77, 0x88, 0x99, /* Auto update by dsi-mipi driver */ - 0x00, 0x14, 0x03, 0x00, 0x02, /* common 8960 */ - 0x00, 0x20, 0x00, 0x01 }, /* common 8960 */ -}; - -/** - * Module init. - * - * Register the panel-info. - * - * Some parameters are from the panel datasheet - * and other are *calculated* by the "dsi_timing_program.xlsm" - * excel file - * - * @return int - */ -static int __init mipi_chimei_wuxga_init(void) -{ - int ret; - struct msm_panel_info *pinfo = &chimei_wuxga_pinfo; - - if (msm_fb_detect_client("mipi_video_chimei_wuxga")) - return 0; - - pr_info("mipi-dsi chimei wuxga (1200x1920) driver ver 1.0.\n"); - - /* Portrait */ - pinfo->xres = 1200; - pinfo->yres = 1920; - pinfo->type = MIPI_VIDEO_PANEL; - pinfo->pdest = DISPLAY_1; /* Primary Display */ - pinfo->wait_cycle = 0; - pinfo->bpp = 24; /* RGB565 requires 24 bits-per-pixel :-O */ - pinfo->fb_num = 2; /* using two frame buffers */ - - /* - * The CMI panel requires 80 MHZ LVDS-CLK. - * The D2L bridge drives the LVDS-CLK from the DSI-CLK. - * The DSI-CLK = bitclk/2, 640 MHZ/2= 320 MHZ. - * LVDS-CLK = DSI-CLK/4 , 320 MHZ/4= 80 MHZ. - */ - - pinfo->clk_rate = 635 * MHZ ; /* bitclk Calculated */ - - /* - * this panel is operated by DE, - * vsycn and hsync are ignored - */ - - pinfo->lcdc.h_front_porch = 160-48-32; /* thfp */ - pinfo->lcdc.h_back_porch = 48; /* thb */ - pinfo->lcdc.h_pulse_width = 32; /* thpw */ - - pinfo->lcdc.v_front_porch = 26-3-6; /* tvfp */ - pinfo->lcdc.v_back_porch = 3; /* tvb */ - pinfo->lcdc.v_pulse_width = 6; /* tvpw */ - - pinfo->lcdc.border_clr = 0; /* black */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - - pinfo->lcdc.hsync_skew = 0; - - /* Backlight levels - controled via PMIC pwm gpio */ - pinfo->bl_max = PWM_LEVEL; - pinfo->bl_min = 1; - - /* mipi - general */ - pinfo->mipi.vc = 0; /* virtual channel */ - pinfo->mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo->mipi.tx_eot_append = true; - pinfo->mipi.t_clk_post = 34; /* Calculated */ - pinfo->mipi.t_clk_pre = 69; /* Calculated */ - - pinfo->mipi.dsi_phy_db = &dsi_video_mode_phy_db; - - /* Four lanes are recomended for 1920x1200 at 60 frames per second */ - pinfo->mipi.frame_rate = 60; - pinfo->mipi.data_lane0 = true; - pinfo->mipi.data_lane1 = true; - pinfo->mipi.data_lane2 = true; - pinfo->mipi.data_lane3 = true; - pinfo->mipi.esc_byte_ratio = 6; - - pinfo->mipi.mode = DSI_VIDEO_MODE; - /* - * Note: The CMI panel input is RGB888, - * thus the DSI-to-LVDS bridge output is RGB888. - * This parameter selects the DSI-Core output to the bridge. - */ - pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB565; - - /* mipi - video mode */ - pinfo->mipi.traffic_mode = DSI_NON_BURST_SYNCH_EVENT; - pinfo->mipi.pulse_mode_hsa_he = false; /* sync mode */ - - pinfo->mipi.hfp_power_stop = false; - pinfo->mipi.hbp_power_stop = false; - pinfo->mipi.hsa_power_stop = false; - pinfo->mipi.eof_bllp_power_stop = false; - pinfo->mipi.bllp_power_stop = false; - - /* mipi - command mode */ - pinfo->mipi.te_sel = 1; /* TE from vsycn gpio */ - pinfo->mipi.interleave_max = 1; - /* The bridge supports only Generic Read/Write commands */ - pinfo->mipi.insert_dcs_cmd = false; - pinfo->mipi.wr_mem_continue = 0; - pinfo->mipi.wr_mem_start = 0; - pinfo->mipi.stream = false; /* dma_p */ - pinfo->mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo->mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - /* - * toshiba d2l chip does not need max_pkt_size dcs cmd - * client reply len is directly configure through - * RDPKTLN register (0x0404) - */ - pinfo->mipi.no_max_pkt_size = 1; - pinfo->mipi.force_clk_lane_hs = 1; - - pinfo->is_3d_panel = FB_TYPE_3D_PANEL; - - ret = mipi_tc358764_dsi2lvds_register(pinfo, MIPI_DSI_PRIM, 1); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_chimei_wuxga_init); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Chimei WUXGA LVDS Panel driver"); -MODULE_AUTHOR("Amir Samuelov "); diff --git a/drivers/video/msm/mipi_chimei_wxga_pt.c b/drivers/video/msm/mipi_chimei_wxga_pt.c deleted file mode 100644 index 8b1b828ce204202f97ac0de9a9db9e19a866b55e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_chimei_wxga_pt.c +++ /dev/null @@ -1,192 +0,0 @@ -/* Copyright (c) 2011, 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. - * - */ - -/* - * Chimei WXGA LVDS Panel driver. - * The panel model is N101BCG-L21. - * - * The panel interface includes: - * 1. LVDS input for video (clock & data). - * 2. few configuration pins: Up/Down scan, Left/Right scan etc. - * 3. Backlight LED control. - * 4. I2C interface for EEPROM access. - * - * The Panel is *internally* controlled by Novatek NT51009 controller. - * However, the "3-wire" SPI interface is not exposed on the panel interface. - * - * This panel is controled via the Toshiba DSI-to-LVDS bridge. - * - */ - -/* #define DEBUG 1 */ - -#include "msm_fb.h" -#include "msm_fb_panel.h" -#include "mipi_dsi.h" -#include "mipi_tc358764_dsi2lvds.h" - -#define MHZ (1000*1000) - -/** - * Panel info parameters. - * The panel info is passed to the mipi framebuffer driver. - */ -static struct msm_panel_info chimei_wxga_pinfo; - -/** - * The mipi_dsi_phy_ctrl is calculated according to the - * "DSI_panel_bring_up_guide_ver3.docm" using the excel sheet. - * Output is based on: 1366x768, RGB888, 4 lanes , 60 frames per second. - */ -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* DSIPHY_REGULATOR_CTRL */ - .regulator = {0x03, 0x0a, 0x04, 0x00, 0x20}, /* common 8960 */ - /* DSIPHY_CTRL */ - .ctrl = {0x5f, 0x00, 0x00, 0x10}, /* common 8960 */ - /* DSIPHY_STRENGTH_CTRL */ - .strength = {0xff, 0x00, 0x06, 0x00}, /* common 8960 */ - /* DSIPHY_TIMING_CTRL */ - .timing = { 0xB6, 0x8D, 0x1E, /* panel specific */ - 0, /* DSIPHY_TIMING_CTRL_3 = 0 */ - 0x21, 0x95, 0x21, 0x8F, 0x21, 0x03, 0x04}, /* panel specific */ - - /* DSIPHY_PLL_CTRL */ - .pll = { 0x00, /* common 8960 */ - /* VCO */ - 0xC6, 0x01, 0x19, /* panel specific */ - 0x00, 0x50, 0x48, 0x63, - 0x77, 0x88, 0x99, /* Auto update by dsi-mipi driver */ - 0x00, 0x14, 0x03, 0x00, 0x02, /* common 8960 */ - 0x00, 0x20, 0x00, 0x01 }, /* common 8960 */ -}; - -/** - * Module init. - * - * Register the panel-info. - * - * Some parameters are from the panel datasheet - * and other are *calculated* according to the - * "DSI_panel_bring_up_guide_ver3.docm". - * - * @return int - */ -static int __init mipi_chimei_wxga_init(void) -{ - int ret; - struct msm_panel_info *pinfo = &chimei_wxga_pinfo; - - if (msm_fb_detect_client("mipi_video_chimei_wxga")) - return 0; - - pr_debug("mipi-dsi chimei wxga (1366x768) driver ver 1.0.\n"); - /* Landscape */ - pinfo->xres = 1366; - pinfo->yres = 768; - pinfo->type = MIPI_VIDEO_PANEL; - pinfo->pdest = DISPLAY_1; /* Primary Display */ - pinfo->wait_cycle = 0; - pinfo->bpp = 24; /* RGB888 = 24 bits-per-pixel */ - pinfo->fb_num = 2; /* using two frame buffers */ - - /* bitclk */ - pinfo->clk_rate = 473400000; /* 473.4 MHZ Calculated */ - - /* - * this panel is operated by DE, - * vsycn and hsync are ignored - */ - - pinfo->lcdc.h_front_porch = 96+2;/* thfp */ - pinfo->lcdc.h_back_porch = 88; /* thb */ - pinfo->lcdc.h_pulse_width = 40; /* thpw */ - - pinfo->lcdc.v_front_porch = 15; /* tvfp */ - pinfo->lcdc.v_back_porch = 23; /* tvb */ - pinfo->lcdc.v_pulse_width = 20; /* tvpw */ - - pinfo->lcdc.border_clr = 0; /* black */ - pinfo->lcdc.underflow_clr = 0xff; /* blue */ - - pinfo->lcdc.hsync_skew = 0; - - /* Backlight levels - controled via PMIC pwm gpio */ - pinfo->bl_max = PWM_LEVEL; - pinfo->bl_min = 1; - - /* mipi - general */ - pinfo->mipi.vc = 0; /* virtual channel */ - pinfo->mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo->mipi.tx_eot_append = true; - pinfo->mipi.t_clk_post = 34; /* Calculated */ - pinfo->mipi.t_clk_pre = 64; /* Calculated */ - pinfo->mipi.esc_byte_ratio = 4; - - pinfo->mipi.dsi_phy_db = &dsi_video_mode_phy_db; - - /* Four lanes are recomended for 1366x768 at 60 frames per second */ - pinfo->mipi.frame_rate = 60; /* 60 frames per second */ - pinfo->mipi.data_lane0 = true; - pinfo->mipi.data_lane1 = true; - pinfo->mipi.data_lane2 = true; - pinfo->mipi.data_lane3 = true; - - pinfo->mipi.mode = DSI_VIDEO_MODE; - /* - * Note: The CMI panel input is RGB888, - * thus the DSI-to-LVDS bridge output is RGB888. - * This parameter selects the DSI-Core output to the bridge. - */ - pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - - /* mipi - video mode */ - pinfo->mipi.traffic_mode = DSI_NON_BURST_SYNCH_EVENT; - pinfo->mipi.pulse_mode_hsa_he = false; /* sync mode */ - - pinfo->mipi.hfp_power_stop = false; - pinfo->mipi.hbp_power_stop = false; - pinfo->mipi.hsa_power_stop = false; - pinfo->mipi.eof_bllp_power_stop = false; - pinfo->mipi.bllp_power_stop = false; - - /* mipi - command mode */ - pinfo->mipi.te_sel = 1; /* TE from vsycn gpio */ - pinfo->mipi.interleave_max = 1; - /* The bridge supports only Generic Read/Write commands */ - pinfo->mipi.insert_dcs_cmd = false; - pinfo->mipi.wr_mem_continue = 0; - pinfo->mipi.wr_mem_start = 0; - pinfo->mipi.stream = false; /* dma_p */ - pinfo->mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo->mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - /* - * toshiba d2l chip does not need max_pkt_szie dcs cmd - * client reply len is directly configure through - * RDPKTLN register (0x0404) - */ - pinfo->mipi.no_max_pkt_size = 1; - pinfo->mipi.force_clk_lane_hs = 1; - - ret = mipi_tc358764_dsi2lvds_register(pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WXGA); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_chimei_wxga_init); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Chimei WXGA LVDS Panel driver"); -MODULE_AUTHOR("Amir Samuelov "); diff --git a/drivers/video/msm/mipi_dsi.c b/drivers/video/msm/mipi_dsi.c deleted file mode 100644 index 0013637c8d1f525c7abda05c1c2137345512ac79..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_dsi.c +++ /dev/null @@ -1,622 +0,0 @@ -/* Copyright (c) 2008-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" -#include "mipi_dsi.h" -#include "mdp.h" -#include "mdp4.h" - -u32 dsi_irq; -u32 esc_byte_ratio; - -static boolean tlmm_settings = FALSE; - -static int mipi_dsi_probe(struct platform_device *pdev); -static int mipi_dsi_remove(struct platform_device *pdev); - -static int mipi_dsi_off(struct platform_device *pdev); -static int mipi_dsi_on(struct platform_device *pdev); - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; -static struct mipi_dsi_platform_data *mipi_dsi_pdata; - -static int vsync_gpio = -1; - -static struct platform_driver mipi_dsi_driver = { - .probe = mipi_dsi_probe, - .remove = mipi_dsi_remove, - .shutdown = NULL, - .driver = { - .name = "mipi_dsi", - }, -}; - -struct device dsi_dev; - -static int mipi_dsi_off(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_data_type *mfd; - struct msm_panel_info *pinfo; - - pr_debug("%s+:\n", __func__); - - mfd = platform_get_drvdata(pdev); - pinfo = &mfd->panel_info; - - if (mdp_rev >= MDP_REV_41) - mutex_lock(&mfd->dma->ov_mutex); - else - down(&mfd->dma->mutex); - - if (mfd->panel_info.type == MIPI_CMD_PANEL) { - mipi_dsi_prepare_clocks(); - mipi_dsi_ahb_ctrl(1); - mipi_dsi_clk_enable(); - - /* make sure dsi_cmd_mdp is idle */ - mipi_dsi_cmd_mdp_busy(); - } - - /* - * Desctiption: change to DSI_CMD_MODE since it needed to - * tx DCS dsiplay off comamnd to panel - */ - mipi_dsi_op_mode_config(DSI_CMD_MODE); - - if (mfd->panel_info.type == MIPI_CMD_PANEL) { - if (pinfo->lcd.vsync_enable) { - if (pinfo->lcd.hw_vsync_mode && vsync_gpio >= 0) { - if (MDP_REV_303 != mdp_rev) - gpio_free(vsync_gpio); - } - mipi_dsi_set_tear_off(mfd); - } - } - - ret = panel_next_off(pdev); - - mipi_dsi_clk_disable(); - - /* disbale dsi engine */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0000, 0); - - mipi_dsi_phy_ctrl(0); - - mipi_dsi_ahb_ctrl(0); - - mipi_dsi_unprepare_clocks(); - if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save) - mipi_dsi_pdata->dsi_power_save(0); - - if (mdp_rev >= MDP_REV_41) - mutex_unlock(&mfd->dma->ov_mutex); - else - up(&mfd->dma->mutex); - - pr_debug("%s-:\n", __func__); - - return ret; -} - -static int mipi_dsi_on(struct platform_device *pdev) -{ - int ret = 0; - u32 clk_rate; - struct msm_fb_data_type *mfd; - struct fb_info *fbi; - struct fb_var_screeninfo *var; - struct msm_panel_info *pinfo; - struct mipi_panel_info *mipi; - u32 hbp, hfp, vbp, vfp, hspw, vspw, width, height; - u32 ystride, bpp, data; - u32 dummy_xres, dummy_yres; - int target_type = 0; - - pr_debug("%s+:\n", __func__); - - mfd = platform_get_drvdata(pdev); - fbi = mfd->fbi; - var = &fbi->var; - pinfo = &mfd->panel_info; - esc_byte_ratio = pinfo->mipi.esc_byte_ratio; - - if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save) - mipi_dsi_pdata->dsi_power_save(1); - - cont_splash_clk_ctrl(0); - mipi_dsi_prepare_clocks(); - - mipi_dsi_ahb_ctrl(1); - - clk_rate = mfd->fbi->var.pixclock; - clk_rate = min(clk_rate, mfd->panel_info.clk_max); - - mipi_dsi_phy_ctrl(1); - - if (mdp_rev == MDP_REV_42 && mipi_dsi_pdata) - target_type = mipi_dsi_pdata->target_type; - - mipi_dsi_phy_init(0, &(mfd->panel_info), target_type); - - mipi_dsi_clk_enable(); - - MIPI_OUTP(MIPI_DSI_BASE + 0x114, 1); - MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0); - - hbp = var->left_margin; - hfp = var->right_margin; - vbp = var->upper_margin; - vfp = var->lower_margin; - hspw = var->hsync_len; - vspw = var->vsync_len; - width = mfd->panel_info.xres; - height = mfd->panel_info.yres; - - mipi = &mfd->panel_info.mipi; - if (mfd->panel_info.type == MIPI_VIDEO_PANEL) { - dummy_xres = mfd->panel_info.lcdc.xres_pad; - dummy_yres = mfd->panel_info.lcdc.yres_pad; - - if (mdp_rev >= MDP_REV_41) { - MIPI_OUTP(MIPI_DSI_BASE + 0x20, - ((hspw + hbp + width + dummy_xres) << 16 | - (hspw + hbp))); - MIPI_OUTP(MIPI_DSI_BASE + 0x24, - ((vspw + vbp + height + dummy_yres) << 16 | - (vspw + vbp))); - MIPI_OUTP(MIPI_DSI_BASE + 0x28, - (vspw + vbp + height + dummy_yres + - vfp - 1) << 16 | (hspw + hbp + - width + dummy_xres + hfp - 1)); - } else { - /* DSI_LAN_SWAP_CTRL */ - MIPI_OUTP(MIPI_DSI_BASE + 0x00ac, mipi->dlane_swap); - - MIPI_OUTP(MIPI_DSI_BASE + 0x20, - ((hbp + width + dummy_xres) << 16 | (hbp))); - MIPI_OUTP(MIPI_DSI_BASE + 0x24, - ((vbp + height + dummy_yres) << 16 | (vbp))); - MIPI_OUTP(MIPI_DSI_BASE + 0x28, - (vbp + height + dummy_yres + vfp) << 16 | - (hbp + width + dummy_xres + hfp)); - } - - MIPI_OUTP(MIPI_DSI_BASE + 0x2c, (hspw << 16)); - MIPI_OUTP(MIPI_DSI_BASE + 0x30, 0); - MIPI_OUTP(MIPI_DSI_BASE + 0x34, (vspw << 16)); - - } else { /* command mode */ - if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888) - bpp = 3; - else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB666) - bpp = 3; - else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565) - bpp = 2; - else - bpp = 3; /* Default format set to RGB888 */ - - ystride = width * bpp + 1; - - /* DSI_COMMAND_MODE_MDP_STREAM_CTRL */ - data = (ystride << 16) | (mipi->vc << 8) | DTYPE_DCS_LWRITE; - MIPI_OUTP(MIPI_DSI_BASE + 0x5c, data); - MIPI_OUTP(MIPI_DSI_BASE + 0x54, data); - - /* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */ - data = height << 16 | width; - MIPI_OUTP(MIPI_DSI_BASE + 0x60, data); - MIPI_OUTP(MIPI_DSI_BASE + 0x58, data); - } - - mipi_dsi_host_init(mipi); - - if (mipi->force_clk_lane_hs) { - u32 tmp; - - tmp = MIPI_INP(MIPI_DSI_BASE + 0xA8); - tmp |= (1<<28); - MIPI_OUTP(MIPI_DSI_BASE + 0xA8, tmp); - wmb(); - } - - if (mdp_rev >= MDP_REV_41) - mutex_lock(&mfd->dma->ov_mutex); - else - down(&mfd->dma->mutex); - - ret = panel_next_on(pdev); - - mipi_dsi_op_mode_config(mipi->mode); - - if (mfd->panel_info.type == MIPI_CMD_PANEL) { - if (pinfo->lcd.vsync_enable) { - if (pinfo->lcd.hw_vsync_mode && vsync_gpio >= 0) { - if (mdp_rev >= MDP_REV_41) { - if (gpio_request(vsync_gpio, - "MDP_VSYNC") == 0) - gpio_direction_input( - vsync_gpio); - else - pr_err("%s: unable to \ - request gpio=%d\n", - __func__, vsync_gpio); - } else if (mdp_rev == MDP_REV_303) { - if (!tlmm_settings && gpio_request( - vsync_gpio, "MDP_VSYNC") == 0) { - ret = gpio_tlmm_config( - GPIO_CFG( - vsync_gpio, 1, - GPIO_CFG_INPUT, - GPIO_CFG_PULL_DOWN, - GPIO_CFG_2MA), - GPIO_CFG_ENABLE); - - if (ret) { - pr_err( - "%s: unable to config \ - tlmm = %d\n", - __func__, vsync_gpio); - } - tlmm_settings = TRUE; - - gpio_direction_input( - vsync_gpio); - } else { - if (!tlmm_settings) { - pr_err( - "%s: unable to request \ - gpio=%d\n", - __func__, vsync_gpio); - } - } - } - } - mipi_dsi_set_tear_on(mfd); - } - mipi_dsi_clk_disable(); - mipi_dsi_ahb_ctrl(0); - mipi_dsi_unprepare_clocks(); - } - - if (mdp_rev >= MDP_REV_41) - mutex_unlock(&mfd->dma->ov_mutex); - else - up(&mfd->dma->mutex); - - pr_debug("%s-:\n", __func__); - - return ret; -} - -static int mipi_dsi_late_init(struct platform_device *pdev) -{ - return panel_next_late_init(pdev); -} - - -static int mipi_dsi_resource_initialized; - -static int mipi_dsi_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct fb_info *fbi; - struct msm_panel_info *pinfo; - struct mipi_panel_info *mipi; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc; - uint8 lanes = 0, bpp; - uint32 h_period, v_period, dsi_pclk_rate; - - resource_size_t size ; - - if ((pdev->id == 1) && (pdev->num_resources >= 0)) { - mipi_dsi_pdata = pdev->dev.platform_data; - - size = resource_size(&pdev->resource[0]); - mipi_dsi_base = ioremap(pdev->resource[0].start, size); - - MSM_FB_INFO("mipi_dsi base phy_addr = 0x%x virt = 0x%x\n", - pdev->resource[0].start, (int) mipi_dsi_base); - - if (!mipi_dsi_base) - return -ENOMEM; - - if (mdp_rev >= MDP_REV_41) { - mmss_sfpb_base = ioremap(MMSS_SFPB_BASE_PHY, 0x100); - MSM_FB_INFO("mmss_sfpb base phy_addr = 0x%x," - "virt = 0x%x\n", MMSS_SFPB_BASE_PHY, - (int) mmss_sfpb_base); - - if (!mmss_sfpb_base) - return -ENOMEM; - } - - dsi_irq = platform_get_irq(pdev, 0); - if (dsi_irq < 0) { - pr_err("mipi_dsi: can not get mdp irq\n"); - return -ENOMEM; - } - - rc = request_irq(dsi_irq, mipi_dsi_isr, IRQF_DISABLED, - "MIPI_DSI", 0); - if (rc) { - pr_err("mipi_dsi_host request_irq() failed!\n"); - return rc; - } - - disable_irq(dsi_irq); - - if (mdp_rev == MDP_REV_42 && mipi_dsi_pdata && - mipi_dsi_pdata->target_type == 1) { - /* Target type is 1 for device with (De)serializer - * 0x4f00000 is the base for TV Encoder. - * Unused Offset 0x1000 is used for - * (de)serializer on emulation platform - */ - periph_base = ioremap(MMSS_SERDES_BASE_PHY, 0x100); - - if (periph_base) { - pr_debug("periph_base %p\n", periph_base); - writel(0x4, periph_base + 0x28); - writel(0xc, periph_base + 0x28); - } else { - pr_err("periph_base is NULL\n"); - free_irq(dsi_irq, 0); - return -ENOMEM; - } - } - - if (mipi_dsi_pdata) { - vsync_gpio = mipi_dsi_pdata->vsync_gpio; - pr_debug("%s: vsync_gpio=%d\n", __func__, vsync_gpio); - - if (mdp_rev == MDP_REV_303 && - mipi_dsi_pdata->dsi_client_reset) { - if (mipi_dsi_pdata->dsi_client_reset()) - pr_err("%s: DSI Client Reset failed!\n", - __func__); - else - pr_debug("%s: DSI Client Reset success\n", - __func__); - } - } - - if (mipi_dsi_clk_init(pdev)) - return -EPERM; - - if (mipi_dsi_pdata->splash_is_enabled && - !mipi_dsi_pdata->splash_is_enabled()) { - mipi_dsi_ahb_ctrl(1); - MIPI_OUTP(MIPI_DSI_BASE + 0x118, 0); - MIPI_OUTP(MIPI_DSI_BASE + 0x0, 0); - MIPI_OUTP(MIPI_DSI_BASE + 0x200, 0); - mipi_dsi_ahb_ctrl(0); - } - mipi_dsi_resource_initialized = 1; - - return 0; - } - - if (!mipi_dsi_resource_initialized) - return -EPERM; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - - /* - * link to the latest pdev - */ - mfd->pdev = mdp_dev; - - /* - * alloc panel device data - */ - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - pr_err("mipi_dsi_probe: platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - /* - * data chain - */ - pdata = mdp_dev->dev.platform_data; - pdata->on = mipi_dsi_on; - pdata->off = mipi_dsi_off; - pdata->late_init = mipi_dsi_late_init; - pdata->next = pdev; - - /* - * get/set panel specific fb info - */ - mfd->panel_info = pdata->panel_info; - pinfo = &mfd->panel_info; - - if (mfd->panel_info.type == MIPI_VIDEO_PANEL) - mfd->dest = DISPLAY_LCDC; - else - mfd->dest = DISPLAY_LCD; - - if (mdp_rev == MDP_REV_303 && - mipi_dsi_pdata->get_lane_config) { - if (mipi_dsi_pdata->get_lane_config() != 2) { - pr_info("Changing to DSI Single Mode Configuration\n"); -#ifdef CONFIG_FB_MSM_MDP303 - update_lane_config(pinfo); -#endif - } - } - - if (mfd->index == 0) - mfd->fb_imgType = MSMFB_DEFAULT_TYPE; - else - mfd->fb_imgType = MDP_RGB_565; - - fbi = mfd->fbi; - fbi->var.pixclock = mfd->panel_info.clk_rate; - fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; - fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; - fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; - fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; - fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; - fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; - - h_period = ((mfd->panel_info.lcdc.h_pulse_width) - + (mfd->panel_info.lcdc.h_back_porch) - + (mfd->panel_info.xres) - + (mfd->panel_info.lcdc.h_front_porch)); - - v_period = ((mfd->panel_info.lcdc.v_pulse_width) - + (mfd->panel_info.lcdc.v_back_porch) - + (mfd->panel_info.yres) - + (mfd->panel_info.lcdc.v_front_porch)); - - mipi = &mfd->panel_info.mipi; - - if (mipi->data_lane3) - lanes += 1; - if (mipi->data_lane2) - lanes += 1; - if (mipi->data_lane1) - lanes += 1; - if (mipi->data_lane0) - lanes += 1; - - if ((mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888) - || (mipi->dst_format == DSI_VIDEO_DST_FORMAT_RGB888) - || (mipi->dst_format == DSI_VIDEO_DST_FORMAT_RGB666_LOOSE)) - bpp = 3; - else if ((mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565) - || (mipi->dst_format == DSI_VIDEO_DST_FORMAT_RGB565)) - bpp = 2; - else - bpp = 3; /* Default format set to RGB888 */ - - if (mfd->panel_info.type == MIPI_VIDEO_PANEL && - !mfd->panel_info.clk_rate) { - h_period += mfd->panel_info.lcdc.xres_pad; - v_period += mfd->panel_info.lcdc.yres_pad; - - if (lanes > 0) { - mfd->panel_info.clk_rate = - ((h_period * v_period * (mipi->frame_rate) * bpp * 8) - / lanes); - } else { - pr_err("%s: forcing mipi_dsi lanes to 1\n", __func__); - mfd->panel_info.clk_rate = - (h_period * v_period - * (mipi->frame_rate) * bpp * 8); - } - } - pll_divider_config.clk_rate = mfd->panel_info.clk_rate; - - rc = mipi_dsi_clk_div_config(bpp, lanes, &dsi_pclk_rate); - if (rc) - goto mipi_dsi_probe_err; - - if ((dsi_pclk_rate < 3300000) || (dsi_pclk_rate > 223000000)) { - pr_err("%s: Pixel clock not supported\n", __func__); - dsi_pclk_rate = 35000000; - } - mipi->dsi_pclk_rate = dsi_pclk_rate; - - /* - * set driver data - */ - platform_set_drvdata(mdp_dev, mfd); - - /* - * register in mdp driver - */ - rc = platform_device_add(mdp_dev); - if (rc) - goto mipi_dsi_probe_err; - - pdev_list[pdev_list_cnt++] = pdev; - - if (!mfd->cont_splash_done) - cont_splash_clk_ctrl(1); - -return 0; - -mipi_dsi_probe_err: - platform_device_put(mdp_dev); - return rc; -} - -static int mipi_dsi_remove(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - iounmap(mipi_dsi_base); - return 0; -} - -static int mipi_dsi_register_driver(void) -{ - return platform_driver_register(&mipi_dsi_driver); -} - -static int __init mipi_dsi_driver_init(void) -{ - int ret; - - mipi_dsi_init(); - - ret = mipi_dsi_register_driver(); - - device_initialize(&dsi_dev); - - if (ret) { - pr_err("mipi_dsi_register_driver() failed!\n"); - return ret; - } - - return ret; -} - -module_init(mipi_dsi_driver_init); diff --git a/drivers/video/msm/mipi_dsi.h b/drivers/video/msm/mipi_dsi.h deleted file mode 100644 index 7338a5a9ac933d043db1dcee38ad8b6e27f99453..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_dsi.h +++ /dev/null @@ -1,378 +0,0 @@ -/* Copyright (c) 2009-2012, 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 MIPI_DSI_H -#define MIPI_DSI_H - -#include -#include - -#ifdef BIT -#undef BIT -#endif - -#define BIT(x) (1<<(x)) - -#define MMSS_CC_BASE_PHY 0x04000000 /* mmss clcok control */ -#define MMSS_SFPB_BASE_PHY 0x05700000 /* mmss SFPB CFG */ -#define MMSS_SERDES_BASE_PHY 0x04f01000 /* mmss (De)Serializer CFG */ - -#define MIPI_DSI_BASE mipi_dsi_base - -#define MIPI_OUTP(addr, data) writel((data), (addr)) -#define MIPI_INP(addr) readl(addr) - -#ifdef CONFIG_MSM_SECURE_IO -#define MIPI_OUTP_SECURE(addr, data) secure_writel((data), (addr)) -#define MIPI_INP_SECURE(addr) secure_readl(addr) -#else -#define MIPI_OUTP_SECURE(addr, data) writel((data), (addr)) -#define MIPI_INP_SECURE(addr) readl(addr) -#endif - -#define MIPI_DSI_PRIM 1 -#define MIPI_DSI_SECD 2 - -#define MIPI_DSI_PANEL_VGA 0 -#define MIPI_DSI_PANEL_WVGA 1 -#define MIPI_DSI_PANEL_WVGA_PT 2 -#define MIPI_DSI_PANEL_FWVGA_PT 3 -#define MIPI_DSI_PANEL_WSVGA_PT 4 -#define MIPI_DSI_PANEL_QHD_PT 5 -#define MIPI_DSI_PANEL_WXGA 6 -#define MIPI_DSI_PANEL_WUXGA 7 -#define MIPI_DSI_PANEL_720P_PT 8 -#define DSI_PANEL_MAX 8 - -enum { /* mipi dsi panel */ - DSI_VIDEO_MODE, - DSI_CMD_MODE, -}; - -enum { - ST_DSI_CLK_OFF, - ST_DSI_SUSPEND, - ST_DSI_RESUME, - ST_DSI_PLAYING, - ST_DSI_NUM -}; - -enum { - EV_DSI_UPDATE, - EV_DSI_DONE, - EV_DSI_TOUT, - EV_DSI_NUM -}; - -enum { - LANDSCAPE = 1, - PORTRAIT = 2, -}; - -enum dsi_trigger_type { - DSI_CMD_MODE_DMA, - DSI_CMD_MODE_MDP, -}; - -#define DSI_NON_BURST_SYNCH_PULSE 0 -#define DSI_NON_BURST_SYNCH_EVENT 1 -#define DSI_BURST_MODE 2 - - -#define DSI_RGB_SWAP_RGB 0 -#define DSI_RGB_SWAP_RBG 1 -#define DSI_RGB_SWAP_BGR 2 -#define DSI_RGB_SWAP_BRG 3 -#define DSI_RGB_SWAP_GRB 4 -#define DSI_RGB_SWAP_GBR 5 - -#define DSI_VIDEO_DST_FORMAT_RGB565 0 -#define DSI_VIDEO_DST_FORMAT_RGB666 1 -#define DSI_VIDEO_DST_FORMAT_RGB666_LOOSE 2 -#define DSI_VIDEO_DST_FORMAT_RGB888 3 - -#define DSI_CMD_DST_FORMAT_RGB111 0 -#define DSI_CMD_DST_FORMAT_RGB332 3 -#define DSI_CMD_DST_FORMAT_RGB444 4 -#define DSI_CMD_DST_FORMAT_RGB565 6 -#define DSI_CMD_DST_FORMAT_RGB666 7 -#define DSI_CMD_DST_FORMAT_RGB888 8 - -#define DSI_INTR_ERROR_MASK BIT(25) -#define DSI_INTR_ERROR BIT(24) -#define DSI_INTR_VIDEO_DONE_MASK BIT(17) -#define DSI_INTR_VIDEO_DONE BIT(16) -#define DSI_INTR_CMD_MDP_DONE_MASK BIT(9) -#define DSI_INTR_CMD_MDP_DONE BIT(8) -#define DSI_INTR_CMD_DMA_DONE_MASK BIT(1) -#define DSI_INTR_CMD_DMA_DONE BIT(0) - -#define DSI_MDP_TERM BIT(8) -#define DSI_CMD_TERM BIT(0) - -#define DSI_CMD_TRIGGER_NONE 0x0 /* mdp trigger */ -#define DSI_CMD_TRIGGER_TE 0x02 -#define DSI_CMD_TRIGGER_SW 0x04 -#define DSI_CMD_TRIGGER_SW_SEOF 0x05 /* cmd dma only */ -#define DSI_CMD_TRIGGER_SW_TE 0x06 - -extern struct device dsi_dev; -extern int mipi_dsi_clk_on; -extern u32 dsi_irq; -extern u32 esc_byte_ratio; - -extern void __iomem *periph_base; -extern char *mmss_cc_base; /* mutimedia sub system clock control */ -extern char *mmss_sfpb_base; /* mutimedia sub system sfpb */ - -struct dsiphy_pll_divider_config { - u32 clk_rate; - u32 fb_divider; - u32 ref_divider_ratio; - u32 bit_clk_divider; /* oCLK1 */ - u32 byte_clk_divider; /* oCLK2 */ - u32 dsi_clk_divider; /* oCLK3 */ -}; - -extern struct dsiphy_pll_divider_config pll_divider_config; - -struct dsi_clk_mnd_table { - uint8 lanes; - uint8 bpp; - uint8 dsiclk_div; - uint8 dsiclk_m; - uint8 dsiclk_n; - uint8 dsiclk_d; - uint8 pclk_m; - uint8 pclk_n; - uint8 pclk_d; -}; - -static const struct dsi_clk_mnd_table mnd_table[] = { - { 1, 2, 8, 1, 1, 0, 1, 2, 1}, - { 1, 3, 8, 1, 1, 0, 1, 3, 2}, - { 2, 2, 4, 1, 1, 0, 1, 2, 1}, - { 2, 3, 4, 1, 1, 0, 1, 3, 2}, - { 3, 2, 1, 3, 8, 4, 3, 16, 8}, - { 3, 3, 1, 3, 8, 4, 1, 8, 4}, - { 4, 2, 2, 1, 1, 0, 1, 2, 1}, - { 4, 3, 2, 1, 1, 0, 1, 3, 2}, -}; - -struct dsi_clk_desc { - uint32 src; - uint32 m; - uint32 n; - uint32 d; - uint32 mnd_mode; - uint32 pre_div_func; -}; - -#define DSI_HOST_HDR_SIZE 4 -#define DSI_HDR_LAST BIT(31) -#define DSI_HDR_LONG_PKT BIT(30) -#define DSI_HDR_BTA BIT(29) -#define DSI_HDR_VC(vc) (((vc) & 0x03) << 22) -#define DSI_HDR_DTYPE(dtype) (((dtype) & 0x03f) << 16) -#define DSI_HDR_DATA2(data) (((data) & 0x0ff) << 8) -#define DSI_HDR_DATA1(data) ((data) & 0x0ff) -#define DSI_HDR_WC(wc) ((wc) & 0x0ffff) - -#define DSI_BUF_SIZE 64 -#define MIPI_DSI_MRPS 0x04 /* Maximum Return Packet Size */ - -#define MIPI_DSI_LEN 8 /* 4 x 4 - 6 - 2, bytes dcs header+crc-align */ - -struct dsi_buf { - uint32 *hdr; /* dsi host header */ - char *start; /* buffer start addr */ - char *end; /* buffer end addr */ - int size; /* size of buffer */ - char *data; /* buffer */ - int len; /* data length */ - dma_addr_t dmap; /* mapped dma addr */ -}; - -/* dcs read/write */ -#define DTYPE_DCS_WRITE 0x05 /* short write, 0 parameter */ -#define DTYPE_DCS_WRITE1 0x15 /* short write, 1 parameter */ -#define DTYPE_DCS_READ 0x06 /* read */ -#define DTYPE_DCS_LWRITE 0x39 /* long write */ - -/* generic read/write */ -#define DTYPE_GEN_WRITE 0x03 /* short write, 0 parameter */ -#define DTYPE_GEN_WRITE1 0x13 /* short write, 1 parameter */ -#define DTYPE_GEN_WRITE2 0x23 /* short write, 2 parameter */ -#define DTYPE_GEN_LWRITE 0x29 /* long write */ -#define DTYPE_GEN_READ 0x04 /* long read, 0 parameter */ -#define DTYPE_GEN_READ1 0x14 /* long read, 1 parameter */ -#define DTYPE_GEN_READ2 0x24 /* long read, 2 parameter */ - -#define DTYPE_TEAR_ON 0x35 /* set tear on */ -#define DTYPE_MAX_PKTSIZE 0x37 /* set max packet size */ -#define DTYPE_NULL_PKT 0x09 /* null packet, no data */ -#define DTYPE_BLANK_PKT 0x19 /* blankiing packet, no data */ - -#define DTYPE_CM_ON 0x02 /* color mode off */ -#define DTYPE_CM_OFF 0x12 /* color mode on */ -#define DTYPE_PERIPHERAL_OFF 0x22 -#define DTYPE_PERIPHERAL_ON 0x32 - -/* - * dcs response - */ -#define DTYPE_ACK_ERR_RESP 0x02 -#define DTYPE_EOT_RESP 0x08 /* end of tx */ -#define DTYPE_GEN_READ1_RESP 0x11 /* 1 parameter, short */ -#define DTYPE_GEN_READ2_RESP 0x12 /* 2 parameter, short */ -#define DTYPE_GEN_LREAD_RESP 0x1a -#define DTYPE_DCS_LREAD_RESP 0x1c -#define DTYPE_DCS_READ1_RESP 0x21 /* 1 parameter, short */ -#define DTYPE_DCS_READ2_RESP 0x22 /* 2 parameter, short */ - -struct dsi_cmd_desc { - int dtype; - int last; - int vc; - int ack; /* ask ACK from peripheral */ - int wait; - int dlen; - char *payload; -}; - -typedef void (*kickoff_act)(void *); - -struct dsi_kickoff_action { - struct list_head act_entry; - kickoff_act action; - void *data; -}; - - -#define CMD_REQ_MAX 4 - -typedef void (*fxn)(u32 data); - -#define CMD_REQ_RX 0x0001 -#define CMD_REQ_COMMIT 0x0002 -#define CMD_CLK_CTRL 0x0004 -#define CMD_REQ_NO_MAX_PKT_SIZE 0x0008 -#define CMD_MDP3_CMD_PANEL 0x80000000 /* mdp3 only */ - -struct dcs_cmd_req { - struct dsi_cmd_desc *cmds; - int cmds_cnt; - u32 flags; - struct dsi_buf *rbuf; - int rlen; /* rx length */ - fxn cb; -}; - -struct dcs_cmd_list { - int put; - int get; - int tot; - struct dcs_cmd_req list[CMD_REQ_MAX]; -}; - - -char *mipi_dsi_buf_reserve_hdr(struct dsi_buf *dp, int hlen); -char *mipi_dsi_buf_init(struct dsi_buf *dp); -void mipi_dsi_init(void); -void mipi_dsi_lane_cfg(void); -void mipi_dsi_bist_ctrl(void); -int mipi_dsi_buf_alloc(struct dsi_buf *, int size); -int mipi_dsi_cmd_dma_add(struct dsi_buf *dp, struct dsi_cmd_desc *cm); -int mipi_dsi_cmd_reg_tx(uint32 data); -void mipi_dsi_host_init(struct mipi_panel_info *pinfo); -void mipi_dsi_op_mode_config(int mode); -void mipi_dsi_cmd_mode_ctrl(int enable); -void mdp4_dsi_cmd_trigger(void); -void mipi_dsi_cmd_mdp_start(void); -int mipi_dsi_ctrl_lock(int mdp); -int mipi_dsi_ctrl_lock_query(void); -void mipi_dsi_cmd_bta_sw_trigger(void); -void mipi_dsi_ack_err_status(void); -void mipi_dsi_set_tear_on(struct msm_fb_data_type *mfd); -void mipi_dsi_set_tear_off(struct msm_fb_data_type *mfd); -void mipi_dsi_set_backlight(struct msm_fb_data_type *mfd, int level); -void mipi_dsi_cmd_backlight_tx(struct dsi_buf *dp); -void mipi_dsi_pre_kickoff_action(void); -void mipi_dsi_post_kickoff_action(void); -void mipi_dsi_pre_kickoff_add(struct dsi_kickoff_action *act); -void mipi_dsi_post_kickoff_add(struct dsi_kickoff_action *act); -void mipi_dsi_pre_kickoff_del(struct dsi_kickoff_action *act); -void mipi_dsi_post_kickoff_del(struct dsi_kickoff_action *act); -void mipi_dsi_controller_cfg(int enable); -void mipi_dsi_sw_reset(void); -void mipi_dsi_mdp_busy_wait(void); - -irqreturn_t mipi_dsi_isr(int irq, void *ptr); - -void mipi_set_tx_power_mode(int mode); -void mipi_dsi_phy_init(int panel_ndx, struct msm_panel_info const *panel_info, - int target_type); -int mipi_dsi_clk_div_config(uint8 bpp, uint8 lanes, - uint32 *expected_dsi_pclk); -int mipi_dsi_clk_init(struct platform_device *pdev); -void mipi_dsi_clk_deinit(struct device *dev); - -#ifdef CONFIG_FB_MSM_MIPI_DSI -void mipi_dsi_clk_enable(void); -void mipi_dsi_clk_disable(void); -void mipi_dsi_prepare_clocks(void); -void mipi_dsi_unprepare_clocks(void); -void mipi_dsi_ahb_ctrl(u32 enable); -void mipi_dsi_phy_ctrl(int on); -#else -static inline void mipi_dsi_clk_enable(void) -{ - /* empty */ -} -void mipi_dsi_clk_disable(void) -{ - /* empty */ -} -void mipi_dsi_prepare_clocks(void) -{ - /* empty */ -} -void mipi_dsi_unprepare_clocks(void) -{ - /* empty */ -} -void mipi_dsi_ahb_ctrl(u32 enable) -{ - /* empty */ -} -void mipi_dsi_phy_ctrl(int on) -{ - /* empty */ -} -#endif - -void cont_splash_clk_ctrl(int enable); -void mipi_dsi_turn_on_clks(void); -void mipi_dsi_turn_off_clks(void); -void mipi_dsi_clk_cfg(int on); - -int mipi_dsi_cmdlist_put(struct dcs_cmd_req *cmdreq); -struct dcs_cmd_req *mipi_dsi_cmdlist_get(void); -void mipi_dsi_cmdlist_commit(int from_mdp); -void mipi_dsi_cmd_mdp_busy(void); - -#ifdef CONFIG_FB_MSM_MDP303 -void update_lane_config(struct msm_panel_info *pinfo); -#endif - -#endif /* MIPI_DSI_H */ diff --git a/drivers/video/msm/mipi_dsi_host.c b/drivers/video/msm/mipi_dsi_host.c deleted file mode 100644 index af45c9a6f4c16cefaa62d3da07a38e9e30014531..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_dsi_host.c +++ /dev/null @@ -1,1675 +0,0 @@ - -/* Copyright (c) 2008-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "msm_fb.h" -#include "mipi_dsi.h" -#include "mdp.h" -#include "mdp4.h" - -static struct completion dsi_dma_comp; -static struct completion dsi_mdp_comp; -static struct dsi_buf dsi_tx_buf; -static struct dsi_buf dsi_rx_buf; -static spinlock_t dsi_irq_lock; -static spinlock_t dsi_mdp_lock; -spinlock_t dsi_clk_lock; -static int dsi_ctrl_lock; -static int dsi_mdp_busy; -static struct mutex cmd_mutex; -static struct mutex clk_mutex; - -static struct list_head pre_kickoff_list; -static struct list_head post_kickoff_list; - -enum { - STAT_DSI_START, - STAT_DSI_ERROR, - STAT_DSI_CMD, - STAT_DSI_MDP -}; - -struct dcs_cmd_list cmdlist; - -#ifdef CONFIG_FB_MSM_MDP40 -void mipi_dsi_mdp_stat_inc(int which) -{ - switch (which) { - case STAT_DSI_START: - mdp4_stat.dsi_mdp_start++; - break; - case STAT_DSI_ERROR: - mdp4_stat.intr_dsi_err++; - break; - case STAT_DSI_CMD: - mdp4_stat.intr_dsi_cmd++; - break; - case STAT_DSI_MDP: - mdp4_stat.intr_dsi_mdp++; - break; - default: - break; - } -} -#else -void mipi_dsi_mdp_stat_inc(int which) -{ -} -#endif - -void mipi_dsi_init(void) -{ - init_completion(&dsi_dma_comp); - init_completion(&dsi_mdp_comp); - mipi_dsi_buf_alloc(&dsi_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&dsi_rx_buf, DSI_BUF_SIZE); - spin_lock_init(&dsi_irq_lock); - spin_lock_init(&dsi_mdp_lock); - spin_lock_init(&dsi_clk_lock); - mutex_init(&cmd_mutex); - mutex_init(&clk_mutex); - - INIT_LIST_HEAD(&pre_kickoff_list); - INIT_LIST_HEAD(&post_kickoff_list); -} - - -static u32 dsi_irq_mask; - -void mipi_dsi_enable_irq(u32 term) -{ - unsigned long flags; - - spin_lock_irqsave(&dsi_irq_lock, flags); - if (dsi_irq_mask & term) { - spin_unlock_irqrestore(&dsi_irq_lock, flags); - return; - } - if (dsi_irq_mask == 0) { - enable_irq(dsi_irq); - pr_debug("%s: IRQ Enable, mask=%x term=%x\n", - __func__, (int)dsi_irq_mask, (int)term); - } - dsi_irq_mask |= term; - spin_unlock_irqrestore(&dsi_irq_lock, flags); -} - -void mipi_dsi_disable_irq(u32 term) -{ - unsigned long flags; - - spin_lock_irqsave(&dsi_irq_lock, flags); - if (!(dsi_irq_mask & term)) { - spin_unlock_irqrestore(&dsi_irq_lock, flags); - return; - } - dsi_irq_mask &= ~term; - if (dsi_irq_mask == 0) { - disable_irq(dsi_irq); - pr_debug("%s: IRQ Disable, mask=%x term=%x\n", - __func__, (int)dsi_irq_mask, (int)term); - } - spin_unlock_irqrestore(&dsi_irq_lock, flags); -} - -/* - * mipi_dsi_disale_irq_nosync() should be called - * from interrupt context - */ -void mipi_dsi_disable_irq_nosync(u32 term) -{ - spin_lock(&dsi_irq_lock); - if (!(dsi_irq_mask & term)) { - spin_unlock(&dsi_irq_lock); - return; - } - dsi_irq_mask &= ~term; - if (dsi_irq_mask == 0) { - disable_irq_nosync(dsi_irq); - pr_debug("%s: IRQ Disable, mask=%x term=%x\n", - __func__, (int)dsi_irq_mask, (int)term); - } - spin_unlock(&dsi_irq_lock); -} - -void mipi_dsi_clk_cfg(int on) -{ - static int dsi_clk_cnt; - - mutex_lock(&clk_mutex); - if (on) { - if (dsi_clk_cnt == 0) { - mipi_dsi_prepare_clocks(); - mipi_dsi_ahb_ctrl(1); - mipi_dsi_clk_enable(); - } - dsi_clk_cnt++; - } else { - if (dsi_clk_cnt) { - dsi_clk_cnt--; - if (dsi_clk_cnt == 0) { - mipi_dsi_clk_disable(); - mipi_dsi_ahb_ctrl(0); - mipi_dsi_unprepare_clocks(); - } - } - } - pr_debug("%s: on=%d clk_cnt=%d pid=%d\n", __func__, - on, dsi_clk_cnt, current->pid); - mutex_unlock(&clk_mutex); -} - -void mipi_dsi_turn_on_clks(void) -{ - mipi_dsi_ahb_ctrl(1); - mipi_dsi_clk_enable(); -} - -void mipi_dsi_turn_off_clks(void) -{ - mipi_dsi_clk_disable(); - mipi_dsi_ahb_ctrl(0); -} - -static void mipi_dsi_action(struct list_head *act_list) -{ - struct list_head *lp; - struct dsi_kickoff_action *act; - - list_for_each(lp, act_list) { - act = list_entry(lp, struct dsi_kickoff_action, act_entry); - if (act && act->action) - act->action(act->data); - } -} - -void mipi_dsi_pre_kickoff_action(void) -{ - mipi_dsi_action(&pre_kickoff_list); -} - -void mipi_dsi_post_kickoff_action(void) -{ - mipi_dsi_action(&post_kickoff_list); -} - -/* - * mipi_dsi_pre_kickoff_add: - * ov_mutex need to be acquired before call this function. - */ -void mipi_dsi_pre_kickoff_add(struct dsi_kickoff_action *act) -{ - if (act) - list_add_tail(&act->act_entry, &pre_kickoff_list); -} - -/* - * mipi_dsi_pre_kickoff_add: - * ov_mutex need to be acquired before call this function. - */ -void mipi_dsi_post_kickoff_add(struct dsi_kickoff_action *act) -{ - if (act) - list_add_tail(&act->act_entry, &post_kickoff_list); -} - -/* - * mipi_dsi_pre_kickoff_add: - * ov_mutex need to be acquired before call this function. - */ -void mipi_dsi_pre_kickoff_del(struct dsi_kickoff_action *act) -{ - if (!list_empty(&pre_kickoff_list) && act) - list_del(&act->act_entry); -} - -/* - * mipi_dsi_pre_kickoff_add: - * ov_mutex need to be acquired before call this function. - */ -void mipi_dsi_post_kickoff_del(struct dsi_kickoff_action *act) -{ - if (!list_empty(&post_kickoff_list) && act) - list_del(&act->act_entry); -} - -/* - * mipi dsi buf mechanism - */ -char *mipi_dsi_buf_reserve(struct dsi_buf *dp, int len) -{ - dp->data += len; - return dp->data; -} - -char *mipi_dsi_buf_unreserve(struct dsi_buf *dp, int len) -{ - dp->data -= len; - return dp->data; -} - -char *mipi_dsi_buf_push(struct dsi_buf *dp, int len) -{ - dp->data -= len; - dp->len += len; - return dp->data; -} - -char *mipi_dsi_buf_reserve_hdr(struct dsi_buf *dp, int hlen) -{ - dp->hdr = (uint32 *)dp->data; - return mipi_dsi_buf_reserve(dp, hlen); -} - -char *mipi_dsi_buf_init(struct dsi_buf *dp) -{ - int off; - - dp->data = dp->start; - off = (int)dp->data; - /* 8 byte align */ - off &= 0x07; - if (off) - off = 8 - off; - dp->data += off; - dp->len = 0; - return dp->data; -} - -int mipi_dsi_buf_alloc(struct dsi_buf *dp, int size) -{ - - dp->start = kmalloc(size, GFP_KERNEL); - if (dp->start == NULL) { - pr_err("%s:%u\n", __func__, __LINE__); - return -ENOMEM; - } - - dp->end = dp->start + size; - dp->size = size; - - if ((int)dp->start & 0x07) - pr_err("%s: buf NOT 8 bytes aligned\n", __func__); - - dp->data = dp->start; - dp->len = 0; - return size; -} - -/* - * mipi dsi gerneric long write - */ -static int mipi_dsi_generic_lwrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - char *bp; - uint32 *hp; - int i, len; - - bp = mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - - /* fill up payload */ - if (cm->payload) { - len = cm->dlen; - len += 3; - len &= ~0x03; /* multipled by 4 */ - for (i = 0; i < cm->dlen; i++) - *bp++ = cm->payload[i]; - - /* append 0xff to the end */ - for (; i < len; i++) - *bp++ = 0xff; - - dp->len += len; - } - - /* fill up header */ - hp = dp->hdr; - *hp = 0; - *hp = DSI_HDR_WC(cm->dlen); - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_LONG_PKT; - *hp |= DSI_HDR_DTYPE(DTYPE_GEN_LWRITE); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; -} - -/* - * mipi dsi gerneric short write with 0, 1 2 parameters - */ -static int mipi_dsi_generic_swrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - int len; - - if (cm->dlen && cm->payload == 0) { - pr_err("%s: NO payload error\n", __func__); - return 0; - } - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - if (cm->last) - *hp |= DSI_HDR_LAST; - - - len = (cm->dlen > 2) ? 2 : cm->dlen; - - if (len == 1) { - *hp |= DSI_HDR_DTYPE(DTYPE_GEN_WRITE1); - *hp |= DSI_HDR_DATA1(cm->payload[0]); - *hp |= DSI_HDR_DATA2(0); - } else if (len == 2) { - *hp |= DSI_HDR_DTYPE(DTYPE_GEN_WRITE2); - *hp |= DSI_HDR_DATA1(cm->payload[0]); - *hp |= DSI_HDR_DATA2(cm->payload[1]); - } else { - *hp |= DSI_HDR_DTYPE(DTYPE_GEN_WRITE); - *hp |= DSI_HDR_DATA1(0); - *hp |= DSI_HDR_DATA2(0); - } - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -/* - * mipi dsi gerneric read with 0, 1 2 parameters - */ -static int mipi_dsi_generic_read(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - int len; - - if (cm->dlen && cm->payload == 0) { - pr_err("%s: NO payload error\n", __func__); - return 0; - } - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_BTA; - if (cm->last) - *hp |= DSI_HDR_LAST; - - len = (cm->dlen > 2) ? 2 : cm->dlen; - - if (len == 1) { - *hp |= DSI_HDR_DTYPE(DTYPE_GEN_READ1); - *hp |= DSI_HDR_DATA1(cm->payload[0]); - *hp |= DSI_HDR_DATA2(0); - } else if (len == 2) { - *hp |= DSI_HDR_DTYPE(DTYPE_GEN_READ2); - *hp |= DSI_HDR_DATA1(cm->payload[0]); - *hp |= DSI_HDR_DATA2(cm->payload[1]); - } else { - *hp |= DSI_HDR_DTYPE(DTYPE_GEN_READ); - *hp |= DSI_HDR_DATA1(0); - *hp |= DSI_HDR_DATA2(0); - } - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - return dp->len; /* 4 bytes */ -} - -/* - * mipi dsi dcs long write - */ -static int mipi_dsi_dcs_lwrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - char *bp; - uint32 *hp; - int i, len; - - bp = mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - - /* - * fill up payload - * dcs command byte (first byte) followed by payload - */ - if (cm->payload) { - len = cm->dlen; - len += 3; - len &= ~0x03; /* multipled by 4 */ - for (i = 0; i < cm->dlen; i++) - *bp++ = cm->payload[i]; - - /* append 0xff to the end */ - for (; i < len; i++) - *bp++ = 0xff; - - dp->len += len; - } - - /* fill up header */ - hp = dp->hdr; - *hp = 0; - *hp = DSI_HDR_WC(cm->dlen); - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_LONG_PKT; - *hp |= DSI_HDR_DTYPE(DTYPE_DCS_LWRITE); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; -} - -/* - * mipi dsi dcs short write with 0 parameters - */ -static int mipi_dsi_dcs_swrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - int len; - - if (cm->payload == 0) { - pr_err("%s: NO payload error\n", __func__); - return -EINVAL; - } - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - if (cm->ack) /* ask ACK trigger msg from peripeheral */ - *hp |= DSI_HDR_BTA; - if (cm->last) - *hp |= DSI_HDR_LAST; - - len = (cm->dlen > 1) ? 1 : cm->dlen; - - *hp |= DSI_HDR_DTYPE(DTYPE_DCS_WRITE); - *hp |= DSI_HDR_DATA1(cm->payload[0]); /* dcs command byte */ - *hp |= DSI_HDR_DATA2(0); - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - return dp->len; -} - -/* - * mipi dsi dcs short write with 1 parameters - */ -static int mipi_dsi_dcs_swrite1(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - if (cm->dlen < 2 || cm->payload == 0) { - pr_err("%s: NO payload error\n", __func__); - return -EINVAL; - } - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - if (cm->ack) /* ask ACK trigger msg from peripeheral */ - *hp |= DSI_HDR_BTA; - if (cm->last) - *hp |= DSI_HDR_LAST; - - *hp |= DSI_HDR_DTYPE(DTYPE_DCS_WRITE1); - *hp |= DSI_HDR_DATA1(cm->payload[0]); /* dcs comamnd byte */ - *hp |= DSI_HDR_DATA2(cm->payload[1]); /* parameter */ - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; -} -/* - * mipi dsi dcs read with 0 parameters - */ - -static int mipi_dsi_dcs_read(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - if (cm->payload == 0) { - pr_err("%s: NO payload error\n", __func__); - return -EINVAL; - } - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_BTA; - *hp |= DSI_HDR_DTYPE(DTYPE_DCS_READ); - if (cm->last) - *hp |= DSI_HDR_LAST; - - *hp |= DSI_HDR_DATA1(cm->payload[0]); /* dcs command byte */ - *hp |= DSI_HDR_DATA2(0); - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -static int mipi_dsi_cm_on(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_DTYPE(DTYPE_CM_ON); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -static int mipi_dsi_cm_off(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_DTYPE(DTYPE_CM_OFF); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -static int mipi_dsi_peripheral_on(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_DTYPE(DTYPE_PERIPHERAL_ON); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -static int mipi_dsi_peripheral_off(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_DTYPE(DTYPE_PERIPHERAL_OFF); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -static int mipi_dsi_set_max_pktsize(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - if (cm->payload == 0) { - pr_err("%s: NO payload error\n", __func__); - return 0; - } - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_DTYPE(DTYPE_MAX_PKTSIZE); - if (cm->last) - *hp |= DSI_HDR_LAST; - - *hp |= DSI_HDR_DATA1(cm->payload[0]); - *hp |= DSI_HDR_DATA2(cm->payload[1]); - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -static int mipi_dsi_null_pkt(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp = DSI_HDR_WC(cm->dlen); - *hp |= DSI_HDR_LONG_PKT; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_DTYPE(DTYPE_NULL_PKT); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -static int mipi_dsi_blank_pkt(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - uint32 *hp; - - mipi_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE); - hp = dp->hdr; - *hp = 0; - *hp = DSI_HDR_WC(cm->dlen); - *hp |= DSI_HDR_LONG_PKT; - *hp |= DSI_HDR_VC(cm->vc); - *hp |= DSI_HDR_DTYPE(DTYPE_BLANK_PKT); - if (cm->last) - *hp |= DSI_HDR_LAST; - - mipi_dsi_buf_push(dp, DSI_HOST_HDR_SIZE); - - return dp->len; /* 4 bytes */ -} - -/* - * prepare cmd buffer to be txed - */ -int mipi_dsi_cmd_dma_add(struct dsi_buf *dp, struct dsi_cmd_desc *cm) -{ - int len = 0; - - switch (cm->dtype) { - case DTYPE_GEN_WRITE: - case DTYPE_GEN_WRITE1: - case DTYPE_GEN_WRITE2: - len = mipi_dsi_generic_swrite(dp, cm); - break; - case DTYPE_GEN_LWRITE: - len = mipi_dsi_generic_lwrite(dp, cm); - break; - case DTYPE_GEN_READ: - case DTYPE_GEN_READ1: - case DTYPE_GEN_READ2: - len = mipi_dsi_generic_read(dp, cm); - break; - case DTYPE_DCS_LWRITE: - len = mipi_dsi_dcs_lwrite(dp, cm); - break; - case DTYPE_DCS_WRITE: - len = mipi_dsi_dcs_swrite(dp, cm); - break; - case DTYPE_DCS_WRITE1: - len = mipi_dsi_dcs_swrite1(dp, cm); - break; - case DTYPE_DCS_READ: - len = mipi_dsi_dcs_read(dp, cm); - break; - case DTYPE_MAX_PKTSIZE: - len = mipi_dsi_set_max_pktsize(dp, cm); - break; - case DTYPE_NULL_PKT: - len = mipi_dsi_null_pkt(dp, cm); - break; - case DTYPE_BLANK_PKT: - len = mipi_dsi_blank_pkt(dp, cm); - break; - case DTYPE_CM_ON: - len = mipi_dsi_cm_on(dp, cm); - break; - case DTYPE_CM_OFF: - len = mipi_dsi_cm_off(dp, cm); - break; - case DTYPE_PERIPHERAL_ON: - len = mipi_dsi_peripheral_on(dp, cm); - break; - case DTYPE_PERIPHERAL_OFF: - len = mipi_dsi_peripheral_off(dp, cm); - break; - default: - pr_debug("%s: dtype=%x NOT supported\n", - __func__, cm->dtype); - break; - - } - - return len; -} - -/* - * mipi_dsi_short_read1_resp: 1 parameter - */ -static int mipi_dsi_short_read1_resp(struct dsi_buf *rp) -{ - /* strip out dcs type */ - rp->data++; - rp->len = 1; - return rp->len; -} - -/* - * mipi_dsi_short_read2_resp: 2 parameter - */ -static int mipi_dsi_short_read2_resp(struct dsi_buf *rp) -{ - /* strip out dcs type */ - rp->data++; - rp->len = 2; - return rp->len; -} - -static int mipi_dsi_long_read_resp(struct dsi_buf *rp) -{ - short len; - - len = rp->data[2]; - len <<= 8; - len |= rp->data[1]; - /* strip out dcs header */ - rp->data += 4; - rp->len -= 4; - /* strip out 2 bytes of checksum */ - rp->len -= 2; - return len; -} - -void mipi_dsi_host_init(struct mipi_panel_info *pinfo) -{ - uint32 dsi_ctrl, intr_ctrl; - uint32 data; - - if (mdp_rev > MDP_REV_41 || mdp_rev == MDP_REV_303) - pinfo->rgb_swap = DSI_RGB_SWAP_RGB; - else - pinfo->rgb_swap = DSI_RGB_SWAP_BGR; - - if (pinfo->mode == DSI_VIDEO_MODE) { - data = 0; - if (pinfo->pulse_mode_hsa_he) - data |= BIT(28); - if (pinfo->hfp_power_stop) - data |= BIT(24); - if (pinfo->hbp_power_stop) - data |= BIT(20); - if (pinfo->hsa_power_stop) - data |= BIT(16); - if (pinfo->eof_bllp_power_stop) - data |= BIT(15); - if (pinfo->bllp_power_stop) - data |= BIT(12); - data |= ((pinfo->traffic_mode & 0x03) << 8); - data |= ((pinfo->dst_format & 0x03) << 4); /* 2 bits */ - data |= (pinfo->vc & 0x03); - MIPI_OUTP(MIPI_DSI_BASE + 0x000c, data); - - data = 0; - data |= ((pinfo->rgb_swap & 0x07) << 12); - if (pinfo->b_sel) - data |= BIT(8); - if (pinfo->g_sel) - data |= BIT(4); - if (pinfo->r_sel) - data |= BIT(0); - MIPI_OUTP(MIPI_DSI_BASE + 0x001c, data); - } else if (pinfo->mode == DSI_CMD_MODE) { - data = 0; - data |= ((pinfo->interleave_max & 0x0f) << 20); - data |= ((pinfo->rgb_swap & 0x07) << 16); - if (pinfo->b_sel) - data |= BIT(12); - if (pinfo->g_sel) - data |= BIT(8); - if (pinfo->r_sel) - data |= BIT(4); - data |= (pinfo->dst_format & 0x0f); /* 4 bits */ - MIPI_OUTP(MIPI_DSI_BASE + 0x003c, data); - - /* DSI_COMMAND_MODE_MDP_DCS_CMD_CTRL */ - data = pinfo->wr_mem_continue & 0x0ff; - data <<= 8; - data |= (pinfo->wr_mem_start & 0x0ff); - if (pinfo->insert_dcs_cmd) - data |= BIT(16); - MIPI_OUTP(MIPI_DSI_BASE + 0x0040, data); - } else - pr_err("%s: Unknown DSI mode=%d\n", __func__, pinfo->mode); - - dsi_ctrl = BIT(8) | BIT(2); /* clock enable & cmd mode */ - intr_ctrl = 0; - intr_ctrl = (DSI_INTR_CMD_DMA_DONE_MASK | DSI_INTR_CMD_MDP_DONE_MASK); - - if (pinfo->crc_check) - dsi_ctrl |= BIT(24); - if (pinfo->ecc_check) - dsi_ctrl |= BIT(20); - if (pinfo->data_lane3) - dsi_ctrl |= BIT(7); - if (pinfo->data_lane2) - dsi_ctrl |= BIT(6); - if (pinfo->data_lane1) - dsi_ctrl |= BIT(5); - if (pinfo->data_lane0) - dsi_ctrl |= BIT(4); - - /* from frame buffer, low power mode */ - /* DSI_COMMAND_MODE_DMA_CTRL */ - MIPI_OUTP(MIPI_DSI_BASE + 0x38, 0x14000000); - - data = 0; - if (pinfo->te_sel) - data |= BIT(31); - data |= pinfo->mdp_trigger << 4;/* cmd mdp trigger */ - data |= pinfo->dma_trigger; /* cmd dma trigger */ - data |= (pinfo->stream & 0x01) << 8; - MIPI_OUTP(MIPI_DSI_BASE + 0x0080, data); /* DSI_TRIG_CTRL */ - - /* DSI_LAN_SWAP_CTRL */ - MIPI_OUTP(MIPI_DSI_BASE + 0x00ac, pinfo->dlane_swap); - - /* clock out ctrl */ - data = pinfo->t_clk_post & 0x3f; /* 6 bits */ - data <<= 8; - data |= pinfo->t_clk_pre & 0x3f; /* 6 bits */ - MIPI_OUTP(MIPI_DSI_BASE + 0xc0, data); /* DSI_CLKOUT_TIMING_CTRL */ - - data = 0; - if (pinfo->rx_eot_ignore) - data |= BIT(4); - if (pinfo->tx_eot_append) - data |= BIT(0); - MIPI_OUTP(MIPI_DSI_BASE + 0x00c8, data); /* DSI_EOT_PACKET_CTRL */ - - - /* allow only ack-err-status to generate interrupt */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0108, 0x13ff3fe0); /* DSI_ERR_INT_MASK0 */ - - intr_ctrl |= DSI_INTR_ERROR_MASK; - MIPI_OUTP(MIPI_DSI_BASE + 0x010c, intr_ctrl); /* DSI_INTL_CTRL */ - - /* turn esc, byte, dsi, pclk, sclk, hclk on */ - if (mdp_rev >= MDP_REV_41) - MIPI_OUTP(MIPI_DSI_BASE + 0x118, 0x23f); /* DSI_CLK_CTRL */ - else - MIPI_OUTP(MIPI_DSI_BASE + 0x118, 0x33f); /* DSI_CLK_CTRL */ - - dsi_ctrl |= BIT(0); /* enable dsi */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0000, dsi_ctrl); - - wmb(); -} - -void mipi_set_tx_power_mode(int mode) -{ - uint32 data = MIPI_INP(MIPI_DSI_BASE + 0x38); - - if (mode == 0) - data &= ~BIT(26); - else - data |= BIT(26); - - MIPI_OUTP(MIPI_DSI_BASE + 0x38, data); -} - -void mipi_dsi_sw_reset(void) -{ - MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0x01); - wmb(); - MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0x00); - wmb(); -} - -void mipi_dsi_controller_cfg(int enable) -{ - - uint32 dsi_ctrl; - uint32 status; - u32 sleep_us = 1000; - u32 timeout_us = 16000; - - /* Check for CMD_MODE_DMA_BUSY */ - if (readl_poll_timeout((MIPI_DSI_BASE + 0x0004), - status, - ((status & 0x02) == 0), - sleep_us, timeout_us)) - pr_info("%s: DSI status=%x failed\n", __func__, status); - - /* Check for x_HS_FIFO_EMPTY */ - if (readl_poll_timeout((MIPI_DSI_BASE + 0x0008), - status, - ((status & 0x11111000) == 0x11111000), - sleep_us, timeout_us)) - pr_info("%s: FIFO status=%x failed\n", __func__, status); - - /* Check for VIDEO_MODE_ENGINE_BUSY */ - if (readl_poll_timeout((MIPI_DSI_BASE + 0x0004), - status, - ((status & 0x08) == 0), - sleep_us, timeout_us)) - pr_info("%s: DSI status=%x failed\n", __func__, status); - - dsi_ctrl = MIPI_INP(MIPI_DSI_BASE + 0x0000); - if (enable) - dsi_ctrl |= 0x01; - else - dsi_ctrl &= ~0x01; - - MIPI_OUTP(MIPI_DSI_BASE + 0x0000, dsi_ctrl); - wmb(); -} - -void mipi_dsi_op_mode_config(int mode) -{ - - uint32 dsi_ctrl, intr_ctrl; - - dsi_ctrl = MIPI_INP(MIPI_DSI_BASE + 0x0000); - dsi_ctrl &= ~0x07; - if (mode == DSI_VIDEO_MODE) { - dsi_ctrl |= 0x03; - intr_ctrl = DSI_INTR_CMD_DMA_DONE_MASK; - } else { /* command mode */ - dsi_ctrl |= 0x05; - intr_ctrl = DSI_INTR_CMD_DMA_DONE_MASK | DSI_INTR_ERROR_MASK | - DSI_INTR_CMD_MDP_DONE_MASK; - } - - pr_debug("%s: dsi_ctrl=%x intr=%x\n", __func__, dsi_ctrl, intr_ctrl); - - MIPI_OUTP(MIPI_DSI_BASE + 0x010c, intr_ctrl); /* DSI_INTL_CTRL */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0000, dsi_ctrl); - wmb(); -} - -void mipi_dsi_mdp_busy_wait(void) -{ - mutex_lock(&cmd_mutex); - mipi_dsi_cmd_mdp_busy(); - mutex_unlock(&cmd_mutex); -} - -void mipi_dsi_cmd_mdp_start(void) -{ - unsigned long flag; - - mipi_dsi_mdp_stat_inc(STAT_DSI_START); - - spin_lock_irqsave(&dsi_mdp_lock, flag); - mipi_dsi_enable_irq(DSI_MDP_TERM); - dsi_mdp_busy = TRUE; - INIT_COMPLETION(dsi_mdp_comp); - spin_unlock_irqrestore(&dsi_mdp_lock, flag); -} - -void mipi_dsi_cmd_bta_sw_trigger(void) -{ - uint32 data; - int cnt = 0; - - MIPI_OUTP(MIPI_DSI_BASE + 0x094, 0x01); /* trigger */ - wmb(); - - while (cnt < 10000) { - data = MIPI_INP(MIPI_DSI_BASE + 0x0004);/* DSI_STATUS */ - if ((data & 0x0010) == 0) - break; - cnt++; - } - - mipi_dsi_ack_err_status(); - - pr_debug("%s: BTA done, cnt=%d\n", __func__, cnt); -} - -static char set_tear_on[2] = {0x35, 0x00}; -static struct dsi_cmd_desc dsi_tear_on_cmd = { - DTYPE_DCS_WRITE1, 1, 0, 0, 0, sizeof(set_tear_on), set_tear_on}; - -static char set_tear_off[2] = {0x34, 0x00}; -static struct dsi_cmd_desc dsi_tear_off_cmd = { - DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(set_tear_off), set_tear_off}; - -void mipi_dsi_set_tear_on(struct msm_fb_data_type *mfd) -{ - struct dcs_cmd_req cmdreq; - - cmdreq.cmds = &dsi_tear_on_cmd; - cmdreq.cmds_cnt = 1; - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - - mipi_dsi_cmdlist_put(&cmdreq); -} - -void mipi_dsi_set_tear_off(struct msm_fb_data_type *mfd) -{ - struct dcs_cmd_req cmdreq; - - cmdreq.cmds = &dsi_tear_off_cmd; - cmdreq.cmds_cnt = 1; - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - - mipi_dsi_cmdlist_put(&cmdreq); -} - -int mipi_dsi_cmd_reg_tx(uint32 data) -{ -#ifdef DSI_HOST_DEBUG - int i; - char *bp; - - bp = (char *)&data; - pr_debug("%s: ", __func__); - for (i = 0; i < 4; i++) - pr_debug("%x ", *bp++); - - pr_debug("\n"); -#endif - - MIPI_OUTP(MIPI_DSI_BASE + 0x0080, 0x04);/* sw trigger */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0, 0x135); - - wmb(); - - MIPI_OUTP(MIPI_DSI_BASE + 0x038, data); - wmb(); - MIPI_OUTP(MIPI_DSI_BASE + 0x08c, 0x01); /* trigger */ - wmb(); - - udelay(300); - - return 4; -} - -static int mipi_dsi_cmd_dma_tx(struct dsi_buf *tp); -static int mipi_dsi_cmd_dma_rx(struct dsi_buf *rp, int rlen); - -/* - * mipi_dsi_cmds_tx: - * thread context only - */ -static int mipi_dsi_cmds_tx(struct dsi_buf *tp, - struct dsi_cmd_desc *cmds, int cnt) -{ - struct dsi_cmd_desc *cm; - uint32 dsi_ctrl, ctrl; - int i, video_mode; - - /* turn on cmd mode - * for video mode, do not send cmds more than - * one pixel line, since it only transmit it - * during BLLP. - */ - dsi_ctrl = MIPI_INP(MIPI_DSI_BASE + 0x0000); - video_mode = dsi_ctrl & 0x02; /* VIDEO_MODE_EN */ - if (video_mode) { - ctrl = dsi_ctrl | 0x04; /* CMD_MODE_EN */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0000, ctrl); - } - - cm = cmds; - mipi_dsi_buf_init(tp); - for (i = 0; i < cnt; i++) { - mipi_dsi_enable_irq(DSI_CMD_TERM); - mipi_dsi_buf_init(tp); - mipi_dsi_cmd_dma_add(tp, cm); - mipi_dsi_cmd_dma_tx(tp); - if (cm->wait) - msleep(cm->wait); - cm++; - } - - if (video_mode) - MIPI_OUTP(MIPI_DSI_BASE + 0x0000, dsi_ctrl); /* restore */ - - return cnt; -} - -/* MIPI_DSI_MRPS, Maximum Return Packet Size */ -static char max_pktsize[2] = {0x00, 0x00}; /* LSB tx first, 10 bytes */ - -static struct dsi_cmd_desc pkt_size_cmd[] = { - {DTYPE_MAX_PKTSIZE, 1, 0, 0, 0, - sizeof(max_pktsize), max_pktsize} -}; - -/* - * DSI panel reply with MAX_RETURN_PACKET_SIZE bytes of data - * plus DCS header, ECC and CRC for DCS long read response - * mipi_dsi_controller only have 4x32 bits register ( 16 bytes) to - * hold data per transaction. - * MIPI_DSI_LEN equal to 8 - * len should be either 4 or 8 - * any return data more than MIPI_DSI_LEN need to be break down - * to multiple transactions. - */ -static int mipi_dsi_cmds_rx(struct dsi_buf *tp, struct dsi_buf *rp, - struct dcs_cmd_req *req, int rlen) -{ - struct dsi_cmd_desc *cmds; - int cnt, len, diff, pkt_size; - char cmd; - - if (req->flags & CMD_REQ_NO_MAX_PKT_SIZE) { - /* Only support rlen = 4*n */ - rlen += 3; - rlen &= ~0x03; - } - - cmds = req->cmds; - - len = rlen; - diff = 0; - - if (len <= 2) - cnt = 4; /* short read */ - else { - if (len > MIPI_DSI_LEN) - len = MIPI_DSI_LEN; /* 8 bytes at most */ - - len = (len + 3) & ~0x03; /* len 4 bytes align */ - diff = len - rlen; - /* - * add extra 2 bytes to len to have overall - * packet size is multipe by 4. This also make - * sure 4 bytes dcs headerlocates within a - * 32 bits register after shift in. - * after all, len should be either 6 or 10. - */ - len += 2; - cnt = len + 6; /* 4 bytes header + 2 bytes crc */ - } - - if (!(req->flags & CMD_REQ_NO_MAX_PKT_SIZE)) { - - - /* packet size need to be set at every read */ - pkt_size = len; - max_pktsize[0] = pkt_size; - mipi_dsi_enable_irq(DSI_CMD_TERM); - mipi_dsi_buf_init(tp); - mipi_dsi_cmd_dma_add(tp, pkt_size_cmd); - mipi_dsi_cmd_dma_tx(tp); - } - - mipi_dsi_enable_irq(DSI_CMD_TERM); - mipi_dsi_buf_init(tp); - mipi_dsi_cmd_dma_add(tp, cmds); - - /* transmit read comamnd to client */ - mipi_dsi_cmd_dma_tx(tp); - - /* - * once cmd_dma_done interrupt received, - * return data from client is ready and stored - * at RDBK_DATA register already - */ - mipi_dsi_buf_init(rp); - if (req->flags & CMD_REQ_NO_MAX_PKT_SIZE) { - /* - * expect rlen = n * 4 - * short alignement for start addr - */ - rp->data += 2; - } - - mipi_dsi_cmd_dma_rx(rp, cnt); - - if (req->flags & CMD_REQ_NO_MAX_PKT_SIZE) { - /* - * remove extra 2 bytes from previous - * rx transaction at shift register - * which was inserted during copy - * shift registers to rx buffer - * rx payload start from long alignment addr - */ - rp->data += 2; - } - - cmd = rp->data[0]; - switch (cmd) { - case DTYPE_ACK_ERR_RESP: - pr_debug("%s: rx ACK_ERR_PACLAGE\n", __func__); - break; - case DTYPE_GEN_READ1_RESP: - case DTYPE_DCS_READ1_RESP: - mipi_dsi_short_read1_resp(rp); - break; - case DTYPE_GEN_READ2_RESP: - case DTYPE_DCS_READ2_RESP: - mipi_dsi_short_read2_resp(rp); - break; - case DTYPE_GEN_LREAD_RESP: - case DTYPE_DCS_LREAD_RESP: - mipi_dsi_long_read_resp(rp); - rp->len -= 2; /* extra 2 bytes added */ - rp->len -= diff; /* align bytes */ - break; - default: - break; - } - - return rp->len; -} - -static int mipi_dsi_cmd_dma_tx(struct dsi_buf *tp) -{ - - unsigned long flags; - -#ifdef DSI_HOST_DEBUG - int i; - char *bp; - - bp = tp->data; - - pr_debug("%s: ", __func__); - for (i = 0; i < tp->len; i++) - pr_debug("%x ", *bp++); - - pr_debug("\n"); -#endif - - if (tp->len == 0) { - pr_err("%s: Error, len=0\n", __func__); - return 0; - } - - spin_lock_irqsave(&dsi_mdp_lock, flags); - tp->len += 3; - tp->len &= ~0x03; /* multipled by 4 */ - - tp->dmap = dma_map_single(&dsi_dev, tp->data, tp->len, DMA_TO_DEVICE); - if (dma_mapping_error(&dsi_dev, tp->dmap)) - pr_err("%s: dmap mapp failed\n", __func__); - - INIT_COMPLETION(dsi_dma_comp); - - MIPI_OUTP(MIPI_DSI_BASE + 0x044, tp->dmap); - MIPI_OUTP(MIPI_DSI_BASE + 0x048, tp->len); - wmb(); - MIPI_OUTP(MIPI_DSI_BASE + 0x08c, 0x01); /* trigger */ - wmb(); - spin_unlock_irqrestore(&dsi_mdp_lock, flags); - - wait_for_completion(&dsi_dma_comp); - - dma_unmap_single(&dsi_dev, tp->dmap, tp->len, DMA_TO_DEVICE); - tp->dmap = 0; - return tp->len; -} - -static int mipi_dsi_cmd_dma_rx(struct dsi_buf *rp, int rlen) -{ - uint32 *lp, data; - int i, off, cnt; - - lp = (uint32 *)rp->data; - cnt = rlen; - cnt += 3; - cnt >>= 2; - - if (cnt > 4) - cnt = 4; /* 4 x 32 bits registers only */ - - off = 0x068; /* DSI_RDBK_DATA0 */ - off += ((cnt - 1) * 4); - - - for (i = 0; i < cnt; i++) { - data = (uint32)MIPI_INP(MIPI_DSI_BASE + off); - *lp++ = ntohl(data); /* to network byte order */ - off -= 4; - rp->len += sizeof(*lp); - } - - return rlen; -} - -static void mipi_dsi_wait_for_video_eng_busy(void) -{ - u32 status; - int sleep_us = 4000; - - /* - * if video mode engine was not busy (in BLLP) - * wait to pass BLLP - */ - - /* check for VIDEO_MODE_ENGINE_BUSY */ - readl_poll((MIPI_DSI_BASE + 0x0004), /* DSI_STATUS */ - status, - (status & 0x08), - sleep_us); -} - -void mipi_dsi_cmd_mdp_busy(void) -{ - unsigned long flags; - int need_wait = 0; - - pr_debug("%s: start pid=%d\n", - __func__, current->pid); - spin_lock_irqsave(&dsi_mdp_lock, flags); - if (dsi_mdp_busy == TRUE) - need_wait++; - spin_unlock_irqrestore(&dsi_mdp_lock, flags); - - if (need_wait) { - /* wait until DMA finishes the current job */ - pr_debug("%s: pending pid=%d\n", - __func__, current->pid); - wait_for_completion(&dsi_mdp_comp); - } - pr_debug("%s: done pid=%d\n", - __func__, current->pid); -} - -/* - * mipi_dsi_cmd_get: cmd_mutex acquired by caller - */ -struct dcs_cmd_req *mipi_dsi_cmdlist_get(void) -{ - struct dcs_cmd_req *req = NULL; - - if (cmdlist.get != cmdlist.put) { - req = &cmdlist.list[cmdlist.get]; - cmdlist.get++; - cmdlist.get %= CMD_REQ_MAX; - cmdlist.tot--; - pr_debug("%s: tot=%d put=%d get=%d\n", __func__, - cmdlist.tot, cmdlist.put, cmdlist.get); - } - return req; -} -void mipi_dsi_cmdlist_tx(struct dcs_cmd_req *req) -{ - struct dsi_buf *tp; - int ret; - - mipi_dsi_buf_init(&dsi_tx_buf); - tp = &dsi_tx_buf; - ret = mipi_dsi_cmds_tx(tp, req->cmds, req->cmds_cnt); - - if (req->cb) - req->cb(ret); - -} - -void mipi_dsi_cmdlist_rx(struct dcs_cmd_req *req) -{ - int len; - u32 *dp; - struct dsi_buf *tp; - struct dsi_buf *rp; - - mipi_dsi_buf_init(&dsi_tx_buf); - - tp = &dsi_tx_buf; - - if (req->rbuf) - rp = req->rbuf; - else - rp = &dsi_rx_buf; - - mipi_dsi_buf_init(rp); - - len = mipi_dsi_cmds_rx(tp, rp, req, req->rlen); - dp = (u32 *)rp->data; - - if (req->cb) - req->cb(*dp); -} - -void mipi_dsi_cmdlist_commit(int from_mdp) -{ - struct dcs_cmd_req *req; - u32 dsi_ctrl; - - mutex_lock(&cmd_mutex); - req = mipi_dsi_cmdlist_get(); - - /* make sure dsi_cmd_mdp is idle */ - mipi_dsi_cmd_mdp_busy(); - - if (req == NULL) - goto need_lock; - - pr_debug("%s: from_mdp=%d pid=%d\n", __func__, from_mdp, current->pid); - - dsi_ctrl = MIPI_INP(MIPI_DSI_BASE + 0x0000); - if (dsi_ctrl & 0x02) { - /* video mode, make sure dsi_cmd_mdp is busy - * so dcs command will be txed at start of BLLP - */ - mipi_dsi_wait_for_video_eng_busy(); - } else { - /* command mode */ - if (!from_mdp) { /* cmdlist_put */ - /* make sure dsi_cmd_mdp is idle */ - mipi_dsi_cmd_mdp_busy(); - } - } - - if (req->flags & CMD_REQ_RX) - mipi_dsi_cmdlist_rx(req); - else - mipi_dsi_cmdlist_tx(req); - -need_lock: - - if (from_mdp) /* from pipe_commit */ - mipi_dsi_cmd_mdp_start(); - - mutex_unlock(&cmd_mutex); -} - -int mipi_dsi_cmdlist_put(struct dcs_cmd_req *cmdreq) -{ - struct dcs_cmd_req *req; - int ret = 0; - - mutex_lock(&cmd_mutex); - req = &cmdlist.list[cmdlist.put]; - *req = *cmdreq; - cmdlist.put++; - cmdlist.put %= CMD_REQ_MAX; - cmdlist.tot++; - if (cmdlist.put == cmdlist.get) { - /* drop the oldest one */ - pr_debug("%s: DROP, tot=%d put=%d get=%d\n", __func__, - cmdlist.tot, cmdlist.put, cmdlist.get); - cmdlist.get++; - cmdlist.get %= CMD_REQ_MAX; - cmdlist.tot--; - } - mutex_unlock(&cmd_mutex); - - ret++; - pr_debug("%s: tot=%d put=%d get=%d\n", __func__, - cmdlist.tot, cmdlist.put, cmdlist.get); - - if (req->flags & CMD_CLK_CTRL) - mipi_dsi_clk_cfg(1); - - if (req->flags & CMD_REQ_COMMIT) - mipi_dsi_cmdlist_commit(0); - - if (req->flags & CMD_CLK_CTRL) - mipi_dsi_clk_cfg(0); - - return ret; -} - -void mipi_dsi_irq_set(uint32 mask, uint32 irq) -{ - uint32 data; - - data = MIPI_INP(MIPI_DSI_BASE + 0x010c);/* DSI_INTR_CTRL */ - data &= ~mask; - data |= irq; - MIPI_OUTP(MIPI_DSI_BASE + 0x010c, data); -} - - -void mipi_dsi_ack_err_status(void) -{ - uint32 status; - - status = MIPI_INP(MIPI_DSI_BASE + 0x0064);/* DSI_ACK_ERR_STATUS */ - - if (status) { - MIPI_OUTP(MIPI_DSI_BASE + 0x0064, status); - pr_debug("%s: status=%x\n", __func__, status); - } -} - -void mipi_dsi_timeout_status(void) -{ - uint32 status; - - status = MIPI_INP(MIPI_DSI_BASE + 0x00bc);/* DSI_TIMEOUT_STATUS */ - if (status & 0x0111) { - MIPI_OUTP(MIPI_DSI_BASE + 0x00bc, status); - pr_debug("%s: status=%x\n", __func__, status); - } -} - -void mipi_dsi_dln0_phy_err(void) -{ - uint32 status; - - status = MIPI_INP(MIPI_DSI_BASE + 0x00b0);/* DSI_DLN0_PHY_ERR */ - - if (status & 0x011111) { - MIPI_OUTP(MIPI_DSI_BASE + 0x00b0, status); - pr_debug("%s: status=%x\n", __func__, status); - } -} - -void mipi_dsi_fifo_status(void) -{ - uint32 status; - - status = MIPI_INP(MIPI_DSI_BASE + 0x0008);/* DSI_FIFO_STATUS */ - - if (status & 0x44444489) { - MIPI_OUTP(MIPI_DSI_BASE + 0x0008, status); - pr_debug("%s: status=%x\n", __func__, status); - } -} - -void mipi_dsi_status(void) -{ - uint32 status; - - status = MIPI_INP(MIPI_DSI_BASE + 0x0004);/* DSI_STATUS */ - - if (status & 0x80000000) { - MIPI_OUTP(MIPI_DSI_BASE + 0x0004, status); - pr_debug("%s: status=%x\n", __func__, status); - } -} - -void mipi_dsi_error(void) -{ - /* DSI_ERR_INT_MASK0 */ - mipi_dsi_ack_err_status(); /* mask0, 0x01f */ - mipi_dsi_timeout_status(); /* mask0, 0x0e0 */ - mipi_dsi_fifo_status(); /* mask0, 0x133d00 */ - mipi_dsi_status(); /* mask0, 0xc0100 */ - mipi_dsi_dln0_phy_err(); /* mask0, 0x3e00000 */ -} - - -irqreturn_t mipi_dsi_isr(int irq, void *ptr) -{ - uint32 isr; - - isr = MIPI_INP(MIPI_DSI_BASE + 0x010c);/* DSI_INTR_CTRL */ - MIPI_OUTP(MIPI_DSI_BASE + 0x010c, isr); - - pr_debug("%s: isr=%x\n", __func__, (int)isr); - -#ifdef CONFIG_FB_MSM_MDP40 - mdp4_stat.intr_dsi++; -#endif - if (isr & DSI_INTR_ERROR) { - mipi_dsi_mdp_stat_inc(STAT_DSI_ERROR); - mipi_dsi_error(); - } - - if (isr & DSI_INTR_VIDEO_DONE) { - /* - * do something here - */ - } - - if (isr & DSI_INTR_CMD_DMA_DONE) { - mipi_dsi_mdp_stat_inc(STAT_DSI_CMD); - spin_lock(&dsi_mdp_lock); - complete(&dsi_dma_comp); - dsi_ctrl_lock = FALSE; - mipi_dsi_disable_irq_nosync(DSI_CMD_TERM); - spin_unlock(&dsi_mdp_lock); - } - - if (isr & DSI_INTR_CMD_MDP_DONE) { - mipi_dsi_mdp_stat_inc(STAT_DSI_MDP); - spin_lock(&dsi_mdp_lock); - dsi_ctrl_lock = FALSE; - dsi_mdp_busy = FALSE; - mipi_dsi_disable_irq_nosync(DSI_MDP_TERM); - complete(&dsi_mdp_comp); - spin_unlock(&dsi_mdp_lock); - } - - - return IRQ_HANDLED; -} diff --git a/drivers/video/msm/mipi_novatek.c b/drivers/video/msm/mipi_novatek.c deleted file mode 100644 index b97d844e97eaf3e3cf31e85787df0bd1ab4227f7..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_novatek.c +++ /dev/null @@ -1,689 +0,0 @@ -/* Copyright (c) 2010-2012, 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. - * - */ - -#ifdef CONFIG_SPI_QUP -#include -#endif -#include -#include "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_novatek.h" -#include "mdp4.h" - - -static struct mipi_dsi_panel_platform_data *mipi_novatek_pdata; - -static struct dsi_buf novatek_tx_buf; -static struct dsi_buf novatek_rx_buf; -static int mipi_novatek_lcd_init(void); - -static int wled_trigger_initialized; - -#define MIPI_DSI_NOVATEK_SPI_DEVICE_NAME "dsi_novatek_3d_panel_spi" -#define HPCI_FPGA_READ_CMD 0x84 -#define HPCI_FPGA_WRITE_CMD 0x04 - -#ifdef CONFIG_SPI_QUP -static struct spi_device *panel_3d_spi_client; - -static void novatek_fpga_write(uint8 addr, uint16 value) -{ - char tx_buf[32]; - int rc; - struct spi_message m; - struct spi_transfer t; - u8 data[4] = {0x0, 0x0, 0x0, 0x0}; - - if (!panel_3d_spi_client) { - pr_err("%s panel_3d_spi_client is NULL\n", __func__); - return; - } - data[0] = HPCI_FPGA_WRITE_CMD; - data[1] = addr; - data[2] = ((value >> 8) & 0xFF); - data[3] = (value & 0xFF); - - memset(&t, 0, sizeof t); - memset(tx_buf, 0, sizeof tx_buf); - t.tx_buf = data; - t.len = 4; - spi_setup(panel_3d_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - - rc = spi_sync(panel_3d_spi_client, &m); - if (rc) - pr_err("%s: SPI transfer failed\n", __func__); - - return; -} - -static void novatek_fpga_read(uint8 addr) -{ - char tx_buf[32]; - int rc; - struct spi_message m; - struct spi_transfer t; - struct spi_transfer rx; - char rx_value[2]; - u8 data[4] = {0x0, 0x0}; - - if (!panel_3d_spi_client) { - pr_err("%s panel_3d_spi_client is NULL\n", __func__); - return; - } - - data[0] = HPCI_FPGA_READ_CMD; - data[1] = addr; - - memset(&t, 0, sizeof t); - memset(tx_buf, 0, sizeof tx_buf); - memset(&rx, 0, sizeof rx); - memset(rx_value, 0, sizeof rx_value); - t.tx_buf = data; - t.len = 2; - rx.rx_buf = rx_value; - rx.len = 2; - spi_setup(panel_3d_spi_client); - spi_message_init(&m); - spi_message_add_tail(&t, &m); - spi_message_add_tail(&rx, &m); - - rc = spi_sync(panel_3d_spi_client, &m); - if (rc) - pr_err("%s: SPI transfer failed\n", __func__); - else - pr_info("%s: rx_value = 0x%x, 0x%x\n", __func__, - rx_value[0], rx_value[1]); - - return; -} - -static int panel_3d_spi_probe(struct spi_device *spi) -{ - panel_3d_spi_client = spi; - return 0; -} -static int panel_3d_spi_remove(struct spi_device *spi) -{ - panel_3d_spi_client = NULL; - return 0; -} -static struct spi_driver panel_3d_spi_driver = { - .probe = panel_3d_spi_probe, - .remove = panel_3d_spi_remove, - .driver = { - .name = "dsi_novatek_3d_panel_spi", - .owner = THIS_MODULE, - } -}; - -#else - -static void novatek_fpga_write(uint8 addr, uint16 value) -{ - return; -} - -static void novatek_fpga_read(uint8 addr) -{ - return; -} - -#endif - - -/* novatek blue panel */ - -#ifdef NOVETAK_COMMANDS_UNUSED -static char display_config_cmd_mode1[] = { - /* TYPE_DCS_LWRITE */ - 0x2A, 0x00, 0x00, 0x01, - 0x3F, 0xFF, 0xFF, 0xFF -}; - -static char display_config_cmd_mode2[] = { - /* DTYPE_DCS_LWRITE */ - 0x2B, 0x00, 0x00, 0x01, - 0xDF, 0xFF, 0xFF, 0xFF -}; - -static char display_config_cmd_mode3_666[] = { - /* DTYPE_DCS_WRITE1 */ - 0x3A, 0x66, 0x15, 0x80 /* 666 Packed (18-bits) */ -}; - -static char display_config_cmd_mode3_565[] = { - /* DTYPE_DCS_WRITE1 */ - 0x3A, 0x55, 0x15, 0x80 /* 565 mode */ -}; - -static char display_config_321[] = { - /* DTYPE_DCS_WRITE1 */ - 0x66, 0x2e, 0x15, 0x00 /* Reg 0x66 : 2E */ -}; - -static char display_config_323[] = { - /* DTYPE_DCS_WRITE */ - 0x13, 0x00, 0x05, 0x00 /* Reg 0x13 < Set for Normal Mode> */ -}; - -static char display_config_2lan[] = { - /* DTYPE_DCS_WRITE */ - 0x61, 0x01, 0x02, 0xff /* Reg 0x61 : 01,02 < Set for 2 Data Lane > */ -}; - -static char display_config_exit_sleep[] = { - /* DTYPE_DCS_WRITE */ - 0x11, 0x00, 0x05, 0x80 /* Reg 0x11 < exit sleep mode> */ -}; - -static char display_config_TE_ON[] = { - /* DTYPE_DCS_WRITE1 */ - 0x35, 0x00, 0x15, 0x80 -}; - -static char display_config_39H[] = { - /* DTYPE_DCS_WRITE */ - 0x39, 0x00, 0x05, 0x80 -}; - -static char display_config_set_tear_scanline[] = { - /* DTYPE_DCS_LWRITE */ - 0x44, 0x00, 0x00, 0xff -}; - -static char display_config_set_twolane[] = { - /* DTYPE_DCS_WRITE1 */ - 0xae, 0x03, 0x15, 0x80 -}; - -static char display_config_set_threelane[] = { - /* DTYPE_DCS_WRITE1 */ - 0xae, 0x05, 0x15, 0x80 -}; - -#else - -static char sw_reset[2] = {0x01, 0x00}; /* DTYPE_DCS_WRITE */ -static char enter_sleep[2] = {0x10, 0x00}; /* DTYPE_DCS_WRITE */ -static char exit_sleep[2] = {0x11, 0x00}; /* DTYPE_DCS_WRITE */ -static char display_off[2] = {0x28, 0x00}; /* DTYPE_DCS_WRITE */ -static char display_on[2] = {0x29, 0x00}; /* DTYPE_DCS_WRITE */ - - - -static char rgb_888[2] = {0x3A, 0x77}; /* DTYPE_DCS_WRITE1 */ - -#if defined(NOVATEK_TWO_LANE) -static char set_num_of_lanes[2] = {0xae, 0x03}; /* DTYPE_DCS_WRITE1 */ -#else /* 1 lane */ -static char set_num_of_lanes[2] = {0xae, 0x01}; /* DTYPE_DCS_WRITE1 */ -#endif -/* commands by Novatke */ -static char novatek_f4[2] = {0xf4, 0x55}; /* DTYPE_DCS_WRITE1 */ -static char novatek_8c[16] = { /* DTYPE_DCS_LWRITE */ - 0x8C, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x08, 0x00, 0x30, 0xC0, 0xB7, 0x37}; -static char novatek_ff[2] = {0xff, 0x55 }; /* DTYPE_DCS_WRITE1 */ - -static char set_width[5] = { /* DTYPE_DCS_LWRITE */ - 0x2A, 0x00, 0x00, 0x02, 0x1B}; /* 540 - 1 */ -static char set_height[5] = { /* DTYPE_DCS_LWRITE */ - 0x2B, 0x00, 0x00, 0x03, 0xBF}; /* 960 - 1 */ -#endif - -static char led_pwm2[2] = {0x53, 0x24}; /* DTYPE_DCS_WRITE1 */ -static char led_pwm3[2] = {0x55, 0x00}; /* DTYPE_DCS_WRITE1 */ - -static struct dsi_cmd_desc novatek_video_on_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 50, - sizeof(sw_reset), sw_reset}, - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(display_on), display_on}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 10, - sizeof(set_num_of_lanes), set_num_of_lanes}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 10, - sizeof(rgb_888), rgb_888}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 10, - sizeof(led_pwm2), led_pwm2}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 10, - sizeof(led_pwm3), led_pwm3}, -}; - -static struct dsi_cmd_desc novatek_cmd_on_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 50, - sizeof(sw_reset), sw_reset}, - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(display_on), display_on}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 50, - sizeof(novatek_f4), novatek_f4}, - {DTYPE_DCS_LWRITE, 1, 0, 0, 50, - sizeof(novatek_8c), novatek_8c}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 50, - sizeof(novatek_ff), novatek_ff}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 10, - sizeof(set_num_of_lanes), set_num_of_lanes}, - {DTYPE_DCS_LWRITE, 1, 0, 0, 50, - sizeof(set_width), set_width}, - {DTYPE_DCS_LWRITE, 1, 0, 0, 50, - sizeof(set_height), set_height}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 10, - sizeof(rgb_888), rgb_888}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 1, - sizeof(led_pwm2), led_pwm2}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 1, - sizeof(led_pwm3), led_pwm3}, -}; - -static struct dsi_cmd_desc novatek_display_off_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(display_off), display_off}, - {DTYPE_DCS_WRITE, 1, 0, 0, 120, - sizeof(enter_sleep), enter_sleep} -}; - -static char manufacture_id[2] = {0x04, 0x00}; /* DTYPE_DCS_READ */ - -static struct dsi_cmd_desc novatek_manufacture_id_cmd = { - DTYPE_DCS_READ, 1, 0, 1, 5, sizeof(manufacture_id), manufacture_id}; - -static u32 manu_id; - -static void mipi_novatek_manufacture_cb(u32 data) -{ - manu_id = data; - pr_info("%s: manufacture_id=%x\n", __func__, manu_id); -} - -static uint32 mipi_novatek_manufacture_id(struct msm_fb_data_type *mfd) -{ - struct dcs_cmd_req cmdreq; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = &novatek_manufacture_id_cmd; - cmdreq.cmds_cnt = 1; - cmdreq.flags = CMD_REQ_RX | CMD_REQ_COMMIT; - cmdreq.rlen = 3; - cmdreq.rbuf = NULL; - cmdreq.cb = mipi_novatek_manufacture_cb; /* call back */ - mipi_dsi_cmdlist_put(&cmdreq); - /* - * blocked here, untill call back called - */ - - return manu_id; -} - -static int fpga_addr; -static int fpga_access_mode; -static bool support_3d; - -static void mipi_novatek_3d_init(int addr, int mode) -{ - fpga_addr = addr; - fpga_access_mode = mode; -} - -static void mipi_dsi_enable_3d_barrier(int mode) -{ - void __iomem *fpga_ptr; - uint32_t ptr_value = 0; - - if (!fpga_addr && support_3d) { - pr_err("%s: fpga_addr not set. Failed to enable 3D barrier\n", - __func__); - return; - } - - if (fpga_access_mode == FPGA_SPI_INTF) { - if (mode == LANDSCAPE) - novatek_fpga_write(fpga_addr, 1); - else if (mode == PORTRAIT) - novatek_fpga_write(fpga_addr, 3); - else - novatek_fpga_write(fpga_addr, 0); - - mb(); - novatek_fpga_read(fpga_addr); - } else if (fpga_access_mode == FPGA_EBI2_INTF) { - fpga_ptr = ioremap_nocache(fpga_addr, sizeof(uint32_t)); - if (!fpga_ptr) { - pr_err("%s: FPGA ioremap failed." - "Failed to enable 3D barrier\n", - __func__); - return; - } - - ptr_value = readl_relaxed(fpga_ptr); - if (mode == LANDSCAPE) - writel_relaxed(((0xFFFF0000 & ptr_value) | 1), - fpga_ptr); - else if (mode == PORTRAIT) - writel_relaxed(((0xFFFF0000 & ptr_value) | 3), - fpga_ptr); - else - writel_relaxed((0xFFFF0000 & ptr_value), - fpga_ptr); - - mb(); - iounmap(fpga_ptr); - } else - pr_err("%s: 3D barrier not configured correctly\n", - __func__); -} - -static int mipi_novatek_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct msm_panel_info *pinfo; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - pinfo = &mfd->panel_info; - if (pinfo->is_3d_panel) - support_3d = TRUE; - - mipi = &mfd->panel_info.mipi; - - if (mipi->mode == DSI_VIDEO_MODE) { - cmdreq.cmds = novatek_video_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(novatek_video_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else { - cmdreq.cmds = novatek_cmd_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(novatek_cmd_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - /* clean up ack_err_status */ - mipi_dsi_cmd_bta_sw_trigger(); - mipi_novatek_manufacture_id(mfd); - } - return 0; -} - -static int mipi_novatek_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - cmdreq.cmds = novatek_display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(novatek_display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - - mipi_dsi_cmdlist_put(&cmdreq); - - return 0; -} - -static int mipi_novatek_lcd_late_init(struct platform_device *pdev) -{ - return 0; -} - -DEFINE_LED_TRIGGER(bkl_led_trigger); - -static char led_pwm1[2] = {0x51, 0x0}; /* DTYPE_DCS_WRITE1 */ -static struct dsi_cmd_desc backlight_cmd = { - DTYPE_DCS_LWRITE, 1, 0, 0, 1, sizeof(led_pwm1), led_pwm1}; - - -static void mipi_novatek_set_backlight(struct msm_fb_data_type *mfd) -{ - struct dcs_cmd_req cmdreq; - - if (mipi_novatek_pdata && - mipi_novatek_pdata->gpio_set_backlight) { - mipi_novatek_pdata->gpio_set_backlight(mfd->bl_level); - return; - } - - if ((mipi_novatek_pdata->enable_wled_bl_ctrl) - && (wled_trigger_initialized)) { - led_trigger_event(bkl_led_trigger, mfd->bl_level); - return; - } - - led_pwm1[1] = (unsigned char)mfd->bl_level; - - cmdreq.cmds = &backlight_cmd; - cmdreq.cmds_cnt = 1; - cmdreq.flags = CMD_REQ_COMMIT | CMD_CLK_CTRL; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - - mipi_dsi_cmdlist_put(&cmdreq); -} - -static int mipi_dsi_3d_barrier_sysfs_register(struct device *dev); -static int barrier_mode; - -static int mipi_novatek_lcd_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct platform_device *current_pdev; - static struct mipi_dsi_phy_ctrl *phy_settings; - static char dlane_swap; - - if (pdev->id == 0) { - mipi_novatek_pdata = pdev->dev.platform_data; - - if (mipi_novatek_pdata - && mipi_novatek_pdata->phy_ctrl_settings) { - phy_settings = (mipi_novatek_pdata->phy_ctrl_settings); - } - - if (mipi_novatek_pdata - && mipi_novatek_pdata->dlane_swap) { - dlane_swap = (mipi_novatek_pdata->dlane_swap); - } - - if (mipi_novatek_pdata - && mipi_novatek_pdata->fpga_3d_config_addr) - mipi_novatek_3d_init(mipi_novatek_pdata - ->fpga_3d_config_addr, mipi_novatek_pdata->fpga_ctrl_mode); - - /* create sysfs to control 3D barrier for the Sharp panel */ - if (mipi_dsi_3d_barrier_sysfs_register(&pdev->dev)) { - pr_err("%s: Failed to register 3d Barrier sysfs\n", - __func__); - return -ENODEV; - } - barrier_mode = 0; - - return 0; - } - - current_pdev = msm_fb_add_device(pdev); - - if (current_pdev) { - mfd = platform_get_drvdata(current_pdev); - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - mipi = &mfd->panel_info.mipi; - - if (phy_settings != NULL) - mipi->dsi_phy_db = phy_settings; - - if (dlane_swap) - mipi->dlane_swap = dlane_swap; - } - return 0; -} - -static struct platform_driver this_driver = { - .probe = mipi_novatek_lcd_probe, - .driver = { - .name = "mipi_novatek", - }, -}; - -static struct msm_fb_panel_data novatek_panel_data = { - .on = mipi_novatek_lcd_on, - .off = mipi_novatek_lcd_off, - .late_init = mipi_novatek_lcd_late_init, - .set_backlight = mipi_novatek_set_backlight, -}; - -static ssize_t mipi_dsi_3d_barrier_read(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return snprintf((char *)buf, sizeof(buf), "%u\n", barrier_mode); -} - -static ssize_t mipi_dsi_3d_barrier_write(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - int ret = -1; - u32 data = 0; - - if (sscanf((char *)buf, "%u", &data) != 1) { - dev_err(dev, "%s\n", __func__); - ret = -EINVAL; - } else { - barrier_mode = data; - if (data == 1) - mipi_dsi_enable_3d_barrier(LANDSCAPE); - else if (data == 2) - mipi_dsi_enable_3d_barrier(PORTRAIT); - else - mipi_dsi_enable_3d_barrier(0); - } - - return count; -} - -static struct device_attribute mipi_dsi_3d_barrier_attributes[] = { - __ATTR(enable_3d_barrier, 0664, mipi_dsi_3d_barrier_read, - mipi_dsi_3d_barrier_write), -}; - -static int mipi_dsi_3d_barrier_sysfs_register(struct device *dev) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(mipi_dsi_3d_barrier_attributes); i++) - if (device_create_file(dev, mipi_dsi_3d_barrier_attributes + i)) - goto error; - - return 0; - -error: - for (; i >= 0 ; i--) - device_remove_file(dev, mipi_dsi_3d_barrier_attributes + i); - pr_err("%s: Unable to create interface\n", __func__); - - return -ENODEV; -} - -static int ch_used[3]; - -int mipi_novatek_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - ret = mipi_novatek_lcd_init(); - if (ret) { - pr_err("mipi_novatek_lcd_init() failed with ret %u\n", ret); - return ret; - } - - pdev = platform_device_alloc("mipi_novatek", (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - novatek_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &novatek_panel_data, - sizeof(novatek_panel_data)); - if (ret) { - printk(KERN_ERR - "%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - printk(KERN_ERR - "%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int mipi_novatek_lcd_init(void) -{ -#ifdef CONFIG_SPI_QUP - int ret; - ret = spi_register_driver(&panel_3d_spi_driver); - - if (ret) { - pr_err("%s: spi register failed: rc=%d\n", __func__, ret); - platform_driver_unregister(&this_driver); - } else - pr_info("%s: SUCCESS (SPI)\n", __func__); -#endif - - led_trigger_register_simple("bkl_trigger", &bkl_led_trigger); - pr_info("%s: SUCCESS (WLED TRIGGER)\n", __func__); - wled_trigger_initialized = 1; - - mipi_dsi_buf_alloc(&novatek_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&novatek_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} diff --git a/drivers/video/msm/mipi_novatek.h b/drivers/video/msm/mipi_novatek.h deleted file mode 100644 index 7abe86399bdcbababd2126ee83baedf8f3b6c5db..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_novatek.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (c) 2010, 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 MIPI_NOVATEK_BLUE_H -#define MIPI_NOVATEK_BLUE_H - -#define NOVATEK_TWO_LANE - -int mipi_novatek_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MIPI_NOVATEK_BLUE_H */ diff --git a/drivers/video/msm/mipi_novatek_cmd_qhd_pt.c b/drivers/video/msm/mipi_novatek_cmd_qhd_pt.c deleted file mode 100644 index d2820a8028cfbbec8916a827c504afbe3e0a8cf1..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_novatek_cmd_qhd_pt.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (c) 2010-2011, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_novatek.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_cmd_mode_phy_db = { -/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */ - {0x03, 0x01, 0x01, 0x00}, /* regulator */ - /* timing */ - {0xB4, 0x8D, 0x1D, 0x00, 0x20, 0x94, 0x20, - 0x8F, 0x20, 0x03, 0x04}, - {0x7f, 0x00, 0x00, 0x00}, /* phy ctrl */ - {0xee, 0x02, 0x86, 0x00}, /* strength */ - /* pll control */ - {0x40, 0xf9, 0xb0, 0xda, 0x00, 0x50, 0x48, 0x63, -#if defined(NOVATEK_TWO_LANE) - 0x30, 0x07, 0x03, -#else /* default set to 1 lane */ - 0x30, 0x07, 0x07, -#endif - 0x05, 0x14, 0x03, 0x0, 0x0, 0x54, 0x06, 0x10, 0x04, 0x0}, -}; - -static int __init mipi_cmd_novatek_blue_qhd_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_cmd_novatek_qhd")) - return 0; - - pinfo.xres = 540; - pinfo.yres = 960; - pinfo.type = MIPI_CMD_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 50; - pinfo.lcdc.h_front_porch = 50; - pinfo.lcdc.h_pulse_width = 20; - pinfo.lcdc.v_back_porch = 11; - pinfo.lcdc.v_front_porch = 10; - pinfo.lcdc.v_pulse_width = 5; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 255; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - pinfo.clk_rate = 454000000; - pinfo.is_3d_panel = FB_TYPE_3D_PANEL; - pinfo.lcd.vsync_enable = TRUE; - pinfo.lcd.hw_vsync_mode = TRUE; - pinfo.lcd.refx100 = 6200; /* adjust refx100 to prevent tearing */ - pinfo.lcd.v_back_porch = 11; - pinfo.lcd.v_front_porch = 10; - pinfo.lcd.v_pulse_width = 5; - - pinfo.mipi.mode = DSI_CMD_MODE; - pinfo.mipi.dst_format = DSI_CMD_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.esc_byte_ratio = 4; -#if defined(NOVATEK_TWO_LANE) - pinfo.mipi.data_lane1 = TRUE; -#endif - pinfo.mipi.t_clk_post = 0x22; - pinfo.mipi.t_clk_pre = 0x3f; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.te_sel = 1; /* TE from vsycn gpio */ - pinfo.mipi.interleave_max = 1; - pinfo.mipi.insert_dcs_cmd = TRUE; - pinfo.mipi.wr_mem_continue = 0x3c; - pinfo.mipi.wr_mem_start = 0x2c; - pinfo.mipi.dsi_phy_db = &dsi_cmd_mode_phy_db; - - ret = mipi_novatek_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_QHD_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_cmd_novatek_blue_qhd_pt_init); diff --git a/drivers/video/msm/mipi_novatek_video_qhd_pt.c b/drivers/video/msm/mipi_novatek_video_qhd_pt.c deleted file mode 100644 index 8881b60b20e94524338cd93b4e6a501fa5d33632..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_novatek_video_qhd_pt.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) 2010-2011, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_novatek.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { -/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */ - {0x03, 0x01, 0x01, 0x00}, /* regulator */ - /* timing */ - {0x82, 0x31, 0x13, 0x0, 0x42, 0x4D, 0x18, - 0x35, 0x21, 0x03, 0x04}, - {0x7f, 0x00, 0x00, 0x00}, /* phy ctrl */ - {0xee, 0x02, 0x86, 0x00}, /* strength */ - /* pll control */ - {0x40, 0xf9, 0xb0, 0xda, 0x00, 0x50, 0x48, 0x63, -#if defined(NOVATEK_TWO_LANE) - 0x30, 0x07, 0x03, -#else /* default set to 1 lane */ - 0x30, 0x07, 0x07, -#endif - 0x05, 0x14, 0x03, 0x0, 0x0, 0x54, 0x06, 0x10, 0x04, 0x0}, -}; - -static int __init mipi_video_novatek_qhd_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_novatek_qhd")) - return 0; - - pinfo.xres = 540; - pinfo.yres = 960; - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 80; - pinfo.lcdc.h_front_porch = 24; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 16; - pinfo.lcdc.v_front_porch = 8; - pinfo.lcdc.v_pulse_width = 1; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 15; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = FALSE; - pinfo.mipi.hbp_power_stop = FALSE; - pinfo.mipi.hsa_power_stop = FALSE; - pinfo.mipi.eof_bllp_power_stop = TRUE; - pinfo.mipi.bllp_power_stop = TRUE; - pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_PULSE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_BGR; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.esc_byte_ratio = 4; -#if defined(NOVATEK_TWO_LANE) - pinfo.mipi.data_lane1 = TRUE; -#endif - pinfo.mipi.tx_eot_append = TRUE; - pinfo.mipi.t_clk_post = 0x04; - pinfo.mipi.t_clk_pre = 0x1c; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - - ret = mipi_novatek_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_QHD_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_novatek_qhd_pt_init); diff --git a/drivers/video/msm/mipi_orise.c b/drivers/video/msm/mipi_orise.c deleted file mode 100644 index e94487000c5d44c06307ef0f276460811f93f6be..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_orise.c +++ /dev/null @@ -1,210 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_orise.h" -#include "mdp4.h" - - -static struct mipi_dsi_panel_platform_data *mipi_orise_pdata; - -static struct dsi_buf orise_tx_buf; -static struct dsi_buf orise_rx_buf; - -static char enter_sleep[2] = {0x10, 0x00}; /* DTYPE_DCS_WRITE */ -static char exit_sleep[2] = {0x11, 0x00}; /* DTYPE_DCS_WRITE */ -static char display_off[2] = {0x28, 0x00}; /* DTYPE_DCS_WRITE */ -static char display_on[2] = {0x29, 0x00}; /* DTYPE_DCS_WRITE */ - -static struct dsi_cmd_desc orise_video_on_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(display_on), display_on}, -}; - -static struct dsi_cmd_desc orise_cmd_on_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(display_on), display_on}, -}; - -static struct dsi_cmd_desc orise_display_off_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 10, - sizeof(display_off), display_off}, - {DTYPE_DCS_WRITE, 1, 0, 0, 120, - sizeof(enter_sleep), enter_sleep} -}; - -static int mipi_orise_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct msm_panel_info *pinfo; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - pinfo = &mfd->panel_info; - mipi = &mfd->panel_info.mipi; - - memset(&cmdreq, 0, sizeof(cmdreq)); - if (mipi->mode == DSI_VIDEO_MODE) { - cmdreq.cmds = orise_video_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(orise_video_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else { - cmdreq.cmds = orise_cmd_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(orise_cmd_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - mipi_dsi_cmd_bta_sw_trigger(); /* clean up ack_err_status */ - } - - return 0; -} - -static int mipi_orise_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = orise_display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(orise_display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - return 0; -} - - - -static int mipi_orise_lcd_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct platform_device *current_pdev; - static struct mipi_dsi_phy_ctrl *phy_settings; - - if (pdev->id == 0) { - mipi_orise_pdata = pdev->dev.platform_data; - - if (mipi_orise_pdata - && mipi_orise_pdata->phy_ctrl_settings) { - phy_settings = (mipi_orise_pdata->phy_ctrl_settings); - } - - return 0; - } - - current_pdev = msm_fb_add_device(pdev); - - if (current_pdev) { - mfd = platform_get_drvdata(current_pdev); - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - mipi = &mfd->panel_info.mipi; - - if (phy_settings != NULL) - mipi->dsi_phy_db = phy_settings; - } - return 0; -} - -static struct platform_driver this_driver = { - .probe = mipi_orise_lcd_probe, - .driver = { - .name = "mipi_orise", - }, -}; - -static struct msm_fb_panel_data orise_panel_data = { - .on = mipi_orise_lcd_on, - .off = mipi_orise_lcd_off, -}; - -static int ch_used[3]; - -int mipi_orise_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - pdev = platform_device_alloc("mipi_orise", (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - orise_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &orise_panel_data, - sizeof(orise_panel_data)); - if (ret) { - printk(KERN_ERR - "%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - printk(KERN_ERR - "%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int __init mipi_orise_lcd_init(void) -{ - mipi_dsi_buf_alloc(&orise_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&orise_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} - -module_init(mipi_orise_lcd_init); diff --git a/drivers/video/msm/mipi_orise.h b/drivers/video/msm/mipi_orise.h deleted file mode 100644 index da4b59f2a5f2a735ac3482200cc50f598b2c426e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_orise.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2012, 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 MIPI_ORISE_H -#define MIPI_ORISE_H - -int mipi_orise_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MIPI_ORISE_H */ diff --git a/drivers/video/msm/mipi_orise_cmd_720p_pt.c b/drivers/video/msm/mipi_orise_cmd_720p_pt.c deleted file mode 100644 index 9b7020ad498a2e8db15edfbe7d95388e85145514..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_orise_cmd_720p_pt.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_orise.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_cmd_mode_phy_db = { -/* DSI_BIT_CLK at 507MHz, 4 lane, RGB888 */ - {0x03, 0x0a, 0x04, 0x00, 0x20}, - /* timing */ - {0x8c, 0x34, 0x15, 0x00, 0x46, 0x50, 0x1a, 0x38, - 0x24, 0x03, 0x04, 0xa0}, - /* phy ctrl */ - {0x5f, 0x00, 0x00, 0x10}, - /* strength */ - {0xff, 0x00, 0x06, 0x00}, - /* pll control */ - {0x0, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62, - 0x40, 0x07, 0x03, - 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01 }, -}; - -static int __init mipi_cmd_orise_720p_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_cmd_orise_720p")) - return 0; - - pinfo.xres = 720; - pinfo.yres = 1280; - pinfo.type = MIPI_CMD_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 160; - pinfo.lcdc.h_front_porch = 160; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 32; - pinfo.lcdc.v_front_porch = 32; - pinfo.lcdc.v_pulse_width = 1; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 200; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - pinfo.clk_rate = 507000000; - pinfo.lcd.vsync_enable = TRUE; - pinfo.lcd.hw_vsync_mode = TRUE; - pinfo.lcd.refx100 = 6000; /* adjust refx100 to prevent tearing */ - pinfo.lcd.v_back_porch = 32; - pinfo.lcd.v_front_porch = 32; - pinfo.lcd.v_pulse_width = 1; - - pinfo.mipi.mode = DSI_CMD_MODE; - pinfo.mipi.dst_format = DSI_CMD_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.data_lane2 = TRUE; - pinfo.mipi.data_lane3 = TRUE; - pinfo.mipi.t_clk_post = 0x04; - pinfo.mipi.t_clk_pre = 0x1e; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.te_sel = 1; /* TE from vsycn gpio */ - pinfo.mipi.interleave_max = 1; - pinfo.mipi.insert_dcs_cmd = TRUE; - pinfo.mipi.wr_mem_continue = 0x3c; - pinfo.mipi.wr_mem_start = 0x2c; - pinfo.mipi.dsi_phy_db = &dsi_cmd_mode_phy_db; - - ret = mipi_orise_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_720P_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_cmd_orise_720p_pt_init); diff --git a/drivers/video/msm/mipi_orise_video_720p_pt.c b/drivers/video/msm/mipi_orise_video_720p_pt.c deleted file mode 100644 index 1484576c99b2982820c77e456221d8676711a37d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_orise_video_720p_pt.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_orise.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* regulator */ - {0x03, 0x0a, 0x04, 0x00, 0x20}, - /* timing */ - {0x83, 0x31, 0x13, 0x00, 0x42, 0x4d, 0x18, 0x35, - 0x21, 0x03, 0x04, 0xa0}, - /* phy ctrl */ - {0x5f, 0x00, 0x00, 0x10}, - /* strength */ - {0xff, 0x00, 0x06, 0x00}, - /* pll control */ - {0x0, 0x0e, 0x30, 0xc0, 0x00, 0x40, 0x03, 0x62, - 0x40, 0x07, 0x07, - 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01 }, -}; - -static int __init mipi_video_orise_720p_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_orise_720p")) - return 0; - - pinfo.xres = 720; - pinfo.yres = 1280; - pinfo.lcdc.xres_pad = 0; - pinfo.lcdc.yres_pad = 0; - - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 160; - pinfo.lcdc.h_front_porch = 160; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 32; - pinfo.lcdc.v_front_porch = 32; - pinfo.lcdc.v_pulse_width = 1; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 200; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = TRUE; - pinfo.mipi.hbp_power_stop = TRUE; - pinfo.mipi.hsa_power_stop = FALSE; - pinfo.mipi.eof_bllp_power_stop = TRUE; - pinfo.mipi.bllp_power_stop = TRUE; - pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_EVENT; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.data_lane2 = TRUE; - pinfo.mipi.data_lane3 = TRUE; - pinfo.mipi.t_clk_post = 0x04; - pinfo.mipi.t_clk_pre = 0x1c; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = 0; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 55; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - pinfo.mipi.tx_eot_append = TRUE; - pinfo.mipi.esc_byte_ratio = 4; - - ret = mipi_orise_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_720P_PT); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_orise_720p_pt_init); diff --git a/drivers/video/msm/mipi_renesas.c b/drivers/video/msm/mipi_renesas.c deleted file mode 100644 index 5c63fe5557a613ae43c462bea8013b671f31804d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_renesas.c +++ /dev/null @@ -1,1292 +0,0 @@ -/* Copyright (c) 2011-2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_renesas.h" -#include - -#define RENESAS_CMD_DELAY 0 /* 50 */ -#define RENESAS_SLEEP_OFF_DELAY 50 -static struct msm_panel_common_pdata *mipi_renesas_pdata; - -static struct dsi_buf renesas_tx_buf; -static struct dsi_buf renesas_rx_buf; - -static int mipi_renesas_lcd_init(void); - -static char config_sleep_out[2] = {0x11, 0x00}; -static char config_CMD_MODE[2] = {0x40, 0x01}; -static char config_WRTXHT[7] = {0x92, 0x16, 0x08, 0x08, 0x00, 0x01, 0xe0}; -static char config_WRTXVT[7] = {0x8b, 0x02, 0x02, 0x02, 0x00, 0x03, 0x60}; -static char config_PLL2NR[2] = {0xa0, 0x24}; -static char config_PLL2NF1[2] = {0xa2, 0xd0}; -static char config_PLL2NF2[2] = {0xa4, 0x00}; -static char config_PLL2BWADJ1[2] = {0xa6, 0xd0}; -static char config_PLL2BWADJ2[2] = {0xa8, 0x00}; -static char config_PLL2CTL[2] = {0xaa, 0x00}; -static char config_DBICBR[2] = {0x48, 0x03}; -static char config_DBICTYPE[2] = {0x49, 0x00}; -static char config_DBICSET1[2] = {0x4a, 0x1c}; -static char config_DBICADD[2] = {0x4b, 0x00}; -static char config_DBICCTL[2] = {0x4e, 0x01}; -/* static char config_COLMOD_565[2] = {0x3a, 0x05}; */ -/* static char config_COLMOD_666PACK[2] = {0x3a, 0x06}; */ -static char config_COLMOD_888[2] = {0x3a, 0x07}; -static char config_MADCTL[2] = {0x36, 0x00}; -static char config_DBIOC[2] = {0x82, 0x40}; -static char config_CASET[7] = {0x2a, 0x00, 0x00, 0x00, 0x00, 0x01, 0xdf }; -static char config_PASET[7] = {0x2b, 0x00, 0x00, 0x00, 0x00, 0x03, 0x5f }; -static char config_TXON[2] = {0x81, 0x00}; -static char config_BLSET_TM[2] = {0xff, 0x6c}; -static char config_DSIRXCTL[2] = {0x41, 0x01}; -static char config_TEON[2] = {0x35, 0x00}; -static char config_TEOFF[1] = {0x34}; - -static char config_AGCPSCTL_TM[2] = {0x56, 0x08}; - -static char config_DBICADD70[2] = {0x4b, 0x70}; -static char config_DBICSET_15[2] = {0x4a, 0x15}; -static char config_DBICADD72[2] = {0x4b, 0x72}; - -static char config_Power_Ctrl_2a_cmd[3] = {0x4c, 0x40, 0x10}; -static char config_Auto_Sequencer_Setting_a_cmd[3] = {0x4c, 0x00, 0x00}; -static char Driver_Output_Ctrl_indx[3] = {0x4c, 0x00, 0x01}; -static char Driver_Output_Ctrl_cmd[3] = {0x4c, 0x03, 0x10}; -static char config_LCD_drive_AC_Ctrl_indx[3] = {0x4c, 0x00, 0x02}; -static char config_LCD_drive_AC_Ctrl_cmd[3] = {0x4c, 0x01, 0x00}; -static char config_Entry_Mode_indx[3] = {0x4c, 0x00, 0x03}; -static char config_Entry_Mode_cmd[3] = {0x4c, 0x00, 0x00}; -static char config_Display_Ctrl_1_indx[3] = {0x4c, 0x00, 0x07}; -static char config_Display_Ctrl_1_cmd[3] = {0x4c, 0x00, 0x00}; -static char config_Display_Ctrl_2_indx[3] = {0x4c, 0x00, 0x08}; -static char config_Display_Ctrl_2_cmd[3] = {0x4c, 0x00, 0x04}; -static char config_Display_Ctrl_3_indx[3] = {0x4c, 0x00, 0x09}; -static char config_Display_Ctrl_3_cmd[3] = {0x4c, 0x00, 0x0c}; -static char config_Display_IF_Ctrl_1_indx[3] = {0x4c, 0x00, 0x0c}; -static char config_Display_IF_Ctrl_1_cmd[3] = {0x4c, 0x40, 0x10}; -static char config_Display_IF_Ctrl_2_indx[3] = {0x4c, 0x00, 0x0e}; -static char config_Display_IF_Ctrl_2_cmd[3] = {0x4c, 0x00, 0x00}; - -static char config_Panel_IF_Ctrl_1_indx[3] = {0x4c, 0x00, 0x20}; -static char config_Panel_IF_Ctrl_1_cmd[3] = {0x4c, 0x01, 0x3f}; -static char config_Panel_IF_Ctrl_3_indx[3] = {0x4c, 0x00, 0x22}; -static char config_Panel_IF_Ctrl_3_cmd[3] = {0x4c, 0x76, 0x00}; -static char config_Panel_IF_Ctrl_4_indx[3] = {0x4c, 0x00, 0x23}; -static char config_Panel_IF_Ctrl_4_cmd[3] = {0x4c, 0x1c, 0x0a}; -static char config_Panel_IF_Ctrl_5_indx[3] = {0x4c, 0x00, 0x24}; -static char config_Panel_IF_Ctrl_5_cmd[3] = {0x4c, 0x1c, 0x2c}; -static char config_Panel_IF_Ctrl_6_indx[3] = {0x4c, 0x00, 0x25}; -static char config_Panel_IF_Ctrl_6_cmd[3] = {0x4c, 0x1c, 0x4e}; -static char config_Panel_IF_Ctrl_8_indx[3] = {0x4c, 0x00, 0x27}; -static char config_Panel_IF_Ctrl_8_cmd[3] = {0x4c, 0x00, 0x00}; -static char config_Panel_IF_Ctrl_9_indx[3] = {0x4c, 0x00, 0x28}; -static char config_Panel_IF_Ctrl_9_cmd[3] = {0x4c, 0x76, 0x0c}; - - -static char config_gam_adjust_00_indx[3] = {0x4c, 0x03, 0x00}; -static char config_gam_adjust_00_cmd[3] = {0x4c, 0x00, 0x00}; -static char config_gam_adjust_01_indx[3] = {0x4c, 0x03, 0x01}; -static char config_gam_adjust_01_cmd[3] = {0x4c, 0x05, 0x02}; -static char config_gam_adjust_02_indx[3] = {0x4c, 0x03, 0x02}; -static char config_gam_adjust_02_cmd[3] = {0x4c, 0x07, 0x05}; -static char config_gam_adjust_03_indx[3] = {0x4c, 0x03, 0x03}; -static char config_gam_adjust_03_cmd[3] = {0x4c, 0x00, 0x00}; -static char config_gam_adjust_04_indx[3] = {0x4c, 0x03, 0x04}; -static char config_gam_adjust_04_cmd[3] = {0x4c, 0x02, 0x00}; -static char config_gam_adjust_05_indx[3] = {0x4c, 0x03, 0x05}; -static char config_gam_adjust_05_cmd[3] = {0x4c, 0x07, 0x07}; -static char config_gam_adjust_06_indx[3] = {0x4c, 0x03, 0x06}; -static char config_gam_adjust_06_cmd[3] = {0x4c, 0x10, 0x10}; -static char config_gam_adjust_07_indx[3] = {0x4c, 0x03, 0x07}; -static char config_gam_adjust_07_cmd[3] = {0x4c, 0x02, 0x02}; -static char config_gam_adjust_08_indx[3] = {0x4c, 0x03, 0x08}; -static char config_gam_adjust_08_cmd[3] = {0x4c, 0x07, 0x04}; -static char config_gam_adjust_09_indx[3] = {0x4c, 0x03, 0x09}; -static char config_gam_adjust_09_cmd[3] = {0x4c, 0x07, 0x07}; -static char config_gam_adjust_0A_indx[3] = {0x4c, 0x03, 0x0a}; -static char config_gam_adjust_0A_cmd[3] = {0x4c, 0x00, 0x00}; -static char config_gam_adjust_0B_indx[3] = {0x4c, 0x03, 0x0b}; -static char config_gam_adjust_0B_cmd[3] = {0x4c, 0x00, 0x00}; -static char config_gam_adjust_0C_indx[3] = {0x4c, 0x03, 0x0c}; -static char config_gam_adjust_0C_cmd[3] = {0x4c, 0x07, 0x07}; -static char config_gam_adjust_0D_indx[3] = {0x4c, 0x03, 0x0d}; -static char config_gam_adjust_0D_cmd[3] = {0x4c, 0x10, 0x10}; -static char config_gam_adjust_10_indx[3] = {0x4c, 0x03, 0x10}; -static char config_gam_adjust_10_cmd[3] = {0x4c, 0x01, 0x04}; -static char config_gam_adjust_11_indx[3] = {0x4c, 0x03, 0x11}; -static char config_gam_adjust_11_cmd[3] = {0x4c, 0x05, 0x03}; -static char config_gam_adjust_12_indx[3] = {0x4c, 0x03, 0x12}; -static char config_gam_adjust_12_cmd[3] = {0x4c, 0x03, 0x04}; -static char config_gam_adjust_15_indx[3] = {0x4c, 0x03, 0x15}; -static char config_gam_adjust_15_cmd[3] = {0x4c, 0x03, 0x04}; -static char config_gam_adjust_16_indx[3] = {0x4c, 0x03, 0x16}; -static char config_gam_adjust_16_cmd[3] = {0x4c, 0x03, 0x1c}; -static char config_gam_adjust_17_indx[3] = {0x4c, 0x03, 0x17}; -static char config_gam_adjust_17_cmd[3] = {0x4c, 0x02, 0x04}; -static char config_gam_adjust_18_indx[3] = {0x4c, 0x03, 0x18}; -static char config_gam_adjust_18_cmd[3] = {0x4c, 0x04, 0x02}; -static char config_gam_adjust_19_indx[3] = {0x4c, 0x03, 0x19}; -static char config_gam_adjust_19_cmd[3] = {0x4c, 0x03, 0x05}; -static char config_gam_adjust_1C_indx[3] = {0x4c, 0x03, 0x1c}; -static char config_gam_adjust_1C_cmd[3] = {0x4c, 0x07, 0x07}; -static char config_gam_adjust_1D_indx[3] = {0x4c, 0x03, 0x1D}; -static char config_gam_adjust_1D_cmd[3] = {0x4c, 0x02, 0x1f}; -static char config_gam_adjust_20_indx[3] = {0x4c, 0x03, 0x20}; -static char config_gam_adjust_20_cmd[3] = {0x4c, 0x05, 0x07}; -static char config_gam_adjust_21_indx[3] = {0x4c, 0x03, 0x21}; -static char config_gam_adjust_21_cmd[3] = {0x4c, 0x06, 0x04}; -static char config_gam_adjust_22_indx[3] = {0x4c, 0x03, 0x22}; -static char config_gam_adjust_22_cmd[3] = {0x4c, 0x04, 0x05}; -static char config_gam_adjust_27_indx[3] = {0x4c, 0x03, 0x27}; -static char config_gam_adjust_27_cmd[3] = {0x4c, 0x02, 0x03}; -static char config_gam_adjust_28_indx[3] = {0x4c, 0x03, 0x28}; -static char config_gam_adjust_28_cmd[3] = {0x4c, 0x03, 0x00}; -static char config_gam_adjust_29_indx[3] = {0x4c, 0x03, 0x29}; -static char config_gam_adjust_29_cmd[3] = {0x4c, 0x00, 0x02}; - -static char config_Power_Ctrl_1_indx[3] = {0x4c, 0x01, 0x00}; -static char config_Power_Ctrl_1b_cmd[3] = {0x4c, 0x36, 0x3c}; -static char config_Power_Ctrl_2_indx[3] = {0x4c, 0x01, 0x01}; -static char config_Power_Ctrl_2b_cmd[3] = {0x4c, 0x40, 0x03}; -static char config_Power_Ctrl_3_indx[3] = {0x4c, 0x01, 0x02}; -static char config_Power_Ctrl_3a_cmd[3] = {0x4c, 0x00, 0x01}; -static char config_Power_Ctrl_4_indx[3] = {0x4c, 0x01, 0x03}; -static char config_Power_Ctrl_4a_cmd[3] = {0x4c, 0x3c, 0x58}; -static char config_Power_Ctrl_6_indx[3] = {0x4c, 0x01, 0x0c}; -static char config_Power_Ctrl_6a_cmd[3] = {0x4c, 0x01, 0x35}; - -static char config_Auto_Sequencer_Setting_b_cmd[3] = {0x4c, 0x00, 0x02}; - -static char config_Panel_IF_Ctrl_10_indx[3] = {0x4c, 0x00, 0x29}; -static char config_Panel_IF_Ctrl_10a_cmd[3] = {0x4c, 0x03, 0xbf}; -static char config_Auto_Sequencer_Setting_indx[3] = {0x4c, 0x01, 0x06}; -static char config_Auto_Sequencer_Setting_c_cmd[3] = {0x4c, 0x00, 0x03}; -static char config_Power_Ctrl_2c_cmd[3] = {0x4c, 0x40, 0x10}; - -static char config_VIDEO[2] = {0x40, 0x00}; - -static char config_Panel_IF_Ctrl_10_indx_off[3] = {0x4C, 0x00, 0x29}; - -static char config_Panel_IF_Ctrl_10b_cmd_off[3] = {0x4C, 0x00, 0x02}; - -static char config_Power_Ctrl_1a_cmd[3] = {0x4C, 0x30, 0x00}; - -static struct dsi_cmd_desc renesas_sleep_off_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, RENESAS_SLEEP_OFF_DELAY, - sizeof(config_sleep_out), config_sleep_out } -}; - -static struct dsi_cmd_desc renesas_display_off_cmds[] = { - /* Choosing Command Mode */ - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_CMD_MODE), config_CMD_MODE }, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_indx), - config_Auto_Sequencer_Setting_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_b_cmd), - config_Auto_Sequencer_Setting_b_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY * 2, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - /* After waiting >= 5 frames, turn OFF RGB signals - This is done by on DSI/MDP (depends on Vid/Cmd Mode. */ - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_indx), - config_Auto_Sequencer_Setting_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_a_cmd), - config_Auto_Sequencer_Setting_a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_10_indx_off), - config_Panel_IF_Ctrl_10_indx_off}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_10b_cmd_off), - config_Panel_IF_Ctrl_10b_cmd_off}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_1_indx), - config_Power_Ctrl_1_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_1a_cmd), - config_Power_Ctrl_1a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_TEOFF), config_TEOFF}, -}; - -static struct dsi_cmd_desc renesas_display_on_cmds[] = { - /* Choosing Command Mode */ - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_CMD_MODE), config_CMD_MODE }, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_WRTXHT), config_WRTXHT }, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_WRTXVT), config_WRTXVT }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_PLL2NR), config_PLL2NR }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_PLL2NF1), config_PLL2NF1 }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_PLL2NF2), config_PLL2NF2 }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_PLL2BWADJ1), config_PLL2BWADJ1}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_PLL2BWADJ2), config_PLL2BWADJ2}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_PLL2CTL), config_PLL2CTL}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICBR), config_DBICBR}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICTYPE), config_DBICTYPE}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET1), config_DBICSET1}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD), config_DBICADD}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICCTL), config_DBICCTL}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_COLMOD_888), config_COLMOD_888}, - /* Choose config_COLMOD_565 or config_COLMOD_666PACK for other modes */ - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_MADCTL), config_MADCTL}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBIOC), config_DBIOC}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_CASET), config_CASET}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_PASET), config_PASET}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DSIRXCTL), config_DSIRXCTL}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_TEON), config_TEON}, - {DTYPE_DCS_WRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_TXON), config_TXON}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_BLSET_TM), config_BLSET_TM}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_AGCPSCTL_TM), config_AGCPSCTL_TM}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_1_indx), config_Power_Ctrl_1_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_1a_cmd), config_Power_Ctrl_1a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_2_indx), config_Power_Ctrl_2_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_2a_cmd), config_Power_Ctrl_2a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_indx), - config_Auto_Sequencer_Setting_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_a_cmd), - config_Auto_Sequencer_Setting_a_cmd }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(Driver_Output_Ctrl_indx), Driver_Output_Ctrl_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(Driver_Output_Ctrl_cmd), - Driver_Output_Ctrl_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_LCD_drive_AC_Ctrl_indx), - config_LCD_drive_AC_Ctrl_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_LCD_drive_AC_Ctrl_cmd), - config_LCD_drive_AC_Ctrl_cmd }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Entry_Mode_indx), - config_Entry_Mode_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Entry_Mode_cmd), - config_Entry_Mode_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_Ctrl_1_indx), - config_Display_Ctrl_1_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_Ctrl_1_cmd), - config_Display_Ctrl_1_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_Ctrl_2_indx), - config_Display_Ctrl_2_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_Ctrl_2_cmd), - config_Display_Ctrl_2_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_Ctrl_3_indx), - config_Display_Ctrl_3_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_Ctrl_3_cmd), - config_Display_Ctrl_3_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_IF_Ctrl_1_indx), - config_Display_IF_Ctrl_1_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_IF_Ctrl_1_cmd), - config_Display_IF_Ctrl_1_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_IF_Ctrl_2_indx), - config_Display_IF_Ctrl_2_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Display_IF_Ctrl_2_cmd), - config_Display_IF_Ctrl_2_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_1_indx), - config_Panel_IF_Ctrl_1_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_1_cmd), - config_Panel_IF_Ctrl_1_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_3_indx), - config_Panel_IF_Ctrl_3_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_3_cmd), - config_Panel_IF_Ctrl_3_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_4_indx), - config_Panel_IF_Ctrl_4_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_4_cmd), - config_Panel_IF_Ctrl_4_cmd }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_5_indx), - config_Panel_IF_Ctrl_5_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_5_cmd), - config_Panel_IF_Ctrl_5_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_6_indx), - config_Panel_IF_Ctrl_6_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_6_cmd), - config_Panel_IF_Ctrl_6_cmd }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_8_indx), - config_Panel_IF_Ctrl_8_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_8_cmd), - config_Panel_IF_Ctrl_8_cmd }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_9_indx), - config_Panel_IF_Ctrl_9_indx }, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_9_cmd), - config_Panel_IF_Ctrl_9_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_00_indx), - config_gam_adjust_00_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_00_cmd), - config_gam_adjust_00_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_01_indx), - config_gam_adjust_01_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_01_cmd), - config_gam_adjust_01_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_02_indx), - config_gam_adjust_02_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_02_cmd), - config_gam_adjust_02_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_03_indx), - config_gam_adjust_03_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_03_cmd), - config_gam_adjust_03_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_04_indx), config_gam_adjust_04_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_04_cmd), config_gam_adjust_04_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_05_indx), config_gam_adjust_05_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_05_cmd), config_gam_adjust_05_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_06_indx), config_gam_adjust_06_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_06_cmd), config_gam_adjust_06_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_07_indx), config_gam_adjust_07_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_07_cmd), config_gam_adjust_07_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_08_indx), config_gam_adjust_08_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_08_cmd), config_gam_adjust_08_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_09_indx), config_gam_adjust_09_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_09_cmd), config_gam_adjust_09_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0A_indx), config_gam_adjust_0A_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0A_cmd), config_gam_adjust_0A_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0B_indx), config_gam_adjust_0B_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0B_cmd), config_gam_adjust_0B_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0C_indx), config_gam_adjust_0C_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0C_cmd), config_gam_adjust_0C_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0D_indx), config_gam_adjust_0D_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_0D_cmd), config_gam_adjust_0D_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_10_indx), config_gam_adjust_10_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_10_cmd), config_gam_adjust_10_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_11_indx), config_gam_adjust_11_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_11_cmd), config_gam_adjust_11_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_12_indx), config_gam_adjust_12_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_12_cmd), config_gam_adjust_12_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_15_indx), config_gam_adjust_15_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_15_cmd), config_gam_adjust_15_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_16_indx), config_gam_adjust_16_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_16_cmd), config_gam_adjust_16_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_17_indx), config_gam_adjust_17_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_17_cmd), config_gam_adjust_17_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_18_indx), config_gam_adjust_18_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_18_cmd), config_gam_adjust_18_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_19_indx), config_gam_adjust_19_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_19_cmd), config_gam_adjust_19_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_1C_indx), config_gam_adjust_1C_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_1C_cmd), config_gam_adjust_1C_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_1D_indx), config_gam_adjust_1D_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_1D_cmd), config_gam_adjust_1D_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_20_indx), config_gam_adjust_20_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_20_cmd), config_gam_adjust_20_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_21_indx), config_gam_adjust_21_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_21_cmd), config_gam_adjust_21_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_22_indx), config_gam_adjust_22_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_22_cmd), config_gam_adjust_22_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_27_indx), config_gam_adjust_27_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_27_cmd), config_gam_adjust_27_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_28_indx), config_gam_adjust_28_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_28_cmd), config_gam_adjust_28_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_29_indx), config_gam_adjust_29_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_gam_adjust_29_cmd), config_gam_adjust_29_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_1_indx), config_Power_Ctrl_1_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_1b_cmd), config_Power_Ctrl_1b_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_2_indx), config_Power_Ctrl_2_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_2b_cmd), config_Power_Ctrl_2b_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_3_indx), config_Power_Ctrl_3_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_3a_cmd), config_Power_Ctrl_3a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_4_indx), config_Power_Ctrl_4_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_4a_cmd), config_Power_Ctrl_4a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_6_indx), config_Power_Ctrl_6_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_6a_cmd), config_Power_Ctrl_6a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_indx), - config_Auto_Sequencer_Setting_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_b_cmd), - config_Auto_Sequencer_Setting_b_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_10_indx), - config_Panel_IF_Ctrl_10_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Panel_IF_Ctrl_10a_cmd), - config_Panel_IF_Ctrl_10a_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_indx), - config_Auto_Sequencer_Setting_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Auto_Sequencer_Setting_c_cmd), - config_Auto_Sequencer_Setting_c_cmd}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD70), config_DBICADD70}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_2_indx), - config_Power_Ctrl_2_indx}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICSET_15), config_DBICSET_15}, - {DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_DBICADD72), config_DBICADD72}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_Power_Ctrl_2c_cmd), - config_Power_Ctrl_2c_cmd}, - - {DTYPE_DCS_WRITE1, 1, 0, 0, 0/* RENESAS_CMD_DELAY */, - sizeof(config_DBICSET_15), config_DBICSET_15}, - -}; - -static char config_WRTXHT2[7] = {0x92, 0x15, 0x05, 0x0F, 0x00, 0x01, 0xe0}; -static char config_WRTXVT2[7] = {0x8b, 0x14, 0x01, 0x14, 0x00, 0x03, 0x60}; - -static struct dsi_cmd_desc renesas_hvga_on_cmds[] = { - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_WRTXHT2), config_WRTXHT2}, - {DTYPE_DCS_LWRITE, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_WRTXVT2), config_WRTXVT2}, -}; - -static struct dsi_cmd_desc renesas_video_on_cmds[] = { -{DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_VIDEO), config_VIDEO} -}; - -static struct dsi_cmd_desc renesas_cmd_on_cmds[] = { -{DTYPE_DCS_WRITE1, 1, 0, 0, RENESAS_CMD_DELAY, - sizeof(config_CMD_MODE), config_CMD_MODE}, -}; - -static int mipi_renesas_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - mipi = &mfd->panel_info.mipi; - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = renesas_sleep_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(renesas_sleep_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - mipi_set_tx_power_mode(1); - - cmdreq.cmds = renesas_display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(renesas_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - if (cpu_is_msm7x25a() || cpu_is_msm7x25aa() || cpu_is_msm7x25ab()) { - cmdreq.cmds = renesas_hvga_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(renesas_hvga_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } - - if (mipi->mode == DSI_VIDEO_MODE) { - cmdreq.cmds = renesas_video_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(renesas_video_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else { - cmdreq.cmds = renesas_cmd_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(renesas_cmd_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } - mipi_set_tx_power_mode(0); - - return 0; -} - -static int mipi_renesas_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = renesas_display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(renesas_display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - return 0; -} - -static int mipi_renesas_lcd_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - mipi_renesas_pdata = pdev->dev.platform_data; - return 0; - } - - msm_fb_add_device(pdev); - - return 0; -} - -static void mipi_renesas_set_backlight(struct msm_fb_data_type *mfd) -{ - int ret = -EPERM; - int bl_level; - - bl_level = mfd->bl_level; - - if (mipi_renesas_pdata && mipi_renesas_pdata->pmic_backlight) - ret = mipi_renesas_pdata->pmic_backlight(bl_level); - else - pr_err("%s(): Backlight level set failed", __func__); -} - -static struct platform_driver this_driver = { - .probe = mipi_renesas_lcd_probe, - .driver = { - .name = "mipi_renesas", - }, -}; - -static struct msm_fb_panel_data renesas_panel_data = { - .on = mipi_renesas_lcd_on, - .off = mipi_renesas_lcd_off, - .set_backlight = mipi_renesas_set_backlight, -}; - -static int ch_used[3]; - -int mipi_renesas_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - ret = mipi_renesas_lcd_init(); - if (ret) { - pr_err("mipi_renesas_lcd_init() failed with ret %u\n", ret); - return ret; - } - - pdev = platform_device_alloc("mipi_renesas", (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - renesas_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &renesas_panel_data, - sizeof(renesas_panel_data)); - if (ret) { - pr_err("%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - pr_err("%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int mipi_renesas_lcd_init(void) -{ - mipi_dsi_buf_alloc(&renesas_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&renesas_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} diff --git a/drivers/video/msm/mipi_renesas.h b/drivers/video/msm/mipi_renesas.h deleted file mode 100644 index 67f777fef564819f622e42fafd18a5bf66f5d294..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_renesas.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2011, 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 MIPI_RENESAS_H -#define MIPI_RENESAS_H - -#define RENESAS_FWVGA_TWO_LANE - -int mipi_renesas_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MIPI_RENESAS_H */ diff --git a/drivers/video/msm/mipi_renesas_cmd_fwvga_pt.c b/drivers/video/msm/mipi_renesas_cmd_fwvga_pt.c deleted file mode 100644 index 1bf86a7f1abf1deb7e956273479df94caece5547..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_renesas_cmd_fwvga_pt.c +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright (c) 2011-2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_renesas.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_cmd_mode_phy_db = { -#ifdef CONFIG_FB_MSM_MDP303 - /* DSI Bit Clock at 500 MHz, 2 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, 0x90, - 0x18, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xbb, 0x02, 0x06, 0x00}, - /* pll control */ - {0x01, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, - 0x01, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, -#else - /* DSI_BIT_CLK at 400MHz, 1 lane, RGB888 */ - {0x03, 0x01, 0x01, 0x00}, /* regulator */ - /* timing */ - {0x22, 0x0c, 0x7, 0x00, 0x10, 0x20, 0x10, - 0xd, 0x8, 0x2, 0x3}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xee, 0x00, 0x6, 0x00}, - /* pll control */ - {0x40, 0x2f, 0xb1, 0xda, 0x00, 0x50, 0x48, 0x63, -#if defined(RENESAS_FWVGA_TWO_LANE) - 0x33, 0x1f, 0x07, -#else /* default set to 1 lane */ - 0x30, 0x07, 0x07, -#endif - 0x05, 0x14, 0x03, 0x0, 0x0, 0x54, 0x06, 0x10, 0x04, 0x0}, -#endif -}; - -static int __init mipi_cmd_renesas_fwvga_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_cmd_renesas_fwvga")) - return 0; - - pinfo.xres = 480; - pinfo.yres = 864; - pinfo.type = MIPI_CMD_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; -#ifdef CONFIG_FB_MSM_MDP303 - pinfo.lcdc.h_back_porch = 100; - pinfo.lcdc.h_front_porch = 100; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 20; - pinfo.lcdc.v_front_porch = 20; - pinfo.lcdc.v_pulse_width = 1; -#else - pinfo.lcdc.h_front_porch = 50; -#if defined(RENESAS_FWVGA_TWO_LANE) - pinfo.lcdc.h_back_porch = 400; - pinfo.lcdc.h_pulse_width = 5; - pinfo.lcdc.v_back_porch = 75; - pinfo.lcdc.v_front_porch = 5; - pinfo.lcdc.v_pulse_width = 1; -#else - pinfo.lcdc.h_back_porch = 50; - pinfo.lcdc.h_pulse_width = 20; - pinfo.lcdc.v_back_porch = 10; - pinfo.lcdc.v_front_porch = 10; - pinfo.lcdc.v_pulse_width = 5; -#endif - -#endif /* CONFIG_FB_MSM_MDP303 */ - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 255; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - -#ifdef CONFIG_FB_MSM_MDP303 - pinfo.clk_rate = 499000000; -#else - pinfo.clk_rate = 152000000; -#endif - pinfo.lcd.refx100 = 6000; /* adjust refx100 to prevent tearing */ - - pinfo.mipi.mode = DSI_CMD_MODE; - pinfo.mipi.dst_format = DSI_CMD_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo.mipi.data_lane0 = TRUE; -#ifdef CONFIG_FB_MSM_MDP303 - pinfo.lcd.vsync_enable = TRUE; - pinfo.lcd.hw_vsync_mode = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.t_clk_post = 0x20; - pinfo.mipi.t_clk_pre = 0x2F; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.te_sel = 1; /* TE from vsync gpio */ - pinfo.mipi.interleave_max = 1; - pinfo.mipi.insert_dcs_cmd = TRUE; - pinfo.mipi.wr_mem_continue = 0x3c; - pinfo.mipi.wr_mem_start = 0x2c; - pinfo.mipi.dsi_phy_db = &dsi_cmd_mode_phy_db; - pinfo.mipi.tx_eot_append = 0x01; - pinfo.mipi.rx_eot_ignore = 0; - pinfo.mipi.dlane_swap = 0x01; -#else -#if defined(RENESAS_FWVGA_TWO_LANE) - pinfo.mipi.data_lane1 = TRUE; -#else - pinfo.mipi.data_lane1 = FALSE; -#endif - pinfo.mipi.t_clk_post = 0x18; - pinfo.mipi.t_clk_pre = 0x14; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.te_sel = 1; /* TE from vsycn gpio */ - pinfo.mipi.interleave_max = 1; - pinfo.mipi.insert_dcs_cmd = TRUE; - pinfo.mipi.wr_mem_continue = 0x3c; - pinfo.mipi.wr_mem_start = 0x2c; - pinfo.mipi.dsi_phy_db = &dsi_cmd_mode_phy_db; -#endif /* CONFIG_FB_MSM_MDP303 */ - - ret = mipi_renesas_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_FWVGA_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_cmd_renesas_fwvga_pt_init); diff --git a/drivers/video/msm/mipi_renesas_video_fwvga_pt.c b/drivers/video/msm/mipi_renesas_video_fwvga_pt.c deleted file mode 100644 index b7f77045efc60bdc5ef0b3b50e98cb61e27a8f1b..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_renesas_video_fwvga_pt.c +++ /dev/null @@ -1,163 +0,0 @@ -/* Copyright (c) 2011-2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_renesas.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { -#ifdef CONFIG_FB_MSM_MDP303 - /* DSI Bit Clock at 500 MHz, 2 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, 0x90, - 0x18, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xbb, 0x02, 0x06, 0x00}, - /* pll control */ - {0x00, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, - 0x01, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, -#else - /* DSI_BIT_CLK at 400MHz, 1 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xaa, 0x3b, 0x1b, 0x00, 0x52, 0x58, 0x20, 0x3f, - 0x2e, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xee, 0x00, 0x86, 0x00}, - /* pll control */ - {0x40, 0xc7, 0xb0, 0xda, 0x00, 0x50, 0x48, 0x63, -#if defined(RENESAS_FWVGA_TWO_LANE) - 0x30, 0x07, 0x03, -#else - /* default set to 1 lane */ - 0x30, 0x07, 0x07, -#endif - 0x05, 0x14, 0x03, 0x0, 0x0, 0x54, 0x06, 0x10, 0x04, 0x0}, -#endif -}; - -static int __init mipi_video_renesas_fwvga_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_renesas_fwvga")) - return 0; - - pinfo.xres = 480; - pinfo.yres = 864; - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; -#ifdef CONFIG_FB_MSM_MDP303 - pinfo.lcdc.h_back_porch = 100; - pinfo.lcdc.h_front_porch = 100; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 20; - pinfo.lcdc.v_front_porch = 20; - pinfo.lcdc.v_pulse_width = 1; - pinfo.clk_rate = 499000000; -#else - -#if defined(RENESAS_FWVGA_TWO_LANE) - pinfo.lcdc.h_back_porch = 400; -#else - pinfo.lcdc.h_back_porch = 50; -#endif - pinfo.lcdc.h_front_porch = 50; - -#if defined(RENESAS_FWVGA_TWO_LANE) - pinfo.lcdc.h_pulse_width = 5; -#else - pinfo.lcdc.h_pulse_width = 20; -#endif - -#if defined(RENESAS_FWVGA_TWO_LANE) - pinfo.lcdc.v_back_porch = 75; - pinfo.lcdc.v_front_porch = 5; - pinfo.lcdc.v_pulse_width = 1; -#else - pinfo.lcdc.v_back_porch = 10; - pinfo.lcdc.v_front_porch = 10; - pinfo.lcdc.v_pulse_width = 5; -#endif - -#endif - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 255; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = TRUE; - pinfo.mipi.hbp_power_stop = TRUE; - pinfo.mipi.hsa_power_stop = TRUE; - pinfo.mipi.eof_bllp_power_stop = TRUE; - pinfo.mipi.bllp_power_stop = TRUE; -#ifdef CONFIG_FB_MSM_MDP303 - pinfo.mipi.traffic_mode = DSI_BURST_MODE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.t_clk_post = 0x20; - pinfo.mipi.t_clk_pre = 0x2F; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - pinfo.mipi.dlane_swap = 0x01; - pinfo.mipi.tx_eot_append = 0x01; -#else - pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_PULSE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_BGR; - pinfo.mipi.data_lane0 = TRUE; -#if defined(RENESAS_FWVGA_TWO_LANE) - pinfo.mipi.data_lane1 = TRUE; -#else - pinfo.mipi.data_lane1 = FALSE; -#endif - pinfo.mipi.t_clk_post = 0x03; - pinfo.mipi.t_clk_pre = 0x24; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; -#endif - - ret = mipi_renesas_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_FWVGA_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_renesas_fwvga_pt_init); diff --git a/drivers/video/msm/mipi_simulator.c b/drivers/video/msm/mipi_simulator.c deleted file mode 100644 index f2f46b5f13a36d1df3adbd44ea69b17179fa073f..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_simulator.c +++ /dev/null @@ -1,179 +0,0 @@ -/* Copyright (c) 2011-2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_simulator.h" - -static struct dsi_buf simulator_tx_buf; -static struct dsi_buf simulator_rx_buf; -static struct msm_panel_common_pdata *mipi_simulator_pdata; - -static int mipi_simulator_lcd_init(void); - -static char display_on[2] = {0x00, 0x00}; -static char display_off[2] = {0x00, 0x00}; - -static struct dsi_cmd_desc display_on_cmds[] = { - {DTYPE_PERIPHERAL_ON, 1, 0, 0, 0, sizeof(display_on), - display_on} -}; -static struct dsi_cmd_desc display_off_cmds[] = { - {DTYPE_PERIPHERAL_OFF, 1, 0, 0, 0, sizeof(display_off), - display_off} -}; - -static int mipi_simulator_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - mipi = &mfd->panel_info.mipi; - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - pr_debug("%s:%d, debug info (mode) : %d", __func__, __LINE__, - mipi->mode); - - memset(&cmdreq, 0, sizeof(cmdreq)); - if (mipi->mode == DSI_VIDEO_MODE) { - cmdreq.cmds = display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else { - pr_err("%s:%d, CMD MODE NOT SUPPORTED", __func__, __LINE__); - return -EINVAL; - } - - return 0; -} - -static int mipi_simulator_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - mipi = &mfd->panel_info.mipi; - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - pr_debug("%s:%d, debug info", __func__, __LINE__); - - memset(&cmdreq, 0, sizeof(cmdreq)); - if (mipi->mode == DSI_VIDEO_MODE) { - cmdreq.cmds = display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else { - pr_debug("%s:%d, DONT REACH HERE", __func__, __LINE__); - return -EINVAL; - } - - return 0; -} - -static int mipi_simulator_lcd_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - mipi_simulator_pdata = pdev->dev.platform_data; - return 0; - } - pr_debug("%s:%d, debug info", __func__, __LINE__); - - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = mipi_simulator_lcd_probe, - .driver = { - .name = "mipi_simulator", - }, -}; - -static struct msm_fb_panel_data simulator_panel_data = { - .on = mipi_simulator_lcd_on, - .off = mipi_simulator_lcd_off, -}; - -static int ch_used[3]; - -int mipi_simulator_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - pr_debug("%s:%d, debug info", __func__, __LINE__); - ret = mipi_simulator_lcd_init(); - if (ret) { - pr_err("mipi_simulator_lcd_init() failed with ret %u\n", ret); - return ret; - } - - pdev = platform_device_alloc("mipi_simulator", (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - simulator_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &simulator_panel_data, - sizeof(simulator_panel_data)); - if (ret) { - pr_err(KERN_ERR - "%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - pr_err(KERN_ERR - "%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int mipi_simulator_lcd_init(void) -{ - mipi_dsi_buf_alloc(&simulator_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&simulator_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} diff --git a/drivers/video/msm/mipi_simulator.h b/drivers/video/msm/mipi_simulator.h deleted file mode 100644 index 6c0a60c105fa4f8c402f51171e58629d97c59d97..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_simulator.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (c) 2011, 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 MIPI_SIMULATOR_H -#define MIPI_SIMULATOR_H - -int mipi_simulator_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MIPI_SIMULATOR_H */ diff --git a/drivers/video/msm/mipi_simulator_video.c b/drivers/video/msm/mipi_simulator_video.c deleted file mode 100644 index 258a7ecabe5ce88b8eed483d75286288a0d90250..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_simulator_video.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (c) 2011, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_simulator.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - {0x03, 0x01, 0x01, 0x00}, - {0xaa, 0x3b, 0x1b, 0x00, 0x52, 0x58, 0x20, 0x3f, - 0x2e, 0x03, 0x04}, - {0x7f, 0x00, 0x00, 0x00}, - {0xee, 0x00, 0x86, 0x00}, - {0x40, 0xc7, 0xb0, 0xda, 0x00, 0x50, 0x48, 0x63, - 0x30, 0x07, 0x03, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x54, 0x06, 0x10, 0x04, 0x0}, -}; - -static int __init mipi_video_simulator_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_simulator_vga")) - return 0; - pinfo.xres = 640; - pinfo.yres = 480; - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - - pinfo.lcdc.h_back_porch = 6; - pinfo.lcdc.h_front_porch = 6; - pinfo.lcdc.h_pulse_width = 2; - pinfo.lcdc.v_back_porch = 6; - pinfo.lcdc.v_front_porch = 6; - pinfo.lcdc.v_pulse_width = 2; - - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 15; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = TRUE; - pinfo.mipi.hbp_power_stop = TRUE; - pinfo.mipi.hsa_power_stop = TRUE; - pinfo.mipi.eof_bllp_power_stop = TRUE; - pinfo.mipi.bllp_power_stop = TRUE; - pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_PULSE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.t_clk_post = 0x03; - pinfo.mipi.t_clk_pre = 0x24; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - - ret = mipi_simulator_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_VGA); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_simulator_init); diff --git a/drivers/video/msm/mipi_tc358764_dsi2lvds.c b/drivers/video/msm/mipi_tc358764_dsi2lvds.c deleted file mode 100644 index fc2b6f7333349ee003211bd8e2d58f8c8aaddaf3..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_tc358764_dsi2lvds.c +++ /dev/null @@ -1,1025 +0,0 @@ -/* Copyright (c) 2011-2013, 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. - * - */ - -/* - * Toshiba MIPI-DSI-to-LVDS Bridge driver. - * Device Model TC358764XBG/65XBG. - * Reference document: TC358764XBG_65XBG_V119.pdf - * - * The Host sends a DSI Generic Long Write packet (Data ID = 0x29) over the - * DSI link for each write access transaction to the chip configuration - * registers. - * Payload of this packet is 16-bit register address and 32-bit data. - * Multiple data values are allowed for sequential addresses. - * - * The Host sends a DSI Generic Read packet (Data ID = 0x24) over the DSI - * link for each read request transaction to the chip configuration - * registers. Payload of this packet is further defined as follows: - * 16-bit address followed by a 32-bit value (Generic Long Read Response - * packet). - * - * The bridge supports 5 GPIO lines controlled via the GPC register. - * - * The bridge support I2C Master/Slave. - * The I2C slave can be used for read/write to the bridge register instead of - * using the DSI interface. - * I2C slave address is 0x0F (read/write 0x1F/0x1E). - * The I2C Master can be used for communication with the panel if - * it has an I2C slave. - * - * NOTE: The I2C interface is not used in this driver. - * Only the DSI interface is used for read/write the bridge registers. - * - * Pixel data can be transmitted in non-burst or burst fashion. - * Non-burst refers to pixel data packet transmission time on DSI link - * being roughly the same (to account for packet overhead time) - * as active video line time on LVDS output (i.e. DE = 1). - * And burst refers to pixel data packet transmission time on DSI link - * being less than the active video line time on LVDS output. - * Video mode transmission is further differentiated by the types of - * timing events being transmitted. - * Video pulse mode refers to the case where both sync start and sync end - * events (for frame and line) are transmitted. - * Video event mode refers to the case where only sync start events - * are transmitted. - * This is configured via register bit VPCTRL.EVTMODE. - * - */ - -/* #define DEBUG 1 */ - -/** - * Use the I2C master to control the panel. - */ -/* #define TC358764_USE_I2C_MASTER */ - -#define DRV_NAME "mipi_tc358764" - -#include -#include -#include -#include -#include "msm_fb.h" -#include "mdp4.h" -#include "mipi_dsi.h" -#include "mipi_tc358764_dsi2lvds.h" - -/* Registers definition */ - -/* DSI D-PHY Layer Registers */ -#define D0W_DPHYCONTTX 0x0004 /* Data Lane 0 DPHY Tx Control */ -#define CLW_DPHYCONTRX 0x0020 /* Clock Lane DPHY Rx Control */ -#define D0W_DPHYCONTRX 0x0024 /* Data Lane 0 DPHY Rx Control */ -#define D1W_DPHYCONTRX 0x0028 /* Data Lane 1 DPHY Rx Control */ -#define D2W_DPHYCONTRX 0x002C /* Data Lane 2 DPHY Rx Control */ -#define D3W_DPHYCONTRX 0x0030 /* Data Lane 3 DPHY Rx Control */ -#define COM_DPHYCONTRX 0x0038 /* DPHY Rx Common Control */ -#define CLW_CNTRL 0x0040 /* Clock Lane Control */ -#define D0W_CNTRL 0x0044 /* Data Lane 0 Control */ -#define D1W_CNTRL 0x0048 /* Data Lane 1 Control */ -#define D2W_CNTRL 0x004C /* Data Lane 2 Control */ -#define D3W_CNTRL 0x0050 /* Data Lane 3 Control */ -#define DFTMODE_CNTRL 0x0054 /* DFT Mode Control */ - -/* DSI PPI Layer Registers */ -#define PPI_STARTPPI 0x0104 /* START control bit of PPI-TX function. */ -#define PPI_BUSYPPI 0x0108 -#define PPI_LINEINITCNT 0x0110 /* Line Initialization Wait Counter */ -#define PPI_LPTXTIMECNT 0x0114 -#define PPI_LANEENABLE 0x0134 /* Enables each lane at the PPI layer. */ -#define PPI_TX_RX_TA 0x013C /* DSI Bus Turn Around timing parameters */ - -/* Analog timer function enable */ -#define PPI_CLS_ATMR 0x0140 /* Delay for Clock Lane in LPRX */ -#define PPI_D0S_ATMR 0x0144 /* Delay for Data Lane 0 in LPRX */ -#define PPI_D1S_ATMR 0x0148 /* Delay for Data Lane 1 in LPRX */ -#define PPI_D2S_ATMR 0x014C /* Delay for Data Lane 2 in LPRX */ -#define PPI_D3S_ATMR 0x0150 /* Delay for Data Lane 3 in LPRX */ -#define PPI_D0S_CLRSIPOCOUNT 0x0164 - -#define PPI_D1S_CLRSIPOCOUNT 0x0168 /* For lane 1 */ -#define PPI_D2S_CLRSIPOCOUNT 0x016C /* For lane 2 */ -#define PPI_D3S_CLRSIPOCOUNT 0x0170 /* For lane 3 */ - -#define CLS_PRE 0x0180 /* Digital Counter inside of PHY IO */ -#define D0S_PRE 0x0184 /* Digital Counter inside of PHY IO */ -#define D1S_PRE 0x0188 /* Digital Counter inside of PHY IO */ -#define D2S_PRE 0x018C /* Digital Counter inside of PHY IO */ -#define D3S_PRE 0x0190 /* Digital Counter inside of PHY IO */ -#define CLS_PREP 0x01A0 /* Digital Counter inside of PHY IO */ -#define D0S_PREP 0x01A4 /* Digital Counter inside of PHY IO */ -#define D1S_PREP 0x01A8 /* Digital Counter inside of PHY IO */ -#define D2S_PREP 0x01AC /* Digital Counter inside of PHY IO */ -#define D3S_PREP 0x01B0 /* Digital Counter inside of PHY IO */ -#define CLS_ZERO 0x01C0 /* Digital Counter inside of PHY IO */ -#define D0S_ZERO 0x01C4 /* Digital Counter inside of PHY IO */ -#define D1S_ZERO 0x01C8 /* Digital Counter inside of PHY IO */ -#define D2S_ZERO 0x01CC /* Digital Counter inside of PHY IO */ -#define D3S_ZERO 0x01D0 /* Digital Counter inside of PHY IO */ - -#define PPI_CLRFLG 0x01E0 /* PRE Counters has reached set values */ -#define PPI_CLRSIPO 0x01E4 /* Clear SIPO values, Slave mode use only. */ -#define HSTIMEOUT 0x01F0 /* HS Rx Time Out Counter */ -#define HSTIMEOUTENABLE 0x01F4 /* Enable HS Rx Time Out Counter */ -#define DSI_STARTDSI 0x0204 /* START control bit of DSI-TX function */ -#define DSI_BUSYDSI 0x0208 -#define DSI_LANEENABLE 0x0210 /* Enables each lane at the Protocol layer. */ -#define DSI_LANESTATUS0 0x0214 /* Displays lane is in HS RX mode. */ -#define DSI_LANESTATUS1 0x0218 /* Displays lane is in ULPS or STOP state */ - -#define DSI_INTSTATUS 0x0220 /* Interrupt Status */ -#define DSI_INTMASK 0x0224 /* Interrupt Mask */ -#define DSI_INTCLR 0x0228 /* Interrupt Clear */ -#define DSI_LPTXTO 0x0230 /* Low Power Tx Time Out Counter */ - -#define DSIERRCNT 0x0300 /* DSI Error Count */ -#define APLCTRL 0x0400 /* Application Layer Control */ -#define RDPKTLN 0x0404 /* Command Read Packet Length */ -#define VPCTRL 0x0450 /* Video Path Control */ -#define HTIM1 0x0454 /* Horizontal Timing Control 1 */ -#define HTIM2 0x0458 /* Horizontal Timing Control 2 */ -#define VTIM1 0x045C /* Vertical Timing Control 1 */ -#define VTIM2 0x0460 /* Vertical Timing Control 2 */ -#define VFUEN 0x0464 /* Video Frame Timing Update Enable */ - -/* Mux Input Select for LVDS LINK Input */ -#define LVMX0003 0x0480 /* Bit 0 to 3 */ -#define LVMX0407 0x0484 /* Bit 4 to 7 */ -#define LVMX0811 0x0488 /* Bit 8 to 11 */ -#define LVMX1215 0x048C /* Bit 12 to 15 */ -#define LVMX1619 0x0490 /* Bit 16 to 19 */ -#define LVMX2023 0x0494 /* Bit 20 to 23 */ -#define LVMX2427 0x0498 /* Bit 24 to 27 */ - -#define LVCFG 0x049C /* LVDS Configuration */ -#define LVPHY0 0x04A0 /* LVDS PHY 0 */ -#define LVPHY1 0x04A4 /* LVDS PHY 1 */ -#define SYSSTAT 0x0500 /* System Status */ -#define SYSRST 0x0504 /* System Reset */ - -/* GPIO Registers */ -#define GPIOC 0x0520 /* GPIO Control */ -#define GPIOO 0x0524 /* GPIO Output */ -#define GPIOI 0x0528 /* GPIO Input */ - -/* I2C Registers */ -#define I2CTIMCTRL 0x0540 /* I2C IF Timing and Enable Control */ -#define I2CMADDR 0x0544 /* I2C Master Addressing */ -#define WDATAQ 0x0548 /* Write Data Queue */ -#define RDATAQ 0x054C /* Read Data Queue */ - -/* Chip ID and Revision ID Register */ -#define IDREG 0x0580 - -#define TC358764XBG_ID 0x00006500 - -/* Debug Registers */ -#define DEBUG00 0x05A0 /* Debug */ -#define DEBUG01 0x05A4 /* LVDS Data */ - -/* PWM */ -static u32 d2l_pwm_freq_hz = (3.921*1000); - -#define PWM_FREQ_HZ (d2l_pwm_freq_hz) -#define PWM_PERIOD_USEC (USEC_PER_SEC / PWM_FREQ_HZ) -#define PWM_DUTY_LEVEL (PWM_PERIOD_USEC / PWM_LEVEL) - -#define CMD_DELAY 100 -#define DSI_MAX_LANES 4 -#define KHZ 1000 -#define MHZ (1000*1000) - -/** - * Command payload for DTYPE_GEN_LWRITE (0x29) / DTYPE_GEN_READ2 (0x24). - */ -struct wr_cmd_payload { - u16 addr; - u32 data; -} __packed; - -/* - * Driver state. - */ -static struct msm_panel_common_pdata *d2l_common_pdata; -struct msm_fb_data_type *d2l_mfd; -static struct dsi_buf d2l_tx_buf; -static struct dsi_buf d2l_rx_buf; -static int led_pwm; -static struct pwm_device *bl_pwm; -static bool is_bl_pwm_enabled; -static struct pwm_device *tn_pwm; -static bool is_tn_pwm_enabled; -static int bl_level; -static u32 d2l_gpio_out_mask; -static u32 d2l_gpio_out_val; -static u32 d2l_3d_gpio_enable; -static u32 d2l_3d_gpio_mode; -static int d2l_enable_3d; -static struct i2c_client *d2l_i2c_client; -static struct i2c_driver d2l_i2c_slave_driver; - -static int mipi_d2l_init(void); -static int mipi_d2l_enable_3d(struct msm_fb_data_type *mfd, - bool enable, bool mode); -static u32 d2l_i2c_read_reg(struct i2c_client *client, u16 reg); -static u32 d2l_i2c_write_reg(struct i2c_client *client, u16 reg, u32 val); - -/** - * Read a bridge register - * - * @param mfd - * - * @return register data value - */ -static u32 mipi_d2l_read_reg(struct msm_fb_data_type *mfd, u16 reg) -{ - u32 data; - int len = 4; - struct dcs_cmd_req cmdreq; - struct dsi_cmd_desc cmd_read_reg = { - DTYPE_GEN_READ2, 1, 0, 1, 0, /* cmd 0x24 */ - sizeof(reg), (char *) ®}; - - mipi_dsi_buf_init(&d2l_rx_buf); - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = &cmd_read_reg; - cmdreq.cmds_cnt = 1; - cmdreq.flags = CMD_REQ_RX | CMD_REQ_COMMIT | CMD_REQ_NO_MAX_PKT_SIZE; - cmdreq.rbuf = &d2l_rx_buf; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - data = *(u32 *)d2l_rx_buf.data; - - if (d2l_rx_buf.len != 4) - pr_err("%s: invalid rlen=%d, expecting 4.\n", __func__, len); - - pr_debug("%s: reg=0x%x.data=0x%08x.\n", __func__, reg, data); - - return data; -} - -/** - * Write a bridge register - * - * @param mfd - * - * @return int - */ -static int mipi_d2l_write_reg(struct msm_fb_data_type *mfd, u16 reg, u32 data) -{ - struct wr_cmd_payload payload; - struct dcs_cmd_req cmdreq; - struct dsi_cmd_desc cmd_write_reg = { - DTYPE_GEN_LWRITE, 1, 0, 0, 0, - sizeof(payload), (char *)&payload}; - - payload.addr = reg; - payload.data = data; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = &cmd_write_reg; - cmdreq.cmds_cnt = 1; - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - pr_debug("%s: reg=0x%x. data=0x%x.\n", __func__, reg, data); - - return 0; -} - -static void mipi_d2l_read_status(struct msm_fb_data_type *mfd) -{ - mipi_d2l_read_reg(mfd, DSI_LANESTATUS0); /* 0x214 */ - mipi_d2l_read_reg(mfd, DSI_LANESTATUS1); /* 0x218 */ - mipi_d2l_read_reg(mfd, DSI_INTSTATUS); /* 0x220 */ - mipi_d2l_read_reg(mfd, SYSSTAT); /* 0x500 */ -} - -static void mipi_d2l_read_status_via_i2c(struct i2c_client *client) -{ - u32 tmp = 0; - - tmp = d2l_i2c_read_reg(client, DSIERRCNT); - d2l_i2c_write_reg(client, DSIERRCNT, 0xFFFF0000); - - d2l_i2c_read_reg(client, DSI_LANESTATUS0); /* 0x214 */ - d2l_i2c_read_reg(client, DSI_LANESTATUS1); /* 0x218 */ - d2l_i2c_read_reg(client, DSI_INTSTATUS); /* 0x220 */ - d2l_i2c_read_reg(client, SYSSTAT); /* 0x500 */ - - d2l_i2c_write_reg(client, DSIERRCNT, tmp); -} -/** - * Init the D2L bridge via the DSI interface for Video. - * - * VPCTRL.EVTMODE (0x20) configuration bit is needed to determine whether - * video timing information is delivered in pulse mode or event mode. - * In pulse mode, both Sync Start and End packets are required. - * In event mode, only Sync Start packets are required. - * - * @param mfd - * - * @return int - */ -static int mipi_d2l_dsi_init_sequence(struct msm_fb_data_type *mfd) -{ - struct mipi_panel_info *mipi = &mfd->panel_info.mipi; - u32 lanes_enable; - u32 vpctrl; - u32 htime1; - u32 vtime1; - u32 htime2; - u32 vtime2; - u32 ppi_tx_rx_ta; /* BTA Bus-Turn-Around */ - u32 lvcfg; - u32 hbpr; /* Horizontal Back Porch */ - u32 hpw; /* Horizontal Pulse Width */ - u32 vbpr; /* Vertical Back Porch */ - u32 vpw; /* Vertical Pulse Width */ - - u32 hfpr; /* Horizontal Front Porch */ - u32 hsize; /* Horizontal Active size */ - u32 vfpr; /* Vertical Front Porch */ - u32 vsize; /* Vertical Active size */ - bool vesa_rgb888 = false; - - lanes_enable = 0x01; /* clock-lane enable */ - lanes_enable |= (mipi->data_lane0 << 1); - lanes_enable |= (mipi->data_lane1 << 2); - lanes_enable |= (mipi->data_lane2 << 3); - lanes_enable |= (mipi->data_lane3 << 4); - - if (mipi->traffic_mode == DSI_NON_BURST_SYNCH_EVENT) - vpctrl = 0x01000120; - else if (mipi->traffic_mode == DSI_NON_BURST_SYNCH_PULSE) - vpctrl = 0x01000100; - else { - pr_err("%s.unsupported traffic_mode %d.\n", - __func__, mipi->traffic_mode); - return -EINVAL; - } - - if (mfd->panel_info.clk_rate > 800*1000*1000) { - pr_err("%s.unsupported clk_rate %d.\n", - __func__, mfd->panel_info.clk_rate); - return -EINVAL; - } - - pr_debug("%s.xres=%d.yres=%d.fps=%d.dst_format=%d.\n", - __func__, - mfd->panel_info.xres, - mfd->panel_info.yres, - mfd->panel_info.mipi.frame_rate, - mfd->panel_info.mipi.dst_format); - - hbpr = mfd->panel_info.lcdc.h_back_porch; - hpw = mfd->panel_info.lcdc.h_pulse_width; - vbpr = mfd->panel_info.lcdc.v_back_porch; - vpw = mfd->panel_info.lcdc.v_pulse_width; - - htime1 = (hbpr << 16) + hpw; - vtime1 = (vbpr << 16) + vpw; - - hfpr = mfd->panel_info.lcdc.h_front_porch; - hsize = mfd->panel_info.xres; - vfpr = mfd->panel_info.lcdc.v_front_porch; - vsize = mfd->panel_info.yres; - - htime2 = (hfpr << 16) + hsize; - vtime2 = (vfpr << 16) + vsize; - - lvcfg = 0x0003; /* PCLK=DCLK/3, Dual Link, LVEN */ - vpctrl = 0x01000120; /* Output RGB888 , Event-Mode , */ - ppi_tx_rx_ta = 0x00040004; - - if (mfd->panel_info.xres == 1366) { - ppi_tx_rx_ta = 0x00040004; - lvcfg = 0x01; /* LVEN */ - vesa_rgb888 = true; - } - - if (mfd->panel_info.xres == 1200) { - lvcfg = 0x0103; /* PCLK=DCLK/4, Dual Link, LVEN */ - vesa_rgb888 = true; - } - - pr_debug("%s.htime1=0x%x.\n", __func__, htime1); - pr_debug("%s.vtime1=0x%x.\n", __func__, vtime1); - pr_debug("%s.vpctrl=0x%x.\n", __func__, vpctrl); - pr_debug("%s.lvcfg=0x%x.\n", __func__, lvcfg); - - mipi_d2l_write_reg(mfd, SYSRST, 0xFF); - msleep(30); - - if (vesa_rgb888) { - /* VESA format instead of JEIDA format for RGB888 */ - mipi_d2l_write_reg(mfd, LVMX0003, 0x03020100); - mipi_d2l_write_reg(mfd, LVMX0407, 0x08050704); - mipi_d2l_write_reg(mfd, LVMX0811, 0x0F0E0A09); - mipi_d2l_write_reg(mfd, LVMX1215, 0x100D0C0B); - mipi_d2l_write_reg(mfd, LVMX1619, 0x12111716); - mipi_d2l_write_reg(mfd, LVMX2023, 0x1B151413); - mipi_d2l_write_reg(mfd, LVMX2427, 0x061A1918); - } - - mipi_d2l_write_reg(mfd, PPI_TX_RX_TA, ppi_tx_rx_ta); /* BTA */ - mipi_d2l_write_reg(mfd, PPI_LPTXTIMECNT, 0x00000004); - mipi_d2l_write_reg(mfd, PPI_D0S_CLRSIPOCOUNT, 0x00000003); - mipi_d2l_write_reg(mfd, PPI_D1S_CLRSIPOCOUNT, 0x00000003); - mipi_d2l_write_reg(mfd, PPI_D2S_CLRSIPOCOUNT, 0x00000003); - mipi_d2l_write_reg(mfd, PPI_D3S_CLRSIPOCOUNT, 0x00000003); - mipi_d2l_write_reg(mfd, PPI_LANEENABLE, lanes_enable); - mipi_d2l_write_reg(mfd, DSI_LANEENABLE, lanes_enable); - mipi_d2l_write_reg(mfd, PPI_STARTPPI, 0x00000001); - mipi_d2l_write_reg(mfd, DSI_STARTDSI, 0x00000001); - - mipi_d2l_write_reg(mfd, VPCTRL, vpctrl); /* RGB888 + Event mode */ - mipi_d2l_write_reg(mfd, HTIM1, htime1); - mipi_d2l_write_reg(mfd, VTIM1, vtime1); - mipi_d2l_write_reg(mfd, HTIM2, htime2); - mipi_d2l_write_reg(mfd, VTIM2, vtime2); - mipi_d2l_write_reg(mfd, VFUEN, 0x00000001); - mipi_d2l_write_reg(mfd, LVCFG, lvcfg); /* Enables LVDS tx */ - - return 0; -} - -/** - * Set Backlight level. - * - * @param pwm - * @param level - * - * @return int - */ -static int mipi_d2l_set_backlight_level(struct pwm_device *pwm, int level) -{ - int ret = 0; - - pr_debug("%s: level=%d.\n", __func__, level); - - if ((pwm == NULL) || (level > PWM_LEVEL) || (level < 0)) { - pr_err("%s.pwm=NULL.\n", __func__); - return -EINVAL; - } - - ret = pwm_config(pwm, PWM_DUTY_LEVEL * level, PWM_PERIOD_USEC); - if (ret) { - pr_err("%s: pwm_config() failed err=%d.\n", __func__, ret); - return ret; - } - - if (is_bl_pwm_enabled) { - pwm_disable(pwm); - is_bl_pwm_enabled = 0; - } - - ret = pwm_enable(pwm); - if (ret) { - pr_err("%s: pwm_enable() failed err=%d\n", - __func__, ret); - return ret; - } - - is_bl_pwm_enabled = 1; - return 0; -} - -/** - * Set TN CLK. - * - * @param pwm - * @param level - * - * @return int - */ -static int mipi_d2l_set_tn_clk(struct pwm_device *pwm, u32 usec) -{ - int ret = 0; - - pr_debug("%s: usec=%d.\n", __func__, usec); - - ret = pwm_config(pwm, usec/2 , usec); - if (ret) { - pr_err("%s: pwm_config() failed err=%d.\n", __func__, ret); - return ret; - } - - if (is_tn_pwm_enabled) { - pwm_disabled(pwm); - is_tn_pwm_enabled = 0; - } - - ret = pwm_enable(pwm); - if (ret) { - pr_err("%s: pwm_enable() failed err=%d\n", - __func__, ret); - return ret; - } - - is_bl_pwm_enabled = 1; - return 0; -} - -/** - * LCD ON. - * - * Set LCD On via MIPI interface or I2C-Slave interface. - * Set Backlight on. - * - * @param pdev - * - * @return int - */ -static int mipi_d2l_lcd_on(struct platform_device *pdev) -{ - int ret = 0; - u32 chip_id; - struct msm_fb_data_type *mfd; - - pr_info("%s.\n", __func__); - - /* wait for valid clock before sending data over DSI or I2C. */ - msleep(30); - - mfd = platform_get_drvdata(pdev); - d2l_mfd = mfd; - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - chip_id = mipi_d2l_read_reg(mfd, IDREG); - - - if (chip_id != TC358764XBG_ID) { - pr_err("%s: invalid chip_id=0x%x", __func__, chip_id); - return -ENODEV; - } - - ret = mipi_d2l_dsi_init_sequence(mfd); - if (ret) - return ret; - - mipi_d2l_write_reg(mfd, GPIOC, d2l_gpio_out_mask); - /* Set gpio#4=U/D=0, gpio#3=L/R=1 , gpio#2,1=CABC=0, gpio#0=NA. */ - mipi_d2l_write_reg(mfd, GPIOO, d2l_gpio_out_val); - - d2l_pwm_freq_hz = (3.921*1000); - - if (bl_level == 0) - bl_level = PWM_LEVEL * 2 / 3 ; /* Default ON value */ - - /* Set backlight via PWM */ - if (bl_pwm) { - ret = mipi_d2l_set_backlight_level(bl_pwm, bl_level); - if (ret) - pr_err("%s.mipi_d2l_set_backlight_level.ret=%d", - __func__, ret); - } - - mipi_d2l_read_status(mfd); - - mipi_d2l_enable_3d(mfd, false, false); - - /* Add I2C driver only after DSI-CLK is running */ - if (d2l_i2c_client == NULL) - i2c_add_driver(&d2l_i2c_slave_driver); - - pr_info("%s.ret=%d.\n", __func__, ret); - - return ret; -} - -/** - * LCD OFF. - * - * @param pdev - * - * @return int - */ -static int mipi_d2l_lcd_off(struct platform_device *pdev) -{ - int ret; - struct msm_fb_data_type *mfd; - - pr_info("%s.\n", __func__); - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - ret = mipi_d2l_set_backlight_level(bl_pwm, 1); - - pr_info("%s.ret=%d.\n", __func__, ret); - - return ret; -} - -static void mipi_d2l_set_backlight(struct msm_fb_data_type *mfd) -{ - int level = mfd->bl_level; - - pr_debug("%s.lvl=%d.\n", __func__, level); - - mipi_d2l_set_backlight_level(bl_pwm, level); - - bl_level = level; -} - -static struct msm_fb_panel_data d2l_panel_data = { - .on = mipi_d2l_lcd_on, - .off = mipi_d2l_lcd_off, - .set_backlight = mipi_d2l_set_backlight, -}; - -static u32 d2l_i2c_read_reg(struct i2c_client *client, u16 reg) -{ - int rc; - u32 val = 0; - u8 buf[6]; - - if (client == NULL) { - pr_err("%s.invalid i2c client.\n", __func__); - return -EINVAL; - } - - buf[0] = reg >> 8; - buf[1] = reg & 0xFF; - - rc = i2c_master_send(client, buf, sizeof(reg)); - rc = i2c_master_recv(client, buf, 4); - - if (rc >= 0) { - val = buf[0] + (buf[1] << 8) + (buf[2] << 16) + (buf[3] << 24); - pr_debug("%s.reg=0x%x.val=0x%x.\n", __func__, reg, val); - } else - pr_err("%s.fail.reg=0x%x.\n", __func__, reg); - - return val; -} - -static u32 d2l_i2c_write_reg(struct i2c_client *client, u16 reg, u32 val) -{ - int rc; - u8 buf[6]; - - if (client == NULL) { - pr_err("%s.invalid i2c client.\n", __func__); - return -EINVAL; - } - - buf[0] = reg >> 8; - buf[1] = reg & 0xFF; - - buf[2] = (val >> 0) & 0xFF; - buf[3] = (val >> 8) & 0xFF; - buf[4] = (val >> 16) & 0xFF; - buf[5] = (val >> 24) & 0xFF; - - rc = i2c_master_send(client, buf, sizeof(buf)); - - if (rc >= 0) - pr_debug("%s.reg=0x%x.val=0x%x.\n", __func__, reg, val); - else - pr_err("%s.fail.reg=0x%x.\n", __func__, reg); - - return val; -} - -static int d2l_i2c_slave_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - static const u32 i2c_funcs = I2C_FUNC_I2C; - - d2l_i2c_client = client; - - if (!i2c_check_functionality(client->adapter, i2c_funcs)) { - pr_err("%s.i2c_check_functionality failed.\n", __func__); - return -ENOSYS; - } else { - pr_debug("%s.i2c_check_functionality OK.\n", __func__); - } - - d2l_i2c_read_reg(client, IDREG); - - mipi_d2l_read_status_via_i2c(d2l_i2c_client); - - return 0; -} - -static int d2l_i2c_slave_remove(struct i2c_client *client) -{ - d2l_i2c_client = NULL; - - return 0; -} - -static const struct i2c_device_id d2l_i2c_id[] = { - {"tc358764-i2c", 0}, - {} -}; - -static struct i2c_driver d2l_i2c_slave_driver = { - .driver = { - .name = "tc358764-i2c", - .owner = THIS_MODULE - }, - .probe = d2l_i2c_slave_probe, - .remove = d2l_i2c_slave_remove, - .id_table = d2l_i2c_id, -}; - -static int mipi_d2l_enable_3d(struct msm_fb_data_type *mfd, - bool enable, bool mode) -{ - u32 tn_usec = 1000000 / 66; /* 66 HZ */ - - pr_debug("%s.enable=%d.mode=%d.\n", __func__, enable, mode); - - gpio_direction_output(d2l_3d_gpio_enable, enable); - gpio_direction_output(d2l_3d_gpio_mode, mode); - - mipi_d2l_set_tn_clk(tn_pwm, tn_usec); - - return 0; -} - -static ssize_t mipi_d2l_enable_3d_read(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - return snprintf((char *)buf, sizeof(buf), "%u\n", d2l_enable_3d); -} - -static ssize_t mipi_d2l_enable_3d_write(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - int ret = -1; - u32 data = 0; - - if (sscanf((char *)buf, "%u", &data) != 1) { - dev_err(dev, "%s. Invalid input.\n", __func__); - ret = -EINVAL; - } else { - d2l_enable_3d = data; - if (data == 1) /* LANDSCAPE */ - mipi_d2l_enable_3d(d2l_mfd, true, true); - else if (data == 2) /* PORTRAIT */ - mipi_d2l_enable_3d(d2l_mfd, true, false); - else if (data == 0) - mipi_d2l_enable_3d(d2l_mfd, false, false); - else if (data == 9) - mipi_d2l_read_status_via_i2c(d2l_i2c_client); - else - pr_err("%s.Invalid value=%d.\n", __func__, data); - } - - return count; -} - -static struct device_attribute mipi_d2l_3d_barrier_attributes[] = { - __ATTR(enable_3d_barrier, 0666, - mipi_d2l_enable_3d_read, - mipi_d2l_enable_3d_write), -}; - -static int mipi_dsi_3d_barrier_sysfs_register(struct device *dev) -{ - int ret; - - pr_debug("%s.d2l_3d_gpio_enable=%d.\n", __func__, d2l_3d_gpio_enable); - pr_debug("%s.d2l_3d_gpio_mode=%d.\n", __func__, d2l_3d_gpio_mode); - - ret = device_create_file(dev, mipi_d2l_3d_barrier_attributes); - if (ret) { - pr_err("%s.failed to create 3D sysfs.\n", __func__); - goto err_device_create_file; - } - - ret = gpio_request(d2l_3d_gpio_enable, "d2l_3d_gpio_enable"); - if (ret) { - pr_err("%s.failed to get d2l_3d_gpio_enable=%d.\n", - __func__, d2l_3d_gpio_enable); - goto err_d2l_3d_gpio_enable; - } - - ret = gpio_request(d2l_3d_gpio_mode, "d2l_3d_gpio_mode"); - if (ret) { - pr_err("%s.failed to get d2l_3d_gpio_mode=%d.\n", - __func__, d2l_3d_gpio_mode); - goto err_d2l_3d_gpio_mode; - } - - return 0; - -err_d2l_3d_gpio_mode: - gpio_free(d2l_3d_gpio_enable); -err_d2l_3d_gpio_enable: - device_remove_file(dev, mipi_d2l_3d_barrier_attributes); -err_device_create_file: - - return ret; -} - -/** - * Probe for device. - * - * Both the "target" and "panel" device use the same probe function. - * "Target" device has id=0, "Panel" devic has non-zero id. - * Target device should register first, passing msm_panel_common_pdata. - * Panel device passing msm_panel_info. - * - * @param pdev - * - * @return int - */ -static int mipi_d2l_probe(struct platform_device *pdev) -{ - int ret = 0; - struct msm_panel_info *pinfo = NULL; - - pr_debug("%s.id=%d.\n", __func__, pdev->id); - - if (pdev->id == 0) { - d2l_common_pdata = pdev->dev.platform_data; - - if (d2l_common_pdata == NULL) { - pr_err("%s: no PWM gpio specified.\n", __func__); - return 0; - } - - led_pwm = d2l_common_pdata->gpio_num[0]; - d2l_gpio_out_mask = d2l_common_pdata->gpio_num[1] >> 8; - d2l_gpio_out_val = d2l_common_pdata->gpio_num[1] & 0xFF; - d2l_3d_gpio_enable = d2l_common_pdata->gpio_num[2]; - d2l_3d_gpio_mode = d2l_common_pdata->gpio_num[3]; - - mipi_dsi_buf_alloc(&d2l_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&d2l_rx_buf, DSI_BUF_SIZE); - - return 0; - } - - if (d2l_common_pdata == NULL) { - pr_err("%s: d2l_common_pdata is NULL.\n", __func__); - return -ENODEV; - } - - bl_pwm = NULL; - if (led_pwm >= 0) { - bl_pwm = pwm_request(led_pwm, "lcd-backlight"); - if (bl_pwm == NULL || IS_ERR(bl_pwm)) { - pr_err("%s pwm_request() failed.id=%d.bl_pwm=%d.\n", - __func__, led_pwm, (int) bl_pwm); - bl_pwm = NULL; - return -EIO; - } else { - pr_debug("%s.pwm_request() ok.pwm-id=%d.\n", - __func__, led_pwm); - - } - } else { - pr_err("%s. led_pwm is invalid.\n", __func__); - } - - tn_pwm = pwm_request(1, "3D_TN_clk"); - if (tn_pwm == NULL || IS_ERR(tn_pwm)) { - pr_err("%s pwm_request() failed.id=%d.tn_pwm=%d.\n", - __func__, 1, (int) tn_pwm); - tn_pwm = NULL; - return -EIO; - } else { - pr_debug("%s.pwm_request() ok.pwm-id=%d.\n", __func__, 1); - - } - - pinfo = pdev->dev.platform_data; - - if (pinfo == NULL) { - pr_err("%s: pinfo is NULL.\n", __func__); - return -ENODEV; - } - - d2l_panel_data.panel_info = *pinfo; - - pdev->dev.platform_data = &d2l_panel_data; - - msm_fb_add_device(pdev); - - if (pinfo->is_3d_panel) - mipi_dsi_3d_barrier_sysfs_register(&(pdev->dev)); - - return ret; -} - -/** - * Device removal notification handler. - * - * @param pdev - * - * @return int - */ -static int mipi_d2l_remove(struct platform_device *pdev) -{ - /* Note: There are no APIs to remove fb device and free DSI buf. */ - pr_debug("%s.\n", __func__); - - if (bl_pwm) { - pwm_free(bl_pwm); - bl_pwm = NULL; - } - - return 0; -} - -/** - * Register the panel device. - * - * @param pinfo - * @param channel_id - * @param panel_id - * - * @return int - */ -int mipi_tc358764_dsi2lvds_register(struct msm_panel_info *pinfo, - u32 channel_id, u32 panel_id) -{ - struct platform_device *pdev = NULL; - int ret; - /* Use DSI-to-LVDS bridge */ - const char driver_name[] = "mipi_tc358764"; - - pr_debug("%s.\n", __func__); - ret = mipi_d2l_init(); - if (ret) { - pr_err("mipi_d2l_init() failed with ret %u\n", ret); - return ret; - } - - /* Note: the device id should be non-zero */ - pdev = platform_device_alloc(driver_name, (panel_id << 8)|channel_id); - if (pdev == NULL) - return -ENOMEM; - - pdev->dev.platform_data = pinfo; - - ret = platform_device_add(pdev); - if (ret) { - pr_err("%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static struct platform_driver d2l_driver = { - .probe = mipi_d2l_probe, - .remove = mipi_d2l_remove, - .driver = { - .name = DRV_NAME, - }, -}; - -/** - * Module Init - * - * @return int - */ -static int mipi_d2l_init(void) -{ - pr_debug("%s.\n", __func__); - - d2l_i2c_client = NULL; - - return platform_driver_register(&d2l_driver); -} - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Toshiba MIPI-DSI-to-LVDS bridge driver"); -MODULE_AUTHOR("Amir Samuelov "); diff --git a/drivers/video/msm/mipi_tc358764_dsi2lvds.h b/drivers/video/msm/mipi_tc358764_dsi2lvds.h deleted file mode 100644 index 671c191d52ac31b49afcba191707a150020d5322..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_tc358764_dsi2lvds.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2011, 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 MIPI_TC358764_DSI2LVDS_H -#define MIPI_TC358764_DSI2LVDS_H - -#define PWM_LEVEL 255 - -int mipi_tc358764_dsi2lvds_register(struct msm_panel_info *pinfo, - u32 channel_id, u32 panel_id); -#endif /* MIPI_TC358764_DSI2LVDS_H */ diff --git a/drivers/video/msm/mipi_toshiba.c b/drivers/video/msm/mipi_toshiba.c deleted file mode 100644 index 3cf63622122f15a0024f6ef151e9aa5338545f86..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_toshiba.c +++ /dev/null @@ -1,383 +0,0 @@ -/* Copyright (c) 2008-2013, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_toshiba.h" - -static struct pwm_device *bl_lpm; -static struct mipi_dsi_panel_platform_data *mipi_toshiba_pdata; - -#define TM_GET_PID(id) (((id) & 0xff00)>>8) - -static struct dsi_buf toshiba_tx_buf; -static struct dsi_buf toshiba_rx_buf; -static int mipi_toshiba_lcd_init(void); - -#ifdef TOSHIBA_CMDS_UNUSED -static char one_lane[3] = {0xEF, 0x60, 0x62}; -static char dmode_wqvga[2] = {0xB3, 0x01}; -static char intern_wr_clk1_wqvga[3] = {0xef, 0x2f, 0x22}; -static char intern_wr_clk2_wqvga[3] = {0xef, 0x6e, 0x33}; -static char hor_addr_2A_wqvga[5] = {0x2A, 0x00, 0x00, 0x00, 0xef}; -static char hor_addr_2B_wqvga[5] = {0x2B, 0x00, 0x00, 0x01, 0xaa}; -static char if_sel_cmd[2] = {0x53, 0x00}; -#endif - -static char exit_sleep[2] = {0x11, 0x00}; -static char display_on[2] = {0x29, 0x00}; -static char display_off[2] = {0x28, 0x00}; -static char enter_sleep[2] = {0x10, 0x00}; - -static char mcap_off[2] = {0xb2, 0x00}; -static char ena_test_reg[3] = {0xEF, 0x01, 0x01}; -static char two_lane[3] = {0xEF, 0x60, 0x63}; -static char non_burst_sync_pulse[3] = {0xef, 0x61, 0x09}; -static char dmode_wvga[2] = {0xB3, 0x00}; -static char intern_wr_clk1_wvga[3] = {0xef, 0x2f, 0xcc}; -static char intern_wr_clk2_wvga[3] = {0xef, 0x6e, 0xdd}; -static char hor_addr_2A_wvga[5] = {0x2A, 0x00, 0x00, 0x01, 0xdf}; -static char hor_addr_2B_wvga[5] = {0x2B, 0x00, 0x00, 0x03, 0x55}; -static char if_sel_video[2] = {0x53, 0x01}; - -static struct dsi_cmd_desc toshiba_wvga_display_on_cmds[] = { - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(mcap_off), mcap_off}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(ena_test_reg), ena_test_reg}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(two_lane), two_lane}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(non_burst_sync_pulse), - non_burst_sync_pulse}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dmode_wvga), dmode_wvga}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(intern_wr_clk1_wvga), - intern_wr_clk1_wvga}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(intern_wr_clk2_wvga), - intern_wr_clk2_wvga}, - {DTYPE_DCS_LWRITE, 1, 0, 0, 0, sizeof(hor_addr_2A_wvga), - hor_addr_2A_wvga}, - {DTYPE_DCS_LWRITE, 1, 0, 0, 0, sizeof(hor_addr_2B_wvga), - hor_addr_2B_wvga}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(if_sel_video), if_sel_video}, - {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(display_on), display_on} -}; - -static char mcap_start[2] = {0xb0, 0x04}; -static char num_out_pixelform[3] = {0xb3, 0x00, 0x87}; -static char dsi_ctrl[3] = {0xb6, 0x30, 0x83}; -static char panel_driving[7] = {0xc0, 0x01, 0x00, 0x85, 0x00, 0x00, 0x00}; -static char dispV_timing[5] = {0xc1, 0x00, 0x10, 0x00, 0x01}; -static char dispCtrl[3] = {0xc3, 0x00, 0x19}; -static char test_mode_c4[2] = {0xc4, 0x03}; -static char dispH_timing[15] = { - /* TYPE_DCS_LWRITE */ - 0xc5, 0x00, 0x01, 0x05, - 0x04, 0x5e, 0x00, 0x00, - 0x00, 0x00, 0x0b, 0x17, - 0x05, 0x00, 0x00 -}; -static char test_mode_c6[2] = {0xc6, 0x00}; -static char gamma_setA[13] = { - 0xc8, 0x0a, 0x15, 0x18, - 0x1b, 0x1c, 0x0d, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00 -}; -static char gamma_setB[13] = { - 0xc9, 0x0d, 0x1d, 0x1f, - 0x1f, 0x1f, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00 -}; -static char gamma_setC[13] = { - 0xca, 0x1e, 0x1f, 0x1e, - 0x1d, 0x1d, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00 -}; -static char powerSet_ChrgPmp[5] = {0xd0, 0x02, 0x00, 0xa3, 0xb8}; -static char testMode_d1[6] = {0xd1, 0x10, 0x14, 0x53, 0x64, 0x00}; -static char powerSet_SrcAmp[3] = {0xd2, 0xb3, 0x00}; -static char powerInt_PS[3] = {0xd3, 0x33, 0x03}; -static char vreg[2] = {0xd5, 0x00}; -static char test_mode_d6[2] = {0xd6, 0x01}; -static char timingCtrl_d7[9] = { - 0xd7, 0x09, 0x00, 0x84, - 0x81, 0x61, 0xbc, 0xb5, - 0x05 -}; -static char timingCtrl_d8[7] = { - 0xd8, 0x04, 0x25, 0x90, - 0x4c, 0x92, 0x00 -}; -static char timingCtrl_d9[4] = {0xd9, 0x5b, 0x7f, 0x05}; -static char white_balance[6] = {0xcb, 0x00, 0x00, 0x00, 0x1c, 0x00}; -static char vcs_settings[2] = {0xdd, 0x53}; -static char vcom_dc_settings[2] = {0xde, 0x43}; -static char testMode_e3[5] = {0xe3, 0x00, 0x00, 0x00, 0x00}; -static char testMode_e4[6] = {0xe4, 0x00, 0x00, 0x22, 0xaa, 0x00}; -static char testMode_e5[2] = {0xe5, 0x00}; -static char testMode_fa[4] = {0xfa, 0x00, 0x00, 0x00}; -static char testMode_fd[5] = {0xfd, 0x00, 0x00, 0x00, 0x00}; -static char testMode_fe[5] = {0xfe, 0x00, 0x00, 0x00, 0x00}; -static char mcap_end[2] = {0xb0, 0x03}; -static char set_add_mode[2] = {0x36, 0x0}; -static char set_pixel_format[2] = {0x3a, 0x70}; - - -static struct dsi_cmd_desc toshiba_wsvga_display_on_cmds[] = { - {DTYPE_GEN_WRITE2, 1, 0, 0, 10, sizeof(mcap_start), mcap_start}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 10, sizeof(num_out_pixelform), - num_out_pixelform}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 10, sizeof(dsi_ctrl), dsi_ctrl}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(panel_driving), panel_driving}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dispV_timing), dispV_timing}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dispCtrl), dispCtrl}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(test_mode_c4), test_mode_c4}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(dispH_timing), dispH_timing}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(test_mode_c6), test_mode_c6}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(gamma_setA), gamma_setA}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(gamma_setB), gamma_setB}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(gamma_setC), gamma_setC}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(powerSet_ChrgPmp), - powerSet_ChrgPmp}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(testMode_d1), testMode_d1}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(powerSet_SrcAmp), - powerSet_SrcAmp}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(powerInt_PS), powerInt_PS}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(vreg), vreg}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(test_mode_d6), test_mode_d6}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(timingCtrl_d7), timingCtrl_d7}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(timingCtrl_d8), timingCtrl_d8}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(timingCtrl_d9), timingCtrl_d9}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(white_balance), white_balance}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(vcs_settings), vcs_settings}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(vcom_dc_settings), - vcom_dc_settings}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(testMode_e3), testMode_e3}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(testMode_e4), testMode_e4}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(testMode_e5), testMode_e5}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(testMode_fa), testMode_fa}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(testMode_fd), testMode_fd}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(testMode_fe), testMode_fe}, - {DTYPE_GEN_WRITE2, 1, 0, 0, 0, sizeof(mcap_end), mcap_end}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 0, sizeof(set_add_mode), set_add_mode}, - {DTYPE_DCS_WRITE1, 1, 0, 0, 0, sizeof(set_pixel_format), - set_pixel_format}, - {DTYPE_DCS_WRITE, 1, 0, 0, 120, sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 50, sizeof(display_on), display_on} -}; - -static struct dsi_cmd_desc toshiba_display_off_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 50, sizeof(display_off), display_off}, - {DTYPE_DCS_WRITE, 1, 0, 0, 120, sizeof(enter_sleep), enter_sleep} -}; - -static int mipi_toshiba_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - if (TM_GET_PID(mfd->panel.id) == MIPI_DSI_PANEL_WVGA_PT) { - cmdreq.cmds = toshiba_wvga_display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(toshiba_wvga_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else if (TM_GET_PID(mfd->panel.id) == MIPI_DSI_PANEL_WSVGA_PT || - TM_GET_PID(mfd->panel.id) == MIPI_DSI_PANEL_WUXGA) { - cmdreq.cmds = toshiba_wsvga_display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(toshiba_wsvga_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else - return -EINVAL; - - return 0; -} - -static int mipi_toshiba_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = toshiba_display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(toshiba_display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - return 0; -} - -static int mipi_toshiba_lcd_late_init(struct platform_device *pdev) -{ - return 0; -} - -void mipi_bklight_pwm_cfg(void) -{ - if (mipi_toshiba_pdata && mipi_toshiba_pdata->dsi_pwm_cfg) - mipi_toshiba_pdata->dsi_pwm_cfg(); -} - -static void mipi_toshiba_set_backlight(struct msm_fb_data_type *mfd) -{ - int ret; - static int bklight_pwm_cfg; - static bool is_pwm_enabled; - - if (bklight_pwm_cfg == 0) { - mipi_bklight_pwm_cfg(); - bklight_pwm_cfg++; - } - - if (bl_lpm) { - ret = pwm_config(bl_lpm, MIPI_TOSHIBA_PWM_DUTY_LEVEL * - mfd->bl_level, MIPI_TOSHIBA_PWM_PERIOD_USEC); - if (ret) { - pr_err("pwm_config on lpm failed %d\n", ret); - return; - } - if (mfd->bl_level) { - if (is_pwm_enabled) { - pwm_disable(bl_lpm); - is_pwm_enabled = 0; - } - ret = pwm_enable(bl_lpm); - if (ret) - pr_err("pwm enable/disable on lpm failed" - "for bl %d\n", mfd->bl_level); - else - is_pwm_enabled = 1; - } else { - pwm_disable(bl_lpm); - is_pwm_enabled = 0; - } - } -} - -static int mipi_toshiba_lcd_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - mipi_toshiba_pdata = pdev->dev.platform_data; - return 0; - } - - if (mipi_toshiba_pdata == NULL) { - pr_err("%s.invalid platform data.\n", __func__); - return -ENODEV; - } - - if (mipi_toshiba_pdata != NULL) - bl_lpm = pwm_request(mipi_toshiba_pdata->gpio[0], - "backlight"); - - if (bl_lpm == NULL || IS_ERR(bl_lpm)) { - pr_err("%s pwm_request() failed\n", __func__); - bl_lpm = NULL; - } - pr_debug("bl_lpm = %p lpm = %d\n", bl_lpm, - mipi_toshiba_pdata->gpio[0]); - - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = mipi_toshiba_lcd_probe, - .driver = { - .name = "mipi_toshiba", - }, -}; - -static struct msm_fb_panel_data toshiba_panel_data = { - .on = mipi_toshiba_lcd_on, - .off = mipi_toshiba_lcd_off, - .late_init = mipi_toshiba_lcd_late_init, - .set_backlight = mipi_toshiba_set_backlight, -}; - -static int ch_used[3]; - -int mipi_toshiba_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - ret = mipi_toshiba_lcd_init(); - if (ret) { - pr_err("mipi_toshiba_lcd_init() failed with ret %u\n", ret); - return ret; - } - - pdev = platform_device_alloc("mipi_toshiba", (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - toshiba_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &toshiba_panel_data, - sizeof(toshiba_panel_data)); - if (ret) { - printk(KERN_ERR - "%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - printk(KERN_ERR - "%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int mipi_toshiba_lcd_init(void) -{ - mipi_dsi_buf_alloc(&toshiba_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&toshiba_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} diff --git a/drivers/video/msm/mipi_toshiba.h b/drivers/video/msm/mipi_toshiba.h deleted file mode 100644 index faff16d6202cecae8077c1ec3c9c1c67693ff3a2..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_toshiba.h +++ /dev/null @@ -1,30 +0,0 @@ - -/* Copyright (c) 2009-2011, 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 MIPI_TOSHIBA_H -#define MIPI_TOSHIBA_H - -#include -#include - -int mipi_toshiba_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#define MIPI_TOSHIBA_PWM_FREQ_HZ 300 -#define MIPI_TOSHIBA_PWM_PERIOD_USEC (USEC_PER_SEC / MIPI_TOSHIBA_PWM_FREQ_HZ) -#define MIPI_TOSHIBA_PWM_LEVEL 255 -#define MIPI_TOSHIBA_PWM_DUTY_LEVEL \ - (MIPI_TOSHIBA_PWM_PERIOD_USEC / MIPI_TOSHIBA_PWM_LEVEL) - -#endif /* MIPI_TOSHIBA_H */ diff --git a/drivers/video/msm/mipi_toshiba_video_wsvga_pt.c b/drivers/video/msm/mipi_toshiba_video_wsvga_pt.c deleted file mode 100644 index f604f0cd16ce870bea524564e2902bc399f68ceb..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_toshiba_video_wsvga_pt.c +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (c) 2011-2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_toshiba.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* 600*1024, RGB888, 3 Lane 55 fps video mode */ - /* regulator */ - {0x09, 0x08, 0x05, 0x00, 0x20}, - /* timing */ - {0x73, 0x2e, 0x11, 0x00, 0x3c, 0x46, 0x14, 0x31, - 0x1c, 0x03, 0x04, 0xa0}, - /* phy ctrl */ - {0x5f, 0x00, 0x00, 0x10}, - /* strength */ - {0xff, 0x00, 0x06, 0x00}, - /* pll control */ - {0x0, 0x49, 0x30, 0xc4, 0x00, 0x20, 0x07, 0x62, - 0x41, 0x0f, 0x01, - 0x00, 0x14, 0x03, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01 }, -}; - -static int __init mipi_video_toshiba_wsvga_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_toshiba_wsvga")) - return 0; - - pinfo.xres = 600; - pinfo.yres = 1024; - /* - * - * Panel's Horizontal input timing requirement is to - * include dummy(pad) data of 200 clk in addition to - * width and porch/sync width values - */ - pinfo.lcdc.xres_pad = 200; - pinfo.lcdc.yres_pad = 0; - - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 16; - pinfo.lcdc.h_front_porch = 23; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 3; - pinfo.lcdc.v_front_porch = 45; - pinfo.lcdc.v_pulse_width = 2; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = MIPI_TOSHIBA_PWM_LEVEL; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = FALSE; - pinfo.mipi.hfp_power_stop = FALSE; - pinfo.mipi.hbp_power_stop = FALSE; - pinfo.mipi.hsa_power_stop = FALSE; - pinfo.mipi.eof_bllp_power_stop = FALSE; - pinfo.mipi.bllp_power_stop = FALSE; - pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_EVENT; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.data_lane2 = TRUE; - pinfo.mipi.t_clk_post = 0x04; - pinfo.mipi.t_clk_pre = 0x1a; - pinfo.mipi.esc_byte_ratio = 4; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = 0; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 55; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - pinfo.mipi.tx_eot_append = TRUE; - - ret = mipi_toshiba_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WSVGA_PT); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_toshiba_wsvga_pt_init); diff --git a/drivers/video/msm/mipi_toshiba_video_wuxga.c b/drivers/video/msm/mipi_toshiba_video_wuxga.c deleted file mode 100644 index ed7895ec37a09d477180b6b7d40f565d3f330b1e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_toshiba_video_wuxga.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_toshiba.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* 1920*1200, RGB888, 4 Lane 60 fps video mode */ - /* regulator */ - {0x03, 0x0a, 0x04, 0x00, 0x20}, - /* timing */ - {0x66, 0x26, 0x1F, 0x00, 0x55, 0x9C, 0x16, 0x90, - 0x23, 0x03, 0x04, 0xa0}, - /* phy ctrl */ - {0x5f, 0x00, 0x00, 0x10}, - /* strength */ - {0xff, 0x00, 0x06, 0x00}, - /* pll control */ - {0x0, 0xD7, 0x1, 0x19, 0x00, 0x50, 0x48, 0x63, - 0x41, 0x0f, 0x01, - 0x00, 0x14, 0x03, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01 }, -}; - -static int __init mipi_video_toshiba_wuxga_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_toshiba_wuxga")) - return 0; - - pinfo.xres = 1920; - pinfo.yres = 1200; - - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 50; - pinfo.lcdc.h_front_porch = 50; - pinfo.lcdc.h_pulse_width = 170; - pinfo.lcdc.v_back_porch = 7; - pinfo.lcdc.v_front_porch = 8; - pinfo.lcdc.v_pulse_width = 30; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = MIPI_TOSHIBA_PWM_LEVEL; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - pinfo.clk_rate = 981560000; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = FALSE; - pinfo.mipi.hbp_power_stop = FALSE; - pinfo.mipi.hsa_power_stop = FALSE; - pinfo.mipi.eof_bllp_power_stop = TRUE; - pinfo.mipi.bllp_power_stop = TRUE; - pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_PULSE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_BGR; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.data_lane2 = TRUE; - pinfo.mipi.data_lane3 = TRUE; - pinfo.mipi.tx_eot_append = TRUE; - pinfo.mipi.t_clk_post = 0x04; - pinfo.mipi.t_clk_pre = 0x1c; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - pinfo.mipi.esc_byte_ratio = 9; - - ret = mipi_toshiba_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WUXGA); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_toshiba_wuxga_init); diff --git a/drivers/video/msm/mipi_toshiba_video_wvga_pt.c b/drivers/video/msm/mipi_toshiba_video_wvga_pt.c deleted file mode 100644 index fdd4d1c4d321e1f4084444a1a87d5e40df935ae1..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_toshiba_video_wvga_pt.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (c) 2009-2011, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_toshiba.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* 480*854, RGB888, 2 Lane 60 fps video mode */ - {0x03, 0x01, 0x01, 0x00}, /* regulator */ - /* timing */ - {0x6a, 0x22, 0x0f, 0x00, 0x30, 0x38, 0x13, 0x26, - 0x1b, 0x03, 0x04}, - {0x7f, 0x00, 0x00, 0x00}, /* phy ctrl */ - {0xee, 0x03, 0x86, 0x03}, /* strength */ - /* pll control */ - -#define DSI_BIT_CLK_380MHZ - -#if defined(DSI_BIT_CLK_366MHZ) - {0x41, 0xdb, 0xb2, 0xf5, 0x00, 0x50, 0x48, 0x63, - 0x31, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x03, 0x03, 0x54, 0x06, 0x10, 0x04, 0x03 }, -#elif defined(DSI_BIT_CLK_380MHZ) - {0x41, 0xf7, 0xb2, 0xf5, 0x00, 0x50, 0x48, 0x63, - 0x31, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x03, 0x03, 0x54, 0x06, 0x10, 0x04, 0x03 }, -#elif defined(DSI_BIT_CLK_400MHZ) - {0x41, 0x8f, 0xb1, 0xda, 0x00, 0x50, 0x48, 0x63, - 0x31, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x03, 0x03, 0x54, 0x06, 0x10, 0x04, 0x03 }, -#else /* 200 mhz */ - {0x41, 0x8f, 0xb1, 0xda, 0x00, 0x50, 0x48, 0x63, - 0x33, 0x1f, 0x0f, - 0x05, 0x14, 0x03, 0x03, 0x03, 0x54, 0x06, 0x10, 0x04, 0x03 }, -#endif -}; - -static int __init mipi_video_toshiba_wvga_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_toshiba_wvga")) - return 0; - - pinfo.xres = 480; - pinfo.yres = 864; /* 856 for V1 surf */ - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 64; - pinfo.lcdc.h_front_porch = 64; - pinfo.lcdc.h_pulse_width = 16; - pinfo.lcdc.v_back_porch = 8; - pinfo.lcdc.v_front_porch = 4; - pinfo.lcdc.v_pulse_width = 1; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 15; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = FALSE; - pinfo.mipi.hbp_power_stop = FALSE; - pinfo.mipi.hsa_power_stop = FALSE; - pinfo.mipi.eof_bllp_power_stop = TRUE; - pinfo.mipi.bllp_power_stop = TRUE; - pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_PULSE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_BGR; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.t_clk_post = 0x04; - pinfo.mipi.t_clk_pre = 0x17; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - - ret = mipi_toshiba_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WVGA_PT); - if (ret) - printk(KERN_ERR "%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_toshiba_wvga_pt_init); diff --git a/drivers/video/msm/mipi_truly.c b/drivers/video/msm/mipi_truly.c deleted file mode 100644 index 277c6fcd128bac9e0b02d215f6be28a2a090bf1f..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_truly.c +++ /dev/null @@ -1,272 +0,0 @@ -/* Copyright (c) 2011-2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_truly.h" - -static struct msm_panel_common_pdata *mipi_truly_pdata; -static struct dsi_buf truly_tx_buf; -static struct dsi_buf truly_rx_buf; - -#define TRULY_CMD_DELAY 0 -#define TRULY_SLEEP_OFF_DELAY 150 -#define TRULY_DISPLAY_ON_DELAY 150 -#define GPIO_TRULY_LCD_RESET 129 - -static int prev_bl = 17; - -static char extend_cmd_enable[4] = {0xB9, 0xFF, 0x83, 0x69}; -static char display_setting[16] = { - 0xB2, 0x00, 0x23, 0x62, - 0x62, 0x70, 0x00, 0xFF, - 0x00, 0x00, 0x00, 0x00, - 0x03, 0x03, 0x00, 0x01, -}; -static char wave_cycle_setting[6] = {0xB4, 0x00, 0x1D, 0x5F, 0x0E, 0x06}; -static char gip_setting[27] = { - 0xD5, 0x00, 0x04, 0x03, - 0x00, 0x01, 0x05, 0x1C, - 0x70, 0x01, 0x03, 0x00, - 0x00, 0x40, 0x06, 0x51, - 0x07, 0x00, 0x00, 0x41, - 0x06, 0x50, 0x07, 0x07, - 0x0F, 0x04, 0x00, -}; -static char power_setting[20] = { - 0xB1, 0x01, 0x00, 0x34, - 0x06, 0x00, 0x0F, 0x0F, - 0x2A, 0x32, 0x3F, 0x3F, - 0x07, 0x3A, 0x01, 0xE6, - 0xE6, 0xE6, 0xE6, 0xE6, -}; -static char vcom_setting[3] = {0xB6, 0x56, 0x56}; -static char pannel_setting[2] = {0xCC, 0x02}; -static char gamma_setting[35] = { - 0xE0, 0x00, 0x1D, 0x22, - 0x38, 0x3D, 0x3F, 0x2E, - 0x4A, 0x06, 0x0D, 0x0F, - 0x13, 0x15, 0x13, 0x16, - 0x10, 0x19, 0x00, 0x1D, - 0x22, 0x38, 0x3D, 0x3F, - 0x2E, 0x4A, 0x06, 0x0D, - 0x0F, 0x13, 0x15, 0x13, - 0x16, 0x10, 0x19, -}; -static char mipi_setting[14] = { - 0xBA, 0x00, 0xA0, 0xC6, - 0x00, 0x0A, 0x00, 0x10, - 0x30, 0x6F, 0x02, 0x11, - 0x18, 0x40, -}; -static char exit_sleep[2] = {0x11, 0x00}; -static char display_on[2] = {0x29, 0x00}; -static char display_off[2] = {0x28, 0x00}; -static char enter_sleep[2] = {0x10, 0x00}; - -static struct dsi_cmd_desc truly_display_off_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 10, sizeof(display_off), display_off}, - {DTYPE_DCS_WRITE, 1, 0, 0, 120, sizeof(enter_sleep), enter_sleep} -}; - -static struct dsi_cmd_desc truly_display_on_cmds[] = { - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(extend_cmd_enable), extend_cmd_enable}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(display_setting), display_setting}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(wave_cycle_setting), wave_cycle_setting}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(gip_setting), gip_setting}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(power_setting), power_setting}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(vcom_setting), vcom_setting}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(pannel_setting), pannel_setting}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(gamma_setting), gamma_setting}, - {DTYPE_GEN_LWRITE, 1, 0, 0, TRULY_CMD_DELAY, - sizeof(mipi_setting), mipi_setting}, - {DTYPE_DCS_WRITE, 1, 0, 0, TRULY_SLEEP_OFF_DELAY, - sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, TRULY_DISPLAY_ON_DELAY, - sizeof(display_on), display_on}, -}; - -static int mipi_truly_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - msleep(20); - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = truly_display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(truly_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - return 0; -} - -static int mipi_truly_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = truly_display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(truly_display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - return 0; -} - -#define BL_LEVEL 17 -static void mipi_truly_set_backlight(struct msm_fb_data_type *mfd) -{ - int step = 0, i = 0; - int bl_level = mfd->bl_level; - - /* real backlight level, 1 - max, 16 - min, 17 - off */ - bl_level = BL_LEVEL - bl_level; - - if (bl_level > prev_bl) { - step = bl_level - prev_bl; - if (bl_level == BL_LEVEL) - step--; - } else if (bl_level < prev_bl) { - step = bl_level + 16 - prev_bl; - } else { - pr_debug("%s: no change\n", __func__); - return; - } - - if (bl_level == BL_LEVEL) { - /* turn off backlight */ - mipi_truly_pdata->pmic_backlight(0); - } else { - if (prev_bl == BL_LEVEL) { - /* turn on backlight */ - mipi_truly_pdata->pmic_backlight(1); - udelay(30); - } - /* adjust backlight level */ - for (i = 0; i < step; i++) { - mipi_truly_pdata->pmic_backlight(0); - udelay(1); - mipi_truly_pdata->pmic_backlight(1); - udelay(1); - } - } - msleep(20); - prev_bl = bl_level; - - return; -} - -static int mipi_truly_lcd_probe(struct platform_device *pdev) -{ - if (pdev->id == 0) { - mipi_truly_pdata = pdev->dev.platform_data; - return 0; - } - - msm_fb_add_device(pdev); - - return 0; -} - -static struct platform_driver this_driver = { - .probe = mipi_truly_lcd_probe, - .driver = { - .name = "mipi_truly", - }, -}; - -static struct msm_fb_panel_data truly_panel_data = { - .on = mipi_truly_lcd_on, - .off = mipi_truly_lcd_off, - .set_backlight = mipi_truly_set_backlight, -}; - -static int ch_used[3]; - -int mipi_truly_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - pdev = platform_device_alloc("mipi_truly", (panel << 8)|channel); - - if (!pdev) - return -ENOMEM; - - truly_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &truly_panel_data, - sizeof(truly_panel_data)); - if (ret) { - pr_err("%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - - if (ret) { - pr_err("%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} - -static int __init mipi_truly_lcd_init(void) -{ - mipi_dsi_buf_alloc(&truly_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&truly_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} - -module_init(mipi_truly_lcd_init); diff --git a/drivers/video/msm/mipi_truly.h b/drivers/video/msm/mipi_truly.h deleted file mode 100644 index 4c12ff9975507fd28dc94cdfcc485366c0ef9ced..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_truly.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2011, 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 MIPI_TRULY_H -#define MIPI_TRULY_H - -/* #define MIPI_TRULY_FAKE_PANEL */ /* FAKE PANEL for test */ - -int mipi_truly_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MIPI_TRULY_H */ diff --git a/drivers/video/msm/mipi_truly_tft540960_1_e.c b/drivers/video/msm/mipi_truly_tft540960_1_e.c deleted file mode 100644 index c519d01a63d05f5bf3909bb9710183bbbc4f9989..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_truly_tft540960_1_e.c +++ /dev/null @@ -1,914 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_truly_tft540960_1_e.h" - -static struct msm_panel_common_pdata *mipi_truly_pdata; -static struct dsi_buf truly_tx_buf; -static struct dsi_buf truly_rx_buf; - -static int mipi_truly_bl_ctrl; - -#define TRULY_CMD_DELAY 0 -#define MIPI_SETTING_DELAY 10 -#define TRULY_SLEEP_OFF_DELAY 150 -#define TRULY_DISPLAY_ON_DELAY 150 - -/* common setting */ -static char exit_sleep[2] = {0x11, 0x00}; -static char display_on[2] = {0x29, 0x00}; -static char display_off[2] = {0x28, 0x00}; -static char enter_sleep[2] = {0x10, 0x00}; -static char write_ram[2] = {0x2c, 0x00}; /* write ram */ - -static struct dsi_cmd_desc truly_display_off_cmds[] = { - {DTYPE_DCS_WRITE, 1, 0, 0, 150, sizeof(display_off), display_off}, - {DTYPE_DCS_WRITE, 1, 0, 0, 150, sizeof(enter_sleep), enter_sleep} -}; - - -/* TFT540960_1_E CMD mode */ -static char cmd0[5] = { - 0xFF, 0xAA, 0x55, 0x25, - 0x01, -}; - -static char cmd2[5] = { - 0xF3, 0x02, 0x03, 0x07, - 0x45, -}; - -static char cmd3[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x00, -}; - -static char cmd4[2] = { - 0xB1, 0xeC, -}; - -/* add 0X BD command */ -static char cmd26_2[6] = { - 0xBD, 0x01, 0x48, 0x10, 0x38, 0x01 /* 59 HZ */ -}; - -static char cmd5[5] = { - 0xB8, 0x01, 0x02, 0x02, - 0x02, -}; - -static char cmd6[4] = { - 0xBC, 0x05, 0x05, 0x05, -}; - -static char cmd7[2] = { - 0x4C, 0x11, -}; - -static char cmd8[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x01, -}; - -static char cmd9[4] = { - 0xB0, 0x05, 0x05, 0x05, -}; - -static char cmd10[4] = { - 0xB6, 0x44, 0x44, 0x44, -}; -static char cmd11[4] = { - 0xB1, 0x05, 0x05, 0x05, -}; - -static char cmd12[4] = { - 0xB7, 0x34, 0x34, 0x34, -}; - -static char cmd13[4] = { - 0xB3, 0x10, 0x10, 0x10, -}; - -static char cmd14[4] = { - 0xB9, 0x34, 0x34, 0x34, -}; - -static char cmd15[4] = { - 0xB4, 0x0A, 0x0A, 0x0A, -}; - -static char cmd16[4] = { - 0xBA, 0x14, 0x14, 0x14, -}; -static char cmd17[4] = { - 0xBC, 0x00, 0xA0, 0x00, -}; - -static char cmd18[4] = { - 0xBD, 0x00, 0xA0, 0x00, -}; - -static char cmd19[2] = { - 0xBE, 0x45, -}; - -static char cmd20[17] = { - 0xD1, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char cmd21[17] = { - 0xD2, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char cmd22[17] = { - 0xD3, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char cmd23[5] = { - 0xD4, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char cmd24[17] = { - 0xD5, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; -static char cmd25[17] = { - 0xD6, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char cmd26[17] = { - 0xD7, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; -static char cmd27[5] = { - 0xD8, 0x03, 0xB0, 0x03, - 0xF4, -}; - - -static char cmd28[17] = { - 0xD9, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char cmd29[17] = { - 0xDD, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; -static char cmd30[17] = { - 0xDE, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char cmd31[5] = { - 0xDF, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char cmd32[17] = { - 0xE0, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char cmd33[17] = { - 0xE1, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char cmd34[17] = { - 0xE2, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char cmd35[5] = { - 0xE3, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char cmd36[17] = { - 0xE4, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; -static char cmd37[17] = { - 0xE5, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char cmd38[17] = { - 0xE6, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char cmd39[5] = { - 0xE7, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char cmd40[17] = { - 0xE8, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char cmd41[17] = { - 0xE9, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char cmd42[17] = { - 0xEA, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char cmd43[5] = { - 0xEB, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char cmd44[2] = { - 0x3A, 0x07, -}; - -static char cmd45[2] = { - 0x35, 0x00, -}; - - -static struct dsi_cmd_desc truly_cmd_display_on_cmds[] = { - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd0), cmd0}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd2), cmd2}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd3), cmd3}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd4), cmd4}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd26_2), cmd26_2}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd5), cmd5}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd6), cmd6}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd7), cmd7}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd8), cmd8}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd9), cmd9}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd10), cmd10}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd11), cmd11}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd12), cmd12}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd13), cmd13}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd14), cmd14}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd15), cmd15}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd16), cmd16}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd17), cmd17}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd18), cmd18}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd19), cmd19}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd20), cmd20}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd21), cmd21}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd22), cmd22}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd23), cmd23}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd24), cmd24}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd25), cmd25}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd26), cmd26}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd27), cmd27}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd28), cmd28}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd29), cmd29}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd30), cmd30}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd31), cmd31}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd32), cmd32}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd33), cmd33}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd34), cmd34}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd35), cmd35}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd36), cmd36}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd37), cmd37}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd38), cmd38}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd39), cmd39}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd40), cmd40}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd41), cmd41}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd42), cmd42}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd43), cmd43}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd44), cmd44}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(cmd45), cmd45}, - {DTYPE_DCS_WRITE, 1, 0, 0, TRULY_SLEEP_OFF_DELAY, sizeof(exit_sleep), - exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, TRULY_CMD_DELAY, sizeof(display_on), - display_on}, - {DTYPE_DCS_WRITE, 1, 0, 0, TRULY_CMD_DELAY, sizeof(write_ram), - write_ram}, - -}; - -/* TFT540960_1_E VIDEO mode */ -static char video0[5] = { - 0xFF, 0xAA, 0x55, 0x25, - 0x01, -}; - -static char video2[5] = { - 0xF3, 0x02, 0x03, 0x07, - 0x15, -}; - -static char video3[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x00, -}; - -static char video4[2] = { - 0xB1, 0xFC, -}; - -static char video5[5] = { - 0xB8, 0x01, 0x02, 0x02, - 0x02, -}; - -static char video6[4] = { - 0xBC, 0x05, 0x05, 0x05, -}; - -static char video7[2] = { - 0x4C, 0x11, -}; - -static char video8[6] = { - 0xF0, 0x55, 0xAA, 0x52, - 0x08, 0x01, -}; - -static char video9[4] = { - 0xB0, 0x05, 0x05, 0x05, -}; - -static char video10[4] = { - 0xB6, 0x44, 0x44, 0x44, -}; - -static char video11[4] = { - 0xB1, 0x05, 0x05, 0x05, -}; - -static char video12[4] = { - 0xB7, 0x34, 0x34, 0x34, -}; - -static char video13[4] = { - 0xB3, 0x10, 0x10, 0x10, -}; - -static char video14[4] = { - 0xB9, 0x34, 0x34, 0x34, -}; - -static char video15[4] = { - 0xB4, 0x0A, 0x0A, 0x0A, -}; - -static char video16[4] = { - 0xBA, 0x14, 0x14, 0x14, -}; - -static char video17[4] = { - 0xBC, 0x00, 0xA0, 0x00, -}; - -static char video18[4] = { - 0xBD, 0x00, 0xA0, 0x00, -}; - -static char video19[2] = { - 0xBE, 0x45, -}; - -static char video20[17] = { - 0xD1, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char video21[17] = { - 0xD2, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char video22[17] = { - 0xD3, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char video23[5] = { - 0xD4, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char video24[17] = { - 0xD5, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char video25[17] = { - 0xD6, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char video26[17] = { - 0xD7, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char video27[5] = { - 0xD8, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char video28[17] = { - 0xD9, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char video29[17] = { - 0xDD, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char video30[17] = { - 0xDE, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char video31[5] = { - 0xDF, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char video32[17] = { - 0xE0, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char video33[17] = { - 0xE1, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char video34[17] = { - 0xE2, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char video35[5] = { - 0xE3, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char video36[17] = { - 0xE4, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char video37[17] = { - 0xE5, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char video38[17] = { - 0xE6, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char video39[5] = { - 0xE7, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char video40[17] = { - 0xE8, 0x00, 0x32, 0x00, - 0x41, 0x00, 0x54, 0x00, - 0x67, 0x00, 0x7A, 0x00, - 0x98, 0x00, 0xB0, 0x00, - 0xDB, -}; - -static char video41[17] = { - 0xE9, 0x01, 0x01, 0x01, - 0x3F, 0x01, 0x70, 0x01, - 0xB4, 0x01, 0xEC, 0x01, - 0xED, 0x02, 0x1E, 0x02, - 0x51, -}; - -static char video42[17] = { - 0xEA, 0x02, 0x6C, 0x02, - 0x8D, 0x02, 0xA5, 0x02, - 0xC9, 0x02, 0xEA, 0x03, - 0x19, 0x03, 0x45, 0x03, - 0x7A, -}; - -static char video43[5] = { - 0xEB, 0x03, 0xB0, 0x03, - 0xF4, -}; - -static char video44[2] = { - 0x3A, 0x07, -}; - -static char video45[2] = { - 0x35, 0x00, -}; - -static struct dsi_cmd_desc truly_video_display_on_cmds[] = { - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video0), video0}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video2), video2}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video3), video3}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video4), video4}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video5), video5}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video6), video6}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video7), video7}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video8), video8}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video9), video9}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video10), video10}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video11), video11}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video12), video12}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video13), video13}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video14), video14}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video15), video15}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video16), video16}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video17), video17}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video18), video18}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video19), video19}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video20), video20}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video21), video21}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video22), video22}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video23), video23}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video24), video24}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video25), video25}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video26), video26}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video27), video27}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video28), video28}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video29), video29}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video30), video30}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video31), video31}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video32), video32}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video33), video33}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video34), video34}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video35), video35}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video36), video36}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video37), video37}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video38), video38}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video39), video39}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video40), video40}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video41), video41}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video42), video42}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video43), video43}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video44), video44}, - {DTYPE_GEN_LWRITE, 1, 0, 0, 0, sizeof(video45), video45}, - - {DTYPE_DCS_WRITE, 1, 0, 0, 150, sizeof(exit_sleep), exit_sleep}, - {DTYPE_DCS_WRITE, 1, 0, 0, 50, sizeof(display_on), display_on}, -}; - -static int mipi_truly_lcd_on(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct mipi_panel_info *mipi; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - mipi = &mfd->panel_info.mipi; - pr_info("%s: mode = %d\n", __func__, mipi->mode); - msleep(120); - - memset(&cmdreq, 0, sizeof(cmdreq)); - if (mipi->mode == DSI_VIDEO_MODE) { - cmdreq.cmds = truly_video_display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(truly_video_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } else if (mipi->mode == DSI_CMD_MODE) { - cmdreq.cmds = truly_cmd_display_on_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(truly_cmd_display_on_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - } - - return 0; -} - -static int mipi_truly_lcd_off(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct dcs_cmd_req cmdreq; - - mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - if (mfd->key != MFD_KEY) - return -EINVAL; - - memset(&cmdreq, 0, sizeof(cmdreq)); - cmdreq.cmds = truly_display_off_cmds; - cmdreq.cmds_cnt = ARRAY_SIZE(truly_display_off_cmds); - cmdreq.flags = CMD_REQ_COMMIT; - cmdreq.rlen = 0; - cmdreq.cb = NULL; - mipi_dsi_cmdlist_put(&cmdreq); - - return 0; -} - -static ssize_t mipi_truly_wta_bl_ctrl(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - ssize_t ret = strnlen(buf, PAGE_SIZE); - int err; - - err = kstrtoint(buf, 0, &mipi_truly_bl_ctrl); - if (err) - return ret; - - pr_info("%s: bl ctrl set to %d\n", __func__, mipi_truly_bl_ctrl); - - return ret; -} - -static DEVICE_ATTR(bl_ctrl, S_IWUSR, NULL, mipi_truly_wta_bl_ctrl); - -static struct attribute *mipi_truly_fs_attrs[] = { - &dev_attr_bl_ctrl.attr, - NULL, -}; - -static struct attribute_group mipi_truly_fs_attr_group = { - .attrs = mipi_truly_fs_attrs, -}; - -static int mipi_truly_create_sysfs(struct platform_device *pdev) -{ - int rc; - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - - if (!mfd) { - pr_err("%s: mfd not found\n", __func__); - return -ENODEV; - } - if (!mfd->fbi) { - pr_err("%s: mfd->fbi not found\n", __func__); - return -ENODEV; - } - if (!mfd->fbi->dev) { - pr_err("%s: mfd->fbi->dev not found\n", __func__); - return -ENODEV; - } - rc = sysfs_create_group(&mfd->fbi->dev->kobj, - &mipi_truly_fs_attr_group); - if (rc) { - pr_err("%s: sysfs group creation failed, rc=%d\n", - __func__, rc); - return rc; - } - - return 0; -} - - -static int mipi_truly_lcd_probe(struct platform_device *pdev) -{ - struct platform_device *pthisdev = NULL; - int rc = 0; - - if (pdev->id == 0) { - mipi_truly_pdata = pdev->dev.platform_data; - if (mipi_truly_pdata->bl_lock) - spin_lock_init(&mipi_truly_pdata->bl_spinlock); - return rc; - } - - pthisdev = msm_fb_add_device(pdev); - mipi_truly_create_sysfs(pthisdev); - - return rc; -} - -static struct platform_driver this_driver = { - .probe = mipi_truly_lcd_probe, - .driver = { - .name = "mipi_truly_tft540960_1_e", - }, -}; - -static int old_bl_level; - -static void mipi_truly_set_backlight(struct msm_fb_data_type *mfd) -{ - int bl_level; - unsigned long flags; - bl_level = mfd->bl_level; - - if (mipi_truly_pdata->bl_lock) { - if (!mipi_truly_bl_ctrl) { - /* Level received is of range 1 to bl_max, - We need to convert the levels to 1 - to 31 */ - bl_level = (2 * bl_level * 31 + mfd->panel_info.bl_max) - /(2 * mfd->panel_info.bl_max); - if (bl_level == old_bl_level) - return; - - if (bl_level == 0) - mipi_truly_pdata->backlight(0, 1); - - if (old_bl_level == 0) - mipi_truly_pdata->backlight(50, 1); - - spin_lock_irqsave(&mipi_truly_pdata->bl_spinlock, - flags); - mipi_truly_pdata->backlight(bl_level, 0); - spin_unlock_irqrestore(&mipi_truly_pdata->bl_spinlock, - flags); - old_bl_level = bl_level; - } else { - mipi_truly_pdata->backlight(bl_level, 1); - } - } else { - mipi_truly_pdata->backlight(bl_level, mipi_truly_bl_ctrl); - } -} - -static struct msm_fb_panel_data truly_panel_data = { - .on = mipi_truly_lcd_on, - .off = mipi_truly_lcd_off, - .set_backlight = mipi_truly_set_backlight, -}; - -static int ch_used[3]; - -static int mipi_truly_tft540960_1_e_lcd_init(void) -{ - mipi_dsi_buf_alloc(&truly_tx_buf, DSI_BUF_SIZE); - mipi_dsi_buf_alloc(&truly_rx_buf, DSI_BUF_SIZE); - - return platform_driver_register(&this_driver); -} -int mipi_truly_tft540960_1_e_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel) -{ - struct platform_device *pdev = NULL; - int ret; - - if ((channel >= 3) || ch_used[channel]) - return -ENODEV; - - ch_used[channel] = TRUE; - - ret = mipi_truly_tft540960_1_e_lcd_init(); - if (ret) { - pr_err("%s: platform_device_register failed!\n", __func__); - return ret; - } - - pdev = platform_device_alloc("mipi_truly_tft540960_1_e", - (panel << 8)|channel); - if (!pdev) - return -ENOMEM; - - truly_panel_data.panel_info = *pinfo; - - ret = platform_device_add_data(pdev, &truly_panel_data, - sizeof(truly_panel_data)); - if (ret) { - pr_err("%s: platform_device_add_data failed!\n", __func__); - goto err_device_put; - } - - ret = platform_device_add(pdev); - if (ret) { - pr_err("%s: platform_device_register failed!\n", __func__); - goto err_device_put; - } - - return 0; - -err_device_put: - platform_device_put(pdev); - return ret; -} diff --git a/drivers/video/msm/mipi_truly_tft540960_1_e.h b/drivers/video/msm/mipi_truly_tft540960_1_e.h deleted file mode 100644 index d7329d6a81489464b87dae1dbfc6da57265f5c04..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_truly_tft540960_1_e.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2012, 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 MIPI_TRULY_H -#define MIPI_TRULY_H - -int mipi_truly_tft540960_1_e_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MIPI_TRULY_H */ diff --git a/drivers/video/msm/mipi_truly_tft540960_1_e_cmd_qhd_pt.c b/drivers/video/msm/mipi_truly_tft540960_1_e_cmd_qhd_pt.c deleted file mode 100644 index ad7ebe98ad748af62ced64ad64c6d1eae04498d8..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_truly_tft540960_1_e_cmd_qhd_pt.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_truly_tft540960_1_e.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_cmd_mode_phy_db = { - /* DSI Bit Clock at 500 MHz, 2 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, 0x90, - 0x18, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xbb, 0x02, 0x06, 0x00}, - /* pll control */ - {0x01, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, - 0x01, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, -}; - -static int mipi_cmd_truly_qhd_pt_init(void) -{ - int ret; - if (msm_fb_detect_client("mipi_cmd_truly_qhd")) - return 0; - - pinfo.xres = 540; - pinfo.yres = 960; - pinfo.type = MIPI_CMD_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 100; - pinfo.lcdc.h_front_porch = 100; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 20; - pinfo.lcdc.v_front_porch = 20; - pinfo.lcdc.v_pulse_width = 1; - - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - pinfo.lcdc.hsync_skew = 0; - pinfo.bl_max = 255; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.clk_rate = 499000000; - - pinfo.lcd.vsync_enable = TRUE; - pinfo.lcd.hw_vsync_mode = TRUE; - pinfo.lcd.refx100 = 6100; /* adjust refx100 to prevent tearing */ - - pinfo.mipi.mode = DSI_CMD_MODE; - pinfo.mipi.dst_format = DSI_CMD_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - pinfo.mipi.t_clk_post = 0x20; - pinfo.mipi.t_clk_pre = 0x2F; - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW_TE; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.te_sel = 1; /* TE from vsync gpio */ - pinfo.mipi.interleave_max = 1; - pinfo.mipi.insert_dcs_cmd = TRUE; - pinfo.mipi.wr_mem_continue = 0x3c; - pinfo.mipi.wr_mem_start = 0x2c; - pinfo.mipi.dsi_phy_db = &dsi_cmd_mode_phy_db; - pinfo.mipi.tx_eot_append = 0x01; - pinfo.mipi.rx_eot_ignore = 0x0; - pinfo.mipi.dlane_swap = 0x01; - - ret = mipi_truly_tft540960_1_e_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WVGA_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_cmd_truly_qhd_pt_init); diff --git a/drivers/video/msm/mipi_truly_tft540960_1_e_video_qhd_pt.c b/drivers/video/msm/mipi_truly_tft540960_1_e_video_qhd_pt.c deleted file mode 100644 index d62cfc9849e0b360d391060aceaadbdac008765c..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_truly_tft540960_1_e_video_qhd_pt.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) 2012, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_truly_tft540960_1_e.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* DSI Bit Clock at 500 MHz, 2 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, 0x90, - 0x18, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xbb, 0x02, 0x06, 0x00}, - /* pll control */ - {0x00, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, - 0x01, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, -}; - -static int mipi_video_truly_qhd_pt_init(void) -{ - int ret; - if (msm_fb_detect_client("mipi_video_truly_qhd")) - return 0; - - pinfo.xres = 540; - pinfo.yres = 960; - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 100; - pinfo.lcdc.h_front_porch = 100; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 20; - pinfo.lcdc.v_front_porch = 20; - pinfo.lcdc.v_pulse_width = 1; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - /* number of dot_clk cycles HSYNC active edge - is delayed from VSYNC active edge */ - pinfo.lcdc.hsync_skew = 0; - pinfo.clk_rate = 699000000; - pinfo.lcd.refx100 = 6000; /* FB driver calc FPS based on this value */ - pinfo.bl_max = 255; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - /* send HSA and HE following VS/VE packet */ - pinfo.mipi.pulse_mode_hsa_he = TRUE; - pinfo.mipi.hfp_power_stop = TRUE; /* LP-11 during the HFP period */ - pinfo.mipi.hbp_power_stop = TRUE; /* LP-11 during the HBP period */ - pinfo.mipi.hsa_power_stop = TRUE; /* LP-11 during the HSA period */ - /* LP-11 or let Command Mode Engine send packets in - HS or LP mode for the BLLP of the last line of a frame */ - pinfo.mipi.eof_bllp_power_stop = TRUE; - /* LP-11 or let Command Mode Engine send packets in - HS or LP mode for packets sent during BLLP period */ - pinfo.mipi.bllp_power_stop = TRUE; - - pinfo.mipi.traffic_mode = DSI_BURST_MODE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; /* RGB */ - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - - pinfo.mipi.t_clk_post = 0x20; - pinfo.mipi.t_clk_pre = 0x2f; - - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; - - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - pinfo.mipi.dlane_swap = 0x01; - /* append EOT at the end of data burst */ - pinfo.mipi.tx_eot_append = 0x01; - - ret = mipi_truly_tft540960_1_e_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WVGA_PT); - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_truly_qhd_pt_init); diff --git a/drivers/video/msm/mipi_truly_video_wvga_pt.c b/drivers/video/msm/mipi_truly_video_wvga_pt.c deleted file mode 100644 index 3fc14d2e8782b2d43355be3f3e7f4a0266b819e1..0000000000000000000000000000000000000000 --- a/drivers/video/msm/mipi_truly_video_wvga_pt.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Copyright (c) 2011, 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 "msm_fb.h" -#include "mipi_dsi.h" -#include "mipi_truly.h" - -static struct msm_panel_info pinfo; - -static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = { - /* DSI Bit Clock at 500 MHz, 2 lane, RGB888 */ - /* regulator */ - {0x03, 0x01, 0x01, 0x00}, - /* timing */ - {0xb9, 0x8e, 0x1f, 0x00, 0x98, 0x9c, 0x22, 0x90, - 0x18, 0x03, 0x04}, - /* phy ctrl */ - {0x7f, 0x00, 0x00, 0x00}, - /* strength */ - {0xbb, 0x02, 0x06, 0x00}, - /* pll control */ - {0x00, 0xec, 0x31, 0xd2, 0x00, 0x40, 0x37, 0x62, - 0x01, 0x0f, 0x07, - 0x05, 0x14, 0x03, 0x0, 0x0, 0x0, 0x20, 0x0, 0x02, 0x0}, -}; - -static int __init mipi_video_truly_wvga_pt_init(void) -{ - int ret; - - if (msm_fb_detect_client("mipi_video_truly_wvga")) - return 0; - - pinfo.xres = 480; - pinfo.yres = 800; - pinfo.type = MIPI_VIDEO_PANEL; - pinfo.pdest = DISPLAY_1; - pinfo.wait_cycle = 0; - pinfo.bpp = 24; - pinfo.lcdc.h_back_porch = 100; - pinfo.lcdc.h_front_porch = 100; - pinfo.lcdc.h_pulse_width = 8; - pinfo.lcdc.v_back_porch = 20; - pinfo.lcdc.v_front_porch = 20; - pinfo.lcdc.v_pulse_width = 1; - pinfo.lcdc.border_clr = 0; /* blk */ - pinfo.lcdc.underflow_clr = 0xff; /* blue */ - /* number of dot_clk cycles HSYNC active edge - is delayed from VSYNC active edge */ - pinfo.lcdc.hsync_skew = 0; - pinfo.clk_rate = 499000000; - pinfo.bl_max = 15; - pinfo.bl_min = 1; - pinfo.fb_num = 2; - - pinfo.mipi.mode = DSI_VIDEO_MODE; - pinfo.mipi.pulse_mode_hsa_he = TRUE; /* send HSA and HE following - VS/VE packet */ - pinfo.mipi.hfp_power_stop = TRUE; /* LP-11 during the HFP period */ - pinfo.mipi.hbp_power_stop = TRUE; /* LP-11 during the HBP period */ - pinfo.mipi.hsa_power_stop = TRUE; /* LP-11 during the HSA period */ - /* LP-11 or let Command Mode Engine send packets in - HS or LP mode for the BLLP of the last line of a frame */ - pinfo.mipi.eof_bllp_power_stop = TRUE; - /* LP-11 or let Command Mode Engine send packets in - HS or LP mode for packets sent during BLLP period */ - pinfo.mipi.bllp_power_stop = TRUE; - - pinfo.mipi.traffic_mode = DSI_BURST_MODE; - pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; - pinfo.mipi.vc = 0; - pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; /* RGB */ - pinfo.mipi.data_lane0 = TRUE; - pinfo.mipi.data_lane1 = TRUE; - - pinfo.mipi.t_clk_post = 0x20; - pinfo.mipi.t_clk_pre = 0x2f; - - pinfo.mipi.stream = 0; /* dma_p */ - pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE; - pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; - pinfo.mipi.frame_rate = 60; /* FIXME */ - - pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db; - pinfo.mipi.dlane_swap = 0x01; - pinfo.mipi.tx_eot_append = 0x01; /* append EOT at the end - of data burst */ - - ret = mipi_truly_device_register(&pinfo, MIPI_DSI_PRIM, - MIPI_DSI_PANEL_WVGA_PT); - - if (ret) - pr_err("%s: failed to register device!\n", __func__); - - return ret; -} - -module_init(mipi_video_truly_wvga_pt_init); diff --git a/drivers/video/msm/msm_dss_io_7x27a.c b/drivers/video/msm/msm_dss_io_7x27a.c deleted file mode 100644 index 8610a2115f5f5dd228f60367e1ce7ee811691c42..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_dss_io_7x27a.c +++ /dev/null @@ -1,488 +0,0 @@ -/* Copyright (c) 2008-2012, 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 -#include "msm_fb.h" -#include "mipi_dsi.h" - -/* multimedia sub system sfpb */ -char *mmss_sfpb_base; -void __iomem *periph_base; - -static struct dsi_clk_desc dsicore_clk; -static struct dsi_clk_desc dsi_pclk; - -static struct clk *dsi_byte_div_clk; -static struct clk *dsi_esc_clk; -static struct clk *dsi_pixel_clk; -static struct clk *dsi_clk; -static struct clk *dsi_ref_clk; -static struct clk *mdp_dsi_pclk; -static struct clk *ahb_m_clk; -static struct clk *ahb_s_clk; -static struct clk *ebi1_dsi_clk; -int mipi_dsi_clk_on; - -int mipi_dsi_clk_init(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - dsi_esc_clk = clk_get(dev, "esc_clk"); - if (IS_ERR_OR_NULL(dsi_esc_clk)) { - printk(KERN_ERR "can't find dsi_esc_clk\n"); - dsi_esc_clk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_byte_div_clk = clk_get(dev, "byte_clk"); - if (IS_ERR_OR_NULL(dsi_byte_div_clk)) { - pr_err("can't find dsi_byte_div_clk\n"); - dsi_byte_div_clk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_pixel_clk = clk_get(dev, "pixel_clk"); - if (IS_ERR_OR_NULL(dsi_pixel_clk)) { - pr_err("can't find dsi_pixel_clk\n"); - dsi_pixel_clk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_clk = clk_get(dev, "core_clk"); - if (IS_ERR_OR_NULL(dsi_clk)) { - pr_err("can't find dsi_clk\n"); - dsi_clk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_ref_clk = clk_get(dev, "ref_clk"); - if (IS_ERR_OR_NULL(dsi_ref_clk)) { - pr_err("can't find dsi_ref_clk\n"); - dsi_ref_clk = NULL; - goto mipi_dsi_clk_err; - } - - mdp_dsi_pclk = clk_get(dev, "mdp_clk"); - if (IS_ERR_OR_NULL(mdp_dsi_pclk)) { - pr_err("can't find mdp_dsi_pclk\n"); - mdp_dsi_pclk = NULL; - goto mipi_dsi_clk_err; - } - - ahb_m_clk = clk_get(dev, "master_iface_clk"); - if (IS_ERR_OR_NULL(ahb_m_clk)) { - pr_err("can't find ahb_m_clk\n"); - ahb_m_clk = NULL; - goto mipi_dsi_clk_err; - } - - ahb_s_clk = clk_get(dev, "slave_iface_clk"); - if (IS_ERR_OR_NULL(ahb_s_clk)) { - pr_err("can't find ahb_s_clk\n"); - ahb_s_clk = NULL; - goto mipi_dsi_clk_err; - } - - ebi1_dsi_clk = clk_get(dev, "mem_clk"); - if (IS_ERR_OR_NULL(ebi1_dsi_clk)) { - pr_err("can't find ebi1_dsi_clk\n"); - ebi1_dsi_clk = NULL; - goto mipi_dsi_clk_err; - } - - return 0; - -mipi_dsi_clk_err: - mipi_dsi_clk_deinit(NULL); - return -EPERM; -} - -void mipi_dsi_clk_deinit(struct device *dev) -{ - if (mdp_dsi_pclk) - clk_put(mdp_dsi_pclk); - if (ahb_m_clk) - clk_put(ahb_m_clk); - if (ahb_s_clk) - clk_put(ahb_s_clk); - if (dsi_ref_clk) - clk_put(dsi_ref_clk); - if (dsi_byte_div_clk) - clk_put(dsi_byte_div_clk); - if (dsi_esc_clk) - clk_put(dsi_esc_clk); - if (ebi1_dsi_clk) - clk_put(ebi1_dsi_clk); -} - -static void mipi_dsi_clk_ctrl(struct dsi_clk_desc *clk, int clk_en) -{ - uint32 data; - if (clk_en) { - data = (clk->pre_div_func) << 24 | - (clk->m) << 16 | (clk->n) << 8 | - ((clk->d) * 2); - clk_set_rate(dsi_clk, data); - clk_enable(dsi_clk); - } else - clk_disable(dsi_clk); -} - -static void mipi_dsi_pclk_ctrl(struct dsi_clk_desc *clk, int clk_en) -{ - uint32 data; - - if (clk_en) { - data = (clk->pre_div_func) << 24 | (clk->m) << 16 - | (clk->n) << 8 | ((clk->d) * 2); - if ((clk_set_rate(dsi_pixel_clk, data)) < 0) - pr_err("%s: pixel clk set rate failed\n", __func__); - if (clk_enable(dsi_pixel_clk)) - pr_err("%s clk enable failed\n", __func__); - } else { - clk_disable(dsi_pixel_clk); - } -} - -static void mipi_dsi_calibration(void) -{ - MIPI_OUTP(MIPI_DSI_BASE + 0xf8, 0x00a105a1); /* cal_hw_ctrl */ -} - -#define PREF_DIV_RATIO 19 -struct dsiphy_pll_divider_config pll_divider_config; - -int mipi_dsi_clk_div_config(uint8 bpp, uint8 lanes, - uint32 *expected_dsi_pclk) -{ - u32 fb_divider, rate, vco; - u32 div_ratio = 0; - struct dsi_clk_mnd_table const *mnd_entry = mnd_table; - if (pll_divider_config.clk_rate == 0) - pll_divider_config.clk_rate = 454000000; - - rate = pll_divider_config.clk_rate / 1000000; /* In Mhz */ - - if (rate < 125) { - vco = rate * 8; - div_ratio = 8; - } else if (rate < 250) { - vco = rate * 4; - div_ratio = 4; - } else if (rate < 500) { - vco = rate * 2; - div_ratio = 2; - } else { - vco = rate * 1; - div_ratio = 1; - } - - /* find the mnd settings from mnd_table entry */ - for (; mnd_entry != mnd_table + ARRAY_SIZE(mnd_table); ++mnd_entry) { - if (((mnd_entry->lanes) == lanes) && - ((mnd_entry->bpp) == bpp)) - break; - } - - if (mnd_entry == mnd_table + ARRAY_SIZE(mnd_table)) { - pr_err("%s: requested Lanes, %u & BPP, %u, not supported\n", - __func__, lanes, bpp); - return -EINVAL; - } - fb_divider = ((vco * PREF_DIV_RATIO) / 27); - pll_divider_config.fb_divider = fb_divider; - pll_divider_config.ref_divider_ratio = PREF_DIV_RATIO; - pll_divider_config.bit_clk_divider = div_ratio; - pll_divider_config.byte_clk_divider = - pll_divider_config.bit_clk_divider * 8; - pll_divider_config.dsi_clk_divider = - (mnd_entry->dsiclk_div) * div_ratio; - - if ((mnd_entry->dsiclk_d == 0) - || (mnd_entry->dsiclk_m == 1)) { - dsicore_clk.mnd_mode = 0; - dsicore_clk.src = 0x3; - dsicore_clk.pre_div_func = (mnd_entry->dsiclk_n - 1); - } else { - dsicore_clk.mnd_mode = 2; - dsicore_clk.src = 0x3; - dsicore_clk.m = mnd_entry->dsiclk_m; - dsicore_clk.n = mnd_entry->dsiclk_n; - dsicore_clk.d = mnd_entry->dsiclk_d; - } - - if ((mnd_entry->pclk_d == 0) - || (mnd_entry->pclk_m == 1)) { - dsi_pclk.mnd_mode = 0; - dsi_pclk.src = 0x3; - dsi_pclk.pre_div_func = (mnd_entry->pclk_n - 1); - *expected_dsi_pclk = ((vco * 1000000) / - ((pll_divider_config.dsi_clk_divider) - * (mnd_entry->pclk_n))); - } else { - dsi_pclk.mnd_mode = 2; - dsi_pclk.src = 0x3; - dsi_pclk.m = mnd_entry->pclk_m; - dsi_pclk.n = mnd_entry->pclk_n; - dsi_pclk.d = mnd_entry->pclk_d; - *expected_dsi_pclk = ((vco * 1000000 * dsi_pclk.m) / - ((pll_divider_config.dsi_clk_divider) - * (mnd_entry->pclk_n))); - } - dsicore_clk.m = 1; - dsicore_clk.n = 1; - dsicore_clk.d = 2; - dsicore_clk.pre_div_func = 0; - - dsi_pclk.m = 1; - dsi_pclk.n = 3; - dsi_pclk.d = 2; - dsi_pclk.pre_div_func = 0; - return 0; -} - -void mipi_dsi_phy_init(int panel_ndx, struct msm_panel_info const *panel_info, - int target_type) -{ - struct mipi_dsi_phy_ctrl *pd; - int i, off; - - MIPI_OUTP(MIPI_DSI_BASE + 0x128, 0x0001);/* start phy sw reset */ - wmb(); - usleep(1000); - MIPI_OUTP(MIPI_DSI_BASE + 0x128, 0x0000);/* end phy w reset */ - wmb(); - usleep(1000); - MIPI_OUTP(MIPI_DSI_BASE + 0x2cc, 0x0003);/* regulator_ctrl_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x2d0, 0x0001);/* regulator_ctrl_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x2d4, 0x0001);/* regulator_ctrl_2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x2d8, 0x0000);/* regulator_ctrl_3 */ -#ifdef DSI_POWER - MIPI_OUTP(MIPI_DSI_BASE + 0x2dc, 0x0100);/* regulator_ctrl_4 */ -#endif - - pd = (panel_info->mipi).dsi_phy_db; - - off = 0x02cc; /* regulator ctrl 0 */ - for (i = 0; i < 4; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->regulator[i]); - wmb(); - off += 4; - } - - off = 0x0260; /* phy timig ctrl 0 */ - for (i = 0; i < 11; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->timing[i]); - wmb(); - off += 4; - } - - off = 0x0290; /* ctrl 0 */ - for (i = 0; i < 4; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->ctrl[i]); - wmb(); - off += 4; - } - - off = 0x02a0; /* strength 0 */ - for (i = 0; i < 4; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->strength[i]); - wmb(); - off += 4; - } - - mipi_dsi_calibration(); - - off = 0x0204; /* pll ctrl 1, skip 0 */ - for (i = 1; i < 21; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->pll[i]); - wmb(); - off += 4; - } - - MIPI_OUTP(MIPI_DSI_BASE + 0x100, 0x67); - - /* pll ctrl 0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0200, pd->pll[0]); - wmb(); -} - -void cont_splash_clk_ctrl(int enable) -{ - static int cont_splash_clks_enabled; - if (enable && !cont_splash_clks_enabled) { - clk_prepare_enable(dsi_ref_clk); - clk_prepare_enable(mdp_dsi_pclk); - clk_prepare_enable(dsi_byte_div_clk); - clk_prepare_enable(dsi_esc_clk); - clk_prepare_enable(dsi_pixel_clk); - clk_prepare_enable(dsi_clk); - cont_splash_clks_enabled = 1; - } else if (!enable && cont_splash_clks_enabled) { - clk_disable_unprepare(dsi_clk); - clk_disable_unprepare(dsi_pixel_clk); - clk_disable_unprepare(dsi_esc_clk); - clk_disable_unprepare(dsi_byte_div_clk); - clk_disable_unprepare(mdp_dsi_pclk); - clk_disable_unprepare(dsi_ref_clk); - cont_splash_clks_enabled = 0; - } -} - -void mipi_dsi_prepare_clocks(void) -{ - clk_prepare(dsi_ref_clk); - clk_prepare(ahb_m_clk); - clk_prepare(ahb_s_clk); - clk_prepare(ebi1_dsi_clk); - clk_prepare(mdp_dsi_pclk); - clk_prepare(dsi_byte_div_clk); - clk_prepare(dsi_esc_clk); - clk_prepare(dsi_clk); - clk_prepare(dsi_pixel_clk); -} - -void mipi_dsi_unprepare_clocks(void) -{ - clk_unprepare(dsi_esc_clk); - clk_unprepare(dsi_byte_div_clk); - clk_unprepare(mdp_dsi_pclk); - clk_unprepare(ebi1_dsi_clk); - clk_unprepare(ahb_m_clk); - clk_unprepare(ahb_s_clk); - clk_unprepare(dsi_ref_clk); - clk_unprepare(dsi_clk); - clk_unprepare(dsi_pixel_clk); -} - -void mipi_dsi_ahb_ctrl(u32 enable) -{ - static int ahb_ctrl_done; - if (enable) { - if (ahb_ctrl_done) { - pr_info("%s: ahb clks already ON\n", __func__); - return; - } - clk_enable(dsi_ref_clk); - clk_enable(ahb_m_clk); - clk_enable(ahb_s_clk); - ahb_ctrl_done = 1; - } else { - if (ahb_ctrl_done == 0) { - pr_info("%s: ahb clks already OFF\n", __func__); - return; - } - clk_disable(ahb_m_clk); - clk_disable(ahb_s_clk); - clk_disable(dsi_ref_clk); - ahb_ctrl_done = 0; - } -} - -void mipi_dsi_clk_enable(void) -{ - unsigned data = 0; - uint32 pll_ctrl; - - if (mipi_dsi_clk_on) { - pr_info("%s: mipi_dsi_clks already ON\n", __func__); - return; - } - if (clk_set_rate(ebi1_dsi_clk, 65000000)) /* 65 MHz */ - pr_err("%s: ebi1_dsi_clk set rate failed\n", __func__); - clk_enable(ebi1_dsi_clk); - - pll_ctrl = MIPI_INP(MIPI_DSI_BASE + 0x0200); - MIPI_OUTP(MIPI_DSI_BASE + 0x0200, pll_ctrl | 0x01); - mb(); - - clk_set_rate(dsi_byte_div_clk, data); - clk_set_rate(dsi_esc_clk, data); - clk_enable(mdp_dsi_pclk); - clk_enable(dsi_byte_div_clk); - clk_enable(dsi_esc_clk); - mipi_dsi_pclk_ctrl(&dsi_pclk, 1); - mipi_dsi_clk_ctrl(&dsicore_clk, 1); - mipi_dsi_clk_on = 1; -} - -void mipi_dsi_clk_disable(void) -{ - if (mipi_dsi_clk_on == 0) { - pr_info("%s: mipi_dsi_clks already OFF\n", __func__); - return; - } - mipi_dsi_pclk_ctrl(&dsi_pclk, 0); - mipi_dsi_clk_ctrl(&dsicore_clk, 0); - clk_disable(dsi_esc_clk); - clk_disable(dsi_byte_div_clk); - clk_disable(mdp_dsi_pclk); - /* DSIPHY_PLL_CTRL_0, disable dsi pll */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0200, 0x40); - if (clk_set_rate(ebi1_dsi_clk, 0)) - pr_err("%s: ebi1_dsi_clk set rate failed\n", __func__); - clk_disable(ebi1_dsi_clk); - mipi_dsi_clk_on = 0; -} - -void mipi_dsi_phy_ctrl(int on) -{ - if (on) { - /* DSIPHY_PLL_CTRL_5 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0214, 0x050); - - /* DSIPHY_TPA_CTRL_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0258, 0x00f); - - /* DSIPHY_TPA_CTRL_2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x025c, 0x000); - } else { - /* DSIPHY_PLL_CTRL_5 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0214, 0x05f); - - /* DSIPHY_TPA_CTRL_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0258, 0x08f); - - /* DSIPHY_TPA_CTRL_2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x025c, 0x001); - - /* DSIPHY_REGULATOR_CTRL_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x02cc, 0x02); - - /* DSIPHY_CTRL_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0290, 0x00); - - /* DSIPHY_CTRL_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0294, 0x7f); - - /* disable dsi clk */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0118, 0); - } -} - -#ifdef CONFIG_FB_MSM_MDP303 -void update_lane_config(struct msm_panel_info *pinfo) -{ - struct mipi_dsi_phy_ctrl *pd; - - pd = (pinfo->mipi).dsi_phy_db; - pinfo->mipi.data_lane1 = FALSE; - pd->pll[10] |= 0x08; - - pinfo->yres = 320; - pinfo->lcdc.h_back_porch = 15; - pinfo->lcdc.h_front_porch = 21; - pinfo->lcdc.h_pulse_width = 5; - pinfo->lcdc.v_back_porch = 50; - pinfo->lcdc.v_front_porch = 101; - pinfo->lcdc.v_pulse_width = 50; -} -#endif diff --git a/drivers/video/msm/msm_dss_io_8960.c b/drivers/video/msm/msm_dss_io_8960.c deleted file mode 100644 index b1f2b343e77fc32991f5311031377433c5210e5c..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_dss_io_8960.c +++ /dev/null @@ -1,829 +0,0 @@ -/* Copyright (c) 2008-2012, 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 -#include -#include "msm_fb.h" -#include "mdp.h" -#include "mdp4.h" -#include "mipi_dsi.h" -#include "hdmi_msm.h" -#include - -/* HDMI PHY macros */ -#define HDMI_PHY_REG_0 (0x00000400) -#define HDMI_PHY_REG_1 (0x00000404) -#define HDMI_PHY_REG_2 (0x00000408) -#define HDMI_PHY_REG_3 (0x0000040c) -#define HDMI_PHY_REG_4 (0x00000410) -#define HDMI_PHY_REG_5 (0x00000414) -#define HDMI_PHY_REG_6 (0x00000418) -#define HDMI_PHY_REG_7 (0x0000041c) -#define HDMI_PHY_REG_8 (0x00000420) -#define HDMI_PHY_REG_9 (0x00000424) -#define HDMI_PHY_REG_10 (0x00000428) -#define HDMI_PHY_REG_11 (0x0000042c) -#define HDMI_PHY_REG_12 (0x00000430) -#define HDMI_PHY_REG_BIST_CFG (0x00000434) -#define HDMI_PHY_DEBUG_BUS_SEL (0x00000438) -#define HDMI_PHY_REG_MISC0 (0x0000043c) -#define HDMI_PHY_REG_13 (0x00000440) -#define HDMI_PHY_REG_14 (0x00000444) -#define HDMI_PHY_REG_15 (0x00000448) -#define HDMI_PHY_CTRL (0x000002D4) - -/* HDMI PHY/PLL bit field macros */ -#define HDMI_PHY_PLL_STATUS0 (0x00000598) -#define SW_RESET BIT(2) -#define SW_RESET_PLL BIT(0) -#define PWRDN_B BIT(7) - -/* multimedia sub system clock control */ -char *mmss_cc_base = MSM_MMSS_CLK_CTL_BASE; -/* multimedia sub system sfpb */ -char *mmss_sfpb_base; -void __iomem *periph_base; - -static struct dsi_clk_desc dsicore_clk; -static struct dsi_clk_desc dsi_pclk; - -static struct clk *dsi_byte_div_clk; -static struct clk *dsi_esc_clk; -static struct clk *dsi_m_pclk; -static struct clk *dsi_s_pclk; - -static struct clk *amp_pclk; -int mipi_dsi_clk_on; - -int mipi_dsi_clk_init(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct device *dev = &pdev->dev; - - mfd = platform_get_drvdata(pdev); - - amp_pclk = clk_get(dev, "arb_clk"); - if (IS_ERR_OR_NULL(amp_pclk)) { - pr_err("can't find amp_pclk\n"); - amp_pclk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_m_pclk = clk_get(dev, "master_iface_clk"); - if (IS_ERR_OR_NULL(dsi_m_pclk)) { - pr_err("can't find dsi_m_pclk\n"); - dsi_m_pclk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_s_pclk = clk_get(dev, "slave_iface_clk"); - if (IS_ERR_OR_NULL(dsi_s_pclk)) { - pr_err("can't find dsi_s_pclk\n"); - dsi_s_pclk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_byte_div_clk = clk_get(dev, "byte_clk"); - if (IS_ERR(dsi_byte_div_clk)) { - pr_err("can't find dsi_byte_div_clk\n"); - dsi_byte_div_clk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_esc_clk = clk_get(dev, "esc_clk"); - if (IS_ERR(dsi_esc_clk)) { - printk(KERN_ERR "can't find dsi_esc_clk\n"); - dsi_esc_clk = NULL; - goto mipi_dsi_clk_err; - } - - return 0; - -mipi_dsi_clk_err: - mipi_dsi_clk_deinit(dev); - return -EPERM; -} - -void mipi_dsi_clk_deinit(struct device *dev) -{ - if (amp_pclk) - clk_put(amp_pclk); - if (amp_pclk) - clk_put(dsi_m_pclk); - if (dsi_s_pclk) - clk_put(dsi_s_pclk); - if (dsi_byte_div_clk) - clk_put(dsi_byte_div_clk); - if (dsi_esc_clk) - clk_put(dsi_esc_clk); -} - -static void mipi_dsi_clk_ctrl(struct dsi_clk_desc *clk, int clk_en) -{ - char *cc, *ns, *md; - int pmxo_sel = 0; - char mnd_en = 1, root_en = 1; - uint32 data, val; - - cc = mmss_cc_base + 0x004c; - md = mmss_cc_base + 0x0050; - ns = mmss_cc_base + 0x0054; - - if (clk_en) { - if (clk->mnd_mode == 0) { - data = clk->pre_div_func << 14; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - MIPI_OUTP_SECURE(cc, ((pmxo_sel << 8) - | (clk->mnd_mode << 6) - | (root_en << 2) | clk_en)); - } else { - val = clk->d * 2; - data = (~val) & 0x0ff; - data |= clk->m << 8; - MIPI_OUTP_SECURE(md, data); - - val = clk->n - clk->m; - data = (~val) & 0x0ff; - data <<= 24; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - - MIPI_OUTP_SECURE(cc, ((pmxo_sel << 8) - | (clk->mnd_mode << 6) - | (mnd_en << 5) - | (root_en << 2) | clk_en)); - } - } else - MIPI_OUTP_SECURE(cc, 0); - - wmb(); -} - -static void mipi_dsi_sfpb_cfg(void) -{ - char *sfpb; - int data; - - sfpb = mmss_sfpb_base + 0x058; - - data = MIPI_INP(sfpb); - data |= 0x01800; - MIPI_OUTP(sfpb, data); - wmb(); -} - -static void mipi_dsi_pclk_ctrl(struct dsi_clk_desc *clk, int clk_en) -{ - char *cc, *ns, *md; - char mnd_en = 1, root_en = 1; - uint32 data, val; - - cc = mmss_cc_base + 0x0130; - md = mmss_cc_base + 0x0134; - ns = mmss_cc_base + 0x0138; - - if (clk_en) { - if (clk->mnd_mode == 0) { - data = clk->pre_div_func << 12; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - MIPI_OUTP_SECURE(cc, ((clk->mnd_mode << 6) - | (root_en << 2) | clk_en)); - } else { - val = clk->d * 2; - data = (~val) & 0x0ff; - data |= clk->m << 8; - MIPI_OUTP_SECURE(md, data); - - val = clk->n - clk->m; - data = (~val) & 0x0ff; - data <<= 24; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - - MIPI_OUTP_SECURE(cc, ((clk->mnd_mode << 6) - | (mnd_en << 5) - | (root_en << 2) | clk_en)); - } - } else - MIPI_OUTP_SECURE(cc, 0); - - wmb(); -} - -static void mipi_dsi_ahb_en(void) -{ - char *ahb; - - ahb = mmss_cc_base + 0x08; - - pr_debug("%s: ahb=%x %x\n", - __func__, (int) ahb, MIPI_INP_SECURE(ahb)); -} - -void mipi_dsi_lane_cfg(void) -{ - int i, ln_offset; - - ln_offset = 0x300; - for (i = 0; i < 4; i++) { - /* DSI1_DSIPHY_LN_CFG0 */ - MIPI_OUTP(MIPI_DSI_BASE + ln_offset, 0x80); - /* DSI1_DSIPHY_LN_CFG1 */ - MIPI_OUTP(MIPI_DSI_BASE + ln_offset + 0x04, 0x45); - /* DSI1_DSIPHY_LN_CFG2 */ - MIPI_OUTP(MIPI_DSI_BASE + ln_offset + 0x08, 0x0); - /* DSI1_DSIPHY_LN_TEST_DATAPATH */ - MIPI_OUTP(MIPI_DSI_BASE + ln_offset + 0x0c, 0x0); - /* DSI1_DSIPHY_LN_TEST_STR0 */ - MIPI_OUTP(MIPI_DSI_BASE + ln_offset + 0x14, 0x1); - /* DSI1_DSIPHY_LN_TEST_STR1 */ - MIPI_OUTP(MIPI_DSI_BASE + ln_offset + 0x18, 0x66); - ln_offset += 0x40; - } - - MIPI_OUTP(MIPI_DSI_BASE + 0x0400, 0x40); /* DSI1_DSIPHY_LNCK_CFG0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0404, 0x67); /* DSI1_DSIPHY_LNCK_CFG1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0408, 0x0); /* DSI1_DSIPHY_LNCK_CFG2 */ - /* DSI1_DSIPHY_LNCK_TEST_DATAPATH */ - MIPI_OUTP(MIPI_DSI_BASE + 0x040c, 0x0); - MIPI_OUTP(MIPI_DSI_BASE + 0x0414, 0x1); /* DSI1_DSIPHY_LNCK_TEST_STR0 */ - /* DSI1_DSIPHY_LNCK_TEST_STR1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0418, 0x88); -} - -void mipi_dsi_bist_ctrl(void) -{ - MIPI_OUTP(MIPI_DSI_BASE + 0x049c, 0x0f); /* DSI1_DSIPHY_BIST_CTRL4 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0490, 0x03); /* DSI1_DSIPHY_BIST_CTRL1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x048c, 0x03); /* DSI1_DSIPHY_BIST_CTRL0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x049c, 0x0); /* DSI1_DSIPHY_BIST_CTRL4 */ -} - -static void mipi_dsi_calibration(void) -{ - int i = 0; - uint32 term_cnt = 5000; - int cal_busy = MIPI_INP(MIPI_DSI_BASE + 0x550); - - /* DSI1_DSIPHY_REGULATOR_CAL_PWR_CFG */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0518, 0x03); - - /* DSI1_DSIPHY_CAL_SW_CFG2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0534, 0x0); - /* DSI1_DSIPHY_CAL_HW_CFG1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x053c, 0x5a); - /* DSI1_DSIPHY_CAL_HW_CFG3 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0544, 0x10); - /* DSI1_DSIPHY_CAL_HW_CFG4 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0548, 0x01); - /* DSI1_DSIPHY_CAL_HW_CFG0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0538, 0x01); - - /* DSI1_DSIPHY_CAL_HW_TRIGGER */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0528, 0x01); - usleep_range(5000, 5000); - /* DSI1_DSIPHY_CAL_HW_TRIGGER */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0528, 0x00); - - cal_busy = MIPI_INP(MIPI_DSI_BASE + 0x550); - while (cal_busy & 0x10) { - i++; - if (i > term_cnt) { - pr_err("DSI1 PHY REGULATOR NOT READY," - "exceeded polling TIMEOUT!\n"); - break; - } - cal_busy = MIPI_INP(MIPI_DSI_BASE + 0x550); - } -} - -void mipi_dsi_phy_rdy_poll(void) -{ - uint32 phy_pll_busy; - uint32 i = 0; - uint32 term_cnt = 0xFFFFFF; - - phy_pll_busy = MIPI_INP(MIPI_DSI_BASE + 0x280); - while (!(phy_pll_busy & 0x1)) { - i++; - if (i > term_cnt) { - pr_err("DSI1 PHY NOT READY, exceeded polling TIMEOUT!\n"); - break; - } - phy_pll_busy = MIPI_INP(MIPI_DSI_BASE + 0x280); - } -} - -#define PREF_DIV_RATIO 27 -struct dsiphy_pll_divider_config pll_divider_config; - -int mipi_dsi_phy_pll_config(u32 clk_rate) -{ - struct dsiphy_pll_divider_config *dividers; - u32 fb_divider, tmp; - dividers = &pll_divider_config; - - /* DSIPHY_PLL_CTRL_x: 1 2 3 8 9 10 */ - /* masks 0xff 0x07 0x3f 0x0f 0xff 0xff */ - - /* DSIPHY_PLL_CTRL_1 */ - fb_divider = ((dividers->fb_divider) / 2) - 1; - MIPI_OUTP(MIPI_DSI_BASE + 0x204, fb_divider & 0xff); - - /* DSIPHY_PLL_CTRL_2 */ - tmp = MIPI_INP(MIPI_DSI_BASE + 0x208); - tmp &= ~0x07; - tmp |= (fb_divider >> 8) & 0x07; - MIPI_OUTP(MIPI_DSI_BASE + 0x208, tmp); - - /* DSIPHY_PLL_CTRL_3 */ - tmp = MIPI_INP(MIPI_DSI_BASE + 0x20c); - tmp &= ~0x3f; - tmp |= (dividers->ref_divider_ratio - 1) & 0x3f; - MIPI_OUTP(MIPI_DSI_BASE + 0x20c, tmp); - - /* DSIPHY_PLL_CTRL_8 */ - tmp = MIPI_INP(MIPI_DSI_BASE + 0x220); - tmp &= ~0x0f; - tmp |= (dividers->bit_clk_divider - 1) & 0x0f; - MIPI_OUTP(MIPI_DSI_BASE + 0x220, tmp); - - /* DSIPHY_PLL_CTRL_9 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x224, (dividers->byte_clk_divider - 1)); - - /* DSIPHY_PLL_CTRL_10 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x228, (dividers->dsi_clk_divider - 1)); - - return 0; -} - -int mipi_dsi_clk_div_config(uint8 bpp, uint8 lanes, - uint32 *expected_dsi_pclk) -{ - u32 fb_divider, rate, vco; - u32 div_ratio = 0; - struct dsi_clk_mnd_table const *mnd_entry = mnd_table; - if (pll_divider_config.clk_rate == 0) - pll_divider_config.clk_rate = 454000000; - - rate = pll_divider_config.clk_rate / 1000000; /* In Mhz */ - - if (rate < 125) { - vco = rate * 8; - div_ratio = 8; - } else if (rate < 250) { - vco = rate * 4; - div_ratio = 4; - } else if (rate < 600) { - vco = rate * 2; - div_ratio = 2; - } else { - vco = rate * 1; - div_ratio = 1; - } - - /* find the mnd settings from mnd_table entry */ - for (; mnd_entry != mnd_table + ARRAY_SIZE(mnd_table); ++mnd_entry) { - if (((mnd_entry->lanes) == lanes) && - ((mnd_entry->bpp) == bpp)) - break; - } - - if (mnd_entry == mnd_table + ARRAY_SIZE(mnd_table)) { - pr_err("%s: requested Lanes, %u & BPP, %u, not supported\n", - __func__, lanes, bpp); - return -EINVAL; - } - fb_divider = ((vco * PREF_DIV_RATIO) / 27); - pll_divider_config.fb_divider = fb_divider; - pll_divider_config.ref_divider_ratio = PREF_DIV_RATIO; - pll_divider_config.bit_clk_divider = div_ratio; - pll_divider_config.byte_clk_divider = - pll_divider_config.bit_clk_divider * 8; - pll_divider_config.dsi_clk_divider = - (mnd_entry->dsiclk_div) * div_ratio; - - if (mnd_entry->dsiclk_d == 0) { - dsicore_clk.mnd_mode = 0; - dsicore_clk.src = 0x3; - dsicore_clk.pre_div_func = (mnd_entry->dsiclk_n - 1); - } else { - dsicore_clk.mnd_mode = 2; - dsicore_clk.src = 0x3; - dsicore_clk.m = mnd_entry->dsiclk_m; - dsicore_clk.n = mnd_entry->dsiclk_n; - dsicore_clk.d = mnd_entry->dsiclk_d; - } - - if ((mnd_entry->pclk_d == 0) - || (mnd_entry->pclk_m == 1)) { - dsi_pclk.mnd_mode = 0; - dsi_pclk.src = 0x3; - dsi_pclk.pre_div_func = (mnd_entry->pclk_n - 1); - *expected_dsi_pclk = ((vco * 1000000) / - ((pll_divider_config.dsi_clk_divider) - * (mnd_entry->pclk_n))); - } else { - dsi_pclk.mnd_mode = 2; - dsi_pclk.src = 0x3; - dsi_pclk.m = mnd_entry->pclk_m; - dsi_pclk.n = mnd_entry->pclk_n; - dsi_pclk.d = mnd_entry->pclk_d; - *expected_dsi_pclk = ((vco * 1000000 * dsi_pclk.m) / - ((pll_divider_config.dsi_clk_divider) - * (mnd_entry->pclk_n))); - } - return 0; -} - -static void mipi_dsi_configure_serdes(void) -{ - void __iomem *cc; - - /* PHY registers programemd thru S2P interface */ - if (periph_base) { - MIPI_OUTP(periph_base + 0x2c, 0x000000b6); - MIPI_OUTP(periph_base + 0x2c, 0x000001b5); - MIPI_OUTP(periph_base + 0x2c, 0x000001b4); - MIPI_OUTP(periph_base + 0x2c, 0x000003b3); - MIPI_OUTP(periph_base + 0x2c, 0x000003a2); - MIPI_OUTP(periph_base + 0x2c, 0x000002a1); - MIPI_OUTP(periph_base + 0x2c, 0x000008a0); - MIPI_OUTP(periph_base + 0x2c, 0x00000d9f); - MIPI_OUTP(periph_base + 0x2c, 0x0000109e); - MIPI_OUTP(periph_base + 0x2c, 0x0000209d); - MIPI_OUTP(periph_base + 0x2c, 0x0000109c); - MIPI_OUTP(periph_base + 0x2c, 0x0000079a); - MIPI_OUTP(periph_base + 0x2c, 0x00000c99); - MIPI_OUTP(periph_base + 0x2c, 0x00002298); - MIPI_OUTP(periph_base + 0x2c, 0x000000a7); - MIPI_OUTP(periph_base + 0x2c, 0x000000a6); - MIPI_OUTP(periph_base + 0x2c, 0x000000a5); - MIPI_OUTP(periph_base + 0x2c, 0x00007fa4); - MIPI_OUTP(periph_base + 0x2c, 0x0000eea8); - MIPI_OUTP(periph_base + 0x2c, 0x000006aa); - MIPI_OUTP(periph_base + 0x2c, 0x00002095); - MIPI_OUTP(periph_base + 0x2c, 0x00000493); - MIPI_OUTP(periph_base + 0x2c, 0x00001092); - MIPI_OUTP(periph_base + 0x2c, 0x00000691); - MIPI_OUTP(periph_base + 0x2c, 0x00005490); - MIPI_OUTP(periph_base + 0x2c, 0x0000038d); - MIPI_OUTP(periph_base + 0x2c, 0x0000148c); - MIPI_OUTP(periph_base + 0x2c, 0x0000058b); - MIPI_OUTP(periph_base + 0x2c, 0x0000078a); - MIPI_OUTP(periph_base + 0x2c, 0x00001f89); - MIPI_OUTP(periph_base + 0x2c, 0x00003388); - MIPI_OUTP(periph_base + 0x2c, 0x00006387); - MIPI_OUTP(periph_base + 0x2c, 0x00004886); - MIPI_OUTP(periph_base + 0x2c, 0x00005085); - MIPI_OUTP(periph_base + 0x2c, 0x00000084); - MIPI_OUTP(periph_base + 0x2c, 0x0000da83); - MIPI_OUTP(periph_base + 0x2c, 0x0000b182); - MIPI_OUTP(periph_base + 0x2c, 0x00002f81); - MIPI_OUTP(periph_base + 0x2c, 0x00004080); - MIPI_OUTP(periph_base + 0x2c, 0x00004180); - MIPI_OUTP(periph_base + 0x2c, 0x000006aa); - } - - cc = MIPI_DSI_BASE + 0x0130; - MIPI_OUTP(cc, 0x806c11c8); - MIPI_OUTP(cc, 0x804c11c8); - MIPI_OUTP(cc, 0x806d0080); - MIPI_OUTP(cc, 0x804d0080); - MIPI_OUTP(cc, 0x00000000); - MIPI_OUTP(cc, 0x807b1597); - MIPI_OUTP(cc, 0x805b1597); - MIPI_OUTP(cc, 0x807c0080); - MIPI_OUTP(cc, 0x805c0080); - MIPI_OUTP(cc, 0x00000000); - MIPI_OUTP(cc, 0x807911c8); - MIPI_OUTP(cc, 0x805911c8); - MIPI_OUTP(cc, 0x807a0080); - MIPI_OUTP(cc, 0x805a0080); - MIPI_OUTP(cc, 0x00000000); - MIPI_OUTP(cc, 0x80721555); - MIPI_OUTP(cc, 0x80521555); - MIPI_OUTP(cc, 0x80730000); - MIPI_OUTP(cc, 0x80530000); - MIPI_OUTP(cc, 0x00000000); -} - -void mipi_dsi_phy_init(int panel_ndx, struct msm_panel_info const *panel_info, - int target_type) -{ - struct mipi_dsi_phy_ctrl *pd; - int i, off; - - MIPI_OUTP(MIPI_DSI_BASE + 0x128, 0x0001);/* start phy sw reset */ - wmb(); - usleep(1); - MIPI_OUTP(MIPI_DSI_BASE + 0x128, 0x0000);/* end phy w reset */ - wmb(); - usleep(1); - MIPI_OUTP(MIPI_DSI_BASE + 0x500, 0x0003);/* regulator_ctrl_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x504, 0x0001);/* regulator_ctrl_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x508, 0x0001);/* regulator_ctrl_2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x50c, 0x0000);/* regulator_ctrl_3 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x510, 0x0100);/* regulator_ctrl_4 */ - - MIPI_OUTP(MIPI_DSI_BASE + 0x4b0, 0x04);/* DSIPHY_LDO_CNTRL */ - - pd = (panel_info->mipi).dsi_phy_db; - - off = 0x0480; /* strength 0 - 2 */ - for (i = 0; i < 3; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->strength[i]); - wmb(); - off += 4; - } - - off = 0x0470; /* ctrl 0 - 3 */ - for (i = 0; i < 4; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->ctrl[i]); - wmb(); - off += 4; - } - - off = 0x0500; /* regulator ctrl 0 - 4 */ - for (i = 0; i < 5; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->regulator[i]); - wmb(); - off += 4; - } - mipi_dsi_calibration(); - mipi_dsi_lane_cfg(); /* lane cfgs */ - mipi_dsi_bist_ctrl(); /* bist ctrl */ - - off = 0x0204; /* pll ctrl 1 - 19, skip 0 */ - for (i = 1; i < 20; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->pll[i]); - wmb(); - off += 4; - } - - if (panel_info) - mipi_dsi_phy_pll_config(panel_info->clk_rate); - - /* pll ctrl 0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x200, pd->pll[0]); - wmb(); - - off = 0x0440; /* phy timing ctrl 0 - 11 */ - for (i = 0; i < 12; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->timing[i]); - wmb(); - off += 4; - } - - if (target_type == 1) - mipi_dsi_configure_serdes(); -} - -void cont_splash_clk_ctrl(int enable) -{ - static int cont_splash_clks_enabled; - if (enable && !cont_splash_clks_enabled) { - clk_prepare_enable(dsi_byte_div_clk); - clk_prepare_enable(dsi_esc_clk); - cont_splash_clks_enabled = 1; - } else if (!enable && cont_splash_clks_enabled) { - clk_disable_unprepare(dsi_byte_div_clk); - clk_disable_unprepare(dsi_esc_clk); - cont_splash_clks_enabled = 0; - } -} - -void mipi_dsi_prepare_clocks(void) -{ - clk_prepare(amp_pclk); - clk_prepare(dsi_m_pclk); - clk_prepare(dsi_s_pclk); - clk_prepare(dsi_byte_div_clk); - clk_prepare(dsi_esc_clk); -} - -void mipi_dsi_unprepare_clocks(void) -{ - clk_unprepare(dsi_esc_clk); - clk_unprepare(dsi_byte_div_clk); - clk_unprepare(dsi_m_pclk); - clk_unprepare(dsi_s_pclk); - clk_unprepare(amp_pclk); -} - -void mipi_dsi_ahb_ctrl(u32 enable) -{ - static int ahb_ctrl_done; - if (enable) { - if (ahb_ctrl_done) { - pr_info("%s: ahb clks already ON\n", __func__); - return; - } - clk_enable(amp_pclk); /* clock for AHB-master to AXI */ - clk_enable(dsi_m_pclk); - clk_enable(dsi_s_pclk); - mipi_dsi_ahb_en(); - mipi_dsi_sfpb_cfg(); - ahb_ctrl_done = 1; - } else { - if (ahb_ctrl_done == 0) { - pr_info("%s: ahb clks already OFF\n", __func__); - return; - } - clk_disable(dsi_m_pclk); - clk_disable(dsi_s_pclk); - clk_disable(amp_pclk); /* clock for AHB-master to AXI */ - ahb_ctrl_done = 0; - } -} - -void mipi_dsi_clk_enable(void) -{ - u32 pll_ctrl = MIPI_INP(MIPI_DSI_BASE + 0x0200); - if (mipi_dsi_clk_on) { - pr_info("%s: mipi_dsi_clks already ON\n", __func__); - return; - } - MIPI_OUTP(MIPI_DSI_BASE + 0x0200, pll_ctrl | 0x01); - mipi_dsi_phy_rdy_poll(); - - if (clk_set_rate(dsi_byte_div_clk, 1) < 0) /* divided by 1 */ - pr_err("%s: dsi_byte_div_clk - " - "clk_set_rate failed\n", __func__); - if (clk_set_rate(dsi_esc_clk, esc_byte_ratio) < 0) /* divided by esc */ - pr_err("%s: dsi_esc_clk - " /* clk ratio */ - "clk_set_rate failed\n", __func__); - mipi_dsi_pclk_ctrl(&dsi_pclk, 1); - mipi_dsi_clk_ctrl(&dsicore_clk, 1); - clk_enable(dsi_byte_div_clk); - clk_enable(dsi_esc_clk); - mipi_dsi_clk_on = 1; - mdp4_stat.dsi_clk_on++; -} - -void mipi_dsi_clk_disable(void) -{ - if (mipi_dsi_clk_on == 0) { - pr_info("%s: mipi_dsi_clks already OFF\n", __func__); - return; - } - clk_disable(dsi_esc_clk); - clk_disable(dsi_byte_div_clk); - mipi_dsi_pclk_ctrl(&dsi_pclk, 0); - mipi_dsi_clk_ctrl(&dsicore_clk, 0); - /* DSIPHY_PLL_CTRL_0, disable dsi pll */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0200, 0x0); - mipi_dsi_clk_on = 0; - mdp4_stat.dsi_clk_off++; -} - -void mipi_dsi_phy_ctrl(int on) -{ - if (on) { - /* DSIPHY_PLL_CTRL_5 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0214, 0x050); - } else { - /* DSIPHY_PLL_CTRL_5 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0214, 0x05f); - - /* DSIPHY_REGULATOR_CTRL_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0500, 0x02); - - /* DSIPHY_CTRL_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0470, 0x00); - - /* DSIPHY_CTRL_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0474, 0x7f); - - /* disable dsi clk */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0118, 0); - } -} - -#ifdef CONFIG_FB_MSM_HDMI_COMMON -void hdmi_phy_reset(void) -{ - unsigned int phy_reset_polarity = 0x0; - unsigned int pll_reset_polarity = 0x0; - - unsigned int val = HDMI_INP_ND(HDMI_PHY_CTRL); - - phy_reset_polarity = val >> 3 & 0x1; - pll_reset_polarity = val >> 1 & 0x1; - - if (phy_reset_polarity == 0) - HDMI_OUTP(HDMI_PHY_CTRL, val | SW_RESET); - else - HDMI_OUTP(HDMI_PHY_CTRL, val & (~SW_RESET)); - - if (pll_reset_polarity == 0) - HDMI_OUTP(HDMI_PHY_CTRL, val | SW_RESET_PLL); - else - HDMI_OUTP(HDMI_PHY_CTRL, val & (~SW_RESET_PLL)); - - msleep(100); - - if (phy_reset_polarity == 0) - HDMI_OUTP(HDMI_PHY_CTRL, val & (~SW_RESET)); - else - HDMI_OUTP(HDMI_PHY_CTRL, val | SW_RESET); - - if (pll_reset_polarity == 0) - HDMI_OUTP(HDMI_PHY_CTRL, val & (~SW_RESET_PLL)); - else - HDMI_OUTP(HDMI_PHY_CTRL, val | SW_RESET_PLL); -} - -void hdmi_msm_reset_core(void) -{ - hdmi_msm_clk(0); - udelay(5); - hdmi_msm_clk(1); - - clk_reset(hdmi_msm_state->hdmi_app_clk, CLK_RESET_ASSERT); - udelay(20); - clk_reset(hdmi_msm_state->hdmi_app_clk, CLK_RESET_DEASSERT); -} - -void hdmi_msm_init_phy(int video_format) -{ - uint32 offset; - pr_err("Video format is : %u\n", video_format); - - HDMI_OUTP(HDMI_PHY_REG_0, 0x1B); - HDMI_OUTP(HDMI_PHY_REG_1, 0xf2); - - offset = HDMI_PHY_REG_4; - while (offset <= HDMI_PHY_REG_11) { - HDMI_OUTP(offset, 0x0); - offset += 0x4; - } - - HDMI_OUTP(HDMI_PHY_REG_3, 0x20); -} - -void hdmi_msm_powerdown_phy(void) -{ - /* Power down PHY */ - HDMI_OUTP_ND(HDMI_PHY_REG_2, 0x7F); /*0b01111111*/ -} - -void hdmi_frame_ctrl_cfg(const struct hdmi_disp_mode_timing_type *timing) -{ - /* 0x02C8 HDMI_FRAME_CTRL - * 31 INTERLACED_EN Interlaced or progressive enable bit - * 0: Frame in progressive - * 1: Frame is interlaced - * 29 HSYNC_HDMI_POL HSYNC polarity fed to HDMI core - * 0: Active Hi Hsync, detect the rising edge of hsync - * 1: Active lo Hsync, Detect the falling edge of Hsync - * 28 VSYNC_HDMI_POL VSYNC polarity fed to HDMI core - * 0: Active Hi Vsync, detect the rising edge of vsync - * 1: Active Lo Vsync, Detect the falling edge of Vsync - * 12 RGB_MUX_SEL ALPHA mdp4 input is RGB, mdp4 input is BGR - */ - HDMI_OUTP(0x02C8, - ((timing->interlaced << 31) & 0x80000000) - | ((timing->active_low_h << 29) & 0x20000000) - | ((timing->active_low_v << 28) & 0x10000000)); -} - -void hdmi_msm_phy_status_poll(void) -{ - unsigned int lock_det, phy_ready; - lock_det = 0x1 & HDMI_INP_ND(HDMI_PHY_PLL_STATUS0); - if (lock_det) { - pr_debug("HDMI Phy PLL Lock Detect Bit is set\n"); - } else { - pr_debug("HDMI Phy Lock Detect Bit is not set," - "waiting for lock detection\n"); - do { - lock_det = 0x1 & \ - HDMI_INP_ND(HDMI_PHY_PLL_STATUS0); - } while (!lock_det); - } - - phy_ready = 0x1 & HDMI_INP_ND(HDMI_PHY_REG_15); - if (phy_ready) { - pr_debug("HDMI Phy Status bit is set and ready\n"); - } else { - pr_debug("HDMI Phy Status bit is not set," - "waiting for ready status\n"); - do { - phy_ready = 0x1 & HDMI_INP_ND(HDMI_PHY_REG_15); - } while (!phy_ready); - } -} - -#endif diff --git a/drivers/video/msm/msm_dss_io_8x60.c b/drivers/video/msm/msm_dss_io_8x60.c deleted file mode 100644 index d60bfadbd1449a31e4f56c356c2fa582b0cd872e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_dss_io_8x60.c +++ /dev/null @@ -1,685 +0,0 @@ -/* Copyright (c) 2008-2012, 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 -#include -#include "msm_fb.h" -#include "mipi_dsi.h" -#include "hdmi_msm.h" -#include - -/* multimedia sub system clock control */ -char *mmss_cc_base = MSM_MMSS_CLK_CTL_BASE; -/* multimedia sub system sfpb */ -char *mmss_sfpb_base; -void __iomem *periph_base; - -static struct dsi_clk_desc dsicore_clk; -static struct dsi_clk_desc dsi_pclk; - -static struct clk *dsi_byte_div_clk; -static struct clk *dsi_esc_clk; -static struct clk *dsi_m_pclk; -static struct clk *dsi_s_pclk; - -static struct clk *amp_pclk; -int mipi_dsi_clk_on; - -int mipi_dsi_clk_init(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - amp_pclk = clk_get(dev, "arb_clk"); - if (IS_ERR_OR_NULL(amp_pclk)) { - pr_err("can't find amp_pclk\n"); - amp_pclk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_m_pclk = clk_get(dev, "master_iface_clk"); - if (IS_ERR_OR_NULL(dsi_m_pclk)) { - pr_err("can't find dsi_m_pclk\n"); - dsi_m_pclk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_s_pclk = clk_get(dev, "slave_iface_clk"); - if (IS_ERR_OR_NULL(dsi_s_pclk)) { - pr_err("can't find dsi_s_pclk\n"); - dsi_s_pclk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_byte_div_clk = clk_get(dev, "byte_clk"); - if (IS_ERR_OR_NULL(dsi_byte_div_clk)) { - pr_err("can't find dsi_byte_div_clk\n"); - dsi_byte_div_clk = NULL; - goto mipi_dsi_clk_err; - } - - dsi_esc_clk = clk_get(dev, "esc_clk"); - if (IS_ERR_OR_NULL(dsi_esc_clk)) { - printk(KERN_ERR "can't find dsi_esc_clk\n"); - dsi_esc_clk = NULL; - goto mipi_dsi_clk_err; - } - - return 0; - -mipi_dsi_clk_err: - mipi_dsi_clk_deinit(NULL); - return -EPERM; -} - -void mipi_dsi_clk_deinit(struct device *dev) -{ - if (amp_pclk) - clk_put(amp_pclk); - if (dsi_m_pclk) - clk_put(dsi_m_pclk); - if (dsi_s_pclk) - clk_put(dsi_s_pclk); - if (dsi_byte_div_clk) - clk_put(dsi_byte_div_clk); - if (dsi_esc_clk) - clk_put(dsi_esc_clk); -} - -static void mipi_dsi_clk_ctrl(struct dsi_clk_desc *clk, int clk_en) -{ - char *cc, *ns, *md; - int pmxo_sel = 0; - char mnd_en = 1, root_en = 1; - uint32 data, val; - - cc = mmss_cc_base + 0x004c; - md = mmss_cc_base + 0x0050; - ns = mmss_cc_base + 0x0054; - - if (clk_en) { - if (clk->mnd_mode == 0) { - data = clk->pre_div_func << 14; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - MIPI_OUTP_SECURE(cc, ((pmxo_sel << 8) - | (clk->mnd_mode << 6) - | (root_en << 2) | clk_en)); - } else { - val = clk->d * 2; - data = (~val) & 0x0ff; - data |= clk->m << 8; - MIPI_OUTP_SECURE(md, data); - - val = clk->n - clk->m; - data = (~val) & 0x0ff; - data <<= 24; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - - MIPI_OUTP_SECURE(cc, ((pmxo_sel << 8) - | (clk->mnd_mode << 6) - | (mnd_en << 5) - | (root_en << 2) | clk_en)); - } - - } else - MIPI_OUTP_SECURE(cc, 0); - - wmb(); -} - -static void mipi_dsi_sfpb_cfg(void) -{ - char *sfpb; - int data; - - sfpb = mmss_sfpb_base + 0x058; - - data = MIPI_INP(sfpb); - data |= 0x01800; - MIPI_OUTP(sfpb, data); - wmb(); -} - -static void mipi_dsi_pclk_ctrl(struct dsi_clk_desc *clk, int clk_en) -{ - char *cc, *ns, *md; - char mnd_en = 1, root_en = 1; - uint32 data, val; - - cc = mmss_cc_base + 0x0130; - md = mmss_cc_base + 0x0134; - ns = mmss_cc_base + 0x0138; - - if (clk_en) { - if (clk->mnd_mode == 0) { - data = clk->pre_div_func << 12; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - MIPI_OUTP_SECURE(cc, ((clk->mnd_mode << 6) - | (root_en << 2) | clk_en)); - } else { - val = clk->d * 2; - data = (~val) & 0x0ff; - data |= clk->m << 8; - MIPI_OUTP_SECURE(md, data); - - val = clk->n - clk->m; - data = (~val) & 0x0ff; - data <<= 24; - data |= clk->src; - MIPI_OUTP_SECURE(ns, data); - - MIPI_OUTP_SECURE(cc, ((clk->mnd_mode << 6) - | (mnd_en << 5) - | (root_en << 2) | clk_en)); - } - - } else - MIPI_OUTP_SECURE(cc, 0); - - wmb(); -} - -static void mipi_dsi_ahb_en(void) -{ - char *ahb; - - ahb = mmss_cc_base + 0x08; - - pr_debug("%s: ahb=%x %x\n", - __func__, (int) ahb, MIPI_INP_SECURE(ahb)); -} - -static void mipi_dsi_calibration(void) -{ - uint32 data; - - MIPI_OUTP(MIPI_DSI_BASE + 0xf4, 0x0000ff11); /* cal_ctrl */ - MIPI_OUTP(MIPI_DSI_BASE + 0xf0, 0x01); /* cal_hw_trigger */ - - while (1) { - data = MIPI_INP(MIPI_DSI_BASE + 0xfc); /* cal_status */ - if ((data & 0x10000000) == 0) - break; - - udelay(10); - } -} - -#define PREF_DIV_RATIO 27 -struct dsiphy_pll_divider_config pll_divider_config; - - -int mipi_dsi_phy_pll_config(u32 clk_rate) -{ - struct dsiphy_pll_divider_config *dividers; - u32 fb_divider, tmp; - dividers = &pll_divider_config; - - /* DSIPHY_PLL_CTRL_x: 1 2 3 8 9 10 */ - /* masks 0xff 0x07 0x3f 0x0f 0xff 0xff */ - - /* DSIPHY_PLL_CTRL_1 */ - fb_divider = ((dividers->fb_divider) / 2) - 1; - MIPI_OUTP(MIPI_DSI_BASE + 0x204, fb_divider & 0xff); - - /* DSIPHY_PLL_CTRL_2 */ - tmp = MIPI_INP(MIPI_DSI_BASE + 0x208); - tmp &= ~0x07; - tmp |= (fb_divider >> 8) & 0x07; - MIPI_OUTP(MIPI_DSI_BASE + 0x208, tmp); - - /* DSIPHY_PLL_CTRL_3 */ - tmp = MIPI_INP(MIPI_DSI_BASE + 0x20c); - tmp &= ~0x3f; - tmp |= (dividers->ref_divider_ratio - 1) & 0x3f; - MIPI_OUTP(MIPI_DSI_BASE + 0x20c, tmp); - - /* DSIPHY_PLL_CTRL_8 */ - tmp = MIPI_INP(MIPI_DSI_BASE + 0x220); - tmp &= ~0x0f; - tmp |= (dividers->bit_clk_divider - 1) & 0x0f; - MIPI_OUTP(MIPI_DSI_BASE + 0x220, tmp); - - /* DSIPHY_PLL_CTRL_9 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x224, (dividers->byte_clk_divider - 1)); - - /* DSIPHY_PLL_CTRL_10 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x228, (dividers->dsi_clk_divider - 1)); - - return 0; -} - -int mipi_dsi_clk_div_config(uint8 bpp, uint8 lanes, - uint32 *expected_dsi_pclk) -{ - u32 fb_divider, rate, vco; - u32 div_ratio = 0; - struct dsi_clk_mnd_table const *mnd_entry = mnd_table; - if (pll_divider_config.clk_rate == 0) - pll_divider_config.clk_rate = 454000000; - - rate = pll_divider_config.clk_rate / 1000000; /* In Mhz */ - - if (rate < 125) { - vco = rate * 8; - div_ratio = 8; - } else if (rate < 250) { - vco = rate * 4; - div_ratio = 4; - } else if (rate < 500) { - vco = rate * 2; - div_ratio = 2; - } else { - vco = rate * 1; - div_ratio = 1; - } - - /* find the mnd settings from mnd_table entry */ - for (; mnd_entry != mnd_table + ARRAY_SIZE(mnd_table); ++mnd_entry) { - if (((mnd_entry->lanes) == lanes) && - ((mnd_entry->bpp) == bpp)) - break; - } - - if (mnd_entry == mnd_table + ARRAY_SIZE(mnd_table)) { - pr_err("%s: requested Lanes, %u & BPP, %u, not supported\n", - __func__, lanes, bpp); - return -EINVAL; - } - fb_divider = ((vco * PREF_DIV_RATIO) / 27); - pll_divider_config.fb_divider = fb_divider; - pll_divider_config.ref_divider_ratio = PREF_DIV_RATIO; - pll_divider_config.bit_clk_divider = div_ratio; - pll_divider_config.byte_clk_divider = - pll_divider_config.bit_clk_divider * 8; - pll_divider_config.dsi_clk_divider = - (mnd_entry->dsiclk_div) * div_ratio; - - if ((mnd_entry->dsiclk_d == 0) - || (mnd_entry->dsiclk_m == 1)) { - dsicore_clk.mnd_mode = 0; - dsicore_clk.src = 0x3; - dsicore_clk.pre_div_func = (mnd_entry->dsiclk_n - 1); - } else { - dsicore_clk.mnd_mode = 2; - dsicore_clk.src = 0x3; - dsicore_clk.m = mnd_entry->dsiclk_m; - dsicore_clk.n = mnd_entry->dsiclk_n; - dsicore_clk.d = mnd_entry->dsiclk_d; - } - - if ((mnd_entry->pclk_d == 0) - || (mnd_entry->pclk_m == 1)) { - dsi_pclk.mnd_mode = 0; - dsi_pclk.src = 0x3; - dsi_pclk.pre_div_func = (mnd_entry->pclk_n - 1); - *expected_dsi_pclk = ((vco * 1000000) / - ((pll_divider_config.dsi_clk_divider) - * (mnd_entry->pclk_n))); - } else { - dsi_pclk.mnd_mode = 2; - dsi_pclk.src = 0x3; - dsi_pclk.m = mnd_entry->pclk_m; - dsi_pclk.n = mnd_entry->pclk_n; - dsi_pclk.d = mnd_entry->pclk_d; - *expected_dsi_pclk = ((vco * 1000000 * dsi_pclk.m) / - ((pll_divider_config.dsi_clk_divider) - * (mnd_entry->pclk_n))); - } - return 0; -} - -void mipi_dsi_phy_init(int panel_ndx, struct msm_panel_info const *panel_info, - int target_type) -{ - struct mipi_dsi_phy_ctrl *pd; - int i, off; - - MIPI_OUTP(MIPI_DSI_BASE + 0x128, 0x0001);/* start phy sw reset */ - wmb(); - usleep(1); - MIPI_OUTP(MIPI_DSI_BASE + 0x128, 0x0000);/* end phy w reset */ - wmb(); - usleep(1); - MIPI_OUTP(MIPI_DSI_BASE + 0x2cc, 0x0003);/* regulator_ctrl_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x2d0, 0x0001);/* regulator_ctrl_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x2d4, 0x0001);/* regulator_ctrl_2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x2d8, 0x0000);/* regulator_ctrl_3 */ -#ifdef DSI_POWER - MIPI_OUTP(MIPI_DSI_BASE + 0x2dc, 0x0100);/* regulator_ctrl_4 */ -#endif - - pd = (panel_info->mipi).dsi_phy_db; - - off = 0x02cc; /* regulator ctrl 0 */ - for (i = 0; i < 4; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->regulator[i]); - wmb(); - off += 4; - } - - off = 0x0260; /* phy timig ctrl 0 */ - for (i = 0; i < 11; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->timing[i]); - wmb(); - off += 4; - } - - off = 0x0290; /* ctrl 0 */ - for (i = 0; i < 4; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->ctrl[i]); - wmb(); - off += 4; - } - - off = 0x02a0; /* strength 0 */ - for (i = 0; i < 4; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->strength[i]); - wmb(); - off += 4; - } - - mipi_dsi_calibration(); - - off = 0x0204; /* pll ctrl 1, skip 0 */ - for (i = 1; i < 21; i++) { - MIPI_OUTP(MIPI_DSI_BASE + off, pd->pll[i]); - wmb(); - off += 4; - } - - if (panel_info) - mipi_dsi_phy_pll_config(panel_info->clk_rate); - - /* pll ctrl 0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x200, pd->pll[0]); - wmb(); -} - -void cont_splash_clk_ctrl(int enable) -{ -} - -void mipi_dsi_prepare_clocks(void) -{ - clk_prepare(amp_pclk); - clk_prepare(dsi_m_pclk); - clk_prepare(dsi_s_pclk); - clk_prepare(dsi_byte_div_clk); - clk_prepare(dsi_esc_clk); -} - -void mipi_dsi_unprepare_clocks(void) -{ - clk_unprepare(dsi_esc_clk); - clk_unprepare(dsi_byte_div_clk); - clk_unprepare(dsi_m_pclk); - clk_unprepare(dsi_s_pclk); - clk_unprepare(amp_pclk); -} - -void mipi_dsi_ahb_ctrl(u32 enable) -{ - static int ahb_ctrl_done; - if (enable) { - if (ahb_ctrl_done) { - pr_info("%s: ahb clks already ON\n", __func__); - return; - } - clk_enable(amp_pclk); /* clock for AHB-master to AXI */ - clk_enable(dsi_m_pclk); - clk_enable(dsi_s_pclk); - mipi_dsi_ahb_en(); - mipi_dsi_sfpb_cfg(); - ahb_ctrl_done = 1; - } else { - if (ahb_ctrl_done == 0) { - pr_info("%s: ahb clks already OFF\n", __func__); - return; - } - clk_disable(dsi_m_pclk); - clk_disable(dsi_s_pclk); - clk_disable(amp_pclk); /* clock for AHB-master to AXI */ - ahb_ctrl_done = 0; - } -} - -void mipi_dsi_clk_enable(void) -{ - u32 pll_ctrl = MIPI_INP(MIPI_DSI_BASE + 0x0200); - if (mipi_dsi_clk_on) { - pr_info("%s: mipi_dsi_clks already ON\n", __func__); - return; - } - MIPI_OUTP(MIPI_DSI_BASE + 0x0200, pll_ctrl | 0x01); - mb(); - - if (clk_set_rate(dsi_byte_div_clk, 1) < 0) /* divided by 1 */ - pr_err("%s: clk_set_rate failed\n", __func__); - mipi_dsi_pclk_ctrl(&dsi_pclk, 1); - mipi_dsi_clk_ctrl(&dsicore_clk, 1); - clk_enable(dsi_byte_div_clk); - clk_enable(dsi_esc_clk); - mipi_dsi_clk_on = 1; -} - -void mipi_dsi_clk_disable(void) -{ - if (mipi_dsi_clk_on == 0) { - pr_info("%s: mipi_dsi_clks already OFF\n", __func__); - return; - } - clk_disable(dsi_esc_clk); - clk_disable(dsi_byte_div_clk); - - mipi_dsi_pclk_ctrl(&dsi_pclk, 0); - mipi_dsi_clk_ctrl(&dsicore_clk, 0); - /* DSIPHY_PLL_CTRL_0, disable dsi pll */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0200, 0x40); - mipi_dsi_clk_on = 0; -} - -void mipi_dsi_phy_ctrl(int on) -{ - if (on) { - /* DSIPHY_PLL_CTRL_5 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0214, 0x050); - - /* DSIPHY_TPA_CTRL_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0258, 0x00f); - - /* DSIPHY_TPA_CTRL_2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x025c, 0x000); - } else { - /* DSIPHY_PLL_CTRL_5 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0214, 0x05f); - - /* DSIPHY_TPA_CTRL_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0258, 0x08f); - - /* DSIPHY_TPA_CTRL_2 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x025c, 0x001); - - /* DSIPHY_REGULATOR_CTRL_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x02cc, 0x02); - - /* DSIPHY_CTRL_0 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0290, 0x00); - - /* DSIPHY_CTRL_1 */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0294, 0x7f); - - /* disable dsi clk */ - MIPI_OUTP(MIPI_DSI_BASE + 0x0118, 0); - } -} - -#ifdef CONFIG_FB_MSM_HDMI_COMMON -#define SW_RESET BIT(2) -void hdmi_phy_reset(void) -{ - unsigned int phy_reset_polarity = 0x0; - unsigned int val = HDMI_INP_ND(0x2D4); - - phy_reset_polarity = val >> 3 & 0x1; - - if (phy_reset_polarity == 0) - HDMI_OUTP(0x2D4, val | SW_RESET); - else - HDMI_OUTP(0x2D4, val & (~SW_RESET)); - - msleep(100); - - if (phy_reset_polarity == 0) - HDMI_OUTP(0x2D4, val & (~SW_RESET)); - else - HDMI_OUTP(0x2D4, val | SW_RESET); -} - -void hdmi_msm_reset_core(void) -{ - hdmi_msm_clk(0); - udelay(5); - hdmi_msm_clk(1); - - clk_reset(hdmi_msm_state->hdmi_app_clk, CLK_RESET_ASSERT); - udelay(20); - clk_reset(hdmi_msm_state->hdmi_app_clk, CLK_RESET_DEASSERT); -} - -void hdmi_msm_init_phy(int video_format) -{ - uint32 offset; - /* De-serializer delay D/C for non-lbk mode - * PHY REG0 = (DESER_SEL(0) | DESER_DEL_CTRL(3) - * | AMUX_OUT_SEL(0)) - */ - HDMI_OUTP_ND(0x0300, 0x0C); /*0b00001100*/ - - if (video_format == HDMI_VFRMT_720x480p60_16_9) { - /* PHY REG1 = DTEST_MUX_SEL(5) | PLL_GAIN_SEL(0) - * | OUTVOL_SWING_CTRL(3) - */ - HDMI_OUTP_ND(0x0304, 0x53); /*0b01010011*/ - } else { - /* If the freq. is less than 120MHz, use low gain 0 - * for board with termination - * PHY REG1 = DTEST_MUX_SEL(5) | PLL_GAIN_SEL(0) - * | OUTVOL_SWING_CTRL(4) - */ - HDMI_OUTP_ND(0x0304, 0x54); /*0b01010100*/ - } - - /* No matter what, start from the power down mode - * PHY REG2 = PD_PWRGEN | PD_PLL | PD_DRIVE_4 | PD_DRIVE_3 - * | PD_DRIVE_2 | PD_DRIVE_1 | PD_DESER - */ - HDMI_OUTP_ND(0x0308, 0x7F); /*0b01111111*/ - - /* Turn PowerGen on - * PHY REG2 = PD_PLL | PD_DRIVE_4 | PD_DRIVE_3 - * | PD_DRIVE_2 | PD_DRIVE_1 | PD_DESER - */ - HDMI_OUTP_ND(0x0308, 0x3F); /*0b00111111*/ - - /* Turn PLL power on - * PHY REG2 = PD_DRIVE_4 | PD_DRIVE_3 - * | PD_DRIVE_2 | PD_DRIVE_1 | PD_DESER - */ - HDMI_OUTP_ND(0x0308, 0x1F); /*0b00011111*/ - - /* Write to HIGH after PLL power down de-assert - * PHY REG3 = PLL_ENABLE - */ - HDMI_OUTP_ND(0x030C, 0x01); - /* ASIC power on; PHY REG9 = 0 */ - HDMI_OUTP_ND(0x0324, 0x00); - /* Enable PLL lock detect, PLL lock det will go high after lock - * Enable the re-time logic - * PHY REG12 = PLL_LOCK_DETECT_EN | RETIMING_ENABLE - */ - HDMI_OUTP_ND(0x0330, 0x03); /*0b00000011*/ - - /* Drivers are on - * PHY REG2 = PD_DESER - */ - HDMI_OUTP_ND(0x0308, 0x01); /*0b00000001*/ - /* If the RX detector is needed - * PHY REG2 = RCV_SENSE_EN | PD_DESER - */ - HDMI_OUTP_ND(0x0308, 0x81); /*0b10000001*/ - - offset = 0x0310; - while (offset <= 0x032C) { - HDMI_OUTP(offset, 0x0); - offset += 0x4; - } - - /* If we want to use lock enable based on counting - * PHY REG12 = FORCE_LOCK | PLL_LOCK_DETECT_EN | RETIMING_ENABLE - */ - HDMI_OUTP_ND(0x0330, 0x13); /*0b00010011*/ -} - -void hdmi_msm_powerdown_phy(void) -{ - /* Assert RESET PHY from controller */ - HDMI_OUTP_ND(0x02D4, 0x4); - udelay(10); - /* De-assert RESET PHY from controller */ - HDMI_OUTP_ND(0x02D4, 0x0); - /* Turn off Driver */ - HDMI_OUTP_ND(0x0308, 0x1F); - udelay(10); - /* Disable PLL */ - HDMI_OUTP_ND(0x030C, 0x00); - /* Power down PHY */ - HDMI_OUTP_ND(0x0308, 0x7F); /*0b01111111*/ -} - -void hdmi_frame_ctrl_cfg(const struct hdmi_disp_mode_timing_type *timing) -{ - /* 0x02C8 HDMI_FRAME_CTRL - * 31 INTERLACED_EN Interlaced or progressive enable bit - * 0: Frame in progressive - * 1: Frame is interlaced - * 29 HSYNC_HDMI_POL HSYNC polarity fed to HDMI core - * 0: Active Hi Hsync, detect the rising edge of hsync - * 1: Active lo Hsync, Detect the falling edge of Hsync - * 28 VSYNC_HDMI_POL VSYNC polarity fed to HDMI core - * 0: Active Hi Vsync, detect the rising edge of vsync - * 1: Active Lo Vsync, Detect the falling edge of Vsync - * 12 RGB_MUX_SEL ALPHA mdp4 input is RGB, mdp4 input is BGR - */ - HDMI_OUTP(0x02C8, - ((timing->interlaced << 31) & 0x80000000) - | ((timing->active_low_h << 29) & 0x20000000) - | ((timing->active_low_v << 28) & 0x10000000) - | (1 << 12)); -} - -void hdmi_msm_phy_status_poll(void) -{ - unsigned int phy_ready; - phy_ready = 0x1 & HDMI_INP_ND(0x33c); - if (phy_ready) { - pr_debug("HDMI Phy Status bit is set and ready\n"); - } else { - pr_debug("HDMI Phy Status bit is not set," - "waiting for ready status\n"); - do { - phy_ready = 0x1 & HDMI_INP_ND(0x33c); - } while (!phy_ready); - } -} -#endif diff --git a/drivers/video/msm/msm_fb.c b/drivers/video/msm/msm_fb.c index 25e497f1aa7b0510a53ef74e5c5df68069800097..7037e12a4b685bacca10994e9d1053266bd18328 100644 --- a/drivers/video/msm/msm_fb.c +++ b/drivers/video/msm/msm_fb.c @@ -45,11 +45,6 @@ #include #define MSM_FB_C -#include "msm_fb.h" -#include "mddihosti.h" -#include "tvenc.h" -#include "mdp.h" -#include "mdp4.h" #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER #define MSM_FB_NUM 3 @@ -173,7 +168,6 @@ int msm_fb_cursor(struct fb_info *info, struct fb_cursor *cursor) static int msm_fb_resource_initialized; -#ifndef CONFIG_FB_BACKLIGHT static int lcd_backlight_registered; static void msm_fb_set_bl_brightness(struct led_classdev *led_cdev, @@ -202,7 +196,6 @@ static struct led_classdev backlight_led = { .brightness = MAX_BACKLIGHT_BRIGHTNESS, .brightness_set = msm_fb_set_bl_brightness, }; -#endif static struct msm_fb_platform_data *msm_fb_pdata; unsigned char hdmi_prim_display; @@ -412,9 +405,6 @@ static int msm_fb_probe(struct platform_device *pdev) if (err < 0) printk(KERN_ERR "pm_runtime: fail to set active.\n"); pm_runtime_enable(mfd->fbi->dev); -#ifdef CONFIG_FB_BACKLIGHT - msm_fb_config_backlight(mfd); -#else /* android supports only one lcd-backlight/lcd for now */ if (!lcd_backlight_registered) { if (led_classdev_register(&pdev->dev, &backlight_led)) @@ -422,7 +412,6 @@ static int msm_fb_probe(struct platform_device *pdev) else lcd_backlight_registered = 1; } -#endif pdev_list[pdev_list_cnt++] = pdev; msm_fb_create_sysfs(pdev); @@ -483,15 +472,10 @@ static int msm_fb_remove(struct platform_device *pdev) /* remove /dev/fb* */ unregister_framebuffer(mfd->fbi); -#ifdef CONFIG_FB_BACKLIGHT - /* remove /sys/class/backlight */ - backlight_device_unregister(mfd->fbi->bl_dev); -#else if (lcd_backlight_registered) { lcd_backlight_registered = 0; led_classdev_unregister(&backlight_led); } -#endif #ifdef MSM_FB_ENABLE_DBGFS if (mfd->sub_dir) @@ -666,66 +650,11 @@ static int msm_fb_runtime_idle(struct device *dev) return 0; } -#if (defined(CONFIG_SUSPEND) && defined(CONFIG_FB_MSM_HDMI_MSM_PANEL)) -static int msm_fb_ext_suspend(struct device *dev) -{ - struct msm_fb_data_type *mfd = dev_get_drvdata(dev); - struct msm_fb_panel_data *pdata = NULL; - int ret = 0; - - if ((!mfd) || (mfd->key != MFD_KEY)) - return 0; - - pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; - if (mfd->panel_info.type == HDMI_PANEL || - mfd->panel_info.type == DTV_PANEL) { - ret = msm_fb_suspend_sub(mfd); - - /* Turn off the HPD circuitry */ - if (pdata->power_ctrl) { - MSM_FB_INFO("%s: Turning off HPD circuitry\n", - __func__); - pdata->power_ctrl(FALSE); - } - } - - return ret; -} - -static int msm_fb_ext_resume(struct device *dev) -{ - struct msm_fb_data_type *mfd = dev_get_drvdata(dev); - struct msm_fb_panel_data *pdata = NULL; - int ret = 0; - - if ((!mfd) || (mfd->key != MFD_KEY)) - return 0; - - pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; - if (mfd->panel_info.type == HDMI_PANEL || - mfd->panel_info.type == DTV_PANEL) { - /* Turn on the HPD circuitry */ - if (pdata->power_ctrl) { - pdata->power_ctrl(TRUE); - MSM_FB_INFO("%s: Turning on HPD circuitry\n", - __func__); - } - - ret = msm_fb_resume_sub(mfd); - } - - return ret; -} -#endif static struct dev_pm_ops msm_fb_dev_pm_ops = { .runtime_suspend = msm_fb_runtime_suspend, .runtime_resume = msm_fb_runtime_resume, .runtime_idle = msm_fb_runtime_idle, -#if (defined(CONFIG_SUSPEND) && defined(CONFIG_FB_MSM_HDMI_MSM_PANEL)) - .suspend = msm_fb_ext_suspend, - .resume = msm_fb_ext_resume, -#endif }; static struct platform_driver msm_fb_driver = { @@ -1478,11 +1407,6 @@ static int msm_fb_register(struct msm_fb_data_type *mfd) ("FrameBuffer[%d] %dx%d size=%d bytes is registered successfully!\n", mfd->index, fbi->var.xres, fbi->var.yres, fbi->fix.smem_len); -#ifdef CONFIG_FB_MSM_LOGO - /* Flip buffer */ - if (!load_565rle_image(INIT_IMAGE_FILE, bf_supported)) - ; -#endif ret = 0; #ifdef CONFIG_HAS_EARLYSUSPEND diff --git a/drivers/video/msm/msm_fb.h b/drivers/video/msm/msm_fb.h deleted file mode 100644 index 12815d13820e08752681804a062f8177f1305b02..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_fb.h +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright (c) 2008-2013, 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 MSM_FB_H -#define MSM_FB_H - -#include -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifdef CONFIG_HAS_EARLYSUSPEND -#include -#endif - -#include "msm_fb_panel.h" -#include "mdp.h" - -#define MSM_FB_DEFAULT_PAGE_SIZE 2 -#define MFD_KEY 0x11161126 -#define MSM_FB_MAX_DEV_LIST 32 - -struct disp_info_type_suspend { - boolean op_enable; - boolean sw_refreshing_enable; - boolean panel_power_on; - boolean op_suspend; -}; - -struct msmfb_writeback_data_list { - struct list_head registered_entry; - struct list_head active_entry; - dma_addr_t addr; - struct ion_handle *ihdl; - struct file *pmem_file; - struct msmfb_data buf_info; - struct msmfb_img img; - int state; -}; - - -struct msm_fb_data_type { - __u32 key; - __u32 index; - __u32 ref_cnt; - __u32 fb_page; - - panel_id_type panel; - struct msm_panel_info panel_info; - - DISP_TARGET dest; - struct fb_info *fbi; - - struct delayed_work backlight_worker; - boolean op_enable; - uint32 fb_imgType; - boolean sw_currently_refreshing; - boolean sw_refreshing_enable; - boolean hw_refresh; -#ifdef CONFIG_FB_MSM_OVERLAY - int overlay_play_enable; -#endif - - MDPIBUF ibuf; - boolean ibuf_flushed; - struct timer_list refresh_timer; - struct completion refresher_comp; - - boolean pan_waiting; - struct completion pan_comp; - - /* vsync */ - boolean use_mdp_vsync; - __u32 vsync_gpio; - __u32 total_lcd_lines; - __u32 total_porch_lines; - __u32 lcd_ref_usec_time; - __u32 refresh_timer_duration; - - struct hrtimer dma_hrtimer; - - boolean panel_power_on; - struct work_struct dma_update_worker; - struct semaphore sem; - - struct timer_list vsync_resync_timer; - boolean vsync_handler_pending; - struct work_struct vsync_resync_worker; - - ktime_t last_vsync_timetick; - - __u32 *vsync_width_boundary; - - unsigned int pmem_id; - struct disp_info_type_suspend suspend; - - __u32 channel_irq; - - struct mdp_dma_data *dma; - struct device_attribute dev_attr; - void (*dma_fnc) (struct msm_fb_data_type *mfd); - int (*cursor_update) (struct fb_info *info, - struct fb_cursor *cursor); - int (*lut_update) (struct fb_info *info, - struct fb_cmap *cmap); - int (*do_histogram) (struct fb_info *info, - struct mdp_histogram_data *hist); - int (*start_histogram) (struct mdp_histogram_start_req *req); - int (*stop_histogram) (struct fb_info *info, uint32_t block); - void (*vsync_ctrl) (int enable); - void (*vsync_init) (int cndx); - void (*update_panel_info)(struct msm_fb_data_type *mfd); - bool (*is_panel_ready)(void); - void *vsync_show; - void *cursor_buf; - void *cursor_buf_phys; - - void *cmd_port; - void *data_port; - void *data_port_phys; - - __u32 bl_level; - - struct platform_device *pdev; - - __u32 var_xres; - __u32 var_yres; - __u32 var_pixclock; - __u32 var_frame_rate; - -#ifdef MSM_FB_ENABLE_DBGFS - struct dentry *sub_dir; -#endif - -#ifdef CONFIG_HAS_EARLYSUSPEND - struct early_suspend early_suspend; -#ifdef CONFIG_FB_MSM_MDDI - struct early_suspend mddi_early_suspend; - struct early_suspend mddi_ext_early_suspend; -#endif -#endif - u32 mdp_fb_page_protection; - - struct clk *ebi1_clk; - boolean dma_update_flag; - struct timer_list msmfb_no_update_notify_timer; - struct completion msmfb_update_notify; - struct completion msmfb_no_update_notify; - struct mutex writeback_mutex; - struct mutex unregister_mutex; - struct list_head writeback_busy_queue; - struct list_head writeback_free_queue; - struct list_head writeback_register_queue; - struct switch_dev writeback_sdev; - wait_queue_head_t wait_q; - struct ion_client *iclient; - dma_addr_t display_iova; - dma_addr_t rotator_iova; - struct mdp_buf_type *ov0_wb_buf; - struct mdp_buf_type *ov1_wb_buf; - u32 ov_start; - u32 mem_hid; - u32 mdp_rev; - u32 writeback_state; - bool writeback_active_cnt; - int cont_splash_done; - void *copy_splash_buf; - unsigned char *copy_splash_phys; - void *cpu_pm_hdl; - u32 avtimer_phy; - int vsync_sysfs_created; - u32 acq_fen_cnt; - struct sync_fence *acq_fen[MDP_MAX_FENCE_FD]; - int cur_rel_fen_fd; - struct sync_pt *cur_rel_sync_pt; - struct sync_fence *cur_rel_fence; - struct sync_fence *last_rel_fence; - struct sw_sync_timeline *timeline; - int timeline_value; - u32 last_acq_fen_cnt; - struct sync_fence *last_acq_fen[MDP_MAX_FENCE_FD]; - struct mutex sync_mutex; - struct completion commit_comp; - u32 is_committing; - struct work_struct commit_work; - void *msm_fb_backup; -}; -struct msm_fb_backup_type { - struct fb_info info; - struct fb_var_screeninfo var; - struct msm_fb_data_type mfd; -}; - -struct dentry *msm_fb_get_debugfs_root(void); -void msm_fb_debugfs_file_create(struct dentry *root, const char *name, - u32 *var); -void msm_fb_set_backlight(struct msm_fb_data_type *mfd, __u32 bkl_lvl); - -struct platform_device *msm_fb_add_device(struct platform_device *pdev); -struct fb_info *msm_fb_get_writeback_fb(void); -int msm_fb_writeback_init(struct fb_info *info); -int msm_fb_writeback_start(struct fb_info *info); -int msm_fb_writeback_queue_buffer(struct fb_info *info, - struct msmfb_data *data); -int msm_fb_writeback_dequeue_buffer(struct fb_info *info, - struct msmfb_data *data); -int msm_fb_writeback_stop(struct fb_info *info); -int msm_fb_writeback_terminate(struct fb_info *info); -int msm_fb_detect_client(const char *name); -int calc_fb_offset(struct msm_fb_data_type *mfd, struct fb_info *fbi, int bpp); -int msm_fb_wait_for_fence(struct msm_fb_data_type *mfd); -int msm_fb_signal_timeline(struct msm_fb_data_type *mfd); -#ifdef CONFIG_FB_BACKLIGHT -void msm_fb_config_backlight(struct msm_fb_data_type *mfd); -#endif - -void fill_black_screen(bool on, uint8 pipe_num, uint8 mixer_num); -int msm_fb_check_frame_rate(struct msm_fb_data_type *mfd, - struct fb_info *info); - -#ifdef CONFIG_FB_MSM_LOGO -#define INIT_IMAGE_FILE "/initlogo.rle" -int load_565rle_image(char *filename, bool bf_supported); -#endif - -#endif /* MSM_FB_H */ diff --git a/drivers/video/msm/msm_fb_bl.c b/drivers/video/msm/msm_fb_bl.c deleted file mode 100644 index cdedc6f89eb81955e11d7d91fe45916668ae1889..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_fb_bl.c +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (c) 2008-2009, 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 -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb.h" - -static int msm_fb_bl_get_brightness(struct backlight_device *pbd) -{ - return pbd->props.brightness; -} - -static int msm_fb_bl_update_status(struct backlight_device *pbd) -{ - struct msm_fb_data_type *mfd = bl_get_data(pbd); - __u32 bl_lvl; - - bl_lvl = pbd->props.brightness; - bl_lvl = mfd->fbi->bl_curve[bl_lvl]; - down(&mfd->sem); - msm_fb_set_backlight(mfd, bl_lvl); - up(&mfd->sem); - return 0; -} - -static struct backlight_ops msm_fb_bl_ops = { - .get_brightness = msm_fb_bl_get_brightness, - .update_status = msm_fb_bl_update_status, -}; - -void msm_fb_config_backlight(struct msm_fb_data_type *mfd) -{ - struct msm_fb_panel_data *pdata; - struct backlight_device *pbd; - struct fb_info *fbi; - char name[16]; - struct backlight_properties props; - - fbi = mfd->fbi; - pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data; - - if ((pdata) && (pdata->set_backlight)) { - snprintf(name, sizeof(name), "msmfb_bl%d", mfd->index); - props.max_brightness = FB_BACKLIGHT_LEVELS - 1; - props.brightness = FB_BACKLIGHT_LEVELS - 1; - pbd = - backlight_device_register(name, fbi->dev, mfd, - &msm_fb_bl_ops, &props); - if (!IS_ERR(pbd)) { - fbi->bl_dev = pbd; - fb_bl_default_curve(fbi, - 0, - mfd->panel_info.bl_min, - mfd->panel_info.bl_max); - } else { - fbi->bl_dev = NULL; - printk(KERN_ERR "msm_fb: backlight_device_register failed!\n"); - } - } -} diff --git a/drivers/video/msm/msm_fb_def.h b/drivers/video/msm/msm_fb_def.h deleted file mode 100644 index 99a910f59575116452a6de9913a3fefe0848a3c7..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_fb_def.h +++ /dev/null @@ -1,200 +0,0 @@ -/* Copyright (c) 2008-2010, 2013, 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 MSM_FB_DEF_H -#define MSM_FB_DEF_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "linux/proc_fs.h" -#include -#include -#include - -#include - - -typedef s64 int64; -typedef s32 int32; -typedef s16 int16; -typedef s8 int8; - -typedef u64 uint64; -typedef u32 uint32; -typedef u16 uint16; -typedef u8 uint8; - -typedef s32 int4; -typedef s16 int2; -typedef s8 int1; - -typedef u32 uint4; -typedef u16 uint2; -typedef u8 uint1; - -typedef u32 dword; -typedef u16 word; -typedef u8 byte; - -typedef unsigned int boolean; - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#define MSM_FB_ENABLE_DBGFS -#define FEATURE_MDDI - -#if defined(CONFIG_FB_MSM_DEFAULT_DEPTH_RGB565) -#define MSMFB_DEFAULT_TYPE MDP_RGB_565 -#elif defined(CONFIG_FB_MSM_DEFAULT_DEPTH_ARGB8888) -#define MSMFB_DEFAULT_TYPE MDP_ARGB_8888 -#elif defined(CONFIG_FB_MSM_DEFAULT_DEPTH_RGBA8888) -#define MSMFB_DEFAULT_TYPE MDP_RGBA_8888 -#else -#define MSMFB_DEFAULT_TYPE MDP_RGB_565 -#endif - -#define outp32(addr, val) writel(val, addr) -#define outp16(addr, val) writew(val, addr) -#define outp8(addr, val) writeb(val, addr) -#define outp(addr, val) outp32(addr, val) - -#ifndef MAX -#define MAX( x, y ) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef MIN -#define MIN( x, y ) (((x) < (y)) ? (x) : (y)) -#endif - -/*--------------------------------------------------------------------------*/ - -#define inp32(addr) readl(addr) -#define inp16(addr) readw(addr) -#define inp8(addr) readb(addr) -#define inp(addr) inp32(addr) - -#define inpw(port) readw(port) -#define outpw(port, val) writew(val, port) -#define inpdw(port) readl(port) -#define outpdw(port, val) writel(val, port) - - -#define clk_busy_wait(x) msleep_interruptible((x)/1000) - -#define memory_barrier() - -#define assert(expr) \ - if(!(expr)) { \ - printk(KERN_ERR "msm_fb: assertion failed! %s,%s,%s,line=%d\n",\ - #expr, __FILE__, __func__, __LINE__); \ - } - -#define ASSERT(x) assert(x) - -#define DISP_EBI2_LOCAL_DEFINE -#ifdef DISP_EBI2_LOCAL_DEFINE -#define LCD_PRIM_BASE_PHYS 0x98000000 -#define LCD_SECD_BASE_PHYS 0x9c000000 -#define EBI2_PRIM_LCD_RS_PIN 0x20000 -#define EBI2_SECD_LCD_RS_PIN 0x20000 - -#define EBI2_PRIM_LCD_CLR 0xC0 -#define EBI2_PRIM_LCD_SEL 0x40 - -#define EBI2_SECD_LCD_CLR 0x300 -#define EBI2_SECD_LCD_SEL 0x100 -#endif - -extern u32 msm_fb_msg_level; - -/* - * Message printing priorities: - * LEVEL 0 KERN_EMERG (highest priority) - * LEVEL 1 KERN_ALERT - * LEVEL 2 KERN_CRIT - * LEVEL 3 KERN_ERR - * LEVEL 4 KERN_WARNING - * LEVEL 5 KERN_NOTICE - * LEVEL 6 KERN_INFO - * LEVEL 7 KERN_DEBUG (Lowest priority) - */ -#define MSM_FB_EMERG(msg, ...) \ - if (msm_fb_msg_level > 0) \ - printk(KERN_EMERG msg, ## __VA_ARGS__); -#define MSM_FB_ALERT(msg, ...) \ - if (msm_fb_msg_level > 1) \ - printk(KERN_ALERT msg, ## __VA_ARGS__); -#define MSM_FB_CRIT(msg, ...) \ - if (msm_fb_msg_level > 2) \ - printk(KERN_CRIT msg, ## __VA_ARGS__); -#define MSM_FB_ERR(msg, ...) \ - if (msm_fb_msg_level > 3) \ - printk(KERN_ERR msg, ## __VA_ARGS__); -#define MSM_FB_WARNING(msg, ...) \ - if (msm_fb_msg_level > 4) \ - printk(KERN_WARNING msg, ## __VA_ARGS__); -#define MSM_FB_NOTICE(msg, ...) \ - if (msm_fb_msg_level > 5) \ - printk(KERN_NOTICE msg, ## __VA_ARGS__); -#define MSM_FB_INFO(msg, ...) \ - if (msm_fb_msg_level > 6) \ - printk(KERN_INFO msg, ## __VA_ARGS__); -#define MSM_FB_DEBUG(msg, ...) \ - if (msm_fb_msg_level > 7) \ - printk(KERN_DEBUG msg, ## __VA_ARGS__); - -#ifdef MSM_FB_C -unsigned char *msm_mdp_base; -unsigned char *msm_pmdh_base; -unsigned char *msm_emdh_base; -unsigned char *mipi_dsi_base; -#else -extern unsigned char *msm_mdp_base; -extern unsigned char *msm_pmdh_base; -extern unsigned char *msm_emdh_base; -extern unsigned char *mipi_dsi_base; -#endif - -#undef ENABLE_MDDI_MULTI_READ_WRITE -#undef ENABLE_FWD_LINK_SKEW_CALIBRATION - -#endif /* MSM_FB_DEF_H */ diff --git a/drivers/video/msm/msm_fb_panel.c b/drivers/video/msm/msm_fb_panel.c deleted file mode 100644 index 28698c12c40b9a78ae83c095ae1335d01d7c8ce0..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_fb_panel.c +++ /dev/null @@ -1,170 +0,0 @@ -/* Copyright (c) 2008-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm_fb_panel.h" - -int panel_next_on(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_panel_data *pdata; - struct msm_fb_panel_data *next_pdata; - struct platform_device *next_pdev; - - pdata = (struct msm_fb_panel_data *)pdev->dev.platform_data; - - if (pdata) { - next_pdev = pdata->next; - if (next_pdev) { - next_pdata = - (struct msm_fb_panel_data *)next_pdev->dev. - platform_data; - if ((next_pdata) && (next_pdata->on)) - ret = next_pdata->on(next_pdev); - } - } - - return ret; -} - -int panel_next_off(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_panel_data *pdata; - struct msm_fb_panel_data *next_pdata; - struct platform_device *next_pdev; - - pdata = (struct msm_fb_panel_data *)pdev->dev.platform_data; - - if (pdata) { - next_pdev = pdata->next; - if (next_pdev) { - next_pdata = - (struct msm_fb_panel_data *)next_pdev->dev. - platform_data; - if ((next_pdata) && (next_pdata->on)) - ret = next_pdata->off(next_pdev); - } - } - - return ret; -} - -int panel_next_late_init(struct platform_device *pdev) -{ - int ret = 0; - struct msm_fb_panel_data *pdata; - struct msm_fb_panel_data *next_pdata; - struct platform_device *next_pdev; - - pdata = (struct msm_fb_panel_data *)pdev->dev.platform_data; - - if (pdata) { - next_pdev = pdata->next; - if (next_pdev) { - next_pdata = (struct msm_fb_panel_data *) - next_pdev->dev.platform_data; - if ((next_pdata) && (next_pdata->late_init)) - ret = next_pdata->late_init(next_pdev); - } - } - - return ret; -} - -struct platform_device *msm_fb_device_alloc(struct msm_fb_panel_data *pdata, - u32 type, u32 id) -{ - struct platform_device *this_dev = NULL; - char dev_name[16]; - - switch (type) { - case EBI2_PANEL: - snprintf(dev_name, sizeof(dev_name), "ebi2_lcd"); - break; - - case MDDI_PANEL: - snprintf(dev_name, sizeof(dev_name), "mddi"); - break; - - case EXT_MDDI_PANEL: - snprintf(dev_name, sizeof(dev_name), "mddi_ext"); - break; - - case TV_PANEL: - snprintf(dev_name, sizeof(dev_name), "tvenc"); - break; - - case HDMI_PANEL: - case LCDC_PANEL: - snprintf(dev_name, sizeof(dev_name), "lcdc"); - break; - - case LVDS_PANEL: - snprintf(dev_name, sizeof(dev_name), "lvds"); - break; - - case DTV_PANEL: - snprintf(dev_name, sizeof(dev_name), "dtv"); - break; - - case MIPI_VIDEO_PANEL: - case MIPI_CMD_PANEL: - snprintf(dev_name, sizeof(dev_name), "mipi_dsi"); - break; - case WRITEBACK_PANEL: - snprintf(dev_name, sizeof(dev_name), "writeback"); - break; - - default: - return NULL; - } - - if (pdata != NULL) - pdata->next = NULL; - else - return NULL; - - this_dev = - platform_device_alloc(dev_name, ((u32) type << 16) | (u32) id); - - if (this_dev) { - if (platform_device_add_data - (this_dev, pdata, sizeof(struct msm_fb_panel_data))) { - printk - ("msm_fb_device_alloc: platform_device_add_data failed!\n"); - platform_device_put(this_dev); - return NULL; - } - } - - return this_dev; -} diff --git a/drivers/video/msm/msm_fb_panel.h b/drivers/video/msm/msm_fb_panel.h deleted file mode 100644 index 26b88b16b5c7b63f439f43a0962640c0e7ccc079..0000000000000000000000000000000000000000 --- a/drivers/video/msm/msm_fb_panel.h +++ /dev/null @@ -1,235 +0,0 @@ -/* Copyright (c) 2008-2012, 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 MSM_FB_PANEL_H -#define MSM_FB_PANEL_H - -#include "msm_fb_def.h" - -struct msm_fb_data_type; - -typedef void (*msm_fb_vsync_handler_type) (void *arg); - -/* panel id type */ -typedef struct panel_id_s { - uint16 id; - uint16 type; -} panel_id_type; - -/* panel type list */ -#define NO_PANEL 0xffff /* No Panel */ -#define MDDI_PANEL 1 /* MDDI */ -#define EBI2_PANEL 2 /* EBI2 */ -#define LCDC_PANEL 3 /* internal LCDC type */ -#define EXT_MDDI_PANEL 4 /* Ext.MDDI */ -#define TV_PANEL 5 /* TV */ -#define HDMI_PANEL 6 /* HDMI TV */ -#define DTV_PANEL 7 /* DTV */ -#define MIPI_VIDEO_PANEL 8 /* MIPI */ -#define MIPI_CMD_PANEL 9 /* MIPI */ -#define WRITEBACK_PANEL 10 /* Wifi display */ -#define LVDS_PANEL 11 /* LVDS */ - -/* panel class */ -typedef enum { - DISPLAY_LCD = 0, /* lcd = ebi2/mddi */ - DISPLAY_LCDC, /* lcdc */ - DISPLAY_TV, /* TV Out */ - DISPLAY_EXT_MDDI, /* External MDDI */ -} DISP_TARGET; - -/* panel device locaiton */ -typedef enum { - DISPLAY_1 = 0, /* attached as first device */ - DISPLAY_2, /* attached on second device */ - DISPLAY_3, /* attached on third writeback device */ - MAX_PHYS_TARGET_NUM, -} DISP_TARGET_PHYS; - -enum { - BLT_SWITCH_TG_OFF, - BLT_SWITCH_TG_ON -}; - -/* panel info type */ -struct lcd_panel_info { - __u32 vsync_enable; - __u32 refx100; - __u32 v_back_porch; - __u32 v_front_porch; - __u32 v_pulse_width; - __u32 hw_vsync_mode; - __u32 vsync_notifier_period; - __u32 blt_ctrl; - __u32 blt_mode; - __u32 rev; -}; - -struct lcdc_panel_info { - __u32 h_back_porch; - __u32 h_front_porch; - __u32 h_pulse_width; - __u32 v_back_porch; - __u32 v_front_porch; - __u32 v_pulse_width; - __u32 border_clr; - __u32 underflow_clr; - __u32 hsync_skew; - /* Pad width */ - uint32 xres_pad; - /* Pad height */ - uint32 yres_pad; - boolean is_sync_active_high; -}; - -struct mddi_panel_info { - __u32 vdopkt; - boolean is_type1; -}; - -struct mipi_panel_info { - char mode; /* video/cmd */ - char interleave_mode; - char crc_check; - char ecc_check; - char dst_format; /* shared by video and command */ - char data_lane0; - char data_lane1; - char data_lane2; - char data_lane3; - char dlane_swap; /* data lane swap */ - char rgb_swap; - char b_sel; - char g_sel; - char r_sel; - char rx_eot_ignore; - char tx_eot_append; - char t_clk_post; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */ - char t_clk_pre; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */ - char vc; /* virtual channel */ - struct mipi_dsi_phy_ctrl *dsi_phy_db; - /* video mode */ - char pulse_mode_hsa_he; - char hfp_power_stop; - char hbp_power_stop; - char hsa_power_stop; - char eof_bllp_power_stop; - char bllp_power_stop; - char traffic_mode; - char frame_rate; - /* command mode */ - char interleave_max; - char insert_dcs_cmd; - char wr_mem_continue; - char wr_mem_start; - char te_sel; - char stream; /* 0 or 1 */ - char mdp_trigger; - char dma_trigger; - uint32 dsi_pclk_rate; - /* byte to esc clk ratio */ - uint32 esc_byte_ratio; - /* The packet-size should not bet changed */ - char no_max_pkt_size; - /* Clock required during LP commands */ - char force_clk_lane_hs; -}; - -enum lvds_mode { - LVDS_SINGLE_CHANNEL_MODE, - LVDS_DUAL_CHANNEL_MODE, -}; - -struct lvds_panel_info { - enum lvds_mode channel_mode; - /* Channel swap in dual mode */ - char channel_swap; -}; - -struct msm_panel_info { - __u32 xres; - __u32 yres; - __u32 bpp; - __u32 mode2_xres; - __u32 mode2_yres; - __u32 mode2_bpp; - __u32 type; - __u32 wait_cycle; - DISP_TARGET_PHYS pdest; - __u32 bl_max; - __u32 bl_min; - __u32 fb_num; - __u32 clk_rate; - __u32 clk_min; - __u32 clk_max; - __u32 frame_count; - __u32 is_3d_panel; - __u32 frame_rate; - __u32 frame_interval; - - struct mddi_panel_info mddi; - struct lcd_panel_info lcd; - struct lcdc_panel_info lcdc; - struct mipi_panel_info mipi; - struct lvds_panel_info lvds; -}; - -#define MSM_FB_SINGLE_MODE_PANEL(pinfo) \ - do { \ - (pinfo)->mode2_xres = 0; \ - (pinfo)->mode2_yres = 0; \ - (pinfo)->mode2_bpp = 0; \ - } while (0) - -struct msm_fb_panel_data { - struct msm_panel_info panel_info; - void (*set_rect) (int x, int y, int xres, int yres); - void (*set_vsync_notifier) (msm_fb_vsync_handler_type, void *arg); - void (*set_backlight) (struct msm_fb_data_type *); - - /* function entry chain */ - int (*on) (struct platform_device *pdev); - int (*off) (struct platform_device *pdev); - int (*late_init) (struct platform_device *pdev); - int (*power_ctrl) (boolean enable); - struct platform_device *next; - int (*clk_func) (int enable); -}; - -enum { - MDP4_OVERLAY_BLT_SWITCH_TG_OFF, - MDP4_OVERLAY_BLT_SWITCH_TG_ON, - MDP4_OVERLAY_BLT_SWITCH_POLL -}; - -enum { - MDP4_OVERLAY_MODE_BLT_CTRL, - MDP4_OVERLAY_MODE_BLT_ALWAYS_ON, - MDP4_OVERLAY_MODE_BLT_ALWAYS_OFF -}; - -/*=========================================================================== - FUNCTIONS PROTOTYPES -============================================================================*/ -struct platform_device *msm_fb_device_alloc(struct msm_fb_panel_data *pdata, - u32 type, u32 id); -int panel_next_on(struct platform_device *pdev); -int panel_next_off(struct platform_device *pdev); -int panel_next_late_init(struct platform_device *pdev); - -int lcdc_device_register(struct msm_panel_info *pinfo); - -int mddi_toshiba_device_register(struct msm_panel_info *pinfo, - u32 channel, u32 panel); - -#endif /* MSM_FB_PANEL_H */ diff --git a/drivers/video/msm/tvenc.c b/drivers/video/msm/tvenc.c deleted file mode 100644 index e261d25fa2ec07c043ba18fd3845226cdebd8bee..0000000000000000000000000000000000000000 --- a/drivers/video/msm/tvenc.c +++ /dev/null @@ -1,520 +0,0 @@ -/* Copyright (c) 2008-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define TVENC_C -#include "tvenc.h" -#include "msm_fb.h" -#include "mdp4.h" -/* AXI rate in KHz */ -#define MSM_SYSTEM_BUS_RATE 128000000 - -static int tvenc_probe(struct platform_device *pdev); -static int tvenc_remove(struct platform_device *pdev); - -static int tvenc_off(struct platform_device *pdev); -static int tvenc_on(struct platform_device *pdev); - -static struct platform_device *pdev_list[MSM_FB_MAX_DEV_LIST]; -static int pdev_list_cnt; - -static struct clk *tvenc_clk; -static struct clk *tvdac_clk; -static struct clk *tvenc_pclk; -static struct clk *mdp_tv_clk; -#ifdef CONFIG_FB_MSM_MDP40 -static struct clk *tv_src_clk; -#endif - -#ifdef CONFIG_MSM_BUS_SCALING -static uint32_t tvenc_bus_scale_handle; -#endif - -static int tvenc_runtime_suspend(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: suspending...\n"); - return 0; -} - -static int tvenc_runtime_resume(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: resuming...\n"); - return 0; -} - -static struct dev_pm_ops tvenc_dev_pm_ops = { - .runtime_suspend = tvenc_runtime_suspend, - .runtime_resume = tvenc_runtime_resume, -}; - -static struct platform_driver tvenc_driver = { - .probe = tvenc_probe, - .remove = tvenc_remove, - .suspend = NULL, - .resume = NULL, - .shutdown = NULL, - .driver = { - .name = "tvenc", - .pm = &tvenc_dev_pm_ops - }, -}; - -int tvenc_set_encoder_clock(boolean clock_on) -{ - int ret = 0; - if (clock_on) { -#ifdef CONFIG_FB_MSM_MDP40 - /* Consolidated clock used by both HDMI & TV encoder. - Clock exists only in MDP4 and not in older versions */ - ret = clk_set_rate(tv_src_clk, 27000000); - if (ret) { - pr_err("%s: tvsrc_clk set rate failed! %d\n", - __func__, ret); - goto tvsrc_err; - } -#endif - ret = clk_prepare_enable(tvenc_clk); - if (ret) { - pr_err("%s: tvenc_clk enable failed! %d\n", - __func__, ret); - goto tvsrc_err; - } - - if (!IS_ERR(tvenc_pclk)) { - ret = clk_prepare_enable(tvenc_pclk); - if (ret) { - pr_err("%s: tvenc_pclk enable failed! %d\n", - __func__, ret); - goto tvencp_err; - } - } - return ret; - } else { - if (!IS_ERR(tvenc_pclk)) - clk_disable_unprepare(tvenc_pclk); - clk_disable_unprepare(tvenc_clk); - return ret; - } -tvencp_err: - clk_disable_unprepare(tvenc_clk); -tvsrc_err: - return ret; -} - -int tvenc_set_clock(boolean clock_on) -{ - int ret = 0; - if (clock_on) { - if (tvenc_pdata->poll) { - ret = tvenc_set_encoder_clock(CLOCK_ON); - if (ret) { - pr_err("%s: TVenc clock(s) enable failed! %d\n", - __func__, ret); - goto tvenc_err; - } - } - ret = clk_prepare_enable(tvdac_clk); - if (ret) { - pr_err("%s: tvdac_clk enable failed! %d\n", - __func__, ret); - goto tvdac_err; - } - if (!IS_ERR(mdp_tv_clk)) { - ret = clk_prepare_enable(mdp_tv_clk); - if (ret) { - pr_err("%s: mdp_tv_clk enable failed! %d\n", - __func__, ret); - goto mdptv_err; - } - } - return ret; - } else { - if (!IS_ERR(mdp_tv_clk)) - clk_disable_unprepare(mdp_tv_clk); - clk_disable_unprepare(tvdac_clk); - if (tvenc_pdata->poll) - tvenc_set_encoder_clock(CLOCK_OFF); - return ret; - } - -mdptv_err: - clk_disable_unprepare(tvdac_clk); -tvdac_err: - tvenc_set_encoder_clock(CLOCK_OFF); -tvenc_err: - return ret; -} - -static int tvenc_off(struct platform_device *pdev) -{ - int ret = 0; - - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - - ret = panel_next_off(pdev); - if (ret) - pr_err("%s: tvout_off failed! %d\n", - __func__, ret); - - tvenc_set_clock(CLOCK_OFF); - - if (tvenc_pdata && tvenc_pdata->pm_vid_en) - ret = tvenc_pdata->pm_vid_en(0); -#ifdef CONFIG_MSM_BUS_SCALING - if (tvenc_bus_scale_handle > 0) - msm_bus_scale_client_update_request(tvenc_bus_scale_handle, - 0); -#else - if (mfd->ebi1_clk) - clk_disable_unprepare(mfd->ebi1_clk); -#endif - - if (ret) - pr_err("%s: pm_vid_en(off) failed! %d\n", - __func__, ret); - mdp4_extn_disp = 0; - return ret; -} - -static int tvenc_on(struct platform_device *pdev) -{ - int ret = 0; - -#ifndef CONFIG_MSM_BUS_SCALING - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); -#endif - -#ifdef CONFIG_MSM_BUS_SCALING - if (tvenc_bus_scale_handle > 0) - msm_bus_scale_client_update_request(tvenc_bus_scale_handle, - 1); -#else - if (mfd->ebi1_clk) - clk_prepare_enable(mfd->ebi1_clk); -#endif - mdp4_extn_disp = 1; - if (tvenc_pdata && tvenc_pdata->pm_vid_en) - ret = tvenc_pdata->pm_vid_en(1); - if (ret) { - pr_err("%s: pm_vid_en(on) failed! %d\n", - __func__, ret); - return ret; - } - - ret = tvenc_set_clock(CLOCK_ON); - if (ret) { - pr_err("%s: tvenc_set_clock(CLOCK_ON) failed! %d\n", - __func__, ret); - tvenc_pdata->pm_vid_en(0); - goto error; - } - - ret = panel_next_on(pdev); - if (ret) { - pr_err("%s: tvout_on failed! %d\n", - __func__, ret); - tvenc_set_clock(CLOCK_OFF); - tvenc_pdata->pm_vid_en(0); - } - -error: - return ret; - -} - -void tvenc_gen_test_pattern(struct msm_fb_data_type *mfd) -{ - uint32 reg = 0, i; - - reg = readl(MSM_TV_ENC_CTL); - reg |= TVENC_CTL_TEST_PATT_EN; - - for (i = 0; i < 3; i++) { - TV_OUT(TV_ENC_CTL, 0); /* disable TV encoder */ - - switch (i) { - /* - * TV Encoder - Color Bar Test Pattern - */ - case 0: - reg |= TVENC_CTL_TPG_CLRBAR; - break; - /* - * TV Encoder - Red Frame Test Pattern - */ - case 1: - reg |= TVENC_CTL_TPG_REDCLR; - break; - /* - * TV Encoder - Modulated Ramp Test Pattern - */ - default: - reg |= TVENC_CTL_TPG_MODRAMP; - break; - } - - TV_OUT(TV_ENC_CTL, reg); - mdelay(5000); - - switch (i) { - /* - * TV Encoder - Color Bar Test Pattern - */ - case 0: - reg &= ~TVENC_CTL_TPG_CLRBAR; - break; - /* - * TV Encoder - Red Frame Test Pattern - */ - case 1: - reg &= ~TVENC_CTL_TPG_REDCLR; - break; - /* - * TV Encoder - Modulated Ramp Test Pattern - */ - default: - reg &= ~TVENC_CTL_TPG_MODRAMP; - break; - } - } -} - -static int tvenc_resource_initialized; - -static int tvenc_probe(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - struct platform_device *mdp_dev = NULL; - struct msm_fb_panel_data *pdata = NULL; - int rc, ret; - struct clk *ebi1_clk = NULL; - - if (pdev->id == 0) { - tvenc_base = ioremap(pdev->resource[0].start, - pdev->resource[0].end - - pdev->resource[0].start + 1); - if (!tvenc_base) { - pr_err("tvenc_base ioremap failed!\n"); - return -ENOMEM; - } - - tvenc_clk = clk_get(&pdev->dev, "enc_clk"); - tvdac_clk = clk_get(&pdev->dev, "dac_clk"); - tvenc_pclk = clk_get(&pdev->dev, "iface_clk"); - mdp_tv_clk = clk_get(&pdev->dev, "mdp_clk"); - -#ifndef CONFIG_MSM_BUS_SCALING - ebi1_clk = clk_get(&pdev->dev, "mem_clk"); - if (IS_ERR(ebi1_clk)) { - rc = PTR_ERR(ebi1_clk); - goto tvenc_probe_err; - } - clk_set_rate(ebi1_clk, MSM_SYSTEM_BUS_RATE); -#endif - -#ifdef CONFIG_FB_MSM_MDP40 - tv_src_clk = clk_get(&pdev->dev, "src_clk"); - if (IS_ERR(tv_src_clk)) - tv_src_clk = tvenc_clk; /* Fallback to slave */ -#endif - - if (IS_ERR(tvenc_clk)) { - pr_err("%s: error: can't get tvenc_clk!\n", __func__); - return PTR_ERR(tvenc_clk); - } - - if (IS_ERR(tvdac_clk)) { - pr_err("%s: error: can't get tvdac_clk!\n", __func__); - return PTR_ERR(tvdac_clk); - } - - if (IS_ERR(tvenc_pclk)) { - ret = PTR_ERR(tvenc_pclk); - if (-ENOENT == ret) - pr_info("%s: tvenc_pclk does not exist!\n", - __func__); - else { - pr_err("%s: error: can't get tvenc_pclk!\n", - __func__); - return ret; - } - } - - if (IS_ERR(mdp_tv_clk)) { - ret = PTR_ERR(mdp_tv_clk); - if (-ENOENT == ret) - pr_info("%s: mdp_tv_clk does not exist!\n", - __func__); - else { - pr_err("%s: error: can't get mdp_tv_clk!\n", - __func__); - return ret; - } - } - - tvenc_pdata = pdev->dev.platform_data; - tvenc_resource_initialized = 1; - return 0; - } - - if (!tvenc_resource_initialized) - return -EPERM; - - mfd = platform_get_drvdata(pdev); - mfd->ebi1_clk = ebi1_clk; - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - - if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) - return -ENOMEM; - - if (tvenc_base == NULL) - return -ENOMEM; - - mdp_dev = platform_device_alloc("mdp", pdev->id); - if (!mdp_dev) - return -ENOMEM; - - /* - * link to the latest pdev - */ - mfd->pdev = mdp_dev; - mfd->dest = DISPLAY_TV; - - /* - * alloc panel device data - */ - if (platform_device_add_data - (mdp_dev, pdev->dev.platform_data, - sizeof(struct msm_fb_panel_data))) { - pr_err("tvenc_probe: platform_device_add_data failed!\n"); - platform_device_put(mdp_dev); - return -ENOMEM; - } - /* - * data chain - */ - pdata = mdp_dev->dev.platform_data; - pdata->on = tvenc_on; - pdata->off = tvenc_off; - pdata->next = pdev; - - /* - * get/set panel specific fb info - */ - mfd->panel_info = pdata->panel_info; -#ifdef CONFIG_FB_MSM_MDP40 - mfd->fb_imgType = MDP_RGB_565; /* base layer */ -#else - mfd->fb_imgType = MDP_YCRYCB_H2V1; -#endif - -#ifdef CONFIG_MSM_BUS_SCALING - if (!tvenc_bus_scale_handle && tvenc_pdata && - tvenc_pdata->bus_scale_table) { - tvenc_bus_scale_handle = - msm_bus_scale_register_client( - tvenc_pdata->bus_scale_table); - if (!tvenc_bus_scale_handle) { - printk(KERN_ERR "%s not able to get bus scale\n", - __func__); - } - } -#endif - - /* - * set driver data - */ - platform_set_drvdata(mdp_dev, mfd); - - /* - * register in mdp driver - */ - rc = platform_device_add(mdp_dev); - if (rc) - goto tvenc_probe_err; - - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - - - - pdev_list[pdev_list_cnt++] = pdev; - - return 0; - -tvenc_probe_err: -#ifdef CONFIG_MSM_BUS_SCALING - if (tvenc_pdata && tvenc_pdata->bus_scale_table && - tvenc_bus_scale_handle > 0) { - msm_bus_scale_unregister_client(tvenc_bus_scale_handle); - tvenc_bus_scale_handle = 0; - } -#endif - platform_device_put(mdp_dev); - return rc; -} - -static int tvenc_remove(struct platform_device *pdev) -{ - struct msm_fb_data_type *mfd; - - mfd = platform_get_drvdata(pdev); - -#ifdef CONFIG_MSM_BUS_SCALING - if (tvenc_pdata && tvenc_pdata->bus_scale_table && - tvenc_bus_scale_handle > 0) { - msm_bus_scale_unregister_client(tvenc_bus_scale_handle); - tvenc_bus_scale_handle = 0; - } -#else - clk_put(mfd->ebi1_clk); -#endif - - pm_runtime_disable(&pdev->dev); - return 0; -} - -static int tvenc_register_driver(void) -{ - return platform_driver_register(&tvenc_driver); -} - -static int __init tvenc_driver_init(void) -{ - return tvenc_register_driver(); -} - -module_init(tvenc_driver_init); diff --git a/drivers/video/msm/tvenc.h b/drivers/video/msm/tvenc.h deleted file mode 100644 index 050cd335e59a211efbd3e3560b3f3075239a3bd6..0000000000000000000000000000000000000000 --- a/drivers/video/msm/tvenc.h +++ /dev/null @@ -1,126 +0,0 @@ -/* Copyright (c) 2008-2010, 2013, 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 TVENC_H -#define TVENC_H - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "msm_fb_panel.h" - -#define NTSC_M 0 /* North America, Korea */ -#define NTSC_J 1 /* Japan */ -#define PAL_BDGHIN 2 /* Non-argentina PAL-N */ -#define PAL_M 3 /* PAL-M */ -#define PAL_N 4 /* Argentina PAL-N */ - -#define CLOCK_OFF 0 -#define CLOCK_ON 1 - -/* 3.57954545 Mhz */ -#define TVENC_CTL_TV_MODE_NTSC_M_PAL60 0 -/* 3.57961149 Mhz */ -#define TVENC_CTL_TV_MODE_PAL_M BIT(0) -/*non-Argintina = 4.3361875 Mhz */ -#define TVENC_CTL_TV_MODE_PAL_BDGHIN BIT(1) -/*Argentina = 3.582055625 Mhz */ -#define TVENC_CTL_TV_MODE_PAL_N (BIT(1)|BIT(0)) - -#define TVENC_CTL_ENC_EN BIT(2) -#define TVENC_CTL_CC_EN BIT(3) -#define TVENC_CTL_CGMS_EN BIT(4) -#define TVENC_CTL_MACRO_EN BIT(5) -#define TVENC_CTL_Y_FILTER_W_NOTCH BIT(6) -#define TVENC_CTL_Y_FILTER_WO_NOTCH 0 -#define TVENC_CTL_Y_FILTER_EN BIT(7) -#define TVENC_CTL_CR_FILTER_EN BIT(8) -#define TVENC_CTL_CB_FILTER_EN BIT(9) -#define TVENC_CTL_SINX_FILTER_EN BIT(10) -#define TVENC_CTL_TEST_PATT_EN BIT(11) -#define TVENC_CTL_OUTPUT_INV BIT(12) -#define TVENC_CTL_PAL60_MODE BIT(13) -#define TVENC_CTL_NTSCJ_MODE BIT(14) -#define TVENC_CTL_S_VIDEO_EN BIT(19) - - -#define TVENC_CTL_TPG_CLRBAR 0 -#define TVENC_CTL_TPG_MODRAMP BIT(15) -#define TVENC_CTL_TPG_REDCLR BIT(16) -#define TVENC_CTL_TPG_NTSC_CBAR (BIT(16)|BIT(15)) -#define TVENC_CTL_TPG_BLACK BIT(17) -#define TVENC_CTL_TPG_WHITE100 (BIT(17)|BIT(15)) -#define TVENC_CTL_TPG_YELLOW75 (BIT(17)|BIT(16)) -#define TVENC_CTL_TPG_CYAN75 (BIT(17)|BIT(16)|BIT(15)) -#define TVENC_CTL_TPG_GREEN75 BIT(18) -#define TVENC_CTL_TPG_MAGENTA75 (BIT(18)|BIT(15)) -#define TVENC_CTL_TPG_RED75 (BIT(18)|BIT(16)) -#define TVENC_CTL_TPG_BLUE75 (BIT(18)|BIT(16)|BIT(15)) -#define TVENC_CTL_TPG_WHITE75 (BIT(18)|BIT(17)) -#define TVENC_CTL_TPG_WHITE_TRSTN (BIT(18)|BIT(17)|BIT(15)) - -#define TVENC_LOAD_DETECT_EN BIT(8) - -#ifdef TVENC_C -void *tvenc_base; -struct tvenc_platform_data *tvenc_pdata; -#else -extern void *tvenc_base; -extern struct tvenc_platform_data *tvenc_pdata; -#endif - -#define TV_OUT(reg, v) writel(v, tvenc_base + MSM_##reg) -#define TV_IN(reg) readl(tvenc_base + MSM_##reg) - -#define MSM_TV_ENC_CTL 0x00 -#define MSM_TV_LEVEL 0x04 -#define MSM_TV_GAIN 0x08 -#define MSM_TV_OFFSET 0x0c -#define MSM_TV_CGMS 0x10 -#define MSM_TV_SYNC_1 0x14 -#define MSM_TV_SYNC_2 0x18 -#define MSM_TV_SYNC_3 0x1c -#define MSM_TV_SYNC_4 0x20 -#define MSM_TV_SYNC_5 0x24 -#define MSM_TV_SYNC_6 0x28 -#define MSM_TV_SYNC_7 0x2c -#define MSM_TV_BURST_V1 0x30 -#define MSM_TV_BURST_V2 0x34 -#define MSM_TV_BURST_V3 0x38 -#define MSM_TV_BURST_V4 0x3c -#define MSM_TV_BURST_H 0x40 -#define MSM_TV_SOL_REQ_ODD 0x44 -#define MSM_TV_SOL_REQ_EVEN 0x48 -#define MSM_TV_DAC_CTL 0x4c -#define MSM_TV_TEST_MUX 0x50 -#define MSM_TV_TEST_MODE 0x54 -#define MSM_TV_TEST_MISR_RESET 0x58 -#define MSM_TV_TEST_EXPORT_MISR 0x5c -#define MSM_TV_TEST_MISR_CURR_VAL 0x60 -#define MSM_TV_TEST_SOF_CFG 0x64 -#define MSM_TV_DAC_INTF 0x100 - -#define MSM_TV_INTR_ENABLE 0x200 -#define MSM_TV_INTR_STATUS 0x204 -#define MSM_TV_INTR_CLEAR 0x208 - -int tvenc_set_encoder_clock(boolean clock_on); -int tvenc_set_clock(boolean clock_on); -#endif /* TVENC_H */ diff --git a/drivers/video/msm/tvout_msm.c b/drivers/video/msm/tvout_msm.c deleted file mode 100644 index 983c585e0981fa9940746f0251f4e1d8a0b4b9bf..0000000000000000000000000000000000000000 --- a/drivers/video/msm/tvout_msm.c +++ /dev/null @@ -1,652 +0,0 @@ -/* Copyright (c) 2008-2011, 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 -#include -#include - -#include "msm_fb.h" -#include "tvenc.h" -#include "external_common.h" - -#define TVOUT_HPD_DUTY_CYCLE 3000 - -#define TV_DIMENSION_MAX_WIDTH 720 -#define TV_DIMENSION_MAX_HEIGHT 576 - -struct tvout_msm_state_type { - struct external_common_state_type common; - struct platform_device *pdev; - struct timer_list hpd_state_timer; - struct timer_list hpd_work_timer; - struct work_struct hpd_work; - uint32 hpd_int_status; - uint32 prev_hpd_int_status; - uint32 five_retry; - int irq; - uint16 y_res; - boolean hpd_initialized; - boolean disp_powered_up; -#ifdef CONFIG_SUSPEND - boolean pm_suspended; -#endif - -}; - -static struct tvout_msm_state_type *tvout_msm_state; -static DEFINE_MUTEX(tvout_msm_state_mutex); - -static int tvout_off(struct platform_device *pdev); -static int tvout_on(struct platform_device *pdev); -static void tvout_check_status(void); - -static void tvout_msm_turn_on(boolean power_on) -{ - uint32 reg_val = 0; - reg_val = TV_IN(TV_ENC_CTL); - if (power_on) { - DEV_DBG("%s: TV Encoder turned on\n", __func__); - reg_val |= TVENC_CTL_ENC_EN; - } else { - DEV_DBG("%s: TV Encoder turned off\n", __func__); - reg_val = 0; - } - /* Enable TV Encoder*/ - TV_OUT(TV_ENC_CTL, reg_val); -} - -static void tvout_check_status() -{ - tvout_msm_state->hpd_int_status &= 0x05; - /* hpd_int_status could either be 0x05 or 0x04 for a cable - plug-out event when cable detect is driven by polling. */ - if ((((tvout_msm_state->hpd_int_status == 0x05) || - (tvout_msm_state->hpd_int_status == 0x04)) && - (tvout_msm_state->prev_hpd_int_status == BIT(2))) || - ((tvout_msm_state->hpd_int_status == 0x01) && - (tvout_msm_state->prev_hpd_int_status == BIT(0)))) { - DEV_DBG("%s: cable event sent already!", __func__); - return; - } - - if (tvout_msm_state->hpd_int_status & BIT(2)) { - DEV_DBG("%s: cable plug-out\n", __func__); - mutex_lock(&external_common_state_hpd_mutex); - external_common_state->hpd_state = FALSE; - mutex_unlock(&external_common_state_hpd_mutex); - kobject_uevent(external_common_state->uevent_kobj, - KOBJ_OFFLINE); - tvout_msm_state->prev_hpd_int_status = BIT(2); - } else if (tvout_msm_state->hpd_int_status & BIT(0)) { - DEV_DBG("%s: cable plug-in\n", __func__); - mutex_lock(&external_common_state_hpd_mutex); - external_common_state->hpd_state = TRUE; - mutex_unlock(&external_common_state_hpd_mutex); - kobject_uevent(external_common_state->uevent_kobj, - KOBJ_ONLINE); - tvout_msm_state->prev_hpd_int_status = BIT(0); - } -} - -/* ISR for TV out cable detect */ -static irqreturn_t tvout_msm_isr(int irq, void *dev_id) -{ - tvout_msm_state->hpd_int_status = TV_IN(TV_INTR_STATUS); - TV_OUT(TV_INTR_CLEAR, tvout_msm_state->hpd_int_status); - DEV_DBG("%s: ISR: 0x%02x\n", __func__, - tvout_msm_state->hpd_int_status & 0x05); - - if (tvenc_pdata->poll) - if (!tvout_msm_state || !tvout_msm_state->disp_powered_up) { - DEV_DBG("%s: ISR ignored, display not yet powered on\n", - __func__); - return IRQ_HANDLED; - } - if (tvout_msm_state->hpd_int_status & BIT(0) || - tvout_msm_state->hpd_int_status & BIT(2)) { - /* Use .75sec to debounce the interrupt */ - mod_timer(&tvout_msm_state->hpd_state_timer, jiffies - + msecs_to_jiffies(750)); - } - - return IRQ_HANDLED; -} - -/* Interrupt debounce timer */ -static void tvout_msm_hpd_state_timer(unsigned long data) -{ -#ifdef CONFIG_SUSPEND - mutex_lock(&tvout_msm_state_mutex); - if (tvout_msm_state->pm_suspended) { - mutex_unlock(&tvout_msm_state_mutex); - DEV_WARN("%s: ignored, pm_suspended\n", __func__); - return; - } - mutex_unlock(&tvout_msm_state_mutex); -#endif - - if (tvenc_pdata->poll) - if (!tvout_msm_state || !tvout_msm_state->disp_powered_up) { - DEV_DBG("%s: ignored, display powered off\n", __func__); - return; - } - - /* TV_INTR_STATUS[0x204] - When a TV_ENC interrupt occurs, then reading this register will - indicate what caused the interrupt since that each bit indicates - the source of the interrupt that had happened. If multiple - interrupt sources had happened, then multiple bits of this - register will be set - Bit 0 : Load present on Video1 - Bit 1 : Load present on Video2 - Bit 2 : Load removed on Video1 - Bit 3 : Load removed on Video2 - */ - - /* Locking interrupt status is not required because - last status read after debouncing is used */ - if ((tvout_msm_state->hpd_int_status & 0x05) == 0x05) { - /* SW-workaround :If the status read after debouncing is - 0x05(indicating both load present & load removed- which can't - happen in reality), force an update. If status remains 0x05 - after retry, it's a cable unplug event */ - if (++tvout_msm_state->five_retry < 2) { - uint32 reg; - DEV_DBG("tvout: Timer: 0x05\n"); - TV_OUT(TV_INTR_CLEAR, 0xf); - reg = TV_IN(TV_DAC_INTF); - TV_OUT(TV_DAC_INTF, reg & ~TVENC_LOAD_DETECT_EN); - TV_OUT(TV_INTR_CLEAR, 0xf); - reg = TV_IN(TV_DAC_INTF); - TV_OUT(TV_DAC_INTF, reg | TVENC_LOAD_DETECT_EN); - return; - } - } - tvout_msm_state->five_retry = 0; - tvout_check_status(); -} - -static void tvout_msm_hpd_work(struct work_struct *work) -{ - uint32 reg; - -#ifdef CONFIG_SUSPEND - mutex_lock(&tvout_msm_state_mutex); - if (tvout_msm_state->pm_suspended) { - mutex_unlock(&tvout_msm_state_mutex); - DEV_WARN("%s: ignored, pm_suspended\n", __func__); - return; - } - mutex_unlock(&tvout_msm_state_mutex); -#endif - - /* Enable power lines & clocks */ - tvenc_pdata->pm_vid_en(1); - tvenc_set_clock(CLOCK_ON); - - /* Enable encoder to get a stable interrupt */ - reg = TV_IN(TV_ENC_CTL); - TV_OUT(TV_ENC_CTL, reg | TVENC_CTL_ENC_EN); - - /* SW- workaround to update status register */ - reg = TV_IN(TV_DAC_INTF); - TV_OUT(TV_DAC_INTF, reg & ~TVENC_LOAD_DETECT_EN); - TV_OUT(TV_INTR_CLEAR, 0xf); - reg = TV_IN(TV_DAC_INTF); - TV_OUT(TV_DAC_INTF, reg | TVENC_LOAD_DETECT_EN); - - tvout_msm_state->hpd_int_status = TV_IN(TV_INTR_STATUS); - - /* Disable TV encoder */ - reg = TV_IN(TV_ENC_CTL); - TV_OUT(TV_ENC_CTL, reg & ~TVENC_CTL_ENC_EN); - - /*Disable power lines & clocks */ - tvenc_set_clock(CLOCK_OFF); - tvenc_pdata->pm_vid_en(0); - - DEV_DBG("%s: ISR: 0x%02x\n", __func__, - tvout_msm_state->hpd_int_status & 0x05); - - mod_timer(&tvout_msm_state->hpd_work_timer, jiffies - + msecs_to_jiffies(TVOUT_HPD_DUTY_CYCLE)); - - tvout_check_status(); -} - -static void tvout_msm_hpd_work_timer(unsigned long data) -{ - schedule_work(&tvout_msm_state->hpd_work); -} - -static int tvout_on(struct platform_device *pdev) -{ - uint32 reg = 0; - struct fb_var_screeninfo *var; - struct msm_fb_data_type *mfd = platform_get_drvdata(pdev); - - if (!mfd) - return -ENODEV; - - if (mfd->key != MFD_KEY) - return -EINVAL; - -#ifdef CONFIG_SUSPEND - mutex_lock(&tvout_msm_state_mutex); - if (tvout_msm_state->pm_suspended) { - mutex_unlock(&tvout_msm_state_mutex); - DEV_WARN("%s: ignored, pm_suspended\n", __func__); - return -ENODEV; - } - mutex_unlock(&tvout_msm_state_mutex); -#endif - - var = &mfd->fbi->var; - if (var->reserved[3] >= NTSC_M && var->reserved[3] <= PAL_N) - external_common_state->video_resolution = var->reserved[3]; - - tvout_msm_state->pdev = pdev; - if (del_timer(&tvout_msm_state->hpd_work_timer)) - DEV_DBG("%s: work timer stopped\n", __func__); - - TV_OUT(TV_ENC_CTL, 0); /* disable TV encoder */ - - switch (external_common_state->video_resolution) { - case NTSC_M: - case NTSC_J: - TV_OUT(TV_CGMS, 0x0); - /* NTSC Timing */ - TV_OUT(TV_SYNC_1, 0x0020009e); - TV_OUT(TV_SYNC_2, 0x011306B4); - TV_OUT(TV_SYNC_3, 0x0006000C); - TV_OUT(TV_SYNC_4, 0x0028020D); - TV_OUT(TV_SYNC_5, 0x005E02FB); - TV_OUT(TV_SYNC_6, 0x0006000C); - TV_OUT(TV_SYNC_7, 0x00000012); - TV_OUT(TV_BURST_V1, 0x0013020D); - TV_OUT(TV_BURST_V2, 0x0014020C); - TV_OUT(TV_BURST_V3, 0x0013020D); - TV_OUT(TV_BURST_V4, 0x0014020C); - TV_OUT(TV_BURST_H, 0x00AE00F2); - TV_OUT(TV_SOL_REQ_ODD, 0x00280208); - TV_OUT(TV_SOL_REQ_EVEN, 0x00290209); - - reg |= TVENC_CTL_TV_MODE_NTSC_M_PAL60; - - if (external_common_state->video_resolution == NTSC_M) { - /* Cr gain 11, Cb gain C6, y_gain 97 */ - TV_OUT(TV_GAIN, 0x0081B697); - } else { - /* Cr gain 11, Cb gain C6, y_gain 97 */ - TV_OUT(TV_GAIN, 0x008bc4a3); - reg |= TVENC_CTL_NTSCJ_MODE; - } - - var->yres = 480; - break; - case PAL_BDGHIN: - case PAL_N: - /* PAL Timing */ - TV_OUT(TV_SYNC_1, 0x00180097); - TV_OUT(TV_SYNC_3, 0x0005000a); - TV_OUT(TV_SYNC_4, 0x00320271); - TV_OUT(TV_SYNC_5, 0x005602f9); - TV_OUT(TV_SYNC_6, 0x0005000a); - TV_OUT(TV_SYNC_7, 0x0000000f); - TV_OUT(TV_BURST_V1, 0x0012026e); - TV_OUT(TV_BURST_V2, 0x0011026d); - TV_OUT(TV_BURST_V3, 0x00100270); - TV_OUT(TV_BURST_V4, 0x0013026f); - TV_OUT(TV_SOL_REQ_ODD, 0x0030026e); - TV_OUT(TV_SOL_REQ_EVEN, 0x0031026f); - - if (external_common_state->video_resolution == PAL_BDGHIN) { - /* Cr gain 11, Cb gain C6, y_gain 97 */ - TV_OUT(TV_GAIN, 0x0088c1a0); - TV_OUT(TV_CGMS, 0x00012345); - TV_OUT(TV_SYNC_2, 0x011f06c0); - TV_OUT(TV_BURST_H, 0x00af00ea); - reg |= TVENC_CTL_TV_MODE_PAL_BDGHIN; - } else { - /* Cr gain 11, Cb gain C6, y_gain 97 */ - TV_OUT(TV_GAIN, 0x0081b697); - TV_OUT(TV_CGMS, 0x000af317); - TV_OUT(TV_SYNC_2, 0x12006c0); - TV_OUT(TV_BURST_H, 0x00af00fa); - reg |= TVENC_CTL_TV_MODE_PAL_N; - } - var->yres = 576; - break; - case PAL_M: - /* Cr gain 11, Cb gain C6, y_gain 97 */ - TV_OUT(TV_GAIN, 0x0081b697); - TV_OUT(TV_CGMS, 0x000af317); - TV_OUT(TV_TEST_MUX, 0x000001c3); - TV_OUT(TV_TEST_MODE, 0x00000002); - /* PAL Timing */ - TV_OUT(TV_SYNC_1, 0x0020009e); - TV_OUT(TV_SYNC_2, 0x011306b4); - TV_OUT(TV_SYNC_3, 0x0006000c); - TV_OUT(TV_SYNC_4, 0x0028020D); - TV_OUT(TV_SYNC_5, 0x005e02fb); - TV_OUT(TV_SYNC_6, 0x0006000c); - TV_OUT(TV_SYNC_7, 0x00000012); - TV_OUT(TV_BURST_V1, 0x0012020b); - TV_OUT(TV_BURST_V2, 0x0016020c); - TV_OUT(TV_BURST_V3, 0x00150209); - TV_OUT(TV_BURST_V4, 0x0013020c); - TV_OUT(TV_BURST_H, 0x00bf010b); - TV_OUT(TV_SOL_REQ_ODD, 0x00280208); - TV_OUT(TV_SOL_REQ_EVEN, 0x00290209); - - reg |= TVENC_CTL_TV_MODE_PAL_M; - var->yres = 480; - break; - default: - return -ENODEV; - } - - reg |= TVENC_CTL_Y_FILTER_EN | TVENC_CTL_CR_FILTER_EN | - TVENC_CTL_CB_FILTER_EN | TVENC_CTL_SINX_FILTER_EN; - - /* DC offset to 0. */ - TV_OUT(TV_LEVEL, 0x00000000); - TV_OUT(TV_OFFSET, 0x008080f0); - -#ifdef CONFIG_FB_MSM_TVOUT_SVIDEO - reg |= TVENC_CTL_S_VIDEO_EN; -#endif -#if defined(CONFIG_FB_MSM_MDP31) - TV_OUT(TV_DAC_INTF, 0x29); -#endif - TV_OUT(TV_ENC_CTL, reg); - - if (!tvout_msm_state->hpd_initialized) { - tvout_msm_state->hpd_initialized = TRUE; - /* Load detect enable */ - reg = TV_IN(TV_DAC_INTF); - reg |= TVENC_LOAD_DETECT_EN; - TV_OUT(TV_DAC_INTF, reg); - } - - tvout_msm_state->disp_powered_up = TRUE; - tvout_msm_turn_on(TRUE); - - if (tvenc_pdata->poll) { - /* Enable Load present & removal interrupts for Video1 */ - TV_OUT(TV_INTR_ENABLE, 0x5); - - /* Enable interrupts when display is on */ - enable_irq(tvout_msm_state->irq); - } - return 0; -} - -static int tvout_off(struct platform_device *pdev) -{ - /* Disable TV encoder irqs when display is off */ - if (tvenc_pdata->poll) - disable_irq(tvout_msm_state->irq); - tvout_msm_turn_on(FALSE); - tvout_msm_state->hpd_initialized = FALSE; - tvout_msm_state->disp_powered_up = FALSE; - if (tvenc_pdata->poll) { - mod_timer(&tvout_msm_state->hpd_work_timer, jiffies - + msecs_to_jiffies(TVOUT_HPD_DUTY_CYCLE)); - } - return 0; -} - -static int tvout_probe(struct platform_device *pdev) -{ - int rc = 0; - uint32 reg; - struct platform_device *fb_dev; - -#ifdef CONFIG_FB_MSM_TVOUT_NTSC_M - external_common_state->video_resolution = NTSC_M; -#elif defined CONFIG_FB_MSM_TVOUT_NTSC_J - external_common_state->video_resolution = NTSC_J; -#elif defined CONFIG_FB_MSM_TVOUT_PAL_M - external_common_state->video_resolution = PAL_M; -#elif defined CONFIG_FB_MSM_TVOUT_PAL_N - external_common_state->video_resolution = PAL_N; -#elif defined CONFIG_FB_MSM_TVOUT_PAL_BDGHIN - external_common_state->video_resolution = PAL_BDGHIN; -#endif - external_common_state->dev = &pdev->dev; - if (pdev->id == 0) { - struct resource *res; - - #define GET_RES(name, mode) do { \ - res = platform_get_resource_byname(pdev, mode, name); \ - if (!res) { \ - DEV_DBG("'" name "' resource not found\n"); \ - rc = -ENODEV; \ - goto error; \ - } \ - } while (0) - - #define GET_IRQ(var, name) do { \ - GET_RES(name, IORESOURCE_IRQ); \ - var = res->start; \ - } while (0) - - GET_IRQ(tvout_msm_state->irq, "tvout_device_irq"); - #undef GET_IRQ - #undef GET_RES - return 0; - } - - DEV_DBG("%s: tvout_msm_state->irq : %d", - __func__, tvout_msm_state->irq); - - rc = request_irq(tvout_msm_state->irq, &tvout_msm_isr, - IRQF_TRIGGER_HIGH, "tvout_msm_isr", NULL); - - if (rc) { - DEV_DBG("Init FAILED: IRQ request, rc=%d\n", rc); - goto error; - } - disable_irq(tvout_msm_state->irq); - - init_timer(&tvout_msm_state->hpd_state_timer); - tvout_msm_state->hpd_state_timer.function = - tvout_msm_hpd_state_timer; - tvout_msm_state->hpd_state_timer.data = (uint32)NULL; - tvout_msm_state->hpd_state_timer.expires = jiffies - + msecs_to_jiffies(1000); - - if (tvenc_pdata->poll) { - init_timer(&tvout_msm_state->hpd_work_timer); - tvout_msm_state->hpd_work_timer.function = - tvout_msm_hpd_work_timer; - tvout_msm_state->hpd_work_timer.data = (uint32)NULL; - tvout_msm_state->hpd_work_timer.expires = jiffies - + msecs_to_jiffies(1000); - } - fb_dev = msm_fb_add_device(pdev); - if (fb_dev) { - rc = external_common_state_create(fb_dev); - if (rc) { - DEV_ERR("Init FAILED: tvout_msm_state_create, rc=%d\n", - rc); - goto error; - } - if (tvenc_pdata->poll) { - /* Start polling timer to detect load */ - mod_timer(&tvout_msm_state->hpd_work_timer, jiffies - + msecs_to_jiffies(TVOUT_HPD_DUTY_CYCLE)); - } else { - /* Enable interrupt to detect load */ - tvenc_set_encoder_clock(CLOCK_ON); - reg = TV_IN(TV_DAC_INTF); - reg |= TVENC_LOAD_DETECT_EN; - TV_OUT(TV_DAC_INTF, reg); - TV_OUT(TV_INTR_ENABLE, 0x5); - enable_irq(tvout_msm_state->irq); - } - } else - DEV_ERR("Init FAILED: failed to add fb device\n"); -error: - return 0; -} - -static int tvout_remove(struct platform_device *pdev) -{ - external_common_state_remove(); - kfree(tvout_msm_state); - tvout_msm_state = NULL; - return 0; -} - -#ifdef CONFIG_SUSPEND -static int tvout_device_pm_suspend(struct device *dev) -{ - mutex_lock(&tvout_msm_state_mutex); - if (tvout_msm_state->pm_suspended) { - mutex_unlock(&tvout_msm_state_mutex); - return 0; - } - if (tvenc_pdata->poll) { - if (del_timer(&tvout_msm_state->hpd_work_timer)) - DEV_DBG("%s: suspending cable detect timer\n", - __func__); - } else { - disable_irq(tvout_msm_state->irq); - tvenc_set_encoder_clock(CLOCK_OFF); - } - tvout_msm_state->pm_suspended = TRUE; - mutex_unlock(&tvout_msm_state_mutex); - return 0; -} - -static int tvout_device_pm_resume(struct device *dev) -{ - mutex_lock(&tvout_msm_state_mutex); - if (!tvout_msm_state->pm_suspended) { - mutex_unlock(&tvout_msm_state_mutex); - return 0; - } - - if (tvenc_pdata->poll) { - tvout_msm_state->pm_suspended = FALSE; - mod_timer(&tvout_msm_state->hpd_work_timer, jiffies - + msecs_to_jiffies(TVOUT_HPD_DUTY_CYCLE)); - mutex_unlock(&tvout_msm_state_mutex); - DEV_DBG("%s: resuming cable detect timer\n", __func__); - } else { - tvenc_set_encoder_clock(CLOCK_ON); - tvout_msm_state->pm_suspended = FALSE; - mutex_unlock(&tvout_msm_state_mutex); - enable_irq(tvout_msm_state->irq); - DEV_DBG("%s: enable cable detect interrupt\n", __func__); - } - return 0; -} -#else -#define tvout_device_pm_suspend NULL -#define tvout_device_pm_resume NULL -#endif - - -static const struct dev_pm_ops tvout_device_pm_ops = { - .suspend = tvout_device_pm_suspend, - .resume = tvout_device_pm_resume, -}; - -static struct platform_driver this_driver = { - .probe = tvout_probe, - .remove = tvout_remove, - .driver = { - .name = "tvout_device", - .pm = &tvout_device_pm_ops, - }, -}; - -static struct msm_fb_panel_data tvout_panel_data = { - .panel_info.xres = TV_DIMENSION_MAX_WIDTH, - .panel_info.yres = TV_DIMENSION_MAX_HEIGHT, - .panel_info.type = TV_PANEL, - .panel_info.pdest = DISPLAY_2, - .panel_info.wait_cycle = 0, -#ifdef CONFIG_FB_MSM_MDP40 - .panel_info.bpp = 24, -#else - .panel_info.bpp = 16, -#endif - .panel_info.fb_num = 2, - .on = tvout_on, - .off = tvout_off, -}; - -static struct platform_device this_device = { - .name = "tvout_device", - .id = 1, - .dev = { - .platform_data = &tvout_panel_data, - } -}; - -static int __init tvout_init(void) -{ - int ret; - - if (msm_fb_detect_client("tvout_msm")) - return 0; - - tvout_msm_state = kzalloc(sizeof(*tvout_msm_state), GFP_KERNEL); - if (!tvout_msm_state) { - DEV_ERR("tvout_msm_init FAILED: out of memory\n"); - ret = -ENOMEM; - goto init_exit; - } - - external_common_state = &tvout_msm_state->common; - ret = platform_driver_register(&this_driver); - if (ret) { - DEV_ERR("tvout_device_init FAILED: platform_driver_register\ - rc=%d\n", ret); - goto init_exit; - } - - ret = platform_device_register(&this_device); - if (ret) { - DEV_ERR("tvout_device_init FAILED: platform_driver_register\ - rc=%d\n", ret); - platform_driver_unregister(&this_driver); - goto init_exit; - } - - INIT_WORK(&tvout_msm_state->hpd_work, tvout_msm_hpd_work); - return 0; - -init_exit: - kfree(tvout_msm_state); - tvout_msm_state = NULL; - return ret; -} - -static void __exit tvout_exit(void) -{ - platform_device_unregister(&this_device); - platform_driver_unregister(&this_driver); -} - -module_init(tvout_init); -module_exit(tvout_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("1.0"); -MODULE_AUTHOR("Qualcomm Innovation Center, Inc."); -MODULE_DESCRIPTION("TV out driver"); diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl.c deleted file mode 100644 index 582744c7c221fc91dc992edfa17fda0fb5f743c5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl.c +++ /dev/null @@ -1,735 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include "vcd_ddl.h" -#include "vcd_ddl_metadata.h" -#include "vcd_res_tracker_api.h" - -static unsigned int first_time; - -u32 ddl_device_init(struct ddl_init_config *ddl_init_config, - void *client_data) -{ - struct ddl_context *ddl_context; - u32 status = VCD_S_SUCCESS; - void *ptr = NULL; - DDL_MSG_HIGH("ddl_device_init"); - - if ((!ddl_init_config) || (!ddl_init_config->ddl_callback) || - (!ddl_init_config->core_virtual_base_addr)) { - DDL_MSG_ERROR("ddl_dev_init:Bad_argument"); - return VCD_ERR_ILLEGAL_PARM; - } - ddl_context = ddl_get_context(); - if (DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_dev_init:Multiple_init"); - return VCD_ERR_ILLEGAL_OP; - } - if (!DDL_IS_IDLE(ddl_context)) { - DDL_MSG_ERROR("ddl_dev_init:Ddl_busy"); - return VCD_ERR_BUSY; - } - memset(ddl_context, 0, sizeof(struct ddl_context)); - DDL_BUSY(ddl_context); - if (res_trk_get_enable_ion()) { - DDL_MSG_LOW("ddl_dev_init:ION framework enabled"); - ddl_context->video_ion_client = - res_trk_get_ion_client(); - if (!ddl_context->video_ion_client) { - DDL_MSG_ERROR("ION client create failed"); - return VCD_ERR_ILLEGAL_OP; - } - } - ddl_context->ddl_callback = ddl_init_config->ddl_callback; - if (ddl_init_config->interrupt_clr) - ddl_context->interrupt_clr = - ddl_init_config->interrupt_clr; - ddl_context->core_virtual_base_addr = - ddl_init_config->core_virtual_base_addr; - ddl_context->client_data = client_data; - ddl_context->ddl_hw_response.arg1 = DDL_INVALID_INTR_STATUS; - - ddl_context->frame_channel_depth = VCD_FRAME_COMMAND_DEPTH; - - DDL_MSG_LOW("%s() : virtual address of core(%x)\n", __func__, - (u32) ddl_init_config->core_virtual_base_addr); - vidc_1080p_set_device_base_addr( - ddl_context->core_virtual_base_addr); - ddl_context->cmd_state = DDL_CMD_INVALID; - ddl_client_transact(DDL_INIT_CLIENTS, NULL); - ddl_context->fw_memory_size = - DDL_FW_INST_GLOBAL_CONTEXT_SPACE_SIZE; - if (res_trk_get_firmware_addr(&ddl_context->dram_base_a)) { - DDL_MSG_ERROR("firmware allocation failed"); - ptr = NULL; - } else { - ptr = (void *)ddl_context->dram_base_a.virtual_base_addr; - } - if (!ptr) { - DDL_MSG_ERROR("Memory Aocation Failed for FW Base"); - status = VCD_ERR_ALLOC_FAIL; - } else { - DDL_MSG_LOW("%s() : physical address of base(%x)\n", - __func__, (u32) ddl_context->dram_base_a.\ - align_physical_addr); - ddl_context->dram_base_b.align_physical_addr = - ddl_context->dram_base_a.align_physical_addr; - ddl_context->dram_base_b.align_virtual_addr = - ddl_context->dram_base_a.align_virtual_addr; - } - if (!status) { - ddl_context->metadata_shared_input.mem_type = DDL_CMD_MEM; - ptr = ddl_pmem_alloc(&ddl_context->metadata_shared_input, - DDL_METADATA_TOTAL_INPUTBUFSIZE, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!ptr) { - DDL_MSG_ERROR("ddl_device_init: metadata alloc fail"); - status = VCD_ERR_ALLOC_FAIL; - } - } - if (!status && !ddl_fw_init(&ddl_context->dram_base_a)) { - DDL_MSG_ERROR("ddl_dev_init:fw_init_failed"); - status = VCD_ERR_ALLOC_FAIL; - } - if (!status) { - ddl_context->cmd_state = DDL_CMD_DMA_INIT; - ddl_vidc_core_init(ddl_context); - } else { - ddl_release_context_buffers(ddl_context); - DDL_IDLE(ddl_context); - } - return status; -} - -u32 ddl_device_release(void *client_data) -{ - struct ddl_context *ddl_context; - - DDL_MSG_HIGH("ddl_device_release"); - ddl_context = ddl_get_context(); - if (!DDL_IS_IDLE(ddl_context)) { - DDL_MSG_ERROR("ddl_dev_rel:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_dev_rel:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl_client_transact(DDL_ACTIVE_CLIENT, NULL)) { - DDL_MSG_ERROR("ddl_dev_rel:Client_present_err"); - return VCD_ERR_CLIENT_PRESENT; - } - DDL_BUSY(ddl_context); - ddl_context->device_state = DDL_DEVICE_NOTINIT; - ddl_context->client_data = client_data; - ddl_context->cmd_state = DDL_CMD_INVALID; - ddl_vidc_core_term(ddl_context); - DDL_MSG_LOW("FW_ENDDONE"); - ddl_context->core_virtual_base_addr = NULL; - ddl_release_context_buffers(ddl_context); - ddl_context->video_ion_client = NULL; - DDL_IDLE(ddl_context); - return VCD_S_SUCCESS; -} - -u32 ddl_open(u32 **ddl_handle, u32 decoding) -{ - struct ddl_context *ddl_context; - struct ddl_client_context *ddl; - void *ptr; - u32 status; - - DDL_MSG_HIGH("ddl_open"); - if (!ddl_handle) { - DDL_MSG_ERROR("ddl_open:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_open:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - status = ddl_client_transact(DDL_GET_CLIENT, &ddl); - if (status) { - DDL_MSG_ERROR("ddl_open:Client_trasac_failed"); - return status; - } - if (res_trk_check_for_sec_session()) - ddl->shared_mem[0].mem_type = DDL_CMD_MEM; - else - ddl->shared_mem[0].mem_type = DDL_FW_MEM; - ptr = ddl_pmem_alloc(&ddl->shared_mem[0], - DDL_FW_AUX_HOST_CMD_SPACE_SIZE, 0); - if (!ptr) - status = VCD_ERR_ALLOC_FAIL; - if (!status && ddl_context->frame_channel_depth - == VCD_DUAL_FRAME_COMMAND_CHANNEL) { - if (res_trk_check_for_sec_session()) - ddl->shared_mem[1].mem_type = DDL_CMD_MEM; - else - ddl->shared_mem[1].mem_type = DDL_FW_MEM; - ptr = ddl_pmem_alloc(&ddl->shared_mem[1], - DDL_FW_AUX_HOST_CMD_SPACE_SIZE, 0); - if (!ptr) { - ddl_pmem_free(&ddl->shared_mem[0]); - status = VCD_ERR_ALLOC_FAIL; - } - } - if (!status) { - memset(ddl->shared_mem[0].align_virtual_addr, 0, - DDL_FW_AUX_HOST_CMD_SPACE_SIZE); - if (ddl_context->frame_channel_depth == - VCD_DUAL_FRAME_COMMAND_CHANNEL) { - memset(ddl->shared_mem[1].align_virtual_addr, 0, - DDL_FW_AUX_HOST_CMD_SPACE_SIZE); - } - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_OPEN", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_OPEN; - ddl->codec_data.hdr.decoding = decoding; - ddl->decoding = decoding; - if (!res_trk_check_for_sec_session()) - ddl_set_default_meta_data_hdr(ddl); - ddl_set_initial_default_values(ddl); - *ddl_handle = (u32 *) ddl; - } else { - ddl_pmem_free(&ddl->shared_mem[0]); - if (ddl_context->frame_channel_depth - == VCD_DUAL_FRAME_COMMAND_CHANNEL) - ddl_pmem_free(&ddl->shared_mem[1]); - ddl_client_transact(DDL_FREE_CLIENT, &ddl); - } - return status; -} - -u32 ddl_close(u32 **ddl_handle) -{ - struct ddl_context *ddl_context; - struct ddl_client_context **pp_ddl = - (struct ddl_client_context **)ddl_handle; - - DDL_MSG_HIGH("ddl_close"); - if (!pp_ddl || !*pp_ddl) { - DDL_MSG_ERROR("ddl_close:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_close:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (!DDLCLIENT_STATE_IS(*pp_ddl, DDL_CLIENT_OPEN)) { - DDL_MSG_ERROR("ddl_close:Not_in_open_state"); - return VCD_ERR_ILLEGAL_OP; - } - ddl_pmem_free(&(*pp_ddl)->shared_mem[0]); - if (ddl_context->frame_channel_depth == - VCD_DUAL_FRAME_COMMAND_CHANNEL) - ddl_pmem_free(&(*pp_ddl)->shared_mem[1]); - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_INVALID", - ddl_get_state_string((*pp_ddl)->client_state)); - (*pp_ddl)->client_state = DDL_CLIENT_INVALID; - ddl_codec_type_transact(*pp_ddl, true, (enum vcd_codec)0); - ddl_client_transact(DDL_FREE_CLIENT, pp_ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_encode_start(u32 *ddl_handle, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - struct ddl_context *ddl_context; - struct ddl_encoder_data *encoder; - void *ptr; - u32 status = VCD_S_SUCCESS; - DDL_MSG_HIGH("ddl_encode_start"); - if (first_time < 2) { - ddl_reset_core_time_variables(ENC_OP_TIME); - first_time++; - } - ddl_set_core_start_time(__func__, ENC_OP_TIME); - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_start:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_start:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || ddl->decoding) { - DDL_MSG_ERROR("ddl_enc_start:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - DDL_MSG_ERROR("ddl_enc_start:Not_opened"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl_encoder_ready_to_start(ddl)) { - DDL_MSG_ERROR("ddl_enc_start:Err_param_settings"); - return VCD_ERR_ILLEGAL_OP; - } - encoder = &ddl->codec_data.encoder; - if (DDL_IS_LTR_ENABLED(encoder)) { - DDL_MSG_HIGH("LTR enabled, mode %u count %u", - (u32)encoder->ltr_control.ltrmode.ltr_mode, - (u32)encoder->ltr_control.ltr_count); - status = ddl_allocate_ltr_list(&encoder->ltr_control); - if (status) { - DDL_MSG_ERROR("%s: allocate ltr list failed", - __func__); - return status; - } else { - ddl_clear_ltr_list(&encoder->ltr_control, false); - } - encoder->num_references_for_p_frame = 2; - encoder->ltr_control.callback_reqd = false; - encoder->ltr_control.curr_ltr_id = (u32)DDL_LTR_FRAME_START_ID; - DDL_MSG_HIGH("num_ref_for_p_frames %u, curr_ltr_id = %u", - (u32)encoder->num_references_for_p_frame, - (u32)encoder->ltr_control.curr_ltr_id); - } - status = ddl_allocate_enc_hw_buffers(ddl); - if (status) - return status; -#ifdef DDL_BUF_LOG - ddl_list_buffers(ddl); -#endif - encoder->seq_header.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&encoder->seq_header, - DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!ptr) { - ddl_free_enc_hw_buffers(ddl); - DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - msm_ion_do_cache_op(ddl_context->video_ion_client, - encoder->seq_header.alloc_handle, - encoder->seq_header.virtual_base_addr, - encoder->seq_header.buffer_size, - ION_IOC_CLEAN_INV_CACHES); - if (encoder->slice_delivery_info.enable) { - DDL_MSG_LOW("%s: slice mode allocate memory for struct\n", - __func__); - ptr = ddl_pmem_alloc(&encoder->batch_frame.slice_batch_in, - DDL_ENC_SLICE_BATCH_INPSTRUCT_SIZE, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (ptr) { - ptr = ddl_pmem_alloc( - &encoder->batch_frame.slice_batch_out, - DDL_ENC_SLICE_BATCH_OUTSTRUCT_SIZE, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - } - if (!ptr) { - ddl_pmem_free(&encoder->batch_frame.slice_batch_in); - ddl_pmem_free(&encoder->batch_frame.slice_batch_out); - ddl_free_enc_hw_buffers(ddl); - ddl_pmem_free(&encoder->seq_header); - DDL_MSG_ERROR("ddlEncStart:SeqHdrAllocFailed"); - return VCD_ERR_ALLOC_FAIL; - } - } - if (!ddl_take_command_channel(ddl_context, ddl, client_data)) - return VCD_ERR_BUSY; - ddl_vidc_channel_set(ddl); - return status; -} - -u32 ddl_decode_start(u32 *ddl_handle, struct vcd_sequence_hdr *header, - void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - struct ddl_context *ddl_context; - struct ddl_decoder_data *decoder; - u32 status = VCD_S_SUCCESS; - - DDL_MSG_HIGH("ddl_decode_start"); - ddl_reset_core_time_variables(DEC_OP_TIME); - ddl_reset_core_time_variables(DEC_IP_TIME); - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_dec_start:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - DDL_MSG_ERROR("ddl_dec_start:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || !ddl->decoding) { - DDL_MSG_ERROR("ddl_dec_start:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - DDL_MSG_ERROR("ddl_dec_start:Not_in_opened_state"); - return VCD_ERR_ILLEGAL_OP; - } - - if ((header) && ((!header->sequence_header_len) || - (!header->sequence_header))) { - DDL_MSG_ERROR("ddl_dec_start:Bad_param_seq_header"); - return VCD_ERR_ILLEGAL_PARM; - } - if (!ddl_decoder_ready_to_start(ddl, header)) { - DDL_MSG_ERROR("ddl_dec_start:Err_param_settings"); - return VCD_ERR_ILLEGAL_OP; - } - decoder = &ddl->codec_data.decoder; - status = ddl_allocate_dec_hw_buffers(ddl); - if (status) - return status; -#ifdef DDL_BUF_LOG - ddl_list_buffers(ddl); -#endif - if (!ddl_take_command_channel(ddl_context, ddl, client_data)) - return VCD_ERR_BUSY; - if (header) { - decoder->header_in_start = true; - decoder->decode_config = *header; - } else { - decoder->header_in_start = false; - decoder->decode_config.sequence_header_len = 0; - } - ddl_vidc_channel_set(ddl); - return status; -} - -u32 ddl_decode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_bits, void *client_data) -{ - u32 vcd_status = VCD_S_SUCCESS; - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - struct ddl_context *ddl_context; - struct ddl_decoder_data *decoder; - DDL_MSG_MED("ddl_decode_frame"); - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_dec_frame:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - DDL_MSG_ERROR("ddl_dec_frame:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || !ddl->decoding) { - DDL_MSG_ERROR("ddl_dec_frame:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!input_bits || ((!input_bits->vcd_frm.physical || - !input_bits->vcd_frm.data_len) && - (!(VCD_FRAME_FLAG_EOS & input_bits->vcd_frm.flags)))) { - DDL_MSG_ERROR("ddl_dec_frame:Bad_input_param"); - return VCD_ERR_ILLEGAL_PARM; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { - DDL_MSG_ERROR("Dec_frame:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - decoder = &(ddl->codec_data.decoder); - if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && - !ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) { - DDL_MSG_ERROR("ddl_dec_frame:Dpbs_requied"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl_take_command_channel(ddl_context, ddl, client_data)) - return VCD_ERR_BUSY; - - ddl->input_frame = *input_bits; - if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) - ddl_vidc_decode_frame_run(ddl); - else { - if (!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) { - DDL_MSG_ERROR("ddl_dec_frame:Dpbs_requied"); - vcd_status = VCD_ERR_ILLEGAL_OP; - } else if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { - vcd_status = ddl_vidc_decode_set_buffers(ddl); - if (vcd_status) - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } else if (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_INITCODEC)) { - if (decoder->codec.codec == VCD_CODEC_DIVX_3) { - if ((!decoder->client_frame_size.width) || - (!decoder->client_frame_size.height)) - return VCD_ERR_ILLEGAL_OP; - } - ddl->codec_data.decoder.decode_config.sequence_header = - ddl->input_frame.vcd_frm.physical; - ddl->codec_data.decoder.decode_config.sequence_header_len = - ddl->input_frame.vcd_frm.data_len; - ddl_vidc_decode_init_codec(ddl); - } else { - DDL_MSG_ERROR("Dec_frame:Wrong_state"); - vcd_status = VCD_ERR_ILLEGAL_OP; - } - if (vcd_status) - DDL_IDLE(ddl_context); - } - return vcd_status; -} - -u32 ddl_encode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_frame, - struct ddl_frame_data_tag *output_bit, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - struct ddl_context *ddl_context; - struct ddl_encoder_data *encoder = - &ddl->codec_data.encoder; - u32 vcd_status = VCD_S_SUCCESS; - if (encoder->slice_delivery_info.enable) { - return ddl_encode_frame_batch(ddl_handle, - input_frame, - output_bit, - 1, - encoder->slice_delivery_info.num_slices, - client_data); - } - - ddl_set_core_start_time(__func__, ENC_OP_TIME); - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_frame:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_frame:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || ddl->decoding) { - DDL_MSG_ERROR("ddl_enc_frame:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!input_frame || !input_frame->vcd_frm.physical || - !input_frame->vcd_frm.data_len) { - DDL_MSG_ERROR("ddl_enc_frame:Bad_input_params"); - return VCD_ERR_ILLEGAL_PARM; - } - if ((((u32) input_frame->vcd_frm.physical + - input_frame->vcd_frm.offset) & - (DDL_STREAMBUF_ALIGN_GUARD_BYTES))) { - DDL_MSG_ERROR("ddl_enc_frame:Un_aligned_yuv_start_address"); - return VCD_ERR_ILLEGAL_PARM; - } - if (!output_bit || !output_bit->vcd_frm.physical || - !output_bit->vcd_frm.alloc_len) { - DDL_MSG_ERROR("ddl_enc_frame:Bad_output_params"); - return VCD_ERR_ILLEGAL_PARM; - } - if ((ddl->codec_data.encoder.output_buf_req.sz + - output_bit->vcd_frm.offset) > - output_bit->vcd_frm.alloc_len) - DDL_MSG_ERROR("ddl_enc_frame:offset_large," - "Exceeds_min_buf_size"); - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { - DDL_MSG_ERROR("ddl_enc_frame:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl_take_command_channel(ddl_context, ddl, client_data)) - return VCD_ERR_BUSY; - - ddl->input_frame = *input_frame; - ddl->output_frame = *output_bit; - if (ddl->codec_data.encoder.i_period.b_frames > 0) { - if (!ddl->b_count) { - ddl->first_output_frame = *output_bit; - ddl->b_count++; - } else if (ddl->codec_data.encoder.i_period.b_frames >= - ddl->b_count) { - ddl->extra_output_frame[ddl->b_count-1] = - *output_bit; - ddl->output_frame = ddl->first_output_frame; - ddl->b_count++; - } - } - ddl_insert_input_frame_to_pool(ddl, input_frame); - if (!vcd_status) - ddl_vidc_encode_frame_run(ddl); - else - DDL_MSG_ERROR("insert to frame pool failed %u", vcd_status); - return vcd_status; -} - -u32 ddl_encode_frame_batch(u32 *ddl_handle, - struct ddl_frame_data_tag *input_frame, - struct ddl_frame_data_tag *output_bit, - u32 num_in_frames, u32 num_out_frames, - void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - struct ddl_context *ddl_context; - u32 vcd_status = VCD_S_SUCCESS; - struct ddl_encoder_data *encoder; - - DDL_MSG_LOW("ddl_encode_frame_batch"); - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_frame:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_frame:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || ddl->decoding) { - DDL_MSG_ERROR("ddl_enc_frame:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!input_frame || !input_frame->vcd_frm.physical || - !input_frame->vcd_frm.data_len) { - DDL_MSG_ERROR("ddl_enc_frame:Bad_input_params"); - return VCD_ERR_ILLEGAL_PARM; - } - if ((((u32) input_frame->vcd_frm.physical + - input_frame->vcd_frm.offset) & - (DDL_STREAMBUF_ALIGN_GUARD_BYTES))) { - DDL_MSG_ERROR("ddl_enc_frame:Un_aligned_yuv_start_address"); - return VCD_ERR_ILLEGAL_PARM; - } - if (!output_bit || !output_bit->vcd_frm.physical || - !output_bit->vcd_frm.alloc_len) { - DDL_MSG_ERROR("ddl_enc_frame:Bad_output_params"); - return VCD_ERR_ILLEGAL_PARM; - } - if ((ddl->codec_data.encoder.output_buf_req.sz + - output_bit->vcd_frm.offset) > - output_bit->vcd_frm.alloc_len) - DDL_MSG_ERROR("ddl_enc_frame:offset_large," - "Exceeds_min_buf_size"); - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { - DDL_MSG_ERROR("ddl_enc_frame:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl_take_command_channel(ddl_context, ddl, client_data)) - return VCD_ERR_BUSY; - encoder = &ddl->codec_data.encoder; - if (encoder->slice_delivery_info.enable) { - DDL_MEMCPY((void *)&(encoder->batch_frame.output_frame[0]), - (void *)output_bit, - sizeof(struct ddl_frame_data_tag) * num_out_frames); - encoder->batch_frame.num_output_frames = num_out_frames; - ddl->input_frame = *input_frame; - vcd_status = ddl_insert_input_frame_to_pool(ddl, input_frame); - if (!vcd_status) - ddl_vidc_encode_slice_batch_run(ddl); - else - DDL_MSG_ERROR("insert to frame pool failed %u", - vcd_status); - } - return vcd_status; -} - -u32 ddl_decode_end(u32 *ddl_handle, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - struct ddl_context *ddl_context; - - DDL_MSG_HIGH("ddl_decode_end"); - ddl_reset_core_time_variables(DEC_OP_TIME); - ddl_reset_core_time_variables(DEC_IP_TIME); - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_dec_end:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - DDL_MSG_ERROR("ddl_dec_end:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || !ddl->decoding) { - DDL_MSG_ERROR("ddl_dec_end:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_FAVIDC_ERROR)) { - DDL_MSG_ERROR("ddl_dec_end:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl_take_command_channel(ddl_context, ddl, client_data)) - return VCD_ERR_BUSY; - ddl_vidc_channel_end(ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_encode_end(u32 *ddl_handle, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - struct ddl_context *ddl_context; - - DDL_MSG_HIGH("ddl_encode_end"); - ddl_reset_core_time_variables(ENC_OP_TIME); - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_end:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - DDL_MSG_ERROR("ddl_enc_end:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || ddl->decoding) { - DDL_MSG_ERROR("ddl_enc_end:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_FAVIDC_ERROR)) { - DDL_MSG_ERROR("ddl_enc_end:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl_take_command_channel(ddl_context, ddl, client_data)) - return VCD_ERR_BUSY; - ddl_vidc_channel_end(ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_reset_hw(u32 mode) -{ - struct ddl_context *ddl_context; - struct ddl_client_context *ddl; - u32 i; - - DDL_MSG_HIGH("ddl_reset_hw"); - DDL_MSG_LOW("ddl_reset_hw:called"); - ddl_context = ddl_get_context(); - ddl_context->cmd_state = DDL_CMD_INVALID; - DDL_BUSY(ddl_context); - if (ddl_context->core_virtual_base_addr) { - vidc_1080p_do_sw_reset(VIDC_1080P_RESET_IN_SEQ_FIRST_STAGE); - msleep(DDL_SW_RESET_SLEEP); - vidc_1080p_do_sw_reset(VIDC_1080P_RESET_IN_SEQ_SECOND_STAGE); - msleep(DDL_SW_RESET_SLEEP); - ddl_context->core_virtual_base_addr = NULL; - } - ddl_context->device_state = DDL_DEVICE_NOTINIT; - for (i = 0; i < VCD_MAX_NO_CLIENT; i++) { - ddl = ddl_context->ddl_clients[i]; - ddl_context->ddl_clients[i] = NULL; - if (ddl) { - ddl_release_client_internal_buffers(ddl); - ddl_client_transact(DDL_FREE_CLIENT, &ddl); - } - } - ddl_release_context_buffers(ddl_context); - memset(ddl_context, 0, sizeof(struct ddl_context)); - return true; -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl.h b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl.h deleted file mode 100644 index b6dc085b5281290c9d34aef3835482264d7f63c5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl.h +++ /dev/null @@ -1,586 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DDL_H_ -#define _VCD_DDL_H_ - -#include "vcd_ddl_api.h" -#include "vcd_ddl_core.h" -#include "vcd_ddl_utils.h" -#include "vidc.h" -#include "vidc_hwio.h" -#include "vidc_pix_cache.h" -#include "vidc.h" - -#define DDL_IDLE_STATE 0 -#define DDL_BUSY_STATE 1 -#define DDL_ERROR_STATE 2 -#define DDL_RUN_STATE 3 - -#define DDL_IS_BUSY(ddl_context) \ - ((ddl_context)->ddl_busy == DDL_BUSY_STATE) -#define DDL_IS_IDLE(ddl_context) \ - ((ddl_context)->ddl_busy == DDL_IDLE_STATE) -#define DDL_BUSY(ddl_context) \ - ((ddl_context)->ddl_busy = DDL_BUSY_STATE) -#define DDL_IDLE(ddl_context) \ - ((ddl_context)->ddl_busy = DDL_IDLE_STATE) -#define DDL_ERROR(ddl_context) \ - ((ddl_context)->ddl_busy = DDL_ERROR_STATE) -#define DDL_RUN(ddl_context) \ - ((ddl_context)->ddl_busy = DDL_RUN_STATE) - -#define DDL_DEVICE_NOTINIT 0 -#define DDL_DEVICE_INITED 1 -#define DDL_DEVICE_HWFATAL 2 - -#define DDL_IS_INITIALIZED(ddl_context) \ - (ddl_context->device_state == DDL_DEVICE_INITED) -#define DDLCOMMAND_STATE_IS(ddl_context, command_state) \ - (command_state == (ddl_context)->cmd_state) -#define DDLCLIENT_STATE_IS(ddl, state) \ - (state == (ddl)->client_state) - -#define DDL_IS_LTR_ENABLED(encoder) \ - ((encoder->ltr_control.ltrmode.ltr_mode == \ - VCD_LTR_MODE_AUTO || \ - encoder->ltr_control.ltrmode.ltr_mode == \ - VCD_LTR_MODE_MANUAL) && \ - (encoder->ltr_control.ltr_count > 0)) - -#define DDL_IS_LTR_IN_AUTO_MODE(encoder) \ - ((encoder->ltr_control.ltrmode.ltr_mode == \ - VCD_LTR_MODE_AUTO) && \ - (encoder->ltr_control.ltr_count > 0) && \ - (encoder->ltr_control.ltr_period > 0)) - -#define DDL_DPB_OP_INIT 1 -#define DDL_DPB_OP_MARK_FREE 2 -#define DDL_DPB_OP_MARK_BUSY 3 -#define DDL_DPB_OP_SET_MASK 4 -#define DDL_DPB_OP_RETRIEVE 5 - -#define DDL_INIT_CLIENTS 0 -#define DDL_GET_CLIENT 1 -#define DDL_FREE_CLIENT 2 -#define DDL_ACTIVE_CLIENT 3 - -#define DDL_INVALID_CHANNEL_ID ((u32)~0) -#define DDL_INVALID_CODEC_TYPE ((u32)~0) -#define DDL_INVALID_INTR_STATUS ((u32)~0) - -#define DDL_ENC_REQ_IFRAME 0x01 -#define DDL_ENC_CHANGE_IPERIOD 0x02 -#define DDL_ENC_CHANGE_BITRATE 0x04 -#define DDL_ENC_CHANGE_FRAMERATE 0x08 -#define DDL_ENC_CHANGE_CIR 0x10 -#define DDL_ENC_LTR_USE_FRAME 0x20 - -#define DDL_DEC_REQ_OUTPUT_FLUSH 0x1 - -#define DDL_MIN_NUM_OF_B_FRAME 0 -#define DDL_MAX_NUM_OF_B_FRAME 1 -#define DDL_DEFAULT_NUM_OF_B_FRAME DDL_MIN_NUM_OF_B_FRAME - -#define DDL_MIN_NUM_REF_FOR_P_FRAME 1 -#define DDL_MAX_NUM_REF_FOR_P_FRAME 2 - -#define DDL_MAX_NUM_IN_INPUTFRAME_POOL (DDL_MAX_NUM_OF_B_FRAME + 1) - -#define MDP_MIN_TILE_HEIGHT 96 - -#define DDL_MAX_NUM_LTR_FRAMES 2 -#define DDL_LTR_FRAME_START_ID 1 - -enum ddl_mem_area { - DDL_FW_MEM = 0x0, - DDL_MM_MEM = 0x1, - DDL_CMD_MEM = 0x2 -}; - -struct ddl_buf_addr{ - u8 *virtual_base_addr; - u8 *physical_base_addr; - u8 *align_physical_addr; - u8 *align_virtual_addr; - phys_addr_t alloced_phys_addr; - struct msm_mapped_buffer *mapped_buffer; - struct ion_handle *alloc_handle; - u32 buffer_size; - enum ddl_mem_area mem_type; - void *pil_cookie; -}; -enum ddl_cmd_state{ - DDL_CMD_INVALID = 0x0, - DDL_CMD_DMA_INIT = 0x1, - DDL_CMD_CPU_RESET = 0x2, - DDL_CMD_CHANNEL_SET = 0x3, - DDL_CMD_INIT_CODEC = 0x4, - DDL_CMD_HEADER_PARSE = 0x5, - DDL_CMD_DECODE_SET_DPB = 0x6, - DDL_CMD_DECODE_FRAME = 0x7, - DDL_CMD_ENCODE_FRAME = 0x8, - DDL_CMD_EOS = 0x9, - DDL_CMD_CHANNEL_END = 0xA, - DDL_CMD_ENCODE_CONTINUE = 0xB, - DDL_CMD_32BIT = 0x7FFFFFFF -}; -enum ddl_client_state{ - DDL_CLIENT_INVALID = 0x0, - DDL_CLIENT_OPEN = 0x1, - DDL_CLIENT_WAIT_FOR_CHDONE = 0x2, - DDL_CLIENT_WAIT_FOR_INITCODEC = 0x3, - DDL_CLIENT_WAIT_FOR_INITCODECDONE = 0x4, - DDL_CLIENT_WAIT_FOR_DPB = 0x5, - DDL_CLIENT_WAIT_FOR_DPBDONE = 0x6, - DDL_CLIENT_WAIT_FOR_FRAME = 0x7, - DDL_CLIENT_WAIT_FOR_FRAME_DONE = 0x8, - DDL_CLIENT_WAIT_FOR_EOS_DONE = 0x9, - DDL_CLIENT_WAIT_FOR_CHEND = 0xA, - DDL_CLIENT_FATAL_ERROR = 0xB, - DDL_CLIENT_FAVIDC_ERROR = 0xC, - DDL_CLIENT_WAIT_FOR_CONTINUE = 0xD, - DDL_CLIENT_32BIT = 0x7FFFFFFF -}; -struct ddl_hw_interface{ - u32 cmd; - u32 arg1; - u32 arg2; - u32 arg3; - u32 arg4; -}; -struct ddl_mask{ - u32 client_mask; - u32 hw_mask; -}; -struct ddl_yuv_buffer_size{ - u32 size_yuv; - u32 size_y; - u32 size_c; -}; -struct ddl_dec_buffer_size{ - u32 sz_dpb0; - u32 sz_dpb1; - u32 sz_mv; - u32 sz_vert_nb_mv; - u32 sz_nb_ip; - u32 sz_luma; - u32 sz_chroma; - u32 sz_nb_dcac; - u32 sz_upnb_mv; - u32 sz_sub_anchor_mv; - u32 sz_overlap_xform; - u32 sz_bit_plane3; - u32 sz_bit_plane2; - u32 sz_bit_plane1; - u32 sz_stx_parser; - u32 sz_desc; - u32 sz_cpb; - u32 sz_context; - u32 sz_extnuserdata; -}; -struct ddl_dec_buffers{ - struct ddl_buf_addr desc; - struct ddl_buf_addr nb_dcac; - struct ddl_buf_addr upnb_mv; - struct ddl_buf_addr sub_anchor_mv; - struct ddl_buf_addr overlay_xform; - struct ddl_buf_addr bit_plane3; - struct ddl_buf_addr bit_plane2; - struct ddl_buf_addr bit_plane1; - struct ddl_buf_addr stx_parser; - struct ddl_buf_addr h264_mv[DDL_MAX_BUFFER_COUNT]; - struct ddl_buf_addr h264_vert_nb_mv; - struct ddl_buf_addr h264_nb_ip; - struct ddl_buf_addr context; - struct ddl_buf_addr extnuserdata; - struct ddl_buf_addr meta_hdr[DDL_MAX_BUFFER_COUNT]; -}; -struct ddl_enc_buffer_size{ - u32 sz_cur_y; - u32 sz_cur_c; - u32 sz_dpb_y; - u32 sz_dpb_c; - u32 sz_strm; - u32 sz_mv; - u32 sz_col_zero; - u32 sz_md; - u32 sz_pred; - u32 sz_nbor_info; - u32 sz_acdc_coef; - u32 sz_mb_info; - u32 sz_context; -}; -struct ddl_enc_buffers{ - struct ddl_buf_addr dpb_y[4]; - struct ddl_buf_addr dpb_c[4]; - struct ddl_buf_addr mv; - struct ddl_buf_addr col_zero; - struct ddl_buf_addr md; - struct ddl_buf_addr pred; - struct ddl_buf_addr nbor_info; - struct ddl_buf_addr acdc_coef; - struct ddl_buf_addr mb_info; - struct ddl_buf_addr context; - u32 dpb_count; - u32 sz_dpb_y; - u32 sz_dpb_c; -}; -struct ddl_codec_data_hdr{ - u32 decoding; -}; -struct ddl_batch_frame_data { - struct ddl_buf_addr slice_batch_in; - struct ddl_buf_addr slice_batch_out; - struct ddl_frame_data_tag input_frame; - struct ddl_frame_data_tag output_frame - [DDL_MAX_NUM_BFRS_FOR_SLICE_BATCH]; - u32 num_output_frames; - u32 out_frm_next_frmindex; -}; -struct ddl_mp2_datadumpenabletype { - u32 userdatadump_enable; - u32 pictempscalable_extdump_enable; - u32 picspat_extdump_enable; - u32 picdisp_extdump_enable; - u32 copyright_extdump_enable; - u32 quantmatrix_extdump_enable; - u32 seqscalable_extdump_enable; - u32 seqdisp_extdump_enable; - u32 seq_extdump_enable; -}; - - -struct ddl_ltrlist { - bool ltr_in_use; - u32 ltr_id; -}; - -struct ddl_ltr_encoding_type { - struct vcd_property_ltrmode_type ltrmode; - struct vcd_property_ltruse_type failed_use_cmd; - struct ddl_ltrlist *ltr_list; - u32 ltr_count; - u32 ltr_period; - u32 ltr_use_frames; - u32 curr_ltr_id; - u32 storing_idx; - u32 out_frame_cnt_to_use_this_ltr; - u32 out_frame_cnt_before_next_idr; - bool storing; - bool callback_reqd; - bool meta_data_reqd; - bool using; - bool first_ltr_use_arvd; - bool use_ltr_reqd; - bool store_for_intraframe_insertion; - bool pending_chg_ltr_useframes; /* True if - * corresponding driver context of - * out_frame_cnt_to_use_this_ltr - * is pending to be changed with - * client settings - */ - bool store_ltr0; - bool store_ltr1; - bool use_ltr0; - bool use_ltr1; -}; - -struct ddl_encoder_data{ - struct ddl_codec_data_hdr hdr; - struct vcd_property_codec codec; - struct vcd_property_frame_size frame_size; - struct vcd_property_frame_rate frame_rate; - struct vcd_property_target_bitrate target_bit_rate; - struct vcd_property_profile profile; - struct vcd_property_level level; - struct vcd_property_rate_control rc; - struct vcd_property_multi_slice multi_slice; - struct ddl_buf_addr meta_data_input; - struct vcd_property_short_header short_header; - struct vcd_property_vop_timing vop_timing; - struct vcd_property_db_config db_control; - struct vcd_property_entropy_control entropy_control; - struct vcd_property_i_period i_period; - struct vcd_property_session_qp session_qp; - struct vcd_property_qp_range qp_range; - struct vcd_property_rc_level rc_level; - struct vcd_property_frame_level_rc_params frame_level_rc; - struct vcd_property_adaptive_rc_params adaptive_rc; - struct vcd_property_intra_refresh_mb_number intra_refresh; - struct vcd_property_buffer_format buf_format; - struct vcd_property_buffer_format recon_buf_format; - struct vcd_property_sps_pps_for_idr_enable sps_pps; - struct ddl_buf_addr seq_header; - struct vcd_buffer_requirement input_buf_req; - struct vcd_buffer_requirement output_buf_req; - struct vcd_buffer_requirement client_input_buf_req; - struct vcd_buffer_requirement client_output_buf_req; - struct ddl_enc_buffers hw_bufs; - struct ddl_yuv_buffer_size input_buf_size; - struct vidc_1080p_enc_frame_info enc_frame_info; - struct ddl_ltr_encoding_type ltr_control; - u32 plusptype_enable; - u32 meta_data_enable_flag; - u32 suffix; - u32 meta_data_offset; - u32 hdr_ext_control; - u32 r_cframe_skip; - u32 vb_vbuffer_size; - u32 dynamic_prop_change; - u32 dynmic_prop_change_req; - u32 seq_header_length; - u32 intra_frame_insertion; - u32 mb_info_enable; - u32 ext_enc_control_val; - u32 num_references_for_p_frame; - u32 closed_gop; - u32 num_slices_comp; - bool intra_period_changed; - struct vcd_property_slice_delivery_info slice_delivery_info; - struct ddl_batch_frame_data batch_frame; - u32 avc_delimiter_enable; - u32 vui_timinginfo_enable; -}; -struct ddl_decoder_data { - struct ddl_codec_data_hdr hdr; - struct vcd_property_codec codec; - struct vcd_property_buffer_format buf_format; - struct vcd_property_frame_size frame_size; - struct vcd_property_frame_size client_frame_size; - struct vcd_property_profile profile; - struct vcd_property_level level; - struct ddl_buf_addr meta_data_input; - struct vcd_property_post_filter post_filter; - struct vcd_sequence_hdr decode_config; - struct ddl_property_dec_pic_buffers dp_buf; - struct ddl_mask dpb_mask; - struct vcd_buffer_requirement actual_input_buf_req; - struct vcd_buffer_requirement min_input_buf_req; - struct vcd_buffer_requirement client_input_buf_req; - struct vcd_buffer_requirement actual_output_buf_req; - struct vcd_buffer_requirement min_output_buf_req; - struct vcd_buffer_requirement client_output_buf_req; - struct ddl_dec_buffers hw_bufs; - struct ddl_yuv_buffer_size dpb_buf_size; - struct vidc_1080p_dec_disp_info dec_disp_info; - u32 progressive_only; - u32 output_order; - u32 meta_data_enable_flag; - u32 suffix; - u32 meta_data_offset; - u32 header_in_start; - u32 min_dpb_num; - u32 y_cb_cr_size; - u32 yuv_size; - u32 dynamic_prop_change; - u32 dynmic_prop_change_req; - u32 flush_pending; - u32 meta_data_exists; - u32 idr_only_decoding; - u32 field_needed_for_prev_ip; - u32 prev_ip_frm_tag; - u32 cont_mode; - u32 reconfig_detected; - u32 dmx_disable; - int avg_dec_time; - int dec_time_sum; - struct ddl_mp2_datadumpenabletype mp2_datadump_enable; - u32 mp2_datadump_status; - u32 extn_user_data_enable; -}; -union ddl_codec_data{ - struct ddl_codec_data_hdr hdr; - struct ddl_decoder_data decoder; - struct ddl_encoder_data encoder; -}; -struct ddl_context{ - u8 *core_virtual_base_addr; - void *client_data; - u32 device_state; - u32 ddl_busy; - u32 cmd_err_status; - u32 disp_pic_err_status; - u32 pix_cache_enable; - u32 fw_version; - u32 fw_memory_size; - u32 cmd_seq_num; - u32 response_cmd_ch_id; - enum ddl_cmd_state cmd_state; - struct ddl_client_context *current_ddl[2]; - struct ddl_buf_addr metadata_shared_input; - struct ddl_client_context *ddl_clients[VCD_MAX_NO_CLIENT]; - struct ddl_buf_addr dram_base_a; - struct ddl_buf_addr dram_base_b; - struct ddl_hw_interface ddl_hw_response; - struct ion_client *video_ion_client; - void (*ddl_callback) (u32 event, u32 status, void *payload, - size_t sz, u32 *ddl_handle, void *const client_data); - void (*interrupt_clr) (void); - void (*vidc_decode_seq_start[2]) - (struct vidc_1080p_dec_seq_start_param *param); - void (*vidc_set_dec_resolution[2]) - (u32 width, u32 height); - void(*vidc_decode_init_buffers[2]) - (struct vidc_1080p_dec_init_buffers_param *param); - void(*vidc_decode_frame_start[2]) - (struct vidc_1080p_dec_frame_start_param *param); - void(*vidc_encode_seq_start[2]) - (struct vidc_1080p_enc_seq_start_param *param); - void(*vidc_encode_frame_start[2]) - (struct vidc_1080p_enc_frame_start_param *param); - void(*vidc_encode_slice_batch_start[2]) - (struct vidc_1080p_enc_frame_start_param *param); - u32 frame_channel_depth; -}; -struct ddl_client_context{ - struct ddl_context *ddl_context; - enum ddl_client_state client_state; - struct ddl_frame_data_tag first_output_frame; - struct ddl_frame_data_tag - extra_output_frame[DDL_MAX_NUM_OF_B_FRAME]; - struct ddl_frame_data_tag input_frame; - struct ddl_frame_data_tag output_frame; - struct ddl_frame_data_tag - input_frame_pool[DDL_MAX_NUM_IN_INPUTFRAME_POOL]; - union ddl_codec_data codec_data; - enum ddl_cmd_state cmd_state; - struct ddl_buf_addr shared_mem[2]; - void *client_data; - u32 decoding; - u32 channel_id; - u32 command_channel; - u32 b_count; - s32 extra_output_buf_count; - u32 instance_id; -}; - -struct ddl_context *ddl_get_context(void); -void ddl_vidc_core_init(struct ddl_context *); -void ddl_vidc_core_term(struct ddl_context *); -void ddl_vidc_channel_set(struct ddl_client_context *); -void ddl_vidc_channel_end(struct ddl_client_context *); -void ddl_vidc_encode_init_codec(struct ddl_client_context *); -void ddl_vidc_decode_init_codec(struct ddl_client_context *); -void ddl_vidc_encode_frame_continue(struct ddl_client_context *); -void ddl_vidc_encode_frame_run(struct ddl_client_context *); -void ddl_vidc_encode_slice_batch_run(struct ddl_client_context *); -void ddl_vidc_decode_frame_run(struct ddl_client_context *); -void ddl_vidc_decode_eos_run(struct ddl_client_context *ddl); -void ddl_vidc_encode_eos_run(struct ddl_client_context *ddl); -void ddl_release_context_buffers(struct ddl_context *); -void ddl_release_client_internal_buffers(struct ddl_client_context *ddl); -u32 ddl_vidc_decode_set_buffers(struct ddl_client_context *); -u32 ddl_decoder_dpb_transact(struct ddl_decoder_data *decoder, - struct ddl_frame_data_tag *in_out_frame, u32 operation); -u32 ddl_decoder_dpb_init(struct ddl_client_context *ddl); -u32 ddl_client_transact(u32 , struct ddl_client_context **); -u32 ddl_set_default_decoder_buffer_req(struct ddl_decoder_data *decoder, - u32 estimate); -void ddl_set_default_encoder_buffer_req(struct ddl_encoder_data - *encoder); -void ddl_set_default_dec_property(struct ddl_client_context *); -u32 ddl_encoder_ready_to_start(struct ddl_client_context *); -u32 ddl_decoder_ready_to_start(struct ddl_client_context *, - struct vcd_sequence_hdr *); -u32 ddl_get_yuv_buffer_size(struct vcd_property_frame_size *frame_size, - struct vcd_property_buffer_format *buf_format, u32 interlace, - u32 decoding, u32 *pn_c_offset); -void ddl_calculate_stride(struct vcd_property_frame_size *frame_size, - u32 interlace); -u32 ddl_codec_type_transact(struct ddl_client_context *ddl, - u32 remove, enum vcd_codec requested_codec); -void ddl_vidc_encode_dynamic_property(struct ddl_client_context *ddl, - u32 enable); -void ddl_vidc_decode_dynamic_property(struct ddl_client_context *ddl, - u32 enable); -void ddl_set_initial_default_values(struct ddl_client_context *ddl); - -u32 ddl_take_command_channel(struct ddl_context *ddl_context, - struct ddl_client_context *ddl, void *client_data); -void ddl_release_command_channel(struct ddl_context *ddl_context, - u32 command_channel); -struct ddl_client_context *ddl_get_current_ddl_client_for_channel_id( - struct ddl_context *ddl_context, u32 channel_id); -struct ddl_client_context *ddl_get_current_ddl_client_for_command( - struct ddl_context *ddl_context, - enum ddl_cmd_state cmd_state); - -u32 ddl_get_yuv_buf_size(u32 width, u32 height, u32 format); -void ddl_free_dec_hw_buffers(struct ddl_client_context *ddl); -void ddl_free_enc_hw_buffers(struct ddl_client_context *ddl); -void ddl_calc_dec_hw_buffers_size(enum vcd_codec codec, u32 width, - u32 height, u32 h264_dpb, - struct ddl_dec_buffer_size *buf_size); -u32 ddl_allocate_dec_hw_buffers(struct ddl_client_context *ddl); -u32 ddl_calc_enc_hw_buffers_size(enum vcd_codec codec, u32 width, - u32 height, enum vcd_yuv_buffer_format input_format, - struct ddl_client_context *ddl, - struct ddl_enc_buffer_size *buf_size); -u32 ddl_allocate_enc_hw_buffers(struct ddl_client_context *ddl); - -u32 ddl_handle_core_errors(struct ddl_context *ddl_context); -void ddl_client_fatal_cb(struct ddl_client_context *ddl); -void ddl_hw_fatal_cb(struct ddl_client_context *ddl); - -void *ddl_pmem_alloc(struct ddl_buf_addr *addr, size_t sz, u32 alignment); -void ddl_pmem_free(struct ddl_buf_addr *addr); - -u32 ddl_get_input_frame_from_pool(struct ddl_client_context *ddl, - u8 *input_buffer_address); -u32 ddl_get_stream_buf_from_batch_pool(struct ddl_client_context *ddl, - struct ddl_frame_data_tag *stream_buffer); -u32 ddl_insert_input_frame_to_pool(struct ddl_client_context *ddl, - struct ddl_frame_data_tag *ddl_input_frame); -void ddl_decoder_chroma_dpb_change(struct ddl_client_context *ddl); -u32 ddl_check_reconfig(struct ddl_client_context *ddl); -void ddl_handle_reconfig(u32 res_change, struct ddl_client_context *ddl); -void ddl_fill_dec_desc_buffer(struct ddl_client_context *ddl); -void ddl_set_vidc_timeout(struct ddl_client_context *ddl); - - -#ifdef DDL_BUF_LOG -void ddl_list_buffers(struct ddl_client_context *ddl); -#endif -#if DDL_MSG_LOG -s8 *ddl_get_state_string(enum ddl_client_state client_state); -#endif -extern unsigned char *vidc_video_codec_fw; -extern u32 vidc_video_codec_fw_size; - -u32 ddl_fw_init(struct ddl_buf_addr *dram_base); -void ddl_get_fw_info(const unsigned char **fw_array_addr, - unsigned int *fw_size); -void ddl_fw_release(struct ddl_buf_addr *); -int ddl_vidc_decode_get_avg_time(struct ddl_client_context *ddl); -void ddl_vidc_decode_reset_avg_time(struct ddl_client_context *ddl); -void ddl_calc_core_proc_time(const char *func_name, u32 index, - struct ddl_client_context *ddl); -s32 ddl_encoder_ltr_control(struct ddl_client_context *ddl); -void ddl_encoder_use_ltr_fail_callback( - struct ddl_client_context *ddl); -void ddl_handle_ltr_in_framedone(struct ddl_client_context *ddl); -s32 ddl_clear_ltr_list(struct ddl_ltr_encoding_type *ltr_control, - bool only_use_flag); -s32 ddl_find_oldest_ltr_not_in_use( - struct ddl_ltr_encoding_type *ltr_control); -s32 ddl_find_ltr_in_use(struct ddl_ltr_encoding_type *ltr_control); -s32 ddl_find_ltr_from_list(struct ddl_ltr_encoding_type *ltr_control, - u32 ltr_id); -s32 ddl_use_ltr_from_list(struct ddl_ltr_encoding_type *ltr_control, - u32 ltr_idx); -s32 ddl_allocate_ltr_list(struct ddl_ltr_encoding_type *ltr_control); -s32 ddl_free_ltr_list(struct ddl_ltr_encoding_type *ltr_control); -void ddl_print_ltr_list(struct ddl_ltr_encoding_type *ltr_control); - -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_api.h b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_api.h deleted file mode 100644 index 3a7e443eb769e1fe78724f9b4b3d564da851ac40..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_api.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DDL_API_H_ -#define _VCD_DDL_API_H_ - -#include -#include "vidc.h" - -#define VCD_EVT_RESP_DDL_BASE 0x3000 -#define VCD_EVT_RESP_DEVICE_INIT (VCD_EVT_RESP_DDL_BASE + 0x1) -#define VCD_EVT_RESP_OUTPUT_REQ (VCD_EVT_RESP_DDL_BASE + 0x2) -#define VCD_EVT_RESP_EOS_DONE (VCD_EVT_RESP_DDL_BASE + 0x3) -#define VCD_EVT_RESP_TRANSACTION_PENDING (VCD_EVT_RESP_DDL_BASE + 0x4) - -#define VCD_S_DDL_ERR_BASE 0x90000000 -#define VCD_ERR_MAX_NO_CODEC (VCD_S_DDL_ERR_BASE + 0x1) -#define VCD_ERR_CLIENT_PRESENT (VCD_S_DDL_ERR_BASE + 0x2) -#define VCD_ERR_CLIENT_FATAL (VCD_S_DDL_ERR_BASE + 0x3) -#define VCD_ERR_NO_SEQ_HDR (VCD_S_DDL_ERR_BASE + 0x4) - -#define VCD_I_CUSTOM_BASE (VCD_I_RESERVED_BASE) -#define VCD_I_RC_LEVEL_CONFIG (VCD_I_CUSTOM_BASE + 0x1) -#define VCD_I_FRAME_LEVEL_RC (VCD_I_CUSTOM_BASE + 0x2) -#define VCD_I_ADAPTIVE_RC (VCD_I_CUSTOM_BASE + 0x3) -#define VCD_I_CUSTOM_DDL_BASE (VCD_I_RESERVED_BASE + 0x100) -#define DDL_I_INPUT_BUF_REQ (VCD_I_CUSTOM_DDL_BASE + 0x1) -#define DDL_I_OUTPUT_BUF_REQ (VCD_I_CUSTOM_DDL_BASE + 0x2) -#define DDL_I_DPB (VCD_I_CUSTOM_DDL_BASE + 0x3) -#define DDL_I_DPB_RELEASE (VCD_I_CUSTOM_DDL_BASE + 0x4) -#define DDL_I_DPB_RETRIEVE (VCD_I_CUSTOM_DDL_BASE + 0x5) -#define DDL_I_REQ_OUTPUT_FLUSH (VCD_I_CUSTOM_DDL_BASE + 0x6) -#define DDL_I_SEQHDR_ALIGN_BYTES (VCD_I_CUSTOM_DDL_BASE + 0x7) -#define DDL_I_CAPABILITY (VCD_I_CUSTOM_DDL_BASE + 0x8) -#define DDL_I_FRAME_PROC_UNITS (VCD_I_CUSTOM_DDL_BASE + 0x9) -#define DDL_I_SEQHDR_PRESENT (VCD_I_CUSTOM_DDL_BASE + 0xA) - -#define DDL_FRAME_VGA_SIZE (640*480) -#define DDL_FRAME_720P_WIDTH 1280 -#define DDL_FRAME_720P_HEIGHT 720 - -struct vcd_property_rc_level{ - u32 frame_level_rc; - u32 mb_level_rc; -}; -struct vcd_property_frame_level_rc_params{ - u32 reaction_coeff; -}; -struct vcd_property_adaptive_rc_params{ - u32 disable_dark_region_as_flag; - u32 disable_smooth_region_as_flag; - u32 disable_static_region_as_flag; - u32 disable_activity_region_flag; -}; -struct vcd_property_slice_delivery_info { - u32 enable; - u32 num_slices; - u32 num_slices_enc; -}; -struct ddl_property_dec_pic_buffers{ - struct ddl_frame_data_tag *dec_pic_buffers; - u32 no_of_dec_pic_buf; -}; -struct ddl_property_capability{ - u32 max_num_client; - u32 general_command_depth; - u32 exclusive; - u32 frame_command_depth; - u32 ddl_time_out_in_ms; -}; -struct ddl_init_config{ - int memtype; - u8 *core_virtual_base_addr; - void (*interrupt_clr) (void); - void (*ddl_callback) (u32 event, u32 status, void *payload, size_t sz, - u32 *ddl_handle, void *const client_data); -}; -struct ddl_frame_data_tag{ - struct vcd_frame_data vcd_frm; - u32 frm_trans_end; - u32 frm_delta; -}; -u32 ddl_device_init(struct ddl_init_config *ddl_init_config, - void *client_data); -u32 ddl_device_release(void *client_data); -u32 ddl_open(u32 **ddl_handle, u32 decoding); -u32 ddl_close(u32 **ddl_handle); -u32 ddl_encode_start(u32 *ddl_handle, void *client_data); -u32 ddl_encode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_frame, - struct ddl_frame_data_tag *output_bit, void *client_data); -u32 ddl_encode_frame_batch(u32 *ddl_handle, - struct ddl_frame_data_tag *input_frame, - struct ddl_frame_data_tag *output_bit, - u32 num_in_frames, u32 num_out_frames, - void *client_data); -u32 ddl_encode_end(u32 *ddl_handle, void *client_data); -u32 ddl_decode_start(u32 *ddl_handle, struct vcd_sequence_hdr *header, - void *client_data); -u32 ddl_decode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_bits, void *client_data); -u32 ddl_decode_end(u32 *ddl_handle, void *client_data); -u32 ddl_set_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value); -u32 ddl_get_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value); -u32 ddl_process_core_response(void); -u32 ddl_reset_hw(u32 mode); -void ddl_read_and_clear_interrupt(void); -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_core.h b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_core.h deleted file mode 100644 index 176699e7a8df05c626e3bac2ed5db65b5a2cc2fc..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_core.h +++ /dev/null @@ -1,163 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DDL_CORE_H_ -#define _VCD_DDL_CORE_H_ - -#define DDL_LINEAR_BUF_ALIGN_MASK 0xFFFFF800U -#define DDL_LINEAR_BUF_ALIGN_GUARD_BYTES 0x7FF -#define DDL_LINEAR_BUFFER_ALIGN_BYTES 2048 -#define DDL_TILE_BUF_ALIGN_MASK 0xFFFFE000U -#define DDL_TILE_BUF_ALIGN_GUARD_BYTES 0x1FFF -#define DDL_TILE_BUFFER_ALIGN_BYTES 8192 - -#define DDL_YUV_BUF_TYPE_LINEAR 0 -#define DDL_YUV_BUF_TYPE_TILE 1 - -#define DDL_NO_OF_MB(nWidth, nHeight) \ - ((((nWidth) + 15) >> 4) * (((nHeight) + 15) >> 4)) - -#define DDL_MAX_FRAME_WIDTH 1920 -#define DDL_MAX_FRAME_HEIGHT 1088 - -#define DDL_MAX_VC1_FRAME_WIDTH (DDL_MAX_FRAME_WIDTH) -#define DDL_MAX_VC1_FRAME_HEIGHT (1280) - -#define MAX_DPB_SIZE_L4PT0_MBS DDL_KILO_BYTE(32) -#define MAX_FRAME_SIZE_L4PT0_MBS DDL_KILO_BYTE(8) - -#define DDL_MAX_MB_PER_FRAME (DDL_NO_OF_MB(DDL_MAX_FRAME_WIDTH,\ - DDL_MAX_FRAME_HEIGHT)) - -#define DDL_DB_LINE_BUF_SIZE\ - (((((DDL_MAX_FRAME_WIDTH * 4) - 1) / 256) + 1) * 8 * 1024) - -#define DDL_MAX_FRAME_RATE 120 -#define DDL_INITIAL_FRAME_RATE 30 - -#define DDL_MAX_BIT_RATE (20*1024*1024) -#define DDL_MAX_MB_PER_SEC (DDL_MAX_MB_PER_FRAME * DDL_INITIAL_FRAME_RATE) - -#define DDL_SW_RESET_SLEEP 1 -#define VCD_MAX_NO_CLIENT 4 -#define VCD_SINGLE_FRAME_COMMAND_CHANNEL 1 -#define VCD_DUAL_FRAME_COMMAND_CHANNEL 2 -#define VCD_FRAME_COMMAND_DEPTH VCD_SINGLE_FRAME_COMMAND_CHANNEL -#define VCD_GENEVIDC_COMMAND_DEPTH 1 -#define VCD_COMMAND_EXCLUSIVE true -#define DDL_HW_TIMEOUT_IN_MS 1000 -#define DDL_STREAMBUF_ALIGN_GUARD_BYTES 0x7FF - -#define DDL_VIDC_1080P_48MHZ (48000000) -#define DDL_VIDC_1080P_133MHZ (133330000) -#define DDL_VIDC_1080P_200MHZ (200000000) -#define DDL_VIDC_1080P_48MHZ_TIMEOUT_VALUE (0xCB8) -#define DDL_VIDC_1080P_133MHZ_TIMEOUT_VALUE (0x2355) -#define DDL_VIDC_1080P_200MHZ_TIMEOUT_VALUE (0x3500) -#define DDL_VIDC_1080P_MAX_TIMEOUT_MULTIPLIER (4) - -#define DDL_CONTEXT_MEMORY (1024 * 15 * (VCD_MAX_NO_CLIENT + 1)) - -#define DDL_ENC_MIN_DPB_BUFFERS 2 -#define DDL_ENC_MAX_DPB_BUFFERS 4 - -#define DDL_FW_AUX_HOST_CMD_SPACE_SIZE (DDL_KILO_BYTE(4)) -#define DDL_FW_INST_GLOBAL_CONTEXT_SPACE_SIZE (DDL_KILO_BYTE(800)) -#define DDL_FW_H264DEC_CONTEXT_SPACE_SIZE (DDL_KILO_BYTE(800)) -#define DDL_FW_H264ENC_CONTEXT_SPACE_SIZE (DDL_KILO_BYTE(20)) -#define DDL_FW_OTHER_CONTEXT_SPACE_SIZE (DDL_KILO_BYTE(20)) - -#define VCD_DEC_CPB_SIZE (DDL_KILO_BYTE(512)) -#define DDL_DBG_CORE_DUMP_SIZE (DDL_KILO_BYTE(10)) -#define DDL_VIDC_1080P_BASE_OFFSET_SHIFT 11 - -#define DDL_BUFEND_PAD 256 -#define DDL_ENC_SEQHEADER_SIZE (512+DDL_BUFEND_PAD) -#define DDL_ENC_SLICE_BATCH_FACTOR 5 -#define DDL_MAX_NUM_BFRS_FOR_SLICE_BATCH 8 -#define DDL_ENC_SLICE_BATCH_INPSTRUCT_SIZE (128 + \ - 32 * DDL_MAX_NUM_BFRS_FOR_SLICE_BATCH) -#define DDL_ENC_SLICE_BATCH_OUTSTRUCT_SIZE (64 + \ - 64 * DDL_MAX_NUM_BFRS_FOR_SLICE_BATCH) -#define DDL_MAX_BUFFER_COUNT 32 -#define DDL_MIN_BUFFER_COUNT 1 - -#define DDL_MPEG_REFBUF_COUNT 2 -#define DDL_MPEG_COMV_BUF_NO 2 -#define DDL_H263_COMV_BUF_NO 0 -#define DDL_COMV_BUFLINE_NO 128 -#define DDL_VC1_COMV_BUFLINE_NO 32 - -#define DDL_MAX_H264_QP 51 -#define DDL_MAX_MPEG4_QP 31 - -#define DDL_CONCEALMENT_Y_COLOR 16 -#define DDL_CONCEALMENT_C_COLOR 128 - -#define DDL_ALLOW_DEC_FRAMESIZE(width, height) \ - ((DDL_NO_OF_MB(width, height) <= \ - MAX_FRAME_SIZE_L4PT0_MBS) && \ - (width <= DDL_MAX_FRAME_WIDTH) && \ - (height <= DDL_MAX_FRAME_WIDTH) && \ - ((width >= 32 && height >= 16) || \ - (width >= 16 && height >= 32))) - -#define DDL_ALLOW_ENC_FRAMESIZE(width, height) \ - ((DDL_NO_OF_MB(width, height) <= \ - MAX_FRAME_SIZE_L4PT0_MBS) && \ - (width <= DDL_MAX_FRAME_WIDTH) && \ - (height <= DDL_MAX_FRAME_WIDTH) && \ - ((width >= 32 && height >= 32))) - -#define DDL_LINEAR_ALIGN_WIDTH 16 -#define DDL_LINEAR_ALIGN_HEIGHT 16 -#define DDL_LINEAR_MULTIPLY_FACTOR 2048 -#define DDL_TILE_ALIGN_WIDTH 128 -#define DDL_TILE_ALIGN_HEIGHT 32 -#define DDL_TILE_MULTIPLY_FACTOR 8192 -#define DDL_TILE_ALIGN(val, grid) \ - (((val) + (grid) - 1) / (grid) * (grid)) - -#define VCD_DDL_720P_YUV_BUF_SIZE ((1280*720*3) >> 1) -#define VCD_DDL_WVGA_BUF_SIZE (800*480) - -#define VCD_DDL_TEST_MAX_WIDTH (DDL_MAX_FRAME_WIDTH) -#define VCD_DDL_TEST_MAX_HEIGHT (DDL_MAX_FRAME_HEIGHT) - -#define VCD_DDL_TEST_MAX_NUM_H264_DPB 8 - -#define VCD_DDL_TEST_NUM_ENC_INPUT_BUFS 6 -#define VCD_DDL_TEST_NUM_ENC_OUTPUT_BUFS 4 - -#define VCD_DDL_TEST_DEFAULT_WIDTH 176 -#define VCD_DDL_TEST_DEFAULT_HEIGHT 144 - -#define DDL_PIXEL_CACHE_NOT_IDLE 0x4000 -#define DDL_PIXEL_CACHE_STATUS_READ_RETRY 10 -#define DDL_PIXEL_CACHE_STATUS_READ_SLEEP 200 - -#define DDL_RESL_CHANGE_NO_CHANGE 0 -#define DDL_RESL_CHANGE_INCREASED 1 -#define DDL_RESL_CHANGE_DECREASED 2 - -#define VIDC_SM_ERR_CONCEALMENT_ENABLE 1 -#define VIDC_SM_ERR_CONCEALMENT_INTER_SLICE_MB_COPY 2 -#define VIDC_SM_ERR_CONCEALMENT_INTRA_SLICE_COLOR_CONCEALMENT 1 - -#define DDL_MAX_P_FRAMES_IN_INTRA_INTERVAL 0xffff - -#define DDL_SATURATE_P_FRAMES_IN_INTRA_INTERVAL(p_rames) \ - (((p_rames) > (DDL_MAX_P_FRAMES_IN_INTRA_INTERVAL - 1)) ? \ - (DDL_MAX_P_FRAMES_IN_INTRA_INTERVAL) : (p_rames)) - -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_errors.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_errors.c deleted file mode 100644 index daafe44baec928c7f4a7fd97ddf3de8aac2f677d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_errors.c +++ /dev/null @@ -1,774 +0,0 @@ -/* Copyright (c) 2010-2012, 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 "vcd_ddl.h" -#include "vcd_ddl_shared_mem.h" -#include "vidc.h" - -static u32 ddl_handle_hw_fatal_errors(struct ddl_client_context *ddl); -static u32 ddl_handle_client_fatal_errors( - struct ddl_client_context *ddl); -static void ddl_input_failed_cb(struct ddl_client_context *ddl, - u32 vcd_event, u32 vcd_status); -static u32 ddl_handle_core_recoverable_errors( - struct ddl_client_context *ddl); -static u32 ddl_handle_core_warnings(u32 error_code); -static void ddl_release_prev_field( - struct ddl_client_context *ddl); -static u32 ddl_handle_dec_seq_hdr_fail_error(struct ddl_client_context *ddl); -static void print_core_errors(u32 error_code); -static void print_core_recoverable_errors(u32 error_code); - -void ddl_hw_fatal_cb(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - u32 error_code = ddl_context->cmd_err_status; - - DDL_MSG_FATAL("VIDC_HW_FATAL"); - ddl->cmd_state = DDL_CMD_INVALID; - ddl_context->device_state = DDL_DEVICE_HWFATAL; - - ddl_context->ddl_callback(VCD_EVT_IND_HWERRFATAL, VCD_ERR_HW_FATAL, - &error_code, sizeof(error_code), - (u32 *)ddl, ddl->client_data); - - ddl_release_command_channel(ddl_context, ddl->command_channel); -} - -static u32 ddl_handle_hw_fatal_errors(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - u32 status = false, error_code = ddl_context->cmd_err_status; - - switch (error_code) { - case VIDC_1080P_ERROR_INVALID_CHANNEL_NUMBER: - case VIDC_1080P_ERROR_INVALID_COMMAND_ID: - case VIDC_1080P_ERROR_CHANNEL_ALREADY_IN_USE: - case VIDC_1080P_ERROR_CHANNEL_NOT_OPEN_BEFORE_CHANNEL_CLOSE: - case VIDC_1080P_ERROR_OPEN_CH_ERROR_SEQ_START: - case VIDC_1080P_ERROR_SEQ_START_ALREADY_CALLED: - case VIDC_1080P_ERROR_OPEN_CH_ERROR_INIT_BUFFERS: - case VIDC_1080P_ERROR_SEQ_START_ERROR_INIT_BUFFERS: - case VIDC_1080P_ERROR_INIT_BUFFER_ALREADY_CALLED: - case VIDC_1080P_ERROR_OPEN_CH_ERROR_FRAME_START: - case VIDC_1080P_ERROR_SEQ_START_ERROR_FRAME_START: - case VIDC_1080P_ERROR_INIT_BUFFERS_ERROR_FRAME_START: - case VIDC_1080P_ERROR_RESOLUTION_CHANGED: - case VIDC_1080P_ERROR_INVALID_COMMAND_LAST_FRAME: - case VIDC_1080P_ERROR_INVALID_COMMAND: - case VIDC_1080P_ERROR_INVALID_CODEC_TYPE: - case VIDC_1080P_ERROR_MEM_ALLOCATION_FAILED: - case VIDC_1080P_ERROR_INSUFFICIENT_CONTEXT_SIZE: - case VIDC_1080P_ERROR_DIVIDE_BY_ZERO: - case VIDC_1080P_ERROR_DMA_TX_NOT_COMPLETE: - case VIDC_1080P_ERROR_VSP_NOT_READY: - case VIDC_1080P_ERROR_BUFFER_FULL_STATE: - ddl_hw_fatal_cb(ddl); - status = true; - break; - default: - break; - } - return status; -} - -void ddl_client_fatal_cb(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - - if (ddl->cmd_state == DDL_CMD_DECODE_FRAME) - ddl_vidc_decode_dynamic_property(ddl, false); - else if (ddl->cmd_state == DDL_CMD_ENCODE_FRAME) - ddl_vidc_encode_dynamic_property(ddl, false); - ddl->cmd_state = DDL_CMD_INVALID; - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_FAVIDC_ERROR", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_FAVIDC_ERROR; - ddl_context->ddl_callback(VCD_EVT_IND_HWERRFATAL, - VCD_ERR_CLIENT_FATAL, NULL, 0, (u32 *)ddl, - ddl->client_data); - ddl_release_command_channel(ddl_context, ddl->command_channel); -} - -static u32 ddl_handle_client_fatal_errors( - struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - u32 status = false; - - switch (ddl_context->cmd_err_status) { - case VIDC_1080P_ERROR_UNSUPPORTED_FEATURE_IN_PROFILE: - case VIDC_1080P_ERROR_RESOLUTION_NOT_SUPPORTED: - case VIDC_1080P_ERROR_VOS_END_CODE_RECEIVED: - case VIDC_1080P_ERROR_FRAME_RATE_NOT_SUPPORTED: - case VIDC_1080P_ERROR_INVALID_QP_VALUE: - case VIDC_1080P_ERROR_INVALID_RC_REACTION_COEFFICIENT: - case VIDC_1080P_ERROR_INVALID_CPB_SIZE_AT_GIVEN_LEVEL: - case VIDC_1080P_ERROR_B_FRAME_NOT_SUPPORTED: - case VIDC_1080P_ERROR_ALLOC_DPB_SIZE_NOT_SUFFICIENT: - case VIDC_1080P_ERROR_NUM_DPB_OUT_OF_RANGE: - case VIDC_1080P_ERROR_NULL_METADATA_INPUT_POINTER: - case VIDC_1080P_ERROR_NULL_DPB_POINTER: - case VIDC_1080P_ERROR_NULL_OTH_EXT_BUFADDR: - case VIDC_1080P_ERROR_NULL_MV_POINTER: - status = true; - DDL_MSG_ERROR("VIDC_CLIENT_FATAL!!"); - break; - default: - break; - } - if (!status) - DDL_MSG_ERROR("VIDC_UNKNOWN_OP_FAILED %d", - ddl_context->cmd_err_status); - ddl_client_fatal_cb(ddl); - return true; -} - -static void ddl_input_failed_cb(struct ddl_client_context *ddl, - u32 vcd_event, u32 vcd_status) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - u32 payload_size = sizeof(struct ddl_frame_data_tag); - - ddl->cmd_state = DDL_CMD_INVALID; - if (ddl->decoding) - ddl_vidc_decode_dynamic_property(ddl, false); - else - ddl_vidc_encode_dynamic_property(ddl, false); - if (ddl->client_state == DDL_CLIENT_WAIT_FOR_INITCODECDONE) { - payload_size = 0; - DDL_MSG_LOW("ddl_state_transition: %s ~~> " - "DDL_CLIENT_WAIT_FOR_INITCODEC", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_INITCODEC; - } else { - DDL_MSG_LOW("ddl_state_transition: %s ~~> " - "DDL_CLIENT_WAIT_FOR_FRAME", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME; - } - if (vcd_status == VCD_ERR_IFRAME_EXPECTED) - vcd_status = VCD_S_SUCCESS; - ddl_context->ddl_callback(vcd_event, vcd_status, &ddl->input_frame, - payload_size, (u32 *)ddl, ddl->client_data); -} - -static u32 ddl_handle_core_recoverable_errors( - struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - u32 vcd_status = VCD_S_SUCCESS; - u32 vcd_event = VCD_EVT_RESP_INPUT_DONE; - u32 eos = false, status = false; - - if (ddl->decoding) { - if (ddl_handle_dec_seq_hdr_fail_error(ddl)) - return true; - } - - if ((ddl->cmd_state != DDL_CMD_DECODE_FRAME) && - (ddl->cmd_state != DDL_CMD_ENCODE_FRAME)) - return false; - - if (ddl->decoding && - (ddl->codec_data.decoder.field_needed_for_prev_ip == 1)) { - ddl->codec_data.decoder.field_needed_for_prev_ip = 0; - ddl_release_prev_field(ddl); - if (ddl_context->cmd_err_status == - VIDC_1080P_ERROR_NON_PAIRED_FIELD_NOT_SUPPORTED) { - ddl_vidc_decode_frame_run(ddl); - return true; - } - } - - switch (ddl_context->cmd_err_status) { - case VIDC_1080P_ERROR_SYNC_POINT_NOT_RECEIVED: - vcd_status = VCD_ERR_IFRAME_EXPECTED; - break; - case VIDC_1080P_ERROR_NO_BUFFER_RELEASED_FROM_HOST: - { - u32 pending_display = 0, release_mask; - - release_mask = - ddl->codec_data.decoder.\ - dpb_mask.hw_mask; - while (release_mask > 0) { - if (release_mask & 0x1) - pending_display++; - release_mask >>= 1; - } - if (pending_display >= ddl->codec_data.\ - decoder.min_dpb_num) { - DDL_MSG_ERROR("VIDC_FW_ISSUE_REQ_BUF"); - ddl_client_fatal_cb(ddl); - status = true; - } else { - vcd_event = VCD_EVT_RESP_OUTPUT_REQ; - DDL_MSG_LOW("VIDC_OUTPUT_BUF_REQ!!"); - } - break; - } - case VIDC_1080P_ERROR_NON_IDR_FRAME_TYPE: - case VIDC_1080P_ERROR_BIT_STREAM_BUF_EXHAUST: - case VIDC_1080P_ERROR_DESCRIPTOR_TABLE_ENTRY_INVALID: - case VIDC_1080P_ERROR_MB_COEFF_NOT_DONE: - case VIDC_1080P_ERROR_CODEC_SLICE_NOT_DONE: - case VIDC_1080P_ERROR_VIDC_CORE_TIME_OUT: - case VIDC_1080P_ERROR_VC1_BITPLANE_DECODE_ERR: - case VIDC_1080P_ERROR_RESOLUTION_MISMATCH: - case VIDC_1080P_ERROR_NV_QUANT_ERR: - case VIDC_1080P_ERROR_SYNC_MARKER_ERR: - case VIDC_1080P_ERROR_FEATURE_NOT_SUPPORTED: - case VIDC_1080P_ERROR_MEM_CORRUPTION: - case VIDC_1080P_ERROR_INVALID_REFERENCE_FRAME: - case VIDC_1080P_ERROR_PICTURE_CODING_TYPE_ERR: - case VIDC_1080P_ERROR_MV_RANGE_ERR: - case VIDC_1080P_ERROR_PICTURE_STRUCTURE_ERR: - case VIDC_1080P_ERROR_SLICE_ADDR_INVALID: - case VIDC_1080P_ERROR_NON_FRAME_DATA_RECEIVED: - case VIDC_1080P_ERROR_NALU_HEADER_ERROR: - case VIDC_1080P_ERROR_SPS_PARSE_ERROR: - case VIDC_1080P_ERROR_PPS_PARSE_ERROR: - case VIDC_1080P_ERROR_HEADER_NOT_FOUND: - case VIDC_1080P_ERROR_SLICE_PARSE_ERROR: - case VIDC_1080P_ERROR_NON_PAIRED_FIELD_NOT_SUPPORTED: - case VIDC_1080P_ERROR_DESCRIPTOR_BUFFER_EMPTY: - vcd_status = VCD_ERR_BITSTREAM_ERR; - DDL_MSG_ERROR("VIDC_BIT_STREAM_ERR (%u)", - (u32)ddl_context->cmd_err_status); - break; - case VIDC_1080P_ERROR_B_FRAME_NOT_SUPPORTED: - case VIDC_1080P_ERROR_UNSUPPORTED_FEATURE_IN_PROFILE: - case VIDC_1080P_ERROR_RESOLUTION_NOT_SUPPORTED: - if (ddl->decoding) { - vcd_status = VCD_ERR_BITSTREAM_ERR; - DDL_MSG_ERROR("VIDC_BIT_STREAM_ERR (%u)", - (u32)ddl_context->cmd_err_status); - } - break; - default: - break; - } - - if (((vcd_status) || (vcd_event != VCD_EVT_RESP_INPUT_DONE)) && - !status) { - ddl->input_frame.frm_trans_end = true; - eos = ((vcd_event == VCD_EVT_RESP_INPUT_DONE) && - (ddl->input_frame.vcd_frm.flags & VCD_FRAME_FLAG_EOS)); - if (((ddl->decoding) && (eos)) || !ddl->decoding) - ddl->input_frame.frm_trans_end = false; - ddl_input_failed_cb(ddl, vcd_event, vcd_status); - if (!ddl->decoding) { - ddl->output_frame.frm_trans_end = !eos; - ddl->output_frame.vcd_frm.data_len = 0; - ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_ERR_FAIL, &ddl->output_frame, - sizeof(struct ddl_frame_data_tag), (u32 *)ddl, - ddl->client_data); - if (eos) { - DDL_MSG_LOW("VIDC_ENC_EOS_DONE"); - ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE, - VCD_S_SUCCESS, NULL, 0, (u32 *)ddl, - ddl->client_data); - } - } - if ((ddl->decoding) && (eos)) - ddl_vidc_decode_eos_run(ddl); - else - ddl_release_command_channel(ddl_context, - ddl->command_channel); - status = true; - } - return status; -} - -static u32 ddl_handle_core_warnings(u32 err_status) -{ - u32 status = false; - - switch (err_status) { - case VIDC_1080P_WARN_COMMAND_FLUSHED: - case VIDC_1080P_WARN_FRAME_RATE_UNKNOWN: - case VIDC_1080P_WARN_ASPECT_RATIO_UNKNOWN: - case VIDC_1080P_WARN_COLOR_PRIMARIES_UNKNOWN: - case VIDC_1080P_WARN_TRANSFER_CHAR_UNKNOWN: - case VIDC_1080P_WARN_MATRIX_COEFF_UNKNOWN: - case VIDC_1080P_WARN_NON_SEQ_SLICE_ADDR: - case VIDC_1080P_WARN_BROKEN_LINK: - case VIDC_1080P_WARN_FRAME_CONCEALED: - case VIDC_1080P_WARN_PROFILE_UNKNOWN: - case VIDC_1080P_WARN_LEVEL_UNKNOWN: - case VIDC_1080P_WARN_BIT_RATE_NOT_SUPPORTED: - case VIDC_1080P_WARN_COLOR_DIFF_FORMAT_NOT_SUPPORTED: - case VIDC_1080P_WARN_NULL_EXTRA_METADATA_POINTER: - case VIDC_1080P_WARN_DEBLOCKING_NOT_DONE: - case VIDC_1080P_WARN_INCOMPLETE_FRAME: - case VIDC_1080P_ERROR_NULL_FW_DEBUG_INFO_POINTER: - case VIDC_1080P_ERROR_ALLOC_DEBUG_INFO_SIZE_INSUFFICIENT: - case VIDC_1080P_WARN_METADATA_NO_SPACE_NUM_CONCEAL_MB: - case VIDC_1080P_WARN_METADATA_NO_SPACE_QP: - case VIDC_1080P_WARN_METADATA_NO_SPACE_CONCEAL_MB: - case VIDC_1080P_WARN_METADATA_NO_SPACE_VC1_PARAM: - case VIDC_1080P_WARN_METADATA_NO_SPACE_SEI: - case VIDC_1080P_WARN_METADATA_NO_SPACE_VUI: - case VIDC_1080P_WARN_METADATA_NO_SPACE_EXTRA: - case VIDC_1080P_WARN_METADATA_NO_SPACE_DATA_NONE: - case VIDC_1080P_WARN_METADATA_NO_SPACE_MB_INFO: - case VIDC_1080P_WARN_METADATA_NO_SPACE_SLICE_SIZE: - case VIDC_1080P_WARN_RESOLUTION_WARNING: - case VIDC_1080P_WARN_NO_LONG_TERM_REFERENCE: - case VIDC_1080P_WARN_NO_SPACE_MPEG2_DATA_DUMP: - case VIDC_1080P_WARN_METADATA_NO_SPACE_MISSING_MB: - status = true; - DDL_MSG_ERROR("VIDC_WARNING_IGNORED"); - break; - default: - break; - } - return status; -} - -u32 ddl_handle_core_errors(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - u32 channel_inst_id, status = false; - u32 disp_status; - - if (!ddl_context->cmd_err_status && - !ddl_context->disp_pic_err_status) { - DDL_MSG_ERROR("VIDC_NO_ERROR"); - return false; - } - vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); - vidc_1080p_clear_returned_channel_inst_id(); - ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context, - ddl_context->response_cmd_ch_id); - if (!ddl) { - DDL_MSG_ERROR("VIDC_SPURIOUS_INTERRUPT_ERROR"); - return true; - } - if (ddl_context->cmd_err_status) { - print_core_errors(ddl_context->cmd_err_status); - print_core_recoverable_errors(ddl_context->cmd_err_status); - } - if (ddl_context->disp_pic_err_status) - print_core_errors(ddl_context->disp_pic_err_status); - status = ddl_handle_core_warnings(ddl_context->cmd_err_status); - disp_status = ddl_handle_core_warnings( - ddl_context->disp_pic_err_status); - if (!status && !disp_status) { - DDL_MSG_ERROR("ddl_warning:Unknown"); - status = ddl_handle_hw_fatal_errors(ddl); - if (!status) - status = ddl_handle_core_recoverable_errors(ddl); - if (!status) - status = ddl_handle_client_fatal_errors(ddl); - } - return status; -} - -static void ddl_release_prev_field(struct ddl_client_context *ddl) -{ - ddl->output_frame.vcd_frm.ip_frm_tag = - ddl->codec_data.decoder.prev_ip_frm_tag; - ddl->output_frame.vcd_frm.physical = NULL; - ddl->output_frame.vcd_frm.virtual = NULL; - ddl->output_frame.frm_trans_end = false; - ddl->ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_ERR_INTRLCD_FIELD_DROP, &(ddl->output_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl->client_data); -} - -static u32 ddl_handle_dec_seq_hdr_fail_error(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - u32 status = false; - - if ((ddl->cmd_state != DDL_CMD_HEADER_PARSE) || - (ddl->client_state != DDL_CLIENT_WAIT_FOR_INITCODECDONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-HDDONE"); - return false; - } - - switch (ddl_context->cmd_err_status) { - case VIDC_1080P_ERROR_UNSUPPORTED_FEATURE_IN_PROFILE: - case VIDC_1080P_ERROR_RESOLUTION_NOT_SUPPORTED: - case VIDC_1080P_ERROR_HEADER_NOT_FOUND: - case VIDC_1080P_ERROR_SPS_PARSE_ERROR: - case VIDC_1080P_ERROR_PPS_PARSE_ERROR: - { - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - if (ddl_context->cmd_err_status == - VIDC_1080P_ERROR_UNSUPPORTED_FEATURE_IN_PROFILE - && decoder->codec.codec == VCD_CODEC_H264) { - DDL_MSG_ERROR("Unsupported Feature for H264"); - ddl_client_fatal_cb(ddl); - return true; - } - if ((ddl_context->cmd_err_status == - VIDC_1080P_ERROR_RESOLUTION_NOT_SUPPORTED) - && (decoder->codec.codec == VCD_CODEC_H263 - || decoder->codec.codec == VCD_CODEC_H264 - || decoder->codec.codec == VCD_CODEC_MPEG4 - || decoder->codec.codec == VCD_CODEC_VC1 - || decoder->codec.codec == VCD_CODEC_VC1_RCV)) { - DDL_MSG_ERROR("Unsupported resolution"); - ddl_client_fatal_cb(ddl); - return true; - } - - DDL_MSG_ERROR("SEQHDR-FAILED"); - if (decoder->header_in_start) { - decoder->header_in_start = false; - ddl_context->ddl_callback(VCD_EVT_RESP_START, - VCD_ERR_SEQHDR_PARSE_FAIL, NULL, 0, - (u32 *) ddl, ddl->client_data); - } else { - ddl->input_frame.frm_trans_end = true; - if ((ddl->input_frame.vcd_frm.flags & - VCD_FRAME_FLAG_EOS)) { - ddl->input_frame.frm_trans_end = false; - } - ddl_vidc_decode_dynamic_property(ddl, false); - ddl_context->ddl_callback( - VCD_EVT_RESP_INPUT_DONE, - VCD_ERR_SEQHDR_PARSE_FAIL, &ddl->input_frame, - sizeof(struct ddl_frame_data_tag), (u32 *)ddl, - ddl->client_data); - if ((ddl->input_frame.vcd_frm.flags & - VCD_FRAME_FLAG_EOS)) { - DDL_MSG_HIGH("EOS_DONE-fromDDL"); - ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE, - VCD_S_SUCCESS, NULL, 0, (u32 *) ddl, - ddl->client_data); - } - } - DDL_MSG_LOW("ddl_state_transition: %s ~~> " - "DDL_CLIENT_WAIT_FOR_INITCODEC", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_INITCODEC; - ddl_release_command_channel(ddl_context, ddl->command_channel); - status = true; - break; - } - default: - break; - } - return status; -} - -void print_core_errors(u32 error_code) -{ - s8 *string = NULL; - - switch (error_code) { - case VIDC_1080P_ERROR_INVALID_CHANNEL_NUMBER: - string = "VIDC_1080P_ERROR_INVALID_CHANNEL_NUMBER"; - break; - case VIDC_1080P_ERROR_INVALID_COMMAND_ID: - string = "VIDC_1080P_ERROR_INVALID_COMMAND_ID"; - break; - case VIDC_1080P_ERROR_CHANNEL_ALREADY_IN_USE: - string = "VIDC_1080P_ERROR_CHANNEL_ALREADY_IN_USE"; - break; - case VIDC_1080P_ERROR_CHANNEL_NOT_OPEN_BEFORE_CHANNEL_CLOSE: - string = - "VIDC_1080P_ERROR_CHANNEL_NOT_OPEN_BEFORE_CHANNEL_CLOSE"; - break; - case VIDC_1080P_ERROR_OPEN_CH_ERROR_SEQ_START: - string = "VIDC_1080P_ERROR_OPEN_CH_ERROR_SEQ_START"; - break; - case VIDC_1080P_ERROR_SEQ_START_ALREADY_CALLED: - string = "VIDC_1080P_ERROR_SEQ_START_ALREADY_CALLED"; - break; - case VIDC_1080P_ERROR_OPEN_CH_ERROR_INIT_BUFFERS: - string = "VIDC_1080P_ERROR_OPEN_CH_ERROR_INIT_BUFFERS"; - break; - case VIDC_1080P_ERROR_SEQ_START_ERROR_INIT_BUFFERS: - string = "VIDC_1080P_ERROR_SEQ_START_ERROR_INIT_BUFFERS"; - break; - case VIDC_1080P_ERROR_INIT_BUFFER_ALREADY_CALLED: - string = "VIDC_1080P_ERROR_INIT_BUFFER_ALREADY_CALLED"; - break; - case VIDC_1080P_ERROR_OPEN_CH_ERROR_FRAME_START: - string = "VIDC_1080P_ERROR_OPEN_CH_ERROR_FRAME_START"; - break; - case VIDC_1080P_ERROR_SEQ_START_ERROR_FRAME_START: - string = "VIDC_1080P_ERROR_SEQ_START_ERROR_FRAME_START"; - break; - case VIDC_1080P_ERROR_INIT_BUFFERS_ERROR_FRAME_START: - string = "VIDC_1080P_ERROR_INIT_BUFFERS_ERROR_FRAME_START"; - break; - case VIDC_1080P_ERROR_RESOLUTION_CHANGED: - string = "VIDC_1080P_ERROR_RESOLUTION_CHANGED"; - break; - case VIDC_1080P_ERROR_INVALID_COMMAND_LAST_FRAME: - string = "VIDC_1080P_ERROR_INVALID_COMMAND_LAST_FRAME"; - break; - case VIDC_1080P_ERROR_INVALID_COMMAND: - string = "VIDC_1080P_ERROR_INVALID_COMMAND"; - break; - case VIDC_1080P_ERROR_INVALID_CODEC_TYPE: - string = "VIDC_1080P_ERROR_INVALID_CODEC_TYPE"; - break; - case VIDC_1080P_ERROR_MEM_ALLOCATION_FAILED: - string = "VIDC_1080P_ERROR_MEM_ALLOCATION_FAILED"; - break; - case VIDC_1080P_ERROR_INSUFFICIENT_CONTEXT_SIZE: - string = "VIDC_1080P_ERROR_INSUFFICIENT_CONTEXT_SIZE"; - break; - case VIDC_1080P_ERROR_DIVIDE_BY_ZERO: - string = "VIDC_1080P_ERROR_DIVIDE_BY_ZERO"; - break; - case VIDC_1080P_ERROR_DESCRIPTOR_BUFFER_EMPTY: - string = "VIDC_1080P_ERROR_DESCRIPTOR_BUFFER_EMPTY"; - break; - case VIDC_1080P_ERROR_DMA_TX_NOT_COMPLETE: - string = "VIDC_1080P_ERROR_DMA_TX_NOT_COMPLETE"; - break; - case VIDC_1080P_ERROR_VSP_NOT_READY: - string = "VIDC_1080P_ERROR_VSP_NOT_READY"; - break; - case VIDC_1080P_ERROR_BUFFER_FULL_STATE: - string = "VIDC_1080P_ERROR_BUFFER_FULL_STATE"; - break; - case VIDC_1080P_ERROR_UNSUPPORTED_FEATURE_IN_PROFILE: - string = "VIDC_1080P_ERROR_UNSUPPORTED_FEATURE_IN_PROFILE"; - break; - case VIDC_1080P_ERROR_HEADER_NOT_FOUND: - string = "VIDC_1080P_ERROR_HEADER_NOT_FOUND"; - break; - case VIDC_1080P_ERROR_VOS_END_CODE_RECEIVED: - string = "VIDC_1080P_ERROR_VOS_END_CODE_RECEIVED"; - break; - case VIDC_1080P_ERROR_RESOLUTION_NOT_SUPPORTED: - string = "VIDC_1080P_ERROR_RESOLUTION_NOT_SUPPORTED"; - break; - case VIDC_1080P_ERROR_FRAME_RATE_NOT_SUPPORTED: - string = "VIDC_1080P_ERROR_FRAME_RATE_NOT_SUPPORTED"; - break; - case VIDC_1080P_ERROR_INVALID_QP_VALUE: - string = "VIDC_1080P_ERROR_INVALID_QP_VALUE"; - break; - case VIDC_1080P_ERROR_INVALID_RC_REACTION_COEFFICIENT: - string = "VIDC_1080P_ERROR_INVALID_RC_REACTION_COEFFICIENT"; - break; - case VIDC_1080P_ERROR_INVALID_CPB_SIZE_AT_GIVEN_LEVEL: - string = "VIDC_1080P_ERROR_INVALID_CPB_SIZE_AT_GIVEN_LEVEL"; - break; - case VIDC_1080P_ERROR_B_FRAME_NOT_SUPPORTED: - string = "VIDC_1080P_ERROR_B_FRAME_NOT_SUPPORTED"; - break; - case VIDC_1080P_ERROR_ALLOC_DPB_SIZE_NOT_SUFFICIENT: - string = "VIDC_1080P_ERROR_ALLOC_DPB_SIZE_NOT_SUFFICIENT"; - break; - case VIDC_1080P_ERROR_NUM_DPB_OUT_OF_RANGE: - string = "VIDC_1080P_ERROR_NUM_DPB_OUT_OF_RANGE"; - break; - case VIDC_1080P_ERROR_NULL_METADATA_INPUT_POINTER: - string = "VIDC_1080P_ERROR_NULL_METADATA_INPUT_POINTER"; - break; - case VIDC_1080P_ERROR_NULL_DPB_POINTER: - string = "VIDC_1080P_ERROR_NULL_DPB_POINTER"; - break; - case VIDC_1080P_ERROR_NULL_OTH_EXT_BUFADDR: - string = "VIDC_1080P_ERROR_NULL_OTH_EXT_BUFADDR"; - break; - case VIDC_1080P_ERROR_NULL_MV_POINTER: - string = "VIDC_1080P_ERROR_NULL_MV_POINTER"; - break; - case VIDC_1080P_ERROR_NON_PAIRED_FIELD_NOT_SUPPORTED: - string = "VIDC_1080P_ERROR_NON_PAIRED_FIELD_NOT_SUPPORTED"; - break; - case VIDC_1080P_WARN_COMMAND_FLUSHED: - string = "VIDC_1080P_WARN_COMMAND_FLUSHED"; - break; - case VIDC_1080P_WARN_FRAME_RATE_UNKNOWN: - string = "VIDC_1080P_WARN_FRAME_RATE_UNKNOWN"; - break; - case VIDC_1080P_WARN_ASPECT_RATIO_UNKNOWN: - string = "VIDC_1080P_WARN_ASPECT_RATIO_UNKNOWN"; - break; - case VIDC_1080P_WARN_COLOR_PRIMARIES_UNKNOWN: - string = "VIDC_1080P_WARN_COLOR_PRIMARIES_UNKNOWN"; - break; - case VIDC_1080P_WARN_TRANSFER_CHAR_UNKNOWN: - string = "VIDC_1080P_WARN_TRANSFER_CHAR_UNKNOWN"; - break; - case VIDC_1080P_WARN_MATRIX_COEFF_UNKNOWN: - string = "VIDC_1080P_WARN_MATRIX_COEFF_UNKNOWN"; - break; - case VIDC_1080P_WARN_NON_SEQ_SLICE_ADDR: - string = "VIDC_1080P_WARN_NON_SEQ_SLICE_ADDR"; - break; - case VIDC_1080P_WARN_BROKEN_LINK: - string = "VIDC_1080P_WARN_BROKEN_LINK"; - break; - case VIDC_1080P_WARN_FRAME_CONCEALED: - string = "VIDC_1080P_WARN_FRAME_CONCEALED"; - break; - case VIDC_1080P_WARN_PROFILE_UNKNOWN: - string = "VIDC_1080P_WARN_PROFILE_UNKNOWN"; - break; - case VIDC_1080P_WARN_LEVEL_UNKNOWN: - string = "VIDC_1080P_WARN_LEVEL_UNKNOWN"; - break; - case VIDC_1080P_WARN_BIT_RATE_NOT_SUPPORTED: - string = "VIDC_1080P_WARN_BIT_RATE_NOT_SUPPORTED"; - break; - case VIDC_1080P_WARN_COLOR_DIFF_FORMAT_NOT_SUPPORTED: - string = "VIDC_1080P_WARN_COLOR_DIFF_FORMAT_NOT_SUPPORTED"; - break; - case VIDC_1080P_WARN_NULL_EXTRA_METADATA_POINTER: - string = "VIDC_1080P_WARN_NULL_EXTRA_METADATA_POINTER"; - break; - case VIDC_1080P_WARN_DEBLOCKING_NOT_DONE: - string = "VIDC_1080P_WARN_DEBLOCKING_NOT_DONE"; - break; - case VIDC_1080P_WARN_INCOMPLETE_FRAME: - string = "VIDC_1080P_WARN_INCOMPLETE_FRAME"; - break; - case VIDC_1080P_ERROR_NULL_FW_DEBUG_INFO_POINTER: - string = "VIDC_1080P_ERROR_NULL_FW_DEBUG_INFO_POINTER"; - break; - case VIDC_1080P_ERROR_ALLOC_DEBUG_INFO_SIZE_INSUFFICIENT: - string = - "VIDC_1080P_ERROR_ALLOC_DEBUG_INFO_SIZE_INSUFFICIENT"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_NUM_CONCEAL_MB: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_NUM_CONCEAL_MB"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_QP: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_QP"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_CONCEAL_MB: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_CONCEAL_MB"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_VC1_PARAM: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_VC1_PARAM"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_SEI: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_SEI"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_VUI: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_VUI"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_EXTRA: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_EXTRA"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_DATA_NONE: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_DATA_NONE"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_MB_INFO: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_MB_INFO"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_SLICE_SIZE: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_SLICE_SIZE"; - break; - case VIDC_1080P_WARN_RESOLUTION_WARNING: - string = "VIDC_1080P_WARN_RESOLUTION_WARNING"; - break; - case VIDC_1080P_WARN_NO_LONG_TERM_REFERENCE: - string = "VIDC_1080P_WARN_NO_LONG_TERM_REFERENCE"; - break; - case VIDC_1080P_WARN_NO_SPACE_MPEG2_DATA_DUMP: - string = "VIDC_1080P_WARN_NO_SPACE_MPEG2_DATA_DUMP"; - break; - case VIDC_1080P_WARN_METADATA_NO_SPACE_MISSING_MB: - string = "VIDC_1080P_WARN_METADATA_NO_SPACE_MISSING_MB"; - break; - } - if (string) - DDL_MSG_ERROR("Error code = 0x%x : %s", error_code, string); -} - -void print_core_recoverable_errors(u32 error_code) -{ - s8 *string = NULL; - - switch (error_code) { - case VIDC_1080P_ERROR_SYNC_POINT_NOT_RECEIVED: - string = "VIDC_1080P_ERROR_SYNC_POINT_NOT_RECEIVED"; - break; - case VIDC_1080P_ERROR_NO_BUFFER_RELEASED_FROM_HOST: - string = "VIDC_1080P_ERROR_NO_BUFFER_RELEASED_FROM_HOST"; - break; - case VIDC_1080P_ERROR_BIT_STREAM_BUF_EXHAUST: - string = "VIDC_1080P_ERROR_BIT_STREAM_BUF_EXHAUST"; - break; - case VIDC_1080P_ERROR_DESCRIPTOR_TABLE_ENTRY_INVALID: - string = "VIDC_1080P_ERROR_DESCRIPTOR_TABLE_ENTRY_INVALID"; - break; - case VIDC_1080P_ERROR_MB_COEFF_NOT_DONE: - string = "VIDC_1080P_ERROR_MB_COEFF_NOT_DONE"; - break; - case VIDC_1080P_ERROR_CODEC_SLICE_NOT_DONE: - string = "VIDC_1080P_ERROR_CODEC_SLICE_NOT_DONE"; - break; - case VIDC_1080P_ERROR_VIDC_CORE_TIME_OUT: - string = "VIDC_1080P_ERROR_VIDC_CORE_TIME_OUT"; - break; - case VIDC_1080P_ERROR_VC1_BITPLANE_DECODE_ERR: - string = "VIDC_1080P_ERROR_VC1_BITPLANE_DECODE_ERR"; - break; - case VIDC_1080P_ERROR_RESOLUTION_MISMATCH: - string = "VIDC_1080P_ERROR_RESOLUTION_MISMATCH"; - break; - case VIDC_1080P_ERROR_NV_QUANT_ERR: - string = "VIDC_1080P_ERROR_NV_QUANT_ERR"; - break; - case VIDC_1080P_ERROR_SYNC_MARKER_ERR: - string = "VIDC_1080P_ERROR_SYNC_MARKER_ERR"; - break; - case VIDC_1080P_ERROR_FEATURE_NOT_SUPPORTED: - string = "VIDC_1080P_ERROR_FEATURE_NOT_SUPPORTED"; - break; - case VIDC_1080P_ERROR_MEM_CORRUPTION: - string = "VIDC_1080P_ERROR_MEM_CORRUPTION"; - break; - case VIDC_1080P_ERROR_INVALID_REFERENCE_FRAME: - string = "VIDC_1080P_ERROR_INVALID_REFERENCE_FRAME"; - break; - case VIDC_1080P_ERROR_PICTURE_CODING_TYPE_ERR: - string = "VIDC_1080P_ERROR_PICTURE_CODING_TYPE_ERR"; - break; - case VIDC_1080P_ERROR_MV_RANGE_ERR: - string = "VIDC_1080P_ERROR_MV_RANGE_ERR"; - break; - case VIDC_1080P_ERROR_PICTURE_STRUCTURE_ERR: - string = "VIDC_1080P_ERROR_PICTURE_STRUCTURE_ERR"; - break; - case VIDC_1080P_ERROR_SLICE_ADDR_INVALID: - string = "VIDC_1080P_ERROR_SLICE_ADDR_INVALID"; - break; - case VIDC_1080P_ERROR_NON_FRAME_DATA_RECEIVED: - string = "VIDC_1080P_ERROR_NON_FRAME_DATA_RECEIVED"; - break; - case VIDC_1080P_ERROR_NALU_HEADER_ERROR: - string = "VIDC_1080P_ERROR_NALU_HEADER_ERROR"; - break; - case VIDC_1080P_ERROR_SPS_PARSE_ERROR: - string = "VIDC_1080P_ERROR_SPS_PARSE_ERROR"; - break; - case VIDC_1080P_ERROR_PPS_PARSE_ERROR: - string = "VIDC_1080P_ERROR_PPS_PARSE_ERROR"; - break; - case VIDC_1080P_ERROR_SLICE_PARSE_ERROR: - string = "VIDC_1080P_ERROR_SLICE_PARSE_ERROR"; - break; - } - if (string) - DDL_MSG_LOW("Recoverable Error code = 0x%x : %s", - error_code, string); -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_helper.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_helper.c deleted file mode 100644 index 77faee3b644433de9ddb03571cae6911d5926888..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_helper.c +++ /dev/null @@ -1,1434 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include "vcd_ddl.h" -#include "vcd_ddl_shared_mem.h" -#include "vcd_res_tracker_api.h" - -struct ddl_context *ddl_get_context(void) -{ - static struct ddl_context ddl_context; - return &ddl_context; -} - -#if DDL_MSG_LOG -s8 *ddl_get_state_string(enum ddl_client_state client_state) -{ - s8 *ptr; - - switch (client_state) { - case DDL_CLIENT_INVALID: - ptr = "INVALID "; - break; - case DDL_CLIENT_OPEN: - ptr = "OPEN "; - break; - case DDL_CLIENT_WAIT_FOR_CHDONE: - ptr = "WAIT_FOR_CHDONE "; - break; - case DDL_CLIENT_WAIT_FOR_INITCODEC: - ptr = "WAIT_FOR_INITCODEC "; - break; - case DDL_CLIENT_WAIT_FOR_INITCODECDONE: - ptr = "WAIT_FOR_INITCODECDONE"; - break; - case DDL_CLIENT_WAIT_FOR_DPB: - ptr = "WAIT_FOR_DPB "; - break; - case DDL_CLIENT_WAIT_FOR_DPBDONE: - ptr = "WAIT_FOR_DPBDONE"; - break; - case DDL_CLIENT_WAIT_FOR_FRAME: - ptr = "WAIT_FOR_FRAME "; - break; - case DDL_CLIENT_WAIT_FOR_FRAME_DONE: - ptr = "WAIT_FOR_FRAME_DONE "; - break; - case DDL_CLIENT_WAIT_FOR_EOS_DONE: - ptr = "WAIT_FOR_EOS_DONE "; - break; - case DDL_CLIENT_WAIT_FOR_CHEND: - ptr = "WAIT_FOR_CHEND "; - break; - case DDL_CLIENT_FATAL_ERROR: - ptr = "FATAL_ERROR"; - break; - default: - ptr = "UNKNOWN "; - break; - } - return ptr; -} -#endif - -u32 ddl_client_transact(u32 operation, - struct ddl_client_context **pddl_client) -{ - struct ddl_context *ddl_context; - u32 ret_status = VCD_ERR_FAIL; - s32 counter; - - ddl_context = ddl_get_context(); - switch (operation) { - case DDL_FREE_CLIENT: - ret_status = VCD_ERR_MAX_CLIENT; - for (counter = 0; (counter < VCD_MAX_NO_CLIENT) && - (ret_status == VCD_ERR_MAX_CLIENT); ++counter) { - if (*pddl_client == ddl_context->ddl_clients - [counter]) { - kfree(*pddl_client); - *pddl_client = NULL; - ddl_context->ddl_clients[counter] - = NULL; - ret_status = VCD_S_SUCCESS; - } - } - break; - case DDL_GET_CLIENT: - ret_status = VCD_ERR_MAX_CLIENT; - for (counter = (VCD_MAX_NO_CLIENT - 1); (counter >= 0) && - (ret_status == VCD_ERR_MAX_CLIENT); --counter) { - if (!ddl_context->ddl_clients[counter]) { - *pddl_client = - (struct ddl_client_context *) - kmalloc(sizeof(struct - ddl_client_context), GFP_KERNEL); - if (!*pddl_client) - ret_status = VCD_ERR_ALLOC_FAIL; - else { - memset(*pddl_client, 0, - sizeof(struct - ddl_client_context)); - ddl_context->ddl_clients - [counter] = *pddl_client; - (*pddl_client)->ddl_context = - ddl_context; - ret_status = VCD_S_SUCCESS; - } - } - } - break; - case DDL_INIT_CLIENTS: - for (counter = 0; counter < VCD_MAX_NO_CLIENT; ++counter) - ddl_context->ddl_clients[counter] = NULL; - ret_status = VCD_S_SUCCESS; - break; - case DDL_ACTIVE_CLIENT: - for (counter = 0; counter < VCD_MAX_NO_CLIENT; - ++counter) { - if (ddl_context->ddl_clients[counter]) { - ret_status = VCD_S_SUCCESS; - break; - } - } - break; - default: - ret_status = VCD_ERR_ILLEGAL_PARM; - break; - } - return ret_status; -} - -u32 ddl_decoder_dpb_transact(struct ddl_decoder_data *decoder, - struct ddl_frame_data_tag *in_out_frame, u32 operation) -{ - struct ddl_frame_data_tag *found_frame = NULL; - struct ddl_mask *dpb_mask = &decoder->dpb_mask; - u32 vcd_status = VCD_S_SUCCESS, loopc; - - switch (operation) { - case DDL_DPB_OP_MARK_BUSY: - case DDL_DPB_OP_MARK_FREE: - for (loopc = 0; !found_frame && loopc < - decoder->dp_buf.no_of_dec_pic_buf; ++loopc) { - if (in_out_frame->vcd_frm.physical == - decoder->dp_buf.dec_pic_buffers[loopc]. - vcd_frm.physical) { - found_frame = &(decoder->dp_buf. - dec_pic_buffers[loopc]); - break; - } - } - if (found_frame) { - if (operation == DDL_DPB_OP_MARK_BUSY) { - dpb_mask->hw_mask &= - (~(u32)(0x1 << loopc)); - *in_out_frame = *found_frame; - } else if (operation == DDL_DPB_OP_MARK_FREE) { - dpb_mask->client_mask |= (0x1 << loopc); - *found_frame = *in_out_frame; - if ((decoder->meta_data_enable_flag) && - (in_out_frame->vcd_frm.buff_ion_handle)) { - struct ddl_context *ddl_context = - ddl_get_context(); - unsigned long *vaddr = - (unsigned long *)((u32) - in_out_frame->vcd_frm.virtual + - decoder->meta_data_offset); - DDL_MSG_LOW("%s: Cache clean: vaddr"\ - " (%p), offset %u, size %u", - __func__, - in_out_frame->vcd_frm.virtual, - decoder->meta_data_offset, - decoder->suffix); - msm_ion_do_cache_op( - ddl_context->video_ion_client, - in_out_frame->vcd_frm.\ - buff_ion_handle, - vaddr, - (unsigned long)decoder->suffix, - ION_IOC_CLEAN_CACHES); - } - } - } else { - in_out_frame->vcd_frm.physical = NULL; - in_out_frame->vcd_frm.virtual = NULL; - vcd_status = VCD_ERR_BAD_POINTER; - DDL_MSG_ERROR("BUF_NOT_FOUND"); - } - break; - case DDL_DPB_OP_SET_MASK: - dpb_mask->hw_mask |= dpb_mask->client_mask; - dpb_mask->client_mask = 0; - break; - case DDL_DPB_OP_INIT: - { - u32 dpb_size; - dpb_size = (!decoder->meta_data_offset) ? - decoder->dp_buf.dec_pic_buffers[0].vcd_frm.alloc_len : - decoder->meta_data_offset; - } - break; - case DDL_DPB_OP_RETRIEVE: - { - u32 position; - if (dpb_mask->client_mask) { - position = 0x1; - for (loopc = 0; loopc < - decoder->dp_buf.no_of_dec_pic_buf && - !found_frame; ++loopc) { - if (dpb_mask->client_mask & position) { - found_frame = &decoder->dp_buf. - dec_pic_buffers[loopc]; - dpb_mask->client_mask &= - ~(position); - } - position <<= 1; - } - } else if (dpb_mask->hw_mask) { - position = 0x1; - for (loopc = 0; loopc < - decoder->dp_buf.no_of_dec_pic_buf && - !found_frame; ++loopc) { - if (dpb_mask->hw_mask & position) { - found_frame = &decoder->dp_buf. - dec_pic_buffers[loopc]; - dpb_mask->hw_mask &= ~(position); - } - position <<= 1; - } - } - if (found_frame) - *in_out_frame = *found_frame; - else { - in_out_frame->vcd_frm.physical = NULL; - in_out_frame->vcd_frm.virtual = NULL; - } - } - break; - default: - break; - } - return vcd_status; -} - -u32 ddl_decoder_dpb_init(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct ddl_dec_buffers *dec_buffers = &decoder->hw_bufs; - struct ddl_frame_data_tag *frame; - u32 luma[DDL_MAX_BUFFER_COUNT], chroma[DDL_MAX_BUFFER_COUNT]; - u32 mv[DDL_MAX_BUFFER_COUNT], luma_size, i, dpb; - frame = &decoder->dp_buf.dec_pic_buffers[0]; - luma_size = ddl_get_yuv_buf_size(decoder->frame_size.width, - decoder->frame_size.height, DDL_YUV_BUF_TYPE_TILE); - dpb = decoder->dp_buf.no_of_dec_pic_buf; - DDL_MSG_LOW("%s Decoder num DPB buffers = %u Luma Size = %u", - __func__, dpb, luma_size); - if (dpb > DDL_MAX_BUFFER_COUNT) - dpb = DDL_MAX_BUFFER_COUNT; - for (i = 0; i < dpb; i++) { - if (!(res_trk_check_for_sec_session()) && - frame[i].vcd_frm.virtual) { - if (luma_size <= frame[i].vcd_frm.alloc_len) { - memset(frame[i].vcd_frm.virtual, - 0x10101010, luma_size); - memset(frame[i].vcd_frm.virtual + luma_size, - 0x80808080, - frame[i].vcd_frm.alloc_len - luma_size); - if (frame[i].vcd_frm.ion_flag - == ION_FLAG_CACHED) { - msm_ion_do_cache_op( - ddl_context->video_ion_client, - frame[i].vcd_frm.buff_ion_handle, - (unsigned long *)frame[i]. - vcd_frm.virtual, - (unsigned long)frame[i]. - vcd_frm.alloc_len, - ION_IOC_CLEAN_INV_CACHES); - } - } else { - DDL_MSG_ERROR("luma size error"); - return VCD_ERR_FAIL; - } - } - - luma[i] = DDL_OFFSET(ddl_context->dram_base_a. - align_physical_addr, frame[i].vcd_frm.physical); - chroma[i] = luma[i] + luma_size; - DDL_MSG_LOW("%s Decoder Luma address = %x Chroma address = %x", - __func__, luma[i], chroma[i]); - } - switch (decoder->codec.codec) { - case VCD_CODEC_MPEG1: - case VCD_CODEC_MPEG2: - vidc_1080p_set_decode_recon_buffers(dpb, luma, chroma); - break; - case VCD_CODEC_DIVX_3: - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_XVID: - case VCD_CODEC_MPEG4: - vidc_1080p_set_decode_recon_buffers(dpb, luma, chroma); - vidc_1080p_set_mpeg4_divx_decode_work_buffers( - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->nb_dcac), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->upnb_mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->sub_anchor_mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->overlay_xform), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->stx_parser)); - break; - case VCD_CODEC_H263: - vidc_1080p_set_decode_recon_buffers(dpb, luma, chroma); - vidc_1080p_set_h263_decode_work_buffers( - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->nb_dcac), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->upnb_mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->sub_anchor_mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->overlay_xform)); - break; - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - vidc_1080p_set_decode_recon_buffers(dpb, luma, chroma); - vidc_1080p_set_vc1_decode_work_buffers( - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->nb_dcac), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->upnb_mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->sub_anchor_mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->overlay_xform), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->bit_plane1), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->bit_plane2), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->bit_plane3)); - break; - case VCD_CODEC_H264: - for (i = 0; i < dpb; i++) - mv[i] = DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->h264_mv[i]); - vidc_1080p_set_h264_decode_buffers(dpb, - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->h264_vert_nb_mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->h264_nb_ip), - luma, chroma, mv); - break; - default: - break; - } - return VCD_S_SUCCESS; -} - -void ddl_release_context_buffers(struct ddl_context *ddl_context) -{ - ddl_pmem_free(&ddl_context->metadata_shared_input); - ddl_fw_release(&ddl_context->dram_base_a); -} - -void ddl_release_client_internal_buffers(struct ddl_client_context *ddl) -{ - if (ddl->decoding) { - struct ddl_decoder_data *decoder = - &(ddl->codec_data.decoder); - kfree(decoder->dp_buf.dec_pic_buffers); - decoder->dp_buf.dec_pic_buffers = NULL; - ddl_vidc_decode_dynamic_property(ddl, false); - decoder->decode_config.sequence_header_len = 0; - decoder->decode_config.sequence_header = NULL; - decoder->dpb_mask.client_mask = 0; - decoder->dpb_mask.hw_mask = 0; - decoder->dp_buf.no_of_dec_pic_buf = 0; - decoder->dynamic_prop_change = 0; - ddl_free_dec_hw_buffers(ddl); - } else { - struct ddl_encoder_data *encoder = - &(ddl->codec_data.encoder); - ddl_pmem_free(&encoder->seq_header); - ddl_pmem_free(&encoder->batch_frame.slice_batch_in); - ddl_pmem_free(&encoder->batch_frame.slice_batch_out); - ddl_vidc_encode_dynamic_property(ddl, false); - encoder->dynamic_prop_change = 0; - ddl_free_enc_hw_buffers(ddl); - ddl_free_ltr_list(&encoder->ltr_control); - } - ddl_pmem_free(&ddl->shared_mem[0]); - ddl_pmem_free(&ddl->shared_mem[1]); -} - -u32 ddl_codec_type_transact(struct ddl_client_context *ddl, - u32 remove, enum vcd_codec requested_codec) -{ - if (requested_codec > VCD_CODEC_VC1_RCV || - requested_codec < VCD_CODEC_H264) - return false; - if (!ddl->decoding && requested_codec != VCD_CODEC_MPEG4 && - requested_codec != VCD_CODEC_H264 && - requested_codec != VCD_CODEC_H263) - return false; - - return true; -} - -u32 ddl_take_command_channel(struct ddl_context *ddl_context, - struct ddl_client_context *ddl, void *client_data) -{ - u32 status = true; - - if (!ddl_context->current_ddl[0]) { - ddl_context->current_ddl[0] = ddl; - ddl->client_data = client_data; - ddl->command_channel = 0; - } else if (!ddl_context->current_ddl[1]) { - ddl_context->current_ddl[1] = ddl; - ddl->client_data = client_data; - ddl->command_channel = 1; - } else - status = false; - if (status) { - if (ddl_context->current_ddl[0] && - ddl_context->current_ddl[1]) - DDL_BUSY(ddl_context); - else - DDL_RUN(ddl_context); - } - return status; -} - -void ddl_release_command_channel(struct ddl_context *ddl_context, - u32 command_channel) -{ - ddl_context->current_ddl[command_channel]->client_data = NULL; - ddl_context->current_ddl[command_channel] = NULL; - if (!ddl_context->current_ddl[0] && - !ddl_context->current_ddl[1]) - DDL_IDLE(ddl_context); - else - DDL_RUN(ddl_context); -} - -struct ddl_client_context *ddl_get_current_ddl_client_for_channel_id( - struct ddl_context *ddl_context, u32 channel_id) -{ - struct ddl_client_context *ddl; - - if (ddl_context->current_ddl[0] && channel_id == - ddl_context->current_ddl[0]->command_channel) - ddl = ddl_context->current_ddl[0]; - else if (ddl_context->current_ddl[1] && channel_id == - ddl_context->current_ddl[1]->command_channel) - ddl = ddl_context->current_ddl[1]; - else { - DDL_MSG_LOW("STATE-CRITICAL-FRMRUN"); - DDL_MSG_LOW("Unexpected channel ID = %d", channel_id); - ddl = NULL; - } - return ddl; -} - -struct ddl_client_context *ddl_get_current_ddl_client_for_command( - struct ddl_context *ddl_context, - enum ddl_cmd_state cmd_state) -{ - struct ddl_client_context *ddl; - - if (ddl_context->current_ddl[0] && - cmd_state == ddl_context->current_ddl[0]->cmd_state) - ddl = ddl_context->current_ddl[0]; - else if (ddl_context->current_ddl[1] && - cmd_state == ddl_context->current_ddl[1]->cmd_state) - ddl = ddl_context->current_ddl[1]; - else { - DDL_MSG_LOW("STATE-CRITICAL-FRMRUN"); - DDL_MSG_ERROR("Error: Unexpected cmd_state = %d", - cmd_state); - ddl = NULL; - } - return ddl; -} - -u32 ddl_get_yuv_buf_size(u32 width, u32 height, u32 format) -{ - u32 mem_size, width_round_up, height_round_up, align; - - width_round_up = width; - height_round_up = height; - align = SZ_4K; - - if (format == DDL_YUV_BUF_TYPE_TILE) { - width_round_up = DDL_ALIGN(width, DDL_TILE_ALIGN_WIDTH); - height_round_up = DDL_ALIGN(height, DDL_TILE_ALIGN_HEIGHT); - align = DDL_TILE_MULTIPLY_FACTOR; - } - if (format == DDL_YUV_BUF_TYPE_LINEAR) { - width_round_up = DDL_ALIGN(width, DDL_LINEAR_ALIGN_WIDTH); - align = DDL_LINEAR_MULTIPLY_FACTOR; - } - mem_size = (width_round_up * height_round_up); - mem_size = DDL_ALIGN(mem_size, align); - return mem_size; -} -void ddl_free_dec_hw_buffers(struct ddl_client_context *ddl) -{ - struct ddl_dec_buffers *dec_bufs = - &ddl->codec_data.decoder.hw_bufs; - ddl_pmem_free(&dec_bufs->h264_nb_ip); - ddl_pmem_free(&dec_bufs->h264_vert_nb_mv); - ddl_pmem_free(&dec_bufs->nb_dcac); - ddl_pmem_free(&dec_bufs->upnb_mv); - ddl_pmem_free(&dec_bufs->sub_anchor_mv); - ddl_pmem_free(&dec_bufs->overlay_xform); - ddl_pmem_free(&dec_bufs->bit_plane3); - ddl_pmem_free(&dec_bufs->bit_plane2); - ddl_pmem_free(&dec_bufs->bit_plane1); - ddl_pmem_free(&dec_bufs->stx_parser); - ddl_pmem_free(&dec_bufs->desc); - ddl_pmem_free(&dec_bufs->context); - ddl_pmem_free(&dec_bufs->extnuserdata); - memset(dec_bufs, 0, sizeof(struct ddl_dec_buffers)); -} - -void ddl_free_enc_hw_buffers(struct ddl_client_context *ddl) -{ - struct ddl_enc_buffers *enc_bufs = - &ddl->codec_data.encoder.hw_bufs; - u32 i; - - for (i = 0; i < enc_bufs->dpb_count; i++) { - ddl_pmem_free(&enc_bufs->dpb_y[i]); - ddl_pmem_free(&enc_bufs->dpb_c[i]); - } - ddl_pmem_free(&enc_bufs->mv); - ddl_pmem_free(&enc_bufs->col_zero); - ddl_pmem_free(&enc_bufs->md); - ddl_pmem_free(&enc_bufs->pred); - ddl_pmem_free(&enc_bufs->nbor_info); - ddl_pmem_free(&enc_bufs->acdc_coef); - ddl_pmem_free(&enc_bufs->context); - memset(enc_bufs, 0, sizeof(struct ddl_enc_buffers)); -} - -u32 ddl_get_input_frame_from_pool(struct ddl_client_context *ddl, - u8 *input_buffer_address) -{ - u32 vcd_status = VCD_S_SUCCESS, i, found = false; - - for (i = 0; i < DDL_MAX_NUM_IN_INPUTFRAME_POOL && !found; i++) { - if (input_buffer_address == - ddl->input_frame_pool[i].vcd_frm.physical) { - found = true; - ddl->input_frame = ddl->input_frame_pool[i]; - memset(&ddl->input_frame_pool[i], 0, - sizeof(struct ddl_frame_data_tag)); - } - } - if (!found) - vcd_status = VCD_ERR_FAIL; - - return vcd_status; -} - -u32 ddl_insert_input_frame_to_pool(struct ddl_client_context *ddl, - struct ddl_frame_data_tag *ddl_input_frame) -{ - u32 vcd_status = VCD_S_SUCCESS, i, found = false; - - for (i = 0; i < DDL_MAX_NUM_IN_INPUTFRAME_POOL && !found; i++) { - if (!ddl->input_frame_pool[i].vcd_frm.physical) { - found = true; - ddl->input_frame_pool[i] = *ddl_input_frame; - } - } - if (!found) - vcd_status = VCD_ERR_FAIL; - - return vcd_status; -} - -void ddl_calc_dec_hw_buffers_size(enum vcd_codec codec, u32 width, - u32 height, u32 dpb, struct ddl_dec_buffer_size *buf_size) -{ - u32 sz_dpb0 = 0, sz_dpb1 = 0, sz_mv = 0; - u32 sz_luma = 0, sz_chroma = 0, sz_nb_dcac = 0, sz_upnb_mv = 0; - u32 sz_sub_anchor_mv = 0, sz_overlap_xform = 0, sz_bit_plane3 = 0; - u32 sz_bit_plane2 = 0, sz_bit_plane1 = 0, sz_stx_parser = 0; - u32 sz_desc, sz_cpb, sz_context, sz_vert_nb_mv = 0, sz_nb_ip = 0; - u32 sz_extnuserdata = 0; - - if (codec == VCD_CODEC_H264) { - sz_mv = ddl_get_yuv_buf_size(width, - height>>2, DDL_YUV_BUF_TYPE_TILE); - sz_nb_ip = DDL_KILO_BYTE(32); - sz_vert_nb_mv = DDL_KILO_BYTE(16); - } else { - if ((codec == VCD_CODEC_MPEG4) || - (codec == VCD_CODEC_DIVX_3) || - (codec == VCD_CODEC_DIVX_4) || - (codec == VCD_CODEC_DIVX_5) || - (codec == VCD_CODEC_DIVX_6) || - (codec == VCD_CODEC_XVID) || - (codec == VCD_CODEC_H263)) { - sz_nb_dcac = DDL_KILO_BYTE(16); - sz_upnb_mv = DDL_KILO_BYTE(68); - sz_sub_anchor_mv = DDL_KILO_BYTE(136); - sz_overlap_xform = DDL_KILO_BYTE(32); - if (codec != VCD_CODEC_H263) - sz_stx_parser = DDL_KILO_BYTE(68); - } else if ((codec == VCD_CODEC_VC1) || - (codec == VCD_CODEC_VC1_RCV)) { - sz_nb_dcac = DDL_KILO_BYTE(16); - sz_upnb_mv = DDL_KILO_BYTE(68); - sz_sub_anchor_mv = DDL_KILO_BYTE(136); - sz_overlap_xform = DDL_KILO_BYTE(32); - sz_bit_plane3 = DDL_KILO_BYTE(2); - sz_bit_plane2 = DDL_KILO_BYTE(2); - sz_bit_plane1 = DDL_KILO_BYTE(2); - } else if (codec == VCD_CODEC_MPEG2) - sz_extnuserdata = DDL_KILO_BYTE(2); - } - sz_desc = DDL_KILO_BYTE(128); - sz_cpb = VCD_DEC_CPB_SIZE; - if (codec == VCD_CODEC_H264) - sz_context = DDL_FW_H264DEC_CONTEXT_SPACE_SIZE; - else - sz_context = DDL_FW_OTHER_CONTEXT_SPACE_SIZE; - if (buf_size) { - buf_size->sz_dpb0 = sz_dpb0; - buf_size->sz_dpb1 = sz_dpb1; - buf_size->sz_mv = sz_mv; - buf_size->sz_vert_nb_mv = sz_vert_nb_mv; - buf_size->sz_nb_ip = sz_nb_ip; - buf_size->sz_luma = sz_luma; - buf_size->sz_chroma = sz_chroma; - buf_size->sz_nb_dcac = sz_nb_dcac; - buf_size->sz_upnb_mv = sz_upnb_mv; - buf_size->sz_sub_anchor_mv = sz_sub_anchor_mv; - buf_size->sz_overlap_xform = sz_overlap_xform; - buf_size->sz_bit_plane3 = sz_bit_plane3; - buf_size->sz_bit_plane2 = sz_bit_plane2; - buf_size->sz_bit_plane1 = sz_bit_plane1; - buf_size->sz_stx_parser = sz_stx_parser; - buf_size->sz_desc = sz_desc; - buf_size->sz_cpb = sz_cpb; - buf_size->sz_context = sz_context; - buf_size->sz_extnuserdata = sz_extnuserdata; - } -} - -u32 ddl_allocate_dec_hw_buffers(struct ddl_client_context *ddl) -{ - struct ddl_dec_buffers *dec_bufs; - struct ddl_dec_buffer_size buf_size; - u32 status = VCD_S_SUCCESS, dpb = 0; - u32 width = 0, height = 0; - u8 *ptr; - struct ddl_context *ddl_context = ddl->ddl_context; - - dec_bufs = &ddl->codec_data.decoder.hw_bufs; - ddl_calc_dec_hw_buffers_size(ddl->codec_data.decoder. - codec.codec, width, height, dpb, &buf_size); - if (buf_size.sz_context > 0) { - dec_bufs->context.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->context, buf_size.sz_context, - DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - else - msm_ion_do_cache_op(ddl_context->video_ion_client, - dec_bufs->context.alloc_handle, - dec_bufs->context.virtual_base_addr, - dec_bufs->context.buffer_size, - ION_IOC_CLEAN_INV_CACHES); - } - if (buf_size.sz_nb_ip > 0) { - dec_bufs->h264_nb_ip.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->h264_nb_ip, buf_size.sz_nb_ip, - DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_vert_nb_mv > 0) { - dec_bufs->h264_vert_nb_mv.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->h264_vert_nb_mv, - buf_size.sz_vert_nb_mv, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_nb_dcac > 0) { - dec_bufs->nb_dcac.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->nb_dcac, buf_size.sz_nb_dcac, - DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_upnb_mv > 0) { - dec_bufs->upnb_mv.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->upnb_mv, buf_size.sz_upnb_mv, - DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_sub_anchor_mv > 0) { - dec_bufs->sub_anchor_mv.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->sub_anchor_mv, - buf_size.sz_sub_anchor_mv, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_overlap_xform > 0) { - dec_bufs->overlay_xform.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->overlay_xform, - buf_size.sz_overlap_xform, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_bit_plane3 > 0) { - dec_bufs->bit_plane3.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->bit_plane3, - buf_size.sz_bit_plane3, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_bit_plane2 > 0) { - dec_bufs->bit_plane2.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->bit_plane2, - buf_size.sz_bit_plane2, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_bit_plane1 > 0) { - dec_bufs->bit_plane1.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->bit_plane1, - buf_size.sz_bit_plane1, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_stx_parser > 0) { - dec_bufs->stx_parser.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->stx_parser, - buf_size.sz_stx_parser, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - } - if (buf_size.sz_desc > 0) { - dec_bufs->desc.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->desc, buf_size.sz_desc, - DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - else { - if (!res_trk_check_for_sec_session()) { - memset(dec_bufs->desc.align_virtual_addr, - 0, buf_size.sz_desc); - msm_ion_do_cache_op( - ddl_context->video_ion_client, - dec_bufs->desc.alloc_handle, - dec_bufs->desc.virtual_base_addr, - dec_bufs->desc.buffer_size, - ION_IOC_CLEAN_INV_CACHES); - } - } - } - if (buf_size.sz_extnuserdata > 0) { - dec_bufs->extnuserdata.mem_type = DDL_CMD_MEM; - ptr = ddl_pmem_alloc(&dec_bufs->extnuserdata, - buf_size.sz_extnuserdata, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_free_exit; - else - memset(dec_bufs->extnuserdata.align_virtual_addr, - 0, buf_size.sz_extnuserdata); - } - return status; -fail_free_exit: - status = VCD_ERR_ALLOC_FAIL; - ddl_free_dec_hw_buffers(ddl); - return status; -} - -u32 ddl_calc_enc_hw_buffers_size(enum vcd_codec codec, u32 width, - u32 height, enum vcd_yuv_buffer_format input_format, - struct ddl_client_context *ddl, - struct ddl_enc_buffer_size *buf_size) -{ - u32 status = VCD_S_SUCCESS, mb_x, mb_y; - u32 sz_cur_y, sz_cur_c, sz_dpb_y, sz_dpb_c, sz_strm = 0, sz_mv; - u32 sz_md = 0, sz_pred = 0, sz_nbor_info = 0 , sz_acdc_coef = 0; - u32 sz_mb_info = 0, sz_context, sz_col_zero = 0; - - mb_x = (width + 15) / 16; - mb_y = (height + 15) / 16; - sz_dpb_y = ddl_get_yuv_buf_size(width, - height, DDL_YUV_BUF_TYPE_TILE); - sz_dpb_c = ddl_get_yuv_buf_size(width, height>>1, - DDL_YUV_BUF_TYPE_TILE); - if (input_format == - VCD_BUFFER_FORMAT_NV12_16M2KA) { - sz_cur_y = ddl_get_yuv_buf_size(width, height, - DDL_YUV_BUF_TYPE_LINEAR); - sz_cur_c = ddl_get_yuv_buf_size(width, height>>1, - DDL_YUV_BUF_TYPE_LINEAR); - } else if (VCD_BUFFER_FORMAT_TILE_4x2 == input_format) { - sz_cur_y = sz_dpb_y; - sz_cur_c = sz_dpb_c; - } else - status = VCD_ERR_NOT_SUPPORTED; - sz_context = DDL_FW_OTHER_CONTEXT_SPACE_SIZE; - if (!status) { - sz_strm = DDL_ALIGN(ddl_get_yuv_buf_size(width, height, - DDL_YUV_BUF_TYPE_LINEAR) + ddl_get_yuv_buf_size(width, - height/2, DDL_YUV_BUF_TYPE_LINEAR), DDL_KILO_BYTE(4)); - sz_mv = DDL_ALIGN(2 * mb_x * 8, DDL_KILO_BYTE(2)); - if ((codec == VCD_CODEC_MPEG4) || - (codec == VCD_CODEC_H264)) { - sz_col_zero = DDL_ALIGN(((mb_x * mb_y + 7) / 8) * - 8, DDL_KILO_BYTE(2)); - } - if ((codec == VCD_CODEC_MPEG4) || - (codec == VCD_CODEC_H263)) { - sz_acdc_coef = DDL_ALIGN((width / 2) * 8, - DDL_KILO_BYTE(2)); - } else if (codec == VCD_CODEC_H264) { - sz_md = DDL_ALIGN(mb_x * 48, DDL_KILO_BYTE(2)); - sz_pred = DDL_ALIGN(2 * 8 * 1024, DDL_KILO_BYTE(2)); - sz_context = DDL_FW_H264ENC_CONTEXT_SPACE_SIZE; - if (ddl) { - if (ddl->codec_data.encoder. - entropy_control.entropy_sel == - VCD_ENTROPY_SEL_CAVLC) - sz_nbor_info = DDL_ALIGN(8 * 8 * mb_x, - DDL_KILO_BYTE(2)); - else if (ddl->codec_data.encoder. - entropy_control.entropy_sel == - VCD_ENTROPY_SEL_CABAC) - sz_nbor_info = DDL_ALIGN(8 * 24 * - mb_x, DDL_KILO_BYTE(2)); - if ((ddl->codec_data.encoder. - mb_info_enable) && - (codec == VCD_CODEC_H264)) { - sz_mb_info = DDL_ALIGN(mb_x * mb_y * - 6 * 8, DDL_KILO_BYTE(2)); - } - } - } else { - sz_nbor_info = DDL_ALIGN(8 * 24 * mb_x, - DDL_KILO_BYTE(2)); - sz_mb_info = DDL_ALIGN(mb_x * mb_y * 6 * 8, - DDL_KILO_BYTE(2)); - } - if (buf_size) { - buf_size->sz_cur_y = sz_cur_y; - buf_size->sz_cur_c = sz_cur_c; - buf_size->sz_dpb_y = sz_dpb_y; - buf_size->sz_dpb_c = sz_dpb_c; - buf_size->sz_strm = sz_strm; - buf_size->sz_mv = sz_mv; - buf_size->sz_col_zero = sz_col_zero; - buf_size->sz_md = sz_md; - buf_size->sz_pred = sz_pred; - buf_size->sz_nbor_info = sz_nbor_info; - buf_size->sz_acdc_coef = sz_acdc_coef; - buf_size->sz_mb_info = sz_mb_info; - buf_size->sz_context = sz_context; - } - } - return status; -} - -u32 ddl_allocate_enc_hw_buffers(struct ddl_client_context *ddl) -{ - struct ddl_enc_buffers *enc_bufs; - struct ddl_enc_buffer_size buf_size; - void *ptr; - u32 status = VCD_S_SUCCESS; - struct ddl_context *ddl_context = ddl->ddl_context; - - enc_bufs = &ddl->codec_data.encoder.hw_bufs; - enc_bufs->dpb_count = DDL_ENC_MIN_DPB_BUFFERS; - - if ((ddl->codec_data.encoder.i_period.b_frames > - DDL_MIN_NUM_OF_B_FRAME) || - (ddl->codec_data.encoder.num_references_for_p_frame - > DDL_MIN_NUM_REF_FOR_P_FRAME)) - enc_bufs->dpb_count = DDL_ENC_MAX_DPB_BUFFERS; - DDL_MSG_HIGH("Encoder num DPB buffers allocated = %d", - enc_bufs->dpb_count); - - status = ddl_calc_enc_hw_buffers_size( - ddl->codec_data.encoder.codec.codec, - ddl->codec_data.encoder.frame_size.width, - ddl->codec_data.encoder.frame_size.height, - ddl->codec_data.encoder.buf_format.buffer_format, - ddl, &buf_size); - buf_size.sz_strm = ddl->codec_data.encoder. - client_output_buf_req.sz; - if (!status) { - enc_bufs->sz_dpb_y = buf_size.sz_dpb_y; - enc_bufs->sz_dpb_c = buf_size.sz_dpb_c; - if (buf_size.sz_mv > 0) { - enc_bufs->mv.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->mv, buf_size.sz_mv, - DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - } - if (buf_size.sz_col_zero > 0) { - enc_bufs->col_zero.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->col_zero, - buf_size.sz_col_zero, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - } - if (buf_size.sz_md > 0) { - enc_bufs->md.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->md, buf_size.sz_md, - DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - } - if (buf_size.sz_pred > 0) { - enc_bufs->pred.mem_type = - res_trk_check_for_sec_session() ? - DDL_MM_MEM : DDL_FW_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->pred, - buf_size.sz_pred, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - } - if (buf_size.sz_nbor_info > 0) { - enc_bufs->nbor_info.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->nbor_info, - buf_size.sz_nbor_info, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - } - if (buf_size.sz_acdc_coef > 0) { - enc_bufs->acdc_coef.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->acdc_coef, - buf_size.sz_acdc_coef, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - } - if (buf_size.sz_mb_info > 0) { - enc_bufs->mb_info.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->mb_info, - buf_size.sz_mb_info, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - } - if (buf_size.sz_context > 0) { - enc_bufs->context.mem_type = DDL_MM_MEM; - ptr = ddl_pmem_alloc(&enc_bufs->context, - buf_size.sz_context, DDL_KILO_BYTE(2)); - if (!ptr) - goto fail_enc_free_exit; - else - msm_ion_do_cache_op( - ddl_context->video_ion_client, - enc_bufs->context.alloc_handle, - enc_bufs->context.virtual_base_addr, - enc_bufs->context.buffer_size, - ION_IOC_CLEAN_INV_CACHES); - } - } - return status; -fail_enc_free_exit: - status = VCD_ERR_ALLOC_FAIL; - ddl_free_enc_hw_buffers(ddl); - return status; -} - -void ddl_decoder_chroma_dpb_change(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct ddl_frame_data_tag *frame = - &(decoder->dp_buf.dec_pic_buffers[0]); - u32 luma[DDL_MAX_BUFFER_COUNT]; - u32 chroma[DDL_MAX_BUFFER_COUNT]; - u32 luma_size, i, dpb; - luma_size = decoder->dpb_buf_size.size_y; - dpb = decoder->dp_buf.no_of_dec_pic_buf; - DDL_MSG_HIGH("%s Decoder num DPB buffers = %u Luma Size = %u", - __func__, dpb, luma_size); - if (dpb > DDL_MAX_BUFFER_COUNT) - dpb = DDL_MAX_BUFFER_COUNT; - for (i = 0; i < dpb; i++) { - luma[i] = DDL_OFFSET( - ddl_context->dram_base_a.align_physical_addr, - frame[i].vcd_frm.physical); - chroma[i] = luma[i] + luma_size; - DDL_MSG_LOW("%s Decoder Luma address = %x" - "Chroma address = %x", __func__, luma[i], chroma[i]); - } - vidc_1080p_set_decode_recon_buffers(dpb, luma, chroma); -} - -u32 ddl_check_reconfig(struct ddl_client_context *ddl) -{ - u32 need_reconfig = true; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - if (decoder->cont_mode) { - if ((decoder->actual_output_buf_req.sz <= - decoder->client_output_buf_req.sz) && - (decoder->actual_output_buf_req.actual_count <= - decoder->client_output_buf_req.actual_count)) { - need_reconfig = false; - if (decoder->min_dpb_num > - decoder->min_output_buf_req.min_count) { - decoder->min_output_buf_req = - decoder->actual_output_buf_req; - } - DDL_MSG_LOW("%s Decoder width = %u height = %u " - "Client width = %u height = %u\n", - __func__, decoder->frame_size.width, - decoder->frame_size.height, - decoder->client_frame_size.width, - decoder->client_frame_size.height); - } - } else { - if ((decoder->frame_size.width == - decoder->client_frame_size.width) && - (decoder->frame_size.height == - decoder->client_frame_size.height) && - (decoder->actual_output_buf_req.sz <= - decoder->client_output_buf_req.sz) && - (decoder->actual_output_buf_req.min_count == - decoder->client_output_buf_req.min_count) && - (decoder->actual_output_buf_req.actual_count == - decoder->client_output_buf_req.actual_count) && - (decoder->frame_size.scan_lines == - decoder->client_frame_size.scan_lines) && - (decoder->frame_size.stride == - decoder->client_frame_size.stride) && - decoder->progressive_only) - need_reconfig = false; - } - return need_reconfig; -} - -void ddl_handle_reconfig(u32 res_change, struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - if ((decoder->cont_mode) && - (res_change == DDL_RESL_CHANGE_DECREASED)) { - DDL_MSG_LOW("%s Resolution decreased, continue decoding\n", - __func__); - vidc_sm_get_min_yc_dpb_sizes( - &ddl->shared_mem[ddl->command_channel], - &decoder->dpb_buf_size.size_y, - &decoder->dpb_buf_size.size_c); - DDL_MSG_LOW(" %s Resolution decreased, size_y = %u" - " size_c = %u\n", - __func__, - decoder->dpb_buf_size.size_y, - decoder->dpb_buf_size.size_c); - ddl_decoder_chroma_dpb_change(ddl); - vidc_sm_set_chroma_addr_change( - &ddl->shared_mem[ddl->command_channel], - true); - ddl_vidc_decode_frame_run(ddl); - } else { - DDL_MSG_LOW("%s Resolution change, start realloc\n", - __func__); - decoder->reconfig_detected = true; - ddl->client_state = DDL_CLIENT_WAIT_FOR_EOS_DONE; - ddl->cmd_state = DDL_CMD_EOS; - vidc_1080p_frame_start_realloc(ddl->instance_id); - } -} - -void ddl_fill_dec_desc_buffer(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct vcd_frame_data *ip_bitstream = &(ddl->input_frame.vcd_frm); - struct ddl_buf_addr *dec_desc_buf = &(decoder->hw_bufs.desc); - - if (ip_bitstream->desc_buf && - ip_bitstream->desc_size < DDL_KILO_BYTE(128)) - memcpy(dec_desc_buf->align_virtual_addr, - ip_bitstream->desc_buf, - ip_bitstream->desc_size); -} - -void ddl_set_vidc_timeout(struct ddl_client_context *ddl) -{ - u32 vidc_time_out = 0; - s32 multiplier = 1; - u32 temp = DDL_VIDC_1080P_200MHZ_TIMEOUT_VALUE; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct vcd_frame_data *ip_bitstream = &(ddl->input_frame.vcd_frm); - - if (ddl->codec_data.decoder.idr_only_decoding) - vidc_time_out = 2 * DDL_VIDC_1080P_200MHZ_TIMEOUT_VALUE; - else { - vidc_time_out = DDL_VIDC_1080P_200MHZ_TIMEOUT_VALUE; - multiplier = decoder->yuv_size - (ip_bitstream->data_len + - (ip_bitstream->data_len / 2)); - if (multiplier <= 0) { - multiplier = decoder->yuv_size - ip_bitstream->data_len; - if (multiplier <= 0) { - if (ip_bitstream->data_len) - multiplier = - DDL_VIDC_1080P_MAX_TIMEOUT_MULTIPLIER; - } - } - if (multiplier == DDL_VIDC_1080P_MAX_TIMEOUT_MULTIPLIER) - vidc_time_out = vidc_time_out * - DDL_VIDC_1080P_MAX_TIMEOUT_MULTIPLIER; - else if (multiplier > 1) { - temp = (decoder->yuv_size * 1000) / multiplier; - temp = (temp * vidc_time_out) / 1000; - if (temp > (u32)(vidc_time_out * - DDL_VIDC_1080P_MAX_TIMEOUT_MULTIPLIER)) - vidc_time_out = vidc_time_out * - DDL_VIDC_1080P_MAX_TIMEOUT_MULTIPLIER; - else - vidc_time_out = temp; - } - } - DDL_MSG_LOW("%s Video core time out value = 0x%x", - __func__, vidc_time_out); - vidc_sm_set_video_core_timeout_value( - &ddl->shared_mem[ddl->command_channel], vidc_time_out); -} - -void ddl_handle_ltr_in_framedone(struct ddl_client_context *ddl) -{ - struct ddl_ltr_encoding_type *ltr_control = - &ddl->codec_data.encoder.ltr_control; - DDL_MSG_LOW("%s:", __func__); - if (ltr_control->storing) { - ltr_control->ltr_list[ltr_control->storing_idx].ltr_id = - ltr_control->curr_ltr_id; - DDL_MSG_MED("Encoder output stores LTR ID %d into entry %d", - ltr_control->curr_ltr_id, ltr_control->storing_idx); - ltr_control->meta_data_reqd = true; - ltr_control->storing = false; - } - ltr_control->out_frame_cnt_before_next_idr++; - if (ltr_control->out_frame_cnt_to_use_this_ltr) { - ltr_control->out_frame_cnt_to_use_this_ltr--; - if (!ltr_control->out_frame_cnt_to_use_this_ltr) - ddl_clear_ltr_list(ltr_control, true); - } -} - -s32 ddl_encoder_ltr_control(struct ddl_client_context *ddl) -{ - s32 vcd_status = VCD_S_SUCCESS; - struct ddl_encoder_data *encoder = &ddl->codec_data.encoder; - struct ddl_ltr_encoding_type *ltr_ctrl = &encoder->ltr_control; - bool intra_period_reached = false; - - DDL_MSG_LOW("%s:", __func__); - ddl_print_ltr_list(ltr_ctrl); - - if (DDL_IS_LTR_IN_AUTO_MODE(encoder)) { - bool finite_i_period, infinite_i_period; - DDL_MSG_LOW("%s: before LTR encoding: output "\ - "count before next IDR %d", __func__, - ltr_ctrl->out_frame_cnt_before_next_idr); - finite_i_period = - (DDL_MAX_P_FRAMES_IN_INTRA_INTERVAL != - encoder->i_period.p_frames) && - (!(ltr_ctrl->out_frame_cnt_before_next_idr % - (encoder->i_period.p_frames + 1))); - infinite_i_period = - ((DDL_MAX_P_FRAMES_IN_INTRA_INTERVAL == - encoder->i_period.p_frames) && - (!ltr_ctrl->out_frame_cnt_before_next_idr)); - if (finite_i_period || infinite_i_period) { - DDL_MSG_HIGH("%s: Intra period reached. "\ - "finite_i_period (%u), infinite_i_period (%u)", - __func__, (u32)finite_i_period, - (u32)infinite_i_period); - intra_period_reached = true; - } - if (intra_period_reached || - ltr_ctrl->store_for_intraframe_insertion || - encoder->intra_period_changed) { - ddl_clear_ltr_list(ltr_ctrl, false); - ltr_ctrl->out_frame_cnt_before_next_idr = 0; - ltr_ctrl->first_ltr_use_arvd = false; - ltr_ctrl->store_for_intraframe_insertion = false; - } else { - if (ltr_ctrl->first_ltr_use_arvd == false) { - ddl_use_ltr_from_list(ltr_ctrl, 0); - ltr_ctrl->out_frame_cnt_to_use_this_ltr = - 0xFFFFFFFF; - ltr_ctrl->use_ltr_reqd = true; - } - } - if (!(ltr_ctrl->out_frame_cnt_before_next_idr % - ltr_ctrl->ltr_period)) { - s32 idx; - DDL_MSG_HIGH("%s: reached LTR period "\ - "out_frame_cnt_before_next_idr %d", - __func__, ltr_ctrl->\ - out_frame_cnt_before_next_idr); - idx = ddl_find_oldest_ltr_not_in_use( - ltr_ctrl); - if (idx >= 0) { - ltr_ctrl->storing = true; - ltr_ctrl->storing_idx = idx; - if (idx == 0) - ltr_ctrl->store_ltr0 = true; - else if (idx == 1) - ltr_ctrl->store_ltr1 = true; - } - } - } - if (encoder->intra_frame_insertion) { - DDL_MSG_HIGH("%s: I-frame insertion requested, "\ - "delay LTR store for one frame", __func__); - ltr_ctrl->store_for_intraframe_insertion = true; - } - if (ltr_ctrl->pending_chg_ltr_useframes) { - ltr_ctrl->out_frame_cnt_to_use_this_ltr = - ltr_ctrl->ltr_use_frames; - ltr_ctrl->pending_chg_ltr_useframes = false; - } - if (ltr_ctrl->out_frame_cnt_to_use_this_ltr) - ltr_ctrl->use_ltr_reqd = true; - if (ltr_ctrl->use_ltr_reqd) { - s32 idx; - idx = ddl_find_ltr_in_use(ltr_ctrl); - if (idx == 0) - ltr_ctrl->use_ltr0 = true; - else if (idx == 1) - ltr_ctrl->use_ltr1 = true; - ltr_ctrl->using = true; - ltr_ctrl->use_ltr_reqd = false; - } else { - DDL_MSG_HIGH("%s: use_ltr_reqd skipped", __func__); - } - - return vcd_status; -} - - -s32 ddl_allocate_ltr_list(struct ddl_ltr_encoding_type *ltr_control) -{ - s32 vcd_status = VCD_S_SUCCESS; - - DDL_MSG_LOW("%s: lrr_cout = %u", __func__, ltr_control->ltr_count); - if (!ltr_control->ltr_list) { - if (ltr_control->ltr_count) { - ltr_control->ltr_list = (struct ddl_ltrlist *) - kmalloc(sizeof(struct ddl_ltrlist)* - ltr_control->ltr_count, GFP_KERNEL); - if (!ltr_control->ltr_list) { - DDL_MSG_ERROR("ddl_allocate_ltr_list failed"); - vcd_status = VCD_ERR_ALLOC_FAIL; - } - } else { - DDL_MSG_ERROR("%s: failed, zero LTR count", __func__); - vcd_status = VCD_ERR_FAIL; - } - } else { - DDL_MSG_HIGH("WARN: ltr_list already allocated"); - } - - return vcd_status; -} - -s32 ddl_free_ltr_list(struct ddl_ltr_encoding_type *ltr_control) -{ - s32 vcd_status = VCD_S_SUCCESS; - - DDL_MSG_LOW("%s:", __func__); - kfree(ltr_control->ltr_list); - ltr_control->ltr_list = NULL; - - return vcd_status; -} - -s32 ddl_clear_ltr_list(struct ddl_ltr_encoding_type *ltr_control, - bool only_use_flag) -{ - s32 vcd_status = VCD_S_SUCCESS; - u32 i; - - DDL_MSG_LOW("%s:", __func__); - for (i = 0; i < ltr_control->ltr_count; i++) { - ltr_control->ltr_list[i].ltr_in_use = false; - if (!only_use_flag) - ltr_control->ltr_list[i].ltr_id = 0; - } - - return vcd_status; -} - -s32 ddl_find_oldest_ltr_not_in_use(struct ddl_ltr_encoding_type *ltr_control) -{ - s32 found_idx = -1; - u32 i; - - if (ltr_control->ltr_list) { - if (ltr_control->ltr_count == 1) - found_idx = 0; - else { - for (i = 0; i < ltr_control->ltr_count; i++) { - if ((ltr_control->ltr_list[i].ltr_in_use == - false) && (found_idx < 0)) { - found_idx = i; - } - if ((found_idx >= 0) && - (ltr_control->ltr_list[i].\ - ltr_in_use == false) && - (ltr_control->ltr_list[i].ltr_id < - ltr_control->ltr_list[found_idx].\ - ltr_id)) { - found_idx = i; - } - } - } - } - - DDL_MSG_LOW("%s: found_idx = %d", __func__, found_idx); - return found_idx; -} - -s32 ddl_find_ltr_in_use(struct ddl_ltr_encoding_type *ltr_control) -{ - s32 found_idx = -1; - u32 i; - - if (ltr_control->ltr_list) { - for (i = 0; i < ltr_control->ltr_count; i++) { - if (ltr_control->ltr_list[i].ltr_in_use == true) - found_idx = i; - } - } - - DDL_MSG_LOW("%s: found_idx = %d", __func__, found_idx); - return found_idx; -} - -s32 ddl_find_ltr_from_list(struct ddl_ltr_encoding_type *ltr_control, - u32 ltr_id) -{ - s32 found_idx = -1; - u32 i; - - if (ltr_control->ltr_list) { - for (i = 0; i < ltr_control->ltr_count; i++) { - if (ltr_control->ltr_list[i].ltr_id == ltr_id) { - found_idx = i; - break; - } - } - } else { - DDL_MSG_ERROR("%s: ltr_list is NULL", __func__); - } - - DDL_MSG_LOW("%s: found_idx = %d", __func__, found_idx); - return found_idx; -} - -s32 ddl_use_ltr_from_list(struct ddl_ltr_encoding_type *ltr_control, - u32 ltr_idx) -{ - s32 vcd_status = VCD_S_SUCCESS; - u32 i; - - DDL_MSG_LOW("%s: ltr_idx = %u", __func__, ltr_idx); - if (ltr_idx > ltr_control->ltr_count) { - DDL_MSG_ERROR("%s: fail, idx %d larger than "\ - "the list array count %d", __func__, - ltr_idx, ltr_control->ltr_count); - vcd_status = VCD_ERR_FAIL; - } else { - for (i = 0; i < ltr_control->ltr_count; i++) { - if (i == ltr_idx) - ltr_control->ltr_list[ltr_idx].ltr_in_use = - true; - else - ltr_control->ltr_list[i].ltr_in_use = false; - } - } - - return vcd_status; -} - -void ddl_encoder_use_ltr_fail_callback(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct ddl_context *ddl_context = ddl->ddl_context; - - DDL_MSG_ERROR("%s: LTR use failed, callback "\ - "requested with LTR ID %d", __func__, - encoder->ltr_control.failed_use_cmd.ltr_id); - - ddl_context->ddl_callback(VCD_EVT_IND_INFO_LTRUSE_FAILED, - VCD_ERR_ILLEGAL_PARM, - &(encoder->ltr_control.failed_use_cmd), - sizeof(struct vcd_property_ltruse_type), - (u32 *)ddl, - ddl->client_data); -} - -void ddl_print_ltr_list(struct ddl_ltr_encoding_type *ltr_control) -{ - u32 i; - - for (i = 0; i < ltr_control->ltr_count; i++) { - DDL_MSG_MED("%s: ltr_id: %d, ltr_in_use: %d", - __func__, ltr_control->ltr_list[i].ltr_id, - ltr_control->ltr_list[i].ltr_in_use); - } -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_interrupt_handler.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_interrupt_handler.c deleted file mode 100644 index 64cc570b312cffea65593dcc4a70c2077049a907..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_interrupt_handler.c +++ /dev/null @@ -1,2067 +0,0 @@ -/* Copyright (c) 2010-2013, 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 "vcd_ddl.h" -#include "vcd_ddl_shared_mem.h" -#include "vcd_ddl_metadata.h" -#include "vcd_res_tracker_api.h" -#include - -static void ddl_decoder_input_done_callback( - struct ddl_client_context *ddl, u32 frame_transact_end); -static u32 ddl_decoder_output_done_callback( - struct ddl_client_context *ddl, u32 frame_transact_end); -static u32 ddl_get_decoded_frame(struct vcd_frame_data *frame, - enum vidc_1080p_decode_frame frame_type); -static u32 ddl_get_encoded_frame(struct vcd_frame_data *frame, - enum vcd_codec codec, - enum vidc_1080p_encode_frame frame_type); -static void ddl_get_dec_profile_level(struct ddl_decoder_data *decoder, - u32 profile, u32 level); -static void ddl_handle_enc_frame_done(struct ddl_client_context *ddl, - u32 eos_present); -static void ddl_handle_slice_done_slice_batch(struct ddl_client_context *ddl); -static u32 ddl_handle_enc_frame_done_slice_mode( - struct ddl_client_context *ddl, u32 eos_present); -static void ddl_handle_enc_skipframe_slice_mode( - struct ddl_client_context *ddl, u32 eos_present); - -static void ddl_fw_status_done_callback(struct ddl_context *ddl_context) -{ - DDL_MSG_MED("ddl_fw_status_done_callback"); - if (!DDLCOMMAND_STATE_IS(ddl_context, DDL_CMD_DMA_INIT)) { - DDL_MSG_ERROR("UNKWN_DMADONE"); - } else { - DDL_MSG_LOW("FW_STATUS_DONE"); - vidc_1080p_set_host2risc_cmd(VIDC_1080P_HOST2RISC_CMD_SYS_INIT, - ddl_context->fw_memory_size, 0, 0, 0); - } -} - -static void ddl_sys_init_done_callback(struct ddl_context *ddl_context, - u32 fw_size) -{ - u32 vcd_status = VCD_S_SUCCESS; - u8 *fw_ver; - - DDL_MSG_MED("ddl_sys_init_done_callback"); - if (!DDLCOMMAND_STATE_IS(ddl_context, DDL_CMD_DMA_INIT)) { - DDL_MSG_ERROR("UNKNOWN_SYS_INIT_DONE"); - } else { - ddl_context->cmd_state = DDL_CMD_INVALID; - DDL_MSG_LOW("SYS_INIT_DONE"); - vidc_1080p_get_fw_version(&ddl_context->fw_version); - fw_ver = (u8 *)&ddl_context->fw_version; - DDL_MSG_ERROR("fw_version %x:%x:20%x", - fw_ver[1]&0xFF, fw_ver[0]&0xFF, fw_ver[2]&0xFF); - if (ddl_context->fw_memory_size >= fw_size) { - ddl_context->device_state = DDL_DEVICE_INITED; - vcd_status = VCD_S_SUCCESS; - } else - vcd_status = VCD_ERR_FAIL; - ddl_context->ddl_callback(VCD_EVT_RESP_DEVICE_INIT, - vcd_status, NULL, 0, NULL, - ddl_context->client_data); - DDL_IDLE(ddl_context); - } -} - -static void ddl_decoder_eos_done_callback( - struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - - if (!ddl->decoding) { - DDL_MSG_ERROR("STATE-CRITICAL-EOSDONE"); - ddl_client_fatal_cb(ddl); - } else { - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME; - DDL_MSG_LOW("EOS_DONE"); - ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE, - VCD_S_SUCCESS, NULL, 0, (u32 *)ddl, - ddl->client_data); - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } -} - -static u32 ddl_channel_set_callback(struct ddl_context *ddl_context, - u32 instance_id) -{ - struct ddl_client_context *ddl; - u32 ret = false; - - DDL_MSG_MED("ddl_channel_open_callback"); - ddl = ddl_get_current_ddl_client_for_command(ddl_context, - DDL_CMD_CHANNEL_SET); - if (ddl) { - ddl->cmd_state = DDL_CMD_INVALID; - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHDONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-CHSET"); - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } else { - DDL_MSG_LOW("CH_SET_DONE"); - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_INITCODEC", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_INITCODEC; - ddl->instance_id = instance_id; - if (ddl->decoding) { - ddl_calc_core_proc_time(__func__, - DEC_OP_TIME, ddl); - if (ddl->codec_data.decoder.header_in_start) - ddl_vidc_decode_init_codec(ddl); - else { - ddl_context->ddl_callback( - VCD_EVT_RESP_START, - VCD_S_SUCCESS, NULL, 0, - (u32 *)ddl, - ddl->client_data); - ddl_release_command_channel( - ddl_context, - ddl->command_channel); - ret = true; - } - } else - ddl_vidc_encode_init_codec(ddl); - } - } - return ret; -} - -static u32 ddl_encoder_seq_done_callback(struct ddl_context *ddl_context, - struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder; - - DDL_MSG_HIGH("ddl_encoder_seq_done_callback"); - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-INITCODEC"); - ddl_client_fatal_cb(ddl); - return true; - } - ddl_calc_core_proc_time(__func__, ENC_OP_TIME, ddl); - ddl->cmd_state = DDL_CMD_INVALID; - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_WAIT_FOR_FRAME", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME; - DDL_MSG_LOW("INIT_CODEC_DONE"); - encoder = &ddl->codec_data.encoder; - vidc_1080p_get_encoder_sequence_header_size( - &encoder->seq_header_length); - ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS, - NULL, 0, (u32 *) ddl, ddl->client_data); - ddl_release_command_channel(ddl_context, - ddl->command_channel); - return true; -} - -static void parse_hdr_size_data(struct ddl_client_context *ddl, - struct vidc_1080p_seq_hdr_info *seq_hdr_info) -{ - u32 progressive; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - if (decoder->output_order == VCD_DEC_ORDER_DISPLAY) { - decoder->frame_size.width = seq_hdr_info->img_size_x; - decoder->frame_size.height = seq_hdr_info->img_size_y; - progressive = seq_hdr_info->disp_progressive; - } else { - vidc_sm_get_dec_order_resl( - &ddl->shared_mem[ddl->command_channel], - &decoder->frame_size.width, - &decoder->frame_size.height); - progressive = seq_hdr_info->dec_progressive; - } - decoder->yuv_size = decoder->frame_size.width * - decoder->frame_size.height; - decoder->yuv_size += decoder->yuv_size / 2; - decoder->min_dpb_num = seq_hdr_info->min_num_dpb; - vidc_sm_get_min_yc_dpb_sizes( - &ddl->shared_mem[ddl->command_channel], - &seq_hdr_info->min_luma_dpb_size, - &seq_hdr_info->min_chroma_dpb_size); - decoder->y_cb_cr_size = seq_hdr_info->min_luma_dpb_size + - seq_hdr_info->min_chroma_dpb_size; - decoder->dpb_buf_size.size_yuv = decoder->y_cb_cr_size; - decoder->dpb_buf_size.size_y = - seq_hdr_info->min_luma_dpb_size; - decoder->dpb_buf_size.size_c = - seq_hdr_info->min_chroma_dpb_size; - decoder->progressive_only = progressive ? false : true; -} - -static void parse_hdr_crop_data(struct ddl_client_context *ddl, - struct vidc_1080p_seq_hdr_info *seq_hdr_info) -{ - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - u32 crop_exists = (decoder->output_order == VCD_DEC_ORDER_DISPLAY) ? - seq_hdr_info->disp_crop_exists : seq_hdr_info->dec_crop_exists; - if (crop_exists) { - if (decoder->output_order == - VCD_DEC_ORDER_DISPLAY) - vidc_sm_get_crop_info( - &ddl->shared_mem[ddl->command_channel], - &seq_hdr_info->crop_left_offset, - &seq_hdr_info->crop_right_offset, - &seq_hdr_info->crop_top_offset, - &seq_hdr_info->crop_bottom_offset); - else - vidc_sm_get_dec_order_crop_info( - &ddl->shared_mem[ddl->command_channel], - &seq_hdr_info->crop_left_offset, - &seq_hdr_info->crop_right_offset, - &seq_hdr_info->crop_top_offset, - &seq_hdr_info->crop_bottom_offset); - decoder->frame_size.width -= - seq_hdr_info->crop_right_offset + - seq_hdr_info->crop_left_offset; - decoder->frame_size.height -= - seq_hdr_info->crop_top_offset + - seq_hdr_info->crop_bottom_offset; - } -} - -static u32 ddl_decoder_seq_done_callback(struct ddl_context *ddl_context, - struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct vidc_1080p_seq_hdr_info seq_hdr_info; - u32 process_further = true; - struct ddl_profile_info_type disp_profile_info; - - DDL_MSG_MED("ddl_decoder_seq_done_callback"); - if (!ddl->decoding || - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-HDDONE"); - ddl_client_fatal_cb(ddl); - } else { - ddl_calc_core_proc_time(__func__, DEC_OP_TIME, ddl); - ddl->cmd_state = DDL_CMD_INVALID; - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_DPB", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_DPB; - DDL_MSG_LOW("HEADER_DONE"); - vidc_1080p_get_decode_seq_start_result(&seq_hdr_info); - parse_hdr_size_data(ddl, &seq_hdr_info); - decoder->mp2_datadump_status = 0; - vidc_sm_get_mp2datadump_status(&ddl->shared_mem - [ddl->command_channel], - &decoder->mp2_datadump_status); - if (res_trk_get_disable_fullhd() && - (seq_hdr_info.img_size_x * seq_hdr_info.img_size_y > - 1280 * 720)) { - DDL_MSG_ERROR("FATAL:Resolution greater than 720P HD"); - ddl_client_fatal_cb(ddl); - return process_further; - } - if (!seq_hdr_info.img_size_x || !seq_hdr_info.img_size_y) { - DDL_MSG_ERROR("FATAL:ZeroImageSize"); - ddl_client_fatal_cb(ddl); - return process_further; - } - vidc_sm_get_profile_info(&ddl->shared_mem - [ddl->command_channel], &disp_profile_info); - seq_hdr_info.profile = disp_profile_info.pic_profile; - seq_hdr_info.level = disp_profile_info.pic_level; - ddl_get_dec_profile_level(decoder, seq_hdr_info.profile, - seq_hdr_info.level); - switch (decoder->codec.codec) { - case VCD_CODEC_H264: - if (decoder->profile.profile == VCD_PROFILE_H264_HIGH || - decoder->profile.profile == - VCD_PROFILE_UNKNOWN) { - if ((disp_profile_info.chroma_format_idc > - VIDC_1080P_IDCFORMAT_420) || - (disp_profile_info.bit_depth_luma_minus8 - || disp_profile_info. - bit_depth_chroma_minus8)) { - DDL_MSG_ERROR("Unsupported H.264 " - "feature: IDC format : %d, Bitdepth: %d", - disp_profile_info. - chroma_format_idc, - (disp_profile_info. - bit_depth_luma_minus8 - || disp_profile_info. - bit_depth_chroma_minus8)); - ddl_client_fatal_cb(ddl); - return process_further; - } - } - break; - case VCD_CODEC_MPEG4: - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_XVID: - if (seq_hdr_info.data_partition) - if ((seq_hdr_info.img_size_x * - seq_hdr_info.img_size_y) > (720 * 576)) { - DDL_MSG_ERROR("Unsupported DP clip"); - ddl_client_fatal_cb(ddl); - return process_further; - } - break; - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - if ((seq_hdr_info.img_size_x > - DDL_MAX_VC1_FRAME_WIDTH) || - (seq_hdr_info.img_size_y > - DDL_MAX_VC1_FRAME_HEIGHT)) { - DDL_MSG_ERROR("Unsupported VC1 clip: " - "Resolution X=%d and Y=%d", - seq_hdr_info.img_size_x, - seq_hdr_info.img_size_y); - ddl_client_fatal_cb(ddl); - return process_further; - } - break; - default: - break; - } - ddl_calculate_stride(&decoder->frame_size, - !decoder->progressive_only); - decoder->frame_size.scan_lines = - DDL_ALIGN(decoder->frame_size.height, DDL_TILE_ALIGN_HEIGHT); - decoder->frame_size.stride = - DDL_ALIGN(decoder->frame_size.width, DDL_TILE_ALIGN_WIDTH); - parse_hdr_crop_data(ddl, &seq_hdr_info); - if (decoder->codec.codec == VCD_CODEC_H264 && - seq_hdr_info.level > VIDC_1080P_H264_LEVEL4) { - DDL_MSG_ERROR("WARNING: H264MaxLevelExceeded : %d", - seq_hdr_info.level); - } - ddl_set_default_decoder_buffer_req(decoder, false); - if (decoder->header_in_start) { - if (!(decoder->cont_mode) || - (decoder->min_dpb_num > - decoder->client_output_buf_req.min_count) || - (decoder->actual_output_buf_req.sz > - decoder->client_output_buf_req.sz)) { - decoder->client_frame_size = - decoder->frame_size; - decoder->client_output_buf_req = - decoder->actual_output_buf_req; - decoder->client_input_buf_req = - decoder->actual_input_buf_req; - } - ddl_context->ddl_callback(VCD_EVT_RESP_START, - VCD_S_SUCCESS, NULL, 0, (u32 *) ddl, - ddl->client_data); - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } else { - u32 seq_hdr_only_frame = false; - u32 need_reconfig = false, eos_present = 0; - struct vcd_frame_data *input_vcd_frm = - &ddl->input_frame.vcd_frm; - need_reconfig = ddl_check_reconfig(ddl); - DDL_MSG_HIGH("%s : need_reconfig = %u\n", __func__, - need_reconfig); - if (((input_vcd_frm->flags & - VCD_FRAME_FLAG_CODECCONFIG) && - (!(input_vcd_frm->flags & - VCD_FRAME_FLAG_SYNCFRAME))) || - input_vcd_frm->data_len <= - seq_hdr_info.dec_frm_size) { - seq_hdr_only_frame = true; - input_vcd_frm->offset += - seq_hdr_info.dec_frm_size; - input_vcd_frm->data_len = 0; - eos_present = - input_vcd_frm->flags & VCD_FRAME_FLAG_EOS; - if (!eos_present) { - input_vcd_frm->flags |= - VCD_FRAME_FLAG_CODECCONFIG; - ddl->input_frame.frm_trans_end = - !need_reconfig; - ddl_context->ddl_callback( - VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, &ddl->input_frame, - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl->client_data); - } else { - input_vcd_frm->flags &= - ~(VCD_FRAME_FLAG_CODECCONFIG); - seq_hdr_only_frame = false; - pr_err("%s() Codec config buffer with eos\n", - __func__); - } - } else { - if (decoder->codec.codec == - VCD_CODEC_VC1_RCV) { - vidc_sm_set_start_byte_number( - &ddl->shared_mem - [ddl->command_channel], - seq_hdr_info.dec_frm_size); - } - } - if (need_reconfig) { - struct ddl_frame_data_tag *payload = - &ddl->input_frame; - u32 payload_size = - sizeof(struct ddl_frame_data_tag); - decoder->client_frame_size = - decoder->frame_size; - decoder->client_output_buf_req = - decoder->actual_output_buf_req; - decoder->client_input_buf_req = - decoder->actual_input_buf_req; - if (seq_hdr_only_frame) { - payload = NULL; - payload_size = 0; - } - DDL_MSG_HIGH("%s : sending port reconfig\n", - __func__); - ddl_context->ddl_callback( - VCD_EVT_IND_OUTPUT_RECONFIG, - VCD_S_SUCCESS, payload, - payload_size, (u32 *) ddl, - ddl->client_data); - } - if (!need_reconfig && !seq_hdr_only_frame) { - if (!ddl_vidc_decode_set_buffers(ddl)) - process_further = false; - else { - DDL_MSG_ERROR("ddl_vidc_decode_set_" - "buffers failed"); - ddl_client_fatal_cb(ddl); - } - } else - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } - } - return process_further; -} - -static u32 ddl_sequence_done_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - u32 channel_inst_id, ret; - - vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); - vidc_1080p_clear_returned_channel_inst_id(); - ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context, - ddl_context->response_cmd_ch_id); - if (!ddl) { - DDL_MSG_ERROR("UNKWN_SEQ_DONE"); - ret = true; - } else { - if (ddl->decoding) - ret = ddl_decoder_seq_done_callback(ddl_context, - ddl); - else - ret = ddl_encoder_seq_done_callback(ddl_context, - ddl); - } - return ret; -} - -static u32 ddl_dpb_buffers_set_done_callback( - struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - u32 channel_inst_id, ret_status = true; - - DDL_MSG_MED("ddl_dpb_buffers_set_done_callback"); - vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); - vidc_1080p_clear_returned_channel_inst_id(); - ddl = ddl_get_current_ddl_client_for_command(ddl_context, - DDL_CMD_DECODE_SET_DPB); - if (ddl) { - ddl->cmd_state = DDL_CMD_INVALID; - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPBDONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-DPBDONE"); - ddl_client_fatal_cb(ddl); - } else { - DDL_MSG_LOW("INTR_DPBDONE"); - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_FRAME", - ddl_get_state_string(ddl->client_state)); - ddl_calc_core_proc_time(__func__, DEC_OP_TIME, ddl); - ddl_reset_core_time_variables(DEC_OP_TIME); - ddl_vidc_decode_reset_avg_time(ddl); - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME; - ddl_vidc_decode_frame_run(ddl); - ret_status = false; - } - } - return ret_status; -} - -static u32 ddl_encoder_frame_run_callback( - struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = - &(ddl->codec_data.encoder); - struct vcd_frame_data *output_frame = - &(ddl->output_frame.vcd_frm); - u32 eos_present = false; - u32 status = true; - - DDL_MSG_MED("ddl_encoder_frame_run_callback\n"); - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-ENCFRMRUN"); - ddl_client_fatal_cb(ddl); - } else { - ddl_calc_core_proc_time(__func__, ENC_OP_TIME, ddl); - DDL_MSG_LOW("ENC_FRM_RUN_DONE"); - ddl->cmd_state = DDL_CMD_INVALID; - vidc_1080p_get_encode_frame_info(&encoder->enc_frame_info); - - if (encoder->meta_data_enable_flag) - vidc_sm_get_metadata_status(&ddl->shared_mem - [ddl->command_channel], - &encoder->enc_frame_info.meta_data_exists); - - if (VCD_FRAME_FLAG_EOS & ddl->input_frame.vcd_frm.flags) { - DDL_MSG_LOW("%s EOS detected\n", __func__); - eos_present = true; - } - - if (encoder->enc_frame_info.enc_frame_size || - (encoder->enc_frame_info.enc_frame == - VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)) { - if (encoder->slice_delivery_info.enable) { - if (encoder->enc_frame_info.enc_frame == - VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED) - ddl_handle_enc_skipframe_slice_mode( - ddl, eos_present); - else - status = - ddl_handle_enc_frame_done_slice_mode( - ddl, eos_present); - } else { - ddl_handle_enc_frame_done(ddl, eos_present); - } - if (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_EOS_DONE) && - encoder->i_period.b_frames) { - if ((ddl->extra_output_buf_count < 0) || - (ddl->extra_output_buf_count > - encoder->i_period.b_frames)) { - DDL_MSG_ERROR("Invalid B frame output" - "buffer index"); - } else { - struct vidc_1080p_enc_frame_start_param - enc_param; - ddl->output_frame = ddl->\ - extra_output_frame[ddl->\ - extra_output_buf_count]; - ddl->\ - extra_output_buf_count--; - output_frame = - &ddl->output_frame.\ - vcd_frm; - memset(&enc_param, 0, - sizeof(enc_param)); - enc_param.cmd_seq_num = - ++ddl_context->cmd_seq_num; - enc_param.inst_id = ddl->instance_id; - enc_param.shared_mem_addr_offset = - DDL_ADDR_OFFSET(ddl_context->\ - dram_base_a, ddl->shared_mem - [ddl->command_channel]); - enc_param.stream_buffer_addr_offset = - DDL_OFFSET(ddl_context->\ - dram_base_a.\ - align_physical_addr, - output_frame->physical); - enc_param.stream_buffer_size = - encoder->client_output_buf_req.sz; - enc_param.encode = - VIDC_1080P_ENC_TYPE_LAST_FRAME_DATA; - ddl->cmd_state = DDL_CMD_ENCODE_FRAME; - ddl_context->vidc_encode_frame_start - [ddl->command_channel] - (&enc_param); - } - } else if (eos_present && - encoder->slice_delivery_info.enable) { - ddl_vidc_encode_eos_run(ddl); - } else { - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_FRAME", - ddl_get_state_string( - ddl->client_state)); - ddl->client_state = - DDL_CLIENT_WAIT_FOR_FRAME; - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } - } else { - ddl_context->ddl_callback( - VCD_EVT_RESP_TRANSACTION_PENDING, - VCD_S_SUCCESS, NULL, 0, (u32 *)ddl, - ddl->client_data); - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_FRAME", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME; - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } - } - - return status; -} - -static void get_dec_status(struct ddl_client_context *ddl, - struct vidc_1080p_dec_disp_info *dec_disp_info, - u32 output_order, u32 *status, u32 *rsl_chg) -{ - if (output_order == VCD_DEC_ORDER_DISPLAY) { - vidc_1080p_get_display_frame_result(dec_disp_info); - *status = dec_disp_info->display_status; - *rsl_chg = dec_disp_info->disp_resl_change; - } else { - vidc_1080p_get_decode_frame_result(dec_disp_info); - vidc_sm_get_dec_order_resl( - &ddl->shared_mem[ddl->command_channel], - &dec_disp_info->img_size_x, - &dec_disp_info->img_size_y); - *status = dec_disp_info->decode_status; - *rsl_chg = dec_disp_info->dec_resl_change; - } -} - -static u32 ddl_decoder_frame_run_callback(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - u32 callback_end = false, ret_status = false; - u32 eos_present = false, rsl_chg; - u32 more_field_needed, extended_rsl_chg; - enum vidc_1080p_display_status disp_status; - DDL_MSG_MED("ddl_decoder_frame_run_callback"); - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-DECFRMRUN"); - ddl_client_fatal_cb(ddl); - ret_status = true; - } else { - DDL_MSG_LOW("DEC_FRM_RUN_DONE"); - ddl->cmd_state = DDL_CMD_INVALID; - get_dec_status(ddl, &ddl->codec_data.decoder.dec_disp_info, - ddl->codec_data.decoder.output_order, - &disp_status, &rsl_chg); - - vidc_sm_get_extended_decode_status( - &ddl->shared_mem[ddl->command_channel], - &more_field_needed, - &extended_rsl_chg); - decoder->field_needed_for_prev_ip = - more_field_needed; - decoder->prev_ip_frm_tag = - ddl->input_frame.vcd_frm.ip_frm_tag; - - ddl_vidc_decode_dynamic_property(ddl, false); - if (rsl_chg != DDL_RESL_CHANGE_NO_CHANGE) { - ddl_handle_reconfig(rsl_chg, ddl); - ret_status = false; - } else { - if ((VCD_FRAME_FLAG_EOS & - ddl->input_frame.vcd_frm.flags)) { - callback_end = false; - eos_present = true; - } - if (disp_status == - VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY || - disp_status == - VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY) { - if (!eos_present) - callback_end = - (disp_status == - VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY); - ddl_decoder_input_done_callback(ddl, - callback_end); - } - if (disp_status == - VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY || - disp_status == - VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY) { - if (!eos_present) - callback_end = (disp_status == - VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY); - if (ddl_decoder_output_done_callback( - ddl, callback_end)) - ret_status = true; - } - if (!ret_status) { - if (disp_status == - VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY - || disp_status == - VIDC_1080P_DISPLAY_STATUS_DPB_EMPTY || - disp_status == - VIDC_1080P_DISPLAY_STATUS_NOOP) { - ddl_vidc_decode_frame_run(ddl); - } else if (eos_present) - ddl_vidc_decode_eos_run(ddl); - else { - ddl->client_state = - DDL_CLIENT_WAIT_FOR_FRAME; - ddl_release_command_channel(ddl_context, - ddl->command_channel); - ret_status = true; - } - } - } - } - return ret_status; -} - -static u32 ddl_eos_frame_done_callback( - struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct ddl_mask *dpb_mask = &decoder->dpb_mask; - u32 ret_status = true, rsl_chg, more_field_needed; - enum vidc_1080p_display_status disp_status; - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-EOSFRMRUN"); - ddl_client_fatal_cb(ddl); - } else { - DDL_MSG_LOW("EOS_FRM_RUN_DONE"); - ddl->cmd_state = DDL_CMD_INVALID; - get_dec_status(ddl, &ddl->codec_data.decoder.dec_disp_info, - ddl->codec_data.decoder.output_order, - &disp_status, &rsl_chg); - vidc_sm_get_extended_decode_status( - &ddl->shared_mem[ddl->command_channel], - &more_field_needed, &rsl_chg); - - decoder->field_needed_for_prev_ip = - more_field_needed; - decoder->prev_ip_frm_tag = - ddl->input_frame.vcd_frm.ip_frm_tag; - ddl_vidc_decode_dynamic_property(ddl, false); - if (disp_status == - VIDC_1080P_DISPLAY_STATUS_DPB_EMPTY) { - if (rsl_chg) { - decoder->header_in_start = false; - decoder->decode_config.sequence_header = - ddl->input_frame.vcd_frm.physical; - decoder->decode_config.sequence_header_len = - ddl->input_frame.vcd_frm.data_len; - decoder->reconfig_detected = false; - ddl_vidc_decode_init_codec(ddl); - ret_status = false; - } else - ddl_decoder_eos_done_callback(ddl); - } else { - struct vidc_1080p_dec_frame_start_param dec_param; - ret_status = false; - if (disp_status == - VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY) { - if (ddl_decoder_output_done_callback( - ddl, false)) - ret_status = true; - } else if (disp_status != - VIDC_1080P_DISPLAY_STATUS_NOOP) - DDL_MSG_ERROR("EOS-STATE-CRITICAL-" - "WRONG-DISP-STATUS"); - if (!ret_status) { - ddl_decoder_dpb_transact(decoder, NULL, - DDL_DPB_OP_SET_MASK); - ddl->cmd_state = DDL_CMD_EOS; - - memset(&dec_param, 0, sizeof(dec_param)); - - dec_param.cmd_seq_num = - ++ddl_context->cmd_seq_num; - dec_param.inst_id = ddl->instance_id; - dec_param.shared_mem_addr_offset = - DDL_ADDR_OFFSET( - ddl_context->dram_base_a, - ddl->shared_mem[ddl->command_channel]); - dec_param.release_dpb_bit_mask = - dpb_mask->hw_mask; - dec_param.decode = - (decoder->reconfig_detected) ?\ - VIDC_1080P_DEC_TYPE_FRAME_DATA :\ - VIDC_1080P_DEC_TYPE_LAST_FRAME_DATA; - - ddl_context->vidc_decode_frame_start[ddl->\ - command_channel](&dec_param); - } - } - } - return ret_status; -} - -static u32 ddl_frame_run_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - u32 channel_inst_id; - u32 return_status = true; - - vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); - vidc_1080p_clear_returned_channel_inst_id(); - ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context, - ddl_context->response_cmd_ch_id); - if (ddl) { - if (ddl_context->pix_cache_enable) { - struct vidc_1080P_pix_cache_statistics - pixel_cache_stats; - vidc_pix_cache_get_statistics(&pixel_cache_stats); - - DDL_MSG_LOW(" pixel cache hits = %d," - "miss = %d", pixel_cache_stats.access_hit, - pixel_cache_stats.access_miss); - DDL_MSG_LOW(" pixel cache core reqs = %d," - "axi reqs = %d", pixel_cache_stats.core_req, - pixel_cache_stats.axi_req); - DDL_MSG_LOW(" pixel cache core bus stats = %d," - "axi bus stats = %d", pixel_cache_stats.core_bus, - pixel_cache_stats.axi_bus); - } - - if (ddl->cmd_state == DDL_CMD_DECODE_FRAME) - return_status = ddl_decoder_frame_run_callback(ddl); - else if (ddl->cmd_state == DDL_CMD_ENCODE_FRAME) - return_status = ddl_encoder_frame_run_callback(ddl); - else if (ddl->cmd_state == DDL_CMD_EOS) - return_status = ddl_eos_frame_done_callback(ddl); - else { - DDL_MSG_ERROR("UNKWN_FRAME_DONE"); - return_status = false; - } - } else - return_status = false; - - return return_status; -} - -static void ddl_channel_end_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - - DDL_MSG_MED("ddl_channel_end_callback"); - ddl = ddl_get_current_ddl_client_for_command(ddl_context, - DDL_CMD_CHANNEL_END); - if (ddl) { - ddl->cmd_state = DDL_CMD_INVALID; - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHEND)) { - DDL_MSG_LOW("STATE-CRITICAL-CHEND"); - } else { - DDL_MSG_LOW("CH_END_DONE"); - ddl_release_client_internal_buffers(ddl); - ddl_context->ddl_callback(VCD_EVT_RESP_STOP, - VCD_S_SUCCESS, NULL, 0, (u32 *)ddl, - ddl->client_data); - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_OPEN", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_OPEN; - } - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } -} - -static void ddl_edfu_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - u32 channel_inst_id; - - DDL_MSG_MED("ddl_edfu_callback"); - vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); - vidc_1080p_clear_returned_channel_inst_id(); - ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context, - ddl_context->response_cmd_ch_id); - if (ddl) { - if (ddl->cmd_state != DDL_CMD_ENCODE_FRAME) - DDL_MSG_LOW("UNKWN_EDFU"); - } -} - -static void ddl_encoder_eos_done(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - u32 channel_inst_id; - - vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); - vidc_1080p_clear_returned_channel_inst_id(); - ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context, - ddl_context->response_cmd_ch_id); - DDL_MSG_LOW("ddl_encoder_eos_done\n"); - if (ddl == NULL) { - DDL_MSG_ERROR("NO_DDL_CONTEXT"); - } else { - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)) { - DDL_MSG_ERROR("STATE-CRITICAL-EOSFRMDONE"); - ddl_client_fatal_cb(ddl); - } else { - struct ddl_encoder_data *encoder = - &(ddl->codec_data.encoder); - vidc_1080p_get_encode_frame_info( - &encoder->enc_frame_info); - if (!encoder->slice_delivery_info.enable) { - ddl_handle_enc_frame_done(ddl, true); - ddl->cmd_state = DDL_CMD_INVALID; - } - DDL_MSG_LOW("encoder_eos_done"); - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_FRAME", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME; - DDL_MSG_LOW("eos_done"); - ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE, - VCD_S_SUCCESS, NULL, 0, - (u32 *)ddl, ddl->client_data); - ddl_release_command_channel(ddl_context, - ddl->command_channel); - } - } -} - -static u32 ddl_slice_done_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - u32 channel_inst_id; - u32 return_status = true; - DDL_MSG_LOW("ddl_sliceDoneCallback"); - vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); - vidc_1080p_clear_returned_channel_inst_id(); - ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context, - ddl_context->response_cmd_ch_id); - if (ddl == NULL) { - DDL_MSG_ERROR("NO_DDL_CONTEXT"); - return_status = false; - } else if (ddl->cmd_state == DDL_CMD_ENCODE_FRAME) { - ddl->cmd_state = DDL_CMD_INVALID; - if (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_FRAME_DONE)) { - ddl_handle_slice_done_slice_batch(ddl); - } else { - DDL_MSG_ERROR("STATE-CRITICAL-ENCFRMRUN : %s\n", - __func__); - ddl_client_fatal_cb(ddl); - } - } else { - DDL_MSG_ERROR("UNKNOWN_SLICEDONE : %s\n", __func__); - } - return return_status; -} - -static u32 ddl_process_intr_status(struct ddl_context *ddl_context, - u32 intr_status) -{ - u32 return_status = true; - switch (intr_status) { - case VIDC_1080P_RISC2HOST_CMD_OPEN_CH_RET: - return_status = ddl_channel_set_callback(ddl_context, - ddl_context->response_cmd_ch_id); - break; - case VIDC_1080P_RISC2HOST_CMD_CLOSE_CH_RET: - ddl_channel_end_callback(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_SEQ_DONE_RET: - return_status = ddl_sequence_done_callback(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_FRAME_DONE_RET: - return_status = ddl_frame_run_callback(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_SLICE_DONE_RET: - ddl_slice_done_callback(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_SYS_INIT_RET: - ddl_sys_init_done_callback(ddl_context, - ddl_context->response_cmd_ch_id); - break; - case VIDC_1080P_RISC2HOST_CMD_FW_STATUS_RET: - ddl_fw_status_done_callback(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_EDFU_INT_RET: - ddl_edfu_callback(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_ENC_COMPLETE_RET: - ddl_encoder_eos_done(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_ERROR_RET: - DDL_MSG_ERROR("CMD_ERROR_INTR"); - return_status = ddl_handle_core_errors(ddl_context); - break; - case VIDC_1080P_RISC2HOST_CMD_INIT_BUFFERS_RET: - return_status = - ddl_dpb_buffers_set_done_callback(ddl_context); - break; - default: - DDL_MSG_LOW("UNKWN_INTR"); - break; - } - return return_status; -} - -void ddl_read_and_clear_interrupt(void) -{ - struct ddl_context *ddl_context; - struct ddl_hw_interface *ddl_hw_response; - struct ddl_client_context *ddl; - struct ddl_encoder_data *encoder; - - ddl_context = ddl_get_context(); - if (!ddl_context->core_virtual_base_addr) { - DDL_MSG_LOW("SPURIOUS_INTERRUPT"); - } else { - ddl_hw_response = &ddl_context->ddl_hw_response; - vidc_1080p_get_risc2host_cmd(&ddl_hw_response->cmd, - &ddl_hw_response->arg1, &ddl_hw_response->arg2, - &ddl_hw_response->arg3, - &ddl_hw_response->arg4); - DDL_MSG_LOW("%s vidc_1080p_get_risc2host_cmd cmd = %u" - "arg1 = %u arg2 = %u arg3 = %u" - "arg4 = %u\n", - __func__, ddl_hw_response->cmd, - ddl_hw_response->arg1, ddl_hw_response->arg2, - ddl_hw_response->arg3, - ddl_hw_response->arg4); - ddl = ddl_get_current_ddl_client_for_channel_id(ddl_context, - ddl_context->response_cmd_ch_id); - if (ddl) { - encoder = &(ddl->codec_data.encoder); - if (encoder && encoder->slice_delivery_info.enable - && - ((ddl_hw_response->cmd == - VIDC_1080P_RISC2HOST_CMD_SLICE_DONE_RET) - || (ddl_hw_response->cmd == - VIDC_1080P_RISC2HOST_CMD_FRAME_DONE_RET))) { - vidc_sm_get_num_slices_comp( - &ddl->shared_mem[ddl->command_channel], - &encoder->num_slices_comp); - vidc_sm_set_encoder_slice_batch_int_ctrl( - &ddl->shared_mem[ddl->command_channel], - 1); - } - } - vidc_1080p_clear_risc2host_cmd(); - vidc_1080p_clear_interrupt(); - vidc_1080p_get_risc2host_cmd_status(ddl_hw_response->arg2, - &ddl_context->cmd_err_status, - &ddl_context->disp_pic_err_status); - DDL_MSG_LOW("%s cmd_err_status = %d\n", __func__, - ddl_context->cmd_err_status); - ddl_context->response_cmd_ch_id = ddl_hw_response->arg1; - } -} - -u32 ddl_process_core_response(void) -{ - struct ddl_context *ddl_context; - struct ddl_hw_interface *ddl_hw_response; - u32 status = false; - - ddl_context = ddl_get_context(); - if (!ddl_context->core_virtual_base_addr) { - DDL_MSG_LOW("SPURIOUS_INTERRUPT"); - return status; - } - ddl_hw_response = &ddl_context->ddl_hw_response; - status = ddl_process_intr_status(ddl_context, ddl_hw_response->cmd); - if (ddl_context->interrupt_clr) - (*ddl_context->interrupt_clr)(); - return status; -} - -static void ddl_decoder_input_done_callback( - struct ddl_client_context *ddl, u32 frame_transact_end) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vidc_1080p_dec_disp_info *dec_disp_info = - &decoder->dec_disp_info; - struct vcd_frame_data *input_vcd_frm = &(ddl->input_frame.vcd_frm); - u32 is_interlaced; - vidc_1080p_get_decoded_frame_size( - &dec_disp_info->input_bytes_consumed); - vidc_sm_set_start_byte_number(&ddl->shared_mem - [ddl->command_channel], 0); - vidc_1080p_get_decode_frame(&dec_disp_info->input_frame); - ddl_get_decoded_frame(input_vcd_frm, - dec_disp_info->input_frame); - vidc_1080p_get_decode_frame_result(dec_disp_info); - is_interlaced = (dec_disp_info->decode_coding == - VIDC_1080P_DISPLAY_CODING_INTERLACED); - if (decoder->output_order == VCD_DEC_ORDER_DECODE) { - dec_disp_info->tag_bottom = is_interlaced ? - dec_disp_info->tag_top : - VCD_FRAMETAG_INVALID; - dec_disp_info->tag_top = input_vcd_frm->ip_frm_tag; - } - input_vcd_frm->interlaced = is_interlaced; - input_vcd_frm->offset += dec_disp_info->input_bytes_consumed; - input_vcd_frm->data_len -= dec_disp_info->input_bytes_consumed; - ddl->input_frame.frm_trans_end = frame_transact_end; - ddl_calc_core_proc_time(__func__, DEC_IP_TIME, ddl); - ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE, VCD_S_SUCCESS, - &ddl->input_frame, sizeof(struct ddl_frame_data_tag), - (u32 *)ddl, ddl->client_data); -} - -static void get_dec_op_done_data(struct vidc_1080p_dec_disp_info *dec_disp_info, - u32 output_order, u8 **physical, u32 *is_interlaced) -{ - enum vidc_1080p_display_coding disp_coding; - if (output_order == VCD_DEC_ORDER_DECODE) { - *physical = (u8 *)(dec_disp_info->decode_y_addr << 11); - disp_coding = dec_disp_info->decode_coding; - } else { - *physical = (u8 *)(dec_disp_info->display_y_addr << 11); - disp_coding = dec_disp_info->display_coding; - } - *is_interlaced = (disp_coding == - VIDC_1080P_DISPLAY_CODING_INTERLACED); -} - -static void get_dec_op_done_crop(u32 output_order, - struct vidc_1080p_dec_disp_info *dec_disp_info, - struct vcd_frame_rect *crop_data, - struct vcd_property_frame_size *op_frame_sz, - struct vcd_property_frame_size *frame_sz, - struct ddl_buf_addr *shared_mem) -{ - u32 crop_exists = - (output_order == VCD_DEC_ORDER_DECODE) ? - dec_disp_info->dec_crop_exists : - dec_disp_info->disp_crop_exists; - crop_data->left = 0; - crop_data->top = 0; - crop_data->right = dec_disp_info->img_size_x; - crop_data->bottom = dec_disp_info->img_size_y; - op_frame_sz->width = dec_disp_info->img_size_x; - op_frame_sz->height = dec_disp_info->img_size_y; - ddl_calculate_stride(op_frame_sz, false); - op_frame_sz->stride = DDL_ALIGN(op_frame_sz->width, - DDL_TILE_ALIGN_WIDTH); - op_frame_sz->scan_lines = DDL_ALIGN(op_frame_sz->height, - DDL_TILE_ALIGN_HEIGHT); - DDL_MSG_LOW("%s img_size_x = %u img_size_y = %u\n", - __func__, dec_disp_info->img_size_x, - dec_disp_info->img_size_y); - if (crop_exists) { - if (output_order == VCD_DEC_ORDER_DECODE) - vidc_sm_get_dec_order_crop_info(shared_mem, - &dec_disp_info->crop_left_offset, - &dec_disp_info->crop_right_offset, - &dec_disp_info->crop_top_offset, - &dec_disp_info->crop_bottom_offset); - else - vidc_sm_get_crop_info(shared_mem, - &dec_disp_info->crop_left_offset, - &dec_disp_info->crop_right_offset, - &dec_disp_info->crop_top_offset, - &dec_disp_info->crop_bottom_offset); - crop_data->left = dec_disp_info->crop_left_offset; - crop_data->top = dec_disp_info->crop_top_offset; - crop_data->right -= dec_disp_info->crop_right_offset; - crop_data->bottom -= dec_disp_info->crop_bottom_offset; - op_frame_sz->width = crop_data->right - crop_data->left; - op_frame_sz->height = crop_data->bottom - crop_data->top; - } -} - -static u32 ddl_decoder_output_done_callback( - struct ddl_client_context *ddl, u32 frame_transact_end) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vidc_1080p_dec_disp_info *dec_disp_info = - &(decoder->dec_disp_info); - struct ddl_frame_data_tag *output_frame = &(ddl->output_frame); - struct vcd_frame_data *output_vcd_frm = &(output_frame->vcd_frm); - enum vidc_1080p_decode_frame frame_type = 0; - u32 vcd_status, free_luma_dpb = 0, disp_pict = 0, is_interlaced; - u32 idr_frame = 0, coded_frame = 0; - get_dec_op_done_data(dec_disp_info, decoder->output_order, - &output_vcd_frm->physical, &is_interlaced); - decoder->progressive_only = !(is_interlaced); - output_vcd_frm->frame = VCD_FRAME_YUV; - vidc_sm_get_displayed_picture_frame(&ddl->shared_mem - [ddl->command_channel], &disp_pict); - coded_frame = (disp_pict & 0x03); - idr_frame = (disp_pict & 0x20) >> 5; - if (idr_frame) - frame_type = VIDC_1080P_DECODE_FRAMETYPE_IDR; - else - frame_type = (disp_pict & 0x1c) >> 2; - if (decoder->codec.codec == VCD_CODEC_MPEG4 || - decoder->codec.codec == VCD_CODEC_VC1 || - decoder->codec.codec == VCD_CODEC_VC1_RCV || - (decoder->codec.codec >= VCD_CODEC_DIVX_3 && - decoder->codec.codec <= VCD_CODEC_XVID)) { - if (decoder->output_order == VCD_DEC_ORDER_DISPLAY) { - if (!coded_frame) { - output_vcd_frm->frame = VCD_FRAME_NOTCODED; - vidc_sm_get_available_luma_dpb_address( - &ddl->shared_mem[ddl->command_channel], - &free_luma_dpb); - } - } else { - if (dec_disp_info->input_frame == - VIDC_1080P_DECODE_FRAMETYPE_NOT_CODED) { - output_vcd_frm->frame = VCD_FRAME_NOTCODED; - vidc_sm_get_available_luma_dpb_dec_order_address( - &ddl->shared_mem[ddl->command_channel], - &free_luma_dpb); - } - } - if (free_luma_dpb) - output_vcd_frm->physical = - (u8 *)(free_luma_dpb << 11); - } - vcd_status = ddl_decoder_dpb_transact(decoder, output_frame, - DDL_DPB_OP_MARK_BUSY); - if (vcd_status) { - DDL_MSG_ERROR("CORRUPTED_OUTPUT_BUFFER_ADDRESS"); - ddl_hw_fatal_cb(ddl); - } else { - ddl_get_decoded_frame(output_vcd_frm, frame_type); - vidc_sm_get_metadata_status(&ddl->shared_mem - [ddl->command_channel], - &decoder->meta_data_exists); - decoder->mp2_datadump_status = 0; - vidc_sm_get_mp2datadump_status(&ddl->shared_mem - [ddl->command_channel], - &decoder->mp2_datadump_status); - if (decoder->output_order == VCD_DEC_ORDER_DISPLAY) { - vidc_sm_get_frame_tags(&ddl->shared_mem - [ddl->command_channel], - &dec_disp_info->tag_top, - &dec_disp_info->tag_bottom); - if (dec_disp_info->display_correct == - VIDC_1080P_DECODE_NOT_CORRECT || - dec_disp_info->display_correct == - VIDC_1080P_DECODE_APPROX_CORRECT) - output_vcd_frm->flags |= - VCD_FRAME_FLAG_DATACORRUPT; - } else { - if (dec_disp_info->decode_correct == - VIDC_1080P_DECODE_NOT_CORRECT || - dec_disp_info->decode_correct == - VIDC_1080P_DECODE_APPROX_CORRECT) - output_vcd_frm->flags |= - VCD_FRAME_FLAG_DATACORRUPT; - } - if (decoder->codec.codec != VCD_CODEC_H264 && - decoder->codec.codec != VCD_CODEC_MPEG2) - output_vcd_frm->flags &= ~VCD_FRAME_FLAG_DATACORRUPT; - output_vcd_frm->ip_frm_tag = dec_disp_info->tag_top; - vidc_sm_get_picture_times(&ddl->shared_mem - [ddl->command_channel], - &dec_disp_info->pic_time_top, - &dec_disp_info->pic_time_bottom); - get_dec_op_done_crop(decoder->output_order, dec_disp_info, - &output_vcd_frm->dec_op_prop.disp_frm, - &output_vcd_frm->dec_op_prop.frm_size, - &decoder->frame_size, - &ddl->shared_mem[ddl_context->response_cmd_ch_id]); - if ((decoder->cont_mode) && - ((output_vcd_frm->dec_op_prop.frm_size.width != - decoder->frame_size.width) || - (output_vcd_frm->dec_op_prop.frm_size.height != - decoder->frame_size.height) || - (decoder->frame_size.width != - decoder->client_frame_size.width) || - (decoder->frame_size.height != - decoder->client_frame_size.height))) { - DDL_MSG_LOW("%s o/p width = %u o/p height = %u" - "decoder width = %u decoder height = %u ", - __func__, - output_vcd_frm->dec_op_prop.frm_size.width, - output_vcd_frm->dec_op_prop.frm_size.height, - decoder->frame_size.width, - decoder->frame_size.height); - DDL_MSG_HIGH("%s Sending INFO_OP_RECONFIG event\n", - __func__); - ddl_context->ddl_callback( - VCD_EVT_IND_INFO_OUTPUT_RECONFIG, - VCD_S_SUCCESS, NULL, 0, - (u32 *)ddl, - ddl->client_data); - decoder->frame_size = - output_vcd_frm->dec_op_prop.frm_size; - decoder->client_frame_size = decoder->frame_size; - decoder->yuv_size = decoder->frame_size.width * - decoder->frame_size.height; - decoder->yuv_size += decoder->yuv_size / 2; - decoder->y_cb_cr_size = - ddl_get_yuv_buffer_size(&decoder->frame_size, - &decoder->buf_format, - (!decoder->progressive_only), - decoder->codec.codec, NULL); - decoder->actual_output_buf_req.sz = - decoder->y_cb_cr_size + decoder->suffix; - decoder->min_output_buf_req = - decoder->actual_output_buf_req; - DDL_MSG_LOW("%s y_cb_cr_size = %u " - "actual_output_buf_req.sz = %u" - "min_output_buf_req.sz = %u\n", - __func__, decoder->y_cb_cr_size, - decoder->actual_output_buf_req.sz, - decoder->min_output_buf_req.sz); - vidc_sm_set_chroma_addr_change( - &ddl->shared_mem[ddl->command_channel], - false); - } - output_vcd_frm->interlaced = is_interlaced; - output_vcd_frm->intrlcd_ip_frm_tag = - (!is_interlaced || !dec_disp_info->tag_bottom) ? - VCD_FRAMETAG_INVALID : dec_disp_info->tag_bottom; - output_vcd_frm->offset = 0; - output_vcd_frm->data_len = decoder->y_cb_cr_size; - if (free_luma_dpb) { - output_vcd_frm->data_len = 0; - output_vcd_frm->flags |= VCD_FRAME_FLAG_DECODEONLY; - } - output_vcd_frm->flags |= VCD_FRAME_FLAG_ENDOFFRAME; - output_frame->frm_trans_end = frame_transact_end; - ddl_calc_core_proc_time(__func__, DEC_OP_TIME, ddl); - ddl_process_decoder_metadata(ddl); - vidc_sm_get_aspect_ratio_info( - &ddl->shared_mem[ddl->command_channel], - decoder->codec.codec, - &output_vcd_frm->aspect_ratio_info); - ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, - vcd_status, output_frame, - sizeof(struct ddl_frame_data_tag), - (u32 *)ddl, ddl->client_data); - } - return vcd_status; -} - -static u32 ddl_get_decoded_frame(struct vcd_frame_data *frame, - enum vidc_1080p_decode_frame frame_type) -{ - u32 status = true; - - switch (frame_type) { - case VIDC_1080P_DECODE_FRAMETYPE_I: - frame->flags |= VCD_FRAME_FLAG_SYNCFRAME; - frame->frame = VCD_FRAME_I; - break; - case VIDC_1080P_DECODE_FRAMETYPE_P: - frame->frame = VCD_FRAME_P; - break; - case VIDC_1080P_DECODE_FRAMETYPE_B: - frame->frame = VCD_FRAME_B; - break; - case VIDC_1080P_DECODE_FRAMETYPE_NOT_CODED: - frame->frame = VCD_FRAME_NOTCODED; - frame->data_len = 0; - DDL_MSG_HIGH("DDL_INFO:Decoder:NotCodedFrame>"); - break; - case VIDC_1080P_DECODE_FRAMETYPE_OTHERS: - frame->frame = VCD_FRAME_YUV; - break; - case VIDC_1080P_DECODE_FRAMETYPE_IDR: - frame->flags |= VCD_FRAME_FLAG_SYNCFRAME; - frame->frame = VCD_FRAME_IDR; - break; - case VIDC_1080P_DECODE_FRAMETYPE_32BIT: - default: - DDL_MSG_ERROR("UNKNOWN-FRAMETYPE"); - status = false; - break; - } - return status; -} - -static u32 ddl_get_encoded_frame(struct vcd_frame_data *frame, - enum vcd_codec codec, - enum vidc_1080p_encode_frame frame_type) -{ - u32 status = true; - - if (codec == VCD_CODEC_H264) { - switch (frame_type) { - case VIDC_1080P_ENCODE_FRAMETYPE_NOT_CODED: - frame->frame = VCD_FRAME_P; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_I: - frame->flags |= VCD_FRAME_FLAG_SYNCFRAME; - frame->frame = VCD_FRAME_I; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_P: - frame->frame = VCD_FRAME_P; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_B: - frame->frame = VCD_FRAME_B; - frame->flags |= VCD_FRAME_FLAG_BFRAME; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED: - frame->frame = VCD_FRAME_NOTCODED; - frame->data_len = 0; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_OTHERS: - DDL_MSG_LOW("FRAMETYPE-OTHERS"); - break; - case VIDC_1080P_ENCODE_FRAMETYPE_32BIT: - default: - DDL_MSG_LOW("UNKNOWN-FRAMETYPE"); - status = false; - break; - } - } else if (codec == VCD_CODEC_MPEG4) { - switch (frame_type) { - case VIDC_1080P_ENCODE_FRAMETYPE_NOT_CODED: - frame->frame = VCD_FRAME_P; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_I: - frame->flags |= VCD_FRAME_FLAG_SYNCFRAME; - frame->frame = VCD_FRAME_I; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_P: - frame->frame = VCD_FRAME_P; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_B: - frame->frame = VCD_FRAME_B; - frame->flags |= VCD_FRAME_FLAG_BFRAME; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED: - frame->frame = VCD_FRAME_NOTCODED; - frame->data_len = 0; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_OTHERS: - DDL_MSG_LOW("FRAMETYPE-OTHERS"); - break; - case VIDC_1080P_ENCODE_FRAMETYPE_32BIT: - default: - DDL_MSG_LOW("UNKNOWN-FRAMETYPE"); - status = false; - break; - } - } else if (codec == VCD_CODEC_H263) { - switch (frame_type) { - case VIDC_1080P_ENCODE_FRAMETYPE_NOT_CODED: - frame->frame = VCD_FRAME_P; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_I: - frame->flags |= VCD_FRAME_FLAG_SYNCFRAME; - frame->frame = VCD_FRAME_I; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_P: - frame->frame = VCD_FRAME_P; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED: - frame->frame = VCD_FRAME_NOTCODED; - frame->data_len = 0; - break; - case VIDC_1080P_ENCODE_FRAMETYPE_OTHERS: - DDL_MSG_LOW("FRAMETYPE-OTHERS"); - break; - case VIDC_1080P_ENCODE_FRAMETYPE_32BIT: - default: - DDL_MSG_LOW("UNKNOWN-FRAMETYPE"); - status = false; - break; - } - } else - status = false; - DDL_MSG_LOW("Enc Frame Type %u", (u32)frame->frame); - return status; -} - -static void ddl_get_mpeg4_dec_level(enum vcd_codec_level *level, - u32 level_codec, enum vcd_codec_profile mpeg4_profile) -{ - switch (level_codec) { - case VIDC_1080P_MPEG4_LEVEL0: - *level = VCD_LEVEL_MPEG4_0; - break; - case VIDC_1080P_MPEG4_LEVEL0b: - *level = VCD_LEVEL_MPEG4_0b; - break; - case VIDC_1080P_MPEG4_LEVEL1: - *level = VCD_LEVEL_MPEG4_1; - break; - case VIDC_1080P_MPEG4_LEVEL2: - *level = VCD_LEVEL_MPEG4_2; - break; - case VIDC_1080P_MPEG4_LEVEL3: - *level = VCD_LEVEL_MPEG4_3; - break; - case VIDC_1080P_MPEG4_LEVEL3b: - if (mpeg4_profile == VCD_PROFILE_MPEG4_SP) - *level = VCD_LEVEL_MPEG4_7; - else - *level = VCD_LEVEL_MPEG4_3b; - break; - case VIDC_1080P_MPEG4_LEVEL4a: - *level = VCD_LEVEL_MPEG4_4a; - break; - case VIDC_1080P_MPEG4_LEVEL5: - *level = VCD_LEVEL_MPEG4_5; - break; - case VIDC_1080P_MPEG4_LEVEL6: - *level = VCD_LEVEL_MPEG4_6; - break; - default: - *level = VCD_LEVEL_UNKNOWN; - break; - } -} - -static void ddl_get_h264_dec_level(enum vcd_codec_level *level, - u32 level_codec) -{ - switch (level_codec) { - case VIDC_1080P_H264_LEVEL1: - *level = VCD_LEVEL_H264_1; - break; - case VIDC_1080P_H264_LEVEL1b: - *level = VCD_LEVEL_H264_1b; - break; - case VIDC_1080P_H264_LEVEL1p1: - *level = VCD_LEVEL_H264_1p1; - break; - case VIDC_1080P_H264_LEVEL1p2: - *level = VCD_LEVEL_H264_1p2; - break; - case VIDC_1080P_H264_LEVEL1p3: - *level = VCD_LEVEL_H264_1p3; - break; - case VIDC_1080P_H264_LEVEL2: - *level = VCD_LEVEL_H264_2; - break; - case VIDC_1080P_H264_LEVEL2p1: - *level = VCD_LEVEL_H264_2p1; - break; - case VIDC_1080P_H264_LEVEL2p2: - *level = VCD_LEVEL_H264_2p2; - break; - case VIDC_1080P_H264_LEVEL3: - *level = VCD_LEVEL_H264_3; - break; - case VIDC_1080P_H264_LEVEL3p1: - *level = VCD_LEVEL_H264_3p1; - break; - case VIDC_1080P_H264_LEVEL3p2: - *level = VCD_LEVEL_H264_3p2; - break; - case VIDC_1080P_H264_LEVEL4: - *level = VCD_LEVEL_H264_4; - break; - default: - *level = VCD_LEVEL_UNKNOWN; - break; - } -} - -static void ddl_get_h263_dec_level(enum vcd_codec_level *level, - u32 level_codec) -{ - switch (level_codec) { - case VIDC_1080P_H263_LEVEL10: - *level = VCD_LEVEL_H263_10; - break; - case VIDC_1080P_H263_LEVEL20: - *level = VCD_LEVEL_H263_20; - break; - case VIDC_1080P_H263_LEVEL30: - *level = VCD_LEVEL_H263_30; - break; - case VIDC_1080P_H263_LEVEL40: - *level = VCD_LEVEL_H263_40; - break; - case VIDC_1080P_H263_LEVEL45: - *level = VCD_LEVEL_H263_45; - break; - case VIDC_1080P_H263_LEVEL50: - *level = VCD_LEVEL_H263_50; - break; - case VIDC_1080P_H263_LEVEL60: - *level = VCD_LEVEL_H263_60; - break; - case VIDC_1080P_H263_LEVEL70: - *level = VCD_LEVEL_H263_70; - break; - default: - *level = VCD_LEVEL_UNKNOWN; - break; - } -} - -static void ddl_get_vc1_dec_level(enum vcd_codec_level *level, - u32 level_codec, enum vcd_codec_profile vc1_profile) -{ - if (vc1_profile == VCD_PROFILE_VC1_ADVANCE) { - switch (level_codec) { - case VIDC_SM_LEVEL_VC1_ADV_0: - *level = VCD_LEVEL_VC1_A_0; - break; - case VIDC_SM_LEVEL_VC1_ADV_1: - *level = VCD_LEVEL_VC1_A_1; - break; - case VIDC_SM_LEVEL_VC1_ADV_2: - *level = VCD_LEVEL_VC1_A_2; - break; - case VIDC_SM_LEVEL_VC1_ADV_3: - *level = VCD_LEVEL_VC1_A_3; - break; - case VIDC_SM_LEVEL_VC1_ADV_4: - *level = VCD_LEVEL_VC1_A_4; - break; - default: - *level = VCD_LEVEL_UNKNOWN; - break; - } - } else if (vc1_profile == VCD_PROFILE_VC1_MAIN) { - switch (level_codec) { - case VIDC_SM_LEVEL_VC1_LOW: - *level = VCD_LEVEL_VC1_M_LOW; - break; - case VIDC_SM_LEVEL_VC1_MEDIUM: - *level = VCD_LEVEL_VC1_M_MEDIUM; - break; - case VIDC_SM_LEVEL_VC1_HIGH: - *level = VCD_LEVEL_VC1_M_HIGH; - break; - default: - *level = VCD_LEVEL_UNKNOWN; - break; - } - } else if (vc1_profile == VCD_PROFILE_VC1_SIMPLE) { - switch (level_codec) { - case VIDC_SM_LEVEL_VC1_LOW: - *level = VCD_LEVEL_VC1_S_LOW; - break; - case VIDC_SM_LEVEL_VC1_MEDIUM: - *level = VCD_LEVEL_VC1_S_MEDIUM; - break; - default: - *level = VCD_LEVEL_UNKNOWN; - break; - } - } -} - -static void ddl_get_mpeg2_dec_level(enum vcd_codec_level *level, - u32 level_codec) -{ - switch (level_codec) { - case VIDC_SM_LEVEL_MPEG2_LOW: - *level = VCD_LEVEL_MPEG2_LOW; - break; - case VIDC_SM_LEVEL_MPEG2_MAIN: - *level = VCD_LEVEL_MPEG2_MAIN; - break; - case VIDC_SM_LEVEL_MPEG2_HIGH_1440: - *level = VCD_LEVEL_MPEG2_HIGH_14; - break; - case VIDC_SM_LEVEL_MPEG2_HIGH: - *level = VCD_LEVEL_MPEG2_HIGH; - break; - default: - *level = VCD_LEVEL_UNKNOWN; - break; - } -} - -static void ddl_get_dec_profile_level(struct ddl_decoder_data *decoder, - u32 profile_codec, u32 level_codec) -{ - enum vcd_codec_profile profile = VCD_PROFILE_UNKNOWN; - enum vcd_codec_level level = VCD_LEVEL_UNKNOWN; - - switch (decoder->codec.codec) { - case VCD_CODEC_MPEG4: - case VCD_CODEC_XVID: - if (profile_codec == VIDC_SM_PROFILE_MPEG4_SIMPLE) - profile = VCD_PROFILE_MPEG4_SP; - else if (profile_codec == VIDC_SM_PROFILE_MPEG4_ADV_SIMPLE) - profile = VCD_PROFILE_MPEG4_ASP; - else - profile = VCD_PROFILE_UNKNOWN; - ddl_get_mpeg4_dec_level(&level, level_codec, profile); - break; - case VCD_CODEC_H264: - if (profile_codec == VIDC_SM_PROFILE_H264_BASELINE) - profile = VCD_PROFILE_H264_BASELINE; - else if (profile_codec == VIDC_SM_PROFILE_H264_MAIN) - profile = VCD_PROFILE_H264_MAIN; - else if (profile_codec == VIDC_SM_PROFILE_H264_HIGH) - profile = VCD_PROFILE_H264_HIGH; - else - profile = VCD_PROFILE_UNKNOWN; - ddl_get_h264_dec_level(&level, level_codec); - break; - case VCD_CODEC_H263: - if (profile_codec == VIDC_SM_PROFILE_H263_BASELINE) - profile = VCD_PROFILE_H263_BASELINE; - else - profile = VCD_PROFILE_UNKNOWN; - ddl_get_h263_dec_level(&level, level_codec); - break; - case VCD_CODEC_MPEG2: - if (profile_codec == VIDC_SM_PROFILE_MPEG2_MAIN) - profile = VCD_PROFILE_MPEG2_MAIN; - else if (profile_codec == VIDC_SM_PROFILE_MPEG2_SIMPLE) - profile = VCD_PROFILE_MPEG2_SIMPLE; - else - profile = VCD_PROFILE_UNKNOWN; - ddl_get_mpeg2_dec_level(&level, level_codec); - break; - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - if (profile_codec == VIDC_SM_PROFILE_VC1_SIMPLE) - profile = VCD_PROFILE_VC1_SIMPLE; - else if (profile_codec == VIDC_SM_PROFILE_VC1_MAIN) - profile = VCD_PROFILE_VC1_MAIN; - else if (profile_codec == VIDC_SM_PROFILE_VC1_ADVANCED) - profile = VCD_PROFILE_VC1_ADVANCE; - else - profile = VCD_PROFILE_UNKNOWN; - ddl_get_vc1_dec_level(&level, level_codec, profile); - break; - default: - if (!profile_codec) - profile = VCD_PROFILE_UNKNOWN; - if (!level) - level = VCD_LEVEL_UNKNOWN; - break; - } - decoder->profile.profile = profile; - decoder->level.level = level; -} - -static void ddl_handle_enc_frame_done(struct ddl_client_context *ddl, - u32 eos_present) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct vcd_frame_data *output_frame = &(ddl->output_frame.vcd_frm); - u32 bottom_frame_tag; - u8 *input_buffer_address = NULL; - - vidc_sm_get_frame_tags(&ddl->shared_mem[ddl->command_channel], - &output_frame->ip_frm_tag, &bottom_frame_tag); - output_frame->data_len = encoder->enc_frame_info.enc_frame_size; - output_frame->flags |= VCD_FRAME_FLAG_ENDOFFRAME; - (void)ddl_get_encoded_frame(output_frame, - encoder->codec.codec, encoder->enc_frame_info.enc_frame - ); - if (!IS_ERR_OR_NULL(output_frame->buff_ion_handle)) { - msm_ion_do_cache_op(ddl_context->video_ion_client, - output_frame->buff_ion_handle, - (unsigned long *) output_frame->virtual, - (unsigned long) output_frame->alloc_len, - ION_IOC_INV_CACHES); - } - - if ((VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED != - encoder->enc_frame_info.enc_frame) && - (VIDC_1080P_ENCODE_FRAMETYPE_NOT_CODED != - encoder->enc_frame_info.enc_frame)) { - if (DDL_IS_LTR_ENABLED(encoder)) - ddl_handle_ltr_in_framedone(ddl); - ddl_process_encoder_metadata(ddl); - encoder->ltr_control.meta_data_reqd = false; - } - encoder->ltr_control.using = false; - ddl_vidc_encode_dynamic_property(ddl, false); - ddl->input_frame.frm_trans_end = false; - input_buffer_address = ddl_context->dram_base_a.align_physical_addr + - encoder->enc_frame_info.enc_luma_address; - ddl_get_input_frame_from_pool(ddl, input_buffer_address); - ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, &(ddl->input_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl->client_data); - ddl->output_frame.frm_trans_end = eos_present ? - false : true; - ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, &(ddl->output_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl->client_data); -} - -static void ddl_handle_slice_done_slice_batch(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct vcd_frame_data *output_frame = NULL; - u32 bottom_frame_tag; - struct vidc_1080p_enc_slice_batch_out_param *slice_output = NULL; - u32 num_slices_comp = 0; - u32 index = 0; - u32 start_bfr_idx = 0; - u32 actual_idx = 0; - - DDL_MSG_LOW("%s\n", __func__); - vidc_sm_get_num_slices_comp( - &ddl->shared_mem[ddl->command_channel], - &num_slices_comp); - slice_output = (struct vidc_1080p_enc_slice_batch_out_param *) - (encoder->batch_frame.slice_batch_out.align_virtual_addr); - DDL_MSG_LOW(" after get no of slices = %d\n", num_slices_comp); - if (slice_output == NULL) { - DDL_MSG_ERROR(" slice_output is NULL\n"); - return; /* Bail out */ - } - encoder->slice_delivery_info.num_slices_enc += num_slices_comp; - if (vidc_msg_timing) { - ddl_calc_core_proc_time_cnt(__func__, ENC_SLICE_OP_TIME, - num_slices_comp); - ddl_set_core_start_time(__func__, ENC_SLICE_OP_TIME); - } - DDL_MSG_LOW("%s : Slices Completed %d Total slices %d OutBfrInfo:" - "Cmd %d Size %d\n", - __func__, - num_slices_comp, - encoder->slice_delivery_info.num_slices_enc, - slice_output->cmd_type, - slice_output->output_size); - start_bfr_idx = encoder->batch_frame.out_frm_next_frmindex; - for (index = 0; index < num_slices_comp; index++) { - actual_idx = - slice_output->slice_info[start_bfr_idx+index].stream_buffer_idx; - DDL_MSG_LOW("Slice Info: OutBfrIndex %d SliceSize %d\n", - actual_idx, - slice_output->slice_info[start_bfr_idx+index]. - stream_buffer_size); - output_frame = &( - encoder->batch_frame.output_frame[actual_idx].vcd_frm); - DDL_MSG_LOW("OutBfr: vcd_frm 0x%x frmbfr(virtual) 0x%x" - "frmbfr(physical) 0x%x\n", - (u32)output_frame, - (u32)output_frame->virtual, - (u32)output_frame->physical); - vidc_1080p_get_encode_frame_info(&encoder->enc_frame_info); - vidc_sm_get_frame_tags(&ddl->shared_mem - [ddl->command_channel], - &output_frame->ip_frm_tag, &bottom_frame_tag); - if (!output_frame->ip_frm_tag) { - DDL_MSG_ERROR("%s: zero frame tag rcvd, index = %d", - __func__, index); - output_frame->ip_frm_tag = (u32)ddl->client_data; - } - ddl_get_encoded_frame(output_frame, - encoder->codec.codec, - encoder->enc_frame_info.enc_frame); - output_frame->data_len = - slice_output->slice_info[actual_idx].stream_buffer_size; - ddl->output_frame = - encoder->batch_frame.output_frame[actual_idx]; - ddl->output_frame.frm_trans_end = false; - ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, &(ddl->output_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl->client_data); - ddl->input_frame.frm_trans_end = false; - DDL_MSG_LOW("%s Set i/p o/p transactions to false\n", __func__); - } - encoder->batch_frame.out_frm_next_frmindex = start_bfr_idx + index; - ddl->cmd_state = DDL_CMD_ENCODE_FRAME; - vidc_sm_set_encoder_slice_batch_int_ctrl( - &ddl->shared_mem[ddl->command_channel], - 0); -} - -static u32 ddl_handle_enc_frame_done_slice_mode( - struct ddl_client_context *ddl, u32 eos_present) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct vcd_frame_data *output_frame = NULL; - u32 bottom_frame_tag; - u8 *input_buffer_address = NULL; - struct vidc_1080p_enc_slice_batch_out_param *slice_output = NULL; - u32 num_slices_comp = 0; - u32 index = 0; - u32 start_bfr_idx = 0; - u32 actual_idx = 0; - struct vcd_transc *transc; - u32 status = true; - - DDL_MSG_LOW("%s\n", __func__); - vidc_sm_get_num_slices_comp( - &ddl->shared_mem[ddl->command_channel], - &num_slices_comp); - slice_output = (struct vidc_1080p_enc_slice_batch_out_param *) - encoder->batch_frame.slice_batch_out.align_virtual_addr; - encoder->slice_delivery_info.num_slices_enc += num_slices_comp; - if (vidc_msg_timing) { - ddl_calc_core_proc_time_cnt(__func__, ENC_OP_TIME, - num_slices_comp); - } - DDL_MSG_LOW("%s Slices Completed %d Total slices done = %d" - " OutBfrInfo: Cmd %d Size %d", - __func__, - num_slices_comp, - encoder->slice_delivery_info.num_slices_enc, - slice_output->cmd_type, - slice_output->output_size); - start_bfr_idx = encoder->batch_frame.out_frm_next_frmindex; - if ((encoder->slice_delivery_info.num_slices_enc % - encoder->batch_frame.num_output_frames) != 0) { - DDL_MSG_ERROR("ERROR : %d %d\n", - encoder->slice_delivery_info.num_slices_enc, - encoder->batch_frame.num_output_frames); - status = false; - } - for (index = 0; index < num_slices_comp; index++) { - actual_idx = - slice_output->slice_info[start_bfr_idx+index]. \ - stream_buffer_idx; - DDL_MSG_LOW("Slice Info: OutBfrIndex %u SliceSize %u", - actual_idx, - slice_output->slice_info[start_bfr_idx+index]. \ - stream_buffer_size); - output_frame = - &(encoder->batch_frame.output_frame[actual_idx].vcd_frm); - DDL_MSG_LOW("OutBfr: vcd_frm 0x%x frmbfr(virtual) 0x%x" - "frmbfr(physical) 0x%x", - (u32)output_frame, - (u32)output_frame->virtual, - (u32)output_frame->physical); - vidc_1080p_get_encode_frame_info( - &encoder->enc_frame_info); - vidc_sm_get_frame_tags(&ddl->shared_mem - [ddl->command_channel], - &output_frame->ip_frm_tag, &bottom_frame_tag); - if (!output_frame->ip_frm_tag) { - DDL_MSG_ERROR("%s: zero frame tag rcvd, index = %d", - __func__, index); - output_frame->ip_frm_tag = (u32)ddl->client_data; - } - ddl_get_encoded_frame(output_frame, - encoder->codec.codec, - encoder->enc_frame_info.enc_frame); - output_frame->data_len = - slice_output->slice_info[actual_idx].stream_buffer_size; - ddl->output_frame = - encoder->batch_frame.output_frame[actual_idx]; - DDL_MSG_LOW("%s: actual_idx = %u "\ - "encoder->batch_frame.num_output_frames = %u\n", __func__, - actual_idx, encoder->batch_frame.num_output_frames); - if (encoder->batch_frame.num_output_frames == (actual_idx+1)) { - output_frame->flags |= VCD_FRAME_FLAG_ENDOFFRAME; - ddl_vidc_encode_dynamic_property(ddl, false); - ddl->input_frame.frm_trans_end = true; - DDL_MSG_LOW("%s End of frame detected\n", __func__); - input_buffer_address = - ddl_context->dram_base_a.align_physical_addr + - encoder->enc_frame_info.enc_luma_address; - ddl_get_input_frame_from_pool(ddl, - input_buffer_address); - transc = (struct vcd_transc *)(ddl->client_data); - if (eos_present) - ddl->output_frame.frm_trans_end = false; - else - ddl->output_frame.frm_trans_end = true; - } - DDL_MSG_LOW("%s Before output done cb\n", __func__); - transc = (struct vcd_transc *)(ddl->client_data); - ddl->output_frame.vcd_frm = *output_frame; - ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, &(ddl->output_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl->client_data); - } - if (encoder->batch_frame.num_output_frames == (actual_idx+1)) { - DDL_MSG_LOW("%s sending input done\n", __func__); - ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, &(ddl->input_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl->client_data); - } - - return status; -} - -static void ddl_handle_enc_skipframe_slice_mode( - struct ddl_client_context *ddl, u32 eos_present) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct vcd_frame_data *output_frame = NULL; - u32 bottom_frame_tag; - u8 *input_buffer_address = NULL; - u32 index = 0; - DDL_MSG_HIGH("ddl_handle_enc_skipframe_slice_mode: frame skipped"); - vidc_sm_set_encoder_slice_batch_int_ctrl( - &ddl->shared_mem[ddl->command_channel], - 1); - for (index = 0; - index < encoder->batch_frame.num_output_frames; - index++) { - output_frame = - &(encoder->batch_frame.output_frame[index].vcd_frm); - DDL_MSG_MED("output buffer: vcd_frm = 0x%x " - "frmbfr(virtual) = 0x%x frmbfr(physical) = 0x%x", - (u32)output_frame, (u32)output_frame->virtual, - (u32)output_frame->physical); - vidc_sm_get_frame_tags( - &ddl->shared_mem[ddl->command_channel], - &output_frame->ip_frm_tag, - &bottom_frame_tag); - if (!output_frame->ip_frm_tag) { - DDL_MSG_ERROR("%s: zero frame tag rcvd, index = %d", - __func__, index); - output_frame->ip_frm_tag = (u32)ddl->client_data; - } - ddl_get_encoded_frame( - output_frame, - encoder->codec.codec, - encoder->enc_frame_info.enc_frame); - output_frame->data_len = 0; - ddl->output_frame.frm_trans_end = false; - if (encoder->batch_frame.num_output_frames == - (index + 1)) { - DDL_MSG_MED("last output bfr for skip frame, set EOF"); - output_frame->flags |= VCD_FRAME_FLAG_ENDOFFRAME; - ddl_vidc_encode_dynamic_property(ddl, false); - if (eos_present) - ddl->output_frame.frm_trans_end = false; - else - ddl->output_frame.frm_trans_end = true; - } - ddl->output_frame.vcd_frm = *output_frame; - ddl_context->ddl_callback( - VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, - &(ddl->output_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *)ddl, - ddl->client_data); - - if (encoder->batch_frame.num_output_frames == - (index + 1)) { - ddl->input_frame.frm_trans_end = false; - input_buffer_address = - ddl_context->dram_base_a.physical_base_addr + - (encoder->enc_frame_info.enc_luma_address); - ddl_get_input_frame_from_pool(ddl, - input_buffer_address); - DDL_MSG_MED("InpBfr: vcd_frm 0x%x frmbfr(virtual) 0x%x" - " frmbfr(physical) 0x%x", - (u32)&(ddl->input_frame.vcd_frm), - (u32)ddl->input_frame.vcd_frm.virtual, - (u32)ddl->input_frame.vcd_frm.physical); - ddl_context->ddl_callback( - VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, - &(ddl->input_frame), - sizeof(struct ddl_frame_data_tag), - (u32 *)ddl, - ddl->client_data); - } - } -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_metadata.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_metadata.c deleted file mode 100644 index 2b8edddf498e62a2155cf9b46a1893326703d6e5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_metadata.c +++ /dev/null @@ -1,682 +0,0 @@ -/* Copyright (c) 2010, 2012, 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 "vcd_ddl.h" -#include "vcd_ddl_shared_mem.h" -#include "vcd_ddl_metadata.h" - -static u32 *ddl_metadata_hdr_entry(struct ddl_client_context *ddl, - u32 meta_data) -{ - u32 skip_words = 0; - u32 *buffer; - - if (ddl->decoding) { - buffer = (u32 *) ddl->codec_data.decoder.meta_data_input. - align_virtual_addr; - skip_words = 32 + 1; - buffer += skip_words; - switch (meta_data) { - default: - case VCD_METADATA_DATANONE: - skip_words = 0; - break; - case VCD_METADATA_QPARRAY: - skip_words = 3; - break; - case VCD_METADATA_CONCEALMB: - skip_words = 6; - break; - case VCD_METADATA_VC1: - skip_words = 9; - break; - case VCD_METADATA_SEI: - skip_words = 12; - break; - case VCD_METADATA_VUI: - skip_words = 15; - break; - case VCD_METADATA_PASSTHROUGH: - skip_words = 18; - break; - case VCD_METADATA_QCOMFILLER: - skip_words = 21; - break; - case VCD_METADATA_USER_DATA: - skip_words = 27; - break; - case VCD_METADATA_EXT_DATA: - skip_words = 30; - break; - } - } else { - buffer = (u32 *) ddl->codec_data.encoder.meta_data_input. - align_virtual_addr; - skip_words = 2; - buffer += skip_words; - switch (meta_data) { - default: - case VCD_METADATA_DATANONE: - skip_words = 0; - break; - case VCD_METADATA_ENC_SLICE: - skip_words = 3; - break; - case VCD_METADATA_QCOMFILLER: - skip_words = 6; - break; - case VCD_METADATA_LTR_INFO: - skip_words = 9; - break; - } - } - buffer += skip_words; - return buffer; -} - -void ddl_set_default_meta_data_hdr(struct ddl_client_context *ddl) -{ - struct ddl_buf_addr *main_buffer = - &ddl->ddl_context->metadata_shared_input; - struct ddl_buf_addr *client_buffer; - u32 *hdr_entry; - - if (ddl->decoding) - client_buffer = &(ddl->codec_data.decoder.meta_data_input); - else - client_buffer = &(ddl->codec_data.encoder.meta_data_input); - DDL_METADATA_CLIENT_INPUTBUF(main_buffer, client_buffer, - ddl->instance_id); - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_QCOMFILLER); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_QCOMFILLER; - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_DATANONE); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_DATANONE; - if (ddl->decoding) { - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_QPARRAY); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_QPARRAY; - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_CONCEALMB); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_CONCEALMB; - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_SEI); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_SEI; - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_VUI); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_VUI; - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_VC1); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_VC1; - hdr_entry = ddl_metadata_hdr_entry(ddl, - VCD_METADATA_PASSTHROUGH); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = - VCD_METADATA_PASSTHROUGH; - hdr_entry = ddl_metadata_hdr_entry(ddl, - VCD_METADATA_USER_DATA); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = - VCD_METADATA_USER_DATA; - hdr_entry = ddl_metadata_hdr_entry(ddl, - VCD_METADATA_EXT_DATA); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = - VCD_METADATA_EXT_DATA; - } else { - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_ENC_SLICE); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_ENC_SLICE; - - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_LTR_INFO); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_LTR_INFO; - } -} - -static u32 ddl_supported_metadata_flag(struct ddl_client_context *ddl) -{ - u32 flag = 0; - enum vcd_codec codec = - ddl->codec_data.decoder.codec.codec; - - if (ddl->decoding) { - flag |= (VCD_METADATA_CONCEALMB | VCD_METADATA_PASSTHROUGH | - VCD_METADATA_QPARRAY | - VCD_METADATA_SEPARATE_BUF); - if (codec == VCD_CODEC_H264) - flag |= (VCD_METADATA_SEI | VCD_METADATA_VUI); - else if (codec == VCD_CODEC_VC1 || - codec == VCD_CODEC_VC1_RCV) - flag |= VCD_METADATA_VC1; - else if (codec == VCD_CODEC_MPEG2) - flag |= (VCD_METADATA_USER_DATA | - VCD_METADATA_EXT_DATA); - } else { - if (codec == VCD_CODEC_H264) - flag |= VCD_METADATA_ENC_SLICE | VCD_METADATA_LTR_INFO; - else - flag |= VCD_METADATA_ENC_SLICE; - } - return flag; -} - -void ddl_set_default_metadata_flag(struct ddl_client_context *ddl) -{ - if (ddl->decoding) - ddl->codec_data.decoder.meta_data_enable_flag = 0; - else - ddl->codec_data.encoder.meta_data_enable_flag = 0; -} - -void ddl_set_default_decoder_metadata_buffer_size(struct ddl_decoder_data - *decoder, struct vcd_property_frame_size *frame_size, - struct vcd_buffer_requirement *output_buf_req) -{ - u32 flag = decoder->meta_data_enable_flag; - u32 suffix = 0, size = 0; - if (!flag) { - decoder->suffix = 0; - return; - } - if (flag & VCD_METADATA_QPARRAY) { - u32 num_of_mb = DDL_NO_OF_MB(frame_size->width, - frame_size->height); - - size = DDL_METADATA_HDR_SIZE; - size += num_of_mb; - DDL_METADATA_ALIGNSIZE(size); - suffix += size; - } - if (flag & VCD_METADATA_CONCEALMB) { - u32 num_of_mb = DDL_NO_OF_MB(frame_size->width, - frame_size->height); - size = DDL_METADATA_HDR_SIZE + (num_of_mb >> 3); - DDL_METADATA_ALIGNSIZE(size); - suffix += size; - } - if (flag & VCD_METADATA_VC1) { - size = DDL_METADATA_HDR_SIZE; - size += DDL_METADATA_VC1_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += size; - } - if (flag & VCD_METADATA_SEI) { - size = DDL_METADATA_HDR_SIZE; - size += DDL_METADATA_SEI_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += (size * DDL_METADATA_SEI_MAX); - } - if (flag & VCD_METADATA_VUI) { - size = DDL_METADATA_HDR_SIZE; - size += DDL_METADATA_VUI_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += (size); - } - if (flag & VCD_METADATA_PASSTHROUGH) { - size = DDL_METADATA_HDR_SIZE; - size += DDL_METADATA_PASSTHROUGH_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += (size); - } - if (flag & VCD_METADATA_USER_DATA) { - size = DDL_METADATA_HDR_SIZE; - size += DDL_METADATA_USER_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += (size); - } - if (flag & VCD_METADATA_EXT_DATA) { - size = DDL_METADATA_HDR_SIZE; - size += DDL_METADATA_EXT_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += (size); - } - size = DDL_METADATA_EXTRADATANONE_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += (size); - suffix += DDL_METADATA_EXTRAPAD_SIZE; - DDL_METADATA_ALIGNSIZE(suffix); - decoder->suffix = suffix; - output_buf_req->sz += suffix; - output_buf_req->meta_buffer_size = suffix; - output_buf_req->meta_buffer_size = - (output_buf_req->meta_buffer_size + 8191) & (~8191); - decoder->meta_data_offset = 0; - DDL_MSG_LOW("metadata output buf size : %d", suffix); -} - -void ddl_set_default_encoder_metadata_buffer_size(struct ddl_encoder_data - *encoder) -{ - u32 flag = encoder->meta_data_enable_flag; - u32 suffix = 0, size = 0; - - if (!flag) { - encoder->suffix = 0; - return; - } - if (flag & VCD_METADATA_ENC_SLICE) { - u32 num_of_mb = DDL_NO_OF_MB(encoder->frame_size.width, - encoder->frame_size.height); - size = DDL_METADATA_HDR_SIZE; - size += 4; - size += (num_of_mb << 3); - DDL_METADATA_ALIGNSIZE(size); - suffix += size; - } - if (flag & VCD_METADATA_LTR_INFO) { - size = DDL_METADATA_HDR_SIZE; - size += DDL_METADATA_LTR_INFO_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += size; - } - size = DDL_METADATA_EXTRADATANONE_SIZE; - DDL_METADATA_ALIGNSIZE(size); - suffix += (size); - suffix += DDL_METADATA_EXTRAPAD_SIZE; - DDL_METADATA_ALIGNSIZE(suffix); - encoder->suffix = suffix; - encoder->output_buf_req.sz += suffix; - encoder->output_buf_req.sz = - DDL_ALIGN(encoder->output_buf_req.sz, DDL_KILO_BYTE(4)); -} - -u32 ddl_set_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - if (property_hdr->prop_id == VCD_I_METADATA_ENABLE) { - struct vcd_property_meta_data_enable *meta_data_enable = - (struct vcd_property_meta_data_enable *) property_value; - u32 *meta_data_enable_flag; - enum vcd_codec codec; - - if (ddl->decoding) { - meta_data_enable_flag = - &(ddl->codec_data.decoder.meta_data_enable_flag); - codec = ddl->codec_data.decoder.codec.codec; - } else { - meta_data_enable_flag = - &ddl->codec_data.encoder.meta_data_enable_flag; - codec = ddl->codec_data.encoder.codec.codec; - } - if (sizeof(struct vcd_property_meta_data_enable) == - property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && codec) { - u32 flag = ddl_supported_metadata_flag(ddl); - flag &= (meta_data_enable->meta_data_enable_flag); - if (flag) - flag |= DDL_METADATA_MANDATORY; - if (*meta_data_enable_flag != flag) { - if (VCD_CODEC_MPEG2 == codec) - ddl_set_mp2_dump_default( - &ddl->codec_data.decoder, - flag); - *meta_data_enable_flag = flag; - if (ddl->decoding) - ddl_set_default_decoder_buffer_req( - &ddl->codec_data.decoder, true); - else - ddl_set_default_encoder_buffer_req( - &ddl->codec_data.encoder); - } - vcd_status = VCD_S_SUCCESS; - } - } else if (property_hdr->prop_id == VCD_I_METADATA_HEADER) { - struct vcd_property_metadata_hdr *hdr = - (struct vcd_property_metadata_hdr *) property_value; - - if (sizeof(struct vcd_property_metadata_hdr) == - property_hdr->sz) { - u32 flag = ddl_supported_metadata_flag(ddl); - - flag |= DDL_METADATA_MANDATORY; - flag &= hdr->meta_data_id; - if (!(flag & (flag - 1))) { - u32 *hdr_entry = ddl_metadata_hdr_entry(ddl, - flag); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = - hdr->version; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = - hdr->port_index; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = - hdr->type; - vcd_status = VCD_S_SUCCESS; - } - } - } - return vcd_status; -} - -u32 ddl_get_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - if (property_hdr->prop_id == VCD_I_METADATA_ENABLE && - sizeof(struct vcd_property_meta_data_enable) == - property_hdr->sz) { - struct vcd_property_meta_data_enable *meta_data_enable = - (struct vcd_property_meta_data_enable *) property_value; - - meta_data_enable->meta_data_enable_flag = - ((ddl->decoding) ? - (ddl->codec_data.decoder.meta_data_enable_flag) : - (ddl->codec_data.encoder.meta_data_enable_flag)); - vcd_status = VCD_S_SUCCESS; - } else if (property_hdr->prop_id == VCD_I_METADATA_HEADER && - sizeof(struct vcd_property_metadata_hdr) == - property_hdr->sz) { - struct vcd_property_metadata_hdr *hdr = - (struct vcd_property_metadata_hdr *) property_value; - u32 flag = ddl_supported_metadata_flag(ddl); - - flag |= DDL_METADATA_MANDATORY; - flag &= hdr->meta_data_id; - if (!(flag & (flag - 1))) { - u32 *hdr_entry = ddl_metadata_hdr_entry(ddl, flag); - hdr->version = - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX]; - hdr->port_index = - hdr_entry[DDL_METADATA_HDR_PORT_INDEX]; - hdr->type = hdr_entry[DDL_METADATA_HDR_TYPE_INDEX]; - vcd_status = VCD_S_SUCCESS; - } - } - return vcd_status; -} - -void ddl_vidc_metadata_enable(struct ddl_client_context *ddl) -{ - u32 flag, extradata_enable = false; - u32 qp_enable = false, concealed_mb_enable = false; - u32 vc1_param_enable = false, sei_nal_enable = false; - u32 vui_enable = false, enc_slice_size_enable = false; - u32 mp2_data_dump_enable = false; - - if (ddl->decoding) - flag = ddl->codec_data.decoder.meta_data_enable_flag; - else - flag = ddl->codec_data.encoder.meta_data_enable_flag; - if (flag) { - if (flag & VCD_METADATA_QPARRAY) - qp_enable = true; - if (flag & VCD_METADATA_CONCEALMB) - concealed_mb_enable = true; - if (flag & VCD_METADATA_VC1) - vc1_param_enable = true; - if (flag & VCD_METADATA_SEI) - sei_nal_enable = true; - if (flag & VCD_METADATA_VUI) - vui_enable = true; - if (flag & VCD_METADATA_ENC_SLICE) - enc_slice_size_enable = true; - if (flag & VCD_METADATA_PASSTHROUGH) - extradata_enable = true; - } - - DDL_MSG_LOW("metadata enable flag : %d", sei_nal_enable); - if (flag & VCD_METADATA_EXT_DATA || flag & VCD_METADATA_USER_DATA) { - mp2_data_dump_enable = true; - ddl->codec_data.decoder.extn_user_data_enable = - mp2_data_dump_enable; - vidc_sm_set_mp2datadump_enable(&ddl->shared_mem - [ddl->command_channel], - &ddl->codec_data.decoder.mp2_datadump_enable); - } else { - mp2_data_dump_enable = false; - ddl->codec_data.decoder.extn_user_data_enable = - mp2_data_dump_enable; - } - vidc_sm_set_metadata_enable(&ddl->shared_mem - [ddl->command_channel], extradata_enable, qp_enable, - concealed_mb_enable, vc1_param_enable, sei_nal_enable, - vui_enable, enc_slice_size_enable, mp2_data_dump_enable); -} - -u32 ddl_vidc_encode_set_metadata_output_buf(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &ddl->codec_data.encoder; - struct vcd_frame_data *stream = &ddl->output_frame.vcd_frm; - struct ddl_context *ddl_context; - u32 ext_buffer_end, hw_metadata_start; - u32 *buffer; - - ddl_context = ddl_get_context(); - ext_buffer_end = (u32) stream->physical + stream->alloc_len; - if (!encoder->meta_data_enable_flag) { - ext_buffer_end &= ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - return ext_buffer_end; - } - hw_metadata_start = (ext_buffer_end - encoder->suffix) & - ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - ext_buffer_end = (hw_metadata_start - 1) & - ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - buffer = (u32 *) encoder->meta_data_input.align_virtual_addr; - *buffer++ = encoder->suffix; - *buffer = DDL_OFFSET(ddl_context->dram_base_a.align_physical_addr, - hw_metadata_start); - encoder->meta_data_offset = hw_metadata_start - (u32) stream->physical; - return ext_buffer_end; -} - -void ddl_vidc_decode_set_metadata_output(struct ddl_decoder_data *decoder) -{ - struct ddl_context *ddl_context; - u32 loopc, yuv_size, dpb; - u32 *buffer; - struct ddl_dec_buffers *dec_buffers = &decoder->hw_bufs; - if (!decoder->meta_data_enable_flag) { - decoder->meta_data_offset = 0; - return; - } - dpb = decoder->dp_buf.no_of_dec_pic_buf; - ddl_context = ddl_get_context(); - yuv_size = ddl_get_yuv_buffer_size(&decoder->client_frame_size, - &decoder->buf_format, !decoder->progressive_only, - decoder->hdr.decoding, NULL); - decoder->meta_data_offset = DDL_ALIGN_SIZE(yuv_size, - DDL_LINEAR_BUF_ALIGN_GUARD_BYTES, DDL_LINEAR_BUF_ALIGN_MASK); - buffer = (u32 *) decoder->meta_data_input.align_virtual_addr; - DDL_MSG_LOW("Metadata offset & size : %d/%d", - decoder->meta_data_offset, decoder->suffix); - if (!(decoder->meta_data_enable_flag & VCD_METADATA_SEPARATE_BUF)) { - *buffer++ = decoder->suffix; - for (loopc = 0; loopc < dpb; ++loopc) { - *buffer++ = (u32)(decoder->meta_data_offset + (u8 *) - DDL_OFFSET(ddl_context->dram_base_a. - align_physical_addr, decoder->dp_buf. - dec_pic_buffers[loopc].vcd_frm.physical)); - } - } else { - *buffer++ = decoder->actual_output_buf_req.meta_buffer_size; - for (loopc = 0; loopc < dpb; ++loopc) { - *buffer++ = DDL_ADDR_OFFSET(ddl_context->dram_base_a, - dec_buffers->meta_hdr[loopc]); - } - } -} - -void ddl_process_encoder_metadata(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct vcd_frame_data *out_frame = - &(ddl->output_frame.vcd_frm); - u32 *qfiller_hdr, *qfiller, start_addr; - u32 qfiller_size; - u8 *extradata_addr; - u32 metadata_available = false; - - out_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - if (!encoder->meta_data_enable_flag) { - DDL_MSG_HIGH("meta_data is not enabled"); - goto exit; - } - start_addr = (u32) ((u8 *)out_frame->virtual + out_frame->offset); - extradata_addr = (u8 *)((out_frame->data_len + - start_addr + 3) & ~3); - qfiller = (u32 *)extradata_addr; - qfiller_size = (u32)((encoder->meta_data_offset + - (u8 *) out_frame->virtual) - (u8 *) qfiller); - if (qfiller_size & 3) { - DDL_MSG_ERROR("qfiller_size is not 4 bytes aligned"); - goto exit; - } - qfiller_hdr = ddl_metadata_hdr_entry(ddl, VCD_METADATA_QCOMFILLER); - *qfiller++ = qfiller_size; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_VERSION_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_PORT_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_TYPE_INDEX]; - *qfiller = (u32)(qfiller_size - DDL_METADATA_HDR_SIZE); - extradata_addr += qfiller_size; - if ((u32)extradata_addr != - (u32)((u8 *)start_addr + encoder->meta_data_offset)) { - DDL_MSG_ERROR("wrong qfiller size"); - goto exit; - } - if (encoder->meta_data_enable_flag & VCD_METADATA_ENC_SLICE) { - u32 *sliceinfo = (u32 *)extradata_addr; - if (sliceinfo[3] != VCD_METADATA_ENC_SLICE) { - DDL_MSG_ERROR("wrong slice info extradata. " \ - "data: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x", - sliceinfo[0], sliceinfo[1], sliceinfo[2], - sliceinfo[3], sliceinfo[4], sliceinfo[5]); - goto metadata_end; - } - extradata_addr += sliceinfo[0]; - metadata_available = true; - DDL_MSG_HIGH("%s: Send %u slices info in metadata", - __func__, sliceinfo[5]); - } - if ((encoder->meta_data_enable_flag & VCD_METADATA_LTR_INFO) && - (encoder->ltr_control.meta_data_reqd == true)) { - u32 *ltrinfo_hdr = ddl_metadata_hdr_entry(ddl, - VCD_METADATA_LTR_INFO); - u32 *ltrinfo = (u32 *)extradata_addr; - if ((u32)extradata_addr > (u32)((u8 *)out_frame->virtual + - out_frame->alloc_len)) { - metadata_available = false; - DDL_MSG_ERROR("Error: extradata_addr = 0x%p, "\ - "buffer_start = 0x%p, size = %u", - extradata_addr, out_frame->virtual, - out_frame->alloc_len); - goto metadata_end; - } - ltrinfo[0] = DDL_METADATA_LTR_INFO_PAYLOAD_SIZE + - DDL_METADATA_HDR_SIZE; - ltrinfo[1] = ltrinfo_hdr[DDL_METADATA_HDR_VERSION_INDEX]; - ltrinfo[2] = ltrinfo_hdr[DDL_METADATA_HDR_PORT_INDEX]; - ltrinfo[3] = ltrinfo_hdr[DDL_METADATA_HDR_TYPE_INDEX]; - ltrinfo[4] = DDL_METADATA_LTR_INFO_PAYLOAD_SIZE; - ltrinfo[5] = encoder->ltr_control.curr_ltr_id; - extradata_addr += ltrinfo[0]; - encoder->ltr_control.curr_ltr_id++; - metadata_available = true; - DDL_MSG_HIGH("%s: Send curr_ltr_id = %u in metadata", - __func__, (u32)encoder->ltr_control.curr_ltr_id); - } -metadata_end: - if (metadata_available == true) { - u32 *data_none_hdr = ddl_metadata_hdr_entry(ddl, - VCD_METADATA_DATANONE); - u32 *data_none = (u32 *)extradata_addr; - DDL_MSG_LOW("prepare metadata_none header"); - data_none[0] = DDL_METADATA_EXTRADATANONE_SIZE; - data_none[1] = data_none_hdr[DDL_METADATA_HDR_VERSION_INDEX]; - data_none[2] = data_none_hdr[DDL_METADATA_HDR_PORT_INDEX]; - data_none[3] = data_none_hdr[DDL_METADATA_HDR_TYPE_INDEX]; - data_none[4] = 0; - out_frame->flags |= VCD_FRAME_FLAG_EXTRADATA; - } -exit: - return; -} - -void ddl_process_decoder_metadata(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vcd_frame_data *output_frame = - &(ddl->output_frame.vcd_frm); - u32 *qfiller_hdr, *qfiller; - u32 qfiller_size; - - if (!decoder->meta_data_enable_flag) { - output_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - return; - } - if (!decoder->meta_data_exists) { - output_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - return; - } - if (!decoder->mp2_datadump_status && decoder->codec.codec == - VCD_CODEC_MPEG2 && !decoder->extn_user_data_enable) { - output_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - return; - } - DDL_MSG_LOW("processing metadata for decoder"); - DDL_MSG_LOW("data_len/metadata_offset : %d/%d", - output_frame->data_len, decoder->meta_data_offset); - output_frame->flags |= VCD_FRAME_FLAG_EXTRADATA; - if (!(decoder->meta_data_enable_flag & VCD_METADATA_SEPARATE_BUF) - && (output_frame->data_len != decoder->meta_data_offset)) { - qfiller = (u32 *)((u32)((output_frame->data_len + - output_frame->offset + - (u8 *) output_frame->virtual) + 3) & ~3); - qfiller_size = (u32)((decoder->meta_data_offset + - (u8 *) output_frame->virtual) - - (u8 *) qfiller); - qfiller_hdr = ddl_metadata_hdr_entry(ddl, - VCD_METADATA_QCOMFILLER); - *qfiller++ = qfiller_size; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_VERSION_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_PORT_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_TYPE_INDEX]; - *qfiller = (u32)(qfiller_size - DDL_METADATA_HDR_SIZE); - } -} - -void ddl_set_mp2_dump_default(struct ddl_decoder_data *decoder, u32 flag) -{ - - if (flag & VCD_METADATA_EXT_DATA) { - decoder->mp2_datadump_enable.pictempscalable_extdump_enable = - true; - decoder->mp2_datadump_enable.picspat_extdump_enable = true; - decoder->mp2_datadump_enable.picdisp_extdump_enable = true; - decoder->mp2_datadump_enable.copyright_extdump_enable = true; - decoder->mp2_datadump_enable.quantmatrix_extdump_enable = - true; - decoder->mp2_datadump_enable.seqscalable_extdump_enable = - true; - decoder->mp2_datadump_enable.seqdisp_extdump_enable = true; - decoder->mp2_datadump_enable.seq_extdump_enable = true; - } - if (flag & VCD_METADATA_USER_DATA) - decoder->mp2_datadump_enable.userdatadump_enable = - DDL_METADATA_USER_DUMP_FULL_MODE; - else - decoder->mp2_datadump_enable.userdatadump_enable = - DDL_METADATA_USER_DUMP_DISABLE_MODE; -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_metadata.h b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_metadata.h deleted file mode 100644 index 5be38d0d9f6c95c3c190be34e13a7e05d4151c5b..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_metadata.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (c) 2010, 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 _VCD_DDL_METADATA_H_ -#define _VCD_DDL_METADATA_H_ - -#define DDL_MAX_DEC_METADATATYPE 10 -#define DDL_MAX_ENC_METADATATYPE 3 -#define DDL_METADATA_EXTRAPAD_SIZE 256 -#define DDL_METADATA_HDR_SIZE 20 -#define DDL_METADATA_EXTRADATANONE_SIZE 24 -#define DDL_METADATA_ALIGNSIZE(x) ((x) = (((x) + 0x7) & ~0x7)) -#define DDL_METADATA_MANDATORY \ - (VCD_METADATA_DATANONE | VCD_METADATA_QCOMFILLER) -#define DDL_METADATA_VC1_PAYLOAD_SIZE (38*4) -#define DDL_METADATA_SEI_PAYLOAD_SIZE 100 -#define DDL_METADATA_SEI_MAX 5 -#define DDL_METADATA_VUI_PAYLOAD_SIZE 256 -#define DDL_METADATA_LTR_INFO_PAYLOAD_SIZE (4) -#define DDL_METADATA_PASSTHROUGH_PAYLOAD_SIZE 68 -#define DDL_METADATA_EXT_PAYLOAD_SIZE (640) -#define DDL_METADATA_USER_PAYLOAD_SIZE (2048) -#define DDL_METADATA_CLIENT_INPUTBUFSIZE 256 -#define DDL_METADATA_TOTAL_INPUTBUFSIZE \ - (DDL_METADATA_CLIENT_INPUTBUFSIZE * VCD_MAX_NO_CLIENT) - -#define DDL_METADATA_CLIENT_INPUTBUF(main_buffer, client_buffer,\ - channel_id) { \ - (client_buffer)->align_physical_addr = (u8 *) \ - ((u8 *)(main_buffer)->align_physical_addr + \ - (DDL_METADATA_CLIENT_INPUTBUFSIZE * channel_id)); \ - (client_buffer)->align_virtual_addr = (u8 *) \ - ((u8 *)(main_buffer)->align_virtual_addr + \ - (DDL_METADATA_CLIENT_INPUTBUFSIZE * channel_id)); \ - (client_buffer)->virtual_base_addr = 0; \ - } - -#define DDL_METADATA_HDR_VERSION_INDEX 0 -#define DDL_METADATA_HDR_PORT_INDEX 1 -#define DDL_METADATA_HDR_TYPE_INDEX 2 - -#define DDL_METADATA_USER_DUMP_DISABLE_MODE 0 -#define DDL_METADATA_USER_DUMP_OFFSET_MODE 1 -#define DDL_METADATA_USER_DUMP_FULL_MODE 2 - -void ddl_set_default_meta_data_hdr(struct ddl_client_context *ddl); -u32 ddl_get_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value); -u32 ddl_set_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value); -void ddl_set_default_metadata_flag(struct ddl_client_context *ddl); -void ddl_set_default_decoder_metadata_buffer_size(struct ddl_decoder_data - *decoder, struct vcd_property_frame_size *frame_size, - struct vcd_buffer_requirement *output_buf_req); -void ddl_set_default_encoder_metadata_buffer_size( - struct ddl_encoder_data *encoder); -void ddl_vidc_metadata_enable(struct ddl_client_context *ddl); -u32 ddl_vidc_encode_set_metadata_output_buf(struct ddl_client_context *ddl); -void ddl_vidc_decode_set_metadata_output(struct ddl_decoder_data *decoder); -void ddl_process_encoder_metadata(struct ddl_client_context *ddl); -void ddl_process_decoder_metadata(struct ddl_client_context *ddl); -void ddl_set_mp2_dump_default(struct ddl_decoder_data *decoder, u32 flag); - -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_properties.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_properties.c deleted file mode 100644 index 5cf2f9cf8d9282fe55019a1a462429847a962ba7..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_properties.c +++ /dev/null @@ -1,2451 +0,0 @@ -/* Copyright (c) 2010-2013, 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 "vcd_ddl.h" -#include "vcd_ddl_metadata.h" -#include "vcd_res_tracker_api.h" - -static u32 ddl_set_dec_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, void *property_value); -static u32 ddl_set_enc_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, void *property_value); -static u32 ddl_get_dec_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, void *property_value); -static u32 ddl_get_enc_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, void *property_value); -static u32 ddl_set_enc_dynamic_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value); -static void ddl_set_default_enc_property(struct ddl_client_context *ddl); -static void ddl_set_default_enc_profile( - struct ddl_encoder_data *encoder); -static void ddl_set_default_enc_level(struct ddl_encoder_data *encoder); -static void ddl_set_default_enc_vop_timing( - struct ddl_encoder_data *encoder); -static void ddl_set_default_enc_intra_period( - struct ddl_encoder_data *encoder); -static void ddl_set_default_enc_rc_params( - struct ddl_encoder_data *encoder); -static u32 ddl_valid_buffer_requirement( - struct vcd_buffer_requirement *original_buf_req, - struct vcd_buffer_requirement *req_buf_req); -static u32 ddl_decoder_min_num_dpb(struct ddl_decoder_data *decoder); -static u32 ddl_set_dec_buffers(struct ddl_decoder_data *decoder, - struct ddl_property_dec_pic_buffers *dpb); - -u32 ddl_set_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - struct ddl_context *ddl_context; - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - u32 vcd_status; - - DDL_MSG_HIGH("ddl_set_property"); - if (!property_hdr || !property_value) { - DDL_MSG_ERROR("ddl_set_prop:Bad_argument"); - return VCD_ERR_ILLEGAL_PARM; - } - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) { - DDL_MSG_ERROR("ddl_set_prop:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (!ddl) { - DDL_MSG_ERROR("ddl_set_prop:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (ddl->decoding) - vcd_status = ddl_set_dec_property(ddl, property_hdr, - property_value); - else - vcd_status = ddl_set_enc_property(ddl, property_hdr, - property_value); - if (vcd_status) - DDL_MSG_ERROR("ddl_set_prop:FAILED"); - return vcd_status; -} - -u32 ddl_get_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - struct ddl_context *ddl_context; - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - - DDL_MSG_HIGH("ddl_get_property"); - if (!property_hdr || !property_value) - return VCD_ERR_ILLEGAL_PARM; - if (property_hdr->prop_id == DDL_I_CAPABILITY) { - if (sizeof(struct ddl_property_capability) == - property_hdr->sz) { - struct ddl_property_capability *ddl_capability = - (struct ddl_property_capability *) - property_value; - - ddl_capability->max_num_client = VCD_MAX_NO_CLIENT; - ddl_capability->exclusive = VCD_COMMAND_EXCLUSIVE; - ddl_capability->frame_command_depth = - VCD_FRAME_COMMAND_DEPTH; - ddl_capability->general_command_depth = - VCD_GENEVIDC_COMMAND_DEPTH; - ddl_capability->ddl_time_out_in_ms = - DDL_HW_TIMEOUT_IN_MS; - vcd_status = VCD_S_SUCCESS; - } - return vcd_status; - } - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) - return VCD_ERR_ILLEGAL_OP; - if (!ddl) - return VCD_ERR_BAD_HANDLE; - if (ddl->decoding) - vcd_status = ddl_get_dec_property(ddl, property_hdr, - property_value); - else - vcd_status = ddl_get_enc_property(ddl, property_hdr, - property_value); - if (vcd_status) - DDL_MSG_ERROR("ddl_get_prop:FAILED"); - else - DDL_MSG_MED("ddl_get_prop:SUCCESS"); - return vcd_status; -} - -u32 ddl_decoder_ready_to_start(struct ddl_client_context *ddl, - struct vcd_sequence_hdr *header) -{ - struct ddl_decoder_data *decoder = - &(ddl->codec_data.decoder); - - if (!decoder->codec.codec) { - DDL_MSG_ERROR("ddl_dec_start_check:Codec_not_set"); - return false; - } - if ((!header) && (!decoder->client_frame_size.height || - !decoder->client_frame_size.width)) { - DDL_MSG_ERROR("ddl_dec_start_check:" - "Client_height_width_default"); - return false; - } - return true; -} - -u32 ddl_encoder_ready_to_start(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - - if (!encoder->codec.codec || !encoder->frame_size.height || - !encoder->frame_size.width || - !encoder->frame_rate.fps_denominator || - !encoder->frame_rate.fps_numerator || - !encoder->target_bit_rate.target_bitrate) - return false; - if (encoder->frame_rate.fps_numerator > - (encoder->frame_rate.fps_denominator * - encoder->vop_timing.vop_time_resolution)) { - DDL_MSG_ERROR("ResVsFrameRateFailed!"); - return false; - } - if (encoder->profile.profile == VCD_PROFILE_H264_BASELINE && - encoder->entropy_control.entropy_sel == VCD_ENTROPY_SEL_CABAC) { - DDL_MSG_ERROR("H264BaseLineCABAC!!"); - return false; - } - if (DDL_IS_LTR_ENABLED(encoder)) { - if ((encoder->codec.codec != VCD_CODEC_H264) || - (encoder->i_period.b_frames)) { - DDL_MSG_ERROR("%s: Only support LTR encoding "\ - "for H264 without B frame. Current "\ - "codec %d, B-frame %d", __func__, - encoder->codec.codec, - encoder->i_period.b_frames); - return false; - } - if (encoder->ltr_control.ltrmode.ltr_mode == - VCD_LTR_MODE_MANUAL) { - DDL_MSG_ERROR("%s: Manual LTR mode not supported!", - __func__); - return false; - } - DDL_MSG_HIGH("%s: LTR: mode = %u, count = %u, period = %u", - __func__, (u32)encoder->ltr_control.ltrmode.ltr_mode, - encoder->ltr_control.ltr_count, - encoder->ltr_control.ltr_period); - } - - return true; -} - -static u32 ddl_set_dec_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - u32 vcd_status = VCD_ERR_ILLEGAL_PARM ; - - switch (property_hdr->prop_id) { - case DDL_I_DPB_RELEASE: - if ((sizeof(struct ddl_frame_data_tag) == - property_hdr->sz) && - (decoder->dp_buf.no_of_dec_pic_buf)) - vcd_status = ddl_decoder_dpb_transact(decoder, - (struct ddl_frame_data_tag *) - property_value, DDL_DPB_OP_MARK_FREE); - break; - case DDL_I_DPB: - { - struct ddl_property_dec_pic_buffers *dpb = - (struct ddl_property_dec_pic_buffers *) property_value; - - if ((sizeof(struct ddl_property_dec_pic_buffers) == - property_hdr->sz) && - (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_INITCODEC) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) && - (dpb->no_of_dec_pic_buf == - decoder->client_output_buf_req.actual_count)) - vcd_status = ddl_set_dec_buffers(decoder, dpb); - } - break; - case DDL_I_REQ_OUTPUT_FLUSH: - if (sizeof(u32) == property_hdr->sz) { - decoder->dynamic_prop_change |= - DDL_DEC_REQ_OUTPUT_FLUSH; - decoder->dpb_mask.client_mask = 0; - decoder->field_needed_for_prev_ip = 0; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_INPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *)property_value; - - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && - (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_INITCODEC) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) && - (ddl_valid_buffer_requirement( - &decoder->min_input_buf_req, buffer_req))) { - decoder->client_input_buf_req = *buffer_req; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case DDL_I_OUTPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *)property_value; - - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && - (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_INITCODEC) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) && - (ddl_valid_buffer_requirement( - &decoder->min_output_buf_req, buffer_req))) { - decoder->client_output_buf_req = - *buffer_req; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_CODEC: - { - struct vcd_property_codec *codec = - (struct vcd_property_codec *)property_value; - if (sizeof(struct vcd_property_codec) == - property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - ddl_codec_type_transact(ddl, false, - codec->codec)) { - if (decoder->codec.codec != codec->codec) { - decoder->codec = *codec; - ddl_set_default_dec_property(ddl); - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_POST_FILTER: - if (sizeof(struct vcd_property_post_filter) == - property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && ( - decoder->codec.codec == VCD_CODEC_MPEG4 || - decoder->codec.codec == VCD_CODEC_MPEG2)) { - decoder->post_filter = - *(struct vcd_property_post_filter *) - property_value; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_FRAME_SIZE: - { - struct vcd_property_frame_size *frame_size = - (struct vcd_property_frame_size *) property_value; - if ((sizeof(struct vcd_property_frame_size) == - property_hdr->sz) && - (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) && - (DDL_ALLOW_DEC_FRAMESIZE(frame_size->width, - frame_size->height))) { - if (decoder->client_frame_size.height != - frame_size->height || - decoder->client_frame_size.width != - frame_size->width) { - decoder->client_frame_size = *frame_size; - ddl_set_default_decoder_buffer_req(decoder, - true); - } - DDL_MSG_LOW("set VCD_I_FRAME_SIZE width = %d" - " height = %d\n", - frame_size->width, frame_size->height); - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_SET_TURBO_CLK: - { - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_BUFFER_FORMAT: - { - struct vcd_property_buffer_format *tile = - (struct vcd_property_buffer_format *) - property_value; - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - tile->buffer_format == VCD_BUFFER_FORMAT_TILE_4x2) { - if (tile->buffer_format != - decoder->buf_format.buffer_format) { - decoder->buf_format = *tile; - ddl_set_default_decoder_buffer_req( - decoder, true); - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_SET_EXT_METABUFFER: - { - int index, buffer_size; - u8 *phys_addr; - u8 *virt_addr; - struct vcd_property_meta_buffer *meta_buffer = - (struct vcd_property_meta_buffer *) property_value; - DDL_MSG_LOW("Entered VCD_I_SET_EXT_METABUFFER Virt: %p,"\ - "Phys %p, fd: %d size: %d count: %d", - meta_buffer->kernel_virtual_addr, - meta_buffer->physical_addr, - meta_buffer->pmem_fd, - meta_buffer->size, meta_buffer->count); - if ((property_hdr->sz == sizeof(struct - vcd_property_meta_buffer)) && - (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_INITCODEC) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN))) { - phys_addr = meta_buffer->dev_addr; - virt_addr = meta_buffer->kernel_virtual_addr; - buffer_size = meta_buffer->size/meta_buffer->count; - - for (index = 0; index < meta_buffer->count; index++) { - ddl->codec_data.decoder.hw_bufs. - meta_hdr[index].align_physical_addr - = phys_addr; - ddl->codec_data.decoder.hw_bufs. - meta_hdr[index].align_virtual_addr - = virt_addr; - ddl->codec_data.decoder.hw_bufs. - meta_hdr[index].buffer_size - = buffer_size; - ddl->codec_data.decoder.hw_bufs. - meta_hdr[index].physical_base_addr - = phys_addr; - ddl->codec_data.decoder.hw_bufs. - meta_hdr[index].virtual_base_addr - = virt_addr; - - DDL_MSG_LOW("Meta Buffer: "\ - "Assigned %d buffer for " - "virt: %p, phys %p for " - "meta_buffers " - "of size: %d\n", - index, virt_addr, - phys_addr, buffer_size); - - phys_addr += buffer_size; - virt_addr += buffer_size; - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_H264_MV_BUFFER: - { - int index, buffer_size; - u8 *phys_addr; - u8 *virt_addr; - struct vcd_property_h264_mv_buffer *mv_buff = - (struct vcd_property_h264_mv_buffer *) - property_value; - DDL_MSG_LOW("Entered VCD_I_H264_MV_BUFFER Virt: %p, Phys %p," - "fd: %d size: %d count: %d\n", - mv_buff->kernel_virtual_addr, - mv_buff->physical_addr, - mv_buff->pmem_fd, - mv_buff->size, mv_buff->count); - if ((property_hdr->sz == sizeof(struct - vcd_property_h264_mv_buffer)) && - (DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_INITCODEC) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN))) { - phys_addr = mv_buff->dev_addr; - virt_addr = mv_buff->kernel_virtual_addr; - buffer_size = mv_buff->size/mv_buff->count; - - for (index = 0; index < mv_buff->count; index++) { - ddl->codec_data.decoder.hw_bufs. - h264_mv[index].align_physical_addr - = phys_addr; - ddl->codec_data.decoder.hw_bufs. - h264_mv[index].align_virtual_addr - = virt_addr; - ddl->codec_data.decoder.hw_bufs. - h264_mv[index].buffer_size - = buffer_size; - ddl->codec_data.decoder.hw_bufs. - h264_mv[index].physical_base_addr - = phys_addr; - ddl->codec_data.decoder.hw_bufs. - h264_mv[index].virtual_base_addr - = virt_addr; - DDL_MSG_LOW("Assigned %d buffer for " - "virt: %p, phys %p for " - "h264_mv_buffers " - "of size: %d\n", - index, virt_addr, - phys_addr, buffer_size); - phys_addr += buffer_size; - virt_addr += buffer_size; - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_FREE_H264_MV_BUFFER: - { - memset(&decoder->hw_bufs.h264_mv, 0, sizeof(struct - ddl_buf_addr) * DDL_MAX_BUFFER_COUNT); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_FREE_EXT_METABUFFER: - { - memset(&decoder->hw_bufs.meta_hdr, 0, sizeof(struct - ddl_buf_addr) * DDL_MAX_BUFFER_COUNT); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_OUTPUT_ORDER: - { - if (sizeof(u32) == property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - decoder->output_order = - *(u32 *)property_value; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_DEC_PICTYPE: - { - if ((sizeof(u32) == property_hdr->sz) && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - decoder->idr_only_decoding = - *(u32 *)property_value; - ddl_set_default_decoder_buffer_req( - decoder, true); - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - DDL_MSG_MED("Meta Data Interface is Requested"); - vcd_status = ddl_set_metadata_params(ddl, property_hdr, - property_value); - vcd_status = VCD_S_SUCCESS; - break; - case VCD_I_FRAME_RATE: - vcd_status = VCD_S_SUCCESS; - break; - case VCD_I_CONT_ON_RECONFIG: - { - DDL_MSG_LOW("Set property VCD_I_CONT_ON_RECONFIG\n"); - if (sizeof(u32) == property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - decoder->cont_mode = *(u32 *)property_value; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_DISABLE_DMX: - { - int disable_dmx_allowed = 0; - DDL_MSG_LOW("Set property VCD_I_DISABLE_DMX\n"); - if (res_trk_get_disable_dmx() && - ((decoder->codec.codec == VCD_CODEC_H264) || - (decoder->codec.codec == VCD_CODEC_VC1) || - (decoder->codec.codec == VCD_CODEC_VC1_RCV))) - disable_dmx_allowed = 1; - - if (sizeof(u32) == property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - disable_dmx_allowed) { - decoder->dmx_disable = *(u32 *)property_value; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_REQ_PERF_LEVEL: - vcd_status = VCD_S_SUCCESS; - break; - default: - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - return vcd_status; -} - -static u32 ddl_check_valid_enc_level(struct vcd_property_codec *codec, - struct vcd_property_profile *profile, - struct vcd_property_level *level) -{ - u32 status = false; - - if (codec && profile && level) { - switch (codec->codec) { - case VCD_CODEC_MPEG4: - status = (profile->profile == - VCD_PROFILE_MPEG4_SP) && - (level->level >= VCD_LEVEL_MPEG4_0) && - (level->level <= VCD_LEVEL_MPEG4_6) && - (VCD_LEVEL_MPEG4_3b != level->level); - status = status || - ((profile->profile == - VCD_PROFILE_MPEG4_ASP) && - (level->level >= VCD_LEVEL_MPEG4_0) && - (level->level <= VCD_LEVEL_MPEG4_5)); - break; - case VCD_CODEC_H264: - status = (level->level >= VCD_LEVEL_H264_1) && - (level->level <= VCD_LEVEL_H264_4); - break; - case VCD_CODEC_H263: - status = (level->level >= VCD_LEVEL_H263_10) && - (level->level <= VCD_LEVEL_H263_70); - break; - default: - break; - } - } - return status; -} - -static u32 ddl_set_enc_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, - void *property_value) -{ - struct ddl_encoder_data *encoder = - &(ddl->codec_data.encoder); - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - - if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - vcd_status = ddl_set_enc_dynamic_property(ddl, - property_hdr, property_value); - } - if (vcd_status) { - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) || - vcd_status != VCD_ERR_ILLEGAL_OP) { - DDL_MSG_ERROR("ddl_set_enc_property:" - "Fails_as_not_in_open_state"); - return VCD_ERR_ILLEGAL_OP; - } - } else - return vcd_status; - - switch (property_hdr->prop_id) { - case VCD_I_FRAME_SIZE: - { - struct vcd_property_frame_size *frame_size = - (struct vcd_property_frame_size *) property_value; - if ((sizeof(struct vcd_property_frame_size) == - property_hdr->sz) && - (DDL_ALLOW_ENC_FRAMESIZE(frame_size->width, - frame_size->height))) { - if (encoder->frame_size.height != frame_size->height || - encoder->frame_size.width != - frame_size->width) { - ddl_calculate_stride(frame_size, false); - encoder->frame_size = *frame_size; - ddl_set_default_encoder_buffer_req(encoder); - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_CODEC: - { - struct vcd_property_codec *codec = - (struct vcd_property_codec *) property_value; - if ((sizeof(struct vcd_property_codec) == - property_hdr->sz) && - (ddl_codec_type_transact(ddl, false, codec->codec))) { - if (codec->codec != encoder->codec.codec) { - encoder->codec = *codec; - ddl_set_default_enc_property(ddl); - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_REQ_IFRAME: - vcd_status = VCD_S_SUCCESS; - break; - case VCD_I_INTRA_PERIOD: - { - struct vcd_property_i_period *i_period = - (struct vcd_property_i_period *)property_value; - if (sizeof(struct vcd_property_i_period) == - property_hdr->sz && - i_period->b_frames <= DDL_MAX_NUM_OF_B_FRAME) { - encoder->i_period = *i_period; - encoder->client_input_buf_req.min_count = - i_period->b_frames + 1; - encoder->client_input_buf_req.actual_count = - DDL_MAX(encoder->client_input_buf_req.\ - actual_count, encoder->\ - client_input_buf_req.min_count); - encoder->client_output_buf_req.min_count = - i_period->b_frames + 2; - encoder->client_output_buf_req.actual_count = - DDL_MAX(encoder->client_output_buf_req.\ - actual_count, encoder->\ - client_output_buf_req.min_count); - ddl->extra_output_buf_count = - i_period->b_frames - 1; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_PROFILE: - { - struct vcd_property_profile *profile = - (struct vcd_property_profile *)property_value; - - if ((sizeof(struct vcd_property_profile) == - property_hdr->sz) && (( - (encoder->codec.codec == VCD_CODEC_MPEG4) && ( - profile->profile == VCD_PROFILE_MPEG4_SP || - profile->profile == VCD_PROFILE_MPEG4_ASP)) || - ((encoder->codec.codec == VCD_CODEC_H264) && - (profile->profile >= VCD_PROFILE_H264_BASELINE) && - (profile->profile <= VCD_PROFILE_H264_HIGH)) || - ((encoder->codec.codec == VCD_CODEC_H263) && - (profile->profile == VCD_PROFILE_H263_BASELINE)))) { - encoder->profile = *profile; - vcd_status = VCD_S_SUCCESS; - if (profile->profile == VCD_PROFILE_H264_BASELINE) - encoder->entropy_control.entropy_sel = - VCD_ENTROPY_SEL_CAVLC; - else - encoder->entropy_control.entropy_sel = - VCD_ENTROPY_SEL_CABAC; - } - } - break; - case VCD_I_LEVEL: - { - struct vcd_property_level *level = - (struct vcd_property_level *) property_value; - - if ((sizeof(struct vcd_property_level) == - property_hdr->sz) && (ddl_check_valid_enc_level - (&encoder->codec, - &encoder->profile, level))) { - encoder->level = *level; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_MULTI_SLICE: - { - struct vcd_property_multi_slice *multi_slice = - (struct vcd_property_multi_slice *) - property_value; - DDL_MSG_HIGH("VCD_I_MULTI_SLICE eMSliceSel %d "\ - "nMSliceSize %d Tot#of MB %d "\ - "encoder->frame_size.width = %d "\ - "encoder->frame_size.height = %d", - (int)multi_slice->m_slice_sel, - multi_slice->m_slice_size, - DDL_NO_OF_MB(encoder->frame_size.width, - encoder->frame_size.height), - encoder->frame_size.width, - encoder->frame_size.height); - switch (multi_slice->m_slice_sel) { - case VCD_MSLICE_OFF: - vcd_status = VCD_S_SUCCESS; - break; - case VCD_MSLICE_BY_GOB: - if (encoder->codec.codec == VCD_CODEC_H263) - vcd_status = VCD_S_SUCCESS; - break; - case VCD_MSLICE_BY_MB_COUNT: - { - if ((multi_slice->m_slice_size >= 1) && - (multi_slice->m_slice_size <= - DDL_NO_OF_MB(encoder->frame_size.width, - encoder->frame_size.height))) { - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_MSLICE_BY_BYTE_COUNT: - if (multi_slice->m_slice_size > 0) - vcd_status = VCD_S_SUCCESS; - break; - default: - break; - } - if (sizeof(struct vcd_property_multi_slice) == - property_hdr->sz && !vcd_status) { - encoder->multi_slice = *multi_slice; - if (multi_slice->m_slice_sel == VCD_MSLICE_OFF) - encoder->multi_slice.m_slice_size = 0; - } - } - break; - case VCD_I_RATE_CONTROL: - { - struct vcd_property_rate_control *rate_control = - (struct vcd_property_rate_control *) - property_value; - if (sizeof(struct vcd_property_rate_control) == - property_hdr->sz && - rate_control->rate_control >= - VCD_RATE_CONTROL_OFF && - rate_control->rate_control <= - VCD_RATE_CONTROL_CBR_CFR) { - encoder->rc = *rate_control; - ddl_set_default_enc_rc_params(encoder); - vcd_status = VCD_S_SUCCESS; - } - - } - break; - case VCD_I_SHORT_HEADER: - if (sizeof(struct vcd_property_short_header) == - property_hdr->sz && - encoder->codec.codec == - VCD_CODEC_MPEG4) { - encoder->short_header = - *(struct vcd_property_short_header *) - property_value; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_VOP_TIMING: - { - struct vcd_property_vop_timing *vop_time = - (struct vcd_property_vop_timing *) - property_value; - - if ((sizeof(struct vcd_property_vop_timing) == - property_hdr->sz) && - (encoder->frame_rate.fps_numerator <= - vop_time->vop_time_resolution) && - (encoder->codec.codec == VCD_CODEC_MPEG4)) { - encoder->vop_timing = *vop_time; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_HEADER_EXTENSION: - if (sizeof(u32) == property_hdr->sz && - encoder->codec.codec == VCD_CODEC_MPEG4) { - encoder->hdr_ext_control = *(u32 *)property_value; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_ENTROPY_CTRL: - { - struct vcd_property_entropy_control *entropy_control = - (struct vcd_property_entropy_control *) - property_value; - if (sizeof(struct vcd_property_entropy_control) == - property_hdr->sz && - encoder->codec.codec == VCD_CODEC_H264 && - entropy_control->entropy_sel >= - VCD_ENTROPY_SEL_CAVLC && - entropy_control->entropy_sel <= - VCD_ENTROPY_SEL_CABAC) { - if ((entropy_control->entropy_sel == - VCD_ENTROPY_SEL_CABAC) && - (encoder->entropy_control.cabac_model == - VCD_CABAC_MODEL_NUMBER_1 || - encoder->entropy_control.cabac_model == - VCD_CABAC_MODEL_NUMBER_2)) { - vcd_status = VCD_ERR_ILLEGAL_PARM; - } else { - encoder->entropy_control = *entropy_control; - vcd_status = VCD_S_SUCCESS; - } - } - } - break; - case VCD_I_DEBLOCKING: - { - struct vcd_property_db_config *db_config = - (struct vcd_property_db_config *) property_value; - if (sizeof(struct vcd_property_db_config) == - property_hdr->sz && - encoder->codec.codec == VCD_CODEC_H264 && - db_config->db_config >= - VCD_DB_ALL_BLOCKING_BOUNDARY && - db_config->db_config <= - VCD_DB_SKIP_SLICE_BOUNDARY) { - encoder->db_control = *db_config; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_QP_RANGE: - { - struct vcd_property_qp_range *qp = - (struct vcd_property_qp_range *)property_value; - - if ((sizeof(struct vcd_property_qp_range) == - property_hdr->sz) && (qp->min_qp <= - qp->max_qp) && ((encoder->codec.codec == - VCD_CODEC_H264 && qp->max_qp <= DDL_MAX_H264_QP) || - (qp->max_qp <= DDL_MAX_MPEG4_QP))) { - encoder->qp_range = *qp; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_SESSION_QP: - { - struct vcd_property_session_qp *qp = - (struct vcd_property_session_qp *)property_value; - if ((sizeof(struct vcd_property_session_qp) == - property_hdr->sz) && - (qp->i_frame_qp >= encoder->qp_range.min_qp) && - (qp->i_frame_qp <= encoder->qp_range.max_qp) && - (qp->p_frame_qp >= encoder->qp_range.min_qp) && - (qp->p_frame_qp <= encoder->qp_range.max_qp)) { - encoder->session_qp = *qp; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_RC_LEVEL_CONFIG: - { - struct vcd_property_rc_level *rc_level = - (struct vcd_property_rc_level *) property_value; - if (sizeof(struct vcd_property_rc_level) == - property_hdr->sz && - (encoder->rc.rate_control >= - VCD_RATE_CONTROL_VBR_VFR || - encoder->rc.rate_control <= - VCD_RATE_CONTROL_CBR_VFR) && - (!rc_level->mb_level_rc || - encoder->codec.codec == VCD_CODEC_H264)) { - encoder->rc_level = *rc_level; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_FRAME_LEVEL_RC: - { - struct vcd_property_frame_level_rc_params - *frame_level_rc = - (struct vcd_property_frame_level_rc_params *) - property_value; - if ((sizeof(struct vcd_property_frame_level_rc_params) == - property_hdr->sz) && - (frame_level_rc->reaction_coeff) && - (encoder->rc_level.frame_level_rc)) { - encoder->frame_level_rc = *frame_level_rc; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_ADAPTIVE_RC: - if ((sizeof(struct vcd_property_adaptive_rc_params) == - property_hdr->sz) && - (encoder->codec.codec == VCD_CODEC_H264) && - (encoder->rc_level.mb_level_rc)) { - encoder->adaptive_rc = - *(struct vcd_property_adaptive_rc_params *) - property_value; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_BUFFER_FORMAT: - { - struct vcd_property_buffer_format *buffer_format = - (struct vcd_property_buffer_format *) - property_value; - - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz && - ((buffer_format->buffer_format == - VCD_BUFFER_FORMAT_NV12_16M2KA) || - (VCD_BUFFER_FORMAT_TILE_4x2 == - buffer_format->buffer_format))) { - if (buffer_format->buffer_format != - encoder->buf_format.buffer_format) { - encoder->buf_format = *buffer_format; - ddl_set_default_encoder_buffer_req(encoder); - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case DDL_I_INPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *)property_value; - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && (ddl_valid_buffer_requirement( - &encoder->input_buf_req, buffer_req))) { - encoder->client_input_buf_req = *buffer_req; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case DDL_I_OUTPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *)property_value; - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && (ddl_valid_buffer_requirement( - &encoder->output_buf_req, buffer_req))) { - encoder->client_output_buf_req = *buffer_req; - encoder->client_output_buf_req.sz = - DDL_ALIGN(buffer_req->sz, - DDL_KILO_BYTE(4)); - DDL_MSG_LOW("%s encoder->client_output_buf_req.sz" - " = %d\n", __func__, - encoder->client_output_buf_req.sz); - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_RECON_BUFFERS: - { - int index, index_hw_bufs = -1; - struct vcd_property_enc_recon_buffer *recon_buffers = - (struct vcd_property_enc_recon_buffer *)property_value; - for (index = 0; index < 4; index++) { - if (!encoder->hw_bufs.dpb_y[index]. - align_physical_addr) { - index_hw_bufs = index; - break; - } else - continue; - } - if (index_hw_bufs == -1) { - DDL_MSG_HIGH("ERROR: value of index_hw_bufs"); - vcd_status = VCD_ERR_ILLEGAL_PARM; - } else { - if (property_hdr->sz == sizeof(struct - vcd_property_enc_recon_buffer)) { - encoder->hw_bufs.dpb_y[index_hw_bufs]. - align_physical_addr = - recon_buffers->dev_addr; - encoder->hw_bufs.dpb_y[index_hw_bufs]. - align_virtual_addr = - recon_buffers->kernel_virtual_addr; - encoder->hw_bufs.dpb_y[index_hw_bufs]. - buffer_size = recon_buffers->buffer_size; - encoder->hw_bufs.dpb_c[index_hw_bufs]. - align_physical_addr = - recon_buffers->dev_addr + - ddl_get_yuv_buf_size( - encoder->frame_size.width, - encoder->frame_size.height, - DDL_YUV_BUF_TYPE_TILE); - encoder->hw_bufs.dpb_c[index_hw_bufs]. - align_virtual_addr = - recon_buffers->kernel_virtual_addr + - recon_buffers->ysize; - DDL_MSG_LOW("Y::KVirt: %p,KPhys: %p" - "UV::KVirt: %p,KPhys: %p\n", - encoder->hw_bufs.dpb_y[index_hw_bufs]. - align_virtual_addr, - encoder->hw_bufs.dpb_y[index_hw_bufs]. - align_physical_addr, - encoder->hw_bufs.dpb_c[index_hw_bufs]. - align_virtual_addr, - encoder->hw_bufs.dpb_c[index_hw_bufs]. - align_physical_addr); - vcd_status = VCD_S_SUCCESS; - } - } - } - break; - case VCD_I_FREE_RECON_BUFFERS: - { - memset(&encoder->hw_bufs.dpb_y, 0, - sizeof(struct ddl_buf_addr) * 4); - memset(&encoder->hw_bufs.dpb_c, 0, - sizeof(struct ddl_buf_addr) * 4); - vcd_status = VCD_S_SUCCESS; - break; - } - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - DDL_MSG_LOW("Meta Data Interface is Requested"); - if (!res_trk_check_for_sec_session()) { - if (!encoder->slice_delivery_info.enable) { - vcd_status = ddl_set_metadata_params(ddl, - property_hdr, property_value); - } else { - DDL_MSG_ERROR("Ignoring meta data settting in " - "slice mode: %s\n", __func__); - vcd_status = VCD_S_SUCCESS; - } - } else { - DDL_MSG_ERROR("Meta Data Interface is not " - "supported in secure session"); - vcd_status = VCD_ERR_ILLEGAL_OP; - } - break; - case VCD_I_META_BUFFER_MODE: - vcd_status = VCD_S_SUCCESS; - break; - case VCD_I_ENABLE_SPS_PPS_FOR_IDR: - { - struct vcd_property_sps_pps_for_idr_enable *sps_pps = - (struct vcd_property_sps_pps_for_idr_enable *) property_value; - - if ((sizeof(struct vcd_property_sps_pps_for_idr_enable)) == - property_hdr->sz) { - DDL_MSG_LOW("SPS PPS generation for IDR Encode " - "is Requested"); - encoder->sps_pps.sps_pps_for_idr_enable_flag = - sps_pps->sps_pps_for_idr_enable_flag; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_SLICE_DELIVERY_MODE: - { - size_t output_buf_size; - u32 num_mb, num_slices; - struct vcd_property_hdr slice_property_hdr; - struct vcd_property_meta_data_enable slice_meta_data; - DDL_MSG_HIGH("Set property VCD_I_SLICE_DELIVERY_MODE\n"); - if (sizeof(u32) == property_hdr->sz && - encoder->codec.codec == VCD_CODEC_H264 && - encoder->multi_slice.m_slice_sel - == VCD_MSLICE_BY_MB_COUNT && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - encoder->slice_delivery_info.enable - = *(u32 *)property_value; - DDL_MSG_HIGH("set encoder->slice_delivery_mode = %u\n", - encoder->slice_delivery_info.enable); - output_buf_size = - encoder->client_output_buf_req.sz; - num_mb = DDL_NO_OF_MB(encoder->frame_size.width, - encoder->frame_size.height); - num_slices = num_mb/ - encoder->multi_slice.m_slice_size; - num_slices = ((num_mb - num_slices * - encoder->multi_slice.m_slice_size) > 0) - ? (num_slices + 1) : num_slices; - encoder->slice_delivery_info.num_slices = - num_slices; - if (num_slices <= DDL_MAX_NUM_BFRS_FOR_SLICE_BATCH) { - DDL_MSG_HIGH("%s: currently slice info " - "metadata is not supported when slice " - "delivery mode is enabled. hence " - "disabling slice info metadata.\n", - __func__); - slice_property_hdr.prop_id = - VCD_I_METADATA_ENABLE; - slice_property_hdr.sz = - sizeof(struct \ - vcd_property_meta_data_enable); - ddl_get_metadata_params(ddl, - &slice_property_hdr, - &slice_meta_data); - slice_meta_data.meta_data_enable_flag - &= ~VCD_METADATA_ENC_SLICE; - ddl_set_metadata_params(ddl, - &slice_property_hdr, - &slice_meta_data); - encoder->client_output_buf_req.min_count = - ((DDL_ENC_SLICE_BATCH_FACTOR * num_slices + 2) - > DDL_MAX_BUFFER_COUNT) - ? DDL_MAX_BUFFER_COUNT : - (DDL_ENC_SLICE_BATCH_FACTOR * num_slices + 2); - output_buf_size = - encoder->client_output_buf_req.sz/num_slices; - encoder->client_output_buf_req.sz = - DDL_ALIGN(output_buf_size, DDL_KILO_BYTE(4)); - if (encoder->client_output_buf_req. \ - actual_count < encoder-> \ - client_output_buf_req.min_count) { - encoder->client_output_buf_req. \ - actual_count = encoder-> \ - client_output_buf_req.min_count; - } - encoder->output_buf_req = - encoder->client_output_buf_req; - DDL_MSG_HIGH("%s num_mb = %u num_slices = %u" \ - " min_count = %u act_count = %u" \ - " aligned size = %u\n", - __func__, num_mb, num_slices, - encoder->client_output_buf_req.min_count, - encoder->client_output_buf_req.actual_count, - encoder->client_output_buf_req.sz); - vcd_status = VCD_S_SUCCESS; - } - } - break; - } - case VCD_I_LTR_MODE: - if (sizeof(struct vcd_property_ltrmode_type) == - property_hdr->sz && encoder->codec.codec == - VCD_CODEC_H264) { - struct vcd_property_ltrmode_type *ltrmode = - (struct vcd_property_ltrmode_type *) - property_value; - encoder->ltr_control.ltrmode.ltr_mode = - ltrmode->ltr_mode; - DDL_MSG_HIGH("%s: set LTR mode = %u", __func__, - (u32)encoder->ltr_control.ltrmode.ltr_mode); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_LTR_COUNT: - if (sizeof(struct vcd_property_ltrcount_type) == - property_hdr->sz && encoder->codec.codec == - VCD_CODEC_H264) { - struct vcd_property_ltrcount_type *ltrcount = - (struct vcd_property_ltrcount_type *) - property_value; - if (ltrcount->ltr_count > DDL_MAX_NUM_LTR_FRAMES) { - DDL_MSG_ERROR("%s: set LTR count failed. "\ - "LTR count %u beyond maximum of %u", - __func__, ltrcount->ltr_count, - (u32)DDL_MAX_NUM_LTR_FRAMES); - } else { - encoder->ltr_control.ltr_count = - ltrcount->ltr_count; - DDL_MSG_HIGH("%s: set LTR count = %u", __func__, - encoder->ltr_control.ltr_count); - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_REQ_PERF_LEVEL: - vcd_status = VCD_S_SUCCESS; - break; - case VCD_I_ENABLE_DELIMITER_FLAG: - { - struct vcd_property_avc_delimiter_enable *delimiter_enable = - (struct vcd_property_avc_delimiter_enable *) - property_value; - if (sizeof(struct vcd_property_avc_delimiter_enable) == - property_hdr->sz && - encoder->codec.codec == VCD_CODEC_H264) { - encoder->avc_delimiter_enable = - delimiter_enable->avc_delimiter_enable_flag; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_ENABLE_VUI_TIMING_INFO: - { - struct vcd_property_vui_timing_info_enable *vui_timing_enable = - (struct vcd_property_vui_timing_info_enable *) - property_value; - if (sizeof(struct vcd_property_vui_timing_info_enable) == - property_hdr->sz && - encoder->codec.codec == VCD_CODEC_H264) { - encoder->vui_timinginfo_enable = - vui_timing_enable->vui_timing_info; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_H263_PLUSPTYPE: - { - struct vcd_property_plusptype *plusptype = - (struct vcd_property_plusptype *)property_value; - - if ((sizeof(struct vcd_property_plusptype) == - property_hdr->sz) && encoder->codec.codec == - VCD_CODEC_H263) { - encoder->plusptype_enable = plusptype->plusptype_enable; - DDL_MSG_LOW("\nencoder->plusptype_enable = %u", - encoder->plusptype_enable); - vcd_status = VCD_S_SUCCESS; - } - break; - } - default: - DDL_MSG_ERROR("%s: unknown prop_id = 0x%x", __func__, - property_hdr->prop_id); - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - return vcd_status; -} - -static u32 ddl_get_dec_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct vcd_property_frame_size *fz_size; - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - DDL_MSG_HIGH("property_hdr->prop_id:%x\n", property_hdr->prop_id); - switch (property_hdr->prop_id) { - case VCD_I_FRAME_SIZE: - if (sizeof(struct vcd_property_frame_size) == - property_hdr->sz) { - ddl_calculate_stride(&decoder->client_frame_size, - !decoder->progressive_only); - fz_size = - &decoder->client_frame_size; - fz_size->stride = - DDL_TILE_ALIGN(fz_size->width, - DDL_TILE_ALIGN_WIDTH); - fz_size->scan_lines = - DDL_TILE_ALIGN(fz_size->height, - DDL_TILE_ALIGN_HEIGHT); - *(struct vcd_property_frame_size *) - property_value = - decoder->client_frame_size; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_PROFILE: - if (sizeof(struct vcd_property_profile) == - property_hdr->sz) { - *(struct vcd_property_profile *)property_value = - decoder->profile; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_LEVEL: - if (sizeof(struct vcd_property_level) == - property_hdr->sz) { - *(struct vcd_property_level *)property_value = - decoder->level; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_PROGRESSIVE_ONLY: - if (sizeof(u32) == property_hdr->sz) { - *(u32 *)property_value = - decoder->progressive_only; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_INPUT_BUF_REQ: - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = - decoder->client_input_buf_req; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_OUTPUT_BUF_REQ: - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = decoder->client_output_buf_req; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_CODEC: - if (sizeof(struct vcd_property_codec) == - property_hdr->sz) { - *(struct vcd_property_codec *) property_value = - decoder->codec; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_BUFFER_FORMAT: - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz) { - *(struct vcd_property_buffer_format *) - property_value = decoder->buf_format; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_POST_FILTER: - if (sizeof(struct vcd_property_post_filter) == - property_hdr->sz) { - *(struct vcd_property_post_filter *) - property_value = - decoder->post_filter; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_SEQHDR_ALIGN_BYTES: - if (sizeof(u32) == property_hdr->sz) { - *(u32 *)property_value = - DDL_LINEAR_BUFFER_ALIGN_BYTES; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_FRAME_PROC_UNITS: - if (sizeof(u32) == property_hdr->sz) { - if (!decoder->progressive_only && - (decoder->client_frame_size.width * - decoder->client_frame_size.height) <= - DDL_FRAME_VGA_SIZE) { - *(u32 *) property_value = DDL_NO_OF_MB( - DDL_FRAME_720P_WIDTH, - DDL_FRAME_720P_HEIGHT); - } else { - *(u32 *) property_value = DDL_NO_OF_MB( - decoder->client_frame_size.width, - decoder->client_frame_size.height); - } - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_DPB_RETRIEVE: - if (sizeof(struct ddl_frame_data_tag) == - property_hdr->sz) { - vcd_status = ddl_decoder_dpb_transact(decoder, - (struct ddl_frame_data_tag *) - property_value, DDL_DPB_OP_RETRIEVE); - } - break; - case VCD_I_GET_H264_MV_SIZE: - if (property_hdr->sz == sizeof(struct - vcd_property_buffer_size)) { - struct vcd_property_buffer_size *mv_size = - (struct vcd_property_buffer_size *) property_value; - mv_size->size = ddl_get_yuv_buf_size(mv_size->width, - mv_size->height, DDL_YUV_BUF_TYPE_TILE); - mv_size->alignment = DDL_TILE_BUFFER_ALIGN_BYTES; - DDL_MSG_LOW("w: %d, h: %d, S: %d, " - "A: %d", mv_size->width, - mv_size->height, mv_size->size, - mv_size->alignment); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_OUTPUT_ORDER: - { - if (sizeof(u32) == property_hdr->sz) { - *(u32 *)property_value = decoder->output_order; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - DDL_MSG_ERROR("Meta Data Interface is Requested"); - vcd_status = ddl_get_metadata_params(ddl, property_hdr, - property_value); - vcd_status = VCD_S_SUCCESS; - break; - case VCD_I_CONT_ON_RECONFIG: - if (sizeof(u32) == property_hdr->sz) { - *(u32 *)property_value = decoder->cont_mode; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_DISABLE_DMX_SUPPORT: - if (sizeof(u32) == property_hdr->sz) { - *(u32 *)property_value = res_trk_get_disable_dmx(); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_DISABLE_DMX: - if (sizeof(u32) == property_hdr->sz) { - *(u32 *)property_value = decoder->dmx_disable; - vcd_status = VCD_S_SUCCESS; - } - break; - default: - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - return vcd_status; -} - -static u32 ddl_get_enc_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - struct ddl_encoder_data *encoder = &ddl->codec_data.encoder; - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - - switch (property_hdr->prop_id) { - case VCD_I_CODEC: - if (sizeof(struct vcd_property_codec) == - property_hdr->sz) { - *(struct vcd_property_codec *) property_value = - encoder->codec; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_FRAME_SIZE: - if (sizeof(struct vcd_property_frame_size) == - property_hdr->sz) { - *(struct vcd_property_frame_size *) - property_value = encoder->frame_size; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_FRAME_RATE: - if (sizeof(struct vcd_property_frame_rate) == - property_hdr->sz) { - *(struct vcd_property_frame_rate *) - property_value = encoder->frame_rate; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_TARGET_BITRATE: - if (sizeof(struct vcd_property_target_bitrate) == - property_hdr->sz) { - *(struct vcd_property_target_bitrate *) - property_value = encoder->target_bit_rate; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_RATE_CONTROL: - if (sizeof(struct vcd_property_rate_control) == - property_hdr->sz) { - *(struct vcd_property_rate_control *) - property_value = encoder->rc; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_PROFILE: - if (sizeof(struct vcd_property_profile) == - property_hdr->sz) { - *(struct vcd_property_profile *) property_value = - encoder->profile; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_LEVEL: - if (sizeof(struct vcd_property_level) == - property_hdr->sz) { - *(struct vcd_property_level *) property_value = - encoder->level; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_MULTI_SLICE: - if (sizeof(struct vcd_property_multi_slice) == - property_hdr->sz) { - *(struct vcd_property_multi_slice *) - property_value = encoder->multi_slice; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_SEQ_HEADER: - { - struct vcd_sequence_hdr *seq_hdr = - (struct vcd_sequence_hdr *) property_value; - - if (!encoder->seq_header_length) { - seq_hdr->sequence_header_len = - encoder->seq_header_length; - vcd_status = VCD_ERR_NO_SEQ_HDR; - } else if (sizeof(struct vcd_sequence_hdr) == - property_hdr->sz && - encoder->seq_header_length <= - seq_hdr->sequence_header_len) { - memcpy(seq_hdr->sequence_header, - encoder->seq_header.align_virtual_addr, - encoder->seq_header_length); - seq_hdr->sequence_header_len = - encoder->seq_header_length; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case DDL_I_SEQHDR_PRESENT: - if (sizeof(u32) == property_hdr->sz) { - if ((encoder->codec.codec == - VCD_CODEC_MPEG4 && - !encoder->short_header.short_header) || - encoder->codec.codec == VCD_CODEC_H264) - *(u32 *) property_value = 0x1; - else - *(u32 *) property_value = 0x0; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_VOP_TIMING: - if (sizeof(struct vcd_property_vop_timing) == - property_hdr->sz) { - *(struct vcd_property_vop_timing *) - property_value = encoder->vop_timing; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_SHORT_HEADER: - if (sizeof(struct vcd_property_short_header) == - property_hdr->sz) { - if (encoder->codec.codec == VCD_CODEC_MPEG4) { - *(struct vcd_property_short_header *) - property_value = - encoder->short_header; - vcd_status = VCD_S_SUCCESS; - } else - vcd_status = VCD_ERR_ILLEGAL_OP; - } - break; - case VCD_I_ENTROPY_CTRL: - if (sizeof(struct vcd_property_entropy_control) == - property_hdr->sz) { - if (encoder->codec.codec == VCD_CODEC_H264) { - *(struct vcd_property_entropy_control *) - property_value = - encoder->entropy_control; - vcd_status = VCD_S_SUCCESS; - } else - vcd_status = VCD_ERR_ILLEGAL_OP; - } - break; - case VCD_I_DEBLOCKING: - if (sizeof(struct vcd_property_db_config) == - property_hdr->sz) { - if (encoder->codec.codec == VCD_CODEC_H264) { - *(struct vcd_property_db_config *) - property_value = - encoder->db_control; - vcd_status = VCD_S_SUCCESS; - } else - vcd_status = VCD_ERR_ILLEGAL_OP; - } - break; - case VCD_I_INTRA_PERIOD: - if (sizeof(struct vcd_property_i_period) == - property_hdr->sz) { - *(struct vcd_property_i_period *) - property_value = encoder->i_period; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_QP_RANGE: - if (sizeof(struct vcd_property_qp_range) == - property_hdr->sz) { - *(struct vcd_property_qp_range *) - property_value = encoder->qp_range; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_SESSION_QP: - if (sizeof(struct vcd_property_session_qp) == - property_hdr->sz) { - *(struct vcd_property_session_qp *) - property_value = encoder->session_qp; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_RC_LEVEL_CONFIG: - if (sizeof(struct vcd_property_rc_level) == - property_hdr->sz) { - *(struct vcd_property_rc_level *) - property_value = encoder->rc_level; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_FRAME_LEVEL_RC: - if (sizeof(struct vcd_property_frame_level_rc_params) == - property_hdr->sz) { - *(struct vcd_property_frame_level_rc_params *) - property_value = encoder->frame_level_rc; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_ADAPTIVE_RC: - if (sizeof(struct vcd_property_adaptive_rc_params) == - property_hdr->sz) { - *(struct vcd_property_adaptive_rc_params *) - property_value = encoder->adaptive_rc; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_INTRA_REFRESH: - if (sizeof(struct vcd_property_intra_refresh_mb_number) == - property_hdr->sz) { - *(struct vcd_property_intra_refresh_mb_number *) - property_value = encoder->intra_refresh; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_INPUT_BUF_REQ: - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = encoder->client_input_buf_req; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_OUTPUT_BUF_REQ: - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = encoder->client_output_buf_req; - DDL_MSG_LOW("%s encoder->client_output_buf_req = %d\n", - __func__, - encoder->client_output_buf_req.sz); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_BUFFER_FORMAT: - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz) { - *(struct vcd_property_buffer_format *) - property_value = encoder->buf_format; - vcd_status = VCD_S_SUCCESS; - } - break; - case DDL_I_FRAME_PROC_UNITS: - if (sizeof(u32) == property_hdr->sz && - encoder->frame_size.width && - encoder->frame_size.height) { - *(u32 *)property_value = DDL_NO_OF_MB( - encoder->frame_size.width, - encoder->frame_size.height); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_HEADER_EXTENSION: - if (sizeof(u32) == property_hdr->sz && - encoder->codec.codec == VCD_CODEC_MPEG4) { - *(u32 *) property_value = - encoder->hdr_ext_control; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_GET_RECON_BUFFER_SIZE: - { - u32 ysize, uvsize; - if (property_hdr->sz == sizeof(struct - vcd_property_buffer_size)) { - struct vcd_property_buffer_size *recon_buff_size = - (struct vcd_property_buffer_size *) property_value; - - ysize = ddl_get_yuv_buf_size(recon_buff_size->width, - recon_buff_size->height, DDL_YUV_BUF_TYPE_TILE); - uvsize = ddl_get_yuv_buf_size(recon_buff_size->width, - recon_buff_size->height/2, - DDL_YUV_BUF_TYPE_TILE); - recon_buff_size->size = ysize + uvsize; - recon_buff_size->alignment = - DDL_TILE_BUFFER_ALIGN_BYTES; - DDL_MSG_LOW("w: %d, h: %d, S: %d, A: %d", - recon_buff_size->width, recon_buff_size->height, - recon_buff_size->size, recon_buff_size->alignment); - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - DDL_MSG_HIGH("Meta Data Interface is Requested"); - vcd_status = ddl_get_metadata_params(ddl, property_hdr, - property_value); - vcd_status = VCD_S_SUCCESS; - break; - case VCD_I_ENABLE_SPS_PPS_FOR_IDR: - if (sizeof(struct vcd_property_sps_pps_for_idr_enable) == - property_hdr->sz) { - *(struct vcd_property_sps_pps_for_idr_enable *) - property_value = encoder->sps_pps; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_SLICE_DELIVERY_MODE: - if (sizeof(struct vcd_property_slice_delivery_info) == - property_hdr->sz) { - *(struct vcd_property_slice_delivery_info *) - property_value = encoder->slice_delivery_info; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_ENABLE_DELIMITER_FLAG: - if (sizeof(struct vcd_property_avc_delimiter_enable) == - property_hdr->sz) { - ((struct vcd_property_avc_delimiter_enable *) - property_value)->avc_delimiter_enable_flag = - encoder->avc_delimiter_enable; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_ENABLE_VUI_TIMING_INFO: - if (sizeof(struct vcd_property_vui_timing_info_enable) == - property_hdr->sz) { - ((struct vcd_property_vui_timing_info_enable *) - property_value)->vui_timing_info = - encoder->vui_timinginfo_enable; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_CAPABILITY_LTR_COUNT: - if (sizeof(struct vcd_property_range_type) == - property_hdr->sz) { - struct vcd_property_range_type capability_ltr_range; - capability_ltr_range.max = DDL_MAX_NUM_LTR_FRAMES; - capability_ltr_range.min = 1; - capability_ltr_range.step_size = 1; - *(struct vcd_property_range_type *)property_value = - capability_ltr_range; - DDL_MSG_HIGH("%s: capability_ltr_count = %u", - __func__, ((struct vcd_property_range_type *) - property_value)->max); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_LTR_MODE: - if (sizeof(struct vcd_property_ltrmode_type) == - property_hdr->sz) { - ((struct vcd_property_ltrmode_type *) - property_value)->ltr_mode = - encoder->ltr_control.ltrmode.ltr_mode; - DDL_MSG_HIGH("%s: ltr_mode = %u", __func__, - (u32)(((struct vcd_property_ltrmode_type *) - property_value)->ltr_mode)); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_LTR_COUNT: - if (sizeof(struct vcd_property_ltrcount_type) == - property_hdr->sz) { - struct vcd_property_ltrcount_type ltr_count; - ltr_count.ltr_count = - encoder->ltr_control.ltr_count; - *(struct vcd_property_ltrcount_type *)property_value = - ltr_count; - DDL_MSG_HIGH("%s: ltr_count = %u", __func__, - ((struct vcd_property_ltrcount_type *) - property_value)->ltr_count); - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_LTR_PERIOD: - if (sizeof(struct vcd_property_ltrperiod_type) == - property_hdr->sz) { - struct vcd_property_ltrperiod_type ltr_period; - if (!encoder->ltr_control.ltr_period) - ltr_period.ltr_period = 0; - else - ltr_period.ltr_period = - encoder->ltr_control.ltr_period - 1; - *(struct vcd_property_ltrperiod_type *)property_value = - ltr_period; - DDL_MSG_HIGH("%s: ltr_period = %u", __func__, - ((struct vcd_property_ltrperiod_type *) - property_value)->ltr_period); - vcd_status = VCD_S_SUCCESS; - } - break; - default: - DDL_MSG_ERROR("%s: unknown prop_id = 0x%x", __func__, - property_hdr->prop_id); - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - return vcd_status; -} - -static u32 ddl_set_enc_dynamic_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - struct ddl_encoder_data *encoder = &ddl->codec_data.encoder; - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - u32 dynamic_prop_change = 0x0; - - switch (property_hdr->prop_id) { - case VCD_I_REQ_IFRAME: - if (sizeof(struct vcd_property_req_i_frame) == - property_hdr->sz) { - dynamic_prop_change |= DDL_ENC_REQ_IFRAME; - vcd_status = VCD_S_SUCCESS; - } - break; - case VCD_I_TARGET_BITRATE: - { - struct vcd_property_target_bitrate *bitrate = - (struct vcd_property_target_bitrate *)property_value; - - if (sizeof(struct vcd_property_target_bitrate) == - property_hdr->sz && bitrate->target_bitrate && - bitrate->target_bitrate <= DDL_MAX_BIT_RATE) { - encoder->target_bit_rate = *bitrate; - dynamic_prop_change = DDL_ENC_CHANGE_BITRATE; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_INTRA_PERIOD: - { - struct vcd_property_i_period *i_period = - (struct vcd_property_i_period *)property_value; - - if (sizeof(struct vcd_property_i_period) == - property_hdr->sz) { - encoder->i_period = *i_period; - dynamic_prop_change = DDL_ENC_CHANGE_IPERIOD; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_FRAME_RATE: - { - struct vcd_property_frame_rate *frame_rate = - (struct vcd_property_frame_rate *) - property_value; - if (sizeof(struct vcd_property_frame_rate) == - property_hdr->sz && - frame_rate->fps_denominator && - frame_rate->fps_numerator && - frame_rate->fps_denominator <= - frame_rate->fps_numerator) { - encoder->frame_rate = *frame_rate; - dynamic_prop_change = DDL_ENC_CHANGE_FRAMERATE; - if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - (encoder->codec.codec != VCD_CODEC_MPEG4 || - encoder->short_header.short_header)) { - ddl_set_default_enc_vop_timing(encoder); - } - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_INTRA_REFRESH: - { - struct vcd_property_intra_refresh_mb_number - *intra_refresh_mb_num = - (struct vcd_property_intra_refresh_mb_number *) - property_value; - u32 frame_mb_num = DDL_NO_OF_MB(encoder->frame_size.width, - encoder->frame_size.height); - - if ((sizeof(struct vcd_property_intra_refresh_mb_number) == - property_hdr->sz) && - (intra_refresh_mb_num->cir_mb_number <= frame_mb_num)) { - encoder->intra_refresh = *intra_refresh_mb_num; - dynamic_prop_change = DDL_ENC_CHANGE_CIR; - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_LTR_PERIOD: - { - if (sizeof(struct vcd_property_ltrperiod_type) == - property_hdr->sz) { - struct vcd_property_ltrperiod_type *ltrperiod = - (struct vcd_property_ltrperiod_type *) - property_value; - encoder->ltr_control.ltr_period = - (ltrperiod->ltr_period == 0xFFFFFFFF) ? - 0xFFFFFFFF : (ltrperiod->ltr_period + 1); - DDL_MSG_HIGH("%s: set ltr_period = %u", __func__, - encoder->ltr_control.ltr_period); - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_LTR_USE: - { - if (sizeof(struct vcd_property_ltruse_type) == - property_hdr->sz) { - struct vcd_property_ltruse_type *ltruse = - (struct vcd_property_ltruse_type *) - property_value; - if (ltruse->ltr_id >= DDL_LTR_FRAME_START_ID) { - struct ddl_ltr_encoding_type *ltr_ctrl = - &encoder->ltr_control; - s32 idx; - idx = ddl_find_ltr_from_list(ltr_ctrl, - ltruse->ltr_id); - if (idx < 0) { - ltr_ctrl->callback_reqd = true; - ltr_ctrl->failed_use_cmd.ltr_id = - ltruse->ltr_id; - ltr_ctrl->failed_use_cmd.ltr_frames = - ltruse->ltr_frames; - DDL_MSG_ERROR("%s: index (%d) "\ - "not found. Callback requested. "\ - "ltr_id = %u, ltr_frames = %u", - __func__, idx, ltruse->ltr_id, - ltruse->ltr_frames); - } else { - ddl_use_ltr_from_list(ltr_ctrl, idx); - ltr_ctrl->ltr_use_frames = - ltruse->ltr_frames; - if (ltr_ctrl->using == false) - ltr_ctrl->\ - out_frame_cnt_to_use_this_ltr = - ltruse->ltr_frames; - else - ltr_ctrl->\ - pending_chg_ltr_useframes = - true; - ltr_ctrl->first_ltr_use_arvd = true; - ltr_ctrl->use_ltr_reqd = true; - DDL_MSG_HIGH("%s: index (%d) found. "\ - "num frames to use this ltr_id (%u) "\ - "is %u", __func__, idx, - ltruse->ltr_id, ltruse->ltr_frames); - } - dynamic_prop_change = DDL_ENC_LTR_USE_FRAME; - vcd_status = VCD_S_SUCCESS; - } else { - DDL_MSG_ERROR("%s: LTRUse ID %d failed. "\ - "LTR ID starts from %d", __func__, - ltruse->ltr_id, - (u32)DDL_LTR_FRAME_START_ID); - vcd_status = VCD_ERR_ILLEGAL_OP; - } - } - } - break; - default: - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - - if (!vcd_status && (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) - || DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE))) - encoder->dynamic_prop_change |= dynamic_prop_change; - - return vcd_status; -} - -void ddl_set_default_dec_property(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = - &(ddl->codec_data.decoder); - - if (decoder->codec.codec >= VCD_CODEC_MPEG2 && - decoder->codec.codec <= VCD_CODEC_XVID) - decoder->post_filter.post_filter = false; - else - decoder->post_filter.post_filter = false; - decoder->buf_format.buffer_format = VCD_BUFFER_FORMAT_TILE_4x2; - decoder->client_frame_size.height = VCD_DDL_TEST_DEFAULT_HEIGHT; - decoder->client_frame_size.width = VCD_DDL_TEST_DEFAULT_WIDTH; - decoder->client_frame_size.stride = VCD_DDL_TEST_DEFAULT_WIDTH; - decoder->client_frame_size.scan_lines = VCD_DDL_TEST_DEFAULT_HEIGHT; - decoder->progressive_only = 1; - decoder->idr_only_decoding = false; - decoder->output_order = VCD_DEC_ORDER_DISPLAY; - decoder->field_needed_for_prev_ip = 0; - decoder->cont_mode = 0; - decoder->reconfig_detected = false; - decoder->dmx_disable = false; - ddl_set_default_metadata_flag(ddl); - ddl_set_default_decoder_buffer_req(decoder, true); -} - -static void ddl_set_default_enc_property(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - - ddl_set_default_enc_profile(encoder); - ddl_set_default_enc_level(encoder); - encoder->rc.rate_control = VCD_RATE_CONTROL_VBR_VFR; - ddl_set_default_enc_rc_params(encoder); - ddl_set_default_enc_intra_period(encoder); - encoder->intra_refresh.cir_mb_number = 0; - ddl_set_default_enc_vop_timing(encoder); - encoder->multi_slice.m_slice_sel = VCD_MSLICE_OFF; - encoder->multi_slice.m_slice_size = 0; - ddl->b_count = 0; - encoder->short_header.short_header = false; - encoder->entropy_control.entropy_sel = VCD_ENTROPY_SEL_CAVLC; - encoder->entropy_control.cabac_model = VCD_CABAC_MODEL_NUMBER_0; - encoder->db_control.db_config = - VCD_DB_ALL_BLOCKING_BOUNDARY; - encoder->db_control.slice_alpha_offset = 0; - encoder->db_control.slice_beta_offset = 0; - encoder->recon_buf_format.buffer_format = - VCD_BUFFER_FORMAT_TILE_1x1; - encoder->buf_format.buffer_format = VCD_BUFFER_FORMAT_NV12_16M2KA; - encoder->hdr_ext_control = 0; - encoder->mb_info_enable = false; - encoder->num_references_for_p_frame = DDL_MIN_NUM_REF_FOR_P_FRAME; - if (encoder->codec.codec == VCD_CODEC_MPEG4) - encoder->closed_gop = true; - encoder->intra_period_changed = false; - memset(&encoder->ltr_control, 0, - sizeof(struct ddl_ltr_encoding_type)); - ddl_set_default_metadata_flag(ddl); - ddl_set_default_encoder_buffer_req(encoder); - encoder->slice_delivery_info.enable = 0; - encoder->slice_delivery_info.num_slices = 0; - encoder->slice_delivery_info.num_slices_enc = 0; - encoder->avc_delimiter_enable = 0; - encoder->vui_timinginfo_enable = 0; -} - -static void ddl_set_default_enc_profile(struct ddl_encoder_data *encoder) -{ - enum vcd_codec codec = encoder->codec.codec; - - if (codec == VCD_CODEC_MPEG4) - encoder->profile.profile = VCD_PROFILE_MPEG4_SP; - else if (codec == VCD_CODEC_H264) - encoder->profile.profile = VCD_PROFILE_H264_BASELINE; - else - encoder->profile.profile = VCD_PROFILE_H263_BASELINE; -} - -static void ddl_set_default_enc_level(struct ddl_encoder_data *encoder) -{ - enum vcd_codec codec = encoder->codec.codec; - - if (codec == VCD_CODEC_MPEG4) - encoder->level.level = VCD_LEVEL_MPEG4_1; - else if (codec == VCD_CODEC_H264) - encoder->level.level = VCD_LEVEL_H264_1; - else - encoder->level.level = VCD_LEVEL_H263_10; -} - -static void ddl_set_default_enc_vop_timing( - struct ddl_encoder_data *encoder) -{ - if (encoder->codec.codec == VCD_CODEC_MPEG4) { - encoder->vop_timing.vop_time_resolution = - (encoder->frame_rate.fps_numerator << 1) / - encoder->frame_rate.fps_denominator; - } else - encoder->vop_timing.vop_time_resolution = - DDL_FRAMERATE_SCALE(DDL_INITIAL_FRAME_RATE); -} - -static void ddl_set_default_enc_intra_period( - struct ddl_encoder_data *encoder) -{ - switch (encoder->rc.rate_control) { - default: - case VCD_RATE_CONTROL_VBR_VFR: - case VCD_RATE_CONTROL_VBR_CFR: - case VCD_RATE_CONTROL_CBR_VFR: - case VCD_RATE_CONTROL_OFF: - encoder->i_period.p_frames = - ((encoder->frame_rate.fps_numerator << 1) / - encoder->frame_rate.fps_denominator) - 1; - break; - case VCD_RATE_CONTROL_CBR_CFR: - encoder->i_period.p_frames = - ((encoder->frame_rate.fps_numerator >> 1) / - encoder->frame_rate.fps_denominator) - 1; - break; - } - encoder->i_period.b_frames = DDL_DEFAULT_NUM_OF_B_FRAME; -} - -static void ddl_set_default_enc_rc_params( - struct ddl_encoder_data *encoder) -{ - enum vcd_codec codec = encoder->codec.codec; - encoder->rc_level.frame_level_rc = true; - encoder->qp_range.min_qp = 0x1; - if (codec == VCD_CODEC_H264) { - encoder->qp_range.min_qp = 0x1; - encoder->qp_range.max_qp = 0x33; - encoder->session_qp.i_frame_qp = 0x14; - encoder->session_qp.p_frame_qp = 0x14; - encoder->session_qp.b_frame_qp = 0x14; - encoder->rc_level.mb_level_rc = true; - encoder->adaptive_rc.disable_activity_region_flag = true; - encoder->adaptive_rc.disable_dark_region_as_flag = true; - encoder->adaptive_rc.disable_smooth_region_as_flag = true; - encoder->adaptive_rc.disable_static_region_as_flag = true; - } else { - encoder->qp_range.max_qp = 0x1f; - encoder->qp_range.min_qp = 0x1; - encoder->session_qp.i_frame_qp = 0xd; - encoder->session_qp.p_frame_qp = 0xd; - encoder->session_qp.b_frame_qp = 0xd; - encoder->rc_level.frame_level_rc = true; - encoder->rc_level.mb_level_rc = false; - } - switch (encoder->rc.rate_control) { - case VCD_RATE_CONTROL_VBR_CFR: - encoder->r_cframe_skip = 0; - encoder->frame_level_rc.reaction_coeff = 0x1f4; - break; - case VCD_RATE_CONTROL_CBR_VFR: - encoder->r_cframe_skip = 1; - if (codec != VCD_CODEC_H264) { - encoder->session_qp.i_frame_qp = 0xf; - encoder->session_qp.p_frame_qp = 0xf; - encoder->session_qp.b_frame_qp = 0xf; - } - encoder->frame_level_rc.reaction_coeff = 0x14; - break; - case VCD_RATE_CONTROL_CBR_CFR: - encoder->r_cframe_skip = 0; - encoder->frame_level_rc.reaction_coeff = 0x6; - break; - case VCD_RATE_CONTROL_OFF: - encoder->r_cframe_skip = 0; - encoder->rc_level.frame_level_rc = false; - encoder->rc_level.mb_level_rc = false; - break; - case VCD_RATE_CONTROL_VBR_VFR: - default: - encoder->r_cframe_skip = 1; - encoder->frame_level_rc.reaction_coeff = 0x1f4; - break; - } -} - -void ddl_set_default_encoder_buffer_req(struct ddl_encoder_data *encoder) -{ - u32 y_cb_cr_size, y_size; - memset(&encoder->hw_bufs.dpb_y, 0, sizeof(struct ddl_buf_addr) * 4); - memset(&encoder->hw_bufs.dpb_c, 0, sizeof(struct ddl_buf_addr) * 4); - - y_cb_cr_size = ddl_get_yuv_buffer_size(&encoder->frame_size, - &encoder->buf_format, false, - encoder->hdr.decoding, &y_size); - encoder->input_buf_size.size_yuv = y_cb_cr_size; - encoder->input_buf_size.size_y = y_size; - encoder->input_buf_size.size_c = y_cb_cr_size - y_size; - memset(&encoder->input_buf_req , 0 , - sizeof(struct vcd_buffer_requirement)); - encoder->input_buf_req.min_count = 3; - encoder->input_buf_req.actual_count = - encoder->input_buf_req.min_count; - encoder->input_buf_req.max_count = DDL_MAX_BUFFER_COUNT; - encoder->input_buf_req.sz = y_cb_cr_size; - if (encoder->buf_format.buffer_format == - VCD_BUFFER_FORMAT_NV12_16M2KA) - encoder->input_buf_req.align = - DDL_LINEAR_BUFFER_ALIGN_BYTES; - else if (VCD_BUFFER_FORMAT_TILE_4x2 == - encoder->buf_format.buffer_format) - encoder->input_buf_req.align = DDL_TILE_BUFFER_ALIGN_BYTES; - encoder->client_input_buf_req = encoder->input_buf_req; - memset(&encoder->output_buf_req , 0 , - sizeof(struct vcd_buffer_requirement)); - encoder->output_buf_req.min_count = encoder->i_period.b_frames + 2; - encoder->output_buf_req.actual_count = - encoder->output_buf_req.min_count + 3; - encoder->output_buf_req.max_count = DDL_MAX_BUFFER_COUNT; - encoder->output_buf_req.align = DDL_LINEAR_BUFFER_ALIGN_BYTES; - if (y_cb_cr_size >= VCD_DDL_720P_YUV_BUF_SIZE) - y_cb_cr_size = y_cb_cr_size>>1; - encoder->output_buf_req.sz = - DDL_ALIGN(y_cb_cr_size, DDL_KILO_BYTE(4)); - ddl_set_default_encoder_metadata_buffer_size(encoder); - encoder->client_output_buf_req = encoder->output_buf_req; - DDL_MSG_LOW("%s encoder->client_output_buf_req.sz = %d\n", - __func__, encoder->client_output_buf_req.sz); -} - -u32 ddl_set_default_decoder_buffer_req(struct ddl_decoder_data *decoder, - u32 estimate) -{ - struct vcd_property_frame_size *frame_size; - struct vcd_buffer_requirement *input_buf_req; - struct vcd_buffer_requirement *output_buf_req; - u32 min_dpb, y_cb_cr_size; - u32 frame_height_actual = 0; - - if (!decoder->codec.codec) - return false; - if (estimate) { - if (!decoder->cont_mode) - min_dpb = ddl_decoder_min_num_dpb(decoder); - else - min_dpb = res_trk_get_min_dpb_count(); - frame_size = &decoder->client_frame_size; - output_buf_req = &decoder->client_output_buf_req; - input_buf_req = &decoder->client_input_buf_req; - y_cb_cr_size = ddl_get_yuv_buffer_size(frame_size, - &decoder->buf_format, - (!decoder->progressive_only), - decoder->hdr.decoding, NULL); - } else { - frame_size = &decoder->frame_size; - output_buf_req = &decoder->actual_output_buf_req; - input_buf_req = &decoder->actual_input_buf_req; - min_dpb = decoder->min_dpb_num; - if ((decoder->buf_format.buffer_format == - VCD_BUFFER_FORMAT_TILE_4x2) && - (frame_size->height < MDP_MIN_TILE_HEIGHT)) { - frame_height_actual = frame_size->height; - frame_size->height = MDP_MIN_TILE_HEIGHT; - ddl_calculate_stride(frame_size, - !decoder->progressive_only); - y_cb_cr_size = ddl_get_yuv_buffer_size( - frame_size, - &decoder->buf_format, - (!decoder->progressive_only), - decoder->hdr.decoding, NULL); - decoder->y_cb_cr_size = y_cb_cr_size; - } else - y_cb_cr_size = decoder->y_cb_cr_size; - } - memset(output_buf_req, 0, - sizeof(struct vcd_buffer_requirement)); - if (!decoder->idr_only_decoding && !decoder->cont_mode) - output_buf_req->actual_count = min_dpb + 4; - else - output_buf_req->actual_count = min_dpb; - output_buf_req->min_count = min_dpb; - output_buf_req->max_count = DDL_MAX_BUFFER_COUNT; - output_buf_req->sz = y_cb_cr_size; - DDL_MSG_LOW("output_buf_req->sz : %d", output_buf_req->sz); - if (decoder->buf_format.buffer_format != VCD_BUFFER_FORMAT_NV12) - output_buf_req->align = DDL_TILE_BUFFER_ALIGN_BYTES; - else - output_buf_req->align = DDL_LINEAR_BUFFER_ALIGN_BYTES; - ddl_set_default_decoder_metadata_buffer_size(decoder, frame_size, - output_buf_req); - - decoder->min_output_buf_req = *output_buf_req; - memset(input_buf_req, 0, - sizeof(struct vcd_buffer_requirement)); - input_buf_req->min_count = 1; - input_buf_req->actual_count = input_buf_req->min_count + 1; - input_buf_req->max_count = DDL_MAX_BUFFER_COUNT; - input_buf_req->sz = (1024 * 1024 * 2); - input_buf_req->align = DDL_LINEAR_BUFFER_ALIGN_BYTES; - decoder->min_input_buf_req = *input_buf_req; - if (frame_height_actual) { - frame_size->height = frame_height_actual; - ddl_calculate_stride(frame_size, !decoder->progressive_only); - } - return true; -} - -u32 ddl_get_yuv_buffer_size(struct vcd_property_frame_size *frame_size, - struct vcd_property_buffer_format *buf_format, - u32 interlace, u32 decoding, u32 *pn_c_offset) -{ - struct vcd_property_frame_size frame_sz = *frame_size; - u32 total_memory_size = 0, c_offset = 0; - ddl_calculate_stride(&frame_sz, interlace); - if (buf_format->buffer_format == VCD_BUFFER_FORMAT_TILE_4x2) { - u32 component_mem_size, width_round_up; - u32 height_round_up, height_chroma = (frame_sz.scan_lines >> 1); - - width_round_up = - DDL_ALIGN(frame_sz.stride, DDL_TILE_ALIGN_WIDTH); - height_round_up = - DDL_ALIGN(frame_sz.scan_lines, - DDL_TILE_ALIGN_HEIGHT); - component_mem_size = width_round_up * height_round_up; - component_mem_size = DDL_ALIGN(component_mem_size, - DDL_TILE_MULTIPLY_FACTOR); - c_offset = component_mem_size; - total_memory_size = ((component_mem_size + - DDL_TILE_BUF_ALIGN_GUARD_BYTES) & - DDL_TILE_BUF_ALIGN_MASK); - height_round_up = DDL_ALIGN(height_chroma, - DDL_TILE_ALIGN_HEIGHT); - component_mem_size = width_round_up * height_round_up; - component_mem_size = DDL_ALIGN(component_mem_size, - DDL_TILE_MULTIPLY_FACTOR); - total_memory_size += component_mem_size; - } else { - if (decoding) - total_memory_size = frame_sz.scan_lines * - frame_sz.stride; - else - total_memory_size = frame_sz.height * frame_sz.stride; - c_offset = DDL_ALIGN(total_memory_size, - DDL_LINEAR_MULTIPLY_FACTOR); - total_memory_size = c_offset + DDL_ALIGN( - total_memory_size >> 1, DDL_LINEAR_MULTIPLY_FACTOR); - } - if (pn_c_offset) - *pn_c_offset = c_offset; - return total_memory_size; -} - - -void ddl_calculate_stride(struct vcd_property_frame_size *frame_size, - u32 interlace) -{ - frame_size->stride = DDL_ALIGN(frame_size->width, - DDL_LINEAR_ALIGN_WIDTH); - if (interlace) - frame_size->scan_lines = DDL_ALIGN(frame_size->height, - DDL_TILE_ALIGN_HEIGHT); - else - frame_size->scan_lines = DDL_ALIGN(frame_size->height, - DDL_LINEAR_ALIGN_HEIGHT); -} - - -static u32 ddl_valid_buffer_requirement(struct vcd_buffer_requirement - *original_buf_req, struct vcd_buffer_requirement *req_buf_req) -{ - u32 status = false; - - if (original_buf_req->max_count >= req_buf_req->actual_count && - original_buf_req->min_count <= - req_buf_req->actual_count && - !((original_buf_req->align - (u32)0x1) & - req_buf_req->align) && - /*original_buf_req->align <= req_buf_req->align,*/ - original_buf_req->sz <= req_buf_req->sz) - status = true; - else { - DDL_MSG_ERROR("ddl_valid_buf_req:Failed"); - DDL_MSG_ERROR("codec_buf_req: min_cnt=%d, mx_cnt=%d, " - "align=%d, sz=%d\n", original_buf_req->min_count, - original_buf_req->max_count, original_buf_req->align, - original_buf_req->sz); - DDL_MSG_ERROR("client_buffs: actual_count=%d, align=%d, " - "sz=%d\n", req_buf_req->actual_count, - req_buf_req->align, req_buf_req->sz); - } - return status; -} - -static u32 ddl_decoder_min_num_dpb(struct ddl_decoder_data *decoder) -{ - u32 min_dpb = 0; - - if (decoder->idr_only_decoding) { - min_dpb = DDL_MIN_BUFFER_COUNT; - if (decoder->post_filter.post_filter) - min_dpb *= 2; - return min_dpb; - } - - switch (decoder->codec.codec) { - case VCD_CODEC_H264: - { - u32 yuv_size_in_mb = DDL_MIN(DDL_NO_OF_MB( - decoder->client_frame_size.stride, - decoder->client_frame_size.scan_lines), - MAX_FRAME_SIZE_L4PT0_MBS); - min_dpb = DDL_MIN((MAX_DPB_SIZE_L4PT0_MBS / - yuv_size_in_mb), 16); - min_dpb += 2; - } - break; - case VCD_CODEC_H263: - min_dpb = 3; - break; - default: - case VCD_CODEC_MPEG1: - case VCD_CODEC_MPEG2: - case VCD_CODEC_MPEG4: - case VCD_CODEC_DIVX_3: - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_XVID: - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - min_dpb = 4; - if (decoder->post_filter.post_filter) - min_dpb *= 2; - break; - } - return min_dpb; -} - -static u32 ddl_set_dec_buffers(struct ddl_decoder_data *decoder, - struct ddl_property_dec_pic_buffers *dpb) -{ - u32 vcd_status = VCD_S_SUCCESS, loopc; - - - for (loopc = 0; !vcd_status && - loopc < dpb->no_of_dec_pic_buf; ++loopc) { - if ((!DDL_ADDR_IS_ALIGNED(dpb->dec_pic_buffers[loopc]. - vcd_frm.physical, - decoder->client_output_buf_req.align)) || - (dpb->dec_pic_buffers[loopc].vcd_frm.alloc_len < - decoder->client_output_buf_req.sz)) - vcd_status = VCD_ERR_ILLEGAL_PARM; - } - if (vcd_status) { - DDL_MSG_ERROR("ddl_set_prop:" - "Dpb_align_fail_or_alloc_size_small"); - return vcd_status; - } - if (decoder->dp_buf.no_of_dec_pic_buf) { - kfree(decoder->dp_buf.dec_pic_buffers); - decoder->dp_buf.no_of_dec_pic_buf = 0; - } - decoder->dp_buf.dec_pic_buffers = - kmalloc(dpb->no_of_dec_pic_buf * - sizeof(struct ddl_frame_data_tag), GFP_KERNEL); - if (!decoder->dp_buf.dec_pic_buffers) { - DDL_MSG_ERROR("ddl_dec_set_prop:Dpb_container_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - decoder->dp_buf.no_of_dec_pic_buf = dpb->no_of_dec_pic_buf; - for (loopc = 0; loopc < dpb->no_of_dec_pic_buf; ++loopc) - decoder->dp_buf.dec_pic_buffers[loopc] = - dpb->dec_pic_buffers[loopc]; - decoder->dpb_mask.client_mask = 0; - decoder->dpb_mask.hw_mask = 0; - decoder->dynamic_prop_change = 0; - return VCD_S_SUCCESS; -} - -void ddl_set_initial_default_values(struct ddl_client_context *ddl) -{ - - if (ddl->decoding) { - ddl->codec_data.decoder.codec.codec = VCD_CODEC_MPEG4; - ddl_set_default_dec_property(ddl); - } else { - struct ddl_encoder_data *encoder = - &(ddl->codec_data.encoder); - encoder->codec.codec = VCD_CODEC_MPEG4; - encoder->target_bit_rate.target_bitrate = 64000; - encoder->frame_size.width = VCD_DDL_TEST_DEFAULT_WIDTH; - encoder->frame_size.height = VCD_DDL_TEST_DEFAULT_HEIGHT; - encoder->frame_size.scan_lines = - VCD_DDL_TEST_DEFAULT_HEIGHT; - encoder->frame_size.stride = VCD_DDL_TEST_DEFAULT_WIDTH; - encoder->frame_rate.fps_numerator = DDL_INITIAL_FRAME_RATE; - encoder->frame_rate.fps_denominator = 1; - ddl_set_default_enc_property(ddl); - encoder->sps_pps.sps_pps_for_idr_enable_flag = false; - encoder->plusptype_enable = 0; - } -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.c deleted file mode 100644 index f5e81e12aed6e6d4c9a975f10142912867b52c93..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.c +++ /dev/null @@ -1,1193 +0,0 @@ -/* Copyright (c) 2010-2012, 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 "vcd_ddl_shared_mem.h" - -#define VIDC_SM_EXTENDED_DECODE_STATUS_ADDR 0x0000 -#define VIDC_SM_EXT_DEC_STATUS_RESOLUTION_CHANGE_BMSK 0x1 -#define VIDC_SM_EXT_DEC_STATUS_RESOLUTION_CHANGE_SHFT 0x0 -#define VIDC_SM_EXT_DEC_STATUS_MORE_FIELD_NEEDED_BMSK 0x4 -#define VIDC_SM_EXT_DEC_STATUS_MORE_FIELD_NEEDED_SHFT 0x2 - -#define VIDC_SM_SET_FRAME_TAG_ADDR 0x0004 -#define VIDC_SM_GET_FRAME_TAG_TOP_ADDR 0x0008 -#define VIDC_SM_GET_FRAME_TAG_BOTTOM_ADDR 0x000c -#define VIDC_SM_PIC_TIME_TOP_ADDR 0x0010 -#define VIDC_SM_PIC_TIME_BOTTOM_ADDR 0x0014 -#define VIDC_SM_START_BYTE_NUM_ADDR 0x0018 - -#define VIDC_SM_CROP_INFO1_ADDR 0x0020 -#define VIDC_SM_CROP_INFO1_RIGHT_OFFSET_BMSK 0xffff0000 -#define VIDC_SM_CROP_INFO1_RIGHT_OFFSET_SHFT 16 -#define VIDC_SM_CROP_INFO1_LEFT_OFFSET_BMSK 0x0000ffff -#define VIDC_SM_CROP_INFO1_LEFT_OFFSET_SHFT 0 - -#define VIDC_SM_CROP_INFO2_ADDR 0x0024 -#define VIDC_SM_CROP_INFO2_BOTTOM_OFFSET_BMSK 0xffff0000 -#define VIDC_SM_CROP_INFO2_BOTTOM_OFFSET_SHFT 16 -#define VIDC_SM_CROP_INFO2_TOP_OFFSET_BMSK 0x0000ffff -#define VIDC_SM_CROP_INFO2_TOP_OFFSET_SHFT 0 - -#define VIDC_SM_DISP_PIC_PROFILE_ADDR 0x007c -#define VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_LEVEL_BMASK 0x0000ff00 -#define VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_LEVEL_SHFT 8 -#define VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_PROFILE_BMASK 0x0000001f -#define VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_PROFILE_SHFT 0 - -#define VIDC_SM_DISP_PIC_FRAME_TYPE_ADDR 0x00c0 -#define VIDC_SM_DISP_PIC_FRAME_TYPE_BMSK 0x0000003f -#define VIDC_SM_DISP_PIC_FRAME_TYPE_SHFT 0 - -#define VIDC_SM_FREE_LUMA_DPB_ADDR 0x00c4 -#define VIDC_SM_FREE_LUMA_DPB_BMSK 0xffffffff -#define VIDC_SM_FREE_LUMA_DPB_SHFT 0 - -#define VIDC_SM_FREE_LUMA_DPB_DEC_ORDER_ADDR 0x00fc -#define VIDC_SM_FREE_LUMA_DPB_DEC_ORDER_BMSK 0xffffffff -#define VIDC_SM_FREE_LUMA_DPB_DEC_ORDER_SHFT 0 - -#define VIDC_SM_DEC_ORDER_WIDTH_ADDR 0x00e8 -#define VIDC_SM_DEC_ORDER_WIDTH_BMSK 0xffffffff -#define VIDC_SM_DEC_ORDER_WIDTH_SHFT 0 - -#define VIDC_SM_DEC_ORDER_HEIGHT_ADDR 0x00ec -#define VIDC_SM_DEC_ORDER_HEIGHT_BMSK 0xffffffff -#define VIDC_SM_DEC_ORDER_HEIGHT_SHFT 0 - -#define VIDC_SM_DEC_CROP_INFO1_ADDR 0x00f4 -#define VIDC_SM_DEC_CROP_INFO1_RIGHT_OFFSET_BMSK 0xffff0000 -#define VIDC_SM_DEC_CROP_INFO1_RIGHT_OFFSET_SHFT 16 -#define VIDC_SM_DEC_CROP_INFO1_LEFT_OFFSET_BMSK 0x0000ffff -#define VIDC_SM_DEC_CROP_INFO1_LEFT_OFFSET_SHFT 0 - -#define VIDC_SM_DEC_CROP_INFO2_ADDR 0x00f8 -#define VIDC_SM_DEC_CROP_INFO2_BOTTOM_OFFSET_BMSK 0xffff0000 -#define VIDC_SM_DEC_CROP_INFO2_BOTTOM_OFFSET_SHFT 16 -#define VIDC_SM_DEC_CROP_INFO2_TOP_OFFSET_BMSK 0x0000ffff -#define VIDC_SM_DEC_CROP_INFO2_TOP_OFFSET_SHFT 0 - -#define VIDC_SM_IDR_DECODING_ONLY_ADDR 0x0108 -#define VIDC_SM_IDR_DECODING_ONLY_BMSK 0x00000001 -#define VIDC_SM_IDR_DECODING_ONLY_SHIFT 0 - -#define VIDC_SM_ENC_EXT_CTRL_ADDR 0x0028 -#define VIDC_SM_ENC_EXT_CTRL_VBV_BUFFER_SIZE_BMSK 0xffff0000 -#define VIDC_SM_ENC_EXT_CTRL_VBV_BUFFER_SIZE_SHFT 16 -#define VIDC_SM_ENC_EXT_CTRL_TIMING_INFO_EN_BMSK 0x00004000 -#define VIDC_SM_ENC_EXT_CTRL_TIMING_INFO_EN_SHFT 14 -#define VIDC_SM_ENC_EXT_CTRL_AU_DELIMITER_EN_BMSK 0x00000800 -#define VIDC_SM_ENC_EXT_CTRL_AU_DELIMITER_EN_SHFT 11 -#define VIDC_SM_ENC_EXT_CTRL_LONG_TERM_REF_ENABLE_BMSK 0x00000400 -#define VIDC_SM_ENC_EXT_CTRL_LONG_TERM_REF_ENABLE_SHFT 10 -#define VIDC_SM_ENC_EXT_CTRL_H263_CPCFC_ENABLE_BMSK 0x80 -#define VIDC_SM_ENC_EXT_CTRL_H263_CPCFC_ENABLE_SHFT 7 -#define VIDC_SM_ENC_EXT_CTRL_SPS_PPS_CONTROL_BMSK 0X100 -#define VIDC_SM_ENC_EXT_CTRL_SPS_PPS_CONTROL_SHFT 8 -#define VIDC_SM_ENC_EXT_CTRL_SEQ_HDR_CTRL_BMSK 0x8 -#define VIDC_SM_ENC_EXT_CTRL_SEQ_HDR_CTRL_SHFT 3 -#define VIDC_SM_ENC_EXT_CTRL_FRAME_SKIP_ENABLE_BMSK 0x6 -#define VIDC_SM_ENC_EXT_CTRL_FRAME_SKIP_ENABLE_SHFT 1 -#define VIDC_SM_ENC_EXT_CTRL_HEC_ENABLE_BMSK 0x1 -#define VIDC_SM_ENC_EXT_CTRL_HEC_ENABLE_SHFT 0 - -#define VIDC_SM_ENC_PARAM_CHANGE_ADDR 0x002c -#define VIDC_SM_ENC_PARAM_CHANGE_RC_BIT_RATE_BMSK 0x4 -#define VIDC_SM_ENC_PARAM_CHANGE_RC_BIT_RATE_SHFT 2 -#define VIDC_SM_ENC_PARAM_CHANGE_RC_FRAME_RATE_BMSK 0x2 -#define VIDC_SM_ENC_PARAM_CHANGE_RC_FRAME_RATE_SHFT 1 -#define VIDC_SM_ENC_PARAM_CHANGE_I_PERIOD_BMSK 0x1 -#define VIDC_SM_ENC_PARAM_CHANGE_I_PERIOD_SHFT 0 - -#define VIDC_SM_ENC_VOP_TIMING_ADDR 0x0030 -#define VIDC_SM_ENC_VOP_TIMING_ENABLE_BMSK 0x80000000 -#define VIDC_SM_ENC_VOP_TIMING_ENABLE_SHFT 31 -#define VIDC_SM_ENC_VOP_TIMING_TIME_RESOLUTION_BMSK 0x7fff0000 -#define VIDC_SM_ENC_VOP_TIMING_TIME_RESOLUTION_SHFT 16 -#define VIDC_SM_ENC_VOP_TIMING_FRAME_DELTA_BMSK 0x0000ffff -#define VIDC_SM_ENC_VOP_TIMING_FRAME_DELTA_SHFT 0 - -#define VIDC_SM_ENC_HEC_PERIOD_ADDR 0x0034 - -#define VIDC_SM_H264_REF_L0_ADDR 0x005c -#define VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_1_BMSK 0x80000000 -#define VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_1_SHFT 31 -#define VIDC_SM_H264_REF_L0_CHRO_REF_1_BMSK 0x7f000000 -#define VIDC_SM_H264_REF_L0_CHRO_REF_1_SHFT 24 -#define VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_0_BMSK 0x00800000 -#define VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_0_SHFT 23 -#define VIDC_SM_H264_REF_L0_CHRO_REF_0_BMSK 0x007f0000 -#define VIDC_SM_H264_REF_L0_CHRO_REF_0_SHFT 16 -#define VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_1_BMSK 0x00008000 -#define VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_1_SHFT 15 -#define VIDC_SM_H264_REF_L0_LUMA_REF_1_BMSK 0x00007f00 -#define VIDC_SM_H264_REF_L0_LUMA_REF_1_SHFT 8 -#define VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_0_BMSK 0x00000080 -#define VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_0_SHFT 7 -#define VIDC_SM_H264_REF_L0_LUMA_REF_0_BMSK 0x0000007f -#define VIDC_SM_H264_REF_L0_LUMA_REF_0_SHFT 0 - -#define VIDC_SM_H264_REF_L1_ADDR 0x0060 -#define VIDC_SM_H264_REF_L1_CHRO_BTM_FLG_0_BMSK 0x00800000 -#define VIDC_SM_H264_REF_L1_CHRO_BTM_FLG_0_SHFT 23 -#define VIDC_SM_H264_REF_L1_CHRO_REF_0_BMSK 0x007f0000 -#define VIDC_SM_H264_REF_L1_CHRO_REF_0_SHFT 16 -#define VIDC_SM_H264_REF_L1_LUMA_BTM_FLG_0_BMSK 0x00000080 -#define VIDC_SM_H264_REF_L1_LUMA_BTM_FLG_0_SHFT 7 -#define VIDC_SM_H264_REF_L1_LUMA_REF_0_BMSK 0x0000007f -#define VIDC_SM_H264_REF_L1_LUMA_REF_0_SHFT 0 - -#define VIDC_SM_P_B_FRAME_QP_ADDR 0x0070 -#define VIDC_SM_P_B_FRAME_QP_B_FRAME_QP_BMASK 0x00000fc0 -#define VIDC_SM_P_B_FRAME_QP_B_FRAME_QP_SHFT 6 -#define VIDC_SM_P_B_FRAME_QP_P_FRAME_QP_BMASK 0x0000003f -#define VIDC_SM_P_B_FRAME_QP_P_FRAME_QP_SHFT 0 - -#define VIDC_SM_NEW_RC_BIT_RATE_ADDR 0x0090 -#define VIDC_SM_NEW_RC_BIT_RATE_VALUE_BMASK 0xffffffff -#define VIDC_SM_NEW_RC_BIT_RATE_VALUE_SHFT 0 -#define VIDC_SM_NEW_RC_FRAME_RATE_ADDR 0x0094 -#define VIDC_SM_NEW_RC_FRAME_RATE_VALUE_BMASK 0xffffffff -#define VIDC_SM_NEW_RC_FRAME_RATE_VALUE_SHFT 0 -#define VIDC_SM_NEW_I_PERIOD_ADDR 0x0098 -#define VIDC_SM_NEW_I_PERIOD_VALUE_BMASK 0xffffffff -#define VIDC_SM_NEW_I_PERIOD_VALUE_SHFT 0 - -#define VIDC_SM_BATCH_INPUT_ADDR 0x00a4 -#define VIDC_SM_BATCH_INPUT_ADDR_VALUE_BMSK 0xffffffff -#define VIDC_SM_BATCH_INPUT_ADDRL_VALUE_SHFT 0 -#define VIDC_SM_BATCH_OUTPUT_ADDR 0x00a8 -#define VIDC_SM_BATCH_OUTPUT_ADDR_VALUE_BMSK 0xffffffff -#define VIDC_SM_BATCH_OUTPUT_ADDR_VALUE_SHFT 0 -#define VIDC_SM_BATCH_OUTPUT_SIZE_ADDR 0x00ac -#define VIDC_SM_BATCH_OUTPUT_SIZE_VALUE_BMSK 0xffffffff -#define VIDC_SM_BATCH_OUTPUT_SIZE_VALUE_SHFT 0 -#define VIDC_SM_ENC_SLICE_BATCH_INT_CTRL_ADDR 0x01c8 -#define VIDC_SM_ENC_SLICE_BATCH_INT_CTRL_VALUE_BMSK 0x1 -#define VIDC_SM_ENC_SLICE_BATCH_INT_CTRL_VALUE_SHFT 0 -#define VIDC_SM_ENC_NUM_OF_SLICE_ADDR 0x01cc -#define VIDC_SM_ENC_NUM_OF_SLICE_VALUE_BMSK 0xffffffff -#define VIDC_SM_ENC_NUM_OF_SLICE_VALUE_SHFT 0 -#define VIDC_SM_ENC_NUM_OF_SLICE_COMP_ADDR 0x01d0 -#define VIDC_SM_ENC_NUM_OF_SLICE_COMP_VALUE_BMSK 0xffffffff -#define VIDC_SM_ENC_NUM_OF_SLICE_COMP_VALUE_SHFT 0 -#define VIDC_SM_ENC_NUM_UNITS_IN_TICK_ADDR 0x01dc -#define VIDC_SM_ENC_NUM_UNITS_IN_TICK_VALUE_BMSK 0xffffffff -#define VIDC_SM_ENC_NUM_UNITS_IN_TICK_VALUE_SHFT 0 -#define VIDC_SM_ENC_TIME_SCALE_ADDR 0x01e0 -#define VIDC_SM_ENC_TIME_SCALE_VALUE_BMSK 0xffffffff -#define VIDC_SM_ENC_TIME_SCALE_VALUE_SHFT 0 - - -#define VIDC_SM_ALLOCATED_LUMA_DPB_SIZE_ADDR 0x0064 -#define VIDC_SM_ALLOCATED_CHROMA_DPB_SIZE_ADDR 0x0068 -#define VIDC_SM_ALLOCATED_MV_SIZE_ADDR 0x006c -#define VIDC_SM_FLUSH_CMD_TYPE_ADDR 0x0080 -#define VIDC_SM_FLUSH_CMD_INBUF1_ADDR 0x0084 -#define VIDC_SM_FLUSH_CMD_INBUF2_ADDR 0x0088 -#define VIDC_SM_FLUSH_CMD_OUTBUF_ADDR 0x008c -#define VIDC_SM_MIN_LUMA_DPB_SIZE_ADDR 0x00b0 -#define VIDC_SM_MIN_CHROMA_DPB_SIZE_ADDR 0x00bc - - -#define VIDC_SM_METADATA_ENABLE_ADDR 0x0038 -#define VIDC_SM_METADATA_ENABLE_MP2_DATADUMP_BMSK 0x00000200 -#define VIDC_SM_METADATA_ENABLE_MP2_DATADUMP_SHFT 9 -#define VIDC_SM_METADATA_ENABLE_EXTRADATA_BMSK 0x40 -#define VIDC_SM_METADATA_ENABLE_EXTRADATA_SHFT 6 -#define VIDC_SM_METADATA_ENABLE_ENC_SLICE_SIZE_BMSK 0x20 -#define VIDC_SM_METADATA_ENABLE_ENC_SLICE_SIZE_SHFT 5 -#define VIDC_SM_METADATA_ENABLE_VUI_BMSK 0x10 -#define VIDC_SM_METADATA_ENABLE_VUI_SHFT 4 -#define VIDC_SM_METADATA_ENABLE_SEI_VIDC_BMSK 0x8 -#define VIDC_SM_METADATA_ENABLE_SEI_VIDC_SHFT 3 -#define VIDC_SM_METADATA_ENABLE_VC1_PARAM_BMSK 0x4 -#define VIDC_SM_METADATA_ENABLE_VC1_PARAM_SHFT 2 -#define VIDC_SM_METADATA_ENABLE_CONCEALED_MB_BMSK 0x2 -#define VIDC_SM_METADATA_ENABLE_CONCEALED_MB_SHFT 1 -#define VIDC_SM_METADATA_ENABLE_QP_BMSK 0x1 -#define VIDC_SM_METADATA_ENABLE_QP_SHFT 0 - -#define VIDC_SM_ASPECT_RATIO_INFO_ADDR 0x00c8 -#define VIDC_SM_MPEG4_ASPECT_RATIO_INFO_BMSK 0xf -#define VIDC_SM_MPEG4_ASPECT_RATIO_INFO_SHFT 0x0 -#define VIDC_SM_MPEG2_ASPECT_RATIO_INFO_BMSK 0x000f0000 -#define VIDC_SM_MPEG2_ASPECT_RATIO_INFO_SHFT 16 -#define VIDC_SM_H264_ASPECT_RATIO_INFO_BMSK 0x00000ff0 -#define VIDC_SM_H264_ASPECT_RATIO_INFO_SHFT 4 -#define VIDC_SM_EXTENDED_PAR_ADDR 0x00cc -#define VIDC_SM_EXTENDED_PAR_WIDTH_BMSK 0xffff0000 -#define VIDC_SM_EXTENDED_PAR_WIDTH_SHFT 16 -#define VIDC_SM_EXTENDED_PAR_HEIGHT_BMSK 0x0000ffff -#define VIDC_SM_EXTENDED_PAR_HEIGHT_SHFT 0x0 - -#define VIDC_SM_METADATA_STATUS_ADDR 0x003c -#define VIDC_SM_METADATA_STATUS_STATUS_BMSK 0x1 -#define VIDC_SM_METADATA_STATUS_STATUS_SHFT 0 - -#define VIDC_SM_METADATA_DISPLAY_INDEX_ADDR 0x0040 -#define VIDC_SM_EXT_METADATA_START_ADDR_ADDR 0x0044 - -#define VIDC_SM_PUT_EXTRADATA_ADDR 0x0048 -#define VIDC_SM_PUT_EXTRADATA_PUT_BMSK 0x1 -#define VIDC_SM_PUT_EXTRADATA_PUT_SHFT 0 - -#define VIDC_SM_EXTRADATA_ADDR_ADDR 0x004c - -#define VIDC_SM_CHROMA_ADDR_CHANGE_ADDR 0x0148 -#define VIDC_SM_CHROMA_ADDR_CHANGE_BMASK 0x00000001 -#define VIDC_SM_CHROMA_ADDR_CHANGE_SHFT 0 - -#define VIDC_SM_ERROR_CONCEALMENT_CONFIG_ADDR 0x0154 - -#define VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTER_SLICE_BMSK 0x0c -#define VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTER_SLICE_SHFT 2 -#define VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTRA_SLICE_BMSK 0X02 -#define VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTRA_SLICE_SHFT 1 -#define VIDC_SM_ERROR_CONCEALMENT_CONFIG_CONCEAL_ENABLE_BMSK 0x01 -#define VIDC_SM_ERROR_CONCEALMENT_CONFIG_CONCEAL_ENABLE_SHFT 0 - -#define VIDC_SM_SEI_ENABLE_ADDR 0x0180 -#define VIDC_SM_SEI_ENABLE_RECOVERY_POINT_SEI_BMSK 0x00000001 -#define VIDC_SM_SEI_ENABLE_RECOVERY_POINT_SEI_SHFT 0 - -#define VIDC_SM_NUM_STUFF_BYTES_CONSUME_ADDR 0X01ac - -#define VIDC_SM_TIMEOUT_VALUE_ADDR 0x0158 -#define VIDC_SM_TIMEOUT_VALUE_BMSK 0xffffffff -#define VIDC_SM_TIMEOUT_VALUE_SHFT 0 - -#define VIDC_SM_MP2_DATA_DUMP_CONTROL_ADDR 0x0194 -#define VIDC_SM_MP2_USERDATA_DUMP_ENABLE_BMSK 0x00000300 -#define VIDC_SM_MP2_USERDATA_DUMP_ENABLE_SHFT 8 -#define VIDC_SM_MP2_PICT_TEMP_DUMP_ENABLE_BMSK 0x00000080 -#define VIDC_SM_MP2_PICT_TEMP_DUMP_ENABLE_SHFT 7 -#define VIDC_SM_MP2_PICT_SPAT_EXT_DUMP_ENABLE_BMSK 0x00000040 -#define VIDC_SM_MP2_PICT_SPAT_EXT_DUMP_ENABLE_SHFT 6 -#define VIDC_SM_MP2_PICT_DISP_EXT_DUMP_ENABLE_BMSK 0x00000020 -#define VIDC_SM_MP2_PICT_DISP_EXT_DUMP_ENABLE_SHFT 5 -#define VIDC_SM_MP2_COPYRIGHT_EXT_DUMP_ENABLE_BMSK 0x00000010 -#define VIDC_SM_MP2_COPYRIGHT_EXT_DUMP_ENABLE_SHFT 4 -#define VIDC_SM_MP2_QMATRIX_EXT_DUMP_ENABLE_BMSK 0x00000008 -#define VIDC_SM_MP2_QMATRIX_EXT_DUMP_ENABLE_SHFT 3 -#define VIDC_SM_MP2_SCAL_EXT_DUMP_ENABLE_BMSK 0x00000004 -#define VIDC_SM_MP2_SCAL_EXT_DUMP_ENABLE_SHFT 2 -#define VIDC_SM_MP2_SEQ_DISP_EXT_DUMP_ENABLE_BMSK 0x00000002 -#define VIDC_SM_MP2_SEQ_DISP_EXT_DUMP_ENABLE_SHFT 1 -#define VIDC_SM_MP2_SEQ_EXT_DUMP_ENABLE_BMSK 0x00000001 -#define VIDC_SM_MP2_SEQ_EXT_DUMP_ENABLE_SHFT 0 - -#define VIDC_SM_MP2_DATA_DUMP_STATUS_ADDR 0x0198 -#define VIDC_SM_MP2_USERDATA_DUMP_STATUS_BMSK 0x00000300 -#define VIDC_SM_MP2_USERDATA_DUMP_STATUS_SHFT 8 -#define VIDC_SM_MP2_PICT_TEMP_DUMP_STATUS_BMSK 0x00000080 -#define VIDC_SM_MP2_PICT_TEMP_DUMP_STATUS_SHFT 7 -#define VIDC_SM_MP2_PICT_SPAT_EXT_DUMP_STATUS_BMSK 0x00000040 -#define VIDC_SM_MP2_PICT_SPAT_EXT_DUMP_STATUS_SHFT 6 -#define VIDC_SM_MP2_PICT_DISP_EXT_DUMP_STATUS_BMSK 0x00000020 -#define VIDC_SM_MP2_PICT_DISP_EXT_DUMP_STATUS_SHFT 5 -#define VIDC_SM_MP2_COPYRIGHT_EXT_DUMP_STATUS_BMSK 0x00000010 -#define VIDC_SM_MP2_COPYRIGHT_EXT_DUMP_STATUS_SHFT 4 -#define VIDC_SM_MP2_QMATRIX_EXT_DUMP_STATUS_BMSK 0x00000008 -#define VIDC_SM_MP2_QMATRIX_EXT_DUMP_STATUS_SHFT 3 -#define VIDC_SM_MP2_SCAL_EXT_DUMP_STATUS_BMSK 0x00000004 -#define VIDC_SM_MP2_SCAL_EXT_DUMP_STATUS_SHFT 2 -#define VIDC_SM_MP2_SEQ_DISP_EXT_DUMP_STATUS_BMSK 0x00000002 -#define VIDC_SM_MP2_SEQ_DISP_EXT_DUMP_STATUS_SHFT 1 -#define VIDC_SM_MP2_SEQ_EXT_DUMP_STATUS_BMSK 0x00000001 -#define VIDC_SM_MP2_SEQ_EXT_DUMP_STATUS_SHFT 0 - -#define VIDC_SM_MP2_DATA_DUMP_BUFFER_ADDR 0x01a4 -#define VIDC_SM_MP2_DATA_DUMP_BUFFER_SIZE_ADDR 0x01a8 - - - -#define VIDC_SM_ENC_EXT_CTRL_CLOSED_GOP_ENABLE_BMSK 0x40 -#define VIDC_SM_ENC_EXT_CTRL_CLOSED_GOP_ENABLE_SHFT 6 - -#define DDL_MEM_WRITE_32(base, offset, val) ddl_mem_write_32(\ - (u32 *) ((u8 *) (base)->align_virtual_addr + (offset)), (val)) -#define DDL_MEM_READ_32(base, offset) ddl_mem_read_32(\ - (u32 *) ((u8 *) (base)->align_virtual_addr + (offset))) - -#define DDL_SHARED_MEM_11BIT_RIGHT_SHIFT 11 - -static void ddl_mem_write_32(u32 *addr, u32 data) -{ - *addr = data; -} - -static u32 ddl_mem_read_32(u32 *addr) -{ - return *addr; -} - -void vidc_sm_get_extended_decode_status(struct ddl_buf_addr *shared_mem, - u32 *more_field_needed, - u32 *resl_change) -{ - u32 decode_status = DDL_MEM_READ_32(shared_mem, - VIDC_SM_EXTENDED_DECODE_STATUS_ADDR); - if (more_field_needed) - *more_field_needed = - VIDC_GETFIELD(decode_status, - VIDC_SM_EXT_DEC_STATUS_MORE_FIELD_NEEDED_BMSK, - VIDC_SM_EXT_DEC_STATUS_MORE_FIELD_NEEDED_SHFT); - if (resl_change) - *resl_change = - VIDC_GETFIELD(decode_status, - VIDC_SM_EXT_DEC_STATUS_RESOLUTION_CHANGE_BMSK, - VIDC_SM_EXT_DEC_STATUS_RESOLUTION_CHANGE_SHFT); -} - -void vidc_sm_set_frame_tag(struct ddl_buf_addr *shared_mem, - u32 frame_tag) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_SET_FRAME_TAG_ADDR, frame_tag); -} - -void vidc_sm_get_frame_tags(struct ddl_buf_addr *shared_mem, - u32 *pn_frame_tag_top, u32 *pn_frame_tag_bottom) -{ - *pn_frame_tag_top = DDL_MEM_READ_32(shared_mem, - VIDC_SM_GET_FRAME_TAG_TOP_ADDR); - *pn_frame_tag_bottom = DDL_MEM_READ_32(shared_mem, - VIDC_SM_GET_FRAME_TAG_BOTTOM_ADDR); -} - -void vidc_sm_get_picture_times(struct ddl_buf_addr *shared_mem, - u32 *pn_time_top, u32 *pn_time_bottom) -{ - *pn_time_top = DDL_MEM_READ_32(shared_mem, VIDC_SM_PIC_TIME_TOP_ADDR); - *pn_time_bottom = DDL_MEM_READ_32(shared_mem, - VIDC_SM_PIC_TIME_BOTTOM_ADDR); -} - -void vidc_sm_set_start_byte_number(struct ddl_buf_addr *shared_mem, - u32 byte_num) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_START_BYTE_NUM_ADDR, byte_num); -} - -void vidc_sm_get_crop_info(struct ddl_buf_addr *shared_mem, - u32 *pn_left, u32 *pn_right, u32 *pn_top, u32 *pn_bottom) -{ - u32 info1, info2; - - info1 = DDL_MEM_READ_32(shared_mem, VIDC_SM_CROP_INFO1_ADDR); - - *pn_left = VIDC_GETFIELD(info1, VIDC_SM_CROP_INFO1_LEFT_OFFSET_BMSK, - VIDC_SM_CROP_INFO1_LEFT_OFFSET_SHFT); - *pn_right = VIDC_GETFIELD(info1, VIDC_SM_CROP_INFO1_RIGHT_OFFSET_BMSK, - VIDC_SM_CROP_INFO1_RIGHT_OFFSET_SHFT); - info2 = DDL_MEM_READ_32(shared_mem, VIDC_SM_CROP_INFO2_ADDR); - *pn_top = VIDC_GETFIELD(info2, VIDC_SM_CROP_INFO2_TOP_OFFSET_BMSK, - VIDC_SM_CROP_INFO2_TOP_OFFSET_SHFT); - *pn_bottom = VIDC_GETFIELD(info2, - VIDC_SM_CROP_INFO2_BOTTOM_OFFSET_BMSK, - VIDC_SM_CROP_INFO2_BOTTOM_OFFSET_SHFT); -} - -void vidc_sm_get_displayed_picture_frame(struct ddl_buf_addr - *shared_mem, u32 *n_disp_picture_frame) -{ - u32 disp_pict_frame; - - disp_pict_frame = DDL_MEM_READ_32(shared_mem, - VIDC_SM_DISP_PIC_FRAME_TYPE_ADDR); - *n_disp_picture_frame = VIDC_GETFIELD(disp_pict_frame, - VIDC_SM_DISP_PIC_FRAME_TYPE_BMSK, - VIDC_SM_DISP_PIC_FRAME_TYPE_SHFT); -} -void vidc_sm_get_available_luma_dpb_address(struct ddl_buf_addr - *shared_mem, u32 *pn_free_luma_dpb_address) -{ - *pn_free_luma_dpb_address = DDL_MEM_READ_32(shared_mem, - VIDC_SM_FREE_LUMA_DPB_ADDR); -} - -void vidc_sm_get_available_luma_dpb_dec_order_address( - struct ddl_buf_addr *shared_mem, - u32 *pn_free_luma_dpb_address) -{ - *pn_free_luma_dpb_address = DDL_MEM_READ_32(shared_mem, - VIDC_SM_FREE_LUMA_DPB_DEC_ORDER_ADDR); -} - -void vidc_sm_get_dec_order_resl( - struct ddl_buf_addr *shared_mem, u32 *width, u32 *height) -{ - *width = DDL_MEM_READ_32(shared_mem, - VIDC_SM_DEC_ORDER_WIDTH_ADDR); - *height = DDL_MEM_READ_32(shared_mem, - VIDC_SM_DEC_ORDER_HEIGHT_ADDR); -} - -void vidc_sm_get_dec_order_crop_info( - struct ddl_buf_addr *shared_mem, u32 *left, - u32 *right, u32 *top, u32 *bottom) -{ - u32 crop_data; - crop_data = DDL_MEM_READ_32(shared_mem, - VIDC_SM_DEC_CROP_INFO1_ADDR); - *left = VIDC_GETFIELD(crop_data, - VIDC_SM_DEC_CROP_INFO1_LEFT_OFFSET_BMSK, - VIDC_SM_DEC_CROP_INFO1_LEFT_OFFSET_SHFT); - *right = VIDC_GETFIELD(crop_data, - VIDC_SM_DEC_CROP_INFO1_RIGHT_OFFSET_BMSK, - VIDC_SM_DEC_CROP_INFO1_RIGHT_OFFSET_SHFT); - crop_data = DDL_MEM_READ_32(shared_mem, - VIDC_SM_DEC_CROP_INFO2_ADDR); - *top = VIDC_GETFIELD(crop_data, - VIDC_SM_DEC_CROP_INFO2_TOP_OFFSET_BMSK, - VIDC_SM_DEC_CROP_INFO2_TOP_OFFSET_SHFT); - *bottom = VIDC_GETFIELD(crop_data, - VIDC_SM_DEC_CROP_INFO2_BOTTOM_OFFSET_BMSK, - VIDC_SM_DEC_CROP_INFO2_BOTTOM_OFFSET_SHFT); -} - -void vidc_sm_set_extended_encoder_control(struct ddl_buf_addr - *shared_mem, u32 hec_enable, - enum VIDC_SM_frame_skip frame_skip_mode, - u32 seq_hdr_in_band, u32 vbv_buffer_size, u32 cpcfc_enable, - u32 sps_pps_control, u32 closed_gop_enable, - u32 au_delim_enable, u32 vui_timing_info_enable, - u32 ltr_enable) -{ - u32 enc_ctrl; - enc_ctrl = VIDC_SETFIELD((hec_enable) ? 1 : 0, - VIDC_SM_ENC_EXT_CTRL_HEC_ENABLE_SHFT, - VIDC_SM_ENC_EXT_CTRL_HEC_ENABLE_BMSK) | - VIDC_SETFIELD((u32) frame_skip_mode, - VIDC_SM_ENC_EXT_CTRL_FRAME_SKIP_ENABLE_SHFT, - VIDC_SM_ENC_EXT_CTRL_FRAME_SKIP_ENABLE_BMSK) | - VIDC_SETFIELD((seq_hdr_in_band) ? 1 : 0 , - VIDC_SM_ENC_EXT_CTRL_SEQ_HDR_CTRL_SHFT , - VIDC_SM_ENC_EXT_CTRL_SEQ_HDR_CTRL_BMSK) | - VIDC_SETFIELD(vbv_buffer_size, - VIDC_SM_ENC_EXT_CTRL_VBV_BUFFER_SIZE_SHFT, - VIDC_SM_ENC_EXT_CTRL_VBV_BUFFER_SIZE_BMSK) | - VIDC_SETFIELD((cpcfc_enable) ? 1 : 0, - VIDC_SM_ENC_EXT_CTRL_H263_CPCFC_ENABLE_SHFT, - VIDC_SM_ENC_EXT_CTRL_H263_CPCFC_ENABLE_BMSK) | - VIDC_SETFIELD((sps_pps_control) ? 1 : 0, - VIDC_SM_ENC_EXT_CTRL_SPS_PPS_CONTROL_SHFT, - VIDC_SM_ENC_EXT_CTRL_SPS_PPS_CONTROL_BMSK) | - VIDC_SETFIELD(closed_gop_enable, - VIDC_SM_ENC_EXT_CTRL_CLOSED_GOP_ENABLE_SHFT, - VIDC_SM_ENC_EXT_CTRL_CLOSED_GOP_ENABLE_BMSK) | - VIDC_SETFIELD((au_delim_enable) ? 1 : 0, - VIDC_SM_ENC_EXT_CTRL_AU_DELIMITER_EN_SHFT, - VIDC_SM_ENC_EXT_CTRL_AU_DELIMITER_EN_BMSK) | - VIDC_SETFIELD((vui_timing_info_enable) ? 1 : 0, - VIDC_SM_ENC_EXT_CTRL_TIMING_INFO_EN_SHFT, - VIDC_SM_ENC_EXT_CTRL_TIMING_INFO_EN_BMSK) | - VIDC_SETFIELD((ltr_enable) ? 1 : 0, - VIDC_SM_ENC_EXT_CTRL_LONG_TERM_REF_ENABLE_SHFT, - VIDC_SM_ENC_EXT_CTRL_LONG_TERM_REF_ENABLE_BMSK); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ENC_EXT_CTRL_ADDR, enc_ctrl); -} - -void vidc_sm_set_encoder_param_change(struct ddl_buf_addr *shared_mem, - u32 bit_rate_chg, u32 frame_rate_chg, u32 i_period_chg) -{ - u32 enc_param_chg; - - enc_param_chg = VIDC_SETFIELD((bit_rate_chg) ? 1 : 0, - VIDC_SM_ENC_PARAM_CHANGE_RC_BIT_RATE_SHFT, - VIDC_SM_ENC_PARAM_CHANGE_RC_BIT_RATE_BMSK) | - VIDC_SETFIELD((frame_rate_chg) ? 1 : 0, - VIDC_SM_ENC_PARAM_CHANGE_RC_FRAME_RATE_SHFT, - VIDC_SM_ENC_PARAM_CHANGE_RC_FRAME_RATE_BMSK) | - VIDC_SETFIELD((i_period_chg) ? 1 : 0, - VIDC_SM_ENC_PARAM_CHANGE_I_PERIOD_SHFT, - VIDC_SM_ENC_PARAM_CHANGE_I_PERIOD_BMSK); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ENC_PARAM_CHANGE_ADDR, - enc_param_chg); -} - -void vidc_sm_set_encoder_vop_time(struct ddl_buf_addr *shared_mem, - u32 vop_time_enable, u32 time_resolution, u32 frame_delta) -{ - u32 vop_time; - - vop_time = VIDC_SETFIELD((vop_time_enable) ? 1 : 0, - VIDC_SM_ENC_VOP_TIMING_ENABLE_SHFT , - VIDC_SM_ENC_VOP_TIMING_ENABLE_BMSK) | - VIDC_SETFIELD(time_resolution , - VIDC_SM_ENC_VOP_TIMING_TIME_RESOLUTION_SHFT, - VIDC_SM_ENC_VOP_TIMING_TIME_RESOLUTION_BMSK) | - VIDC_SETFIELD(frame_delta, - VIDC_SM_ENC_VOP_TIMING_FRAME_DELTA_SHFT, - VIDC_SM_ENC_VOP_TIMING_FRAME_DELTA_BMSK); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ENC_VOP_TIMING_ADDR, vop_time); -} - -void vidc_sm_set_encoder_hec_period(struct ddl_buf_addr *shared_mem, - u32 hec_period) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ENC_HEC_PERIOD_ADDR, - hec_period); -} - -void vidc_sm_get_h264_encoder_reference_list0(struct ddl_buf_addr - *shared_mem, enum VIDC_SM_ref_picture *pe_luma_picture0, - u32 *pn_luma_picture_index0, enum VIDC_SM_ref_picture - *pe_luma_picture1, u32 *pn_luma_picture_index1, - enum VIDC_SM_ref_picture *pe_chroma_picture0, - u32 *pn_chroma_picture_index0, - enum VIDC_SM_ref_picture *pe_chroma_picture1, - u32 *pn_chroma_picture_index1) -{ - u32 ref_list; - - ref_list = DDL_MEM_READ_32(shared_mem, VIDC_SM_H264_REF_L0_ADDR); - - *pe_luma_picture0 = (enum VIDC_SM_ref_picture) - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_0_BMSK, - VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_0_SHFT); - *pn_luma_picture_index0 = - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_LUMA_REF_0_BMSK, - VIDC_SM_H264_REF_L0_LUMA_REF_0_SHFT); - *pe_luma_picture1 = (enum VIDC_SM_ref_picture) - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_1_BMSK, - VIDC_SM_H264_REF_L0_LUMA_BTM_FLG_1_SHFT); - *pn_luma_picture_index1 = VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_LUMA_REF_1_BMSK, - VIDC_SM_H264_REF_L0_LUMA_REF_1_SHFT); - *pe_chroma_picture0 = (enum VIDC_SM_ref_picture) - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_0_BMSK, - VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_0_SHFT); - *pn_chroma_picture_index0 = VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_CHRO_REF_0_BMSK, - VIDC_SM_H264_REF_L0_CHRO_REF_0_SHFT); - *pe_chroma_picture1 = (enum VIDC_SM_ref_picture) - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_1_BMSK, - VIDC_SM_H264_REF_L0_CHRO_BTM_FLG_1_SHFT); - *pn_chroma_picture_index1 = - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L0_CHRO_REF_1_BMSK, - VIDC_SM_H264_REF_L0_CHRO_REF_1_SHFT); -} - -void vidc_sm_get_h264_encoder_reference_list1(struct ddl_buf_addr - *shared_mem, enum VIDC_SM_ref_picture *pe_luma_picture, - u32 *pn_luma_picture_index, - enum VIDC_SM_ref_picture *pe_chroma_picture, - u32 *pn_chroma_picture_index) -{ - u32 ref_list; - - ref_list = DDL_MEM_READ_32(shared_mem, VIDC_SM_H264_REF_L1_ADDR); - - *pe_luma_picture = (enum VIDC_SM_ref_picture) - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L1_LUMA_BTM_FLG_0_BMSK, - VIDC_SM_H264_REF_L1_LUMA_BTM_FLG_0_SHFT); - *pn_luma_picture_index = - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L1_LUMA_REF_0_BMSK, - VIDC_SM_H264_REF_L1_LUMA_REF_0_SHFT); - *pe_chroma_picture = (enum VIDC_SM_ref_picture) - VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L1_CHRO_BTM_FLG_0_BMSK, - VIDC_SM_H264_REF_L1_CHRO_BTM_FLG_0_SHFT); - *pn_chroma_picture_index = VIDC_GETFIELD(ref_list, - VIDC_SM_H264_REF_L1_CHRO_REF_0_BMSK, - VIDC_SM_H264_REF_L1_CHRO_REF_0_SHFT); -} - -void vidc_sm_set_allocated_dpb_size(struct ddl_buf_addr *shared_mem, - u32 y_size, u32 c_size) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ALLOCATED_LUMA_DPB_SIZE_ADDR, - y_size); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ALLOCATED_CHROMA_DPB_SIZE_ADDR, - c_size); -} - -void vidc_sm_set_allocated_h264_mv_size(struct ddl_buf_addr *shared_mem, - u32 mv_size) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ALLOCATED_MV_SIZE_ADDR, - mv_size); -} - -void vidc_sm_get_min_yc_dpb_sizes(struct ddl_buf_addr *shared_mem, - u32 *pn_min_luma_dpb_size, u32 *pn_min_chroma_dpb_size) -{ - *pn_min_luma_dpb_size = DDL_MEM_READ_32(shared_mem, - VIDC_SM_MIN_LUMA_DPB_SIZE_ADDR); - *pn_min_chroma_dpb_size = DDL_MEM_READ_32(shared_mem, - VIDC_SM_MIN_CHROMA_DPB_SIZE_ADDR); -} - -void vidc_sm_set_concealment_color(struct ddl_buf_addr *shared_mem, - u32 conceal_ycolor, u32 conceal_ccolor) -{ - u32 conceal_color; - - conceal_color = (((conceal_ycolor << 8) & 0xff00) | - (conceal_ccolor & 0xff)); - DDL_MEM_WRITE_32(shared_mem, 0x00f0, conceal_color); -} - -void vidc_sm_set_metadata_enable(struct ddl_buf_addr *shared_mem, - u32 extradata_enable, u32 qp_enable, u32 concealed_mb_enable, - u32 vc1Param_enable, u32 sei_nal_enable, u32 vui_enable, - u32 enc_slice_size_enable, u32 mp2_data_dump_enable) -{ - u32 metadata_enable; - - metadata_enable = VIDC_SETFIELD((mp2_data_dump_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_MP2_DATADUMP_SHFT, - VIDC_SM_METADATA_ENABLE_MP2_DATADUMP_BMSK) | - VIDC_SETFIELD((extradata_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_EXTRADATA_SHFT, - VIDC_SM_METADATA_ENABLE_EXTRADATA_BMSK) | - VIDC_SETFIELD((enc_slice_size_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_ENC_SLICE_SIZE_SHFT, - VIDC_SM_METADATA_ENABLE_ENC_SLICE_SIZE_BMSK) | - VIDC_SETFIELD((vui_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_VUI_SHFT, - VIDC_SM_METADATA_ENABLE_VUI_BMSK) | - VIDC_SETFIELD((sei_nal_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_SEI_VIDC_SHFT, - VIDC_SM_METADATA_ENABLE_SEI_VIDC_BMSK) | - VIDC_SETFIELD((vc1Param_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_VC1_PARAM_SHFT, - VIDC_SM_METADATA_ENABLE_VC1_PARAM_BMSK) | - VIDC_SETFIELD((concealed_mb_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_CONCEALED_MB_SHFT, - VIDC_SM_METADATA_ENABLE_CONCEALED_MB_BMSK) | - VIDC_SETFIELD((qp_enable) ? 1 : 0, - VIDC_SM_METADATA_ENABLE_QP_SHFT, - VIDC_SM_METADATA_ENABLE_QP_BMSK); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_METADATA_ENABLE_ADDR, - metadata_enable); -} - -void vidc_sm_get_metadata_status(struct ddl_buf_addr - *shared_mem, u32 *pb_metadata_present) -{ - u32 status; - - status = DDL_MEM_READ_32(shared_mem, VIDC_SM_METADATA_STATUS_ADDR); - *pb_metadata_present = (u32) VIDC_GETFIELD(status, - VIDC_SM_METADATA_STATUS_STATUS_BMSK, - VIDC_SM_METADATA_STATUS_STATUS_SHFT); -} - -void vidc_sm_get_metadata_display_index(struct ddl_buf_addr *shared_mem, - u32 *pn_dixplay_index) -{ - *pn_dixplay_index = DDL_MEM_READ_32(shared_mem, - VIDC_SM_METADATA_DISPLAY_INDEX_ADDR); -} - -void vidc_sm_set_metadata_start_address(struct ddl_buf_addr *shared_mem, - u32 address) -{ - u32 address_shift = address; - - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_EXT_METADATA_START_ADDR_ADDR, - address_shift); -} - -void vidc_sm_set_extradata_presence(struct ddl_buf_addr *shared_mem, - u32 extradata_present) -{ - u32 put_extradata; - - put_extradata = VIDC_SETFIELD((extradata_present) ? 1 : 0, - VIDC_SM_PUT_EXTRADATA_PUT_SHFT, - VIDC_SM_PUT_EXTRADATA_PUT_BMSK); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_PUT_EXTRADATA_ADDR, - put_extradata); -} - -void vidc_sm_set_extradata_addr(struct ddl_buf_addr *shared_mem, - u32 extradata_addr) -{ - u32 address_shift = extradata_addr; - - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_EXTRADATA_ADDR_ADDR, - address_shift); -} - -void vidc_sm_set_pand_b_frame_qp(struct ddl_buf_addr *shared_mem, - u32 b_frame_qp, u32 p_frame_qp) -{ - u32 nP_B_frame_qp; - - nP_B_frame_qp = VIDC_SETFIELD(b_frame_qp, - VIDC_SM_P_B_FRAME_QP_B_FRAME_QP_SHFT, - VIDC_SM_P_B_FRAME_QP_B_FRAME_QP_BMASK); - nP_B_frame_qp |= VIDC_SETFIELD(p_frame_qp, - VIDC_SM_P_B_FRAME_QP_P_FRAME_QP_SHFT, - VIDC_SM_P_B_FRAME_QP_P_FRAME_QP_BMASK); - DDL_MEM_WRITE_32(shared_mem , VIDC_SM_P_B_FRAME_QP_ADDR, - nP_B_frame_qp); -} - - -void vidc_sm_get_profile_info(struct ddl_buf_addr *shared_mem, - struct ddl_profile_info_type *ddl_profile_info) -{ - u32 disp_pic_profile; - - disp_pic_profile = DDL_MEM_READ_32(shared_mem, - VIDC_SM_DISP_PIC_PROFILE_ADDR); - ddl_profile_info->bit_depth_chroma_minus8 = - (disp_pic_profile & 0x00380000) >> 19; - ddl_profile_info->bit_depth_luma_minus8 = - (disp_pic_profile & 0x00070000) >> 16; - ddl_profile_info->pic_profile = VIDC_GETFIELD( - disp_pic_profile, - VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_PROFILE_BMASK, - VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_PROFILE_SHFT); - ddl_profile_info->pic_level = VIDC_GETFIELD( - disp_pic_profile, - VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_LEVEL_BMASK, - VIDC_SM_DISP_PIC_PROFILE_DISP_PIC_LEVEL_SHFT); - ddl_profile_info->chroma_format_idc = - (disp_pic_profile & 0x60) >> 5; -} - -void vidc_sm_set_encoder_new_bit_rate(struct ddl_buf_addr *shared_mem, - u32 new_bit_rate) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_NEW_RC_BIT_RATE_ADDR, - new_bit_rate); -} - -void vidc_sm_set_encoder_new_frame_rate(struct ddl_buf_addr *shared_mem, - u32 new_frame_rate) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_NEW_RC_FRAME_RATE_ADDR, - new_frame_rate); -} - -void vidc_sm_set_encoder_new_i_period(struct ddl_buf_addr *shared_mem, - u32 new_i_period) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_NEW_I_PERIOD_ADDR, - new_i_period); -} -void vidc_sm_set_encoder_init_rc_value(struct ddl_buf_addr *shared_mem, - u32 new_rc_value) -{ - DDL_MEM_WRITE_32(shared_mem, 0x011C, new_rc_value); - -} -void vidc_sm_set_idr_decode_only(struct ddl_buf_addr *shared_mem, - u32 enable) -{ - u32 idr_decode_only = VIDC_SETFIELD((enable) ? 1 : 0, - VIDC_SM_IDR_DECODING_ONLY_SHIFT, - VIDC_SM_IDR_DECODING_ONLY_BMSK - ); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_IDR_DECODING_ONLY_ADDR, - idr_decode_only); -} - -void vidc_sm_set_chroma_addr_change(struct ddl_buf_addr *shared_mem, - u32 addr_change) -{ - u32 chroma_addr_change = VIDC_SETFIELD((addr_change) ? 1 : 0, - VIDC_SM_CHROMA_ADDR_CHANGE_SHFT, - VIDC_SM_CHROMA_ADDR_CHANGE_BMASK); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_CHROMA_ADDR_CHANGE_ADDR, - chroma_addr_change); - -} - -void vidc_sm_set_mpeg4_profile_override(struct ddl_buf_addr *shared_mem, - enum vidc_sm_mpeg4_profileinfo profile_info) -{ - u32 profile_enforce = 0; - if (shared_mem != NULL) { - profile_enforce = 1; - switch (profile_info) { - case VIDC_SM_PROFILE_INFO_ASP: - profile_enforce |= 4; - break; - case VIDC_SM_PROFILE_INFO_SP: - profile_enforce |= 2; - break; - case VIDC_SM_PROFILE_INFO_DISABLE: - default: - profile_enforce = 0; - break; - } - DDL_MEM_WRITE_32(shared_mem, 0x15c, profile_enforce); - } -} -void vidc_sm_set_decoder_sei_enable(struct ddl_buf_addr *shared_mem, - u32 sei_enable) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_SEI_ENABLE_ADDR, sei_enable); -} - -void vidc_sm_get_decoder_sei_enable(struct ddl_buf_addr *shared_mem, - u32 *sei_enable) -{ - *sei_enable = DDL_MEM_READ_32(shared_mem, VIDC_SM_SEI_ENABLE_ADDR); -} - -void vidc_sm_set_error_concealment_config(struct ddl_buf_addr *shared_mem, - u32 inter_slice, u32 intra_slice, u32 conceal_config_enable) -{ - u32 error_conceal_config = 0; - - error_conceal_config = VIDC_SETFIELD(inter_slice, - VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTER_SLICE_SHFT, - VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTER_SLICE_BMSK); - - error_conceal_config |= VIDC_SETFIELD(intra_slice, - VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTRA_SLICE_SHFT, - VIDC_SM_ERROR_CONCEALMENT_CONFIG_INTRA_SLICE_BMSK); - - error_conceal_config |= VIDC_SETFIELD(conceal_config_enable, - VIDC_SM_ERROR_CONCEALMENT_CONFIG_CONCEAL_ENABLE_SHFT, - VIDC_SM_ERROR_CONCEALMENT_CONFIG_CONCEAL_ENABLE_BMSK); - - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_ERROR_CONCEALMENT_CONFIG_ADDR, - error_conceal_config); -} - -void vidc_sm_set_decoder_stuff_bytes_consumption( - struct ddl_buf_addr *shared_mem, - enum vidc_sm_num_stuff_bytes_consume_info consume_info) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_NUM_STUFF_BYTES_CONSUME_ADDR, - consume_info); -} - -void vidc_sm_get_aspect_ratio_info(struct ddl_buf_addr *shared_mem, - enum vcd_codec codec, struct vcd_aspect_ratio *aspect_ratio_info) -{ - u32 extended_par_info = 0, aspect_ratio = 0; - - aspect_ratio = DDL_MEM_READ_32(shared_mem, - VIDC_SM_ASPECT_RATIO_INFO_ADDR); - - if (codec == VCD_CODEC_H264) { - aspect_ratio_info->aspect_ratio = - VIDC_GETFIELD(aspect_ratio, - VIDC_SM_H264_ASPECT_RATIO_INFO_BMSK, - VIDC_SM_H264_ASPECT_RATIO_INFO_SHFT); - - switch (aspect_ratio_info->aspect_ratio) { - case 1: - aspect_ratio_info->par_width = 1; - aspect_ratio_info->par_height = 1; - break; - case 2: - aspect_ratio_info->par_width = 12; - aspect_ratio_info->par_height = 11; - break; - case 3: - aspect_ratio_info->par_width = 10; - aspect_ratio_info->par_height = 11; - break; - case 4: - aspect_ratio_info->par_width = 16; - aspect_ratio_info->par_height = 11; - break; - case 5: - aspect_ratio_info->par_width = 40; - aspect_ratio_info->par_height = 33; - break; - case 6: - aspect_ratio_info->par_width = 24; - aspect_ratio_info->par_height = 11; - break; - case 7: - aspect_ratio_info->par_width = 20; - aspect_ratio_info->par_height = 11; - break; - case 8: - aspect_ratio_info->par_width = 32; - aspect_ratio_info->par_height = 11; - break; - case 9: - aspect_ratio_info->par_width = 80; - aspect_ratio_info->par_height = 33; - break; - case 10: - aspect_ratio_info->par_width = 18; - aspect_ratio_info->par_height = 11; - break; - case 11: - aspect_ratio_info->par_width = 15; - aspect_ratio_info->par_height = 11; - break; - case 12: - aspect_ratio_info->par_width = 64; - aspect_ratio_info->par_height = 33; - break; - case 13: - aspect_ratio_info->par_width = 160; - aspect_ratio_info->par_height = 99; - break; - case 14: - aspect_ratio_info->par_width = 4; - aspect_ratio_info->par_height = 3; - break; - case 15: - aspect_ratio_info->par_width = 3; - aspect_ratio_info->par_height = 2; - break; - case 16: - aspect_ratio_info->par_width = 2; - aspect_ratio_info->par_height = 1; - break; - case 255: - extended_par_info = DDL_MEM_READ_32(shared_mem, - VIDC_SM_EXTENDED_PAR_ADDR); - aspect_ratio_info->par_width = - VIDC_GETFIELD(extended_par_info, - VIDC_SM_EXTENDED_PAR_WIDTH_BMSK, - VIDC_SM_EXTENDED_PAR_WIDTH_SHFT); - aspect_ratio_info->par_height = - VIDC_GETFIELD(extended_par_info, - VIDC_SM_EXTENDED_PAR_HEIGHT_BMSK, - VIDC_SM_EXTENDED_PAR_HEIGHT_SHFT); - break; - default: - DDL_MSG_LOW("Incorrect Aspect Ratio."); - aspect_ratio_info->par_width = 1; - aspect_ratio_info->par_height = 1; - break; - } - } else if ((codec == VCD_CODEC_MPEG4) || - (codec == VCD_CODEC_DIVX_4) || - (codec == VCD_CODEC_DIVX_5) || - (codec == VCD_CODEC_DIVX_6) || - (codec == VCD_CODEC_XVID)) { - - aspect_ratio_info->aspect_ratio = - VIDC_GETFIELD(aspect_ratio, - VIDC_SM_MPEG4_ASPECT_RATIO_INFO_BMSK, - VIDC_SM_MPEG4_ASPECT_RATIO_INFO_SHFT); - - switch (aspect_ratio_info->aspect_ratio) { - case 1: - aspect_ratio_info->par_width = 1; - aspect_ratio_info->par_height = 1; - break; - case 2: - aspect_ratio_info->par_width = 12; - aspect_ratio_info->par_height = 11; - break; - case 3: - aspect_ratio_info->par_width = 10; - aspect_ratio_info->par_height = 11; - break; - case 4: - aspect_ratio_info->par_width = 16; - aspect_ratio_info->par_height = 11; - break; - case 5: - aspect_ratio_info->par_width = 40; - aspect_ratio_info->par_height = 33; - break; - case 15: - extended_par_info = DDL_MEM_READ_32(shared_mem, - VIDC_SM_EXTENDED_PAR_ADDR); - aspect_ratio_info->par_width = - VIDC_GETFIELD(extended_par_info, - VIDC_SM_EXTENDED_PAR_WIDTH_BMSK, - VIDC_SM_EXTENDED_PAR_WIDTH_SHFT); - aspect_ratio_info->par_height = - VIDC_GETFIELD(extended_par_info, - VIDC_SM_EXTENDED_PAR_HEIGHT_BMSK, - VIDC_SM_EXTENDED_PAR_HEIGHT_SHFT); - break; - default: - DDL_MSG_LOW("Incorrect Aspect Ratio."); - aspect_ratio_info->par_width = 1; - aspect_ratio_info->par_height = 1; - break; - } - } else if (codec == VCD_CODEC_MPEG2) { - - aspect_ratio_info->aspect_ratio = - VIDC_GETFIELD(aspect_ratio, - VIDC_SM_MPEG2_ASPECT_RATIO_INFO_BMSK, - VIDC_SM_MPEG2_ASPECT_RATIO_INFO_SHFT); - - switch (aspect_ratio_info->aspect_ratio) { - case 1: - aspect_ratio_info->par_width = 1; - aspect_ratio_info->par_height = 1; - break; - case 2: - aspect_ratio_info->par_width = 4; - aspect_ratio_info->par_height = 3; - break; - case 3: - aspect_ratio_info->par_width = 16; - aspect_ratio_info->par_height = 9; - break; - case 4: - aspect_ratio_info->par_width = 221; - aspect_ratio_info->par_height = 100; - break; - default: - DDL_MSG_LOW("Incorrect Aspect Ratio."); - aspect_ratio_info->par_width = 1; - aspect_ratio_info->par_height = 1; - break; - } - } - -} - -void vidc_sm_set_encoder_slice_batch_int_ctrl(struct ddl_buf_addr *shared_mem, - u32 slice_batch_int_enable) -{ - u32 slice_batch_int_ctrl = VIDC_SETFIELD((slice_batch_int_enable) ? - 1 : 0, - VIDC_SM_ENC_EXT_CTRL_HEC_ENABLE_SHFT, - VIDC_SM_ENC_EXT_CTRL_HEC_ENABLE_BMSK); - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_ENC_SLICE_BATCH_INT_CTRL_ADDR, - slice_batch_int_ctrl); -} - -void vidc_sm_get_num_slices_comp(struct ddl_buf_addr *shared_mem, - u32 *num_slices_comp) -{ - *num_slices_comp = DDL_MEM_READ_32(shared_mem, - VIDC_SM_ENC_NUM_OF_SLICE_COMP_ADDR); -} - -void vidc_sm_set_encoder_batch_config(struct ddl_buf_addr *shared_mem, - u32 num_slices, - u32 input_addr, u32 output_addr, - u32 output_buffer_size) -{ - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_ENC_NUM_OF_SLICE_ADDR, - num_slices); - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_BATCH_INPUT_ADDR, - input_addr); - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_BATCH_OUTPUT_ADDR, - output_addr); - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_BATCH_OUTPUT_SIZE_ADDR, - output_buffer_size); -} - -void vidc_sm_get_encoder_batch_output_size(struct ddl_buf_addr *shared_mem, - u32 *output_buffer_size) -{ - *output_buffer_size = DDL_MEM_READ_32(shared_mem, - VIDC_SM_BATCH_OUTPUT_SIZE_ADDR); -} - -void vidc_sm_set_video_core_timeout_value(struct ddl_buf_addr *shared_mem, - u32 timeout) -{ - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_TIMEOUT_VALUE_ADDR, - timeout); -} - -void vidc_sm_set_mp2datadump_enable(struct ddl_buf_addr *shared_mem, - struct ddl_mp2_datadumpenabletype *ddl_mp2_datadump_enable) -{ - u32 mp2_datadump_enable = 0; - - mp2_datadump_enable = VIDC_SETFIELD( - ddl_mp2_datadump_enable->userdatadump_enable, - VIDC_SM_MP2_USERDATA_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_USERDATA_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - pictempscalable_extdump_enable ? 1 : 0, - VIDC_SM_MP2_PICT_TEMP_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_PICT_TEMP_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - picspat_extdump_enable ? 1 : 0, - VIDC_SM_MP2_PICT_SPAT_EXT_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_PICT_SPAT_EXT_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - picdisp_extdump_enable ? 1 : 0, - VIDC_SM_MP2_PICT_DISP_EXT_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_PICT_DISP_EXT_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - copyright_extdump_enable ? 1 : 0, - VIDC_SM_MP2_COPYRIGHT_EXT_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_COPYRIGHT_EXT_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - quantmatrix_extdump_enable ? 1 : 0, - VIDC_SM_MP2_QMATRIX_EXT_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_QMATRIX_EXT_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - seqscalable_extdump_enable ? 1 : 0, - VIDC_SM_MP2_SCAL_EXT_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_SCAL_EXT_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - seqdisp_extdump_enable ? 1 : 0, - VIDC_SM_MP2_SEQ_DISP_EXT_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_SEQ_DISP_EXT_DUMP_ENABLE_BMSK) | - VIDC_SETFIELD(ddl_mp2_datadump_enable-> - seq_extdump_enable ? 1 : 0, - VIDC_SM_MP2_SEQ_EXT_DUMP_ENABLE_SHFT, - VIDC_SM_MP2_SEQ_EXT_DUMP_ENABLE_BMSK); - DDL_MEM_WRITE_32(shared_mem, VIDC_SM_MP2_DATA_DUMP_CONTROL_ADDR, - mp2_datadump_enable); - -} - -void vidc_sm_get_mp2datadump_status(struct ddl_buf_addr - *shared_mem, u32 *ext_userdata_present) -{ - u32 status; - - status = DDL_MEM_READ_32(shared_mem, - VIDC_SM_MP2_DATA_DUMP_STATUS_ADDR); - *ext_userdata_present = (u32) VIDC_GETFIELD(status, - VIDC_SM_MP2_USERDATA_DUMP_STATUS_BMSK, - VIDC_SM_MP2_USERDATA_DUMP_STATUS_SHFT); -} - -void vidc_sm_set_mp2datadumpbuffer(struct ddl_buf_addr *shared_mem, - u32 mp2datadumpaddr, u32 mp2datadumpsize) -{ - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_MP2_DATA_DUMP_BUFFER_ADDR, - mp2datadumpaddr); - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_MP2_DATA_DUMP_BUFFER_SIZE_ADDR, - mp2datadumpsize); -} - -void vidc_sm_set_h264_encoder_timing_info(struct ddl_buf_addr *shared_mem, - u32 num_units_in_tick, u32 time_scale) -{ - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_ENC_NUM_UNITS_IN_TICK_ADDR, - num_units_in_tick); - - DDL_MEM_WRITE_32(shared_mem, - VIDC_SM_ENC_TIME_SCALE_ADDR, - time_scale); -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.h b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.h deleted file mode 100644 index b7325a861362b18e0bd5580ccb9ba01d2bcf1b53..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.h +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DDL_SHARED_MEM_H_ -#define _VCD_DDL_SHARED_MEM_H_ - -#include "vcd_ddl.h" - -#define VIDC_SM_PROFILE_MPEG4_SIMPLE (0) -#define VIDC_SM_PROFILE_MPEG4_ADV_SIMPLE (1) - -#define VIDC_SM_PROFILE_H264_BASELINE (0) -#define VIDC_SM_PROFILE_H264_MAIN (1) -#define VIDC_SM_PROFILE_H264_HIGH (2) - -#define VIDC_SM_PROFILE_H263_BASELINE (0) - -#define VIDC_SM_PROFILE_VC1_SIMPLE (0) -#define VIDC_SM_PROFILE_VC1_MAIN (1) -#define VIDC_SM_PROFILE_VC1_ADVANCED (2) - -#define VIDC_SM_PROFILE_MPEG2_MAIN (4) -#define VIDC_SM_PROFILE_MPEG2_SIMPLE (5) - -#define VIDC_SM_LEVEL_MPEG2_LOW (10) -#define VIDC_SM_LEVEL_MPEG2_MAIN (8) -#define VIDC_SM_LEVEL_MPEG2_HIGH_1440 (6) -#define VIDC_SM_LEVEL_MPEG2_HIGH (4) - -#define VIDC_SM_LEVEL_VC1_LOW (0) -#define VIDC_SM_LEVEL_VC1_MEDIUM (2) -#define VIDC_SM_LEVEL_VC1_HIGH (4) - -#define VIDC_SM_LEVEL_VC1_ADV_0 (0) -#define VIDC_SM_LEVEL_VC1_ADV_1 (1) -#define VIDC_SM_LEVEL_VC1_ADV_2 (2) -#define VIDC_SM_LEVEL_VC1_ADV_3 (3) -#define VIDC_SM_LEVEL_VC1_ADV_4 (4) - -#define VIDC_SM_RECOVERY_POINT_SEI (1) -enum VIDC_SM_frame_skip { - VIDC_SM_FRAME_SKIP_DISABLE = 0, - VIDC_SM_FRAME_SKIP_ENABLE_LEVEL = 1, - VIDC_SM_FRAME_SKIP_ENABLE_VBV = 2 -}; -enum VIDC_SM_ref_picture { - VIDC_SM_REF_PICT_FRAME_OR_TOP_FIELD = 0, - VIDC_SM_REF_PICT_BOTTOM_FIELD = 1 -}; - -struct ddl_profile_info_type { - u32 bit_depth_chroma_minus8; - u32 bit_depth_luma_minus8; - u32 pic_level; - u32 chroma_format_idc; - u32 pic_profile; -}; - -enum vidc_sm_mpeg4_profileinfo { - VIDC_SM_PROFILE_INFO_DISABLE = 0, - VIDC_SM_PROFILE_INFO_SP = 1, - VIDC_SM_PROFILE_INFO_ASP = 2, - VIDC_SM_PROFILE_INFO_MAX = 0x7fffffff -}; - -enum vidc_sm_num_stuff_bytes_consume_info { - VIDC_SM_NUM_STUFF_BYTES_CONSUME_ALL = 0x0, - VIDC_SM_NUM_STUFF_BYTES_CONSUME_NONE = 0xffffffff -}; - -void vidc_sm_get_extended_decode_status(struct ddl_buf_addr *shared_mem, - u32 *more_field_needed, - u32 *resl_change); -void vidc_sm_set_frame_tag(struct ddl_buf_addr *shared_mem, - u32 frame_tag); -void vidc_sm_get_frame_tags(struct ddl_buf_addr *shared_mem, - u32 *pn_frame_tag_top, u32 *pn_frame_tag_bottom); -void vidc_sm_get_picture_times(struct ddl_buf_addr *shared_mem, - u32 *pn_time_top, u32 *pn_time_bottom); -void vidc_sm_set_start_byte_number(struct ddl_buf_addr *shared_mem, - u32 byte_num); -void vidc_sm_get_crop_info(struct ddl_buf_addr *shared_mem, u32 *pn_left, - u32 *pn_right, u32 *pn_top, u32 *pn_bottom); -void vidc_sm_get_displayed_picture_frame(struct ddl_buf_addr - *shared_mem, u32 *n_disp_picture_frame); -void vidc_sm_get_available_luma_dpb_address( - struct ddl_buf_addr *shared_mem, u32 *pn_free_luma_dpb_address); -void vidc_sm_get_available_luma_dpb_dec_order_address( - struct ddl_buf_addr *shared_mem, u32 *pn_free_luma_dpb_address); -void vidc_sm_get_dec_order_resl( - struct ddl_buf_addr *shared_mem, u32 *width, u32 *height); -void vidc_sm_get_dec_order_crop_info( - struct ddl_buf_addr *shared_mem, u32 *left, - u32 *right, u32 *top, u32 *bottom); -void vidc_sm_set_extended_encoder_control( - struct ddl_buf_addr *shared_mem, u32 hec_enable, - enum VIDC_SM_frame_skip frame_skip_mode, u32 seq_hdr_in_band, - u32 vbv_buffer_size, u32 cpcfc_enable, u32 sps_pps_control, - u32 closed_gop_enable, u32 au_delim_enable, u32 vui_timing_info_enable, - u32 ltr_enable); -void vidc_sm_set_encoder_param_change(struct ddl_buf_addr *shared_mem, - u32 bit_rate_chg, u32 frame_rate_chg, u32 i_period_chg); -void vidc_sm_set_encoder_vop_time(struct ddl_buf_addr *shared_mem, - u32 vop_time_enable, u32 time_resolution, u32 frame_delta); -void vidc_sm_set_encoder_hec_period(struct ddl_buf_addr *shared_mem, - u32 hec_period); -void vidc_sm_get_h264_encoder_reference_list0( - struct ddl_buf_addr *shared_mem, - enum VIDC_SM_ref_picture *pe_luma_picture0, - u32 *pn_luma_picture_index0, - enum VIDC_SM_ref_picture *pe_luma_picture1, - u32 *pn_luma_picture_index1, - enum VIDC_SM_ref_picture *pe_chroma_picture0, - u32 *pn_chroma_picture_index0, - enum VIDC_SM_ref_picture *pe_chroma_picture1, - u32 *pn_chroma_picture_index1); - -void vidc_sm_get_h264_encoder_reference_list1( - struct ddl_buf_addr *shared_mem, - enum VIDC_SM_ref_picture *pe_luma_picture, - u32 *pn_luma_picture_index, - enum VIDC_SM_ref_picture *pe_chroma_picture, - u32 *pn_chroma_picture_index); -void vidc_sm_set_allocated_dpb_size(struct ddl_buf_addr *shared_mem, - u32 y_size, u32 c_size); -void vidc_sm_set_allocated_h264_mv_size(struct ddl_buf_addr *shared_mem, - u32 mv_size); -void vidc_sm_get_min_yc_dpb_sizes(struct ddl_buf_addr *shared_mem, - u32 *pn_min_luma_dpb_size, u32 *pn_min_chroma_dpb_size); -void vidc_sm_set_metadata_enable(struct ddl_buf_addr *shared_mem, - u32 extradata_enable, u32 qp_enable, u32 concealed_mb_enable, - u32 vc1Param_enable, u32 sei_nal_enable, u32 vui_enable, - u32 enc_slice_size_enable, u32 mp2_data_dump_enable); -void vidc_sm_get_metadata_status(struct ddl_buf_addr *shared_mem, - u32 *pb_metadata_present); -void vidc_sm_get_metadata_display_index(struct ddl_buf_addr *shared_mem, - u32 *pn_dixplay_index); -void vidc_sm_set_metadata_start_address(struct ddl_buf_addr *shared_mem, - u32 address); -void vidc_sm_set_extradata_presence(struct ddl_buf_addr *shared_mem, - u32 extradata_present); -void vidc_sm_set_extradata_addr(struct ddl_buf_addr *shared_mem, - u32 extradata_addr); -void vidc_sm_set_pand_b_frame_qp(struct ddl_buf_addr *shared_mem, - u32 b_frame_qp, u32 p_frame_qp); -void vidc_sm_get_profile_info(struct ddl_buf_addr *shared_mem, - struct ddl_profile_info_type *ddl_profile_info); -void vidc_sm_set_encoder_new_bit_rate(struct ddl_buf_addr *shared_mem, - u32 new_bit_rate); -void vidc_sm_set_encoder_new_frame_rate(struct ddl_buf_addr *shared_mem, - u32 new_frame_rate); -void vidc_sm_set_encoder_new_i_period(struct ddl_buf_addr *shared_mem, - u32 new_i_period); -void vidc_sm_set_encoder_init_rc_value(struct ddl_buf_addr *shared_mem, - u32 new_rc_value); -void vidc_sm_set_idr_decode_only(struct ddl_buf_addr *shared_mem, - u32 enable); -void vidc_sm_set_concealment_color(struct ddl_buf_addr *shared_mem, - u32 conceal_ycolor, u32 conceal_ccolor); -void vidc_sm_set_chroma_addr_change(struct ddl_buf_addr *shared_mem, - u32 addr_change); -void vidc_sm_set_mpeg4_profile_override(struct ddl_buf_addr *shared_mem, - enum vidc_sm_mpeg4_profileinfo profile_info); -void vidc_sm_set_decoder_sei_enable(struct ddl_buf_addr *shared_mem, - u32 sei_enable); -void vidc_sm_get_decoder_sei_enable(struct ddl_buf_addr *shared_mem, - u32 *sei_enable); -void vidc_sm_set_error_concealment_config(struct ddl_buf_addr *shared_mem, - u32 inter_slice, u32 intra_slice, u32 conceal_config_enable); -void vidc_sm_set_decoder_stuff_bytes_consumption( - struct ddl_buf_addr *shared_mem, - enum vidc_sm_num_stuff_bytes_consume_info consume_info); -void vidc_sm_get_aspect_ratio_info(struct ddl_buf_addr *shared_mem, - enum vcd_codec codec, struct vcd_aspect_ratio *aspect_ratio_info); -void vidc_sm_set_encoder_slice_batch_int_ctrl(struct ddl_buf_addr *shared_mem, - u32 slice_batch_int_enable); -void vidc_sm_get_num_slices_comp(struct ddl_buf_addr *shared_mem, - u32 *num_slices_comp); -void vidc_sm_set_encoder_batch_config(struct ddl_buf_addr *shared_mem, - u32 num_slices, - u32 input_addr, u32 output_addr, - u32 output_buffer_size); -void vidc_sm_get_encoder_batch_output_size(struct ddl_buf_addr *shared_mem, - u32 *output_buffer_size); -void vidc_sm_set_video_core_timeout_value(struct ddl_buf_addr *shared_mem, - u32 timeout); -void vidc_sm_get_mp2datadump_status(struct ddl_buf_addr - *shared_mem, u32 *ext_userdata_present); -void vidc_sm_set_mp2datadump_enable(struct ddl_buf_addr *shared_mem, - struct ddl_mp2_datadumpenabletype *ddl_mp2_datadump_enable); -void vidc_sm_set_mp2datadumpbuffer(struct ddl_buf_addr *shared_mem, - u32 mp2datadumpaddr, u32 mp2datadumpsize); -void vidc_sm_set_h264_encoder_timing_info(struct ddl_buf_addr *shared_mem, - u32 num_units_in_tick, u32 time_scale); - -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c deleted file mode 100644 index f1d1e172e923ecd7a989962ded0e56c1538492a5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.c +++ /dev/null @@ -1,460 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include "vcd_ddl_utils.h" -#include "vcd_ddl.h" -#include "vcd_res_tracker_api.h" - -struct time_data { - unsigned int ddl_t1; - unsigned int ddl_ttotal; - unsigned int ddl_count; -}; -static struct time_data proc_time[MAX_TIME_DATA]; -#define DDL_MSG_TIME(x...) printk(KERN_DEBUG x) - -#ifdef DDL_BUF_LOG -static void ddl_print_buffer(struct ddl_context *ddl_context, - struct ddl_buf_addr *buf, u32 idx, u8 *str); -static void ddl_print_port(struct ddl_context *ddl_context, - struct ddl_buf_addr *buf); -static void ddl_print_buffer_port(struct ddl_context *ddl_context, - struct ddl_buf_addr *buf, u32 idx, u8 *str); -#endif -void *ddl_pmem_alloc(struct ddl_buf_addr *addr, size_t sz, u32 alignment) -{ - u32 alloc_size, offset = 0 ; - struct ddl_context *ddl_context; - unsigned long iova = 0; - unsigned long buffer_size = 0; - unsigned long *kernel_vaddr = NULL; - int ret = 0; - ion_phys_addr_t phyaddr = 0; - size_t len = 0; - int rc = 0; - DBG_PMEM("\n%s() IN: Requested alloc size(%u)", __func__, (u32)sz); - if (!addr) { - DDL_MSG_ERROR("\n%s() Invalid Parameters", __func__); - goto bail_out; - } - ddl_context = ddl_get_context(); - res_trk_set_mem_type(addr->mem_type); - alloc_size = (sz + alignment); - if (res_trk_get_enable_ion()) { - if (!ddl_context->video_ion_client) - ddl_context->video_ion_client = - res_trk_get_ion_client(); - if (!ddl_context->video_ion_client) { - DDL_MSG_ERROR("%s() :DDL ION Client Invalid handle\n", - __func__); - goto bail_out; - } - alloc_size = (alloc_size+4095) & ~4095; - addr->alloc_handle = ion_alloc( - ddl_context->video_ion_client, alloc_size, SZ_4K, - res_trk_get_mem_type(), res_trk_get_ion_flags()); - if (IS_ERR_OR_NULL(addr->alloc_handle)) { - DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", - __func__); - goto bail_out; - } - kernel_vaddr = (unsigned long *) ion_map_kernel( - ddl_context->video_ion_client, - addr->alloc_handle); - if (IS_ERR_OR_NULL(kernel_vaddr)) { - DDL_MSG_ERROR("%s() :DDL ION map failed\n", - __func__); - goto free_ion_alloc; - } - addr->virtual_base_addr = (u8 *) kernel_vaddr; - if (res_trk_check_for_sec_session()) { - rc = ion_phys(ddl_context->video_ion_client, - addr->alloc_handle, &phyaddr, - &len); - if (rc || !phyaddr) { - DDL_MSG_ERROR( - "%s():DDL ION client physical failed\n", - __func__); - goto unmap_ion_alloc; - } - addr->alloced_phys_addr = phyaddr; - } else { - ret = ion_map_iommu(ddl_context->video_ion_client, - addr->alloc_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL, - SZ_4K, - 0, - (dma_addr_t *)&iova, - &buffer_size, - 0, 0); - if (ret || !iova) { - DDL_MSG_ERROR( - "%s():DDL ION ion map iommu failed, ret = %d iova = 0x%lx\n", - __func__, ret, iova); - goto unmap_ion_alloc; - } - addr->alloced_phys_addr = (phys_addr_t) iova; - } - if (!addr->alloced_phys_addr) { - DDL_MSG_ERROR("%s():DDL ION client physical failed\n", - __func__); - goto unmap_ion_alloc; - } - addr->mapped_buffer = NULL; - addr->physical_base_addr = (u8 *) addr->alloced_phys_addr; - addr->align_physical_addr = (u8 *) DDL_ALIGN((u32) - addr->physical_base_addr, alignment); - offset = (u32)(addr->align_physical_addr - - addr->physical_base_addr); - addr->align_virtual_addr = addr->virtual_base_addr + offset; - addr->buffer_size = alloc_size; - } else { - pr_err("ION must be enabled."); - goto bail_out; - } - return addr->virtual_base_addr; -unmap_ion_alloc: - ion_unmap_kernel(ddl_context->video_ion_client, - addr->alloc_handle); - addr->virtual_base_addr = NULL; - addr->alloced_phys_addr = (phys_addr_t)NULL; -free_ion_alloc: - ion_free(ddl_context->video_ion_client, - addr->alloc_handle); - addr->alloc_handle = NULL; -bail_out: - return NULL; -} - -void ddl_pmem_free(struct ddl_buf_addr *addr) -{ - struct ddl_context *ddl_context; - ddl_context = ddl_get_context(); - if (!addr) { - pr_err("%s() invalid args\n", __func__); - return; - } - if (ddl_context->video_ion_client) { - if (!IS_ERR_OR_NULL(addr->alloc_handle)) { - ion_unmap_kernel(ddl_context->video_ion_client, - addr->alloc_handle); - if (!res_trk_check_for_sec_session()) { - ion_unmap_iommu(ddl_context->video_ion_client, - addr->alloc_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(ddl_context->video_ion_client, - addr->alloc_handle); - } - } - memset(addr, 0, sizeof(struct ddl_buf_addr)); -} - -#ifdef DDL_BUF_LOG - -static void ddl_print_buffer(struct ddl_context *ddl_context, - struct ddl_buf_addr *buf, u32 idx, u8 *str) -{ - struct ddl_buf_addr *base_ram; - s32 offset; - size_t sz, KB = 0; - - base_ram = &ddl_context->dram_base_a; - offset = (s32) DDL_ADDR_OFFSET(*base_ram, *buf); - sz = buf->buffer_size; - if (sz > 0) { - if (!(sz % 1024)) { - sz /= 1024; - KB++; - if (!(sz % 1024)) { - sz /= 1024; - KB++; - } - } - } - DDL_MSG_LOW("\n%12s [%2d]: 0x%08x [0x%04x], 0x%08x(%d%s), %s", - str, idx, (u32) buf->align_physical_addr, - (offset > 0) ? offset : 0, buf->buffer_size, sz, - ((2 == KB) ? "MB" : (1 == KB) ? "KB" : ""), - (((u32) buf->virtual_base_addr) ? "Alloc" : "")); -} - -static void ddl_print_port(struct ddl_context *ddl_context, - struct ddl_buf_addr *buf) -{ - struct ddl_buf_addr *a = &ddl_context->dram_base_a; - struct ddl_buf_addr *b = &ddl_context->dram_base_b; - - if (!buf->align_physical_addr || !buf->buffer_size) - return; - if (buf->align_physical_addr >= a->align_physical_addr && - buf->align_physical_addr + buf->buffer_size <= - a->align_physical_addr + a->buffer_size) - DDL_MSG_LOW(" -A [0x%x]-", DDL_ADDR_OFFSET(*a, *buf)); - else if (buf->align_physical_addr >= b->align_physical_addr && - buf->align_physical_addr + buf->buffer_size <= - b->align_physical_addr + b->buffer_size) - DDL_MSG_LOW(" -B [0x%x]-", DDL_ADDR_OFFSET(*b, *buf)); - else - DDL_MSG_LOW(" -?-"); -} - -static void ddl_print_buffer_port(struct ddl_context *ddl_context, - struct ddl_buf_addr *buf, u32 idx, u8 *str) -{ - DDL_MSG_LOW("\n"); - ddl_print_buffer(ddl_context, buf, idx, str); - ddl_print_port(ddl_context, buf); -} - -void ddl_list_buffers(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context; - u32 i; - - ddl_context = ddl->ddl_context; - DDL_MSG_LOW("\n\n"); - DDL_MSG_LOW("\n Buffer : Start [offs], Size \ - (Size), Alloc/Port"); - DDL_MSG_LOW("\n-------------------------------------------------------\ - -------------------------"); - ddl_print_buffer(ddl_context, &ddl_context->dram_base_a, 0, - "dram_base_a"); - ddl_print_buffer(ddl_context, &ddl_context->dram_base_b, 0, - "dram_base_b"); - if (ddl->codec_data.hdr.decoding) { - struct ddl_dec_buffers *dec_bufs = - &ddl->codec_data.decoder.hw_bufs; - for (i = 0; i < 32; i++) - ddl_print_buffer_port(ddl_context, - &dec_bufs->h264Mv[i], i, "h264Mv"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->h264Vert_nb_mv, 0, "h264Vert_nb_mv"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->h264Nb_ip, 0, "h264Nb_ip"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->nb_dcac, 0, "nb_dcac"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->upnb_mv, 0, "upnb_mv"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->sub_anchor_mv, 0, "sub_anchor_mv"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->overlay_xform, 0, "overlay_xform"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->bit_plane3, 0, "bit_plane3"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->bit_plane2, 0, "bit_plane2"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->bit_plane1, 0, "bit_plane1"); - ddl_print_buffer_port(ddl_context, - dec_bufs->stx_parser, 0, "stx_parser"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->desc, 0, "desc"); - ddl_print_buffer_port(ddl_context, - &dec_bufs->context, 0, "context"); - } else { - struct ddl_enc_buffers *enc_bufs = - &ddl->codec_data.encoder.hw_bufs; - - for (i = 0; i < 4; i++) - ddl_print_buffer_port(ddl_context, - &enc_bufs->dpb_y[i], i, "dpb_y"); - for (i = 0; i < 4; i++) - ddl_print_buffer_port(ddl_context, - &enc_bufs->dpb_c[i], i, "dpb_c"); - ddl_print_buffer_port(ddl_context, &enc_bufs->mv, 0, "mv"); - ddl_print_buffer_port(ddl_context, - &enc_bufs->col_zero, 0, "col_zero"); - ddl_print_buffer_port(ddl_context, &enc_bufs->md, 0, "md"); - ddl_print_buffer_port(ddl_context, - &enc_bufs->pred, 0, "pred"); - ddl_print_buffer_port(ddl_context, - &enc_bufs->nbor_info, 0, "nbor_info"); - ddl_print_buffer_port(ddl_context, - &enc_bufs->acdc_coef, 0, "acdc_coef"); - ddl_print_buffer_port(ddl_context, - &enc_bufs->context, 0, "context"); - } -} -#endif - -u32 ddl_fw_init(struct ddl_buf_addr *dram_base) -{ - u8 *dest_addr; - dest_addr = DDL_GET_ALIGNED_VITUAL(*dram_base); - DDL_MSG_LOW("FW Addr / FW Size : %x/%d", (u32)vidc_video_codec_fw, - vidc_video_codec_fw_size); - if (res_trk_check_for_sec_session() && res_trk_is_cp_enabled()) { - if (res_trk_enable_footswitch()) { - pr_err("Failed to enable footswitch"); - return false; - } - if (res_trk_enable_iommu_clocks()) { - res_trk_disable_footswitch(); - pr_err("Failed to enable iommu clocks\n"); - return false; - } - dram_base->pil_cookie = subsystem_get("vidc"); - if (res_trk_disable_iommu_clocks()) - pr_err("Failed to disable iommu clocks\n"); - if (IS_ERR_OR_NULL(dram_base->pil_cookie)) { - res_trk_disable_footswitch(); - pr_err("subsystem_get failed\n"); - return false; - } - } else { - if (vidc_video_codec_fw_size > dram_base->buffer_size || - !vidc_video_codec_fw) - return false; - memcpy(dest_addr, vidc_video_codec_fw, - vidc_video_codec_fw_size); - } - return true; -} - -void ddl_fw_release(struct ddl_buf_addr *dram_base) -{ - void *cookie = dram_base->pil_cookie; - if (res_trk_is_cp_enabled() && - res_trk_check_for_sec_session()) { - res_trk_close_secure_session(); - if (IS_ERR_OR_NULL(cookie)) { - pr_err("Invalid params"); - return; - } - if (res_trk_enable_footswitch()) { - pr_err("Failed to enable footswitch"); - return; - } - if (res_trk_enable_iommu_clocks()) { - res_trk_disable_footswitch(); - pr_err("Failed to enable iommu clocks\n"); - return; - } - subsystem_put(cookie); - if (res_trk_disable_iommu_clocks()) - pr_err("Failed to disable iommu clocks\n"); - if (res_trk_disable_footswitch()) - pr_err("Failed to disable footswitch\n"); - } else { - if (res_trk_check_for_sec_session()) - res_trk_close_secure_session(); - res_trk_release_fw_addr(); - } -} - -void ddl_set_core_start_time(const char *func_name, u32 index) -{ - u32 act_time; - struct timeval ddl_tv; - struct time_data *time_data = &proc_time[index]; - do_gettimeofday(&ddl_tv); - act_time = (ddl_tv.tv_sec * 1000) + (ddl_tv.tv_usec / 1000); - if (!time_data->ddl_t1) { - time_data->ddl_t1 = act_time; - DDL_MSG_LOW("\n%s(): Start Time (%u)", func_name, act_time); - } else if (vidc_msg_timing) { - DDL_MSG_LOW("\n%s(): Timer already started! St(%u) Act(%u)", - func_name, time_data->ddl_t1, act_time); - } -} - -void ddl_calc_core_proc_time(const char *func_name, u32 index, - struct ddl_client_context *ddl) -{ - struct time_data *time_data = &proc_time[index]; - struct ddl_decoder_data *decoder = NULL; - if (time_data->ddl_t1) { - int ddl_t2; - struct timeval ddl_tv; - do_gettimeofday(&ddl_tv); - ddl_t2 = (ddl_tv.tv_sec * 1000) + (ddl_tv.tv_usec / 1000); - time_data->ddl_ttotal += (ddl_t2 - time_data->ddl_t1); - time_data->ddl_count++; - if (vidc_msg_timing) { - DDL_MSG_TIME("\n%s(): cnt(%u) End Time (%u)" - "Diff(%u) Avg(%u)", - func_name, time_data->ddl_count, ddl_t2, - ddl_t2 - time_data->ddl_t1, - time_data->ddl_ttotal/time_data->ddl_count); - } - if ((index == DEC_OP_TIME) && (time_data->ddl_count > 2) && - (time_data->ddl_count < 6)) { - decoder = &(ddl->codec_data.decoder); - decoder->dec_time_sum = decoder->dec_time_sum + - ddl_t2 - time_data->ddl_t1; - if (time_data->ddl_count == 5) - decoder->avg_dec_time = - decoder->dec_time_sum / 3; - } - time_data->ddl_t1 = 0; - } -} - -void ddl_calc_core_proc_time_cnt(const char *func_name, u32 index, u32 count) -{ - struct time_data *time_data = &proc_time[index]; - if (time_data->ddl_t1) { - int ddl_t2; - struct timeval ddl_tv; - do_gettimeofday(&ddl_tv); - ddl_t2 = (ddl_tv.tv_sec * 1000) + (ddl_tv.tv_usec / 1000); - time_data->ddl_ttotal += (ddl_t2 - time_data->ddl_t1); - time_data->ddl_count += count; - DDL_MSG_TIME("\n%s(): cnt(%u) End Time (%u) Diff(%u) Avg(%u)", - func_name, time_data->ddl_count, ddl_t2, - ddl_t2 - time_data->ddl_t1, - time_data->ddl_ttotal/time_data->ddl_count); - time_data->ddl_t1 = 0; - } -} - -void ddl_update_core_start_time(const char *func_name, u32 index) -{ - u32 act_time; - struct timeval ddl_tv; - struct time_data *time_data = &proc_time[index]; - do_gettimeofday(&ddl_tv); - act_time = (ddl_tv.tv_sec * 1000) + (ddl_tv.tv_usec / 1000); - time_data->ddl_t1 = act_time; - DDL_MSG_LOW("\n%s(): Start time updated Act(%u)", - func_name, act_time); -} - -void ddl_reset_core_time_variables(u32 index) -{ - proc_time[index].ddl_t1 = 0; - proc_time[index].ddl_ttotal = 0; - proc_time[index].ddl_count = 0; -} - -int ddl_get_core_decode_proc_time(u32 *ddl_handle) -{ - int avg_time = 0; - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - avg_time = ddl_vidc_decode_get_avg_time(ddl); - return avg_time; -} - -void ddl_reset_avg_dec_time(u32 *ddl_handle) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *) ddl_handle; - ddl_vidc_decode_reset_avg_time(ddl); -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.h b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.h deleted file mode 100644 index 1792510634cd5aba6db0c485a0f33e894fd9dbbb..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_utils.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DDL_UTILS_H_ -#define _VCD_DDL_UTILS_H_ - -#include -#include - -extern u32 vidc_msg_pmem; -extern u32 vidc_msg_timing; - -enum timing_data { - DEC_OP_TIME, - DEC_IP_TIME, - ENC_OP_TIME, - ENC_SLICE_OP_TIME, - MAX_TIME_DATA -}; - -#define DBG_PMEM(x...) \ -do { \ - if (vidc_msg_pmem) \ - printk(KERN_DEBUG x); \ -} while (0) - -#if DDL_MSG_LOG -#define DDL_MSG_LOW(x...) printk(KERN_INFO x) -#define DDL_MSG_MED(x...) printk(KERN_INFO x) -#define DDL_MSG_HIGH(x...) printk(KERN_INFO x) -#define DDL_MSG_ERROR(x...) printk(KERN_INFO x) -#else -#define DDL_MSG_LOW(x...) -#define DDL_MSG_MED(x...) -#define DDL_MSG_HIGH(x...) -#define DDL_MSG_ERROR(x...) -#endif - - -#define DDL_MSG_FATAL(x...) printk(KERN_INFO x) - -#define DDL_ALIGN_SIZE(sz, guard_bytes, align_mask) \ - (((u32)(sz) + guard_bytes) & align_mask) -#define DDL_ADDR_IS_ALIGNED(addr, align_bytes) \ - (!((u32)(addr) & ((align_bytes) - 1))) -#define DDL_ALIGN(val, grid) ((!(grid)) ? (val) : \ - ((((val) + (grid) - 1) / (grid)) * (grid))) -#define DDL_ALIGN_FLOOR(val, grid) ((!(grid)) ? (val) : \ - (((val) / (grid)) * (grid))) -#define DDL_OFFSET(base, addr) ((!(addr)) ? 0 : (u32)((u8 *) \ - (addr) - (u8 *) (base))) -#define DDL_ADDR_OFFSET(base, addr) DDL_OFFSET((base).align_physical_addr, \ - (addr).align_physical_addr) -#define DDL_GET_ALIGNED_VITUAL(x) ((x).align_virtual_addr) -#define DDL_KILO_BYTE(x) ((x)*1024) -#define DDL_MEGA_BYTE(x) ((x)*1024*1024) -#define DDL_FRAMERATE_SCALE_FACTOR (1000) -#define DDL_FRAMERATE_SCALE(x) ((x) * DDL_FRAMERATE_SCALE_FACTOR) - -#define DDL_MIN(x, y) ((x < y) ? x : y) -#define DDL_MAX(x, y) ((x > y) ? x : y) -#define DDL_MEMCPY(dest, src, len) memcpy((dest), (src), (len)) -#define DDL_MEMSET(src, value, len) memset((src), (value), (len)) - -void ddl_set_core_start_time(const char *func_name, u32 index); -void ddl_reset_core_time_variables(u32 index); -void ddl_calc_core_proc_time_cnt(const char *func_name, u32 index, u32 count); -void ddl_update_core_start_time(const char *func_name, u32 index); -int ddl_get_core_decode_proc_time(u32 *ddl_handle); -void ddl_reset_avg_dec_time(u32 *ddl_handle); -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_vidc.c b/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_vidc.c deleted file mode 100644 index 52ad4aadbb5ca824de364c6ab0a0ddb3a03a3667..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vcd_ddl_vidc.c +++ /dev/null @@ -1,1238 +0,0 @@ -/* Copyright (c) 2010-2012, 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 "vcd_ddl.h" -#include "vcd_ddl_metadata.h" -#include "vcd_ddl_shared_mem.h" -#include "vcd_core.h" -#include "vcd_res_tracker_api.h" - -#if defined(PIX_CACHE_DISABLE) -#define DDL_PIX_CACHE_ENABLE false -#else -#define DDL_PIX_CACHE_ENABLE true -#endif -static unsigned int run_cnt; - -void ddl_vidc_core_init(struct ddl_context *ddl_context) -{ - struct vidc_1080P_pix_cache_config pixel_cache_config; - - vidc_1080p_do_sw_reset(VIDC_1080P_RESET_IN_SEQ_FIRST_STAGE); - msleep(DDL_SW_RESET_SLEEP); - vidc_1080p_do_sw_reset(VIDC_1080P_RESET_IN_SEQ_SECOND_STAGE); - vidc_1080p_init_memory_controller( - (u32) ddl_context->dram_base_a.align_physical_addr, - (u32) ddl_context->dram_base_b.align_physical_addr); - vidc_1080p_clear_returned_channel_inst_id(); - ddl_context->vidc_decode_seq_start[0] = - vidc_1080p_decode_seq_start_ch0; - ddl_context->vidc_decode_seq_start[1] = - vidc_1080p_decode_seq_start_ch1; - ddl_context->vidc_decode_init_buffers[0] = - vidc_1080p_decode_init_buffers_ch0; - ddl_context->vidc_decode_init_buffers[1] = - vidc_1080p_decode_init_buffers_ch1; - ddl_context->vidc_decode_frame_start[0] = - vidc_1080p_decode_frame_start_ch0; - ddl_context->vidc_decode_frame_start[1] = - vidc_1080p_decode_frame_start_ch1; - ddl_context->vidc_set_dec_resolution[0] = - vidc_1080p_set_dec_resolution_ch0; - ddl_context->vidc_set_dec_resolution[1] = - vidc_1080p_set_dec_resolution_ch1; - ddl_context->vidc_encode_seq_start[0] = - vidc_1080p_encode_seq_start_ch0; - ddl_context->vidc_encode_seq_start[1] = - vidc_1080p_encode_seq_start_ch1; - ddl_context->vidc_encode_frame_start[0] = - vidc_1080p_encode_frame_start_ch0; - ddl_context->vidc_encode_frame_start[1] = - vidc_1080p_encode_frame_start_ch1; - ddl_context->vidc_encode_slice_batch_start[0] = - vidc_1080p_encode_slice_batch_start_ch0; - ddl_context->vidc_encode_slice_batch_start[1] = - vidc_1080p_encode_slice_batch_start_ch1; - vidc_1080p_release_sw_reset(); - ddl_context->pix_cache_enable = DDL_PIX_CACHE_ENABLE; - if (ddl_context->pix_cache_enable) { - vidc_pix_cache_sw_reset(); - pixel_cache_config.cache_enable = true; - pixel_cache_config.prefetch_en = true; - pixel_cache_config.port_select = VIDC_1080P_PIX_CACHE_PORT_B; - pixel_cache_config.statistics_off = true; - pixel_cache_config.page_size = - VIDC_1080P_PIX_CACHE_PAGE_SIZE_1K; - vidc_pix_cache_init_config(&pixel_cache_config); - } -} - -void ddl_vidc_core_term(struct ddl_context *ddl_context) -{ - if (ddl_context->pix_cache_enable) { - u32 pix_cache_idle = false; - u32 counter = 0; - - vidc_pix_cache_set_halt(true); - - do { - msleep(DDL_SW_RESET_SLEEP); - vidc_pix_cache_get_status_idle(&pix_cache_idle); - counter++; - } while (!pix_cache_idle && - counter < DDL_PIXEL_CACHE_STATUS_READ_RETRY); - - if (!pix_cache_idle) { - ddl_context->cmd_err_status = - DDL_PIXEL_CACHE_NOT_IDLE; - ddl_handle_core_errors(ddl_context); - } - } -} - -void ddl_vidc_channel_set(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - enum vcd_codec *vcd_codec; - enum vidc_1080p_codec codec = VIDC_1080P_H264_DECODE; - const enum vidc_1080p_decode_p_cache_enable - dec_pix_cache = VIDC_1080P_DECODE_PCACHE_DISABLE; - const enum vidc_1080p_encode_p_cache_enable - enc_pix_cache = VIDC_1080P_ENCODE_PCACHE_ENABLE; - u32 pix_cache_ctrl, ctxt_mem_offset, ctxt_mem_size, arg1 = 0; - u8 *hw_ctxt = NULL; - - if (ddl->decoding) { - ddl_set_core_start_time(__func__, DEC_OP_TIME); - vcd_codec = &(ddl->codec_data.decoder.codec.codec); - pix_cache_ctrl = (u32)dec_pix_cache; - ctxt_mem_offset = DDL_ADDR_OFFSET(ddl_context->dram_base_a, - ddl->codec_data.decoder.hw_bufs.context) >> 11; - hw_ctxt = - ddl->codec_data.decoder.hw_bufs.context.virtual_base_addr; - ctxt_mem_size = - ddl->codec_data.decoder.hw_bufs.context.buffer_size; - } else { - vcd_codec = &(ddl->codec_data.encoder.codec.codec); - pix_cache_ctrl = (u32)enc_pix_cache; - ctxt_mem_offset = DDL_ADDR_OFFSET(ddl_context->dram_base_a, - ddl->codec_data.encoder.hw_bufs.context) >> 11; - hw_ctxt = - ddl->codec_data.encoder.hw_bufs.context.virtual_base_addr; - ctxt_mem_size = - ddl->codec_data.encoder.hw_bufs.context.buffer_size; - } - if (!res_trk_check_for_sec_session() && hw_ctxt) { - memset(hw_ctxt, 0, ctxt_mem_size); - arg1 = 1 << 29; - } - switch (*vcd_codec) { - default: - case VCD_CODEC_MPEG4: - if (ddl->decoding) - codec = VIDC_1080P_MPEG4_DECODE; - else - codec = VIDC_1080P_MPEG4_ENCODE; - break; - case VCD_CODEC_H264: - if (ddl->decoding) - codec = VIDC_1080P_H264_DECODE; - else - codec = VIDC_1080P_H264_ENCODE; - break; - case VCD_CODEC_DIVX_3: - if (ddl->decoding) - codec = VIDC_1080P_DIVX311_DECODE; - break; - case VCD_CODEC_DIVX_4: - if (ddl->decoding) - codec = VIDC_1080P_DIVX412_DECODE; - break; - case VCD_CODEC_DIVX_5: - if (ddl->decoding) - codec = VIDC_1080P_DIVX502_DECODE; - break; - case VCD_CODEC_DIVX_6: - if (ddl->decoding) - codec = VIDC_1080P_DIVX503_DECODE; - break; - case VCD_CODEC_XVID: - if (ddl->decoding) - codec = VIDC_1080P_MPEG4_DECODE; - break; - case VCD_CODEC_H263: - if (ddl->decoding) - codec = VIDC_1080P_H263_DECODE; - else - codec = VIDC_1080P_H263_ENCODE; - break; - case VCD_CODEC_MPEG1: - case VCD_CODEC_MPEG2: - if (ddl->decoding) - codec = VIDC_1080P_MPEG2_DECODE; - break; - case VCD_CODEC_VC1: - if (ddl->decoding) - codec = VIDC_1080P_VC1_DECODE; - break; - case VCD_CODEC_VC1_RCV: - if (ddl->decoding) - codec = VIDC_1080P_VC1_RCV_DECODE; - break; - } - ddl->cmd_state = DDL_CMD_CHANNEL_SET; - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_WAIT_FOR_CHDONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_CHDONE; - arg1 |= (u32)codec; - vidc_1080p_set_host2risc_cmd(VIDC_1080P_HOST2RISC_CMD_OPEN_CH, - arg1, pix_cache_ctrl, ctxt_mem_offset, - ctxt_mem_size); -} - -void ddl_vidc_decode_init_codec(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vidc_1080p_dec_seq_start_param seq_start_param; - u32 seq_size; - - ddl_set_core_start_time(__func__, DEC_OP_TIME); - vidc_1080p_set_decode_mpeg4_pp_filter(decoder->post_filter.post_filter); - vidc_sm_set_concealment_color(&ddl->shared_mem[ddl->command_channel], - DDL_CONCEALMENT_Y_COLOR, DDL_CONCEALMENT_C_COLOR); - - vidc_sm_set_error_concealment_config( - &ddl->shared_mem[ddl->command_channel], - VIDC_SM_ERR_CONCEALMENT_INTER_SLICE_MB_COPY, - VIDC_SM_ERR_CONCEALMENT_INTRA_SLICE_COLOR_CONCEALMENT, - VIDC_SM_ERR_CONCEALMENT_ENABLE); - - ddl_vidc_metadata_enable(ddl); - vidc_sm_set_metadata_start_address(&ddl->shared_mem - [ddl->command_channel], - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - ddl->codec_data.decoder.meta_data_input)); - - vidc_sm_set_idr_decode_only(&ddl->shared_mem[ddl->command_channel], - decoder->idr_only_decoding); - - if ((decoder->codec.codec == VCD_CODEC_DIVX_3) || - (decoder->codec.codec == VCD_CODEC_VC1_RCV || - decoder->codec.codec == VCD_CODEC_VC1)) - ddl_context->vidc_set_dec_resolution - [ddl->command_channel](decoder->client_frame_size.width, - decoder->client_frame_size.height); - else - ddl_context->vidc_set_dec_resolution - [ddl->command_channel](0x0, 0x0); - DDL_MSG_LOW("HEADER-PARSE-START"); - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_INITCODECDONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_INITCODECDONE; - ddl->cmd_state = DDL_CMD_HEADER_PARSE; - seq_start_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - seq_start_param.inst_id = ddl->instance_id; - seq_start_param.shared_mem_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, ddl->shared_mem - [ddl->command_channel]); - seq_start_param.stream_buffer_addr_offset = - DDL_OFFSET(ddl_context->dram_base_a.align_physical_addr, - decoder->decode_config.sequence_header); - seq_start_param.stream_buffersize = - decoder->client_input_buf_req.sz; - seq_size = decoder->decode_config.sequence_header_len + - DDL_LINEAR_BUFFER_ALIGN_BYTES + VCD_SEQ_HDR_PADDING_BYTES; - if (seq_start_param.stream_buffersize < seq_size) - seq_start_param.stream_buffersize = seq_size; - seq_start_param.stream_frame_size = - decoder->decode_config.sequence_header_len; - seq_start_param.descriptor_buffer_addr_offset = - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - decoder->hw_bufs.desc), - seq_start_param.descriptor_buffer_size = - decoder->hw_bufs.desc.buffer_size; - if ((decoder->codec.codec == VCD_CODEC_MPEG4) || - (decoder->codec.codec == VCD_CODEC_DIVX_4) || - (decoder->codec.codec == VCD_CODEC_DIVX_5) || - (decoder->codec.codec == VCD_CODEC_DIVX_6) || - (decoder->codec.codec == VCD_CODEC_XVID)) - vidc_sm_set_mpeg4_profile_override( - &ddl->shared_mem[ddl->command_channel], - VIDC_SM_PROFILE_INFO_ASP); - if (VCD_CODEC_MPEG2 == decoder->codec.codec) - vidc_sm_set_mp2datadumpbuffer( - &ddl->shared_mem[ddl->command_channel], - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - ddl->codec_data.decoder.hw_bufs.extnuserdata), - DDL_KILO_BYTE(2)); - if (VCD_CODEC_H264 == decoder->codec.codec) - vidc_sm_set_decoder_sei_enable( - &ddl->shared_mem[ddl->command_channel], - VIDC_SM_RECOVERY_POINT_SEI); - ddl_context->vidc_decode_seq_start[ddl->command_channel]( - &seq_start_param); - - vidc_sm_set_decoder_stuff_bytes_consumption( - &ddl->shared_mem[ddl->command_channel], - VIDC_SM_NUM_STUFF_BYTES_CONSUME_NONE); -} - -void ddl_vidc_decode_dynamic_property(struct ddl_client_context *ddl, - u32 enable) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vcd_frame_data *bit_stream = - &(ddl->input_frame.vcd_frm); - struct ddl_context *ddl_context = ddl->ddl_context; - - if (!enable) { - if (decoder->dynmic_prop_change_req) - decoder->dynmic_prop_change_req = false; - return; - } - if ((decoder->dynamic_prop_change & DDL_DEC_REQ_OUTPUT_FLUSH)) { - decoder->dynmic_prop_change_req = true; - decoder->dynamic_prop_change &= ~(DDL_DEC_REQ_OUTPUT_FLUSH); - decoder->dpb_mask.hw_mask = 0; - decoder->flush_pending = true; - } - if (((decoder->meta_data_enable_flag & VCD_METADATA_PASSTHROUGH)) && - ((VCD_FRAME_FLAG_EXTRADATA & bit_stream->flags))) { - u32 extradata_presence = true; - u8* tmp = ((u8 *) bit_stream->physical + - bit_stream->offset + - bit_stream->data_len + 3); - u32 extra_data_start = (u32) ((u32)tmp & ~3); - - extra_data_start = extra_data_start - - (u32)ddl_context->dram_base_a.align_physical_addr; - decoder->dynmic_prop_change_req = true; - vidc_sm_set_extradata_addr(&ddl->shared_mem - [ddl->command_channel], extra_data_start); - vidc_sm_set_extradata_presence(&ddl->shared_mem - [ddl->command_channel], extradata_presence); - } -} - -void ddl_vidc_encode_dynamic_property(struct ddl_client_context *ddl, - u32 enable) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - u32 frame_rate_change = false, bit_rate_change = false; - u32 reset_req = false; - - if (!enable) { - if (encoder->dynmic_prop_change_req) { - reset_req = true; - encoder->dynmic_prop_change_req = false; - } - } else { - if ((encoder->dynamic_prop_change & DDL_ENC_REQ_IFRAME)) { - encoder->intra_frame_insertion = true; - encoder->dynamic_prop_change &= - ~(DDL_ENC_REQ_IFRAME); - } - if (encoder->dynamic_prop_change & DDL_ENC_LTR_USE_FRAME) { - if (encoder->ltr_control.callback_reqd) { - DDL_MSG_ERROR("%s: LTR use failed", __func__); - ddl_encoder_use_ltr_fail_callback(ddl); - encoder->ltr_control.callback_reqd = false; - } else { - encoder->ltr_control.use_ltr_reqd = true; - } - encoder->dynamic_prop_change &= - ~(DDL_ENC_LTR_USE_FRAME); - } - if ((encoder->dynamic_prop_change & - DDL_ENC_CHANGE_BITRATE)) { - bit_rate_change = true; - vidc_sm_set_encoder_new_bit_rate( - &ddl->shared_mem[ddl->command_channel], - encoder->target_bit_rate.target_bitrate); - encoder->dynamic_prop_change &= - ~(DDL_ENC_CHANGE_BITRATE); - } - if ((encoder->dynamic_prop_change - & DDL_ENC_CHANGE_IPERIOD)) { - encoder->intra_period_changed = true; - vidc_sm_set_encoder_new_i_period( - &ddl->shared_mem[ddl->command_channel], - encoder->i_period.p_frames); - encoder->dynamic_prop_change &= - ~(DDL_ENC_CHANGE_IPERIOD); - } - if ((encoder->dynamic_prop_change - & DDL_ENC_CHANGE_FRAMERATE)) { - frame_rate_change = true; - vidc_sm_set_encoder_new_frame_rate( - &ddl->shared_mem[ddl->command_channel], - (u32)(DDL_FRAMERATE_SCALE(encoder->\ - frame_rate.fps_numerator) / - encoder->frame_rate.fps_denominator)); - if (encoder->vui_timinginfo_enable && - encoder->frame_rate.fps_denominator) { - vidc_sm_set_h264_encoder_timing_info( - &ddl->shared_mem[ddl->command_channel], - DDL_FRAMERATE_SCALE_FACTOR, - (u32)(DDL_FRAMERATE_SCALE(encoder->\ - frame_rate.fps_numerator) / encoder->\ - frame_rate.fps_denominator) << 1); - } - encoder->dynamic_prop_change &= - ~(DDL_ENC_CHANGE_FRAMERATE); - } - } - if ((enable) || (reset_req)) { - vidc_sm_set_encoder_param_change( - &ddl->shared_mem[ddl->command_channel], - bit_rate_change, frame_rate_change, - encoder->intra_period_changed); - } -} - -static void ddl_vidc_encode_set_profile_level( - struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - u32 encode_profile, level = 0; - - switch (encoder->profile.profile) { - default: - case VCD_PROFILE_MPEG4_SP: - encode_profile = VIDC_1080P_PROFILE_MPEG4_SIMPLE; - break; - case VCD_PROFILE_MPEG4_ASP: - encode_profile = VIDC_1080P_PROFILE_MPEG4_ADV_SIMPLE; - break; - case VCD_PROFILE_H264_BASELINE: - encode_profile = VIDC_1080P_PROFILE_H264_CONSTRAINED_BASELINE; - break; - case VCD_PROFILE_H264_MAIN: - encode_profile = VIDC_1080P_PROFILE_H264_MAIN; - break; - case VCD_PROFILE_H264_HIGH: - encode_profile = VIDC_1080P_PROFILE_H264_HIGH; - break; - } - switch (encoder->level.level) { - default: - case VCD_LEVEL_MPEG4_0: - level = VIDC_1080P_MPEG4_LEVEL0; - break; - case VCD_LEVEL_MPEG4_0b: - level = VIDC_1080P_MPEG4_LEVEL0b; - break; - case VCD_LEVEL_MPEG4_1: - level = VIDC_1080P_MPEG4_LEVEL1; - break; - case VCD_LEVEL_MPEG4_2: - level = VIDC_1080P_MPEG4_LEVEL2; - break; - case VCD_LEVEL_MPEG4_3: - level = VIDC_1080P_MPEG4_LEVEL3; - break; - case VCD_LEVEL_MPEG4_3b: - level = VIDC_1080P_MPEG4_LEVEL3b; - break; - case VCD_LEVEL_MPEG4_4: - level = VIDC_1080P_MPEG4_LEVEL4; - break; - case VCD_LEVEL_MPEG4_4a: - level = VIDC_1080P_MPEG4_LEVEL4a; - break; - case VCD_LEVEL_MPEG4_5: - level = VIDC_1080P_MPEG4_LEVEL5; - break; - case VCD_LEVEL_MPEG4_6: - level = VIDC_1080P_MPEG4_LEVEL6; - break; - case VCD_LEVEL_MPEG4_7: - level = VIDC_1080P_MPEG4_LEVEL7; - break; - case VCD_LEVEL_H264_1: - level = VIDC_1080P_H264_LEVEL1; - break; - case VCD_LEVEL_H264_1b: - level = VIDC_1080P_H264_LEVEL1b; - break; - case VCD_LEVEL_H264_1p1: - level = VIDC_1080P_H264_LEVEL1p1; - break; - case VCD_LEVEL_H264_1p2: - level = VIDC_1080P_H264_LEVEL1p2; - break; - case VCD_LEVEL_H264_1p3: - level = VIDC_1080P_H264_LEVEL1p3; - break; - case VCD_LEVEL_H264_2: - level = VIDC_1080P_H264_LEVEL2; - break; - case VCD_LEVEL_H264_2p1: - level = VIDC_1080P_H264_LEVEL2p1; - break; - case VCD_LEVEL_H264_2p2: - level = VIDC_1080P_H264_LEVEL2p2; - break; - case VCD_LEVEL_H264_3: - level = VIDC_1080P_H264_LEVEL3; - break; - case VCD_LEVEL_H264_3p1: - level = VIDC_1080P_H264_LEVEL3p1; - break; - case VCD_LEVEL_H264_3p2: - level = VIDC_1080P_H264_LEVEL3p2; - break; - case VCD_LEVEL_H264_4: - level = VIDC_1080P_H264_LEVEL4; - break; - case VCD_LEVEL_H263_10: - level = VIDC_1080P_H263_LEVEL10; - break; - case VCD_LEVEL_H263_20: - level = VIDC_1080P_H263_LEVEL20; - break; - case VCD_LEVEL_H263_30: - level = VIDC_1080P_H263_LEVEL30; - break; - case VCD_LEVEL_H263_40: - level = VIDC_1080P_H263_LEVEL40; - break; - case VCD_LEVEL_H263_45: - level = VIDC_1080P_H263_LEVEL45; - break; - case VCD_LEVEL_H263_50: - level = VIDC_1080P_H263_LEVEL50; - break; - case VCD_LEVEL_H263_60: - level = VIDC_1080P_H263_LEVEL60; - break; - case VCD_LEVEL_H263_70: - level = VIDC_1080P_H263_LEVEL70; - break; - } - vidc_1080p_set_encode_profile_level(encode_profile, level); -} - -static void ddl_vidc_encode_set_multi_slice_info( - struct ddl_encoder_data *encoder) -{ - enum vidc_1080p_MSlice_selection m_slice_sel; - u32 i_multi_slice_size = 0, i_multi_slice_byte = 0; - - if (!encoder) { - DDL_MSG_ERROR("Invalid Parameter"); - return; - } - - switch (encoder->multi_slice.m_slice_sel) { - default: - case VCD_MSLICE_OFF: - m_slice_sel = VIDC_1080P_MSLICE_DISABLE; - break; - case VCD_MSLICE_BY_GOB: - case VCD_MSLICE_BY_MB_COUNT: - m_slice_sel = VIDC_1080P_MSLICE_BY_MB_COUNT; - i_multi_slice_size = encoder->multi_slice.m_slice_size; - break; - case VCD_MSLICE_BY_BYTE_COUNT: - m_slice_sel = VIDC_1080P_MSLICE_BY_BYTE_COUNT; - i_multi_slice_byte = encoder->multi_slice.m_slice_size; - break; - } - vidc_1080p_set_encode_multi_slice_control(m_slice_sel, - i_multi_slice_size, i_multi_slice_byte); -} - -static void ddl_vidc_encode_set_batch_slice_info( - struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - DDL_MSG_LOW("%s\n", __func__); - encoder->batch_frame.slice_batch_out.buffer_size = - encoder->output_buf_req.sz; - DDL_MSG_LOW("encoder->batch_frame.slice_batch_out.buffer_size = %d\n", - encoder->batch_frame.slice_batch_out.buffer_size); - vidc_sm_set_encoder_batch_config( - &ddl->shared_mem[ddl->command_channel], - 1, - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - encoder->batch_frame.slice_batch_in), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - encoder->batch_frame.slice_batch_out), - encoder->batch_frame.slice_batch_out.buffer_size); - vidc_sm_set_encoder_slice_batch_int_ctrl( - &ddl->shared_mem[ddl->command_channel], - 0); -} - -void ddl_vidc_encode_init_codec(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct ddl_enc_buffers *enc_buffers = &encoder->hw_bufs; - struct vidc_1080p_enc_seq_start_param seq_start_param; - enum vidc_1080p_memory_access_method mem_access_method; - enum vidc_1080p_DBConfig db_config; - enum VIDC_SM_frame_skip r_cframe_skip = - VIDC_SM_FRAME_SKIP_DISABLE; - u32 index, luma[4], chroma[4], hdr_ext_control = false; - const u32 recon_bufs = 4; - u32 h263_cpfc_enable = false; - u32 scaled_frame_rate, ltr_enable; - - ddl_vidc_encode_set_profile_level(ddl); - vidc_1080p_set_encode_frame_size(encoder->frame_size.width, - encoder->frame_size.height); - vidc_1080p_encode_set_qp_params(encoder->qp_range.max_qp, - encoder->qp_range.min_qp); - vidc_1080p_encode_set_rc_config(encoder->rc_level.frame_level_rc, - encoder->rc_level.mb_level_rc, - encoder->session_qp.i_frame_qp); - if (encoder->hdr_ext_control > 0) - hdr_ext_control = true; - if (encoder->r_cframe_skip > 0) - r_cframe_skip = VIDC_SM_FRAME_SKIP_ENABLE_LEVEL; - scaled_frame_rate = DDL_FRAMERATE_SCALE(encoder->\ - frame_rate.fps_numerator) / - encoder->frame_rate.fps_denominator; - if ((encoder->codec.codec == VCD_CODEC_H263) && - (DDL_FRAMERATE_SCALE(DDL_INITIAL_FRAME_RATE) - != scaled_frame_rate) && encoder->plusptype_enable) - h263_cpfc_enable = true; - ltr_enable = DDL_IS_LTR_ENABLED(encoder); - DDL_MSG_HIGH("ltr_enable = %u", ltr_enable); - vidc_sm_set_extended_encoder_control(&ddl->shared_mem - [ddl->command_channel], hdr_ext_control, - r_cframe_skip, false, 0, - h263_cpfc_enable, encoder->sps_pps.sps_pps_for_idr_enable_flag, - encoder->closed_gop, encoder->avc_delimiter_enable, - encoder->vui_timinginfo_enable, ltr_enable); - if (encoder->vui_timinginfo_enable) { - vidc_sm_set_h264_encoder_timing_info( - &ddl->shared_mem[ddl->command_channel], - DDL_FRAMERATE_SCALE_FACTOR, - scaled_frame_rate << 1); - } - vidc_sm_set_encoder_init_rc_value(&ddl->shared_mem - [ddl->command_channel], - encoder->target_bit_rate.target_bitrate); - vidc_sm_set_encoder_hec_period(&ddl->shared_mem - [ddl->command_channel], encoder->hdr_ext_control); - vidc_sm_set_encoder_vop_time(&ddl->shared_mem - [ddl->command_channel], true, - encoder->vop_timing.vop_time_resolution, 0); - if (encoder->rc_level.frame_level_rc) - vidc_1080p_encode_set_frame_level_rc_params( - scaled_frame_rate, - encoder->target_bit_rate.target_bitrate, - encoder->frame_level_rc.reaction_coeff); - if (encoder->rc_level.mb_level_rc) - vidc_1080p_encode_set_mb_level_rc_params( - encoder->adaptive_rc.disable_dark_region_as_flag, - encoder->adaptive_rc.disable_smooth_region_as_flag, - encoder->adaptive_rc.disable_static_region_as_flag, - encoder->adaptive_rc.disable_activity_region_flag); - if ((!encoder->rc_level.frame_level_rc) && - (!encoder->rc_level.mb_level_rc)) - vidc_sm_set_pand_b_frame_qp( - &ddl->shared_mem[ddl->command_channel], - encoder->session_qp.b_frame_qp, - encoder->session_qp.p_frame_qp); - if (encoder->codec.codec == VCD_CODEC_MPEG4) { - vidc_1080p_set_mpeg4_encode_quarter_pel_control(false); - vidc_1080p_set_encode_field_picture_structure(false); - } - if (encoder->codec.codec == VCD_CODEC_H264) { - enum vidc_1080p_entropy_sel entropy_sel; - switch (encoder->entropy_control.entropy_sel) { - default: - case VCD_ENTROPY_SEL_CAVLC: - entropy_sel = VIDC_1080P_ENTROPY_SEL_CAVLC; - break; - case VCD_ENTROPY_SEL_CABAC: - entropy_sel = VIDC_1080P_ENTROPY_SEL_CABAC; - break; - } - vidc_1080p_set_h264_encode_entropy(entropy_sel); - switch (encoder->db_control.db_config) { - default: - case VCD_DB_ALL_BLOCKING_BOUNDARY: - db_config = VIDC_1080P_DB_ALL_BLOCKING_BOUNDARY; - break; - case VCD_DB_DISABLE: - db_config = VIDC_1080P_DB_DISABLE; - break; - case VCD_DB_SKIP_SLICE_BOUNDARY: - db_config = VIDC_1080P_DB_SKIP_SLICE_BOUNDARY; - break; - } - vidc_1080p_set_h264_encode_loop_filter(db_config, - encoder->db_control.slice_alpha_offset, - encoder->db_control.slice_beta_offset); - vidc_1080p_set_h264_encoder_p_frame_ref_count(encoder->\ - num_references_for_p_frame); - if (encoder->profile.profile == VCD_PROFILE_H264_HIGH) - vidc_1080p_set_h264_encode_8x8transform_control(true); - } - vidc_1080p_set_encode_picture(encoder->i_period.p_frames, - encoder->i_period.b_frames); - vidc_1080p_set_encode_circular_intra_refresh( - encoder->intra_refresh.cir_mb_number); - ddl_vidc_encode_set_multi_slice_info(encoder); - ddl_vidc_metadata_enable(ddl); - if (encoder->meta_data_enable_flag) - vidc_sm_set_metadata_start_address(&ddl->shared_mem - [ddl->command_channel], DDL_ADDR_OFFSET( - ddl_context->dram_base_a, - ddl->codec_data.encoder.meta_data_input)); - luma[0] = DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->dpb_y[0]); - luma[1] = DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->dpb_y[1]); - if (encoder->hw_bufs.dpb_count == DDL_ENC_MAX_DPB_BUFFERS) { - luma[2] = DDL_ADDR_OFFSET(ddl_context->dram_base_b, - enc_buffers->dpb_y[2]); - luma[3] = DDL_ADDR_OFFSET(ddl_context->dram_base_b, - enc_buffers->dpb_y[3]); - } - for (index = 0; index < recon_bufs; index++) - chroma[index] = DDL_ADDR_OFFSET(ddl_context->dram_base_b, - enc_buffers->dpb_c[index]); - vidc_1080p_set_encode_recon_buffers(recon_bufs, luma, chroma); - switch (encoder->codec.codec) { - case VCD_CODEC_MPEG4: - vidc_1080p_set_mpeg4_encode_work_buffers( - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->col_zero), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->acdc_coef), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->mv)); - break; - case VCD_CODEC_H263: - vidc_1080p_set_h263_encode_work_buffers( - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->acdc_coef)); - break; - case VCD_CODEC_H264: - vidc_1080p_set_h264_encode_work_buffers( - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->mv), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->col_zero), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->md), - DDL_ADDR_OFFSET(ddl_context->dram_base_b, - enc_buffers->pred), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->nbor_info), - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - enc_buffers->mb_info)); - break; - default: - break; - } - if (encoder->buf_format.buffer_format == - VCD_BUFFER_FORMAT_NV12_16M2KA) - mem_access_method = VIDC_1080P_TILE_LINEAR; - else - mem_access_method = VIDC_1080P_TILE_64x32; - vidc_1080p_set_encode_input_frame_format(mem_access_method); - vidc_1080p_set_encode_padding_control(0, 0, 0, 0); - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_INITCODECDONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_INITCODECDONE; - ddl->cmd_state = DDL_CMD_INIT_CODEC; - vidc_1080p_set_encode_field_picture_structure(false); - seq_start_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - seq_start_param.inst_id = ddl->instance_id; - seq_start_param.shared_mem_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, ddl->shared_mem - [ddl->command_channel]); - seq_start_param.stream_buffer_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, encoder->seq_header); - seq_start_param.stream_buffer_size = - encoder->seq_header.buffer_size; - encoder->seq_header_length = 0; - ddl_context->vidc_encode_seq_start[ddl->command_channel]( - &seq_start_param); -} - -void ddl_vidc_channel_end(struct ddl_client_context *ddl) -{ - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_WAIT_FOR_CHEND", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_CHEND; - ddl->cmd_state = DDL_CMD_CHANNEL_END; - vidc_1080p_set_host2risc_cmd(VIDC_1080P_HOST2RISC_CMD_CLOSE_CH, - ddl->instance_id, 0, 0, 0); -} - -void ddl_vidc_encode_frame_run(struct ddl_client_context *ddl) -{ - struct vidc_1080p_enc_frame_start_param enc_param; - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct ddl_enc_buffers *enc_buffers = &(encoder->hw_bufs); - struct vcd_frame_data *stream = &(ddl->output_frame.vcd_frm); - struct vcd_frame_data *input_vcd_frm = - &(ddl->input_frame.vcd_frm); - u32 dpb_addr_y[4], dpb_addr_c[4]; - u32 index, y_addr, c_addr; - - DDL_MSG_LOW("%s\n", __func__); - ddl_vidc_encode_set_metadata_output_buf(ddl); - - encoder->enc_frame_info.meta_data_exists = false; - - y_addr = DDL_OFFSET(ddl_context->dram_base_b.align_physical_addr, - input_vcd_frm->physical); - c_addr = (y_addr + encoder->input_buf_size.size_y); - if (input_vcd_frm->flags & VCD_FRAME_FLAG_EOS) { - enc_param.encode = VIDC_1080P_ENC_TYPE_LAST_FRAME_DATA; - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_EOS_DONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_EOS_DONE; - } else { - enc_param.encode = VIDC_1080P_ENC_TYPE_FRAME_DATA; - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_FRAME_DONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME_DONE; - } - ddl->cmd_state = DDL_CMD_ENCODE_FRAME; - if (encoder->dynamic_prop_change) { - encoder->dynmic_prop_change_req = true; - ddl_vidc_encode_dynamic_property(ddl, true); - } - if (DDL_IS_LTR_ENABLED(encoder)) - ddl_encoder_ltr_control(ddl); - vidc_1080p_set_encode_circular_intra_refresh( - encoder->intra_refresh.cir_mb_number); - ddl_vidc_encode_set_multi_slice_info(encoder); - enc_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - enc_param.inst_id = ddl->instance_id; - enc_param.shared_mem_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, - ddl->shared_mem[ddl->command_channel]); - enc_param.current_y_addr_offset = y_addr; - enc_param.current_c_addr_offset = c_addr; - enc_param.stream_buffer_addr_offset = DDL_OFFSET( - ddl_context->dram_base_a.align_physical_addr, stream->physical); - enc_param.stream_buffer_size = - encoder->client_output_buf_req.sz; - enc_param.intra_frame = encoder->intra_frame_insertion; - enc_param.input_flush = false; - enc_param.slice_enable = false; - enc_param.store_ltr0 = encoder->ltr_control.store_ltr0; - enc_param.store_ltr1 = encoder->ltr_control.store_ltr1; - enc_param.use_ltr0 = encoder->ltr_control.use_ltr0; - enc_param.use_ltr1 = encoder->ltr_control.use_ltr1; - - encoder->intra_frame_insertion = false; - encoder->intra_period_changed = false; - encoder->ltr_control.store_ltr0 = false; - encoder->ltr_control.store_ltr1 = false; - encoder->ltr_control.use_ltr0 = false; - encoder->ltr_control.use_ltr1 = false; - vidc_sm_set_encoder_vop_time( - &ddl->shared_mem[ddl->command_channel], true, - encoder->vop_timing.vop_time_resolution, - ddl->input_frame.frm_delta); - vidc_sm_set_frame_tag(&ddl->shared_mem[ddl->command_channel], - ddl->input_frame.vcd_frm.ip_frm_tag); - if (ddl_context->pix_cache_enable) { - for (index = 0; index < enc_buffers->dpb_count; - index++) { - dpb_addr_y[index] = - (u32) VIDC_1080P_DEC_DPB_RESET_VALUE; - dpb_addr_c[index] = (u32) enc_buffers->dpb_c - [index].align_physical_addr; - } - - dpb_addr_y[index] = (u32) input_vcd_frm->physical; - dpb_addr_c[index] = (u32) input_vcd_frm->physical + - encoder->input_buf_size.size_y; - - vidc_pix_cache_init_luma_chroma_base_addr( - enc_buffers->dpb_count + 1, dpb_addr_y, dpb_addr_c); - vidc_pix_cache_set_frame_size(encoder->frame_size.width, - encoder->frame_size.height); - vidc_pix_cache_set_frame_range(enc_buffers->sz_dpb_y, - enc_buffers->sz_dpb_c); - vidc_pix_cache_clear_cache_tags(); - } - ddl_context->vidc_encode_frame_start[ddl->command_channel] ( - &enc_param); -} - -void ddl_vidc_encode_frame_continue(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct vcd_frame_data *input_vcd_frm = &(ddl->input_frame.vcd_frm); - u32 address_offset; - address_offset = (u32)(ddl->output_frame.vcd_frm.physical - - ddl_context->dram_base_a.align_physical_addr) >> - DDL_VIDC_1080P_BASE_OFFSET_SHIFT; - DDL_MSG_LOW("%s\n", __func__); - if (VCD_FRAME_FLAG_EOS & input_vcd_frm->flags) - ddl->client_state = DDL_CLIENT_WAIT_FOR_EOS_DONE; - else - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME_DONE; - ddl->cmd_state = DDL_CMD_ENCODE_CONTINUE; - vidc_1080p_set_host2risc_cmd(VIDC_1080P_HOST2RISC_CMD_CONTINUE_ENC, - address_offset, - 0, 0, 0); -} - -void ddl_vidc_encode_slice_batch_run(struct ddl_client_context *ddl) -{ - struct vidc_1080p_enc_frame_start_param enc_param; - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct ddl_enc_buffers *enc_buffers = &(encoder->hw_bufs); - struct vcd_frame_data *input_vcd_frm = - &(ddl->input_frame.vcd_frm); - u32 dpb_addr_y[4], dpb_addr_c[4]; - u32 index, y_addr, c_addr; - u32 bitstream_size; - struct vidc_1080p_enc_slice_batch_in_param *slice_batch_in = - (struct vidc_1080p_enc_slice_batch_in_param *) - encoder->batch_frame.slice_batch_in.align_virtual_addr; - DDL_MSG_LOW("%s\n", __func__); - DDL_MEMSET(slice_batch_in, 0, - sizeof(struct vidc_1080p_enc_slice_batch_in_param)); - DDL_MEMSET(encoder->batch_frame.slice_batch_in.align_virtual_addr, 0, - sizeof(struct vidc_1080p_enc_slice_batch_in_param)); - encoder->batch_frame.out_frm_next_frmindex = 0; - bitstream_size = encoder->batch_frame.output_frame[0].vcd_frm.alloc_len; - encoder->output_buf_req.sz = bitstream_size; - y_addr = DDL_OFFSET(ddl_context->dram_base_b.align_physical_addr, - input_vcd_frm->physical); - c_addr = (y_addr + encoder->input_buf_size.size_y); - enc_param.encode = VIDC_1080P_ENC_TYPE_SLICE_BATCH_START; - DDL_MSG_LOW("ddl_state_transition: %s ~~>" - "DDL_CLIENT_WAIT_FOR_FRAME_DONE", - ddl_get_state_string(ddl->client_state)); - slice_batch_in->cmd_type = VIDC_1080P_ENC_TYPE_SLICE_BATCH_START; - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME_DONE; - ddl->cmd_state = DDL_CMD_ENCODE_FRAME; - vidc_1080p_set_encode_circular_intra_refresh( - encoder->intra_refresh.cir_mb_number); - ddl_vidc_encode_set_multi_slice_info(encoder); - enc_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - enc_param.inst_id = ddl->instance_id; - enc_param.shared_mem_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, - ddl->shared_mem[ddl->command_channel]); - enc_param.current_y_addr_offset = y_addr; - enc_param.current_c_addr_offset = c_addr; - enc_param.stream_buffer_size = bitstream_size; - slice_batch_in->num_stream_buffer = - encoder->batch_frame.num_output_frames; - slice_batch_in->stream_buffer_size = bitstream_size; - DDL_MSG_LOW("%s slice_batch_in->num_stream_buffer = %u size = %u\n", - __func__, slice_batch_in->num_stream_buffer, - slice_batch_in->stream_buffer_size); - for (index = 0; index < encoder->batch_frame.num_output_frames; - index++) { - slice_batch_in->stream_buffer_addr_offset[index] = - ((DDL_OFFSET(ddl_context->dram_base_b.align_physical_addr, - encoder->batch_frame.output_frame[index].vcd_frm.physical)) >> - DDL_VIDC_1080P_BASE_OFFSET_SHIFT); - } - slice_batch_in->input_size = VIDC_1080P_SLICE_BATCH_IN_SIZE(index); - enc_param.intra_frame = encoder->intra_frame_insertion; - if (encoder->intra_frame_insertion) - encoder->intra_frame_insertion = false; - enc_param.input_flush = false; - enc_param.slice_enable = - encoder->slice_delivery_info.enable; - vidc_sm_set_encoder_vop_time( - &ddl->shared_mem[ddl->command_channel], true, - encoder->vop_timing.vop_time_resolution, - ddl->input_frame.frm_delta); - vidc_sm_set_frame_tag(&ddl->shared_mem[ddl->command_channel], - ddl->input_frame.vcd_frm.ip_frm_tag); - DDL_MSG_LOW("%sdpb_count = %d\n", __func__, enc_buffers->dpb_count); - if (ddl_context->pix_cache_enable) { - for (index = 0; index < enc_buffers->dpb_count; - index++) { - dpb_addr_y[index] = - (u32) VIDC_1080P_DEC_DPB_RESET_VALUE; - dpb_addr_c[index] = (u32) enc_buffers->dpb_c - [index].align_physical_addr; - } - - dpb_addr_y[index] = (u32) input_vcd_frm->physical; - dpb_addr_c[index] = (u32) input_vcd_frm->physical + - encoder->input_buf_size.size_y; - - vidc_pix_cache_init_luma_chroma_base_addr( - enc_buffers->dpb_count + 1, dpb_addr_y, dpb_addr_c); - vidc_pix_cache_set_frame_size(encoder->frame_size.width, - encoder->frame_size.height); - vidc_pix_cache_set_frame_range(enc_buffers->sz_dpb_y, - enc_buffers->sz_dpb_c); - vidc_pix_cache_clear_cache_tags(); - } - if ((!encoder->rc_level.frame_level_rc) && - (!encoder->rc_level.mb_level_rc)) { - encoder->session_qp.p_frame_qp++; - if (encoder->session_qp.p_frame_qp > encoder->qp_range.max_qp) - encoder->session_qp.p_frame_qp = - encoder->qp_range.min_qp; - vidc_sm_set_pand_b_frame_qp( - &ddl->shared_mem[ddl->command_channel], - encoder->session_qp.b_frame_qp, - encoder->session_qp.p_frame_qp); - } - - if (vidc_msg_timing) { - if (run_cnt < 2) { - ddl_reset_core_time_variables(ENC_OP_TIME); - ddl_reset_core_time_variables(ENC_SLICE_OP_TIME); - run_cnt++; - } - ddl_update_core_start_time(__func__, ENC_SLICE_OP_TIME); - ddl_set_core_start_time(__func__, ENC_OP_TIME); - } - encoder->num_slices_comp = 0; - ddl_vidc_encode_set_batch_slice_info(ddl); - ddl_context->vidc_encode_slice_batch_start[ddl->command_channel] ( - &enc_param); -} - -u32 ddl_vidc_decode_set_buffers(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - u32 vcd_status = VCD_S_SUCCESS; - struct vidc_1080p_dec_init_buffers_param init_buf_param; - u32 size_y = 0; - u32 size_c = 0; - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { - DDL_MSG_ERROR("STATE-CRITICAL"); - return VCD_ERR_FAIL; - } - ddl_set_vidc_timeout(ddl); - ddl_vidc_decode_set_metadata_output(decoder); - if (decoder->dp_buf.no_of_dec_pic_buf < - decoder->client_output_buf_req.actual_count) - return VCD_ERR_BAD_STATE; - if (decoder->codec.codec == VCD_CODEC_H264) { - vidc_sm_set_allocated_h264_mv_size( - &ddl->shared_mem[ddl->command_channel], - decoder->hw_bufs.h264_mv[0].buffer_size); - } - if (vcd_status) - return vcd_status; -#ifdef DDL_BUF_LOG - ddl_list_buffers(ddl); -#endif - ddl_set_core_start_time(__func__, DEC_OP_TIME); - ddl_decoder_dpb_transact(decoder, NULL, DDL_DPB_OP_INIT); - if (ddl_decoder_dpb_init(ddl) == VCD_ERR_FAIL) - return VCD_ERR_FAIL; - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_WAIT_FOR_DPBDONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_DPBDONE; - ddl->cmd_state = DDL_CMD_DECODE_SET_DPB; - if (decoder->cont_mode) { - size_y = ddl_get_yuv_buf_size(decoder->client_frame_size.width, - decoder->client_frame_size.height, - DDL_YUV_BUF_TYPE_TILE); - size_c = ddl_get_yuv_buf_size(decoder->client_frame_size.width, - (decoder->client_frame_size.height >> 1), - DDL_YUV_BUF_TYPE_TILE); - vidc_sm_set_allocated_dpb_size( - &ddl->shared_mem[ddl->command_channel], - size_y, - size_c); - } else { - vidc_sm_set_allocated_dpb_size( - &ddl->shared_mem[ddl->command_channel], - decoder->dpb_buf_size.size_y, - decoder->dpb_buf_size.size_c); - } - init_buf_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - init_buf_param.inst_id = ddl->instance_id; - init_buf_param.shared_mem_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, ddl->shared_mem - [ddl->command_channel]); - init_buf_param.dpb_count = decoder->dp_buf.no_of_dec_pic_buf; - init_buf_param.dmx_disable = decoder->dmx_disable; - ddl_context->vidc_decode_init_buffers[ddl->command_channel] ( - &init_buf_param); - return VCD_S_SUCCESS; -} - -void ddl_vidc_decode_frame_run(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vcd_frame_data *bit_stream = - &(ddl->input_frame.vcd_frm); - struct ddl_dec_buffers *dec_buffers = &decoder->hw_bufs; - struct ddl_mask *dpb_mask = &ddl->codec_data.decoder.dpb_mask; - struct vidc_1080p_dec_frame_start_param dec_param; - u32 dpb_addr_y[32], index; - ddl_set_core_start_time(__func__, DEC_OP_TIME); - ddl_set_core_start_time(__func__, DEC_IP_TIME); - if ((!bit_stream->data_len) || (!bit_stream->physical)) { - ddl_vidc_decode_eos_run(ddl); - return; - } - DDL_MSG_LOW("ddl_state_transition: %s ~~" - "DDL_CLIENT_WAIT_FOR_FRAME_DONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME_DONE; - ddl_vidc_decode_dynamic_property(ddl, true); - ddl_decoder_dpb_transact(decoder, NULL, DDL_DPB_OP_SET_MASK); - ddl->cmd_state = DDL_CMD_DECODE_FRAME; - dec_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - dec_param.inst_id = ddl->instance_id; - dec_param.shared_mem_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, ddl->shared_mem - [ddl->command_channel]); - dec_param.stream_buffer_addr_offset = DDL_OFFSET( - ddl_context->dram_base_a.align_physical_addr, - bit_stream->physical); - dec_param.stream_frame_size = bit_stream->data_len; - dec_param.stream_buffersize = decoder->client_input_buf_req.sz; - dec_param.descriptor_buffer_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, dec_buffers->desc); - dec_param.descriptor_buffer_size = dec_buffers->desc.buffer_size; - dec_param.release_dpb_bit_mask = dpb_mask->hw_mask; - dec_param.decode = VIDC_1080P_DEC_TYPE_FRAME_DATA; - dec_param.dpb_count = decoder->dp_buf.no_of_dec_pic_buf; - dec_param.dmx_disable = decoder->dmx_disable; - if (decoder->dmx_disable) - ddl_fill_dec_desc_buffer(ddl); - if (decoder->flush_pending) { - dec_param.dpb_flush = true; - decoder->flush_pending = false; - } else - dec_param.dpb_flush = false; - ddl_set_vidc_timeout(ddl); - vidc_sm_set_frame_tag(&ddl->shared_mem[ddl->command_channel], - bit_stream->ip_frm_tag); - if (ddl_context->pix_cache_enable) { - for (index = 0; index < - decoder->dp_buf.no_of_dec_pic_buf; index++) { - dpb_addr_y[index] = (u32) - decoder->dp_buf.dec_pic_buffers - [index].vcd_frm.physical; - } - vidc_pix_cache_init_luma_chroma_base_addr( - decoder->dp_buf.no_of_dec_pic_buf, - dpb_addr_y, NULL); - vidc_pix_cache_set_frame_range(decoder->dpb_buf_size.size_y, - decoder->dpb_buf_size.size_c); - vidc_pix_cache_clear_cache_tags(); - } - ddl_context->vidc_decode_frame_start[ddl->command_channel] ( - &dec_param); -} - -void ddl_vidc_decode_eos_run(struct ddl_client_context *ddl) -{ - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vcd_frame_data *bit_stream = - &(ddl->input_frame.vcd_frm); - struct ddl_dec_buffers *dec_buffers = &(decoder->hw_bufs); - struct ddl_mask *dpb_mask = - &(ddl->codec_data.decoder.dpb_mask); - struct vidc_1080p_dec_frame_start_param dec_param; - - DDL_MSG_LOW("ddl_state_transition: %s ~~> DDL_CLIENT_WAIT_FOR_EOS_DONE", - ddl_get_state_string(ddl->client_state)); - ddl->client_state = DDL_CLIENT_WAIT_FOR_EOS_DONE; - if (decoder->output_order == VCD_DEC_ORDER_DECODE) - decoder->dynamic_prop_change |= DDL_DEC_REQ_OUTPUT_FLUSH; - ddl_vidc_decode_dynamic_property(ddl, true); - ddl_decoder_dpb_transact(decoder, NULL, DDL_DPB_OP_SET_MASK); - decoder->dynmic_prop_change_req = true; - ddl->cmd_state = DDL_CMD_EOS; - memset(&dec_param, 0, sizeof(dec_param)); - dec_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - dec_param.inst_id = ddl->instance_id; - dec_param.shared_mem_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, - ddl->shared_mem[ddl->command_channel]); - dec_param.descriptor_buffer_addr_offset = DDL_ADDR_OFFSET( - ddl_context->dram_base_a, dec_buffers->desc); - dec_param.descriptor_buffer_size = dec_buffers->desc.buffer_size; - dec_param.release_dpb_bit_mask = dpb_mask->hw_mask; - dec_param.decode = VIDC_1080P_DEC_TYPE_LAST_FRAME_DATA; - dec_param.dpb_count = decoder->dp_buf.no_of_dec_pic_buf; - if (decoder->flush_pending) { - dec_param.dpb_flush = true; - decoder->flush_pending = false; - } else - dec_param.dpb_flush = false; - vidc_sm_set_frame_tag(&ddl->shared_mem[ddl->command_channel], - bit_stream->ip_frm_tag); - ddl_context->vidc_decode_frame_start[ddl->command_channel] ( - &dec_param); -} - -void ddl_vidc_encode_eos_run(struct ddl_client_context *ddl) -{ - struct vidc_1080p_enc_frame_start_param enc_param; - struct ddl_context *ddl_context = ddl->ddl_context; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - DDL_MSG_LOW("%s\n", __func__); - ddl->client_state = DDL_CLIENT_WAIT_FOR_EOS_DONE; - ddl_vidc_encode_dynamic_property(ddl, true); - ddl->client_state = DDL_CMD_EOS; - DDL_MEMSET(&enc_param, 0, sizeof(enc_param)); - enc_param.encode = VIDC_1080P_ENC_TYPE_LAST_FRAME_DATA; - enc_param.cmd_seq_num = ++ddl_context->cmd_seq_num; - enc_param.inst_id = ddl->instance_id; - enc_param.shared_mem_addr_offset = - DDL_ADDR_OFFSET(ddl_context->dram_base_a, - ddl->shared_mem[ddl->command_channel]); - enc_param.current_y_addr_offset = 0; - enc_param.current_c_addr_offset = 0; - enc_param.stream_buffer_size = 0; - enc_param.intra_frame = encoder->intra_frame_insertion; - vidc_sm_set_frame_tag(&ddl->shared_mem[ddl->command_channel], - ddl->input_frame.vcd_frm.ip_frm_tag); - ddl_context->vidc_encode_frame_start[ddl->command_channel]( - &enc_param); -} - -int ddl_vidc_decode_get_avg_time(struct ddl_client_context *ddl) -{ - int avg_time = 0; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - avg_time = decoder->avg_dec_time; - return avg_time; -} - -void ddl_vidc_decode_reset_avg_time(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - decoder->avg_dec_time = 0; - decoder->dec_time_sum = 0; -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vidc.c b/drivers/video/msm/vidc/1080p/ddl/vidc.c deleted file mode 100644 index c60175a61365503f861d14fb354e4dd094457685..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vidc.c +++ /dev/null @@ -1,1157 +0,0 @@ -/* Copyright (c) 2010-2012, 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 "vidc.h" -#include "vidc_hwio.h" - - -#define VIDC_1080P_INIT_CH_INST_ID 0x0000ffff -#define VIDC_1080P_RESET_VI 0x3f7 -#define VIDC_1080P_RESET_VI_RISC 0x3f6 -#define VIDC_1080P_RESET_VI_VIDC_RISC 0x3f2 -#define VIDC_1080P_RESET_ALL 0 -#define VIDC_1080P_RESET_RISC 0x3fe -#define VIDC_1080P_RESET_NONE 0x3ff -#define VIDC_1080P_INTERRUPT_CLEAR 0 -#define VIDC_1080P_MAX_H264DECODER_DPB 32 -#define VIDC_1080P_MAX_DEC_RECON_BUF 32 - -#define VIDC_1080P_SI_RG7_DISPLAY_STATUS_MASK 0x00000007 -#define VIDC_1080P_SI_RG7_DISPLAY_STATUS_SHIFT 0 -#define VIDC_1080P_SI_RG7_DISPLAY_CODING_MASK 0x00000008 -#define VIDC_1080P_SI_RG7_DISPLAY_CODING_SHIFT 3 -#define VIDC_1080P_SI_RG7_DISPLAY_RES_MASK 0x00000030 -#define VIDC_1080P_SI_RG7_DISPLAY_RES_SHIFT 4 - -#define VIDC_1080P_SI_RG7_DISPLAY_CROP_MASK 0x00000040 -#define VIDC_1080P_SI_RG7_DISPLAY_CROP_SHIFT 6 - -#define VIDC_1080P_SI_RG7_DISPLAY_CORRECT_MASK 0x00000180 -#define VIDC_1080P_SI_RG7_DISPLAY_CORRECT_SHIFT 7 -#define VIDC_1080P_SI_RG8_DECODE_FRAMETYPE_MASK 0x00000007 - -#define VIDC_1080P_SI_RG10_NUM_DPB_BMSK 0x00003fff -#define VIDC_1080P_SI_RG10_NUM_DPB_SHFT 0 -#define VIDC_1080P_SI_RG10_DPB_FLUSH_BMSK 0x00004000 -#define VIDC_1080P_SI_RG10_DPB_FLUSH_SHFT 14 -#define VIDC_1080P_SI_RG10_DMX_DISABLE_BMSK 0x00008000 -#define VIDC_1080P_SI_RG10_DMX_DISABLE_SHFT 15 - -#define VIDC_1080P_SI_RG11_DECODE_STATUS_MASK 0x00000007 -#define VIDC_1080P_SI_RG11_DECODE_STATUS_SHIFT 0 -#define VIDC_1080P_SI_RG11_DECODE_CODING_MASK 0x00000008 -#define VIDC_1080P_SI_RG11_DECODE_CODING_SHIFT 3 -#define VIDC_1080P_SI_RG11_DECODE_RES_MASK 0x000000C0 -#define VIDC_1080P_SI_RG11_DECODE_RES_SHIFT 6 -#define VIDC_1080P_SI_RG11_DECODE_CROPP_MASK 0x00000100 -#define VIDC_1080P_SI_RG11_DECODE_CROPP_SHIFT 8 - -#define VIDC_1080P_SI_RG11_DECODE_CORRECT_MASK 0x00000600 -#define VIDC_1080P_SI_RG11_DECODE_CORRECT_SHIFT 9 -#define VIDC_1080P_BASE_OFFSET_SHIFT 11 - - -#define VIDC_1080P_H264DEC_LUMA_ADDR HWIO_REG_759068_ADDR -#define VIDC_1080P_H264DEC_CHROMA_ADDR HWIO_REG_515200_ADDR -#define VIDC_1080P_H264DEC_MV_PLANE_ADDR HWIO_REG_466192_ADDR - -#define VIDC_1080P_DEC_LUMA_ADDR HWIO_REG_759068_ADDR -#define VIDC_1080P_DEC_CHROMA_ADDR HWIO_REG_515200_ADDR - -#define VIDC_1080P_DEC_TYPE_SEQ_HEADER 0x00010000 -#define VIDC_1080P_DEC_TYPE_FRAME_DATA 0x00020000 -#define VIDC_1080P_DEC_TYPE_LAST_FRAME_DATA 0x00030000 -#define VIDC_1080P_DEC_TYPE_INIT_BUFFERS 0x00040000 - -#define VIDC_1080P_ENC_TYPE_SEQ_HEADER 0x00010000 -#define VIDC_1080P_ENC_TYPE_FRAME_DATA 0x00020000 -#define VIDC_1080P_ENC_TYPE_LAST_FRAME_DATA 0x00030000 - -#define VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_BMSK 0x00004000 -#define VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_SHFT 14 -#define VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_BMSK 0x80000000 -#define VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_SHFT 31 -#define VIDC_1080P_MAX_INTRA_PERIOD 0xffff - -#define VIDC_1080P_COMMON_CHX_RG6_I_FRAME_BMASK 0x00000001 -#define VIDC_1080P_COMMON_CHX_RG6_I_FRAME_SHIFT 0 -#define VIDC_1080P_COMMON_CHX_RG6_STORE_LTR0_BMASK 0x00000008 -#define VIDC_1080P_COMMON_CHX_RG6_STORE_LTR0_SHIFT 3 -#define VIDC_1080P_COMMON_CHX_RG6_STORE_LTR1_BMASK 0x00000010 -#define VIDC_1080P_COMMON_CHX_RG6_STORE_LTR1_SHIFT 4 -#define VIDC_1080P_COMMON_CHX_RG6_USE_LTR0_BMASK 0x00000020 -#define VIDC_1080P_COMMON_CHX_RG6_USE_LTR0_SHIFT 5 -#define VIDC_1080P_COMMON_CHX_RG6_USE_LTR1_BMASK 0x00000040 -#define VIDC_1080P_COMMON_CHX_RG6_USE_LTR1_SHIFT 6 - -u8 *VIDC_BASE_PTR; - -void vidc_1080p_do_sw_reset(enum vidc_1080p_reset init_flag) -{ - if (init_flag == VIDC_1080P_RESET_IN_SEQ_FIRST_STAGE) { - u32 sw_reset_value = 0; - - VIDC_HWIO_IN(REG_557899, &sw_reset_value); - sw_reset_value &= (~HWIO_REG_557899_RSTN_VI_BMSK); - VIDC_HWIO_OUT(REG_557899, sw_reset_value); - sw_reset_value &= (~HWIO_REG_557899_RSTN_RISC_BMSK); - VIDC_HWIO_OUT(REG_557899, sw_reset_value); - sw_reset_value &= (~(HWIO_REG_557899_RSTN_VIDCCORE_BMSK | - HWIO_REG_557899_RSTN_DMX_BMSK)); - - VIDC_HWIO_OUT(REG_557899, sw_reset_value); - } else if (init_flag == VIDC_1080P_RESET_IN_SEQ_SECOND_STAGE) { - VIDC_HWIO_OUT(REG_557899, VIDC_1080P_RESET_ALL); - VIDC_HWIO_OUT(REG_557899, VIDC_1080P_RESET_RISC); - } -} - -void vidc_1080p_release_sw_reset(void) -{ - u32 nAxiCtl; - u32 nAxiStatus; - u32 nRdWrBurst; - u32 nOut_Order; - - nOut_Order = VIDC_SETFIELD(1, HWIO_REG_5519_AXI_AOOORD_SHFT, - HWIO_REG_5519_AXI_AOOORD_BMSK); - VIDC_HWIO_OUT(REG_5519, nOut_Order); - - nOut_Order = VIDC_SETFIELD(1, HWIO_REG_606364_AXI_AOOOWR_SHFT, - HWIO_REG_606364_AXI_AOOOWR_BMSK); - VIDC_HWIO_OUT(REG_606364, nOut_Order); - - nAxiCtl = VIDC_SETFIELD(1, HWIO_REG_471159_AXI_HALT_REQ_SHFT, - HWIO_REG_471159_AXI_HALT_REQ_BMSK); - - VIDC_HWIO_OUT(REG_471159, nAxiCtl); - - do { - VIDC_HWIO_IN(REG_437878, &nAxiStatus); - nAxiStatus = VIDC_GETFIELD(nAxiStatus, - HWIO_REG_437878_AXI_HALT_ACK_BMSK, - HWIO_REG_437878_AXI_HALT_ACK_SHFT); - } while (0x3 != nAxiStatus); - - nAxiCtl = VIDC_SETFIELD(1, - HWIO_REG_471159_AXI_RESET_SHFT, - HWIO_REG_471159_AXI_RESET_BMSK); - - VIDC_HWIO_OUT(REG_471159, nAxiCtl); - VIDC_HWIO_OUT(REG_471159, 0); - - nRdWrBurst = VIDC_SETFIELD(8, - HWIO_REG_922106_XBAR_OUT_MAX_RD_BURST_SHFT, - HWIO_REG_922106_XBAR_OUT_MAX_RD_BURST_BMSK) | - VIDC_SETFIELD(8, HWIO_REG_922106_XBAR_OUT_MAX_WR_BURST_SHFT, - HWIO_REG_922106_XBAR_OUT_MAX_WR_BURST_BMSK); - - VIDC_HWIO_OUT(REG_922106, nRdWrBurst); - - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_611794, VIDC_1080P_HOST2RISC_CMD_EMPTY); - VIDC_HWIO_OUT(REG_557899, VIDC_1080P_RESET_NONE); -} - -void vidc_1080p_clear_interrupt(void) -{ - VIDC_HWIO_OUT(REG_575377, VIDC_1080P_INTERRUPT_CLEAR); -} - -void vidc_1080p_set_host2risc_cmd(enum vidc_1080p_host2risc_cmd - host2risc_command, u32 host2risc_arg1, u32 host2risc_arg2, - u32 host2risc_arg3, u32 host2risc_arg4) -{ - VIDC_HWIO_OUT(REG_611794, VIDC_1080P_HOST2RISC_CMD_EMPTY); - VIDC_HWIO_OUT(REG_356340, host2risc_arg1); - VIDC_HWIO_OUT(REG_899023, host2risc_arg2); - VIDC_HWIO_OUT(REG_987762, host2risc_arg3); - VIDC_HWIO_OUT(REG_544000, host2risc_arg4); - VIDC_HWIO_OUT(REG_611794, host2risc_command); -} - -void vidc_1080p_get_risc2host_cmd(u32 *pn_risc2host_command, - u32 *pn_risc2host_arg1, u32 *pn_risc2host_arg2, - u32 *pn_risc2host_arg3, u32 *pn_risc2host_arg4) -{ - VIDC_HWIO_IN(REG_695082, pn_risc2host_command); - VIDC_HWIO_IN(REG_156596, pn_risc2host_arg1); - VIDC_HWIO_IN(REG_222292, pn_risc2host_arg2); - VIDC_HWIO_IN(REG_790962, pn_risc2host_arg3); - VIDC_HWIO_IN(REG_679882, pn_risc2host_arg4); -} - -void vidc_1080p_get_risc2host_cmd_status(u32 err_status, - u32 *dec_err_status, u32 *disp_err_status) -{ - *dec_err_status = VIDC_GETFIELD(err_status, - VIDC_RISC2HOST_ARG2_VIDC_DEC_ERROR_STATUS_BMSK, - VIDC_RISC2HOST_ARG2_VIDC_DEC_ERROR_STATUS_SHFT); - *disp_err_status = VIDC_GETFIELD(err_status, - VIDC_RISC2HOST_ARG2_VIDC_DISP_ERROR_STATUS_BMSK, - VIDC_RISC2HOST_ARG2_VIDC_DISP_ERROR_STATUS_SHFT); - -} - -void vidc_1080p_clear_risc2host_cmd(void) -{ - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); -} - -void vidc_1080p_get_fw_version(u32 *pn_fw_version) -{ - VIDC_HWIO_IN(REG_653206, pn_fw_version); -} - -void vidc_1080p_get_fw_status(u32 *pn_fw_status) -{ - VIDC_HWIO_IN(REG_350619, pn_fw_status); -} - -void vidc_1080p_init_memory_controller(u32 dram_base_addr_a, - u32 dram_base_addr_b) -{ - VIDC_HWIO_OUT(REG_64440, dram_base_addr_a); - VIDC_HWIO_OUT(REG_675915, dram_base_addr_b); -} - -void vidc_1080p_get_memory_controller_status(u32 *pb_mc_abusy, - u32 *pb_mc_bbusy) -{ - u32 mc_status = 0; - - VIDC_HWIO_IN(REG_399911, &mc_status); - *pb_mc_abusy = (u32) ((mc_status & - HWIO_REG_399911_MC_BUSY_A_BMSK) >> - HWIO_REG_399911_MC_BUSY_A_SHFT); - *pb_mc_bbusy = (u32) ((mc_status & - HWIO_REG_399911_MC_BUSY_B_BMSK) >> - HWIO_REG_399911_MC_BUSY_B_SHFT); -} - -void vidc_1080p_set_h264_decode_buffers(u32 dpb, u32 dec_vert_nb_mv_offset, - u32 dec_nb_ip_offset, u32 *pn_dpb_luma_offset, - u32 *pn_dpb_chroma_offset, u32 *pn_mv_buffer_offset) -{ - u32 count = 0, num_dpb_used = dpb; - u8 *vidc_dpb_luma_reg = (u8 *) VIDC_1080P_H264DEC_LUMA_ADDR; - u8 *vidc_dpb_chroma_reg = (u8 *) VIDC_1080P_H264DEC_CHROMA_ADDR; - u8 *vidc_mv_buffer_reg = (u8 *) VIDC_1080P_H264DEC_MV_PLANE_ADDR; - - VIDC_HWIO_OUT(REG_931311, (dec_vert_nb_mv_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_16277, (dec_nb_ip_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - if (num_dpb_used > VIDC_1080P_MAX_H264DECODER_DPB) - num_dpb_used = VIDC_1080P_MAX_H264DECODER_DPB; - for (count = 0; count < num_dpb_used; count++) { - VIDC_OUT_DWORD(vidc_dpb_luma_reg, - (pn_dpb_luma_offset[count] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_OUT_DWORD(vidc_dpb_chroma_reg, - (pn_dpb_chroma_offset[count] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_OUT_DWORD(vidc_mv_buffer_reg, - (pn_mv_buffer_offset[count] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - vidc_dpb_luma_reg += 4; - vidc_dpb_chroma_reg += 4; - vidc_mv_buffer_reg += 4; - } -} - -void vidc_1080p_set_decode_recon_buffers(u32 recon_buffer, - u32 *pn_dec_luma, u32 *pn_dec_chroma) -{ - u32 count = 0, recon_buf_to_program = recon_buffer; - u8 *dec_recon_luma_reg = (u8 *) VIDC_1080P_DEC_LUMA_ADDR; - u8 *dec_recon_chroma_reg = (u8 *) VIDC_1080P_DEC_CHROMA_ADDR; - - if (recon_buf_to_program > VIDC_1080P_MAX_DEC_RECON_BUF) - recon_buf_to_program = VIDC_1080P_MAX_DEC_RECON_BUF; - for (count = 0; count < recon_buf_to_program; count++) { - VIDC_OUT_DWORD(dec_recon_luma_reg, (pn_dec_luma[count] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_OUT_DWORD(dec_recon_chroma_reg, - (pn_dec_chroma[count] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - dec_recon_luma_reg += 4; - dec_recon_chroma_reg += 4; - } -} - -void vidc_1080p_set_mpeg4_divx_decode_work_buffers(u32 nb_dcac_buffer_offset, - u32 upnb_mv_buffer_offset, u32 sub_anchor_buffer_offset, - u32 overlay_transform_buffer_offset, u32 stx_parser_buffer_offset) -{ - VIDC_HWIO_OUT(REG_931311, (nb_dcac_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_16277, (upnb_mv_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_654169, (sub_anchor_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_802794, - (overlay_transform_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_252167, (stx_parser_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); -} - -void vidc_1080p_set_h263_decode_work_buffers(u32 nb_dcac_buffer_offset, - u32 upnb_mv_buffer_offset, u32 sub_anchor_buffer_offset, - u32 overlay_transform_buffer_offset) -{ - VIDC_HWIO_OUT(REG_931311, (nb_dcac_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_16277, (upnb_mv_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_654169, (sub_anchor_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_802794, - (overlay_transform_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); -} - -void vidc_1080p_set_vc1_decode_work_buffers(u32 nb_dcac_buffer_offset, - u32 upnb_mv_buffer_offset, u32 sub_anchor_buffer_offset, - u32 overlay_transform_buffer_offset, u32 bitplain1Buffer_offset, - u32 bitplain2Buffer_offset, u32 bitplain3Buffer_offset) -{ - VIDC_HWIO_OUT(REG_931311, (nb_dcac_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_16277, (upnb_mv_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_654169, (sub_anchor_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_802794, - (overlay_transform_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_724376, (bitplain3Buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_551674, (bitplain2Buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_115991, (bitplain1Buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); -} - -void vidc_1080p_set_encode_recon_buffers(u32 recon_buffer, - u32 *pn_enc_luma, u32 *pn_enc_chroma) -{ - if (recon_buffer > 0) { - VIDC_HWIO_OUT(REG_294579, (pn_enc_luma[0] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_759068, (pn_enc_chroma[0] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - } - if (recon_buffer > 1) { - VIDC_HWIO_OUT(REG_616802, (pn_enc_luma[1] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_833502, (pn_enc_chroma[1] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - } - if (recon_buffer > 2) { - VIDC_HWIO_OUT(REG_61427, (pn_enc_luma[2] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_68356, (pn_enc_chroma[2] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - } - if (recon_buffer > 3) { - VIDC_HWIO_OUT(REG_23318, (pn_enc_luma[3] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_127855, (pn_enc_chroma[3] >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - } -} - -void vidc_1080p_set_h264_encode_work_buffers(u32 up_row_mv_buffer_offset, - u32 direct_colzero_flag_buffer_offset, - u32 upper_intra_md_buffer_offset, - u32 upper_intra_pred_buffer_offset, u32 nbor_infor_buffer_offset, - u32 mb_info_offset) -{ - VIDC_HWIO_OUT(REG_515200, (up_row_mv_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_69832, - (direct_colzero_flag_buffer_offset>> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_256132, - (upper_intra_md_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_475648, - (upper_intra_pred_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_29510, (nbor_infor_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_175929, (mb_info_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); -} - -void vidc_1080p_set_h263_encode_work_buffers(u32 up_row_mv_buffer_offset, - u32 up_row_inv_quanti_coeff_buffer_offset) -{ - VIDC_HWIO_OUT(REG_515200, (up_row_mv_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_29510, ( - up_row_inv_quanti_coeff_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); -} - -void vidc_1080p_set_mpeg4_encode_work_buffers(u32 skip_flag_buffer_offset, - u32 up_row_inv_quanti_coeff_buffer_offset, u32 upper_mv_offset) -{ - VIDC_HWIO_OUT(REG_69832, (skip_flag_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_29510, ( - up_row_inv_quanti_coeff_buffer_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); - VIDC_HWIO_OUT(REG_515200, (upper_mv_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT)); -} - -void vidc_1080p_set_encode_frame_size(u32 hori_size, u32 vert_size) -{ - VIDC_HWIO_OUT(REG_934655, hori_size); - VIDC_HWIO_OUT(REG_179070, vert_size); -} - -void vidc_1080p_set_encode_profile_level(u32 encode_profile, u32 enc_level) -{ - u32 profile_level = 0; - - profile_level = VIDC_SETFIELD(enc_level, - HWIO_REG_63643_LEVEL_SHFT, - HWIO_REG_63643_LEVEL_BMSK) | - VIDC_SETFIELD(encode_profile, - HWIO_REG_63643_PROFILE_SHFT, - HWIO_REG_63643_PROFILE_BMSK); - VIDC_HWIO_OUT(REG_63643, profile_level); -} - -void vidc_1080p_set_encode_field_picture_structure(u32 enc_field_picture) -{ - VIDC_HWIO_OUT(REG_786024, enc_field_picture); -} - -void vidc_1080p_set_decode_mpeg4_pp_filter(u32 lf_enables) -{ - VIDC_HWIO_OUT(REG_152500, lf_enables); -} - -void vidc_1080p_set_decode_qp_save_control(u32 enable_q_pout) -{ - VIDC_HWIO_OUT(REG_143629, enable_q_pout); -} - -void vidc_1080p_get_returned_channel_inst_id(u32 *pn_rtn_chid) -{ - VIDC_HWIO_IN(REG_607589, pn_rtn_chid); -} - -void vidc_1080p_clear_returned_channel_inst_id(void) -{ - VIDC_HWIO_OUT(REG_607589, VIDC_1080P_INIT_CH_INST_ID); -} - -void vidc_1080p_get_decode_seq_start_result( - struct vidc_1080p_seq_hdr_info *seq_hdr_info) -{ - u32 dec_disp_result; - u32 frame = 0; - VIDC_HWIO_IN(REG_845544, &seq_hdr_info->img_size_y); - VIDC_HWIO_IN(REG_859906, &seq_hdr_info->img_size_x); - VIDC_HWIO_IN(REG_490078, &seq_hdr_info->min_num_dpb); - VIDC_HWIO_IN(REG_489688, &seq_hdr_info->dec_frm_size); - VIDC_HWIO_IN(REG_853667, &dec_disp_result); - seq_hdr_info->disp_progressive = VIDC_GETFIELD(dec_disp_result, - VIDC_1080P_SI_RG7_DISPLAY_CODING_MASK, - VIDC_1080P_SI_RG7_DISPLAY_CODING_SHIFT); - seq_hdr_info->disp_crop_exists = VIDC_GETFIELD(dec_disp_result, - VIDC_1080P_SI_RG7_DISPLAY_CROP_MASK, - VIDC_1080P_SI_RG7_DISPLAY_CROP_SHIFT); - VIDC_HWIO_IN(REG_692991, &dec_disp_result); - seq_hdr_info->dec_progressive = VIDC_GETFIELD(dec_disp_result, - VIDC_1080P_SI_RG11_DECODE_CODING_MASK, - VIDC_1080P_SI_RG11_DECODE_CODING_SHIFT); - seq_hdr_info->dec_crop_exists = VIDC_GETFIELD(dec_disp_result, - VIDC_1080P_SI_RG11_DECODE_CROPP_MASK, - VIDC_1080P_SI_RG11_DECODE_CROPP_SHIFT); - VIDC_HWIO_IN(REG_760102, &frame); - seq_hdr_info->data_partition = ((frame & 0x8) >> 3); -} - -void vidc_1080p_get_decoded_frame_size(u32 *pn_decoded_size) -{ - VIDC_HWIO_IN(REG_489688, pn_decoded_size); -} - -void vidc_1080p_get_display_frame_result( - struct vidc_1080p_dec_disp_info *dec_disp_info) -{ - u32 display_result; - VIDC_HWIO_IN(REG_640904, &dec_disp_info->display_y_addr); - VIDC_HWIO_IN(REG_60114, &dec_disp_info->display_c_addr); - VIDC_HWIO_IN(REG_853667, &display_result); - VIDC_HWIO_IN(REG_845544, &dec_disp_info->img_size_y); - VIDC_HWIO_IN(REG_859906, &dec_disp_info->img_size_x); - dec_disp_info->display_status = - (enum vidc_1080p_display_status) - VIDC_GETFIELD(display_result, - VIDC_1080P_SI_RG7_DISPLAY_STATUS_MASK, - VIDC_1080P_SI_RG7_DISPLAY_STATUS_SHIFT); - dec_disp_info->display_coding = - (enum vidc_1080p_display_coding) - VIDC_GETFIELD(display_result, VIDC_1080P_SI_RG7_DISPLAY_CODING_MASK, - VIDC_1080P_SI_RG7_DISPLAY_CODING_SHIFT); - dec_disp_info->disp_resl_change = VIDC_GETFIELD(display_result, - VIDC_1080P_SI_RG7_DISPLAY_RES_MASK, - VIDC_1080P_SI_RG7_DISPLAY_RES_SHIFT); - dec_disp_info->disp_crop_exists = VIDC_GETFIELD(display_result, - VIDC_1080P_SI_RG7_DISPLAY_CROP_MASK, - VIDC_1080P_SI_RG7_DISPLAY_CROP_SHIFT); - dec_disp_info->display_correct = VIDC_GETFIELD(display_result, - VIDC_1080P_SI_RG7_DISPLAY_CORRECT_MASK, - VIDC_1080P_SI_RG7_DISPLAY_CORRECT_SHIFT); -} - -void vidc_1080p_get_decode_frame( - enum vidc_1080p_decode_frame *pe_frame) -{ - u32 frame = 0; - - VIDC_HWIO_IN(REG_760102, &frame); - if (frame & 0x10) - *pe_frame = (enum vidc_1080p_decode_frame) - VIDC_1080P_DECODE_FRAMETYPE_IDR; - else - *pe_frame = (enum vidc_1080p_decode_frame) - (frame & VIDC_1080P_SI_RG8_DECODE_FRAMETYPE_MASK); -} - -void vidc_1080p_get_decode_frame_result( - struct vidc_1080p_dec_disp_info *dec_disp_info) -{ - u32 decode_result; - - VIDC_HWIO_IN(REG_378318, &dec_disp_info->decode_y_addr); - VIDC_HWIO_IN(REG_203487, &dec_disp_info->decode_c_addr); - VIDC_HWIO_IN(REG_692991, &decode_result); - dec_disp_info->decode_status = (enum vidc_1080p_display_status) - VIDC_GETFIELD(decode_result, - VIDC_1080P_SI_RG11_DECODE_STATUS_MASK, - VIDC_1080P_SI_RG11_DECODE_STATUS_SHIFT); - dec_disp_info->decode_coding = (enum vidc_1080p_display_coding) - VIDC_GETFIELD(decode_result, - VIDC_1080P_SI_RG11_DECODE_CODING_MASK, - VIDC_1080P_SI_RG11_DECODE_CODING_SHIFT); - dec_disp_info->dec_resl_change = VIDC_GETFIELD(decode_result, - VIDC_1080P_SI_RG11_DECODE_RES_MASK, - VIDC_1080P_SI_RG11_DECODE_RES_SHIFT); - dec_disp_info->dec_crop_exists = VIDC_GETFIELD(decode_result, - VIDC_1080P_SI_RG11_DECODE_CROPP_MASK, - VIDC_1080P_SI_RG11_DECODE_CROPP_SHIFT); - dec_disp_info->decode_correct = VIDC_GETFIELD(decode_result, - VIDC_1080P_SI_RG11_DECODE_CORRECT_MASK, - VIDC_1080P_SI_RG11_DECODE_CORRECT_SHIFT); -} - -void vidc_1080p_decode_seq_start_ch0( - struct vidc_1080p_dec_seq_start_param *param) -{ - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_117192, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_145068, param->stream_frame_size); - VIDC_HWIO_OUT(REG_921356, - param->descriptor_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_190381, param->stream_buffersize); - VIDC_HWIO_OUT(REG_85655, param->descriptor_buffer_size); - VIDC_HWIO_OUT(REG_889944, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_404623, 0); - VIDC_HWIO_OUT(REG_397087, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_DEC_TYPE_SEQ_HEADER | - param->inst_id); -} - -void vidc_1080p_decode_seq_start_ch1( - struct vidc_1080p_dec_seq_start_param *param) -{ - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_980194, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_936704, param->stream_frame_size); - VIDC_HWIO_OUT(REG_821977, - param->descriptor_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_887095, param->stream_buffersize); - VIDC_HWIO_OUT(REG_576987, param->descriptor_buffer_size); - VIDC_HWIO_OUT(REG_652528, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_404623, 0); - VIDC_HWIO_OUT(REG_254093, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_DEC_TYPE_SEQ_HEADER | - param->inst_id); -} - -void vidc_1080p_decode_frame_start_ch0( - struct vidc_1080p_dec_frame_start_param *param) -{ - u32 dpb_config; - - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - if ((param->decode == VIDC_1080P_DEC_TYPE_LAST_FRAME_DATA) && - ((!param->stream_buffer_addr_offset) || - (!param->stream_frame_size))) { - VIDC_HWIO_OUT(REG_117192, 0); - VIDC_HWIO_OUT(REG_145068, 0); - VIDC_HWIO_OUT(REG_190381, 0); - } else { - VIDC_HWIO_OUT(REG_117192, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_145068, - param->stream_frame_size); - VIDC_HWIO_OUT(REG_190381, - param->stream_buffersize); - } - dpb_config = VIDC_SETFIELD(param->dmx_disable, - VIDC_1080P_SI_RG10_DMX_DISABLE_SHFT, - VIDC_1080P_SI_RG10_DMX_DISABLE_BMSK) | - VIDC_SETFIELD(param->dpb_flush, - VIDC_1080P_SI_RG10_DPB_FLUSH_SHFT, - VIDC_1080P_SI_RG10_DPB_FLUSH_BMSK) | - VIDC_SETFIELD(param->dpb_count, - VIDC_1080P_SI_RG10_NUM_DPB_SHFT, - VIDC_1080P_SI_RG10_NUM_DPB_BMSK); - VIDC_HWIO_OUT(REG_921356, - param->descriptor_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_85655, param->descriptor_buffer_size); - VIDC_HWIO_OUT(REG_86830, param->release_dpb_bit_mask); - VIDC_HWIO_OUT(REG_889944, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_404623, dpb_config); - VIDC_HWIO_OUT(REG_397087, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_666957, (u32)param->decode | - param->inst_id); -} - - -void vidc_1080p_decode_frame_start_ch1( - struct vidc_1080p_dec_frame_start_param *param) -{ - u32 dpb_config; - - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_INIT_CH_INST_ID); - if ((param->decode == VIDC_1080P_DEC_TYPE_LAST_FRAME_DATA) && - ((!param->stream_buffer_addr_offset) || - (!param->stream_frame_size))) { - VIDC_HWIO_OUT(REG_980194, 0); - VIDC_HWIO_OUT(REG_936704, 0); - VIDC_HWIO_OUT(REG_887095, 0); - } else { - VIDC_HWIO_OUT(REG_980194, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_936704, - param->stream_frame_size); - VIDC_HWIO_OUT(REG_887095, - param->stream_buffersize); - } - dpb_config = VIDC_SETFIELD(param->dmx_disable, - VIDC_1080P_SI_RG10_DMX_DISABLE_SHFT, - VIDC_1080P_SI_RG10_DMX_DISABLE_BMSK) | - VIDC_SETFIELD(param->dpb_flush, - VIDC_1080P_SI_RG10_DPB_FLUSH_SHFT, - VIDC_1080P_SI_RG10_DPB_FLUSH_BMSK) | - VIDC_SETFIELD(param->dpb_count, - VIDC_1080P_SI_RG10_NUM_DPB_SHFT, - VIDC_1080P_SI_RG10_NUM_DPB_BMSK); - VIDC_HWIO_OUT(REG_821977, - param->descriptor_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_576987, param->descriptor_buffer_size); - VIDC_HWIO_OUT(REG_70448, param->release_dpb_bit_mask); - VIDC_HWIO_OUT(REG_652528, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_220637, dpb_config); - VIDC_HWIO_OUT(REG_254093, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_313350, (u32)param->decode | - param->inst_id); -} - -void vidc_1080p_decode_init_buffers_ch0( - struct vidc_1080p_dec_init_buffers_param *param) -{ - u32 dpb_config; - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - dpb_config = VIDC_SETFIELD(param->dmx_disable, - VIDC_1080P_SI_RG10_DMX_DISABLE_SHFT, - VIDC_1080P_SI_RG10_DMX_DISABLE_BMSK) | - VIDC_SETFIELD(param->dpb_count, - VIDC_1080P_SI_RG10_NUM_DPB_SHFT, - VIDC_1080P_SI_RG10_NUM_DPB_BMSK); - VIDC_HWIO_OUT(REG_889944, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_404623, dpb_config); - VIDC_HWIO_OUT(REG_397087, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_DEC_TYPE_INIT_BUFFERS | - param->inst_id); -} - -void vidc_1080p_decode_init_buffers_ch1( - struct vidc_1080p_dec_init_buffers_param *param) -{ - u32 dpb_config; - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_INIT_CH_INST_ID); - dpb_config = VIDC_SETFIELD(param->dmx_disable, - VIDC_1080P_SI_RG10_DMX_DISABLE_SHFT, - VIDC_1080P_SI_RG10_DMX_DISABLE_BMSK) | - VIDC_SETFIELD(param->dpb_count, - VIDC_1080P_SI_RG10_NUM_DPB_SHFT, - VIDC_1080P_SI_RG10_NUM_DPB_BMSK); - VIDC_HWIO_OUT(REG_652528, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_220637, dpb_config); - VIDC_HWIO_OUT(REG_254093, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_DEC_TYPE_INIT_BUFFERS | - param->inst_id); -} - -void vidc_1080p_set_dec_resolution_ch0(u32 width, u32 height) -{ - VIDC_HWIO_OUT(REG_612810, height); - VIDC_HWIO_OUT(REG_175608, width); -} - -void vidc_1080p_set_dec_resolution_ch1(u32 width, u32 height) -{ - VIDC_HWIO_OUT(REG_655721, height); - VIDC_HWIO_OUT(REG_548308, width); -} - -void vidc_1080p_get_encode_frame_info( - struct vidc_1080p_enc_frame_info *frame_info) -{ - VIDC_HWIO_IN(REG_845544, &(frame_info->enc_frame_size)); - VIDC_HWIO_IN(REG_859906, - &(frame_info->enc_picture_count)); - VIDC_HWIO_IN(REG_490078, - &(frame_info->enc_write_pointer)); - VIDC_HWIO_IN(REG_640904, - (u32 *)(&(frame_info->enc_frame))); - VIDC_HWIO_IN(REG_60114, - &(frame_info->enc_luma_address)); - frame_info->enc_luma_address = frame_info->enc_luma_address << - VIDC_1080P_BASE_OFFSET_SHIFT; - VIDC_HWIO_IN(REG_489688, - &(frame_info->enc_chroma_address)); - frame_info->enc_chroma_address = frame_info->\ - enc_chroma_address << VIDC_1080P_BASE_OFFSET_SHIFT; -} - -void vidc_1080p_encode_seq_start_ch0( - struct vidc_1080p_enc_seq_start_param *param) -{ - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_117192, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_921356, param->stream_buffer_size); - VIDC_HWIO_OUT(REG_889944, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_397087, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_ENC_TYPE_SEQ_HEADER | - param->inst_id); -} - -void vidc_1080p_encode_seq_start_ch1( - struct vidc_1080p_enc_seq_start_param *param) -{ - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_980194, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_821977, param->stream_buffer_size); - VIDC_HWIO_OUT(REG_652528, param->shared_mem_addr_offset); - VIDC_HWIO_OUT(REG_254093, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_ENC_TYPE_SEQ_HEADER | - param->inst_id); -} - -void vidc_1080p_encode_frame_start_ch0( - struct vidc_1080p_enc_frame_start_param *param) -{ - u32 input_flush = 0; - u32 frame_insertion = 0; - - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_117192, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_921356, param->stream_buffer_size); - VIDC_HWIO_OUT(REG_612810, param->current_y_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_175608, param->current_c_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - frame_insertion = VIDC_SETFIELD(param->intra_frame, - VIDC_1080P_COMMON_CHX_RG6_I_FRAME_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_I_FRAME_BMASK); - frame_insertion |= VIDC_SETFIELD(param->store_ltr0, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR0_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR0_BMASK); - frame_insertion |= VIDC_SETFIELD(param->store_ltr1, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR1_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR1_BMASK); - frame_insertion |= VIDC_SETFIELD(param->use_ltr0, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR0_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR0_BMASK); - frame_insertion |= VIDC_SETFIELD(param->use_ltr1, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR1_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR1_BMASK); - VIDC_HWIO_OUT(REG_190381, frame_insertion); - VIDC_HWIO_OUT(REG_889944, param->shared_mem_addr_offset); - input_flush = VIDC_SETFIELD(param->input_flush, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_SHFT, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_BMSK); - input_flush |= VIDC_SETFIELD(param->slice_enable, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_SHFT, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_BMSK); - VIDC_HWIO_OUT(REG_404623, input_flush); - VIDC_HWIO_OUT(REG_397087, param->cmd_seq_num); - - VIDC_HWIO_OUT(REG_666957, (u32)param->encode | - param->inst_id); -} - -void vidc_1080p_encode_frame_start_ch1( - struct vidc_1080p_enc_frame_start_param *param) -{ - u32 input_flush = 0; - u32 frame_insertion = 0; - - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_980194, - param->stream_buffer_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_821977, param->stream_buffer_size); - VIDC_HWIO_OUT(REG_655721, param->current_y_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_548308, param->current_c_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - frame_insertion = VIDC_SETFIELD(param->intra_frame, - VIDC_1080P_COMMON_CHX_RG6_I_FRAME_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_I_FRAME_BMASK); - frame_insertion |= VIDC_SETFIELD(param->store_ltr0, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR0_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR0_BMASK); - frame_insertion |= VIDC_SETFIELD(param->store_ltr1, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR1_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_STORE_LTR1_BMASK); - frame_insertion |= VIDC_SETFIELD(param->use_ltr0, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR0_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR0_BMASK); - frame_insertion |= VIDC_SETFIELD(param->use_ltr1, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR1_SHIFT, - VIDC_1080P_COMMON_CHX_RG6_USE_LTR1_BMASK); - VIDC_HWIO_OUT(REG_887095, frame_insertion); - VIDC_HWIO_OUT(REG_652528, param->shared_mem_addr_offset); - input_flush = VIDC_SETFIELD(param->input_flush, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_SHFT, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_BMSK); - input_flush |= VIDC_SETFIELD(param->slice_enable, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_SHFT, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_BMSK); - - VIDC_HWIO_OUT(REG_404623, input_flush); - VIDC_HWIO_OUT(REG_254093, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_313350, (u32)param->encode | - param->inst_id); -} - -void vidc_1080p_encode_slice_batch_start_ch0( - struct vidc_1080p_enc_frame_start_param *param) -{ - u32 input_flush; - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_612810, param->current_y_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_175608, param->current_c_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_190381, param->intra_frame); - VIDC_HWIO_OUT(REG_889944, param->shared_mem_addr_offset); - input_flush = VIDC_SETFIELD(param->input_flush, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_SHFT, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_BMSK); - input_flush |= VIDC_SETFIELD(param->slice_enable, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_SHFT, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_BMSK); - VIDC_HWIO_OUT(REG_404623, input_flush); - VIDC_HWIO_OUT(REG_397087, param->cmd_seq_num); - - VIDC_HWIO_OUT(REG_666957, (u32)param->encode | - param->inst_id); - -} - -void vidc_1080p_encode_slice_batch_start_ch1( - struct vidc_1080p_enc_frame_start_param *param) -{ - u32 input_flush; - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_313350, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_655721, param->current_y_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_548308, param->current_c_addr_offset >> - VIDC_1080P_BASE_OFFSET_SHIFT); - VIDC_HWIO_OUT(REG_887095, param->intra_frame); - VIDC_HWIO_OUT(REG_652528, param->shared_mem_addr_offset); - input_flush = VIDC_SETFIELD(param->input_flush, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_SHFT, - VIDC_1080P_SI_RG10_ENCODE_INPUT_BUFFER_FLUSH_BMSK); - input_flush |= VIDC_SETFIELD(param->slice_enable, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_SHFT, - VIDC_1080P_SI_RG10_ENCODE_SLICE_IF_ENABLE_BMSK); - - VIDC_HWIO_OUT(REG_404623, input_flush); - VIDC_HWIO_OUT(REG_254093, param->cmd_seq_num); - VIDC_HWIO_OUT(REG_313350, (u32)param->encode | - param->inst_id); - -} - -void vidc_1080p_set_encode_picture(u32 number_p, u32 number_b) -{ - u32 picture, ifrm_ctrl; - if (number_p >= VIDC_1080P_MAX_INTRA_PERIOD) - ifrm_ctrl = 0; - else - ifrm_ctrl = number_p + 1; - picture = VIDC_SETFIELD(1 , - HWIO_REG_783891_ENC_PIC_TYPE_USE_SHFT, - HWIO_REG_783891_ENC_PIC_TYPE_USE_BMSK) | - VIDC_SETFIELD(ifrm_ctrl, - HWIO_REG_783891_I_FRM_CTRL_SHFT, - HWIO_REG_783891_I_FRM_CTRL_BMSK) - | VIDC_SETFIELD(number_b , - HWIO_REG_783891_B_FRM_CTRL_SHFT , - HWIO_REG_783891_B_FRM_CTRL_BMSK); - VIDC_HWIO_OUT(REG_783891, picture); -} - -void vidc_1080p_set_encode_multi_slice_control( - enum vidc_1080p_MSlice_selection multiple_slice_selection, - u32 mslice_mb, u32 mslice_byte) -{ - VIDC_HWIO_OUT(REG_226332, multiple_slice_selection); - VIDC_HWIO_OUT(REG_696136, mslice_mb); - VIDC_HWIO_OUT(REG_515564, mslice_byte); -} - -void vidc_1080p_set_encode_circular_intra_refresh(u32 cir_num) -{ - VIDC_HWIO_OUT(REG_886210, cir_num); -} - -void vidc_1080p_set_encode_input_frame_format( - enum vidc_1080p_memory_access_method memory_format) -{ - VIDC_HWIO_OUT(REG_645603, memory_format); -} - -void vidc_1080p_set_encode_padding_control(u32 pad_ctrl_on, - u32 cr_pad_val, u32 cb_pad_val, u32 luma_pad_val) -{ - u32 padding = VIDC_SETFIELD(pad_ctrl_on , - HWIO_REG_811733_PAD_CTRL_ON_SHFT, - HWIO_REG_811733_PAD_CTRL_ON_BMSK) | - VIDC_SETFIELD(cr_pad_val , - HWIO_REG_811733_CR_PAD_VIDC_SHFT , - HWIO_REG_811733_CR_PAD_VIDC_BMSK) | - VIDC_SETFIELD(cb_pad_val , - HWIO_REG_811733_CB_PAD_VIDC_SHFT , - HWIO_REG_811733_CB_PAD_VIDC_BMSK) | - VIDC_SETFIELD(luma_pad_val , - HWIO_REG_811733_LUMA_PAD_VIDC_SHFT , - HWIO_REG_811733_LUMA_PAD_VIDC_BMSK) ; - VIDC_HWIO_OUT(REG_811733, padding); -} - -void vidc_1080p_encode_set_rc_config(u32 enable_frame_level_rc, - u32 enable_mb_level_rc_flag, u32 frame_qp) -{ - u32 rc_config = VIDC_SETFIELD(enable_frame_level_rc , - HWIO_REG_559908_FR_RC_EN_SHFT , - HWIO_REG_559908_FR_RC_EN_BMSK) | - VIDC_SETFIELD(enable_mb_level_rc_flag , - HWIO_REG_559908_MB_RC_EN_SHFT, - HWIO_REG_559908_MB_RC_EN_BMSK) | - VIDC_SETFIELD(frame_qp , - HWIO_REG_559908_FRAME_QP_SHFT , - HWIO_REG_559908_FRAME_QP_BMSK); - VIDC_HWIO_OUT(REG_559908, rc_config); -} - -void vidc_1080p_encode_set_frame_level_rc_params(u32 rc_frame_rate, - u32 target_bitrate, u32 reaction_coeff) -{ - VIDC_HWIO_OUT(REG_977937, rc_frame_rate); - VIDC_HWIO_OUT(REG_166135, target_bitrate); - VIDC_HWIO_OUT(REG_550322, reaction_coeff); -} - -void vidc_1080p_encode_set_qp_params(u32 max_qp, u32 min_qp) -{ - u32 qbound = VIDC_SETFIELD(max_qp , HWIO_REG_109072_MAX_QP_SHFT, - HWIO_REG_109072_MAX_QP_BMSK) | - VIDC_SETFIELD(min_qp, - HWIO_REG_109072_MIN_QP_SHFT , - HWIO_REG_109072_MIN_QP_BMSK); - VIDC_HWIO_OUT(REG_109072, qbound); -} - -void vidc_1080p_encode_set_mb_level_rc_params(u32 disable_dark_region_as_flag, - u32 disable_smooth_region_as_flag , u32 disable_static_region_as_flag, - u32 disable_activity_region_flag) -{ - u32 rc_active_feature = VIDC_SETFIELD( - disable_dark_region_as_flag, - HWIO_REG_949086_DARK_DISABLE_SHFT, - HWIO_REG_949086_DARK_DISABLE_BMSK) | - VIDC_SETFIELD( - disable_smooth_region_as_flag, - HWIO_REG_949086_SMOOTH_DISABLE_SHFT, - HWIO_REG_949086_SMOOTH_DISABLE_BMSK) | - VIDC_SETFIELD( - disable_static_region_as_flag, - HWIO_REG_949086_STATIC_DISABLE_SHFT, - HWIO_REG_949086_STATIC_DISABLE_BMSK) | - VIDC_SETFIELD( - disable_activity_region_flag, - HWIO_REG_949086_ACT_DISABLE_SHFT, - HWIO_REG_949086_ACT_DISABLE_BMSK); - VIDC_HWIO_OUT(REG_949086, rc_active_feature); -} - -void vidc_1080p_set_h264_encode_entropy( - enum vidc_1080p_entropy_sel entropy_sel) -{ - VIDC_HWIO_OUT(REG_447796, entropy_sel); -} - -void vidc_1080p_set_h264_encode_loop_filter( - enum vidc_1080p_DBConfig db_config, u32 slice_alpha_offset, - u32 slice_beta_offset) -{ - VIDC_HWIO_OUT(REG_152500, db_config); - VIDC_HWIO_OUT(REG_266285, slice_alpha_offset); - VIDC_HWIO_OUT(REG_964731, slice_beta_offset); -} - -void vidc_1080p_set_h264_encoder_p_frame_ref_count(u32 max_reference) -{ - u32 ref_frames; - ref_frames = VIDC_SETFIELD(max_reference, - HWIO_REG_744348_P_SHFT, - HWIO_REG_744348_P_BMSK); - VIDC_HWIO_OUT(REG_744348, ref_frames); -} - -void vidc_1080p_set_h264_encode_8x8transform_control(u32 enable_8x8transform) -{ - VIDC_HWIO_OUT(REG_672163, enable_8x8transform); -} - -void vidc_1080p_set_mpeg4_encode_quarter_pel_control( - u32 enable_mpeg4_quarter_pel) -{ - VIDC_HWIO_OUT(REG_330132, enable_mpeg4_quarter_pel); -} - -void vidc_1080p_set_device_base_addr(u8 *mapped_va) -{ - VIDC_BASE_PTR = mapped_va; -} - -void vidc_1080p_get_intra_bias(u32 *bias) -{ - u32 intra_bias; - - VIDC_HWIO_IN(REG_676866, &intra_bias); - *bias = VIDC_GETFIELD(intra_bias, - HWIO_REG_676866_RMSK, - HWIO_REG_676866_SHFT); -} - -void vidc_1080p_set_intra_bias(u32 bias) -{ - u32 intra_bias; - - intra_bias = VIDC_SETFIELD(bias, - HWIO_REG_676866_SHFT, - HWIO_REG_676866_RMSK); - VIDC_HWIO_OUT(REG_676866, intra_bias); -} - -void vidc_1080p_get_bi_directional_bias(u32 *bi_directional_bias) -{ - u32 nbi_direct_bias; - - VIDC_HWIO_IN(REG_54267, &nbi_direct_bias); - *bi_directional_bias = VIDC_GETFIELD(nbi_direct_bias, - HWIO_REG_54267_RMSK, - HWIO_REG_54267_SHFT); -} - -void vidc_1080p_set_bi_directional_bias(u32 bi_directional_bias) -{ - u32 nbi_direct_bias; - - nbi_direct_bias = VIDC_SETFIELD(bi_directional_bias, - HWIO_REG_54267_SHFT, - HWIO_REG_54267_RMSK); - VIDC_HWIO_OUT(REG_54267, nbi_direct_bias); -} - -void vidc_1080p_get_encoder_sequence_header_size(u32 *seq_header_size) -{ - VIDC_HWIO_IN(REG_845544, seq_header_size); -} - -void vidc_1080p_get_intermedia_stage_debug_counter( - u32 *intermediate_stage_counter) -{ - VIDC_HWIO_IN(REG_805993, intermediate_stage_counter); -} - -void vidc_1080p_get_exception_status(u32 *exception_status) -{ - VIDC_HWIO_IN(REG_493355, exception_status); -} - -void vidc_1080p_frame_start_realloc(u32 instance_id) -{ - VIDC_HWIO_OUT(REG_695082, VIDC_1080P_RISC2HOST_CMD_EMPTY); - VIDC_HWIO_OUT(REG_666957, VIDC_1080P_INIT_CH_INST_ID); - VIDC_HWIO_OUT(REG_666957, - VIDC_1080P_DEC_TYPE_FRAME_START_REALLOC | instance_id); -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vidc.h b/drivers/video/msm/vidc/1080p/ddl/vidc.h deleted file mode 100644 index 0d83dd9530a2a7b9caa0c4ec93a5ed979cda27ef..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vidc.h +++ /dev/null @@ -1,593 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VIDC_H_ -#define _VIDC_H_ - -#include "vidc_hwio_reg.h" - -#define VIDC_1080P_RISC2HOST_CMD_EMPTY 0 -#define VIDC_1080P_RISC2HOST_CMD_OPEN_CH_RET 1 -#define VIDC_1080P_RISC2HOST_CMD_CLOSE_CH_RET 2 -#define VIDC_1080P_RISC2HOST_CMD_SEQ_DONE_RET 4 -#define VIDC_1080P_RISC2HOST_CMD_FRAME_DONE_RET 5 -#define VIDC_1080P_RISC2HOST_CMD_SLICE_DONE_RET 6 -#define VIDC_1080P_RISC2HOST_CMD_ENC_COMPLETE_RET 7 -#define VIDC_1080P_RISC2HOST_CMD_SYS_INIT_RET 8 -#define VIDC_1080P_RISC2HOST_CMD_FW_STATUS_RET 9 -#define VIDC_1080P_RISC2HOST_CMD_FLUSH_COMMAND_RET 12 -#define VIDC_1080P_RISC2HOST_CMD_ABORT_RET 13 -#define VIDC_1080P_RISC2HOST_CMD_BATCH_ENC_RET 14 -#define VIDC_1080P_RISC2HOST_CMD_INIT_BUFFERS_RET 15 -#define VIDC_1080P_RISC2HOST_CMD_EDFU_INT_RET 16 -#define VIDC_1080P_RISC2HOST_CMD_ERROR_RET 32 - -#define VIDC_RISC2HOST_ARG2_VIDC_DISP_ERROR_STATUS_BMSK 0xffff0000 -#define VIDC_RISC2HOST_ARG2_VIDC_DISP_ERROR_STATUS_SHFT 16 -#define VIDC_RISC2HOST_ARG2_VIDC_DEC_ERROR_STATUS_BMSK 0x0000ffff -#define VIDC_RISC2HOST_ARG2_VIDC_DEC_ERROR_STATUS_SHFT 0 - -#define VIDC_1080P_ERROR_INVALID_CHANNEL_NUMBER 1 -#define VIDC_1080P_ERROR_INVALID_COMMAND_ID 2 -#define VIDC_1080P_ERROR_CHANNEL_ALREADY_IN_USE 3 -#define VIDC_1080P_ERROR_CHANNEL_NOT_OPEN_BEFORE_CHANNEL_CLOSE 4 -#define VIDC_1080P_ERROR_OPEN_CH_ERROR_SEQ_START 5 -#define VIDC_1080P_ERROR_SEQ_START_ALREADY_CALLED 6 -#define VIDC_1080P_ERROR_OPEN_CH_ERROR_INIT_BUFFERS 7 -#define VIDC_1080P_ERROR_SEQ_START_ERROR_INIT_BUFFERS 8 -#define VIDC_1080P_ERROR_INIT_BUFFER_ALREADY_CALLED 9 -#define VIDC_1080P_ERROR_OPEN_CH_ERROR_FRAME_START 10 -#define VIDC_1080P_ERROR_SEQ_START_ERROR_FRAME_START 11 -#define VIDC_1080P_ERROR_INIT_BUFFERS_ERROR_FRAME_START 12 -#define VIDC_1080P_ERROR_RESOLUTION_CHANGED 13 -#define VIDC_1080P_ERROR_INVALID_COMMAND_LAST_FRAME 14 -#define VIDC_1080P_ERROR_INVALID_COMMAND 15 -#define VIDC_1080P_ERROR_INVALID_CODEC_TYPE 16 - -#define VIDC_1080P_ERROR_MEM_ALLOCATION_FAILED 20 -#define VIDC_1080P_ERROR_INSUFFICIENT_CONTEXT_SIZE 25 -#define VIDC_1080P_ERROR_UNSUPPORTED_FEATURE_IN_PROFILE 27 -#define VIDC_1080P_ERROR_RESOLUTION_NOT_SUPPORTED 28 - -#define VIDC_1080P_ERROR_HEADER_NOT_FOUND 52 -#define VIDC_1080P_ERROR_VOS_END_CODE_RECEIVED 53 -#define VIDC_1080P_ERROR_FRAME_RATE_NOT_SUPPORTED 62 -#define VIDC_1080P_ERROR_INVALID_QP_VALUE 63 -#define VIDC_1080P_ERROR_INVALID_RC_REACTION_COEFFICIENT 64 -#define VIDC_1080P_ERROR_INVALID_CPB_SIZE_AT_GIVEN_LEVEL 65 -#define VIDC_1080P_ERROR_B_FRAME_NOT_SUPPORTED 66 -#define VIDC_1080P_ERROR_ALLOC_DPB_SIZE_NOT_SUFFICIENT 71 -#define VIDC_1080P_ERROR_NUM_DPB_OUT_OF_RANGE 74 -#define VIDC_1080P_ERROR_NULL_METADATA_INPUT_POINTER 77 -#define VIDC_1080P_ERROR_NULL_DPB_POINTER 78 -#define VIDC_1080P_ERROR_NULL_OTH_EXT_BUFADDR 79 -#define VIDC_1080P_ERROR_NULL_MV_POINTER 80 -#define VIDC_1080P_ERROR_DIVIDE_BY_ZERO 81 -#define VIDC_1080P_ERROR_BIT_STREAM_BUF_EXHAUST 82 -#define VIDC_1080P_ERROR_DESCRIPTOR_BUFFER_EMPTY 83 -#define VIDC_1080P_ERROR_DMA_TX_NOT_COMPLETE 84 -#define VIDC_1080P_ERROR_DESCRIPTOR_TABLE_ENTRY_INVALID 85 -#define VIDC_1080P_ERROR_MB_COEFF_NOT_DONE 86 -#define VIDC_1080P_ERROR_CODEC_SLICE_NOT_DONE 87 -#define VIDC_1080P_ERROR_VIDC_CORE_TIME_OUT 88 -#define VIDC_1080P_ERROR_VC1_BITPLANE_DECODE_ERR 89 -#define VIDC_1080P_ERROR_VSP_NOT_READY 90 -#define VIDC_1080P_ERROR_BUFFER_FULL_STATE 91 - -#define VIDC_1080P_ERROR_RESOLUTION_MISMATCH 112 -#define VIDC_1080P_ERROR_NV_QUANT_ERR 113 -#define VIDC_1080P_ERROR_SYNC_MARKER_ERR 114 -#define VIDC_1080P_ERROR_FEATURE_NOT_SUPPORTED 115 -#define VIDC_1080P_ERROR_MEM_CORRUPTION 116 -#define VIDC_1080P_ERROR_INVALID_REFERENCE_FRAME 117 -#define VIDC_1080P_ERROR_PICTURE_CODING_TYPE_ERR 118 -#define VIDC_1080P_ERROR_MV_RANGE_ERR 119 -#define VIDC_1080P_ERROR_PICTURE_STRUCTURE_ERR 120 -#define VIDC_1080P_ERROR_SLICE_ADDR_INVALID 121 -#define VIDC_1080P_ERROR_NON_PAIRED_FIELD_NOT_SUPPORTED 122 -#define VIDC_1080P_ERROR_NON_FRAME_DATA_RECEIVED 123 -#define VIDC_1080P_ERROR_NO_BUFFER_RELEASED_FROM_HOST 125 -#define VIDC_1080P_ERROR_NULL_FW_DEBUG_INFO_POINTER 126 -#define VIDC_1080P_ERROR_ALLOC_DEBUG_INFO_SIZE_INSUFFICIENT 127 -#define VIDC_1080P_ERROR_NALU_HEADER_ERROR 128 -#define VIDC_1080P_ERROR_SPS_PARSE_ERROR 129 -#define VIDC_1080P_ERROR_PPS_PARSE_ERROR 130 -#define VIDC_1080P_ERROR_SLICE_PARSE_ERROR 131 -#define VIDC_1080P_ERROR_NON_IDR_FRAME_TYPE 132 -#define VIDC_1080P_ERROR_SYNC_POINT_NOT_RECEIVED 171 - -#define VIDC_1080P_WARN_COMMAND_FLUSHED 145 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_NUM_CONCEAL_MB 150 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_QP 151 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_CONCEAL_MB 152 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_VC1_PARAM 153 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_SEI 154 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_VUI 155 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_EXTRA 156 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_DATA_NONE 157 -#define VIDC_1080P_WARN_FRAME_RATE_UNKNOWN 158 -#define VIDC_1080P_WARN_ASPECT_RATIO_UNKNOWN 159 -#define VIDC_1080P_WARN_COLOR_PRIMARIES_UNKNOWN 160 -#define VIDC_1080P_WARN_TRANSFER_CHAR_UNKNOWN 161 -#define VIDC_1080P_WARN_MATRIX_COEFF_UNKNOWN 162 -#define VIDC_1080P_WARN_NON_SEQ_SLICE_ADDR 163 -#define VIDC_1080P_WARN_BROKEN_LINK 164 -#define VIDC_1080P_WARN_FRAME_CONCEALED 165 -#define VIDC_1080P_WARN_PROFILE_UNKNOWN 166 -#define VIDC_1080P_WARN_LEVEL_UNKNOWN 167 -#define VIDC_1080P_WARN_BIT_RATE_NOT_SUPPORTED 168 -#define VIDC_1080P_WARN_COLOR_DIFF_FORMAT_NOT_SUPPORTED 169 -#define VIDC_1080P_WARN_NULL_EXTRA_METADATA_POINTER 170 -#define VIDC_1080P_WARN_DEBLOCKING_NOT_DONE 178 -#define VIDC_1080P_WARN_INCOMPLETE_FRAME 179 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_MB_INFO 180 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_SLICE_SIZE 181 -#define VIDC_1080P_WARN_RESOLUTION_WARNING 182 - -#define VIDC_1080P_WARN_NO_LONG_TERM_REFERENCE 183 -#define VIDC_1080P_WARN_NO_SPACE_MPEG2_DATA_DUMP 190 -#define VIDC_1080P_WARN_METADATA_NO_SPACE_MISSING_MB 191 - -#define VIDC_1080P_H264_ENC_TYPE_P 0 -#define VIDC_1080P_H264_ENC_TYPE_B 1 -#define VIDC_1080P_H264_ENC_TYPE_IDR 2 -#define VIDC_1080P_MP4_H263_ENC_TYPE_I 0 -#define VIDC_1080P_MP4_H263_ENC_TYPE_P 1 -#define VIDC_1080P_MP4_H263_ENC_TYPE_B 2 - -#define VIDC_1080P_MPEG4_LEVEL0 0 -#define VIDC_1080P_MPEG4_LEVEL0b 9 -#define VIDC_1080P_MPEG4_LEVEL1 1 -#define VIDC_1080P_MPEG4_LEVEL2 2 -#define VIDC_1080P_MPEG4_LEVEL3 3 -#define VIDC_1080P_MPEG4_LEVEL3b 7 -#define VIDC_1080P_MPEG4_LEVEL4 4 -#define VIDC_1080P_MPEG4_LEVEL4a 4 -#define VIDC_1080P_MPEG4_LEVEL5 5 -#define VIDC_1080P_MPEG4_LEVEL6 6 -#define VIDC_1080P_MPEG4_LEVEL7 7 - -#define VIDC_1080P_H264_LEVEL1 10 -#define VIDC_1080P_H264_LEVEL1b 9 -#define VIDC_1080P_H264_LEVEL1p1 11 -#define VIDC_1080P_H264_LEVEL1p2 12 -#define VIDC_1080P_H264_LEVEL1p3 13 -#define VIDC_1080P_H264_LEVEL2 20 -#define VIDC_1080P_H264_LEVEL2p1 21 -#define VIDC_1080P_H264_LEVEL2p2 22 -#define VIDC_1080P_H264_LEVEL3 30 -#define VIDC_1080P_H264_LEVEL3p1 31 -#define VIDC_1080P_H264_LEVEL3p2 32 -#define VIDC_1080P_H264_LEVEL4 40 -#define VIDC_1080P_H264_LEVEL5p1 51 -#define VIDC_1080P_H264_LEVEL_MAX VIDC_1080P_H264_LEVEL5p1 - -#define VIDC_1080P_H263_LEVEL10 10 -#define VIDC_1080P_H263_LEVEL20 20 -#define VIDC_1080P_H263_LEVEL30 30 -#define VIDC_1080P_H263_LEVEL40 40 -#define VIDC_1080P_H263_LEVEL45 45 -#define VIDC_1080P_H263_LEVEL50 50 -#define VIDC_1080P_H263_LEVEL60 60 -#define VIDC_1080P_H263_LEVEL70 70 - -#define VIDC_1080P_BUS_ERROR_HANDLER 0x01 -#define VIDC_1080P_ILLEVIDC_INSTRUCTION_HANDLER 0x02 -#define VIDC_1080P_TICK_HANDLER 0x04 -#define VIDC_1080P_TRAP_HANDLER 0x10 -#define VIDC_1080P_ALIGN_HANDLER 0x20 -#define VIDC_1080P_RANGE_HANDLER 0x40 -#define VIDC_1080P_DTLB_MISS_EXCEPTION_HANDLER 0x80 -#define VIDC_1080P_ITLB_MISS_EXCEPTION_HANDLER 0x100 -#define VIDC_1080P_DATA_PAGE_FAULT_EXCEPTION_HANDLER 0x200 -#define VIDC_1080P_INST_PAGE_FAULT_EXCEPTION_HANDLER 0x400 -#define VIDC_1080P_SLICE_BATCH_MAX_STRM_BFR 8 -#define VIDC_1080P_SLICE_BATCH_IN_SIZE(idx) (4 * sizeof(u32) + \ - idx * sizeof(u32)) -enum vidc_1080p_reset{ - VIDC_1080P_RESET_IN_SEQ_FIRST_STAGE = 0x0, - VIDC_1080P_RESET_IN_SEQ_SECOND_STAGE = 0x1, -}; -enum vidc_1080p_memory_access_method{ - VIDC_1080P_TILE_LINEAR = 0, - VIDC_1080P_TILE_16x16 = 2, - VIDC_1080P_TILE_64x32 = 3, - VIDC_1080P_TILE_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_host2risc_cmd{ - VIDC_1080P_HOST2RISC_CMD_EMPTY = 0, - VIDC_1080P_HOST2RISC_CMD_OPEN_CH = 1, - VIDC_1080P_HOST2RISC_CMD_CLOSE_CH = 2, - VIDC_1080P_HOST2RISC_CMD_SYS_INIT = 3, - VIDC_1080P_HOST2RISC_CMD_FLUSH_COMMMAND = 4, - VIDC_1080P_HOST2RISC_CMD_CONTINUE_ENC = 7, - VIDC_1080P_HOST2RISC_CMD_ABORT_ENC = 8, - VIDC_1080P_HOST2RISC_CMD_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_decode_p_cache_enable{ - VIDC_1080P_DECODE_PCACHE_ENABLE_P = 0, - VIDC_1080P_DECODE_PCACHE_ENABLE_B = 1, - VIDC_1080P_DECODE_PCACHE_ENABLE_PB = 2, - VIDC_1080P_DECODE_PCACHE_DISABLE = 3, - VIDC_1080P_DECODE_PCACHE_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_encode_p_cache_enable{ - VIDC_1080P_ENCODE_PCACHE_ENABLE = 0, - VIDC_1080P_ENCODE_PCACHE_DISABLE = 3, - VIDC_1080P_ENCODE_PCACHE_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_codec{ - VIDC_1080P_H264_DECODE = 0, - VIDC_1080P_VC1_DECODE = 1, - VIDC_1080P_MPEG4_DECODE = 2, - VIDC_1080P_MPEG2_DECODE = 3, - VIDC_1080P_H263_DECODE = 4, - VIDC_1080P_VC1_RCV_DECODE = 5, - VIDC_1080P_DIVX311_DECODE = 6, - VIDC_1080P_DIVX412_DECODE = 7, - VIDC_1080P_DIVX502_DECODE = 8, - VIDC_1080P_DIVX503_DECODE = 9, - VIDC_1080P_H264_ENCODE = 16, - VIDC_1080P_MPEG4_ENCODE = 17, - VIDC_1080P_H263_ENCODE = 18, - VIDC_1080P_CODEC_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_entropy_sel{ - VIDC_1080P_ENTROPY_SEL_CAVLC = 0, - VIDC_1080P_ENTROPY_SEL_CABAC = 1, - VIDC_1080P_ENTROPY_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_DBConfig{ - VIDC_1080P_DB_ALL_BLOCKING_BOUNDARY = 0, - VIDC_1080P_DB_DISABLE = 1, - VIDC_1080P_DB_SKIP_SLICE_BOUNDARY = 2, - VIDC_1080P_DB_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_MSlice_selection{ - VIDC_1080P_MSLICE_DISABLE = 0, - VIDC_1080P_MSLICE_BY_MB_COUNT = 1, - VIDC_1080P_MSLICE_BY_BYTE_COUNT = 3, - VIDC_1080P_MSLICE_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_display_status{ - VIDC_1080P_DISPLAY_STATUS_DECODE_ONLY = 0, - VIDC_1080P_DISPLAY_STATUS_DECODE_AND_DISPLAY = 1, - VIDC_1080P_DISPLAY_STATUS_DISPLAY_ONLY = 2, - VIDC_1080P_DISPLAY_STATUS_DPB_EMPTY = 3, - VIDC_1080P_DISPLAY_STATUS_NOOP = 4, - VIDC_1080P_DISPLAY_STATUS_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_display_coding{ - VIDC_1080P_DISPLAY_CODING_PROGRESSIVE_SCAN = 0, - VIDC_1080P_DISPLAY_CODING_INTERLACED = 1, - VIDC_1080P_DISPLAY_CODING_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_decode_frame{ - VIDC_1080P_DECODE_FRAMETYPE_NOT_CODED = 0, - VIDC_1080P_DECODE_FRAMETYPE_I = 1, - VIDC_1080P_DECODE_FRAMETYPE_P = 2, - VIDC_1080P_DECODE_FRAMETYPE_B = 3, - VIDC_1080P_DECODE_FRAMETYPE_OTHERS = 4, - VIDC_1080P_DECODE_FRAMETYPE_IDR = 5, - VIDC_1080P_DECODE_FRAMETYPE_32BIT = 0x7FFFFFFF -}; -enum vidc_1080P_decode_frame_correct_type { - VIDC_1080P_DECODE_NOT_CORRECT = 0, - VIDC_1080P_DECODE_CORRECT = 1, - VIDC_1080P_DECODE_APPROX_CORRECT = 2, - VIDC_1080P_DECODE_CORRECTTYPE_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_encode_frame{ - VIDC_1080P_ENCODE_FRAMETYPE_NOT_CODED = 0, - VIDC_1080P_ENCODE_FRAMETYPE_I = 1, - VIDC_1080P_ENCODE_FRAMETYPE_P = 2, - VIDC_1080P_ENCODE_FRAMETYPE_B = 3, - VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED = 4, - VIDC_1080P_ENCODE_FRAMETYPE_OTHERS = 5, - VIDC_1080P_ENCODE_FRAMETYPE_32BIT = 0x7FFFFFFF - -}; - -enum vidc_1080p_decode_idc_format { - VIDC_1080P_IDCFORMAT_MONOCHROME = 0, - VIDC_1080P_IDCFORMAT_420 = 1, - VIDC_1080P_IDCFORMAT_422 = 2, - VIDC_1080P_IDCFORMAT_444 = 3, - VIDC_1080P_IDCFORMAT_OTHERS = 4, - VIDC_1080P_IDCFORMAT_32BIT = 0x7FFFFFFF -}; - -#define VIDC_1080P_PROFILE_MPEG4_SIMPLE 0x00000000 -#define VIDC_1080P_PROFILE_MPEG4_ADV_SIMPLE 0x00000001 - -#define VIDC_1080P_PROFILE_H264_MAIN 0x00000000 -#define VIDC_1080P_PROFILE_H264_HIGH 0x00000001 -#define VIDC_1080P_PROFILE_H264_BASELINE 0x00000002 -#define VIDC_1080P_PROFILE_H264_CONSTRAINED_BASELINE 0x00000003 - - -enum vidc_1080p_decode{ - VIDC_1080P_DEC_TYPE_SEQ_HEADER = 0x00010000, - VIDC_1080P_DEC_TYPE_FRAME_DATA = 0x00020000, - VIDC_1080P_DEC_TYPE_LAST_FRAME_DATA = 0x00030000, - VIDC_1080P_DEC_TYPE_INIT_BUFFERS = 0x00040000, - VIDC_1080P_DEC_TYPE_FRAME_START_REALLOC = 0x00050000, - VIDC_1080P_DEC_TYPE_32BIT = 0x7FFFFFFF -}; -enum vidc_1080p_encode{ - VIDC_1080P_ENC_TYPE_SEQ_HEADER = 0x00010000, - VIDC_1080P_ENC_TYPE_FRAME_DATA = 0x00020000, - VIDC_1080P_ENC_TYPE_LAST_FRAME_DATA = 0x00030000, - VIDC_1080P_ENC_TYPE_SLICE_BATCH_START = 0x00070000, - VIDC_1080P_ENC_TYPE_32BIT = 0x7FFFFFFF -}; -struct vidc_1080p_dec_seq_start_param{ - u32 cmd_seq_num; - u32 inst_id; - u32 shared_mem_addr_offset; - u32 stream_buffer_addr_offset; - u32 stream_buffersize; - u32 stream_frame_size; - u32 descriptor_buffer_addr_offset; - u32 descriptor_buffer_size; -}; -struct vidc_1080p_dec_frame_start_param{ - u32 cmd_seq_num; - u32 inst_id; - u32 shared_mem_addr_offset; - u32 stream_buffer_addr_offset; - u32 stream_buffersize; - u32 stream_frame_size; - u32 descriptor_buffer_addr_offset; - u32 descriptor_buffer_size; - u32 release_dpb_bit_mask; - u32 dpb_count; - u32 dpb_flush; - u32 dmx_disable; - enum vidc_1080p_decode decode; -}; -struct vidc_1080p_dec_init_buffers_param{ - u32 cmd_seq_num; - u32 inst_id; - u32 shared_mem_addr_offset; - u32 dpb_count; - u32 dmx_disable; -}; -struct vidc_1080p_seq_hdr_info{ - u32 img_size_x; - u32 img_size_y; - u32 dec_frm_size; - u32 min_num_dpb; - u32 min_luma_dpb_size; - u32 min_chroma_dpb_size; - u32 profile; - u32 level; - u32 disp_progressive; - u32 disp_crop_exists; - u32 dec_progressive; - u32 dec_crop_exists; - u32 crop_right_offset; - u32 crop_left_offset; - u32 crop_bottom_offset; - u32 crop_top_offset; - u32 data_partition; -}; -struct vidc_1080p_enc_seq_start_param{ - u32 cmd_seq_num; - u32 inst_id; - u32 shared_mem_addr_offset; - u32 stream_buffer_addr_offset; - u32 stream_buffer_size; -}; -struct vidc_1080p_enc_frame_start_param{ - u32 cmd_seq_num; - u32 inst_id; - u32 shared_mem_addr_offset; - u32 current_y_addr_offset; - u32 current_c_addr_offset; - u32 stream_buffer_addr_offset; - u32 stream_buffer_size; - u32 intra_frame; - u32 input_flush; - u32 slice_enable; - u32 store_ltr0; - u32 store_ltr1; - u32 use_ltr0; - u32 use_ltr1; - enum vidc_1080p_encode encode; -}; -struct vidc_1080p_enc_frame_info{ - u32 enc_frame_size; - u32 enc_picture_count; - u32 enc_write_pointer; - u32 enc_luma_address; - u32 enc_chroma_address; - enum vidc_1080p_encode_frame enc_frame; - u32 meta_data_exists; -}; -struct vidc_1080p_enc_slice_batch_in_param { - u32 cmd_type; - u32 input_size; - u32 num_stream_buffer; - u32 stream_buffer_size; - u32 stream_buffer_addr_offset[VIDC_1080P_SLICE_BATCH_MAX_STRM_BFR]; -}; -struct vidc_1080p_enc_slice_info { - u32 stream_buffer_idx; - u32 stream_buffer_size; -}; -struct vidc_1080p_enc_slice_batch_out_param { - u32 cmd_type; - u32 output_size; - struct vidc_1080p_enc_slice_info slice_info - [VIDC_1080P_SLICE_BATCH_MAX_STRM_BFR]; -}; -struct vidc_1080p_dec_disp_info{ - u32 disp_resl_change; - u32 dec_resl_change; - u32 reconfig_flush_done; - u32 img_size_x; - u32 img_size_y; - u32 display_y_addr; - u32 display_c_addr; - u32 decode_y_addr; - u32 decode_c_addr; - u32 tag_top; - u32 pic_time_top; - u32 tag_bottom; - u32 pic_time_bottom; - u32 metadata_exists; - u32 disp_crop_exists; - u32 dec_crop_exists; - u32 crop_right_offset; - u32 crop_left_offset; - u32 crop_bottom_offset; - u32 crop_top_offset; - u32 input_bytes_consumed; - u32 input_is_interlace; - u32 input_frame_num; - enum vidc_1080p_display_status display_status; - enum vidc_1080p_display_status decode_status; - enum vidc_1080p_display_coding display_coding; - enum vidc_1080p_display_coding decode_coding; - enum vidc_1080P_decode_frame_correct_type display_correct; - enum vidc_1080P_decode_frame_correct_type decode_correct; - enum vidc_1080p_decode_frame input_frame; -}; -void vidc_1080p_do_sw_reset(enum vidc_1080p_reset init_flag); -void vidc_1080p_release_sw_reset(void); -void vidc_1080p_clear_interrupt(void); -void vidc_1080p_set_host2risc_cmd( - enum vidc_1080p_host2risc_cmd host2risc_command, - u32 host2risc_arg1, u32 host2risc_arg2, - u32 host2risc_arg3, u32 host2risc_arg4); -void vidc_1080p_get_risc2host_cmd(u32 *pn_risc2host_command, - u32 *pn_risc2host_arg1, u32 *pn_risc2host_arg2, - u32 *pn_risc2host_arg3, u32 *pn_risc2host_arg4); -void vidc_1080p_get_risc2host_cmd_status(u32 err_status, - u32 *dec_err_status, u32 *disp_err_status); -void vidc_1080p_clear_risc2host_cmd(void); -void vidc_1080p_get_fw_version(u32 *pn_fw_version); -void vidc_1080p_get_fw_status(u32 *pn_fw_status); -void vidc_1080p_init_memory_controller(u32 dram_base_addr_a, - u32 dram_base_addr_b); -void vidc_1080p_get_memory_controller_status(u32 *pb_mc_abusy, - u32 *pb_mc_bbusy); -void vidc_1080p_set_h264_decode_buffers(u32 dpb, u32 dec_vert_nb_mv_offset, - u32 dec_nb_ip_offset, u32 *pn_dpb_luma_offset, - u32 *pn_dpb_chroma_offset, u32 *pn_mv_buffer_offset); -void vidc_1080p_set_decode_recon_buffers(u32 recon_buffer, u32 *pn_dec_luma, - u32 *pn_dec_chroma); -void vidc_1080p_set_mpeg4_divx_decode_work_buffers(u32 nb_dcac_buffer_offset, - u32 upnb_mv_buffer_offset, u32 sub_anchor_buffer_offset, - u32 overlay_transform_buffer_offset, u32 stx_parser_buffer_offset); -void vidc_1080p_set_h263_decode_work_buffers(u32 nb_dcac_buffer_offset, - u32 upnb_mv_buffer_offset, u32 sub_anchor_buffer_offset, - u32 overlay_transform_buffer_offset); -void vidc_1080p_set_vc1_decode_work_buffers(u32 nb_dcac_buffer_offset, - u32 upnb_mv_buffer_offset, u32 sub_anchor_buffer_offset, - u32 overlay_transform_buffer_offset, u32 bitplain1Buffer_offset, - u32 bitplain2Buffer_offset, u32 bitplain3Buffer_offset); -void vidc_1080p_set_encode_recon_buffers(u32 recon_buffer, u32 *pn_enc_luma, - u32 *pn_enc_chroma); -void vidc_1080p_set_h264_encode_work_buffers(u32 up_row_mv_buffer_offset, - u32 direct_colzero_flag_buffer_offset, - u32 upper_intra_md_buffer_offset, - u32 upper_intra_pred_buffer_offset, u32 nbor_infor_buffer_offset, - u32 mb_info_offset); -void vidc_1080p_set_h263_encode_work_buffers(u32 up_row_mv_buffer_offset, - u32 up_row_inv_quanti_coeff_buffer_offset); -void vidc_1080p_set_mpeg4_encode_work_buffers(u32 skip_flag_buffer_offset, - u32 up_row_inv_quanti_coeff_buffer_offset, u32 upper_mv_offset); -void vidc_1080p_set_encode_frame_size(u32 hori_size, u32 vert_size); -void vidc_1080p_set_encode_profile_level(u32 encode_profile, u32 enc_level); -void vidc_1080p_set_encode_field_picture_structure(u32 enc_field_picture); -void vidc_1080p_set_decode_mpeg4_pp_filter(u32 lf_enables); -void vidc_1080p_set_decode_qp_save_control(u32 enable_q_pout); -void vidc_1080p_get_returned_channel_inst_id(u32 *pn_rtn_chid); -void vidc_1080p_clear_returned_channel_inst_id(void); -void vidc_1080p_get_decode_seq_start_result( - struct vidc_1080p_seq_hdr_info *seq_hdr_info); -void vidc_1080p_get_decoded_frame_size(u32 *pn_decoded_size); -void vidc_1080p_get_display_frame_result( - struct vidc_1080p_dec_disp_info *dec_disp_info); -void vidc_1080p_get_decode_frame( - enum vidc_1080p_decode_frame *pe_frame); -void vidc_1080p_get_decode_frame_result( - struct vidc_1080p_dec_disp_info *dec_disp_info); -void vidc_1080p_decode_seq_start_ch0( - struct vidc_1080p_dec_seq_start_param *param); -void vidc_1080p_decode_seq_start_ch1( - struct vidc_1080p_dec_seq_start_param *param); -void vidc_1080p_decode_init_buffers_ch0 - (struct vidc_1080p_dec_init_buffers_param *param); -void vidc_1080p_decode_init_buffers_ch1( - struct vidc_1080p_dec_init_buffers_param *param); -void vidc_1080p_decode_frame_start_ch0( - struct vidc_1080p_dec_frame_start_param *param); -void vidc_1080p_decode_frame_start_ch1( - struct vidc_1080p_dec_frame_start_param *param); -void vidc_1080p_set_dec_resolution_ch0(u32 width, u32 height); -void vidc_1080p_set_dec_resolution_ch1(u32 width, u32 height); -void vidc_1080p_get_encode_frame_info( - struct vidc_1080p_enc_frame_info *frame_info); -void vidc_1080p_encode_seq_start_ch0( - struct vidc_1080p_enc_seq_start_param *param); -void vidc_1080p_encode_seq_start_ch1( - struct vidc_1080p_enc_seq_start_param *param); -void vidc_1080p_encode_frame_start_ch0( - struct vidc_1080p_enc_frame_start_param *param); -void vidc_1080p_encode_frame_start_ch1( - struct vidc_1080p_enc_frame_start_param *param); -void vidc_1080p_encode_slice_batch_start_ch0( - struct vidc_1080p_enc_frame_start_param *param); -void vidc_1080p_encode_slice_batch_start_ch1( - struct vidc_1080p_enc_frame_start_param *param); -void vidc_1080p_set_encode_picture(u32 ifrm_ctrl, u32 number_b); -void vidc_1080p_set_encode_multi_slice_control( - enum vidc_1080p_MSlice_selection multiple_slice_selection, - u32 mslice_mb, u32 mslice_byte); -void vidc_1080p_set_encode_circular_intra_refresh(u32 cir_num); -void vidc_1080p_set_encode_input_frame_format( - enum vidc_1080p_memory_access_method memory_format); -void vidc_1080p_set_encode_padding_control(u32 pad_ctrl_on, - u32 cr_pad_val, u32 cb_pad_val, u32 luma_pad_val); -void vidc_1080p_encode_set_rc_config(u32 enable_frame_level_rc, - u32 enable_mb_level_rc_flag, u32 frame_qp); -void vidc_1080p_encode_set_frame_level_rc_params(u32 rc_frame_rate, - u32 target_bitrate, u32 reaction_coeff); -void vidc_1080p_encode_set_qp_params(u32 max_qp, u32 min_qp); -void vidc_1080p_encode_set_mb_level_rc_params(u32 disable_dark_region_as_flag, - u32 disable_smooth_region_as_flag , u32 disable_static_region_as_flag, - u32 disable_activity_region_flag); -void vidc_1080p_get_qp(u32 *pn_frame_qp); -void vidc_1080p_set_h264_encode_entropy( - enum vidc_1080p_entropy_sel entropy_sel); -void vidc_1080p_set_h264_encode_loop_filter( - enum vidc_1080p_DBConfig db_config, u32 slice_alpha_offset, - u32 slice_beta_offset); -void vidc_1080p_set_h264_encoder_p_frame_ref_count(u32 max_reference); -void vidc_1080p_set_h264_encode_8x8transform_control(u32 enable_8x8transform); -void vidc_1080p_set_mpeg4_encode_quarter_pel_control( - u32 enable_mpeg4_quarter_pel); -void vidc_1080p_set_device_base_addr(u8 *mapped_va); -void vidc_1080p_get_intra_bias(u32 *intra_bias); -void vidc_1080p_set_intra_bias(u32 intra_bias); -void vidc_1080p_get_bi_directional_bias(u32 *bi_directional_bias); -void vidc_1080p_set_bi_directional_bias(u32 bi_directional_bias); -void vidc_1080p_get_encoder_sequence_header_size(u32 *seq_header_size); -void vidc_1080p_get_intermedia_stage_debug_counter( - u32 *intermediate_stage_counter); -void vidc_1080p_get_exception_status(u32 *exception_status); -void vidc_1080p_frame_start_realloc(u32 instance_id); -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vidc_hwio.h b/drivers/video/msm/vidc/1080p/ddl/vidc_hwio.h deleted file mode 100644 index d63a45bb420424630d80f9bc66cbe110d9ec97aa..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vidc_hwio.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (c) 2010, 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 _VIDC_HWIO_H_ -#define _VIDC_HWIO_H_ - -#include "vidc_hwio_reg.h" - -#ifdef VIDC_REGISTER_LOG -#define VIDC_REG_OUT(x...) printk(KERN_DEBUG x) -#define VIDC_REG_IN(x...) printk(KERN_DEBUG x) -#else -#define VIDC_REG_OUT(x...) -#define VIDC_REG_IN(x...) -#endif - -#define __inpdw(port) __raw_readl(port) -#define __outpdw(port, val) __raw_writel(val, port) - -#define in_dword(addr) (__inpdw(addr)) -#define in_dword_masked(addr, mask) (__inpdw(addr) & (mask)) -#define out_dword(addr, val) __outpdw(addr, val) - -#define out_dword_masked(io, mask, val, shadow) \ -do { \ - shadow = (shadow & (u32)(~(mask))) | ((u32)((val) & (mask))); \ - out_dword(io, shadow); \ -} while (0) -#define out_dword_masked_ns(io, mask, val, current_reg_content) \ - out_dword(io, ((current_reg_content & (u32)(~(mask))) | \ - ((u32)((val) & (mask))))) - -#define HWIO_IN(hwiosym) HWIO_##hwiosym##_IN -#define HWIO_INI(hwiosym, index) HWIO_##hwiosym##_INI(index) -#define HWIO_INM(hwiosym, mask) HWIO_##hwiosym##_INM(mask) -#define HWIO_INF(hwiosym, field) (HWIO_INM(hwiosym, \ - HWIO_FMSK(hwiosym, field)) >> HWIO_SHFT(hwiosym, field)) - -#define HWIO_OUT(hwiosym, val) HWIO_##hwiosym##_OUT(val) -#define HWIO_OUTI(hwiosym, index, val) HWIO_##hwiosym##_OUTI(index, val) -#define HWIO_OUTM(hwiosym, mask, val) HWIO_##hwiosym##_OUTM(mask, val) -#define HWIO_OUTF(hwiosym, field, val) HWIO_OUTM(hwiosym, \ - HWIO_FMSK(hwiosym, field), (u32)(val) << HWIO_SHFT(hwiosym, field)) - -#define HWIO_SHFT(hwio_regsym, hwio_fldsym) \ - HWIO_##hwiosym##_##hwiofldsym##_SHFT -#define HWIO_FMSK(hwio_regsym, hwio_fldsym) \ - HWIO_##hwiosym##_##hwiofldsym##_BMSK - -#define VIDC_SETFIELD(val, shift, mask) \ - (((val) << (shift)) & (mask)) -#define VIDC_GETFIELD(val, mask, shift) \ - (((val) & (mask)) >> (shift)) - -#define VIDC_HWIO_OUT(hwiosym, val) \ -do { \ - VIDC_REG_OUT("\n(0x%x:"#hwiosym"=0x%x)", \ - HWIO_##hwiosym##_ADDR - VIDC_BASE_PTR, val); \ - mb(); \ - HWIO_OUT(hwiosym, val); \ -} while (0) -#define VIDC_HWIO_OUTI(hwiosym, index, val) \ -do { \ - VIDC_REG_OUT("\n(0x%x:"#hwiosym"(%d)=0x%x)", \ - HWIO_##hwiosym##_ADDR(index) - VIDC_BASE_PTR, index, val); \ - mb(); \ - HWIO_OUTI(hwiosym, index, val); \ -} while (0) -#define VIDC_HWIO_OUTF(hwiosym, field, val) \ -do { \ - VIDC_REG_OUT("\n(0x%x:"#hwiosym":0x%x:=0x%x)" , \ - HWIO_##hwiosym##_ADDR - VIDC_BASE_PTR, \ - HWIO_##hwiosym##_##field##_BMSK, val) \ - mb(); \ - HWIO_OUTF(hwiosym, field, val); \ -} while (0) -#define VIDC_OUT_DWORD(addr, val) \ -do { \ - VIDC_REG_OUT("\n(0x%x:"#addr"=0x%x)", \ - addr - VIDC_BASE_PTR, val); \ - mb(); \ - out_dword(addr, val); \ -} while (0) -#define VIDC_HWIO_IN(hwiosym, pval) \ -do { \ - mb(); \ - *pval = (u32) HWIO_IN(hwiosym); \ - VIDC_REG_IN("\n(0x%x:"#hwiosym"=0x%x)", \ - HWIO_##hwiosym##_ADDR - VIDC_BASE_PTR, *pval);\ -} while (0) -#define VIDC_HWIO_INI(hwiosym, index, pval) \ -do { \ - mb(); \ - *pval = (u32) HWIO_INI(hwiosym, index); \ - VIDC_REG_IN("(0x%x:"#hwiosym"(%d)==0x%x)", \ - HWIO_##hwiosym##_ADDR(index) - VIDC_BASE_PTR, index, *pval); \ -} while (0) -#define VIDC_HWIO_INF(hwiosym, mask, pval) \ -do { \ - mb(); \ - *pval = HWIO_INF(hwiosym, mask); \ - VIDC_REG_IN("\n(0x%x:"#hwiosym"=0x%x)", \ - HWIO_##hwiosym##_ADDR - VIDC_BASE_PTR, *pval); \ -} while (0) -#endif diff --git a/drivers/video/msm/vidc/1080p/ddl/vidc_hwio_reg.h b/drivers/video/msm/vidc/1080p/ddl/vidc_hwio_reg.h deleted file mode 100644 index 41517bfff1d15e07d33b7c974a0c9f1172433b48..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vidc_hwio_reg.h +++ /dev/null @@ -1,4543 +0,0 @@ -/* Copyright (c) 2010, 2013, 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 _VIDC_HWIO_REG_H_ -#define _VIDC_HWIO_REG_H_ - -#include -#include -#include "vidc.h" - -extern u8 *VIDC_BASE_PTR; - -#define VIDC_BASE VIDC_BASE_PTR - -#define VIDC_BLACKBIRD_REG_BASE (VIDC_BASE + 0x00000000) -#define VIDC_BLACKBIRD_REG_BASE_PHYS 0x04400000 - -#define HWIO_REG_557899_ADDR (VIDC_BLACKBIRD_REG_BASE + 00000000) -#define HWIO_REG_557899_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 00000000) -#define HWIO_REG_557899_RMSK 0x3ff -#define HWIO_REG_557899_SHFT 0 -#define HWIO_REG_557899_IN in_dword_masked(HWIO_REG_557899_ADDR,\ - HWIO_REG_557899_RMSK) -#define HWIO_REG_557899_INM(m) in_dword_masked(HWIO_REG_557899_ADDR, m) -#define HWIO_REG_557899_OUT(v) out_dword(HWIO_REG_557899_ADDR, v) -#define HWIO_REG_557899_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_557899_ADDR, m, v, HWIO_REG_557899_IN); -#define HWIO_REG_557899_RSTN_RG_MPEG2_BMSK 0x200 -#define HWIO_REG_557899_RSTN_RG_MPEG2_SHFT 0x9 -#define HWIO_REG_557899_RSTN_RG_MPEG4_BMSK 0x100 -#define HWIO_REG_557899_RSTN_RG_MPEG4_SHFT 0x8 -#define HWIO_REG_557899_RSTN_RG_VC1_BMSK 0x80 -#define HWIO_REG_557899_RSTN_RG_VC1_SHFT 0x7 -#define HWIO_REG_557899_RSTN_RG_H264_BMSK 0x40 -#define HWIO_REG_557899_RSTN_RG_H264_SHFT 0x6 -#define HWIO_REG_557899_RSTN_RG_COMMON_BMSK 0x20 -#define HWIO_REG_557899_RSTN_RG_COMMON_SHFT 0x5 -#define HWIO_REG_557899_RSTN_DMX_BMSK 0x10 -#define HWIO_REG_557899_RSTN_DMX_SHFT 0x4 -#define HWIO_REG_557899_RSTN_VI_BMSK 0x8 -#define HWIO_REG_557899_RSTN_VI_SHFT 0x3 -#define HWIO_REG_557899_RSTN_VIDCCORE_BMSK 0x4 -#define HWIO_REG_557899_RSTN_VIDCCORE_SHFT 0x2 -#define HWIO_REG_557899_RSTN_MC_BMSK 0x2 -#define HWIO_REG_557899_RSTN_MC_SHFT 0x1 -#define HWIO_REG_557899_RSTN_RISC_BMSK 0x1 -#define HWIO_REG_557899_RSTN_RISC_SHFT 0 - -#define HWIO_REG_575377_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000008) -#define HWIO_REG_575377_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000008) -#define HWIO_REG_575377_RMSK 0x1 -#define HWIO_REG_575377_SHFT 0 -#define HWIO_REG_575377_IN in_dword_masked(\ - HWIO_REG_575377_ADDR, HWIO_REG_575377_RMSK) -#define HWIO_REG_575377_INM(m) \ - in_dword_masked(HWIO_REG_575377_ADDR, m) -#define HWIO_REG_575377_OUT(v) \ - out_dword(HWIO_REG_575377_ADDR, v) -#define HWIO_REG_575377_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_575377_ADDR, m, v, HWIO_REG_575377_IN); -#define HWIO_REG_575377_INTERRUPT_BMSK 0x1 -#define HWIO_REG_575377_INTERRUPT_SHFT 0 - -#define HWIO_REG_611794_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000030) -#define HWIO_REG_611794_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000030) -#define HWIO_REG_611794_RMSK 0xffffffff -#define HWIO_REG_611794_SHFT 0 -#define HWIO_REG_611794_IN in_dword_masked(\ - HWIO_REG_611794_ADDR, HWIO_REG_611794_RMSK) -#define HWIO_REG_611794_INM(m) \ - in_dword_masked(HWIO_REG_611794_ADDR, m) -#define HWIO_REG_611794_OUT(v) \ - out_dword(HWIO_REG_611794_ADDR, v) -#define HWIO_REG_611794_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_611794_ADDR, m, v,\ - HWIO_REG_611794_IN); -#define HWIO_REG_611794_HOST2RISC_COMMAND_BMSK 0xffffffff -#define HWIO_REG_611794_HOST2RISC_COMMAND_SHFT 0 - -#define HWIO_REG_356340_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000034) -#define HWIO_REG_356340_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000034) -#define HWIO_REG_356340_RMSK 0xffffffff -#define HWIO_REG_356340_SHFT 0 -#define HWIO_REG_356340_IN in_dword_masked(\ - HWIO_REG_356340_ADDR, HWIO_REG_356340_RMSK) -#define HWIO_REG_356340_INM(m) \ - in_dword_masked(HWIO_REG_356340_ADDR, m) -#define HWIO_REG_356340_OUT(v) \ - out_dword(HWIO_REG_356340_ADDR, v) -#define HWIO_REG_356340_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_356340_ADDR, m, v, HWIO_REG_356340_IN); -#define HWIO_REG_356340_HOST2RISC_ARG1_BMSK 0xffffffff -#define HWIO_REG_356340_HOST2RISC_ARG1_SHFT 0 - -#define HWIO_REG_899023_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000038) -#define HWIO_REG_899023_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000038) -#define HWIO_REG_899023_RMSK 0xffffffff -#define HWIO_REG_899023_SHFT 0 -#define HWIO_REG_899023_IN in_dword_masked(\ - HWIO_REG_899023_ADDR, HWIO_REG_899023_RMSK) -#define HWIO_REG_899023_INM(m) \ - in_dword_masked(HWIO_REG_899023_ADDR, m) -#define HWIO_REG_899023_OUT(v) \ - out_dword(HWIO_REG_899023_ADDR, v) -#define HWIO_REG_899023_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_899023_ADDR, m, v, HWIO_REG_899023_IN); -#define HWIO_REG_899023_HOST2RISC_ARG2_BMSK 0xffffffff -#define HWIO_REG_899023_HOST2RISC_ARG2_SHFT 0 - -#define HWIO_REG_987762_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000003c) -#define HWIO_REG_987762_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000003c) -#define HWIO_REG_987762_RMSK 0xffffffff -#define HWIO_REG_987762_SHFT 0 -#define HWIO_REG_987762_IN in_dword_masked(\ - HWIO_REG_987762_ADDR, HWIO_REG_987762_RMSK) -#define HWIO_REG_987762_INM(m) \ - in_dword_masked(HWIO_REG_987762_ADDR, m) -#define HWIO_REG_987762_OUT(v) \ - out_dword(HWIO_REG_987762_ADDR, v) -#define HWIO_REG_987762_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_987762_ADDR, m, v, HWIO_REG_987762_IN); -#define HWIO_REG_987762_HOST2RISC_ARG3_BMSK 0xffffffff -#define HWIO_REG_987762_HOST2RISC_ARG3_SHFT 0 - -#define HWIO_REG_544000_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000040) -#define HWIO_REG_544000_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000040) -#define HWIO_REG_544000_RMSK 0xffffffff -#define HWIO_REG_544000_SHFT 0 -#define HWIO_REG_544000_IN in_dword_masked(\ - HWIO_REG_544000_ADDR, HWIO_REG_544000_RMSK) -#define HWIO_REG_544000_INM(m) \ - in_dword_masked(HWIO_REG_544000_ADDR, m) -#define HWIO_REG_544000_OUT(v) \ - out_dword(HWIO_REG_544000_ADDR, v) -#define HWIO_REG_544000_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_544000_ADDR, m, v, HWIO_REG_544000_IN); -#define HWIO_REG_544000_HOST2RISC_ARG4_BMSK 0xffffffff -#define HWIO_REG_544000_HOST2RISC_ARG4_SHFT 0 - -#define HWIO_REG_695082_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000044) -#define HWIO_REG_695082_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000044) -#define HWIO_REG_695082_RMSK 0xffffffff -#define HWIO_REG_695082_SHFT 0 -#define HWIO_REG_695082_IN in_dword_masked(\ - HWIO_REG_695082_ADDR, HWIO_REG_695082_RMSK) -#define HWIO_REG_695082_INM(m) \ - in_dword_masked(HWIO_REG_695082_ADDR, m) -#define HWIO_REG_695082_OUT(v) \ - out_dword(HWIO_REG_695082_ADDR, v) -#define HWIO_REG_695082_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_695082_ADDR, m, v, HWIO_REG_695082_IN); -#define HWIO_REG_695082_RISC2HOST_COMMAND_BMSK 0xffffffff -#define HWIO_REG_695082_RISC2HOST_COMMAND_SHFT 0 - -#define HWIO_REG_156596_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000048) -#define HWIO_REG_156596_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000048) -#define HWIO_REG_156596_RMSK 0xffffffff -#define HWIO_REG_156596_SHFT 0 -#define HWIO_REG_156596_IN in_dword_masked(\ - HWIO_REG_156596_ADDR, HWIO_REG_156596_RMSK) -#define HWIO_REG_156596_INM(m) \ - in_dword_masked(HWIO_REG_156596_ADDR, m) -#define HWIO_REG_156596_OUT(v) \ - out_dword(HWIO_REG_156596_ADDR, v) -#define HWIO_REG_156596_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_156596_ADDR, m, v, HWIO_REG_156596_IN); -#define HWIO_REG_156596_REG_156596_BMSK 0xffffffff -#define HWIO_REG_156596_REG_156596_SHFT 0 - -#define HWIO_REG_222292_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000004c) -#define HWIO_REG_222292_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000004c) -#define HWIO_REG_222292_RMSK 0xffffffff -#define HWIO_REG_222292_SHFT 0 -#define HWIO_REG_222292_IN in_dword_masked(\ - HWIO_REG_222292_ADDR, HWIO_REG_222292_RMSK) -#define HWIO_REG_222292_INM(m) \ - in_dword_masked(HWIO_REG_222292_ADDR, m) -#define HWIO_REG_222292_OUT(v) \ - out_dword(HWIO_REG_222292_ADDR, v) -#define HWIO_REG_222292_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_222292_ADDR, m, v, HWIO_REG_222292_IN); -#define HWIO_REG_222292_REG_222292_BMSK 0xffffffff -#define HWIO_REG_222292_REG_222292_SHFT 0 - -#define HWIO_REG_790962_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000050) -#define HWIO_REG_790962_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000050) -#define HWIO_REG_790962_RMSK 0xffffffff -#define HWIO_REG_790962_SHFT 0 -#define HWIO_REG_790962_IN in_dword_masked(\ - HWIO_REG_790962_ADDR, HWIO_REG_790962_RMSK) -#define HWIO_REG_790962_INM(m) \ - in_dword_masked(HWIO_REG_790962_ADDR, m) -#define HWIO_REG_790962_OUT(v) \ - out_dword(HWIO_REG_790962_ADDR, v) -#define HWIO_REG_790962_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_790962_ADDR, m, v, HWIO_REG_790962_IN); -#define HWIO_REG_790962_REG_790962_BMSK 0xffffffff -#define HWIO_REG_790962_REG_790962_SHFT 0 - -#define HWIO_REG_679882_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000054) -#define HWIO_REG_679882_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000054) -#define HWIO_REG_679882_RMSK 0xffffffff -#define HWIO_REG_679882_SHFT 0 -#define HWIO_REG_679882_IN in_dword_masked(\ - HWIO_REG_679882_ADDR, HWIO_REG_679882_RMSK) -#define HWIO_REG_679882_INM(m) \ - in_dword_masked(HWIO_REG_679882_ADDR, m) -#define HWIO_REG_679882_OUT(v) \ - out_dword(HWIO_REG_679882_ADDR, v) -#define HWIO_REG_679882_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_679882_ADDR, m, v, HWIO_REG_679882_IN); -#define HWIO_REG_679882_REG_679882_BMSK 0xffffffff -#define HWIO_REG_679882_REG_679882_SHFT 0 - -#define HWIO_REG_653206_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000058) -#define HWIO_REG_653206_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000058) -#define HWIO_REG_653206_RMSK 0xffffff -#define HWIO_REG_653206_SHFT 0 -#define HWIO_REG_653206_IN in_dword_masked(\ - HWIO_REG_653206_ADDR, HWIO_REG_653206_RMSK) -#define HWIO_REG_653206_INM(m) \ - in_dword_masked(HWIO_REG_653206_ADDR, m) -#define HWIO_REG_653206_YEAR_BMSK 0xff0000 -#define HWIO_REG_653206_YEAR_SHFT 0x10 -#define HWIO_REG_653206_MONTH_BMSK 0xff00 -#define HWIO_REG_653206_MONTH_SHFT 0x8 -#define HWIO_REG_653206_DAY_BMSK 0xff -#define HWIO_REG_653206_DAY_SHFT 0 - -#define HWIO_REG_805993_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000064) -#define HWIO_REG_805993_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000064) -#define HWIO_REG_805993_RMSK 0xffffffff -#define HWIO_REG_805993_SHFT 0 -#define HWIO_REG_805993_IN in_dword_masked(\ - HWIO_REG_805993_ADDR, HWIO_REG_805993_RMSK) -#define HWIO_REG_805993_INM(m) \ - in_dword_masked(HWIO_REG_805993_ADDR, m) -#define HWIO_REG_805993_INTERMEDIATE_STAGE_COUNTER_BMSK 0xffffffff -#define HWIO_REG_805993_INTERMEDIATE_STAGE_COUNTER_SHFT 0 - -#define HWIO_REG_493355_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000068) -#define HWIO_REG_493355_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000068) -#define HWIO_REG_493355_RMSK 0xffffffff -#define HWIO_REG_493355_SHFT 0 -#define HWIO_REG_493355_IN in_dword_masked(\ - HWIO_REG_493355_ADDR, HWIO_REG_493355_RMSK) -#define HWIO_REG_493355_INM(m) \ - in_dword_masked(HWIO_REG_493355_ADDR, m) -#define HWIO_REG_493355_EXCEPTION_STATUS_BMSK 0xffffffff -#define HWIO_REG_493355_EXCEPTION_STATUS_SHFT 0 - -#define HWIO_REG_350619_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000080) -#define HWIO_REG_350619_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000080) -#define HWIO_REG_350619_RMSK 0x1 -#define HWIO_REG_350619_SHFT 0 -#define HWIO_REG_350619_IN in_dword_masked(\ - HWIO_REG_350619_ADDR, HWIO_REG_350619_RMSK) -#define HWIO_REG_350619_INM(m) \ - in_dword_masked(HWIO_REG_350619_ADDR, m) -#define HWIO_REG_350619_FIRMWARE_STATUS_BMSK 0x1 -#define HWIO_REG_350619_FIRMWARE_STATUS_SHFT 0 - -#define HWIO_REG_64440_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000508) -#define HWIO_REG_64440_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000508) -#define HWIO_REG_64440_RMSK 0xfffe0000 -#define HWIO_REG_64440_SHFT 0 -#define HWIO_REG_64440_IN in_dword_masked(\ - HWIO_REG_64440_ADDR, HWIO_REG_64440_RMSK) -#define HWIO_REG_64440_INM(m) \ - in_dword_masked(HWIO_REG_64440_ADDR, m) -#define HWIO_REG_64440_OUT(v) \ - out_dword(HWIO_REG_64440_ADDR, v) -#define HWIO_REG_64440_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_64440_ADDR, m, v,\ - HWIO_REG_64440_IN); -#define HWIO_REG_64440_MC_DRAMBASE_ADDR_BMSK 0xfffe0000 -#define HWIO_REG_64440_MC_DRAMBASE_ADDR_SHFT 0x11 - -#define HWIO_REG_675915_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000050c) -#define HWIO_REG_675915_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000050c) -#define HWIO_REG_675915_RMSK 0xfffe0000 -#define HWIO_REG_675915_SHFT 0 -#define HWIO_REG_675915_IN in_dword_masked(\ - HWIO_REG_675915_ADDR, HWIO_REG_675915_RMSK) -#define HWIO_REG_675915_INM(m) \ - in_dword_masked(HWIO_REG_675915_ADDR, m) -#define HWIO_REG_675915_OUT(v) \ - out_dword(HWIO_REG_675915_ADDR, v) -#define HWIO_REG_675915_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_675915_ADDR, m, v,\ - HWIO_REG_675915_IN); -#define HWIO_REG_675915_MC_DRAMBASE_ADDR_BMSK 0xfffe0000 -#define HWIO_REG_675915_MC_DRAMBASE_ADDR_SHFT 0x11 - -#define HWIO_REG_399911_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000510) -#define HWIO_REG_399911_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000510) -#define HWIO_REG_399911_RMSK 0x3 -#define HWIO_REG_399911_SHFT 0 -#define HWIO_REG_399911_IN in_dword_masked(\ - HWIO_REG_399911_ADDR, HWIO_REG_399911_RMSK) -#define HWIO_REG_399911_INM(m) in_dword_masked(HWIO_REG_399911_ADDR, m) -#define HWIO_REG_399911_MC_BUSY_B_BMSK 0x2 -#define HWIO_REG_399911_MC_BUSY_B_SHFT 0x1 -#define HWIO_REG_399911_MC_BUSY_A_BMSK 0x1 -#define HWIO_REG_399911_MC_BUSY_A_SHFT 0 - -#define HWIO_REG_515200_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000600) -#define HWIO_REG_515200_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000600) -#define HWIO_REG_515200_RMSK 0x1ffff -#define HWIO_REG_515200_SHFT 0 -#define HWIO_REG_515200_IN in_dword_masked(\ - HWIO_REG_515200_ADDR, HWIO_REG_515200_RMSK) -#define HWIO_REG_515200_INM(m) \ - in_dword_masked(HWIO_REG_515200_ADDR, m) -#define HWIO_REG_515200_OUT(v) \ - out_dword(HWIO_REG_515200_ADDR, v) -#define HWIO_REG_515200_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_515200_ADDR, m, v,\ - HWIO_REG_515200_IN); -#define HWIO_REG_515200_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_515200_BASE_ADDR_SHFT 0 - -#define HWIO_REG_29510_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000604) -#define HWIO_REG_29510_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000604) -#define HWIO_REG_29510_RMSK 0x1ffff -#define HWIO_REG_29510_SHFT 0 -#define HWIO_REG_29510_IN in_dword_masked(\ - HWIO_REG_29510_ADDR, HWIO_REG_29510_RMSK) -#define HWIO_REG_29510_INM(m) \ - in_dword_masked(HWIO_REG_29510_ADDR, m) -#define HWIO_REG_29510_OUT(v) \ - out_dword(HWIO_REG_29510_ADDR, v) -#define HWIO_REG_29510_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_29510_ADDR, m, v,\ - HWIO_REG_29510_IN); -#define HWIO_REG_29510_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_29510_BASE_ADDR_SHFT 0 - -#define HWIO_REG_256132_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000608) -#define HWIO_REG_256132_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000608) -#define HWIO_REG_256132_RMSK 0x1ffff -#define HWIO_REG_256132_SHFT 0 -#define HWIO_REG_256132_IN in_dword_masked(\ - HWIO_REG_256132_ADDR, HWIO_REG_256132_RMSK) -#define HWIO_REG_256132_INM(m) \ - in_dword_masked(HWIO_REG_256132_ADDR, m) -#define HWIO_REG_256132_OUT(v) \ - out_dword(HWIO_REG_256132_ADDR, v) -#define HWIO_REG_256132_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_256132_ADDR, m, v,\ - HWIO_REG_256132_IN); -#define HWIO_REG_256132_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_256132_BASE_ADDR_SHFT 0 - -#define HWIO_REG_885152_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000060c) -#define HWIO_REG_885152_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000060c) -#define HWIO_REG_885152_RMSK 0x1ffff -#define HWIO_REG_885152_SHFT 0 -#define HWIO_REG_885152_IN in_dword_masked(\ - HWIO_REG_885152_ADDR, HWIO_REG_885152_RMSK) -#define HWIO_REG_885152_INM(m) \ - in_dword_masked(HWIO_REG_885152_ADDR, m) -#define HWIO_REG_885152_OUT(v) \ - out_dword(HWIO_REG_885152_ADDR, v) -#define HWIO_REG_885152_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_885152_ADDR, m, v,\ - HWIO_REG_885152_IN); -#define HWIO_REG_885152_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_885152_BASE_ADDR_SHFT 0 - -#define HWIO_REG_69832_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000610) -#define HWIO_REG_69832_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000610) -#define HWIO_REG_69832_RMSK 0x1ffff -#define HWIO_REG_69832_SHFT 0 -#define HWIO_REG_69832_IN in_dword_masked(\ - HWIO_REG_69832_ADDR, HWIO_REG_69832_RMSK) -#define HWIO_REG_69832_INM(m) \ - in_dword_masked(HWIO_REG_69832_ADDR, m) -#define HWIO_REG_69832_OUT(v) \ - out_dword(HWIO_REG_69832_ADDR, v) -#define HWIO_REG_69832_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_69832_ADDR, m, v,\ - HWIO_REG_69832_IN); -#define HWIO_REG_69832_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_69832_BASE_ADDR_SHFT 0 - -#define HWIO_REG_686205_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000614) -#define HWIO_REG_686205_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000614) -#define HWIO_REG_686205_RMSK 0x1ffff -#define HWIO_REG_686205_SHFT 0 -#define HWIO_REG_686205_IN in_dword_masked(\ - HWIO_REG_686205_ADDR, HWIO_REG_686205_RMSK) -#define HWIO_REG_686205_INM(m) \ - in_dword_masked(HWIO_REG_686205_ADDR, m) -#define HWIO_REG_686205_OUT(v) \ - out_dword(HWIO_REG_686205_ADDR, v) -#define HWIO_REG_686205_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_686205_ADDR, m, v,\ - HWIO_REG_686205_IN); -#define HWIO_REG_686205_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_686205_BASE_ADDR_SHFT 0 - -#define HWIO_REG_728036_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000618) -#define HWIO_REG_728036_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000618) -#define HWIO_REG_728036_RMSK 0x1ffff -#define HWIO_REG_728036_SHFT 0 -#define HWIO_REG_728036_IN in_dword_masked(\ - HWIO_REG_728036_ADDR, HWIO_REG_728036_RMSK) -#define HWIO_REG_728036_INM(m) \ - in_dword_masked(HWIO_REG_728036_ADDR, m) -#define HWIO_REG_728036_OUT(v) \ - out_dword(HWIO_REG_728036_ADDR, v) -#define HWIO_REG_728036_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_728036_ADDR, m, v,\ - HWIO_REG_728036_IN); -#define HWIO_REG_728036_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_728036_BASE_ADDR_SHFT 0 - -#define HWIO_REG_294579_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000061c) -#define HWIO_REG_294579_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000061c) -#define HWIO_REG_294579_RMSK 0x1ffff -#define HWIO_REG_294579_SHFT 0 -#define HWIO_REG_294579_IN in_dword_masked(\ - HWIO_REG_294579_ADDR, HWIO_REG_294579_RMSK) -#define HWIO_REG_294579_INM(m) \ - in_dword_masked(HWIO_REG_294579_ADDR, m) -#define HWIO_REG_294579_OUT(v) \ - out_dword(HWIO_REG_294579_ADDR, v) -#define HWIO_REG_294579_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_294579_ADDR, m, v,\ - HWIO_REG_294579_IN); -#define HWIO_REG_294579_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_294579_BASE_ADDR_SHFT 0 - -#define HWIO_REG_61427_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000620) -#define HWIO_REG_61427_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000620) -#define HWIO_REG_61427_RMSK 0x1ffff -#define HWIO_REG_61427_SHFT 0 -#define HWIO_REG_61427_IN in_dword_masked(\ - HWIO_REG_61427_ADDR, HWIO_REG_61427_RMSK) -#define HWIO_REG_61427_INM(m) \ - in_dword_masked(HWIO_REG_61427_ADDR, m) -#define HWIO_REG_61427_OUT(v) \ - out_dword(HWIO_REG_61427_ADDR, v) -#define HWIO_REG_61427_OUTM(m , v) out_dword_masked_ns(\ - HWIO_REG_61427_ADDR, m, v,\ - HWIO_REG_61427_IN); -#define HWIO_REG_61427_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_61427_BASE_ADDR_SHFT 0 - -#define HWIO_REG_578196_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000624) -#define HWIO_REG_578196_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000624) -#define HWIO_REG_578196_RMSK 0x1ffff -#define HWIO_REG_578196_SHFT 0 -#define HWIO_REG_578196_IN in_dword_masked(\ - HWIO_REG_578196_ADDR, HWIO_REG_578196_RMSK) -#define HWIO_REG_578196_INM(m) \ - in_dword_masked(HWIO_REG_578196_ADDR, m) -#define HWIO_REG_578196_OUT(v) \ - out_dword(HWIO_REG_578196_ADDR, v) -#define HWIO_REG_578196_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_578196_ADDR, m, v,\ - HWIO_REG_578196_IN); -#define HWIO_REG_578196_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_578196_BASE_ADDR_SHFT 0 - -#define HWIO_REG_408588_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000628) -#define HWIO_REG_408588_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000628) -#define HWIO_REG_408588_RMSK 0x1ffff -#define HWIO_REG_408588_SHFT 0 -#define HWIO_REG_408588_IN in_dword_masked(\ - HWIO_REG_408588_ADDR, HWIO_REG_408588_RMSK) -#define HWIO_REG_408588_INM(m) \ - in_dword_masked(HWIO_REG_408588_ADDR, m) -#define HWIO_REG_408588_OUT(v) \ - out_dword(HWIO_REG_408588_ADDR, v) -#define HWIO_REG_408588_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_408588_ADDR, m, v,\ - HWIO_REG_408588_IN); -#define HWIO_REG_408588_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_408588_BASE_ADDR_SHFT 0 - -#define HWIO_REG_55617_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000062c) -#define HWIO_REG_55617_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000062c) -#define HWIO_REG_55617_RMSK 0x1ffff -#define HWIO_REG_55617_SHFT 0 -#define HWIO_REG_55617_IN in_dword_masked(\ - HWIO_REG_55617_ADDR, HWIO_REG_55617_RMSK) -#define HWIO_REG_55617_INM(m) \ - in_dword_masked(HWIO_REG_55617_ADDR, m) -#define HWIO_REG_55617_OUT(v) \ - out_dword(HWIO_REG_55617_ADDR, v) -#define HWIO_REG_55617_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_55617_ADDR, m, v,\ - HWIO_REG_55617_IN); -#define HWIO_REG_55617_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_55617_BASE_ADDR_SHFT 0 - -#define HWIO_REG_555239_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000630) -#define HWIO_REG_555239_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000630) -#define HWIO_REG_555239_RMSK 0x1ffff -#define HWIO_REG_555239_SHFT 0 -#define HWIO_REG_555239_IN in_dword_masked(\ - HWIO_REG_555239_ADDR, HWIO_REG_555239_RMSK) -#define HWIO_REG_555239_INM(m) \ - in_dword_masked(HWIO_REG_555239_ADDR, m) -#define HWIO_REG_555239_OUT(v) \ - out_dword(HWIO_REG_555239_ADDR, v) -#define HWIO_REG_555239_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_555239_ADDR, m, v,\ - HWIO_REG_555239_IN); -#define HWIO_REG_555239_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_555239_BASE_ADDR_SHFT 0 - -#define HWIO_REG_515333_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000634) -#define HWIO_REG_515333_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000634) -#define HWIO_REG_515333_RMSK 0x1ffff -#define HWIO_REG_515333_SHFT 0 -#define HWIO_REG_515333_IN in_dword_masked(\ - HWIO_REG_515333_ADDR, HWIO_REG_515333_RMSK) -#define HWIO_REG_515333_INM(m) \ - in_dword_masked(HWIO_REG_515333_ADDR, m) -#define HWIO_REG_515333_OUT(v) \ - out_dword(HWIO_REG_515333_ADDR, v) -#define HWIO_REG_515333_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_515333_ADDR, m, v,\ - HWIO_REG_515333_IN); -#define HWIO_REG_515333_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_515333_BASE_ADDR_SHFT 0 - -#define HWIO_REG_951675_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000638) -#define HWIO_REG_951675_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000638) -#define HWIO_REG_951675_RMSK 0x1ffff -#define HWIO_REG_951675_SHFT 0 -#define HWIO_REG_951675_IN in_dword_masked(\ - HWIO_REG_951675_ADDR, HWIO_REG_951675_RMSK) -#define HWIO_REG_951675_INM(m) \ - in_dword_masked(HWIO_REG_951675_ADDR, m) -#define HWIO_REG_951675_OUT(v) \ - out_dword(HWIO_REG_951675_ADDR, v) -#define HWIO_REG_951675_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_951675_ADDR, m, v,\ - HWIO_REG_951675_IN); -#define HWIO_REG_951675_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_951675_BASE_ADDR_SHFT 0 - -#define HWIO_REG_500775_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000063c) -#define HWIO_REG_500775_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000063c) -#define HWIO_REG_500775_RMSK 0x1ffff -#define HWIO_REG_500775_SHFT 0 -#define HWIO_REG_500775_IN in_dword_masked(\ - HWIO_REG_500775_ADDR, HWIO_REG_500775_RMSK) -#define HWIO_REG_500775_INM(m) \ - in_dword_masked(HWIO_REG_500775_ADDR, m) -#define HWIO_REG_500775_OUT(v) \ - out_dword(HWIO_REG_500775_ADDR, v) -#define HWIO_REG_500775_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_500775_ADDR, m, v,\ - HWIO_REG_500775_IN); -#define HWIO_REG_500775_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_500775_BASE_ADDR_SHFT 0 - -#define HWIO_REG_649786_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000640) -#define HWIO_REG_649786_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000640) -#define HWIO_REG_649786_RMSK 0x1ffff -#define HWIO_REG_649786_SHFT 0 -#define HWIO_REG_649786_IN in_dword_masked(\ - HWIO_REG_649786_ADDR, HWIO_REG_649786_RMSK) -#define HWIO_REG_649786_INM(m) \ - in_dword_masked(HWIO_REG_649786_ADDR, m) -#define HWIO_REG_649786_OUT(v) \ - out_dword(HWIO_REG_649786_ADDR, v) -#define HWIO_REG_649786_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_649786_ADDR, m, v,\ - HWIO_REG_649786_IN); -#define HWIO_REG_649786_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_649786_BASE_ADDR_SHFT 0 - -#define HWIO_REG_233366_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000644) -#define HWIO_REG_233366_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000644) -#define HWIO_REG_233366_RMSK 0x1ffff -#define HWIO_REG_233366_SHFT 0 -#define HWIO_REG_233366_IN in_dword_masked(\ - HWIO_REG_233366_ADDR, HWIO_REG_233366_RMSK) -#define HWIO_REG_233366_INM(m) \ - in_dword_masked(HWIO_REG_233366_ADDR, m) -#define HWIO_REG_233366_OUT(v) \ - out_dword(HWIO_REG_233366_ADDR, v) -#define HWIO_REG_233366_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_233366_ADDR, m, v,\ - HWIO_REG_233366_IN); -#define HWIO_REG_233366_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_233366_BASE_ADDR_SHFT 0 - -#define HWIO_REG_366750_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000648) -#define HWIO_REG_366750_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000648) -#define HWIO_REG_366750_RMSK 0x1ffff -#define HWIO_REG_366750_SHFT 0 -#define HWIO_REG_366750_IN in_dword_masked(\ - HWIO_REG_366750_ADDR, HWIO_REG_366750_RMSK) -#define HWIO_REG_366750_INM(m) \ - in_dword_masked(HWIO_REG_366750_ADDR, m) -#define HWIO_REG_366750_OUT(v) \ - out_dword(HWIO_REG_366750_ADDR, v) -#define HWIO_REG_366750_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_366750_ADDR, m, v,\ - HWIO_REG_366750_IN); -#define HWIO_REG_366750_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_366750_BASE_ADDR_SHFT 0 - -#define HWIO_REG_616292_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000064c) -#define HWIO_REG_616292_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000064c) -#define HWIO_REG_616292_RMSK 0x1ffff -#define HWIO_REG_616292_SHFT 0 -#define HWIO_REG_616292_IN in_dword_masked(\ - HWIO_REG_616292_ADDR, HWIO_REG_616292_RMSK) -#define HWIO_REG_616292_INM(m) \ - in_dword_masked(HWIO_REG_616292_ADDR, m) -#define HWIO_REG_616292_OUT(v) \ - out_dword(HWIO_REG_616292_ADDR, v) -#define HWIO_REG_616292_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_616292_ADDR, m, v,\ - HWIO_REG_616292_IN); -#define HWIO_REG_616292_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_616292_BASE_ADDR_SHFT 0 - -#define HWIO_REG_666754_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000650) -#define HWIO_REG_666754_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000650) -#define HWIO_REG_666754_RMSK 0x1ffff -#define HWIO_REG_666754_SHFT 0 -#define HWIO_REG_666754_IN in_dword_masked(\ - HWIO_REG_666754_ADDR, HWIO_REG_666754_RMSK) -#define HWIO_REG_666754_INM(m) \ - in_dword_masked(HWIO_REG_666754_ADDR, m) -#define HWIO_REG_666754_OUT(v) \ - out_dword(HWIO_REG_666754_ADDR, v) -#define HWIO_REG_666754_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_666754_ADDR, m, v,\ - HWIO_REG_666754_IN); -#define HWIO_REG_666754_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_666754_BASE_ADDR_SHFT 0 - -#define HWIO_REG_650155_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000654) -#define HWIO_REG_650155_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000654) -#define HWIO_REG_650155_RMSK 0x1ffff -#define HWIO_REG_650155_SHFT 0 -#define HWIO_REG_650155_IN in_dword_masked(\ - HWIO_REG_650155_ADDR, HWIO_REG_650155_RMSK) -#define HWIO_REG_650155_INM(m) \ - in_dword_masked(HWIO_REG_650155_ADDR, m) -#define HWIO_REG_650155_OUT(v) \ - out_dword(HWIO_REG_650155_ADDR, v) -#define HWIO_REG_650155_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_650155_ADDR, m, v,\ - HWIO_REG_650155_IN); -#define HWIO_REG_650155_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_650155_BASE_ADDR_SHFT 0 - -#define HWIO_REG_248198_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000658) -#define HWIO_REG_248198_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000658) -#define HWIO_REG_248198_RMSK 0x1ffff -#define HWIO_REG_248198_SHFT 0 -#define HWIO_REG_248198_IN in_dword_masked(\ - HWIO_REG_248198_ADDR, HWIO_REG_248198_RMSK) -#define HWIO_REG_248198_INM(m) \ - in_dword_masked(HWIO_REG_248198_ADDR, m) -#define HWIO_REG_248198_OUT(v) \ - out_dword(HWIO_REG_248198_ADDR, v) -#define HWIO_REG_248198_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_248198_ADDR, m, v,\ - HWIO_REG_248198_IN); -#define HWIO_REG_248198_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_248198_BASE_ADDR_SHFT 0 - -#define HWIO_REG_389428_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000065c) -#define HWIO_REG_389428_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000065c) -#define HWIO_REG_389428_RMSK 0x1ffff -#define HWIO_REG_389428_SHFT 0 -#define HWIO_REG_389428_IN in_dword_masked(\ - HWIO_REG_389428_ADDR, HWIO_REG_389428_RMSK) -#define HWIO_REG_389428_INM(m) \ - in_dword_masked(HWIO_REG_389428_ADDR, m) -#define HWIO_REG_389428_OUT(v) \ - out_dword(HWIO_REG_389428_ADDR, v) -#define HWIO_REG_389428_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_389428_ADDR, m, v,\ - HWIO_REG_389428_IN); -#define HWIO_REG_389428_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_389428_BASE_ADDR_SHFT 0 - -#define HWIO_REG_504308_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000660) -#define HWIO_REG_504308_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000660) -#define HWIO_REG_504308_RMSK 0x1ffff -#define HWIO_REG_504308_SHFT 0 -#define HWIO_REG_504308_IN in_dword_masked(\ - HWIO_REG_504308_ADDR, HWIO_REG_504308_RMSK) -#define HWIO_REG_504308_INM(m) \ - in_dword_masked(HWIO_REG_504308_ADDR, m) -#define HWIO_REG_504308_OUT(v) \ - out_dword(HWIO_REG_504308_ADDR, v) -#define HWIO_REG_504308_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_504308_ADDR, m, v,\ - HWIO_REG_504308_IN); -#define HWIO_REG_504308_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_504308_BASE_ADDR_SHFT 0 - -#define HWIO_REG_280814_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000664) -#define HWIO_REG_280814_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000664) -#define HWIO_REG_280814_RMSK 0x1ffff -#define HWIO_REG_280814_SHFT 0 -#define HWIO_REG_280814_IN in_dword_masked(\ - HWIO_REG_280814_ADDR, HWIO_REG_280814_RMSK) -#define HWIO_REG_280814_INM(m) \ - in_dword_masked(HWIO_REG_280814_ADDR, m) -#define HWIO_REG_280814_OUT(v) \ - out_dword(HWIO_REG_280814_ADDR, v) -#define HWIO_REG_280814_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_280814_ADDR, m, v,\ - HWIO_REG_280814_IN); -#define HWIO_REG_280814_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_280814_BASE_ADDR_SHFT 0 - -#define HWIO_REG_785484_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000668) -#define HWIO_REG_785484_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000668) -#define HWIO_REG_785484_RMSK 0x1ffff -#define HWIO_REG_785484_SHFT 0 -#define HWIO_REG_785484_IN in_dword_masked(\ - HWIO_REG_785484_ADDR, HWIO_REG_785484_RMSK) -#define HWIO_REG_785484_INM(m) \ - in_dword_masked(HWIO_REG_785484_ADDR, m) -#define HWIO_REG_785484_OUT(v) \ - out_dword(HWIO_REG_785484_ADDR, v) -#define HWIO_REG_785484_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_785484_ADDR, m, v,\ - HWIO_REG_785484_IN); -#define HWIO_REG_785484_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_785484_BASE_ADDR_SHFT 0 - -#define HWIO_REG_218455_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000066c) -#define HWIO_REG_218455_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000066c) -#define HWIO_REG_218455_RMSK 0x1ffff -#define HWIO_REG_218455_SHFT 0 -#define HWIO_REG_218455_IN in_dword_masked(\ - HWIO_REG_218455_ADDR, HWIO_REG_218455_RMSK) -#define HWIO_REG_218455_INM(m) \ - in_dword_masked(HWIO_REG_218455_ADDR, m) -#define HWIO_REG_218455_OUT(v) \ - out_dword(HWIO_REG_218455_ADDR, v) -#define HWIO_REG_218455_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_218455_ADDR, m, v,\ - HWIO_REG_218455_IN); -#define HWIO_REG_218455_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_218455_BASE_ADDR_SHFT 0 - -#define HWIO_REG_886591_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000670) -#define HWIO_REG_886591_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000670) -#define HWIO_REG_886591_RMSK 0x1ffff -#define HWIO_REG_886591_SHFT 0 -#define HWIO_REG_886591_IN in_dword_masked(\ - HWIO_REG_886591_ADDR, HWIO_REG_886591_RMSK) -#define HWIO_REG_886591_INM(m) \ - in_dword_masked(HWIO_REG_886591_ADDR, m) -#define HWIO_REG_886591_OUT(v) \ - out_dword(HWIO_REG_886591_ADDR, v) -#define HWIO_REG_886591_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_886591_ADDR, m, v,\ - HWIO_REG_886591_IN); -#define HWIO_REG_886591_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_886591_BASE_ADDR_SHFT 0 - -#define HWIO_REG_912449_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000674) -#define HWIO_REG_912449_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000674) -#define HWIO_REG_912449_RMSK 0x1ffff -#define HWIO_REG_912449_SHFT 0 -#define HWIO_REG_912449_IN in_dword_masked(\ - HWIO_REG_912449_ADDR, HWIO_REG_912449_RMSK) -#define HWIO_REG_912449_INM(m) \ - in_dword_masked(HWIO_REG_912449_ADDR, m) -#define HWIO_REG_912449_OUT(v) \ - out_dword(HWIO_REG_912449_ADDR, v) -#define HWIO_REG_912449_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_912449_ADDR, m, v,\ - HWIO_REG_912449_IN); -#define HWIO_REG_912449_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_912449_BASE_ADDR_SHFT 0 - -#define HWIO_REG_1065_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000678) -#define HWIO_REG_1065_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000678) -#define HWIO_REG_1065_RMSK 0x1ffff -#define HWIO_REG_1065_SHFT 0 -#define HWIO_REG_1065_IN in_dword_masked(\ - HWIO_REG_1065_ADDR, HWIO_REG_1065_RMSK) -#define HWIO_REG_1065_INM(m) \ - in_dword_masked(HWIO_REG_1065_ADDR, m) -#define HWIO_REG_1065_OUT(v) \ - out_dword(HWIO_REG_1065_ADDR, v) -#define HWIO_REG_1065_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_1065_ADDR, m, v,\ - HWIO_REG_1065_IN); -#define HWIO_REG_1065_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_1065_BASE_ADDR_SHFT 0 - -#define HWIO_REG_61838_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000067c) -#define HWIO_REG_61838_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000067c) -#define HWIO_REG_61838_RMSK 0x1ffff -#define HWIO_REG_61838_SHFT 0 -#define HWIO_REG_61838_IN in_dword_masked(\ - HWIO_REG_61838_ADDR, HWIO_REG_61838_RMSK) -#define HWIO_REG_61838_INM(m) \ - in_dword_masked(HWIO_REG_61838_ADDR, m) -#define HWIO_REG_61838_OUT(v) \ - out_dword(HWIO_REG_61838_ADDR, v) -#define HWIO_REG_61838_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_61838_ADDR, m, v,\ - HWIO_REG_61838_IN); -#define HWIO_REG_61838_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_61838_BASE_ADDR_SHFT 0 - -#define HWIO_REG_169838_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000680) -#define HWIO_REG_169838_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000680) -#define HWIO_REG_169838_RMSK 0x1ffff -#define HWIO_REG_169838_SHFT 0 -#define HWIO_REG_169838_IN in_dword_masked(\ - HWIO_REG_169838_ADDR, HWIO_REG_169838_RMSK) -#define HWIO_REG_169838_INM(m) \ - in_dword_masked(HWIO_REG_169838_ADDR, m) -#define HWIO_REG_169838_OUT(v) \ - out_dword(HWIO_REG_169838_ADDR, v) -#define HWIO_REG_169838_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_169838_ADDR, m, v,\ - HWIO_REG_169838_IN); -#define HWIO_REG_169838_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_169838_BASE_ADDR_SHFT 0 - -#define HWIO_REG_986147_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000684) -#define HWIO_REG_986147_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000684) -#define HWIO_REG_986147_RMSK 0x1ffff -#define HWIO_REG_986147_SHFT 0 -#define HWIO_REG_986147_IN in_dword_masked(\ - HWIO_REG_986147_ADDR, HWIO_REG_986147_RMSK) -#define HWIO_REG_986147_INM(m) \ - in_dword_masked(HWIO_REG_986147_ADDR, m) -#define HWIO_REG_986147_OUT(v) \ - out_dword(HWIO_REG_986147_ADDR, v) -#define HWIO_REG_986147_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_986147_ADDR, m, v,\ - HWIO_REG_986147_IN); -#define HWIO_REG_986147_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_986147_BASE_ADDR_SHFT 0 - -#define HWIO_REG_678637_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000688) -#define HWIO_REG_678637_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000688) -#define HWIO_REG_678637_RMSK 0x1ffff -#define HWIO_REG_678637_SHFT 0 -#define HWIO_REG_678637_IN in_dword_masked(\ - HWIO_REG_678637_ADDR, HWIO_REG_678637_RMSK) -#define HWIO_REG_678637_INM(m) \ - in_dword_masked(HWIO_REG_678637_ADDR, m) -#define HWIO_REG_678637_OUT(v) \ - out_dword(HWIO_REG_678637_ADDR, v) -#define HWIO_REG_678637_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_678637_ADDR, m, v,\ - HWIO_REG_678637_IN); -#define HWIO_REG_678637_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_678637_BASE_ADDR_SHFT 0 - -#define HWIO_REG_931311_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000068c) -#define HWIO_REG_931311_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000068c) -#define HWIO_REG_931311_RMSK 0x1ffff -#define HWIO_REG_931311_SHFT 0 -#define HWIO_REG_931311_IN in_dword_masked(\ - HWIO_REG_931311_ADDR, HWIO_REG_931311_RMSK) -#define HWIO_REG_931311_INM(m) \ - in_dword_masked(HWIO_REG_931311_ADDR, m) -#define HWIO_REG_931311_OUT(v) \ - out_dword(HWIO_REG_931311_ADDR, v) -#define HWIO_REG_931311_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_931311_ADDR, m, v,\ - HWIO_REG_931311_IN); -#define HWIO_REG_931311_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_931311_BASE_ADDR_SHFT 0 - -#define HWIO_REG_16277_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000690) -#define HWIO_REG_16277_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000690) -#define HWIO_REG_16277_RMSK 0x1ffff -#define HWIO_REG_16277_SHFT 0 -#define HWIO_REG_16277_IN in_dword_masked(\ - HWIO_REG_16277_ADDR, HWIO_REG_16277_RMSK) -#define HWIO_REG_16277_INM(m) \ - in_dword_masked(HWIO_REG_16277_ADDR, m) -#define HWIO_REG_16277_OUT(v) \ - out_dword(HWIO_REG_16277_ADDR, v) -#define HWIO_REG_16277_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_16277_ADDR, m, v,\ - HWIO_REG_16277_IN); -#define HWIO_REG_16277_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_16277_BASE_ADDR_SHFT 0 - -#define HWIO_REG_654169_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000694) -#define HWIO_REG_654169_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000694) -#define HWIO_REG_654169_RMSK 0x1ffff -#define HWIO_REG_654169_SHFT 0 -#define HWIO_REG_654169_IN in_dword_masked(\ - HWIO_REG_654169_ADDR, HWIO_REG_654169_RMSK) -#define HWIO_REG_654169_INM(m) \ - in_dword_masked(HWIO_REG_654169_ADDR, m) -#define HWIO_REG_654169_OUT(v) \ - out_dword(HWIO_REG_654169_ADDR, v) -#define HWIO_REG_654169_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_654169_ADDR, m, v,\ - HWIO_REG_654169_IN); -#define HWIO_REG_654169_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_654169_BASE_ADDR_SHFT 0 - -#define HWIO_REG_802794_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000698) -#define HWIO_REG_802794_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000698) -#define HWIO_REG_802794_RMSK 0x1ffff -#define HWIO_REG_802794_SHFT 0 -#define HWIO_REG_802794_IN in_dword_masked(\ - HWIO_REG_802794_ADDR, HWIO_REG_802794_RMSK) -#define HWIO_REG_802794_INM(m) \ - in_dword_masked(HWIO_REG_802794_ADDR, m) -#define HWIO_REG_802794_OUT(v) \ - out_dword(HWIO_REG_802794_ADDR, v) -#define HWIO_REG_802794_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_802794_ADDR, m, v,\ - HWIO_REG_802794_IN); -#define HWIO_REG_802794_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_802794_BASE_ADDR_SHFT 0 - -#define HWIO_REG_724376_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000069c) -#define HWIO_REG_724376_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000069c) -#define HWIO_REG_724376_RMSK 0x1ffff -#define HWIO_REG_724376_SHFT 0 -#define HWIO_REG_724376_IN in_dword_masked(\ - HWIO_REG_724376_ADDR, HWIO_REG_724376_RMSK) -#define HWIO_REG_724376_INM(m) \ - in_dword_masked(HWIO_REG_724376_ADDR, m) -#define HWIO_REG_724376_OUT(v) \ - out_dword(HWIO_REG_724376_ADDR, v) -#define HWIO_REG_724376_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_724376_ADDR, m, v,\ - HWIO_REG_724376_IN); -#define HWIO_REG_724376_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_724376_BASE_ADDR_SHFT 0 - -#define HWIO_REG_551674_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006a0) -#define HWIO_REG_551674_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006a0) -#define HWIO_REG_551674_RMSK 0x1ffff -#define HWIO_REG_551674_SHFT 0 -#define HWIO_REG_551674_IN in_dword_masked(\ - HWIO_REG_551674_ADDR, HWIO_REG_551674_RMSK) -#define HWIO_REG_551674_INM(m) \ - in_dword_masked(HWIO_REG_551674_ADDR, m) -#define HWIO_REG_551674_OUT(v) \ - out_dword(HWIO_REG_551674_ADDR, v) -#define HWIO_REG_551674_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_551674_ADDR, m, v,\ - HWIO_REG_551674_IN); -#define HWIO_REG_551674_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_551674_BASE_ADDR_SHFT 0 - -#define HWIO_REG_115991_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006a4) -#define HWIO_REG_115991_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006a4) -#define HWIO_REG_115991_RMSK 0x1ffff -#define HWIO_REG_115991_SHFT 0 -#define HWIO_REG_115991_IN in_dword_masked(\ - HWIO_REG_115991_ADDR, HWIO_REG_115991_RMSK) -#define HWIO_REG_115991_INM(m) \ - in_dword_masked(HWIO_REG_115991_ADDR, m) -#define HWIO_REG_115991_OUT(v) \ - out_dword(HWIO_REG_115991_ADDR, v) -#define HWIO_REG_115991_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_115991_ADDR, m, v,\ - HWIO_REG_115991_IN); -#define HWIO_REG_115991_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_115991_BASE_ADDR_SHFT 0 - -#define HWIO_REG_252167_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006a8) -#define HWIO_REG_252167_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006a8) -#define HWIO_REG_252167_RMSK 0x1ffff -#define HWIO_REG_252167_SHFT 0 -#define HWIO_REG_252167_IN in_dword_masked(\ - HWIO_REG_252167_ADDR, HWIO_REG_252167_RMSK) -#define HWIO_REG_252167_INM(m) \ - in_dword_masked(HWIO_REG_252167_ADDR, m) -#define HWIO_REG_252167_OUT(v) \ - out_dword(HWIO_REG_252167_ADDR, v) -#define HWIO_REG_252167_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_252167_ADDR, m, v,\ - HWIO_REG_252167_IN); -#define HWIO_REG_252167_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_252167_BASE_ADDR_SHFT 0 - -#define HWIO_REG_695516_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006ac) -#define HWIO_REG_695516_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006ac) -#define HWIO_REG_695516_RMSK 0x1ffff -#define HWIO_REG_695516_SHFT 0 -#define HWIO_REG_695516_IN in_dword_masked(\ - HWIO_REG_695516_ADDR, HWIO_REG_695516_RMSK) -#define HWIO_REG_695516_INM(m) \ - in_dword_masked(HWIO_REG_695516_ADDR, m) -#define HWIO_REG_695516_OUT(v) \ - out_dword(HWIO_REG_695516_ADDR, v) -#define HWIO_REG_695516_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_695516_ADDR, m, v,\ - HWIO_REG_695516_IN); -#define HWIO_REG_695516_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_695516_BASE_ADDR_SHFT 0 - -#define HWIO_REG_152193_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006b0) -#define HWIO_REG_152193_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006b0) -#define HWIO_REG_152193_RMSK 0x1ffff -#define HWIO_REG_152193_SHFT 0 -#define HWIO_REG_152193_IN in_dword_masked(\ - HWIO_REG_152193_ADDR, HWIO_REG_152193_RMSK) -#define HWIO_REG_152193_INM(m) \ - in_dword_masked(HWIO_REG_152193_ADDR, m) -#define HWIO_REG_152193_OUT(v) \ - out_dword(HWIO_REG_152193_ADDR, v) -#define HWIO_REG_152193_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_152193_ADDR, m, v,\ - HWIO_REG_152193_IN); -#define HWIO_REG_152193_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_152193_BASE_ADDR_SHFT 0 - -#define HWIO_REG_358705_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006b4) -#define HWIO_REG_358705_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006b4) -#define HWIO_REG_358705_RMSK 0x1ffff -#define HWIO_REG_358705_SHFT 0 -#define HWIO_REG_358705_IN in_dword_masked(\ - HWIO_REG_358705_ADDR, HWIO_REG_358705_RMSK) -#define HWIO_REG_358705_INM(m) \ - in_dword_masked(HWIO_REG_358705_ADDR, m) -#define HWIO_REG_358705_OUT(v) \ - out_dword(HWIO_REG_358705_ADDR, v) -#define HWIO_REG_358705_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_358705_ADDR, m, v,\ - HWIO_REG_358705_IN); -#define HWIO_REG_358705_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_358705_BASE_ADDR_SHFT 0 - -#define HWIO_REG_457068_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006b8) -#define HWIO_REG_457068_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006b8) -#define HWIO_REG_457068_RMSK 0x1ffff -#define HWIO_REG_457068_SHFT 0 -#define HWIO_REG_457068_IN in_dword_masked(\ - HWIO_REG_457068_ADDR, HWIO_REG_457068_RMSK) -#define HWIO_REG_457068_INM(m) \ - in_dword_masked(HWIO_REG_457068_ADDR, m) -#define HWIO_REG_457068_OUT(v) \ - out_dword(HWIO_REG_457068_ADDR, v) -#define HWIO_REG_457068_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_457068_ADDR, m, v,\ - HWIO_REG_457068_IN); -#define HWIO_REG_457068_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_457068_BASE_ADDR_SHFT 0 - -#define HWIO_REG_485412_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006bc) -#define HWIO_REG_485412_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006bc) -#define HWIO_REG_485412_RMSK 0x1ffff -#define HWIO_REG_485412_SHFT 0 -#define HWIO_REG_485412_IN in_dword_masked(\ - HWIO_REG_485412_ADDR, HWIO_REG_485412_RMSK) -#define HWIO_REG_485412_INM(m) \ - in_dword_masked(HWIO_REG_485412_ADDR, m) -#define HWIO_REG_485412_OUT(v) \ - out_dword(HWIO_REG_485412_ADDR, v) -#define HWIO_REG_485412_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_485412_ADDR, m, v,\ - HWIO_REG_485412_IN); -#define HWIO_REG_485412_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_485412_BASE_ADDR_SHFT 0 - -#define HWIO_REG_223131_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006c0) -#define HWIO_REG_223131_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006c0) -#define HWIO_REG_223131_RMSK 0x1ffff -#define HWIO_REG_223131_SHFT 0 -#define HWIO_REG_223131_IN in_dword_masked(\ - HWIO_REG_223131_ADDR, HWIO_REG_223131_RMSK) -#define HWIO_REG_223131_INM(m) \ - in_dword_masked(HWIO_REG_223131_ADDR, m) -#define HWIO_REG_223131_OUT(v) \ - out_dword(HWIO_REG_223131_ADDR, v) -#define HWIO_REG_223131_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_223131_ADDR, m, v,\ - HWIO_REG_223131_IN); -#define HWIO_REG_223131_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_223131_BASE_ADDR_SHFT 0 - -#define HWIO_REG_683737_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006c4) -#define HWIO_REG_683737_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006c4) -#define HWIO_REG_683737_RMSK 0x1ffff -#define HWIO_REG_683737_SHFT 0 -#define HWIO_REG_683737_IN in_dword_masked(\ - HWIO_REG_683737_ADDR, HWIO_REG_683737_RMSK) -#define HWIO_REG_683737_INM(m) \ - in_dword_masked(HWIO_REG_683737_ADDR, m) -#define HWIO_REG_683737_OUT(v) \ - out_dword(HWIO_REG_683737_ADDR, v) -#define HWIO_REG_683737_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_683737_ADDR, m, v,\ - HWIO_REG_683737_IN); -#define HWIO_REG_683737_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_683737_BASE_ADDR_SHFT 0 - -#define HWIO_REG_750474_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006c8) -#define HWIO_REG_750474_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006c8) -#define HWIO_REG_750474_RMSK 0x1ffff -#define HWIO_REG_750474_SHFT 0 -#define HWIO_REG_750474_IN in_dword_masked(\ - HWIO_REG_750474_ADDR, HWIO_REG_750474_RMSK) -#define HWIO_REG_750474_INM(m) \ - in_dword_masked(HWIO_REG_750474_ADDR, m) -#define HWIO_REG_750474_OUT(v) \ - out_dword(HWIO_REG_750474_ADDR, v) -#define HWIO_REG_750474_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_750474_ADDR, m, v,\ - HWIO_REG_750474_IN); -#define HWIO_REG_750474_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_750474_BASE_ADDR_SHFT 0 - -#define HWIO_REG_170086_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006cc) -#define HWIO_REG_170086_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006cc) -#define HWIO_REG_170086_RMSK 0x1ffff -#define HWIO_REG_170086_SHFT 0 -#define HWIO_REG_170086_IN in_dword_masked(\ - HWIO_REG_170086_ADDR, HWIO_REG_170086_RMSK) -#define HWIO_REG_170086_INM(m) \ - in_dword_masked(HWIO_REG_170086_ADDR, m) -#define HWIO_REG_170086_OUT(v) \ - out_dword(HWIO_REG_170086_ADDR, v) -#define HWIO_REG_170086_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_170086_ADDR, m, v,\ - HWIO_REG_170086_IN); -#define HWIO_REG_170086_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_170086_BASE_ADDR_SHFT 0 - -#define HWIO_REG_838595_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006d0) -#define HWIO_REG_838595_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006d0) -#define HWIO_REG_838595_RMSK 0x1ffff -#define HWIO_REG_838595_SHFT 0 -#define HWIO_REG_838595_IN in_dword_masked(\ - HWIO_REG_838595_ADDR, HWIO_REG_838595_RMSK) -#define HWIO_REG_838595_INM(m) \ - in_dword_masked(HWIO_REG_838595_ADDR, m) -#define HWIO_REG_838595_OUT(v) \ - out_dword(HWIO_REG_838595_ADDR, v) -#define HWIO_REG_838595_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_838595_ADDR, m, v,\ - HWIO_REG_838595_IN); -#define HWIO_REG_838595_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_838595_BASE_ADDR_SHFT 0 - -#define HWIO_REG_569788_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006d4) -#define HWIO_REG_569788_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006d4) -#define HWIO_REG_569788_RMSK 0x1ffff -#define HWIO_REG_569788_SHFT 0 -#define HWIO_REG_569788_IN in_dword_masked(\ - HWIO_REG_569788_ADDR, HWIO_REG_569788_RMSK) -#define HWIO_REG_569788_INM(m) \ - in_dword_masked(HWIO_REG_569788_ADDR, m) -#define HWIO_REG_569788_OUT(v) \ - out_dword(HWIO_REG_569788_ADDR, v) -#define HWIO_REG_569788_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_569788_ADDR, m, v,\ - HWIO_REG_569788_IN); -#define HWIO_REG_569788_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_569788_BASE_ADDR_SHFT 0 - -#define HWIO_REG_974527_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006d8) -#define HWIO_REG_974527_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006d8) -#define HWIO_REG_974527_RMSK 0x1ffff -#define HWIO_REG_974527_SHFT 0 -#define HWIO_REG_974527_IN in_dword_masked(\ - HWIO_REG_974527_ADDR, HWIO_REG_974527_RMSK) -#define HWIO_REG_974527_INM(m) \ - in_dword_masked(HWIO_REG_974527_ADDR, m) -#define HWIO_REG_974527_OUT(v) \ - out_dword(HWIO_REG_974527_ADDR, v) -#define HWIO_REG_974527_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_974527_ADDR, m, v,\ - HWIO_REG_974527_IN); -#define HWIO_REG_974527_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_974527_BASE_ADDR_SHFT 0 - -#define HWIO_REG_316806_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006dc) -#define HWIO_REG_316806_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006dc) -#define HWIO_REG_316806_RMSK 0x1ffff -#define HWIO_REG_316806_SHFT 0 -#define HWIO_REG_316806_IN in_dword_masked(\ - HWIO_REG_316806_ADDR, HWIO_REG_316806_RMSK) -#define HWIO_REG_316806_INM(m) \ - in_dword_masked(HWIO_REG_316806_ADDR, m) -#define HWIO_REG_316806_OUT(v) \ - out_dword(HWIO_REG_316806_ADDR, v) -#define HWIO_REG_316806_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_316806_ADDR, m, v,\ - HWIO_REG_316806_IN); -#define HWIO_REG_316806_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_316806_BASE_ADDR_SHFT 0 - -#define HWIO_REG_900472_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006e0) -#define HWIO_REG_900472_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006e0) -#define HWIO_REG_900472_RMSK 0x1ffff -#define HWIO_REG_900472_SHFT 0 -#define HWIO_REG_900472_IN in_dword_masked(\ - HWIO_REG_900472_ADDR, HWIO_REG_900472_RMSK) -#define HWIO_REG_900472_INM(m) \ - in_dword_masked(HWIO_REG_900472_ADDR, m) -#define HWIO_REG_900472_OUT(v) \ - out_dword(HWIO_REG_900472_ADDR, v) -#define HWIO_REG_900472_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_900472_ADDR, m, v,\ - HWIO_REG_900472_IN); -#define HWIO_REG_900472_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_900472_BASE_ADDR_SHFT 0 - -#define HWIO_REG_256156_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006e4) -#define HWIO_REG_256156_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006e4) -#define HWIO_REG_256156_RMSK 0x1ffff -#define HWIO_REG_256156_SHFT 0 -#define HWIO_REG_256156_IN in_dword_masked(\ - HWIO_REG_256156_ADDR, HWIO_REG_256156_RMSK) -#define HWIO_REG_256156_INM(m) \ - in_dword_masked(HWIO_REG_256156_ADDR, m) -#define HWIO_REG_256156_OUT(v) \ - out_dword(HWIO_REG_256156_ADDR, v) -#define HWIO_REG_256156_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_256156_ADDR, m, v,\ - HWIO_REG_256156_IN); -#define HWIO_REG_256156_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_256156_BASE_ADDR_SHFT 0 - -#define HWIO_REG_335729_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006e8) -#define HWIO_REG_335729_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006e8) -#define HWIO_REG_335729_RMSK 0x1ffff -#define HWIO_REG_335729_SHFT 0 -#define HWIO_REG_335729_IN in_dword_masked(\ - HWIO_REG_335729_ADDR, HWIO_REG_335729_RMSK) -#define HWIO_REG_335729_INM(m) \ - in_dword_masked(HWIO_REG_335729_ADDR, m) -#define HWIO_REG_335729_OUT(v) \ - out_dword(HWIO_REG_335729_ADDR, v) -#define HWIO_REG_335729_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_335729_ADDR, m, v,\ - HWIO_REG_335729_IN); -#define HWIO_REG_335729_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_335729_BASE_ADDR_SHFT 0 - -#define HWIO_REG_303383_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006ec) -#define HWIO_REG_303383_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006ec) -#define HWIO_REG_303383_RMSK 0x1ffff -#define HWIO_REG_303383_SHFT 0 -#define HWIO_REG_303383_IN in_dword_masked(\ - HWIO_REG_303383_ADDR, HWIO_REG_303383_RMSK) -#define HWIO_REG_303383_INM(m) \ - in_dword_masked(HWIO_REG_303383_ADDR, m) -#define HWIO_REG_303383_OUT(v) \ - out_dword(HWIO_REG_303383_ADDR, v) -#define HWIO_REG_303383_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_303383_ADDR, m, v,\ - HWIO_REG_303383_IN); -#define HWIO_REG_303383_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_303383_BASE_ADDR_SHFT 0 - -#define HWIO_REG_180871_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006f0) -#define HWIO_REG_180871_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006f0) -#define HWIO_REG_180871_RMSK 0x1ffff -#define HWIO_REG_180871_SHFT 0 -#define HWIO_REG_180871_IN in_dword_masked(\ - HWIO_REG_180871_ADDR, HWIO_REG_180871_RMSK) -#define HWIO_REG_180871_INM(m) \ - in_dword_masked(HWIO_REG_180871_ADDR, m) -#define HWIO_REG_180871_OUT(v) \ - out_dword(HWIO_REG_180871_ADDR, v) -#define HWIO_REG_180871_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_180871_ADDR, m, v,\ - HWIO_REG_180871_IN); -#define HWIO_REG_180871_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_180871_BASE_ADDR_SHFT 0 - -#define HWIO_REG_514148_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006f4) -#define HWIO_REG_514148_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006f4) -#define HWIO_REG_514148_RMSK 0x1ffff -#define HWIO_REG_514148_SHFT 0 -#define HWIO_REG_514148_IN in_dword_masked(\ - HWIO_REG_514148_ADDR, HWIO_REG_514148_RMSK) -#define HWIO_REG_514148_INM(m) \ - in_dword_masked(HWIO_REG_514148_ADDR, m) -#define HWIO_REG_514148_OUT(v) \ - out_dword(HWIO_REG_514148_ADDR, v) -#define HWIO_REG_514148_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_514148_ADDR, m, v,\ - HWIO_REG_514148_IN); -#define HWIO_REG_514148_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_514148_BASE_ADDR_SHFT 0 - -#define HWIO_REG_578636_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006f8) -#define HWIO_REG_578636_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006f8) -#define HWIO_REG_578636_RMSK 0x1ffff -#define HWIO_REG_578636_SHFT 0 -#define HWIO_REG_578636_IN in_dword_masked(\ - HWIO_REG_578636_ADDR, HWIO_REG_578636_RMSK) -#define HWIO_REG_578636_INM(m) \ - in_dword_masked(HWIO_REG_578636_ADDR, m) -#define HWIO_REG_578636_OUT(v) \ - out_dword(HWIO_REG_578636_ADDR, v) -#define HWIO_REG_578636_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_578636_ADDR, m, v,\ - HWIO_REG_578636_IN); -#define HWIO_REG_578636_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_578636_BASE_ADDR_SHFT 0 - -#define HWIO_REG_888116_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000006fc) -#define HWIO_REG_888116_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000006fc) -#define HWIO_REG_888116_RMSK 0x1ffff -#define HWIO_REG_888116_SHFT 0 -#define HWIO_REG_888116_IN in_dword_masked(\ - HWIO_REG_888116_ADDR, HWIO_REG_888116_RMSK) -#define HWIO_REG_888116_INM(m) \ - in_dword_masked(HWIO_REG_888116_ADDR, m) -#define HWIO_REG_888116_OUT(v) \ - out_dword(HWIO_REG_888116_ADDR, v) -#define HWIO_REG_888116_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_888116_ADDR, m, v,\ - HWIO_REG_888116_IN); -#define HWIO_REG_888116_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_888116_BASE_ADDR_SHFT 0 - -#define HWIO_REG_759068_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000700) -#define HWIO_REG_759068_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000700) -#define HWIO_REG_759068_RMSK 0x1ffff -#define HWIO_REG_759068_SHFT 0 -#define HWIO_REG_759068_IN in_dword_masked(\ - HWIO_REG_759068_ADDR, HWIO_REG_759068_RMSK) -#define HWIO_REG_759068_INM(m) \ - in_dword_masked(HWIO_REG_759068_ADDR, m) -#define HWIO_REG_759068_OUT(v) \ - out_dword(HWIO_REG_759068_ADDR, v) -#define HWIO_REG_759068_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_759068_ADDR, m, v,\ - HWIO_REG_759068_IN); -#define HWIO_REG_759068_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_759068_BASE_ADDR_SHFT 0 - -#define HWIO_REG_68356_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000704) -#define HWIO_REG_68356_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000704) -#define HWIO_REG_68356_RMSK 0x1ffff -#define HWIO_REG_68356_SHFT 0 -#define HWIO_REG_68356_IN in_dword_masked(\ - HWIO_REG_68356_ADDR, HWIO_REG_68356_RMSK) -#define HWIO_REG_68356_INM(m) \ - in_dword_masked(HWIO_REG_68356_ADDR, m) -#define HWIO_REG_68356_OUT(v) \ - out_dword(HWIO_REG_68356_ADDR, v) -#define HWIO_REG_68356_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_68356_ADDR, m, v,\ - HWIO_REG_68356_IN); -#define HWIO_REG_68356_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_68356_BASE_ADDR_SHFT 0 - -#define HWIO_REG_833502_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000708) -#define HWIO_REG_833502_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000708) -#define HWIO_REG_833502_RMSK 0x1ffff -#define HWIO_REG_833502_SHFT 0 -#define HWIO_REG_833502_IN in_dword_masked(\ - HWIO_REG_833502_ADDR, HWIO_REG_833502_RMSK) -#define HWIO_REG_833502_INM(m) \ - in_dword_masked(HWIO_REG_833502_ADDR, m) -#define HWIO_REG_833502_OUT(v) \ - out_dword(HWIO_REG_833502_ADDR, v) -#define HWIO_REG_833502_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_833502_ADDR, m, v,\ - HWIO_REG_833502_IN); -#define HWIO_REG_833502_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_833502_BASE_ADDR_SHFT 0 - -#define HWIO_REG_127855_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000070c) -#define HWIO_REG_127855_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000070c) -#define HWIO_REG_127855_RMSK 0x1ffff -#define HWIO_REG_127855_SHFT 0 -#define HWIO_REG_127855_IN in_dword_masked(\ - HWIO_REG_127855_ADDR, HWIO_REG_127855_RMSK) -#define HWIO_REG_127855_INM(m) \ - in_dword_masked(HWIO_REG_127855_ADDR, m) -#define HWIO_REG_127855_OUT(v) \ - out_dword(HWIO_REG_127855_ADDR, v) -#define HWIO_REG_127855_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_127855_ADDR, m, v,\ - HWIO_REG_127855_IN); -#define HWIO_REG_127855_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_127855_BASE_ADDR_SHFT 0 - -#define HWIO_REG_616802_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000710) -#define HWIO_REG_616802_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000710) -#define HWIO_REG_616802_RMSK 0x1ffff -#define HWIO_REG_616802_SHFT 0 -#define HWIO_REG_616802_IN in_dword_masked(\ - HWIO_REG_616802_ADDR, HWIO_REG_616802_RMSK) -#define HWIO_REG_616802_INM(m) \ - in_dword_masked(HWIO_REG_616802_ADDR, m) -#define HWIO_REG_616802_OUT(v) \ - out_dword(HWIO_REG_616802_ADDR, v) -#define HWIO_REG_616802_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_616802_ADDR, m, v,\ - HWIO_REG_616802_IN); -#define HWIO_REG_616802_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_616802_BASE_ADDR_SHFT 0 - -#define HWIO_REG_23318_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000714) -#define HWIO_REG_23318_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000714) -#define HWIO_REG_23318_RMSK 0x1ffff -#define HWIO_REG_23318_SHFT 0 -#define HWIO_REG_23318_IN in_dword_masked(\ - HWIO_REG_23318_ADDR, HWIO_REG_23318_RMSK) -#define HWIO_REG_23318_INM(m) \ - in_dword_masked(HWIO_REG_23318_ADDR, m) -#define HWIO_REG_23318_OUT(v) \ - out_dword(HWIO_REG_23318_ADDR, v) -#define HWIO_REG_23318_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_23318_ADDR, m, v,\ - HWIO_REG_23318_IN); -#define HWIO_REG_23318_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_23318_BASE_ADDR_SHFT 0 - -#define HWIO_REG_317106_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000718) -#define HWIO_REG_317106_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000718) -#define HWIO_REG_317106_RMSK 0x1ffff -#define HWIO_REG_317106_SHFT 0 -#define HWIO_REG_317106_IN in_dword_masked(\ - HWIO_REG_317106_ADDR, HWIO_REG_317106_RMSK) -#define HWIO_REG_317106_INM(m) \ - in_dword_masked(HWIO_REG_317106_ADDR, m) -#define HWIO_REG_317106_OUT(v) \ - out_dword(HWIO_REG_317106_ADDR, v) -#define HWIO_REG_317106_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_317106_ADDR, m, v,\ - HWIO_REG_317106_IN); -#define HWIO_REG_317106_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_317106_BASE_ADDR_SHFT 0 - -#define HWIO_REG_603772_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000071c) -#define HWIO_REG_603772_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000071c) -#define HWIO_REG_603772_RMSK 0x1ffff -#define HWIO_REG_603772_SHFT 0 -#define HWIO_REG_603772_IN in_dword_masked(\ - HWIO_REG_603772_ADDR, HWIO_REG_603772_RMSK) -#define HWIO_REG_603772_INM(m) \ - in_dword_masked(HWIO_REG_603772_ADDR, m) -#define HWIO_REG_603772_OUT(v) \ - out_dword(HWIO_REG_603772_ADDR, v) -#define HWIO_REG_603772_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_603772_ADDR, m, v,\ - HWIO_REG_603772_IN); -#define HWIO_REG_603772_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_603772_BASE_ADDR_SHFT 0 - -#define HWIO_REG_175929_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000720) -#define HWIO_REG_175929_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000720) -#define HWIO_REG_175929_RMSK 0x1ffff -#define HWIO_REG_175929_SHFT 0 -#define HWIO_REG_175929_IN in_dword_masked(\ - HWIO_REG_175929_ADDR, HWIO_REG_175929_RMSK) -#define HWIO_REG_175929_INM(m) \ - in_dword_masked(HWIO_REG_175929_ADDR, m) -#define HWIO_REG_175929_OUT(v) \ - out_dword(HWIO_REG_175929_ADDR, v) -#define HWIO_REG_175929_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_175929_ADDR, m, v,\ - HWIO_REG_175929_IN); -#define HWIO_REG_175929_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_175929_BASE_ADDR_SHFT 0 - -#define HWIO_REG_11928_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000724) -#define HWIO_REG_11928_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000724) -#define HWIO_REG_11928_RMSK 0x1ffff -#define HWIO_REG_11928_SHFT 0 -#define HWIO_REG_11928_IN in_dword_masked(\ - HWIO_REG_11928_ADDR, HWIO_REG_11928_RMSK) -#define HWIO_REG_11928_INM(m) \ - in_dword_masked(HWIO_REG_11928_ADDR, m) -#define HWIO_REG_11928_OUT(v) \ - out_dword(HWIO_REG_11928_ADDR, v) -#define HWIO_REG_11928_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_11928_ADDR, m, v,\ - HWIO_REG_11928_IN); -#define HWIO_REG_11928_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_11928_BASE_ADDR_SHFT 0 - -#define HWIO_REG_772678_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000728) -#define HWIO_REG_772678_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000728) -#define HWIO_REG_772678_RMSK 0x1ffff -#define HWIO_REG_772678_SHFT 0 -#define HWIO_REG_772678_IN in_dword_masked(\ - HWIO_REG_772678_ADDR, HWIO_REG_772678_RMSK) -#define HWIO_REG_772678_INM(m) \ - in_dword_masked(HWIO_REG_772678_ADDR, m) -#define HWIO_REG_772678_OUT(v) \ - out_dword(HWIO_REG_772678_ADDR, v) -#define HWIO_REG_772678_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_772678_ADDR, m, v,\ - HWIO_REG_772678_IN); -#define HWIO_REG_772678_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_772678_BASE_ADDR_SHFT 0 - -#define HWIO_REG_603389_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000072c) -#define HWIO_REG_603389_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000072c) -#define HWIO_REG_603389_RMSK 0x1ffff -#define HWIO_REG_603389_SHFT 0 -#define HWIO_REG_603389_IN in_dword_masked(\ - HWIO_REG_603389_ADDR, HWIO_REG_603389_RMSK) -#define HWIO_REG_603389_INM(m) \ - in_dword_masked(HWIO_REG_603389_ADDR, m) -#define HWIO_REG_603389_OUT(v) \ - out_dword(HWIO_REG_603389_ADDR, v) -#define HWIO_REG_603389_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_603389_ADDR, m, v,\ - HWIO_REG_603389_IN); -#define HWIO_REG_603389_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_603389_BASE_ADDR_SHFT 0 - -#define HWIO_REG_989918_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000730) -#define HWIO_REG_989918_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000730) -#define HWIO_REG_989918_RMSK 0x1ffff -#define HWIO_REG_989918_SHFT 0 -#define HWIO_REG_989918_IN in_dword_masked(\ - HWIO_REG_989918_ADDR, HWIO_REG_989918_RMSK) -#define HWIO_REG_989918_INM(m) \ - in_dword_masked(HWIO_REG_989918_ADDR, m) -#define HWIO_REG_989918_OUT(v) \ - out_dword(HWIO_REG_989918_ADDR, v) -#define HWIO_REG_989918_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_989918_ADDR, m, v,\ - HWIO_REG_989918_IN); -#define HWIO_REG_989918_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_989918_BASE_ADDR_SHFT 0 - -#define HWIO_REG_5460_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000734) -#define HWIO_REG_5460_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000734) -#define HWIO_REG_5460_RMSK 0x1ffff -#define HWIO_REG_5460_SHFT 0 -#define HWIO_REG_5460_IN in_dword_masked(\ - HWIO_REG_5460_ADDR, HWIO_REG_5460_RMSK) -#define HWIO_REG_5460_INM(m) \ - in_dword_masked(HWIO_REG_5460_ADDR, m) -#define HWIO_REG_5460_OUT(v) \ - out_dword(HWIO_REG_5460_ADDR, v) -#define HWIO_REG_5460_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_5460_ADDR, m, v,\ - HWIO_REG_5460_IN); -#define HWIO_REG_5460_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_5460_BASE_ADDR_SHFT 0 - -#define HWIO_REG_734724_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000738) -#define HWIO_REG_734724_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000738) -#define HWIO_REG_734724_RMSK 0x1ffff -#define HWIO_REG_734724_SHFT 0 -#define HWIO_REG_734724_IN in_dword_masked(\ - HWIO_REG_734724_ADDR, HWIO_REG_734724_RMSK) -#define HWIO_REG_734724_INM(m) \ - in_dword_masked(HWIO_REG_734724_ADDR, m) -#define HWIO_REG_734724_OUT(v) \ - out_dword(HWIO_REG_734724_ADDR, v) -#define HWIO_REG_734724_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_734724_ADDR, m, v,\ - HWIO_REG_734724_IN); -#define HWIO_REG_734724_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_734724_BASE_ADDR_SHFT 0 - -#define HWIO_REG_451742_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000073c) -#define HWIO_REG_451742_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000073c) -#define HWIO_REG_451742_RMSK 0x1ffff -#define HWIO_REG_451742_SHFT 0 -#define HWIO_REG_451742_IN in_dword_masked(\ - HWIO_REG_451742_ADDR, HWIO_REG_451742_RMSK) -#define HWIO_REG_451742_INM(m) \ - in_dword_masked(HWIO_REG_451742_ADDR, m) -#define HWIO_REG_451742_OUT(v) \ - out_dword(HWIO_REG_451742_ADDR, v) -#define HWIO_REG_451742_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_451742_ADDR, m, v,\ - HWIO_REG_451742_IN); -#define HWIO_REG_451742_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_451742_BASE_ADDR_SHFT 0 - -#define HWIO_REG_475648_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000740) -#define HWIO_REG_475648_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000740) -#define HWIO_REG_475648_RMSK 0x1ffff -#define HWIO_REG_475648_SHFT 0 -#define HWIO_REG_475648_IN in_dword_masked(\ - HWIO_REG_475648_ADDR, HWIO_REG_475648_RMSK) -#define HWIO_REG_475648_INM(m) \ - in_dword_masked(HWIO_REG_475648_ADDR, m) -#define HWIO_REG_475648_OUT(v) \ - out_dword(HWIO_REG_475648_ADDR, v) -#define HWIO_REG_475648_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_475648_ADDR, m, v,\ - HWIO_REG_475648_IN); -#define HWIO_REG_475648_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_475648_BASE_ADDR_SHFT 0 - -#define HWIO_REG_284758_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000744) -#define HWIO_REG_284758_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000744) -#define HWIO_REG_284758_RMSK 0x1ffff -#define HWIO_REG_284758_SHFT 0 -#define HWIO_REG_284758_IN in_dword_masked(\ - HWIO_REG_284758_ADDR, HWIO_REG_284758_RMSK) -#define HWIO_REG_284758_INM(m) \ - in_dword_masked(HWIO_REG_284758_ADDR, m) -#define HWIO_REG_284758_OUT(v) \ - out_dword(HWIO_REG_284758_ADDR, v) -#define HWIO_REG_284758_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_284758_ADDR, m, v,\ - HWIO_REG_284758_IN); -#define HWIO_REG_284758_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_284758_BASE_ADDR_SHFT 0 - -#define HWIO_REG_523659_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000748) -#define HWIO_REG_523659_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000748) -#define HWIO_REG_523659_RMSK 0x1ffff -#define HWIO_REG_523659_SHFT 0 -#define HWIO_REG_523659_IN in_dword_masked(\ - HWIO_REG_523659_ADDR, HWIO_REG_523659_RMSK) -#define HWIO_REG_523659_INM(m) \ - in_dword_masked(HWIO_REG_523659_ADDR, m) -#define HWIO_REG_523659_OUT(v) \ - out_dword(HWIO_REG_523659_ADDR, v) -#define HWIO_REG_523659_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_523659_ADDR, m, v,\ - HWIO_REG_523659_IN); -#define HWIO_REG_523659_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_523659_BASE_ADDR_SHFT 0 - -#define HWIO_REG_815580_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000074c) -#define HWIO_REG_815580_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000074c) -#define HWIO_REG_815580_RMSK 0x1ffff -#define HWIO_REG_815580_SHFT 0 -#define HWIO_REG_815580_IN in_dword_masked(\ - HWIO_REG_815580_ADDR, HWIO_REG_815580_RMSK) -#define HWIO_REG_815580_INM(m) \ - in_dword_masked(HWIO_REG_815580_ADDR, m) -#define HWIO_REG_815580_OUT(v) \ - out_dword(HWIO_REG_815580_ADDR, v) -#define HWIO_REG_815580_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_815580_ADDR, m, v,\ - HWIO_REG_815580_IN); -#define HWIO_REG_815580_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_815580_BASE_ADDR_SHFT 0 - -#define HWIO_REG_546551_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000750) -#define HWIO_REG_546551_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000750) -#define HWIO_REG_546551_RMSK 0x1ffff -#define HWIO_REG_546551_SHFT 0 -#define HWIO_REG_546551_IN in_dword_masked(\ - HWIO_REG_546551_ADDR, HWIO_REG_546551_RMSK) -#define HWIO_REG_546551_INM(m) \ - in_dword_masked(HWIO_REG_546551_ADDR, m) -#define HWIO_REG_546551_OUT(v) \ - out_dword(HWIO_REG_546551_ADDR, v) -#define HWIO_REG_546551_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_546551_ADDR, m, v,\ - HWIO_REG_546551_IN); -#define HWIO_REG_546551_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_546551_BASE_ADDR_SHFT 0 - -#define HWIO_REG_769851_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000754) -#define HWIO_REG_769851_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000754) -#define HWIO_REG_769851_RMSK 0x1ffff -#define HWIO_REG_769851_SHFT 0 -#define HWIO_REG_769851_IN in_dword_masked(\ - HWIO_REG_769851_ADDR, HWIO_REG_769851_RMSK) -#define HWIO_REG_769851_INM(m) \ - in_dword_masked(HWIO_REG_769851_ADDR, m) -#define HWIO_REG_769851_OUT(v) \ - out_dword(HWIO_REG_769851_ADDR, v) -#define HWIO_REG_769851_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_769851_ADDR, m, v,\ - HWIO_REG_769851_IN); -#define HWIO_REG_769851_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_769851_BASE_ADDR_SHFT 0 - -#define HWIO_REG_205028_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000758) -#define HWIO_REG_205028_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000758) -#define HWIO_REG_205028_RMSK 0x1ffff -#define HWIO_REG_205028_SHFT 0 -#define HWIO_REG_205028_IN in_dword_masked(\ - HWIO_REG_205028_ADDR, HWIO_REG_205028_RMSK) -#define HWIO_REG_205028_INM(m) \ - in_dword_masked(HWIO_REG_205028_ADDR, m) -#define HWIO_REG_205028_OUT(v) \ - out_dword(HWIO_REG_205028_ADDR, v) -#define HWIO_REG_205028_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_205028_ADDR, m, v,\ - HWIO_REG_205028_IN); -#define HWIO_REG_205028_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_205028_BASE_ADDR_SHFT 0 - -#define HWIO_REG_206835_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000075c) -#define HWIO_REG_206835_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000075c) -#define HWIO_REG_206835_RMSK 0x1ffff -#define HWIO_REG_206835_SHFT 0 -#define HWIO_REG_206835_IN in_dword_masked(\ - HWIO_REG_206835_ADDR, HWIO_REG_206835_RMSK) -#define HWIO_REG_206835_INM(m) \ - in_dword_masked(HWIO_REG_206835_ADDR, m) -#define HWIO_REG_206835_OUT(v) \ - out_dword(HWIO_REG_206835_ADDR, v) -#define HWIO_REG_206835_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_206835_ADDR, m, v,\ - HWIO_REG_206835_IN); -#define HWIO_REG_206835_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_206835_BASE_ADDR_SHFT 0 - -#define HWIO_REG_582575_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000760) -#define HWIO_REG_582575_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000760) -#define HWIO_REG_582575_RMSK 0x1ffff -#define HWIO_REG_582575_SHFT 0 -#define HWIO_REG_582575_IN in_dword_masked(\ - HWIO_REG_582575_ADDR, HWIO_REG_582575_RMSK) -#define HWIO_REG_582575_INM(m) \ - in_dword_masked(HWIO_REG_582575_ADDR, m) -#define HWIO_REG_582575_OUT(v) \ - out_dword(HWIO_REG_582575_ADDR, v) -#define HWIO_REG_582575_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_582575_ADDR, m, v,\ - HWIO_REG_582575_IN); -#define HWIO_REG_582575_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_582575_BASE_ADDR_SHFT 0 - -#define HWIO_REG_120885_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000764) -#define HWIO_REG_120885_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000764) -#define HWIO_REG_120885_RMSK 0x1ffff -#define HWIO_REG_120885_SHFT 0 -#define HWIO_REG_120885_IN in_dword_masked(\ - HWIO_REG_120885_ADDR, HWIO_REG_120885_RMSK) -#define HWIO_REG_120885_INM(m) \ - in_dword_masked(HWIO_REG_120885_ADDR, m) -#define HWIO_REG_120885_OUT(v) \ - out_dword(HWIO_REG_120885_ADDR, v) -#define HWIO_REG_120885_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_120885_ADDR, m, v,\ - HWIO_REG_120885_IN); -#define HWIO_REG_120885_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_120885_BASE_ADDR_SHFT 0 - -#define HWIO_REG_496067_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000768) -#define HWIO_REG_496067_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000768) -#define HWIO_REG_496067_RMSK 0x1ffff -#define HWIO_REG_496067_SHFT 0 -#define HWIO_REG_496067_IN in_dword_masked(\ - HWIO_REG_496067_ADDR, HWIO_REG_496067_RMSK) -#define HWIO_REG_496067_INM(m) \ - in_dword_masked(HWIO_REG_496067_ADDR, m) -#define HWIO_REG_496067_OUT(v) \ - out_dword(HWIO_REG_496067_ADDR, v) -#define HWIO_REG_496067_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_496067_ADDR, m, v,\ - HWIO_REG_496067_IN); -#define HWIO_REG_496067_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_496067_BASE_ADDR_SHFT 0 - -#define HWIO_REG_472919_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000076c) -#define HWIO_REG_472919_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000076c) -#define HWIO_REG_472919_RMSK 0x1ffff -#define HWIO_REG_472919_SHFT 0 -#define HWIO_REG_472919_IN in_dword_masked(\ - HWIO_REG_472919_ADDR, HWIO_REG_472919_RMSK) -#define HWIO_REG_472919_INM(m) \ - in_dword_masked(HWIO_REG_472919_ADDR, m) -#define HWIO_REG_472919_OUT(v) \ - out_dword(HWIO_REG_472919_ADDR, v) -#define HWIO_REG_472919_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_472919_ADDR, m, v,\ - HWIO_REG_472919_IN); -#define HWIO_REG_472919_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_472919_BASE_ADDR_SHFT 0 - -#define HWIO_REG_486985_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000770) -#define HWIO_REG_486985_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000770) -#define HWIO_REG_486985_RMSK 0x1ffff -#define HWIO_REG_486985_SHFT 0 -#define HWIO_REG_486985_IN in_dword_masked(\ - HWIO_REG_486985_ADDR, HWIO_REG_486985_RMSK) -#define HWIO_REG_486985_INM(m) \ - in_dword_masked(HWIO_REG_486985_ADDR, m) -#define HWIO_REG_486985_OUT(v) \ - out_dword(HWIO_REG_486985_ADDR, v) -#define HWIO_REG_486985_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_486985_ADDR, m, v,\ - HWIO_REG_486985_IN); -#define HWIO_REG_486985_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_486985_BASE_ADDR_SHFT 0 - -#define HWIO_REG_964692_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000774) -#define HWIO_REG_964692_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000774) -#define HWIO_REG_964692_RMSK 0x1ffff -#define HWIO_REG_964692_SHFT 0 -#define HWIO_REG_964692_IN in_dword_masked(\ - HWIO_REG_964692_ADDR, HWIO_REG_964692_RMSK) -#define HWIO_REG_964692_INM(m) \ - in_dword_masked(HWIO_REG_964692_ADDR, m) -#define HWIO_REG_964692_OUT(v) \ - out_dword(HWIO_REG_964692_ADDR, v) -#define HWIO_REG_964692_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_964692_ADDR, m, v,\ - HWIO_REG_964692_IN); -#define HWIO_REG_964692_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_964692_BASE_ADDR_SHFT 0 - -#define HWIO_REG_941116_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000778) -#define HWIO_REG_941116_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000778) -#define HWIO_REG_941116_RMSK 0x1ffff -#define HWIO_REG_941116_SHFT 0 -#define HWIO_REG_941116_IN in_dword_masked(\ - HWIO_REG_941116_ADDR, HWIO_REG_941116_RMSK) -#define HWIO_REG_941116_INM(m) \ - in_dword_masked(HWIO_REG_941116_ADDR, m) -#define HWIO_REG_941116_OUT(v) \ - out_dword(HWIO_REG_941116_ADDR, v) -#define HWIO_REG_941116_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_941116_ADDR, m, v,\ - HWIO_REG_941116_IN); -#define HWIO_REG_941116_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_941116_BASE_ADDR_SHFT 0 - -#define HWIO_REG_122567_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000077c) -#define HWIO_REG_122567_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000077c) -#define HWIO_REG_122567_RMSK 0x1ffff -#define HWIO_REG_122567_SHFT 0 -#define HWIO_REG_122567_IN in_dword_masked(\ - HWIO_REG_122567_ADDR, HWIO_REG_122567_RMSK) -#define HWIO_REG_122567_INM(m) \ - in_dword_masked(HWIO_REG_122567_ADDR, m) -#define HWIO_REG_122567_OUT(v) \ - out_dword(HWIO_REG_122567_ADDR, v) -#define HWIO_REG_122567_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_122567_ADDR, m, v,\ - HWIO_REG_122567_IN); -#define HWIO_REG_122567_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_122567_BASE_ADDR_SHFT 0 - -#define HWIO_REG_466192_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000780) -#define HWIO_REG_466192_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000780) -#define HWIO_REG_466192_RMSK 0x1ffff -#define HWIO_REG_466192_SHFT 0 -#define HWIO_REG_466192_IN in_dword_masked(\ - HWIO_REG_466192_ADDR, HWIO_REG_466192_RMSK) -#define HWIO_REG_466192_INM(m) \ - in_dword_masked(HWIO_REG_466192_ADDR, m) -#define HWIO_REG_466192_OUT(v) \ - out_dword(HWIO_REG_466192_ADDR, v) -#define HWIO_REG_466192_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_466192_ADDR, m, v,\ - HWIO_REG_466192_IN); -#define HWIO_REG_466192_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_466192_BASE_ADDR_SHFT 0 - -#define HWIO_REG_554890_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000784) -#define HWIO_REG_554890_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000784) -#define HWIO_REG_554890_RMSK 0x1ffff -#define HWIO_REG_554890_SHFT 0 -#define HWIO_REG_554890_IN in_dword_masked(\ - HWIO_REG_554890_ADDR, HWIO_REG_554890_RMSK) -#define HWIO_REG_554890_INM(m) \ - in_dword_masked(HWIO_REG_554890_ADDR, m) -#define HWIO_REG_554890_OUT(v) \ - out_dword(HWIO_REG_554890_ADDR, v) -#define HWIO_REG_554890_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_554890_ADDR, m, v,\ - HWIO_REG_554890_IN); -#define HWIO_REG_554890_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_554890_BASE_ADDR_SHFT 0 - -#define HWIO_REG_295616_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000788) -#define HWIO_REG_295616_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000788) -#define HWIO_REG_295616_RMSK 0x1ffff -#define HWIO_REG_295616_SHFT 0 -#define HWIO_REG_295616_IN in_dword_masked(\ - HWIO_REG_295616_ADDR, HWIO_REG_295616_RMSK) -#define HWIO_REG_295616_INM(m) \ - in_dword_masked(HWIO_REG_295616_ADDR, m) -#define HWIO_REG_295616_OUT(v) \ - out_dword(HWIO_REG_295616_ADDR, v) -#define HWIO_REG_295616_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_295616_ADDR, m, v,\ - HWIO_REG_295616_IN); -#define HWIO_REG_295616_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_295616_BASE_ADDR_SHFT 0 - -#define HWIO_REG_440836_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000078c) -#define HWIO_REG_440836_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000078c) -#define HWIO_REG_440836_RMSK 0x1ffff -#define HWIO_REG_440836_SHFT 0 -#define HWIO_REG_440836_IN in_dword_masked(\ - HWIO_REG_440836_ADDR, HWIO_REG_440836_RMSK) -#define HWIO_REG_440836_INM(m) \ - in_dword_masked(HWIO_REG_440836_ADDR, m) -#define HWIO_REG_440836_OUT(v) \ - out_dword(HWIO_REG_440836_ADDR, v) -#define HWIO_REG_440836_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_440836_ADDR, m, v,\ - HWIO_REG_440836_IN); -#define HWIO_REG_440836_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_440836_BASE_ADDR_SHFT 0 - -#define HWIO_REG_741154_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000790) -#define HWIO_REG_741154_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000790) -#define HWIO_REG_741154_RMSK 0x1ffff -#define HWIO_REG_741154_SHFT 0 -#define HWIO_REG_741154_IN in_dword_masked(\ - HWIO_REG_741154_ADDR,\ - HWIO_REG_741154_RMSK) -#define HWIO_REG_741154_INM(m) \ - in_dword_masked(HWIO_REG_741154_ADDR, m) -#define HWIO_REG_741154_OUT(v) \ - out_dword(HWIO_REG_741154_ADDR, v) -#define HWIO_REG_741154_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_741154_ADDR, m, v,\ - HWIO_REG_741154_IN); -#define HWIO_REG_741154_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_741154_BASE_ADDR_SHFT 0 - -#define HWIO_REG_753139_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000794) -#define HWIO_REG_753139_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000794) -#define HWIO_REG_753139_RMSK 0x1ffff -#define HWIO_REG_753139_SHFT 0 -#define HWIO_REG_753139_IN in_dword_masked(\ - HWIO_REG_753139_ADDR,\ - HWIO_REG_753139_RMSK) -#define HWIO_REG_753139_INM(m) \ - in_dword_masked(HWIO_REG_753139_ADDR, m) -#define HWIO_REG_753139_OUT(v) \ - out_dword(HWIO_REG_753139_ADDR, v) -#define HWIO_REG_753139_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_753139_ADDR, m, v,\ - HWIO_REG_753139_IN); -#define HWIO_REG_753139_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_753139_BASE_ADDR_SHFT 0 - -#define HWIO_REG_409994_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x00000798) -#define HWIO_REG_409994_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000798) -#define HWIO_REG_409994_RMSK 0x1ffff -#define HWIO_REG_409994_SHFT 0 -#define HWIO_REG_409994_IN in_dword_masked(\ - HWIO_REG_409994_ADDR,\ - HWIO_REG_409994_RMSK) -#define HWIO_REG_409994_INM(m) \ - in_dword_masked(HWIO_REG_409994_ADDR, m) -#define HWIO_REG_409994_OUT(v) \ - out_dword(HWIO_REG_409994_ADDR, v) -#define HWIO_REG_409994_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_409994_ADDR, m, v,\ - HWIO_REG_409994_IN); -#define HWIO_REG_409994_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_409994_BASE_ADDR_SHFT 0 - -#define HWIO_REG_492611_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000079c) -#define HWIO_REG_492611_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000079c) -#define HWIO_REG_492611_RMSK 0x1ffff -#define HWIO_REG_492611_SHFT 0 -#define HWIO_REG_492611_IN in_dword_masked(\ - HWIO_REG_492611_ADDR,\ - HWIO_REG_492611_RMSK) -#define HWIO_REG_492611_INM(m) \ - in_dword_masked(HWIO_REG_492611_ADDR, m) -#define HWIO_REG_492611_OUT(v) \ - out_dword(HWIO_REG_492611_ADDR, v) -#define HWIO_REG_492611_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_492611_ADDR, m, v,\ - HWIO_REG_492611_IN); -#define HWIO_REG_492611_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_492611_BASE_ADDR_SHFT 0 - -#define HWIO_REG_91427_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007a0) -#define HWIO_REG_91427_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007a0) -#define HWIO_REG_91427_RMSK 0x1ffff -#define HWIO_REG_91427_SHFT 0 -#define HWIO_REG_91427_IN in_dword_masked(\ - HWIO_REG_91427_ADDR,\ - HWIO_REG_91427_RMSK) -#define HWIO_REG_91427_INM(m) \ - in_dword_masked(HWIO_REG_91427_ADDR, m) -#define HWIO_REG_91427_OUT(v) \ - out_dword(HWIO_REG_91427_ADDR, v) -#define HWIO_REG_91427_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_91427_ADDR, m, v,\ - HWIO_REG_91427_IN); -#define HWIO_REG_91427_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_91427_BASE_ADDR_SHFT 0 - -#define HWIO_REG_617696_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007a4) -#define HWIO_REG_617696_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007a4) -#define HWIO_REG_617696_RMSK 0x1ffff -#define HWIO_REG_617696_SHFT 0 -#define HWIO_REG_617696_IN in_dword_masked(\ - HWIO_REG_617696_ADDR,\ - HWIO_REG_617696_RMSK) -#define HWIO_REG_617696_INM(m) \ - in_dword_masked(HWIO_REG_617696_ADDR, m) -#define HWIO_REG_617696_OUT(v) \ - out_dword(HWIO_REG_617696_ADDR, v) -#define HWIO_REG_617696_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_617696_ADDR, m, v,\ - HWIO_REG_617696_IN); -#define HWIO_REG_617696_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_617696_BASE_ADDR_SHFT 0 - -#define HWIO_REG_459602_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007a8) -#define HWIO_REG_459602_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007a8) -#define HWIO_REG_459602_RMSK 0x1ffff -#define HWIO_REG_459602_SHFT 0 -#define HWIO_REG_459602_IN in_dword_masked(\ - HWIO_REG_459602_ADDR,\ - HWIO_REG_459602_RMSK) -#define HWIO_REG_459602_INM(m) \ - in_dword_masked(HWIO_REG_459602_ADDR, m) -#define HWIO_REG_459602_OUT(v) \ - out_dword(HWIO_REG_459602_ADDR, v) -#define HWIO_REG_459602_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_459602_ADDR, m, v,\ - HWIO_REG_459602_IN); -#define HWIO_REG_459602_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_459602_BASE_ADDR_SHFT 0 - -#define HWIO_REG_758_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007ac) -#define HWIO_REG_758_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007ac) -#define HWIO_REG_758_RMSK 0x1ffff -#define HWIO_REG_758_SHFT 0 -#define HWIO_REG_758_IN in_dword_masked(\ - HWIO_REG_758_ADDR,\ - HWIO_REG_758_RMSK) -#define HWIO_REG_758_INM(m) \ - in_dword_masked(HWIO_REG_758_ADDR, m) -#define HWIO_REG_758_OUT(v) \ - out_dword(HWIO_REG_758_ADDR, v) -#define HWIO_REG_758_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_758_ADDR, m, v,\ - HWIO_REG_758_IN); -#define HWIO_REG_758_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_758_BASE_ADDR_SHFT 0 - -#define HWIO_REG_710606_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007b0) -#define HWIO_REG_710606_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007b0) -#define HWIO_REG_710606_RMSK 0x1ffff -#define HWIO_REG_710606_SHFT 0 -#define HWIO_REG_710606_IN in_dword_masked(\ - HWIO_REG_710606_ADDR,\ - HWIO_REG_710606_RMSK) -#define HWIO_REG_710606_INM(m) \ - in_dword_masked(HWIO_REG_710606_ADDR, m) -#define HWIO_REG_710606_OUT(v) \ - out_dword(HWIO_REG_710606_ADDR, v) -#define HWIO_REG_710606_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_710606_ADDR, m, v,\ - HWIO_REG_710606_IN); -#define HWIO_REG_710606_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_710606_BASE_ADDR_SHFT 0 - -#define HWIO_REG_122975_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007b4) -#define HWIO_REG_122975_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007b4) -#define HWIO_REG_122975_RMSK 0x1ffff -#define HWIO_REG_122975_SHFT 0 -#define HWIO_REG_122975_IN in_dword_masked(\ - HWIO_REG_122975_ADDR,\ - HWIO_REG_122975_RMSK) -#define HWIO_REG_122975_INM(m)\ - in_dword_masked(HWIO_REG_122975_ADDR, m) -#define HWIO_REG_122975_OUT(v)\ - out_dword(HWIO_REG_122975_ADDR, v) -#define HWIO_REG_122975_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_122975_ADDR, m, v,\ - HWIO_REG_122975_IN); -#define HWIO_REG_122975_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_122975_BASE_ADDR_SHFT 0 - -#define HWIO_REG_860205_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007b8) -#define HWIO_REG_860205_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007b8) -#define HWIO_REG_860205_RMSK 0x1ffff -#define HWIO_REG_860205_SHFT 0 -#define HWIO_REG_860205_IN in_dword_masked(\ - HWIO_REG_860205_ADDR,\ - HWIO_REG_860205_RMSK) -#define HWIO_REG_860205_INM(m) \ - in_dword_masked(HWIO_REG_860205_ADDR, m) -#define HWIO_REG_860205_OUT(v) \ - out_dword(HWIO_REG_860205_ADDR, v) -#define HWIO_REG_860205_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_860205_ADDR, m, v,\ - HWIO_REG_860205_IN); -#define HWIO_REG_860205_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_860205_BASE_ADDR_SHFT 0 - -#define HWIO_REG_366154_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007bc) -#define HWIO_REG_366154_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007bc) -#define HWIO_REG_366154_RMSK 0x1ffff -#define HWIO_REG_366154_SHFT 0 -#define HWIO_REG_366154_IN in_dword_masked(\ - HWIO_REG_366154_ADDR,\ - HWIO_REG_366154_RMSK) -#define HWIO_REG_366154_INM(m) \ - in_dword_masked(HWIO_REG_366154_ADDR, m) -#define HWIO_REG_366154_OUT(v) \ - out_dword(HWIO_REG_366154_ADDR, v) -#define HWIO_REG_366154_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_366154_ADDR, m, v,\ - HWIO_REG_366154_IN); -#define HWIO_REG_366154_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_366154_BASE_ADDR_SHFT 0 - -#define HWIO_REG_632247_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007c0) -#define HWIO_REG_632247_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007c0) -#define HWIO_REG_632247_RMSK 0x1ffff -#define HWIO_REG_632247_SHFT 0 -#define HWIO_REG_632247_IN in_dword_masked(\ - HWIO_REG_632247_ADDR,\ - HWIO_REG_632247_RMSK) -#define HWIO_REG_632247_INM(m) \ - in_dword_masked(HWIO_REG_632247_ADDR, m) -#define HWIO_REG_632247_OUT(v) \ - out_dword(HWIO_REG_632247_ADDR, v) -#define HWIO_REG_632247_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_632247_ADDR, m, v,\ - HWIO_REG_632247_IN); -#define HWIO_REG_632247_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_632247_BASE_ADDR_SHFT 0 - -#define HWIO_REG_709312_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007c4) -#define HWIO_REG_709312_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007c4) -#define HWIO_REG_709312_RMSK 0x1ffff -#define HWIO_REG_709312_SHFT 0 -#define HWIO_REG_709312_IN in_dword_masked(\ - HWIO_REG_709312_ADDR,\ - HWIO_REG_709312_RMSK) -#define HWIO_REG_709312_INM(m) \ - in_dword_masked(HWIO_REG_709312_ADDR, m) -#define HWIO_REG_709312_OUT(v) \ - out_dword(HWIO_REG_709312_ADDR, v) -#define HWIO_REG_709312_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_709312_ADDR, m, v,\ - HWIO_REG_709312_IN); -#define HWIO_REG_709312_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_709312_BASE_ADDR_SHFT 0 - -#define HWIO_REG_891367_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007c8) -#define HWIO_REG_891367_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007c8) -#define HWIO_REG_891367_RMSK 0x1ffff -#define HWIO_REG_891367_SHFT 0 -#define HWIO_REG_891367_IN in_dword_masked(\ - HWIO_REG_891367_ADDR,\ - HWIO_REG_891367_RMSK) -#define HWIO_REG_891367_INM(m) \ - in_dword_masked(HWIO_REG_891367_ADDR, m) -#define HWIO_REG_891367_OUT(v) \ - out_dword(HWIO_REG_891367_ADDR, v) -#define HWIO_REG_891367_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_891367_ADDR, m, v,\ - HWIO_REG_891367_IN); -#define HWIO_REG_891367_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_891367_BASE_ADDR_SHFT 0 - -#define HWIO_REG_628746_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007cc) -#define HWIO_REG_628746_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007cc) -#define HWIO_REG_628746_RMSK 0x1ffff -#define HWIO_REG_628746_SHFT 0 -#define HWIO_REG_628746_IN in_dword_masked(\ - HWIO_REG_628746_ADDR,\ - HWIO_REG_628746_RMSK) -#define HWIO_REG_628746_INM(m) \ - in_dword_masked(HWIO_REG_628746_ADDR, m) -#define HWIO_REG_628746_OUT(v) \ - out_dword(HWIO_REG_628746_ADDR, v) -#define HWIO_REG_628746_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_628746_ADDR, m, v,\ - HWIO_REG_628746_IN); -#define HWIO_REG_628746_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_628746_BASE_ADDR_SHFT 0 - -#define HWIO_REG_821010_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007d0) -#define HWIO_REG_821010_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007d0) -#define HWIO_REG_821010_RMSK 0x1ffff -#define HWIO_REG_821010_SHFT 0 -#define HWIO_REG_821010_IN in_dword_masked(\ - HWIO_REG_821010_ADDR,\ - HWIO_REG_821010_RMSK) -#define HWIO_REG_821010_INM(m) \ - in_dword_masked(HWIO_REG_821010_ADDR, m) -#define HWIO_REG_821010_OUT(v) \ - out_dword(HWIO_REG_821010_ADDR, v) -#define HWIO_REG_821010_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_821010_ADDR, m, v,\ - HWIO_REG_821010_IN); -#define HWIO_REG_821010_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_821010_BASE_ADDR_SHFT 0 - -#define HWIO_REG_902098_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007d4) -#define HWIO_REG_902098_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007d4) -#define HWIO_REG_902098_RMSK 0x1ffff -#define HWIO_REG_902098_SHFT 0 -#define HWIO_REG_902098_IN in_dword_masked(\ - HWIO_REG_902098_ADDR,\ - HWIO_REG_902098_RMSK) -#define HWIO_REG_902098_INM(m) \ - in_dword_masked(HWIO_REG_902098_ADDR, m) -#define HWIO_REG_902098_OUT(v) \ - out_dword(HWIO_REG_902098_ADDR, v) -#define HWIO_REG_902098_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_902098_ADDR, m, v,\ - HWIO_REG_902098_IN); -#define HWIO_REG_902098_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_902098_BASE_ADDR_SHFT 0 - -#define HWIO_REG_939091_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007d8) -#define HWIO_REG_939091_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007d8) -#define HWIO_REG_939091_RMSK 0x1ffff -#define HWIO_REG_939091_SHFT 0 -#define HWIO_REG_939091_IN in_dword_masked(\ - HWIO_REG_939091_ADDR,\ - HWIO_REG_939091_RMSK) -#define HWIO_REG_939091_INM(m) \ - in_dword_masked(HWIO_REG_939091_ADDR, m) -#define HWIO_REG_939091_OUT(v) \ - out_dword(HWIO_REG_939091_ADDR, v) -#define HWIO_REG_939091_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_939091_ADDR, m, v,\ - HWIO_REG_939091_IN); -#define HWIO_REG_939091_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_939091_BASE_ADDR_SHFT 0 - -#define HWIO_REG_261074_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007dc) -#define HWIO_REG_261074_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007dc) -#define HWIO_REG_261074_RMSK 0x1ffff -#define HWIO_REG_261074_SHFT 0 -#define HWIO_REG_261074_IN in_dword_masked(\ - HWIO_REG_261074_ADDR,\ - HWIO_REG_261074_RMSK) -#define HWIO_REG_261074_INM(m) \ - in_dword_masked(HWIO_REG_261074_ADDR, m) -#define HWIO_REG_261074_OUT(v) \ - out_dword(HWIO_REG_261074_ADDR, v) -#define HWIO_REG_261074_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_261074_ADDR, m, v,\ - HWIO_REG_261074_IN); -#define HWIO_REG_261074_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_261074_BASE_ADDR_SHFT 0 - -#define HWIO_REG_157718_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007e0) -#define HWIO_REG_157718_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007e0) -#define HWIO_REG_157718_RMSK 0x1ffff -#define HWIO_REG_157718_SHFT 0 -#define HWIO_REG_157718_IN in_dword_masked(\ - HWIO_REG_157718_ADDR,\ - HWIO_REG_157718_RMSK) -#define HWIO_REG_157718_INM(m) \ - in_dword_masked(HWIO_REG_157718_ADDR, m) -#define HWIO_REG_157718_OUT(v) \ - out_dword(HWIO_REG_157718_ADDR, v) -#define HWIO_REG_157718_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_157718_ADDR, m, v,\ - HWIO_REG_157718_IN); -#define HWIO_REG_5552391_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_5552391_BASE_ADDR_SHFT 0 - -#define HWIO_REG_148889_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007e8) -#define HWIO_REG_148889_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007e8) -#define HWIO_REG_148889_RMSK 0x1ffff -#define HWIO_REG_148889_SHFT 0 -#define HWIO_REG_148889_IN in_dword_masked(\ - HWIO_REG_148889_ADDR,\ - HWIO_REG_148889_RMSK) -#define HWIO_REG_148889_INM(m) \ - in_dword_masked(HWIO_REG_148889_ADDR, m) -#define HWIO_REG_148889_OUT(v) \ - out_dword(HWIO_REG_148889_ADDR, v) -#define HWIO_REG_148889_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_148889_ADDR, m, v,\ - HWIO_REG_148889_IN); -#define HWIO_REG_148889_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_148889_BASE_ADDR_SHFT 0 - -#define HWIO_REG_396380_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007ec) -#define HWIO_REG_396380_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007ec) -#define HWIO_REG_396380_RMSK 0x1ffff -#define HWIO_REG_396380_SHFT 0 -#define HWIO_REG_396380_IN in_dword_masked(\ - HWIO_REG_396380_ADDR,\ - HWIO_REG_396380_RMSK) -#define HWIO_REG_396380_INM(m) \ - in_dword_masked(HWIO_REG_396380_ADDR, m) -#define HWIO_REG_396380_OUT(v) \ - out_dword(HWIO_REG_396380_ADDR, v) -#define HWIO_REG_396380_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_396380_ADDR, m, v,\ - HWIO_REG_396380_IN); -#define HWIO_REG_396380_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_396380_BASE_ADDR_SHFT 0 - -#define HWIO_REG_351005_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007f0) -#define HWIO_REG_351005_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007f0) -#define HWIO_REG_351005_RMSK 0x1ffff -#define HWIO_REG_351005_SHFT 0 -#define HWIO_REG_351005_IN in_dword_masked(\ - HWIO_REG_351005_ADDR,\ - HWIO_REG_351005_RMSK) -#define HWIO_REG_351005_INM(m) \ - in_dword_masked(HWIO_REG_351005_ADDR, m) -#define HWIO_REG_351005_OUT(v) \ - out_dword(HWIO_REG_351005_ADDR, v) -#define HWIO_REG_351005_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_351005_ADDR, m, v,\ - HWIO_REG_351005_IN); -#define HWIO_REG_351005_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_351005_BASE_ADDR_SHFT 0 - -#define HWIO_REG_863263_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007f4) -#define HWIO_REG_863263_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007f4) -#define HWIO_REG_863263_RMSK 0x1ffff -#define HWIO_REG_863263_SHFT 0 -#define HWIO_REG_863263_IN in_dword_masked(\ - HWIO_REG_863263_ADDR,\ - HWIO_REG_863263_RMSK) -#define HWIO_REG_863263_INM(m) \ - in_dword_masked(HWIO_REG_863263_ADDR, m) -#define HWIO_REG_863263_OUT(v) \ - out_dword(HWIO_REG_863263_ADDR, v) -#define HWIO_REG_863263_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_863263_ADDR, m, v,\ - HWIO_REG_863263_IN); -#define HWIO_REG_863263_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_863263_BASE_ADDR_SHFT 0 - -#define HWIO_REG_135009_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007f8) -#define HWIO_REG_135009_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007f8) -#define HWIO_REG_135009_RMSK 0x1ffff -#define HWIO_REG_135009_SHFT 0 -#define HWIO_REG_135009_IN in_dword_masked(\ - HWIO_REG_135009_ADDR,\ - HWIO_REG_135009_RMSK) -#define HWIO_REG_135009_INM(m) \ - in_dword_masked(HWIO_REG_135009_ADDR, m) -#define HWIO_REG_135009_OUT(v) \ - out_dword(HWIO_REG_135009_ADDR, v) -#define HWIO_REG_135009_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_135009_ADDR, m, v,\ - HWIO_REG_135009_IN); -#define HWIO_REG_135009_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_135009_BASE_ADDR_SHFT 0 - -#define HWIO_REG_923883_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x000007fc) -#define HWIO_REG_923883_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000007fc) -#define HWIO_REG_923883_RMSK 0x1ffff -#define HWIO_REG_923883_SHFT 0 -#define HWIO_REG_923883_IN in_dword_masked(\ - HWIO_REG_923883_ADDR,\ - HWIO_REG_923883_RMSK) -#define HWIO_REG_923883_INM(m) \ - in_dword_masked(HWIO_REG_923883_ADDR, m) -#define HWIO_REG_923883_OUT(v) \ - out_dword(HWIO_REG_923883_ADDR, v) -#define HWIO_REG_923883_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_923883_ADDR, m, v,\ - HWIO_REG_923883_IN); -#define HWIO_REG_923883_BASE_ADDR_BMSK 0x1ffff -#define HWIO_REG_923883_BASE_ADDR_SHFT 0 - -#define HWIO_REG_934655_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000818) -#define HWIO_REG_934655_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000818) -#define HWIO_REG_934655_RMSK 0x1fff -#define HWIO_REG_934655_SHFT 0 -#define HWIO_REG_934655_IN \ - in_dword_masked(HWIO_REG_934655_ADDR, HWIO_REG_934655_RMSK) -#define HWIO_REG_934655_INM(m) \ - in_dword_masked(HWIO_REG_934655_ADDR, m) -#define HWIO_REG_934655_OUT(v) \ - out_dword(HWIO_REG_934655_ADDR, v) -#define HWIO_REG_934655_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_934655_ADDR, m, v, HWIO_REG_934655_IN); -#define HWIO_REG_934655_FRAME_WIDTH_BMSK 0x1fff -#define HWIO_REG_934655_FRAME_WIDTH_SHFT 0 - -#define HWIO_REG_179070_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000081c) -#define HWIO_REG_179070_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000081c) -#define HWIO_REG_179070_RMSK 0x1fff -#define HWIO_REG_179070_SHFT 0 -#define HWIO_REG_179070_IN in_dword_masked(\ - HWIO_REG_179070_ADDR, HWIO_REG_179070_RMSK) -#define HWIO_REG_179070_INM(m) \ - in_dword_masked(HWIO_REG_179070_ADDR, m) -#define HWIO_REG_179070_OUT(v) \ - out_dword(HWIO_REG_179070_ADDR, v) -#define HWIO_REG_179070_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_179070_ADDR, m, v, HWIO_REG_179070_IN); -#define HWIO_REG_179070_FRAME_HEIGHT_BMSK 0x1fff -#define HWIO_REG_179070_FRAME_HEIGHT_SHFT 0 - -#define HWIO_REG_63643_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000830) -#define HWIO_REG_63643_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000830) -#define HWIO_REG_63643_RMSK 0xff3f -#define HWIO_REG_63643_SHFT 0 -#define HWIO_REG_63643_IN in_dword_masked(\ - HWIO_REG_63643_ADDR, HWIO_REG_63643_RMSK) -#define HWIO_REG_63643_INM(m) \ - in_dword_masked(HWIO_REG_63643_ADDR, m) -#define HWIO_REG_63643_OUT(v) \ - out_dword(HWIO_REG_63643_ADDR, v) -#define HWIO_REG_63643_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_63643_ADDR, m, v, HWIO_REG_63643_IN); -#define HWIO_REG_63643_LEVEL_BMSK 0xff00 -#define HWIO_REG_63643_LEVEL_SHFT 0x8 -#define HWIO_REG_63643_PROFILE_BMSK 0x3f -#define HWIO_REG_63643_PROFILE_SHFT 0 - -#define HWIO_REG_786024_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000083c) -#define HWIO_REG_786024_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000083c) -#define HWIO_REG_786024_RMSK 0x1 -#define HWIO_REG_786024_SHFT 0 -#define HWIO_REG_786024_IN in_dword_masked(\ - HWIO_REG_786024_ADDR, HWIO_REG_786024_RMSK) -#define HWIO_REG_786024_INM(m) \ - in_dword_masked(HWIO_REG_786024_ADDR, m) -#define HWIO_REG_786024_OUT(v) \ - out_dword(HWIO_REG_786024_ADDR, v) -#define HWIO_REG_786024_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_786024_ADDR, m, v, HWIO_REG_786024_IN); -#define HWIO_REG_786024_FIELD_BMSK 0x1 -#define HWIO_REG_786024_FIELD_SHFT 0 - -#define HWIO_REG_152500_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000848) -#define HWIO_REG_152500_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000848) -#define HWIO_REG_152500_RMSK 0x3 -#define HWIO_REG_152500_SHFT 0 -#define HWIO_REG_152500_IN in_dword_masked(\ - HWIO_REG_152500_ADDR, HWIO_REG_152500_RMSK) -#define HWIO_REG_152500_INM(m) \ - in_dword_masked(HWIO_REG_152500_ADDR, m) -#define HWIO_REG_152500_OUT(v) \ - out_dword(HWIO_REG_152500_ADDR, v) -#define HWIO_REG_152500_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_152500_ADDR, m, v, HWIO_REG_152500_IN); -#define HWIO_REG_152500_LF_CONTROL_BMSK 0x3 -#define HWIO_REG_152500_LF_CONTROL_SHFT 0 - -#define HWIO_REG_266285_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000084c) -#define HWIO_REG_266285_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000084c) -#define HWIO_REG_266285_RMSK 0x1f -#define HWIO_REG_266285_SHFT 0 -#define HWIO_REG_266285_IN in_dword_masked(\ - HWIO_REG_266285_ADDR, HWIO_REG_266285_RMSK) -#define HWIO_REG_266285_INM(m) \ - in_dword_masked(HWIO_REG_266285_ADDR, m) -#define HWIO_REG_266285_OUT(v) \ - out_dword(HWIO_REG_266285_ADDR, v) -#define HWIO_REG_266285_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_266285_ADDR, m, v, HWIO_REG_266285_IN); -#define HWIO_REG_266285_LF_ALPHAS_OFF_BMSK 0x1f -#define HWIO_REG_266285_LF_ALPHAS_OFF_SHFT 0 - -#define HWIO_REG_964731_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000850) -#define HWIO_REG_964731_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000850) -#define HWIO_REG_964731_RMSK 0x1f -#define HWIO_REG_964731_SHFT 0 -#define HWIO_REG_964731_IN in_dword_masked(\ - HWIO_REG_964731_ADDR, HWIO_REG_964731_RMSK) -#define HWIO_REG_964731_INM(m) \ - in_dword_masked(HWIO_REG_964731_ADDR, m) -#define HWIO_REG_964731_OUT(v) \ - out_dword(HWIO_REG_964731_ADDR, v) -#define HWIO_REG_964731_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_964731_ADDR, m, v, HWIO_REG_964731_IN); -#define HWIO_REG_964731_LF_BETA_OFF_BMSK 0x1f -#define HWIO_REG_964731_LF_BETA_OFF_SHFT 0 - -#define HWIO_REG_919924_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000c30) -#define HWIO_REG_919924_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000c30) -#define HWIO_REG_919924_RMSK 0xffffffff -#define HWIO_REG_919924_SHFT 0 -#define HWIO_REG_919924_IN in_dword_masked(\ - HWIO_REG_919924_ADDR, HWIO_REG_919924_RMSK) -#define HWIO_REG_919924_INM(m) \ - in_dword_masked(HWIO_REG_919924_ADDR, m) -#define HWIO_REG_919924_OUT(v) \ - out_dword(HWIO_REG_919924_ADDR, v) -#define HWIO_REG_919924_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_919924_ADDR, m, v, HWIO_REG_919924_IN); -#define HWIO_REG_919924_VIDC_QP_OFFSET_BMSK 0xffffffff -#define HWIO_REG_919924_VIDC_QP_OFFSET_SHFT 0 - -#define HWIO_REG_143629_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00000c34) -#define HWIO_REG_143629_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00000c34) -#define HWIO_REG_143629_RMSK 0x1 -#define HWIO_REG_143629_SHFT 0 -#define HWIO_REG_143629_IN in_dword_masked(\ - HWIO_REG_143629_ADDR, HWIO_REG_143629_RMSK) -#define HWIO_REG_143629_INM(m) \ - in_dword_masked(HWIO_REG_143629_ADDR, m) -#define HWIO_REG_143629_OUT(v) \ - out_dword(HWIO_REG_143629_ADDR, v) -#define HWIO_REG_143629_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_143629_ADDR, m, v, HWIO_REG_143629_IN); -#define HWIO_REG_143629_REG_143629_BMSK 0x1 -#define HWIO_REG_143629_REG_143629_SHFT 0 - -#define HWIO_REG_607589_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002000) -#define HWIO_REG_607589_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002000) -#define HWIO_REG_607589_RMSK 0xffffffff -#define HWIO_REG_607589_SHFT 0 -#define HWIO_REG_607589_IN in_dword_masked(\ - HWIO_REG_607589_ADDR, HWIO_REG_607589_RMSK) -#define HWIO_REG_607589_INM(m) \ - in_dword_masked(HWIO_REG_607589_ADDR, m) -#define HWIO_REG_607589_OUT(v) \ - out_dword(HWIO_REG_607589_ADDR, v) -#define HWIO_REG_607589_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_607589_ADDR, m, v, HWIO_REG_607589_IN); -#define HWIO_REG_607589_RTN_CHID_BMSK 0xffffffff -#define HWIO_REG_607589_RTN_CHID_SHFT 0 - -#define HWIO_REG_845544_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002004) -#define HWIO_REG_845544_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002004) -#define HWIO_REG_845544_RMSK 0xffffffff -#define HWIO_REG_845544_SHFT 0 -#define HWIO_REG_845544_IN in_dword_masked(\ - HWIO_REG_845544_ADDR, HWIO_REG_845544_RMSK) -#define HWIO_REG_845544_INM(m) \ - in_dword_masked(HWIO_REG_845544_ADDR, m) -#define HWIO_REG_845544_OUT(v) \ - out_dword(HWIO_REG_845544_ADDR, v) -#define HWIO_REG_845544_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_845544_ADDR, m, v, HWIO_REG_845544_IN); -#define HWIO_REG_845544_REG_845544_BMSK 0xffffffff -#define HWIO_REG_845544_REG_845544_SHFT 0 - -#define HWIO_REG_859906_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002008) -#define HWIO_REG_859906_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002008) -#define HWIO_REG_859906_RMSK 0xffffffff -#define HWIO_REG_859906_SHFT 0 -#define HWIO_REG_859906_IN in_dword_masked(\ - HWIO_REG_859906_ADDR, HWIO_REG_859906_RMSK) -#define HWIO_REG_859906_INM(m) \ - in_dword_masked(HWIO_REG_859906_ADDR, m) -#define HWIO_REG_859906_OUT(v) \ - out_dword(HWIO_REG_859906_ADDR, v) -#define HWIO_REG_859906_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_859906_ADDR, m, v, HWIO_REG_859906_IN); -#define HWIO_REG_859906_REG_859906_BMSK 0xffffffff -#define HWIO_REG_859906_REG_859906_SHFT 0 - -#define HWIO_REG_490078_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000200c) -#define HWIO_REG_490078_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000200c) -#define HWIO_REG_490078_RMSK 0xffffffff -#define HWIO_REG_490078_SHFT 0 -#define HWIO_REG_490078_IN in_dword_masked(\ - HWIO_REG_490078_ADDR, HWIO_REG_490078_RMSK) -#define HWIO_REG_490078_INM(m) \ - in_dword_masked(HWIO_REG_490078_ADDR, m) -#define HWIO_REG_490078_OUT(v) \ - out_dword(HWIO_REG_490078_ADDR, v) -#define HWIO_REG_490078_OUTM(m, v) \ - out_dword_masked_ns(HWIO_REG_490078_ADDR, m, v,\ - HWIO_REG_490078_IN); -#define HWIO_REG_490078_REG_490078_BMSK 0xffffffff -#define HWIO_REG_490078_REG_490078_SHFT 0 - -#define HWIO_REG_640904_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002010) -#define HWIO_REG_640904_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002010) -#define HWIO_REG_640904_RMSK 0xffffffff -#define HWIO_REG_640904_SHFT 0 -#define HWIO_REG_640904_IN in_dword_masked(\ - HWIO_REG_640904_ADDR, HWIO_REG_640904_RMSK) -#define HWIO_REG_640904_INM(m) \ - in_dword_masked(HWIO_REG_640904_ADDR, m) -#define HWIO_REG_640904_OUT(v) \ - out_dword(HWIO_REG_640904_ADDR, v) -#define HWIO_REG_640904_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_640904_ADDR, m, v, HWIO_REG_640904_IN); -#define HWIO_REG_640904_REG_640904_BMSK 0xffffffff -#define HWIO_REG_640904_REG_640904_SHFT 0 - -#define HWIO_REG_60114_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002014) -#define HWIO_REG_60114_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002014) -#define HWIO_REG_60114_RMSK 0xffffffff -#define HWIO_REG_60114_SHFT 0 -#define HWIO_REG_60114_IN in_dword_masked(\ - HWIO_REG_60114_ADDR, HWIO_REG_60114_RMSK) -#define HWIO_REG_60114_INM(m) \ - in_dword_masked(HWIO_REG_60114_ADDR, m) -#define HWIO_REG_60114_OUT(v) \ - out_dword(HWIO_REG_60114_ADDR, v) -#define HWIO_REG_60114_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_60114_ADDR, m, v, HWIO_REG_60114_IN); -#define HWIO_REG_60114_REG_60114_BMSK 0xffffffff -#define HWIO_REG_60114_REG_60114_SHFT 0 - -#define HWIO_REG_489688_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002018) -#define HWIO_REG_489688_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002018) -#define HWIO_REG_489688_RMSK 0xffffffff -#define HWIO_REG_489688_SHFT 0 -#define HWIO_REG_489688_IN in_dword_masked(\ - HWIO_REG_489688_ADDR, HWIO_REG_489688_RMSK) -#define HWIO_REG_489688_INM(m) \ - in_dword_masked(HWIO_REG_489688_ADDR, m) -#define HWIO_REG_489688_OUT(v) \ - out_dword(HWIO_REG_489688_ADDR, v) -#define HWIO_REG_489688_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_489688_ADDR, m, v, HWIO_REG_489688_IN); -#define HWIO_REG_489688_REG_489688_BMSK 0xffffffff -#define HWIO_REG_489688_REG_489688_SHFT 0 - -#define HWIO_REG_853667_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000201c) -#define HWIO_REG_853667_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000201c) -#define HWIO_REG_853667_RMSK 0xffffffff -#define HWIO_REG_853667_SHFT 0 -#define HWIO_REG_853667_IN in_dword_masked(\ - HWIO_REG_853667_ADDR, HWIO_REG_853667_RMSK) -#define HWIO_REG_853667_INM(m) \ - in_dword_masked(HWIO_REG_853667_ADDR, m) -#define HWIO_REG_853667_OUT(v) \ - out_dword(HWIO_REG_853667_ADDR, v) -#define HWIO_REG_853667_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_853667_ADDR, m, v, HWIO_REG_853667_IN); -#define HWIO_REG_853667_REG_853667_BMSK 0xffffffff -#define HWIO_REG_853667_REG_853667_SHFT 0 - -#define HWIO_REG_760102_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002020) -#define HWIO_REG_760102_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002020) -#define HWIO_REG_760102_RMSK 0xffffffff -#define HWIO_REG_760102_SHFT 0 -#define HWIO_REG_760102_IN in_dword_masked(\ - HWIO_REG_760102_ADDR, HWIO_REG_760102_RMSK) -#define HWIO_REG_760102_INM(m) \ - in_dword_masked(HWIO_REG_760102_ADDR, m) -#define HWIO_REG_760102_OUT(v) \ - out_dword(HWIO_REG_760102_ADDR, v) -#define HWIO_REG_760102_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_760102_ADDR, m, v, HWIO_REG_760102_IN); -#define HWIO_REG_760102_REG_760102_BMSK 0xffffffff -#define HWIO_REG_760102_REG_760102_SHFT 0 - -#define HWIO_REG_378318_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002024) -#define HWIO_REG_378318_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002024) -#define HWIO_REG_378318_RMSK 0xffffffff -#define HWIO_REG_378318_SHFT 0 -#define HWIO_REG_378318_IN in_dword_masked(\ - HWIO_REG_378318_ADDR, HWIO_REG_378318_RMSK) -#define HWIO_REG_378318_INM(m) \ - in_dword_masked(HWIO_REG_378318_ADDR, m) -#define HWIO_REG_378318_OUT(v) \ - out_dword(HWIO_REG_378318_ADDR, v) -#define HWIO_REG_378318_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_378318_ADDR, m, v, HWIO_REG_378318_IN); -#define HWIO_REG_378318_REG_378318_BMSK 0xffffffff -#define HWIO_REG_378318_REG_378318_SHFT 0 - -#define HWIO_REG_203487_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002028) -#define HWIO_REG_203487_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002028) -#define HWIO_REG_203487_RMSK 0xffffffff -#define HWIO_REG_203487_SHFT 0 -#define HWIO_REG_203487_IN in_dword_masked(\ - HWIO_REG_203487_ADDR, HWIO_REG_203487_RMSK) -#define HWIO_REG_203487_INM(m) \ - in_dword_masked(HWIO_REG_203487_ADDR, m) -#define HWIO_REG_203487_OUT(v) \ - out_dword(HWIO_REG_203487_ADDR, v) -#define HWIO_REG_203487_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_203487_ADDR, m, v, HWIO_REG_203487_IN); -#define HWIO_REG_203487_REG_203487_BMSK 0xffffffff -#define HWIO_REG_203487_REG_203487_SHFT 0 - -#define HWIO_REG_692991_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000202c) -#define HWIO_REG_692991_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000202c) -#define HWIO_REG_692991_RMSK 0xffffffff -#define HWIO_REG_692991_SHFT 0 -#define HWIO_REG_692991_IN in_dword_masked(\ - HWIO_REG_692991_ADDR, HWIO_REG_692991_RMSK) -#define HWIO_REG_692991_INM(m) \ - in_dword_masked(HWIO_REG_692991_ADDR, m) -#define HWIO_REG_692991_OUT(v) \ - out_dword(HWIO_REG_692991_ADDR, v) -#define HWIO_REG_692991_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_692991_ADDR, m, v, HWIO_REG_692991_IN); -#define HWIO_REG_692991_REG_692991_BMSK 0xffffffff -#define HWIO_REG_692991_REG_692991_SHFT 0 - -#define HWIO_REG_161740_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002030) -#define HWIO_REG_161740_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002030) -#define HWIO_REG_161740_RMSK 0xffffffff -#define HWIO_REG_161740_SHFT 0 -#define HWIO_REG_161740_IN in_dword_masked(\ - HWIO_REG_161740_ADDR, HWIO_REG_161740_RMSK) -#define HWIO_REG_161740_INM(m) \ - in_dword_masked(HWIO_REG_161740_ADDR, m) -#define HWIO_REG_161740_OUT(v) \ - out_dword(HWIO_REG_161740_ADDR, v) -#define HWIO_REG_161740_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_161740_ADDR, m, v, HWIO_REG_161740_IN); -#define HWIO_REG_161740_REG_161740_BMSK 0xffffffff -#define HWIO_REG_161740_REG_161740_SHFT 0 - -#define HWIO_REG_930239_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002034) -#define HWIO_REG_930239_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002034) -#define HWIO_REG_930239_RMSK 0xffffffff -#define HWIO_REG_930239_SHFT 0 -#define HWIO_REG_930239_IN in_dword_masked(\ - HWIO_REG_930239_ADDR, HWIO_REG_930239_RMSK) -#define HWIO_REG_930239_INM(m) \ - in_dword_masked(HWIO_REG_930239_ADDR, m) -#define HWIO_REG_930239_OUT(v) \ - out_dword(HWIO_REG_930239_ADDR, v) -#define HWIO_REG_930239_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_930239_ADDR, m, v, HWIO_REG_930239_IN); -#define HWIO_REG_930239_REG_930239_BMSK 0xffffffff -#define HWIO_REG_930239_REG_930239_SHFT 0 - -#define HWIO_REG_567827_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002038) -#define HWIO_REG_567827_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002038) -#define HWIO_REG_567827_RMSK 0xffffffff -#define HWIO_REG_567827_SHFT 0 -#define HWIO_REG_567827_IN in_dword_masked(\ - HWIO_REG_567827_ADDR, HWIO_REG_567827_RMSK) -#define HWIO_REG_567827_INM(m) \ - in_dword_masked(HWIO_REG_567827_ADDR, m) -#define HWIO_REG_567827_OUT(v) \ - out_dword(HWIO_REG_567827_ADDR, v) -#define HWIO_REG_567827_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_567827_ADDR, m, v, HWIO_REG_567827_IN); -#define HWIO_REG_567827_REG_567827_BMSK 0xffffffff -#define HWIO_REG_567827_REG_567827_SHFT 0 - -#define HWIO_REG_542997_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000203c) -#define HWIO_REG_542997_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000203c) -#define HWIO_REG_542997_RMSK 0xffffffff -#define HWIO_REG_542997_SHFT 0 -#define HWIO_REG_542997_IN in_dword_masked(\ - HWIO_REG_542997_ADDR, HWIO_REG_542997_RMSK) -#define HWIO_REG_542997_INM(m) \ - in_dword_masked(HWIO_REG_542997_ADDR, m) -#define HWIO_REG_542997_OUT(v) \ - out_dword(HWIO_REG_542997_ADDR, v) -#define HWIO_REG_542997_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_542997_ADDR, m, v, HWIO_REG_542997_IN); -#define HWIO_REG_542997_REG_542997_BMSK 0xffffffff -#define HWIO_REG_542997_REG_542997_SHFT 0 - -#define HWIO_REG_666957_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002040) -#define HWIO_REG_666957_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002040) -#define HWIO_REG_666957_RMSK 0x7ffff -#define HWIO_REG_666957_SHFT 0 -#define HWIO_REG_666957_IN in_dword_masked(\ - HWIO_REG_666957_ADDR, HWIO_REG_666957_RMSK) -#define HWIO_REG_666957_INM(m) \ - in_dword_masked(HWIO_REG_666957_ADDR, m) -#define HWIO_REG_666957_OUT(v) \ - out_dword(HWIO_REG_666957_ADDR, v) -#define HWIO_REG_666957_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_666957_ADDR, m, v, HWIO_REG_666957_IN); -#define HWIO_REG_666957_CH_DEC_TYPE_BMSK 0x70000 -#define HWIO_REG_666957_CH_DEC_TYPE_SHFT 0x10 -#define HWIO_REG_666957_CH_INST_ID_BMSK 0xffff -#define HWIO_REG_666957_CH_INST_ID_SHFT 0 - -#define HWIO_REG_117192_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002044) -#define HWIO_REG_117192_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002044) -#define HWIO_REG_117192_RMSK 0xffffffff -#define HWIO_REG_117192_SHFT 0 -#define HWIO_REG_117192_IN in_dword_masked(\ - HWIO_REG_117192_ADDR, HWIO_REG_117192_RMSK) -#define HWIO_REG_117192_INM(m) \ - in_dword_masked(HWIO_REG_117192_ADDR, m) -#define HWIO_REG_117192_OUT(v) \ - out_dword(HWIO_REG_117192_ADDR, v) -#define HWIO_REG_117192_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_117192_ADDR, m, v, HWIO_REG_117192_IN); -#define HWIO_REG_117192_REG_117192_BMSK 0xffffffff -#define HWIO_REG_117192_REG_117192_SHFT 0 - -#define HWIO_REG_145068_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002048) -#define HWIO_REG_145068_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002048) -#define HWIO_REG_145068_RMSK 0xffffffff -#define HWIO_REG_145068_SHFT 0 -#define HWIO_REG_145068_IN in_dword_masked(\ - HWIO_REG_145068_ADDR, HWIO_REG_145068_RMSK) -#define HWIO_REG_145068_INM(m) \ - in_dword_masked(HWIO_REG_145068_ADDR, m) -#define HWIO_REG_145068_OUT(v) \ - out_dword(HWIO_REG_145068_ADDR, v) -#define HWIO_REG_145068_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_145068_ADDR, m, v, HWIO_REG_145068_IN); -#define HWIO_REG_145068_REG_145068_BMSK 0xffffffff -#define HWIO_REG_145068_REG_145068_SHFT 0 - -#define HWIO_REG_921356_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000204c) -#define HWIO_REG_921356_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000204c) -#define HWIO_REG_921356_RMSK 0xffffffff -#define HWIO_REG_921356_SHFT 0 -#define HWIO_REG_921356_IN in_dword_masked(\ - HWIO_REG_921356_ADDR, HWIO_REG_921356_RMSK) -#define HWIO_REG_921356_INM(m) \ - in_dword_masked(HWIO_REG_921356_ADDR, m) -#define HWIO_REG_921356_OUT(v) \ - out_dword(HWIO_REG_921356_ADDR, v) -#define HWIO_REG_921356_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_921356_ADDR, m, v, HWIO_REG_921356_IN); -#define HWIO_REG_921356_REG_921356_BMSK 0xffffffff -#define HWIO_REG_921356_REG_921356_SHFT 0 - -#define HWIO_REG_612810_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002050) -#define HWIO_REG_612810_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002050) -#define HWIO_REG_612810_RMSK 0xffffffff -#define HWIO_REG_612810_SHFT 0 -#define HWIO_REG_612810_IN in_dword_masked(\ - HWIO_REG_612810_ADDR, HWIO_REG_612810_RMSK) -#define HWIO_REG_612810_INM(m) \ - in_dword_masked(HWIO_REG_612810_ADDR, m) -#define HWIO_REG_612810_OUT(v) \ - out_dword(HWIO_REG_612810_ADDR, v) -#define HWIO_REG_612810_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_612810_ADDR, m, v, HWIO_REG_612810_IN); -#define HWIO_REG_612810_REG_612810_BMSK 0xffffffff -#define HWIO_REG_612810_REG_612810_SHFT 0 - -#define HWIO_REG_175608_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002054) -#define HWIO_REG_175608_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002054) -#define HWIO_REG_175608_RMSK 0xffffffff -#define HWIO_REG_175608_SHFT 0 -#define HWIO_REG_175608_IN in_dword_masked(\ - HWIO_REG_175608_ADDR, HWIO_REG_175608_RMSK) -#define HWIO_REG_175608_INM(m) \ - in_dword_masked(HWIO_REG_175608_ADDR, m) -#define HWIO_REG_175608_OUT(v) \ - out_dword(HWIO_REG_175608_ADDR, v) -#define HWIO_REG_175608_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_175608_ADDR, m, v, HWIO_REG_175608_IN); -#define HWIO_REG_175608_REG_175608_BMSK 0xffffffff -#define HWIO_REG_175608_REG_175608_SHFT 0 - -#define HWIO_REG_190381_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002058) -#define HWIO_REG_190381_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002058) -#define HWIO_REG_190381_RMSK 0xffffffff -#define HWIO_REG_190381_SHFT 0 -#define HWIO_REG_190381_IN in_dword_masked(\ - HWIO_REG_190381_ADDR, HWIO_REG_190381_RMSK) -#define HWIO_REG_190381_INM(m) \ - in_dword_masked(HWIO_REG_190381_ADDR, m) -#define HWIO_REG_190381_OUT(v) \ - out_dword(HWIO_REG_190381_ADDR, v) -#define HWIO_REG_190381_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_190381_ADDR, m, v, HWIO_REG_190381_IN); -#define HWIO_REG_190381_REG_190381_BMSK 0xffffffff -#define HWIO_REG_190381_REG_190381_SHFT 0 - -#define HWIO_REG_85655_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000205c) -#define HWIO_REG_85655_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000205c) -#define HWIO_REG_85655_RMSK 0xffffffff -#define HWIO_REG_85655_SHFT 0 -#define HWIO_REG_85655_IN in_dword_masked(\ - HWIO_REG_85655_ADDR, HWIO_REG_85655_RMSK) -#define HWIO_REG_85655_INM(m) \ - in_dword_masked(HWIO_REG_85655_ADDR, m) -#define HWIO_REG_85655_OUT(v) \ - out_dword(HWIO_REG_85655_ADDR, v) -#define HWIO_REG_85655_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_85655_ADDR, m, v, HWIO_REG_85655_IN); -#define HWIO_REG_85655_REG_85655_BMSK 0xffffffff -#define HWIO_REG_85655_REG_85655_SHFT 0 - -#define HWIO_REG_86830_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002060) -#define HWIO_REG_86830_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002060) -#define HWIO_REG_86830_RMSK 0xffffffff -#define HWIO_REG_86830_SHFT 0 -#define HWIO_REG_86830_IN in_dword_masked(\ - HWIO_REG_86830_ADDR, HWIO_REG_86830_RMSK) -#define HWIO_REG_86830_INM(m) \ - in_dword_masked(HWIO_REG_86830_ADDR, m) -#define HWIO_REG_86830_OUT(v) \ - out_dword(HWIO_REG_86830_ADDR, v) -#define HWIO_REG_86830_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_86830_ADDR, m, v, HWIO_REG_86830_IN); -#define HWIO_REG_86830_REG_86830_BMSK 0xffffffff -#define HWIO_REG_86830_REG_86830_SHFT 0 - -#define HWIO_REG_889944_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002064) -#define HWIO_REG_889944_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002064) -#define HWIO_REG_889944_RMSK 0xffffffff -#define HWIO_REG_889944_SHFT 0 -#define HWIO_REG_889944_IN in_dword_masked(\ - HWIO_REG_889944_ADDR, HWIO_REG_889944_RMSK) -#define HWIO_REG_889944_INM(m) \ - in_dword_masked(HWIO_REG_889944_ADDR, m) -#define HWIO_REG_889944_OUT(v) \ - out_dword(HWIO_REG_889944_ADDR, v) -#define HWIO_REG_889944_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_889944_ADDR, m, v, HWIO_REG_889944_IN); -#define HWIO_REG_889944_HOST_WR_ADDR_BMSK 0xffffffff -#define HWIO_REG_889944_HOST_WR_ADSR_SHFT 0 - -#define HWIO_REG_404623_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002068) -#define HWIO_REG_404623_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002068) -#define HWIO_REG_404623_RMSK 0xffffffff -#define HWIO_REG_404623_SHFT 0 -#define HWIO_REG_404623_IN in_dword_masked(\ - HWIO_REG_404623_ADDR, HWIO_REG_404623_RMSK) -#define HWIO_REG_404623_INM(m) \ - in_dword_masked(HWIO_REG_404623_ADDR, m) -#define HWIO_REG_404623_OUT(v) \ - out_dword(HWIO_REG_404623_ADDR, v) -#define HWIO_REG_404623_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_404623_ADDR, m, v, HWIO_REG_404623_IN); -#define HWIO_REG_404623_REG_404623_BMSK 0xffffffff -#define HWIO_REG_404623_REG_404623_SHFT 0 - -#define HWIO_REG_397087_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000206c) -#define HWIO_REG_397087_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000206c) -#define HWIO_REG_397087_RMSK 0xffffffff -#define HWIO_REG_397087_SHFT 0 -#define HWIO_REG_397087_IN in_dword_masked(\ - HWIO_REG_397087_ADDR, HWIO_REG_397087_RMSK) -#define HWIO_REG_397087_INM(m) \ - in_dword_masked(HWIO_REG_397087_ADDR, m) -#define HWIO_REG_397087_OUT(v) \ - out_dword(HWIO_REG_397087_ADDR, v) -#define HWIO_REG_397087_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_397087_ADDR, m, v, HWIO_REG_397087_IN); -#define HWIO_REG_397087_CMD_SEQ_NUM_BMSK 0xffffffff -#define HWIO_REG_397087_CMD_SEQ_NUM_SHFT 0 - -#define HWIO_REG_212613_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002070) -#define HWIO_REG_212613_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002070) -#define HWIO_REG_212613_RMSK 0xffffffff -#define HWIO_REG_212613_SHFT 0 -#define HWIO_REG_212613_IN in_dword_masked(\ - HWIO_REG_212613_ADDR, HWIO_REG_212613_RMSK) -#define HWIO_REG_212613_INM(m) \ - in_dword_masked(HWIO_REG_212613_ADDR, m) -#define HWIO_REG_212613_OUT(v) \ - out_dword(HWIO_REG_212613_ADDR, v) -#define HWIO_REG_212613_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_212613_ADDR, m, v, HWIO_REG_212613_IN); -#define HWIO_REG_212613_REG_212613_BMSK 0xffffffff -#define HWIO_REG_212613_REG_212613_SHFT 0 - -#define HWIO_REG_840123_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002074) -#define HWIO_REG_840123_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002074) -#define HWIO_REG_840123_RMSK 0xffffffff -#define HWIO_REG_840123_SHFT 0 -#define HWIO_REG_840123_IN in_dword_masked(\ - HWIO_REG_840123_ADDR, HWIO_REG_840123_RMSK) -#define HWIO_REG_840123_INM(m) \ - in_dword_masked(HWIO_REG_840123_ADDR, m) -#define HWIO_REG_840123_OUT(v) \ - out_dword(HWIO_REG_840123_ADDR, v) -#define HWIO_REG_840123_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_840123_ADDR, m, v, HWIO_REG_840123_IN); -#define HWIO_REG_840123_REG_840123_BMSK 0xffffffff -#define HWIO_REG_840123_REG_840123_SHFT 0 - -#define HWIO_REG_520335_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002078) -#define HWIO_REG_520335_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002078) -#define HWIO_REG_520335_RMSK 0xffffffff -#define HWIO_REG_520335_SHFT 0 -#define HWIO_REG_520335_IN in_dword_masked(\ - HWIO_REG_520335_ADDR, HWIO_REG_520335_RMSK) -#define HWIO_REG_520335_INM(m) \ - in_dword_masked(HWIO_REG_520335_ADDR, m) -#define HWIO_REG_520335_OUT(v) \ - out_dword(HWIO_REG_520335_ADDR, v) -#define HWIO_REG_520335_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_520335_ADDR, m, v, HWIO_REG_520335_IN); -#define HWIO_REG_520335_REG_196943_BMSK 0xffffffff -#define HWIO_REG_520335_REG_196943_SHFT 0 - -#define HWIO_REG_196943_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000207c) -#define HWIO_REG_196943_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000207c) -#define HWIO_REG_196943_RMSK 0xffffffff -#define HWIO_REG_196943_SHFT 0 -#define HWIO_REG_196943_IN in_dword_masked(\ - HWIO_REG_196943_ADDR, HWIO_REG_196943_RMSK) -#define HWIO_REG_196943_INM(m) \ - in_dword_masked(HWIO_REG_196943_ADDR, m) -#define HWIO_REG_196943_OUT(v) \ - out_dword(HWIO_REG_196943_ADDR, v) -#define HWIO_REG_196943_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_196943_ADDR, m, v, HWIO_REG_196943_IN); -#define HWIO_REG_196943_REG_196943_BMSK 0xffffffff -#define HWIO_REG_196943_REG_196943_SHFT 0 - -#define HWIO_REG_313350_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002080) -#define HWIO_REG_313350_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002080) -#define HWIO_REG_313350_RMSK 0x7ffff -#define HWIO_REG_313350_SHFT 0 -#define HWIO_REG_313350_IN in_dword_masked(\ - HWIO_REG_313350_ADDR, HWIO_REG_313350_RMSK) -#define HWIO_REG_313350_INM(m) \ - in_dword_masked(HWIO_REG_313350_ADDR, m) -#define HWIO_REG_313350_OUT(v) \ - out_dword(HWIO_REG_313350_ADDR, v) -#define HWIO_REG_313350_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_313350_ADDR, m, v, HWIO_REG_313350_IN); -#define HWIO_REG_313350_CH_DEC_TYPE_BMSK 0x70000 -#define HWIO_REG_313350_CH_DEC_TYPE_SHFT 0x10 -#define HWIO_REG_313350_CH_INST_ID_BMSK 0xffff -#define HWIO_REG_313350_CH_INST_ID_SHFT 0 - -#define HWIO_REG_980194_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002084) -#define HWIO_REG_980194_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002084) -#define HWIO_REG_980194_RMSK 0xffffffff -#define HWIO_REG_980194_SHFT 0 -#define HWIO_REG_980194_IN in_dword_masked(\ - HWIO_REG_980194_ADDR, HWIO_REG_980194_RMSK) -#define HWIO_REG_980194_INM(m) \ - in_dword_masked(HWIO_REG_980194_ADDR, m) -#define HWIO_REG_980194_OUT(v) \ - out_dword(HWIO_REG_980194_ADDR, v) -#define HWIO_REG_980194_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_980194_ADDR, m, v, HWIO_REG_980194_IN); -#define HWIO_REG_980194_REG_980194_BMSK 0xffffffff -#define HWIO_REG_980194_REG_980194_SHFT 0 - -#define HWIO_REG_936704_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002088) -#define HWIO_REG_936704_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002088) -#define HWIO_REG_936704_RMSK 0xffffffff -#define HWIO_REG_936704_SHFT 0 -#define HWIO_REG_936704_IN in_dword_masked(\ - HWIO_REG_936704_ADDR, HWIO_REG_936704_RMSK) -#define HWIO_REG_936704_INM(m) \ - in_dword_masked(HWIO_REG_936704_ADDR, m) -#define HWIO_REG_936704_OUT(v) \ - out_dword(HWIO_REG_936704_ADDR, v) -#define HWIO_REG_936704_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_936704_ADDR, m, v, HWIO_REG_936704_IN); -#define HWIO_REG_936704_REG_936704_BMSK 0xffffffff -#define HWIO_REG_936704_REG_936704_SHFT 0 - -#define HWIO_REG_821977_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000208c) -#define HWIO_REG_821977_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000208c) -#define HWIO_REG_821977_RMSK 0xffffffff -#define HWIO_REG_821977_SHFT 0 -#define HWIO_REG_821977_IN in_dword_masked(\ - HWIO_REG_821977_ADDR, HWIO_REG_821977_RMSK) -#define HWIO_REG_821977_INM(m) \ - in_dword_masked(HWIO_REG_821977_ADDR, m) -#define HWIO_REG_821977_OUT(v) \ - out_dword(HWIO_REG_821977_ADDR, v) -#define HWIO_REG_821977_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_821977_ADDR, m, v, HWIO_REG_821977_IN); -#define HWIO_REG_821977_REG_821977_BMSK 0xffffffff -#define HWIO_REG_821977_REG_821977_SHFT 0 - -#define HWIO_REG_655721_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002090) -#define HWIO_REG_655721_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002090) -#define HWIO_REG_655721_RMSK 0xffffffff -#define HWIO_REG_655721_SHFT 0 -#define HWIO_REG_655721_IN in_dword_masked(\ - HWIO_REG_655721_ADDR, HWIO_REG_655721_RMSK) -#define HWIO_REG_655721_INM(m) \ - in_dword_masked(HWIO_REG_655721_ADDR, m) -#define HWIO_REG_655721_OUT(v) \ - out_dword(HWIO_REG_655721_ADDR, v) -#define HWIO_REG_655721_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_655721_ADDR, m, v, HWIO_REG_655721_IN); -#define HWIO_REG_655721_REG_655721_BMSK 0xffffffff -#define HWIO_REG_655721_REG_655721_SHFT 0 - -#define HWIO_REG_548308_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002094) -#define HWIO_REG_548308_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002094) -#define HWIO_REG_548308_RMSK 0xffffffff -#define HWIO_REG_548308_SHFT 0 -#define HWIO_REG_548308_IN in_dword_masked(\ - HWIO_REG_548308_ADDR, HWIO_REG_548308_RMSK) -#define HWIO_REG_548308_INM(m) \ - in_dword_masked(HWIO_REG_548308_ADDR, m) -#define HWIO_REG_548308_OUT(v) \ - out_dword(HWIO_REG_548308_ADDR, v) -#define HWIO_REG_548308_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_548308_ADDR, m, v, HWIO_REG_548308_IN); -#define HWIO_REG_548308_REG_548308_BMSK 0xffffffff -#define HWIO_REG_548308_REG_548308_SHFT 0 - -#define HWIO_REG_887095_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x00002098) -#define HWIO_REG_887095_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x00002098) -#define HWIO_REG_887095_RMSK 0xffffffff -#define HWIO_REG_887095_SHFT 0 -#define HWIO_REG_887095_IN in_dword_masked(\ - HWIO_REG_887095_ADDR, HWIO_REG_887095_RMSK) -#define HWIO_REG_887095_INM(m) \ - in_dword_masked(HWIO_REG_887095_ADDR, m) -#define HWIO_REG_887095_OUT(v) \ - out_dword(HWIO_REG_887095_ADDR, v) -#define HWIO_REG_887095_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_887095_ADDR, m, v, HWIO_REG_887095_IN); -#define HWIO_REG_887095_REG_887095_BMSK 0xffffffff -#define HWIO_REG_887095_REG_887095_SHFT 0 - -#define HWIO_REG_576987_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000209c) -#define HWIO_REG_576987_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000209c) -#define HWIO_REG_576987_RMSK 0xffffffff -#define HWIO_REG_576987_SHFT 0 -#define HWIO_REG_576987_IN in_dword_masked(\ - HWIO_REG_576987_ADDR, HWIO_REG_576987_RMSK) -#define HWIO_REG_576987_INM(m) \ - in_dword_masked(HWIO_REG_576987_ADDR, m) -#define HWIO_REG_576987_OUT(v) \ - out_dword(HWIO_REG_576987_ADDR, v) -#define HWIO_REG_576987_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_576987_ADDR, m, v, HWIO_REG_576987_IN); -#define HWIO_REG_576987_REG_576987_BMSK 0xffffffff -#define HWIO_REG_576987_REG_576987_SHFT 0 - -#define HWIO_REG_70448_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020a0) -#define HWIO_REG_70448_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020a0) -#define HWIO_REG_70448_RMSK 0xffffffff -#define HWIO_REG_70448_SHFT 0 -#define HWIO_REG_70448_IN in_dword_masked(\ - HWIO_REG_70448_ADDR, HWIO_REG_70448_RMSK) -#define HWIO_REG_70448_INM(m) \ - in_dword_masked(HWIO_REG_70448_ADDR, m) -#define HWIO_REG_70448_OUT(v) \ - out_dword(HWIO_REG_70448_ADDR, v) -#define HWIO_REG_70448_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_70448_ADDR, m, v, HWIO_REG_70448_IN); -#define HWIO_REG_70448_REG_70448_BMSK 0xffffffff -#define HWIO_REG_70448_REG_70448_SHFT 0 - -#define HWIO_REG_652528_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020a4) -#define HWIO_REG_652528_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020a4) -#define HWIO_REG_652528_RMSK 0xffffffff -#define HWIO_REG_652528_SHFT 0 -#define HWIO_REG_652528_IN in_dword_masked(\ - HWIO_REG_652528_ADDR, HWIO_REG_652528_RMSK) -#define HWIO_REG_652528_INM(m) \ - in_dword_masked(HWIO_REG_652528_ADDR, m) -#define HWIO_REG_652528_OUT(v) \ - out_dword(HWIO_REG_652528_ADDR, v) -#define HWIO_REG_652528_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_652528_ADDR, m, v , HWIO_REG_652528_IN); -#define HWIO_REG_652528_REG_652528_BMSK 0xffffffff -#define HWIO_REG_652528_REG_652528_SHFT 0 - -#define HWIO_REG_220637_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020a8) -#define HWIO_REG_220637_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020a8) -#define HWIO_REG_220637_RMSK 0xffffffff -#define HWIO_REG_220637_SHFT 0 -#define HWIO_REG_220637_IN in_dword_masked(\ - HWIO_REG_220637_ADDR, HWIO_REG_220637_RMSK) -#define HWIO_REG_220637_INM(m) \ - in_dword_masked(HWIO_REG_220637_ADDR, m) -#define HWIO_REG_220637_OUT(v) \ - out_dword(HWIO_REG_220637_ADDR, v) -#define HWIO_REG_220637_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_220637_ADDR, m, v, HWIO_REG_220637_IN); -#define HWIO_REG_220637_REG_220637_BMSK 0xffffffff -#define HWIO_REG_220637_REG_220637_SHFT 0 - -#define HWIO_REG_254093_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020ac) -#define HWIO_REG_254093_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020ac) -#define HWIO_REG_254093_RMSK 0xffffffff -#define HWIO_REG_254093_SHFT 0 -#define HWIO_REG_254093_IN in_dword_masked(\ - HWIO_REG_254093_ADDR, HWIO_REG_254093_RMSK) -#define HWIO_REG_254093_INM(m) \ - in_dword_masked(HWIO_REG_254093_ADDR, m) -#define HWIO_REG_254093_OUT(v) \ - out_dword(HWIO_REG_254093_ADDR, v) -#define HWIO_REG_254093_OUTM(m, v) out_dword_masked_ns\ - (HWIO_REG_254093_ADDR, m, v, HWIO_REG_254093_IN); -#define HWIO_REG_254093_REG_254093_BMSK 0xffffffff -#define HWIO_REG_254093_REG_254093_SHFT 0 - -#define HWIO_REG_160474_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020b0) -#define HWIO_REG_160474_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020b0) -#define HWIO_REG_160474_RMSK 0xffffffff -#define HWIO_REG_160474_SHFT 0 -#define HWIO_REG_160474_IN in_dword_masked(\ - HWIO_REG_160474_ADDR, HWIO_REG_160474_RMSK) -#define HWIO_REG_160474_INM(m) \ - in_dword_masked(HWIO_REG_160474_ADDR, m) -#define HWIO_REG_160474_OUT(v) \ - out_dword(HWIO_REG_160474_ADDR, v) -#define HWIO_REG_160474_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_160474_ADDR, m, v, HWIO_REG_160474_IN); -#define HWIO_REG_160474_REG_160474_BMSK 0xffffffff -#define HWIO_REG_160474_REG_160474_SHFT 0 - -#define HWIO_REG_39027_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020b4) -#define HWIO_REG_39027_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020b4) -#define HWIO_REG_39027_RMSK 0xffffffff -#define HWIO_REG_39027_SHFT 0 -#define HWIO_REG_39027_IN in_dword_masked(\ - HWIO_REG_39027_ADDR, HWIO_REG_39027_RMSK) -#define HWIO_REG_39027_INM(m) \ - in_dword_masked(HWIO_REG_39027_ADDR, m) -#define HWIO_REG_39027_OUT(v) \ - out_dword(HWIO_REG_39027_ADDR, v) -#define HWIO_REG_39027_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_39027_ADDR, m, v, HWIO_REG_39027_IN); -#define HWIO_REG_39027_REG_39027_BMSK 0xffffffff -#define HWIO_REG_39027_REG_39027_SHFT 0 - -#define HWIO_REG_74049_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020b8) -#define HWIO_REG_74049_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020b8) -#define HWIO_REG_74049_RMSK 0xffffffff -#define HWIO_REG_74049_SHFT 0 -#define HWIO_REG_74049_IN in_dword_masked(\ - HWIO_REG_74049_ADDR, HWIO_REG_74049_RMSK) -#define HWIO_REG_74049_INM(m) \ - in_dword_masked(HWIO_REG_74049_ADDR, m) -#define HWIO_REG_74049_OUT(v) \ - out_dword(HWIO_REG_74049_ADDR, v) -#define HWIO_REG_74049_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_74049_ADDR, m, v, HWIO_REG_74049_IN); -#define HWIO_REG_74049_REG_74049_BMSK 0xffffffff -#define HWIO_REG_74049_REG_74049_SHFT 0 - -#define HWIO_REG_697870_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x000020bc) -#define HWIO_REG_697870_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x000020bc) -#define HWIO_REG_697870_RMSK 0xffffffff -#define HWIO_REG_697870_SHFT 0 -#define HWIO_REG_697870_IN in_dword_masked(\ - HWIO_REG_697870_ADDR, HWIO_REG_697870_RMSK) -#define HWIO_REG_697870_INM(m) \ - in_dword_masked(HWIO_REG_697870_ADDR, m) -#define HWIO_REG_697870_OUT(v) \ - out_dword(HWIO_REG_697870_ADDR, v) -#define HWIO_REG_697870_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_697870_ADDR, m, v, HWIO_REG_697870_IN); -#define HWIO_REG_697870_REG_697870_BMSK 0xffffffff -#define HWIO_REG_697870_REG_697870_SHFT 0 - -#define HWIO_REG_783891_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c504) -#define HWIO_REG_783891_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c504) -#define HWIO_REG_783891_RMSK 0x7ffff -#define HWIO_REG_783891_SHFT 0 -#define HWIO_REG_783891_IN in_dword_masked(\ - HWIO_REG_783891_ADDR, HWIO_REG_783891_RMSK) -#define HWIO_REG_783891_INM(m) \ - in_dword_masked(HWIO_REG_783891_ADDR, m) -#define HWIO_REG_783891_OUT(v) \ - out_dword(HWIO_REG_783891_ADDR, v) -#define HWIO_REG_783891_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_783891_ADDR, m, v, HWIO_REG_783891_IN); -#define HWIO_REG_783891_ENC_PIC_TYPE_USE_BMSK 0x40000 -#define HWIO_REG_783891_ENC_PIC_TYPE_USE_SHFT 0x12 -#define HWIO_REG_783891_B_FRM_CTRL_BMSK 0x30000 -#define HWIO_REG_783891_B_FRM_CTRL_SHFT 0x10 -#define HWIO_REG_783891_I_FRM_CTRL_BMSK 0xffff -#define HWIO_REG_783891_I_FRM_CTRL_SHFT 0 - -#define HWIO_REG_226332_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c50c) -#define HWIO_REG_226332_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c50c) -#define HWIO_REG_226332_RMSK 0x7 -#define HWIO_REG_226332_SHFT 0 -#define HWIO_REG_226332_IN in_dword_masked(\ - HWIO_REG_226332_ADDR, HWIO_REG_226332_RMSK) -#define HWIO_REG_226332_INM(m) in_dword_masked(HWIO_REG_226332_ADDR, m) -#define HWIO_REG_226332_OUT(v) out_dword(HWIO_REG_226332_ADDR, v) -#define HWIO_REG_226332_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_226332_ADDR, m, v, HWIO_REG_226332_IN); -#define HWIO_REG_226332_MSLICE_MODE_BMSK 0x6 -#define HWIO_REG_226332_MSLICE_MODE_SHFT 0x1 -#define HWIO_REG_226332_MSLICE_ENA_BMSK 0x1 -#define HWIO_REG_226332_MSLICE_ENA_SHFT 0 - -#define HWIO_REG_696136_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c510) -#define HWIO_REG_696136_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c510) -#define HWIO_REG_696136_RMSK 0xffff -#define HWIO_REG_696136_SHFT 0 -#define HWIO_REG_696136_IN in_dword_masked(\ - HWIO_REG_696136_ADDR, HWIO_REG_696136_RMSK) -#define HWIO_REG_696136_INM(m) in_dword_masked(HWIO_REG_696136_ADDR, m) -#define HWIO_REG_696136_OUT(v) out_dword(HWIO_REG_696136_ADDR, v) -#define HWIO_REG_696136_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_696136_ADDR, m, v, HWIO_REG_696136_IN); -#define HWIO_REG_696136_MSLICE_MB_BMSK 0xffff -#define HWIO_REG_696136_MSLICE_MB_SHFT 0 - -#define HWIO_REG_515564_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c514) -#define HWIO_REG_515564_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c514) -#define HWIO_REG_515564_RMSK 0xffffffff -#define HWIO_REG_515564_SHFT 0 -#define HWIO_REG_515564_IN in_dword_masked(\ - HWIO_REG_515564_ADDR, HWIO_REG_515564_RMSK) -#define HWIO_REG_515564_INM(m) \ - in_dword_masked(HWIO_REG_515564_ADDR, m) -#define HWIO_REG_515564_OUT(v) out_dword(HWIO_REG_515564_ADDR, v) -#define HWIO_REG_515564_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_515564_ADDR, m, v, HWIO_REG_515564_IN); -#define HWIO_REG_515564_MSLICE_BIT_BMSK 0xffffffff -#define HWIO_REG_515564_MSLICE_BIT_SHFT 0 - -#define HWIO_REG_886210_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c518) -#define HWIO_REG_886210_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c518) -#define HWIO_REG_886210_RMSK 0xffff -#define HWIO_REG_886210_SHFT 0 -#define HWIO_REG_886210_IN in_dword_masked(\ - HWIO_REG_886210_ADDR, HWIO_REG_886210_RMSK) -#define HWIO_REG_886210_INM(m) in_dword_masked(HWIO_REG_886210_ADDR, m) -#define HWIO_REG_886210_OUT(v) out_dword(HWIO_REG_886210_ADDR, v) -#define HWIO_REG_886210_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_886210_ADDR, m, v, HWIO_REG_886210_IN); -#define HWIO_REG_886210_CIR_NUM_BMSK 0xffff -#define HWIO_REG_886210_CIR_NUM_SHFT 0 - -#define HWIO_REG_645603_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c51c) -#define HWIO_REG_645603_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c51c) -#define HWIO_REG_645603_RMSK 0x3 -#define HWIO_REG_645603_SHFT 0 -#define HWIO_REG_645603_IN in_dword_masked(\ - HWIO_REG_645603_ADDR, HWIO_REG_645603_RMSK) -#define HWIO_REG_645603_INM(m) \ - in_dword_masked(HWIO_REG_645603_ADDR, m) -#define HWIO_REG_645603_OUT(v) out_dword(HWIO_REG_645603_ADDR, v) -#define HWIO_REG_645603_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_645603_ADDR, m, v, HWIO_REG_645603_IN); -#define HWIO_REG_645603_REG_645603_BMSK 0x3 -#define HWIO_REG_645603_REG_645603_SHFT 0 - -#define HWIO_REG_811733_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c520) -#define HWIO_REG_811733_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c520) -#define HWIO_REG_811733_RMSK 0x80ffffff -#define HWIO_REG_811733_SHFT 0 -#define HWIO_REG_811733_IN in_dword_masked(\ - HWIO_REG_811733_ADDR, HWIO_REG_811733_RMSK) -#define HWIO_REG_811733_INM(m) \ - in_dword_masked(HWIO_REG_811733_ADDR, m) -#define HWIO_REG_811733_OUT(v) out_dword(HWIO_REG_811733_ADDR, v) -#define HWIO_REG_811733_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_811733_ADDR, m, v, HWIO_REG_811733_IN); -#define HWIO_REG_811733_PAD_CTRL_ON_BMSK 0x80000000 -#define HWIO_REG_811733_PAD_CTRL_ON_SHFT 0x1f -#define HWIO_REG_811733_CR_PAD_VIDC_BMSK 0xff0000 -#define HWIO_REG_811733_CR_PAD_VIDC_SHFT 0x10 -#define HWIO_REG_811733_CB_PAD_VIDC_BMSK 0xff00 -#define HWIO_REG_811733_CB_PAD_VIDC_SHFT 0x8 -#define HWIO_REG_811733_LUMA_PAD_VIDC_BMSK 0xff -#define HWIO_REG_811733_LUMA_PAD_VIDC_SHFT 0 - -#define HWIO_REG_676866_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c588) -#define HWIO_REG_676866_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c588) -#define HWIO_REG_676866_RMSK 0xffff -#define HWIO_REG_676866_SHFT 0 -#define HWIO_REG_676866_IN in_dword_masked(\ - HWIO_REG_676866_ADDR, HWIO_REG_676866_RMSK) -#define HWIO_REG_676866_INM(m) \ - in_dword_masked(HWIO_REG_676866_ADDR, m) -#define HWIO_REG_676866_OUT(v) \ - out_dword(HWIO_REG_676866_ADDR, v) -#define HWIO_REG_676866_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_676866_ADDR, m, v, HWIO_REG_676866_IN); -#define HWIO_REG_676866_REG_676866_BMSK 0xffff -#define HWIO_REG_676866_REG_676866_SHFT 0 - -#define HWIO_REG_54267_ADDR \ - (VIDC_BLACKBIRD_REG_BASE + 0x0000c58c) -#define HWIO_REG_54267_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c58c) -#define HWIO_REG_54267_RMSK 0xffff -#define HWIO_REG_54267_SHFT 0 -#define HWIO_REG_54267_IN in_dword_masked(\ - HWIO_REG_54267_ADDR,\ - HWIO_REG_54267_RMSK) -#define HWIO_REG_54267_INM(m) \ - in_dword_masked(HWIO_REG_54267_ADDR, m) -#define HWIO_REG_54267_OUT(v) \ - out_dword(HWIO_REG_54267_ADDR, v) -#define HWIO_REG_54267_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_54267_ADDR, m, v,\ - HWIO_REG_54267_IN); -#define HWIO_REG_54267_REG_54267_BMSK 0xffff -#define HWIO_REG_54267_REG_54267_SHFT 0 - -#define HWIO_REG_559908_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c5a0) -#define HWIO_REG_559908_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c5a0) -#define HWIO_REG_559908_RMSK 0x33f -#define HWIO_REG_559908_SHFT 0 -#define HWIO_REG_559908_IN in_dword_masked(\ - HWIO_REG_559908_ADDR, HWIO_REG_559908_RMSK) -#define HWIO_REG_559908_INM(m) in_dword_masked(HWIO_REG_559908_ADDR, m) -#define HWIO_REG_559908_OUT(v) out_dword(HWIO_REG_559908_ADDR, v) -#define HWIO_REG_559908_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_559908_ADDR, m, v, HWIO_REG_559908_IN); -#define HWIO_REG_559908_FR_RC_EN_BMSK 0x200 -#define HWIO_REG_559908_FR_RC_EN_SHFT 0x9 -#define HWIO_REG_559908_MB_RC_EN_BMSK 0x100 -#define HWIO_REG_559908_MB_RC_EN_SHFT 0x8 -#define HWIO_REG_559908_FRAME_QP_BMSK 0x3f -#define HWIO_REG_559908_FRAME_QP_SHFT 0 - -#define HWIO_REG_977937_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000d0d0) -#define HWIO_REG_977937_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000d0d0) -#define HWIO_REG_977937_RMSK 0xff -#define HWIO_REG_977937_SHFT 0 -#define HWIO_REG_977937_IN in_dword_masked(\ - HWIO_REG_977937_ADDR, HWIO_REG_977937_RMSK) -#define HWIO_REG_977937_INM(m) in_dword_masked(HWIO_REG_977937_ADDR, m) -#define HWIO_REG_977937_OUT(v) out_dword(HWIO_REG_977937_ADDR, v) -#define HWIO_REG_977937_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_977937_ADDR, m, v, HWIO_REG_977937_IN); -#define HWIO_REG_977937_FRAME_RATE_BMSK 0xff -#define HWIO_REG_977937_FRAME_RATE_SHFT 0 - -#define HWIO_REG_166135_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c5a8) -#define HWIO_REG_166135_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c5a8) -#define HWIO_REG_166135_RMSK 0xffffffff -#define HWIO_REG_166135_SHFT 0 -#define HWIO_REG_166135_IN in_dword_masked(\ - HWIO_REG_166135_ADDR, HWIO_REG_166135_RMSK) -#define HWIO_REG_166135_INM(m) in_dword_masked(HWIO_REG_166135_ADDR, m) -#define HWIO_REG_166135_OUT(v) out_dword(HWIO_REG_166135_ADDR, v) -#define HWIO_REG_166135_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_166135_ADDR, m, v, HWIO_REG_166135_IN); -#define HWIO_REG_166135_BIT_RATE_BMSK 0xffffffff -#define HWIO_REG_166135_BIT_RATE_SHFT 0 - -#define HWIO_REG_109072_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c5ac) -#define HWIO_REG_109072_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c5ac) -#define HWIO_REG_109072_RMSK 0x3fff -#define HWIO_REG_109072_SHFT 0 -#define HWIO_REG_109072_IN in_dword_masked(\ - HWIO_REG_109072_ADDR, HWIO_REG_109072_RMSK) -#define HWIO_REG_109072_INM(m) in_dword_masked(HWIO_REG_109072_ADDR, m) -#define HWIO_REG_109072_OUT(v) out_dword(HWIO_REG_109072_ADDR, v) -#define HWIO_REG_109072_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_109072_ADDR, m, v, HWIO_REG_109072_IN); -#define HWIO_REG_109072_MAX_QP_BMSK 0x3f00 -#define HWIO_REG_109072_MAX_QP_SHFT 0x8 -#define HWIO_REG_109072_MIN_QP_BMSK 0x3f -#define HWIO_REG_109072_MIN_QP_SHFT 0 - -#define HWIO_REG_550322_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c5b0) -#define HWIO_REG_550322_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c5b0) -#define HWIO_REG_550322_RMSK 0xffff -#define HWIO_REG_550322_SHFT 0 -#define HWIO_REG_550322_IN in_dword_masked(\ - HWIO_REG_550322_ADDR, HWIO_REG_550322_RMSK) -#define HWIO_REG_550322_INM(m) in_dword_masked(HWIO_REG_550322_ADDR, m) -#define HWIO_REG_550322_OUT(v) out_dword(HWIO_REG_550322_ADDR, v) -#define HWIO_REG_550322_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_550322_ADDR, m, v, HWIO_REG_550322_IN); -#define HWIO_REG_550322_REACT_PARA_BMSK 0xffff -#define HWIO_REG_550322_REACT_PARA_SHFT 0 - -#define HWIO_REG_949086_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000c5b4) -#define HWIO_REG_949086_PHYS (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000c5b4) -#define HWIO_REG_949086_RMSK 0xf -#define HWIO_REG_949086_SHFT 0 -#define HWIO_REG_949086_IN in_dword_masked(\ - HWIO_REG_949086_ADDR, HWIO_REG_949086_RMSK) -#define HWIO_REG_949086_INM(m) in_dword_masked(HWIO_REG_949086_ADDR, m) -#define HWIO_REG_949086_OUT(v) out_dword(HWIO_REG_949086_ADDR, v) -#define HWIO_REG_949086_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_949086_ADDR, m, v, HWIO_REG_949086_IN); -#define HWIO_REG_949086_DARK_DISABLE_BMSK 0x8 -#define HWIO_REG_949086_DARK_DISABLE_SHFT 0x3 -#define HWIO_REG_949086_SMOOTH_DISABLE_BMSK 0x4 -#define HWIO_REG_949086_SMOOTH_DISABLE_SHFT 0x2 -#define HWIO_REG_949086_STATIC_DISABLE_BMSK 0x2 -#define HWIO_REG_949086_STATIC_DISABLE_SHFT 0x1 -#define HWIO_REG_949086_ACT_DISABLE_BMSK 0x1 -#define HWIO_REG_949086_ACT_DISABLE_SHFT 0 - -#define HWIO_REG_447796_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000d004) -#define HWIO_REG_447796_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000d004) -#define HWIO_REG_447796_RMSK 0x1 -#define HWIO_REG_447796_SHFT 0 -#define HWIO_REG_447796_IN in_dword_masked(\ - HWIO_REG_447796_ADDR, HWIO_REG_447796_RMSK) -#define HWIO_REG_447796_INM(m) \ - in_dword_masked(HWIO_REG_447796_ADDR, m) -#define HWIO_REG_447796_OUT(v) \ - out_dword(HWIO_REG_447796_ADDR, v) -#define HWIO_REG_447796_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_447796_ADDR, m, v, HWIO_REG_447796_IN); -#define HWIO_REG_447796_REG_447796_BMSK 0x1 -#define HWIO_REG_447796_REG_447796_SHFT 0 - -#define HWIO_REG_744348_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000d010) -#define HWIO_REG_744348_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000d010) -#define HWIO_REG_744348_RMSK 0x7f -#define HWIO_REG_744348_SHFT 0 -#define HWIO_REG_744348_IN in_dword_masked(\ - HWIO_REG_744348_ADDR, HWIO_REG_744348_RMSK) -#define HWIO_REG_744348_INM(m) \ - in_dword_masked(HWIO_REG_744348_ADDR, m) -#define HWIO_REG_744348_OUT(v) \ - out_dword(HWIO_REG_744348_ADDR, v) -#define HWIO_REG_744348_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_744348_ADDR, m, v, HWIO_REG_744348_IN); -#define HWIO_REG_744348_P_BMSK 0x60 -#define HWIO_REG_744348_P_SHFT 0x5 -#define HWIO_REG_744348_BMSK 0x1f -#define HWIO_REG_744348_SHFT 0 - -#define HWIO_REG_672163_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000d034) -#define HWIO_REG_672163_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000d034) -#define HWIO_REG_672163_RMSK 0x1 -#define HWIO_REG_672163_SHFT 0 -#define HWIO_REG_672163_IN in_dword_masked(\ - HWIO_REG_672163_ADDR, HWIO_REG_672163_RMSK) -#define HWIO_REG_672163_INM(m) \ - in_dword_masked(HWIO_REG_672163_ADDR, m) -#define HWIO_REG_672163_OUT(v) \ - out_dword(HWIO_REG_672163_ADDR, v) -#define HWIO_REG_672163_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_672163_ADDR, m, v,\ - HWIO_REG_672163_IN); -#define HWIO_REG_672163_ENC_TRANS_8X8_FLAG_BMSK 0x1 -#define HWIO_REG_672163_ENC_TRANS_8X8_FLAG_SHFT 0 - -#define HWIO_REG_780908_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000d140) -#define HWIO_REG_780908_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000d140) -#define HWIO_REG_780908_RMSK 0x1 -#define HWIO_REG_780908_SHFT 0 -#define HWIO_REG_780908_IN in_dword_masked(\ - HWIO_REG_780908_ADDR, HWIO_REG_780908_RMSK) -#define HWIO_REG_780908_INM(m) in_dword_masked(\ - HWIO_REG_780908_ADDR, m) -#define HWIO_REG_780908_OUT(v) out_dword(\ - HWIO_REG_780908_ADDR, v) -#define HWIO_REG_780908_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_780908_ADDR, m, v,\ - HWIO_REG_780908_IN) -#define HWIO_REG_780908_REG_780908_BMSK 0x1 -#define HWIO_REG_780908_REG_780908_SHFT 0 - -#define HWIO_REG_330132_ADDR (VIDC_BLACKBIRD_REG_BASE + 0x0000e008) -#define HWIO_REG_330132_PHYS \ - (VIDC_BLACKBIRD_REG_BASE_PHYS + 0x0000e008) -#define HWIO_REG_330132_RMSK 0x1 -#define HWIO_REG_330132_SHFT 0 -#define HWIO_REG_330132_IN in_dword_masked(\ - HWIO_REG_330132_ADDR, HWIO_REG_330132_RMSK) -#define HWIO_REG_330132_INM(m) \ - in_dword_masked(HWIO_REG_330132_ADDR, m) -#define HWIO_REG_330132_OUT(v) \ - out_dword(HWIO_REG_330132_ADDR, v) -#define HWIO_REG_330132_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_330132_ADDR, m, v, HWIO_REG_330132_IN); -#define HWIO_REG_330132_MPEG4_QUART_PXL_BMSK 0x1 -#define HWIO_REG_330132_MPEG4_QUART_PXL_SHFT 0 - - -#define VIDC_MGEN2MAXI_REG_BASE (VIDC_BASE + 0x00080000) -#define VIDC_MGEN2MAXI_REG_BASE_PHYS 0x04480000 - -#define HWIO_REG_916352_ADDR (VIDC_MGEN2MAXI_REG_BASE + 00000000) -#define HWIO_REG_916352_PHYS (VIDC_MGEN2MAXI_REG_BASE_PHYS + 00000000) -#define HWIO_REG_916352_RMSK 0xff -#define HWIO_REG_916352_SHFT 0 -#define HWIO_REG_916352_IN in_dword_masked(\ - HWIO_REG_916352_ADDR, HWIO_REG_916352_RMSK) -#define HWIO_REG_916352_INM(m) \ - in_dword_masked(HWIO_REG_916352_ADDR, m) -#define HWIO_REG_916352_VERSION_BMSK 0xff -#define HWIO_REG_916352_VERSION_SHFT 0 - -#define HWIO_REG_5519_ADDR (VIDC_MGEN2MAXI_REG_BASE + 0x00000004) -#define HWIO_REG_5519_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000004) -#define HWIO_REG_5519_RMSK 0x1 -#define HWIO_REG_5519_SHFT 0 -#define HWIO_REG_5519_IN in_dword_masked(\ - HWIO_REG_5519_ADDR, HWIO_REG_5519_RMSK) -#define HWIO_REG_5519_INM(m) \ - in_dword_masked(HWIO_REG_5519_ADDR, m) -#define HWIO_REG_5519_OUT(v) \ - out_dword(HWIO_REG_5519_ADDR, v) -#define HWIO_REG_5519_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_5519_ADDR, m, v, HWIO_REG_5519_IN); -#define HWIO_REG_5519_AXI_AOOORD_BMSK 0x1 -#define HWIO_REG_5519_AXI_AOOORD_SHFT 0 - -#define HWIO_REG_606364_ADDR (VIDC_MGEN2MAXI_REG_BASE + 0x00000008) -#define HWIO_REG_606364_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000008) -#define HWIO_REG_606364_RMSK 0x1 -#define HWIO_REG_606364_SHFT 0 -#define HWIO_REG_606364_IN in_dword_masked(\ - HWIO_REG_606364_ADDR, HWIO_REG_606364_RMSK) -#define HWIO_REG_606364_INM(m) \ - in_dword_masked(HWIO_REG_606364_ADDR, m) -#define HWIO_REG_606364_OUT(v) \ - out_dword(HWIO_REG_606364_ADDR, v) -#define HWIO_REG_606364_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_606364_ADDR, m, v, HWIO_REG_606364_IN); -#define HWIO_REG_606364_AXI_AOOOWR_BMSK 0x1 -#define HWIO_REG_606364_AXI_AOOOWR_SHFT 0 - -#define HWIO_REG_821472_ADDR (VIDC_MGEN2MAXI_REG_BASE + 0x0000000c) -#define HWIO_REG_821472_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x0000000c) -#define HWIO_REG_821472_RMSK 0xf -#define HWIO_REG_821472_SHFT 0 -#define HWIO_REG_821472_IN in_dword_masked(\ - HWIO_REG_821472_ADDR, HWIO_REG_821472_RMSK) -#define HWIO_REG_821472_INM(m) \ - in_dword_masked(HWIO_REG_821472_ADDR, m) -#define HWIO_REG_821472_OUT(v) \ - out_dword(HWIO_REG_821472_ADDR, v) -#define HWIO_REG_821472_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_821472_ADDR, m, v, HWIO_REG_821472_IN); -#define HWIO_REG_821472_AXI_TYPE_BMSK 0xf -#define HWIO_REG_821472_AXI_TYPE_SHFT 0 - -#define HWIO_REG_988424_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x00000010) -#define HWIO_REG_988424_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000010) -#define HWIO_REG_988424_RMSK 0x3 -#define HWIO_REG_988424_SHFT 0 -#define HWIO_REG_988424_IN in_dword_masked(\ - HWIO_REG_988424_ADDR,\ - HWIO_REG_988424_RMSK) -#define HWIO_REG_988424_INM(m) \ - in_dword_masked(HWIO_REG_988424_ADDR, m) -#define HWIO_REG_988424_OUT(v) \ - out_dword(HWIO_REG_988424_ADDR, v) -#define HWIO_REG_988424_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_988424_ADDR, m, v,\ - HWIO_REG_988424_IN); -#define HWIO_REG_988424_AXI_AREQPRIORITY_BMSK 0x3 -#define HWIO_REG_988424_AXI_AREQPRIORITY_SHFT 0 - -#define HWIO_REG_471159_ADDR (VIDC_MGEN2MAXI_REG_BASE + 0x00000014) -#define HWIO_REG_471159_PHYS (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000014) -#define HWIO_REG_471159_RMSK 0x801f1111 -#define HWIO_REG_471159_SHFT 0 -#define HWIO_REG_471159_IN in_dword_masked(\ - HWIO_REG_471159_ADDR, HWIO_REG_471159_RMSK) -#define HWIO_REG_471159_INM(m) \ - in_dword_masked(HWIO_REG_471159_ADDR, m) -#define HWIO_REG_471159_OUT(v) \ - out_dword(HWIO_REG_471159_ADDR, v) -#define HWIO_REG_471159_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_471159_ADDR, m, v, HWIO_REG_471159_IN); -#define HWIO_REG_471159_AXI_INTR_CLR_BMSK 0x80000000 -#define HWIO_REG_471159_AXI_INTR_CLR_SHFT 0x1f -#define HWIO_REG_471159_AXI_WDTIMEOUT_LOG2_BMSK 0x1e0000 -#define HWIO_REG_471159_AXI_WDTIMEOUT_LOG2_SHFT 0x11 -#define HWIO_REG_471159_AXI_HALT_ON_WDTIMEOUT_BMSK 0x10000 -#define HWIO_REG_471159_AXI_HALT_ON_WDTIMEOUT_SHFT 0x10 -#define HWIO_REG_471159_AXI_HALT_ON_WR_ERR_BMSK 0x1000 -#define HWIO_REG_471159_AXI_HALT_ON_WR_ERR_SHFT 0xc -#define HWIO_REG_471159_AXI_HALT_ON_RD_ERR_BMSK 0x100 -#define HWIO_REG_471159_AXI_HALT_ON_RD_ERR_SHFT 0x8 -#define HWIO_REG_471159_AXI_RESET_BMSK 0x10 -#define HWIO_REG_471159_AXI_RESET_SHFT 0x4 -#define HWIO_REG_471159_AXI_HALT_REQ_BMSK 0x1 -#define HWIO_REG_471159_AXI_HALT_REQ_SHFT 0 - -#define HWIO_REG_437878_ADDR (VIDC_MGEN2MAXI_REG_BASE + 0x00000018) -#define HWIO_REG_437878_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000018) -#define HWIO_REG_437878_RMSK 0x3333 -#define HWIO_REG_437878_SHFT 0 -#define HWIO_REG_437878_IN in_dword_masked(\ - HWIO_REG_437878_ADDR, HWIO_REG_437878_RMSK) -#define HWIO_REG_437878_INM(m) \ - in_dword_masked(HWIO_REG_437878_ADDR, m) -#define HWIO_REG_437878_AXI_WDTIMEOUT_INTR_BMSK 0x3000 -#define HWIO_REG_437878_AXI_WDTIMEOUT_INTR_SHFT 0xc -#define HWIO_REG_437878_AXI_ERR_INTR_BMSK 0x300 -#define HWIO_REG_437878_AXI_ERR_INTR_SHFT 0x8 -#define HWIO_REG_437878_AXI_IDLE_BMSK 0x30 -#define HWIO_REG_437878_AXI_IDLE_SHFT 0x4 -#define HWIO_REG_437878_AXI_HALT_ACK_BMSK 0x3 -#define HWIO_REG_437878_AXI_HALT_ACK_SHFT 0 - -#define HWIO_REG_736158_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x0000001c) -#define HWIO_REG_736158_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x0000001c) -#define HWIO_REG_736158_RMSK 0x10fff -#define HWIO_REG_736158_SHFT 0 -#define HWIO_REG_736158_IN in_dword_masked(\ - HWIO_REG_736158_ADDR,\ - HWIO_REG_736158_RMSK) -#define HWIO_REG_736158_INM(m) \ - in_dword_masked(HWIO_REG_736158_ADDR, m) -#define HWIO_REG_736158_AXI_WDTIMEOUT_BMSK 0x10000 -#define HWIO_REG_736158_AXI_WDTIMEOUT_SHFT 0x10 -#define HWIO_REG_736158_AXI_ERR_BMSK 0x800 -#define HWIO_REG_736158_AXI_ERR_SHFT 0xb -#define HWIO_REG_736158_AXI_ERR_TYPE_BMSK 0x400 -#define HWIO_REG_736158_AXI_ERR_TYPE_SHFT 0xa -#define HWIO_REG_736158_AXI_RESP_BMSK 0x300 -#define HWIO_REG_736158_AXI_RESP_SHFT 0x8 -#define HWIO_REG_736158_AXI_MID_BMSK 0xf0 -#define HWIO_REG_736158_AXI_MID_SHFT 0x4 -#define HWIO_REG_736158_AXI_TID_BMSK 0xf -#define HWIO_REG_736158_AXI_TID_SHFT 0 - -#define HWIO_REG_598415_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x00000020) -#define HWIO_REG_598415_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000020) -#define HWIO_REG_598415_RMSK 0x10fff -#define HWIO_REG_598415_SHFT 0 -#define HWIO_REG_598415_IN in_dword_masked(\ - HWIO_REG_598415_ADDR,\ - HWIO_REG_598415_RMSK) -#define HWIO_REG_598415_INM(m) \ - in_dword_masked(HWIO_REG_598415_ADDR, m) -#define HWIO_REG_598415_AXI_WDTIMEOUT_BMSK 0x10000 -#define HWIO_REG_598415_AXI_WDTIMEOUT_SHFT 0x10 -#define HWIO_REG_598415_AXI_ERR_BMSK 0x800 -#define HWIO_REG_598415_AXI_ERR_SHFT 0xb -#define HWIO_REG_598415_AXI_ERR_TYPE_BMSK 0x400 -#define HWIO_REG_598415_AXI_ERR_TYPE_SHFT 0xa -#define HWIO_REG_598415_AXI_RESP_BMSK 0x300 -#define HWIO_REG_598415_AXI_RESP_SHFT 0x8 -#define HWIO_REG_598415_AXI_MID_BMSK 0xf0 -#define HWIO_REG_598415_AXI_MID_SHFT 0x4 -#define HWIO_REG_598415_AXI_TID_BMSK 0xf -#define HWIO_REG_598415_AXI_TID_SHFT 0 - -#define HWIO_REG_439061_ADDR (VIDC_MGEN2MAXI_REG_BASE + 0x00000024) -#define HWIO_REG_439061_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000024) -#define HWIO_REG_439061_RMSK 0x11111ff -#define HWIO_REG_439061_SHFT 0 -#define HWIO_REG_439061_IN in_dword_masked(\ - HWIO_REG_439061_ADDR, HWIO_REG_439061_RMSK) -#define HWIO_REG_439061_INM(m) \ - in_dword_masked(HWIO_REG_439061_ADDR, m) -#define HWIO_REG_439061_OUT(v) \ - out_dword(HWIO_REG_439061_ADDR, v) -#define HWIO_REG_439061_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_439061_ADDR, m, v, HWIO_REG_439061_IN); -#define HWIO_REG_439061_AXI_RD_LAT_REP_EN_BMSK 0x1000000 -#define HWIO_REG_439061_AXI_RD_LAT_REP_EN_SHFT 0x18 -#define HWIO_REG_439061_AXI_LSFR_EN_BMSK 0x100000 -#define HWIO_REG_439061_AXI_LSFR_EN_SHFT 0x14 -#define HWIO_REG_439061_AXI_MISR_RES_BMSK 0x10000 -#define HWIO_REG_439061_AXI_MISR_RES_SHFT 0x10 -#define HWIO_REG_439061_AXI_MISR_EN_BMSK 0x1000 -#define HWIO_REG_439061_AXI_MISR_EN_SHFT 0xc -#define HWIO_REG_439061_AXI_MISR_WD_BMSK 0x100 -#define HWIO_REG_439061_AXI_MISR_WD_SHFT 0x8 -#define HWIO_REG_439061_AXI_CTR_EN_BMSK 0x80 -#define HWIO_REG_439061_AXI_CTR_EN_SHFT 0x7 -#define HWIO_REG_439061_AXI_CTR_RES_BMSK 0x40 -#define HWIO_REG_439061_AXI_CTR_RES_SHFT 0x6 -#define HWIO_REG_439061_AXI_TEST_ARB_SEL_BMSK 0x30 -#define HWIO_REG_439061_AXI_TEST_ARB_SEL_SHFT 0x4 -#define HWIO_REG_439061_AXI_TEST_OUT_SEL_BMSK 0xf -#define HWIO_REG_439061_AXI_TEST_OUT_SEL_SHFT 0 - -#define HWIO_REG_573121_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x00000028) -#define HWIO_REG_573121_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000028) -#define HWIO_REG_573121_RMSK 0xffffffff -#define HWIO_REG_573121_SHFT 0 -#define HWIO_REG_573121_IN in_dword_masked(\ - HWIO_REG_573121_ADDR,\ - HWIO_REG_573121_RMSK) -#define HWIO_REG_573121_INM(m) \ - in_dword_masked(HWIO_REG_573121_ADDR, m) -#define HWIO_REG_573121_AXI_TEST_OUT_BMSK 0xffffffff -#define HWIO_REG_573121_AXI_TEST_OUT_SHFT 0 - -#define HWIO_REG_806413_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x0000002c) -#define HWIO_REG_806413_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x0000002c) -#define HWIO_REG_806413_RMSK 0xffffffff -#define HWIO_REG_806413_SHFT 0 -#define HWIO_REG_806413_IN in_dword_masked(\ - HWIO_REG_806413_ADDR,\ - HWIO_REG_806413_RMSK) -#define HWIO_REG_806413_INM(m) \ - in_dword_masked(HWIO_REG_806413_ADDR, m) -#define HWIO_REG_806413_AXI_TEST_OUT_BMSK 0xffffffff -#define HWIO_REG_806413_AXI_TEST_OUT_SHFT 0 - -#define HWIO_REG_804110_ADDR (VIDC_MGEN2MAXI_REG_BASE + 0x00000030) -#define HWIO_REG_804110_PHYS (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000030) -#define HWIO_REG_804110_RMSK 0xc00fffff -#define HWIO_REG_804110_SHFT 0 -#define HWIO_REG_804110_IN in_dword_masked(\ - HWIO_REG_804110_ADDR, HWIO_REG_804110_RMSK) -#define HWIO_REG_804110_INM(m) \ - in_dword_masked(HWIO_REG_804110_ADDR, m) -#define HWIO_REG_804110_OUT(v) out_dword(HWIO_REG_804110_ADDR, v) -#define HWIO_REG_804110_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_804110_ADDR, m, v, HWIO_REG_804110_IN); -#define HWIO_REG_804110_ENABLE_BMSK 0x80000000 -#define HWIO_REG_804110_ENABLE_SHFT 0x1f -#define HWIO_REG_804110_CONST_VIDC_BMSK 0x40000000 -#define HWIO_REG_804110_CONST_VIDC_SHFT 0x1e -#define HWIO_REG_804110_VIDCV_1080P_VERSION_BMSK 0xff000 -#define HWIO_REG_804110_VIDCV_1080P_VERSION_SHFT 0xc -#define HWIO_REG_804110_MGEN2MAXI_DATA_SEL_BMSK 0xf00 -#define HWIO_REG_804110_MGEN2MAXI_DATA_SEL_SHFT 0x8 -#define HWIO_REG_804110_MGEN2MAXI_XIN_SEL_BMSK 0x80 -#define HWIO_REG_804110_MGEN2MAXI_XIN_SEL_SHFT 0x7 -#define HWIO_REG_804110_MGEN2MAXI_ARB_SEL_BMSK 0x40 -#define HWIO_REG_804110_MGEN2MAXI_ARB_SEL_SHFT 0x6 -#define HWIO_REG_804110_MGEN2MAXI_TESTBUS_SEL_BMSK 0x30 -#define HWIO_REG_804110_MGEN2MAXI_TESTBUS_SEL_SHFT 0x4 -#define HWIO_REG_804110_AHB2AHB_TESTBUS_SEL_BMSK 0x8 -#define HWIO_REG_804110_AHB2AHB_TESTBUS_SEL_SHFT 0x3 -#define HWIO_REG_804110_MGEN2MAXI_AXI_SEL_BMSK 0x4 -#define HWIO_REG_804110_MGEN2MAXI_AXI_SEL_SHFT 0x2 -#define HWIO_REG_804110_SELECT_BMSK 0x3 -#define HWIO_REG_804110_SELECT_SHFT 0 - -#define HWIO_REG_616440_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x00000034) -#define HWIO_REG_616440_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000034) -#define HWIO_REG_616440_RMSK 0xffff -#define HWIO_REG_616440_SHFT 0 -#define HWIO_REG_616440_IN in_dword_masked(\ - HWIO_REG_616440_ADDR,\ - HWIO_REG_616440_RMSK) -#define HWIO_REG_616440_INM(m) \ - in_dword_masked(HWIO_REG_616440_ADDR, m) -#define HWIO_REG_616440_OUT(v) \ - out_dword(HWIO_REG_616440_ADDR, v) -#define HWIO_REG_616440_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_616440_ADDR, m, v,\ - HWIO_REG_616440_IN); -#define HWIO_REG_616440_XBAR_IN_RD_LIM_BMSK 0xff00 -#define HWIO_REG_616440_XBAR_IN_RD_LIM_SHFT 0x8 -#define HWIO_REG_616440_XBAR_IN_WR_LIM_BMSK 0xff -#define HWIO_REG_616440_XBAR_IN_WR_LIM_SHFT 0 - -#define HWIO_REG_527219_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x00000038) -#define HWIO_REG_527219_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x00000038) -#define HWIO_REG_527219_RMSK 0xffff -#define HWIO_REG_527219_SHFT 0 -#define HWIO_REG_527219_IN in_dword_masked(\ - HWIO_REG_527219_ADDR,\ - HWIO_REG_527219_RMSK) -#define HWIO_REG_527219_INM(m) \ - in_dword_masked(HWIO_REG_527219_ADDR, m) -#define HWIO_REG_527219_OUT(v) \ - out_dword(HWIO_REG_527219_ADDR, v) -#define HWIO_REG_527219_OUTM(m, v) \out_dword_masked_ns(\ - HWIO_REG_527219_ADDR, m, v,\ - HWIO_REG_527219_IN); -#define HWIO_REG_527219_XBAR_OUT_RD_LIM_BMSK 0xff00 -#define HWIO_REG_527219_XBAR_OUT_RD_LIM_SHFT 0x8 -#define HWIO_REG_527219_XBAR_OUT_WR_LIM_BMSK 0xff -#define HWIO_REG_527219_XBAR_OUT_WR_LIM_SHFT 0 - -#define HWIO_REG_922106_ADDR \ - (VIDC_MGEN2MAXI_REG_BASE + 0x0000003c) -#define HWIO_REG_922106_PHYS \ - (VIDC_MGEN2MAXI_REG_BASE_PHYS + 0x0000003c) -#define HWIO_REG_922106_RMSK 0xffff -#define HWIO_REG_922106_SHFT 0 -#define HWIO_REG_922106_IN in_dword_masked(\ - HWIO_REG_922106_ADDR,\ - HWIO_REG_922106_RMSK) -#define HWIO_REG_922106_INM(m) \ - in_dword_masked(HWIO_REG_922106_ADDR, m) -#define HWIO_REG_922106_OUT(v) \ - out_dword(HWIO_REG_922106_ADDR, v) -#define HWIO_REG_922106_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_922106_ADDR, m, v,\ - HWIO_REG_922106_IN); -#define HWIO_REG_922106_XBAR_OUT_MAX_RD_BURST_BMSK 0xff00 -#define HWIO_REG_922106_XBAR_OUT_MAX_RD_BURST_SHFT 0x8 -#define HWIO_REG_922106_XBAR_OUT_MAX_WR_BURST_BMSK 0xff -#define HWIO_REG_922106_XBAR_OUT_MAX_WR_BURST_SHFT 0 - -#define VIDC_ENHANCE_REG_BASE (VIDC_BASE + 0x000c0000) -#define VIDC_ENHANCE_REG_BASE_PHYS 0x044c0000 - -#define HWIO_REG_261029_ADDR (VIDC_ENHANCE_REG_BASE + 00000000) -#define HWIO_REG_261029_PHYS (VIDC_ENHANCE_REG_BASE_PHYS + 00000000) -#define HWIO_REG_261029_RMSK 0x10f -#define HWIO_REG_261029_SHFT 0 -#define HWIO_REG_261029_IN in_dword_masked(\ - HWIO_REG_261029_ADDR, HWIO_REG_261029_RMSK) -#define HWIO_REG_261029_INM(m) \ - in_dword_masked(HWIO_REG_261029_ADDR, m) -#define HWIO_REG_261029_OUT(v) \ - out_dword(HWIO_REG_261029_ADDR, v) -#define HWIO_REG_261029_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_261029_ADDR, m, v, HWIO_REG_261029_IN); -#define HWIO_REG_261029_AUTO_INC_EN_BMSK 0x100 -#define HWIO_REG_261029_AUTO_INC_EN_SHFT 0x8 -#define HWIO_REG_261029_DMI_RAM_SEL_BMSK 0xf -#define HWIO_REG_261029_DMI_RAM_SEL_SHFT 0 - -#define HWIO_REG_576200_ADDR (VIDC_ENHANCE_REG_BASE + 0x00000004) -#define HWIO_REG_576200_PHYS (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000004) -#define HWIO_REG_576200_RMSK 0x7ff -#define HWIO_REG_576200_SHFT 0 -#define HWIO_REG_576200_IN in_dword_masked(\ - HWIO_REG_576200_ADDR, HWIO_REG_576200_RMSK) -#define HWIO_REG_576200_INM(m) \ - in_dword_masked(HWIO_REG_576200_ADDR, m) -#define HWIO_REG_576200_OUT(v) \ - out_dword(HWIO_REG_576200_ADDR, v) -#define HWIO_REG_576200_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_576200_ADDR, m, v, HWIO_REG_576200_IN); -#define HWIO_REG_576200_DMI_ADDR_BMSK 0x7ff -#define HWIO_REG_576200_DMI_ADDR_SHFT 0 - -#define HWIO_REG_917583_ADDR (VIDC_ENHANCE_REG_BASE + 0x00000008) -#define HWIO_REG_917583_PHYS (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000008) -#define HWIO_REG_917583_RMSK 0xffffffff -#define HWIO_REG_917583_SHFT 0 -#define HWIO_REG_917583_IN in_dword_masked(\ - HWIO_REG_917583_ADDR, HWIO_REG_917583_RMSK) -#define HWIO_REG_917583_INM(m) \ - in_dword_masked(HWIO_REG_917583_ADDR, m) -#define HWIO_REG_917583_OUT(v) \ - out_dword(HWIO_REG_917583_ADDR, v) -#define HWIO_REG_917583_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_917583_ADDR, m, v, HWIO_REG_917583_IN); -#define HWIO_REG_917583_DMI_DATA_HI_BMSK 0xffffffff -#define HWIO_REG_917583_DMI_DATA_HI_SHFT 0 - -#define HWIO_REG_556274_ADDR (VIDC_ENHANCE_REG_BASE + 0x0000000c) -#define HWIO_REG_556274_PHYS (VIDC_ENHANCE_REG_BASE_PHYS + 0x0000000c) -#define HWIO_REG_556274_RMSK 0xffffffff -#define HWIO_REG_556274_SHFT 0 -#define HWIO_REG_556274_IN in_dword_masked(\ - HWIO_REG_556274_ADDR, HWIO_REG_556274_RMSK) -#define HWIO_REG_556274_INM(m) \ - in_dword_masked(HWIO_REG_556274_ADDR, m) -#define HWIO_REG_556274_OUT(v) \ - out_dword(HWIO_REG_556274_ADDR, v) -#define HWIO_REG_556274_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_556274_ADDR, m, v, HWIO_REG_556274_IN); -#define HWIO_REG_556274_DMI_DATA_LO_BMSK 0xffffffff -#define HWIO_REG_556274_DMI_DATA_LO_SHFT 0 - -#define HWIO_REG_39703_ADDR (VIDC_ENHANCE_REG_BASE + 0x00000010) -#define HWIO_REG_39703_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000010) -#define HWIO_REG_39703_RMSK 0x1f -#define HWIO_REG_39703_SHFT 0 -#define HWIO_REG_39703_IN in_dword_masked(\ - HWIO_REG_39703_ADDR, HWIO_REG_39703_RMSK) -#define HWIO_REG_39703_INM(m) \ - in_dword_masked(HWIO_REG_39703_ADDR, m) -#define HWIO_REG_39703_OUT(v) \ - out_dword(HWIO_REG_39703_ADDR, v) -#define HWIO_REG_39703_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_39703_ADDR, m, v, HWIO_REG_39703_IN); -#define HWIO_REG_39703_PIX_CACHE_TB_SEL_BMSK 0x1f -#define HWIO_REG_39703_PIX_CACHE_TB_SEL_SHFT 0 - -#define HWIO_REG_169013_ADDR (VIDC_ENHANCE_REG_BASE + 0x00000014) -#define HWIO_REG_169013_PHYS (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000014) -#define HWIO_REG_169013_RMSK 0x3 -#define HWIO_REG_169013_SHFT 0 -#define HWIO_REG_169013_IN in_dword_masked(\ - HWIO_REG_169013_ADDR, HWIO_REG_169013_RMSK) -#define HWIO_REG_169013_INM(m) \ - in_dword_masked(HWIO_REG_169013_ADDR, m) -#define HWIO_REG_169013_OUT(v) \ - out_dword(HWIO_REG_169013_ADDR, v) -#define HWIO_REG_169013_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_169013_ADDR, m, v, HWIO_REG_169013_IN); -#define HWIO_REG_169013_PIX_CACHE_SW_RESET_BMSK 0x2 -#define HWIO_REG_169013_PIX_CACHE_SW_RESET_SHFT 0x1 -#define HWIO_REG_169013_CRIF_RESET_BMSK 0x1 -#define HWIO_REG_169013_CRIF_RESET_SHFT 0 - -#define HWIO_REG_22756_ADDR (VIDC_ENHANCE_REG_BASE + 0x00000018) -#define HWIO_REG_22756_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000018) -#define HWIO_REG_22756_RMSK 0x133f -#define HWIO_REG_22756_SHFT 0 -#define HWIO_REG_22756_IN in_dword_masked(\ - HWIO_REG_22756_ADDR, HWIO_REG_22756_RMSK) -#define HWIO_REG_22756_INM(m) \ - in_dword_masked(HWIO_REG_22756_ADDR, m) -#define HWIO_REG_22756_OUT(v) \ - out_dword(HWIO_REG_22756_ADDR, v) -#define HWIO_REG_22756_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_22756_ADDR, m, v, HWIO_REG_22756_IN); -#define HWIO_REG_22756_CACHE_HALT_BMSK 0x1000 -#define HWIO_REG_22756_CACHE_HALT_SHFT 0xc -#define HWIO_REG_22756_PAGE_SIZE_BMSK 0x300 -#define HWIO_REG_22756_PAGE_SIZE_SHFT 0x8 -#define HWIO_REG_22756_STATISTICS_OFF_BMSK 0x20 -#define HWIO_REG_22756_STATISTICS_OFF_SHFT 0x5 -#define HWIO_REG_22756_CACHE_PORT_SELECT_BMSK 0x10 -#define HWIO_REG_22756_CACHE_PORT_SELECT_SHFT 0x4 -#define HWIO_REG_22756_PREFETCH_EN_BMSK 0x8 -#define HWIO_REG_22756_PREFETCH_EN_SHFT 0x3 -#define HWIO_REG_22756_SS_TILE_FORMAT_BMSK 0x4 -#define HWIO_REG_22756_SS_TILE_FORMAT_SHFT 0x2 -#define HWIO_REG_22756_CACHE_EN_BMSK 0x2 -#define HWIO_REG_22756_CACHE_EN_SHFT 0x1 -#define HWIO_REG_22756_CACHE_TAG_CLEAR_BMSK 0x1 -#define HWIO_REG_22756_CACHE_TAG_CLEAR_SHFT 0 - -#define HWIO_REG_951731_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x0000001c) -#define HWIO_REG_951731_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x0000001c) -#define HWIO_REG_951731_RMSK 0x7ff07ff -#define HWIO_REG_951731_SHFT 0 -#define HWIO_REG_951731_IN in_dword_masked(\ - HWIO_REG_951731_ADDR,\ - HWIO_REG_951731_RMSK) -#define HWIO_REG_951731_INM(m) \ - in_dword_masked(HWIO_REG_951731_ADDR, m) -#define HWIO_REG_951731_OUT(v) \ - out_dword(HWIO_REG_951731_ADDR, v) -#define HWIO_REG_951731_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_951731_ADDR, m, v,\ - HWIO_REG_951731_IN); -#define HWIO_REG_951731_FRAME_HEIGHT_BMSK 0x7ff0000 -#define HWIO_REG_951731_FRAME_HEIGHT_SHFT 0x10 -#define HWIO_REG_951731_FRAME_WIDTH_BMSK 0x7ff -#define HWIO_REG_951731_FRAME_WIDTH_SHFT 0 - -#define HWIO_REG_905239_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x00000020) -#define HWIO_REG_905239_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000020) -#define HWIO_REG_905239_RMSK 0x3ffff -#define HWIO_REG_905239_SHFT 0 -#define HWIO_REG_905239_IN in_dword_masked(\ - HWIO_REG_905239_ADDR,\ - HWIO_REG_905239_RMSK) -#define HWIO_REG_905239_INM(m) \ - in_dword_masked(HWIO_REG_905239_ADDR, m) -#define HWIO_REG_905239_OUT(v) \ - out_dword(HWIO_REG_905239_ADDR, v) -#define HWIO_REG_905239_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_905239_ADDR, m, v,\ - HWIO_REG_905239_IN); -#define HWIO_REG_905239_LINEAR_LUMA_BMSK 0x3ffff -#define HWIO_REG_905239_LINEAR_LUMA_SHFT 0 -#define HWIO_REG_905239_TILE_LUMA_BMSK 0xff00 -#define HWIO_REG_905239_TILE_LUMA_SHFT 0x8 -#define HWIO_REG_905239_TILE_CHROMA_BMSK 0xff -#define HWIO_REG_905239_TILE_CHROMA_SHFT 0 - -#define HWIO_REG_804925_ADDR(n) \ - (VIDC_ENHANCE_REG_BASE + 0x00000024 + 4 * (n)) -#define HWIO_REG_804925_PHYS(n) \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000024 + 4 * (n)) -#define HWIO_REG_804925_RMSK 0xfffffff8 -#define HWIO_REG_804925_SHFT 0 -#define HWIO_REG_804925_MAXn 0x12 -#define HWIO_REG_804925_INI(n) \ - in_dword(HWIO_REG_804925_ADDR(n)) -#define HWIO_REG_804925_INMI(n, mask) \ - in_dword_masked(HWIO_REG_804925_ADDR(n), mask) -#define HWIO_REG_804925_OUTI(n, val) \ - out_dword(HWIO_REG_804925_ADDR(n), val) -#define HWIO_REG_804925_OUTMI(n, mask, val) \ - out_dword_masked_ns(HWIO_REG_804925_ADDR(n),\ - mask, val, HWIO_REG_804925_INI(n)); -#define HWIO_REG_804925_ADDR_BMSK 0xfffffff8 -#define HWIO_REG_804925_ADDR_SHFT 0x3 - -#define HWIO_REG_41909_ADDR(n) \ - (VIDC_ENHANCE_REG_BASE + 0x00000070 + 4 * (n)) -#define HWIO_REG_41909_PHYS(n) \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x00000070 + 4 * (n)) -#define HWIO_REG_41909_RMSK 0xfffffff8 -#define HWIO_REG_41909_SHFT 0 -#define HWIO_REG_41909_MAXn 0x12 -#define HWIO_REG_41909_INI(n) \ - in_dword(HWIO_REG_41909_ADDR(n)) -#define HWIO_REG_41909_INMI(n, mask) \ - in_dword_masked(HWIO_REG_41909_ADDR(n), mask) -#define HWIO_REG_41909_OUTI(n, val) \ - out_dword(HWIO_REG_41909_ADDR(n), val) -#define HWIO_REG_41909_OUTMI(n, mask, val) \ - out_dword_masked_ns(HWIO_REG_41909_ADDR(n),\ - mask, val, HWIO_REG_41909_INI(n)); -#define HWIO_REG_41909_ADDR_BMSK 0xfffffff8 -#define HWIO_REG_41909_ADDR_SHFT 0x3 - -#define HWIO_REG_919904_ADDR (VIDC_ENHANCE_REG_BASE + 0x000000bc) -#define HWIO_REG_919904_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000bc) -#define HWIO_REG_919904_RMSK 0x1 -#define HWIO_REG_919904_SHFT 0 -#define HWIO_REG_919904_IN in_dword_masked(\ - HWIO_REG_919904_ADDR,\ - HWIO_REG_919904_RMSK) -#define HWIO_REG_919904_INM(m) \ - in_dword_masked(HWIO_REG_919904_ADDR, m) -#define HWIO_REG_919904_IDLE_BMSK 0x1 -#define HWIO_REG_919904_IDLE_SHFT 0 - -#define HWIO_REG_278310_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x000000c0) -#define HWIO_REG_278310_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000c0) -#define HWIO_REG_278310_RMSK 0xffffffff -#define HWIO_REG_278310_SHFT 0 -#define HWIO_REG_278310_IN in_dword_masked(\ - HWIO_REG_278310_ADDR,\ - HWIO_REG_278310_RMSK) -#define HWIO_REG_278310_INM(m) \ - in_dword_masked(HWIO_REG_278310_ADDR, m) -#define HWIO_REG_278310_MISS_COUNT_BMSK 0xffffffff -#define HWIO_REG_278310_MISS_COUNT_SHFT 0 - -#define HWIO_REG_421222_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x000000c4) -#define HWIO_REG_421222_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000c4) -#define HWIO_REG_421222_RMSK 0xffffffff -#define HWIO_REG_421222_SHFT 0 -#define HWIO_REG_421222_IN in_dword_masked(\ - HWIO_REG_421222_ADDR,\ - HWIO_REG_421222_RMSK) -#define HWIO_REG_421222_INM(m) \ - in_dword_masked(HWIO_REG_421222_ADDR, m) -#define HWIO_REG_421222_HIT_COUNT_BMSK 0xffffffff -#define HWIO_REG_421222_HIT_COUNT_SHFT 0 - -#define HWIO_REG_609607_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x000000c8) -#define HWIO_REG_609607_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000c8) -#define HWIO_REG_609607_RMSK 0xffffffff -#define HWIO_REG_609607_SHFT 0 -#define HWIO_REG_609607_IN in_dword_masked(\ - HWIO_REG_609607_ADDR,\ - HWIO_REG_609607_RMSK) -#define HWIO_REG_609607_INM(m) \ - in_dword_masked(HWIO_REG_609607_ADDR, m) -#define HWIO_REG_609607_AXI_REQUEST_COUNT_BMSK 0xffffffff -#define HWIO_REG_609607_AXI_REQUEST_COUNT_SHFT 0 - -#define HWIO_REG_395232_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x000000cc) -#define HWIO_REG_395232_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000cc) -#define HWIO_REG_395232_RMSK 0xffffffff -#define HWIO_REG_395232_SHFT 0 -#define HWIO_REG_395232_IN in_dword_masked(\ - HWIO_REG_395232_ADDR,\ - HWIO_REG_395232_RMSK) -#define HWIO_REG_395232_INM(m) \ - in_dword_masked(HWIO_REG_395232_ADDR, m) -#define HWIO_REG_395232_CORE_REQUEST_COUNT_BMSK \ - 0xffffffff -#define HWIO_REG_395232_CORE_REQUEST_COUNT_SHFT 0 - -#define HWIO_REG_450146_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x000000d0) -#define HWIO_REG_450146_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000d0) -#define HWIO_REG_450146_RMSK 0xffffffff -#define HWIO_REG_450146_SHFT 0 -#define HWIO_REG_450146_IN in_dword_masked(\ - HWIO_REG_450146_ADDR,\ - HWIO_REG_450146_RMSK) -#define HWIO_REG_450146_INM(m) \ - in_dword_masked(HWIO_REG_450146_ADDR, m) -#define HWIO_REG_450146_AXI_BEAT_COUNT_BMSK 0xffffffff -#define HWIO_REG_450146_AXI_BEAT_COUNT_SHFT 0 - -#define HWIO_REG_610651_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x000000d4) -#define HWIO_REG_610651_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000d4) -#define HWIO_REG_610651_RMSK 0xffffffff -#define HWIO_REG_610651_SHFT 0 -#define HWIO_REG_610651_IN in_dword_masked(\ - HWIO_REG_610651_ADDR,\ - HWIO_REG_610651_RMSK) -#define HWIO_REG_610651_INM(m) \ - in_dword_masked(HWIO_REG_610651_ADDR, m) -#define HWIO_REG_610651_CORE_BEAT_COUNT_BMSK 0xffffffff -#define HWIO_REG_610651_CORE_BEAT_COUNT_SHFT 0 - -#define HWIO_REG_883784_ADDR \ - (VIDC_ENHANCE_REG_BASE + 0x000000d8) -#define HWIO_REG_883784_PHYS \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000d8) -#define HWIO_REG_883784_RMSK 0xffffffff -#define HWIO_REG_883784_SHFT 0 -#define HWIO_REG_883784_IN in_dword_masked(\ - HWIO_REG_883784_ADDR,\ - HWIO_REG_883784_RMSK) -#define HWIO_REG_883784_INM(m) \ - in_dword_masked(HWIO_REG_883784_ADDR, m) -#define HWIO_REG_883784_OUT(v) \ - out_dword(HWIO_REG_883784_ADDR, v) -#define HWIO_REG_883784_OUTM(m, v) out_dword_masked_ns(\ - HWIO_REG_883784_ADDR, m, v,\ - HWIO_REG_883784_IN); -#define HWIO_REG_883784_COUNTER_BMSK 0xffffff00 -#define HWIO_REG_883784_COUNTER_SHFT 0x8 -#define HWIO_REG_883784_ID_BMSK 0xf0 -#define HWIO_REG_883784_ID_SHFT 0x4 -#define HWIO_REG_883784_IGNORE_ID_BMSK 0x8 -#define HWIO_REG_883784_IGNORE_ID_SHFT 0x3 -#define HWIO_REG_883784_INPUT_SEL_BMSK 0x6 -#define HWIO_REG_883784_INPUT_SEL_SHFT 0x1 -#define HWIO_REG_883784_MISR_EN_BMSK 0x1 -#define HWIO_REG_883784_MISR_EN_SHFT 0 - -#define HWIO_REG_651391_ADDR(n) \ - (VIDC_ENHANCE_REG_BASE + 0x000000dc + 4 * (n)) -#define HWIO_REG_651391_PHYS(n) \ - (VIDC_ENHANCE_REG_BASE_PHYS + 0x000000dc + 4 * (n)) -#define HWIO_REG_651391_RMSK 0xffffffff -#define HWIO_REG_651391_SHFT 0 -#define HWIO_REG_651391_MAXn 0x1 -#define HWIO_REG_651391_INI(n) \ - in_dword(HWIO_REG_651391_ADDR(n)) -#define HWIO_REG_651391_INMI(n, mask) \ - in_dword_masked(HWIO_REG_651391_ADDR(n), mask) -#define HWIO_REG_651391_OUTI(n, val) \ - out_dword(HWIO_REG_651391_ADDR(n), val) -#define HWIO_REG_651391_SIGNATURE_BMSK 0xffffffff -#define HWIO_REG_651391_SIGNATURE_SHFT 0 - -#endif - diff --git a/drivers/video/msm/vidc/1080p/ddl/vidc_pix_cache.c b/drivers/video/msm/vidc/1080p/ddl/vidc_pix_cache.c deleted file mode 100644 index de294fd423e9993ae2667cfca2bb5f30283136b0..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vidc_pix_cache.c +++ /dev/null @@ -1,349 +0,0 @@ -/* Copyright (c) 2010, 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 "vidc_hwio_reg.h" -#include "vidc_hwio.h" -#include "vidc_pix_cache.h" - - -#define VIDC_1080P_MAX_DEC_DPB 19 -#define VIDC_TILE_MULTIPLY_FACTOR 8192 - -void vidc_pix_cache_sw_reset(void) -{ - u32 sw_reset_value = 0; - - VIDC_HWIO_IN(REG_169013, &sw_reset_value); - sw_reset_value |= HWIO_REG_169013_PIX_CACHE_SW_RESET_BMSK; - VIDC_HWIO_OUT(REG_169013, sw_reset_value); - VIDC_HWIO_IN(REG_169013, &sw_reset_value); - sw_reset_value &= (~HWIO_REG_169013_PIX_CACHE_SW_RESET_BMSK); - VIDC_HWIO_OUT(REG_169013, sw_reset_value); -} - -void vidc_pix_cache_init_luma_chroma_base_addr(u32 dpb, - u32 *pn_dpb_luma_offset, u32 *pn_dpb_chroma_offset) -{ - u32 count, num_dpb_used = dpb; - u32 dpb_reset_value = VIDC_1080P_DEC_DPB_RESET_VALUE; - - if (num_dpb_used > VIDC_1080P_MAX_DEC_DPB) - num_dpb_used = VIDC_1080P_MAX_DEC_DPB; - for (count = 0; count < VIDC_1080P_MAX_DEC_DPB; count++) { - if (count < num_dpb_used) { - if (pn_dpb_luma_offset) { - VIDC_HWIO_OUTI( - REG_804925, - count, pn_dpb_luma_offset[count]); - } else { - VIDC_HWIO_OUTI( - REG_804925, - count, dpb_reset_value); - } - if (pn_dpb_chroma_offset) { - VIDC_HWIO_OUTI( - REG_41909, - count, pn_dpb_chroma_offset[count]); - } else { - VIDC_HWIO_OUTI( - REG_41909, - count, dpb_reset_value); - } - } else { - VIDC_HWIO_OUTI(REG_804925, - count, dpb_reset_value); - VIDC_HWIO_OUTI(REG_41909, - count, dpb_reset_value); - } - } -} - -void vidc_pix_cache_set_frame_range(u32 luma_size, u32 chroma_size) -{ - u32 frame_range; - - frame_range = - (((luma_size / VIDC_TILE_MULTIPLY_FACTOR) & 0xFF) << 8)| - ((chroma_size / VIDC_TILE_MULTIPLY_FACTOR) & 0xFF); - VIDC_HWIO_OUT(REG_905239, frame_range); -} -void vidc_pix_cache_set_frame_size(u32 frame_width, u32 frame_height) -{ - u32 frame_size; - frame_size = (((u32) (frame_height << HWIO_REG_951731_FRAME_HEIGHT_SHFT) & - HWIO_REG_951731_FRAME_HEIGHT_BMSK) | - ((u32) (frame_width << HWIO_REG_951731_FRAME_WIDTH_SHFT) & - HWIO_REG_951731_FRAME_WIDTH_BMSK)); - VIDC_HWIO_OUT(REG_951731, frame_size); -} - -void vidc_pix_cache_init_config( - struct vidc_1080P_pix_cache_config *config) -{ - u32 cfg_reg = 0; - - if (config->cache_enable) - cfg_reg |= HWIO_REG_22756_CACHE_EN_BMSK; - else - cfg_reg &= (~HWIO_REG_22756_CACHE_EN_BMSK); - if (config->port_select == VIDC_1080P_PIX_CACHE_PORT_A) - cfg_reg &= - (~HWIO_REG_22756_CACHE_PORT_SELECT_BMSK); - else - cfg_reg |= HWIO_REG_22756_CACHE_PORT_SELECT_BMSK; - if (!config->statistics_off) - cfg_reg |= HWIO_REG_22756_STATISTICS_OFF_BMSK; - else - cfg_reg &= (~HWIO_REG_22756_STATISTICS_OFF_BMSK); - if (config->prefetch_en) - cfg_reg |= HWIO_REG_22756_PREFETCH_EN_BMSK; - else - cfg_reg &= (~HWIO_REG_22756_PREFETCH_EN_BMSK); - cfg_reg &= (~HWIO_REG_22756_PAGE_SIZE_BMSK); - cfg_reg |= VIDC_SETFIELD(config->page_size, - HWIO_REG_22756_PAGE_SIZE_SHFT, - HWIO_REG_22756_PAGE_SIZE_BMSK); - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_set_prefetch_page_limit(u32 page_size_limit) -{ - u32 cfg_reg = 0; - - VIDC_HWIO_IN(REG_22756, &cfg_reg); - cfg_reg &= (~HWIO_REG_22756_PAGE_SIZE_BMSK); - cfg_reg |= VIDC_SETFIELD(page_size_limit, - HWIO_REG_22756_PAGE_SIZE_SHFT, - HWIO_REG_22756_PAGE_SIZE_BMSK); - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_enable_prefetch(u32 prefetch_enable) -{ - u32 cfg_reg = 0; - - VIDC_HWIO_IN(REG_22756, &cfg_reg); - if (prefetch_enable) - cfg_reg |= HWIO_REG_22756_PREFETCH_EN_BMSK; - else - cfg_reg &= (~HWIO_REG_22756_PREFETCH_EN_BMSK); - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_disable_statistics(u32 statistics_off) -{ - u32 cfg_reg = 0; - - VIDC_HWIO_IN(REG_22756, &cfg_reg); - if (!statistics_off) - cfg_reg |= HWIO_REG_22756_STATISTICS_OFF_BMSK; - else - cfg_reg &= (~HWIO_REG_22756_STATISTICS_OFF_BMSK); - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_set_port( - enum vidc_1080P_pix_cache_port_sel port_select) -{ - u32 cfg_reg = 0; - - VIDC_HWIO_IN(REG_22756, &cfg_reg); - if (port_select == VIDC_1080P_PIX_CACHE_PORT_A) - cfg_reg &= - (~HWIO_REG_22756_CACHE_PORT_SELECT_BMSK); - else - cfg_reg |= HWIO_REG_22756_CACHE_PORT_SELECT_BMSK; - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_enable_cache(u32 cache_enable) -{ - u32 cfg_reg = 0; - - VIDC_HWIO_IN(REG_22756, &cfg_reg); - if (cache_enable) - cfg_reg |= HWIO_REG_22756_CACHE_EN_BMSK; - else - cfg_reg &= (~HWIO_REG_22756_CACHE_EN_BMSK); - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_clear_cache_tags(void) -{ - u32 cfg_reg = 0; - - VIDC_HWIO_IN(REG_22756, &cfg_reg); - cfg_reg |= HWIO_REG_22756_CACHE_TAG_CLEAR_BMSK; - VIDC_HWIO_OUT(REG_22756, cfg_reg); - VIDC_HWIO_IN(REG_22756, &cfg_reg); - cfg_reg &= (~HWIO_REG_22756_CACHE_TAG_CLEAR_BMSK); - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_set_halt(u32 halt_enable) -{ - u32 cfg_reg = 0; - - VIDC_HWIO_IN(REG_22756, &cfg_reg); - if (halt_enable) - cfg_reg |= HWIO_REG_22756_CACHE_HALT_BMSK; - else - cfg_reg &= (~HWIO_REG_22756_CACHE_HALT_BMSK); - VIDC_HWIO_OUT(REG_22756, cfg_reg); -} - -void vidc_pix_cache_get_status_idle(u32 *idle_status) -{ - VIDC_HWIO_IN(REG_919904, idle_status); -} - -void vidc_pix_cache_set_ram(u32 ram_select) -{ - u32 dmi_cfg_reg = 0; - - VIDC_HWIO_IN(REG_261029, &dmi_cfg_reg); - dmi_cfg_reg &= (~HWIO_REG_261029_DMI_RAM_SEL_BMSK); - dmi_cfg_reg |= VIDC_SETFIELD(ram_select, - HWIO_REG_261029_AUTO_INC_EN_SHFT, - HWIO_REG_261029_DMI_RAM_SEL_BMSK); - VIDC_HWIO_OUT(REG_261029, dmi_cfg_reg); -} - -void vidc_pix_cache_set_auto_inc_ram_addr(u32 auto_inc_enable) -{ - u32 dmi_cfg_reg = 0; - - VIDC_HWIO_IN(REG_261029, &dmi_cfg_reg); - if (auto_inc_enable) - dmi_cfg_reg |= HWIO_REG_261029_AUTO_INC_EN_BMSK; - else - dmi_cfg_reg &= (~HWIO_REG_261029_AUTO_INC_EN_BMSK); - VIDC_HWIO_OUT(REG_261029, dmi_cfg_reg); -} - - -void vidc_pix_cache_read_ram_data(u32 src_ram_address, - u32 ram_size, u32 *dest_address) -{ - u32 count, dmi_cfg_reg = 0; - - VIDC_HWIO_IN(REG_261029, &dmi_cfg_reg); - VIDC_HWIO_OUT(REG_576200, src_ram_address); - vidc_pix_cache_set_auto_inc_ram_addr(1); - for (count = 0; count < ram_size; count++) { - VIDC_HWIO_IN(REG_556274, dest_address); - dest_address++; - VIDC_HWIO_IN(REG_917583, dest_address); - dest_address++; - } - VIDC_HWIO_OUT(REG_261029, dmi_cfg_reg); -} - -void vidc_pix_cache_write_ram_data(u32 *src_address, - u32 ram_size, u32 dest_ram_address) -{ - u32 count, dmi_cfg_reg = 0; - - VIDC_HWIO_IN(REG_261029, &dmi_cfg_reg); - VIDC_HWIO_OUT(REG_576200, dest_ram_address); - vidc_pix_cache_set_auto_inc_ram_addr(1); - for (count = 0; count < ram_size; count++) { - VIDC_HWIO_OUT(REG_917583, *src_address); - src_address++; - VIDC_HWIO_OUT(REG_556274, *src_address); - src_address++; - } - VIDC_HWIO_OUT(REG_261029, dmi_cfg_reg); -} - -void vidc_pix_cache_get_statistics( - struct vidc_1080P_pix_cache_statistics *statistics) -{ - VIDC_HWIO_IN(REG_278310, - &statistics->access_miss); - VIDC_HWIO_IN(REG_421222, - &statistics->access_hit); - VIDC_HWIO_IN(REG_609607, - &statistics->axi_req); - VIDC_HWIO_IN(REG_395232, - &statistics->core_req); - VIDC_HWIO_IN(REG_450146, - &statistics->axi_bus); - VIDC_HWIO_IN(REG_610651, - &statistics->core_bus); -} - -void vidc_pix_cache_enable_misr(u32 misr_enable) -{ - u32 misr_cfg_reg = 0; - - VIDC_HWIO_IN(REG_883784, &misr_cfg_reg); - if (misr_enable) - misr_cfg_reg |= HWIO_REG_883784_MISR_EN_BMSK; - else - misr_cfg_reg &= - (~HWIO_REG_883784_MISR_EN_BMSK); - VIDC_HWIO_OUT(REG_261029, misr_cfg_reg); -} - -void vidc_pix_cache_set_misr_interface(u32 input_select) -{ - u32 misr_cfg_reg = 0; - - VIDC_HWIO_IN(REG_883784, &misr_cfg_reg); - misr_cfg_reg &= (~HWIO_REG_883784_INPUT_SEL_BMSK); - misr_cfg_reg |= VIDC_SETFIELD(input_select, - HWIO_REG_883784_INPUT_SEL_SHFT, - HWIO_REG_883784_INPUT_SEL_BMSK); - VIDC_HWIO_OUT(REG_261029, misr_cfg_reg); -} - -void vidc_pix_cache_set_misr_id_filtering( - struct vidc_1080P_pix_cache_misr_id_filtering *filter_id) -{ - u32 misr_cfg_reg = 0; - - VIDC_HWIO_IN(REG_883784, &misr_cfg_reg); - if (filter_id->ignore_id) - misr_cfg_reg |= - HWIO_REG_883784_IGNORE_ID_BMSK; - else - misr_cfg_reg &= - (~HWIO_REG_883784_IGNORE_ID_BMSK); - misr_cfg_reg &= (~HWIO_REG_883784_ID_BMSK); - misr_cfg_reg |= VIDC_SETFIELD(filter_id->id, - HWIO_REG_883784_ID_SHFT, - HWIO_REG_883784_ID_BMSK); - VIDC_HWIO_OUT(REG_261029, misr_cfg_reg); -} - -void vidc_pix_cache_set_misr_filter_trans(u32 no_of_trans) -{ - u32 misr_cfg_reg = 0; - - VIDC_HWIO_IN(REG_883784, &misr_cfg_reg); - misr_cfg_reg &= (~HWIO_REG_883784_COUNTER_BMSK); - misr_cfg_reg |= VIDC_SETFIELD(no_of_trans, - HWIO_REG_883784_COUNTER_SHFT, - HWIO_REG_883784_COUNTER_BMSK); - VIDC_HWIO_OUT(REG_261029, misr_cfg_reg); -} - -void vidc_pix_cache_get_misr_signatures( - struct vidc_1080P_pix_cache_misr_signature *signatures) -{ - VIDC_HWIO_INI(REG_651391, 0, - &signatures->signature0); - VIDC_HWIO_INI(REG_651391, 1, - &signatures->signature1); -} diff --git a/drivers/video/msm/vidc/1080p/ddl/vidc_pix_cache.h b/drivers/video/msm/vidc/1080p/ddl/vidc_pix_cache.h deleted file mode 100644 index c70b1131d5d5c770673ce05ddba809ac95a53028..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/ddl/vidc_pix_cache.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (c) 2010, 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 _VIDEO_CORE_PIXCACHE_ -#define _VIDEO_CORE_PIXCACHE_ - - -#include "vidc.h" - -#define VIDC_1080P_DEC_DPB_RESET_VALUE 0xFFFFFFF8 - -enum vidc_1080P_pix_cache_port_sel{ - VIDC_1080P_PIX_CACHE_PORT_A = 0, - VIDC_1080P_PIX_CACHE_PORT_B = 1, - VIDC_1080P_PIX_CACHE_PORT_32BIT = 0x7FFFFFFF -}; -enum vidc_1080P_pix_cache_page_size{ - VIDC_1080P_PIX_CACHE_PAGE_SIZE_1K = 0, - VIDC_1080P_PIX_CACHE_PAGE_SIZE_2K = 1, - VIDC_1080P_PIX_CACHE_PAGE_SIZE_4K = 2 -}; -struct vidc_1080P_pix_cache_config{ - u32 cache_enable; - u32 prefetch_en; - enum vidc_1080P_pix_cache_port_sel port_select; - u32 statistics_off; - enum vidc_1080P_pix_cache_page_size page_size; -}; -struct vidc_1080P_pix_cache_statistics{ - u32 access_miss; - u32 access_hit; - u32 axi_req; - u32 core_req; - u32 axi_bus; - u32 core_bus; -}; -struct vidc_1080P_pix_cache_misr_id_filtering{ - u32 ignore_id; - u32 id; -}; -struct vidc_1080P_pix_cache_misr_signature{ - u32 signature0; - u32 signature1; -}; - -void vidc_pix_cache_sw_reset(void); -void vidc_pix_cache_init_luma_chroma_base_addr(u32 dpb, - u32 *pn_dpb_luma_offset, u32 *pn_dpb_chroma_offset); -void vidc_pix_cache_set_frame_range(u32 luma_size, u32 chroma_size); -void vidc_pix_cache_set_frame_size(u32 frame_width, u32 frame_height); -void vidc_pix_cache_init_config( - struct vidc_1080P_pix_cache_config *config); -void vidc_pix_cache_set_prefetch_page_limit(u32 page_size_limit); -void vidc_pix_cache_enable_prefetch(u32 prefetch_enable); -void vidc_pix_cache_disable_statistics(u32 statistics_off); -void vidc_pix_cache_set_port( - enum vidc_1080P_pix_cache_port_sel port_select); -void vidc_pix_cache_enable_cache(u32 cache_enable); -void vidc_pix_cache_clear_cache_tags(void); -void vidc_pix_cache_set_halt(u32 halt_enable); -void vidc_pix_cache_get_status_idle(u32 *idle_status); -void vidc_pix_cache_set_ram(u32 ram_select); -void vidc_pix_cache_set_auto_inc_ram_addr(u32 auto_inc_enable); -void vidc_pix_cache_read_ram_data(u32 src_ram_address, u32 ram_size, - u32 *dest_address); -void vidc_pix_cache_write_ram_data(u32 *src_address, u32 ram_size, - u32 dest_ram_address); -void vidc_pix_cache_get_statistics( - struct vidc_1080P_pix_cache_statistics *statistics); -void vidc_pix_cache_enable_misr(u32 misr_enable); -void vidc_pix_cache_set_misr_interface(u32 input_select); -void vidc_pix_cache_set_misr_id_filtering( - struct vidc_1080P_pix_cache_misr_id_filtering *filter_id); -void vidc_pix_cache_set_misr_filter_trans(u32 no_of_trans); -void vidc_pix_cache_get_misr_signatures( - struct vidc_1080P_pix_cache_misr_signature *signatures); -#endif diff --git a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c b/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c deleted file mode 100644 index a0a047183ec6430e03cc84bda74225eb994bd876..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c +++ /dev/null @@ -1,1035 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "vidc.h" -#include "vcd_res_tracker.h" - -#define PIL_FW_SIZE 0x200000 - -static unsigned int vidc_clk_table[5] = { - 48000000, 133330000, 200000000, 228570000, 266670000, -}; -static struct res_trk_context resource_context; - -#define VIDC_FW "vidc_1080p.fw" -#define VIDC_FW_SIZE SZ_1M - -struct res_trk_vidc_mmu_clk { - char *mmu_clk_name; - struct clk *mmu_clk; -}; - -static struct res_trk_vidc_mmu_clk vidc_mmu_clks[] = { - {"mdp_iommu_clk"}, {"rot_iommu_clk"}, - {"vcodec_iommu0_clk"}, {"vcodec_iommu1_clk"}, - {"smmu_iface_clk"} -}; - -unsigned char *vidc_video_codec_fw; -u32 vidc_video_codec_fw_size; -static u32 res_trk_get_clk(void); -static void res_trk_put_clk(void); - -static void *res_trk_pmem_map - (struct ddl_buf_addr *addr, size_t sz, u32 alignment) -{ - u32 offset = 0; - struct ddl_context *ddl_context; - int ret = 0; - unsigned long iova = 0; - unsigned long buffer_size = 0; - unsigned long *kernel_vaddr = NULL; - - ddl_context = ddl_get_context(); - if (res_trk_get_enable_ion() && addr->alloc_handle) { - kernel_vaddr = (unsigned long *) ion_map_kernel( - ddl_context->video_ion_client, - addr->alloc_handle); - if (IS_ERR_OR_NULL(kernel_vaddr)) { - DDL_MSG_ERROR("%s():DDL ION client map failed\n", - __func__); - goto ion_bail_out; - } - addr->virtual_base_addr = (u8 *) kernel_vaddr; - ret = ion_map_iommu(ddl_context->video_ion_client, - addr->alloc_handle, - VIDEO_DOMAIN, - VIDEO_FIRMWARE_POOL, - SZ_4K, - 0, - (dma_addr_t *)&iova, - &buffer_size, - 0, 0); - if (ret || !iova) { - DDL_MSG_ERROR( - "%s():DDL ION client iommu map failed, ret = %d iova = 0x%lx\n", - __func__, ret, iova); - goto ion_unmap_bail_out; - } - addr->mapped_buffer = NULL; - addr->physical_base_addr = (u8 *)iova; - addr->align_physical_addr = (u8 *) DDL_ALIGN((u32) - addr->physical_base_addr, alignment); - offset = (u32)(addr->align_physical_addr - - addr->physical_base_addr); - addr->align_virtual_addr = addr->virtual_base_addr + offset; - addr->buffer_size = buffer_size; - } else { - pr_err("ION must be enabled."); - goto bail_out; - } - return addr->virtual_base_addr; -bail_out: - return NULL; -ion_unmap_bail_out: - if (!IS_ERR_OR_NULL(addr->alloc_handle)) { - ion_unmap_kernel(resource_context. - res_ion_client, addr->alloc_handle); - } -ion_bail_out: - return NULL; -} - -static void res_trk_pmem_free(struct ddl_buf_addr *addr) -{ - struct ddl_context *ddl_context; - - if (!addr) - return; - - ddl_context = ddl_get_context(); - if (ddl_context->video_ion_client) { - if (addr->alloc_handle) { - ion_free(ddl_context->video_ion_client, - addr->alloc_handle); - addr->alloc_handle = NULL; - } - } - memset(addr, 0 , sizeof(struct ddl_buf_addr)); -} -static int res_trk_pmem_alloc - (struct ddl_buf_addr *addr, size_t sz, u32 alignment) -{ - u32 alloc_size; - struct ddl_context *ddl_context; - unsigned long fw_addr; - int rc = 0; - DBG_PMEM("\n%s() IN: Requested alloc size(%u)", __func__, (u32)sz); - if (!addr) { - DDL_MSG_ERROR("\n%s() Invalid Parameters", __func__); - rc = -EINVAL; - goto bail_out; - } - ddl_context = ddl_get_context(); - res_trk_set_mem_type(addr->mem_type); - alloc_size = (sz + alignment); - if (res_trk_get_enable_ion()) { - if (!res_trk_is_cp_enabled() || - !res_trk_check_for_sec_session()) { - if (!ddl_context->video_ion_client) - ddl_context->video_ion_client = - res_trk_get_ion_client(); - if (!ddl_context->video_ion_client) { - DDL_MSG_ERROR( - "%s() :DDL ION Client Invalid handle\n", - __func__); - rc = -ENOMEM; - goto bail_out; - } - alloc_size = (alloc_size+4095) & ~4095; - addr->alloc_handle = ion_alloc( - ddl_context->video_ion_client, - alloc_size, SZ_4K, - res_trk_get_mem_type(), - res_trk_get_ion_flags()); - if (IS_ERR_OR_NULL(addr->alloc_handle)) { - DDL_MSG_ERROR("%s() :DDL ION alloc failed\n", - __func__); - rc = -ENOMEM; - goto bail_out; - } - } else { - fw_addr = resource_context.vidc_platform_data->fw_addr; - addr->alloc_handle = NULL; - addr->alloced_phys_addr = fw_addr; - addr->buffer_size = sz; - } - } else { - addr->alloced_phys_addr = (phys_addr_t) - allocate_contiguous_memory_nomap(alloc_size, - res_trk_get_mem_type(), SZ_4K); - if (!addr->alloced_phys_addr) { - DDL_MSG_ERROR("%s() : acm alloc failed (%d)\n", - __func__, alloc_size); - rc = -ENOMEM; - goto bail_out; - } - addr->buffer_size = sz; - return rc; - } -bail_out: - return rc; -} - -static void res_trk_pmem_unmap(struct ddl_buf_addr *addr) -{ - if (!addr) { - pr_err("%s() invalid args\n", __func__); - return; - } - if (!IS_ERR_OR_NULL(addr->alloc_handle)) { - if (addr->physical_base_addr) { - ion_unmap_kernel(resource_context.res_ion_client, - addr->alloc_handle); - if (!res_trk_check_for_sec_session()) { - ion_unmap_iommu(resource_context.res_ion_client, - addr->alloc_handle, - VIDEO_DOMAIN, - VIDEO_FIRMWARE_POOL); - } - addr->virtual_base_addr = NULL; - addr->physical_base_addr = NULL; - } - } - addr->mapped_buffer = NULL; -} - -static u32 res_trk_get_clk() -{ - if (resource_context.vcodec_clk || - resource_context.vcodec_pclk) { - VCDRES_MSG_ERROR("%s() Clock reference exists\n", - __func__); - goto bail_out; - } - resource_context.vcodec_clk = clk_get(resource_context.device, - "core_clk"); - if (IS_ERR(resource_context.vcodec_clk)) { - VCDRES_MSG_ERROR("%s(): core_clk get failed\n", - __func__); - goto bail_out; - } - resource_context.vcodec_pclk = clk_get(resource_context.device, - "iface_clk"); - if (IS_ERR(resource_context.vcodec_pclk)) { - VCDRES_MSG_ERROR("%s(): iface_clk get failed\n", - __func__); - goto release_vcodec_clk; - } - if (clk_set_rate(resource_context.vcodec_clk, - vidc_clk_table[0])) { - VCDRES_MSG_ERROR("%s(): set rate failed in power up\n", - __func__); - goto release_vcodec_pclk; - } - return true; -release_vcodec_pclk: - clk_put(resource_context.vcodec_pclk); - resource_context.vcodec_pclk = NULL; -release_vcodec_clk: - clk_put(resource_context.vcodec_clk); - resource_context.vcodec_clk = NULL; -bail_out: - return false; -} - -static void res_trk_put_clk() -{ - if (resource_context.vcodec_clk) - clk_put(resource_context.vcodec_clk); - if (resource_context.vcodec_pclk) - clk_put(resource_context.vcodec_pclk); - resource_context.vcodec_clk = NULL; - resource_context.vcodec_pclk = NULL; -} - -static u32 res_trk_shutdown_vidc(void) -{ - mutex_lock(&resource_context.lock); - if (resource_context.clock_enabled) { - mutex_unlock(&resource_context.lock); - VCDRES_MSG_LOW("\n Calling CLK disable in Power Down\n"); - res_trk_disable_clocks(); - mutex_lock(&resource_context.lock); - } - res_trk_put_clk(); - if (resource_context.footswitch) { - if (regulator_disable(resource_context.footswitch)) - VCDRES_MSG_ERROR("Regulator disable failed\n"); - regulator_put(resource_context.footswitch); - resource_context.footswitch = NULL; - } - if (pm_runtime_put(resource_context.device) < 0) - VCDRES_MSG_ERROR("Error : pm_runtime_put failed"); - mutex_unlock(&resource_context.lock); - return true; -} - -u32 res_trk_enable_clocks(void) -{ - VCDRES_MSG_LOW("\n in res_trk_enable_clocks()"); - mutex_lock(&resource_context.lock); - if (!resource_context.clock_enabled) { - VCDRES_MSG_LOW("Enabling IRQ in %s()\n", __func__); - enable_irq(resource_context.irq_num); - VCDRES_MSG_LOW("%s(): Enabling the clocks\n", __func__); - if (resource_context.vcodec_clk && - resource_context.vcodec_pclk) { - if (clk_prepare_enable(resource_context.vcodec_pclk)) { - VCDRES_MSG_ERROR("vidc pclk Enable fail\n"); - goto bail_out; - } - if (clk_prepare_enable(resource_context.vcodec_clk)) { - VCDRES_MSG_ERROR("vidc core clk Enable fail\n"); - goto vidc_disable_pclk; - } - - VCDRES_MSG_LOW("%s(): Clocks enabled!\n", __func__); - } else { - VCDRES_MSG_ERROR("%s(): Clocks enable failed!\n", - __func__); - goto bail_out; - } - } - resource_context.clock_enabled = 1; - mutex_unlock(&resource_context.lock); - return true; -vidc_disable_pclk: - clk_disable_unprepare(resource_context.vcodec_pclk); -bail_out: - mutex_unlock(&resource_context.lock); - return false; -} - -static u32 res_trk_sel_clk_rate(unsigned long hclk_rate) -{ - u32 status = true; - mutex_lock(&resource_context.lock); - if (clk_set_rate(resource_context.vcodec_clk, - hclk_rate)) { - VCDRES_MSG_ERROR("vidc hclk set rate failed\n"); - status = false; - } else - resource_context.vcodec_clk_rate = hclk_rate; - mutex_unlock(&resource_context.lock); - return status; -} - -u32 res_trk_get_clk_rate(unsigned long *phclk_rate) -{ - u32 status = true; - mutex_lock(&resource_context.lock); - if (phclk_rate) { - *phclk_rate = clk_get_rate(resource_context.vcodec_clk); - if (!(*phclk_rate)) { - VCDRES_MSG_ERROR("vidc hclk get rate failed\n"); - status = false; - } - } else - status = false; - mutex_unlock(&resource_context.lock); - return status; -} - -u32 res_trk_disable_clocks(void) -{ - u32 status = false; - VCDRES_MSG_LOW("in res_trk_disable_clocks()\n"); - mutex_lock(&resource_context.lock); - if (resource_context.clock_enabled) { - VCDRES_MSG_LOW("Disabling IRQ in %s()\n", __func__); - disable_irq_nosync(resource_context.irq_num); - VCDRES_MSG_LOW("%s(): Disabling the clocks ...\n", __func__); - resource_context.clock_enabled = 0; - if (resource_context.vcodec_clk) - clk_disable_unprepare(resource_context.vcodec_clk); - if (resource_context.vcodec_pclk) - clk_disable_unprepare(resource_context.vcodec_pclk); - status = true; - } - mutex_unlock(&resource_context.lock); - return status; -} - -static u32 res_trk_vidc_pwr_up(void) -{ - mutex_lock(&resource_context.lock); - - if (pm_runtime_get(resource_context.device) < 0) { - VCDRES_MSG_ERROR("Error : pm_runtime_get failed\n"); - goto bail_out; - } - if (!resource_context.footswitch) - resource_context.footswitch = - regulator_get(resource_context.device, "vdd"); - if (IS_ERR(resource_context.footswitch)) { - VCDRES_MSG_ERROR("foot switch get failed\n"); - resource_context.footswitch = NULL; - } else - regulator_enable(resource_context.footswitch); - if (!res_trk_get_clk()) - goto rel_vidc_pm_runtime; - mutex_unlock(&resource_context.lock); - return true; - -rel_vidc_pm_runtime: - if (pm_runtime_put(resource_context.device) < 0) - VCDRES_MSG_ERROR("Error : pm_runtime_put failed"); -bail_out: - mutex_unlock(&resource_context.lock); - return false; -} - -static struct ion_client *res_trk_create_ion_client(void){ - struct ion_client *video_client; - video_client = msm_ion_client_create(-1, "video_client"); - if (IS_ERR_OR_NULL(video_client)) { - VCDRES_MSG_ERROR("%s: Unable to create ION client\n", __func__); - video_client = NULL; - } - return video_client; -} - -int res_trk_enable_footswitch(void) -{ - int rc = 0; - mutex_lock(&resource_context.lock); - if (!resource_context.footswitch) - resource_context.footswitch = regulator_get(NULL, "fs_ved"); - if (IS_ERR(resource_context.footswitch)) { - VCDRES_MSG_ERROR("foot switch get failed\n"); - resource_context.footswitch = NULL; - rc = -EINVAL; - } else - rc = regulator_enable(resource_context.footswitch); - mutex_unlock(&resource_context.lock); - return rc; -} - -int res_trk_disable_footswitch(void) -{ - mutex_lock(&resource_context.lock); - if (resource_context.footswitch) { - if (regulator_disable(resource_context.footswitch)) - VCDRES_MSG_ERROR("Regulator disable failed\n"); - regulator_put(resource_context.footswitch); - resource_context.footswitch = NULL; - } - mutex_unlock(&resource_context.lock); - return 0; -} - -u32 res_trk_power_up(void) -{ - VCDRES_MSG_LOW("clk_regime_rail_enable"); - VCDRES_MSG_LOW("clk_regime_sel_rail_control"); -#ifdef CONFIG_MSM_BUS_SCALING - resource_context.pcl = 0; - if (resource_context.vidc_bus_client_pdata) { - resource_context.pcl = msm_bus_scale_register_client( - resource_context.vidc_bus_client_pdata); - VCDRES_MSG_LOW("%s(), resource_context.pcl = %x", __func__, - resource_context.pcl); - } - if (resource_context.pcl == 0) { - dev_err(resource_context.device, - "register bus client returned NULL\n"); - return false; - } -#endif - return res_trk_vidc_pwr_up(); -} - -u32 res_trk_power_down(void) -{ - VCDRES_MSG_LOW("clk_regime_rail_disable"); - res_trk_pmem_unmap(&resource_context.firmware_addr); - res_trk_pmem_free(&resource_context.firmware_addr); -#ifdef CONFIG_MSM_BUS_SCALING - msm_bus_scale_client_update_request(resource_context.pcl, 0); - msm_bus_scale_unregister_client(resource_context.pcl); -#endif - VCDRES_MSG_MED("res_trk_power_down():: Calling " - "res_trk_shutdown_vidc()\n"); - return res_trk_shutdown_vidc(); -} - -u32 res_trk_get_max_perf_level(u32 *pn_max_perf_lvl) -{ - if (!pn_max_perf_lvl) { - VCDRES_MSG_ERROR("%s(): pn_max_perf_lvl is NULL\n", - __func__); - return false; - } - *pn_max_perf_lvl = RESTRK_1080P_MAX_PERF_LEVEL; - return true; -} - -#ifdef CONFIG_MSM_BUS_SCALING -int res_trk_update_bus_perf_level(struct vcd_dev_ctxt *dev_ctxt, u32 perf_level) -{ - struct vcd_clnt_ctxt *cctxt_itr = NULL; - u32 enc_perf_level = 0, dec_perf_level = 0; - u32 bus_clk_index, client_type = 0; - int rc = 0; - bool turbo_supported = - !resource_context.vidc_platform_data->disable_turbo; - - cctxt_itr = dev_ctxt->cctxt_list_head; - while (cctxt_itr) { - if (cctxt_itr->decoding) - dec_perf_level += cctxt_itr->reqd_perf_lvl; - else - enc_perf_level += cctxt_itr->reqd_perf_lvl; - cctxt_itr = cctxt_itr->next; - } - - if (!enc_perf_level) - client_type = 1; - if (perf_level <= RESTRK_1080P_VGA_PERF_LEVEL) - bus_clk_index = 0; - else if (perf_level <= RESTRK_1080P_720P_PERF_LEVEL) - bus_clk_index = 1; - else if (perf_level <= RESTRK_1080P_MAX_PERF_LEVEL) - bus_clk_index = 2; - else - bus_clk_index = 3; - - if (dev_ctxt->reqd_perf_lvl + dev_ctxt->curr_perf_lvl == 0) - bus_clk_index = 2; - else if (!turbo_supported && bus_clk_index == 3) - bus_clk_index = 2; - bus_clk_index = (bus_clk_index << 1) + (client_type + 1); - VCDRES_MSG_LOW("%s(), bus_clk_index = %d", __func__, bus_clk_index); - VCDRES_MSG_LOW("%s(),context.pcl = %x", __func__, resource_context.pcl); - VCDRES_MSG_LOW("%s(), bus_perf_level = %x", __func__, perf_level); - rc = msm_bus_scale_client_update_request(resource_context.pcl, - bus_clk_index); - return rc; -} -#endif - -u32 res_trk_set_perf_level(u32 req_perf_lvl, u32 *pn_set_perf_lvl, - struct vcd_dev_ctxt *dev_ctxt) -{ - u32 vidc_freq = 0; - bool turbo_supported = - !resource_context.vidc_platform_data->disable_turbo; - - if (!pn_set_perf_lvl || !dev_ctxt) { - VCDRES_MSG_ERROR("%s(): NULL pointer! dev_ctxt(%p)\n", - __func__, dev_ctxt); - return false; - } - - VCDRES_MSG_LOW("%s(), req_perf_lvl = %d", __func__, req_perf_lvl); - - if (!turbo_supported && req_perf_lvl > RESTRK_1080P_MAX_PERF_LEVEL) { - VCDRES_MSG_ERROR("%s(): Turbo not supported! dev_ctxt(%p)\n", - __func__, dev_ctxt); - } - -#ifdef CONFIG_MSM_BUS_SCALING - if (!res_trk_update_bus_perf_level(dev_ctxt, req_perf_lvl) < 0) { - VCDRES_MSG_ERROR("%s(): update buf perf level failed\n", - __func__); - return false; - } - -#endif - if (dev_ctxt->reqd_perf_lvl + dev_ctxt->curr_perf_lvl == 0) - req_perf_lvl = RESTRK_1080P_MAX_PERF_LEVEL; - - if (req_perf_lvl <= RESTRK_1080P_VGA_PERF_LEVEL) { - vidc_freq = vidc_clk_table[0]; - *pn_set_perf_lvl = RESTRK_1080P_VGA_PERF_LEVEL; - } else if (req_perf_lvl <= RESTRK_1080P_720P_PERF_LEVEL) { - vidc_freq = vidc_clk_table[1]; - *pn_set_perf_lvl = RESTRK_1080P_720P_PERF_LEVEL; - } else if (req_perf_lvl <= RESTRK_1080P_MAX_PERF_LEVEL) { - vidc_freq = vidc_clk_table[2]; - *pn_set_perf_lvl = RESTRK_1080P_MAX_PERF_LEVEL; - } else { - vidc_freq = vidc_clk_table[4]; - *pn_set_perf_lvl = RESTRK_1080P_TURBO_PERF_LEVEL; - } - - if (!turbo_supported && - *pn_set_perf_lvl == RESTRK_1080P_TURBO_PERF_LEVEL) { - vidc_freq = vidc_clk_table[2]; - *pn_set_perf_lvl = RESTRK_1080P_MAX_PERF_LEVEL; - } - - resource_context.perf_level = *pn_set_perf_lvl; - VCDRES_MSG_MED("VIDC: vidc_freq = %u, req_perf_lvl = %u\n", - vidc_freq, req_perf_lvl); -#ifdef USE_RES_TRACKER - if (req_perf_lvl != RESTRK_1080P_MIN_PERF_LEVEL) { - VCDRES_MSG_MED("%s(): Setting vidc freq to %u\n", - __func__, vidc_freq); - if (!res_trk_sel_clk_rate(vidc_freq)) { - if (vidc_freq == vidc_clk_table[4]) { - if (res_trk_sel_clk_rate(vidc_clk_table[3])) - goto ret; - } - VCDRES_MSG_ERROR("%s(): res_trk_sel_clk_rate FAILED\n", - __func__); - *pn_set_perf_lvl = 0; - return false; - } - } -#endif -ret: VCDRES_MSG_MED("%s() set perl level : %d", __func__, *pn_set_perf_lvl); - return true; -} - -u32 res_trk_get_curr_perf_level(u32 *pn_perf_lvl) -{ - unsigned long freq; - - if (!pn_perf_lvl) { - VCDRES_MSG_ERROR("%s(): pn_perf_lvl is NULL\n", - __func__); - return false; - } - VCDRES_MSG_LOW("clk_regime_msm_get_clk_freq_hz"); - if (!res_trk_get_clk_rate(&freq)) { - VCDRES_MSG_ERROR("%s(): res_trk_get_clk_rate FAILED\n", - __func__); - *pn_perf_lvl = 0; - return false; - } - *pn_perf_lvl = resource_context.perf_level; - VCDRES_MSG_MED("%s(): freq = %lu, *pn_perf_lvl = %u", __func__, - freq, *pn_perf_lvl); - return true; -} - -u32 res_trk_download_firmware(void) -{ - const struct firmware *fw_video = NULL; - int rc = 0; - u32 status = true; - - VCDRES_MSG_HIGH("%s(): Request firmware download\n", - __func__); - mutex_lock(&resource_context.lock); - rc = request_firmware(&fw_video, VIDC_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_FW, rc); - status = false; - goto bail_out; - } - vidc_video_codec_fw = (unsigned char *)fw_video->data; - vidc_video_codec_fw_size = (u32) fw_video->size; -bail_out: - mutex_unlock(&resource_context.lock); - return status; -} - -void res_trk_init(struct device *device, u32 irq) -{ - if (resource_context.device || resource_context.irq_num || - !device) { - VCDRES_MSG_ERROR("%s() Resource Tracker Init error\n", - __func__); - } else { - memset(&resource_context, 0, sizeof(resource_context)); - mutex_init(&resource_context.lock); - mutex_init(&resource_context.secure_lock); - resource_context.device = device; - resource_context.irq_num = irq; - resource_context.vidc_platform_data = - (struct msm_vidc_platform_data *) device->platform_data; - if (resource_context.vidc_platform_data) { - resource_context.memtype = - resource_context.vidc_platform_data->memtype; - resource_context.fw_mem_type = - resource_context.vidc_platform_data->memtype; - resource_context.cmd_mem_type = - resource_context.vidc_platform_data->memtype; - if (resource_context.vidc_platform_data->enable_ion) { - resource_context.res_ion_client = - res_trk_create_ion_client(); - if (!(resource_context.res_ion_client)) { - VCDRES_MSG_ERROR("%s()ION createfail\n", - __func__); - return; - } - resource_context.fw_mem_type = - ION_MM_FIRMWARE_HEAP_ID; - resource_context.cmd_mem_type = - ION_CP_MFC_HEAP_ID; - } - resource_context.disable_dmx = - resource_context.vidc_platform_data->disable_dmx; - resource_context.disable_fullhd = - resource_context.vidc_platform_data->disable_fullhd; -#ifdef CONFIG_MSM_BUS_SCALING - resource_context.vidc_bus_client_pdata = - resource_context.vidc_platform_data-> - vidc_bus_client_pdata; -#endif - } else { - resource_context.memtype = -1; - resource_context.disable_dmx = 0; - } - resource_context.core_type = VCD_CORE_1080P; - resource_context.firmware_addr.mem_type = DDL_FW_MEM; - } -} - -u32 res_trk_get_core_type(void){ - return resource_context.core_type; -} - -u32 res_trk_get_firmware_addr(struct ddl_buf_addr *firm_addr) -{ - int rc = 0; - size_t size = 0; - if (!firm_addr || resource_context.firmware_addr.mapped_buffer) { - pr_err("%s() invalid params", __func__); - return -EINVAL; - } - if (res_trk_is_cp_enabled() && res_trk_check_for_sec_session()) - size = PIL_FW_SIZE; - else - size = VIDC_FW_SIZE; - - if (res_trk_pmem_alloc(&resource_context.firmware_addr, - size, DDL_KILO_BYTE(128))) { - pr_err("%s() Firmware buffer allocation failed", - __func__); - memset(&resource_context.firmware_addr, 0, - sizeof(resource_context.firmware_addr)); - rc = -ENOMEM; - goto fail_alloc; - } - if (!res_trk_pmem_map(&resource_context.firmware_addr, - resource_context.firmware_addr.buffer_size, - DDL_KILO_BYTE(128))) { - pr_err("%s() Firmware buffer mapping failed", - __func__); - rc = -ENOMEM; - goto fail_map; - } - memcpy(firm_addr, &resource_context.firmware_addr, - sizeof(struct ddl_buf_addr)); - return 0; -fail_map: - res_trk_pmem_free(&resource_context.firmware_addr); -fail_alloc: - return rc; -} - -void res_trk_release_fw_addr(void) -{ - res_trk_pmem_unmap(&resource_context.firmware_addr); - res_trk_pmem_free(&resource_context.firmware_addr); -} - -int res_trk_check_for_sec_session(void) -{ - int rc; - mutex_lock(&resource_context.secure_lock); - rc = resource_context.secure_session; - mutex_unlock(&resource_context.secure_lock); - return rc; -} - -int res_trk_get_mem_type(void) -{ - int mem_type = -1; - switch (resource_context.res_mem_type) { - case DDL_FW_MEM: - mem_type = ION_HEAP(resource_context.fw_mem_type); - return mem_type; - case DDL_MM_MEM: - mem_type = resource_context.memtype; - break; - case DDL_CMD_MEM: - if (res_trk_check_for_sec_session()) - mem_type = resource_context.cmd_mem_type; - else - mem_type = resource_context.memtype; - break; - default: - return mem_type; - } - if (resource_context.vidc_platform_data->enable_ion) { - if (res_trk_check_for_sec_session()) { - mem_type = ION_HEAP(mem_type); - } else - mem_type = (ION_HEAP(mem_type) | - ION_HEAP(ION_IOMMU_HEAP_ID)); - } - - return mem_type; -} - -unsigned int res_trk_get_ion_flags(void) -{ - unsigned int flags = 0; - if (resource_context.res_mem_type == DDL_FW_MEM) - return flags; - - if (resource_context.vidc_platform_data->enable_ion) { - if (res_trk_check_for_sec_session()) { - if (resource_context.res_mem_type != DDL_FW_MEM) - flags |= ION_FLAG_SECURE; - else if (res_trk_is_cp_enabled()) - flags |= ION_FLAG_SECURE; - } - } - return flags; -} - -u32 res_trk_is_cp_enabled(void) -{ - if (resource_context.vidc_platform_data->cp_enabled) - return 1; - else - return 0; -} - -u32 res_trk_get_enable_ion(void) -{ - if (resource_context.vidc_platform_data->enable_ion) - return 1; - else - return 0; -} - -struct ion_client *res_trk_get_ion_client(void) -{ - return resource_context.res_ion_client; -} - -u32 res_trk_get_disable_dmx(void){ - return resource_context.disable_dmx; -} - -u32 res_trk_get_min_dpb_count(void){ - return resource_context.vidc_platform_data->cont_mode_dpb_count; -} - -void res_trk_set_mem_type(enum ddl_mem_area mem_type) -{ - resource_context.res_mem_type = mem_type; - return; -} - -u32 res_trk_get_disable_fullhd(void) -{ - return resource_context.disable_fullhd; -} - -int res_trk_enable_iommu_clocks(void) -{ - int ret = 0, i; - if (resource_context.mmu_clks_on) { - pr_err(" %s: Clocks are already on", __func__); - return -EINVAL; - } - resource_context.mmu_clks_on = 1; - for (i = 0; i < ARRAY_SIZE(vidc_mmu_clks); i++) { - vidc_mmu_clks[i].mmu_clk = clk_get(resource_context.device, - vidc_mmu_clks[i].mmu_clk_name); - if (IS_ERR(vidc_mmu_clks[i].mmu_clk)) { - pr_err(" %s: Get failed for clk %s", __func__, - vidc_mmu_clks[i].mmu_clk_name); - ret = PTR_ERR(vidc_mmu_clks[i].mmu_clk); - } - if (!ret) { - ret = clk_prepare_enable(vidc_mmu_clks[i].mmu_clk); - if (ret) { - clk_put(vidc_mmu_clks[i].mmu_clk); - vidc_mmu_clks[i].mmu_clk = NULL; - } - } - if (ret) { - for (i--; i >= 0; i--) { - clk_disable_unprepare(vidc_mmu_clks[i].mmu_clk); - clk_put(vidc_mmu_clks[i].mmu_clk); - vidc_mmu_clks[i].mmu_clk = NULL; - } - resource_context.mmu_clks_on = 0; - pr_err("%s() clocks enable failed", __func__); - break; - } - } - return ret; -} - -int res_trk_disable_iommu_clocks(void) -{ - int i; - if (!resource_context.mmu_clks_on) { - pr_err(" %s: clks are already off", __func__); - return -EINVAL; - } - resource_context.mmu_clks_on = 0; - for (i = 0; i < ARRAY_SIZE(vidc_mmu_clks); i++) { - clk_disable_unprepare(vidc_mmu_clks[i].mmu_clk); - clk_put(vidc_mmu_clks[i].mmu_clk); - vidc_mmu_clks[i].mmu_clk = NULL; - } - return 0; -} - -void res_trk_secure_unset(void) -{ - mutex_lock(&resource_context.secure_lock); - resource_context.secure_session--; - mutex_unlock(&resource_context.secure_lock); -} - -void res_trk_secure_set(void) -{ - mutex_lock(&resource_context.secure_lock); - resource_context.secure_session++; - mutex_unlock(&resource_context.secure_lock); -} - -int res_trk_open_secure_session() -{ - int rc, memtype; - if (!res_trk_check_for_sec_session()) { - pr_err("Secure sessions are not active\n"); - return -EINVAL; - } - mutex_lock(&resource_context.secure_lock); - if (!resource_context.sec_clk_heap) { - pr_err("Securing...\n"); - rc = res_trk_enable_iommu_clocks(); - if (rc) { - pr_err("IOMMU clock enabled failed while open"); - goto error_open; - } - memtype = ION_HEAP(resource_context.memtype); - rc = msm_ion_secure_heap(memtype); - if (rc) { - pr_err("ION heap secure failed heap id %d rc %d\n", - resource_context.memtype, rc); - goto disable_iommu_clks; - } - memtype = ION_HEAP(resource_context.cmd_mem_type); - rc = msm_ion_secure_heap(memtype); - if (rc) { - pr_err("ION heap secure failed heap id %d rc %d\n", - resource_context.cmd_mem_type, rc); - goto unsecure_memtype_heap; - } - if (resource_context.vidc_platform_data->secure_wb_heap) { - memtype = ION_HEAP(ION_CP_WB_HEAP_ID); - rc = msm_ion_secure_heap(memtype); - if (rc) { - pr_err("WB_HEAP_ID secure failed rc %d\n", rc); - goto unsecure_cmd_heap; - } - } - resource_context.sec_clk_heap = 1; - res_trk_disable_iommu_clocks(); - } - mutex_unlock(&resource_context.secure_lock); - return 0; -unsecure_cmd_heap: - msm_ion_unsecure_heap(ION_HEAP(resource_context.memtype)); -unsecure_memtype_heap: - msm_ion_unsecure_heap(ION_HEAP(resource_context.cmd_mem_type)); -disable_iommu_clks: - res_trk_disable_iommu_clocks(); -error_open: - resource_context.sec_clk_heap = 0; - mutex_unlock(&resource_context.secure_lock); - return rc; -} - -int res_trk_close_secure_session() -{ - int rc; - if (res_trk_check_for_sec_session() == 1 && - resource_context.sec_clk_heap) { - pr_err("Unsecuring....\n"); - mutex_lock(&resource_context.secure_lock); - rc = res_trk_enable_iommu_clocks(); - if (rc) { - pr_err("IOMMU clock enabled failed while close\n"); - goto error_close; - } - msm_ion_unsecure_heap(ION_HEAP(resource_context.cmd_mem_type)); - msm_ion_unsecure_heap(ION_HEAP(resource_context.memtype)); - - if (resource_context.vidc_platform_data->secure_wb_heap) - msm_ion_unsecure_heap(ION_HEAP(ION_CP_WB_HEAP_ID)); - - res_trk_disable_iommu_clocks(); - resource_context.sec_clk_heap = 0; - mutex_unlock(&resource_context.secure_lock); - } - return 0; -error_close: - mutex_unlock(&resource_context.secure_lock); - return rc; -} - -u32 get_res_trk_perf_level(enum vcd_perf_level perf_level) -{ - u32 res_trk_perf_level; - switch (perf_level) { - case VCD_PERF_LEVEL0: - res_trk_perf_level = RESTRK_1080P_VGA_PERF_LEVEL; - break; - case VCD_PERF_LEVEL1: - res_trk_perf_level = RESTRK_1080P_720P_PERF_LEVEL; - break; - case VCD_PERF_LEVEL2: - res_trk_perf_level = RESTRK_1080P_MAX_PERF_LEVEL; - break; - case VCD_PERF_LEVEL_TURBO: - res_trk_perf_level = RESTRK_1080P_TURBO_PERF_LEVEL; - break; - default: - VCD_MSG_ERROR("Invalid perf level: %d\n", perf_level); - res_trk_perf_level = -EINVAL; - } - return res_trk_perf_level; -} - -u32 res_trk_estimate_perf_level(u32 pn_perf_lvl) -{ - VCDRES_MSG_MED("%s(), req_perf_lvl = %d", __func__, pn_perf_lvl); - if ((pn_perf_lvl >= RESTRK_1080P_VGA_PERF_LEVEL) && - (pn_perf_lvl < RESTRK_1080P_720P_PERF_LEVEL)) { - return RESTRK_1080P_720P_PERF_LEVEL; - } else if ((pn_perf_lvl >= RESTRK_1080P_720P_PERF_LEVEL) && - (pn_perf_lvl < RESTRK_1080P_MAX_PERF_LEVEL)) { - return RESTRK_1080P_MAX_PERF_LEVEL; - } else { - return pn_perf_lvl; - } -} diff --git a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.h b/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.h deleted file mode 100644 index 6cb9fe7160bb665b62c16340d71dd14a84151909..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VIDEO_720P_RESOURCE_TRACKER_H_ -#define _VIDEO_720P_RESOURCE_TRACKER_H_ - -#include -#include -#include "vcd_res_tracker_api.h" -#ifdef CONFIG_MSM_BUS_SCALING -#include -#include -#endif -#include - -#define RESTRK_1080P_VGA_PERF_LEVEL VCD_MIN_PERF_LEVEL -#define RESTRK_1080P_720P_PERF_LEVEL 108000 -#define RESTRK_1080P_1080P_PERF_LEVEL 244800 - -#define RESTRK_1080P_MIN_PERF_LEVEL RESTRK_1080P_VGA_PERF_LEVEL -#define RESTRK_1080P_MAX_PERF_LEVEL RESTRK_1080P_1080P_PERF_LEVEL -#define RESTRK_1080P_TURBO_PERF_LEVEL (RESTRK_1080P_MAX_PERF_LEVEL + 1) - -struct res_trk_context { - struct device *device; - u32 irq_num; - struct mutex lock; - struct clk *vcodec_clk; - struct clk *vcodec_pclk; - unsigned long vcodec_clk_rate; - unsigned int clock_enabled; - unsigned int perf_level; - struct regulator *footswitch; - struct msm_vidc_platform_data *vidc_platform_data; - int memtype; - int fw_mem_type; - int cmd_mem_type; -#ifdef CONFIG_MSM_BUS_SCALING - struct msm_bus_scale_pdata *vidc_bus_client_pdata; - uint32_t pcl; -#endif - u32 core_type; - struct ddl_buf_addr firmware_addr; - struct ion_client *res_ion_client; - u32 disable_dmx; - u32 disable_fullhd; - enum ddl_mem_area res_mem_type; - u32 mmu_clks_on; - u32 secure_session; - struct mutex secure_lock; - u32 sec_clk_heap; -}; - -#if DEBUG - -#define VCDRES_MSG_LOW(xx_fmt...) printk(KERN_INFO "\n\t* " xx_fmt) -#define VCDRES_MSG_MED(xx_fmt...) printk(KERN_INFO "\n * " xx_fmt) - -#else - -#define VCDRES_MSG_LOW(xx_fmt...) -#define VCDRES_MSG_MED(xx_fmt...) - -#endif - -#define VCDRES_MSG_HIGH(xx_fmt...) printk(KERN_WARNING "\n" xx_fmt) -#define VCDRES_MSG_ERROR(xx_fmt...) printk(KERN_ERR "\n err: " xx_fmt) -#define VCDRES_MSG_FATAL(xx_fmt...) printk(KERN_ERR "\n " xx_fmt) - -#ifdef CONFIG_MSM_BUS_SCALING -int res_trk_update_bus_perf_level(struct vcd_dev_ctxt *dev_ctxt, - u32 perf_level); -#endif -#endif diff --git a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h b/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h deleted file mode 100644 index 2c47921ca7da12a159ea42021fcb5b88ad00bb8c..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker_api.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VIDEO_720P_RESOURCE_TRACKER_API_H_ -#define _VIDEO_720P_RESOURCE_TRACKER_API_H_ - -#include "vcd_core.h" -#include "vcd_ddl.h" -#include "vcd_ddl_utils.h" - -void res_trk_init(struct device *device, u32 irq); -u32 res_trk_power_up(void); -u32 res_trk_power_down(void); -u32 res_trk_enable_clocks(void); -u32 res_trk_disable_clocks(void); -u32 res_trk_get_max_perf_level(u32 *pn_max_perf_lvl); -u32 res_trk_set_perf_level(u32 req_perf_lvl, u32 *pn_set_perf_lvl, - struct vcd_dev_ctxt *dev_ctxt); -u32 res_trk_get_curr_perf_level(u32 *pn_perf_lvl); -u32 res_trk_download_firmware(void); -u32 res_trk_get_core_type(void); -u32 res_trk_get_firmware_addr(struct ddl_buf_addr *firm_addr); -int res_trk_get_mem_type(void); -unsigned int res_trk_get_ion_flags(void); -u32 res_trk_get_enable_ion(void); -u32 res_trk_is_cp_enabled(void); -u32 res_trk_get_disable_fullhd(void); -struct ion_client *res_trk_get_ion_client(void); -u32 res_trk_get_disable_dmx(void); -u32 res_trk_get_min_dpb_count(void); -void res_trk_set_mem_type(enum ddl_mem_area mem_type); -int res_trk_enable_iommu_clocks(void); -int res_trk_disable_iommu_clocks(void); -int res_trk_check_for_sec_session(void); -int res_trk_open_secure_session(void); -int res_trk_close_secure_session(void); -void res_trk_secure_set(void); -void res_trk_secure_unset(void); -u32 get_res_trk_perf_level(enum vcd_perf_level); -int res_trk_enable_footswitch(void); -int res_trk_disable_footswitch(void); -void res_trk_release_fw_addr(void); -u32 res_trk_estimate_perf_level(u32 pn_perf_lvl); -u32 res_trk_get_clk_rate(unsigned long *phclk_rate); -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl.c deleted file mode 100644 index 9b27abd44fbf410740fd3d9f4beee80deda670fb..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl.c +++ /dev/null @@ -1,637 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vcd_ddl_utils.h" -#include "vcd_ddl_metadata.h" -#include "vcd_res_tracker_api.h" - -u32 ddl_device_init(struct ddl_init_config *ddl_init_config, - void *client_data) -{ - struct ddl_context *ddl_context; - u32 status = VCD_S_SUCCESS; - - if ((!ddl_init_config) || - (!ddl_init_config->ddl_callback) || - (!ddl_init_config->core_virtual_base_addr) - ) { - VIDC_LOGERR_STRING("ddl_dev_init:Bad_argument"); - return VCD_ERR_ILLEGAL_PARM; - } - - ddl_context = ddl_get_context(); - - if (DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dev_init:Multiple_init"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dev_init:Ddl_busy"); - return VCD_ERR_BUSY; - } - - DDL_MEMSET(ddl_context, 0, sizeof(struct ddl_context)); - DDL_BUSY(ddl_context); - - if (res_trk_get_enable_ion()) { - VIDC_LOGERR_STRING("ddl_dev_init: ION framework enabled"); - ddl_context->video_ion_client = - res_trk_get_ion_client(); - if (!ddl_context->video_ion_client) { - VIDC_LOGERR_STRING("ION client create failed"); - return VCD_ERR_ILLEGAL_OP; - } - } - ddl_context->memtype = res_trk_get_mem_type(); - if (ddl_context->memtype == -1) { - VIDC_LOGERR_STRING("ddl_dev_init:Invalid Memtype"); - return VCD_ERR_ILLEGAL_PARM; - } - ddl_context->ddl_callback = ddl_init_config->ddl_callback; - ddl_context->interrupt_clr = ddl_init_config->interrupt_clr; - ddl_context->core_virtual_base_addr = - ddl_init_config->core_virtual_base_addr; - ddl_context->client_data = client_data; - - vidc_720p_set_device_virtual_base(ddl_context-> - core_virtual_base_addr); - - ddl_context->current_ddl = NULL; - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - - ddl_client_transact(DDL_INIT_CLIENTS, NULL); - - ddl_pmem_alloc(&ddl_context->context_buf_addr, - DDL_CONTEXT_MEMORY, DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!ddl_context->context_buf_addr.virtual_base_addr) { - VIDC_LOGERR_STRING("ddl_dev_init:Context_alloc_fail"); - status = VCD_ERR_ALLOC_FAIL; - } - if (!status) { - ddl_pmem_alloc(&ddl_context->db_line_buffer, - DDL_DB_LINE_BUF_SIZE, - DDL_TILE_BUFFER_ALIGN_BYTES); - if (!ddl_context->db_line_buffer.virtual_base_addr) { - VIDC_LOGERR_STRING("ddl_dev_init:Line_buf_alloc_fail"); - status = VCD_ERR_ALLOC_FAIL; - } - } - - if (!status) { - ddl_pmem_alloc(&ddl_context->data_partition_tempbuf, - DDL_MPEG4_DATA_PARTITION_BUF_SIZE, - DDL_TILE_BUFFER_ALIGN_BYTES); - if (ddl_context->data_partition_tempbuf.virtual_base_addr \ - == NULL) { - VIDC_LOGERR_STRING - ("ddl_dev_init:Data_partition_buf_alloc_fail"); - status = VCD_ERR_ALLOC_FAIL; - } - } - - if (!status) { - - ddl_pmem_alloc(&ddl_context->metadata_shared_input, - DDL_METADATA_TOTAL_INPUTBUFSIZE, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!ddl_context->metadata_shared_input.virtual_base_addr) { - VIDC_LOGERR_STRING - ("ddl_dev_init:metadata_shared_input_alloc_fail"); - status = VCD_ERR_ALLOC_FAIL; - } - } - - if (!status) { - ddl_pmem_alloc(&ddl_context->dbg_core_dump, \ - DDL_DBG_CORE_DUMP_SIZE, \ - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!ddl_context->dbg_core_dump.virtual_base_addr) { - VIDC_LOGERR_STRING - ("ddl_dev_init:dbg_core_dump_alloc_failed"); - status = VCD_ERR_ALLOC_FAIL; - } - ddl_context->enable_dbg_core_dump = 0; - } - - if (!status && !vcd_fw_init()) { - VIDC_LOGERR_STRING("ddl_dev_init:fw_init_failed"); - status = VCD_ERR_ALLOC_FAIL; - } - if (status) { - ddl_release_context_buffers(ddl_context); - DDL_IDLE(ddl_context); - return status; - } - - ddl_move_command_state(ddl_context, DDL_CMD_DMA_INIT); - - ddl_core_init(ddl_context); - - return status; -} - -u32 ddl_device_release(void *client_data) -{ - struct ddl_context *ddl_context; - - ddl_context = ddl_get_context(); - - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dev_rel:Ddl_busy"); - return VCD_ERR_BUSY; - } - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dev_rel:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - - if (!ddl_client_transact(DDL_ACTIVE_CLIENT, NULL)) { - VIDC_LOGERR_STRING("ddl_dev_rel:Client_present_err"); - return VCD_ERR_CLIENT_PRESENT; - } - DDL_BUSY(ddl_context); - - ddl_context->device_state = DDL_DEVICE_NOTINIT; - ddl_context->client_data = client_data; - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - vidc_720p_stop_fw(); - - VIDC_LOG_STRING("FW_ENDDONE"); - ddl_release_context_buffers(ddl_context); - ddl_context->video_ion_client = NULL; - DDL_IDLE(ddl_context); - - return VCD_S_SUCCESS; -} - -u32 ddl_open(u32 **ddl_handle, u32 decoding) -{ - struct ddl_context *ddl_context; - struct ddl_client_context *ddl; - u32 status; - - if (!ddl_handle) { - VIDC_LOGERR_STRING("ddl_open:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - - ddl_context = ddl_get_context(); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_open:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - - status = ddl_client_transact(DDL_GET_CLIENT, &ddl); - - if (status) { - VIDC_LOGERR_STRING("ddl_open:Client_trasac_failed"); - return status; - } - - ddl_move_client_state(ddl, DDL_CLIENT_OPEN); - - ddl->codec_data.hdr.decoding = decoding; - ddl->decoding = decoding; - - ddl_set_default_meta_data_hdr(ddl); - - ddl_set_initial_default_values(ddl); - - *ddl_handle = (u32 *) ddl; - return VCD_S_SUCCESS; -} - -u32 ddl_close(u32 **ddl_handle) -{ - struct ddl_context *ddl_context; - struct ddl_client_context **ddl = - (struct ddl_client_context **)ddl_handle; - - if (!ddl || !*ddl) { - VIDC_LOGERR_STRING("ddl_close:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - - ddl_context = ddl_get_context(); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_close:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - - if (!DDLCLIENT_STATE_IS(*ddl, DDL_CLIENT_OPEN)) { - VIDC_LOGERR_STRING("ddl_close:Not_in_open_state"); - return VCD_ERR_ILLEGAL_OP; - } - - ddl_move_client_state(*ddl, DDL_CLIENT_INVALID); - if ((*ddl)->decoding) { - vcd_fw_transact(false, true, - (*ddl)->codec_data.decoder.codec.codec); - } else { - vcd_fw_transact(false, false, - (*ddl)->codec_data.encoder.codec.codec); - } - ddl_client_transact(DDL_FREE_CLIENT, ddl); - - return VCD_S_SUCCESS; -} - -u32 ddl_encode_start(u32 *ddl_handle, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - struct ddl_context *ddl_context; - struct ddl_encoder_data *encoder; - u32 dpb_size; - - ddl_context = ddl_get_context(); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_enc_start:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_enc_start:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || ddl->decoding) { - VIDC_LOGERR_STRING("ddl_enc_start:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - VIDC_LOGERR_STRING("ddl_enc_start:Not_opened"); - return VCD_ERR_ILLEGAL_OP; - } - - if (!ddl_encoder_ready_to_start(ddl)) { - VIDC_LOGERR_STRING("ddl_enc_start:Err_param_settings"); - return VCD_ERR_ILLEGAL_OP; - } - - encoder = &ddl->codec_data.encoder; - - dpb_size = ddl_get_yuv_buffer_size(&encoder->frame_size, - &encoder->re_con_buf_format, false, - encoder->codec.codec); - - dpb_size *= DDL_ENC_NUM_DPB_BUFFERS; - ddl_pmem_alloc(&encoder->enc_dpb_addr, - dpb_size, DDL_TILE_BUFFER_ALIGN_BYTES); - if (!encoder->enc_dpb_addr.virtual_base_addr) { - VIDC_LOGERR_STRING("ddl_enc_start:Dpb_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - - if ((encoder->codec.codec == VCD_CODEC_MPEG4 && - !encoder->short_header.short_header) || - encoder->codec.codec == VCD_CODEC_H264) { - ddl_pmem_alloc(&encoder->seq_header, - DDL_ENC_SEQHEADER_SIZE, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!encoder->seq_header.virtual_base_addr) { - ddl_pmem_free(&encoder->enc_dpb_addr); - VIDC_LOGERR_STRING - ("ddl_enc_start:Seq_hdr_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - } else { - encoder->seq_header.buffer_size = 0; - encoder->seq_header.virtual_base_addr = 0; - } - - DDL_BUSY(ddl_context); - - ddl_context->current_ddl = ddl; - ddl_context->client_data = client_data; - ddl_channel_set(ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_decode_start(u32 *ddl_handle, - struct vcd_sequence_hdr *header, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - struct ddl_context *ddl_context; - struct ddl_decoder_data *decoder; - - ddl_context = ddl_get_context(); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dec_start:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dec_start:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || !ddl->decoding) { - VIDC_LOGERR_STRING("ddl_dec_start:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - VIDC_LOGERR_STRING("ddl_dec_start:Not_in_opened_state"); - return VCD_ERR_ILLEGAL_OP; - } - - if ((header) && - ((!header->sequence_header_len) || - (!header->sequence_header) - ) - ) { - VIDC_LOGERR_STRING("ddl_dec_start:Bad_param_seq_header"); - return VCD_ERR_ILLEGAL_PARM; - } - - if (!ddl_decoder_ready_to_start(ddl, header)) { - VIDC_LOGERR_STRING("ddl_dec_start:Err_param_settings"); - return VCD_ERR_ILLEGAL_OP; - } - - DDL_BUSY(ddl_context); - - decoder = &ddl->codec_data.decoder; - if (header) { - decoder->header_in_start = true; - decoder->decode_config = *header; - } else { - decoder->header_in_start = false; - decoder->decode_config.sequence_header_len = 0; - } - - if (decoder->codec.codec == VCD_CODEC_H264) { - ddl_pmem_alloc(&decoder->h264Vsp_temp_buffer, - DDL_DECODE_H264_VSPTEMP_BUFSIZE, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!decoder->h264Vsp_temp_buffer.virtual_base_addr) { - DDL_IDLE(ddl_context); - VIDC_LOGERR_STRING - ("ddl_dec_start:H264Sps_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - } - - ddl_context->current_ddl = ddl; - ddl_context->client_data = client_data; - - ddl_channel_set(ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_decode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_bits, void *client_data) -{ - u32 vcd_status = VCD_S_SUCCESS; - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - struct ddl_context *ddl_context = ddl_get_context(); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dec_frame:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dec_frame:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || !ddl->decoding) { - VIDC_LOGERR_STRING("ddl_dec_frame:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!input_bits || - ((!input_bits->vcd_frm.physical || - !input_bits->vcd_frm.data_len) && - (!(VCD_FRAME_FLAG_EOS & input_bits->vcd_frm.flags)) - ) - ) { - VIDC_LOGERR_STRING("ddl_dec_frame:Bad_input_param"); - return VCD_ERR_ILLEGAL_PARM; - } - - DDL_BUSY(ddl_context); - - ddl_context->current_ddl = ddl; - ddl_context->client_data = client_data; - - ddl->input_frame = *input_bits; - - if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { - ddl_decode_frame_run(ddl); - } else { - if (!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) { - VIDC_LOGERR_STRING("ddl_dec_frame:Dpbs_requied"); - vcd_status = VCD_ERR_ILLEGAL_OP; - } else if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { - vcd_status = ddl_decode_set_buffers(ddl); - } else - if (DDLCLIENT_STATE_IS - (ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) { - ddl->codec_data.decoder.decode_config. - sequence_header = - ddl->input_frame.vcd_frm.physical; - ddl->codec_data.decoder.decode_config. - sequence_header_len = - ddl->input_frame.vcd_frm.data_len; - ddl_decode_init_codec(ddl); - } else { - VIDC_LOGERR_STRING("Dec_frame:Wrong_state"); - vcd_status = VCD_ERR_ILLEGAL_OP; - } - if (vcd_status) - DDL_IDLE(ddl_context); - } - return vcd_status; -} - -u32 ddl_encode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_frame, - struct ddl_frame_data_tag *output_bit, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - struct ddl_context *ddl_context = ddl_get_context(); - - if (vidc_msg_timing) - ddl_set_core_start_time(__func__, ENC_OP_TIME); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_enc_frame:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_enc_frame:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || ddl->decoding) { - VIDC_LOGERR_STRING("ddl_enc_frame:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!input_frame || - !input_frame->vcd_frm.physical || - !input_frame->vcd_frm.data_len) { - VIDC_LOGERR_STRING("ddl_enc_frame:Bad_input_params"); - return VCD_ERR_ILLEGAL_PARM; - } - if ((((u32) input_frame->vcd_frm.physical + - input_frame->vcd_frm.offset) & - (DDL_STREAMBUF_ALIGN_GUARD_BYTES) - ) - ) { - VIDC_LOGERR_STRING - ("ddl_enc_frame:Un_aligned_yuv_start_address"); - return VCD_ERR_ILLEGAL_PARM; - } - if (!output_bit || - !output_bit->vcd_frm.physical || - !output_bit->vcd_frm.alloc_len) { - VIDC_LOGERR_STRING("ddl_enc_frame:Bad_output_params"); - return VCD_ERR_ILLEGAL_PARM; - } - if ((ddl->codec_data.encoder.output_buf_req.sz + - output_bit->vcd_frm.offset) > - output_bit->vcd_frm.alloc_len) { - VIDC_LOGERR_STRING - ("ddl_enc_frame:offset_large, Exceeds_min_buf_size"); - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) { - VIDC_LOGERR_STRING("ddl_enc_frame:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - - DDL_BUSY(ddl_context); - - ddl_context->current_ddl = ddl; - ddl_context->client_data = client_data; - - ddl->input_frame = *input_frame; - ddl->output_frame = *output_bit; - - ddl_encode_frame_run(ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_decode_end(u32 *ddl_handle, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - struct ddl_context *ddl_context; - - ddl_context = ddl_get_context(); - - if (vidc_msg_timing) { - ddl_reset_core_time_variables(DEC_OP_TIME); - ddl_reset_core_time_variables(DEC_IP_TIME); - } - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dec_end:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_dec_end:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || !ddl->decoding) { - VIDC_LOGERR_STRING("ddl_dec_end:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_FATAL_ERROR) - ) { - VIDC_LOGERR_STRING("ddl_dec_end:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - DDL_BUSY(ddl_context); - - ddl_context->current_ddl = ddl; - ddl_context->client_data = client_data; - - ddl_channel_end(ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_encode_end(u32 *ddl_handle, void *client_data) -{ - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - struct ddl_context *ddl_context; - - ddl_context = ddl_get_context(); - - if (vidc_msg_timing) - ddl_reset_core_time_variables(ENC_OP_TIME); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_enc_end:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - if (DDL_IS_BUSY(ddl_context)) { - VIDC_LOGERR_STRING("ddl_enc_end:Ddl_busy"); - return VCD_ERR_BUSY; - } - if (!ddl || ddl->decoding) { - VIDC_LOGERR_STRING("ddl_enc_end:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) && - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_FATAL_ERROR)) { - VIDC_LOGERR_STRING("ddl_enc_end:Wrong_state"); - return VCD_ERR_ILLEGAL_OP; - } - DDL_BUSY(ddl_context); - - ddl_context->current_ddl = ddl; - ddl_context->client_data = client_data; - - ddl_channel_end(ddl); - return VCD_S_SUCCESS; -} - -u32 ddl_reset_hw(u32 mode) -{ - struct ddl_context *ddl_context; - struct ddl_client_context *ddl; - int i_client_num; - - VIDC_LOG_STRING("ddl_reset_hw:called"); - ddl_context = ddl_get_context(); - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - DDL_BUSY(ddl_context); - - if (ddl_context->core_virtual_base_addr) - vidc_720p_do_sw_reset(); - - ddl_context->device_state = DDL_DEVICE_NOTINIT; - for (i_client_num = 0; i_client_num < VCD_MAX_NO_CLIENT; - ++i_client_num) { - ddl = ddl_context->ddl_clients[i_client_num]; - ddl_context->ddl_clients[i_client_num] = NULL; - if (ddl) { - ddl_release_client_internal_buffers(ddl); - ddl_client_transact(DDL_FREE_CLIENT, &ddl); - } - } - - ddl_release_context_buffers(ddl_context); - DDL_MEMSET(ddl_context, 0, sizeof(struct ddl_context)); - - return true; -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl.h b/drivers/video/msm/vidc/720p/ddl/vcd_ddl.h deleted file mode 100644 index 383a91bd3cfa4ca9008f9e7a16b841d1d8fa7c6f..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl.h +++ /dev/null @@ -1,293 +0,0 @@ -/* Copyright (c) 2010-2012 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 _VCD_DDL_H_ -#define _VCD_DDL_H_ -#include "vcd_ddl_api.h" -#include "vcd_ddl_utils.h" -#include "vcd_ddl_firmware.h" -#include "vidc.h" - -#undef DDL_INLINE -#define DDL_INLINE - -#define DDL_BUSY_STATE 1 -#define DDL_IDLE_STATE 0 -#define DDL_ERROR_STATE 2 -#define DDL_IS_BUSY(ddl_context) \ - (((ddl_context)->ddl_busy != DDL_IDLE_STATE)) -#define DDL_BUSY(ddl_context) \ - ((ddl_context)->ddl_busy = DDL_BUSY_STATE) -#define DDL_IDLE(ddl_context) \ - ((ddl_context)->ddl_busy = DDL_IDLE_STATE) -#define DDL_ERROR(ddl_context) \ - ((ddl_context)->ddl_busy = DDL_ERROR_STATE) - -#define DDL_DEVICE_NOTINIT 0 -#define DDL_DEVICE_INITED 1 -#define DDL_DEVICE_HWFATAL 2 -#define DDL_IS_INITIALIZED(ddl_context) \ -(ddl_context->device_state == DDL_DEVICE_INITED) - -#define DDLCOMMAND_STATE_IS(ddl_context, command_state) \ -(command_state == (ddl_context)->cmd_state) - -#define DDLCLIENT_STATE_IS(ddl, current_state) \ -(current_state == (ddl)->client_state) - -#define DDL_DPB_OP_INIT 1 -#define DDL_DPB_OP_MARK_FREE 2 -#define DDL_DPB_OP_MARK_BUSY 3 -#define DDL_DPB_OP_SET_MASK 4 -#define DDL_DPB_OP_RETRIEVE 5 - -#define DDL_INIT_CLIENTS 0 -#define DDL_GET_CLIENT 1 -#define DDL_FREE_CLIENT 2 -#define DDL_ACTIVE_CLIENT 3 - -#define DDL_INVALID_CHANNEL_ID ((u32)~0) -#define DDL_INVALID_CODEC_TYPE ((u32)~0) - -#define DDL_ENC_REQ_IFRAME 0x01 -#define DDL_ENC_CHANGE_IPERIOD 0x02 -#define DDL_ENC_CHANGE_BITRATE 0x04 -#define DDL_ENC_CHANGE_FRAMERATE 0x08 -#define DDL_ENC_CHANGE_CIR 0x10 - -#define DDL_DEC_REQ_OUTPUT_FLUSH 0x1 - -enum ddl_mem_area { - DDL_MM_MEM = 0x0 -}; - -struct ddl_buf_addr { - u32 *physical_base_addr; - u32 *virtual_base_addr; - u32 *align_physical_addr; - u32 *align_virtual_addr; - struct msm_mapped_buffer *mapped_buffer; - struct ion_handle *alloc_handle; - u32 buffer_size; - enum ddl_mem_area mem_type; -}; - -enum ddl_cmd_state { - DDL_CMD_INVALID = 0x0, - DDL_CMD_DMA_INIT = 0x1, - DDL_CMD_CPU_RESET = 0x2, - DDL_CMD_CHANNEL_SET = 0x3, - DDL_CMD_INIT_CODEC = 0x4, - DDL_CMD_HEADER_PARSE = 0x5, - DDL_CMD_DECODE_SET_DPB = 0x6, - DDL_CMD_DECODE_FRAME = 0x7, - DDL_CMD_ENCODE_FRAME = 0x8, - DDL_CMD_EOS = 0x9, - DDL_CMD_CHANNEL_END = 0xA, - DDL_CMD_32BIT = 0x7FFFFFFF -}; - -enum ddl_client_state { - DDL_CLIENT_INVALID = 0x0, - DDL_CLIENT_OPEN = 0x1, - DDL_CLIENT_WAIT_FOR_CHDONE = 0x2, - DDL_CLIENT_WAIT_FOR_INITCODEC = 0x3, - DDL_CLIENT_WAIT_FOR_INITCODECDONE = 0x4, - DDL_CLIENT_WAIT_FOR_DPB = 0x5, - DDL_CLIENT_WAIT_FOR_DPBDONE = 0x6, - DDL_CLIENT_WAIT_FOR_FRAME = 0x7, - DDL_CLIENT_WAIT_FOR_FRAME_DONE = 0x8, - DDL_CLIENT_WAIT_FOR_EOS_DONE = 0x9, - DDL_CLIENT_WAIT_FOR_CHEND = 0xA, - DDL_CLIENT_FATAL_ERROR = 0xB, - DDL_CLIENT_32BIT = 0x7FFFFFFF -}; - -struct ddl_mask { - u32 client_mask; - u32 hw_mask; -}; - -struct ddl_context; - -struct ddl_client_context; - -struct ddl_codec_data_hdr { - u32 decoding; -}; - -struct ddl_encoder_data { - struct ddl_codec_data_hdr hdr; - struct vcd_property_codec codec; - struct vcd_property_frame_size frame_size; - struct vcd_property_frame_rate frame_rate; - struct vcd_property_target_bitrate target_bit_rate; - struct vcd_property_profile profile; - struct vcd_property_level level; - struct vcd_property_rate_control rc; - struct vcd_property_multi_slice multi_slice; - u32 meta_data_enable_flag; - u32 suffix; - struct ddl_buf_addr meta_data_input; - u32 meta_data_offset; - struct vcd_property_short_header short_header; - struct vcd_property_vop_timing vop_timing; - u32 hdr_ext_control; - struct vcd_property_db_config db_control; - struct vcd_property_entropy_control entropy_control; - struct vcd_property_i_period i_period; - struct vcd_property_session_qp session_qp; - struct vcd_property_qp_range qp_range; - struct vcd_property_rc_level rc_level; - u32 r_cframe_skip; - u32 vb_vbuffer_size; - struct vcd_property_frame_level_rc_params frame_level_rc; - struct vcd_property_adaptive_rc_params adaptive_rc; - struct vcd_property_intra_refresh_mb_number intra_refresh; - struct vcd_property_buffer_format buf_format; - struct vcd_property_buffer_format re_con_buf_format; - u32 dynamic_prop_change; - u32 dynmic_prop_change_req; - u32 ext_enc_control_val; - struct vidc_720p_enc_frame_info enc_frame_info; - struct ddl_buf_addr enc_dpb_addr; - struct ddl_buf_addr seq_header; - struct vcd_buffer_requirement input_buf_req; - struct vcd_buffer_requirement output_buf_req; - struct vcd_buffer_requirement client_input_buf_req; - struct vcd_buffer_requirement client_output_buf_req; -}; - -struct ddl_decoder_data { - struct ddl_codec_data_hdr hdr; - struct vcd_property_codec codec; - struct vcd_property_buffer_format buf_format; - struct vcd_property_frame_size frame_size; - struct vcd_property_frame_size client_frame_size; - struct vcd_property_profile profile; - struct vcd_property_level level; - u32 progressive_only; - u32 output_order; - u32 meta_data_enable_flag; - u32 suffix; - struct ddl_buf_addr meta_data_input; - struct ddl_buf_addr ref_buffer; - u32 meta_data_offset; - struct vcd_property_post_filter post_filter; - struct vcd_sequence_hdr decode_config; - u32 header_in_start; - u32 min_dpb_num; - u32 y_cb_cr_size; - struct ddl_property_dec_pic_buffers dp_buf; - struct ddl_mask dpb_mask; - u32 dynamic_prop_change; - u32 dynmic_prop_change_req; - struct vidc_720p_dec_disp_info dec_disp_info; - struct ddl_buf_addr dpb_comv_buffer; - struct ddl_buf_addr h264Vsp_temp_buffer; - struct vcd_buffer_requirement actual_input_buf_req; - struct vcd_buffer_requirement min_input_buf_req; - struct vcd_buffer_requirement client_input_buf_req; - struct vcd_buffer_requirement actual_output_buf_req; - struct vcd_buffer_requirement min_output_buf_req; - struct vcd_buffer_requirement client_output_buf_req; - u32 idr_only_decoding; -}; - -union ddl_codec_data { - struct ddl_codec_data_hdr hdr; - struct ddl_decoder_data decoder; - struct ddl_encoder_data encoder; -}; - -struct ddl_context { - int memtype; - u8 *core_virtual_base_addr; - void (*ddl_callback) (u32 event, u32 status, void *payload, size_t sz, - u32 *ddl_handle, void *const client_data); - void *client_data; - void (*interrupt_clr) (void); - enum ddl_cmd_state cmd_state; - struct ddl_client_context *current_ddl; - struct ddl_buf_addr context_buf_addr; - struct ddl_buf_addr db_line_buffer; - struct ddl_buf_addr data_partition_tempbuf; - struct ddl_buf_addr metadata_shared_input; - struct ddl_buf_addr dbg_core_dump; - u32 enable_dbg_core_dump; - struct ddl_client_context *ddl_clients[VCD_MAX_NO_CLIENT]; - struct ion_client *video_ion_client; - u32 device_state; - u32 ddl_busy; - u32 intr_status; - u32 cmd_err_status; - u32 disp_pic_err_status; - u32 op_failed; -}; - -struct ddl_client_context { - struct ddl_context *ddl_context; - enum ddl_client_state client_state; - u32 decoding; - u32 channel_id; - struct ddl_frame_data_tag input_frame; - struct ddl_frame_data_tag output_frame; - union ddl_codec_data codec_data; -}; - -DDL_INLINE struct ddl_context *ddl_get_context(void); -DDL_INLINE void ddl_move_command_state(struct ddl_context *ddl_context, - enum ddl_cmd_state command_state); -DDL_INLINE void ddl_move_client_state(struct ddl_client_context *ddl, - enum ddl_client_state client_state); -void ddl_core_init(struct ddl_context *); -void ddl_core_start_cpu(struct ddl_context *); -void ddl_channel_set(struct ddl_client_context *); -void ddl_channel_end(struct ddl_client_context *); -void ddl_encode_init_codec(struct ddl_client_context *); -void ddl_decode_init_codec(struct ddl_client_context *); -void ddl_encode_frame_run(struct ddl_client_context *); -void ddl_decode_frame_run(struct ddl_client_context *); -void ddl_decode_eos_run(struct ddl_client_context *); -void ddl_release_context_buffers(struct ddl_context *); -void ddl_release_client_internal_buffers(struct ddl_client_context *ddl); -u32 ddl_decode_set_buffers(struct ddl_client_context *); -u32 ddl_decoder_dpb_transact(struct ddl_decoder_data *decoder, - struct ddl_frame_data_tag *in_out_frame, - u32 operation); -u32 ddl_client_transact(u32, struct ddl_client_context **); -void ddl_set_default_decoder_buffer_req - (struct ddl_decoder_data *decoder, u32 estimate); -void ddl_set_default_encoder_buffer_req - (struct ddl_encoder_data *encoder); -void ddl_set_default_dec_property(struct ddl_client_context *); -u32 ddl_encoder_ready_to_start(struct ddl_client_context *); -u32 ddl_decoder_ready_to_start(struct ddl_client_context *, - struct vcd_sequence_hdr *); -u32 ddl_get_yuv_buffer_size - (struct vcd_property_frame_size *frame_size, - struct vcd_property_buffer_format *buf_format, u32 inter_lace, - enum vcd_codec codec); -void ddl_calculate_stride(struct vcd_property_frame_size *frame_size, - u32 inter_lace, enum vcd_codec codec); -void ddl_encode_dynamic_property(struct ddl_client_context *ddl, - u32 enable); -void ddl_decode_dynamic_property(struct ddl_client_context *ddl, - u32 enable); -void ddl_set_initial_default_values(struct ddl_client_context *ddl); -u32 ddl_handle_core_errors(struct ddl_context *ddl_context); -void ddl_client_fatal_cb(struct ddl_context *ddl_context); -void ddl_hw_fatal_cb(struct ddl_context *ddl_context); -u32 ddl_hal_engine_reset(struct ddl_context *ddl_context); -void ddl_pmem_alloc(struct ddl_buf_addr *addr, size_t sz, u32 alignment); -void ddl_pmem_free(struct ddl_buf_addr *addr); -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_api.h b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_api.h deleted file mode 100644 index 3796e8f7ab5bbdd6be2ed1a5cec96f6c13472742..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_api.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2010, 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 _VCD_DDL_API_H_ -#define _VCD_DDL_API_H_ -#include "vcd_ddl_internal_property.h" - -struct ddl_init_config { - int memtype; - u8 *core_virtual_base_addr; - void (*interrupt_clr) (void); - void (*ddl_callback) (u32 event, u32 status, void *payload, size_t sz, - u32 *ddl_handle, void *const client_data); -}; - -struct ddl_frame_data_tag { - struct vcd_frame_data vcd_frm; - u32 frm_trans_end; - u32 frm_delta; -}; - -u32 ddl_device_init(struct ddl_init_config *ddl_init_config, - void *client_data); -u32 ddl_device_release(void *client_data); -u32 ddl_open(u32 **ddl_handle, u32 decoding); -u32 ddl_close(u32 **ddl_handle); -u32 ddl_encode_start(u32 *ddl_handle, void *client_data); -u32 ddl_encode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_frame, - struct ddl_frame_data_tag *output_bit, void *client_data); -u32 ddl_encode_end(u32 *ddl_handle, void *client_data); -u32 ddl_decode_start(u32 *ddl_handle, struct vcd_sequence_hdr *header, - void *client_data); -u32 ddl_decode_frame(u32 *ddl_handle, - struct ddl_frame_data_tag *input_bits, void *client_data); -u32 ddl_decode_end(u32 *ddl_handle, void *client_data); -u32 ddl_set_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value); -u32 ddl_get_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value); -void ddl_read_and_clear_interrupt(void); -u32 ddl_process_core_response(void); -u32 ddl_reset_hw(u32 mode); -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_core.h b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_core.h deleted file mode 100644 index 78b05ec1d04b6b2beff2f018d625da7c11d950dd..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_core.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright (c) 2010-2011, 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 _VCD_DDL_CORE_H_ -#define _VCD_DDL_CORE_H_ - -#define DDL_LINEAR_BUF_ALIGN_MASK 0xFFFFFFF8U -#define DDL_LINEAR_BUF_ALIGN_GUARD_BYTES 0x7 -#define DDL_LINEAR_BUFFER_ALIGN_BYTES 8 - -#define DDL_TILE_BUF_ALIGN_MASK 0xFFFFE000U -#define DDL_TILE_BUF_ALIGN_GUARD_BYTES 0x1FFF -#define DDL_TILE_BUFFER_ALIGN_BYTES 8192 - -#define DDL_MAX_FRAME_WIDTH (1280) -#define DDL_MAX_FRAME_HEIGHT (720) - -#define DDL_MAX_DP_FRAME_WIDTH 352 -#define DDL_MAX_DP_FRAME_HEIGHT 288 - -#define DDL_MAX_BIT_RATE (14*1000*1000) - -#define DDL_SW_RESET_SLEEP 10 - -#define VCD_MAX_NO_CLIENT 4 -#define VCD_FRAME_COMMAND_DEPTH 1 -#define VCD_GENERAL_COMMAND_DEPTH 1 -#define VCD_COMMAND_EXCLUSIVE true - -#define DDL_HW_TIMEOUT_IN_MS 1000 - -#define DDL_STREAMBUF_ALIGN_GUARD_BYTES 0x7 - -#define DDL_CONTEXT_MEMORY (1024 * 15 * (VCD_MAX_NO_CLIENT + 1)) -#define DDL_DB_LINE_BUF_SIZE \ -(((((DDL_MAX_FRAME_WIDTH * 4) - 1) / 256) + 1) * 8 * 1024) -#define DDL_MPEG4_DATA_PARTITION_BUF_SIZE (64 * 1024) -#define DDL_DECODE_H264_VSPTEMP_BUFSIZE 0x59c00 -#define DDL_ENC_NUM_DPB_BUFFERS 2 - -#define DDL_DBG_CORE_DUMP_SIZE (10 * 1024) - -#define DDL_BUFEND_PAD 256 -#define DDL_ENC_SEQHEADER_SIZE (256+DDL_BUFEND_PAD) -#define DDL_MAX_BUFFER_COUNT 32 - -#define DDL_MPEG_REFBUF_COUNT 2 - -#define DDL_MPEG_COMV_BUF_NO 2 -#define DDL_H263_COMV_BUF_NO 2 -#define DDL_COMV_BUFLINE_NO 128 -#define DDL_VC1_COMV_BUFLINE_NO 32 -#define DDL_MINIMUM_BYTE_PER_SLICE 1920 - -#define DDL_MAX_H264_QP 51 -#define DDL_MAX_MPEG4_QP 31 - -#define DDL_PADDING_HACK(addr) \ - (addr) = (u32)((((u32)(addr) + DDL_STREAMBUF_ALIGN_GUARD_BYTES) & \ - ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES)) + DDL_BUFEND_PAD) - -#define DDL_QCIF_MBS 99 -#define DDL_CIF_MBS 396 -#define DDL_QVGA_MBS 300 -#define DDL_VGA_MBS 1200 -#define DDL_WVGA_MBS 1500 -#define DDL_720P_MBS 3600 - -#define DDL_FRAMESIZE_DIV_FACTOR (0xF) - -#define DDL_NO_OF_MB(width, height) \ - (((width + 15) >> 4) * ((height + 15) >> 4)) - -#define DDL_ALLOW_ENC_FRAMESIZE(width, height) \ -((DDL_NO_OF_MB(width, height) <= DDL_720P_MBS) \ - && (((width) <= DDL_MAX_FRAME_WIDTH) && \ - ((height) <= DDL_MAX_FRAME_WIDTH)) \ - && ((width) >= 32 && (height) >= 32)) - -#define DDL_VALIDATE_ENC_FRAMESIZE(width, height) \ - (!((width) & DDL_FRAMESIZE_DIV_FACTOR) && \ - !((height) & DDL_FRAMESIZE_DIV_FACTOR)) - -#define DDL_TILE_ALIGN_WIDTH 128 -#define DDL_TILE_ALIGN_HEIGHT 32 -#define DDL_TILE_MULTIPLY_FACTOR 8192 -#define DDL_TILE_ALIGN(val, grid) \ - (((val) + (grid) - 1) / (grid) * (grid)) - -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_errors.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_errors.c deleted file mode 100644 index 6e43a7c6d575faabcebc6e9a2138bfedf60bc10d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_errors.c +++ /dev/null @@ -1,612 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vcd_ddl_utils.h" -#include "vcd_ddl.h" - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -#define ERR(x...) printk(KERN_ERR x) - -#define INVALID_CHANNEL_NUMBER 1 -#define INVALID_COMMAND_ID 2 -#define CHANNEL_ALREADY_IN_USE 3 -#define CHANNEL_NOT_SET_BEFORE_CHANNEL_CLOSE 4 -#define CHANNEL_SET_ERROR_INIT_CODEC 5 -#define INIT_CODEC_ALREADY_CALLED 6 -#define CHANNEL_SET_ERROR_INIT_BUFFERS 7 -#define INIT_CODEC_ERROR_INIT_BUFFERS 8 -#define INIT_BUFFER_ALREADY_CALLED 9 -#define CHANNEL_SET_ERROR_FRAME_RUN 10 -#define INIT_CODEC_ERROR_FRAME_RUN 11 -#define INIT_BUFFERS_ERROR_FRAME_RUN 12 -#define CODEC_LIMIT_EXCEEDED 13 -#define FIRMWARE_SIZE_ZERO 14 -#define FIRMWARE_ADDRESS_EXT_ZERO 15 -#define CONTEXT_DMA_IN_ERROR 16 -#define CONTEXT_DMA_OUT_ERROR 17 -#define PROGRAM_DMA_ERROR 18 -#define CONTEXT_STORE_EXT_ADD_ZERO 19 -#define MEM_ALLOCATION_FAILED 20 - - -#define UNSUPPORTED_FEATURE_IN_PROFILE 27 -#define RESOLUTION_NOT_SUPPORTED 28 -#define HEADER_NOT_FOUND 52 -#define MB_NUM_INVALID 61 -#define FRAME_RATE_NOT_SUPPORTED 62 -#define INVALID_QP_VALUE 63 -#define INVALID_RC_REACTION_COEFFICIENT 64 -#define INVALID_CPB_SIZE_AT_GIVEN_LEVEL 65 - -#define ALLOC_DPB_SIZE_NOT_SUFFICIENT 71 -#define ALLOC_DB_SIZE_NOT_SUFFICIENT 72 -#define ALLOC_COMV_SIZE_NOT_SUFFICIENT 73 -#define NUM_BUF_OUT_OF_RANGE 74 -#define NULL_CONTEXT_POINTER 75 -#define NULL_COMAMND_CONTROL_COMM_POINTER 76 -#define NULL_METADATA_INPUT_POINTER 77 -#define NULL_DPB_POINTER 78 -#define NULL_DB_POINTER 79 -#define NULL_COMV_POINTER 80 - -#define DIVIDE_BY_ZERO 81 -#define BIT_STREAM_BUF_EXHAUST 82 -#define DMA_NOT_STOPPED 83 -#define DMA_TX_NOT_COMPLETE 84 - -#define MB_HEADER_NOT_DONE 85 -#define MB_COEFF_NOT_DONE 86 -#define CODEC_SLICE_NOT_DONE 87 -#define VME_NOT_READY 88 -#define VC1_BITPLANE_DECODE_ERR 89 - - -#define VSP_NOT_READY 90 -#define BUFFER_FULL_STATE 91 - -#define RESOLUTION_MISMATCH 112 -#define NV_QUANT_ERR 113 -#define SYNC_MARKER_ERR 114 -#define FEATURE_NOT_SUPPORTED 115 -#define MEM_CORRUPTION 116 -#define INVALID_REFERENCE_FRAME 117 -#define PICTURE_CODING_TYPE_ERR 118 -#define MV_RANGE_ERR 119 -#define PICTURE_STRUCTURE_ERR 120 -#define SLICE_ADDR_INVALID 121 -#define NON_PAIRED_FIELD_NOT_SUPPORTED 122 -#define NON_FRAME_DATA_RECEIVED 123 -#define INCOMPLETE_FRAME 124 -#define NO_BUFFER_RELEASED_FROM_HOST 125 -#define PICTURE_MANAGEMENT_ERROR 128 -#define INVALID_MMCO 129 -#define INVALID_PIC_REORDERING 130 -#define INVALID_POC_TYPE 131 -#define ACTIVE_SPS_NOT_PRESENT 132 -#define ACTIVE_PPS_NOT_PRESENT 133 -#define INVALID_SPS_ID 134 -#define INVALID_PPS_ID 135 - - -#define METADATA_NO_SPACE_QP 151 -#define METADATA_NO_SAPCE_CONCEAL_MB 152 -#define METADATA_NO_SPACE_VC1_PARAM 153 -#define METADATA_NO_SPACE_SEI 154 -#define METADATA_NO_SPACE_VUI 155 -#define METADATA_NO_SPACE_EXTRA 156 -#define METADATA_NO_SPACE_DATA_NONE 157 -#define FRAME_RATE_UNKNOWN 158 -#define ASPECT_RATIO_UNKOWN 159 -#define COLOR_PRIMARIES_UNKNOWN 160 -#define TRANSFER_CHAR_UNKWON 161 -#define MATRIX_COEFF_UNKNOWN 162 -#define NON_SEQ_SLICE_ADDR 163 -#define BROKEN_LINK 164 -#define FRAME_CONCEALED 165 -#define PROFILE_UNKOWN 166 -#define LEVEL_UNKOWN 167 -#define BIT_RATE_NOT_SUPPORTED 168 -#define COLOR_DIFF_FORMAT_NOT_SUPPORTED 169 -#define NULL_EXTRA_METADATA_POINTER 170 -#define SYNC_POINT_NOT_RECEIVED_STARTED_DECODING 171 -#define NULL_FW_DEBUG_INFO_POINTER 172 -#define ALLOC_DEBUG_INFO_SIZE_INSUFFICIENT 173 -#define MAX_STAGE_COUNTER_EXCEEDED 174 - -#define METADATA_NO_SPACE_MB_INFO 180 -#define METADATA_NO_SPACE_SLICE_SIZE 181 -#define RESOLUTION_WARNING 182 - -static void ddl_handle_npf_decoding_error( - struct ddl_context *ddl_context); - -static u32 ddl_handle_seqhdr_fail_error( - struct ddl_context *ddl_context); - -void ddl_hw_fatal_cb(struct ddl_context *ddl_context) -{ - /* Invalidate the command state */ - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - ddl_context->device_state = DDL_DEVICE_HWFATAL; - - /* callback to the client to indicate hw fatal error */ - ddl_context->ddl_callback(VCD_EVT_IND_HWERRFATAL, - VCD_ERR_HW_FATAL, NULL, 0, - (void *)ddl_context->current_ddl, - ddl_context->client_data); - - DDL_IDLE(ddl_context); -} - -static u32 ddl_handle_hw_fatal_errors(struct ddl_context - *ddl_context) -{ - u32 status = false; - - switch (ddl_context->cmd_err_status) { - - case INVALID_CHANNEL_NUMBER: - case INVALID_COMMAND_ID: - case CHANNEL_ALREADY_IN_USE: - case CHANNEL_NOT_SET_BEFORE_CHANNEL_CLOSE: - case CHANNEL_SET_ERROR_INIT_CODEC: - case INIT_CODEC_ALREADY_CALLED: - case CHANNEL_SET_ERROR_INIT_BUFFERS: - case INIT_CODEC_ERROR_INIT_BUFFERS: - case INIT_BUFFER_ALREADY_CALLED: - case CHANNEL_SET_ERROR_FRAME_RUN: - case INIT_CODEC_ERROR_FRAME_RUN: - case INIT_BUFFERS_ERROR_FRAME_RUN: - case CODEC_LIMIT_EXCEEDED: - case FIRMWARE_SIZE_ZERO: - case FIRMWARE_ADDRESS_EXT_ZERO: - - case CONTEXT_DMA_IN_ERROR: - case CONTEXT_DMA_OUT_ERROR: - case PROGRAM_DMA_ERROR: - case CONTEXT_STORE_EXT_ADD_ZERO: - case MEM_ALLOCATION_FAILED: - - case DIVIDE_BY_ZERO: - case DMA_NOT_STOPPED: - case DMA_TX_NOT_COMPLETE: - - case VSP_NOT_READY: - case BUFFER_FULL_STATE: - case NULL_DB_POINTER: - ERR("HW FATAL ERROR"); - ddl_hw_fatal_cb(ddl_context); - status = true; - break; - } - return status; -} - -void ddl_client_fatal_cb(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = - ddl_context->current_ddl; - - if (ddl_context->cmd_state == DDL_CMD_DECODE_FRAME) - ddl_decode_dynamic_property(ddl, false); - else if (ddl_context->cmd_state == DDL_CMD_ENCODE_FRAME) - ddl_encode_dynamic_property(ddl, false); - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - - ddl_move_client_state(ddl, DDL_CLIENT_FATAL_ERROR); - - ddl_context->ddl_callback - ( - VCD_EVT_IND_HWERRFATAL, - VCD_ERR_CLIENT_FATAL, - NULL, - 0, - (void *)ddl, - ddl_context->client_data - ); - - DDL_IDLE(ddl_context); -} - -static u32 ddl_handle_client_fatal_errors(struct ddl_context - *ddl_context) -{ - u32 status = false; - - switch (ddl_context->cmd_err_status) { - case MB_NUM_INVALID: - case FRAME_RATE_NOT_SUPPORTED: - case INVALID_QP_VALUE: - case INVALID_RC_REACTION_COEFFICIENT: - case INVALID_CPB_SIZE_AT_GIVEN_LEVEL: - - case ALLOC_DPB_SIZE_NOT_SUFFICIENT: - case ALLOC_DB_SIZE_NOT_SUFFICIENT: - case ALLOC_COMV_SIZE_NOT_SUFFICIENT: - case NUM_BUF_OUT_OF_RANGE: - case NULL_CONTEXT_POINTER: - case NULL_COMAMND_CONTROL_COMM_POINTER: - case NULL_METADATA_INPUT_POINTER: - case NULL_DPB_POINTER: - case NULL_COMV_POINTER: - { - status = true; - break; - } - } - - if (!status) - ERR("UNKNOWN-OP-FAILED"); - - ddl_client_fatal_cb(ddl_context); - - return true; -} - -static void ddl_input_failed_cb(struct ddl_context *ddl_context, - u32 vcd_event, u32 vcd_status) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - - if (ddl->decoding) - ddl_decode_dynamic_property(ddl, false); - else - ddl_encode_dynamic_property(ddl, false); - - ddl_context->ddl_callback(vcd_event, - vcd_status, &ddl->input_frame, - sizeof(struct ddl_frame_data_tag), - (void *)ddl, ddl_context->client_data); - - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME); -} - -static u32 ddl_handle_core_recoverable_errors(struct ddl_context \ - *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - u32 vcd_status = VCD_S_SUCCESS; - u32 vcd_event = VCD_EVT_RESP_INPUT_DONE; - u32 eos = false, pending_display = 0, release_mask = 0; - - if (ddl->decoding) - if (ddl_handle_seqhdr_fail_error(ddl_context)) - return true; - - if (ddl_context->cmd_state != DDL_CMD_DECODE_FRAME && - ddl_context->cmd_state != DDL_CMD_ENCODE_FRAME) { - return false; - } - switch (ddl_context->cmd_err_status) { - case NON_PAIRED_FIELD_NOT_SUPPORTED: - { - ddl_handle_npf_decoding_error(ddl_context); - return true; - } - case NO_BUFFER_RELEASED_FROM_HOST: - { - /* lets check sanity of this error */ - release_mask = - ddl->codec_data.decoder.dpb_mask.hw_mask; - while (release_mask > 0) { - if ((release_mask & 0x1)) - pending_display += 1; - release_mask >>= 1; - } - - if (pending_display >= - ddl->codec_data.decoder.min_dpb_num) { - DBG("FWISSUE-REQBUF!!"); - /* callback to client for client fatal error */ - ddl_client_fatal_cb(ddl_context); - return true ; - } - vcd_event = VCD_EVT_RESP_OUTPUT_REQ; - break; - } - case BIT_STREAM_BUF_EXHAUST: - case MB_HEADER_NOT_DONE: - case MB_COEFF_NOT_DONE: - case CODEC_SLICE_NOT_DONE: - case VME_NOT_READY: - case VC1_BITPLANE_DECODE_ERR: - { - u32 reset_core; - /* need to reset the internal core hw engine */ - reset_core = ddl_hal_engine_reset(ddl_context); - if (!reset_core) - return true; - /* fall through to process bitstream error handling */ - } - case RESOLUTION_MISMATCH: - case NV_QUANT_ERR: - case SYNC_MARKER_ERR: - case FEATURE_NOT_SUPPORTED: - case MEM_CORRUPTION: - case INVALID_REFERENCE_FRAME: - case PICTURE_CODING_TYPE_ERR: - case MV_RANGE_ERR: - case PICTURE_STRUCTURE_ERR: - case SLICE_ADDR_INVALID: - case NON_FRAME_DATA_RECEIVED: - case INCOMPLETE_FRAME: - case PICTURE_MANAGEMENT_ERROR: - case INVALID_MMCO: - case INVALID_PIC_REORDERING: - case INVALID_POC_TYPE: - { - vcd_status = VCD_ERR_BITSTREAM_ERR; - break; - } - case ACTIVE_SPS_NOT_PRESENT: - case ACTIVE_PPS_NOT_PRESENT: - { - if (ddl->codec_data.decoder.idr_only_decoding) { - DBG("Consider warnings as errors in idr mode"); - ddl_client_fatal_cb(ddl_context); - return true; - } - vcd_status = VCD_ERR_BITSTREAM_ERR; - break; - } - case PROFILE_UNKOWN: - if (ddl->decoding) - vcd_status = VCD_ERR_BITSTREAM_ERR; - break; - } - - if (!vcd_status && vcd_event == VCD_EVT_RESP_INPUT_DONE) - return false; - - ddl->input_frame.frm_trans_end = true; - - eos = ((vcd_event == VCD_EVT_RESP_INPUT_DONE) && - ((VCD_FRAME_FLAG_EOS & ddl->input_frame. - vcd_frm.flags))); - - if ((ddl->decoding && eos) || - (!ddl->decoding)) - ddl->input_frame.frm_trans_end = false; - - if (vcd_event == VCD_EVT_RESP_INPUT_DONE && - ddl->decoding && - !ddl->codec_data.decoder.header_in_start && - !ddl->codec_data.decoder.dec_disp_info.img_size_x && - !ddl->codec_data.decoder.dec_disp_info.img_size_y && - !eos) { - DBG("Treat header in start error %u as success", - vcd_status); - /* this is first frame seq. header only case */ - vcd_status = VCD_S_SUCCESS; - ddl->input_frame.vcd_frm.flags |= - VCD_FRAME_FLAG_CODECCONFIG; - ddl->input_frame.frm_trans_end = !eos; - /* put just some non - zero value */ - ddl->codec_data.decoder.dec_disp_info.img_size_x = 0xff; - } - /* inform client about input failed */ - ddl_input_failed_cb(ddl_context, vcd_event, vcd_status); - - /* for Encoder case, we need to send output done also */ - if (!ddl->decoding) { - /* transaction is complete after this callback */ - ddl->output_frame.frm_trans_end = !eos; - /* error case: NO data present */ - ddl->output_frame.vcd_frm.data_len = 0; - /* call back to client for output frame done */ - ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_ERR_FAIL, &(ddl->output_frame), - sizeof(struct ddl_frame_data_tag), - (void *)ddl, ddl_context->client_data); - - if (eos) { - DBG("ENC-EOS_DONE"); - /* send client EOS DONE callback */ - ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE, - VCD_S_SUCCESS, NULL, 0, (void *)ddl, - ddl_context->client_data); - } - } - - /* if it is decoder EOS case */ - if (ddl->decoding && eos) { - DBG("DEC-EOS_RUN"); - ddl_decode_eos_run(ddl); - } else - DDL_IDLE(ddl_context); - - return true; -} - -static u32 ddl_handle_core_warnings(u32 err_status) -{ - u32 status = false; - - switch (err_status) { - case FRAME_RATE_UNKNOWN: - case ASPECT_RATIO_UNKOWN: - case COLOR_PRIMARIES_UNKNOWN: - case TRANSFER_CHAR_UNKWON: - case MATRIX_COEFF_UNKNOWN: - case NON_SEQ_SLICE_ADDR: - case BROKEN_LINK: - case FRAME_CONCEALED: - case PROFILE_UNKOWN: - case LEVEL_UNKOWN: - case BIT_RATE_NOT_SUPPORTED: - case COLOR_DIFF_FORMAT_NOT_SUPPORTED: - case NULL_EXTRA_METADATA_POINTER: - case SYNC_POINT_NOT_RECEIVED_STARTED_DECODING: - - case NULL_FW_DEBUG_INFO_POINTER: - case ALLOC_DEBUG_INFO_SIZE_INSUFFICIENT: - case MAX_STAGE_COUNTER_EXCEEDED: - - case METADATA_NO_SPACE_MB_INFO: - case METADATA_NO_SPACE_SLICE_SIZE: - case RESOLUTION_WARNING: - - /* decoder warnings */ - case METADATA_NO_SPACE_QP: - case METADATA_NO_SAPCE_CONCEAL_MB: - case METADATA_NO_SPACE_VC1_PARAM: - case METADATA_NO_SPACE_SEI: - case METADATA_NO_SPACE_VUI: - case METADATA_NO_SPACE_EXTRA: - case METADATA_NO_SPACE_DATA_NONE: - { - status = true; - DBG("CMD-WARNING-IGNORED!!"); - break; - } - } - return status; -} - -u32 ddl_handle_core_errors(struct ddl_context *ddl_context) -{ - u32 status = false; - - if (!ddl_context->cmd_err_status && - !ddl_context->disp_pic_err_status && - !ddl_context->op_failed) - return false; - - if (ddl_context->cmd_state == DDL_CMD_INVALID) { - DBG("SPURIOUS_INTERRUPT_ERROR"); - return true; - } - - if (!ddl_context->op_failed) { - u32 disp_status; - status = ddl_handle_core_warnings(ddl_context-> - cmd_err_status); - disp_status = ddl_handle_core_warnings( - ddl_context->disp_pic_err_status); - if (!status && !disp_status) - DBG("ddl_warning:Unknown"); - - return false; - } - - ERR("\n %s(): OPFAILED!!", __func__); - ERR("\n CMD_ERROR_STATUS = %u, DISP_ERR_STATUS = %u", - ddl_context->cmd_err_status, - ddl_context->disp_pic_err_status); - - status = ddl_handle_hw_fatal_errors(ddl_context); - - if (!status) - status = ddl_handle_core_recoverable_errors(ddl_context); - - if (!status) - status = ddl_handle_client_fatal_errors(ddl_context); - - return status; -} - -void ddl_handle_npf_decoding_error(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - if (!ddl->decoding) { - ERR("FWISSUE-ENC-NPF!!!"); - ddl_client_fatal_cb(ddl_context); - return; - } - vidc_720p_decode_display_info(&decoder->dec_disp_info); - ddl_decode_dynamic_property(ddl, false); - ddl->output_frame.vcd_frm.ip_frm_tag = - decoder->dec_disp_info.tag_top; - ddl->output_frame.vcd_frm.physical = NULL; - ddl->output_frame.frm_trans_end = false; - ddl->ddl_context->ddl_callback( - VCD_EVT_RESP_OUTPUT_DONE, - VCD_ERR_INTRLCD_FIELD_DROP, - &ddl->output_frame, - sizeof(struct ddl_frame_data_tag), - (void *)ddl, - ddl->ddl_context->client_data); - ddl_decode_frame_run(ddl); -} - -u32 ddl_handle_seqhdr_fail_error(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - u32 status = false; - if (ddl_context->cmd_state == DDL_CMD_HEADER_PARSE && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) { - switch (ddl_context->cmd_err_status) { - case UNSUPPORTED_FEATURE_IN_PROFILE: - case HEADER_NOT_FOUND: - case INVALID_SPS_ID: - case INVALID_PPS_ID: - case RESOLUTION_NOT_SUPPORTED: - case PROFILE_UNKOWN: - ERR("SEQ-HDR-FAILED!!!"); - if ((ddl_context->cmd_err_status == - RESOLUTION_NOT_SUPPORTED) && - (decoder->codec.codec == VCD_CODEC_H264 || - decoder->codec.codec == VCD_CODEC_H263 || - decoder->codec.codec == VCD_CODEC_MPEG4 || - decoder->codec.codec == VCD_CODEC_VC1_RCV || - decoder->codec.codec == VCD_CODEC_VC1)) { - ddl_client_fatal_cb(ddl_context); - status = true; - break; - } - if (decoder->header_in_start) { - decoder->header_in_start = false; - ddl_context->ddl_callback(VCD_EVT_RESP_START, - VCD_ERR_SEQHDR_PARSE_FAIL, - NULL, 0, (void *)ddl, - ddl_context->client_data); - } else { - if (ddl->input_frame.vcd_frm.flags & - VCD_FRAME_FLAG_EOS) - ddl->input_frame.frm_trans_end = false; - else - ddl->input_frame.frm_trans_end = true; - ddl_decode_dynamic_property(ddl, false); - ddl_context->ddl_callback( - VCD_EVT_RESP_INPUT_DONE, - VCD_ERR_SEQHDR_PARSE_FAIL, - &ddl->input_frame, - sizeof(struct ddl_frame_data_tag), - (void *)ddl, ddl_context->client_data); - if (ddl->input_frame.vcd_frm.flags & - VCD_FRAME_FLAG_EOS) - ddl_context->ddl_callback( - VCD_EVT_RESP_EOS_DONE, - VCD_S_SUCCESS, NULL, - 0, (void *)ddl, - ddl_context->client_data); - } - ddl_move_client_state(ddl, - DDL_CLIENT_WAIT_FOR_INITCODEC); - DDL_IDLE(ddl_context); - status = true; - } - } - return status; -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_firmware.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_firmware.c deleted file mode 100644 index 23948d4e8f54645ebafbf6fdd28250121a660af0..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_firmware.c +++ /dev/null @@ -1,352 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vcd_ddl_firmware.h" -#include "vcd_ddl_utils.h" - -#define VCDFW_TOTALNUM_IMAGE 7 -#define VCDFW_MAX_NO_IMAGE 2 - -struct vcd_firmware { - u32 active_fw_img[VCDFW_TOTALNUM_IMAGE]; - struct ddl_buf_addr boot_code; - - struct ddl_buf_addr enc_mpeg4; - struct ddl_buf_addr encH264; - - struct ddl_buf_addr dec_mpeg4; - struct ddl_buf_addr decH264; - struct ddl_buf_addr decH263; - struct ddl_buf_addr dec_mpeg2; - struct ddl_buf_addr dec_vc1; -}; - -static struct vcd_firmware vcd_firmware; - - -static void vcd_fw_change_endian(unsigned char *fw, u32 fw_size) -{ - u32 i = 0; - unsigned char temp; - for (i = 0; i < fw_size; i = i + 4) { - temp = fw[i]; - fw[i] = fw[i + 3]; - fw[i + 3] = temp; - - temp = fw[i + 1]; - fw[i + 1] = fw[i + 2]; - fw[i + 2] = temp; - } - return; -} - -static u32 vcd_fw_prepare(struct ddl_buf_addr *fw_details, - const unsigned char fw_array[], - const unsigned int fw_array_size, u32 change_endian) -{ - u32 *buffer; - - ddl_pmem_alloc(fw_details, fw_array_size, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!fw_details->virtual_base_addr) - return false; - - fw_details->buffer_size = fw_array_size / 4; - - buffer = fw_details->align_virtual_addr; - - memcpy(buffer, fw_array, fw_array_size); - if (change_endian) - vcd_fw_change_endian((unsigned char *)buffer, fw_array_size); - return true; -} - -u32 vcd_fw_init(void) -{ - u32 status = false; - - status = vcd_fw_prepare(&vcd_firmware.boot_code, - vidc_command_control_fw, - vidc_command_control_fw_size, false); - - if (status) { - status = vcd_fw_prepare(&vcd_firmware.dec_mpeg4, - vidc_mpg4_dec_fw, - vidc_mpg4_dec_fw_size, true); - } - - if (status) { - status = vcd_fw_prepare(&vcd_firmware.decH264, - vidc_h264_dec_fw, - vidc_h264_dec_fw_size, true); - } - - if (status) { - status = vcd_fw_prepare(&vcd_firmware.decH263, - vidc_h263_dec_fw, - vidc_h263_dec_fw_size, true); - } - - if (status) { - status = vcd_fw_prepare(&vcd_firmware.enc_mpeg4, - vidc_mpg4_enc_fw, - vidc_mpg4_enc_fw_size, true); - } - - if (status) { - status = vcd_fw_prepare(&vcd_firmware.encH264, - vidc_h264_enc_fw, - vidc_h264_enc_fw_size, true); - } - - if (status) { - status = vcd_fw_prepare(&vcd_firmware.dec_vc1, - vidc_vc1_dec_fw, - vidc_vc1_dec_fw_size, true); - } - return status; -} - - -static u32 get_dec_fw_image(struct vcd_fw_details *fw_details) -{ - u32 status = true; - switch (fw_details->codec) { - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_XVID: - case VCD_CODEC_MPEG4: - { - fw_details->fw_buffer_addr = - vcd_firmware.dec_mpeg4.align_physical_addr; - fw_details->fw_size = - vcd_firmware.dec_mpeg4.buffer_size; - break; - } - case VCD_CODEC_H264: - { - fw_details->fw_buffer_addr = - vcd_firmware.decH264.align_physical_addr; - fw_details->fw_size = - vcd_firmware.decH264.buffer_size; - break; - } - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - { - fw_details->fw_buffer_addr = - vcd_firmware.dec_vc1.align_physical_addr; - fw_details->fw_size = - vcd_firmware.dec_vc1.buffer_size; - break; - } - case VCD_CODEC_MPEG2: - { - fw_details->fw_buffer_addr = - vcd_firmware.dec_mpeg2.align_physical_addr; - fw_details->fw_size = - vcd_firmware.dec_mpeg2.buffer_size; - break; - } - case VCD_CODEC_H263: - { - fw_details->fw_buffer_addr = - vcd_firmware.decH263.align_physical_addr; - fw_details->fw_size = - vcd_firmware.decH263.buffer_size; - break; - } - default: - { - status = false; - break; - } - } - return status; -} - -static u32 get_enc_fw_image(struct vcd_fw_details *fw_details) -{ - u32 status = true; - switch (fw_details->codec) { - case VCD_CODEC_H263: - case VCD_CODEC_MPEG4: - { - fw_details->fw_buffer_addr = - vcd_firmware.enc_mpeg4.align_physical_addr; - fw_details->fw_size = - vcd_firmware.enc_mpeg4.buffer_size; - break; - } - case VCD_CODEC_H264: - { - fw_details->fw_buffer_addr = - vcd_firmware.encH264.align_physical_addr; - fw_details->fw_size = - vcd_firmware.encH264.buffer_size; - break; - } - default: - { - status = false; - break; - } - } - return status; -} - -u32 vcd_get_fw_property(u32 prop_id, void *prop_details) -{ - u32 status = true; - struct vcd_fw_details *fw_details; - switch (prop_id) { - case VCD_FW_ENDIAN: - { - *(u32 *) prop_details = VCD_FW_BIG_ENDIAN; - break; - } - case VCD_FW_BOOTCODE: - { - fw_details = - (struct vcd_fw_details *)prop_details; - fw_details->fw_buffer_addr = - vcd_firmware.boot_code.align_physical_addr; - fw_details->fw_size = - vcd_firmware.boot_code.buffer_size; - break; - } - case VCD_FW_DECODE: - { - fw_details = - (struct vcd_fw_details *)prop_details; - status = get_dec_fw_image(fw_details); - break; - } - case VCD_FW_ENCODE: - { - fw_details = - (struct vcd_fw_details *)prop_details; - status = get_enc_fw_image(fw_details); - break; - } - default: - { - status = false; - break; - } - } - return status; -} - -u32 vcd_fw_transact(u32 add, u32 decoding, enum vcd_codec codec) -{ - u32 status = true; - u32 index = 0, active_fw = 0, loop_count; - - if (decoding) { - switch (codec) { - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_XVID: - case VCD_CODEC_MPEG4: - { - index = 0; - break; - } - case VCD_CODEC_H264: - { - index = 1; - break; - } - case VCD_CODEC_H263: - { - index = 2; - break; - } - case VCD_CODEC_MPEG2: - { - index = 3; - break; - } - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - { - index = 4; - break; - } - default: - { - status = false; - break; - } - } - } else { - switch (codec) { - case VCD_CODEC_H263: - case VCD_CODEC_MPEG4: - { - index = 5; - break; - } - case VCD_CODEC_H264: - { - index = 6; - break; - } - default: - { - status = false; - break; - } - } - } - - if (!status) - return status; - - if (!add && - vcd_firmware.active_fw_img[index] - ) { - --vcd_firmware.active_fw_img[index]; - return status; - } - - for (loop_count = 0; loop_count < VCDFW_TOTALNUM_IMAGE; - ++loop_count) { - if (vcd_firmware.active_fw_img[loop_count]) - ++active_fw; - } - - if (active_fw < VCDFW_MAX_NO_IMAGE || - vcd_firmware.active_fw_img[index] > 0) { - ++vcd_firmware.active_fw_img[index]; - } else { - status = false; - } - return status; -} - -void vcd_fw_release(void) -{ - ddl_pmem_free(&vcd_firmware.boot_code); - ddl_pmem_free(&vcd_firmware.enc_mpeg4); - ddl_pmem_free(&vcd_firmware.encH264); - ddl_pmem_free(&vcd_firmware.dec_mpeg4); - ddl_pmem_free(&vcd_firmware.decH264); - ddl_pmem_free(&vcd_firmware.decH263); - ddl_pmem_free(&vcd_firmware.dec_mpeg2); - ddl_pmem_free(&vcd_firmware.dec_vc1); -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_firmware.h b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_firmware.h deleted file mode 100644 index ba8dbcbfcce42f63ad1d0d67e2958e6832a1c167..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_firmware.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DDL_FIRMWARE_H_ -#define _VCD_DDL_FIRMWARE_H_ -#include - -#define VCD_FW_BIG_ENDIAN 0x0 -#define VCD_FW_LITTLE_ENDIAN 0x1 - -struct vcd_fw_details { - enum vcd_codec codec; - u32 *fw_buffer_addr; - u32 fw_size; -}; - -#define VCD_FW_PROP_BASE 0x0 - -#define VCD_FW_ENDIAN (VCD_FW_PROP_BASE + 0x1) -#define VCD_FW_BOOTCODE (VCD_FW_PROP_BASE + 0x2) -#define VCD_FW_DECODE (VCD_FW_PROP_BASE + 0x3) -#define VCD_FW_ENCODE (VCD_FW_PROP_BASE + 0x4) - -extern unsigned char *vidc_command_control_fw; -extern u32 vidc_command_control_fw_size; -extern unsigned char *vidc_mpg4_dec_fw; -extern u32 vidc_mpg4_dec_fw_size; -extern unsigned char *vidc_h263_dec_fw; -extern u32 vidc_h263_dec_fw_size; -extern unsigned char *vidc_h264_dec_fw; -extern u32 vidc_h264_dec_fw_size; -extern unsigned char *vidc_mpg4_enc_fw; -extern u32 vidc_mpg4_enc_fw_size; -extern unsigned char *vidc_h264_enc_fw; -extern u32 vidc_h264_enc_fw_size; -extern unsigned char *vidc_vc1_dec_fw; -extern u32 vidc_vc1_dec_fw_size; - -u32 vcd_fw_init(void); -u32 vcd_get_fw_property(u32 prop_id, void *prop_details); -u32 vcd_fw_transact(u32 add, u32 decoding, enum vcd_codec codec); -void vcd_fw_release(void); - -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_hal.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_hal.c deleted file mode 100644 index 4cbd984a47cabc26900cc76dae286acd06aa28f5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_hal.c +++ /dev/null @@ -1,971 +0,0 @@ -/* Copyright (c) 2010-2012, 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 - -#include "vcd_ddl_utils.h" -#include "vcd_ddl_metadata.h" - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -#define DBG_INFO(x...) pr_info(x) - -void ddl_core_init(struct ddl_context *ddl_context) -{ - char *psz_version; - struct vcd_fw_details fw_details; - u32 fw_endianness; - enum vidc_720p_endian dma_endian; - u32 interrupt_off; - enum vidc_720p_interrupt_level_selection interrupt_sel; - u32 intr_mask = 0x0; - - vcd_get_fw_property(VCD_FW_BOOTCODE, &fw_details); - vcd_get_fw_property(VCD_FW_ENDIAN, &fw_endianness); - if (fw_endianness == VCD_FW_BIG_ENDIAN) - dma_endian = VIDC_720P_BIG_ENDIAN; - else - dma_endian = VIDC_720P_LITTLE_ENDIAN; - - interrupt_off = false; - interrupt_sel = VIDC_720P_INTERRUPT_LEVEL_SEL; - - intr_mask |= VIDC_720P_INTR_BUFFER_FULL; - intr_mask |= VIDC_720P_INTR_FW_DONE; - intr_mask |= VIDC_720P_INTR_DMA_DONE; - intr_mask |= VIDC_720P_INTR_FRAME_DONE; - - vidc_720p_do_sw_reset(); - - DBG_INFO("Loading CONTROL_FW of FW_SIZE %u\n", - fw_details.fw_size*4); - - vidc_720p_init(&psz_version, - fw_details.fw_size, - fw_details.fw_buffer_addr, - dma_endian, - interrupt_off, interrupt_sel, intr_mask); - return; -} - -void ddl_core_start_cpu(struct ddl_context *ddl_context) -{ - u32 fw_endianness; - enum vidc_720p_endian dma_endian; - u32 dbg_core_dump_buf_size = 0; - - vcd_get_fw_property(VCD_FW_ENDIAN, &fw_endianness); - if (fw_endianness == VCD_FW_BIG_ENDIAN) - dma_endian = VIDC_720P_LITTLE_ENDIAN; - else - dma_endian = VIDC_720P_BIG_ENDIAN; - - ddl_move_command_state(ddl_context, DDL_CMD_CPU_RESET); - - DBG("VSP_BUF_ADDR_SIZE %d", - ddl_context->context_buf_addr.buffer_size); - if (ddl_context->enable_dbg_core_dump) { - dbg_core_dump_buf_size = ddl_context->dbg_core_dump. - buffer_size; - } - - vidc_720p_start_cpu(dma_endian, - ddl_context->context_buf_addr.align_physical_addr, - ddl_context->dbg_core_dump.align_physical_addr, - dbg_core_dump_buf_size); - - VIDC_DEBUG_REGISTER_LOG; -} - -void ddl_channel_set(struct ddl_client_context *ddl) -{ - enum vidc_720p_enc_dec_selection enc_dec_sel; - enum vidc_720p_codec codec; - enum vcd_codec *vcd_codec; - u32 fw_property_id; - struct vcd_fw_details fw_details; - - if (ddl->decoding) { - if (vidc_msg_timing) - ddl_set_core_start_time(__func__, DEC_OP_TIME); - enc_dec_sel = VIDC_720P_DECODER; - fw_property_id = VCD_FW_DECODE; - vcd_codec = &(ddl->codec_data.decoder.codec.codec); - } else { - enc_dec_sel = VIDC_720P_ENCODER; - fw_property_id = VCD_FW_ENCODE; - vcd_codec = &(ddl->codec_data.encoder.codec.codec); - } - switch (*vcd_codec) { - default: - case VCD_CODEC_MPEG4: - { - codec = VIDC_720P_MPEG4; - - if (ddl->decoding) { - vidc_720p_decode_set_mpeg4_data_partitionbuffer - (ddl->ddl_context->data_partition_tempbuf. - align_physical_addr); - } - - break; - } - case VCD_CODEC_H264: - { - codec = VIDC_720P_H264; - break; - } - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - { - codec = VIDC_720P_DIVX; - break; - } - case VCD_CODEC_XVID: - { - codec = VIDC_720P_XVID; - break; - } - case VCD_CODEC_H263: - { - codec = VIDC_720P_H263; - break; - } - case VCD_CODEC_MPEG2: - { - codec = VIDC_720P_MPEG2; - break; - } - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - { - codec = VIDC_720P_VC1; - break; - } - } - - fw_details.codec = *vcd_codec; - vcd_get_fw_property(fw_property_id, &fw_details); - VIDC_DEBUG_REGISTER_LOG; - - ddl_move_command_state(ddl->ddl_context, DDL_CMD_CHANNEL_SET); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_CHDONE); - - DBG_INFO("Loading firmware for CODEC:%u of FW_SIZE:%u\n", - fw_details.codec, fw_details.fw_size*4); - - vidc_720p_set_channel(ddl->channel_id, - enc_dec_sel, - codec, - fw_details.fw_buffer_addr, - fw_details.fw_size); -} - -void ddl_decode_init_codec(struct ddl_client_context *ddl) -{ - u32 seq_h = 0, seq_e = 0, start_byte_num = 0; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vcd_sequence_hdr *seq_hdr = &decoder->decode_config; - enum vidc_720p_memory_access_method mem_access_method; - if (vidc_msg_timing) - ddl_set_core_start_time(__func__, DEC_OP_TIME); - ddl_metadata_enable(ddl); - - vidc_720p_decode_set_error_control(true); - - vidc_720p_decode_set_mpeg4Post_filter(decoder->post_filter. - post_filter); - - if (decoder->codec.codec == VCD_CODEC_H264) { - vidc_720p_decode_setH264VSPBuffer(decoder-> - h264Vsp_temp_buffer. - align_physical_addr); - VIDC_LOG1("VSP_BUF_ADDR_SIZE", - decoder->h264Vsp_temp_buffer.buffer_size); - } - - if (decoder->codec.codec == VCD_CODEC_VC1_RCV || - decoder->codec.codec == VCD_CODEC_VC1) { - vidc_720p_set_frame_size(decoder->client_frame_size.width, - decoder->client_frame_size.height); - } else { - vidc_720p_set_frame_size(0x0, 0x0); - } - - switch (decoder->buf_format.buffer_format) { - default: - case VCD_BUFFER_FORMAT_NV12: - { - mem_access_method = VIDC_720P_TILE_LINEAR; - break; - } - case VCD_BUFFER_FORMAT_TILE_4x2: - { - mem_access_method = VIDC_720P_TILE_64x32; - break; - } - } - VIDC_LOG_STRING("HEADER-PARSE-START"); - VIDC_DEBUG_REGISTER_LOG; - seq_h = (u32) seq_hdr->sequence_header; - start_byte_num = 8 - (seq_h & DDL_STREAMBUF_ALIGN_GUARD_BYTES); - seq_e = seq_h + seq_hdr->sequence_header_len; - seq_h &= ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - DDL_PADDING_HACK(seq_e); - - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE); - ddl_move_command_state(ddl->ddl_context, DDL_CMD_HEADER_PARSE); - - vidc_720p_decode_bitstream_header(ddl->channel_id, - seq_hdr->sequence_header_len, - start_byte_num, - seq_h, - seq_e, - mem_access_method, - decoder->output_order); -} - -void ddl_decode_dynamic_property(struct ddl_client_context *ddl, - u32 enable) -{ - uint8_t *temp = NULL; - u32 extra_datastart = 0; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vcd_frame_data *bit_stream = - &(ddl->input_frame.vcd_frm); - - if (!enable) { - if (decoder->dynmic_prop_change_req) { - decoder->dynmic_prop_change_req = false; - vidc_720p_decode_dynamic_req_reset(); - } - return; - } - if ((decoder->dynamic_prop_change & - DDL_DEC_REQ_OUTPUT_FLUSH)) { - decoder->dynmic_prop_change_req = true; - decoder->dynamic_prop_change &= ~(DDL_DEC_REQ_OUTPUT_FLUSH); - decoder->dpb_mask.hw_mask = 0; - vidc_720p_decode_dynamic_req_set(VIDC_720P_FLUSH_REQ); - } - if (((decoder->meta_data_enable_flag & VCD_METADATA_PASSTHROUGH)) - && ((VCD_FRAME_FLAG_EXTRADATA & bit_stream->flags)) - ) { - - temp = ((uint8_t *)bit_stream->physical + - bit_stream->offset + - bit_stream->data_len + 3); - - extra_datastart = (u32) ((u32)temp & ~3); - decoder->dynmic_prop_change_req = true; - - vidc_720p_decode_setpassthrough_start(extra_datastart); - - vidc_720p_decode_dynamic_req_set(VIDC_720P_EXTRADATA); - } -} - -void ddl_encode_dynamic_property(struct ddl_client_context *ddl, - u32 enable) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - u32 enc_param_change = 0; - - if (!enable) { - if (encoder->dynmic_prop_change_req) { - encoder->dynmic_prop_change_req = false; - encoder->ext_enc_control_val &= - ~(VIDC_720P_ENC_IFRAME_REQ); - vidc_720p_encode_set_control_param - (encoder->ext_enc_control_val); - vidc_720p_encoder_set_param_change(enc_param_change); - } - return; - } - if ((encoder->dynamic_prop_change & DDL_ENC_REQ_IFRAME)) { - encoder->dynamic_prop_change &= ~(DDL_ENC_REQ_IFRAME); - encoder->ext_enc_control_val |= VIDC_720P_ENC_IFRAME_REQ; - vidc_720p_encode_set_control_param - (encoder->ext_enc_control_val); - } - if ((encoder->dynamic_prop_change & DDL_ENC_CHANGE_BITRATE)) { - vidc_720p_encode_set_bit_rate( - encoder->target_bit_rate.target_bitrate); - enc_param_change |= VIDC_720P_ENC_BITRATE_CHANGE; - encoder->dynamic_prop_change &= ~(DDL_ENC_CHANGE_BITRATE); - } - if ((encoder->dynamic_prop_change & DDL_ENC_CHANGE_CIR)) { - vidc_720p_encode_set_intra_refresh_mb_number( - encoder->intra_refresh.cir_mb_number); - encoder->dynamic_prop_change &= ~(DDL_ENC_CHANGE_CIR); - } - if ((encoder->dynamic_prop_change & DDL_ENC_CHANGE_IPERIOD)) { - vidc_720p_encode_set_i_period - (encoder->i_period.p_frames); - enc_param_change |= VIDC_720P_ENC_IPERIOD_CHANGE; - encoder->dynamic_prop_change &= ~(DDL_ENC_CHANGE_IPERIOD); - } - if ((encoder->dynamic_prop_change & - DDL_ENC_CHANGE_FRAMERATE)) { - vidc_720p_encode_set_fps - ((encoder->frame_rate.fps_numerator * 1000) / - encoder->frame_rate.fps_denominator); - enc_param_change |= VIDC_720P_ENC_FRAMERATE_CHANGE; - encoder->dynamic_prop_change &= ~(DDL_ENC_CHANGE_FRAMERATE); - } - if (enc_param_change) - vidc_720p_encoder_set_param_change(enc_param_change); -} - -static void ddl_encode_set_profile_level(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - u32 profile; - u32 level; - - switch (encoder->profile.profile) { - default: - case VCD_PROFILE_MPEG4_SP: - { - profile = VIDC_720P_PROFILE_MPEG4_SP; - break; - } - case VCD_PROFILE_MPEG4_ASP: - { - profile = VIDC_720P_PROFILE_MPEG4_ASP; - break; - } - case VCD_PROFILE_H264_BASELINE: - { - profile = VIDC_720P_PROFILE_H264_CPB; - break; - } - case VCD_PROFILE_H264_MAIN: - { - profile = VIDC_720P_PROFILE_H264_MAIN; - break; - } - case VCD_PROFILE_H264_HIGH: - { - profile = VIDC_720P_PROFILE_H264_HIGH; - break; - } - case VCD_PROFILE_H263_BASELINE: - { - profile = VIDC_720P_PROFILE_H263_BASELINE; - break; - } - } - switch (encoder->level.level) { - default: - case VCD_LEVEL_MPEG4_0: - { - level = VIDC_720P_MPEG4_LEVEL0; - break; - } - case VCD_LEVEL_MPEG4_0b: - { - level = VIDC_720P_MPEG4_LEVEL0b; - break; - } - case VCD_LEVEL_MPEG4_1: - { - level = VIDC_720P_MPEG4_LEVEL1; - break; - } - case VCD_LEVEL_MPEG4_2: - { - level = VIDC_720P_MPEG4_LEVEL2; - break; - } - case VCD_LEVEL_MPEG4_3: - { - level = VIDC_720P_MPEG4_LEVEL3; - break; - } - case VCD_LEVEL_MPEG4_3b: - { - level = VIDC_720P_MPEG4_LEVEL3b; - break; - } - - case VCD_LEVEL_MPEG4_4: - case VCD_LEVEL_MPEG4_4a: - { - level = VIDC_720P_MPEG4_LEVEL4a; - break; - } - case VCD_LEVEL_MPEG4_5: - { - level = VIDC_720P_MPEG4_LEVEL5; - break; - } - case VCD_LEVEL_MPEG4_6: - { - level = VIDC_720P_MPEG4_LEVEL6; - break; - } - case VCD_LEVEL_H264_1: - { - level = VIDC_720P_H264_LEVEL1; - break; - } - case VCD_LEVEL_H264_1b: - { - level = VIDC_720P_H264_LEVEL1b; - break; - } - case VCD_LEVEL_H264_1p1: - { - level = VIDC_720P_H264_LEVEL1p1; - break; - } - case VCD_LEVEL_H264_1p2: - { - level = VIDC_720P_H264_LEVEL1p2; - break; - } - case VCD_LEVEL_H264_1p3: - { - level = VIDC_720P_H264_LEVEL1p3; - break; - } - case VCD_LEVEL_H264_2: - { - level = VIDC_720P_H264_LEVEL2; - break; - } - case VCD_LEVEL_H264_2p1: - { - level = VIDC_720P_H264_LEVEL2p1; - break; - } - case VCD_LEVEL_H264_2p2: - { - level = VIDC_720P_H264_LEVEL2p2; - break; - } - case VCD_LEVEL_H264_3: - { - level = VIDC_720P_H264_LEVEL3; - break; - } - case VCD_LEVEL_H264_3p1: - { - level = VIDC_720P_H264_LEVEL3p1; - break; - } - case VCD_LEVEL_H263_10: - { - level = VIDC_720P_H263_LEVEL10; - break; - } - case VCD_LEVEL_H263_20: - { - level = VIDC_720P_H263_LEVEL20; - break; - } - case VCD_LEVEL_H263_30: - { - level = VIDC_720P_H263_LEVEL30; - break; - } - case VCD_LEVEL_H263_40: - { - level = VIDC_720P_H263_LEVEL40; - break; - } - case VCD_LEVEL_H263_45: - { - level = VIDC_720P_H263_LEVEL45; - break; - } - case VCD_LEVEL_H263_50: - { - level = VIDC_720P_H263_LEVEL50; - break; - } - case VCD_LEVEL_H263_60: - { - level = VIDC_720P_H263_LEVEL60; - break; - } - case VCD_LEVEL_H263_70: - { - level = VIDC_720P_H263_LEVEL70; - break; - } - } - vidc_720p_encode_set_profile(profile, level); -} - -void ddl_encode_init_codec(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - enum vidc_720p_memory_access_method mem_access_method; - enum vidc_720p_DBConfig db_config; - enum vidc_720p_MSlice_selection m_slice_sel; - - ddl_encode_set_profile_level(ddl); - - vidc_720p_set_frame_size - (encoder->frame_size.width, encoder->frame_size.height); - vidc_720p_encode_set_qp_params - (encoder->qp_range.max_qp, encoder->qp_range.min_qp); - vidc_720p_encode_set_rc_config - (encoder->rc_level.frame_level_rc, - encoder->rc_level.mb_level_rc, - encoder->session_qp.i_frame_qp, - encoder->session_qp.p_frame_qp); - - if (encoder->r_cframe_skip) { - if (encoder->vb_vbuffer_size) { - encoder->ext_enc_control_val = (0x2 << 0x2) | - (encoder->vb_vbuffer_size << 0x10); - } else - encoder->ext_enc_control_val = (0x1 << 2); - } else - encoder->ext_enc_control_val = 0; - - vidc_720p_encode_set_fps - ((encoder->frame_rate.fps_numerator * 1000) / - encoder->frame_rate.fps_denominator); - - vidc_720p_encode_set_vop_time( - encoder->vop_timing.vop_time_resolution, 0); - - if (encoder->rc_level.frame_level_rc) { - vidc_720p_encode_set_bit_rate - (encoder->target_bit_rate.target_bitrate); - - vidc_720p_encode_set_frame_level_rc_params - (encoder->frame_level_rc.reaction_coeff); - } - if (encoder->rc_level.mb_level_rc) { - vidc_720p_encode_set_mb_level_rc_params - (encoder->adaptive_rc.dark_region_as_flag, - encoder->adaptive_rc.smooth_region_as_flag, - encoder->adaptive_rc.static_region_as_flag, - encoder->adaptive_rc.activity_region_flag); - } - if (encoder->codec.codec == VCD_CODEC_MPEG4) { - vidc_720p_encode_set_short_header - (encoder->short_header.short_header); - - if (encoder->hdr_ext_control) { - vidc_720p_encode_set_hec_period - (encoder->hdr_ext_control); - encoder->ext_enc_control_val |= (0x1 << 0x1); - } - } - /* set extended encoder control settings */ - vidc_720p_encode_set_control_param - (encoder->ext_enc_control_val); - - if (encoder->codec.codec == VCD_CODEC_H264) { - enum vidc_720p_entropy_sel entropy_sel; - enum vidc_720p_cabac_model cabac_model_number; - switch (encoder->entropy_control.entropy_sel) { - default: - case VCD_ENTROPY_SEL_CAVLC: - { - entropy_sel = VIDC_720P_ENTROPY_SEL_CAVLC; - break; - } - case VCD_ENTROPY_SEL_CABAC: - { - entropy_sel = VIDC_720P_ENTROPY_SEL_CABAC; - break; - } - } - switch (encoder->entropy_control.cabac_model) { - default: - case VCD_CABAC_MODEL_NUMBER_0: - { - cabac_model_number = - VIDC_720P_CABAC_MODEL_NUMBER_0; - break; - } - case VCD_CABAC_MODEL_NUMBER_1: - { - cabac_model_number = - VIDC_720P_CABAC_MODEL_NUMBER_1; - break; - } - case VCD_CABAC_MODEL_NUMBER_2: - { - cabac_model_number = - VIDC_720P_CABAC_MODEL_NUMBER_2; - break; - } - } - vidc_720p_encode_set_entropy_control - (entropy_sel, cabac_model_number); - switch (encoder->db_control.db_config) { - default: - case VCD_DB_ALL_BLOCKING_BOUNDARY: - { - db_config = - VIDC_720P_DB_ALL_BLOCKING_BOUNDARY; - break; - } - case VCD_DB_DISABLE: - { - db_config = - VIDC_720P_DB_DISABLE; - break; - } - case VCD_DB_SKIP_SLICE_BOUNDARY: - { - db_config = - VIDC_720P_DB_SKIP_SLICE_BOUNDARY; - break; - } - } - vidc_720p_encode_set_db_filter_control - (db_config, - encoder->db_control.slice_alpha_offset, - encoder->db_control.slice_beta_offset); - } - - vidc_720p_encode_set_intra_refresh_mb_number - (encoder->intra_refresh.cir_mb_number); - - switch (encoder->multi_slice.m_slice_sel) { - default: - case VCD_MSLICE_OFF: - m_slice_sel = VIDC_720P_MSLICE_OFF; - break; - case VCD_MSLICE_BY_MB_COUNT: - { - m_slice_sel = VIDC_720P_MSLICE_BY_MB_COUNT; - break; - } - case VCD_MSLICE_BY_BYTE_COUNT: - { - m_slice_sel = VIDC_720P_MSLICE_BY_BYTE_COUNT; - break; - } - case VCD_MSLICE_BY_GOB: - { - m_slice_sel = VIDC_720P_MSLICE_BY_GOB; - break; - } - } - vidc_720p_encode_set_multi_slice_info - (m_slice_sel, encoder->multi_slice.m_slice_size); - - vidc_720p_encode_set_dpb_buffer - (encoder->enc_dpb_addr.align_physical_addr, - encoder->enc_dpb_addr.buffer_size); - - VIDC_LOG1("ENC_DPB_ADDR_SIZE", encoder->enc_dpb_addr.buffer_size); - - vidc_720p_encode_set_i_period(encoder->i_period.p_frames); - - ddl_metadata_enable(ddl); - - if (encoder->seq_header.virtual_base_addr) { - u32 ext_buffer_start, ext_buffer_end, start_byte_num; - ext_buffer_start = - (u32) encoder->seq_header.align_physical_addr; - ext_buffer_end = - ext_buffer_start + encoder->seq_header.buffer_size; - start_byte_num = - (ext_buffer_start & DDL_STREAMBUF_ALIGN_GUARD_BYTES); - ext_buffer_start &= ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - ext_buffer_end &= ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - VIDC_LOG1("ENC_SEQHDR_ALLOC_SIZE", - encoder->seq_header.buffer_size); - vidc_720p_encode_set_seq_header_buffer(ext_buffer_start, - ext_buffer_end, - start_byte_num); - } - - if (encoder->re_con_buf_format.buffer_format == - VCD_BUFFER_FORMAT_NV12) - mem_access_method = VIDC_720P_TILE_LINEAR; - else - mem_access_method = VIDC_720P_TILE_16x16; - - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE); - ddl_move_command_state(ddl->ddl_context, DDL_CMD_INIT_CODEC); - - vidc_720p_encode_init_codec(ddl->channel_id, mem_access_method); -} - -void ddl_channel_end(struct ddl_client_context *ddl) -{ - VIDC_DEBUG_REGISTER_LOG; - - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_CHEND); - ddl_move_command_state(ddl->ddl_context, DDL_CMD_CHANNEL_END); - - vidc_720p_submit_command(ddl->channel_id, VIDC_720P_CMD_CHEND); -} - -void ddl_encode_frame_run(struct ddl_client_context *ddl) -{ - u32 ext_buffer_start, ext_buffer_end; - u32 y_addr, c_addr; - u32 start_byte_number = 0; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct vcd_frame_data *stream = &(ddl->output_frame.vcd_frm); - - ext_buffer_start = (u32) stream->physical + stream->offset; - ext_buffer_end = ddl_encode_set_metadata_output_buf(ddl); - start_byte_number = - (ext_buffer_start & DDL_STREAMBUF_ALIGN_GUARD_BYTES); - if (start_byte_number) { - u32 upper_data, lower_data; - u32 *align_virtual_addr; - ext_buffer_start &= ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - align_virtual_addr = (u32 *) (((u32) stream->virtual + - stream->offset) - - start_byte_number); - upper_data = *align_virtual_addr; - align_virtual_addr++; - lower_data = *align_virtual_addr; - vidc_720p_encode_unalign_bitstream(upper_data, lower_data); - } - - y_addr = (u32) ddl->input_frame.vcd_frm.physical + - ddl->input_frame.vcd_frm.offset; - c_addr = (y_addr + (encoder->frame_size.scan_lines * - encoder->frame_size.stride)); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE); - ddl_move_command_state(ddl->ddl_context, DDL_CMD_ENCODE_FRAME); - - if (encoder->dynamic_prop_change) { - encoder->dynmic_prop_change_req = true; - ddl_encode_dynamic_property(ddl, true); - } - vidc_720p_encode_set_vop_time( - encoder->vop_timing.vop_time_resolution, - ddl->input_frame.frm_delta - ); - - vidc_720p_encode_frame(ddl->channel_id, - ext_buffer_start, - ext_buffer_end, - start_byte_number, y_addr, c_addr); -} - -u32 ddl_decode_set_buffers(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - u32 comv_buf_size = DDL_COMV_BUFLINE_NO, comv_buf_no = 0; - u32 ref_buf_no = 0; - struct ddl_context *ddl_ctxt = NULL; - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) { - VIDC_LOG_STRING("STATE-CRITICAL"); - return VCD_ERR_FAIL; - } - if (vidc_msg_timing) - ddl_set_core_start_time(__func__, DEC_OP_TIME); - switch (decoder->codec.codec) { - default: - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_XVID: - case VCD_CODEC_MPEG2: - case VCD_CODEC_MPEG4: - { - comv_buf_no = DDL_MPEG_COMV_BUF_NO; - ref_buf_no = DDL_MPEG_REFBUF_COUNT; - break; - } - case VCD_CODEC_H263: - { - comv_buf_no = DDL_H263_COMV_BUF_NO; - break; - } - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - { - comv_buf_no = - decoder->client_output_buf_req.actual_count + 1; - comv_buf_size = DDL_VC1_COMV_BUFLINE_NO; - break; - } - case VCD_CODEC_H264: - { - if (decoder->idr_only_decoding) - comv_buf_no = decoder->min_dpb_num; - else - comv_buf_no = - decoder-> - client_output_buf_req. - actual_count; - break; - } - } - - if (comv_buf_no) { - comv_buf_size *= (comv_buf_no * - (decoder->client_frame_size.stride >> 4) * - ((decoder->client_frame_size.scan_lines >> 4) + 1)); - if (decoder->dpb_comv_buffer.virtual_base_addr) - ddl_pmem_free(&decoder->dpb_comv_buffer); - ddl_pmem_alloc(&decoder->dpb_comv_buffer, comv_buf_size, - DDL_LINEAR_BUFFER_ALIGN_BYTES); - if (!decoder->dpb_comv_buffer.virtual_base_addr) { - VIDC_LOGERR_STRING - ("Dec_set_buf:Comv_buf_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - vidc_720p_decode_set_comv_buffer(decoder->dpb_comv_buffer. - align_physical_addr, - decoder->dpb_comv_buffer. - buffer_size); - } - decoder->ref_buffer.align_physical_addr = NULL; - if (ref_buf_no) { - size_t sz, align_bytes, y_sz, frm_sz; - u32 i = 0; - sz = decoder->dp_buf.dec_pic_buffers[0].vcd_frm.alloc_len; - frm_sz = sz; - y_sz = decoder->client_frame_size.height * - decoder->client_frame_size.width; - sz *= ref_buf_no; - align_bytes = decoder->client_output_buf_req.align; - if (decoder->ref_buffer.virtual_base_addr) - ddl_pmem_free(&decoder->ref_buffer); - ddl_pmem_alloc(&decoder->ref_buffer, sz, align_bytes); - if (!decoder->ref_buffer.virtual_base_addr) { - ddl_pmem_free(&decoder->dpb_comv_buffer); - VIDC_LOGERR_STRING - ("Dec_set_buf:mpeg_ref_buf_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - memset((u8 *)decoder->ref_buffer.virtual_base_addr, - 0x80, sz); - for (i = 0; i < ref_buf_no; i++) - memset((u8 *)decoder->ref_buffer.align_virtual_addr + - i*frm_sz, 0x10, y_sz); - } - ddl_decode_set_metadata_output(decoder); - ddl_decoder_dpb_transact(decoder, NULL, DDL_DPB_OP_INIT); - ddl_ctxt = ddl_get_context(); - vidc_720p_set_deblock_line_buffer( - ddl_ctxt->db_line_buffer.align_physical_addr, - ddl_ctxt->db_line_buffer.buffer_size); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_DPBDONE); - ddl_move_command_state(ddl->ddl_context, DDL_CMD_DECODE_SET_DPB); - - vidc_720p_submit_command(ddl->channel_id, - VIDC_720P_CMD_INITBUFFERS); - return VCD_S_SUCCESS; -} - -void ddl_decode_frame_run(struct ddl_client_context *ddl) -{ - u32 ext_buffer_start = 0, ext_buffer_end = 0; - u32 start_byte_num = 8; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - struct vcd_frame_data *bit_stream = - &(ddl->input_frame.vcd_frm); - if (vidc_msg_timing) { - ddl_set_core_start_time(__func__, DEC_OP_TIME); - ddl_set_core_start_time(__func__, DEC_IP_TIME); - } - if (!bit_stream->data_len || - !bit_stream->physical) { - ddl_decode_eos_run(ddl); - return; - } - - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE); - - ddl_decode_dynamic_property(ddl, true); - - ddl_decoder_dpb_transact(decoder, NULL, DDL_DPB_OP_SET_MASK); - - ext_buffer_start = (u32)bit_stream->physical + - bit_stream->offset; - start_byte_num = 8 - (ext_buffer_start & - DDL_STREAMBUF_ALIGN_GUARD_BYTES); - ext_buffer_end = ext_buffer_start + bit_stream->data_len; - ext_buffer_start &= ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - DDL_PADDING_HACK(ext_buffer_end); - - ddl_move_command_state(ddl->ddl_context, DDL_CMD_DECODE_FRAME); - - vidc_720p_decode_frame(ddl->channel_id, - ext_buffer_start, - ext_buffer_end, - bit_stream->data_len, - start_byte_num, bit_stream->ip_frm_tag); -} - -void ddl_decode_eos_run(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE); - - ddl_decode_dynamic_property(ddl, true); - - ddl_decoder_dpb_transact(decoder, NULL, DDL_DPB_OP_SET_MASK); - - decoder->dynmic_prop_change_req = true; - - ddl_move_command_state(ddl->ddl_context, DDL_CMD_EOS); - - vidc_720p_issue_eos(ddl->channel_id); -} - -u32 ddl_hal_engine_reset(struct ddl_context *ddl_context) -{ - u32 eng_reset; - u32 channel_id = 0; - u32 fw_endianness; - enum vidc_720p_endian dma_endian; - enum vidc_720p_interrupt_level_selection interrupt_sel; - u32 intr_mask = 0x0; - - if (ddl_context->current_ddl) - channel_id = ddl_context->current_ddl->channel_id; - - interrupt_sel = VIDC_720P_INTERRUPT_LEVEL_SEL; - /* Enable all the supported interrupt */ - intr_mask |= VIDC_720P_INTR_BUFFER_FULL; - intr_mask |= VIDC_720P_INTR_FW_DONE; - intr_mask |= VIDC_720P_INTR_DMA_DONE; - intr_mask |= VIDC_720P_INTR_FRAME_DONE; - - vcd_get_fw_property(VCD_FW_ENDIAN, &fw_endianness); - /* Reverse the endianness settings after boot code download */ - if (fw_endianness == VCD_FW_BIG_ENDIAN) - dma_endian = VIDC_720P_LITTLE_ENDIAN; - else - dma_endian = VIDC_720P_BIG_ENDIAN; - - /* Need to reset MFC silently */ - eng_reset = vidc_720p_engine_reset( - channel_id, - dma_endian, interrupt_sel, - intr_mask); - if (!eng_reset) { - /* call the hw fatal callback if engine reset fails */ - ddl_hw_fatal_cb(ddl_context); - } - return eng_reset ; -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_helper.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_helper.c deleted file mode 100644 index b97fae6a32f7669081bef5154de8e7c8081e90bb..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_helper.c +++ /dev/null @@ -1,297 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vcd_ddl_utils.h" - -DDL_INLINE struct ddl_context *ddl_get_context(void) -{ - static struct ddl_context ddl_context; - return &ddl_context; -} - -DDL_INLINE void ddl_move_client_state(struct ddl_client_context *ddl, - enum ddl_client_state client_state) -{ - ddl->client_state = client_state; -} - -DDL_INLINE void ddl_move_command_state(struct ddl_context *ddl_context, - enum ddl_cmd_state command_state) -{ - ddl_context->cmd_state = command_state; -} - -u32 ddl_client_transact(u32 operation, - struct ddl_client_context **pddl_client) -{ - u32 ret_status = VCD_ERR_FAIL; - u32 counter; - struct ddl_context *ddl_context; - - ddl_context = ddl_get_context(); - switch (operation) { - case DDL_FREE_CLIENT: - { - if (pddl_client && *pddl_client) { - u32 channel_id; - channel_id = (*pddl_client)->channel_id; - if (channel_id < VCD_MAX_NO_CLIENT) { - ddl_context-> - ddl_clients[channel_id] = NULL; - } else { - VIDC_LOG_STRING("CHID_CORRUPTION"); - } - DDL_FREE(*pddl_client); - ret_status = VCD_S_SUCCESS; - } - break; - } - case DDL_GET_CLIENT: - { - ret_status = VCD_ERR_MAX_CLIENT; - for (counter = 0; counter < VCD_MAX_NO_CLIENT && - ret_status == VCD_ERR_MAX_CLIENT; ++counter) { - if (!ddl_context->ddl_clients[counter]) { - *pddl_client = - (struct ddl_client_context *) - DDL_MALLOC(sizeof - (struct ddl_client_context) - ); - if (!*pddl_client) { - ret_status = VCD_ERR_ALLOC_FAIL; - } else { - DDL_MEMSET(*pddl_client, 0, - sizeof(struct - ddl_client_context)); - ddl_context-> - ddl_clients[counter] = - *pddl_client; - (*pddl_client)->channel_id = - counter; - (*pddl_client)->ddl_context = - ddl_context; - ret_status = VCD_S_SUCCESS; - } - } - } - break; - } - case DDL_INIT_CLIENTS: - { - for (counter = 0; counter < VCD_MAX_NO_CLIENT; - ++counter) { - ddl_context->ddl_clients[counter] = NULL; - } - ret_status = VCD_S_SUCCESS; - break; - } - case DDL_ACTIVE_CLIENT: - { - for (counter = 0; counter < VCD_MAX_NO_CLIENT; - ++counter) { - if (ddl_context->ddl_clients[counter]) { - ret_status = VCD_S_SUCCESS; - break; - } - } - break; - } - default: - { - ret_status = VCD_ERR_ILLEGAL_PARM; - break; - } - } - return ret_status; -} - -u32 ddl_decoder_dpb_transact(struct ddl_decoder_data *decoder, - struct ddl_frame_data_tag *in_out_frame, - u32 operation) -{ - u32 vcd_status = VCD_S_SUCCESS; - u32 loopc; - struct ddl_frame_data_tag *found_frame = NULL; - struct ddl_mask *dpb_mask = &decoder->dpb_mask; - u32 temp_mask; - - switch (operation) { - case DDL_DPB_OP_MARK_BUSY: - case DDL_DPB_OP_MARK_FREE: - { - for (loopc = 0; !found_frame && - loopc < decoder->dp_buf.no_of_dec_pic_buf; - ++loopc) { - if (in_out_frame->vcd_frm.physical == - decoder->dp_buf. - dec_pic_buffers[loopc].vcd_frm. - physical) { - found_frame = - &(decoder->dp_buf. - dec_pic_buffers[loopc]); - break; - } - } - - if (found_frame) { - if (operation == DDL_DPB_OP_MARK_BUSY) { - temp_mask = (~(0x1 << loopc)); - if (decoder->idr_only_decoding) - temp_mask = ~(0xffffffff); - dpb_mask->hw_mask &= temp_mask; - *in_out_frame = *found_frame; - } else if (operation == - DDL_DPB_OP_MARK_FREE) { - temp_mask = (0x1 << loopc); - if (decoder->idr_only_decoding) - temp_mask = 0xffffffff; - dpb_mask->client_mask |= temp_mask; - *found_frame = *in_out_frame; - } - } else { - in_out_frame->vcd_frm.physical = NULL; - in_out_frame->vcd_frm.virtual = NULL; - vcd_status = VCD_ERR_BAD_POINTER; - VIDC_LOG_STRING("BUF_NOT_FOUND"); - } - break; - } - case DDL_DPB_OP_SET_MASK: - { - dpb_mask->hw_mask |= dpb_mask->client_mask; - dpb_mask->client_mask = 0; - vidc_720p_decode_set_dpb_release_buffer_mask - (dpb_mask->hw_mask); - break; - } - case DDL_DPB_OP_INIT: - { - u32 dpb_size, index, num_dpb; - dpb_size = (!decoder->meta_data_offset) ? - decoder->dp_buf.dec_pic_buffers[0].vcd_frm. - alloc_len : decoder->meta_data_offset; - if (decoder->idr_only_decoding) - num_dpb = decoder->min_dpb_num; - else - num_dpb = decoder->dp_buf.no_of_dec_pic_buf; - vidc_720p_decode_set_dpb_details( - num_dpb, - dpb_size, - decoder->ref_buffer. - align_physical_addr); - for (loopc = 0; loopc < num_dpb; ++loopc) { - if (decoder->idr_only_decoding) - index = 0; - else - index = loopc; - vidc_720p_decode_set_dpb_buffers(loopc, - (u32 *) - decoder-> - dp_buf. - dec_pic_buffers - [index]. - vcd_frm. - physical); - VIDC_LOG1("DEC_DPB_BUFn_SIZE=%d", - decoder->dp_buf. - dec_pic_buffers[index].vcd_frm. - alloc_len); - } - break; - } - case DDL_DPB_OP_RETRIEVE: - { - u32 position; - if (dpb_mask->client_mask) { - position = 0x1; - for (loopc = 0; - loopc < - decoder->dp_buf.no_of_dec_pic_buf - && !found_frame; ++loopc) { - if (dpb_mask-> - client_mask & position) { - found_frame = - &decoder->dp_buf. - dec_pic_buffers[loopc]; - dpb_mask->client_mask &= - ~(position); - } - position <<= 1; - } - } else if (dpb_mask->hw_mask) { - position = 0x1; - for (loopc = 0; - loopc < - decoder->dp_buf.no_of_dec_pic_buf - && !found_frame; ++loopc) { - if (dpb_mask->hw_mask - & position) { - found_frame = - &decoder->dp_buf. - dec_pic_buffers[loopc]; - dpb_mask->hw_mask &= - ~(position); - } - position <<= 1; - } - } - if (found_frame) - *in_out_frame = *found_frame; - else { - in_out_frame->vcd_frm.physical = NULL; - in_out_frame->vcd_frm.virtual = NULL; - } - break; - } - } - return vcd_status; -} - -void ddl_release_context_buffers(struct ddl_context *ddl_context) -{ - ddl_pmem_free(&ddl_context->context_buf_addr); - ddl_pmem_free(&ddl_context->db_line_buffer); - ddl_pmem_free(&ddl_context->data_partition_tempbuf); - ddl_pmem_free(&ddl_context->metadata_shared_input); - ddl_pmem_free(&ddl_context->dbg_core_dump); - - vcd_fw_release(); -} - -void ddl_release_client_internal_buffers(struct ddl_client_context *ddl) -{ - if (ddl->decoding) { - struct ddl_decoder_data *decoder = - &(ddl->codec_data.decoder); - ddl_pmem_free(&decoder->h264Vsp_temp_buffer); - ddl_pmem_free(&decoder->dpb_comv_buffer); - ddl_pmem_free(&decoder->ref_buffer); - DDL_FREE(decoder->dp_buf.dec_pic_buffers); - ddl_decode_dynamic_property(ddl, false); - decoder->decode_config.sequence_header_len = 0; - decoder->decode_config.sequence_header = NULL; - decoder->dpb_mask.client_mask = 0; - decoder->dpb_mask.hw_mask = 0; - decoder->dp_buf.no_of_dec_pic_buf = 0; - decoder->dynamic_prop_change = 0; - - } else { - struct ddl_encoder_data *encoder = - &(ddl->codec_data.encoder); - ddl_pmem_free(&encoder->enc_dpb_addr); - ddl_pmem_free(&encoder->seq_header); - ddl_encode_dynamic_property(ddl, false); - encoder->dynamic_prop_change = 0; - } -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_internal_property.h b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_internal_property.h deleted file mode 100644 index 32a40477581dc9c99145379817d0d50e1e6f2f4e..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_internal_property.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DDL_INTERNAL_PROPERTY_H_ -#define _VCD_DDL_INTERNAL_PROPERTY_H_ -#include - -#define VCD_EVT_RESP_DDL_BASE 0x3000 -#define VCD_EVT_RESP_DEVICE_INIT (VCD_EVT_RESP_DDL_BASE + 0x1) -#define VCD_EVT_RESP_OUTPUT_REQ (VCD_EVT_RESP_DDL_BASE + 0x2) -#define VCD_EVT_RESP_EOS_DONE (VCD_EVT_RESP_DDL_BASE + 0x3) -#define VCD_EVT_RESP_TRANSACTION_PENDING (VCD_EVT_RESP_DDL_BASE + 0x4) - -#define VCD_S_DDL_ERR_BASE 0x90000000 -#define VCD_ERR_MAX_NO_CODEC (VCD_S_DDL_ERR_BASE + 0x1) -#define VCD_ERR_CLIENT_PRESENT (VCD_S_DDL_ERR_BASE + 0x2) -#define VCD_ERR_CLIENT_FATAL (VCD_S_DDL_ERR_BASE + 0x3) - -#define VCD_I_CUSTOM_BASE (VCD_I_RESERVED_BASE) -#define VCD_I_RC_LEVEL_CONFIG (VCD_I_CUSTOM_BASE + 0x1) -#define VCD_I_FRAME_LEVEL_RC (VCD_I_CUSTOM_BASE + 0x2) -#define VCD_I_ADAPTIVE_RC (VCD_I_CUSTOM_BASE + 0x3) -#define VCD_I_CUSTOM_DDL_BASE (VCD_I_RESERVED_BASE + 0x100) -#define DDL_I_INPUT_BUF_REQ (VCD_I_CUSTOM_DDL_BASE + 0x1) -#define DDL_I_OUTPUT_BUF_REQ (VCD_I_CUSTOM_DDL_BASE + 0x2) -#define DDL_I_DPB (VCD_I_CUSTOM_DDL_BASE + 0x3) -#define DDL_I_DPB_RELEASE (VCD_I_CUSTOM_DDL_BASE + 0x4) -#define DDL_I_DPB_RETRIEVE (VCD_I_CUSTOM_DDL_BASE + 0x5) -#define DDL_I_REQ_OUTPUT_FLUSH (VCD_I_CUSTOM_DDL_BASE + 0x6) -#define DDL_I_SEQHDR_ALIGN_BYTES (VCD_I_CUSTOM_DDL_BASE + 0x7) -#define DDL_I_SEQHDR_PRESENT (VCD_I_CUSTOM_DDL_BASE + 0xb) -#define DDL_I_CAPABILITY (VCD_I_CUSTOM_DDL_BASE + 0x8) -#define DDL_I_FRAME_PROC_UNITS (VCD_I_CUSTOM_DDL_BASE + 0x9) - -struct vcd_property_rc_level { - u32 frame_level_rc; - u32 mb_level_rc; -}; - -struct vcd_property_frame_level_rc_params { - u32 reaction_coeff; -}; - -struct vcd_property_adaptive_rc_params { - u32 dark_region_as_flag; - u32 smooth_region_as_flag; - u32 static_region_as_flag; - u32 activity_region_flag; -}; - -struct vcd_property_slice_delivery_info { - u32 enable; - u32 num_slices; - u32 num_slices_enc; -}; - -struct ddl_frame_data_tag; - -struct ddl_property_dec_pic_buffers { - struct ddl_frame_data_tag *dec_pic_buffers; - u32 no_of_dec_pic_buf; -}; - -struct ddl_property_capability { - u32 max_num_client; - u32 general_command_depth; - u32 frame_command_depth; - u32 exclusive; - u32 ddl_time_out_in_ms; -}; - -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_interrupt_handler.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_interrupt_handler.c deleted file mode 100644 index 817a98e7beaf5a9918d864e2158565057de01aff..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_interrupt_handler.c +++ /dev/null @@ -1,1128 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vidc.h" -#include "vcd_ddl_utils.h" -#include "vcd_ddl_metadata.h" - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -static void ddl_decoder_input_done_callback( - struct ddl_client_context *ddl, u32 frame_transact_end); -static u32 ddl_decoder_output_done_callback( - struct ddl_client_context *ddl, u32 frame_transact_end); - -static u32 ddl_get_frame - (struct vcd_frame_data *frame, u32 frame_type); - -static void ddl_getdec_profilelevel -(struct ddl_decoder_data *decoder, u32 profile, u32 level); - -static void ddl_dma_done_callback(struct ddl_context *ddl_context) -{ - if (!DDLCOMMAND_STATE_IS(ddl_context, DDL_CMD_DMA_INIT)) { - VIDC_LOGERR_STRING("UNKWN_DMADONE"); - return; - } - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - VIDC_LOG_STRING("DMA_DONE"); - ddl_core_start_cpu(ddl_context); -} - -static void ddl_cpu_started_callback(struct ddl_context *ddl_context) -{ - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - VIDC_LOG_STRING("CPU-STARTED"); - - if (!vidc_720p_cpu_start()) { - ddl_hw_fatal_cb(ddl_context); - return; - } - - vidc_720p_set_deblock_line_buffer( - ddl_context->db_line_buffer.align_physical_addr, - ddl_context->db_line_buffer.buffer_size); - ddl_context->device_state = DDL_DEVICE_INITED; - ddl_context->ddl_callback(VCD_EVT_RESP_DEVICE_INIT, VCD_S_SUCCESS, - NULL, 0, NULL, ddl_context->client_data); - DDL_IDLE(ddl_context); -} - - -static u32 ddl_eos_done_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - u32 displaystatus, resl_change; - - if (!DDLCOMMAND_STATE_IS(ddl_context, DDL_CMD_EOS)) { - VIDC_LOGERR_STRING("UNKWN_EOSDONE"); - ddl_client_fatal_cb(ddl_context); - return true; - } - - if (!ddl || - !ddl->decoding || - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE) - ) { - VIDC_LOG_STRING("STATE-CRITICAL-EOSDONE"); - ddl_client_fatal_cb(ddl_context); - return true; - } - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - - vidc_720p_eos_info(&displaystatus, &resl_change); - if ((enum vidc_720p_display_status)displaystatus - != VIDC_720P_EMPTY_BUFFER) { - VIDC_LOG_STRING("EOSDONE-EMPTYBUF-ISSUE"); - } - - ddl_decode_dynamic_property(ddl, false); - if (resl_change == 0x1) { - ddl->codec_data.decoder.header_in_start = false; - ddl->codec_data.decoder.decode_config.sequence_header = - ddl->input_frame.vcd_frm.physical; - ddl->codec_data.decoder.decode_config.sequence_header_len = - ddl->input_frame.vcd_frm.data_len; - ddl_decode_init_codec(ddl); - return false; - } - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME); - VIDC_LOG_STRING("EOS_DONE"); - ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE, VCD_S_SUCCESS, - NULL, 0, (u32 *) ddl, ddl_context->client_data); - DDL_IDLE(ddl_context); - - return true; -} - -static u32 ddl_channel_set_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - u32 return_status = false; - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - VIDC_DEBUG_REGISTER_LOG; - - if (!ddl || - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHDONE) - ) { - VIDC_LOG_STRING("STATE-CRITICAL-CHSET"); - DDL_IDLE(ddl_context); - return return_status; - } - VIDC_LOG_STRING("Channel-set"); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC); - - if (ddl->decoding) { - if (vidc_msg_timing) - ddl_calc_core_proc_time(__func__, DEC_OP_TIME); - if (ddl->codec_data.decoder.header_in_start) { - ddl_decode_init_codec(ddl); - } else { - ddl_context->ddl_callback(VCD_EVT_RESP_START, - VCD_S_SUCCESS, NULL, - 0, (u32 *) ddl, - ddl_context->client_data); - - DDL_IDLE(ddl_context); - return_status = true; - } - } else { - ddl_encode_init_codec(ddl); - } - return return_status; -} - -static void ddl_init_codec_done_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - struct ddl_encoder_data *encoder; - - if (!ddl || - ddl->decoding || - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE) - ) { - VIDC_LOG_STRING("STATE-CRITICAL-INITCODEC"); - ddl_client_fatal_cb(ddl_context); - return; - } - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME); - VIDC_LOG_STRING("INIT_CODEC_DONE"); - - encoder = &ddl->codec_data.encoder; - if (encoder->seq_header.virtual_base_addr) { - vidc_720p_encode_get_header(&encoder->seq_header. - buffer_size); - } - - ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS, NULL, - 0, (u32 *) ddl, ddl_context->client_data); - - DDL_IDLE(ddl_context); -} - -static u32 ddl_header_done_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - struct ddl_decoder_data *decoder; - struct vidc_720p_seq_hdr_info seq_hdr_info; - - u32 process_further = true; - u32 seq_hdr_only_frame = false; - u32 need_reconfig = true; - struct vcd_frame_data *input_vcd_frm; - struct ddl_frame_data_tag *reconfig_payload = NULL; - u32 reconfig_payload_size = 0; - - if (!ddl || - !ddl->decoding || - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE) - ) { - VIDC_LOG_STRING("STATE-CRITICAL-HDDONE"); - ddl_client_fatal_cb(ddl_context); - return true; - } - if (vidc_msg_timing) - ddl_calc_core_proc_time(__func__, DEC_OP_TIME); - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_DPB); - VIDC_LOG_STRING("HEADER_DONE"); - VIDC_DEBUG_REGISTER_LOG; - - vidc_720p_decode_get_seq_hdr_info(&seq_hdr_info); - - decoder = &(ddl->codec_data.decoder); - decoder->frame_size.width = seq_hdr_info.img_size_x; - decoder->frame_size.height = seq_hdr_info.img_size_y; - decoder->min_dpb_num = seq_hdr_info.min_num_dpb; - decoder->y_cb_cr_size = seq_hdr_info.min_dpb_size; - decoder->progressive_only = 1 - seq_hdr_info.progressive; - if (!seq_hdr_info.img_size_x || !seq_hdr_info.img_size_y) { - VIDC_LOGERR_STRING("FATAL: ZeroImageSize"); - ddl_client_fatal_cb(ddl_context); - return process_further; - } - if (seq_hdr_info.data_partitioned == 0x1 && - decoder->codec.codec == VCD_CODEC_MPEG4 && - seq_hdr_info.img_size_x > DDL_MAX_DP_FRAME_WIDTH && - seq_hdr_info.img_size_y > DDL_MAX_DP_FRAME_HEIGHT) { - ddl_client_fatal_cb(ddl_context); - return process_further; - } - ddl_getdec_profilelevel(decoder, seq_hdr_info.profile, - seq_hdr_info.level); - ddl_calculate_stride(&decoder->frame_size, - !decoder->progressive_only, - decoder->codec.codec); - if (decoder->buf_format.buffer_format == VCD_BUFFER_FORMAT_TILE_4x2) { - decoder->frame_size.stride = - DDL_TILE_ALIGN(decoder->frame_size.width, - DDL_TILE_ALIGN_WIDTH); - decoder->frame_size.scan_lines = - DDL_TILE_ALIGN(decoder->frame_size.height, - DDL_TILE_ALIGN_HEIGHT); - } - if (seq_hdr_info.crop_exists) { - decoder->frame_size.width -= - (seq_hdr_info.crop_right_offset - + seq_hdr_info.crop_left_offset); - decoder->frame_size.height -= - (seq_hdr_info.crop_top_offset + - seq_hdr_info.crop_bottom_offset); - } - ddl_set_default_decoder_buffer_req(decoder, false); - - if (decoder->header_in_start) { - decoder->client_frame_size = decoder->frame_size; - decoder->client_output_buf_req = - decoder->actual_output_buf_req; - decoder->client_input_buf_req = - decoder->actual_input_buf_req; - ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS, - NULL, 0, (u32 *) ddl, ddl_context->client_data); - DDL_IDLE(ddl_context); - } else { - DBG("%s(): Client data: WxH(%u x %u) SxSL(%u x %u) Sz(%u)\n", - __func__, decoder->client_frame_size.width, - decoder->client_frame_size.height, - decoder->client_frame_size.stride, - decoder->client_frame_size.scan_lines, - decoder->client_output_buf_req.sz); - DBG("%s(): DDL data: WxH(%u x %u) SxSL(%u x %u) Sz(%u)\n", - __func__, decoder->frame_size.width, - decoder->frame_size.height, - decoder->frame_size.stride, - decoder->frame_size.scan_lines, - decoder->actual_output_buf_req.sz); - DBG("%s(): min_dpb_num = %d actual_count = %d\n", __func__, - decoder->min_dpb_num, - decoder->client_output_buf_req.actual_count); - - input_vcd_frm = &(ddl->input_frame.vcd_frm); - - if (decoder->frame_size.width == - decoder->client_frame_size.width - && decoder->frame_size.height == - decoder->client_frame_size.height - && decoder->frame_size.stride == - decoder->client_frame_size.stride - && decoder->frame_size.scan_lines == - decoder->client_frame_size.scan_lines - && decoder->actual_output_buf_req.sz <= - decoder->client_output_buf_req.sz - && decoder->actual_output_buf_req.actual_count <= - decoder->client_output_buf_req.actual_count - && decoder->progressive_only) - need_reconfig = false; - if ((input_vcd_frm->data_len <= seq_hdr_info.dec_frm_size || - (input_vcd_frm->flags & VCD_FRAME_FLAG_CODECCONFIG)) && - (!need_reconfig || - !(input_vcd_frm->flags & VCD_FRAME_FLAG_EOS))) { - input_vcd_frm->flags |= - VCD_FRAME_FLAG_CODECCONFIG; - seq_hdr_only_frame = true; - input_vcd_frm->data_len = 0; - ddl->input_frame.frm_trans_end = !need_reconfig; - ddl_context->ddl_callback( - VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, &ddl->input_frame, - sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, - ddl->ddl_context->client_data); - } else if (decoder->codec.codec != VCD_CODEC_H263) { - input_vcd_frm->offset += seq_hdr_info.dec_frm_size; - input_vcd_frm->data_len -= seq_hdr_info.dec_frm_size; - } - if (need_reconfig) { - decoder->client_frame_size = decoder->frame_size; - decoder->client_output_buf_req = - decoder->actual_output_buf_req; - decoder->client_input_buf_req = - decoder->actual_input_buf_req; - if (!seq_hdr_only_frame) { - reconfig_payload = &ddl->input_frame; - reconfig_payload_size = - sizeof(struct ddl_frame_data_tag); - } - ddl_context->ddl_callback(VCD_EVT_IND_OUTPUT_RECONFIG, - VCD_S_SUCCESS, reconfig_payload, - reconfig_payload_size, - (u32 *) ddl, - ddl_context->client_data); - } - if (!need_reconfig && !seq_hdr_only_frame) { - if (ddl_decode_set_buffers(ddl) == VCD_S_SUCCESS) - process_further = false; - else - ddl_client_fatal_cb(ddl_context); - } else - DDL_IDLE(ddl_context); - } - return process_further; -} - -static u32 ddl_dpb_buffers_set_done_callback(struct ddl_context - *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - if (!ddl || - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPBDONE) - ) { - VIDC_LOG_STRING("STATE-CRITICAL-DPBDONE"); - ddl_client_fatal_cb(ddl_context); - return true; - } - if (vidc_msg_timing) { - ddl_calc_core_proc_time(__func__, DEC_OP_TIME); - ddl_reset_core_time_variables(DEC_OP_TIME); - } - VIDC_LOG_STRING("INTR_DPBDONE"); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME); - ddl->codec_data.decoder.dec_disp_info.img_size_x = 0; - ddl->codec_data.decoder.dec_disp_info.img_size_y = 0; - ddl_decode_frame_run(ddl); - return false; -} - -static void ddl_encoder_frame_run_callback(struct ddl_context - *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - u32 eos_present = false; - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE) - ) { - VIDC_LOG_STRING("STATE-CRITICAL-ENCFRMRUN"); - ddl_client_fatal_cb(ddl_context); - return; - } - - VIDC_LOG_STRING("ENC_FRM_RUN_DONE"); - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - vidc_720p_enc_frame_info(&encoder->enc_frame_info); - - ddl->output_frame.vcd_frm.ip_frm_tag = - ddl->input_frame.vcd_frm.ip_frm_tag; - ddl->output_frame.vcd_frm.data_len = - encoder->enc_frame_info.enc_size; - ddl->output_frame.vcd_frm.flags |= VCD_FRAME_FLAG_ENDOFFRAME; - ddl_get_frame - (&(ddl->output_frame.vcd_frm), - encoder->enc_frame_info.frame); - ddl_process_encoder_metadata(ddl); - - ddl_encode_dynamic_property(ddl, false); - - ddl->input_frame.frm_trans_end = false; - ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE, VCD_S_SUCCESS, - &(ddl->input_frame), sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl_context->client_data); - - if (vidc_msg_timing) - ddl_calc_core_proc_time(__func__, ENC_OP_TIME); - - /* check the presence of EOS */ - eos_present = - ((VCD_FRAME_FLAG_EOS & ddl->input_frame.vcd_frm.flags)); - - ddl->output_frame.frm_trans_end = !eos_present; - ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS, - &(ddl->output_frame), sizeof(struct ddl_frame_data_tag), - (u32 *) ddl, ddl_context->client_data); - - if (eos_present) { - VIDC_LOG_STRING("ENC-EOS_DONE"); - ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE, - VCD_S_SUCCESS, NULL, 0, (u32 *)ddl, - ddl_context->client_data); - } - - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME); - DDL_IDLE(ddl_context); -} - -static u32 ddl_decoder_frame_run_callback(struct ddl_context - *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - struct vidc_720p_dec_disp_info *dec_disp_info = - &(ddl->codec_data.decoder.dec_disp_info); - u32 callback_end = false; - u32 status = true, eos_present = false;; - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE)) { - VIDC_LOG_STRING("STATE-CRITICAL-DECFRMRUN"); - ddl_client_fatal_cb(ddl_context); - return true; - } - - VIDC_LOG_STRING("DEC_FRM_RUN_DONE"); - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - - vidc_720p_decode_display_info(dec_disp_info); - - ddl_decode_dynamic_property(ddl, false); - - if (dec_disp_info->resl_change) { - VIDC_LOG_STRING - ("DEC_FRM_RUN_DONE: RECONFIG"); - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE); - ddl_move_command_state(ddl_context, DDL_CMD_EOS); - vidc_720p_submit_command(ddl->channel_id, - VIDC_720P_CMD_FRAMERUN_REALLOCATE); - return false; - } - - if ((VCD_FRAME_FLAG_EOS & ddl->input_frame.vcd_frm.flags)) { - callback_end = false; - eos_present = true; - } - - - if (dec_disp_info->disp_status == VIDC_720P_DECODE_ONLY || - dec_disp_info->disp_status - == VIDC_720P_DECODE_AND_DISPLAY) { - if (!eos_present) - callback_end = (dec_disp_info->disp_status - == VIDC_720P_DECODE_ONLY); - - ddl_decoder_input_done_callback(ddl, callback_end); - } - - if (dec_disp_info->disp_status == VIDC_720P_DECODE_AND_DISPLAY - || dec_disp_info->disp_status == VIDC_720P_DISPLAY_ONLY) { - if (!eos_present) - callback_end = - (dec_disp_info->disp_status - == VIDC_720P_DECODE_AND_DISPLAY); - - if (ddl_decoder_output_done_callback(ddl, callback_end) - != VCD_S_SUCCESS) - return true; - } - - if (dec_disp_info->disp_status == VIDC_720P_DISPLAY_ONLY || - dec_disp_info->disp_status == VIDC_720P_EMPTY_BUFFER) { - /* send the same input once again for decoding */ - ddl_decode_frame_run(ddl); - /* client need to ignore the interrupt */ - status = false; - } else if (eos_present) { - /* send EOS command to HW */ - ddl_decode_eos_run(ddl); - /* client need to ignore the interrupt */ - status = false; - } else { - ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME); - /* move to Idle */ - DDL_IDLE(ddl_context); - } - return status; -} - -static u32 ddl_eos_frame_done_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl = ddl_context->current_ddl; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vidc_720p_dec_disp_info *dec_disp_info = - &(decoder->dec_disp_info); - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)) { - VIDC_LOGERR_STRING("STATE-CRITICAL-EOSFRMRUN"); - ddl_client_fatal_cb(ddl_context); - return true; - } - VIDC_LOG_STRING("EOS_FRM_RUN_DONE"); - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - - vidc_720p_decode_display_info(dec_disp_info); - - ddl_decode_dynamic_property(ddl, false); - - if (dec_disp_info->disp_status == VIDC_720P_DISPLAY_ONLY) { - if (ddl_decoder_output_done_callback(ddl, false) - != VCD_S_SUCCESS) - return true; - } else - VIDC_LOG_STRING("STATE-CRITICAL-WRONG-DISP-STATUS"); - - ddl_decoder_dpb_transact(decoder, NULL, DDL_DPB_OP_SET_MASK); - ddl_move_command_state(ddl_context, DDL_CMD_EOS); - vidc_720p_submit_command(ddl->channel_id, - VIDC_720P_CMD_FRAMERUN); - return false; -} - -static void ddl_channel_end_callback(struct ddl_context *ddl_context) -{ - struct ddl_client_context *ddl; - - ddl_move_command_state(ddl_context, DDL_CMD_INVALID); - VIDC_LOG_STRING("CH_END_DONE"); - - ddl = ddl_context->current_ddl; - if (!ddl || - !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHEND) - ) { - VIDC_LOG_STRING("STATE-CRITICAL-CHEND"); - DDL_IDLE(ddl_context); - return; - } - - ddl_release_client_internal_buffers(ddl); - ddl_context->ddl_callback(VCD_EVT_RESP_STOP, VCD_S_SUCCESS, - NULL, 0, (u32 *) ddl, ddl_context->client_data); - ddl_move_client_state(ddl, DDL_CLIENT_OPEN); - DDL_IDLE(ddl_context); -} - -static u32 ddl_operation_done_callback(struct ddl_context *ddl_context) -{ - u32 return_status = true; - - switch (ddl_context->cmd_state) { - case DDL_CMD_DECODE_FRAME: - { - return_status = ddl_decoder_frame_run_callback( - ddl_context); - break; - } - case DDL_CMD_ENCODE_FRAME: - { - ddl_encoder_frame_run_callback(ddl_context); - break; - } - case DDL_CMD_CHANNEL_SET: - { - return_status = ddl_channel_set_callback( - ddl_context); - break; - } - case DDL_CMD_INIT_CODEC: - { - ddl_init_codec_done_callback(ddl_context); - break; - } - case DDL_CMD_HEADER_PARSE: - { - return_status = ddl_header_done_callback( - ddl_context); - break; - } - case DDL_CMD_DECODE_SET_DPB: - { - return_status = ddl_dpb_buffers_set_done_callback( - ddl_context); - break; - } - case DDL_CMD_CHANNEL_END: - { - ddl_channel_end_callback(ddl_context); - break; - } - case DDL_CMD_EOS: - { - return_status = ddl_eos_frame_done_callback( - ddl_context); - break; - } - case DDL_CMD_CPU_RESET: - { - ddl_cpu_started_callback(ddl_context); - break; - } - default: - { - VIDC_LOG_STRING("UNKWN_OPDONE"); - return_status = false; - break; - } - } - return return_status; -} - -static u32 ddl_process_intr_status(struct ddl_context *ddl_context, - u32 int_status) -{ - u32 status = true; - switch (int_status) { - case VIDC_720P_INTR_FRAME_DONE: - { - status = ddl_operation_done_callback(ddl_context); - break; - } - case VIDC_720P_INTR_DMA_DONE: - { - ddl_dma_done_callback(ddl_context); - status = false; - break; - } - case VIDC_720P_INTR_FW_DONE: - { - status = ddl_eos_done_callback(ddl_context); - break; - } - case VIDC_720P_INTR_BUFFER_FULL: - { - VIDC_LOGERR_STRING("BUF_FULL_INTR"); - ddl_hw_fatal_cb(ddl_context); - break; - } - default: - { - VIDC_LOGERR_STRING("UNKWN_INTR"); - break; - } - } - return status; -} - -void ddl_read_and_clear_interrupt(void) -{ - struct ddl_context *ddl_context; - - ddl_context = ddl_get_context(); - if (!ddl_context->core_virtual_base_addr) { - VIDC_LOGERR_STRING("SPURIOUS_INTERRUPT"); - return; - } - vidc_720p_get_interrupt_status(&ddl_context->intr_status, - &ddl_context->cmd_err_status, - &ddl_context->disp_pic_err_status, - &ddl_context->op_failed - ); - - vidc_720p_interrupt_done_clear(); - -} - -u32 ddl_process_core_response(void) -{ - struct ddl_context *ddl_context; - u32 return_status = true; - - ddl_context = ddl_get_context(); - if (!ddl_context->core_virtual_base_addr) { - VIDC_LOGERR_STRING("UNKWN_INTR"); - return false; - } - - if (!ddl_handle_core_errors(ddl_context)) { - return_status = ddl_process_intr_status(ddl_context, - ddl_context->intr_status); - } - - if (ddl_context->interrupt_clr) - (*ddl_context->interrupt_clr)(); - - return return_status; -} - -static void ddl_decoder_input_done_callback( - struct ddl_client_context *ddl, u32 frame_transact_end) -{ - struct vidc_720p_dec_disp_info *dec_disp_info = - &(ddl->codec_data.decoder.dec_disp_info); - struct vcd_frame_data *input_vcd_frm = - &(ddl->input_frame.vcd_frm); - ddl_get_frame(input_vcd_frm, dec_disp_info-> - input_frame); - - input_vcd_frm->interlaced = (dec_disp_info-> - input_is_interlace); - - input_vcd_frm->offset += dec_disp_info->input_bytes_consumed; - input_vcd_frm->data_len -= dec_disp_info->input_bytes_consumed; - - ddl->input_frame.frm_trans_end = frame_transact_end; - if (vidc_msg_timing) - ddl_calc_core_proc_time(__func__, DEC_IP_TIME); - ddl->ddl_context->ddl_callback( - VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, - &ddl->input_frame, - sizeof(struct ddl_frame_data_tag), - (void *)ddl, - ddl->ddl_context->client_data); -} - -static u32 ddl_decoder_output_done_callback( - struct ddl_client_context *ddl, - u32 frame_transact_end) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vidc_720p_dec_disp_info *dec_disp_info = - &(decoder->dec_disp_info); - struct ddl_frame_data_tag *output_frame = - &ddl->output_frame; - struct vcd_frame_data *output_vcd_frm = - &(output_frame->vcd_frm); - u32 vcd_status; - u32 free_luma_dpb = 0; - - output_vcd_frm->physical = (u8 *)dec_disp_info->y_addr; - - if (decoder->codec.codec == VCD_CODEC_MPEG4 || - decoder->codec.codec == VCD_CODEC_VC1 || - decoder->codec.codec == VCD_CODEC_VC1_RCV || - (decoder->codec.codec >= VCD_CODEC_DIVX_3 && - decoder->codec.codec <= VCD_CODEC_XVID)){ - vidc_720p_decode_skip_frm_details(&free_luma_dpb); - if (free_luma_dpb) - output_vcd_frm->physical = (u8 *) free_luma_dpb; - } - - - vcd_status = ddl_decoder_dpb_transact( - decoder, - output_frame, - DDL_DPB_OP_MARK_BUSY); - - if (vcd_status != VCD_S_SUCCESS) { - VIDC_LOGERR_STRING("CorruptedOutputBufferAddress"); - ddl_hw_fatal_cb(ddl->ddl_context); - return vcd_status; - } - - output_vcd_frm->ip_frm_tag = dec_disp_info->tag_top; - if (dec_disp_info->crop_exists == 0x1) { - output_vcd_frm->dec_op_prop.disp_frm.left = - dec_disp_info->crop_left_offset; - output_vcd_frm->dec_op_prop.disp_frm.top = - dec_disp_info->crop_top_offset; - output_vcd_frm->dec_op_prop.disp_frm.right = - dec_disp_info->img_size_x - - dec_disp_info->crop_right_offset; - output_vcd_frm->dec_op_prop.disp_frm.bottom = - dec_disp_info->img_size_y - - dec_disp_info->crop_bottom_offset; - } else { - output_vcd_frm->dec_op_prop.disp_frm.left = 0; - output_vcd_frm->dec_op_prop.disp_frm.top = 0; - output_vcd_frm->dec_op_prop.disp_frm.right = - dec_disp_info->img_size_x; - output_vcd_frm->dec_op_prop.disp_frm.bottom = - dec_disp_info->img_size_y; - } - if (!dec_disp_info->disp_is_interlace) { - output_vcd_frm->interlaced = false; - output_vcd_frm->intrlcd_ip_frm_tag = VCD_FRAMETAG_INVALID; - } else { - output_vcd_frm->interlaced = true; - output_vcd_frm->intrlcd_ip_frm_tag = - dec_disp_info->tag_bottom; - } - - output_vcd_frm->offset = 0; - output_vcd_frm->data_len = decoder->y_cb_cr_size; - if (free_luma_dpb) { - output_vcd_frm->data_len = 0; - output_vcd_frm->flags |= VCD_FRAME_FLAG_DECODEONLY; - } - output_vcd_frm->flags |= VCD_FRAME_FLAG_ENDOFFRAME; - ddl_process_decoder_metadata(ddl); - output_frame->frm_trans_end = frame_transact_end; - - if (vidc_msg_timing) - ddl_calc_core_proc_time(__func__, DEC_OP_TIME); - - ddl->ddl_context->ddl_callback( - VCD_EVT_RESP_OUTPUT_DONE, - vcd_status, - output_frame, - sizeof(struct ddl_frame_data_tag), - (void *)ddl, - ddl->ddl_context->client_data); - return vcd_status; -} - -static u32 ddl_get_frame - (struct vcd_frame_data *frame, u32 frametype) { - enum vidc_720p_frame vidc_frame = - (enum vidc_720p_frame)frametype; - u32 status = true; - - switch (vidc_frame) { - case VIDC_720P_IFRAME: - { - frame->flags |= VCD_FRAME_FLAG_SYNCFRAME; - frame->frame = VCD_FRAME_I; - break; - } - case VIDC_720P_PFRAME: - { - frame->frame = VCD_FRAME_P; - break; - } - case VIDC_720P_BFRAME: - { - frame->frame = VCD_FRAME_B; - break; - } - case VIDC_720P_NOTCODED: - { - frame->frame = VCD_FRAME_NOTCODED; - frame->data_len = 0; - break; - } - case VIDC_720P_IDRFRAME: - { - frame->flags |= VCD_FRAME_FLAG_SYNCFRAME; - frame->frame = VCD_FRAME_IDR; - break; - } - default: - { - VIDC_LOG_STRING("CRITICAL-FRAMETYPE"); - status = false; - break; - } - } - return status; -} - -static void ddl_getmpeg4_declevel(enum vcd_codec_level *codec_level, - u32 level) -{ - switch (level) { - case VIDC_720P_MPEG4_LEVEL0: - { - *codec_level = VCD_LEVEL_MPEG4_0; - break; - } - case VIDC_720P_MPEG4_LEVEL0b: - { - *codec_level = VCD_LEVEL_MPEG4_0b; - break; - } - case VIDC_720P_MPEG4_LEVEL1: - { - *codec_level = VCD_LEVEL_MPEG4_1; - break; - } - case VIDC_720P_MPEG4_LEVEL2: - { - *codec_level = VCD_LEVEL_MPEG4_2; - break; - } - case VIDC_720P_MPEG4_LEVEL3: - { - *codec_level = VCD_LEVEL_MPEG4_3; - break; - } - case VIDC_720P_MPEG4_LEVEL3b: - { - *codec_level = VCD_LEVEL_MPEG4_3b; - break; - } - case VIDC_720P_MPEG4_LEVEL4a: - { - *codec_level = VCD_LEVEL_MPEG4_4a; - break; - } - case VIDC_720P_MPEG4_LEVEL5: - { - *codec_level = VCD_LEVEL_MPEG4_5; - break; - } - case VIDC_720P_MPEG4_LEVEL6: - { - *codec_level = VCD_LEVEL_MPEG4_6; - break; - } - } -} - -static void ddl_geth264_declevel(enum vcd_codec_level *codec_level, - u32 level) -{ - switch (level) { - case VIDC_720P_H264_LEVEL1: - { - *codec_level = VCD_LEVEL_H264_1; - break; - } - case VIDC_720P_H264_LEVEL1b: - { - *codec_level = VCD_LEVEL_H264_1b; - break; - } - case VIDC_720P_H264_LEVEL1p1: - { - *codec_level = VCD_LEVEL_H264_1p1; - break; - } - case VIDC_720P_H264_LEVEL1p2: - { - *codec_level = VCD_LEVEL_H264_1p2; - break; - } - case VIDC_720P_H264_LEVEL1p3: - { - *codec_level = VCD_LEVEL_H264_1p3; - break; - } - case VIDC_720P_H264_LEVEL2: - { - *codec_level = VCD_LEVEL_H264_2; - break; - } - case VIDC_720P_H264_LEVEL2p1: - { - *codec_level = VCD_LEVEL_H264_2p1; - break; - } - case VIDC_720P_H264_LEVEL2p2: - { - *codec_level = VCD_LEVEL_H264_2p2; - break; - } - case VIDC_720P_H264_LEVEL3: - { - *codec_level = VCD_LEVEL_H264_3; - break; - } - case VIDC_720P_H264_LEVEL3p1: - { - *codec_level = VCD_LEVEL_H264_3p1; - break; - } - case VIDC_720P_H264_LEVEL3p2: - { - *codec_level = VCD_LEVEL_H264_3p2; - break; - } - - } -} - -static void ddl_get_vc1_dec_level( - enum vcd_codec_level *codec_level, u32 level, - enum vcd_codec_profile vc1_profile) -{ - if (vc1_profile == VCD_PROFILE_VC1_ADVANCE) { - switch (level) { - case VIDC_720P_VC1_LEVEL0: - { - *codec_level = VCD_LEVEL_VC1_A_0; - break; - } - case VIDC_720P_VC1_LEVEL1: - { - *codec_level = VCD_LEVEL_VC1_A_1; - break; - } - case VIDC_720P_VC1_LEVEL2: - { - *codec_level = VCD_LEVEL_VC1_A_2; - break; - } - case VIDC_720P_VC1_LEVEL3: - { - *codec_level = VCD_LEVEL_VC1_A_3; - break; - } - case VIDC_720P_VC1_LEVEL4: - { - *codec_level = VCD_LEVEL_VC1_A_4; - break; - } - } - return; - } else if (vc1_profile == VCD_PROFILE_VC1_MAIN) { - switch (level) { - case VIDC_720P_VC1_LEVEL_LOW: - { - *codec_level = VCD_LEVEL_VC1_M_LOW; - break; - } - case VIDC_720P_VC1_LEVEL_MED: - { - *codec_level = VCD_LEVEL_VC1_M_MEDIUM; - break; - } - case VIDC_720P_VC1_LEVEL_HIGH: - { - *codec_level = VCD_LEVEL_VC1_M_HIGH; - break; - } - } - } else if (vc1_profile == VCD_PROFILE_VC1_SIMPLE) { - switch (level) { - case VIDC_720P_VC1_LEVEL_LOW: - { - *codec_level = VCD_LEVEL_VC1_S_LOW; - break; - } - case VIDC_720P_VC1_LEVEL_MED: - { - *codec_level = VCD_LEVEL_VC1_S_MEDIUM; - break; - } - } - } -} - -static void ddl_get_mpeg2_dec_level(enum vcd_codec_level *codec_level, - u32 level) -{ - switch (level) { - case VIDCL_720P_MPEG2_LEVEL_LOW: - { - *codec_level = VCD_LEVEL_MPEG2_LOW; - break; - } - case VIDCL_720P_MPEG2_LEVEL_MAIN: - { - *codec_level = VCD_LEVEL_MPEG2_MAIN; - break; - } - case VIDCL_720P_MPEG2_LEVEL_HIGH14: - { - *codec_level = VCD_LEVEL_MPEG2_HIGH_14; - break; - } - } -} - -static void ddl_getdec_profilelevel(struct ddl_decoder_data *decoder, - u32 profile, u32 level) -{ - enum vcd_codec_profile codec_profile = VCD_PROFILE_UNKNOWN; - enum vcd_codec_level codec_level = VCD_LEVEL_UNKNOWN; - - switch (decoder->codec.codec) { - case VCD_CODEC_MPEG4: - { - if (profile == VIDC_720P_PROFILE_MPEG4_SP) - codec_profile = VCD_PROFILE_MPEG4_SP; - else if (profile == VIDC_720P_PROFILE_MPEG4_ASP) - codec_profile = VCD_PROFILE_MPEG4_ASP; - - ddl_getmpeg4_declevel(&codec_level, level); - break; - } - case VCD_CODEC_H264: - { - if (profile == VIDC_720P_PROFILE_H264_BASELINE) - codec_profile = VCD_PROFILE_H264_BASELINE; - else if (profile == VIDC_720P_PROFILE_H264_MAIN) - codec_profile = VCD_PROFILE_H264_MAIN; - else if (profile == VIDC_720P_PROFILE_H264_HIGH) - codec_profile = VCD_PROFILE_H264_HIGH; - ddl_geth264_declevel(&codec_level, level); - break; - } - default: - case VCD_CODEC_H263: - { - break; - } - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - { - if (profile == VIDC_720P_PROFILE_VC1_SP) - codec_profile = VCD_PROFILE_VC1_SIMPLE; - else if (profile == VIDC_720P_PROFILE_VC1_MAIN) - codec_profile = VCD_PROFILE_VC1_MAIN; - else if (profile == VIDC_720P_PROFILE_VC1_ADV) - codec_profile = VCD_PROFILE_VC1_ADVANCE; - ddl_get_vc1_dec_level(&codec_level, level, profile); - break; - } - case VCD_CODEC_MPEG2: - { - if (profile == VIDC_720P_PROFILE_MPEG2_MAIN) - codec_profile = VCD_PROFILE_MPEG2_MAIN; - else if (profile == VIDC_720P_PROFILE_MPEG2_SP) - codec_profile = VCD_PROFILE_MPEG2_SIMPLE; - ddl_get_mpeg2_dec_level(&codec_level, level); - break; - } - } - - decoder->profile.profile = codec_profile; - decoder->level.level = codec_level; -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_metadata.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_metadata.c deleted file mode 100644 index 5d8753324365819afccc0b3358018defa1be91be..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_metadata.c +++ /dev/null @@ -1,580 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vcd_ddl_utils.h" -#include "vcd_ddl_metadata.h" - -static u32 *ddl_metadata_hdr_entry(struct ddl_client_context *ddl, - u32 meta_data) -{ - u32 skip_words = 0; - u32 *buffer; - - if (ddl->decoding) { - buffer = (u32 *) - ddl->codec_data.decoder.meta_data_input. - align_virtual_addr; - skip_words = 32 + 1; - buffer += skip_words; - - switch (meta_data) { - default: - case VCD_METADATA_DATANONE: - { - skip_words = 0; - break; - } - case VCD_METADATA_QPARRAY: - { - skip_words = 3; - break; - } - case VCD_METADATA_CONCEALMB: - { - skip_words = 6; - break; - } - case VCD_METADATA_VC1: - { - skip_words = 9; - break; - } - case VCD_METADATA_SEI: - { - skip_words = 12; - break; - } - case VCD_METADATA_VUI: - { - skip_words = 15; - break; - } - case VCD_METADATA_PASSTHROUGH: - { - skip_words = 18; - break; - } - case VCD_METADATA_QCOMFILLER: - { - skip_words = 21; - break; - } - } - } else { - buffer = (u32 *) - ddl->codec_data.encoder.meta_data_input. - align_virtual_addr; - skip_words = 2; - buffer += skip_words; - - switch (meta_data) { - default: - case VCD_METADATA_DATANONE: - { - skip_words = 0; - break; - } - case VCD_METADATA_ENC_SLICE: - { - skip_words = 3; - break; - } - case VCD_METADATA_QCOMFILLER: - { - skip_words = 6; - break; - } - } - - } - - buffer += skip_words; - return buffer; -} - -void ddl_set_default_meta_data_hdr(struct ddl_client_context *ddl) -{ - struct ddl_buf_addr *main_buffer = - &ddl->ddl_context->metadata_shared_input; - struct ddl_buf_addr *client_buffer; - u32 *hdr_entry; - - if (ddl->decoding) - client_buffer = &(ddl->codec_data.decoder.meta_data_input); - else - client_buffer = &(ddl->codec_data.encoder.meta_data_input); - - DDL_METADATA_CLIENT_INPUTBUF(main_buffer, client_buffer, - ddl->channel_id); - - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_QCOMFILLER); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_QCOMFILLER; - - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_DATANONE); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_DATANONE; - - if (ddl->decoding) { - hdr_entry = - ddl_metadata_hdr_entry(ddl, VCD_METADATA_QPARRAY); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_QPARRAY; - - hdr_entry = - ddl_metadata_hdr_entry(ddl, VCD_METADATA_CONCEALMB); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_CONCEALMB; - - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_SEI); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_SEI; - - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_VUI); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_VUI; - - hdr_entry = ddl_metadata_hdr_entry(ddl, VCD_METADATA_VC1); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = VCD_METADATA_VC1; - - hdr_entry = - ddl_metadata_hdr_entry(ddl, VCD_METADATA_PASSTHROUGH); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = - VCD_METADATA_PASSTHROUGH; - - } else { - hdr_entry = - ddl_metadata_hdr_entry(ddl, VCD_METADATA_ENC_SLICE); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = 0x00000101; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = 1; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = - VCD_METADATA_ENC_SLICE; - } -} - -static u32 ddl_supported_metadata_flag(struct ddl_client_context *ddl) -{ - u32 flag = 0; - - if (ddl->decoding) { - enum vcd_codec codec = - ddl->codec_data.decoder.codec.codec; - - flag |= (VCD_METADATA_CONCEALMB | - VCD_METADATA_PASSTHROUGH | VCD_METADATA_QPARRAY); - if (codec == VCD_CODEC_H264) { - flag |= (VCD_METADATA_SEI | VCD_METADATA_VUI); - } else if (codec == VCD_CODEC_VC1 || - codec == VCD_CODEC_VC1_RCV) { - flag |= VCD_METADATA_VC1; - } - } else { - flag |= VCD_METADATA_ENC_SLICE; - } - - return flag; -} - -void ddl_set_default_metadata_flag(struct ddl_client_context *ddl) -{ - if (ddl->decoding) - ddl->codec_data.decoder.meta_data_enable_flag = 0; - else - ddl->codec_data.encoder.meta_data_enable_flag = 0; -} - -void ddl_set_default_decoder_metadata_buffer_size( - struct ddl_decoder_data *decoder, - struct vcd_property_frame_size *frame_size, - struct vcd_buffer_requirement *output_buf_req) -{ - u32 flag = decoder->meta_data_enable_flag; - u32 suffix = 0; - size_t sz = 0; - - if (!flag) { - decoder->suffix = 0; - return; - } - - if (flag & VCD_METADATA_QPARRAY) { - u32 num_of_mb = - ((frame_size->width * frame_size->height) >> 8); - sz = DDL_METADATA_HDR_SIZE; - sz += num_of_mb; - DDL_METADATA_ALIGNSIZE(sz); - suffix += sz; - } - if (flag & VCD_METADATA_CONCEALMB) { - u32 num_of_mb = - ((frame_size->width * frame_size->height) >> 8); - sz = DDL_METADATA_HDR_SIZE + (num_of_mb >> 3); - DDL_METADATA_ALIGNSIZE(sz); - suffix += sz; - } - if (flag & VCD_METADATA_VC1) { - sz = DDL_METADATA_HDR_SIZE; - sz += DDL_METADATA_VC1_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(sz); - suffix += sz; - } - if (flag & VCD_METADATA_SEI) { - sz = DDL_METADATA_HDR_SIZE; - sz += DDL_METADATA_SEI_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(sz); - suffix += (sz * DDL_METADATA_SEI_MAX); - } - if (flag & VCD_METADATA_VUI) { - sz = DDL_METADATA_HDR_SIZE; - sz += DDL_METADATA_VUI_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(sz); - suffix += (sz); - } - if (flag & VCD_METADATA_PASSTHROUGH) { - sz = DDL_METADATA_HDR_SIZE; - sz += DDL_METADATA_PASSTHROUGH_PAYLOAD_SIZE; - DDL_METADATA_ALIGNSIZE(sz); - suffix += (sz); - } - sz = DDL_METADATA_EXTRADATANONE_SIZE; - DDL_METADATA_ALIGNSIZE(sz); - suffix += (sz); - - suffix += DDL_METADATA_EXTRAPAD_SIZE; - DDL_METADATA_ALIGNSIZE(suffix); - - decoder->suffix = suffix; - output_buf_req->sz += suffix; - return; -} - -void ddl_set_default_encoder_metadata_buffer_size(struct ddl_encoder_data - *encoder) -{ - u32 flag = encoder->meta_data_enable_flag; - u32 suffix = 0; - size_t sz = 0; - - if (!flag) { - encoder->suffix = 0; - return; - } - - if (flag & VCD_METADATA_ENC_SLICE) { - u32 num_of_mb = (encoder->frame_size.width * - encoder->frame_size.height / 16 / 16); - sz = DDL_METADATA_HDR_SIZE; - - sz += 4; - - sz += (8 * num_of_mb); - DDL_METADATA_ALIGNSIZE(sz); - suffix += sz; - } - - sz = DDL_METADATA_EXTRADATANONE_SIZE; - DDL_METADATA_ALIGNSIZE(sz); - suffix += (sz); - - suffix += DDL_METADATA_EXTRAPAD_SIZE; - DDL_METADATA_ALIGNSIZE(suffix); - - encoder->suffix = suffix; - encoder->output_buf_req.sz += suffix; -} - -u32 ddl_set_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, - void *property_value) -{ - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - if (property_hdr->prop_id == VCD_I_METADATA_ENABLE) { - struct vcd_property_meta_data_enable *meta_data_enable = - (struct vcd_property_meta_data_enable *) - property_value; - u32 *meta_data_enable_flag; - enum vcd_codec codec; - if (ddl->decoding) { - meta_data_enable_flag = - &(ddl->codec_data.decoder. - meta_data_enable_flag); - codec = ddl->codec_data.decoder.codec.codec; - } else { - meta_data_enable_flag = - &(ddl->codec_data.encoder. - meta_data_enable_flag); - codec = ddl->codec_data.encoder.codec.codec; - } - if (sizeof(struct vcd_property_meta_data_enable) == - property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - codec) { - u32 flag = ddl_supported_metadata_flag(ddl); - flag &= (meta_data_enable->meta_data_enable_flag); - if (flag) - flag |= DDL_METADATA_MANDATORY; - if (flag != *meta_data_enable_flag) { - *meta_data_enable_flag = flag; - if (ddl->decoding) { - ddl_set_default_decoder_buffer_req - (&ddl->codec_data.decoder, - true); - } else { - ddl_set_default_encoder_buffer_req - (&ddl->codec_data.encoder); - } - } - vcd_status = VCD_S_SUCCESS; - } - } else if (property_hdr->prop_id == VCD_I_METADATA_HEADER) { - struct vcd_property_metadata_hdr *hdr = - (struct vcd_property_metadata_hdr *)property_value; - if (sizeof(struct vcd_property_metadata_hdr) == - property_hdr->sz) { - u32 flag = ddl_supported_metadata_flag(ddl); - flag |= DDL_METADATA_MANDATORY; - flag &= hdr->meta_data_id; - if (!(flag & (flag - 1))) { - u32 *hdr_entry = - ddl_metadata_hdr_entry(ddl, flag); - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX] = - hdr->version; - hdr_entry[DDL_METADATA_HDR_PORT_INDEX] = - hdr->port_index; - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX] = - hdr->type; - vcd_status = VCD_S_SUCCESS; - } - } - } - return vcd_status; -} - -u32 ddl_get_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, - void *property_value) -{ - u32 vcd_status = VCD_ERR_ILLEGAL_PARM ; - if (property_hdr->prop_id == VCD_I_METADATA_ENABLE && - sizeof(struct vcd_property_meta_data_enable) - == property_hdr->sz) { - struct vcd_property_meta_data_enable *meta_data_enable = - (struct vcd_property_meta_data_enable *) - property_value; - meta_data_enable->meta_data_enable_flag = - ((ddl->decoding) ? - (ddl->codec_data.decoder.meta_data_enable_flag) - : (ddl->codec_data.encoder.meta_data_enable_flag)); - vcd_status = VCD_S_SUCCESS; - } else if (property_hdr->prop_id == VCD_I_METADATA_HEADER && - sizeof(struct vcd_property_metadata_hdr) == - property_hdr->sz) { - struct vcd_property_metadata_hdr *hdr = - (struct vcd_property_metadata_hdr *) - property_value; - u32 flag = ddl_supported_metadata_flag(ddl); - flag |= DDL_METADATA_MANDATORY; - flag &= hdr->meta_data_id; - if (!(flag & (flag - 1))) { - u32 *hdr_entry = ddl_metadata_hdr_entry(ddl, - flag); - hdr->version = - hdr_entry[DDL_METADATA_HDR_VERSION_INDEX]; - hdr->port_index = - hdr_entry[DDL_METADATA_HDR_PORT_INDEX]; - hdr->type = - hdr_entry[DDL_METADATA_HDR_TYPE_INDEX]; - vcd_status = VCD_S_SUCCESS; - } - } - return vcd_status; -} - -void ddl_metadata_enable(struct ddl_client_context *ddl) -{ - u32 flag, hal_flag = 0; - u32 *metadata_input; - if (ddl->decoding) { - flag = ddl->codec_data.decoder.meta_data_enable_flag; - metadata_input = - ddl->codec_data.decoder.meta_data_input. - align_physical_addr; - } else { - flag = ddl->codec_data.encoder.meta_data_enable_flag; - metadata_input = - ddl->codec_data.encoder.meta_data_input. - align_physical_addr; - } - if (flag) { - if (flag & VCD_METADATA_QPARRAY) - hal_flag |= VIDC_720P_METADATA_ENABLE_QP; - if (flag & VCD_METADATA_CONCEALMB) - hal_flag |= VIDC_720P_METADATA_ENABLE_CONCEALMB; - if (flag & VCD_METADATA_VC1) - hal_flag |= VIDC_720P_METADATA_ENABLE_VC1; - if (flag & VCD_METADATA_SEI) - hal_flag |= VIDC_720P_METADATA_ENABLE_SEI; - if (flag & VCD_METADATA_VUI) - hal_flag |= VIDC_720P_METADATA_ENABLE_VUI; - if (flag & VCD_METADATA_ENC_SLICE) - hal_flag |= VIDC_720P_METADATA_ENABLE_ENCSLICE; - if (flag & VCD_METADATA_PASSTHROUGH) - hal_flag |= VIDC_720P_METADATA_ENABLE_PASSTHROUGH; - } else { - metadata_input = 0; - } - vidc_720p_metadata_enable(hal_flag, metadata_input); -} - -u32 ddl_encode_set_metadata_output_buf(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &ddl->codec_data.encoder; - u32 *buffer; - struct vcd_frame_data *stream = &(ddl->output_frame.vcd_frm); - u32 ext_buffer_end, hw_metadata_start; - - ext_buffer_end = (u32) stream->physical + stream->alloc_len; - if (!encoder->meta_data_enable_flag) { - ext_buffer_end &= ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - return ext_buffer_end; - } - hw_metadata_start = (ext_buffer_end - encoder->suffix) & - ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - - ext_buffer_end = (hw_metadata_start - 1) & - ~(DDL_STREAMBUF_ALIGN_GUARD_BYTES); - - buffer = encoder->meta_data_input.align_virtual_addr; - - *buffer++ = encoder->suffix; - - *buffer = hw_metadata_start; - - encoder->meta_data_offset = - hw_metadata_start - (u32) stream->physical; - - return ext_buffer_end; -} - -void ddl_decode_set_metadata_output(struct ddl_decoder_data *decoder) -{ - u32 *buffer; - u32 loopc; - - if (!decoder->meta_data_enable_flag) { - decoder->meta_data_offset = 0; - return; - } - - decoder->meta_data_offset = ddl_get_yuv_buffer_size( - &decoder->client_frame_size, &decoder->buf_format, - (!decoder->progressive_only), decoder->codec.codec); - - buffer = decoder->meta_data_input.align_virtual_addr; - - *buffer++ = decoder->suffix; - - for (loopc = 0; loopc < decoder->dp_buf.no_of_dec_pic_buf; - ++loopc) { - *buffer++ = (u32) (decoder->meta_data_offset + (u8 *) - decoder->dp_buf. - dec_pic_buffers[loopc].vcd_frm. - physical); - } -} - -void ddl_process_encoder_metadata(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - struct vcd_frame_data *out_frame = - &(ddl->output_frame.vcd_frm); - u32 *qfiller_hdr, *qfiller, start_addr; - u32 qfiller_size; - - if (!encoder->meta_data_enable_flag) { - out_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - return; - } - - if (!encoder->enc_frame_info.metadata_exists) { - out_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - return; - } - out_frame->flags |= VCD_FRAME_FLAG_EXTRADATA; - - start_addr = (u32) ((u8 *) out_frame->virtual + - out_frame->offset); - qfiller = (u32 *) ((out_frame->data_len + start_addr + 3) & ~3); - - qfiller_size = (u32) ((encoder->meta_data_offset + - (u8 *) out_frame->virtual) - - (u8 *) qfiller); - - qfiller_hdr = ddl_metadata_hdr_entry(ddl, VCD_METADATA_QCOMFILLER); - - *qfiller++ = qfiller_size; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_VERSION_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_PORT_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_TYPE_INDEX]; - *qfiller = (u32) (qfiller_size - DDL_METADATA_HDR_SIZE); -} - -void ddl_process_decoder_metadata(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - struct vcd_frame_data *output_frame = - &(ddl->output_frame.vcd_frm); - u32 *qfiller_hdr, *qfiller; - u32 qfiller_size; - - if (!decoder->meta_data_enable_flag) { - output_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - return; - } - - if (!decoder->dec_disp_info.metadata_exists) { - output_frame->flags &= ~(VCD_FRAME_FLAG_EXTRADATA); - return; - } - output_frame->flags |= VCD_FRAME_FLAG_EXTRADATA; - - if (output_frame->data_len != decoder->meta_data_offset) { - qfiller = (u32 *) ((u32) ((output_frame->data_len + - output_frame->offset + - (u8 *) output_frame->virtual) + - 3) & ~3); - - qfiller_size = (u32) ((decoder->meta_data_offset + - (u8 *) output_frame->virtual) - - (u8 *) qfiller); - - qfiller_hdr = - ddl_metadata_hdr_entry(ddl, VCD_METADATA_QCOMFILLER); - *qfiller++ = qfiller_size; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_VERSION_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_PORT_INDEX]; - *qfiller++ = qfiller_hdr[DDL_METADATA_HDR_TYPE_INDEX]; - *qfiller = (u32) (qfiller_size - DDL_METADATA_HDR_SIZE); - } -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_metadata.h b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_metadata.h deleted file mode 100644 index 7c9ac951bfe296559b100a483c00485aa7681671..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_metadata.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) 2010, 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 _VCD_DDL_METADATA_H_ -#define _VCD_DDL_METADATA_H_ - -#define DDL_MAX_DEC_METADATATYPE (8) -#define DDL_MAX_ENC_METADATATYPE (3) - -#define DDL_METADATA_EXTRAPAD_SIZE (256) -#define DDL_METADATA_HDR_SIZE (20) - -#define DDL_METADATA_EXTRADATANONE_SIZE (24) - -#define DDL_METADATA_ALIGNSIZE(x) ((x) = (((x) + 0x7) & ~0x7)) - -#define DDL_METADATA_MANDATORY (VCD_METADATA_DATANONE | \ - VCD_METADATA_QCOMFILLER) - -#define DDL_METADATA_VC1_PAYLOAD_SIZE (38*4) - -#define DDL_METADATA_SEI_PAYLOAD_SIZE (100) -#define DDL_METADATA_SEI_MAX (5) - -#define DDL_METADATA_VUI_PAYLOAD_SIZE (256) - -#define DDL_METADATA_PASSTHROUGH_PAYLOAD_SIZE (68) - -#define DDL_METADATA_CLIENT_INPUTBUFSIZE (256) -#define DDL_METADATA_TOTAL_INPUTBUFSIZE \ - (DDL_METADATA_CLIENT_INPUTBUFSIZE * VCD_MAX_NO_CLIENT) - -#define DDL_METADATA_CLIENT_INPUTBUF(main_buffer, client_buffer, \ - channel_id) \ -{ \ - (client_buffer)->align_physical_addr = (u32 *)\ - ((u8 *)(main_buffer)->align_physical_addr + \ - (DDL_METADATA_CLIENT_INPUTBUFSIZE * (channel_id)) \ - ); \ - (client_buffer)->align_virtual_addr = (u32 *)\ - ((u8 *)(main_buffer)->align_virtual_addr + \ - (DDL_METADATA_CLIENT_INPUTBUFSIZE * (channel_id)) \ - ); \ - (client_buffer)->virtual_base_addr = 0; \ -} - -#define DDL_METADATA_HDR_VERSION_INDEX 0 -#define DDL_METADATA_HDR_PORT_INDEX 1 -#define DDL_METADATA_HDR_TYPE_INDEX 2 - - -void ddl_set_default_meta_data_hdr(struct ddl_client_context *ddl); -u32 ddl_get_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value); -u32 ddl_set_metadata_params(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, - void *property_value); -void ddl_set_default_metadata_flag(struct ddl_client_context *ddl); -void ddl_set_default_decoder_metadata_buffer_size - (struct ddl_decoder_data *decoder, - struct vcd_property_frame_size *frame_size, - struct vcd_buffer_requirement *output_buf_req); -void ddl_set_default_encoder_metadata_buffer_size(struct ddl_encoder_data - *encoder); -void ddl_metadata_enable(struct ddl_client_context *ddl); -u32 ddl_encode_set_metadata_output_buf(struct ddl_client_context *ddl); -void ddl_decode_set_metadata_output(struct ddl_decoder_data *decoder); -void ddl_process_encoder_metadata(struct ddl_client_context *ddl); -void ddl_process_decoder_metadata(struct ddl_client_context *ddl); -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_properties.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_properties.c deleted file mode 100644 index cdb6313da70b7ffd5ad0d4a2943557dcc940c41c..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_properties.c +++ /dev/null @@ -1,1943 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vcd_ddl_utils.h" -#include "vcd_ddl_metadata.h" - -static u32 ddl_set_dec_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, - void *property_value); -static u32 ddl_set_enc_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, - void *property_value); -static u32 ddl_get_dec_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, - void *property_value); -static u32 ddl_get_enc_property(struct ddl_client_context *pddl, - struct vcd_property_hdr *property_hdr, - void *property_value); -static u32 ddl_set_enc_dynamic_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, - void *property_value); -static void ddl_set_default_enc_property(struct ddl_client_context *ddl); -static void ddl_set_default_enc_profile(struct ddl_encoder_data - *encoder); -static void ddl_set_default_enc_level(struct ddl_encoder_data *encoder); -static void ddl_set_default_enc_vop_timing(struct ddl_encoder_data - *encoder); -static void ddl_set_default_enc_intra_period(struct ddl_encoder_data - *encoder); -static void ddl_set_default_enc_rc_params(struct ddl_encoder_data - *encoder); -static u32 ddl_valid_buffer_requirement(struct vcd_buffer_requirement - *original_buf_req, - struct vcd_buffer_requirement - *req_buf_req); -static u32 ddl_decoder_min_num_dpb(struct ddl_decoder_data *decoder); -static u32 ddl_set_dec_buffers - (struct ddl_decoder_data *decoder, - struct ddl_property_dec_pic_buffers *dpb); - -u32 ddl_set_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - u32 vcd_status; - struct ddl_context *ddl_context; - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - - if (!property_hdr || !property_value) { - VIDC_LOGERR_STRING("ddl_set_prop:Bad_argument"); - return VCD_ERR_ILLEGAL_PARM; - } - ddl_context = ddl_get_context(); - - if (!DDL_IS_INITIALIZED(ddl_context)) { - VIDC_LOGERR_STRING("ddl_set_prop:Not_inited"); - return VCD_ERR_ILLEGAL_OP; - } - - if (!ddl) { - VIDC_LOGERR_STRING("ddl_set_prop:Bad_handle"); - return VCD_ERR_BAD_HANDLE; - } - if (ddl->decoding) { - vcd_status = - ddl_set_dec_property(ddl, property_hdr, - property_value); - } else { - vcd_status = - ddl_set_enc_property(ddl, property_hdr, - property_value); - } - if (vcd_status) - VIDC_LOGERR_STRING("ddl_set_prop:FAILED"); - - return vcd_status; -} - -u32 ddl_get_property(u32 *ddl_handle, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - struct ddl_context *ddl_context; - struct ddl_client_context *ddl = - (struct ddl_client_context *)ddl_handle; - - if (!property_hdr || !property_value) - return VCD_ERR_ILLEGAL_PARM; - - if (property_hdr->prop_id == DDL_I_CAPABILITY) { - if (sizeof(struct ddl_property_capability) == - property_hdr->sz) { - struct ddl_property_capability *ddl_capability = - (struct ddl_property_capability *) - property_value; - ddl_capability->max_num_client = VCD_MAX_NO_CLIENT; - ddl_capability->exclusive = - VCD_COMMAND_EXCLUSIVE; - ddl_capability->frame_command_depth = - VCD_FRAME_COMMAND_DEPTH; - ddl_capability->general_command_depth = - VCD_GENERAL_COMMAND_DEPTH; - ddl_capability->ddl_time_out_in_ms = - DDL_HW_TIMEOUT_IN_MS; - vcd_status = VCD_S_SUCCESS; - } - return vcd_status; - } - ddl_context = ddl_get_context(); - if (!DDL_IS_INITIALIZED(ddl_context)) - return VCD_ERR_ILLEGAL_OP; - - if (!ddl) - return VCD_ERR_BAD_HANDLE; - - if (ddl->decoding) { - vcd_status = - ddl_get_dec_property(ddl, property_hdr, - property_value); - } else { - vcd_status = - ddl_get_enc_property(ddl, property_hdr, - property_value); - } - if (vcd_status) - VIDC_LOGERR_STRING("ddl_get_prop:FAILED"); - - return vcd_status; -} - -u32 ddl_decoder_ready_to_start(struct ddl_client_context *ddl, - struct vcd_sequence_hdr *header) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - if (!decoder->codec.codec) { - VIDC_LOGERR_STRING("ddl_dec_start_check:Codec_not_set"); - return false; - } - if ((!header) && - (!decoder->client_frame_size.height || - !decoder->client_frame_size.width) - ) { - VIDC_LOGERR_STRING - ("ddl_dec_start_check:Client_height_width_default"); - return false; - } - return true; -} - -u32 ddl_encoder_ready_to_start(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - - if (!encoder->codec.codec || - !encoder->frame_size.height || - !encoder->frame_size.width || - !encoder->frame_rate.fps_denominator || - !encoder->frame_rate.fps_numerator || - !encoder->target_bit_rate.target_bitrate) { - return false; - } - return true; -} - -static u32 ddl_set_dec_property - (struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) { - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - switch (property_hdr->prop_id) { - case DDL_I_DPB_RELEASE: - { - if (sizeof(struct ddl_frame_data_tag) == - property_hdr->sz - && decoder->dp_buf.no_of_dec_pic_buf) { - vcd_status = - ddl_decoder_dpb_transact(decoder, - (struct ddl_frame_data_tag *) - property_value, - DDL_DPB_OP_MARK_FREE); - } - break; - } - case DDL_I_DPB: - { - struct ddl_property_dec_pic_buffers *dpb = - (struct ddl_property_dec_pic_buffers *) - property_value; - - if (sizeof(struct ddl_property_dec_pic_buffers) == - property_hdr->sz && - (DDLCLIENT_STATE_IS - (ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) - || DDLCLIENT_STATE_IS(ddl, - DDL_CLIENT_WAIT_FOR_DPB) - ) && - dpb->no_of_dec_pic_buf >= - decoder->client_output_buf_req.actual_count) { - vcd_status = - ddl_set_dec_buffers(decoder, dpb); - } - break; - } - case DDL_I_REQ_OUTPUT_FLUSH: - { - if (sizeof(u32) == property_hdr->sz) { - decoder->dynamic_prop_change |= - DDL_DEC_REQ_OUTPUT_FLUSH; - decoder->dpb_mask.client_mask = 0; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_INPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *) - property_value; - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && - (ddl_valid_buffer_requirement( - &decoder->min_input_buf_req, - buffer_req))) { - decoder->client_input_buf_req = *buffer_req; - decoder->client_input_buf_req.min_count = - decoder->min_input_buf_req.min_count; - decoder->client_input_buf_req.max_count = - decoder->min_input_buf_req.max_count; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_OUTPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *) - property_value; - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && - (ddl_valid_buffer_requirement( - &decoder->min_output_buf_req, - buffer_req))) { - decoder->client_output_buf_req = - *buffer_req; - decoder->client_output_buf_req.min_count = - decoder->min_output_buf_req.min_count; - decoder->client_output_buf_req.max_count = - decoder->min_output_buf_req.max_count; - vcd_status = VCD_S_SUCCESS; - } - break; - } - - case VCD_I_CODEC: - { - struct vcd_property_codec *codec = - (struct vcd_property_codec *)property_value; - if (sizeof(struct vcd_property_codec) == - property_hdr->sz - && DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) - ) { - u32 status; - vcd_fw_transact(false, true, - decoder->codec.codec); - status = vcd_fw_transact(true, true, - codec->codec); - if (status) { - decoder->codec = *codec; - ddl_set_default_dec_property(ddl); - vcd_status = VCD_S_SUCCESS; - } else { - status = vcd_fw_transact(true, true, - decoder->codec.codec); - vcd_status = VCD_ERR_NOT_SUPPORTED; - } - } - break; - } - case VCD_I_POST_FILTER: - { - if (sizeof(struct vcd_property_post_filter) == - property_hdr->sz - && DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - (decoder->codec.codec == VCD_CODEC_MPEG4 || - decoder->codec.codec == VCD_CODEC_MPEG2) - ) { - decoder->post_filter = - *(struct vcd_property_post_filter *) - property_value; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_FRAME_SIZE: - { - struct vcd_property_frame_size *frame_size = - (struct vcd_property_frame_size *) - property_value; - - if ((sizeof(struct vcd_property_frame_size) == - property_hdr->sz) && - (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN))) { - if (decoder->client_frame_size.height != - frame_size->height - || decoder->client_frame_size.width != - frame_size->width) { - decoder->client_frame_size = - *frame_size; - ddl_set_default_decoder_buffer_req - (decoder, true); - } - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_BUFFER_FORMAT: - { - struct vcd_property_buffer_format *tile = - (struct vcd_property_buffer_format *) - property_value; - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - (tile->buffer_format == VCD_BUFFER_FORMAT_NV12 - || tile->buffer_format == - VCD_BUFFER_FORMAT_TILE_4x2) - ) { - if (tile->buffer_format != - decoder->buf_format.buffer_format) { - decoder->buf_format = *tile; - ddl_set_default_decoder_buffer_req - (decoder, true); - } - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - { - vcd_status = ddl_set_metadata_params(ddl, - property_hdr, - property_value); - break; - } - case VCD_I_OUTPUT_ORDER: - { - if (sizeof(u32) == property_hdr->sz && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - decoder->output_order = - *(u32 *)property_value; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_DEC_PICTYPE: - { - if ((sizeof(u32) == property_hdr->sz) && - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) { - decoder->idr_only_decoding = - *(u32 *)property_value; - ddl_set_default_decoder_buffer_req( - decoder, true); - vcd_status = VCD_S_SUCCESS; - } - } - break; - case VCD_I_FRAME_RATE: - { - vcd_status = VCD_S_SUCCESS; - break; - } - default: - { - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - } - return vcd_status; -} - -static u32 ddl_set_enc_property(struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) -{ - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - - if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) || - (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN))) - vcd_status = ddl_set_enc_dynamic_property(ddl, - property_hdr, property_value); - if (vcd_status == VCD_S_SUCCESS) - return vcd_status; - - if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) || - vcd_status != VCD_ERR_ILLEGAL_OP) { - VIDC_LOGERR_STRING - ("ddl_set_enc_property:Fails_as_not_in_open_state"); - return VCD_ERR_ILLEGAL_OP; - } - - switch (property_hdr->prop_id) { - case VCD_I_FRAME_SIZE: - { - struct vcd_property_frame_size *framesize = - (struct vcd_property_frame_size *) - property_value; - - if (sizeof(struct vcd_property_frame_size) - == property_hdr->sz && - DDL_ALLOW_ENC_FRAMESIZE(framesize->width, - framesize->height) && - (encoder->codec.codec == VCD_CODEC_H264 || - DDL_VALIDATE_ENC_FRAMESIZE(framesize->width, - framesize->height)) - ) { - encoder->frame_size = *framesize; - ddl_calculate_stride(&encoder->frame_size, - false, encoder->codec.codec); - ddl_set_default_encoder_buffer_req(encoder); - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_CODEC: - { - struct vcd_property_codec *codec = - (struct vcd_property_codec *) - property_value; - if (sizeof(struct vcd_property_codec) == - property_hdr->sz) { - u32 status; - - vcd_fw_transact(false, false, - encoder->codec.codec); - - status = vcd_fw_transact(true, false, - codec->codec); - if (status) { - encoder->codec = *codec; - ddl_set_default_enc_property(ddl); - vcd_status = VCD_S_SUCCESS; - } else { - status = vcd_fw_transact(true, false, - encoder->codec.codec); - vcd_status = VCD_ERR_NOT_SUPPORTED; - } - } - break; - } - case VCD_I_PROFILE: - { - struct vcd_property_profile *profile = - (struct vcd_property_profile *) - property_value; - if ((sizeof(struct vcd_property_profile) == - property_hdr->sz) && - ((encoder->codec.codec == - VCD_CODEC_MPEG4 && - (profile->profile == - VCD_PROFILE_MPEG4_SP || - profile->profile == - VCD_PROFILE_MPEG4_ASP)) || - (encoder->codec.codec == - VCD_CODEC_H264 && - (profile->profile >= - VCD_PROFILE_H264_BASELINE || - profile->profile <= - VCD_PROFILE_H264_HIGH)) || - (encoder->codec.codec == - VCD_CODEC_H263 && - profile->profile == - VCD_PROFILE_H263_BASELINE)) - ) { - encoder->profile = *profile; - vcd_status = VCD_S_SUCCESS; - - if (profile->profile == - VCD_PROFILE_H264_BASELINE) - encoder->entropy_control.entropy_sel - = VCD_ENTROPY_SEL_CAVLC; - else - encoder->entropy_control.entropy_sel - = VCD_ENTROPY_SEL_CABAC; - } - break; - } - case VCD_I_LEVEL: - { - struct vcd_property_level *level = - (struct vcd_property_level *) - property_value; - if ( - (sizeof(struct vcd_property_level) == - property_hdr->sz - ) && - ( - ( - (encoder->codec. - codec == VCD_CODEC_MPEG4) && - (level->level >= VCD_LEVEL_MPEG4_0) && - (level->level <= VCD_LEVEL_MPEG4_6) - ) || - ( - (encoder->codec. - codec == VCD_CODEC_H264) && - (level->level >= VCD_LEVEL_H264_1) && - (level->level <= VCD_LEVEL_H264_3p1) - ) || - ( - (encoder->codec. - codec == VCD_CODEC_H263) && - (level->level >= VCD_LEVEL_H263_10) && - (level->level <= VCD_LEVEL_H263_70) - ) - ) - ) { - encoder->level = *level; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_MULTI_SLICE: - { - struct vcd_property_multi_slice *multislice = - (struct vcd_property_multi_slice *) - property_value; - switch (multislice->m_slice_sel) { - case VCD_MSLICE_OFF: - { - vcd_status = VCD_S_SUCCESS; - break; - } - case VCD_MSLICE_BY_GOB: - { - if (encoder->codec.codec == - VCD_CODEC_H263) - vcd_status = VCD_S_SUCCESS; - break; - } - case VCD_MSLICE_BY_MB_COUNT: - { - if (multislice->m_slice_size - >= 1 && (multislice-> - m_slice_size <= - (encoder->frame_size.height - * encoder->frame_size.width - / 16 / 16)) - ) { - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_MSLICE_BY_BYTE_COUNT: - { - if (multislice->m_slice_size > 0) - vcd_status = VCD_S_SUCCESS; - break; - } - default: - { - break; - } - } - if (sizeof(struct vcd_property_multi_slice) == - property_hdr->sz && - !vcd_status) { - encoder->multi_slice = *multislice; - if (multislice->m_slice_sel == - VCD_MSLICE_OFF) - encoder->multi_slice.m_slice_size = 0; - } - break; - } - case VCD_I_RATE_CONTROL: - { - struct vcd_property_rate_control - *ratecontrol = - (struct vcd_property_rate_control *) - property_value; - if (sizeof(struct vcd_property_rate_control) == - property_hdr->sz && - ratecontrol-> - rate_control >= VCD_RATE_CONTROL_OFF && - ratecontrol-> - rate_control <= VCD_RATE_CONTROL_CBR_CFR - ) { - encoder->rc = *ratecontrol; - ddl_set_default_enc_rc_params(encoder); - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_SHORT_HEADER: - { - - if (sizeof(struct vcd_property_short_header) == - property_hdr->sz && - encoder->codec.codec == VCD_CODEC_MPEG4) { - encoder->short_header = - *(struct vcd_property_short_header *) - property_value; - vcd_status = VCD_S_SUCCESS; - } - - break; - } - case VCD_I_VOP_TIMING: - { - struct vcd_property_vop_timing *voptime = - (struct vcd_property_vop_timing *) - property_value; - if ( - (sizeof(struct vcd_property_vop_timing) == - property_hdr->sz - ) && - (encoder->frame_rate.fps_numerator <= - voptime->vop_time_resolution) - ) { - encoder->vop_timing = *voptime; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_HEADER_EXTENSION: - { - if (sizeof(u32) == property_hdr->sz && - encoder->codec.codec == VCD_CODEC_MPEG4 - ) { - encoder->hdr_ext_control = *(u32 *) - property_value; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_ENTROPY_CTRL: - { - struct vcd_property_entropy_control - *entropy_control = - (struct vcd_property_entropy_control *) - property_value; - if (sizeof(struct vcd_property_entropy_control) == - property_hdr->sz && - encoder->codec.codec == VCD_CODEC_H264 - && entropy_control-> - entropy_sel >= VCD_ENTROPY_SEL_CAVLC && - entropy_control->entropy_sel <= - VCD_ENTROPY_SEL_CABAC) { - encoder->entropy_control = *entropy_control; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_DEBLOCKING: - { - struct vcd_property_db_config *dbconfig = - (struct vcd_property_db_config *) - property_value; - if (sizeof(struct vcd_property_db_config) == - property_hdr->sz && - encoder->codec.codec == VCD_CODEC_H264 - && dbconfig->db_config >= - VCD_DB_ALL_BLOCKING_BOUNDARY - && dbconfig->db_config <= - VCD_DB_SKIP_SLICE_BOUNDARY - ) { - encoder->db_control = *dbconfig; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_QP_RANGE: - { - struct vcd_property_qp_range *qp = - (struct vcd_property_qp_range *) - property_value; - if ((sizeof(struct vcd_property_qp_range) == - property_hdr->sz) && - (qp->min_qp <= qp->max_qp) && - ( - (encoder->codec.codec == VCD_CODEC_H264 - && qp->max_qp <= DDL_MAX_H264_QP) || - (qp->max_qp <= DDL_MAX_MPEG4_QP) - ) - ) { - encoder->qp_range = *qp; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_SESSION_QP: - { - struct vcd_property_session_qp *qp = - (struct vcd_property_session_qp *) - property_value; - - if ((sizeof(struct vcd_property_session_qp) == - property_hdr->sz) && - (qp->i_frame_qp >= encoder->qp_range.min_qp) && - (qp->i_frame_qp <= encoder->qp_range.max_qp) && - (qp->p_frame_qp >= encoder->qp_range.min_qp) && - (qp->p_frame_qp <= encoder->qp_range.max_qp) - ) { - encoder->session_qp = *qp; - vcd_status = VCD_S_SUCCESS; - } - - break; - } - case VCD_I_RC_LEVEL_CONFIG: - { - struct vcd_property_rc_level *rc_level = - (struct vcd_property_rc_level *) - property_value; - if (sizeof(struct vcd_property_rc_level) == - property_hdr->sz && - ( - encoder->rc. - rate_control >= VCD_RATE_CONTROL_VBR_VFR || - encoder->rc. - rate_control <= VCD_RATE_CONTROL_CBR_VFR - ) && - (!rc_level->mb_level_rc || - encoder->codec.codec == VCD_CODEC_H264 - ) - ) { - encoder->rc_level = *rc_level; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_FRAME_LEVEL_RC: - { - - struct vcd_property_frame_level_rc_params - *frame_levelrc = - (struct vcd_property_frame_level_rc_params *) - property_value; - - if ((sizeof(struct - vcd_property_frame_level_rc_params) - == property_hdr->sz) && - (frame_levelrc->reaction_coeff) && - (encoder->rc_level.frame_level_rc) - ) { - encoder->frame_level_rc = *frame_levelrc; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_ADAPTIVE_RC: - { - - if ((sizeof(struct - vcd_property_adaptive_rc_params) - == property_hdr->sz) && - (encoder->codec. - codec == VCD_CODEC_H264) && - (encoder->rc_level.mb_level_rc)) { - - encoder->adaptive_rc = - *(struct vcd_property_adaptive_rc_params *) - property_value; - - vcd_status = VCD_S_SUCCESS; - } - - break; - } - case VCD_I_BUFFER_FORMAT: - { - struct vcd_property_buffer_format *tile = - (struct vcd_property_buffer_format *) - property_value; - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz && - tile->buffer_format == - VCD_BUFFER_FORMAT_NV12) { - encoder->buf_format = *tile; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_INPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *) - property_value; - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && - (ddl_valid_buffer_requirement( - &encoder->input_buf_req, buffer_req)) - ) { - encoder->client_input_buf_req = *buffer_req; - encoder->client_input_buf_req.min_count = - encoder->input_buf_req.min_count; - encoder->client_input_buf_req.max_count = - encoder->input_buf_req.max_count; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_OUTPUT_BUF_REQ: - { - struct vcd_buffer_requirement *buffer_req = - (struct vcd_buffer_requirement *) - property_value; - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz && - (ddl_valid_buffer_requirement( - &encoder->output_buf_req, buffer_req)) - ) { - encoder->client_output_buf_req = - *buffer_req; - encoder->client_output_buf_req.min_count = - encoder->output_buf_req.min_count; - encoder->client_output_buf_req.max_count = - encoder->output_buf_req.max_count; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - { - vcd_status = ddl_set_metadata_params( - ddl, property_hdr, property_value); - break; - } - case VCD_I_META_BUFFER_MODE: - { - vcd_status = VCD_S_SUCCESS; - break; - } - default: - { - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - } - return vcd_status; -} - -static u32 ddl_get_dec_property - (struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) { - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; - - switch (property_hdr->prop_id) { - case VCD_I_FRAME_SIZE: - { - struct vcd_property_frame_size *fz_size; - if (sizeof(struct vcd_property_frame_size) == - property_hdr->sz) { - ddl_calculate_stride( - &decoder->client_frame_size, - !decoder->progressive_only, - decoder->codec.codec); - if (decoder->buf_format.buffer_format - == VCD_BUFFER_FORMAT_TILE_4x2) { - fz_size = - &decoder->client_frame_size; - fz_size->stride = - DDL_TILE_ALIGN(fz_size->width, - DDL_TILE_ALIGN_WIDTH); - fz_size->scan_lines = - DDL_TILE_ALIGN(fz_size->height, - DDL_TILE_ALIGN_HEIGHT); - } - *(struct vcd_property_frame_size *) - property_value = - decoder->client_frame_size; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_PROFILE: - { - if (sizeof(struct vcd_property_profile) == - property_hdr->sz) { - *(struct vcd_property_profile *) - property_value = decoder->profile; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_LEVEL: - { - if (sizeof(struct vcd_property_level) == - property_hdr->sz) { - *(struct vcd_property_level *) - property_value = decoder->level; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_PROGRESSIVE_ONLY: - { - if (sizeof(u32) == property_hdr->sz) { - *(u32 *) property_value = - decoder->progressive_only; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_INPUT_BUF_REQ: - { - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = - decoder->client_input_buf_req; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_OUTPUT_BUF_REQ: - { - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = - decoder->client_output_buf_req; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_CODEC: - { - if (sizeof(struct vcd_property_codec) == - property_hdr->sz) { - *(struct vcd_property_codec *) - property_value = decoder->codec; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_BUFFER_FORMAT: - { - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz) { - *(struct vcd_property_buffer_format *) - property_value = decoder->buf_format; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_POST_FILTER: - { - if (sizeof(struct vcd_property_post_filter) == - property_hdr->sz) { - *(struct vcd_property_post_filter *) - property_value = decoder->post_filter; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_SEQHDR_ALIGN_BYTES: - { - if (sizeof(u32) == property_hdr->sz) { - *(u32 *) property_value = - DDL_LINEAR_BUFFER_ALIGN_BYTES; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_FRAME_PROC_UNITS: - { - if (sizeof(u32) == property_hdr->sz) { - struct vcd_property_frame_size frame_sz = - decoder->client_frame_size; - ddl_calculate_stride(&frame_sz, - !decoder->progressive_only, - decoder->codec.codec); - *(u32 *) property_value = - ((frame_sz.stride >> 4) * - (frame_sz.scan_lines >> 4)); - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_DPB_RETRIEVE: - { - if (sizeof(struct ddl_frame_data_tag) == - property_hdr->sz) { - vcd_status = - ddl_decoder_dpb_transact(decoder, - (struct ddl_frame_data_tag *) - property_value, - DDL_DPB_OP_RETRIEVE); - } - break; - } - case VCD_I_OUTPUT_ORDER: - { - if (sizeof(u32) == property_hdr->sz) { - *(u32 *)property_value = decoder->output_order; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - { - vcd_status = ddl_get_metadata_params( - ddl, - property_hdr, - property_value); - break; - } - default: - { - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - } - return vcd_status; -} - -static u32 ddl_get_enc_property - (struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) { - u32 vcd_status = VCD_ERR_ILLEGAL_PARM; - struct ddl_encoder_data *encoder = &ddl->codec_data.encoder; - - struct vcd_property_entropy_control *entropy_control; - struct vcd_property_intra_refresh_mb_number *intra_refresh; - - switch (property_hdr->prop_id) { - case VCD_I_CODEC: - { - if (sizeof(struct vcd_property_codec) == - property_hdr->sz) { - *(struct vcd_property_codec *) - property_value = - encoder->codec; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_FRAME_SIZE: - { - if (sizeof(struct vcd_property_frame_size) == - property_hdr->sz) { - *(struct vcd_property_frame_size *) - property_value = - encoder->frame_size; - - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_FRAME_RATE: - { - if (sizeof(struct vcd_property_frame_rate) == - property_hdr->sz) { - - *(struct vcd_property_frame_rate *) - property_value = - encoder->frame_rate; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_TARGET_BITRATE: - { - - if (sizeof(struct vcd_property_target_bitrate) == - property_hdr->sz) { - *(struct vcd_property_target_bitrate *) - property_value = - encoder->target_bit_rate; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_RATE_CONTROL: - { - if (sizeof(struct vcd_property_rate_control) == - property_hdr->sz) { - *(struct vcd_property_rate_control *) - property_value = encoder->rc; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_PROFILE: - { - if (sizeof(struct vcd_property_profile) == - property_hdr->sz) { - *(struct vcd_property_profile *) - property_value = encoder->profile; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_LEVEL: - { - if (sizeof(struct vcd_property_level) == - property_hdr->sz) { - *(struct vcd_property_level *) - property_value = encoder->level; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_MULTI_SLICE: - { - if (sizeof(struct vcd_property_multi_slice) == - property_hdr->sz) { - *(struct vcd_property_multi_slice *) - property_value = encoder->multi_slice; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_SEQ_HEADER: - { - struct vcd_sequence_hdr *seq_hdr = - (struct vcd_sequence_hdr *)property_value; - if (encoder->seq_header.buffer_size && - sizeof(struct vcd_sequence_hdr) == - property_hdr->sz - && encoder->seq_header.buffer_size <= - seq_hdr->sequence_header_len) { - DDL_MEMCPY(seq_hdr->sequence_header, - encoder->seq_header. - align_virtual_addr, - encoder->seq_header.buffer_size); - seq_hdr->sequence_header_len = - encoder->seq_header.buffer_size; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_SEQHDR_PRESENT: - { - if (sizeof(u32) == property_hdr->sz) { - if ((encoder->codec. - codec == VCD_CODEC_MPEG4 && - !encoder->short_header.short_header) - || encoder->codec.codec == - VCD_CODEC_H264) { - *(u32 *)property_value = 0x1; - } else { - *(u32 *)property_value = 0x0; - } - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_VOP_TIMING: - { - if (sizeof(struct vcd_property_vop_timing) == - property_hdr->sz) { - *(struct vcd_property_vop_timing *) - property_value = encoder->vop_timing; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_SHORT_HEADER: - { - if (sizeof(struct vcd_property_short_header) == - property_hdr->sz) { - if (encoder->codec.codec == - VCD_CODEC_MPEG4) { - *(struct vcd_property_short_header - *)property_value = - encoder->short_header; - vcd_status = VCD_S_SUCCESS; - } else { - vcd_status = VCD_ERR_ILLEGAL_OP; - } - } - break; - } - case VCD_I_ENTROPY_CTRL: - { - entropy_control = property_value; - if (sizeof(struct vcd_property_entropy_control) == - property_hdr->sz) { - if (encoder->codec.codec == - VCD_CODEC_H264) { - *entropy_control = - encoder->entropy_control; - vcd_status = VCD_S_SUCCESS; - } else { - vcd_status = VCD_ERR_ILLEGAL_OP; - } - } - break; - } - case VCD_I_DEBLOCKING: - { - if (sizeof(struct vcd_property_db_config) == - property_hdr->sz) { - if (encoder->codec.codec == - VCD_CODEC_H264) { - *(struct vcd_property_db_config *) - property_value = - encoder->db_control; - vcd_status = VCD_S_SUCCESS; - } else { - vcd_status = VCD_ERR_ILLEGAL_OP; - } - } - break; - } - case VCD_I_INTRA_PERIOD: - { - if (sizeof(struct vcd_property_i_period) == - property_hdr->sz) { - *(struct vcd_property_i_period *) - property_value = encoder->i_period; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_QP_RANGE: - { - if (sizeof(struct vcd_property_qp_range) == - property_hdr->sz) { - *(struct vcd_property_qp_range *) - property_value = encoder->qp_range; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_SESSION_QP: - { - if (sizeof(struct vcd_property_session_qp) == - property_hdr->sz) { - *(struct vcd_property_session_qp *) - property_value = encoder->session_qp; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_RC_LEVEL_CONFIG: - { - if (sizeof(struct vcd_property_rc_level) == - property_hdr->sz) { - *(struct vcd_property_rc_level *) - property_value = encoder->rc_level; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_FRAME_LEVEL_RC: - { - if (sizeof - (struct vcd_property_frame_level_rc_params) == - property_hdr->sz) { - *(struct vcd_property_frame_level_rc_params - *)property_value = - encoder->frame_level_rc; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_ADAPTIVE_RC: - { - if (sizeof(struct vcd_property_adaptive_rc_params) - == property_hdr->sz) { - *(struct vcd_property_adaptive_rc_params *) - property_value = encoder->adaptive_rc; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_INTRA_REFRESH: - { - intra_refresh = property_value; - if (sizeof - (struct vcd_property_intra_refresh_mb_number) - == property_hdr->sz) { - *intra_refresh = encoder->intra_refresh; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_INPUT_BUF_REQ: - { - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = - encoder->client_input_buf_req; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_OUTPUT_BUF_REQ: - { - if (sizeof(struct vcd_buffer_requirement) == - property_hdr->sz) { - *(struct vcd_buffer_requirement *) - property_value = - encoder->client_output_buf_req; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_BUFFER_FORMAT: - { - if (sizeof(struct vcd_property_buffer_format) == - property_hdr->sz) { - *(struct vcd_property_buffer_format *) - property_value = encoder->buf_format; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case DDL_I_FRAME_PROC_UNITS: - { - if (sizeof(u32) == property_hdr->sz) { - *(u32 *) property_value = - ((encoder->frame_size.width >> 4) * - (encoder->frame_size.height >> 4) - ); - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_HEADER_EXTENSION: - { - if (sizeof(u32) == property_hdr->sz && - encoder->codec.codec == VCD_CODEC_MPEG4) { - *(u32 *) property_value = - encoder->hdr_ext_control; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_METADATA_ENABLE: - case VCD_I_METADATA_HEADER: - { - vcd_status = ddl_get_metadata_params( - ddl, - property_hdr, - property_value); - break; - } - default: - { - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - } - return vcd_status; -} - -static u32 ddl_set_enc_dynamic_property - (struct ddl_client_context *ddl, - struct vcd_property_hdr *property_hdr, void *property_value) { - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - u32 vcd_status = VCD_ERR_ILLEGAL_PARM, dynamic_prop_change = 0x0; - switch (property_hdr->prop_id) { - case VCD_I_REQ_IFRAME: - { - if (sizeof(struct vcd_property_req_i_frame) == - property_hdr->sz) { - dynamic_prop_change = DDL_ENC_REQ_IFRAME; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_TARGET_BITRATE: - { - struct vcd_property_target_bitrate *bitrate = - (struct vcd_property_target_bitrate *) - property_value; - if (sizeof(struct vcd_property_target_bitrate) == - property_hdr->sz && bitrate->target_bitrate > 0 - && bitrate->target_bitrate <= DDL_MAX_BIT_RATE) { - encoder->target_bit_rate = *bitrate; - dynamic_prop_change = DDL_ENC_CHANGE_BITRATE; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_INTRA_PERIOD: - { - struct vcd_property_i_period *iperiod = - (struct vcd_property_i_period *) - property_value; - if (sizeof(struct vcd_property_i_period) == - property_hdr->sz && - !iperiod->b_frames) { - encoder->i_period = *iperiod; - dynamic_prop_change = DDL_ENC_CHANGE_IPERIOD; - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_FRAME_RATE: - { - struct vcd_property_frame_rate *frame_rate = - (struct vcd_property_frame_rate *) - property_value; - if (sizeof(struct vcd_property_frame_rate) - == property_hdr->sz && - frame_rate->fps_denominator && - frame_rate->fps_numerator && - frame_rate->fps_denominator <= - frame_rate->fps_numerator) { - encoder->frame_rate = *frame_rate; - dynamic_prop_change = DDL_ENC_CHANGE_FRAMERATE; - if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN) && - (encoder->codec.codec != VCD_CODEC_MPEG4 - || encoder->short_header.short_header)) - ddl_set_default_enc_vop_timing(encoder); - vcd_status = VCD_S_SUCCESS; - } - break; - } - case VCD_I_INTRA_REFRESH: - { - struct vcd_property_intra_refresh_mb_number - *intra_refresh_mbnum = ( - struct vcd_property_intra_refresh_mb_number *) - property_value; - u32 frame_mbnum = - (encoder->frame_size.width >> 4) * - (encoder->frame_size.height >> 4); - if (sizeof(struct - vcd_property_intra_refresh_mb_number) - == property_hdr->sz && - intra_refresh_mbnum->cir_mb_number <= - frame_mbnum) { - encoder->intra_refresh = - *intra_refresh_mbnum; - dynamic_prop_change = DDL_ENC_CHANGE_CIR; - vcd_status = VCD_S_SUCCESS; - } - - break; - } - default: - { - vcd_status = VCD_ERR_ILLEGAL_OP; - break; - } - } - if (vcd_status == VCD_S_SUCCESS && - (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) || - DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE))) - encoder->dynamic_prop_change |= dynamic_prop_change; - return vcd_status; -} - -void ddl_set_default_dec_property(struct ddl_client_context *ddl) -{ - struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); - - if (decoder->codec.codec >= VCD_CODEC_MPEG2 && - decoder->codec.codec <= VCD_CODEC_XVID) - decoder->post_filter.post_filter = true; - else - decoder->post_filter.post_filter = false; - decoder->buf_format.buffer_format = VCD_BUFFER_FORMAT_NV12; - decoder->client_frame_size.height = 144; - decoder->client_frame_size.width = 176; - decoder->client_frame_size.stride = 176; - decoder->client_frame_size.scan_lines = 144; - decoder->progressive_only = 1; - decoder->idr_only_decoding = 0; - decoder->profile.profile = VCD_PROFILE_UNKNOWN; - decoder->level.level = VCD_LEVEL_UNKNOWN; - decoder->output_order = VCD_DEC_ORDER_DISPLAY; - ddl_set_default_metadata_flag(ddl); - ddl_set_default_decoder_buffer_req(decoder, true); -} - -static void ddl_set_default_enc_property(struct ddl_client_context *ddl) -{ - struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder); - - ddl_set_default_enc_profile(encoder); - ddl_set_default_enc_level(encoder); - - encoder->rc.rate_control = VCD_RATE_CONTROL_VBR_VFR; - ddl_set_default_enc_rc_params(encoder); - - ddl_set_default_enc_intra_period(encoder); - - encoder->intra_refresh.cir_mb_number = 0; - ddl_set_default_enc_vop_timing(encoder); - - encoder->multi_slice.m_slice_sel = VCD_MSLICE_OFF; - encoder->multi_slice.m_slice_size = 0; - encoder->short_header.short_header = false; - - encoder->entropy_control.entropy_sel = VCD_ENTROPY_SEL_CAVLC; - encoder->entropy_control.cabac_model = VCD_CABAC_MODEL_NUMBER_0; - encoder->db_control.db_config = VCD_DB_ALL_BLOCKING_BOUNDARY; - encoder->db_control.slice_alpha_offset = 0; - encoder->db_control.slice_beta_offset = 0; - - encoder->re_con_buf_format.buffer_format = - VCD_BUFFER_FORMAT_TILE_4x2; - - encoder->buf_format.buffer_format = VCD_BUFFER_FORMAT_NV12; - - encoder->hdr_ext_control = 0; - - ddl_set_default_metadata_flag(ddl); - - ddl_set_default_encoder_buffer_req(encoder); -} - -static void ddl_set_default_enc_profile(struct ddl_encoder_data *encoder) -{ - enum vcd_codec codec = encoder->codec.codec; - if (codec == VCD_CODEC_MPEG4) - encoder->profile.profile = VCD_PROFILE_MPEG4_SP; - else if (codec == VCD_CODEC_H264) - encoder->profile.profile = VCD_PROFILE_H264_BASELINE; - else - encoder->profile.profile = VCD_PROFILE_H263_BASELINE; -} - -static void ddl_set_default_enc_level(struct ddl_encoder_data *encoder) -{ - enum vcd_codec codec = encoder->codec.codec; - if (codec == VCD_CODEC_MPEG4) - encoder->level.level = VCD_LEVEL_MPEG4_1; - else if (codec == VCD_CODEC_H264) - encoder->level.level = VCD_LEVEL_H264_1; - else - encoder->level.level = VCD_LEVEL_H263_10; -} - -static void ddl_set_default_enc_vop_timing - (struct ddl_encoder_data *encoder) -{ - if (encoder->codec.codec == VCD_CODEC_MPEG4) - encoder->vop_timing.vop_time_resolution = - (2 * encoder->frame_rate.fps_numerator) / - encoder->frame_rate.fps_denominator; - else - encoder->vop_timing.vop_time_resolution = 0x7530; -} - -static void ddl_set_default_enc_intra_period( - struct ddl_encoder_data *encoder) -{ - switch (encoder->rc.rate_control) { - default: - case VCD_RATE_CONTROL_VBR_VFR: - case VCD_RATE_CONTROL_VBR_CFR: - case VCD_RATE_CONTROL_CBR_VFR: - case VCD_RATE_CONTROL_OFF: - { - encoder->i_period.p_frames = - ((encoder->frame_rate.fps_numerator << 1) / - encoder->frame_rate.fps_denominator) - 1; - break; - } - case VCD_RATE_CONTROL_CBR_CFR: - { - encoder->i_period.p_frames = - ((encoder->frame_rate.fps_numerator >> 1) / - encoder->frame_rate.fps_denominator) - 1; - break; - } - } - encoder->i_period.b_frames = 0; -} - -static void ddl_set_default_enc_rc_params( - struct ddl_encoder_data *encoder) -{ - enum vcd_codec codec = encoder->codec.codec; - - encoder->rc_level.frame_level_rc = true; - encoder->qp_range.min_qp = 0x1; - - if (codec == VCD_CODEC_H264) { - encoder->qp_range.max_qp = 0x33; - encoder->session_qp.i_frame_qp = 0x14; - encoder->session_qp.p_frame_qp = 0x14; - - encoder->rc_level.mb_level_rc = true; - encoder->adaptive_rc.activity_region_flag = true; - encoder->adaptive_rc.dark_region_as_flag = true; - encoder->adaptive_rc.smooth_region_as_flag = true; - encoder->adaptive_rc.static_region_as_flag = true; - } else { - encoder->qp_range.max_qp = 0x1f; - encoder->session_qp.i_frame_qp = 0xd; - encoder->session_qp.p_frame_qp = 0xd; - encoder->rc_level.mb_level_rc = false; - } - - switch (encoder->rc.rate_control) { - default: - case VCD_RATE_CONTROL_VBR_VFR: - { - encoder->r_cframe_skip = 1; - encoder->frame_level_rc.reaction_coeff = 0x1f4; - break; - } - case VCD_RATE_CONTROL_VBR_CFR: - { - encoder->r_cframe_skip = 0; - encoder->frame_level_rc.reaction_coeff = 0x1f4; - break; - } - case VCD_RATE_CONTROL_CBR_VFR: - { - encoder->r_cframe_skip = 1; - if (codec != VCD_CODEC_H264) { - encoder->session_qp.i_frame_qp = 0xf; - encoder->session_qp.p_frame_qp = 0xf; - } - - encoder->frame_level_rc.reaction_coeff = 0x14; - break; - } - case VCD_RATE_CONTROL_CBR_CFR: - { - encoder->r_cframe_skip = 0; - encoder->frame_level_rc.reaction_coeff = 0x6; - break; - } - case VCD_RATE_CONTROL_OFF: - { - encoder->r_cframe_skip = 0; - encoder->rc_level.frame_level_rc = false; - encoder->rc_level.mb_level_rc = false; - break; - } - } -} - -void ddl_set_default_encoder_buffer_req(struct ddl_encoder_data *encoder) -{ - u32 y_cb_cr_size; - - y_cb_cr_size = ddl_get_yuv_buffer_size(&encoder->frame_size, - &encoder->buf_format, false, encoder->codec.codec); - - memset(&encoder->input_buf_req, 0, - sizeof(struct vcd_buffer_requirement)); - - encoder->input_buf_req.min_count = 1; - encoder->input_buf_req.actual_count = - encoder->input_buf_req.min_count + 8; - encoder->input_buf_req.max_count = DDL_MAX_BUFFER_COUNT; - encoder->input_buf_req.sz = y_cb_cr_size; - encoder->input_buf_req.align = DDL_LINEAR_BUFFER_ALIGN_BYTES; - - encoder->client_input_buf_req = encoder->input_buf_req; - - memset(&encoder->output_buf_req, 0, - sizeof(struct vcd_buffer_requirement)); - - encoder->output_buf_req.min_count = 2; - encoder->output_buf_req.actual_count = - encoder->output_buf_req.min_count + 3; - encoder->output_buf_req.max_count = DDL_MAX_BUFFER_COUNT; - encoder->output_buf_req.align = DDL_LINEAR_BUFFER_ALIGN_BYTES; - encoder->output_buf_req.sz = y_cb_cr_size; - ddl_set_default_encoder_metadata_buffer_size(encoder); - encoder->client_output_buf_req = encoder->output_buf_req; -} - -void ddl_set_default_decoder_buffer_req(struct ddl_decoder_data *decoder, - u32 estimate) -{ - u32 y_cb_cr_size, min_dpb, num_mb; - struct vcd_property_frame_size *frame_size; - struct vcd_buffer_requirement *output_buf_req, *input_buf_req; - - if (!decoder->codec.codec) - return; - - if (estimate) { - frame_size = &decoder->client_frame_size; - output_buf_req = &decoder->client_output_buf_req; - input_buf_req = &decoder->client_input_buf_req; - min_dpb = ddl_decoder_min_num_dpb(decoder); - y_cb_cr_size = ddl_get_yuv_buffer_size(frame_size, - &decoder->buf_format, (!decoder->progressive_only), - decoder->codec.codec); - } else { - frame_size = &decoder->frame_size; - output_buf_req = &decoder->actual_output_buf_req; - input_buf_req = &decoder->actual_input_buf_req; - y_cb_cr_size = decoder->y_cb_cr_size; - min_dpb = decoder->min_dpb_num; - } - - if (decoder->idr_only_decoding) - min_dpb = 1; - - memset(output_buf_req, 0, sizeof(struct vcd_buffer_requirement)); - - output_buf_req->min_count = min_dpb; - - num_mb = DDL_NO_OF_MB(frame_size->width, frame_size->height); - if (decoder->idr_only_decoding) { - output_buf_req->actual_count = output_buf_req->min_count; - } else { - if (num_mb >= DDL_WVGA_MBS) { - output_buf_req->actual_count = min_dpb + 2; - if (output_buf_req->actual_count < 10) - output_buf_req->actual_count = 10; - } else - output_buf_req->actual_count = min_dpb + 5; - } - output_buf_req->max_count = DDL_MAX_BUFFER_COUNT; - output_buf_req->sz = y_cb_cr_size; - if (decoder->buf_format.buffer_format != VCD_BUFFER_FORMAT_NV12) - output_buf_req->align = DDL_TILE_BUFFER_ALIGN_BYTES; - else - output_buf_req->align = DDL_LINEAR_BUFFER_ALIGN_BYTES; - - ddl_set_default_decoder_metadata_buffer_size(decoder, - frame_size, output_buf_req); - - decoder->min_output_buf_req = *output_buf_req; - - memset(input_buf_req, 0, sizeof(struct vcd_buffer_requirement)); - - input_buf_req->min_count = 1; - input_buf_req->actual_count = input_buf_req->min_count + 3; - input_buf_req->max_count = DDL_MAX_BUFFER_COUNT; - input_buf_req->sz = (1280*720*3*3) >> 3; - input_buf_req->align = DDL_LINEAR_BUFFER_ALIGN_BYTES; - - decoder->min_input_buf_req = *input_buf_req; - -} - -u32 ddl_get_yuv_buffer_size(struct vcd_property_frame_size *frame_size, - struct vcd_property_buffer_format *buf_format, u32 inter_lace, - enum vcd_codec codec) -{ - struct vcd_property_frame_size frame_sz = *frame_size; - u32 total_memory_size; - ddl_calculate_stride(&frame_sz, inter_lace, codec); - - if (buf_format->buffer_format != VCD_BUFFER_FORMAT_NV12) { - u32 component_mem_size; - u32 width_round_up; - u32 height_round_up; - u32 height_chroma = (frame_sz.scan_lines >> 1); - - width_round_up = - DDL_TILE_ALIGN(frame_sz.stride, DDL_TILE_ALIGN_WIDTH); - height_round_up = - DDL_TILE_ALIGN(frame_sz.scan_lines, DDL_TILE_ALIGN_HEIGHT); - - component_mem_size = width_round_up * height_round_up; - component_mem_size = DDL_TILE_ALIGN(component_mem_size, - DDL_TILE_MULTIPLY_FACTOR); - - total_memory_size = ((component_mem_size + - DDL_TILE_BUF_ALIGN_GUARD_BYTES) & - DDL_TILE_BUF_ALIGN_MASK); - - height_round_up = - DDL_TILE_ALIGN(height_chroma, DDL_TILE_ALIGN_HEIGHT); - component_mem_size = width_round_up * height_round_up; - component_mem_size = DDL_TILE_ALIGN(component_mem_size, - DDL_TILE_MULTIPLY_FACTOR); - total_memory_size += component_mem_size; - } else { - total_memory_size = frame_sz.scan_lines * frame_sz.stride; - total_memory_size += (total_memory_size >> 1); - } - return total_memory_size; -} - -void ddl_calculate_stride(struct vcd_property_frame_size *frame_size, - u32 interlace, enum vcd_codec codec) -{ - frame_size->stride = ((frame_size->width + 15) >> 4) << 4; - if (!interlace || codec == VCD_CODEC_MPEG4 || - codec == VCD_CODEC_DIVX_4 || - codec == VCD_CODEC_DIVX_5 || - codec == VCD_CODEC_DIVX_6 || - codec == VCD_CODEC_XVID) { - frame_size->scan_lines = - ((frame_size->height + 15) >> 4) << 4; - } else { - frame_size->scan_lines = - ((frame_size->height + 31) >> 5) << 5; - } - -} - -static u32 ddl_valid_buffer_requirement - (struct vcd_buffer_requirement *original_buf_req, - struct vcd_buffer_requirement *req_buf_req) -{ - u32 status = false; - if (original_buf_req->max_count >= req_buf_req->actual_count && - original_buf_req->min_count <= req_buf_req->actual_count && - original_buf_req->align <= req_buf_req->align && - original_buf_req->sz <= req_buf_req->sz) { - status = true; - } else { - VIDC_LOGERR_STRING("ddl_valid_buf_req:Failed"); - } - return status; -} - -static u32 ddl_decoder_min_num_dpb(struct ddl_decoder_data *decoder) -{ - u32 min_dpb = 0, yuv_size = 0; - struct vcd_property_frame_size frame_sz = decoder->client_frame_size; - switch (decoder->codec.codec) { - default: - case VCD_CODEC_MPEG4: - case VCD_CODEC_MPEG2: - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_XVID: - { - min_dpb = 3; - break; - } - case VCD_CODEC_H263: - { - min_dpb = 2; - break; - } - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - { - min_dpb = 4; - break; - } - case VCD_CODEC_H264: - { - ddl_calculate_stride(&frame_sz, - !decoder->progressive_only, - decoder->codec.codec); - yuv_size = - ((frame_sz.scan_lines * - frame_sz.stride * 3) >> 1); - min_dpb = 6912000 / yuv_size; - if (min_dpb > 16) - min_dpb = 16; - - min_dpb += 2; - break; - } - } - return min_dpb; -} - -static u32 ddl_set_dec_buffers - (struct ddl_decoder_data *decoder, - struct ddl_property_dec_pic_buffers *dpb) { - u32 vcd_status = VCD_S_SUCCESS; - u32 loopc; - for (loopc = 0; !vcd_status && - loopc < dpb->no_of_dec_pic_buf; ++loopc) { - if ((!DDL_ADDR_IS_ALIGNED - (dpb->dec_pic_buffers[loopc].vcd_frm.physical, - decoder->client_output_buf_req.align) - ) - || (dpb->dec_pic_buffers[loopc].vcd_frm.alloc_len < - decoder->client_output_buf_req.sz) - ) { - vcd_status = VCD_ERR_ILLEGAL_PARM; - } - } - if (vcd_status) { - VIDC_LOGERR_STRING - ("ddl_set_prop:Dpb_align_fail_or_alloc_size_small"); - return vcd_status; - } - if (decoder->dp_buf.no_of_dec_pic_buf) { - DDL_FREE(decoder->dp_buf.dec_pic_buffers); - decoder->dp_buf.no_of_dec_pic_buf = 0; - } - decoder->dp_buf.dec_pic_buffers = - DDL_MALLOC(dpb->no_of_dec_pic_buf * - sizeof(struct ddl_frame_data_tag)); - - if (!decoder->dp_buf.dec_pic_buffers) { - VIDC_LOGERR_STRING - ("ddl_dec_set_prop:Dpb_container_alloc_failed"); - return VCD_ERR_ALLOC_FAIL; - } - decoder->dp_buf.no_of_dec_pic_buf = dpb->no_of_dec_pic_buf; - for (loopc = 0; loopc < dpb->no_of_dec_pic_buf; ++loopc) { - decoder->dp_buf.dec_pic_buffers[loopc] = - dpb->dec_pic_buffers[loopc]; - } - decoder->dpb_mask.client_mask = 0; - decoder->dpb_mask.hw_mask = 0; - decoder->dynamic_prop_change = 0; - return VCD_S_SUCCESS; -} - -void ddl_set_initial_default_values(struct ddl_client_context *ddl) -{ - if (ddl->decoding) { - ddl->codec_data.decoder.codec.codec = VCD_CODEC_MPEG4; - vcd_fw_transact(true, true, - ddl->codec_data.decoder.codec.codec); - ddl_set_default_dec_property(ddl); - } else { - struct ddl_encoder_data *encoder = - &(ddl->codec_data.encoder); - encoder->codec.codec = VCD_CODEC_MPEG4; - vcd_fw_transact(true, false, - encoder->codec.codec); - - encoder->target_bit_rate.target_bitrate = 64000; - encoder->frame_size.width = 176; - encoder->frame_size.height = 144; - encoder->frame_size.stride = 176; - encoder->frame_size.scan_lines = 144; - encoder->frame_rate.fps_numerator = 30; - encoder->frame_rate.fps_denominator = 1; - ddl_set_default_enc_property(ddl); - } - - return; -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_utils.c b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_utils.c deleted file mode 100644 index edc8112af89f11e50e0bdfa8367acae232e07581..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_utils.c +++ /dev/null @@ -1,269 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include "vcd_ddl_utils.h" -#include "vcd_res_tracker_api.h" - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -#define DBG_TIME(x...) printk(KERN_DEBUG x) -#define ERR(x...) printk(KERN_ERR x) - -struct time_data { - unsigned int ddl_t1; - unsigned int ddl_ttotal; - unsigned int ddl_count; -}; - -static struct time_data proc_time[MAX_TIME_DATA]; - -#ifdef NO_IN_KERNEL_PMEM - -void ddl_pmem_alloc(struct ddl_buf_addr *buff_addr, size_t sz, u32 align) -{ - u32 guard_bytes, align_mask; - u32 physical_addr, align_offset; - dma_addr_t phy_addr; - - if (align == DDL_LINEAR_BUFFER_ALIGN_BYTES) { - - guard_bytes = 31; - align_mask = 0xFFFFFFE0U; - - } else { - - guard_bytes = DDL_TILE_BUF_ALIGN_GUARD_BYTES; - align_mask = DDL_TILE_BUF_ALIGN_MASK; - } - - buff_addr->virtual_base_addr = - kmalloc((sz + guard_bytes), GFP_KERNEL); - - if (!buff_addr->virtual_base_addr) { - ERR("\n ERROR %s:%u kamlloc fails to allocate" - " sz + guard_bytes = %u\n", __func__, __LINE__, - (sz + guard_bytes)); - return; - } - - phy_addr = dma_map_single(NULL, buff_addr->virtual_base_addr, - sz + guard_bytes, DMA_TO_DEVICE); - - buff_addr->buffer_size = sz; - physical_addr = (u32) phy_addr; - buff_addr->align_physical_addr = - (u32 *) ((physical_addr + guard_bytes) & align_mask); - align_offset = - (u32) (buff_addr->align_physical_addr) - physical_addr; - buff_addr->align_virtual_addr = - (u32 *) ((u32) (buff_addr->virtual_base_addr) - + align_offset); -} - -void ddl_pmem_free(struct ddl_buf_addr *buff_addr) -{ - kfree(buff_addr->virtual_base_addr); - buff_addr->buffer_size = 0; - buff_addr->virtual_base_addr = NULL; -} - -#else - -void ddl_pmem_alloc(struct ddl_buf_addr *buff_addr, size_t sz, u32 align) -{ - u32 guard_bytes, align_mask; - u32 align_offset; - u32 alloc_size; - struct ddl_context *ddl_context; - unsigned long *kernel_vaddr = NULL; - ion_phys_addr_t phyaddr = 0; - size_t len = 0; - int ret = -EINVAL; - - if (!buff_addr) { - ERR("\n%s() Invalid Parameters\n", __func__); - return; - } - if (align == DDL_LINEAR_BUFFER_ALIGN_BYTES) { - guard_bytes = 31; - align_mask = 0xFFFFFFE0U; - } else { - guard_bytes = DDL_TILE_BUF_ALIGN_GUARD_BYTES; - align_mask = DDL_TILE_BUF_ALIGN_MASK; - } - ddl_context = ddl_get_context(); - alloc_size = sz + guard_bytes; - if (res_trk_get_enable_ion()) { - if (!ddl_context->video_ion_client) - ddl_context->video_ion_client = - res_trk_get_ion_client(); - if (!ddl_context->video_ion_client) { - ERR("\n%s(): DDL ION Client Invalid handle\n", - __func__); - goto bailout; - } - buff_addr->mem_type = res_trk_get_mem_type(); - buff_addr->alloc_handle = ion_alloc( - ddl_context->video_ion_client, - alloc_size, - SZ_4K, - buff_addr->mem_type, 0); - if (IS_ERR_OR_NULL(buff_addr->alloc_handle)) { - ERR("\n%s(): DDL ION alloc failed\n", __func__); - goto bailout; - } - ret = ion_phys(ddl_context->video_ion_client, - buff_addr->alloc_handle, - &phyaddr, - &len); - if (ret || !phyaddr) { - ERR("\n%s(): DDL ION client physical failed\n", - __func__); - goto free_ion_buffer; - } - buff_addr->physical_base_addr = (u32 *)phyaddr; - kernel_vaddr = (unsigned long *) ion_map_kernel( - ddl_context->video_ion_client, - buff_addr->alloc_handle); - if (IS_ERR_OR_NULL(kernel_vaddr)) { - ERR("\n%s(): DDL ION map failed\n", __func__); - goto unmap_ion_buffer; - } - buff_addr->virtual_base_addr = (u32 *)kernel_vaddr; - DBG("ddl_ion_alloc: handle(0x%x), mem_type(0x%x), "\ - "phys(0x%x), virt(0x%x), size(%u), align(%u), "\ - "alloced_len(%u)", (u32)buff_addr->alloc_handle, - (u32)buff_addr->mem_type, - (u32)buff_addr->physical_base_addr, - (u32)buff_addr->virtual_base_addr, - alloc_size, align, len); - } else { - pr_err("ION must be enabled."); - goto bailout; - } - - memset(buff_addr->virtual_base_addr, 0 , sz + guard_bytes); - buff_addr->buffer_size = sz; - buff_addr->align_physical_addr = (u32 *) - (((u32)buff_addr->physical_base_addr + guard_bytes) & - align_mask); - align_offset = (u32) (buff_addr->align_physical_addr) - - (u32)buff_addr->physical_base_addr; - buff_addr->align_virtual_addr = - (u32 *) ((u32) (buff_addr->virtual_base_addr) - + align_offset); - DBG("%s(): phys(0x%x) align_phys(0x%x), virt(0x%x),"\ - " align_virt(0x%x)", __func__, - (u32)buff_addr->physical_base_addr, - (u32)buff_addr->align_physical_addr, - (u32)buff_addr->virtual_base_addr, - (u32)buff_addr->align_virtual_addr); - return; - -unmap_ion_buffer: - if (ddl_context->video_ion_client) { - if (buff_addr->alloc_handle) - ion_unmap_kernel(ddl_context->video_ion_client, - buff_addr->alloc_handle); - } -free_ion_buffer: - if (ddl_context->video_ion_client) { - if (buff_addr->alloc_handle) - ion_free(ddl_context->video_ion_client, - buff_addr->alloc_handle); - } -bailout: - memset(buff_addr, 0, sizeof(struct ddl_buf_addr)); -} - -void ddl_pmem_free(struct ddl_buf_addr *buff_addr) -{ - struct ddl_context *ddl_context; - ddl_context = ddl_get_context(); - if (!buff_addr) { - ERR("\n %s() invalid arguments %p", __func__, buff_addr); - return; - } - DBG("ddl_pmem_free: phys(0x%x) align_phys(0x%x), "\ - "virt(0x%x), align_virt(0x%x), size(%u)", - (u32)buff_addr->physical_base_addr, - (u32)buff_addr->align_physical_addr, - (u32)buff_addr->virtual_base_addr, - (u32)buff_addr->align_virtual_addr, - buff_addr->buffer_size); - if (ddl_context->video_ion_client) { - if (buff_addr->alloc_handle) { - ion_unmap_kernel(ddl_context->video_ion_client, - buff_addr->alloc_handle); - ion_free(ddl_context->video_ion_client, - buff_addr->alloc_handle); - } - } - memset(buff_addr, 0, sizeof(struct ddl_buf_addr)); -} -#endif - -void ddl_set_core_start_time(const char *func_name, u32 index) -{ - u32 act_time; - struct timeval ddl_tv; - struct time_data *time_data = &proc_time[index]; - do_gettimeofday(&ddl_tv); - act_time = (ddl_tv.tv_sec * 1000) + (ddl_tv.tv_usec / 1000); - if (!time_data->ddl_t1) { - time_data->ddl_t1 = act_time; - DBG("\n%s(): Start Time (%u)", func_name, act_time); - } else { - DBG_TIME("\n%s(): Timer already started! St(%u) Act(%u)", - func_name, time_data->ddl_t1, act_time); - } -} - -void ddl_calc_core_proc_time(const char *func_name, u32 index) -{ - struct time_data *time_data = &proc_time[index]; - if (time_data->ddl_t1) { - int ddl_t2; - struct timeval ddl_tv; - do_gettimeofday(&ddl_tv); - ddl_t2 = (ddl_tv.tv_sec * 1000) + (ddl_tv.tv_usec / 1000); - time_data->ddl_ttotal += (ddl_t2 - time_data->ddl_t1); - time_data->ddl_count++; - DBG_TIME("\n%s(): cnt(%u) Diff(%u) Avg(%u)", - func_name, time_data->ddl_count, - ddl_t2 - time_data->ddl_t1, - time_data->ddl_ttotal/time_data->ddl_count); - time_data->ddl_t1 = 0; - } -} - -void ddl_reset_core_time_variables(u32 index) -{ - proc_time[index].ddl_t1 = 0; - proc_time[index].ddl_ttotal = 0; - proc_time[index].ddl_count = 0; -} -int ddl_get_core_decode_proc_time(u32 *ddl_handle) -{ - return 0; -} - -void ddl_reset_avg_dec_time(u32 *ddl_handle) -{ - return; -} diff --git a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_utils.h b/drivers/video/msm/vidc/720p/ddl/vcd_ddl_utils.h deleted file mode 100644 index 633292b23e9e59d04d3fea34269026a130c4dd14..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vcd_ddl_utils.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) 2010-2011, 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 _VCD_DDL_UTILS_H_ -#define _VCD_DDL_UTILS_H_ - -#include "vcd_ddl_core.h" -#include "vcd_ddl.h" - -extern u32 vidc_msg_pmem; -extern u32 vidc_msg_timing; - -enum timing_data { - DEC_OP_TIME, - DEC_IP_TIME, - ENC_OP_TIME, - MAX_TIME_DATA -}; - -#define DDL_INLINE - -#define DDL_ALIGN_SIZE(sz, guard_bytes, align_mask) \ - (((u32)(sz) + guard_bytes) & align_mask) - -#define DDL_MALLOC(x) kmalloc(x, GFP_KERNEL) -#define DDL_FREE(x) { if ((x)) kfree((x)); (x) = NULL; } - -#define DBG_PMEM(x...) \ -do { \ - if (vidc_msg_pmem) \ - printk(KERN_DEBUG x); \ -} while (0) - -void ddl_set_core_start_time(const char *func_name, u32 index); - -void ddl_calc_core_proc_time(const char *func_name, u32 index); - -void ddl_reset_core_time_variables(u32 index); - -int ddl_get_core_decode_proc_time(u32 *ddl_handle); - -void ddl_reset_avg_dec_time(u32 *ddl_handle); - -#define DDL_ASSERT(x) -#define DDL_MEMSET(src, value, len) memset((src), (value), (len)) -#define DDL_MEMCPY(dest, src, len) memcpy((dest), (src), (len)) - -#define DDL_ADDR_IS_ALIGNED(addr, align_bytes) \ -(!((u32)(addr) & ((align_bytes) - 1))) - -#endif diff --git a/drivers/video/msm/vidc/720p/ddl/vidc.c b/drivers/video/msm/vidc/720p/ddl/vidc.c deleted file mode 100644 index da969ef64233e411b37ee61c28d26ee0f5e340ce..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vidc.c +++ /dev/null @@ -1,804 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include "vidc.h" - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -#define VIDC_720P_VERSION_STRING "VIDC_V1.0" -u8 *vidc_base_addr; - -#ifdef VIDC_REGISTER_LOG_INTO_BUFFER -char vidclog[VIDC_REGLOG_BUFSIZE]; -unsigned int vidclog_index; -#endif - -void vidc_720p_set_device_virtual_base(u8 *core_virtual_base_addr) -{ - vidc_base_addr = core_virtual_base_addr; -} - -void vidc_720p_init(char **ppsz_version, u32 i_firmware_size, - u32 *pi_firmware_address, - enum vidc_720p_endian dma_endian, - u32 interrupt_off, - enum vidc_720p_interrupt_level_selection - interrupt_sel, u32 interrupt_mask) -{ - if (ppsz_version) - *ppsz_version = VIDC_720P_VERSION_STRING; - - if (interrupt_sel == VIDC_720P_INTERRUPT_LEVEL_SEL) - VIDC_IO_OUT(REG_491082, 0); - else - VIDC_IO_OUT(REG_491082, 1); - - if (interrupt_off) - VIDC_IO_OUT(REG_609676, 1); - else - VIDC_IO_OUT(REG_609676, 0); - - VIDC_IO_OUT(REG_614776, 1); - - VIDC_IO_OUT(REG_418173, 0); - - VIDC_IO_OUT(REG_418173, interrupt_mask); - - VIDC_IO_OUT(REG_736316, dma_endian); - - VIDC_IO_OUT(REG_215724, 0); - - VIDC_IO_OUT(REG_361582, 1); - - VIDC_IO_OUT(REG_591577, i_firmware_size); - - VIDC_IO_OUT(REG_203921, pi_firmware_address); - - VIDC_IO_OUT(REG_531515_ADDR, 0); - - VIDC_IO_OUT(REG_614413, 1); -} - -u32 vidc_720p_do_sw_reset(void) -{ - - u32 fw_start = 0; - VIDC_BUSY_WAIT(5); - VIDC_IO_OUT(REG_224135, 0); - VIDC_BUSY_WAIT(5); - VIDC_IO_OUT(REG_193553, 0); - VIDC_BUSY_WAIT(5); - VIDC_IO_OUT(REG_141269, 1); - VIDC_BUSY_WAIT(15); - VIDC_IO_OUT(REG_141269, 0); - VIDC_BUSY_WAIT(5); - VIDC_IO_IN(REG_193553, &fw_start); - - if (!fw_start) { - DBG("\n VIDC-SW-RESET-FAILS!"); - return false; - } - return true; -} - -u32 vidc_720p_reset_is_success() -{ - u32 stagecounter = 0; - VIDC_IO_IN(REG_352831, &stagecounter); - stagecounter &= 0xff; - if (stagecounter != 0xe5) { - DBG("\n VIDC-CPU_RESET-FAILS!"); - VIDC_IO_OUT(REG_224135, 0); - msleep(10); - return false; - } - return true; -} - -void vidc_720p_start_cpu(enum vidc_720p_endian dma_endian, - u32 *icontext_bufferstart, - u32 *debug_core_dump_addr, - u32 debug_buffer_size) -{ - u32 dbg_info_input0_reg = 0x1; - VIDC_IO_OUT(REG_361582, 0); - VIDC_IO_OUT(REG_958768, icontext_bufferstart); - VIDC_IO_OUT(REG_736316, dma_endian); - if (debug_buffer_size) { - dbg_info_input0_reg = (debug_buffer_size << 0x10) - | (0x2 << 1) | 0x1; - VIDC_IO_OUT(REG_166247, debug_core_dump_addr); - } - VIDC_IO_OUT(REG_699747, dbg_info_input0_reg); - VIDC_IO_OUT(REG_224135, 1); -} - -u32 vidc_720p_cpu_start() -{ - u32 fw_status = 0x0; - VIDC_IO_IN(REG_381535, &fw_status); - if (fw_status != 0x02) - return false; - return true; -} - - -void vidc_720p_stop_fw(void) -{ - VIDC_IO_OUT(REG_193553, 0); - VIDC_IO_OUT(REG_224135, 0); -} - -void vidc_720p_get_interrupt_status(u32 *interrupt_status, - u32 *cmd_err_status, u32 *disp_pic_err_status, u32 *op_failed) -{ - u32 err_status; - VIDC_IO_IN(REG_512143, interrupt_status); - VIDC_IO_IN(REG_300310, &err_status); - *cmd_err_status = err_status & 0xffff; - *disp_pic_err_status = (err_status & 0xffff0000) >> 16; - VIDC_IO_INF(REG_724381, OPERATION_FAILED, \ - op_failed); -} - -void vidc_720p_interrupt_done_clear(void) -{ - VIDC_IO_OUT(REG_614776, 1); - VIDC_IO_OUT(REG_97293, 4); -} - -void vidc_720p_submit_command(u32 ch_id, u32 cmd_id) -{ - u32 fw_status; - VIDC_IO_OUT(REG_97293, ch_id); - VIDC_IO_OUT(REG_62325, cmd_id); - VIDC_DEBUG_REGISTER_LOG; - VIDC_IO_IN(REG_381535, &fw_status); - VIDC_IO_OUT(REG_926519, fw_status); -} - -u32 vidc_720p_engine_reset(u32 ch_id, - enum vidc_720p_endian dma_endian, - enum vidc_720p_interrupt_level_selection interrupt_sel, - u32 interrupt_mask -) -{ - u32 op_done = 0; - u32 counter = 0; - - VIDC_LOGERR_STRING("ENG-RESET!!"); - /* issue the engine reset command */ - vidc_720p_submit_command(ch_id, VIDC_720P_CMD_MFC_ENGINE_RESET); - - do { - VIDC_BUSY_WAIT(20); - VIDC_IO_IN(REG_982553, &op_done); - counter++; - } while (!op_done && counter < 10); - - if (!op_done) { - /* Reset fails */ - return false ; - } - - /* write invalid channel id */ - VIDC_IO_OUT(REG_97293, 4); - - /* Set INT_PULSE_SEL */ - if (interrupt_sel == VIDC_720P_INTERRUPT_LEVEL_SEL) - VIDC_IO_OUT(REG_491082, 0); - else - VIDC_IO_OUT(REG_491082, 1); - - if (!interrupt_mask) { - /* Disable interrupt */ - VIDC_IO_OUT(REG_609676, 1); - } else { - /* Enable interrupt */ - VIDC_IO_OUT(REG_609676, 0); - } - - /* Clear any pending interrupt */ - VIDC_IO_OUT(REG_614776, 1); - - /* Set INT_ENABLE_REG */ - VIDC_IO_OUT(REG_418173, interrupt_mask); - - /*Sets the DMA endianness */ - VIDC_IO_OUT(REG_736316, dma_endian); - - /*Restore ARM endianness */ - VIDC_IO_OUT(REG_215724, 0); - - /* retun engine reset success */ - return true ; -} - -void vidc_720p_set_channel(u32 i_ch_id, - enum vidc_720p_enc_dec_selection - enc_dec_sel, enum vidc_720p_codec codec, - u32 *pi_fw, u32 i_firmware_size) -{ - u32 std_sel = 0; - VIDC_IO_OUT(REG_661565, 0); - - if (enc_dec_sel) - std_sel = VIDC_REG_713080_ENC_ON_BMSK; - - std_sel |= (u32) codec; - - VIDC_IO_OUT(REG_713080, std_sel); - - switch (codec) { - default: - case VIDC_720P_DIVX: - case VIDC_720P_XVID: - case VIDC_720P_MPEG4: - { - if (enc_dec_sel == VIDC_720P_ENCODER) - VIDC_IO_OUT(REG_765787, pi_fw); - else - VIDC_IO_OUT(REG_225040, pi_fw); - break; - } - case VIDC_720P_H264: - { - if (enc_dec_sel == VIDC_720P_ENCODER) - VIDC_IO_OUT(REG_942456, pi_fw); - else - VIDC_IO_OUT(REG_942170_ADDR_3, pi_fw); - break; - } - case VIDC_720P_H263: - { - if (enc_dec_sel == VIDC_720P_ENCODER) - VIDC_IO_OUT(REG_765787, pi_fw); - else - VIDC_IO_OUT(REG_942170_ADDR_6, pi_fw); - break; - } - case VIDC_720P_VC1: - { - VIDC_IO_OUT(REG_880188, pi_fw); - break; - } - case VIDC_720P_MPEG2: - { - VIDC_IO_OUT(REG_40293, pi_fw); - break; - } - } - VIDC_IO_OUT(REG_591577, i_firmware_size); - - vidc_720p_submit_command(i_ch_id, VIDC_720P_CMD_CHSET); -} - -void vidc_720p_encode_set_profile(u32 i_profile, u32 i_level) -{ - u32 profile_level = i_profile|(i_level << 0x8); - VIDC_IO_OUT(REG_839021, profile_level); -} - -void vidc_720p_set_frame_size(u32 i_size_x, u32 i_size_y) -{ - VIDC_IO_OUT(REG_999267, i_size_x); - - VIDC_IO_OUT(REG_345712, i_size_y); -} - -void vidc_720p_encode_set_fps(u32 i_rc_frame_rate) -{ - VIDC_IO_OUT(REG_625444, i_rc_frame_rate); -} - -void vidc_720p_encode_set_short_header(u32 i_short_header) -{ - VIDC_IO_OUT(REG_314290, i_short_header); -} - -void vidc_720p_encode_set_vop_time(u32 vop_time_resolution, - u32 vop_time_increment) -{ - u32 enable_vop, vop_timing_reg; - if (!vop_time_resolution) - VIDC_IO_OUT(REG_64895, 0x0); - else { - enable_vop = 0x1; - vop_timing_reg = (enable_vop << 0x1f) | - (vop_time_resolution << 0x10) | vop_time_increment; - VIDC_IO_OUT(REG_64895, vop_timing_reg); - } -} - -void vidc_720p_encode_set_hec_period(u32 hec_period) -{ - VIDC_IO_OUT(REG_407718, hec_period); -} - -void vidc_720p_encode_set_qp_params(u32 i_max_qp, u32 i_min_qp) -{ - u32 qp = i_min_qp | (i_max_qp << 0x8); - VIDC_IO_OUT(REG_734318, qp); -} - -void vidc_720p_encode_set_rc_config(u32 enable_frame_level_rc, - u32 enable_mb_level_rc_flag, - u32 i_frame_qp, u32 pframe_qp) -{ - u32 rc_config = i_frame_qp; - - if (enable_frame_level_rc) - rc_config |= (0x1 << 0x9); - - if (enable_mb_level_rc_flag) - rc_config |= (0x1 << 0x8); - - VIDC_IO_OUT(REG_58211, rc_config); - VIDC_IO_OUT(REG_548359, pframe_qp); -} - -void vidc_720p_encode_set_bit_rate(u32 i_target_bitrate) -{ - VIDC_IO_OUT(REG_174150, i_target_bitrate); -} - -void vidc_720p_encoder_set_param_change(u32 enc_param_change) -{ - VIDC_IO_OUT(REG_804959, enc_param_change); -} - -void vidc_720p_encode_set_control_param(u32 param_val) -{ - VIDC_IO_OUT(REG_128234, param_val); -} - -void vidc_720p_encode_set_frame_level_rc_params(u32 i_reaction_coeff) -{ - VIDC_IO_OUT(REG_677784, i_reaction_coeff); -} - -void vidc_720p_encode_set_mb_level_rc_params(u32 dark_region_as_flag, - u32 smooth_region_as_flag, - u32 static_region_as_flag, - u32 activity_region_flag) -{ - u32 mb_level_rc = 0x0; - if (activity_region_flag) - mb_level_rc |= 0x1; - if (static_region_as_flag) - mb_level_rc |= (0x1 << 0x1); - if (smooth_region_as_flag) - mb_level_rc |= (0x1 << 0x2); - if (dark_region_as_flag) - mb_level_rc |= (0x1 << 0x3); - /* Write MB level rate control */ - VIDC_IO_OUT(REG_995041, mb_level_rc); -} - -void vidc_720p_encode_set_entropy_control(enum vidc_720p_entropy_sel - entropy_sel, - enum vidc_720p_cabac_model - cabac_model_number) -{ - u32 num; - u32 entropy_params = (u32)entropy_sel; - /* Set Model Number */ - if (entropy_sel == VIDC_720P_ENTROPY_SEL_CABAC) { - num = (u32)cabac_model_number; - entropy_params |= (num << 0x2); - } - /* Set Entropy parameters */ - VIDC_IO_OUT(REG_504878, entropy_params); -} - -void vidc_720p_encode_set_db_filter_control(enum vidc_720p_DBConfig - db_config, - u32 i_slice_alpha_offset, - u32 i_slice_beta_offset) -{ - u32 deblock_params; - deblock_params = (u32)db_config; - deblock_params |= - ((i_slice_beta_offset << 0x2) | (i_slice_alpha_offset << 0x7)); - - /* Write deblocking control settings */ - VIDC_IO_OUT(REG_458130, deblock_params); -} - -void vidc_720p_encode_set_intra_refresh_mb_number(u32 i_cir_mb_number) -{ - VIDC_IO_OUT(REG_857491, i_cir_mb_number); -} - -void vidc_720p_encode_set_multi_slice_info(enum - vidc_720p_MSlice_selection - m_slice_sel, - u32 multi_slice_size) -{ - switch (m_slice_sel) { - case VIDC_720P_MSLICE_BY_MB_COUNT: - { - VIDC_IO_OUT(REG_588301, 0x1); - VIDC_IO_OUT(REG_1517, m_slice_sel); - VIDC_IO_OUT(REG_105335, multi_slice_size); - break; - } - case VIDC_720P_MSLICE_BY_BYTE_COUNT: - { - VIDC_IO_OUT(REG_588301, 0x1); - VIDC_IO_OUT(REG_1517, m_slice_sel); - VIDC_IO_OUT(REG_561679, multi_slice_size); - break; - } - case VIDC_720P_MSLICE_BY_GOB: - { - VIDC_IO_OUT(REG_588301, 0x1); - break; - } - default: - case VIDC_720P_MSLICE_OFF: - { - VIDC_IO_OUT(REG_588301, 0x0); - break; - } - } -} - -void vidc_720p_encode_set_dpb_buffer(u32 *pi_enc_dpb_addr, u32 alloc_len) -{ - VIDC_IO_OUT(REG_341928_ADDR, pi_enc_dpb_addr); - VIDC_IO_OUT(REG_319934, alloc_len); -} - -void vidc_720p_encode_set_i_period(u32 i_i_period) -{ - VIDC_IO_OUT(REG_950374, i_i_period); -} - -void vidc_720p_encode_init_codec(u32 i_ch_id, - enum vidc_720p_memory_access_method - memory_access_model) -{ - - VIDC_IO_OUT(REG_841539, memory_access_model); - vidc_720p_submit_command(i_ch_id, VIDC_720P_CMD_INITCODEC); -} - -void vidc_720p_encode_unalign_bitstream(u32 upper_unalign_word, - u32 lower_unalign_word) -{ - VIDC_IO_OUT(REG_792026, upper_unalign_word); - VIDC_IO_OUT(REG_844152, lower_unalign_word); -} - -void vidc_720p_encode_set_seq_header_buffer(u32 ext_buffer_start, - u32 ext_buffer_end, - u32 start_byte_num) -{ - VIDC_IO_OUT(REG_275113_ADDR, ext_buffer_start); - - VIDC_IO_OUT(REG_87912, ext_buffer_start); - - VIDC_IO_OUT(REG_988007_ADDR, ext_buffer_end); - - VIDC_IO_OUT(REG_66693, start_byte_num); -} - -void vidc_720p_encode_frame(u32 ch_id, - u32 ext_buffer_start, - u32 ext_buffer_end, - u32 start_byte_number, u32 y_addr, - u32 c_addr) -{ - VIDC_IO_OUT(REG_275113_ADDR, ext_buffer_start); - - VIDC_IO_OUT(REG_988007_ADDR, ext_buffer_end); - - VIDC_IO_OUT(REG_87912, ext_buffer_start); - - VIDC_IO_OUT(REG_66693, start_byte_number); - - VIDC_IO_OUT(REG_99105, y_addr); - - VIDC_IO_OUT(REG_777113_ADDR, c_addr); - - vidc_720p_submit_command(ch_id, VIDC_720P_CMD_FRAMERUN); -} - -void vidc_720p_encode_get_header(u32 *pi_enc_header_size) -{ - VIDC_IO_IN(REG_114286, pi_enc_header_size); -} - -void vidc_720p_enc_frame_info(struct vidc_720p_enc_frame_info - *enc_frame_info) -{ - VIDC_IO_IN(REG_782249, &enc_frame_info->enc_size); - - VIDC_IO_IN(REG_441270, &enc_frame_info->frame); - - enc_frame_info->frame &= 0x03; - - VIDC_IO_IN(REG_613254, - &enc_frame_info->metadata_exists); -} - -void vidc_720p_decode_bitstream_header(u32 ch_id, - u32 dec_unit_size, - u32 start_byte_num, - u32 ext_buffer_start, - u32 ext_buffer_end, - enum - vidc_720p_memory_access_method - memory_access_model, - u32 decode_order) -{ - VIDC_IO_OUT(REG_965480, decode_order); - - VIDC_IO_OUT(REG_639999, 0x8080); - - VIDC_IO_OUT(REG_275113_ADDR, ext_buffer_start); - - VIDC_IO_OUT(REG_988007_ADDR, ext_buffer_end); - - VIDC_IO_OUT(REG_87912, ext_buffer_end); - - VIDC_IO_OUT(REG_761892, dec_unit_size); - - VIDC_IO_OUT(REG_66693, start_byte_num); - - VIDC_IO_OUT(REG_841539, memory_access_model); - - vidc_720p_submit_command(ch_id, VIDC_720P_CMD_INITCODEC); -} - -void vidc_720p_decode_get_seq_hdr_info(struct vidc_720p_seq_hdr_info - *seq_hdr_info) -{ - u32 display_status; - VIDC_IO_IN(REG_999267, &seq_hdr_info->img_size_x); - - VIDC_IO_IN(REG_345712, &seq_hdr_info->img_size_y); - - VIDC_IO_IN(REG_257463, &seq_hdr_info->min_num_dpb); - - VIDC_IO_IN(REG_854281, &seq_hdr_info->min_dpb_size); - - VIDC_IO_IN(REG_580603, &seq_hdr_info->dec_frm_size); - - VIDC_IO_INF(REG_606447, DISP_PIC_PROFILE, - &seq_hdr_info->profile); - - VIDC_IO_INF(REG_606447, DIS_PIC_LEVEL, - &seq_hdr_info->level); - - VIDC_IO_INF(REG_612715, DISPLAY_STATUS, - &display_status); - seq_hdr_info->progressive = - ((display_status & 0x4) >> 2); - /* bit 3 is for crop existence */ - seq_hdr_info->crop_exists = ((display_status & 0x8) >> 3); - - if (seq_hdr_info->crop_exists) { - /* read the cropping information */ - VIDC_IO_INF(REG_881638, CROP_RIGHT_OFFSET, \ - &seq_hdr_info->crop_right_offset); - VIDC_IO_INF(REG_881638, CROP_LEFT_OFFSET, \ - &seq_hdr_info->crop_left_offset); - VIDC_IO_INF(REG_161486, CROP_BOTTOM_OFFSET, \ - &seq_hdr_info->crop_bottom_offset); - VIDC_IO_INF(REG_161486, CROP_TOP_OFFSET, \ - &seq_hdr_info->crop_top_offset); - } - /* Read the MPEG4 data partitioning indication */ - VIDC_IO_INF(REG_441270, DATA_PARTITIONED, \ - &seq_hdr_info->data_partitioned); - -} - -void vidc_720p_decode_set_dpb_release_buffer_mask(u32 - i_dpb_release_buffer_mask) -{ - VIDC_IO_OUT(REG_603032, i_dpb_release_buffer_mask); -} - -void vidc_720p_decode_set_dpb_buffers(u32 i_buf_index, u32 *pi_dpb_buffer) -{ - VIDC_IO_OUTI(REG_615716, i_buf_index, pi_dpb_buffer); -} - -void vidc_720p_decode_set_comv_buffer(u32 *pi_dpb_comv_buffer, - u32 alloc_len) -{ - VIDC_IO_OUT(REG_456376_ADDR, pi_dpb_comv_buffer); - - VIDC_IO_OUT(REG_490443, alloc_len); -} - -void vidc_720p_decode_set_dpb_details(u32 num_dpb, u32 alloc_len, - u32 *ref_buffer) -{ - VIDC_IO_OUT(REG_518133, ref_buffer); - - VIDC_IO_OUT(REG_267567, 0); - - VIDC_IO_OUT(REG_883500, num_dpb); - - VIDC_IO_OUT(REG_319934, alloc_len); -} - -void vidc_720p_decode_set_mpeg4Post_filter(u32 enable_post_filter) -{ - if (enable_post_filter) - VIDC_IO_OUT(REG_443811, 0x1); - else - VIDC_IO_OUT(REG_443811, 0x0); -} - -void vidc_720p_decode_set_error_control(u32 enable_error_control) -{ - if (enable_error_control) - VIDC_IO_OUT(REG_846346, 0); - else - VIDC_IO_OUT(REG_846346, 1); -} - -void vidc_720p_set_deblock_line_buffer(u32 *pi_deblock_line_buffer_start, - u32 alloc_len) -{ - VIDC_IO_OUT(REG_979942, pi_deblock_line_buffer_start); - - VIDC_IO_OUT(REG_101184, alloc_len); -} - -void vidc_720p_decode_set_mpeg4_data_partitionbuffer(u32 *vsp_buf_start) -{ - VIDC_IO_OUT(REG_958768, vsp_buf_start); -} - -void vidc_720p_decode_setH264VSPBuffer(u32 *pi_vsp_temp_buffer_start) -{ - VIDC_IO_OUT(REG_958768, pi_vsp_temp_buffer_start); -} - -void vidc_720p_decode_frame(u32 ch_id, u32 ext_buffer_start, - u32 ext_buffer_end, u32 dec_unit_size, - u32 start_byte_num, u32 input_frame_tag) -{ - VIDC_IO_OUT(REG_275113_ADDR, ext_buffer_start); - - VIDC_IO_OUT(REG_988007_ADDR, ext_buffer_end); - - VIDC_IO_OUT(REG_87912, ext_buffer_end); - - VIDC_IO_OUT(REG_66693, start_byte_num); - - VIDC_IO_OUT(REG_94750, input_frame_tag); - - VIDC_IO_OUT(REG_761892, dec_unit_size); - - vidc_720p_submit_command(ch_id, VIDC_720P_CMD_FRAMERUN); -} - -void vidc_720p_issue_eos(u32 i_ch_id) -{ - VIDC_IO_OUT(REG_896825, 0x1); - - VIDC_IO_OUT(REG_761892, 0); - - vidc_720p_submit_command(i_ch_id, VIDC_720P_CMD_FRAMERUN); -} - -void vidc_720p_eos_info(u32 *disp_status, u32 *resl_change) -{ - VIDC_IO_INF(REG_612715, DISPLAY_STATUS, disp_status); - (*disp_status) = (*disp_status) & 0x3; - VIDC_IO_INF(REG_724381, RESOLUTION_CHANGE, resl_change); -} - -void vidc_720p_decode_display_info(struct vidc_720p_dec_disp_info - *disp_info) -{ - u32 display_status = 0; - VIDC_IO_INF(REG_612715, DISPLAY_STATUS, &display_status); - - disp_info->disp_status = - (enum vidc_720p_display_status)((display_status & 0x3)); - - disp_info->disp_is_interlace = ((display_status & 0x4) >> 2); - disp_info->crop_exists = ((display_status & 0x8) >> 3); - - disp_info->resl_change = ((display_status & 0x30) >> 4); - - VIDC_IO_INF(REG_724381, RESOLUTION_CHANGE, - &disp_info->reconfig_flush_done); - - VIDC_IO_IN(REG_999267, &disp_info->img_size_x); - - VIDC_IO_IN(REG_345712, &disp_info->img_size_y); - VIDC_IO_IN(REG_151345, &disp_info->y_addr); - VIDC_IO_IN(REG_293983, &disp_info->c_addr); - VIDC_IO_IN(REG_370409, &disp_info->tag_top); - VIDC_IO_IN(REG_438677, &disp_info->tag_bottom); - VIDC_IO_IN(REG_679165, &disp_info->pic_time_top); - VIDC_IO_IN(REG_374150, &disp_info->pic_time_bottom); - - if (disp_info->crop_exists) { - VIDC_IO_INF(REG_881638, CROP_RIGHT_OFFSET, - &disp_info->crop_right_offset); - VIDC_IO_INF(REG_881638, CROP_LEFT_OFFSET, - &disp_info->crop_left_offset); - VIDC_IO_INF(REG_161486, CROP_BOTTOM_OFFSET, - &disp_info->crop_bottom_offset); - VIDC_IO_INF(REG_161486, CROP_TOP_OFFSET, - &disp_info->crop_top_offset); - } - VIDC_IO_IN(REG_613254, &disp_info->metadata_exists); - - VIDC_IO_IN(REG_580603, - &disp_info->input_bytes_consumed); - - VIDC_IO_IN(REG_757835, &disp_info->input_frame_num); - - VIDC_IO_INF(REG_441270, FRAME_TYPE, - &disp_info->input_frame); - - disp_info->input_is_interlace = - ((disp_info->input_frame & 0x4) >> 2); - - if (disp_info->input_frame & 0x10) - disp_info->input_frame = VIDC_720P_IDRFRAME; - else - disp_info->input_frame &= 0x3; -} - -void vidc_720p_decode_skip_frm_details(u32 *free_luma_dpb) -{ - u32 disp_frm; - VIDC_IO_IN(REG_697961, &disp_frm); - - if (disp_frm == VIDC_720P_NOTCODED) - VIDC_IO_IN(REG_347105, free_luma_dpb); -} - -void vidc_720p_metadata_enable(u32 flag, u32 *input_buffer) -{ - VIDC_IO_OUT(REG_854681, flag); - VIDC_IO_OUT(REG_988552, input_buffer); -} - -void vidc_720p_decode_dynamic_req_reset(void) -{ - VIDC_IO_OUT(REG_76706, 0x0); - VIDC_IO_OUT(REG_147682, 0x0); - VIDC_IO_OUT(REG_896825, 0x0); -} - -void vidc_720p_decode_dynamic_req_set(u32 property) -{ - if (property == VIDC_720P_FLUSH_REQ) - VIDC_IO_OUT(REG_76706, 0x1); - else if (property == VIDC_720P_EXTRADATA) - VIDC_IO_OUT(REG_147682, 0x1); -} - -void vidc_720p_decode_setpassthrough_start(u32 pass_startaddr) -{ - VIDC_IO_OUT(REG_486169, pass_startaddr); -} diff --git a/drivers/video/msm/vidc/720p/ddl/vidc.h b/drivers/video/msm/vidc/720p/ddl/vidc.h deleted file mode 100644 index 0c33394ffe4dd0c9b6767dc22a2eb0036e0d3465..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/ddl/vidc.h +++ /dev/null @@ -1,2704 +0,0 @@ -/* Copyright (c) 2010-2011, 2013, 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 VIDC_H -#define VIDC_H -#include -#include - -#define VIDC_720P_IN(reg) VIDC_##reg##_IN -#define VIDC_720P_INM(reg, mask) VIDC_##reg##_INM(mask) -#define VIDC_720P_OUT(reg, val) VIDC_##reg##_OUT(val) -#define VIDC_720P_OUTI(reg, index, val) VIDC_##reg##_OUTI(index, val) -#define VIDC_720P_OUTM(reg, mask, val) VIDC_##reg##_OUTM(mask, val) -#define VIDC_720P_SHFT(reg, field) VIDC_##reg##_##field##_SHFT -#define VIDC_720P_FMSK(reg, field) VIDC_##reg##_##field##_BMSK - -#define VIDC_720P_INF(io, field) (VIDC_720P_INM(io, VIDC_720P_FMSK(io, field)) \ - >> VIDC_720P_SHFT(io, field)) -#define VIDC_720P_OUTF(io, field, val) \ - VIDC_720P_OUTM(io, VIDC_720P_FMSK(io, field), \ - val << VIDC_720P_SHFT(io, field)) - -#define __inpdw(port) ioread32(port) -#define __outpdw(port, val) iowrite32(val, port) - -#define in_dword_masked(addr, mask) (__inpdw(addr) & (mask)) - -#define out_dword(addr, val) __outpdw(addr, val) - -#define out_dword_masked(io, mask, val, shadow) \ -do { \ - shadow = (shadow & (u32)(~(mask))) | ((u32)((val) & (mask))); \ - (void) out_dword(io, shadow); \ -} while (0) - -#define out_dword_masked_ns(io, mask, val, current_reg_content) \ - (void) out_dword(io, ((current_reg_content & (u32)(~(mask))) | \ - ((u32)((val) & (mask))))) - -extern u8 *vidc_base_addr; - -#define VIDC720P_BASE vidc_base_addr -#define VIDC_720P_WRAPPER_REG_BASE (VIDC720P_BASE + \ - 0x00000000) -#define VIDC_720P_WRAPPER_REG_BASE_PHYS VIDC_720P_BASE_PHYS - -#define VIDC_REG_614413_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 00000000) -#define VIDC_REG_614413_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 00000000) -#define VIDC_REG_614413_RMSK 0x1 -#define VIDC_REG_614413_SHFT 0 -#define VIDC_REG_614413_IN \ - in_dword_masked(VIDC_REG_614413_ADDR, \ - VIDC_REG_614413_RMSK) -#define VIDC_REG_614413_INM(m) \ - in_dword_masked(VIDC_REG_614413_ADDR, m) -#define VIDC_REG_614413_OUT(v) \ - out_dword(VIDC_REG_614413_ADDR, v) -#define VIDC_REG_614413_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_614413_ADDR, m, v, \ - VIDC_REG_614413_IN); \ -} while (0) -#define VIDC_REG_614413_DMA_START_BMSK 0x1 -#define VIDC_REG_614413_DMA_START_SHFT 0 - -#define VIDC_REG_591577_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000000c) -#define VIDC_REG_591577_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000000c) -#define VIDC_REG_591577_RMSK 0xffffffff -#define VIDC_REG_591577_SHFT 0 -#define VIDC_REG_591577_IN \ - in_dword_masked(VIDC_REG_591577_ADDR, \ - VIDC_REG_591577_RMSK) -#define VIDC_REG_591577_INM(m) \ - in_dword_masked(VIDC_REG_591577_ADDR, m) -#define VIDC_REG_591577_OUT(v) \ - out_dword(VIDC_REG_591577_ADDR, v) -#define VIDC_REG_591577_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_591577_ADDR, m, v, \ - VIDC_REG_591577_IN); \ -} while (0) -#define VIDC_REG_591577_BOOTCODE_SIZE_BMSK 0xffffffff -#define VIDC_REG_591577_BOOTCODE_SIZE_SHFT 0 - -#define VIDC_REG_203921_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000014) -#define VIDC_REG_203921_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000014) -#define VIDC_REG_203921_RMSK 0xffffffff -#define VIDC_REG_203921_SHFT 0 -#define VIDC_REG_203921_IN \ - in_dword_masked(VIDC_REG_203921_ADDR, \ - VIDC_REG_203921_RMSK) -#define VIDC_REG_203921_INM(m) \ - in_dword_masked(VIDC_REG_203921_ADDR, m) -#define VIDC_REG_203921_OUT(v) \ - out_dword(VIDC_REG_203921_ADDR, v) -#define VIDC_REG_203921_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_203921_ADDR, m, v, \ - VIDC_REG_203921_IN); \ -} while (0) -#define VIDC_REG_203921_DMA_EXTADDR_BMSK 0xffffffff -#define VIDC_REG_203921_DMA_EXTADDR_SHFT 0 - -#define VIDC_REG_275113_ADDR_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000018) -#define VIDC_REG_275113_ADDR_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000018) -#define VIDC_REG_275113_ADDR_RMSK 0xffffffff -#define VIDC_REG_275113_ADDR_SHFT 0 -#define VIDC_REG_275113_ADDR_IN \ - in_dword_masked(VIDC_REG_275113_ADDR_ADDR, \ - VIDC_REG_275113_ADDR_RMSK) -#define VIDC_REG_275113_ADDR_INM(m) \ - in_dword_masked(VIDC_REG_275113_ADDR_ADDR, m) -#define VIDC_REG_275113_ADDR_OUT(v) \ - out_dword(VIDC_REG_275113_ADDR_ADDR, v) -#define VIDC_REG_275113_ADDR_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_275113_ADDR_ADDR, m, v, \ - VIDC_REG_275113_ADDR_IN); \ -} while (0) -#define VIDC_REG_742076_ADDR_BMSK 0xffffffff -#define VIDC_REG_742076_ADDR_SHFT 0 - -#define VIDC_REG_988007_ADDR_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000001c) -#define VIDC_REG_988007_ADDR_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000001c) -#define VIDC_REG_988007_ADDR_RMSK 0xffffffff -#define VIDC_REG_988007_ADDR_SHFT 0 -#define VIDC_REG_988007_ADDR_IN \ - in_dword_masked(VIDC_REG_988007_ADDR_ADDR, \ - VIDC_REG_988007_ADDR_RMSK) -#define VIDC_REG_988007_ADDR_INM(m) \ - in_dword_masked(VIDC_REG_988007_ADDR_ADDR, m) -#define VIDC_REG_988007_ADDR_OUT(v) \ - out_dword(VIDC_REG_988007_ADDR_ADDR, v) -#define VIDC_REG_988007_ADDR_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_988007_ADDR_ADDR, m, v, \ - VIDC_REG_988007_ADDR_IN); \ -} while (0) -#define VIDC_REG_988007_ADDR_EXT_BUF_END_ADDR_BMSK 0xffffffff -#define VIDC_REG_988007_ADDR_EXT_BUF_END_ADDR_SHFT 0 - -#define VIDC_REG_531515_ADDR_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000020) -#define VIDC_REG_531515_ADDR_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000020) -#define VIDC_REG_531515_ADDR_RMSK 0xffffffff -#define VIDC_REG_531515_ADDR_SHFT 0 -#define VIDC_REG_531515_ADDR_IN \ - in_dword_masked(VIDC_REG_531515_ADDR_ADDR, \ - VIDC_REG_531515_ADDR_RMSK) -#define VIDC_REG_531515_ADDR_INM(m) \ - in_dword_masked(VIDC_REG_531515_ADDR_ADDR, m) -#define VIDC_REG_531515_ADDR_OUT(v) \ - out_dword(VIDC_REG_531515_ADDR_ADDR, v) -#define VIDC_REG_531515_ADDR_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_531515_ADDR_ADDR, m, v, \ - VIDC_REG_531515_ADDR_IN); \ -} while (0) -#define VIDC_REG_531515_ADDR_DMA_INT_ADDR_BMSK 0xffffffff -#define VIDC_REG_531515_ADDR_DMA_INT_ADDR_SHFT 0 - -#define VIDC_REG_87912_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000024) -#define VIDC_REG_87912_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000024) -#define VIDC_REG_87912_RMSK 0xffffffff -#define VIDC_REG_87912_SHFT 0 -#define VIDC_REG_87912_IN \ - in_dword_masked(VIDC_REG_87912_ADDR, \ - VIDC_REG_87912_RMSK) -#define VIDC_REG_87912_INM(m) \ - in_dword_masked(VIDC_REG_87912_ADDR, m) -#define VIDC_REG_87912_OUT(v) \ - out_dword(VIDC_REG_87912_ADDR, v) -#define VIDC_REG_87912_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_87912_ADDR, m, v, \ - VIDC_REG_87912_IN); \ -} while (0) -#define VIDC_REG_87912_HOST_PTR_ADDR_BMSK 0xffffffff -#define VIDC_REG_87912_HOST_PTR_ADDR_SHFT 0 - -#define VIDC_REG_896825_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000028) -#define VIDC_REG_896825_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000028) -#define VIDC_REG_896825_RMSK 0x1 -#define VIDC_REG_896825_SHFT 0 -#define VIDC_REG_896825_IN \ - in_dword_masked(VIDC_REG_896825_ADDR, \ - VIDC_REG_896825_RMSK) -#define VIDC_REG_896825_INM(m) \ - in_dword_masked(VIDC_REG_896825_ADDR, m) -#define VIDC_REG_896825_OUT(v) \ - out_dword(VIDC_REG_896825_ADDR, v) -#define VIDC_REG_896825_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_896825_ADDR, m, v, \ - VIDC_REG_896825_IN); \ -} while (0) -#define VIDC_REG_896825_LAST_DEC_BMSK 0x1 -#define VIDC_REG_896825_LAST_DEC_SHFT 0 - -#define VIDC_REG_174526_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000002c) -#define VIDC_REG_174526_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000002c) -#define VIDC_REG_174526_RMSK 0x1 -#define VIDC_REG_174526_SHFT 0 -#define VIDC_REG_174526_IN \ - in_dword_masked(VIDC_REG_174526_ADDR, VIDC_REG_174526_RMSK) -#define VIDC_REG_174526_INM(m) \ - in_dword_masked(VIDC_REG_174526_ADDR, m) -#define VIDC_REG_174526_DONE_M_BMSK 0x1 -#define VIDC_REG_174526_DONE_M_SHFT 0 - -#define VIDC_REG_736316_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000044) -#define VIDC_REG_736316_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000044) -#define VIDC_REG_736316_RMSK 0x1 -#define VIDC_REG_736316_SHFT 0 -#define VIDC_REG_736316_IN \ - in_dword_masked(VIDC_REG_736316_ADDR, \ - VIDC_REG_736316_RMSK) -#define VIDC_REG_736316_INM(m) \ - in_dword_masked(VIDC_REG_736316_ADDR, m) -#define VIDC_REG_736316_OUT(v) \ - out_dword(VIDC_REG_736316_ADDR, v) -#define VIDC_REG_736316_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_736316_ADDR, m, v, \ - VIDC_REG_736316_IN); \ -} while (0) -#define VIDC_REG_736316_BITS_ENDIAN_BMSK 0x1 -#define VIDC_REG_736316_BITS_ENDIAN_SHFT 0 - -#define VIDC_REG_761892_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000054) -#define VIDC_REG_761892_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000054) -#define VIDC_REG_761892_RMSK 0xffffffff -#define VIDC_REG_761892_SHFT 0 -#define VIDC_REG_761892_IN \ - in_dword_masked(VIDC_REG_761892_ADDR, \ - VIDC_REG_761892_RMSK) -#define VIDC_REG_761892_INM(m) \ - in_dword_masked(VIDC_REG_761892_ADDR, m) -#define VIDC_REG_761892_OUT(v) \ - out_dword(VIDC_REG_761892_ADDR, v) -#define VIDC_REG_761892_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_761892_ADDR, m, v, \ - VIDC_REG_761892_IN); \ -} while (0) -#define VIDC_REG_761892_DEC_UNIT_SIZE_BMSK 0xffffffff -#define VIDC_REG_761892_DEC_UNIT_SIZE_SHFT 0 - -#define VIDC_REG_782249_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000058) -#define VIDC_REG_782249_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000058) -#define VIDC_REG_782249_RMSK 0xffffffff -#define VIDC_REG_782249_SHFT 0 -#define VIDC_REG_782249_IN \ - in_dword_masked(VIDC_REG_782249_ADDR, \ - VIDC_REG_782249_RMSK) -#define VIDC_REG_782249_INM(m) \ - in_dword_masked(VIDC_REG_782249_ADDR, m) -#define VIDC_REG_782249_ENC_UNIT_SIZE_BMSK 0xffffffff -#define VIDC_REG_782249_ENC_UNIT_SIZE_SHFT 0 - -#define VIDC_REG_66693_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000005c) -#define VIDC_REG_66693_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000005c) -#define VIDC_REG_66693_RMSK 0xf -#define VIDC_REG_66693_SHFT 0 -#define VIDC_REG_66693_IN \ - in_dword_masked(VIDC_REG_66693_ADDR, \ - VIDC_REG_66693_RMSK) -#define VIDC_REG_66693_INM(m) \ - in_dword_masked(VIDC_REG_66693_ADDR, m) -#define VIDC_REG_66693_OUT(v) \ - out_dword(VIDC_REG_66693_ADDR, v) -#define VIDC_REG_66693_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_66693_ADDR, m, v, \ - VIDC_REG_66693_IN); \ -} while (0) -#define VIDC_REG_66693_START_BYTE_NUM_BMSK 0xf -#define VIDC_REG_66693_START_BYTE_NUM_SHFT 0 - -#define VIDC_REG_114286_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000060) -#define VIDC_REG_114286_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000060) -#define VIDC_REG_114286_RMSK 0xffffffff -#define VIDC_REG_114286_SHFT 0 -#define VIDC_REG_114286_IN \ - in_dword_masked(VIDC_REG_114286_ADDR, \ - VIDC_REG_114286_RMSK) -#define VIDC_REG_114286_INM(m) \ - in_dword_masked(VIDC_REG_114286_ADDR, m) -#define VIDC_REG_114286_ENC_HEADER_SIZE_BMSK 0xffffffff -#define VIDC_REG_114286_ENC_HEADER_SIZE_SHFT 0 - -#define VIDC_REG_713080_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000100) -#define VIDC_REG_713080_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000100) -#define VIDC_REG_713080_RMSK 0x1f -#define VIDC_REG_713080_SHFT 0 -#define VIDC_REG_713080_IN \ - in_dword_masked(VIDC_REG_713080_ADDR, \ - VIDC_REG_713080_RMSK) -#define VIDC_REG_713080_INM(m) \ - in_dword_masked(VIDC_REG_713080_ADDR, m) -#define VIDC_REG_713080_OUT(v) \ - out_dword(VIDC_REG_713080_ADDR, v) -#define VIDC_REG_713080_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_713080_ADDR, m, v, \ - VIDC_REG_713080_IN); \ -} while (0) -#define VIDC_REG_713080_ENC_ON_BMSK 0x10 -#define VIDC_REG_713080_ENC_ON_SHFT 0x4 -#define VIDC_REG_713080_STANDARD_SEL_BMSK 0xf -#define VIDC_REG_713080_STANDARD_SEL_SHFT 0 - -#define VIDC_REG_97293_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000104) -#define VIDC_REG_97293_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000104) -#define VIDC_REG_97293_RMSK 0x1f -#define VIDC_REG_97293_SHFT 0 -#define VIDC_REG_97293_IN \ - in_dword_masked(VIDC_REG_97293_ADDR, VIDC_REG_97293_RMSK) -#define VIDC_REG_97293_INM(m) \ - in_dword_masked(VIDC_REG_97293_ADDR, m) -#define VIDC_REG_97293_OUT(v) \ - out_dword(VIDC_REG_97293_ADDR, v) -#define VIDC_REG_97293_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_97293_ADDR, m, v, \ - VIDC_REG_97293_IN); \ -} while (0) -#define VIDC_REG_97293_CH_ID_BMSK 0x1f -#define VIDC_REG_97293_CH_ID_SHFT 0 - -#define VIDC_REG_224135_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000108) -#define VIDC_REG_224135_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000108) -#define VIDC_REG_224135_RMSK 0x1 -#define VIDC_REG_224135_SHFT 0 -#define VIDC_REG_224135_IN \ - in_dword_masked(VIDC_REG_224135_ADDR, \ - VIDC_REG_224135_RMSK) -#define VIDC_REG_224135_INM(m) \ - in_dword_masked(VIDC_REG_224135_ADDR, m) -#define VIDC_REG_224135_OUT(v) \ - out_dword(VIDC_REG_224135_ADDR, v) -#define VIDC_REG_224135_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_224135_ADDR, m, v, \ - VIDC_REG_224135_IN); \ -} while (0) -#define VIDC_REG_224135_CPU_RESET_BMSK 0x1 -#define VIDC_REG_224135_CPU_RESET_SHFT 0 - -#define VIDC_REG_832522_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000010c) -#define VIDC_REG_832522_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000010c) -#define VIDC_REG_832522_RMSK 0x1 -#define VIDC_REG_832522_SHFT 0 -#define VIDC_REG_832522_IN \ - in_dword_masked(VIDC_REG_832522_ADDR, VIDC_REG_832522_RMSK) -#define VIDC_REG_832522_INM(m) \ - in_dword_masked(VIDC_REG_832522_ADDR, m) -#define VIDC_REG_832522_OUT(v) \ - out_dword(VIDC_REG_832522_ADDR, v) -#define VIDC_REG_832522_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_832522_ADDR, m, v, \ - VIDC_REG_832522_IN); \ -} while (0) -#define VIDC_REG_832522_FW_END_BMSK 0x1 -#define VIDC_REG_832522_FW_END_SHFT 0 - -#define VIDC_REG_361582_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000110) -#define VIDC_REG_361582_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000110) -#define VIDC_REG_361582_RMSK 0x1 -#define VIDC_REG_361582_SHFT 0 -#define VIDC_REG_361582_IN \ - in_dword_masked(VIDC_REG_361582_ADDR, \ - VIDC_REG_361582_RMSK) -#define VIDC_REG_361582_INM(m) \ - in_dword_masked(VIDC_REG_361582_ADDR, m) -#define VIDC_REG_361582_OUT(v) \ - out_dword(VIDC_REG_361582_ADDR, v) -#define VIDC_REG_361582_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_361582_ADDR, m, v, \ - VIDC_REG_361582_IN); \ -} while (0) -#define VIDC_REG_361582_BUS_MASTER_BMSK 0x1 -#define VIDC_REG_361582_BUS_MASTER_SHFT 0 - -#define VIDC_REG_314435_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000114) -#define VIDC_REG_314435_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000114) -#define VIDC_REG_314435_RMSK 0x1 -#define VIDC_REG_314435_SHFT 0 -#define VIDC_REG_314435_IN \ - in_dword_masked(VIDC_REG_314435_ADDR, \ - VIDC_REG_314435_RMSK) -#define VIDC_REG_314435_INM(m) \ - in_dword_masked(VIDC_REG_314435_ADDR, m) -#define VIDC_REG_314435_OUT(v) \ - out_dword(VIDC_REG_314435_ADDR, v) -#define VIDC_REG_314435_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_314435_ADDR, m, v, \ - VIDC_REG_314435_IN); \ -} while (0) -#define VIDC_REG_314435_FRAME_START_BMSK 0x1 -#define VIDC_REG_314435_FRAME_START_SHFT 0 - -#define VIDC_REG_999267_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000118) -#define VIDC_REG_999267_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000118) -#define VIDC_REG_999267_RMSK 0xffff -#define VIDC_REG_999267_SHFT 0 -#define VIDC_REG_999267_IN \ - in_dword_masked(VIDC_REG_999267_ADDR, \ - VIDC_REG_999267_RMSK) -#define VIDC_REG_999267_INM(m) \ - in_dword_masked(VIDC_REG_999267_ADDR, m) -#define VIDC_REG_999267_OUT(v) \ - out_dword(VIDC_REG_999267_ADDR, v) -#define VIDC_REG_999267_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_999267_ADDR, m, v, \ - VIDC_REG_999267_IN); \ -} while (0) -#define VIDC_REG_999267_IMG_SIZE_X_BMSK 0xffff -#define VIDC_REG_999267_IMG_SIZE_X_SHFT 0 - -#define VIDC_REG_345712_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000011c) -#define VIDC_REG_345712_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000011c) -#define VIDC_REG_345712_RMSK 0xffff -#define VIDC_REG_345712_SHFT 0 -#define VIDC_REG_345712_IN \ - in_dword_masked(VIDC_REG_345712_ADDR, \ - VIDC_REG_345712_RMSK) -#define VIDC_REG_345712_INM(m) \ - in_dword_masked(VIDC_REG_345712_ADDR, m) -#define VIDC_REG_345712_OUT(v) \ - out_dword(VIDC_REG_345712_ADDR, v) -#define VIDC_REG_345712_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_345712_ADDR, m, v, \ - VIDC_REG_345712_IN); \ -} while (0) -#define VIDC_REG_345712_IMG_SIZE_Y_BMSK 0xffff -#define VIDC_REG_345712_IMG_SIZE_Y_SHFT 0 - -#define VIDC_REG_443811_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000124) -#define VIDC_REG_443811_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000124) -#define VIDC_REG_443811_RMSK 0x1 -#define VIDC_REG_443811_SHFT 0 -#define VIDC_REG_443811_IN \ - in_dword_masked(VIDC_REG_443811_ADDR, VIDC_REG_443811_RMSK) -#define VIDC_REG_443811_INM(m) \ - in_dword_masked(VIDC_REG_443811_ADDR, m) -#define VIDC_REG_443811_OUT(v) \ - out_dword(VIDC_REG_443811_ADDR, v) -#define VIDC_REG_443811_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_443811_ADDR, m, v, \ - VIDC_REG_443811_IN); \ -} while (0) -#define VIDC_REG_443811_POST_ON_BMSK 0x1 -#define VIDC_REG_443811_POST_ON_SHFT 0 - -#define VIDC_REG_538267_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000128) -#define VIDC_REG_538267_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000128) -#define VIDC_REG_538267_RMSK 0xffffffff -#define VIDC_REG_538267_SHFT 0 -#define VIDC_REG_538267_IN \ - in_dword_masked(VIDC_REG_538267_ADDR, \ - VIDC_REG_538267_RMSK) -#define VIDC_REG_538267_INM(m) \ - in_dword_masked(VIDC_REG_538267_ADDR, m) -#define VIDC_REG_538267_OUT(v) \ - out_dword(VIDC_REG_538267_ADDR, v) -#define VIDC_REG_538267_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_538267_ADDR, m, v, \ - VIDC_REG_538267_IN); \ -} while (0) -#define VIDC_REG_538267_QUOTIENT_VAL_BMSK 0xffff0000 -#define VIDC_REG_538267_QUOTIENT_VAL_SHFT 0x10 -#define VIDC_REG_538267_REMAINDER_VAL_BMSK 0xffff -#define VIDC_REG_538267_REMAINDER_VAL_SHFT 0 - -#define VIDC_REG_661565_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000012c) -#define VIDC_REG_661565_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000012c) -#define VIDC_REG_661565_RMSK 0x1 -#define VIDC_REG_661565_SHFT 0 -#define VIDC_REG_661565_IN \ - in_dword_masked(VIDC_REG_661565_ADDR, \ - VIDC_REG_661565_RMSK) -#define VIDC_REG_661565_INM(m) \ - in_dword_masked(VIDC_REG_661565_ADDR, m) -#define VIDC_REG_661565_OUT(v) \ - out_dword(VIDC_REG_661565_ADDR, v) -#define VIDC_REG_661565_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_661565_ADDR, m, v, \ - VIDC_REG_661565_IN); \ -} while (0) -#define VIDC_REG_661565_SEQUENCE_START_BMSK 0x1 -#define VIDC_REG_661565_SEQUENCE_START_SHFT 0 - -#define VIDC_REG_141269_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000130) -#define VIDC_REG_141269_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000130) -#define VIDC_REG_141269_RMSK 0x1 -#define VIDC_REG_141269_SHFT 0 -#define VIDC_REG_141269_IN \ - in_dword_masked(VIDC_REG_141269_ADDR, \ - VIDC_REG_141269_RMSK) -#define VIDC_REG_141269_INM(m) \ - in_dword_masked(VIDC_REG_141269_ADDR, m) -#define VIDC_REG_141269_OUT(v) \ - out_dword(VIDC_REG_141269_ADDR, v) -#define VIDC_REG_141269_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_141269_ADDR, m, v, \ - VIDC_REG_141269_IN); \ -} while (0) -#define VIDC_REG_141269_SW_RESET_BMSK 0x1 -#define VIDC_REG_141269_SW_RESET_SHFT 0 - -#define VIDC_REG_193553_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000134) -#define VIDC_REG_193553_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000134) -#define VIDC_REG_193553_RMSK 0x1 -#define VIDC_REG_193553_SHFT 0 -#define VIDC_REG_193553_IN \ - in_dword_masked(VIDC_REG_193553_ADDR, \ - VIDC_REG_193553_RMSK) -#define VIDC_REG_193553_INM(m) \ - in_dword_masked(VIDC_REG_193553_ADDR, m) -#define VIDC_REG_193553_OUT(v) \ - out_dword(VIDC_REG_193553_ADDR, v) -#define VIDC_REG_193553_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_193553_ADDR, m, v, \ - VIDC_REG_193553_IN); \ -} while (0) -#define VIDC_REG_193553_FW_START_BMSK 0x1 -#define VIDC_REG_193553_FW_START_SHFT 0 - -#define VIDC_REG_215724_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000138) -#define VIDC_REG_215724_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000138) -#define VIDC_REG_215724_RMSK 0x1 -#define VIDC_REG_215724_SHFT 0 -#define VIDC_REG_215724_IN \ - in_dword_masked(VIDC_REG_215724_ADDR, \ - VIDC_REG_215724_RMSK) -#define VIDC_REG_215724_INM(m) \ - in_dword_masked(VIDC_REG_215724_ADDR, m) -#define VIDC_REG_215724_OUT(v) \ - out_dword(VIDC_REG_215724_ADDR, v) -#define VIDC_REG_215724_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_215724_ADDR, m, v, \ - VIDC_REG_215724_IN); \ -} while (0) -#define VIDC_REG_215724_ARM_ENDIAN_BMSK 0x1 -#define VIDC_REG_215724_ARM_ENDIAN_SHFT 0 - -#define VIDC_REG_846346_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000013c) -#define VIDC_REG_846346_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000013c) -#define VIDC_REG_846346_RMSK 0x1 -#define VIDC_REG_846346_SHFT 0 -#define VIDC_REG_846346_IN \ - in_dword_masked(VIDC_REG_846346_ADDR, \ - VIDC_REG_846346_RMSK) -#define VIDC_REG_846346_INM(m) \ - in_dword_masked(VIDC_REG_846346_ADDR, m) -#define VIDC_REG_846346_OUT(v) \ - out_dword(VIDC_REG_846346_ADDR, v) -#define VIDC_REG_846346_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_846346_ADDR, m, v, \ - VIDC_REG_846346_IN); \ -} while (0) -#define VIDC_REG_846346_ERR_CTRL_BMSK 0x1 -#define VIDC_REG_846346_ERR_CTRL_SHFT 0 - -#define VIDC_REG_765787_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000200) -#define VIDC_REG_765787_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000200) -#define VIDC_REG_765787_RMSK 0xffffffff -#define VIDC_REG_765787_SHFT 0 -#define VIDC_REG_765787_IN \ - in_dword_masked(VIDC_REG_765787_ADDR, \ - VIDC_REG_765787_RMSK) -#define VIDC_REG_765787_INM(m) \ - in_dword_masked(VIDC_REG_765787_ADDR, m) -#define VIDC_REG_765787_OUT(v) \ - out_dword(VIDC_REG_765787_ADDR, v) -#define VIDC_REG_765787_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_765787_ADDR, m, v, \ - VIDC_REG_765787_IN); \ -} while (0) -#define VIDC_REG_765787_FW_STT_ADDR_0_BMSK 0xffffffff -#define VIDC_REG_765787_FW_STT_ADDR_0_SHFT 0 - -#define VIDC_REG_225040_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000204) -#define VIDC_REG_225040_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000204) -#define VIDC_REG_225040_RMSK 0xffffffff -#define VIDC_REG_225040_SHFT 0 -#define VIDC_REG_225040_IN \ - in_dword_masked(VIDC_REG_225040_ADDR, \ - VIDC_REG_225040_RMSK) -#define VIDC_REG_225040_INM(m) \ - in_dword_masked(VIDC_REG_225040_ADDR, m) -#define VIDC_REG_225040_OUT(v) \ - out_dword(VIDC_REG_225040_ADDR, v) -#define VIDC_REG_225040_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_225040_ADDR, m, v, \ - VIDC_REG_225040_IN); \ -} while (0) -#define VIDC_REG_225040_FW_STT_ADDR_1_BMSK 0xffffffff -#define VIDC_REG_225040_FW_STT_ADDR_1_SHFT 0 - -#define VIDC_REG_942456_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000208) -#define VIDC_REG_942456_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000208) -#define VIDC_REG_942456_RMSK 0xffffffff -#define VIDC_REG_942456_SHFT 0 -#define VIDC_REG_942456_IN \ - in_dword_masked(VIDC_REG_942456_ADDR, \ - VIDC_REG_942456_RMSK) -#define VIDC_REG_942456_INM(m) \ - in_dword_masked(VIDC_REG_942456_ADDR, m) -#define VIDC_REG_942456_OUT(v) \ - out_dword(VIDC_REG_942456_ADDR, v) -#define VIDC_REG_942456_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_942456_ADDR, m, v, \ - VIDC_REG_942456_IN); \ -} while (0) -#define VIDC_REG_942456_FW_STT_ADDR_2_BMSK 0xffffffff -#define VIDC_REG_942456_FW_STT_ADDR_2_SHFT 0 - -#define VIDC_REG_942170_ADDR_3_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000020c) -#define VIDC_REG_942170_ADDR_3_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000020c) -#define VIDC_REG_942170_ADDR_3_RMSK 0xffffffff -#define VIDC_REG_942170_ADDR_3_SHFT 0 -#define VIDC_REG_942170_ADDR_3_IN \ - in_dword_masked(VIDC_REG_942170_ADDR_3_ADDR, \ - VIDC_REG_942170_ADDR_3_RMSK) -#define VIDC_REG_942170_ADDR_3_INM(m) \ - in_dword_masked(VIDC_REG_942170_ADDR_3_ADDR, m) -#define VIDC_REG_942170_ADDR_3_OUT(v) \ - out_dword(VIDC_REG_942170_ADDR_3_ADDR, v) -#define VIDC_REG_942170_ADDR_3_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_942170_ADDR_3_ADDR, m, v, \ - VIDC_REG_942170_ADDR_3_IN); \ -} while (0) -#define VIDC_REG_942170_ADDR_3_FW_STT_ADDR_3_BMSK 0xffffffff -#define VIDC_REG_942170_ADDR_3_FW_STT_ADDR_3_SHFT 0 - -#define VIDC_REG_880188_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000210) -#define VIDC_REG_880188_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000210) -#define VIDC_REG_880188_RMSK 0xffffffff -#define VIDC_REG_880188_SHFT 0 -#define VIDC_REG_880188_IN \ - in_dword_masked(VIDC_REG_880188_ADDR, \ - VIDC_REG_880188_RMSK) -#define VIDC_REG_880188_INM(m) \ - in_dword_masked(VIDC_REG_880188_ADDR, m) -#define VIDC_REG_880188_OUT(v) \ - out_dword(VIDC_REG_880188_ADDR, v) -#define VIDC_REG_880188_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_880188_ADDR, m, v, \ - VIDC_REG_880188_IN); \ -} while (0) -#define VIDC_REG_880188_FW_STT_ADDR_4_BMSK 0xffffffff -#define VIDC_REG_880188_FW_STT_ADDR_4_SHFT 0 - -#define VIDC_REG_40293_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000214) -#define VIDC_REG_40293_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000214) -#define VIDC_REG_40293_RMSK 0xffffffff -#define VIDC_REG_40293_SHFT 0 -#define VIDC_REG_40293_IN \ - in_dword_masked(VIDC_REG_40293_ADDR, \ - VIDC_REG_40293_RMSK) -#define VIDC_REG_40293_INM(m) \ - in_dword_masked(VIDC_REG_40293_ADDR, m) -#define VIDC_REG_40293_OUT(v) \ - out_dword(VIDC_REG_40293_ADDR, v) -#define VIDC_REG_40293_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_40293_ADDR, m, v, \ - VIDC_REG_40293_IN); \ -} while (0) -#define VIDC_REG_40293_FW_STT_ADDR_5_BMSK 0xffffffff -#define VIDC_REG_40293_FW_STT_ADDR_5_SHFT 0 - -#define VIDC_REG_942170_ADDR_6_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000218) -#define VIDC_REG_942170_ADDR_6_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000218) -#define VIDC_REG_942170_ADDR_6_RMSK 0xffffffff -#define VIDC_REG_942170_ADDR_6_SHFT 0 -#define VIDC_REG_942170_ADDR_6_IN \ - in_dword_masked(VIDC_REG_942170_ADDR_6_ADDR, \ - VIDC_REG_942170_ADDR_6_RMSK) -#define VIDC_REG_942170_ADDR_6_INM(m) \ - in_dword_masked(VIDC_REG_942170_ADDR_6_ADDR, m) -#define VIDC_REG_942170_ADDR_6_OUT(v) \ - out_dword(VIDC_REG_942170_ADDR_6_ADDR, v) -#define VIDC_REG_942170_ADDR_6_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_942170_ADDR_6_ADDR, m, v, \ - VIDC_REG_942170_ADDR_6_IN); \ -} while (0) -#define VIDC_REG_942170_ADDR_6_FW_STT_ADDR_6_BMSK 0xffffffff -#define VIDC_REG_942170_ADDR_6_FW_STT_ADDR_6_SHFT 0 - -#define VIDC_REG_958768_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000230) -#define VIDC_REG_958768_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000230) -#define VIDC_REG_958768_RMSK 0xffffffff -#define VIDC_REG_958768_SHFT 0 -#define VIDC_REG_958768_IN \ - in_dword_masked(VIDC_REG_958768_ADDR, \ - VIDC_REG_958768_RMSK) -#define VIDC_REG_958768_INM(m) \ - in_dword_masked(VIDC_REG_958768_ADDR, m) -#define VIDC_REG_958768_OUT(v) \ - out_dword(VIDC_REG_958768_ADDR, v) -#define VIDC_REG_958768_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_958768_ADDR, m, v, \ - VIDC_REG_958768_IN); \ -} while (0) -#define VIDC_REG_699384_ADDR_BMSK 0xffffffff -#define VIDC_REG_699384_ADDR_SHFT 0 - -#define VIDC_REG_979942_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000234) -#define VIDC_REG_979942_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000234) -#define VIDC_REG_979942_RMSK 0xffffffff -#define VIDC_REG_979942_SHFT 0 -#define VIDC_REG_979942_IN \ - in_dword_masked(VIDC_REG_979942_ADDR, \ - VIDC_REG_979942_RMSK) -#define VIDC_REG_979942_INM(m) \ - in_dword_masked(VIDC_REG_979942_ADDR, m) -#define VIDC_REG_979942_OUT(v) \ - out_dword(VIDC_REG_979942_ADDR, v) -#define VIDC_REG_979942_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_979942_ADDR, m, v, \ - VIDC_REG_979942_IN); \ -} while (0) -#define VIDC_REG_979942_DB_STT_ADDR_BMSK 0xffffffff -#define VIDC_REG_979942_DB_STT_ADDR_SHFT 0 - -#define VIDC_REG_839021_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000300) -#define VIDC_REG_839021_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000300) -#define VIDC_REG_839021_RMSK 0xff1f -#define VIDC_REG_839021_SHFT 0 -#define VIDC_REG_839021_IN \ - in_dword_masked(VIDC_REG_839021_ADDR, VIDC_REG_839021_RMSK) -#define VIDC_REG_839021_INM(m) \ - in_dword_masked(VIDC_REG_839021_ADDR, m) -#define VIDC_REG_839021_OUT(v) \ - out_dword(VIDC_REG_839021_ADDR, v) -#define VIDC_REG_839021_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_839021_ADDR, m, v, \ - VIDC_REG_839021_IN); \ -} while (0) -#define VIDC_REG_839021_LEVEL_BMSK 0xff00 -#define VIDC_REG_839021_LEVEL_SHFT 0x8 -#define VIDC_REG_839021_PROFILE_BMSK 0x1f -#define VIDC_REG_839021_PROFILE_SHFT 0 - -#define VIDC_REG_950374_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000308) -#define VIDC_REG_950374_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000308) -#define VIDC_REG_950374_RMSK 0xffff -#define VIDC_REG_950374_SHFT 0 -#define VIDC_REG_950374_IN \ - in_dword_masked(VIDC_REG_950374_ADDR, \ - VIDC_REG_950374_RMSK) -#define VIDC_REG_950374_INM(m) \ - in_dword_masked(VIDC_REG_950374_ADDR, m) -#define VIDC_REG_950374_OUT(v) \ - out_dword(VIDC_REG_950374_ADDR, v) -#define VIDC_REG_950374_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_950374_ADDR, m, v, \ - VIDC_REG_950374_IN); \ -} while (0) -#define VIDC_REG_950374_I_PERIOD_BMSK 0xffff -#define VIDC_REG_950374_I_PERIOD_SHFT 0 - -#define VIDC_REG_504878_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000310) -#define VIDC_REG_504878_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000310) -#define VIDC_REG_504878_RMSK 0xd -#define VIDC_REG_504878_SHFT 0 -#define VIDC_REG_504878_IN \ - in_dword_masked(VIDC_REG_504878_ADDR, \ - VIDC_REG_504878_RMSK) -#define VIDC_REG_504878_INM(m) \ - in_dword_masked(VIDC_REG_504878_ADDR, m) -#define VIDC_REG_504878_OUT(v) \ - out_dword(VIDC_REG_504878_ADDR, v) -#define VIDC_REG_504878_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_504878_ADDR, m, v, \ - VIDC_REG_504878_IN); \ -} while (0) -#define VIDC_REG_504878_FIXED_NUMBER_BMSK 0xc -#define VIDC_REG_504878_FIXED_NUMBER_SHFT 0x2 -#define VIDC_REG_504878_ENTROPY_SEL_BMSK 0x1 -#define VIDC_REG_504878_ENTROPY_SEL_SHFT 0 - -#define VIDC_REG_458130_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000314) -#define VIDC_REG_458130_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000314) -#define VIDC_REG_458130_RMSK 0xfff -#define VIDC_REG_458130_SHFT 0 -#define VIDC_REG_458130_IN \ - in_dword_masked(VIDC_REG_458130_ADDR, \ - VIDC_REG_458130_RMSK) -#define VIDC_REG_458130_INM(m) \ - in_dword_masked(VIDC_REG_458130_ADDR, m) -#define VIDC_REG_458130_OUT(v) \ - out_dword(VIDC_REG_458130_ADDR, v) -#define VIDC_REG_458130_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_458130_ADDR, m, v, \ - VIDC_REG_458130_IN); \ -} while (0) -#define VIDC_REG_458130_SLICE_ALPHA_C0_OFFSET_DIV2_BMSK \ - 0xf80 -#define VIDC_REG_458130_SLICE_ALPHA_C0_OFFSET_DIV2_SHFT \ - 0x7 -#define VIDC_REG_458130_SLICE_BETA_OFFSET_DIV2_BMSK 0x7c -#define VIDC_REG_458130_SLICE_BETA_OFFSET_DIV2_SHFT 0x2 -#define \ - \ -VIDC_REG_458130_DISABLE_DEBLOCKING_FILTER_IDC_BMSK 0x3 -#define \ - \ -VIDC_REG_458130_DISABLE_DEBLOCKING_FILTER_IDC_SHFT 0 - -#define VIDC_REG_314290_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000318) -#define VIDC_REG_314290_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000318) -#define VIDC_REG_314290_RMSK 0x1 -#define VIDC_REG_314290_SHFT 0 -#define VIDC_REG_314290_IN \ - in_dword_masked(VIDC_REG_314290_ADDR, \ - VIDC_REG_314290_RMSK) -#define VIDC_REG_314290_INM(m) \ - in_dword_masked(VIDC_REG_314290_ADDR, m) -#define VIDC_REG_314290_OUT(v) \ - out_dword(VIDC_REG_314290_ADDR, v) -#define VIDC_REG_314290_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_314290_ADDR, m, v, \ - VIDC_REG_314290_IN); \ -} while (0) -#define VIDC_REG_314290_SHORT_HD_ON_BMSK 0x1 -#define VIDC_REG_314290_SHORT_HD_ON_SHFT 0 - -#define VIDC_REG_588301_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000031c) -#define VIDC_REG_588301_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000031c) -#define VIDC_REG_588301_RMSK 0x1 -#define VIDC_REG_588301_SHFT 0 -#define VIDC_REG_588301_IN \ - in_dword_masked(VIDC_REG_588301_ADDR, \ - VIDC_REG_588301_RMSK) -#define VIDC_REG_588301_INM(m) \ - in_dword_masked(VIDC_REG_588301_ADDR, m) -#define VIDC_REG_588301_OUT(v) \ - out_dword(VIDC_REG_588301_ADDR, v) -#define VIDC_REG_588301_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_588301_ADDR, m, v, \ - VIDC_REG_588301_IN); \ -} while (0) -#define VIDC_REG_588301_MSLICE_ENA_BMSK 0x1 -#define VIDC_REG_588301_MSLICE_ENA_SHFT 0 - -#define VIDC_REG_1517_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000320) -#define VIDC_REG_1517_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000320) -#define VIDC_REG_1517_RMSK 0x3 -#define VIDC_REG_1517_SHFT 0 -#define VIDC_REG_1517_IN \ - in_dword_masked(VIDC_REG_1517_ADDR, \ - VIDC_REG_1517_RMSK) -#define VIDC_REG_1517_INM(m) \ - in_dword_masked(VIDC_REG_1517_ADDR, m) -#define VIDC_REG_1517_OUT(v) \ - out_dword(VIDC_REG_1517_ADDR, v) -#define VIDC_REG_1517_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_1517_ADDR, m, v, \ - VIDC_REG_1517_IN); \ -} while (0) -#define VIDC_REG_1517_MSLICE_SEL_BMSK 0x3 -#define VIDC_REG_1517_MSLICE_SEL_SHFT 0 - -#define VIDC_REG_105335_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000324) -#define VIDC_REG_105335_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000324) -#define VIDC_REG_105335_RMSK 0xffffffff -#define VIDC_REG_105335_SHFT 0 -#define VIDC_REG_105335_IN \ - in_dword_masked(VIDC_REG_105335_ADDR, \ - VIDC_REG_105335_RMSK) -#define VIDC_REG_105335_INM(m) \ - in_dword_masked(VIDC_REG_105335_ADDR, m) -#define VIDC_REG_105335_OUT(v) \ - out_dword(VIDC_REG_105335_ADDR, v) -#define VIDC_REG_105335_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_105335_ADDR, m, v, \ - VIDC_REG_105335_IN); \ -} while (0) -#define VIDC_REG_105335_MSLICE_MB_BMSK 0xffffffff -#define VIDC_REG_105335_MSLICE_MB_SHFT 0 - -#define VIDC_REG_561679_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000328) -#define VIDC_REG_561679_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000328) -#define VIDC_REG_561679_RMSK 0xffffffff -#define VIDC_REG_561679_SHFT 0 -#define VIDC_REG_561679_IN \ - in_dword_masked(VIDC_REG_561679_ADDR, \ - VIDC_REG_561679_RMSK) -#define VIDC_REG_561679_INM(m) \ - in_dword_masked(VIDC_REG_561679_ADDR, m) -#define VIDC_REG_561679_OUT(v) \ - out_dword(VIDC_REG_561679_ADDR, v) -#define VIDC_REG_561679_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_561679_ADDR, m, v, \ - VIDC_REG_561679_IN); \ -} while (0) -#define VIDC_REG_561679_MSLICE_BYTE_BMSK 0xffffffff -#define VIDC_REG_561679_MSLICE_BYTE_SHFT 0 - -#define VIDC_REG_151345_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000400) -#define VIDC_REG_151345_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000400) -#define VIDC_REG_151345_RMSK 0xffffffff -#define VIDC_REG_151345_SHFT 0 -#define VIDC_REG_151345_IN \ - in_dword_masked(VIDC_REG_151345_ADDR, \ - VIDC_REG_151345_RMSK) -#define VIDC_REG_151345_INM(m) \ - in_dword_masked(VIDC_REG_151345_ADDR, m) -#define VIDC_REG_151345_DISPLAY_Y_ADR_BMSK 0xffffffff -#define VIDC_REG_151345_DISPLAY_Y_ADR_SHFT 0 - -#define VIDC_REG_293983_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000404) -#define VIDC_REG_293983_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000404) -#define VIDC_REG_293983_RMSK 0xffffffff -#define VIDC_REG_293983_SHFT 0 -#define VIDC_REG_293983_IN \ - in_dword_masked(VIDC_REG_293983_ADDR, \ - VIDC_REG_293983_RMSK) -#define VIDC_REG_293983_INM(m) \ - in_dword_masked(VIDC_REG_293983_ADDR, m) -#define VIDC_REG_293983_DISPLAY_C_ADR_BMSK 0xffffffff -#define VIDC_REG_293983_DISPLAY_C_ADR_SHFT 0 - -#define VIDC_REG_612715_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000408) -#define VIDC_REG_612715_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000408) -#define VIDC_REG_612715_RMSK 0x3f -#define VIDC_REG_612715_SHFT 0 -#define VIDC_REG_612715_IN \ - in_dword_masked(VIDC_REG_612715_ADDR, \ - VIDC_REG_612715_RMSK) -#define VIDC_REG_612715_INM(m) \ - in_dword_masked(VIDC_REG_612715_ADDR, m) -#define VIDC_REG_612715_DISPLAY_STATUS_BMSK 0x3f -#define VIDC_REG_612715_DISPLAY_STATUS_SHFT 0 - -#define VIDC_REG_209364_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000040c) -#define VIDC_REG_209364_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000040c) -#define VIDC_REG_209364_RMSK 0x1 -#define VIDC_REG_209364_SHFT 0 -#define VIDC_REG_209364_IN \ - in_dword_masked(VIDC_REG_209364_ADDR, \ - VIDC_REG_209364_RMSK) -#define VIDC_REG_209364_INM(m) \ - in_dword_masked(VIDC_REG_209364_ADDR, m) -#define VIDC_REG_209364_HEADER_DONE_BMSK 0x1 -#define VIDC_REG_209364_HEADER_DONE_SHFT 0 - -#define VIDC_REG_757835_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000410) -#define VIDC_REG_757835_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000410) -#define VIDC_REG_757835_RMSK 0xffffffff -#define VIDC_REG_757835_SHFT 0 -#define VIDC_REG_757835_IN \ - in_dword_masked(VIDC_REG_757835_ADDR, \ - VIDC_REG_757835_RMSK) -#define VIDC_REG_757835_INM(m) \ - in_dword_masked(VIDC_REG_757835_ADDR, m) -#define VIDC_REG_757835_FRAME_NUM_BMSK 0xffffffff -#define VIDC_REG_757835_FRAME_NUM_SHFT 0 - -#define VIDC_REG_352831_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000414) -#define VIDC_REG_352831_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000414) -#define VIDC_REG_352831_RMSK 0xffffffff -#define VIDC_REG_352831_SHFT 0 -#define VIDC_REG_352831_IN \ - in_dword_masked(VIDC_REG_352831_ADDR, \ - VIDC_REG_352831_RMSK) -#define VIDC_REG_352831_INM(m) \ - in_dword_masked(VIDC_REG_352831_ADDR, m) -#define VIDC_REG_352831_DBG_INFO_OUTPUT0_BMSK 0xffffffff -#define VIDC_REG_352831_DBG_INFO_OUTPUT0_SHFT 0 - -#define VIDC_REG_668634_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000418) -#define VIDC_REG_668634_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000418) -#define VIDC_REG_668634_RMSK 0xffffffff -#define VIDC_REG_668634_SHFT 0 -#define VIDC_REG_668634_IN \ - in_dword_masked(VIDC_REG_668634_ADDR, \ - VIDC_REG_668634_RMSK) -#define VIDC_REG_668634_INM(m) \ - in_dword_masked(VIDC_REG_668634_ADDR, m) -#define VIDC_REG_668634_DBG_INFO_OUTPUT1_BMSK 0xffffffff -#define VIDC_REG_668634_DBG_INFO_OUTPUT1_SHFT 0 - -#define VIDC_REG_609676_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000500) -#define VIDC_REG_609676_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000500) -#define VIDC_REG_609676_RMSK 0x1 -#define VIDC_REG_609676_SHFT 0 -#define VIDC_REG_609676_IN \ - in_dword_masked(VIDC_REG_609676_ADDR, VIDC_REG_609676_RMSK) -#define VIDC_REG_609676_INM(m) \ - in_dword_masked(VIDC_REG_609676_ADDR, m) -#define VIDC_REG_609676_OUT(v) \ - out_dword(VIDC_REG_609676_ADDR, v) -#define VIDC_REG_609676_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_609676_ADDR, m, v, \ - VIDC_REG_609676_IN); \ -} while (0) -#define VIDC_REG_609676_INT_OFF_BMSK 0x1 -#define VIDC_REG_609676_INT_OFF_SHFT 0 - -#define VIDC_REG_491082_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000504) -#define VIDC_REG_491082_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000504) -#define VIDC_REG_491082_RMSK 0x1 -#define VIDC_REG_491082_SHFT 0 -#define VIDC_REG_491082_IN \ - in_dword_masked(VIDC_REG_491082_ADDR, \ - VIDC_REG_491082_RMSK) -#define VIDC_REG_491082_INM(m) \ - in_dword_masked(VIDC_REG_491082_ADDR, m) -#define VIDC_REG_491082_OUT(v) \ - out_dword(VIDC_REG_491082_ADDR, v) -#define VIDC_REG_491082_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_491082_ADDR, m, v, \ - VIDC_REG_491082_IN); \ -} while (0) -#define VIDC_REG_491082_INT_PULSE_SEL_BMSK 0x1 -#define VIDC_REG_491082_INT_PULSE_SEL_SHFT 0 - -#define VIDC_REG_614776_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000508) -#define VIDC_REG_614776_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000508) -#define VIDC_REG_614776_RMSK 0x1 -#define VIDC_REG_614776_SHFT 0 -#define VIDC_REG_614776_IN \ - in_dword_masked(VIDC_REG_614776_ADDR, \ - VIDC_REG_614776_RMSK) -#define VIDC_REG_614776_INM(m) \ - in_dword_masked(VIDC_REG_614776_ADDR, m) -#define VIDC_REG_614776_OUT(v) \ - out_dword(VIDC_REG_614776_ADDR, v) -#define VIDC_REG_614776_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_614776_ADDR, m, v, \ - VIDC_REG_614776_IN); \ -} while (0) -#define VIDC_REG_614776_INT_DONE_CLEAR_BMSK 0x1 -#define VIDC_REG_614776_INT_DONE_CLEAR_SHFT 0 - -#define VIDC_REG_982553_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000050c) -#define VIDC_REG_982553_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000050c) -#define VIDC_REG_982553_RMSK 0x1 -#define VIDC_REG_982553_SHFT 0 -#define VIDC_REG_982553_IN \ - in_dword_masked(VIDC_REG_982553_ADDR, \ - VIDC_REG_982553_RMSK) -#define VIDC_REG_982553_INM(m) \ - in_dword_masked(VIDC_REG_982553_ADDR, m) -#define VIDC_REG_982553_OPERATION_DONE_BMSK 0x1 -#define VIDC_REG_982553_OPERATION_DONE_SHFT 0 - -#define VIDC_REG_259967_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000510) -#define VIDC_REG_259967_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000510) -#define VIDC_REG_259967_RMSK 0x1 -#define VIDC_REG_259967_SHFT 0 -#define VIDC_REG_259967_IN \ - in_dword_masked(VIDC_REG_259967_ADDR, VIDC_REG_259967_RMSK) -#define VIDC_REG_259967_INM(m) \ - in_dword_masked(VIDC_REG_259967_ADDR, m) -#define VIDC_REG_259967_FW_DONE_BMSK 0x1 -#define VIDC_REG_259967_FW_DONE_SHFT 0 - -#define VIDC_REG_512143_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000514) -#define VIDC_REG_512143_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000514) -#define VIDC_REG_512143_RMSK 0x1f8 -#define VIDC_REG_512143_SHFT 0 -#define VIDC_REG_512143_IN \ - in_dword_masked(VIDC_REG_512143_ADDR, \ - VIDC_REG_512143_RMSK) -#define VIDC_REG_512143_INM(m) \ - in_dword_masked(VIDC_REG_512143_ADDR, m) -#define VIDC_REG_512143_FRAME_DONE_STAT_BMSK 0x100 -#define VIDC_REG_512143_FRAME_DONE_STAT_SHFT 0x8 -#define VIDC_REG_512143_DMA_DONE_STAT_BMSK 0x80 -#define VIDC_REG_512143_DMA_DONE_STAT_SHFT 0x7 -#define VIDC_REG_512143_HEADER_DONE_STAT_BMSK 0x40 -#define VIDC_REG_512143_HEADER_DONE_STAT_SHFT 0x6 -#define VIDC_REG_512143_FW_DONE_STAT_BMSK 0x20 -#define VIDC_REG_512143_FW_DONE_STAT_SHFT 0x5 -#define VIDC_REG_512143_OPERATION_FAILED_BMSK 0x10 -#define VIDC_REG_512143_OPERATION_FAILED_SHFT 0x4 -#define VIDC_REG_512143_STREAM_HDR_CHANGED_BMSK 0x8 -#define VIDC_REG_512143_STREAM_HDR_CHANGED_SHFT 0x3 - -#define VIDC_REG_418173_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000518) -#define VIDC_REG_418173_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000518) -#define VIDC_REG_418173_RMSK 0x1fa -#define VIDC_REG_418173_SHFT 0 -#define VIDC_REG_418173_IN \ - in_dword_masked(VIDC_REG_418173_ADDR, \ - VIDC_REG_418173_RMSK) -#define VIDC_REG_418173_INM(m) \ - in_dword_masked(VIDC_REG_418173_ADDR, m) -#define VIDC_REG_418173_OUT(v) \ - out_dword(VIDC_REG_418173_ADDR, v) -#define VIDC_REG_418173_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_418173_ADDR, m, v, \ - VIDC_REG_418173_IN); \ -} while (0) -#define VIDC_REG_418173_FRAME_DONE_ENABLE_BMSK 0x100 -#define VIDC_REG_418173_FRAME_DONE_ENABLE_SHFT 0x8 -#define VIDC_REG_418173_DMA_DONE_ENABLE_BMSK 0x80 -#define VIDC_REG_418173_DMA_DONE_ENABLE_SHFT 0x7 -#define VIDC_REG_418173_HEADER_DONE_ENABLE_BMSK 0x40 -#define VIDC_REG_418173_HEADER_DONE_ENABLE_SHFT 0x6 -#define VIDC_REG_418173_FW_DONE_ENABLE_BMSK 0x20 -#define VIDC_REG_418173_FW_DONE_ENABLE_SHFT 0x5 -#define VIDC_REG_418173_OPERATION_FAILED_ENABLE_BMSK 0x10 -#define VIDC_REG_418173_OPERATION_FAILED_ENABLE_SHFT 0x4 -#define VIDC_REG_418173_STREAM_HDR_CHANGED_ENABLE_BMSK 0x8 -#define VIDC_REG_418173_STREAM_HDR_CHANGED_ENABLE_SHFT 0x3 -#define VIDC_REG_418173_BUFFER_FULL_ENABLE_BMSK 0x2 -#define VIDC_REG_418173_BUFFER_FULL_ENABLE_SHFT 0x1 - -#define VIDC_REG_841539_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000600) -#define VIDC_REG_841539_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000600) -#define VIDC_REG_841539_RMSK 0x3 -#define VIDC_REG_841539_SHFT 0 -#define VIDC_REG_841539_IN \ - in_dword_masked(VIDC_REG_841539_ADDR, \ - VIDC_REG_841539_RMSK) -#define VIDC_REG_841539_INM(m) \ - in_dword_masked(VIDC_REG_841539_ADDR, m) -#define VIDC_REG_841539_OUT(v) \ - out_dword(VIDC_REG_841539_ADDR, v) -#define VIDC_REG_841539_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_841539_ADDR, m, v, \ - VIDC_REG_841539_IN); \ -} while (0) -#define VIDC_REG_841539_TILE_MODE_BMSK 0x3 -#define VIDC_REG_841539_TILE_MODE_SHFT 0 - -#define VIDC_REG_99105_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000800) -#define VIDC_REG_99105_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000800) -#define VIDC_REG_99105_RMSK 0xffffffff -#define VIDC_REG_99105_SHFT 0 -#define VIDC_REG_99105_IN \ - in_dword_masked(VIDC_REG_99105_ADDR, \ - VIDC_REG_99105_RMSK) -#define VIDC_REG_99105_INM(m) \ - in_dword_masked(VIDC_REG_99105_ADDR, m) -#define VIDC_REG_99105_OUT(v) \ - out_dword(VIDC_REG_99105_ADDR, v) -#define VIDC_REG_99105_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_99105_ADDR, m, v, \ - VIDC_REG_99105_IN); \ -} while (0) -#define VIDC_REG_99105_ENC_CUR_Y_ADDR_BMSK 0xffffffff -#define VIDC_REG_99105_ENC_CUR_Y_ADDR_SHFT 0 - -#define VIDC_REG_777113_ADDR_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000804) -#define VIDC_REG_777113_ADDR_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000804) -#define VIDC_REG_777113_ADDR_RMSK 0xffffffff -#define VIDC_REG_777113_ADDR_SHFT 0 -#define VIDC_REG_777113_ADDR_IN \ - in_dword_masked(VIDC_REG_777113_ADDR_ADDR, \ - VIDC_REG_777113_ADDR_RMSK) -#define VIDC_REG_777113_ADDR_INM(m) \ - in_dword_masked(VIDC_REG_777113_ADDR_ADDR, m) -#define VIDC_REG_777113_ADDR_OUT(v) \ - out_dword(VIDC_REG_777113_ADDR_ADDR, v) -#define VIDC_REG_777113_ADDR_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_777113_ADDR_ADDR, m, v, \ - VIDC_REG_777113_ADDR_IN); \ -} while (0) -#define VIDC_REG_777113_ADDR_ENC_CUR_C_ADDR_BMSK 0xffffffff -#define VIDC_REG_777113_ADDR_ENC_CUR_C_ADDR_SHFT 0 - -#define VIDC_REG_341928_ADDR_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000080c) -#define VIDC_REG_341928_ADDR_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000080c) -#define VIDC_REG_341928_ADDR_RMSK 0xffffffff -#define VIDC_REG_341928_ADDR_SHFT 0 -#define VIDC_REG_341928_ADDR_IN \ - in_dword_masked(VIDC_REG_341928_ADDR_ADDR, \ - VIDC_REG_341928_ADDR_RMSK) -#define VIDC_REG_341928_ADDR_INM(m) \ - in_dword_masked(VIDC_REG_341928_ADDR_ADDR, m) -#define VIDC_REG_341928_ADDR_OUT(v) \ - out_dword(VIDC_REG_341928_ADDR_ADDR, v) -#define VIDC_REG_341928_ADDR_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_341928_ADDR_ADDR, m, v, \ - VIDC_REG_341928_ADDR_IN); \ -} while (0) -#define VIDC_REG_341928_ADDR_ENC_DPB_ADR_BMSK 0xffffffff -#define VIDC_REG_341928_ADDR_ENC_DPB_ADR_SHFT 0 - -#define VIDC_REG_857491_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000810) -#define VIDC_REG_857491_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000810) -#define VIDC_REG_857491_RMSK 0xfff -#define VIDC_REG_857491_SHFT 0 -#define VIDC_REG_857491_IN \ - in_dword_masked(VIDC_REG_857491_ADDR, \ - VIDC_REG_857491_RMSK) -#define VIDC_REG_857491_INM(m) \ - in_dword_masked(VIDC_REG_857491_ADDR, m) -#define VIDC_REG_857491_OUT(v) \ - out_dword(VIDC_REG_857491_ADDR, v) -#define VIDC_REG_857491_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_857491_ADDR, m, v, \ - VIDC_REG_857491_IN); \ -} while (0) -#define VIDC_REG_857491_CIR_MB_NUM_BMSK 0xfff -#define VIDC_REG_857491_CIR_MB_NUM_SHFT 0 - -#define VIDC_REG_518133_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000900) -#define VIDC_REG_518133_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000900) -#define VIDC_REG_518133_RMSK 0xffffffff -#define VIDC_REG_518133_SHFT 0 -#define VIDC_REG_518133_IN \ - in_dword_masked(VIDC_REG_518133_ADDR, \ - VIDC_REG_518133_RMSK) -#define VIDC_REG_518133_INM(m) \ - in_dword_masked(VIDC_REG_518133_ADDR, m) -#define VIDC_REG_518133_OUT(v) \ - out_dword(VIDC_REG_518133_ADDR, v) -#define VIDC_REG_518133_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_518133_ADDR, m, v, \ - VIDC_REG_518133_IN); \ -} while (0) -#define VIDC_REG_518133_DEC_DPB_ADDR_BMSK 0xffffffff -#define VIDC_REG_518133_DEC_DPB_ADDR_SHFT 0 - -#define VIDC_REG_456376_ADDR_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000904) -#define VIDC_REG_456376_ADDR_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000904) -#define VIDC_REG_456376_ADDR_RMSK 0xffffffff -#define VIDC_REG_456376_ADDR_SHFT 0 -#define VIDC_REG_456376_ADDR_IN \ - in_dword_masked(VIDC_REG_456376_ADDR_ADDR, \ - VIDC_REG_456376_ADDR_RMSK) -#define VIDC_REG_456376_ADDR_INM(m) \ - in_dword_masked(VIDC_REG_456376_ADDR_ADDR, m) -#define VIDC_REG_456376_ADDR_OUT(v) \ - out_dword(VIDC_REG_456376_ADDR_ADDR, v) -#define VIDC_REG_456376_ADDR_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_456376_ADDR_ADDR, m, v, \ - VIDC_REG_456376_ADDR_IN); \ -} while (0) -#define VIDC_REG_456376_ADDR_DPB_COMV_ADDR_BMSK 0xffffffff -#define VIDC_REG_456376_ADDR_DPB_COMV_ADDR_SHFT 0 - -#define VIDC_REG_267567_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000908) -#define VIDC_REG_267567_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000908) -#define VIDC_REG_267567_RMSK 0xffffffff -#define VIDC_REG_267567_SHFT 0 -#define VIDC_REG_267567_IN \ - in_dword_masked(VIDC_REG_267567_ADDR, \ - VIDC_REG_267567_RMSK) -#define VIDC_REG_267567_INM(m) \ - in_dword_masked(VIDC_REG_267567_ADDR, m) -#define VIDC_REG_267567_OUT(v) \ - out_dword(VIDC_REG_267567_ADDR, v) -#define VIDC_REG_267567_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_267567_ADDR, m, v, \ - VIDC_REG_267567_IN); \ -} while (0) -#define VIDC_REG_798486_ADDR_BMSK 0xffffffff -#define VIDC_REG_798486_ADDR_SHFT 0 - -#define VIDC_REG_105770_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x0000090c) -#define VIDC_REG_105770_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x0000090c) -#define VIDC_REG_105770_RMSK 0xff -#define VIDC_REG_105770_SHFT 0 -#define VIDC_REG_105770_IN \ - in_dword_masked(VIDC_REG_105770_ADDR, \ - VIDC_REG_105770_RMSK) -#define VIDC_REG_105770_INM(m) \ - in_dword_masked(VIDC_REG_105770_ADDR, m) -#define VIDC_REG_105770_DPB_SIZE_BMSK 0xff -#define VIDC_REG_105770_DPB_SIZE_SHFT 0 - -#define VIDC_REG_58211_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000a00) -#define VIDC_REG_58211_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000a00) -#define VIDC_REG_58211_RMSK 0x33f -#define VIDC_REG_58211_SHFT 0 -#define VIDC_REG_58211_IN \ - in_dword_masked(VIDC_REG_58211_ADDR, \ - VIDC_REG_58211_RMSK) -#define VIDC_REG_58211_INM(m) \ - in_dword_masked(VIDC_REG_58211_ADDR, m) -#define VIDC_REG_58211_OUT(v) \ - out_dword(VIDC_REG_58211_ADDR, v) -#define VIDC_REG_58211_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_58211_ADDR, m, v, \ - VIDC_REG_58211_IN); \ -} while (0) -#define VIDC_REG_58211_FR_RC_EN_BMSK 0x200 -#define VIDC_REG_58211_FR_RC_EN_SHFT 0x9 -#define VIDC_REG_58211_MB_RC_EN_BMSK 0x100 -#define VIDC_REG_58211_MB_RC_EN_SHFT 0x8 -#define VIDC_REG_58211_FRAME_QP_BMSK 0x3f -#define VIDC_REG_58211_FRAME_QP_SHFT 0 - -#define VIDC_REG_548359_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000a04) -#define VIDC_REG_548359_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000a04) -#define VIDC_REG_548359_RMSK 0x3f -#define VIDC_REG_548359_SHFT 0 -#define VIDC_REG_548359_IN \ - in_dword_masked(VIDC_REG_548359_ADDR, \ - VIDC_REG_548359_RMSK) -#define VIDC_REG_548359_INM(m) \ - in_dword_masked(VIDC_REG_548359_ADDR, m) -#define VIDC_REG_548359_OUT(v) \ - out_dword(VIDC_REG_548359_ADDR, v) -#define VIDC_REG_548359_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_548359_ADDR, m, v, \ - VIDC_REG_548359_IN); \ -} while (0) -#define VIDC_REG_548359_P_FRAME_QP_BMSK 0x3f -#define VIDC_REG_548359_P_FRAME_QP_SHFT 0 - -#define VIDC_REG_174150_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000a08) -#define VIDC_REG_174150_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000a08) -#define VIDC_REG_174150_RMSK 0xffffffff -#define VIDC_REG_174150_SHFT 0 -#define VIDC_REG_174150_IN \ - in_dword_masked(VIDC_REG_174150_ADDR, \ - VIDC_REG_174150_RMSK) -#define VIDC_REG_174150_INM(m) \ - in_dword_masked(VIDC_REG_174150_ADDR, m) -#define VIDC_REG_174150_OUT(v) \ - out_dword(VIDC_REG_174150_ADDR, v) -#define VIDC_REG_174150_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_174150_ADDR, m, v, \ - VIDC_REG_174150_IN); \ -} while (0) -#define VIDC_REG_174150_BIT_RATE_BMSK 0xffffffff -#define VIDC_REG_174150_BIT_RATE_SHFT 0 - -#define VIDC_REG_734318_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000a0c) -#define VIDC_REG_734318_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000a0c) -#define VIDC_REG_734318_RMSK 0x3f3f -#define VIDC_REG_734318_SHFT 0 -#define VIDC_REG_734318_IN \ - in_dword_masked(VIDC_REG_734318_ADDR, \ - VIDC_REG_734318_RMSK) -#define VIDC_REG_734318_INM(m) \ - in_dword_masked(VIDC_REG_734318_ADDR, m) -#define VIDC_REG_734318_OUT(v) \ - out_dword(VIDC_REG_734318_ADDR, v) -#define VIDC_REG_734318_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_734318_ADDR, m, v, \ - VIDC_REG_734318_IN); \ -} while (0) -#define VIDC_REG_734318_MAX_QP_BMSK 0x3f00 -#define VIDC_REG_734318_MAX_QP_SHFT 0x8 -#define VIDC_REG_734318_MIN_QP_BMSK 0x3f -#define VIDC_REG_734318_MIN_QP_SHFT 0 - -#define VIDC_REG_677784_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000a10) -#define VIDC_REG_677784_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000a10) -#define VIDC_REG_677784_RMSK 0xffff -#define VIDC_REG_677784_SHFT 0 -#define VIDC_REG_677784_IN \ - in_dword_masked(VIDC_REG_677784_ADDR, \ - VIDC_REG_677784_RMSK) -#define VIDC_REG_677784_INM(m) \ - in_dword_masked(VIDC_REG_677784_ADDR, m) -#define VIDC_REG_677784_OUT(v) \ - out_dword(VIDC_REG_677784_ADDR, v) -#define VIDC_REG_677784_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_677784_ADDR, m, v, \ - VIDC_REG_677784_IN); \ -} while (0) -#define VIDC_REG_677784_REACT_PARA_BMSK 0xffff -#define VIDC_REG_677784_REACT_PARA_SHFT 0 - -#define VIDC_REG_995041_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000a14) -#define VIDC_REG_995041_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000a14) -#define VIDC_REG_995041_RMSK 0xf -#define VIDC_REG_995041_SHFT 0 -#define VIDC_REG_995041_IN \ - in_dword_masked(VIDC_REG_995041_ADDR, \ - VIDC_REG_995041_RMSK) -#define VIDC_REG_995041_INM(m) \ - in_dword_masked(VIDC_REG_995041_ADDR, m) -#define VIDC_REG_995041_OUT(v) \ - out_dword(VIDC_REG_995041_ADDR, v) -#define VIDC_REG_995041_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_995041_ADDR, m, v, \ - VIDC_REG_995041_IN); \ -} while (0) -#define VIDC_REG_995041_DARK_DISABLE_BMSK 0x8 -#define VIDC_REG_995041_DARK_DISABLE_SHFT 0x3 -#define VIDC_REG_995041_SMOOTH_DISABLE_BMSK 0x4 -#define VIDC_REG_995041_SMOOTH_DISABLE_SHFT 0x2 -#define VIDC_REG_995041_STATIC_DISABLE_BMSK 0x2 -#define VIDC_REG_995041_STATIC_DISABLE_SHFT 0x1 -#define VIDC_REG_995041_ACT_DISABLE_BMSK 0x1 -#define VIDC_REG_995041_ACT_DISABLE_SHFT 0 - -#define VIDC_REG_273649_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000a18) -#define VIDC_REG_273649_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000a18) -#define VIDC_REG_273649_RMSK 0x3f -#define VIDC_REG_273649_SHFT 0 -#define VIDC_REG_273649_IN \ - in_dword_masked(VIDC_REG_273649_ADDR, VIDC_REG_273649_RMSK) -#define VIDC_REG_273649_INM(m) \ - in_dword_masked(VIDC_REG_273649_ADDR, m) -#define VIDC_REG_273649_QP_OUT_BMSK 0x3f -#define VIDC_REG_273649_QP_OUT_SHFT 0 - -#define VIDC_REG_548823_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000b00) -#define VIDC_REG_548823_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000b00) -#define VIDC_REG_548823_RMSK 0xffffffff -#define VIDC_REG_548823_SHFT 0 -#define VIDC_REG_548823_IN \ - in_dword_masked(VIDC_REG_548823_ADDR, \ - VIDC_REG_548823_RMSK) -#define VIDC_REG_548823_INM(m) \ - in_dword_masked(VIDC_REG_548823_ADDR, m) -#define VIDC_REG_548823_720P_VERSION_BMSK 0xffffffff -#define VIDC_REG_548823_720P_VERSION_SHFT 0 - -#define VIDC_REG_881638_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000c00) -#define VIDC_REG_881638_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000c00) -#define VIDC_REG_881638_RMSK 0xffffffff -#define VIDC_REG_881638_SHFT 0 -#define VIDC_REG_881638_IN \ - in_dword_masked(VIDC_REG_881638_ADDR, \ - VIDC_REG_881638_RMSK) -#define VIDC_REG_881638_INM(m) \ - in_dword_masked(VIDC_REG_881638_ADDR, m) -#define VIDC_REG_881638_CROP_RIGHT_OFFSET_BMSK 0xffff0000 -#define VIDC_REG_881638_CROP_RIGHT_OFFSET_SHFT 0x10 -#define VIDC_REG_881638_CROP_LEFT_OFFSET_BMSK 0xffff -#define VIDC_REG_881638_CROP_LEFT_OFFSET_SHFT 0 - -#define VIDC_REG_161486_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000c04) -#define VIDC_REG_161486_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000c04) -#define VIDC_REG_161486_RMSK 0xffffffff -#define VIDC_REG_161486_SHFT 0 -#define VIDC_REG_161486_IN \ - in_dword_masked(VIDC_REG_161486_ADDR, \ - VIDC_REG_161486_RMSK) -#define VIDC_REG_161486_INM(m) \ - in_dword_masked(VIDC_REG_161486_ADDR, m) -#define VIDC_REG_161486_CROP_BOTTOM_OFFSET_BMSK 0xffff0000 -#define VIDC_REG_161486_CROP_BOTTOM_OFFSET_SHFT 0x10 -#define VIDC_REG_161486_CROP_TOP_OFFSET_BMSK 0xffff -#define VIDC_REG_161486_CROP_TOP_OFFSET_SHFT 0 - -#define VIDC_REG_580603_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000c08) -#define VIDC_REG_580603_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000c08) -#define VIDC_REG_580603_RMSK 0xffffffff -#define VIDC_REG_580603_SHFT 0 -#define VIDC_REG_580603_IN \ - in_dword_masked(VIDC_REG_580603_ADDR, \ - VIDC_REG_580603_RMSK) -#define VIDC_REG_580603_INM(m) \ - in_dword_masked(VIDC_REG_580603_ADDR, m) -#define VIDC_REG_580603_720P_DEC_FRM_SIZE_BMSK 0xffffffff -#define VIDC_REG_580603_720P_DEC_FRM_SIZE_SHFT 0 - - -#define VIDC_REG_606447_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000c0c) -#define VIDC_REG_606447_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000c0c) -#define VIDC_REG_606447_RMSK 0xff1f -#define VIDC_REG_606447_SHFT 0 -#define VIDC_REG_606447_IN \ - in_dword_masked(VIDC_REG_606447_ADDR, \ - VIDC_REG_606447_RMSK) -#define VIDC_REG_606447_INM(m) \ - in_dword_masked(VIDC_REG_606447_ADDR, m) -#define VIDC_REG_606447_OUT(v) \ - out_dword(VIDC_REG_606447_ADDR, v) -#define VIDC_REG_606447_OUTM(m, v) \ - out_dword_masked_ns(VIDC_REG_606447_ADDR, \ - m, v, VIDC_REG_606447_IN); \ - -#define VIDC_REG_606447_DIS_PIC_LEVEL_BMSK 0xff00 -#define VIDC_REG_606447_DIS_PIC_LEVEL_SHFT 0x8 -#define VIDC_REG_606447_DISP_PIC_PROFILE_BMSK 0x1f -#define VIDC_REG_606447_DISP_PIC_PROFILE_SHFT 0 - -#define VIDC_REG_854281_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000c10) -#define VIDC_REG_854281_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000c10) -#define VIDC_REG_854281_RMSK 0xffffffff -#define VIDC_REG_854281_SHFT 0 -#define VIDC_REG_854281_IN \ - in_dword_masked(VIDC_REG_854281_ADDR, \ - VIDC_REG_854281_RMSK) -#define VIDC_REG_854281_INM(m) \ - in_dword_masked(VIDC_REG_854281_ADDR, m) -#define VIDC_REG_854281_MIN_DPB_SIZE_BMSK 0xffffffff -#define VIDC_REG_854281_MIN_DPB_SIZE_SHFT 0 - - -#define VIDC_REG_381535_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000c14) -#define VIDC_REG_381535_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000c14) -#define VIDC_REG_381535_RMSK 0xffffffff -#define VIDC_REG_381535_SHFT 0 -#define VIDC_REG_381535_IN \ - in_dword_masked(VIDC_REG_381535_ADDR, \ - VIDC_REG_381535_RMSK) -#define VIDC_REG_381535_INM(m) \ - in_dword_masked(VIDC_REG_381535_ADDR, m) -#define VIDC_REG_381535_720P_FW_STATUS_BMSK 0xffffffff -#define VIDC_REG_381535_720P_FW_STATUS_SHFT 0 - - -#define VIDC_REG_347105_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000c18) -#define VIDC_REG_347105_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000c18) -#define VIDC_REG_347105_RMSK 0xffffffff -#define VIDC_REG_347105_SHFT 0 -#define VIDC_REG_347105_IN \ - in_dword_masked(VIDC_REG_347105_ADDR, \ - VIDC_REG_347105_RMSK) -#define VIDC_REG_347105_INM(m) \ - in_dword_masked(VIDC_REG_347105_ADDR, m) -#define VIDC_REG_347105_FREE_LUMA_DPB_BMSK 0xffffffff -#define VIDC_REG_347105_FREE_LUMA_DPB_SHFT 0 - - -#define VIDC_REG_62325_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d00) -#define VIDC_REG_62325_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d00) -#define VIDC_REG_62325_RMSK 0xf -#define VIDC_REG_62325_SHFT 0 -#define VIDC_REG_62325_IN \ - in_dword_masked(VIDC_REG_62325_ADDR, \ - VIDC_REG_62325_RMSK) -#define VIDC_REG_62325_INM(m) \ - in_dword_masked(VIDC_REG_62325_ADDR, m) -#define VIDC_REG_62325_OUT(v) \ - out_dword(VIDC_REG_62325_ADDR, v) -#define VIDC_REG_62325_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_62325_ADDR, m, v, \ - VIDC_REG_62325_IN); \ -} while (0) -#define VIDC_REG_62325_COMMAND_TYPE_BMSK 0xf -#define VIDC_REG_62325_COMMAND_TYPE_SHFT 0 - -#define VIDC_REG_101184_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d04) -#define VIDC_REG_101184_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d04) -#define VIDC_REG_101184_RMSK 0xffffffff -#define VIDC_REG_101184_SHFT 0 -#define VIDC_REG_101184_OUT(v) \ - out_dword(VIDC_REG_101184_ADDR, v) - -#define VIDC_REG_490443_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d08) -#define VIDC_REG_490443_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d08) -#define VIDC_REG_490443_RMSK \ - 0xffffffff -#define \ - \ -VIDC_REG_490443_SHFT 0 -#define VIDC_REG_490443_OUT(v) \ - out_dword(VIDC_REG_490443_ADDR, v) - -#define VIDC_REG_625444_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d14) -#define VIDC_REG_625444_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d14) -#define VIDC_REG_625444_RMSK 0xffffffff -#define VIDC_REG_625444_SHFT 0 -#define VIDC_REG_625444_IN \ - in_dword_masked(VIDC_REG_625444_ADDR, \ - VIDC_REG_625444_RMSK) -#define VIDC_REG_625444_INM(m) \ - in_dword_masked(VIDC_REG_625444_ADDR, m) -#define VIDC_REG_625444_OUT(v) \ - out_dword(VIDC_REG_625444_ADDR, v) -#define VIDC_REG_625444_OUTM(m, v) \ -do { \ - out_dword_masked_ns(VIDC_REG_625444_ADDR, m, v, \ - VIDC_REG_625444_IN); \ -} while (0) -#define VIDC_REG_625444_FRAME_RATE_BMSK 0xffffffff -#define VIDC_REG_625444_FRAME_RATE_SHFT 0 - -#define VIDC_REG_639999_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d20) -#define VIDC_REG_639999_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d20) -#define VIDC_REG_639999_RMSK 0xffff -#define VIDC_REG_639999_SHFT 0 -#define VIDC_REG_639999_OUT(v) \ - out_dword(VIDC_REG_639999_ADDR, v) - -#define VIDC_REG_64895_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e00) -#define VIDC_REG_64895_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e00) -#define VIDC_REG_64895_RMSK 0xffffffff -#define VIDC_REG_64895_SHFT 0 -#define VIDC_REG_64895_OUT(v) \ - out_dword(VIDC_REG_64895_ADDR, v) - -#define VIDC_REG_965480_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e04) -#define VIDC_REG_965480_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e04) -#define VIDC_REG_965480_RMSK 0x1 -#define VIDC_REG_965480_SHFT 0 -#define VIDC_REG_965480_OUT(v) \ - out_dword(VIDC_REG_965480_ADDR, v) - -#define VIDC_REG_804959_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e08) -#define VIDC_REG_804959_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e08) -#define VIDC_REG_804959_RMSK 0x7 -#define VIDC_REG_804959_SHFT 0 -#define VIDC_REG_804959_OUT(v) \ - out_dword(VIDC_REG_804959_ADDR, v) - -#define VIDC_REG_257463_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e10) -#define VIDC_REG_257463_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e10) -#define VIDC_REG_257463_RMSK 0xffffffff -#define VIDC_REG_257463_SHFT 0 -#define VIDC_REG_257463_IN \ - in_dword_masked(VIDC_REG_257463_ADDR, \ - VIDC_REG_257463_RMSK) -#define VIDC_REG_257463_INM(m) \ - in_dword_masked(VIDC_REG_257463_ADDR, m) -#define VIDC_REG_257463_MIN_NUM_DPB_BMSK 0xffffffff -#define VIDC_REG_257463_MIN_NUM_DPB_SHFT 0 - -#define VIDC_REG_883500_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e14) -#define VIDC_REG_883500_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e14) -#define VIDC_REG_883500_RMSK 0xffffffff -#define VIDC_REG_883500_SHFT 0 -#define VIDC_REG_883500_OUT(v) \ - out_dword(VIDC_REG_883500_ADDR, v) - -#define VIDC_REG_615716_ADDR(n) \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e18 + 4 * (n)) -#define VIDC_REG_615716_PHYS(n) \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e18 + 4 * (n)) -#define VIDC_REG_615716_RMSK 0xffffffff -#define VIDC_REG_615716_SHFT 0 -#define VIDC_REG_615716_OUTI(n, v) \ - out_dword(VIDC_REG_615716_ADDR(n), v) - -#define VIDC_REG_603032_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e98) -#define VIDC_REG_603032_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e98) -#define VIDC_REG_603032_RMSK 0xffffffff -#define VIDC_REG_603032_SHFT 0 -#define VIDC_REG_603032_OUT(v) \ - out_dword(VIDC_REG_603032_ADDR, v) - -#define VIDC_REG_300310_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000e9c) -#define VIDC_REG_300310_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000e9c) -#define VIDC_REG_300310_RMSK 0xffffffff -#define VIDC_REG_300310_SHFT 0 -#define VIDC_REG_300310_IN \ - in_dword_masked(VIDC_REG_300310_ADDR, \ - VIDC_REG_300310_RMSK) -#define VIDC_REG_300310_INM(m) \ - in_dword_masked(VIDC_REG_300310_ADDR, m) -#define VIDC_REG_300310_ERROR_STATUS_BMSK 0xffffffff -#define VIDC_REG_300310_ERROR_STATUS_SHFT 0 - -#define VIDC_REG_792026_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ea0) -#define VIDC_REG_792026_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ea0) -#define VIDC_REG_792026_RMSK 0xffffffff -#define VIDC_REG_792026_SHFT 0 -#define VIDC_REG_792026_OUT(v) \ - out_dword(VIDC_REG_792026_ADDR, v) - -#define VIDC_REG_844152_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ea4) -#define VIDC_REG_844152_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ea4) -#define VIDC_REG_844152_RMSK 0xffffffff -#define VIDC_REG_844152_SHFT 0 -#define VIDC_REG_844152_OUT(v) \ - out_dword(VIDC_REG_844152_ADDR, v) - -#define VIDC_REG_370409_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ea8) -#define VIDC_REG_370409_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ea8) -#define VIDC_REG_370409_RMSK 0xffffffff -#define VIDC_REG_370409_SHFT 0 -#define VIDC_REG_370409_IN \ - in_dword_masked(VIDC_REG_370409_ADDR, \ - VIDC_REG_370409_RMSK) -#define VIDC_REG_370409_INM(m) \ - in_dword_masked(VIDC_REG_370409_ADDR, m) -#define VIDC_REG_370409_GET_FRAME_TAG_TOP_BMSK 0xffffffff -#define VIDC_REG_370409_GET_FRAME_TAG_TOP_SHFT 0 - -#define VIDC_REG_147682_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000eac) -#define VIDC_REG_147682_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000eac) -#define VIDC_REG_147682_RMSK 0x1 -#define VIDC_REG_147682_SHFT 0 -#define VIDC_REG_147682_OUT(v) \ - out_dword(VIDC_REG_147682_ADDR, v) - -#define VIDC_REG_407718_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000eb0) -#define VIDC_REG_407718_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000eb0) -#define VIDC_REG_407718_RMSK 0xffffffff -#define VIDC_REG_407718_SHFT 0 -#define VIDC_REG_407718_OUT(v) \ - out_dword(VIDC_REG_407718_ADDR, v) - -#define VIDC_REG_697961_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000eb4) -#define VIDC_REG_697961_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000eb4) -#define VIDC_REG_697961_RMSK 0x3 -#define VIDC_REG_697961_SHFT 0 -#define VIDC_REG_697961_IN \ - in_dword_masked(VIDC_REG_697961_ADDR, \ - VIDC_REG_697961_RMSK) -#define VIDC_REG_697961_INM(m) \ - in_dword_masked(VIDC_REG_697961_ADDR, m) -#define VIDC_REG_697961_FRAME_TYPE_BMSK 0x3 -#define VIDC_REG_697961_FRAME_TYPE_SHFT 0 - - -#define VIDC_REG_613254_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000eb8) -#define VIDC_REG_613254_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000eb8) -#define VIDC_REG_613254_RMSK 0x1 -#define VIDC_REG_613254_SHFT 0 -#define VIDC_REG_613254_IN \ - in_dword_masked(VIDC_REG_613254_ADDR, \ - VIDC_REG_613254_RMSK) -#define VIDC_REG_613254_INM(m) \ - in_dword_masked(VIDC_REG_613254_ADDR, m) -#define VIDC_REG_613254_METADATA_STATUS_BMSK 0x1 -#define VIDC_REG_613254_METADATA_STATUS_SHFT 0 -#define VIDC_REG_441270_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ebc) -#define VIDC_REG_441270_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ebc) -#define VIDC_REG_441270_RMSK 0x1f -#define VIDC_REG_441270_SHFT 0 -#define VIDC_REG_441270_IN \ - in_dword_masked(VIDC_REG_441270_ADDR, \ - VIDC_REG_441270_RMSK) -#define VIDC_REG_441270_INM(m) \ - in_dword_masked(VIDC_REG_441270_ADDR, m) -#define VIDC_REG_441270_DATA_PARTITIONED_BMSK 0x8 -#define VIDC_REG_441270_DATA_PARTITIONED_SHFT 0x3 - -#define VIDC_REG_441270_FRAME_TYPE_BMSK 0x17 -#define VIDC_REG_441270_FRAME_TYPE_SHFT 0 - -#define VIDC_REG_724381_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ec0) -#define VIDC_REG_724381_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ec0) -#define VIDC_REG_724381_RMSK 0x3 -#define VIDC_REG_724381_SHFT 0 -#define VIDC_REG_724381_IN \ - in_dword_masked(VIDC_REG_724381_ADDR, \ - VIDC_REG_724381_RMSK) -#define VIDC_REG_724381_INM(m) \ - in_dword_masked(VIDC_REG_724381_ADDR, m) -#define VIDC_REG_724381_MORE_FIELD_NEEDED_BMSK 0x4 -#define VIDC_REG_724381_MORE_FIELD_NEEDED_SHFT 0x2 -#define VIDC_REG_724381_OPERATION_FAILED_BMSK 0x2 -#define VIDC_REG_724381_OPERATION_FAILED_SHFT 0x1 -#define VIDC_REG_724381_RESOLUTION_CHANGE_BMSK 0x1 -#define VIDC_REG_724381_RESOLUTION_CHANGE_SHFT 0 - -#define VIDC_REG_854681_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ec4) -#define VIDC_REG_854681_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ec4) -#define VIDC_REG_854681_RMSK 0x7f -#define VIDC_REG_854681_SHFT 0 -#define VIDC_REG_854681_OUT(v) \ - out_dword(VIDC_REG_854681_ADDR, v) - -#define VIDC_REG_128234_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ec8) -#define VIDC_REG_128234_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ec8) -#define VIDC_REG_128234_RMSK 0xffff000f -#define VIDC_REG_128234_SHFT 0 -#define VIDC_REG_128234_OUT(v) \ - out_dword(VIDC_REG_128234_ADDR, v) - -#define VIDC_REG_1137_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ecc) -#define VIDC_REG_1137_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ecc) -#define VIDC_REG_1137_RMSK 0xffffffff -#define VIDC_REG_1137_SHFT 0 -#define VIDC_REG_1137_IN \ - in_dword_masked(VIDC_REG_1137_ADDR, \ - VIDC_REG_1137_RMSK) -#define VIDC_REG_1137_INM(m) \ - in_dword_masked(VIDC_REG_1137_ADDR, m) -#define VIDC_REG_1137_METADATA_DISPLAY_INDEX_BMSK \ - 0xffffffff -#define \ - \ -VIDC_REG_1137_METADATA_DISPLAY_INDEX_SHFT 0 - -#define VIDC_REG_988552_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ed0) -#define VIDC_REG_988552_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ed0) -#define VIDC_REG_988552_RMSK 0xffffffff -#define VIDC_REG_988552_SHFT 0 -#define VIDC_REG_988552_OUT(v) \ - out_dword(VIDC_REG_988552_ADDR, v) - -#define VIDC_REG_319934_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ed4) -#define VIDC_REG_319934_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ed4) -#define VIDC_REG_319934_RMSK 0xffffffff -#define VIDC_REG_319934_SHFT 0 -#define VIDC_REG_319934_OUT(v) \ - out_dword(VIDC_REG_319934_ADDR, v) - -#define VIDC_REG_679165_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ed8) -#define VIDC_REG_679165_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ed8) -#define VIDC_REG_679165_RMSK 0xffffffff -#define VIDC_REG_679165_SHFT 0 -#define VIDC_REG_679165_IN \ - in_dword_masked(VIDC_REG_679165_ADDR, \ - VIDC_REG_679165_RMSK) -#define VIDC_REG_679165_INM(m) \ - in_dword_masked(VIDC_REG_679165_ADDR, m) -#define VIDC_REG_679165_PIC_TIME_TOP_BMSK 0xffffffff -#define VIDC_REG_679165_PIC_TIME_TOP_SHFT 0 - -#define VIDC_REG_374150_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000edc) -#define VIDC_REG_374150_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000edc) -#define VIDC_REG_374150_RMSK 0xffffffff -#define VIDC_REG_374150_SHFT 0 -#define VIDC_REG_374150_IN \ - in_dword_masked(VIDC_REG_374150_ADDR, \ - VIDC_REG_374150_RMSK) -#define VIDC_REG_374150_INM(m) \ - in_dword_masked(VIDC_REG_374150_ADDR, m) -#define VIDC_REG_374150_PIC_TIME_BOTTOM_BMSK 0xffffffff -#define VIDC_REG_374150_PIC_TIME_BOTTOM_SHFT 0 - -#define VIDC_REG_94750_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ee0) -#define VIDC_REG_94750_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ee0) -#define VIDC_REG_94750_RMSK 0xffffffff -#define VIDC_REG_94750_SHFT 0 -#define VIDC_REG_94750_OUT(v) \ - out_dword(VIDC_REG_94750_ADDR, v) - -#define VIDC_REG_438677_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ee4) -#define VIDC_REG_438677_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ee4) -#define VIDC_REG_438677_RMSK 0xffffffff -#define VIDC_REG_438677_SHFT 0 -#define VIDC_REG_438677_IN \ - in_dword_masked(VIDC_REG_438677_ADDR, \ - VIDC_REG_438677_RMSK) -#define VIDC_REG_438677_INM(m) \ - in_dword_masked(VIDC_REG_438677_ADDR, m) -#define VIDC_REG_438677_GET_FRAME_TAG_BOTTOM_BMSK 0xffffffff -#define VIDC_REG_438677_GET_FRAME_TAG_BOTTOM_SHFT 0 - -#define VIDC_REG_76706_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000ee8) -#define VIDC_REG_76706_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000ee8) -#define VIDC_REG_76706_RMSK 0x1 -#define VIDC_REG_76706_SHFT 0 -#define VIDC_REG_76706_OUT(v) \ - out_dword(VIDC_REG_76706_ADDR, v) - -#define VIDC_REG_809984_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00001000) -#define VIDC_REG_809984_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00001000) -#define VIDC_REG_809984_RMSK 0xffff0007 -#define VIDC_REG_809984_SHFT 0 -#define VIDC_REG_809984_IN \ - in_dword_masked(VIDC_REG_809984_ADDR, VIDC_REG_809984_RMSK) -#define VIDC_REG_809984_INM(m) \ - in_dword_masked(VIDC_REG_809984_ADDR, m) -#define VIDC_REG_809984_720PV_720P_WRAPPER_VERSION_BMSK 0xffff0000 -#define VIDC_REG_809984_720PV_720P_WRAPPER_VERSION_SHFT 0x10 -#define VIDC_REG_809984_TEST_MUX_SEL_BMSK 0x7 -#define VIDC_REG_809984_TEST_MUX_SEL_SHFT 0 - - -#define VIDC_REG_699747_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d0c) -#define VIDC_REG_699747_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d0c) -#define VIDC_REG_699747_RMSK 0xffffffff -#define VIDC_REG_699747_SHFT 0 -#define VIDC_REG_699747_OUT(v) \ - out_dword(VIDC_REG_699747_ADDR, v) - -#define VIDC_REG_166247_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d10) -#define VIDC_REG_166247_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d10) -#define VIDC_REG_166247_RMSK 0xffffffff -#define VIDC_REG_166247_SHFT 0 -#define VIDC_REG_166247_OUT(v) \ - out_dword(VIDC_REG_166247_ADDR, v) - -#define VIDC_REG_486169_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d18) -#define VIDC_REG_486169_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d18) -#define VIDC_REG_486169_RMSK 0xffffffff -#define VIDC_REG_486169_SHFT 0 -#define VIDC_REG_486169_OUT(v) \ - out_dword(VIDC_REG_486169_ADDR, v) - -#define VIDC_REG_926519_ADDR \ - (VIDC_720P_WRAPPER_REG_BASE + 0x00000d1c) -#define VIDC_REG_926519_PHYS \ - (VIDC_720P_WRAPPER_REG_BASE_PHYS + 0x00000d1c) -#define VIDC_REG_926519_RMSK 0xffffffff -#define VIDC_REG_926519_SHFT 0 -#define VIDC_REG_926519_OUT(v) \ - out_dword(VIDC_REG_926519_ADDR, v) - -/** List all the levels and their register valus */ - -#define VIDC_720P_PROFILE_MPEG4_SP 0 -#define VIDC_720P_PROFILE_MPEG4_ASP 1 -#define VIDC_720P_PROFILE_H264_BASELINE 0 -#define VIDC_720P_PROFILE_H264_MAIN 1 -#define VIDC_720P_PROFILE_H264_HIGH 2 -#define VIDC_720P_PROFILE_H264_CPB 3 -#define VIDC_720P_PROFILE_H263_BASELINE 0 - -#define VIDC_720P_PROFILE_VC1_SP 0 -#define VIDC_720P_PROFILE_VC1_MAIN 1 -#define VIDC_720P_PROFILE_VC1_ADV 2 -#define VIDC_720P_PROFILE_MPEG2_MAIN 4 -#define VIDC_720P_PROFILE_MPEG2_SP 5 - -#define VIDC_720P_MPEG4_LEVEL0 0 -#define VIDC_720P_MPEG4_LEVEL0b 9 -#define VIDC_720P_MPEG4_LEVEL1 1 -#define VIDC_720P_MPEG4_LEVEL2 2 -#define VIDC_720P_MPEG4_LEVEL3 3 -#define VIDC_720P_MPEG4_LEVEL3b 7 -#define VIDC_720P_MPEG4_LEVEL4a 4 -#define VIDC_720P_MPEG4_LEVEL5 5 -#define VIDC_720P_MPEG4_LEVEL6 6 - -#define VIDC_720P_H264_LEVEL1 10 -#define VIDC_720P_H264_LEVEL1b 9 -#define VIDC_720P_H264_LEVEL1p1 11 -#define VIDC_720P_H264_LEVEL1p2 12 -#define VIDC_720P_H264_LEVEL1p3 13 -#define VIDC_720P_H264_LEVEL2 20 -#define VIDC_720P_H264_LEVEL2p1 21 -#define VIDC_720P_H264_LEVEL2p2 22 -#define VIDC_720P_H264_LEVEL3 30 -#define VIDC_720P_H264_LEVEL3p1 31 -#define VIDC_720P_H264_LEVEL3p2 32 - -#define VIDC_720P_H263_LEVEL10 10 -#define VIDC_720P_H263_LEVEL20 20 -#define VIDC_720P_H263_LEVEL30 30 -#define VIDC_720P_H263_LEVEL40 40 -#define VIDC_720P_H263_LEVEL45 45 -#define VIDC_720P_H263_LEVEL50 50 -#define VIDC_720P_H263_LEVEL60 60 -#define VIDC_720P_H263_LEVEL70 70 - -#define VIDC_720P_VC1_LEVEL_LOW 0 -#define VIDC_720P_VC1_LEVEL_MED 2 -#define VIDC_720P_VC1_LEVEL_HIGH 4 -#define VIDC_720P_VC1_LEVEL0 0 -#define VIDC_720P_VC1_LEVEL1 1 -#define VIDC_720P_VC1_LEVEL2 2 -#define VIDC_720P_VC1_LEVEL3 3 -#define VIDC_720P_VC1_LEVEL4 4 - -#define VIDCL_720P_MPEG2_LEVEL_LOW 10 -#define VIDCL_720P_MPEG2_LEVEL_MAIN 8 -#define VIDCL_720P_MPEG2_LEVEL_HIGH14 6 - -#define VIDC_720P_CMD_CHSET 0x0 -#define VIDC_720P_CMD_CHEND 0x2 -#define VIDC_720P_CMD_INITCODEC 0x3 -#define VIDC_720P_CMD_FRAMERUN 0x4 -#define VIDC_720P_CMD_INITBUFFERS 0x5 -#define VIDC_720P_CMD_FRAMERUN_REALLOCATE 0x6 -#define VIDC_720P_CMD_MFC_ENGINE_RESET 0x7 - -enum vidc_720p_endian { - VIDC_720P_BIG_ENDIAN = 0x0, - VIDC_720P_LITTLE_ENDIAN = 0x1 -}; - -enum vidc_720p_memory_access_method { - VIDC_720P_TILE_LINEAR = 0, - VIDC_720P_TILE_16x16 = 2, - VIDC_720P_TILE_64x32 = 3 -}; - -enum vidc_720p_interrupt_control_mode { - VIDC_720P_INTERRUPT_MODE = 0, - VIDC_720P_POLL_MODE = 1 -}; - -enum vidc_720p_interrupt_level_selection { - VIDC_720P_INTERRUPT_LEVEL_SEL = 0, - VIDC_720P_INTERRUPT_PULSE_SEL = 1 -}; - -#define VIDC_720P_INTR_BUFFER_FULL 0x002 -#define VIDC_720P_INTR_FW_DONE 0x020 -#define VIDC_720P_INTR_HEADER_DONE 0x040 -#define VIDC_720P_INTR_DMA_DONE 0x080 -#define VIDC_720P_INTR_FRAME_DONE 0x100 - -enum vidc_720p_enc_dec_selection { - VIDC_720P_DECODER = 0, - VIDC_720P_ENCODER = 1 -}; - -enum vidc_720p_codec { - VIDC_720P_MPEG4 = 0, - VIDC_720P_H264 = 1, - VIDC_720P_DIVX = 2, - VIDC_720P_XVID = 3, - VIDC_720P_H263 = 4, - VIDC_720P_MPEG2 = 5, - VIDC_720P_VC1 = 6 -}; - -enum vidc_720p_frame { - VIDC_720P_NOTCODED = 0, - VIDC_720P_IFRAME = 1, - VIDC_720P_PFRAME = 2, - VIDC_720P_BFRAME = 3, - VIDC_720P_IDRFRAME = 4 -}; - -enum vidc_720p_entropy_sel { - VIDC_720P_ENTROPY_SEL_CAVLC = 0, - VIDC_720P_ENTROPY_SEL_CABAC = 1 -}; - -enum vidc_720p_cabac_model { - VIDC_720P_CABAC_MODEL_NUMBER_0 = 0, - VIDC_720P_CABAC_MODEL_NUMBER_1 = 1, - VIDC_720P_CABAC_MODEL_NUMBER_2 = 2 -}; - -enum vidc_720p_DBConfig { - VIDC_720P_DB_ALL_BLOCKING_BOUNDARY = 0, - VIDC_720P_DB_DISABLE = 1, - VIDC_720P_DB_SKIP_SLICE_BOUNDARY = 2 -}; - -enum vidc_720p_MSlice_selection { - VIDC_720P_MSLICE_BY_MB_COUNT = 0, - VIDC_720P_MSLICE_BY_BYTE_COUNT = 1, - VIDC_720P_MSLICE_BY_GOB = 2, - VIDC_720P_MSLICE_OFF = 3 -}; - -enum vidc_720p_display_status { - VIDC_720P_DECODE_ONLY = 0, - VIDC_720P_DECODE_AND_DISPLAY = 1, - VIDC_720P_DISPLAY_ONLY = 2, - VIDC_720P_EMPTY_BUFFER = 3 -}; - -#define VIDC_720P_ENC_IFRAME_REQ 0x1 -#define VIDC_720P_ENC_IPERIOD_CHANGE 0x1 -#define VIDC_720P_ENC_FRAMERATE_CHANGE 0x2 -#define VIDC_720P_ENC_BITRATE_CHANGE 0x4 - -#define VIDC_720P_FLUSH_REQ 0x1 -#define VIDC_720P_EXTRADATA 0x2 - -#define VIDC_720P_METADATA_ENABLE_QP 0x01 -#define VIDC_720P_METADATA_ENABLE_CONCEALMB 0x02 -#define VIDC_720P_METADATA_ENABLE_VC1 0x04 -#define VIDC_720P_METADATA_ENABLE_SEI 0x08 -#define VIDC_720P_METADATA_ENABLE_VUI 0x10 -#define VIDC_720P_METADATA_ENABLE_ENCSLICE 0x20 -#define VIDC_720P_METADATA_ENABLE_PASSTHROUGH 0x40 - -struct vidc_720p_dec_disp_info { - enum vidc_720p_display_status disp_status; - u32 resl_change; - u32 reconfig_flush_done; - u32 img_size_x; - u32 img_size_y; - u32 y_addr; - u32 c_addr; - u32 tag_top; - u32 pic_time_top; - u32 disp_is_interlace; - u32 tag_bottom; - u32 pic_time_bottom; - u32 metadata_exists; - u32 crop_exists; - u32 crop_right_offset; - u32 crop_left_offset; - u32 crop_bottom_offset; - u32 crop_top_offset; - u32 input_frame; - u32 input_bytes_consumed; - u32 input_is_interlace; - u32 input_frame_num; -}; - -struct vidc_720p_seq_hdr_info { - u32 img_size_x; - u32 img_size_y; - u32 dec_frm_size; - u32 min_num_dpb; - u32 min_dpb_size; - u32 profile; - u32 level; - u32 progressive; - u32 data_partitioned; - u32 crop_exists; - u32 crop_right_offset; - u32 crop_left_offset; - u32 crop_bottom_offset; - u32 crop_top_offset; -}; - -struct vidc_720p_enc_frame_info { - u32 enc_size; - u32 frame; - u32 metadata_exists; -}; - -void vidc_720p_set_device_virtual_base(u8 *core_virtual_base_addr); - -void vidc_720p_init(char **ppsz_version, u32 i_firmware_size, - u32 *pi_firmware_address, enum vidc_720p_endian dma_endian, - u32 interrupt_off, - enum vidc_720p_interrupt_level_selection interrupt_sel, - u32 interrupt_mask); - -u32 vidc_720p_do_sw_reset(void); - -u32 vidc_720p_reset_is_success(void); - -void vidc_720p_start_cpu(enum vidc_720p_endian dma_endian, - u32 *icontext_bufferstart, u32 *debug_core_dump_addr, - u32 debug_buffer_size); - -u32 vidc_720p_cpu_start(void); - -void vidc_720p_stop_fw(void); - -void vidc_720p_get_interrupt_status(u32 *interrupt_status, - u32 *cmd_err_status, u32 *disp_pic_err_status, - u32 *op_failed); - -void vidc_720p_interrupt_done_clear(void); - -void vidc_720p_submit_command(u32 ch_id, u32 cmd_id); - - -void vidc_720p_set_channel(u32 i_ch_id, - enum vidc_720p_enc_dec_selection enc_dec_sel, - enum vidc_720p_codec codec, u32 *pi_fw, u32 i_firmware_size); - -u32 vidc_720p_engine_reset(u32 ch_id, - enum vidc_720p_endian dma_endian, - enum vidc_720p_interrupt_level_selection interrupt_sel, - u32 interrupt_mask -); - -void vidc_720p_encode_set_profile(u32 i_profile, u32 i_level); - -void vidc_720p_set_frame_size(u32 i_size_x, u32 i_size_y); - -void vidc_720p_encode_set_fps(u32 i_rc_frame_rate); - -void vidc_720p_encode_set_vop_time(u32 vop_time_resolution, - u32 vop_time_increment); - -void vidc_720p_encode_set_hec_period(u32 hec_period); - -void vidc_720p_encode_set_short_header(u32 i_short_header); - -void vidc_720p_encode_set_qp_params(u32 i_max_qp, u32 i_min_qp); - -void vidc_720p_encode_set_rc_config(u32 enable_frame_level_rc, - u32 enable_mb_level_rc_flag, u32 i_frame_qp, u32 pframe_qp); - -void vidc_720p_encode_set_bit_rate(u32 i_target_bitrate); - -void vidc_720p_encoder_set_param_change(u32 enc_param_change); - -void vidc_720p_encode_set_control_param(u32 param_val); - -void vidc_720p_encode_set_frame_level_rc_params(u32 i_reaction_coeff); - -void vidc_720p_encode_set_mb_level_rc_params(u32 dark_region_as_flag, - u32 smooth_region_as_flag, u32 static_region_as_flag, - u32 activity_region_flag); - -void vidc_720p_encode_set_entropy_control(enum vidc_720p_entropy_sel \ - entropy_sel, - enum vidc_720p_cabac_model cabac_model_number); - -void vidc_720p_encode_set_db_filter_control(enum vidc_720p_DBConfig - db_config, u32 i_slice_alpha_offset, u32 i_slice_beta_offset); - -void vidc_720p_encode_set_intra_refresh_mb_number(u32 i_cir_mb_number); - -void vidc_720p_encode_set_multi_slice_info( - enum vidc_720p_MSlice_selection m_slice_sel, - u32 multi_slice_size); - -void vidc_720p_encode_set_dpb_buffer(u32 *pi_enc_dpb_addr, u32 alloc_len); - -void vidc_720p_set_deblock_line_buffer(u32 *pi_deblock_line_buffer_start, - u32 alloc_len); - -void vidc_720p_encode_set_i_period(u32 i_i_period); - -void vidc_720p_encode_init_codec(u32 i_ch_id, - enum vidc_720p_memory_access_method memory_access_model); - -void vidc_720p_encode_unalign_bitstream(u32 upper_unalign_word, - u32 lower_unalign_word); - -void vidc_720p_encode_set_seq_header_buffer(u32 ext_buffer_start, - u32 ext_buffer_end, u32 start_byte_num); - -void vidc_720p_encode_frame(u32 ch_id, u32 ext_buffer_start, - u32 ext_buffer_end, u32 start_byte_number, - u32 y_addr, u32 c_addr); - -void vidc_720p_encode_get_header(u32 *pi_enc_header_size); - -void vidc_720p_enc_frame_info - (struct vidc_720p_enc_frame_info *enc_frame_info); - -void vidc_720p_decode_bitstream_header(u32 ch_id, u32 dec_unit_size, - u32 start_byte_num, u32 ext_buffer_start, u32 ext_buffer_end, - enum vidc_720p_memory_access_method memory_access_model, - u32 decode_order); - -void vidc_720p_decode_get_seq_hdr_info - (struct vidc_720p_seq_hdr_info *seq_hdr_info); - -void vidc_720p_decode_set_dpb_release_buffer_mask - (u32 i_dpb_release_buffer_mask); - -void vidc_720p_decode_set_dpb_buffers(u32 i_buf_index, u32 *pi_dpb_buffer); - -void vidc_720p_decode_set_comv_buffer - (u32 *pi_dpb_comv_buffer, u32 alloc_len); - -void vidc_720p_decode_set_dpb_details - (u32 num_dpb, u32 alloc_len, u32 *ref_buffer); - -void vidc_720p_decode_set_mpeg4Post_filter(u32 enable_post_filter); - -void vidc_720p_decode_set_error_control(u32 enable_error_control); - -void vidc_720p_decode_set_mpeg4_data_partitionbuffer(u32 *vsp_buf_start); - -void vidc_720p_decode_setH264VSPBuffer(u32 *pi_vsp_temp_buffer_start); - -void vidc_720p_decode_frame(u32 ch_id, u32 ext_buffer_start, - u32 ext_buffer_end, u32 dec_unit_size, - u32 start_byte_num, u32 input_frame_tag); - -void vidc_720p_issue_eos(u32 i_ch_id); -void vidc_720p_eos_info(u32 *disp_status, u32 *resl_change); - -void vidc_720p_decode_display_info - (struct vidc_720p_dec_disp_info *disp_info); - -void vidc_720p_decode_skip_frm_details(u32 *free_luma_dpb); - -void vidc_720p_metadata_enable(u32 flag, u32 *input_buffer); - -void vidc_720p_decode_dynamic_req_reset(void); - -void vidc_720p_decode_dynamic_req_set(u32 property); - -void vidc_720p_decode_setpassthrough_start(u32 pass_startaddr); - - - -#define DDL_720P_REG_BASE VIDC_720P_WRAPPER_REG_BASE -#define VIDC_BUSY_WAIT(n) udelay(n) - -#undef VIDC_REGISTER_LOG_MSG -#undef VIDC_REGISTER_LOG_INTO_BUFFER - -#ifdef VIDC_REGISTER_LOG_MSG -#define VIDC_MSG1(msg_format, a) printk(KERN_INFO msg_format, a) -#define VIDC_MSG2(msg_format, a, b) printk(KERN_INFO msg_format, a, b) -#define VIDC_MSG3(msg_format, a, b, c) printk(KERN_INFO msg_format, a, b, c) -#else -#define VIDC_MSG1(msg_format, a) -#define VIDC_MSG2(msg_format, a, b) -#define VIDC_MSG3(msg_format, a, b, c) -#endif - -#ifdef VIDC_REGISTER_LOG_INTO_BUFFER - -#define VIDC_REGLOG_BUFSIZE 200000 -#define VIDC_REGLOG_MAX_PRINT_SIZE 100 -extern char vidclog[VIDC_REGLOG_BUFSIZE]; -extern unsigned int vidclog_index; - -#define VIDC_LOG_BUFFER_INIT \ -{if (vidclog_index) \ - memset(vidclog, 0, vidclog_index+1); \ - vidclog_index = 0; } - -#define VIDC_REGLOG_CHECK_BUFINDEX(req_size) \ - vidclog_index = \ - (vidclog_index+(req_size) < VIDC_REGLOG_BUFSIZE) ? vidclog_index : 0; - -#define VIDC_LOG_WRITE(reg, val) \ -{unsigned int len; \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], VIDC_REGLOG_MAX_PRINT_SIZE, \ - "(0x%x:"#reg"=0x%x)" , VIDC_##reg##_ADDR - DDL_720P_REG_BASE, val);\ - vidclog_index += len; } - -#define VIDC_LOG_WRITEI(reg, index, val) \ -{unsigned int len; \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], VIDC_REGLOG_MAX_PRINT_SIZE, \ - "(0x%x:"#reg"=0x%x)" , VIDC_##reg##_ADDR(index)-DDL_720P_REG_BASE, \ - val); vidclog_index += len; } - -#define VIDC_LOG_WRITEF(reg, field, val) \ -{unsigned int len; \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], VIDC_REGLOG_MAX_PRINT_SIZE, \ - "(0x%x:"#reg":0x%x:=0x%x)" , VIDC_##reg##_ADDR - DDL_720P_REG_BASE, \ - VIDC_##reg##_##field##_BMSK, val);\ - vidclog_index += len; } - -#define VIDC_LOG_READ(reg, pval) \ -{ unsigned int len; \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], VIDC_REGLOG_MAX_PRINT_SIZE, \ - "(0x%x:"#reg"==0x%x)" , VIDC_##reg##_ADDR - DDL_720P_REG_BASE, \ - (u32)*pval); \ - vidclog_index += len; } - -#define VIDC_STR_LOGBUFFER(str) \ -{ unsigned int len; \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], VIDC_REGLOG_MAX_PRINT_SIZE, \ - "<%s>" , str); vidclog_index += len; } - -#define VIDC_LONG_LOGBUFFER(str, arg1) \ -{ unsigned int len; \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], VIDC_REGLOG_MAX_PRINT_SIZE, \ - "<%s=0x%x>" , str, arg1); vidclog_index += len; } - -#define VIDC_DEBUG_REGISTER_LOG \ -{ u32 val; unsigned int len; \ - val = VIDC_720P_IN(REG_881638); \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], 50, "[dbg1=%x]" , val); \ - vidclog_index += len; \ - val = VIDC_720P_IN(REG_161486); \ - VIDC_REGLOG_CHECK_BUFINDEX(VIDC_REGLOG_MAX_PRINT_SIZE); \ - len = snprintf(&vidclog[vidclog_index], 50, "[dbg2=%x]" , val); \ - vidclog_index += len; } - -#else -#define VIDC_LOG_WRITE(reg, val) -#define VIDC_LOG_WRITEI(reg, index, val) -#define VIDC_LOG_WRITEF(reg, field, val) -#define VIDC_LOG_READ(reg, pval) -#define VIDC_LOG_BUFFER_INIT -#define VIDC_STR_LOGBUFFER(str) -#define VIDC_LONG_LOGBUFFER(str, arg1) -#define VIDC_DEBUG_REGISTER_LOG -#endif - -void vidcputlog(char *str); -void vidcput_debug_reglog(void); - -#define VIDC_LOGERR_STRING(str) \ -do { \ - VIDC_STR_LOGBUFFER(str); \ - VIDC_MSG1("\n<%s>", str); \ -} while (0) - -#define VIDC_LOG_STRING(str) \ -do { \ - VIDC_STR_LOGBUFFER(str); \ - VIDC_MSG1("\n<%s>", str); \ -} while (0) - -#define VIDC_LOG1(str, arg1) \ -do { \ - VIDC_LONG_LOGBUFFER(str, arg1); \ - VIDC_MSG2("\n<%s=0x%08x>", str, arg1); \ -} while (0) - -#define VIDC_IO_OUT(reg, val) \ -do { \ - VIDC_LOG_WRITE(reg, (u32)val); \ - VIDC_MSG2("\n(0x%08x:"#reg"=0x%08x)", \ - (u32)(VIDC_##reg##_ADDR - DDL_720P_REG_BASE), (u32)val); \ - mb(); \ - VIDC_720P_OUT(reg, val); \ -} while (0) - -#define VIDC_IO_OUTI(reg, index, val) \ -do { \ - VIDC_LOG_WRITEI(reg, index, (u32)val); \ - VIDC_MSG2("\n(0x%08x:"#reg"=0x%08x)", \ - (u32)(VIDC_##reg##_ADDR(index)-DDL_720P_REG_BASE), (u32)val); \ - mb(); \ - VIDC_720P_OUTI(reg, index, val); \ -} while (0) - -#define VIDC_IO_OUTF(reg, field, val) \ -do { \ - VIDC_LOG_WRITEF(reg, field, val); \ - VIDC_MSG3("\n(0x%08x:"#reg":0x%x:=0x%08x)", \ - (u32)(VIDC_##reg##_ADDR - DDL_720P_REG_BASE), \ - VIDC_##reg##_##field##_BMSK, (u32)val); \ - mb(); \ - VIDC_720P_OUTF(reg, field, val); \ -} while (0) - -#define VIDC_IO_IN(reg, pval) \ -do { \ - mb(); \ - *pval = (u32) VIDC_720P_IN(reg); \ - VIDC_LOG_READ(reg, pval); \ - VIDC_MSG2("\n(0x%08x:"#reg"==0x%08x)", \ - (u32)(VIDC_##reg##_ADDR - DDL_720P_REG_BASE), (u32) *pval); \ -} while (0) - -#define VIDC_IO_INF(reg, mask, pval) \ -do { \ - mb(); \ - *pval = VIDC_720P_INF(reg, mask); \ - VIDC_LOG_READ(reg, pval); \ - VIDC_MSG2("\n(0x%08x:"#reg"==0x%08x)", \ - (u32)(VIDC_##reg##_ADDR - DDL_720P_REG_BASE), *pval); \ -} while (0) - -#endif diff --git a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.c b/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.c deleted file mode 100644 index a67dc1c1bc7f84580c0866fe7c6eeb77a534d921..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.c +++ /dev/null @@ -1,811 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include "vcd_res_tracker.h" - -#define MSM_AXI_QOS_NAME "msm_vidc_reg" -#define AXI_CLK_SCALING - -#define QVGA_PERF_LEVEL (300 * 30) -#define VGA_PERF_LEVEL (1200 * 30) -#define WVGA_PERF_LEVEL (1500 * 30) - -static unsigned int mfc_clk_freq_table[3] = { - 61440000, 122880000, 170667000 -}; - -static unsigned int axi_clk_freq_table_enc[2] = { - 122880, 192000 -}; -static unsigned int axi_clk_freq_table_dec[2] = { - 122880, 192000 -}; - -static struct res_trk_context resource_context; - -#define VIDC_BOOT_FW "vidc_720p_command_control.fw" -#define VIDC_MPG4_DEC_FW "vidc_720p_mp4_dec_mc.fw" -#define VIDC_H263_DEC_FW "vidc_720p_h263_dec_mc.fw" -#define VIDC_H264_DEC_FW "vidc_720p_h264_dec_mc.fw" -#define VIDC_MPG4_ENC_FW "vidc_720p_mp4_enc_mc.fw" -#define VIDC_H264_ENC_FW "vidc_720p_h264_enc_mc.fw" -#define VIDC_VC1_DEC_FW "vidc_720p_vc1_dec_mc.fw" - -unsigned char *vidc_command_control_fw; -u32 vidc_command_control_fw_size; - -unsigned char *vidc_mpg4_dec_fw; -u32 vidc_mpg4_dec_fw_size; - -unsigned char *vidc_h263_dec_fw; -u32 vidc_h263_dec_fw_size; - -unsigned char *vidc_h264_dec_fw; -u32 vidc_h264_dec_fw_size; - -unsigned char *vidc_mpg4_enc_fw; -u32 vidc_mpg4_enc_fw_size; - -unsigned char *vidc_h264_enc_fw; -u32 vidc_h264_enc_fw_size; - -unsigned char *vidc_vc1_dec_fw; -u32 vidc_vc1_dec_fw_size; - -static u32 res_trk_disable_videocore(void) -{ - int rc = -1; - mutex_lock(&resource_context.lock); - - if (!resource_context.rail_enabled) { - mutex_unlock(&resource_context.lock); - return false; - } - - if (!resource_context.clock_enabled && - resource_context.pclk && - resource_context.hclk && - resource_context.hclk_div2) { - - VCDRES_MSG_LOW("\nEnabling clk before disabling pwr rail\n"); - if (clk_set_rate(resource_context.hclk, - mfc_clk_freq_table[0])) { - VCDRES_MSG_ERROR("\n pwr_rail_disable:" - " set clk rate failed\n"); - goto bail_out; - } - - if (clk_prepare_enable(resource_context.pclk)) { - VCDRES_MSG_ERROR("vidc pclk Enable failed\n"); - goto bail_out; - } - - if (clk_prepare_enable(resource_context.hclk)) { - VCDRES_MSG_ERROR("vidc hclk Enable failed\n"); - goto disable_pclk; - } - - if (clk_prepare_enable(resource_context.hclk_div2)) { - VCDRES_MSG_ERROR("vidc hclk_div2 Enable failed\n"); - goto disable_hclk; - } - } else { - VCDRES_MSG_ERROR("\ndisabling pwr rail: Enabling clk failed\n"); - goto bail_out; - } - - resource_context.rail_enabled = 0; - rc = clk_reset(resource_context.pclk, CLK_RESET_ASSERT); - if (rc) { - VCDRES_MSG_ERROR("\n clk_reset failed %d\n", rc); - mutex_unlock(&resource_context.lock); - return false; - } - msleep(20); - - clk_disable_unprepare(resource_context.pclk); - clk_disable_unprepare(resource_context.hclk); - clk_disable_unprepare(resource_context.hclk_div2); - - clk_put(resource_context.hclk_div2); - clk_put(resource_context.hclk); - clk_put(resource_context.pclk); - - rc = regulator_disable(resource_context.regulator); - if (rc) { - VCDRES_MSG_ERROR("\n regulator disable failed %d\n", rc); - mutex_unlock(&resource_context.lock); - return false; - } - - resource_context.hclk_div2 = NULL; - resource_context.hclk = NULL; - resource_context.pclk = NULL; - - mutex_unlock(&resource_context.lock); - - return true; - -disable_hclk: - clk_disable_unprepare(resource_context.hclk); -disable_pclk: - clk_disable_unprepare(resource_context.pclk); -bail_out: - if (resource_context.pclk) { - clk_put(resource_context.pclk); - resource_context.pclk = NULL; - } - if (resource_context.hclk) { - clk_put(resource_context.hclk); - resource_context.hclk = NULL; - } - if (resource_context.hclk_div2) { - clk_put(resource_context.hclk_div2); - resource_context.hclk_div2 = NULL; - } - mutex_unlock(&resource_context.lock); - return false; -} - -u32 res_trk_enable_clocks(void) -{ - VCDRES_MSG_LOW("\n in res_trk_enable_clocks()"); - - mutex_lock(&resource_context.lock); - if (!resource_context.clock_enabled) { - VCDRES_MSG_LOW("Enabling IRQ in %s()\n", __func__); - enable_irq(resource_context.irq_num); - - VCDRES_MSG_LOW("%s(): Enabling the clocks ...\n", __func__); - - if (clk_prepare_enable(resource_context.pclk)) { - VCDRES_MSG_ERROR("vidc pclk Enable failed\n"); - - clk_put(resource_context.hclk); - clk_put(resource_context.hclk_div2); - mutex_unlock(&resource_context.lock); - return false; - } - - if (clk_prepare_enable(resource_context.hclk)) { - VCDRES_MSG_ERROR("vidc hclk Enable failed\n"); - clk_put(resource_context.pclk); - clk_put(resource_context.hclk_div2); - mutex_unlock(&resource_context.lock); - return false; - } - - if (clk_prepare_enable(resource_context.hclk_div2)) { - VCDRES_MSG_ERROR("vidc hclk Enable failed\n"); - clk_put(resource_context.hclk); - clk_put(resource_context.pclk); - mutex_unlock(&resource_context.lock); - return false; - } - } - - resource_context.clock_enabled = 1; - mutex_unlock(&resource_context.lock); - return true; -} - -static u32 res_trk_sel_clk_rate(unsigned long hclk_rate) -{ - mutex_lock(&resource_context.lock); - if (clk_set_rate(resource_context.hclk, - hclk_rate)) { - VCDRES_MSG_ERROR("vidc hclk set rate failed\n"); - mutex_unlock(&resource_context.lock); - return false; - } - resource_context.hclk_rate = hclk_rate; - mutex_unlock(&resource_context.lock); - return true; -} - -static u32 res_trk_get_clk_rate(unsigned long *phclk_rate) -{ - if (!phclk_rate) { - VCDRES_MSG_ERROR("%s(): phclk_rate is NULL\n", __func__); - return false; - } - mutex_lock(&resource_context.lock); - *phclk_rate = clk_get_rate(resource_context.hclk); - if (!(*phclk_rate)) { - VCDRES_MSG_ERROR("vidc hclk get rate failed\n"); - mutex_unlock(&resource_context.lock); - return false; - } - mutex_unlock(&resource_context.lock); - return true; -} - -u32 res_trk_disable_clocks(void) -{ - VCDRES_MSG_LOW("in res_trk_disable_clocks()\n"); - - mutex_lock(&resource_context.lock); - - if (!resource_context.clock_enabled) { - mutex_unlock(&resource_context.lock); - return false; - } - - VCDRES_MSG_LOW("Disabling IRQ in %s()\n", __func__); - disable_irq_nosync(resource_context.irq_num); - VCDRES_MSG_LOW("%s(): Disabling the clocks ...\n", __func__); - - resource_context.clock_enabled = 0; - clk_disable_unprepare(resource_context.hclk); - clk_disable_unprepare(resource_context.hclk_div2); - clk_disable_unprepare(resource_context.pclk); - mutex_unlock(&resource_context.lock); - - return true; -} - -static u32 res_trk_enable_videocore(void) -{ - mutex_lock(&resource_context.lock); - if (!resource_context.rail_enabled) { - int rc = -1; - - rc = regulator_enable(resource_context.regulator); - if (rc) { - VCDRES_MSG_ERROR("%s(): regulator_enable failed %d\n", - __func__, rc); - goto bail_out; - } - VCDRES_MSG_LOW("%s(): regulator enable Success %d\n", - __func__, rc); - - resource_context.pclk = clk_get(resource_context.device, - "iface_clk"); - - if (IS_ERR(resource_context.pclk)) { - VCDRES_MSG_ERROR("%s(): iface_clk get failed\n" - , __func__); - goto disable_regulator; - } - - resource_context.hclk = clk_get(resource_context.device, - "core_clk"); - - if (IS_ERR(resource_context.hclk)) { - VCDRES_MSG_ERROR("%s(): core_clk get failed\n" - , __func__); - - goto release_pclk; - } - - resource_context.hclk_div2 = - clk_get(resource_context.device, "core_div2_clk"); - - if (IS_ERR(resource_context.hclk_div2)) { - VCDRES_MSG_ERROR("%s(): core_div2_clk get failed\n" - , __func__); - goto release_hclk_pclk; - } - - if (clk_set_rate(resource_context.hclk, - mfc_clk_freq_table[0])) { - VCDRES_MSG_ERROR("\n pwr_rail_enable:" - " set clk rate failed\n"); - goto release_all_clks; - } - - if (clk_prepare_enable(resource_context.pclk)) { - VCDRES_MSG_ERROR("vidc pclk Enable failed\n"); - goto release_all_clks; - } - - if (clk_prepare_enable(resource_context.hclk)) { - VCDRES_MSG_ERROR("vidc hclk Enable failed\n"); - goto disable_pclk; - } - - if (clk_prepare_enable(resource_context.hclk_div2)) { - VCDRES_MSG_ERROR("vidc hclk_div2 Enable failed\n"); - goto disable_hclk_pclk; - } - - rc = clk_reset(resource_context.pclk, CLK_RESET_DEASSERT); - if (rc) { - VCDRES_MSG_ERROR("\n clk_reset failed %d\n", rc); - goto disable_and_release_all_clks; - } - msleep(20); - - clk_disable_unprepare(resource_context.pclk); - clk_disable_unprepare(resource_context.hclk); - clk_disable_unprepare(resource_context.hclk_div2); - - } - resource_context.rail_enabled = 1; - mutex_unlock(&resource_context.lock); - return true; - -disable_and_release_all_clks: - clk_disable_unprepare(resource_context.hclk_div2); -disable_hclk_pclk: - clk_disable_unprepare(resource_context.hclk); -disable_pclk: - clk_disable_unprepare(resource_context.pclk); -release_all_clks: - clk_put(resource_context.hclk_div2); - resource_context.hclk_div2 = NULL; -release_hclk_pclk: - clk_put(resource_context.hclk); - resource_context.hclk = NULL; -release_pclk: - clk_put(resource_context.pclk); - resource_context.pclk = NULL; -disable_regulator: - regulator_disable(resource_context.regulator); -bail_out: - mutex_unlock(&resource_context.lock); - return false; -} - -static u32 res_trk_convert_freq_to_perf_lvl(u64 freq) -{ - u64 perf_lvl; - u64 temp; - - VCDRES_MSG_MED("\n %s():: freq = %u\n", __func__, (u32)freq); - - if (!freq) - return 0; - - temp = freq * 1000; - do_div(temp, VCD_RESTRK_HZ_PER_1000_PERFLVL); - perf_lvl = (u32)temp; - VCDRES_MSG_MED("\n %s(): perf_lvl = %u\n", __func__, - (u32)perf_lvl); - - return (u32)perf_lvl; -} - -static u32 res_trk_convert_perf_lvl_to_freq(u64 perf_lvl) -{ - u64 freq, temp; - - VCDRES_MSG_MED("\n %s():: perf_lvl = %u\n", __func__, - (u32)perf_lvl); - temp = (perf_lvl * VCD_RESTRK_HZ_PER_1000_PERFLVL) + 999; - do_div(temp, 1000); - freq = (u32)temp; - VCDRES_MSG_MED("\n %s(): freq = %u\n", __func__, (u32)freq); - - return (u32)freq; -} - -static struct clk *ebi1_clk; - -u32 res_trk_power_up(void) -{ - VCDRES_MSG_LOW("clk_regime_rail_enable"); - VCDRES_MSG_LOW("clk_regime_sel_rail_control"); -#ifdef AXI_CLK_SCALING -{ - VCDRES_MSG_MED("\n res_trk_power_up():: " - "Calling AXI add requirement\n"); - ebi1_clk = clk_get(resource_context.device, "mem_clk"); - if (IS_ERR(ebi1_clk)) { - VCDRES_MSG_ERROR("Request AXI bus QOS fails."); - return false; - } - clk_prepare_enable(ebi1_clk); -} -#endif - - VCDRES_MSG_MED("\n res_trk_power_up():: Calling " - "vidc_enable_pwr_rail()\n"); - return res_trk_enable_videocore(); -} - -u32 res_trk_power_down(void) -{ - VCDRES_MSG_LOW("clk_regime_rail_disable"); -#ifdef AXI_CLK_SCALING - VCDRES_MSG_MED("\n res_trk_power_down()::" - "Calling AXI remove requirement\n"); - clk_disable_unprepare(ebi1_clk); - clk_put(ebi1_clk); -#endif - VCDRES_MSG_MED("\n res_trk_power_down():: Calling " - "res_trk_disable_videocore()\n"); - return res_trk_disable_videocore(); -} - -u32 res_trk_get_max_perf_level(u32 *pn_max_perf_lvl) -{ - if (!pn_max_perf_lvl) { - VCDRES_MSG_ERROR("%s(): pn_max_perf_lvl is NULL\n", - __func__); - return false; - } - - *pn_max_perf_lvl = VCD_RESTRK_MAX_PERF_LEVEL; - return true; -} - -u32 res_trk_set_perf_level(u32 req_perf_lvl, u32 *pn_set_perf_lvl, - struct vcd_dev_ctxt *dev_ctxt) -{ - struct vcd_clnt_ctxt *cctxt_itr = NULL; - u32 axi_freq = 0, mfc_freq = 0, calc_mfc_freq = 0; - u8 enc_clnt_present = false; - - if (!pn_set_perf_lvl || !dev_ctxt) { - VCDRES_MSG_ERROR("%s(): NULL pointer! dev_ctxt(%p)\n", - __func__, dev_ctxt); - return false; - } - - VCDRES_MSG_LOW("%s(), req_perf_lvl = %d", __func__, req_perf_lvl); - calc_mfc_freq = res_trk_convert_perf_lvl_to_freq( - (u64)req_perf_lvl); - - if (calc_mfc_freq < VCD_RESTRK_MIN_FREQ_POINT) - calc_mfc_freq = VCD_RESTRK_MIN_FREQ_POINT; - else if (calc_mfc_freq > VCD_RESTRK_MAX_FREQ_POINT) - calc_mfc_freq = VCD_RESTRK_MAX_FREQ_POINT; - - cctxt_itr = dev_ctxt->cctxt_list_head; - while (cctxt_itr) { - VCDRES_MSG_LOW("\n cctxt_itr = %p", cctxt_itr); - if (!cctxt_itr->decoding) { - VCDRES_MSG_LOW("\n Encoder client"); - enc_clnt_present = true; - break; - } else { - VCDRES_MSG_LOW("\n Decoder client"); - } - cctxt_itr = cctxt_itr->next; - } - - if (enc_clnt_present) { - if (req_perf_lvl >= VGA_PERF_LEVEL) { - mfc_freq = mfc_clk_freq_table[2]; - axi_freq = axi_clk_freq_table_enc[1]; - } else { - mfc_freq = mfc_clk_freq_table[0]; - axi_freq = axi_clk_freq_table_enc[0]; - } - VCDRES_MSG_MED("\n ENCODER: axi_freq = %u" - ", mfc_freq = %u, calc_mfc_freq = %u," - " req_perf_lvl = %u", axi_freq, - mfc_freq, calc_mfc_freq, - req_perf_lvl); - } else { - if (req_perf_lvl <= QVGA_PERF_LEVEL) { - mfc_freq = mfc_clk_freq_table[0]; - axi_freq = axi_clk_freq_table_dec[0]; - } else { - axi_freq = axi_clk_freq_table_dec[0]; - if (req_perf_lvl <= VGA_PERF_LEVEL) - mfc_freq = mfc_clk_freq_table[0]; - else if (req_perf_lvl <= WVGA_PERF_LEVEL) - mfc_freq = mfc_clk_freq_table[1]; - else { - mfc_freq = mfc_clk_freq_table[2]; - axi_freq = axi_clk_freq_table_dec[1]; - } - } - VCDRES_MSG_MED("\n DECODER: axi_freq = %u" - ", mfc_freq = %u, calc_mfc_freq = %u," - " req_perf_lvl = %u", axi_freq, - mfc_freq, calc_mfc_freq, - req_perf_lvl); - } - -#ifdef AXI_CLK_SCALING - if (req_perf_lvl != VCD_RESTRK_MIN_PERF_LEVEL) { - VCDRES_MSG_MED("\n %s(): Setting AXI freq to %u", - __func__, axi_freq); - clk_set_rate(ebi1_clk, axi_freq * 1000); - } -#endif - -#ifdef USE_RES_TRACKER - if (req_perf_lvl != VCD_RESTRK_MIN_PERF_LEVEL) { - VCDRES_MSG_MED("\n %s(): Setting MFC freq to %u", - __func__, mfc_freq); - if (!res_trk_sel_clk_rate(mfc_freq)) { - VCDRES_MSG_ERROR("%s(): res_trk_sel_clk_rate FAILED\n", - __func__); - *pn_set_perf_lvl = 0; - return false; - } - } -#endif - - *pn_set_perf_lvl = - res_trk_convert_freq_to_perf_lvl((u64) mfc_freq); - return true; -} - -u32 res_trk_get_curr_perf_level(u32 *pn_perf_lvl) -{ - unsigned long freq; - - if (!pn_perf_lvl) { - VCDRES_MSG_ERROR("%s(): pn_perf_lvl is NULL\n", - __func__); - return false; - } - VCDRES_MSG_LOW("clk_regime_msm_get_clk_freq_hz"); - if (!res_trk_get_clk_rate(&freq)) { - VCDRES_MSG_ERROR("%s(): res_trk_get_clk_rate FAILED\n", - __func__); - *pn_perf_lvl = 0; - return false; - } - - *pn_perf_lvl = res_trk_convert_freq_to_perf_lvl((u64) freq); - VCDRES_MSG_MED("%s(): freq = %lu, *pn_perf_lvl = %u", __func__, - freq, *pn_perf_lvl); - return true; -} - -u32 res_trk_download_firmware(void) -{ - const struct firmware *fw_boot = NULL; - const struct firmware *fw_mpg4_dec = NULL; - const struct firmware *fw_h263_dec = NULL; - const struct firmware *fw_h264_dec = NULL; - const struct firmware *fw_mpg4_enc = NULL; - const struct firmware *fw_h264_enc = NULL; - const struct firmware *fw_vc1_dec = NULL; - int rc = 0; - u32 status = true; - - VCDRES_MSG_HIGH("%s(): Request firmware download\n", - __func__); - mutex_lock(&resource_context.lock); - rc = request_firmware(&fw_boot, VIDC_BOOT_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_BOOT_FW, rc); - mutex_unlock(&resource_context.lock); - return false; - } - vidc_command_control_fw = (unsigned char *)fw_boot->data; - vidc_command_control_fw_size = (u32) fw_boot->size; - - rc = request_firmware(&fw_mpg4_dec, VIDC_MPG4_DEC_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_MPG4_DEC_FW, rc); - status = false; - goto boot_fw_free; - } - vidc_mpg4_dec_fw = (unsigned char *)fw_mpg4_dec->data; - vidc_mpg4_dec_fw_size = (u32) fw_mpg4_dec->size; - - - rc = request_firmware(&fw_h263_dec, VIDC_H263_DEC_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_H263_DEC_FW, rc); - status = false; - goto mp4dec_fw_free; - } - vidc_h263_dec_fw = (unsigned char *)fw_h263_dec->data; - vidc_h263_dec_fw_size = (u32) fw_h263_dec->size; - - rc = request_firmware(&fw_h264_dec, VIDC_H264_DEC_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_H264_DEC_FW, rc); - status = false; - goto h263dec_fw_free; - } - vidc_h264_dec_fw = (unsigned char *)fw_h264_dec->data; - vidc_h264_dec_fw_size = (u32) fw_h264_dec->size; - - rc = request_firmware(&fw_mpg4_enc, VIDC_MPG4_ENC_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_MPG4_ENC_FW, rc); - status = false; - goto h264dec_fw_free; - } - vidc_mpg4_enc_fw = (unsigned char *)fw_mpg4_enc->data; - vidc_mpg4_enc_fw_size = (u32) fw_mpg4_enc->size; - - rc = request_firmware(&fw_h264_enc, VIDC_H264_ENC_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_H264_ENC_FW, rc); - status = false; - goto mp4enc_fw_free; - } - vidc_h264_enc_fw = (unsigned char *)fw_h264_enc->data; - vidc_h264_enc_fw_size = (u32) fw_h264_enc->size; - - rc = request_firmware(&fw_vc1_dec, VIDC_VC1_DEC_FW, - resource_context.device); - if (rc) { - VCDRES_MSG_ERROR("request_firmware for %s error %d\n", - VIDC_VC1_DEC_FW, rc); - status = false; - goto h264enc_fw_free; - } - vidc_vc1_dec_fw = (unsigned char *)fw_vc1_dec->data; - vidc_vc1_dec_fw_size = (u32) fw_vc1_dec->size; - mutex_unlock(&resource_context.lock); - return status; - -h264enc_fw_free: - release_firmware(fw_h264_enc); -mp4enc_fw_free: - release_firmware(fw_mpg4_enc); -h264dec_fw_free: - release_firmware(fw_h264_dec); -h263dec_fw_free: - release_firmware(fw_h263_dec); -mp4dec_fw_free: - release_firmware(fw_mpg4_dec); -boot_fw_free: - release_firmware(fw_boot); - mutex_unlock(&resource_context.lock); - return false; -} - -static struct ion_client *res_trk_create_ion_client(void){ - struct ion_client *video_client; - VCDRES_MSG_LOW("%s", __func__); - video_client = msm_ion_client_create(-1, "video_client"); - if (IS_ERR_OR_NULL(video_client)) { - VCDRES_MSG_ERROR("%s: Unable to create ION client\n", __func__); - video_client = NULL; - } - return video_client; -} - -void res_trk_init(struct device *device, u32 irq) -{ - VCDRES_MSG_LOW("%s", __func__); - if (resource_context.device || resource_context.irq_num || - !device) { - VCDRES_MSG_ERROR("%s() Resource Tracker Init error\n", - __func__); - return; - } - memset(&resource_context, 0, sizeof(resource_context)); - mutex_init(&resource_context.lock); - resource_context.device = device; - resource_context.irq_num = irq; - resource_context.core_type = VCD_CORE_720P; - resource_context.regulator = regulator_get(NULL, "fs_mfc"); - resource_context.vidc_platform_data = - (struct msm_vidc_platform_data *) device->platform_data; - if (resource_context.vidc_platform_data) { - resource_context.memtype = - resource_context.vidc_platform_data->memtype; - VCDRES_MSG_LOW("%s(): resource_context.memtype = 0x%x", - __func__, (u32)resource_context.memtype); - if (resource_context.vidc_platform_data->enable_ion) { - resource_context.res_ion_client = - res_trk_create_ion_client(); - if (!(resource_context.res_ion_client)) { - VCDRES_MSG_ERROR("%s()ION createfail\n", - __func__); - return; - } - VCDRES_MSG_LOW("%s(): ion_client = 0x%x", __func__, - (u32)resource_context.res_ion_client); - } else { - VCDRES_MSG_ERROR("%s(): ION not disabled\n", - __func__); - } - } else { - resource_context.memtype = -1; - VCDRES_MSG_ERROR("%s(): vidc_platform_data is NULL", - __func__); - } -} - -u32 res_trk_get_core_type(void){ - return resource_context.core_type; -} - -u32 res_trk_get_enable_ion(void) -{ - if (resource_context.vidc_platform_data->enable_ion) - return 1; - else - return 0; -} - -struct ion_client *res_trk_get_ion_client(void) -{ - return resource_context.res_ion_client; -} - -u32 res_trk_get_mem_type(void) -{ - u32 mem_type = ION_HEAP(resource_context.memtype); - return mem_type; -} - -void res_trk_set_mem_type(enum ddl_mem_area mem_type) -{ - return; -} - -u32 res_trk_get_disable_fullhd(void) -{ - return 0; -} - -u32 res_trk_get_ion_flags(void) -{ - return 0; -} - -int res_trk_check_for_sec_session() -{ - return 0; -} - -void res_trk_secure_unset(void) -{ - return; -} - -void res_trk_secure_set(void) -{ - return; -} - -int res_trk_open_secure_session() -{ - return -EINVAL; -} - -int res_trk_close_secure_session() -{ - return 0; -} -u32 get_res_trk_perf_level(enum vcd_perf_level perf_level) -{ - return -ENOTSUPP; -} -u32 res_trk_is_cp_enabled(void) -{ - if (resource_context.vidc_platform_data->cp_enabled) - return 1; - else - return 0; -} -u32 res_trk_estimate_perf_level(u32 pn_perf_lvl) -{ - return 0; -} - diff --git a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.h b/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.h deleted file mode 100644 index e1781b68ad53eb526bca6b6d35164c9d87304096..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VIDEO_720P_RESOURCE_TRACKER_H_ -#define _VIDEO_720P_RESOURCE_TRACKER_H_ -#include -#include -#include "vcd_res_tracker_api.h" - -#define VCD_RESTRK_MIN_PERF_LEVEL 37900 -#define VCD_RESTRK_MAX_PERF_LEVEL 108000 -#define VCD_RESTRK_MIN_FREQ_POINT 61440000 -#define VCD_RESTRK_MAX_FREQ_POINT 170667000 -#define VCD_RESTRK_HZ_PER_1000_PERFLVL 1580250 - -struct res_trk_context { - struct device *device; - u32 irq_num; - struct mutex lock; - struct clk *hclk; - struct clk *hclk_div2; - struct clk *pclk; - unsigned long hclk_rate; - unsigned int clock_enabled; - unsigned int rail_enabled; - struct regulator *regulator; - struct msm_vidc_platform_data *vidc_platform_data; - u32 core_type; - int memtype; - u32 secure_session; - struct ion_client *res_ion_client; - enum ddl_mem_area res_mem_type; -}; - -#if DEBUG - -#define VCDRES_MSG_LOW(xx_fmt...) printk(KERN_INFO "\n\t* " xx_fmt) -#define VCDRES_MSG_MED(xx_fmt...) printk(KERN_INFO "\n * " xx_fmt) - -#else - -#define VCDRES_MSG_LOW(xx_fmt...) -#define VCDRES_MSG_MED(xx_fmt...) - -#endif - -#define VCDRES_MSG_HIGH(xx_fmt...) printk(KERN_WARNING "\n" xx_fmt) -#define VCDRES_MSG_ERROR(xx_fmt...) printk(KERN_ERR "\n err: " xx_fmt) -#define VCDRES_MSG_FATAL(xx_fmt...) printk(KERN_ERR "\n " xx_fmt) - -#endif diff --git a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker_api.h b/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker_api.h deleted file mode 100644 index 537f3c80ad19308a92670fd51f3d46e58dfe2462..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/720p/resource_tracker/vcd_res_tracker_api.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VIDEO_720P_RESOURCE_TRACKER_API_H_ -#define _VIDEO_720P_RESOURCE_TRACKER_API_H_ - -#include "vcd_core.h" -#include "vcd_ddl.h" - -void res_trk_init(struct device *device, u32 irq); -u32 res_trk_power_up(void); -u32 res_trk_power_down(void); -u32 res_trk_enable_clocks(void); -u32 res_trk_disable_clocks(void); -u32 res_trk_get_max_perf_level(u32 *pn_max_perf_lvl); -u32 res_trk_set_perf_level(u32 req_perf_lvl, u32 *pn_set_perf_lvl, - struct vcd_dev_ctxt *dev_ctxt); -u32 res_trk_get_curr_perf_level(u32 *pn_perf_lvl); -u32 res_trk_download_firmware(void); -u32 res_trk_get_core_type(void); -u32 res_trk_get_mem_type(void); -u32 res_trk_get_disable_fullhd(void); -u32 res_trk_get_ion_flags(void); -u32 res_trk_get_enable_ion(void); -u32 res_trk_is_cp_enabled(void); -struct ion_client *res_trk_get_ion_client(void); -void res_trk_set_mem_type(enum ddl_mem_area mem_type); -int res_trk_check_for_sec_session(void); -int res_trk_open_secure_session(void); -int res_trk_close_secure_session(void); -void res_trk_secure_set(void); -void res_trk_secure_unset(void); -u32 get_res_trk_perf_level(enum vcd_perf_level perf_level); -u32 res_trk_estimate_perf_level(u32 pn_perf_lvl); -#endif diff --git a/drivers/video/msm/vidc/Makefile b/drivers/video/msm/vidc/Makefile index af41f181878e489bc091287131842ba24f92cca5..18a113aa8497c5374c9cf71a761dcc97d658b9c0 100644 --- a/drivers/video/msm/vidc/Makefile +++ b/drivers/video/msm/vidc/Makefile @@ -15,48 +15,9 @@ EXTRA_CFLAGS += -Idrivers/video/msm/vidc/common/init obj-$(CONFIG_MSM_VIDC) += vidc.o -vidc-objs := common/init/vidc_init.o \ - common/vcd/vcd_api.o \ - common/vcd/vcd_power_sm.o \ - common/vcd/vcd_client_sm.o \ - common/vcd/vcd_device_sm.o \ - common/vcd/vcd_scheduler.o \ - common/vcd/vcd_sub.o \ - -ifdef CONFIG_MSM_VIDC_720P -vidc-objs += 720p/ddl/vcd_ddl_firmware.o \ - 720p/ddl/vcd_ddl_metadata.o \ - 720p/ddl/vidc.o \ - 720p/ddl/vcd_ddl_utils.o \ - 720p/ddl/vcd_ddl.o \ - 720p/ddl/vcd_ddl_helper.o \ - 720p/ddl/vcd_ddl_interrupt_handler.o \ - 720p/ddl/vcd_ddl_hal.o \ - 720p/ddl/vcd_ddl_properties.o \ - 720p/resource_tracker/vcd_res_tracker.o \ - 720p/ddl/vcd_ddl_errors.o -endif - -ifdef CONFIG_MSM_VIDC_1080P -vidc-objs += 1080p/ddl/vcd_ddl_helper.o \ - 1080p/ddl/vcd_ddl_utils.o \ - 1080p/ddl/vcd_ddl_interrupt_handler.o \ - 1080p/ddl/vcd_ddl_properties.o \ - 1080p/ddl/vcd_ddl_errors.o \ - 1080p/ddl/vcd_ddl_shared_mem.o \ - 1080p/ddl/vidc.o \ - 1080p/ddl/vidc_pix_cache.o \ - 1080p/ddl/vcd_ddl_vidc.o \ - 1080p/ddl/vcd_ddl.o \ - 1080p/ddl/vcd_ddl_metadata.o \ - 1080p/resource_tracker/vcd_res_tracker.o -endif obj-$(CONFIG_MSM_VIDC_VDEC) += vidc_vdec.o -vidc_vdec-objs := common/dec/vdec.o obj-$(CONFIG_MSM_VIDC_VENC) += vidc_venc.o -vidc_venc-objs := common/enc/venc.o \ - common/enc/venc_internal.o diff --git a/drivers/video/msm/vidc/common/dec/vdec.c b/drivers/video/msm/vidc/common/dec/vdec.c deleted file mode 100644 index 081e7061a45d15a9b4cf96a054926222f8a8f8ab..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/dec/vdec.c +++ /dev/null @@ -1,2691 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include "vcd_res_tracker_api.h" -#include "vdec_internal.h" - - - -#define DBG(x...) pr_debug(x) -#define INFO(x...) pr_info(x) -#define ERR(x...) pr_err(x) - -#define VID_DEC_NAME "msm_vidc_dec" - -static char *node_name[2] = {"", "_sec"}; -static struct vid_dec_dev *vid_dec_device_p; -static dev_t vid_dec_dev_num; -static struct class *vid_dec_class; - -static s32 vid_dec_get_empty_client_index(void) -{ - u32 i, found = false; - - for (i = 0; i < VIDC_MAX_NUM_CLIENTS; i++) { - if (!vid_dec_device_p->vdec_clients[i].vcd_handle) { - found = true; - break; - } - } - if (!found) { - ERR("%s():ERROR No space for new client\n", __func__); - return -ENOMEM; - } else { - DBG("%s(): available client index = %u\n", __func__, i); - return i; - } -} - -u32 vid_dec_get_status(u32 status) -{ - u32 vdec_status; - - switch (status) { - case VCD_ERR_SEQHDR_PARSE_FAIL: - case VCD_ERR_BITSTREAM_ERR: - vdec_status = VDEC_S_INPUT_BITSTREAM_ERR; - break; - case VCD_S_SUCCESS: - vdec_status = VDEC_S_SUCCESS; - break; - case VCD_ERR_FAIL: - vdec_status = VDEC_S_EFAIL; - break; - case VCD_ERR_ALLOC_FAIL: - vdec_status = VDEC_S_ENOSWRES; - break; - case VCD_ERR_ILLEGAL_OP: - vdec_status = VDEC_S_EINVALCMD; - break; - case VCD_ERR_ILLEGAL_PARM: - vdec_status = VDEC_S_EBADPARAM; - break; - case VCD_ERR_BAD_POINTER: - case VCD_ERR_BAD_HANDLE: - vdec_status = VDEC_S_EFATAL; - break; - case VCD_ERR_NOT_SUPPORTED: - vdec_status = VDEC_S_ENOTSUPP; - break; - case VCD_ERR_BAD_STATE: - vdec_status = VDEC_S_EINVALSTATE; - break; - case VCD_ERR_BUSY: - vdec_status = VDEC_S_BUSY; - break; - case VCD_ERR_MAX_CLIENT: - vdec_status = VDEC_S_ENOHWRES; - break; - default: - vdec_status = VDEC_S_EFAIL; - break; - } - - return vdec_status; -} - -static void vid_dec_notify_client(struct video_client_ctx *client_ctx) -{ - if (client_ctx) - complete(&client_ctx->event); -} - -void vid_dec_vcd_open_done(struct video_client_ctx *client_ctx, - struct vcd_handle_container *handle_container) -{ - DBG("vid_dec_vcd_open_done\n"); - - if (client_ctx) { - if (handle_container) - client_ctx->vcd_handle = handle_container->handle; - else - ERR("%s(): ERROR. handle_container is NULL\n", - __func__); - - vid_dec_notify_client(client_ctx); - } else - ERR("%s(): ERROR. client_ctx is NULL\n", __func__); -} - -static void vid_dec_handle_field_drop(struct video_client_ctx *client_ctx, - u32 event, u32 status, int64_t time_stamp) -{ - struct vid_dec_msg *vdec_msg; - - if (!client_ctx) { - ERR("%s() NULL pointer\n", __func__); - return; - } - - vdec_msg = kzalloc(sizeof(struct vid_dec_msg), GFP_KERNEL); - if (!vdec_msg) { - ERR("%s(): cannot allocate vid_dec_msg " - " buffer\n", __func__); - return; - } - vdec_msg->vdec_msg_info.status_code = vid_dec_get_status(status); - if (event == VCD_EVT_IND_INFO_FIELD_DROPPED) { - vdec_msg->vdec_msg_info.msgcode = - VDEC_MSG_EVT_INFO_FIELD_DROPPED; - vdec_msg->vdec_msg_info.msgdata.output_frame.time_stamp - = time_stamp; - DBG("Send FIELD_DROPPED message to client = %p\n", client_ctx); - } else { - ERR("vid_dec_input_frame_done(): invalid event type: " - "%d\n", event); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_INVALID; - } - vdec_msg->vdec_msg_info.msgdatasize = - sizeof(struct vdec_output_frameinfo); - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&vdec_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - wake_up(&client_ctx->msg_wait); -} - -static void vid_dec_input_frame_done(struct video_client_ctx *client_ctx, - u32 event, u32 status, - struct vcd_frame_data *vcd_frame_data) -{ - struct vid_dec_msg *vdec_msg; - - if (!client_ctx || !vcd_frame_data) { - ERR("vid_dec_input_frame_done() NULL pointer\n"); - return; - } - - kfree(vcd_frame_data->desc_buf); - vcd_frame_data->desc_buf = NULL; - vcd_frame_data->desc_size = 0; - - vdec_msg = kzalloc(sizeof(struct vid_dec_msg), GFP_KERNEL); - if (!vdec_msg) { - ERR("vid_dec_input_frame_done(): cannot allocate vid_dec_msg " - " buffer\n"); - return; - } - - vdec_msg->vdec_msg_info.status_code = vid_dec_get_status(status); - - if (event == VCD_EVT_RESP_INPUT_DONE) { - vdec_msg->vdec_msg_info.msgcode = - VDEC_MSG_RESP_INPUT_BUFFER_DONE; - DBG("Send INPUT_DON message to client = %p\n", client_ctx); - - } else if (event == VCD_EVT_RESP_INPUT_FLUSHED) { - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_RESP_INPUT_FLUSHED; - DBG("Send INPUT_FLUSHED message to client = %p\n", client_ctx); - } else { - ERR("vid_dec_input_frame_done(): invalid event type: " - "%d\n", event); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_INVALID; - } - - vdec_msg->vdec_msg_info.msgdata.input_frame_clientdata = - (void *)vcd_frame_data->frm_clnt_data; - vdec_msg->vdec_msg_info.msgdatasize = sizeof(void *); - - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&vdec_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - wake_up(&client_ctx->msg_wait); -} - -static void vid_dec_output_frame_done(struct video_client_ctx *client_ctx, - u32 event, u32 status, - struct vcd_frame_data *vcd_frame_data) -{ - struct vid_dec_msg *vdec_msg; - - unsigned long kernel_vaddr = 0, phy_addr = 0, user_vaddr = 0; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - enum vdec_picture pic_type; - u32 ion_flag = 0; - struct ion_handle *buff_handle = NULL; - struct vdec_output_frameinfo *output_frame; - - if (!client_ctx || !vcd_frame_data) { - ERR("vid_dec_input_frame_done() NULL pointer\n"); - return; - } - - vdec_msg = kzalloc(sizeof(struct vid_dec_msg), GFP_KERNEL); - if (!vdec_msg) { - ERR("vid_dec_input_frame_done(): cannot allocate vid_dec_msg " - " buffer\n"); - return; - } - - vdec_msg->vdec_msg_info.status_code = vid_dec_get_status(status); - - if (event == VCD_EVT_RESP_OUTPUT_DONE) - vdec_msg->vdec_msg_info.msgcode = - VDEC_MSG_RESP_OUTPUT_BUFFER_DONE; - else if (event == VCD_EVT_RESP_OUTPUT_FLUSHED) - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_RESP_OUTPUT_FLUSHED; - else { - ERR("QVD: vid_dec_output_frame_done invalid cmd type: " - "%d\n", event); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_INVALID; - } - - kernel_vaddr = (unsigned long)vcd_frame_data->virtual; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - false, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index) || - (vcd_frame_data->flags & VCD_FRAME_FLAG_EOS)) { - - if (res_trk_check_for_sec_session() && - event == VCD_EVT_RESP_OUTPUT_DONE) { - DBG("Buffer Index = %d", buffer_index); - if (buffer_index != -1) { - if (client_ctx->meta_addr_table[buffer_index]. - kernel_vir_addr_iommu && - client_ctx-> - meta_addr_table[buffer_index]. - kernel_vir_addr) { - - memcpy(client_ctx-> - meta_addr_table[buffer_index]. - kernel_vir_addr_iommu, - client_ctx-> - meta_addr_table[buffer_index]. - kernel_vir_addr, - client_ctx->meta_buf_size); - DBG("Copying Meta Buffer from "\ - "secure memory" - "kernel_virt_iommu = %p " - "kernel_virt = %p", - client_ctx-> - meta_addr_table[buffer_index]. - kernel_vir_addr_iommu, - client_ctx-> - meta_addr_table[buffer_index]. - kernel_vir_addr); - } - } - } - - /* Buffer address in user space */ - vdec_msg->vdec_msg_info.msgdata.output_frame.bufferaddr = - (u8 *) user_vaddr; - /* Data length */ - vdec_msg->vdec_msg_info.msgdata.output_frame.len = - vcd_frame_data->data_len; - vdec_msg->vdec_msg_info.msgdata.output_frame.flags = - vcd_frame_data->flags; - /* Timestamp pass-through from input frame */ - vdec_msg->vdec_msg_info.msgdata.output_frame.time_stamp = - vcd_frame_data->time_stamp; - /* Output frame client data */ - vdec_msg->vdec_msg_info.msgdata.output_frame.client_data = - (void *)vcd_frame_data->frm_clnt_data; - /* Associated input frame client data */ - vdec_msg->vdec_msg_info.msgdata.output_frame. - input_frame_clientdata = - (void *)vcd_frame_data->ip_frm_tag; - /* Decoded picture width and height */ - vdec_msg->vdec_msg_info.msgdata.output_frame.framesize. - bottom = - vcd_frame_data->dec_op_prop.disp_frm.bottom; - vdec_msg->vdec_msg_info.msgdata.output_frame.framesize.left = - vcd_frame_data->dec_op_prop.disp_frm.left; - vdec_msg->vdec_msg_info.msgdata.output_frame.framesize.right = - vcd_frame_data->dec_op_prop.disp_frm.right; - vdec_msg->vdec_msg_info.msgdata.output_frame.framesize.top = - vcd_frame_data->dec_op_prop.disp_frm.top; - if (vcd_frame_data->interlaced) { - vdec_msg->vdec_msg_info.msgdata. - output_frame.interlaced_format = - VDEC_InterlaceInterleaveFrameTopFieldFirst; - } else { - vdec_msg->vdec_msg_info.msgdata. - output_frame.interlaced_format = - VDEC_InterlaceFrameProgressive; - } - /* Decoded picture type */ - switch (vcd_frame_data->frame) { - case VCD_FRAME_I: - pic_type = PICTURE_TYPE_I; - break; - case VCD_FRAME_P: - pic_type = PICTURE_TYPE_P; - break; - case VCD_FRAME_B: - pic_type = PICTURE_TYPE_B; - break; - case VCD_FRAME_NOTCODED: - pic_type = PICTURE_TYPE_SKIP; - break; - case VCD_FRAME_IDR: - pic_type = PICTURE_TYPE_IDR; - break; - default: - pic_type = PICTURE_TYPE_UNKNOWN; - } - vdec_msg->vdec_msg_info.msgdata.output_frame.pic_type = - pic_type; - output_frame = &vdec_msg->vdec_msg_info.msgdata.output_frame; - output_frame->aspect_ratio_info.aspect_ratio = - vcd_frame_data->aspect_ratio_info.aspect_ratio; - output_frame->aspect_ratio_info.par_width = - vcd_frame_data->aspect_ratio_info.par_width; - output_frame->aspect_ratio_info.par_height = - vcd_frame_data->aspect_ratio_info.par_height; - vdec_msg->vdec_msg_info.msgdatasize = - sizeof(struct vdec_output_frameinfo); - } else { - ERR("vid_dec_output_frame_done UVA can not be found\n"); - vdec_msg->vdec_msg_info.status_code = VDEC_S_EFATAL; - } - if (vcd_frame_data->data_len > 0) { - ion_flag = vidc_get_fd_info(client_ctx, BUFFER_TYPE_OUTPUT, - pmem_fd, kernel_vaddr, buffer_index, - &buff_handle); - if (ion_flag == ION_FLAG_CACHED && buff_handle) { - DBG("%s: Cache invalidate: vaddr (%p), "\ - "size %u\n", __func__, - (void *)kernel_vaddr, - vcd_frame_data->alloc_len); - msm_ion_do_cache_op(client_ctx->user_ion_client, - buff_handle, - (unsigned long *) kernel_vaddr, - (unsigned long)vcd_frame_data->\ - alloc_len, - ION_IOC_INV_CACHES); - } - } - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&vdec_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - wake_up(&client_ctx->msg_wait); -} - -static void vid_dec_lean_event(struct video_client_ctx *client_ctx, - u32 event, u32 status) -{ - struct vid_dec_msg *vdec_msg; - - if (!client_ctx) { - ERR("%s(): !client_ctx pointer\n", __func__); - return; - } - - vdec_msg = kzalloc(sizeof(struct vid_dec_msg), GFP_KERNEL); - if (!vdec_msg) { - ERR("%s(): cannot allocate vid_dec_msg buffer\n", __func__); - return; - } - - vdec_msg->vdec_msg_info.status_code = vid_dec_get_status(status); - - switch (event) { - case VCD_EVT_IND_OUTPUT_RECONFIG: - DBG("msm_vidc_dec: Sending VDEC_MSG_EVT_CONFIG_CHANGED" - " to client"); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_EVT_CONFIG_CHANGED; - break; - case VCD_EVT_IND_RESOURCES_LOST: - DBG("msm_vidc_dec: Sending VDEC_EVT_RESOURCES_LOST" - " to client"); - vdec_msg->vdec_msg_info.msgcode = VDEC_EVT_RESOURCES_LOST; - break; - case VCD_EVT_RESP_FLUSH_INPUT_DONE: - DBG("msm_vidc_dec: Sending VDEC_MSG_RESP_FLUSH_INPUT_DONE" - " to client"); - vdec_msg->vdec_msg_info.msgcode = - VDEC_MSG_RESP_FLUSH_INPUT_DONE; - break; - case VCD_EVT_RESP_FLUSH_OUTPUT_DONE: - DBG("msm_vidc_dec: Sending VDEC_MSG_RESP_FLUSH_OUTPUT_DONE" - " to client"); - vdec_msg->vdec_msg_info.msgcode = - VDEC_MSG_RESP_FLUSH_OUTPUT_DONE; - break; - case VCD_EVT_IND_HWERRFATAL: - DBG("msm_vidc_dec: Sending VDEC_MSG_EVT_HW_ERROR" - " to client"); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_EVT_HW_ERROR; - break; - case VCD_EVT_RESP_START: - DBG("msm_vidc_dec: Sending VDEC_MSG_RESP_START_DONE" - " to client"); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_RESP_START_DONE; - break; - case VCD_EVT_RESP_STOP: - DBG("msm_vidc_dec: Sending VDEC_MSG_RESP_STOP_DONE" - " to client"); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_RESP_STOP_DONE; - break; - case VCD_EVT_RESP_PAUSE: - DBG("msm_vidc_dec: Sending VDEC_MSG_RESP_PAUSE_DONE" - " to client"); - vdec_msg->vdec_msg_info.msgcode = VDEC_MSG_RESP_PAUSE_DONE; - break; - case VCD_EVT_IND_INFO_OUTPUT_RECONFIG: - DBG("msm_vidc_dec: Sending VDEC_MSG_EVT_INFO_CONFIG_CHANGED" - " to client"); - vdec_msg->vdec_msg_info.msgcode = - VDEC_MSG_EVT_INFO_CONFIG_CHANGED; - break; - default: - ERR("%s() : unknown event type\n", __func__); - break; - } - - vdec_msg->vdec_msg_info.msgdatasize = 0; - if (client_ctx->stop_sync_cb && - (event == VCD_EVT_RESP_STOP || event == VCD_EVT_IND_HWERRFATAL)) { - client_ctx->stop_sync_cb = false; - complete(&client_ctx->event); - kfree(vdec_msg); - return; - } - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&vdec_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - wake_up(&client_ctx->msg_wait); -} - - -void vid_dec_vcd_cb(u32 event, u32 status, - void *info, size_t sz, void *handle, void *const client_data) -{ - struct video_client_ctx *client_ctx = - (struct video_client_ctx *)client_data; - - DBG("Entering %s()\n", __func__); - - if (!client_ctx) { - ERR("%s(): client_ctx is NULL\n", __func__); - return; - } - - client_ctx->event_status = status; - - switch (event) { - case VCD_EVT_RESP_OPEN: - vid_dec_vcd_open_done(client_ctx, - (struct vcd_handle_container *) - info); - break; - case VCD_EVT_RESP_INPUT_DONE: - case VCD_EVT_RESP_INPUT_FLUSHED: - vid_dec_input_frame_done(client_ctx, event, status, - (struct vcd_frame_data *)info); - break; - case VCD_EVT_IND_INFO_FIELD_DROPPED: - if (info) - vid_dec_handle_field_drop(client_ctx, event, - status, *((int64_t *)info)); - else - pr_err("Wrong Payload for Field dropped\n"); - break; - case VCD_EVT_RESP_OUTPUT_DONE: - case VCD_EVT_RESP_OUTPUT_FLUSHED: - vid_dec_output_frame_done(client_ctx, event, status, - (struct vcd_frame_data *)info); - break; - case VCD_EVT_RESP_PAUSE: - case VCD_EVT_RESP_STOP: - case VCD_EVT_RESP_FLUSH_INPUT_DONE: - case VCD_EVT_RESP_FLUSH_OUTPUT_DONE: - case VCD_EVT_IND_OUTPUT_RECONFIG: - case VCD_EVT_IND_HWERRFATAL: - case VCD_EVT_IND_RESOURCES_LOST: - case VCD_EVT_IND_INFO_OUTPUT_RECONFIG: - vid_dec_lean_event(client_ctx, event, status); - break; - case VCD_EVT_RESP_START: - if (!client_ctx->seq_header_set) - vid_dec_lean_event(client_ctx, event, status); - else - vid_dec_notify_client(client_ctx); - break; - default: - ERR("%s() : Error - Invalid event type =%u\n", __func__, - event); - break; - } -} - -static u32 vid_dec_set_codec(struct video_client_ctx *client_ctx, - enum vdec_codec *vdec_codec) -{ - u32 result = true; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_codec codec; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !vdec_codec) - return false; - - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - - switch (*vdec_codec) { - case VDEC_CODECTYPE_MPEG4: - codec.codec = VCD_CODEC_MPEG4; - break; - case VDEC_CODECTYPE_H264: - codec.codec = VCD_CODEC_H264; - break; - case VDEC_CODECTYPE_DIVX_3: - codec.codec = VCD_CODEC_DIVX_3; - break; - case VDEC_CODECTYPE_DIVX_4: - codec.codec = VCD_CODEC_DIVX_4; - break; - case VDEC_CODECTYPE_DIVX_5: - codec.codec = VCD_CODEC_DIVX_5; - break; - case VDEC_CODECTYPE_DIVX_6: - codec.codec = VCD_CODEC_DIVX_6; - break; - case VDEC_CODECTYPE_XVID: - codec.codec = VCD_CODEC_XVID; - break; - case VDEC_CODECTYPE_H263: - codec.codec = VCD_CODEC_H263; - break; - case VDEC_CODECTYPE_MPEG2: - codec.codec = VCD_CODEC_MPEG2; - break; - case VDEC_CODECTYPE_VC1: - codec.codec = VCD_CODEC_VC1; - break; - case VDEC_CODECTYPE_VC1_RCV: - codec.codec = VCD_CODEC_VC1_RCV; - break; - default: - result = false; - break; - } - - if (result) { - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &codec); - if (vcd_status) - result = false; - } - return result; -} - -static u32 vid_dec_set_output_format(struct video_client_ctx *client_ctx, - enum vdec_output_fromat *output_format) -{ - u32 result = true; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_buffer_format vcd_prop_buffer_format; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !output_format) - return false; - - vcd_property_hdr.prop_id = VCD_I_BUFFER_FORMAT;; - vcd_property_hdr.sz = - sizeof(struct vcd_property_buffer_format); - - switch (*output_format) { - case VDEC_YUV_FORMAT_NV12: - vcd_prop_buffer_format.buffer_format = VCD_BUFFER_FORMAT_NV12; - break; - case VDEC_YUV_FORMAT_TILE_4x2: - vcd_prop_buffer_format.buffer_format = - VCD_BUFFER_FORMAT_TILE_4x2; - break; - default: - result = false; - break; - } - - if (result) - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, - &vcd_prop_buffer_format); - - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_set_frame_resolution(struct video_client_ctx *client_ctx, - struct vdec_picsize *video_resoultion) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_size frame_resolution; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !video_resoultion) - return false; - - vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; - vcd_property_hdr.sz = sizeof(struct vcd_property_frame_size); - frame_resolution.width = video_resoultion->frame_width; - frame_resolution.height = video_resoultion->frame_height; - frame_resolution.stride = video_resoultion->stride; - frame_resolution.scan_lines = video_resoultion->scan_lines; - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &frame_resolution); - - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_set_turbo_clk(struct video_client_ctx *client_ctx) -{ - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - u32 dummy = 0; - - if (!client_ctx) - return false; - vcd_property_hdr.prop_id = VCD_I_SET_TURBO_CLK; - vcd_property_hdr.sz = sizeof(struct vcd_property_frame_size); - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &dummy); - - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_get_frame_resolution(struct video_client_ctx *client_ctx, - struct vdec_picsize *video_resoultion) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_size frame_resolution; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !video_resoultion) - return false; - - vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; - vcd_property_hdr.sz = sizeof(struct vcd_property_frame_size); - - vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - &frame_resolution); - - video_resoultion->frame_width = frame_resolution.width; - video_resoultion->frame_height = frame_resolution.height; - video_resoultion->scan_lines = frame_resolution.scan_lines; - video_resoultion->stride = frame_resolution.stride; - - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_get_progressive_only(struct video_client_ctx *client_ctx, - u32 *progressive_only) -{ - struct vcd_property_hdr vcd_property_hdr; - if (!client_ctx || !progressive_only) - return false; - vcd_property_hdr.prop_id = VCD_I_PROGRESSIVE_ONLY; - vcd_property_hdr.sz = sizeof(u32); - if (vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - progressive_only)) - return false; - else - return true; -} - -static u32 vid_dec_get_disable_dmx_support(struct video_client_ctx *client_ctx, - u32 *disable_dmx) -{ - - struct vcd_property_hdr vcd_property_hdr; - if (!client_ctx || !disable_dmx) - return false; - vcd_property_hdr.prop_id = VCD_I_DISABLE_DMX_SUPPORT; - vcd_property_hdr.sz = sizeof(u32); - if (vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - disable_dmx)) - return false; - else - return true; -} -static u32 vid_dec_get_disable_dmx(struct video_client_ctx *client_ctx, - u32 *disable_dmx) -{ - - struct vcd_property_hdr vcd_property_hdr; - if (!client_ctx || !disable_dmx) - return false; - vcd_property_hdr.prop_id = VCD_I_DISABLE_DMX; - vcd_property_hdr.sz = sizeof(u32); - if (vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, - disable_dmx)) - return false; - else - return true; -} - -static u32 vid_dec_set_disable_dmx(struct video_client_ctx *client_ctx) -{ - - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_disable_dmx; - if (!client_ctx) - return false; - vcd_property_hdr.prop_id = VCD_I_DISABLE_DMX; - vcd_property_hdr.sz = sizeof(u32); - vcd_disable_dmx = true; - DBG("%s() : Setting Disable DMX: %d\n", - __func__, vcd_disable_dmx); - - if (vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, - &vcd_disable_dmx)) - return false; - else - return true; -} - -static u32 vid_dec_set_picture_order(struct video_client_ctx *client_ctx, - u32 *picture_order) -{ - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL, vcd_picture_order, ret = true; - if (!client_ctx || !picture_order) - return false; - vcd_property_hdr.prop_id = VCD_I_OUTPUT_ORDER; - vcd_property_hdr.sz = sizeof(u32); - if (*picture_order == VDEC_ORDER_DISPLAY) - vcd_picture_order = VCD_DEC_ORDER_DISPLAY; - else if (*picture_order == VDEC_ORDER_DECODE) - vcd_picture_order = VCD_DEC_ORDER_DECODE; - else - ret = false; - if (ret) { - DBG("%s() : Setting output picture order: %d\n", - __func__, vcd_picture_order); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_picture_order); - if (vcd_status != VCD_S_SUCCESS) - ret = false; - } - return ret; -} - -static u32 vid_dec_set_frame_rate(struct video_client_ctx *client_ctx, - struct vdec_framerate *frame_rate) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_rate vcd_frame_rate; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !frame_rate) - return false; - - vcd_property_hdr.prop_id = VCD_I_FRAME_RATE; - vcd_property_hdr.sz = sizeof(struct vcd_property_frame_rate); - vcd_frame_rate.fps_numerator = frame_rate->fps_numerator; - vcd_frame_rate.fps_denominator = frame_rate->fps_denominator; - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_frame_rate); - - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_set_extradata(struct video_client_ctx *client_ctx, - u32 *extradata_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_meta_data_enable vcd_meta_data; - u32 vcd_status = VCD_ERR_FAIL; - if (!client_ctx || !extradata_flag) - return false; - vcd_property_hdr.prop_id = VCD_I_METADATA_ENABLE; - vcd_property_hdr.sz = sizeof(struct vcd_property_meta_data_enable); - vcd_meta_data.meta_data_enable_flag = *extradata_flag; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_meta_data); - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_set_idr_only_decoding(struct video_client_ctx *client_ctx) -{ - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - u32 enable = true; - if (!client_ctx) - return false; - vcd_property_hdr.prop_id = VCD_I_DEC_PICTYPE; - vcd_property_hdr.sz = sizeof(u32); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &enable); - if (vcd_status) - return false; - return true; -} -static u32 vid_dec_set_meta_buffers(struct video_client_ctx *client_ctx, - struct vdec_meta_buffers *meta_buffers) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_meta_buffer *vcd_meta_buffer = NULL; - u32 vcd_status = VCD_ERR_FAIL; - u32 len = 0, len_iommu = 0, buf_size = 0; - int rc = 0; - unsigned long ionflag = 0, ionflag_iommu = 0; - unsigned long buffer_size = 0, buffer_size_iommu = 0; - unsigned long iova = 0, iova_iommu = 0; - int index = -1, num_buffers = 0; - u8 *ker_vir_addr = NULL, *ker_vir_addr_iommu = NULL; - - if (!client_ctx || !meta_buffers) - return false; - - vcd_property_hdr.prop_id = VCD_I_SET_EXT_METABUFFER; - vcd_property_hdr.sz = sizeof(struct vcd_property_meta_buffer); - vcd_meta_buffer = &client_ctx->vcd_meta_buffer; - - memset(&client_ctx->vcd_meta_buffer, 0, - sizeof(struct vcd_property_meta_buffer)); - vcd_meta_buffer->size = meta_buffers->size; - vcd_meta_buffer->count = meta_buffers->count; - vcd_meta_buffer->pmem_fd = meta_buffers->pmem_fd; - vcd_meta_buffer->offset = meta_buffers->offset; - vcd_meta_buffer->pmem_fd_iommu = meta_buffers->pmem_fd_iommu; - - if (!vcd_get_ion_status()) { - pr_err("PMEM Not available\n"); - return false; - } else { - client_ctx->meta_buffer_ion_handle = ion_import_dma_buf( - client_ctx->user_ion_client, - vcd_meta_buffer->pmem_fd); - if (IS_ERR_OR_NULL(client_ctx->meta_buffer_ion_handle)) { - ERR("%s(): get_ION_handle failed\n", __func__); - goto import_ion_error; - } - rc = ion_handle_get_flags(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle, - &ionflag); - if (rc) { - ERR("%s():get_ION_flags fail\n", - __func__); - goto import_ion_error; - } - vcd_meta_buffer->kernel_virtual_addr = - (u8 *) ion_map_kernel( - client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle); - if (!vcd_meta_buffer->kernel_virtual_addr) { - ERR("%s(): get_ION_kernel virtual addr failed\n", - __func__); - goto import_ion_error; - } - if (res_trk_check_for_sec_session() || - (res_trk_get_core_type() == (u32)VCD_CORE_720P)) { - rc = ion_phys(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle, - (ion_phys_addr_t *) (&(vcd_meta_buffer-> - physical_addr)), &len); - if (rc) { - ERR("%s():get_ION_kernel physical addr fail\n", - __func__); - goto ion_map_error; - } - vcd_meta_buffer->client_data = NULL; - vcd_meta_buffer->dev_addr = (u8 *) - vcd_meta_buffer->physical_addr; - } else { - rc = ion_map_iommu(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle, - VIDEO_DOMAIN, VIDEO_MAIN_POOL, - SZ_4K, 0, (dma_addr_t *)&iova, - (unsigned long *)&buffer_size, - 0, 0); - if (rc || !iova) { - ERR("%s():get_ION_kernel physical addr fail,"\ - " rc = %d iova = 0x%lx\n", - __func__, rc, iova); - goto ion_map_error; - } - vcd_meta_buffer->physical_addr = (u8 *) iova; - vcd_meta_buffer->client_data = NULL; - vcd_meta_buffer->dev_addr = (u8 *) iova; - } - - client_ctx->meta_buffer_iommu_ion_handle = ion_import_dma_buf( - client_ctx->user_ion_client, - vcd_meta_buffer->pmem_fd_iommu); - if (IS_ERR_OR_NULL(client_ctx->meta_buffer_iommu_ion_handle)) { - ERR("%s(): get_ION_handle failed\n", __func__); - goto import_ion_error; - } - rc = ion_handle_get_flags(client_ctx->user_ion_client, - client_ctx-> - meta_buffer_iommu_ion_handle, - &ionflag_iommu); - if (rc) { - ERR("%s():get_ION_flags fail\n", - __func__); - goto import_ion_error; - } - vcd_meta_buffer->kernel_virt_addr_iommu = - (u8 *) ion_map_kernel( - client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle); - if (!vcd_meta_buffer->kernel_virt_addr_iommu) { - ERR("%s(): get_ION_kernel virtual addr failed\n", - __func__); - goto import_ion_error; - } - if (res_trk_get_core_type() == (u32)VCD_CORE_720P) { - rc = ion_phys(client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle, - (dma_addr_t *) (&(vcd_meta_buffer-> - physical_addr_iommu)), &len_iommu); - if (rc) { - ERR("%s():get_ION_kernel physical addr fail\n", - __func__); - goto ion_map_error_iommu; - } - vcd_meta_buffer->client_data_iommu = NULL; - vcd_meta_buffer->dev_addr_iommu = (u8 *) - vcd_meta_buffer->physical_addr_iommu; - } else { - rc = ion_map_iommu(client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle, - VIDEO_DOMAIN, VIDEO_MAIN_POOL, - SZ_4K, 0, (dma_addr_t *)&iova_iommu, - (unsigned long *)&buffer_size_iommu, - 0, 0); - if (rc || !iova_iommu) { - ERR("%s():get_ION_kernel physical addr fail, "\ - "rc = %d iova = 0x%lx\n", - __func__, rc, iova); - goto ion_map_error_iommu; - } - vcd_meta_buffer->physical_addr_iommu = - (u8 *) iova_iommu; - vcd_meta_buffer->client_data_iommu = NULL; - vcd_meta_buffer->dev_addr_iommu = (u8 *) iova_iommu; - } - } - - /*fill the meta addr table*/ - num_buffers = vcd_meta_buffer->count; - buf_size = vcd_meta_buffer->size/num_buffers; - ker_vir_addr = vcd_meta_buffer->kernel_virtual_addr; - ker_vir_addr_iommu = vcd_meta_buffer->kernel_virt_addr_iommu; - client_ctx->meta_buf_size = buf_size; - for (index = 0; index < num_buffers; index++) { - client_ctx->meta_addr_table[index].kernel_vir_addr = - ker_vir_addr; - client_ctx->meta_addr_table[index].kernel_vir_addr_iommu = - ker_vir_addr_iommu; - DBG("[%d] kernel_virtual = %p kernel_vir_iommu = %p", - index, ker_vir_addr, ker_vir_addr_iommu); - ker_vir_addr += buf_size; - ker_vir_addr_iommu += buf_size; - } - - DBG("Meta Buffer: Virt: %p, Phys %p, fd: %d", - vcd_meta_buffer->kernel_virtual_addr, - vcd_meta_buffer->physical_addr, - vcd_meta_buffer->pmem_fd); - DBG("IOMMU Meta Buffer: Virt: %p, Phys %p, fd: %d", - vcd_meta_buffer->kernel_virt_addr_iommu, - vcd_meta_buffer->physical_addr_iommu, - vcd_meta_buffer->pmem_fd_iommu); - DBG("Meta_buffer: Dev addr %p", vcd_meta_buffer->dev_addr); - DBG("IOMMU Meta_buffer: Dev addr %p", - vcd_meta_buffer->dev_addr_iommu); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, - vcd_meta_buffer); - - if (vcd_status) - return false; - else - return true; -ion_map_error_iommu: - if (vcd_meta_buffer->kernel_virt_addr_iommu) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle); - vcd_meta_buffer->kernel_virt_addr_iommu = NULL; - } - if (!IS_ERR_OR_NULL(client_ctx->meta_buffer_iommu_ion_handle)) { - ion_free(client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle); - client_ctx->meta_buffer_iommu_ion_handle = NULL; - } -ion_map_error: - if (vcd_meta_buffer->kernel_virtual_addr) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle); - vcd_meta_buffer->kernel_virtual_addr = NULL; - } - if (!IS_ERR_OR_NULL(client_ctx->meta_buffer_ion_handle)) { - ion_free(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle); - client_ctx->meta_buffer_ion_handle = NULL; - } -import_ion_error: - return false; -} -static u32 vid_dec_set_h264_mv_buffers(struct video_client_ctx *client_ctx, - struct vdec_h264_mv *mv_data) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_h264_mv_buffer *vcd_h264_mv_buffer = NULL; - u32 vcd_status = VCD_ERR_FAIL; - u32 len = 0; - int rc = 0; - unsigned long ionflag = 0; - unsigned long buffer_size = 0; - unsigned long iova = 0; - - if (!client_ctx || !mv_data) - return false; - - vcd_property_hdr.prop_id = VCD_I_H264_MV_BUFFER; - vcd_property_hdr.sz = sizeof(struct vcd_property_h264_mv_buffer); - vcd_h264_mv_buffer = &client_ctx->vcd_h264_mv_buffer; - - memset(&client_ctx->vcd_h264_mv_buffer, 0, - sizeof(struct vcd_property_h264_mv_buffer)); - vcd_h264_mv_buffer->size = mv_data->size; - vcd_h264_mv_buffer->count = mv_data->count; - vcd_h264_mv_buffer->pmem_fd = mv_data->pmem_fd; - vcd_h264_mv_buffer->offset = mv_data->offset; - - if (!vcd_get_ion_status()) { - pr_err("PMEM not available\n"); - return false; - } else { - client_ctx->h264_mv_ion_handle = ion_import_dma_buf( - client_ctx->user_ion_client, - vcd_h264_mv_buffer->pmem_fd); - if (IS_ERR_OR_NULL(client_ctx->h264_mv_ion_handle)) { - ERR("%s(): get_ION_handle failed\n", __func__); - goto import_ion_error; - } - rc = ion_handle_get_flags(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle, - &ionflag); - if (rc) { - ERR("%s():get_ION_flags fail\n", - __func__); - goto import_ion_error; - } - vcd_h264_mv_buffer->kernel_virtual_addr = (u8 *) ion_map_kernel( - client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle); - if (!vcd_h264_mv_buffer->kernel_virtual_addr) { - ERR("%s(): get_ION_kernel virtual addr failed\n", - __func__); - goto import_ion_error; - } - if (res_trk_check_for_sec_session() || - (res_trk_get_core_type() == (u32)VCD_CORE_720P)) { - rc = ion_phys(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle, - (dma_addr_t *) (&(vcd_h264_mv_buffer-> - physical_addr)), &len); - if (rc) { - ERR("%s():get_ION_kernel physical addr fail\n", - __func__); - goto ion_map_error; - } - vcd_h264_mv_buffer->client_data = NULL; - vcd_h264_mv_buffer->dev_addr = (u8 *) - vcd_h264_mv_buffer->physical_addr; - } else { - rc = ion_map_iommu(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle, - VIDEO_DOMAIN, VIDEO_MAIN_POOL, - SZ_4K, 0, (dma_addr_t *)&iova, - (unsigned long *)&buffer_size, - 0, 0); - if (rc || !iova) { - ERR( - "%s():get_ION_kernel physical addr fail, rc = %d iova = 0x%lx\n", - __func__, rc, iova); - goto ion_map_error; - } - vcd_h264_mv_buffer->physical_addr = (u8 *) iova; - vcd_h264_mv_buffer->client_data = NULL; - vcd_h264_mv_buffer->dev_addr = (u8 *) iova; - } - } - DBG("Virt: %p, Phys %p, fd: %d", vcd_h264_mv_buffer-> - kernel_virtual_addr, vcd_h264_mv_buffer->physical_addr, - vcd_h264_mv_buffer->pmem_fd); - DBG("Dev addr %p", vcd_h264_mv_buffer->dev_addr); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, vcd_h264_mv_buffer); - - if (vcd_status) - return false; - else - return true; -ion_map_error: - if (vcd_h264_mv_buffer->kernel_virtual_addr) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle); - vcd_h264_mv_buffer->kernel_virtual_addr = NULL; - } - if (!IS_ERR_OR_NULL(client_ctx->h264_mv_ion_handle)) { - ion_free(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle); - client_ctx->h264_mv_ion_handle = NULL; - } -import_ion_error: - return false; -} - -static u32 vid_dec_set_cont_on_reconfig(struct video_client_ctx *client_ctx) -{ - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - u32 enable = true; - if (!client_ctx) - return false; - vcd_property_hdr.prop_id = VCD_I_CONT_ON_RECONFIG; - vcd_property_hdr.sz = sizeof(u32); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &enable); - if (vcd_status) - return false; - return true; -} - -static u32 vid_dec_get_h264_mv_buffer_size(struct video_client_ctx *client_ctx, - struct vdec_mv_buff_size *mv_buff) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_buffer_size h264_mv_buffer_size; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !mv_buff) - return false; - - vcd_property_hdr.prop_id = VCD_I_GET_H264_MV_SIZE; - vcd_property_hdr.sz = sizeof(struct vcd_property_buffer_size); - - h264_mv_buffer_size.width = mv_buff->width; - h264_mv_buffer_size.height = mv_buff->height; - - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &h264_mv_buffer_size); - - mv_buff->width = h264_mv_buffer_size.width; - mv_buff->height = h264_mv_buffer_size.height; - mv_buff->size = h264_mv_buffer_size.size; - mv_buff->alignment = h264_mv_buffer_size.alignment; - - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_free_meta_buffers(struct video_client_ctx *client_ctx) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_buffer_size meta_buffer_size; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx) - return false; - - vcd_property_hdr.prop_id = VCD_I_FREE_EXT_METABUFFER; - vcd_property_hdr.sz = sizeof(struct vcd_property_buffer_size); - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &meta_buffer_size); - - if (!IS_ERR_OR_NULL(client_ctx->meta_buffer_ion_handle)) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle); - if (!res_trk_check_for_sec_session() && - (res_trk_get_core_type() != (u32)VCD_CORE_720P)) { - ion_unmap_iommu(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(client_ctx->user_ion_client, - client_ctx->meta_buffer_ion_handle); - client_ctx->meta_buffer_ion_handle = NULL; - } - - if (!IS_ERR_OR_NULL(client_ctx->meta_buffer_iommu_ion_handle)) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle); - if (res_trk_check_for_sec_session() && - (res_trk_get_core_type() != (u32)VCD_CORE_720P)) { - ion_unmap_iommu(client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(client_ctx->user_ion_client, - client_ctx->meta_buffer_iommu_ion_handle); - client_ctx->meta_buffer_iommu_ion_handle = NULL; - } - - if (vcd_status) - return false; - else - return true; -} - - -static u32 vid_dec_free_h264_mv_buffers(struct video_client_ctx *client_ctx) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_buffer_size h264_mv_buffer_size; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx) - return false; - - vcd_property_hdr.prop_id = VCD_I_FREE_H264_MV_BUFFER; - vcd_property_hdr.sz = sizeof(struct vcd_property_buffer_size); - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &h264_mv_buffer_size); - - if (!IS_ERR_OR_NULL(client_ctx->h264_mv_ion_handle)) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle); - if (!res_trk_check_for_sec_session() && - (res_trk_get_core_type() != (u32)VCD_CORE_720P)) { - ion_unmap_iommu(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle); - client_ctx->h264_mv_ion_handle = NULL; - } - - if (vcd_status) - return false; - else - return true; -} - -static u32 vid_dec_get_buffer_req(struct video_client_ctx *client_ctx, - struct vdec_allocatorproperty *vdec_buf_req) -{ - u32 vcd_status = VCD_ERR_FAIL; - struct vcd_buffer_requirement vcd_buf_req; - - if (!client_ctx || !vdec_buf_req) - return false; - - if (vdec_buf_req->buffer_type == VDEC_BUFFER_TYPE_INPUT) { - vcd_status = vcd_get_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_INPUT, - &vcd_buf_req); - } else { - vcd_status = vcd_get_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, - &vcd_buf_req); - } - - if (vcd_status) { - return false; - } else { - vdec_buf_req->mincount = vcd_buf_req.min_count; - vdec_buf_req->maxcount = vcd_buf_req.max_count; - vdec_buf_req->actualcount = vcd_buf_req.actual_count; - vdec_buf_req->buffer_size = vcd_buf_req.sz; - vdec_buf_req->alignment = vcd_buf_req.align; - vdec_buf_req->buf_poolid = vcd_buf_req.buf_pool_id; - vdec_buf_req->meta_buffer_size = vcd_buf_req.meta_buffer_size; - - return true; - } -} - -static u32 vid_dec_set_buffer(struct video_client_ctx *client_ctx, - struct vdec_setbuffer_cmd *buffer_info) -{ - enum vcd_buffer_type buffer = VCD_BUFFER_INPUT; - enum buffer_dir dir_buffer = BUFFER_TYPE_INPUT; - u32 vcd_status = VCD_ERR_FAIL; - unsigned long kernel_vaddr, buf_adr_offset = 0, length; - - if (!client_ctx || !buffer_info) - return false; - - if (buffer_info->buffer_type == VDEC_BUFFER_TYPE_OUTPUT) { - dir_buffer = BUFFER_TYPE_OUTPUT; - buffer = VCD_BUFFER_OUTPUT; - buf_adr_offset = (unsigned long)buffer_info->buffer.offset; - } - length = buffer_info->buffer.buffer_len; - /*If buffer cannot be set, ignore */ - if (!vidc_insert_addr_table(client_ctx, dir_buffer, - (unsigned long)buffer_info->buffer.bufferaddr, - &kernel_vaddr, buffer_info->buffer.pmem_fd, - buf_adr_offset, MAX_VIDEO_NUM_OF_BUFF, length)) { - DBG("%s() : user_virt_addr = %p cannot be set.", - __func__, buffer_info->buffer.bufferaddr); - return false; - } - vcd_status = vcd_set_buffer(client_ctx->vcd_handle, - buffer, (u8 *) kernel_vaddr, - buffer_info->buffer.buffer_len); - - if (!vcd_status) - return true; - else - return false; -} - - -static u32 vid_dec_free_buffer(struct video_client_ctx *client_ctx, - struct vdec_setbuffer_cmd *buffer_info) -{ - enum vcd_buffer_type buffer = VCD_BUFFER_INPUT; - enum buffer_dir dir_buffer = BUFFER_TYPE_INPUT; - u32 vcd_status = VCD_ERR_FAIL; - unsigned long kernel_vaddr; - - if (!client_ctx || !buffer_info) - return false; - - if (buffer_info->buffer_type == VDEC_BUFFER_TYPE_OUTPUT) { - dir_buffer = BUFFER_TYPE_OUTPUT; - buffer = VCD_BUFFER_OUTPUT; - } - - /*If buffer NOT set, ignore */ - if (!vidc_delete_addr_table(client_ctx, dir_buffer, - (unsigned long)buffer_info->buffer.bufferaddr, - &kernel_vaddr)) { - DBG("%s() : user_virt_addr = %p has not been set.", - __func__, buffer_info->buffer.bufferaddr); - return true; - } - vcd_status = vcd_free_buffer(client_ctx->vcd_handle, buffer, - (u8 *)kernel_vaddr); - - if (!vcd_status) - return true; - else - return false; -} - -static u32 vid_dec_pause_resume(struct video_client_ctx *client_ctx, u32 pause) -{ - u32 vcd_status; - - if (!client_ctx) { - ERR("\n %s(): Invalid client_ctx", __func__); - return false; - } - - if (pause) { - DBG("msm_vidc_dec: PAUSE command from client = %p\n", - client_ctx); - vcd_status = vcd_pause(client_ctx->vcd_handle); - } else{ - DBG("msm_vidc_dec: RESUME command from client = %p\n", - client_ctx); - vcd_status = vcd_resume(client_ctx->vcd_handle); - } - - if (vcd_status) - return false; - - return true; - -} - -static u32 vid_dec_start_stop(struct video_client_ctx *client_ctx, u32 start) -{ - struct vid_dec_msg *vdec_msg = NULL; - u32 vcd_status; - - DBG("msm_vidc_dec: Inside %s()", __func__); - if (!client_ctx) { - ERR("\n Invalid client_ctx"); - return false; - } - - if (start) { - if (client_ctx->seq_header_set) { - DBG("%s(): Seq Hdr set: Send START_DONE to client", - __func__); - vdec_msg = kzalloc(sizeof(*vdec_msg), GFP_KERNEL); - if (!vdec_msg) { - ERR("vid_dec_start_stop: cannot allocate" - "buffer\n"); - return false; - } - vdec_msg->vdec_msg_info.msgcode = - VDEC_MSG_RESP_START_DONE; - vdec_msg->vdec_msg_info.status_code = VDEC_S_SUCCESS; - vdec_msg->vdec_msg_info.msgdatasize = 0; - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&vdec_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - - wake_up(&client_ctx->msg_wait); - - DBG("Send START_DONE message to client = %p\n", - client_ctx); - - } else { - DBG("%s(): Calling decode_start()", __func__); - vcd_status = - vcd_decode_start(client_ctx->vcd_handle, NULL); - - if (vcd_status) { - ERR("%s(): vcd_decode_start failed." - " vcd_status = %u\n", __func__, vcd_status); - return false; - } - } - } else { - DBG("%s(): Calling vcd_stop()", __func__); - mutex_lock(&vid_dec_device_p->lock); - vcd_status = VCD_ERR_FAIL; - if (!client_ctx->stop_called) { - client_ctx->stop_called = true; - vcd_status = vcd_stop(client_ctx->vcd_handle); - } - if (vcd_status) { - ERR("%s(): vcd_stop failed. vcd_status = %u\n", - __func__, vcd_status); - mutex_unlock(&vid_dec_device_p->lock); - return false; - } - DBG("Send STOP_DONE message to client = %p\n", client_ctx); - mutex_unlock(&vid_dec_device_p->lock); - } - return true; -} - -static u32 vid_dec_decode_frame(struct video_client_ctx *client_ctx, - struct vdec_input_frameinfo *input_frame_info, - u8 *desc_buf, u32 desc_size) -{ - struct vcd_frame_data vcd_input_buffer; - unsigned long kernel_vaddr, phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - u32 vcd_status = VCD_ERR_FAIL; - u32 ion_flag = 0; - struct ion_handle *buff_handle = NULL; - - if (!client_ctx || !input_frame_info) - return false; - - user_vaddr = (unsigned long)input_frame_info->bufferaddr; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_INPUT, - true, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index)) { - - /* kernel_vaddr is found. send the frame to VCD */ - memset((void *)&vcd_input_buffer, 0, - sizeof(struct vcd_frame_data)); - vcd_input_buffer.virtual = - (u8 *) (kernel_vaddr + input_frame_info->pmem_offset); - vcd_input_buffer.offset = input_frame_info->offset; - vcd_input_buffer.frm_clnt_data = - (u32) input_frame_info->client_data; - vcd_input_buffer.ip_frm_tag = - (u32) input_frame_info->client_data; - vcd_input_buffer.data_len = input_frame_info->datalen; - vcd_input_buffer.time_stamp = input_frame_info->timestamp; - /* Rely on VCD using the same flags as OMX */ - vcd_input_buffer.flags = input_frame_info->flags; - vcd_input_buffer.desc_buf = desc_buf; - vcd_input_buffer.desc_size = desc_size; - if (vcd_input_buffer.data_len > 0) { - ion_flag = vidc_get_fd_info(client_ctx, - BUFFER_TYPE_INPUT, - pmem_fd, - kernel_vaddr, - buffer_index, - &buff_handle); - if (ion_flag == ION_FLAG_CACHED && buff_handle) { - msm_ion_do_cache_op(client_ctx->user_ion_client, - buff_handle, - (unsigned long *)kernel_vaddr, - (unsigned long) vcd_input_buffer.data_len, - ION_IOC_CLEAN_CACHES); - } - } - vcd_status = vcd_decode_frame(client_ctx->vcd_handle, - &vcd_input_buffer); - if (!vcd_status) - return true; - else { - ERR("%s(): vcd_decode_frame failed = %u\n", __func__, - vcd_status); - return false; - } - - } else { - ERR("%s(): kernel_vaddr not found\n", __func__); - return false; - } -} - -static u32 vid_dec_fill_output_buffer(struct video_client_ctx *client_ctx, - struct vdec_fillbuffer_cmd *fill_buffer_cmd) -{ - unsigned long kernel_vaddr, phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - u32 vcd_status = VCD_ERR_FAIL; - struct ion_handle *buff_handle = NULL; - - struct vcd_frame_data vcd_frame; - - if (!client_ctx || !fill_buffer_cmd) - return false; - - user_vaddr = (unsigned long)fill_buffer_cmd->buffer.bufferaddr; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - true, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index)) { - - memset((void *)&vcd_frame, 0, - sizeof(struct vcd_frame_data)); - vcd_frame.virtual = (u8 *) kernel_vaddr; - vcd_frame.frm_clnt_data = (u32) fill_buffer_cmd->client_data; - vcd_frame.alloc_len = fill_buffer_cmd->buffer.buffer_len; - vcd_frame.ion_flag = vidc_get_fd_info(client_ctx, - BUFFER_TYPE_OUTPUT, - pmem_fd, kernel_vaddr, - buffer_index, - &buff_handle); - vcd_frame.buff_ion_handle = buff_handle; - vcd_status = vcd_fill_output_buffer(client_ctx->vcd_handle, - &vcd_frame); - if (!vcd_status) - return true; - else { - ERR("%s(): vcd_fill_output_buffer failed = %u\n", - __func__, vcd_status); - return false; - } - } else { - ERR("%s(): kernel_vaddr not found\n", __func__); - return false; - } -} - - -static u32 vid_dec_flush(struct video_client_ctx *client_ctx, - enum vdec_bufferflush flush_dir) -{ - u32 vcd_status = VCD_ERR_FAIL; - - DBG("msm_vidc_dec: %s() called with dir = %u", __func__, - flush_dir); - if (!client_ctx) { - ERR("\n Invalid client_ctx"); - return false; - } - - switch (flush_dir) { - case VDEC_FLUSH_TYPE_INPUT: - vcd_status = vcd_flush(client_ctx->vcd_handle, VCD_FLUSH_INPUT); - break; - case VDEC_FLUSH_TYPE_OUTPUT: - vcd_status = vcd_flush(client_ctx->vcd_handle, - VCD_FLUSH_OUTPUT); - break; - case VDEC_FLUSH_TYPE_ALL: - vcd_status = vcd_flush(client_ctx->vcd_handle, VCD_FLUSH_ALL); - break; - default: - ERR("%s(): Inavlid flush cmd. flush_dir = %u\n", __func__, - flush_dir); - return false; - break; - } - - if (!vcd_status) - return true; - else { - ERR("%s(): vcd_flush failed. vcd_status = %u " - " flush_dir = %u\n", __func__, vcd_status, flush_dir); - return false; - } -} - -static u32 vid_dec_msg_pending(struct video_client_ctx *client_ctx) -{ - u32 islist_empty = 0; - mutex_lock(&client_ctx->msg_queue_lock); - islist_empty = list_empty(&client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - - if (islist_empty) { - DBG("%s(): vid_dec msg queue empty\n", __func__); - if (client_ctx->stop_msg) { - DBG("%s(): List empty and Stop Msg set\n", - __func__); - return client_ctx->stop_msg; - } - } else - DBG("%s(): vid_dec msg queue Not empty\n", __func__); - - return !islist_empty; -} - -static int vid_dec_get_next_msg(struct video_client_ctx *client_ctx, - struct vdec_msginfo *vdec_msg_info) -{ - int rc; - struct vid_dec_msg *vid_dec_msg = NULL; - - if (!client_ctx) - return false; - - rc = wait_event_interruptible(client_ctx->msg_wait, - vid_dec_msg_pending(client_ctx)); - if (rc < 0) { - DBG("rc = %d, stop_msg = %u\n", rc, client_ctx->stop_msg); - return rc; - } else if (client_ctx->stop_msg) { - DBG("rc = %d, stop_msg = %u\n", rc, client_ctx->stop_msg); - return -EIO; - } - - mutex_lock(&client_ctx->msg_queue_lock); - if (!list_empty(&client_ctx->msg_queue)) { - DBG("%s(): After Wait\n", __func__); - vid_dec_msg = list_first_entry(&client_ctx->msg_queue, - struct vid_dec_msg, list); - list_del(&vid_dec_msg->list); - memcpy(vdec_msg_info, &vid_dec_msg->vdec_msg_info, - sizeof(struct vdec_msginfo)); - kfree(vid_dec_msg); - } - mutex_unlock(&client_ctx->msg_queue_lock); - return 0; -} - -static long vid_dec_ioctl(struct file *file, - unsigned cmd, unsigned long u_arg) -{ - struct video_client_ctx *client_ctx = NULL; - struct vdec_ioctl_msg vdec_msg; - u32 vcd_status; - unsigned long kernel_vaddr, phy_addr, len; - unsigned long ker_vaddr; - u32 result = true; - void __user *arg = (void __user *)u_arg; - int rc = 0; - size_t ion_len; - - DBG("%s\n", __func__); - if (_IOC_TYPE(cmd) != VDEC_IOCTL_MAGIC) - return -ENOTTY; - - client_ctx = (struct video_client_ctx *)file->private_data; - if (!client_ctx) { - ERR("!client_ctx. Cannot attach to device handle\n"); - return -ENODEV; - } - - switch (cmd) { - case VDEC_IOCTL_SET_CODEC: - { - enum vdec_codec vdec_codec; - DBG("VDEC_IOCTL_SET_CODEC\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&vdec_codec, vdec_msg.in, - sizeof(vdec_codec))) - return -EFAULT; - DBG("setting code type = %u\n", vdec_codec); - result = vid_dec_set_codec(client_ctx, &vdec_codec); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_SET_OUTPUT_FORMAT: - { - enum vdec_output_fromat output_format; - DBG("VDEC_IOCTL_SET_OUTPUT_FORMAT\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&output_format, vdec_msg.in, - sizeof(output_format))) - return -EFAULT; - - result = vid_dec_set_output_format(client_ctx, &output_format); - - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_SET_PICRES: - { - struct vdec_picsize video_resoultion; - DBG("VDEC_IOCTL_SET_PICRES\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&video_resoultion, vdec_msg.in, - sizeof(video_resoultion))) - return -EFAULT; - result = - vid_dec_set_frame_resolution(client_ctx, &video_resoultion); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_GET_PICRES: - { - struct vdec_picsize video_resoultion; - DBG("VDEC_IOCTL_GET_PICRES\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&video_resoultion, vdec_msg.out, - sizeof(video_resoultion))) - return -EFAULT; - - result = vid_dec_get_frame_resolution(client_ctx, - &video_resoultion); - - if (result) { - if (copy_to_user(vdec_msg.out, &video_resoultion, - sizeof(video_resoultion))) - return -EFAULT; - } else - return -EIO; - break; - } - case VDEC_IOCTL_SET_BUFFER_REQ: - { - struct vdec_allocatorproperty vdec_buf_req; - struct vcd_buffer_requirement buffer_req; - DBG("VDEC_IOCTL_SET_BUFFER_REQ\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - - if (copy_from_user(&vdec_buf_req, vdec_msg.in, - sizeof(vdec_buf_req))) - return -EFAULT; - - buffer_req.actual_count = vdec_buf_req.actualcount; - buffer_req.align = vdec_buf_req.alignment; - buffer_req.max_count = vdec_buf_req.maxcount; - buffer_req.min_count = vdec_buf_req.mincount; - buffer_req.sz = vdec_buf_req.buffer_size; - - switch (vdec_buf_req.buffer_type) { - case VDEC_BUFFER_TYPE_INPUT: - vcd_status = - vcd_set_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_INPUT, &buffer_req); - break; - case VDEC_BUFFER_TYPE_OUTPUT: - vcd_status = - vcd_set_buffer_requirements(client_ctx->vcd_handle, - VCD_BUFFER_OUTPUT, &buffer_req); - break; - default: - vcd_status = VCD_ERR_BAD_POINTER; - break; - } - - if (vcd_status) - return -EFAULT; - break; - } - case VDEC_IOCTL_GET_BUFFER_REQ: - { - struct vdec_allocatorproperty vdec_buf_req; - DBG("VDEC_IOCTL_GET_BUFFER_REQ\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&vdec_buf_req, vdec_msg.out, - sizeof(vdec_buf_req))) - return -EFAULT; - - result = vid_dec_get_buffer_req(client_ctx, &vdec_buf_req); - - if (result) { - if (copy_to_user(vdec_msg.out, &vdec_buf_req, - sizeof(vdec_buf_req))) - return -EFAULT; - } else - return -EIO; - break; - } - case VDEC_IOCTL_SET_BUFFER: - { - struct vdec_setbuffer_cmd setbuffer; - DBG("VDEC_IOCTL_SET_BUFFER\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&setbuffer, vdec_msg.in, - sizeof(setbuffer))) - return -EFAULT; - result = vid_dec_set_buffer(client_ctx, &setbuffer); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_FREE_BUFFER: - { - struct vdec_setbuffer_cmd setbuffer; - DBG("VDEC_IOCTL_FREE_BUFFER\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&setbuffer, vdec_msg.in, - sizeof(setbuffer))) - return -EFAULT; - result = vid_dec_free_buffer(client_ctx, &setbuffer); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_CMD_START: - { - DBG(" VDEC_IOCTL_CMD_START\n"); - result = vid_dec_start_stop(client_ctx, true); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_CMD_STOP: - { - DBG("VDEC_IOCTL_CMD_STOP\n"); - result = vid_dec_start_stop(client_ctx, false); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_CMD_PAUSE: - { - result = vid_dec_pause_resume(client_ctx, true); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_CMD_RESUME: - { - DBG("VDEC_IOCTL_CMD_PAUSE\n"); - result = vid_dec_pause_resume(client_ctx, false); - - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_DECODE_FRAME: - { - struct vdec_input_frameinfo input_frame_info; - u8 *desc_buf = NULL; - u32 desc_size = 0; - DBG("VDEC_IOCTL_DECODE_FRAME\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&input_frame_info, vdec_msg.in, - sizeof(input_frame_info))) - return -EFAULT; - if (client_ctx->dmx_disable) { - if (input_frame_info.desc_addr) { - desc_size = input_frame_info.desc_size; - desc_buf = kzalloc(desc_size, GFP_KERNEL); - if (desc_buf) { - if (copy_from_user(desc_buf, - input_frame_info.desc_addr, - desc_size)) { - kfree(desc_buf); - desc_buf = NULL; - return -EFAULT; - } - } - } else - return -EINVAL; - } - result = vid_dec_decode_frame(client_ctx, &input_frame_info, - desc_buf, desc_size); - - if (!result) { - kfree(desc_buf); - desc_buf = NULL; - return -EIO; - } - break; - } - case VDEC_IOCTL_SET_PERF_CLK: - { - vid_dec_set_turbo_clk(client_ctx); - break; - } - case VDEC_IOCTL_FILL_OUTPUT_BUFFER: - { - struct vdec_fillbuffer_cmd fill_buffer_cmd; - DBG("VDEC_IOCTL_FILL_OUTPUT_BUFFER\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&fill_buffer_cmd, vdec_msg.in, - sizeof(fill_buffer_cmd))) - return -EFAULT; - result = vid_dec_fill_output_buffer(client_ctx, - &fill_buffer_cmd); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_CMD_FLUSH: - { - enum vdec_bufferflush flush_dir; - DBG("VDEC_IOCTL_CMD_FLUSH\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&flush_dir, vdec_msg.in, - sizeof(flush_dir))) - return -EFAULT; - result = vid_dec_flush(client_ctx, flush_dir); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_GET_NEXT_MSG: - { - struct vdec_msginfo vdec_msg_info; - DBG("VDEC_IOCTL_GET_NEXT_MSG\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - result = vid_dec_get_next_msg(client_ctx, &vdec_msg_info); - if (result) - return result; - if (copy_to_user(vdec_msg.out, &vdec_msg_info, - sizeof(vdec_msg_info))) - return -EFAULT; - break; - } - case VDEC_IOCTL_STOP_NEXT_MSG: - { - DBG("VDEC_IOCTL_STOP_NEXT_MSG\n"); - client_ctx->stop_msg = 1; - wake_up(&client_ctx->msg_wait); - break; - } - case VDEC_IOCTL_SET_SEQUENCE_HEADER: - { - struct vdec_seqheader seq_header; - struct vcd_sequence_hdr vcd_seq_hdr; - unsigned long ionflag; - DBG("VDEC_IOCTL_SET_SEQUENCE_HEADER\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) { - ERR("Copy from user vdec_msg failed\n"); - return -EFAULT; - } - if (copy_from_user(&seq_header, vdec_msg.in, - sizeof(seq_header))) { - ERR("Copy from user seq_header failed\n"); - return -EFAULT; - } - if (!seq_header.seq_header_len) { - ERR("Seq Len is Zero\n"); - return -EFAULT; - } - - if (!vcd_get_ion_status()) { - pr_err("PMEM Not available\n"); - return -EINVAL; - } else { - client_ctx->seq_hdr_ion_handle = ion_import_dma_buf( - client_ctx->user_ion_client, - seq_header.pmem_fd); - if (!client_ctx->seq_hdr_ion_handle) { - ERR("%s(): get_ION_handle failed\n", __func__); - return false; - } - rc = ion_handle_get_flags(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle, - &ionflag); - if (rc) { - ERR("%s():get_ION_flags fail\n", - __func__); - ion_free(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle); - return false; - } - ker_vaddr = (unsigned long) ion_map_kernel( - client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle); - if (!ker_vaddr) { - ERR("%s():get_ION_kernel virtual addr fail\n", - __func__); - ion_free(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle); - return false; - } - kernel_vaddr = ker_vaddr; - rc = ion_phys(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle, - (ion_phys_addr_t *)&phy_addr, &ion_len); - if (rc) { - ERR("%s():get_ION_kernel physical addr fail\n", - __func__); - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle); - ion_free(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle); - return false; - } - len = ion_len; - } - vcd_seq_hdr.sequence_header_len = seq_header.seq_header_len; - kernel_vaddr += (unsigned long)seq_header.pmem_offset; - vcd_seq_hdr.sequence_header = (u8 *)kernel_vaddr; - if (!vcd_seq_hdr.sequence_header) { - ERR("Sequence Header pointer failed\n"); - return -EFAULT; - } - client_ctx->seq_header_set = true; - if (vcd_decode_start(client_ctx->vcd_handle, &vcd_seq_hdr)) { - ERR("Decode start Failed\n"); - client_ctx->seq_header_set = false; - return -EFAULT; - } - DBG("Wait Client completion Sequence Header\n"); - wait_for_completion(&client_ctx->event); - vcd_seq_hdr.sequence_header = NULL; - if (client_ctx->event_status) { - ERR("Set Seq Header status is failed"); - return -EFAULT; - } - if (vcd_get_ion_status()) { - if (client_ctx->seq_hdr_ion_handle) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle); - ion_free(client_ctx->user_ion_client, - client_ctx->seq_hdr_ion_handle); - } - } - break; - } - case VDEC_IOCTL_GET_NUMBER_INSTANCES: - { - DBG("VDEC_IOCTL_GET_NUMBER_INSTANCES\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_to_user(vdec_msg.out, - &vid_dec_device_p->num_clients, sizeof(u32))) - return -EFAULT; - break; - } - case VDEC_IOCTL_GET_INTERLACE_FORMAT: - { - u32 progressive_only, interlace_format; - DBG("VDEC_IOCTL_GET_INTERLACE_FORMAT\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - result = vid_dec_get_progressive_only(client_ctx, - &progressive_only); - if (result) { - interlace_format = progressive_only ? - VDEC_InterlaceFrameProgressive : - VDEC_InterlaceInterleaveFrameTopFieldFirst; - if (copy_to_user(vdec_msg.out, &interlace_format, - sizeof(u32))) - return -EFAULT; - } else - return -EIO; - break; - } - - case VDEC_IOCTL_GET_DISABLE_DMX_SUPPORT: - { - u32 disable_dmx; - DBG("VDEC_IOCTL_GET_DISABLE_DMX_SUPPORT\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - result = vid_dec_get_disable_dmx_support(client_ctx, - &disable_dmx); - if (result) { - if (copy_to_user(vdec_msg.out, &disable_dmx, - sizeof(u32))) - return -EFAULT; - } else - return -EIO; - break; - } - case VDEC_IOCTL_GET_DISABLE_DMX: - { - u32 disable_dmx; - DBG("VDEC_IOCTL_GET_DISABLE_DMX\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - result = vid_dec_get_disable_dmx(client_ctx, - &disable_dmx); - if (result) { - if (copy_to_user(vdec_msg.out, &disable_dmx, - sizeof(u32))) - return -EFAULT; - } else - return -EIO; - break; - } - case VDEC_IOCTL_SET_DISABLE_DMX: - { - DBG("VDEC_IOCTL_SET_DISABLE_DMX\n"); - result = vid_dec_set_disable_dmx(client_ctx); - if (!result) - return -EIO; - client_ctx->dmx_disable = 1; - break; - } - case VDEC_IOCTL_SET_PICTURE_ORDER: - { - u32 picture_order; - DBG("VDEC_IOCTL_SET_PICTURE_ORDER\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&picture_order, vdec_msg.in, - sizeof(u32))) - return -EFAULT; - result = vid_dec_set_picture_order(client_ctx, &picture_order); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_SET_FRAME_RATE: - { - struct vdec_framerate frame_rate; - DBG("VDEC_IOCTL_SET_FRAME_RATE\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&frame_rate, vdec_msg.in, - sizeof(frame_rate))) - return -EFAULT; - result = vid_dec_set_frame_rate(client_ctx, &frame_rate); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_SET_EXTRADATA: - { - u32 extradata_flag; - DBG("VDEC_IOCTL_SET_EXTRADATA\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&extradata_flag, vdec_msg.in, - sizeof(u32))) - return -EFAULT; - result = vid_dec_set_extradata(client_ctx, &extradata_flag); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_SET_META_BUFFERS: - { - struct vdec_meta_buffers meta_buffers; - DBG("VDEC_IOCTL_SET_META_BUFFERS\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&meta_buffers, vdec_msg.in, - sizeof(meta_buffers))) - return -EFAULT; - result = vid_dec_set_meta_buffers(client_ctx, &meta_buffers); - - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_FREE_META_BUFFERS: - { - DBG("VDEC_IOCTL_FREE_META_BUFFERS\n"); - result = vid_dec_free_meta_buffers(client_ctx); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_SET_H264_MV_BUFFER: - { - struct vdec_h264_mv mv_data; - DBG("VDEC_IOCTL_SET_H264_MV_BUFFER\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&mv_data, vdec_msg.in, - sizeof(mv_data))) - return -EFAULT; - result = vid_dec_set_h264_mv_buffers(client_ctx, &mv_data); - - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_FREE_H264_MV_BUFFER: - { - DBG("VDEC_IOCTL_FREE_H264_MV_BUFFER\n"); - result = vid_dec_free_h264_mv_buffers(client_ctx); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_GET_MV_BUFFER_SIZE: - { - struct vdec_mv_buff_size mv_buff; - DBG("VDEC_IOCTL_GET_MV_BUFFER_SIZE\n"); - if (copy_from_user(&vdec_msg, arg, sizeof(vdec_msg))) - return -EFAULT; - if (copy_from_user(&mv_buff, vdec_msg.out, - sizeof(mv_buff))) - return -EFAULT; - result = vid_dec_get_h264_mv_buffer_size(client_ctx, &mv_buff); - if (result) { - DBG(" Returning W: %d, H: %d, S: %d, A: %d", - mv_buff.width, mv_buff.height, - mv_buff.size, mv_buff.alignment); - if (copy_to_user(vdec_msg.out, &mv_buff, - sizeof(mv_buff))) - return -EFAULT; - } else - return -EIO; - break; - } - case VDEC_IOCTL_SET_IDR_ONLY_DECODING: - { - result = vid_dec_set_idr_only_decoding(client_ctx); - if (!result) - return -EIO; - break; - } - case VDEC_IOCTL_SET_CONT_ON_RECONFIG: - { - result = vid_dec_set_cont_on_reconfig(client_ctx); - if (!result) - return -EIO; - break; - } - default: - ERR("%s(): Unsupported ioctl\n", __func__); - return -ENOTTY; - break; - } - - return 0; -} - -static u32 vid_dec_close_client(struct video_client_ctx *client_ctx) -{ - struct vid_dec_msg *vdec_msg; - u32 vcd_status; - - DBG("msm_vidc_dec: Inside %s()", __func__); - if (!client_ctx || (!client_ctx->vcd_handle)) { - ERR("\n Invalid client_ctx"); - return false; - } - - mutex_lock(&vid_dec_device_p->lock); - if (!client_ctx->stop_called) { - client_ctx->stop_called = true; - client_ctx->stop_sync_cb = true; - vcd_status = vcd_stop(client_ctx->vcd_handle); - DBG("\n Stuck at the stop call"); - if (!vcd_status) - wait_for_completion(&client_ctx->event); - DBG("\n Came out of wait event"); - } - mutex_lock(&client_ctx->msg_queue_lock); - while (!list_empty(&client_ctx->msg_queue)) { - DBG("%s(): Delete remaining entries\n", __func__); - vdec_msg = list_first_entry(&client_ctx->msg_queue, - struct vid_dec_msg, list); - if (vdec_msg) { - list_del(&vdec_msg->list); - kfree(vdec_msg); - } - } - mutex_unlock(&client_ctx->msg_queue_lock); - vcd_status = vcd_close(client_ctx->vcd_handle); - - client_ctx->user_ion_client = NULL; - memset((void *)client_ctx, 0, sizeof(struct video_client_ctx)); - vid_dec_device_p->num_clients--; - mutex_unlock(&vid_dec_device_p->lock); - return true; -} - -int vid_dec_open_client(struct video_client_ctx **vid_clnt_ctx, int flags) -{ - int rc = 0; - s32 client_index; - struct video_client_ctx *client_ctx = NULL; - u8 client_count; - - if (!vid_clnt_ctx) { - ERR("Invalid input\n"); - return -EINVAL; - } - *vid_clnt_ctx = NULL; - client_count = vcd_get_num_of_clients(); - if (client_count == VIDC_MAX_NUM_CLIENTS) { - ERR("ERROR : vid_dec_open() max number of clients" - "limit reached\n"); - rc = -ENOMEM; - goto client_failure; - } - - DBG(" Virtual Address of ioremap is %p\n", vid_dec_device_p->virt_base); - if (!vid_dec_device_p->num_clients) { - if (!vidc_load_firmware()) { - rc = -ENOMEM; - goto client_failure; - } - } - - client_index = vid_dec_get_empty_client_index(); - if (client_index < 0) { - ERR("%s() : No free clients client_index == -1\n", __func__); - rc = -ENOMEM; - goto client_failure; - } - client_ctx = &vid_dec_device_p->vdec_clients[client_index]; - vid_dec_device_p->num_clients++; - init_completion(&client_ctx->event); - mutex_init(&client_ctx->msg_queue_lock); - mutex_init(&client_ctx->enrty_queue_lock); - INIT_LIST_HEAD(&client_ctx->msg_queue); - init_waitqueue_head(&client_ctx->msg_wait); - client_ctx->stop_msg = 0; - client_ctx->stop_called = false; - client_ctx->stop_sync_cb = false; - client_ctx->dmx_disable = 0; - if (vcd_get_ion_status()) { - client_ctx->user_ion_client = vcd_get_ion_client(); - if (!client_ctx->user_ion_client) { - ERR("vcd_open ion client get failed"); - rc = -ENOMEM; - goto client_failure; - } - } - rc = vcd_open(vid_dec_device_p->device_handle, true, - vid_dec_vcd_cb, client_ctx, flags); - if (!rc) { - wait_for_completion(&client_ctx->event); - if (client_ctx->event_status) { - ERR("callback for vcd_open returned error: %u", - client_ctx->event_status); - rc = -ENODEV; - goto client_failure; - } - } else { - ERR("vcd_open returned error: %u", rc); - goto client_failure; - } - client_ctx->seq_header_set = false; - *vid_clnt_ctx = client_ctx; -client_failure: - return rc; -} - -static int vid_dec_open_secure(struct inode *inode, struct file *file) -{ - int rc = 0; - struct video_client_ctx *client_ctx; - mutex_lock(&vid_dec_device_p->lock); - rc = vid_dec_open_client(&client_ctx, VCD_CP_SESSION); - if (rc) - goto error; - if (!client_ctx) { - rc = -ENOMEM; - goto error; - } - - file->private_data = client_ctx; - if (res_trk_open_secure_session()) { - ERR("Secure session operation failure\n"); - rc = -EACCES; - goto error; - } - mutex_unlock(&vid_dec_device_p->lock); - return 0; -error: - mutex_unlock(&vid_dec_device_p->lock); - return rc; -} - -static int vid_dec_open(struct inode *inode, struct file *file) -{ - int rc = 0; - struct video_client_ctx *client_ctx; - INFO("msm_vidc_dec: Inside %s()", __func__); - mutex_lock(&vid_dec_device_p->lock); - rc = vid_dec_open_client(&client_ctx, 0); - if (rc) { - mutex_unlock(&vid_dec_device_p->lock); - return rc; - } - if (!client_ctx) { - mutex_unlock(&vid_dec_device_p->lock); - return -ENOMEM; - } - - file->private_data = client_ctx; - mutex_unlock(&vid_dec_device_p->lock); - return rc; -} - -static int vid_dec_release_secure(struct inode *inode, struct file *file) -{ - struct video_client_ctx *client_ctx = file->private_data; - - INFO("msm_vidc_dec: Inside %s()", __func__); - vidc_cleanup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT); - vidc_cleanup_addr_table(client_ctx, BUFFER_TYPE_INPUT); - vid_dec_close_client(client_ctx); - vidc_release_firmware(); -#ifndef USE_RES_TRACKER - vidc_disable_clk(); -#endif - INFO("msm_vidc_dec: Return from %s()", __func__); - return 0; -} - -static int vid_dec_release(struct inode *inode, struct file *file) -{ - struct video_client_ctx *client_ctx = file->private_data; - - INFO("msm_vidc_dec: Inside %s()", __func__); - vidc_cleanup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT); - vidc_cleanup_addr_table(client_ctx, BUFFER_TYPE_INPUT); - vid_dec_close_client(client_ctx); - vidc_release_firmware(); -#ifndef USE_RES_TRACKER - vidc_disable_clk(); -#endif - INFO("msm_vidc_dec: Return from %s()", __func__); - return 0; -} - -static const struct file_operations vid_dec_fops[2] = { - { - .owner = THIS_MODULE, - .open = vid_dec_open, - .release = vid_dec_release, - .unlocked_ioctl = vid_dec_ioctl, - }, - { - .owner = THIS_MODULE, - .open = vid_dec_open_secure, - .release = vid_dec_release_secure, - .unlocked_ioctl = vid_dec_ioctl, - }, - -}; - -void vid_dec_interrupt_deregister(void) -{ -} - -void vid_dec_interrupt_register(void *device_name) -{ -} - -void vid_dec_interrupt_clear(void) -{ -} - -void *vid_dec_map_dev_base_addr(void *device_name) -{ - return vid_dec_device_p->virt_base; -} - -static int vid_dec_vcd_init(void) -{ - int rc; - struct vcd_init_config vcd_init_config; - u32 i; - - /* init_timer(&hw_timer); */ - DBG("msm_vidc_dec: Inside %s()", __func__); - vid_dec_device_p->num_clients = 0; - - for (i = 0; i < VIDC_MAX_NUM_CLIENTS; i++) { - memset((void *)&vid_dec_device_p->vdec_clients[i], 0, - sizeof(vid_dec_device_p->vdec_clients[i])); - } - - mutex_init(&vid_dec_device_p->lock); - vid_dec_device_p->virt_base = vidc_get_ioaddr(); - DBG("%s() : base address for VIDC core %u\n", __func__, \ - (int)vid_dec_device_p->virt_base); - - if (!vid_dec_device_p->virt_base) { - ERR("%s() : ioremap failed\n", __func__); - return -ENOMEM; - } - - vcd_init_config.device_name = "VIDC"; - vcd_init_config.map_dev_base_addr = vid_dec_map_dev_base_addr; - vcd_init_config.interrupt_clr = vid_dec_interrupt_clear; - vcd_init_config.register_isr = vid_dec_interrupt_register; - vcd_init_config.deregister_isr = vid_dec_interrupt_deregister; - vcd_init_config.timer_create = vidc_timer_create; - vcd_init_config.timer_release = vidc_timer_release; - vcd_init_config.timer_start = vidc_timer_start; - vcd_init_config.timer_stop = vidc_timer_stop; - - rc = vcd_init(&vcd_init_config, &vid_dec_device_p->device_handle); - - if (rc) { - ERR("%s() : vcd_init failed\n", __func__); - return -ENODEV; - } - return 0; -} - -static int __init vid_dec_init(void) -{ - int rc = 0, i = 0, j = 0; - struct device *class_devp; - - DBG("msm_vidc_dec: Inside %s()", __func__); - vid_dec_device_p = kzalloc(sizeof(struct vid_dec_dev), GFP_KERNEL); - if (!vid_dec_device_p) { - ERR("%s Unable to allocate memory for vid_dec_dev\n", - __func__); - return -ENOMEM; - } - - rc = alloc_chrdev_region(&vid_dec_dev_num, 0, NUM_OF_DRIVER_NODES, - VID_DEC_NAME); - if (rc < 0) { - ERR("%s: alloc_chrdev_region Failed rc = %d\n", - __func__, rc); - goto error_vid_dec_alloc_chrdev_region; - } - - vid_dec_class = class_create(THIS_MODULE, VID_DEC_NAME); - if (IS_ERR(vid_dec_class)) { - rc = PTR_ERR(vid_dec_class); - ERR("%s: couldn't create vid_dec_class rc = %d\n", - __func__, rc); - - goto error_vid_dec_class_create; - } - for (i = 0; i < NUM_OF_DRIVER_NODES; i++) { - class_devp = device_create(vid_dec_class, NULL, - (vid_dec_dev_num + i), - NULL, VID_DEC_NAME "%s", - node_name[i]); - - if (IS_ERR(class_devp)) { - rc = PTR_ERR(class_devp); - ERR("%s: class device_create failed %d\n", - __func__, rc); - if (!i) - goto error_vid_dec_class_device_create; - else - goto error_vid_dec_cdev_add; - } - - vid_dec_device_p->device[i] = class_devp; - - cdev_init(&vid_dec_device_p->cdev[i], &vid_dec_fops[i]); - vid_dec_device_p->cdev[i].owner = THIS_MODULE; - rc = cdev_add(&(vid_dec_device_p->cdev[i]), - (vid_dec_dev_num+i), 1); - - if (rc < 0) { - ERR("%s: cdev_add failed %d\n", __func__, rc); - goto error_vid_dec_cdev_add; - } - } - vid_dec_vcd_init(); - return 0; - -error_vid_dec_cdev_add: - for (j = i-1; j >= 0; j--) - cdev_del(&(vid_dec_device_p->cdev[j])); - device_destroy(vid_dec_class, vid_dec_dev_num); -error_vid_dec_class_device_create: - class_destroy(vid_dec_class); -error_vid_dec_class_create: - unregister_chrdev_region(vid_dec_dev_num, NUM_OF_DRIVER_NODES); -error_vid_dec_alloc_chrdev_region: - kfree(vid_dec_device_p); - return rc; -} - -static void __exit vid_dec_exit(void) -{ - int i = 0; - INFO("msm_vidc_dec: Inside %s()", __func__); - for (i = 0; i < NUM_OF_DRIVER_NODES; i++) - cdev_del(&(vid_dec_device_p->cdev[i])); - device_destroy(vid_dec_class, vid_dec_dev_num); - class_destroy(vid_dec_class); - unregister_chrdev_region(vid_dec_dev_num, NUM_OF_DRIVER_NODES); - kfree(vid_dec_device_p); - DBG("msm_vidc_dec: Return from %s()", __func__); -} - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Video decoder driver"); -MODULE_VERSION("1.0"); - -module_init(vid_dec_init); -module_exit(vid_dec_exit); diff --git a/drivers/video/msm/vidc/common/dec/vdec_internal.h b/drivers/video/msm/vidc/common/dec/vdec_internal.h deleted file mode 100644 index a7a32a58e062e4568f39327765243f1ed224bad6..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/dec/vdec_internal.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2010, 2012, 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 VDEC_INTERNAL_H -#define VDEC_INTERNAL_H - -#include -#include -#include - -#define NUM_OF_DRIVER_NODES 2 - -struct vid_dec_msg { - struct list_head list; - struct vdec_msginfo vdec_msg_info; -}; - -struct vid_dec_dev { - struct cdev cdev[NUM_OF_DRIVER_NODES]; - struct device *device[NUM_OF_DRIVER_NODES]; - resource_size_t phys_base; - void __iomem *virt_base; - unsigned int irq; - struct clk *hclk; - struct clk *hclk_div2; - struct clk *pclk; - unsigned long hclk_rate; - struct mutex lock; - s32 device_handle; - struct video_client_ctx vdec_clients[VIDC_MAX_NUM_CLIENTS]; - u32 num_clients; - void(*timer_handler)(void *); -}; - -#endif diff --git a/drivers/video/msm/vidc/common/enc/venc.c b/drivers/video/msm/vidc/common/enc/venc.c deleted file mode 100644 index 823626ad18e9be41f24b1ad94b4e9a56b9755907..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/enc/venc.c +++ /dev/null @@ -1,1929 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "venc_internal.h" -#include "vcd_res_tracker_api.h" - -#define VID_ENC_NAME "msm_vidc_enc" -static char *node_name[2] = {"", "_sec"}; - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -#define INFO(x...) printk(KERN_INFO x) -#define ERR(x...) printk(KERN_ERR x) - -static struct vid_enc_dev *vid_enc_device_p; -static dev_t vid_enc_dev_num; -static struct class *vid_enc_class; -static long vid_enc_ioctl(struct file *file, - unsigned cmd, unsigned long arg); - -static s32 vid_enc_get_empty_client_index(void) -{ - u32 i; - u32 found = false; - - for (i = 0; i < VIDC_MAX_NUM_CLIENTS; i++) { - if (!vid_enc_device_p->venc_clients[i].vcd_handle) { - found = true; - break; - } - } - if (!found) { - ERR("%s():ERROR No space for new client\n", - __func__); - return -ENOMEM; - } else { - DBG("%s(): available client index = %u\n", - __func__, i); - return i; - } -} - - -u32 vid_enc_get_status(u32 status) -{ - u32 venc_status; - - switch (status) { - case VCD_S_SUCCESS: - venc_status = VEN_S_SUCCESS; - break; - case VCD_ERR_FAIL: - venc_status = VEN_S_EFAIL; - break; - case VCD_ERR_ALLOC_FAIL: - venc_status = VEN_S_ENOSWRES; - break; - case VCD_ERR_ILLEGAL_OP: - venc_status = VEN_S_EINVALCMD; - break; - case VCD_ERR_ILLEGAL_PARM: - venc_status = VEN_S_EBADPARAM; - break; - case VCD_ERR_BAD_POINTER: - case VCD_ERR_BAD_HANDLE: - venc_status = VEN_S_EFATAL; - break; - case VCD_ERR_NOT_SUPPORTED: - venc_status = VEN_S_ENOTSUPP; - break; - case VCD_ERR_BAD_STATE: - venc_status = VEN_S_EINVALSTATE; - break; - case VCD_ERR_MAX_CLIENT: - venc_status = VEN_S_ENOHWRES; - break; - default: - venc_status = VEN_S_EFAIL; - break; - } - return venc_status; -} - -static void vid_enc_notify_client(struct video_client_ctx *client_ctx) -{ - if (client_ctx) - complete(&client_ctx->event); -} - -void vid_enc_vcd_open_done(struct video_client_ctx *client_ctx, - struct vcd_handle_container *handle_container) -{ - DBG("vid_enc_vcd_open_done\n"); - - if (client_ctx) { - if (handle_container) - client_ctx->vcd_handle = handle_container->handle; - else - ERR("%s(): ERROR. handle_container is NULL\n", - __func__); - vid_enc_notify_client(client_ctx); - } else - ERR("%s(): ERROR. client_ctx is NULL\n", - __func__); -} - -static void vid_enc_input_frame_done(struct video_client_ctx *client_ctx, - u32 event, u32 status, - struct vcd_frame_data *vcd_frame_data) -{ - struct vid_enc_msg *venc_msg; - - if (!client_ctx || !vcd_frame_data) { - ERR("vid_enc_input_frame_done() NULL pointer\n"); - return; - } - - venc_msg = kzalloc(sizeof(struct vid_enc_msg), - GFP_KERNEL); - if (!venc_msg) { - ERR("vid_enc_input_frame_done(): cannot allocate vid_enc_msg " - " buffer\n"); - return; - } - - venc_msg->venc_msg_info.statuscode = vid_enc_get_status(status); - - venc_msg->venc_msg_info.msgcode = VEN_MSG_INPUT_BUFFER_DONE; - - switch (event) { - case VCD_EVT_RESP_INPUT_DONE: - DBG("Send INPUT_DON message to client = %p\n", - client_ctx); - break; - case VCD_EVT_RESP_INPUT_FLUSHED: - DBG("Send INPUT_FLUSHED message to client = %p\n", - client_ctx); - break; - default: - ERR("vid_enc_input_frame_done(): invalid event type: " - "%d\n", event); - venc_msg->venc_msg_info.statuscode = VEN_S_EFATAL; - break; - } - - venc_msg->venc_msg_info.buf.clientdata = - (void *)vcd_frame_data->frm_clnt_data; - venc_msg->venc_msg_info.msgdata_size = - sizeof(struct vid_enc_msg); - - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&venc_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - wake_up(&client_ctx->msg_wait); -} - -static void vid_enc_output_frame_done(struct video_client_ctx *client_ctx, - u32 event, u32 status, - struct vcd_frame_data *vcd_frame_data) -{ - struct vid_enc_msg *venc_msg; - unsigned long kernel_vaddr, phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - u32 ion_flag = 0; - struct ion_handle *buff_handle = NULL; - - if (!client_ctx || !vcd_frame_data) { - ERR("vid_enc_input_frame_done() NULL pointer\n"); - return; - } - - venc_msg = kzalloc(sizeof(struct vid_enc_msg), - GFP_KERNEL); - if (!venc_msg) { - ERR("vid_enc_input_frame_done(): cannot allocate vid_enc_msg " - " buffer\n"); - return; - } - - venc_msg->venc_msg_info.statuscode = vid_enc_get_status(status); - venc_msg->venc_msg_info.msgcode = VEN_MSG_OUTPUT_BUFFER_DONE; - - switch (event) { - case VCD_EVT_RESP_OUTPUT_DONE: - DBG("Send OUTPUT_DON message to client = %p\n", - client_ctx); - break; - case VCD_EVT_RESP_OUTPUT_FLUSHED: - DBG("Send OUTPUT_FLUSHED message to client = %p\n", - client_ctx); - break; - default: - ERR("vid_enc_output_frame_done: invalid cmd type: %d\n", event); - venc_msg->venc_msg_info.statuscode = VEN_S_EFATAL; - break; - } - - kernel_vaddr = - (unsigned long)vcd_frame_data->virtual; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - false, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index)) { - - /* Buffer address in user space */ - venc_msg->venc_msg_info.buf.ptrbuffer = (u8 *) user_vaddr; - /* Buffer address in user space */ - venc_msg->venc_msg_info.buf.clientdata = (void *) - vcd_frame_data->frm_clnt_data; - /* Data length */ - venc_msg->venc_msg_info.buf.len = - vcd_frame_data->data_len; - venc_msg->venc_msg_info.buf.flags = - vcd_frame_data->flags; - /* Timestamp pass-through from input frame */ - venc_msg->venc_msg_info.buf.timestamp = - vcd_frame_data->time_stamp; - venc_msg->venc_msg_info.buf.sz = - vcd_frame_data->alloc_len; - - /* Decoded picture width and height */ - venc_msg->venc_msg_info.msgdata_size = - sizeof(struct venc_buffer); - } else { - ERR("vid_enc_output_frame_done UVA can not be found\n"); - venc_msg->venc_msg_info.statuscode = - VEN_S_EFATAL; - } - if (venc_msg->venc_msg_info.buf.len > 0) { - ion_flag = vidc_get_fd_info(client_ctx, BUFFER_TYPE_OUTPUT, - pmem_fd, kernel_vaddr, buffer_index, - &buff_handle); - if (ion_flag == ION_FLAG_CACHED && buff_handle) { - msm_ion_do_cache_op(client_ctx->user_ion_client, - buff_handle, - (unsigned long *) kernel_vaddr, - (unsigned long)venc_msg->venc_msg_info.buf.sz, - ION_IOC_CLEAN_INV_CACHES); - } - } - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&venc_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - wake_up(&client_ctx->msg_wait); -} - -static void vid_enc_lean_event(struct video_client_ctx *client_ctx, - u32 event, u32 status) -{ - struct vid_enc_msg *venc_msg; - if (!client_ctx) { - ERR("%s(): !client_ctx pointer\n", - __func__); - return; - } - - venc_msg = kzalloc(sizeof(struct vid_enc_msg), - GFP_KERNEL); - if (!venc_msg) { - ERR("%s(): cannot allocate vid_enc_msg buffer\n", - __func__); - return; - } - - venc_msg->venc_msg_info.statuscode = - vid_enc_get_status(status); - - switch (event) { - case VCD_EVT_RESP_FLUSH_INPUT_DONE: - INFO("\n msm_vidc_enc: Sending VCD_EVT_RESP_FLUSH_INPUT_DONE" - " to client"); - venc_msg->venc_msg_info.msgcode = - VEN_MSG_FLUSH_INPUT_DONE; - break; - case VCD_EVT_RESP_FLUSH_OUTPUT_DONE: - INFO("\n msm_vidc_enc: Sending VCD_EVT_RESP_FLUSH_OUTPUT_DONE" - " to client"); - venc_msg->venc_msg_info.msgcode = - VEN_MSG_FLUSH_OUPUT_DONE; - break; - - case VCD_EVT_RESP_START: - INFO("\n msm_vidc_enc: Sending VCD_EVT_RESP_START" - " to client"); - venc_msg->venc_msg_info.msgcode = - VEN_MSG_START; - break; - - case VCD_EVT_RESP_STOP: - INFO("\n msm_vidc_enc: Sending VCD_EVT_RESP_STOP" - " to client"); - venc_msg->venc_msg_info.msgcode = - VEN_MSG_STOP; - break; - - case VCD_EVT_RESP_PAUSE: - INFO("\n msm_vidc_enc: Sending VCD_EVT_RESP_PAUSE" - " to client"); - venc_msg->venc_msg_info.msgcode = - VEN_MSG_PAUSE; - break; - case VCD_EVT_IND_INFO_LTRUSE_FAILED: - INFO("\n msm_vidc_enc: Sending VEN_MSG_LTRUSE_FAILED"\ - " to client"); - venc_msg->venc_msg_info.msgcode = - VEN_MSG_LTRUSE_FAILED; - break; - - default: - ERR("%s() : unknown event type %u\n", - __func__, event); - break; - } - - venc_msg->venc_msg_info.msgdata_size = 0; - - mutex_lock(&client_ctx->msg_queue_lock); - list_add_tail(&venc_msg->list, &client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - wake_up(&client_ctx->msg_wait); -} - - -void vid_enc_vcd_cb(u32 event, u32 status, - void *info, size_t sz, void *handle, - void *const client_data) -{ - struct video_client_ctx *client_ctx = - (struct video_client_ctx *)client_data; - - DBG("Entering %s()\n", __func__); - - if (!client_ctx) { - ERR("%s(): client_ctx is NULL\n", __func__); - return; - } - - client_ctx->event_status = status; - - switch (event) { - case VCD_EVT_RESP_OPEN: - vid_enc_vcd_open_done(client_ctx, - (struct vcd_handle_container *)info); - break; - - case VCD_EVT_RESP_INPUT_DONE: - case VCD_EVT_RESP_INPUT_FLUSHED: - vid_enc_input_frame_done(client_ctx, event, - status, (struct vcd_frame_data *)info); - break; - - case VCD_EVT_RESP_OUTPUT_DONE: - case VCD_EVT_RESP_OUTPUT_FLUSHED: - vid_enc_output_frame_done(client_ctx, event, status, - (struct vcd_frame_data *)info); - break; - - case VCD_EVT_RESP_PAUSE: - case VCD_EVT_RESP_START: - case VCD_EVT_RESP_STOP: - case VCD_EVT_RESP_FLUSH_INPUT_DONE: - case VCD_EVT_RESP_FLUSH_OUTPUT_DONE: - case VCD_EVT_IND_OUTPUT_RECONFIG: - case VCD_EVT_IND_HWERRFATAL: - case VCD_EVT_IND_RESOURCES_LOST: - case VCD_EVT_IND_INFO_LTRUSE_FAILED: - vid_enc_lean_event(client_ctx, event, status); - break; - - default: - ERR("%s() : Error - Invalid event type =%u\n", - __func__, event); - break; - } -} - -static u32 vid_enc_msg_pending(struct video_client_ctx *client_ctx) -{ - u32 islist_empty = 0; - - mutex_lock(&client_ctx->msg_queue_lock); - islist_empty = list_empty(&client_ctx->msg_queue); - mutex_unlock(&client_ctx->msg_queue_lock); - - if (islist_empty) { - DBG("%s(): vid_enc msg queue empty\n", - __func__); - if (client_ctx->stop_msg) { - DBG("%s(): List empty and Stop Msg set\n", - __func__); - return client_ctx->stop_msg; - } - } else - DBG("%s(): vid_enc msg queue Not empty\n", - __func__); - - return !islist_empty; -} - -static int vid_enc_get_next_msg(struct video_client_ctx *client_ctx, - struct venc_msg *venc_msg_info) -{ - int rc; - struct vid_enc_msg *vid_enc_msg = NULL; - - if (!client_ctx) - return -EIO; - - rc = wait_event_interruptible(client_ctx->msg_wait, - vid_enc_msg_pending(client_ctx)); - - if (rc < 0) { - DBG("rc = %d,stop_msg= %u\n", rc, client_ctx->stop_msg); - return rc; - } else if (client_ctx->stop_msg) { - DBG("stopped stop_msg = %u\n", client_ctx->stop_msg); - return -EIO; - } - - mutex_lock(&client_ctx->msg_queue_lock); - - if (!list_empty(&client_ctx->msg_queue)) { - DBG("%s(): After Wait\n", __func__); - vid_enc_msg = list_first_entry(&client_ctx->msg_queue, - struct vid_enc_msg, list); - list_del(&vid_enc_msg->list); - memcpy(venc_msg_info, &vid_enc_msg->venc_msg_info, - sizeof(struct venc_msg)); - kfree(vid_enc_msg); - } - mutex_unlock(&client_ctx->msg_queue_lock); - return 0; -} - -static u32 vid_enc_close_client(struct video_client_ctx *client_ctx) -{ - struct vid_enc_msg *vid_enc_msg = NULL; - u32 vcd_status; - int rc; - - INFO("\n msm_vidc_enc: Inside %s()", __func__); - if (!client_ctx || (!client_ctx->vcd_handle)) { - ERR("\n %s(): Invalid client_ctx", __func__); - return false; - } - - mutex_lock(&vid_enc_device_p->lock); - - if (!client_ctx->stop_called) { - vcd_status = vcd_stop(client_ctx->vcd_handle); - DBG("Waiting for VCD_STOP: Before Timeout\n"); - if (!vcd_status) { - rc = wait_for_completion_timeout(&client_ctx->event, - 5 * HZ); - if (!rc) { - ERR("%s:ERROR vcd_stop time out" - "rc = %d\n", __func__, rc); - } - - if (client_ctx->event_status) { - ERR("%s:ERROR " - "vcd_stop Not successs\n", __func__); - } - } - } - DBG("VCD_STOPPED: After Timeout, calling VCD_CLOSE\n"); - mutex_lock(&client_ctx->msg_queue_lock); - while (!list_empty(&client_ctx->msg_queue)) { - DBG("%s(): Delete remaining entries\n", __func__); - vid_enc_msg = list_first_entry(&client_ctx->msg_queue, - struct vid_enc_msg, list); - list_del(&vid_enc_msg->list); - kfree(vid_enc_msg); - } - mutex_unlock(&client_ctx->msg_queue_lock); - vcd_status = vcd_close(client_ctx->vcd_handle); - - if (vcd_status) { - mutex_unlock(&vid_enc_device_p->lock); - return false; - } - memset((void *)client_ctx, 0, - sizeof(struct video_client_ctx)); - - vid_enc_device_p->num_clients--; - client_ctx->stop_called = 0; - mutex_unlock(&vid_enc_device_p->lock); - return true; -} - -static int vid_enc_open_client(struct video_client_ctx **vid_clnt_ctx, - int flags) -{ - s32 client_index; - struct video_client_ctx *client_ctx; - int rc = 0; - u8 client_count = 0; - - INFO("\n msm_vidc_enc: Inside %s()", __func__); - if (!vid_clnt_ctx) { - ERR("Invalid input\n"); - rc = -EINVAL; - goto client_failure; - } - *vid_clnt_ctx = NULL; - client_count = vcd_get_num_of_clients(); - if (client_count == VIDC_MAX_NUM_CLIENTS) { - ERR("ERROR : vid_enc_open() max number of clients\n"); - rc = -ENODEV; - goto client_failure; - } - - DBG(" Virtual Address of ioremap is %p\n", vid_enc_device_p->virt_base); - if (!vid_enc_device_p->num_clients) { - if (!vidc_load_firmware()) { - rc = -ENODEV; - goto client_failure; - } - } - - client_index = vid_enc_get_empty_client_index(); - - if (client_index < 0) { - ERR("%s() : No free clients client_index == -1\n", - __func__); - rc = -ENODEV; - goto client_failure; - } - - client_ctx = - &vid_enc_device_p->venc_clients[client_index]; - vid_enc_device_p->num_clients++; - - init_completion(&client_ctx->event); - mutex_init(&client_ctx->msg_queue_lock); - mutex_init(&client_ctx->enrty_queue_lock); - INIT_LIST_HEAD(&client_ctx->msg_queue); - init_waitqueue_head(&client_ctx->msg_wait); - if (vcd_get_ion_status()) { - client_ctx->user_ion_client = vcd_get_ion_client(); - if (!client_ctx->user_ion_client) { - ERR("vcd_open ion get client failed"); - rc = -EFAULT; - goto client_failure; - } - } - rc = vcd_open(vid_enc_device_p->device_handle, false, - vid_enc_vcd_cb, client_ctx, flags); - client_ctx->stop_msg = 0; - client_ctx->stop_called = 1; - - if (!rc) { - wait_for_completion(&client_ctx->event); - if (client_ctx->event_status) { - ERR("callback for vcd_open returned error: %u", - client_ctx->event_status); - rc = -EFAULT; - goto client_failure; - } - } else { - ERR("vcd_open returned error: %u", rc); - goto client_failure; - } - *vid_clnt_ctx = client_ctx; -client_failure: - return rc; -} -static int vid_enc_open(struct inode *inode, struct file *file) -{ - int rc = 0; - struct video_client_ctx *client_ctx = NULL; - INFO("msm_vidc_venc: Inside %s()", __func__); - mutex_lock(&vid_enc_device_p->lock); - rc = vid_enc_open_client(&client_ctx, 0); - if (rc) - pr_err("%s() open failed rc=%d\n", __func__, rc); - else if (!client_ctx) { - pr_err("%s() client_ctx is NULL\n", __func__); - rc = -ENOMEM; - } - if (!rc) - file->private_data = client_ctx; - mutex_unlock(&vid_enc_device_p->lock); - return rc; -} - -static int vid_enc_release(struct inode *inode, struct file *file) -{ - struct video_client_ctx *client_ctx = file->private_data; - INFO("\n msm_vidc_enc: Inside %s()", __func__); - vid_enc_close_client(client_ctx); - vidc_release_firmware(); -#ifndef USE_RES_TRACKER - vidc_disable_clk(); -#endif - INFO("\n msm_vidc_enc: Return from %s()", __func__); - return 0; -} -static int vid_enc_open_secure(struct inode *inode, struct file *file) -{ - int rc = 0, vcd_status = 0; - struct video_client_ctx *client_ctx = NULL; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_sps_pps_for_idr_enable idr_enable; - - INFO("msm_vidc_enc: Inside %s()", __func__); - mutex_lock(&vid_enc_device_p->lock); - rc = vid_enc_open_client(&client_ctx, VCD_CP_SESSION); - if (rc || !client_ctx) { - pr_err("%s() open failed rc=%d\n", __func__, rc); - if (!client_ctx) - rc = -ENOMEM; - goto error; - } - file->private_data = client_ctx; - vcd_property_hdr.prop_id = VCD_I_ENABLE_SPS_PPS_FOR_IDR; - vcd_property_hdr.sz = - sizeof(struct vcd_property_sps_pps_for_idr_enable); - idr_enable.sps_pps_for_idr_enable_flag = 1; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &idr_enable); - if (vcd_status) { - ERR("Setting SPS with IDR failed\n"); - rc = -EACCES; - goto close_client; - } - - if (res_trk_open_secure_session()) { - rc = -EACCES; - goto close_client; - } - mutex_unlock(&vid_enc_device_p->lock); - return rc; - -close_client: - vid_enc_close_client(client_ctx); - ERR("Secure session operation failure\n"); -error: - mutex_unlock(&vid_enc_device_p->lock); - return rc; -} -static const struct file_operations vid_enc_fops[NUM_OF_DRIVER_NODES] = { - { - .owner = THIS_MODULE, - .open = vid_enc_open, - .release = vid_enc_release, - .unlocked_ioctl = vid_enc_ioctl, - }, - { - .owner = THIS_MODULE, - .open = vid_enc_open_secure, - .release = vid_enc_release, - .unlocked_ioctl = vid_enc_ioctl, - }, -}; - -void vid_enc_interrupt_deregister(void) -{ -} - -void vid_enc_interrupt_register(void *device_name) -{ -} - -void vid_enc_interrupt_clear(void) -{ -} - -void *vid_enc_map_dev_base_addr(void *device_name) -{ - return vid_enc_device_p->virt_base; -} - -static int vid_enc_vcd_init(void) -{ - int rc; - struct vcd_init_config vcd_init_config; - u32 i; - - INFO("\n msm_vidc_enc: Inside %s()", __func__); - vid_enc_device_p->num_clients = 0; - - for (i = 0; i < VIDC_MAX_NUM_CLIENTS; i++) { - memset((void *)&vid_enc_device_p->venc_clients[i], 0, - sizeof(vid_enc_device_p->venc_clients[i])); - } - - mutex_init(&vid_enc_device_p->lock); - vid_enc_device_p->virt_base = vidc_get_ioaddr(); - - if (!vid_enc_device_p->virt_base) { - ERR("%s() : ioremap failed\n", __func__); - return -ENOMEM; - } - - vcd_init_config.device_name = "VIDC"; - vcd_init_config.map_dev_base_addr = - vid_enc_map_dev_base_addr; - vcd_init_config.interrupt_clr = - vid_enc_interrupt_clear; - vcd_init_config.register_isr = - vid_enc_interrupt_register; - vcd_init_config.deregister_isr = - vid_enc_interrupt_deregister; - - rc = vcd_init(&vcd_init_config, - &vid_enc_device_p->device_handle); - - if (rc) { - ERR("%s() : vcd_init failed\n", - __func__); - return -ENODEV; - } - return 0; -} - -static int __init vid_enc_init(void) -{ - int rc = 0, i = 0, j = 0; - struct device *class_devp; - - INFO("\n msm_vidc_enc: Inside %s()", __func__); - vid_enc_device_p = kzalloc(sizeof(struct vid_enc_dev), - GFP_KERNEL); - if (!vid_enc_device_p) { - ERR("%s Unable to allocate memory for vid_enc_dev\n", - __func__); - return -ENOMEM; - } - rc = alloc_chrdev_region(&vid_enc_dev_num, 0, NUM_OF_DRIVER_NODES, - VID_ENC_NAME); - if (rc < 0) { - ERR("%s: alloc_chrdev_region Failed rc = %d\n", - __func__, rc); - goto error_vid_enc_alloc_chrdev_region; - } - vid_enc_class = class_create(THIS_MODULE, VID_ENC_NAME); - if (IS_ERR(vid_enc_class)) { - rc = PTR_ERR(vid_enc_class); - ERR("%s: couldn't create vid_enc_class rc = %d\n", - __func__, rc); - goto error_vid_enc_class_create; - } - for (i = 0; i < NUM_OF_DRIVER_NODES; i++) { - class_devp = device_create(vid_enc_class, NULL, - (vid_enc_dev_num + i), NULL, - VID_ENC_NAME "%s", node_name[i]); - - if (IS_ERR(class_devp)) { - rc = PTR_ERR(class_devp); - ERR("%s: class device_create failed %d\n", - __func__, rc); - if (!i) - goto error_vid_enc_class_device_create; - else - goto error_vid_enc_cdev_add; - } - - vid_enc_device_p->device[i] = class_devp; - - cdev_init(&vid_enc_device_p->cdev[i], &vid_enc_fops[i]); - vid_enc_device_p->cdev[i].owner = THIS_MODULE; - rc = cdev_add(&(vid_enc_device_p->cdev[i]), - (vid_enc_dev_num + i), 1); - - if (rc < 0) { - ERR("%s: cdev_add failed %d\n", - __func__, rc); - goto error_vid_enc_cdev_add; - } - } - vid_enc_vcd_init(); - return 0; - -error_vid_enc_cdev_add: - for (j = i-1; j >= 0; j--) - cdev_del(&(vid_enc_device_p->cdev[j])); - device_destroy(vid_enc_class, vid_enc_dev_num); -error_vid_enc_class_device_create: - class_destroy(vid_enc_class); -error_vid_enc_class_create: - unregister_chrdev_region(vid_enc_dev_num, 1); -error_vid_enc_alloc_chrdev_region: - kfree(vid_enc_device_p); - - return rc; -} - -static void __exit vid_enc_exit(void) -{ - int i = 0; - INFO("\n msm_vidc_enc: Inside %s()", __func__); - for (i = 0; i < NUM_OF_DRIVER_NODES; i++) - cdev_del(&(vid_enc_device_p->cdev[i])); - device_destroy(vid_enc_class, vid_enc_dev_num); - class_destroy(vid_enc_class); - unregister_chrdev_region(vid_enc_dev_num, 1); - kfree(vid_enc_device_p); - INFO("\n msm_vidc_enc: Return from %s()", __func__); -} -static long vid_enc_ioctl(struct file *file, - unsigned cmd, unsigned long u_arg) -{ - struct video_client_ctx *client_ctx = NULL; - struct venc_ioctl_msg venc_msg; - void __user *arg = (void __user *)u_arg; - u32 result = true; - int result_read = -1; - - DBG("%s\n", __func__); - - client_ctx = (struct video_client_ctx *)file->private_data; - if (!client_ctx) { - ERR("!client_ctx. Cannot attach to device handle\n"); - return -ENODEV; - } - - switch (cmd) { - case VEN_IOCTL_CMD_READ_NEXT_MSG: - { - struct venc_msg cb_msg; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_CMD_READ_NEXT_MSG\n"); - result_read = vid_enc_get_next_msg(client_ctx, &cb_msg); - if (result_read < 0) - return result_read; - if (copy_to_user(venc_msg.out, &cb_msg, sizeof(cb_msg))) - return -EFAULT; - break; - } - case VEN_IOCTL_CMD_STOP_READ_MSG: - { - DBG("VEN_IOCTL_CMD_STOP_READ_MSG\n"); - client_ctx->stop_msg = 1; - wake_up(&client_ctx->msg_wait); - break; - } - case VEN_IOCTL_CMD_ENCODE_FRAME: - case VEN_IOCTL_CMD_FILL_OUTPUT_BUFFER: - { - struct venc_buffer enc_buffer; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (copy_from_user(&enc_buffer, venc_msg.in, - sizeof(enc_buffer))) - return -EFAULT; - if (cmd == VEN_IOCTL_CMD_ENCODE_FRAME) { - DBG("VEN_IOCTL_CMD_ENCODE_FRAME\n"); - result = vid_enc_encode_frame(client_ctx, - &enc_buffer); - } else { - DBG("VEN_IOCTL_CMD_FILL_OUTPUT_BUFFER\n"); - result = vid_enc_fill_output_buffer(client_ctx, - &enc_buffer); - } - if (!result) { - DBG("\n VEN_IOCTL_CMD_ENCODE_FRAME/" - "VEN_IOCTL_CMD_FILL_OUTPUT_BUFFER failed"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_INPUT_BUFFER: - case VEN_IOCTL_SET_OUTPUT_BUFFER: - { - enum venc_buffer_dir buffer_dir; - struct venc_bufferpayload buffer_info; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_SET_INPUT_BUFFER/VEN_IOCTL_SET_OUTPUT_BUFFER\n"); - if (copy_from_user(&buffer_info, venc_msg.in, - sizeof(buffer_info))) - return -EFAULT; - buffer_dir = VEN_BUFFER_TYPE_INPUT; - if (cmd == VEN_IOCTL_SET_OUTPUT_BUFFER) - buffer_dir = VEN_BUFFER_TYPE_OUTPUT; - result = vid_enc_set_buffer(client_ctx, &buffer_info, - buffer_dir); - if (!result) { - DBG("\n VEN_IOCTL_SET_INPUT_BUFFER" - "/VEN_IOCTL_SET_OUTPUT_BUFFER failed"); - return -EIO; - } - break; - } - case VEN_IOCTL_CMD_FREE_INPUT_BUFFER: - case VEN_IOCTL_CMD_FREE_OUTPUT_BUFFER: - { - enum venc_buffer_dir buffer_dir; - struct venc_bufferpayload buffer_info; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - DBG("VEN_IOCTL_CMD_FREE_INPUT_BUFFER/" - "VEN_IOCTL_CMD_FREE_OUTPUT_BUFFER\n"); - - if (copy_from_user(&buffer_info, venc_msg.in, - sizeof(buffer_info))) - return -EFAULT; - - buffer_dir = VEN_BUFFER_TYPE_INPUT; - if (cmd == VEN_IOCTL_CMD_FREE_OUTPUT_BUFFER) - buffer_dir = VEN_BUFFER_TYPE_OUTPUT; - - result = vid_enc_free_buffer(client_ctx, &buffer_info, - buffer_dir); - if (!result) { - DBG("\n VEN_IOCTL_CMD_FREE_OUTPUT_BUFFER" - "/VEN_IOCTL_CMD_FREE_OUTPUT_BUFFER failed"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_INPUT_BUFFER_REQ: - case VEN_IOCTL_SET_OUTPUT_BUFFER_REQ: - { - struct venc_allocatorproperty allocatorproperty; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - if (copy_from_user(&allocatorproperty, venc_msg.in, - sizeof(allocatorproperty))) - return -EFAULT; - - if (cmd == VEN_IOCTL_SET_OUTPUT_BUFFER_REQ) { - DBG("VEN_IOCTL_SET_OUTPUT_BUFFER_REQ\n"); - result = vid_enc_set_buffer_req(client_ctx, - &allocatorproperty, false); - } else { - DBG("VEN_IOCTL_SET_INPUT_BUFFER_REQ\n"); - result = vid_enc_set_buffer_req(client_ctx, - &allocatorproperty, true); - } - if (!result) { - DBG("setting VEN_IOCTL_SET_OUTPUT_BUFFER_REQ/" - "VEN_IOCTL_SET_INPUT_BUFFER_REQ failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_GET_INPUT_BUFFER_REQ: - case VEN_IOCTL_GET_OUTPUT_BUFFER_REQ: - { - struct venc_allocatorproperty allocatorproperty; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - if (cmd == VEN_IOCTL_GET_OUTPUT_BUFFER_REQ) { - DBG("VEN_IOCTL_GET_OUTPUT_BUFFER_REQ\n"); - result = vid_enc_get_buffer_req(client_ctx, - &allocatorproperty, false); - } else { - DBG("VEN_IOCTL_GET_INPUT_BUFFER_REQ\n"); - result = vid_enc_get_buffer_req(client_ctx, - &allocatorproperty, true); - } - if (!result) - return -EIO; - if (copy_to_user(venc_msg.out, &allocatorproperty, - sizeof(allocatorproperty))) - return -EFAULT; - break; - } - case VEN_IOCTL_CMD_FLUSH: - { - struct venc_bufferflush bufferflush; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - DBG("VEN_IOCTL_CMD_FLUSH\n"); - if (copy_from_user(&bufferflush, venc_msg.in, - sizeof(bufferflush))) - return -EFAULT; - INFO("\n %s(): Calling vid_enc_flush with mode = %lu", - __func__, bufferflush.flush_mode); - result = vid_enc_flush(client_ctx, &bufferflush); - - if (!result) { - ERR("setting VEN_IOCTL_CMD_FLUSH failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_CMD_START: - { - INFO("\n %s(): Executing VEN_IOCTL_CMD_START", __func__); - result = vid_enc_start_stop(client_ctx, true); - if (!result) { - ERR("setting VEN_IOCTL_CMD_START failed\n"); - return -EIO; - } else - client_ctx->stop_called = 0; - break; - } - case VEN_IOCTL_CMD_STOP: - { - INFO("\n %s(): Executing VEN_IOCTL_CMD_STOP", __func__); - result = vid_enc_start_stop(client_ctx, false); - if (!result) { - ERR("setting VEN_IOCTL_CMD_STOP failed\n"); - return -EIO; - } - client_ctx->stop_called = 1; - break; - } - case VEN_IOCTL_CMD_PAUSE: - { - INFO("\n %s(): Executing VEN_IOCTL_CMD_PAUSE", __func__); - result = vid_enc_pause_resume(client_ctx, true); - if (!result) { - ERR("setting VEN_IOCTL_CMD_PAUSE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_CMD_RESUME: - { - INFO("\n %s(): Executing VEN_IOCTL_CMD_RESUME", __func__); - result = vid_enc_pause_resume(client_ctx, false); - if (!result) { - ERR("setting VEN_IOCTL_CMD_RESUME failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_RECON_BUFFER: - { - struct venc_recon_addr venc_recon; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_SET_RECON_BUFFER\n"); - if (copy_from_user(&venc_recon, venc_msg.in, - sizeof(venc_recon))) - return -EFAULT; - result = vid_enc_set_recon_buffers(client_ctx, - &venc_recon); - if (!result) { - ERR("setting VEN_IOCTL_SET_RECON_BUFFER failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_FREE_RECON_BUFFER: - { - struct venc_recon_addr venc_recon; - DBG("VEN_IOCTL_FREE_RECON_BUFFER\n"); - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (copy_from_user(&venc_recon, venc_msg.in, - sizeof(venc_recon))) - return -EFAULT; - result = vid_enc_free_recon_buffers(client_ctx, - &venc_recon); - if (!result) { - ERR("VEN_IOCTL_FREE_RECON_BUFFER failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_GET_RECON_BUFFER_SIZE: - { - struct venc_recon_buff_size venc_recon_size; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_GET_RECON_BUFFER_SIZE\n"); - if (copy_from_user(&venc_recon_size, venc_msg.out, - sizeof(venc_recon_size))) - return -EFAULT; - result = vid_enc_get_recon_buffer_size(client_ctx, - &venc_recon_size); - if (result) { - if (copy_to_user(venc_msg.out, &venc_recon_size, - sizeof(venc_recon_size))) - return -EFAULT; - } else { - ERR("setting VEN_IOCTL_GET_RECON_BUFFER_SIZE" - "failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_QP_RANGE: - case VEN_IOCTL_GET_QP_RANGE: - { - struct venc_qprange qprange; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_G(S)ET_QP_RANGE\n"); - if (cmd == VEN_IOCTL_SET_QP_RANGE) { - if (copy_from_user(&qprange, venc_msg.in, - sizeof(qprange))) - return -EFAULT; - result = vid_enc_set_get_qprange(client_ctx, - &qprange, true); - } else { - result = vid_enc_set_get_qprange(client_ctx, - &qprange, false); - if (result) { - if (copy_to_user(venc_msg.out, &qprange, - sizeof(qprange))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_G(S)ET_QP_RANGE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_HEC: - case VEN_IOCTL_GET_HEC: - { - struct venc_headerextension headerextension; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_HEC\n"); - if (cmd == VEN_IOCTL_SET_HEC) { - if (copy_from_user(&headerextension, venc_msg.in, - sizeof(headerextension))) - return -EFAULT; - - result = vid_enc_set_get_headerextension(client_ctx, - &headerextension, true); - } else { - result = vid_enc_set_get_headerextension(client_ctx, - &headerextension, false); - if (result) { - if (copy_to_user(venc_msg.out, &headerextension, - sizeof(headerextension))) - return -EFAULT; - } - } - - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_HEC failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_TARGET_BITRATE: - case VEN_IOCTL_GET_TARGET_BITRATE: - { - struct venc_targetbitrate targetbitrate; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_TARGET_BITRATE\n"); - if (cmd == VEN_IOCTL_SET_TARGET_BITRATE) { - if (copy_from_user(&targetbitrate, venc_msg.in, - sizeof(targetbitrate))) - return -EFAULT; - - result = vid_enc_set_get_bitrate(client_ctx, - &targetbitrate, true); - } else { - result = vid_enc_set_get_bitrate(client_ctx, - &targetbitrate, false); - if (result) { - if (copy_to_user(venc_msg.out, &targetbitrate, - sizeof(targetbitrate))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_TARGET_BITRATE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_FRAME_RATE: - case VEN_IOCTL_GET_FRAME_RATE: - { - struct venc_framerate framerate; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_FRAME_RATE\n"); - if (cmd == VEN_IOCTL_SET_FRAME_RATE) { - if (copy_from_user(&framerate, venc_msg.in, - sizeof(framerate))) - return -EFAULT; - result = vid_enc_set_get_framerate(client_ctx, - &framerate, true); - } else { - result = vid_enc_set_get_framerate(client_ctx, - &framerate, false); - if (result) { - if (copy_to_user(venc_msg.out, &framerate, - sizeof(framerate))) - return -EFAULT; - } - } - - if (!result) { - ERR("VEN_IOCTL_(G)SET_FRAME_RATE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_VOP_TIMING_CFG: - case VEN_IOCTL_GET_VOP_TIMING_CFG: - { - struct venc_voptimingcfg voptimingcfg; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - DBG("VEN_IOCTL_(G)SET_VOP_TIMING_CFG\n"); - if (cmd == VEN_IOCTL_SET_VOP_TIMING_CFG) { - if (copy_from_user(&voptimingcfg, venc_msg.in, - sizeof(voptimingcfg))) - return -EFAULT; - result = vid_enc_set_get_voptimingcfg(client_ctx, - &voptimingcfg, true); - } else { - result = vid_enc_set_get_voptimingcfg(client_ctx, - &voptimingcfg, false); - if (result) { - if (copy_to_user(venc_msg.out, &voptimingcfg, - sizeof(voptimingcfg))) - return -EFAULT; - } - } - if (!result) { - ERR("VEN_IOCTL_(G)SET_VOP_TIMING_CFG failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_RATE_CTRL_CFG: - case VEN_IOCTL_GET_RATE_CTRL_CFG: - { - struct venc_ratectrlcfg ratectrlcfg; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_RATE_CTRL_CFG\n"); - if (cmd == VEN_IOCTL_SET_RATE_CTRL_CFG) { - if (copy_from_user(&ratectrlcfg, venc_msg.in, - sizeof(ratectrlcfg))) - return -EFAULT; - - result = vid_enc_set_get_ratectrlcfg(client_ctx, - &ratectrlcfg, true); - } else { - result = vid_enc_set_get_ratectrlcfg(client_ctx, - &ratectrlcfg, false); - if (result) { - if (copy_to_user(venc_msg.out, &ratectrlcfg, - sizeof(ratectrlcfg))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_RATE_CTRL_CFG failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_MULTI_SLICE_CFG: - case VEN_IOCTL_GET_MULTI_SLICE_CFG: - { - struct venc_multiclicecfg multiclicecfg; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_MULTI_SLICE_CFG\n"); - if (cmd == VEN_IOCTL_SET_MULTI_SLICE_CFG) { - if (copy_from_user(&multiclicecfg, venc_msg.in, - sizeof(multiclicecfg))) - return -EFAULT; - - result = vid_enc_set_get_multiclicecfg(client_ctx, - &multiclicecfg, true); - } else { - result = vid_enc_set_get_multiclicecfg(client_ctx, - &multiclicecfg, false); - if (result) { - if (copy_to_user(venc_msg.out, &multiclicecfg, - sizeof(multiclicecfg))) - return -EFAULT; - } - } - if (!result) { - ERR("VEN_IOCTL_(G)SET_MULTI_SLICE_CFG failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_INTRA_REFRESH: - case VEN_IOCTL_GET_INTRA_REFRESH: - { - struct venc_intrarefresh intrarefresh; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_INTRA_REFRESH\n"); - if (cmd == VEN_IOCTL_SET_INTRA_REFRESH) { - if (copy_from_user(&intrarefresh, venc_msg.in, - sizeof(intrarefresh))) - return -EFAULT; - result = vid_enc_set_get_intrarefresh(client_ctx, - &intrarefresh, true); - } else { - result = vid_enc_set_get_intrarefresh(client_ctx, - &intrarefresh, false); - if (result) { - if (copy_to_user(venc_msg.out, &intrarefresh, - sizeof(intrarefresh))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_SET_INTRA_REFRESH failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_DEBLOCKING_CFG: - case VEN_IOCTL_GET_DEBLOCKING_CFG: - { - struct venc_dbcfg dbcfg; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - DBG("VEN_IOCTL_(G)SET_DEBLOCKING_CFG\n"); - if (cmd == VEN_IOCTL_SET_DEBLOCKING_CFG) { - if (copy_from_user(&dbcfg, venc_msg.in, - sizeof(dbcfg))) - return -EFAULT; - result = vid_enc_set_get_dbcfg(client_ctx, - &dbcfg, true); - } else { - result = vid_enc_set_get_dbcfg(client_ctx, - &dbcfg, false); - if (result) { - if (copy_to_user(venc_msg.out, &dbcfg, - sizeof(dbcfg))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_SET_DEBLOCKING_CFG failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_ENTROPY_CFG: - case VEN_IOCTL_GET_ENTROPY_CFG: - { - struct venc_entropycfg entropy_cfg; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_ENTROPY_CFG\n"); - if (cmd == VEN_IOCTL_SET_ENTROPY_CFG) { - if (copy_from_user(&entropy_cfg, venc_msg.in, - sizeof(entropy_cfg))) - return -EFAULT; - result = vid_enc_set_get_entropy_cfg(client_ctx, - &entropy_cfg, true); - } else { - result = vid_enc_set_get_entropy_cfg(client_ctx, - &entropy_cfg, false); - if (result) { - if (copy_to_user(venc_msg.out, &entropy_cfg, - sizeof(entropy_cfg))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_ENTROPY_CFG failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_GET_SEQUENCE_HDR: - { - struct venc_seqheader seq_header; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - if (copy_from_user(&seq_header, venc_msg.in, - sizeof(seq_header))) - return -EFAULT; - - DBG("VEN_IOCTL_GET_SEQUENCE_HDR\n"); - result = vid_enc_get_sequence_header(client_ctx, - &seq_header); - if (!result) { - ERR("get sequence header failed\n"); - return -EIO; - } - DBG("seq_header: buf=%x, sz=%d, hdrlen=%d\n", - (int)seq_header.hdrbufptr, - (int)seq_header.bufsize, - (int)seq_header.hdrlen); - if (copy_to_user(venc_msg.out, &seq_header, - sizeof(seq_header))) - return -EFAULT; - break; - } - case VEN_IOCTL_CMD_REQUEST_IFRAME: - { - DBG("VEN_IOCTL_CMD_REQUEST_IFRAME\n"); - result = vid_enc_request_iframe(client_ctx); - if (!result) { - ERR("setting VEN_IOCTL_CMD_REQUEST_IFRAME failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_INTRA_PERIOD: - case VEN_IOCTL_GET_INTRA_PERIOD: - { - struct venc_intraperiod intraperiod; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_INTRA_PERIOD\n"); - if (cmd == VEN_IOCTL_SET_INTRA_PERIOD) { - if (copy_from_user(&intraperiod, venc_msg.in, - sizeof(intraperiod))) - return -EFAULT; - result = vid_enc_set_get_intraperiod(client_ctx, - &intraperiod, true); - } else { - result = vid_enc_set_get_intraperiod(client_ctx, - &intraperiod, false); - if (result) { - if (copy_to_user(venc_msg.out, &intraperiod, - sizeof(intraperiod))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_INTRA_PERIOD failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_SESSION_QP: - case VEN_IOCTL_GET_SESSION_QP: - { - struct venc_sessionqp session_qp; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_(G)SET_SESSION_QP\n"); - if (cmd == VEN_IOCTL_SET_SESSION_QP) { - if (copy_from_user(&session_qp, venc_msg.in, - sizeof(session_qp))) - return -EFAULT; - result = vid_enc_set_get_session_qp(client_ctx, - &session_qp, true); - } else { - result = vid_enc_set_get_session_qp(client_ctx, - &session_qp, false); - if (result) { - if (copy_to_user(venc_msg.out, &session_qp, - sizeof(session_qp))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_SESSION_QP failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_PROFILE_LEVEL: - case VEN_IOCTL_GET_PROFILE_LEVEL: - { - struct ven_profilelevel profile_level; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - DBG("VEN_IOCTL_(G)SET_PROFILE_LEVEL\n"); - if (cmd == VEN_IOCTL_SET_PROFILE_LEVEL) { - if (copy_from_user(&profile_level, venc_msg.in, - sizeof(profile_level))) - return -EFAULT; - result = vid_enc_set_get_profile_level(client_ctx, - &profile_level, true); - } else { - result = vid_enc_set_get_profile_level(client_ctx, - &profile_level, false); - if (result) { - if (copy_to_user(venc_msg.out, - &profile_level, sizeof(profile_level))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_SET_PROFILE_LEVEL failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_CODEC_PROFILE: - case VEN_IOCTL_GET_CODEC_PROFILE: - { - struct venc_profile profile; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - DBG("VEN_IOCTL_(G)SET_CODEC_PROFILE\n"); - if (cmd == VEN_IOCTL_SET_CODEC_PROFILE) { - if (copy_from_user(&profile, venc_msg.in, - sizeof(profile))) - return -EFAULT; - result = vid_enc_set_get_profile(client_ctx, - &profile, true); - } else { - result = vid_enc_set_get_profile(client_ctx, - &profile, false); - if (result) { - if (copy_to_user(venc_msg.out, &profile, - sizeof(profile))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_SET_CODEC_PROFILE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_SHORT_HDR: - case VEN_IOCTL_GET_SHORT_HDR: - { - struct venc_switch encoder_switch; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("Getting VEN_IOCTL_(G)SET_SHORT_HDR\n"); - if (cmd == VEN_IOCTL_SET_SHORT_HDR) { - if (copy_from_user(&encoder_switch, venc_msg.in, - sizeof(encoder_switch))) - return -EFAULT; - - result = vid_enc_set_get_short_header(client_ctx, - &encoder_switch, true); - } else { - result = vid_enc_set_get_short_header(client_ctx, - &encoder_switch, false); - if (result) { - if (copy_to_user(venc_msg.out, &encoder_switch, - sizeof(encoder_switch))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_SHORT_HDR failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_BASE_CFG: - case VEN_IOCTL_GET_BASE_CFG: - { - struct venc_basecfg base_config; - DBG("VEN_IOCTL_SET_BASE_CFG\n"); - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (cmd == VEN_IOCTL_SET_BASE_CFG) { - if (copy_from_user(&base_config, venc_msg.in, - sizeof(base_config))) - return -EFAULT; - result = vid_enc_set_get_base_cfg(client_ctx, - &base_config, true); - } else { - result = vid_enc_set_get_base_cfg(client_ctx, - &base_config, false); - if (result) { - if (copy_to_user(venc_msg.out, &base_config, - sizeof(base_config))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_SET_BASE_CFG failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_LIVE_MODE: - case VEN_IOCTL_GET_LIVE_MODE: - { - struct venc_switch encoder_switch; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - DBG("Getting VEN_IOCTL_(G)SET_LIVE_MODE\n"); - if (cmd == VEN_IOCTL_SET_LIVE_MODE) { - if (copy_from_user(&encoder_switch, venc_msg.in, - sizeof(encoder_switch))) - return -EFAULT; - result = vid_enc_set_get_live_mode(client_ctx, - &encoder_switch, true); - } else { - result = vid_enc_set_get_live_mode(client_ctx, - &encoder_switch, false); - if (result) { - if (copy_to_user(venc_msg.out, &encoder_switch, - sizeof(encoder_switch))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_LIVE_MODE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_GET_NUMBER_INSTANCES: - { - DBG("VEN_IOCTL_GET_NUMBER_INSTANCES\n"); - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (copy_to_user(venc_msg.out, - &vid_enc_device_p->num_clients, sizeof(u32))) - return -EFAULT; - break; - } - case VEN_IOCTL_SET_METABUFFER_MODE: - { - u32 metabuffer_mode, vcd_status; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_live live_mode; - - DBG("VEN_IOCTL_SET_METABUFFER_MODE\n"); - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (copy_from_user(&metabuffer_mode, venc_msg.in, - sizeof(metabuffer_mode))) - return -EFAULT; - vcd_property_hdr.prop_id = VCD_I_META_BUFFER_MODE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_live); - live_mode.live = metabuffer_mode; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &live_mode); - if (vcd_status) { - pr_err(" Setting metabuffer mode failed"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_EXTRADATA: - case VEN_IOCTL_GET_EXTRADATA: - { - u32 extradata_flag; - DBG("VEN_IOCTL_(G)SET_EXTRADATA\n"); - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (cmd == VEN_IOCTL_SET_EXTRADATA) { - if (copy_from_user(&extradata_flag, venc_msg.in, - sizeof(u32))) - return -EFAULT; - result = vid_enc_set_get_extradata(client_ctx, - &extradata_flag, true); - } else { - result = vid_enc_set_get_extradata(client_ctx, - &extradata_flag, false); - if (result) { - if (copy_to_user(venc_msg.out, &extradata_flag, - sizeof(u32))) - return -EFAULT; - } - } - if (!result) { - ERR("setting VEN_IOCTL_(G)SET_LIVE_MODE failed\n"); - } - break; - } - case VEN_IOCTL_SET_SLICE_DELIVERY_MODE: - { - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - u32 enable = true; - DBG("VEN_IOCTL_SET_SLICE_DELIVERY_MODE\n"); - vcd_property_hdr.prop_id = VCD_I_SLICE_DELIVERY_MODE; - vcd_property_hdr.sz = sizeof(u32); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &enable); - if (vcd_status) { - pr_err(" Setting slice delivery mode failed"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_H263_PLUSPTYPE: - { - struct vcd_property_hdr vcd_property_hdr; - struct venc_plusptype plusptype; - u32 enable; - u32 vcd_status = VCD_ERR_FAIL; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (copy_from_user(&plusptype, venc_msg.in, - sizeof(plusptype))) - return -EFAULT; - vcd_property_hdr.prop_id = VCD_I_H263_PLUSPTYPE; - vcd_property_hdr.sz = sizeof(u32); - enable = plusptype.plusptype_enable; - DBG("VEN_IOCTL_SET PLUSPTYPE = %d\n", enable); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &enable); - if (vcd_status) { - pr_err(" Setting plusptype failed"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_LTRMODE: - case VEN_IOCTL_GET_LTRMODE: - { - struct venc_ltrmode encoder_ltrmode; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (cmd == VEN_IOCTL_SET_LTRMODE) { - DBG("VEN_IOCTL_SET_LTRMODE\n"); - if (copy_from_user(&encoder_ltrmode, venc_msg.in, - sizeof(encoder_ltrmode))) - return -EFAULT; - result = vid_enc_set_get_ltrmode(client_ctx, - &encoder_ltrmode, true); - } else { - DBG("VEN_IOCTL_GET_LTRMODE\n"); - result = vid_enc_set_get_ltrmode(client_ctx, - &encoder_ltrmode, false); - if (result) { - if (copy_to_user(venc_msg.out, &encoder_ltrmode, - sizeof(encoder_ltrmode))) - return -EFAULT; - } - } - if (!result) { - ERR("VEN_IOCTL_(G)SET_LTRMODE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_LTRCOUNT: - case VEN_IOCTL_GET_LTRCOUNT: - { - struct venc_ltrcount encoder_ltrcount; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (cmd == VEN_IOCTL_SET_LTRCOUNT) { - DBG("VEN_IOCTL_SET_LTRCOUNT\n"); - if (copy_from_user(&encoder_ltrcount, venc_msg.in, - sizeof(encoder_ltrcount))) - return -EFAULT; - result = vid_enc_set_get_ltrcount(client_ctx, - &encoder_ltrcount, true); - } else { - DBG("VEN_IOCTL_GET_LTRCOUNT\n"); - result = vid_enc_set_get_ltrcount(client_ctx, - &encoder_ltrcount, false); - if (result) { - if (copy_to_user(venc_msg.out, - &encoder_ltrcount, - sizeof(encoder_ltrcount))) - return -EFAULT; - } - } - if (!result) { - ERR("VEN_IOCTL_(G)SET_LTRCOUNT failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_LTRPERIOD: - case VEN_IOCTL_GET_LTRPERIOD: - { - struct venc_ltrperiod encoder_ltrperiod; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (cmd == VEN_IOCTL_SET_LTRPERIOD) { - DBG("VEN_IOCTL_SET_LTRPERIOD\n"); - if (copy_from_user(&encoder_ltrperiod, venc_msg.in, - sizeof(encoder_ltrperiod))) - return -EFAULT; - result = vid_enc_set_get_ltrperiod(client_ctx, - &encoder_ltrperiod, true); - } else { - DBG("VEN_IOCTL_GET_LTRPERIOD\n"); - result = vid_enc_set_get_ltrperiod(client_ctx, - &encoder_ltrperiod, false); - if (result) { - if (copy_to_user(venc_msg.out, - &encoder_ltrperiod, - sizeof(encoder_ltrperiod))) - return -EFAULT; - } - } - if (!result) { - ERR("VEN_IOCTL_(G)SET_LTRPERIOD failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_GET_CAPABILITY_LTRCOUNT: - { - struct venc_range venc_capltrcount; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - DBG("VEN_IOCTL_GET_CAPABILITY_LTRCOUNT\n"); - result = vid_enc_get_capability_ltrcount(client_ctx, - &venc_capltrcount); - if (result) { - if (copy_to_user(venc_msg.out, &venc_capltrcount, - sizeof(venc_capltrcount))) - return -EFAULT; - } else { - ERR("VEN_IOCTL_GET_CAPABILITY_LTRCOUNT failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_LTRUSE: - case VEN_IOCTL_GET_LTRUSE: - { - struct venc_ltruse encoder_ltruse; - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - if (cmd == VEN_IOCTL_SET_LTRUSE) { - DBG("VEN_IOCTL_SET_LTRUSE\n"); - if (copy_from_user(&encoder_ltruse, venc_msg.in, - sizeof(encoder_ltruse))) - return -EFAULT; - result = vid_enc_set_get_ltruse(client_ctx, - &encoder_ltruse, true); - } else { - DBG("VEN_IOCTL_GET_LTRUSE\n"); - result = vid_enc_set_get_ltruse(client_ctx, - &encoder_ltruse, false); - if (result) { - if (copy_to_user(venc_msg.out, - &encoder_ltruse, - sizeof(encoder_ltruse))) - return -EFAULT; - } - } - if (!result) { - ERR("VEN_IOCTL_(G)SET_LTRUSE failed\n"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_SPS_PPS_FOR_IDR: - { - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_sps_pps_for_idr_enable idr_enable; - u32 vcd_status = VCD_ERR_FAIL; - u32 enabled = 1; - - if (copy_from_user(&venc_msg, arg, sizeof(venc_msg))) - return -EFAULT; - - vcd_property_hdr.prop_id = VCD_I_ENABLE_SPS_PPS_FOR_IDR; - vcd_property_hdr.sz = sizeof(idr_enable); - - if (copy_from_user(&enabled, venc_msg.in, sizeof(u32))) - return -EFAULT; - - idr_enable.sps_pps_for_idr_enable_flag = enabled; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &idr_enable); - if (vcd_status) { - pr_err("Setting sps/pps per IDR failed"); - return -EIO; - } - break; - } - case VEN_IOCTL_SET_AC_PREDICTION: - case VEN_IOCTL_GET_AC_PREDICTION: - case VEN_IOCTL_SET_RVLC: - case VEN_IOCTL_GET_RVLC: - case VEN_IOCTL_SET_ROTATION: - case VEN_IOCTL_GET_ROTATION: - case VEN_IOCTL_SET_DATA_PARTITION: - case VEN_IOCTL_GET_DATA_PARTITION: - case VEN_IOCTL_GET_CAPABILITY: - default: - ERR("%s(): Unsupported ioctl %d\n", __func__, cmd); - return -ENOTTY; - - break; - } - return 0; -} - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Video encoder driver"); -MODULE_VERSION("1.0"); - -module_init(vid_enc_init); -module_exit(vid_enc_exit); diff --git a/drivers/video/msm/vidc/common/enc/venc_internal.c b/drivers/video/msm/vidc/common/enc/venc_internal.c deleted file mode 100644 index 126b4fdb0b8fd824da9c936d5f926a2ecf1f40f2..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/enc/venc_internal.c +++ /dev/null @@ -1,2220 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include "vcd_res_tracker_api.h" -#include "venc_internal.h" - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -#define ERR(x...) printk(KERN_ERR x) - -u32 vid_enc_set_get_base_cfg(struct video_client_ctx *client_ctx, - struct venc_basecfg *base_config, u32 set_flag) -{ - struct venc_targetbitrate venc_bitrate; - struct venc_framerate frame_rate; - u32 current_codec; - - if (!client_ctx || !base_config) - return false; - - if (!vid_enc_set_get_codec(client_ctx, ¤t_codec, false)) - return false; - - DBG("%s(): Current Codec Type = %u\n", __func__, current_codec); - if (current_codec != base_config->codectype) { - if (!vid_enc_set_get_codec(client_ctx, - (u32 *)&base_config->codectype, set_flag)) - return false; - } - - if (!vid_enc_set_get_inputformat(client_ctx, - (u32 *)&base_config->inputformat, set_flag)) - return false; - - if (!vid_enc_set_get_framesize(client_ctx, - (u32 *)&base_config->input_height, - (u32 *)&base_config->input_width, set_flag)) - return false; - - if (set_flag) - venc_bitrate.target_bitrate = base_config->targetbitrate; - - if (!vid_enc_set_get_bitrate(client_ctx, &venc_bitrate, set_flag)) - return false; - - if (!set_flag) - base_config->targetbitrate = venc_bitrate.target_bitrate; - - if (set_flag) { - frame_rate.fps_denominator = base_config->fps_den; - frame_rate.fps_numerator = base_config->fps_num; - } - - if (!vid_enc_set_get_framerate(client_ctx, &frame_rate, set_flag)) - return false; - - if (!set_flag) { - base_config->fps_den = frame_rate.fps_denominator; - base_config->fps_num = frame_rate.fps_numerator; - } - - return true; -} - -u32 vid_enc_set_get_inputformat(struct video_client_ctx *client_ctx, - u32 *input_format, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_buffer_format format; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !input_format) - return false; - - vcd_property_hdr.prop_id = VCD_I_BUFFER_FORMAT; - vcd_property_hdr.sz = - sizeof(struct vcd_property_buffer_format); - - if (set_flag) { - switch (*input_format) { - case VEN_INPUTFMT_NV12: - format.buffer_format = VCD_BUFFER_FORMAT_NV12; - break; - case VEN_INPUTFMT_NV12_16M2KA: - format.buffer_format = - VCD_BUFFER_FORMAT_NV12_16M2KA; - break; - default: - status = false; - break; - } - - if (status) { - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &format); - if (vcd_status) { - status = false; - ERR("%s(): Set VCD_I_BUFFER_FORMAT Failed\n", - __func__); - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &format); - - if (vcd_status) { - status = false; - ERR("%s(): Get VCD_I_BUFFER_FORMAT Failed\n", __func__); - } else { - switch (format.buffer_format) { - case VCD_BUFFER_FORMAT_NV12: - *input_format = VEN_INPUTFMT_NV12; - break; - case VCD_BUFFER_FORMAT_TILE_4x2: - *input_format = VEN_INPUTFMT_NV21; - break; - default: - status = false; - break; - } - } - } - return status; -} - -u32 vid_enc_set_get_codec(struct video_client_ctx *client_ctx, u32 *codec, - u32 set_flag) -{ - struct vcd_property_codec vcd_property_codec; - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !codec) - return false; - - vcd_property_hdr.prop_id = VCD_I_CODEC; - vcd_property_hdr.sz = sizeof(struct vcd_property_codec); - - if (set_flag) { - switch (*codec) { - case VEN_CODEC_MPEG4: - vcd_property_codec.codec = VCD_CODEC_MPEG4; - break; - case VEN_CODEC_H263: - vcd_property_codec.codec = VCD_CODEC_H263; - break; - case VEN_CODEC_H264: - vcd_property_codec.codec = VCD_CODEC_H264; - break; - default: - status = false; - break; - } - - if (status) { - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - if (vcd_status) { - status = false; - ERR("%s(): Set VCD_I_CODEC Failed\n", __func__); - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_codec); - - if (vcd_status) { - status = false; - ERR("%s(): Get VCD_I_CODEC Failed\n", - __func__); - } else { - switch (vcd_property_codec.codec) { - case VCD_CODEC_H263: - *codec = VEN_CODEC_H263; - break; - case VCD_CODEC_H264: - *codec = VEN_CODEC_H264; - break; - case VCD_CODEC_MPEG4: - *codec = VEN_CODEC_MPEG4; - break; - case VCD_CODEC_DIVX_3: - case VCD_CODEC_DIVX_4: - case VCD_CODEC_DIVX_5: - case VCD_CODEC_DIVX_6: - case VCD_CODEC_MPEG1: - case VCD_CODEC_MPEG2: - case VCD_CODEC_VC1: - case VCD_CODEC_VC1_RCV: - case VCD_CODEC_XVID: - default: - status = false; - break; - } - } - } - return status; -} - -u32 vid_enc_set_get_framesize(struct video_client_ctx *client_ctx, - u32 *height, u32 *width, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_size frame_size; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !height || !width) - return false; - - vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_frame_size); - - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &frame_size); - - if (vcd_status) { - ERR("%s(): Get VCD_I_FRAME_SIZE Failed\n", - __func__); - return false; - } - if (set_flag) { - if (frame_size.height != *height || - frame_size.width != *width) { - DBG("%s(): ENC Set Size (%d x %d)\n", - __func__, *height, *width); - frame_size.height = *height; - frame_size.width = *width; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &frame_size); - if (vcd_status) { - ERR("%s(): Set VCD_I_FRAME_SIZE Failed\n", - __func__); - return false; - } - } - } else { - *height = frame_size.height; - *width = frame_size.width; - } - return true; -} - -u32 vid_enc_set_get_bitrate(struct video_client_ctx *client_ctx, - struct venc_targetbitrate *venc_bitrate, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_target_bitrate bit_rate; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !venc_bitrate) - return false; - - vcd_property_hdr.prop_id = VCD_I_TARGET_BITRATE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_target_bitrate); - if (set_flag) { - bit_rate.target_bitrate = venc_bitrate->target_bitrate; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &bit_rate); - - if (vcd_status) { - ERR("%s(): Set VCD_I_TARGET_BITRATE Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &bit_rate); - - if (vcd_status) { - ERR("%s(): Get VCD_I_TARGET_BITRATE Failed\n", - __func__); - return false; - } - venc_bitrate->target_bitrate = bit_rate.target_bitrate; - } - return true; -} - -u32 vid_enc_set_get_extradata(struct video_client_ctx *client_ctx, - u32 *extradata_flag, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_meta_data_enable vcd_meta_data; - u32 vcd_status = VCD_ERR_FAIL; - if (!client_ctx || !extradata_flag) - return false; - vcd_property_hdr.prop_id = VCD_I_METADATA_ENABLE; - vcd_property_hdr.sz = sizeof(struct vcd_property_meta_data_enable); - if (set_flag) { - DBG("vcd_set_property: VCD_I_METADATA_ENABLE = %x\n", - (u32)*extradata_flag); - vcd_meta_data.meta_data_enable_flag = *extradata_flag; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_meta_data); - if (vcd_status) { - ERR("%s(): Set VCD_I_METADATA_ENABLE Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_meta_data); - if (vcd_status) { - ERR("%s(): Get VCD_I_METADATA_ENABLE Failed\n", - __func__); - return false; - } - *extradata_flag = vcd_meta_data.meta_data_enable_flag; - DBG("vcd_get_property: VCD_I_METADATA_ENABLE = 0x%x\n", - (u32)*extradata_flag); - } - return true; -} - -u32 vid_enc_set_get_extradata_cfg(struct video_client_ctx *client_ctx, - u32 *extradata_flag, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_meta_data_enable vcd_meta_data; - u32 vcd_status = VCD_ERR_FAIL; - if (!client_ctx || !extradata_flag) - return false; - vcd_property_hdr.prop_id = VCD_I_METADATA_ENABLE; - vcd_property_hdr.sz = sizeof(struct vcd_property_meta_data_enable); - if (set_flag) { - DBG("vcd_set_property: VCD_I_METADATA_ENABLE = %d\n", - *extradata_flag); - vcd_meta_data.meta_data_enable_flag = *extradata_flag; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_meta_data); - if (vcd_status) { - ERR("%s(): Set VCD_I_METADATA_ENABLE Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_meta_data); - if (vcd_status) { - ERR("%s(): Get VCD_I_METADATA_ENABLE Failed\n", - __func__); - return false; - } - *extradata_flag = vcd_meta_data.meta_data_enable_flag; - DBG("vcd_get_property: VCD_I_METADATA_ENABLE = %d\n", - *extradata_flag); - } - return true; -} - -u32 vid_enc_set_get_framerate(struct video_client_ctx *client_ctx, - struct venc_framerate *frame_rate, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_frame_rate vcd_frame_rate; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !frame_rate) - return false; - - vcd_property_hdr.prop_id = VCD_I_FRAME_RATE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_frame_rate); - - if (set_flag) { - vcd_frame_rate.fps_denominator = frame_rate->fps_denominator; - vcd_frame_rate.fps_numerator = frame_rate->fps_numerator; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_frame_rate); - - if (vcd_status) { - ERR("%s(): Set VCD_I_FRAME_RATE Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_frame_rate); - - if (vcd_status) { - ERR("%s(): Get VCD_I_FRAME_RATE Failed\n", - __func__); - return false; - } - frame_rate->fps_denominator = vcd_frame_rate.fps_denominator; - frame_rate->fps_numerator = vcd_frame_rate.fps_numerator; - } - return true; -} - -u32 vid_enc_set_get_live_mode(struct video_client_ctx *client_ctx, - struct venc_switch *encoder_switch, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_live live_mode; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx) - return false; - - vcd_property_hdr.prop_id = VCD_I_LIVE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_live); - - if (set_flag) { - live_mode.live = 1; - if (!encoder_switch->status) - live_mode.live = 0; - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &live_mode); - if (vcd_status) { - ERR("%s(): Set VCD_I_LIVE Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &live_mode); - - if (vcd_status) { - ERR("%s(): Get VCD_I_LIVE Failed\n", - __func__); - return false; - } else { - encoder_switch->status = 1; - if (!live_mode.live) - encoder_switch->status = 0; - } - } - return true; -} - -u32 vid_enc_set_get_short_header(struct video_client_ctx *client_ctx, - struct venc_switch *encoder_switch, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_short_header short_header; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !encoder_switch) - return false; - - vcd_property_hdr.prop_id = VCD_I_SHORT_HEADER; - vcd_property_hdr.sz = - sizeof(struct vcd_property_short_header); - - if (set_flag) { - short_header.short_header = (u32) encoder_switch->status; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &short_header); - - if (vcd_status) { - ERR("%s(): Set VCD_I_SHORT_HEADER Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &short_header); - - if (vcd_status) { - ERR("%s(): Get VCD_I_SHORT_HEADER Failed\n", - __func__); - return false; - } else { - encoder_switch->status = - (u8) short_header.short_header; - } - } - return true; -} - -u32 vid_enc_set_get_profile(struct video_client_ctx *client_ctx, - struct venc_profile *profile, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_profile profile_type; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !profile) - return false; - - vcd_property_hdr.prop_id = VCD_I_PROFILE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_profile); - - if (set_flag) { - switch (profile->profile) { - case VEN_PROFILE_MPEG4_SP: - profile_type.profile = VCD_PROFILE_MPEG4_SP; - break; - case VEN_PROFILE_MPEG4_ASP: - profile_type.profile = VCD_PROFILE_MPEG4_ASP; - break; - case VEN_PROFILE_H264_BASELINE: - profile_type.profile = VCD_PROFILE_H264_BASELINE; - break; - case VEN_PROFILE_H264_MAIN: - profile_type.profile = VCD_PROFILE_H264_MAIN; - break; - case VEN_PROFILE_H264_HIGH: - profile_type.profile = VCD_PROFILE_H264_HIGH; - break; - case VEN_PROFILE_H263_BASELINE: - profile_type.profile = VCD_PROFILE_H263_BASELINE; - break; - default: - status = false; - break; - } - - if (status) { - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &profile_type); - - if (vcd_status) { - ERR("%s(): Set VCD_I_PROFILE Failed\n", - __func__); - return false; - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &profile_type); - - if (vcd_status) { - ERR("%s(): Get VCD_I_PROFILE Failed\n", - __func__); - return false; - } else { - switch (profile_type.profile) { - case VCD_PROFILE_H263_BASELINE: - profile->profile = VEN_PROFILE_H263_BASELINE; - break; - case VCD_PROFILE_H264_BASELINE: - profile->profile = VEN_PROFILE_H264_BASELINE; - break; - case VCD_PROFILE_H264_HIGH: - profile->profile = VEN_PROFILE_H264_HIGH; - break; - case VCD_PROFILE_H264_MAIN: - profile->profile = VEN_PROFILE_H264_MAIN; - break; - case VCD_PROFILE_MPEG4_ASP: - profile->profile = VEN_PROFILE_MPEG4_ASP; - break; - case VCD_PROFILE_MPEG4_SP: - profile->profile = VEN_PROFILE_MPEG4_SP; - break; - default: - status = false; - break; - } - } - } - return status; -} - -u32 vid_enc_set_get_profile_level(struct video_client_ctx *client_ctx, - struct ven_profilelevel *profile_level, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_level level; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !profile_level) - return false; - - vcd_property_hdr.prop_id = VCD_I_LEVEL; - vcd_property_hdr.sz = - sizeof(struct vcd_property_level); - - if (set_flag) { - switch (profile_level->level) { - case VEN_LEVEL_MPEG4_0: - level.level = VCD_LEVEL_MPEG4_0; - break; - case VEN_LEVEL_MPEG4_1: - level.level = VCD_LEVEL_MPEG4_1; - break; - case VEN_LEVEL_MPEG4_2: - level.level = VCD_LEVEL_MPEG4_2; - break; - case VEN_LEVEL_MPEG4_3: - level.level = VCD_LEVEL_MPEG4_3; - break; - case VEN_LEVEL_MPEG4_4: - level.level = VCD_LEVEL_MPEG4_4; - break; - case VEN_LEVEL_MPEG4_5: - level.level = VCD_LEVEL_MPEG4_5; - break; - case VEN_LEVEL_MPEG4_3b: - level.level = VCD_LEVEL_MPEG4_3b; - break; - case VEN_LEVEL_MPEG4_6: - level.level = VCD_LEVEL_MPEG4_6; - break; - case VEN_LEVEL_H264_1: - level.level = VCD_LEVEL_H264_1; - break; - case VEN_LEVEL_H264_1b: - level.level = VCD_LEVEL_H264_1b; - break; - case VEN_LEVEL_H264_1p1: - level.level = VCD_LEVEL_H264_1p1; - break; - case VEN_LEVEL_H264_1p2: - level.level = VCD_LEVEL_H264_1p2; - break; - case VEN_LEVEL_H264_1p3: - level.level = VCD_LEVEL_H264_1p3; - break; - case VEN_LEVEL_H264_2: - level.level = VCD_LEVEL_H264_2; - break; - case VEN_LEVEL_H264_2p1: - level.level = VCD_LEVEL_H264_2p1; - break; - case VEN_LEVEL_H264_2p2: - level.level = VCD_LEVEL_H264_2p2; - break; - case VEN_LEVEL_H264_3: - level.level = VCD_LEVEL_H264_3; - break; - case VEN_LEVEL_H264_3p1: - level.level = VCD_LEVEL_H264_3p1; - break; - case VEN_LEVEL_H264_3p2: - level.level = VCD_LEVEL_H264_3p2; - break; - case VEN_LEVEL_H264_4: - level.level = VCD_LEVEL_H264_4; - break; - case VEN_LEVEL_H263_10: - level.level = VCD_LEVEL_H263_10; - break; - case VEN_LEVEL_H263_20: - level.level = VCD_LEVEL_H263_20; - break; - case VEN_LEVEL_H263_30: - level.level = VCD_LEVEL_H263_30; - break; - case VEN_LEVEL_H263_40: - level.level = VCD_LEVEL_H263_40; - break; - case VEN_LEVEL_H263_45: - level.level = VCD_LEVEL_H263_45; - break; - case VEN_LEVEL_H263_50: - level.level = VCD_LEVEL_H263_50; - break; - case VEN_LEVEL_H263_60: - level.level = VCD_LEVEL_H263_60; - break; - case VEN_LEVEL_H263_70: - level.level = VCD_LEVEL_H263_70; - break; - default: - status = false; - break; - } - if (status) { - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &level); - - if (vcd_status) { - ERR("%s(): Set VCD_I_LEVEL Failed\n", - __func__); - return false; - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &level); - - if (vcd_status) { - ERR("%s(): Get VCD_I_LEVEL Failed\n", - __func__); - return false; - } else { - switch (level.level) { - case VCD_LEVEL_MPEG4_0: - profile_level->level = VEN_LEVEL_MPEG4_0; - break; - case VCD_LEVEL_MPEG4_1: - profile_level->level = VEN_LEVEL_MPEG4_1; - break; - case VCD_LEVEL_MPEG4_2: - profile_level->level = VEN_LEVEL_MPEG4_2; - break; - case VCD_LEVEL_MPEG4_3: - profile_level->level = VEN_LEVEL_MPEG4_3; - break; - case VCD_LEVEL_MPEG4_4: - profile_level->level = VEN_LEVEL_MPEG4_4; - break; - case VCD_LEVEL_MPEG4_5: - profile_level->level = VEN_LEVEL_MPEG4_5; - break; - case VCD_LEVEL_MPEG4_3b: - profile_level->level = VEN_LEVEL_MPEG4_3b; - break; - case VCD_LEVEL_H264_1: - profile_level->level = VEN_LEVEL_H264_1; - break; - case VCD_LEVEL_H264_1b: - profile_level->level = VEN_LEVEL_H264_1b; - break; - case VCD_LEVEL_H264_1p1: - profile_level->level = VEN_LEVEL_H264_1p1; - break; - case VCD_LEVEL_H264_1p2: - profile_level->level = VEN_LEVEL_H264_1p2; - break; - case VCD_LEVEL_H264_1p3: - profile_level->level = VEN_LEVEL_H264_1p3; - break; - case VCD_LEVEL_H264_2: - profile_level->level = VEN_LEVEL_H264_2; - break; - case VCD_LEVEL_H264_2p1: - profile_level->level = VEN_LEVEL_H264_2p1; - break; - case VCD_LEVEL_H264_2p2: - profile_level->level = VEN_LEVEL_H264_2p2; - break; - case VCD_LEVEL_H264_3: - profile_level->level = VEN_LEVEL_H264_3; - break; - case VCD_LEVEL_H264_3p1: - profile_level->level = VEN_LEVEL_H264_3p1; - break; - case VCD_LEVEL_H264_3p2: - profile_level->level = VEN_LEVEL_H264_3p2; - break; - case VCD_LEVEL_H264_4: - profile_level->level = VEN_LEVEL_H264_4; - break; - case VCD_LEVEL_H263_10: - profile_level->level = VEN_LEVEL_H263_10; - break; - case VCD_LEVEL_H263_20: - profile_level->level = VEN_LEVEL_H263_20; - break; - case VCD_LEVEL_H263_30: - profile_level->level = VEN_LEVEL_H263_30; - break; - case VCD_LEVEL_H263_40: - profile_level->level = VEN_LEVEL_H263_40; - break; - case VCD_LEVEL_H263_45: - profile_level->level = VEN_LEVEL_H263_45; - break; - case VCD_LEVEL_H263_50: - profile_level->level = VEN_LEVEL_H263_50; - break; - case VCD_LEVEL_H263_60: - profile_level->level = VEN_LEVEL_H263_60; - break; - case VCD_LEVEL_H263_70: - status = false; - break; - default: - status = false; - break; - } - } - } - return status; -} - -u32 vid_enc_set_get_session_qp(struct video_client_ctx *client_ctx, - struct venc_sessionqp *session_qp, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_session_qp qp; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !session_qp) - return false; - - vcd_property_hdr.prop_id = VCD_I_SESSION_QP; - vcd_property_hdr.sz = - sizeof(struct vcd_property_session_qp); - - if (set_flag) { - qp.i_frame_qp = session_qp->iframeqp; - qp.p_frame_qp = session_qp->pframqp; - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &qp); - - if (vcd_status) { - ERR("%s(): Set VCD_I_SESSION_QP Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &qp); - - if (vcd_status) { - ERR("%s(): Set VCD_I_SESSION_QP Failed\n", - __func__); - return false; - } else { - session_qp->iframeqp = qp.i_frame_qp; - session_qp->pframqp = qp.p_frame_qp; - } - } - return true; -} - -u32 vid_enc_set_get_intraperiod(struct video_client_ctx *client_ctx, - struct venc_intraperiod *intraperiod, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_i_period period; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !intraperiod) - return false; - - vcd_property_hdr.prop_id = VCD_I_INTRA_PERIOD; - vcd_property_hdr.sz = - sizeof(struct vcd_property_i_period); - - if (set_flag) { - period.p_frames = intraperiod->num_pframes; - period.b_frames = intraperiod->num_bframes; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &period); - - if (vcd_status) { - ERR("%s(): Set VCD_I_INTRA_PERIOD Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &period); - - if (vcd_status) { - ERR("%s(): Get VCD_I_INTRA_PERIOD Failed\n", - __func__); - return false; - } else - intraperiod->num_pframes = period.p_frames; - } - return true; -} - -u32 vid_enc_request_iframe(struct video_client_ctx *client_ctx) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_req_i_frame request; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx) - return false; - - vcd_property_hdr.prop_id = VCD_I_REQ_IFRAME; - vcd_property_hdr.sz = - sizeof(struct vcd_property_req_i_frame); - request.req_i_frame = 1; - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &request); - - if (vcd_status) { - ERR("%s(): Set VCD_I_REQ_IFRAME Failed\n", - __func__); - return false; - } - return status; -} - -u32 vid_enc_get_sequence_header(struct video_client_ctx *client_ctx, - struct venc_seqheader *seq_header) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_sequence_hdr hdr; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !seq_header || !seq_header->bufsize) - return false; - - vcd_property_hdr.prop_id = VCD_I_SEQ_HEADER; - vcd_property_hdr.sz = sizeof(struct vcd_sequence_hdr); - - hdr.sequence_header = seq_header->hdrbufptr; - hdr.sequence_header_len = seq_header->bufsize; - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &hdr); - seq_header->hdrlen = hdr.sequence_header_len; - - if (vcd_status) { - ERR("%s(): Get VCD_I_SEQ_HEADER Failed\n", - __func__); - status = false; - } - return true; -} - -u32 vid_enc_set_get_entropy_cfg(struct video_client_ctx *client_ctx, - struct venc_entropycfg *entropy_cfg, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_entropy_control control; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !entropy_cfg) - return false; - - vcd_property_hdr.prop_id = VCD_I_ENTROPY_CTRL; - vcd_property_hdr.sz = - sizeof(struct vcd_property_entropy_control); - if (set_flag) { - switch (entropy_cfg->longentropysel) { - case VEN_ENTROPY_MODEL_CAVLC: - control.entropy_sel = VCD_ENTROPY_SEL_CAVLC; - break; - case VEN_ENTROPY_MODEL_CABAC: - control.entropy_sel = VCD_ENTROPY_SEL_CABAC; - break; - default: - status = false; - break; - } - - if (status && entropy_cfg->cabacmodel == - VCD_ENTROPY_SEL_CABAC) { - switch (entropy_cfg->cabacmodel) { - case VEN_CABAC_MODEL_0: - control.cabac_model = - VCD_CABAC_MODEL_NUMBER_0; - break; - case VEN_CABAC_MODEL_1: - control.cabac_model = - VCD_CABAC_MODEL_NUMBER_1; - break; - case VEN_CABAC_MODEL_2: - control.cabac_model = - VCD_CABAC_MODEL_NUMBER_2; - break; - default: - status = false; - break; - } - } - if (status) { - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Set VCD_I_ENTROPY_CTRL Failed\n", - __func__); - status = false; - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Get VCD_I_ENTROPY_CTRL Failed\n", - __func__); - status = false; - } else { - switch (control.entropy_sel) { - case VCD_ENTROPY_SEL_CABAC: - entropy_cfg->cabacmodel = - VEN_ENTROPY_MODEL_CABAC; - break; - case VCD_ENTROPY_SEL_CAVLC: - entropy_cfg->cabacmodel = - VEN_ENTROPY_MODEL_CAVLC; - break; - default: - status = false; - break; - } - - if (status && control.entropy_sel == - VCD_ENTROPY_SEL_CABAC) { - switch (control.cabac_model) { - case VCD_CABAC_MODEL_NUMBER_0: - entropy_cfg->cabacmodel = - VEN_CABAC_MODEL_0; - break; - case VCD_CABAC_MODEL_NUMBER_1: - entropy_cfg->cabacmodel = - VEN_CABAC_MODEL_1; - break; - case VCD_CABAC_MODEL_NUMBER_2: - entropy_cfg->cabacmodel = - VEN_CABAC_MODEL_2; - break; - default: - status = false; - break; - } - } - } - } - return status; -} - -u32 vid_enc_set_get_dbcfg(struct video_client_ctx *client_ctx, - struct venc_dbcfg *dbcfg, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_db_config control; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !dbcfg) - return false; - - vcd_property_hdr.prop_id = VCD_I_DEBLOCKING; - vcd_property_hdr.sz = - sizeof(struct vcd_property_db_config); - - if (set_flag) { - switch (dbcfg->db_mode) { - case VEN_DB_DISABLE: - control.db_config = VCD_DB_DISABLE; - break; - case VEN_DB_ALL_BLKG_BNDRY: - control.db_config = VCD_DB_ALL_BLOCKING_BOUNDARY; - break; - case VEN_DB_SKIP_SLICE_BNDRY: - control.db_config = VCD_DB_SKIP_SLICE_BOUNDARY; - break; - default: - status = false; - break; - } - - if (status) { - control.slice_alpha_offset = - dbcfg->slicealpha_offset; - control.slice_beta_offset = - dbcfg->slicebeta_offset; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (vcd_status) { - ERR("%s(): Set VCD_I_DEBLOCKING Failed\n", - __func__); - status = false; - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (vcd_status) { - ERR("%s(): Get VCD_I_DEBLOCKING Failed\n", - __func__); - status = false; - } else { - switch (control.db_config) { - case VCD_DB_ALL_BLOCKING_BOUNDARY: - dbcfg->db_mode = VEN_DB_ALL_BLKG_BNDRY; - break; - case VCD_DB_DISABLE: - dbcfg->db_mode = VEN_DB_DISABLE; - break; - case VCD_DB_SKIP_SLICE_BOUNDARY: - dbcfg->db_mode = VEN_DB_SKIP_SLICE_BNDRY; - break; - default: - status = false; - break; - } - dbcfg->slicealpha_offset = - control.slice_alpha_offset; - dbcfg->slicebeta_offset = - control.slice_beta_offset; - } - } - return status; -} - -u32 vid_enc_set_get_intrarefresh(struct video_client_ctx *client_ctx, - struct venc_intrarefresh *intrarefresh, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_intra_refresh_mb_number control; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !intrarefresh) - return false; - - vcd_property_hdr.prop_id = VCD_I_INTRA_REFRESH; - vcd_property_hdr.sz = - sizeof(struct vcd_property_intra_refresh_mb_number); - - if (set_flag) { - control.cir_mb_number = intrarefresh->mbcount; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Set VCD_I_INTRA_REFRESH Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Set VCD_I_INTRA_REFRESH Failed\n", - __func__); - return false; - } else - intrarefresh->mbcount = control.cir_mb_number; - } - return true; -} - -u32 vid_enc_set_get_multiclicecfg(struct video_client_ctx *client_ctx, - struct venc_multiclicecfg *multiclicecfg, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_multi_slice control; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !multiclicecfg) - return false; - - vcd_property_hdr.prop_id = VCD_I_MULTI_SLICE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_multi_slice); - - if (set_flag) { - switch (multiclicecfg->mslice_mode) { - case VEN_MSLICE_OFF: - control.m_slice_sel = - VCD_MSLICE_OFF; - break; - case VEN_MSLICE_CNT_MB: - control.m_slice_sel = - VCD_MSLICE_BY_MB_COUNT; - break; - case VEN_MSLICE_CNT_BYTE: - control.m_slice_sel = - VCD_MSLICE_BY_BYTE_COUNT; - break; - case VEN_MSLICE_GOB: - control.m_slice_sel = - VCD_MSLICE_BY_GOB; - break; - default: - status = false; - break; - } - - if (status) { - control.m_slice_size = - multiclicecfg->mslice_size; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Set VCD_I_MULTI_SLICE Failed\n", - __func__); - status = false; - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Get VCD_I_MULTI_SLICE Failed\n", - __func__); - status = false; - } else { - multiclicecfg->mslice_size = - control.m_slice_size; - switch (control.m_slice_sel) { - case VCD_MSLICE_OFF: - multiclicecfg->mslice_mode = VEN_MSLICE_OFF; - break; - case VCD_MSLICE_BY_MB_COUNT: - multiclicecfg->mslice_mode = VEN_MSLICE_CNT_MB; - break; - case VCD_MSLICE_BY_BYTE_COUNT: - multiclicecfg->mslice_mode = - VEN_MSLICE_CNT_BYTE; - break; - case VCD_MSLICE_BY_GOB: - multiclicecfg->mslice_mode = - VEN_MSLICE_GOB; - break; - default: - status = false; - break; - } - } - } - return status; -} - -u32 vid_enc_set_get_ratectrlcfg(struct video_client_ctx *client_ctx, - struct venc_ratectrlcfg *ratectrlcfg, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_rate_control control; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !ratectrlcfg) - return false; - - vcd_property_hdr.prop_id = VCD_I_RATE_CONTROL; - vcd_property_hdr.sz = - sizeof(struct vcd_property_rate_control); - - if (set_flag) { - switch (ratectrlcfg->rcmode) { - case VEN_RC_OFF: - control.rate_control = VCD_RATE_CONTROL_OFF; - break; - case VEN_RC_CBR_VFR: - control.rate_control = VCD_RATE_CONTROL_CBR_VFR; - break; - case VEN_RC_VBR_CFR: - control.rate_control = VCD_RATE_CONTROL_VBR_CFR; - break; - case VEN_RC_VBR_VFR: - control.rate_control = VCD_RATE_CONTROL_VBR_VFR; - break; - case VEN_RC_CBR_CFR: - control.rate_control = VCD_RATE_CONTROL_CBR_CFR; - break; - default: - status = false; - break; - } - - if (status) { - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (vcd_status) { - ERR("%s(): Set VCD_I_RATE_CONTROL Failed\n", - __func__); - status = false; - } - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Get VCD_I_RATE_CONTROL Failed\n", - __func__); - status = false; - } else { - switch (control.rate_control) { - case VCD_RATE_CONTROL_OFF: - ratectrlcfg->rcmode = VEN_RC_OFF; - break; - case VCD_RATE_CONTROL_CBR_VFR: - ratectrlcfg->rcmode = VEN_RC_CBR_VFR; - break; - case VCD_RATE_CONTROL_VBR_CFR: - ratectrlcfg->rcmode = VEN_RC_VBR_CFR; - break; - case VCD_RATE_CONTROL_VBR_VFR: - ratectrlcfg->rcmode = VEN_RC_VBR_VFR; - break; - case VCD_RATE_CONTROL_CBR_CFR: - ratectrlcfg->rcmode = VEN_RC_CBR_CFR; - break; - default: - status = false; - break; - } - } - } - return status; -} - -u32 vid_enc_set_get_voptimingcfg(struct video_client_ctx *client_ctx, - struct venc_voptimingcfg *voptimingcfg, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_vop_timing control; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !voptimingcfg) - return false; - - vcd_property_hdr.prop_id = VCD_I_VOP_TIMING; - vcd_property_hdr.sz = - sizeof(struct vcd_property_vop_timing); - - if (set_flag) { - control.vop_time_resolution = - voptimingcfg->voptime_resolution; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Set VCD_I_VOP_TIMING Failed\n", - __func__); - status = false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (vcd_status) { - ERR("%s(): Get VCD_I_VOP_TIMING Failed\n", - __func__); - status = false; - } else - voptimingcfg->voptime_resolution = - control.vop_time_resolution; - } - return status; -} - -u32 vid_enc_set_get_headerextension(struct video_client_ctx *client_ctx, - struct venc_headerextension *headerextension, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - u32 control; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !headerextension) - return false; - - vcd_property_hdr.prop_id = VCD_I_HEADER_EXTENSION; - vcd_property_hdr.sz = sizeof(u32); - - if (set_flag) { - control = headerextension->header_extension; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (vcd_status) { - ERR("%s(): Set VCD_I_HEADER_EXTENSION Failed\n", - __func__); - status = false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (vcd_status) { - ERR("%s(): Get VCD_I_HEADER_EXTENSION Failed\n", - __func__); - status = false; - } else { - headerextension->header_extension = control; - } - } - return status; -} - -u32 vid_enc_set_get_qprange(struct video_client_ctx *client_ctx, - struct venc_qprange *qprange, u32 set_flag) -{ - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_qp_range control; - u32 vcd_status = VCD_ERR_FAIL; - u32 status = true; - - if (!client_ctx || !qprange) - return false; - - vcd_property_hdr.prop_id = VCD_I_QP_RANGE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_qp_range); - - if (set_flag) { - control.max_qp = qprange->maxqp; - control.min_qp = qprange->minqp; - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - if (vcd_status) { - ERR("%s(): Set VCD_I_QP_RANGE Failed\n", - __func__); - status = false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - if (vcd_status) { - ERR("%s(): Get VCD_I_QP_RANGE Failed\n", - __func__); - status = false; - } else { - qprange->maxqp = control.max_qp; - qprange->minqp = control.min_qp; - } - } - return status; -} - -u32 vid_enc_start_stop(struct video_client_ctx *client_ctx, u32 start) -{ - u32 vcd_status; - - if (!client_ctx) - return false; - - if (start) { - vcd_status = vcd_encode_start(client_ctx->vcd_handle); - - if (vcd_status) { - ERR("%s(): vcd_encode_start failed." - " vcd_status = %u\n", __func__, vcd_status); - return false; - } - } else { - vcd_status = vcd_stop(client_ctx->vcd_handle); - if (vcd_status) { - ERR("%s(): vcd_stop failed. vcd_status = %u\n", - __func__, vcd_status); - return false; - } - DBG("Send STOP_DONE message to client = %p\n", - client_ctx); - } - return true; -} - -u32 vid_enc_pause_resume(struct video_client_ctx *client_ctx, u32 pause) -{ - u32 vcd_status; - - if (!client_ctx) - return false; - - if (pause) { - DBG("PAUSE command from client = %p\n", - client_ctx); - vcd_status = vcd_pause(client_ctx->vcd_handle); - } else { - DBG("Resume command from client = %p\n", - client_ctx); - vcd_status = vcd_resume(client_ctx->vcd_handle); - } - - if (vcd_status) - return false; - - return true; -} - -u32 vid_enc_flush(struct video_client_ctx *client_ctx, - struct venc_bufferflush *bufferflush) -{ - u32 status = true, mode, vcd_status; - - if (!client_ctx || !bufferflush) - return false; - - switch (bufferflush->flush_mode) { - case VEN_FLUSH_INPUT: - mode = VCD_FLUSH_INPUT; - break; - case VEN_FLUSH_OUTPUT: - mode = VCD_FLUSH_OUTPUT; - break; - case VEN_FLUSH_ALL: - mode = VCD_FLUSH_ALL; - break; - default: - status = false; - break; - } - if (status) { - vcd_status = vcd_flush(client_ctx->vcd_handle, mode); - if (vcd_status) - status = false; - } - return status; -} - -u32 vid_enc_get_buffer_req(struct video_client_ctx *client_ctx, - struct venc_allocatorproperty *venc_buf_req, u32 input_dir) -{ - enum vcd_buffer_type buffer; - struct vcd_buffer_requirement buffer_req; - u32 status = true; - u32 vcd_status; - - if (!client_ctx || !venc_buf_req) - return false; - - buffer = VCD_BUFFER_OUTPUT; - if (input_dir) - buffer = VCD_BUFFER_INPUT; - - vcd_status = vcd_get_buffer_requirements(client_ctx->vcd_handle, - buffer, &buffer_req); - - if (vcd_status) - status = false; - - if (status) { - venc_buf_req->actualcount = buffer_req.actual_count; - venc_buf_req->alignment = buffer_req.align; - venc_buf_req->datasize = buffer_req.sz; - venc_buf_req->mincount = buffer_req.min_count; - venc_buf_req->maxcount = buffer_req.max_count; - venc_buf_req->alignment = buffer_req.align; - venc_buf_req->bufpoolid = buffer_req.buf_pool_id; - venc_buf_req->suffixsize = 0; - DBG("%s: actual_count=%d, align=%d, sz=%d, min_count=%d, " - "max_count=%d, buf_pool_id=%d\n", __func__, - buffer_req.actual_count, buffer_req.align, - buffer_req.sz, buffer_req.min_count, - buffer_req.max_count, buffer_req.buf_pool_id); - } - return status; -} - -u32 vid_enc_set_buffer_req(struct video_client_ctx *client_ctx, - struct venc_allocatorproperty *venc_buf_req, u32 input_dir) -{ - enum vcd_buffer_type buffer; - struct vcd_buffer_requirement buffer_req; - u32 status = true; - u32 vcd_status; - - if (!client_ctx || !venc_buf_req) - return false; - - buffer = VCD_BUFFER_OUTPUT; - if (input_dir) - buffer = VCD_BUFFER_INPUT; - - buffer_req.actual_count = venc_buf_req->actualcount; - buffer_req.align = venc_buf_req->alignment; - buffer_req.sz = venc_buf_req->datasize; - buffer_req.min_count = venc_buf_req->mincount; - buffer_req.max_count = venc_buf_req->maxcount; - buffer_req.align = venc_buf_req->alignment; - buffer_req.buf_pool_id = 0; - - DBG("%s: actual_count=%d, align=%d, sz=%d, min_count=%d, " - "max_count=%d, buf_pool_id=%d\n", __func__, - buffer_req.actual_count, buffer_req.align, buffer_req.sz, - buffer_req.min_count, buffer_req.max_count, - buffer_req.buf_pool_id); - vcd_status = vcd_set_buffer_requirements(client_ctx->vcd_handle, - buffer, &buffer_req); - - if (vcd_status) - status = false; - return status; -} - -u32 vid_enc_set_buffer(struct video_client_ctx *client_ctx, - struct venc_bufferpayload *buffer_info, - enum venc_buffer_dir buffer) -{ - enum vcd_buffer_type vcd_buffer_t = VCD_BUFFER_INPUT; - enum buffer_dir dir_buffer = BUFFER_TYPE_INPUT; - u32 vcd_status = VCD_ERR_FAIL; - unsigned long kernel_vaddr, length = 0; - - if (!client_ctx || !buffer_info) - return false; - - if (buffer == VEN_BUFFER_TYPE_OUTPUT) { - dir_buffer = BUFFER_TYPE_OUTPUT; - vcd_buffer_t = VCD_BUFFER_OUTPUT; - } - length = buffer_info->sz; - /*If buffer cannot be set, ignore */ - if (!vidc_insert_addr_table(client_ctx, dir_buffer, - (unsigned long)buffer_info->pbuffer, - &kernel_vaddr, - buffer_info->fd, - (unsigned long)buffer_info->offset, - VID_ENC_MAX_NUM_OF_BUFF, length)) { - DBG("%s() : user_virt_addr = %p cannot be set.", - __func__, buffer_info->pbuffer); - return false; - } - - vcd_status = vcd_set_buffer(client_ctx->vcd_handle, - vcd_buffer_t, (u8 *) kernel_vaddr, - buffer_info->sz); - - if (!vcd_status) - return true; - else - return false; -} - -u32 vid_enc_free_buffer(struct video_client_ctx *client_ctx, - struct venc_bufferpayload *buffer_info, - enum venc_buffer_dir buffer) -{ - enum vcd_buffer_type buffer_vcd = VCD_BUFFER_INPUT; - enum buffer_dir dir_buffer = BUFFER_TYPE_INPUT; - u32 vcd_status = VCD_ERR_FAIL; - unsigned long kernel_vaddr; - - if (!client_ctx || !buffer_info) - return false; - - if (buffer == VEN_BUFFER_TYPE_OUTPUT) { - dir_buffer = BUFFER_TYPE_OUTPUT; - buffer_vcd = VCD_BUFFER_OUTPUT; - } - /*If buffer NOT set, ignore */ - if (!vidc_delete_addr_table(client_ctx, dir_buffer, - (unsigned long)buffer_info->pbuffer, - &kernel_vaddr)) { - DBG("%s() : user_virt_addr = %p has not been set.", - __func__, buffer_info->pbuffer); - return true; - } - vcd_status = vcd_free_buffer(client_ctx->vcd_handle, buffer_vcd, - (u8 *)kernel_vaddr); - - if (!vcd_status) - return true; - else - return false; -} - -u32 vid_enc_encode_frame(struct video_client_ctx *client_ctx, - struct venc_buffer *input_frame_info) -{ - struct vcd_frame_data vcd_input_buffer; - unsigned long kernel_vaddr, phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - u32 ion_flag = 0; - struct ion_handle *buff_handle = NULL; - - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !input_frame_info) - return false; - - user_vaddr = (unsigned long)input_frame_info->ptrbuffer; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_INPUT, - true, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index)) { - - /* kernel_vaddr is found. send the frame to VCD */ - memset((void *)&vcd_input_buffer, 0, - sizeof(struct vcd_frame_data)); - - vcd_input_buffer.virtual = - (u8 *) (kernel_vaddr + input_frame_info->offset); - - vcd_input_buffer.offset = input_frame_info->offset; - vcd_input_buffer.frm_clnt_data = - (u32) input_frame_info->clientdata; - vcd_input_buffer.ip_frm_tag = - (u32) input_frame_info->clientdata; - vcd_input_buffer.data_len = input_frame_info->len; - vcd_input_buffer.time_stamp = input_frame_info->timestamp; - - /* Rely on VCD using the same flags as OMX */ - vcd_input_buffer.flags = input_frame_info->flags; - - ion_flag = vidc_get_fd_info(client_ctx, BUFFER_TYPE_INPUT, - pmem_fd, kernel_vaddr, buffer_index, - &buff_handle); - - if (vcd_input_buffer.data_len > 0) { - if (ion_flag == ION_FLAG_CACHED && buff_handle) { - msm_ion_do_cache_op( - client_ctx->user_ion_client, - buff_handle, - (unsigned long *) vcd_input_buffer.virtual, - (unsigned long) vcd_input_buffer.data_len, - ION_IOC_CLEAN_CACHES); - } - } - - vcd_status = vcd_encode_frame(client_ctx->vcd_handle, - &vcd_input_buffer); - if (!vcd_status) - return true; - else { - ERR("%s(): vcd_encode_frame failed = %u\n", - __func__, vcd_status); - return false; - } - - } else { - ERR("%s(): kernel_vaddr not found\n", - __func__); - return false; - } -} - -u32 vid_enc_fill_output_buffer(struct video_client_ctx *client_ctx, - struct venc_buffer *output_frame_info) -{ - unsigned long kernel_vaddr, phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - u32 vcd_status = VCD_ERR_FAIL; - struct ion_handle *buff_handle = NULL; - - struct vcd_frame_data vcd_frame; - - if (!client_ctx || !output_frame_info) - return false; - - user_vaddr = (unsigned long)output_frame_info->ptrbuffer; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - true, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index)) { - - memset((void *)&vcd_frame, 0, - sizeof(struct vcd_frame_data)); - vidc_get_fd_info(client_ctx, BUFFER_TYPE_OUTPUT, - pmem_fd, kernel_vaddr, buffer_index, - &buff_handle); - vcd_frame.virtual = (u8 *) kernel_vaddr; - vcd_frame.frm_clnt_data = (u32) output_frame_info->clientdata; - vcd_frame.alloc_len = output_frame_info->sz; - vcd_frame.buff_ion_handle = buff_handle; - - vcd_status = vcd_fill_output_buffer(client_ctx->vcd_handle, - &vcd_frame); - if (!vcd_status) - return true; - else { - ERR("%s(): vcd_fill_output_buffer failed = %u\n", - __func__, vcd_status); - return false; - } - } else { - ERR("%s(): kernel_vaddr not found\n", __func__); - return false; - } -} -u32 vid_enc_set_recon_buffers(struct video_client_ctx *client_ctx, - struct venc_recon_addr *venc_recon) -{ - u32 vcd_status = VCD_ERR_FAIL; - u32 len, i; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_enc_recon_buffer *control = NULL; - int rc = -1; - unsigned long ionflag = 0; - unsigned long iova = 0; - unsigned long buffer_size = 0; - size_t ion_len = -1; - unsigned long phy_addr; - - if (!client_ctx || !venc_recon) { - pr_err("%s() Invalid params", __func__); - return false; - } - len = sizeof(client_ctx->recon_buffer)/ - sizeof(struct vcd_property_enc_recon_buffer); - for (i = 0; i < len; i++) { - if (!client_ctx->recon_buffer[i].kernel_virtual_addr) { - control = &client_ctx->recon_buffer[i]; - break; - } - } - if (!control) { - pr_err("Exceeded max recon buffer setting"); - return false; - } - control->buffer_size = venc_recon->buffer_size; - control->kernel_virtual_addr = NULL; - control->physical_addr = NULL; - control->pmem_fd = venc_recon->pmem_fd; - control->offset = venc_recon->offset; - control->user_virtual_addr = venc_recon->pbuffer; - - if (!vcd_get_ion_status()) { - pr_err("PMEM not available\n"); - return false; - } else { - client_ctx->recon_buffer_ion_handle[i] = ion_import_dma_buf( - client_ctx->user_ion_client, control->pmem_fd); - if (IS_ERR_OR_NULL(client_ctx->recon_buffer_ion_handle[i])) { - ERR("%s(): get_ION_handle failed\n", __func__); - goto import_ion_error; - } - rc = ion_handle_get_flags(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - &ionflag); - if (rc) { - ERR("%s():get_ION_flags fail\n", - __func__); - goto import_ion_error; - } - control->kernel_virtual_addr = (u8 *) ion_map_kernel( - client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - if (!control->kernel_virtual_addr) { - ERR("%s(): get_ION_kernel virtual addr fail\n", - __func__); - goto import_ion_error; - } - if (res_trk_check_for_sec_session() || - (res_trk_get_core_type() == (u32)VCD_CORE_720P)) { - rc = ion_phys(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - (ion_phys_addr_t *)&phy_addr, &ion_len); - if (rc) { - ERR("%s():get_ION_kernel physical addr fail\n", - __func__); - goto map_ion_error; - } - control->physical_addr = (u8 *) phy_addr; - len = (unsigned long) ion_len; - control->client_data = NULL; - control->dev_addr = (u8 *)control->physical_addr; - } else { - rc = ion_map_iommu(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - VIDEO_DOMAIN, - VIDEO_MAIN_POOL, - SZ_4K, - 0, - (dma_addr_t *)&iova, - (unsigned long *)&buffer_size, - 0, 0); - if (rc || !iova) { - ERR( - "%s():ION map iommu addr fail, rc = %d, iova = 0x%lx\n", - __func__, rc, iova); - goto map_ion_error; - } - control->physical_addr = (u8 *) iova; - len = buffer_size; - control->client_data = NULL; - control->dev_addr = (u8 *)iova; - } - } - - vcd_property_hdr.prop_id = VCD_I_RECON_BUFFERS; - vcd_property_hdr.sz = - sizeof(struct vcd_property_enc_recon_buffer); - - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, control); - if (!vcd_status) { - DBG("vcd_set_property returned success\n"); - return true; - } else { - ERR("%s(): vid_enc_set_recon_buffers failed = %u\n", - __func__, vcd_status); - return false; - } -map_ion_error: - if (control->kernel_virtual_addr) - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - if (client_ctx->recon_buffer_ion_handle[i]) - ion_free(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - client_ctx->recon_buffer_ion_handle[i] = NULL; -import_ion_error: - return false; -} - -u32 vid_enc_free_recon_buffers(struct video_client_ctx *client_ctx, - struct venc_recon_addr *venc_recon) -{ - u32 vcd_status = VCD_ERR_FAIL; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_enc_recon_buffer *control = NULL; - u32 len = 0, i; - - if (!client_ctx || !venc_recon) { - pr_err("%s() Invalid params", __func__); - return false; - } - len = sizeof(client_ctx->recon_buffer)/ - sizeof(struct vcd_property_enc_recon_buffer); - pr_err(" %s() address %p", __func__, - venc_recon->pbuffer); - for (i = 0; i < len; i++) { - if (client_ctx->recon_buffer[i].user_virtual_addr - == venc_recon->pbuffer) { - control = &client_ctx->recon_buffer[i]; - break; - } - } - if (!control) { - pr_err(" %s() address not found %p", __func__, - venc_recon->pbuffer); - return false; - } - - vcd_property_hdr.prop_id = VCD_I_FREE_RECON_BUFFERS; - vcd_property_hdr.sz = sizeof(struct vcd_property_buffer_size); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, control); - if (vcd_get_ion_status()) { - if (client_ctx->recon_buffer_ion_handle[i]) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - if (!res_trk_check_for_sec_session() && - (res_trk_get_core_type() != (u32)VCD_CORE_720P)) { - ion_unmap_iommu(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i], - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(client_ctx->user_ion_client, - client_ctx->recon_buffer_ion_handle[i]); - client_ctx->recon_buffer_ion_handle[i] = NULL; - } - } - memset(control, 0, sizeof(struct vcd_property_enc_recon_buffer)); - return true; -} - -u32 vid_enc_get_recon_buffer_size(struct video_client_ctx *client_ctx, - struct venc_recon_buff_size *venc_recon_size) -{ - u32 vcd_status = VCD_ERR_FAIL; - struct vcd_property_hdr vcd_property_hdr; - struct vcd_property_buffer_size control; - - control.width = venc_recon_size->width; - control.height = venc_recon_size->height; - - vcd_property_hdr.prop_id = VCD_I_GET_RECON_BUFFER_SIZE; - vcd_property_hdr.sz = sizeof(struct vcd_property_buffer_size); - - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &control); - - venc_recon_size->width = control.width; - venc_recon_size->height = control.height; - venc_recon_size->size = control.size; - venc_recon_size->alignment = control.alignment; - DBG("W: %d, H: %d, S: %d, A: %d", venc_recon_size->width, - venc_recon_size->height, venc_recon_size->size, - venc_recon_size->alignment); - - if (!vcd_status) { - DBG("vcd_set_property returned success\n"); - return true; - } else { - ERR("%s(): vid_enc_get_recon_buffer_size failed = %u\n", - __func__, vcd_status); - return false; - } -} - -u32 vid_enc_set_get_ltrmode(struct video_client_ctx *client_ctx, - struct venc_ltrmode *venc_ltrmode, u32 set_flag) -{ - struct vcd_property_ltrmode_type vcd_property_ltrmode; - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !venc_ltrmode) - return false; - - vcd_property_hdr.prop_id = VCD_I_LTR_MODE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_ltrmode_type); - - if (set_flag) { - vcd_property_ltrmode.ltr_mode = (enum vcd_property_ltrmode) - venc_ltrmode->ltr_mode; - DBG("%s: Set ltr_mode = %u", __func__, - (u32)vcd_property_ltrmode.ltr_mode); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltrmode); - if (vcd_status) { - ERR("%s(): Set VCD_I_LTR_MODE Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltrmode); - if (vcd_status) { - ERR("%s(): Get VCD_I_LTR_MODE Failed\n", - __func__); - return false; - } else { - venc_ltrmode->ltr_mode = (unsigned long) - vcd_property_ltrmode.ltr_mode; - DBG("%s: Got ltr_mode = %u", __func__, - (u32)vcd_property_ltrmode.ltr_mode); - } - } - - return true; -} - -u32 vid_enc_set_get_ltrcount(struct video_client_ctx *client_ctx, - struct venc_ltrcount *venc_ltrcount, u32 set_flag) -{ - struct vcd_property_ltrcount_type vcd_property_ltrcount; - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !venc_ltrcount) - return false; - - vcd_property_hdr.prop_id = VCD_I_LTR_COUNT; - vcd_property_hdr.sz = - sizeof(struct vcd_property_ltrcount_type); - - if (set_flag) { - vcd_property_ltrcount.ltr_count = (u32) - venc_ltrcount->ltr_count; - DBG("%s: Set ltr_count = %u", __func__, - (u32)vcd_property_ltrcount.ltr_count); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltrcount); - if (vcd_status) { - ERR("%s(): Set VCD_I_LTR_COUNT Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltrcount); - if (vcd_status) { - ERR("%s(): Get VCD_I_LTR_COUNT Failed\n", - __func__); - return false; - } else { - venc_ltrcount->ltr_count = (unsigned long) - vcd_property_ltrcount.ltr_count; - DBG("%s: Got ltr_count = %u", __func__, - (u32)vcd_property_ltrcount.ltr_count); - } - } - - return true; -} - -u32 vid_enc_set_get_ltrperiod(struct video_client_ctx *client_ctx, - struct venc_ltrperiod *venc_ltrperiod, u32 set_flag) -{ - struct vcd_property_ltrperiod_type vcd_property_ltrperiod; - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !venc_ltrperiod) - return false; - - vcd_property_hdr.prop_id = VCD_I_LTR_PERIOD; - vcd_property_hdr.sz = - sizeof(struct vcd_property_ltrperiod_type); - - if (set_flag) { - vcd_property_ltrperiod.ltr_period = (u32) - venc_ltrperiod->ltr_period; - DBG("%s: Set ltr_period = %u", __func__, - (u32)vcd_property_ltrperiod.ltr_period); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltrperiod); - if (vcd_status) { - ERR("%s(): Set VCD_I_LTR_PERIOD Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltrperiod); - if (vcd_status) { - ERR("%s(): Get VCD_I_LTR_PERIOD Failed\n", - __func__); - return false; - } else { - venc_ltrperiod->ltr_period = (unsigned long) - vcd_property_ltrperiod.ltr_period; - DBG("%s: Got ltr_period = %u", __func__, - (u32)vcd_property_ltrperiod.ltr_period); - } - } - - return true; -} - -u32 vid_enc_set_get_ltruse(struct video_client_ctx *client_ctx, - struct venc_ltruse *venc_ltruse, u32 set_flag) -{ - struct vcd_property_ltruse_type vcd_property_ltruse; - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !venc_ltruse) - return false; - - vcd_property_hdr.prop_id = VCD_I_LTR_USE; - vcd_property_hdr.sz = - sizeof(struct vcd_property_ltruse_type); - - if (set_flag) { - vcd_property_ltruse.ltr_id = (u32) - venc_ltruse->ltr_id; - vcd_property_ltruse.ltr_frames = (u32) - venc_ltruse->ltr_frames; - DBG("%s: Set ltr_id = %u, ltr_frames = %u", - __func__, vcd_property_ltruse.ltr_id, - vcd_property_ltruse.ltr_frames); - vcd_status = vcd_set_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltruse); - if (vcd_status) { - ERR("%s(): Set VCD_I_LTR_USE Failed\n", - __func__); - return false; - } - } else { - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_ltruse); - if (vcd_status) { - ERR("%s(): Get VCD_I_LTR_USE Failed\n", - __func__); - return false; - } else { - venc_ltruse->ltr_id = (unsigned long) - vcd_property_ltruse.ltr_id; - venc_ltruse->ltr_frames = (unsigned long) - vcd_property_ltruse.ltr_frames; - DBG("%s: Got ltr_id = %u, ltr_frames = %u", - __func__, vcd_property_ltruse.ltr_id, - vcd_property_ltruse.ltr_frames); - } - } - - return true; -} - -u32 vid_enc_get_capability_ltrcount(struct video_client_ctx *client_ctx, - struct venc_range *venc_capltrcount) -{ - struct vcd_property_range_type vcd_property_range; - struct vcd_property_hdr vcd_property_hdr; - u32 vcd_status = VCD_ERR_FAIL; - - if (!client_ctx || !venc_capltrcount) - return false; - - vcd_property_hdr.prop_id = VCD_I_CAPABILITY_LTR_COUNT; - vcd_property_hdr.sz = sizeof(struct vcd_property_range_type); - vcd_status = vcd_get_property(client_ctx->vcd_handle, - &vcd_property_hdr, &vcd_property_range); - if (vcd_status) { - ERR("%s(): Get VCD_I_CAPABILITY_LTR_COUNT Failed\n", - __func__); - return false; - } else { - venc_capltrcount->min = vcd_property_range.min; - venc_capltrcount->max = vcd_property_range.max; - venc_capltrcount->step_size = vcd_property_range.step_size; - DBG("%s: Got min: %lu, max: %lu, step_size: %lu", __func__, - venc_capltrcount->min, venc_capltrcount->max, - venc_capltrcount->step_size); - } - - return true; -} diff --git a/drivers/video/msm/vidc/common/enc/venc_internal.h b/drivers/video/msm/vidc/common/enc/venc_internal.h deleted file mode 100644 index b7b8c982920aec15061b67cc8537ae0dc576d60b..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/enc/venc_internal.h +++ /dev/null @@ -1,170 +0,0 @@ -/* Copyright (c) 2012-2013, 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 VENC_INTERNAL_H -#define VENC_INTERNAL_H - -#include -#include -#include - -#define NUM_OF_DRIVER_NODES 2 -#define VID_ENC_MAX_NUM_OF_BUFF 100 - -enum venc_buffer_dir{ - VEN_BUFFER_TYPE_INPUT, - VEN_BUFFER_TYPE_OUTPUT -}; - -struct vid_enc_msg { - struct list_head list; - struct venc_msg venc_msg_info; -}; - -struct vid_enc_dev { - - struct cdev cdev[NUM_OF_DRIVER_NODES]; - struct device *device[NUM_OF_DRIVER_NODES]; - resource_size_t phys_base; - void __iomem *virt_base; - unsigned int irq; - struct clk *hclk; - struct clk *hclk_div2; - struct clk *pclk; - unsigned long hclk_rate; - struct mutex lock; - s32 device_handle; - struct video_client_ctx venc_clients[VIDC_MAX_NUM_CLIENTS]; - u32 num_clients; -}; - -u32 vid_enc_set_get_base_cfg(struct video_client_ctx *client_ctx, - struct venc_basecfg *base_config, u32 set_flag); - -u32 vid_enc_set_get_inputformat(struct video_client_ctx *client_ctx, - u32 *input_format, u32 set_flag); - -u32 vid_enc_set_get_codec(struct video_client_ctx *client_ctx, u32 *codec, - u32 set_flag); - -u32 vid_enc_set_get_framesize(struct video_client_ctx *client_ctx, - u32 *height, u32 *width, u32 set_flag); - -u32 vid_enc_set_get_bitrate(struct video_client_ctx *client_ctx, - struct venc_targetbitrate *venc_bitrate, u32 set_flag); - -u32 vid_enc_set_get_framerate(struct video_client_ctx *client_ctx, - struct venc_framerate *frame_rate, u32 set_flag); - -u32 vid_enc_set_get_live_mode(struct video_client_ctx *client_ctx, - struct venc_switch *encoder_switch, u32 set_flag); - -u32 vid_enc_set_get_extradata(struct video_client_ctx *client_ctx, - u32 *extradata_flag, u32 set_flag); - -u32 vid_enc_set_get_short_header(struct video_client_ctx *client_ctx, - struct venc_switch *encoder_switch, u32 set_flag); - -u32 vid_enc_set_get_profile(struct video_client_ctx *client_ctx, - struct venc_profile *profile, u32 set_flag); - -u32 vid_enc_set_get_profile_level(struct video_client_ctx *client_ctx, - struct ven_profilelevel *profile_level, u32 set_flag); - -u32 vid_enc_set_get_session_qp(struct video_client_ctx *client_ctx, - struct venc_sessionqp *session_qp, u32 set_flag); - -u32 vid_enc_set_get_intraperiod(struct video_client_ctx *client_ctx, - struct venc_intraperiod *intraperiod, u32 set_flag); - -u32 vid_enc_request_iframe(struct video_client_ctx *client_ctx); - -u32 vid_enc_get_sequence_header(struct video_client_ctx *client_ctx, - struct venc_seqheader *seq_header); - -u32 vid_enc_set_get_entropy_cfg(struct video_client_ctx *client_ctx, - struct venc_entropycfg *entropy_cfg, u32 set_flag); - -u32 vid_enc_set_get_dbcfg(struct video_client_ctx *client_ctx, - struct venc_dbcfg *dbcfg, u32 set_flag); - -u32 vid_enc_set_get_intrarefresh(struct video_client_ctx *client_ctx, - struct venc_intrarefresh *intrarefresh, u32 set_flag); - -u32 vid_enc_set_get_multiclicecfg(struct video_client_ctx *client_ctx, - struct venc_multiclicecfg *multiclicecfg, u32 set_flag); - -u32 vid_enc_set_get_ratectrlcfg(struct video_client_ctx *client_ctx, - struct venc_ratectrlcfg *ratectrlcfg, u32 set_flag); - -u32 vid_enc_set_get_voptimingcfg(struct video_client_ctx *client_ctx, - struct venc_voptimingcfg *voptimingcfg, u32 set_flag); - -u32 vid_enc_set_get_headerextension(struct video_client_ctx *client_ctx, - struct venc_headerextension *headerextension, u32 set_flag); - -u32 vid_enc_set_get_qprange(struct video_client_ctx *client_ctx, - struct venc_qprange *qprange, u32 set_flag); - -u32 vid_enc_start_stop(struct video_client_ctx *client_ctx, u32 start); - -u32 vid_enc_pause_resume(struct video_client_ctx *client_ctx, u32 pause); - -u32 vid_enc_flush(struct video_client_ctx *client_ctx, - struct venc_bufferflush *bufferflush); - -u32 vid_enc_get_buffer_req(struct video_client_ctx *client_ctx, - struct venc_allocatorproperty *venc_buf_req, u32 input_dir); - -u32 vid_enc_set_buffer_req(struct video_client_ctx *client_ctx, - struct venc_allocatorproperty *venc_buf_req, u32 input_dir); - -u32 vid_enc_set_buffer(struct video_client_ctx *client_ctx, - struct venc_bufferpayload *buffer_info, - enum venc_buffer_dir buffer); - -u32 vid_enc_free_buffer(struct video_client_ctx *client_ctx, - struct venc_bufferpayload *buffer_info, - enum venc_buffer_dir buffer); - -u32 vid_enc_encode_frame(struct video_client_ctx *client_ctx, - struct venc_buffer *input_frame_info); - -u32 vid_enc_fill_output_buffer(struct video_client_ctx *client_ctx, - struct venc_buffer *output_frame_info); - -u32 vid_enc_set_recon_buffers(struct video_client_ctx *client_ctx, - struct venc_recon_addr *venc_recon); - -u32 vid_enc_free_recon_buffers(struct video_client_ctx *client_ctx, - struct venc_recon_addr *venc_recon); - -u32 vid_enc_get_recon_buffer_size(struct video_client_ctx *client_ctx, - struct venc_recon_buff_size *venc_recon_size); - -u32 vid_enc_set_get_ltrmode(struct video_client_ctx *client_ctx, - struct venc_ltrmode *encoder_ltrmode, u32 set_flag); - -u32 vid_enc_set_get_ltrcount(struct video_client_ctx *client_ctx, - struct venc_ltrcount *encoder_ltrcount, u32 set_flag); - -u32 vid_enc_set_get_ltrperiod(struct video_client_ctx *client_ctx, - struct venc_ltrperiod *encoder_ltrperiod, u32 set_flag); - -u32 vid_enc_get_capability_ltrcount(struct video_client_ctx *client_ctx, - struct venc_range *venc_capltrcount); - -u32 vid_enc_set_get_ltruse(struct video_client_ctx *client_ctx, - struct venc_ltruse *encoder_ltruse, u32 set_flag); - -#endif diff --git a/drivers/video/msm/vidc/common/init/vidc_init.c b/drivers/video/msm/vidc/common/init/vidc_init.c deleted file mode 100644 index 087f13450b8a1bd917687dd0998bbe29af73092d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/init/vidc_init.c +++ /dev/null @@ -1,899 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "vidc_init_internal.h" -#include "vcd_res_tracker_api.h" - -#if DEBUG -#define DBG(x...) printk(KERN_DEBUG x) -#else -#define DBG(x...) -#endif - -#define VIDC_NAME "msm_vidc_reg" - -#define ERR(x...) printk(KERN_ERR x) - -static struct vidc_dev *vidc_device_p; -static dev_t vidc_dev_num; -static struct class *vidc_class; - -static const struct file_operations vidc_fops = { - .owner = THIS_MODULE, - .open = NULL, - .release = NULL, - .unlocked_ioctl = NULL, -}; - -struct workqueue_struct *vidc_wq; -struct workqueue_struct *vidc_timer_wq; -static irqreturn_t vidc_isr(int irq, void *dev); -static spinlock_t vidc_spin_lock; - -u32 vidc_msg_timing, vidc_msg_pmem, vidc_msg_register; - -#ifdef VIDC_ENABLE_DBGFS -struct dentry *vidc_debugfs_root; - -struct dentry *vidc_get_debugfs_root(void) -{ - if (vidc_debugfs_root == NULL) - vidc_debugfs_root = debugfs_create_dir("vidc", NULL); - return vidc_debugfs_root; -} - -void vidc_debugfs_file_create(struct dentry *root, const char *name, - u32 *var) -{ - struct dentry *vidc_debugfs_file = - debugfs_create_u32(name, S_IRUGO | S_IWUSR, root, var); - if (!vidc_debugfs_file) - ERR("%s(): Error creating/opening file %s\n", __func__, name); -} -#endif - -static void vidc_timer_fn(unsigned long data) -{ - unsigned long flag; - struct vidc_timer *hw_timer = NULL; - ERR("%s() Timer expired\n", __func__); - spin_lock_irqsave(&vidc_spin_lock, flag); - hw_timer = (struct vidc_timer *)data; - list_add_tail(&hw_timer->list, &vidc_device_p->vidc_timer_queue); - spin_unlock_irqrestore(&vidc_spin_lock, flag); - DBG("Queue the work for timer\n"); - queue_work(vidc_timer_wq, &vidc_device_p->vidc_timer_worker); -} - -static void vidc_timer_handler(struct work_struct *work) -{ - unsigned long flag = 0; - u32 islist_empty = 0; - struct vidc_timer *hw_timer = NULL; - - ERR("%s() Timer expired\n", __func__); - do { - spin_lock_irqsave(&vidc_spin_lock, flag); - islist_empty = list_empty(&vidc_device_p->vidc_timer_queue); - if (!islist_empty) { - hw_timer = list_first_entry( - &vidc_device_p->vidc_timer_queue, - struct vidc_timer, list); - list_del(&hw_timer->list); - } - spin_unlock_irqrestore(&vidc_spin_lock, flag); - if (!islist_empty && hw_timer && hw_timer->cb_func) - hw_timer->cb_func(hw_timer->userdata); - } while (!islist_empty); -} - -static void vidc_work_handler(struct work_struct *work) -{ - DBG("vidc_work_handler()"); - vcd_read_and_clear_interrupt(); - vcd_response_handler(); - enable_irq(vidc_device_p->irq); - DBG("vidc_work_handler() done"); -} - -static DECLARE_WORK(vidc_work, vidc_work_handler); - -static int vidc_720p_probe(struct platform_device *pdev) -{ - struct resource *resource; - DBG("Enter %s()\n", __func__); - - if (pdev->id) { - ERR("Invalid plaform device ID = %d\n", pdev->id); - return -EINVAL; - } - vidc_device_p->irq = platform_get_irq(pdev, 0); - if (unlikely(vidc_device_p->irq < 0)) { - ERR("%s(): Invalid irq = %d\n", __func__, - vidc_device_p->irq); - return -ENXIO; - } - - resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (unlikely(!resource)) { - ERR("%s(): Invalid resource\n", __func__); - return -ENXIO; - } - - vidc_device_p->phys_base = resource->start; - vidc_device_p->virt_base = ioremap(resource->start, - resource->end - resource->start + 1); - - if (!vidc_device_p->virt_base) { - ERR("%s() : ioremap failed\n", __func__); - return -ENOMEM; - } - vidc_device_p->device = &pdev->dev; - mutex_init(&vidc_device_p->lock); - - vidc_wq = create_singlethread_workqueue("vidc_worker_queue"); - if (!vidc_wq) { - ERR("%s: create workque failed\n", __func__); - return -ENOMEM; - } - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - return 0; -} - -static int vidc_720p_remove(struct platform_device *pdev) -{ - if (pdev->id) { - ERR("Invalid plaform device ID = %d\n", pdev->id); - return -EINVAL; - } - pm_runtime_disable(&pdev->dev); - - return 0; -} - -static int vidc_runtime_suspend(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: suspending...\n"); - return 0; -} - -static int vidc_runtime_resume(struct device *dev) -{ - dev_dbg(dev, "pm_runtime: resuming...\n"); - return 0; -} - -static const struct dev_pm_ops vidc_dev_pm_ops = { - .runtime_suspend = vidc_runtime_suspend, - .runtime_resume = vidc_runtime_resume, -}; - -static struct platform_driver msm_vidc_720p_platform_driver = { - .probe = vidc_720p_probe, - .remove = vidc_720p_remove, - .driver = { - .name = "msm_vidc", - .pm = &vidc_dev_pm_ops, - }, -}; - -static void __exit vidc_exit(void) -{ - platform_driver_unregister(&msm_vidc_720p_platform_driver); -} - -static irqreturn_t vidc_isr(int irq, void *dev) -{ - DBG("\n vidc_isr() %d ", irq); - disable_irq_nosync(irq); - queue_work(vidc_wq, &vidc_work); - return IRQ_HANDLED; -} - -static int __init vidc_init(void) -{ - int rc = 0; - struct device *class_devp; -#ifdef VIDC_ENABLE_DBGFS - struct dentry *root = NULL; -#endif - - vidc_device_p = kzalloc(sizeof(struct vidc_dev), GFP_KERNEL); - if (!vidc_device_p) { - ERR("%s Unable to allocate memory for vidc_dev\n", - __func__); - return -ENOMEM; - } - - rc = alloc_chrdev_region(&vidc_dev_num, 0, 1, VIDC_NAME); - if (rc < 0) { - ERR("%s: alloc_chrdev_region Failed rc = %d\n", - __func__, rc); - goto error_vidc_alloc_chrdev_region; - } - - vidc_class = class_create(THIS_MODULE, VIDC_NAME); - if (IS_ERR(vidc_class)) { - rc = PTR_ERR(vidc_class); - ERR("%s: couldn't create vidc_class rc = %d\n", - __func__, rc); - - goto error_vidc_class_create; - } - - class_devp = device_create(vidc_class, NULL, vidc_dev_num, NULL, - VIDC_NAME); - - if (IS_ERR(class_devp)) { - rc = PTR_ERR(class_devp); - ERR("%s: class device_create failed %d\n", - __func__, rc); - goto error_vidc_class_device_create; - } - - cdev_init(&vidc_device_p->cdev, &vidc_fops); - vidc_device_p->cdev.owner = THIS_MODULE; - rc = cdev_add(&(vidc_device_p->cdev), vidc_dev_num, 1); - - if (rc < 0) { - ERR("%s: cdev_add failed %d\n", __func__, rc); - goto error_vidc_cdev_add; - } - - rc = platform_driver_register(&msm_vidc_720p_platform_driver); - if (rc) { - ERR("%s failed to load\n", __func__); - goto error_vidc_platfom_register; - } - - rc = request_irq(vidc_device_p->irq, vidc_isr, IRQF_TRIGGER_HIGH, - "vidc", vidc_device_p->device); - - if (unlikely(rc)) { - ERR("%s() :request_irq failed\n", __func__); - goto error_vidc_request_irq; - } - res_trk_init(vidc_device_p->device, vidc_device_p->irq); - vidc_timer_wq = create_singlethread_workqueue("vidc_timer_wq"); - if (!vidc_timer_wq) { - ERR("%s: create workque failed\n", __func__); - rc = -ENOMEM; - goto error_vidc_create_workqueue; - } - DBG("Disabling IRQ in %s()\n", __func__); - disable_irq_nosync(vidc_device_p->irq); - INIT_WORK(&vidc_device_p->vidc_timer_worker, - vidc_timer_handler); - spin_lock_init(&vidc_spin_lock); - INIT_LIST_HEAD(&vidc_device_p->vidc_timer_queue); - - vidc_device_p->ref_count = 0; - vidc_device_p->firmware_refcount = 0; - vidc_device_p->get_firmware = 0; -#ifdef VIDC_ENABLE_DBGFS - root = vidc_get_debugfs_root(); - if (root) { - vidc_debugfs_file_create(root, "vidc_msg_timing", - (u32 *) &vidc_msg_timing); - vidc_debugfs_file_create(root, "vidc_msg_pmem", - (u32 *) &vidc_msg_pmem); - vidc_debugfs_file_create(root, "vidc_msg_register", - (u32 *) &vidc_msg_register); - } -#endif - return 0; - -error_vidc_create_workqueue: - free_irq(vidc_device_p->irq, vidc_device_p->device); -error_vidc_request_irq: - platform_driver_unregister(&msm_vidc_720p_platform_driver); -error_vidc_platfom_register: - cdev_del(&(vidc_device_p->cdev)); -error_vidc_cdev_add: - device_destroy(vidc_class, vidc_dev_num); -error_vidc_class_device_create: - class_destroy(vidc_class); -error_vidc_class_create: - unregister_chrdev_region(vidc_dev_num, 1); -error_vidc_alloc_chrdev_region: - kfree(vidc_device_p); - - return rc; -} - -void __iomem *vidc_get_ioaddr(void) -{ - return (u8 *)vidc_device_p->virt_base; -} -EXPORT_SYMBOL(vidc_get_ioaddr); - -int vidc_load_firmware(void) -{ - u32 status = true; - - if (!res_trk_check_for_sec_session()) { - mutex_lock(&vidc_device_p->lock); - if (!vidc_device_p->get_firmware) { - status = res_trk_download_firmware(); - if (!status) - goto error; - vidc_device_p->get_firmware = 1; - } - vidc_device_p->firmware_refcount++; -error: - mutex_unlock(&vidc_device_p->lock); - } - return status; -} -EXPORT_SYMBOL(vidc_load_firmware); - -void vidc_release_firmware(void) -{ - if (!res_trk_check_for_sec_session()) { - mutex_lock(&vidc_device_p->lock); - if (vidc_device_p->firmware_refcount > 0) - vidc_device_p->firmware_refcount--; - else - vidc_device_p->firmware_refcount = 0; - mutex_unlock(&vidc_device_p->lock); - } -} -EXPORT_SYMBOL(vidc_release_firmware); - -u32 vidc_get_fd_info(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, int pmem_fd, - unsigned long kvaddr, int index, - struct ion_handle **buff_handle) -{ - struct buf_addr_table *buf_addr_table; - u32 rc = 0; - if (!client_ctx) - return false; - if (buffer == BUFFER_TYPE_INPUT) - buf_addr_table = client_ctx->input_buf_addr_table; - else - buf_addr_table = client_ctx->output_buf_addr_table; - if (buf_addr_table[index].pmem_fd == pmem_fd) { - if (buf_addr_table[index].kernel_vaddr == kvaddr) { - rc = buf_addr_table[index].buff_ion_flag; - *buff_handle = buf_addr_table[index].buff_ion_handle; - } else - *buff_handle = NULL; - } else - *buff_handle = NULL; - return rc; -} -EXPORT_SYMBOL(vidc_get_fd_info); - -void vidc_cleanup_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer) -{ - u32 *num_of_buffers = NULL; - u32 i = 0; - struct buf_addr_table *buf_addr_table; - if (buffer == BUFFER_TYPE_INPUT) { - buf_addr_table = client_ctx->input_buf_addr_table; - num_of_buffers = &client_ctx->num_of_input_buffers; - DBG("%s(): buffer = INPUT\n", __func__); - - } else { - buf_addr_table = client_ctx->output_buf_addr_table; - num_of_buffers = &client_ctx->num_of_output_buffers; - DBG("%s(): buffer = OUTPUT\n", __func__); - } - - if (!*num_of_buffers) - goto bail_out_cleanup; - if (!client_ctx->user_ion_client) - goto bail_out_cleanup; - for (i = 0; i < *num_of_buffers; ++i) { - if (!IS_ERR_OR_NULL(buf_addr_table[i].buff_ion_handle)) { - if (!IS_ERR_OR_NULL(client_ctx->user_ion_client)) { - ion_unmap_kernel(client_ctx->user_ion_client, - buf_addr_table[i]. - buff_ion_handle); - if (!res_trk_check_for_sec_session() && - (res_trk_get_core_type() != - (u32)VCD_CORE_720P)) { - ion_unmap_iommu( - client_ctx->user_ion_client, - buf_addr_table[i]. - buff_ion_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(client_ctx->user_ion_client, - buf_addr_table[i]. - buff_ion_handle); - buf_addr_table[i].buff_ion_handle = NULL; - } - } - } - if (!IS_ERR_OR_NULL(client_ctx->h264_mv_ion_handle)) { - if (!IS_ERR_OR_NULL(client_ctx->user_ion_client)) { - ion_unmap_kernel(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle); - if (!res_trk_check_for_sec_session() && - (res_trk_get_core_type() != (u32)VCD_CORE_720P)) { - ion_unmap_iommu(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(client_ctx->user_ion_client, - client_ctx->h264_mv_ion_handle); - client_ctx->h264_mv_ion_handle = NULL; - } - } -bail_out_cleanup: - return; -} -EXPORT_SYMBOL(vidc_cleanup_addr_table); - -u32 vidc_lookup_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, - u32 search_with_user_vaddr, - unsigned long *user_vaddr, - unsigned long *kernel_vaddr, - unsigned long *phy_addr, int *pmem_fd, - struct file **file, s32 *buffer_index) -{ - u32 num_of_buffers; - u32 i; - struct buf_addr_table *buf_addr_table; - u32 found = false; - - if (!client_ctx) - return false; - mutex_lock(&client_ctx->enrty_queue_lock); - if (buffer == BUFFER_TYPE_INPUT) { - buf_addr_table = client_ctx->input_buf_addr_table; - num_of_buffers = client_ctx->num_of_input_buffers; - DBG("%s(): buffer = INPUT\n", __func__); - - } else { - buf_addr_table = client_ctx->output_buf_addr_table; - num_of_buffers = client_ctx->num_of_output_buffers; - DBG("%s(): buffer = OUTPUT\n", __func__); - } - - for (i = 0; i < num_of_buffers; ++i) { - if (search_with_user_vaddr) { - if (*user_vaddr == buf_addr_table[i].user_vaddr) { - *kernel_vaddr = buf_addr_table[i].kernel_vaddr; - found = true; - DBG("%s() : client_ctx = %p." - " user_virt_addr = 0x%08lx is found", - __func__, client_ctx, *user_vaddr); - break; - } - } else { - if (*kernel_vaddr == buf_addr_table[i].kernel_vaddr) { - *user_vaddr = buf_addr_table[i].user_vaddr; - found = true; - DBG("%s() : client_ctx = %p." - " kernel_virt_addr = 0x%08lx is found", - __func__, client_ctx, *kernel_vaddr); - break; - } - } - } - - if (found) { - *phy_addr = buf_addr_table[i].dev_addr; - *pmem_fd = buf_addr_table[i].pmem_fd; - *file = buf_addr_table[i].file; - *buffer_index = i; - - if (search_with_user_vaddr) - DBG("kernel_vaddr = 0x%08lx, phy_addr = 0x%08lx " - " pmem_fd = %d, struct *file = %p " - "buffer_index = %d\n", *kernel_vaddr, - *phy_addr, *pmem_fd, *file, *buffer_index); - else - DBG("user_vaddr = 0x%08lx, phy_addr = 0x%08lx " - " pmem_fd = %d, struct *file = %p " - "buffer_index = %d\n", *user_vaddr, *phy_addr, - *pmem_fd, *file, *buffer_index); - mutex_unlock(&client_ctx->enrty_queue_lock); - return true; - } else { - if (search_with_user_vaddr) - DBG("%s() : client_ctx = %p user_virt_addr = 0x%08lx" - " Not Found.\n", __func__, client_ctx, *user_vaddr); - else - DBG("%s() : client_ctx = %p kernel_virt_addr = 0x%08lx" - " Not Found.\n", __func__, client_ctx, - *kernel_vaddr); - mutex_unlock(&client_ctx->enrty_queue_lock); - return false; - } -} -EXPORT_SYMBOL(vidc_lookup_addr_table); - -u32 vidc_insert_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, unsigned long user_vaddr, - unsigned long *kernel_vaddr, int pmem_fd, - unsigned long buffer_addr_offset, unsigned int max_num_buffers, - unsigned long length) -{ - unsigned long len, phys_addr; - struct file *file = NULL; - u32 *num_of_buffers = NULL; - u32 i; - struct buf_addr_table *buf_addr_table; - struct ion_handle *buff_ion_handle = NULL; - unsigned long ionflag = 0; - unsigned long iova = 0; - int ret = 0; - unsigned long buffer_size = 0; - size_t ion_len; - - if (!client_ctx || !length) - return false; - mutex_lock(&client_ctx->enrty_queue_lock); - if (buffer == BUFFER_TYPE_INPUT) { - buf_addr_table = client_ctx->input_buf_addr_table; - num_of_buffers = &client_ctx->num_of_input_buffers; - DBG("%s(): buffer = INPUT #Buf = %d\n", - __func__, *num_of_buffers); - - } else { - buf_addr_table = client_ctx->output_buf_addr_table; - num_of_buffers = &client_ctx->num_of_output_buffers; - DBG("%s(): buffer = OUTPUT #Buf = %d\n", - __func__, *num_of_buffers); - length = length * 2; /* workaround for iommu video h/w bug */ - } - - if (*num_of_buffers == max_num_buffers) { - ERR("%s(): Num of buffers reached max value : %d", - __func__, max_num_buffers); - goto bail_out_add; - } - - i = 0; - while (i < *num_of_buffers && - user_vaddr != buf_addr_table[i].user_vaddr) - i++; - if (i < *num_of_buffers) { - DBG("%s() : client_ctx = %p." - " user_virt_addr = 0x%08lx already set", - __func__, client_ctx, user_vaddr); - goto bail_out_add; - } else { - if (!vcd_get_ion_status()) { - pr_err("PMEM not available\n"); - goto bail_out_add; - } else { - buff_ion_handle = ion_import_dma_buf( - client_ctx->user_ion_client, pmem_fd); - if (IS_ERR_OR_NULL(buff_ion_handle)) { - ERR("%s(): get_ION_handle failed\n", - __func__); - goto bail_out_add; - } - if (ion_handle_get_flags(client_ctx->user_ion_client, - buff_ion_handle, - &ionflag)) { - ERR("%s():ION flags fail\n", - __func__); - goto bail_out_add; - } - *kernel_vaddr = (unsigned long) - ion_map_kernel( - client_ctx->user_ion_client, - buff_ion_handle); - if (IS_ERR_OR_NULL((void *)*kernel_vaddr)) { - ERR("%s():ION virtual addr fail\n", - __func__); - *kernel_vaddr = (unsigned long)NULL; - goto ion_free_error; - } - if (res_trk_check_for_sec_session() || - (res_trk_get_core_type() == (u32)VCD_CORE_720P)) { - if (ion_phys(client_ctx->user_ion_client, - buff_ion_handle, - (ion_phys_addr_t *)&phys_addr, - &ion_len)) { - ERR("%s():ION physical addr fail\n", - __func__); - goto ion_map_error; - } - len = (unsigned long) ion_len; - buf_addr_table[*num_of_buffers].client_data = - NULL; - buf_addr_table[*num_of_buffers].dev_addr = - phys_addr; - } else { - ret = ion_map_iommu(client_ctx->user_ion_client, - buff_ion_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL, - SZ_8K, - length, - (dma_addr_t *) &iova, - (unsigned long *) &buffer_size, - 0, - ION_IOMMU_UNMAP_DELAYED); - if (ret || !iova) { - ERR( - "%s():ION iommu map fail, ret = %d, iova = 0x%lx\n", - __func__, ret, iova); - goto ion_map_error; - } - phys_addr = iova; - buf_addr_table[*num_of_buffers].client_data = - NULL; - buf_addr_table[*num_of_buffers].dev_addr = - iova; - } - } - phys_addr += buffer_addr_offset; - (*kernel_vaddr) += buffer_addr_offset; - buf_addr_table[*num_of_buffers].user_vaddr = user_vaddr; - buf_addr_table[*num_of_buffers].kernel_vaddr = *kernel_vaddr; - buf_addr_table[*num_of_buffers].pmem_fd = pmem_fd; - buf_addr_table[*num_of_buffers].file = file; - buf_addr_table[*num_of_buffers].phy_addr = phys_addr; - buf_addr_table[*num_of_buffers].buff_ion_handle = - buff_ion_handle; - buf_addr_table[*num_of_buffers].buff_ion_flag = - ionflag; - *num_of_buffers = *num_of_buffers + 1; - DBG("%s() : client_ctx = %p, user_virt_addr = 0x%08lx, " - "kernel_vaddr = 0x%08lx phys_addr=%lu inserted!", - __func__, client_ctx, user_vaddr, *kernel_vaddr, - phys_addr); - } - mutex_unlock(&client_ctx->enrty_queue_lock); - return true; -ion_map_error: - if (*kernel_vaddr && buff_ion_handle) - ion_unmap_kernel(client_ctx->user_ion_client, buff_ion_handle); -ion_free_error: - if (!IS_ERR_OR_NULL(buff_ion_handle)) - ion_free(client_ctx->user_ion_client, buff_ion_handle); -bail_out_add: - mutex_unlock(&client_ctx->enrty_queue_lock); - return false; -} -EXPORT_SYMBOL(vidc_insert_addr_table); - -/* - * Similar to vidc_insert_addr_table except intended for in-kernel - * use where buffers have already been alloced and mapped properly - */ -u32 vidc_insert_addr_table_kernel(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, unsigned long user_vaddr, - unsigned long kernel_vaddr, unsigned long phys_addr, - unsigned int max_num_buffers, - unsigned long length) -{ - u32 *num_of_buffers = NULL; - u32 i; - struct buf_addr_table *buf_addr_table; - struct msm_mapped_buffer *mapped_buffer = NULL; - - if (!client_ctx || !length || !kernel_vaddr || !phys_addr) - return false; - mutex_lock(&client_ctx->enrty_queue_lock); - if (buffer == BUFFER_TYPE_INPUT) { - buf_addr_table = client_ctx->input_buf_addr_table; - num_of_buffers = &client_ctx->num_of_input_buffers; - DBG("%s(): buffer = INPUT #Buf = %d\n", - __func__, *num_of_buffers); - - } else { - buf_addr_table = client_ctx->output_buf_addr_table; - num_of_buffers = &client_ctx->num_of_output_buffers; - DBG("%s(): buffer = OUTPUT #Buf = %d\n", - __func__, *num_of_buffers); - } - - if (*num_of_buffers == max_num_buffers) { - ERR("%s(): Num of buffers reached max value : %d", - __func__, max_num_buffers); - goto bail_out_add; - } - - i = 0; - while (i < *num_of_buffers && - user_vaddr != buf_addr_table[i].user_vaddr) { - i++; - } - if (i < *num_of_buffers) { - DBG("%s() : client_ctx = %p." - " user_virt_addr = 0x%08lx already set", - __func__, client_ctx, user_vaddr); - goto bail_out_add; - } else { - mapped_buffer = NULL; - buf_addr_table[*num_of_buffers].client_data = (void *) - mapped_buffer; - buf_addr_table[*num_of_buffers].dev_addr = phys_addr; - buf_addr_table[*num_of_buffers].user_vaddr = user_vaddr; - buf_addr_table[*num_of_buffers].kernel_vaddr = kernel_vaddr; - buf_addr_table[*num_of_buffers].pmem_fd = -1; - buf_addr_table[*num_of_buffers].file = NULL; - buf_addr_table[*num_of_buffers].phy_addr = phys_addr; - buf_addr_table[*num_of_buffers].buff_ion_handle = NULL; - *num_of_buffers = *num_of_buffers + 1; - DBG("%s() : client_ctx = %p, user_virt_addr = 0x%08lx, " - "kernel_vaddr = 0x%08lx inserted!", __func__, - client_ctx, user_vaddr, kernel_vaddr); - } - mutex_unlock(&client_ctx->enrty_queue_lock); - return true; -bail_out_add: - mutex_unlock(&client_ctx->enrty_queue_lock); - return false; -} -EXPORT_SYMBOL(vidc_insert_addr_table_kernel); - -u32 vidc_delete_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, - unsigned long user_vaddr, - unsigned long *kernel_vaddr) -{ - u32 *num_of_buffers = NULL; - u32 i; - struct buf_addr_table *buf_addr_table; - - if (!client_ctx) - return false; - mutex_lock(&client_ctx->enrty_queue_lock); - if (buffer == BUFFER_TYPE_INPUT) { - buf_addr_table = client_ctx->input_buf_addr_table; - num_of_buffers = &client_ctx->num_of_input_buffers; - - } else { - buf_addr_table = client_ctx->output_buf_addr_table; - num_of_buffers = &client_ctx->num_of_output_buffers; - } - - if (!*num_of_buffers) - goto bail_out_del; - - i = 0; - while (i < *num_of_buffers && - user_vaddr != buf_addr_table[i].user_vaddr) - i++; - if (i == *num_of_buffers) { - pr_err("%s() : client_ctx = %p." - " user_virt_addr = 0x%08lx NOT found", - __func__, client_ctx, user_vaddr); - goto bail_out_del; - } - *kernel_vaddr = buf_addr_table[i].kernel_vaddr; - if (buf_addr_table[i].buff_ion_handle) { - ion_unmap_kernel(client_ctx->user_ion_client, - buf_addr_table[i].buff_ion_handle); - if (!res_trk_check_for_sec_session() && - (res_trk_get_core_type() != (u32)VCD_CORE_720P)) { - ion_unmap_iommu(client_ctx->user_ion_client, - buf_addr_table[i].buff_ion_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - } - ion_free(client_ctx->user_ion_client, - buf_addr_table[i].buff_ion_handle); - buf_addr_table[i].buff_ion_handle = NULL; - } - if (i < (*num_of_buffers - 1)) { - buf_addr_table[i].client_data = - buf_addr_table[*num_of_buffers - 1].client_data; - buf_addr_table[i].dev_addr = - buf_addr_table[*num_of_buffers - 1].dev_addr; - buf_addr_table[i].user_vaddr = - buf_addr_table[*num_of_buffers - 1].user_vaddr; - buf_addr_table[i].kernel_vaddr = - buf_addr_table[*num_of_buffers - 1].kernel_vaddr; - buf_addr_table[i].phy_addr = - buf_addr_table[*num_of_buffers - 1].phy_addr; - buf_addr_table[i].pmem_fd = - buf_addr_table[*num_of_buffers - 1].pmem_fd; - buf_addr_table[i].file = - buf_addr_table[*num_of_buffers - 1].file; - buf_addr_table[i].buff_ion_handle = - buf_addr_table[*num_of_buffers - 1].buff_ion_handle; - } - *num_of_buffers = *num_of_buffers - 1; - DBG("%s() : client_ctx = %p." - " user_virt_addr = 0x%08lx is found and deleted", - __func__, client_ctx, user_vaddr); - mutex_unlock(&client_ctx->enrty_queue_lock); - return true; -bail_out_del: - mutex_unlock(&client_ctx->enrty_queue_lock); - return false; -} -EXPORT_SYMBOL(vidc_delete_addr_table); - -u32 vidc_timer_create(void (*timer_handler)(void *), - void *user_data, void **timer_handle) -{ - struct vidc_timer *hw_timer = NULL; - if (!timer_handler || !timer_handle) { - DBG("%s(): timer creation failed\n ", __func__); - return false; - } - hw_timer = kzalloc(sizeof(struct vidc_timer), GFP_KERNEL); - if (!hw_timer) { - DBG("%s(): timer creation failed in allocation\n ", __func__); - return false; - } - init_timer(&hw_timer->hw_timeout); - hw_timer->hw_timeout.data = (unsigned long)hw_timer; - hw_timer->hw_timeout.function = vidc_timer_fn; - hw_timer->cb_func = timer_handler; - hw_timer->userdata = user_data; - *timer_handle = hw_timer; - return true; -} -EXPORT_SYMBOL(vidc_timer_create); - -void vidc_timer_release(void *timer_handle) -{ - kfree(timer_handle); -} -EXPORT_SYMBOL(vidc_timer_release); - -void vidc_timer_start(void *timer_handle, u32 time_out) -{ - struct vidc_timer *hw_timer = (struct vidc_timer *)timer_handle; - DBG("%s(): start timer\n ", __func__); - if (hw_timer) { - hw_timer->hw_timeout.expires = jiffies + 1*HZ; - add_timer(&hw_timer->hw_timeout); - } -} -EXPORT_SYMBOL(vidc_timer_start); - -void vidc_timer_stop(void *timer_handle) -{ - struct vidc_timer *hw_timer = (struct vidc_timer *)timer_handle; - DBG("%s(): stop timer\n ", __func__); - if (hw_timer) - del_timer(&hw_timer->hw_timeout); -} -EXPORT_SYMBOL(vidc_timer_stop); - -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Video decoder/encoder driver Init Module"); -MODULE_VERSION("1.0"); -module_init(vidc_init); -module_exit(vidc_exit); diff --git a/drivers/video/msm/vidc/common/init/vidc_init_internal.h b/drivers/video/msm/vidc/common/init/vidc_init_internal.h deleted file mode 100644 index b62280faebac1db8c1f3a652a11f40771f8afc5d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/init/vidc_init_internal.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2010, 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 VIDC_INIT_INTERNAL_H -#define VIDC_INIT_INTERNAL_H - -#include - -struct vidc_timer { - struct list_head list; - struct timer_list hw_timeout; - void (*cb_func)(void *); - void *userdata; -}; - -struct vidc_dev { - struct cdev cdev; - struct device *device; - resource_size_t phys_base; - void __iomem *virt_base; - unsigned int irq; - unsigned int ref_count; - unsigned int firmware_refcount; - unsigned int get_firmware; - struct mutex lock; - s32 device_handle; - struct list_head vidc_timer_queue; - struct work_struct vidc_timer_worker; -}; - -#endif diff --git a/drivers/video/msm/vidc/common/vcd/vcd.h b/drivers/video/msm/vidc/common/vcd/vcd.h deleted file mode 100644 index 90f7d0ebc3e99ec543f6a20135939e8fe6707a76..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd.h +++ /dev/null @@ -1,408 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_H_ -#define _VCD_H_ - -#include -#include "vcd_util.h" -#include "vcd_ddl_api.h" -#include "vcd_res_tracker_api.h" -#include "vcd_client_sm.h" -#include "vcd_core.h" -#include "vcd_device_sm.h" - -void vcd_reset_device_channels(struct vcd_dev_ctxt *dev_ctxt); - -u32 vcd_get_command_channel - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **transc); - -u32 vcd_get_command_channel_in_loop - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **transc); - -void vcd_mark_command_channel - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc); - -void vcd_release_command_channel - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc); - -void vcd_release_multiple_command_channels(struct vcd_dev_ctxt *dev_ctxt, - u32 channels); - -void vcd_release_interim_command_channels(struct vcd_dev_ctxt *dev_ctxt); - -u32 vcd_get_frame_channel - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **transc); - -u32 vcd_get_frame_channel_in_loop - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc **transc); - -void vcd_mark_frame_channel(struct vcd_dev_ctxt *dev_ctxt); - -void vcd_release_frame_channel - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc); - -void vcd_release_multiple_frame_channels(struct vcd_dev_ctxt *dev_ctxt, - u32 channels); - -void vcd_release_interim_frame_channels(struct vcd_dev_ctxt *dev_ctxt); -u32 vcd_core_is_busy(struct vcd_dev_ctxt *dev_ctxt); - -void vcd_device_timer_start(struct vcd_dev_ctxt *dev_ctxt); -void vcd_device_timer_stop(struct vcd_dev_ctxt *dev_ctxt); - - -u32 vcd_init_device_context - (struct vcd_drv_ctxt *drv_ctxt, u32 ev_code); - -u32 vcd_deinit_device_context - (struct vcd_drv_ctxt *drv_ctxt, u32 ev_code); - -u32 vcd_init_client_context(struct vcd_clnt_ctxt *cctxt); - -void vcd_destroy_client_context(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_check_for_client_context - (struct vcd_dev_ctxt *dev_ctxt, s32 driver_id); - -u32 vcd_validate_driver_handle - (struct vcd_dev_ctxt *dev_ctxt, s32 driver_handle); - -void vcd_handle_for_last_clnt_close - (struct vcd_dev_ctxt *dev_ctxt, u32 send_deinit); - -u32 vcd_common_allocate_set_buffer - (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer, - u32 buf_size, struct vcd_buffer_pool **buf_pool); - -u32 vcd_set_buffer_internal - (struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool, u8 *buffer, u32 buf_size); - -u32 vcd_allocate_buffer_internal - (struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool, - u32 buf_size, u8 **vir_buf_addr, u8 **phy_buf_addr); - -u32 vcd_free_one_buffer_internal - (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer_type, u8 *buffer); - -u32 vcd_free_buffers_internal - (struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool); - -u32 vcd_alloc_buffer_pool_entries - (struct vcd_buffer_pool *buf_pool, - struct vcd_buffer_requirement *buf_req); - -void vcd_free_buffer_pool_entries(struct vcd_buffer_pool *buf_pool); - -void vcd_flush_in_use_buffer_pool_entries(struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool, u32 event); - -void vcd_reset_buffer_pool_for_reuse(struct vcd_buffer_pool *buf_pool); - -struct vcd_buffer_entry *vcd_get_free_buffer_pool_entry - (struct vcd_buffer_pool *pool); - -struct vcd_buffer_entry *vcd_find_buffer_pool_entry - (struct vcd_buffer_pool *pool, u8 *v_addr); - -struct vcd_buffer_entry *vcd_buffer_pool_entry_de_q - (struct vcd_buffer_pool *pool); - -u32 vcd_buffer_pool_entry_en_q - (struct vcd_buffer_pool *pool, - struct vcd_buffer_entry *entry); - -u32 vcd_check_if_buffer_req_met(struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer_type); - -u32 vcd_client_cmd_en_q - (struct vcd_clnt_ctxt *cctxt, enum vcd_command command); - -void vcd_client_cmd_flush_and_en_q - (struct vcd_clnt_ctxt *cctxt, enum vcd_command command); - -u32 vcd_client_cmd_de_q - (struct vcd_clnt_ctxt *cctxt, enum vcd_command *command); - -u32 vcd_handle_recvd_eos - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame, u32 * pb_eos_handled); - -u32 vcd_handle_first_decode_frame(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_handle_input_frame - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame); - -u32 vcd_store_seq_hdr - (struct vcd_clnt_ctxt *cctxt, - struct vcd_sequence_hdr *seq_hdr); - -u32 vcd_set_frame_size - (struct vcd_clnt_ctxt *cctxt, - struct vcd_property_frame_size *frm_size); - -u32 vcd_set_frame_rate - (struct vcd_clnt_ctxt *cctxt, - struct vcd_property_frame_rate *fps); - -u32 vcd_calculate_frame_delta - (struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *frame); - -struct vcd_buffer_entry *vcd_check_fill_output_buffer - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *buffer); - -u32 vcd_handle_first_fill_output_buffer - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *buffer, u32 *b_handled); - -u32 vcd_handle_first_fill_output_buffer_for_enc - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *frm_entry, u32 *b_handled); - -u32 vcd_handle_first_fill_output_buffer_for_dec - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *frm_entry, u32 *b_handled); - -u32 vcd_schedule_frame(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt **cctxt, struct vcd_buffer_entry - **ip_buf_entry); - -u32 vcd_submit_command_in_continue - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc); - -u32 vcd_submit_cmd_sess_start(struct vcd_transc *transc); - -u32 vcd_submit_cmd_sess_end(struct vcd_transc *transc); - -void vcd_submit_cmd_client_close(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_submit_frame - (struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc); - -u32 vcd_try_submit_frame_in_continue(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc *transc); - -u32 vcd_process_cmd_sess_start(struct vcd_clnt_ctxt *cctxt); - -void vcd_try_submit_frame(struct vcd_dev_ctxt *dev_ctxt); - -u32 vcd_setup_with_ddl_capabilities(struct vcd_dev_ctxt *dev_ctxt); -void vcd_handle_submit_frame_failed(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc *transc); - -struct vcd_transc *vcd_get_free_trans_tbl_entry - (struct vcd_dev_ctxt *dev_ctxt); - -void vcd_release_trans_tbl_entry(struct vcd_transc *trans_entry); - -void vcd_release_all_clnt_frm_transc(struct vcd_clnt_ctxt *cctxt); -void vcd_release_all_clnt_transc(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_handle_input_done - (struct vcd_clnt_ctxt *cctxt, - void *payload, u32 event, u32 status); - -u32 vcd_handle_input_done_in_eos - (struct vcd_clnt_ctxt *cctxt, void *payload, u32 status); - -void vcd_handle_input_done_failed - (struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc); - -void vcd_handle_input_done_with_codec_config - (struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, - struct ddl_frame_data_tag *frm); - -void vcd_handle_input_done_for_interlacing - (struct vcd_clnt_ctxt *cctxt); - -void vcd_handle_input_done_with_trans_end - (struct vcd_clnt_ctxt *cctxt); - -u32 vcd_handle_frame_done - (struct vcd_clnt_ctxt *cctxt, - void *payload, u32 event, u32 status); - -void vcd_handle_frame_done_for_interlacing - (struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc_ip1, - struct ddl_frame_data_tag *op_frm, u32 status); - - -u32 vcd_handle_frame_done_in_eos - (struct vcd_clnt_ctxt *cctxt, void *payload, u32 status); - -u32 vcd_handle_output_required(struct vcd_clnt_ctxt *cctxt, - void *payload, u32 status); - -u32 vcd_handle_output_required_in_flushing(struct vcd_clnt_ctxt *cctxt, - void *payload); - -u32 vcd_handle_output_req_tran_end_in_eos(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_validate_io_done_pyld - (struct vcd_clnt_ctxt *cctxt, void *payload, u32 status); - -void vcd_handle_eos_trans_end(struct vcd_clnt_ctxt *cctxt); - - -void vcd_handle_eos_done - (struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status); - -void vcd_send_frame_done_in_eos - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame, u32 valid_opbuf); - -void vcd_send_frame_done_in_eos_for_dec - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame); - -void vcd_send_frame_done_in_eos_for_enc - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame); - -void vcd_handle_start_done(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status); - -void vcd_handle_stop_done(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status); - -void vcd_handle_stop_done_in_starting(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status); - -void vcd_handle_stop_done_in_invalid(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status); - -void vcd_send_flush_done(struct vcd_clnt_ctxt *cctxt, u32 status); - -void vcd_process_pending_flush_in_eos(struct vcd_clnt_ctxt *cctxt); - -void vcd_process_pending_stop_in_eos(struct vcd_clnt_ctxt *cctxt); - -void vcd_handle_trans_pending(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_handle_ind_output_reconfig - (struct vcd_clnt_ctxt *cctxt, void* payload, u32 status); - -u32 vcd_handle_ind_output_reconfig_in_flushing - (struct vcd_clnt_ctxt *cctxt, void* payload, u32 status); - -void vcd_flush_output_buffers(struct vcd_clnt_ctxt *cctxt); - -void vcd_flush_bframe_buffers(struct vcd_clnt_ctxt *cctxt, u32 mode); - -u32 vcd_flush_buffers(struct vcd_clnt_ctxt *cctxt, u32 mode); -void vcd_flush_buffers_in_err_fatal(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_power_event - (struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *cctxt, u32 event); - -u32 vcd_device_power_event(struct vcd_dev_ctxt *dev_ctxt, u32 event, - struct vcd_clnt_ctxt *cctxt); - -u32 vcd_client_power_event - (struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *cctxt, u32 event); - -u32 vcd_enable_clock(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *cctxt); - -u32 vcd_disable_clock(struct vcd_dev_ctxt *dev_ctxt); - -u32 vcd_set_perf_level(struct vcd_dev_ctxt *dev_ctxt, u32 perf_lvl); - -u32 vcd_update_clnt_perf_lvl - (struct vcd_clnt_ctxt *cctxt, - struct vcd_property_frame_rate *fps, u32 frm_p_units); - -u32 vcd_gate_clock(struct vcd_dev_ctxt *dev_ctxt); - -u32 vcd_un_gate_clock(struct vcd_dev_ctxt *dev_ctxt); - -void vcd_handle_err_fatal(struct vcd_clnt_ctxt *cctxt, - u32 event, u32 status); - -void vcd_handle_device_err_fatal(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *cctxt); - -void vcd_clnt_handle_device_err_fatal(struct vcd_clnt_ctxt *cctxt, - u32 event); - -void vcd_handle_err_in_starting(struct vcd_clnt_ctxt *cctxt, - u32 status); - -void vcd_handle_ind_hw_err_fatal(struct vcd_clnt_ctxt *cctxt, - u32 event, u32 status); - -u32 vcd_return_op_buffer_to_hw(struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_entry *buf_entry); - -u32 vcd_sched_create(struct list_head *sched_list); - -void vcd_sched_destroy(struct list_head *sched_clnt_list); - -u32 vcd_sched_add_client(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_sched_remove_client(struct vcd_sched_clnt_ctx *sched_cctxt); - -u32 vcd_sched_update_config(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_sched_queue_buffer( - struct vcd_sched_clnt_ctx *sched_cctxt, - struct vcd_buffer_entry *buffer, u32 b_tail); - -u32 vcd_sched_dequeue_buffer( - struct vcd_sched_clnt_ctx *sched_cctxt, - struct vcd_buffer_entry **buffer); - -u32 vcd_sched_mark_client_eof(struct vcd_sched_clnt_ctx *sched_cctxt); - -u32 vcd_sched_suspend_resume_clnt( - struct vcd_clnt_ctxt *cctxt, u32 b_state); - -u32 vcd_sched_get_client_frame(struct list_head *sched_clnt_list, - struct vcd_clnt_ctxt **cctxt, - struct vcd_buffer_entry **buffer); - -void vcd_handle_clnt_fatal(struct vcd_clnt_ctxt *cctxt, u32 trans_end); - -void vcd_handle_clnt_fatal_input_done(struct vcd_clnt_ctxt *cctxt, - u32 trans_end); - -void vcd_handle_ind_info_output_reconfig - (struct vcd_clnt_ctxt *cctxt, u32 status); - -u32 vcd_req_perf_level(struct vcd_clnt_ctxt *cctxt, - struct vcd_property_perf_level *); - -u32 vcd_set_num_slices(struct vcd_clnt_ctxt *cctxt); - -u32 vcd_update_decoder_perf_level(struct vcd_dev_ctxt *dev_ctxt, u32 perf_lvl); - -u32 vcd_set_perf_turbo_level(struct vcd_clnt_ctxt *cctxt); - -struct vcd_transc *vcd_get_first_in_use_trans_for_clnt( - struct vcd_clnt_ctxt *cctxt); - -u32 vcd_handle_ltr_use_failed(struct vcd_clnt_ctxt *cctxt, - void *payload, size_t sz, u32 status); - -#endif diff --git a/drivers/video/msm/vidc/common/vcd/vcd_api.c b/drivers/video/msm/vidc/common/vcd/vcd_api.c deleted file mode 100644 index 3d7474f2ffb40b533395bc53d2c5afa7253df8c3..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_api.c +++ /dev/null @@ -1,981 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include "vcd.h" - -u32 vcd_init(struct vcd_init_config *config, s32 *driver_handle) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_drv_ctxt *drv_ctxt; - - VCD_MSG_MED("vcd_init:"); - - if (!config || - !driver_handle || !config->map_dev_base_addr) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_ILLEGAL_PARM; - } - - drv_ctxt = vcd_get_drv_context(); - mutex_init(&drv_ctxt->dev_mutex); - mutex_lock(&drv_ctxt->dev_mutex); - - if (drv_ctxt->dev_state.state_table->ev_hdlr.init) { - rc = drv_ctxt->dev_state.state_table->ev_hdlr. - init(drv_ctxt, config, driver_handle); - } else { - VCD_MSG_ERROR("Unsupported API in device state %d", - drv_ctxt->dev_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_init); - -u32 vcd_term(s32 driver_handle) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_drv_ctxt *drv_ctxt; - - VCD_MSG_MED("vcd_term:"); - - drv_ctxt = vcd_get_drv_context(); - mutex_lock(&drv_ctxt->dev_mutex); - - if (drv_ctxt->dev_state.state_table->ev_hdlr.term) { - rc = drv_ctxt->dev_state.state_table->ev_hdlr. - term(drv_ctxt, driver_handle); - } else { - VCD_MSG_ERROR("Unsupported API in device state %d", - drv_ctxt->dev_state.state); - - rc = VCD_ERR_BAD_STATE; - } - mutex_unlock(&drv_ctxt->dev_mutex); - return rc; - -} -EXPORT_SYMBOL(vcd_term); - -struct client_security_info { - int secure_enc; - int secure_dec; - int non_secure_enc; - int non_secure_dec; -}; - -static int vcd_get_clients_security_info(struct client_security_info *sec_info) -{ - struct vcd_drv_ctxt *drv_ctxt; - struct vcd_clnt_ctxt *cctxt; - int count = 0; - if (!sec_info) { - VCD_MSG_ERROR("Invalid argument\n"); - return -EINVAL; - } - memset(sec_info, 0 , sizeof(*sec_info)); - drv_ctxt = vcd_get_drv_context(); - mutex_lock(&drv_ctxt->dev_mutex); - cctxt = drv_ctxt->dev_ctxt.cctxt_list_head; - while (cctxt) { - if (cctxt->secure && cctxt->decoding) - sec_info->secure_dec++; - else if (cctxt->secure && !cctxt->decoding) - sec_info->secure_enc++; - else if (!cctxt->secure && cctxt->decoding) - sec_info->non_secure_dec++; - else - sec_info->non_secure_enc++; - count++; - cctxt = cctxt->next; - } - mutex_unlock(&drv_ctxt->dev_mutex); - return count; -} - -static int is_session_invalid(u32 decoding, u32 flags) -{ - int is_secure; - struct client_security_info sec_info; - int client_count = 0; - int secure_session_running = 0, non_secure_runnung = 0; - is_secure = (flags & VCD_CP_SESSION) ? 1 : 0; - client_count = vcd_get_clients_security_info(&sec_info); - secure_session_running = (sec_info.secure_enc > 0) || - (sec_info.secure_dec > 0); - non_secure_runnung = sec_info.non_secure_dec + sec_info.non_secure_enc; - if (!is_secure) { - if (secure_session_running) { - pr_err("non secure session failed secure running\n"); - return -EACCES; - } - } else { - if (non_secure_runnung) { - pr_err("Secure session failed non secure running\n"); - return -EACCES; - } - } - return 0; -} - -u32 vcd_open(s32 driver_handle, u32 decoding, - void (*callback) (u32 event, u32 status, void *info, size_t sz, - void *handle, void *const client_data), - void *client_data, int flags) -{ - u32 rc = 0, num_of_instances = 0; - struct vcd_drv_ctxt *drv_ctxt; - struct vcd_clnt_ctxt *cctxt; - int is_secure = (flags & VCD_CP_SESSION) ? 1 : 0; - VCD_MSG_MED("vcd_open:"); - - if (!callback) { - VCD_MSG_ERROR("Bad parameters"); - return -EINVAL; - } - - drv_ctxt = vcd_get_drv_context(); - cctxt = drv_ctxt->dev_ctxt.cctxt_list_head; - while (cctxt) { - num_of_instances++; - cctxt = cctxt->next; - } - if (num_of_instances == VIDC_MAX_NUM_CLIENTS) { - pr_err(" %s(): Max number of clients reached\n", __func__); - return -ENODEV; - } - rc = is_session_invalid(decoding, flags); - if (rc) { - VCD_MSG_ERROR("Invalid Session: is_decoder: %d, secure: %d\n", - decoding, flags); - return rc; - } - if (is_secure) - res_trk_secure_set(); - mutex_lock(&drv_ctxt->dev_mutex); - - if (drv_ctxt->dev_state.state_table->ev_hdlr.open) { - rc = drv_ctxt->dev_state.state_table->ev_hdlr. - open(drv_ctxt, driver_handle, decoding, callback, - client_data); - if (rc) { - rc = -ENODEV; - } - } else { - VCD_MSG_ERROR("Unsupported API in device state %d", - drv_ctxt->dev_state.state); - rc = -EPERM; - } - if (!rc) { - cctxt = drv_ctxt->dev_ctxt.cctxt_list_head; - cctxt->secure = is_secure; - } else if (is_secure) - res_trk_secure_unset(); - - mutex_unlock(&drv_ctxt->dev_mutex); - return rc; -} -EXPORT_SYMBOL(vcd_open); - -u32 vcd_close(void *handle) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - int is_secure = 0; - VCD_MSG_MED("vcd_close:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - is_secure = cctxt->secure; - drv_ctxt = vcd_get_drv_context(); - mutex_lock(&drv_ctxt->dev_mutex); - if (drv_ctxt->dev_state.state_table->ev_hdlr.close) { - rc = drv_ctxt->dev_state.state_table->ev_hdlr. - close(drv_ctxt, cctxt); - } else { - VCD_MSG_ERROR("Unsupported API in device state %d", - drv_ctxt->dev_state.state); - - rc = VCD_ERR_BAD_STATE; - } - mutex_unlock(&drv_ctxt->dev_mutex); - if (is_secure) - res_trk_secure_unset(); - return rc; - -} -EXPORT_SYMBOL(vcd_close); - -u32 vcd_encode_start(void *handle) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_encode_start:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.encode_start && - drv_ctxt->dev_ctxt.pwr_state != VCD_PWR_STATE_SLEEP) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - encode_start(cctxt); - } else { - VCD_MSG_ERROR - ("Unsupported API in dev power state %d OR client state %d", - drv_ctxt->dev_ctxt.pwr_state, - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_encode_start); - -u32 vcd_encode_frame(void *handle, struct vcd_frame_data *input_frame) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_encode_frame:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!input_frame) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.encode_frame) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - encode_frame(cctxt, input_frame); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_encode_frame); - -u32 vcd_decode_start(void *handle, struct vcd_sequence_hdr *seq_hdr) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_decode_start:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.decode_start && - drv_ctxt->dev_ctxt.pwr_state != VCD_PWR_STATE_SLEEP) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - decode_start(cctxt, seq_hdr); - } else { - VCD_MSG_ERROR - ("Unsupported API in dev power state %d OR client state %d", - drv_ctxt->dev_ctxt.pwr_state, - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_decode_start); - -u32 vcd_decode_frame(void *handle, struct vcd_frame_data *input_frame) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_decode_frame:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!input_frame) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.decode_frame) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - decode_frame(cctxt, input_frame); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_decode_frame); - -u32 vcd_pause(void *handle) -{ - struct vcd_drv_ctxt *drv_ctxt; - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - u32 rc; - - VCD_MSG_MED("vcd_pause:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.pause) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - pause(cctxt); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_pause); - -u32 vcd_resume(void *handle) -{ - struct vcd_drv_ctxt *drv_ctxt; - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - u32 rc; - - VCD_MSG_MED("vcd_resume:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (drv_ctxt->dev_state.state_table->ev_hdlr.resume && - drv_ctxt->dev_ctxt.pwr_state != VCD_PWR_STATE_SLEEP) { - rc = drv_ctxt->dev_state.state_table->ev_hdlr. - resume(drv_ctxt, cctxt); - } else { - VCD_MSG_ERROR - ("Unsupported API in dev power state %d OR client state %d", - drv_ctxt->dev_ctxt.pwr_state, - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_resume); - -u32 vcd_flush(void *handle, u32 mode) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_flush:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.flush) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - flush(cctxt, mode); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_flush); - -u32 vcd_stop(void *handle) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_stop:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.stop && - drv_ctxt->dev_ctxt.pwr_state != VCD_PWR_STATE_SLEEP) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - stop(cctxt); - } else { - VCD_MSG_ERROR - ("Unsupported API in dev power state %d OR client state %d", - drv_ctxt->dev_ctxt.pwr_state, - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_stop); - -u32 vcd_set_property(void *handle, - struct vcd_property_hdr *prop_hdr, void *prop_val) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_set_property:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!prop_hdr || !prop_val) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.set_property) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - set_property(cctxt, prop_hdr, prop_val); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_set_property); - -u32 vcd_get_property(void *handle, - struct vcd_property_hdr *prop_hdr, void *prop_val) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_get_property:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!prop_hdr || !prop_val) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.get_property) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - get_property(cctxt, prop_hdr, prop_val); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_get_property); - -u32 vcd_set_buffer_requirements(void *handle, - enum vcd_buffer_type buffer, - struct vcd_buffer_requirement *buffer_req) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_set_buffer_requirements:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!buffer_req) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr. - set_buffer_requirements) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - set_buffer_requirements(cctxt, buffer, buffer_req); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_set_buffer_requirements); - -u32 vcd_get_buffer_requirements(void *handle, - enum vcd_buffer_type buffer, - struct vcd_buffer_requirement *buffer_req) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_get_buffer_requirements:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!buffer_req) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr. - get_buffer_requirements) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - get_buffer_requirements(cctxt, buffer, buffer_req); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_get_buffer_requirements); - -u32 vcd_set_buffer(void *handle, - enum vcd_buffer_type buffer_type, u8 *buffer, u32 buf_size) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_set_buffer:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!buffer || !buf_size) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.set_buffer) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - set_buffer(cctxt, buffer_type, buffer, buf_size); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_set_buffer); - -u32 vcd_allocate_buffer(void *handle, - enum vcd_buffer_type buffer, - u32 buf_size, u8 **vir_buf_addr, u8 **phy_buf_addr) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_allocate_buffer:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!vir_buf_addr || !phy_buf_addr - || !buf_size) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.allocate_buffer) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - allocate_buffer(cctxt, buffer, buf_size, - vir_buf_addr, phy_buf_addr); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_allocate_buffer); - -u32 vcd_free_buffer(void *handle, enum vcd_buffer_type buffer_type, u8 *buffer) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_free_buffer:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.free_buffer) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - free_buffer(cctxt, buffer_type, buffer); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_free_buffer); - -u32 vcd_fill_output_buffer(void *handle, struct vcd_frame_data *buffer) -{ - struct vcd_clnt_ctxt *cctxt = - (struct vcd_clnt_ctxt *)handle; - struct vcd_drv_ctxt *drv_ctxt; - u32 rc; - - VCD_MSG_MED("vcd_fill_output_buffer:"); - - if (!cctxt || cctxt->signature != VCD_SIGNATURE) { - VCD_MSG_ERROR("Bad client handle"); - - return VCD_ERR_BAD_HANDLE; - } - - if (!buffer) { - VCD_MSG_ERROR("Bad parameters"); - - return VCD_ERR_BAD_POINTER; - } - - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (cctxt->clnt_state.state_table->ev_hdlr.fill_output_buffer) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - fill_output_buffer(cctxt, buffer); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_fill_output_buffer); - -u32 vcd_set_device_power(s32 driver_handle, - enum vcd_power_state pwr_state) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_drv_ctxt *drv_ctxt; - - VCD_MSG_MED("vcd_set_device_power:"); - - drv_ctxt = vcd_get_drv_context(); - mutex_lock(&drv_ctxt->dev_mutex); - - if (drv_ctxt->dev_state.state_table->ev_hdlr.set_dev_pwr) { - rc = drv_ctxt->dev_state.state_table->ev_hdlr. - set_dev_pwr(drv_ctxt, pwr_state); - } else { - VCD_MSG_ERROR("Unsupported API in device state %d", - drv_ctxt->dev_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - mutex_unlock(&drv_ctxt->dev_mutex); - - return rc; - -} -EXPORT_SYMBOL(vcd_set_device_power); - -void vcd_read_and_clear_interrupt(void) -{ - VCD_MSG_LOW("vcd_read_and_clear_interrupt:"); - ddl_read_and_clear_interrupt(); -} - - -void vcd_response_handler(void) -{ - struct vcd_drv_ctxt *drv_ctxt; - - VCD_MSG_LOW("vcd_response_handler:"); - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - - if (!ddl_process_core_response()) { - VCD_MSG_HIGH - ("ddl_process_core_response indicated no further" - "processing"); - mutex_unlock(&drv_ctxt->dev_mutex); - return; - } - - if (drv_ctxt->dev_ctxt.command_continue) - vcd_continue(); - mutex_unlock(&drv_ctxt->dev_mutex); -} -EXPORT_SYMBOL(vcd_response_handler); - -u8 vcd_get_num_of_clients(void) -{ - struct vcd_drv_ctxt *drv_ctxt; - struct vcd_clnt_ctxt *cctxt; - u8 count = 0; - - VCD_MSG_LOW("vcd_get_num_of_clients:"); - drv_ctxt = vcd_get_drv_context(); - - mutex_lock(&drv_ctxt->dev_mutex); - cctxt = drv_ctxt->dev_ctxt.cctxt_list_head; - while (cctxt) { - count++; - cctxt = cctxt->next; - } - mutex_unlock(&drv_ctxt->dev_mutex); - return count; -} -EXPORT_SYMBOL(vcd_get_num_of_clients); - -u32 vcd_get_ion_status(void) -{ - return res_trk_get_enable_ion(); -} -EXPORT_SYMBOL(vcd_get_ion_status); - -struct ion_client *vcd_get_ion_client(void) -{ - return res_trk_get_ion_client(); -} -EXPORT_SYMBOL(vcd_get_ion_client); - - - - diff --git a/drivers/video/msm/vidc/common/vcd/vcd_client_sm.c b/drivers/video/msm/vidc/common/vcd/vcd_client_sm.c deleted file mode 100644 index 14c803071eee5dc480674b11518300bc39d399c4..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_client_sm.c +++ /dev/null @@ -1,1897 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include "vcd.h" - -static const struct vcd_clnt_state_table *vcd_clnt_state_table[]; - -void vcd_clnt_handle_device_err_fatal(struct vcd_clnt_ctxt *cctxt, - u32 event) -{ - if (cctxt->clnt_state.state == VCD_CLIENT_STATE_NULL) { - cctxt->callback(VCD_EVT_RESP_OPEN, VCD_ERR_HW_FATAL, NULL, 0, - cctxt, cctxt->client_data); - vcd_destroy_client_context(cctxt); - return; - } - if (event == VCD_EVT_RESP_BASE) - event = VCD_EVT_IND_HWERRFATAL; - if (cctxt->clnt_state.state != VCD_CLIENT_STATE_INVALID) { - cctxt->callback(event, VCD_ERR_HW_FATAL, NULL, 0, - cctxt, cctxt->client_data); - vcd_flush_buffers_in_err_fatal(cctxt); - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_INVALID, - CLIENT_STATE_EVENT_NUMBER(clnt_cb)); - } -} - -static u32 vcd_close_in_open(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_close_in_open:"); - if (cctxt->in_buf_pool.allocated || - cctxt->out_buf_pool.allocated) { - VCD_MSG_ERROR("\n Allocated buffers are not freed yet"); - return VCD_ERR_ILLEGAL_OP; - } - vcd_destroy_client_context(cctxt); - return rc; -} - -static u32 vcd_close_in_invalid(struct vcd_clnt_ctxt *cctxt) -{ - VCD_MSG_LOW("vcd_close_in_invalid:"); - if (cctxt->in_buf_pool.allocated || - cctxt->out_buf_pool.allocated){ - VCD_MSG_ERROR("Allocated buffers are not freed yet"); - return VCD_ERR_ILLEGAL_OP; - } - - if (cctxt->status.mask & VCD_CLEANING_UP) - cctxt->status.mask |= VCD_CLOSE_PENDING; - else - vcd_destroy_client_context(cctxt); - return VCD_S_SUCCESS; -} - -static u32 vcd_start_in_run_cmn(struct vcd_clnt_ctxt *cctxt) -{ - VCD_MSG_LOW("vcd_start_in_run_cmn:"); - cctxt->callback(VCD_EVT_RESP_START, VCD_S_SUCCESS, NULL, 0, - cctxt, cctxt->client_data); - return VCD_S_SUCCESS; - -} - -static u32 vcd_encode_start_in_open(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_property_hdr prop_hdr; - struct vcd_property_vop_timing timing; - - VCD_MSG_LOW("vcd_encode_start_in_open:"); - - if (cctxt->decoding) { - VCD_MSG_ERROR("vcd_encode_init for decoder client"); - - return VCD_ERR_ILLEGAL_OP; - } - - if ((!cctxt->meta_mode && !cctxt->in_buf_pool.entries) || - !cctxt->out_buf_pool.entries || - (!cctxt->meta_mode && - cctxt->in_buf_pool.validated != cctxt->in_buf_pool.count) || - cctxt->out_buf_pool.validated != - cctxt->out_buf_pool.count) { - VCD_MSG_HIGH("%s: Buffer pool is not completely setup yet", - __func__); - } - - rc = vcd_sched_add_client(cctxt); - VCD_FAILED_RETURN(rc, "Failed: vcd_sched_add_client"); - - prop_hdr.prop_id = VCD_I_VOP_TIMING; - prop_hdr.sz = sizeof(struct vcd_property_vop_timing); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &timing); - - VCD_FAILED_RETURN(rc, "Failed: Get VCD_I_VOP_TIMING"); - if (!timing.vop_time_resolution) { - VCD_MSG_ERROR("Vop_time_resolution value is zero"); - return VCD_ERR_FAIL; - } - cctxt->time_resoln = timing.vop_time_resolution; - - rc = vcd_process_cmd_sess_start(cctxt); - - if (!VCD_FAILED(rc)) { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_STARTING, - CLIENT_STATE_EVENT_NUMBER - (encode_start)); - } - - return rc; -} - -static u32 vcd_encode_start_in_run(struct vcd_clnt_ctxt - *cctxt) -{ - VCD_MSG_LOW("vcd_encode_start_in_run:"); - (void) vcd_start_in_run_cmn(cctxt); - return VCD_S_SUCCESS; -} - - -static u32 vcd_encode_frame_cmn(struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame) -{ - VCD_MSG_LOW("vcd_encode_frame_cmn in %d:", cctxt->clnt_state.state); - - if (cctxt->decoding) { - VCD_MSG_ERROR("vcd_encode_frame for decoder client"); - - return VCD_ERR_ILLEGAL_OP; - } - - return vcd_handle_input_frame(cctxt, input_frame); -} - -static u32 vcd_decode_start_in_open - (struct vcd_clnt_ctxt *cctxt, - struct vcd_sequence_hdr *seq_hdr) -{ - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_decode_start_in_open:"); - - if (!cctxt->decoding) { - VCD_MSG_ERROR("vcd_decode_init for encoder client"); - - return VCD_ERR_ILLEGAL_OP; - } - - if (seq_hdr) { - VCD_MSG_HIGH("Seq hdr supplied. len = %d", - seq_hdr->sequence_header_len); - - rc = vcd_store_seq_hdr(cctxt, seq_hdr); - - } else { - VCD_MSG_HIGH("Seq hdr not supplied"); - - cctxt->seq_hdr.sequence_header_len = 0; - cctxt->seq_hdr.sequence_header = NULL; - } - - VCD_FAILED_RETURN(rc, "Err processing seq hdr"); - - rc = vcd_process_cmd_sess_start(cctxt); - - if (!VCD_FAILED(rc)) { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_STARTING, - CLIENT_STATE_EVENT_NUMBER - (decode_start)); - } - - return rc; -} - -static u32 vcd_decode_start_in_run(struct vcd_clnt_ctxt *cctxt, - struct vcd_sequence_hdr *seqhdr) -{ - VCD_MSG_LOW("vcd_decode_start_in_run:"); - (void) vcd_start_in_run_cmn(cctxt); - return VCD_S_SUCCESS; -} - -static u32 vcd_decode_frame_cmn - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame) -{ - VCD_MSG_LOW("vcd_decode_frame_cmn in %d:", cctxt->clnt_state.state); - - if (!cctxt->decoding) { - VCD_MSG_ERROR("Decode_frame api called for Encoder client"); - - return VCD_ERR_ILLEGAL_OP; - } - - return vcd_handle_input_frame(cctxt, input_frame); -} - -static u32 vcd_pause_cmn(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_pause_cmn:"); - - if (cctxt->sched_clnt_hdl) { - rc = vcd_sched_suspend_resume_clnt(cctxt, false); - VCD_FAILED_RETURN(rc, "Failed: vcd_sched_suspend_resume_clnt"); - } - - if (cctxt->status.frame_submitted > 0) { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_PAUSING, - CLIENT_STATE_EVENT_NUMBER - (pause)); - - } else { - VCD_MSG_HIGH("No client frames are currently being processed"); - - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_PAUSED, - CLIENT_STATE_EVENT_NUMBER - (pause)); - - cctxt->callback(VCD_EVT_RESP_PAUSE, - VCD_S_SUCCESS, - NULL, 0, cctxt, cctxt->client_data); - - rc = vcd_power_event(cctxt->dev_ctxt, cctxt, - VCD_EVT_PWR_CLNT_PAUSE); - - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("VCD_EVT_PWR_CLNT_PAUSE_END failed"); - - } - - return VCD_S_SUCCESS; -} - -static u32 vcd_resume_in_paused(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_resume_in_paused:"); - - - if (cctxt->sched_clnt_hdl) { - rc = vcd_power_event(cctxt->dev_ctxt, - cctxt, VCD_EVT_PWR_CLNT_RESUME); - - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR("VCD_EVT_PWR_CLNT_RESUME failed"); - } else { - rc = vcd_sched_suspend_resume_clnt(cctxt, true); - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR - ("rc = 0x%x. Failed: " - "vcd_sched_suspend_resume_clnt", - rc); - } - - } - if (!VCD_FAILED(rc)) { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER - (resume)); - vcd_try_submit_frame(dev_ctxt); - } - } else { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER - (resume)); - } - - return rc; -} - -static u32 vcd_flush_cmn(struct vcd_clnt_ctxt *cctxt, u32 mode) -{ - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_flush_cmn in %d:", cctxt->clnt_state.state); - - rc = vcd_flush_buffers(cctxt, mode); - - VCD_FAILED_RETURN(rc, "Failed: vcd_flush_buffers"); - - if (cctxt->status.frame_submitted > 0) { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_FLUSHING, - CLIENT_STATE_EVENT_NUMBER - (flush)); - } else { - VCD_MSG_HIGH("All buffers are flushed"); - cctxt->status.mask |= (mode & VCD_FLUSH_ALL); - vcd_send_flush_done(cctxt, VCD_S_SUCCESS); - } - - return rc; -} - -static u32 vcd_flush_inopen(struct vcd_clnt_ctxt *cctxt, - u32 mode) -{ - VCD_MSG_LOW("vcd_flush_inopen:"); - cctxt->status.mask |= (mode & VCD_FLUSH_ALL); - vcd_send_flush_done(cctxt, VCD_S_SUCCESS); - return VCD_S_SUCCESS; -} - -static u32 vcd_flush_in_flushing - (struct vcd_clnt_ctxt *cctxt, u32 mode) -{ - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_flush_in_flushing:"); - - rc = vcd_flush_buffers(cctxt, mode); - - return rc; -} - -static u32 vcd_flush_in_eos(struct vcd_clnt_ctxt *cctxt, - u32 mode) -{ - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("vcd_flush_in_eos:"); - - if (mode > VCD_FLUSH_ALL || !mode) { - VCD_MSG_ERROR("Invalid flush mode %d", mode); - - return VCD_ERR_ILLEGAL_PARM; - } - - VCD_MSG_MED("Flush mode requested %d", mode); - if (!(cctxt->status.frame_submitted) && - (!cctxt->decoding)) { - rc = vcd_flush_buffers(cctxt, mode); - if (!VCD_FAILED(rc)) { - VCD_MSG_HIGH("All buffers are flushed"); - cctxt->status.mask |= (mode & VCD_FLUSH_ALL); - vcd_send_flush_done(cctxt, VCD_S_SUCCESS); - } - } else - cctxt->status.mask |= (mode & VCD_FLUSH_ALL); - - return rc; -} - -static u32 vcd_flush_in_invalid(struct vcd_clnt_ctxt *cctxt, - u32 mode) -{ - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("vcd_flush_in_invalid:"); - if (!(cctxt->status.mask & VCD_CLEANING_UP)) { - rc = vcd_flush_buffers(cctxt, mode); - if (!VCD_FAILED(rc)) { - VCD_MSG_HIGH("All buffers are flushed"); - cctxt->status.mask |= (mode & VCD_FLUSH_ALL); - vcd_send_flush_done(cctxt, VCD_S_SUCCESS); - } - } else - cctxt->status.mask |= (mode & VCD_FLUSH_ALL); - return rc; -} - -static u32 vcd_stop_cmn(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - struct vcd_transc *transc; - - VCD_MSG_LOW("vcd_stop_cmn in %d:", cctxt->clnt_state.state); - - rc = vcd_flush_buffers(cctxt, VCD_FLUSH_ALL); - - VCD_FAILED_RETURN(rc, "Failed: vcd_flush_buffers"); - - if (!cctxt->status.frame_submitted) { - - if (vcd_get_command_channel(dev_ctxt, &transc)) { - rc = vcd_power_event(dev_ctxt, cctxt, - VCD_EVT_PWR_CLNT_CMD_BEGIN); - - if (!VCD_FAILED(rc)) { - transc->type = VCD_CMD_CODEC_STOP; - transc->cctxt = cctxt; - - rc = vcd_submit_cmd_sess_end(transc); - } else { - VCD_MSG_ERROR("Failed:" - " VCD_EVT_PWR_CLNT_CMD_BEGIN"); - } - - if (VCD_FAILED(rc)) { - vcd_release_command_channel(dev_ctxt, - transc); - } - - } else { - vcd_client_cmd_flush_and_en_q(cctxt, - VCD_CMD_CODEC_STOP); - } - } - - if (VCD_FAILED(rc)) { - (void)vcd_power_event(dev_ctxt, cctxt, - VCD_EVT_PWR_CLNT_CMD_FAIL); - } else { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_STOPPING, - CLIENT_STATE_EVENT_NUMBER - (stop)); - } - - return rc; -} - - -static u32 vcd_stop_inopen(struct vcd_clnt_ctxt *cctxt) -{ - VCD_MSG_LOW("vcd_stop_inopen:"); - - cctxt->callback(VCD_EVT_RESP_STOP, VCD_S_SUCCESS, - NULL, 0, cctxt, - cctxt->client_data); - - return VCD_S_SUCCESS; -} - -static u32 vcd_stop_in_run(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("vcd_stop_in_run:"); - rc = vcd_stop_cmn(cctxt); - if (!VCD_FAILED(rc) && - (cctxt->status.mask & VCD_FIRST_IP_RCVD)) { - rc = vcd_power_event(cctxt->dev_ctxt, - cctxt, VCD_EVT_PWR_CLNT_LAST_FRAME); - } - return rc; -} - -static u32 vcd_stop_in_eos(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("vcd_stop_in_eos:"); - if (cctxt->status.mask & VCD_EOS_WAIT_OP_BUF) { - rc = vcd_stop_cmn(cctxt); - if (!VCD_FAILED(rc)) { - rc = vcd_power_event(cctxt->dev_ctxt, - cctxt, VCD_EVT_PWR_CLNT_LAST_FRAME); - cctxt->status.mask &= ~VCD_EOS_WAIT_OP_BUF; - } - } else - cctxt->status.mask |= VCD_STOP_PENDING; - return rc; -} - -static u32 vcd_stop_in_invalid(struct vcd_clnt_ctxt *cctxt) -{ - VCD_MSG_LOW("vcd_stop_in_invalid:"); - if (cctxt->status.mask & VCD_CLEANING_UP) { - cctxt->status.mask |= VCD_STOP_PENDING; - } else { - (void) vcd_flush_buffers(cctxt, VCD_FLUSH_ALL); - cctxt->callback(VCD_EVT_RESP_STOP, VCD_S_SUCCESS, NULL, - 0, cctxt, cctxt->client_data); - } - return VCD_S_SUCCESS; -} - -static u32 vcd_set_property_cmn - (struct vcd_clnt_ctxt *cctxt, - struct vcd_property_hdr *prop_hdr, void *prop_val) -{ - u32 rc; - VCD_MSG_LOW("vcd_set_property_cmn in %d:", cctxt->clnt_state.state); - VCD_MSG_LOW("property Id = %d", prop_hdr->prop_id); - if (!prop_hdr->sz || !prop_hdr->prop_id) { - VCD_MSG_MED("Bad parameters"); - return VCD_ERR_ILLEGAL_PARM; - } - - rc = ddl_set_property(cctxt->ddl_handle, prop_hdr, prop_val); - if (rc) { - /* Some properties aren't known to ddl that we can handle */ - if (prop_hdr->prop_id != VCD_I_VOP_TIMING_CONSTANT_DELTA) - VCD_FAILED_RETURN(rc, "Failed: ddl_set_property"); - } - - switch (prop_hdr->prop_id) { - case VCD_I_META_BUFFER_MODE: - { - struct vcd_property_live *live = - (struct vcd_property_live *)prop_val; - cctxt->meta_mode = live->live; - break; - } - case VCD_I_LIVE: - { - struct vcd_property_live *live = - (struct vcd_property_live *)prop_val; - cctxt->live = live->live; - break; - } - case VCD_I_FRAME_RATE: - { - if (cctxt->sched_clnt_hdl) { - rc = vcd_set_frame_rate(cctxt, - (struct vcd_property_frame_rate *) - prop_val); - } - break; - } - case VCD_I_FRAME_SIZE: - { - if (cctxt->sched_clnt_hdl) { - rc = vcd_set_frame_size(cctxt, - (struct vcd_property_frame_size *) - prop_val); - } - break; - } - case VCD_I_SET_TURBO_CLK: - { - if (cctxt->sched_clnt_hdl) - rc = vcd_set_perf_turbo_level(cctxt); - break; - } - case VCD_I_INTRA_PERIOD: - { - struct vcd_property_i_period *iperiod = - (struct vcd_property_i_period *)prop_val; - cctxt->bframe = iperiod->b_frames; - break; - } - case VCD_REQ_PERF_LEVEL: - rc = vcd_req_perf_level(cctxt, - (struct vcd_property_perf_level *)prop_val); - break; - case VCD_I_VOP_TIMING_CONSTANT_DELTA: - { - struct vcd_property_vop_timing_constant_delta *delta = - prop_val; - - if (delta->constant_delta > 0) { - cctxt->time_frame_delta = delta->constant_delta; - rc = VCD_S_SUCCESS; - } else { - VCD_MSG_ERROR("Frame delta must be positive"); - rc = VCD_ERR_ILLEGAL_PARM; - } - break; - } - default: - { - break; - } - } - return rc; -} - -static u32 vcd_get_property_cmn - (struct vcd_clnt_ctxt *cctxt, - struct vcd_property_hdr *prop_hdr, void *prop_val) -{ - int rc; - VCD_MSG_LOW("vcd_get_property_cmn in %d:", cctxt->clnt_state.state); - VCD_MSG_LOW("property Id = %d", prop_hdr->prop_id); - if (!prop_hdr->sz || !prop_hdr->prop_id) { - VCD_MSG_MED("Bad parameters"); - - return VCD_ERR_ILLEGAL_PARM; - } - rc = ddl_get_property(cctxt->ddl_handle, prop_hdr, prop_val); - if (rc) { - /* Some properties aren't known to ddl that we can handle */ - if (prop_hdr->prop_id != VCD_I_VOP_TIMING_CONSTANT_DELTA) - VCD_FAILED_RETURN(rc, "Failed: ddl_set_property"); - } - - switch (prop_hdr->prop_id) { - case VCD_I_VOP_TIMING_CONSTANT_DELTA: - { - struct vcd_property_vop_timing_constant_delta *delta = - (struct vcd_property_vop_timing_constant_delta *) - prop_val; - delta->constant_delta = cctxt->time_frame_delta; - rc = VCD_S_SUCCESS; - } - } - return rc; -} - -static u32 vcd_set_buffer_requirements_cmn - (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer, - struct vcd_buffer_requirement *buffer_req) -{ - struct vcd_property_hdr Prop_hdr; - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_pool *buf_pool; - u32 first_frm_recvd = 0; - - VCD_MSG_LOW("vcd_set_buffer_requirements_cmn in %d:", - cctxt->clnt_state.state); - - if (!cctxt->decoding && - cctxt->clnt_state.state != VCD_CLIENT_STATE_OPEN) { - VCD_MSG_ERROR("Bad state (%d) for encoder", - cctxt->clnt_state.state); - - return VCD_ERR_BAD_STATE; - } - - VCD_MSG_MED("Buffer type = %d", buffer); - - if (buffer == VCD_BUFFER_INPUT) { - Prop_hdr.prop_id = DDL_I_INPUT_BUF_REQ; - buf_pool = &cctxt->in_buf_pool; - first_frm_recvd = VCD_FIRST_IP_RCVD; - } else if (buffer == VCD_BUFFER_OUTPUT) { - Prop_hdr.prop_id = DDL_I_OUTPUT_BUF_REQ; - buf_pool = &cctxt->out_buf_pool; - first_frm_recvd = VCD_FIRST_OP_RCVD; - } else { - rc = VCD_ERR_ILLEGAL_PARM; - } - - VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); - - if (buf_pool->validated > 0) { - VCD_MSG_ERROR("Need to free allocated buffers"); - return VCD_ERR_ILLEGAL_OP; - } - - first_frm_recvd &= cctxt->status.mask; - if (first_frm_recvd) { - VCD_MSG_ERROR("VCD SetBufReq called when data path is active"); - return VCD_ERR_BAD_STATE; - } - Prop_hdr.sz = sizeof(*buffer_req); - rc = ddl_set_property(cctxt->ddl_handle, &Prop_hdr, buffer_req); - VCD_FAILED_RETURN(rc, "Failed: ddl_set_property"); - if (buf_pool->entries) { - VCD_MSG_MED("Resetting buffer requirements"); - vcd_free_buffer_pool_entries(buf_pool); - } - return rc; -} - -static u32 vcd_get_buffer_requirements_cmn - (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer, - struct vcd_buffer_requirement *buffer_req) -{ - struct vcd_property_hdr Prop_hdr; - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_get_buffer_requirements_cmn in %d:", - cctxt->clnt_state.state); - - VCD_MSG_MED("Buffer type = %d", buffer); - - if (buffer == VCD_BUFFER_INPUT) - Prop_hdr.prop_id = DDL_I_INPUT_BUF_REQ; - else if (buffer == VCD_BUFFER_OUTPUT) - Prop_hdr.prop_id = DDL_I_OUTPUT_BUF_REQ; - else - rc = VCD_ERR_ILLEGAL_PARM; - - VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); - - Prop_hdr.sz = sizeof(*buffer_req); - - return ddl_get_property(cctxt->ddl_handle, &Prop_hdr, buffer_req); - -} - -static u32 vcd_set_buffer_cmn - (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer_type, u8 *buffer, u32 buf_size) -{ - u32 rc; - struct vcd_buffer_pool *buf_pool; - - VCD_MSG_LOW("vcd_set_buffer_cmn in %d:", cctxt->clnt_state.state); - - rc = vcd_common_allocate_set_buffer(cctxt, buffer_type, buf_size, - &buf_pool); - - if (!VCD_FAILED(rc)) { - rc = vcd_set_buffer_internal(cctxt, buf_pool, buffer, - buf_size); - } - - return rc; -} - -static u32 vcd_allocate_buffer_cmn - (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer, - u32 buf_size, u8 **vir_buf_addr, u8 **phy_buf_addr) -{ - u32 rc; - struct vcd_buffer_pool *buf_pool; - - VCD_MSG_LOW("vcd_allocate_buffer_cmn in %d:", - cctxt->clnt_state.state); - - rc = vcd_common_allocate_set_buffer(cctxt, buffer, buf_size, - &buf_pool); - - if (!VCD_FAILED(rc)) { - rc = vcd_allocate_buffer_internal(cctxt, - buf_pool, - buf_size, - vir_buf_addr, - phy_buf_addr); - } - - return rc; -} - -static u32 vcd_free_buffer_cmn - (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer_type, u8 *buffer) -{ - - VCD_MSG_LOW("vcd_free_buffer_cmn in %d:", cctxt->clnt_state.state); - - return vcd_free_one_buffer_internal(cctxt, buffer_type, buffer); -} - -static u32 vcd_fill_output_buffer_cmn - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *buffer) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_entry *buf_entry; - u32 result = true; - u32 handled = true; - if (!cctxt || !buffer) { - VCD_MSG_ERROR("%s(): Inavlid params cctxt %p buffer %p", - __func__, cctxt, buffer); - return VCD_ERR_BAD_POINTER; - } - VCD_MSG_LOW("vcd_fill_output_buffer_cmn in %d:", - cctxt->clnt_state.state); - if (cctxt->status.mask & VCD_IN_RECONFIG) { - buffer->time_stamp = 0; - buffer->data_len = 0; - VCD_MSG_LOW("In reconfig: Return output buffer"); - cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, - buffer, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - return rc; - } - buf_entry = vcd_check_fill_output_buffer(cctxt, buffer); - if (!buf_entry) - return VCD_ERR_BAD_POINTER; - - if (!(cctxt->status.mask & VCD_FIRST_OP_RCVD)) { - rc = vcd_handle_first_fill_output_buffer(cctxt, buffer, - &handled); - VCD_FAILED_RETURN(rc, - "Failed: vcd_handle_first_fill_output_buffer"); - if (handled) - return rc ; - } - - result = - vcd_buffer_pool_entry_en_q(&cctxt->out_buf_pool, buf_entry); - - if (!result && !cctxt->decoding) { - VCD_MSG_ERROR("Failed: vcd_buffer_pool_entry_en_q"); - - return VCD_ERR_FAIL; - } - - buf_entry->frame = *buffer; - rc = vcd_return_op_buffer_to_hw(cctxt, buf_entry); - if (!VCD_FAILED(rc) && cctxt->sched_clnt_hdl) { - cctxt->sched_clnt_hdl->tkns++; - vcd_try_submit_frame(cctxt->dev_ctxt); - } - return rc; -} - -static u32 vcd_fill_output_buffer_in_eos - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *buffer) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_entry *buf_entry; - - VCD_MSG_LOW("vcd_fill_output_buffer_in_eos:"); - - buf_entry = vcd_check_fill_output_buffer(cctxt, buffer); - if (!buf_entry) - return VCD_ERR_BAD_POINTER; - - if (cctxt->status.mask & VCD_EOS_WAIT_OP_BUF) { - VCD_MSG_HIGH("Got an output buffer we were waiting for"); - - buf_entry->frame = *buffer; - - buf_entry->frame.data_len = 0; - buf_entry->frame.flags |= VCD_FRAME_FLAG_EOS; - buf_entry->frame.ip_frm_tag = - cctxt->status.eos_trig_ip_frm.ip_frm_tag; - buf_entry->frame.time_stamp = - cctxt->status.eos_trig_ip_frm.time_stamp; - - cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, - &buf_entry->frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - - cctxt->status.mask &= ~VCD_EOS_WAIT_OP_BUF; - - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER - (fill_output_buffer)); - - } else { - rc = vcd_fill_output_buffer_cmn(cctxt, buffer); - } - - return rc; -} - -static void vcd_clnt_cb_in_starting - (struct vcd_clnt_ctxt *cctxt, - u32 event, u32 status, void *payload, size_t sz, - u32 *ddl_handle, void *const client_data) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - struct vcd_transc *transc = - (struct vcd_transc *)client_data; - VCD_MSG_LOW("vcd_clnt_cb_in_starting:"); - if (cctxt->ddl_handle != ddl_handle) { - VCD_MSG_ERROR("vcd_clnt_cb_in_initing: Wrong DDL handle %p", - ddl_handle); - return; - } - - switch (event) { - case VCD_EVT_RESP_START: - { - vcd_handle_start_done(cctxt, - (struct vcd_transc *)client_data, - status); - break; - } - case VCD_EVT_RESP_STOP: - { - vcd_handle_stop_done_in_starting(cctxt, - (struct vcd_transc *)client_data, - status); - break; - } - case VCD_EVT_IND_HWERRFATAL: - { - cctxt->status.cmd_submitted--; - vcd_mark_command_channel(cctxt->dev_ctxt, transc); - vcd_handle_err_fatal(cctxt, VCD_EVT_RESP_START, - status); - break; - } - default: - { - VCD_MSG_ERROR("Unexpected callback event=%d status=%d " - "from DDL", event, status); - dev_ctxt->command_continue = false; - break; - } - } -} - -static void vcd_clnt_cb_in_run - (struct vcd_clnt_ctxt *cctxt, - u32 event, - u32 status, - void *payload, size_t sz, u32 *ddl_handle, void *const client_data) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - - if (cctxt->ddl_handle != ddl_handle) { - VCD_MSG_ERROR("ddl_handle mismatch"); - - return; - } - - switch (event) { - case VCD_EVT_RESP_INPUT_DONE: - { - rc = vcd_handle_input_done(cctxt, payload, event, - status); - - break; - } - - case VCD_EVT_RESP_OUTPUT_DONE: - { - - rc = vcd_handle_frame_done(cctxt, payload, event, - status); - - break; - } - case VCD_EVT_RESP_OUTPUT_REQ: - { - rc = vcd_handle_output_required(cctxt, payload, - status); - break; - } - - case VCD_EVT_IND_OUTPUT_RECONFIG: - { - rc = vcd_handle_ind_output_reconfig(cctxt, payload, - status); - break; - } - case VCD_EVT_RESP_TRANSACTION_PENDING: - { - vcd_handle_trans_pending(cctxt); - break; - } - - case VCD_EVT_IND_HWERRFATAL: - { - vcd_handle_ind_hw_err_fatal(cctxt, - VCD_EVT_IND_HWERRFATAL, status); - break; - } - case VCD_EVT_IND_INFO_OUTPUT_RECONFIG: - { - vcd_handle_ind_info_output_reconfig(cctxt, status); - break; - } - case VCD_EVT_IND_INFO_LTRUSE_FAILED: - { - rc = vcd_handle_ltr_use_failed(cctxt, - payload, sz, status); - break; - } - default: - { - VCD_MSG_ERROR - ("Unexpected callback event=%d status=%d from DDL", - event, status); - dev_ctxt->command_continue = false; - - break; - } - } - - if (!VCD_FAILED(rc) && - (event == VCD_EVT_RESP_INPUT_DONE || - event == VCD_EVT_RESP_OUTPUT_DONE || - event == VCD_EVT_RESP_OUTPUT_REQ)) { - - if (((struct ddl_frame_data_tag *) - payload)->frm_trans_end) - vcd_mark_frame_channel(cctxt->dev_ctxt); - } -} - -static void vcd_clnt_cb_in_eos - (struct vcd_clnt_ctxt *cctxt, - u32 event, - u32 status, - void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - struct vcd_transc *transc = NULL; - u32 frm_trans_end = false, rc = VCD_S_SUCCESS; - - if (cctxt->ddl_handle != ddl_handle) { - VCD_MSG_ERROR("ddl_handle mismatch"); - - return; - } - - switch (event) { - case VCD_EVT_RESP_INPUT_DONE: - { - rc = vcd_handle_input_done_in_eos(cctxt, payload, - status); - - break; - } - - case VCD_EVT_RESP_OUTPUT_DONE: - { - rc = vcd_handle_frame_done_in_eos(cctxt, payload, - status); - - break; - } - case VCD_EVT_RESP_OUTPUT_REQ: - { - rc = vcd_handle_output_required(cctxt, payload, - status); - break; - } - case VCD_EVT_RESP_EOS_DONE: - { - transc = (struct vcd_transc *)client_data; - vcd_handle_eos_done(cctxt, transc, status); - vcd_mark_frame_channel(cctxt->dev_ctxt); - break; - } - case VCD_EVT_IND_OUTPUT_RECONFIG: - { - rc = vcd_handle_ind_output_reconfig(cctxt, - payload, status); - if (!VCD_FAILED(rc)) { - frm_trans_end = true; - payload = NULL; - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER - (clnt_cb)); - VCD_MSG_LOW - ("RECONFIGinEOS:Suspending Client"); - rc = vcd_sched_suspend_resume_clnt(cctxt, - false); - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR - ("Failed: suspend_resume_clnt. rc=0x%x", - rc); - } - } - break; - } - case VCD_EVT_IND_HWERRFATAL: - { - vcd_handle_ind_hw_err_fatal(cctxt, - VCD_EVT_IND_HWERRFATAL, status); - break; - } - case VCD_EVT_IND_INFO_OUTPUT_RECONFIG: - { - vcd_handle_ind_info_output_reconfig(cctxt, status); - break; - } - default: - { - VCD_MSG_ERROR - ("Unexpected callback event=%d status=%d from DDL", - event, status); - - dev_ctxt->command_continue = false; - - break; - } - - } - if (!VCD_FAILED(rc) && - (event == VCD_EVT_RESP_INPUT_DONE || - event == VCD_EVT_RESP_OUTPUT_DONE || - event == VCD_EVT_RESP_OUTPUT_REQ || - event == VCD_EVT_IND_OUTPUT_RECONFIG)) { - if (payload && ((struct ddl_frame_data_tag *) - payload)->frm_trans_end) { - vcd_mark_frame_channel(cctxt->dev_ctxt); - frm_trans_end = true; - } - if (frm_trans_end && !cctxt->status.frame_submitted) - vcd_handle_eos_trans_end(cctxt); - } -} - -static void vcd_clnt_cb_in_flushing - (struct vcd_clnt_ctxt *cctxt, - u32 event, - u32 status, - void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - u32 frm_trans_end = false; - - VCD_MSG_LOW("vcd_clnt_cb_in_flushing:"); - - if (cctxt->ddl_handle != ddl_handle) { - VCD_MSG_ERROR("ddl_handle mismatch"); - - return; - } - - switch (event) { - case VCD_EVT_RESP_INPUT_DONE: - { - rc = vcd_handle_input_done(cctxt, - payload, - VCD_EVT_RESP_INPUT_FLUSHED, - status); - - break; - } - - case VCD_EVT_RESP_OUTPUT_DONE: - { - - rc = vcd_handle_frame_done(cctxt, - payload, - VCD_EVT_RESP_OUTPUT_FLUSHED, - status); - - break; - } - case VCD_EVT_RESP_OUTPUT_REQ: - { - rc = vcd_handle_output_required_in_flushing(cctxt, - payload); - break; - } - case VCD_EVT_IND_OUTPUT_RECONFIG: - { - rc = vcd_handle_ind_output_reconfig(cctxt, - payload, status); - if (!VCD_FAILED(rc)) { - frm_trans_end = true; - payload = NULL; - } - break; - } - case VCD_EVT_IND_HWERRFATAL: - { - vcd_handle_ind_hw_err_fatal(cctxt, - VCD_EVT_IND_HWERRFATAL, status); - break; - } - default: - { - VCD_MSG_ERROR - ("Unexpected callback event=%d status=%d from DDL", - event, status); - - dev_ctxt->command_continue = false; - - break; - } - } - if (!VCD_FAILED(rc) && ((event == VCD_EVT_RESP_INPUT_DONE || - event == VCD_EVT_RESP_OUTPUT_DONE || - event == VCD_EVT_RESP_OUTPUT_REQ || - event == VCD_EVT_IND_OUTPUT_RECONFIG))) { - if (payload && - ((struct ddl_frame_data_tag *)\ - payload)->frm_trans_end) { - - vcd_mark_frame_channel(cctxt->dev_ctxt); - frm_trans_end = true; - } - if (frm_trans_end && !cctxt->status.frame_submitted) { - VCD_MSG_HIGH - ("All pending frames recvd from DDL"); - if (cctxt->status.mask & VCD_FLUSH_INPUT) - vcd_flush_bframe_buffers(cctxt, - VCD_FLUSH_INPUT); - if (cctxt->status.mask & VCD_FLUSH_OUTPUT) - vcd_flush_output_buffers(cctxt); - vcd_send_flush_done(cctxt, VCD_S_SUCCESS); - vcd_release_interim_frame_channels(dev_ctxt); - VCD_MSG_HIGH("Flush complete"); - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER - (clnt_cb)); - } - } -} - -static void vcd_clnt_cb_in_stopping - (struct vcd_clnt_ctxt *cctxt, - u32 event, - u32 status, - void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - u32 frm_trans_end = false; - - VCD_MSG_LOW("vcd_clnt_cb_in_stopping:"); - - if (cctxt->ddl_handle != ddl_handle) { - VCD_MSG_ERROR("ddl_handle mismatch"); - - return; - } - - switch (event) { - - case VCD_EVT_RESP_INPUT_DONE: - { - rc = vcd_handle_input_done(cctxt, - payload, - VCD_EVT_RESP_INPUT_FLUSHED, - status); - - break; - } - - case VCD_EVT_RESP_OUTPUT_DONE: - { - - rc = vcd_handle_frame_done(cctxt, - payload, - VCD_EVT_RESP_OUTPUT_FLUSHED, - status); - - break; - } - case VCD_EVT_RESP_OUTPUT_REQ: - { - rc = vcd_handle_output_required_in_flushing(cctxt, - payload); - break; - } - case VCD_EVT_RESP_STOP: - { - vcd_handle_stop_done(cctxt, - (struct vcd_transc *) - client_data, status); - - break; - } - case VCD_EVT_IND_OUTPUT_RECONFIG: - { - (void) vcd_handle_ind_output_reconfig(cctxt, - payload, status); - - frm_trans_end = true; - payload = NULL; - - break; - } - case VCD_EVT_IND_HWERRFATAL: - { - vcd_handle_ind_hw_err_fatal(cctxt, VCD_EVT_RESP_STOP, - status); - break; - } - - default: - { - VCD_MSG_ERROR - ("Unexpected callback event=%d status=%d from DDL", - event, status); - - dev_ctxt->command_continue = false; - - break; - } - } - - if (!VCD_FAILED(rc) && ((event == VCD_EVT_RESP_INPUT_DONE || - event == VCD_EVT_RESP_OUTPUT_DONE) || - event == VCD_EVT_RESP_OUTPUT_REQ || - event == VCD_EVT_IND_OUTPUT_RECONFIG)) { - - if (payload && - ((struct ddl_frame_data_tag *)\ - payload)->frm_trans_end) { - - vcd_mark_frame_channel(cctxt->dev_ctxt); - frm_trans_end = true; - } - if (frm_trans_end && !cctxt->status.frame_submitted) { - VCD_MSG_HIGH - ("All pending frames recvd from DDL"); - vcd_flush_bframe_buffers(cctxt, - VCD_FLUSH_INPUT); - vcd_flush_output_buffers(cctxt); - cctxt->status.mask &= ~VCD_FLUSH_ALL; - vcd_release_all_clnt_frm_transc(cctxt); - VCD_MSG_HIGH - ("All buffers flushed. Enqueuing stop cmd"); - vcd_client_cmd_flush_and_en_q(cctxt, - VCD_CMD_CODEC_STOP); - } - } -} - -static void vcd_clnt_cb_in_pausing - (struct vcd_clnt_ctxt *cctxt, - u32 event, - u32 status, - void *payload, size_t sz, u32 *ddl_handle, void *const client_data) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - u32 frm_trans_end = false; - - VCD_MSG_LOW("vcd_clnt_cb_in_pausing:"); - - if (cctxt->ddl_handle != ddl_handle) { - VCD_MSG_ERROR("ddl_handle mismatch"); - - return; - } - - switch (event) { - case VCD_EVT_RESP_INPUT_DONE: - { - rc = vcd_handle_input_done(cctxt, payload, event, - status); - - break; - } - - case VCD_EVT_RESP_OUTPUT_DONE: - { - rc = vcd_handle_frame_done(cctxt, payload, event, - status); - break; - } - case VCD_EVT_RESP_OUTPUT_REQ: - { - rc = vcd_handle_output_required(cctxt, payload, - status); - break; - } - case VCD_EVT_IND_OUTPUT_RECONFIG: - { - rc = vcd_handle_ind_output_reconfig(cctxt, - payload, status); - if (!VCD_FAILED(rc)) { - frm_trans_end = true; - payload = NULL; - } - break; - } - case VCD_EVT_IND_HWERRFATAL: - { - vcd_handle_ind_hw_err_fatal(cctxt, - VCD_EVT_RESP_PAUSE, status); - rc = VCD_ERR_FAIL; - break; - } - default: - { - VCD_MSG_ERROR - ("Unexpected callback event=%d status=%d from DDL", - event, status); - - dev_ctxt->command_continue = false; - - break; - } - - } - - if (!VCD_FAILED(rc)) { - - if (payload && - ((struct ddl_frame_data_tag *)\ - payload)->frm_trans_end) { - - vcd_mark_frame_channel(cctxt->dev_ctxt); - frm_trans_end = true; - } - if (frm_trans_end && !cctxt->status.frame_submitted) { - VCD_MSG_HIGH - ("All pending frames recvd from DDL"); - - cctxt->callback(VCD_EVT_RESP_PAUSE, - VCD_S_SUCCESS, - NULL, - 0, - cctxt, - cctxt->client_data); - - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_PAUSED, - CLIENT_STATE_EVENT_NUMBER - (clnt_cb)); - - rc = vcd_power_event(cctxt->dev_ctxt, - cctxt, - VCD_EVT_PWR_CLNT_PAUSE); - - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR - ("VCD_EVT_PWR_CLNT_PAUSE_END" - "failed"); - } - } - } -} - -static void vcd_clnt_cb_in_invalid( - struct vcd_clnt_ctxt *cctxt, u32 event, u32 status, - void *payload, size_t sz, u32 *ddl_handle, - void *const client_data -) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - VCD_MSG_LOW("vcd_clnt_cb_in_invalid:"); - if (cctxt->ddl_handle != ddl_handle) { - VCD_MSG_ERROR("ddl_handle mismatch"); - return; - } - switch (event) { - case VCD_EVT_RESP_STOP: - { - vcd_handle_stop_done_in_invalid(cctxt, - (struct vcd_transc *)client_data, - status); - break; - } - case VCD_EVT_RESP_INPUT_DONE: - case VCD_EVT_RESP_OUTPUT_REQ: - { - if (cctxt->status.frame_submitted) - cctxt->status.frame_submitted--; - if (payload && ((struct ddl_frame_data_tag *) - payload)->frm_trans_end) - vcd_mark_frame_channel(cctxt->dev_ctxt); - break; - } - case VCD_EVT_RESP_OUTPUT_DONE: - { - if (payload && ((struct ddl_frame_data_tag *) - payload)->frm_trans_end) - vcd_mark_frame_channel(cctxt->dev_ctxt); - break; - } - case VCD_EVT_RESP_TRANSACTION_PENDING: - { - if (cctxt->status.frame_submitted) - cctxt->status.frame_submitted--; - vcd_mark_frame_channel(cctxt->dev_ctxt); - break; - } - case VCD_EVT_IND_HWERRFATAL: - { - if (status == VCD_ERR_HW_FATAL) - vcd_handle_stop_done_in_invalid(cctxt, - (struct vcd_transc *)client_data, - status); - - break; - } - case VCD_EVT_RESP_EOS_DONE: - { - vcd_mark_frame_channel(cctxt->dev_ctxt); - break; - } - case VCD_EVT_IND_OUTPUT_RECONFIG: - { - if (cctxt->status.frame_submitted > 0) - cctxt->status.frame_submitted--; - else - cctxt->status.frame_delayed--; - vcd_mark_frame_channel(cctxt->dev_ctxt); - break; - } - default: - { - VCD_MSG_ERROR("Unexpected callback event=%d status=%d" - "from DDL", event, status); - dev_ctxt->command_continue = false; - break; - } - } -} - -static void vcd_clnt_enter_open - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Entering CLIENT_STATE_OPEN on api %d", state_event); -} - -static void vcd_clnt_enter_starting - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Entering CLIENT_STATE_STARTING on api %d", - state_event); - cctxt->status.last_evt = VCD_EVT_RESP_START; -} - -static void vcd_clnt_enter_run - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Entering CLIENT_STATE_RUN on api %d", state_event); -} - -static void vcd_clnt_enter_flushing - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Entering CLIENT_STATE_FLUSHING on api %d", - state_event); -} - -static void vcd_clnt_enter_stopping - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Entering CLIENT_STATE_STOPPING on api %d", - state_event); - cctxt->status.last_evt = VCD_EVT_RESP_STOP; -} - -static void vcd_clnt_enter_eos(struct vcd_clnt_ctxt *cctxt, - s32 state_event) -{ - u32 rc; - VCD_MSG_MED("Entering CLIENT_STATE_EOS on api %d", state_event); - rc = vcd_sched_suspend_resume_clnt(cctxt, false); - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("Failed: vcd_sched_suspend_resume_clnt." - "rc=0x%x", rc); -} - -static void vcd_clnt_enter_pausing - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Entering CLIENT_STATE_PAUSING on api %d", - state_event); - cctxt->status.last_evt = VCD_EVT_RESP_PAUSE; -} - -static void vcd_clnt_enter_paused - (struct vcd_clnt_ctxt *cctxt, s32 state_event) -{ - VCD_MSG_MED("Entering CLIENT_STATE_PAUSED on api %d", - state_event); -} - -static void vcd_clnt_enter_invalid(struct vcd_clnt_ctxt *cctxt, - s32 state_event) -{ - VCD_MSG_MED("Entering CLIENT_STATE_INVALID on api %d", - state_event); - cctxt->ddl_hdl_valid = false; - cctxt->status.mask &= ~(VCD_FIRST_IP_RCVD | VCD_FIRST_OP_RCVD); - if (cctxt->sched_clnt_hdl) - vcd_sched_suspend_resume_clnt(cctxt, false); -} - -static void vcd_clnt_exit_open - (struct vcd_clnt_ctxt *cctxt, s32 state_event) -{ - VCD_MSG_MED("Exiting CLIENT_STATE_OPEN on api %d", state_event); -} - -static void vcd_clnt_exit_starting - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Exiting CLIENT_STATE_STARTING on api %d", - state_event); - cctxt->status.last_evt = VCD_EVT_RESP_BASE; -} - -static void vcd_clnt_exit_run - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Exiting CLIENT_STATE_RUN on api %d", state_event); -} - -static void vcd_clnt_exit_flushing - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Exiting CLIENT_STATE_FLUSHING on api %d", - state_event); -} - -static void vcd_clnt_exit_stopping - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Exiting CLIENT_STATE_STOPPING on api %d", - state_event); - cctxt->status.last_evt = VCD_EVT_RESP_BASE; -} - -static void vcd_clnt_exit_eos - (struct vcd_clnt_ctxt *cctxt, s32 state_event) -{ - u32 rc; - VCD_MSG_MED("Exiting CLIENT_STATE_EOS on api %d", state_event); - rc = vcd_sched_suspend_resume_clnt(cctxt, true); - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("Failed: vcd_sched_suspend_resume_clnt. rc=0x%x", - rc); -} - -static void vcd_clnt_exit_pausing - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Exiting CLIENT_STATE_PAUSING on api %d", - state_event); - cctxt->status.last_evt = VCD_EVT_RESP_BASE; -} - -static void vcd_clnt_exit_paused - (struct vcd_clnt_ctxt *cctxt, s32 state_event) { - VCD_MSG_MED("Exiting CLIENT_STATE_PAUSED on api %d", - state_event); -} - -static void vcd_clnt_exit_invalid(struct vcd_clnt_ctxt *cctxt, - s32 state_event) -{ - VCD_MSG_MED("Exiting CLIENT_STATE_INVALID on api %d", - state_event); -} - -void vcd_do_client_state_transition(struct vcd_clnt_ctxt *cctxt, - enum vcd_clnt_state_enum to_state, u32 ev_code) -{ - struct vcd_clnt_state_ctxt *state_ctxt; - - if (!cctxt || to_state >= VCD_CLIENT_STATE_MAX) { - VCD_MSG_ERROR("Bad parameters. cctxt=%p, to_state=%d", - cctxt, to_state); - return; - } - - state_ctxt = &cctxt->clnt_state; - - if (state_ctxt->state == to_state) { - VCD_MSG_HIGH("Client already in requested to_state=%d", - to_state); - - return; - } - - VCD_MSG_MED("vcd_do_client_state_transition: C%d -> C%d, for api %d", - (int)state_ctxt->state, (int)to_state, ev_code); - - if (state_ctxt->state_table->exit) - state_ctxt->state_table->exit(cctxt, ev_code); - - - state_ctxt->state = to_state; - state_ctxt->state_table = vcd_clnt_state_table[to_state]; - - if (state_ctxt->state_table->entry) - state_ctxt->state_table->entry(cctxt, ev_code); -} - -const struct vcd_clnt_state_table *vcd_get_client_state_table - (enum vcd_clnt_state_enum state) { - return vcd_clnt_state_table[state]; -} - -static const struct vcd_clnt_state_table vcd_clnt_table_open = { - { - vcd_close_in_open, - vcd_encode_start_in_open, - NULL, - vcd_decode_start_in_open, - NULL, - NULL, - NULL, - vcd_flush_inopen, - vcd_stop_inopen, - vcd_set_property_cmn, - vcd_get_property_cmn, - vcd_set_buffer_requirements_cmn, - vcd_get_buffer_requirements_cmn, - vcd_set_buffer_cmn, - vcd_allocate_buffer_cmn, - vcd_free_buffer_cmn, - vcd_fill_output_buffer_cmn, - NULL, - }, - vcd_clnt_enter_open, - vcd_clnt_exit_open -}; - -static const struct vcd_clnt_state_table vcd_clnt_table_starting = { - { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - vcd_get_property_cmn, - NULL, - vcd_get_buffer_requirements_cmn, - NULL, - NULL, - NULL, - NULL, - vcd_clnt_cb_in_starting, - }, - vcd_clnt_enter_starting, - vcd_clnt_exit_starting -}; - -static const struct vcd_clnt_state_table vcd_clnt_table_run = { - { - NULL, - vcd_encode_start_in_run, - vcd_encode_frame_cmn, - vcd_decode_start_in_run, - vcd_decode_frame_cmn, - vcd_pause_cmn, - NULL, - vcd_flush_cmn, - vcd_stop_in_run, - vcd_set_property_cmn, - vcd_get_property_cmn, - vcd_set_buffer_requirements_cmn, - vcd_get_buffer_requirements_cmn, - vcd_set_buffer_cmn, - vcd_allocate_buffer_cmn, - vcd_free_buffer_cmn, - vcd_fill_output_buffer_cmn, - vcd_clnt_cb_in_run, - }, - vcd_clnt_enter_run, - vcd_clnt_exit_run -}; - -static const struct vcd_clnt_state_table vcd_clnt_table_flushing = { - { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - vcd_flush_in_flushing, - NULL, - vcd_set_property_cmn, - vcd_get_property_cmn, - NULL, - vcd_get_buffer_requirements_cmn, - NULL, - NULL, - vcd_free_buffer_cmn, - vcd_fill_output_buffer_cmn, - vcd_clnt_cb_in_flushing, - }, - vcd_clnt_enter_flushing, - vcd_clnt_exit_flushing -}; - -static const struct vcd_clnt_state_table vcd_clnt_table_stopping = { - { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - vcd_get_property_cmn, - NULL, - vcd_get_buffer_requirements_cmn, - NULL, - NULL, - NULL, - NULL, - vcd_clnt_cb_in_stopping, - }, - vcd_clnt_enter_stopping, - vcd_clnt_exit_stopping -}; - -static const struct vcd_clnt_state_table vcd_clnt_table_eos = { - { - NULL, - NULL, - vcd_encode_frame_cmn, - NULL, - vcd_decode_frame_cmn, - vcd_pause_cmn, - NULL, - vcd_flush_in_eos, - vcd_stop_in_eos, - NULL, - vcd_get_property_cmn, - NULL, - vcd_get_buffer_requirements_cmn, - NULL, - NULL, - NULL, - vcd_fill_output_buffer_in_eos, - vcd_clnt_cb_in_eos, - }, - vcd_clnt_enter_eos, - vcd_clnt_exit_eos -}; - -static const struct vcd_clnt_state_table vcd_clnt_table_pausing = { - { - NULL, - NULL, - vcd_encode_frame_cmn, - NULL, - vcd_decode_frame_cmn, - NULL, - NULL, - NULL, - NULL, - vcd_set_property_cmn, - vcd_get_property_cmn, - NULL, - vcd_get_buffer_requirements_cmn, - NULL, - NULL, - NULL, - vcd_fill_output_buffer_cmn, - vcd_clnt_cb_in_pausing, - }, - vcd_clnt_enter_pausing, - vcd_clnt_exit_pausing -}; - -static const struct vcd_clnt_state_table vcd_clnt_table_paused = { - { - NULL, - NULL, - vcd_encode_frame_cmn, - NULL, - vcd_decode_frame_cmn, - NULL, - vcd_resume_in_paused, - vcd_flush_cmn, - vcd_stop_cmn, - vcd_set_property_cmn, - vcd_get_property_cmn, - vcd_set_buffer_requirements_cmn, - vcd_get_buffer_requirements_cmn, - vcd_set_buffer_cmn, - vcd_allocate_buffer_cmn, - NULL, - vcd_fill_output_buffer_cmn, - NULL, - }, - vcd_clnt_enter_paused, - vcd_clnt_exit_paused -}; -static const struct vcd_clnt_state_table vcd_clnt_table_invalid = { - { - vcd_close_in_invalid, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - vcd_flush_in_invalid, - vcd_stop_in_invalid, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - vcd_free_buffer_cmn, - NULL, - vcd_clnt_cb_in_invalid, - }, - vcd_clnt_enter_invalid, - vcd_clnt_exit_invalid -}; - -static const struct vcd_clnt_state_table *vcd_clnt_state_table[] = { - NULL, - &vcd_clnt_table_open, - &vcd_clnt_table_starting, - &vcd_clnt_table_run, - &vcd_clnt_table_flushing, - &vcd_clnt_table_pausing, - &vcd_clnt_table_paused, - &vcd_clnt_table_stopping, - &vcd_clnt_table_eos, - &vcd_clnt_table_invalid -}; diff --git a/drivers/video/msm/vidc/common/vcd/vcd_client_sm.h b/drivers/video/msm/vidc/common/vcd/vcd_client_sm.h deleted file mode 100644 index ba1884dd601dcb7839d10e130977ab6116a3947d..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_client_sm.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_CLIENT_SM_H_ -#define _VCD_CLIENT_SM_H_ -#include -#include "vcd_ddl_api.h" - -struct vcd_clnt_state_table; -struct vcd_clnt_state_ctxt; -struct vcd_clnt_ctxt; - -enum vcd_clnt_state_enum { - VCD_CLIENT_STATE_NULL = 0, - VCD_CLIENT_STATE_OPEN, - VCD_CLIENT_STATE_STARTING, - VCD_CLIENT_STATE_RUN, - VCD_CLIENT_STATE_FLUSHING, - VCD_CLIENT_STATE_PAUSING, - VCD_CLIENT_STATE_PAUSED, - VCD_CLIENT_STATE_STOPPING, - VCD_CLIENT_STATE_EOS, - VCD_CLIENT_STATE_INVALID, - VCD_CLIENT_STATE_MAX, - VCD_CLIENT_STATE_32BIT = 0x7FFFFFFF -}; - -#define CLIENT_STATE_EVENT_NUMBER(ppf) \ - ((u32 *) (&(((struct vcd_clnt_state_table*)0)->ev_hdlr.ppf)) - \ - (u32 *) (&(((struct vcd_clnt_state_table*)0)->ev_hdlr.close)) \ - + 1) - -struct vcd_clnt_state_table { - struct { - u32(*close) (struct vcd_clnt_ctxt *cctxt); - u32(*encode_start) (struct vcd_clnt_ctxt *cctxt); - u32(*encode_frame) (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame); - u32(*decode_start) (struct vcd_clnt_ctxt *cctxt, - struct vcd_sequence_hdr *seq_hdr); - u32(*decode_frame) (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame); - u32(*pause) (struct vcd_clnt_ctxt *cctxt); - u32(*resume) (struct vcd_clnt_ctxt *cctxt); - u32(*flush) (struct vcd_clnt_ctxt *cctxt, - u32 mode); - u32(*stop) (struct vcd_clnt_ctxt *cctxt); - u32(*set_property) (struct vcd_clnt_ctxt *cctxt, - struct vcd_property_hdr *prop_hdr, - void *prop); - u32(*get_property) (struct vcd_clnt_ctxt *cctxt, - struct vcd_property_hdr *prop_hdr, - void *prop); - u32(*set_buffer_requirements) (struct vcd_clnt_ctxt * - cctxt, - enum vcd_buffer_type buffer, - struct - vcd_buffer_requirement * - buffer_req); - u32(*get_buffer_requirements) (struct vcd_clnt_ctxt * - cctxt, - enum vcd_buffer_type buffer, - struct - vcd_buffer_requirement * - buffer_req); - u32(*set_buffer) (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer_type, u8 *buffer, - u32 buf_size); - u32(*allocate_buffer) (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer, u32 buf_size, - u8 **vir_buf_addr, u8 **phy_buf_addr); - u32(*free_buffer) (struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer_type, u8 *buffer); - u32(*fill_output_buffer) ( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *buffer); - void (*clnt_cb) (struct vcd_clnt_ctxt *cctxt, - u32 event, u32 status, void *payload, - size_t sz, u32 *ddl_handle, - void *const client_data); - } ev_hdlr; - - void (*entry) (struct vcd_clnt_ctxt *cctxt, - s32 state_event); - void (*exit) (struct vcd_clnt_ctxt *cctxt, - s32 state_event); -}; - -struct vcd_clnt_state_ctxt { - const struct vcd_clnt_state_table *state_table; - enum vcd_clnt_state_enum state; -}; - -extern void vcd_do_client_state_transition - (struct vcd_clnt_ctxt *cctxt, - enum vcd_clnt_state_enum to_state, u32 ev_code); - -extern const struct vcd_clnt_state_table *vcd_get_client_state_table( - enum vcd_clnt_state_enum state); - -#endif diff --git a/drivers/video/msm/vidc/common/vcd/vcd_core.h b/drivers/video/msm/vidc/common/vcd/vcd_core.h deleted file mode 100644 index 0eaff74adf3c6ef6fdc612d835b7450d8647d14a..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_core.h +++ /dev/null @@ -1,229 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_CORE_H_ -#define _VCD_CORE_H_ - -#include -#include -#include "vcd_ddl_api.h" - -#include "vcd_util.h" -#include "vcd_client_sm.h" -#include "vcd_power_sm.h" - -#define VCD_SIGNATURE 0x75017591U - -#define VCD_MIN_PERF_LEVEL 37900 - -#define VCD_DRIVER_CLIENTS_MAX 6 - -#define VCD_MAX_CLIENT_TRANSACTIONS 32 - -#define VCD_MAX_BUFFER_ENTRIES 32 - -#define VCD_SEQ_HDR_PADDING_BYTES 256 - -#define VCD_DEC_NUM_INTERLACED_FIELDS 2 - -#define VCD_TIMESTAMP_RESOLUTION 1000000 -#define VCD_DEC_INITIAL_FRAME_RATE 30 -#define VCD_MAXPERF_FPS_THRESHOLD_X_1000 (59*1000) - -#define VCD_FIRST_IP_RCVD 0x00000004 -#define VCD_FIRST_OP_RCVD 0x00000008 -#define VCD_EOS_PREV_VALID 0x00000010 -#define VCD_EOS_WAIT_OP_BUF 0x00000020 -#define VCD_CLEANING_UP 0x00000040 -#define VCD_STOP_PENDING 0x00000080 -#define VCD_CLOSE_PENDING 0x00000100 -#define VCD_IN_RECONFIG 0x00000200 -#define VCD_FIRST_IP_DONE 0x00000400 - -enum vcd_command { - VCD_CMD_NONE, - VCD_CMD_DEVICE_INIT, - VCD_CMD_DEVICE_TERM, - VCD_CMD_DEVICE_RESET, - VCD_CMD_CODEC_START, - VCD_CMD_CODEC_STOP, - VCD_CMD_CODE_FRAME, - VCD_CMD_OUTPUT_FLUSH, - VCD_CMD_CLIENT_CLOSE -}; - -enum vcd_core_type { - VCD_CORE_1080P, - VCD_CORE_720P -}; - -struct vcd_cmd_q_element { - enum vcd_command pending_cmd; -}; - -struct vcd_buffer_entry { - struct list_head sched_list; - struct list_head list; - u32 valid; - u8 *alloc; - u8 *virtual; - u8 *physical; - size_t sz; - u32 allocated; - u32 in_use; - struct vcd_frame_data frame; - -}; - -struct vcd_buffer_pool { - struct vcd_buffer_entry *entries; - u32 count; - struct vcd_buffer_requirement buf_req; - u32 validated; - u32 allocated; - u32 in_use; - struct list_head queue; - u16 q_len; -}; - -struct vcd_transc { - u32 in_use; - enum vcd_command type; - struct vcd_clnt_ctxt *cctxt; - - struct vcd_buffer_entry *ip_buf_entry; - - s64 time_stamp; - u32 flags; - u32 ip_frm_tag; - enum vcd_frame frame; - - struct vcd_buffer_entry *op_buf_entry; - - u32 input_done; - u32 frame_done; -}; - -struct vcd_dev_ctxt { - u32 ddl_cmd_concurrency; - u32 ddl_frame_ch_depth; - u32 ddl_cmd_ch_depth; - u32 ddl_frame_ch_interim; - u32 ddl_cmd_ch_interim; - u32 ddl_frame_ch_free; - u32 ddl_cmd_ch_free; - - struct list_head sched_clnt_list; - - struct vcd_init_config config; - - u32 driver_ids[VCD_DRIVER_CLIENTS_MAX]; - u32 refs; - u8 *device_base_addr; - void *hw_timer_handle; - u32 hw_time_out; - struct vcd_clnt_ctxt *cctxt_list_head; - - enum vcd_command pending_cmd; - - u32 command_continue; - - struct vcd_transc *trans_tbl; - u32 trans_tbl_size; - - enum vcd_power_state pwr_state; - enum vcd_pwr_clk_state pwr_clk_state; - u32 active_clnts; - u32 max_perf_lvl; - u32 reqd_perf_lvl; - u32 curr_perf_lvl; - u32 set_perf_lvl_pending; -}; - -struct vcd_clnt_status { - u32 req_perf_lvl; - u32 frame_submitted; - u32 frame_delayed; - u32 cmd_submitted; - u32 int_field_cnt; - s64 first_ts; - s64 prev_ts; - u64 time_elapsed; - struct vcd_frame_data eos_trig_ip_frm; - struct ddl_frame_data_tag eos_prev_op_frm; - u32 eos_prev_op_frm_status; - u32 last_err; - u32 last_evt; - u32 mask; -}; - -struct vcd_sched_clnt_ctx { - struct list_head list; - u32 clnt_active; - void *clnt_data; - u32 tkns; - u32 round_perfrm; - u32 rounds; - struct list_head ip_frm_list; -}; - -struct vcd_clnt_ctxt { - u32 signature; - struct vcd_clnt_state_ctxt clnt_state; - - s32 driver_id; - - u32 live; - u32 decoding; - u32 bframe; - u32 num_slices; - - struct vcd_property_frame_rate frm_rate; - u32 frm_p_units; - u32 reqd_perf_lvl; - u32 time_resoln; - u32 time_frame_delta; - - struct vcd_buffer_pool in_buf_pool; - struct vcd_buffer_pool out_buf_pool; - - void (*callback) (u32 event, u32 status, void *info, size_t sz, - void *handle, void *const client_data); - void *client_data; - struct vcd_sched_clnt_ctx *sched_clnt_hdl; - u32 ddl_hdl_valid; - u32 *ddl_handle; - struct vcd_dev_ctxt *dev_ctxt; - struct vcd_cmd_q_element cmd_q; - struct vcd_sequence_hdr seq_hdr; - u8 *seq_hdr_phy_addr; - struct vcd_clnt_status status; - struct ion_client *vcd_ion_client; - u32 vcd_enable_ion; - struct vcd_clnt_ctxt *next; - u32 meta_mode; - int perf_set_by_client; - int secure; - bool is_turbo_enabled; -}; - -#define VCD_BUFFERPOOL_INUSE_DECREMENT(val) \ -do { \ - if ((val) > 0) \ - val--; \ - else { \ - VCD_MSG_ERROR("%s(): Inconsistent val given in " \ - " VCD_BUFFERPOOL_INUSE_DECREMENT\n", __func__); \ - } \ -} while (0) - -#endif diff --git a/drivers/video/msm/vidc/common/vcd/vcd_device_sm.c b/drivers/video/msm/vidc/common/vcd/vcd_device_sm.c deleted file mode 100644 index 90743583b0331b985dc98844239783674641b8ae..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_device_sm.c +++ /dev/null @@ -1,1218 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include "vcd.h" - -static const struct vcd_dev_state_table *vcd_dev_state_table[]; -static const struct vcd_dev_state_table vcd_dev_table_null; - -struct vcd_drv_ctxt *vcd_get_drv_context(void) -{ - static struct vcd_drv_ctxt drv_context = { - {&vcd_dev_table_null, VCD_DEVICE_STATE_NULL}, - {0}, - }; - - return &drv_context; - -} - -void vcd_do_device_state_transition(struct vcd_drv_ctxt *drv_ctxt, - enum vcd_dev_state_enum to_state, u32 ev_code) -{ - struct vcd_dev_state_ctxt *state_ctxt; - - if (!drv_ctxt || to_state >= VCD_DEVICE_STATE_MAX) { - VCD_MSG_ERROR("Bad parameters. drv_ctxt=%p, to_state=%d", - drv_ctxt, to_state); - return; - } - - state_ctxt = &drv_ctxt->dev_state; - - if (state_ctxt->state == to_state) { - VCD_MSG_HIGH("Device already in requested to_state=%d", - to_state); - - return; - } - - VCD_MSG_MED("vcd_do_device_state_transition: D%d -> D%d, for api %d", - (int)state_ctxt->state, (int)to_state, ev_code); - - if (state_ctxt->state_table->exit) - state_ctxt->state_table->exit(drv_ctxt, ev_code); - - - state_ctxt->state = to_state; - state_ctxt->state_table = vcd_dev_state_table[to_state]; - - if (state_ctxt->state_table->entry) - state_ctxt->state_table->entry(drv_ctxt, ev_code); -} - -void vcd_hw_timeout_handler(void *user_data) -{ - struct vcd_drv_ctxt *drv_ctxt; - - VCD_MSG_HIGH("vcd_hw_timeout_handler:"); - user_data = NULL; - drv_ctxt = vcd_get_drv_context(); - mutex_lock(&drv_ctxt->dev_mutex); - if (drv_ctxt->dev_state.state_table->ev_hdlr.timeout) - drv_ctxt->dev_state.state_table->ev_hdlr. - timeout(drv_ctxt, user_data); - else - VCD_MSG_ERROR("hw_timeout unsupported in device state %d", - drv_ctxt->dev_state.state); - mutex_unlock(&drv_ctxt->dev_mutex); -} - -void vcd_ddl_callback(u32 event, u32 status, void *payload, - size_t sz, u32 *ddl_handle, void *const client_data) -{ - struct vcd_drv_ctxt *drv_ctxt; - struct vcd_dev_ctxt *dev_ctxt; - struct vcd_dev_state_ctxt *dev_state; - struct vcd_clnt_ctxt *cctxt; - struct vcd_transc *transc; - - VCD_MSG_LOW("vcd_ddl_callback:"); - - VCD_MSG_LOW("event=0x%x status=0x%x", event, status); - - drv_ctxt = vcd_get_drv_context(); - dev_ctxt = &drv_ctxt->dev_ctxt; - dev_state = &drv_ctxt->dev_state; - - dev_ctxt->command_continue = true; - vcd_device_timer_stop(dev_ctxt); - - switch (dev_state->state) { - case VCD_DEVICE_STATE_NULL: - { - VCD_MSG_HIGH("Callback unexpected in NULL state"); - break; - } - - case VCD_DEVICE_STATE_NOT_INIT: - { - VCD_MSG_HIGH("Callback unexpected in NOT_INIT state"); - break; - } - - case VCD_DEVICE_STATE_INITING: - { - if (dev_state->state_table->ev_hdlr.dev_cb) { - dev_state->state_table->ev_hdlr. - dev_cb(drv_ctxt, event, status, - payload, sz, ddl_handle, - client_data); - } else { - VCD_MSG_HIGH("No device handler in %d state", - dev_state->state); - } - break; - } - - case VCD_DEVICE_STATE_READY: - { - transc = (struct vcd_transc *)client_data; - - if (!transc || !transc->in_use || !transc->cctxt) { - VCD_MSG_ERROR("Invalid clientdata " - "received from DDL, transc = 0x%x\n", - (u32)transc); - if (transc) { - VCD_MSG_ERROR("transc->in_use = %u, " - "transc->cctxt = 0x%x\n", - transc->in_use, - (u32)transc->cctxt); - } - } else { - cctxt = transc->cctxt; - - if (cctxt->clnt_state.state_table->ev_hdlr. - clnt_cb) { - cctxt->clnt_state.state_table-> - ev_hdlr.clnt_cb(cctxt, - event, status, payload, - sz, ddl_handle, - client_data); - } else { - VCD_MSG_HIGH - ("No client handler in" - " (dsm:READY, csm:%d) state", - (int)cctxt->clnt_state.state); - - if (VCD_FAILED(status)) { - VCD_MSG_FATAL("DDL callback" - " returned failure 0x%x", - status); - } - } - } - break; - } - - default: - { - VCD_MSG_ERROR("Unknown state"); - break; - } - - } - -} - -u32 vcd_init_device_context(struct vcd_drv_ctxt *drv_ctxt, - u32 ev_code) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - u32 rc; - struct ddl_init_config ddl_init; - - VCD_MSG_LOW("vcd_init_device_context:"); - - dev_ctxt->pending_cmd = VCD_CMD_NONE; - - rc = vcd_power_event(dev_ctxt, NULL, VCD_EVT_PWR_DEV_INIT_BEGIN); - VCD_FAILED_RETURN(rc, "VCD_EVT_PWR_DEV_INIT_BEGIN failed"); - - VCD_MSG_HIGH("Device powered ON and clocked"); - rc = vcd_sched_create(&dev_ctxt->sched_clnt_list); - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_sched_create", rc); - - (void)vcd_power_event(dev_ctxt, NULL, - VCD_EVT_PWR_DEV_INIT_FAIL); - - return rc; - } - - VCD_MSG_HIGH("Created scheduler instance."); - - ddl_init.core_virtual_base_addr = dev_ctxt->device_base_addr; - ddl_init.interrupt_clr = dev_ctxt->config.interrupt_clr; - ddl_init.ddl_callback = vcd_ddl_callback; - - rc = ddl_device_init(&ddl_init, NULL); - - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR("rc = 0x%x. Failed: ddl_device_init", rc); - vcd_sched_destroy(&dev_ctxt->sched_clnt_list); - (void)vcd_power_event(dev_ctxt, NULL, - VCD_EVT_PWR_DEV_INIT_FAIL); - } else { - vcd_device_timer_start(dev_ctxt); - vcd_do_device_state_transition(drv_ctxt, - VCD_DEVICE_STATE_INITING, - ev_code); - } - return rc; -} - -void vcd_handle_device_init_failed(struct vcd_drv_ctxt *drv_ctxt, - u32 status) -{ - struct vcd_clnt_ctxt *client; - struct vcd_clnt_ctxt *tmp_client; - - VCD_MSG_ERROR("Device init failed. status = %d", status); - - client = drv_ctxt->dev_ctxt.cctxt_list_head; - while (client) { - client->callback(VCD_EVT_RESP_OPEN, - status, NULL, 0, 0, client->client_data); - - tmp_client = client; - client = client->next; - - vcd_destroy_client_context(tmp_client); - } - if (ddl_device_release(NULL)) - VCD_MSG_ERROR("Failed: ddl_device_release"); - - vcd_sched_destroy(&drv_ctxt->dev_ctxt.sched_clnt_list); - if (vcd_power_event(&drv_ctxt->dev_ctxt, - NULL, VCD_EVT_PWR_DEV_INIT_FAIL)) - VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_FAIL failed"); - - vcd_do_device_state_transition(drv_ctxt, - VCD_DEVICE_STATE_NOT_INIT, - DEVICE_STATE_EVENT_NUMBER(dev_cb)); -} - -u32 vcd_deinit_device_context(struct vcd_drv_ctxt *drv_ctxt, - u32 ev_code) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_deinit_device_context:"); - - rc = vcd_power_event(&drv_ctxt->dev_ctxt, NULL, - VCD_EVT_PWR_DEV_TERM_BEGIN); - - VCD_FAILED_RETURN(rc, "VCD_EVT_PWR_DEV_TERM_BEGIN failed"); - - rc = ddl_device_release(NULL); - - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR("rc = 0x%x. Failed: ddl_device_release", rc); - - (void)vcd_power_event(dev_ctxt, NULL, - VCD_EVT_PWR_DEV_TERM_FAIL); - } else { - vcd_sched_destroy(&dev_ctxt->sched_clnt_list); - (void) vcd_power_event(dev_ctxt, NULL, - VCD_EVT_PWR_DEV_TERM_END); - - vcd_do_device_state_transition(drv_ctxt, - VCD_DEVICE_STATE_NOT_INIT, ev_code); - } - return rc; -} - -void vcd_term_driver_context(struct vcd_drv_ctxt *drv_ctxt) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - - VCD_MSG_HIGH("All driver instances terminated"); - - if (dev_ctxt->config.deregister_isr) - dev_ctxt->config.deregister_isr(); - - if (dev_ctxt->config.un_map_dev_base_addr) - dev_ctxt->config.un_map_dev_base_addr(); - - if (dev_ctxt->config.timer_release) - dev_ctxt->config.timer_release( - dev_ctxt->hw_timer_handle); - - kfree(dev_ctxt->trans_tbl); - - memset(dev_ctxt, 0, sizeof(struct vcd_dev_ctxt)); - - vcd_do_device_state_transition(drv_ctxt, - VCD_DEVICE_STATE_NULL, - DEVICE_STATE_EVENT_NUMBER(term)); - -} - -u32 vcd_reset_device_context(struct vcd_drv_ctxt *drv_ctxt, - u32 ev_code) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_reset_device_context:"); - vcd_reset_device_channels(dev_ctxt); - rc = vcd_power_event(&drv_ctxt->dev_ctxt, NULL, - VCD_EVT_PWR_DEV_TERM_BEGIN); - VCD_FAILED_RETURN(rc, "VCD_EVT_PWR_DEV_TERM_BEGIN failed"); - if (ddl_reset_hw(0)) - VCD_MSG_HIGH("HW Reset done"); - else - VCD_MSG_FATAL("HW Reset failed"); - - (void)vcd_power_event(dev_ctxt, NULL, VCD_EVT_PWR_DEV_TERM_END); - - return VCD_S_SUCCESS; -} - -void vcd_handle_device_err_fatal(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *trig_clnt) -{ - struct vcd_clnt_ctxt *cctxt = dev_ctxt->cctxt_list_head; - struct vcd_clnt_ctxt *tmp_clnt = NULL; - VCD_MSG_LOW("vcd_handle_device_err_fatal:"); - while (cctxt) { - tmp_clnt = cctxt; - cctxt = cctxt->next; - if (tmp_clnt != trig_clnt) - vcd_clnt_handle_device_err_fatal(tmp_clnt, - tmp_clnt->status.last_evt); - } - dev_ctxt->pending_cmd = VCD_CMD_DEVICE_RESET; - if (!dev_ctxt->cctxt_list_head) - vcd_do_device_state_transition(vcd_get_drv_context(), - VCD_DEVICE_STATE_NOT_INIT, - DEVICE_STATE_EVENT_NUMBER(timeout)); - else - vcd_do_device_state_transition(vcd_get_drv_context(), - VCD_DEVICE_STATE_INVALID, - DEVICE_STATE_EVENT_NUMBER(dev_cb)); -} - -void vcd_handle_for_last_clnt_close( - struct vcd_dev_ctxt *dev_ctxt, u32 send_deinit) -{ - if (!dev_ctxt->cctxt_list_head) { - VCD_MSG_HIGH("All clients are closed"); - if (send_deinit) - (void) vcd_deinit_device_context( - vcd_get_drv_context(), - DEVICE_STATE_EVENT_NUMBER(close)); - else - dev_ctxt->pending_cmd = - VCD_CMD_DEVICE_TERM; - } -} -void vcd_continue(void) -{ - struct vcd_drv_ctxt *drv_ctxt; - struct vcd_dev_ctxt *dev_ctxt; - u32 command_continue; - struct vcd_transc *transc; - u32 rc; - VCD_MSG_LOW("vcd_continue:"); - - drv_ctxt = vcd_get_drv_context(); - dev_ctxt = &drv_ctxt->dev_ctxt; - - dev_ctxt->command_continue = false; - - if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_INIT) { - VCD_MSG_HIGH("VCD_CMD_DEVICE_INIT is pending"); - - dev_ctxt->pending_cmd = VCD_CMD_NONE; - - (void)vcd_init_device_context(drv_ctxt, - DEVICE_STATE_EVENT_NUMBER(open)); - } else if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_TERM) { - VCD_MSG_HIGH("VCD_CMD_DEVICE_TERM is pending"); - - dev_ctxt->pending_cmd = VCD_CMD_NONE; - - (void)vcd_deinit_device_context(drv_ctxt, - DEVICE_STATE_EVENT_NUMBER(close)); - } else if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_RESET) { - VCD_MSG_HIGH("VCD_CMD_DEVICE_RESET is pending"); - dev_ctxt->pending_cmd = VCD_CMD_NONE; - (void)vcd_reset_device_context(drv_ctxt, - DEVICE_STATE_EVENT_NUMBER(dev_cb)); - } else { - if (dev_ctxt->set_perf_lvl_pending) { - rc = vcd_power_event(dev_ctxt, NULL, - VCD_EVT_PWR_DEV_SET_PERFLVL); - - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR - ("VCD_EVT_PWR_CLNT_SET_PERFLVL failed"); - VCD_MSG_HIGH - ("Not running at desired perf level." - "curr=%d, reqd=%d", - dev_ctxt->curr_perf_lvl, - dev_ctxt->reqd_perf_lvl); - } else { - dev_ctxt->set_perf_lvl_pending = false; - } - } - - do { - command_continue = false; - - if (vcd_get_command_channel_in_loop - (dev_ctxt, &transc)) { - if (vcd_submit_command_in_continue(dev_ctxt, - transc)) - command_continue = true; - else { - VCD_MSG_MED - ("No more commands to submit"); - - vcd_release_command_channel(dev_ctxt, - transc); - - vcd_release_interim_command_channels - (dev_ctxt); - } - } - } while (command_continue); - - do { - command_continue = false; - - if (vcd_get_frame_channel_in_loop - (dev_ctxt, &transc)) { - if (vcd_try_submit_frame_in_continue(dev_ctxt, - transc)) { - command_continue = true; - } else { - VCD_MSG_MED("No more frames to submit"); - - vcd_release_frame_channel(dev_ctxt, - transc); - - vcd_release_interim_frame_channels - (dev_ctxt); - } - } - - } while (command_continue); - - if (!vcd_core_is_busy(dev_ctxt)) { - rc = vcd_power_event(dev_ctxt, NULL, - VCD_EVT_PWR_CLNT_CMD_END); - - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("Failed:" - "VCD_EVT_PWR_CLNT_CMD_END"); - } - } -} - -static void vcd_pause_all_sessions(struct vcd_dev_ctxt *dev_ctxt) -{ - struct vcd_clnt_ctxt *cctxt = dev_ctxt->cctxt_list_head; - u32 rc; - - while (cctxt) { - if (cctxt->clnt_state.state_table->ev_hdlr.pause) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - pause(cctxt); - - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("Client pause failed"); - - } - - cctxt = cctxt->next; - } -} - -static void vcd_resume_all_sessions(struct vcd_dev_ctxt *dev_ctxt) -{ - struct vcd_clnt_ctxt *cctxt = dev_ctxt->cctxt_list_head; - u32 rc; - - while (cctxt) { - if (cctxt->clnt_state.state_table->ev_hdlr.resume) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - resume(cctxt); - - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("Client resume failed"); - - } - - cctxt = cctxt->next; - } -} - -static u32 vcd_init_cmn - (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_init_config *config, s32 *driver_handle) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - s32 driver_id; - - if (dev_ctxt->config.interrupt_clr != - config->interrupt_clr - || dev_ctxt->config.register_isr != - config->register_isr - || dev_ctxt->config.deregister_isr != - config->deregister_isr - || dev_ctxt->config.map_dev_base_addr != - config->map_dev_base_addr - || dev_ctxt->config.un_map_dev_base_addr != - config->un_map_dev_base_addr) { - VCD_MSG_HIGH("Device config mismatch. " - "VCD will be using config from 1st vcd_init"); - } - - *driver_handle = 0; - - driver_id = 0; - while (driver_id < VCD_DRIVER_CLIENTS_MAX && - dev_ctxt->driver_ids[driver_id]) { - ++driver_id; - } - - if (driver_id == VCD_DRIVER_CLIENTS_MAX) { - VCD_MSG_ERROR("Max driver instances reached"); - - return VCD_ERR_FAIL; - } - - ++dev_ctxt->refs; - dev_ctxt->driver_ids[driver_id] = true; - *driver_handle = driver_id + 1; - - VCD_MSG_HIGH("Driver_id = %d. No of driver instances = %d", - driver_id, dev_ctxt->refs); - - return VCD_S_SUCCESS; - -} - -static u32 vcd_init_in_null - (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_init_config *config, s32 *driver_handle) { - u32 rc = VCD_S_SUCCESS; - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - u32 done_create_timer = false; - VCD_MSG_LOW("vcd_init_in_dev_null:"); - - - dev_ctxt->config = *config; - - dev_ctxt->device_base_addr = - (u8 *)config->map_dev_base_addr( - dev_ctxt->config.device_name); - - if (!dev_ctxt->device_base_addr) { - VCD_MSG_ERROR("NULL Device_base_addr"); - - return VCD_ERR_FAIL; - } - - if (config->register_isr) { - config->register_isr(dev_ctxt->config. - device_name); - } - - if (config->timer_create) { - if (config->timer_create(vcd_hw_timeout_handler, - NULL, &dev_ctxt->hw_timer_handle)) - done_create_timer = true; - else { - VCD_MSG_ERROR("timercreate failed"); - return VCD_ERR_FAIL; - } - } - - - rc = vcd_init_cmn(drv_ctxt, config, driver_handle); - - if (!VCD_FAILED(rc)) { - vcd_do_device_state_transition(drv_ctxt, - VCD_DEVICE_STATE_NOT_INIT, - DEVICE_STATE_EVENT_NUMBER - (init)); - } else { - if (dev_ctxt->config.un_map_dev_base_addr) - dev_ctxt->config.un_map_dev_base_addr(); - - if (dev_ctxt->config.deregister_isr) - dev_ctxt->config.deregister_isr(); - - if (done_create_timer && dev_ctxt->config.timer_release) - dev_ctxt->config.timer_release(dev_ctxt-> - hw_timer_handle); - - } - - return rc; - -} - -static u32 vcd_init_in_not_init - (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_init_config *config, s32 *driver_handle) -{ - - VCD_MSG_LOW("vcd_init_in_dev_not_init:"); - - return vcd_init_cmn(drv_ctxt, config, driver_handle); - -} - -static u32 vcd_init_in_initing - (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_init_config *config, s32 *driver_handle) { - - VCD_MSG_LOW("vcd_init_in_dev_initing:"); - - return vcd_init_cmn(drv_ctxt, config, driver_handle); - -} - -static u32 vcd_init_in_ready - (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_init_config *config, s32 *driver_handle) -{ - VCD_MSG_LOW("vcd_init_in_dev_ready:"); - - return vcd_init_cmn(drv_ctxt, config, driver_handle); -} - -static u32 vcd_term_cmn - (struct vcd_drv_ctxt *drv_ctxt, s32 driver_handle) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - - if (!vcd_validate_driver_handle(dev_ctxt, driver_handle)) { - VCD_MSG_ERROR("Invalid driver handle = %d", driver_handle); - - return VCD_ERR_BAD_HANDLE; - } - - if (vcd_check_for_client_context(dev_ctxt, - driver_handle - 1)) { - VCD_MSG_ERROR("Driver has active client"); - - return VCD_ERR_BAD_STATE; - } - - --dev_ctxt->refs; - dev_ctxt->driver_ids[driver_handle - 1] = false; - - VCD_MSG_HIGH("Driver_id %d terminated. No of driver instances = %d", - driver_handle - 1, dev_ctxt->refs); - - return VCD_S_SUCCESS; -} - -static u32 vcd_term_in_not_init - (struct vcd_drv_ctxt *drv_ctxt, s32 driver_handle) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - u32 rc; - - VCD_MSG_LOW("vcd_term_in_dev_not_init:"); - - rc = vcd_term_cmn(drv_ctxt, driver_handle); - - if (!VCD_FAILED(rc) && !dev_ctxt->refs) - vcd_term_driver_context(drv_ctxt); - - return rc; -} - -static u32 vcd_term_in_initing - (struct vcd_drv_ctxt *drv_ctxt, s32 driver_handle) -{ - VCD_MSG_LOW("vcd_term_in_dev_initing:"); - - return vcd_term_cmn(drv_ctxt, driver_handle); -} - -static u32 vcd_term_in_ready - (struct vcd_drv_ctxt *drv_ctxt, s32 driver_handle) -{ - VCD_MSG_LOW("vcd_term_in_dev_ready:"); - - return vcd_term_cmn(drv_ctxt, driver_handle); -} - -static u32 vcd_term_in_invalid(struct vcd_drv_ctxt *drv_ctxt, - s32 driver_handle) -{ - u32 rc; - VCD_MSG_LOW("vcd_term_in_invalid:"); - rc = vcd_term_cmn(drv_ctxt, driver_handle); - if (!VCD_FAILED(rc) && !drv_ctxt->dev_ctxt.refs) - vcd_term_driver_context(drv_ctxt); - - return rc; -} - -static u32 vcd_open_cmn - (struct vcd_drv_ctxt *drv_ctxt, - s32 driver_handle, - u32 decoding, - void (*callback) (u32 event, u32 status, void *info, size_t sz, - void *handle, void *const client_data), - void *client_data, struct vcd_clnt_ctxt ** clnt_cctxt) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - struct vcd_clnt_ctxt *cctxt; - struct vcd_clnt_ctxt *client; - - if (!vcd_validate_driver_handle(dev_ctxt, driver_handle)) { - VCD_MSG_ERROR("Invalid driver handle = %d", driver_handle); - - return VCD_ERR_BAD_HANDLE; - } - - cctxt = (struct vcd_clnt_ctxt *) - kmalloc(sizeof(struct vcd_clnt_ctxt), GFP_KERNEL); - if (!cctxt) { - VCD_MSG_ERROR("No memory for client ctxt"); - - return VCD_ERR_ALLOC_FAIL; - } - - memset(cctxt, 0, sizeof(struct vcd_clnt_ctxt)); - cctxt->dev_ctxt = dev_ctxt; - cctxt->driver_id = driver_handle - 1; - cctxt->decoding = decoding; - cctxt->callback = callback; - cctxt->client_data = client_data; - cctxt->status.last_evt = VCD_EVT_RESP_OPEN; - INIT_LIST_HEAD(&cctxt->in_buf_pool.queue); - INIT_LIST_HEAD(&cctxt->out_buf_pool.queue); - client = dev_ctxt->cctxt_list_head; - dev_ctxt->cctxt_list_head = cctxt; - cctxt->next = client; - - *clnt_cctxt = cctxt; - - return VCD_S_SUCCESS; - -} - -static u32 vcd_open_in_not_init - (struct vcd_drv_ctxt *drv_ctxt, - s32 driver_handle, - u32 decoding, - void (*callback) (u32 event, u32 status, void *info, size_t sz, - void *handle, void *const client_data), - void *client_data) -{ - struct vcd_clnt_ctxt *cctxt; - u32 rc; - - VCD_MSG_LOW("vcd_open_in_dev_not_init:"); - - rc = vcd_open_cmn(drv_ctxt, driver_handle, decoding, callback, - client_data, &cctxt); - - VCD_FAILED_RETURN(rc, "Failed: vcd_open_cmn"); - - rc = vcd_init_device_context(drv_ctxt, - DEVICE_STATE_EVENT_NUMBER(open)); - - if (VCD_FAILED(rc)) - vcd_destroy_client_context(cctxt); - - return rc; -} - -static u32 vcd_open_in_initing(struct vcd_drv_ctxt *drv_ctxt, - s32 driver_handle, u32 decoding, - void (*callback) (u32 event, u32 status, void *info, size_t sz, - void *handle, void *const client_data), - void *client_data) -{ - struct vcd_clnt_ctxt *cctxt; - - VCD_MSG_LOW("vcd_open_in_dev_initing:"); - - return vcd_open_cmn(drv_ctxt, driver_handle, decoding, callback, - client_data, &cctxt); -} - -static u32 vcd_open_in_ready - (struct vcd_drv_ctxt *drv_ctxt, - s32 driver_handle, - u32 decoding, - void (*callback) (u32 event, u32 status, void *info, size_t sz, - void *handle, void *const client_data), - void *client_data) -{ - struct vcd_clnt_ctxt *cctxt; - struct vcd_handle_container container; - u32 rc; - - VCD_MSG_LOW("vcd_open_in_dev_ready:"); - - rc = vcd_open_cmn(drv_ctxt, driver_handle, decoding, callback, - client_data, &cctxt); - - VCD_FAILED_RETURN(rc, "Failed: vcd_open_cmn"); - - rc = vcd_init_client_context(cctxt); - - if (!VCD_FAILED(rc)) { - container.handle = (void *)cctxt; - - callback(VCD_EVT_RESP_OPEN, - VCD_S_SUCCESS, - &container, - sizeof(container), container.handle, client_data); - } else { - VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_init_client_context", rc); - - vcd_destroy_client_context(cctxt); - } - - return rc; -} - -static u32 vcd_close_in_ready - (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_clnt_ctxt *cctxt) { - u32 rc; - - VCD_MSG_LOW("vcd_close_in_dev_ready:"); - - if (cctxt->clnt_state.state_table->ev_hdlr.close) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - close(cctxt); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - vcd_destroy_client_context(cctxt); - rc = VCD_ERR_BAD_STATE; - } - - if (!VCD_FAILED(rc)) - vcd_handle_for_last_clnt_close(&drv_ctxt->dev_ctxt, true); - - return rc; -} - -static u32 vcd_close_in_dev_invalid(struct vcd_drv_ctxt *drv_ctxt, - struct vcd_clnt_ctxt *cctxt) -{ - u32 rc; - VCD_MSG_LOW("vcd_close_in_dev_invalid:"); - if (cctxt->clnt_state.state_table->ev_hdlr.close) { - rc = cctxt->clnt_state.state_table-> - ev_hdlr.close(cctxt); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - rc = VCD_ERR_BAD_STATE; - } - if (!VCD_FAILED(rc) && !drv_ctxt->dev_ctxt. - cctxt_list_head) { - VCD_MSG_HIGH("All INVALID clients are closed"); - vcd_do_device_state_transition(drv_ctxt, - VCD_DEVICE_STATE_NOT_INIT, - DEVICE_STATE_EVENT_NUMBER(close)); - } - return rc; -} - -static u32 vcd_resume_in_ready - (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_clnt_ctxt *cctxt) { - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_resume_in_ready:"); - - if (cctxt->clnt_state.state_table->ev_hdlr.resume) { - rc = cctxt->clnt_state.state_table->ev_hdlr. - resume(cctxt); - } else { - VCD_MSG_ERROR("Unsupported API in client state %d", - cctxt->clnt_state.state); - - rc = VCD_ERR_BAD_STATE; - } - - return rc; -} - -static u32 vcd_set_dev_pwr_in_ready - (struct vcd_drv_ctxt *drv_ctxt, - enum vcd_power_state pwr_state) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - - VCD_MSG_LOW("vcd_set_dev_pwr_in_ready:"); - - switch (pwr_state) { - case VCD_PWR_STATE_SLEEP: - { - if (dev_ctxt->pwr_state == VCD_PWR_STATE_ON) - vcd_pause_all_sessions(dev_ctxt); - dev_ctxt->pwr_state = VCD_PWR_STATE_SLEEP; - break; - } - - case VCD_PWR_STATE_ON: - { - if (dev_ctxt->pwr_state == VCD_PWR_STATE_SLEEP) - vcd_resume_all_sessions(dev_ctxt); - dev_ctxt->pwr_state = VCD_PWR_STATE_ON; - break; - } - - default: - { - VCD_MSG_ERROR("Invalid power state requested %d", - pwr_state); - break; - } - - } - - return rc; -} - -static void vcd_dev_cb_in_initing - (struct vcd_drv_ctxt *drv_ctxt, - u32 event, - u32 status, - void *payload, size_t sz, u32 *ddl_handle, void *const client_data) -{ - struct vcd_dev_ctxt *dev_ctxt; - struct vcd_clnt_ctxt *client; - struct vcd_clnt_ctxt *tmp_client; - struct vcd_handle_container container; - u32 rc = VCD_S_SUCCESS; - u32 client_inited = false; - u32 fail_all_open = false; - struct ddl_context *ddl_context; - - ddl_context = ddl_get_context(); - - VCD_MSG_LOW("vcd_dev_cb_in_initing:"); - - if (event != VCD_EVT_RESP_DEVICE_INIT) { - VCD_MSG_ERROR("vcd_dev_cb_in_initing: Unexpected event %d", - (int)event); - return; - } - - dev_ctxt = &drv_ctxt->dev_ctxt; - - dev_ctxt->command_continue = false; - - if (VCD_FAILED(status)) { - vcd_handle_device_init_failed(drv_ctxt, status); - - return; - } - - vcd_do_device_state_transition(drv_ctxt, - VCD_DEVICE_STATE_READY, - DEVICE_STATE_EVENT_NUMBER(open)); - - if (!dev_ctxt->cctxt_list_head) { - VCD_MSG_HIGH("All clients are closed"); - - dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM; - - return; - } - - if (!dev_ctxt->ddl_cmd_ch_depth - || !dev_ctxt->trans_tbl) - rc = vcd_setup_with_ddl_capabilities(dev_ctxt); - - - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR - ("rc = 0x%x: Failed vcd_setup_with_ddl_capabilities", - rc); - - fail_all_open = true; - } - - client = dev_ctxt->cctxt_list_head; - while (client) { - if (!fail_all_open) - rc = vcd_init_client_context(client); - - - if (!VCD_FAILED(rc)) { - container.handle = (void *)client; - client->callback(VCD_EVT_RESP_OPEN, - VCD_S_SUCCESS, - &container, - sizeof(container), - container.handle, - client->client_data); - - client = client->next; - - client_inited = true; - } else { - VCD_MSG_ERROR - ("rc = 0x%x, Failed: vcd_init_client_context", - rc); - - client->callback(VCD_EVT_RESP_OPEN, - rc, - NULL, 0, 0, client->client_data); - - tmp_client = client; - client = client->next; - if (tmp_client == dev_ctxt->cctxt_list_head) - fail_all_open = true; - - vcd_destroy_client_context(tmp_client); - } - } - - if (!client_inited || fail_all_open) { - VCD_MSG_ERROR("All client open requests failed"); - - DDL_IDLE(ddl_context); - - vcd_handle_device_init_failed(drv_ctxt, - DEVICE_STATE_EVENT_NUMBER(close)); - dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM; - } else { - if (vcd_power_event(dev_ctxt, NULL, - VCD_EVT_PWR_DEV_INIT_END)) { - VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_END failed"); - } - } -} - -static void vcd_hw_timeout_cmn(struct vcd_drv_ctxt *drv_ctxt, - void *user_data) -{ - struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; - VCD_MSG_LOW("vcd_hw_timeout_cmn:"); - vcd_device_timer_stop(dev_ctxt); - - vcd_handle_device_err_fatal(dev_ctxt, NULL); - - /* Reset HW. */ - (void) vcd_reset_device_context(drv_ctxt, - DEVICE_STATE_EVENT_NUMBER(timeout)); -} - -static void vcd_dev_enter_null - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Entering DEVICE_STATE_NULL on api %d", state_event); - -} - -static void vcd_dev_enter_not_init - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Entering DEVICE_STATE_NOT_INIT on api %d", - state_event); - -} - -static void vcd_dev_enter_initing - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Entering DEVICE_STATE_INITING on api %d", - state_event); - -} - -static void vcd_dev_enter_ready - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Entering DEVICE_STATE_READY on api %d", - state_event); -} - -static void vcd_dev_enter_invalid(struct vcd_drv_ctxt *drv_ctxt, - s32 state_event) -{ - VCD_MSG_MED("Entering DEVICE_STATE_INVALID on api %d", state_event); -} - -static void vcd_dev_exit_null - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Exiting DEVICE_STATE_NULL on api %d", state_event); -} - -static void vcd_dev_exit_not_init - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Exiting DEVICE_STATE_NOT_INIT on api %d", - state_event); - -} - -static void vcd_dev_exit_initing - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Exiting DEVICE_STATE_INITING on api %d", - state_event); -} - -static void vcd_dev_exit_ready - (struct vcd_drv_ctxt *drv_ctxt, s32 state_event) { - VCD_MSG_MED("Exiting DEVICE_STATE_READY on api %d", state_event); -} - -static void vcd_dev_exit_invalid(struct vcd_drv_ctxt *drv_ctxt, - s32 state_event) -{ - VCD_MSG_MED("Exiting DEVICE_STATE_INVALID on api %d", state_event); -} - -static const struct vcd_dev_state_table vcd_dev_table_null = { - { - vcd_init_in_null, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - }, - vcd_dev_enter_null, - vcd_dev_exit_null -}; - -static const struct vcd_dev_state_table vcd_dev_table_not_init = { - { - vcd_init_in_not_init, - vcd_term_in_not_init, - vcd_open_in_not_init, - NULL, - NULL, - NULL, - NULL, - NULL, - }, - vcd_dev_enter_not_init, - vcd_dev_exit_not_init -}; - -static const struct vcd_dev_state_table vcd_dev_table_initing = { - { - vcd_init_in_initing, - vcd_term_in_initing, - vcd_open_in_initing, - NULL, - NULL, - NULL, - vcd_dev_cb_in_initing, - vcd_hw_timeout_cmn, - }, - vcd_dev_enter_initing, - vcd_dev_exit_initing -}; - -static const struct vcd_dev_state_table vcd_dev_table_ready = { - { - vcd_init_in_ready, - vcd_term_in_ready, - vcd_open_in_ready, - vcd_close_in_ready, - vcd_resume_in_ready, - vcd_set_dev_pwr_in_ready, - NULL, - vcd_hw_timeout_cmn, - }, - vcd_dev_enter_ready, - vcd_dev_exit_ready -}; - -static const struct vcd_dev_state_table vcd_dev_table_in_invalid = { - { - NULL, - vcd_term_in_invalid, - NULL, - vcd_close_in_dev_invalid, - NULL, - NULL, - NULL, - NULL, - }, - vcd_dev_enter_invalid, - vcd_dev_exit_invalid -}; - -static const struct vcd_dev_state_table *vcd_dev_state_table[] = { - &vcd_dev_table_null, - &vcd_dev_table_not_init, - &vcd_dev_table_initing, - &vcd_dev_table_ready, - &vcd_dev_table_in_invalid -}; diff --git a/drivers/video/msm/vidc/common/vcd/vcd_device_sm.h b/drivers/video/msm/vidc/common/vcd/vcd_device_sm.h deleted file mode 100644 index 898f284bee8e3978d000ff9d66522024848eb4e0..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_device_sm.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_DEVICE_SM_H_ -#define _VCD_DEVICE_SM_H_ - -#include -#include "vcd_ddl_api.h" -#include "vcd_core.h" - -struct vcd_dev_state_table; -struct vcd_dev_state_ctxt; -struct vcd_drv_ctxt; - -enum vcd_dev_state_enum { - VCD_DEVICE_STATE_NULL = 0, - VCD_DEVICE_STATE_NOT_INIT, - VCD_DEVICE_STATE_INITING, - VCD_DEVICE_STATE_READY, - VCD_DEVICE_STATE_INVALID, - VCD_DEVICE_STATE_MAX, - VCD_DEVICE_STATE_32BIT = 0x7FFFFFFF -}; - -struct vcd_dev_state_table { - struct { - u32(*init) (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_init_config *config, - s32 *driver_handle); - - u32(*term) (struct vcd_drv_ctxt *drv_ctxt, - s32 driver_handle); - - u32(*open) (struct vcd_drv_ctxt *drv_ctxt, - s32 driver_handle, u32 decoding, - void (*callback) (u32 event, u32 status, - void *info, size_t sz, void *handle, - void *const client_data), - void *client_data); - - u32(*close) (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_clnt_ctxt *cctxt); - - u32(*resume) (struct vcd_drv_ctxt *drv_ctxt, - struct vcd_clnt_ctxt *cctxt); - - u32(*set_dev_pwr) (struct vcd_drv_ctxt *drv_ctxt, - enum vcd_power_state pwr_state); - - void (*dev_cb) (struct vcd_drv_ctxt *drv_ctxt, - u32 event, u32 status, void *payload, - size_t sz, u32 *ddl_handle, - void *const client_data); - - void (*timeout) (struct vcd_drv_ctxt *drv_ctxt, - void *user_data); - } ev_hdlr; - - void (*entry) (struct vcd_drv_ctxt *drv_ctxt, - s32 state_event); - void (*exit) (struct vcd_drv_ctxt *drv_ctxt, - s32 state_event); -}; - -#define DEVICE_STATE_EVENT_NUMBER(ppf) \ - ((u32 *) (&(((struct vcd_dev_state_table*)0)->ev_hdlr.ppf)) - \ - (u32 *) (&(((struct vcd_dev_state_table*)0)->ev_hdlr.init)) \ - + 1) - -struct vcd_dev_state_ctxt { - const struct vcd_dev_state_table *state_table; - - enum vcd_dev_state_enum state; -}; - -struct vcd_drv_ctxt { - struct vcd_dev_state_ctxt dev_state; - struct vcd_dev_ctxt dev_ctxt; - struct mutex dev_mutex; -}; - - -extern struct vcd_drv_ctxt *vcd_get_drv_context(void); - -void vcd_continue(void); - -#endif diff --git a/drivers/video/msm/vidc/common/vcd/vcd_power_sm.c b/drivers/video/msm/vidc/common/vcd/vcd_power_sm.c deleted file mode 100644 index 4b70eeda0b7a544a96e290f28ec86ecc558bd41c..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_power_sm.c +++ /dev/null @@ -1,398 +0,0 @@ -/* Copyright (c) 2010-2012, 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 -#include "vcd_power_sm.h" -#include "vcd_core.h" -#include "vcd.h" -#include "vcd_res_tracker.h" - -u32 vcd_power_event( - struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *cctxt, u32 event) -{ - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_MED("Device power state = %d", dev_ctxt->pwr_clk_state); - VCD_MSG_MED("event = 0x%x", event); - switch (event) { - - case VCD_EVT_PWR_DEV_INIT_BEGIN: - case VCD_EVT_PWR_DEV_INIT_END: - case VCD_EVT_PWR_DEV_INIT_FAIL: - case VCD_EVT_PWR_DEV_TERM_BEGIN: - case VCD_EVT_PWR_DEV_TERM_END: - case VCD_EVT_PWR_DEV_TERM_FAIL: - case VCD_EVT_PWR_DEV_SLEEP_BEGIN: - case VCD_EVT_PWR_DEV_SLEEP_END: - case VCD_EVT_PWR_DEV_SET_PERFLVL: - case VCD_EVT_PWR_DEV_HWTIMEOUT: - { - rc = vcd_device_power_event(dev_ctxt, event, - cctxt); - break; - } - - case VCD_EVT_PWR_CLNT_CMD_BEGIN: - case VCD_EVT_PWR_CLNT_CMD_END: - case VCD_EVT_PWR_CLNT_CMD_FAIL: - case VCD_EVT_PWR_CLNT_PAUSE: - case VCD_EVT_PWR_CLNT_RESUME: - case VCD_EVT_PWR_CLNT_FIRST_FRAME: - case VCD_EVT_PWR_CLNT_LAST_FRAME: - case VCD_EVT_PWR_CLNT_ERRFATAL: - { - rc = vcd_client_power_event(dev_ctxt, cctxt, event); - break; - } - - } - - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("vcd_power_event: event 0x%x failed", event); - - - return rc; - -} - -u32 vcd_device_power_event(struct vcd_dev_ctxt *dev_ctxt, u32 event, - struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_ERR_FAIL; - u32 set_perf_lvl; - - switch (event) { - - case VCD_EVT_PWR_DEV_INIT_BEGIN: - { - if (dev_ctxt->pwr_clk_state == - VCD_PWRCLK_STATE_OFF) { - if (res_trk_get_max_perf_level(&dev_ctxt-> - max_perf_lvl)) { - if (res_trk_power_up()) { - dev_ctxt->pwr_clk_state = - VCD_PWRCLK_STATE_ON_NOTCLOCKED; - dev_ctxt->curr_perf_lvl = 0; - dev_ctxt->reqd_perf_lvl = 0; - dev_ctxt->active_clnts = 0; - dev_ctxt-> - set_perf_lvl_pending = false; - rc = vcd_enable_clock(dev_ctxt, - cctxt); - if (VCD_FAILED(rc)) { - (void)res_trk_power_down(); - dev_ctxt->pwr_clk_state = - VCD_PWRCLK_STATE_OFF; - } - } - } - } - - break; - } - - case VCD_EVT_PWR_DEV_INIT_END: - case VCD_EVT_PWR_DEV_TERM_FAIL: - case VCD_EVT_PWR_DEV_SLEEP_BEGIN: - case VCD_EVT_PWR_DEV_HWTIMEOUT: - { - rc = vcd_gate_clock(dev_ctxt); - - break; - } - - case VCD_EVT_PWR_DEV_INIT_FAIL: - case VCD_EVT_PWR_DEV_TERM_END: - { - if (dev_ctxt->pwr_clk_state != - VCD_PWRCLK_STATE_OFF) { - (void)vcd_disable_clock(dev_ctxt); - (void)res_trk_power_down(); - - dev_ctxt->pwr_clk_state = - VCD_PWRCLK_STATE_OFF; - dev_ctxt->curr_perf_lvl = 0; - dev_ctxt->reqd_perf_lvl = 0; - dev_ctxt->active_clnts = 0; - dev_ctxt->set_perf_lvl_pending = false; - rc = VCD_S_SUCCESS; - } - - break; - } - - case VCD_EVT_PWR_DEV_TERM_BEGIN: - case VCD_EVT_PWR_DEV_SLEEP_END: - { - rc = vcd_un_gate_clock(dev_ctxt); - - break; - } - - case VCD_EVT_PWR_DEV_SET_PERFLVL: - { - set_perf_lvl = - dev_ctxt->reqd_perf_lvl > - 0 ? dev_ctxt-> - reqd_perf_lvl : VCD_MIN_PERF_LEVEL; - rc = vcd_set_perf_level(dev_ctxt, set_perf_lvl); - break; - } - } - return rc; -} - -u32 vcd_client_power_event( - struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *cctxt, u32 event) -{ - u32 rc = VCD_ERR_FAIL; - - switch (event) { - - case VCD_EVT_PWR_CLNT_CMD_BEGIN: - { - rc = vcd_un_gate_clock(dev_ctxt); - break; - } - - case VCD_EVT_PWR_CLNT_CMD_END: - { - rc = vcd_gate_clock(dev_ctxt); - break; - } - - case VCD_EVT_PWR_CLNT_CMD_FAIL: - { - if (!vcd_core_is_busy(dev_ctxt)) - rc = vcd_gate_clock(dev_ctxt); - - break; - } - - case VCD_EVT_PWR_CLNT_PAUSE: - case VCD_EVT_PWR_CLNT_LAST_FRAME: - case VCD_EVT_PWR_CLNT_ERRFATAL: - { - if (cctxt) { - rc = VCD_S_SUCCESS; - if (cctxt->status.req_perf_lvl) { - dev_ctxt->reqd_perf_lvl -= - cctxt->reqd_perf_lvl; - cctxt->status.req_perf_lvl = false; - rc = vcd_set_perf_level(dev_ctxt, - dev_ctxt->reqd_perf_lvl); - } - } - - break; - } - - case VCD_EVT_PWR_CLNT_RESUME: - case VCD_EVT_PWR_CLNT_FIRST_FRAME: - { - if (cctxt) { - rc = VCD_S_SUCCESS; - if (!cctxt->status.req_perf_lvl) { - dev_ctxt->reqd_perf_lvl += - cctxt->reqd_perf_lvl; - cctxt->status.req_perf_lvl = true; - - rc = vcd_set_perf_level(dev_ctxt, - dev_ctxt->reqd_perf_lvl); - } - } - break; - } - } - - return rc; -} - -u32 vcd_enable_clock(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - u32 set_perf_lvl; - - if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_OFF) { - VCD_MSG_ERROR("vcd_enable_clock(): Already in state " - "VCD_PWRCLK_STATE_OFF\n"); - rc = VCD_ERR_FAIL; - } else if (dev_ctxt->pwr_clk_state == - VCD_PWRCLK_STATE_ON_NOTCLOCKED) { - set_perf_lvl = - dev_ctxt->reqd_perf_lvl > - 0 ? dev_ctxt-> - reqd_perf_lvl : VCD_MIN_PERF_LEVEL; - rc = vcd_set_perf_level(dev_ctxt, set_perf_lvl); - if (!VCD_FAILED(rc)) { - if (res_trk_enable_clocks()) { - dev_ctxt->pwr_clk_state = - VCD_PWRCLK_STATE_ON_CLOCKED; - } - } else { - rc = VCD_ERR_FAIL; - } - - } - - if (!VCD_FAILED(rc)) - dev_ctxt->active_clnts++; - - return rc; -} - -u32 vcd_disable_clock(struct vcd_dev_ctxt *dev_ctxt) -{ - u32 rc = VCD_S_SUCCESS; - - if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_OFF) { - VCD_MSG_ERROR("vcd_disable_clock(): Already in state " - "VCD_PWRCLK_STATE_OFF\n"); - rc = VCD_ERR_FAIL; - } else if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_ON_CLOCKED || - dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_ON_CLOCKGATED) { - dev_ctxt->active_clnts--; - - if (!dev_ctxt->active_clnts) { - if (!res_trk_disable_clocks()) - rc = VCD_ERR_FAIL; - - dev_ctxt->pwr_clk_state = - VCD_PWRCLK_STATE_ON_NOTCLOCKED; - dev_ctxt->curr_perf_lvl = 0; - } - } - - return rc; -} - -u32 vcd_set_perf_level(struct vcd_dev_ctxt *dev_ctxt, u32 perf_lvl) -{ - u32 rc = VCD_S_SUCCESS; - if (!vcd_core_is_busy(dev_ctxt)) { - if (res_trk_set_perf_level(perf_lvl, - &dev_ctxt->curr_perf_lvl, dev_ctxt)) { - dev_ctxt->set_perf_lvl_pending = false; - } else { - rc = VCD_ERR_FAIL; - dev_ctxt->set_perf_lvl_pending = true; - } - - } else { - dev_ctxt->set_perf_lvl_pending = true; - } - - return rc; -} - -u32 vcd_set_perf_turbo_level(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; -#ifdef CONFIG_MSM_BUS_SCALING - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - pr_err("\n Setting Turbo mode !!"); - - if (res_trk_update_bus_perf_level(dev_ctxt, - RESTRK_1080P_TURBO_PERF_LEVEL) < 0) { - pr_err("\n %s(): update buf perf level failed\n", - __func__); - return false; - } - dev_ctxt->curr_perf_lvl = RESTRK_1080P_TURBO_PERF_LEVEL; - vcd_update_decoder_perf_level(dev_ctxt, RESTRK_1080P_TURBO_PERF_LEVEL); -#endif - return rc; -} - -u32 vcd_update_decoder_perf_level(struct vcd_dev_ctxt *dev_ctxt, u32 perf_lvl) -{ - u32 rc = VCD_S_SUCCESS; - - if (res_trk_set_perf_level(perf_lvl, - &dev_ctxt->curr_perf_lvl, dev_ctxt)) { - dev_ctxt->set_perf_lvl_pending = false; - } else { - rc = VCD_ERR_FAIL; - dev_ctxt->set_perf_lvl_pending = true; - } - - return rc; -} - -u32 vcd_update_clnt_perf_lvl( - struct vcd_clnt_ctxt *cctxt, - struct vcd_property_frame_rate *fps, u32 frm_p_units) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 new_perf_lvl; - new_perf_lvl = frm_p_units *\ - (fps->fps_numerator / fps->fps_denominator); - - if ((fps->fps_numerator * 1000) / fps->fps_denominator - > VCD_MAXPERF_FPS_THRESHOLD_X_1000) { - u32 max_perf_level = 0; - if (res_trk_get_max_perf_level(&max_perf_level)) { - new_perf_lvl = max_perf_level; - VCD_MSG_HIGH("Using max perf level(%d) for >60fps\n", - new_perf_lvl); - } else { - VCD_MSG_ERROR("Failed to get max perf level\n"); - } - } - if (cctxt->status.req_perf_lvl) { - dev_ctxt->reqd_perf_lvl = - dev_ctxt->reqd_perf_lvl - cctxt->reqd_perf_lvl + - new_perf_lvl; - rc = vcd_set_perf_level(cctxt->dev_ctxt, - dev_ctxt->reqd_perf_lvl); - } - cctxt->reqd_perf_lvl = new_perf_lvl; - return rc; -} - -u32 vcd_gate_clock(struct vcd_dev_ctxt *dev_ctxt) -{ - u32 rc = VCD_S_SUCCESS; - if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_OFF || - dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_ON_NOTCLOCKED) { - VCD_MSG_ERROR("%s(): Clk is Off or Not Clked yet\n", __func__); - rc = VCD_ERR_FAIL; - } else if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_ON_CLOCKGATED) - rc = VCD_S_SUCCESS; - else if (res_trk_disable_clocks()) - dev_ctxt->pwr_clk_state = VCD_PWRCLK_STATE_ON_CLOCKGATED; - else - rc = VCD_ERR_FAIL; - return rc; -} - -u32 vcd_un_gate_clock(struct vcd_dev_ctxt *dev_ctxt) -{ - u32 rc = VCD_S_SUCCESS; - if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_OFF || - dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_ON_NOTCLOCKED) { - VCD_MSG_ERROR("%s(): Clk is Off or Not Clked yet\n", __func__); - rc = VCD_ERR_FAIL; - } else if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_ON_CLOCKED) - rc = VCD_S_SUCCESS; - else if (res_trk_enable_clocks()) - dev_ctxt->pwr_clk_state = VCD_PWRCLK_STATE_ON_CLOCKED; - else - rc = VCD_ERR_FAIL; - return rc; -} - diff --git a/drivers/video/msm/vidc/common/vcd/vcd_power_sm.h b/drivers/video/msm/vidc/common/vcd/vcd_power_sm.h deleted file mode 100644 index aecbc8d58f283536c99e42920146f306da399c39..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_power_sm.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2010, 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 _VCD_POWERSM_H_ -#define _VCD_POWERSM_H_ - -#define VCD_EVT_PWR_BASE 0x5000 -#define VCD_EVT_PWR_DEV_INIT_BEGIN (VCD_EVT_PWR_BASE + 0x1) -#define VCD_EVT_PWR_DEV_INIT_END (VCD_EVT_PWR_BASE + 0x2) -#define VCD_EVT_PWR_DEV_INIT_FAIL (VCD_EVT_PWR_BASE + 0x3) -#define VCD_EVT_PWR_DEV_TERM_BEGIN (VCD_EVT_PWR_BASE + 0x4) -#define VCD_EVT_PWR_DEV_TERM_END (VCD_EVT_PWR_BASE + 0x5) -#define VCD_EVT_PWR_DEV_TERM_FAIL (VCD_EVT_PWR_BASE + 0x6) -#define VCD_EVT_PWR_DEV_SLEEP_BEGIN (VCD_EVT_PWR_BASE + 0x7) -#define VCD_EVT_PWR_DEV_SLEEP_END (VCD_EVT_PWR_BASE + 0x8) -#define VCD_EVT_PWR_DEV_SET_PERFLVL (VCD_EVT_PWR_BASE + 0x9) -#define VCD_EVT_PWR_DEV_HWTIMEOUT (VCD_EVT_PWR_BASE + 0xa) -#define VCD_EVT_PWR_CLNT_CMD_BEGIN (VCD_EVT_PWR_BASE + 0xb) -#define VCD_EVT_PWR_CLNT_CMD_END (VCD_EVT_PWR_BASE + 0xc) -#define VCD_EVT_PWR_CLNT_CMD_FAIL (VCD_EVT_PWR_BASE + 0xd) -#define VCD_EVT_PWR_CLNT_PAUSE (VCD_EVT_PWR_BASE + 0xe) -#define VCD_EVT_PWR_CLNT_RESUME (VCD_EVT_PWR_BASE + 0xf) -#define VCD_EVT_PWR_CLNT_FIRST_FRAME (VCD_EVT_PWR_BASE + 0x10) -#define VCD_EVT_PWR_CLNT_LAST_FRAME (VCD_EVT_PWR_BASE + 0x11) -#define VCD_EVT_PWR_CLNT_ERRFATAL (VCD_EVT_PWR_BASE + 0x12) - -enum vcd_pwr_clk_state { - VCD_PWRCLK_STATE_OFF = 0, - VCD_PWRCLK_STATE_ON_NOTCLOCKED, - VCD_PWRCLK_STATE_ON_CLOCKED, - VCD_PWRCLK_STATE_ON_CLOCKGATED -}; - -#endif diff --git a/drivers/video/msm/vidc/common/vcd/vcd_scheduler.c b/drivers/video/msm/vidc/common/vcd/vcd_scheduler.c deleted file mode 100644 index fe0e131b19f8247e8d7b232b24e79ad521055cb0..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_scheduler.c +++ /dev/null @@ -1,296 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include "vcd.h" - -#define NORMALIZATION_FACTOR 3600 -#define ADJUST_CLIENT_ROUNDS(client, round_adjustment) \ -do {\ - if ((client)->rounds < round_adjustment) {\ - (client)->rounds = 0;\ - VCD_MSG_HIGH("%s(): WARNING: Scheduler list unsorted",\ - __func__);\ - } else\ - (client)->rounds -= round_adjustment;\ -} while (0) - -u32 vcd_sched_create(struct list_head *sched_list) -{ - u32 rc = VCD_S_SUCCESS; - if (!sched_list) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else - INIT_LIST_HEAD(sched_list); - return rc; -} - -void vcd_sched_destroy(struct list_head *sched_clnt_list) -{ - struct vcd_sched_clnt_ctx *sched_clnt, *sched_clnt_next; - if (sched_clnt_list) - list_for_each_entry_safe(sched_clnt, - sched_clnt_next, sched_clnt_list, list) { - list_del_init(&sched_clnt->list); - sched_clnt->clnt_active = false; - } -} - -void insert_client_in_list(struct list_head *sched_clnt_list, - struct vcd_sched_clnt_ctx *sched_new_clnt, bool tail) -{ - struct vcd_sched_clnt_ctx *sched_clnt; - if (!list_empty(sched_clnt_list)) { - if (tail) - sched_clnt = list_entry(sched_clnt_list->prev, - struct vcd_sched_clnt_ctx, list); - else - sched_clnt = list_first_entry(sched_clnt_list, - struct vcd_sched_clnt_ctx, list); - sched_new_clnt->rounds = sched_clnt->rounds; - } else - sched_new_clnt->rounds = 0; - if (tail) - list_add_tail(&sched_new_clnt->list, sched_clnt_list); - else - list_add(&sched_new_clnt->list, sched_clnt_list); -} - -u32 vcd_sched_add_client(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_property_hdr prop_hdr; - struct vcd_sched_clnt_ctx *sched_cctxt; - u32 rc = VCD_S_SUCCESS; - if (!cctxt) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else if (cctxt->sched_clnt_hdl) - VCD_MSG_HIGH( - "%s(): Scheduler client already exists!", __func__); - else { - sched_cctxt = (struct vcd_sched_clnt_ctx *) - kmalloc(sizeof(struct vcd_sched_clnt_ctx), - GFP_KERNEL); - if (sched_cctxt) { - - prop_hdr.prop_id = DDL_I_FRAME_PROC_UNITS; - prop_hdr.sz = sizeof(cctxt->frm_p_units); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, - &cctxt->frm_p_units); - if (VCD_FAILED(rc)) { - kfree(sched_cctxt); - VCD_MSG_ERROR( - "Failed: Get DDL_I_FRAME_PROC_UNITS"); - return rc; - } - - if (cctxt->decoding) { - cctxt->frm_rate.fps_numerator = - VCD_DEC_INITIAL_FRAME_RATE; - cctxt->frm_rate.fps_denominator = 1; - } else { - prop_hdr.prop_id = VCD_I_FRAME_RATE; - prop_hdr.sz = sizeof(cctxt->frm_rate); - rc = ddl_get_property(cctxt->ddl_handle, - &prop_hdr, &cctxt->frm_rate); - if (VCD_FAILED(rc)) { - kfree(sched_cctxt); - VCD_MSG_ERROR( - "Failed: Get VCD_I_FRAME_RATE"); - return rc; - } - } - if (!cctxt->perf_set_by_client) - cctxt->reqd_perf_lvl = cctxt->frm_p_units * - cctxt->frm_rate.fps_numerator / - cctxt->frm_rate.fps_denominator; - - cctxt->sched_clnt_hdl = sched_cctxt; - memset(sched_cctxt, 0, - sizeof(struct vcd_sched_clnt_ctx)); - sched_cctxt->tkns = 0; - sched_cctxt->round_perfrm = NORMALIZATION_FACTOR * - cctxt->frm_rate.fps_denominator / - cctxt->frm_rate.fps_numerator; - sched_cctxt->clnt_active = true; - sched_cctxt->clnt_data = cctxt; - INIT_LIST_HEAD(&sched_cctxt->ip_frm_list); - - insert_client_in_list( - &cctxt->dev_ctxt->sched_clnt_list, - sched_cctxt, false); - } - } - return rc; -} - -u32 vcd_sched_remove_client(struct vcd_sched_clnt_ctx *sched_cctxt) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_clnt_ctxt *cctxt; - if (!sched_cctxt) { - VCD_MSG_ERROR("%s(): Invalid handle ptr", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else if (!list_empty(&sched_cctxt->ip_frm_list)) { - VCD_MSG_ERROR( - "%s(): Cannot remove client, queue no empty", __func__); - rc = VCD_ERR_ILLEGAL_OP; - } else { - cctxt = sched_cctxt->clnt_data; - list_del(&sched_cctxt->list); - memset(sched_cctxt, 0, - sizeof(struct vcd_sched_clnt_ctx)); - kfree(sched_cctxt); - } - return rc; -} - -u32 vcd_sched_update_config(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - if (!cctxt || !cctxt->sched_clnt_hdl) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else { - cctxt->sched_clnt_hdl->rounds /= - cctxt->sched_clnt_hdl->round_perfrm; - cctxt->sched_clnt_hdl->round_perfrm = - NORMALIZATION_FACTOR * - cctxt->frm_rate.fps_denominator / - cctxt->frm_rate.fps_numerator; - cctxt->sched_clnt_hdl->rounds *= - cctxt->sched_clnt_hdl->round_perfrm; - } - return rc; -} - -u32 vcd_sched_queue_buffer( - struct vcd_sched_clnt_ctx *sched_cctxt, - struct vcd_buffer_entry *buffer, u32 tail) -{ - u32 rc = VCD_S_SUCCESS; - if (!sched_cctxt || !buffer) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else if (tail) - list_add_tail(&buffer->sched_list, - &sched_cctxt->ip_frm_list); - else - list_add(&buffer->sched_list, &sched_cctxt->ip_frm_list); - return rc; -} - -u32 vcd_sched_dequeue_buffer( - struct vcd_sched_clnt_ctx *sched_cctxt, - struct vcd_buffer_entry **buffer) -{ - u32 rc = VCD_ERR_QEMPTY; - if (!sched_cctxt || !buffer) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else { - *buffer = NULL; - if (!list_empty(&sched_cctxt->ip_frm_list)) { - *buffer = list_first_entry( - &sched_cctxt->ip_frm_list, - struct vcd_buffer_entry, - sched_list); - list_del(&(*buffer)->sched_list); - rc = VCD_S_SUCCESS; - } - } - return rc; -} - -u32 vcd_sched_mark_client_eof(struct vcd_sched_clnt_ctx *sched_cctxt) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_entry *buffer = NULL; - if (!sched_cctxt) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else if (!list_empty(&sched_cctxt->ip_frm_list)) { - buffer = list_entry(sched_cctxt->ip_frm_list.prev, - struct vcd_buffer_entry, sched_list); - buffer->frame.flags |= VCD_FRAME_FLAG_EOS; - } else - rc = VCD_ERR_QEMPTY; - return rc; -} - -u32 vcd_sched_suspend_resume_clnt( - struct vcd_clnt_ctxt *cctxt, u32 state) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_sched_clnt_ctx *sched_cctxt; - if (!cctxt || !cctxt->sched_clnt_hdl) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else { - sched_cctxt = cctxt->sched_clnt_hdl; - if (state != sched_cctxt->clnt_active) { - sched_cctxt->clnt_active = state; - if (state) - insert_client_in_list(&cctxt->dev_ctxt->\ - sched_clnt_list, sched_cctxt, false); - else - list_del_init(&sched_cctxt->list); - } - } - return rc; -} - -u32 vcd_sched_get_client_frame(struct list_head *sched_clnt_list, - struct vcd_clnt_ctxt **cctxt, - struct vcd_buffer_entry **buffer) -{ - u32 rc = VCD_ERR_QEMPTY, round_adjustment = 0; - struct vcd_sched_clnt_ctx *sched_clnt, *clnt_nxt; - if (!sched_clnt_list || !cctxt || !buffer) { - VCD_MSG_ERROR("%s(): Invalid parameter", __func__); - rc = VCD_ERR_ILLEGAL_PARM; - } else if (!list_empty(sched_clnt_list)) { - *cctxt = NULL; - *buffer = NULL; - list_for_each_entry_safe(sched_clnt, - clnt_nxt, sched_clnt_list, list) { - if (&sched_clnt->list == sched_clnt_list->next) - round_adjustment = sched_clnt->rounds; - if (*cctxt) { - if ((*cctxt)->sched_clnt_hdl->rounds >= - sched_clnt->rounds) - list_move(&(*cctxt)->sched_clnt_hdl\ - ->list, &sched_clnt->list); - ADJUST_CLIENT_ROUNDS(sched_clnt, - round_adjustment); - } else if (sched_clnt->tkns && - !list_empty(&sched_clnt->ip_frm_list)) { - *cctxt = sched_clnt->clnt_data; - sched_clnt->rounds += sched_clnt->round_perfrm; - } else - ADJUST_CLIENT_ROUNDS(sched_clnt, - round_adjustment); - } - if (*cctxt) { - rc = vcd_sched_dequeue_buffer( - (*cctxt)->sched_clnt_hdl, buffer); - if (rc == VCD_S_SUCCESS) { - (*cctxt)->sched_clnt_hdl->tkns--; - ADJUST_CLIENT_ROUNDS((*cctxt)->\ - sched_clnt_hdl, round_adjustment); - } - } - } - return rc; -} diff --git a/drivers/video/msm/vidc/common/vcd/vcd_sub.c b/drivers/video/msm/vidc/common/vcd/vcd_sub.c deleted file mode 100644 index 27aa675b85778e26ae15ee0516e7f76df4d4e1ee..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_sub.c +++ /dev/null @@ -1,3496 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include "vcd.h" -#include "vdec_internal.h" - -#define MAX(x, y) (((x) > (y)) ? (x) : (y)) -#define MAP_TABLE_SZ 64 -#define VCD_ENC_MAX_OUTBFRS_PER_FRAME 8 -#define MAX_DEC_TIME 33 - -struct vcd_msm_map_buffer { - phys_addr_t phy_addr; - void *vaddr; - struct ion_handle *alloc_handle; - u32 in_use; -}; -static struct vcd_msm_map_buffer msm_mapped_buffer_table[MAP_TABLE_SZ]; - -static int vcd_pmem_alloc(size_t sz, u8 **kernel_vaddr, u8 **phy_addr, - struct vcd_clnt_ctxt *cctxt) -{ - u32 memtype, i = 0; - struct vcd_msm_map_buffer *map_buffer = NULL; - unsigned long iova = 0; - unsigned long buffer_size = 0; - int ret = 0; - unsigned long ionflag = 0; - ion_phys_addr_t phyaddr = 0; - size_t len = 0; - - if (!kernel_vaddr || !phy_addr || !cctxt) { - pr_err("\n%s: Invalid parameters", __func__); - goto bailout; - } - *phy_addr = NULL; - *kernel_vaddr = NULL; - for (i = 0; i < MAP_TABLE_SZ; i++) { - if (!msm_mapped_buffer_table[i].in_use) { - map_buffer = &msm_mapped_buffer_table[i]; - map_buffer->in_use = 1; - break; - } - } - if (!map_buffer) { - pr_err("%s() map table is full", __func__); - goto bailout; - } - res_trk_set_mem_type(DDL_MM_MEM); - memtype = res_trk_get_mem_type(); - if (!cctxt->vcd_enable_ion) { - pr_err("ION must be enabled\n"); - goto free_map_table; - } else { - map_buffer->alloc_handle = ion_alloc( - cctxt->vcd_ion_client, sz, SZ_4K, - memtype, res_trk_get_ion_flags()); - if (IS_ERR_OR_NULL(map_buffer->alloc_handle)) { - pr_err("%s() ION alloc failed", __func__); - goto bailout; - } - if (ion_handle_get_flags(cctxt->vcd_ion_client, - map_buffer->alloc_handle, - &ionflag)) { - pr_err("%s() ION get flag failed", __func__); - goto bailout; - } - *kernel_vaddr = (u8 *) ion_map_kernel( - cctxt->vcd_ion_client, - map_buffer->alloc_handle); - map_buffer->vaddr = *kernel_vaddr; - if (!(*kernel_vaddr)) { - pr_err("%s() ION map failed", __func__); - goto ion_free_bailout; - } - if (res_trk_get_core_type() != (u32)VCD_CORE_720P) { - ret = ion_map_iommu(cctxt->vcd_ion_client, - map_buffer->alloc_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL, - SZ_4K, - 0, - (dma_addr_t *)&iova, - (unsigned long *)&buffer_size, - 0, 0); - if (ret || !iova) { - pr_err( - "%s() ION iommu map failed, ret = %d, iova = 0x%lx", - __func__, ret, iova); - goto ion_map_bailout; - } - map_buffer->phy_addr = iova; - } else { - ret = ion_phys(cctxt->vcd_ion_client, - map_buffer->alloc_handle, - &phyaddr, - &len); - if (ret) { - pr_err("%s() ion_phys failed", __func__); - goto ion_map_bailout; - } - map_buffer->phy_addr = phyaddr; - } - if (!map_buffer->phy_addr) { - pr_err("%s() acm alloc failed", __func__); - goto free_map_table; - } - *phy_addr = (u8 *)map_buffer->phy_addr; - VCD_MSG_LOW("vcd_ion_alloc: phys(0x%x), virt(0x%x), "\ - "sz(%u), ionflags(0x%x)", (u32)*phy_addr, - (u32)*kernel_vaddr, sz, (u32)ionflag); - } - - return 0; - -ion_map_bailout: - ion_unmap_kernel(cctxt->vcd_ion_client, map_buffer->alloc_handle); -ion_free_bailout: - ion_free(cctxt->vcd_ion_client, map_buffer->alloc_handle); -free_map_table: - map_buffer->in_use = 0; -bailout: - return -ENOMEM; -} - -static int vcd_pmem_free(u8 *kernel_vaddr, u8 *phy_addr, - struct vcd_clnt_ctxt *cctxt) -{ - u32 i = 0; - struct vcd_msm_map_buffer *map_buffer = NULL; - - if (!kernel_vaddr || !phy_addr || !cctxt) { - pr_err("\n%s: Invalid parameters", __func__); - goto bailout; - } - for (i = 0; i < MAP_TABLE_SZ; i++) { - if (msm_mapped_buffer_table[i].in_use && - (msm_mapped_buffer_table[i].vaddr == kernel_vaddr)) { - map_buffer = &msm_mapped_buffer_table[i]; - map_buffer->in_use = 0; - break; - } - } - if (!map_buffer) { - pr_err("%s() Entry not found", __func__); - goto bailout; - } - if (cctxt->vcd_enable_ion) { - VCD_MSG_LOW("vcd_ion_free: phys(0x%x), virt(0x%x)", - (u32)phy_addr, (u32)kernel_vaddr); - if (map_buffer->alloc_handle) { - ion_unmap_kernel(cctxt->vcd_ion_client, - map_buffer->alloc_handle); - if (res_trk_get_core_type() != (u32)VCD_CORE_720P) - ion_unmap_iommu(cctxt->vcd_ion_client, - map_buffer->alloc_handle, - VIDEO_DOMAIN, - VIDEO_MAIN_POOL); - ion_free(cctxt->vcd_ion_client, - map_buffer->alloc_handle); - } - } else { - VCD_MSG_LOW("vcd_pmem_free: phys(0x%x), virt(0x%x)", - (u32)phy_addr, (u32)kernel_vaddr); - free_contiguous_memory_by_paddr( - (unsigned long)map_buffer->phy_addr); - } -bailout: - kernel_vaddr = NULL; - phy_addr = NULL; - return 0; -} - - -u8 *vcd_pmem_get_physical(struct video_client_ctx *client_ctx, - unsigned long kernel_vaddr) -{ - unsigned long phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_INPUT, - false, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index)) { - - return (u8 *) phy_addr; - } else if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - false, &user_vaddr, &kernel_vaddr, &phy_addr, &pmem_fd, &file, - &buffer_index)) { - return (u8 *) phy_addr; - } else { - VCD_MSG_ERROR("Couldn't get physical address"); - - return NULL; - } - -} - -u32 vcd_get_ion_flag(struct video_client_ctx *client_ctx, - unsigned long kernel_vaddr, - struct ion_handle **buff_ion_handle) -{ - unsigned long phy_addr, user_vaddr; - int pmem_fd; - struct file *file; - s32 buffer_index = -1; - u32 ion_flag = 0; - struct ion_handle *buff_handle = NULL; - - if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_INPUT, - false, &user_vaddr, &kernel_vaddr, - &phy_addr, &pmem_fd, &file, - &buffer_index)) { - - ion_flag = vidc_get_fd_info(client_ctx, BUFFER_TYPE_INPUT, - pmem_fd, kernel_vaddr, buffer_index, - &buff_handle); - *buff_ion_handle = buff_handle; - return ion_flag; - } else if (vidc_lookup_addr_table(client_ctx, BUFFER_TYPE_OUTPUT, - false, &user_vaddr, &kernel_vaddr, &phy_addr, &pmem_fd, &file, - &buffer_index)) { - ion_flag = vidc_get_fd_info(client_ctx, BUFFER_TYPE_OUTPUT, - pmem_fd, kernel_vaddr, buffer_index, - &buff_handle); - *buff_ion_handle = buff_handle; - return ion_flag; - } else { - VCD_MSG_ERROR("Couldn't get ion flag"); - return 0; - } - -} - -void vcd_reset_device_channels(struct vcd_dev_ctxt *dev_ctxt) -{ - dev_ctxt->ddl_frame_ch_free = dev_ctxt->ddl_frame_ch_depth; - dev_ctxt->ddl_cmd_ch_free = dev_ctxt->ddl_cmd_ch_depth; - dev_ctxt->ddl_frame_ch_interim = 0; - dev_ctxt->ddl_cmd_ch_interim = 0; -} - -u32 vcd_get_command_channel( - struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc **transc) -{ - u32 result = false; - - *transc = NULL; - - if (dev_ctxt->ddl_cmd_ch_free > 0) { - if (dev_ctxt->ddl_cmd_concurrency) { - --dev_ctxt->ddl_cmd_ch_free; - result = true; - } else if ((dev_ctxt->ddl_frame_ch_free + - dev_ctxt->ddl_frame_ch_interim) - == dev_ctxt->ddl_frame_ch_depth) { - --dev_ctxt->ddl_cmd_ch_free; - result = true; - } - } - - if (result) { - *transc = vcd_get_free_trans_tbl_entry(dev_ctxt); - - if (!*transc) { - result = false; - - vcd_release_command_channel(dev_ctxt, *transc); - } - - } - return result; -} - -u32 vcd_get_command_channel_in_loop( - struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc **transc) -{ - u32 result = false; - - *transc = NULL; - - if (dev_ctxt->ddl_cmd_ch_interim > 0) { - if (dev_ctxt->ddl_cmd_concurrency) { - --dev_ctxt->ddl_cmd_ch_interim; - result = true; - } else if ((dev_ctxt->ddl_frame_ch_free + - dev_ctxt->ddl_frame_ch_interim) - == dev_ctxt->ddl_frame_ch_depth) { - --dev_ctxt->ddl_cmd_ch_interim; - result = true; - } - } else { - result = vcd_get_command_channel(dev_ctxt, transc); - } - - if (result && !*transc) { - *transc = vcd_get_free_trans_tbl_entry(dev_ctxt); - - if (!*transc) { - result = false; - - ++dev_ctxt->ddl_cmd_ch_interim; - } - - } - - return result; -} - -void vcd_mark_command_channel(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc *transc) -{ - ++dev_ctxt->ddl_cmd_ch_interim; - - vcd_release_trans_tbl_entry(transc); - if (dev_ctxt->ddl_cmd_ch_interim + - dev_ctxt->ddl_cmd_ch_free > - dev_ctxt->ddl_cmd_ch_depth) { - VCD_MSG_ERROR("\n Command channel access counters messed up"); - } -} - -void vcd_release_command_channel( - struct vcd_dev_ctxt *dev_ctxt, struct vcd_transc *transc) -{ - ++dev_ctxt->ddl_cmd_ch_free; - - vcd_release_trans_tbl_entry(transc); - if (dev_ctxt->ddl_cmd_ch_interim + dev_ctxt->ddl_cmd_ch_free > - dev_ctxt->ddl_cmd_ch_depth) { - VCD_MSG_ERROR("\n Command channel access counters messed up"); - } -} - -void vcd_release_multiple_command_channels(struct vcd_dev_ctxt - *dev_ctxt, u32 channels) -{ - dev_ctxt->ddl_cmd_ch_free += channels; - - if (dev_ctxt->ddl_cmd_ch_interim + - dev_ctxt->ddl_cmd_ch_free > - dev_ctxt->ddl_cmd_ch_depth) { - VCD_MSG_ERROR("\n Command channel access counters messed up"); - } -} - -void vcd_release_interim_command_channels(struct vcd_dev_ctxt *dev_ctxt) -{ - dev_ctxt->ddl_cmd_ch_free += dev_ctxt->ddl_cmd_ch_interim; - dev_ctxt->ddl_cmd_ch_interim = 0; - - if (dev_ctxt->ddl_cmd_ch_interim + dev_ctxt->ddl_cmd_ch_free > - dev_ctxt->ddl_cmd_ch_depth) { - VCD_MSG_ERROR("\n Command channel access counters messed up"); - } -} - -u32 vcd_get_frame_channel(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc **transc) -{ - u32 result = false; - - if (dev_ctxt->ddl_frame_ch_free > 0) { - if (dev_ctxt->ddl_cmd_concurrency) { - --dev_ctxt->ddl_frame_ch_free; - result = true; - } else if ((dev_ctxt->ddl_cmd_ch_free + - dev_ctxt->ddl_cmd_ch_interim) - == dev_ctxt->ddl_cmd_ch_depth) { - --dev_ctxt->ddl_frame_ch_free; - result = true; - } - } - - if (result) { - *transc = vcd_get_free_trans_tbl_entry(dev_ctxt); - - if (!*transc) { - result = false; - - vcd_release_frame_channel(dev_ctxt, *transc); - } else { - (*transc)->type = VCD_CMD_CODE_FRAME; - } - - } - - return result; -} - -u32 vcd_get_frame_channel_in_loop( - struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc **transc) -{ - u32 result = false; - - *transc = NULL; - - if (dev_ctxt->ddl_frame_ch_interim > 0) { - if (dev_ctxt->ddl_cmd_concurrency) { - --dev_ctxt->ddl_frame_ch_interim; - result = true; - } else if ((dev_ctxt->ddl_cmd_ch_free + - dev_ctxt->ddl_cmd_ch_interim) - == dev_ctxt->ddl_cmd_ch_depth) { - --dev_ctxt->ddl_frame_ch_interim; - result = true; - } - } else { - result = vcd_get_frame_channel(dev_ctxt, transc); - } - - if (result && !*transc) { - *transc = vcd_get_free_trans_tbl_entry(dev_ctxt); - - if (!*transc) { - result = false; - VCD_MSG_FATAL("\n%s: All transactions are busy;" - "Couldnt find free one\n", __func__); - ++dev_ctxt->ddl_frame_ch_interim; - } else - (*transc)->type = VCD_CMD_CODE_FRAME; - } - - return result; -} - -void vcd_mark_frame_channel(struct vcd_dev_ctxt *dev_ctxt) -{ - ++dev_ctxt->ddl_frame_ch_interim; - - if (dev_ctxt->ddl_frame_ch_interim + - dev_ctxt->ddl_frame_ch_free > - dev_ctxt->ddl_cmd_ch_depth) { - VCD_MSG_FATAL("Frame channel access counters messed up"); - } -} - -void vcd_release_frame_channel(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc *transc) -{ - ++dev_ctxt->ddl_frame_ch_free; - - vcd_release_trans_tbl_entry(transc); - - if (dev_ctxt->ddl_frame_ch_interim + - dev_ctxt->ddl_frame_ch_free > - dev_ctxt->ddl_cmd_ch_depth) { - VCD_MSG_FATAL("Frame channel access counters messed up"); - } -} - -void vcd_release_multiple_frame_channels(struct vcd_dev_ctxt - *dev_ctxt, u32 channels) -{ - dev_ctxt->ddl_frame_ch_free += channels; - - if (dev_ctxt->ddl_frame_ch_interim + - dev_ctxt->ddl_frame_ch_free > - dev_ctxt->ddl_frame_ch_depth) { - VCD_MSG_FATAL("Frame channel access counters messed up"); - } -} - -void vcd_release_interim_frame_channels(struct vcd_dev_ctxt - *dev_ctxt) -{ - dev_ctxt->ddl_frame_ch_free += - dev_ctxt->ddl_frame_ch_interim; - dev_ctxt->ddl_frame_ch_interim = 0; - - if (dev_ctxt->ddl_frame_ch_free > - dev_ctxt->ddl_cmd_ch_depth) { - VCD_MSG_FATAL("Frame channel access counters messed up"); - } -} - -u32 vcd_core_is_busy(struct vcd_dev_ctxt *dev_ctxt) -{ - if (((dev_ctxt->ddl_cmd_ch_free + - dev_ctxt->ddl_cmd_ch_interim) != - dev_ctxt->ddl_cmd_ch_depth) - || - ((dev_ctxt->ddl_frame_ch_free + - dev_ctxt->ddl_frame_ch_interim) != - dev_ctxt->ddl_frame_ch_depth) - ) { - return true; - } else { - return false; - } -} - -void vcd_device_timer_start(struct vcd_dev_ctxt *dev_ctxt) -{ - if (dev_ctxt->config.timer_start) - dev_ctxt->config.timer_start(dev_ctxt->hw_timer_handle, - dev_ctxt->hw_time_out); -} - -void vcd_device_timer_stop(struct vcd_dev_ctxt *dev_ctxt) -{ - if (dev_ctxt->config.timer_stop) - dev_ctxt->config.timer_stop(dev_ctxt->hw_timer_handle); -} - - -u32 vcd_common_allocate_set_buffer( - struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer, - u32 buf_size, struct vcd_buffer_pool **buffer_pool) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_requirement Buf_req; - struct vcd_property_hdr Prop_hdr; - struct vcd_buffer_pool *buf_pool; - - if (buffer == VCD_BUFFER_INPUT) { - Prop_hdr.prop_id = DDL_I_INPUT_BUF_REQ; - buf_pool = &cctxt->in_buf_pool; - } else if (buffer == VCD_BUFFER_OUTPUT) { - Prop_hdr.prop_id = DDL_I_OUTPUT_BUF_REQ; - buf_pool = &cctxt->out_buf_pool; - } else { - rc = VCD_ERR_ILLEGAL_PARM; - } - VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); - - *buffer_pool = buf_pool; - - if (buf_pool->count > 0 && - buf_pool->validated == buf_pool->count) { - VCD_MSG_ERROR("Buffer pool is full"); - return VCD_ERR_FAIL; - } - - if (!buf_pool->entries) { - Prop_hdr.sz = sizeof(Buf_req); - rc = ddl_get_property(cctxt->ddl_handle, &Prop_hdr, &Buf_req); - if (!VCD_FAILED(rc)) { - rc = vcd_alloc_buffer_pool_entries(buf_pool, - &Buf_req); - } else { - VCD_MSG_ERROR("rc = 0x%x. Failed: ddl_get_property", - rc); - } - } - - if (!VCD_FAILED(rc)) { - if (buf_pool->buf_req.sz > buf_size) { - VCD_MSG_ERROR("\n required buffer sz %u " - "allocated sz %u", buf_pool->buf_req. - sz, buf_size); - - rc = VCD_ERR_ILLEGAL_PARM; - } - } - - return rc; -} - -u32 vcd_set_buffer_internal( - struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool, u8 *buffer, u32 buf_size) -{ - struct vcd_buffer_entry *buf_entry; - u8 *physical; - u32 ion_flag = 0; - struct ion_handle *buff_handle = NULL; - - buf_entry = vcd_find_buffer_pool_entry(buf_pool, buffer); - if (buf_entry) { - VCD_MSG_ERROR("This buffer address already exists"); - - return VCD_ERR_ILLEGAL_OP; - } - - physical = (u8 *) vcd_pmem_get_physical( - cctxt->client_data, (unsigned long)buffer); - - ion_flag = vcd_get_ion_flag(cctxt->client_data, - (unsigned long)buffer, - &buff_handle); - if (!physical) { - VCD_MSG_ERROR("Couldn't get physical address"); - return VCD_ERR_BAD_POINTER; - } - if (((u32) physical % buf_pool->buf_req.align)) { - VCD_MSG_ERROR("Physical addr is not aligned"); - return VCD_ERR_BAD_POINTER; - } - - buf_entry = vcd_get_free_buffer_pool_entry(buf_pool); - if (!buf_entry) { - VCD_MSG_ERROR("Can't allocate buffer pool is full"); - return VCD_ERR_FAIL; - } - buf_entry->virtual = buffer; - buf_entry->physical = physical; - buf_entry->sz = buf_size; - buf_entry->frame.alloc_len = buf_size; - buf_entry->allocated = false; - - buf_entry->frame.virtual = buf_entry->virtual; - buf_entry->frame.physical = buf_entry->physical; - buf_entry->frame.ion_flag = ion_flag; - buf_entry->frame.buff_ion_handle = buff_handle; - - buf_pool->validated++; - - return VCD_S_SUCCESS; - -} - -u32 vcd_allocate_buffer_internal( - struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool, - u32 buf_size, u8 **vir_buf_addr, u8 **phy_buf_addr) -{ - struct vcd_buffer_entry *buf_entry; - struct vcd_buffer_requirement *buf_req; - u32 addr; - int rc = 0; - - buf_entry = vcd_get_free_buffer_pool_entry(buf_pool); - if (!buf_entry) { - VCD_MSG_ERROR("Can't allocate buffer pool is full"); - - return VCD_ERR_FAIL; - } - - buf_req = &buf_pool->buf_req; - - buf_size += buf_req->align; - - rc = vcd_pmem_alloc(buf_size, &buf_entry->alloc, - &buf_entry->physical, cctxt); - - if (rc < 0) { - VCD_MSG_ERROR("Buffer allocation failed"); - - return VCD_ERR_ALLOC_FAIL; - } - - buf_entry->sz = buf_size; - buf_entry->frame.alloc_len = buf_size; - - if (!buf_entry->physical) { - VCD_MSG_ERROR("Couldn't get physical address"); - - return VCD_ERR_BAD_POINTER; - } - - buf_entry->allocated = true; - - if (buf_req->align > 0) { - - addr = (u32) buf_entry->physical; - addr += buf_req->align; - addr -= (addr % buf_req->align); - buf_entry->virtual = buf_entry->alloc; - buf_entry->virtual += (u32) (addr - (u32) - buf_entry->physical); - buf_entry->physical = (u8 *) addr; - } else { - VCD_MSG_LOW("No buffer alignment required"); - - buf_entry->virtual = buf_entry->alloc; - - } - - buf_entry->frame.virtual = buf_entry->virtual; - buf_entry->frame.physical = buf_entry->physical; - - *vir_buf_addr = buf_entry->virtual; - *phy_buf_addr = buf_entry->physical; - - buf_pool->allocated++; - buf_pool->validated++; - - return VCD_S_SUCCESS; -} - -u32 vcd_free_one_buffer_internal( - struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer_type, u8 *buffer) -{ - struct vcd_buffer_pool *buf_pool; - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_entry *buf_entry; - u32 first_frm_recvd = 0; - - if (buffer_type == VCD_BUFFER_INPUT) { - buf_pool = &cctxt->in_buf_pool; - first_frm_recvd = VCD_FIRST_IP_RCVD; - } else if (buffer_type == VCD_BUFFER_OUTPUT) { - buf_pool = &cctxt->out_buf_pool; - first_frm_recvd = VCD_FIRST_OP_RCVD; - } else - rc = VCD_ERR_ILLEGAL_PARM; - - VCD_FAILED_RETURN(rc, "Invalid buffer type provided"); - - first_frm_recvd &= cctxt->status.mask; - if (first_frm_recvd && !cctxt->meta_mode) { - VCD_MSG_ERROR( - "VCD free buffer called when data path is active"); - return VCD_ERR_BAD_STATE; - } - - buf_entry = vcd_find_buffer_pool_entry(buf_pool, buffer); - if (!buf_entry) { - VCD_MSG_ERROR("Buffer addr %p not found. Can't free buffer", - buffer); - - return VCD_ERR_ILLEGAL_PARM; - } - if (buf_entry->in_use) { - VCD_MSG_ERROR("Buffer is in use and is not flushed: %p, %d\n", - buf_entry, buf_entry->in_use); - return VCD_ERR_ILLEGAL_OP; - } - - VCD_MSG_LOW("Freeing buffer %p. Allocated %d", - buf_entry->virtual, buf_entry->allocated); - - if (buf_entry->allocated) { - vcd_pmem_free(buf_entry->alloc, buf_entry->physical, cctxt); - buf_pool->allocated--; - } - - buf_entry->valid = buf_entry->allocated = buf_entry->in_use = 0; - buf_entry->alloc = buf_entry->virtual = buf_entry->physical = NULL; - buf_entry->sz = 0; - memset(&buf_entry->frame, 0, sizeof(struct vcd_frame_data)); - - buf_pool->validated--; - if (buf_pool->validated == 0) - vcd_free_buffer_pool_entries(buf_pool); - - return VCD_S_SUCCESS; -} - -u32 vcd_free_buffers_internal( - struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool) -{ - u32 rc = VCD_S_SUCCESS; - u32 i; - - VCD_MSG_LOW("vcd_free_buffers_internal:"); - - if (buf_pool->entries) { - for (i = 1; i <= buf_pool->count; i++) { - if (buf_pool->entries[i].valid && - buf_pool->entries[i].allocated) { - vcd_pmem_free(buf_pool->entries[i].alloc, - buf_pool->entries[i]. - physical, cctxt); - } - } - - } - - vcd_reset_buffer_pool_for_reuse(buf_pool); - - return rc; -} - -u32 vcd_alloc_buffer_pool_entries( - struct vcd_buffer_pool *buf_pool, - struct vcd_buffer_requirement *buf_req) -{ - - VCD_MSG_LOW("vcd_alloc_buffer_pool_entries:"); - - buf_pool->buf_req = *buf_req; - - buf_pool->count = buf_req->actual_count; - buf_pool->entries = (struct vcd_buffer_entry *) - kzalloc((sizeof(struct vcd_buffer_entry) * - (VCD_MAX_BUFFER_ENTRIES + 1)), GFP_KERNEL); - - if (!buf_pool->entries) { - VCD_MSG_ERROR("Buf_pool entries alloc failed"); - return VCD_ERR_ALLOC_FAIL; - } - - INIT_LIST_HEAD(&buf_pool->queue); - buf_pool->entries[0].valid = true; - buf_pool->q_len = 0; - - buf_pool->validated = 0; - buf_pool->allocated = 0; - buf_pool->in_use = 0; - - return VCD_S_SUCCESS; -} - -void vcd_free_buffer_pool_entries(struct vcd_buffer_pool *buf_pool) -{ - VCD_MSG_LOW("vcd_free_buffer_pool_entries:"); - kfree(buf_pool->entries); - memset(buf_pool, 0, sizeof(struct vcd_buffer_pool)); - INIT_LIST_HEAD(&buf_pool->queue); -} - -void vcd_flush_in_use_buffer_pool_entries(struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_pool *buf_pool, u32 event) -{ - u32 i; - VCD_MSG_LOW("vcd_flush_buffer_pool_entries: event=0x%x", event); - - if (buf_pool->entries) { - for (i = 0; i <= buf_pool->count; i++) { - if (buf_pool->entries[i].virtual && - buf_pool->entries[i].in_use) { - cctxt->callback(event, VCD_S_SUCCESS, - &buf_pool->entries[i].frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - buf_pool->entries[i].in_use = false; - VCD_BUFFERPOOL_INUSE_DECREMENT( - buf_pool->in_use); - } - } - } -} - - -void vcd_reset_buffer_pool_for_reuse(struct vcd_buffer_pool *buf_pool) -{ - VCD_MSG_LOW("vcd_reset_buffer_pool_for_reuse:"); - - if (buf_pool->entries) { - memset(&buf_pool->entries[1], 0, - sizeof(struct vcd_buffer_entry) * - VCD_MAX_BUFFER_ENTRIES); - } - buf_pool->q_len = 0; - - buf_pool->validated = 0; - buf_pool->allocated = 0; - buf_pool->in_use = 0; - INIT_LIST_HEAD(&buf_pool->queue); -} - -struct vcd_buffer_entry *vcd_get_free_buffer_pool_entry - (struct vcd_buffer_pool *pool) { - u32 i; - - i = 1; - while (i <= pool->count && pool->entries[i].valid) - i++; - - - if (i <= pool->count) { - pool->entries[i].valid = true; - - return &pool->entries[i]; - } else { - return NULL; - } -} - -struct vcd_buffer_entry *vcd_find_buffer_pool_entry - (struct vcd_buffer_pool *pool, u8 *addr) -{ - u32 i; - u32 found = false; - - for (i = 1; i <= pool->count && !found; i++) { - if (pool->entries[i].virtual == addr) - found = true; - - } - - if (found) - return &pool->entries[i - 1]; - else - return NULL; - -} - -u32 vcd_buffer_pool_entry_en_q( - struct vcd_buffer_pool *pool, - struct vcd_buffer_entry *entry) -{ - struct vcd_buffer_entry *list_itr; - - if (pool->q_len == pool->count) - return false; - - list_for_each_entry(list_itr, &pool->queue, list) - if (list_itr == entry) { - VCD_MSG_HIGH("\n this output buffer is already present" - " in queue"); - VCD_MSG_HIGH("\n Vir Addr %p Phys Addr %p", - entry->virtual, entry->physical); - return false; - } - - list_add_tail(&entry->list, &pool->queue); - pool->q_len++; - - return true; -} - -struct vcd_buffer_entry *vcd_buffer_pool_entry_de_q - (struct vcd_buffer_pool *pool) { - struct vcd_buffer_entry *entry; - - if (!pool || !pool->q_len) - return NULL; - - entry = list_first_entry(&pool->queue, - struct vcd_buffer_entry, list); - - if (entry) { - list_del(&entry->list); - pool->q_len--; - } - return entry; -} - -void vcd_flush_bframe_buffers(struct vcd_clnt_ctxt *cctxt, u32 mode) -{ - int i; - struct vcd_buffer_pool *buf_pool; - - if (!cctxt->decoding && cctxt->bframe) { - buf_pool = (mode == VCD_FLUSH_INPUT) ? - &cctxt->in_buf_pool : &cctxt->out_buf_pool; - if (buf_pool->entries != NULL) { - for (i = 1; i <= buf_pool->count; i++) { - if ((buf_pool->entries[i].in_use) && - (buf_pool->entries[i].frame.virtual - != NULL)) { - if (mode == VCD_FLUSH_INPUT) { - cctxt->callback( - VCD_EVT_RESP_INPUT_FLUSHED, - VCD_S_SUCCESS, - &(buf_pool->entries[i].frame), - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - } else { - buf_pool->entries[i]. - frame.data_len = 0; - cctxt->callback( - VCD_EVT_RESP_OUTPUT_FLUSHED, - VCD_S_SUCCESS, - &(buf_pool->entries[i].frame), - sizeof(struct vcd_frame_data), - cctxt, - cctxt->client_data); - } - VCD_BUFFERPOOL_INUSE_DECREMENT( - buf_pool->in_use); - buf_pool->entries[i].in_use = false; - } - } - } - } -} - -void vcd_flush_output_buffers(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_buffer_pool *buf_pool; - struct vcd_buffer_entry *buf_entry; - u32 count = 0; - struct vcd_property_hdr prop_hdr; - - VCD_MSG_LOW("vcd_flush_output_buffers:"); - buf_pool = &cctxt->out_buf_pool; - buf_entry = vcd_buffer_pool_entry_de_q(buf_pool); - while (buf_entry) { - if (!cctxt->decoding || buf_entry->in_use) { - buf_entry->frame.data_len = 0; - cctxt->callback(VCD_EVT_RESP_OUTPUT_FLUSHED, - VCD_S_SUCCESS, - &buf_entry->frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - if (buf_entry->in_use) { - VCD_BUFFERPOOL_INUSE_DECREMENT( - buf_pool->in_use); - buf_entry->in_use = false; - } - count++; - } - buf_entry = vcd_buffer_pool_entry_de_q(buf_pool); - } - vcd_flush_bframe_buffers(cctxt, VCD_FLUSH_OUTPUT); - if (buf_pool->in_use || buf_pool->q_len) { - VCD_MSG_ERROR("%s(): WARNING in_use(%u) or q_len(%u) not zero!", - __func__, buf_pool->in_use, buf_pool->q_len); - buf_pool->in_use = buf_pool->q_len = 0; - } - if (cctxt->sched_clnt_hdl) { - if (count > cctxt->sched_clnt_hdl->tkns) - cctxt->sched_clnt_hdl->tkns = 0; - else - cctxt->sched_clnt_hdl->tkns -= count; - } - - if (cctxt->ddl_hdl_valid && cctxt->decoding) { - prop_hdr.prop_id = DDL_I_REQ_OUTPUT_FLUSH; - prop_hdr.sz = sizeof(u32); - count = 0x1; - - (void)ddl_set_property(cctxt->ddl_handle, &prop_hdr, - &count); - } - vcd_release_all_clnt_frm_transc(cctxt); - cctxt->status.mask &= ~VCD_IN_RECONFIG; -} - -u32 vcd_flush_buffers(struct vcd_clnt_ctxt *cctxt, u32 mode) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_entry *buf_entry; - struct vcd_buffer_entry *orig_frame = NULL; - - VCD_MSG_LOW("vcd_flush_buffers:"); - - if (mode > VCD_FLUSH_ALL || !(mode & VCD_FLUSH_ALL)) { - VCD_MSG_ERROR("Invalid flush mode %d", mode); - return VCD_ERR_ILLEGAL_PARM; - } - - VCD_MSG_MED("Flush mode %d requested", mode); - if ((mode & VCD_FLUSH_INPUT) && - cctxt->sched_clnt_hdl) { - - rc = vcd_sched_dequeue_buffer( - cctxt->sched_clnt_hdl, &buf_entry); - while (!VCD_FAILED(rc) && buf_entry) { - if (buf_entry->virtual) { - cctxt->callback(VCD_EVT_RESP_INPUT_FLUSHED, - VCD_S_SUCCESS, - &buf_entry->frame, - sizeof(struct - vcd_frame_data), - cctxt, - cctxt->client_data); - orig_frame = vcd_find_buffer_pool_entry( - &cctxt->in_buf_pool, - buf_entry->virtual); - } - - if (orig_frame) { - orig_frame->in_use--; - if (orig_frame != buf_entry) - kfree(buf_entry); - } else { - buf_entry->in_use = false; - VCD_MSG_ERROR("Original frame not found in buffer pool\n"); - } - VCD_BUFFERPOOL_INUSE_DECREMENT( - cctxt->in_buf_pool.in_use); - buf_entry = NULL; - rc = vcd_sched_dequeue_buffer( - cctxt->sched_clnt_hdl, &buf_entry); - } - } - if (rc != VCD_ERR_QEMPTY) - VCD_FAILED_RETURN(rc, "Failed: vcd_sched_dequeue_buffer"); - if (cctxt->status.frame_submitted > 0) - cctxt->status.mask |= mode; - else { - if (mode & VCD_FLUSH_INPUT) - vcd_flush_bframe_buffers(cctxt, VCD_FLUSH_INPUT); - if (mode & VCD_FLUSH_OUTPUT) - vcd_flush_output_buffers(cctxt); - } - return VCD_S_SUCCESS; -} - -void vcd_flush_buffers_in_err_fatal(struct vcd_clnt_ctxt *cctxt) -{ - VCD_MSG_LOW("\n vcd_flush_buffers_in_err_fatal:"); - (void) vcd_flush_buffers(cctxt, VCD_FLUSH_ALL); - vcd_flush_in_use_buffer_pool_entries(cctxt, - &cctxt->in_buf_pool, VCD_EVT_RESP_INPUT_FLUSHED); - vcd_flush_in_use_buffer_pool_entries(cctxt, - &cctxt->out_buf_pool, VCD_EVT_RESP_OUTPUT_FLUSHED); - vcd_send_flush_done(cctxt, VCD_S_SUCCESS); -} - -u32 vcd_init_client_context(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc; - VCD_MSG_LOW("vcd_init_client_context:"); - rc = ddl_open(&cctxt->ddl_handle, cctxt->decoding); - VCD_FAILED_RETURN(rc, "Failed: ddl_open"); - cctxt->vcd_enable_ion = res_trk_get_enable_ion(); - if (cctxt->vcd_enable_ion) { - cctxt->vcd_ion_client = res_trk_get_ion_client(); - if (!cctxt->vcd_ion_client) { - VCD_MSG_LOW("vcd_init_ion_get_client_failed:"); - return -EINVAL; - } - } - cctxt->ddl_hdl_valid = true; - cctxt->clnt_state.state = VCD_CLIENT_STATE_OPEN; - cctxt->clnt_state.state_table = - vcd_get_client_state_table(VCD_CLIENT_STATE_OPEN); - cctxt->signature = VCD_SIGNATURE; - cctxt->live = true; - cctxt->bframe = 0; - cctxt->cmd_q.pending_cmd = VCD_CMD_NONE; - cctxt->status.last_evt = VCD_EVT_RESP_BASE; - cctxt->num_slices = 1; - return rc; -} - -void vcd_destroy_client_context(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_dev_ctxt *dev_ctxt; - struct vcd_clnt_ctxt *client; - struct vcd_buffer_entry *buf_entry; - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("vcd_destroy_client_context:"); - - dev_ctxt = cctxt->dev_ctxt; - - if (cctxt == dev_ctxt->cctxt_list_head) { - VCD_MSG_MED("Clnt list head clnt being removed"); - - dev_ctxt->cctxt_list_head = cctxt->next; - } else { - client = dev_ctxt->cctxt_list_head; - while (client && cctxt != client->next) - client = client->next; - if (client) - client->next = cctxt->next; - if (!client) { - rc = VCD_ERR_FAIL; - VCD_MSG_ERROR("Client not found in client list"); - } - } - - if (VCD_FAILED(rc)) - return; - - if (cctxt->sched_clnt_hdl) { - rc = VCD_S_SUCCESS; - while (!VCD_FAILED(rc)) { - rc = vcd_sched_dequeue_buffer( - cctxt->sched_clnt_hdl, &buf_entry); - if (rc != VCD_ERR_QEMPTY && VCD_FAILED(rc)) - VCD_MSG_ERROR("\n Failed: " - "vcd_sched_de_queue_buffer"); - } - rc = vcd_sched_remove_client(cctxt->sched_clnt_hdl); - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("\n Failed: sched_remove_client"); - cctxt->sched_clnt_hdl = NULL; - } - - if (cctxt->seq_hdr.sequence_header) { - vcd_pmem_free(cctxt->seq_hdr.sequence_header, - cctxt->seq_hdr_phy_addr, cctxt); - cctxt->seq_hdr.sequence_header = NULL; - } - - vcd_free_buffers_internal(cctxt, &cctxt->in_buf_pool); - vcd_free_buffers_internal(cctxt, &cctxt->out_buf_pool); - vcd_free_buffer_pool_entries(&cctxt->in_buf_pool); - vcd_free_buffer_pool_entries(&cctxt->out_buf_pool); - vcd_release_all_clnt_transc(cctxt); - - if (cctxt->ddl_hdl_valid) { - (void)ddl_close(&cctxt->ddl_handle); - cctxt->ddl_hdl_valid = false; - } - - cctxt->signature = 0; - cctxt->clnt_state.state = VCD_CLIENT_STATE_NULL; - cctxt->clnt_state.state_table = NULL; - cctxt->vcd_ion_client = NULL; - kfree(cctxt); -} - -u32 vcd_check_for_client_context( - struct vcd_dev_ctxt *dev_ctxt, s32 driver_id) -{ - struct vcd_clnt_ctxt *client; - - client = dev_ctxt->cctxt_list_head; - while (client && client->driver_id != driver_id) - client = client->next; - - if (!client) - return false; - else - return true; -} - -u32 vcd_validate_driver_handle( - struct vcd_dev_ctxt *dev_ctxt, s32 driver_handle) -{ - driver_handle--; - - if (driver_handle < 0 || - driver_handle >= VCD_DRIVER_CLIENTS_MAX || - !dev_ctxt->driver_ids[driver_handle]) { - return false; - } else { - return true; - } -} - -u32 vcd_client_cmd_en_q( - struct vcd_clnt_ctxt *cctxt, enum vcd_command command) -{ - u32 result; - - if (cctxt->cmd_q.pending_cmd == VCD_CMD_NONE) { - cctxt->cmd_q.pending_cmd = command; - result = true; - } else { - result = false; - } - - return result; -} - -void vcd_client_cmd_flush_and_en_q( - struct vcd_clnt_ctxt *cctxt, enum vcd_command command) -{ - cctxt->cmd_q.pending_cmd = command; -} - -u32 vcd_client_cmd_de_q(struct vcd_clnt_ctxt *cctxt, - enum vcd_command *command) -{ - if (cctxt->cmd_q.pending_cmd == VCD_CMD_NONE) - return false; - - *command = cctxt->cmd_q.pending_cmd; - cctxt->cmd_q.pending_cmd = VCD_CMD_NONE; - - return true; -} - -u32 vcd_get_next_queued_client_cmd(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt **cctxt, enum vcd_command *command) -{ - struct vcd_clnt_ctxt *client = dev_ctxt->cctxt_list_head; - u32 result = false; - - while (client && !result) { - *cctxt = client; - result = vcd_client_cmd_de_q(client, command); - client = client->next; - } - return result; -} - -u32 vcd_submit_cmd_sess_start(struct vcd_transc *transc) -{ - u32 rc; - struct vcd_sequence_hdr Seq_hdr; - - VCD_MSG_LOW("vcd_submit_cmd_sess_start:"); - - if (transc->cctxt->decoding) { - - if (transc->cctxt->seq_hdr.sequence_header) { - Seq_hdr.sequence_header_len = - transc->cctxt->seq_hdr. - sequence_header_len; - Seq_hdr.sequence_header = - transc->cctxt->seq_hdr_phy_addr; - - rc = ddl_decode_start(transc->cctxt->ddl_handle, - &Seq_hdr, (void *)transc); - } else { - rc = ddl_decode_start(transc->cctxt->ddl_handle, - NULL, (void *)transc); - } - - } else { - vcd_set_num_slices(transc->cctxt); - rc = ddl_encode_start(transc->cctxt->ddl_handle, - (void *)transc); - } - if (!VCD_FAILED(rc)) { - transc->cctxt->status.cmd_submitted++; - vcd_device_timer_start(transc->cctxt->dev_ctxt); - } else - VCD_MSG_ERROR("rc = 0x%x. Failed: ddl start", rc); - - return rc; -} - -u32 vcd_submit_cmd_sess_end(struct vcd_transc *transc) -{ - u32 rc; - - VCD_MSG_LOW("vcd_submit_cmd_sess_end:"); - - if (transc->cctxt->decoding) { - rc = ddl_decode_end(transc->cctxt->ddl_handle, - (void *)transc); - } else { - rc = ddl_encode_end(transc->cctxt->ddl_handle, - (void *)transc); - } - if (!VCD_FAILED(rc)) { - transc->cctxt->status.cmd_submitted++; - vcd_device_timer_start(transc->cctxt->dev_ctxt); - } else - VCD_MSG_ERROR("rc = 0x%x. Failed: ddl end", rc); - - return rc; -} - -void vcd_submit_cmd_client_close(struct vcd_clnt_ctxt *cctxt) -{ - (void) ddl_close(&cctxt->ddl_handle); - cctxt->ddl_hdl_valid = false; - cctxt->status.mask &= ~VCD_CLEANING_UP; - if (cctxt->status.mask & VCD_CLOSE_PENDING) { - vcd_destroy_client_context(cctxt); - vcd_handle_for_last_clnt_close(cctxt->dev_ctxt, true); - } -} - -u32 vcd_submit_command_in_continue(struct vcd_dev_ctxt - *dev_ctxt, struct vcd_transc *transc) -{ - struct vcd_property_hdr prop_hdr; - struct vcd_clnt_ctxt *client = NULL; - enum vcd_command cmd = VCD_CMD_NONE; - u32 rc = VCD_ERR_FAIL; - u32 result = false, flush = 0, event = 0; - u32 command_break = false; - - VCD_MSG_LOW("\n vcd_submit_command_in_continue:"); - - while (!command_break) { - result = vcd_get_next_queued_client_cmd(dev_ctxt, - &client, &cmd); - - if (!result) - command_break = true; - else { - transc->type = cmd; - transc->cctxt = client; - - switch (cmd) { - case VCD_CMD_CODEC_START: - { - rc = vcd_submit_cmd_sess_start(transc); - event = VCD_EVT_RESP_START; - break; - } - case VCD_CMD_CODEC_STOP: - { - rc = vcd_submit_cmd_sess_end(transc); - event = VCD_EVT_RESP_STOP; - break; - } - case VCD_CMD_OUTPUT_FLUSH: - { - prop_hdr.prop_id = DDL_I_REQ_OUTPUT_FLUSH; - prop_hdr.sz = sizeof(u32); - flush = 0x1; - (void) ddl_set_property(client->ddl_handle, - &prop_hdr, &flush); - vcd_release_command_channel(dev_ctxt, - transc); - rc = VCD_S_SUCCESS; - break; - } - case VCD_CMD_CLIENT_CLOSE: - { - vcd_submit_cmd_client_close(client); - vcd_release_command_channel(dev_ctxt, - transc); - rc = VCD_S_SUCCESS; - break; - } - default: - { - VCD_MSG_ERROR("\n vcd_submit_command: Unknown" - "command %d", (int)cmd); - break; - } - } - - if (!VCD_FAILED(rc)) { - command_break = true; - } else { - VCD_MSG_ERROR("vcd_submit_command %d: failed 0x%x", - cmd, rc); - client->callback(event, rc, NULL, 0, client, - client->client_data); - } - } - } - return result; -} - -u32 vcd_schedule_frame(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_clnt_ctxt **cctxt, struct vcd_buffer_entry - **ip_buf_entry) -{ - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("vcd_schedule_frame:"); - - if (!dev_ctxt->cctxt_list_head) { - VCD_MSG_HIGH("Client list empty"); - return false; - } - rc = vcd_sched_get_client_frame(&dev_ctxt->sched_clnt_list, - cctxt, ip_buf_entry); - if (rc == VCD_ERR_QEMPTY) { - VCD_MSG_HIGH("No frame available. Sched queues are empty"); - return false; - } - if (VCD_FAILED(rc)) { - VCD_MSG_FATAL("vcd_submit_frame: sched_de_queue_frame" - "failed 0x%x", rc); - return false; - } - if (!*cctxt || !*ip_buf_entry) { - VCD_MSG_FATAL("Sched returned invalid values. ctxt=%p," - "ipbuf=%p", *cctxt, *ip_buf_entry); - return false; - } - return true; -} - -void vcd_try_submit_frame(struct vcd_dev_ctxt *dev_ctxt) -{ - struct vcd_transc *transc; - u32 rc = VCD_S_SUCCESS; - struct vcd_clnt_ctxt *cctxt = NULL; - struct vcd_buffer_entry *ip_buf_entry = NULL; - u32 result = false; - - VCD_MSG_LOW("vcd_try_submit_frame:"); - - if (!vcd_get_frame_channel(dev_ctxt, &transc)) - return; - - if (!vcd_schedule_frame(dev_ctxt, &cctxt, &ip_buf_entry)) { - vcd_release_frame_channel(dev_ctxt, transc); - return; - } - - rc = vcd_power_event(dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_CMD_BEGIN); - - if (!VCD_FAILED(rc)) { - transc->cctxt = cctxt; - transc->ip_buf_entry = ip_buf_entry; - - result = vcd_submit_frame(dev_ctxt, transc); - } else { - VCD_MSG_ERROR("Failed: VCD_EVT_PWR_CLNT_CMD_BEGIN"); - (void) vcd_sched_queue_buffer( - cctxt->sched_clnt_hdl, ip_buf_entry, false); - cctxt->sched_clnt_hdl->tkns++; - } - - if (!result) { - vcd_release_frame_channel(dev_ctxt, transc); - (void) vcd_power_event(dev_ctxt, cctxt, - VCD_EVT_PWR_CLNT_CMD_FAIL); - } -} - -u32 vcd_submit_frame(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc *transc) -{ - struct vcd_clnt_ctxt *cctxt = NULL; - struct vcd_frame_data *ip_frm_entry; - struct vcd_buffer_entry *op_buf_entry = NULL; - u32 rc = VCD_S_SUCCESS; - u32 evcode = 0; - u32 perf_level = 0; - int decodeTime = 0; - struct ddl_frame_data_tag ddl_ip_frm; - struct ddl_frame_data_tag *ddl_op_frm; - u32 out_buf_cnt = 0; - - VCD_MSG_LOW("vcd_submit_frame:"); - cctxt = transc->cctxt; - ip_frm_entry = &transc->ip_buf_entry->frame; - - transc->op_buf_entry = op_buf_entry; - transc->ip_frm_tag = ip_frm_entry->ip_frm_tag; - transc->time_stamp = ip_frm_entry->time_stamp; - transc->flags = ip_frm_entry->flags; - ip_frm_entry->ip_frm_tag = (u32) transc; - memset(&ddl_ip_frm, 0, sizeof(ddl_ip_frm)); - if (cctxt->decoding) { - decodeTime = ddl_get_core_decode_proc_time(cctxt->ddl_handle); - if (decodeTime > MAX_DEC_TIME) { - if (res_trk_get_curr_perf_level(&perf_level)) { - vcd_update_decoder_perf_level(dev_ctxt, - res_trk_estimate_perf_level(perf_level)); - ddl_reset_avg_dec_time(cctxt->ddl_handle); - } else - VCD_MSG_ERROR("%s(): retrieve curr_perf_level" - "returned FALSE\n", __func__); - } - evcode = CLIENT_STATE_EVENT_NUMBER(decode_frame); - ddl_ip_frm.vcd_frm = *ip_frm_entry; - rc = ddl_decode_frame(cctxt->ddl_handle, &ddl_ip_frm, - (void *) transc); - } else { - ddl_op_frm = (struct ddl_frame_data_tag *) - kmalloc((sizeof(struct ddl_frame_data_tag) * - VCD_ENC_MAX_OUTBFRS_PER_FRAME), GFP_KERNEL); - if (!ddl_op_frm) { - VCD_MSG_ERROR("Memory allocation failure"); - return VCD_ERR_ALLOC_FAIL; - } - memset(ddl_op_frm, 0, (sizeof(struct ddl_frame_data_tag) * - VCD_ENC_MAX_OUTBFRS_PER_FRAME)); - for (out_buf_cnt = 0; out_buf_cnt < cctxt->num_slices ; - out_buf_cnt++) { - op_buf_entry = vcd_buffer_pool_entry_de_q( - &cctxt->out_buf_pool); - if (!op_buf_entry) { - VCD_MSG_ERROR("Sched provided frame when no" - "op buffer was present"); - rc = VCD_ERR_FAIL; - break; - } - op_buf_entry->in_use = true; - cctxt->out_buf_pool.in_use++; - ddl_op_frm[out_buf_cnt].vcd_frm = op_buf_entry->frame; - VCD_MSG_LOW("%s : buffer_cnt = %d framebfr(virtual)" - " 0x%p", __func__, out_buf_cnt, - op_buf_entry->frame.virtual); - VCD_MSG_LOW("framebfr(physical) 0x%p bfrlength %d", - op_buf_entry->frame.physical, - op_buf_entry->frame.alloc_len); - } - ddl_ip_frm.vcd_frm = *ip_frm_entry; - ddl_ip_frm.frm_delta = - vcd_calculate_frame_delta(cctxt, - ip_frm_entry); - evcode = CLIENT_STATE_EVENT_NUMBER(encode_frame); - - if (!VCD_FAILED(rc)) { - rc = ddl_encode_frame(cctxt->ddl_handle, - &ddl_ip_frm, &ddl_op_frm[0], (void *) transc); - } - kfree(ddl_op_frm); - } - ip_frm_entry->ip_frm_tag = transc->ip_frm_tag; - if (!VCD_FAILED(rc)) { - vcd_device_timer_start(dev_ctxt); - cctxt->status.frame_submitted++; - if (ip_frm_entry->flags & VCD_FRAME_FLAG_EOS) - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_EOS, evcode); - } else { - VCD_MSG_ERROR("Frame submission failed. rc = 0x%x", rc); - vcd_handle_submit_frame_failed(dev_ctxt, transc); - } - return true; -} - -u32 vcd_try_submit_frame_in_continue(struct vcd_dev_ctxt *dev_ctxt, - struct vcd_transc *transc) -{ - struct vcd_clnt_ctxt *cctxt = NULL; - struct vcd_buffer_entry *ip_buf_entry = NULL; - - VCD_MSG_LOW("vcd_try_submit_frame_in_continue:"); - - if (!vcd_schedule_frame(dev_ctxt, &cctxt, &ip_buf_entry)) - return false; - - transc->cctxt = cctxt; - transc->ip_buf_entry = ip_buf_entry; - - return vcd_submit_frame(dev_ctxt, transc); -} - -u32 vcd_process_cmd_sess_start(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_transc *transc; - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_process_cmd_sess_start:"); - if (vcd_get_command_channel(cctxt->dev_ctxt, &transc)) { - rc = vcd_power_event(cctxt->dev_ctxt, - cctxt, VCD_EVT_PWR_CLNT_CMD_BEGIN); - - if (!VCD_FAILED(rc)) { - transc->type = VCD_CMD_CODEC_START; - transc->cctxt = cctxt; - rc = vcd_submit_cmd_sess_start(transc); - } else { - VCD_MSG_ERROR("Failed: VCD_EVT_PWR_CLNT_CMD_BEGIN"); - } - - if (VCD_FAILED(rc)) { - vcd_release_command_channel(cctxt->dev_ctxt, - transc); - } - } else { - u32 result; - - result = vcd_client_cmd_en_q(cctxt, VCD_CMD_CODEC_START); - if (!result) { - rc = VCD_ERR_BUSY; - VCD_MSG_ERROR("%s(): vcd_client_cmd_en_q() " - "failed\n", __func__); - } - } - - if (VCD_FAILED(rc)) { - (void)vcd_power_event(cctxt->dev_ctxt, - cctxt, VCD_EVT_PWR_CLNT_CMD_FAIL); - } - - return rc; -} - -void vcd_send_frame_done_in_eos(struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame, u32 valid_opbuf) -{ - VCD_MSG_HIGH("vcd_send_frame_done_in_eos:"); - - if (!input_frame->virtual && !valid_opbuf) { - VCD_MSG_MED("Sending NULL output with EOS"); - - cctxt->out_buf_pool.entries[0].frame.flags = - VCD_FRAME_FLAG_EOS; - cctxt->out_buf_pool.entries[0].frame.data_len = 0; - cctxt->out_buf_pool.entries[0].frame.time_stamp = - input_frame->time_stamp; - cctxt->out_buf_pool.entries[0].frame.ip_frm_tag = - input_frame->ip_frm_tag; - - cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, - &cctxt->out_buf_pool.entries[0].frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - - memset(&cctxt->out_buf_pool.entries[0].frame, - 0, sizeof(struct vcd_frame_data)); - } else if (!input_frame->data_len) { - if (cctxt->decoding) { - vcd_send_frame_done_in_eos_for_dec(cctxt, - input_frame); - } else { - vcd_send_frame_done_in_eos_for_enc(cctxt, - input_frame); - } - - } -} - -void vcd_send_frame_done_in_eos_for_dec( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame) -{ - struct vcd_buffer_entry *buf_entry; - struct vcd_property_hdr prop_hdr; - u32 rc; - struct ddl_frame_data_tag ddl_frm; - - prop_hdr.prop_id = DDL_I_DPB_RETRIEVE; - prop_hdr.sz = sizeof(struct ddl_frame_data_tag); - memset(&ddl_frm, 0, sizeof(ddl_frm)); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &ddl_frm); - - if (VCD_FAILED(rc) || !ddl_frm.vcd_frm.virtual) { - cctxt->status.eos_trig_ip_frm = *input_frame; - cctxt->status.mask |= VCD_EOS_WAIT_OP_BUF; - return; - } - - buf_entry = vcd_find_buffer_pool_entry(&cctxt->out_buf_pool, - ddl_frm.vcd_frm.virtual); - if (!buf_entry) { - VCD_MSG_ERROR("Unrecognized buffer address provided = %p", - ddl_frm.vcd_frm.virtual); - return; - } else { - if (cctxt->sched_clnt_hdl->tkns) - cctxt->sched_clnt_hdl->tkns--; - - VCD_MSG_MED("Sending non-NULL output with EOS"); - - buf_entry->frame.data_len = 0; - buf_entry->frame.offset = 0; - buf_entry->frame.flags |= VCD_FRAME_FLAG_EOS; - buf_entry->frame.ip_frm_tag = input_frame->ip_frm_tag; - buf_entry->frame.time_stamp = input_frame->time_stamp; - - cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, - &buf_entry->frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - - buf_entry->in_use = false; - VCD_BUFFERPOOL_INUSE_DECREMENT(cctxt->out_buf_pool.in_use); - } -} - -void vcd_send_frame_done_in_eos_for_enc( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame) -{ - struct vcd_buffer_entry *op_buf_entry; - - if (!cctxt->out_buf_pool.q_len) { - cctxt->status.eos_trig_ip_frm = *input_frame; - - cctxt->status.mask |= VCD_EOS_WAIT_OP_BUF; - - return; - } - - op_buf_entry = vcd_buffer_pool_entry_de_q(&cctxt->out_buf_pool); - if (!op_buf_entry) { - VCD_MSG_ERROR("%s(): vcd_buffer_pool_entry_de_q() " - "failed\n", __func__); - } else { - if (cctxt->sched_clnt_hdl->tkns) - cctxt->sched_clnt_hdl->tkns--; - - VCD_MSG_MED("Sending non-NULL output with EOS"); - - op_buf_entry->frame.data_len = 0; - op_buf_entry->frame.flags |= VCD_FRAME_FLAG_EOS; - op_buf_entry->frame.ip_frm_tag = - input_frame->ip_frm_tag; - op_buf_entry->frame.time_stamp = input_frame->time_stamp; - - cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, - &op_buf_entry->frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - } -} - -struct vcd_transc *vcd_get_first_in_use_trans_for_clnt( - struct vcd_clnt_ctxt *cctxt) -{ - u32 i; - struct vcd_dev_ctxt *dev_ctxt; - VCD_MSG_HIGH("%s: ", __func__); - dev_ctxt = cctxt->dev_ctxt; - if (!dev_ctxt->trans_tbl) { - VCD_MSG_ERROR("%s: Null trans_tbl", __func__); - return NULL; - } - i = 0; - while (i < dev_ctxt->trans_tbl_size) { - if ((cctxt == dev_ctxt->trans_tbl[i].cctxt) && - (dev_ctxt->trans_tbl[i].in_use)) { - VCD_MSG_MED("%s: found transc = 0x%p", - __func__, &dev_ctxt->trans_tbl[i]); - break; - } - i++; - } - if (i == dev_ctxt->trans_tbl_size) { - VCD_MSG_ERROR("%s: in_use transction not found", - __func__); - return NULL; - } else - return &dev_ctxt->trans_tbl[i]; -} - -u32 vcd_handle_recvd_eos( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame, u32 *pb_eos_handled) -{ - u32 rc; - struct vcd_transc *transc; - VCD_MSG_LOW("vcd_handle_recvd_eos:"); - - *pb_eos_handled = false; - - if (input_frame->virtual && - input_frame->data_len) - return VCD_S_SUCCESS; - - input_frame->data_len = 0; - rc = vcd_sched_mark_client_eof(cctxt->sched_clnt_hdl); - if (VCD_FAILED(rc) && rc != VCD_ERR_QEMPTY) - return rc; - - if (rc == VCD_S_SUCCESS) - *pb_eos_handled = true; - else if (cctxt->decoding && !input_frame->virtual) - cctxt->sched_clnt_hdl->tkns++; - else if (!cctxt->decoding && !cctxt->status.frame_delayed) { - if (!cctxt->status.frame_submitted) { - vcd_send_frame_done_in_eos(cctxt, input_frame, false); - if (cctxt->status.mask & VCD_EOS_WAIT_OP_BUF) - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_EOS, - CLIENT_STATE_EVENT_NUMBER - (encode_frame)); - } else { - transc = vcd_get_first_in_use_trans_for_clnt(cctxt); - if (transc) { - transc->flags |= VCD_FRAME_FLAG_EOS; - VCD_MSG_HIGH("%s: Add EOS flag to transc", - __func__); - } - } - *pb_eos_handled = true; - } - - if (*pb_eos_handled && - input_frame->virtual && - !input_frame->data_len) { - cctxt->callback(VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, - input_frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - } - return VCD_S_SUCCESS; -} - -u32 vcd_handle_first_decode_frame(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_ERR_BAD_STATE; - - VCD_MSG_LOW("vcd_handle_first_decode_frame:"); - if (!cctxt->in_buf_pool.entries || - !cctxt->out_buf_pool.entries || - cctxt->in_buf_pool.validated != - cctxt->in_buf_pool.count || - cctxt->out_buf_pool.validated != - cctxt->out_buf_pool.count) - VCD_MSG_ERROR("Buffer pool is not completely setup yet"); - else if (!cctxt->sched_clnt_hdl) { - rc = vcd_sched_add_client(cctxt); - VCD_FAILED_RETURN(rc, "Failed: vcd_add_client_to_sched"); - cctxt->sched_clnt_hdl->tkns = - cctxt->out_buf_pool.q_len; - } else - rc = vcd_sched_suspend_resume_clnt(cctxt, true); - return rc; -} - -u32 vcd_setup_with_ddl_capabilities(struct vcd_dev_ctxt *dev_ctxt) -{ - struct vcd_property_hdr Prop_hdr; - struct ddl_property_capability capability; - u32 rc = VCD_S_SUCCESS; - - VCD_MSG_LOW("vcd_setup_with_ddl_capabilities:"); - - if (!dev_ctxt->ddl_cmd_ch_depth) { - Prop_hdr.prop_id = DDL_I_CAPABILITY; - Prop_hdr.sz = sizeof(capability); - - /* - ** Since this is underlying core's property we don't need a - ** ddl client handle. - */ - rc = ddl_get_property(NULL, &Prop_hdr, &capability); - - if (!VCD_FAILED(rc)) { - /* - ** Allocate the transaction table. - */ - dev_ctxt->trans_tbl_size = - (VCD_MAX_CLIENT_TRANSACTIONS * - capability.max_num_client) + - capability.general_command_depth; - - dev_ctxt->trans_tbl = (struct vcd_transc *) - kzalloc((sizeof(struct vcd_transc) * - dev_ctxt->trans_tbl_size), GFP_KERNEL); - - if (!dev_ctxt->trans_tbl) { - VCD_MSG_ERROR("Transaction table alloc failed"); - rc = VCD_ERR_ALLOC_FAIL; - } else { - dev_ctxt->ddl_cmd_concurrency = - !capability.exclusive; - dev_ctxt->ddl_frame_ch_depth = - capability.frame_command_depth; - dev_ctxt->ddl_cmd_ch_depth = - capability.general_command_depth; - - vcd_reset_device_channels(dev_ctxt); - - dev_ctxt->hw_time_out = - capability.ddl_time_out_in_ms; - - } - } - } - return rc; -} - -struct vcd_transc *vcd_get_free_trans_tbl_entry - (struct vcd_dev_ctxt *dev_ctxt) { - u32 i; - - if (!dev_ctxt->trans_tbl) - return NULL; - - i = 0; - while (i < dev_ctxt->trans_tbl_size && - dev_ctxt->trans_tbl[i].in_use) - i++; - - if (i == dev_ctxt->trans_tbl_size) { - return NULL; - } else { - memset(&dev_ctxt->trans_tbl[i], 0, - sizeof(struct vcd_transc)); - dev_ctxt->trans_tbl[i].in_use = true; - VCD_MSG_LOW("%s: Get transc = 0x%x, in_use = %u\n", - __func__, (u32)(&dev_ctxt->trans_tbl[i]), - dev_ctxt->trans_tbl[i].in_use); - return &dev_ctxt->trans_tbl[i]; - } -} - -void vcd_release_trans_tbl_entry(struct vcd_transc *trans_entry) -{ - if (trans_entry) { - trans_entry->in_use = false; - VCD_MSG_LOW("%s: Free transc = 0x%x, in_use = %u\n", - __func__, (u32)trans_entry, trans_entry->in_use); - } -} - -u32 vcd_handle_input_done( - struct vcd_clnt_ctxt *cctxt, - void *payload, u32 event, u32 status) -{ - struct vcd_transc *transc; - struct ddl_frame_data_tag *frame = - (struct ddl_frame_data_tag *) payload; - struct vcd_buffer_entry *orig_frame = NULL; - u32 rc; - VCD_MSG_LOW("%s\n", __func__); - - if (!cctxt->status.frame_submitted && - !cctxt->status.frame_delayed) { - VCD_MSG_ERROR("Input done was not expected"); - return VCD_ERR_BAD_STATE; - } - - rc = vcd_validate_io_done_pyld(cctxt, payload, status); - if (rc == VCD_ERR_CLIENT_FATAL) - vcd_handle_clnt_fatal_input_done(cctxt, frame->frm_trans_end); - VCD_FAILED_RETURN(rc, "Bad input done payload"); - - transc = (struct vcd_transc *)frame->vcd_frm.ip_frm_tag; - orig_frame = vcd_find_buffer_pool_entry(&cctxt->in_buf_pool, - transc->ip_buf_entry->virtual); - - if (!orig_frame) { - rc = VCD_ERR_ILLEGAL_PARM; - VCD_FAILED_RETURN(rc, "Couldn't find buffer"); - } - - if ((transc->ip_buf_entry->frame.virtual != - frame->vcd_frm.virtual) - || !transc->ip_buf_entry->in_use) { - VCD_MSG_ERROR("Bad frm transaction state"); - vcd_handle_clnt_fatal_input_done(cctxt, frame->frm_trans_end); - return VCD_ERR_BAD_POINTER; - } - - frame->vcd_frm.ip_frm_tag = transc->ip_frm_tag; - transc->frame = frame->vcd_frm.frame; - - cctxt->callback(event, - status, - &frame->vcd_frm, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - - orig_frame->in_use--; - VCD_BUFFERPOOL_INUSE_DECREMENT(cctxt->in_buf_pool.in_use); - - if (cctxt->decoding && orig_frame->in_use) { - VCD_MSG_ERROR("When decoding same input buffer not " - "supposed to be queued multiple times"); - return VCD_ERR_FAIL; - } - - if (orig_frame != transc->ip_buf_entry) - kfree(transc->ip_buf_entry); - transc->ip_buf_entry = NULL; - transc->input_done = true; - - if (transc->input_done && transc->frame_done) { - VCD_MSG_LOW("%s Calling vcd_release_trans_tbl_entry\n", - __func__); - vcd_release_trans_tbl_entry(transc); - } - - if (VCD_FAILED(status)) { - VCD_MSG_ERROR("INPUT_DONE returned err = 0x%x", status); - vcd_handle_input_done_failed(cctxt, transc); - } else - cctxt->status.mask |= VCD_FIRST_IP_DONE; - - if (cctxt->status.frame_submitted > 0) - cctxt->status.frame_submitted--; - else - cctxt->status.frame_delayed--; - - if (!VCD_FAILED(status) && - cctxt->decoding) { - if (frame->vcd_frm.flags & VCD_FRAME_FLAG_CODECCONFIG) { - VCD_MSG_HIGH( - "INPUT_DONE with VCD_FRAME_FLAG_CODECCONFIG"); - vcd_handle_input_done_with_codec_config(cctxt, - transc, frame); - frame->vcd_frm.flags &= ~VCD_FRAME_FLAG_CODECCONFIG; - } - if (frame->vcd_frm.interlaced) - vcd_handle_input_done_for_interlacing(cctxt); - if (frame->frm_trans_end) - vcd_handle_input_done_with_trans_end(cctxt); - } - - return VCD_S_SUCCESS; -} - -u32 vcd_handle_input_done_in_eos( - struct vcd_clnt_ctxt *cctxt, void *payload, u32 status) -{ - struct vcd_transc *transc; - struct ddl_frame_data_tag *frame = - (struct ddl_frame_data_tag *) payload; - u32 rc = VCD_ERR_FAIL, codec_config = false; - u32 core_type = res_trk_get_core_type(); - VCD_MSG_LOW("%s\n", __func__); - rc = vcd_validate_io_done_pyld(cctxt, payload, status); - if (rc == VCD_ERR_CLIENT_FATAL) - vcd_handle_clnt_fatal_input_done(cctxt, frame->frm_trans_end); - VCD_FAILED_RETURN(rc, "Failed: vcd_validate_io_done_pyld"); - transc = (struct vcd_transc *)frame->vcd_frm.ip_frm_tag; - codec_config = frame->vcd_frm.flags & VCD_FRAME_FLAG_CODECCONFIG; - rc = vcd_handle_input_done(cctxt, - payload, VCD_EVT_RESP_INPUT_DONE, status); - VCD_FAILED_RETURN(rc, "Failed: vcd_handle_input_done"); - if (frame->vcd_frm.flags & VCD_FRAME_FLAG_EOS) { - VCD_MSG_HIGH("Got input done for EOS initiator"); - transc->input_done = false; - transc->in_use = true; - if ((codec_config && - (status != VCD_ERR_BITSTREAM_ERR)) || - (codec_config && (status == VCD_ERR_BITSTREAM_ERR) && - !(cctxt->status.mask & VCD_FIRST_IP_DONE) && - (core_type == VCD_CORE_720P))) { - VCD_MSG_HIGH("handle EOS for codec config"); - vcd_handle_eos_done(cctxt, transc, VCD_S_SUCCESS); - } - } - return rc; -} - -u32 vcd_validate_io_done_pyld( - struct vcd_clnt_ctxt *cctxt, void *payload, u32 status) -{ - struct ddl_frame_data_tag *frame = - (struct ddl_frame_data_tag *) payload; - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - struct vcd_transc *transc = NULL; - u32 rc = VCD_S_SUCCESS, i = 0; - - if (!frame) { - VCD_MSG_ERROR("Bad payload from DDL"); - return VCD_ERR_BAD_POINTER; - } - - transc = (struct vcd_transc *)frame->vcd_frm.ip_frm_tag; - if (dev_ctxt->trans_tbl) { - while (i < dev_ctxt->trans_tbl_size && - transc != &dev_ctxt->trans_tbl[i]) - i++; - if (i == dev_ctxt->trans_tbl_size || - !dev_ctxt->trans_tbl[i].in_use) - rc = VCD_ERR_CLIENT_FATAL; - } else - rc = VCD_ERR_CLIENT_FATAL; - - if (VCD_FAILED(rc)) { - VCD_MSG_FATAL("vcd_validate_io_done_pyld: "\ - "invalid transaction 0x%x", (u32)transc); - } else if (!frame->vcd_frm.virtual && - status != VCD_ERR_INTRLCD_FIELD_DROP) - rc = VCD_ERR_BAD_POINTER; - - return rc; -} - -void vcd_handle_input_done_failed( - struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc) -{ - if (cctxt->decoding) { - cctxt->sched_clnt_hdl->tkns++; - vcd_release_trans_tbl_entry(transc); - } -} - -void vcd_handle_input_done_with_codec_config( - struct vcd_clnt_ctxt *cctxt, struct vcd_transc *transc, - struct ddl_frame_data_tag *frm) -{ - cctxt->sched_clnt_hdl->tkns++; - if (frm->frm_trans_end) - vcd_release_trans_tbl_entry(transc); -} - -void vcd_handle_input_done_for_interlacing(struct vcd_clnt_ctxt *cctxt) -{ - cctxt->status.int_field_cnt++; - if (cctxt->status.int_field_cnt == 1) - cctxt->sched_clnt_hdl->tkns++; - else if (cctxt->status.int_field_cnt == - VCD_DEC_NUM_INTERLACED_FIELDS) - cctxt->status.int_field_cnt = 0; -} - -void vcd_handle_input_done_with_trans_end( - struct vcd_clnt_ctxt *cctxt) -{ - if (!cctxt->decoding) - return; - if (cctxt->out_buf_pool.in_use < - cctxt->out_buf_pool.buf_req.min_count) - return; - if (!cctxt->sched_clnt_hdl->tkns) - cctxt->sched_clnt_hdl->tkns++; -} - -u32 vcd_handle_output_required(struct vcd_clnt_ctxt - *cctxt, void *payload, u32 status) -{ - struct vcd_transc *transc; - struct ddl_frame_data_tag *frame = - (struct ddl_frame_data_tag *)payload; - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("%s\n", __func__); - - if (!cctxt->status.frame_submitted && - !cctxt->status.frame_delayed) { - VCD_MSG_ERROR("\n Input done was not expected"); - return VCD_ERR_BAD_STATE; - } - - rc = vcd_validate_io_done_pyld(cctxt, payload, status); - if (rc == VCD_ERR_CLIENT_FATAL) - vcd_handle_clnt_fatal_input_done(cctxt, frame->frm_trans_end); - VCD_FAILED_RETURN(rc, "\n Bad input done payload"); - - transc = (struct vcd_transc *)frame-> - vcd_frm.ip_frm_tag; - - if ((transc->ip_buf_entry->frame.virtual != - frame->vcd_frm.virtual) || - !transc->ip_buf_entry->in_use) { - VCD_MSG_ERROR("\n Bad frm transaction state"); - vcd_handle_clnt_fatal_input_done(cctxt, frame->frm_trans_end); - return VCD_ERR_BAD_STATE; - } - rc = vcd_sched_queue_buffer(cctxt->sched_clnt_hdl, - transc->ip_buf_entry, false); - VCD_FAILED_RETURN(rc, "Failed: vcd_sched_queue_buffer"); - - transc->ip_buf_entry = NULL; - vcd_release_trans_tbl_entry(transc); - frame->frm_trans_end = true; - - if (VCD_FAILED(status)) - VCD_MSG_ERROR("\n OUTPUT_REQ returned err = 0x%x", - status); - - if (cctxt->status.frame_submitted > 0) - cctxt->status.frame_submitted--; - else - cctxt->status.frame_delayed--; - - - if (!VCD_FAILED(status) && - cctxt->decoding && - frame->vcd_frm.interlaced) { - if (cctxt->status.int_field_cnt > 0) { - VCD_MSG_ERROR("\n Not expected: OUTPUT_REQ" - "for 2nd interlace field"); - rc = VCD_ERR_FAIL; - } - } - - return rc; -} - -u32 vcd_handle_output_required_in_flushing( -struct vcd_clnt_ctxt *cctxt, void *payload) -{ - u32 rc; - struct vcd_transc *transc; - struct ddl_frame_data_tag *frame = - (struct ddl_frame_data_tag *)payload; - VCD_MSG_LOW("%s\n", __func__); - - rc = vcd_validate_io_done_pyld(cctxt, payload, VCD_S_SUCCESS); - if (rc == VCD_ERR_CLIENT_FATAL) - vcd_handle_clnt_fatal_input_done(cctxt, frame->frm_trans_end); - VCD_FAILED_RETURN(rc, "Bad input done payload"); - - transc = (struct vcd_transc *) - (((struct ddl_frame_data_tag *)payload)-> - vcd_frm.ip_frm_tag); - - ((struct ddl_frame_data_tag *)payload)-> - vcd_frm.interlaced = false; - - rc = vcd_handle_input_done(cctxt, payload, - VCD_EVT_RESP_INPUT_FLUSHED, VCD_S_SUCCESS); - VCD_FAILED_RETURN(rc, "Failed: vcd_handle_input_done"); - - vcd_release_trans_tbl_entry(transc); - ((struct ddl_frame_data_tag *)payload)->frm_trans_end = true; - - return rc; -} - -u32 vcd_handle_frame_done( - struct vcd_clnt_ctxt *cctxt, - void *payload, u32 event, u32 status) -{ - struct vcd_buffer_entry *op_buf_entry = NULL; - struct ddl_frame_data_tag *op_frm = - (struct ddl_frame_data_tag *) payload; - struct vcd_transc *transc; - u32 rc; - s64 time_stamp; - VCD_MSG_LOW("%s\n", __func__); - - rc = vcd_validate_io_done_pyld(cctxt, payload, status); - if (rc == VCD_ERR_CLIENT_FATAL) - vcd_handle_clnt_fatal(cctxt, op_frm->frm_trans_end); - VCD_FAILED_RETURN(rc, "Bad payload recvd"); - - transc = (struct vcd_transc *)op_frm->vcd_frm.ip_frm_tag; - - if (op_frm->vcd_frm.virtual) { - - if (!transc->op_buf_entry) { - op_buf_entry = - vcd_find_buffer_pool_entry( - &cctxt->out_buf_pool, - op_frm->vcd_frm. - virtual); - } else { - op_buf_entry = transc->op_buf_entry; - } - - if (!op_buf_entry) { - VCD_MSG_ERROR("Invalid output buffer returned" - "from DDL"); - vcd_handle_clnt_fatal(cctxt, op_frm->frm_trans_end); - rc = VCD_ERR_BAD_POINTER; - } else if (!op_buf_entry->in_use) { - VCD_MSG_ERROR("Bad output buffer 0x%p recvd from DDL", - op_buf_entry->frame.virtual); - vcd_handle_clnt_fatal(cctxt, op_frm->frm_trans_end); - rc = VCD_ERR_BAD_POINTER; - } else { - op_buf_entry->in_use = false; - VCD_BUFFERPOOL_INUSE_DECREMENT( - cctxt->out_buf_pool.in_use); - VCD_MSG_LOW("outBufPool.InUse = %d", - cctxt->out_buf_pool.in_use); - } - } - VCD_FAILED_RETURN(rc, "Bad output buffer pointer"); - op_frm->vcd_frm.time_stamp = transc->time_stamp; - op_frm->vcd_frm.ip_frm_tag = transc->ip_frm_tag; - - if (transc->flags & VCD_FRAME_FLAG_EOSEQ) - op_frm->vcd_frm.flags |= VCD_FRAME_FLAG_EOSEQ; - else - op_frm->vcd_frm.flags &= ~VCD_FRAME_FLAG_EOSEQ; - - if (cctxt->decoding) - op_frm->vcd_frm.frame = transc->frame; - else - transc->frame = op_frm->vcd_frm.frame; - transc->frame_done = true; - - if (transc->input_done && transc->frame_done) { - time_stamp = transc->time_stamp; - vcd_release_trans_tbl_entry(transc); - } - - if (status == VCD_ERR_INTRLCD_FIELD_DROP || - (op_frm->vcd_frm.intrlcd_ip_frm_tag != - VCD_FRAMETAG_INVALID && - op_frm->vcd_frm.intrlcd_ip_frm_tag)) { - vcd_handle_frame_done_for_interlacing(cctxt, transc, - op_frm, status); - if (status == VCD_ERR_INTRLCD_FIELD_DROP) { - cctxt->callback(VCD_EVT_IND_INFO_FIELD_DROPPED, - VCD_S_SUCCESS, - &time_stamp, - sizeof(time_stamp), - cctxt, cctxt->client_data); - } - } - - if (status != VCD_ERR_INTRLCD_FIELD_DROP) { - cctxt->callback(event, - status, - &op_frm->vcd_frm, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - } - return rc; -} - -u32 vcd_handle_frame_done_in_eos( - struct vcd_clnt_ctxt *cctxt, void *payload, u32 status) -{ - struct ddl_frame_data_tag *frame = - (struct ddl_frame_data_tag *) payload; - u32 rc = VCD_S_SUCCESS; - VCD_MSG_LOW("%s\n", __func__); - rc = vcd_validate_io_done_pyld(cctxt, payload, status); - if (rc == VCD_ERR_CLIENT_FATAL) - vcd_handle_clnt_fatal(cctxt, frame->frm_trans_end); - VCD_FAILED_RETURN(rc, "Bad payload received"); - - if (cctxt->status.mask & VCD_EOS_PREV_VALID) { - rc = vcd_handle_frame_done(cctxt, - (void *)&cctxt->status. - eos_prev_op_frm, - VCD_EVT_RESP_OUTPUT_DONE, - cctxt->status.eos_prev_op_frm_status); - VCD_FAILED_RETURN(rc, "Failed: vcd_handle_frame_done"); - } - - cctxt->status.eos_prev_op_frm = *frame; - cctxt->status.eos_prev_op_frm_status = status; - cctxt->status.mask |= VCD_EOS_PREV_VALID; - return rc; -} - -void vcd_handle_frame_done_for_interlacing( - struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc_ip1, - struct ddl_frame_data_tag *op_frm, u32 status) -{ - struct vcd_transc *transc_ip2 = - (struct vcd_transc *)op_frm->\ - vcd_frm.intrlcd_ip_frm_tag; - - if (status == VCD_ERR_INTRLCD_FIELD_DROP) { - cctxt->status.int_field_cnt = 0; - return; - } - - op_frm->vcd_frm.intrlcd_ip_frm_tag = transc_ip2->ip_frm_tag; - - transc_ip2->frame_done = true; - - if (transc_ip2->input_done && transc_ip2->frame_done) - vcd_release_trans_tbl_entry(transc_ip2); - - if (!transc_ip1->frame || !transc_ip2->frame) { - VCD_MSG_ERROR("DDL didn't provided frame type"); - return; - } -} - -u32 vcd_handle_first_fill_output_buffer( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *buffer, - u32 *handled) -{ - u32 rc = VCD_S_SUCCESS; - rc = vcd_check_if_buffer_req_met(cctxt, VCD_BUFFER_OUTPUT); - VCD_FAILED_RETURN(rc, "Output buffer requirements not met"); - if (cctxt->out_buf_pool.q_len > 0) { - VCD_MSG_ERROR("Old output buffers were not flushed out"); - return VCD_ERR_BAD_STATE; - } - cctxt->status.mask |= VCD_FIRST_OP_RCVD; - if (cctxt->sched_clnt_hdl) - rc = vcd_sched_suspend_resume_clnt(cctxt, true); - VCD_FAILED_RETURN(rc, "Failed: vcd_sched_suspend_resume_clnt"); - if (cctxt->decoding) - rc = vcd_handle_first_fill_output_buffer_for_dec( - cctxt, buffer, handled); - else - rc = vcd_handle_first_fill_output_buffer_for_enc( - cctxt, buffer, handled); - return rc; -} - -u32 vcd_handle_first_fill_output_buffer_for_enc( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *frm_entry, - u32 *handled) -{ - u32 rc, seqhdr_present = 0; - struct vcd_property_hdr prop_hdr; - struct vcd_sequence_hdr seq_hdr; - struct vcd_property_sps_pps_for_idr_enable idr_enable; - struct vcd_property_codec codec; - *handled = true; - prop_hdr.prop_id = DDL_I_SEQHDR_PRESENT; - prop_hdr.sz = sizeof(seqhdr_present); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &seqhdr_present); - VCD_FAILED_RETURN(rc, "Failed: DDL_I_SEQHDR_PRESENT"); - if (!seqhdr_present) { - *handled = false; - return VCD_S_SUCCESS; - } - - prop_hdr.prop_id = VCD_I_CODEC; - prop_hdr.sz = sizeof(struct vcd_property_codec); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &codec); - if (!VCD_FAILED(rc)) { - if (codec.codec != VCD_CODEC_H263) { - /* - * The seq. header is stored in a seperate internal - * buffer and is memcopied into the output buffer - * that we provide. In secure sessions, we aren't - * allowed to touch these buffers. In these cases - * seq. headers are returned to client as part of - * I-frames. So for secure session, just return - * empty buffer. - */ - if (!cctxt->secure) { - prop_hdr.prop_id = VCD_I_SEQ_HEADER; - prop_hdr.sz = sizeof(struct vcd_sequence_hdr); - seq_hdr.sequence_header = frm_entry->virtual; - seq_hdr.sequence_header_len = - frm_entry->alloc_len; - rc = ddl_get_property(cctxt->ddl_handle, - &prop_hdr, &seq_hdr); - if (!VCD_FAILED(rc)) { - frm_entry->data_len = - seq_hdr.sequence_header_len; - frm_entry->time_stamp = 0; - frm_entry->flags |= - VCD_FRAME_FLAG_CODECCONFIG; - } else - VCD_MSG_ERROR("rc = 0x%x. Failed:" - "ddl_get_property: VCD_I_SEQ_HEADER", - rc); - } else { - /* - * First check that the proper props are enabled - * so client can get the proper info eventually - */ - prop_hdr.prop_id = VCD_I_ENABLE_SPS_PPS_FOR_IDR; - prop_hdr.sz = sizeof(idr_enable); - rc = ddl_get_property(cctxt->ddl_handle, - &prop_hdr, &idr_enable); - if (!VCD_FAILED(rc)) { - if (!idr_enable. - sps_pps_for_idr_enable_flag) { - VCD_MSG_ERROR("SPS/PPS per IDR " - "needs to be enabled"); - rc = VCD_ERR_BAD_STATE; - } else { - /* Send zero len frame */ - frm_entry->data_len = 0; - frm_entry->time_stamp = 0; - frm_entry->flags = 0; - } - } - - } - - if (!VCD_FAILED(rc)) - cctxt->callback(VCD_EVT_RESP_OUTPUT_DONE, - VCD_S_SUCCESS, frm_entry, - sizeof(struct vcd_frame_data), - cctxt, - cctxt->client_data); - } else - VCD_MSG_LOW("Codec Type is H.263\n"); - } else - VCD_MSG_ERROR( - "rc = 0x%x. Failed: ddl_get_property:VCD_I_CODEC", - rc); - return rc; -} - -u32 vcd_handle_first_fill_output_buffer_for_dec( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *frm_entry, - u32 *handled) -{ - u32 rc; - struct vcd_property_hdr prop_hdr; - struct vcd_buffer_pool *out_buf_pool; - struct ddl_property_dec_pic_buffers dpb; - struct ddl_frame_data_tag *dpb_list; - u8 i; - - (void)frm_entry; - *handled = true; - prop_hdr.prop_id = DDL_I_DPB; - prop_hdr.sz = sizeof(dpb); - out_buf_pool = &cctxt->out_buf_pool; - - dpb_list = (struct ddl_frame_data_tag *) - kmalloc((sizeof(struct ddl_frame_data_tag) * - out_buf_pool->count), GFP_KERNEL); - - if (!dpb_list) { - VCD_MSG_ERROR("Memory allocation failure"); - return VCD_ERR_ALLOC_FAIL; - } - - for (i = 1; i <= out_buf_pool->count; i++) - dpb_list[i - 1].vcd_frm = out_buf_pool->entries[i].frame; - - dpb.dec_pic_buffers = dpb_list; - dpb.no_of_dec_pic_buf = out_buf_pool->count; - rc = ddl_set_property(cctxt->ddl_handle, &prop_hdr, &dpb); - - kfree(dpb_list); - *handled = false; - - return VCD_S_SUCCESS; -} - -void vcd_handle_eos_trans_end(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - if (cctxt->status.mask & VCD_EOS_PREV_VALID) { - rc = vcd_handle_frame_done(cctxt, - (void *)&cctxt->status.eos_prev_op_frm, - VCD_EVT_RESP_OUTPUT_DONE, - cctxt->status.eos_prev_op_frm_status); - cctxt->status.mask &= ~VCD_EOS_PREV_VALID; - } - if (VCD_FAILED(rc)) - return; - - if (cctxt->status.mask & VCD_FLUSH_ALL) - vcd_process_pending_flush_in_eos(cctxt); - - if (cctxt->status.mask & VCD_STOP_PENDING) - vcd_process_pending_stop_in_eos(cctxt); - else { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER(clnt_cb)); - } -} - -void vcd_handle_eos_done(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status) -{ - struct vcd_frame_data vcd_frm; - u32 rc = VCD_S_SUCCESS, sent_eos_frm = false; - VCD_MSG_LOW("vcd_handle_eos_done:"); - - if (VCD_FAILED(status)) - VCD_MSG_ERROR("EOS DONE returned error = 0x%x", status); - - if (cctxt->status.mask & VCD_EOS_PREV_VALID) { - cctxt->status.eos_prev_op_frm.vcd_frm.flags |= - VCD_FRAME_FLAG_EOS; - - rc = vcd_handle_frame_done(cctxt, - (void *)&cctxt->status. - eos_prev_op_frm, - VCD_EVT_RESP_OUTPUT_DONE, - cctxt->status. - eos_prev_op_frm_status); - cctxt->status.mask &= ~VCD_EOS_PREV_VALID; - if (!VCD_FAILED(rc) && - cctxt->status.eos_prev_op_frm_status != - VCD_ERR_INTRLCD_FIELD_DROP) - sent_eos_frm = true; - } - if (!sent_eos_frm) { - if (transc->ip_buf_entry) { - transc->ip_buf_entry->frame.ip_frm_tag = - transc->ip_frm_tag; - - vcd_send_frame_done_in_eos(cctxt, - &transc->ip_buf_entry->frame, false); - } else { - memset(&vcd_frm, 0, sizeof(struct vcd_frame_data)); - vcd_frm.ip_frm_tag = transc->ip_frm_tag; - vcd_frm.time_stamp = transc->time_stamp; - vcd_frm.flags = VCD_FRAME_FLAG_EOS; - vcd_send_frame_done_in_eos(cctxt, &vcd_frm, true); - } - } - if (VCD_FAILED(rc)) - return; - if (transc->ip_buf_entry) { - if (transc->ip_buf_entry->frame.virtual) { - transc->ip_buf_entry->frame.ip_frm_tag = - transc->ip_frm_tag; - cctxt->callback(VCD_EVT_RESP_INPUT_DONE, - VCD_S_SUCCESS, - &transc->ip_buf_entry->frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - } - transc->ip_buf_entry->in_use = false; - VCD_BUFFERPOOL_INUSE_DECREMENT(cctxt->in_buf_pool.in_use); - transc->ip_buf_entry = NULL; - if (cctxt->status.frame_submitted) - cctxt->status.frame_submitted--; - else - cctxt->status.frame_delayed--; - } - - vcd_release_trans_tbl_entry(transc); - if (cctxt->status.mask & VCD_FLUSH_ALL) - vcd_process_pending_flush_in_eos(cctxt); - - if (cctxt->status.mask & VCD_STOP_PENDING) { - vcd_process_pending_stop_in_eos(cctxt); - } else if (!(cctxt->status.mask & VCD_EOS_WAIT_OP_BUF)) { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER - (clnt_cb)); - } -} - -void vcd_handle_start_done(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status) -{ - cctxt->status.cmd_submitted--; - vcd_mark_command_channel(cctxt->dev_ctxt, transc); - - if (!VCD_FAILED(status)) { - cctxt->callback(VCD_EVT_RESP_START, status, NULL, - 0, cctxt, cctxt->client_data); - - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_RUN, - CLIENT_STATE_EVENT_NUMBER(clnt_cb)); - } else { - VCD_MSG_ERROR("ddl callback returned failure." - "status = 0x%x", status); - vcd_handle_err_in_starting(cctxt, status); - } -} - -void vcd_handle_stop_done(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status) -{ - - VCD_MSG_LOW("vcd_handle_stop_done:"); - cctxt->status.cmd_submitted--; - vcd_mark_command_channel(cctxt->dev_ctxt, transc); - - if (!VCD_FAILED(status)) { - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_OPEN, - CLIENT_STATE_EVENT_NUMBER(clnt_cb)); - } else { - VCD_MSG_FATAL("STOP_DONE returned error = 0x%x", status); - status = VCD_ERR_HW_FATAL; - vcd_handle_device_err_fatal(cctxt->dev_ctxt, cctxt); - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_INVALID, - CLIENT_STATE_EVENT_NUMBER(clnt_cb)); - } - - cctxt->callback(VCD_EVT_RESP_STOP, status, NULL, 0, cctxt, - cctxt->client_data); - - memset(&cctxt->status, 0, sizeof(struct vcd_clnt_status)); -} - -void vcd_handle_stop_done_in_starting(struct vcd_clnt_ctxt - *cctxt, struct vcd_transc *transc, u32 status) -{ - VCD_MSG_LOW("vcd_handle_stop_done_in_starting:"); - cctxt->status.cmd_submitted--; - vcd_mark_command_channel(cctxt->dev_ctxt, transc); - if (!VCD_FAILED(status)) { - cctxt->callback(VCD_EVT_RESP_START, cctxt->status. - last_err, NULL, 0, cctxt, cctxt->client_data); - vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_OPEN, - CLIENT_STATE_EVENT_NUMBER(clnt_cb)); - } else { - VCD_MSG_FATAL("VCD Cleanup: STOP_DONE returned error " - "= 0x%x", status); - vcd_handle_err_fatal(cctxt, VCD_EVT_RESP_START, - VCD_ERR_HW_FATAL); - } -} - -void vcd_handle_stop_done_in_invalid(struct vcd_clnt_ctxt *cctxt, - struct vcd_transc *transc, u32 status) -{ - u32 rc; - VCD_MSG_LOW("vcd_handle_stop_done_in_invalid:"); - - cctxt->status.cmd_submitted--; - vcd_mark_command_channel(cctxt->dev_ctxt, transc); - - if (!VCD_FAILED(status)) { - vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CLIENT_CLOSE); - if (cctxt->status.frame_submitted) { - vcd_release_multiple_frame_channels(cctxt->dev_ctxt, - cctxt->status.frame_submitted); - - cctxt->status.frame_submitted = 0; - cctxt->status.frame_delayed = 0; - } - if (cctxt->status.cmd_submitted) { - vcd_release_multiple_command_channels( - cctxt->dev_ctxt, - cctxt->status.cmd_submitted); - cctxt->status.cmd_submitted = 0; - } - } else { - VCD_MSG_FATAL("VCD Cleanup: STOP_DONE returned error " - "= 0x%x", status); - vcd_handle_device_err_fatal(cctxt->dev_ctxt, cctxt); - cctxt->status.mask &= ~VCD_CLEANING_UP; - } - vcd_flush_buffers_in_err_fatal(cctxt); - VCD_MSG_HIGH("VCD cleanup: All buffers are returned"); - if (cctxt->status.mask & VCD_STOP_PENDING) { - cctxt->callback(VCD_EVT_RESP_STOP, VCD_S_SUCCESS, NULL, 0, - cctxt, cctxt->client_data); - cctxt->status.mask &= ~VCD_STOP_PENDING; - } - rc = vcd_power_event(cctxt->dev_ctxt, cctxt, - VCD_EVT_PWR_CLNT_ERRFATAL); - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("VCD_EVT_PWR_CLNT_ERRFATAL failed"); - if (!(cctxt->status.mask & VCD_CLEANING_UP) && - cctxt->status.mask & VCD_CLOSE_PENDING) { - vcd_destroy_client_context(cctxt); - vcd_handle_for_last_clnt_close(cctxt->dev_ctxt, false); - } -} - -u32 vcd_handle_input_frame( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *input_frame) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - struct vcd_buffer_entry *buf_entry, *orig_frame; - struct vcd_frame_data *frm_entry; - u32 rc = VCD_S_SUCCESS; - u32 eos_handled = false; - - VCD_MSG_LOW("vcd_handle_input_frame:"); - - VCD_MSG_LOW("input buffer: addr=(0x%p), sz=(%d), len=(%d)", - input_frame->virtual, input_frame->alloc_len, - input_frame->data_len); - - if (!input_frame->virtual && - !(input_frame->flags & VCD_FRAME_FLAG_EOS)) { - VCD_MSG_ERROR("Bad frame ptr/len/EOS combination"); - return VCD_ERR_ILLEGAL_PARM; - } - - - if (!input_frame->data_len && - !(input_frame->flags & VCD_FRAME_FLAG_EOS)) { - VCD_MSG_MED("data_len = 0, returning INPUT DONE"); - cctxt->callback(VCD_EVT_RESP_INPUT_DONE, - VCD_ERR_INPUT_NOT_PROCESSED, - input_frame, - sizeof(struct vcd_frame_data), - cctxt, cctxt->client_data); - return VCD_S_SUCCESS; - } - - if (!(cctxt->status.mask & VCD_FIRST_IP_RCVD)) { - if (cctxt->decoding) - rc = vcd_handle_first_decode_frame(cctxt); - - if (!VCD_FAILED(rc)) { - cctxt->status.first_ts = input_frame->time_stamp; - cctxt->status.prev_ts = cctxt->status.first_ts; - - cctxt->status.mask |= VCD_FIRST_IP_RCVD; - - (void)vcd_power_event(cctxt->dev_ctxt, - cctxt, - VCD_EVT_PWR_CLNT_FIRST_FRAME); - } - } - VCD_FAILED_RETURN(rc, "Failed: First frame handling"); - - orig_frame = vcd_find_buffer_pool_entry(&cctxt->in_buf_pool, - input_frame->virtual); - if (!orig_frame) { - VCD_MSG_ERROR("Bad buffer addr: %p", input_frame->virtual); - return VCD_ERR_FAIL; - } - - if (orig_frame->in_use) { - /* - * This path only allowed for enc., dec. not allowed - * to queue same buffer multiple times - */ - if (cctxt->decoding) { - VCD_MSG_ERROR("An inuse input frame is being " - "re-queued to scheduler"); - return VCD_ERR_FAIL; - } - - buf_entry = kzalloc(sizeof(*buf_entry), GFP_KERNEL); - if (!buf_entry) { - VCD_MSG_ERROR("Unable to alloc memory"); - return VCD_ERR_FAIL; - } - - INIT_LIST_HEAD(&buf_entry->sched_list); - /* - * Pre-emptively poisoning this, as these dupe entries - * shouldn't get added to any list - */ - INIT_LIST_HEAD(&buf_entry->list); - buf_entry->list.next = LIST_POISON1; - buf_entry->list.prev = LIST_POISON2; - - buf_entry->valid = orig_frame->valid; - buf_entry->alloc = orig_frame->alloc; - buf_entry->virtual = orig_frame->virtual; - buf_entry->physical = orig_frame->physical; - buf_entry->sz = orig_frame->sz; - buf_entry->allocated = orig_frame->allocated; - buf_entry->in_use = 1; /* meaningless for the dupe buffers */ - buf_entry->frame = orig_frame->frame; - } else - buf_entry = orig_frame; - - if (input_frame->alloc_len > buf_entry->sz) { - VCD_MSG_ERROR("Bad buffer Alloc_len %d, Actual sz=%d", - input_frame->alloc_len, buf_entry->sz); - - return VCD_ERR_ILLEGAL_PARM; - } - - frm_entry = &buf_entry->frame; - - *frm_entry = *input_frame; - frm_entry->physical = buf_entry->physical; - - if (input_frame->flags & VCD_FRAME_FLAG_EOS) { - rc = vcd_handle_recvd_eos(cctxt, input_frame, - &eos_handled); - } - - if (VCD_FAILED(rc) || eos_handled) { - VCD_MSG_HIGH("rc = 0x%x, eos_handled = %d", rc, - eos_handled); - - return rc; - } - rc = vcd_sched_queue_buffer( - cctxt->sched_clnt_hdl, buf_entry, true); - VCD_FAILED_RETURN(rc, "Failed: vcd_sched_queue_buffer"); - - orig_frame->in_use++; - cctxt->in_buf_pool.in_use++; - vcd_try_submit_frame(dev_ctxt); - return rc; -} - -void vcd_release_all_clnt_frm_transc(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 i, cntr = 0; - VCD_MSG_LOW("vcd_release_all_clnt_frm_transc:"); - for (i = 0; i < dev_ctxt->trans_tbl_size; i++) { - if (dev_ctxt->trans_tbl[i].in_use && - cctxt == dev_ctxt->trans_tbl[i].cctxt) { - if (dev_ctxt->trans_tbl[i]. - type == VCD_CMD_CODE_FRAME || - dev_ctxt->trans_tbl[i]. - type == VCD_CMD_NONE) { - vcd_release_trans_tbl_entry(&dev_ctxt-> - trans_tbl[i]); - } else { - VCD_MSG_LOW("vcd_transaction in use type(%u)", - dev_ctxt->trans_tbl[i].type); - cntr++; - } - } - } - if (cntr) - VCD_MSG_ERROR("vcd_transactions still in use: (%d)", cntr); -} - -void vcd_release_all_clnt_transc(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; - u32 i; - - VCD_MSG_LOW("vcd_release_all_clnt_transc:"); - - for (i = 0; i < dev_ctxt->trans_tbl_size; i++) { - if (dev_ctxt->trans_tbl[i].in_use && - cctxt == dev_ctxt->trans_tbl[i].cctxt) { - vcd_release_trans_tbl_entry( - &dev_ctxt->trans_tbl[i]); - } - } -} - -void vcd_send_flush_done(struct vcd_clnt_ctxt *cctxt, u32 status) -{ - VCD_MSG_LOW("vcd_send_flush_done:"); - - if (cctxt->status.mask & VCD_FLUSH_INPUT) { - cctxt->callback(VCD_EVT_RESP_FLUSH_INPUT_DONE, - status, NULL, 0, cctxt, cctxt->client_data); - cctxt->status.mask &= ~VCD_FLUSH_INPUT; - } - - if (cctxt->status.mask & VCD_FLUSH_OUTPUT) { - cctxt->callback(VCD_EVT_RESP_FLUSH_OUTPUT_DONE, - status, NULL, 0, cctxt, cctxt->client_data); - cctxt->status.mask &= ~VCD_FLUSH_OUTPUT; - } -} - -u32 vcd_store_seq_hdr( - struct vcd_clnt_ctxt *cctxt, - struct vcd_sequence_hdr *seq_hdr) -{ - u32 rc; - struct vcd_property_hdr prop_hdr; - u32 align; - u8 *virtual_aligned; - u32 addr; - int ret = 0; - - if (!seq_hdr->sequence_header_len - || !seq_hdr->sequence_header) { - VCD_MSG_ERROR("Bad seq hdr"); - - return VCD_ERR_BAD_POINTER; - } - - if (cctxt->seq_hdr.sequence_header) { - VCD_MSG_HIGH("Old seq hdr detected"); - - vcd_pmem_free(cctxt->seq_hdr.sequence_header, - cctxt->seq_hdr_phy_addr, cctxt); - cctxt->seq_hdr.sequence_header = NULL; - } - - cctxt->seq_hdr.sequence_header_len = - seq_hdr->sequence_header_len; - - prop_hdr.prop_id = DDL_I_SEQHDR_ALIGN_BYTES; - prop_hdr.sz = sizeof(u32); - - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &align); - - VCD_FAILED_RETURN(rc, - "Failed: ddl_get_property DDL_I_SEQHDR_ALIGN_BYTES"); - - VCD_MSG_MED("Seq hdr alignment bytes = %d", align); - - ret = vcd_pmem_alloc(cctxt->seq_hdr.sequence_header_len + align + - VCD_SEQ_HDR_PADDING_BYTES, - &(cctxt->seq_hdr.sequence_header), - &(cctxt->seq_hdr_phy_addr), cctxt); - - if (ret < 0) { - VCD_MSG_ERROR("Seq hdr allocation failed"); - - return VCD_ERR_ALLOC_FAIL; - } - - if (!cctxt->seq_hdr_phy_addr) { - VCD_MSG_ERROR("Couldn't get physical address"); - - return VCD_ERR_BAD_POINTER; - } - - if (align > 0) { - addr = (u32) cctxt->seq_hdr_phy_addr; - addr += align; - addr -= (addr % align); - virtual_aligned = cctxt->seq_hdr.sequence_header; - virtual_aligned += (u32) (addr - - (u32) cctxt->seq_hdr_phy_addr); - cctxt->seq_hdr_phy_addr = (u8 *) addr; - } else { - virtual_aligned = cctxt->seq_hdr.sequence_header; - } - - memcpy(virtual_aligned, seq_hdr->sequence_header, - seq_hdr->sequence_header_len); - - return VCD_S_SUCCESS; -} - -u32 vcd_set_frame_rate( - struct vcd_clnt_ctxt *cctxt, - struct vcd_property_frame_rate *fps) -{ - u32 rc; - cctxt->frm_rate = *fps; - rc = vcd_update_clnt_perf_lvl(cctxt, &cctxt->frm_rate, - cctxt->frm_p_units); - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_update_clnt_perf_lvl", - rc); - } - rc = vcd_sched_update_config(cctxt); - return rc; -} - -u32 vcd_req_perf_level( - struct vcd_clnt_ctxt *cctxt, - struct vcd_property_perf_level *perf_level) -{ - u32 rc; - u32 res_trk_perf_level; - u32 turbo_perf_level; - if (!perf_level) { - VCD_MSG_ERROR("Invalid parameters\n"); - return -EINVAL; - } - res_trk_perf_level = get_res_trk_perf_level(perf_level->level); - if (res_trk_perf_level < 0) { - rc = -ENOTSUPP; - goto perf_level_not_supp; - } - turbo_perf_level = get_res_trk_perf_level(VCD_PERF_LEVEL_TURBO); - rc = vcd_set_perf_level(cctxt->dev_ctxt, res_trk_perf_level); - if (!rc) { - cctxt->reqd_perf_lvl = res_trk_perf_level; - cctxt->perf_set_by_client = 1; - if (res_trk_perf_level == turbo_perf_level) - cctxt->is_turbo_enabled = true; - } -perf_level_not_supp: - return rc; -} - -u32 vcd_set_frame_size( - struct vcd_clnt_ctxt *cctxt, - struct vcd_property_frame_size *frm_size) -{ - struct vcd_property_hdr prop_hdr; - u32 rc; - u32 frm_p_units; - (void)frm_size; - if (res_trk_get_disable_fullhd() && frm_size && - (frm_size->width * frm_size->height > 1280 * 720)) { - VCD_MSG_ERROR("Frame size = %dX%d greater than 1280X720 not" - "supported", frm_size->width, frm_size->height); - return VCD_ERR_FAIL; - } - prop_hdr.prop_id = DDL_I_FRAME_PROC_UNITS; - prop_hdr.sz = sizeof(frm_p_units); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &frm_p_units); - VCD_FAILED_RETURN(rc, "Failed: Get DDL_I_FRAME_PROC_UNITS"); - - cctxt->frm_p_units = frm_p_units; - - rc = vcd_update_clnt_perf_lvl(cctxt, &cctxt->frm_rate, - frm_p_units); - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_update_clnt_perf_lvl", - rc); - } - return rc; -} - -void vcd_process_pending_flush_in_eos(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - VCD_MSG_HIGH("Buffer flush is pending"); - rc = vcd_flush_buffers(cctxt, cctxt->status.mask & VCD_FLUSH_ALL); - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_flush_buffers", rc); - cctxt->status.mask &= ~VCD_EOS_WAIT_OP_BUF; - vcd_send_flush_done(cctxt, VCD_S_SUCCESS); -} - -void vcd_process_pending_stop_in_eos(struct vcd_clnt_ctxt *cctxt) -{ - u32 rc = VCD_S_SUCCESS; - rc = vcd_flush_buffers(cctxt, VCD_FLUSH_ALL); - if (VCD_FAILED(rc)) - VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_flush_buffers", rc); - VCD_MSG_HIGH("All buffers are returned. Enqueuing stop cmd"); - vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CODEC_STOP); - cctxt->status.mask &= ~VCD_STOP_PENDING; - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_STOPPING, - CLIENT_STATE_EVENT_NUMBER(stop)); -} - -u32 vcd_calculate_frame_delta( - struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *frame) -{ - u32 frm_delta; - u64 temp, max = ~((u64)0); - - if (cctxt->time_frame_delta) - temp = cctxt->time_frame_delta; - else if (frame->time_stamp >= cctxt->status.prev_ts) - temp = frame->time_stamp - cctxt->status.prev_ts; - else - temp = (max - cctxt->status.prev_ts) + - frame->time_stamp; - - VCD_MSG_LOW("Curr_ts=%lld Prev_ts=%lld Diff=%llu\n", - frame->time_stamp, cctxt->status.prev_ts, temp); - - temp *= cctxt->time_resoln; - (void)do_div(temp, VCD_TIMESTAMP_RESOLUTION); - frm_delta = temp; - cctxt->status.time_elapsed += frm_delta; - - temp = (cctxt->status.time_elapsed * VCD_TIMESTAMP_RESOLUTION); - (void)do_div(temp, cctxt->time_resoln); - cctxt->status.prev_ts = cctxt->status.first_ts + temp; - - VCD_MSG_LOW("Time_elapsed=%llu, Drift=%llu, new Prev_ts=%lld", - cctxt->status.time_elapsed, temp, - cctxt->status.prev_ts); - - return frm_delta; -} - -struct vcd_buffer_entry *vcd_check_fill_output_buffer - (struct vcd_clnt_ctxt *cctxt, - struct vcd_frame_data *buffer) { - struct vcd_buffer_pool *buf_pool = &cctxt->out_buf_pool; - struct vcd_buffer_entry *buf_entry; - - if (!buf_pool->entries) { - VCD_MSG_ERROR("Buffers not set or allocated yet"); - - return NULL; - } - - if (!buffer->virtual) { - VCD_MSG_ERROR("NULL buffer address provided"); - return NULL; - } - - buf_entry = - vcd_find_buffer_pool_entry(buf_pool, buffer->virtual); - if (!buf_entry) { - VCD_MSG_ERROR("Unrecognized buffer address provided = %p", - buffer->virtual); - return NULL; - } - - if (buf_entry->in_use) { - VCD_MSG_ERROR - ("An inuse output frame is being provided for reuse"); - return NULL; - } - - if ((buffer->alloc_len < buf_pool->buf_req.sz || - buffer->alloc_len > buf_entry->sz) && - !(cctxt->status.mask & VCD_IN_RECONFIG)) { - VCD_MSG_ERROR - ("Bad buffer Alloc_len = %d, Actual sz = %d, " - " Min sz = %u", - buffer->alloc_len, buf_entry->sz, - buf_pool->buf_req.sz); - return NULL; - } - - return buf_entry; -} - -void vcd_handle_ind_hw_err_fatal(struct vcd_clnt_ctxt *cctxt, - u32 event, u32 status) -{ - if (cctxt->status.frame_submitted) { - cctxt->status.frame_submitted--; - vcd_mark_frame_channel(cctxt->dev_ctxt); - } - vcd_handle_err_fatal(cctxt, event, status); -} - -void vcd_handle_err_fatal(struct vcd_clnt_ctxt *cctxt, u32 event, - u32 status) -{ - VCD_MSG_LOW("vcd_handle_err_fatal: event=%x, err=%x", event, status); - if (!VCD_FAILED_FATAL(status)) - return; - - if (VCD_FAILED_DEVICE_FATAL(status)) { - vcd_clnt_handle_device_err_fatal(cctxt, event); - vcd_handle_device_err_fatal(cctxt->dev_ctxt, cctxt); - } else if (VCD_FAILED_CLIENT_FATAL(status)) { - cctxt->status.last_evt = event; - cctxt->callback(event, VCD_ERR_HW_FATAL, NULL, 0, cctxt, - cctxt->client_data); - cctxt->status.mask |= VCD_CLEANING_UP; - vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CODEC_STOP); - vcd_do_client_state_transition(cctxt, - VCD_CLIENT_STATE_INVALID, - CLIENT_STATE_EVENT_NUMBER(clnt_cb)); - } -} - -void vcd_handle_err_in_starting(struct vcd_clnt_ctxt *cctxt, - u32 status) -{ - VCD_MSG_LOW("\n vcd_handle_err_in_starting:"); - if (VCD_FAILED_FATAL(status)) { - vcd_handle_err_fatal(cctxt, VCD_EVT_RESP_START, status); - } else { - cctxt->status.last_err = status; - VCD_MSG_HIGH("\n VCD cleanup: Enqueuing stop cmd"); - vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CODEC_STOP); - } -} - -void vcd_handle_trans_pending(struct vcd_clnt_ctxt *cctxt) -{ - if (!cctxt->status.frame_submitted) { - VCD_MSG_ERROR("Transaction pending response was not expected"); - return; - } - cctxt->status.frame_submitted--; - cctxt->status.frame_delayed++; - vcd_mark_frame_channel(cctxt->dev_ctxt); -} -void vcd_handle_submit_frame_failed(struct vcd_dev_ctxt - *dev_ctxt, struct vcd_transc *transc) -{ - struct vcd_clnt_ctxt *cctxt = transc->cctxt; - u32 rc; - - vcd_mark_frame_channel(dev_ctxt); - vcd_release_trans_tbl_entry(transc); - - vcd_handle_err_fatal(cctxt, VCD_EVT_IND_HWERRFATAL, - VCD_ERR_CLIENT_FATAL); - - if (vcd_get_command_channel(dev_ctxt, &transc)) { - transc->type = VCD_CMD_CODEC_STOP; - transc->cctxt = cctxt; - rc = vcd_submit_cmd_sess_end(transc); - if (VCD_FAILED(rc)) { - vcd_release_command_channel(dev_ctxt, transc); - VCD_MSG_ERROR("rc = 0x%x. Failed: VCD_SubmitCmdSessEnd", - rc); - } - } -} - -u32 vcd_check_if_buffer_req_met(struct vcd_clnt_ctxt *cctxt, - enum vcd_buffer_type buffer) -{ - struct vcd_property_hdr prop_hdr; - struct vcd_buffer_pool *buf_pool; - struct vcd_buffer_requirement buf_req; - u32 rc; - u8 i; - - if (buffer == VCD_BUFFER_INPUT) { - prop_hdr.prop_id = DDL_I_INPUT_BUF_REQ; - buf_pool = &cctxt->in_buf_pool; - } else { - prop_hdr.prop_id = DDL_I_OUTPUT_BUF_REQ; - buf_pool = &cctxt->out_buf_pool; - } - - prop_hdr.sz = sizeof(buf_req); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &buf_req); - VCD_FAILED_RETURN(rc, "Failed: ddl_GetProperty"); - - buf_pool->buf_req = buf_req; - if (buf_pool->count < buf_req.actual_count) { - VCD_MSG_ERROR("Buf requirement count not met"); - return VCD_ERR_FAIL; - } - - if (buf_pool->count > buf_req.actual_count) - buf_pool->count = buf_req.actual_count; - - if (!buf_pool->entries || - buf_pool->validated != buf_pool->count) { - VCD_MSG_ERROR("Buffer pool is not completely setup yet"); - return VCD_ERR_BAD_STATE; - } - for (i = 1; (rc == VCD_S_SUCCESS && i <= buf_pool->count); i++) { - if (buf_pool->entries[i].sz < - buf_pool->buf_req.sz) { - VCD_MSG_ERROR( - "BufReq sz not met:\ - addr=(0x%p) sz=%d ReqSize=%d", - buf_pool->entries[i].virtual, - buf_pool->entries[i].sz, - buf_pool->buf_req.sz); - rc = VCD_ERR_FAIL; - } - } - return rc; -} - -u32 vcd_handle_ind_output_reconfig( - struct vcd_clnt_ctxt *cctxt, void* payload, u32 status) -{ - struct ddl_frame_data_tag *frame = - (struct ddl_frame_data_tag *)payload; - struct vcd_property_hdr prop_hdr; - u32 rc = VCD_S_SUCCESS; - struct vcd_buffer_pool *out_buf_pool; - struct vcd_buffer_requirement buf_req; - - if (frame) - rc = vcd_handle_output_required(cctxt, payload, status); - VCD_FAILED_RETURN(rc, "Failed: vcd_handle_output_required in reconfig"); - vcd_mark_frame_channel(cctxt->dev_ctxt); - - rc = vcd_sched_suspend_resume_clnt(cctxt, false); - VCD_FAILED_RETURN(rc, "Failed: vcd_sched_suspend_resume_clnt"); - out_buf_pool = &cctxt->out_buf_pool; - prop_hdr.prop_id = DDL_I_OUTPUT_BUF_REQ; - prop_hdr.sz = sizeof(buf_req); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, &buf_req); - VCD_FAILED_RETURN(rc, "Failed: ddl_GetProperty"); - - out_buf_pool->buf_req = buf_req; - - if (out_buf_pool->count < buf_req.actual_count) { - VCD_MSG_HIGH("Output buf requirement count increased"); - out_buf_pool->count = buf_req.actual_count; - } - - if (buf_req.actual_count > VCD_MAX_BUFFER_ENTRIES) { - VCD_MSG_ERROR("\n New act count exceeds Max count(32)"); - return VCD_ERR_FAIL; - } - - if (!VCD_FAILED(rc)) { - rc = vcd_set_frame_size(cctxt, NULL); - VCD_FAILED_RETURN(rc, "Failed: set_frame_size in reconfig"); - cctxt->status.mask &= ~VCD_FIRST_OP_RCVD; - cctxt->status.mask |= VCD_IN_RECONFIG; - cctxt->callback(VCD_EVT_IND_OUTPUT_RECONFIG, - status, NULL, 0, cctxt, - cctxt->client_data); - } - return rc; -} - -u32 vcd_handle_ind_output_reconfig_in_flushing( - struct vcd_clnt_ctxt *cctxt, void* payload, u32 status) -{ - u32 rc = VCD_S_SUCCESS; - if (cctxt->status.mask & VCD_FLUSH_INPUT && payload) { - (void)vcd_handle_input_done(cctxt, payload, - VCD_EVT_RESP_INPUT_FLUSHED, status); - payload = NULL; - } - rc = vcd_handle_ind_output_reconfig(cctxt, payload, status); - return rc; -} - -u32 vcd_return_op_buffer_to_hw(struct vcd_clnt_ctxt *cctxt, - struct vcd_buffer_entry *buf_entry) -{ - u32 rc = VCD_S_SUCCESS; - struct vcd_frame_data *frm_entry = &buf_entry->frame; - - VCD_MSG_LOW("vcd_return_op_buffer_to_hw in %d:", - cctxt->clnt_state.state); - frm_entry->physical = buf_entry->physical; - frm_entry->ip_frm_tag = VCD_FRAMETAG_INVALID; - frm_entry->intrlcd_ip_frm_tag = VCD_FRAMETAG_INVALID; - frm_entry->data_len = 0; - - if (cctxt->decoding) { - struct vcd_property_hdr Prop_hdr; - struct ddl_frame_data_tag ddl_frm; - Prop_hdr.prop_id = DDL_I_DPB_RELEASE; - Prop_hdr.sz = - sizeof(struct ddl_frame_data_tag); - memset(&ddl_frm, 0, sizeof(ddl_frm)); - ddl_frm.vcd_frm = *frm_entry; - rc = ddl_set_property(cctxt->ddl_handle, &Prop_hdr, - &ddl_frm); - if (VCD_FAILED(rc)) { - VCD_MSG_ERROR("Error returning output buffer to" - " HW. rc = 0x%x", rc); - buf_entry->in_use = false; - } else { - cctxt->out_buf_pool.in_use++; - buf_entry->in_use = true; - } - } - return rc; -} - -void vcd_handle_clnt_fatal(struct vcd_clnt_ctxt *cctxt, u32 trans_end) -{ - if (trans_end) - vcd_mark_frame_channel(cctxt->dev_ctxt); - vcd_handle_err_fatal(cctxt, - VCD_EVT_IND_HWERRFATAL, VCD_ERR_CLIENT_FATAL); -} - -void vcd_handle_clnt_fatal_input_done(struct vcd_clnt_ctxt *cctxt, - u32 trans_end) -{ - if (cctxt->status.frame_submitted > 0) - cctxt->status.frame_submitted--; - vcd_handle_clnt_fatal(cctxt, trans_end); -} - -void vcd_handle_ind_info_output_reconfig( - struct vcd_clnt_ctxt *cctxt, u32 status) -{ - if (cctxt) { - cctxt->callback(VCD_EVT_IND_INFO_OUTPUT_RECONFIG, status, NULL, - 0, cctxt, cctxt->client_data); - } -} - -u32 vcd_set_num_slices(struct vcd_clnt_ctxt *cctxt) -{ - struct vcd_property_hdr prop_hdr; - struct vcd_property_slice_delivery_info slice_delivery_info; - u32 rc = VCD_S_SUCCESS; - prop_hdr.prop_id = VCD_I_SLICE_DELIVERY_MODE; - prop_hdr.sz = - sizeof(struct vcd_property_slice_delivery_info); - rc = ddl_get_property(cctxt->ddl_handle, &prop_hdr, - &slice_delivery_info); - VCD_FAILED_RETURN(rc, "Failed: Get VCD_I_SLICE_DELIVERY_MODE"); - if (slice_delivery_info.enable) { - cctxt->num_slices = slice_delivery_info.num_slices; - VCD_MSG_LOW("%s slice delivery mode num_slices = %u\n", - __func__, cctxt->num_slices); - } else { - cctxt->num_slices = 1; - } - return rc; -} - -u32 vcd_handle_ltr_use_failed(struct vcd_clnt_ctxt *cctxt, - void *payload, size_t sz, u32 status) -{ - u32 rc = VCD_S_SUCCESS; - if (payload && cctxt) { - cctxt->callback(VCD_EVT_IND_INFO_LTRUSE_FAILED, - status, payload, sz, cctxt, cctxt->client_data); - } - return rc; -} diff --git a/drivers/video/msm/vidc/common/vcd/vcd_util.c b/drivers/video/msm/vidc/common/vcd/vcd_util.c deleted file mode 100644 index 98bc7f553e96ce4a5c4f1f3620c57881a2a6a4c1..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_util.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (c) 2010, 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 "vidc_type.h" -#include "vcd_util.h" - -u32 vcd_critical_section_create(u32 **p_cs) -{ - struct mutex *lock; - if (!p_cs) { - VCD_MSG_ERROR("Bad critical section ptr"); - return VCD_ERR_BAD_POINTER; - } else { - lock = kmalloc(sizeof(struct mutex), GFP_KERNEL); - if (!lock) { - VCD_MSG_ERROR("Failed: vcd_critical_section_create"); - return VCD_ERR_ALLOC_FAIL; - } - mutex_init(lock); - *p_cs = (u32 *) lock; - return VCD_S_SUCCESS; - } -} - -u32 vcd_critical_section_release(u32 *cs) -{ - struct mutex *lock = (struct mutex *)cs; - if (!lock) { - VCD_MSG_ERROR("Bad critical section object"); - return VCD_ERR_BAD_POINTER; - } - - mutex_destroy(lock); - kfree(cs); - return VCD_S_SUCCESS; -} - -u32 vcd_critical_section_enter(u32 *cs) -{ - struct mutex *lock = (struct mutex *)cs; - if (!lock) { - VCD_MSG_ERROR("Bad critical section object"); - return VCD_ERR_BAD_POINTER; - } else - mutex_lock(lock); - - return VCD_S_SUCCESS; -} - -u32 vcd_critical_section_leave(u32 *cs) -{ - struct mutex *lock = (struct mutex *)cs; - - if (!lock) { - VCD_MSG_ERROR("Bad critical section object"); - - return VCD_ERR_BAD_POINTER; - } else - mutex_unlock(lock); - - return VCD_S_SUCCESS; -} - -int vcd_pmem_alloc(u32 size, u8 **kernel_vaddr, u8 **phy_addr) -{ - *phy_addr = - (u8 *) pmem_kalloc(size, PMEM_MEMTYPE | PMEM_ALIGNMENT_4K); - - if (!IS_ERR((void *)*phy_addr)) { - - *kernel_vaddr = ioremap((unsigned long)*phy_addr, size); - - if (!*kernel_vaddr) { - pr_err("%s: could not ioremap in kernel pmem buffers\n", - __func__); - pmem_kfree((s32) *phy_addr); - return -ENOMEM; - } - pr_debug("write buf: phy addr 0x%08x kernel addr 0x%08x\n", - (u32) *phy_addr, (u32) *kernel_vaddr); - return 0; - } else { - pr_err("%s: could not allocte in kernel pmem buffers\n", - __func__); - return -ENOMEM; - } - -} - -int vcd_pmem_free(u8 *kernel_vaddr, u8 *phy_addr) -{ - iounmap((void *)kernel_vaddr); - pmem_kfree((s32) phy_addr); - - return 0; -} diff --git a/drivers/video/msm/vidc/common/vcd/vcd_util.h b/drivers/video/msm/vidc/common/vcd/vcd_util.h deleted file mode 100644 index f374ebb9930fd37f74ceb738b77addfb3e126be5..0000000000000000000000000000000000000000 --- a/drivers/video/msm/vidc/common/vcd/vcd_util.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_UTIL_H_ -#define _VCD_UTIL_H_ -#include -#include - -#if DEBUG - -#define VCD_MSG_LOW(xx_fmt...) printk(KERN_INFO "\n\t* " xx_fmt) -#define VCD_MSG_MED(xx_fmt...) printk(KERN_INFO "\n * " xx_fmt) -#define VCD_MSG_HIGH(xx_fmt...) printk(KERN_WARNING "\n" xx_fmt) -#define VCD_MSG_ERROR(xx_fmt...) printk(KERN_ERR "\n err: " xx_fmt) -#else - -#define VCD_MSG_LOW(xx_fmt...) -#define VCD_MSG_MED(xx_fmt...) -#define VCD_MSG_HIGH(xx_fmt...) -#define VCD_MSG_ERROR(xx_fmt...) -#endif - - -#define VCD_MSG_FATAL(xx_fmt...) printk(KERN_ERR "\n " xx_fmt) - -#define VCD_FAILED_RETURN(rc, xx_fmt...) \ - do { \ - if (VCD_FAILED(rc)) { \ - printk(KERN_ERR xx_fmt); \ - return rc; \ - } \ - } while (0) - -#define VCD_FAILED_DEVICE_FATAL(rc) \ - (rc == VCD_ERR_HW_FATAL ? true : false) -#define VCD_FAILED_CLIENT_FATAL(rc) \ - (rc == VCD_ERR_CLIENT_FATAL ? true : false) - -#define VCD_FAILED_FATAL(rc) \ - ((VCD_FAILED_DEVICE_FATAL(rc) || VCD_FAILED_CLIENT_FATAL(rc)) \ - ? true : false) - -#endif diff --git a/include/linux/adv7520.h b/include/linux/adv7520.h deleted file mode 100644 index f64dbdfb75b1ee53a536e96c28cfceba0615850a..0000000000000000000000000000000000000000 --- a/include/linux/adv7520.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (c) 2010, 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 _ADV7520_H_ -#define _ADV7520_H_ -#define ADV7520_DRV_NAME "adv7520" - -/* Configure the 20-bit 'N' used with the CTS to -regenerate the audio clock in the receiver -Pixel clock: 74.25 Mhz, Audio sampling: 44.1 Khz -> N -value = 6272 */ -#define ADV7520_AUDIO_CTS_20BIT_N 6272 - -#endif diff --git a/include/linux/atmel_maxtouch.h b/include/linux/atmel_maxtouch.h deleted file mode 100644 index 012e68bb3ce02da4bed57e1a0202e71e30f2e5e7..0000000000000000000000000000000000000000 --- a/include/linux/atmel_maxtouch.h +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Atmel maXTouch header file - * - * Copyright (c) 2010 Atmel Corporation - * Copyright (C) 2010 Ulf Samuelsson (ulf@atmel.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * See the file "COPYING" in the main directory of this archive - * for more details. - * - */ - -#define MXT224_I2C_ADDR1 0x4A -#define MXT224_I2C_ADDR2 0x4B -#define MXT1386_I2C_ADDR1 0x4C -#define MXT1386_I2C_ADDR2 0x4D -#define MXT1386_I2C_ADDR3 0x5A -#define MXT1386_I2C_ADDR4 0x5B - -/* - * Select this address from above depending on what maXTouch - * chip you have and how it's address pins are configured; - * see datasheet. - */ - -#define MXT_I2C_ADDRESS MXT224_I2C_ADDR2 - -#define MXT_BL_ADDRESS 0x25 - -#define MXT224_FAMILYID 0x80 -#define MXT1386_FAMILYID 0xA0 - -#define MXT224_CAL_VARIANTID 0x01 -#define MXT224_UNCAL_VARIANTID 0x00 -#define MXT1386_CAL_VARIANTID 0x00 - -#define MXT_MAX_REPORTED_WIDTH 255 -#define MXT_MAX_REPORTED_PRESSURE 255 -#define MXT_MAX_TOUCH_SIZE 255 -#define MXT_MAX_NUM_TOUCHES 10 - -/* Fixed addresses inside maXTouch device */ -#define MXT_ADDR_INFO_BLOCK 0 -#define MXT_ADDR_OBJECT_TABLE 7 -#define MXT_ID_BLOCK_SIZE 7 -#define MXT_OBJECT_TABLE_ELEMENT_SIZE 6 - -/* Object types */ -#define MXT_DEBUG_DELTAS_T2 2 -#define MXT_DEBUG_REFERENCES_T3 3 -#define MXT_GEN_MESSAGEPROCESSOR_T5 5 -#define MXT_GEN_COMMANDPROCESSOR_T6 6 -#define MXT_GEN_POWERCONFIG_T7 7 -#define MXT_GEN_ACQUIRECONFIG_T8 8 -#define MXT_TOUCH_MULTITOUCHSCREEN_T9 9 -#define MXT_TOUCH_SINGLETOUCHSCREEN_T10 10 -#define MXT_TOUCH_XSLIDER_T11 11 -#define MXT_TOUCH_YSLIDER_T12 12 -#define MXT_TOUCH_XWHEEL_T13 13 -#define MXT_TOUCH_YWHEEL_T14 14 -#define MXT_TOUCH_KEYARRAY_T15 15 -#define MXT_SPT_GPIOPWM_T19 19 -#define MXT_PROCI_GRIPFACESUPPRESSION_T20 20 -#define MXT_PROCG_NOISESUPPRESSION_T22 22 -#define MXT_TOUCH_PROXIMITY_T23 23 -#define MXT_PROCI_ONETOUCHGESTUREPROCESSOR_T24 24 -#define MXT_SPT_SELFTEST_T25 25 -#define MXT_DEBUG_CTERANGE_T26 26 -#define MXT_PROCI_TWOTOUCHGESTUREPROCESSOR_T27 27 -#define MXT_SPT_CTECONFIG_T28 28 -#define MXT_TOUCH_KEYSET_T31 31 -#define MXT_TOUCH_XSLIDERSET_T32 32 -#define MXT_DEBUG_DIAGNOSTIC_T37 37 -#define MXT_USER_INFO_T38 38 - - -/* - * If a message is read from mXT when there's no new messages available, - * the report ID of the message will be 0xFF. - */ -#define MXT_END_OF_MESSAGES 0xFF - - -/* GEN_COMMANDPROCESSOR_T6 Register offsets from T6 base address */ -#define MXT_ADR_T6_RESET 0x00 -#define MXT_ADR_T6_BACKUPNV 0x01 -#define MXT_ADR_T6_CALIBRATE 0x02 -#define MXT_ADR_T6_REPORTALL 0x03 -#define MXT_ADR_T6_RESERVED 0x04 -#define MXT_ADR_T6_DIAGNOSTIC 0x05 - -/* T6 Debug Diagnostics Commands */ -#define MXT_CMD_T6_PAGE_UP 0x01 -#define MXT_CMD_T6_PAGE_DOWN 0x02 -#define MXT_CMD_T6_DELTAS_MODE 0x10 -#define MXT_CMD_T6_REFERENCES_MODE 0x11 -#define MXT_CMD_T6_CTE_MODE 0x31 - -/* T6 Backup Command */ -#define MXT_CMD_T6_BACKUP 0x55 - -/* SPT_DEBUG_DIAGNOSTIC_T37 Register offsets from T37 base address */ -#define MXT_ADR_T37_PAGE 0x01 -#define MXT_ADR_T37_DATA 0x02 - - - -/************************************************************************ - * MESSAGE OBJECTS ADDRESS FIELDS - * - ************************************************************************/ -#define MXT_MSG_REPORTID 0x00 - - -/* MXT_GEN_MESSAGEPROCESSOR_T5 Message address definitions */ -#define MXT_MSG_T5_REPORTID 0x00 -#define MXT_MSG_T5_MESSAGE 0x01 -#define MXT_MSG_T5_CHECKSUM 0x08 - -/* MXT_GEN_COMMANDPROCESSOR_T6 Message address definitions */ -#define MXT_MSG_T6_STATUS 0x01 -#define MXT_MSGB_T6_COMSERR 0x04 -#define MXT_MSGB_T6_CFGERR 0x08 -#define MXT_MSGB_T6_CAL 0x10 -#define MXT_MSGB_T6_SIGERR 0x20 -#define MXT_MSGB_T6_OFL 0x40 -#define MXT_MSGB_T6_RESET 0x80 -/* Three bytes */ -#define MXT_MSG_T6_CHECKSUM 0x02 - -/* MXT_GEN_POWERCONFIG_T7 NO Message address definitions */ -/* MXT_GEN_ACQUIRECONFIG_T8 Message address definitions */ -/* MXT_TOUCH_MULTITOUCHSCREEN_T9 Message address definitions */ - -#define MXT_MSG_T9_STATUS 0x01 -/* Status bit field */ -#define MXT_MSGB_T9_SUPPRESS 0x02 -#define MXT_MSGB_T9_AMP 0x04 -#define MXT_MSGB_T9_VECTOR 0x08 -#define MXT_MSGB_T9_MOVE 0x10 -#define MXT_MSGB_T9_RELEASE 0x20 -#define MXT_MSGB_T9_PRESS 0x40 -#define MXT_MSGB_T9_DETECT 0x80 - -#define MXT_MSG_T9_XPOSMSB 0x02 -#define MXT_MSG_T9_YPOSMSB 0x03 -#define MXT_MSG_T9_XYPOSLSB 0x04 -#define MXT_MSG_T9_TCHAREA 0x05 -#define MXT_MSG_T9_TCHAMPLITUDE 0x06 -#define MXT_MSG_T9_TCHVECTOR 0x07 - - -/* MXT_SPT_GPIOPWM_T19 Message address definitions */ -#define MXT_MSG_T19_STATUS 0x01 - -/* MXT_PROCI_GRIPFACESUPPRESSION_T20 Message address definitions */ -#define MXT_MSG_T20_STATUS 0x01 -#define MXT_MSGB_T20_FACE_SUPPRESS 0x01 -/* MXT_PROCG_NOISESUPPRESSION_T22 Message address definitions */ -#define MXT_MSG_T22_STATUS 0x01 -#define MXT_MSGB_T22_FHCHG 0x01 -#define MXT_MSGB_T22_GCAFERR 0x04 -#define MXT_MSGB_T22_FHERR 0x08 -#define MXT_MSG_T22_GCAFDEPTH 0x02 - -/* MXT_TOUCH_PROXIMITY_T23 Message address definitions */ -#define MXT_MSG_T23_STATUS 0x01 -#define MXT_MSGB_T23_FALL 0x20 -#define MXT_MSGB_T23_RISE 0x40 -#define MXT_MSGB_T23_DETECT 0x80 -/* 16 bit */ -#define MXT_MSG_T23_PROXDELTA 0x02 - -/* MXT_PROCI_ONETOUCHGESTUREPROCESSOR_T24 Message address definitions */ -#define MXT_MSG_T24_STATUS 0x01 -#define MXT_MSG_T24_XPOSMSB 0x02 -#define MXT_MSG_T24_YPOSMSB 0x03 -#define MXT_MSG_T24_XYPOSLSB 0x04 -#define MXT_MSG_T24_DIR 0x05 -/* 16 bit */ -#define MXT_MSG_T24_DIST 0x06 - -/* MXT_SPT_SELFTEST_T25 Message address definitions */ -#define MXT_MSG_T25_STATUS 0x01 -/* 5 Bytes */ -#define MXT_MSGR_T25_OK 0xFE -#define MXT_MSGR_T25_INVALID_TEST 0xFD -#define MXT_MSGR_T25_PIN_FAULT 0x11 -#define MXT_MSGR_T25_SIGNAL_LIMIT_FAULT 0x17 -#define MXT_MSGR_T25_GAIN_ERROR 0x20 -#define MXT_MSG_T25_INFO 0x02 - -/* MXT_PROCI_TWOTOUCHGESTUREPROCESSOR_T27 Message address definitions */ -#define MXT_MSG_T27_STATUS 0x01 -#define MXT_MSGB_T27_ROTATEDIR 0x10 -#define MXT_MSGB_T27_PINCH 0x20 -#define MXT_MSGB_T27_ROTATE 0x40 -#define MXT_MSGB_T27_STRETCH 0x80 -#define MXT_MSG_T27_XPOSMSB 0x02 -#define MXT_MSG_T27_YPOSMSB 0x03 -#define MXT_MSG_T27_XYPOSLSB 0x04 -#define MXT_MSG_T27_ANGLE 0x05 - -/* 16 bit */ -#define MXT_MSG_T27_SEPARATION 0x06 - -/* MXT_SPT_CTECONFIG_T28 Message address definitions */ -#define MXT_MSG_T28_STATUS 0x01 -#define MXT_MSGB_T28_CHKERR 0x01 - - -/* One Touch Events */ -#define MXT_GESTURE_RESERVED 0x00 -#define MXT_GESTURE_PRESS 0x01 -#define MXT_GESTURE_RELEASE 0x02 -#define MXT_GESTURE_TAP 0x03 -#define MXT_GESTURE_DOUBLE_TAP 0x04 -#define MXT_GESTURE_FLICK 0x05 -#define MXT_GESTURE_DRAG 0x06 -#define MXT_GESTURE_SHORT_PRESS 0x07 -#define MXT_GESTURE_LONG_PRESS 0x08 -#define MXT_GESTURE_REPEAT_PRESS 0x09 -#define MXT_GESTURE_TAP_AND_PRESS 0x0a -#define MXT_GESTURE_THROW 0x0b - -/* Two-touch events */ -#define MXT_GESTURE_STRETCH (1 << 7) -#define MXT_GESTURE_ROTATE (1 << 6) -#define MXT_GESTURE_PINCH (1 << 5) -#define MXT_GESTURE_ROTATEDIR (1 << 4) - - - -/* Bootloader states */ -#define WAITING_BOOTLOAD_COMMAND 0xC0 -#define WAITING_FRAME_DATA 0x80 -#define APP_CRC_FAIL 0x40 -#define FRAME_CRC_CHECK 0x02 -#define FRAME_CRC_PASS 0x04 -#define FRAME_CRC_FAIL 0x03 - -#define MXT_MAX_FRAME_SIZE 276 - -/* Debug levels */ -#define DEBUG_INFO 1 -#define DEBUG_VERBOSE 2 -#define DEBUG_MESSAGES 5 -#define DEBUG_RAW 8 -#define DEBUG_TRACE 10 - -/* IOCTL commands */ -/* TODO: get correct numbers! */ -#define MXT_SET_ADDRESS_IOCTL ('x' + 1) /* Sets the internal address pointer */ -#define MXT_RESET_IOCTL ('x' + 2) /* Resets the device */ -#define MXT_CALIBRATE_IOCTL ('x' + 3) /* Calibrates the device */ -/* Backups the current state of registers to NVM */ -#define MXT_BACKUP_IOCTL ('x' + 4) -/* - * Only non-touch messages can be read from the message buffer - * (/dev/maXTouch_messages) - */ -#define MXT_NONTOUCH_MSG_IOCTL ('x' + 5) -/* All messages can be read from the message buffer */ -#define MXT_ALL_MSG_IOCTL ('x' + 6) - - -/* Message buffer size. This is a ring buffer, and when full, the oldest entry - will be overwritten. */ -#define MXT_MESSAGE_BUFFER_SIZE 128 - -/* Routines for memory access within a 16 bit address space */ - -/* TODO: - won't compile if functions aren't defined*/ -/* Bootloader specific function prototypes. */ - -#if 0 -static int mxt_read_byte_bl(struct i2c_client *client, u8 *value); -static int mxt_read_block_bl(struct i2c_client *client, u16 length, u8 *value); -static int mxt_write_byte_bl(struct i2c_client *client, u8 value); -static int mxt_write_block_bl(struct i2c_client *client, u16 length, u8 *value); -#endif - -/** - * struct maxtouch_platform_data - includes platform specific informatio - * related to Atmel maXTouch touchscreen controller. - * - * @numtouch: Number of simultaneous touches supported - * @init_platform_hw(): Initialization function, which can for example - * trigger a hardware reset by toggling a GPIO pin - * @exit_platform_hw(): Function to run when the driver is unloaded. - * @valid_interrupt(): Function that checks the validity of the interrupt - - * function that check the validity of a interrupt (by - * reading the changeline interrupt pin and checking that - * it really is low for example). - * @max_x: Reported X range - * @max_y: Reported Y range - */ - -struct maxtouch_platform_data { - u8 numtouch; /* Number of touches to report */ - int (*init_platform_hw)(struct i2c_client *client); - int (*exit_platform_hw)(struct i2c_client *client); - int display_res_x; - int display_res_y; - int min_x; - int min_y; - int max_x; /* The default reported X range */ - int max_y; /* The default reported Y range */ - u8 (*valid_interrupt) (void); - u8 (*read_chg) (void); - bool wakeup; - int (*power_on)(bool on); -}; - -void mxt_hw_reset(void); diff --git a/include/linux/csdio.h b/include/linux/csdio.h deleted file mode 100644 index 94da3dc07cb292ddc5ee661a483c1dd5387128cc..0000000000000000000000000000000000000000 --- a/include/linux/csdio.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CSDIO_H -#define CSDIO_H - -#include - -#endif diff --git a/include/linux/cyttsp-qc.h b/include/linux/cyttsp-qc.h deleted file mode 100644 index 30319c9d8bfab8bc0397173b7ba9f9a3303dfd7a..0000000000000000000000000000000000000000 --- a/include/linux/cyttsp-qc.h +++ /dev/null @@ -1,664 +0,0 @@ -/* Header file for: - * Cypress TrueTouch(TM) Standard Product touchscreen drivers. - * include/linux/cyttsp.h - * - * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc. - * - * 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Cypress reserves the right to make changes without further notice - * to the materials described herein. Cypress does not assume any - * liability arising out of the application described herein. - * - * Contact Cypress Semiconductor at www.cypress.com - * - */ - - -#ifndef __CYTTSP_H__ -#define __CYTTSP_H__ - -#include -#include -#include -#include -#include - -#define CYPRESS_TTSP_NAME "cyttsp" -#define CY_I2C_NAME "cyttsp-i2c" -#define CY_SPI_NAME "cyttsp-spi" - -#ifdef CY_DECLARE_GLOBALS - uint32_t cyttsp_tsdebug; - module_param_named(tsdebug, cyttsp_tsdebug, uint, 0664); - uint32_t cyttsp_tsxdebug; - module_param_named(tsxdebug, cyttsp_tsxdebug, uint, 0664); - - uint32_t cyttsp_disable_touch; - module_param_named(disable_touch, cyttsp_disable_touch, uint, 0664); -#else - extern uint32_t cyttsp_tsdebug; - extern uint32_t cyttsp_tsxdebug; - extern uint32_t cyttsp_disable_touch; -#endif - - - -/****************************************************************************** - * Global Control, Used to control the behavior of the driver - */ - -/* defines for Gen2 (Txx2xx); Gen3 (Txx3xx) - * use these defines to set cyttsp_platform_data.gen in board config file - */ -#define CY_GEN2 2 -#define CY_GEN3 3 - -/* define for using I2C driver - */ -#define CY_USE_I2C_DRIVER - -/* defines for using SPI driver */ -/* -#define CY_USE_SPI_DRIVER - */ -#define CY_SPI_DFLT_SPEED_HZ 1000000 -#define CY_SPI_MAX_SPEED_HZ 4000000 -#define CY_SPI_SPEED_HZ CY_SPI_DFLT_SPEED_HZ -#define CY_SPI_BITS_PER_WORD 8 -#define CY_SPI_DAV 139 /* set correct gpio id */ -#define CY_SPI_BUFSIZE 512 - -/* Voltage and Current ratings */ -#define CY_TMA300_VTG_MAX_UV 5500000 -#define CY_TMA300_VTG_MIN_UV 1710000 -#define CY_TMA300_CURR_24HZ_UA 17500 -#define CY_TMA300_SLEEP_CURR_UA 10 -#define CY_I2C_VTG_MAX_UV 1800000 -#define CY_I2C_VTG_MIN_UV 1800000 -#define CY_I2C_CURR_UA 9630 -#define CY_I2C_SLEEP_CURR_UA 10 - - -/* define for inclusion of TTSP App Update Load File - * use this define if update to the TTSP Device is desired - */ -/* -#define CY_INCLUDE_LOAD_FILE -*/ - -/* define if force new load file for bootloader load */ -/* -#define CY_FORCE_FW_UPDATE -*/ - -/* undef for production use */ -/* -#define CY_USE_DEBUG -*/ - -/* undef for irq use; use this define in the board configuration file */ -/* -#define CY_USE_TIMER - */ - -/* undef to allow use of extra debug capability */ -/* -#define CY_ALLOW_EXTRA_DEBUG -*/ - -/* undef to remove additional debug prints */ -/* -#define CY_USE_EXTRA_DEBUG -*/ - -/* undef to remove additional debug prints */ -/* -#define CY_USE_EXTRA_DEBUG1 - */ - -/* undef to use operational touch timer jiffies; else use test jiffies */ -/* - */ -#define CY_USE_TIMER_DEBUG - -/* define to use canned test data */ -/* -#define CY_USE_TEST_DATA - */ - -/* define if gesture signaling is used - * and which gesture groups to use - */ -/* -#define CY_USE_GEST -#define CY_USE_GEST_GRP1 -#define CY_USE_GEST_GRP2 -#define CY_USE_GEST_GRP3 -#define CY_USE_GEST_GRP4 - */ -/* Active distance in pixels for a gesture to be reported - * if set to 0, then all gesture movements are reported - */ -#define CY_ACT_DIST_DFLT 8 -#define CY_ACT_DIST CY_ACT_DIST_DFLT - -/* define if MT signals are desired */ -/* -*/ -#define CY_USE_MT_SIGNALS - -/* define if MT tracking id signals are used */ -/* -#define CY_USE_MT_TRACK_ID - */ - -/* define if ST signals are required */ -/* -*/ -#define CY_USE_ST_SIGNALS - -/* define to send handshake to device */ -/* -*/ -#define CY_USE_HNDSHK - -/* define if log all raw motion signals to a sysfs file */ -/* -#define CY_LOG_TO_FILE -*/ - - -/* End of the Global Control section - ****************************************************************************** - */ -#define CY_DIFF(m, n) ((m) != (n)) - -#ifdef CY_LOG_TO_FILE - #define cyttsp_openlog() /* use sysfs */ -#else - #define cyttsp_openlog() -#endif /* CY_LOG_TO_FILE */ - -/* see kernel.h for pr_xxx def'ns */ -#define cyttsp_info(f, a...) pr_info("%s:" f, __func__ , ## a) -#define cyttsp_error(f, a...) pr_err("%s:" f, __func__ , ## a) -#define cyttsp_alert(f, a...) pr_alert("%s:" f, __func__ , ## a) - -#ifdef CY_USE_DEBUG - #define cyttsp_debug(f, a...) pr_alert("%s:" f, __func__ , ## a) -#else - #define cyttsp_debug(f, a...) {if (cyttsp_tsdebug) \ - pr_alert("%s:" f, __func__ , ## a); } -#endif /* CY_USE_DEBUG */ - -#ifdef CY_ALLOW_EXTRA_DEBUG -#ifdef CY_USE_EXTRA_DEBUG - #define cyttsp_xdebug(f, a...) pr_alert("%s:" f, __func__ , ## a) -#else - #define cyttsp_xdebug(f, a...) {if (cyttsp_tsxdebug) \ - pr_alert("%s:" f, __func__ , ## a); } -#endif /* CY_USE_EXTRA_DEBUG */ - -#ifdef CY_USE_EXTRA_DEBUG1 - #define cyttsp_xdebug1(f, a...) pr_alert("%s:" f, __func__ , ## a) -#else - #define cyttsp_xdebug1(f, a...) -#endif /* CY_USE_EXTRA_DEBUG1 */ -#else - #define cyttsp_xdebug(f, a...) - #define cyttsp_xdebug1(f, a...) -#endif /* CY_ALLOW_EXTRA_DEBUG */ - -#ifdef CY_USE_TIMER_DEBUG - #define TOUCHSCREEN_TIMEOUT (msecs_to_jiffies(1000)) -#else - #define TOUCHSCREEN_TIMEOUT (msecs_to_jiffies(28)) -#endif - -/* reduce extra signals in MT only build - * be careful not to lose backward compatibility for pre-MT apps - */ -#ifdef CY_USE_ST_SIGNALS - #define CY_USE_ST 1 -#else - #define CY_USE_ST 0 -#endif /* CY_USE_ST_SIGNALS */ - -/* rely on kernel input.h to define Multi-Touch capability */ -/* if input.h defines the Multi-Touch signals, then use MT */ -#if defined(ABS_MT_TOUCH_MAJOR) && defined(CY_USE_MT_SIGNALS) - #define CY_USE_MT 1 - #define CY_MT_SYNC(input) input_mt_sync(input) -#else - #define CY_USE_MT 0 - #define CY_MT_SYNC(input) - /* the following includes are provided to ensure a compile; - * the code that compiles with these defines will not be executed if - * the CY_USE_MT is properly used in the platform structure init - */ - #ifndef ABS_MT_TOUCH_MAJOR - #define ABS_MT_TOUCH_MAJOR 0x30 /* touching ellipse */ - #define ABS_MT_TOUCH_MINOR 0x31 /* (omit if circular) */ - #define ABS_MT_WIDTH_MAJOR 0x32 /* approaching ellipse */ - #define ABS_MT_WIDTH_MINOR 0x33 /* (omit if circular) */ - #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ - #define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ - #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ - #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ - #define ABS_MT_BLOB_ID 0x38 /* Group set of pkts as blob */ - #endif /* ABS_MT_TOUCH_MAJOR */ -#endif /* ABS_MT_TOUCH_MAJOR and CY_USE_MT_SIGNALS */ -#if defined(ABS_MT_TRACKING_ID) && defined(CY_USE_MT_TRACK_ID) - #define CY_USE_TRACKING_ID 1 -#else - #define CY_USE_TRACKING_ID 0 -/* define only if not defined already by system; - * value based on linux kernel 2.6.30.10 - */ -#ifndef ABS_MT_TRACKING_ID - #define ABS_MT_TRACKING_ID (ABS_MT_BLOB_ID+1) -#endif -#endif /* ABS_MT_TRACKING_ID */ - -#define CY_USE_DEEP_SLEEP_SEL 0x80 -#define CY_USE_LOW_POWER_SEL 0x01 - -#ifdef CY_USE_TEST_DATA - #define cyttsp_testdat(ray1, ray2, sizeofray) \ - { \ - int i; \ - u8 *up1 = (u8 *)ray1; \ - u8 *up2 = (u8 *)ray2; \ - for (i = 0; i < sizeofray; i++) { \ - up1[i] = up2[i]; \ - } \ - } -#else - #define cyttsp_testdat(xy, test_xy, sizeofray) -#endif /* CY_USE_TEST_DATA */ - -/* helper macros */ -#define GET_NUM_TOUCHES(x) ((x) & 0x0F) -#define GET_TOUCH1_ID(x) (((x) & 0xF0) >> 4) -#define GET_TOUCH2_ID(x) ((x) & 0x0F) -#define GET_TOUCH3_ID(x) (((x) & 0xF0) >> 4) -#define GET_TOUCH4_ID(x) ((x) & 0x0F) -#define IS_LARGE_AREA(x) (((x) & 0x10) >> 4) -#define FLIP_DATA_FLAG 0x01 -#define REVERSE_X_FLAG 0x02 -#define REVERSE_Y_FLAG 0x04 -#define FLIP_DATA(flags) ((flags) & FLIP_DATA_FLAG) -#define REVERSE_X(flags) ((flags) & REVERSE_X_FLAG) -#define REVERSE_Y(flags) ((flags) & REVERSE_Y_FLAG) -#define FLIP_XY(x, y) { \ - u16 tmp; \ - tmp = (x); \ - (x) = (y); \ - (y) = tmp; \ - } -#define INVERT_X(x, xmax) ((xmax) - (x)) -#define INVERT_Y(y, maxy) ((maxy) - (y)) -#define SET_HSTMODE(reg, mode) ((reg) & (mode)) -#define GET_HSTMODE(reg) ((reg & 0x70) >> 4) -#define GET_BOOTLOADERMODE(reg) ((reg & 0x10) >> 4) - -/* constant definitions */ -/* maximum number of concurrent ST track IDs */ -#define CY_NUM_ST_TCH_ID 2 - -/* maximum number of concurrent MT track IDs */ -#define CY_NUM_MT_TCH_ID 4 - -/* maximum number of track IDs */ -#define CY_NUM_TRK_ID 16 - -#define CY_NTCH 0 /* no touch (lift off) */ -#define CY_TCH 1 /* active touch (touchdown) */ -#define CY_ST_FNGR1_IDX 0 -#define CY_ST_FNGR2_IDX 1 -#define CY_MT_TCH1_IDX 0 -#define CY_MT_TCH2_IDX 1 -#define CY_MT_TCH3_IDX 2 -#define CY_MT_TCH4_IDX 3 -#define CY_XPOS 0 -#define CY_YPOS 1 -#define CY_IGNR_TCH (-1) -#define CY_SMALL_TOOL_WIDTH 10 -#define CY_LARGE_TOOL_WIDTH 255 -#define CY_REG_BASE 0x00 -#define CY_REG_GEST_SET 0x1E -#define CY_REG_ACT_INTRVL 0x1D -#define CY_REG_TCH_TMOUT (CY_REG_ACT_INTRVL+1) -#define CY_REG_LP_INTRVL (CY_REG_TCH_TMOUT+1) -#define CY_SOFT_RESET ((1 << 0)) -#define CY_DEEP_SLEEP ((1 << 1)) -#define CY_LOW_POWER ((1 << 2)) -#define CY_MAXZ 255 -#define CY_OK 0 -#define CY_INIT 1 -#define CY_DLY_DFLT 10 /* ms */ -#define CY_DLY_SYSINFO 20 /* ms */ -#define CY_DLY_BL 300 -#define CY_DLY_DNLOAD 100 /* ms */ -#define CY_NUM_RETRY 4 /* max num touch data read */ - -/* handshake bit in the hst_mode reg */ -#define CY_HNDSHK_BIT 0x80 -#ifdef CY_USE_HNDSHK - #define CY_SEND_HNDSHK 1 -#else - #define CY_SEND_HNDSHK 0 -#endif - -/* Bootloader File 0 offset */ -#define CY_BL_FILE0 0x00 - -/* Bootloader command directive */ -#define CY_BL_CMD 0xFF - -/* Bootloader Initiate Bootload */ -#define CY_BL_INIT_LOAD 0x38 - -/* Bootloader Write a Block */ -#define CY_BL_WRITE_BLK 0x39 - -/* Bootloader Terminate Bootload */ -#define CY_BL_TERMINATE 0x3B - -/* Bootloader Exit and Verify Checksum command */ -#define CY_BL_EXIT 0xA5 - -/* Bootloader default keys */ -#define CY_BL_KEY0 0x00 -#define CY_BL_KEY1 0x01 -#define CY_BL_KEY2 0x02 -#define CY_BL_KEY3 0x03 -#define CY_BL_KEY4 0x04 -#define CY_BL_KEY5 0x05 -#define CY_BL_KEY6 0x06 -#define CY_BL_KEY7 0x07 - -/* Active Power state scanning/processing refresh interval */ -#define CY_ACT_INTRVL_DFLT 0x00 - -/* touch timeout for the Active power */ -#define CY_TCH_TMOUT_DFLT 0xFF - -/* Low Power state scanning/processing refresh interval */ -#define CY_LP_INTRVL_DFLT 0x0A - -#define CY_IDLE_STATE 0 -#define CY_ACTIVE_STATE 1 -#define CY_LOW_PWR_STATE 2 -#define CY_SLEEP_STATE 3 - -/* device mode bits */ -#define CY_OP_MODE 0x00 -#define CY_SYSINFO_MODE 0x10 - -/* power mode select bits */ -#define CY_SOFT_RESET_MODE 0x01 /* return to Bootloader mode */ -#define CY_DEEP_SLEEP_MODE 0x02 -#define CY_LOW_PWR_MODE 0x04 - -#define CY_NUM_KEY 8 - -#ifdef CY_USE_GEST - #define CY_USE_GESTURES 1 -#else - #define CY_USE_GESTURES 0 -#endif /* CY_USE_GESTURE_SIGNALS */ - -#ifdef CY_USE_GEST_GRP1 - #define CY_GEST_GRP1 0x10 -#else - #define CY_GEST_GRP1 0x00 -#endif /* CY_USE_GEST_GRP1 */ -#ifdef CY_USE_GEST_GRP2 - #define CY_GEST_GRP2 0x20 -#else - #define CY_GEST_GRP2 0x00 -#endif /* CY_USE_GEST_GRP2 */ -#ifdef CY_USE_GEST_GRP3 - #define CY_GEST_GRP3 0x40 -#else - #define CY_GEST_GRP3 0x00 -#endif /* CY_USE_GEST_GRP3 */ -#ifdef CY_USE_GEST_GRP4 - #define CY_GEST_GRP4 0x80 -#else - #define CY_GEST_GRP4 0x00 -#endif /* CY_USE_GEST_GRP4 */ - -struct cyttsp_regulator { - const char *name; - u32 max_uV; - u32 min_uV; - u32 hpm_load_uA; - u32 lpm_load_uA; -}; - -struct cyttsp_platform_data { - u32 panel_maxx; - u32 panel_maxy; - u32 disp_resx; - u32 disp_resy; - u32 disp_minx; - u32 disp_miny; - u32 disp_maxx; - u32 disp_maxy; - u8 correct_fw_ver; - u32 flags; - u8 gen; - u8 use_st; - u8 use_mt; - u8 use_hndshk; - u8 use_trk_id; - u8 use_sleep; - u8 use_gestures; - u8 gest_set; - u8 act_intrvl; - u8 tch_tmout; - u8 lp_intrvl; - u8 power_state; - bool wakeup; - int sleep_gpio; - int resout_gpio; - int irq_gpio; - struct cyttsp_regulator *regulator_info; - u8 num_regulators; - const char *fw_fname; - bool disable_ghost_det; -#ifdef CY_USE_I2C_DRIVER - s32 (*init)(struct i2c_client *client); - s32 (*resume)(struct i2c_client *client); - s32 (*suspend)(struct i2c_client *client); -#endif -#ifdef CY_USE_SPI_DRIVER - s32 (*init)(struct spi_device *spi); - s32 (*resume)(struct spi_device *spi); -#endif -}; - -/* TrueTouch Standard Product Gen3 (Txx3xx) interface definition */ -struct cyttsp_gen3_xydata_t { - u8 hst_mode; - u8 tt_mode; - u8 tt_stat; - u16 x1 __attribute__ ((packed)); - u16 y1 __attribute__ ((packed)); - u8 z1; - u8 touch12_id; - u16 x2 __attribute__ ((packed)); - u16 y2 __attribute__ ((packed)); - u8 z2; - u8 gest_cnt; - u8 gest_id; - u16 x3 __attribute__ ((packed)); - u16 y3 __attribute__ ((packed)); - u8 z3; - u8 touch34_id; - u16 x4 __attribute__ ((packed)); - u16 y4 __attribute__ ((packed)); - u8 z4; - u8 tt_undef[3]; - u8 gest_set; - u8 tt_reserved; -}; - -/* TrueTouch Standard Product Gen2 (Txx2xx) interface definition */ -#define CY_GEN2_NOTOUCH 0x03 /* Both touches removed */ -#define CY_GEN2_GHOST 0x02 /* ghost */ -#define CY_GEN2_2TOUCH 0x03 /* 2 touch; no ghost */ -#define CY_GEN2_1TOUCH 0x01 /* 1 touch only */ -#define CY_GEN2_TOUCH2 0x01 /* 1st touch removed; - * 2nd touch remains */ -struct cyttsp_gen2_xydata_t { - u8 hst_mode; - u8 tt_mode; - u8 tt_stat; - u16 x1 __attribute__ ((packed)); - u16 y1 __attribute__ ((packed)); - u8 z1; - u8 evnt_idx; - u16 x2 __attribute__ ((packed)); - u16 y2 __attribute__ ((packed)); - u8 tt_undef1; - u8 gest_cnt; - u8 gest_id; - u8 tt_undef[14]; - u8 gest_set; - u8 tt_reserved; -}; - -/* TTSP System Information interface definition */ -struct cyttsp_sysinfo_data_t { - u8 hst_mode; - u8 mfg_cmd; - u8 mfg_stat; - u8 cid[3]; - u8 tt_undef1; - u8 uid[8]; - u8 bl_verh; - u8 bl_verl; - u8 tts_verh; - u8 tts_verl; - u8 app_idh; - u8 app_idl; - u8 app_verh; - u8 app_verl; - u8 tt_undef[6]; - u8 act_intrvl; - u8 tch_tmout; - u8 lp_intrvl; -}; - -/* TTSP Bootloader Register Map interface definition */ -#define CY_BL_CHKSUM_OK 0x01 -struct cyttsp_bootloader_data_t { - u8 bl_file; - u8 bl_status; - u8 bl_error; - u8 blver_hi; - u8 blver_lo; - u8 bld_blver_hi; - u8 bld_blver_lo; - u8 ttspver_hi; - u8 ttspver_lo; - u8 appid_hi; - u8 appid_lo; - u8 appver_hi; - u8 appver_lo; - u8 cid_0; - u8 cid_1; - u8 cid_2; -}; - -#define cyttsp_wake_data_t cyttsp_gen3_xydata_t -#ifdef CY_DECLARE_GLOBALS - #ifdef CY_INCLUDE_LOAD_FILE - /* this file declares: - * firmware download block array (cyttsp_fw[]), - * the number of command block records (cyttsp_fw_records), - * and the version variables - */ - #include "cyttsp_fw.h" /* imports cyttsp_fw[] array */ - #define cyttsp_app_load() 1 - #ifdef CY_FORCE_FW_UPDATE - #define cyttsp_force_fw_load() 1 - #else - #define cyttsp_force_fw_load() 0 - #endif - - #else - /* the following declarations are to allow - * some debugging capability - */ - unsigned char cyttsp_fw_tts_verh = 0x00; - unsigned char cyttsp_fw_tts_verl = 0x01; - unsigned char cyttsp_fw_app_idh = 0x02; - unsigned char cyttsp_fw_app_idl = 0x03; - unsigned char cyttsp_fw_app_verh = 0x04; - unsigned char cyttsp_fw_app_verl = 0x05; - unsigned char cyttsp_fw_cid_0 = 0x06; - unsigned char cyttsp_fw_cid_1 = 0x07; - unsigned char cyttsp_fw_cid_2 = 0x08; - #define cyttsp_app_load() 0 - #define cyttsp_force_fw_load() 0 - #endif - #define cyttsp_tts_verh() cyttsp_fw_tts_verh - #define cyttsp_tts_verl() cyttsp_fw_tts_verl - #define cyttsp_app_idh() cyttsp_fw_app_idh - #define cyttsp_app_idl() cyttsp_fw_app_idl - #define cyttsp_app_verh() cyttsp_fw_app_verh - #define cyttsp_app_verl() cyttsp_fw_app_verl - #define cyttsp_cid_0() cyttsp_fw_cid_0 - #define cyttsp_cid_1() cyttsp_fw_cid_1 - #define cyttsp_cid_2() cyttsp_fw_cid_2 - #ifdef CY_USE_TEST_DATA - static struct cyttsp_gen2_xydata_t tt_gen2_testray[] = { - {0x00}, {0x00}, {0x04}, - {0x4000}, {0x8000}, {0x80}, - {0x03}, - {0x2000}, {0x1000}, {0x00}, - {0x00}, - {0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00}, - {0x00} - }; - - static struct cyttsp_gen3_xydata_t tt_gen3_testray[] = { - {0x00}, {0x00}, {0x04}, - {0x4000}, {0x8000}, {0x80}, - {0x12}, - {0x2000}, {0x1000}, {0xA0}, - {0x00}, {0x00}, - {0x8000}, {0x4000}, {0xB0}, - {0x34}, - {0x4000}, {0x1000}, {0xC0}, - {0x00, 0x00, 0x00}, - {0x00}, - {0x00} - }; - #endif /* CY_USE_TEST_DATA */ - -#else - extern u8 g_appload_ray[]; -#endif - -#endif /* __CYTTSP_H__ */ diff --git a/include/linux/fb.h b/include/linux/fb.h index d49c60f5aa4c52250e5e5c9549ccb4fdf105d3ce..b0f2eb48a9ec428ce45d74183a2af4d8a538c6e5 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -460,16 +460,6 @@ struct fb_info { struct list_head modelist; /* mode list */ struct fb_videomode *mode; /* current mode */ -#ifdef CONFIG_FB_BACKLIGHT - /* assigned backlight device */ - /* set before framebuffer registration, - remove after unregister */ - struct backlight_device *bl_dev; - - /* Backlight level curve */ - struct mutex bl_curve_mutex; - u8 bl_curve[FB_BACKLIGHT_LEVELS]; -#endif #ifdef CONFIG_FB_DEFERRED_IO struct delayed_work deferred_work; struct fb_deferred_io *fbdefio; diff --git a/include/linux/fsm_dfe_hh.h b/include/linux/fsm_dfe_hh.h deleted file mode 100644 index db96794b6f72976d9956f30ba3d8da06f3b5a4d0..0000000000000000000000000000000000000000 --- a/include/linux/fsm_dfe_hh.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) 2011-2012, 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 _FSM_DFE_HH_H_ -#define _FSM_DFE_HH_H_ - -#include - -/* - * Device interface - */ - -#define DFE_HH_DEVICE_NAME "dfe_hh" - -/* - * IOCTL interface - */ - -enum { - DFE_IOCTL_COMMAND_CODE_WRITE, - DFE_IOCTL_COMMAND_CODE_WRITE_WITH_MASK, -}; - -struct dfe_write_register_param { - unsigned int offset; - unsigned int value; -}; - -struct dfe_write_register_mask_param { - unsigned int offset; - unsigned int value; - unsigned int mask; -}; - -struct dfe_read_write_array_param { - unsigned int offset; - unsigned int num; /* number of 16 bit registers */ - unsigned int *pArray; -}; - -struct dfe_command_entry { - unsigned int code; - unsigned int offset; - unsigned int value; - unsigned int mask; /* DFE_IOCTL_COMMAND_CODE_WRITE_WITH_MASK only */ -}; - -struct dfe_command_param { - unsigned int num; - struct dfe_command_entry *pEntry; -}; - -#define DFE_IOCTL_MAGIC 'h' -#define DFE_IOCTL_READ_REGISTER \ - _IOC(_IOC_READ, DFE_IOCTL_MAGIC, 0x01, \ - sizeof(unsigned int *)) -#define DFE_IOCTL_WRITE_REGISTER \ - _IOC(_IOC_WRITE, DFE_IOCTL_MAGIC, 0x02, \ - sizeof(struct dfe_write_register_param *)) -#define DFE_IOCTL_WRITE_REGISTER_WITH_MASK \ - _IOC(_IOC_WRITE, DFE_IOCTL_MAGIC, 0x03, \ - sizeof(struct dfe_write_register_mask_param *)) -#define DFE_IOCTL_READ_REGISTER_ARRAY \ - _IOC(_IOC_READ, DFE_IOCTL_MAGIC, 0x04, \ - sizeof(struct dfe_read_write_array_param *)) -#define DFE_IOCTL_WRITE_REGISTER_ARRAY \ - _IOC(_IOC_WRITE, DFE_IOCTL_MAGIC, 0x05, \ - sizeof(struct dfe_read_write_array_param *)) -#define DFE_IOCTL_COMMAND \ - _IOC(_IOC_WRITE, DFE_IOCTL_MAGIC, 0x10, \ - sizeof(struct dfe_command_param *)) - -#endif /* _FSM_DFE_HH_H_ */ diff --git a/include/linux/fsm_rfic_ftr.h b/include/linux/fsm_rfic_ftr.h deleted file mode 100644 index 6288a335739a73a93bcfb3283cd76b4cb761bea1..0000000000000000000000000000000000000000 --- a/include/linux/fsm_rfic_ftr.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _FSM_RFIC_FTR_H_ -#define _FSM_RFIC_FTR_H_ - -#include - -/* - * Device interface - */ - -#define RFIC_FTR_DEVICE_NAME "rfic_ftr" - -/* - * IOCTL interface - */ - -/* - Macro to associate the "bus" and "address" pair when accessing the RFIC. - Using a 32 bit address, reserve the upper 8 bits for the bus value, and - the lower 24 bits for the address. - */ -#define RFIC_FTR_ADDR(bus, addr) (((bus&0x03)<<24)|(addr&0xFFFFFF)) -#define RFIC_FTR_GET_ADDR(busAddr) (busAddr&0xFFFFFF) -#define RFIC_FTR_GET_BUS(busAddr) ((busAddr>>24)&0x03) - -struct rfic_write_register_param { - unsigned int rficAddr; - unsigned int value; -}; - -struct rfic_write_register_mask_param { - unsigned int rficAddr; - unsigned int value; - unsigned int mask; -}; - -struct rfic_grfc_param { - unsigned int grfcId; - unsigned int maskValue; - unsigned int ctrlValue; -}; - -#define RFIC_IOCTL_MAGIC 'f' -#define RFIC_IOCTL_READ_REGISTER \ - _IOC(_IOC_READ, RFIC_IOCTL_MAGIC, 0x01, \ - sizeof(unsigned int *)) -#define RFIC_IOCTL_WRITE_REGISTER \ - _IOC(_IOC_WRITE, RFIC_IOCTL_MAGIC, 0x02, \ - sizeof(struct rfic_write_register_param *)) -#define RFIC_IOCTL_WRITE_REGISTER_WITH_MASK \ - _IOC(_IOC_WRITE, RFIC_IOCTL_MAGIC, 0x03, \ - sizeof(struct rfic_write_register_mask_param *)) -#define RFIC_IOCTL_GET_GRFC \ - _IOC(_IOC_WRITE, RFIC_IOCTL_MAGIC, 0x10, \ - sizeof(struct rfic_grfc_param *)) -#define RFIC_IOCTL_SET_GRFC \ - _IOC(_IOC_WRITE, RFIC_IOCTL_MAGIC, 0x11, \ - sizeof(struct rfic_grfc_param *)) - -#endif /* _FSM_RFIC_FTR_H_ */ diff --git a/include/linux/gpio-pm8xxx-rpc.h b/include/linux/gpio-pm8xxx-rpc.h deleted file mode 100644 index cb8247f4d51ff94fc7a7782f1f8bb9ff7d56bbfd..0000000000000000000000000000000000000000 --- a/include/linux/gpio-pm8xxx-rpc.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -/* - * Qualcomm PMIC8XXX gpio rpc driver header file - * - */ - -#ifndef __GPIO_PM8XXX_RPC_H -#define __GPIO_PM8XXX_RPC_H - -#define PM8XXX_GPIO_DEV_NAME "pm8xxx-gpio-rpc" - -struct pm8xxx_gpio_rpc_platform_data { - int ngpios; - int gpio_base; -}; - -/* GPIO parameters */ -/* direction */ -#define PM_GPIO_DIR_OUT 0x01 -#define PM_GPIO_DIR_IN 0x02 -#define PM_GPIO_DIR_BOTH (PM_GPIO_DIR_OUT | PM_GPIO_DIR_IN) - -#endif diff --git a/include/linux/i2c/bq27520.h b/include/linux/i2c/bq27520.h deleted file mode 100644 index c1e5e06a2ae1ae5b3022525a81ff090e86c35536..0000000000000000000000000000000000000000 --- a/include/linux/i2c/bq27520.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __LINUX_BQ27520_H -#define __LINUX_BQ27520_H -struct bq27520_platform_data { - const char *name; - unsigned int soc_int; - unsigned int bi_tout; - unsigned int chip_en; /* CE */ - const char *vreg_name; /* regulater used by bq27520 */ - int vreg_value; /* its value */ - int enable_dlog; /* if enable on-chip coulomb counter data logger */ -}; - -#endif /* __LINUX_BQ27520_H */ diff --git a/include/linux/i2c/isl9519.h b/include/linux/i2c/isl9519.h deleted file mode 100644 index 3499674c8df72f97e0e447aab00796c61fa96626..0000000000000000000000000000000000000000 --- a/include/linux/i2c/isl9519.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __ISL9519_H__ -#define __ISL9519_H__ - -/** - * struct isl_platform_data - * @chgcurrent: max current the islchip can draw - * @valid_irq: interrupt for insertion/removal notification - * @valid_n_gpio: gpio to debounce insertion/removal - * @valid_config: machine specific func to configure gpio line - * @max_system_voltage: the max voltage isl should charge battery to - * @min_system_voltage: the min voltage isl should trkl charge the - * battery - * @term_current: the batt current when isl charging should stop - * @input_current: the max current isl should pull from the adapter - */ -struct isl_platform_data { - int chgcurrent; - int valid_n_gpio; - int (*chg_detection_config) (void); - int max_system_voltage; - int min_system_voltage; - int term_current; - int input_current; -}; - -#endif diff --git a/include/linux/i2c/smb137b.h b/include/linux/i2c/smb137b.h deleted file mode 100644 index 7367ac5f21607a1ee16ddbd145992c5c6a33ce13..0000000000000000000000000000000000000000 --- a/include/linux/i2c/smb137b.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __SMB137B_H__ -#define __SMB137B_H__ - -/** - * struct smb137b_platform_data - * structure to pass board specific information to the smb137b charger driver - * @chgcurrent: max current the smb137bchip can draw - * @valid_n_gpio: gpio to debounce insertion/removal - * @chg_detection_config: machine specific func to configure - * insertion/removal gpio line - * @batt_mah_rating: the battery current rating - */ -struct smb137b_platform_data { - int valid_n_gpio; - int (*chg_detection_config) (void); - int batt_mah_rating; -}; - -void smb137b_otg_power(int on); - -#endif diff --git a/include/linux/i2c/smb349.h b/include/linux/i2c/smb349.h deleted file mode 100644 index 40e1fac5a4c81ebfbf9d2beade9e47d1ab32f946..0000000000000000000000000000000000000000 --- a/include/linux/i2c/smb349.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2012 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 __SMB349_H__ -#define __SMB349_H__ - -#define SMB349_NAME "smb349" - -/** - * struct smb349_platform_data - * structure to pass board specific information to the smb137b charger driver - * @chg_current_ma: maximum fast charge current in mA - * @en_n_gpio: gpio to enable or disable charging - * @chg_susp_gpio: put active low to allow chip to suspend and disable I2C - */ -struct smb349_platform_data { - int en_n_gpio; - int chg_susp_gpio; - int chg_current_ma; -}; - -#endif diff --git a/include/linux/idle_stats_device.h b/include/linux/idle_stats_device.h deleted file mode 100644 index c2557a182e1c34aff40a78290391d5437b12cd1c..0000000000000000000000000000000000000000 --- a/include/linux/idle_stats_device.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __LINUX_IDLE_STATS_DEVICE_H -#define __LINUX_IDLE_STATS_DEVICE_H - -#include -#include -#include -#include - -struct msm_idle_stats_device { - const char *name; - void (*get_sample)(struct msm_idle_stats_device *device, - struct msm_idle_pulse *pulse); - - struct miscdevice miscdev; - spinlock_t lock; - wait_queue_head_t wait; - struct list_head list; - struct hrtimer busy_timer; - ktime_t busy_timer_interval; - ktime_t idle_start; - ktime_t remaining_time; - __u32 max_samples; - - struct msm_idle_read_stats *stats; - struct msm_idle_read_stats stats_vector[2]; -}; - -int msm_idle_stats_register_device(struct msm_idle_stats_device *device); -int msm_idle_stats_deregister_device(struct msm_idle_stats_device *device); -void msm_idle_stats_prepare_idle_start(struct msm_idle_stats_device *device); -void msm_idle_stats_abort_idle_start(struct msm_idle_stats_device *device); -void msm_idle_stats_idle_start(struct msm_idle_stats_device *device); -void msm_idle_stats_idle_end(struct msm_idle_stats_device *device, - struct msm_idle_pulse *pulse); -void msm_idle_stats_update_event(struct msm_idle_stats_device *device, - __u32 event); - -#endif /* __LINUX_IDLE_STATS_DEVICE_H */ - diff --git a/include/linux/input/cy8c_ts.h b/include/linux/input/cy8c_ts.h deleted file mode 100644 index a451c445a40c1df47405439306927417a39c0dae..0000000000000000000000000000000000000000 --- a/include/linux/input/cy8c_ts.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Header file for: - * Cypress CY8CTMA300 Prototype touchscreen driver. - * - * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc. - * Copyright (c) 2010, 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Cypress reserves the right to make changes without further notice - * to the materials described herein. Cypress does not assume any - * liability arising out of the application described herein. - * - * Contact Cypress Semiconductor at www.cypress.com - * - * History: - * (C) 2010 Cypress - Update for GPL distribution - * (C) 2009 Cypress - Assume maintenance ownership - * (C) 2009 Enea - Original prototype - * - */ -#ifndef __CY8C8CTS_H__ -#define __CY8C8CTS_H__ - - -/* CY8CTMA300-TMG200 platform data - */ -struct cy8c_ts_platform_data { - int (*power_on)(int on); - int (*dev_setup)(bool on); - const char *ts_name; - u32 dis_min_x; /* display resoltion */ - u32 dis_max_x; - u32 dis_min_y; - u32 dis_max_y; - u32 min_touch; /* no.of touches supported */ - u32 max_touch; - u32 min_tid; /* track id */ - u32 max_tid; - u32 min_width;/* size of the finger */ - u32 max_width; - u32 res_x; /* TS resolution */ - u32 res_y; - u32 swap_xy; - u32 flags; - u16 invert_x; - u16 invert_y; - u8 nfingers; - u32 irq_gpio; - int resout_gpio; - bool wakeup; -}; - -#endif diff --git a/include/linux/input/kp_flip_switch.h b/include/linux/input/kp_flip_switch.h deleted file mode 100644 index 68c226b41cb2f74847ae386b1d2dcaec7d3e3861..0000000000000000000000000000000000000000 --- a/include/linux/input/kp_flip_switch.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) 2010, 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 __KP_FLIP_SWITCH_H_ -#define __KP_FLIP_SWITCH_H_ -/* flip switch driver platform data */ -struct flip_switch_pdata { - int flip_gpio; - int left_key; - int right_key; - int wakeup; - int active_low; - int (*flip_mpp_config) (void); - char name[25]; -}; -#endif diff --git a/include/linux/input/lis3dh.h b/include/linux/input/lis3dh.h deleted file mode 100644 index 7c0172f7bc5ecc5c156a7c9717bc593ed56f9a27..0000000000000000000000000000000000000000 --- a/include/linux/input/lis3dh.h +++ /dev/null @@ -1,85 +0,0 @@ - -/******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** -* -* File Name : lis3dh_misc.h -* Authors : MH - C&I BU - Application Team -* : Matteo Dameno (matteo.dameno@st.com) -* : Carmine Iascone (carmine.iascone@st.com) -* : Samuel Huo (samuel.huo@st.com) -* Version : V 1.1.0 -* Date : 07/10/2012 -* -******************************************************************************** -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* THE PRESENT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES -* OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, FOR THE SOLE -* PURPOSE TO SUPPORT YOUR APPLICATION DEVELOPMENT. -* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, -* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE -* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING -* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. -* -* THIS SOFTWARE IS SPECIFICALLY DESIGNED FOR EXCLUSIVE USE WITH ST PARTS. -* -*******************************************************************************/ - -#ifndef __LIS3DH_H__ -#define __LIS3DH_H__ - - -#define SAD0L 0x00 -#define SAD0H 0x01 -#define LIS3DH_ACC_I2C_SADROOT 0x0C -#define LIS3DH_ACC_I2C_SAD_L ((LIS3DH_ACC_I2C_SADROOT<<1)|SAD0L) -#define LIS3DH_ACC_I2C_SAD_H ((LIS3DH_ACC_I2C_SADROOT<<1)|SAD0H) -#define LIS3DH_ACC_DEV_NAME "lis3dh_acc" -#define ACCEL_INPUT_DEV_NAME "accelerometer" - -/************************************************/ -/* Accelerometer defines section */ -/************************************************/ - -/* Accelerometer Sensor Full Scale */ -#define LIS3DH_ACC_FS_MASK 0x30 -#define LIS3DH_ACC_G_2G 0x00 -#define LIS3DH_ACC_G_4G 0x10 -#define LIS3DH_ACC_G_8G 0x20 -#define LIS3DH_ACC_G_16G 0x30 - - -#ifdef __KERNEL__ -struct lis3dh_acc_platform_data { - int poll_interval; - int min_interval; - - u8 g_range; - - u8 axis_map_x; - u8 axis_map_y; - u8 axis_map_z; - - u8 negate_x; - u8 negate_y; - u8 negate_z; - - int (*init)(void); - void (*exit)(void); - int (*power_on)(void); - int (*power_off)(void); - - /* set gpio_int[1,2] either to the choosen gpio pin number or to -EINVAL - * if leaved unconnected - */ - int gpio_int1; - int gpio_int2; -}; -#endif /* __KERNEL__ */ - -#endif /* __LIS3DH_H__ */ - - - diff --git a/include/linux/input/msm_ts.h b/include/linux/input/msm_ts.h deleted file mode 100644 index 45df9f7bc3cc3a6e64fcac857455ed45db86852f..0000000000000000000000000000000000000000 --- a/include/linux/input/msm_ts.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Internal platform definitions for msm/qsd touchscreen devices - * - * Copyright (C) 2008 Google Incorporated - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __ASM_ARCH_MSM_TS_H -#define __ASM_ARCH_MSM_TS_H - -#include - -/* The dimensions for the virtual key are for the other axis, i.e. if - * virtual keys are in the Y dimension then min/max is the range in the X - * dimension where that key would be activated */ -struct ts_virt_key { - int key; - int min; - int max; -}; - -struct msm_ts_virtual_keys { - struct ts_virt_key *keys; - int num_keys; -}; - -struct msm_ts_platform_data { - uint32_t min_x; - uint32_t max_x; - uint32_t min_y; - uint32_t max_y; - uint32_t min_press; - uint32_t max_press; - struct msm_ts_virtual_keys *vkeys_x; - uint32_t virt_x_start; - struct msm_ts_virtual_keys *vkeys_y; - uint32_t virt_y_start; - uint32_t inv_x; - uint32_t inv_y; - bool can_wakeup; -}; - -#endif /* __ASM_ARCH_MSM_TS_H */ diff --git a/include/linux/input/qci_kbd.h b/include/linux/input/qci_kbd.h deleted file mode 100644 index 20fd9e9b9dce2e77a298eb5ab3302b5899b41a66..0000000000000000000000000000000000000000 --- a/include/linux/input/qci_kbd.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2010, 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 __QCI_KBD_H__ -#define __QCI_KBD_H__ - -/** - * struct qci_kbd_platform_data - platform data for keyboard - * @repeat: enable or disable key repeate feature - * - * platform data structure for QCI keyboard driver. - */ -struct qci_kbd_platform_data { - bool repeat; - bool standard_scancodes; - bool kb_leds; -}; - -#endif /*__QCI_KBD_H__*/ diff --git a/include/linux/input/rmi_i2c.h b/include/linux/input/rmi_i2c.h deleted file mode 100644 index 65ebbfb7634795771f6ebccddc7d4d9823978887..0000000000000000000000000000000000000000 --- a/include/linux/input/rmi_i2c.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * - * Synaptics RMI over I2C Physical Layer Driver Header File. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################# - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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 _RMI_I2C_H -#define _RMI_I2C_H - -#include - -/* Sensor-specific configuration data, to be included as the platform data - * for the relevant i2c_board_info entry. - * - * This describes a single RMI4 sensor on an I2C bus, including: - * its I2C address, IRQ (if any), the type of IRQ (if applicable), and an - * optional list of any non-default settings (on a per function basis) - * to be applied at start up. - */ -struct rmi_i2c_platformdata { - /* The seven-bit i2c address of the sensor. */ - int i2c_address; - /* The number of the irq. Set to zero if polling is required. */ - int irq; - /* The type of the irq (e.g., IRQF_TRIGGER_FALLING). - * Only valid if irq != 0 */ - int irq_type; - - /* If >0, the driver will delay this many milliseconds before attempting - * I2C communications. This is necessary because some horribly broken - * development systems don't bring their I2C up very fast after system - * power on or reboot. In most cases, you can safely ignore this. - */ - int delay_ms; - - /* Use this to specify platformdata that is not I2C specific. */ - struct rmi_sensordata *sensordata; -}; - -#endif diff --git a/include/linux/input/rmi_platformdata.h b/include/linux/input/rmi_platformdata.h deleted file mode 100644 index 8c44d4c71b647a98c1ac322dbfb139a3e2189143..0000000000000000000000000000000000000000 --- a/include/linux/input/rmi_platformdata.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - * - * Synaptics RMI platform data definitions for use in board files. - * Copyright (c) 2007 - 2011, Synaptics Incorporated - * - */ -/* - * This file is licensed under the GPL2 license. - * - *############################################################################ - * GPL - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * - *############################################################################ - */ - -#if !defined(_RMI_PLATFORMDATA_H) -#define _RMI_PLATFORMDATA_H - -#define RMI_F01_INDEX 0x01 -#define RMI_F11_INDEX 0x11 -#define RMI_F19_INDEX 0x19 -#define RMI_F34_INDEX 0x34 - - -/* A couple of structs that are useful for frequently occuring constructs,such - * as coordinate origin offsets or coordinate clipping values. - */ -struct rmi_XY_pair { - int x; - int y; -}; - -struct rmi_range { - int min; - int max; -}; - -/* This contains sensor specific data that is not specialized to I2C or SPI. - */ -struct rmi_sensordata { - /* This will be called from rmi_register_sensor(). You can use it - * to set up gpios, IRQs, and other platform specific infrastructure. - */ - int (*rmi_sensor_setup)(void); - - /* This will be called when the sensor is unloaded. Use this to - * release gpios, IRQs, and other platform specific infrastructure. - */ - void (*rmi_sensor_teardown)(void); - - /* Use this to specify non-default settings on a per function basis. - */ - struct rmi_functiondata_list *perfunctiondata; -}; - -/* This contains the per-function customization for a given function.We store - * the data this way in order to avoid allocating a large sparse array - * typically - * only a few functions are present on a sensor, and even fewer will be have - * custom settings. There is a very small penalty paid for doing a linear - * search through the list to find a given function's data, but since the list - * is typically very short and is searched only at system boot time, this is - * considered acceptable. - * - * When adding new fields to a functiondata struct, please follow these rules: - * - Where possible, use 0 to indicate that the value should be defaulted. - * This works pretty well for bools, ints, and chars. - * - Where this is not practical (for example, in coordinate offsets or - * range clipping), use a pointer. Set that pointer to null to indicate - * that the value should be defaulted. - */ -struct rmi_functiondata { - unsigned char function_index; - void *data; -}; - -/* This can be included in the platformdata for SPI or I2C RMI4 devices to - * customize the settings of the functions on a given sensor. - */ -struct rmi_functiondata_list { - unsigned char count; /* Number of elements in the array */ - struct rmi_functiondata *functiondata; -}; - -struct rmi_f01_functiondata { - /* What this does is product specific. For most, but not all, RMI4 - * devices, you can set this to true in order to request the device - * report data at half the usual rate. This can be useful on slow - * CPUs that don't have the resources to process data at the usual - * rate. However, the meaning of this field is product specific, and - * you should consult the product spec for your sensor to find out - * what this will do. - */ - bool nonstandard_report_rate; -}; - -struct rmi_f11_functiondata { - bool swap_axes; - bool flipX; - bool flipY; - int button_height; - struct rmi_XY_pair *offset; - struct rmi_range *clipX; - struct rmi_range *clipY; -}; - -struct rmi_button_map { - unsigned char nbuttons; - unsigned char *map; -}; - -struct rmi_f19_functiondata { - struct rmi_button_map *button_map; -}; - -#endif diff --git a/include/linux/input/tdisc_shinetsu.h b/include/linux/input/tdisc_shinetsu.h deleted file mode 100644 index 973606afa070c8545d048c9283160bb216403d23..0000000000000000000000000000000000000000 --- a/include/linux/input/tdisc_shinetsu.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2010, 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 _TDISC_SHINETSU_H_ -#define _TDISC_SHINETSU_H_ - -struct tdisc_abs_values { - int x_max; - int y_max; - int x_min; - int y_min; - int pressure_max; - int pressure_min; -}; - -struct tdisc_platform_data { - int (*tdisc_setup) (void); - void (*tdisc_release) (void); - int (*tdisc_enable) (void); - int (*tdisc_disable)(void); - int tdisc_wakeup; - int tdisc_gpio; - bool tdisc_report_keys; - bool tdisc_report_relative; - bool tdisc_report_absolute; - bool tdisc_report_wheel; - bool tdisc_reverse_x; - bool tdisc_reverse_y; - struct tdisc_abs_values *tdisc_abs; -}; - -#endif /* _TDISC_SHINETSU_H_ */ diff --git a/include/linux/leds-msm-tricolor.h b/include/linux/leds-msm-tricolor.h deleted file mode 100644 index 330267621aa4f10c6875ed041be3b60bdd998e91..0000000000000000000000000000000000000000 --- a/include/linux/leds-msm-tricolor.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2012, 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 __LEDS_MSM_TRICOLOR__ -enum tri_color_led_color { - LED_COLOR_RED, - LED_COLOR_GREEN, - LED_COLOR_BLUE, - LED_COLOR_MAX -}; -#endif diff --git a/include/linux/libra_sdioif.h b/include/linux/libra_sdioif.h deleted file mode 100644 index d1a42cc52cf1c48667f41107c0eb24d7f47a53a9..0000000000000000000000000000000000000000 --- a/include/linux/libra_sdioif.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 2009-2012, 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 __LIBRA_SDIOIF_H__ -#define __LIBRA_SDIOIF_H__ - -/* - * Header for SDIO Card Interface Functions - */ -#include -#include -#include -#include - -/* - * Common Defines - */ -#define LIBRA_MAN_ID 0x70 -#define LIBRA_REV_1_0_CARD_ID 0x0 - -#define VOLANS_MAN_ID 0x70 -#define VOLANS_REV_1_0_CARD_ID 0x0 -#define VOLANS_REV_2_0_CARD_ID 0x2881 - -typedef int (suspend_handler_t)(struct sdio_func *); -typedef void (resume_handler_t)(struct sdio_func *); -typedef void (notify_card_removal_t)(void); -typedef void (shutdown_handler_t)(void); - -int libra_enable_sdio_irq_in_chip(struct sdio_func *func, u8 enable); -int libra_sdio_configure(sdio_irq_handler_t libra_sdio_rxhandler, - void (*func_drv_fn)(int *status), - u32 funcdrv_timeout, u32 blksize); -void libra_sdio_deconfigure(struct sdio_func *func); -struct sdio_func *libra_getsdio_funcdev(void); -void libra_sdio_setprivdata(struct sdio_func *sdio_func_dev, - void *padapter); -void *libra_sdio_getprivdata(struct sdio_func *sdio_func_dev); -void libra_claim_host(struct sdio_func *sdio_func_dev, - pid_t *curr_claimed, pid_t current_pid, - atomic_t *claim_count); -void libra_release_host(struct sdio_func *sdio_func_dev, - pid_t *curr_claimed, pid_t current_pid, - atomic_t *claim_count); -void libra_sdiocmd52(struct sdio_func *sdio_func_dev, - u32 addr, u8 *b, int write, int *err_ret); -u8 libra_sdio_readsb(struct sdio_func *func, void *dst, - unsigned int addr, int count); -int libra_sdio_memcpy_fromio(struct sdio_func *func, - void *dst, unsigned int addr, int count); -int libra_sdio_writesb(struct sdio_func *func, - unsigned int addr, void *src, int count); -int libra_sdio_memcpy_toio(struct sdio_func *func, - unsigned int addr, void *src, int count); -int libra_sdio_enable_polling(void); - -int libra_sdio_configure_suspend_resume( - suspend_handler_t *libra_sdio_suspend_hdlr, - resume_handler_t *libra_sdio_resume_hdlr); - -int libra_detect_card_change(void); - -void libra_sdio_set_clock(struct sdio_func *func, unsigned int clk_freq); -void libra_sdio_get_card_id(struct sdio_func *func, unsigned short *card_id); -void libra_sdio_release_irq(struct sdio_func *func); -int libra_enable_sdio_irq(struct sdio_func *func, u8 enable); -void libra_sdio_disable_func(struct sdio_func *func); -int libra_disable_sdio_irq_capability(struct sdio_func *func, u8 disable); -int libra_sdio_notify_card_removal( - notify_card_removal_t *libra_sdio_notify_card_removal_hdlr); -int libra_sdio_register_shutdown_hdlr( - shutdown_handler_t *libra_shutdown_hdlr); -#endif /* __LIBRA_SDIOIF_H__ */ diff --git a/include/linux/m_adcproc.h b/include/linux/m_adcproc.h deleted file mode 100644 index e7628b0be100779d00dfedaf4d5fc14a94ea80a3..0000000000000000000000000000000000000000 --- a/include/linux/m_adcproc.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2010-2011, 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 _M_ADC_PROC_H -#define _M_ADC_PROC_H - -#include -int32_t tdkntcgtherm(int32_t adc_code, const struct adc_properties *, - const struct chan_properties *, struct adc_chan_result *); -int32_t scale_default(int32_t adc_code, const struct adc_properties *, - const struct chan_properties *, struct adc_chan_result *); -int32_t scale_msm_therm(int32_t adc_code, const struct adc_properties *, - const struct chan_properties *, struct adc_chan_result *); -int32_t scale_batt_therm(int32_t adc_code, const struct adc_properties *, - const struct chan_properties *, struct adc_chan_result *); -int32_t scale_pmic_therm(int32_t adc_code, const struct adc_properties *, - const struct chan_properties *, struct adc_chan_result *); -int32_t scale_xtern_chgr_cur(int32_t adc_code, const struct adc_properties *, - const struct chan_properties *, struct adc_chan_result *); -#endif /* _M_ADC_PROC_H */ diff --git a/include/linux/mfd/marimba-codec.h b/include/linux/mfd/marimba-codec.h deleted file mode 100644 index 2fbbc0eb1fb1f03eaadc902e912e511b927ada52..0000000000000000000000000000000000000000 --- a/include/linux/mfd/marimba-codec.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2009, 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 __LINUX_MFD_MSM_MARIMBA_CODEC_H -#define __LINUX_MFD_MSM_MARIMBA_CODEC_H - -#include - -struct adie_codec_register { - u8 reg; - u8 mask; - u8 val; -}; - -struct adie_codec_register_image { - struct adie_codec_register *regs; - u32 img_sz; -}; - -struct adie_codec_path { - struct adie_codec_dev_profile *profile; - struct adie_codec_register_image img; - u32 hwsetting_idx; - u32 stage_idx; - u32 curr_stage; -}; - -int adie_codec_open(struct adie_codec_dev_profile *profile, - struct adie_codec_path **path_pptr); -int adie_codec_setpath(struct adie_codec_path *path_ptr, - u32 freq_plan, u32 osr); -int adie_codec_proceed_stage(struct adie_codec_path *path_ptr, u32 state); -int adie_codec_close(struct adie_codec_path *path_ptr); -u32 adie_codec_freq_supported(struct adie_codec_dev_profile *profile, - u32 requested_freq); -int adie_codec_enable_sidetone(struct adie_codec_path *rx_path_ptr, u32 enable); - -int adie_codec_set_device_digital_volume(struct adie_codec_path *path_ptr, - u32 num_channels, u32 vol_percentage /* in percentage */); - -int adie_codec_set_device_analog_volume(struct adie_codec_path *path_ptr, - u32 num_channels, u32 volume /* in percentage */); -#endif diff --git a/include/linux/mfd/marimba-tsadc.h b/include/linux/mfd/marimba-tsadc.h deleted file mode 100644 index 247fedd150d7cd4a3014305e24ec3d202259b80d..0000000000000000000000000000000000000000 --- a/include/linux/mfd/marimba-tsadc.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2009, 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 _MARIMBA_TSADC_H_ -#define _MARIMBA_TSADC_H_ - -struct marimba_tsadc_client; - -#define TSSC_SUSPEND_LEVEL 1 -#define TSADC_SUSPEND_LEVEL 2 - -int marimba_tsadc_start(struct marimba_tsadc_client *client); - -struct marimba_tsadc_client * -marimba_tsadc_register(struct platform_device *pdev, unsigned int is_ts); - -void marimba_tsadc_unregister(struct marimba_tsadc_client *client); - -#endif /* _MARIMBA_TSADC_H_ */ diff --git a/include/linux/mfd/marimba.h b/include/linux/mfd/marimba.h deleted file mode 100644 index 473d39ba09798d9608fedb633296deb1b5855a4a..0000000000000000000000000000000000000000 --- a/include/linux/mfd/marimba.h +++ /dev/null @@ -1,191 +0,0 @@ -/* Copyright (c) 2009-2011, 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. - * - */ -/* - * Qualcomm Marimba Core Driver header file - */ - -#ifndef _MARIMBA_H -#define _MARIMBA_H_ - -#include -#include -#include -#include - -#define MARIMBA_NUM_CHILD 4 - -#define MARIMBA_SLAVE_ID_MARIMBA 0x00 -#define MARIMBA_SLAVE_ID_FM 0x01 -#define MARIMBA_SLAVE_ID_CDC 0x02 -#define MARIMBA_SLAVE_ID_QMEMBIST 0x03 - -#define MARIMBA_ID_TSADC 0x04 - -#define BAHAMA_SLAVE_ID_FM_ID 0x02 -#define SLAVE_ID_BAHAMA 0x05 -#define SLAVE_ID_BAHAMA_FM 0x07 -#define SLAVE_ID_BAHAMA_QMEMBIST 0x08 - -#if defined(CONFIG_ARCH_MSM7X30) -#define MARIMBA_SSBI_ADAP 0x7 -#elif defined(CONFIG_ARCH_MSM8X60) -#define MARIMBA_SSBI_ADAP 0X8 -#endif - -enum chip_id { - MARIMBA_ID = 0, - TIMPANI_ID, - BAHAMA_ID, - CHIP_ID_MAX -}; - -enum bahama_version { - BAHAMA_VER_1_0, - BAHAMA_VER_2_0, - BAHAMA_VER_UNSUPPORTED = 0xFF -}; -enum { - BT_PCM_ON, - BT_PCM_OFF, - FM_I2S_ON, - FM_I2S_OFF, -}; -struct marimba { - struct i2c_client *client; - - struct i2c_msg xfer_msg[2]; - - struct mutex xfer_lock; - - int mod_id; -}; - -struct marimba_top_level_platform_data { - int slave_id; /* Member added for eg. */ -}; - -struct marimba_fm_platform_data { - int irq; - int (*fm_setup)(struct marimba_fm_platform_data *pdata); - void (*fm_shutdown)(struct marimba_fm_platform_data *pdata); - struct vreg *vreg_s2; - struct vreg *vreg_xo_out; - /* - This is to indicate whether Fm SoC is I2S master/slave - false - FM SoC is I2S slave - true - FM SoC is I2S master - */ - bool is_fm_soc_i2s_master; - int (*config_i2s_gpio)(int mode); -}; - -struct marimba_codec_platform_data { - int (*marimba_codec_power)(int vreg_on); - void (*snddev_profile_init) (void); -}; - -struct marimba_tsadc_setup_params { - bool pen_irq_en; - bool tsadc_en; -}; - -enum sample_period { - TSADC_CLK_3 = 0, - TSADC_CLK_24, - TSADC_CLK_36, - TSADC_CLK_48, - TSADC_CLK_1, - TSADC_CLK_2, - TSADC_CLK_6, - TSADC_CLK_12, - TSADC_CLOCK_MAX -}; - -struct marimba_tsadc_config_params2 { - unsigned long input_clk_khz; - enum sample_period sample_prd; -}; - -struct marimba_tsadc_config_params3 { - unsigned long prechg_time_nsecs; - unsigned long stable_time_nsecs; - unsigned long tsadc_test_mode; -}; - -struct marimba_tsadc_platform_data { - int (*marimba_tsadc_power)(int vreg_on); - int (*init)(void); - int (*exit)(void); - int (*level_vote)(int vote_on); - bool tsadc_prechg_en; - bool can_wakeup; - struct marimba_tsadc_setup_params setup; - struct marimba_tsadc_config_params2 params2; - struct marimba_tsadc_config_params3 params3; - - struct msm_ts_platform_data *tssc_data; -}; - -/* - * Marimba Platform Data - * */ -struct marimba_platform_data { - struct marimba_top_level_platform_data *marimba_tp_level; - struct marimba_fm_platform_data *fm; - struct marimba_codec_platform_data *codec; - struct marimba_tsadc_platform_data *tsadc; - u8 slave_id[(MARIMBA_NUM_CHILD + 1) * CHIP_ID_MAX]; - u32 (*marimba_setup) (void); - void (*marimba_shutdown) (void); - u32 (*bahama_setup) (void); - u32 (*bahama_shutdown) (int); - u32 (*marimba_gpio_config) (int); - u32 (*bahama_core_config) (int type); - u32 tsadc_ssbi_adap; -}; - -/* - * Read and Write to register - * */ -int marimba_read(struct marimba *, u8 reg, u8 *value, unsigned num_bytes); -int marimba_write(struct marimba *, u8 reg, u8 *value, unsigned num_bytes); - -/* - * Read and Write single 8 bit register with bit mask - * */ -int marimba_read_bit_mask(struct marimba *, u8 reg, u8 *value, - unsigned num_bytes, u8 mask); -int marimba_write_bit_mask(struct marimba *, u8 reg, u8 *value, - unsigned num_bytes, u8 mask); - -/* - * Read and Write to TSADC registers across the SSBI - * * */ -int marimba_ssbi_read(struct marimba *, u16 reg, u8 *value, int len); -int marimba_ssbi_write(struct marimba *, u16 reg , u8 *value, int len); - -/* Read and write to Timpani */ -int timpani_read(struct marimba*, u8 reg, u8 *value, unsigned num_bytes); -int timpani_write(struct marimba*, u8 reg, u8 *value, - unsigned num_bytes); - -/* Get the detected codec type */ -int adie_get_detected_codec_type(void); -int adie_get_detected_connectivity_type(void); -int marimba_gpio_config(int gpio_value); -bool marimba_get_fm_status(struct marimba *); -bool marimba_get_bt_status(struct marimba *); -void marimba_set_fm_status(struct marimba *, bool); -void marimba_set_bt_status(struct marimba *, bool); -int marimba_read_bahama_ver(struct marimba *); -#endif diff --git a/include/linux/mfd/pm8xxx/batt-alarm.h b/include/linux/mfd/pm8xxx/batt-alarm.h index b266f3eed42e733c86d864d138262562aaab2d44..f2746535807c0b95540c1173a5f8cb9bf040ccf9 100644 --- a/include/linux/mfd/pm8xxx/batt-alarm.h +++ b/include/linux/mfd/pm8xxx/batt-alarm.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, 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 @@ -70,99 +70,6 @@ enum pm8xxx_batt_alarm_hold_time { #define PM8XXX_BATT_ALARM_STATUS_BELOW_LOWER BIT(0) #define PM8XXX_BATT_ALARM_STATUS_ABOVE_UPPER BIT(1) -#if defined(CONFIG_MFD_PM8XXX_BATT_ALARM) \ - || defined(CONFIG_MFD_PM8XXX_BATT_ALARM_MODULE) - -/** - * pm8xxx_batt_alarm_enable - enable one of the battery voltage threshold - * comparators - * @comparator: selects which comparator to enable - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_enable(enum pm8xxx_batt_alarm_comparator comparator); - -/** - * pm8xxx_batt_alarm_disable - disable one of the battery voltage threshold - * comparators - * @comparator: selects which comparator to disable - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_disable(enum pm8xxx_batt_alarm_comparator comparator); - - -/** - * pm8xxx_batt_alarm_threshold_set - set the lower and upper alarm thresholds - * @comparator: selects which comparator to set the threshold of - * @threshold_mV: battery voltage threshold in millivolts - * set points = 2500-5675 mV in 25 mV steps - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_threshold_set( - enum pm8xxx_batt_alarm_comparator comparator, int threshold_mV); - -/** - * pm8xxx_batt_alarm_status_read - get status of both threshold comparators - * - * RETURNS: < 0 = error - * 0 = battery voltage ok - * BIT(0) set = battery voltage below lower threshold - * BIT(1) set = battery voltage above upper threshold - */ -int pm8xxx_batt_alarm_status_read(void); - -/** - * pm8xxx_batt_alarm_register_notifier - register a notifier to run when a - * battery voltage change interrupt fires - * @nb: notifier block containing callback function to register - * - * nb->notifier_call must point to a function of this form - - * int (*notifier_call)(struct notifier_block *nb, unsigned long status, - * void *unused); - * "status" will receive the battery alarm status; "unused" will be NULL. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_register_notifier(struct notifier_block *nb); - -/** - * pm8xxx_batt_alarm_unregister_notifier - unregister a notifier that is run - * when a battery voltage change interrupt fires - * @nb: notifier block containing callback function to unregister - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_unregister_notifier(struct notifier_block *nb); - -/** - * pm8xxx_batt_alarm_hold_time_set - set hold time of interrupt output * - * @hold_time: amount of time that battery voltage must remain outside of the - * threshold range before the battery alarm interrupt triggers - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_hold_time_set(enum pm8xxx_batt_alarm_hold_time hold_time); - -/** - * pm8xxx_batt_alarm_pwm_rate_set - set battery alarm update rate * - * @use_pwm: 1 = use PWM update rate, 0 = comparators always active - * @clock_scaler: PWM clock scaler = 2 to 9 - * @clock_divider: PWM clock divider = 2 to 8 - * - * This function sets the rate at which the battery alarm module enables - * the threshold comparators. The rate is determined by the following equation: - * - * f_update = (1024 Hz) / (clock_divider * (2 ^ clock_scaler)) - * - * Thus, the update rate can range from 0.25 Hz to 128 Hz. - * - * RETURNS: an appropriate -ERRNO error value on error, or zero for success. - */ -int pm8xxx_batt_alarm_pwm_rate_set(int use_pwm, int clock_scaler, - int clock_divider); -#else static inline int pm8xxx_batt_alarm_enable(enum pm8xxx_batt_alarm_comparator comparator) @@ -195,7 +102,6 @@ static inline int pm8xxx_batt_alarm_pwm_rate_set(int use_pwm, int clock_scaler, int clock_divider) { return -ENODEV; } -#endif #endif /* __MFD_PM8XXX_BATT_ALARM_H__ */ diff --git a/include/linux/mfd/pm8xxx/ccadc.h b/include/linux/mfd/pm8xxx/ccadc.h index a29486f8f3356f1e56d0a1f364b0629c7ade6e10..d838860a24ab0ec7afd4ce4956c9f81946c012e1 100644 --- a/include/linux/mfd/pm8xxx/ccadc.h +++ b/include/linux/mfd/pm8xxx/ccadc.h @@ -46,7 +46,7 @@ static inline s64 pm8xxx_ccadc_reading_to_microvolt(int revision, s64 cc) CCADC_READING_RESOLUTION_D); } -#if defined(CONFIG_PM8XXX_CCADC) || defined(CONFIG_PM8XXX_CCADC_MODULE) +#if defined(CONFIG_PM8XXX_CCADC_MODULE) /** * pm8xxx_cc_adjust_for_gain - the function to adjust the voltage read from * ccadc for gain compensation diff --git a/include/linux/mfd/pm8xxx/gpio.h b/include/linux/mfd/pm8xxx/gpio.h index 333d13f8a43a673f2da82852e4a829a7cbaf6490..bd0cb3621704cd5073f10edab2c258a78ed91c69 100644 --- a/include/linux/mfd/pm8xxx/gpio.h +++ b/include/linux/mfd/pm8xxx/gpio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2013, 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 @@ -143,7 +143,7 @@ struct pm_gpio { int disable_pin; }; -#if defined(CONFIG_GPIO_PM8XXX) || defined(CONFIG_GPIO_PM8XXX_MODULE) +#if defined(CONFIG_GPIO_PM8XXX_MODULE) /** * pm8xxx_gpio_config - configure a gpio controlled by a pm8xxx chip * @gpio: gpio number to configure diff --git a/include/linux/mfd/pm8xxx/misc.h b/include/linux/mfd/pm8xxx/misc.h index 98ec93f260a1ea181490ce08521b7d7b20501593..f3461d63fe8ce6309c4cd9a1978ec3f35807766e 100644 --- a/include/linux/mfd/pm8xxx/misc.h +++ b/include/linux/mfd/pm8xxx/misc.h @@ -95,7 +95,7 @@ enum pm8xxx_hsed_bias { PM8XXX_HSED_BIAS2, }; -#if defined(CONFIG_MFD_PM8XXX_MISC) || defined(CONFIG_MFD_PM8XXX_MISC_MODULE) +#if defined(CONFIG_MFD_PM8XXX_MISC_MODULE) /** * pm8xxx_reset_pwr_off - switch all PM8XXX PMIC chips attached to the system to diff --git a/include/linux/mfd/pm8xxx/mpp.h b/include/linux/mfd/pm8xxx/mpp.h index 90596f840d17661cc21a6e31d488e5770526d90b..1ba00440e566e9aea04f534f198c302626875804 100644 --- a/include/linux/mfd/pm8xxx/mpp.h +++ b/include/linux/mfd/pm8xxx/mpp.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2013, 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 @@ -106,7 +106,7 @@ struct pm8xxx_mpp_config_data { }; /* API */ -#if defined(CONFIG_GPIO_PM8XXX_MPP) || defined(CONFIG_GPIO_PM8XXX_MPP_MODULE) +#if defined(CONFIG_GPIO_PM8XXX_MPP_MODULE) /** * pm8xxx_mpp_config() - configure control options of a multi-purpose pin (MPP) diff --git a/include/linux/mfd/pm8xxx/pm8018.h b/include/linux/mfd/pm8xxx/pm8018.h deleted file mode 100644 index 002623c174f93be3483ab9aa46e97a0d0fca569e..0000000000000000000000000000000000000000 --- a/include/linux/mfd/pm8xxx/pm8018.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ -/* - * Qualcomm PMIC 8018 driver header file - * - */ - -#ifndef __MFD_PM8018_H -#define __MFD_PM8018_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PM8018_CORE_DEV_NAME "pm8018-core" - -#define PM8018_NR_IRQS 256 - -#define PM8018_NR_GPIOS 6 - -#define PM8018_NR_MPPS 6 - -#define PM8018_GPIO_BLOCK_START 24 -#define PM8018_MPP_BLOCK_START 16 -#define PM8018_IRQ_BLOCK_BIT(block, bit) ((block) * 8 + (bit)) - -/* GPIOs and MPPs [1,N] */ -#define PM8018_GPIO_IRQ(base, gpio) ((base) + \ - PM8018_IRQ_BLOCK_BIT(PM8018_GPIO_BLOCK_START, (gpio)-1)) -#define PM8018_MPP_IRQ(base, mpp) ((base) + \ - PM8018_IRQ_BLOCK_BIT(PM8018_MPP_BLOCK_START, (mpp)-1)) - -/* PMIC Interrupts */ -#define PM8018_RTC_ALARM_IRQ PM8018_IRQ_BLOCK_BIT(4, 7) - -#define PM8018_PWRKEY_REL_IRQ PM8018_IRQ_BLOCK_BIT(6, 2) -#define PM8018_PWRKEY_PRESS_IRQ PM8018_IRQ_BLOCK_BIT(6, 3) -#define PM8018_ADC_EOC_USR_IRQ PM8018_IRQ_BLOCK_BIT(9, 6) -#define PM8018_ADC_BATT_TEMP_WARM_IRQ PM8018_IRQ_BLOCK_BIT(9, 1) -#define PM8018_ADC_BATT_TEMP_COLD_IRQ PM8018_IRQ_BLOCK_BIT(9, 0) - -#define PM8018_OVERTEMP_IRQ PM8018_IRQ_BLOCK_BIT(4, 2) -#define PM8018_TEMPSTAT_IRQ PM8018_IRQ_BLOCK_BIT(6, 7) - -#define PM8018_LVS1_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 0) - -struct pm8018_platform_data { - struct pm8xxx_irq_platform_data *irq_pdata; - struct pm8xxx_gpio_platform_data *gpio_pdata; - struct pm8xxx_mpp_platform_data *mpp_pdata; - struct pm8xxx_rtc_platform_data *rtc_pdata; - struct pm8xxx_pwrkey_platform_data *pwrkey_pdata; - struct pm8xxx_misc_platform_data *misc_pdata; - struct pm8xxx_regulator_platform_data *regulator_pdatas; - struct pm8xxx_adc_platform_data *adc_pdata; - int num_regulators; - struct pm8xxx_led_platform_data *leds_pdata; -}; - -#endif diff --git a/include/linux/mfd/pm8xxx/pm8038.h b/include/linux/mfd/pm8xxx/pm8038.h deleted file mode 100644 index 5c9219c82b04330c3f903730e7eb37ef460f5841..0000000000000000000000000000000000000000 --- a/include/linux/mfd/pm8xxx/pm8038.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ -/* - * Qualcomm PMIC 8038 driver header file - * - */ - -#ifndef __MFD_PM8038_H -#define __MFD_PM8038_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PM8038_CORE_DEV_NAME "pm8038-core" - -#define PM8038_NR_IRQS 256 -#define PM8038_NR_GPIOS 12 -#define PM8038_NR_MPPS 6 - -#define PM8038_GPIO_BLOCK_START 24 -#define PM8038_MPP_BLOCK_START 16 - -#define PM8038_IRQ_BLOCK_BIT(block, bit) ((block) * 8 + (bit)) - -/* GPIO and MPPs [1,N] */ -#define PM8038_GPIO_IRQ(base, gpio) ((base) + \ - PM8038_IRQ_BLOCK_BIT(PM8038_GPIO_BLOCK_START, (gpio)-1)) -#define PM8038_MPP_IRQ(base, mpp) ((base) + \ - PM8038_IRQ_BLOCK_BIT(PM8038_MPP_BLOCK_START, (mpp)-1)) - -/* PMIC Interrupts */ -#define PM8038_RTC_ALARM_IRQ PM8038_IRQ_BLOCK_BIT(4, 7) -#define PM8038_BATT_ALARM_IRQ PM8921_IRQ_BLOCK_BIT(5, 6) -#define PM8038_PWRKEY_REL_IRQ PM8038_IRQ_BLOCK_BIT(6, 2) -#define PM8038_PWRKEY_PRESS_IRQ PM8038_IRQ_BLOCK_BIT(6, 3) -#define PM8038_KEYPAD_IRQ PM8038_IRQ_BLOCK_BIT(9, 2) -#define PM8038_KEYSTUCK_IRQ PM8038_IRQ_BLOCK_BIT(9, 3) -#define PM8038_ADC_EOC_USR_IRQ PM8038_IRQ_BLOCK_BIT(9, 6) -#define PM8038_ADC_BATT_TEMP_WARM_IRQ PM8038_IRQ_BLOCK_BIT(9, 1) -#define PM8038_ADC_BATT_TEMP_COLD_IRQ PM8038_IRQ_BLOCK_BIT(9, 0) -#define PM8038_USB_ID_IN_IRQ(base) (base + PM8921_IRQ_BLOCK_BIT(6, 1)) - -#define PM8038_RESOUT_IRQ PM8038_IRQ_BLOCK_BIT(6, 4) - -#define PM8038_OVERTEMP_IRQ PM8038_IRQ_BLOCK_BIT(4, 2) -#define PM8038_TEMPSTAT_IRQ PM8038_IRQ_BLOCK_BIT(6, 7) - -struct pm8038_platform_data { - int irq_base; - struct pm8xxx_gpio_platform_data *gpio_pdata; - struct pm8xxx_irq_platform_data *irq_pdata; - struct pm8xxx_mpp_platform_data *mpp_pdata; - struct pm8xxx_rtc_platform_data *rtc_pdata; - struct pm8xxx_pwrkey_platform_data *pwrkey_pdata; - struct pm8xxx_misc_platform_data *misc_pdata; - struct pm8xxx_regulator_platform_data *regulator_pdatas; - int num_regulators; - struct pm8921_charger_platform_data *charger_pdata; - struct pm8921_bms_platform_data *bms_pdata; - struct pm8xxx_adc_platform_data *adc_pdata; - struct pm8xxx_led_platform_data *leds_pdata; - struct pm8xxx_vibrator_platform_data *vibrator_pdata; - struct pm8xxx_ccadc_platform_data *ccadc_pdata; - struct pm8xxx_spk_platform_data *spk_pdata; -}; - -#endif diff --git a/include/linux/mfd/pm8xxx/pm8821-irq.h b/include/linux/mfd/pm8xxx/pm8821-irq.h deleted file mode 100644 index 4d9b8b855ade50974cd1260321e5c911ef4b29d2..0000000000000000000000000000000000000000 --- a/include/linux/mfd/pm8xxx/pm8821-irq.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ -/* - * Qualcomm PMIC irq 8821 driver header file - * - */ - -#ifndef __MFD_PM8821_IRQ_H -#define __MFD_PM8821_IRQ_H - -#include -#include -#include - -#ifdef CONFIG_MFD_PM8821_IRQ -int pm8821_get_irq_stat(struct pm_irq_chip *chip, int irq); -struct pm_irq_chip *pm8821_irq_init(struct device *dev, - const struct pm8xxx_irq_platform_data *pdata); -int pm8821_irq_exit(struct pm_irq_chip *chip); -#else -static inline int pm8821_get_irq_stat(struct pm_irq_chip *chip, int irq) -{ - return -ENXIO; -} -static inline struct pm_irq_chip *pm8821_irq_init(const struct device *dev, - const struct pm8xxx_irq_platform_data *pdata) -{ - return ERR_PTR(-ENXIO); -} -static inline int pm8821_irq_exit(struct pm_irq_chip *chip) -{ - return -ENXIO; -} -#endif /* CONFIG_MFD_PM8821_IRQ */ -#endif /* __MFD_PM8821_IRQ_H */ diff --git a/include/linux/mfd/pm8xxx/pm8821.h b/include/linux/mfd/pm8xxx/pm8821.h deleted file mode 100644 index e5877ac06ee015cbb9d5f3d8c4cd8510990d5330..0000000000000000000000000000000000000000 --- a/include/linux/mfd/pm8xxx/pm8821.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011-2012, 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. - */ -/* - * Qualcomm PMIC 8821 driver header file - * - */ - -#ifndef __MFD_PM8821_H -#define __MFD_PM8821_H - -#include -#include -#include -#include - -#define PM8821_NR_IRQS (112) -#define PM8821_NR_MPPS (4) - -#define PM8821_MPP_BLOCK_START (4) - -/* - * Block 0 does not exist in PM8821 IRQ SSBI address space, - * IRQ0 is assigned to bit0 of block1 - */ -#define PM8821_IRQ_BLOCK_BIT(block, bit) ((block-1) * 8 + (bit)) - -/* MPPs [1,N] */ -#define PM8821_MPP_IRQ(base, mpp) ((base) + \ - PM8821_IRQ_BLOCK_BIT(PM8821_MPP_BLOCK_START, (mpp)-1)) - -/* PMIC Interrupts */ -#define PM8821_OVERTEMP_IRQ PM8821_IRQ_BLOCK_BIT(5, 2) -#define PM8821_TEMPSTAT_IRQ PM8821_IRQ_BLOCK_BIT(5, 7) - -struct pm8821_platform_data { - int irq_base; - struct pm8xxx_irq_platform_data *irq_pdata; - struct pm8xxx_mpp_platform_data *mpp_pdata; -}; - -#endif diff --git a/include/linux/mfd/pm8xxx/pm8921-charger.h b/include/linux/mfd/pm8xxx/pm8921-charger.h index b7d8ff1a8a535dbbf19fac209ed38cdae95c69ef..b1c57604413e6ee1a0016fbe4bddb2b54cfbd270 100644 --- a/include/linux/mfd/pm8xxx/pm8921-charger.h +++ b/include/linux/mfd/pm8xxx/pm8921-charger.h @@ -199,7 +199,7 @@ enum pm8921_charger_source { PM8921_CHG_SRC_DC, }; -#if defined(CONFIG_PM8921_CHARGER) || defined(CONFIG_PM8921_CHARGER_MODULE) +#if defined(CONFIG_PM8921_CHARGER_MODULE) void pm8921_charger_vbus_draw(unsigned int mA); int pm8921_charger_register_vbus_sn(void (*callback)(int)); void pm8921_charger_unregister_vbus_sn(void (*callback)(int)); diff --git a/include/linux/mfd/pm8xxx/pm8xxx-adc.h b/include/linux/mfd/pm8xxx/pm8xxx-adc.h index f40633a0d293145c40fa1fd680a2f16659cbee30..58de627ab56134a3179ae9682d1ce8ea3eaddb76 100644 --- a/include/linux/mfd/pm8xxx/pm8xxx-adc.h +++ b/include/linux/mfd/pm8xxx/pm8xxx-adc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2013, 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 @@ -305,101 +305,6 @@ struct pm8xxx_adc_chan_result { int64_t physical; }; -#if defined(CONFIG_SENSORS_PM8XXX_ADC) \ - || defined(CONFIG_SENSORS_PM8XXX_ADC_MODULE) -/** - * pm8xxx_adc_scale_default() - Scales the pre-calibrated digital output - * of an ADC to the ADC reference and compensates for the - * gain and offset. - * @adc_code: pre-calibrated digital ouput of the ADC. - * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, - * reference voltage. - * @chan_prop: individual channel properties to compensate the i/p scaling, - * slope and offset. - * @chan_rslt: Physical result to be stored. - */ -int32_t pm8xxx_adc_scale_default(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_prop, - const struct pm8xxx_adc_chan_properties *chan_prop, - struct pm8xxx_adc_chan_result *chan_rslt); -/** - * pm8xxx_adc_scale_tdkntcg_therm() - Scales the pre-calibrated digital output - * of an ADC to the ADC reference and compensates for the - * gain and offset. Returns the temperature of the xo therm in mili - degC. - * @adc_code: pre-calibrated digital ouput of the ADC. - * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, - * reference voltage. - * @chan_prop: individual channel properties to compensate the i/p scaling, - * slope and offset. - * @chan_rslt: physical result to be stored. - */ -int32_t pm8xxx_adc_tdkntcg_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_prop, - const struct pm8xxx_adc_chan_properties *chan_prop, - struct pm8xxx_adc_chan_result *chan_rslt); -/** - * pm8xxx_adc_scale_batt_therm() - Scales the pre-calibrated digital output - * of an ADC to the ADC reference and compensates for the - * gain and offset. Returns the temperature in degC. - * @adc_code: pre-calibrated digital ouput of the ADC. - * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, - * reference voltage. - * @chan_prop: individual channel properties to compensate the i/p scaling, - * slope and offset. - * @chan_rslt: physical result to be stored. - */ -int32_t pm8xxx_adc_scale_batt_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_prop, - const struct pm8xxx_adc_chan_properties *chan_prop, - struct pm8xxx_adc_chan_result *chan_rslt); -/** - * pm8xxx_adc_scale_pa_therm() - Scales the pre-calibrated digital output - * of an ADC to the ADC reference and compensates for the - * gain and offset. Returns the temperature in degC. - * @adc_code: pre-calibrated digital ouput of the ADC. - * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, - * reference voltage. - * @chan_prop: individual channel properties to compensate the i/p scaling, - * slope and offset. - * @chan_rslt: physical result to be stored. - */ -int32_t pm8xxx_adc_scale_pa_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_prop, - const struct pm8xxx_adc_chan_properties *chan_prop, - struct pm8xxx_adc_chan_result *chan_rslt); -/** - * pm8xxx_adc_scale_pmic_therm() - Scales the pre-calibrated digital output - * of an ADC to the ADC reference and compensates for the - * gain and offset. Performs the AMUX out as 2mv/K and returns - * the temperature in mili degC. - * @adc_code: pre-calibrated digital ouput of the ADC. - * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, - * reference voltage. - * @chan_prop: individual channel properties to compensate the i/p scaling, - * slope and offset. - * @chan_rslt: physical result to be stored. - */ -int32_t pm8xxx_adc_scale_pmic_therm(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_prop, - const struct pm8xxx_adc_chan_properties *chan_prop, - struct pm8xxx_adc_chan_result *chan_rslt); -/** - * pm8xxx_adc_scale_batt_id() - Scales the pre-calibrated digital output - * of an ADC to the ADC reference and compensates for the - * gain and offset. - * @adc_code: pre-calibrated digital ouput of the ADC. - * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, - * reference voltage. - * @chan_prop: individual channel properties to compensate the i/p scaling, - * slope and offset. - * @chan_rslt: physical result to be stored. - */ -int32_t pm8xxx_adc_scale_batt_id(int32_t adc_code, - const struct pm8xxx_adc_properties *adc_prop, - const struct pm8xxx_adc_chan_properties *chan_prop, - struct pm8xxx_adc_chan_result *chan_rslt); -#else static inline int32_t pm8xxx_adc_scale_default(int32_t adc_code, const struct pm8xxx_adc_properties *adc_prop, const struct pm8xxx_adc_chan_properties *chan_prop, @@ -430,7 +335,6 @@ static inline int32_t pm8xxx_adc_scale_batt_id(int32_t adc_code, const struct pm8xxx_adc_chan_properties *chan_prop, struct pm8xxx_adc_chan_result *chan_rslt) { return -ENXIO; } -#endif /** * struct pm8xxx_adc_scale_fn - Scaling function prototype @@ -511,80 +415,6 @@ struct pm8xxx_adc_platform_data { }; /* Public API */ -#if defined(CONFIG_SENSORS_PM8XXX_ADC) \ - || defined(CONFIG_SENSORS_PM8XXX_ADC_MODULE) -/** - * pm8xxx_adc_read() - Performs ADC read on the channel. - * @channel: Input channel to perform the ADC read. - * @result: Structure pointer of type adc_chan_result - * in which the ADC read results are stored. - */ -uint32_t pm8xxx_adc_read(enum pm8xxx_adc_channels channel, - struct pm8xxx_adc_chan_result *result); -/** - * pm8xxx_adc_mpp_config_read() - Configure's the PM8XXX MPP - * to AMUX6 and performs an ADC read. - * - * On PM8921 ADC the MPP needs to first be configured - * as an analog input to the AMUX pre-mux channel before - * issuing a read request. PM8921 MPP 8 is mapped to AMUX8 - * and is common between remote processor's. - * - * On PM8018 ADC the MPP is directly connected to the AMUX - * pre-mux. Therefore clients of the PM8018 MPP do not need - * to configure the MPP as an analog input to the pre-mux. - * Clients can directly issue request on the pre-mux AMUX - * channel to read the ADC on the MPP. Clients can directly - * call the pm8xxx_adc_read(). - * @mpp_num PM8XXX MPP number to configure to AMUX6. - * @channel: Input channel to perform the ADC read. - * a) 'ADC_MPP_1_AMUX6' if the input voltage is less than 1.8V - * b) 'ADC_MPP_2_AMUX6' if the input voltage is greater then 1.8V - * the input voltage is pre-divided by 3 and passed to the ADC. - * The appropriate scaling function needs to be selected to let - * the driver know a post scaling is required before returning - * the result. - * @result: Structure pointer of type adc_chan_result - * in which the ADC read results are stored. - */ -uint32_t pm8xxx_adc_mpp_config_read(uint32_t mpp_num, - enum pm8xxx_adc_channels channel, - struct pm8xxx_adc_chan_result *result); -/** - * pm8xxx_adc_btm_start() - Configure the BTM registers and start - monitoring the BATT_THERM channel for - threshold warm/cold temperature set - by the Battery client. The btm_start - api is to be used after calling the - pm8xxx_btm_configure() api which sets - the temperature thresholds, interval - and functions to call when warm/cold - events are triggered. - * @param: none. - */ -uint32_t pm8xxx_adc_btm_start(void); - -/** - * pm8xxx_adc_btm_end() - Configures the BTM registers to stop - * monitoring the BATT_THERM channel for - * warm/cold events and disables the - * interval timer. - * @param: none. - */ -uint32_t pm8xxx_adc_btm_end(void); - -/** - * pm8xxx_adc_btm_configure() - Configures the BATT_THERM channel - * parameters for warm/cold thresholds. - * Sets the interval timer for perfoming - * reading the temperature done by the HW. - * @btm_param: Structure pointer of type adc_arb_btm_param * - * which client provides for threshold warm/cold, - * interval and functions to call when warm/cold - * events are triggered. - */ -uint32_t pm8xxx_adc_btm_configure(struct pm8xxx_adc_arb_btm_param *); -#else static inline uint32_t pm8xxx_adc_read(uint32_t channel, struct pm8xxx_adc_chan_result *result) { return -ENXIO; } @@ -599,6 +429,5 @@ static inline uint32_t pm8xxx_adc_btm_end(void) static inline uint32_t pm8xxx_adc_btm_configure( struct pm8xxx_adc_arb_btm_param *param) { return -ENXIO; } -#endif #endif /* PM8XXX_ADC_H */ diff --git a/include/linux/mfd/pm8xxx/regulator.h b/include/linux/mfd/pm8xxx/regulator.h deleted file mode 100644 index 31c26847ed1f4aede0688f35123accb67eef7b9f..0000000000000000000000000000000000000000 --- a/include/linux/mfd/pm8xxx/regulator.h +++ /dev/null @@ -1,271 +0,0 @@ -/* Copyright (c) 2011-2012, 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 __MFD_PM8XXX_REGULATOR_H__ -#define __MFD_PM8XXX_REGULATOR_H__ - -#include -#include -#include -#include - -/** - * enum pm8xxx_regulator_type - possible PM8XXX voltage regulator types - * %PM8XXX_REGULATOR_TYPE_PLDO: PMOS low drop-out linear regulator - * %PM8XXX_REGULATOR_TYPE_NLDO: NMOS low drop-out linear regulator - * %PM8XXX_REGULATOR_TYPE_NLDO1200: NMOS low drop-out linear regulator - * capable of supplying up to 1200 mA - * %PM8XXX_REGULATOR_TYPE_SMPS: switched-mode power supply (buck) - * %PM8XXX_REGULATOR_TYPE_FTSMPS: fast transient switched-mode power - * supply (buck) - * %PM8XXX_REGULATOR_TYPE_VS: voltage switch capable of sourcing 100mA - * %PM8XXX_REGULATOR_TYPE_VS300: voltage switch capable of sourcing 300mA - * %PM8XXX_REGULATOR_TYPE_NCP: negative charge pump - * %PM8XXX_REGULATOR_TYPE_BOOST: boost regulator - * %PM8XXX_REGULATOR_TYPE_MAX: used internally for error checking; not - * a valid regulator type. - * - * Each of these has a different register control interface. - */ -enum pm8xxx_regulator_type { - PM8XXX_REGULATOR_TYPE_PLDO, - PM8XXX_REGULATOR_TYPE_NLDO, - PM8XXX_REGULATOR_TYPE_NLDO1200, - PM8XXX_REGULATOR_TYPE_SMPS, - PM8XXX_REGULATOR_TYPE_FTSMPS, - PM8XXX_REGULATOR_TYPE_VS, - PM8XXX_REGULATOR_TYPE_VS300, - PM8XXX_REGULATOR_TYPE_NCP, - PM8XXX_REGULATOR_TYPE_BOOST, - PM8XXX_REGULATOR_TYPE_MAX, -}; - -/** - * struct pm8xxx_vreg - regulator configuration and state data used by the - * pm8xxx-regulator driver - * @rdesc: regulator description - * @rdesc_pc: pin control regulator description. rdesc_pc.name == NULL - * implies that there is no pin control version of this - * regulator. - * @type: regulator type - * @hpm_min_load: minimum load in uA that will result in the regulator - * being set to high power mode - * @ctrl_addr: control register SSBI address - * @test_addr: test register SSBI address (not needed for all types) - * @clk_ctrl_addr: clock control register SSBI address (only used by SMPS - * type regulators) - * @sleep_ctrl_addr: sleep control register SSBI address (only used by SMPS - * type regulators) - * @pfm_ctrl_addr: pulse-frequency modulation control register SSBI address - * (only used by FTSMPS type regulators) - * @pwr_cnfg_addr: power configuration register SSBI address (only used by - * FTSMPS type regulators) - * @pdata: this platform data struct is filled based using the - * platform data pointed to in a core platform data struct - * @rdev: pointer to regulator device which is created with - * regulator_register - * @rdev_pc: pointer to pin controlled regulator device which is - * created with regulator_register - * @dev: pointer to pm8xxx-regulator device - * @dev_pc: pointer to pin control pm8xxx-regulator device - * @pc_lock: mutex lock to handle sharing between pin controlled and - * non-pin controlled versions of a given regulator. Note, - * this lock must be initialized in the PMIC core driver.) - * @save_uV: current regulator voltage in uV - * @mode: current mode of the regulator - * @write_count: number of SSBI writes that have taken place for this - * regulator. This is used for debug printing to determine - * if a given operation is redundant. - * @prev_write_count: number of SSBI writes that have taken place for this - * regulator at the start of an operation. This is used for - * debug printing to determine if a given operation is - * redundant. - * @is_enabled: true if the regulator is currently enabled, false if not - * @is_enabled_pc: true if the pin controlled version of the regulator is - * currently enabled (i.e. pin control is active), false if - * not - * @test_reg: last value read from or written to each of the banks of - * the test register - * @ctrl_reg: last value read from or written to the control register - * @clk_ctrl_reg: last value read from or written to the clock control - * register - * @sleep_ctrl_reg: last value read from or written to the sleep control - * register - * @pfm_ctrl_reg: last value read from or written to the PFM control - * register - * @pwr_cnfg_reg: last value read from or written to the power - * configuration register - * - * This data structure should only need to be instantiated in a PMIC core driver - * It is used to specify PMIC specific as opposed to board specific - * configuration data. It is also used to hold all state variables needed by - * the pm8xxx-regulator driver as these variables need to be shared between - * pin controlled and non-pin controlled versions of a given regulator, which - * are probed separately. - */ -struct pm8xxx_vreg { - /* Configuration data */ - struct regulator_desc rdesc; - struct regulator_desc rdesc_pc; - enum pm8xxx_regulator_type type; - const int hpm_min_load; - const u16 ctrl_addr; - const u16 test_addr; - const u16 clk_ctrl_addr; - const u16 sleep_ctrl_addr; - const u16 pfm_ctrl_addr; - const u16 pwr_cnfg_addr; - /* State data */ - struct pm8xxx_regulator_platform_data pdata; - struct regulator_dev *rdev; - struct regulator_dev *rdev_pc; - struct device *dev; - struct device *dev_pc; - struct mutex pc_lock; - int save_uV; - int mode; - u32 write_count; - u32 prev_write_count; - bool is_enabled; - bool is_enabled_pc; - u8 test_reg[REGULATOR_TEST_BANKS_MAX]; - u8 ctrl_reg; - u8 clk_ctrl_reg; - u8 sleep_ctrl_reg; - u8 pfm_ctrl_reg; - u8 pwr_cnfg_reg; -}; - -/** - * struct pm8xxx_regulator_core_platform_data - platform data specified in a - * PMIC core driver and utilized in the pm8xxx-regulator driver -* @vreg: pointer to pm8xxx_vreg data structure that may be shared -* between pin controlled and non-pin controlled versions -* of a given regulator. Note that this data must persist -* as long as the regulator device is in use. -* @pdata: pointer to platform data passed in from a board file -* @is_pin_controlled: true if the regulator driver represents the pin control -* portion of a regulator, false if not. -* -* This data structure should only be needed in a PMIC core driver. -*/ -struct pm8xxx_regulator_core_platform_data { - struct pm8xxx_vreg *vreg; - struct pm8xxx_regulator_platform_data *pdata; - bool is_pin_controlled; -}; - -/* Helper macros */ -#define PLDO(_name, _pc_name, _ctrl_addr, _test_addr, _hpm_min_load) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_PLDO, \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \ - .rdesc.name = _name, \ - .rdesc_pc.name = _pc_name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define NLDO(_name, _pc_name, _ctrl_addr, _test_addr, _hpm_min_load) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_NLDO, \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \ - .rdesc.name = _name, \ - .rdesc_pc.name = _pc_name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define NLDO1200(_name, _ctrl_addr, _test_addr, _hpm_min_load) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_NLDO1200, \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \ - .rdesc.name = _name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define SMPS(_name, _pc_name, _ctrl_addr, _test_addr, _clk_ctrl_addr, \ - _sleep_ctrl_addr, _hpm_min_load) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_SMPS, \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .clk_ctrl_addr = _clk_ctrl_addr, \ - .sleep_ctrl_addr = _sleep_ctrl_addr, \ - .hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \ - .rdesc.name = _name, \ - .rdesc_pc.name = _pc_name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define FTSMPS(_name, _pwm_ctrl_addr, _fts_cnfg1_addr, _pfm_ctrl_addr, \ - _pwr_cnfg_addr, _hpm_min_load) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_FTSMPS, \ - .ctrl_addr = _pwm_ctrl_addr, \ - .test_addr = _fts_cnfg1_addr, \ - .pfm_ctrl_addr = _pfm_ctrl_addr, \ - .pwr_cnfg_addr = _pwr_cnfg_addr, \ - .hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \ - .rdesc.name = _name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define VS(_name, _pc_name, _ctrl_addr, _test_addr) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_VS, \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .rdesc.name = _name, \ - .rdesc_pc.name = _pc_name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define VS300(_name, _ctrl_addr, _test_addr) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_VS300, \ - .ctrl_addr = _ctrl_addr, \ - .test_addr = _test_addr, \ - .rdesc.name = _name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define NCP(_name, _ctrl_addr) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_NCP, \ - .ctrl_addr = _ctrl_addr, \ - .rdesc.name = _name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#define BOOST(_name, _ctrl_addr) \ - { \ - .type = PM8XXX_REGULATOR_TYPE_BOOST, \ - .ctrl_addr = _ctrl_addr, \ - .rdesc.name = _name, \ - .write_count = 0, \ - .prev_write_count = -1, \ - } - -#endif diff --git a/include/linux/mfd/pm8xxx/spk.h b/include/linux/mfd/pm8xxx/spk.h deleted file mode 100644 index 9835b85344545afda13c0fb75e5aca32b34fa805..0000000000000000000000000000000000000000 --- a/include/linux/mfd/pm8xxx/spk.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2012, 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 __SPK_PM8XXX_H__ -#define __SPK_PM8XXX_H__ - -#define PM8XXX_SPK_DEV_NAME "pm8xxx-spk" - -/** - * struct pm8xxx_spk_pdata - SPK driver platform data - * @spk_add_enable: variable stating SPK secondary input adding capability - */ -struct pm8xxx_spk_platform_data { - bool spk_add_enable; - int cd_ng_threshold; - int cd_nf_preamp_bias; - int cd_ng_hold; - int cd_ng_max_atten; - int noise_mute; - int cd_ng_decay_rate; - int cd_ng_attack_rate; - int cd_delay; -}; - -/* - * pm8xxx_spk_mute - mute/unmute speaker pamp - * - * @mute: bool value for mute - */ -int pm8xxx_spk_mute(bool mute); - -/* - * pm8xxx_spk_gain - Set Speaker gain - * - * @gain: Speaker gain - */ -int pm8xxx_spk_gain(u8 gain); - -/* - * pm8xxx_spk_enable - Enable/Disable Speaker - * - * @enable: bool enable/disable Speaker - */ -int pm8xxx_spk_enable(int enable); - -#endif /* __SPK_PM8XXX_H__ */ diff --git a/include/linux/mfd/timpani-audio.h b/include/linux/mfd/timpani-audio.h deleted file mode 100644 index 49fd49ba2155ba3e14fee1225ffab3402744d104..0000000000000000000000000000000000000000 --- a/include/linux/mfd/timpani-audio.h +++ /dev/null @@ -1,5016 +0,0 @@ -#ifndef __LINUX_MFD_TIMPANI_AUDIO_H -#define __LINUX_MFD_TIMPANI_AUDIO_H - -/* - * MREF - */ -#define TIMPANI_A_MREF (0x3) -#define TIMPANI_MREF_RWC "RW" -#define TIMPANI_MREF_POR 0xe2 -#define TIMPANI_MREF_S 0 -#define TIMPANI_MREF_M 0xFF - -#define TIMPANI_MREF_MREF_BG_EN_S 7 -#define TIMPANI_MREF_MREF_BG_EN_M 0x80 -#define TIMPANI_MREF_MREF_BG_EN_ENABLE 0x0 -#define TIMPANI_MREF_MREF_BG_EN_DISABLE 0x1 - -#define TIMPANI_MREF_MREF_BG_REF_CUR_EN_S 6 -#define TIMPANI_MREF_MREF_BG_REF_CUR_EN_M 0x40 -#define TIMPANI_MREF_MREF_BG_REF_CUR_EN_ENABLE_NORMAL_OP 0x0 -#define TIMPANI_MREF_MREF_BG_REF_CUR_EN_DISABLE 0x1 - -#define TIMPANI_MREF_MREF_200K_MODE_EN_S 5 -#define TIMPANI_MREF_MREF_200K_MODE_EN_M 0x20 -#define TIMPANI_MREF_MREF_200K_MODE_EN_ENABLE 0x0 -#define TIMPANI_MREF_MREF_200K_MODE_EN_DISABLE 0x1 - -#define TIMPANI_MREF_MREF_PRE_CHARGE_EN_S 4 -#define TIMPANI_MREF_MREF_PRE_CHARGE_EN_M 0x10 -#define TIMPANI_MREF_MREF_PRE_CHARGE_EN_DISABLE 0x0 -#define TIMPANI_MREF_MREF_PRE_CHARGE_EN_ENABLE 0x1 - -#define TIMPANI_MREF_MREF_100UA_CUR_CONN_S 3 -#define TIMPANI_MREF_MREF_100UA_CUR_CONN_M 0x8 -#define TIMPANI_MREF_MREF_100UA_CUR_CONN_ON_CHIP_RESISTOR_NORMAL_OP 0x0 -#define TIMPANI_MREF_MREF_100UA_CUR_CONN_ATEST 0x1 - -#define TIMPANI_MREF_MREF_PTAT_CURRENT_S 2 -#define TIMPANI_MREF_MREF_PTAT_CURRENT_M 0x4 -#define TIMPANI_MREF_MREF_PTAT_CURRENT_V_10UA_PTAT_NORMAL_OP 0x0 -#define TIMPANI_MREF_MREF_PTAT_CURRENT_V_5UA_PTAT_BIAS_CURRENT 0x1 - -#define TIMPANI_MREF_MREF_400K_MODE_EN_S 1 -#define TIMPANI_MREF_MREF_400K_MODE_EN_M 0x2 -#define TIMPANI_MREF_MREF_400K_MODE_EN_ENABLE 0x0 -#define TIMPANI_MREF_MREF_400K_MODE_EN_DISABLE 0x1 - -#define TIMPANI_MREF_RESERVED_S 0 -#define TIMPANI_MREF_RESERVED_M 0x1 - - -/* For CDAC_IDAC_REF_CUR */ -#define TIMPANI_A_CDAC_IDAC_REF_CUR (0x4) -#define TIMPANI_CDAC_IDAC_REF_CUR_RWC "RW" -#define TIMPANI_CDAC_IDAC_REF_CUR_POR 0x8c -#define TIMPANI_CDAC_IDAC_REF_CUR_S 0 -#define TIMPANI_CDAC_IDAC_REF_CUR_M 0xFF - - -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_S 5 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_M 0xE0 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_4UA 0x0 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_6UA 0x1 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_8UA 0x2 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_9UA 0x3 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_10UA_NORMAL_OP 0x4 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_11UA 0x5 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_13UA 0x6 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_REF_BUFF_CUR_V_15UA 0x7 - -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_S 2 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_M 0x1C -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_8_5UA 0x0 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_9_0UA 0x1 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_9_5UA 0x2 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_10_0UA_NORMAL_OP 0x3 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_10_5UA 0x4 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_11_0UA 0x5 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_11_5UA 0x6 -#define TIMPANI_CDAC_IDAC_REF_CUR_CDAC_BIAS_CUR_V_12_0UA 0x7 - -#define TIMPANI_CDAC_IDAC_REF_CUR_IDAC_REF_CUR_S 0 -#define TIMPANI_CDAC_IDAC_REF_CUR_IDAC_REF_CUR_M 0x3 -#define TIMPANI_CDAC_IDAC_REF_CUR_IDAC_REF_CUR_V_2UA 0x0 -#define TIMPANI_CDAC_IDAC_REF_CUR_IDAC_REF_CUR_V_3UA 0x1 -#define TIMPANI_CDAC_IDAC_REF_CUR_IDAC_REF_CUR_V_5UA_NORMAL_OP 0x2 -#define TIMPANI_CDAC_IDAC_REF_CUR_IDAC_REF_CUR_V_8UA 0x3 - - -/* -- For TXADC12_REF_CURR */ -#define TIMPANI_A_TXADC12_REF_CURR (0x5) -#define TIMPANI_TXADC12_REF_CURR_RWC "RW" -#define TIMPANI_TXADC12_REF_CURR_POR 0xa0 -#define TIMPANI_TXADC12_REF_CURR_S 0 -#define TIMPANI_TXADC12_REF_CURR_M 0xFF - - -#define TIMPANI_TXADC12_REF_CURR_TXADC1_REF_BUFF_CUR_S 6 -#define TIMPANI_TXADC12_REF_CURR_TXADC1_REF_BUFF_CUR_M 0xC0 -#define TIMPANI_TXADC12_REF_CURR_TXADC1_REF_BUFF_CUR_V_50UA 0x0 -#define TIMPANI_TXADC12_REF_CURR_TXADC1_REF_BUFF_CUR_V_45UA 0x1 -#define TIMPANI_TXADC12_REF_CURR_TXADC1_REF_BUFF_CUR_V_40UA_NORMAL_OP 0x2 -#define TIMPANI_TXADC12_REF_CURR_TXADC1_REF_BUFF_CUR_V_35UA 0x3 - -#define TIMPANI_TXADC12_REF_CURR_TXADC2_REF_BUFF_CUR_S 4 -#define TIMPANI_TXADC12_REF_CURR_TXADC2_REF_BUFF_CUR_M 0x30 -#define TIMPANI_TXADC12_REF_CURR_TXADC2_REF_BUFF_CUR_V_50UA 0x0 -#define TIMPANI_TXADC12_REF_CURR_TXADC2_REF_BUFF_CUR_V_45UA 0x1 -#define TIMPANI_TXADC12_REF_CURR_TXADC2_REF_BUFF_CUR_V_40UA_NORMAL_OP 0x2 -#define TIMPANI_TXADC12_REF_CURR_TXADC2_REF_BUFF_CUR_V_35UA 0x3 - -#define TIMPANI_TXADC12_REF_CURR_RESERVED_S 0 -#define TIMPANI_TXADC12_REF_CURR_RESERVED_M 0xF - - -/* -- For TXADC3_EN */ -#define TIMPANI_A_TXADC3_EN (0x9) -#define TIMPANI_TXADC3_EN_RWC "RW" -#define TIMPANI_TXADC3_EN_POR 0 -#define TIMPANI_TXADC3_EN_S 0 -#define TIMPANI_TXADC3_EN_M 0xFF - - -#define TIMPANI_TXADC3_EN_TXADC3_REF_EN_S 7 -#define TIMPANI_TXADC3_EN_TXADC3_REF_EN_M 0x80 -#define TIMPANI_TXADC3_EN_TXADC3_REF_EN_DISABLE 0x0 -#define TIMPANI_TXADC3_EN_TXADC3_REF_EN_ENABLE 0x1 - -#define TIMPANI_TXADC3_EN_TXADC3_DAC_REF_CUR_COMPENSATION_EN_S 6 -#define TIMPANI_TXADC3_EN_TXADC3_DAC_REF_CUR_COMPENSATION_EN_M 0x40 -#define TIMPANI_TXADC3_EN_TXADC3_DAC_REF_CUR_COMPENSATION_EN_DISABLE 0x0 -#define TIMPANI_TXADC3_EN_TXADC3_DAC_REF_CUR_COMPENSATION_EN_ENABLE 0x1 - -#define TIMPANI_TXADC3_EN_TXADC3_OTA1_EN_S 5 -#define TIMPANI_TXADC3_EN_TXADC3_OTA1_EN_M 0x20 -#define TIMPANI_TXADC3_EN_TXADC3_OTA1_EN_DISABLE 0x0 -#define TIMPANI_TXADC3_EN_TXADC3_OTA1_EN_ENABLE 0x1 - -#define TIMPANI_TXADC3_EN_TXADC3_OTA2_EN_S 4 -#define TIMPANI_TXADC3_EN_TXADC3_OTA2_EN_M 0x10 -#define TIMPANI_TXADC3_EN_TXADC3_OTA2_EN_DISABLE 0x0 -#define TIMPANI_TXADC3_EN_TXADC3_OTA2_EN_ENABLE 0x1 - -#define TIMPANI_TXADC3_EN_TXADC3_COMP_EN_S 3 -#define TIMPANI_TXADC3_EN_TXADC3_COMP_EN_M 0x8 -#define TIMPANI_TXADC3_EN_TXADC3_COMP_EN_DISABLE 0x0 -#define TIMPANI_TXADC3_EN_TXADC3_COMP_EN_ENABLE 0x1 - -#define TIMPANI_TXADC3_EN_TXADC3_DEM_EN_S 2 -#define TIMPANI_TXADC3_EN_TXADC3_DEM_EN_M 0x4 -#define TIMPANI_TXADC3_EN_TXADC3_DEM_EN_DISABLE 0x0 -#define TIMPANI_TXADC3_EN_TXADC3_DEM_EN_ENABLE 0x1 - -#define TIMPANI_TXADC3_EN_TXADC3_DEM_ERROR_DET_EN_S 1 -#define TIMPANI_TXADC3_EN_TXADC3_DEM_ERROR_DET_EN_M 0x2 -#define TIMPANI_TXADC3_EN_TXADC3_DEM_ERROR_DET_EN_DISABLE 0x0 -#define TIMPANI_TXADC3_EN_TXADC3_DEM_ERROR_DET_EN_ENABLE 0x1 - -#define TIMPANI_TXADC3_EN_RESERVED_S 0 -#define TIMPANI_TXADC3_EN_RESERVED_M 0x1 - - -/* -- For TXADC4_EN */ -#define TIMPANI_A_TXADC4_EN (0xA) -#define TIMPANI_TXADC4_EN_RWC "RW" -#define TIMPANI_TXADC4_EN_POR 0 -#define TIMPANI_TXADC4_EN_S 0 -#define TIMPANI_TXADC4_EN_M 0xFF - - -#define TIMPANI_TXADC4_EN_TXADC4_REF_EN_S 7 -#define TIMPANI_TXADC4_EN_TXADC4_REF_EN_M 0x80 -#define TIMPANI_TXADC4_EN_TXADC4_REF_EN_DISABLE 0x0 -#define TIMPANI_TXADC4_EN_TXADC4_REF_EN_ENABLE 0x1 - -#define TIMPANI_TXADC4_EN_TXADC4_DAC_REF_CUR_COMPENSATION_EN_S 6 -#define TIMPANI_TXADC4_EN_TXADC4_DAC_REF_CUR_COMPENSATION_EN_M 0x40 -#define TIMPANI_TXADC4_EN_TXADC4_DAC_REF_CUR_COMPENSATION_EN_DISABLE 0x0 -#define TIMPANI_TXADC4_EN_TXADC4_DAC_REF_CUR_COMPENSATION_EN_ENABLE 0x1 - -#define TIMPANI_TXADC4_EN_TXADC4_OTA1_EN_S 5 -#define TIMPANI_TXADC4_EN_TXADC4_OTA1_EN_M 0x20 -#define TIMPANI_TXADC4_EN_TXADC4_OTA1_EN_DISABLE 0x0 -#define TIMPANI_TXADC4_EN_TXADC4_OTA1_EN_ENABLE 0x1 - -#define TIMPANI_TXADC4_EN_TXADC4_OTA2_EN_S 4 -#define TIMPANI_TXADC4_EN_TXADC4_OTA2_EN_M 0x10 -#define TIMPANI_TXADC4_EN_TXADC4_OTA2_EN_DISABLE 0x0 -#define TIMPANI_TXADC4_EN_TXADC4_OTA2_EN_ENABLE 0x1 - -#define TIMPANI_TXADC4_EN_TXADC4_COMP_EN_S 3 -#define TIMPANI_TXADC4_EN_TXADC4_COMP_EN_M 0x8 -#define TIMPANI_TXADC4_EN_TXADC4_COMP_EN_DISABLE 0x0 -#define TIMPANI_TXADC4_EN_TXADC4_COMP_EN_ENABLE 0x1 - -#define TIMPANI_TXADC4_EN_TXADC4_DEM_EN_S 2 -#define TIMPANI_TXADC4_EN_TXADC4_DEM_EN_M 0x4 -#define TIMPANI_TXADC4_EN_TXADC4_DEM_EN_DISABLE 0x0 -#define TIMPANI_TXADC4_EN_TXADC4_DEM_EN_ENABLE 0x1 - -#define TIMPANI_TXADC4_EN_TXADC4_DEM_ERROR_DET_EN_S 1 -#define TIMPANI_TXADC4_EN_TXADC4_DEM_ERROR_DET_EN_M 0x2 -#define TIMPANI_TXADC4_EN_TXADC4_DEM_ERROR_DET_EN_DISABLE 0x0 -#define TIMPANI_TXADC4_EN_TXADC4_DEM_ERROR_DET_EN_ENABLE 0x1 - -#define TIMPANI_TXADC4_EN_RESERVED_S 0 -#define TIMPANI_TXADC4_EN_RESERVED_M 0x1 - - -/* -- For CODEC_TXADC_STATUS_REGISTER_1 */ -#define TIMPANI_A_CODEC_TXADC_STATUS_REGISTER_1 (0xB) -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_RWC "R" -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_POR 0 -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_S 0 -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_M 0xFF - - -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC1_DEM_ERROR_S 7 -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC1_DEM_ERROR_M 0x80 - -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC2_DEM_ERROR_S 6 -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC2_DEM_ERROR_M 0x40 - -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC3_DEM_ERROR_S 5 -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC3_DEM_ERROR_M 0x20 - -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC4_DEM_ERROR_S 4 -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_TXADC4_DEM_ERROR_M 0x10 - -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_RESERVED_S 0 -#define TIMPANI_CODEC_TXADC_STATUS_REGISTER_1_RESERVED_M 0xF - - -/* -- For TXFE1 */ -#define TIMPANI_A_TXFE1 (0xD) -#define TIMPANI_TXFE1_RWC "RW" -#define TIMPANI_TXFE1_POR 0 -#define TIMPANI_TXFE1_S 0 -#define TIMPANI_TXFE1_M 0xFF - - -#define TIMPANI_TXFE1_TXFE1_EN_S 7 -#define TIMPANI_TXFE1_TXFE1_EN_M 0x80 -#define TIMPANI_TXFE1_TXFE1_EN_DISABLE 0x0 -#define TIMPANI_TXFE1_TXFE1_EN_ENABLE 0x1 - -#define TIMPANI_TXFE1_TXFE1_GAIN_S 5 -#define TIMPANI_TXFE1_TXFE1_GAIN_M 0x60 -#define TIMPANI_TXFE1_TXFE1_GAIN_V_0DB 0x0 -#define TIMPANI_TXFE1_TXFE1_GAIN_V_4_5DB 0x1 -#define TIMPANI_TXFE1_TXFE1_GAIN_V_24DB_1 0x2 -#define TIMPANI_TXFE1_TXFE1_GAIN_V_24DB_2 0x3 - -#define TIMPANI_TXFE1_TXFE1_IN_MIC1_CONN_S 4 -#define TIMPANI_TXFE1_TXFE1_IN_MIC1_CONN_M 0x10 -#define TIMPANI_TXFE1_TXFE1_IN_MIC1_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE1_TXFE1_IN_MIC1_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE1_TXFE1_IN_MIC2_CONN_S 3 -#define TIMPANI_TXFE1_TXFE1_IN_MIC2_CONN_M 0x8 -#define TIMPANI_TXFE1_TXFE1_IN_MIC2_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE1_TXFE1_IN_MIC2_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_L_CONN_S 2 -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_L_CONN_M 0x4 -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_L_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_R_CONN_S 1 -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_R_CONN_M 0x2 -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE1_TXFE1_IN_LINE_I_R_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE1_TXFE1_IN_AUXI_CONN_S 0 -#define TIMPANI_TXFE1_TXFE1_IN_AUXI_CONN_M 0x1 -#define TIMPANI_TXFE1_TXFE1_IN_AUXI_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE1_TXFE1_IN_AUXI_CONN_CONNECT 0x1 - - -/* -- For TXFE2 */ -#define TIMPANI_A_TXFE2 (0xE) -#define TIMPANI_TXFE2_RWC "RW" -#define TIMPANI_TXFE2_POR 0 -#define TIMPANI_TXFE2_S 0 -#define TIMPANI_TXFE2_M 0xFF - - -#define TIMPANI_TXFE2_TXFE2_EN_S 7 -#define TIMPANI_TXFE2_TXFE2_EN_M 0x80 -#define TIMPANI_TXFE2_TXFE2_EN_DISABLE 0x0 -#define TIMPANI_TXFE2_TXFE2_EN_ENABLE 0x1 - -#define TIMPANI_TXFE2_TXFE2_GAIN_S 5 -#define TIMPANI_TXFE2_TXFE2_GAIN_M 0x60 -#define TIMPANI_TXFE2_TXFE2_GAIN_V_0DB 0x0 -#define TIMPANI_TXFE2_TXFE2_GAIN_V_4_5DB 0x1 -#define TIMPANI_TXFE2_TXFE2_GAIN_V_24DB_1 0x2 -#define TIMPANI_TXFE2_TXFE2_GAIN_V_24DB_2 0x3 - -#define TIMPANI_TXFE2_TXFE2_IN_MIC1_CONN_S 4 -#define TIMPANI_TXFE2_TXFE2_IN_MIC1_CONN_M 0x10 -#define TIMPANI_TXFE2_TXFE2_IN_MIC1_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE2_TXFE2_IN_MIC1_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE2_TXFE2_IN_MIC2_CONN_S 3 -#define TIMPANI_TXFE2_TXFE2_IN_MIC2_CONN_M 0x8 -#define TIMPANI_TXFE2_TXFE2_IN_MIC2_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE2_TXFE2_IN_MIC2_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_L_CONN_S 2 -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_L_CONN_M 0x4 -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_L_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_R_CONN_S 1 -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_R_CONN_M 0x2 -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE2_TXFE2_IN_LINE_I_R_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE2_TXFE2_IN_AUXI_CONN_S 0 -#define TIMPANI_TXFE2_TXFE2_IN_AUXI_CONN_M 0x1 -#define TIMPANI_TXFE2_TXFE2_IN_AUXI_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE2_TXFE2_IN_AUXI_CONN_CONNECT 0x1 - - -/* -- For TXFE12_ATEST */ -#define TIMPANI_A_TXFE12_ATEST (0xF) -#define TIMPANI_TXFE12_ATEST_RWC "RW" -#define TIMPANI_TXFE12_ATEST_POR 0 -#define TIMPANI_TXFE12_ATEST_S 0 -#define TIMPANI_TXFE12_ATEST_M 0xFF - - -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_SHORT_TO_VICM_EN_S 7 -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_SHORT_TO_VICM_EN_M 0x80 -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_SHORT_TO_VICM_EN_DISABLE 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_SHORT_TO_VICM_EN_ENABLE 0x1 - -#define TIMPANI_TXFE12_ATEST_TXFE1_BYPASS_EN_S 6 -#define TIMPANI_TXFE12_ATEST_TXFE1_BYPASS_EN_M 0x40 -#define TIMPANI_TXFE12_ATEST_TXFE1_BYPASS_EN_DISABLE 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE1_BYPASS_EN_ENABLE 0x1 - -#define TIMPANI_TXFE12_ATEST_TXFE1_CMOUT_ATEST_CONN_S 5 -#define TIMPANI_TXFE12_ATEST_TXFE1_CMOUT_ATEST_CONN_M 0x20 -#define TIMPANI_TXFE12_ATEST_TXFE1_CMOUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE1_CMOUT_ATEST_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_ATEST_CONN_S 4 -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_ATEST_CONN_M 0x10 -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE1_OUT_ATEST_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_SHORT_TO_VICM_EN_S 3 -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_SHORT_TO_VICM_EN_M 0x8 -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_SHORT_TO_VICM_EN_DISABLE 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_SHORT_TO_VICM_EN_ENABLE 0x1 - -#define TIMPANI_TXFE12_ATEST_TXFE2_BYPASS_EN_S 2 -#define TIMPANI_TXFE12_ATEST_TXFE2_BYPASS_EN_M 0x4 -#define TIMPANI_TXFE12_ATEST_TXFE2_BYPASS_EN_DISABLE 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE2_BYPASS_EN_ENABLE 0x1 - -#define TIMPANI_TXFE12_ATEST_TXFE2_CMOUT_ATEST_CONN_S 1 -#define TIMPANI_TXFE12_ATEST_TXFE2_CMOUT_ATEST_CONN_M 0x2 -#define TIMPANI_TXFE12_ATEST_TXFE2_CMOUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE2_CMOUT_ATEST_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_ATEST_CONN_S 0 -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_ATEST_CONN_M 0x1 -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE12_ATEST_TXFE2_OUT_ATEST_CONN_CONNECT 0x1 - - -/* -- For TXFE_CLT */ -#define TIMPANI_A_TXFE_CLT (0x10) -#define TIMPANI_TXFE_CLT_RWC "RW" -#define TIMPANI_TXFE_CLT_POR 0x68 -#define TIMPANI_TXFE_CLT_S 0 -#define TIMPANI_TXFE_CLT_M 0xFF - - -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_S 5 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_M 0xE0 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_1_125V 0x0 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_1_100V 0x1 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_1_075V 0x2 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_1_050V_NORMAL_OP 0x3 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_1_025V 0x4 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_1_000V 0x5 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_0_975V 0x6 -#define TIMPANI_TXFE_CLT_TXFE_OUT_CM_VOLT_V_0_950V 0x7 - -#define TIMPANI_TXFE_CLT_TXFE_BIAS_CUR_S 3 -#define TIMPANI_TXFE_CLT_TXFE_BIAS_CUR_M 0x18 -#define TIMPANI_TXFE_CLT_TXFE_BIAS_CUR_V_3UA 0x0 -#define TIMPANI_TXFE_CLT_TXFE_BIAS_CUR_V_4UA_NORMAL_OP 0x1 -#define TIMPANI_TXFE_CLT_TXFE_BIAS_CUR_V_6UA 0x2 -#define TIMPANI_TXFE_CLT_TXFE_BIAS_CUR_V_8UA 0x3 - -#define TIMPANI_TXFE_CLT_RESERVED_S 0 -#define TIMPANI_TXFE_CLT_RESERVED_M 0x7 - - -/* -- For TXADC1_EN */ -#define TIMPANI_A_TXADC1_EN (0x11) -#define TIMPANI_TXADC1_EN_RWC "RW" -#define TIMPANI_TXADC1_EN_POR 0 -#define TIMPANI_TXADC1_EN_S 0 -#define TIMPANI_TXADC1_EN_M 0xFF - - -#define TIMPANI_TXADC1_EN_TXADC1_REF_EN_S 7 -#define TIMPANI_TXADC1_EN_TXADC1_REF_EN_M 0x80 -#define TIMPANI_TXADC1_EN_TXADC1_REF_EN_DISABLE 0x0 -#define TIMPANI_TXADC1_EN_TXADC1_REF_EN_ENABLE 0x1 - -#define TIMPANI_TXADC1_EN_TXADC1_DAC_REF_CUR_COMPENSATION_EN_S 6 -#define TIMPANI_TXADC1_EN_TXADC1_DAC_REF_CUR_COMPENSATION_EN_M 0x40 -#define TIMPANI_TXADC1_EN_TXADC1_DAC_REF_CUR_COMPENSATION_EN_DISABLE 0x0 -#define TIMPANI_TXADC1_EN_TXADC1_DAC_REF_CUR_COMPENSATION_EN_ENABLE 0x1 - -#define TIMPANI_TXADC1_EN_TXADC1_OTA1_EN_S 5 -#define TIMPANI_TXADC1_EN_TXADC1_OTA1_EN_M 0x20 -#define TIMPANI_TXADC1_EN_TXADC1_OTA1_EN_DISABLE 0x0 -#define TIMPANI_TXADC1_EN_TXADC1_OTA1_EN_ENABLE 0x1 - -#define TIMPANI_TXADC1_EN_TXADC1_OTA2_EN_S 4 -#define TIMPANI_TXADC1_EN_TXADC1_OTA2_EN_M 0x10 -#define TIMPANI_TXADC1_EN_TXADC1_OTA2_EN_DISABLE 0x0 -#define TIMPANI_TXADC1_EN_TXADC1_OTA2_EN_ENABLE 0x1 - -#define TIMPANI_TXADC1_EN_TXADC1_COMP_EN_S 3 -#define TIMPANI_TXADC1_EN_TXADC1_COMP_EN_M 0x8 -#define TIMPANI_TXADC1_EN_TXADC1_COMP_EN_DISABLE 0x0 -#define TIMPANI_TXADC1_EN_TXADC1_COMP_EN_ENABLE 0x1 - -#define TIMPANI_TXADC1_EN_TXADC1_DEM_EN_S 2 -#define TIMPANI_TXADC1_EN_TXADC1_DEM_EN_M 0x4 -#define TIMPANI_TXADC1_EN_TXADC1_DEM_EN_DISABLE 0x0 -#define TIMPANI_TXADC1_EN_TXADC1_DEM_EN_ENABLE 0x1 - -#define TIMPANI_TXADC1_EN_TXADC1_DEM_ERROR_DET_EN_S 1 -#define TIMPANI_TXADC1_EN_TXADC1_DEM_ERROR_DET_EN_M 0x2 -#define TIMPANI_TXADC1_EN_TXADC1_DEM_ERROR_DET_EN_DISABLE 0x0 -#define TIMPANI_TXADC1_EN_TXADC1_DEM_ERROR_DET_EN_ENABLE 0x1 - -#define TIMPANI_TXADC1_EN_RESERVED_S 0 -#define TIMPANI_TXADC1_EN_RESERVED_M 0x1 - - -/* -- For TXADC2_EN */ -#define TIMPANI_A_TXADC2_EN (0x12) -#define TIMPANI_TXADC2_EN_RWC "RW" -#define TIMPANI_TXADC2_EN_POR 0 -#define TIMPANI_TXADC2_EN_S 0 -#define TIMPANI_TXADC2_EN_M 0xFF - - -#define TIMPANI_TXADC2_EN_TXADC2_REF_EN_S 7 -#define TIMPANI_TXADC2_EN_TXADC2_REF_EN_M 0x80 -#define TIMPANI_TXADC2_EN_TXADC2_REF_EN_DISABLE 0x0 -#define TIMPANI_TXADC2_EN_TXADC2_REF_EN_ENABLE 0x1 - -#define TIMPANI_TXADC2_EN_TXADC2_DAC_REF_CUR_COMPENSATION_EN_S 6 -#define TIMPANI_TXADC2_EN_TXADC2_DAC_REF_CUR_COMPENSATION_EN_M 0x40 -#define TIMPANI_TXADC2_EN_TXADC2_DAC_REF_CUR_COMPENSATION_EN_DISABLE 0x0 -#define TIMPANI_TXADC2_EN_TXADC2_DAC_REF_CUR_COMPENSATION_EN_ENABLE 0x1 - -#define TIMPANI_TXADC2_EN_TXADC2_OTA1_EN_S 5 -#define TIMPANI_TXADC2_EN_TXADC2_OTA1_EN_M 0x20 -#define TIMPANI_TXADC2_EN_TXADC2_OTA1_EN_DISABLE 0x0 -#define TIMPANI_TXADC2_EN_TXADC2_OTA1_EN_ENABLE 0x1 - -#define TIMPANI_TXADC2_EN_TXADC2_OTA2_EN_S 4 -#define TIMPANI_TXADC2_EN_TXADC2_OTA2_EN_M 0x10 -#define TIMPANI_TXADC2_EN_TXADC2_OTA2_EN_DISABLE 0x0 -#define TIMPANI_TXADC2_EN_TXADC2_OTA2_EN_ENABLE 0x1 - -#define TIMPANI_TXADC2_EN_TXADC2_COMP_EN_S 3 -#define TIMPANI_TXADC2_EN_TXADC2_COMP_EN_M 0x8 -#define TIMPANI_TXADC2_EN_TXADC2_COMP_EN_DISABLE 0x0 -#define TIMPANI_TXADC2_EN_TXADC2_COMP_EN_ENABLE 0x1 - -#define TIMPANI_TXADC2_EN_TXADC2_DEM_EN_S 2 -#define TIMPANI_TXADC2_EN_TXADC2_DEM_EN_M 0x4 -#define TIMPANI_TXADC2_EN_TXADC2_DEM_EN_DISABLE 0x0 -#define TIMPANI_TXADC2_EN_TXADC2_DEM_EN_ENABLE 0x1 - -#define TIMPANI_TXADC2_EN_TXADC2_DEM_ERROR_DET_EN_S 1 -#define TIMPANI_TXADC2_EN_TXADC2_DEM_ERROR_DET_EN_M 0x2 -#define TIMPANI_TXADC2_EN_TXADC2_DEM_ERROR_DET_EN_DISABLE 0x0 -#define TIMPANI_TXADC2_EN_TXADC2_DEM_ERROR_DET_EN_ENABLE 0x1 - -#define TIMPANI_TXADC2_EN_RESERVED_S 0 -#define TIMPANI_TXADC2_EN_RESERVED_M 0x1 - - -/* -- For TXADC_CTL */ -#define TIMPANI_A_TXADC_CTL (0x13) -#define TIMPANI_TXADC_CTL_RWC "RW" -#define TIMPANI_TXADC_CTL_POR 0x58 -#define TIMPANI_TXADC_CTL_S 0 -#define TIMPANI_TXADC_CTL_M 0xFF - - -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_DDA_AMP_BIAS_CUR_S 6 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_DDA_AMP_BIAS_CUR_M 0xC0 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_DDA_AMP_BIAS_CUR_V_5UA 0x0 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_DDA_AMP_BIAS_CUR_V_10UA_NORMAL_OP 0x1 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_DDA_AMP_BIAS_CUR_V_15UA 0x2 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_DDA_AMP_BIAS_CUR_V_20UA 0x3 - -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_SRC_FOLLOWER_BIAS_CUR_S 4 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_SRC_FOLLOWER_BIAS_CUR_M 0x30 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_SRC_FOLLOWER_BIAS_CUR_V_40UA 0x0 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_SRC_FOLLOWER_BIAS_CUR_V_80UA 0x1 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_SRC_FOLLOWER_BIAS_CUR_V_120UA 0x2 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_SRC_FOLLOWER_BIAS_CUR_V_160UA 0x3 - -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_VOLT_S 2 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_VOLT_M 0xC -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_VOLT_V_1_8V 0x0 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_VOLT_V_1_7V 0x1 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_VOLT_V_1_6V_NORMAL_OP 0x2 -#define TIMPANI_TXADC_CTL_TXADC_DAC_REF_VOLT_V_1_5V 0x3 - -#define TIMPANI_TXADC_CTL_TXADC_VREFMID_BIAS_CUR_S 0 -#define TIMPANI_TXADC_CTL_TXADC_VREFMID_BIAS_CUR_M 0x3 -#define TIMPANI_TXADC_CTL_TXADC_VREFMID_BIAS_CUR_V_20UA_NORMAL_OP 0x0 -#define TIMPANI_TXADC_CTL_TXADC_VREFMID_BIAS_CUR_V_40UA 0x1 -#define TIMPANI_TXADC_CTL_TXADC_VREFMID_BIAS_CUR_V_80UA 0x2 -#define TIMPANI_TXADC_CTL_TXADC_VREFMID_BIAS_CUR_V_160UA 0x3 - - -/* -- For TXADC_CTL2 */ -#define TIMPANI_A_TXADC_CTL2 (0x14) -#define TIMPANI_TXADC_CTL2_RWC "RW" -#define TIMPANI_TXADC_CTL2_POR 0x64 -#define TIMPANI_TXADC_CTL2_S 0 -#define TIMPANI_TXADC_CTL2_M 0xFF - - -#define TIMPANI_TXADC_CTL2_TXADC_COMP_THRESH_VOLT_S 6 -#define TIMPANI_TXADC_CTL2_TXADC_COMP_THRESH_VOLT_M 0xC0 -#define TIMPANI_TXADC_CTL2_TXADC_COMP_THRESH_VOLT_V_333MV 0x0 -#define TIMPANI_TXADC_CTL2_TXADC_COMP_THRESH_VOLT_V_356MV_NORMAL_OP 0x1 -#define TIMPANI_TXADC_CTL2_TXADC_COMP_THRESH_VOLT_V_378MV 0x2 -#define TIMPANI_TXADC_CTL2_TXADC_COMP_THRESH_VOLT_V_400MV 0x3 - -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_BIAS_CUR_S 4 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_BIAS_CUR_M 0x30 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_BIAS_CUR_V_50UA 0x0 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_BIAS_CUR_V_100UA 0x1 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_BIAS_CUR_V_200UA_NORMAL_OP 0x2 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_BIAS_CUR_V_400UA 0x3 - -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_OUT_VOLT_S 2 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_OUT_VOLT_M 0xC -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_OUT_VOLT_V_1_1V 0x0 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_OUT_VOLT_V_1_15V_NORMAL_OP 0x1 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_OUT_VOLT_V_1_2V 0x2 -#define TIMPANI_TXADC_CTL2_TXADC_VICM_REF_BUFF_OUT_VOLT_V_1_25V 0x3 - -#define TIMPANI_TXADC_CTL2_TXADC_VOCM_BUFFER_BIAS_CUR_S 1 -#define TIMPANI_TXADC_CTL2_TXADC_VOCM_BUFFER_BIAS_CUR_M 0x2 -#define TIMPANI_TXADC_CTL2_TXADC_VOCM_BUFFER_BIAS_CUR_V_50UA_NORMAL_OP 0x0 -#define TIMPANI_TXADC_CTL2_TXADC_VOCM_BUFFER_BIAS_CUR_V_100UA 0x1 - -#define TIMPANI_TXADC_CTL2_TXADC_DIG_OUT_EN_S 0 -#define TIMPANI_TXADC_CTL2_TXADC_DIG_OUT_EN_M 0x1 -#define TIMPANI_TXADC_CTL2_TXADC_DIG_OUT_EN_DISABLE 0x0 -#define TIMPANI_TXADC_CTL2_TXADC_DIG_OUT_EN_ENABLE_NORMAL_OP 0x1 - - -/* -- For TXADC_CTL3 */ -#define TIMPANI_A_TXADC_CTL3 (0x15) -#define TIMPANI_TXADC_CTL3_RWC "RW" -#define TIMPANI_TXADC_CTL3_POR 0x64 -#define TIMPANI_TXADC_CTL3_S 0 -#define TIMPANI_TXADC_CTL3_M 0xFF - - -#define TIMPANI_TXADC_CTL3_TXADC_VOCM_REF_BUFF_VOLT_S 6 -#define TIMPANI_TXADC_CTL3_TXADC_VOCM_REF_BUFF_VOLT_M 0xC0 -#define TIMPANI_TXADC_CTL3_TXADC_VOCM_REF_BUFF_VOLT_V_0_85V 0x0 -#define TIMPANI_TXADC_CTL3_TXADC_VOCM_REF_BUFF_VOLT_V_0_90V_NORMAL_OP 0x1 -#define TIMPANI_TXADC_CTL3_TXADC_VOCM_REF_BUFF_VOLT_V_0_95V 0x2 -#define TIMPANI_TXADC_CTL3_TXADC_VOCM_REF_BUFF_VOLT_V_1_00V 0x3 - -#define TIMPANI_TXADC_CTL3_TXADC_OTA1_BIAS_CUR_S 4 -#define TIMPANI_TXADC_CTL3_TXADC_OTA1_BIAS_CUR_M 0x30 -#define TIMPANI_TXADC_CTL3_TXADC_OTA1_BIAS_CUR_V_10UA 0x0 -#define TIMPANI_TXADC_CTL3_TXADC_OTA1_BIAS_CUR_V_15UA 0x1 -#define TIMPANI_TXADC_CTL3_TXADC_OTA1_BIAS_CUR_V_20UA_NORMAL_OP 0x2 -#define TIMPANI_TXADC_CTL3_TXADC_OTA1_BIAS_CUR_V_25UA 0x3 - -#define TIMPANI_TXADC_CTL3_TXADC_OTA2_BIAS_CUR_S 2 -#define TIMPANI_TXADC_CTL3_TXADC_OTA2_BIAS_CUR_M 0xC -#define TIMPANI_TXADC_CTL3_TXADC_OTA2_BIAS_CUR_V_5UA 0x0 -#define TIMPANI_TXADC_CTL3_TXADC_OTA2_BIAS_CUR_V_10UA_NORMAL_OP 0x1 -#define TIMPANI_TXADC_CTL3_TXADC_OTA2_BIAS_CUR_V_15UA 0x2 -#define TIMPANI_TXADC_CTL3_TXADC_OTA2_BIAS_CUR_V_20UA 0x3 - -#define TIMPANI_TXADC_CTL3_TXADC_COMP_BIAS_CUR_S 1 -#define TIMPANI_TXADC_CTL3_TXADC_COMP_BIAS_CUR_M 0x2 -#define TIMPANI_TXADC_CTL3_TXADC_COMP_BIAS_CUR_V_5UA_NORMAL_OP 0x0 -#define TIMPANI_TXADC_CTL3_TXADC_COMP_BIAS_CUR_V_10UA 0x1 - -#define TIMPANI_TXADC_CTL3_RESERVED_S 0 -#define TIMPANI_TXADC_CTL3_RESERVED_M 0x1 - - -/* -- For TXADC_CHOP_CTL */ -#define TIMPANI_A_TXADC_CHOP_CTL (0x16) -#define TIMPANI_TXADC_CHOP_CTL_RWC "RW" -#define TIMPANI_TXADC_CHOP_CTL_POR 0 -#define TIMPANI_TXADC_CHOP_CTL_S 0 -#define TIMPANI_TXADC_CHOP_CTL_M 0xFF - - -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_EN_S 7 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_EN_M 0x80 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_EN_DISABLE 0x0 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_EN_ENABLE 0x1 - -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_S 4 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_M 0x70 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_2_NORMAL_OP 0x0 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_4 0x1 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_8 0x2 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_16 0x3 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_32 0x4 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_64 0x5 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_128 0x6 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_DIV_RATIO_V_256 0x7 - -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_STATE_RESET_S 3 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_STATE_RESET_M 0x8 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_STATE_RESET_NORMAL_OP 0x0 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_STATE_RESET_RESET_CHOP 0x1 - -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_CLK_PHASE_SEL_S 2 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_CLK_PHASE_SEL_M 0x4 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_CLK_PHASE_SEL_FALLING_EDGE_CK1 0x0 -#define TIMPANI_TXADC_CHOP_CTL_TXADC_CHOP_CLK_PHASE_SEL_FALLING_EDGE_CK2 0x1 - -#define TIMPANI_TXADC_CHOP_CTL_RESERVED_S 0 -#define TIMPANI_TXADC_CHOP_CTL_RESERVED_M 0x3 - - -/* -- For TXFE3 */ -#define TIMPANI_A_TXFE3 (0x18) -#define TIMPANI_TXFE3_RWC "RW" -#define TIMPANI_TXFE3_POR 0 -#define TIMPANI_TXFE3_S 0 -#define TIMPANI_TXFE3_M 0xFF - - -#define TIMPANI_TXFE3_TXFE3_EN_S 7 -#define TIMPANI_TXFE3_TXFE3_EN_M 0x80 -#define TIMPANI_TXFE3_TXFE3_EN_DISABLE 0x0 -#define TIMPANI_TXFE3_TXFE3_EN_ENABLE 0x1 - -#define TIMPANI_TXFE3_TXFE3_GAIN_S 5 -#define TIMPANI_TXFE3_TXFE3_GAIN_M 0x60 -#define TIMPANI_TXFE3_TXFE3_GAIN_V_0DB 0x0 -#define TIMPANI_TXFE3_TXFE3_GAIN_V_4_5DB 0x1 -#define TIMPANI_TXFE3_TXFE3_GAIN_V_24DB_1 0x2 -#define TIMPANI_TXFE3_TXFE3_GAIN_V_24DB_2 0x3 - -#define TIMPANI_TXFE3_RESERVED_1_S 2 -#define TIMPANI_TXFE3_RESERVED_1_M 0x1C - -#define TIMPANI_TXFE3_TXFE3_IN_CONN_S 1 -#define TIMPANI_TXFE3_TXFE3_IN_CONN_M 0x2 -#define TIMPANI_TXFE3_TXFE3_IN_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE3_TXFE3_IN_CONN_LINE_IN_L 0x1 - -#define TIMPANI_TXFE3_RESERVED_2_S 0 -#define TIMPANI_TXFE3_RESERVED_2_M 0x1 - - -/* -- For TXFE4 */ -#define TIMPANI_A_TXFE4 (0x19) -#define TIMPANI_TXFE4_RWC "RW" -#define TIMPANI_TXFE4_POR 0 -#define TIMPANI_TXFE4_S 0 -#define TIMPANI_TXFE4_M 0xFF - - -#define TIMPANI_TXFE4_TXFE4_EN_S 7 -#define TIMPANI_TXFE4_TXFE4_EN_M 0x80 -#define TIMPANI_TXFE4_TXFE4_EN_DISABLE 0x0 -#define TIMPANI_TXFE4_TXFE4_EN_ENABLE 0x1 - -#define TIMPANI_TXFE4_TXFE4_GAIN_S 5 -#define TIMPANI_TXFE4_TXFE4_GAIN_M 0x60 -#define TIMPANI_TXFE4_TXFE4_GAIN_V_0DB 0x0 -#define TIMPANI_TXFE4_TXFE4_GAIN_V_4_5DB 0x1 -#define TIMPANI_TXFE4_TXFE4_GAIN_V_24DB_1 0x2 -#define TIMPANI_TXFE4_TXFE4_GAIN_V_24DB_2 0x3 - -#define TIMPANI_TXFE4_RESERVED_1_S 2 -#define TIMPANI_TXFE4_RESERVED_1_M 0x1C - -#define TIMPANI_TXFE4_TXFE4_IN_CONN_S 1 -#define TIMPANI_TXFE4_TXFE4_IN_CONN_M 0x2 -#define TIMPANI_TXFE4_TXFE4_IN_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE4_TXFE4_IN_CONN_LINE_IN_R 0x1 - -#define TIMPANI_TXFE4_RESERVED_2_S 0 -#define TIMPANI_TXFE4_RESERVED_2_M 0x1 - - -/* -- For TXFE3_ATEST */ -#define TIMPANI_A_TXFE3_ATEST (0x1A) -#define TIMPANI_TXFE3_ATEST_RWC "RW" -#define TIMPANI_TXFE3_ATEST_POR 0 -#define TIMPANI_TXFE3_ATEST_S 0 -#define TIMPANI_TXFE3_ATEST_M 0xFF - - -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_SHORT_TO_VICM_EN_S 7 -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_SHORT_TO_VICM_EN_M 0x80 -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_SHORT_TO_VICM_EN_DISABLE 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_SHORT_TO_VICM_EN_ENABLE 0x1 - -#define TIMPANI_TXFE3_ATEST_TXFE3_BYPASS_EN_S 6 -#define TIMPANI_TXFE3_ATEST_TXFE3_BYPASS_EN_M 0x40 -#define TIMPANI_TXFE3_ATEST_TXFE3_BYPASS_EN_DISABLE 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE3_BYPASS_EN_ENABLE 0x1 - -#define TIMPANI_TXFE3_ATEST_TXFE3_CMOUT_ATEST_CONN_S 5 -#define TIMPANI_TXFE3_ATEST_TXFE3_CMOUT_ATEST_CONN_M 0x20 -#define TIMPANI_TXFE3_ATEST_TXFE3_CMOUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE3_CMOUT_ATEST_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_ATEST_CONN_S 4 -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_ATEST_CONN_M 0x10 -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE3_OUT_ATEST_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_SHORT_TO_VICM_EN_S 3 -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_SHORT_TO_VICM_EN_M 0x8 -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_SHORT_TO_VICM_EN_DISABLE 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_SHORT_TO_VICM_EN_ENABLE 0x1 - -#define TIMPANI_TXFE3_ATEST_TXFE4_BYPASS_EN_S 2 -#define TIMPANI_TXFE3_ATEST_TXFE4_BYPASS_EN_M 0x4 -#define TIMPANI_TXFE3_ATEST_TXFE4_BYPASS_EN_DISABLE 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE4_BYPASS_EN_ENABLE 0x1 - -#define TIMPANI_TXFE3_ATEST_TXFE4_CMOUT_ATEST_CONN_S 1 -#define TIMPANI_TXFE3_ATEST_TXFE4_CMOUT_ATEST_CONN_M 0x2 -#define TIMPANI_TXFE3_ATEST_TXFE4_CMOUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE4_CMOUT_ATEST_CONN_CONNECT 0x1 - -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_ATEST_CONN_S 0 -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_ATEST_CONN_M 0x1 -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_TXFE3_ATEST_TXFE4_OUT_ATEST_CONN_CONNECT 0x1 - - -/* -- For TXFE_DIFF_SE */ -#define TIMPANI_A_TXFE_DIFF_SE (0x1B) -#define TIMPANI_TXFE_DIFF_SE_RWC "RW" -#define TIMPANI_TXFE_DIFF_SE_POR 0 -#define TIMPANI_TXFE_DIFF_SE_S 0 -#define TIMPANI_TXFE_DIFF_SE_M 0xFF - - -#define TIMPANI_TXFE_DIFF_SE_RESERVED_S 4 -#define TIMPANI_TXFE_DIFF_SE_RESERVED_M 0xF0 - -#define TIMPANI_TXFE_DIFF_SE_TXADC1_IN_MODE_S 3 -#define TIMPANI_TXFE_DIFF_SE_TXADC1_IN_MODE_M 0x8 -#define TIMPANI_TXFE_DIFF_SE_TXADC1_IN_MODE_DIFF 0x0 -#define TIMPANI_TXFE_DIFF_SE_TXADC1_IN_MODE_SINGLE_ENDED 0x1 - -#define TIMPANI_TXFE_DIFF_SE_TXADC2_IN_MODE_S 2 -#define TIMPANI_TXFE_DIFF_SE_TXADC2_IN_MODE_M 0x4 -#define TIMPANI_TXFE_DIFF_SE_TXADC2_IN_MODE_DIFF 0x0 -#define TIMPANI_TXFE_DIFF_SE_TXADC2_IN_MODE_SINGLE_ENDED 0x1 - -#define TIMPANI_TXFE_DIFF_SE_TXADC3_IN_MODE_S 1 -#define TIMPANI_TXFE_DIFF_SE_TXADC3_IN_MODE_M 0x2 -#define TIMPANI_TXFE_DIFF_SE_TXADC3_IN_MODE_DIFF 0x0 -#define TIMPANI_TXFE_DIFF_SE_TXADC3_IN_MODE_SINGLE_ENDED 0x1 - -#define TIMPANI_TXFE_DIFF_SE_TXADC4_IN_MODE_S 0 -#define TIMPANI_TXFE_DIFF_SE_TXADC4_IN_MODE_M 0x1 -#define TIMPANI_TXFE_DIFF_SE_TXADC4_IN_MODE_DIFF 0x0 -#define TIMPANI_TXFE_DIFF_SE_TXADC4_IN_MODE_SINGLE_ENDED 0x1 - - -/* -- For CDAC_RX_CLK_CTL */ -#define TIMPANI_A_CDAC_RX_CLK_CTL (0x20) -#define TIMPANI_CDAC_RX_CLK_CTL_RWC "RW" -#define TIMPANI_CDAC_RX_CLK_CTL_POR 0x98 -#define TIMPANI_CDAC_RX_CLK_CTL_S 0 -#define TIMPANI_CDAC_RX_CLK_CTL_M 0xFF - - -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_EN_S 7 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_EN_M 0x80 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_EN_DISABLE 0x0 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_EN_ENABLE_NORMAL_OP 0x1 - -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_CTRL_EN_S 6 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_CTRL_EN_M 0x40 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_CTRL_EN_DISABLE_NORMAL_OP 0x0 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_CTRL_EN_ENABLE 0x1 - -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_S 2 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_M 0x3C -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_6NS 0x0 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_8_4NS 0x1 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_10_8NS 0x2 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_13_2NS 0x3 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_15_6NS 0x4 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_18NS 0x5 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_20_4NS_NORMAL_OP 0x6 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_22_8NS 0x7 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_25_2NS 0x8 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_27_6NS 0x9 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_30NS 0xA -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_32_4NS 0xB -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_34_8NS 0xC -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_37_2NS 0xD -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_39_6NS 0xE -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_EXTERNAL_DELAY_V_42NS 0xF - -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_FF_RESET_S 1 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_FF_RESET_M 0x2 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_FF_RESET_ENABLE 0x1 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_FF_RESET_DISABLE 0x0 - -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_ATEST_CONN_S 0 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_ATEST_CONN_M 0x1 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_ATEST_CONN_NO_CONNECT 0x0 -#define TIMPANI_CDAC_RX_CLK_CTL_CDAC_RESET_PULSE_GEN_ATEST_CONN_CONNECT 0x1 - - -/* -- For CDAC_BUFF_CTL */ -#define TIMPANI_A_CDAC_BUFF_CTL (0x21) -#define TIMPANI_CDAC_BUFF_CTL_RWC "RW" -#define TIMPANI_CDAC_BUFF_CTL_POR 0x60 -#define TIMPANI_CDAC_BUFF_CTL_S 0 -#define TIMPANI_CDAC_BUFF_CTL_M 0xFF - - -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_S 5 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_M 0xE0 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_40UA 0x0 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_60UA_NORMAL_OP 0x1 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_80UA 0x2 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_100UA 0x3 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_120UA 0x4 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_140UA 0x5 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_160UA 0x6 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_DM_BUFF_CUR_V_180UA 0x7 - -#define TIMPANI_CDAC_BUFF_CTL_CDAC_CM_BUFF_CUR_S 3 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_CM_BUFF_CUR_M 0x18 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_CM_BUFF_CUR_V_20UA 0x0 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_CM_BUFF_CUR_V_30UA_NORMAL_OP 0x1 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_CM_BUFF_CUR_V_40UA 0x2 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_CM_BUFF_CUR_V_50UA 0x3 - -#define TIMPANI_CDAC_BUFF_CTL_CDAC_REF_BUFF_OTA_BIAS_CUR_S 1 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_REF_BUFF_OTA_BIAS_CUR_M 0x6 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_REF_BUFF_OTA_BIAS_CUR_V_5UA_5UA 0x0 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_REF_BUFF_OTA_BIAS_CUR_V_5UA_10UA 0x1 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_REF_BUFF_OTA_BIAS_CUR_V_10UA_5UA 0x2 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_REF_BUFF_OTA_BIAS_CUR_V_10UA_10UA 0x3 - -#define TIMPANI_CDAC_BUFF_CTL_CDAC_VCOM_SOURCE_S 0 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_VCOM_SOURCE_M 0x1 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_VCOM_SOURCE_CURRENT_TO_VCOM_NORMAL_OP 0x0 -#define TIMPANI_CDAC_BUFF_CTL_CDAC_VCOM_SOURCE_MASTER_BIAS_TO_VCOM 0x1 - - -/* -- For CDAC_REF_CTL1 */ -#define TIMPANI_A_CDAC_REF_CTL1 (0x22) -#define TIMPANI_CDAC_REF_CTL1_RWC "RW" -#define TIMPANI_CDAC_REF_CTL1_POR 0xe1 -#define TIMPANI_CDAC_REF_CTL1_S 0 -#define TIMPANI_CDAC_REF_CTL1_M 0xFF - - -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_S 5 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_M 0xE0 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_1_8V 0x0 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_1_825V 0x1 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_1_85V 0x2 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_1_9V 0x3 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_1_925V 0x4 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_1_95V_NORMAL_OP 0x5 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_1_975 0x6 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACH_VOLT_V_2_0V 0x7 - -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_S 2 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_M 0x1C -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_1V 0x0 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_125V 0x1 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_15V_NORMAL_OP 0x2 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_175V 0x3 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_2V 0x4 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_25V 0x5 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_275V 0x6 -#define TIMPANI_CDAC_REF_CTL1_CDAC_DACL_VOLT_V_0_3V 0x7 - -#define TIMPANI_CDAC_REF_CTL1_CDAC_CM_VOLT_S 0 -#define TIMPANI_CDAC_REF_CTL1_CDAC_CM_VOLT_M 0x3 -#define TIMPANI_CDAC_REF_CTL1_CDAC_CM_VOLT_V_1_025V 0x0 -#define TIMPANI_CDAC_REF_CTL1_CDAC_CM_VOLT_V_1_05V_NORMAL_OP 0x1 -#define TIMPANI_CDAC_REF_CTL1_CDAC_CM_VOLT_V_1_075V 0x2 -#define TIMPANI_CDAC_REF_CTL1_CDAC_CM_VOLT_V_1_1V 0x3 - - -/* -- For IDAC_DWA_FIR_CTL */ -#define TIMPANI_A_IDAC_DWA_FIR_CTL (0x23) -#define TIMPANI_IDAC_DWA_FIR_CTL_RWC "RW" -#define TIMPANI_IDAC_DWA_FIR_CTL_POR 0x28 -#define TIMPANI_IDAC_DWA_FIR_CTL_S 0 -#define TIMPANI_IDAC_DWA_FIR_CTL_M 0xFF - - -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_CLK_NON_OL_TIME_S 7 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_CLK_NON_OL_TIME_M 0x80 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_CLK_NON_OL_TIME_NORMAL_OP 0x0 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_CLK_NON_OL_TIME_V_150PSEC_REDUCTION 0x1 - -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_FIR_S 4 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_FIR_M 0x70 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_FIR_FIR0 0x0 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_FIR_FIR1 0x1 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_FIR_FIR2 0x2 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_FIR_FIR3 0x3 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_FIR_FIR4 0x4 - -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_EN_SOURCE_S 3 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_EN_SOURCE_M 0x8 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_EN_SOURCE_INTERNAL_NORMAL_OP 0x1 -#define TIMPANI_IDAC_DWA_FIR_CTL_IDAC_EN_SOURCE_EXTERNAL 0x0 - -#define TIMPANI_IDAC_DWA_FIR_CTL_RESERVED_S 0 -#define TIMPANI_IDAC_DWA_FIR_CTL_RESERVED_M 0x7 - - -/* -- For CDAC_REF_CTL2 */ -#define TIMPANI_A_CDAC_REF_CTL2 (0x24) -#define TIMPANI_CDAC_REF_CTL2_RWC "RW" -#define TIMPANI_CDAC_REF_CTL2_POR 0xc -#define TIMPANI_CDAC_REF_CTL2_S 0 -#define TIMPANI_CDAC_REF_CTL2_M 0xFF - - -#define TIMPANI_CDAC_REF_CTL2_RESERVED_1_S 7 -#define TIMPANI_CDAC_REF_CTL2_RESERVED_1_M 0x80 - -#define TIMPANI_CDAC_REF_CTL2_CDAC_L_EN_S 6 -#define TIMPANI_CDAC_REF_CTL2_CDAC_L_EN_M 0x40 -#define TIMPANI_CDAC_REF_CTL2_CDAC_L_EN_DISABLE 0x0 -#define TIMPANI_CDAC_REF_CTL2_CDAC_L_EN_ENABLE 0x1 - -#define TIMPANI_CDAC_REF_CTL2_CDAC_R_EN_S 5 -#define TIMPANI_CDAC_REF_CTL2_CDAC_R_EN_M 0x20 -#define TIMPANI_CDAC_REF_CTL2_CDAC_R_EN_DISABLE 0x0 -#define TIMPANI_CDAC_REF_CTL2_CDAC_R_EN_ENABLE 0x1 - -#define TIMPANI_CDAC_REF_CTL2_RESERVED_2_S 4 -#define TIMPANI_CDAC_REF_CTL2_RESERVED_2_M 0x10 - -#define TIMPANI_CDAC_REF_CTL2_CDAC_DWA_RX_FILTER_TIMING_S 2 -#define TIMPANI_CDAC_REF_CTL2_CDAC_DWA_RX_FILTER_TIMING_M 0xC -#define TIMPANI_CDAC_REF_CTL2_CDAC_DWA_RX_FILTER_TIMING_CLK_SYNC_CK11DBAR 0x1 -#define TIMPANI_CDAC_REF_CTL2_CDAC_DWA_RX_FILTER_TIMING_CLK_SYNC_CK21 0x3 - -#define TIMPANI_CDAC_REF_CTL2_CDAC_OSR_S 0 -#define TIMPANI_CDAC_REF_CTL2_CDAC_OSR_M 0x3 -#define TIMPANI_CDAC_REF_CTL2_CDAC_OSR_V_256 0x0 -#define TIMPANI_CDAC_REF_CTL2_CDAC_OSR_V_128 0x1 -#define TIMPANI_CDAC_REF_CTL2_CDAC_OSR_V_64 0x3 - - -/* -- For CDAC_CTL1 */ -#define TIMPANI_A_CDAC_CTL1 (0x25) -#define TIMPANI_CDAC_CTL1_RWC "RW" -#define TIMPANI_CDAC_CTL1_POR 0xb -#define TIMPANI_CDAC_CTL1_S 0 -#define TIMPANI_CDAC_CTL1_M 0xFF - - -#define TIMPANI_CDAC_CTL1_RESERVED_S 6 -#define TIMPANI_CDAC_CTL1_RESERVED_M 0xC0 - -#define TIMPANI_CDAC_CTL1_CDAC_L_OUT_SHORT_EN_S 5 -#define TIMPANI_CDAC_CTL1_CDAC_L_OUT_SHORT_EN_M 0x20 -#define TIMPANI_CDAC_CTL1_CDAC_L_OUT_SHORT_EN_DISABLE 0x0 -#define TIMPANI_CDAC_CTL1_CDAC_L_OUT_SHORT_EN_ENABLE 0x1 - -#define TIMPANI_CDAC_CTL1_CDAC_R_OUT_SHORT_EN_S 4 -#define TIMPANI_CDAC_CTL1_CDAC_R_OUT_SHORT_EN_M 0x10 -#define TIMPANI_CDAC_CTL1_CDAC_R_OUT_SHORT_EN_DISABLE 0x0 -#define TIMPANI_CDAC_CTL1_CDAC_R_OUT_SHORT_EN_ENABLE 0x1 - -#define TIMPANI_CDAC_CTL1_CDAC_REF_RESISTOR_VOLT_S 2 -#define TIMPANI_CDAC_CTL1_CDAC_REF_RESISTOR_VOLT_M 0xC -#define TIMPANI_CDAC_CTL1_CDAC_REF_RESISTOR_VOLT_V_1_0V 0x0 -#define TIMPANI_CDAC_CTL1_CDAC_REF_RESISTOR_VOLT_V_1_025V 0x1 -#define TIMPANI_CDAC_CTL1_CDAC_REF_RESISTOR_VOLT_V_1_05V_NORMAL_OP 0x2 -#define TIMPANI_CDAC_CTL1_CDAC_REF_RESISTOR_VOLT_V_1_0752V 0x3 - -#define TIMPANI_CDAC_CTL1_CDAC_SAMP_CAP_RESET_EN_S 1 -#define TIMPANI_CDAC_CTL1_CDAC_SAMP_CAP_RESET_EN_M 0x2 -#define TIMPANI_CDAC_CTL1_CDAC_SAMP_CAP_RESET_EN_DISABLE 0x0 -#define TIMPANI_CDAC_CTL1_CDAC_SAMP_CAP_RESET_EN_ENABLE_NORMAL_OP 0x1 - -#define TIMPANI_CDAC_CTL1_CDAC_RESET_SOURCE_S 0 -#define TIMPANI_CDAC_CTL1_CDAC_RESET_SOURCE_M 0x1 -#define TIMPANI_CDAC_CTL1_CDAC_RESET_SOURCE_INTERNAL_NORMAL_OP 0x1 -#define TIMPANI_CDAC_CTL1_CDAC_RESET_SOURCE_EXTERNAL_REGISTER_RESET 0x0 - - -/* -- For CDAC_CTL2 */ -#define TIMPANI_A_CDAC_CTL2 (0x26) -#define TIMPANI_CDAC_CTL2_RWC "RW" -#define TIMPANI_CDAC_CTL2_POR 0xd0 -#define TIMPANI_CDAC_CTL2_S 0 -#define TIMPANI_CDAC_CTL2_M 0xFF - - -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_S 5 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_M 0xE0 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_10UA 0x0 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_8_75UA 0x1 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_7_5UA 0x2 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_6_25UA 0x3 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_5UA 0x4 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_3_75UA 0x5 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_2_5UA_NORMAL_OP 0x6 -#define TIMPANI_CDAC_CTL2_CDAC_OTA_BIAS_V_1_25UA 0x7 - -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_S 2 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_M 0x1C -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_10UA 0x0 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_8_75UA 0x1 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_7_5UA 0x2 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_6_25UA 0x3 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_5UA_NORMAL_OP 0x4 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_3_75UA 0x5 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_2_5UA 0x6 -#define TIMPANI_CDAC_CTL2_CDAC_REF_BUFF_OTA_BIAS_V_1_25UA 0x7 - -#define TIMPANI_CDAC_CTL2_CDAC_RESET_PULSE_GEN_UPDATE_RATE_S 0 -#define TIMPANI_CDAC_CTL2_CDAC_RESET_PULSE_GEN_UPDATE_RATE_M 0x3 -#define TIMPANI_CDAC_CTL2_CDAC_RESET_PULSE_GEN_UPDATE_RATE_FS 0x0 -#define TIMPANI_CDAC_CTL2_CDAC_RESET_PULSE_GEN_UPDATE_RATE_FS_BY_8 0x1 -#define TIMPANI_CDAC_CTL2_CDAC_RESET_PULSE_GEN_UPDATE_RATE_FS_BY_16 0x2 - - -/* -- For IDAC_L_CTL */ -#define TIMPANI_A_IDAC_L_CTL (0x28) -#define TIMPANI_IDAC_L_CTL_RWC "RW" -#define TIMPANI_IDAC_L_CTL_POR 0xe -#define TIMPANI_IDAC_L_CTL_S 0 -#define TIMPANI_IDAC_L_CTL_M 0xFF - - -#define TIMPANI_IDAC_L_CTL_IDAC_L_EN_S 7 -#define TIMPANI_IDAC_L_CTL_IDAC_L_EN_M 0x80 -#define TIMPANI_IDAC_L_CTL_IDAC_L_EN_DISABLE 0x0 -#define TIMPANI_IDAC_L_CTL_IDAC_L_EN_ENABLE 0x1 - -#define TIMPANI_IDAC_L_CTL_IDAC_L_REF_SEL_S 5 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REF_SEL_M 0x60 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REF_SEL_GROUND 0x0 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REF_SEL_IBIAS_X_R_REF 0x1 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REF_SEL_BG_VOLTAGE_NORMAL_OP 0x2 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REF_SEL_VDD_BY_2 0x3 - -#define TIMPANI_IDAC_L_CTL_IDAC_L_GAIN_S 3 -#define TIMPANI_IDAC_L_CTL_IDAC_L_GAIN_M 0x18 -#define TIMPANI_IDAC_L_CTL_IDAC_L_GAIN_NEG_1_5DB 0x0 -#define TIMPANI_IDAC_L_CTL_IDAC_L_GAIN_V_0_0DB_NORMAL_OP 0x1 -#define TIMPANI_IDAC_L_CTL_IDAC_L_GAIN_POS_1_5DB 0x2 -#define TIMPANI_IDAC_L_CTL_IDAC_L_GAIN_POS_3_0DB 0x3 - -#define TIMPANI_IDAC_L_CTL_IDAC_L_LOW_RESISTANCE_S 2 -#define TIMPANI_IDAC_L_CTL_IDAC_L_LOW_RESISTANCE_M 0x4 -#define TIMPANI_IDAC_L_CTL_IDAC_L_LOW_RESISTANCE_V_30K 0x0 -#define TIMPANI_IDAC_L_CTL_IDAC_L_LOW_RESISTANCE_V_10K_NORMAL_OP 0x1 - -#define TIMPANI_IDAC_L_CTL_IDAC_L_SYNC_EN_S 1 -#define TIMPANI_IDAC_L_CTL_IDAC_L_SYNC_EN_M 0x2 -#define TIMPANI_IDAC_L_CTL_IDAC_L_SYNC_EN_ASYNCHRONOUSLY 0x0 -#define TIMPANI_IDAC_L_CTL_IDAC_L_SYNC_EN_ENABLE_NORMAL_OP 0x1 - -#define TIMPANI_IDAC_L_CTL_IDAC_L_REPLICA_BIAS_S 0 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REPLICA_BIAS_M 0x1 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REPLICA_BIAS_REPLICA_BIAS_NORMAL_OP 0x0 -#define TIMPANI_IDAC_L_CTL_IDAC_L_REPLICA_BIAS_SERVO_LOOP_BIAS 0x1 - - -/* -- For IDAC_R_CTL */ -#define TIMPANI_A_IDAC_R_CTL (0x29) -#define TIMPANI_IDAC_R_CTL_RWC "RW" -#define TIMPANI_IDAC_R_CTL_POR 0xe -#define TIMPANI_IDAC_R_CTL_S 0 -#define TIMPANI_IDAC_R_CTL_M 0xFF - - -#define TIMPANI_IDAC_R_CTL_IDAC_R_EN_S 7 -#define TIMPANI_IDAC_R_CTL_IDAC_R_EN_M 0x80 -#define TIMPANI_IDAC_R_CTL_IDAC_R_EN_DISABLED 0x0 -#define TIMPANI_IDAC_R_CTL_IDAC_R_EN_ENABLED 0x1 - -#define TIMPANI_IDAC_R_CTL_IDAC_R_REF_SEL_S 5 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REF_SEL_M 0x60 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REF_SEL_GROUND 0x0 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REF_SEL_IBIAS_X_R_REF 0x1 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REF_SEL_BG_VOLTAGE_NORMAL_OP 0x2 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REF_SEL_VDD_BY_2 0x3 - -#define TIMPANI_IDAC_R_CTL_IDAC_R_GAIN_S 3 -#define TIMPANI_IDAC_R_CTL_IDAC_R_GAIN_M 0x18 -#define TIMPANI_IDAC_R_CTL_IDAC_R_GAIN_NEG_1_5DB 0x0 -#define TIMPANI_IDAC_R_CTL_IDAC_R_GAIN_V_0_0DB_NORMAL_OP 0x1 -#define TIMPANI_IDAC_R_CTL_IDAC_R_GAIN_POS_1_5DB 0x2 -#define TIMPANI_IDAC_R_CTL_IDAC_R_GAIN_POS_3_0DB 0x3 - -#define TIMPANI_IDAC_R_CTL_IDAC_R_LOW_RESISTANCE_S 2 -#define TIMPANI_IDAC_R_CTL_IDAC_R_LOW_RESISTANCE_M 0x4 -#define TIMPANI_IDAC_R_CTL_IDAC_R_LOW_RESISTANCE_V_30K 0x0 -#define TIMPANI_IDAC_R_CTL_IDAC_R_LOW_RESISTANCE_V_10K_NORMAL_OP 0x1 - -#define TIMPANI_IDAC_R_CTL_IDAC_R_SYNC_EN_S 1 -#define TIMPANI_IDAC_R_CTL_IDAC_R_SYNC_EN_M 0x2 -#define TIMPANI_IDAC_R_CTL_IDAC_R_SYNC_EN_ASYNCHRONOUSLY 0x0 -#define TIMPANI_IDAC_R_CTL_IDAC_R_SYNC_EN_ENABLE_NORMAL_OP 0x1 - -#define TIMPANI_IDAC_R_CTL_IDAC_R_REPLICA_BIAS_S 0 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REPLICA_BIAS_M 0x1 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REPLICA_BIAS_REPLICA_BIAS_NORMAL_OP 0x0 -#define TIMPANI_IDAC_R_CTL_IDAC_R_REPLICA_BIAS_SERVO_LOOP_BIAS 0x1 - - -/* -- For PA_MASTER_BIAS */ -#define TIMPANI_A_PA_MASTER_BIAS (0x2D) -#define TIMPANI_PA_MASTER_BIAS_RWC "RW" -#define TIMPANI_PA_MASTER_BIAS_POR 0x6f -#define TIMPANI_PA_MASTER_BIAS_S 0 -#define TIMPANI_PA_MASTER_BIAS_M 0xFF - - -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_S 5 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_M 0xE0 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_17_5UA 0x0 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_15_0UA 0x1 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_12_5UA 0x2 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_10_0UA 0x3 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_7_5UA 0x4 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_5_0UA 0x5 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_2_5UA 0x6 -#define TIMPANI_PA_MASTER_BIAS_LINE_MASTER_BIAS_CUR_V_0_0UA 0x7 - -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_S 2 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_M 0x1C -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_17_5UA 0x0 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_15_0UA 0x1 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_12_5UA 0x2 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_10_0UA 0x3 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_7_5UA 0x4 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_5_0UA 0x5 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_2_5UA 0x6 -#define TIMPANI_PA_MASTER_BIAS_HPH_MASTER_BIAS_CUR_V_0_0UA 0x7 - -#define TIMPANI_PA_MASTER_BIAS_CLASSD_REF_BUF_MASTER_BIAS_CUR_S 0 -#define TIMPANI_PA_MASTER_BIAS_CLASSD_REF_BUF_MASTER_BIAS_CUR_M 0x3 -#define TIMPANI_PA_MASTER_BIAS_CLASSD_REF_BUF_MASTER_BIAS_CUR_V_6_25UA 0x0 -#define TIMPANI_PA_MASTER_BIAS_CLASSD_REF_BUF_MASTER_BIAS_CUR_V_5_0UA 0x1 -#define TIMPANI_PA_MASTER_BIAS_CLASSD_REF_BUF_MASTER_BIAS_CUR_V_3_75UA 0x2 -#define TIMPANI_PA_MASTER_BIAS_CLASSD_REF_BUF_MASTER_BIAS_CUR_V_2_5UA 0x3 - - -/* -- For PA_CLASSD_BIAS */ -#define TIMPANI_A_PA_CLASSD_BIAS (0x2E) -#define TIMPANI_PA_CLASSD_BIAS_RWC "RW" -#define TIMPANI_PA_CLASSD_BIAS_POR 0x55 -#define TIMPANI_PA_CLASSD_BIAS_S 0 -#define TIMPANI_PA_CLASSD_BIAS_M 0xFF - - -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_COMP_BIAS_CUR_S 6 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_COMP_BIAS_CUR_M 0xC0 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_COMP_BIAS_CUR_V_6_25UA 0x0 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_COMP_BIAS_CUR_V_5_0UA 0x1 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_COMP_BIAS_CUR_V_3_75UA 0x2 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_COMP_BIAS_CUR_V_2_5UA 0x3 - -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA1_BIAS_CUR_S 4 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA1_BIAS_CUR_M 0x30 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA1_BIAS_CUR_V_6_25UA 0x0 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA1_BIAS_CUR_V_5_0U 0x1 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA1_BIAS_CUR_V_3_75UA 0x2 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA1_BIAS_CUR_V_2_5UA 0x3 - -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA2_BIAS_CUR_S 2 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA2_BIAS_CUR_M 0xC -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA2_BIAS_CUR_V_6_25UA 0x0 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA2_BIAS_CUR_V_5_0UA 0x1 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA2_BIAS_CUR_V_3_75UA 0x2 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OTA2_BIAS_CUR_V_2_5UA 0x3 - -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OCP_BIAS_CUR_S 0 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OCP_BIAS_CUR_M 0x3 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OCP_BIAS_CUR_V_6_25UA 0x0 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OCP_BIAS_CUR_V_5_0UA 0x1 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OCP_BIAS_CUR_V_3_75UA 0x2 -#define TIMPANI_PA_CLASSD_BIAS_CLASSD_OCP_BIAS_CUR_V_2_5UA 0x3 - - -/* -- For AUXPGA_CUR */ -#define TIMPANI_A_AUXPGA_CUR (0x2F) -#define TIMPANI_AUXPGA_CUR_RWC "RW" -#define TIMPANI_AUXPGA_CUR_POR 0x44 -#define TIMPANI_AUXPGA_CUR_S 0 -#define TIMPANI_AUXPGA_CUR_M 0xFF - - -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_S 4 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_M 0xF0 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_0UA 0x0 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_0_3125UA 0x1 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_0_625UA 0x2 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_0_9375UA 0x3 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_1_25UA 0x4 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_1_5625UA 0x5 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_1_875UA 0x6 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_2_1875UA 0x7 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_2_5UA 0x8 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_2_8125UA 0x9 -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_3_125UA 0xA -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_3_4375UA 0xB -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_3_75UA 0xC -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_4_0625UA 0xD -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_4_375UA 0xE -#define TIMPANI_AUXPGA_CUR_AUXPGA_PMOSAB_CUR_V_4_6875UA 0xF - -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_S 0 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_M 0xF -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_0UA 0x0 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_0_3125UA 0x1 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_0_625UA 0x2 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_0_9375UA 0x3 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_1_25UA 0x4 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_1_5625UA 0x5 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_1_875UA 0x6 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_2_1875UA 0x7 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_2_5UA 0x8 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_2_8125UA 0x9 -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_3_125UA 0xA -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_3_4375UA 0xB -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_3_75UA 0xC -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_4_0625UA 0xD -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_4_375UA 0xE -#define TIMPANI_AUXPGA_CUR_AUXPGA_NMOSAB_CUR_V_4_6875UA 0xF - - -/* -- For AUXPGA_CM */ -#define TIMPANI_A_AUXPGA_CM (0x30) -#define TIMPANI_AUXPGA_CM_RWC "RW" -#define TIMPANI_AUXPGA_CM_POR 0x92 -#define TIMPANI_AUXPGA_CM_S 0 -#define TIMPANI_AUXPGA_CM_M 0xFF - - -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_S 5 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_M 0xE0 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_7_5UA 0x0 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_7_925UA 0x1 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_8_75UA 0x2 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_9_375UA 0x3 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_10UA 0x4 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_10_625UA 0x5 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_11_25UA 0x6 -#define TIMPANI_AUXPGA_CM_AUXPGA_R_CM_DIFF_PAIR_TAIL_CUR_V_11_875UA 0x7 - -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_S 2 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_M 0x1C -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_7_5UA 0x0 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_7_925UA 0x1 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_8_75UA 0x2 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_9_375UA 0x3 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_10UA 0x4 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_10_625UA 0x5 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_11_25UA 0x6 -#define TIMPANI_AUXPGA_CM_AUXPGA_L_CM_DIFF_PAIR_TAIL_CUR_V_11_875UA 0x7 - -#define TIMPANI_AUXPGA_CM_AUXPGA_R2R_CM_S 1 -#define TIMPANI_AUXPGA_CM_AUXPGA_R2R_CM_M 0x2 -#define TIMPANI_AUXPGA_CM_AUXPGA_R2R_CM_VCMI_TO_R2R_CM 0x1 -#define TIMPANI_AUXPGA_CM_AUXPGA_R2R_CM_R2R_CM_FLOATING 0x0 - -#define TIMPANI_AUXPGA_CM_AUXPGA_VCM_REF_GEN_S 0 -#define TIMPANI_AUXPGA_CM_AUXPGA_VCM_REF_GEN_M 0x1 -#define TIMPANI_AUXPGA_CM_AUXPGA_VCM_REF_GEN_GEN_VCM_LOCALLY 0x1 -#define TIMPANI_AUXPGA_CM_AUXPGA_VCM_REF_GEN_BG_VCM 0x0 - - -/* -- For PA_HPH_EARPA_MSTB_EN */ -#define TIMPANI_A_PA_HPH_EARPA_MSTB_EN (0x31) -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_RWC "RW" -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_POR 0x4 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_S 0 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_M 0xFF - - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_EN_S 7 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_EN_M 0x80 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_BIAS_EN_S 6 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_BIAS_EN_M 0x40 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_BIAS_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_L_BIAS_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_EN_S 5 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_EN_M 0x20 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_BIAS_EN_S 4 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_BIAS_EN_M 0x10 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_BIAS_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_R_BIAS_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_VCM_BUFFER_EN_S 3 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_VCM_BUFFER_EN_M 0x8 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_VCM_BUFFER_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_VCM_BUFFER_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_CAPLESS_MODE_S 2 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_CAPLESS_MODE_M 0x4 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_CAPLESS_MODE_CAPLESS 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_HPH_CAPLESS_MODE_LEGACY 0x0 - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_EARPA_EN_S 1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_EARPA_EN_M 0x2 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_EARPA_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_EARPA_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_PA_MASTER_BIAS_EN_S 0 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_PA_MASTER_BIAS_EN_M 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_PA_MASTER_BIAS_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_EARPA_MSTB_EN_PA_MASTER_BIAS_EN_DISABLE 0x0 - - -/* -- For PA_LINE_AUXO_EN */ -#define TIMPANI_A_PA_LINE_AUXO_EN (0x32) -#define TIMPANI_PA_LINE_AUXO_EN_RWC "RW" -#define TIMPANI_PA_LINE_AUXO_EN_POR 0 -#define TIMPANI_PA_LINE_AUXO_EN_S 0 -#define TIMPANI_PA_LINE_AUXO_EN_M 0xFF - - -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_EN_S 7 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_EN_M 0x80 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_EN_DISABLE 0x0 - -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_BIAS_EN_S 6 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_BIAS_EN_M 0x40 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_BIAS_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_L_BIAS_EN_DISABLE 0x0 - -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_EN_S 5 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_EN_M 0x20 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_EN_DISABLE 0x0 - -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_BIAS_EN_S 4 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_BIAS_EN_M 0x10 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_BIAS_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_R_BIAS_EN_DISABLE 0x0 - -#define TIMPANI_PA_LINE_AUXO_EN_LINE_VCM_BUFFER_EN_S 3 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_VCM_BUFFER_EN_M 0x8 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_VCM_BUFFER_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_LINE_VCM_BUFFER_EN_DISABLE 0x0 - -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_EN_S 2 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_EN_M 0x4 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_EN_DISABLE 0x0 - -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_BIAS_EN_S 1 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_BIAS_EN_M 0x2 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_BIAS_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_BIAS_EN_DISABLE 0x0 - -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_VCM_BUFFER_EN_S 0 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_VCM_BUFFER_EN_M 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_VCM_BUFFER_EN_ENABLE 0x1 -#define TIMPANI_PA_LINE_AUXO_EN_AUXOUT_VCM_BUFFER_EN_DISABLE 0x0 - - -/* -- For PA_CLASSD_AUXPGA_EN */ -#define TIMPANI_A_PA_CLASSD_AUXPGA_EN (0x33) -#define TIMPANI_PA_CLASSD_AUXPGA_EN_RWC "RW" -#define TIMPANI_PA_CLASSD_AUXPGA_EN_POR 0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_S 0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_M 0xFF - - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_MUTE_S 7 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_MUTE_M 0x80 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_MUTE_MUTE 0x1 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_MUTE_UNMUTE 0x0 - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_MUTE_S 6 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_MUTE_M 0x40 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_MUTE_MUTE 0x1 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_MUTE_UNMUTE 0x0 - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_EN_S 5 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_EN_M 0x20 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_L_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_EN_S 4 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_EN_M 0x10 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_AUXPGA_R_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_REF_EN_S 3 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_REF_EN_M 0x8 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_REF_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_REF_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_EN_S 2 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_EN_M 0x4 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_L_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_REF_EN_S 1 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_REF_EN_M 0x2 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_REF_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_REF_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_EN_S 0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_EN_M 0x1 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_AUXPGA_EN_CLASSD_R_EN_ENABLE 0x1 - - -/* -- For PA_LINE_L_GAIN */ -#define TIMPANI_A_PA_LINE_L_GAIN (0x34) -#define TIMPANI_PA_LINE_L_GAIN_RWC "RW" -#define TIMPANI_PA_LINE_L_GAIN_POR 0xac -#define TIMPANI_PA_LINE_L_GAIN_S 0 -#define TIMPANI_PA_LINE_L_GAIN_M 0xFF - - -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_S 2 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_M 0xFC -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_POS_1_5 0x0 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_POS_0_0 0x1 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_1_5 0x2 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_3_0 0x3 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_4_5 0x4 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_6_0 0x5 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_7_5 0x6 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_9_0 0x7 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_10_5 0x8 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_12_0 0x9 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_13_5 0xA -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_15_0 0xB -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_16_5 0xC -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_18_0 0xD -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_19_5 0xE -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_21_0 0xF -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_22_5 0x10 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_24_0 0x11 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_25_5 0x12 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_27_0 0x13 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_28_5 0x14 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_30_0 0x15 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_31_5 0x16 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_33_0 0x17 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_34_5 0x18 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_36_0 0x19 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_37_5 0x1A -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_39_0 0x1B -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_40_5 0x1C -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_42_0 0x1D -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_43_5 0x1E -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_45_0 0x1F -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_46_5 0x20 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_48_0 0x21 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_49_5 0x22 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_51_0 0x23 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_52_5 0x24 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_54_0 0x25 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_55_5 0x26 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_57_0 0x27 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_58_5 0x28 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_60_0 0x29 -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_61_5 0x2A -#define TIMPANI_PA_LINE_L_GAIN_LINE_L_GAIN_NEG_63_0 0x2B - -#define TIMPANI_PA_LINE_L_GAIN_RESERVED_S 0 -#define TIMPANI_PA_LINE_L_GAIN_RESERVED_M 0x3 - - -/* -- For PA_LINE_R_GAIN */ -#define TIMPANI_A_PA_LINE_R_GAIN (0x35) -#define TIMPANI_PA_LINE_R_GAIN_RWC "RW" -#define TIMPANI_PA_LINE_R_GAIN_POR 0xac -#define TIMPANI_PA_LINE_R_GAIN_S 0 -#define TIMPANI_PA_LINE_R_GAIN_M 0xFF - - -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_S 2 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_M 0xFC -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_POS_1_5 0x0 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_POS_0_0 0x1 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_1_5 0x2 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_3_0 0x3 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_4_5 0x4 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_6_0 0x5 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_7_5 0x6 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_9_0 0x7 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_10_5 0x8 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_12_0 0x9 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_13_5 0xA -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_15_0 0xB -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_16_5 0xC -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_18_0 0xD -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_19_5 0xE -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_21_0 0xF -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_22_5 0x10 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_24_0 0x11 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_25_5 0x12 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_27_0 0x13 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_28_5 0x14 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_30_0 0x15 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_31_5 0x16 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_33_0 0x17 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_34_5 0x18 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_36_0 0x19 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_37_5 0x1A -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_39_0 0x1B -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_40_5 0x1C -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_42_0 0x1D -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_43_5 0x1E -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_45_0 0x1F -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_46_5 0x20 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_48_0 0x21 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_49_5 0x22 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_51_0 0x23 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_52_5 0x24 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_54_0 0x25 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_55_5 0x26 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_57_0 0x27 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_58_5 0x28 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_60_0 0x29 -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_61_5 0x2A -#define TIMPANI_PA_LINE_R_GAIN_LINE_R_GAIN_NEG_63_0 0x2B - -#define TIMPANI_PA_LINE_R_GAIN_RESERVED_S 0 -#define TIMPANI_PA_LINE_R_GAIN_RESERVED_M 0x3 - - -/* -- For PA_HPH_L_GAIN */ -#define TIMPANI_A_PA_HPH_L_GAIN (0x36) -#define TIMPANI_PA_HPH_L_GAIN_RWC "RW" -#define TIMPANI_PA_HPH_L_GAIN_POR 0xae -#define TIMPANI_PA_HPH_L_GAIN_S 0 -#define TIMPANI_PA_HPH_L_GAIN_M 0xFF - - -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_S 2 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_M 0xFC -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_POS_1_5 0x0 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_POS_0_0 0x1 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_1_5 0x2 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_3_0 0x3 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_4_5 0x4 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_6_0 0x5 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_7_5 0x6 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_9_0 0x7 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_10_5 0x8 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_12_0 0x9 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_13_5 0xA -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_15_0 0xB -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_16_5 0xC -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_18_0 0xD -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_19_5 0xE -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_21_0 0xF -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_22_5 0x10 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_24_0 0x11 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_25_5 0x12 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_27_0 0x13 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_28_5 0x14 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_30_0 0x15 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_31_5 0x16 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_33_0 0x17 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_34_5 0x18 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_36_0 0x19 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_37_5 0x1A -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_39_0 0x1B -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_40_5 0x1C -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_42_0 0x1D -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_43_5 0x1E -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_45_0 0x1F -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_46_5 0x20 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_48_0 0x21 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_49_5 0x22 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_51_0 0x23 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_52_5 0x24 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_54_0 0x25 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_55_5 0x26 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_57_0 0x27 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_58_5 0x28 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_60_0 0x29 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_61_5 0x2A -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_GAIN_NEG_63_0 0x2B - -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_MUTE_S 1 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_MUTE_M 0x2 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_MUTE_MUTE 0x1 -#define TIMPANI_PA_HPH_L_GAIN_HPH_L_MUTE_UNMUTE 0x0 - -#define TIMPANI_PA_HPH_L_GAIN_RESERVED_S 0 -#define TIMPANI_PA_HPH_L_GAIN_RESERVED_M 0x1 - - -/* -- For PA_HPH_R_GAIN */ -#define TIMPANI_A_PA_HPH_R_GAIN (0x37) -#define TIMPANI_PA_HPH_R_GAIN_RWC "RW" -#define TIMPANI_PA_HPH_R_GAIN_POR 0xae -#define TIMPANI_PA_HPH_R_GAIN_S 0 -#define TIMPANI_PA_HPH_R_GAIN_M 0xFF - - -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_S 2 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_M 0xFC -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_POS_1_5 0x0 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_POS_0_0 0x1 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_1_5 0x2 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_3_0 0x3 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_4_5 0x4 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_6_0 0x5 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_7_5 0x6 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_9_0 0x7 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_10_5 0x8 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_12_0 0x9 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_13_5 0xA -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_15_0 0xB -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_16_5 0xC -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_18_0 0xD -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_19_5 0xE -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_21_0 0xF -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_22_5 0x10 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_24_0 0x11 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_25_5 0x12 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_27_0 0x13 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_28_5 0x14 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_30_0 0x15 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_31_5 0x16 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_33_0 0x17 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_34_5 0x18 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_36_0 0x19 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_37_5 0x1A -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_39_0 0x1B -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_40_5 0x1C -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_42_0 0x1D -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_43_5 0x1E -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_45_0 0x1F -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_46_5 0x20 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_48_0 0x21 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_49_5 0x22 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_51_0 0x23 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_52_5 0x24 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_54_0 0x25 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_55_5 0x26 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_57_0 0x27 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_58_5 0x28 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_60_0 0x29 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_61_5 0x2A -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_GAIN_NEG_63_0 0x2B - -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_MUTE_S 1 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_MUTE_M 0x2 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_MUTE_MUTE 0x1 -#define TIMPANI_PA_HPH_R_GAIN_HPH_R_MUTE_UNMUTE 0x0 - -#define TIMPANI_PA_HPH_R_GAIN_RESERVED_S 0 -#define TIMPANI_PA_HPH_R_GAIN_RESERVED_M 0x1 - - -/* -- For AUXPGA_LR_GAIN */ -#define TIMPANI_A_AUXPGA_LR_GAIN (0x38) -#define TIMPANI_AUXPGA_LR_GAIN_RWC "RW" -#define TIMPANI_AUXPGA_LR_GAIN_POR 0xaa -#define TIMPANI_AUXPGA_LR_GAIN_S 0 -#define TIMPANI_AUXPGA_LR_GAIN_M 0xFF - - -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_S 4 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_M 0xF0 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_30DB 0x0 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_27DB 0x1 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_24DB 0x2 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_21DB 0x3 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_18DB 0x4 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_15DB 0x5 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_12DB 0x6 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_9_0DB 0x7 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_6_0DB 0x8 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_NEG_3_0DB 0x9 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_POS_0_0DB 0xA -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_POS_3_0DB 0xB -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_POS_6_0DB 0xC -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_POS_9_0DB 0xD -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_POS_12_0DB_1 0xE -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_L_GAIN_POS_12_0DB_2 0xF - -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_S 0 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_M 0xF -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_30DB 0x0 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_27DB 0x1 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_24DB 0x2 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_21DB 0x3 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_18DB 0x4 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_15DB 0x5 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_12DB 0x6 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_9_0DB 0x7 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_6_0DB 0x8 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_NEG_3_0DB 0x9 -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_POS_0_0DB 0xA -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_POS_3_0DB 0xB -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_POS_6_0DB 0xC -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_POS_9_0DB 0xD -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_POS_12_0DB_1 0xE -#define TIMPANI_AUXPGA_LR_GAIN_AUXPGA_R_GAIN_POS_12_0DB_2 0xF - - -/* -- For PA_AUXO_EARPA_CONN */ -#define TIMPANI_A_PA_AUXO_EARPA_CONN (0x39) -#define TIMPANI_PA_AUXO_EARPA_CONN_RWC "RW" -#define TIMPANI_PA_AUXO_EARPA_CONN_POR 0 -#define TIMPANI_PA_AUXO_EARPA_CONN_S 0 -#define TIMPANI_PA_AUXO_EARPA_CONN_M 0xFF - - -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_AUXPGA_L_CONN_S 7 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_AUXPGA_L_CONN_M 0x80 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_AUXPGA_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_AUXPGA_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_IDAC_L_CONN_S 6 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_IDAC_L_CONN_M 0x40 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_IDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_IDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_CDAC_L_CONN_S 5 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_CDAC_L_CONN_M 0x20 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_CDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_AUXO_EARPA_CONN_AUXOUT_CDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_AUXO_EARPA_CONN_RESERVED_S 4 -#define TIMPANI_PA_AUXO_EARPA_CONN_RESERVED_M 0x10 - -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_GAIN_S 3 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_GAIN_M 0x8 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_GAIN_V_3_52DB 0x1 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_GAIN_V_2_02DB 0x0 - -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_AUXPGA_L_CONN_S 2 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_AUXPGA_L_CONN_M 0x4 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_AUXPGA_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_AUXPGA_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_IDAC_L_CONN_S 1 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_IDAC_L_CONN_M 0x2 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_IDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_IDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_CDAC_L_CONN_S 0 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_CDAC_L_CONN_M 0x1 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_CDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_AUXO_EARPA_CONN_EARPA_CDAC_L_CONN_CONNECT 0x1 - - -/* -- For PA_LINE_ST_CONN */ -#define TIMPANI_A_PA_LINE_ST_CONN (0x3A) -#define TIMPANI_PA_LINE_ST_CONN_RWC "RW" -#define TIMPANI_PA_LINE_ST_CONN_POR 0 -#define TIMPANI_PA_LINE_ST_CONN_S 0 -#define TIMPANI_PA_LINE_ST_CONN_M 0xFF - - -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_AUXPGA_L_CONN_S 7 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_AUXPGA_L_CONN_M 0x80 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_AUXPGA_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_AUXPGA_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_IDAC_L_CONN_S 6 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_IDAC_L_CONN_M 0x40 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_IDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_IDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_CDAC_L_CONN_S 5 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_CDAC_L_CONN_M 0x20 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_CDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_ST_CONN_LINE_L_CDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_AUXPGA_R_CONN_S 4 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_AUXPGA_R_CONN_M 0x10 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_AUXPGA_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_AUXPGA_R_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_IDAC_R_CONN_S 3 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_IDAC_R_CONN_M 0x8 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_IDAC_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_IDAC_R_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_CDAC_R_CONN_S 2 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_CDAC_R_CONN_M 0x4 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_CDAC_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_ST_CONN_LINE_R_CDAC_R_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_ST_CONN_AUXPGA_L_VCM_ADD_CURR_S 0 -#define TIMPANI_PA_LINE_ST_CONN_AUXPGA_L_VCM_ADD_CURR_M 0x3 -#define TIMPANI_PA_LINE_ST_CONN_AUXPGA_L_VCM_ADD_CURR_NONE 0x0 -#define TIMPANI_PA_LINE_ST_CONN_AUXPGA_L_VCM_ADD_CURR_V_1_25UA 0x1 -#define TIMPANI_PA_LINE_ST_CONN_AUXPGA_L_VCM_ADD_CURR_V_2_5UA 0x2 -#define TIMPANI_PA_LINE_ST_CONN_AUXPGA_L_VCM_ADD_CURR_V_3_75UA 0x3 - - -/* -- For PA_LINE_MONO_CONN */ -#define TIMPANI_A_PA_LINE_MONO_CONN (0x3B) -#define TIMPANI_PA_LINE_MONO_CONN_RWC "RW" -#define TIMPANI_PA_LINE_MONO_CONN_POR 0 -#define TIMPANI_PA_LINE_MONO_CONN_S 0 -#define TIMPANI_PA_LINE_MONO_CONN_M 0xFF - - -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_CONN_S 7 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_CONN_M 0x80 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_CONN_S 6 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_CONN_M 0x40 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_CONN_S 5 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_CONN_M 0x20 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_INV_CONN_S 4 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_INV_CONN_M 0x10 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_INV_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_AUXPGA_L_INV_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_INV_CONN_S 3 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_INV_CONN_M 0x8 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_INV_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_IDAC_L_INV_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_INV_CONN_S 2 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_INV_CONN_M 0x4 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_INV_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_LINE_MONO_CONN_LINE_R_CDAC_L_INV_CONN_CONNECT 0x1 - -#define TIMPANI_PA_LINE_MONO_CONN_AUXPGA_R_VCM_ADD_CURR_S 0 -#define TIMPANI_PA_LINE_MONO_CONN_AUXPGA_R_VCM_ADD_CURR_M 0x3 -#define TIMPANI_PA_LINE_MONO_CONN_AUXPGA_R_VCM_ADD_CURR_NONE 0x0 -#define TIMPANI_PA_LINE_MONO_CONN_AUXPGA_R_VCM_ADD_CURR_V_1_25UA 0x1 -#define TIMPANI_PA_LINE_MONO_CONN_AUXPGA_R_VCM_ADD_CURR_V_2_5UA 0x2 -#define TIMPANI_PA_LINE_MONO_CONN_AUXPGA_R_VCM_ADD_CURR_V_3_75UA 0x3 - - -/* -- For PA_HPH_ST_CONN */ -#define TIMPANI_A_PA_HPH_ST_CONN (0x3C) -#define TIMPANI_PA_HPH_ST_CONN_RWC "RW" -#define TIMPANI_PA_HPH_ST_CONN_POR 0 -#define TIMPANI_PA_HPH_ST_CONN_S 0 -#define TIMPANI_PA_HPH_ST_CONN_M 0xFF - - -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_AUXPGA_L_CONN_S 7 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_AUXPGA_L_CONN_M 0x80 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_AUXPGA_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_AUXPGA_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_IDAC_L_CONN_S 6 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_IDAC_L_CONN_M 0x40 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_IDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_IDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_CDAC_L_CONN_S 5 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_CDAC_L_CONN_M 0x20 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_CDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_CDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_AUXPGA_R_CONN_S 4 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_AUXPGA_R_CONN_M 0x10 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_AUXPGA_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_AUXPGA_R_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_IDAC_R_CONN_S 3 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_IDAC_R_CONN_M 0x8 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_IDAC_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_IDAC_R_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_CDAC_R_CONN_S 2 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_CDAC_R_CONN_M 0x4 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_CDAC_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_CDAC_R_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_RAMP_GEN_EN_S 1 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_RAMP_GEN_EN_M 0x2 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_RAMP_GEN_EN_DISABLE 0x1 -#define TIMPANI_PA_HPH_ST_CONN_HPH_L_RAMP_GEN_EN_ENABLE 0x0 - -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_RAMP_GEN_EN_S 0 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_RAMP_GEN_EN_M 0x1 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_RAMP_GEN_EN_DISABLE 0x1 -#define TIMPANI_PA_HPH_ST_CONN_HPH_R_RAMP_GEN_EN_ENABLE 0x0 - - -/* -- For PA_HPH_MONO_CONN */ -#define TIMPANI_A_PA_HPH_MONO_CONN (0x3D) -#define TIMPANI_PA_HPH_MONO_CONN_RWC "RW" -#define TIMPANI_PA_HPH_MONO_CONN_POR 0 -#define TIMPANI_PA_HPH_MONO_CONN_S 0 -#define TIMPANI_PA_HPH_MONO_CONN_M 0xFF - - -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_CONN_S 7 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_CONN_M 0x80 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_CONN_S 6 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_CONN_M 0x40 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_CONN_S 5 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_CONN_M 0x20 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_INV_CONN_S 4 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_INV_CONN_M 0x10 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_INV_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_AUXPGA_L_INV_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_INV_CONN_S 3 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_INV_CONN_M 0x8 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_INV_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_IDAC_L_INV_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_INV_CONN_S 2 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_INV_CONN_M 0x4 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_INV_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_HPH_MONO_CONN_HPH_R_CDAC_L_INV_CONN_CONNECT 0x1 - -#define TIMPANI_PA_HPH_MONO_CONN_RESERVED_S 0 -#define TIMPANI_PA_HPH_MONO_CONN_RESERVED_M 0x3 - - -/* -- For PA_CLASSD_CONN */ -#define TIMPANI_A_PA_CLASSD_CONN (0x3E) -#define TIMPANI_PA_CLASSD_CONN_RWC "RW" -#define TIMPANI_PA_CLASSD_CONN_POR 0 -#define TIMPANI_PA_CLASSD_CONN_S 0 -#define TIMPANI_PA_CLASSD_CONN_M 0xFF - - -#define TIMPANI_PA_CLASSD_CONN_CLASSD_CDAC_CONN_S 7 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_CDAC_CONN_M 0x80 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_CDAC_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_CDAC_CONN_CONNECT 0x1 - -#define TIMPANI_PA_CLASSD_CONN_CLASSD_IDAC_CONN_S 6 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_IDAC_CONN_M 0x40 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_IDAC_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_IDAC_CONN_CONNECT 0x1 - -#define TIMPANI_PA_CLASSD_CONN_CLASSD_AUXPGA_CONN_S 5 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_AUXPGA_CONN_M 0x20 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_AUXPGA_CONN_NO_CONNECT 0x0 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_AUXPGA_CONN_CONNECT 0x1 - -#define TIMPANI_PA_CLASSD_CONN_CLASSD_PA_MODE_S 4 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_PA_MODE_M 0x10 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_PA_MODE_MONO_DIFF 0x1 -#define TIMPANI_PA_CLASSD_CONN_CLASSD_PA_MODE_STEREO 0x0 - -#define TIMPANI_PA_CLASSD_CONN_RESERVED_S 0 -#define TIMPANI_PA_CLASSD_CONN_RESERVED_M 0xF - - -/* -- For PA_CNP_CTL */ -#define TIMPANI_A_PA_CNP_CTL (0x3F) -#define TIMPANI_PA_CNP_CTL_RWC "RW" -#define TIMPANI_PA_CNP_CTL_POR 0x07 -#define TIMPANI_PA_CNP_CTL_S 0 -#define TIMPANI_PA_CNP_CTL_M 0xFF - - -#define TIMPANI_PA_CNP_CTL_CNP_RAMP_GEN_CURRENT_S 6 -#define TIMPANI_PA_CNP_CTL_CNP_RAMP_GEN_CURRENT_M 0xC0 -#define TIMPANI_PA_CNP_CTL_CNP_RAMP_GEN_CURRENT_V_1_75_NA 0x0 -#define TIMPANI_PA_CNP_CTL_CNP_RAMP_GEN_CURRENT_V_3_5_NA_NORMAL_OP 0x1 -#define TIMPANI_PA_CNP_CTL_CNP_RAMP_GEN_CURRENT_V_5_25_NA 0x2 -#define TIMPANI_PA_CNP_CTL_CNP_RAMP_GEN_CURRENT_V_10_NA 0x3 - -#define TIMPANI_PA_CNP_CTL_RESERVED_S 4 -#define TIMPANI_PA_CNP_CTL_RESERVED_M 0x30 - -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_CIRCUIT_EN_S 3 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_CIRCUIT_EN_M 0x8 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_CIRCUIT_EN_DISABLE 0x0 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_CIRCUIT_EN_ENABLE 0x1 - -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_S 0 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_M 0x7 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_220_V 0x0 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_243_V 0x1 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_266_V 0x2 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_290_V 0x3 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_341_V 0x4 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_339_V 0x5 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_365_V 0x6 -#define TIMPANI_PA_CNP_CTL_CLASSD_SUPPLY_DUMP_THRESH_V_2_391_V 0x7 - - -/* -- For PA_CLASSD_L_CTL */ -#define TIMPANI_A_PA_CLASSD_L_CTL (0x40) -#define TIMPANI_PA_CLASSD_L_CTL_RWC "RW" -#define TIMPANI_PA_CLASSD_L_CTL_POR 0x08 -#define TIMPANI_PA_CLASSD_L_CTL_S 0 -#define TIMPANI_PA_CLASSD_L_CTL_M 0xFF - - -#define TIMPANI_PA_CLASSD_L_CTL_RESERVED_S 6 -#define TIMPANI_PA_CLASSD_L_CTL_RESERVED_M 0xC0 - -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_LOGIC_RESET_S 5 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_LOGIC_RESET_M 0x20 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_LOGIC_RESET_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_LOGIC_RESET_RESET_PA_LOGIC 0x1 - -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_INT_RESET_S 4 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_INT_RESET_M 0x10 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_INT_RESET_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_INT_RESET_DISCHARGE_CAPS 0x1 - -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_REF_SEL_S 2 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_REF_SEL_M 0xC -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_REF_SEL_GND 0x0 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_REF_SEL_IBIAS_X_R_REF 0x1 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_REF_SEL_BG_VOLTAGE 0x2 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_REF_SEL_VDD_BY_2 0x3 - -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_1_S 1 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_1_M 0x2 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_1_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_1_PA_OUT_TO_VDD 0x1 - -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_0_S 0 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_0_M 0x1 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_0_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_L_CTL_CLASSD_L_PA_FORCE_0_PA_OUT_TO_GND 0x1 - - -/* -- For PA_CLASSD_R_CTL */ -#define TIMPANI_A_PA_CLASSD_R_CTL (0x41) -#define TIMPANI_PA_CLASSD_R_CTL_RWC "RW" -#define TIMPANI_PA_CLASSD_R_CTL_POR 0x08 -#define TIMPANI_PA_CLASSD_R_CTL_S 0 -#define TIMPANI_PA_CLASSD_R_CTL_M 0xFF - - -#define TIMPANI_PA_CLASSD_R_CTL_RESERVED_S 6 -#define TIMPANI_PA_CLASSD_R_CTL_RESERVED_M 0xC0 - -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_LOGIC_RESET_S 5 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_LOGIC_RESET_M 0x20 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_LOGIC_RESET_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_LOGIC_RESET_RESET_PA_LOGIC 0x1 - -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_INT_RESET_S 4 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_INT_RESET_M 0x10 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_INT_RESET_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_INT_RESET_DISCHARGE_CAPS 0x1 - -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_REF_SEL_S 2 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_REF_SEL_M 0xC -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_REF_SEL_GND 0x0 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_REF_SEL_IBIAS_X_R_REF 0x1 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_REF_SEL_BG_VOLTAGE 0x2 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_REF_SEL_VDD_BY_2 0x3 - -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_1_S 1 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_1_M 0x2 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_1_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_1_PA_OUT_TO_VDD 0x1 - -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_0_S 0 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_0_M 0x1 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_0_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_R_CTL_CLASSD_R_PA_FORCE_0_PA_OUT_TO_GND 0x1 - - -/* -- For PA_CLASSD_INT2_CTL */ -#define TIMPANI_A_PA_CLASSD_INT2_CTL (0x42) -#define TIMPANI_PA_CLASSD_INT2_CTL_RWC "RW" -#define TIMPANI_PA_CLASSD_INT2_CTL_POR 0xb0 -#define TIMPANI_PA_CLASSD_INT2_CTL_S 0 -#define TIMPANI_PA_CLASSD_INT2_CTL_M 0xFF - - -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_CFB_S 6 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_CFB_M 0xC0 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_CFB_V_5_0PF 0x0 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_CFB_V_7_5PF 0x1 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_CFB_V_10PF 0x2 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_CFB_V_15PF 0x3 - -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_RIN_S 4 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_RIN_M 0x30 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_RIN_V_100K 0x0 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_RIN_V_150K 0x1 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_RIN_V_175K 0x2 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_L_INT2_RIN_V_200K 0x3 - -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_CFB_S 2 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_CFB_M 0xC -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_CFB_V_5_0PF 0x0 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_CFB_V_7_5PF 0x1 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_CFB_V_10PF 0x2 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_CFB_V_15PF 0x3 - -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_RIN_S 0 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_RIN_M 0x3 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_RIN_V_100K 0x0 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_RIN_V_150K 0x1 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_RIN_V_175K 0x2 -#define TIMPANI_PA_CLASSD_INT2_CTL_CLASSD_R_INT2_RIN_V_200K 0x3 - - -/* -- For PA_HPH_L_OCP_CLK_CTL */ -#define TIMPANI_A_PA_HPH_L_OCP_CLK_CTL (0x43) -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_RWC "RW" -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_POR 0xf2 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_S 0 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_M 0xFF - - -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_DIV_2_EN_S 7 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_DIV_2_EN_M 0x80 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_DIV_2_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_DIV_2_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_EN_S 6 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_EN_M 0x40 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_RATIO_S 4 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_RATIO_M 0x30 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_RATIO_DIV2 0x0 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_RATIO_DIV4 0x1 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_RATIO_DIV6 0x2 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CARRIER_PROG_DIV_RATIO_DIV8 0x3 - -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CLK_SEL_LEFT_S 3 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CLK_SEL_LEFT_M 0x8 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CLK_SEL_LEFT_CLK_FROM_CH_2 0x1 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_CLK_SEL_LEFT_CLK_FROM_CH_1 0x0 - -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_2_EN_S 2 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_2_EN_M 0x4 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_2_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_2_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_RATIO_S 0 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_RATIO_M 0x3 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_RATIO_DIV_BY_4 0x0 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_RATIO_DIV_BY_8 0x1 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_RATIO_DIV_BY_12 0x2 -#define TIMPANI_PA_HPH_L_OCP_CLK_CTL_HPH_L_OCP_TIMER_DIV_RATIO_DIV_BY_16 0x3 - - -/* -- For PA_CLASSD_L_SW_CTL */ -#define TIMPANI_A_PA_CLASSD_L_SW_CTL (0x44) -#define TIMPANI_PA_CLASSD_L_SW_CTL_RWC "RW" -#define TIMPANI_PA_CLASSD_L_SW_CTL_POR 0x37 -#define TIMPANI_PA_CLASSD_L_SW_CTL_S 0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_M 0xFF - - -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_BREAK_BEFORE_MAKE_DELAY_S 6 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_BREAK_BEFORE_MAKE_DELAY_M 0xC0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_BREAK_BEFORE_MAKE_DELAY_V_1 0x0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_BREAK_BEFORE_MAKE_DELAY_V_2 0x1 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_BREAK_BEFORE_MAKE_DELAY_V_3 0x2 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_BREAK_BEFORE_MAKE_DELAY_V_4 0x3 - -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_OUT_DRIVE_STREN_S 4 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_OUT_DRIVE_STREN_M 0x30 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_OUT_DRIVE_STREN_V_3_OF_6_UNITS 0x0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_OUT_DRIVE_STREN_V_4_OF_6_UNITS 0x1 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_OUT_DRIVE_STREN_V_5_OF_6_UNITS 0x2 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_OUT_DRIVE_STREN_V_6_OF_6_UNITS 0x3 - -#define TIMPANI_PA_CLASSD_L_SW_CTL_RESERVED_S 3 -#define TIMPANI_PA_CLASSD_L_SW_CTL_RESERVED_M 0x8 - -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_BYPASS_CAP_EN_S 2 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_BYPASS_CAP_EN_M 0x4 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_BYPASS_CAP_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_BYPASS_CAP_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_NON_OVERLAP_EN_S 1 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_NON_OVERLAP_EN_M 0x2 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_NON_OVERLAP_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_NON_OVERLAP_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_SWITCH_MODE_S 0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_SWITCH_MODE_M 0x1 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_SWITCH_MODE_POWER_GROUND 0x0 -#define TIMPANI_PA_CLASSD_L_SW_CTL_CLASSD_L_CDAC_SWITCH_MODE_RST_MIDPOINT 0x1 - -/* -- For PA_CLASSD_L_OCP1 */ -#define TIMPANI_A_PA_CLASSD_L_OCP1 (0x45) -#define TIMPANI_PA_CLASSD_L_OCP1_RWC "RW" -#define TIMPANI_PA_CLASSD_L_OCP1_POR 0xff -#define TIMPANI_PA_CLASSD_L_OCP1_S 0 -#define TIMPANI_PA_CLASSD_L_OCP1_M 0xFF - - -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_EN_S 7 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_EN_M 0x80 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_LOCK_S 6 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_LOCK_M 0x40 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_LOCK_NEVER_LOCKS 0x0 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_LOCK_LOCKS 0x1 - -#define TIMPANI_PA_CLASSD_L_OCP1_OCP_CUR_THRESH_S 4 -#define TIMPANI_PA_CLASSD_L_OCP1_OCP_CUR_THRESH_M 0x30 -#define TIMPANI_PA_CLASSD_L_OCP1_OCP_CUR_THRESH_V_100MA_83_3MA_66_7MA_50MA 0x0 -#define TIMPANI_PA_CLASSD_L_OCP1_OCP_CUR_THRESH_V_133MA_111MA_88_7MA_66_7MA 0x1 -#define TIMPANI_PA_CLASSD_L_OCP1_OCP_CUR_THRESH_V_166MA_138MA_111MA_83_3MA 0x2 -#define TIMPANI_PA_CLASSD_L_OCP1_OCP_CUR_THRESH_V_200MA_166MA_133MA_100MA 0x3 - -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_S 0 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_M 0xF -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_1 0x1 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_2 0x2 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_3 0x3 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_4 0x4 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_5 0x5 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_6 0x6 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_7 0x7 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_8 0x8 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_9 0x9 -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_10 0xA -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_11 0xB -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_12 0xC -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_13 0xD -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_14 0xE -#define TIMPANI_PA_CLASSD_L_OCP1_CLASSD_L_OCP_NUM_CONN_ATTEMPTS_V_15 0xF - -/* -- For PA_CLASSD_L_OCP2 */ -#define TIMPANI_A_PA_CLASSD_L_OCP2 (0x46) -#define TIMPANI_PA_CLASSD_L_OCP2_RWC "RW" -#define TIMPANI_PA_CLASSD_L_OCP2_POR 0x77 -#define TIMPANI_PA_CLASSD_L_OCP2_S 0 -#define TIMPANI_PA_CLASSD_L_OCP2_M 0xFF - - -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_S 4 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_M 0xF0 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_255 0x0 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_511 0x1 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_767 0x2 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_1023 0x3 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_1279 0x4 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_1535 0x5 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_1791 0x6 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_2047 0x7 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_2303 0x8 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_2559 0x9 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_2815 0xA -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_3071 0xB -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_3327 0xC -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_3583 0xD -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_3839 0xE -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_WAIT_CNT_V_4095 0xF - -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_S 0 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_M 0xF -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_255 0x0 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_511 0x1 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_767 0x2 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_1023 0x3 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_1279 0x4 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_1535 0x5 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_1791 0x6 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_2047 0x7 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_2303 0x8 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_2559 0x9 -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_2815 0xA -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_3071 0xB -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_3327 0xC -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_3583 0xD -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_3839 0xE -#define TIMPANI_PA_CLASSD_L_OCP2_CLASSD_L_OCP_OCP_RUN_CNT_V_4095 0xF - - -/* -- For PA_HPH_R_OCP_CLK_CTL */ -#define TIMPANI_A_PA_HPH_R_OCP_CLK_CTL (0x47) -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_RWC "RW" -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_POR 0xf2 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_S 0 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_M 0xFF - - -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_DIV_2_EN_S 7 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_DIV_2_EN_M 0x80 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_DIV_2_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_DIV_2_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_EN_S 6 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_EN_M 0x40 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_RATIO_S 4 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_RATIO_M 0x30 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_RATIO_DIV2 0x0 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_RATIO_DIV4 0x1 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_RATIO_DIV6 0x2 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CARRIER_PROG_DIV_RATIO_DIV8 0x3 - -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CLK_SEL_RIGHT_S 3 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CLK_SEL_RIGHT_M 0x8 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CLK_SEL_RIGHT_CLK_FROM_CH_2 0x1 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_CLK_SEL_RIGHT_CLK_FROM_CH_1 0x0 - -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_2_EN_S 2 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_2_EN_M 0x4 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_2_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_2_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_RATIO_S 0 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_RATIO_M 0x3 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_RATIO_DIV_BY_4 0x0 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_RATIO_DIV_BY_8 0x1 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_RATIO_DIV_BY_12 0x2 -#define TIMPANI_PA_HPH_R_OCP_CLK_CTL_HPH_R_OCP_TIMER_DIV_RATIO_DIV_BY_16 0x3 - - -/* -- For PA_CLASSD_R_SW_CTL */ -#define TIMPANI_A_PA_CLASSD_R_SW_CTL (0x48) -#define TIMPANI_PA_CLASSD_R_SW_CTL_RWC "RW" -#define TIMPANI_PA_CLASSD_R_SW_CTL_POR 0x37 -#define TIMPANI_PA_CLASSD_R_SW_CTL_S 0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_M 0xFF - - -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_BREAK_BEFORE_MAKE_DELAY_S 6 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_BREAK_BEFORE_MAKE_DELAY_M 0xC0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_BREAK_BEFORE_MAKE_DELAY_V_1 0x0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_BREAK_BEFORE_MAKE_DELAY_V_2 0x1 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_BREAK_BEFORE_MAKE_DELAY_V_3 0x2 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_BREAK_BEFORE_MAKE_DELAY_V_4 0x3 - -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_OUT_DRIVE_STREN_S 4 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_OUT_DRIVE_STREN_M 0x30 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_OUT_DRIVE_STREN_V_3_OF_6_UNITS 0x0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_OUT_DRIVE_STREN_V_4_OF_6_UNITS 0x1 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_OUT_DRIVE_STREN_V_5_OF_6_UNITS 0x2 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_OUT_DRIVE_STREN_V_6_OF_6_UNITS 0x3 - -#define TIMPANI_PA_CLASSD_R_SW_CTL_RESERVED_S 3 -#define TIMPANI_PA_CLASSD_R_SW_CTL_RESERVED_M 0x8 - -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_BYPASS_CAP_EN_S 2 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_BYPASS_CAP_EN_M 0x4 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_BYPASS_CAP_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_BYPASS_CAP_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_NON_OVERLAP_EN_S 1 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_NON_OVERLAP_EN_M 0x2 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_NON_OVERLAP_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_NON_OVERLAP_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_SWITCH_MODE_S 0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_SWITCH_MODE_M 0x1 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_SWITCH_MODE_POWER_GROUND 0x0 -#define TIMPANI_PA_CLASSD_R_SW_CTL_CLASSD_R_CDAC_SWITCH_MODE_RST_MIDPOINT 0x1 - - -/* -- For PA_CLASSD_R_OCP1 */ -#define TIMPANI_A_PA_CLASSD_R_OCP1 (0x49) -#define TIMPANI_PA_CLASSD_R_OCP1_RWC "RW" -#define TIMPANI_PA_CLASSD_R_OCP1_POR 0xff -#define TIMPANI_PA_CLASSD_R_OCP1_S 0 -#define TIMPANI_PA_CLASSD_R_OCP1_M 0xFF - - -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_EN_S 7 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_EN_M 0x80 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_EN_DISABLE 0x0 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_EN_ENABLE 0x1 - -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_LOCK_S 6 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_LOCK_M 0x40 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_LOCK_NEVER_LOCKS 0x0 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_LOCK_LOCKS 0x1 - -#define TIMPANI_PA_CLASSD_R_OCP1_OCP_CUR_THRESH_S 4 -#define TIMPANI_PA_CLASSD_R_OCP1_OCP_CUR_THRESH_M 0x30 -#define TIMPANI_PA_CLASSD_R_OCP1_OCP_CUR_THRESH_V_100MA_83_3MA_66_7MA_50MA 0x0 -#define TIMPANI_PA_CLASSD_R_OCP1_OCP_CUR_THRESH_V_133MA_111MA_88_7MA_66_7MA 0x1 -#define TIMPANI_PA_CLASSD_R_OCP1_OCP_CUR_THRESH_V_166MA_138MA_111MA_83_3MA 0x2 -#define TIMPANI_PA_CLASSD_R_OCP1_OCP_CUR_THRESH_V_200MA_166MA_133MA_100MA 0x3 - -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_S 0 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_M 0xF -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_1 0x1 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_2 0x2 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_3 0x3 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_4 0x4 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_5 0x5 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_6 0x6 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_7 0x7 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_8 0x8 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_9 0x9 -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_10 0xA -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_11 0xB -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_12 0xC -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_13 0xD -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_14 0xE -#define TIMPANI_PA_CLASSD_R_OCP1_CLASSD_R_OCP_NUM_CONN_ATTEMPTS_V_15 0xF - - -/* -- For PA_CLASSD_R_OCP2 */ -#define TIMPANI_A_PA_CLASSD_R_OCP2 (0x4A) -#define TIMPANI_PA_CLASSD_R_OCP2_RWC "RW" -#define TIMPANI_PA_CLASSD_R_OCP2_POR 0x77 -#define TIMPANI_PA_CLASSD_R_OCP2_S 0 -#define TIMPANI_PA_CLASSD_R_OCP2_M 0xFF - - -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_S 4 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_M 0xF0 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_255 0x0 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_511 0x1 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_767 0x2 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_1023 0x3 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_1279 0x4 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_1535 0x5 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_1791 0x6 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_2047 0x7 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_2303 0x8 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_2559 0x9 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_2815 0xA -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_3071 0xB -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_3327 0xC -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_3583 0xD -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_3839 0xE -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_WAIT_CNT_V_4095 0xF - -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_S 0 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_M 0xF -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_255 0x0 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_511 0x1 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_767 0x2 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_1023 0x3 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_1279 0x4 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_1535 0x5 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_1791 0x6 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_2047 0x7 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_2303 0x8 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_2559 0x9 -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_2815 0xA -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_3071 0xB -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_3327 0xC -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_3583 0xD -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_3839 0xE -#define TIMPANI_PA_CLASSD_R_OCP2_CLASSD_R_OCP_OCP_RUN_CNT_V_4095 0xF - - -/* -- For PA_HPH_CTL1 */ -#define TIMPANI_A_PA_HPH_CTL1 (0x4B) -#define TIMPANI_PA_HPH_CTL1_RWC "RW" -#define TIMPANI_PA_HPH_CTL1_POR 0x44 -#define TIMPANI_PA_HPH_CTL1_S 0 -#define TIMPANI_PA_HPH_CTL1_M 0xFF - - -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_S 4 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_M 0xF0 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_V_400PER 0x1 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_V_200PER 0x2 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_V_133PER 0x3 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_V_100PER 0x4 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_V_66PER 0x6 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_V_50PER 0x8 -#define TIMPANI_PA_HPH_CTL1_HPH_GM3_BIAS_V_33PER 0xC - -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_DET_EN_S 3 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_DET_EN_M 0x8 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_DET_EN_DISABLE 0x0 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_DET_EN_ENABLE 0x1 - -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_S 0 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_M 0x7 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_V_300MA 0x0 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_V_350MA 0x2 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_V_365MA 0x3 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_V_150MA 0x4 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_V_190MA 0x6 -#define TIMPANI_PA_HPH_CTL1_HPH_SHORT_CIRCUIT_CUR_LIMIT_V_220MA 0x7 - - -/* -- For PA_HPH_CTL2 */ -#define TIMPANI_A_PA_HPH_CTL2 (0x4C) -#define TIMPANI_PA_HPH_CTL2_RWC "RW" -#define TIMPANI_PA_HPH_CTL2_POR 0xC8 -#define TIMPANI_PA_HPH_CTL2_S 0 -#define TIMPANI_PA_HPH_CTL2_M 0xFF - - -#define TIMPANI_PA_HPH_CTL2_HPH_SW_VNEG_CTL_S 7 -#define TIMPANI_PA_HPH_CTL2_HPH_SW_VNEG_CTL_M 0x80 -#define TIMPANI_PA_HPH_CTL2_HPH_SW_VNEG_CTL_VNEG 0x1 -#define TIMPANI_PA_HPH_CTL2_HPH_SW_VNEG_CTL_VSS 0x0 - -#define TIMPANI_PA_HPH_CTL2_HPH_VNEG_PS_GAIN_S 6 -#define TIMPANI_PA_HPH_CTL2_HPH_VNEG_PS_GAIN_M 0x40 -#define TIMPANI_PA_HPH_CTL2_HPH_VNEG_PS_GAIN_V_1_5 0x1 -#define TIMPANI_PA_HPH_CTL2_HPH_VNEG_PS_GAIN_V_2_5 0x0 - -#define TIMPANI_PA_HPH_CTL2_HPH_PS_FILTER_EN_S 5 -#define TIMPANI_PA_HPH_CTL2_HPH_PS_FILTER_EN_M 0x20 -#define TIMPANI_PA_HPH_CTL2_HPH_PS_FILTER_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_CTL2_HPH_PS_FILTER_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_CTL2_HPH_OCP_EN_S 4 -#define TIMPANI_PA_HPH_CTL2_HPH_OCP_EN_M 0x10 -#define TIMPANI_PA_HPH_CTL2_HPH_OCP_EN_ENABLE 0x1 -#define TIMPANI_PA_HPH_CTL2_HPH_OCP_EN_DISABLE 0x0 - -#define TIMPANI_PA_HPH_CTL2_HPH_VREF_SEL_S 2 -#define TIMPANI_PA_HPH_CTL2_HPH_VREF_SEL_M 0xC -#define TIMPANI_PA_HPH_CTL2_HPH_VREF_SEL_GROUND 0x0 -#define TIMPANI_PA_HPH_CTL2_HPH_VREF_SEL_IBIAS_ON_RESISTOR 0x1 -#define TIMPANI_PA_HPH_CTL2_HPH_VREF_SEL_BG 0x2 -#define TIMPANI_PA_HPH_CTL2_HPH_VREF_SEL_AVDD_BY_2 0x3 - -#define TIMPANI_PA_HPH_CTL2_HPH_OUT_SHUNT_EN_S 1 -#define TIMPANI_PA_HPH_CTL2_HPH_OUT_SHUNT_EN_M 0x2 -#define TIMPANI_PA_HPH_CTL2_HPH_OUT_SHUNT_EN_DISABLE 0x0 -#define TIMPANI_PA_HPH_CTL2_HPH_OUT_SHUNT_EN_ENABLE 0x1 - -#define TIMPANI_PA_HPH_CTL2_RESERVED_S 0 -#define TIMPANI_PA_HPH_CTL2_RESERVED_M 0x1 - - -/* -- For PA_LINE_AUXO_CTL */ -#define TIMPANI_A_PA_LINE_AUXO_CTL (0x4D) -#define TIMPANI_PA_LINE_AUXO_CTL_RWC "RW" -#define TIMPANI_PA_LINE_AUXO_CTL_POR 0x2 -#define TIMPANI_PA_LINE_AUXO_CTL_S 0 -#define TIMPANI_PA_LINE_AUXO_CTL_M 0xFF - - -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_RAMPGEN_CNT_S 6 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_RAMPGEN_CNT_M 0xC0 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_RAMPGEN_CNT_V_1_75NA 0x0 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_RAMPGEN_CNT_V_3_5NA 0x1 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_RAMPGEN_CNT_V_5_25NA 0x2 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_RAMPGEN_CNT_V_10NA 0x3 - -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_L_BIAS_CUR_S 4 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_L_BIAS_CUR_M 0x30 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_L_BIAS_CUR_V_60UA 0x0 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_L_BIAS_CUR_V_30UA_1 0x1 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_L_BIAS_CUR_V_30UA_2 0x2 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_L_BIAS_CUR_V_15UA 0x3 - -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_R_BIAS_CUR_S 2 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_R_BIAS_CUR_M 0xC -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_R_BIAS_CUR_V_60UA 0x0 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_R_BIAS_CUR_V_30UA_1 0x1 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_R_BIAS_CUR_V_30UA_2 0x2 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_R_BIAS_CUR_V_15UA 0x3 - -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_CM_REF_SEL_S 0 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_CM_REF_SEL_M 0x3 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_CM_REF_SEL_VSSA 0x0 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_CM_REF_SEL_BG 0x2 -#define TIMPANI_PA_LINE_AUXO_CTL_LINEO_AUXO_CM_REF_SEL_VDDA_BY_2 0x3 - - -/* -- For PA_AUXO_EARPA_CTL */ -#define TIMPANI_A_PA_AUXO_EARPA_CTL (0x4E) -#define TIMPANI_PA_AUXO_EARPA_CTL_RWC "RW" -#define TIMPANI_PA_AUXO_EARPA_CTL_POR 0xe -#define TIMPANI_PA_AUXO_EARPA_CTL_S 0 -#define TIMPANI_PA_AUXO_EARPA_CTL_M 0xFF - - -#define TIMPANI_PA_AUXO_EARPA_CTL_RESERVED_S 6 -#define TIMPANI_PA_AUXO_EARPA_CTL_RESERVED_M 0xC0 - -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_BIAS_CUR_S 4 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_BIAS_CUR_M 0x30 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_BIAS_CUR_V_60UA 0x0 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_BIAS_CUR_V_30UA 0x1 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_BIAS_CUR_V_30UA_SAME_AS_01 0x2 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_BIAS_CUR_V_15UA 0x3 - -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_GAIN_S 3 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_GAIN_M 0x8 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_GAIN_NEG_4_5DB 0x1 -#define TIMPANI_PA_AUXO_EARPA_CTL_AUXO_GAIN_NEG_3_0DB 0x0 - -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_MASTER_BIAS_CUR_S 1 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_MASTER_BIAS_CUR_M 0x6 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_MASTER_BIAS_CUR_V_12_5UA 0x0 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_MASTER_BIAS_CUR_V_10_0UA 0x1 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_MASTER_BIAS_CUR_V_7_5UA 0x2 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_MASTER_BIAS_CUR_V_5_0UA 0x3 - -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_VCM_SOURCE_S 0 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_VCM_SOURCE_M 0x1 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_VCM_SOURCE_BG 0x1 -#define TIMPANI_PA_AUXO_EARPA_CTL_EARPA_VCM_SOURCE_LOCAL_VCM 0x0 - - -/* -- For PA_EARO_CTL */ -#define TIMPANI_A_PA_EARO_CTL (0x4F) -#define TIMPANI_PA_EARO_CTL_RWC "RW" -#define TIMPANI_PA_EARO_CTL_POR 0x0 -#define TIMPANI_PA_EARO_CTL_S 0 -#define TIMPANI_PA_EARO_CTL_M 0xFF - - -#define TIMPANI_PA_EARO_CTL_EARPA_STARTUP_S 7 -#define TIMPANI_PA_EARO_CTL_EARPA_STARTUP_M 0x80 -#define TIMPANI_PA_EARO_CTL_EARPA_STARTUP_NORMAL_OP 0x0 -#define TIMPANI_PA_EARO_CTL_EARPA_STARTUP_CONNECT_INPUTS_TO_GROUND 0x1 - -#define TIMPANI_PA_EARO_CTL_EARPA_BYPASS_INPUT_CM_S 6 -#define TIMPANI_PA_EARO_CTL_EARPA_BYPASS_INPUT_CM_M 0x40 -#define TIMPANI_PA_EARO_CTL_EARPA_BYPASS_INPUT_CM_NO_BYPASS 0x0 -#define TIMPANI_PA_EARO_CTL_EARPA_BYPASS_INPUT_CM_BYPASS 0x1 - -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_S 3 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_M 0x38 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_213UA 0x0 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_280UA 0x1 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_408UA_1 0x2 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_780UA_1 0x3 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_408UA_2 0x4 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_530UA 0x5 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_780UA_2 0x6 -#define TIMPANI_PA_EARO_CTL_EARPA_NMOS_BIAS_CUR_V_1480UA 0x7 - -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_S 0 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_M 0x7 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_213UA 0x0 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_280UA 0x1 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_408UA_1 0x2 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_780UA_1 0x3 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_408UA_2 0x4 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_530UA 0x5 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_780UA_2 0x6 -#define TIMPANI_PA_EARO_CTL_EARPA_PMOS_BIAS_CUR_V_1480UA 0x7 - - -/* -- For PA_MASTER_BIAS_CUR */ -#define TIMPANI_A_PA_MASTER_BIAS_CUR (0x50) -#define TIMPANI_PA_MASTER_BIAS_CUR_RWC "RW" -#define TIMPANI_PA_MASTER_BIAS_CUR_POR 0xea -#define TIMPANI_PA_MASTER_BIAS_CUR_S 0 -#define TIMPANI_PA_MASTER_BIAS_CUR_M 0xFF - - -#define TIMPANI_PA_MASTER_BIAS_CUR_RAMPGEN_MASTER_BIAS_CUR_S 7 -#define TIMPANI_PA_MASTER_BIAS_CUR_RAMPGEN_MASTER_BIAS_CUR_M 0x80 -#define TIMPANI_PA_MASTER_BIAS_CUR_RAMPGEN_MASTER_BIAS_CUR_V_2_5UA 0x1 -#define TIMPANI_PA_MASTER_BIAS_CUR_RAMPGEN_MASTER_BIAS_CUR_V_5UA 0x0 - -#define TIMPANI_PA_MASTER_BIAS_CUR_AUXPGA_BIAS_CUR_S 5 -#define TIMPANI_PA_MASTER_BIAS_CUR_AUXPGA_BIAS_CUR_M 0x60 -#define TIMPANI_PA_MASTER_BIAS_CUR_AUXPGA_BIAS_CUR_V_10UA 0x0 -#define TIMPANI_PA_MASTER_BIAS_CUR_AUXPGA_BIAS_CUR_V_7_5UA 0x1 -#define TIMPANI_PA_MASTER_BIAS_CUR_AUXPGA_BIAS_CUR_V_5_0UA 0x2 -#define TIMPANI_PA_MASTER_BIAS_CUR_AUXPGA_BIAS_CUR_V_2_5UA 0x3 - -#define TIMPANI_PA_MASTER_BIAS_CUR_HPH_VCM_BUFF_BIAS_CURR_S 3 -#define TIMPANI_PA_MASTER_BIAS_CUR_HPH_VCM_BUFF_BIAS_CURR_M 0x18 -#define TIMPANI_PA_MASTER_BIAS_CUR_HPH_VCM_BUFF_BIAS_CURR_V_6_25UA 0x0 -#define TIMPANI_PA_MASTER_BIAS_CUR_HPH_VCM_BUFF_BIAS_CURR_V_5_0UA 0x1 -#define TIMPANI_PA_MASTER_BIAS_CUR_HPH_VCM_BUFF_BIAS_CURR_V_3_75UA 0x2 -#define TIMPANI_PA_MASTER_BIAS_CUR_HPH_VCM_BUFF_BIAS_CURR_V_2_5UA 0x3 - -#define TIMPANI_PA_MASTER_BIAS_CUR_LINE_VCM_BUFF_BIAS_CURR_S 1 -#define TIMPANI_PA_MASTER_BIAS_CUR_LINE_VCM_BUFF_BIAS_CURR_M 0x6 -#define TIMPANI_PA_MASTER_BIAS_CUR_LINE_VCM_BUFF_BIAS_CURR_V_6_25UA 0x0 -#define TIMPANI_PA_MASTER_BIAS_CUR_LINE_VCM_BUFF_BIAS_CURR_V_5_0UA 0x1 -#define TIMPANI_PA_MASTER_BIAS_CUR_LINE_VCM_BUFF_BIAS_CURR_V_3_75UA 0x2 -#define TIMPANI_PA_MASTER_BIAS_CUR_LINE_VCM_BUFF_BIAS_CURR_V_2_5UA 0x3 - -#define TIMPANI_PA_MASTER_BIAS_CUR_RESERVED_S 0 -#define TIMPANI_PA_MASTER_BIAS_CUR_RESERVED_M 0x1 - - -/* -- For PA_CLASSD_SC_STATUS */ -#define TIMPANI_A_PA_CLASSD_SC_STATUS (0x51) -#define TIMPANI_PA_CLASSD_SC_STATUS_RWC "R" -#define TIMPANI_PA_CLASSD_SC_STATUS_POR 0 -#define TIMPANI_PA_CLASSD_SC_STATUS_S 0 -#define TIMPANI_PA_CLASSD_SC_STATUS_M 0xFF - - -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_SC_DET_S 7 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_SC_DET_M 0x80 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_SC_DET_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_SC_DET_SC_DET 0x1 - -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_PWR_STAGE_HI_Z_S 6 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_PWR_STAGE_HI_Z_M 0x40 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_PWR_STAGE_HI_Z_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_L_PWR_STAGE_HI_Z_POWER_STAGE_OFF 0x1 - -#define TIMPANI_PA_CLASSD_SC_STATUS_RESERVED_1_S 4 -#define TIMPANI_PA_CLASSD_SC_STATUS_RESERVED_1_M 0x30 - -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_SC_DET_S 3 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_SC_DET_M 0x8 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_SC_DET_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_SC_DET_SC_DET 0x1 - -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_PWR_STAGE_HI_Z_S 2 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_PWR_STAGE_HI_Z_M 0x4 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_PWR_STAGE_HI_Z_NORMAL_OP 0x0 -#define TIMPANI_PA_CLASSD_SC_STATUS_CLASSD_R_PWR_STAGE_HI_Z_POWER_STAGE_OFF 0x1 - -#define TIMPANI_PA_CLASSD_SC_STATUS_RESERVED_2_S 1 -#define TIMPANI_PA_CLASSD_SC_STATUS_RESERVED_2_M 0x2 - -#define TIMPANI_PA_CLASSD_SC_STATUS_RESERVED_S 0 -#define TIMPANI_PA_CLASSD_SC_STATUS_RESERVED_M 0x1 - - -/* -- For PA_HPH_SC_STATUS */ -#define TIMPANI_A_PA_HPH_SC_STATUS (0x52) -#define TIMPANI_PA_HPH_SC_STATUS_RWC "R" -#define TIMPANI_PA_HPH_SC_STATUS_POR 0 -#define TIMPANI_PA_HPH_SC_STATUS_S 0 -#define TIMPANI_PA_HPH_SC_STATUS_M 0xFF - - -#define TIMPANI_PA_HPH_SC_STATUS_HPH_L_SC_DET_S 7 -#define TIMPANI_PA_HPH_SC_STATUS_HPH_L_SC_DET_M 0x80 -#define TIMPANI_PA_HPH_SC_STATUS_HPH_L_SC_DET_NORMAL_OP 0x0 -#define TIMPANI_PA_HPH_SC_STATUS_HPH_L_SC_DET_SC_DET 0x1 - -#define TIMPANI_PA_HPH_SC_STATUS_RESERVED_1_S 4 -#define TIMPANI_PA_HPH_SC_STATUS_RESERVED_1_M 0x70 - -#define TIMPANI_PA_HPH_SC_STATUS_HPH_R_SC_DET_S 3 -#define TIMPANI_PA_HPH_SC_STATUS_HPH_R_SC_DET_M 0x8 -#define TIMPANI_PA_HPH_SC_STATUS_HPH_R_SC_DET_NORMAL_OP 0x0 -#define TIMPANI_PA_HPH_SC_STATUS_HPH_R_SC_DET_SC_DET 0x1 - -#define TIMPANI_PA_HPH_SC_STATUS_RESERVED_2_S 2 -#define TIMPANI_PA_HPH_SC_STATUS_RESERVED_2_M 0x4 - -#define TIMPANI_PA_HPH_SC_STATUS_RESERVED_S 0 -#define TIMPANI_PA_HPH_SC_STATUS_RESERVED_M 0x3 - - -/* -- For ATEST_EN */ -#define TIMPANI_A_ATEST_EN (0x53) -#define TIMPANI_ATEST_EN_RWC "RW" -#define TIMPANI_ATEST_EN_POR 0 -#define TIMPANI_ATEST_EN_S 0 -#define TIMPANI_ATEST_EN_M 0xFF - - -#define TIMPANI_ATEST_EN_ATEST_EN_S 7 -#define TIMPANI_ATEST_EN_ATEST_EN_M 0x80 -#define TIMPANI_ATEST_EN_ATEST_EN_DISABLE 0x0 -#define TIMPANI_ATEST_EN_ATEST_EN_ENABLE 0x1 - -#define TIMPANI_ATEST_EN_RESERVED_S 0 -#define TIMPANI_ATEST_EN_RESERVED_M 0x7F - - -/* -- For ATEST_TSHKADC */ -#define TIMPANI_A_ATEST_TSHKADC (0x54) -#define TIMPANI_ATEST_TSHKADC_RWC "RW" -#define TIMPANI_ATEST_TSHKADC_POR 0 -#define TIMPANI_ATEST_TSHKADC_S 0 -#define TIMPANI_ATEST_TSHKADC_M 0xFF - - -#define TIMPANI_ATEST_TSHKADC_RESERVED_S 4 -#define TIMPANI_ATEST_TSHKADC_RESERVED_M 0xF0 - -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_AN_CONN_S 2 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_AN_CONN_M 0xC -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_AN_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_AN_CONN_MUX1 0x1 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_AN_CONN_MUX2 0x2 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_AN_CONN_MUX3 0x3 - -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_DIG_CONN_S 0 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_DIG_CONN_M 0x3 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_DIG_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_DIG_CONN_MUX1 0x1 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_DIG_CONN_MUX2 0x2 -#define TIMPANI_ATEST_TSHKADC_ATEST_TSADC_DIG_CONN_MUX3 0x3 - - -/* -- For ATEST_TXADC13 */ -#define TIMPANI_A_ATEST_TXADC13 (0x55) -#define TIMPANI_ATEST_TXADC13_RWC "RW" -#define TIMPANI_ATEST_TXADC13_POR 0 -#define TIMPANI_ATEST_TXADC13_S 0 -#define TIMPANI_ATEST_TXADC13_M 0xFF - - -#define TIMPANI_ATEST_TXADC13_RESERVED_S 7 -#define TIMPANI_ATEST_TXADC13_RESERVED_M 0x80 - -#define TIMPANI_ATEST_TXADC13_ATEST_SEL_L_S 6 -#define TIMPANI_ATEST_TXADC13_ATEST_SEL_L_M 0x40 -#define TIMPANI_ATEST_TXADC13_ATEST_SEL_L_TXADC1 0x0 -#define TIMPANI_ATEST_TXADC13_ATEST_SEL_L_TXADC3 0x1 - -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_S 3 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_M 0x38 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_ICMP1_TO_ATEST1 0x1 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_IOTA2_TO_ATEST1 0x2 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_IOTA1_TO_ATEST1 0x3 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_VICM_TO_ATEST1 0x4 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_VTH_P_TO_ATEST1 0x5 -#define TIMPANI_ATEST_TXADC13_ATEST1_TXADC13_CONN_VREFP_TO_ATEST1 0x6 - -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_S 0 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_M 0x7 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_IDACREF_TO_ATEST2 0x1 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_IB_10U_TO_ATEST2 0x2 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_VREFMID_TO_ATEST2 0x3 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_VOCM_TO_ATEST2 0x4 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_VTH_N_TO_ATEST2 0x5 -#define TIMPANI_ATEST_TXADC13_ATEST2_TXADC13_CONN_VREFN_TO_ATEST2 0x6 - - -/* -- For ATEST_TXADC24 */ -#define TIMPANI_A_ATEST_TXADC24 (0x56) -#define TIMPANI_ATEST_TXADC24_RWC "RW" -#define TIMPANI_ATEST_TXADC24_POR 0 -#define TIMPANI_ATEST_TXADC24_S 0 -#define TIMPANI_ATEST_TXADC24_M 0xFF - - -#define TIMPANI_ATEST_TXADC24_RESERVED_S 7 -#define TIMPANI_ATEST_TXADC24_RESERVED_M 0x80 - -#define TIMPANI_ATEST_TXADC24_ATEST_SEL_R_S 6 -#define TIMPANI_ATEST_TXADC24_ATEST_SEL_R_M 0x40 -#define TIMPANI_ATEST_TXADC24_ATEST_SEL_R_TXADC1 0x0 -#define TIMPANI_ATEST_TXADC24_ATEST_SEL_R_TXADC3 0x1 - -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_S 3 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_M 0x38 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_ICMP1_TO_ATEST1 0x1 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_IOTA2_TO_ATEST1 0x2 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_IOTA1_TO_ATEST1 0x3 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_VICM_TO_ATEST1 0x4 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_VTH_P_TO_ATEST1 0x5 -#define TIMPANI_ATEST_TXADC24_ATEST1_TXADC24_CONN_VREFP_TO_ATEST1 0x6 - -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_S 0 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_M 0x7 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_IDACREF_TO_ATEST2 0x1 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_IB_10U_TO_ATEST2 0x2 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_VREFMID_TO_ATEST2 0x3 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_VOCM_TO_ATEST2 0x4 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_VTH_N_TO_ATEST2 0x5 -#define TIMPANI_ATEST_TXADC24_ATEST2_TXADC24_CONN_VREFN_TO_ATEST2 0x6 - - -/* -- For ATEST_AUXPGA */ -#define TIMPANI_A_ATEST_AUXPGA (0x57) -#define TIMPANI_ATEST_AUXPGA_RWC "RW" -#define TIMPANI_ATEST_AUXPGA_POR 0 -#define TIMPANI_ATEST_AUXPGA_S 0 -#define TIMPANI_ATEST_AUXPGA_M 0xFF - - -#define TIMPANI_ATEST_AUXPGA_ATEST1_AUXPGA_INT_VCM_CONN_S 7 -#define TIMPANI_ATEST_AUXPGA_ATEST1_AUXPGA_INT_VCM_CONN_M 0x80 -#define TIMPANI_ATEST_AUXPGA_ATEST1_AUXPGA_INT_VCM_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_AUXPGA_ATEST1_AUXPGA_INT_VCM_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMI_VDD_CONN_S 6 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMI_VDD_CONN_M 0x40 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMI_VDD_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMI_VDD_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMO_R_L_CONN_S 5 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMO_R_L_CONN_M 0x20 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMO_R_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_VCMO_R_L_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_R_CONN_S 4 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_R_CONN_M 0x10 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_R_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_L_CONN_S 3 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_L_CONN_M 0x8 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_AUXPGA_ATEST_AUXPGA_L_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_AUXPGA_RESERVED_S 0 -#define TIMPANI_ATEST_AUXPGA_RESERVED_M 0x7 - - -/* -- For ATEST_CDAC */ -#define TIMPANI_A_ATEST_CDAC (0x58) -#define TIMPANI_ATEST_CDAC_RWC "RW" -#define TIMPANI_ATEST_CDAC_POR 0 -#define TIMPANI_ATEST_CDAC_S 0 -#define TIMPANI_ATEST_CDAC_M 0xFF - - -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_IN_CONN_S 7 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_IN_CONN_M 0x80 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_IN_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_IN_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_OUT_CONN_S 6 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_OUT_CONN_M 0x40 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_OUT_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_DWA_OUT_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_L_OUT_CONN_S 5 -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_L_OUT_CONN_M 0x20 -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_L_OUT_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_L_OUT_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_R_OUT_CONN_S 4 -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_R_OUT_CONN_M 0x10 -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_R_OUT_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_CDAC_ATEST_FILTER_R_OUT_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_L_CONN_S 2 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_L_CONN_M 0xC -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_L_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_L_CONN_TEST1 0x1 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_L_CONN_TEST2 0x2 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_L_CONN_TEST3 0x3 - -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_R_CONN_S 0 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_R_CONN_M 0x3 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_R_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_R_CONN_TEST1 0x1 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_R_CONN_TEST2 0x2 -#define TIMPANI_ATEST_CDAC_ATEST_CDAC_R_CONN_TEST3 0x3 - - -/* -- For ATEST_IDAC */ -#define TIMPANI_A_ATEST_IDAC (0x59) -#define TIMPANI_ATEST_IDAC_RWC "RW" -#define TIMPANI_ATEST_IDAC_POR 0 -#define TIMPANI_ATEST_IDAC_S 0 -#define TIMPANI_ATEST_IDAC_M 0xFF - - -#define TIMPANI_ATEST_IDAC_ATEST1_LR_CONN_S 7 -#define TIMPANI_ATEST_IDAC_ATEST1_LR_CONN_M 0x80 -#define TIMPANI_ATEST_IDAC_ATEST1_LR_CONN_RIGHT 0x1 -#define TIMPANI_ATEST_IDAC_ATEST1_LR_CONN_LEFT 0x0 - -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_S 4 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_M 0x70 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_IDAC_NEG_OUT 0x7 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_CT_FILTER_POS_OUT 0x6 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_CT_FILTER_IBIAS 0x5 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_NO_CONNECT_1 0x4 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_NO_CONNECT_2 0x3 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_NO_CONNECT_3 0x2 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_NO_CONNECT_4 0x1 -#define TIMPANI_ATEST_IDAC_ATEST1_CONN_NO_CONNECT_5 0x0 - -#define TIMPANI_ATEST_IDAC_ATEST2_LR_CONN_S 3 -#define TIMPANI_ATEST_IDAC_ATEST2_LR_CONN_M 0x8 -#define TIMPANI_ATEST_IDAC_ATEST2_LR_CONN_RIGHT 0x1 -#define TIMPANI_ATEST_IDAC_ATEST2_LR_CONN_LEFT 0x0 - -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_S 0 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_M 0x7 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_IDAC_POS_OUT 0x7 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_CT_FILTER_NEG_OUT 0x6 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_IDAC_IBIAS 0x5 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_NO_CONNECT_1 0x4 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_NO_CONNECT_2 0x3 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_NO_CONNECT_3 0x2 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_NO_CONNECT_4 0x1 -#define TIMPANI_ATEST_IDAC_ATEST2_CONN_NO_CONNECT_5 0x0 - - -/* -- For ATEST_PA1 */ -#define TIMPANI_A_ATEST_PA1 (0x5A) -#define TIMPANI_ATEST_PA1_RWC "RW" -#define TIMPANI_ATEST_PA1_POR 0 -#define TIMPANI_ATEST_PA1_S 0 -#define TIMPANI_ATEST_PA1_M 0xFF - - -#define TIMPANI_ATEST_PA1_ATEST_EARPA_FSV_NP_CONN_S 7 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_FSV_NP_CONN_M 0x80 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_FSV_NP_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_FSV_NP_CONN_EN 0x1 - -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NCASC_NMIRR_CONN_S 6 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NCASC_NMIRR_CONN_M 0x40 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NCASC_NMIRR_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NCASC_NMIRR_CONN_EN 0x1 - -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NMIRR_PCASC_CONN_S 5 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NMIRR_PCASC_CONN_M 0x20 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NMIRR_PCASC_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_NMIRR_PCASC_CONN_EN 0x1 - -#define TIMPANI_ATEST_PA1_ATEST_EARPA_VCM_PTAIL1_CONN_S 4 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_VCM_PTAIL1_CONN_M 0x10 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_VCM_PTAIL1_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_VCM_PTAIL1_CONN_EN 0x1 - -#define TIMPANI_ATEST_PA1_ATEST_EARPA_IBTEST_VSS2P2_CONN_S 3 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_IBTEST_VSS2P2_CONN_M 0x8 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_IBTEST_VSS2P2_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_IBTEST_VSS2P2_CONN_EN 0x1 - -#define TIMPANI_ATEST_PA1_ATEST_EARPA_ITEST1_ITEST2_CONN_S 2 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_ITEST1_ITEST2_CONN_M 0x4 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_ITEST1_ITEST2_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_PA1_ATEST_EARPA_ITEST1_ITEST2_CONN_EN 0x1 - -#define TIMPANI_ATEST_PA1_ATEST_CLASSD_CLK_GATING_S 1 -#define TIMPANI_ATEST_PA1_ATEST_CLASSD_CLK_GATING_M 0x2 -#define TIMPANI_ATEST_PA1_ATEST_CLASSD_CLK_GATING_PASS 0x0 -#define TIMPANI_ATEST_PA1_ATEST_CLASSD_CLK_GATING_GATE 0x1 - -#define TIMPANI_ATEST_PA1_ATEST2_HPH_VCM_CONN_S 0 -#define TIMPANI_ATEST_PA1_ATEST2_HPH_VCM_CONN_M 0x1 -#define TIMPANI_ATEST_PA1_ATEST2_HPH_VCM_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_PA1_ATEST2_HPH_VCM_CONN_CONNECT 0x1 - - -/* -- For ATEST_CLASSD */ -#define TIMPANI_A_ATEST_CLASSD (0x5B) -#define TIMPANI_ATEST_CLASSD_RWC "RW" -#define TIMPANI_ATEST_CLASSD_POR 0 -#define TIMPANI_ATEST_CLASSD_S 0 -#define TIMPANI_ATEST_CLASSD_M 0xFF - - -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_S 4 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_M 0xF0 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_NO_CONNECT_1 0x0 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_L_SC_OCP 0x1 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_L_CDAC_CLK 0x2 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_L_POS_CDAC 0x3 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_L_BREAK_BEFORE_MAKE_OUT_CP 0x4 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_L_COMP_OUT 0x5 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_L_INT2_POS_OUT 0x6 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_L_INT1_POS_OUT 0x7 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_NO_CONNECT_2 0x8 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_R_SC_OCP_SIGNAL 0x9 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_R_CDAC_CLK 0xA -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_R_POS_CDAC 0xB -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_R_BREAK_BEFORE_MAKE_OUT_CP 0xC -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_R_COMP_OUT 0xD -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_R_INT2_POS_OUT 0xE -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST1_CONN_R_INT1_POS_OUT 0xF - -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_S 0 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_M 0xF -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_NO_CONNECT_1 0x0 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_L_HI_Z_OCP 0x1 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_L_OCP_CLOCK 0x2 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_L_NEG_CDAC 0x3 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_L_BREAK_BEFORE_MAKE_OUT_CN 0x4 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_L_CM_BUFF_OUT 0x5 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_L_INT2_NEG_OUT 0x6 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_L_INT1_NEG_OUT 0x7 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_NO_CONNECT_2 0x8 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_R_HI_Z_OCP 0x9 -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_R_OCP_CLOCK 0xA -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_R_NEGATIVE_CDAC 0xB -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_R_BREAK_BEFORE_MAKE_OUT_CN 0xC -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_R_CM_BUFF_OUT 0xD -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_R_INTR2_NEG_OUT 0xE -#define TIMPANI_ATEST_CLASSD_CLASSD_ATEST2_CONN_R_INT1_NEG_OUT 0xF - - -/* -- For ATEST_LINEO_AUXO */ -#define TIMPANI_A_ATEST_LINEO_AUXO (0x5C) -#define TIMPANI_ATEST_LINEO_AUXO_RWC "RW" -#define TIMPANI_ATEST_LINEO_AUXO_POR 0 -#define TIMPANI_ATEST_LINEO_AUXO_S 0 -#define TIMPANI_ATEST_LINEO_AUXO_M 0xFF - - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_EN_S 7 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_EN_M 0x80 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_EN_DISABLE 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_EN_ENABLE 0x1 - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_VCM_CONN_S 6 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_VCM_CONN_M 0x40 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_VCM_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_AUXO_VCM_CONN_CONNECT 0x1 - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NREFIN_STG1OP_CONN_S 5 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NREFIN_STG1OP_CONN_M 0x20 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NREFIN_STG1OP_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NREFIN_STG1OP_CONN_EN 0x1 - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NMOS_PMOS_CONN_S 4 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NMOS_PMOS_CONN_M 0x10 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NMOS_PMOS_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_L_NMOS_PMOS_CONN_EN 01 - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NREFIN_STG1OP_CONN_S 3 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NREFIN_STG1OP_CONN_M 0x8 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NREFIN_STG1OP_CONN_NO_CONNECT 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NREFIN_STG1OP_CONN_EN 01 - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NMOS_PMOS_CONN_S 2 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NMOS_PMOS_CONN_M 0x4 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NMOS_PMOS_CONN_DISABLE 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_LINEO_R_NMOS_PMOS_CONN_EN 0x1 - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NREFIN_STG1OP_CONN_S 1 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NREFIN_STG1OP_CONN_M 0x2 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NREFIN_STG1OP_CONN_DISABLE 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NREFIN_STG1OP_CONN_EN 0x1 - -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NMOS_PMOS_CONN_S 0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NMOS_PMOS_CONN_M 0x1 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NMOS_PMOS_CONN_DISABLE 0x0 -#define TIMPANI_ATEST_LINEO_AUXO_ATEST_AUXO_NMOS_PMOS_CONN_EN 0x1 - - -/* -- For CDC_RESET_CTL */ -#define TIMPANI_A_CDC_RESET_CTL (0x80) -#define TIMPANI_CDC_RESET_CTL_RWC "RW" -#define TIMPANI_CDC_RESET_CTL_POR 0 -#define TIMPANI_CDC_RESET_CTL_S 0 -#define TIMPANI_CDC_RESET_CTL_M 0x7F - - -#define TIMPANI_CDC_RESET_CTL_ARB_SOFT_RESET_S 6 -#define TIMPANI_CDC_RESET_CTL_ARB_SOFT_RESET_M 0x40 - -#define TIMPANI_CDC_RESET_CTL_TX2_SOFT_RESET_R_S 5 -#define TIMPANI_CDC_RESET_CTL_TX2_SOFT_RESET_R_M 0x20 - -#define TIMPANI_CDC_RESET_CTL_TX2_SOFT_RESET_L_S 4 -#define TIMPANI_CDC_RESET_CTL_TX2_SOFT_RESET_L_M 0x10 - -#define TIMPANI_CDC_RESET_CTL_RX2_SOFT_RESET_S 3 -#define TIMPANI_CDC_RESET_CTL_RX2_SOFT_RESET_M 0x8 - -#define TIMPANI_CDC_RESET_CTL_TX1_SOFT_RESET_R_S 2 -#define TIMPANI_CDC_RESET_CTL_TX1_SOFT_RESET_R_M 0x4 - -#define TIMPANI_CDC_RESET_CTL_RX1_SOFT_RESET_S 1 -#define TIMPANI_CDC_RESET_CTL_RX1_SOFT_RESET_M 0x2 - -#define TIMPANI_CDC_RESET_CTL_TX1_SOFT_RESET_L_S 0 -#define TIMPANI_CDC_RESET_CTL_TX1_SOFT_RESET_L_M 0x1 - - -/* -- For CDC_RX1_CTL */ -#define TIMPANI_A_CDC_RX1_CTL (0x81) -#define TIMPANI_CDC_RX1_CTL_RWC "RW" -#define TIMPANI_CDC_RX1_CTL_POR 0xc -#define TIMPANI_CDC_RX1_CTL_S 0 -#define TIMPANI_CDC_RX1_CTL_M 0x3F - - -#define TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_R_S 5 -#define TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_R_M 0x20 - -#define TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_L_S 4 -#define TIMPANI_CDC_RX1_CTL_SIDETONE_EN1_L_M 0x10 - -#define TIMPANI_CDC_RX1_CTL_RX1_RATE_S 2 -#define TIMPANI_CDC_RX1_CTL_RX1_RATE_M 0xC -#define TIMPANI_CDC_RX1_CTL_RX1_RATE_OSR_256 0x3 -#define TIMPANI_CDC_RX1_CTL_RX1_RATE_OSR_128 0x1 -#define TIMPANI_CDC_RX1_CTL_RX1_RATE_OSR_64 0x0 - -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_RATE_S 1 -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_RATE_M 0x2 -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_RATE_BR_32 0x1 -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_RATE_BR_64 0x0 - -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_MODE_S 0 -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_MODE_M 0x1 -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_MODE_MASTER 0x1 -#define TIMPANI_CDC_RX1_CTL_RX1_I2S_MODE_SLAVE 0x0 - - -/* -- For CDC_TX_I2S_CTL */ -#define TIMPANI_A_CDC_TX_I2S_CTL (0x82) -#define TIMPANI_CDC_TX_I2S_CTL_RWC "RW" -#define TIMPANI_CDC_TX_I2S_CTL_POR 0xc -#define TIMPANI_CDC_TX_I2S_CTL_S 0 -#define TIMPANI_CDC_TX_I2S_CTL_M 0x3F - - -#define TIMPANI_CDC_TX_I2S_CTL_TX2_I2S_SD_OE_S 5 -#define TIMPANI_CDC_TX_I2S_CTL_TX2_I2S_SD_OE_M 0x20 - -#define TIMPANI_CDC_TX_I2S_CTL_TX1_I2S_SD_OE_S 4 -#define TIMPANI_CDC_TX_I2S_CTL_TX1_I2S_SD_OE_M 0x10 - -#define TIMPANI_CDC_TX_I2S_CTL_TX_RATE_S 2 -#define TIMPANI_CDC_TX_I2S_CTL_TX_RATE_M 0xC -#define TIMPANI_CDC_TX_I2S_CTL_TX_RATE_OSR_256 0x3 -#define TIMPANI_CDC_TX_I2S_CTL_TX_RATE_OSR_128 0x1 -#define TIMPANI_CDC_TX_I2S_CTL_TX_RATE_OSR_64 0x0 - -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_RATE_S 1 -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_RATE_M 0x2 -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_RATE_BR_32 0x1 -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_RATE_BR_64 0x0 - -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_MODE_S 0 -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_MODE_M 0x1 -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_MODE_MASTER 0x1 -#define TIMPANI_CDC_TX_I2S_CTL_TX_I2S_MODE_SLAVE 0x0 - - -/* -- For CDC_CH_CTL */ -#define TIMPANI_A_CDC_CH_CTL (0x83) -#define TIMPANI_CDC_CH_CTL_RWC "RW" -#define TIMPANI_CDC_CH_CTL_POR 0 -#define TIMPANI_CDC_CH_CTL_S 0 -#define TIMPANI_CDC_CH_CTL_M 0xFF - - -#define TIMPANI_CDC_CH_CTL_TX2_EN_R_S 7 -#define TIMPANI_CDC_CH_CTL_TX2_EN_R_M 0x80 - -#define TIMPANI_CDC_CH_CTL_TX2_EN_L_S 6 -#define TIMPANI_CDC_CH_CTL_TX2_EN_L_M 0x40 - -#define TIMPANI_CDC_CH_CTL_RX2_EN_R_S 5 -#define TIMPANI_CDC_CH_CTL_RX2_EN_R_M 0x20 - -#define TIMPANI_CDC_CH_CTL_RX2_EN_L_S 4 -#define TIMPANI_CDC_CH_CTL_RX2_EN_L_M 0x10 - -#define TIMPANI_CDC_CH_CTL_TX1_EN_R_S 3 -#define TIMPANI_CDC_CH_CTL_TX1_EN_R_M 0x8 - -#define TIMPANI_CDC_CH_CTL_TX1_EN_L_S 2 -#define TIMPANI_CDC_CH_CTL_TX1_EN_L_M 0x4 - -#define TIMPANI_CDC_CH_CTL_RX1_EN_R_S 1 -#define TIMPANI_CDC_CH_CTL_RX1_EN_R_M 0x2 - -#define TIMPANI_CDC_CH_CTL_RX1_EN_L_S 0 -#define TIMPANI_CDC_CH_CTL_RX1_EN_L_M 0x1 - - -/* -- For CDC_RX1LG */ -#define TIMPANI_A_CDC_RX1LG (0x84) -#define TIMPANI_CDC_RX1LG_RWC "RW" -#define TIMPANI_CDC_RX1LG_POR 0xac -#define TIMPANI_CDC_RX1LG_S 0 -#define TIMPANI_CDC_RX1LG_M 0xFF - - -#define TIMPANI_CDC_RX1LG_GAIN_S 0 -#define TIMPANI_CDC_RX1LG_GAIN_M 0xFF - - -/* -- For CDC_RX1RG */ -#define TIMPANI_A_CDC_RX1RG (0x85) -#define TIMPANI_CDC_RX1RG_RWC "RW" -#define TIMPANI_CDC_RX1RG_POR 0xac -#define TIMPANI_CDC_RX1RG_S 0 -#define TIMPANI_CDC_RX1RG_M 0xFF - - -#define TIMPANI_CDC_RX1RG_GAIN_S 0 -#define TIMPANI_CDC_RX1RG_GAIN_M 0xFF - - -/* -- For CDC_TX1LG */ -#define TIMPANI_A_CDC_TX1LG (0x86) -#define TIMPANI_CDC_TX1LG_RWC "RW" -#define TIMPANI_CDC_TX1LG_POR 0xac -#define TIMPANI_CDC_TX1LG_S 0 -#define TIMPANI_CDC_TX1LG_M 0xFF - - -#define TIMPANI_CDC_TX1LG_GAIN_S 0 -#define TIMPANI_CDC_TX1LG_GAIN_M 0xFF - - -/* -- For CDC_TX1RG */ -#define TIMPANI_A_CDC_TX1RG (0x87) -#define TIMPANI_CDC_TX1RG_RWC "RW" -#define TIMPANI_CDC_TX1RG_POR 0xac -#define TIMPANI_CDC_TX1RG_S 0 -#define TIMPANI_CDC_TX1RG_M 0xFF - - -#define TIMPANI_CDC_TX1RG_GAIN_S 0 -#define TIMPANI_CDC_TX1RG_GAIN_M 0xFF - - -/* -- For CDC_RX_PGA_TIMER */ -#define TIMPANI_A_CDC_RX_PGA_TIMER (0x88) -#define TIMPANI_CDC_RX_PGA_TIMER_RWC "RW" -#define TIMPANI_CDC_RX_PGA_TIMER_POR 0xff -#define TIMPANI_CDC_RX_PGA_TIMER_S 0 -#define TIMPANI_CDC_RX_PGA_TIMER_M 0xFF - - -#define TIMPANI_CDC_RX_PGA_TIMER_TIMER_VAL_S 0 -#define TIMPANI_CDC_RX_PGA_TIMER_TIMER_VAL_M 0xFF - - -/* -- For CDC_TX_PGA_TIMER */ -#define TIMPANI_A_CDC_TX_PGA_TIMER (0x89) -#define TIMPANI_CDC_TX_PGA_TIMER_RWC "RW" -#define TIMPANI_CDC_TX_PGA_TIMER_POR 0xff -#define TIMPANI_CDC_TX_PGA_TIMER_S 0 -#define TIMPANI_CDC_TX_PGA_TIMER_M 0xFF - - -#define TIMPANI_CDC_TX_PGA_TIMER_TIMER_VAL_S 0 -#define TIMPANI_CDC_TX_PGA_TIMER_TIMER_VAL_M 0xFF - - -/* -- For CDC_GCTL1 */ -#define TIMPANI_A_CDC_GCTL1 (0x8A) -#define TIMPANI_CDC_GCTL1_RWC "RW" -#define TIMPANI_CDC_GCTL1_POR 0x33 -#define TIMPANI_CDC_GCTL1_S 0 -#define TIMPANI_CDC_GCTL1_M 0xFF - - -#define TIMPANI_CDC_GCTL1_TX1_PGA_UPDATE_R_S 7 -#define TIMPANI_CDC_GCTL1_TX1_PGA_UPDATE_R_M 0x80 - -#define TIMPANI_CDC_GCTL1_TX1_PGA_UPDATE_L_S 6 -#define TIMPANI_CDC_GCTL1_TX1_PGA_UPDATE_L_M 0x40 - -#define TIMPANI_CDC_GCTL1_TX1_PGA_MUTE_EN_R_S 5 -#define TIMPANI_CDC_GCTL1_TX1_PGA_MUTE_EN_R_M 0x20 - -#define TIMPANI_CDC_GCTL1_TX1_PGA_MUTE_EN_L_S 4 -#define TIMPANI_CDC_GCTL1_TX1_PGA_MUTE_EN_L_M 0x10 - -#define TIMPANI_CDC_GCTL1_RX1_PGA_UPDATE_R_S 3 -#define TIMPANI_CDC_GCTL1_RX1_PGA_UPDATE_R_M 0x8 - -#define TIMPANI_CDC_GCTL1_RX1_PGA_UPDATE_L_S 2 -#define TIMPANI_CDC_GCTL1_RX1_PGA_UPDATE_L_M 0x4 - -#define TIMPANI_CDC_GCTL1_RX1_PGA_MUTE_EN_R_S 1 -#define TIMPANI_CDC_GCTL1_RX1_PGA_MUTE_EN_R_M 0x2 - -#define TIMPANI_CDC_GCTL1_RX1_PGA_MUTE_EN_L_S 0 -#define TIMPANI_CDC_GCTL1_RX1_PGA_MUTE_EN_L_M 0x1 - - -/* -- For CDC_TX1L_STG */ -#define TIMPANI_A_CDC_TX1L_STG (0x8B) -#define TIMPANI_CDC_TX1L_STG_RWC "RW" -#define TIMPANI_CDC_TX1L_STG_POR 0xac -#define TIMPANI_CDC_TX1L_STG_S 0 -#define TIMPANI_CDC_TX1L_STG_M 0xFF - - -#define TIMPANI_CDC_TX1L_STG_GAIN_S 0 -#define TIMPANI_CDC_TX1L_STG_GAIN_M 0xFF - - -/* -- For CDC_ST_CTL */ -#define TIMPANI_A_CDC_ST_CTL (0x8C) -#define TIMPANI_CDC_ST_CTL_RWC "RW" -#define TIMPANI_CDC_ST_CTL_POR 0x55 -#define TIMPANI_CDC_ST_CTL_S 0 -#define TIMPANI_CDC_ST_CTL_M 0xFF - - -#define TIMPANI_CDC_ST_CTL_TX2_R_SIDETONE_UPDATE_S 7 -#define TIMPANI_CDC_ST_CTL_TX2_R_SIDETONE_UPDATE_M 0x80 - -#define TIMPANI_CDC_ST_CTL_TX2_R_SIDETONE_MUTE_EN_S 6 -#define TIMPANI_CDC_ST_CTL_TX2_R_SIDETONE_MUTE_EN_M 0x40 - -#define TIMPANI_CDC_ST_CTL_TX2_L_SIDETONE_UPDATE_S 5 -#define TIMPANI_CDC_ST_CTL_TX2_L_SIDETONE_UPDATE_M 0x20 - -#define TIMPANI_CDC_ST_CTL_TX2_L_SIDETONE_MUTE_EN_S 4 -#define TIMPANI_CDC_ST_CTL_TX2_L_SIDETONE_MUTE_EN_M 0x10 - -#define TIMPANI_CDC_ST_CTL_TX1_R_SIDETONE_UPDATE_S 3 -#define TIMPANI_CDC_ST_CTL_TX1_R_SIDETONE_UPDATE_M 0x8 - -#define TIMPANI_CDC_ST_CTL_TX1_R_SIDETONE_MUTE_EN_S 2 -#define TIMPANI_CDC_ST_CTL_TX1_R_SIDETONE_MUTE_EN_M 0x4 - -#define TIMPANI_CDC_ST_CTL_TX1_L_SIDETONE_UPDATE_S 1 -#define TIMPANI_CDC_ST_CTL_TX1_L_SIDETONE_UPDATE_M 0x2 - -#define TIMPANI_CDC_ST_CTL_TX1_L_SIDETONE_MUTE_EN_S 0 -#define TIMPANI_CDC_ST_CTL_TX1_L_SIDETONE_MUTE_EN_M 0x1 - - -/* -- For CDC_RX1L_DCOFFSET */ -#define TIMPANI_A_CDC_RX1L_DCOFFSET (0x8D) -#define TIMPANI_CDC_RX1L_DCOFFSET_RWC "RW" -#define TIMPANI_CDC_RX1L_DCOFFSET_POR 0 -#define TIMPANI_CDC_RX1L_DCOFFSET_S 0 -#define TIMPANI_CDC_RX1L_DCOFFSET_M 0xFF - - -#define TIMPANI_CDC_RX1L_DCOFFSET_OFFSET_S 0 -#define TIMPANI_CDC_RX1L_DCOFFSET_OFFSET_M 0xFF - - -/* -- For CDC_RX1R_DCOFFSET */ -#define TIMPANI_A_CDC_RX1R_DCOFFSET (0x8E) -#define TIMPANI_CDC_RX1R_DCOFFSET_RWC "RW" -#define TIMPANI_CDC_RX1R_DCOFFSET_POR 0 -#define TIMPANI_CDC_RX1R_DCOFFSET_S 0 -#define TIMPANI_CDC_RX1R_DCOFFSET_M 0xFF - - -#define TIMPANI_CDC_RX1R_DCOFFSET_OFFSET_S 0 -#define TIMPANI_CDC_RX1R_DCOFFSET_OFFSET_M 0xFF - - -/* -- For CDC_BYPASS_CTL1 */ -#define TIMPANI_A_CDC_BYPASS_CTL1 (0x8F) -#define TIMPANI_CDC_BYPASS_CTL1_RWC "RW" -#define TIMPANI_CDC_BYPASS_CTL1_POR 0x2 -#define TIMPANI_CDC_BYPASS_CTL1_S 0 -#define TIMPANI_CDC_BYPASS_CTL1_M 0xF - - -#define TIMPANI_CDC_BYPASS_CTL1_DITHER_BP_S 3 -#define TIMPANI_CDC_BYPASS_CTL1_DITHER_BP_M 0x8 - -#define TIMPANI_CDC_BYPASS_CTL1_DITHER_SHAPE_SEL_S 2 -#define TIMPANI_CDC_BYPASS_CTL1_DITHER_SHAPE_SEL_M 0x4 - -#define TIMPANI_CDC_BYPASS_CTL1_DITHER_DLY_SEL_S 1 -#define TIMPANI_CDC_BYPASS_CTL1_DITHER_DLY_SEL_M 0x2 - -#define TIMPANI_CDC_BYPASS_CTL1_RX1_HPF_BP_S 0 -#define TIMPANI_CDC_BYPASS_CTL1_RX1_HPF_BP_M 0x1 - - -/* -- For CDC_PDM_CONFIG */ -#define TIMPANI_A_CDC_PDM_CONFIG (0x90) -#define TIMPANI_CDC_PDM_CONFIG_RWC "RW" -#define TIMPANI_CDC_PDM_CONFIG_POR 0 -#define TIMPANI_CDC_PDM_CONFIG_S 0 -#define TIMPANI_CDC_PDM_CONFIG_M 0xF - - -#define TIMPANI_CDC_PDM_CONFIG_PDM_SEL_S 0 -#define TIMPANI_CDC_PDM_CONFIG_PDM_SEL_M 0xF - - -/* -- For CDC_TESTMODE1 */ -#define TIMPANI_A_CDC_TESTMODE1 (0x91) -#define TIMPANI_CDC_TESTMODE1_RWC "RW" -#define TIMPANI_CDC_TESTMODE1_POR 0 -#define TIMPANI_CDC_TESTMODE1_S 0 -#define TIMPANI_CDC_TESTMODE1_M 0x3F - - -#define TIMPANI_CDC_TESTMODE1_COMP_I2C_TEST_EN_S 5 -#define TIMPANI_CDC_TESTMODE1_COMP_I2C_TEST_EN_M 0x20 - -#define TIMPANI_CDC_TESTMODE1_RX1_TEST_EN_R_S 4 -#define TIMPANI_CDC_TESTMODE1_RX1_TEST_EN_R_M 0x10 - -#define TIMPANI_CDC_TESTMODE1_RX1_TEST_EN_L_S 3 -#define TIMPANI_CDC_TESTMODE1_RX1_TEST_EN_L_M 0x8 - -#define TIMPANI_CDC_TESTMODE1_TX1_TEST_EN_R_S 2 -#define TIMPANI_CDC_TESTMODE1_TX1_TEST_EN_R_M 0x4 - -#define TIMPANI_CDC_TESTMODE1_TX1_TEST_EN_L_S 1 -#define TIMPANI_CDC_TESTMODE1_TX1_TEST_EN_L_M 0x2 - -#define TIMPANI_CDC_TESTMODE1_A_LOOPBACK_EN1_S 0 -#define TIMPANI_CDC_TESTMODE1_A_LOOPBACK_EN1_M 0x1 - - -/* -- For CDC_DMIC_CLK_CTL */ -#define TIMPANI_A_CDC_DMIC_CLK_CTL (0x92) -#define TIMPANI_CDC_DMIC_CLK_CTL_RWC "RW" -#define TIMPANI_CDC_DMIC_CLK_CTL_POR 0 -#define TIMPANI_CDC_DMIC_CLK_CTL_S 0 -#define TIMPANI_CDC_DMIC_CLK_CTL_M 0x3F - - -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_DIV_SEL_S 3 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_DIV_SEL_M 0x38 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_DIV_SEL_DIV_6 0x4 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_DIV_SEL_DIV_4 0x3 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_DIV_SEL_DIV_3 0x2 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_DIV_SEL_DIV_2 0x1 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_DIV_SEL_DIV_1 0x0 - -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_SEL_S 1 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_SEL_M 0x6 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_SEL_RX_MCLK2 0x2 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_SEL_RX_MCLK1 0x1 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_MCLK_SEL_TX_MCLK 0x0 - -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_CLK_EN_S 0 -#define TIMPANI_CDC_DMIC_CLK_CTL_DMIC_CLK_EN_M 0x1 - - -/* -- For CDC_ADC12_CLK_CTL */ -#define TIMPANI_A_CDC_ADC12_CLK_CTL (0x93) -#define TIMPANI_CDC_ADC12_CLK_CTL_RWC "RW" -#define TIMPANI_CDC_ADC12_CLK_CTL_POR 0 -#define TIMPANI_CDC_ADC12_CLK_CTL_S 0 -#define TIMPANI_CDC_ADC12_CLK_CTL_M 0xFF - - -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_SEL_S 6 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_SEL_M 0xC0 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_SEL_RX_MCLK2 0x2 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_SEL_RX_MCLK1 0x1 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_SEL_TX_MCLK 0x0 - -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_R_S 3 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_R_M 0x38 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_R_DIV_6 0x4 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_R_DIV_4 0x3 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_R_DIV_3 0x2 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_R_DIV_2 0x1 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_R_DIV_1 0x0 - -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_L_S 0 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_L_M 0x7 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_L_DIV_6 0x4 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_L_DIV_4 0x3 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_L_DIV_3 0x2 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_L_DIV_2 0x1 -#define TIMPANI_CDC_ADC12_CLK_CTL_TX1_MCLK_DIV_SEL_L_DIV_1 0x0 - - -/* -- For CDC_TX1_CTL */ -#define TIMPANI_A_CDC_TX1_CTL (0x94) -#define TIMPANI_CDC_TX1_CTL_RWC "RW" -#define TIMPANI_CDC_TX1_CTL_POR 0x1b -#define TIMPANI_CDC_TX1_CTL_S 0 -#define TIMPANI_CDC_TX1_CTL_M 0x3F - - -#define TIMPANI_CDC_TX1_CTL_TX1_DMIC_SEL_R_S 5 -#define TIMPANI_CDC_TX1_CTL_TX1_DMIC_SEL_R_M 0x20 - -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_R_S 3 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_R_M 0x18 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_R_OSR_256 0x3 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_R_OSR_128 0x1 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_R_OSR_64 0x0 - -#define TIMPANI_CDC_TX1_CTL_TX1_DMIC_SEL_L_S 2 -#define TIMPANI_CDC_TX1_CTL_TX1_DMIC_SEL_L_M 0x4 - -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_L_S 0 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_L_M 0x3 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_L_OSR_256 0x3 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_L_OSR_128 0x1 -#define TIMPANI_CDC_TX1_CTL_TX1_RATE_L_OSR_64 0x0 - - -/* -- For CDC_ADC34_CLK_CTL */ -#define TIMPANI_A_CDC_ADC34_CLK_CTL (0x95) -#define TIMPANI_CDC_ADC34_CLK_CTL_RWC "RW" -#define TIMPANI_CDC_ADC34_CLK_CTL_POR 0 -#define TIMPANI_CDC_ADC34_CLK_CTL_S 0 -#define TIMPANI_CDC_ADC34_CLK_CTL_M 0xFF - - -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_SEL_S 6 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_SEL_M 0xC0 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_SEL_RX_MCLK2 0x2 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_SEL_RX_MCLK1 0x1 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_SEL_TX_MCLK 0x0 - -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_R_S 3 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_R_M 0x38 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_R_DIV_6 0x4 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_R_DIV_4 0x3 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_R_DIV_3 0x2 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_R_DIV_2 0x1 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_R_DIV_1 0x0 - -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_L_S 0 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_L_M 0x7 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_L_DIV_6 0x4 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_L_DIV_4 0x3 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_L_DIV_3 0x2 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_L_DIV_2 0x1 -#define TIMPANI_CDC_ADC34_CLK_CTL_TX2_MCLK_DIV_SEL_L_DIV_1 0x0 - - -/* -- For CDC_TX2_CTL */ -#define TIMPANI_A_CDC_TX2_CTL (0x96) -#define TIMPANI_CDC_TX2_CTL_RWC "RW" -#define TIMPANI_CDC_TX2_CTL_POR 0x1b -#define TIMPANI_CDC_TX2_CTL_S 0 -#define TIMPANI_CDC_TX2_CTL_M 0x3F - - -#define TIMPANI_CDC_TX2_CTL_TX2_DMIC_SEL_R_S 5 -#define TIMPANI_CDC_TX2_CTL_TX2_DMIC_SEL_R_M 0x20 - -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_R_S 3 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_R_M 0x18 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_R_OSR_256 0x3 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_R_OSR_128 0x1 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_R_OSR_64 0x0 - -#define TIMPANI_CDC_TX2_CTL_TX2_DMIC_SEL_L_S 2 -#define TIMPANI_CDC_TX2_CTL_TX2_DMIC_SEL_L_M 0x4 - -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_L_S 0 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_L_M 0x3 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_L_OSR_256 0x3 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_L_OSR_128 0x1 -#define TIMPANI_CDC_TX2_CTL_TX2_RATE_L_OSR_64 0x0 - - -/* -- For CDC_RX1_CLK_CTL */ -#define TIMPANI_A_CDC_RX1_CLK_CTL (0x97) -#define TIMPANI_CDC_RX1_CLK_CTL_RWC "RW" -#define TIMPANI_CDC_RX1_CLK_CTL_POR 0x1 -#define TIMPANI_CDC_RX1_CLK_CTL_S 0 -#define TIMPANI_CDC_RX1_CLK_CTL_M 0x1F - - -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_DIV_SEL_S 2 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_DIV_SEL_M 0x1C -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_DIV_SEL_DIV_6 0x4 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_DIV_SEL_DIV_4 0x3 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_DIV_SEL_DIV_3 0x2 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_DIV_SEL_DIV_2 0x1 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_DIV_SEL_DIV_1 0x0 - -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_SEL_S 0 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_SEL_M 0x3 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_SEL_RX_MCLK2 0x2 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_SEL_RX_MCLK1 0x1 -#define TIMPANI_CDC_RX1_CLK_CTL_RX1_MCLK_SEL_TX_MCLK 0x0 - - -/* -- For CDC_RX2_CLK_CTL */ -#define TIMPANI_A_CDC_RX2_CLK_CTL (0x98) -#define TIMPANI_CDC_RX2_CLK_CTL_RWC "RW" -#define TIMPANI_CDC_RX2_CLK_CTL_POR 0x2 -#define TIMPANI_CDC_RX2_CLK_CTL_S 0 -#define TIMPANI_CDC_RX2_CLK_CTL_M 0x1F - - -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_DIV_SEL_S 2 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_DIV_SEL_M 0x1C -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_DIV_SEL_DIV_6 0x4 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_DIV_SEL_DIV_4 0x3 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_DIV_SEL_DIV_3 0x2 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_DIV_SEL_DIV_2 0x1 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_DIV_SEL_DIV_1 0x0 - -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_SEL_S 0 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_SEL_M 0x3 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_SEL_RX_MCLK2 0x2 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_SEL_RX_MCLK1 0x1 -#define TIMPANI_CDC_RX2_CLK_CTL_RX2_MCLK_SEL_TX_MCLK 0x0 - - -/* -- For CDC_DEC_ADC_SEL */ -#define TIMPANI_A_CDC_DEC_ADC_SEL (0x99) -#define TIMPANI_CDC_DEC_ADC_SEL_RWC "RW" -#define TIMPANI_CDC_DEC_ADC_SEL_POR 0 -#define TIMPANI_CDC_DEC_ADC_SEL_S 0 -#define TIMPANI_CDC_DEC_ADC_SEL_M 0xFF - - -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_R_S 6 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_R_M 0xC0 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_R_ADC4 0x3 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_R_ADC3 0x2 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_R_ADC2 0x1 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_R_ADC1 0x0 - -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_L_S 4 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_L_M 0x30 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_L_ADC4 0x3 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_L_ADC3 0x2 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_L_ADC2 0x1 -#define TIMPANI_CDC_DEC_ADC_SEL_TX2_ADC_SEL_L_ADC1 0x0 - -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_R_S 2 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_R_M 0xC -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_R_ADC4 0x3 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_R_ADC3 0x2 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_R_ADC2 0x1 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_R_ADC1 0x0 - -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_L_S 0 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_L_M 0x3 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_L_ADC4 0x3 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_L_ADC3 0x2 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_L_ADC2 0x1 -#define TIMPANI_CDC_DEC_ADC_SEL_TX1_ADC_SEL_L_ADC1 0x0 - - -/* -- For CDC_ANC_INPUT_MUX */ -#define TIMPANI_A_CDC_ANC_INPUT_MUX (0x9A) -#define TIMPANI_CDC_ANC_INPUT_MUX_RWC "RW" -#define TIMPANI_CDC_ANC_INPUT_MUX_POR 0 -#define TIMPANI_CDC_ANC_INPUT_MUX_S 0 -#define TIMPANI_CDC_ANC_INPUT_MUX_M 0xFF - - -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_ADC_SEL_S 6 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_ADC_SEL_M 0xC0 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_ADC_SEL_A_CDC_TX2DOR 0x3 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_ADC_SEL_A_CDC_TX2DOL 0x2 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_ADC_SEL_A_CDC_TX1DOR 0x1 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_ADC_SEL_A_CDC_TX1DOL 0x0 - -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_DMIC_SEL_S 4 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_DMIC_SEL_M 0x30 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_DMIC_SEL_MIC2_DIN_R 0x3 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_DMIC_SEL_MIC2_DIN_L 0x2 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_DMIC_SEL_MIC1_DIN_R 0x1 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC2_DMIC_SEL_MIC1_DIN_L 0x0 - -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_ADC_SEL_S 2 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_ADC_SEL_M 0xC -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_ADC_SEL_A_CDC_TX2DOR 0x3 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_ADC_SEL_A_CDC_TX2DOL 0x2 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_ADC_SEL_A_CDC_TX1DOR 0x1 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_ADC_SEL_A_CDC_TX1DOL 0x0 - -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_DMIC_SEL_S 0 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_DMIC_SEL_M 0x3 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_DMIC_SEL_MIC2_DIN_R 0x3 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_DMIC_SEL_MIC2_DIN_L 0x2 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_DMIC_SEL_MIC1_DIN_R 0x1 -#define TIMPANI_CDC_ANC_INPUT_MUX_ANC1_DMIC_SEL_MIC1_DIN_L 0x0 - - -/* -- For CDC_ANC_RX_CLK_NS_SEL */ -#define TIMPANI_A_CDC_ANC_RX_CLK_NS_SEL (0x9B) -#define TIMPANI_CDC_ANC_RX_CLK_NS_SEL_RWC "RW" -#define TIMPANI_CDC_ANC_RX_CLK_NS_SEL_POR 0 -#define TIMPANI_CDC_ANC_RX_CLK_NS_SEL_S 0 -#define TIMPANI_CDC_ANC_RX_CLK_NS_SEL_M 0x1 - - -#define TIMPANI_CDC_ANC_RX_CLK_NS_SEL_ANC_RX_CLK_NS_SEL_S 0 -#define TIMPANI_CDC_ANC_RX_CLK_NS_SEL_ANC_RX_CLK_NS_SEL_M 0x1 - - -/* -- For CDC_ANC_FB_TUNE_SEL */ -#define TIMPANI_A_CDC_ANC_FB_TUNE_SEL (0x9C) -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_RWC "RW" -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_POR 0 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_S 0 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_M 0x3 - - -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC2_FB_ADC_SEL_S 1 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC2_FB_ADC_SEL_M 0x2 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC2_FB_ADC_SEL_FB_TUNE_EN 0x1 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC2_FB_ADC_SEL_FB_TUNE_DIS 0x0 - -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC1_FB_ADC_SEL_S 0 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC1_FB_ADC_SEL_M 0x1 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC1_FB_ADC_SEL_FB_TUNE_EN 0x1 -#define TIMPANI_CDC_ANC_FB_TUNE_SEL_ANC1_FB_ADC_SEL_FB_TUNE_DIS 0x0 - - -/* -- For CLK_DIV_SYNC_CTL */ -#define TIMPANI_A_CLK_DIV_SYNC_CTL (0x9E) -#define TIMPANI_CLK_DIV_SYNC_CTL_RWC "RW" -#define TIMPANI_CLK_DIV_SYNC_CTL_POR 0 -#define TIMPANI_CLK_DIV_SYNC_CTL_S 0 -#define TIMPANI_CLK_DIV_SYNC_CTL_M 0x3 - - -#define TIMPANI_CLK_DIV_SYNC_CTL_GLBL_DIV_SYNC_S 1 -#define TIMPANI_CLK_DIV_SYNC_CTL_GLBL_DIV_SYNC_M 0x2 - -#define TIMPANI_CLK_DIV_SYNC_CTL_TX_DIV_SYNC_S 0 -#define TIMPANI_CLK_DIV_SYNC_CTL_TX_DIV_SYNC_M 0x1 - - -/* -- For CDC_ADC_CLK_EN */ -#define TIMPANI_A_CDC_ADC_CLK_EN (0x9F) -#define TIMPANI_CDC_ADC_CLK_EN_RWC "RW" -#define TIMPANI_CDC_ADC_CLK_EN_POR 0 -#define TIMPANI_CDC_ADC_CLK_EN_S 0 -#define TIMPANI_CDC_ADC_CLK_EN_M 0xF - - -#define TIMPANI_CDC_ADC_CLK_EN_A_TX2_R_EN_S 3 -#define TIMPANI_CDC_ADC_CLK_EN_A_TX2_R_EN_M 0x8 - -#define TIMPANI_CDC_ADC_CLK_EN_A_TX2_L_EN_S 2 -#define TIMPANI_CDC_ADC_CLK_EN_A_TX2_L_EN_M 0x4 - -#define TIMPANI_CDC_ADC_CLK_EN_A_TX1_R_EN_S 1 -#define TIMPANI_CDC_ADC_CLK_EN_A_TX1_R_EN_M 0x2 - -#define TIMPANI_CDC_ADC_CLK_EN_A_TX1_L_EN_S 0 -#define TIMPANI_CDC_ADC_CLK_EN_A_TX1_L_EN_M 0x1 - - -/* -- For CDC_ST_MIXING */ -#define TIMPANI_A_CDC_ST_MIXING (0xA0) -#define TIMPANI_CDC_ST_MIXING_RWC "RW" -#define TIMPANI_CDC_ST_MIXING_POR 0 -#define TIMPANI_CDC_ST_MIXING_S 0 -#define TIMPANI_CDC_ST_MIXING_M 0xF - - -#define TIMPANI_CDC_ST_MIXING_TX2_R_S 3 -#define TIMPANI_CDC_ST_MIXING_TX2_R_M 0x8 - -#define TIMPANI_CDC_ST_MIXING_TX2_L_S 2 -#define TIMPANI_CDC_ST_MIXING_TX2_L_M 0x4 - -#define TIMPANI_CDC_ST_MIXING_TX1_R_S 1 -#define TIMPANI_CDC_ST_MIXING_TX1_R_M 0x2 - -#define TIMPANI_CDC_ST_MIXING_TX1_L_S 0 -#define TIMPANI_CDC_ST_MIXING_TX1_L_M 0x1 - - -/* -- For CDC_RX2_CTL */ -#define TIMPANI_A_CDC_RX2_CTL (0xA1) -#define TIMPANI_CDC_RX2_CTL_RWC "RW" -#define TIMPANI_CDC_RX2_CTL_POR 0xc -#define TIMPANI_CDC_RX2_CTL_S 0 -#define TIMPANI_CDC_RX2_CTL_M 0x3F - - -#define TIMPANI_CDC_RX2_CTL_SIDETONE_EN2_R_S 5 -#define TIMPANI_CDC_RX2_CTL_SIDETONE_EN2_R_M 0x20 - -#define TIMPANI_CDC_RX2_CTL_SIDETONE_EN2_L_S 4 -#define TIMPANI_CDC_RX2_CTL_SIDETONE_EN2_L_M 0x10 - -#define TIMPANI_CDC_RX2_CTL_RX2_RATE_S 2 -#define TIMPANI_CDC_RX2_CTL_RX2_RATE_M 0xC -#define TIMPANI_CDC_RX2_CTL_RX2_RATE_OSR_256 0x3 -#define TIMPANI_CDC_RX2_CTL_RX2_RATE_OSR_128 0x1 -#define TIMPANI_CDC_RX2_CTL_RX2_RATE_OSR_64 0x0 - -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_RATE_S 1 -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_RATE_M 0x2 -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_RATE_BR_32 0x1 -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_RATE_BR_64 0x0 - -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_MODE_S 0 -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_MODE_M 0x1 -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_MODE_MASTER 0x1 -#define TIMPANI_CDC_RX2_CTL_RX2_I2S_MODE_SLAVE 0x0 - - -/* -- For CDC_ARB_CLK_EN */ -#define TIMPANI_A_CDC_ARB_CLK_EN (0xA2) -#define TIMPANI_CDC_ARB_CLK_EN_RWC "RW" -#define TIMPANI_CDC_ARB_CLK_EN_POR 0 -#define TIMPANI_CDC_ARB_CLK_EN_S 0 -#define TIMPANI_CDC_ARB_CLK_EN_M 0x1 - - -#define TIMPANI_CDC_ARB_CLK_EN_ARB_CLK_EN_S 0 -#define TIMPANI_CDC_ARB_CLK_EN_ARB_CLK_EN_M 0x1 - - -/* -- For CDC_I2S_CTL2 */ -#define TIMPANI_A_CDC_I2S_CTL2 (0xA3) -#define TIMPANI_CDC_I2S_CTL2_RWC "RW" -#define TIMPANI_CDC_I2S_CTL2_POR 0 -#define TIMPANI_CDC_I2S_CTL2_S 0 -#define TIMPANI_CDC_I2S_CTL2_M 0x3F - - -#define TIMPANI_CDC_I2S_CTL2_TX_I2S_CLK_SEL_S 3 -#define TIMPANI_CDC_I2S_CTL2_TX_I2S_CLK_SEL_M 0x38 -#define TIMPANI_CDC_I2S_CTL2_TX_I2S_CLK_SEL_CLK_DMIC 0x4 -#define TIMPANI_CDC_I2S_CTL2_TX_I2S_CLK_SEL_CLK_TX2_R 0x3 -#define TIMPANI_CDC_I2S_CTL2_TX_I2S_CLK_SEL_CLK_TX2_L 0x2 -#define TIMPANI_CDC_I2S_CTL2_TX_I2S_CLK_SEL_CLK_TX1_R 0x1 -#define TIMPANI_CDC_I2S_CTL2_TX_I2S_CLK_SEL_CLK_TX1_L 0x0 - -#define TIMPANI_CDC_I2S_CTL2_RX2_I2SCLK_EN_S 2 -#define TIMPANI_CDC_I2S_CTL2_RX2_I2SCLK_EN_M 0x4 - -#define TIMPANI_CDC_I2S_CTL2_RX1_I2SCLK_EN_S 1 -#define TIMPANI_CDC_I2S_CTL2_RX1_I2SCLK_EN_M 0x2 - -#define TIMPANI_CDC_I2S_CTL2_TX_I2SCLK_EN_S 0 -#define TIMPANI_CDC_I2S_CTL2_TX_I2SCLK_EN_M 0x1 - - -/* -- For CDC_RX2LG */ -#define TIMPANI_A_CDC_RX2LG (0xA4) -#define TIMPANI_CDC_RX2LG_RWC "RW" -#define TIMPANI_CDC_RX2LG_POR 0xac -#define TIMPANI_CDC_RX2LG_S 0 -#define TIMPANI_CDC_RX2LG_M 0xFF - - -#define TIMPANI_CDC_RX2LG_GAIN_S 0 -#define TIMPANI_CDC_RX2LG_GAIN_M 0xFF - - -/* -- For CDC_RX2RG */ -#define TIMPANI_A_CDC_RX2RG (0xA5) -#define TIMPANI_CDC_RX2RG_RWC "RW" -#define TIMPANI_CDC_RX2RG_POR 0xac -#define TIMPANI_CDC_RX2RG_S 0 -#define TIMPANI_CDC_RX2RG_M 0xFF - - -#define TIMPANI_CDC_RX2RG_GAIN_S 0 -#define TIMPANI_CDC_RX2RG_GAIN_M 0xFF - - -/* -- For CDC_TX2LG */ -#define TIMPANI_A_CDC_TX2LG (0xA6) -#define TIMPANI_CDC_TX2LG_RWC "RW" -#define TIMPANI_CDC_TX2LG_POR 0xac -#define TIMPANI_CDC_TX2LG_S 0 -#define TIMPANI_CDC_TX2LG_M 0xFF - - -#define TIMPANI_CDC_TX2LG_GAIN_S 0 -#define TIMPANI_CDC_TX2LG_GAIN_M 0xFF - - -/* -- For CDC_TX2RG */ -#define TIMPANI_A_CDC_TX2RG (0xA7) -#define TIMPANI_CDC_TX2RG_RWC "RW" -#define TIMPANI_CDC_TX2RG_POR 0xac -#define TIMPANI_CDC_TX2RG_S 0 -#define TIMPANI_CDC_TX2RG_M 0xFF - - -#define TIMPANI_CDC_TX2RG_GAIN_S 0 -#define TIMPANI_CDC_TX2RG_GAIN_M 0xFF - - -/* -- For CDC_DMIC_MUX */ -#define TIMPANI_A_CDC_DMIC_MUX (0xA8) -#define TIMPANI_CDC_DMIC_MUX_RWC "RW" -#define TIMPANI_CDC_DMIC_MUX_POR 0 -#define TIMPANI_CDC_DMIC_MUX_S 0 -#define TIMPANI_CDC_DMIC_MUX_M 0xFF - - -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_R_S 6 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_R_M 0xC0 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_R_MIC2_DIN_R 0x3 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_R_MIC2_DIN_L 0x2 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_R_MIC1_DIN_R 0x1 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_R_MIC1_DIN_L 0x0 - -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_L_S 4 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_L_M 0x30 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_L_MIC2_DIN_R 0x3 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_L_MIC2_DIN_L 0x2 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_L_MIC1_DIN_R 0x1 -#define TIMPANI_CDC_DMIC_MUX_TX2_DMIC_MUX_SEL_L_MIC1_DIN_L 0x0 - -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_R_S 2 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_R_M 0xC -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_R_MIC2_DIN_R 0x3 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_R_MIC2_DIN_L 0x2 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_R_MIC1_DIN_R 0x1 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_R_MIC1_DIN_L 0x0 - -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_L_S 0 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_L_M 0x3 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_L_MIC2_DIN_R 0x3 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_L_MIC2_DIN_L 0x2 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_L_MIC1_DIN_R 0x1 -#define TIMPANI_CDC_DMIC_MUX_TX1_DMIC_MUX_SEL_L_MIC1_DIN_L 0x0 - - -/* -- For CDC_ARB_CLK_CTL */ -#define TIMPANI_A_CDC_ARB_CLK_CTL (0xA9) -#define TIMPANI_CDC_ARB_CLK_CTL_RWC "RW" -#define TIMPANI_CDC_ARB_CLK_CTL_POR 0 -#define TIMPANI_CDC_ARB_CLK_CTL_S 0 -#define TIMPANI_CDC_ARB_CLK_CTL_M 0x3 - - -#define TIMPANI_CDC_ARB_CLK_CTL_ARB_CLK_SEL_S 0 -#define TIMPANI_CDC_ARB_CLK_CTL_ARB_CLK_SEL_M 0x3 -#define TIMPANI_CDC_ARB_CLK_CTL_ARB_CLK_SEL_TX_MCLK 0x0 -#define TIMPANI_CDC_ARB_CLK_CTL_ARB_CLK_SEL_RX_MCLK1 0x1 -#define TIMPANI_CDC_ARB_CLK_CTL_ARB_CLK_SEL_RX_MCLK2 0x2 -#define TIMPANI_CDC_ARB_CLK_CTL_ARB_CLK_SEL_TCXO 0x3 - - -/* -- For CDC_GCTL2 */ -#define TIMPANI_A_CDC_GCTL2 (0xAA) -#define TIMPANI_CDC_GCTL2_RWC "RW" -#define TIMPANI_CDC_GCTL2_POR 0x33 -#define TIMPANI_CDC_GCTL2_S 0 -#define TIMPANI_CDC_GCTL2_M 0xFF - - -#define TIMPANI_CDC_GCTL2_TX2_PGA_UPDATE_R_S 7 -#define TIMPANI_CDC_GCTL2_TX2_PGA_UPDATE_R_M 0x80 - -#define TIMPANI_CDC_GCTL2_TX2_PGA_UPDATE_L_S 6 -#define TIMPANI_CDC_GCTL2_TX2_PGA_UPDATE_L_M 0x40 - -#define TIMPANI_CDC_GCTL2_TX2_PGA_MUTE_EN_R_S 5 -#define TIMPANI_CDC_GCTL2_TX2_PGA_MUTE_EN_R_M 0x20 - -#define TIMPANI_CDC_GCTL2_TX2_PGA_MUTE_EN_L_S 4 -#define TIMPANI_CDC_GCTL2_TX2_PGA_MUTE_EN_L_M 0x10 - -#define TIMPANI_CDC_GCTL2_RX2_PGA_UPDATE_R_S 3 -#define TIMPANI_CDC_GCTL2_RX2_PGA_UPDATE_R_M 0x8 - -#define TIMPANI_CDC_GCTL2_RX2_PGA_UPDATE_L_S 2 -#define TIMPANI_CDC_GCTL2_RX2_PGA_UPDATE_L_M 0x4 - -#define TIMPANI_CDC_GCTL2_RX2_PGA_MUTE_EN_R_S 1 -#define TIMPANI_CDC_GCTL2_RX2_PGA_MUTE_EN_R_M 0x2 - -#define TIMPANI_CDC_GCTL2_RX2_PGA_MUTE_EN_L_S 0 -#define TIMPANI_CDC_GCTL2_RX2_PGA_MUTE_EN_L_M 0x1 - - -/* -- For CDC_BYPASS_CTL2 */ -#define TIMPANI_A_CDC_BYPASS_CTL2 (0xAB) -#define TIMPANI_CDC_BYPASS_CTL2_RWC "RW" -#define TIMPANI_CDC_BYPASS_CTL2_POR 0x2D -#define TIMPANI_CDC_BYPASS_CTL2_S 0 -#define TIMPANI_CDC_BYPASS_CTL2_M 0x3F - - -#define TIMPANI_CDC_BYPASS_CTL2_TX1_DMIC_GAIN_BP_R_S 5 -#define TIMPANI_CDC_BYPASS_CTL2_TX1_DMIC_GAIN_BP_R_M 0x20 - -#define TIMPANI_CDC_BYPASS_CTL2_TX1_ADC_GAIN_BP_R_S 4 -#define TIMPANI_CDC_BYPASS_CTL2_TX1_ADC_GAIN_BP_R_M 0x10 - -#define TIMPANI_CDC_BYPASS_CTL2_TX1_HPF_BP_R_S 3 -#define TIMPANI_CDC_BYPASS_CTL2_TX1_HPF_BP_R_M 0x8 - -#define TIMPANI_CDC_BYPASS_CTL2_TX1_DMIC_GAIN_BP_L_S 2 -#define TIMPANI_CDC_BYPASS_CTL2_TX1_DMIC_GAIN_BP_L_M 0x4 - -#define TIMPANI_CDC_BYPASS_CTL2_TX1_ADC_GAIN_BP_L_S 1 -#define TIMPANI_CDC_BYPASS_CTL2_TX1_ADC_GAIN_BP_L_M 0x2 - -#define TIMPANI_CDC_BYPASS_CTL2_TX1_HPF_BP_L_S 0 -#define TIMPANI_CDC_BYPASS_CTL2_TX1_HPF_BP_L_M 0x1 - - -/* -- For CDC_BYPASS_CTL3 */ -#define TIMPANI_A_CDC_BYPASS_CTL3 (0xAC) -#define TIMPANI_CDC_BYPASS_CTL3_RWC "RW" -#define TIMPANI_CDC_BYPASS_CTL3_POR 0x2D -#define TIMPANI_CDC_BYPASS_CTL3_S 0 -#define TIMPANI_CDC_BYPASS_CTL3_M 0x3F - - -#define TIMPANI_CDC_BYPASS_CTL3_TX2_DMIC_GAIN_BP_R_S 5 -#define TIMPANI_CDC_BYPASS_CTL3_TX2_DMIC_GAIN_BP_R_M 0x20 - -#define TIMPANI_CDC_BYPASS_CTL3_TX2_ADC_GAIN_BP_R_S 4 -#define TIMPANI_CDC_BYPASS_CTL3_TX2_ADC_GAIN_BP_R_M 0x10 - -#define TIMPANI_CDC_BYPASS_CTL3_TX2_HPF_BP_R_S 3 -#define TIMPANI_CDC_BYPASS_CTL3_TX2_HPF_BP_R_M 0x8 - -#define TIMPANI_CDC_BYPASS_CTL3_TX2_DMIC_GAIN_BP_L_S 2 -#define TIMPANI_CDC_BYPASS_CTL3_TX2_DMIC_GAIN_BP_L_M 0x4 - -#define TIMPANI_CDC_BYPASS_CTL3_TX2_ADC_GAIN_BP_L_S 1 -#define TIMPANI_CDC_BYPASS_CTL3_TX2_ADC_GAIN_BP_L_M 0x2 - -#define TIMPANI_CDC_BYPASS_CTL3_TX2_HPF_BP_L_S 0 -#define TIMPANI_CDC_BYPASS_CTL3_TX2_HPF_BP_L_M 0x1 - - -/* -- For CDC_BYPASS_CTL4 */ -#define TIMPANI_A_CDC_BYPASS_CTL4 (0xAD) -#define TIMPANI_CDC_BYPASS_CTL4_RWC "RW" -#define TIMPANI_CDC_BYPASS_CTL4_POR 0x2 -#define TIMPANI_CDC_BYPASS_CTL4_S 0 -#define TIMPANI_CDC_BYPASS_CTL4_M 0xF - - -#define TIMPANI_CDC_BYPASS_CTL4_DITHER_BP_S 3 -#define TIMPANI_CDC_BYPASS_CTL4_DITHER_BP_M 0x8 - -#define TIMPANI_CDC_BYPASS_CTL4_DITHER_SHAPE_SEL_S 2 -#define TIMPANI_CDC_BYPASS_CTL4_DITHER_SHAPE_SEL_M 0x4 - -#define TIMPANI_CDC_BYPASS_CTL4_DITHER_DLY_SEL_S 1 -#define TIMPANI_CDC_BYPASS_CTL4_DITHER_DLY_SEL_M 0x2 - -#define TIMPANI_CDC_BYPASS_CTL4_RX2_HPF_BP_S 0 -#define TIMPANI_CDC_BYPASS_CTL4_RX2_HPF_BP_M 0x1 - - -/* -- For CDC_RX2L_DCOFFSET */ -#define TIMPANI_A_CDC_RX2L_DCOFFSET (0xAE) -#define TIMPANI_CDC_RX2L_DCOFFSET_RWC "RW" -#define TIMPANI_CDC_RX2L_DCOFFSET_POR 0 -#define TIMPANI_CDC_RX2L_DCOFFSET_S 0 -#define TIMPANI_CDC_RX2L_DCOFFSET_M 0xFF - - -#define TIMPANI_CDC_RX2L_DCOFFSET_OFFSET_S 0 -#define TIMPANI_CDC_RX2L_DCOFFSET_OFFSET_M 0xFF - - -/* -- For CDC_RX2R_DCOFFSET */ -#define TIMPANI_A_CDC_RX2R_DCOFFSET (0xAF) -#define TIMPANI_CDC_RX2R_DCOFFSET_RWC "RW" -#define TIMPANI_CDC_RX2R_DCOFFSET_POR 0 -#define TIMPANI_CDC_RX2R_DCOFFSET_S 0 -#define TIMPANI_CDC_RX2R_DCOFFSET_M 0xFF - - -#define TIMPANI_CDC_RX2R_DCOFFSET_OFFSET_S 0 -#define TIMPANI_CDC_RX2R_DCOFFSET_OFFSET_M 0xFF - - -/* -- For CDC_RX_MIX_CTL */ -#define TIMPANI_A_CDC_RX_MIX_CTL (0xB0) -#define TIMPANI_CDC_RX_MIX_CTL_RWC "RW" -#define TIMPANI_CDC_RX_MIX_CTL_POR 0 -#define TIMPANI_CDC_RX_MIX_CTL_S 0 -#define TIMPANI_CDC_RX_MIX_CTL_M 0x3 - - -#define TIMPANI_CDC_RX_MIX_CTL_RX2TO1_EN_S 1 -#define TIMPANI_CDC_RX_MIX_CTL_RX2TO1_EN_M 0x2 - -#define TIMPANI_CDC_RX_MIX_CTL_RX1TO2_EN_S 0 -#define TIMPANI_CDC_RX_MIX_CTL_RX1TO2_EN_M 0x1 - - -/* -- For CDC_SPARE_CTL */ -#define TIMPANI_A_CDC_SPARE_CTL (0xB1) -#define TIMPANI_CDC_SPARE_CTL_RWC "RW" -#define TIMPANI_CDC_SPARE_CTL_POR 0 -#define TIMPANI_CDC_SPARE_CTL_S 0 -#define TIMPANI_CDC_SPARE_CTL_M 0xFF - - -#define TIMPANI_CDC_SPARE_CTL_CDC_SPARE_S 0 -#define TIMPANI_CDC_SPARE_CTL_CDC_SPARE_M 0xFF - - -/* -- For CDC_TESTMODE2 */ -#define TIMPANI_A_CDC_TESTMODE2 (0xB2) -#define TIMPANI_CDC_TESTMODE2_RWC "RW" -#define TIMPANI_CDC_TESTMODE2_POR 0 -#define TIMPANI_CDC_TESTMODE2_S 0 -#define TIMPANI_CDC_TESTMODE2_M 0x1F - - -#define TIMPANI_CDC_TESTMODE2_RX2_TEST_EN_R_S 4 -#define TIMPANI_CDC_TESTMODE2_RX2_TEST_EN_R_M 0x10 - -#define TIMPANI_CDC_TESTMODE2_RX2_TEST_EN_L_S 3 -#define TIMPANI_CDC_TESTMODE2_RX2_TEST_EN_L_M 0x8 - -#define TIMPANI_CDC_TESTMODE2_TX2_TEST_EN_R_S 2 -#define TIMPANI_CDC_TESTMODE2_TX2_TEST_EN_R_M 0x4 - -#define TIMPANI_CDC_TESTMODE2_TX2_TEST_EN_L_S 1 -#define TIMPANI_CDC_TESTMODE2_TX2_TEST_EN_L_M 0x2 - -#define TIMPANI_CDC_TESTMODE2_A_LOOPBACK_EN2_S 0 -#define TIMPANI_CDC_TESTMODE2_A_LOOPBACK_EN2_M 0x1 - - -/* -- For CDC_PDM_OE */ -#define TIMPANI_A_CDC_PDM_OE (0xB3) -#define TIMPANI_CDC_PDM_OE_RWC "RW" -#define TIMPANI_CDC_PDM_OE_POR 0 -#define TIMPANI_CDC_PDM_OE_S 0 -#define TIMPANI_CDC_PDM_OE_M 0x3F - - -#define TIMPANI_CDC_PDM_OE_PDM_23_20_OE_S 5 -#define TIMPANI_CDC_PDM_OE_PDM_23_20_OE_M 0x20 - -#define TIMPANI_CDC_PDM_OE_PDM_19_16_OE_S 4 -#define TIMPANI_CDC_PDM_OE_PDM_19_16_OE_M 0x10 - -#define TIMPANI_CDC_PDM_OE_PDM_15_12_OE_S 3 -#define TIMPANI_CDC_PDM_OE_PDM_15_12_OE_M 0x8 - -#define TIMPANI_CDC_PDM_OE_PDM_11_8_OE_S 2 -#define TIMPANI_CDC_PDM_OE_PDM_11_8_OE_M 0x4 - -#define TIMPANI_CDC_PDM_OE_PDM_7_4_OE_S 1 -#define TIMPANI_CDC_PDM_OE_PDM_7_4_OE_M 0x2 - -#define TIMPANI_CDC_PDM_OE_PDM_3_0_OE_S 0 -#define TIMPANI_CDC_PDM_OE_PDM_3_0_OE_M 0x1 - - -/* -- For CDC_TX1R_STG */ -#define TIMPANI_A_CDC_TX1R_STG (0xB4) -#define TIMPANI_CDC_TX1R_STG_RWC "RW" -#define TIMPANI_CDC_TX1R_STG_POR 0xac -#define TIMPANI_CDC_TX1R_STG_S 0 -#define TIMPANI_CDC_TX1R_STG_M 0xFF - - -#define TIMPANI_CDC_TX1R_STG_GAIN_S 0 -#define TIMPANI_CDC_TX1R_STG_GAIN_M 0xFF - - -/* -- For CDC_TX2L_STG */ -#define TIMPANI_A_CDC_TX2L_STG (0xB5) -#define TIMPANI_CDC_TX2L_STG_RWC "RW" -#define TIMPANI_CDC_TX2L_STG_POR 0xac -#define TIMPANI_CDC_TX2L_STG_S 0 -#define TIMPANI_CDC_TX2L_STG_M 0xFF - - -#define TIMPANI_CDC_TX2L_STG_GAIN_S 0 -#define TIMPANI_CDC_TX2L_STG_GAIN_M 0xFF - - -/* -- For CDC_TX2R_STG */ -#define TIMPANI_A_CDC_TX2R_STG (0xB6) -#define TIMPANI_CDC_TX2R_STG_RWC "RW" -#define TIMPANI_CDC_TX2R_STG_POR 0xac -#define TIMPANI_CDC_TX2R_STG_S 0 -#define TIMPANI_CDC_TX2R_STG_M 0xFF - - -#define TIMPANI_CDC_TX2R_STG_GAIN_S 0 -#define TIMPANI_CDC_TX2R_STG_GAIN_M 0xFF - - -/* -- For CDC_ARB_BYPASS_CTL */ -#define TIMPANI_A_CDC_ARB_BYPASS_CTL (0xB7) -#define TIMPANI_CDC_ARB_BYPASS_CTL_RWC "RW" -#define TIMPANI_CDC_ARB_BYPASS_CTL_POR 0 -#define TIMPANI_CDC_ARB_BYPASS_CTL_S 0 -#define TIMPANI_CDC_ARB_BYPASS_CTL_M 0x1 - - -#define TIMPANI_CDC_ARB_BYPASS_CTL_ARB_BYPASS_EN_S 0 -#define TIMPANI_CDC_ARB_BYPASS_CTL_ARB_BYPASS_EN_M 0x1 -#define TIMPANI_CDC_ARB_BYPASS_CTL_ARB_BYPASS_EN_BYPASS 0x1 -#define TIMPANI_CDC_ARB_BYPASS_CTL_ARB_BYPASS_EN_NO_BYPASS 0x0 - - -/* -- For CDC_ANC1_CTL1 */ -#define TIMPANI_A_CDC_ANC1_CTL1 (0xC0) -#define TIMPANI_CDC_ANC1_CTL1_RWC "RW" -#define TIMPANI_CDC_ANC1_CTL1_POR 0 -#define TIMPANI_CDC_ANC1_CTL1_S 0 -#define TIMPANI_CDC_ANC1_CTL1_M 0x3F - - -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FF_OUT_DIS_S 5 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FF_OUT_DIS_M 0x20 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FF_OUT_DIS_FF_OUT_DIS 0x1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FF_OUT_DIS_FF_OUT_EN 0x0 - -#define TIMPANI_CDC_ANC1_CTL1_ANC1_ADC_DMIC_SEL_S 4 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_ADC_DMIC_SEL_M 0x10 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_ADC_DMIC_SEL_DMIC 0x1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_ADC_DMIC_SEL_ADC 0x0 - -#define TIMPANI_CDC_ANC1_CTL1_ANC1_LR_EN_S 3 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_LR_EN_M 0x8 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_LR_EN_LR_MIX_EN 0x1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_LR_EN_LR_MIX_DIS 0x0 - -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FB_EN_S 2 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FB_EN_M 0x4 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FB_EN_FB_MIX_EN 0x1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_FB_EN_FB_MIX_DIS 0x0 - -#define TIMPANI_CDC_ANC1_CTL1_ANC1_EN_S 1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_EN_M 0x2 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_EN_ANC_EN 0x1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_EN_ANC_DIS 0x0 - -#define TIMPANI_CDC_ANC1_CTL1_ANC1_SOFT_RESET_S 0 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_SOFT_RESET_M 0x1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_SOFT_RESET_ANC_RESET 0x1 -#define TIMPANI_CDC_ANC1_CTL1_ANC1_SOFT_RESET_ANC_ACTIVE 0x0 - - -/* -- For CDC_ANC1_CTL2 */ -#define TIMPANI_A_CDC_ANC1_CTL2 (0xC1) -#define TIMPANI_CDC_ANC1_CTL2_RWC "RW" -#define TIMPANI_CDC_ANC1_CTL2_POR 0 -#define TIMPANI_CDC_ANC1_CTL2_S 0 -#define TIMPANI_CDC_ANC1_CTL2_M 0x1F - - -#define TIMPANI_CDC_ANC1_CTL2_ANC1_FREQ_SEL_S 0 -#define TIMPANI_CDC_ANC1_CTL2_ANC1_FREQ_SEL_M 0x1F - - -/* -- For CDC_ANC1_FF_FB_SHIFT */ -#define TIMPANI_A_CDC_ANC1_FF_FB_SHIFT (0xC2) -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_RWC "RW" -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_POR 0 -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_S 0 -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_M 0xFF - - -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_ANC1_FB_LPF_SHIFT_S 4 -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_ANC1_FB_LPF_SHIFT_M 0xF0 - -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_ANC1_FF_LPF_SHIFT_S 0 -#define TIMPANI_CDC_ANC1_FF_FB_SHIFT_ANC1_FF_LPF_SHIFT_M 0xF - - -/* -- For CDC_ANC1_RX_NS */ -#define TIMPANI_A_CDC_ANC1_RX_NS (0xC3) -#define TIMPANI_CDC_ANC1_RX_NS_RWC "RW" -#define TIMPANI_CDC_ANC1_RX_NS_POR 0x1 -#define TIMPANI_CDC_ANC1_RX_NS_S 0 -#define TIMPANI_CDC_ANC1_RX_NS_M 0x7 - - -#define TIMPANI_CDC_ANC1_RX_NS_ANC1_DITHER_BP_S 2 -#define TIMPANI_CDC_ANC1_RX_NS_ANC1_DITHER_BP_M 0x4 - -#define TIMPANI_CDC_ANC1_RX_NS_ANC1_DITHER_SHAPE_SEL_S 1 -#define TIMPANI_CDC_ANC1_RX_NS_ANC1_DITHER_SHAPE_SEL_M 0x2 - -#define TIMPANI_CDC_ANC1_RX_NS_ANC1_DITHER_DLY_SEL_S 0 -#define TIMPANI_CDC_ANC1_RX_NS_ANC1_DITHER_DLY_SEL_M 0x1 - - -/* -- For CDC_ANC1_SPARE */ -#define TIMPANI_A_CDC_ANC1_SPARE (0xC4) -#define TIMPANI_CDC_ANC1_SPARE_RWC "RW" -#define TIMPANI_CDC_ANC1_SPARE_POR 0 -#define TIMPANI_CDC_ANC1_SPARE_S 0 -#define TIMPANI_CDC_ANC1_SPARE_M 0xFF - - -#define TIMPANI_CDC_ANC1_SPARE_ANC1_SPARE_S 0 -#define TIMPANI_CDC_ANC1_SPARE_ANC1_SPARE_M 0xFF - - -/* -- For CDC_ANC1_IIR_COEFF_PTR */ -#define TIMPANI_A_CDC_ANC1_IIR_COEFF_PTR (0xC5) -#define TIMPANI_CDC_ANC1_IIR_COEFF_PTR_RWC "RW" -#define TIMPANI_CDC_ANC1_IIR_COEFF_PTR_POR 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_PTR_M 0x1F - - -#define TIMPANI_CDC_ANC1_IIR_COEFF_PTR_ANC1_IIR_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_PTR_ANC1_IIR_COEFF_PTR_M 0x1F - - -/* -- For CDC_ANC1_IIR_COEFF_MSB */ -#define TIMPANI_A_CDC_ANC1_IIR_COEFF_MSB (0xC6) -#define TIMPANI_CDC_ANC1_IIR_COEFF_MSB_RWC "RW" -#define TIMPANI_CDC_ANC1_IIR_COEFF_MSB_POR 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_MSB_M 0x1 - - -#define TIMPANI_CDC_ANC1_IIR_COEFF_MSB_ANC1_IIR_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_MSB_ANC1_IIR_COEFF_MSB_M 0x1 - - -/* -- For CDC_ANC1_IIR_COEFF_LSB */ -#define TIMPANI_A_CDC_ANC1_IIR_COEFF_LSB (0xC7) -#define TIMPANI_CDC_ANC1_IIR_COEFF_LSB_RWC "RW" -#define TIMPANI_CDC_ANC1_IIR_COEFF_LSB_POR 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_LSB_M 0xFF - - -#define TIMPANI_CDC_ANC1_IIR_COEFF_LSB_ANC1_IIR_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_LSB_ANC1_IIR_COEFF_LSB_M 0xFF - - -/* -- For CDC_ANC1_IIR_COEFF_CTL */ -#define TIMPANI_A_CDC_ANC1_IIR_COEFF_CTL (0xC8) -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_RWC "RW" -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_POR 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_M 0x3 - - -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_ADAPTIVE_S 1 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_ADAPTIVE_M 0x2 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_ADAPTIVE_ADAPTIVE 0x1 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_ADAPTIVE_NON_ADAPTIVE 0x0 - -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_EN_S 0 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_EN_M 0x1 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_EN_UPDATE 0x1 -#define TIMPANI_CDC_ANC1_IIR_COEFF_CTL_ANC1_IIR_COEFF_EN_NO_UPDATE 0x0 - - -/* -- For CDC_ANC1_LPF_COEFF_PTR */ -#define TIMPANI_A_CDC_ANC1_LPF_COEFF_PTR (0xC9) -#define TIMPANI_CDC_ANC1_LPF_COEFF_PTR_RWC "RW" -#define TIMPANI_CDC_ANC1_LPF_COEFF_PTR_POR 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_PTR_M 0xF - - -#define TIMPANI_CDC_ANC1_LPF_COEFF_PTR_ANC1_LPF_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_PTR_ANC1_LPF_COEFF_PTR_M 0xF - - -/* -- For CDC_ANC1_LPF_COEFF_MSB */ -#define TIMPANI_A_CDC_ANC1_LPF_COEFF_MSB (0xCA) -#define TIMPANI_CDC_ANC1_LPF_COEFF_MSB_RWC "RW" -#define TIMPANI_CDC_ANC1_LPF_COEFF_MSB_POR 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_MSB_M 0xF - - -#define TIMPANI_CDC_ANC1_LPF_COEFF_MSB_ANC1_LPF_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_MSB_ANC1_LPF_COEFF_MSB_M 0xF - - -/* -- For CDC_ANC1_LPF_COEFF_LSB */ -#define TIMPANI_A_CDC_ANC1_LPF_COEFF_LSB (0xCB) -#define TIMPANI_CDC_ANC1_LPF_COEFF_LSB_RWC "RW" -#define TIMPANI_CDC_ANC1_LPF_COEFF_LSB_POR 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_LSB_M 0xFF - - -#define TIMPANI_CDC_ANC1_LPF_COEFF_LSB_ANC1_LPF_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC1_LPF_COEFF_LSB_ANC1_LPF_COEFF_LSB_M 0xFF - - -/* -- For CDC_ANC1_SCALE_PTR */ -#define TIMPANI_A_CDC_ANC1_SCALE_PTR (0xCC) -#define TIMPANI_CDC_ANC1_SCALE_PTR_RWC "RW" -#define TIMPANI_CDC_ANC1_SCALE_PTR_POR 0 -#define TIMPANI_CDC_ANC1_SCALE_PTR_S 0 -#define TIMPANI_CDC_ANC1_SCALE_PTR_M 0x7 - - -#define TIMPANI_CDC_ANC1_SCALE_PTR_ANC1_SCALE_PTR_S 0 -#define TIMPANI_CDC_ANC1_SCALE_PTR_ANC1_SCALE_PTR_M 0x7 - - -/* -- For CDC_ANC1_SCALE */ -#define TIMPANI_A_CDC_ANC1_SCALE (0xCD) -#define TIMPANI_CDC_ANC1_SCALE_RWC "RW" -#define TIMPANI_CDC_ANC1_SCALE_POR 0 -#define TIMPANI_CDC_ANC1_SCALE_S 0 -#define TIMPANI_CDC_ANC1_SCALE_M 0xFF - - -#define TIMPANI_CDC_ANC1_SCALE_ANC1_SCALE_S 0 -#define TIMPANI_CDC_ANC1_SCALE_ANC1_SCALE_M 0xFF - - -/* -- For CDC_ANC1_DEBUG */ -#define TIMPANI_A_CDC_ANC1_DEBUG (0xCE) -#define TIMPANI_CDC_ANC1_DEBUG_RWC "RW" -#define TIMPANI_CDC_ANC1_DEBUG_POR 0 -#define TIMPANI_CDC_ANC1_DEBUG_S 0 -#define TIMPANI_CDC_ANC1_DEBUG_M 0xF - - -#define TIMPANI_CDC_ANC1_DEBUG_ANC1_DEBUG_SEL_S 0 -#define TIMPANI_CDC_ANC1_DEBUG_ANC1_DEBUG_SEL_M 0xF - - -/* -- For CDC_ANC2_CTL1 */ -#define TIMPANI_A_CDC_ANC2_CTL1 (0xD0) -#define TIMPANI_CDC_ANC2_CTL1_RWC "RW" -#define TIMPANI_CDC_ANC2_CTL1_POR 0 -#define TIMPANI_CDC_ANC2_CTL1_S 0 -#define TIMPANI_CDC_ANC2_CTL1_M 0x3F - - -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FF_OUT_DIS_S 5 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FF_OUT_DIS_M 0x20 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FF_OUT_DIS_FF_OUT_DIS 0x1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FF_OUT_DIS_FF_OUT_EN 0x0 - -#define TIMPANI_CDC_ANC2_CTL1_ANC2_ADC_DMIC_SEL_S 4 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_ADC_DMIC_SEL_M 0x10 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_ADC_DMIC_SEL_DMIC 0x1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_ADC_DMIC_SEL_ADC 0x0 - -#define TIMPANI_CDC_ANC2_CTL1_ANC2_LR_EN_S 3 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_LR_EN_M 0x8 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_LR_EN_LR_MIX_EN 0x1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_LR_EN_LR_MIX_DIS 0x0 - -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FB_EN_S 2 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FB_EN_M 0x4 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FB_EN_FB_MIX_EN 0x1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_FB_EN_FB_MIX_DIS 0x0 - -#define TIMPANI_CDC_ANC2_CTL1_ANC2_EN_S 1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_EN_M 0x2 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_EN_ANC_EN 0x1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_EN_ANC_DIS 0x0 - -#define TIMPANI_CDC_ANC2_CTL1_ANC2_SOFT_RESET_S 0 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_SOFT_RESET_M 0x1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_SOFT_RESET_ANC_RESET 0x1 -#define TIMPANI_CDC_ANC2_CTL1_ANC2_SOFT_RESET_ANC_ACTIVE 0x0 - - -/* -- For CDC_ANC2_CTL2 */ -#define TIMPANI_A_CDC_ANC2_CTL2 (0xD1) -#define TIMPANI_CDC_ANC2_CTL2_RWC "RW" -#define TIMPANI_CDC_ANC2_CTL2_POR 0 -#define TIMPANI_CDC_ANC2_CTL2_S 0 -#define TIMPANI_CDC_ANC2_CTL2_M 0x1F - - -#define TIMPANI_CDC_ANC2_CTL2_ANC2_FREQ_SEL_S 0 -#define TIMPANI_CDC_ANC2_CTL2_ANC2_FREQ_SEL_M 0x1F - - -/* -- For CDC_ANC2_FF_FB_SHIFT */ -#define TIMPANI_A_CDC_ANC2_FF_FB_SHIFT (0xD2) -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_RWC "RW" -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_POR 0 -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_S 0 -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_M 0xFF - - -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_ANC2_FB_LPF_SHIFT_S 4 -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_ANC2_FB_LPF_SHIFT_M 0xF0 - -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_ANC2_FF_LPF_SHIFT_S 0 -#define TIMPANI_CDC_ANC2_FF_FB_SHIFT_ANC2_FF_LPF_SHIFT_M 0xF - - -/* -- For CDC_ANC2_RX_NS */ -#define TIMPANI_A_CDC_ANC2_RX_NS (0xD3) -#define TIMPANI_CDC_ANC2_RX_NS_RWC "RW" -#define TIMPANI_CDC_ANC2_RX_NS_POR 0x1 -#define TIMPANI_CDC_ANC2_RX_NS_S 0 -#define TIMPANI_CDC_ANC2_RX_NS_M 0x7 - - -#define TIMPANI_CDC_ANC2_RX_NS_ANC2_DITHER_BP_S 2 -#define TIMPANI_CDC_ANC2_RX_NS_ANC2_DITHER_BP_M 0x4 - -#define TIMPANI_CDC_ANC2_RX_NS_ANC2_DITHER_SHAPE_SEL_S 1 -#define TIMPANI_CDC_ANC2_RX_NS_ANC2_DITHER_SHAPE_SEL_M 0x2 - -#define TIMPANI_CDC_ANC2_RX_NS_ANC2_DITHER_DLY_SEL_S 0 -#define TIMPANI_CDC_ANC2_RX_NS_ANC2_DITHER_DLY_SEL_M 0x1 - - -/* -- For CDC_ANC2_SPARE */ -#define TIMPANI_A_CDC_ANC2_SPARE (0xD4) -#define TIMPANI_CDC_ANC2_SPARE_RWC "RW" -#define TIMPANI_CDC_ANC2_SPARE_POR 0 -#define TIMPANI_CDC_ANC2_SPARE_S 0 -#define TIMPANI_CDC_ANC2_SPARE_M 0xFF - - -#define TIMPANI_CDC_ANC2_SPARE_ANC2_SPARE_S 0 -#define TIMPANI_CDC_ANC2_SPARE_ANC2_SPARE_M 0xFF - - -/* -- For CDC_ANC2_IIR_COEFF_PTR */ -#define TIMPANI_A_CDC_ANC2_IIR_COEFF_PTR (0xD5) -#define TIMPANI_CDC_ANC2_IIR_COEFF_PTR_RWC "RW" -#define TIMPANI_CDC_ANC2_IIR_COEFF_PTR_POR 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_PTR_M 0x1F - - -#define TIMPANI_CDC_ANC2_IIR_COEFF_PTR_ANC2_IIR_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_PTR_ANC2_IIR_COEFF_PTR_M 0x1F - - -/* -- For CDC_ANC2_IIR_COEFF_MSB */ -#define TIMPANI_A_CDC_ANC2_IIR_COEFF_MSB (0xD6) -#define TIMPANI_CDC_ANC2_IIR_COEFF_MSB_RWC "RW" -#define TIMPANI_CDC_ANC2_IIR_COEFF_MSB_POR 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_MSB_M 0x1 - - -#define TIMPANI_CDC_ANC2_IIR_COEFF_MSB_ANC2_IIR_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_MSB_ANC2_IIR_COEFF_MSB_M 0x1 - - -/* -- For CDC_ANC2_IIR_COEFF_LSB */ -#define TIMPANI_A_CDC_ANC2_IIR_COEFF_LSB (0xD7) -#define TIMPANI_CDC_ANC2_IIR_COEFF_LSB_RWC "RW" -#define TIMPANI_CDC_ANC2_IIR_COEFF_LSB_POR 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_LSB_M 0xFF - - -#define TIMPANI_CDC_ANC2_IIR_COEFF_LSB_ANC2_IIR_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_LSB_ANC2_IIR_COEFF_LSB_M 0xFF - - -/* -- For CDC_ANC2_IIR_COEFF_CTL */ -#define TIMPANI_A_CDC_ANC2_IIR_COEFF_CTL (0xD8) -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_RWC "RW" -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_POR 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_M 0x3 - - -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_ADAPTIVE_S 1 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_ADAPTIVE_M 0x2 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_ADAPTIVE_ADAPTIVE 0x1 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_ADAPTIVE_NON_ADAPTIVE 0x0 - -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_EN_S 0 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_EN_M 0x1 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_EN_UPDATE 0x1 -#define TIMPANI_CDC_ANC2_IIR_COEFF_CTL_ANC2_IIR_COEFF_EN_NO_UPDATE 0x0 - - -/* -- For CDC_ANC2_LPF_COEFF_PTR */ -#define TIMPANI_A_CDC_ANC2_LPF_COEFF_PTR (0xD9) -#define TIMPANI_CDC_ANC2_LPF_COEFF_PTR_RWC "RW" -#define TIMPANI_CDC_ANC2_LPF_COEFF_PTR_POR 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_PTR_M 0xF - - -#define TIMPANI_CDC_ANC2_LPF_COEFF_PTR_ANC2_LPF_COEFF_PTR_S 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_PTR_ANC2_LPF_COEFF_PTR_M 0xF - - -/* -- For CDC_ANC2_LPF_COEFF_MSB */ -#define TIMPANI_A_CDC_ANC2_LPF_COEFF_MSB (0xDA) -#define TIMPANI_CDC_ANC2_LPF_COEFF_MSB_RWC "RW" -#define TIMPANI_CDC_ANC2_LPF_COEFF_MSB_POR 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_MSB_M 0xF - - -#define TIMPANI_CDC_ANC2_LPF_COEFF_MSB_ANC2_LPF_COEFF_MSB_S 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_MSB_ANC2_LPF_COEFF_MSB_M 0xF - - -/* -- For CDC_ANC2_LPF_COEFF_LSB */ -#define TIMPANI_A_CDC_ANC2_LPF_COEFF_LSB (0xDB) -#define TIMPANI_CDC_ANC2_LPF_COEFF_LSB_RWC "RW" -#define TIMPANI_CDC_ANC2_LPF_COEFF_LSB_POR 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_LSB_M 0xFF - - -#define TIMPANI_CDC_ANC2_LPF_COEFF_LSB_ANC2_LPF_COEFF_LSB_S 0 -#define TIMPANI_CDC_ANC2_LPF_COEFF_LSB_ANC2_LPF_COEFF_LSB_M 0xFF - - -/* -- For CDC_ANC2_SCALE_PTR */ -#define TIMPANI_A_CDC_ANC2_SCALE_PTR (0xDC) -#define TIMPANI_CDC_ANC2_SCALE_PTR_RWC "RW" -#define TIMPANI_CDC_ANC2_SCALE_PTR_POR 0 -#define TIMPANI_CDC_ANC2_SCALE_PTR_S 0 -#define TIMPANI_CDC_ANC2_SCALE_PTR_M 0x7 - - -#define TIMPANI_CDC_ANC2_SCALE_PTR_ANC2_SCALE_PTR_S 0 -#define TIMPANI_CDC_ANC2_SCALE_PTR_ANC2_SCALE_PTR_M 0x7 - - -/* -- For CDC_ANC2_SCALE */ -#define TIMPANI_A_CDC_ANC2_SCALE (0xDD) -#define TIMPANI_CDC_ANC2_SCALE_RWC "RW" -#define TIMPANI_CDC_ANC2_SCALE_POR 0 -#define TIMPANI_CDC_ANC2_SCALE_S 0 -#define TIMPANI_CDC_ANC2_SCALE_M 0xFF - - -#define TIMPANI_CDC_ANC2_SCALE_ANC2_SCALE_S 0 -#define TIMPANI_CDC_ANC2_SCALE_ANC2_SCALE_M 0xFF - - -/* -- For CDC_ANC2_DEBUG */ -#define TIMPANI_A_CDC_ANC2_DEBUG (0xDE) -#define TIMPANI_CDC_ANC2_DEBUG_RWC "RW" -#define TIMPANI_CDC_ANC2_DEBUG_POR 0 -#define TIMPANI_CDC_ANC2_DEBUG_S 0 -#define TIMPANI_CDC_ANC2_DEBUG_M 0xF - - -#define TIMPANI_CDC_ANC2_DEBUG_ANC2_DEBUG_SEL_S 0 -#define TIMPANI_CDC_ANC2_DEBUG_ANC2_DEBUG_SEL_M 0xF - - -/* -- For CDC_LINE_L_AVOL */ -#define TIMPANI_A_CDC_LINE_L_AVOL (0xE0) -#define TIMPANI_CDC_LINE_L_AVOL_RWC "RW" -#define TIMPANI_CDC_LINE_L_AVOL_POR 0xac -#define TIMPANI_CDC_LINE_L_AVOL_S 0 -#define TIMPANI_CDC_LINE_L_AVOL_M 0xFF - - -#define TIMPANI_CDC_LINE_L_AVOL_USER_GAIN_S 2 -#define TIMPANI_CDC_LINE_L_AVOL_USER_GAIN_M 0xFC - -#define TIMPANI_CDC_LINE_L_AVOL_DUMMY_S 0 -#define TIMPANI_CDC_LINE_L_AVOL_DUMMY_M 0x3 - - -/* -- For CDC_LINE_R_AVOL */ -#define TIMPANI_A_CDC_LINE_R_AVOL (0xE1) -#define TIMPANI_CDC_LINE_R_AVOL_RWC "RW" -#define TIMPANI_CDC_LINE_R_AVOL_POR 0xac -#define TIMPANI_CDC_LINE_R_AVOL_S 0 -#define TIMPANI_CDC_LINE_R_AVOL_M 0xFF - - -#define TIMPANI_CDC_LINE_R_AVOL_USER_GAIN_S 2 -#define TIMPANI_CDC_LINE_R_AVOL_USER_GAIN_M 0xFC - -#define TIMPANI_CDC_LINE_R_AVOL_DUMMY_S 0 -#define TIMPANI_CDC_LINE_R_AVOL_DUMMY_M 0x3 - - -/* -- For CDC_HPH_L_AVOL */ -#define TIMPANI_A_CDC_HPH_L_AVOL (0xE2) -#define TIMPANI_CDC_HPH_L_AVOL_RWC "RW" -#define TIMPANI_CDC_HPH_L_AVOL_POR 0xae -#define TIMPANI_CDC_HPH_L_AVOL_S 0 -#define TIMPANI_CDC_HPH_L_AVOL_M 0xFF - - -#define TIMPANI_CDC_HPH_L_AVOL_USER_GAIN_S 2 -#define TIMPANI_CDC_HPH_L_AVOL_USER_GAIN_M 0xFC - -#define TIMPANI_CDC_HPH_L_AVOL_MUTE_S 1 -#define TIMPANI_CDC_HPH_L_AVOL_MUTE_M 0x2 -#define TIMPANI_CDC_HPH_L_AVOL_MUTE_MUTE 0x1 -#define TIMPANI_CDC_HPH_L_AVOL_MUTE_UNMUTE 0x0 - -#define TIMPANI_CDC_HPH_L_AVOL_DUMMY_S 0 -#define TIMPANI_CDC_HPH_L_AVOL_DUMMY_M 0x1 - - -/* -- For CDC_HPH_R_AVOL */ -#define TIMPANI_A_CDC_HPH_R_AVOL (0xE3) -#define TIMPANI_CDC_HPH_R_AVOL_RWC "RW" -#define TIMPANI_CDC_HPH_R_AVOL_POR 0xae -#define TIMPANI_CDC_HPH_R_AVOL_S 0 -#define TIMPANI_CDC_HPH_R_AVOL_M 0xFF - - -#define TIMPANI_CDC_HPH_R_AVOL_USER_GAIN_S 2 -#define TIMPANI_CDC_HPH_R_AVOL_USER_GAIN_M 0xFC - -#define TIMPANI_CDC_HPH_R_AVOL_MUTE_S 1 -#define TIMPANI_CDC_HPH_R_AVOL_MUTE_M 0x2 -#define TIMPANI_CDC_HPH_R_AVOL_MUTE_MUTE 0x1 -#define TIMPANI_CDC_HPH_R_AVOL_MUTE_UNMUTE 0x0 - -#define TIMPANI_CDC_HPH_R_AVOL_DUMMY_S 0 -#define TIMPANI_CDC_HPH_R_AVOL_DUMMY_M 0x1 - - -/* -- For CDC_COMP_CTL1 */ -#define TIMPANI_A_CDC_COMP_CTL1 (0xE4) -#define TIMPANI_CDC_COMP_CTL1_RWC "RW" -#define TIMPANI_CDC_COMP_CTL1_POR 0 -#define TIMPANI_CDC_COMP_CTL1_S 0 -#define TIMPANI_CDC_COMP_CTL1_M 0xFF - - -#define TIMPANI_CDC_COMP_CTL1_LO_CLK_EN_S 7 -#define TIMPANI_CDC_COMP_CTL1_LO_CLK_EN_M 0x80 - -#define TIMPANI_CDC_COMP_CTL1_HPH_CLK_EN_S 6 -#define TIMPANI_CDC_COMP_CTL1_HPH_CLK_EN_M 0x40 - -#define TIMPANI_CDC_COMP_CTL1_LO_SOFT_RESET_S 5 -#define TIMPANI_CDC_COMP_CTL1_LO_SOFT_RESET_M 0x20 - -#define TIMPANI_CDC_COMP_CTL1_HPH_SOFT_RESET_S 4 -#define TIMPANI_CDC_COMP_CTL1_HPH_SOFT_RESET_M 0x10 - -#define TIMPANI_CDC_COMP_CTL1_LO_R_EN_S 3 -#define TIMPANI_CDC_COMP_CTL1_LO_R_EN_M 0x8 - -#define TIMPANI_CDC_COMP_CTL1_LO_L_EN_S 2 -#define TIMPANI_CDC_COMP_CTL1_LO_L_EN_M 0x4 - -#define TIMPANI_CDC_COMP_CTL1_HPH_R_EN_S 1 -#define TIMPANI_CDC_COMP_CTL1_HPH_R_EN_M 0x2 - -#define TIMPANI_CDC_COMP_CTL1_HPH_L_EN_S 0 -#define TIMPANI_CDC_COMP_CTL1_HPH_L_EN_M 0x1 - - -/* -- For CDC_COMP_CTL2 */ -#define TIMPANI_A_CDC_COMP_CTL2 (0xE5) -#define TIMPANI_CDC_COMP_CTL2_RWC "RW" -#define TIMPANI_CDC_COMP_CTL2_POR 0xe -#define TIMPANI_CDC_COMP_CTL2_S 0 -#define TIMPANI_CDC_COMP_CTL2_M 0xF - - -#define TIMPANI_CDC_COMP_CTL2_LINEOUT_IN_MUX_S 2 -#define TIMPANI_CDC_COMP_CTL2_LINEOUT_IN_MUX_M 0xC - -#define TIMPANI_CDC_COMP_CTL2_HPH_IN_MUX_S 0 -#define TIMPANI_CDC_COMP_CTL2_HPH_IN_MUX_M 0x3 - - -/* -- For CDC_COMP_PEAK_METER */ -#define TIMPANI_A_CDC_COMP_PEAK_METER (0xE6) -#define TIMPANI_CDC_COMP_PEAK_METER_RWC "RW" -#define TIMPANI_CDC_COMP_PEAK_METER_POR 0x9 -#define TIMPANI_CDC_COMP_PEAK_METER_S 0 -#define TIMPANI_CDC_COMP_PEAK_METER_M 0xF - - -#define TIMPANI_CDC_COMP_PEAK_METER_TIME_OUT_S 0 -#define TIMPANI_CDC_COMP_PEAK_METER_TIME_OUT_M 0xF - - -/* -- For CDC_COMP_LEVEL_METER_CTL1 */ -#define TIMPANI_A_CDC_COMP_LEVEL_METER_CTL1 (0xE7) -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL1_RWC "RW" -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL1_POR 0x7 -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL1_S 0 -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL1_M 0xF - - -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL1_DIV_FACTOR_S 0 -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL1_DIV_FACTOR_M 0xF - - -/* -- For CDC_COMP_LEVEL_METER_CTL2 */ -#define TIMPANI_A_CDC_COMP_LEVEL_METER_CTL2 (0xE8) -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL2_RWC "RW" -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL2_POR 0x28 -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL2_S 0 -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL2_M 0xFF - - -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL2_RESAMPLE_RATE_S 0 -#define TIMPANI_CDC_COMP_LEVEL_METER_CTL2_RESAMPLE_RATE_M 0xFF - - -/* -- For CDC_COMP_ZONE_SELECT */ -#define TIMPANI_A_CDC_COMP_ZONE_SELECT (0xE9) -#define TIMPANI_CDC_COMP_ZONE_SELECT_RWC "RW" -#define TIMPANI_CDC_COMP_ZONE_SELECT_POR 0x3b -#define TIMPANI_CDC_COMP_ZONE_SELECT_S 0 -#define TIMPANI_CDC_COMP_ZONE_SELECT_M 0x7F - - -#define TIMPANI_CDC_COMP_ZONE_SELECT_ENTRY_S 3 -#define TIMPANI_CDC_COMP_ZONE_SELECT_ENTRY_M 0x78 - -#define TIMPANI_CDC_COMP_ZONE_SELECT_SHIFT_S 0 -#define TIMPANI_CDC_COMP_ZONE_SELECT_SHIFT_M 0x7 - - -/* -- For CDC_COMP_ZC_MSB */ -#define TIMPANI_A_CDC_COMP_ZC_MSB (0xEA) -#define TIMPANI_CDC_COMP_ZC_MSB_RWC "RW" -#define TIMPANI_CDC_COMP_ZC_MSB_POR 0 -#define TIMPANI_CDC_COMP_ZC_MSB_S 0 -#define TIMPANI_CDC_COMP_ZC_MSB_M 0x7 - - -#define TIMPANI_CDC_COMP_ZC_MSB_DET_WINDOW_S 0 -#define TIMPANI_CDC_COMP_ZC_MSB_DET_WINDOW_M 0x7 - - -/* -- For CDC_COMP_ZC_LSB */ -#define TIMPANI_A_CDC_COMP_ZC_LSB (0xEB) -#define TIMPANI_CDC_COMP_ZC_LSB_RWC "RW" -#define TIMPANI_CDC_COMP_ZC_LSB_POR 0x1f -#define TIMPANI_CDC_COMP_ZC_LSB_S 0 -#define TIMPANI_CDC_COMP_ZC_LSB_M 0xFF - - -#define TIMPANI_CDC_COMP_ZC_LSB_DET_WINDOW_S 0 -#define TIMPANI_CDC_COMP_ZC_LSB_DET_WINDOW_M 0xFF - - -/* -- For CDC_COMP_SHUT_DOWN */ -#define TIMPANI_A_CDC_COMP_SHUT_DOWN (0xEC) -#define TIMPANI_CDC_COMP_SHUT_DOWN_RWC "RW" -#define TIMPANI_CDC_COMP_SHUT_DOWN_POR 0x1b -#define TIMPANI_CDC_COMP_SHUT_DOWN_S 0 -#define TIMPANI_CDC_COMP_SHUT_DOWN_M 0x3F - - -#define TIMPANI_CDC_COMP_SHUT_DOWN_HPH_TIMEOUT_S 3 -#define TIMPANI_CDC_COMP_SHUT_DOWN_HPH_TIMEOUT_M 0x38 - -#define TIMPANI_CDC_COMP_SHUT_DOWN_LO_TIMEOUT_S 0 -#define TIMPANI_CDC_COMP_SHUT_DOWN_LO_TIMEOUT_M 0x7 - - -/* -- For CDC_COMP_SHUT_DOWN_STATUS */ -#define TIMPANI_A_CDC_COMP_SHUT_DOWN_STATUS (0xED) -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_RWC "RW" -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_POR 0 -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_S 0 -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_M 0xF - - -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_LO_R_S 3 -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_LO_R_M 0x8 - -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_LO_L_S 2 -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_LO_L_M 0x4 - -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_HPH_R_S 1 -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_HPH_R_M 0x2 - -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_HPH_L_S 0 -#define TIMPANI_CDC_COMP_SHUT_DOWN_STATUS_HPH_L_M 0x1 - - -/* -- For CDC_COMP_HALT */ -#define TIMPANI_A_CDC_COMP_HALT (0xEE) -#define TIMPANI_CDC_COMP_HALT_RWC "RW" -#define TIMPANI_CDC_COMP_HALT_POR 0 -#define TIMPANI_CDC_COMP_HALT_S 0 -#define TIMPANI_CDC_COMP_HALT_M 0x1 - - -#define TIMPANI_CDC_COMP_HALT_COMPANDER_HALT_S 0 -#define TIMPANI_CDC_COMP_HALT_COMPANDER_HALT_M 0x1 - - -#endif diff --git a/include/linux/mfd/tps65023.h b/include/linux/mfd/tps65023.h deleted file mode 100644 index b6ad6e561489d50a15cfd56694206f8f42e3bb31..0000000000000000000000000000000000000000 --- a/include/linux/mfd/tps65023.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2009, 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 __LINUX_I2C_TPS65023_H -#define __LINUX_I2C_TPS65023_H - -#ifndef CONFIG_TPS65023 -/* Set the output voltage for the DCDC1 convertor */ -#define tps65023_set_dcdc1_level(mvolts) (-ENODEV) - -/* Read the output voltage from the DCDC1 convertor */ -#define tps65023_get_dcdc1_level(mvolts) (-ENODEV) - -#else -/* Set the output voltage for the DCDC1 convertor */ -extern int tps65023_set_dcdc1_level(int mvolts); - -/* Read the output voltage from the DCDC1 convertor */ -extern int tps65023_get_dcdc1_level(int *mvolts); -#endif - -#endif diff --git a/include/linux/mfd/wcd9xxx/wcd9304_registers.h b/include/linux/mfd/wcd9xxx/wcd9304_registers.h deleted file mode 100644 index 8e5e23a7f543409bb854a39a7d13273b0a95da9e..0000000000000000000000000000000000000000 --- a/include/linux/mfd/wcd9xxx/wcd9304_registers.h +++ /dev/null @@ -1,872 +0,0 @@ -/* Copyright (c) 2012-2013, 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 SITAR_CODEC_DIGITAL_H -#define SITAR_CODEC_DIGITAL_H - -#define SITAR_A_PIN_CTL_OE0 (0x10) -#define SITAR_A_PIN_CTL_OE0__POR (0x00000000) -#define SITAR_A_PIN_CTL_OE1 (0x11) -#define SITAR_A_PIN_CTL_OE1__POR (0x00000000) -#define SITAR_A_PIN_CTL_DATA0 (0x12) -#define SITAR_A_PIN_CTL_DATA0__POR (0x00000000) -#define SITAR_A_PIN_CTL_DATA1 (0x13) -#define SITAR_A_PIN_CTL_DATA1__POR (0x00000000) -#define SITAR_A_HDRIVE_GENERIC (0x18) -#define SITAR_A_HDRIVE_GENERIC__POR (0x00000000) -#define SITAR_A_HDRIVE_OVERRIDE (0x19) -#define SITAR_A_HDRIVE_OVERRIDE__POR (0x00000008) -#define SITAR_A_ANA_CSR_WAIT_STATE (0x20) -#define SITAR_A_ANA_CSR_WAIT_STATE__POR (0x00000044) -#define SITAR_A_PROCESS_MONITOR_CTL0 (0x40) -#define SITAR_A_PROCESS_MONITOR_CTL0__POR (0x00000080) -#define SITAR_A_PROCESS_MONITOR_CTL1 (0x41) -#define SITAR_A_PROCESS_MONITOR_CTL1__POR (0x00000000) -#define SITAR_A_PROCESS_MONITOR_CTL2 (0x42) -#define SITAR_A_PROCESS_MONITOR_CTL2__POR (0x00000000) -#define SITAR_A_PROCESS_MONITOR_CTL3 (0x43) -#define SITAR_A_PROCESS_MONITOR_CTL3__POR (0x00000001) -#define SITAR_A_QFUSE_CTL (0x48) -#define SITAR_A_QFUSE_CTL__POR (0x00000000) -#define SITAR_A_QFUSE_STATUS (0x49) -#define SITAR_A_QFUSE_STATUS__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT0 (0x4A) -#define SITAR_A_QFUSE_DATA_OUT0__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT1 (0x4B) -#define SITAR_A_QFUSE_DATA_OUT1__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT2 (0x4C) -#define SITAR_A_QFUSE_DATA_OUT2__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT3 (0x4D) -#define SITAR_A_QFUSE_DATA_OUT3__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT4 (0x4E) -#define SITAR_A_QFUSE_DATA_OUT4__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT5 (0x4F) -#define SITAR_A_QFUSE_DATA_OUT5__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT6 (0x50) -#define SITAR_A_QFUSE_DATA_OUT6__POR (0x00000000) -#define SITAR_A_QFUSE_DATA_OUT7 (0x51) -#define SITAR_A_QFUSE_DATA_OUT7__POR (0x00000000) -#define SITAR_A_CDC_CTL (0x80) -#define SITAR_A_CDC_CTL__POR (0x00000000) -#define SITAR_A_LEAKAGE_CTL (0x88) -#define SITAR_A_LEAKAGE_CTL__POR (0x00000004) -#define SITAR_A_INTR_MODE (0x90) -#define SITAR_A_INTR_MODE__POR (0x00000000) -#define SITAR_A_INTR_MASK0 (0x94) -#define SITAR_A_INTR_MASK0__POR (0x000000ff) -#define SITAR_A_INTR_MASK1 (0x95) -#define SITAR_A_INTR_MASK1__POR (0x000000ff) -#define SITAR_A_INTR_MASK2 (0x96) -#define SITAR_A_INTR_MASK2__POR (0x000000ff) -#define SITAR_A_INTR_STATUS0 (0x98) -#define SITAR_A_INTR_STATUS0__POR (0x00000000) -#define SITAR_A_INTR_STATUS1 (0x99) -#define SITAR_A_INTR_STATUS1__POR (0x00000000) -#define SITAR_A_INTR_STATUS2 (0x9A) -#define SITAR_A_INTR_STATUS2__POR (0x00000000) -#define SITAR_A_INTR_CLEAR0 (0x9C) -#define SITAR_A_INTR_CLEAR0__POR (0x00000000) -#define SITAR_A_INTR_CLEAR1 (0x9D) -#define SITAR_A_INTR_CLEAR1__POR (0x00000000) -#define SITAR_A_INTR_CLEAR2 (0x9E) -#define SITAR_A_INTR_CLEAR2__POR (0x00000000) -#define SITAR_A_INTR_LEVEL0 (0xA0) -#define SITAR_A_INTR_LEVEL0__POR (0x00000001) -#define SITAR_A_INTR_LEVEL1 (0xA1) -#define SITAR_A_INTR_LEVEL1__POR (0x00000000) -#define SITAR_A_INTR_LEVEL2 (0xA2) -#define SITAR_A_INTR_LEVEL2__POR (0x00000000) -#define SITAR_A_INTR_TEST0 (0xA4) -#define SITAR_A_INTR_TEST0__POR (0x00000000) -#define SITAR_A_INTR_TEST1 (0xA5) -#define SITAR_A_INTR_TEST1__POR (0x00000000) -#define SITAR_A_INTR_TEST2 (0xA6) -#define SITAR_A_INTR_TEST2__POR (0x00000000) -#define SITAR_A_INTR_SET0 (0xA8) -#define SITAR_A_INTR_SET0__POR (0x00000000) -#define SITAR_A_INTR_SET1 (0xA9) -#define SITAR_A_INTR_SET1__POR (0x00000000) -#define SITAR_A_INTR_SET2 (0xAA) -#define SITAR_A_INTR_SET2__POR (0x00000000) -#define SITAR_A_CDC_TX_I2S_SCK_MODE (0xC0) -#define SITAR_A_CDC_TX_I2S_SCK_MODE__POR (0x00000000) -#define SITAR_A_CDC_TX_I2S_WS_MODE (0xC1) -#define SITAR_A_CDC_TX_I2S_WS_MODE__POR (0x00000000) -#define SITAR_A_CDC_DMIC_DATA0_MODE (0xC4) -#define SITAR_A_CDC_DMIC_DATA0_MODE__POR (0x00000000) -#define SITAR_A_CDC_DMIC_CLK0_MODE (0xC5) -#define SITAR_A_CDC_DMIC_CLK0_MODE__POR (0x00000000) -#define SITAR_A_CDC_DMIC_DATA1_MODE (0xC6) -#define SITAR_A_CDC_DMIC_DATA1_MODE__POR (0x00000000) -#define SITAR_A_CDC_DMIC_CLK1_MODE (0xC7) -#define SITAR_A_CDC_DMIC_CLK1_MODE__POR (0x00000000) -#define SITAR_A_CDC_TX_I2S_SD0_MODE (0xC8) -#define SITAR_A_CDC_TX_I2S_SD0_MODE__POR (0x00000000) -#define SITAR_A_CDC_INTR_MODE (0xC9) -#define SITAR_A_CDC_INTR_MODE__POR (0x00000000) -#define SITAR_A_CDC_RX_I2S_SD0_MODE (0xCA) -#define SITAR_A_CDC_RX_I2S_SD0_MODE__POR (0x00000000) -#define SITAR_A_CDC_RX_I2S_SD1_MODE (0xCB) -#define SITAR_A_CDC_RX_I2S_SD1_MODE__POR (0x00000000) -#define SITAR_A_BIAS_REF_CTL (0x100) -#define SITAR_A_BIAS_REF_CTL__POR (0x0000001c) -#define SITAR_A_BIAS_CENTRAL_BG_CTL (0x101) -#define SITAR_A_BIAS_CENTRAL_BG_CTL__POR (0x00000050) -#define SITAR_A_BIAS_PRECHRG_CTL (0x102) -#define SITAR_A_BIAS_PRECHRG_CTL__POR (0x00000007) -#define SITAR_A_BIAS_CURR_CTL_1 (0x103) -#define SITAR_A_BIAS_CURR_CTL_1__POR (0x00000052) -#define SITAR_A_BIAS_CURR_CTL_2 (0x104) -#define SITAR_A_BIAS_CURR_CTL_2__POR (0x00000000) -#define SITAR_A_BIAS_OSC_BG_CTL (0x105) -#define SITAR_A_BIAS_OSC_BG_CTL__POR (0x00000016) -#define SITAR_A_CLK_BUFF_EN1 (0x108) -#define SITAR_A_CLK_BUFF_EN1__POR (0x00000004) -#define SITAR_A_CLK_BUFF_EN2 (0x109) -#define SITAR_A_CLK_BUFF_EN2__POR (0x00000002) -#define SITAR_A_LDO_H_MODE_1 (0x110) -#define SITAR_A_LDO_H_MODE_1__POR (0x00000065) -#define SITAR_A_LDO_H_MODE_2 (0x111) -#define SITAR_A_LDO_H_MODE_2__POR (0x000000a8) -#define SITAR_A_LDO_H_LOOP_CTL (0x112) -#define SITAR_A_LDO_H_LOOP_CTL__POR (0x0000006b) -#define SITAR_A_LDO_H_COMP_1 (0x113) -#define SITAR_A_LDO_H_COMP_1__POR (0x00000084) -#define SITAR_A_LDO_H_COMP_2 (0x114) -#define SITAR_A_LDO_H_COMP_2__POR (0x000000e0) -#define SITAR_A_LDO_H_BIAS_1 (0x115) -#define SITAR_A_LDO_H_BIAS_1__POR (0x0000006d) -#define SITAR_A_LDO_H_BIAS_2 (0x116) -#define SITAR_A_LDO_H_BIAS_2__POR (0x000000a5) -#define SITAR_A_LDO_H_BIAS_3 (0x117) -#define SITAR_A_LDO_H_BIAS_3__POR (0x00000060) -#define SITAR_A_MICB_CFILT_1_CTL (0x128) -#define SITAR_A_MICB_CFILT_1_CTL__POR (0x00000040) -#define SITAR_A_MICB_CFILT_1_VAL (0x129) -#define SITAR_A_MICB_CFILT_1_VAL__POR (0x00000080) -#define SITAR_A_MICB_CFILT_1_PRECHRG (0x12A) -#define SITAR_A_MICB_CFILT_1_PRECHRG__POR (0x00000038) -#define SITAR_A_MICB_1_CTL (0x12B) -#define SITAR_A_MICB_1_CTL__POR (0x00000016) -#define SITAR_A_MICB_1_INT_RBIAS (0x12C) -#define SITAR_A_MICB_1_INT_RBIAS__POR (0x00000024) -#define SITAR_A_MICB_1_MBHC (0x12D) -#define SITAR_A_MICB_1_MBHC__POR (0x00000001) -#define SITAR_A_MICB_CFILT_2_CTL (0x12E) -#define SITAR_A_MICB_CFILT_2_CTL__POR (0x00000040) -#define SITAR_A_MICB_CFILT_2_VAL (0x12F) -#define SITAR_A_MICB_CFILT_2_VAL__POR (0x00000080) -#define SITAR_A_MICB_CFILT_2_PRECHRG (0x130) -#define SITAR_A_MICB_CFILT_2_PRECHRG__POR (0x00000038) -#define SITAR_A_MICB_2_CTL (0x131) -#define SITAR_A_MICB_2_CTL__POR (0x00000016) -#define SITAR_A_MICB_2_INT_RBIAS (0x132) -#define SITAR_A_MICB_2_INT_RBIAS__POR (0x00000024) -#define SITAR_A_MICB_2_MBHC (0x133) -#define SITAR_A_MICB_2_MBHC__POR (0x00000002) -#define SITAR_A_TX_COM_BIAS (0x14C) -#define SITAR_A_TX_COM_BIAS__POR (0x000000e0) -#define SITAR_A_MBHC_SCALING_MUX_1 (0x14E) -#define SITAR_A_MBHC_SCALING_MUX_1__POR (0x00000000) -#define SITAR_A_MBHC_SCALING_MUX_2 (0x14F) -#define SITAR_A_MBHC_SCALING_MUX_2__POR (0x00000080) -#define SITAR_A_TX_SUP_SWITCH_CTRL_1 (0x151) -#define SITAR_A_TX_SUP_SWITCH_CTRL_1__POR (0x00000000) -#define SITAR_A_TX_SUP_SWITCH_CTRL_2 (0x152) -#define SITAR_A_TX_SUP_SWITCH_CTRL_2__POR (0x00000080) -#define SITAR_A_TX_1_2_EN (0x153) -#define SITAR_A_TX_1_2_EN__POR (0x00000000) -#define SITAR_A_TX_1_2_TEST_EN (0x154) -#define SITAR_A_TX_1_2_TEST_EN__POR (0x000000cc) -#define SITAR_A_TX_1_2_ADC_CH1 (0x155) -#define SITAR_A_TX_1_2_ADC_CH1__POR (0x00000044) -#define SITAR_A_TX_1_2_ADC_CH2 (0x156) -#define SITAR_A_TX_1_2_ADC_CH2__POR (0x00000044) -#define SITAR_A_TX_1_2_ATEST_REFCTRL (0x157) -#define SITAR_A_TX_1_2_ATEST_REFCTRL__POR (0x00000000) -#define SITAR_A_TX_1_2_TEST_CTL (0x158) -#define SITAR_A_TX_1_2_TEST_CTL__POR (0x00000038) -#define SITAR_A_TX_1_2_TEST_BLOCK_EN (0x159) -#define SITAR_A_TX_1_2_TEST_BLOCK_EN__POR (0x000000fc) -#define SITAR_A_TX_1_2_TXFE_CLKDIV (0x15A) -#define SITAR_A_TX_1_2_TXFE_CLKDIV__POR (0x000000ee) -#define SITAR_A_TX_1_2_SAR_ERR_CH1 (0x15B) -#define SITAR_A_TX_1_2_SAR_ERR_CH1__POR (0x00000000) -#define SITAR_A_TX_1_2_SAR_ERR_CH2 (0x15C) -#define SITAR_A_TX_1_2_SAR_ERR_CH2__POR (0x00000000) -#define SITAR_A_TX_3_EN (0x15D) -#define SITAR_A_TX_3_EN__POR (0x00000000) -#define SITAR_A_TX_3_TEST_EN (0x15E) -#define SITAR_A_TX_3_TEST_EN__POR (0x000000cc) -#define SITAR_A_TX_3_ADC (0x15F) -#define SITAR_A_TX_3_ADC__POR (0x00000044) -#define SITAR_A_TX_3_MBHC_ATEST_REFCTRL (0x161) -#define SITAR_A_TX_3_MBHC_ATEST_REFCTRL__POR (0x00000000) -#define SITAR_A_TX_3_TEST_CTL (0x162) -#define SITAR_A_TX_3_TEST_CTL__POR (0x00000038) -#define SITAR_A_TX_3_TEST_BLOCK_EN (0x163) -#define SITAR_A_TX_3_TEST_BLOCK_EN__POR (0x000000fc) -#define SITAR_A_TX_3_TXFE_CKDIV (0x164) -#define SITAR_A_TX_3_TXFE_CKDIV__POR (0x000000ee) -#define SITAR_A_TX_3_SAR_ERR (0x165) -#define SITAR_A_TX_3_SAR_ERR__POR (0x00000000) -#define SITAR_A_TX_4_MBHC_EN (0x171) -#define SITAR_A_TX_4_MBHC_EN__POR (0x0000000c) -#define SITAR_A_TX_4_MBHC_ADC (0x173) -#define SITAR_A_TX_4_MBHC_ADC__POR (0x00000044) -#define SITAR_A_TX_4_MBHC_TEST_CTL (0x174) -#define SITAR_A_TX_4_MBHC_TEST_CTL__POR (0x00000038) -#define SITAR_A_TX_4_MBHC_SAR_ERR (0x175) -#define SITAR_A_TX_4_MBHC_SAR_ERR__POR (0x00000000) -#define SITAR_A_TX_4_TXFE_CLKDIV (0x176) -#define SITAR_A_TX_4_TXFE_CLKDIV__POR (0x0000001c) -#define SITAR_A_AUX_COM_CTL (0x180) -#define SITAR_A_AUX_COM_CTL__POR (0x00000034) -#define SITAR_A_AUX_COM_ATEST (0x181) -#define SITAR_A_AUX_COM_ATEST__POR (0x00000000) -#define SITAR_A_AUX_L_EN (0x182) -#define SITAR_A_AUX_L_EN__POR (0x00000000) -#define SITAR_A_AUX_L_GAIN (0x183) -#define SITAR_A_AUX_L_GAIN__POR (0x0000001f) -#define SITAR_A_AUX_L_PA_CONN (0x184) -#define SITAR_A_AUX_L_PA_CONN__POR (0x00000000) -#define SITAR_A_AUX_L_PA_CONN_INV (0x185) -#define SITAR_A_AUX_L_PA_CONN_INV__POR (0x00000000) -#define SITAR_A_AUX_R_EN (0x186) -#define SITAR_A_AUX_R_EN__POR (0x00000000) -#define SITAR_A_AUX_R_GAIN (0x187) -#define SITAR_A_AUX_R_GAIN__POR (0x0000001f) -#define SITAR_A_AUX_R_PA_CONN (0x188) -#define SITAR_A_AUX_R_PA_CONN__POR (0x00000000) -#define SITAR_A_AUX_R_PA_CONN_INV (0x189) -#define SITAR_A_AUX_R_PA_CONN_INV__POR (0x00000000) -#define SITAR_A_CP_EN (0x192) -#define SITAR_A_CP_EN__POR (0x000000e6) -#define SITAR_A_CP_CLK (0x193) -#define SITAR_A_CP_CLK__POR (0x00000029) -#define SITAR_A_CP_STATIC (0x194) -#define SITAR_A_CP_STATIC__POR (0x00000010) -#define SITAR_A_CP_DCC1 (0x195) -#define SITAR_A_CP_DCC1__POR (0x00000052) -#define SITAR_A_CP_DCC3 (0x196) -#define SITAR_A_CP_DCC3__POR (0x00000001) -#define SITAR_A_CP_ATEST (0x197) -#define SITAR_A_CP_ATEST__POR (0x00000000) -#define SITAR_A_CP_DTEST (0x198) -#define SITAR_A_CP_DTEST__POR (0x00000000) -#define SITAR_A_RX_COM_TIMER_DIV (0x19E) -#define SITAR_A_RX_COM_TIMER_DIV__POR (0x000000e8) -#define SITAR_A_RX_COM_OCP_CTL (0x19F) -#define SITAR_A_RX_COM_OCP_CTL__POR (0x0000001f) -#define SITAR_A_RX_COM_OCP_COUNT (0x1A0) -#define SITAR_A_RX_COM_OCP_COUNT__POR (0x00000077) -#define SITAR_A_RX_COM_DAC_CTL (0x1A1) -#define SITAR_A_RX_COM_DAC_CTL__POR (0x00000000) -#define SITAR_A_RX_COM_BIAS (0x1A2) -#define SITAR_A_RX_COM_BIAS__POR (0x00000000) -#define SITAR_A_RX_HPH_BIAS_PA (0x1A6) -#define SITAR_A_RX_HPH_BIAS_PA__POR (0x00000057) -#define SITAR_A_RX_HPH_BIAS_LDO (0x1A7) -#define SITAR_A_RX_HPH_BIAS_LDO__POR (0x00000056) -#define SITAR_A_RX_HPH_BIAS_CNP (0x1A8) -#define SITAR_A_RX_HPH_BIAS_CNP__POR (0x0000008a) -#define SITAR_A_RX_HPH_BIAS_WG (0x1A9) -#define SITAR_A_RX_HPH_BIAS_WG__POR (0x00000060) -#define SITAR_A_RX_HPH_OCP_CTL (0x1AA) -#define SITAR_A_RX_HPH_OCP_CTL__POR (0x000000e8) -#define SITAR_A_RX_HPH_CNP_EN (0x1AB) -#define SITAR_A_RX_HPH_CNP_EN__POR (0x00000080) -#define SITAR_A_RX_HPH_CNP_WG_CTL (0x1AC) -#define SITAR_A_RX_HPH_CNP_WG_CTL__POR (0x000000dc) -#define SITAR_A_RX_HPH_CNP_WG_TIME (0x1AD) -#define SITAR_A_RX_HPH_CNP_WG_TIME__POR (0x00000028) -#define SITAR_A_RX_HPH_L_GAIN (0x1AE) -#define SITAR_A_RX_HPH_L_GAIN__POR (0x00000000) -#define SITAR_A_RX_HPH_L_TEST (0x1AF) -#define SITAR_A_RX_HPH_L_TEST__POR (0x00000001) -#define SITAR_A_RX_HPH_L_PA_CTL (0x1B0) -#define SITAR_A_RX_HPH_L_PA_CTL__POR (0x00000040) -#define SITAR_A_RX_HPH_L_DAC_CTL (0x1B1) -#define SITAR_A_RX_HPH_L_DAC_CTL__POR (0x00000000) -#define SITAR_A_RX_HPH_L_ATEST (0x1B2) -#define SITAR_A_RX_HPH_L_ATEST__POR (0x00000000) -#define SITAR_A_RX_HPH_L_STATUS (0x1B3) -#define SITAR_A_RX_HPH_L_STATUS__POR (0x00000004) -#define SITAR_A_RX_HPH_R_GAIN (0x1B4) -#define SITAR_A_RX_HPH_R_GAIN__POR (0x00000000) -#define SITAR_A_RX_HPH_R_TEST (0x1B5) -#define SITAR_A_RX_HPH_R_TEST__POR (0x00000001) -#define SITAR_A_RX_HPH_R_PA_CTL (0x1B6) -#define SITAR_A_RX_HPH_R_PA_CTL__POR (0x00000040) -#define SITAR_A_RX_HPH_R_DAC_CTL (0x1B7) -#define SITAR_A_RX_HPH_R_DAC_CTL__POR (0x00000000) -#define SITAR_A_RX_HPH_R_ATEST (0x1B8) -#define SITAR_A_RX_HPH_R_ATEST__POR (0x00000000) -#define SITAR_A_RX_HPH_R_STATUS (0x1B9) -#define SITAR_A_RX_HPH_R_STATUS__POR (0x00000004) -#define SITAR_A_RX_EAR_BIAS_PA (0x1BA) -#define SITAR_A_RX_EAR_BIAS_PA__POR (0x000000a6) -#define SITAR_A_RX_EAR_BIAS_CMBUFF (0x1BB) -#define SITAR_A_RX_EAR_BIAS_CMBUFF__POR (0x000000a0) -#define SITAR_A_RX_EAR_EN (0x1BC) -#define SITAR_A_RX_EAR_EN__POR (0x00000000) -#define SITAR_A_RX_EAR_GAIN (0x1BD) -#define SITAR_A_RX_EAR_GAIN__POR (0x00000002) -#define SITAR_A_RX_EAR_CMBUFF (0x1BE) -#define SITAR_A_RX_EAR_CMBUFF__POR (0x00000004) -#define SITAR_A_RX_EAR_ICTL (0x1BF) -#define SITAR_A_RX_EAR_ICTL__POR (0x00000040) -#define SITAR_A_RX_EAR_CCOMP (0x1C0) -#define SITAR_A_RX_EAR_CCOMP__POR (0x00000008) -#define SITAR_A_RX_EAR_VCM (0x1C1) -#define SITAR_A_RX_EAR_VCM__POR (0x00000003) -#define SITAR_A_RX_EAR_CNP (0x1C2) -#define SITAR_A_RX_EAR_CNP__POR (0x000000f2) -#define SITAR_A_RX_EAR_ATEST (0x1C3) -#define SITAR_A_RX_EAR_ATEST__POR (0x00000000) -#define SITAR_A_RX_EAR_STATUS (0x1C5) -#define SITAR_A_RX_EAR_STATUS__POR (0x00000004) -#define SITAR_A_RX_LINE_BIAS_PA (0x1C6) -#define SITAR_A_RX_LINE_BIAS_PA__POR (0x000000aa) -#define SITAR_A_RX_LINE_BIAS_LDO (0x1C7) -#define SITAR_A_RX_LINE_BIAS_LDO__POR (0x00000086) -#define SITAR_A_RX_LINE_BIAS_CNP1 (0x1C8) -#define SITAR_A_RX_LINE_BIAS_CNP1__POR (0x00000060) -#define SITAR_A_RX_LINE_COM (0x1C9) -#define SITAR_A_RX_LINE_COM__POR (0x00000000) -#define SITAR_A_RX_LINE_CNP_EN (0x1CA) -#define SITAR_A_RX_LINE_CNP_EN__POR (0x00000080) -#define SITAR_A_RX_LINE_CNP_WG_CTL (0x1CB) -#define SITAR_A_RX_LINE_CNP_WG_CTL__POR (0x000000dc) -#define SITAR_A_RX_LINE_CNP_WG_TIME (0x1CC) -#define SITAR_A_RX_LINE_CNP_WG_TIME__POR (0x00000028) -#define SITAR_A_RX_LINE_1_GAIN (0x1CD) -#define SITAR_A_RX_LINE_1_GAIN__POR (0x00000000) -#define SITAR_A_RX_LINE_1_TEST (0x1CE) -#define SITAR_A_RX_LINE_1_TEST__POR (0x00000001) -#define SITAR_A_RX_LINE_1_DAC_CTL (0x1CF) -#define SITAR_A_RX_LINE_1_DAC_CTL__POR (0x00000000) -#define SITAR_A_RX_LINE_1_STATUS (0x1D0) -#define SITAR_A_RX_LINE_1_STATUS__POR (0x00000004) -#define SITAR_A_RX_LINE_2_GAIN (0x1D1) -#define SITAR_A_RX_LINE_2_GAIN__POR (0x00000000) -#define SITAR_A_RX_LINE_2_TEST (0x1D2) -#define SITAR_A_RX_LINE_2_TEST__POR (0x00000001) -#define SITAR_A_RX_LINE_2_DAC_CTL (0x1D3) -#define SITAR_A_RX_LINE_2_DAC_CTL__POR (0x00000000) -#define SITAR_A_RX_LINE_2_STATUS (0x1D4) -#define SITAR_A_RX_LINE_2_STATUS__POR (0x00000004) -#define SITAR_A_RX_LINE_BIAS_CNP2 (0x1E1) -#define SITAR_A_RX_LINE_BIAS_CNP2__POR (0x0000008a) -#define SITAR_A_RX_LINE_OCP_CTL (0x1E2) -#define SITAR_A_RX_LINE_OCP_CTL__POR (0x000000e8) -#define SITAR_A_RX_LINE_1_PA_CTL (0x1E3) -#define SITAR_A_RX_LINE_1_PA_CTL__POR (0x00000040) -#define SITAR_A_RX_LINE_2_PA_CTL (0x1E4) -#define SITAR_A_RX_LINE_2_PA_CTL__POR (0x00000040) -#define SITAR_A_RX_LINE_CNP_DBG (0x1EC) -#define SITAR_A_RX_LINE_CNP_DBG__POR (0x00000000) -#define SITAR_A_MBHC_HPH (0x1ED) -#define SITAR_A_MBHC_HPH__POR (0x00000048) -#define SITAR_A_RC_OSC_FREQ (0x1F7) -#define SITAR_A_RC_OSC_FREQ__POR (0x00000046) -#define SITAR_A_RC_OSC_TEST (0x1F8) -#define SITAR_A_RC_OSC_TEST__POR (0x0000000a) -#define SITAR_A_RC_OSC_STATUS (0x1F9) -#define SITAR_A_RC_OSC_STATUS__POR (0x0000001c) -#define SITAR_A_RC_OSC_TUNER (0x1FA) -#define SITAR_A_RC_OSC_TUNER__POR (0x00000000) -#define SITAR_A_CDC_ANC1_CTL (0x200) -#define SITAR_A_CDC_ANC1_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_SHIFT (0x201) -#define SITAR_A_CDC_ANC1_SHIFT__POR (0x00000000) -#define SITAR_A_CDC_ANC1_IIR_B1_CTL (0x202) -#define SITAR_A_CDC_ANC1_IIR_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_IIR_B2_CTL (0x203) -#define SITAR_A_CDC_ANC1_IIR_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_IIR_B3_CTL (0x204) -#define SITAR_A_CDC_ANC1_IIR_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_IIR_B4_CTL (0x205) -#define SITAR_A_CDC_ANC1_IIR_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_LPF_B1_CTL (0x206) -#define SITAR_A_CDC_ANC1_LPF_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_LPF_B2_CTL (0x207) -#define SITAR_A_CDC_ANC1_LPF_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_LPF_B3_CTL (0x208) -#define SITAR_A_CDC_ANC1_LPF_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_SPARE (0x209) -#define SITAR_A_CDC_ANC1_SPARE__POR (0x00000000) -#define SITAR_A_CDC_ANC1_SMLPF_CTL (0x20A) -#define SITAR_A_CDC_ANC1_SMLPF_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC1_DCFLT_CTL (0x20B) -#define SITAR_A_CDC_ANC1_DCFLT_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_CTL (0x280) -#define SITAR_A_CDC_ANC2_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_SHIFT (0x281) -#define SITAR_A_CDC_ANC2_SHIFT__POR (0x00000000) -#define SITAR_A_CDC_ANC2_IIR_B1_CTL (0x282) -#define SITAR_A_CDC_ANC2_IIR_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_IIR_B2_CTL (0x283) -#define SITAR_A_CDC_ANC2_IIR_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_IIR_B3_CTL (0x284) -#define SITAR_A_CDC_ANC2_IIR_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_IIR_B4_CTL (0x285) -#define SITAR_A_CDC_ANC2_IIR_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_LPF_B1_CTL (0x286) -#define SITAR_A_CDC_ANC2_LPF_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_LPF_B2_CTL (0x287) -#define SITAR_A_CDC_ANC2_LPF_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_LPF_B3_CTL (0x288) -#define SITAR_A_CDC_ANC2_LPF_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_SPARE (0x289) -#define SITAR_A_CDC_ANC2_SPARE__POR (0x00000000) -#define SITAR_A_CDC_ANC2_SMLPF_CTL (0x28A) -#define SITAR_A_CDC_ANC2_SMLPF_CTL__POR (0x00000000) -#define SITAR_A_CDC_ANC2_DCFLT_CTL (0x28B) -#define SITAR_A_CDC_ANC2_DCFLT_CTL__POR (0x00000000) - -#define SITAR_A_CDC_TX1_VOL_CTL_TIMER (0x220) -#define SITAR_A_CDC_TX1_VOL_CTL_TIMER__POR (0x00000000) -#define SITAR_A_CDC_TX1_VOL_CTL_GAIN (0x221) -#define SITAR_A_CDC_TX1_VOL_CTL_GAIN__POR (0x00000000) -#define SITAR_A_CDC_TX1_VOL_CTL_CFG (0x222) -#define SITAR_A_CDC_TX1_VOL_CTL_CFG__POR (0x00000000) -#define SITAR_A_CDC_TX1_MUX_CTL (0x223) -#define SITAR_A_CDC_TX1_MUX_CTL__POR (0x00000008) -#define SITAR_A_CDC_TX1_CLK_FS_CTL (0x224) -#define SITAR_A_CDC_TX1_CLK_FS_CTL__POR (0x00000003) -#define SITAR_A_CDC_TX1_DMIC_CTL (0x225) -#define SITAR_A_CDC_TX1_DMIC_CTL__POR (0x00000000) - -#define SITAR_A_CDC_TX2_VOL_CTL_TIMER (0x228) -#define SITAR_A_CDC_TX2_VOL_CTL_TIMER__POR (0x00000000) -#define SITAR_A_CDC_TX2_VOL_CTL_GAIN (0x229) -#define SITAR_A_CDC_TX2_VOL_CTL_GAIN__POR (0x00000000) -#define SITAR_A_CDC_TX2_VOL_CTL_CFG (0x22A) -#define SITAR_A_CDC_TX2_VOL_CTL_CFG__POR (0x00000000) -#define SITAR_A_CDC_TX2_MUX_CTL (0x22B) -#define SITAR_A_CDC_TX2_MUX_CTL__POR (0x00000008) -#define SITAR_A_CDC_TX2_CLK_FS_CTL (0x22C) -#define SITAR_A_CDC_TX2_CLK_FS_CTL__POR (0x00000003) -#define SITAR_A_CDC_TX2_DMIC_CTL (0x22D) -#define SITAR_A_CDC_TX2_DMIC_CTL__POR (0x00000000) - -#define SITAR_A_CDC_TX3_VOL_CTL_TIMER (0x230) -#define SITAR_A_CDC_TX3_VOL_CTL_TIMER__POR (0x00000000) -#define SITAR_A_CDC_TX3_VOL_CTL_GAIN (0x231) -#define SITAR_A_CDC_TX3_VOL_CTL_GAIN__POR (0x00000000) -#define SITAR_A_CDC_TX3_VOL_CTL_CFG (0x232) -#define SITAR_A_CDC_TX3_VOL_CTL_CFG__POR (0x00000000) -#define SITAR_A_CDC_TX3_MUX_CTL (0x233) -#define SITAR_A_CDC_TX3_MUX_CTL__POR (0x00000008) -#define SITAR_A_CDC_TX3_CLK_FS_CTL (0x234) -#define SITAR_A_CDC_TX3_CLK_FS_CTL__POR (0x00000003) -#define SITAR_A_CDC_TX3_DMIC_CTL (0x235) -#define SITAR_A_CDC_TX3_DMIC_CTL__POR (0x00000000) - -#define SITAR_A_CDC_TX4_VOL_CTL_TIMER (0x238) -#define SITAR_A_CDC_TX4_VOL_CTL_TIMER__POR (0x00000000) -#define SITAR_A_CDC_TX4_VOL_CTL_GAIN (0x239) -#define SITAR_A_CDC_TX4_VOL_CTL_GAIN__POR (0x00000000) -#define SITAR_A_CDC_TX4_VOL_CTL_CFG (0x23A) -#define SITAR_A_CDC_TX4_VOL_CTL_CFG__POR (0x00000000) -#define SITAR_A_CDC_TX4_MUX_CTL (0x23B) -#define SITAR_A_CDC_TX4_MUX_CTL__POR (0x00000008) -#define SITAR_A_CDC_TX4_CLK_FS_CTL (0x23C) -#define SITAR_A_CDC_TX4_CLK_FS_CTL__POR (0x00000003) -#define SITAR_A_CDC_TX4_DMIC_CTL (0x23D) -#define SITAR_A_CDC_TX4_DMIC_CTL__POR (0x00000000) - -#define SITAR_A_CDC_TX5_VOL_CTL_TIMER (0x240) -#define SITAR_A_CDC_TX5_VOL_CTL_TIMER__POR (0x00000000) -#define SITAR_A_CDC_TX5_VOL_CTL_GAIN (0x241) -#define SITAR_A_CDC_TX5_VOL_CTL_GAIN__POR (0x00000000) -#define SITAR_A_CDC_TX5_VOL_CTL_CFG (0x242) -#define SITAR_A_CDC_TX5_VOL_CTL_CFG__POR (0x00000000) -#define SITAR_A_CDC_TX5_MUX_CTL (0x243) -#define SITAR_A_CDC_TX5_MUX_CTL__POR (0x00000008) -#define SITAR_A_CDC_TX5_CLK_FS_CTL (0x244) -#define SITAR_A_CDC_TX5_CLK_FS_CTL__POR (0x00000003) -#define SITAR_A_CDC_TX5_DMIC_CTL (0x245) -#define SITAR_A_CDC_TX5_DMIC_CTL__POR (0x00000000) - -#define SITAR_A_CDC_SRC1_PDA_CFG (0x2A0) -#define SITAR_A_CDC_SRC1_PDA_CFG__POR (0x00000000) -#define SITAR_A_CDC_SRC1_FS_CTL (0x2A1) -#define SITAR_A_CDC_SRC1_FS_CTL__POR (0x0000001b) -#define SITAR_A_CDC_SRC2_PDA_CFG (0x2A8) -#define SITAR_A_CDC_SRC2_PDA_CFG__POR (0x00000000) -#define SITAR_A_CDC_SRC2_FS_CTL (0x2A9) -#define SITAR_A_CDC_SRC2_FS_CTL__POR (0x0000001b) - -#define SITAR_A_CDC_RX1_B1_CTL (0x2B0) -#define SITAR_A_CDC_RX1_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX1_B2_CTL (0x2B1) -#define SITAR_A_CDC_RX1_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX1_B3_CTL (0x2B2) -#define SITAR_A_CDC_RX1_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX1_B4_CTL (0x2B3) -#define SITAR_A_CDC_RX1_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX1_B5_CTL (0x2B4) -#define SITAR_A_CDC_RX1_B5_CTL__POR (0x00000078) -#define SITAR_A_CDC_RX1_B6_CTL (0x2B5) -#define SITAR_A_CDC_RX1_B6_CTL__POR (0x00000080) -#define SITAR_A_CDC_RX1_VOL_CTL_B1_CTL (0x2B6) -#define SITAR_A_CDC_RX1_VOL_CTL_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX1_VOL_CTL_B2_CTL (0x2B7) -#define SITAR_A_CDC_RX1_VOL_CTL_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX2_B1_CTL (0x2B8) -#define SITAR_A_CDC_RX2_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX2_B2_CTL (0x2B9) -#define SITAR_A_CDC_RX2_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX2_B3_CTL (0x2BA) -#define SITAR_A_CDC_RX2_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX2_B4_CTL (0x2BB) -#define SITAR_A_CDC_RX2_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX2_B5_CTL (0x2BC) -#define SITAR_A_CDC_RX2_B5_CTL__POR (0x00000078) -#define SITAR_A_CDC_RX2_B6_CTL (0x2BD) -#define SITAR_A_CDC_RX2_B6_CTL__POR (0x00000080) -#define SITAR_A_CDC_RX2_VOL_CTL_B1_CTL (0x2BE) -#define SITAR_A_CDC_RX2_VOL_CTL_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX2_VOL_CTL_B2_CTL (0x2BF) -#define SITAR_A_CDC_RX2_VOL_CTL_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX3_B1_CTL (0x2C0) -#define SITAR_A_CDC_RX3_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX3_B2_CTL (0x2C1) -#define SITAR_A_CDC_RX3_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX3_B3_CTL (0x2C2) -#define SITAR_A_CDC_RX3_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX3_B4_CTL (0x2C3) -#define SITAR_A_CDC_RX3_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX3_B5_CTL (0x2C4) -#define SITAR_A_CDC_RX3_B5_CTL__POR (0x00000078) -#define SITAR_A_CDC_RX3_B6_CTL (0x2C5) -#define SITAR_A_CDC_RX3_B6_CTL__POR (0x00000080) -#define SITAR_A_CDC_RX3_VOL_CTL_B1_CTL (0x2C6) -#define SITAR_A_CDC_RX3_VOL_CTL_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_RX3_VOL_CTL_B2_CTL (0x2C7) -#define SITAR_A_CDC_RX3_VOL_CTL_B2_CTL__POR (0x00000000) - -#define SITAR_A_CDC_CLK_ANC_RESET_CTL (0x300) -#define SITAR_A_CDC_CLK_ANC_RESET_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_RX_RESET_CTL (0x301) -#define SITAR_A_CDC_CLK_RX_RESET_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_TX_RESET_B1_CTL (0x302) -#define SITAR_A_CDC_CLK_TX_RESET_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_TX_RESET_B2_CTL (0x303) -#define SITAR_A_CDC_CLK_TX_RESET_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_DMIC_CTL (0x304) -#define SITAR_A_CDC_CLK_DMIC_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_RX_I2S_CTL (0x305) -#define SITAR_A_CDC_CLK_RX_I2S_CTL__POR (0x00000003) -#define SITAR_A_CDC_CLK_TX_I2S_CTL (0x306) -#define SITAR_A_CDC_CLK_TX_I2S_CTL__POR (0x00000003) -#define SITAR_A_CDC_CLK_OTHR_RESET_CTL (0x307) -#define SITAR_A_CDC_CLK_OTHR_RESET_CTL__POR (0x00000010) -#define SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL (0x308) -#define SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_OTHR_CTL (0x30A) -#define SITAR_A_CDC_CLK_OTHR_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_RDAC_CLK_EN_CTL (0x30B) -#define SITAR_A_CDC_CLK_RDAC_CLK_EN_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_ANC_CLK_EN_CTL (0x30C) -#define SITAR_A_CDC_CLK_ANC_CLK_EN_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_RX_B1_CTL (0x30D) -#define SITAR_A_CDC_CLK_RX_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_RX_B2_CTL (0x30E) -#define SITAR_A_CDC_CLK_RX_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_MCLK_CTL (0x30F) -#define SITAR_A_CDC_CLK_MCLK_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_PDM_CTL (0x310) -#define SITAR_A_CDC_CLK_PDM_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_SD_CTL (0x311) -#define SITAR_A_CDC_CLK_SD_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLK_LP_CTL (0x312) -#define SITAR_A_CDC_CLK_LP_CTL__POR (0x00000000) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B1_CTL (0x320) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B1_CTL__POR (0x00000007) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B2_CTL (0x321) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B2_CTL__POR (0x00000013) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B3_CTL (0x322) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B3_CTL__POR (0x0000001b) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B4_CTL (0x323) -#define SITAR_A_CDC_CLSG_FREQ_THRESH_B4_CTL__POR (0x0000007f) -#define SITAR_A_CDC_CLSG_GAIN_THRESH_CTL (0x324) -#define SITAR_A_CDC_CLSG_GAIN_THRESH_CTL__POR (0x00000026) -#define SITAR_A_CDC_CLSG_TIMER_B1_CFG (0x325) -#define SITAR_A_CDC_CLSG_TIMER_B1_CFG__POR (0x0000000a) -#define SITAR_A_CDC_CLSG_TIMER_B2_CFG (0x326) -#define SITAR_A_CDC_CLSG_TIMER_B2_CFG__POR (0x00000000) -#define SITAR_A_CDC_CLSG_CTL (0x327) -#define SITAR_A_CDC_CLSG_CTL__POR (0x00000013) -#define SITAR_A_CDC_IIR1_GAIN_B1_CTL (0x340) -#define SITAR_A_CDC_IIR1_GAIN_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_GAIN_B2_CTL (0x341) -#define SITAR_A_CDC_IIR1_GAIN_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_GAIN_B3_CTL (0x342) -#define SITAR_A_CDC_IIR1_GAIN_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_GAIN_B4_CTL (0x343) -#define SITAR_A_CDC_IIR1_GAIN_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_GAIN_B5_CTL (0x344) -#define SITAR_A_CDC_IIR1_GAIN_B5_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_GAIN_B6_CTL (0x345) -#define SITAR_A_CDC_IIR1_GAIN_B6_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_GAIN_B7_CTL (0x346) -#define SITAR_A_CDC_IIR1_GAIN_B7_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_GAIN_B8_CTL (0x347) -#define SITAR_A_CDC_IIR1_GAIN_B8_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_CTL (0x348) -#define SITAR_A_CDC_IIR1_CTL__POR (0x00000040) -#define SITAR_A_CDC_IIR1_GAIN_TIMER_CTL (0x349) -#define SITAR_A_CDC_IIR1_GAIN_TIMER_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_COEF_B1_CTL (0x34A) -#define SITAR_A_CDC_IIR1_COEF_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_COEF_B2_CTL (0x34B) -#define SITAR_A_CDC_IIR1_COEF_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_COEF_B3_CTL (0x34C) -#define SITAR_A_CDC_IIR1_COEF_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_COEF_B4_CTL (0x34D) -#define SITAR_A_CDC_IIR1_COEF_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR1_COEF_B5_CTL (0x34E) -#define SITAR_A_CDC_IIR1_COEF_B5_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B1_CTL (0x350) -#define SITAR_A_CDC_IIR2_GAIN_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B2_CTL (0x351) -#define SITAR_A_CDC_IIR2_GAIN_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B3_CTL (0x352) -#define SITAR_A_CDC_IIR2_GAIN_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B4_CTL (0x353) -#define SITAR_A_CDC_IIR2_GAIN_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B5_CTL (0x354) -#define SITAR_A_CDC_IIR2_GAIN_B5_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B6_CTL (0x355) -#define SITAR_A_CDC_IIR2_GAIN_B6_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B7_CTL (0x356) -#define SITAR_A_CDC_IIR2_GAIN_B7_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_GAIN_B8_CTL (0x357) -#define SITAR_A_CDC_IIR2_GAIN_B8_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_CTL (0x358) -#define SITAR_A_CDC_IIR2_CTL__POR (0x00000040) -#define SITAR_A_CDC_IIR2_GAIN_TIMER_CTL (0x359) -#define SITAR_A_CDC_IIR2_GAIN_TIMER_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_COEF_B1_CTL (0x35A) -#define SITAR_A_CDC_IIR2_COEF_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_COEF_B2_CTL (0x35B) -#define SITAR_A_CDC_IIR2_COEF_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_COEF_B3_CTL (0x35C) -#define SITAR_A_CDC_IIR2_COEF_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_COEF_B4_CTL (0x35D) -#define SITAR_A_CDC_IIR2_COEF_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_IIR2_COEF_B5_CTL (0x35E) -#define SITAR_A_CDC_IIR2_COEF_B5_CTL__POR (0x00000000) -#define SITAR_A_CDC_TOP_GAIN_UPDATE (0x360) -#define SITAR_A_CDC_TOP_GAIN_UPDATE__POR (0x00000000) -#define SITAR_A_CDC_TOP_RDAC_DOUT_CTL (0x361) -#define SITAR_A_CDC_TOP_RDAC_DOUT_CTL__POR (0x00000000) -#define SITAR_A_CDC_DEBUG_B1_CTL (0x368) -#define SITAR_A_CDC_DEBUG_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_DEBUG_B2_CTL (0x369) -#define SITAR_A_CDC_DEBUG_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_DEBUG_B3_CTL (0x36A) -#define SITAR_A_CDC_DEBUG_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_DEBUG_B4_CTL (0x36B) -#define SITAR_A_CDC_DEBUG_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_DEBUG_B5_CTL (0x36C) -#define SITAR_A_CDC_DEBUG_B5_CTL__POR (0x00000000) -#define SITAR_A_CDC_DEBUG_B6_CTL (0x36D) -#define SITAR_A_CDC_DEBUG_B6_CTL__POR (0x00000000) -#define SITAR_A_CDC_DEBUG_B7_CTL (0x36E) -#define SITAR_A_CDC_DEBUG_B7_CTL__POR (0x00000000) -#define SITAR_A_CDC_COMP1_B1_CTL (0x370) -#define SITAR_A_CDC_COMP1_B1_CTL__POR (0x00000030) -#define SITAR_A_CDC_COMP1_B2_CTL (0x371) -#define SITAR_A_CDC_COMP1_B2_CTL__POR (0x000000b5) -#define SITAR_A_CDC_COMP1_B3_CTL (0x372) -#define SITAR_A_CDC_COMP1_B3_CTL__POR (0x00000028) -#define SITAR_A_CDC_COMP1_B4_CTL (0x373) -#define SITAR_A_CDC_COMP1_B4_CTL__POR (0x0000003c) -#define SITAR_A_CDC_COMP1_B5_CTL (0x374) -#define SITAR_A_CDC_COMP1_B5_CTL__POR (0x0000001f) -#define SITAR_A_CDC_COMP1_B6_CTL (0x375) -#define SITAR_A_CDC_COMP1_B6_CTL__POR (0x00000000) -#define SITAR_A_CDC_COMP1_SHUT_DOWN_STATUS (0x376) -#define SITAR_A_CDC_COMP1_SHUT_DOWN_STATUS__POR (0x00000003) -#define SITAR_A_CDC_COMP1_FS_CFG (0x377) -#define SITAR_A_CDC_COMP1_FS_CFG__POR (0x0000001b) -#define SITAR_A_CDC_COMP2_B1_CTL (0x378) -#define SITAR_A_CDC_COMP2_B1_CTL__POR (0x00000030) -#define SITAR_A_CDC_COMP2_B2_CTL (0x379) -#define SITAR_A_CDC_COMP2_B2_CTL__POR (0x000000b5) -#define SITAR_A_CDC_COMP2_B3_CTL (0x37A) -#define SITAR_A_CDC_COMP2_B3_CTL__POR (0x00000028) -#define SITAR_A_CDC_COMP2_B4_CTL (0x37B) -#define SITAR_A_CDC_COMP2_B4_CTL__POR (0x0000003c) -#define SITAR_A_CDC_COMP2_B5_CTL (0x37C) -#define SITAR_A_CDC_COMP2_B5_CTL__POR (0x0000001f) -#define SITAR_A_CDC_COMP2_B6_CTL (0x37D) -#define SITAR_A_CDC_COMP2_B6_CTL__POR (0x00000000) -#define SITAR_A_CDC_COMP2_SHUT_DOWN_STATUS (0x37E) -#define SITAR_A_CDC_COMP2_SHUT_DOWN_STATUS__POR (0x00000003) -#define SITAR_A_CDC_COMP2_FS_CFG (0x37F) -#define SITAR_A_CDC_COMP2_FS_CFG__POR (0x0000001b) -#define SITAR_A_CDC_CONN_RX1_B1_CTL (0x380) -#define SITAR_A_CDC_CONN_RX1_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX1_B2_CTL (0x381) -#define SITAR_A_CDC_CONN_RX1_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX1_B3_CTL (0x382) -#define SITAR_A_CDC_CONN_RX1_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX2_B1_CTL (0x383) -#define SITAR_A_CDC_CONN_RX2_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX2_B2_CTL (0x384) -#define SITAR_A_CDC_CONN_RX2_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX2_B3_CTL (0x385) -#define SITAR_A_CDC_CONN_RX2_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX3_B1_CTL (0x386) -#define SITAR_A_CDC_CONN_RX3_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX3_B2_CTL (0x387) -#define SITAR_A_CDC_CONN_RX3_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX3_B3_CTL (0x388) -#define SITAR_A_CDC_CONN_RX3_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_ANC_B1_CTL (0x391) -#define SITAR_A_CDC_CONN_ANC_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_ANC_B2_CTL (0x392) -#define SITAR_A_CDC_CONN_ANC_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_TX_B1_CTL (0x393) -#define SITAR_A_CDC_CONN_TX_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_TX_B2_CTL (0x394) -#define SITAR_A_CDC_CONN_TX_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ1_B1_CTL (0x397) -#define SITAR_A_CDC_CONN_EQ1_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ1_B2_CTL (0x398) -#define SITAR_A_CDC_CONN_EQ1_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ1_B3_CTL (0x399) -#define SITAR_A_CDC_CONN_EQ1_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ1_B4_CTL (0x39A) -#define SITAR_A_CDC_CONN_EQ1_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ2_B1_CTL (0x39B) -#define SITAR_A_CDC_CONN_EQ2_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ2_B2_CTL (0x39C) -#define SITAR_A_CDC_CONN_EQ2_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ2_B3_CTL (0x39D) -#define SITAR_A_CDC_CONN_EQ2_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_EQ2_B4_CTL (0x39E) -#define SITAR_A_CDC_CONN_EQ2_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_SRC1_B1_CTL (0x39F) -#define SITAR_A_CDC_CONN_SRC1_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_SRC1_B2_CTL (0x3A0) -#define SITAR_A_CDC_CONN_SRC1_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_SRC2_B1_CTL (0x3A1) -#define SITAR_A_CDC_CONN_SRC2_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_SRC2_B2_CTL (0x3A2) -#define SITAR_A_CDC_CONN_SRC2_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_TX_SB_B1_CTL (0x3A3) -#define SITAR_A_CDC_CONN_TX_SB_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_TX_SB_B2_CTL (0x3A4) -#define SITAR_A_CDC_CONN_TX_SB_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_TX_SB_B3_CTL (0x3A5) -#define SITAR_A_CDC_CONN_TX_SB_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_TX_SB_B4_CTL (0x3A6) -#define SITAR_A_CDC_CONN_TX_SB_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_TX_SB_B5_CTL (0x3A7) -#define SITAR_A_CDC_CONN_TX_SB_B5_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX_SB_B1_CTL (0x3AE) -#define SITAR_A_CDC_CONN_RX_SB_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_RX_SB_B2_CTL (0x3AF) -#define SITAR_A_CDC_CONN_RX_SB_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_CLSG_CTL (0x3B0) -#define SITAR_A_CDC_CONN_CLSG_CTL__POR (0x00000000) -#define SITAR_A_CDC_CONN_SPARE (0x3B1) -#define SITAR_A_CDC_CONN_SPARE__POR (0x00000000) -#define SITAR_A_CDC_MBHC_EN_CTL (0x3C0) -#define SITAR_A_CDC_MBHC_EN_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_FIR_B1_CFG (0x3C1) -#define SITAR_A_CDC_MBHC_FIR_B1_CFG__POR (0x00000000) -#define SITAR_A_CDC_MBHC_FIR_B2_CFG (0x3C2) -#define SITAR_A_CDC_MBHC_FIR_B2_CFG__POR (0x00000006) -#define SITAR_A_CDC_MBHC_TIMER_B1_CTL (0x3C3) -#define SITAR_A_CDC_MBHC_TIMER_B1_CTL__POR (0x00000003) -#define SITAR_A_CDC_MBHC_TIMER_B2_CTL (0x3C4) -#define SITAR_A_CDC_MBHC_TIMER_B2_CTL__POR (0x00000009) -#define SITAR_A_CDC_MBHC_TIMER_B3_CTL (0x3C5) -#define SITAR_A_CDC_MBHC_TIMER_B3_CTL__POR (0x0000001e) -#define SITAR_A_CDC_MBHC_TIMER_B4_CTL (0x3C6) -#define SITAR_A_CDC_MBHC_TIMER_B4_CTL__POR (0x00000045) -#define SITAR_A_CDC_MBHC_TIMER_B5_CTL (0x3C7) -#define SITAR_A_CDC_MBHC_TIMER_B5_CTL__POR (0x00000004) -#define SITAR_A_CDC_MBHC_TIMER_B6_CTL (0x3C8) -#define SITAR_A_CDC_MBHC_TIMER_B6_CTL__POR (0x00000078) -#define SITAR_A_CDC_MBHC_B1_STATUS (0x3C9) -#define SITAR_A_CDC_MBHC_B1_STATUS__POR (0x00000000) -#define SITAR_A_CDC_MBHC_B2_STATUS (0x3CA) -#define SITAR_A_CDC_MBHC_B2_STATUS__POR (0x00000000) -#define SITAR_A_CDC_MBHC_B3_STATUS (0x3CB) -#define SITAR_A_CDC_MBHC_B3_STATUS__POR (0x00000000) -#define SITAR_A_CDC_MBHC_B4_STATUS (0x3CC) -#define SITAR_A_CDC_MBHC_B4_STATUS__POR (0x00000000) -#define SITAR_A_CDC_MBHC_B5_STATUS (0x3CD) -#define SITAR_A_CDC_MBHC_B5_STATUS__POR (0x00000000) -#define SITAR_A_CDC_MBHC_B1_CTL (0x3CE) -#define SITAR_A_CDC_MBHC_B1_CTL__POR (0x000000c0) -#define SITAR_A_CDC_MBHC_B2_CTL (0x3CF) -#define SITAR_A_CDC_MBHC_B2_CTL__POR (0x0000005d) -#define SITAR_A_CDC_MBHC_VOLT_B1_CTL (0x3D0) -#define SITAR_A_CDC_MBHC_VOLT_B1_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_VOLT_B2_CTL (0x3D1) -#define SITAR_A_CDC_MBHC_VOLT_B2_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_VOLT_B3_CTL (0x3D2) -#define SITAR_A_CDC_MBHC_VOLT_B3_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_VOLT_B4_CTL (0x3D3) -#define SITAR_A_CDC_MBHC_VOLT_B4_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_VOLT_B5_CTL (0x3D4) -#define SITAR_A_CDC_MBHC_VOLT_B5_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_VOLT_B6_CTL (0x3D5) -#define SITAR_A_CDC_MBHC_VOLT_B6_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_VOLT_B7_CTL (0x3D6) -#define SITAR_A_CDC_MBHC_VOLT_B7_CTL__POR (0x000000ff) -#define SITAR_A_CDC_MBHC_VOLT_B8_CTL (0x3D7) -#define SITAR_A_CDC_MBHC_VOLT_B8_CTL__POR (0x00000007) -#define SITAR_A_CDC_MBHC_VOLT_B9_CTL (0x3D8) -#define SITAR_A_CDC_MBHC_VOLT_B9_CTL__POR (0x000000ff) -#define SITAR_A_CDC_MBHC_VOLT_B10_CTL (0x3D9) -#define SITAR_A_CDC_MBHC_VOLT_B10_CTL__POR (0x0000007f) -#define SITAR_A_CDC_MBHC_VOLT_B11_CTL (0x3DA) -#define SITAR_A_CDC_MBHC_VOLT_B11_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_VOLT_B12_CTL (0x3DB) -#define SITAR_A_CDC_MBHC_VOLT_B12_CTL__POR (0x00000080) -#define SITAR_A_CDC_MBHC_CLK_CTL (0x3DC) -#define SITAR_A_CDC_MBHC_CLK_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_INT_CTL (0x3DD) -#define SITAR_A_CDC_MBHC_INT_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_DEBUG_CTL (0x3DE) -#define SITAR_A_CDC_MBHC_DEBUG_CTL__POR (0x00000000) -#define SITAR_A_CDC_MBHC_SPARE (0x3DF) -#define SITAR_A_CDC_MBHC_SPARE__POR (0x00000000) -/* SLIMBUS Slave Registers */ -#define SITAR_SLIM_PGD_PORT_INT_EN0 (0x30) -#define SITAR_SLIM_PGD_PORT_INT_STATUS0 (0x34) -#define SITAR_SLIM_PGD_PORT_INT_CLR0 (0x38) -#define SITAR_SLIM_PGD_PORT_INT_SOURCE0 (0x60) - -/* Macros for Packing Register Writes into a U32 */ -#define SITAR_PACKED_REG_SIZE sizeof(u32) - -#define SITAR_CODEC_PACK_ENTRY(reg, mask, val) ((val & 0xff)|\ - ((mask & 0xff) << 8)|((reg & 0xffff) << 16)) - -#define SITAR_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \ - do { \ - ((reg) = ((packed >> 16) & (0xffff))); \ - ((mask) = ((packed >> 8) & (0xff))); \ - ((val) = ((packed) & (0xff))); \ - } while (0); -#endif diff --git a/include/linux/msm-charger.h b/include/linux/msm-charger.h deleted file mode 100644 index 93ed7cfd76bf32cb47a74f3c2fcf110fc0fa26a4..0000000000000000000000000000000000000000 --- a/include/linux/msm-charger.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __MSM_CHARGER_H__ -#define __MSM_CHARGER_H__ - -#include - -enum { - CHG_TYPE_USB, - CHG_TYPE_AC -}; - -enum msm_hardware_charger_event { - CHG_INSERTED_EVENT, - CHG_ENUMERATED_EVENT, - CHG_REMOVED_EVENT, - CHG_DONE_EVENT, - CHG_BATT_BEGIN_FAST_CHARGING, - CHG_BATT_CHG_RESUME, - CHG_BATT_TEMP_OUTOFRANGE, - CHG_BATT_TEMP_INRANGE, - CHG_BATT_INSERTED, - CHG_BATT_REMOVED, - CHG_BATT_STATUS_CHANGE, - CHG_BATT_NEEDS_RECHARGING, -}; - -/** - * enum hardware_charger_state - * @CHG_ABSENT_STATE: charger cable is unplugged - * @CHG_PRESENT_STATE: charger cable is plugged but charge current isnt drawn - * @CHG_READY_STATE: charger cable is plugged and kernel knows how much current - * it can draw - * @CHG_CHARGING_STATE: charger cable is plugged and current is drawn for - * charging - */ -enum msm_hardware_charger_state { - CHG_ABSENT_STATE, - CHG_PRESENT_STATE, - CHG_READY_STATE, - CHG_CHARGING_STATE, -}; - -struct msm_hardware_charger { - int type; - int rating; - const char *name; - int (*start_charging) (struct msm_hardware_charger *hw_chg, - int chg_voltage, int chg_current); - int (*stop_charging) (struct msm_hardware_charger *hw_chg); - int (*charging_switched) (struct msm_hardware_charger *hw_chg); - void (*start_system_current) (struct msm_hardware_charger *hw_chg, - int chg_current); - void (*stop_system_current) (struct msm_hardware_charger *hw_chg); - - void *charger_private; /* used by the msm_charger.c */ -}; - -struct msm_battery_gauge { - int (*get_battery_mvolts) (void); - int (*get_battery_temperature) (void); - int (*is_battery_present) (void); - int (*is_battery_temp_within_range) (void); - int (*is_battery_id_valid) (void); - int (*get_battery_status)(void); - int (*get_batt_remaining_capacity) (void); - int (*monitor_for_recharging) (void); -}; -/** - * struct msm_charger_platform_data - * @safety_time: max charging time in minutes - * @update_time: how often the userland be updated of the charging progress - * @max_voltage: the max voltage the battery should be charged upto - * @min_voltage: the voltage where charging method switches from trickle to fast - * @get_batt_capacity_percent: a board specific function to return battery - * capacity. Can be null - a default one will be used - */ -struct msm_charger_platform_data { - unsigned int safety_time; - unsigned int update_time; - unsigned int max_voltage; - unsigned int min_voltage; - unsigned int (*get_batt_capacity_percent) (void); -}; - -typedef void (*notify_vbus_state) (int); -#if defined(CONFIG_BATTERY_MSM8X60) || defined(CONFIG_BATTERY_MSM8X60_MODULE) -void msm_battery_gauge_register(struct msm_battery_gauge *batt_gauge); -void msm_battery_gauge_unregister(struct msm_battery_gauge *batt_gauge); -int msm_charger_register(struct msm_hardware_charger *hw_chg); -int msm_charger_unregister(struct msm_hardware_charger *hw_chg); -int msm_charger_notify_event(struct msm_hardware_charger *hw_chg, - enum msm_hardware_charger_event event); -void msm_charger_vbus_draw(unsigned int mA); - -int msm_charger_register_vbus_sn(void (*callback)(int)); -void msm_charger_unregister_vbus_sn(void (*callback)(int)); -#else -static inline void msm_battery_gauge_register(struct msm_battery_gauge *gauge) -{ -} -static inline void msm_battery_gauge_unregister(struct msm_battery_gauge *gauge) -{ -} -static inline int msm_charger_register(struct msm_hardware_charger *hw_chg) -{ - return -ENXIO; -} -static inline int msm_charger_unregister(struct msm_hardware_charger *hw_chg) -{ - return -ENXIO; -} -static inline int msm_charger_notify_event(struct msm_hardware_charger *hw_chg, - enum msm_hardware_charger_event event) -{ - return -ENXIO; -} -static inline void msm_charger_vbus_draw(unsigned int mA) -{ -} -static inline int msm_charger_register_vbus_sn(void (*callback)(int)) -{ - return -ENXIO; -} -static inline void msm_charger_unregister_vbus_sn(void (*callback)(int)) -{ -} -#endif -#endif /* __MSM_CHARGER_H__ */ diff --git a/include/linux/msm_adc.h b/include/linux/msm_adc.h deleted file mode 100644 index 7d793848f20d3bc5f6e7128f7b46f93af1bce6b8..0000000000000000000000000000000000000000 --- a/include/linux/msm_adc.h +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef __MSM_ADC_H -#define __MSM_ADC_H - -#include - -#define MSM_ADC_MAX_NUM_DEVS 3 - -enum { - ADC_CONFIG_TYPE1, - ADC_CONFIG_TYPE2, - ADC_CONFIG_NONE = 0xffffffff -}; - -enum { - ADC_CALIB_CONFIG_TYPE1, - ADC_CALIB_CONFIG_TYPE2, - ADC_CALIB_CONFIG_TYPE3, - ADC_CALIB_CONFIG_TYPE4, - ADC_CALIB_CONFIG_TYPE5, - ADC_CALIB_CONFIG_TYPE6, - ADC_CALIB_CONFIG_TYPE7, - ADC_CALIB_CONFIG_NONE = 0xffffffff -}; - -enum { - /* CHAN_PATH_TYPEn is specific for each ADC driver - and can be used however way it wants*/ - CHAN_PATH_TYPE1, - CHAN_PATH_TYPE2, - CHAN_PATH_TYPE3, - CHAN_PATH_TYPE4, - CHAN_PATH_TYPE5, - CHAN_PATH_TYPE6, - CHAN_PATH_TYPE7, - CHAN_PATH_TYPE8, - CHAN_PATH_TYPE9, - CHAN_PATH_TYPE10, - CHAN_PATH_TYPE11, - CHAN_PATH_TYPE12, - CHAN_PATH_TYPE13, - CHAN_PATH_TYPE14, - CHAN_PATH_TYPE15, - CHAN_PATH_TYPE16, - /* A given channel connects directly to the ADC */ - CHAN_PATH_TYPE_NONE = 0xffffffff -}; - -#define CHANNEL_ADC_BATT_ID 0 -#define CHANNEL_ADC_BATT_THERM 1 -#define CHANNEL_ADC_BATT_AMON 2 -#define CHANNEL_ADC_VBATT 3 -#define CHANNEL_ADC_VCOIN 4 -#define CHANNEL_ADC_VCHG 5 -#define CHANNEL_ADC_CHG_MONITOR 6 -#define CHANNEL_ADC_VPH_PWR 7 -#define CHANNEL_ADC_USB_VBUS 8 -#define CHANNEL_ADC_DIE_TEMP 9 -#define CHANNEL_ADC_DIE_TEMP_4K 0xa -#define CHANNEL_ADC_XOTHERM 0xb -#define CHANNEL_ADC_XOTHERM_4K 0xc -#define CHANNEL_ADC_HDSET 0xd -#define CHANNEL_ADC_MSM_THERM 0xe -#define CHANNEL_ADC_625_REF 0xf -#define CHANNEL_ADC_1250_REF 0x10 -#define CHANNEL_ADC_325_REF 0x11 -#define CHANNEL_ADC_FSM_THERM 0x12 -#define CHANNEL_ADC_PA_THERM 0x13 - -enum { - CALIB_STARTED, - CALIB_NOT_REQUIRED = 0xffffffff, -}; - -struct linear_graph { - int32_t offset; - int32_t dy; /* Slope numerator */ - int32_t dx; /* Slope denominator */ -}; - -struct adc_map_pt { - int32_t x; - int32_t y; -}; - -struct adc_properties { - uint32_t adc_reference; /* milli-voltage for this adc */ - uint32_t bitresolution; - bool bipolar; - uint32_t conversiontime; -}; - -struct chan_properties { - uint32_t gain_numerator; - uint32_t gain_denominator; - struct linear_graph *adc_graph; -/* this maybe the same as adc_properties.ConversionTime - if channel does not change the adc properties */ - uint32_t chan_conv_time; -}; - -struct msm_adc_channels { - char *name; - uint32_t channel_name; - uint32_t adc_dev_instance; - struct adc_access_fn *adc_access_fn; - uint32_t chan_path_type; - uint32_t adc_config_type; - uint32_t adc_calib_type; - int32_t (*chan_processor)(int32_t, const struct adc_properties *, - const struct chan_properties *, struct adc_chan_result *); - -}; - -struct msm_adc_platform_data { - struct msm_adc_channels *channel; - uint32_t num_chan_supported; - uint32_t num_adc; - uint32_t chan_per_adc; - char **dev_names; - uint32_t target_hw; - uint32_t gpio_config; - u32 (*adc_gpio_enable) (int); - u32 (*adc_gpio_disable) (int); - u32 (*adc_fluid_enable) (void); - u32 (*adc_fluid_disable) (void); -}; - -enum hw_type { - MSM_7x30, - MSM_8x60, - FSM_9xxx, - MSM_8x25, -}; - -enum epm_gpio_config { - MPROC_CONFIG, - APROC_CONFIG -}; - -enum adc_request { - START_OF_CONV, - END_OF_CONV, - START_OF_CALIBRATION, - END_OF_CALIBRATION, -}; - -struct adc_dev_spec { - uint32_t hwmon_dev_idx; - struct dal_dev_spec { - uint32_t dev_idx; - uint32_t chan_idx; - } dal; -}; - -struct dal_conv_request { - struct dal_dev_spec target; - void *cb_h; -}; - -struct dal_adc_result { - uint32_t status; - uint32_t token; - uint32_t dev_idx; - uint32_t chan_idx; - int physical; - uint32_t percent; - uint32_t microvolts; - uint32_t reserved; -}; - -struct dal_conv_slot { - void *cb_h; - struct dal_adc_result result; - struct completion comp; - struct list_head list; - uint32_t idx; - uint32_t chan_idx; - bool blocking; - struct msm_client_data *client; -}; - -struct dal_translation { - uint32_t dal_dev_idx; - uint32_t hwmon_dev_idx; - uint32_t hwmon_start; - uint32_t hwmon_end; -}; - -struct msm_client_data { - struct list_head complete_list; - bool online; - int32_t adc_chan; - uint32_t num_complete; - uint32_t num_outstanding; - wait_queue_head_t data_wait; - wait_queue_head_t outst_wait; - struct mutex lock; -}; - -struct adc_conv_slot { - void *cb_h; - union { - struct adc_chan_result result; - struct dal_adc_result dal_result; - } conv; - struct completion comp; - struct completion *compk; - struct list_head list; - uint32_t idx; - enum adc_request adc_request; - bool blocking; - struct msm_client_data *client; - struct work_struct work; - struct chan_properties chan_properties; - uint32_t chan_path; - uint32_t chan_adc_config; - uint32_t chan_adc_calib; -}; - -struct adc_access_fn { - int32_t (*adc_select_chan_and_start_conv)(uint32_t, - struct adc_conv_slot*); - int32_t (*adc_read_adc_code)(uint32_t dev_instance, int32_t *data); - struct adc_properties *(*adc_get_properties)(uint32_t dev_instance); - void (*adc_slot_request)(uint32_t dev_instance, - struct adc_conv_slot **); - void (*adc_restore_slot)(uint32_t dev_instance, - struct adc_conv_slot *slot); - int32_t (*adc_calibrate)(uint32_t dev_instance, struct adc_conv_slot*, - int *); -}; - -void msm_adc_wq_work(struct work_struct *work); -void msm_adc_conv_cb(void *context, u32 param, void *evt_buf, u32 len); -#ifdef CONFIG_SENSORS_MSM_ADC -int32_t adc_channel_open(uint32_t channel, void **h); -int32_t adc_channel_close(void *h); -int32_t adc_channel_request_conv(void *h, struct completion *conv_complete_evt); -int32_t adc_channel_read_result(void *h, struct adc_chan_result *chan_result); -#else -static inline int32_t adc_channel_open(uint32_t channel, void **h) -{ - pr_err("%s.not supported.\n", __func__); - return -ENODEV; -} -static inline int32_t adc_channel_close(void *h) -{ - pr_err("%s.not supported.\n", __func__); - return -ENODEV; -} -static inline int32_t -adc_channel_request_conv(void *h, struct completion *conv_complete_evt) -{ - pr_err("%s.not supported.\n", __func__); - return -ENODEV; -} -static inline int32_t -adc_channel_read_result(void *h, struct adc_chan_result *chan_result) -{ - pr_err("%s.not supported.\n", __func__); - return -ENODEV; -} -#endif /* CONFIG_SENSORS_MSM_ADC */ -#endif /* __MSM_ADC_H */ diff --git a/include/linux/msm_rpcrouter.h b/include/linux/msm_rpcrouter.h deleted file mode 100644 index cd304f3f88aae1042c804cecc05a2faa547e3c13..0000000000000000000000000000000000000000 --- a/include/linux/msm_rpcrouter.h +++ /dev/null @@ -1,50 +0,0 @@ -/* include/linux/msm_rpcrouter.h - * - * Copyright (c) 2009, The Linux Foundation. All rights reserved. - * Copyright (C) 2007 Google, Inc. - * Author: San Mehat - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 __LINUX_MSM_RPCROUTER_H -#define __LINUX_MSM_RPCROUTER_H - -#include -#include - -#define RPC_ROUTER_VERSION_V1 0x00010000 - -struct rpcrouter_ioctl_server_args { - uint32_t prog; - uint32_t vers; -}; - -#define RPC_ROUTER_IOCTL_MAGIC (0xC1) - -#define RPC_ROUTER_IOCTL_GET_VERSION \ - _IOR(RPC_ROUTER_IOCTL_MAGIC, 0, unsigned int) - -#define RPC_ROUTER_IOCTL_GET_MTU \ - _IOR(RPC_ROUTER_IOCTL_MAGIC, 1, unsigned int) - -#define RPC_ROUTER_IOCTL_REGISTER_SERVER \ - _IOWR(RPC_ROUTER_IOCTL_MAGIC, 2, unsigned int) - -#define RPC_ROUTER_IOCTL_UNREGISTER_SERVER \ - _IOWR(RPC_ROUTER_IOCTL_MAGIC, 3, unsigned int) - -#define RPC_ROUTER_IOCTL_CLEAR_NETRESET \ - _IOWR(RPC_ROUTER_IOCTL_MAGIC, 4, unsigned int) - -#define RPC_ROUTER_IOCTL_GET_CURR_PKT_SIZE \ - _IOR(RPC_ROUTER_IOCTL_MAGIC, 5, unsigned int) - -#endif diff --git a/include/linux/msm_tsens.h b/include/linux/msm_tsens.h index 35eacf10c45cd69f9e64490f5d4b477f218669b0..5e477b1ee7aa58f050703e6f162dc8c615e20e18 100644 --- a/include/linux/msm_tsens.h +++ b/include/linux/msm_tsens.h @@ -57,7 +57,7 @@ static inline int tsens_get_hw_id_mapping( { return -ENXIO; } #endif -#if defined(CONFIG_THERMAL_TSENS8974) || defined(CONFIG_THERMAL_TSENS8960) +#if defined(CONFIG_THERMAL_TSENS8974) int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors); #else static inline int tsens_get_max_sensor_num(uint32_t *tsens_num_sensors) diff --git a/include/linux/ofn_atlab.h b/include/linux/ofn_atlab.h deleted file mode 100644 index 6e3a2770c5b91733639f3d8f8ae7da0aa063764c..0000000000000000000000000000000000000000 --- a/include/linux/ofn_atlab.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2008-2010, 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. - * - */ -/* - * Atlab optical Finger Navigation driver - * - */ - -struct ofn_function1 { - bool no_motion1_en; - bool touch_sensor_en; - bool ofn_en; - u16 clock_select_khz; - u32 cpi_selection; -}; - -struct ofn_function2 { - bool invert_y; - bool invert_x; - bool swap_x_y; - bool hold_a_b_en; - bool motion_filter_en; -}; - -struct ofn_atlab_platform_data { - int irq_button_l; - int irq_button_r; - int gpio_button_l; - int gpio_button_r; - int rotate_xy; - int (*gpio_setup)(void); - void (*gpio_release)(void); - int (*optnav_on)(void); - void (*optnav_off)(void); - struct ofn_function1 function1; - struct ofn_function2 function2; -}; diff --git a/include/linux/platform_data/qcom_ssm.h b/include/linux/platform_data/qcom_ssm.h deleted file mode 100644 index 03ac67a4a391df862890d20a7e9504c3a7754599..0000000000000000000000000000000000000000 --- a/include/linux/platform_data/qcom_ssm.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2013, 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 __QCOM_SSM_H_ -#define __QCOM_SSM_H_ - -struct ssm_platform_data { - bool need_key_exchg; - const char *channel_name; -}; - -#endif /* __QCOM_SSM_H_ */ diff --git a/include/linux/pmic8058-charger.h b/include/linux/pmic8058-charger.h deleted file mode 100644 index a11c4ed91d5a9d05c7b2d38b11b2529c0a583813..0000000000000000000000000000000000000000 --- a/include/linux/pmic8058-charger.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2011, 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 __PMIC8058_CHARGER_H__ -#define __PMIC8058_CHARGER_H__ -/** - * enum pmic8058_chg_state - pmic8058 charging states - * @PMIC8058_CHG_STATE_NONE: Initial off state - * @PMIC8058_CHG_STATE_PWR_CHG: Device powered from charger - * @PMIC8058_CHG_STATE_ATC: Device is Auto Tricke Charged (ATC) - * @PMIC8058_CHG_STATE_PWR_BAT: Device powered from Battery - * @PMIC8058_CHG_STATE_ATC_FAIL: ATC failed - * @PMIC8058_CHG_STATE_AUX_EN: Transient state - * @PMIC8058_CHG_STATE_PON_AFTER_ATC: Power on from battery and chg with limit - * of 90mA - * @PMIC8058_CHG_STATE_FAST_CHG: pmic is fast charging the battery - * @PMIC8058_CHG_STATE_TRKL_CHG: pmic is trck charging the battery - * @PMIC8058_CHG_STATE_CHG_FAIL: charging failed - * @PMIC8058_CHG_STATE_EOC: end of charging reached - * @PMIC8058_CHG_STATE_INRUSH_LIMIT: Brings up Vdd with 90mA max drawn from - * VBUS - * @PMIC8058_CHG_STATE_USB_SUSPENDED: USB supended, no current drawn from VBUS - * @PMIC8058_CHG_STATE_PAUSE_ATC: ATC paused - * @PMIC8058_CHG_STATE_PAUSE_FAST_CHG: FAST charging paused - * @PMIC8058_CHG_STATE_PAUSE_TRKL_CHG: TRLK charging paused - * - * The paused states happen when a unfavourable condition for charging is - * detected. The most common one being the battery gets too hot ot gets - * too cold for charging. - */ -enum pmic8058_chg_state { - PMIC8058_CHG_STATE_NONE, - PMIC8058_CHG_STATE_PWR_CHG, - PMIC8058_CHG_STATE_ATC, - PMIC8058_CHG_STATE_PWR_BAT, - PMIC8058_CHG_STATE_ATC_FAIL, - PMIC8058_CHG_STATE_AUX_EN, - PMIC8058_CHG_STATE_PON_AFTER_ATC, - PMIC8058_CHG_STATE_FAST_CHG, - PMIC8058_CHG_STATE_TRKL_CHG, - PMIC8058_CHG_STATE_CHG_FAIL, - PMIC8058_CHG_STATE_EOC, - PMIC8058_CHG_STATE_INRUSH_LIMIT, - PMIC8058_CHG_STATE_USB_SUSPENDED, - PMIC8058_CHG_STATE_PAUSE_ATC, - PMIC8058_CHG_STATE_PAUSE_FAST_CHG, - PMIC8058_CHG_STATE_PAUSE_TRKL_CHG -}; - -#if defined(CONFIG_BATTERY_MSM8X60) || defined(CONFIG_BATTERY_MSM8X60_MODULE) -int pmic8058_get_charge_batt(void); -int pmic8058_set_charge_batt(int); -/** - * pmic8058_get_fsm_state - - * - * CONTEXT: may sleep - should not be called from non-atomic context - * - * RETURNS: The pmic internal state, or error otherwise - */ -enum pmic8058_chg_state pmic8058_get_fsm_state(void); -#else -int pmic8058_get_charge_batt(void) -{ - return -ENXIO; -} -int pmic8058_set_charge_batt(int) -{ - return -ENXIO; -} -enum pmic8058_chg_state pmic8058_get_fsm_state(void) -{ - return -ENXIO; -} -#endif -#endif /* __PMIC8058_CHARGER_H__ */ diff --git a/include/linux/pmic8058-xoadc.h b/include/linux/pmic8058-xoadc.h index bc4772d939a76290939d8ae3c7e5d2372419a804..cc3167523a31dbbed4305b767e0f6f5fed4e6285 100644 --- a/include/linux/pmic8058-xoadc.h +++ b/include/linux/pmic8058-xoadc.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. +/* Copyright (c) 2010-2013, 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 @@ -65,28 +65,6 @@ struct xoadc_platform_data { u32 xoadc_wakeup; }; -#ifdef CONFIG_PMIC8058_XOADC -int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, int32_t *data); - -int32_t pm8058_xoadc_select_chan_and_start_conv(uint32_t adc_instance, - struct adc_conv_slot *slot); - -void pm8058_xoadc_slot_request(uint32_t adc_instance, - struct adc_conv_slot **slot); - -void pm8058_xoadc_restore_slot(uint32_t adc_instance, - struct adc_conv_slot *slot); - -struct adc_properties *pm8058_xoadc_get_properties(uint32_t dev_instance); - -int32_t pm8058_xoadc_calibrate(uint32_t dev_instance, - struct adc_conv_slot *slot, int * calib_status); - -int32_t pm8058_xoadc_registered(void); - -int32_t pm8058_xoadc_calib_device(uint32_t adc_instance); - -#else static inline int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, int32_t *data) @@ -118,4 +96,3 @@ static inline int32_t pm8058_xoadc_registered(void) static inline int32_t pm8058_xoadc_calib_device(uint32_t adc_instance) { return -ENXIO; } #endif -#endif diff --git a/include/linux/power/ltc4088-charger.h b/include/linux/power/ltc4088-charger.h deleted file mode 100644 index e7c7e63121399721615d3513a8ef26b1ff7ade63..0000000000000000000000000000000000000000 --- a/include/linux/power/ltc4088-charger.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2011, 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 LTC4088_CHARGER_H_ -#define LTC4088_CHARGER_H_ - -#define LTC4088_CHARGER_DEV_NAME "ltc4088-charger" - -/** - * struct ltc4088_charger_platform_data - platform data for LTC4088 charger - * @gpio_mode_select_d0: GPIO #pin for D0 charger line - * @gpio_mode_select_d1: GPIO #pin for D1 charger line - * @gpio_mode_select_d2: GPIO #pin for D2 charger line - */ -struct ltc4088_charger_platform_data { - unsigned int gpio_mode_select_d0; - unsigned int gpio_mode_select_d1; - unsigned int gpio_mode_select_d2; -}; - -#endif /* LTC4088_CHARGER_H_ */ diff --git a/include/linux/qcomwlan7x27a_pwrif.h b/include/linux/qcomwlan7x27a_pwrif.h deleted file mode 100644 index fc022aed247ab76cf541d6ea68088ca86ef8b286..0000000000000000000000000000000000000000 --- a/include/linux/qcomwlan7x27a_pwrif.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2011, 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 __QCOM_WLAN_PWRIF_H__ -#define __QCOM_WLAN_PWRIF_H__ - -#include - -int chip_power_qrf6285(bool on); - -#endif /* __QCOM_WLAN_PWRIF_H__ */ diff --git a/include/linux/qcomwlan_pwrif.h b/include/linux/qcomwlan_pwrif.h deleted file mode 100644 index be354256089db02f40ba73e721b4b48b19449179..0000000000000000000000000000000000000000 --- a/include/linux/qcomwlan_pwrif.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2010-2011, 2013, 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 __QCOM_WLAN_PWRIF_H__ -#define __QCOM_WLAN_PWRIF_H__ - -/* - * Headers for WLAN Power Interface Functions - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CHIP_POWER_ON 1 -#define CHIP_POWER_OFF 0 - -int vos_chip_power_qrf8615(int on); -int qcomwlan_pmic_xo_core_force_enable(int on); -int qcomwlan_freq_change_1p3v_supply(enum rpm_vreg_freq freq); - -#endif /* __QCOM_WLAN_PWRIF_H__ */ diff --git a/include/linux/regulator/msm-gpio-regulator.h b/include/linux/regulator/msm-gpio-regulator.h deleted file mode 100644 index 0269aa7a13ff3d43ed15283ba88e3571987d523b..0000000000000000000000000000000000000000 --- a/include/linux/regulator/msm-gpio-regulator.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2011-2012, 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 __MSM_GPIO_REGULATOR_H__ -#define __MSM_GPIO_REGULATOR_H__ - -#include - -#define GPIO_REGULATOR_DEV_NAME "msm-gpio-regulator" - -/** - * struct gpio_regulator_platform_data - GPIO regulator platform data - * @init_data: regulator constraints - * @gpio_label: label to use when requesting the GPIO - * @regulator_name: name for regulator used during registration - * @gpio: gpio number - * @active_low: 0 = regulator is enabled when GPIO outputs high - * 1 = regulator is enabled when GPIO outputs low - */ -struct gpio_regulator_platform_data { - struct regulator_init_data init_data; - char *gpio_label; - char *regulator_name; - unsigned gpio; - int active_low; -}; - -#endif diff --git a/include/linux/rmt_storage_client.h b/include/linux/rmt_storage_client.h deleted file mode 100644 index 077a42aec45a858567c2a6c90ccb15b202a8d322..0000000000000000000000000000000000000000 --- a/include/linux/rmt_storage_client.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 2009-2010, 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 __RMT_STORAGE_SERVER_H -#define __RMT_STORAGE_SERVER_H - -#include -#include - -#define RMT_STORAGE_OPEN 0 -#define RMT_STORAGE_WRITE 1 -#define RMT_STORAGE_CLOSE 2 -#define RMT_STORAGE_SEND_USER_DATA 3 -#define RMT_STORAGE_READ 4 -#define RMT_STORAGE_NOOP 255 - -#define RMT_STORAGE_MAX_IOVEC_XFR_CNT 5 -#define MAX_NUM_CLIENTS 10 -#define MAX_RAMFS_TBL_ENTRIES 3 -#define RAMFS_BLOCK_SIZE 512 - - -enum { - RMT_STORAGE_NO_ERROR = 0, /* Success */ - RMT_STORAGE_ERROR_PARAM, /* Invalid parameters */ - RMT_STORAGE_ERROR_PIPE, /* RPC pipe failure */ - RMT_STORAGE_ERROR_UNINIT, /* Server is not initalized */ - RMT_STORAGE_ERROR_BUSY, /* Device busy */ - RMT_STORAGE_ERROR_DEVICE /* Remote storage device */ -} rmt_storage_status; - -struct rmt_storage_iovec_desc { - uint32_t sector_addr; - uint32_t data_phy_addr; - uint32_t num_sector; -}; - -#define MAX_PATH_NAME 32 -struct rmt_storage_event { - uint32_t id; /* Event ID */ - uint32_t sid; /* Storage ID */ - uint32_t handle; /* Client handle */ - char path[MAX_PATH_NAME]; - struct rmt_storage_iovec_desc xfer_desc[RMT_STORAGE_MAX_IOVEC_XFR_CNT]; - uint32_t xfer_cnt; - uint32_t usr_data; -}; - -struct rmt_storage_send_sts { - uint32_t err_code; - uint32_t data; - uint32_t handle; - uint32_t xfer_dir; -}; - -struct rmt_shrd_mem_param { - uint32_t sid; /* Storage ID */ - uint32_t start; /* Physical memory address */ - uint32_t size; /* Physical memory size */ - void *base; /* Virtual user-space memory address */ -}; - -#define RMT_STORAGE_IOCTL_MAGIC (0xC2) - -#define RMT_STORAGE_SHRD_MEM_PARAM \ - _IOWR(RMT_STORAGE_IOCTL_MAGIC, 0, struct rmt_shrd_mem_param) - -#define RMT_STORAGE_WAIT_FOR_REQ \ - _IOR(RMT_STORAGE_IOCTL_MAGIC, 1, struct rmt_storage_event) - -#define RMT_STORAGE_SEND_STATUS \ - _IOW(RMT_STORAGE_IOCTL_MAGIC, 2, struct rmt_storage_send_sts) -#endif diff --git a/include/linux/rtc-msm.h b/include/linux/rtc-msm.h deleted file mode 100644 index 324d66ad41e49b8341b879b83fcbf3e42d602ae5..0000000000000000000000000000000000000000 --- a/include/linux/rtc-msm.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2011, 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 __RTC_MSM_H__ -#define __RTC_MSM_H__ - -/* - * This is the only function which updates the xtime structure. This - * function is supposed to be called only once during kernel initialization. - * But we need to call this function whenever we receive an RTC update - * from MODEM. - */ -int rtc_hctosys(void); - -extern void msm_pm_set_max_sleep_time(int64_t sleep_time_ns); -void msmrtc_updateatsuspend(struct timespec *ts); - -#ifdef CONFIG_PM -int64_t msm_timer_get_sclk_time(int64_t *period); -#endif /* CONFIG_PM */ - -#endif /* __RTC_MSM_H__ */ diff --git a/include/linux/tsif_api.h b/include/linux/tsif_api.h deleted file mode 100644 index b69ddf595f3ae2824ba925ece6488da36c55af5a..0000000000000000000000000000000000000000 --- a/include/linux/tsif_api.h +++ /dev/null @@ -1,277 +0,0 @@ -/** - * TSIF driver - * - * Kernel API - * - * Copyright (c) 2012-2013, 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 _TSIF_API_H_ -#define _TSIF_API_H_ -/** - * Theory of operation - * - * TSIF driver maintains internal cyclic data buffer where - * received TSIF packets are stored. Size of buffer, in packets, - * and its address, may be obtained by tsif_get_info(). - * - * TSIF stream delivered to the client that should register with - * TSIF driver using tsif_attach() - * - * Producer-consumer pattern used. TSIF driver act as producer, - * writing data to the buffer; clientis consumer. - * 2 indexes maintained by the TSIF driver: - * - wi (write index) points to the next item to be written by - * TSIF - * - ri (read index) points to the next item available for read - * by the client. - * Write index advanced by the TSIF driver when new data - * received; - * Read index advanced only when client tell so to the TSIF - * driver by tsif_reclaim_packets() - * - * Consumer may directly access data TSIF buffer between ri and - * wi. When ri==wi, buffer is empty. - * - * TSIF driver notifies client about any change by calling - * notify function. Client should use tsif_get_state() to query - * new state. - */ - -/* bytes in TSIF packet. not customizable */ -#define TSIF_PKT_SIZE (192) - -/** - * tsif_pkt_status - get TSIF packet status - * - * @pkt: TSIF packet location - * - * Return last DWORD of packet, containing status. - * Status dword consists of: - * - 3 low bytes TTS - * - 1 byte (last byte of packet) with status bits - */ -static inline u32 tsif_pkt_status(void *pkt) -{ - u32 *x = pkt; - return x[TSIF_PKT_SIZE / sizeof(u32) - 1]; -} - -/** - * Status dword parts for status returned by @tsif_pkt_status - */ -#define TSIF_STATUS_TTS(x) ((x) & 0xffffff) -#define TSIF_STATUS_VALID(x) ((x) & (1<<24)) -#define TSIF_STATUS_FIRST(x) ((x) & (1<<25)) -#define TSIF_STATUS_OVFLW(x) ((x) & (1<<26)) -#define TSIF_STATUS_ERROR(x) ((x) & (1<<27)) -#define TSIF_STATUS_NULL(x) ((x) & (1<<28)) -#define TSIF_STATUS_TIMEO(x) ((x) & (1<<30)) - -/** - * enum tsif_state - TSIF device state - * @tsif_state_stopped: Idle state, data acquisition not running - * @tsif_state_running: Data acquisition in progress - * @tsif_state_flushing: Device is flushing - * - * State transition diagram: - * - * init -> tsif_state_stopped - * - * tsif_state_stopped: - * - open -> tsif_state_running - * - * tsif_state_running: - * - close -> tsif_state_flushing - * - * tsif_state_flushing: - * - flushed -> tsif_state_stopped - */ -enum tsif_state { - tsif_state_stopped = 0, - tsif_state_running = 1, - tsif_state_flushing = 2, - tsif_state_error = 3, -}; - -/** - * tsif_get_active - return active tsif hardware instance - * - * Return TSIF instance to use (selected by CONFIG_MSM_USE_TSIF1) - */ -int tsif_get_active(void); - -/** - * tsif_attach - Attach to the device. - * @id: TSIF device ID, used to identify TSIF instance. - * @notify: client callback, called when - * any client visible TSIF state changed. - * This includes new data available and device state change - * @data: client data, will be passed to @notify - * - * Return TSIF cookie or error code - * - * Should be called prior to any other tsif_XXX function. - */ -void *tsif_attach(int id, void (*notify)(void *client_data), void *client_data); - -/** - * tsif_detach - detach from device - * @cookie: TSIF cookie previously obtained with tsif_attach() - */ -void tsif_detach(void *cookie); - -/** - * tsif_get_info - get data buffer info - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @pdata: if not NULL, TSIF data buffer will be stored there - * @psize: if not NULL, TSIF data buffer size, in packets, - * will be stored there - * - * Data buffer information should be queried after each tsif_start() before - * using data; since data buffer will be re-allocated on tsif_start() - */ -void tsif_get_info(void *cookie, void **pdata, int *psize); - -/** - * tsif_set_mode - set TSIF mode - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @mode: desired mode of operation - * - * Return error code - * - * Mode may be changed only when TSIF device is stopped. - */ -int tsif_set_mode(void *cookie, int mode); - -/** - * tsif_set_time_limit - set TSIF time limit - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @value: desired time limit, 0 to disable - * - * Return error code - * - * Time limit may be changed only when TSIF device is stopped. - */ -int tsif_set_time_limit(void *cookie, u32 value); - -/** - * tsif_set_buf_config - configure data buffer - * - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @pkts_in_chunk: requested number of packets per chunk - * @chunks_in_buf: requested number of chunks in buffer - * - * Return error code - * - * Parameter selection criteria: - * - * - @pkts_in_chunk defines size of DMA transfer and, in turn, time between - * consecutive DMA transfers. Increase @pkts_in_chunk reduces chance for - * hardware overflow. If TSIF stats reports overflows, increase it. - * - * - @chunks_in_buf * @pkts_in_chunk defines total buffer size. Increase this - * parameter if client latency is large and TSIF reports "soft drop" in its - * stats - */ -int tsif_set_buf_config(void *cookie, u32 pkts_in_chunk, u32 chunks_in_buf); - -/** - * tsif_get_state - query current data buffer information - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @ri: if not NULL, read index will be stored here - * @wi: if not NULL, write index will be stored here - * @state: if not NULL, state will be stored here - */ -void tsif_get_state(void *cookie, int *ri, int *wi, enum tsif_state *state); - -/** - * tsif_set_clk_inverse - set whether to inverse the clock signal. - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @inverse: 1 to inverse the clock, 0 otherwise. Default is 0. - * - * Return error code - * - * Setting may be changed only when TSIF device is stopped. - */ -int tsif_set_clk_inverse(void *cookie, int inverse); - -/** - * tsif_set_data_inverse - set whether to inverse the data signal. - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @inverse: 1 to inverse the clock, 0 otherwise. Default is 0. - * - * Return error code - * - * Setting may be changed only when TSIF device is stopped. - */ -int tsif_set_data_inverse(void *cookie, int inverse); - -/** - * tsif_set_sync_inverse - set whether to inverse the sync signal. - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @inverse: 1 to inverse the clock, 0 otherwise. Default is 0. - * - * Return error code - * - * Setting may be changed only when TSIF device is stopped. - */ -int tsif_set_sync_inverse(void *cookie, int inverse); - -/** - * tsif_set_enable_inverse - set whether to inverse the enable signal. - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @inverse: 1 to inverse the clock, 0 otherwise. Default is 0. - * - * Return error code - * - * Setting may be changed only when TSIF device is stopped. - */ -int tsif_set_enable_inverse(void *cookie, int inverse); - -/** - * tsif_start - start data acquisition - * @cookie: TSIF cookie previously obtained with tsif_attach() - * - * Return error code - */ -int tsif_start(void *cookie); - -/** - * tsif_stop - stop data acquisition - * @cookie: TSIF cookie previously obtained with tsif_attach() - * - * Data buffer allocated during this function call; thus client should - * query data buffer info using tsif_get_info() and reset its data pointers. - */ -void tsif_stop(void *cookie); - -/** - * tsif_get_ref_clk_counter - return the TSIF clock reference (TCR) counter. - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @tcr_counter: the value of TCR counter - * - * Return error code - * - * TCR increments at a rate equal to 27 MHz/256 = 105.47 kHz. - */ -int tsif_get_ref_clk_counter(void *cookie, u32 *tcr_counter); - -/** - * tsif_reclaim_packets - inform that buffer space may be reclaimed - * @cookie: TSIF cookie previously obtained with tsif_attach() - * @ri: new value for read index - */ -void tsif_reclaim_packets(void *cookie, int ri); - -#endif /* _TSIF_API_H_ */ - diff --git a/include/linux/wpce775x.h b/include/linux/wpce775x.h deleted file mode 100644 index 1803122d1e71daf0cea1eba21ab33e4a7b0906a2..0000000000000000000000000000000000000000 --- a/include/linux/wpce775x.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Quanta EC driver for the Winbond Embedded Controller - * - * Copyright (C) 2009 Quanta Computer Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 WPCE775X_DRV_H -#define WPCE775X_DRV_H - -#include - -struct i2c_client *wpce_get_i2c_client(void); -int wpce_smbus_write_word_data(u8 command, u16 value); -struct i2c_client *wpce_get_i2c_client(void); -void wpce_poweroff(void); -void wpce_restart(void); -int wpce_i2c_transfer(struct i2c_msg *msg); -int wpce_smbus_write_word_data(u8 command, u16 value); -int wpce_smbus_write_byte_data(u8 command, u8 value); - -#endif diff --git a/include/media/msm/vcd_api.h b/include/media/msm/vcd_api.h deleted file mode 100644 index 09e1a53fc67cf041b4721d06829b75764016263a..0000000000000000000000000000000000000000 --- a/include/media/msm/vcd_api.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (c) 2010-2013, 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 _VCD_API_H_ -#define _VCD_API_H_ -#include -#include "vcd_property.h" -#include "vcd_status.h" - -#define VCD_FRAME_FLAG_EOS 0x00000001 -#define VCD_FRAME_FLAG_DECODEONLY 0x00000004 -#define VCD_FRAME_FLAG_DATACORRUPT 0x00000008 -#define VCD_FRAME_FLAG_ENDOFFRAME 0x00000010 -#define VCD_FRAME_FLAG_SYNCFRAME 0x00000020 -#define VCD_FRAME_FLAG_EXTRADATA 0x00000040 -#define VCD_FRAME_FLAG_CODECCONFIG 0x00000080 -#define VCD_FRAME_FLAG_BFRAME 0x00100000 -#define VCD_FRAME_FLAG_EOSEQ 0x00200000 - -#define VCD_FLUSH_INPUT 0x0001 -#define VCD_FLUSH_OUTPUT 0x0002 -#define VCD_FLUSH_ALL 0x0003 - -#define VCD_FRAMETAG_INVALID 0xffffffff - -struct vcd_handle_container { - void *handle; -}; -struct vcd_flush_cmd { - u32 mode; -}; - -enum vcd_frame { - VCD_FRAME_YUV = 1, - VCD_FRAME_I, - VCD_FRAME_P, - VCD_FRAME_B, - VCD_FRAME_NOTCODED, - VCD_FRAME_IDR, - VCD_FRAME_32BIT = 0x7fffffff -}; - -enum vcd_power_state { - VCD_PWR_STATE_ON = 1, - VCD_PWR_STATE_SLEEP, -}; - -struct vcd_aspect_ratio { - u32 aspect_ratio; - u32 par_width; - u32 par_height; -}; - -struct vcd_frame_data { - u8 *virtual; - u8 *physical; - u32 ion_flag; - u32 alloc_len; - u32 data_len; - u32 offset; - s64 time_stamp; /* in usecs*/ - u32 flags; - u32 frm_clnt_data; - struct vcd_property_dec_output_buffer dec_op_prop; - u32 interlaced; - enum vcd_frame frame; - u32 ip_frm_tag; - u32 intrlcd_ip_frm_tag; - u8 *desc_buf; - u32 desc_size; - struct ion_handle *buff_ion_handle; - struct vcd_aspect_ratio aspect_ratio_info; -}; - -struct vcd_sequence_hdr { - u8 *sequence_header; - u32 sequence_header_len; - -}; - -enum vcd_buffer_type { - VCD_BUFFER_INPUT = 0x1, - VCD_BUFFER_OUTPUT = 0x2, - VCD_BUFFER_INVALID = 0x3, - VCD_BUFFER_32BIT = 0x7FFFFFFF -}; - -struct vcd_buffer_requirement { - u32 min_count; - u32 actual_count; - u32 max_count; - size_t sz; - u32 align; - u32 buf_pool_id; - size_t meta_buffer_size; -}; - -struct vcd_init_config { - void *device_name; - void *(*map_dev_base_addr) (void *device_name); - void (*un_map_dev_base_addr) (void); - void (*interrupt_clr) (void); - void (*register_isr) (void *device_name); - void (*deregister_isr) (void); - u32 (*timer_create) (void (*timer_handler)(void *), - void *user_data, void **timer_handle); - void (*timer_release) (void *timer_handle); - void (*timer_start) (void *timer_handle, u32 time_out); - void (*timer_stop) (void *timer_handle); -}; - -/*Flags passed to vcd_open*/ -#define VCD_CP_SESSION 0x00000001 - -u32 vcd_init(struct vcd_init_config *config, s32 *driver_handle); -u32 vcd_term(s32 driver_handle); -u32 vcd_open(s32 driver_handle, u32 decoding, - void (*callback) (u32 event, u32 status, void *info, size_t sz, - void *handle, void *const client_data), void *client_data, int flags); -u32 vcd_close(void *handle); -u32 vcd_encode_start(void *handle); -u32 vcd_encode_frame(void *handle, struct vcd_frame_data *input_frame); -u32 vcd_decode_start(void *handle, struct vcd_sequence_hdr *seq_hdr); -u32 vcd_decode_frame(void *handle, struct vcd_frame_data *input_frame); -u32 vcd_pause(void *handle); -u32 vcd_resume(void *handle); -u32 vcd_flush(void *handle, u32 mode); -u32 vcd_stop(void *handle); -u32 vcd_set_property(void *handle, struct vcd_property_hdr *prop_hdr, - void *prop_val); -u32 vcd_get_property(void *handle, struct vcd_property_hdr *prop_hdr, - void *prop_val); -u32 vcd_set_buffer_requirements(void *handle, enum vcd_buffer_type buffer, - struct vcd_buffer_requirement *buffer_req); -u32 vcd_get_buffer_requirements(void *handle, enum vcd_buffer_type buffer, - struct vcd_buffer_requirement *buffer_req); -u32 vcd_set_buffer(void *handle, enum vcd_buffer_type buffer_type, - u8 *buffer, u32 buf_size); -u32 vcd_allocate_buffer(void *handle, enum vcd_buffer_type buffer, - u32 buf_size, u8 **vir_buf_addr, u8 **phy_buf_addr); - -u32 vcd_free_buffer(void *handle, enum vcd_buffer_type buffer_type, u8 *buffer); -u32 vcd_fill_output_buffer(void *handle, struct vcd_frame_data *buffer); -u32 vcd_set_device_power(s32 driver_handle, - enum vcd_power_state pwr_state); -void vcd_read_and_clear_interrupt(void); -void vcd_response_handler(void); -u8 vcd_get_num_of_clients(void); -u32 vcd_get_ion_status(void); -struct ion_client *vcd_get_ion_client(void); -#endif diff --git a/include/media/msm/vcd_property.h b/include/media/msm/vcd_property.h deleted file mode 100644 index ce6c4795bfd95ea4f88b935f4ac98735d9876bba..0000000000000000000000000000000000000000 --- a/include/media/msm/vcd_property.h +++ /dev/null @@ -1,449 +0,0 @@ -/* Copyright (c) 2010-2013, 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 _VCD_DRIVER_PROPERTY_H_ -#define _VCD_DRIVER_PROPERTY_H_ - -#include - -#define VCD_START_BASE 0x0 -#define VCD_I_LIVE (VCD_START_BASE + 0x1) -#define VCD_I_CODEC (VCD_START_BASE + 0x2) -#define VCD_I_FRAME_SIZE (VCD_START_BASE + 0x3) -#define VCD_I_METADATA_ENABLE (VCD_START_BASE + 0x4) -#define VCD_I_METADATA_HEADER (VCD_START_BASE + 0x5) -#define VCD_I_PROFILE (VCD_START_BASE + 0x6) -#define VCD_I_LEVEL (VCD_START_BASE + 0x7) -#define VCD_I_BUFFER_FORMAT (VCD_START_BASE + 0x8) -#define VCD_I_FRAME_RATE (VCD_START_BASE + 0x9) -#define VCD_I_TARGET_BITRATE (VCD_START_BASE + 0xA) -#define VCD_I_MULTI_SLICE (VCD_START_BASE + 0xB) -#define VCD_I_ENTROPY_CTRL (VCD_START_BASE + 0xC) -#define VCD_I_DEBLOCKING (VCD_START_BASE + 0xD) -#define VCD_I_RATE_CONTROL (VCD_START_BASE + 0xE) -#define VCD_I_QP_RANGE (VCD_START_BASE + 0xF) -#define VCD_I_SESSION_QP (VCD_START_BASE + 0x10) -#define VCD_I_INTRA_PERIOD (VCD_START_BASE + 0x11) -#define VCD_I_VOP_TIMING (VCD_START_BASE + 0x12) -#define VCD_I_SHORT_HEADER (VCD_START_BASE + 0x13) -#define VCD_I_SEQ_HEADER (VCD_START_BASE + 0x14) -#define VCD_I_HEADER_EXTENSION (VCD_START_BASE + 0x15) -#define VCD_I_INTRA_REFRESH (VCD_START_BASE + 0x16) -#define VCD_I_POST_FILTER (VCD_START_BASE + 0x17) -#define VCD_I_PROGRESSIVE_ONLY (VCD_START_BASE + 0x18) -#define VCD_I_OUTPUT_ORDER (VCD_START_BASE + 0x19) -#define VCD_I_RECON_BUFFERS (VCD_START_BASE + 0x1A) -#define VCD_I_FREE_RECON_BUFFERS (VCD_START_BASE + 0x1B) -#define VCD_I_GET_RECON_BUFFER_SIZE (VCD_START_BASE + 0x1C) -#define VCD_I_H264_MV_BUFFER (VCD_START_BASE + 0x1D) -#define VCD_I_FREE_H264_MV_BUFFER (VCD_START_BASE + 0x1E) -#define VCD_I_GET_H264_MV_SIZE (VCD_START_BASE + 0x1F) -#define VCD_I_DEC_PICTYPE (VCD_START_BASE + 0x20) -#define VCD_I_CONT_ON_RECONFIG (VCD_START_BASE + 0x21) -#define VCD_I_META_BUFFER_MODE (VCD_START_BASE + 0x22) -#define VCD_I_DISABLE_DMX (VCD_START_BASE + 0x23) -#define VCD_I_DISABLE_DMX_SUPPORT (VCD_START_BASE + 0x24) -#define VCD_I_ENABLE_SPS_PPS_FOR_IDR (VCD_START_BASE + 0x25) -#define VCD_REQ_PERF_LEVEL (VCD_START_BASE + 0x26) -#define VCD_I_SLICE_DELIVERY_MODE (VCD_START_BASE + 0x27) -#define VCD_I_VOP_TIMING_CONSTANT_DELTA (VCD_START_BASE + 0x28) -#define VCD_I_SET_TURBO_CLK (VCD_START_BASE + 0x29) -#define VCD_I_ENABLE_DELIMITER_FLAG (VCD_START_BASE + 0x2A) -#define VCD_I_ENABLE_VUI_TIMING_INFO (VCD_START_BASE + 0x2B) -#define VCD_I_H263_PLUSPTYPE (VCD_START_BASE + 0x2C) -#define VCD_I_LTR_MODE (VCD_START_BASE + 0x2D) -#define VCD_I_LTR_COUNT (VCD_START_BASE + 0x2E) -#define VCD_I_LTR_PERIOD (VCD_START_BASE + 0x2F) -#define VCD_I_LTR_USE (VCD_START_BASE + 0x30) -#define VCD_I_CAPABILITY_LTR_COUNT (VCD_START_BASE + 0x31) -#define VCD_I_LTR_MARK (VCD_START_BASE + 0x32) -#define VCD_I_SET_EXT_METABUFFER (VCD_START_BASE + 0x33) -#define VCD_I_FREE_EXT_METABUFFER (VCD_START_BASE + 0x34) - -#define VCD_START_REQ (VCD_START_BASE + 0x1000) -#define VCD_I_REQ_IFRAME (VCD_START_REQ + 0x1) - -#define VCD_I_RESERVED_BASE (VCD_START_BASE + 0x10000) - -struct vcd_property_hdr { - u32 prop_id; - size_t sz; -}; - -struct vcd_property_live { - u32 live; -}; - -enum vcd_codec { - VCD_CODEC_H264 = 0x1, - VCD_CODEC_H263 = 0x2, - VCD_CODEC_MPEG1 = 0x3, - VCD_CODEC_MPEG2 = 0x4, - VCD_CODEC_MPEG4 = 0x5, - VCD_CODEC_DIVX_3 = 0x6, - VCD_CODEC_DIVX_4 = 0x7, - VCD_CODEC_DIVX_5 = 0x8, - VCD_CODEC_DIVX_6 = 0x9, - VCD_CODEC_XVID = 0xA, - VCD_CODEC_VC1 = 0xB, - VCD_CODEC_VC1_RCV = 0xC -}; - -struct vcd_property_codec { - enum vcd_codec codec; -}; - -struct vcd_property_frame_size { - u32 width; - u32 height; - u32 stride; - u32 scan_lines; -}; - -enum vcd_perf_level { - VCD_PERF_LEVEL0, - VCD_PERF_LEVEL1, - VCD_PERF_LEVEL2, - VCD_PERF_LEVEL_TURBO, -}; - -#define VCD_METADATA_DATANONE 0x001 -#define VCD_METADATA_QCOMFILLER 0x002 -#define VCD_METADATA_QPARRAY 0x004 -#define VCD_METADATA_CONCEALMB 0x008 -#define VCD_METADATA_SEI 0x010 -#define VCD_METADATA_VUI 0x020 -#define VCD_METADATA_VC1 0x040 -#define VCD_METADATA_PASSTHROUGH 0x080 -#define VCD_METADATA_ENC_SLICE 0x100 -#define VCD_METADATA_LTR_INFO 0x200 - -#define VCD_METADATA_EXT_DATA 0x0800 -#define VCD_METADATA_USER_DATA 0x1000 -#define VCD_METADATA_SEPARATE_BUF 0x2000 - - -struct vcd_property_meta_data_enable { - u32 meta_data_enable_flag; -}; - -struct vcd_property_metadata_hdr { - u32 meta_data_id; - u32 version; - u32 port_index; - u32 type; -}; - -struct vcd_property_frame_rate { - u32 fps_denominator; - u32 fps_numerator; -}; - -struct vcd_property_target_bitrate { - u32 target_bitrate; -}; - -struct vcd_property_perf_level { - enum vcd_perf_level level; -}; - -enum vcd_yuv_buffer_format { - VCD_BUFFER_FORMAT_NV12 = 0x1, - VCD_BUFFER_FORMAT_TILE_4x2 = 0x2, - VCD_BUFFER_FORMAT_NV12_16M2KA = 0x3, - VCD_BUFFER_FORMAT_TILE_1x1 = 0x4 -}; - -struct vcd_property_buffer_format { - enum vcd_yuv_buffer_format buffer_format; -}; - -struct vcd_property_post_filter { - u32 post_filter; -}; - -enum vcd_codec_profile { - VCD_PROFILE_UNKNOWN = 0x0, - VCD_PROFILE_MPEG4_SP = 0x1, - VCD_PROFILE_MPEG4_ASP = 0x2, - VCD_PROFILE_H264_BASELINE = 0x3, - VCD_PROFILE_H264_MAIN = 0x4, - VCD_PROFILE_H264_HIGH = 0x5, - VCD_PROFILE_H263_BASELINE = 0x6, - VCD_PROFILE_VC1_SIMPLE = 0x7, - VCD_PROFILE_VC1_MAIN = 0x8, - VCD_PROFILE_VC1_ADVANCE = 0x9, - VCD_PROFILE_MPEG2_MAIN = 0xA, - VCD_PROFILE_MPEG2_SIMPLE = 0xB -}; - -struct vcd_property_profile { - enum vcd_codec_profile profile; -}; - -enum vcd_codec_level { - VCD_LEVEL_UNKNOWN = 0x0, - VCD_LEVEL_MPEG4_0 = 0x1, - VCD_LEVEL_MPEG4_0b = 0x2, - VCD_LEVEL_MPEG4_1 = 0x3, - VCD_LEVEL_MPEG4_2 = 0x4, - VCD_LEVEL_MPEG4_3 = 0x5, - VCD_LEVEL_MPEG4_3b = 0x6, - VCD_LEVEL_MPEG4_4 = 0x7, - VCD_LEVEL_MPEG4_4a = 0x8, - VCD_LEVEL_MPEG4_5 = 0x9, - VCD_LEVEL_MPEG4_6 = 0xA, - VCD_LEVEL_MPEG4_7 = 0xB, - VCD_LEVEL_MPEG4_X = 0xC, - VCD_LEVEL_H264_1 = 0x10, - VCD_LEVEL_H264_1b = 0x11, - VCD_LEVEL_H264_1p1 = 0x12, - VCD_LEVEL_H264_1p2 = 0x13, - VCD_LEVEL_H264_1p3 = 0x14, - VCD_LEVEL_H264_2 = 0x15, - VCD_LEVEL_H264_2p1 = 0x16, - VCD_LEVEL_H264_2p2 = 0x17, - VCD_LEVEL_H264_3 = 0x18, - VCD_LEVEL_H264_3p1 = 0x19, - VCD_LEVEL_H264_3p2 = 0x1A, - VCD_LEVEL_H264_4 = 0x1B, - VCD_LEVEL_H264_4p1 = 0x1C, - VCD_LEVEL_H264_4p2 = 0x1D, - VCD_LEVEL_H264_5 = 0x1E, - VCD_LEVEL_H264_5p1 = 0x1F, - VCD_LEVEL_H263_10 = 0x20, - VCD_LEVEL_H263_20 = 0x21, - VCD_LEVEL_H263_30 = 0x22, - VCD_LEVEL_H263_40 = 0x23, - VCD_LEVEL_H263_45 = 0x24, - VCD_LEVEL_H263_50 = 0x25, - VCD_LEVEL_H263_60 = 0x26, - VCD_LEVEL_H263_70 = 0x27, - VCD_LEVEL_H263_X = 0x28, - VCD_LEVEL_MPEG2_LOW = 0x30, - VCD_LEVEL_MPEG2_MAIN = 0x31, - VCD_LEVEL_MPEG2_HIGH_14 = 0x32, - VCD_LEVEL_MPEG2_HIGH = 0x33, - VCD_LEVEL_MPEG2_X = 0x34, - VCD_LEVEL_VC1_S_LOW = 0x40, - VCD_LEVEL_VC1_S_MEDIUM = 0x41, - VCD_LEVEL_VC1_M_LOW = 0x42, - VCD_LEVEL_VC1_M_MEDIUM = 0x43, - VCD_LEVEL_VC1_M_HIGH = 0x44, - VCD_LEVEL_VC1_A_0 = 0x45, - VCD_LEVEL_VC1_A_1 = 0x46, - VCD_LEVEL_VC1_A_2 = 0x47, - VCD_LEVEL_VC1_A_3 = 0x48, - VCD_LEVEL_VC1_A_4 = 0x49, - VCD_LEVEL_VC1_X = 0x4A -}; - -struct vcd_property_level { - enum vcd_codec_level level; -}; - -enum vcd_m_slice_sel { - VCD_MSLICE_OFF = 0x1, - VCD_MSLICE_BY_MB_COUNT = 0x2, - VCD_MSLICE_BY_BYTE_COUNT = 0x3, - VCD_MSLICE_BY_GOB = 0x4 -}; - -struct vcd_property_multi_slice { - enum vcd_m_slice_sel m_slice_sel; - u32 m_slice_size; -}; - -enum vcd_entropy_sel { - VCD_ENTROPY_SEL_CAVLC = 0x1, - VCD_ENTROPY_SEL_CABAC = 0x2 -}; - -enum vcd_cabac_model { - VCD_CABAC_MODEL_NUMBER_0 = 0x1, - VCD_CABAC_MODEL_NUMBER_1 = 0x2, - VCD_CABAC_MODEL_NUMBER_2 = 0x3 -}; - -struct vcd_property_entropy_control { - enum vcd_entropy_sel entropy_sel; - enum vcd_cabac_model cabac_model; -}; - -enum vcd_db_config { - VCD_DB_ALL_BLOCKING_BOUNDARY = 0x1, - VCD_DB_DISABLE = 0x2, - VCD_DB_SKIP_SLICE_BOUNDARY = 0x3 -}; -struct vcd_property_db_config { - enum vcd_db_config db_config; - u32 slice_alpha_offset; - u32 slice_beta_offset; -}; - -enum vcd_rate_control { - VCD_RATE_CONTROL_OFF = 0x1, - VCD_RATE_CONTROL_VBR_VFR = 0x2, - VCD_RATE_CONTROL_VBR_CFR = 0x3, - VCD_RATE_CONTROL_CBR_VFR = 0x4, - VCD_RATE_CONTROL_CBR_CFR = 0x5 -}; - -struct vcd_property_rate_control { - enum vcd_rate_control rate_control; -}; - -struct vcd_property_qp_range { - u32 max_qp; - u32 min_qp; -}; - -struct vcd_property_plusptype { - u32 plusptype_enable; -}; - -struct vcd_property_session_qp { - u32 i_frame_qp; - u32 p_frame_qp; - u32 b_frame_qp; -}; - -struct vcd_property_i_period { - u32 p_frames; - u32 b_frames; -}; - -struct vcd_property_vop_timing { - u32 vop_time_resolution; -}; - -struct vcd_property_vop_timing_constant_delta { - u32 constant_delta; /*In usecs */ -}; - -struct vcd_property_short_header { - u32 short_header; -}; - -struct vcd_property_intra_refresh_mb_number { - u32 cir_mb_number; -}; - -struct vcd_property_req_i_frame { - u32 req_i_frame; -}; - -struct vcd_frame_rect { - u32 left; - u32 top; - u32 right; - u32 bottom; -}; - -struct vcd_property_dec_output_buffer { - struct vcd_frame_rect disp_frm; - struct vcd_property_frame_size frm_size; -}; - -enum vcd_output_order { - VCD_DEC_ORDER_DISPLAY = 0x0, - VCD_DEC_ORDER_DECODE = 0x1 -}; - -struct vcd_property_enc_recon_buffer { - u8 *user_virtual_addr; - u8 *kernel_virtual_addr; - u8 *physical_addr; - u8 *dev_addr; - u32 buffer_size; - u32 ysize; - int pmem_fd; - u32 offset; - void *client_data; -}; - -struct vcd_property_h264_mv_buffer { - u8 *kernel_virtual_addr; - u8 *physical_addr; - u32 size; - u32 count; - int pmem_fd; - u32 offset; - u8 *dev_addr; - void *client_data; -}; - -struct vcd_property_buffer_size { - int width; - int height; - int size; - int alignment; -}; - -struct vcd_property_sps_pps_for_idr_enable { - u32 sps_pps_for_idr_enable_flag; -}; - -struct vcd_property_avc_delimiter_enable { - u32 avc_delimiter_enable_flag; -}; - -struct vcd_property_vui_timing_info_enable { - u32 vui_timing_info; -}; - -struct vcd_property_range_type { - u32 min; - u32 max; - u32 step_size; -}; - -enum vcd_property_ltrmode { - VCD_LTR_MODE_DISABLE = 0, - VCD_LTR_MODE_MANUAL = 1, - VCD_LTR_MODE_AUTO = 2, - VCD_LTR_MODE_MAX = 0x7fffffff -}; - -struct vcd_property_ltrmode_type { - enum vcd_property_ltrmode ltr_mode; -}; - -struct vcd_property_ltrcount_type { - u32 ltr_count; -}; - -struct vcd_property_ltrperiod_type { - u32 ltr_period; -}; - -struct vcd_property_ltruse_type { - u32 ltr_id; - u32 ltr_frames; -}; - -struct vcd_property_meta_buffer { - u8 *kernel_virtual_addr; - u8 *physical_addr; - u32 size; - u32 count; - int pmem_fd; - u32 offset; - u8 *dev_addr; - void *client_data; - u8 *kernel_virt_addr_iommu; - u8 *physical_addr_iommu; - int pmem_fd_iommu; - u8 *dev_addr_iommu; - void *client_data_iommu; -}; -#endif diff --git a/include/media/msm/vcd_status.h b/include/media/msm/vcd_status.h deleted file mode 100644 index 7419b238560342822012b50e0a06e6340a77de27..0000000000000000000000000000000000000000 --- a/include/media/msm/vcd_status.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2010-2012, 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 _VCD_ERR_STATUS_H_ -#define _VCD_ERR_STATUS_H_ - -#define VCD_EVT_RESP_BASE 0x1000 -#define VCD_EVT_RESP_OPEN (VCD_EVT_RESP_BASE + 0x1) -#define VCD_EVT_RESP_START (VCD_EVT_RESP_BASE + 0x2) -#define VCD_EVT_RESP_STOP (VCD_EVT_RESP_BASE + 0x3) -#define VCD_EVT_RESP_PAUSE (VCD_EVT_RESP_BASE + 0x4) -#define VCD_EVT_RESP_FLUSH_INPUT_DONE (VCD_EVT_RESP_BASE + 0x5) -#define VCD_EVT_RESP_FLUSH_OUTPUT_DONE (VCD_EVT_RESP_BASE + 0x6) -#define VCD_EVT_RESP_INPUT_FLUSHED (VCD_EVT_RESP_BASE + 0x7) -#define VCD_EVT_RESP_OUTPUT_FLUSHED (VCD_EVT_RESP_BASE + 0x8) -#define VCD_EVT_RESP_INPUT_DONE (VCD_EVT_RESP_BASE + 0x9) -#define VCD_EVT_RESP_OUTPUT_DONE (VCD_EVT_RESP_BASE + 0xa) - -#define VCD_EVT_IND_BASE 0x2000 -#define VCD_EVT_IND_INPUT_RECONFIG (VCD_EVT_IND_BASE + 0x1) -#define VCD_EVT_IND_OUTPUT_RECONFIG (VCD_EVT_IND_BASE + 0x2) -#define VCD_EVT_IND_HWERRFATAL (VCD_EVT_IND_BASE + 0x3) -#define VCD_EVT_IND_RESOURCES_LOST (VCD_EVT_IND_BASE + 0x4) -#define VCD_EVT_IND_INFO_OUTPUT_RECONFIG (VCD_EVT_IND_BASE + 0x5) -#define VCD_EVT_IND_INFO_FIELD_DROPPED (VCD_EVT_IND_BASE + 0x6) -#define VCD_EVT_IND_INFO_LTRUSE_FAILED (VCD_EVT_IND_BASE + 0x7) - -#define VCD_S_SUCCESS 0x0 - -#define VCD_S_ERR_BASE 0x80000000 -#define VCD_ERR_FAIL (VCD_S_ERR_BASE + 0x01) -#define VCD_ERR_ALLOC_FAIL (VCD_S_ERR_BASE + 0x02) -#define VCD_ERR_ILLEGAL_OP (VCD_S_ERR_BASE + 0x03) -#define VCD_ERR_ILLEGAL_PARM (VCD_S_ERR_BASE + 0x04) -#define VCD_ERR_BAD_POINTER (VCD_S_ERR_BASE + 0x05) -#define VCD_ERR_BAD_HANDLE (VCD_S_ERR_BASE + 0x06) -#define VCD_ERR_NOT_SUPPORTED (VCD_S_ERR_BASE + 0x07) -#define VCD_ERR_BAD_STATE (VCD_S_ERR_BASE + 0x08) -#define VCD_ERR_BUSY (VCD_S_ERR_BASE + 0x09) -#define VCD_ERR_MAX_CLIENT (VCD_S_ERR_BASE + 0x0a) -#define VCD_ERR_IFRAME_EXPECTED (VCD_S_ERR_BASE + 0x0b) -#define VCD_ERR_INTRLCD_FIELD_DROP (VCD_S_ERR_BASE + 0x0c) -#define VCD_ERR_HW_FATAL (VCD_S_ERR_BASE + 0x0d) -#define VCD_ERR_BITSTREAM_ERR (VCD_S_ERR_BASE + 0x0e) -#define VCD_ERR_QEMPTY (VCD_S_ERR_BASE + 0x0f) -#define VCD_ERR_SEQHDR_PARSE_FAIL (VCD_S_ERR_BASE + 0x10) -#define VCD_ERR_INPUT_NOT_PROCESSED (VCD_S_ERR_BASE + 0x11) -#define VCD_ERR_INDEX_NOMORE (VCD_S_ERR_BASE + 0x12) - -#define VCD_FAILED(rc) ((rc > VCD_S_ERR_BASE) ? true : false) - -#endif diff --git a/include/media/msm/vidc_init.h b/include/media/msm/vidc_init.h deleted file mode 100644 index bcc037026ae0ee2e92b4de1b4b697ea48d793834..0000000000000000000000000000000000000000 --- a/include/media/msm/vidc_init.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (c) 2010-2012, 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 VIDC_INIT_H -#define VIDC_INIT_H -#include -#include -#include - -#define VIDC_MAX_NUM_CLIENTS 4 -#define MAX_VIDEO_NUM_OF_BUFF 100 -#define MAX_META_BUFFERS 32 - -enum buffer_dir { - BUFFER_TYPE_INPUT, - BUFFER_TYPE_OUTPUT -}; - -struct buf_addr_table { - unsigned long user_vaddr; - unsigned long kernel_vaddr; - unsigned long phy_addr; - unsigned long buff_ion_flag; - struct ion_handle *buff_ion_handle; - int pmem_fd; - struct file *file; - unsigned long dev_addr; - void *client_data; -}; - -struct meta_buffer_addr_table { - u8 *kernel_vir_addr; - u8 *kernel_vir_addr_iommu; -}; - -struct video_client_ctx { - void *vcd_handle; - u32 num_of_input_buffers; - u32 num_of_output_buffers; - struct buf_addr_table input_buf_addr_table[MAX_VIDEO_NUM_OF_BUFF]; - struct buf_addr_table output_buf_addr_table[MAX_VIDEO_NUM_OF_BUFF]; - struct list_head msg_queue; - struct mutex msg_queue_lock; - struct mutex enrty_queue_lock; - wait_queue_head_t msg_wait; - struct completion event; - struct vcd_property_h264_mv_buffer vcd_h264_mv_buffer; - struct vcd_property_meta_buffer vcd_meta_buffer; - struct vcd_property_enc_recon_buffer recon_buffer[4]; - u32 event_status; - u32 seq_header_set; - u32 stop_msg; - u32 stop_called; - u32 stop_sync_cb; - size_t meta_buf_size; - struct ion_client *user_ion_client; - struct ion_handle *seq_hdr_ion_handle; - struct ion_handle *h264_mv_ion_handle; - struct ion_handle *recon_buffer_ion_handle[4]; - struct ion_handle *meta_buffer_ion_handle; - struct ion_handle *meta_buffer_iommu_ion_handle; - u32 dmx_disable; - struct meta_buffer_addr_table meta_addr_table[MAX_META_BUFFERS]; -}; - -void __iomem *vidc_get_ioaddr(void); -int vidc_load_firmware(void); -void vidc_release_firmware(void); -u32 vidc_get_fd_info(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, int pmem_fd, - unsigned long kvaddr, int index, - struct ion_handle **buff_handle); -u32 vidc_lookup_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, u32 search_with_user_vaddr, - unsigned long *user_vaddr, unsigned long *kernel_vaddr, - unsigned long *phy_addr, int *pmem_fd, struct file **file, - s32 *buffer_index); -u32 vidc_insert_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, unsigned long user_vaddr, - unsigned long *kernel_vaddr, int pmem_fd, - unsigned long buffer_addr_offset, - unsigned int max_num_buffers, unsigned long length); -u32 vidc_insert_addr_table_kernel(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, unsigned long user_vaddr, - unsigned long kernel_vaddr, unsigned long phys_addr, - unsigned int max_num_buffers, - unsigned long length); -u32 vidc_delete_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer, unsigned long user_vaddr, - unsigned long *kernel_vaddr); -void vidc_cleanup_addr_table(struct video_client_ctx *client_ctx, - enum buffer_dir buffer); - -u32 vidc_timer_create(void (*timer_handler)(void *), - void *user_data, void **timer_handle); -void vidc_timer_release(void *timer_handle); -void vidc_timer_start(void *timer_handle, u32 time_out); -void vidc_timer_stop(void *timer_handle); - - -#endif diff --git a/include/media/msm/vidc_type.h b/include/media/msm/vidc_type.h deleted file mode 100644 index 5463fc6b19bc35bf38df2ed383927ad689455c9d..0000000000000000000000000000000000000000 --- a/include/media/msm/vidc_type.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2010-2013, 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 VIDC_TYPE_H -#define VIDC_TYPE_H - -#include -#include -#include -#include -#include -#include -#include -#include - - -#define DDL_MSG_LOG 0 -#define DEBUG 0 -#define VIDC_ENABLE_DBGFS -#define USE_RES_TRACKER - -#endif diff --git a/include/media/msm_v4l2_overlay.h b/include/media/msm_v4l2_overlay.h deleted file mode 100644 index c83cfb7b19169b2924b244b9e0fffe9ac20faded..0000000000000000000000000000000000000000 --- a/include/media/msm_v4l2_overlay.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef LINUX_MSM_V4L2_OVERLAY -#define LINUX_MSM_V4L2_OVERLAY - -#include - -#define VIDIOC_MSM_USERPTR_QBUF \ -_IOWR('V', BASE_VIDIOC_PRIVATE, struct v4l2_buffer) - -#endif diff --git a/include/media/user-rc-input.h b/include/media/user-rc-input.h deleted file mode 100644 index 0eb9aec708babf37d82bf11e4e6ef28352b22c86..0000000000000000000000000000000000000000 --- a/include/media/user-rc-input.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2012, 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 __USER_RC_INPUT_H__ -#define __USER_RC_INPUT_H__ - -#define USER_CONTROL_PRESSED 0x01 -#define USER_CONTROL_REPEATED 0x02 -#define USER_CONTROL_RELEASED 0x03 - -#endif /* __USER_RC_INPUT_H__ */ - diff --git a/include/media/vcap_v4l2.h b/include/media/vcap_v4l2.h deleted file mode 100644 index d186000e2231e1fb75bf2f3e455c8cc360458df2..0000000000000000000000000000000000000000 --- a/include/media/vcap_v4l2.h +++ /dev/null @@ -1,276 +0,0 @@ -/* Copyright (c) 2012-2013, 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 VCAP_V4L2_H -#define VCAP_V4L2_H - -#ifdef __KERNEL__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define to_client_data(val) container_of(val, struct vcap_client_data, vfh) - -#define writel_iowmb(val, addr) \ - do { \ - __iowmb(); \ - writel_relaxed(val, addr); \ - } while (0) - -#define VCAP_USEC (1000000) - -#define VCAP_STRIDE_ALIGN_16 0x10 -#define VCAP_STRIDE_ALIGN_32 0x20 -#define VCAP_STRIDE_CALC(x, align) (((x / align) + \ - (!(!(x % align)))) * align) - -#define VCAP_BASE (dev->vcapbase) -#define VCAP_OFFSET(off) (VCAP_BASE + off) - -struct reg_range { - u32 min_val; - u32 max_val; -}; - -#define VCAP_REG_RANGE_1_MIN 0x0 -#define VCAP_REG_RANGE_1_MAX 0x48 -#define VCAP_REG_RANGE_2_MIN 0x100 -#define VCAP_REG_RANGE_2_MAX 0x104 -#define VCAP_REG_RANGE_3_MIN 0x400 -#define VCAP_REG_RANGE_3_MAX 0x7F0 -#define VCAP_REG_RANGE_4_MIN 0x800 -#define VCAP_REG_RANGE_4_MAX 0x8A0 -#define VCAP_REG_RANGE_5_MIN 0xC00 -#define VCAP_REG_RANGE_5_MAX 0xDF0 - -#define VCAP_SW_RESET_REQ (VCAP_BASE + 0x024) -#define VCAP_SW_RESET_STATUS (VCAP_BASE + 0x028) - -#define VCAP_VP_MIN_BUF 4 -#define VCAP_VC_MAX_BUF 6 -#define VCAP_VC_MIN_BUF 2 -struct vcap_client_data; - -enum vp_state { - VP_UNKNOWN = 0, - VP_FRAME1, - VP_FRAME2, - VP_FRAME3, - VP_NORMAL, -}; - -enum nr_buf_pos { - BUF_NOT_IN_USE = 0, - NRT2_BUF, - T1_BUF, - T0_BUF, - TM1_BUF, -}; - -struct vcap_buf_info { - unsigned long vaddr; - unsigned long size; -}; - -enum vcap_op_mode { - UNKNOWN_VCAP_OP = 0, - VC_VCAP_OP, - VP_VCAP_OP, - VC_AND_VP_VCAP_OP, -}; - -struct vc_action { - struct list_head active; - - /* thread for generating video stream*/ - wait_queue_head_t wq; - - /* Buffer index */ - uint8_t tot_buf; - uint8_t buf_num; - - bool field1; - bool field_dropped; - - struct timeval vc_ts; - uint32_t last_ts; - - /* Buffers inside vc */ - struct vcap_buffer *buf[6]; -}; - -struct nr_buffer { - struct ion_handle *nr_handle; - unsigned long paddr; - enum nr_buf_pos nr_pos; -}; - -struct vp_action { - struct list_head in_active; - struct list_head out_active; - - /* Buffer index */ - enum vp_state vp_state; - - /* Buffers inside vc */ - struct vcap_buffer *bufTm1; - struct vcap_buffer *bufT0; - struct vcap_buffer *bufT1; - struct vcap_buffer *bufT2; - struct vcap_buffer *bufNRT2; - - struct vcap_buffer *bufOut; - - struct ion_handle *motionHandle; - void *bufMotion; - struct nr_buffer bufNR; -}; - -struct vp_work_t { - struct work_struct work; - struct vcap_client_data *cd; -}; - -struct vcap_debugfs_params { - atomic_t vc_drop_count; - uint32_t vc_timestamp; - uint32_t vp_timestamp; - uint32_t vp_ewma;/* Exponential moving average */ - uint32_t clk_rate; - uint32_t bw_request; - uint32_t reg_addr; -}; - -struct vcap_dev { - struct v4l2_device v4l2_dev; - - struct video_device *vfd; - struct ion_client *ion_client; - - struct resource *vcirq; - struct resource *vpirq; - - struct resource *vcapmem; - struct resource *vcapio; - void __iomem *vcapbase; - - struct vcap_platform_data *vcap_pdata; - - struct regulator *fs_vcap; - struct clk *vcap_clk; - struct clk *vcap_p_clk; - struct clk *vcap_npl_clk; - struct device *ddev; - /*struct platform_device *pdev;*/ - - uint32_t bus_client_handle; - - int domain_num; - struct device *vc_iommu_ctx; - struct device *vp_iommu_ctx; - struct iommu_domain *iommu_vcap_domain; - - struct vcap_client_data *vc_client; - struct vcap_client_data *vp_client; - - atomic_t vc_enabled; - atomic_t vp_enabled; - - struct mutex dev_mutex; - atomic_t open_clients; - bool vc_resource; - bool vp_resource; - bool vp_dummy_event; - bool vp_dummy_complete; - bool vp_shutdown; - wait_queue_head_t vp_dummy_waitq; - - uint8_t vc_tot_buf; - - struct workqueue_struct *vcap_wq; - struct vp_work_t vp_work; - struct vp_work_t vc_to_vp_work; - struct vp_work_t vp_to_vc_work; - - struct nr_param nr_param; - bool nr_update; - struct vcap_debugfs_params dbg_p; -}; - -struct vp_format_data { - unsigned int width, height; - unsigned int pixfmt; -}; - -struct vcap_buffer { - /* common v4l buffer stuff -- must be first */ - struct vb2_buffer vb; - struct list_head list; - dma_addr_t paddr; - struct ion_handle *ion_handle; -}; - -struct vcap_client_data { - bool set_cap, set_decode, set_vp_o; - struct vcap_dev *dev; - - struct vb2_queue vc_vidq; - struct vb2_queue vp_in_vidq; - struct vb2_queue vp_out_vidq; - - enum vcap_op_mode op_mode; - - struct v4l2_format_vc_ext vc_format; - enum vcap_stride stride; - - enum v4l2_buf_type vp_buf_type_field; - struct vp_format_data vp_in_fmt; - struct vp_format_data vp_out_fmt; - - struct vc_action vc_action; - struct vp_action vp_action; - struct workqueue_struct *vcap_work_q; - struct ion_handle *vc_ion_handle; - - uint32_t hold_vc; - uint32_t hold_vp; - - /* Mutex ensures only one thread is dq buffer or turning streamoff */ - struct mutex mutex; - spinlock_t cap_slock; - bool streaming; - - struct v4l2_fh vfh; -}; - -struct vcap_hacked_vals { - uint32_t value; - uint32_t offset; -}; - -extern struct vcap_hacked_vals hacked_buf[]; - -#endif -int vcvp_qbuf(struct vb2_queue *q, struct v4l2_buffer *b); -int vcvp_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b); -#endif diff --git a/include/media/videobuf-msm-mem.h b/include/media/videobuf-msm-mem.h deleted file mode 100644 index 5e9790cdd60168dc6620e363165a90bc6f2406fe..0000000000000000000000000000000000000000 --- a/include/media/videobuf-msm-mem.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2011, 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. - * - * helper functions for physically contiguous PMEM capture buffers - */ - -#ifndef _VIDEOBUF_PMEM_CONTIG_H -#define _VIDEOBUF_PMEM_CONTIG_H - -#include - -struct videobuf_contig_pmem { - u32 magic; - void *vaddr; - int phyaddr; - unsigned long size; - int is_userptr; - uint32_t y_off; - uint32_t cbcr_off; - int buffer_type; - struct file *file; -}; - -void videobuf_queue_pmem_contig_init(struct videobuf_queue *q, - const struct videobuf_queue_ops *ops, - struct device *dev, - spinlock_t *irqlock, - enum v4l2_buf_type type, - enum v4l2_field field, - unsigned int msize, - void *priv, - struct mutex *ext_lock); - -int videobuf_to_pmem_contig(struct videobuf_buffer *buf); -int videobuf_pmem_contig_free(struct videobuf_queue *q, - struct videobuf_buffer *buf); - -#endif /* _VIDEOBUF_PMEM_CONTIG_H */ diff --git a/include/sound/dai.h b/include/sound/dai.h deleted file mode 100644 index 031fe3b80a5a429b342236666ab930a5d4155c7c..0000000000000000000000000000000000000000 --- a/include/sound/dai.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __DAI_H__ -#define __DAI_H__ - -struct dai_dma_params { - u8 *buffer; - uint32_t src_start; - uint32_t bus_id; - int buffer_size; - int period_size; - int channels; -}; - -enum { - DAI_SPKR = 0, - DAI_MIC, - DAI_MI2S, - DAI_SEC_SPKR, - DAI_SEC_MIC, -}; - -/* Function Prototypes */ -int dai_open(uint32_t dma_ch); -void dai_close(uint32_t dma_ch); -int dai_start(uint32_t dma_ch); -int dai_stop(uint32_t dma_ch); -int dai_set_params(uint32_t dma_ch, struct dai_dma_params *params); -uint32_t dai_get_dma_pos(uint32_t dma_ch); -void register_dma_irq_handler(int dma_ch, - irqreturn_t (*callback) (int intrSrc, void *private_data), - void *private_data); -void unregister_dma_irq_handler(int dma_ch); -void dai_set_master_mode(uint32_t dma_ch, int mode); -int dai_start_hdmi(uint32_t dma_ch); -int wait_for_dma_cnt_stop(uint32_t dma_ch); -void dai_stop_hdmi(uint32_t dma_ch); - -#endif diff --git a/include/sound/msm-dai-q6.h b/include/sound/msm-dai-q6.h deleted file mode 100644 index a39d3dc08d00864716cb6f58717a725dda0e5fc5..0000000000000000000000000000000000000000 --- a/include/sound/msm-dai-q6.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2011, 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 __MSM_DAI_Q6_PDATA_H__ - -#define __MSM_DAI_Q6_PDATA_H__ - -#define MSM_MI2S_SD0 (1 << 0) -#define MSM_MI2S_SD1 (1 << 1) -#define MSM_MI2S_SD2 (1 << 2) -#define MSM_MI2S_SD3 (1 << 3) -#define MSM_MI2S_CAP_RX 0 -#define MSM_MI2S_CAP_TX 1 - -struct msm_dai_auxpcm_config { - u16 mode; - u16 sync; - u16 frame; - u16 quant; - u16 slot; - u16 data; - int pcm_clk_rate; -}; - -struct msm_mi2s_pdata { - u16 rx_sd_lines; - u16 tx_sd_lines; -}; - -struct msm_dai_auxpcm_pdata { - const char *clk; - struct msm_dai_auxpcm_config mode_8k; - struct msm_dai_auxpcm_config mode_16k; -}; - -#endif diff --git a/include/sound/omap-abe-dsp.h b/include/sound/omap-abe-dsp.h deleted file mode 100644 index 60c405d48c61f33b3fda83cf0190e49dd41b2b17..0000000000000000000000000000000000000000 --- a/include/sound/omap-abe-dsp.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * omap-aess -- OMAP4 ABE DSP - * - * Author: Liam Girdwood - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef _OMAP4_ABE_DSP_H -#define _OMAP4_ABE_DSP_H - -struct omap4_abe_dsp_pdata { - /* Return context loss count due to PM states changing */ - int (*get_context_loss_count)(struct device *dev); -}; - -#endif diff --git a/include/sound/q6adm.h b/include/sound/q6adm.h deleted file mode 100644 index b819725ffb7da4137c11626db1b371e1554d2e53..0000000000000000000000000000000000000000 --- a/include/sound/q6adm.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) 2010-2012, 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 __Q6_ADM_H__ -#define __Q6_ADM_H__ -#include - -#define ADM_PATH_PLAYBACK 0x1 -#define ADM_PATH_LIVE_REC 0x2 -#define ADM_PATH_NONLIVE_REC 0x3 - -/* multiple copp per stream. */ -struct route_payload { - unsigned int copp_ids[AFE_MAX_PORTS]; - unsigned short num_copps; - unsigned int session_id; -}; - -int adm_open(int port, int path, int rate, int mode, int topology); - -int adm_multi_ch_copp_open(int port, int path, int rate, int mode, - int topology, int perfmode); - -int adm_memory_map_regions(uint32_t *buf_add, uint32_t mempool_id, - uint32_t *bufsz, uint32_t bufcnt); - -int adm_memory_unmap_regions(uint32_t *buf_add, uint32_t *bufsz, - uint32_t bufcnt); - -int adm_close(int port); - -int adm_pseudo_close(int port); - -int adm_matrix_map(int session_id, int path, int num_copps, - unsigned int *port_id, int copp_id); - -int adm_connect_afe_port(int mode, int session_id, int port_id); -int adm_disconnect_afe_port(int mode, int session_id, int port_id); - -void adm_ec_ref_rx_id(int port_id); - -int adm_connect_afe_port_v2(int mode, int session_id, int port_id, - int sample_rate, int channels); - -int adm_multi_ch_copp_pseudo_open_v3(int port_id, int path, int rate, - int channel_mode, int topology); - -#ifdef CONFIG_RTAC -int adm_get_copp_id(int port_id); -#endif - -#endif /* __Q6_ADM_H__ */ diff --git a/include/sound/q6afe.h b/include/sound/q6afe.h deleted file mode 100644 index 54ba4758cf06dd59a84c5e07ff3be80bd48724a7..0000000000000000000000000000000000000000 --- a/include/sound/q6afe.h +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (c) 2010-2012, 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 __Q6AFE_H__ -#define __Q6AFE_H__ -#include - -#define MSM_AFE_MONO 0 -#define MSM_AFE_MONO_RIGHT 1 -#define MSM_AFE_MONO_LEFT 2 -#define MSM_AFE_STEREO 3 -#define MSM_AFE_4CHANNELS 4 -#define MSM_AFE_6CHANNELS 6 -#define MSM_AFE_8CHANNELS 8 - -#define MSM_AFE_I2S_FORMAT_LPCM 0 -#define MSM_AFE_I2S_FORMAT_COMPR 1 -#define MSM_AFE_I2S_FORMAT_IEC60958_LPCM 2 -#define MSM_AFE_I2S_FORMAT_IEC60958_COMPR 3 - -#define MSM_AFE_PORT_TYPE_RX 0 -#define MSM_AFE_PORT_TYPE_TX 1 - -#define RT_PROXY_DAI_001_RX 0xE0 -#define RT_PROXY_DAI_001_TX 0xF0 -#define RT_PROXY_DAI_002_RX 0xF1 -#define RT_PROXY_DAI_002_TX 0xE1 -#define VIRTUAL_ID_TO_PORTID(val) ((val & 0xF) | 0x2000) - -enum { - IDX_PRIMARY_I2S_RX = 0, - IDX_PRIMARY_I2S_TX = 1, - IDX_PCM_RX = 2, - IDX_PCM_TX = 3, - IDX_SECONDARY_I2S_RX = 4, - IDX_SECONDARY_I2S_TX = 5, - IDX_MI2S_RX = 6, - IDX_MI2S_TX = 7, - IDX_HDMI_RX = 8, - IDX_RSVD_2 = 9, - IDX_RSVD_3 = 10, - IDX_DIGI_MIC_TX = 11, - IDX_VOICE_RECORD_RX = 12, - IDX_VOICE_RECORD_TX = 13, - IDX_VOICE_PLAYBACK_TX = 14, - IDX_SLIMBUS_0_RX = 15, - IDX_SLIMBUS_0_TX = 16, - IDX_SLIMBUS_1_RX = 17, - IDX_SLIMBUS_1_TX = 18, - IDX_SLIMBUS_2_RX = 19, - IDX_SLIMBUS_2_TX = 20, - IDX_SLIMBUS_3_RX = 21, - IDX_SLIMBUS_3_TX = 22, - IDX_SLIMBUS_4_RX = 23, - IDX_SLIMBUS_4_TX = 24, - IDX_INT_BT_SCO_RX = 25, - IDX_INT_BT_SCO_TX = 26, - IDX_INT_BT_A2DP_RX = 27, - IDX_INT_FM_RX = 28, - IDX_INT_FM_TX = 29, - IDX_RT_PROXY_PORT_001_RX = 30, - IDX_RT_PROXY_PORT_001_TX = 31, - IDX_SECONDARY_PCM_RX = 32, - IDX_SECONDARY_PCM_TX = 33, - IDX_PSEUDOPORT_01 = 34, - AFE_MAX_PORTS -}; - -int afe_open(u16 port_id, union afe_port_config *afe_config, int rate); -int afe_close(int port_id); -int afe_loopback(u16 enable, u16 rx_port, u16 tx_port); -int afe_loopback_cfg(u16 enable, u16 dst_port, u16 src_port, u16 mode); -int afe_sidetone(u16 tx_port_id, u16 rx_port_id, u16 enable, uint16_t gain); -int afe_loopback_gain(u16 port_id, u16 volume); -int afe_validate_port(u16 port_id); -int afe_get_port_index(u16 port_id); -int afe_start_pseudo_port(u16 port_id); -int afe_stop_pseudo_port(u16 port_id); -int afe_cmd_memory_map(u32 dma_addr_p, u32 dma_buf_sz); -int afe_cmd_memory_map_nowait(u32 dma_addr_p, u32 dma_buf_sz); -int afe_cmd_memory_unmap(u32 dma_addr_p); -int afe_cmd_memory_unmap_nowait(u32 dma_addr_p); -void afe_set_dtmf_gen_rx_portid(u16 rx_port_id, int set); -int afe_dtmf_generate_rx(int64_t duration_in_ms, - uint16_t high_freq, - uint16_t low_freq, uint16_t gain); -int afe_register_get_events(u16 port_id, - void (*cb) (uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv), - void *private_data); -int afe_unregister_get_events(u16 port_id); -int afe_rt_proxy_port_write(u32 buf_addr_p, int bytes); -int afe_rt_proxy_port_read(u32 buf_addr_p, int bytes); -int afe_port_start(u16 port_id, union afe_port_config *afe_config, u32 rate); -int afe_port_stop_nowait(int port_id); -int afe_apply_gain(u16 port_id, u16 gain); -int afe_q6_interface_prepare(void); -int afe_get_port_type(u16 port_id); -/* if port_id is virtual, convert to physical.. - * if port_id is already physical, return physical - */ -int afe_convert_virtual_to_portid(u16 port_id); - -int afe_pseudo_port_start_nowait(u16 port_id); -int afe_pseudo_port_stop_nowait(u16 port_id); -#endif /* __Q6AFE_H__ */ diff --git a/include/sound/q6asm.h b/include/sound/q6asm.h deleted file mode 100644 index 41f875b823815402e5cb900faab86cc746552ad8..0000000000000000000000000000000000000000 --- a/include/sound/q6asm.h +++ /dev/null @@ -1,353 +0,0 @@ -/* Copyright (c) 2010-2013, 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 __Q6_ASM_H__ -#define __Q6_ASM_H__ - -#include -#include -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION -#include -#endif - -#define IN 0x000 -#define OUT 0x001 -#define CH_MODE_MONO 0x001 -#define CH_MODE_STEREO 0x002 - -#define FORMAT_LINEAR_PCM 0x0000 -#define FORMAT_DTMF 0x0001 -#define FORMAT_ADPCM 0x0002 -#define FORMAT_YADPCM 0x0003 -#define FORMAT_MP3 0x0004 -#define FORMAT_MPEG4_AAC 0x0005 -#define FORMAT_AMRNB 0x0006 -#define FORMAT_AMRWB 0x0007 -#define FORMAT_V13K 0x0008 -#define FORMAT_EVRC 0x0009 -#define FORMAT_EVRCB 0x000a -#define FORMAT_EVRCWB 0x000b -#define FORMAT_MIDI 0x000c -#define FORMAT_SBC 0x000d -#define FORMAT_WMA_V10PRO 0x000e -#define FORMAT_WMA_V9 0x000f -#define FORMAT_AMR_WB_PLUS 0x0010 -#define FORMAT_MPEG4_MULTI_AAC 0x0011 -#define FORMAT_MULTI_CHANNEL_LINEAR_PCM 0x0012 -#define FORMAT_AC3 0x0013 -#define FORMAT_DTS 0x0014 -#define FORMAT_EAC3 0x0015 -#define FORMAT_ATRAC 0x0016 -#define FORMAT_MAT 0x0017 -#define FORMAT_AAC 0x0018 -#define FORMAT_DTS_LBR 0x0019 -#define FORMAT_PASS_THROUGH 0x0020 -#define FORMAT_MP2 0x0021 - -#define ENCDEC_SBCBITRATE 0x0001 -#define ENCDEC_IMMEDIATE_DECODE 0x0002 -#define ENCDEC_CFG_BLK 0x0003 -#define DTS_ENC_SAMPLE_RATE48k 48000 - -#define CMD_PAUSE 0x0001 -#define CMD_FLUSH 0x0002 -#define CMD_EOS 0x0003 -#define CMD_CLOSE 0x0004 -#define CMD_OUT_FLUSH 0x0005 - -/* bit 0:1 represents priority of stream */ -#define STREAM_PRIORITY_NORMAL 0x0000 -#define STREAM_PRIORITY_LOW 0x0001 -#define STREAM_PRIORITY_HIGH 0x0002 - -/* bit 4 represents META enable of encoded data buffer */ -#define BUFFER_META_ENABLE 0x0010 - -/* Enable Sample_Rate/Channel_Mode notification event from Decoder */ -#define SR_CM_NOTIFY_ENABLE 0x0004 - -#define TUN_WRITE_IO_MODE 0x0008 /* tunnel read write mode */ -#define TUN_READ_IO_MODE 0x0004 /* tunnel read write mode */ -#define ASYNC_IO_MODE 0x0002 -#define SYNC_IO_MODE 0x0001 -#define NO_TIMESTAMP 0xFF00 -#define SET_TIMESTAMP 0x0000 - -#define SOFT_PAUSE_ENABLE 1 -#define SOFT_PAUSE_DISABLE 0 - -#define SESSION_MAX 0x08 - -#define SOFT_PAUSE_PERIOD 30 /* ramp up/down for 30ms */ -#define SOFT_PAUSE_STEP_LINEAR 0 /* Step value 0ms or 0us */ -#define SOFT_PAUSE_STEP 0 /* Step value 0ms or 0us */ -enum { - SOFT_PAUSE_CURVE_LINEAR = 0, - SOFT_PAUSE_CURVE_EXP, - SOFT_PAUSE_CURVE_LOG, -}; - -#define SOFT_VOLUME_PERIOD 30 /* ramp up/down for 30ms */ -#define SOFT_VOLUME_STEP_LINEAR 0 /* Step value 0ms or 0us */ -#define SOFT_VOLUME_STEP 0 /* Step value 0ms or 0us */ -enum { - SOFT_VOLUME_CURVE_LINEAR = 0, - SOFT_VOLUME_CURVE_EXP, - SOFT_VOLUME_CURVE_LOG, -}; - -typedef void (*app_cb)(uint32_t opcode, uint32_t token, - uint32_t *payload, void *priv); - -struct audio_buffer { - dma_addr_t phys; - void *data; - uint32_t used; - uint32_t size;/* size of buffer */ - uint32_t actual_size; /* actual number of bytes read by DSP */ -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - struct ion_handle *handle; - struct ion_client *client; -#else - void *mem_buffer; -#endif -}; - -struct audio_aio_write_param { - unsigned long paddr; - uint32_t uid; - uint32_t len; - uint32_t msw_ts; - uint32_t lsw_ts; - uint32_t flags; -}; - -struct audio_aio_read_param { - unsigned long paddr; - uint32_t len; - uint32_t uid; -}; - -struct audio_port_data { - struct audio_buffer *buf; - uint32_t max_buf_cnt; - uint32_t dsp_buf; - uint32_t cpu_buf; - /* read or write locks */ - struct mutex lock; - spinlock_t dsp_lock; -}; - -struct audio_client { - int session; - /* idx:1 out port, 0: in port*/ - struct audio_port_data port[2]; - - struct apr_svc *apr; - struct mutex cmd_lock; - - atomic_t cmd_state; - atomic_t cmd_close_state; - atomic_t time_flag; - atomic_t nowait_cmd_cnt; - wait_queue_head_t cmd_wait; - wait_queue_head_t time_wait; - - app_cb cb; - void *priv; - uint32_t io_mode; - uint64_t time_stamp; - atomic_t cmd_response; - bool perf_mode; -}; - -void q6asm_audio_client_free(struct audio_client *ac); - -struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv); - -struct audio_client *q6asm_get_audio_client(int session_id); - -int q6asm_audio_client_buf_alloc(unsigned int dir/* 1:Out,0:In */, - struct audio_client *ac, - unsigned int bufsz, - unsigned int bufcnt); -int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir - /* 1:Out,0:In */, - struct audio_client *ac, - unsigned int bufsz, - unsigned int bufcnt); - -int q6asm_audio_client_buf_free_contiguous(unsigned int dir, - struct audio_client *ac); - -int q6asm_open_read(struct audio_client *ac, uint32_t format); -int q6asm_open_read_v2_1(struct audio_client *ac, uint32_t format); - -int q6asm_open_read_compressed(struct audio_client *ac, - uint32_t frames_per_buffer, uint32_t meta_data_mode); - -int q6asm_open_write(struct audio_client *ac, uint32_t format); - -int q6asm_open_write_compressed(struct audio_client *ac, uint32_t format); - -int q6asm_open_transcode_loopback(struct audio_client *ac, uint32_t channels); - -int q6asm_enc_cfg_blk_dts(struct audio_client *ac, - uint32_t sample_rate, uint32_t channels); - -int q6asm_open_read_write(struct audio_client *ac, - uint32_t rd_format, - uint32_t wr_format); - -int q6asm_open_loopack(struct audio_client *ac); - -int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts, - uint32_t lsw_ts, uint32_t flags); -int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts, - uint32_t lsw_ts, uint32_t flags); - -int q6asm_async_write(struct audio_client *ac, - struct audio_aio_write_param *param); - -int q6asm_async_read(struct audio_client *ac, - struct audio_aio_read_param *param); - -int q6asm_async_read_compressed(struct audio_client *ac, - struct audio_aio_read_param *param); - -int q6asm_read(struct audio_client *ac); -int q6asm_read_nolock(struct audio_client *ac); - -int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add, - int dir, uint32_t bufsz, uint32_t bufcnt); - -int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add, - int dir); - -int q6asm_run(struct audio_client *ac, uint32_t flags, - uint32_t msw_ts, uint32_t lsw_ts); - -int q6asm_run_nowait(struct audio_client *ac, uint32_t flags, - uint32_t msw_ts, uint32_t lsw_ts); - -int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable); - -int q6asm_cmd(struct audio_client *ac, int cmd); - -int q6asm_cmd_nowait(struct audio_client *ac, int cmd); - -void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac, - uint32_t *size, uint32_t *idx); - -void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac, - uint32_t *size, uint32_t *idx); - -int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac); - -/* File format specific configurations to be added below */ - -int q6asm_enc_cfg_blk_aac(struct audio_client *ac, - uint32_t frames_per_buf, - uint32_t sample_rate, uint32_t channels, - uint32_t bit_rate, - uint32_t mode, uint32_t format); - -int q6asm_enc_cfg_blk_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels); - -int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac, - uint32_t rate, uint32_t channels); - -int q6asm_enc_cfg_blk_multi_ch_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels); - -int q6asm_enable_sbrps(struct audio_client *ac, - uint32_t sbr_ps); - -int q6asm_cfg_dual_mono_aac(struct audio_client *ac, - uint16_t sce_left, uint16_t sce_right); - -int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff); - -int q6asm_set_encdec_chan_map(struct audio_client *ac, - uint32_t num_channels); - -int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t min_rate, uint16_t max_rate, - uint16_t reduced_rate_level, uint16_t rate_modulation_cmd); - -int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t min_rate, uint16_t max_rate, - uint16_t rate_modulation_cmd); - -int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t band_mode, uint16_t dtx_enable); - -int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t band_mode, uint16_t dtx_enable); - -int q6asm_media_format_block_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels); - -int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels, - char *channel_map); - -int q6asm_media_format_block_aac(struct audio_client *ac, - struct asm_aac_cfg *cfg); - -int q6asm_media_format_block_amrwbplus(struct audio_client *ac, - struct asm_amrwbplus_cfg *cfg); - -int q6asm_media_format_block_multi_aac(struct audio_client *ac, - struct asm_aac_cfg *cfg); - -int q6asm_media_format_block_wma(struct audio_client *ac, - void *cfg); - -int q6asm_media_format_block_wmapro(struct audio_client *ac, - void *cfg); - -/* PP specific */ -int q6asm_equalizer(struct audio_client *ac, void *eq); - -/* Send Volume Command */ -int q6asm_set_volume(struct audio_client *ac, int volume); - -/* Set SoftPause Params */ -int q6asm_set_softpause(struct audio_client *ac, - struct asm_softpause_params *param); - -/* Set Softvolume Params */ -int q6asm_set_softvolume(struct audio_client *ac, - struct asm_softvolume_params *param); - -/* Send left-right channel gain */ -int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain); - -/* Enable Mute/unmute flag */ -int q6asm_set_mute(struct audio_client *ac, int muteflag); - -int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp); - -/* Client can set the IO mode to either AIO/SIO mode */ -int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode); - -#ifdef CONFIG_RTAC -/* Get Service ID for APR communication */ -int q6asm_get_apr_service_id(int session_id); -#endif - -/* Common format block without any payload -*/ -int q6asm_media_format_block(struct audio_client *ac, uint32_t format); - -#endif /* __Q6_ASM_H__ */ diff --git a/include/trace/events/mpdcvs_trace.h b/include/trace/events/mpdcvs_trace.h deleted file mode 100644 index 0db137881bfb7884d5580a0aaf7c92daab22e08b..0000000000000000000000000000000000000000 --- a/include/trace/events/mpdcvs_trace.h +++ /dev/null @@ -1,156 +0,0 @@ -/* Copyright (c) 2012, Free Software 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. - */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM mpdcvs_trace - -#if !defined(_TRACE_MPDCVS_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_MPDCVS_H - -#include - -DECLARE_EVENT_CLASS(msm_mp, - - TP_PROTO(const char *name, int mp_val), - - TP_ARGS(name, mp_val), - - TP_STRUCT__entry( - __string(name, name) - __field(int, mp_val) - ), - - TP_fast_assign( - __assign_str(name, name); - __entry->mp_val = mp_val; - ), - - TP_printk("ev_name=%s ev_level=%d", - __get_str(name), - __entry->mp_val) -); - -/* Core function of run_q */ - -DEFINE_EVENT(msm_mp, msm_mp_runq, - - TP_PROTO(const char *name, int mp_val), - - TP_ARGS(name, mp_val) -); - -DEFINE_EVENT(msm_mp, msm_mp_cpusonline, - - TP_PROTO(const char *name, int mp_val), - - TP_ARGS(name, mp_val) -); - -DEFINE_EVENT(msm_mp, msm_mp_slacktime, - - TP_PROTO(const char *name, int mp_val), - - TP_ARGS(name, mp_val) -); - -DECLARE_EVENT_CLASS(msm_dcvs, - - TP_PROTO(const char *name, const char *cpuid, int val), - - TP_ARGS(name, cpuid, val), - - TP_STRUCT__entry( - __string(name, name) - __string(cpuid, cpuid) - __field(int, val) - ), - - TP_fast_assign( - __assign_str(name, name); - __assign_str(cpuid, cpuid); - __entry->val = val; - ), - - TP_printk("ev_name=%s d_name=%s ev_level=%d", - __get_str(name), - __get_str(cpuid), - __entry->val) -); - -/* Core function of dcvs */ - -DEFINE_EVENT(msm_dcvs, msm_dcvs_idle, - - TP_PROTO(const char *name, const char *cpuid, int val), - - TP_ARGS(name, cpuid, val) -); - -DEFINE_EVENT(msm_dcvs, msm_dcvs_iowait, - - TP_PROTO(const char *name, const char *cpuid, int val), - - TP_ARGS(name, cpuid, val) -); - -DEFINE_EVENT(msm_dcvs, msm_dcvs_slack_time, - - TP_PROTO(const char *name, const char *cpuid, int val), - - TP_ARGS(name, cpuid, val) -); - -DECLARE_EVENT_CLASS(msm_dcvs_scm, - - TP_PROTO(unsigned long cpuid, int ev_type, unsigned long param0, - unsigned long param1, unsigned long ret0, unsigned long ret1), - - TP_ARGS(cpuid, ev_type, param0, param1, ret0, ret1), - - TP_STRUCT__entry( - __field(unsigned long, cpuid) - __field(int, ev_type) - __field(unsigned long, param0) - __field(unsigned long, param1) - __field(unsigned long, ret0) - __field(unsigned long, ret1) - ), - - TP_fast_assign( - __entry->cpuid = cpuid; - __entry->ev_type = ev_type; - __entry->param0 = param0; - __entry->param1 = param1; - __entry->ret0 = ret0; - __entry->ret1 = ret1; - ), - - TP_printk("dev=%lu ev_type=%d ev_param0=%lu ev_param1=%lu ev_ret0=%lu ev_ret1=%lu", - __entry->cpuid, - __entry->ev_type, - __entry->param0, - __entry->param1, - __entry->ret0, - __entry->ret1) -); - -DEFINE_EVENT(msm_dcvs_scm, msm_dcvs_scm_event, - - TP_PROTO(unsigned long cpuid, int ev_type, unsigned long param0, - unsigned long param1, unsigned long ret0, unsigned long ret1), - - TP_ARGS(cpuid, ev_type, param0, param1, ret0, ret1) -); - -#endif /* _TRACE_MPDCVS_H */ - -/* This part must be outside protection */ -#include diff --git a/sound/compress_offload/core.c b/sound/compress_offload/core.c deleted file mode 100644 index 987594a6b482a1b11e3935eec295431205058409..0000000000000000000000000000000000000000 --- a/sound/compress_offload/core.c +++ /dev/null @@ -1,658 +0,0 @@ -/* - * core.c - compress offload core - * - * Copyright (C) 2011 Intel Corporation - * Authors: Vinod Koul - * Pierre-Louis Bossart - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * 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 of the License. - * - * 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. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* TODO: - * - Integrate with alsa, compressed devices should register as alsa devices - * as /dev/snd_compr_xxx - * - Integrate with ASoC: - * Opening compressed path should also start the codec dai - * TBD how the cpu dai will be viewed and started. - * ASoC should always be optional part - * (we should be able to use this framework in non asoc systems - * - Multiple node representation - * driver should be able to register multiple nodes - * - Version numbering for API - */ - -static DEFINE_MUTEX(device_mutex); -static LIST_HEAD(device_list); -static LIST_HEAD(misc_list); - -/* - * currently we are using misc device for registration and exposing ioctls - * this is temporary and will be moved to snd - * the device should be registered as /dev/snd_compr..... - */ - -struct snd_compr_misc { - struct miscdevice misc; - struct list_head list; - struct snd_compr *compr; -}; - -struct snd_ioctl_data { - struct snd_compr_misc *misc; - unsigned long caps; - unsigned int minor; - struct snd_compr_stream stream; -}; - -static struct snd_compr_misc *snd_compr_get_device(unsigned int minor) -{ - struct snd_compr_misc *misc; - - list_for_each_entry(misc, &misc_list, list) { - if (minor == misc->misc.minor) - return misc; - } - return NULL; -} - -static int snd_compr_open(struct inode *inode, struct file *f) -{ - unsigned int minor = iminor(inode); - struct snd_compr_misc *misc = snd_compr_get_device(minor); - struct snd_ioctl_data *data; - struct snd_compr_runtime *runtime; - unsigned int direction; - int ret; - - mutex_lock(&device_mutex); - if (f->f_flags & O_WRONLY) - direction = SNDRV_PCM_STREAM_PLAYBACK; - else { - ret = -ENXIO; - goto out; - } - /* curently only encoded playback is supported, above needs to be - * removed once we have recording support */ - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto out; - } - data->misc = misc; - data->minor = minor; - data->stream.ops = misc->compr->ops; - data->stream.direction = direction; - data->stream.private_data = misc->compr->private_data; - data->stream.device = misc->compr; - runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); - if (!runtime) { - ret = -ENOMEM; - kfree(data); - goto out; - } - runtime->state = SNDRV_PCM_STATE_OPEN; - init_waitqueue_head(&runtime->sleep); - data->stream.runtime = runtime; - f->private_data = (void *)data; - ret = misc->compr->ops->open(&data->stream); - if (ret) { - kfree(runtime); - kfree(data); - goto out; - } -out: - mutex_unlock(&device_mutex); - return ret; -} - -static int snd_compr_free(struct inode *inode, struct file *f) -{ - struct snd_ioctl_data *data = f->private_data; - mutex_lock(&device_mutex); - data->stream.ops->free(&data->stream); - kfree(data->stream.runtime->buffer); - kfree(data->stream.runtime); - kfree(data); - mutex_unlock(&device_mutex); - return 0; -} - -static void snd_compr_update_tstamp(struct snd_compr_stream *stream, - struct snd_compr_tstamp *tstamp) -{ - stream->ops->pointer(stream, tstamp); - stream->runtime->hw_pointer = tstamp->copied_bytes; -} - -static size_t snd_compr_calc_avail(struct snd_compr_stream *stream, - struct snd_compr_avail *avail) -{ - size_t avail_calc; - - snd_compr_update_tstamp(stream, &avail->tstamp); - avail_calc = stream->runtime->app_pointer - stream->runtime->hw_pointer; - if (avail_calc < 0) - avail_calc = stream->runtime->buffer_size + avail_calc; - avail->avail = avail_calc; - return avail_calc; -} - -static size_t snd_compr_get_avail(struct snd_compr_stream *stream) -{ - struct snd_compr_avail avail; - - return snd_compr_calc_avail(stream, &avail); -} - -static int -snd_compr_ioctl_avail(struct snd_compr_stream *stream, unsigned long arg) -{ - struct snd_compr_avail ioctl_avail; - - snd_compr_calc_avail(stream, &ioctl_avail); - - if (copy_to_user((unsigned long __user *)arg, &ioctl_avail, sizeof(ioctl_avail))) - return -EFAULT; - return 0; -} - -static int snd_compr_write_data(struct snd_compr_stream *stream, - const char __user *buf, size_t count) -{ - void *dstn; - size_t copy; - - dstn = stream->runtime->buffer + stream->runtime->app_pointer; - if (count < stream->runtime->buffer_size - stream->runtime->app_pointer) { - if (copy_from_user(dstn, buf, count)) - return -EFAULT; - stream->runtime->app_pointer += count; - } else { - copy = stream->runtime->buffer_size - stream->runtime->app_pointer; - if (copy_from_user(dstn, buf, copy)) - return -EFAULT; - if (copy_from_user(stream->runtime->buffer, buf + copy, count - copy)) - return -EFAULT; - stream->runtime->app_pointer = count - copy; - } - /* if DSP cares, let it know data has been written */ - if (stream->ops->ack) - stream->ops->ack(stream); - return count; -} - -static ssize_t snd_compr_write(struct file *f, const char __user *buf, - size_t count, loff_t *offset) -{ - struct snd_ioctl_data *data = f->private_data; - struct snd_compr_stream *stream; - size_t avail; - int retval; - - BUG_ON(!data); - stream = &data->stream; - mutex_lock(&stream->device->lock); - /* write is allowed when stream is running or has been steup */ - if (stream->runtime->state != SNDRV_PCM_STATE_SETUP && - stream->runtime->state != SNDRV_PCM_STATE_RUNNING) { - mutex_unlock(&stream->device->lock); - return -EPERM; - } - - avail = snd_compr_get_avail(stream); - /* calculate how much we can write to buffer */ - if (avail > count) - avail = count; - - if (stream->ops->copy) - retval = stream->ops->copy(stream, buf, avail); - else - retval = snd_compr_write_data(stream, buf, avail); - - /* while initiating the stream, write should be called before START - * call, so in setup move state */ - if (stream->runtime->state == SNDRV_PCM_STATE_SETUP) - stream->runtime->state = SNDRV_PCM_STATE_PREPARED; - - mutex_unlock(&stream->device->lock); - return retval; -} - - -static ssize_t snd_compr_read(struct file *f, char __user *buf, - size_t count, loff_t *offset) -{ - return -ENXIO; -} - -static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma) -{ - return -ENXIO; -} - -unsigned int snd_compr_poll(struct file *f, poll_table *wait) -{ - struct snd_ioctl_data *data = f->private_data; - struct snd_compr_stream *stream; - int retval = 0; - - BUG_ON(!data); - stream = &data->stream; - - mutex_lock(&stream->device->lock); - if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) { - retval = -ENXIO; - goto out; - } - poll_wait(f, &stream->runtime->sleep, wait); - - /* this would change after read is implemented, we would need to - * check for direction here */ - if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) - retval = POLLOUT | POLLWRNORM; -out: - mutex_unlock(&stream->device->lock); - return retval; -} - -void snd_compr_fragment_elapsed(struct snd_compr_stream *stream) -{ - size_t avail; - - if (stream->direction != SNDRV_PCM_STREAM_PLAYBACK) - return; - avail = snd_compr_get_avail(stream); - if (avail >= stream->runtime->fragment_size) - wake_up(&stream->runtime->sleep); -} -EXPORT_SYMBOL_GPL(snd_compr_fragment_elapsed); - -void snd_compr_frame_elapsed(struct snd_compr_stream *stream) -{ - size_t avail; - - if (stream->direction != SNDRV_PCM_STREAM_CAPTURE) - return; - avail = snd_compr_get_avail(stream); - if (avail) - wake_up(&stream->runtime->sleep); -} -EXPORT_SYMBOL_GPL(snd_compr_frame_elapsed); - -static int snd_compr_get_caps(struct snd_compr_stream *stream, unsigned long arg) -{ - int retval; - struct snd_compr_caps caps; - - if (!stream->ops->get_caps) - return -ENXIO; - - retval = stream->ops->get_caps(stream, &caps); - if (retval) - goto out; - if (copy_to_user((void __user *)arg, &caps, sizeof(caps))) - retval = -EFAULT; -out: - return retval; -} - -static int snd_compr_get_codec_caps(struct snd_compr_stream *stream, unsigned long arg) -{ - int retval; - struct snd_compr_codec_caps *caps; - - if (!stream->ops->get_codec_caps) - return -ENXIO; - - caps = kmalloc(sizeof(*caps), GFP_KERNEL); - if (!caps) - return -ENOMEM; - - retval = stream->ops->get_codec_caps(stream, caps); - if (retval) - goto out; - if (copy_to_user((void __user *)arg, caps, sizeof(*caps))) - retval = -EFAULT; - -out: - kfree(caps); - return retval; -} - -/* revisit this with snd_pcm_preallocate_xxx */ -static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, - struct snd_compr_params *params) -{ - unsigned int buffer_size; - void *buffer; - - buffer_size = params->buffer.fragment_size * params->buffer.fragments; - if (stream->ops->copy) { - buffer = NULL; - /* if copy is defined the driver will be required to copy - * the data from core - */ - } else { - buffer = kmalloc(buffer_size, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - } - stream->runtime->fragment_size = params->buffer.fragment_size; - stream->runtime->fragments = params->buffer.fragments; - stream->runtime->buffer = buffer; - stream->runtime->buffer_size = buffer_size; - return 0; -} - -static int snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) -{ - struct snd_compr_params *params; - int retval; - - if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) { - /* - * we should allow parameter change only when stream has been - * opened not in other cases - */ - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) - return -ENOMEM; - if (copy_from_user(params, (void __user *)arg, sizeof(*params))) - return -EFAULT; - retval = snd_compr_allocate_buffer(stream, params); - if (retval) { - kfree(params); - return -ENOMEM; - } - retval = stream->ops->set_params(stream, params); - if (retval) - goto out; - stream->runtime->state = SNDRV_PCM_STATE_SETUP; - } else - return -EPERM; -out: - kfree(params); - return retval; -} - -static int snd_compr_get_params(struct snd_compr_stream *stream, unsigned long arg) -{ - struct snd_compr_params *params; - int retval; - - if (!stream->ops->get_params) - return -ENXIO; - - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) - return -ENOMEM; - retval = stream->ops->get_params(stream, params); - if (retval) - goto out; - if (copy_to_user((char __user *)arg, params, sizeof(*params))) - retval = -EFAULT; - -out: - kfree(params); - return retval; -} - -static int snd_compr_tstamp(struct snd_compr_stream *stream, unsigned long arg) -{ - struct snd_compr_tstamp tstamp; - - snd_compr_update_tstamp(stream, &tstamp); - if (copy_to_user((struct snd_compr_tstamp __user *)arg, &tstamp, sizeof(tstamp))) - return -EFAULT; - return 0; -} - -static int snd_compr_pause(struct snd_compr_stream *stream) -{ - int retval; - - if (stream->runtime->state == SNDRV_PCM_STATE_PAUSED) - return 0; - retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_PUSH); - if (!retval) { - stream->runtime->state = SNDRV_PCM_STATE_PAUSED; - wake_up(&stream->runtime->sleep); - } - return retval; -} - -static int snd_compr_resume(struct snd_compr_stream *stream) -{ - int retval; - - if (stream->runtime->state != SNDRV_PCM_STATE_PAUSED) - return -EPERM; - retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_PAUSE_RELEASE); - if (!retval) - stream->runtime->state = SNDRV_PCM_STATE_RUNNING; - return retval; -} - -static int snd_compr_start(struct snd_compr_stream *stream) -{ - int retval; - - if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED) - return -EPERM; - retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START); - if (!retval) - stream->runtime->state = SNDRV_PCM_STATE_RUNNING; - return retval; -} - -static int snd_compr_stop(struct snd_compr_stream *stream) -{ - int retval; - - if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED) - return -EPERM; - retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); - if (!retval) { - stream->runtime->state = SNDRV_PCM_STATE_SETUP; - wake_up(&stream->runtime->sleep); - } - return retval; -} - -static int snd_compr_drain(struct snd_compr_stream *stream) -{ - int retval; - - if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED || - stream->runtime->state != SNDRV_PCM_STATE_PAUSED) - return -EPERM; - retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); - if (!retval) { - stream->runtime->state = SNDRV_PCM_STATE_SETUP; - wake_up(&stream->runtime->sleep); - } - return retval; -} - -static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) -{ - struct snd_ioctl_data *data = f->private_data; - struct snd_compr_stream *stream; - int retval = -ENOTTY; - - BUG_ON(!data); - stream = &data->stream; - mutex_lock(&stream->device->lock); - switch (_IOC_NR(cmd)) { - case _IOC_NR(SNDRV_COMPRESS_GET_CAPS): - retval = snd_compr_get_caps(stream, arg); - break; - case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS): - retval = snd_compr_get_codec_caps(stream, arg); - break; - case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS): - retval = snd_compr_set_params(stream, arg); - break; - case _IOC_NR(SNDRV_COMPRESS_GET_PARAMS): - retval = snd_compr_get_params(stream, arg); - break; - case _IOC_NR(SNDRV_COMPRESS_TSTAMP): - retval = snd_compr_tstamp(stream, arg); - break; - case _IOC_NR(SNDRV_COMPRESS_AVAIL): - retval = snd_compr_ioctl_avail(stream, arg); - case _IOC_NR(SNDRV_COMPRESS_PAUSE): - retval = snd_compr_pause(stream); - break; - case _IOC_NR(SNDRV_COMPRESS_RESUME): - retval = snd_compr_resume(stream); - break; - case _IOC_NR(SNDRV_COMPRESS_START): - retval = snd_compr_start(stream); - break; - case _IOC_NR(SNDRV_COMPRESS_STOP): - retval = snd_compr_stop(stream); - break; - case _IOC_NR(SNDRV_COMPRESS_DRAIN): - cmd = SND_COMPR_TRIGGER_DRAIN; - retval = snd_compr_drain(stream); - break; - } - mutex_unlock(&stream->device->lock); - return retval; -} - -static const struct file_operations snd_comp_file = { - .owner = THIS_MODULE, - .open = snd_compr_open, - .release = snd_compr_free, - .read = snd_compr_read, - .write = snd_compr_write, - .unlocked_ioctl = snd_compr_ioctl, - .mmap = snd_compr_mmap, - .poll = snd_compr_poll, -}; - -static int snd_compress_add_device(struct snd_compr *device) -{ - int ret; - - struct snd_compr_misc *misc = kzalloc(sizeof(*misc), GFP_KERNEL); - - misc->misc.name = device->name; - misc->misc.fops = &snd_comp_file; - misc->misc.minor = MISC_DYNAMIC_MINOR; - misc->compr = device; - ret = misc_register(&misc->misc); - if (ret) { - pr_err("couldn't register misc device\n"); - kfree(misc); - } else { - pr_debug("Got minor %d\n", misc->misc.minor); - list_add_tail(&misc->list, &misc_list); - } - return ret; -} - -static int snd_compress_remove_device(struct snd_compr *device) -{ - struct snd_compr_misc *misc, *__misc; - - list_for_each_entry_safe(misc, __misc, &misc_list, list) { - if (device == misc->compr) { - misc_deregister(&misc->misc); - list_del(&device->list); - kfree(misc); - } - } - return 0; -} -/** - * snd_compress_register - register compressed device - * - * @device: compressed device to register - */ -int snd_compress_register(struct snd_compr *device) -{ - int retval; - - if (device->name == NULL || device->dev == NULL || device->ops == NULL) - return -EINVAL; - BUG_ON(!device->ops->open); - BUG_ON(!device->ops->free); - BUG_ON(!device->ops->set_params); - BUG_ON(!device->ops->get_params); - BUG_ON(!device->ops->trigger); - BUG_ON(!device->ops->pointer); - BUG_ON(!device->ops->get_caps); - BUG_ON(!device->ops->get_codec_caps); - - INIT_LIST_HEAD(&device->list); - /* todo register the compressed streams */ - /* todo integrate with asoc */ - - /* register a compressed card TBD if this needs change */ - - pr_debug("Registering compressed device %s\n", device->name); - mutex_lock(&device_mutex); - /* register a msic device for now */ - retval = snd_compress_add_device(device); - if (!retval) - list_add_tail(&device->list, &device_list); - mutex_unlock(&device_mutex); - return retval; -} -EXPORT_SYMBOL_GPL(snd_compress_register); - -int snd_compress_deregister(struct snd_compr *device) -{ - pr_debug("Removing compressed device %s\n", device->name); - mutex_lock(&device_mutex); - snd_compress_remove_device(device); - list_del(&device->list); - mutex_unlock(&device_mutex); - return 0; -} -EXPORT_SYMBOL_GPL(snd_compress_deregister); - -static int __init snd_compress_init(void) -{ - return 0; -} - -static void __exit snd_compress_exit(void) -{ -} - -module_init(snd_compress_init); -module_exit(snd_compress_exit); diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index b4000caa29ec51dadc8ce1576925acab5fac6cae..15e13e2239466973ef42e45e63239185ae88caec 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -123,7 +123,6 @@ config SND_SOC_ALL_CODECS select SND_SOC_WM9705 if SND_SOC_AC97_BUS select SND_SOC_WM9712 if SND_SOC_AC97_BUS select SND_SOC_WM9713 if SND_SOC_AC97_BUS - select SND_SOC_TIMPANI if MARIMBA_CORE help Normally ASoC codec drivers are only built if a machine driver which uses them is also built since they are only usable with a machine @@ -356,15 +355,9 @@ config SND_SOC_UDA134X config SND_SOC_UDA1380 tristate -config SND_SOC_WCD9304 - tristate - config SND_SOC_WCD9310 tristate -config SND_SOC_CS8427 - tristate - config SND_SOC_WCD9320 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index fc7544aa6a6569868c76f946d9451420748a971f..e7ef6cff2e6e95920c48082d38c1edd427bfcb6b 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -66,9 +66,7 @@ snd-soc-twl4030-objs := twl4030.o snd-soc-twl6040-objs := twl6040.o snd-soc-uda134x-objs := uda134x.o snd-soc-uda1380-objs := uda1380.o -snd-soc-wcd9304-objs := wcd9304.o wcd9304-tables.o snd-soc-wcd9310-objs := wcd9310.o wcd9310-tables.o -snd-soc-cs8427-objs := cs8427.o snd-soc-wcd9320-objs := wcd9320.o wcd9320-tables.o snd-soc-wcd9306-objs := wcd9306.o wcd9306-tables.o snd-soc-wcd9xxx-objs := wcd9xxx-resmgr.o wcd9xxx-mbhc.o wcd9xxx-common.o @@ -126,7 +124,6 @@ snd-soc-wm9712-objs := wm9712.o snd-soc-wm9713-objs := wm9713.o snd-soc-wm-hubs-objs := wm_hubs.o -snd-soc-timpani-objs := timpani.o snd-soc-msm-stub-objs := msm_stub.o obj-$(CONFIG_SND_SOC_MSM_HDMI_CODEC_RX) := msm_hdmi_codec_rx.o @@ -201,9 +198,7 @@ obj-$(CONFIG_SND_SOC_TWL4030) += snd-soc-twl4030.o obj-$(CONFIG_SND_SOC_TWL6040) += snd-soc-twl6040.o obj-$(CONFIG_SND_SOC_UDA134X) += snd-soc-uda134x.o obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o -obj-$(CONFIG_SND_SOC_WCD9304) += snd-soc-wcd9304.o obj-$(CONFIG_SND_SOC_WCD9310) += snd-soc-wcd9310.o -obj-$(CONFIG_SND_SOC_CS8427) += snd-soc-cs8427.o obj-$(CONFIG_SND_SOC_WCD9320) += snd-soc-wcd9320.o obj-$(CONFIG_SND_SOC_WCD9306) += snd-soc-wcd9306.o obj-$(CONFIG_SND_SOC_MSM8X10_WCD) += snd-soc-msm8x10-wcd.o wcd9xxx-resmgr.o wcd9xxx-mbhc.o diff --git a/sound/soc/codecs/cs8427.c b/sound/soc/codecs/cs8427.c deleted file mode 100644 index 0496f52c47f7c45bcad4915deb9503853b9b2e6f..0000000000000000000000000000000000000000 --- a/sound/soc/codecs/cs8427.c +++ /dev/null @@ -1,989 +0,0 @@ -/* - * Routines for control of the CS8427 via i2c bus - * IEC958 (S/PDIF) receiver & transmitter by Cirrus Logic - * Copyright (c) by Jaroslav Kysela - * Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CS8427_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ - SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ - SNDRV_PCM_RATE_96000) - -#define CS8427_FORMATS (SNDRV_PCM_FMTBIT_S24_LE |\ - SNDRV_PCM_FORMAT_S16_LE |\ - SNDRV_PCM_FORMAT_S20_3LE) - -struct cs8427_stream { - struct snd_pcm_substream *substream; - char hw_status[CHANNEL_STATUS_SIZE]; /* hardware status */ - char def_status[CHANNEL_STATUS_SIZE]; /* default status */ - char pcm_status[CHANNEL_STATUS_SIZE]; /* PCM private status */ - char hw_udata[32]; - struct snd_kcontrol *pcm_ctl; -}; - -struct cs8427 { - struct i2c_client *client; - struct i2c_msg xfer_msg[2]; - unsigned char regmap[0x14]; /* map of first 1 + 13 registers */ - unsigned int reset_timeout; - struct cs8427_stream playback; -}; - -static int cs8427_i2c_write_device(struct cs8427 *cs8427_i2c, - u16 reg, u8 *value, u32 bytes) -{ - struct i2c_msg *msg; - int ret = 0; - u8 reg_addr = 0; - u8 data[bytes + 1]; - - if (cs8427_i2c->client == NULL) { - pr_err("%s: failed to get device info\n", __func__); - return -ENODEV; - } - reg_addr = (u8)reg; - msg = &cs8427_i2c->xfer_msg[0]; - msg->addr = cs8427_i2c->client->addr; - msg->len = bytes + 1; - msg->flags = 0; - data[0] = reg_addr; - data[1] = *value; - msg->buf = data; - ret = i2c_transfer(cs8427_i2c->client->adapter, - cs8427_i2c->xfer_msg, 1); - /* Try again if the write fails - * checking with ebusy and number of bytes executed - * for write ret value should be 1 - */ - if ((ret != 1) || (ret == -EBUSY)) { - ret = i2c_transfer( - cs8427_i2c->client->adapter, - cs8427_i2c->xfer_msg, 1); - if ((ret != 1) || (ret < 0)) { - dev_err(&cs8427_i2c->client->dev, - "failed to write the" - " device reg %d\n", reg); - return ret; - } - } - return 0; -} - -static int cs8427_i2c_write(struct cs8427 *chip, unsigned short reg, - int bytes, void *src) -{ - int ret = 0, err = 0; - struct cs8427_platform_data *pdata = chip->client->dev.platform_data; - /* - * enable the 100KHz level shifter to communicate - * with CS8427 chip - */ - if (pdata->enable) { - err = pdata->enable(1, pdata->ls_gpio); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to enable the level shifter\n"); - return err; - } - } - ret = cs8427_i2c_write_device(chip, reg, src, bytes); - - /* - * Disable the 100KHz level shifter to communicate - * with CS8427 chip - */ - if (pdata->enable) { - err = pdata->enable(0, pdata->ls_gpio); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to disable the level shifter\n"); - return err; - } - } - return ret; -} - -static int cs8427_i2c_read_device(struct cs8427 *cs8427_i2c, - unsigned short reg, - int bytes, unsigned char *dest) -{ - struct i2c_msg *msg; - int ret = 0; - u8 reg_addr = 0; - u8 i = 0; - - if (cs8427_i2c->client == NULL) { - pr_err("%s: failed to get device info\n", __func__); - return -ENODEV; - } - for (i = 0; i < bytes; i++) { - reg_addr = (u8)reg++; - msg = &cs8427_i2c->xfer_msg[0]; - msg->addr = cs8427_i2c->client->addr; - msg->len = 1; - msg->flags = 0; - msg->buf = ®_addr; - - msg = &cs8427_i2c->xfer_msg[1]; - msg->addr = cs8427_i2c->client->addr; - msg->len = 1; - msg->flags = I2C_M_RD; - msg->buf = dest++; - ret = i2c_transfer(cs8427_i2c->client->adapter, - cs8427_i2c->xfer_msg, 2); - - /* Try again if read fails first time - checking with ebusy and number of bytes executed - for read ret value should be 2*/ - if ((ret != 2) || (ret == -EBUSY)) { - ret = i2c_transfer( - cs8427_i2c->client->adapter, - cs8427_i2c->xfer_msg, 2); - if ((ret != 2) || (ret < 0)) { - dev_err(&cs8427_i2c->client->dev, - "failed to read cs8427" - " register %d\n", reg); - return ret; - } - } - } - return 0; -} - -static int cs8427_i2c_read(struct cs8427 *chip, - unsigned short reg, - int bytes, void *dest) -{ - u32 err = 0, ret = 0; - struct cs8427_platform_data *pdata = chip->client->dev.platform_data; - /* - * enable the 100KHz level shifter to communicate - * with CS8427 chip - */ - if (pdata->enable) { - err = pdata->enable(1, pdata->ls_gpio); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to enable the level shifter\n"); - return err; - } - } - ret = cs8427_i2c_read_device(chip, reg, - bytes, dest); - - /* - * Disable the 100KHz level shifter to communicate - * with CS8427 chip - */ - if (pdata->enable) { - err = pdata->enable(0, pdata->ls_gpio); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to disable the level shifter\n"); - return err; - } - } - return ret; -} - -static int cs8427_i2c_sendbytes(struct cs8427 *chip, - char *reg_addr, char *data, - int bytes) -{ - u32 ret = 0, err = 0; - u8 i = 0; - struct cs8427_platform_data *pdata = chip->client->dev.platform_data; - - if (!chip) { - pr_err("%s, invalid device info\n", __func__); - return -ENODEV; - } - if (!data) { - dev_err(&chip->client->dev, "%s:" - "invalid data pointer\n", __func__); - return -EINVAL; - } - /* - * enable the 100KHz level shifter to communicate - * with CS8427 chip - */ - if (pdata->enable) { - err = pdata->enable(1, pdata->ls_gpio); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to enable the level shifter\n"); - return err; - } - } - for (i = 0; i < bytes; i++) { - ret = cs8427_i2c_write_device(chip, (*reg_addr + i), - &data[i], 1); - if (ret < 0) { - dev_err(&chip->client->dev, - "%s: failed to send the data to" - " cs8427 chip\n", __func__); - break; - } - } - - /* - * Disable the 100KHz level shifter to communicate - * with CS8427 chip - */ - if (pdata->enable) { - err = pdata->enable(0, pdata->ls_gpio); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to disable the level shifter\n"); - return err; - } - } - return i; -} - -/* - * Reset the chip using run bit, also lock PLL using ILRCK and - * put back AES3INPUT. This workaround is described in latest - * CS8427 datasheet, otherwise TXDSERIAL will not work. - */ -static void snd_cs8427_reset(struct cs8427 *chip) -{ - unsigned long end_time; - int data, aes3input = 0; - unsigned char val = 0; - - if (snd_BUG_ON(!chip)) - return; - if ((chip->regmap[CS8427_REG_CLOCKSOURCE] & CS8427_RXDAES3INPUT) == - CS8427_RXDAES3INPUT) /* AES3 bit is set */ - aes3input = 1; - chip->regmap[CS8427_REG_CLOCKSOURCE] &= ~(CS8427_RUN | CS8427_RXDMASK); - cs8427_i2c_write(chip, CS8427_REG_CLOCKSOURCE, - 1, &chip->regmap[CS8427_REG_CLOCKSOURCE]); - udelay(200); - chip->regmap[CS8427_REG_CLOCKSOURCE] |= CS8427_RUN | CS8427_RXDILRCK; - cs8427_i2c_write(chip, CS8427_REG_CLOCKSOURCE, - 1, &chip->regmap[CS8427_REG_CLOCKSOURCE]); - udelay(200); - end_time = jiffies + chip->reset_timeout; - while (time_after_eq(end_time, jiffies)) { - data = cs8427_i2c_read(chip, CS8427_REG_RECVERRORS, - 1, &val); - if (!(val & CS8427_UNLOCK)) - break; - schedule_timeout_uninterruptible(1); - } - chip->regmap[CS8427_REG_CLOCKSOURCE] &= ~CS8427_RXDMASK; - if (aes3input) - chip->regmap[CS8427_REG_CLOCKSOURCE] |= CS8427_RXDAES3INPUT; - cs8427_i2c_write(chip, CS8427_REG_CLOCKSOURCE, - 1, &chip->regmap[CS8427_REG_CLOCKSOURCE]); -} - -static int snd_cs8427_in_status_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 255; - return 0; -} - -static int snd_cs8427_in_status_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct cs8427 *chip = kcontrol->private_data; - unsigned char val = 0; - int err = 0; - - err = cs8427_i2c_read(chip, kcontrol->private_value, 1, &val); - if (err < 0) - return err; - ucontrol->value.integer.value[0] = val; - return 0; -} - -static int snd_cs8427_qsubcode_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; - uinfo->count = 10; - return 0; -} - -static int snd_cs8427_qsubcode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct cs8427 *chip = kcontrol->private_data; - unsigned char reg = CS8427_REG_QSUBCODE; - int err; - unsigned char val[20]; - - if (!chip) { - pr_err("%s: invalid device info\n", __func__); - return -ENODEV; - } - - err = cs8427_i2c_write(chip, reg, 1, &val[0]); - if (err != 1) { - dev_err(&chip->client->dev, "unable to send register" - " 0x%x byte to CS8427\n", reg); - return err < 0 ? err : -EIO; - } - err = cs8427_i2c_read(chip, *ucontrol->value.bytes.data, 10, &val); - if (err != 10) { - dev_err(&chip->client->dev, "unable to read" - " Q-subcode bytes from CS8427\n"); - return err < 0 ? err : -EIO; - } - return 0; -} - -static int snd_cs8427_spdif_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; - uinfo->count = 1; - return 0; -} - -static int snd_cs8427_select_corudata(struct cs8427 *cs8427_i2c, int udata) -{ - struct cs8427 *chip = cs8427_i2c; - int err; - - udata = udata ? CS8427_BSEL : 0; - if (udata != (chip->regmap[CS8427_REG_CSDATABUF] & udata)) { - chip->regmap[CS8427_REG_CSDATABUF] &= ~CS8427_BSEL; - chip->regmap[CS8427_REG_CSDATABUF] |= udata; - err = cs8427_i2c_write(cs8427_i2c, CS8427_REG_CSDATABUF, - 1, &chip->regmap[CS8427_REG_CSDATABUF]); - if (err < 0) - return err; - } - return 0; -} - -static int snd_cs8427_send_corudata(struct cs8427 *obj, - int udata, - unsigned char *ndata, - int count) -{ - struct cs8427 *chip = obj; - char *hw_data = udata ? - chip->playback.hw_udata : chip->playback.hw_status; - char data[32]; - int err, idx; - unsigned char addr = 0; - int ret = 0; - - if (!memcmp(hw_data, ndata, count)) - return 0; - err = snd_cs8427_select_corudata(chip, udata); - if (err < 0) - return err; - memcpy(hw_data, ndata, count); - if (udata) { - memset(data, 0, sizeof(data)); - if (memcmp(hw_data, data, count) == 0) { - chip->regmap[CS8427_REG_UDATABUF] &= ~CS8427_UBMMASK; - chip->regmap[CS8427_REG_UDATABUF] |= CS8427_UBMZEROS | - CS8427_EFTUI; - err = cs8427_i2c_write(chip, CS8427_REG_UDATABUF, - 1, &chip->regmap[CS8427_REG_UDATABUF]); - return err < 0 ? err : 0; - } - } - idx = 0; - memcpy(data, ndata, CHANNEL_STATUS_SIZE); - /* address from where the bufferhas to write*/ - addr = 0x20; - ret = cs8427_i2c_sendbytes(chip, &addr, data, count); - if (ret != count) - return -EIO; - return 1; -} - -static int snd_cs8427_spdif_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct cs8427 *chip = kcontrol->private_data; - if (!chip) { - pr_err("%s: invalid device info\n", __func__); - return -ENODEV; - } - - memcpy(ucontrol->value.iec958.status, - chip->playback.def_status, CHANNEL_STATUS_SIZE); - return 0; -} - -static int snd_cs8427_spdif_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct cs8427 *chip = kcontrol->private_data; - unsigned char *status; - int err, change; - - if (!chip) { - pr_err("%s: invalid device info\n", __func__); - return -ENODEV; - } - status = kcontrol->private_value ? - chip->playback.pcm_status : chip->playback.def_status; - - change = memcmp(ucontrol->value.iec958.status, status, - CHANNEL_STATUS_SIZE) != 0; - - if (!change) { - memcpy(status, ucontrol->value.iec958.status, - CHANNEL_STATUS_SIZE); - err = snd_cs8427_send_corudata(chip, 0, status, - CHANNEL_STATUS_SIZE); - if (err < 0) - change = err; - } - return change; -} - -static int snd_cs8427_spdif_mask_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; - uinfo->count = 1; - return 0; -} - -static int snd_cs8427_spdif_mask_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - memset(ucontrol->value.iec958.status, 0xff, CHANNEL_STATUS_SIZE); - return 0; -} - -static struct snd_kcontrol_new snd_cs8427_iec958_controls[] = { - { - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .info = snd_cs8427_in_status_info, - .name = "IEC958 CS8427 Input Status", - .access = (SNDRV_CTL_ELEM_ACCESS_READ | - SNDRV_CTL_ELEM_ACCESS_VOLATILE), - .get = snd_cs8427_in_status_get, - .private_value = 15, - }, - { - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .info = snd_cs8427_in_status_info, - .name = "IEC958 CS8427 Error Status", - .access = (SNDRV_CTL_ELEM_ACCESS_READ | - SNDRV_CTL_ELEM_ACCESS_VOLATILE), - .get = snd_cs8427_in_status_get, - .private_value = 16, - }, - { - .access = SNDRV_CTL_ELEM_ACCESS_READ, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK), - .info = snd_cs8427_spdif_mask_info, - .get = snd_cs8427_spdif_mask_get, - }, - { - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, - DEFAULT), - .info = snd_cs8427_spdif_info, - .get = snd_cs8427_spdif_get, - .put = snd_cs8427_spdif_put, - .private_value = 0 - }, - { - .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | - SNDRV_CTL_ELEM_ACCESS_INACTIVE), - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM), - .info = snd_cs8427_spdif_info, - .get = snd_cs8427_spdif_get, - .put = snd_cs8427_spdif_put, - .private_value = 1 - }, - { - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .info = snd_cs8427_qsubcode_info, - .name = "IEC958 Q-subcode Capture Default", - .access = (SNDRV_CTL_ELEM_ACCESS_READ | - SNDRV_CTL_ELEM_ACCESS_VOLATILE), - .get = snd_cs8427_qsubcode_get - } -}; - -static int cs8427_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct snd_soc_codec *codec = dai->codec; - struct cs8427 *chip = dev_get_drvdata(codec->dev); - int ret = 0; - if (chip == NULL) { - pr_err("invalid device private data\n"); - return -ENODEV; - } - chip->regmap[CS8427_REG_SERIALINPUT] &= CS8427_BITWIDTH_MASK; - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S16_LE: - chip->regmap[CS8427_REG_SERIALINPUT] |= CS8427_SIRES16; - ret = cs8427_i2c_write(chip, CS8427_REG_SERIALINPUT, 1, - &chip->regmap[CS8427_REG_SERIALINPUT]); - break; - case SNDRV_PCM_FORMAT_S20_3LE: - chip->regmap[CS8427_REG_SERIALINPUT] |= CS8427_SIRES20; - ret = cs8427_i2c_write(chip, CS8427_REG_SERIALINPUT, 1, - &chip->regmap[CS8427_REG_SERIALINPUT]); - - break; - case SNDRV_PCM_FORMAT_S24_LE: - chip->regmap[CS8427_REG_SERIALINPUT] |= CS8427_SIRES24; - ret = cs8427_i2c_write(chip, CS8427_REG_SERIALINPUT, 1, - &chip->regmap[CS8427_REG_SERIALINPUT]); - break; - default: - pr_err("invalid format\n"); - break; - } - dev_dbg(&chip->client->dev, - "%s(): substream = %s stream = %d\n" , __func__, - substream->name, substream->stream); - return ret; -} - -static int snd_cs8427_iec958_register_kcontrol(struct cs8427 *cs8427, - struct snd_card *card) -{ - struct cs8427 *chip = cs8427; - struct snd_kcontrol *kctl; - unsigned int idx; - int err; - - for (idx = 0; idx < ARRAY_SIZE(snd_cs8427_iec958_controls); idx++) { - kctl = snd_ctl_new1(&snd_cs8427_iec958_controls[idx], chip); - if (kctl == NULL) - return -ENOMEM; - err = snd_ctl_add(card, kctl); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to add the kcontrol\n"); - return err; - } - } - return err; -} - -static int cs8427_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct cs8427 *chip = dev_get_drvdata(dai->codec->dev); - - if (chip == NULL) { - pr_err("invalid device private data\n"); - return -ENODEV; - } - /* - * we need to make the pll lock for the I2S tranfers - * reset the cs8427 chip for this. - */ - snd_cs8427_reset(chip); - dev_dbg(&chip->client->dev, - "%s(): substream = %s stream = %d\n" , __func__, - substream->name, substream->stream); - - return 0; -} - -static void cs8427_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct cs8427 *chip = dev_get_drvdata(dai->codec->dev); - - if (chip == NULL) { - pr_err("invalid device private data\n"); - return; - } - dev_dbg(&chip->client->dev, - "%s(): substream = %s stream = %d\n" , __func__, - substream->name, substream->stream); -} - -static int cs8427_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) -{ - struct cs8427 *chip = dev_get_drvdata(dai->codec->dev); - - if (chip == NULL) { - pr_err("invalid device private data\n"); - return -ENODEV; - } - dev_dbg(&chip->client->dev, "%s\n", __func__); - return 0; -} - -static struct snd_soc_dai_ops cs8427_dai_ops = { - .startup = cs8427_startup, - .shutdown = cs8427_shutdown, - .hw_params = cs8427_hw_params, - .set_fmt = cs8427_set_dai_fmt, -}; - -static struct snd_soc_dai_driver cs8427_dai[] = { - { - .name = "spdif_rx", - .id = 1, - .playback = { - .stream_name = "AIF1 Playback", - .rates = CS8427_RATES, - .formats = CS8427_FORMATS, - .rate_max = 192000, - .rate_min = 8000, - .channels_min = 1, - .channels_max = 2, - }, - .ops = &cs8427_dai_ops, - }, -}; - - -static unsigned int cs8427_soc_i2c_read(struct snd_soc_codec *codec, - unsigned int reg) -{ - struct cs8427 *chip = dev_get_drvdata(codec->dev); - - if (chip == NULL) { - pr_err("invalid device private data\n"); - return -ENODEV; - } - dev_dbg(&chip->client->dev, "cs8427 soc i2c read\n"); - return 0; -} - -static int cs8427_soc_i2c_write(struct snd_soc_codec *codec, - unsigned int reg, unsigned int value) -{ - struct cs8427 *chip = dev_get_drvdata(codec->dev); - - if (chip == NULL) { - pr_err("invalid device private data\n"); - return -ENODEV; - } - dev_dbg(&chip->client->dev, "cs8427 soc i2c write\n"); - return 0; -} - -static int cs8427_soc_probe(struct snd_soc_codec *codec) -{ - int ret = 0; - struct cs8427 *chip; - codec->control_data = dev_get_drvdata(codec->dev); - chip = codec->control_data; - - if (chip == NULL) { - pr_err("invalid device private data\n"); - return -ENODEV; - } - snd_cs8427_iec958_register_kcontrol(chip, codec->card->snd_card); - dev_set_drvdata(codec->dev, chip); - return ret; -} - -static struct snd_soc_codec_driver soc_codec_dev_cs8427 = { - .read = cs8427_soc_i2c_read, - .write = cs8427_soc_i2c_write, - .probe = cs8427_soc_probe, -}; - -int poweron_cs8427(struct cs8427 *chip) -{ - struct cs8427_platform_data *pdata = chip->client->dev.platform_data; - int ret = 0; - - if (pdata->enable) { - ret = gpio_request(pdata->ls_gpio, "cs8427 ls"); - if (ret < 0) { - dev_err(&chip->client->dev, - "failed to request the gpio %d\n", - pdata->reset_gpio); - return ret; - } - } - - ret = gpio_request(pdata->reset_gpio, "cs8427 reset"); - if (ret < 0) { - dev_err(&chip->client->dev, - "failed to request the gpio %d\n", - pdata->reset_gpio); - return ret; - } - /*bring the chip out of reset*/ - gpio_direction_output(pdata->reset_gpio, 1); - msleep(20); - gpio_direction_output(pdata->reset_gpio, 0); - msleep(20); - gpio_direction_output(pdata->reset_gpio, 1); - msleep(20); - return ret; -} - -static int cs8427_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - static unsigned char initvals1[] = { - CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC, - /* CS8427_REG_CONTROL1: RMCK to OMCK, valid PCM audio, disable mutes, - * TCBL=output - */ - CS8427_SWCLK | CS8427_TCBLDIR, - /* CS8427_REG_CONTROL2: hold last valid audio sample, RMCK=256*Fs, - * normal stereo operation - */ - 0x08, - /* CS8427_REG_DATAFLOW: - * AES3 Transmitter data source => Serial Audio input port - * Serial audio output port data source => reserved - */ - CS8427_TXDSERIAL, - /* CS8427_REG_CLOCKSOURCE: Run off, CMCK=256*Fs, - * output time base = OMCK, input time base = recovered input clock, - * recovered input clock source is ILRCK changed to AES3INPUT - * (workaround, see snd_cs8427_reset) - */ - CS8427_RXDILRCK | CS8427_OUTC, - /* CS8427_REG_SERIALINPUT: Serial audio input port data format = I2S, - * 24-bit, 64*Fsi - */ - CS8427_SIDEL | CS8427_SILRPOL | CS8427_SORES16, - /* CS8427_REG_SERIALOUTPUT: Serial audio output port data format - * = I2S, 24-bit, 64*Fsi - */ - CS8427_SODEL | CS8427_SOLRPOL | CS8427_SIRES16, - }; - static unsigned char initvals2[] = { - CS8427_REG_RECVERRMASK | CS8427_REG_AUTOINC, - /* CS8427_REG_RECVERRMASK: unmask the input PLL clock, V, confidence, - * biphase, parity status bits - * CS8427_UNLOCK | CS8427_V | CS8427_CONF | CS8427_BIP | CS8427_PAR, - */ - 0xff, /* set everything */ - /* CS8427_REG_CSDATABUF: - * Registers 32-55 window to CS buffer - * Inhibit D->E transfers from overwriting first 5 bytes of CS data. - * Inhibit D->E transfers (all) of CS data. - * Allow E->F transfer of CS data. - * One byte mode; both A/B channels get same written CB data. - * A channel info is output to chip's EMPH* pin. - */ - CS8427_CBMR | CS8427_DETCI, - /* CS8427_REG_UDATABUF: - * Use internal buffer to transmit User (U) data. - * Chip's U pin is an output. - * Transmit all O's for user data. - * Inhibit D->E transfers. - * Inhibit E->F transfers. - */ - CS8427_UD | CS8427_EFTUI | CS8427_DETUI, - }; - int err; - unsigned char buf[CHANNEL_STATUS_SIZE]; - unsigned char val = 0; - char addr = 0; - unsigned int reset_timeout = 1; - int ret = 0; - struct cs8427 *chip; - - if (!client) { - pr_err("%s: invalid device info\n", __func__); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct cs8427), GFP_KERNEL); - if (chip == NULL) { - dev_err(&client->dev, - "%s: error, allocation failed\n", __func__); - return -ENOMEM; - } - - chip->client = client; - - dev_set_drvdata(&chip->client->dev, chip); - - ret = poweron_cs8427(chip); - - if (ret) { - dev_err(&chip->client->dev, - "failed to bring chip out of reset\n"); - return -ENODEV; - } - - err = cs8427_i2c_read(chip, CS8427_REG_ID_AND_VER, 1, &val); - if (err < 0) { - /* give second chance */ - dev_err(&chip->client->dev, - "failed to read cs8427 trying once again\n"); - err = cs8427_i2c_read(chip, CS8427_REG_ID_AND_VER, - 1, &val); - if (err < 0) { - dev_err(&chip->client->dev, - "failed to read version number\n"); - return -ENODEV; - } - dev_dbg(&chip->client->dev, - "version number read = %x\n", val); - } - if (val != CS8427_VER8427A) { - dev_err(&chip->client->dev, - "unable to find CS8427 signature " - "(expected 0x%x, read 0x%x),\n", - CS8427_VER8427A, val); - dev_err(&chip->client->dev, - " initialization is not completed\n"); - return -EFAULT; - } - val = 0; - /* turn off run bit while making changes to configuration */ - err = cs8427_i2c_write(chip, CS8427_REG_CLOCKSOURCE, 1, &val); - if (err < 0) - goto __fail; - /* send initial values */ - memcpy(chip->regmap + (initvals1[0] & 0x7f), initvals1 + 1, 6); - addr = 1; - err = cs8427_i2c_sendbytes(chip, &addr, &initvals1[1], 6); - if (err != 6) { - err = err < 0 ? err : -EIO; - goto __fail; - } - /* Turn off CS8427 interrupt stuff that is not used in hardware */ - memset(buf, 0, 7); - /* from address 9 to 15 */ - addr = 9; - err = cs8427_i2c_sendbytes(chip, &addr, buf, 7); - if (err != 7) - goto __fail; - /* send transfer initialization sequence */ - addr = 0x11; - memcpy(chip->regmap + (initvals2[0] & 0x7f), initvals2 + 1, 3); - err = cs8427_i2c_sendbytes(chip, &addr, &initvals2[1], 3); - if (err != 3) { - err = err < 0 ? err : -EIO; - goto __fail; - } - /* write default channel status bytes */ - put_unaligned_le32(SNDRV_PCM_DEFAULT_CON_SPDIF, buf); - memset(buf + 4, 0, CHANNEL_STATUS_SIZE - 4); - if (snd_cs8427_send_corudata(chip, 0, buf, CHANNEL_STATUS_SIZE) < 0) - goto __fail; - memcpy(chip->playback.def_status, buf, CHANNEL_STATUS_SIZE); - memcpy(chip->playback.pcm_status, buf, CHANNEL_STATUS_SIZE); - - /* turn on run bit and rock'n'roll */ - if (reset_timeout < 1) - reset_timeout = 1; - chip->reset_timeout = reset_timeout; - snd_cs8427_reset(chip); - - ret = snd_soc_register_codec(&chip->client->dev, &soc_codec_dev_cs8427, - cs8427_dai, ARRAY_SIZE(cs8427_dai)); - - return 0; - -__fail: - kfree(chip); - return err < 0 ? err : -EIO; -} - -static int cs8427_remove(struct i2c_client *client) -{ - struct cs8427 *chip; - struct cs8427_platform_data *pdata; - chip = dev_get_drvdata(&client->dev); - if (!chip) { - pr_err("invalid device info\n"); - return -ENODEV; - } - pdata = chip->client->dev.platform_data; - gpio_free(pdata->reset_gpio); - if (pdata->enable) { - pdata->enable(0, pdata->ls_gpio); - gpio_free(pdata->ls_gpio); - } - kfree(chip); - return 0; -} - -static struct i2c_device_id cs8427_id_table[] = { - {"cs8427", CS8427_ADDR0}, - {"cs8427", CS8427_ADDR2}, - {"cs8427", CS8427_ADDR3}, - {"cs8427", CS8427_ADDR4}, - {"cs8427", CS8427_ADDR5}, - {"cs8427", CS8427_ADDR6}, - {"cs8427", CS8427_ADDR7}, - {} -}; -MODULE_DEVICE_TABLE(i2c, cs8427_id_table); - -static struct i2c_driver cs8427_i2c_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "cs8427-spdif", - }, - .id_table = cs8427_id_table, - .probe = cs8427_i2c_probe, - .remove = cs8427_remove, -}; - -static int __init cs8427_module_init(void) -{ - int ret = 0; - ret = i2c_add_driver(&cs8427_i2c_driver); - if (ret != 0) - pr_err("failed to add the I2C driver\n"); - return ret; -} - -static void __exit cs8427_module_exit(void) -{ - pr_info("module exit\n"); -} - -module_init(cs8427_module_init) -module_exit(cs8427_module_exit) - -MODULE_DESCRIPTION("CS8427 interface driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/timpani.c b/sound/soc/codecs/timpani.c deleted file mode 100644 index f80c0fcf4cb18d0238433ea44ddbc79502e65663..0000000000000000000000000000000000000000 --- a/sound/soc/codecs/timpani.c +++ /dev/null @@ -1,482 +0,0 @@ -/* Copyright (c) 2010, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* Debug purpose */ -#include -#include -#include -/* End of debug purpose */ - -#define ADIE_CODEC_MAX 2 - -struct adie_codec_register { - u8 reg; - u8 mask; - u8 val; -}; - -static struct adie_codec_register dmic_on[] = { - {0x80, 0x05, 0x05}, - {0x80, 0x05, 0x00}, - {0x83, 0x0C, 0x00}, - {0x8A, 0xF0, 0x30}, - {0x86, 0xFF, 0xAC}, - {0x87, 0xFF, 0xAC}, - {0x8A, 0xF0, 0xF0}, - {0x82, 0x1F, 0x1E}, - {0x83, 0x0C, 0x0C}, - {0x92, 0x3F, 0x21}, - {0x94, 0x3F, 0x24}, - {0xA3, 0x39, 0x01}, - {0xA8, 0x0F, 0x00}, - {0xAB, 0x3F, 0x00}, - {0x86, 0xFF, 0x00}, - {0x87, 0xFF, 0x00}, - {0x8A, 0xF0, 0xC0}, -}; - -static struct adie_codec_register dmic_off[] = { - {0x8A, 0xF0, 0xF0}, - {0x83, 0x0C, 0x00}, - {0x92, 0xFF, 0x00}, - {0x94, 0xFF, 0x1B}, -}; - -static struct adie_codec_register spk_on[] = { - {0x80, 0x02, 0x02}, - {0x80, 0x02, 0x00}, - {0x83, 0x03, 0x00}, - {0x8A, 0x0F, 0x03}, - {0xA3, 0x02, 0x02}, - {0x84, 0xFF, 0x00}, - {0x85, 0xFF, 0x00}, - {0x8A, 0x0F, 0x0C}, - {0x81, 0xFF, 0x0E}, - {0x83, 0x03, 0x03}, - {0x24, 0x6F, 0x6C}, - {0xB7, 0x01, 0x01}, - {0x31, 0x01, 0x01}, - {0x32, 0xF8, 0x08}, - {0x32, 0xF8, 0x48}, - {0x32, 0xF8, 0xF8}, - {0xE0, 0xFE, 0xAC}, - {0xE1, 0xFE, 0xAC}, - {0x3A, 0x24, 0x24}, - {0xE0, 0xFE, 0x3C}, - {0xE1, 0xFE, 0x3C}, - {0xE0, 0xFE, 0x1C}, - {0xE1, 0xFE, 0x1C}, - {0xE0, 0xFE, 0x10}, - {0xE1, 0xFE, 0x10}, -}; - -static struct adie_codec_register spk_off[] = { - {0x8A, 0x0F, 0x0F}, - {0xE0, 0xFE, 0x1C}, - {0xE1, 0xFE, 0x1C}, - {0xE0, 0xFE, 0x3C}, - {0xE1, 0xFE, 0x3C}, - {0xE0, 0xFC, 0xAC}, - {0xE1, 0xFC, 0xAC}, - {0x32, 0xF8, 0x00}, - {0x31, 0x05, 0x00}, - {0x3A, 0x24, 0x00}, -}; - -static struct adie_codec_register spk_mute[] = { - {0x84, 0xFF, 0xAC}, - {0x85, 0xFF, 0xAC}, - {0x8A, 0x0F, 0x0C}, -}; - -static struct adie_codec_register spk_unmute[] = { - {0x84, 0xFF, 0x00}, - {0x85, 0xFF, 0x00}, - {0x8A, 0x0F, 0x0C}, -}; - -struct adie_codec_path { - int rate; /* sample rate of path */ - u32 reg_owner; -}; - -struct timpani_drv_data { /* member undecided */ - struct snd_soc_codec codec; - struct adie_codec_path path[ADIE_CODEC_MAX]; - u32 ref_cnt; - struct marimba_codec_platform_data *codec_pdata; -}; - -static struct snd_soc_codec *timpani_codec; - -enum /* regaccess blk id */ -{ - RA_BLOCK_RX1 = 0, - RA_BLOCK_RX2, - RA_BLOCK_TX1, - RA_BLOCK_TX2, - RA_BLOCK_LB, - RA_BLOCK_SHARED_RX_LB, - RA_BLOCK_SHARED_TX, - RA_BLOCK_TXFE1, - RA_BLOCK_TXFE2, - RA_BLOCK_PA_COMMON, - RA_BLOCK_PA_EAR, - RA_BLOCK_PA_HPH, - RA_BLOCK_PA_LINE, - RA_BLOCK_PA_AUX, - RA_BLOCK_ADC, - RA_BLOCK_DMIC, - RA_BLOCK_TX_I2S, - RA_BLOCK_DRV, - RA_BLOCK_TEST, - RA_BLOCK_RESERVED, - RA_BLOCK_NUM, -}; - -enum /* regaccess onwer ID */ -{ - RA_OWNER_NONE = 0, - RA_OWNER_PATH_RX1, - RA_OWNER_PATH_RX2, - RA_OWNER_PATH_TX1, - RA_OWNER_PATH_TX2, - RA_OWNER_PATH_LB, - RA_OWNER_DRV, - RA_OWNER_NUM, -}; - -struct reg_acc_blk_cfg { - u8 valid_owners[RA_OWNER_NUM]; -}; - -struct timpani_regaccess { - u8 reg_addr; - u8 blk_mask[RA_BLOCK_NUM]; - u8 reg_mask; - u8 reg_default; -}; - -static unsigned int timpani_codec_read(struct snd_soc_codec *codec, - unsigned int reg) -{ - struct marimba *pdrv = codec->control_data; - int rc; - u8 val; - - rc = marimba_read(pdrv, reg, &val, 1); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: fail to write reg %x\n", __func__, reg); - return 0; - } - return val; -} - -static int timpani_codec_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int value) -{ - struct marimba *pdrv = codec->control_data; - int rc; - - rc = marimba_write_bit_mask(pdrv, reg, (u8 *)&value, 1, 0xFF); - if (IS_ERR_VALUE(rc)) { - pr_err("%s: fail to write reg %x\n", __func__, reg); - return -EIO; - } - pr_debug("%s: write reg %x val %x\n", __func__, reg, value); - return 0; -} - -static void timpani_codec_bring_up(struct snd_soc_codec *codec) -{ - struct timpani_drv_data *timpani = snd_soc_codec_get_drvdata(codec); - int rc; - - if (timpani->codec_pdata && - timpani->codec_pdata->marimba_codec_power) { - if (timpani->ref_cnt) - return; - /* Codec power up sequence */ - rc = timpani->codec_pdata->marimba_codec_power(1); - if (rc) - pr_err("%s: could not power up timpani " - "codec\n", __func__); - else { - timpani_codec_write(codec, 0xFF, 0x08); - timpani_codec_write(codec, 0xFF, 0x0A); - timpani_codec_write(codec, 0xFF, 0x0E); - timpani_codec_write(codec, 0xFF, 0x07); - timpani_codec_write(codec, 0xFF, 0x17); - timpani_codec_write(codec, TIMPANI_A_MREF, 0x22); - msleep(15); - timpani->ref_cnt++; - } - } -} - -static void timpani_codec_bring_down(struct snd_soc_codec *codec) -{ - struct timpani_drv_data *timpani = snd_soc_codec_get_drvdata(codec); - int rc; - - if (timpani->codec_pdata && - timpani->codec_pdata->marimba_codec_power) { - timpani->ref_cnt--; - if (timpani->ref_cnt >= 1) - return; - timpani_codec_write(codec, TIMPANI_A_MREF, TIMPANI_MREF_POR); - timpani_codec_write(codec, 0xFF, 0x07); - timpani_codec_write(codec, 0xFF, 0x06); - timpani_codec_write(codec, 0xFF, 0x0E); - timpani_codec_write(codec, 0xFF, 0x08); - rc = timpani->codec_pdata->marimba_codec_power(0); - if (rc) - pr_err("%s: could not power down timpani " - "codec\n", __func__); - } -} - -static void timpani_dmic_config(struct snd_soc_codec *codec, int on) -{ - struct adie_codec_register *regs; - int regs_sz, i; - - if (on) { - regs = dmic_on; - regs_sz = ARRAY_SIZE(dmic_on); - } else { - regs = dmic_off; - regs_sz = ARRAY_SIZE(dmic_off); - } - - for (i = 0; i < regs_sz; i++) - timpani_codec_write(codec, regs[i].reg, - (regs[i].mask & regs[i].val)); -} - -static void timpani_spk_config(struct snd_soc_codec *codec, int on) -{ - struct adie_codec_register *regs; - int regs_sz, i; - - if (on) { - regs = spk_on; - regs_sz = ARRAY_SIZE(spk_on); - } else { - regs = spk_off; - regs_sz = ARRAY_SIZE(spk_off); - } - - for (i = 0; i < regs_sz; i++) - timpani_codec_write(codec, regs[i].reg, - (regs[i].mask & regs[i].val)); -} - -static int timpani_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->card->codec; - - pr_info("%s()\n", __func__); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_info("%s: playback\n", __func__); - timpani_codec_bring_up(codec); - timpani_spk_config(codec, 1); - } else { - pr_info("%s: Capture\n", __func__); - timpani_codec_bring_up(codec); - timpani_dmic_config(codec, 1); - } - return 0; -} - -static void timpani_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->card->codec; - - pr_info("%s()\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - timpani_codec_bring_down(codec); - timpani_spk_config(codec, 0); - } else { - timpani_codec_bring_down(codec); - timpani_dmic_config(codec, 0); - } - return; -} - -int digital_mute(struct snd_soc_dai *dai, int mute) -{ - struct snd_soc_codec *codec = dai->codec; - struct adie_codec_register *regs; - int regs_sz, i; - - if (mute) { - regs = spk_mute; - regs_sz = ARRAY_SIZE(spk_mute); - } else { - regs = spk_unmute; - regs_sz = ARRAY_SIZE(spk_unmute); - } - - for (i = 0; i < regs_sz; i++) { - timpani_codec_write(codec, regs[i].reg, - (regs[i].mask & regs[i].val)); - msleep(10); - } - - return 0; -} - -static struct snd_soc_dai_ops timpani_dai_ops = { - .startup = timpani_startup, - .shutdown = timpani_shutdown, -}; - -struct snd_soc_dai timpani_codec_dai[] = { - { - .name = "TIMPANI Rx", - .playback = { - .stream_name = "Handset Playback", - .rates = SNDRV_PCM_RATE_8000_96000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rate_max = 96000, - .rate_min = 8000, - .channels_min = 1, - .channels_max = 2, - }, - .ops = &timpani_dai_ops, - }, - { - .name = "TIMPANI Tx", - .capture = { - .stream_name = "Handset Capture", - .rates = SNDRV_PCM_RATE_8000_96000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rate_max = 96000, - .rate_min = 8000, - .channels_min = 1, - .channels_max = 2, - }, - .ops = &timpani_dai_ops, - } -}; - -static int timpani_soc_probe(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec; - int ret = 0; - - if (!timpani_codec) { - dev_err(&pdev->dev, "core driver not yet probed\n"); - return -ENODEV; - } - - socdev->card->codec = timpani_codec; - codec = timpani_codec; - - ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); - if (ret < 0) - dev_err(codec->dev, "failed to create pcms\n"); - return ret; -} - -/* power down chip */ -static int timpani_soc_remove(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - - snd_soc_free_pcms(socdev); - return 0; -} - -struct snd_soc_codec_device soc_codec_dev_timpani = { - .probe = timpani_soc_probe, - .remove = timpani_soc_remove, -}; -EXPORT_SYMBOL_GPL(soc_codec_dev_timpani); - -static int timpani_codec_probe(struct platform_device *pdev) -{ - struct snd_soc_codec *codec; - struct timpani_drv_data *priv; - - pr_info("%s()\n", __func__); - priv = kzalloc(sizeof(struct timpani_drv_data), GFP_KERNEL); - if (priv == NULL) - return -ENOMEM; - - codec = &priv->codec; - snd_soc_codec_set_drvdata(codec, priv); - priv->codec_pdata = pdev->dev.platform_data; - - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - - codec->name = "TIMPANI"; - codec->owner = THIS_MODULE; - codec->read = timpani_codec_read; - codec->write = timpani_codec_write; - codec->dai = timpani_codec_dai; - codec->num_dai = ARRAY_SIZE(timpani_codec_dai); - codec->control_data = platform_get_drvdata(pdev); - timpani_codec = codec; - - snd_soc_register_dais(timpani_codec_dai, ARRAY_SIZE(timpani_codec_dai)); - snd_soc_register_codec(codec); - - return 0; -} - -static struct platform_driver timpani_codec_driver = { - .probe = timpani_codec_probe, - .driver = { - .name = "timpani_codec", - .owner = THIS_MODULE, - }, -}; - -static int __init timpani_codec_init(void) -{ - return platform_driver_register(&timpani_codec_driver); -} - -static void __exit timpani_codec_exit(void) -{ - platform_driver_unregister(&timpani_codec_driver); -} - -module_init(timpani_codec_init); -module_exit(timpani_codec_exit); - -MODULE_DESCRIPTION("Timpani codec driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/timpani.h b/sound/soc/codecs/timpani.h deleted file mode 100644 index bfa0b8b644aa358e4ab4099a077deb5247b02e43..0000000000000000000000000000000000000000 --- a/sound/soc/codecs/timpani.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (c) 2010, 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. - * - */ -#define NUM_I2S 2 -extern struct snd_soc_dai timpani_codec_dai[NUM_I2S]; -extern struct snd_soc_codec_device soc_codec_dev_timpani; diff --git a/sound/soc/codecs/wcd9304-tables.c b/sound/soc/codecs/wcd9304-tables.c deleted file mode 100644 index 7ec0152d8db3d43bba5d299f4fbaeb0f7a1bfce6..0000000000000000000000000000000000000000 --- a/sound/soc/codecs/wcd9304-tables.c +++ /dev/null @@ -1,845 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include "wcd9304.h" - -const u8 sitar_reg_defaults[SITAR_CACHE_SIZE] = { - [WCD9XXX_A_CHIP_CTL] = WCD9XXX_A_CHIP_CTL__POR, - [WCD9XXX_A_CHIP_STATUS] = WCD9XXX_A_CHIP_STATUS__POR, - [WCD9XXX_A_CHIP_ID_BYTE_0] = WCD9XXX_A_CHIP_ID_BYTE_0__POR, - [WCD9XXX_A_CHIP_ID_BYTE_1] = WCD9XXX_A_CHIP_ID_BYTE_1__POR, - [WCD9XXX_A_CHIP_ID_BYTE_2] = WCD9XXX_A_CHIP_ID_BYTE_2__POR, - [WCD9XXX_A_CHIP_ID_BYTE_3] = WCD9XXX_A_CHIP_ID_BYTE_3__POR, - [WCD9XXX_A_CHIP_VERSION] = WCD9XXX_A_CHIP_VERSION__POR, - [WCD9XXX_A_SB_VERSION] = WCD9XXX_A_SB_VERSION__POR, - [WCD9XXX_A_SLAVE_ID_1] = WCD9XXX_A_SLAVE_ID_1__POR, - [WCD9XXX_A_SLAVE_ID_2] = WCD9XXX_A_SLAVE_ID_2__POR, - [WCD9XXX_A_SLAVE_ID_3] = WCD9XXX_A_SLAVE_ID_3__POR, - [SITAR_A_PIN_CTL_OE0] = SITAR_A_PIN_CTL_OE0__POR, - [SITAR_A_PIN_CTL_OE1] = SITAR_A_PIN_CTL_OE1__POR, - [SITAR_A_PIN_CTL_DATA0] = SITAR_A_PIN_CTL_DATA0__POR, - [SITAR_A_PIN_CTL_DATA1] = SITAR_A_PIN_CTL_DATA1__POR, - [SITAR_A_HDRIVE_GENERIC] = SITAR_A_HDRIVE_GENERIC__POR, - [SITAR_A_HDRIVE_OVERRIDE] = SITAR_A_HDRIVE_OVERRIDE__POR, - [SITAR_A_ANA_CSR_WAIT_STATE] = SITAR_A_ANA_CSR_WAIT_STATE__POR, - [SITAR_A_PROCESS_MONITOR_CTL0] = SITAR_A_PROCESS_MONITOR_CTL0__POR, - [SITAR_A_PROCESS_MONITOR_CTL1] = SITAR_A_PROCESS_MONITOR_CTL1__POR, - [SITAR_A_PROCESS_MONITOR_CTL2] = SITAR_A_PROCESS_MONITOR_CTL2__POR, - [SITAR_A_PROCESS_MONITOR_CTL3] = SITAR_A_PROCESS_MONITOR_CTL3__POR, - [SITAR_A_QFUSE_CTL] = SITAR_A_QFUSE_CTL__POR, - [SITAR_A_QFUSE_STATUS] = SITAR_A_QFUSE_STATUS__POR, - [SITAR_A_QFUSE_DATA_OUT0] = SITAR_A_QFUSE_DATA_OUT0__POR, - [SITAR_A_QFUSE_DATA_OUT1] = SITAR_A_QFUSE_DATA_OUT1__POR, - [SITAR_A_QFUSE_DATA_OUT2] = SITAR_A_QFUSE_DATA_OUT2__POR, - [SITAR_A_QFUSE_DATA_OUT3] = SITAR_A_QFUSE_DATA_OUT3__POR, - [SITAR_A_CDC_CTL] = SITAR_A_CDC_CTL__POR, - [SITAR_A_LEAKAGE_CTL] = SITAR_A_LEAKAGE_CTL__POR, - [SITAR_A_INTR_MODE] = SITAR_A_INTR_MODE__POR, - [SITAR_A_INTR_MASK0] = SITAR_A_INTR_MASK0__POR, - [SITAR_A_INTR_MASK1] = SITAR_A_INTR_MASK1__POR, - [SITAR_A_INTR_MASK2] = SITAR_A_INTR_MASK2__POR, - [SITAR_A_INTR_STATUS0] = SITAR_A_INTR_STATUS0__POR, - [SITAR_A_INTR_STATUS1] = SITAR_A_INTR_STATUS1__POR, - [SITAR_A_INTR_STATUS2] = SITAR_A_INTR_STATUS2__POR, - [SITAR_A_INTR_CLEAR0] = SITAR_A_INTR_CLEAR0__POR, - [SITAR_A_INTR_CLEAR1] = SITAR_A_INTR_CLEAR1__POR, - [SITAR_A_INTR_CLEAR2] = SITAR_A_INTR_CLEAR2__POR, - [SITAR_A_INTR_LEVEL0] = SITAR_A_INTR_LEVEL0__POR, - [SITAR_A_INTR_LEVEL1] = SITAR_A_INTR_LEVEL1__POR, - [SITAR_A_INTR_LEVEL2] = SITAR_A_INTR_LEVEL2__POR, - [SITAR_A_INTR_TEST0] = SITAR_A_INTR_TEST0__POR, - [SITAR_A_INTR_TEST1] = SITAR_A_INTR_TEST1__POR, - [SITAR_A_INTR_TEST2] = SITAR_A_INTR_TEST2__POR, - [SITAR_A_INTR_SET0] = SITAR_A_INTR_SET0__POR, - [SITAR_A_INTR_SET1] = SITAR_A_INTR_SET1__POR, - [SITAR_A_INTR_SET2] = SITAR_A_INTR_SET2__POR, - [SITAR_A_CDC_TX_I2S_SCK_MODE] = SITAR_A_CDC_TX_I2S_SCK_MODE__POR, - [SITAR_A_CDC_TX_I2S_WS_MODE] = SITAR_A_CDC_TX_I2S_WS_MODE__POR, - [SITAR_A_CDC_DMIC_DATA0_MODE] = SITAR_A_CDC_DMIC_DATA0_MODE__POR, - [SITAR_A_CDC_DMIC_CLK0_MODE] = SITAR_A_CDC_DMIC_CLK0_MODE__POR, - [SITAR_A_CDC_DMIC_DATA1_MODE] = SITAR_A_CDC_DMIC_DATA1_MODE__POR, - [SITAR_A_CDC_DMIC_CLK1_MODE] = SITAR_A_CDC_DMIC_CLK1_MODE__POR, - [SITAR_A_CDC_TX_I2S_SD0_MODE] = SITAR_A_CDC_TX_I2S_SD0_MODE__POR, - [SITAR_A_CDC_INTR_MODE] = SITAR_A_CDC_INTR_MODE__POR, - [SITAR_A_CDC_RX_I2S_SD0_MODE] = SITAR_A_CDC_RX_I2S_SD0_MODE__POR, - [SITAR_A_CDC_RX_I2S_SD1_MODE] = SITAR_A_CDC_RX_I2S_SD1_MODE__POR, - [SITAR_A_BIAS_REF_CTL] = SITAR_A_BIAS_REF_CTL__POR, - [SITAR_A_BIAS_CENTRAL_BG_CTL] = SITAR_A_BIAS_CENTRAL_BG_CTL__POR, - [SITAR_A_BIAS_PRECHRG_CTL] = SITAR_A_BIAS_PRECHRG_CTL__POR, - [SITAR_A_BIAS_CURR_CTL_1] = SITAR_A_BIAS_CURR_CTL_1__POR, - [SITAR_A_BIAS_CURR_CTL_2] = SITAR_A_BIAS_CURR_CTL_2__POR, - [SITAR_A_BIAS_OSC_BG_CTL] = SITAR_A_BIAS_OSC_BG_CTL__POR, - [SITAR_A_CLK_BUFF_EN1] = SITAR_A_CLK_BUFF_EN1__POR, - [SITAR_A_CLK_BUFF_EN2] = SITAR_A_CLK_BUFF_EN2__POR, - [SITAR_A_LDO_H_MODE_1] = SITAR_A_LDO_H_MODE_1__POR, - [SITAR_A_LDO_H_MODE_2] = SITAR_A_LDO_H_MODE_2__POR, - [SITAR_A_LDO_H_LOOP_CTL] = SITAR_A_LDO_H_LOOP_CTL__POR, - [SITAR_A_LDO_H_COMP_1] = SITAR_A_LDO_H_COMP_1__POR, - [SITAR_A_LDO_H_COMP_2] = SITAR_A_LDO_H_COMP_2__POR, - [SITAR_A_LDO_H_BIAS_1] = SITAR_A_LDO_H_BIAS_1__POR, - [SITAR_A_LDO_H_BIAS_2] = SITAR_A_LDO_H_BIAS_2__POR, - [SITAR_A_LDO_H_BIAS_3] = SITAR_A_LDO_H_BIAS_3__POR, - [SITAR_A_MICB_CFILT_1_CTL] = SITAR_A_MICB_CFILT_1_CTL__POR, - [SITAR_A_MICB_CFILT_1_VAL] = SITAR_A_MICB_CFILT_1_VAL__POR, - [SITAR_A_MICB_CFILT_1_PRECHRG] = SITAR_A_MICB_CFILT_1_PRECHRG__POR, - [SITAR_A_MICB_1_CTL] = SITAR_A_MICB_1_CTL__POR, - [SITAR_A_MICB_1_INT_RBIAS] = SITAR_A_MICB_1_INT_RBIAS__POR, - [SITAR_A_MICB_1_MBHC] = SITAR_A_MICB_1_MBHC__POR, - [SITAR_A_MICB_CFILT_2_CTL] = SITAR_A_MICB_CFILT_2_CTL__POR, - [SITAR_A_MICB_CFILT_2_VAL] = SITAR_A_MICB_CFILT_2_VAL__POR, - [SITAR_A_MICB_CFILT_2_PRECHRG] = SITAR_A_MICB_CFILT_2_PRECHRG__POR, - [SITAR_A_MICB_2_CTL] = SITAR_A_MICB_2_CTL__POR, - [SITAR_A_MICB_2_INT_RBIAS] = SITAR_A_MICB_2_INT_RBIAS__POR, - [SITAR_A_MICB_2_MBHC] = SITAR_A_MICB_2_MBHC__POR, - [SITAR_A_TX_COM_BIAS] = SITAR_A_TX_COM_BIAS__POR, - [SITAR_A_MBHC_SCALING_MUX_1] = SITAR_A_MBHC_SCALING_MUX_1__POR, - [SITAR_A_MBHC_SCALING_MUX_2] = SITAR_A_MBHC_SCALING_MUX_2__POR, - [SITAR_A_TX_SUP_SWITCH_CTRL_1] = SITAR_A_TX_SUP_SWITCH_CTRL_1__POR, - [SITAR_A_TX_SUP_SWITCH_CTRL_2] = SITAR_A_TX_SUP_SWITCH_CTRL_2__POR, - [SITAR_A_TX_1_2_EN] = SITAR_A_TX_1_2_EN__POR, - [SITAR_A_TX_1_2_TEST_EN] = SITAR_A_TX_1_2_TEST_EN__POR, - [SITAR_A_TX_1_2_ADC_CH1] = SITAR_A_TX_1_2_ADC_CH1__POR, - [SITAR_A_TX_1_2_ADC_CH2] = SITAR_A_TX_1_2_ADC_CH2__POR, - [SITAR_A_TX_1_2_ATEST_REFCTRL] = SITAR_A_TX_1_2_ATEST_REFCTRL__POR, - [SITAR_A_TX_1_2_TEST_CTL] = SITAR_A_TX_1_2_TEST_CTL__POR, - [SITAR_A_TX_1_2_TEST_BLOCK_EN] = SITAR_A_TX_1_2_TEST_BLOCK_EN__POR, - [SITAR_A_TX_1_2_TXFE_CLKDIV] = SITAR_A_TX_1_2_TXFE_CLKDIV__POR, - [SITAR_A_TX_1_2_SAR_ERR_CH1] = SITAR_A_TX_1_2_SAR_ERR_CH1__POR, - [SITAR_A_TX_1_2_SAR_ERR_CH2] = SITAR_A_TX_1_2_SAR_ERR_CH2__POR, - [SITAR_A_TX_3_EN] = SITAR_A_TX_3_EN__POR, - [SITAR_A_TX_3_TEST_EN] = SITAR_A_TX_3_TEST_EN__POR, - [SITAR_A_TX_3_ADC] = SITAR_A_TX_3_ADC__POR, - [SITAR_A_TX_3_MBHC_ATEST_REFCTRL] = - SITAR_A_TX_3_MBHC_ATEST_REFCTRL__POR, - [SITAR_A_TX_3_TEST_CTL] = SITAR_A_TX_3_TEST_CTL__POR, - [SITAR_A_TX_3_TEST_BLOCK_EN] = SITAR_A_TX_3_TEST_BLOCK_EN__POR, - [SITAR_A_TX_3_TXFE_CKDIV] = SITAR_A_TX_3_TXFE_CKDIV__POR, - [SITAR_A_TX_3_SAR_ERR] = SITAR_A_TX_3_SAR_ERR__POR, - [SITAR_A_TX_4_MBHC_EN] = SITAR_A_TX_4_MBHC_EN__POR, - [SITAR_A_TX_4_MBHC_ADC] = SITAR_A_TX_4_MBHC_ADC__POR, - [SITAR_A_TX_4_MBHC_TEST_CTL] = SITAR_A_TX_4_MBHC_TEST_CTL__POR, - [SITAR_A_TX_4_MBHC_SAR_ERR] = SITAR_A_TX_4_MBHC_SAR_ERR__POR, - [SITAR_A_TX_4_TXFE_CLKDIV] = SITAR_A_TX_4_TXFE_CLKDIV__POR, - [SITAR_A_AUX_COM_CTL] = SITAR_A_AUX_COM_CTL__POR, - [SITAR_A_AUX_COM_ATEST] = SITAR_A_AUX_COM_ATEST__POR, - [SITAR_A_AUX_L_EN] = SITAR_A_AUX_L_EN__POR, - [SITAR_A_AUX_L_GAIN] = SITAR_A_AUX_L_GAIN__POR, - [SITAR_A_AUX_L_PA_CONN] = SITAR_A_AUX_L_PA_CONN__POR, - [SITAR_A_AUX_L_PA_CONN_INV] = SITAR_A_AUX_L_PA_CONN_INV__POR, - [SITAR_A_AUX_R_EN] = SITAR_A_AUX_R_EN__POR, - [SITAR_A_AUX_R_GAIN] = SITAR_A_AUX_R_GAIN__POR, - [SITAR_A_AUX_R_PA_CONN] = SITAR_A_AUX_R_PA_CONN__POR, - [SITAR_A_AUX_R_PA_CONN_INV] = SITAR_A_AUX_R_PA_CONN_INV__POR, - [SITAR_A_CP_EN] = SITAR_A_CP_EN__POR, - [SITAR_A_CP_CLK] = SITAR_A_CP_CLK__POR, - [SITAR_A_CP_STATIC] = SITAR_A_CP_STATIC__POR, - [SITAR_A_CP_DCC1] = SITAR_A_CP_DCC1__POR, - [SITAR_A_CP_DCC3] = SITAR_A_CP_DCC3__POR, - [SITAR_A_CP_ATEST] = SITAR_A_CP_ATEST__POR, - [SITAR_A_CP_DTEST] = SITAR_A_CP_DTEST__POR, - [SITAR_A_RX_COM_TIMER_DIV] = SITAR_A_RX_COM_TIMER_DIV__POR, - [SITAR_A_RX_COM_OCP_CTL] = SITAR_A_RX_COM_OCP_CTL__POR, - [SITAR_A_RX_COM_OCP_COUNT] = SITAR_A_RX_COM_OCP_COUNT__POR, - [SITAR_A_RX_COM_DAC_CTL] = SITAR_A_RX_COM_DAC_CTL__POR, - [SITAR_A_RX_COM_BIAS] = SITAR_A_RX_COM_BIAS__POR, - [SITAR_A_RX_HPH_BIAS_PA] = SITAR_A_RX_HPH_BIAS_PA__POR, - [SITAR_A_RX_HPH_BIAS_LDO] = SITAR_A_RX_HPH_BIAS_LDO__POR, - [SITAR_A_RX_HPH_BIAS_CNP] = SITAR_A_RX_HPH_BIAS_CNP__POR, - [SITAR_A_RX_HPH_BIAS_WG] = SITAR_A_RX_HPH_BIAS_WG__POR, - [SITAR_A_RX_HPH_OCP_CTL] = SITAR_A_RX_HPH_OCP_CTL__POR, - [SITAR_A_RX_HPH_CNP_EN] = SITAR_A_RX_HPH_CNP_EN__POR, - [SITAR_A_RX_HPH_CNP_WG_CTL] = SITAR_A_RX_HPH_CNP_WG_CTL__POR, - [SITAR_A_RX_HPH_CNP_WG_TIME] = SITAR_A_RX_HPH_CNP_WG_TIME__POR, - [SITAR_A_RX_HPH_L_GAIN] = SITAR_A_RX_HPH_L_GAIN__POR, - [SITAR_A_RX_HPH_L_TEST] = SITAR_A_RX_HPH_L_TEST__POR, - [SITAR_A_RX_HPH_L_PA_CTL] = SITAR_A_RX_HPH_L_PA_CTL__POR, - [SITAR_A_RX_HPH_L_DAC_CTL] = SITAR_A_RX_HPH_L_DAC_CTL__POR, - [SITAR_A_RX_HPH_L_ATEST] = SITAR_A_RX_HPH_L_ATEST__POR, - [SITAR_A_RX_HPH_L_STATUS] = SITAR_A_RX_HPH_L_STATUS__POR, - [SITAR_A_RX_HPH_R_GAIN] = SITAR_A_RX_HPH_R_GAIN__POR, - [SITAR_A_RX_HPH_R_TEST] = SITAR_A_RX_HPH_R_TEST__POR, - [SITAR_A_RX_HPH_R_PA_CTL] = SITAR_A_RX_HPH_R_PA_CTL__POR, - [SITAR_A_RX_HPH_R_DAC_CTL] = SITAR_A_RX_HPH_R_DAC_CTL__POR, - [SITAR_A_RX_HPH_R_ATEST] = SITAR_A_RX_HPH_R_ATEST__POR, - [SITAR_A_RX_HPH_R_STATUS] = SITAR_A_RX_HPH_R_STATUS__POR, - [SITAR_A_RX_EAR_BIAS_PA] = SITAR_A_RX_EAR_BIAS_PA__POR, - [SITAR_A_RX_EAR_BIAS_CMBUFF] = SITAR_A_RX_EAR_BIAS_CMBUFF__POR, - [SITAR_A_RX_EAR_EN] = SITAR_A_RX_EAR_EN__POR, - [SITAR_A_RX_EAR_GAIN] = SITAR_A_RX_EAR_GAIN__POR, - [SITAR_A_RX_EAR_CMBUFF] = SITAR_A_RX_EAR_CMBUFF__POR, - [SITAR_A_RX_EAR_ICTL] = SITAR_A_RX_EAR_ICTL__POR, - [SITAR_A_RX_EAR_CCOMP] = SITAR_A_RX_EAR_CCOMP__POR, - [SITAR_A_RX_EAR_VCM] = SITAR_A_RX_EAR_VCM__POR, - [SITAR_A_RX_EAR_CNP] = SITAR_A_RX_EAR_CNP__POR, - [SITAR_A_RX_EAR_ATEST] = SITAR_A_RX_EAR_ATEST__POR, - [SITAR_A_RX_EAR_STATUS] = SITAR_A_RX_EAR_STATUS__POR, - [SITAR_A_RX_LINE_BIAS_PA] = SITAR_A_RX_LINE_BIAS_PA__POR, - [SITAR_A_RX_LINE_BIAS_LDO] = SITAR_A_RX_LINE_BIAS_LDO__POR, - [SITAR_A_RX_LINE_BIAS_CNP1] = SITAR_A_RX_LINE_BIAS_CNP1__POR, - [SITAR_A_RX_LINE_COM] = SITAR_A_RX_LINE_COM__POR, - [SITAR_A_RX_LINE_CNP_EN] = SITAR_A_RX_LINE_CNP_EN__POR, - [SITAR_A_RX_LINE_CNP_WG_CTL] = SITAR_A_RX_LINE_CNP_WG_CTL__POR, - [SITAR_A_RX_LINE_CNP_WG_TIME] = SITAR_A_RX_LINE_CNP_WG_TIME__POR, - [SITAR_A_RX_LINE_1_GAIN] = SITAR_A_RX_LINE_1_GAIN__POR, - [SITAR_A_RX_LINE_1_TEST] = SITAR_A_RX_LINE_1_TEST__POR, - [SITAR_A_RX_LINE_1_DAC_CTL] = SITAR_A_RX_LINE_1_DAC_CTL__POR, - [SITAR_A_RX_LINE_1_STATUS] = SITAR_A_RX_LINE_1_STATUS__POR, - [SITAR_A_RX_LINE_2_GAIN] = SITAR_A_RX_LINE_2_GAIN__POR, - [SITAR_A_RX_LINE_2_TEST] = SITAR_A_RX_LINE_2_TEST__POR, - [SITAR_A_RX_LINE_2_DAC_CTL] = SITAR_A_RX_LINE_2_DAC_CTL__POR, - [SITAR_A_RX_LINE_2_STATUS] = SITAR_A_RX_LINE_2_STATUS__POR, - [SITAR_A_RX_LINE_BIAS_CNP2] = SITAR_A_RX_LINE_BIAS_CNP2__POR, - [SITAR_A_RX_LINE_OCP_CTL] = SITAR_A_RX_LINE_OCP_CTL__POR, - [SITAR_A_RX_LINE_1_PA_CTL] = SITAR_A_RX_LINE_1_PA_CTL__POR, - [SITAR_A_RX_LINE_2_PA_CTL] = SITAR_A_RX_LINE_2_PA_CTL__POR, - [SITAR_A_RX_LINE_CNP_DBG] = SITAR_A_RX_LINE_CNP_DBG__POR, - [SITAR_A_MBHC_HPH] = SITAR_A_MBHC_HPH__POR, - [SITAR_A_RC_OSC_FREQ] = SITAR_A_RC_OSC_FREQ__POR, - [SITAR_A_RC_OSC_TEST] = SITAR_A_RC_OSC_TEST__POR, - [SITAR_A_RC_OSC_STATUS] = SITAR_A_RC_OSC_STATUS__POR, - [SITAR_A_RC_OSC_TUNER] = SITAR_A_RC_OSC_TUNER__POR, - [SITAR_A_CDC_ANC1_CTL] = SITAR_A_CDC_ANC1_CTL__POR, - [SITAR_A_CDC_ANC1_SHIFT] = SITAR_A_CDC_ANC1_SHIFT__POR, - [SITAR_A_CDC_ANC1_IIR_B1_CTL] = SITAR_A_CDC_ANC1_IIR_B1_CTL__POR, - [SITAR_A_CDC_ANC1_IIR_B2_CTL] = SITAR_A_CDC_ANC1_IIR_B2_CTL__POR, - [SITAR_A_CDC_ANC1_IIR_B3_CTL] = SITAR_A_CDC_ANC1_IIR_B3_CTL__POR, - [SITAR_A_CDC_ANC1_IIR_B4_CTL] = SITAR_A_CDC_ANC1_IIR_B4_CTL__POR, - [SITAR_A_CDC_ANC1_LPF_B1_CTL] = SITAR_A_CDC_ANC1_LPF_B1_CTL__POR, - [SITAR_A_CDC_ANC1_LPF_B2_CTL] = SITAR_A_CDC_ANC1_LPF_B2_CTL__POR, - [SITAR_A_CDC_ANC1_LPF_B3_CTL] = SITAR_A_CDC_ANC1_LPF_B3_CTL__POR, - [SITAR_A_CDC_ANC1_SPARE] = SITAR_A_CDC_ANC1_SPARE__POR, - [SITAR_A_CDC_ANC1_SMLPF_CTL] = SITAR_A_CDC_ANC1_SMLPF_CTL__POR, - [SITAR_A_CDC_ANC1_DCFLT_CTL] = SITAR_A_CDC_ANC1_DCFLT_CTL__POR, - [SITAR_A_CDC_TX1_VOL_CTL_TIMER] = SITAR_A_CDC_TX1_VOL_CTL_TIMER__POR, - [SITAR_A_CDC_TX1_VOL_CTL_GAIN] = SITAR_A_CDC_TX1_VOL_CTL_GAIN__POR, - [SITAR_A_CDC_TX1_VOL_CTL_CFG] = SITAR_A_CDC_TX1_VOL_CTL_CFG__POR, - [SITAR_A_CDC_TX1_MUX_CTL] = SITAR_A_CDC_TX1_MUX_CTL__POR, - [SITAR_A_CDC_TX1_CLK_FS_CTL] = SITAR_A_CDC_TX1_CLK_FS_CTL__POR, - [SITAR_A_CDC_TX1_DMIC_CTL] = SITAR_A_CDC_TX1_DMIC_CTL__POR, - [SITAR_A_CDC_SRC1_PDA_CFG] = SITAR_A_CDC_SRC1_PDA_CFG__POR, - [SITAR_A_CDC_SRC1_FS_CTL] = SITAR_A_CDC_SRC1_FS_CTL__POR, - [SITAR_A_CDC_RX1_B1_CTL] = SITAR_A_CDC_RX1_B1_CTL__POR, - [SITAR_A_CDC_RX1_B2_CTL] = SITAR_A_CDC_RX1_B2_CTL__POR, - [SITAR_A_CDC_RX1_B3_CTL] = SITAR_A_CDC_RX1_B3_CTL__POR, - [SITAR_A_CDC_RX1_B4_CTL] = SITAR_A_CDC_RX1_B4_CTL__POR, - [SITAR_A_CDC_RX1_B5_CTL] = SITAR_A_CDC_RX1_B5_CTL__POR, - [SITAR_A_CDC_RX1_B6_CTL] = SITAR_A_CDC_RX1_B6_CTL__POR, - [SITAR_A_CDC_RX2_B1_CTL] = SITAR_A_CDC_RX2_B1_CTL__POR, - [SITAR_A_CDC_RX2_B2_CTL] = SITAR_A_CDC_RX2_B2_CTL__POR, - [SITAR_A_CDC_RX2_B3_CTL] = SITAR_A_CDC_RX2_B3_CTL__POR, - [SITAR_A_CDC_RX2_B4_CTL] = SITAR_A_CDC_RX2_B4_CTL__POR, - [SITAR_A_CDC_RX2_B5_CTL] = SITAR_A_CDC_RX2_B5_CTL__POR, - [SITAR_A_CDC_RX2_B6_CTL] = SITAR_A_CDC_RX2_B6_CTL__POR, - [SITAR_A_CDC_RX3_B1_CTL] = SITAR_A_CDC_RX3_B1_CTL__POR, - [SITAR_A_CDC_RX3_B2_CTL] = SITAR_A_CDC_RX3_B2_CTL__POR, - [SITAR_A_CDC_RX3_B3_CTL] = SITAR_A_CDC_RX3_B3_CTL__POR, - [SITAR_A_CDC_RX3_B4_CTL] = SITAR_A_CDC_RX3_B4_CTL__POR, - [SITAR_A_CDC_RX3_B5_CTL] = SITAR_A_CDC_RX3_B5_CTL__POR, - [SITAR_A_CDC_RX3_B6_CTL] = SITAR_A_CDC_RX3_B6_CTL__POR, - [SITAR_A_CDC_RX1_VOL_CTL_B1_CTL] = SITAR_A_CDC_RX1_VOL_CTL_B1_CTL__POR, - [SITAR_A_CDC_RX1_VOL_CTL_B2_CTL] = SITAR_A_CDC_RX1_VOL_CTL_B2_CTL__POR, - [SITAR_A_CDC_RX2_VOL_CTL_B1_CTL] = SITAR_A_CDC_RX2_VOL_CTL_B1_CTL__POR, - [SITAR_A_CDC_RX2_VOL_CTL_B2_CTL] = SITAR_A_CDC_RX2_VOL_CTL_B2_CTL__POR, - [SITAR_A_CDC_RX3_VOL_CTL_B1_CTL] = SITAR_A_CDC_RX3_VOL_CTL_B1_CTL__POR, - [SITAR_A_CDC_RX3_VOL_CTL_B2_CTL] = SITAR_A_CDC_RX3_VOL_CTL_B2_CTL__POR, - [SITAR_A_CDC_CLK_ANC_RESET_CTL] = SITAR_A_CDC_CLK_ANC_RESET_CTL__POR, - [SITAR_A_CDC_CLK_RX_RESET_CTL] = SITAR_A_CDC_CLK_RX_RESET_CTL__POR, - [SITAR_A_CDC_CLK_TX_RESET_B1_CTL] = - SITAR_A_CDC_CLK_TX_RESET_B1_CTL__POR, - [SITAR_A_CDC_CLK_TX_RESET_B2_CTL] = - SITAR_A_CDC_CLK_TX_RESET_B2_CTL__POR, - [SITAR_A_CDC_CLK_DMIC_CTL] = SITAR_A_CDC_CLK_DMIC_CTL__POR, - [SITAR_A_CDC_CLK_RX_I2S_CTL] = SITAR_A_CDC_CLK_RX_I2S_CTL__POR, - [SITAR_A_CDC_CLK_TX_I2S_CTL] = SITAR_A_CDC_CLK_TX_I2S_CTL__POR, - [SITAR_A_CDC_CLK_OTHR_RESET_CTL] = SITAR_A_CDC_CLK_OTHR_RESET_CTL__POR, - [SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL] = - SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL__POR, - [SITAR_A_CDC_CLK_OTHR_CTL] = SITAR_A_CDC_CLK_OTHR_CTL__POR, - [SITAR_A_CDC_CLK_RDAC_CLK_EN_CTL] = - SITAR_A_CDC_CLK_RDAC_CLK_EN_CTL__POR, - [SITAR_A_CDC_CLK_ANC_CLK_EN_CTL] = SITAR_A_CDC_CLK_ANC_CLK_EN_CTL__POR, - [SITAR_A_CDC_CLK_RX_B1_CTL] = SITAR_A_CDC_CLK_RX_B1_CTL__POR, - [SITAR_A_CDC_CLK_RX_B2_CTL] = SITAR_A_CDC_CLK_RX_B2_CTL__POR, - [SITAR_A_CDC_CLK_MCLK_CTL] = SITAR_A_CDC_CLK_MCLK_CTL__POR, - [SITAR_A_CDC_CLK_PDM_CTL] = SITAR_A_CDC_CLK_PDM_CTL__POR, - [SITAR_A_CDC_CLK_SD_CTL] = SITAR_A_CDC_CLK_SD_CTL__POR, - [SITAR_A_CDC_CLK_LP_CTL] = SITAR_A_CDC_CLK_LP_CTL__POR, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B1_CTL] = - SITAR_A_CDC_CLSG_FREQ_THRESH_B1_CTL__POR, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B2_CTL] = - SITAR_A_CDC_CLSG_FREQ_THRESH_B2_CTL__POR, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B3_CTL] = - SITAR_A_CDC_CLSG_FREQ_THRESH_B3_CTL__POR, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B4_CTL] = - SITAR_A_CDC_CLSG_FREQ_THRESH_B4_CTL__POR, - [SITAR_A_CDC_CLSG_GAIN_THRESH_CTL] = - SITAR_A_CDC_CLSG_GAIN_THRESH_CTL__POR, - [SITAR_A_CDC_CLSG_TIMER_B1_CFG] = SITAR_A_CDC_CLSG_TIMER_B1_CFG__POR, - [SITAR_A_CDC_CLSG_TIMER_B2_CFG] = SITAR_A_CDC_CLSG_TIMER_B2_CFG__POR, - [SITAR_A_CDC_CLSG_CTL] = SITAR_A_CDC_CLSG_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B1_CTL] = SITAR_A_CDC_IIR1_GAIN_B1_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B2_CTL] = SITAR_A_CDC_IIR1_GAIN_B2_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B3_CTL] = SITAR_A_CDC_IIR1_GAIN_B3_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B4_CTL] = SITAR_A_CDC_IIR1_GAIN_B4_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B5_CTL] = SITAR_A_CDC_IIR1_GAIN_B5_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B6_CTL] = SITAR_A_CDC_IIR1_GAIN_B6_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B7_CTL] = SITAR_A_CDC_IIR1_GAIN_B7_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_B8_CTL] = SITAR_A_CDC_IIR1_GAIN_B8_CTL__POR, - [SITAR_A_CDC_IIR1_CTL] = SITAR_A_CDC_IIR1_CTL__POR, - [SITAR_A_CDC_IIR1_GAIN_TIMER_CTL] = - SITAR_A_CDC_IIR1_GAIN_TIMER_CTL__POR, - [SITAR_A_CDC_IIR1_COEF_B1_CTL] = SITAR_A_CDC_IIR1_COEF_B1_CTL__POR, - [SITAR_A_CDC_IIR1_COEF_B2_CTL] = SITAR_A_CDC_IIR1_COEF_B2_CTL__POR, - [SITAR_A_CDC_IIR1_COEF_B3_CTL] = SITAR_A_CDC_IIR1_COEF_B3_CTL__POR, - [SITAR_A_CDC_IIR1_COEF_B4_CTL] = SITAR_A_CDC_IIR1_COEF_B4_CTL__POR, - [SITAR_A_CDC_IIR1_COEF_B5_CTL] = SITAR_A_CDC_IIR1_COEF_B5_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B1_CTL] = SITAR_A_CDC_IIR2_GAIN_B1_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B2_CTL] = SITAR_A_CDC_IIR2_GAIN_B2_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B3_CTL] = SITAR_A_CDC_IIR2_GAIN_B3_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B4_CTL] = SITAR_A_CDC_IIR2_GAIN_B4_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B5_CTL] = SITAR_A_CDC_IIR2_GAIN_B5_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B6_CTL] = SITAR_A_CDC_IIR2_GAIN_B6_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B7_CTL] = SITAR_A_CDC_IIR2_GAIN_B7_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_B8_CTL] = SITAR_A_CDC_IIR2_GAIN_B8_CTL__POR, - [SITAR_A_CDC_IIR2_CTL] = SITAR_A_CDC_IIR2_CTL__POR, - [SITAR_A_CDC_IIR2_GAIN_TIMER_CTL] = - SITAR_A_CDC_IIR2_GAIN_TIMER_CTL__POR, - [SITAR_A_CDC_IIR2_COEF_B1_CTL] = SITAR_A_CDC_IIR2_COEF_B1_CTL__POR, - [SITAR_A_CDC_IIR2_COEF_B2_CTL] = SITAR_A_CDC_IIR2_COEF_B2_CTL__POR, - [SITAR_A_CDC_IIR2_COEF_B3_CTL] = SITAR_A_CDC_IIR2_COEF_B3_CTL__POR, - [SITAR_A_CDC_IIR2_COEF_B4_CTL] = SITAR_A_CDC_IIR2_COEF_B4_CTL__POR, - [SITAR_A_CDC_IIR2_COEF_B5_CTL] = SITAR_A_CDC_IIR2_COEF_B5_CTL__POR, - [SITAR_A_CDC_TOP_GAIN_UPDATE] = SITAR_A_CDC_TOP_GAIN_UPDATE__POR, - [SITAR_A_CDC_TOP_RDAC_DOUT_CTL] = SITAR_A_CDC_TOP_RDAC_DOUT_CTL__POR, - [SITAR_A_CDC_DEBUG_B1_CTL] = SITAR_A_CDC_DEBUG_B1_CTL__POR, - [SITAR_A_CDC_DEBUG_B2_CTL] = SITAR_A_CDC_DEBUG_B2_CTL__POR, - [SITAR_A_CDC_DEBUG_B3_CTL] = SITAR_A_CDC_DEBUG_B3_CTL__POR, - [SITAR_A_CDC_DEBUG_B4_CTL] = SITAR_A_CDC_DEBUG_B4_CTL__POR, - [SITAR_A_CDC_DEBUG_B5_CTL] = SITAR_A_CDC_DEBUG_B5_CTL__POR, - [SITAR_A_CDC_DEBUG_B6_CTL] = SITAR_A_CDC_DEBUG_B6_CTL__POR, - [SITAR_A_CDC_DEBUG_B7_CTL] = SITAR_A_CDC_DEBUG_B7_CTL__POR, - [SITAR_A_CDC_COMP1_B1_CTL] = SITAR_A_CDC_COMP1_B1_CTL__POR, - [SITAR_A_CDC_COMP1_B2_CTL] = SITAR_A_CDC_COMP1_B2_CTL__POR, - [SITAR_A_CDC_COMP1_B3_CTL] = SITAR_A_CDC_COMP1_B3_CTL__POR, - [SITAR_A_CDC_COMP1_B4_CTL] = SITAR_A_CDC_COMP1_B4_CTL__POR, - [SITAR_A_CDC_COMP1_B5_CTL] = SITAR_A_CDC_COMP1_B5_CTL__POR, - [SITAR_A_CDC_COMP1_B6_CTL] = SITAR_A_CDC_COMP1_B6_CTL__POR, - [SITAR_A_CDC_COMP1_SHUT_DOWN_STATUS] = - SITAR_A_CDC_COMP1_SHUT_DOWN_STATUS__POR, - [SITAR_A_CDC_COMP1_FS_CFG] = SITAR_A_CDC_COMP1_FS_CFG__POR, - [SITAR_A_CDC_COMP2_B1_CTL] = SITAR_A_CDC_COMP2_B1_CTL__POR, - [SITAR_A_CDC_COMP2_B2_CTL] = SITAR_A_CDC_COMP2_B2_CTL__POR, - [SITAR_A_CDC_COMP2_B3_CTL] = SITAR_A_CDC_COMP2_B3_CTL__POR, - [SITAR_A_CDC_COMP2_B4_CTL] = SITAR_A_CDC_COMP2_B4_CTL__POR, - [SITAR_A_CDC_COMP2_B5_CTL] = SITAR_A_CDC_COMP2_B5_CTL__POR, - [SITAR_A_CDC_COMP2_B6_CTL] = SITAR_A_CDC_COMP2_B6_CTL__POR, - [SITAR_A_CDC_COMP2_SHUT_DOWN_STATUS] = - SITAR_A_CDC_COMP2_SHUT_DOWN_STATUS__POR, - [SITAR_A_CDC_COMP2_FS_CFG] = SITAR_A_CDC_COMP2_FS_CFG__POR, - [SITAR_A_CDC_CONN_RX1_B1_CTL] = SITAR_A_CDC_CONN_RX1_B1_CTL__POR, - [SITAR_A_CDC_CONN_RX1_B2_CTL] = SITAR_A_CDC_CONN_RX1_B2_CTL__POR, - [SITAR_A_CDC_CONN_RX1_B3_CTL] = SITAR_A_CDC_CONN_RX1_B3_CTL__POR, - [SITAR_A_CDC_CONN_RX2_B1_CTL] = SITAR_A_CDC_CONN_RX2_B1_CTL__POR, - [SITAR_A_CDC_CONN_RX2_B2_CTL] = SITAR_A_CDC_CONN_RX2_B2_CTL__POR, - [SITAR_A_CDC_CONN_RX2_B3_CTL] = SITAR_A_CDC_CONN_RX2_B3_CTL__POR, - [SITAR_A_CDC_CONN_RX3_B1_CTL] = SITAR_A_CDC_CONN_RX3_B1_CTL__POR, - [SITAR_A_CDC_CONN_RX3_B2_CTL] = SITAR_A_CDC_CONN_RX3_B2_CTL__POR, - [SITAR_A_CDC_CONN_RX3_B3_CTL] = SITAR_A_CDC_CONN_RX3_B3_CTL__POR, - [SITAR_A_CDC_CONN_ANC_B1_CTL] = SITAR_A_CDC_CONN_ANC_B1_CTL__POR, - [SITAR_A_CDC_CONN_ANC_B2_CTL] = SITAR_A_CDC_CONN_ANC_B2_CTL__POR, - [SITAR_A_CDC_CONN_TX_B1_CTL] = SITAR_A_CDC_CONN_TX_B1_CTL__POR, - [SITAR_A_CDC_CONN_TX_B2_CTL] = SITAR_A_CDC_CONN_TX_B2_CTL__POR, - [SITAR_A_CDC_CONN_EQ1_B1_CTL] = SITAR_A_CDC_CONN_EQ1_B1_CTL__POR, - [SITAR_A_CDC_CONN_EQ1_B2_CTL] = SITAR_A_CDC_CONN_EQ1_B2_CTL__POR, - [SITAR_A_CDC_CONN_EQ1_B3_CTL] = SITAR_A_CDC_CONN_EQ1_B3_CTL__POR, - [SITAR_A_CDC_CONN_EQ1_B4_CTL] = SITAR_A_CDC_CONN_EQ1_B4_CTL__POR, - [SITAR_A_CDC_CONN_EQ2_B1_CTL] = SITAR_A_CDC_CONN_EQ2_B1_CTL__POR, - [SITAR_A_CDC_CONN_EQ2_B2_CTL] = SITAR_A_CDC_CONN_EQ2_B2_CTL__POR, - [SITAR_A_CDC_CONN_EQ2_B3_CTL] = SITAR_A_CDC_CONN_EQ2_B3_CTL__POR, - [SITAR_A_CDC_CONN_EQ2_B4_CTL] = SITAR_A_CDC_CONN_EQ2_B4_CTL__POR, - [SITAR_A_CDC_CONN_SRC1_B1_CTL] = SITAR_A_CDC_CONN_SRC1_B1_CTL__POR, - [SITAR_A_CDC_CONN_SRC1_B2_CTL] = SITAR_A_CDC_CONN_SRC1_B2_CTL__POR, - [SITAR_A_CDC_CONN_SRC2_B1_CTL] = SITAR_A_CDC_CONN_SRC2_B1_CTL__POR, - [SITAR_A_CDC_CONN_SRC2_B2_CTL] = SITAR_A_CDC_CONN_SRC2_B2_CTL__POR, - [SITAR_A_CDC_CONN_TX_SB_B1_CTL] = SITAR_A_CDC_CONN_TX_SB_B1_CTL__POR, - [SITAR_A_CDC_CONN_TX_SB_B2_CTL] = SITAR_A_CDC_CONN_TX_SB_B2_CTL__POR, - [SITAR_A_CDC_CONN_TX_SB_B3_CTL] = SITAR_A_CDC_CONN_TX_SB_B3_CTL__POR, - [SITAR_A_CDC_CONN_TX_SB_B4_CTL] = SITAR_A_CDC_CONN_TX_SB_B4_CTL__POR, - [SITAR_A_CDC_CONN_TX_SB_B5_CTL] = SITAR_A_CDC_CONN_TX_SB_B5_CTL__POR, - [SITAR_A_CDC_CONN_RX_SB_B1_CTL] = SITAR_A_CDC_CONN_RX_SB_B1_CTL__POR, - [SITAR_A_CDC_CONN_RX_SB_B2_CTL] = SITAR_A_CDC_CONN_RX_SB_B2_CTL__POR, - [SITAR_A_CDC_CONN_CLSG_CTL] = SITAR_A_CDC_CONN_CLSG_CTL__POR, - [SITAR_A_CDC_CONN_SPARE] = SITAR_A_CDC_CONN_SPARE__POR, - [SITAR_A_CDC_MBHC_EN_CTL] = SITAR_A_CDC_MBHC_EN_CTL__POR, - [SITAR_A_CDC_MBHC_FIR_B1_CFG] = SITAR_A_CDC_MBHC_FIR_B1_CFG__POR, - [SITAR_A_CDC_MBHC_FIR_B2_CFG] = SITAR_A_CDC_MBHC_FIR_B2_CFG__POR, - [SITAR_A_CDC_MBHC_TIMER_B1_CTL] = SITAR_A_CDC_MBHC_TIMER_B1_CTL__POR, - [SITAR_A_CDC_MBHC_TIMER_B2_CTL] = SITAR_A_CDC_MBHC_TIMER_B2_CTL__POR, - [SITAR_A_CDC_MBHC_TIMER_B3_CTL] = SITAR_A_CDC_MBHC_TIMER_B3_CTL__POR, - [SITAR_A_CDC_MBHC_TIMER_B4_CTL] = SITAR_A_CDC_MBHC_TIMER_B4_CTL__POR, - [SITAR_A_CDC_MBHC_TIMER_B5_CTL] = SITAR_A_CDC_MBHC_TIMER_B5_CTL__POR, - [SITAR_A_CDC_MBHC_TIMER_B6_CTL] = SITAR_A_CDC_MBHC_TIMER_B6_CTL__POR, - [SITAR_A_CDC_MBHC_B1_STATUS] = SITAR_A_CDC_MBHC_B1_STATUS__POR, - [SITAR_A_CDC_MBHC_B2_STATUS] = SITAR_A_CDC_MBHC_B2_STATUS__POR, - [SITAR_A_CDC_MBHC_B3_STATUS] = SITAR_A_CDC_MBHC_B3_STATUS__POR, - [SITAR_A_CDC_MBHC_B4_STATUS] = SITAR_A_CDC_MBHC_B4_STATUS__POR, - [SITAR_A_CDC_MBHC_B5_STATUS] = SITAR_A_CDC_MBHC_B5_STATUS__POR, - [SITAR_A_CDC_MBHC_B1_CTL] = SITAR_A_CDC_MBHC_B1_CTL__POR, - [SITAR_A_CDC_MBHC_B2_CTL] = SITAR_A_CDC_MBHC_B2_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B1_CTL] = SITAR_A_CDC_MBHC_VOLT_B1_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B2_CTL] = SITAR_A_CDC_MBHC_VOLT_B2_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B3_CTL] = SITAR_A_CDC_MBHC_VOLT_B3_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B4_CTL] = SITAR_A_CDC_MBHC_VOLT_B4_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B5_CTL] = SITAR_A_CDC_MBHC_VOLT_B5_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B6_CTL] = SITAR_A_CDC_MBHC_VOLT_B6_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B7_CTL] = SITAR_A_CDC_MBHC_VOLT_B7_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B8_CTL] = SITAR_A_CDC_MBHC_VOLT_B8_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B9_CTL] = SITAR_A_CDC_MBHC_VOLT_B9_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B10_CTL] = SITAR_A_CDC_MBHC_VOLT_B10_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B11_CTL] = SITAR_A_CDC_MBHC_VOLT_B11_CTL__POR, - [SITAR_A_CDC_MBHC_VOLT_B12_CTL] = SITAR_A_CDC_MBHC_VOLT_B12_CTL__POR, - [SITAR_A_CDC_MBHC_CLK_CTL] = SITAR_A_CDC_MBHC_CLK_CTL__POR, - [SITAR_A_CDC_MBHC_INT_CTL] = SITAR_A_CDC_MBHC_INT_CTL__POR, - [SITAR_A_CDC_MBHC_DEBUG_CTL] = SITAR_A_CDC_MBHC_DEBUG_CTL__POR, - [SITAR_A_CDC_MBHC_SPARE] = SITAR_A_CDC_MBHC_SPARE__POR, -}; - -const u8 sitar_reg_readable[SITAR_CACHE_SIZE] = { - [WCD9XXX_A_CHIP_CTL] = 1, - [WCD9XXX_A_CHIP_STATUS] = 1, - [WCD9XXX_A_CHIP_ID_BYTE_0] = 1, - [WCD9XXX_A_CHIP_ID_BYTE_1] = 1, - [WCD9XXX_A_CHIP_ID_BYTE_2] = 1, - [WCD9XXX_A_CHIP_ID_BYTE_3] = 1, - [WCD9XXX_A_CHIP_VERSION] = 1, - [WCD9XXX_A_SB_VERSION] = 1, - [WCD9XXX_A_SLAVE_ID_1] = 1, - [WCD9XXX_A_SLAVE_ID_2] = 1, - [WCD9XXX_A_SLAVE_ID_3] = 1, - [SITAR_A_PIN_CTL_OE0] = 1, - [SITAR_A_PIN_CTL_OE1] = 1, - [SITAR_A_PIN_CTL_DATA0] = 1, - [SITAR_A_PIN_CTL_DATA1] = 1, - [SITAR_A_HDRIVE_GENERIC] = 1, - [SITAR_A_HDRIVE_OVERRIDE] = 1, - [SITAR_A_ANA_CSR_WAIT_STATE] = 1, - [SITAR_A_PROCESS_MONITOR_CTL0] = 1, - [SITAR_A_PROCESS_MONITOR_CTL1] = 1, - [SITAR_A_PROCESS_MONITOR_CTL2] = 1, - [SITAR_A_PROCESS_MONITOR_CTL3] = 1, - [SITAR_A_QFUSE_CTL] = 1, - [SITAR_A_QFUSE_STATUS] = 1, - [SITAR_A_QFUSE_DATA_OUT0] = 1, - [SITAR_A_QFUSE_DATA_OUT1] = 1, - [SITAR_A_QFUSE_DATA_OUT2] = 1, - [SITAR_A_QFUSE_DATA_OUT3] = 1, - [SITAR_A_QFUSE_DATA_OUT4] = 1, - [SITAR_A_QFUSE_DATA_OUT5] = 1, - [SITAR_A_QFUSE_DATA_OUT6] = 1, - [SITAR_A_QFUSE_DATA_OUT7] = 1, - [SITAR_A_CDC_CTL] = 1, - [SITAR_A_LEAKAGE_CTL] = 1, - [SITAR_A_INTR_MODE] = 1, - [SITAR_A_INTR_MASK0] = 1, - [SITAR_A_INTR_MASK1] = 1, - [SITAR_A_INTR_MASK2] = 1, - [SITAR_A_INTR_STATUS0] = 1, - [SITAR_A_INTR_STATUS1] = 1, - [SITAR_A_INTR_STATUS2] = 1, - [SITAR_A_INTR_CLEAR0] = 1, - [SITAR_A_INTR_CLEAR1] = 1, - [SITAR_A_INTR_CLEAR2] = 1, - [SITAR_A_INTR_LEVEL0] = 1, - [SITAR_A_INTR_LEVEL1] = 1, - [SITAR_A_INTR_LEVEL2] = 1, - [SITAR_A_INTR_TEST0] = 1, - [SITAR_A_INTR_TEST1] = 1, - [SITAR_A_INTR_TEST2] = 1, - [SITAR_A_INTR_SET0] = 1, - [SITAR_A_INTR_SET1] = 1, - [SITAR_A_INTR_SET2] = 1, - [SITAR_A_CDC_TX_I2S_SCK_MODE] = 1, - [SITAR_A_CDC_TX_I2S_WS_MODE] = 1, - [SITAR_A_CDC_DMIC_DATA0_MODE] = 1, - [SITAR_A_CDC_DMIC_CLK0_MODE] = 1, - [SITAR_A_CDC_DMIC_DATA1_MODE] = 1, - [SITAR_A_CDC_DMIC_CLK1_MODE] = 1, - [SITAR_A_CDC_TX_I2S_SD0_MODE] = 1, - [SITAR_A_CDC_INTR_MODE] = 1, - [SITAR_A_CDC_RX_I2S_SD0_MODE] = 1, - [SITAR_A_CDC_RX_I2S_SD1_MODE] = 1, - [SITAR_A_BIAS_REF_CTL] = 1, - [SITAR_A_BIAS_CENTRAL_BG_CTL] = 1, - [SITAR_A_BIAS_PRECHRG_CTL] = 1, - [SITAR_A_BIAS_CURR_CTL_1] = 1, - [SITAR_A_BIAS_CURR_CTL_2] = 1, - [SITAR_A_BIAS_OSC_BG_CTL] = 1, - [SITAR_A_CLK_BUFF_EN1] = 1, - [SITAR_A_CLK_BUFF_EN2] = 1, - [SITAR_A_LDO_H_MODE_1] = 1, - [SITAR_A_LDO_H_MODE_2] = 1, - [SITAR_A_LDO_H_LOOP_CTL] = 1, - [SITAR_A_LDO_H_COMP_1] = 1, - [SITAR_A_LDO_H_COMP_2] = 1, - [SITAR_A_LDO_H_BIAS_1] = 1, - [SITAR_A_LDO_H_BIAS_2] = 1, - [SITAR_A_LDO_H_BIAS_3] = 1, - [SITAR_A_MICB_CFILT_1_CTL] = 1, - [SITAR_A_MICB_CFILT_1_VAL] = 1, - [SITAR_A_MICB_CFILT_1_PRECHRG] = 1, - [SITAR_A_MICB_1_CTL] = 1, - [SITAR_A_MICB_1_INT_RBIAS] = 1, - [SITAR_A_MICB_1_MBHC] = 1, - [SITAR_A_MICB_CFILT_2_CTL] = 1, - [SITAR_A_MICB_CFILT_2_VAL] = 1, - [SITAR_A_MICB_CFILT_2_PRECHRG] = 1, - [SITAR_A_MICB_2_CTL] = 1, - [SITAR_A_MICB_2_INT_RBIAS] = 1, - [SITAR_A_MICB_2_MBHC] = 1, - [SITAR_A_TX_COM_BIAS] = 1, - [SITAR_A_MBHC_SCALING_MUX_1] = 1, - [SITAR_A_MBHC_SCALING_MUX_2] = 1, - [SITAR_A_TX_SUP_SWITCH_CTRL_1] = 1, - [SITAR_A_TX_SUP_SWITCH_CTRL_2] = 1, - [SITAR_A_TX_1_2_EN] = 1, - [SITAR_A_TX_1_2_TEST_EN] = 1, - [SITAR_A_TX_1_2_ADC_CH1] = 1, - [SITAR_A_TX_1_2_ADC_CH2] = 1, - [SITAR_A_TX_1_2_ATEST_REFCTRL] = 1, - [SITAR_A_TX_1_2_TEST_CTL] = 1, - [SITAR_A_TX_1_2_TEST_BLOCK_EN] = 1, - [SITAR_A_TX_1_2_TXFE_CLKDIV] = 1, - [SITAR_A_TX_1_2_SAR_ERR_CH1] = 1, - [SITAR_A_TX_1_2_SAR_ERR_CH2] = 1, - [SITAR_A_TX_3_EN] = 1, - [SITAR_A_TX_3_TEST_EN] = 1, - [SITAR_A_TX_3_ADC] = 1, - [SITAR_A_TX_3_MBHC_ATEST_REFCTRL] = 1, - [SITAR_A_TX_3_TEST_CTL] = 1, - [SITAR_A_TX_3_TEST_BLOCK_EN] = 1, - [SITAR_A_TX_3_TXFE_CKDIV] = 1, - [SITAR_A_TX_3_SAR_ERR] = 1, - [SITAR_A_TX_4_MBHC_EN] = 1, - [SITAR_A_TX_4_MBHC_ADC] = 1, - [SITAR_A_TX_4_MBHC_TEST_CTL] = 1, - [SITAR_A_TX_4_MBHC_SAR_ERR] = 1, - [SITAR_A_TX_4_TXFE_CLKDIV] = 1, - [SITAR_A_AUX_COM_CTL] = 1, - [SITAR_A_AUX_COM_ATEST] = 1, - [SITAR_A_AUX_L_EN] = 1, - [SITAR_A_AUX_L_GAIN] = 1, - [SITAR_A_AUX_L_PA_CONN] = 1, - [SITAR_A_AUX_L_PA_CONN_INV] = 1, - [SITAR_A_AUX_R_EN] = 1, - [SITAR_A_AUX_R_GAIN] = 1, - [SITAR_A_AUX_R_PA_CONN] = 1, - [SITAR_A_AUX_R_PA_CONN_INV] = 1, - [SITAR_A_CP_EN] = 1, - [SITAR_A_CP_CLK] = 1, - [SITAR_A_CP_STATIC] = 1, - [SITAR_A_CP_DCC1] = 1, - [SITAR_A_CP_DCC3] = 1, - [SITAR_A_CP_ATEST] = 1, - [SITAR_A_CP_DTEST] = 1, - [SITAR_A_RX_COM_TIMER_DIV] = 1, - [SITAR_A_RX_COM_OCP_CTL] = 1, - [SITAR_A_RX_COM_OCP_COUNT] = 1, - [SITAR_A_RX_COM_DAC_CTL] = 1, - [SITAR_A_RX_COM_BIAS] = 1, - [SITAR_A_RX_HPH_BIAS_PA] = 1, - [SITAR_A_RX_HPH_BIAS_LDO] = 1, - [SITAR_A_RX_HPH_BIAS_CNP] = 1, - [SITAR_A_RX_HPH_BIAS_WG] = 1, - [SITAR_A_RX_HPH_OCP_CTL] = 1, - [SITAR_A_RX_HPH_CNP_EN] = 1, - [SITAR_A_RX_HPH_CNP_WG_CTL] = 1, - [SITAR_A_RX_HPH_CNP_WG_TIME] = 1, - [SITAR_A_RX_HPH_L_GAIN] = 1, - [SITAR_A_RX_HPH_L_TEST] = 1, - [SITAR_A_RX_HPH_L_PA_CTL] = 1, - [SITAR_A_RX_HPH_L_DAC_CTL] = 1, - [SITAR_A_RX_HPH_L_ATEST] = 1, - [SITAR_A_RX_HPH_L_STATUS] = 1, - [SITAR_A_RX_HPH_R_GAIN] = 1, - [SITAR_A_RX_HPH_R_TEST] = 1, - [SITAR_A_RX_HPH_R_PA_CTL] = 1, - [SITAR_A_RX_HPH_R_DAC_CTL] = 1, - [SITAR_A_RX_HPH_R_ATEST] = 1, - [SITAR_A_RX_HPH_R_STATUS] = 1, - [SITAR_A_RX_EAR_BIAS_PA] = 1, - [SITAR_A_RX_EAR_BIAS_CMBUFF] = 1, - [SITAR_A_RX_EAR_EN] = 1, - [SITAR_A_RX_EAR_GAIN] = 1, - [SITAR_A_RX_EAR_CMBUFF] = 1, - [SITAR_A_RX_EAR_ICTL] = 1, - [SITAR_A_RX_EAR_CCOMP] = 1, - [SITAR_A_RX_EAR_VCM] = 1, - [SITAR_A_RX_EAR_CNP] = 1, - [SITAR_A_RX_EAR_ATEST] = 1, - [SITAR_A_RX_EAR_STATUS] = 1, - [SITAR_A_RX_LINE_BIAS_PA] = 1, - [SITAR_A_RX_LINE_BIAS_LDO] = 1, - [SITAR_A_RX_LINE_BIAS_CNP1] = 1, - [SITAR_A_RX_LINE_COM] = 1, - [SITAR_A_RX_LINE_CNP_EN] = 1, - [SITAR_A_RX_LINE_CNP_WG_CTL] = 1, - [SITAR_A_RX_LINE_CNP_WG_TIME] = 1, - [SITAR_A_RX_LINE_1_GAIN] = 1, - [SITAR_A_RX_LINE_1_TEST] = 1, - [SITAR_A_RX_LINE_1_DAC_CTL] = 1, - [SITAR_A_RX_LINE_1_STATUS] = 1, - [SITAR_A_RX_LINE_2_GAIN] = 1, - [SITAR_A_RX_LINE_2_TEST] = 1, - [SITAR_A_RX_LINE_2_DAC_CTL] = 1, - [SITAR_A_RX_LINE_2_STATUS] = 1, - [SITAR_A_RX_LINE_BIAS_CNP2] = 1, - [SITAR_A_RX_LINE_OCP_CTL] = 1, - [SITAR_A_RX_LINE_1_PA_CTL] = 1, - [SITAR_A_RX_LINE_2_PA_CTL] = 1, - [SITAR_A_RX_LINE_CNP_DBG] = 1, - [SITAR_A_MBHC_HPH] = 1, - [SITAR_A_RC_OSC_FREQ] = 1, - [SITAR_A_RC_OSC_TEST] = 1, - [SITAR_A_RC_OSC_STATUS] = 1, - [SITAR_A_RC_OSC_TUNER] = 1, - [SITAR_A_CDC_ANC1_CTL] = 1, - [SITAR_A_CDC_ANC1_SHIFT] = 1, - [SITAR_A_CDC_ANC1_IIR_B1_CTL] = 1, - [SITAR_A_CDC_ANC1_IIR_B2_CTL] = 1, - [SITAR_A_CDC_ANC1_IIR_B3_CTL] = 1, - [SITAR_A_CDC_ANC1_IIR_B4_CTL] = 1, - [SITAR_A_CDC_ANC1_LPF_B1_CTL] = 1, - [SITAR_A_CDC_ANC1_LPF_B2_CTL] = 1, - [SITAR_A_CDC_ANC1_LPF_B3_CTL] = 1, - [SITAR_A_CDC_ANC1_SPARE] = 1, - [SITAR_A_CDC_ANC1_SMLPF_CTL] = 1, - [SITAR_A_CDC_ANC1_DCFLT_CTL] = 1, - [SITAR_A_CDC_ANC2_CTL] = 1, - [SITAR_A_CDC_ANC2_SHIFT] = 1, - [SITAR_A_CDC_ANC2_IIR_B1_CTL] = 1, - [SITAR_A_CDC_ANC2_IIR_B2_CTL] = 1, - [SITAR_A_CDC_ANC2_IIR_B3_CTL] = 1, - [SITAR_A_CDC_ANC2_IIR_B4_CTL] = 1, - [SITAR_A_CDC_ANC2_LPF_B1_CTL] = 1, - [SITAR_A_CDC_ANC2_LPF_B2_CTL] = 1, - [SITAR_A_CDC_ANC2_LPF_B3_CTL] = 1, - [SITAR_A_CDC_ANC2_SPARE] = 1, - [SITAR_A_CDC_ANC2_SMLPF_CTL] = 1, - [SITAR_A_CDC_ANC2_DCFLT_CTL] = 1, - [SITAR_A_CDC_TX1_VOL_CTL_TIMER] = 1, - [SITAR_A_CDC_TX1_VOL_CTL_GAIN] = 1, - [SITAR_A_CDC_TX1_VOL_CTL_CFG] = 1, - [SITAR_A_CDC_TX1_MUX_CTL] = 1, - [SITAR_A_CDC_TX1_CLK_FS_CTL] = 1, - [SITAR_A_CDC_TX1_DMIC_CTL] = 1, - [SITAR_A_CDC_TX2_VOL_CTL_TIMER] = 1, - [SITAR_A_CDC_TX2_VOL_CTL_GAIN] = 1, - [SITAR_A_CDC_TX2_VOL_CTL_CFG] = 1, - [SITAR_A_CDC_TX2_MUX_CTL] = 1, - [SITAR_A_CDC_TX2_CLK_FS_CTL] = 1, - [SITAR_A_CDC_TX2_DMIC_CTL] = 1, - [SITAR_A_CDC_TX3_VOL_CTL_TIMER] = 1, - [SITAR_A_CDC_TX3_VOL_CTL_GAIN] = 1, - [SITAR_A_CDC_TX3_VOL_CTL_CFG] = 1, - [SITAR_A_CDC_TX3_MUX_CTL] = 1, - [SITAR_A_CDC_TX3_CLK_FS_CTL] = 1, - [SITAR_A_CDC_TX3_DMIC_CTL] = 1, - [SITAR_A_CDC_TX4_VOL_CTL_TIMER] = 1, - [SITAR_A_CDC_TX4_VOL_CTL_GAIN] = 1, - [SITAR_A_CDC_TX4_VOL_CTL_CFG] = 1, - [SITAR_A_CDC_TX4_MUX_CTL] = 1, - [SITAR_A_CDC_TX4_CLK_FS_CTL] = 1, - [SITAR_A_CDC_TX4_DMIC_CTL] = 1, - [SITAR_A_CDC_TX5_VOL_CTL_TIMER] = 1, - [SITAR_A_CDC_TX5_VOL_CTL_GAIN] = 1, - [SITAR_A_CDC_TX5_VOL_CTL_CFG] = 1, - [SITAR_A_CDC_TX5_MUX_CTL] = 1, - [SITAR_A_CDC_TX5_CLK_FS_CTL] = 1, - [SITAR_A_CDC_TX5_DMIC_CTL] = 1, - [SITAR_A_CDC_SRC1_PDA_CFG] = 1, - [SITAR_A_CDC_SRC1_FS_CTL] = 1, - [SITAR_A_CDC_SRC2_PDA_CFG] = 1, - [SITAR_A_CDC_SRC2_FS_CTL] = 1, - [SITAR_A_CDC_RX1_B1_CTL] = 1, - [SITAR_A_CDC_RX1_B2_CTL] = 1, - [SITAR_A_CDC_RX1_B3_CTL] = 1, - [SITAR_A_CDC_RX1_B4_CTL] = 1, - [SITAR_A_CDC_RX1_B5_CTL] = 1, - [SITAR_A_CDC_RX1_B6_CTL] = 1, - [SITAR_A_CDC_RX1_VOL_CTL_B1_CTL] = 1, - [SITAR_A_CDC_RX1_VOL_CTL_B2_CTL] = 1, - [SITAR_A_CDC_RX2_B1_CTL] = 1, - [SITAR_A_CDC_RX2_B2_CTL] = 1, - [SITAR_A_CDC_RX2_B3_CTL] = 1, - [SITAR_A_CDC_RX2_B4_CTL] = 1, - [SITAR_A_CDC_RX2_B5_CTL] = 1, - [SITAR_A_CDC_RX2_B6_CTL] = 1, - [SITAR_A_CDC_RX2_VOL_CTL_B1_CTL] = 1, - [SITAR_A_CDC_RX2_VOL_CTL_B2_CTL] = 1, - [SITAR_A_CDC_RX3_B1_CTL] = 1, - [SITAR_A_CDC_RX3_B2_CTL] = 1, - [SITAR_A_CDC_RX3_B3_CTL] = 1, - [SITAR_A_CDC_RX3_B4_CTL] = 1, - [SITAR_A_CDC_RX3_B5_CTL] = 1, - [SITAR_A_CDC_RX3_B6_CTL] = 1, - [SITAR_A_CDC_RX3_VOL_CTL_B1_CTL] = 1, - [SITAR_A_CDC_RX3_VOL_CTL_B2_CTL] = 1, - [SITAR_A_CDC_CLK_ANC_RESET_CTL] = 1, - [SITAR_A_CDC_CLK_RX_RESET_CTL] = 1, - [SITAR_A_CDC_CLK_TX_RESET_B1_CTL] = 1, - [SITAR_A_CDC_CLK_TX_RESET_B2_CTL] = 1, - [SITAR_A_CDC_CLK_DMIC_CTL] = 1, - [SITAR_A_CDC_CLK_RX_I2S_CTL] = 1, - [SITAR_A_CDC_CLK_TX_I2S_CTL] = 1, - [SITAR_A_CDC_CLK_OTHR_RESET_CTL] = 1, - [SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL] = 1, - [SITAR_A_CDC_CLK_OTHR_CTL] = 1, - [SITAR_A_CDC_CLK_RDAC_CLK_EN_CTL] = 1, - [SITAR_A_CDC_CLK_ANC_CLK_EN_CTL] = 1, - [SITAR_A_CDC_CLK_RX_B1_CTL] = 1, - [SITAR_A_CDC_CLK_RX_B2_CTL] = 1, - [SITAR_A_CDC_CLK_MCLK_CTL] = 1, - [SITAR_A_CDC_CLK_PDM_CTL] = 1, - [SITAR_A_CDC_CLK_SD_CTL] = 1, - [SITAR_A_CDC_CLK_LP_CTL] = 1, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B1_CTL] = 1, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B2_CTL] = 1, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B3_CTL] = 1, - [SITAR_A_CDC_CLSG_FREQ_THRESH_B4_CTL] = 1, - [SITAR_A_CDC_CLSG_GAIN_THRESH_CTL] = 1, - [SITAR_A_CDC_CLSG_TIMER_B1_CFG] = 1, - [SITAR_A_CDC_CLSG_TIMER_B2_CFG] = 1, - [SITAR_A_CDC_CLSG_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B1_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B2_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B3_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B4_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B5_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B6_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B7_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_B8_CTL] = 1, - [SITAR_A_CDC_IIR1_CTL] = 1, - [SITAR_A_CDC_IIR1_GAIN_TIMER_CTL] = 1, - [SITAR_A_CDC_IIR1_COEF_B1_CTL] = 1, - [SITAR_A_CDC_IIR1_COEF_B2_CTL] = 1, - [SITAR_A_CDC_IIR1_COEF_B3_CTL] = 1, - [SITAR_A_CDC_IIR1_COEF_B4_CTL] = 1, - [SITAR_A_CDC_IIR1_COEF_B5_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B1_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B2_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B3_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B4_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B5_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B6_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B7_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_B8_CTL] = 1, - [SITAR_A_CDC_IIR2_CTL] = 1, - [SITAR_A_CDC_IIR2_GAIN_TIMER_CTL] = 1, - [SITAR_A_CDC_IIR2_COEF_B1_CTL] = 1, - [SITAR_A_CDC_IIR2_COEF_B2_CTL] = 1, - [SITAR_A_CDC_IIR2_COEF_B3_CTL] = 1, - [SITAR_A_CDC_IIR2_COEF_B4_CTL] = 1, - [SITAR_A_CDC_IIR2_COEF_B5_CTL] = 1, - [SITAR_A_CDC_TOP_GAIN_UPDATE] = 1, - [SITAR_A_CDC_TOP_RDAC_DOUT_CTL] = 1, - [SITAR_A_CDC_DEBUG_B1_CTL] = 1, - [SITAR_A_CDC_DEBUG_B2_CTL] = 1, - [SITAR_A_CDC_DEBUG_B3_CTL] = 1, - [SITAR_A_CDC_DEBUG_B4_CTL] = 1, - [SITAR_A_CDC_DEBUG_B5_CTL] = 1, - [SITAR_A_CDC_DEBUG_B6_CTL] = 1, - [SITAR_A_CDC_DEBUG_B7_CTL] = 1, - [SITAR_A_CDC_COMP1_B1_CTL] = 1, - [SITAR_A_CDC_COMP1_B2_CTL] = 1, - [SITAR_A_CDC_COMP1_B3_CTL] = 1, - [SITAR_A_CDC_COMP1_B4_CTL] = 1, - [SITAR_A_CDC_COMP1_B5_CTL] = 1, - [SITAR_A_CDC_COMP1_B6_CTL] = 1, - [SITAR_A_CDC_COMP1_SHUT_DOWN_STATUS] = 1, - [SITAR_A_CDC_COMP1_FS_CFG] = 1, - [SITAR_A_CDC_COMP2_B1_CTL] = 1, - [SITAR_A_CDC_COMP2_B2_CTL] = 1, - [SITAR_A_CDC_COMP2_B3_CTL] = 1, - [SITAR_A_CDC_COMP2_B4_CTL] = 1, - [SITAR_A_CDC_COMP2_B5_CTL] = 1, - [SITAR_A_CDC_COMP2_B6_CTL] = 1, - [SITAR_A_CDC_COMP2_SHUT_DOWN_STATUS] = 1, - [SITAR_A_CDC_COMP2_FS_CFG] = 1, - [SITAR_A_CDC_CONN_RX1_B1_CTL] = 1, - [SITAR_A_CDC_CONN_RX1_B2_CTL] = 1, - [SITAR_A_CDC_CONN_RX1_B3_CTL] = 1, - [SITAR_A_CDC_CONN_RX2_B1_CTL] = 1, - [SITAR_A_CDC_CONN_RX2_B2_CTL] = 1, - [SITAR_A_CDC_CONN_RX2_B3_CTL] = 1, - [SITAR_A_CDC_CONN_RX3_B1_CTL] = 1, - [SITAR_A_CDC_CONN_RX3_B2_CTL] = 1, - [SITAR_A_CDC_CONN_RX3_B3_CTL] = 1, - [SITAR_A_CDC_CONN_ANC_B1_CTL] = 1, - [SITAR_A_CDC_CONN_ANC_B2_CTL] = 1, - [SITAR_A_CDC_CONN_TX_B1_CTL] = 1, - [SITAR_A_CDC_CONN_TX_B2_CTL] = 1, - [SITAR_A_CDC_CONN_EQ1_B1_CTL] = 1, - [SITAR_A_CDC_CONN_EQ1_B2_CTL] = 1, - [SITAR_A_CDC_CONN_EQ1_B3_CTL] = 1, - [SITAR_A_CDC_CONN_EQ1_B4_CTL] = 1, - [SITAR_A_CDC_CONN_EQ2_B1_CTL] = 1, - [SITAR_A_CDC_CONN_EQ2_B2_CTL] = 1, - [SITAR_A_CDC_CONN_EQ2_B3_CTL] = 1, - [SITAR_A_CDC_CONN_EQ2_B4_CTL] = 1, - [SITAR_A_CDC_CONN_SRC1_B1_CTL] = 1, - [SITAR_A_CDC_CONN_SRC1_B2_CTL] = 1, - [SITAR_A_CDC_CONN_SRC2_B1_CTL] = 1, - [SITAR_A_CDC_CONN_SRC2_B2_CTL] = 1, - [SITAR_A_CDC_CONN_TX_SB_B1_CTL] = 1, - [SITAR_A_CDC_CONN_TX_SB_B2_CTL] = 1, - [SITAR_A_CDC_CONN_TX_SB_B3_CTL] = 1, - [SITAR_A_CDC_CONN_TX_SB_B4_CTL] = 1, - [SITAR_A_CDC_CONN_TX_SB_B5_CTL] = 1, - [SITAR_A_CDC_CONN_RX_SB_B1_CTL] = 1, - [SITAR_A_CDC_CONN_RX_SB_B2_CTL] = 1, - [SITAR_A_CDC_CONN_CLSG_CTL] = 1, - [SITAR_A_CDC_CONN_SPARE] = 1, - [SITAR_A_CDC_MBHC_EN_CTL] = 1, - [SITAR_A_CDC_MBHC_FIR_B1_CFG] = 1, - [SITAR_A_CDC_MBHC_FIR_B2_CFG] = 1, - [SITAR_A_CDC_MBHC_TIMER_B1_CTL] = 1, - [SITAR_A_CDC_MBHC_TIMER_B2_CTL] = 1, - [SITAR_A_CDC_MBHC_TIMER_B3_CTL] = 1, - [SITAR_A_CDC_MBHC_TIMER_B4_CTL] = 1, - [SITAR_A_CDC_MBHC_TIMER_B5_CTL] = 1, - [SITAR_A_CDC_MBHC_TIMER_B6_CTL] = 1, - [SITAR_A_CDC_MBHC_B1_STATUS] = 1, - [SITAR_A_CDC_MBHC_B2_STATUS] = 1, - [SITAR_A_CDC_MBHC_B3_STATUS] = 1, - [SITAR_A_CDC_MBHC_B4_STATUS] = 1, - [SITAR_A_CDC_MBHC_B5_STATUS] = 1, - [SITAR_A_CDC_MBHC_B1_CTL] = 1, - [SITAR_A_CDC_MBHC_B2_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B1_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B2_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B3_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B4_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B5_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B6_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B7_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B8_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B9_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B10_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B11_CTL] = 1, - [SITAR_A_CDC_MBHC_VOLT_B12_CTL] = 1, - [SITAR_A_CDC_MBHC_CLK_CTL] = 1, - [SITAR_A_CDC_MBHC_INT_CTL] = 1, - [SITAR_A_CDC_MBHC_DEBUG_CTL] = 1, - [SITAR_A_CDC_MBHC_SPARE] = 1, -}; diff --git a/sound/soc/codecs/wcd9304.c b/sound/soc/codecs/wcd9304.c deleted file mode 100644 index f805b9d4c462ea9b1ac89c18a0e709cf6161dfba..0000000000000000000000000000000000000000 --- a/sound/soc/codecs/wcd9304.c +++ /dev/null @@ -1,6245 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "wcd9304.h" - -#define WCD9304_RATES (SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|\ - SNDRV_PCM_RATE_32000|SNDRV_PCM_RATE_48000) -#define ADC_DMIC_SEL_ADC 0 -#define ADC_DMIC_SEL_DMIC 1 - -#define NUM_AMIC 3 -#define NUM_DECIMATORS 4 -#define NUM_INTERPOLATORS 3 -#define BITS_PER_REG 8 -#define SITAR_RX_PORT_START_NUMBER 10 - -enum { - AIF1_PB = 0, - AIF1_CAP, - NUM_CODEC_DAIS, -}; - -struct wcd9xxx_ch sitar_rx_chs[SITAR_RX_MAX] = { - WCD9XXX_CH(SITAR_RX_PORT_START_NUMBER, 0), - WCD9XXX_CH(SITAR_RX_PORT_START_NUMBER + 1, 1), - WCD9XXX_CH(SITAR_RX_PORT_START_NUMBER + 2, 2), - WCD9XXX_CH(SITAR_RX_PORT_START_NUMBER + 3, 3), - WCD9XXX_CH(SITAR_RX_PORT_START_NUMBER + 4, 4) -}; - -struct wcd9xxx_ch sitar_tx_chs[SITAR_TX_MAX] = { - WCD9XXX_CH(0, 0), - WCD9XXX_CH(1, 1), - WCD9XXX_CH(2, 2), - WCD9XXX_CH(3, 3), - WCD9XXX_CH(4, 4), -}; - -#define SITAR_CFILT_FAST_MODE 0x00 -#define SITAR_CFILT_SLOW_MODE 0x40 -#define MBHC_FW_READ_ATTEMPTS 15 -#define MBHC_FW_READ_TIMEOUT 2000000 - -#define SLIM_CLOSE_TIMEOUT 1000 - -#define SITAR_JACK_MASK (SND_JACK_HEADSET | SND_JACK_OC_HPHL | SND_JACK_OC_HPHR) - -#define SITAR_I2S_MASTER_MODE_MASK 0x08 - -#define SITAR_OCP_ATTEMPT 1 - -#define COMP_DIGITAL_DB_GAIN_APPLY(a, b) \ - (((a) <= 0) ? ((a) - b) : (a)) -/* The wait time value comes from codec HW specification */ -#define COMP_BRINGUP_WAIT_TIME 3000 - -#define SITAR_MCLK_RATE_12288KHZ 12288000 -#define SITAR_MCLK_RATE_9600KHZ 9600000 - -#define SITAR_FAKE_INS_THRESHOLD_MS 2500 -#define SITAR_FAKE_REMOVAL_MIN_PERIOD_MS 50 -#define SITAR_MBHC_BUTTON_MIN 0x8000 -#define SITAR_GPIO_IRQ_DEBOUNCE_TIME_US 5000 - -#define SITAR_ACQUIRE_LOCK(x) do { mutex_lock(&x); } while (0) -#define SITAR_RELEASE_LOCK(x) do { mutex_unlock(&x); } while (0) - -#define MBHC_NUM_DCE_PLUG_DETECT 3 -#define SITAR_MBHC_FAKE_INSERT_LOW 10 -#define SITAR_MBHC_FAKE_INSERT_HIGH 80 -#define SITAR_MBHC_FAKE_INSERT_VOLT_DELTA_MV 500 -#define SITAR_HS_DETECT_PLUG_TIME_MS (5 * 1000) -#define SITAR_HS_DETECT_PLUG_INERVAL_MS 100 -#define NUM_ATTEMPTS_TO_REPORT 5 -#define SITAR_MBHC_STATUS_REL_DETECTION 0x0C -#define SITAR_MBHC_GPIO_REL_DEBOUNCE_TIME_MS 200 - -#define CUT_OF_FREQ_MASK 0x30 -#define CF_MIN_3DB_4HZ 0x0 -#define CF_MIN_3DB_75HZ 0x01 -#define CF_MIN_3DB_150HZ 0x02 - - -static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); -static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1); -static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1); -static struct snd_soc_dai_driver sitar_dai[]; -static int sitar_codec_enable_slimtx(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event); -static int sitar_codec_enable_slimrx(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event); - -enum sitar_bandgap_type { - SITAR_BANDGAP_OFF = 0, - SITAR_BANDGAP_AUDIO_MODE, - SITAR_BANDGAP_MBHC_MODE, -}; - -struct mbhc_micbias_regs { - u16 cfilt_val; - u16 cfilt_ctl; - u16 mbhc_reg; - u16 int_rbias; - u16 ctl_reg; - u8 cfilt_sel; -}; - -/* Codec supports 2 IIR filters */ -enum { - IIR1 = 0, - IIR2, - IIR_MAX, -}; -/* Codec supports 5 bands */ -enum { - BAND1 = 0, - BAND2, - BAND3, - BAND4, - BAND5, - BAND_MAX, -}; - -enum { - COMPANDER_1 = 0, - COMPANDER_2, - COMPANDER_MAX, -}; - -enum { - COMPANDER_FS_8KHZ = 0, - COMPANDER_FS_16KHZ, - COMPANDER_FS_32KHZ, - COMPANDER_FS_48KHZ, - COMPANDER_FS_96KHZ, - COMPANDER_FS_192KHZ, - COMPANDER_FS_MAX, -}; - -/* Flags to track of PA and DAC state. - * PA and DAC should be tracked separately as AUXPGA loopback requires - * only PA to be turned on without DAC being on. */ -enum sitar_priv_ack_flags { - SITAR_HPHL_PA_OFF_ACK = 0, - SITAR_HPHR_PA_OFF_ACK, - SITAR_HPHL_DAC_OFF_ACK, - SITAR_HPHR_DAC_OFF_ACK -}; - -struct comp_sample_dependent_params { - u32 peak_det_timeout; - u32 rms_meter_div_fact; - u32 rms_meter_resamp_fact; -}; - -struct comp_dgtl_gain_offset { - u8 whole_db_gain; - u8 half_db_gain; -}; - -static const struct comp_dgtl_gain_offset comp_dgtl_gain[] = { - {0, 0}, - {1, 1}, - {3, 0}, - {4, 1}, - {6, 0}, - {7, 1}, - {9, 0}, - {10, 1}, - {12, 0}, - {13, 1}, - {15, 0}, - {16, 1}, - {18, 0}, -}; - -/* Data used by MBHC */ -struct mbhc_internal_cal_data { - u16 dce_z; - u16 dce_mb; - u16 sta_z; - u16 sta_mb; - u32 t_sta_dce; - u32 t_dce; - u32 t_sta; - u32 micb_mv; - u16 v_ins_hu; - u16 v_ins_h; - u16 v_b1_hu; - u16 v_b1_h; - u16 v_b1_huc; - u16 v_brh; - u16 v_brl; - u16 v_no_mic; - u8 npoll; - u8 nbounce_wait; -}; - -enum sitar_mbhc_plug_type { - PLUG_TYPE_INVALID = -1, - PLUG_TYPE_NONE, - PLUG_TYPE_HEADSET, - PLUG_TYPE_HEADPHONE, - PLUG_TYPE_HIGH_HPH, -}; - -enum sitar_mbhc_state { - MBHC_STATE_NONE = -1, - MBHC_STATE_POTENTIAL, - MBHC_STATE_POTENTIAL_RECOVERY, - MBHC_STATE_RELEASE, -}; - -static const u32 vport_check_table[NUM_CODEC_DAIS] = { - 0, /* AIF1_PB */ - 0, /* AIF1_CAP */ -}; - -struct hpf_work { - struct sitar_priv *sitar; - u32 decimator; - u8 tx_hpf_cut_of_freq; - struct delayed_work dwork; -}; - -static struct hpf_work tx_hpf_work[NUM_DECIMATORS]; - -struct sitar_priv { - struct snd_soc_codec *codec; - u32 mclk_freq; - u32 adc_count; - u32 cfilt1_cnt; - u32 cfilt2_cnt; - u32 cfilt3_cnt; - u32 rx_bias_count; - enum sitar_bandgap_type bandgap_type; - bool mclk_enabled; - bool clock_active; - bool config_mode_active; - bool mbhc_polling_active; - unsigned long mbhc_fake_ins_start; - int buttons_pressed; - - enum sitar_micbias_num micbias; - /* void* calibration contains: - * struct sitar_mbhc_general_cfg generic; - * struct sitar_mbhc_plug_detect_cfg plug_det; - * struct sitar_mbhc_plug_type_cfg plug_type; - * struct sitar_mbhc_btn_detect_cfg btn_det; - * struct sitar_mbhc_imped_detect_cfg imped_det; - * Note: various size depends on btn_det->num_btn - */ - void *calibration; - struct mbhc_internal_cal_data mbhc_data; - - struct wcd9xxx_pdata *pdata; - u32 anc_slot; - - bool no_mic_headset_override; - - struct mbhc_micbias_regs mbhc_bias_regs; - u8 cfilt_k_value; - bool mbhc_micbias_switched; - - /* track PA/DAC state */ - unsigned long hph_pa_dac_state; - - /*track sitar interface type*/ - u8 intf_type; - - u32 hph_status; /* track headhpone status */ - /* define separate work for left and right headphone OCP to avoid - * additional checking on which OCP event to report so no locking - * to ensure synchronization is required - */ - struct work_struct hphlocp_work; /* reporting left hph ocp off */ - struct work_struct hphrocp_work; /* reporting right hph ocp off */ - - u8 hphlocp_cnt; /* headphone left ocp retry */ - u8 hphrocp_cnt; /* headphone right ocp retry */ - - /* Callback function to enable MCLK */ - int (*mclk_cb) (struct snd_soc_codec*, int); - - /* Work to perform MBHC Firmware Read */ - struct delayed_work mbhc_firmware_dwork; - const struct firmware *mbhc_fw; - - /* num of slim ports required */ - struct wcd9xxx_codec_dai_data dai[NUM_CODEC_DAIS]; - - /*compander*/ - int comp_enabled[COMPANDER_MAX]; - u32 comp_fs[COMPANDER_MAX]; - u8 comp_gain_offset[NUM_INTERPOLATORS]; - - /* Currently, only used for mbhc purpose, to protect - * concurrent execution of mbhc threaded irq handlers and - * kill race between DAPM and MBHC.But can serve as a - * general lock to protect codec resource - */ - struct mutex codec_resource_lock; - - struct sitar_mbhc_config mbhc_cfg; - bool in_gpio_handler; - u8 current_plug; - bool lpi_enabled; - enum sitar_mbhc_state mbhc_state; - struct work_struct hs_correct_plug_work; - bool hs_detect_work_stop; - struct delayed_work mbhc_btn_dwork; - unsigned long mbhc_last_resume; /* in jiffies */ -}; - -#ifdef CONFIG_DEBUG_FS -struct sitar_priv *debug_sitar_priv; -#endif - -static const int comp_rx_path[] = { - COMPANDER_2, - COMPANDER_1, - COMPANDER_1, - COMPANDER_MAX, -}; - -static const struct comp_sample_dependent_params - comp_samp_params[COMPANDER_FS_MAX] = { - { - .peak_det_timeout = 0x6, - .rms_meter_div_fact = 0x9 << 4, - .rms_meter_resamp_fact = 0x06, - }, - { - .peak_det_timeout = 0x7, - .rms_meter_div_fact = 0xA << 4, - .rms_meter_resamp_fact = 0x0C, - }, - { - .peak_det_timeout = 0x8, - .rms_meter_div_fact = 0xB << 4, - .rms_meter_resamp_fact = 0x30, - }, - { - .peak_det_timeout = 0x9, - .rms_meter_div_fact = 0xB << 4, - .rms_meter_resamp_fact = 0x28, - }, - { - .peak_det_timeout = 0xA, - .rms_meter_div_fact = 0xC << 4, - .rms_meter_resamp_fact = 0x50, - }, - { - .peak_det_timeout = 0xB, - .rms_meter_div_fact = 0xC << 4, - .rms_meter_resamp_fact = 0x50, - }, -}; - -static int sitar_get_anc_slot(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - ucontrol->value.integer.value[0] = sitar->anc_slot; - return 0; -} - -static int sitar_put_anc_slot(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - sitar->anc_slot = ucontrol->value.integer.value[0]; - return 0; -} - -static int sitar_pa_gain_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - u8 ear_pa_gain; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - ear_pa_gain = snd_soc_read(codec, SITAR_A_RX_EAR_GAIN); - - ear_pa_gain &= 0xE0; - - if (ear_pa_gain == 0x00) { - ucontrol->value.integer.value[0] = 0; - } else if (ear_pa_gain == 0x80) { - ucontrol->value.integer.value[0] = 1; - } else if (ear_pa_gain == 0xA0) { - ucontrol->value.integer.value[0] = 2; - } else if (ear_pa_gain == 0xE0) { - ucontrol->value.integer.value[0] = 3; - } else { - pr_err("%s: ERROR: Unsupported Ear Gain = 0x%x\n", - __func__, ear_pa_gain); - return -EINVAL; - } - - pr_debug("%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain); - - return 0; -} - -static int sitar_pa_gain_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - u8 ear_pa_gain; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s: ucontrol->value.integer.value[0] = %ld\n", __func__, - ucontrol->value.integer.value[0]); - - switch (ucontrol->value.integer.value[0]) { - case 0: - ear_pa_gain = 0x00; - break; - case 1: - ear_pa_gain = 0x80; - break; - case 2: - ear_pa_gain = 0xA0; - break; - case 3: - ear_pa_gain = 0xE0; - break; - default: - return -EINVAL; - } - - snd_soc_update_bits(codec, SITAR_A_RX_EAR_GAIN, 0xE0, ear_pa_gain); - return 0; -} - -static int sitar_get_iir_enable_audio_mixer( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - int iir_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int band_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - - ucontrol->value.integer.value[0] = - snd_soc_read(codec, (SITAR_A_CDC_IIR1_CTL + 16 * iir_idx)) & - (1 << band_idx); - - pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, - iir_idx, band_idx, - (uint32_t)ucontrol->value.integer.value[0]); - return 0; -} - -static int sitar_put_iir_enable_audio_mixer( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - int iir_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int band_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - int value = ucontrol->value.integer.value[0]; - - /* Mask first 5 bits, 6-8 are reserved */ - snd_soc_update_bits(codec, (SITAR_A_CDC_IIR1_CTL + 16 * iir_idx), - (1 << band_idx), (value << band_idx)); - - pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, - iir_idx, band_idx, value); - return 0; -} -static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, - int iir_idx, int band_idx, - int coeff_idx) -{ - /* Address does not automatically update if reading */ - snd_soc_write(codec, - (SITAR_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx), - (band_idx * BAND_MAX + coeff_idx) & 0x1F); - - /* Mask bits top 2 bits since they are reserved */ - return ((snd_soc_read(codec, - (SITAR_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx)) << 24) | - (snd_soc_read(codec, - (SITAR_A_CDC_IIR1_COEF_B3_CTL + 16 * iir_idx)) << 16) | - (snd_soc_read(codec, - (SITAR_A_CDC_IIR1_COEF_B4_CTL + 16 * iir_idx)) << 8) | - (snd_soc_read(codec, - (SITAR_A_CDC_IIR1_COEF_B5_CTL + 16 * iir_idx)))) & - 0x3FFFFFFF; -} - -static int sitar_get_iir_band_audio_mixer( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - int iir_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int band_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - - ucontrol->value.integer.value[0] = - get_iir_band_coeff(codec, iir_idx, band_idx, 0); - ucontrol->value.integer.value[1] = - get_iir_band_coeff(codec, iir_idx, band_idx, 1); - ucontrol->value.integer.value[2] = - get_iir_band_coeff(codec, iir_idx, band_idx, 2); - ucontrol->value.integer.value[3] = - get_iir_band_coeff(codec, iir_idx, band_idx, 3); - ucontrol->value.integer.value[4] = - get_iir_band_coeff(codec, iir_idx, band_idx, 4); - - pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" - "%s: IIR #%d band #%d b1 = 0x%x\n" - "%s: IIR #%d band #%d b2 = 0x%x\n" - "%s: IIR #%d band #%d a1 = 0x%x\n" - "%s: IIR #%d band #%d a2 = 0x%x\n", - __func__, iir_idx, band_idx, - (uint32_t)ucontrol->value.integer.value[0], - __func__, iir_idx, band_idx, - (uint32_t)ucontrol->value.integer.value[1], - __func__, iir_idx, band_idx, - (uint32_t)ucontrol->value.integer.value[2], - __func__, iir_idx, band_idx, - (uint32_t)ucontrol->value.integer.value[3], - __func__, iir_idx, band_idx, - (uint32_t)ucontrol->value.integer.value[4]); - return 0; -} - -static void set_iir_band_coeff(struct snd_soc_codec *codec, - int iir_idx, int band_idx, - int coeff_idx, uint32_t value) -{ - /* Mask top 3 bits, 6-8 are reserved */ - /* Update address manually each time */ - snd_soc_write(codec, - (SITAR_A_CDC_IIR1_COEF_B1_CTL + 16 * iir_idx), - (band_idx * BAND_MAX + coeff_idx) & 0x1F); - - /* Mask top 2 bits, 7-8 are reserved */ - snd_soc_write(codec, - (SITAR_A_CDC_IIR1_COEF_B2_CTL + 16 * iir_idx), - (value >> 24) & 0x3F); - - /* Isolate 8bits at a time */ - snd_soc_write(codec, - (SITAR_A_CDC_IIR1_COEF_B3_CTL + 16 * iir_idx), - (value >> 16) & 0xFF); - - snd_soc_write(codec, - (SITAR_A_CDC_IIR1_COEF_B4_CTL + 16 * iir_idx), - (value >> 8) & 0xFF); - - snd_soc_write(codec, - (SITAR_A_CDC_IIR1_COEF_B5_CTL + 16 * iir_idx), - value & 0xFF); -} - -static int sitar_put_iir_band_audio_mixer( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - int iir_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int band_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - - set_iir_band_coeff(codec, iir_idx, band_idx, 0, - ucontrol->value.integer.value[0]); - set_iir_band_coeff(codec, iir_idx, band_idx, 1, - ucontrol->value.integer.value[1]); - set_iir_band_coeff(codec, iir_idx, band_idx, 2, - ucontrol->value.integer.value[2]); - set_iir_band_coeff(codec, iir_idx, band_idx, 3, - ucontrol->value.integer.value[3]); - set_iir_band_coeff(codec, iir_idx, band_idx, 4, - ucontrol->value.integer.value[4]); - - pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" - "%s: IIR #%d band #%d b1 = 0x%x\n" - "%s: IIR #%d band #%d b2 = 0x%x\n" - "%s: IIR #%d band #%d a1 = 0x%x\n" - "%s: IIR #%d band #%d a2 = 0x%x\n", - __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 0), - __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 1), - __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 2), - __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 3), - __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 4)); - return 0; -} - -static int sitar_compander_gain_offset( - struct snd_soc_codec *codec, u32 enable, - unsigned int pa_reg, unsigned int vol_reg, - int mask, int event, - struct comp_dgtl_gain_offset *gain_offset, - int index) -{ - unsigned int pa_gain = snd_soc_read(codec, pa_reg); - unsigned int digital_vol = snd_soc_read(codec, vol_reg); - int pa_mode = pa_gain & mask; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - pr_debug("%s: pa_gain(0x%x=0x%x)digital_vol(0x%x=0x%x)event(0x%x) index(%d)\n", - __func__, pa_reg, pa_gain, vol_reg, digital_vol, event, index); - if (((pa_gain & 0xF) + 1) > ARRAY_SIZE(comp_dgtl_gain) || - (index >= ARRAY_SIZE(sitar->comp_gain_offset))) { - pr_err("%s: Out of array boundary\n", __func__); - return -EINVAL; - } - - if (SND_SOC_DAPM_EVENT_ON(event) && (enable != 0)) { - gain_offset->whole_db_gain = COMP_DIGITAL_DB_GAIN_APPLY( - (digital_vol - comp_dgtl_gain[pa_gain & 0xF].whole_db_gain), - comp_dgtl_gain[pa_gain & 0xF].half_db_gain); - pr_debug("%s: listed whole_db_gain:0x%x, adjusted whole_db_gain:0x%x\n", - __func__, comp_dgtl_gain[pa_gain & 0xF].whole_db_gain, - gain_offset->whole_db_gain); - gain_offset->half_db_gain = - comp_dgtl_gain[pa_gain & 0xF].half_db_gain; - sitar->comp_gain_offset[index] = digital_vol - - gain_offset->whole_db_gain ; - } - if (SND_SOC_DAPM_EVENT_OFF(event) && (pa_mode == 0)) { - gain_offset->whole_db_gain = digital_vol + - sitar->comp_gain_offset[index]; - pr_debug("%s: listed whole_db_gain:0x%x, adjusted whole_db_gain:0x%x\n", - __func__, comp_dgtl_gain[pa_gain & 0xF].whole_db_gain, - gain_offset->whole_db_gain); - gain_offset->half_db_gain = 0; - } - - pr_debug("%s: half_db_gain(%d)whole_db_gain(0x%x)comp_gain_offset[%d](%d)\n", - __func__, gain_offset->half_db_gain, - gain_offset->whole_db_gain, index, - sitar->comp_gain_offset[index]); - return 0; -} - -static int sitar_config_gain_compander( - struct snd_soc_codec *codec, - u32 compander, u32 enable, int event) -{ - int value = 0; - int mask = 1 << 4; - struct comp_dgtl_gain_offset gain_offset = {0, 0}; - if (compander >= COMPANDER_MAX) { - pr_err("%s: Error, invalid compander channel\n", __func__); - return -EINVAL; - } - - if ((enable == 0) || SND_SOC_DAPM_EVENT_OFF(event)) - value = 1 << 4; - - if (compander == COMPANDER_1) { - sitar_compander_gain_offset(codec, enable, - SITAR_A_RX_HPH_L_GAIN, - SITAR_A_CDC_RX2_VOL_CTL_B2_CTL, - mask, event, &gain_offset, 1); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_L_GAIN, mask, value); - snd_soc_update_bits(codec, SITAR_A_CDC_RX2_VOL_CTL_B2_CTL, - 0xFF, gain_offset.whole_db_gain); - snd_soc_update_bits(codec, SITAR_A_CDC_RX2_B6_CTL, - 0x02, gain_offset.half_db_gain); - sitar_compander_gain_offset(codec, enable, - SITAR_A_RX_HPH_R_GAIN, - SITAR_A_CDC_RX3_VOL_CTL_B2_CTL, - mask, event, &gain_offset, 2); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_R_GAIN, mask, value); - snd_soc_update_bits(codec, SITAR_A_CDC_RX3_VOL_CTL_B2_CTL, - 0xFF, gain_offset.whole_db_gain); - snd_soc_update_bits(codec, SITAR_A_CDC_RX3_B6_CTL, - 0x02, gain_offset.half_db_gain); - } else if (compander == COMPANDER_2) { - sitar_compander_gain_offset(codec, enable, - SITAR_A_RX_LINE_1_GAIN, - SITAR_A_CDC_RX1_VOL_CTL_B2_CTL, - mask, event, &gain_offset, 0); - snd_soc_update_bits(codec, SITAR_A_RX_LINE_1_GAIN, mask, value); - snd_soc_update_bits(codec, SITAR_A_RX_LINE_2_GAIN, mask, value); - snd_soc_update_bits(codec, SITAR_A_CDC_RX1_VOL_CTL_B2_CTL, - 0xFF, gain_offset.whole_db_gain); - snd_soc_update_bits(codec, SITAR_A_CDC_RX1_B6_CTL, - 0x02, gain_offset.half_db_gain); - } - return 0; -} - -static int sitar_get_compander(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - int comp = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - ucontrol->value.integer.value[0] = sitar->comp_enabled[comp]; - - return 0; -} - -static int sitar_set_compander(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - int comp = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - int value = ucontrol->value.integer.value[0]; - - pr_debug("%s: compander #%d enable %d\n", - __func__, comp + 1, value); - if (value == sitar->comp_enabled[comp]) { - pr_debug("%s: compander #%d enable %d no change\n", - __func__, comp + 1, value); - return 0; - } - sitar->comp_enabled[comp] = value; - return 0; -} - -static int sitar_config_compander(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, - int event) -{ - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u32 rate = sitar->comp_fs[w->shift]; - u32 value; - - pr_debug("%s: compander #%d enable %d event %d widget name %s\n", - __func__, w->shift + 1, - sitar->comp_enabled[w->shift], event , w->name); - if (sitar->comp_enabled[w->shift] == 0) - goto rtn; - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - /* Update compander sample rate */ - snd_soc_update_bits(codec, SITAR_A_CDC_COMP1_FS_CFG + - w->shift * 8, 0x07, rate); - /* Enable compander clock */ - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_RX_B2_CTL, - 1 << w->shift, - 1 << w->shift); - /* Toggle compander reset bits */ - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_OTHR_RESET_CTL, - 1 << w->shift, - 1 << w->shift); - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_OTHR_RESET_CTL, - 1 << w->shift, 0); - sitar_config_gain_compander(codec, w->shift, 1, event); - /* Compander enable -> 0x370/0x378 */ - snd_soc_update_bits(codec, SITAR_A_CDC_COMP1_B1_CTL + - w->shift * 8, 0x03, 0x03); - /* Update the RMS meter resampling */ - snd_soc_update_bits(codec, - SITAR_A_CDC_COMP1_B3_CTL + - w->shift * 8, 0xFF, 0x01); - snd_soc_update_bits(codec, - SITAR_A_CDC_COMP1_B2_CTL + - w->shift * 8, 0xF0, 0x50); - usleep_range(COMP_BRINGUP_WAIT_TIME, COMP_BRINGUP_WAIT_TIME); - break; - case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, - SITAR_A_CDC_CLSG_CTL, - 0x11, 0x00); - if (w->shift == COMPANDER_1) - value = 0x22; - else - value = 0x11; - snd_soc_write(codec, - SITAR_A_CDC_CONN_CLSG_CTL, value); - - snd_soc_update_bits(codec, SITAR_A_CDC_COMP1_B2_CTL + - w->shift * 8, 0x0F, - comp_samp_params[rate].peak_det_timeout); - snd_soc_update_bits(codec, SITAR_A_CDC_COMP1_B2_CTL + - w->shift * 8, 0xF0, - comp_samp_params[rate].rms_meter_div_fact); - snd_soc_update_bits(codec, SITAR_A_CDC_COMP1_B3_CTL + - w->shift * 8, 0xFF, - comp_samp_params[rate].rms_meter_resamp_fact); - break; - case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, SITAR_A_CDC_COMP1_B1_CTL + - w->shift * 8, 0x03, 0x00); - /* Toggle compander reset bits */ - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_OTHR_RESET_CTL, - 1 << w->shift, - 1 << w->shift); - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_OTHR_RESET_CTL, - 1 << w->shift, 0); - /* Disable compander clock */ - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_RX_B2_CTL, - 1 << w->shift, - 0); - /* Restore the gain */ - sitar_config_gain_compander(codec, w->shift, - sitar->comp_enabled[w->shift], - event); - snd_soc_update_bits(codec, - SITAR_A_CDC_CLSG_CTL, - 0x11, 0x11); - snd_soc_write(codec, - SITAR_A_CDC_CONN_CLSG_CTL, 0x14); - break; - } -rtn: - return 0; -} - -static int sitar_codec_dem_input_selection(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, - int event) -{ - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - pr_debug("%s: compander#1->enable(%d) compander#2->enable(%d) reg(0x%x = 0x%x) event(%d)\n", - __func__, sitar->comp_enabled[COMPANDER_1], - sitar->comp_enabled[COMPANDER_2], - SITAR_A_CDC_RX1_B6_CTL + w->shift * 8, - snd_soc_read(codec, SITAR_A_CDC_RX1_B6_CTL + w->shift * 8), - event); - switch (event) { - case SND_SOC_DAPM_POST_PMU: - if (sitar->comp_enabled[COMPANDER_1] || - sitar->comp_enabled[COMPANDER_2]) - snd_soc_update_bits(codec, - SITAR_A_CDC_RX1_B6_CTL + - w->shift * 8, - 1 << 5, 0); - else - snd_soc_update_bits(codec, - SITAR_A_CDC_RX1_B6_CTL + - w->shift * 8, - 1 << 5, 0x20); - break; - case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, - SITAR_A_CDC_RX1_B6_CTL + w->shift * 8, - 1 << 5, 0); - break; - } - return 0; -} - -static const char * const sitar_ear_pa_gain_text[] = {"POS_6_DB", - "POS_2_DB", "NEG_2P5_DB", "NEG_12_DB"}; - -static const struct soc_enum sitar_ear_pa_gain_enum[] = { - SOC_ENUM_SINGLE_EXT(4, sitar_ear_pa_gain_text), -}; - -/*cut of frequency for high pass filter*/ -static const char *cf_text[] = { - "MIN_3DB_4Hz", "MIN_3DB_75Hz", "MIN_3DB_150Hz" -}; - -static const struct soc_enum cf_dec1_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_TX1_MUX_CTL, 4, 3, cf_text); - -static const struct soc_enum cf_rxmix1_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_RX1_B4_CTL, 1, 3, cf_text); - -static const struct snd_kcontrol_new sitar_snd_controls[] = { - - SOC_ENUM_EXT("EAR PA Gain", sitar_ear_pa_gain_enum[0], - sitar_pa_gain_get, sitar_pa_gain_put), - - SOC_SINGLE_TLV("LINEOUT1 Volume", SITAR_A_RX_LINE_1_GAIN, 0, 12, 1, - line_gain), - SOC_SINGLE_TLV("LINEOUT2 Volume", SITAR_A_RX_LINE_2_GAIN, 0, 12, 1, - line_gain), - - SOC_SINGLE_TLV("HPHL Volume", SITAR_A_RX_HPH_L_GAIN, 0, 12, 1, - line_gain), - SOC_SINGLE_TLV("HPHR Volume", SITAR_A_RX_HPH_R_GAIN, 0, 12, 1, - line_gain), - - SOC_SINGLE_S8_TLV("RX1 Digital Volume", SITAR_A_CDC_RX1_VOL_CTL_B2_CTL, - -84, 40, digital_gain), - SOC_SINGLE_S8_TLV("RX2 Digital Volume", SITAR_A_CDC_RX2_VOL_CTL_B2_CTL, - -84, 40, digital_gain), - SOC_SINGLE_S8_TLV("RX3 Digital Volume", SITAR_A_CDC_RX3_VOL_CTL_B2_CTL, - -84, 40, digital_gain), - - SOC_SINGLE_S8_TLV("DEC1 Volume", SITAR_A_CDC_TX1_VOL_CTL_GAIN, -84, 40, - digital_gain), - SOC_SINGLE_S8_TLV("DEC2 Volume", SITAR_A_CDC_TX2_VOL_CTL_GAIN, -84, 40, - digital_gain), - SOC_SINGLE_S8_TLV("DEC3 Volume", SITAR_A_CDC_TX3_VOL_CTL_GAIN, -84, 40, - digital_gain), - SOC_SINGLE_S8_TLV("DEC4 Volume", SITAR_A_CDC_TX4_VOL_CTL_GAIN, -84, 40, - digital_gain), - - SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", SITAR_A_CDC_IIR1_GAIN_B1_CTL, -84, - 40, digital_gain), - SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", SITAR_A_CDC_IIR1_GAIN_B2_CTL, -84, - 40, digital_gain), - SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", SITAR_A_CDC_IIR1_GAIN_B3_CTL, -84, - 40, digital_gain), - SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", SITAR_A_CDC_IIR1_GAIN_B4_CTL, -84, - 40, digital_gain), - SOC_SINGLE_TLV("ADC1 Volume", SITAR_A_TX_1_2_EN, 5, 3, 0, analog_gain), - SOC_SINGLE_TLV("ADC2 Volume", SITAR_A_TX_1_2_EN, 1, 3, 0, analog_gain), - SOC_SINGLE_TLV("ADC3 Volume", SITAR_A_TX_3_EN, 5, 3, 0, analog_gain), - - SOC_SINGLE_EXT("ANC Slot", SND_SOC_NOPM, 0, 0, 100, sitar_get_anc_slot, - sitar_put_anc_slot), - - SOC_ENUM("TX1 HPF cut off", cf_dec1_enum), - - SOC_SINGLE("TX1 HPF Switch", SITAR_A_CDC_TX1_MUX_CTL, 3, 1, 0), - - SOC_SINGLE("RX1 HPF Switch", SITAR_A_CDC_RX1_B5_CTL, 2, 1, 0), - - SOC_ENUM("RX1 HPF cut off", cf_rxmix1_enum), - - SOC_SINGLE_EXT("IIR1 Enable Band1", IIR1, BAND1, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR1 Enable Band2", IIR1, BAND2, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR1 Enable Band3", IIR1, BAND3, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR1 Enable Band4", IIR1, BAND4, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR1 Enable Band5", IIR1, BAND5, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR2 Enable Band1", IIR2, BAND1, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR2 Enable Band2", IIR2, BAND2, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR2 Enable Band3", IIR2, BAND3, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR2 Enable Band4", IIR2, BAND4, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - SOC_SINGLE_EXT("IIR2 Enable Band5", IIR2, BAND5, 1, 0, - sitar_get_iir_enable_audio_mixer, sitar_put_iir_enable_audio_mixer), - - SOC_SINGLE_MULTI_EXT("IIR1 Band1", IIR1, BAND1, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR1 Band2", IIR1, BAND2, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR1 Band3", IIR1, BAND3, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR1 Band4", IIR1, BAND4, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR1 Band5", IIR1, BAND5, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR2 Band1", IIR2, BAND1, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR2 Band2", IIR2, BAND2, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR2 Band3", IIR2, BAND3, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR2 Band4", IIR2, BAND4, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("IIR2 Band5", IIR2, BAND5, 255, 0, 5, - sitar_get_iir_band_audio_mixer, sitar_put_iir_band_audio_mixer), - SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0, - sitar_get_compander, sitar_set_compander), - SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0, - sitar_get_compander, sitar_set_compander), -}; - -static const char *rx_mix1_text[] = { - "ZERO", "SRC1", "SRC2", "IIR1", "IIR2", "RX1", "RX2", "RX3", "RX4", - "RX5" -}; - -static const char *rx_dac1_text[] = { - "ZERO", "RX1", "RX2" -}; - -static const char *rx_dac2_text[] = { - "ZERO", "RX1", -}; - -static const char *rx_dac3_text[] = { - "ZERO", "RX1", "INV_RX1", "RX2" -}; - -static const char *rx_dac4_text[] = { - "ZERO", "ON" -}; - -static const char *sb_tx1_mux_text[] = { - "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", - "DEC1" -}; - -static const char *sb_tx2_mux_text[] = { - "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", - "DEC2" -}; - -static const char *sb_tx3_mux_text[] = { - "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", - "DEC3" -}; - -static const char *sb_tx4_mux_text[] = { - "ZERO", "RMIX1", "RMIX2", "RMIX3", "RMIX4", "RMIX5", "RMIX6", "RMIX7", - "DEC4" -}; - -static const char *sb_tx5_mux_text[] = { - "ZERO", "RMIX1", "RMIX2", "RMIX3", "DEC1", "DEC2", "DEC3", "DEC4" -}; - -static const char *dec1_mux_text[] = { - "ZERO", "DMIC1", "ADC1", "ADC2", "ADC3", "MBADC", "DMIC4", "ANC1_FB", -}; - -static const char *dec2_mux_text[] = { - "ZERO", "DMIC2", "ADC1", "ADC2", "ADC3", "MBADC", "DMIC3", "ANC2_FB", -}; - -static const char *dec3_mux_text[] = { - "ZERO", "DMIC3", "ADC1", "ADC2", "ADC3", "MBADC", "DMIC2", "DMIC4" -}; - -static const char *dec4_mux_text[] = { - "ZERO", "DMIC4", "ADC1", "ADC2", "ADC3", "DMIC3", "DMIC2", "DMIC1" -}; - -static const char const *anc_mux_text[] = { - "ZERO", "ADC1", "ADC2", "ADC3", "RSVD1", "RSVD2", "RSVD3", - "MBADC", "RSVD4", "DMIC1", "DMIC2", "DMIC3", "DMIC4" -}; - -static const char const *anc1_fb_mux_text[] = { - "ZERO", "EAR_HPH_L", "EAR_LINE_1", -}; - -static const char const *iir_inp1_text[] = { - "ZERO", "DEC1", "DEC2", "DEC3", "DEC4", "ZERO", "ZERO", "ZERO", - "ZERO", "ZERO", "ZERO", "RX1", "RX2", "RX3", "RX4", "RX5", -}; - -static const struct soc_enum rx_mix1_inp1_chain_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_RX1_B1_CTL, 0, 10, rx_mix1_text); - -static const struct soc_enum rx_mix1_inp2_chain_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_RX1_B1_CTL, 4, 10, rx_mix1_text); - -static const struct soc_enum rx2_mix1_inp1_chain_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_RX2_B1_CTL, 0, 10, rx_mix1_text); - -static const struct soc_enum rx2_mix1_inp2_chain_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_RX2_B1_CTL, 4, 10, rx_mix1_text); - -static const struct soc_enum rx3_mix1_inp1_chain_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_RX3_B1_CTL, 0, 10, rx_mix1_text); - -static const struct soc_enum rx3_mix1_inp2_chain_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_RX3_B1_CTL, 4, 10, rx_mix1_text); - -static const struct soc_enum rx_dac1_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_TOP_RDAC_DOUT_CTL, 6, 3, rx_dac1_text); - -static const struct soc_enum rx_dac2_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_TOP_RDAC_DOUT_CTL, 4, 2, rx_dac2_text); - -static const struct soc_enum rx_dac3_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_TOP_RDAC_DOUT_CTL, 2, 4, rx_dac3_text); - -static const struct soc_enum rx_dac4_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_TOP_RDAC_DOUT_CTL, 0, 2, rx_dac4_text); - -static const struct soc_enum sb_tx5_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_SB_B5_CTL, 0, 9, sb_tx5_mux_text); - -static const struct soc_enum sb_tx4_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_SB_B4_CTL, 0, 9, sb_tx4_mux_text); - -static const struct soc_enum sb_tx3_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_SB_B3_CTL, 0, 9, sb_tx3_mux_text); - -static const struct soc_enum sb_tx2_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_SB_B2_CTL, 0, 9, sb_tx2_mux_text); - -static const struct soc_enum sb_tx1_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_SB_B1_CTL, 0, 9, sb_tx1_mux_text); - -static const struct soc_enum dec1_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_B1_CTL, 0, 8, dec1_mux_text); - -static const struct soc_enum dec2_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_B1_CTL, 3, 8, dec2_mux_text); - -static const struct soc_enum dec3_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_B2_CTL, 0, 8, dec3_mux_text); - -static const struct soc_enum dec4_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_TX_B2_CTL, 3, 8, dec4_mux_text); - -static const struct soc_enum anc1_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_ANC_B1_CTL, 0, 13, anc_mux_text); - -static const struct soc_enum anc2_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_ANC_B1_CTL, 4, 13, anc_mux_text); - -static const struct soc_enum anc1_fb_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_ANC_B2_CTL, 0, 3, anc1_fb_mux_text); - -static const struct soc_enum iir1_inp1_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_EQ1_B1_CTL, 0, 16, iir_inp1_text); - -static const struct soc_enum iir2_inp1_mux_enum = - SOC_ENUM_SINGLE(SITAR_A_CDC_CONN_EQ2_B1_CTL, 0, 16, iir_inp1_text); - -static const struct snd_kcontrol_new rx_mix1_inp1_mux = - SOC_DAPM_ENUM("RX1 MIX1 INP1 Mux", rx_mix1_inp1_chain_enum); - -static const struct snd_kcontrol_new rx_mix1_inp2_mux = - SOC_DAPM_ENUM("RX1 MIX1 INP2 Mux", rx_mix1_inp2_chain_enum); - -static const struct snd_kcontrol_new rx2_mix1_inp1_mux = - SOC_DAPM_ENUM("RX2 MIX1 INP1 Mux", rx2_mix1_inp1_chain_enum); - -static const struct snd_kcontrol_new rx2_mix1_inp2_mux = - SOC_DAPM_ENUM("RX2 MIX1 INP2 Mux", rx2_mix1_inp2_chain_enum); - -static const struct snd_kcontrol_new rx3_mix1_inp1_mux = - SOC_DAPM_ENUM("RX3 MIX1 INP1 Mux", rx3_mix1_inp1_chain_enum); - -static const struct snd_kcontrol_new rx3_mix1_inp2_mux = - SOC_DAPM_ENUM("RX3 MIX1 INP2 Mux", rx3_mix1_inp2_chain_enum); - -static const struct snd_kcontrol_new rx_dac1_mux = - SOC_DAPM_ENUM("RX DAC1 Mux", rx_dac1_enum); - -static const struct snd_kcontrol_new rx_dac2_mux = - SOC_DAPM_ENUM("RX DAC2 Mux", rx_dac2_enum); - -static const struct snd_kcontrol_new rx_dac3_mux = - SOC_DAPM_ENUM("RX DAC3 Mux", rx_dac3_enum); - -static const struct snd_kcontrol_new rx_dac4_mux = - SOC_DAPM_ENUM("RX DAC4 Mux", rx_dac4_enum); - -static const struct snd_kcontrol_new sb_tx5_mux = - SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum); - -static const struct snd_kcontrol_new sb_tx4_mux = - SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum); - -static const struct snd_kcontrol_new sb_tx3_mux = - SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum); - -static const struct snd_kcontrol_new sb_tx2_mux = - SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum); - -static const struct snd_kcontrol_new sb_tx1_mux = - SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum); - -static int wcd9304_put_dec_enum(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) - { - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *w = wlist->widgets[0]; - struct snd_soc_codec *codec = w->codec; - struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - unsigned int dec_mux, decimator; - char *dec_name = NULL; - char *widget_name = NULL; - char *temp; - u16 tx_mux_ctl_reg; - u8 adc_dmic_sel = 0x0; - int ret = 0; - - if (ucontrol->value.enumerated.item[0] > e->max - 1) - return -EINVAL; - - dec_mux = ucontrol->value.enumerated.item[0]; - - widget_name = kstrndup(w->name, 15, GFP_KERNEL); - if (!widget_name) - return -ENOMEM; - temp = widget_name; - - dec_name = strsep(&widget_name, " "); - widget_name = temp; - if (!dec_name) { - pr_err("%s: Invalid decimator = %s\n", __func__, w->name); - ret = -EINVAL; - goto out; - } - - ret = kstrtouint(strpbrk(dec_name, "1234"), 10, &decimator); - if (ret < 0) { - pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); - ret = -EINVAL; - goto out; - } - - dev_dbg(w->dapm->dev, "%s(): widget = %s dec_name = %s decimator = %u"\ - "dec_mux = %u\n", __func__, w->name, dec_name, decimator, - dec_mux); - - - switch (decimator) { - case 1: - case 2: - if ((dec_mux == 1) || (dec_mux == 6)) - adc_dmic_sel = ADC_DMIC_SEL_DMIC; - else - adc_dmic_sel = ADC_DMIC_SEL_ADC; - break; - case 3: - if ((dec_mux == 1) || (dec_mux == 6) || (dec_mux == 7)) - adc_dmic_sel = ADC_DMIC_SEL_DMIC; - else - adc_dmic_sel = ADC_DMIC_SEL_ADC; - break; - case 4: - if ((dec_mux == 1) || (dec_mux == 5) - || (dec_mux == 6) || (dec_mux == 7)) - adc_dmic_sel = ADC_DMIC_SEL_DMIC; - else - adc_dmic_sel = ADC_DMIC_SEL_ADC; - break; - default: - pr_err("%s: Invalid Decimator = %u\n", __func__, decimator); - ret = -EINVAL; - goto out; - } - - tx_mux_ctl_reg = SITAR_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1); - - snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel); - - ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); -out: - kfree(widget_name); - return ret; -} - -#define WCD9304_DEC_ENUM(xname, xenum) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ - .info = snd_soc_info_enum_double, \ - .get = snd_soc_dapm_get_enum_double, \ - .put = wcd9304_put_dec_enum, \ - .private_value = (unsigned long)&xenum } - -static const struct snd_kcontrol_new dec1_mux = - WCD9304_DEC_ENUM("DEC1 MUX Mux", dec1_mux_enum); - -static const struct snd_kcontrol_new dec2_mux = - WCD9304_DEC_ENUM("DEC2 MUX Mux", dec2_mux_enum); - -static const struct snd_kcontrol_new dec3_mux = - WCD9304_DEC_ENUM("DEC3 MUX Mux", dec3_mux_enum); - -static const struct snd_kcontrol_new dec4_mux = - WCD9304_DEC_ENUM("DEC4 MUX Mux", dec4_mux_enum); - -static const struct snd_kcontrol_new iir1_inp1_mux = - SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum); - -static const struct snd_kcontrol_new iir2_inp1_mux = - SOC_DAPM_ENUM("IIR2 INP1 Mux", iir2_inp1_mux_enum); - -static const struct snd_kcontrol_new anc1_mux = - SOC_DAPM_ENUM("ANC1 MUX Mux", anc1_mux_enum); - -static const struct snd_kcontrol_new anc2_mux = - SOC_DAPM_ENUM("ANC2 MUX Mux", anc2_mux_enum); - -static const struct snd_kcontrol_new anc1_fb_mux = - SOC_DAPM_ENUM("ANC1 FB MUX Mux", anc1_fb_mux_enum); - -static const struct snd_kcontrol_new dac1_switch[] = { - SOC_DAPM_SINGLE("Switch", SITAR_A_RX_EAR_EN, 5, 1, 0), -}; - -static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - - ucontrol->value.integer.value[0] = widget->value; - return 0; -} - -static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct snd_soc_codec *codec = widget->codec; - struct sitar_priv *sitar_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); - struct soc_multi_mixer_control *mixer = - ((struct soc_multi_mixer_control *)kcontrol->private_value); - u32 dai_id = widget->shift; - u32 port_id = mixer->shift; - u32 enable = ucontrol->value.integer.value[0]; - - mutex_lock(&codec->mutex); - - if (sitar_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - if (dai_id != AIF1_CAP) { - dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", - __func__); - mutex_unlock(&codec->mutex); - return -EINVAL; - } - } - - switch (dai_id) { - case AIF1_CAP: - if (enable && !(widget->value & 1 << port_id)) { - if (wcd9xxx_tx_vport_validation( - vport_check_table[dai_id], - port_id, - sitar_p->dai)) { - dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n", - __func__, port_id + 1); - mutex_unlock(&codec->mutex); - return 0; - } - widget->value |= 1 << port_id; - list_add_tail(&core->tx_chs[port_id].list, - &sitar_p->dai[dai_id].wcd9xxx_ch_list); - } else if (!enable && (widget->value & 1 << port_id)) { - widget->value &= ~(1<tx_chs[port_id].list); - } else { - if (enable) - dev_dbg(codec->dev, "%s: TX%u port is used by this virtual port\n", - __func__, port_id + 1); - else - dev_dbg(codec->dev, "%s: TX%u port is not used by this virtual port\n", - __func__, port_id + 1); - /* avoid update power function */ - mutex_unlock(&codec->mutex); - return 0; - } - break; - default: - pr_err("Unknown AIF %d\n", dai_id); - mutex_unlock(&codec->mutex); - return -EINVAL; - } - - pr_debug("%s: name %s sname %s updated value %u shift %d\n", __func__, - widget->name, widget->sname, widget->value, widget->shift); - snd_soc_dapm_mixer_update_power(widget, kcontrol, enable); - mutex_unlock(&codec->mutex); - return 0; -} - -static int slim_rx_mux_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - - ucontrol->value.enumerated.item[0] = widget->value; - return 0; -} - -static const char * const slim_rx_mux_text[] = { - "ZERO", "AIF1_PB" -}; - -static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct snd_soc_codec *codec = widget->codec; - struct sitar_priv *sitar_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); - struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - u32 port_id = widget->shift; - - widget->value = ucontrol->value.enumerated.item[0]; - - mutex_lock(&codec->mutex); - - if (sitar_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - if (widget->value > 1) { - dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", - __func__); - goto err; - } - } - - switch (widget->value) { - case 0: - list_del_init(&core->rx_chs[port_id].list); - break; - case 1: - if (wcd9xxx_rx_vport_validation(port_id + - SITAR_RX_PORT_START_NUMBER, - &sitar_p->dai[AIF1_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", - __func__, port_id + 1); - goto rtn; - } - list_add_tail(&core->rx_chs[port_id].list, - &sitar_p->dai[AIF1_PB].wcd9xxx_ch_list); - break; - break; - default: - pr_err("Unknown AIF %d\n", widget->value); - goto err; - } - -rtn: - snd_soc_dapm_mux_update_power(widget, kcontrol, 1, widget->value, e); - mutex_unlock(&codec->mutex); - return 0; -err: - mutex_unlock(&codec->mutex); - return -EINVAL; -} - -static const struct soc_enum slim_rx_mux_enum = - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text); - -static const struct snd_kcontrol_new sitar_aif_pb_mux[SITAR_RX_MAX] = { - SOC_DAPM_ENUM_EXT("SLIM RX1 MUX", slim_rx_mux_enum, - slim_rx_mux_get, slim_rx_mux_put), - SOC_DAPM_ENUM_EXT("SLIM RX2 MUX", slim_rx_mux_enum, - slim_rx_mux_get, slim_rx_mux_put), - SOC_DAPM_ENUM_EXT("SLIM RX3 MUX", slim_rx_mux_enum, - slim_rx_mux_get, slim_rx_mux_put), - SOC_DAPM_ENUM_EXT("SLIM RX4 MUX", slim_rx_mux_enum, - slim_rx_mux_get, slim_rx_mux_put), - SOC_DAPM_ENUM_EXT("SLIM RX5 MUX", slim_rx_mux_enum, - slim_rx_mux_get, slim_rx_mux_put) -}; - -static const struct snd_kcontrol_new sitar_aif_cap_mixer[SITAR_TX_MAX] = { - SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, SITAR_TX1, 1, 0, - slim_tx_mixer_get, slim_tx_mixer_put), - SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, SITAR_TX2, 1, 0, - slim_tx_mixer_get, slim_tx_mixer_put), - SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, SITAR_TX3, 1, 0, - slim_tx_mixer_get, slim_tx_mixer_put), - SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, SITAR_TX4, 1, 0, - slim_tx_mixer_get, slim_tx_mixer_put), - SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, SITAR_TX5, 1, 0, - slim_tx_mixer_get, slim_tx_mixer_put), -}; - - -static void sitar_codec_enable_adc_block(struct snd_soc_codec *codec, - int enable) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - pr_debug("%s %d\n", __func__, enable); - - if (enable) { - sitar->adc_count++; - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_OTHR_CTL, - 0x02, 0x02); - } else { - sitar->adc_count--; - if (!sitar->adc_count) { - if (!sitar->mbhc_polling_active) - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_OTHR_CTL, 0xE0, 0x0); - } - } -} - -static int sitar_codec_enable_adc(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - u16 adc_reg; - u8 init_bit_shift; - - pr_debug("%s %d\n", __func__, event); - - if (w->reg == SITAR_A_TX_1_2_EN) - adc_reg = SITAR_A_TX_1_2_TEST_CTL; - else if (w->reg == SITAR_A_TX_3_EN) - adc_reg = SITAR_A_TX_3_TEST_CTL; - else { - pr_err("%s: Error, invalid adc register\n", __func__); - return -EINVAL; - } - - if (w->shift == 3) - init_bit_shift = 6; - else if (w->shift == 7) - init_bit_shift = 7; - else { - pr_err("%s: Error, invalid init bit postion adc register\n", - __func__); - return -EINVAL; - } - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - sitar_codec_enable_adc_block(codec, 1); - snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, - 1 << init_bit_shift); - break; - case SND_SOC_DAPM_POST_PMU: - - snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00); - - break; - case SND_SOC_DAPM_POST_PMD: - sitar_codec_enable_adc_block(codec, 0); - break; - } - return 0; -} - -static int sitar_lineout_dac_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - - pr_debug("%s %s %d\n", __func__, w->name, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, w->reg, 0x40, 0x40); - break; - - case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, w->reg, 0x40, 0x00); - break; - } - return 0; -} - -static void sitar_enable_classg(struct snd_soc_codec *codec, - bool enable) -{ - - if (enable) { - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_OTHR_RESET_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, SITAR_A_CP_STATIC, 0x07, 0x00); - snd_soc_update_bits(codec, SITAR_A_CP_STATIC, 0x08, 0x00); - snd_soc_update_bits(codec, SITAR_A_CP_STATIC, 0x10, 0x00); - - } else { - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_OTHR_RESET_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, SITAR_A_CP_STATIC, 0x07, 0x03); - snd_soc_update_bits(codec, SITAR_A_CP_STATIC, 0x08, 0x08); - snd_soc_update_bits(codec, SITAR_A_CP_STATIC, 0x10, 0x10); - } -} - -static bool sitar_is_hph_pa_on(struct snd_soc_codec *codec) -{ - u8 hph_reg_val = 0; - hph_reg_val = snd_soc_read(codec, SITAR_A_RX_HPH_CNP_EN); - - return (hph_reg_val & 0x30) ? true : false; -} - -static bool sitar_is_line_pa_on(struct snd_soc_codec *codec) -{ - u8 line_reg_val = 0; - line_reg_val = snd_soc_read(codec, SITAR_A_RX_LINE_CNP_EN); - - return (line_reg_val & 0x03) ? true : false; -} - -static int sitar_codec_enable_lineout(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u16 lineout_gain_reg; - - pr_debug("%s %d %s comp2 enable %d\n", __func__, event, w->name, - sitar->comp_enabled[COMPANDER_2]); - - if (sitar->comp_enabled[COMPANDER_2]) - goto rtn; - - switch (w->shift) { - case 0: - lineout_gain_reg = SITAR_A_RX_LINE_1_GAIN; - break; - case 1: - lineout_gain_reg = SITAR_A_RX_LINE_2_GAIN; - break; - default: - pr_err("%s: Error, incorrect lineout register value\n", - __func__); - return -EINVAL; - } - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - if (sitar_is_hph_pa_on(codec)) { - snd_soc_update_bits(codec, SITAR_A_CDC_RX1_B6_CTL, - 0x20, 0x00); - sitar_enable_classg(codec, false); - } else { - snd_soc_update_bits(codec, SITAR_A_CDC_RX1_B6_CTL, - 0x20, 0x20); - sitar_enable_classg(codec, true); - } - snd_soc_update_bits(codec, lineout_gain_reg, 0x10, 0x10); - break; - case SND_SOC_DAPM_POST_PMU: - pr_debug("%s: sleeping 32 ms after %s PA turn on\n", - __func__, w->name); - usleep_range(32000, 32000); - break; - case SND_SOC_DAPM_POST_PMD: - if (sitar_is_hph_pa_on(codec)) - sitar_enable_classg(codec, true); - else - sitar_enable_classg(codec, false); - - snd_soc_update_bits(codec, lineout_gain_reg, 0x10, 0x00); - break; - } -rtn: - return 0; -} - -static int sitar_codec_enable_dmic(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - u16 tx_dmic_ctl_reg; - u8 dmic_clk_sel, dmic_clk_en; - unsigned int dmic; - int ret; - - ret = kstrtouint(strpbrk(w->name, "1234"), 10, &dmic); - if (ret < 0) { - pr_err("%s: Invalid DMIC line on the codec\n", __func__); - return -EINVAL; - } - - switch (dmic) { - case 1: - case 2: - dmic_clk_sel = 0x02; - dmic_clk_en = 0x01; - break; - case 3: - case 4: - dmic_clk_sel = 0x08; - dmic_clk_en = 0x04; - break; - - break; - - default: - pr_err("%s: Invalid DMIC Selection\n", __func__); - return -EINVAL; - } - - tx_dmic_ctl_reg = SITAR_A_CDC_TX1_DMIC_CTL + 8 * (dmic - 1); - - pr_debug("%s %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_DMIC_CTL, - dmic_clk_sel, dmic_clk_sel); - - snd_soc_update_bits(codec, tx_dmic_ctl_reg, 0x1, 0x1); - - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_DMIC_CTL, - dmic_clk_en, dmic_clk_en); - break; - case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_DMIC_CTL, - dmic_clk_en, 0); - break; - } - return 0; -} - -static int sitar_codec_enable_anc(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - const char *filename; - const struct firmware *fw; - int i; - int ret; - int num_anc_slots; - struct anc_header *anc_head; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u32 anc_writes_size = 0; - int anc_size_remaining; - u32 *anc_ptr; - u16 reg; - u8 mask, val, old_val; - - pr_debug("%s %d\n", __func__, event); - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - - /* Use the same firmware file as that of WCD9310, - * since the register sequences are same for - * WCD9310 and WCD9304 - */ - filename = "wcd9310/wcd9310_anc.bin"; - - ret = request_firmware(&fw, filename, codec->dev); - if (ret != 0) { - dev_err(codec->dev, "Failed to acquire ANC data: %d\n", - ret); - return -ENODEV; - } - - if (fw->size < sizeof(struct anc_header)) { - dev_err(codec->dev, "Not enough data\n"); - release_firmware(fw); - return -ENOMEM; - } - - /* First number is the number of register writes */ - anc_head = (struct anc_header *)(fw->data); - anc_ptr = (u32 *)((u32)fw->data + sizeof(struct anc_header)); - anc_size_remaining = fw->size - sizeof(struct anc_header); - num_anc_slots = anc_head->num_anc_slots; - - if (sitar->anc_slot >= num_anc_slots) { - dev_err(codec->dev, "Invalid ANC slot selected\n"); - release_firmware(fw); - return -EINVAL; - } - - for (i = 0; i < num_anc_slots; i++) { - - if (anc_size_remaining < SITAR_PACKED_REG_SIZE) { - dev_err(codec->dev, "Invalid register format\n"); - release_firmware(fw); - return -EINVAL; - } - anc_writes_size = (u32)(*anc_ptr); - anc_size_remaining -= sizeof(u32); - anc_ptr += 1; - - if (anc_writes_size * SITAR_PACKED_REG_SIZE - > anc_size_remaining) { - dev_err(codec->dev, "Invalid register format\n"); - release_firmware(fw); - return -ENOMEM; - } - - if (sitar->anc_slot == i) - break; - - anc_size_remaining -= (anc_writes_size * - SITAR_PACKED_REG_SIZE); - anc_ptr += anc_writes_size; - } - if (i == num_anc_slots) { - dev_err(codec->dev, "Selected ANC slot not present\n"); - release_firmware(fw); - return -ENOMEM; - } - - for (i = 0; i < anc_writes_size; i++) { - SITAR_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, - mask, val); - old_val = snd_soc_read(codec, reg); - snd_soc_write(codec, reg, (old_val & ~mask) | - (val & mask)); - } - - release_firmware(fw); - - /* For Sitar, it is required to enable both Feed-forward - * and Feed back clocks to enable ANC - */ - snd_soc_write(codec, SITAR_A_CDC_CLK_ANC_CLK_EN_CTL, 0x0F); - - break; - - case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, SITAR_A_CDC_CLK_ANC_RESET_CTL, 0xFF); - snd_soc_write(codec, SITAR_A_CDC_CLK_ANC_CLK_EN_CTL, 0x00); - break; - } - return 0; -} - - -static void sitar_codec_start_hs_polling(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - int mbhc_state = sitar->mbhc_state; - - pr_debug("%s: enter\n", __func__); - if (!sitar->mbhc_polling_active) { - pr_debug("Polling is not active, do not start polling\n"); - return; - } - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x84); - - - if (!sitar->no_mic_headset_override) { - if (mbhc_state == MBHC_STATE_POTENTIAL) { - pr_debug("%s recovering MBHC state macine\n", __func__); - sitar->mbhc_state = MBHC_STATE_POTENTIAL_RECOVERY; - /* set to max button press threshold */ - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B2_CTL, - 0x7F); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B1_CTL, - 0xFF); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B4_CTL, - 0x7F); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B3_CTL, - 0xFF); - /* set to max */ - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B6_CTL, - 0x7F); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B5_CTL, - 0xFF); - } - } - - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x84); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x1); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x0); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x1); -} - -static void sitar_codec_pause_hs_polling(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - pr_debug("%s: enter\n", __func__); - if (!sitar->mbhc_polling_active) { - pr_debug("polling not active, nothing to pause\n"); - return; - } - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); - pr_debug("%s: leave\n", __func__); - -} - -static void sitar_codec_switch_cfilt_mode(struct snd_soc_codec *codec, - int mode) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u8 reg_mode_val, cur_mode_val; - bool mbhc_was_polling = false; - - if (mode) - reg_mode_val = SITAR_CFILT_FAST_MODE; - else - reg_mode_val = SITAR_CFILT_SLOW_MODE; - - cur_mode_val = snd_soc_read(codec, - sitar->mbhc_bias_regs.cfilt_ctl) & 0x40; - - if (cur_mode_val != reg_mode_val) { - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - if (sitar->mbhc_polling_active) { - sitar_codec_pause_hs_polling(codec); - mbhc_was_polling = true; - } - snd_soc_update_bits(codec, - sitar->mbhc_bias_regs.cfilt_ctl, 0x40, reg_mode_val); - if (mbhc_was_polling) - sitar_codec_start_hs_polling(codec); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - pr_debug("%s: CFILT mode change (%x to %x)\n", __func__, - cur_mode_val, reg_mode_val); - } else { - pr_err("%s: CFILT Value is already %x\n", - __func__, cur_mode_val); - } -} - -static void sitar_codec_update_cfilt_usage(struct snd_soc_codec *codec, - u8 cfilt_sel, int inc) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u32 *cfilt_cnt_ptr = NULL; - u16 micb_cfilt_reg; - - switch (cfilt_sel) { - case SITAR_CFILT1_SEL: - cfilt_cnt_ptr = &sitar->cfilt1_cnt; - micb_cfilt_reg = SITAR_A_MICB_CFILT_1_CTL; - break; - case SITAR_CFILT2_SEL: - cfilt_cnt_ptr = &sitar->cfilt2_cnt; - micb_cfilt_reg = SITAR_A_MICB_CFILT_2_CTL; - break; - default: - return; /* should not happen */ - } - - if (inc) { - if (!(*cfilt_cnt_ptr)++) { - /* Switch CFILT to slow mode if MBHC CFILT being used */ - if (cfilt_sel == sitar->mbhc_bias_regs.cfilt_sel) - sitar_codec_switch_cfilt_mode(codec, 0); - - snd_soc_update_bits(codec, micb_cfilt_reg, 0x80, 0x80); - } - } else { - /* check if count not zero, decrement - * then check if zero, go ahead disable cfilter - */ - if ((*cfilt_cnt_ptr) && !--(*cfilt_cnt_ptr)) { - snd_soc_update_bits(codec, micb_cfilt_reg, 0x80, 0); - - /* Switch CFILT to fast mode if MBHC CFILT being used */ - if (cfilt_sel == sitar->mbhc_bias_regs.cfilt_sel) - sitar_codec_switch_cfilt_mode(codec, 1); - } - } -} - -static int sitar_find_k_value(unsigned int ldoh_v, unsigned int cfilt_mv) -{ - int rc = -EINVAL; - unsigned min_mv, max_mv; - - switch (ldoh_v) { - case SITAR_LDOH_1P95_V: - min_mv = 160; - max_mv = 1800; - break; - case SITAR_LDOH_2P35_V: - min_mv = 200; - max_mv = 2200; - break; - case SITAR_LDOH_2P75_V: - min_mv = 240; - max_mv = 2600; - break; - case SITAR_LDOH_2P85_V: - min_mv = 250; - max_mv = 2700; - break; - default: - goto done; - } - - if (cfilt_mv < min_mv || cfilt_mv > max_mv) - goto done; - - for (rc = 4; rc <= 44; rc++) { - min_mv = max_mv * (rc) / 44; - if (min_mv >= cfilt_mv) { - rc -= 4; - break; - } - } -done: - return rc; -} - -static bool sitar_is_hph_dac_on(struct snd_soc_codec *codec, int left) -{ - u8 hph_reg_val = 0; - if (left) - hph_reg_val = snd_soc_read(codec, - SITAR_A_RX_HPH_L_DAC_CTL); - else - hph_reg_val = snd_soc_read(codec, - SITAR_A_RX_HPH_R_DAC_CTL); - - return (hph_reg_val & 0xC0) ? true : false; -} - -static void sitar_codec_switch_micbias(struct snd_soc_codec *codec, - int vddio_switch) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - int cfilt_k_val; - bool mbhc_was_polling = false; - - switch (vddio_switch) { - case 1: - if (sitar->mbhc_micbias_switched == 0 && - sitar->mbhc_polling_active) { - - sitar_codec_pause_hs_polling(codec); - /* Enable Mic Bias switch to VDDIO */ - sitar->cfilt_k_value = snd_soc_read(codec, - sitar->mbhc_bias_regs.cfilt_val); - cfilt_k_val = sitar_find_k_value( - sitar->pdata->micbias.ldoh_v, 1800); - snd_soc_update_bits(codec, - sitar->mbhc_bias_regs.cfilt_val, - 0xFC, (cfilt_k_val << 2)); - - snd_soc_update_bits(codec, - sitar->mbhc_bias_regs.mbhc_reg, 0x80, 0x80); - snd_soc_update_bits(codec, - sitar->mbhc_bias_regs.mbhc_reg, 0x10, 0x00); - sitar_codec_start_hs_polling(codec); - - sitar->mbhc_micbias_switched = true; - pr_debug("%s: Enabled MBHC Mic bias to VDDIO Switch\n", - __func__); - } - break; - - case 0: - if (sitar->mbhc_micbias_switched) { - if (sitar->mbhc_polling_active) { - sitar_codec_pause_hs_polling(codec); - mbhc_was_polling = true; - } - /* Disable Mic Bias switch to VDDIO */ - if (sitar->cfilt_k_value != 0) - snd_soc_update_bits(codec, - sitar->mbhc_bias_regs.cfilt_val, 0XFC, - sitar->cfilt_k_value); - snd_soc_update_bits(codec, - sitar->mbhc_bias_regs.mbhc_reg, 0x80, 0x00); - snd_soc_update_bits(codec, - sitar->mbhc_bias_regs.mbhc_reg, 0x10, 0x00); - - if (mbhc_was_polling) - sitar_codec_start_hs_polling(codec); - - sitar->mbhc_micbias_switched = false; - pr_debug("%s: Disabled MBHC Mic bias to VDDIO Switch\n", - __func__); - } - break; - } -} - -static int sitar_codec_enable_micbias(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u16 micb_int_reg; - int micb_line; - u8 cfilt_sel_val = 0; - char *internal1_text = "Internal1"; - char *internal2_text = "Internal2"; - - pr_debug("%s %d\n", __func__, event); - switch (w->reg) { - case SITAR_A_MICB_1_CTL: - micb_int_reg = SITAR_A_MICB_1_INT_RBIAS; - cfilt_sel_val = sitar->pdata->micbias.bias1_cfilt_sel; - micb_line = SITAR_MICBIAS1; - break; - case SITAR_A_MICB_2_CTL: - micb_int_reg = SITAR_A_MICB_2_INT_RBIAS; - cfilt_sel_val = sitar->pdata->micbias.bias2_cfilt_sel; - micb_line = SITAR_MICBIAS2; - break; - default: - pr_err("%s: Error, invalid micbias register\n", __func__); - return -EINVAL; - } - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - /* Decide whether to switch the micbias for MBHC */ - if (w->reg == sitar->mbhc_bias_regs.ctl_reg) { - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - sitar_codec_switch_micbias(codec, 0); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - } - - snd_soc_update_bits(codec, w->reg, 0x1E, 0x00); - sitar_codec_update_cfilt_usage(codec, cfilt_sel_val, 1); - - if (strnstr(w->name, internal1_text, 30)) - snd_soc_update_bits(codec, micb_int_reg, 0xFF, 0xA4); - else if (strnstr(w->name, internal2_text, 30)) - snd_soc_update_bits(codec, micb_int_reg, 0x1C, 0x1C); - break; - case SND_SOC_DAPM_POST_PMU: - - usleep_range(20000, 20000); - if (sitar->mbhc_polling_active && - sitar->mbhc_cfg.micbias == micb_line) { - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - sitar_codec_pause_hs_polling(codec); - sitar_codec_start_hs_polling(codec); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - } - break; - case SND_SOC_DAPM_POST_PMD: - - if ((w->reg == sitar->mbhc_bias_regs.ctl_reg) - && sitar_is_hph_pa_on(codec)) - sitar_codec_switch_micbias(codec, 1); - - if (strnstr(w->name, internal1_text, 30)) - snd_soc_update_bits(codec, micb_int_reg, 0x80, 0x00); - else if (strnstr(w->name, internal2_text, 30)) - snd_soc_update_bits(codec, micb_int_reg, 0x10, 0x00); - sitar_codec_update_cfilt_usage(codec, cfilt_sel_val, 0); - break; - } - - return 0; -} - -static void tx_hpf_corner_freq_callback(struct work_struct *work) -{ - struct delayed_work *hpf_delayed_work; - struct hpf_work *hpf_work; - struct sitar_priv *sitar; - struct snd_soc_codec *codec; - u16 tx_mux_ctl_reg; - u8 hpf_cut_of_freq; - - hpf_delayed_work = to_delayed_work(work); - hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); - sitar = hpf_work->sitar; - codec = hpf_work->sitar->codec; - hpf_cut_of_freq = hpf_work->tx_hpf_cut_of_freq; - - tx_mux_ctl_reg = SITAR_A_CDC_TX1_MUX_CTL + - (hpf_work->decimator - 1) * 8; - - pr_debug("%s(): decimator %u hpf_cut_of_freq 0x%x\n", __func__, - hpf_work->decimator, (unsigned int)hpf_cut_of_freq); - - snd_soc_update_bits(codec, tx_mux_ctl_reg, - CUT_OF_FREQ_MASK, hpf_cut_of_freq << 4); -} - -static int sitar_codec_enable_dec(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - u16 dec_reset_reg, gain_reg, tx_vol_ctl_reg, tx_mux_ctl_reg; - unsigned int decimator; - char *dec_name = NULL; - char *widget_name = NULL; - char *temp; - int ret = 0; - u8 dec_hpf_cut_of_freq, current_gain; - - pr_debug("%s %d\n", __func__, event); - - widget_name = kstrndup(w->name, 15, GFP_KERNEL); - if (!widget_name) - return -ENOMEM; - temp = widget_name; - - dec_name = strsep(&widget_name, " "); - widget_name = temp; - if (!dec_name) { - pr_err("%s: Invalid decimator = %s\n", __func__, w->name); - ret = -EINVAL; - goto out; - } - - ret = kstrtouint(strpbrk(dec_name, "1234"), 10, &decimator); - if (ret < 0) { - pr_err("%s: Invalid decimator = %s\n", __func__, dec_name); - ret = -EINVAL; - goto out; - } - - pr_debug("%s(): widget = %s dec_name = %s decimator = %u\n", __func__, - w->name, dec_name, decimator); - - if (w->reg == SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL) - dec_reset_reg = SITAR_A_CDC_CLK_TX_RESET_B1_CTL; - else { - pr_err("%s: Error, incorrect dec\n", __func__); - ret = EINVAL; - goto out; - } - - tx_vol_ctl_reg = SITAR_A_CDC_TX1_VOL_CTL_CFG + 8 * (decimator - 1); - tx_mux_ctl_reg = SITAR_A_CDC_TX1_MUX_CTL + 8 * (decimator - 1); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - /* Enable TX Digital Mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); - - snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, - 1 << w->shift); - snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0); - - dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg); - dec_hpf_cut_of_freq = (dec_hpf_cut_of_freq & - CUT_OF_FREQ_MASK) >> 4; - - tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq = - dec_hpf_cut_of_freq; - - if ((dec_hpf_cut_of_freq != CF_MIN_3DB_150HZ)) { - /* Set cut off freq to CF_MIN_3DB_150HZ (0x01) */ - snd_soc_update_bits(codec, tx_mux_ctl_reg, - CUT_OF_FREQ_MASK, CF_MIN_3DB_150HZ << 4); - } - - /* enable HPF */ - snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x00); - - break; - - case SND_SOC_DAPM_POST_PMU: - /* Disable TX Digital Mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x00); - - if (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq != - CF_MIN_3DB_150HZ) { - schedule_delayed_work(&tx_hpf_work[decimator - 1].dwork, - msecs_to_jiffies(300)); - } - - /* Reprogram the digital gain after power up of Decimator */ - gain_reg = SITAR_A_CDC_TX1_VOL_CTL_GAIN + (8 * w->shift); - current_gain = snd_soc_read(codec, gain_reg); - snd_soc_write(codec, gain_reg, current_gain); - break; - - case SND_SOC_DAPM_PRE_PMD: - /* Enable Digital Mute, Cancel possibly scheduled work */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x01, 0x01); - cancel_delayed_work_sync(&tx_hpf_work[decimator - 1].dwork); - - break; - - case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x08, 0x08); - snd_soc_update_bits(codec, tx_mux_ctl_reg, CUT_OF_FREQ_MASK, - (tx_hpf_work[decimator - 1].tx_hpf_cut_of_freq) << 4); - break; - - } - -out: - kfree(widget_name); - return ret; - -} - -static int sitar_codec_reset_interpolator(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - u16 gain_reg; - u8 current_gain; - - pr_debug("%s %d %s\n", __func__, event, w->name); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_RX_RESET_CTL, - 1 << w->shift, 1 << w->shift); - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_RX_RESET_CTL, - 1 << w->shift, 0x0); - break; - case SND_SOC_DAPM_POST_PMU: - /* Reprogram gain after power up interpolator */ - gain_reg = SITAR_A_CDC_RX1_VOL_CTL_B2_CTL + (8 * w->shift); - current_gain = snd_soc_read(codec, gain_reg); - snd_soc_write(codec, gain_reg, current_gain); - } - return 0; -} - -static int sitar_codec_enable_ldo_h(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - switch (event) { - case SND_SOC_DAPM_POST_PMU: - case SND_SOC_DAPM_POST_PMD: - usleep_range(1000, 1000); - pr_debug("LDO_H\n"); - break; - } - return 0; -} - -static void sitar_enable_rx_bias(struct snd_soc_codec *codec, u32 enable) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - if (enable) { - sitar->rx_bias_count++; - if (sitar->rx_bias_count == 1) - snd_soc_update_bits(codec, SITAR_A_RX_COM_BIAS, - 0x80, 0x80); - } else { - sitar->rx_bias_count--; - if (!sitar->rx_bias_count) - snd_soc_update_bits(codec, SITAR_A_RX_COM_BIAS, - 0x80, 0x00); - } -} - -static int sitar_codec_enable_rx_bias(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - - pr_debug("%s %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - sitar_enable_rx_bias(codec, 1); - break; - case SND_SOC_DAPM_POST_PMD: - sitar_enable_rx_bias(codec, 0); - break; - } - return 0; -} -static int sitar_hph_dac_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - pr_debug("%s %s %d comp#1 enable %d\n", __func__, - w->name, event, sitar->comp_enabled[COMPANDER_1]); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - if (w->reg == SITAR_A_RX_HPH_L_DAC_CTL) { - if (!sitar->comp_enabled[COMPANDER_1]) { - snd_soc_update_bits(codec, - SITAR_A_CDC_CONN_CLSG_CTL, - 0x30, 0x20); - snd_soc_update_bits(codec, - SITAR_A_CDC_CONN_CLSG_CTL, - 0x0C, 0x08); - } - } - snd_soc_update_bits(codec, w->reg, 0x40, 0x40); - break; - case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, w->reg, 0x40, 0x00); - if (w->reg == SITAR_A_RX_HPH_L_DAC_CTL) { - snd_soc_update_bits(codec, SITAR_A_CDC_CONN_CLSG_CTL, - 0x30, 0x10); - snd_soc_update_bits(codec, SITAR_A_CDC_CONN_CLSG_CTL, - 0x0C, 0x04); - } - break; - } - return 0; -} - -static void sitar_snd_soc_jack_report(struct sitar_priv *sitar, - struct snd_soc_jack *jack, int status, - int mask) -{ - /* XXX: wake_lock_timeout()? */ - snd_soc_jack_report_no_dapm(jack, status, mask); -} - -static void hphocp_off_report(struct sitar_priv *sitar, - u32 jack_status, int irq) -{ - struct snd_soc_codec *codec; - - if (!sitar) { - pr_err("%s: Bad sitar private data\n", __func__); - return; - } - - pr_info("%s: clear ocp status %x\n", __func__, jack_status); - codec = sitar->codec; - if (sitar->hph_status & jack_status) { - sitar->hph_status &= ~jack_status; - if (sitar->mbhc_cfg.headset_jack) - sitar_snd_soc_jack_report(sitar, - sitar->mbhc_cfg.headset_jack, - sitar->hph_status, - SITAR_JACK_MASK); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, 0x10, 0x10); - /* reset retry counter as PA is turned off signifying - * start of new OCP detection session - */ - if (WCD9XXX_IRQ_HPH_PA_OCPL_FAULT) - sitar->hphlocp_cnt = 0; - else - sitar->hphrocp_cnt = 0; - wcd9xxx_enable_irq(codec->control_data, irq); - } -} - -static void hphlocp_off_report(struct work_struct *work) -{ - struct sitar_priv *sitar = container_of(work, struct sitar_priv, - hphlocp_work); - hphocp_off_report(sitar, SND_JACK_OC_HPHL, - WCD9XXX_IRQ_HPH_PA_OCPL_FAULT); -} - -static void hphrocp_off_report(struct work_struct *work) -{ - struct sitar_priv *sitar = container_of(work, struct sitar_priv, - hphrocp_work); - hphocp_off_report(sitar, SND_JACK_OC_HPHR, - WCD9XXX_IRQ_HPH_PA_OCPR_FAULT); -} - -static int sitar_hph_pa_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u8 mbhc_micb_ctl_val; - pr_debug("%s: event = %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - mbhc_micb_ctl_val = snd_soc_read(codec, - sitar->mbhc_bias_regs.ctl_reg); - - if (!(mbhc_micb_ctl_val & 0x80)) { - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - sitar_codec_switch_micbias(codec, 1); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - } - - if (sitar_is_line_pa_on(codec)) - sitar_enable_classg(codec, false); - else - sitar_enable_classg(codec, true); - - break; - - case SND_SOC_DAPM_POST_PMD: - /* schedule work is required because at the time HPH PA DAPM - * event callback is called by DAPM framework, CODEC dapm mutex - * would have been locked while snd_soc_jack_report also - * attempts to acquire same lock. - */ - if (w->shift == 5) { - clear_bit(SITAR_HPHL_PA_OFF_ACK, - &sitar->hph_pa_dac_state); - clear_bit(SITAR_HPHL_DAC_OFF_ACK, - &sitar->hph_pa_dac_state); - if (sitar->hph_status & SND_JACK_OC_HPHL) - schedule_work(&sitar->hphlocp_work); - } else if (w->shift == 4) { - clear_bit(SITAR_HPHR_PA_OFF_ACK, - &sitar->hph_pa_dac_state); - clear_bit(SITAR_HPHR_DAC_OFF_ACK, - &sitar->hph_pa_dac_state); - if (sitar->hph_status & SND_JACK_OC_HPHR) - schedule_work(&sitar->hphrocp_work); - } - - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - sitar_codec_switch_micbias(codec, 0); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - - pr_debug("%s: sleep 10 ms after %s PA disable.\n", __func__, - w->name); - usleep_range(10000, 10000); - - if (sitar_is_line_pa_on(codec)) - sitar_enable_classg(codec, true); - else - sitar_enable_classg(codec, false); - - break; - } - return 0; -} - -static void sitar_get_mbhc_micbias_regs(struct snd_soc_codec *codec, - struct mbhc_micbias_regs *micbias_regs) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - unsigned int cfilt; - - switch (sitar->mbhc_cfg.micbias) { - case SITAR_MICBIAS1: - cfilt = sitar->pdata->micbias.bias1_cfilt_sel; - micbias_regs->mbhc_reg = SITAR_A_MICB_1_MBHC; - micbias_regs->int_rbias = SITAR_A_MICB_1_INT_RBIAS; - micbias_regs->ctl_reg = SITAR_A_MICB_1_CTL; - break; - case SITAR_MICBIAS2: - cfilt = sitar->pdata->micbias.bias2_cfilt_sel; - micbias_regs->mbhc_reg = SITAR_A_MICB_2_MBHC; - micbias_regs->int_rbias = SITAR_A_MICB_2_INT_RBIAS; - micbias_regs->ctl_reg = SITAR_A_MICB_2_CTL; - break; - default: - /* Should never reach here */ - pr_err("%s: Invalid MIC BIAS for MBHC\n", __func__); - return; - } - - micbias_regs->cfilt_sel = cfilt; - - switch (cfilt) { - case SITAR_CFILT1_SEL: - micbias_regs->cfilt_val = SITAR_A_MICB_CFILT_1_VAL; - micbias_regs->cfilt_ctl = SITAR_A_MICB_CFILT_1_CTL; - sitar->mbhc_data.micb_mv = sitar->pdata->micbias.cfilt1_mv; - break; - case SITAR_CFILT2_SEL: - micbias_regs->cfilt_val = SITAR_A_MICB_CFILT_2_VAL; - micbias_regs->cfilt_ctl = SITAR_A_MICB_CFILT_2_CTL; - sitar->mbhc_data.micb_mv = sitar->pdata->micbias.cfilt2_mv; - break; - } -} - -static int sitar_codec_enable_charge_pump(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - - pr_debug("%s %d\n", __func__, event); - switch (event) { - case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_OTHR_CTL, 0x01, - 0x01); - snd_soc_update_bits(codec, SITAR_A_CDC_CLSG_CTL, 0x08, 0x08); - usleep_range(200, 200); - break; - case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, SITAR_A_CDC_CLSG_CTL, 0x08, 0x00); - /* - * This delay is for the class G controller to settle down - * after turn OFF. The delay is as per the hardware spec for - * the codec - */ - usleep_range(20, 20); - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_OTHR_CTL, 0x01, - 0x00); - break; - } - return 0; -} - -static int sitar_ear_pa_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - switch (event) { - case SND_SOC_DAPM_POST_PMU: - pr_debug("%s: Sleeping 20ms after enabling EAR PA\n", - __func__); - msleep(20); - break; - case SND_SOC_DAPM_POST_PMD: - pr_debug("%s: Sleeping 20ms after disabling EAR PA\n", - __func__); - msleep(20); - break; - } - return 0; -} - -static const struct snd_soc_dapm_widget sitar_dapm_i2s_widgets[] = { - SND_SOC_DAPM_SUPPLY("RX_I2S_CLK", SITAR_A_CDC_CLK_RX_I2S_CTL, - 4, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("TX_I2S_CLK", SITAR_A_CDC_CLK_TX_I2S_CTL, 4, - 0, NULL, 0), -}; - -static const struct snd_soc_dapm_widget sitar_dapm_widgets[] = { - /*RX stuff */ - SND_SOC_DAPM_OUTPUT("EAR"), - - SND_SOC_DAPM_PGA_E("EAR PA", SITAR_A_RX_EAR_EN, 4, 0, NULL, 0, - sitar_ear_pa_event, SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_MIXER("DAC1", SITAR_A_RX_EAR_EN, 6, 0, dac1_switch, - ARRAY_SIZE(dac1_switch)), - SND_SOC_DAPM_SUPPLY("EAR DRIVER", SITAR_A_RX_EAR_EN, 3, 0, NULL, 0), - - SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM, - AIF1_PB, 0, sitar_codec_enable_slimrx, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, SITAR_RX1, 0, - &sitar_aif_pb_mux[SITAR_RX1]), - SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, SITAR_RX2, 0, - &sitar_aif_pb_mux[SITAR_RX2]), - SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, SITAR_RX3, 0, - &sitar_aif_pb_mux[SITAR_RX3]), - SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, SITAR_RX4, 0, - &sitar_aif_pb_mux[SITAR_RX4]), - SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, SITAR_RX5, 0, - &sitar_aif_pb_mux[SITAR_RX5]), - - SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0), - - /* Headphone */ - SND_SOC_DAPM_OUTPUT("HEADPHONE"), - SND_SOC_DAPM_PGA_E("HPHL", SITAR_A_RX_HPH_CNP_EN, 5, 0, NULL, 0, - sitar_hph_pa_event, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_PGA_E("HPHR", SITAR_A_RX_HPH_CNP_EN, 4, 0, NULL, 0, - sitar_hph_pa_event, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_DAC_E("HPHL DAC", NULL, SITAR_A_RX_HPH_L_DAC_CTL, 7, 0, - sitar_hph_dac_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_DAC_E("HPHR DAC", NULL, SITAR_A_RX_HPH_R_DAC_CTL, 7, 0, - sitar_hph_dac_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - /* Speaker */ - SND_SOC_DAPM_OUTPUT("LINEOUT1"), - SND_SOC_DAPM_OUTPUT("LINEOUT2"), - - SND_SOC_DAPM_DAC_E("LINEOUT1 DAC", NULL, SITAR_A_RX_LINE_1_DAC_CTL, 7, 0 - , sitar_lineout_dac_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_DAC_E("LINEOUT2 DAC", NULL, SITAR_A_RX_LINE_2_DAC_CTL, 7, 0 - , sitar_lineout_dac_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_PGA_E("LINEOUT1 PA", SITAR_A_RX_LINE_CNP_EN, 0, 0, NULL, - 0, sitar_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_PGA_E("LINEOUT2 PA", SITAR_A_RX_LINE_CNP_EN, 1, 0, NULL, - 0, sitar_codec_enable_lineout, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MIXER_E("RX1 MIX1", SITAR_A_CDC_CLK_RX_B1_CTL, 0, 0, NULL, - 0, sitar_codec_reset_interpolator, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), - SND_SOC_DAPM_MIXER_E("RX2 MIX1", SITAR_A_CDC_CLK_RX_B1_CTL, 1, 0, NULL, - 0, sitar_codec_reset_interpolator, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), - SND_SOC_DAPM_MIXER_E("RX3 MIX1", SITAR_A_CDC_CLK_RX_B1_CTL, 2, 0, NULL, - 0, sitar_codec_reset_interpolator, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), - - SND_SOC_DAPM_MUX("DAC1 MUX", SND_SOC_NOPM, 0, 0, - &rx_dac1_mux), - SND_SOC_DAPM_MUX("DAC2 MUX", SND_SOC_NOPM, 0, 0, - &rx_dac2_mux), - SND_SOC_DAPM_MUX("DAC3 MUX", SND_SOC_NOPM, 0, 0, - &rx_dac3_mux), - SND_SOC_DAPM_MUX("DAC4 MUX", SND_SOC_NOPM, 0, 0, - &rx_dac4_mux), - - SND_SOC_DAPM_MIXER_E("RX1 CHAIN", SND_SOC_NOPM, 0, 0, NULL, - 0, sitar_codec_dem_input_selection, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), - SND_SOC_DAPM_MIXER_E("RX2 CHAIN", SND_SOC_NOPM, 1, 0, NULL, - 0, sitar_codec_dem_input_selection, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), - SND_SOC_DAPM_MIXER_E("RX3 CHAIN", SND_SOC_NOPM, 2, 0, NULL, - 0, sitar_codec_dem_input_selection, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), - - SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0, - &rx_mix1_inp1_mux), - SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0, - &rx_mix1_inp2_mux), - SND_SOC_DAPM_MUX("RX2 MIX1 INP1", SND_SOC_NOPM, 0, 0, - &rx2_mix1_inp1_mux), - SND_SOC_DAPM_MUX("RX2 MIX1 INP2", SND_SOC_NOPM, 0, 0, - &rx2_mix1_inp2_mux), - SND_SOC_DAPM_MUX("RX3 MIX1 INP1", SND_SOC_NOPM, 0, 0, - &rx3_mix1_inp1_mux), - SND_SOC_DAPM_MUX("RX3 MIX1 INP2", SND_SOC_NOPM, 0, 0, - &rx3_mix1_inp2_mux), - - SND_SOC_DAPM_SUPPLY("CP", SITAR_A_CP_EN, 0, 0, - sitar_codec_enable_charge_pump, SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_PRE_PMD), - SND_SOC_DAPM_SUPPLY("RX_BIAS", SND_SOC_NOPM, 0, 0, - sitar_codec_enable_rx_bias, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SUPPLY("LDO_H", SITAR_A_LDO_H_MODE_1, 7, 0, - sitar_codec_enable_ldo_h, SND_SOC_DAPM_POST_PMU), - /* TX */ - - SND_SOC_DAPM_SUPPLY("CDC_CONN", SITAR_A_CDC_CLK_OTHR_CTL, 2, 0, NULL, - 0), - SND_SOC_DAPM_INPUT("AMIC1"), - SND_SOC_DAPM_INPUT("AMIC2"), - SND_SOC_DAPM_INPUT("AMIC3"), - SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 External", SITAR_A_MICB_1_CTL, 7, 0, - sitar_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_MICBIAS_E("MIC BIAS1 Internal1", SITAR_A_MICB_1_CTL, 7, 0, - sitar_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 External", SITAR_A_MICB_2_CTL, 7, 0, - sitar_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal1", SITAR_A_MICB_2_CTL, 7, 0, - sitar_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_MICBIAS_E("MIC BIAS2 Internal2", SITAR_A_MICB_2_CTL, 7, 0, - sitar_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_ADC_E("ADC1", NULL, SITAR_A_TX_1_2_EN, 7, 0, - sitar_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_ADC_E("ADC2", NULL, SITAR_A_TX_1_2_EN, 3, 0, - sitar_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_ADC_E("ADC3", NULL, SITAR_A_TX_3_EN, 7, 0, - sitar_codec_enable_adc, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MUX_E("DEC1 MUX", SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL, 0, 0, - &dec1_mux, sitar_codec_enable_dec, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MUX_E("DEC2 MUX", SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL, 1, 0, - &dec2_mux, sitar_codec_enable_dec, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MUX_E("DEC3 MUX", SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL, 2, 0, - &dec3_mux, sitar_codec_enable_dec, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MUX_E("DEC4 MUX", SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL, 3, 0, - &dec4_mux, sitar_codec_enable_dec, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MUX("ANC1 MUX", SND_SOC_NOPM, 0, 0, &anc1_mux), - SND_SOC_DAPM_MUX("ANC2 MUX", SND_SOC_NOPM, 0, 0, &anc2_mux), - - SND_SOC_DAPM_MIXER_E("ANC", SND_SOC_NOPM, 0, 0, NULL, 0, - sitar_codec_enable_anc, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux), - - SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM, - AIF1_CAP, 0, sitar_codec_enable_slimtx, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0, - sitar_aif_cap_mixer, ARRAY_SIZE(sitar_aif_cap_mixer)), - - SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, SITAR_TX1, 0, - &sb_tx1_mux), - SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, SITAR_TX2, 0, - &sb_tx2_mux), - SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, SITAR_TX3, 0, - &sb_tx3_mux), - SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, SITAR_TX3, 0, - &sb_tx4_mux), - SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, SITAR_TX3, 0, - &sb_tx5_mux), - - SND_SOC_DAPM_AIF_OUT_E("SLIM TX5", "AIF1 Capture", 0, SND_SOC_NOPM, 0, - 0, sitar_codec_enable_slimtx, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - /* Digital Mic Inputs */ - SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, - sitar_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0, - sitar_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0, - sitar_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0, - sitar_codec_enable_dmic, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SUPPLY("COMP1_CLK", SND_SOC_NOPM, COMPANDER_1, 0, - sitar_config_compander, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_SUPPLY("COMP2_CLK", SND_SOC_NOPM, COMPANDER_2, 0, - sitar_config_compander, SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - - /* Sidetone */ - SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux), - SND_SOC_DAPM_PGA("IIR1", SITAR_A_CDC_CLK_SD_CTL, 0, 0, NULL, 0), - SND_SOC_DAPM_MUX("IIR2 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir2_inp1_mux), - SND_SOC_DAPM_PGA("IIR2", SITAR_A_CDC_CLK_SD_CTL, 1, 0, NULL, 0), - -}; - -static const struct snd_soc_dapm_route audio_i2s_map[] = { - {"RX_I2S_CLK", NULL, "CP"}, - {"RX_I2S_CLK", NULL, "CDC_CONN"}, - {"SLIM RX1", NULL, "RX_I2S_CLK"}, - {"SLIM RX2", NULL, "RX_I2S_CLK"}, - {"SLIM RX3", NULL, "RX_I2S_CLK"}, - {"SLIM RX4", NULL, "RX_I2S_CLK"}, - - {"SLIM TX1", NULL, "TX_I2S_CLK"}, - {"SLIM TX2", NULL, "TX_I2S_CLK"}, - {"SLIM TX3", NULL, "TX_I2S_CLK"}, - {"SLIM TX4", NULL, "TX_I2S_CLK"}, -}; -#define SLIM_MIXER(x) (\ - {x, "SLIM TX1", "SLIM TX1 MUX"}, \ - {x, "SLIM TX2", "SLIM TX2 MUX"}, \ - {x, "SLIM TX3", "SLIM TX3 MUX"}, \ - {x, "SLIM TX4", "SLIM TX4 MUX"}) - - -#define SLIM_MUX(x, y) (\ - {"SLIM RX1 MUX", x, y}, \ - {"SLIM RX2 MUX", x, y}, \ - {"SLIM RX3 MUX", x, y}, \ - {"SLIM RX4 MUX", x, y}) - -static const struct snd_soc_dapm_route audio_map[] = { - /* Earpiece (RX MIX1) */ - {"EAR", NULL, "EAR PA"}, - {"EAR PA", "NULL", "DAC1"}, - {"DAC1", "Switch", "DAC1 MUX"}, - {"DAC1", NULL, "CP"}, - {"DAC1", NULL, "EAR DRIVER"}, - - {"CP", NULL, "RX_BIAS"}, - - {"LINEOUT1 DAC", NULL, "RX_BIAS"}, - {"LINEOUT2 DAC", NULL, "RX_BIAS"}, - - {"LINEOUT2", NULL, "LINEOUT2 PA"}, - {"LINEOUT2 PA", NULL, "CP"}, - {"LINEOUT2 PA", NULL, "LINEOUT2 DAC"}, - {"LINEOUT2 DAC", NULL, "DAC3 MUX"}, - - {"LINEOUT1", NULL, "LINEOUT1 PA"}, - {"LINEOUT2 PA", NULL, "CP"}, - {"LINEOUT1 PA", NULL, "LINEOUT1 DAC"}, - {"LINEOUT1 DAC", NULL, "DAC2 MUX"}, - - {"ANC1 FB MUX", "EAR_HPH_L", "RX2 MIX1"}, - {"ANC1 FB MUX", "EAR_LINE_1", "RX3 MIX1"}, - {"ANC", NULL, "ANC1 FB MUX"}, - - - /* Headset (RX MIX1 and RX MIX2) */ - {"HEADPHONE", NULL, "HPHL"}, - {"HEADPHONE", NULL, "HPHR"}, - - - {"HPHL DAC", NULL, "CP"}, - {"HPHR DAC", NULL, "CP"}, - - {"HPHL", NULL, "HPHL DAC"}, - {"HPHL DAC", "NULL", "RX2 CHAIN"}, - {"RX2 CHAIN", NULL, "DAC4 MUX"}, - {"HPHR", NULL, "HPHR DAC"}, - {"HPHR DAC", NULL, "RX3 CHAIN"}, - {"RX3 CHAIN", NULL, "RX3 MIX1"}, - - {"DAC1 MUX", "RX1", "RX1 CHAIN"}, - {"DAC2 MUX", "RX1", "RX1 CHAIN"}, - - {"DAC3 MUX", "RX1", "RX1 CHAIN"}, - {"DAC3 MUX", "INV_RX1", "RX1 CHAIN"}, - {"DAC3 MUX", "RX2", "RX2 MIX1"}, - - {"DAC4 MUX", "ON", "RX2 MIX1"}, - - {"RX1 CHAIN", NULL, "RX1 MIX1"}, - - {"RX1 MIX1", NULL, "RX1 MIX1 INP1"}, - {"RX1 MIX1", NULL, "RX1 MIX1 INP2"}, - {"RX2 MIX1", NULL, "RX2 MIX1 INP1"}, - {"RX2 MIX1", NULL, "RX2 MIX1 INP2"}, - {"RX3 MIX1", NULL, "RX3 MIX1 INP1"}, - {"RX3 MIX1", NULL, "RX3 MIX1 INP2"}, - - /* ANC */ - {"ANC", NULL, "ANC1 MUX"}, - {"ANC", NULL, "ANC2 MUX"}, - {"ANC1 MUX", "ADC1", "ADC1"}, - {"ANC1 MUX", "ADC2", "ADC2"}, - {"ANC1 MUX", "ADC3", "ADC3"}, - {"ANC2 MUX", "ADC1", "ADC1"}, - {"ANC2 MUX", "ADC2", "ADC2"}, - {"ANC2 MUX", "ADC3", "ADC3"}, - - {"ANC", NULL, "CDC_CONN"}, - - {"RX2 MIX1", NULL, "ANC"}, - {"RX3 MIX1", NULL, "ANC"}, - - /* SLIMBUS Connections */ - {"AIF1 CAP", NULL, "AIF1_CAP Mixer"}, - - /* SLIM_MIXER("AIF1_CAP Mixer"),*/ - {"AIF1_CAP Mixer", "SLIM TX1", "SLIM TX1 MUX"}, - {"AIF1_CAP Mixer", "SLIM TX2", "SLIM TX2 MUX"}, - {"AIF1_CAP Mixer", "SLIM TX3", "SLIM TX3 MUX"}, - {"AIF1_CAP Mixer", "SLIM TX4", "SLIM TX4 MUX"}, - /* SLIM_MUX("AIF1_PB", "AIF1 PB"), */ - {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"}, - {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"}, - {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"}, - {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"}, - - {"SLIM RX1", NULL, "SLIM RX1 MUX"}, - {"SLIM RX2", NULL, "SLIM RX2 MUX"}, - {"SLIM RX3", NULL, "SLIM RX3 MUX"}, - {"SLIM RX4", NULL, "SLIM RX4 MUX"}, - - {"RX1 MIX1", NULL, "COMP2_CLK"}, - {"RX2 MIX1", NULL, "COMP1_CLK"}, - {"RX3 MIX1", NULL, "COMP1_CLK"}, - - /* Slimbus port 5 is non functional in Sitar 1.0 */ - {"RX1 MIX1 INP1", "RX1", "SLIM RX1"}, - {"RX1 MIX1 INP1", "RX2", "SLIM RX2"}, - {"RX1 MIX1 INP1", "RX3", "SLIM RX3"}, - {"RX1 MIX1 INP1", "RX4", "SLIM RX4"}, - {"RX1 MIX1 INP1", "IIR1", "IIR1"}, - {"RX1 MIX1 INP1", "IIR2", "IIR2"}, - {"RX1 MIX1 INP2", "RX1", "SLIM RX1"}, - {"RX1 MIX1 INP2", "RX2", "SLIM RX2"}, - {"RX1 MIX1 INP2", "RX3", "SLIM RX3"}, - {"RX1 MIX1 INP2", "RX4", "SLIM RX4"}, - {"RX1 MIX1 INP2", "IIR1", "IIR1"}, - {"RX1 MIX1 INP2", "IIR2", "IIR2"}, - {"RX2 MIX1 INP1", "RX1", "SLIM RX1"}, - {"RX2 MIX1 INP1", "RX2", "SLIM RX2"}, - {"RX2 MIX1 INP1", "RX3", "SLIM RX3"}, - {"RX2 MIX1 INP1", "RX4", "SLIM RX4"}, - {"RX2 MIX1 INP1", "IIR1", "IIR1"}, - {"RX2 MIX1 INP1", "IIR2", "IIR2"}, - {"RX2 MIX1 INP2", "RX1", "SLIM RX1"}, - {"RX2 MIX1 INP2", "RX2", "SLIM RX2"}, - {"RX2 MIX1 INP2", "RX3", "SLIM RX3"}, - {"RX2 MIX1 INP2", "RX4", "SLIM RX4"}, - {"RX2 MIX1 INP2", "IIR1", "IIR1"}, - {"RX2 MIX1 INP2", "IIR2", "IIR2"}, - {"RX3 MIX1 INP1", "RX1", "SLIM RX1"}, - {"RX3 MIX1 INP1", "RX2", "SLIM RX2"}, - {"RX3 MIX1 INP1", "RX3", "SLIM RX3"}, - {"RX3 MIX1 INP1", "RX4", "SLIM RX4"}, - {"RX3 MIX1 INP1", "IIR1", "IIR1"}, - {"RX3 MIX1 INP1", "IIR2", "IIR2"}, - {"RX3 MIX1 INP2", "RX1", "SLIM RX1"}, - {"RX3 MIX1 INP2", "RX2", "SLIM RX2"}, - {"RX3 MIX1 INP2", "RX3", "SLIM RX3"}, - {"RX3 MIX1 INP2", "RX4", "SLIM RX4"}, - {"RX3 MIX1 INP2", "IIR1", "IIR1"}, - {"RX3 MIX1 INP2", "IIR2", "IIR2"}, - - - /* TX */ - {"SLIM TX1 MUX", "DEC1", "DEC1 MUX"}, - {"SLIM TX2 MUX", "DEC2", "DEC2 MUX"}, - {"SLIM TX3 MUX", "DEC3", "DEC3 MUX"}, - {"SLIM TX4 MUX", "DEC4", "DEC4 MUX"}, - {"SLIM TX5 MUX", "DEC1", "DEC1 MUX"}, - {"SLIM TX5 MUX", "DEC2", "DEC2 MUX"}, - {"SLIM TX5 MUX", "DEC3", "DEC3 MUX"}, - {"SLIM TX5 MUX", "DEC4", "DEC4 MUX"}, - - /* Decimator Inputs */ - {"DEC1 MUX", "DMIC1", "DMIC1"}, - {"DEC1 MUX", "DMIC4", "DMIC4"}, - {"DEC1 MUX", "ADC1", "ADC1"}, - {"DEC1 MUX", "ADC2", "ADC2"}, - {"DEC1 MUX", "ADC3", "ADC3"}, - {"DEC1 MUX", NULL, "CDC_CONN"}, - {"DEC2 MUX", "DMIC2", "DMIC2"}, - {"DEC2 MUX", "DMIC3", "DMIC3"}, - {"DEC2 MUX", "ADC1", "ADC1"}, - {"DEC2 MUX", "ADC2", "ADC2"}, - {"DEC2 MUX", "ADC3", "ADC3"}, - {"DEC2 MUX", NULL, "CDC_CONN"}, - {"DEC3 MUX", "DMIC3", "DMIC3"}, - {"DEC3 MUX", "ADC1", "ADC1"}, - {"DEC3 MUX", "ADC2", "ADC2"}, - {"DEC3 MUX", "ADC3", "ADC3"}, - {"DEC3 MUX", "DMIC2", "DMIC2"}, - {"DEC3 MUX", "DMIC4", "DMIC4"}, - {"DEC3 MUX", NULL, "CDC_CONN"}, - {"DEC4 MUX", "DMIC4", "DMIC4"}, - {"DEC4 MUX", "ADC1", "ADC1"}, - {"DEC4 MUX", "ADC2", "ADC2"}, - {"DEC4 MUX", "ADC3", "ADC3"}, - {"DEC4 MUX", "DMIC3", "DMIC3"}, - {"DEC4 MUX", "DMIC2", "DMIC2"}, - {"DEC4 MUX", "DMIC1", "DMIC1"}, - {"DEC4 MUX", NULL, "CDC_CONN"}, - - /* ADC Connections */ - {"ADC1", NULL, "AMIC1"}, - {"ADC2", NULL, "AMIC2"}, - {"ADC3", NULL, "AMIC3"}, - - /* IIR */ - {"IIR1", NULL, "IIR1 INP1 MUX"}, - {"IIR1 INP1 MUX", "DEC1", "DEC1 MUX"}, - {"IIR1 INP1 MUX", "DEC2", "DEC2 MUX"}, - {"IIR1 INP1 MUX", "DEC3", "DEC3 MUX"}, - {"IIR1 INP1 MUX", "DEC4", "DEC4 MUX"}, - {"IIR1 INP1 MUX", "RX1", "SLIM RX1"}, - {"IIR1 INP1 MUX", "RX2", "SLIM RX2"}, - {"IIR1 INP1 MUX", "RX3", "SLIM RX3"}, - {"IIR1 INP1 MUX", "RX4", "SLIM RX4"}, - {"IIR1 INP1 MUX", "RX5", "SLIM RX5"}, - - {"IIR2", NULL, "IIR2 INP1 MUX"}, - {"IIR2 INP1 MUX", "DEC1", "DEC1 MUX"}, - {"IIR2 INP1 MUX", "DEC2", "DEC2 MUX"}, - {"IIR2 INP1 MUX", "DEC3", "DEC3 MUX"}, - {"IIR2 INP1 MUX", "DEC4", "DEC4 MUX"}, - {"IIR2 INP1 MUX", "RX1", "SLIM RX1"}, - {"IIR2 INP1 MUX", "RX2", "SLIM RX2"}, - {"IIR2 INP1 MUX", "RX3", "SLIM RX3"}, - {"IIR2 INP1 MUX", "RX4", "SLIM RX4"}, - {"IIR2 INP1 MUX", "RX5", "SLIM RX5"}, - - {"MIC BIAS1 Internal1", NULL, "LDO_H"}, - {"MIC BIAS1 External", NULL, "LDO_H"}, - {"MIC BIAS2 Internal1", NULL, "LDO_H"}, - {"MIC BIAS2 External", NULL, "LDO_H"}, -}; - -static int sitar_readable(struct snd_soc_codec *ssc, unsigned int reg) -{ - return sitar_reg_readable[reg]; -} - -static int sitar_volatile(struct snd_soc_codec *ssc, unsigned int reg) -{ - int i; - - /* Registers lower than 0x100 are top level registers which can be - * written by the Sitar core driver. - */ - if ((reg >= SITAR_A_CDC_MBHC_EN_CTL) || (reg < 0x100)) - return 1; - - /* IIR Coeff registers are not cacheable */ - if ((reg >= SITAR_A_CDC_IIR1_COEF_B1_CTL) && - (reg <= SITAR_A_CDC_IIR1_COEF_B5_CTL)) - return 1; - - for (i = 0; i < NUM_DECIMATORS; i++) { - if (reg == SITAR_A_CDC_TX1_VOL_CTL_GAIN + (8 * i)) - return 1; - } - - for (i = 0; i < NUM_INTERPOLATORS; i++) { - if (reg == SITAR_A_CDC_RX1_VOL_CTL_B2_CTL + (8 * i)) - return 1; - } - - if ((reg == SITAR_A_CDC_COMP1_SHUT_DOWN_STATUS) || - (reg == SITAR_A_CDC_COMP2_SHUT_DOWN_STATUS)) - return 1; - return 0; -} - -#define SITAR_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) -static int sitar_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int value) -{ - int ret; - - if (reg == SND_SOC_NOPM) - return 0; - - BUG_ON(reg > SITAR_MAX_REGISTER); - - if (!sitar_volatile(codec, reg)) { - ret = snd_soc_cache_write(codec, reg, value); - if (ret != 0) - dev_err(codec->dev, "Cache write to %x failed: %d\n", - reg, ret); - } - - return wcd9xxx_reg_write(codec->control_data, reg, value); -} -static unsigned int sitar_read(struct snd_soc_codec *codec, - unsigned int reg) -{ - unsigned int val; - int ret; - - if (reg == SND_SOC_NOPM) - return 0; - - BUG_ON(reg > SITAR_MAX_REGISTER); - - if (!sitar_volatile(codec, reg) && sitar_readable(codec, reg) && - reg < codec->driver->reg_cache_size) { - ret = snd_soc_cache_read(codec, reg, &val); - if (ret >= 0) { - return val; - } else - dev_err(codec->dev, "Cache read from %x failed: %d\n", - reg, ret); - } - - val = wcd9xxx_reg_read(codec->control_data, reg); - return val; -} - -static void sitar_codec_enable_audio_mode_bandgap(struct snd_soc_codec *codec) -{ - struct wcd9xxx *sitar_core = dev_get_drvdata(codec->dev->parent); - - if (SITAR_IS_1P0(sitar_core->version)) - snd_soc_update_bits(codec, SITAR_A_LDO_H_MODE_1, 0x80, 0x80); - - snd_soc_update_bits(codec, SITAR_A_BIAS_CURR_CTL_2, 0x0C, 0x08); - usleep_range(1000, 1000); - snd_soc_write(codec, SITAR_A_BIAS_REF_CTL, 0x1C); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x80, - 0x80); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x04, - 0x04); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x01, - 0x01); - usleep_range(1000, 1000); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x80, - 0x00); -} - -static void sitar_codec_enable_bandgap(struct snd_soc_codec *codec, - enum sitar_bandgap_type choice) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *sitar_core = dev_get_drvdata(codec->dev->parent); - - /* TODO lock resources accessed by audio streams and threaded - * interrupt handlers - */ - - pr_debug("%s, choice is %d, current is %d\n", __func__, choice, - sitar->bandgap_type); - - if (sitar->bandgap_type == choice) - return; - - if ((sitar->bandgap_type == SITAR_BANDGAP_OFF) && - (choice == SITAR_BANDGAP_AUDIO_MODE)) { - sitar_codec_enable_audio_mode_bandgap(codec); - } else if (choice == SITAR_BANDGAP_MBHC_MODE) { - snd_soc_update_bits(codec, SITAR_A_BIAS_CURR_CTL_2, 0x0C, 0x08); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x2, - 0x2); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x80, - 0x80); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x4, - 0x4); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x01, - 0x1); - usleep_range(1000, 1000); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x80, - 0x00); - } else if ((sitar->bandgap_type == SITAR_BANDGAP_MBHC_MODE) && - (choice == SITAR_BANDGAP_AUDIO_MODE)) { - snd_soc_write(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x50); - usleep_range(100, 100); - sitar_codec_enable_audio_mode_bandgap(codec); - } else if (choice == SITAR_BANDGAP_OFF) { - snd_soc_update_bits(codec, SITAR_A_BIAS_CURR_CTL_2, 0x0C, 0x00); - snd_soc_write(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x50); - if (SITAR_IS_1P0(sitar_core->version)) - snd_soc_update_bits(codec, SITAR_A_LDO_H_MODE_1, - 0xF3, 0x61); - usleep_range(1000, 1000); - } else { - pr_err("%s: Error, Invalid bandgap settings\n", __func__); - } - sitar->bandgap_type = choice; -} - -static int sitar_codec_enable_config_mode(struct snd_soc_codec *codec, - int enable) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - if (enable) { - snd_soc_update_bits(codec, SITAR_A_RC_OSC_FREQ, 0x10, 0); - snd_soc_write(codec, SITAR_A_BIAS_OSC_BG_CTL, 0x17); - usleep_range(5, 5); - snd_soc_update_bits(codec, SITAR_A_RC_OSC_FREQ, 0x80, - 0x80); - snd_soc_update_bits(codec, SITAR_A_RC_OSC_TEST, 0x80, - 0x80); - usleep_range(10, 10); - snd_soc_update_bits(codec, SITAR_A_RC_OSC_TEST, 0x80, 0); - usleep_range(20, 20); - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN1, 0x08, 0x08); - } else { - snd_soc_update_bits(codec, SITAR_A_BIAS_OSC_BG_CTL, 0x1, - 0); - snd_soc_update_bits(codec, SITAR_A_RC_OSC_FREQ, 0x80, 0); - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN1, 0x08, 0x00); - } - sitar->config_mode_active = enable ? true : false; - - return 0; -} - -static int sitar_codec_enable_clock_block(struct snd_soc_codec *codec, - int config_mode) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - pr_debug("%s\n", __func__); - - if (config_mode) { - sitar_codec_enable_config_mode(codec, 1); - snd_soc_write(codec, SITAR_A_CLK_BUFF_EN2, 0x00); - snd_soc_write(codec, SITAR_A_CLK_BUFF_EN2, 0x02); - snd_soc_write(codec, SITAR_A_CLK_BUFF_EN1, 0x0D); - usleep_range(1000, 1000); - } else - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN1, 0x08, 0x00); - - if (!config_mode && sitar->mbhc_polling_active) { - snd_soc_write(codec, SITAR_A_CLK_BUFF_EN2, 0x02); - sitar_codec_enable_config_mode(codec, 0); - - } - - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN1, 0x05, 0x05); - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN2, 0x02, 0x00); - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN2, 0x04, 0x04); - usleep_range(50, 50); - sitar->clock_active = true; - return 0; -} -static void sitar_codec_disable_clock_block(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - pr_debug("%s\n", __func__); - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN2, 0x04, 0x00); - ndelay(160); - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN2, 0x02, 0x02); - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN1, 0x05, 0x00); - sitar->clock_active = false; -} - -static int sitar_codec_mclk_index(const struct sitar_priv *sitar) -{ - if (sitar->mbhc_cfg.mclk_rate == SITAR_MCLK_RATE_12288KHZ) - return 0; - else if (sitar->mbhc_cfg.mclk_rate == SITAR_MCLK_RATE_9600KHZ) - return 1; - else { - BUG_ON(1); - return -EINVAL; - } -} - -static void sitar_codec_calibrate_hs_polling(struct snd_soc_codec *codec) -{ - u8 *n_ready, *n_cic; - struct sitar_mbhc_btn_detect_cfg *btn_det; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - btn_det = SITAR_MBHC_CAL_BTN_DET_PTR(sitar->mbhc_cfg.calibration); - - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B1_CTL, - sitar->mbhc_data.v_ins_hu & 0xFF); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B2_CTL, - (sitar->mbhc_data.v_ins_hu >> 8) & 0xFF); - - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B3_CTL, - sitar->mbhc_data.v_b1_hu & 0xFF); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B4_CTL, - (sitar->mbhc_data.v_b1_hu >> 8) & 0xFF); - - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B5_CTL, - sitar->mbhc_data.v_b1_h & 0xFF); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B6_CTL, - (sitar->mbhc_data.v_b1_h >> 8) & 0xFF); - - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B9_CTL, - sitar->mbhc_data.v_brh & 0xFF); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B10_CTL, - (sitar->mbhc_data.v_brh >> 8) & 0xFF); - - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B11_CTL, - sitar->mbhc_data.v_brl & 0xFF); - snd_soc_write(codec, SITAR_A_CDC_MBHC_VOLT_B12_CTL, - (sitar->mbhc_data.v_brl >> 8) & 0xFF); - - n_ready = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_N_READY); - snd_soc_write(codec, SITAR_A_CDC_MBHC_TIMER_B1_CTL, - n_ready[sitar_codec_mclk_index(sitar)]); - snd_soc_write(codec, SITAR_A_CDC_MBHC_TIMER_B2_CTL, - sitar->mbhc_data.npoll); - snd_soc_write(codec, SITAR_A_CDC_MBHC_TIMER_B3_CTL, - sitar->mbhc_data.nbounce_wait); - n_cic = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_N_CIC); - snd_soc_write(codec, SITAR_A_CDC_MBHC_TIMER_B6_CTL, - n_cic[sitar_codec_mclk_index(sitar)]); -} - -static int sitar_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct wcd9xxx *wcd9xxx = dev_get_drvdata(dai->codec->dev->parent); - if ((wcd9xxx != NULL) && (wcd9xxx->dev != NULL) && - (wcd9xxx->dev->parent != NULL)) - pm_runtime_get_sync(wcd9xxx->dev->parent); - pr_debug("%s(): substream = %s stream = %d\n" , __func__, - substream->name, substream->stream); - - return 0; -} - -static void sitar_codec_pm_runtime_put(struct wcd9xxx *sitar) -{ - if (sitar->dev != NULL && - sitar->dev->parent != NULL) { - pm_runtime_mark_last_busy(sitar->dev->parent); - pm_runtime_put(sitar->dev->parent); - } -} - -static void sitar_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct wcd9xxx *sitar_core = dev_get_drvdata(dai->codec->dev->parent); - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(dai->codec); - u32 active = 0; - - pr_debug("%s(): substream = %s stream = %d\n" , __func__, - substream->name, substream->stream); - if (sitar->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) - return; - - if (dai->id <= NUM_CODEC_DAIS) { - if (sitar->dai[dai->id].ch_mask) { - active = 1; - pr_debug("%s(): Codec DAI: chmask[%d] = 0x%lx\n", - __func__, dai->id, - sitar->dai[dai->id].ch_mask); - } - } - - if (sitar_core != NULL && active == 0) - sitar_codec_pm_runtime_put(sitar_core); -} - -int sitar_mclk_enable(struct snd_soc_codec *codec, int mclk_enable, bool dapm) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - pr_debug("%s() mclk_enable = %u\n", __func__, mclk_enable); - - if (dapm) - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - if (mclk_enable) { - sitar->mclk_enabled = true; - - if (sitar->mbhc_polling_active && (sitar->mclk_enabled)) { - sitar_codec_pause_hs_polling(codec); - sitar_codec_enable_bandgap(codec, - SITAR_BANDGAP_AUDIO_MODE); - sitar_codec_enable_clock_block(codec, 0); - sitar_codec_calibrate_hs_polling(codec); - sitar_codec_start_hs_polling(codec); - } else { - sitar_codec_enable_bandgap(codec, - SITAR_BANDGAP_AUDIO_MODE); - sitar_codec_enable_clock_block(codec, 0); - } - } else { - - if (!sitar->mclk_enabled) { - if (dapm) - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - pr_err("Error, MCLK already diabled\n"); - return -EINVAL; - } - sitar->mclk_enabled = false; - - if (sitar->mbhc_polling_active) { - if (!sitar->mclk_enabled) { - sitar_codec_pause_hs_polling(codec); - sitar_codec_enable_bandgap(codec, - SITAR_BANDGAP_MBHC_MODE); - sitar_enable_rx_bias(codec, 1); - sitar_codec_enable_clock_block(codec, 1); - sitar_codec_calibrate_hs_polling(codec); - sitar_codec_start_hs_polling(codec); - } - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN1, - 0x05, 0x01); - } else { - sitar_codec_disable_clock_block(codec); - sitar_codec_enable_bandgap(codec, - SITAR_BANDGAP_OFF); - } - } - if (dapm) - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - return 0; -} - -static int sitar_set_dai_sysclk(struct snd_soc_dai *dai, - int clk_id, unsigned int freq, int dir) -{ - pr_debug("%s\n", __func__); - return 0; -} - -static int sitar_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) -{ - u8 val = 0; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(dai->codec); - - pr_debug("%s\n", __func__); - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - /* CPU is master */ - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { - if (dai->id == AIF1_CAP) - snd_soc_update_bits(dai->codec, - SITAR_A_CDC_CLK_TX_I2S_CTL, - SITAR_I2S_MASTER_MODE_MASK, 0); - else if (dai->id == AIF1_PB) - snd_soc_update_bits(dai->codec, - SITAR_A_CDC_CLK_RX_I2S_CTL, - SITAR_I2S_MASTER_MODE_MASK, 0); - } - break; - case SND_SOC_DAIFMT_CBM_CFM: - /* CPU is slave */ - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { - val = SITAR_I2S_MASTER_MODE_MASK; - if (dai->id == AIF1_CAP) - snd_soc_update_bits(dai->codec, - SITAR_A_CDC_CLK_TX_I2S_CTL, val, val); - else if (dai->id == AIF1_PB) - snd_soc_update_bits(dai->codec, - SITAR_A_CDC_CLK_RX_I2S_CTL, val, val); - } - break; - default: - return -EINVAL; - } - return 0; -} -static int sitar_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) - -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(dai->codec); - struct wcd9xxx *core = dev_get_drvdata(dai->codec->dev->parent); - if (!tx_slot && !rx_slot) { - pr_err("%s: Invalid\n", __func__); - return -EINVAL; - } - pr_debug("%s: DAI-ID %x %d %d\n", __func__, dai->id, tx_num, rx_num); - - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) - wcd9xxx_init_slimslave(core, core->slim->laddr, - tx_num, tx_slot, rx_num, rx_slot); - return 0; -} - -static int sitar_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 sitar_priv *sitar_p = snd_soc_codec_get_drvdata(dai->codec); - u32 i = 0; - struct wcd9xxx_ch *ch; - - switch (dai->id) { - case AIF1_PB: - if (!rx_slot || !rx_num) { - pr_err("%s: Invalid rx_slot 0x%x or rx_num 0x%x\n", - __func__, (u32) rx_slot, (u32) rx_num); - return -EINVAL; - } - list_for_each_entry(ch, &sitar_p->dai[dai->id].wcd9xxx_ch_list, - list) { - rx_slot[i++] = ch->ch_num; - } - *rx_num = i; - break; - case AIF1_CAP: - if (!tx_slot || !tx_num) { - pr_err("%s: Invalid tx_slot 0x%x or tx_num 0x%x\n", - __func__, (u32) tx_slot, (u32) tx_num); - return -EINVAL; - } - list_for_each_entry(ch, &sitar_p->dai[dai->id].wcd9xxx_ch_list, - list) { - tx_slot[i++] = ch->ch_num; - } - *tx_num = i; - break; - default: - pr_err("%s: Invalid dai %d", __func__, dai->id); - return -EINVAL; - } - return 0; -} - -static int sitar_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct snd_soc_codec *codec = dai->codec; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(dai->codec); - u8 path, shift; - u32 compander_fs; - u16 tx_fs_reg, rx_fs_reg; - u8 tx_fs_rate, rx_fs_rate, rx_state, tx_state; - - pr_debug("%s: DAI-ID %x\n", __func__, dai->id); - - switch (params_rate(params)) { - case 8000: - tx_fs_rate = 0x00; - rx_fs_rate = 0x00; - compander_fs = COMPANDER_FS_8KHZ; - break; - case 16000: - tx_fs_rate = 0x01; - rx_fs_rate = 0x20; - compander_fs = COMPANDER_FS_16KHZ; - break; - case 32000: - tx_fs_rate = 0x02; - rx_fs_rate = 0x40; - compander_fs = COMPANDER_FS_32KHZ; - break; - case 48000: - tx_fs_rate = 0x03; - rx_fs_rate = 0x60; - compander_fs = COMPANDER_FS_48KHZ; - break; - case 96000: - tx_fs_rate = 0x04; - rx_fs_rate = 0x80; - compander_fs = COMPANDER_FS_96KHZ; - break; - case 192000: - tx_fs_rate = 0x05; - rx_fs_rate = 0xa0; - compander_fs = COMPANDER_FS_192KHZ; - break; - default: - pr_err("%s: Invalid sampling rate %d\n", __func__, - params_rate(params)); - return -EINVAL; - } - - - /** - * If current dai is a tx dai, set sample rate to - * all the txfe paths that are currently not active - */ - if (dai->id == AIF1_CAP) { - - tx_state = snd_soc_read(codec, - SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL); - - for (path = 1, shift = 0; - path <= NUM_DECIMATORS; path++, shift++) { - - if (!(tx_state & (1 << shift))) { - tx_fs_reg = SITAR_A_CDC_TX1_CLK_FS_CTL - + (BITS_PER_REG*(path-1)); - snd_soc_update_bits(codec, tx_fs_reg, - 0x03, tx_fs_rate); - } - } - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S16_LE: - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_TX_I2S_CTL, - 0x20, 0x20); - break; - case SNDRV_PCM_FORMAT_S32_LE: - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_TX_I2S_CTL, - 0x20, 0x00); - break; - default: - pr_err("%s: Unsupport format %d\n", __func__, - params_format(params)); - return -EINVAL; - } - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_TX_I2S_CTL, - 0x03, tx_fs_rate); - } else { - sitar->dai[dai->id].rate = params_rate(params); - } - } - - /** - * TODO: Need to handle case where same RX chain takes 2 or more inputs - * with varying sample rates - */ - - /** - * If current dai is a rx dai, set sample rate to - * all the rx paths that are currently not active - */ - if (dai->id == AIF1_PB) { - - rx_state = snd_soc_read(codec, - SITAR_A_CDC_CLK_RX_B1_CTL); - - for (path = 1, shift = 0; - path <= NUM_INTERPOLATORS; path++, shift++) { - - if (!(rx_state & (1 << shift))) { - rx_fs_reg = SITAR_A_CDC_RX1_B5_CTL - + (BITS_PER_REG*(path-1)); - snd_soc_update_bits(codec, rx_fs_reg, - 0xE0, rx_fs_rate); - if (comp_rx_path[shift] < COMPANDER_MAX) - sitar->comp_fs[comp_rx_path[shift]] - = compander_fs; - } - } - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S16_LE: - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_RX_I2S_CTL, - 0x20, 0x20); - break; - case SNDRV_PCM_FORMAT_S32_LE: - snd_soc_update_bits(codec, - SITAR_A_CDC_CLK_RX_I2S_CTL, - 0x20, 0x00); - break; - default: - pr_err("%s: Unsupport format %d\n", __func__, - params_format(params)); - break; - } - snd_soc_update_bits(codec, SITAR_A_CDC_CLK_RX_I2S_CTL, - 0x03, (rx_fs_rate >> 0x05)); - } else { - sitar->dai[dai->id].rate = params_rate(params); - } - } - - return 0; -} - -static struct snd_soc_dai_ops sitar_dai_ops = { - .startup = sitar_startup, - .shutdown = sitar_shutdown, - .hw_params = sitar_hw_params, - .set_sysclk = sitar_set_dai_sysclk, - .set_fmt = sitar_set_dai_fmt, - .set_channel_map = sitar_set_channel_map, - .get_channel_map = sitar_get_channel_map, -}; - -static struct snd_soc_dai_driver sitar_dai[] = { - { - .name = "sitar_rx1", - .id = AIF1_PB, - .playback = { - .stream_name = "AIF1 Playback", - .rates = WCD9304_RATES, - .formats = SITAR_FORMATS, - .rate_max = 48000, - .rate_min = 8000, - .channels_min = 1, - .channels_max = 2, - }, - .ops = &sitar_dai_ops, - }, - { - .name = "sitar_tx1", - .id = AIF1_CAP, - .capture = { - .stream_name = "AIF1 Capture", - .rates = WCD9304_RATES, - .formats = SITAR_FORMATS, - .rate_max = 48000, - .rate_min = 8000, - .channels_min = 1, - .channels_max = 2, - }, - .ops = &sitar_dai_ops, - }, -}; - -static struct snd_soc_dai_driver sitar_i2s_dai[] = { - { - .name = "sitar_i2s_rx1", - .id = AIF1_PB, - .playback = { - .stream_name = "AIF1 Playback", - .rates = WCD9304_RATES, - .formats = SITAR_FORMATS, - .rate_max = 192000, - .rate_min = 8000, - .channels_min = 1, - .channels_max = 4, - }, - .ops = &sitar_dai_ops, - }, - { - .name = "sitar_i2s_tx1", - .id = AIF1_CAP, - .capture = { - .stream_name = "AIF1 Capture", - .rates = WCD9304_RATES, - .formats = SITAR_FORMATS, - .rate_max = 192000, - .rate_min = 8000, - .channels_min = 1, - .channels_max = 4, - }, - .ops = &sitar_dai_ops, - }, -}; - -static int sitar_codec_enable_chmask(struct sitar_priv *sitar, - int event, int index) -{ - int ret = 0; - struct wcd9xxx_ch *ch; - - switch (event) { - case SND_SOC_DAPM_POST_PMU: - list_for_each_entry(ch, - &sitar->dai[index].wcd9xxx_ch_list, list) { - ret = wcd9xxx_get_slave_port(ch->ch_num); - if (ret < 0) { - pr_err("%s: Invalid slave port ID: %d\n", - __func__, ret); - ret = -EINVAL; - break; - } - sitar->dai[index].ch_mask |= 1 << ret; - } - break; - case SND_SOC_DAPM_POST_PMD: - ret = wait_event_timeout(sitar->dai[index].dai_wait, - (sitar->dai[index].ch_mask == 0), - msecs_to_jiffies(SLIM_CLOSE_TIMEOUT)); - if (!ret) { - pr_err("%s: Slim close tx/rx wait timeout\n", - __func__); - ret = -EINVAL; - } else { - ret = 0; - } - break; - } - return ret; -} - -static int sitar_codec_enable_slimrx(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct wcd9xxx *core; - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar_p = snd_soc_codec_get_drvdata(codec); - int ret = 0; - struct wcd9xxx_codec_dai_data *dai; - - core = dev_get_drvdata(codec->dev->parent); - - /* Execute the callback only if interface type is slimbus */ - if (sitar_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - if (event == SND_SOC_DAPM_POST_PMD && (core != NULL)) - sitar_codec_pm_runtime_put(core); - return 0; - } - - dai = &sitar_p->dai[w->shift]; - - switch (event) { - case SND_SOC_DAPM_POST_PMU: - ret = sitar_codec_enable_chmask(sitar_p, SND_SOC_DAPM_POST_PMU, - w->shift); - ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list, - dai->rate, dai->bit_width, - &dai->grph); - break; - case SND_SOC_DAPM_POST_PMD: - ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list, - dai->grph); - ret = sitar_codec_enable_chmask(sitar_p, SND_SOC_DAPM_POST_PMD, - w->shift); - if (ret < 0) { - ret = wcd9xxx_disconnect_port(core, - &dai->wcd9xxx_ch_list, - dai->grph); - pr_info("%s: Disconnect RX port ret = %d\n", - __func__, ret); - } - if (core != NULL) - sitar_codec_pm_runtime_put(core); - break; - } - return ret; -} - -static int sitar_codec_enable_slimtx(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct wcd9xxx *core; - struct snd_soc_codec *codec = w->codec; - struct sitar_priv *sitar_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx_codec_dai_data *dai; - int ret = 0; - - core = dev_get_drvdata(codec->dev->parent); - - /* Execute the callback only if interface type is slimbus */ - if (sitar_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - if (event == SND_SOC_DAPM_POST_PMD && (core != NULL)) - sitar_codec_pm_runtime_put(core); - return 0; - } - - dai = &sitar_p->dai[w->shift]; - switch (event) { - case SND_SOC_DAPM_POST_PMU: - ret = sitar_codec_enable_chmask(sitar_p, SND_SOC_DAPM_POST_PMU, - w->shift); - ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list, - dai->rate, dai->bit_width, - &dai->grph); - break; - case SND_SOC_DAPM_POST_PMD: - ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list, - dai->grph); - ret = sitar_codec_enable_chmask(sitar_p, SND_SOC_DAPM_POST_PMD, - w->shift); - if (ret < 0) { - ret = wcd9xxx_disconnect_port(core, - &dai->wcd9xxx_ch_list, - dai->grph); - pr_info("%s: Disconnect RX port ret = %d\n", - __func__, ret); - } - if (core != NULL) - sitar_codec_pm_runtime_put(core); - break; - } - return ret; -} - - -static short sitar_codec_read_sta_result(struct snd_soc_codec *codec) -{ - u8 bias_msb, bias_lsb; - short bias_value; - - bias_msb = snd_soc_read(codec, SITAR_A_CDC_MBHC_B3_STATUS); - bias_lsb = snd_soc_read(codec, SITAR_A_CDC_MBHC_B2_STATUS); - bias_value = (bias_msb << 8) | bias_lsb; - return bias_value; -} - -static short sitar_codec_read_dce_result(struct snd_soc_codec *codec) -{ - u8 bias_msb, bias_lsb; - short bias_value; - - bias_msb = snd_soc_read(codec, SITAR_A_CDC_MBHC_B5_STATUS); - bias_lsb = snd_soc_read(codec, SITAR_A_CDC_MBHC_B4_STATUS); - bias_value = (bias_msb << 8) | bias_lsb; - return bias_value; -} - -static void sitar_turn_onoff_rel_detection(struct snd_soc_codec *codec, - bool on) -{ - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x02, on << 1); -} - -static short __sitar_codec_sta_dce(struct snd_soc_codec *codec, int dce, - bool override_bypass, bool noreldetection) -{ - short bias_value; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = codec->control_data; - struct wcd9xxx_core_resource *core_res = &core->core_res; - - wcd9xxx_disable_irq(core_res, WCD9XXX_IRQ_MBHC_POTENTIAL); - if (noreldetection) - sitar_turn_onoff_rel_detection(codec, false); - - /* Turn on the override */ - if (!override_bypass) - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x4, 0x4); - if (dce) { - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x4); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x0); - usleep_range(sitar->mbhc_data.t_sta_dce, - sitar->mbhc_data.t_sta_dce); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x4); - usleep_range(sitar->mbhc_data.t_dce, - sitar->mbhc_data.t_dce); - bias_value = sitar_codec_read_dce_result(codec); - } else { - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x2); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x0); - usleep_range(sitar->mbhc_data.t_sta_dce, - sitar->mbhc_data.t_sta_dce); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x2); - usleep_range(sitar->mbhc_data.t_sta, - sitar->mbhc_data.t_sta); - bias_value = sitar_codec_read_sta_result(codec); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x0); - } - /* Turn off the override after measuring mic voltage */ - if (!override_bypass) - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x04, 0x00); - - if (noreldetection) - sitar_turn_onoff_rel_detection(codec, true); - wcd9xxx_enable_irq(codec->control_data, WCD9XXX_IRQ_MBHC_POTENTIAL); - - return bias_value; -} - -static short sitar_codec_sta_dce(struct snd_soc_codec *codec, int dce, - bool norel) -{ - return __sitar_codec_sta_dce(codec, dce, false, norel); -} - -static void sitar_codec_shutdown_hs_removal_detect(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - const struct sitar_mbhc_general_cfg *generic = - SITAR_MBHC_CAL_GENERAL_PTR(sitar->mbhc_cfg.calibration); - - if (!sitar->mclk_enabled && !sitar->mbhc_polling_active) - sitar_codec_enable_config_mode(codec, 1); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x2, 0x2); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x6, 0x0); - - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.mbhc_reg, 0x80, 0x00); - - usleep_range(generic->t_shutdown_plug_rem, - generic->t_shutdown_plug_rem); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0xA, 0x8); - if (!sitar->mclk_enabled && !sitar->mbhc_polling_active) - sitar_codec_enable_config_mode(codec, 0); - - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x00); -} - -static void sitar_codec_cleanup_hs_polling(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - sitar_codec_shutdown_hs_removal_detect(codec); - - if (!sitar->mclk_enabled) { - sitar_codec_disable_clock_block(codec); - sitar_codec_enable_bandgap(codec, SITAR_BANDGAP_OFF); - } - - sitar->mbhc_polling_active = false; - sitar->mbhc_state = MBHC_STATE_NONE; -} - -/* called only from interrupt which is under codec_resource_lock acquisition */ -static short sitar_codec_setup_hs_polling(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - short bias_value; - u8 cfilt_mode; - - if (!sitar->mbhc_cfg.calibration) { - pr_err("Error, no sitar calibration\n"); - return -ENODEV; - } - - if (!sitar->mclk_enabled) { - sitar_codec_enable_bandgap(codec, SITAR_BANDGAP_MBHC_MODE); - sitar_enable_rx_bias(codec, 1); - sitar_codec_enable_clock_block(codec, 1); - } - - snd_soc_update_bits(codec, SITAR_A_CLK_BUFF_EN1, 0x05, 0x01); - - /* Make sure CFILT is in fast mode, save current mode */ - cfilt_mode = snd_soc_read(codec, sitar->mbhc_bias_regs.cfilt_ctl); - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.cfilt_ctl, 0x70, 0x00); - - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.ctl_reg, 0x1F, 0x16); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x2, 0x2); - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x84); - - snd_soc_update_bits(codec, SITAR_A_TX_4_MBHC_EN, 0x80, 0x80); - snd_soc_update_bits(codec, SITAR_A_TX_4_MBHC_EN, 0x1F, 0x1C); - snd_soc_update_bits(codec, SITAR_A_TX_4_MBHC_TEST_CTL, 0x40, 0x40); - - snd_soc_update_bits(codec, SITAR_A_TX_4_MBHC_EN, 0x80, 0x00); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x00); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x2, 0x2); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x8, 0x8); - - sitar_codec_calibrate_hs_polling(codec); - - /* don't flip override */ - bias_value = __sitar_codec_sta_dce(codec, 1, true, true); - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.cfilt_ctl, 0x40, - cfilt_mode); - snd_soc_update_bits(codec, SITAR_A_MBHC_HPH, 0x13, 0x00); - - return bias_value; -} - -static int sitar_cancel_btn_work(struct sitar_priv *sitar) -{ - int r = 0; - struct wcd9xxx *core = dev_get_drvdata(sitar->codec->dev->parent); - struct wcd9xxx_core_resource *core_res = &core->core_res; - - if (cancel_delayed_work_sync(&sitar->mbhc_btn_dwork)) { - /* if scheduled mbhc_btn_dwork is canceled from here, - * we have to unlock from here instead btn_work */ - wcd9xxx_unlock_sleep(core_res); - r = 1; - } - return r; -} - - -static u16 sitar_codec_v_sta_dce(struct snd_soc_codec *codec, bool dce, - s16 vin_mv) -{ - short diff, zero; - struct sitar_priv *sitar; - u32 mb_mv, in; - - sitar = snd_soc_codec_get_drvdata(codec); - mb_mv = sitar->mbhc_data.micb_mv; - - if (mb_mv == 0) { - pr_err("%s: Mic Bias voltage is set to zero\n", __func__); - return -EINVAL; - } - - if (dce) { - diff = sitar->mbhc_data.dce_mb - sitar->mbhc_data.dce_z; - zero = sitar->mbhc_data.dce_z; - } else { - diff = sitar->mbhc_data.sta_mb - sitar->mbhc_data.sta_z; - zero = sitar->mbhc_data.sta_z; - } - in = (u32) diff * vin_mv; - - return (u16) (in / mb_mv) + zero; -} - -static s32 sitar_codec_sta_dce_v(struct snd_soc_codec *codec, s8 dce, - u16 bias_value) -{ - struct sitar_priv *sitar; - s16 value, z, mb; - s32 mv; - - sitar = snd_soc_codec_get_drvdata(codec); - value = bias_value; - - if (dce) { - z = (sitar->mbhc_data.dce_z); - mb = (sitar->mbhc_data.dce_mb); - mv = (value - z) * (s32)sitar->mbhc_data.micb_mv / (mb - z); - } else { - z = (sitar->mbhc_data.sta_z); - mb = (sitar->mbhc_data.sta_mb); - mv = (value - z) * (s32)sitar->mbhc_data.micb_mv / (mb - z); - } - - return mv; -} - -static void btn_lpress_fn(struct work_struct *work) -{ - struct delayed_work *delayed_work; - struct sitar_priv *sitar; - short bias_value; - int dce_mv, sta_mv; - struct wcd9xxx *core; - struct wcd9xxx_core_resource *core_res; - - pr_debug("%s:\n", __func__); - - delayed_work = to_delayed_work(work); - sitar = container_of(delayed_work, struct sitar_priv, mbhc_btn_dwork); - core = dev_get_drvdata(sitar->codec->dev->parent); - core_res = &core->core_res; - - if (sitar) { - if (sitar->mbhc_cfg.button_jack) { - bias_value = sitar_codec_read_sta_result(sitar->codec); - sta_mv = sitar_codec_sta_dce_v(sitar->codec, 0, - bias_value); - bias_value = sitar_codec_read_dce_result(sitar->codec); - dce_mv = sitar_codec_sta_dce_v(sitar->codec, 1, - bias_value); - pr_debug("%s: Reporting long button press event" - " STA: %d, DCE: %d\n", __func__, sta_mv, dce_mv); - sitar_snd_soc_jack_report(sitar, - sitar->mbhc_cfg.button_jack, - sitar->buttons_pressed, - sitar->buttons_pressed); - } - } else { - pr_err("%s: Bad sitar private data\n", __func__); - } - - pr_debug("%s: leave\n", __func__); - wcd9xxx_unlock_sleep(core_res); -} - - -void sitar_mbhc_cal(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar; - struct sitar_mbhc_btn_detect_cfg *btn_det; - u8 cfilt_mode, bg_mode; - u8 ncic, nmeas, navg; - u32 mclk_rate; - u32 dce_wait, sta_wait; - u8 *n_cic; - void *calibration; - struct wcd9xxx *core = codec->control_data; - struct wcd9xxx_core_resource *core_res = &core->core_res; - - sitar = snd_soc_codec_get_drvdata(codec); - calibration = sitar->mbhc_cfg.calibration; - - wcd9xxx_disable_irq(core_res, WCD9XXX_IRQ_MBHC_POTENTIAL); - sitar_turn_onoff_rel_detection(codec, false); - - /* First compute the DCE / STA wait times - * depending on tunable parameters. - * The value is computed in microseconds - */ - btn_det = SITAR_MBHC_CAL_BTN_DET_PTR(calibration); - n_cic = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_N_CIC); - ncic = n_cic[sitar_codec_mclk_index(sitar)]; - nmeas = SITAR_MBHC_CAL_BTN_DET_PTR(calibration)->n_meas; - navg = SITAR_MBHC_CAL_GENERAL_PTR(calibration)->mbhc_navg; - mclk_rate = sitar->mbhc_cfg.mclk_rate; - dce_wait = (1000 * 512 * 60 * (nmeas + 1)) / (mclk_rate / 1000); - sta_wait = (1000 * 128 * (navg + 1)) / (mclk_rate / 1000); - - sitar->mbhc_data.t_dce = DEFAULT_DCE_WAIT; - sitar->mbhc_data.t_sta = DEFAULT_STA_WAIT; - - /* LDOH and CFILT are already configured during pdata handling. - * Only need to make sure CFILT and bandgap are in Fast mode. - * Need to restore defaults once calculation is done. - */ - cfilt_mode = snd_soc_read(codec, sitar->mbhc_bias_regs.cfilt_ctl); - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.cfilt_ctl, 0x40, 0x00); - bg_mode = snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x02, - 0x02); - - /* Micbias, CFILT, LDOH, MBHC MUX mode settings - * to perform ADC calibration - */ - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.ctl_reg, 0x60, - sitar->mbhc_cfg.micbias << 5); - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.ctl_reg, 0x01, 0x00); - snd_soc_update_bits(codec, SITAR_A_LDO_H_MODE_1, 0x60, 0x60); - snd_soc_write(codec, SITAR_A_TX_4_MBHC_TEST_CTL, 0x78); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x04, 0x04); - - /* DCE measurement for 0 volts */ - snd_soc_write(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x0A); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x04); - snd_soc_write(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x02); - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x81); - usleep_range(100, 100); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x04); - usleep_range(sitar->mbhc_data.t_dce, sitar->mbhc_data.t_dce); - sitar->mbhc_data.dce_z = sitar_codec_read_dce_result(codec); - - /* DCE measurment for MB voltage */ - snd_soc_write(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x0A); - snd_soc_write(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x02); - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x82); - usleep_range(100, 100); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x04); - usleep_range(sitar->mbhc_data.t_dce, sitar->mbhc_data.t_dce); - sitar->mbhc_data.dce_mb = sitar_codec_read_dce_result(codec); - - /* Sta measuremnt for 0 volts */ - snd_soc_write(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x0A); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x02); - snd_soc_write(codec, SITAR_A_CDC_MBHC_CLK_CTL, 0x02); - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x81); - usleep_range(100, 100); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x02); - usleep_range(sitar->mbhc_data.t_sta, sitar->mbhc_data.t_sta); - sitar->mbhc_data.sta_z = sitar_codec_read_sta_result(codec); - - /* STA Measurement for MB Voltage */ - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x82); - usleep_range(100, 100); - snd_soc_write(codec, SITAR_A_CDC_MBHC_EN_CTL, 0x02); - usleep_range(sitar->mbhc_data.t_sta, sitar->mbhc_data.t_sta); - sitar->mbhc_data.sta_mb = sitar_codec_read_sta_result(codec); - - /* Restore default settings. */ - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x04, 0x00); - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.cfilt_ctl, 0x40, - cfilt_mode); - snd_soc_update_bits(codec, SITAR_A_BIAS_CENTRAL_BG_CTL, 0x02, bg_mode); - - snd_soc_write(codec, SITAR_A_MBHC_SCALING_MUX_1, 0x84); - usleep_range(100, 100); - - wcd9xxx_enable_irq(codec->control_data, WCD9XXX_IRQ_MBHC_POTENTIAL); - sitar_turn_onoff_rel_detection(codec, true); -} - -void *sitar_mbhc_cal_btn_det_mp(const struct sitar_mbhc_btn_detect_cfg* btn_det, - const enum sitar_mbhc_btn_det_mem mem) -{ - void *ret = &btn_det->_v_btn_low; - - switch (mem) { - case SITAR_BTN_DET_GAIN: - ret += sizeof(btn_det->_n_cic); - case SITAR_BTN_DET_N_CIC: - ret += sizeof(btn_det->_n_ready); - case SITAR_BTN_DET_N_READY: - ret += sizeof(btn_det->_v_btn_high[0]) * btn_det->num_btn; - case SITAR_BTN_DET_V_BTN_HIGH: - ret += sizeof(btn_det->_v_btn_low[0]) * btn_det->num_btn; - case SITAR_BTN_DET_V_BTN_LOW: - /* do nothing */ - break; - default: - ret = NULL; - } - - return ret; -} - -static void sitar_mbhc_calc_thres(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar; - s16 btn_mv = 0, btn_delta_mv; - struct sitar_mbhc_btn_detect_cfg *btn_det; - struct sitar_mbhc_plug_type_cfg *plug_type; - u16 *btn_high; - u8 *n_ready; - int i; - - sitar = snd_soc_codec_get_drvdata(codec); - btn_det = SITAR_MBHC_CAL_BTN_DET_PTR(sitar->mbhc_cfg.calibration); - plug_type = SITAR_MBHC_CAL_PLUG_TYPE_PTR(sitar->mbhc_cfg.calibration); - - n_ready = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_N_READY); - if (sitar->mbhc_cfg.mclk_rate == SITAR_MCLK_RATE_12288KHZ) { - sitar->mbhc_data.npoll = 9; - sitar->mbhc_data.nbounce_wait = 30; - } else if (sitar->mbhc_cfg.mclk_rate == SITAR_MCLK_RATE_9600KHZ) { - sitar->mbhc_data.npoll = 7; - sitar->mbhc_data.nbounce_wait = 23; - } - - sitar->mbhc_data.t_sta_dce = ((1000 * 256) / - (sitar->mbhc_cfg.mclk_rate / 1000) * - n_ready[sitar_codec_mclk_index(sitar)]) + - 10; - sitar->mbhc_data.v_ins_hu = - sitar_codec_v_sta_dce(codec, STA, plug_type->v_hs_max); - sitar->mbhc_data.v_ins_h = - sitar_codec_v_sta_dce(codec, DCE, plug_type->v_hs_max); - - btn_high = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_V_BTN_HIGH); - for (i = 0; i < btn_det->num_btn; i++) - btn_mv = btn_high[i] > btn_mv ? btn_high[i] : btn_mv; - - sitar->mbhc_data.v_b1_h = sitar_codec_v_sta_dce(codec, DCE, btn_mv); - btn_delta_mv = btn_mv + btn_det->v_btn_press_delta_sta; - - sitar->mbhc_data.v_b1_hu = - sitar_codec_v_sta_dce(codec, STA, btn_delta_mv); - - btn_delta_mv = btn_mv + btn_det->v_btn_press_delta_cic; - - sitar->mbhc_data.v_b1_huc = - sitar_codec_v_sta_dce(codec, DCE, btn_delta_mv); - - sitar->mbhc_data.v_brh = sitar->mbhc_data.v_b1_h; - sitar->mbhc_data.v_brl = SITAR_MBHC_BUTTON_MIN; - - sitar->mbhc_data.v_no_mic = - sitar_codec_v_sta_dce(codec, STA, plug_type->v_no_mic); -} - -void sitar_mbhc_init(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar; - struct sitar_mbhc_general_cfg *generic; - struct sitar_mbhc_btn_detect_cfg *btn_det; - int n; - u8 *n_cic, *gain; - - pr_err("%s(): ENTER\n", __func__); - sitar = snd_soc_codec_get_drvdata(codec); - generic = SITAR_MBHC_CAL_GENERAL_PTR(sitar->mbhc_cfg.calibration); - btn_det = SITAR_MBHC_CAL_BTN_DET_PTR(sitar->mbhc_cfg.calibration); - - for (n = 0; n < 8; n++) { - if (n != 7) { - snd_soc_update_bits(codec, - SITAR_A_CDC_MBHC_FIR_B1_CFG, - 0x07, n); - snd_soc_write(codec, SITAR_A_CDC_MBHC_FIR_B2_CFG, - btn_det->c[n]); - } - } - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B2_CTL, 0x07, - btn_det->nc); - - n_cic = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_N_CIC); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_TIMER_B6_CTL, 0xFF, - n_cic[sitar_codec_mclk_index(sitar)]); - - gain = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_GAIN); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B2_CTL, 0x78, - gain[sitar_codec_mclk_index(sitar)] << 3); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_TIMER_B4_CTL, 0x70, - generic->mbhc_nsa << 4); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_TIMER_B4_CTL, 0x0F, - btn_det->n_meas); - - snd_soc_write(codec, SITAR_A_CDC_MBHC_TIMER_B5_CTL, generic->mbhc_navg); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x80, 0x80); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x78, - btn_det->mbhc_nsc << 3); - - snd_soc_update_bits(codec, SITAR_A_MICB_1_MBHC, 0x03, - sitar->mbhc_cfg.micbias); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x02, 0x02); - - snd_soc_update_bits(codec, SITAR_A_MBHC_SCALING_MUX_2, 0xF0, 0xF0); - -} - -static bool sitar_mbhc_fw_validate(const struct firmware *fw) -{ - u32 cfg_offset; - struct sitar_mbhc_imped_detect_cfg *imped_cfg; - struct sitar_mbhc_btn_detect_cfg *btn_cfg; - - if (fw->size < SITAR_MBHC_CAL_MIN_SIZE) - return false; - - /* previous check guarantees that there is enough fw data up - * to num_btn - */ - btn_cfg = SITAR_MBHC_CAL_BTN_DET_PTR(fw->data); - cfg_offset = (u32) ((void *) btn_cfg - (void *) fw->data); - if (fw->size < (cfg_offset + SITAR_MBHC_CAL_BTN_SZ(btn_cfg))) - return false; - - /* previous check guarantees that there is enough fw data up - * to start of impedance detection configuration - */ - imped_cfg = SITAR_MBHC_CAL_IMPED_DET_PTR(fw->data); - cfg_offset = (u32) ((void *) imped_cfg - (void *) fw->data); - - if (fw->size < (cfg_offset + SITAR_MBHC_CAL_IMPED_MIN_SZ)) - return false; - - if (fw->size < (cfg_offset + SITAR_MBHC_CAL_IMPED_SZ(imped_cfg))) - return false; - - return true; -} - - -static void sitar_turn_onoff_override(struct snd_soc_codec *codec, bool on) -{ - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_B1_CTL, 0x04, on << 2); -} - -/* called under codec_resource_lock acquisition */ -void sitar_set_and_turnoff_hph_padac(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - u8 wg_time; - - wg_time = snd_soc_read(codec, SITAR_A_RX_HPH_CNP_WG_TIME) ; - wg_time += 1; - - /* If headphone PA is on, check if userspace receives - * removal event to sync-up PA's state */ - if (sitar_is_hph_pa_on(codec)) { - pr_debug("%s PA is on, setting PA_OFF_ACK\n", __func__); - set_bit(SITAR_HPHL_PA_OFF_ACK, &sitar->hph_pa_dac_state); - set_bit(SITAR_HPHR_PA_OFF_ACK, &sitar->hph_pa_dac_state); - } else { - pr_debug("%s PA is off\n", __func__); - } - - if (sitar_is_hph_dac_on(codec, 1)) - set_bit(SITAR_HPHL_DAC_OFF_ACK, &sitar->hph_pa_dac_state); - if (sitar_is_hph_dac_on(codec, 0)) - set_bit(SITAR_HPHR_DAC_OFF_ACK, &sitar->hph_pa_dac_state); - - snd_soc_update_bits(codec, SITAR_A_RX_HPH_CNP_EN, 0x30, 0x00); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_L_DAC_CTL, - 0xC0, 0x00); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_R_DAC_CTL, - 0xC0, 0x00); - usleep_range(wg_time * 1000, wg_time * 1000); -} - -static void sitar_clr_and_turnon_hph_padac(struct sitar_priv *sitar) -{ - bool pa_turned_on = false; - struct snd_soc_codec *codec = sitar->codec; - u8 wg_time; - - wg_time = snd_soc_read(codec, SITAR_A_RX_HPH_CNP_WG_TIME) ; - wg_time += 1; - - if (test_and_clear_bit(SITAR_HPHR_DAC_OFF_ACK, - &sitar->hph_pa_dac_state)) { - pr_debug("%s: HPHR clear flag and enable DAC\n", __func__); - snd_soc_update_bits(sitar->codec, SITAR_A_RX_HPH_R_DAC_CTL, - 0xC0, 0xC0); - } - if (test_and_clear_bit(SITAR_HPHL_DAC_OFF_ACK, - &sitar->hph_pa_dac_state)) { - pr_debug("%s: HPHL clear flag and enable DAC\n", __func__); - snd_soc_update_bits(sitar->codec, SITAR_A_RX_HPH_L_DAC_CTL, - 0xC0, 0xC0); - } - - if (test_and_clear_bit(SITAR_HPHR_PA_OFF_ACK, - &sitar->hph_pa_dac_state)) { - pr_debug("%s: HPHR clear flag and enable PA\n", __func__); - snd_soc_update_bits(sitar->codec, SITAR_A_RX_HPH_CNP_EN, 0x10, - 1 << 4); - pa_turned_on = true; - } - if (test_and_clear_bit(SITAR_HPHL_PA_OFF_ACK, - &sitar->hph_pa_dac_state)) { - pr_debug("%s: HPHL clear flag and enable PA\n", __func__); - snd_soc_update_bits(sitar->codec, SITAR_A_RX_HPH_CNP_EN, 0x20, - 1 << 5); - pa_turned_on = true; - } - - if (pa_turned_on) { - pr_debug("%s: PA was turned off by MBHC and not by DAPM\n", - __func__); - usleep_range(wg_time * 1000, wg_time * 1000); - } -} - -static void sitar_codec_report_plug(struct snd_soc_codec *codec, int insertion, - enum snd_jack_types jack_type) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - if (!insertion) { - /* Report removal */ - sitar->hph_status &= ~jack_type; - if (sitar->mbhc_cfg.headset_jack) { - /* cancel possibly scheduled btn work and - * report release if we reported button press */ - if (sitar_cancel_btn_work(sitar)) { - pr_debug("%s: button press is canceled\n", - __func__); - } else if (sitar->buttons_pressed) { - pr_debug("%s: Reporting release for reported " - "button press %d\n", __func__, - jack_type); - sitar_snd_soc_jack_report(sitar, - sitar->mbhc_cfg.button_jack, 0, - sitar->buttons_pressed); - sitar->buttons_pressed &= - ~SITAR_JACK_BUTTON_MASK; - } - pr_debug("%s: Reporting removal %d\n", __func__, - jack_type); - sitar_snd_soc_jack_report(sitar, - sitar->mbhc_cfg.headset_jack, - sitar->hph_status, - SITAR_JACK_MASK); - } - sitar_set_and_turnoff_hph_padac(codec); - hphocp_off_report(sitar, SND_JACK_OC_HPHR, - WCD9XXX_IRQ_HPH_PA_OCPR_FAULT); - hphocp_off_report(sitar, SND_JACK_OC_HPHL, - WCD9XXX_IRQ_HPH_PA_OCPL_FAULT); - sitar->current_plug = PLUG_TYPE_NONE; - sitar->mbhc_polling_active = false; - } else { - /* Report insertion */ - sitar->hph_status |= jack_type; - - if (jack_type == SND_JACK_HEADPHONE) - sitar->current_plug = PLUG_TYPE_HEADPHONE; - else if (jack_type == SND_JACK_HEADSET) { - sitar->mbhc_polling_active = true; - sitar->current_plug = PLUG_TYPE_HEADSET; - } - if (sitar->mbhc_cfg.headset_jack) { - pr_debug("%s: Reporting insertion %d\n", __func__, - jack_type); - sitar_snd_soc_jack_report(sitar, - sitar->mbhc_cfg.headset_jack, - sitar->hph_status, - SITAR_JACK_MASK); - } - sitar_clr_and_turnon_hph_padac(sitar); - } -} - - -static bool sitar_hs_gpio_level_remove(struct sitar_priv *sitar) -{ - return (gpio_get_value_cansleep(sitar->mbhc_cfg.gpio) != - sitar->mbhc_cfg.gpio_level_insert); -} - -static bool sitar_is_invalid_insert_delta(struct snd_soc_codec *codec, - int mic_volt, int mic_volt_prev) -{ - int delta = abs(mic_volt - mic_volt_prev); - if (delta > SITAR_MBHC_FAKE_INSERT_VOLT_DELTA_MV) { - pr_debug("%s: volt delta %dmv\n", __func__, delta); - return true; - } - return false; -} - -static bool sitar_is_invalid_insertion_range(struct snd_soc_codec *codec, - s32 mic_volt) -{ - bool invalid = false; - - if (mic_volt < SITAR_MBHC_FAKE_INSERT_HIGH - && (mic_volt > SITAR_MBHC_FAKE_INSERT_LOW)) { - invalid = true; - } - - return invalid; -} - -static bool sitar_codec_is_invalid_plug(struct snd_soc_codec *codec, - s32 mic_mv[MBHC_NUM_DCE_PLUG_DETECT], - enum sitar_mbhc_plug_type plug_type[MBHC_NUM_DCE_PLUG_DETECT]) -{ - int i; - bool r = false; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - struct sitar_mbhc_plug_type_cfg *plug_type_ptr = - SITAR_MBHC_CAL_PLUG_TYPE_PTR(sitar->mbhc_cfg.calibration); - - for (i = 0 ; i < MBHC_NUM_DCE_PLUG_DETECT && !r; i++) { - if (mic_mv[i] < plug_type_ptr->v_no_mic) - plug_type[i] = PLUG_TYPE_HEADPHONE; - else if (mic_mv[i] < plug_type_ptr->v_hs_max) - plug_type[i] = PLUG_TYPE_HEADSET; - else if (mic_mv[i] > plug_type_ptr->v_hs_max) - plug_type[i] = PLUG_TYPE_HIGH_HPH; - - r = sitar_is_invalid_insertion_range(codec, mic_mv[i]); - if (!r && i > 0) { - if (plug_type[i-1] != plug_type[i]) - r = true; - else - r = sitar_is_invalid_insert_delta(codec, - mic_mv[i], - mic_mv[i - 1]); - } - } - - return r; -} - -/* called under codec_resource_lock acquisition */ -void sitar_find_plug_and_report(struct snd_soc_codec *codec, - enum sitar_mbhc_plug_type plug_type) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - if (plug_type == PLUG_TYPE_HEADPHONE - && sitar->current_plug == PLUG_TYPE_NONE) { - /* Nothing was reported previously - * reporte a headphone - */ - sitar_codec_report_plug(codec, 1, SND_JACK_HEADPHONE); - sitar_codec_cleanup_hs_polling(codec); - } else if (plug_type == PLUG_TYPE_HEADSET) { - /* If Headphone was reported previously, this will - * only report the mic line - */ - sitar_codec_report_plug(codec, 1, SND_JACK_HEADSET); - msleep(100); - sitar_codec_start_hs_polling(codec); - } else if (plug_type == PLUG_TYPE_HIGH_HPH) { - if (sitar->current_plug == PLUG_TYPE_NONE) - sitar_codec_report_plug(codec, 1, SND_JACK_HEADPHONE); - sitar_codec_cleanup_hs_polling(codec); - pr_debug("setup mic trigger for further detection\n"); - sitar->lpi_enabled = true; - /* TODO ::: sitar_codec_enable_hs_detect */ - pr_err("%s(): High impedence hph not supported\n", __func__); - } -} - -/* should be called under interrupt context that hold suspend */ -static void sitar_schedule_hs_detect_plug(struct sitar_priv *sitar) -{ - struct wcd9xxx *core = sitar->codec->control_data; - struct wcd9xxx_core_resource *core_res = &core->core_res; - - pr_debug("%s: scheduling sitar_hs_correct_gpio_plug\n", __func__); - sitar->hs_detect_work_stop = false; - wcd9xxx_lock_sleep(core_res); - schedule_work(&sitar->hs_correct_plug_work); -} - -/* called under codec_resource_lock acquisition */ -static void sitar_cancel_hs_detect_plug(struct sitar_priv *sitar) -{ - struct wcd9xxx *core = sitar->codec->control_data; - struct wcd9xxx_core_resource *core_res = &core->core_res; - - pr_debug("%s: canceling hs_correct_plug_work\n", __func__); - sitar->hs_detect_work_stop = true; - wmb(); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - if (cancel_work_sync(&sitar->hs_correct_plug_work)) { - pr_debug("%s: hs_correct_plug_work is canceled\n", __func__); - wcd9xxx_unlock_sleep(core_res); - } - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); -} - -static void sitar_hs_correct_gpio_plug(struct work_struct *work) -{ - struct sitar_priv *sitar; - struct snd_soc_codec *codec; - int retry = 0, i; - bool correction = false; - s32 mic_mv[MBHC_NUM_DCE_PLUG_DETECT]; - short mb_v[MBHC_NUM_DCE_PLUG_DETECT]; - enum sitar_mbhc_plug_type plug_type[MBHC_NUM_DCE_PLUG_DETECT]; - unsigned long timeout; - struct wcd9xxx *core; - struct wcd9xxx_core_resource *core_res; - - sitar = container_of(work, struct sitar_priv, hs_correct_plug_work); - codec = sitar->codec; - core = sitar->codec->control_data; - core_res = &core->core_res; - - pr_debug("%s: enter\n", __func__); - sitar->mbhc_cfg.mclk_cb_fn(codec, 1, false); - - /* Keep override on during entire plug type correction work. - * - * This is okay under the assumption that any GPIO irqs which use - * MBHC block cancel and sync this work so override is off again - * prior to GPIO interrupt handler's MBHC block usage. - * Also while this correction work is running, we can guarantee - * DAPM doesn't use any MBHC block as this work only runs with - * headphone detection. - */ - sitar_turn_onoff_override(codec, true); - - timeout = jiffies + msecs_to_jiffies(SITAR_HS_DETECT_PLUG_TIME_MS); - while (!time_after(jiffies, timeout)) { - ++retry; - rmb(); - if (sitar->hs_detect_work_stop) { - pr_debug("%s: stop requested\n", __func__); - break; - } - - msleep(SITAR_HS_DETECT_PLUG_INERVAL_MS); - if (sitar_hs_gpio_level_remove(sitar)) { - pr_debug("%s: GPIO value is low\n", __func__); - break; - } - - /* can race with removal interrupt */ - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - for (i = 0; i < MBHC_NUM_DCE_PLUG_DETECT; i++) { - mb_v[i] = __sitar_codec_sta_dce(codec, 1, true, true); - mic_mv[i] = sitar_codec_sta_dce_v(codec, 1 , mb_v[i]); - pr_debug("%s : DCE run %d, mic_mv = %d(%x)\n", - __func__, retry, mic_mv[i], mb_v[i]); - } - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - - if (sitar_codec_is_invalid_plug(codec, mic_mv, plug_type)) { - pr_debug("Invalid plug in attempt # %d\n", retry); - if (retry == NUM_ATTEMPTS_TO_REPORT && - sitar->current_plug == PLUG_TYPE_NONE) { - sitar_codec_report_plug(codec, 1, - SND_JACK_HEADPHONE); - } - } else if (!sitar_codec_is_invalid_plug(codec, mic_mv, - plug_type) && - plug_type[0] == PLUG_TYPE_HEADPHONE) { - pr_debug("Good headphone detected, continue polling mic\n"); - if (sitar->current_plug == PLUG_TYPE_NONE) { - sitar_codec_report_plug(codec, 1, - SND_JACK_HEADPHONE); - } - } else { - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - /* Turn off override */ - sitar_turn_onoff_override(codec, false); - sitar_find_plug_and_report(codec, plug_type[0]); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - pr_debug("Attempt %d found correct plug %d\n", retry, - plug_type[0]); - correction = true; - break; - } - } - - /* Turn off override */ - if (!correction) - sitar_turn_onoff_override(codec, false); - - sitar->mbhc_cfg.mclk_cb_fn(codec, 0, false); - pr_debug("%s: leave\n", __func__); - /* unlock sleep */ - wcd9xxx_unlock_sleep(core_res); -} - -/* called under codec_resource_lock acquisition */ -static void sitar_codec_decide_gpio_plug(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - short mb_v[MBHC_NUM_DCE_PLUG_DETECT]; - s32 mic_mv[MBHC_NUM_DCE_PLUG_DETECT]; - enum sitar_mbhc_plug_type plug_type[MBHC_NUM_DCE_PLUG_DETECT]; - int i; - - pr_debug("%s: enter\n", __func__); - - sitar_turn_onoff_override(codec, true); - mb_v[0] = sitar_codec_setup_hs_polling(codec); - mic_mv[0] = sitar_codec_sta_dce_v(codec, 1, mb_v[0]); - pr_debug("%s: DCE run 1, mic_mv = %d\n", __func__, mic_mv[0]); - - for (i = 1; i < MBHC_NUM_DCE_PLUG_DETECT; i++) { - mb_v[i] = __sitar_codec_sta_dce(codec, 1, true, true); - mic_mv[i] = sitar_codec_sta_dce_v(codec, 1 , mb_v[i]); - pr_debug("%s: DCE run %d, mic_mv = %d\n", __func__, i + 1, - mic_mv[i]); - } - sitar_turn_onoff_override(codec, false); - - if (sitar_hs_gpio_level_remove(sitar)) { - pr_debug("%s: GPIO value is low when determining plug\n", - __func__); - return; - } - - if (sitar_codec_is_invalid_plug(codec, mic_mv, plug_type)) { - sitar_schedule_hs_detect_plug(sitar); - } else if (plug_type[0] == PLUG_TYPE_HEADPHONE) { - sitar_codec_report_plug(codec, 1, SND_JACK_HEADPHONE); - sitar_schedule_hs_detect_plug(sitar); - } else if (plug_type[0] == PLUG_TYPE_HEADSET) { - pr_debug("%s: Valid plug found, determine plug type\n", - __func__); - sitar_find_plug_and_report(codec, plug_type[0]); - } - -} - -/* called under codec_resource_lock acquisition */ -static void sitar_codec_detect_plug_type(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - const struct sitar_mbhc_plug_detect_cfg *plug_det = - SITAR_MBHC_CAL_PLUG_DET_PTR(sitar->mbhc_cfg.calibration); - - if (plug_det->t_ins_complete > 20) - msleep(plug_det->t_ins_complete); - else - usleep_range(plug_det->t_ins_complete * 1000, - plug_det->t_ins_complete * 1000); - - if (sitar_hs_gpio_level_remove(sitar)) - pr_debug("%s: GPIO value is low when determining " - "plug\n", __func__); - else - sitar_codec_decide_gpio_plug(codec); - - return; -} - -static void sitar_hs_gpio_handler(struct snd_soc_codec *codec) -{ - bool insert; - struct sitar_priv *priv = snd_soc_codec_get_drvdata(codec); - bool is_removed = false; - - pr_debug("%s: enter\n", __func__); - - priv->in_gpio_handler = true; - /* Wait here for debounce time */ - usleep_range(SITAR_GPIO_IRQ_DEBOUNCE_TIME_US, - SITAR_GPIO_IRQ_DEBOUNCE_TIME_US); - - SITAR_ACQUIRE_LOCK(priv->codec_resource_lock); - - /* cancel pending button press */ - if (sitar_cancel_btn_work(priv)) - pr_debug("%s: button press is canceled\n", __func__); - - insert = (gpio_get_value_cansleep(priv->mbhc_cfg.gpio) == - priv->mbhc_cfg.gpio_level_insert); - if ((priv->current_plug == PLUG_TYPE_NONE) && insert) { - priv->lpi_enabled = false; - wmb(); - - /* cancel detect plug */ - sitar_cancel_hs_detect_plug(priv); - - /* Disable Mic Bias pull down and HPH Switch to GND */ - snd_soc_update_bits(codec, priv->mbhc_bias_regs.ctl_reg, 0x01, - 0x00); - snd_soc_update_bits(codec, SITAR_A_MBHC_HPH, 0x01, 0x00); - sitar_codec_detect_plug_type(codec); - } else if ((priv->current_plug != PLUG_TYPE_NONE) && !insert) { - priv->lpi_enabled = false; - wmb(); - - /* cancel detect plug */ - sitar_cancel_hs_detect_plug(priv); - - if (priv->current_plug == PLUG_TYPE_HEADPHONE) { - sitar_codec_report_plug(codec, 0, SND_JACK_HEADPHONE); - is_removed = true; - } else if (priv->current_plug == PLUG_TYPE_HEADSET) { - sitar_codec_pause_hs_polling(codec); - sitar_codec_cleanup_hs_polling(codec); - sitar_codec_report_plug(codec, 0, SND_JACK_HEADSET); - is_removed = true; - } - - if (is_removed) { - /* Enable Mic Bias pull down and HPH Switch to GND */ - snd_soc_update_bits(codec, - priv->mbhc_bias_regs.ctl_reg, 0x01, - 0x01); - snd_soc_update_bits(codec, SITAR_A_MBHC_HPH, 0x01, - 0x01); - /* Make sure mic trigger is turned off */ - snd_soc_update_bits(codec, - priv->mbhc_bias_regs.ctl_reg, - 0x01, 0x01); - snd_soc_update_bits(codec, - priv->mbhc_bias_regs.mbhc_reg, - 0x90, 0x00); - /* Reset MBHC State Machine */ - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, - 0x08, 0x08); - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_CLK_CTL, - 0x08, 0x00); - /* Turn off override */ - sitar_turn_onoff_override(codec, false); - } - } - - priv->in_gpio_handler = false; - SITAR_RELEASE_LOCK(priv->codec_resource_lock); - pr_debug("%s: leave\n", __func__); -} - -static irqreturn_t sitar_mechanical_plug_detect_irq(int irq, void *data) -{ - int r = IRQ_HANDLED; - struct snd_soc_codec *codec = data; - struct wcd9xxx *core = codec->control_data; - struct wcd9xxx_core_resource *core_res = &core->core_res; - - if (unlikely(wcd9xxx_lock_sleep(core_res) == false)) { - pr_warn("%s(): Failed to hold suspend\n", __func__); - r = IRQ_NONE; - } else { - sitar_hs_gpio_handler(codec); - wcd9xxx_unlock_sleep(codec->control_data); - } - return r; -} - -static int sitar_mbhc_init_and_calibrate(struct snd_soc_codec *codec) -{ - int rc = 0; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - sitar->mbhc_cfg.mclk_cb_fn(codec, 1, false); - sitar_mbhc_init(codec); - sitar_mbhc_cal(codec); - sitar_mbhc_calc_thres(codec); - sitar->mbhc_cfg.mclk_cb_fn(codec, 0, false); - sitar_codec_calibrate_hs_polling(codec); - - /* Enable Mic Bias pull down and HPH Switch to GND */ - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.ctl_reg, - 0x01, 0x01); - snd_soc_update_bits(codec, SITAR_A_MBHC_HPH, - 0x01, 0x01); - - rc = request_threaded_irq(sitar->mbhc_cfg.gpio_irq, - NULL, - sitar_mechanical_plug_detect_irq, - (IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING), - "sitar-hs-gpio", codec); - - if (!IS_ERR_VALUE(rc)) { - rc = enable_irq_wake(sitar->mbhc_cfg.gpio_irq); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, - 0x10, 0x10); - wcd9xxx_enable_irq(codec->control_data, - WCD9XXX_IRQ_HPH_PA_OCPL_FAULT); - wcd9xxx_enable_irq(codec->control_data, - WCD9XXX_IRQ_HPH_PA_OCPR_FAULT); - /* Bootup time detection */ - sitar_hs_gpio_handler(codec); - } - - return rc; -} - -static void mbhc_fw_read(struct work_struct *work) -{ - struct delayed_work *dwork; - struct sitar_priv *sitar; - struct snd_soc_codec *codec; - const struct firmware *fw; - int ret = -1, retry = 0; - - dwork = to_delayed_work(work); - sitar = container_of(dwork, struct sitar_priv, - mbhc_firmware_dwork); - codec = sitar->codec; - - while (retry < MBHC_FW_READ_ATTEMPTS) { - retry++; - pr_info("%s:Attempt %d to request MBHC firmware\n", - __func__, retry); - ret = request_firmware(&fw, "wcd9310/wcd9310_mbhc.bin", - codec->dev); - - if (ret != 0) { - usleep_range(MBHC_FW_READ_TIMEOUT, - MBHC_FW_READ_TIMEOUT); - } else { - pr_info("%s: MBHC Firmware read succesful\n", __func__); - break; - } - } - - if (ret != 0) { - pr_err("%s: Cannot load MBHC firmware use default cal\n", - __func__); - } else if (sitar_mbhc_fw_validate(fw) == false) { - pr_err("%s: Invalid MBHC cal data size use default cal\n", - __func__); - release_firmware(fw); - } else { - sitar->calibration = (void *)fw->data; - sitar->mbhc_fw = fw; - } - - sitar_mbhc_init_and_calibrate(codec); -} - -int sitar_hs_detect(struct snd_soc_codec *codec, - const struct sitar_mbhc_config *cfg) -{ - struct sitar_priv *sitar; - int rc = 0; - - if (!codec || !cfg->calibration) { - pr_err("Error: no codec or calibration\n"); - return -EINVAL; - } - - if (cfg->mclk_rate != SITAR_MCLK_RATE_12288KHZ) { - if (cfg->mclk_rate == SITAR_MCLK_RATE_9600KHZ) - pr_err("Error: clock rate %dHz is not yet supported\n", - cfg->mclk_rate); - else - pr_err("Error: unsupported clock rate %d\n", - cfg->mclk_rate); - return -EINVAL; - } - - sitar = snd_soc_codec_get_drvdata(codec); - sitar->mbhc_cfg = *cfg; - sitar->in_gpio_handler = false; - sitar->current_plug = PLUG_TYPE_NONE; - sitar->lpi_enabled = false; - sitar_get_mbhc_micbias_regs(codec, &sitar->mbhc_bias_regs); - - /* Put CFILT in fast mode by default */ - snd_soc_update_bits(codec, sitar->mbhc_bias_regs.cfilt_ctl, - 0x40, SITAR_CFILT_FAST_MODE); - - INIT_DELAYED_WORK(&sitar->mbhc_firmware_dwork, mbhc_fw_read); - INIT_DELAYED_WORK(&sitar->mbhc_btn_dwork, btn_lpress_fn); - INIT_WORK(&sitar->hphlocp_work, hphlocp_off_report); - INIT_WORK(&sitar->hphrocp_work, hphrocp_off_report); - INIT_WORK(&sitar->hs_correct_plug_work, - sitar_hs_correct_gpio_plug); - - if (!sitar->mbhc_cfg.read_fw_bin) { - rc = sitar_mbhc_init_and_calibrate(codec); - } else { - schedule_delayed_work(&sitar->mbhc_firmware_dwork, - usecs_to_jiffies(MBHC_FW_READ_TIMEOUT)); - } - - return rc; -} -EXPORT_SYMBOL_GPL(sitar_hs_detect); - -static int sitar_determine_button(const struct sitar_priv *priv, - const s32 bias_mv) -{ - s16 *v_btn_low, *v_btn_high; - struct sitar_mbhc_btn_detect_cfg *btn_det; - int i, btn = -1; - - btn_det = SITAR_MBHC_CAL_BTN_DET_PTR(priv->mbhc_cfg.calibration); - v_btn_low = sitar_mbhc_cal_btn_det_mp(btn_det, SITAR_BTN_DET_V_BTN_LOW); - v_btn_high = sitar_mbhc_cal_btn_det_mp(btn_det, - SITAR_BTN_DET_V_BTN_HIGH); - for (i = 0; i < btn_det->num_btn; i++) { - if ((v_btn_low[i] <= bias_mv) && (v_btn_high[i] >= bias_mv)) { - btn = i; - break; - } - } - - if (btn == -1) - pr_debug("%s: couldn't find button number for mic mv %d\n", - __func__, bias_mv); - - return btn; -} - -static int sitar_get_button_mask(const int btn) -{ - int mask = 0; - switch (btn) { - case 0: - mask = SND_JACK_BTN_0; - break; - case 1: - mask = SND_JACK_BTN_1; - break; - case 2: - mask = SND_JACK_BTN_2; - break; - case 3: - mask = SND_JACK_BTN_3; - break; - case 4: - mask = SND_JACK_BTN_4; - break; - case 5: - mask = SND_JACK_BTN_5; - break; - case 6: - mask = SND_JACK_BTN_6; - break; - case 7: - mask = SND_JACK_BTN_7; - break; - } - return mask; -} - - -static irqreturn_t sitar_dce_handler(int irq, void *data) -{ - int i, mask; - short dce, sta, bias_value_dce; - s32 mv, stamv, bias_mv_dce; - int btn = -1, meas = 0; - struct sitar_priv *priv = data; - const struct sitar_mbhc_btn_detect_cfg *d = - SITAR_MBHC_CAL_BTN_DET_PTR(priv->mbhc_cfg.calibration); - short btnmeas[d->n_btn_meas + 1]; - struct snd_soc_codec *codec = priv->codec; - struct wcd9xxx *core = dev_get_drvdata(priv->codec->dev->parent); - struct wcd9xxx_core_resource *core_res = &core->core_res; - int n_btn_meas = d->n_btn_meas; - u8 mbhc_status = snd_soc_read(codec, SITAR_A_CDC_MBHC_B1_STATUS) & 0x3E; - - pr_debug("%s: enter\n", __func__); - - SITAR_ACQUIRE_LOCK(priv->codec_resource_lock); - if (priv->mbhc_state == MBHC_STATE_POTENTIAL_RECOVERY) { - pr_debug("%s: mbhc is being recovered, skip button press\n", - __func__); - goto done; - } - - priv->mbhc_state = MBHC_STATE_POTENTIAL; - - if (!priv->mbhc_polling_active) { - pr_warn("%s: mbhc polling is not active, skip button press\n", - __func__); - goto done; - } - - dce = sitar_codec_read_dce_result(codec); - mv = sitar_codec_sta_dce_v(codec, 1, dce); - - /* If GPIO interrupt already kicked in, ignore button press */ - if (priv->in_gpio_handler) { - pr_debug("%s: GPIO State Changed, ignore button press\n", - __func__); - btn = -1; - goto done; - } - - if (mbhc_status != SITAR_MBHC_STATUS_REL_DETECTION) { - if (priv->mbhc_last_resume && - !time_after(jiffies, priv->mbhc_last_resume + HZ)) { - pr_debug("%s: Button is already released shortly after " - "resume\n", __func__); - n_btn_meas = 0; - } else { - pr_debug("%s: Button is already released without " - "resume", __func__); - sta = sitar_codec_read_sta_result(codec); - stamv = sitar_codec_sta_dce_v(codec, 0, sta); - btn = sitar_determine_button(priv, mv); - if (btn != sitar_determine_button(priv, stamv)) - btn = -1; - goto done; - } - } - - /* determine pressed button */ - btnmeas[meas++] = sitar_determine_button(priv, mv); - pr_debug("%s: meas %d - DCE %d,%d, button %d\n", __func__, - meas - 1, dce, mv, btnmeas[meas - 1]); - if (n_btn_meas == 0) - btn = btnmeas[0]; - for (; ((d->n_btn_meas) && (meas < (d->n_btn_meas + 1))); meas++) { - bias_value_dce = sitar_codec_sta_dce(codec, 1, false); - bias_mv_dce = sitar_codec_sta_dce_v(codec, 1, bias_value_dce); - btnmeas[meas] = sitar_determine_button(priv, bias_mv_dce); - pr_debug("%s: meas %d - DCE %d,%d, button %d\n", - __func__, meas, bias_value_dce, bias_mv_dce, - btnmeas[meas]); - /* if large enough measurements are collected, - * start to check if last all n_btn_con measurements were - * in same button low/high range */ - if (meas + 1 >= d->n_btn_con) { - for (i = 0; i < d->n_btn_con; i++) - if ((btnmeas[meas] < 0) || - (btnmeas[meas] != btnmeas[meas - i])) - break; - if (i == d->n_btn_con) { - /* button pressed */ - btn = btnmeas[meas]; - break; - } else if ((n_btn_meas - meas) < (d->n_btn_con - 1)) { - /* if left measurements are less than n_btn_con, - * it's impossible to find button number */ - break; - } - } - } - - if (btn >= 0) { - if (priv->in_gpio_handler) { - pr_debug("%s: GPIO already triggered, ignore button " - "press\n", __func__); - goto done; - } - mask = sitar_get_button_mask(btn); - priv->buttons_pressed |= mask; - wcd9xxx_lock_sleep(core_res); - if (schedule_delayed_work(&priv->mbhc_btn_dwork, - msecs_to_jiffies(400)) == 0) { - WARN(1, "Button pressed twice without release" - "event\n"); - wcd9xxx_unlock_sleep(core_res); - } - } else { - pr_debug("%s: bogus button press, too short press?\n", - __func__); - } - - done: - pr_debug("%s: leave\n", __func__); - SITAR_RELEASE_LOCK(priv->codec_resource_lock); - return IRQ_HANDLED; -} - -static int sitar_is_fake_press(struct sitar_priv *priv) -{ - int i; - int r = 0; - struct snd_soc_codec *codec = priv->codec; - const int dces = MBHC_NUM_DCE_PLUG_DETECT; - short mb_v; - - for (i = 0; i < dces; i++) { - usleep_range(10000, 10000); - if (i == 0) { - mb_v = sitar_codec_sta_dce(codec, 0, true); - pr_debug("%s: STA[0]: %d,%d\n", __func__, mb_v, - sitar_codec_sta_dce_v(codec, 0, mb_v)); - if (mb_v < (short)priv->mbhc_data.v_b1_hu || - mb_v > (short)priv->mbhc_data.v_ins_hu) { - r = 1; - break; - } - } else { - mb_v = sitar_codec_sta_dce(codec, 1, true); - pr_debug("%s: DCE[%d]: %d,%d\n", __func__, i, mb_v, - sitar_codec_sta_dce_v(codec, 1, mb_v)); - if (mb_v < (short)priv->mbhc_data.v_b1_h || - mb_v > (short)priv->mbhc_data.v_ins_h) { - r = 1; - break; - } - } - } - - return r; -} - -static irqreturn_t sitar_release_handler(int irq, void *data) -{ - int ret; - struct sitar_priv *priv = data; - struct snd_soc_codec *codec = priv->codec; - - pr_debug("%s: enter\n", __func__); - - SITAR_ACQUIRE_LOCK(priv->codec_resource_lock); - priv->mbhc_state = MBHC_STATE_RELEASE; - - if (priv->buttons_pressed & SITAR_JACK_BUTTON_MASK) { - ret = sitar_cancel_btn_work(priv); - if (ret == 0) { - pr_debug("%s: Reporting long button release event\n", - __func__); - if (priv->mbhc_cfg.button_jack) - sitar_snd_soc_jack_report(priv, - priv->mbhc_cfg.button_jack, 0, - priv->buttons_pressed); - } else { - if (sitar_is_fake_press(priv)) { - pr_debug("%s: Fake button press interrupt\n", - __func__); - } else if (priv->mbhc_cfg.button_jack) { - if (priv->in_gpio_handler) { - pr_debug("%s: GPIO kicked in, ignore\n", - __func__); - } else { - pr_debug("%s: Reporting short button 0 " - "press and release\n", - __func__); - sitar_snd_soc_jack_report(priv, - priv->mbhc_cfg.button_jack, - priv->buttons_pressed, - priv->buttons_pressed); - sitar_snd_soc_jack_report(priv, - priv->mbhc_cfg.button_jack, 0, - priv->buttons_pressed); - } - } - } - - priv->buttons_pressed &= ~SITAR_JACK_BUTTON_MASK; - } - - sitar_codec_calibrate_hs_polling(codec); - - if (priv->mbhc_cfg.gpio) - msleep(SITAR_MBHC_GPIO_REL_DEBOUNCE_TIME_MS); - - sitar_codec_start_hs_polling(codec); - - pr_debug("%s: leave\n", __func__); - SITAR_RELEASE_LOCK(priv->codec_resource_lock); - - return IRQ_HANDLED; -} - -static irqreturn_t sitar_hphl_ocp_irq(int irq, void *data) -{ - struct sitar_priv *sitar = data; - struct snd_soc_codec *codec; - struct wcd9xxx *core; - struct wcd9xxx_core_resource *core_res; - - pr_info("%s: received HPHL OCP irq\n", __func__); - - if (sitar) { - codec = sitar->codec; - core = codec->control_data; - core_res = &core->core_res; - - if ((sitar->hphlocp_cnt < SITAR_OCP_ATTEMPT) && - (!sitar->hphrocp_cnt)) { - pr_info("%s: retry\n", __func__); - sitar->hphlocp_cnt++; - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, 0x10, - 0x00); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, 0x10, - 0x10); - } else { - wcd9xxx_disable_irq(core_res, - WCD9XXX_IRQ_HPH_PA_OCPL_FAULT); - sitar->hph_status |= SND_JACK_OC_HPHL; - if (sitar->mbhc_cfg.headset_jack) - sitar_snd_soc_jack_report(sitar, - sitar->mbhc_cfg.headset_jack, - sitar->hph_status, - SITAR_JACK_MASK); - } - } else { - pr_err("%s: Bad sitar private data\n", __func__); - } - - return IRQ_HANDLED; -} - -static irqreturn_t sitar_hphr_ocp_irq(int irq, void *data) -{ - struct sitar_priv *sitar = data; - struct snd_soc_codec *codec; - struct wcd9xxx *core; - struct wcd9xxx_core_resource *core_res; - - pr_info("%s: received HPHR OCP irq\n", __func__); - - if (sitar) { - codec = sitar->codec; - core = codec->control_data; - core_res = &core->core_res; - - if ((sitar->hphrocp_cnt < SITAR_OCP_ATTEMPT) && - (!sitar->hphlocp_cnt)) { - pr_info("%s: retry\n", __func__); - sitar->hphrocp_cnt++; - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, 0x10, - 0x00); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, 0x10, - 0x10); - } else { - wcd9xxx_disable_irq(core_res, - WCD9XXX_IRQ_HPH_PA_OCPR_FAULT); - sitar->hph_status |= SND_JACK_OC_HPHR; - if (sitar->mbhc_cfg.headset_jack) - sitar_snd_soc_jack_report(sitar, - sitar->mbhc_cfg.headset_jack, - sitar->hph_status, - SITAR_JACK_MASK); - } - } else { - pr_err("%s: Bad sitar private data\n", __func__); - } - - return IRQ_HANDLED; -} - -static irqreturn_t sitar_hs_insert_irq(int irq, void *data) -{ - struct sitar_priv *priv = data; - struct snd_soc_codec *codec = priv->codec; - struct wcd9xxx *core = codec->control_data; - struct wcd9xxx_core_resource *core_res = &core->core_res; - - pr_debug("%s: enter\n", __func__); - SITAR_ACQUIRE_LOCK(priv->codec_resource_lock); - wcd9xxx_disable_irq(core_res, WCD9XXX_IRQ_MBHC_INSERTION); - - snd_soc_update_bits(codec, SITAR_A_CDC_MBHC_INT_CTL, 0x03, 0x00); - - /* Turn off both HPH and MIC line schmitt triggers */ - snd_soc_update_bits(codec, priv->mbhc_bias_regs.mbhc_reg, 0x90, 0x00); - snd_soc_update_bits(codec, SITAR_A_MBHC_HPH, 0x13, 0x00); - snd_soc_update_bits(codec, priv->mbhc_bias_regs.ctl_reg, 0x01, 0x00); - - pr_debug("%s: MIC trigger insertion interrupt\n", __func__); - - rmb(); - if (priv->lpi_enabled) - msleep(100); - - rmb(); - if (!priv->lpi_enabled) { - pr_debug("%s: lpi is disabled\n", __func__); - } else if (gpio_get_value_cansleep(priv->mbhc_cfg.gpio) == - priv->mbhc_cfg.gpio_level_insert) { - pr_debug("%s: Valid insertion, " - "detect plug type\n", __func__); - sitar_codec_decide_gpio_plug(codec); - } else { - pr_debug("%s: Invalid insertion, " - "stop plug detection\n", __func__); - } - SITAR_RELEASE_LOCK(priv->codec_resource_lock); - return IRQ_HANDLED; -} - -static bool is_valid_mic_voltage(struct snd_soc_codec *codec, s32 mic_mv) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - struct sitar_mbhc_plug_type_cfg *plug_type = - SITAR_MBHC_CAL_PLUG_TYPE_PTR(sitar->mbhc_cfg.calibration); - - return (!(mic_mv > SITAR_MBHC_FAKE_INSERT_LOW - && mic_mv < SITAR_MBHC_FAKE_INSERT_HIGH) - && (mic_mv > plug_type->v_no_mic) - && (mic_mv < plug_type->v_hs_max)) ? true : false; -} - -/* called under codec_resource_lock acquisition - * returns true if mic voltage range is back to normal insertion - * returns false either if timedout or removed */ -static bool sitar_hs_remove_settle(struct snd_soc_codec *codec) -{ - int i; - bool timedout, settled = false; - s32 mic_mv[MBHC_NUM_DCE_PLUG_DETECT]; - short mb_v[MBHC_NUM_DCE_PLUG_DETECT]; - unsigned long retry = 0, timeout; - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - - timeout = jiffies + msecs_to_jiffies(SITAR_HS_DETECT_PLUG_TIME_MS); - while (!(timedout = time_after(jiffies, timeout))) { - retry++; - if (sitar_hs_gpio_level_remove(sitar)) { - pr_debug("%s: GPIO indicates removal\n", __func__); - break; - } - - if (retry > 1) - msleep(250); - else - msleep(50); - - if (sitar_hs_gpio_level_remove(sitar)) { - pr_debug("%s: GPIO indicates removal\n", __func__); - break; - } - - sitar_turn_onoff_override(codec, true); - for (i = 0; i < MBHC_NUM_DCE_PLUG_DETECT; i++) { - mb_v[i] = __sitar_codec_sta_dce(codec, 1, true, true); - mic_mv[i] = sitar_codec_sta_dce_v(codec, 1 , mb_v[i]); - pr_debug("%s : DCE run %lu, mic_mv = %d(%x)\n", - __func__, retry, mic_mv[i], mb_v[i]); - } - sitar_turn_onoff_override(codec, false); - - if (sitar_hs_gpio_level_remove(sitar)) { - pr_debug("%s: GPIO indicates removal\n", __func__); - break; - } - - for (i = 0; i < MBHC_NUM_DCE_PLUG_DETECT; i++) - if (!is_valid_mic_voltage(codec, mic_mv[i])) - break; - - if (i == MBHC_NUM_DCE_PLUG_DETECT) { - pr_debug("%s: MIC voltage settled\n", __func__); - settled = true; - msleep(200); - break; - } - } - - if (timedout) - pr_debug("%s: Microphone did not settle in %d seconds\n", - __func__, SITAR_HS_DETECT_PLUG_TIME_MS); - return settled; -} - -static irqreturn_t sitar_hs_remove_irq(int irq, void *data) -{ - struct sitar_priv *priv = data; - struct snd_soc_codec *codec = priv->codec; - - pr_debug("%s: enter, removal interrupt\n", __func__); - - SITAR_ACQUIRE_LOCK(priv->codec_resource_lock); - if (sitar_hs_remove_settle(codec)) - sitar_codec_start_hs_polling(codec); - pr_debug("%s: remove settle done\n", __func__); - - SITAR_RELEASE_LOCK(priv->codec_resource_lock); - return IRQ_HANDLED; -} - - - -static irqreturn_t sitar_slimbus_irq(int irq, void *data) -{ - struct sitar_priv *priv = data; - struct snd_soc_codec *codec = priv->codec; - unsigned long slimbus_value; - int i, j, k, port_id, ch_mask_temp; - u8 val; - - - for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++) { - slimbus_value = wcd9xxx_interface_reg_read(codec->control_data, - SITAR_SLIM_PGD_PORT_INT_STATUS0 + i); - for_each_set_bit(j, &slimbus_value, BITS_PER_BYTE) { - port_id = i*8 + j; - val = wcd9xxx_interface_reg_read(codec->control_data, - SITAR_SLIM_PGD_PORT_INT_SOURCE0 + port_id); - if (val & 0x1) - pr_err_ratelimited("overflow error on port %x, value %x\n", - port_id, val); - if (val & 0x2) - pr_err_ratelimited("underflow error on port %x,value %x\n", - port_id, val); - if (val & 0x4) { - pr_debug("%s: port %x disconnect value %x\n", - __func__, port_id, val); - for (k = 0; k < ARRAY_SIZE(sitar_dai); k++) { - ch_mask_temp = 1 << port_id; - if (ch_mask_temp & - priv->dai[k].ch_mask) { - priv->dai[k].ch_mask &= - ~ch_mask_temp; - if (!priv->dai[k].ch_mask) - wake_up( - &priv->dai[k].dai_wait); - } - } - } - } - wcd9xxx_interface_reg_write(codec->control_data, - SITAR_SLIM_PGD_PORT_INT_CLR0 + i, slimbus_value); - val = 0x0; - } - - return IRQ_HANDLED; -} - - -static int sitar_handle_pdata(struct sitar_priv *sitar) -{ - struct snd_soc_codec *codec = sitar->codec; - struct wcd9xxx_pdata *pdata = sitar->pdata; - int k1, k2, rc = 0; - u8 leg_mode = pdata->amic_settings.legacy_mode; - u8 txfe_bypass = pdata->amic_settings.txfe_enable; - u8 txfe_buff = pdata->amic_settings.txfe_buff; - u8 flag = pdata->amic_settings.use_pdata; - u8 i = 0, j = 0; - u8 val_txfe = 0, value = 0; - int amic_reg_count = 0; - - if (!pdata) { - rc = -ENODEV; - goto done; - } - - /* Make sure settings are correct */ - if ((pdata->micbias.ldoh_v > SITAR_LDOH_2P85_V) || - (pdata->micbias.bias1_cfilt_sel > SITAR_CFILT2_SEL) || - (pdata->micbias.bias2_cfilt_sel > SITAR_CFILT2_SEL)) { - rc = -EINVAL; - goto done; - } - - /* figure out k value */ - k1 = sitar_find_k_value(pdata->micbias.ldoh_v, - pdata->micbias.cfilt1_mv); - k2 = sitar_find_k_value(pdata->micbias.ldoh_v, - pdata->micbias.cfilt2_mv); - - if (IS_ERR_VALUE(k1) || IS_ERR_VALUE(k2)) { - rc = -EINVAL; - goto done; - } - - /* Set voltage level and always use LDO */ - snd_soc_update_bits(codec, SITAR_A_LDO_H_MODE_1, 0x0C, - (pdata->micbias.ldoh_v << 2)); - - snd_soc_update_bits(codec, SITAR_A_MICB_CFILT_1_VAL, 0xFC, - (k1 << 2)); - snd_soc_update_bits(codec, SITAR_A_MICB_CFILT_2_VAL, 0xFC, - (k2 << 2)); - - snd_soc_update_bits(codec, SITAR_A_MICB_1_CTL, 0x60, - (pdata->micbias.bias1_cfilt_sel << 5)); - snd_soc_update_bits(codec, SITAR_A_MICB_2_CTL, 0x60, - (pdata->micbias.bias2_cfilt_sel << 5)); - - /* Set micbias capless mode */ - snd_soc_update_bits(codec, SITAR_A_MICB_1_CTL, 0x10, - (pdata->micbias.bias1_cap_mode << 4)); - snd_soc_update_bits(codec, SITAR_A_MICB_2_CTL, 0x10, - (pdata->micbias.bias2_cap_mode << 4)); - - amic_reg_count = (NUM_AMIC % 2) ? NUM_AMIC + 1 : NUM_AMIC; - for (i = 0; i < amic_reg_count; j++, i += 2) { - if (flag & (0x01 << i)) { - value = (leg_mode & (0x01 << i)) ? 0x10 : 0x00; - val_txfe = (txfe_bypass & (0x01 << i)) ? 0x20 : 0x00; - val_txfe = val_txfe | - ((txfe_buff & (0x01 << i)) ? 0x10 : 0x00); - snd_soc_update_bits(codec, SITAR_A_TX_1_2_EN + j * 10, - 0x10, value); - snd_soc_update_bits(codec, - SITAR_A_TX_1_2_TEST_EN + j * 10, - 0x30, val_txfe); - } - if (flag & (0x01 << (i + 1))) { - value = (leg_mode & (0x01 << (i + 1))) ? 0x01 : 0x00; - val_txfe = (txfe_bypass & - (0x01 << (i + 1))) ? 0x02 : 0x00; - val_txfe |= (txfe_buff & - (0x01 << (i + 1))) ? 0x01 : 0x00; - snd_soc_update_bits(codec, SITAR_A_TX_1_2_EN + j * 10, - 0x01, value); - snd_soc_update_bits(codec, - SITAR_A_TX_1_2_TEST_EN + j * 10, - 0x03, val_txfe); - } - } - if (flag & 0x40) { - value = (leg_mode & 0x40) ? 0x10 : 0x00; - value = value | ((txfe_bypass & 0x40) ? 0x02 : 0x00); - value = value | ((txfe_buff & 0x40) ? 0x01 : 0x00); - snd_soc_update_bits(codec, SITAR_A_TX_4_MBHC_EN, - 0x13, value); - } - - - if (pdata->ocp.use_pdata) { - /* not defined in CODEC specification */ - if (pdata->ocp.hph_ocp_limit == 1 || - pdata->ocp.hph_ocp_limit == 5) { - rc = -EINVAL; - goto done; - } - snd_soc_update_bits(codec, SITAR_A_RX_COM_OCP_CTL, - 0x0F, pdata->ocp.num_attempts); - snd_soc_write(codec, SITAR_A_RX_COM_OCP_COUNT, - ((pdata->ocp.run_time << 4) | pdata->ocp.wait_time)); - snd_soc_update_bits(codec, SITAR_A_RX_HPH_OCP_CTL, - 0xE0, (pdata->ocp.hph_ocp_limit << 5)); - } -done: - return rc; -} - -static const struct sitar_reg_mask_val sitar_1_1_reg_defaults[] = { - - SITAR_REG_VAL(SITAR_A_MICB_1_INT_RBIAS, 0x24), - SITAR_REG_VAL(SITAR_A_MICB_2_INT_RBIAS, 0x24), - - SITAR_REG_VAL(SITAR_A_RX_HPH_BIAS_PA, 0x57), - SITAR_REG_VAL(SITAR_A_RX_HPH_BIAS_LDO, 0x56), - - SITAR_REG_VAL(SITAR_A_RX_EAR_BIAS_PA, 0xA6), - SITAR_REG_VAL(SITAR_A_RX_EAR_GAIN, 0x02), - SITAR_REG_VAL(SITAR_A_RX_EAR_VCM, 0x03), - - SITAR_REG_VAL(SITAR_A_RX_LINE_BIAS_PA, 0xA7), - - SITAR_REG_VAL(SITAR_A_CDC_RX1_B5_CTL, 0x78), - SITAR_REG_VAL(SITAR_A_CDC_RX2_B5_CTL, 0x78), - SITAR_REG_VAL(SITAR_A_CDC_RX3_B5_CTL, 0x78), - - SITAR_REG_VAL(SITAR_A_CDC_RX1_B6_CTL, 0x80), - - SITAR_REG_VAL(SITAR_A_CDC_CLSG_FREQ_THRESH_B3_CTL, 0x1B), - SITAR_REG_VAL(SITAR_A_CDC_CLSG_FREQ_THRESH_B4_CTL, 0x5B), - -}; - -static void sitar_update_reg_defaults(struct snd_soc_codec *codec) -{ - u32 i; - for (i = 0; i < ARRAY_SIZE(sitar_1_1_reg_defaults); i++) - snd_soc_write(codec, sitar_1_1_reg_defaults[i].reg, - sitar_1_1_reg_defaults[i].val); - -} - -static const struct sitar_reg_mask_val sitar_i2c_codec_reg_init_val[] = { - {WCD9XXX_A_CHIP_CTL, 0x1, 0x1}, -}; - -static const struct sitar_reg_mask_val sitar_codec_reg_init_val[] = { - /* Initialize current threshold to 350MA - * number of wait and run cycles to 4096 - */ - {SITAR_A_RX_HPH_OCP_CTL, 0xE0, 0x60}, - {SITAR_A_RX_COM_OCP_COUNT, 0xFF, 0xFF}, - - {SITAR_A_QFUSE_CTL, 0xFF, 0x03}, - - /* Initialize gain registers to use register gain */ - {SITAR_A_RX_HPH_L_GAIN, 0x10, 0x10}, - {SITAR_A_RX_HPH_R_GAIN, 0x10, 0x10}, - {SITAR_A_RX_LINE_1_GAIN, 0x10, 0x10}, - {SITAR_A_RX_LINE_2_GAIN, 0x10, 0x10}, - - /* Set the MICBIAS default output as pull down*/ - {SITAR_A_MICB_1_CTL, 0x01, 0x01}, - {SITAR_A_MICB_2_CTL, 0x01, 0x01}, - - /* Initialize mic biases to differential mode */ - {SITAR_A_MICB_1_INT_RBIAS, 0x24, 0x24}, - {SITAR_A_MICB_2_INT_RBIAS, 0x24, 0x24}, - - {SITAR_A_CDC_CONN_CLSG_CTL, 0x3C, 0x14}, - - /* Use 16 bit sample size for TX1 to TX6 */ - {SITAR_A_CDC_CONN_TX_SB_B1_CTL, 0x30, 0x20}, - {SITAR_A_CDC_CONN_TX_SB_B2_CTL, 0x30, 0x20}, - {SITAR_A_CDC_CONN_TX_SB_B3_CTL, 0x30, 0x20}, - {SITAR_A_CDC_CONN_TX_SB_B4_CTL, 0x30, 0x20}, - {SITAR_A_CDC_CONN_TX_SB_B5_CTL, 0x30, 0x20}, - {SITAR_A_CDC_CLK_TX_CLK_EN_B1_CTL, 0x1, 0x1}, - - /* Use 16 bit sample size for RX */ - {SITAR_A_CDC_CONN_RX_SB_B1_CTL, 0xFF, 0xAA}, - {SITAR_A_CDC_CONN_RX_SB_B2_CTL, 0x02, 0x02}, - - /*enable HPF filter for TX paths */ - {SITAR_A_CDC_TX1_MUX_CTL, 0x8, 0x0}, - {SITAR_A_CDC_TX2_MUX_CTL, 0x8, 0x0}, - - /*enable External clock select*/ - {SITAR_A_CDC_CLK_MCLK_CTL, 0x01, 0x01}, - - /*disabling the cp static overide gain*/ - {SITAR_A_CP_STATIC, 0x10, 0x00}, -}; - -static void sitar_i2c_codec_init_reg(struct snd_soc_codec *codec) -{ - u32 i; - for (i = 0; i < ARRAY_SIZE(sitar_i2c_codec_reg_init_val); i++) - snd_soc_update_bits(codec, sitar_i2c_codec_reg_init_val[i].reg, - sitar_i2c_codec_reg_init_val[i].mask, - sitar_i2c_codec_reg_init_val[i].val); -} - -static void sitar_codec_init_reg(struct snd_soc_codec *codec) -{ - u32 i; - for (i = 0; i < ARRAY_SIZE(sitar_codec_reg_init_val); i++) - snd_soc_update_bits(codec, sitar_codec_reg_init_val[i].reg, - sitar_codec_reg_init_val[i].mask, - sitar_codec_reg_init_val[i].val); -} - -static int sitar_codec_probe(struct snd_soc_codec *codec) -{ - struct wcd9xxx *core; - struct sitar_priv *sitar; - struct snd_soc_dapm_context *dapm = &codec->dapm; - int ret = 0; - int i; - u8 sitar_version; - void *ptr = NULL; - struct wcd9xxx_core_resource *core_res; - - codec->control_data = dev_get_drvdata(codec->dev->parent); - core = codec->control_data; - core_res = &core->core_res; - - sitar = kzalloc(sizeof(struct sitar_priv), GFP_KERNEL); - if (!sitar) { - dev_err(codec->dev, "Failed to allocate private data\n"); - return -ENOMEM; - } - - for (i = 0; i < NUM_DECIMATORS; i++) { - tx_hpf_work[i].sitar = sitar; - tx_hpf_work[i].decimator = i + 1; - INIT_DELAYED_WORK(&tx_hpf_work[i].dwork, - tx_hpf_corner_freq_callback); - } - - - /* Make sure mbhc micbias register addresses are zeroed out */ - memset(&sitar->mbhc_bias_regs, 0, - sizeof(struct mbhc_micbias_regs)); - sitar->cfilt_k_value = 0; - sitar->mbhc_micbias_switched = false; - - /* Make sure mbhc intenal calibration data is zeroed out */ - memset(&sitar->mbhc_data, 0, - sizeof(struct mbhc_internal_cal_data)); - sitar->mbhc_data.t_sta_dce = DEFAULT_DCE_STA_WAIT; - sitar->mbhc_data.t_dce = DEFAULT_DCE_WAIT; - sitar->mbhc_data.t_sta = DEFAULT_STA_WAIT; - snd_soc_codec_set_drvdata(codec, sitar); - - sitar->mclk_enabled = false; - sitar->bandgap_type = SITAR_BANDGAP_OFF; - sitar->clock_active = false; - sitar->config_mode_active = false; - sitar->mbhc_polling_active = false; - sitar->no_mic_headset_override = false; - mutex_init(&sitar->codec_resource_lock); - sitar->codec = codec; - sitar->mbhc_state = MBHC_STATE_NONE; - sitar->mbhc_last_resume = 0; - sitar->pdata = dev_get_platdata(codec->dev->parent); - sitar_update_reg_defaults(codec); - sitar_codec_init_reg(codec); - sitar->intf_type = wcd9xxx_get_intf_type(); - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) - sitar_i2c_codec_init_reg(codec); - - for (i = 0; i < COMPANDER_MAX; i++) { - sitar->comp_enabled[i] = 0; - sitar->comp_fs[i] = COMPANDER_FS_48KHZ; - } - - ret = sitar_handle_pdata(sitar); - if (IS_ERR_VALUE(ret)) { - pr_err("%s: bad pdata\n", __func__); - goto err_pdata; - } - - snd_soc_add_codec_controls(codec, sitar_snd_controls, - ARRAY_SIZE(sitar_snd_controls)); - snd_soc_dapm_new_controls(dapm, sitar_dapm_widgets, - ARRAY_SIZE(sitar_dapm_widgets)); - - ptr = kmalloc((sizeof(sitar_rx_chs) + - sizeof(sitar_tx_chs)), GFP_KERNEL); - if (!ptr) { - pr_err("%s: no mem for slim chan ctl data\n", __func__); - ret = -ENOMEM; - goto err_nomem_slimch; - } - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { - snd_soc_dapm_new_controls(dapm, sitar_dapm_i2s_widgets, - ARRAY_SIZE(sitar_dapm_i2s_widgets)); - snd_soc_dapm_add_routes(dapm, audio_i2s_map, - ARRAY_SIZE(audio_i2s_map)); - for (i = 0; i < ARRAY_SIZE(sitar_i2s_dai); i++) - INIT_LIST_HEAD(&sitar->dai[i].wcd9xxx_ch_list); - } - if (sitar->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - for (i = 0; i < NUM_CODEC_DAIS; i++) { - INIT_LIST_HEAD(&sitar->dai[i].wcd9xxx_ch_list); - init_waitqueue_head(&sitar->dai[i].dai_wait); - } - } - core->num_rx_port = SITAR_RX_MAX; - core->rx_chs = ptr; - memcpy(core->rx_chs, sitar_rx_chs, sizeof(sitar_rx_chs)); - core->num_tx_port = SITAR_TX_MAX; - core->tx_chs = ptr + sizeof(sitar_rx_chs); - memcpy(core->tx_chs, sitar_tx_chs, sizeof(sitar_tx_chs)); - - snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); - - sitar_version = snd_soc_read(codec, WCD9XXX_A_CHIP_VERSION); - pr_info("%s : Sitar version reg 0x%2x\n", __func__, (u32)sitar_version); - - sitar_version &= 0x1F; - pr_info("%s : Sitar version %u\n", __func__, (u32)sitar_version); - - snd_soc_dapm_sync(dapm); - - - ret = wcd9xxx_request_irq(core_res, - WCD9XXX_IRQ_MBHC_INSERTION, - sitar_hs_insert_irq, "Headset insert detect", sitar); - if (ret) { - pr_err("%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_MBHC_INSERTION); - goto err_insert_irq; - } - wcd9xxx_disable_irq(core_res, WCD9XXX_IRQ_MBHC_INSERTION); - - ret = wcd9xxx_request_irq(core_res, - WCD9XXX_IRQ_MBHC_REMOVAL, - sitar_hs_remove_irq, "Headset remove detect", sitar); - if (ret) { - pr_err("%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_MBHC_REMOVAL); - goto err_remove_irq; - } - - ret = wcd9xxx_request_irq(core_res, - WCD9XXX_IRQ_MBHC_POTENTIAL, - sitar_dce_handler, "DC Estimation detect", sitar); - if (ret) { - pr_err("%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_MBHC_POTENTIAL); - goto err_potential_irq; - } - - ret = wcd9xxx_request_irq(core_res, - WCD9XXX_IRQ_MBHC_RELEASE, - sitar_release_handler, - "Button Release detect", sitar); - if (ret) { - pr_err("%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_MBHC_RELEASE); - goto err_release_irq; - } - - ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS, - sitar_slimbus_irq, "SLIMBUS Slave", sitar); - if (ret) { - pr_err("%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_SLIMBUS); - goto err_slimbus_irq; - } - - for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++) - wcd9xxx_interface_reg_write(codec->control_data, - SITAR_SLIM_PGD_PORT_INT_EN0 + i, 0xFF); - - - ret = wcd9xxx_request_irq(core_res, - WCD9XXX_IRQ_HPH_PA_OCPL_FAULT, - sitar_hphl_ocp_irq, - "HPH_L OCP detect", sitar); - if (ret) { - pr_err("%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_HPH_PA_OCPL_FAULT); - goto err_hphl_ocp_irq; - } - wcd9xxx_disable_irq(core_res, - WCD9XXX_IRQ_HPH_PA_OCPL_FAULT); - - ret = wcd9xxx_request_irq(core_res, - WCD9XXX_IRQ_HPH_PA_OCPR_FAULT, - sitar_hphr_ocp_irq, "HPH_R OCP detect", - sitar); - if (ret) { - pr_err("%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_HPH_PA_OCPR_FAULT); - goto err_hphr_ocp_irq; - } - wcd9xxx_disable_irq(core_res, WCD9XXX_IRQ_HPH_PA_OCPR_FAULT); - - codec->ignore_pmdown_time = 1; - -#ifdef CONFIG_DEBUG_FS - debug_sitar_priv = sitar; -#endif - - return ret; - -err_hphr_ocp_irq: - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_HPH_PA_OCPL_FAULT, - sitar); -err_hphl_ocp_irq: - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, sitar); -err_slimbus_irq: - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_RELEASE, sitar); -err_release_irq: - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_POTENTIAL, - sitar); -err_potential_irq: - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_REMOVAL, sitar); -err_remove_irq: - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_INSERTION, - sitar); -err_insert_irq: - kfree(ptr); -err_nomem_slimch: -err_pdata: - mutex_destroy(&sitar->codec_resource_lock); - kfree(sitar); - return ret; -} -static int sitar_codec_remove(struct snd_soc_codec *codec) -{ - struct sitar_priv *sitar = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = codec->control_data; - struct wcd9xxx_core_resource *core_res = &core->core_res; - - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_SLIMBUS, sitar); - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_RELEASE, sitar); - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_POTENTIAL, - sitar); - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_REMOVAL, sitar); - wcd9xxx_free_irq(core_res, WCD9XXX_IRQ_MBHC_INSERTION, - sitar); - SITAR_ACQUIRE_LOCK(sitar->codec_resource_lock); - sitar_codec_disable_clock_block(codec); - SITAR_RELEASE_LOCK(sitar->codec_resource_lock); - sitar_codec_enable_bandgap(codec, SITAR_BANDGAP_OFF); - if (sitar->mbhc_fw) - release_firmware(sitar->mbhc_fw); - mutex_destroy(&sitar->codec_resource_lock); - kfree(sitar); - return 0; -} -static struct snd_soc_codec_driver soc_codec_dev_sitar = { - .probe = sitar_codec_probe, - .remove = sitar_codec_remove, - .read = sitar_read, - .write = sitar_write, - - .readable_register = sitar_readable, - .volatile_register = sitar_volatile, - - .reg_cache_size = SITAR_CACHE_SIZE, - .reg_cache_default = sitar_reg_defaults, - .reg_word_size = 1, -}; - -#ifdef CONFIG_DEBUG_FS -static struct dentry *debugfs_poke; - -static int codec_debug_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static ssize_t codec_debug_write(struct file *filp, - const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char lbuf[32]; - char *buf; - int rc; - - if (cnt > sizeof(lbuf) - 1) - return -EINVAL; - - rc = copy_from_user(lbuf, ubuf, cnt); - if (rc) - return -EFAULT; - - lbuf[cnt] = '\0'; - buf = (char *)lbuf; - debug_sitar_priv->no_mic_headset_override = (*strsep(&buf, " ") == '0') - ? false : true; - - return rc; -} - -static const struct file_operations codec_debug_ops = { - .open = codec_debug_open, - .write = codec_debug_write, -}; -#endif - -#ifdef CONFIG_PM -static int sitar_suspend(struct device *dev) -{ - dev_dbg(dev, "%s: system suspend\n", __func__); - return 0; -} - -static int sitar_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct sitar_priv *sitar = platform_get_drvdata(pdev); - dev_dbg(dev, "%s: system resume\n", __func__); - sitar->mbhc_last_resume = jiffies; - return 0; -} - -static const struct dev_pm_ops sitar_pm_ops = { - .suspend = sitar_suspend, - .resume = sitar_resume, -}; -#endif - -static int sitar_probe(struct platform_device *pdev) -{ - int ret = 0; - pr_err("%s\n", __func__); -#ifdef CONFIG_DEBUG_FS - debugfs_poke = debugfs_create_file("TRRS", - S_IFREG | S_IRUGO, NULL, (void *) "TRRS", &codec_debug_ops); - -#endif - if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS) - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_sitar, - sitar_dai, ARRAY_SIZE(sitar_dai)); - else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_sitar, - sitar_i2s_dai, ARRAY_SIZE(sitar_i2s_dai)); - return ret; -} -static int sitar_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - -#ifdef CONFIG_DEBUG_FS - debugfs_remove(debugfs_poke); -#endif - return 0; -} -static struct platform_driver sitar_codec_driver = { - .probe = sitar_probe, - .remove = sitar_remove, - .driver = { - .name = "sitar_codec", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &sitar_pm_ops, -#endif - }, -}; - -static int __init sitar_codec_init(void) -{ - return platform_driver_register(&sitar_codec_driver); -} - -static void __exit sitar_codec_exit(void) -{ - platform_driver_unregister(&sitar_codec_driver); -} - -module_init(sitar_codec_init); -module_exit(sitar_codec_exit); - -MODULE_DESCRIPTION("Sitar codec driver"); -MODULE_VERSION("1.0"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/wcd9304.h b/sound/soc/codecs/wcd9304.h deleted file mode 100644 index 4c92fb8399b408577669195b8252feb7d5b28db7..0000000000000000000000000000000000000000 --- a/sound/soc/codecs/wcd9304.h +++ /dev/null @@ -1,271 +0,0 @@ -/* Copyright (c) 2012, 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 -#include - -#define SITAR_NUM_REGISTERS 0x400 -#define SITAR_MAX_REGISTER (SITAR_NUM_REGISTERS-1) -#define SITAR_CACHE_SIZE SITAR_NUM_REGISTERS -#define SITAR_1_X_ONLY_REGISTERS 3 -#define SITAR_2_HIGHER_ONLY_REGISTERS 3 - -#define SITAR_REG_VAL(reg, val) {reg, 0, val} - -#define DEFAULT_DCE_STA_WAIT 55 -#define DEFAULT_DCE_WAIT 60000 -#define DEFAULT_STA_WAIT 5000 - -#define STA 0 -#define DCE 1 - -#define SITAR_JACK_BUTTON_MASK (SND_JACK_BTN_0 | SND_JACK_BTN_1 | \ - SND_JACK_BTN_2 | SND_JACK_BTN_3 | \ - SND_JACK_BTN_4 | SND_JACK_BTN_5 | \ - SND_JACK_BTN_6 | SND_JACK_BTN_7) - -extern const u8 sitar_reg_readable[SITAR_CACHE_SIZE]; -extern const u32 sitar_1_reg_readable[SITAR_1_X_ONLY_REGISTERS]; -extern const u32 sitar_2_reg_readable[SITAR_2_HIGHER_ONLY_REGISTERS]; -extern const u8 sitar_reg_defaults[SITAR_CACHE_SIZE]; - -enum sitar_micbias_num { - SITAR_MICBIAS1, - SITAR_MICBIAS2, - SITAR_MICBIAS3, - SITAR_MICBIAS4, -}; - -enum sitar_pid_current { - SITAR_PID_MIC_2P5_UA, - SITAR_PID_MIC_5_UA, - SITAR_PID_MIC_10_UA, - SITAR_PID_MIC_20_UA, -}; - -struct sitar_reg_mask_val { - u16 reg; - u8 mask; - u8 val; -}; - -enum sitar_mbhc_clk_freq { - SITAR_MCLK_12P2MHZ = 0, - SITAR_MCLK_9P6MHZ, - SITAR_NUM_CLK_FREQS, -}; - -enum sitar_mbhc_analog_pwr_cfg { - SITAR_ANALOG_PWR_COLLAPSED = 0, - SITAR_ANALOG_PWR_ON, - SITAR_NUM_ANALOG_PWR_CONFIGS, -}; - -enum sitar_mbhc_btn_det_mem { - SITAR_BTN_DET_V_BTN_LOW, - SITAR_BTN_DET_V_BTN_HIGH, - SITAR_BTN_DET_N_READY, - SITAR_BTN_DET_N_CIC, - SITAR_BTN_DET_GAIN -}; - -struct sitar_mbhc_general_cfg { - u8 t_ldoh; - u8 t_bg_fast_settle; - u8 t_shutdown_plug_rem; - u8 mbhc_nsa; - u8 mbhc_navg; - u8 v_micbias_l; - u8 v_micbias; - u8 mbhc_reserved; - u16 settle_wait; - u16 t_micbias_rampup; - u16 t_micbias_rampdown; - u16 t_supply_bringup; -} __packed; - -struct sitar_mbhc_plug_detect_cfg { - u32 mic_current; - u32 hph_current; - u16 t_mic_pid; - u16 t_ins_complete; - u16 t_ins_retry; - u16 v_removal_delta; - u8 micbias_slow_ramp; - u8 reserved0; - u8 reserved1; - u8 reserved2; -} __packed; - -struct sitar_mbhc_plug_type_cfg { - u8 av_detect; - u8 mono_detect; - u8 num_ins_tries; - u8 reserved0; - s16 v_no_mic; - s16 v_av_min; - s16 v_av_max; - s16 v_hs_min; - s16 v_hs_max; - u16 reserved1; -} __packed; - - -struct sitar_mbhc_btn_detect_cfg { - s8 c[8]; - u8 nc; - u8 n_meas; - u8 mbhc_nsc; - u8 n_btn_meas; - u8 n_btn_con; - u8 num_btn; - u8 reserved0; - u8 reserved1; - u16 t_poll; - u16 t_bounce_wait; - u16 t_rel_timeout; - s16 v_btn_press_delta_sta; - s16 v_btn_press_delta_cic; - u16 t_btn0_timeout; - s16 _v_btn_low[0]; /* v_btn_low[num_btn] */ - s16 _v_btn_high[0]; /* v_btn_high[num_btn] */ - u8 _n_ready[SITAR_NUM_CLK_FREQS]; - u8 _n_cic[SITAR_NUM_CLK_FREQS]; - u8 _gain[SITAR_NUM_CLK_FREQS]; -} __packed; - -struct sitar_mbhc_imped_detect_cfg { - u8 _hs_imped_detect; - u8 _n_rload; - u8 _hph_keep_on; - u8 _repeat_rload_calc; - u16 _t_dac_ramp_time; - u16 _rhph_high; - u16 _rhph_low; - u16 _rload[0]; /* rload[n_rload] */ - u16 _alpha[0]; /* alpha[n_rload] */ - u16 _beta[3]; -} __packed; - -struct sitar_mbhc_config { - struct snd_soc_jack *headset_jack; - struct snd_soc_jack *button_jack; - bool read_fw_bin; - /* void* calibration contains: - * struct tabla_mbhc_general_cfg generic; - * struct tabla_mbhc_plug_detect_cfg plug_det; - * struct tabla_mbhc_plug_type_cfg plug_type; - * struct tabla_mbhc_btn_detect_cfg btn_det; - * struct tabla_mbhc_imped_detect_cfg imped_det; - * Note: various size depends on btn_det->num_btn - */ - void *calibration; - enum sitar_micbias_num micbias; - int (*mclk_cb_fn) (struct snd_soc_codec*, int, bool); - unsigned int mclk_rate; - unsigned int gpio; - unsigned int gpio_irq; - int gpio_level_insert; -}; - -extern int sitar_hs_detect(struct snd_soc_codec *codec, - const struct sitar_mbhc_config *cfg); - -#ifndef anc_header_dec -struct anc_header { - u32 reserved[3]; - u32 num_anc_slots; -}; -#define anc_header_dec -#endif - -extern int sitar_mclk_enable(struct snd_soc_codec *codec, int mclk_enable, - bool dapm); - -/* Number of input and output Slimbus ports - */ -enum { - SITAR_RX1 = 0, - SITAR_RX2, - SITAR_RX3, - SITAR_RX4, - SITAR_RX5, - SITAR_RX_MAX, -}; - -enum { - SITAR_TX1 = 0, - SITAR_TX2, - SITAR_TX3, - SITAR_TX4, - SITAR_TX5, - SITAR_TX_MAX, -}; - -extern void *sitar_mbhc_cal_btn_det_mp(const struct sitar_mbhc_btn_detect_cfg - *btn_det, - const enum sitar_mbhc_btn_det_mem mem); - -#define SITAR_MBHC_CAL_SIZE(buttons, rload) ( \ - sizeof(enum sitar_micbias_num) + \ - sizeof(struct sitar_mbhc_general_cfg) + \ - sizeof(struct sitar_mbhc_plug_detect_cfg) + \ - ((sizeof(s16) + sizeof(s16)) * buttons) + \ - sizeof(struct sitar_mbhc_plug_type_cfg) + \ - sizeof(struct sitar_mbhc_btn_detect_cfg) + \ - sizeof(struct sitar_mbhc_imped_detect_cfg) + \ - ((sizeof(u16) + sizeof(u16)) * rload) \ - ) - -#define SITAR_MBHC_CAL_GENERAL_PTR(cali) ( \ - (struct sitar_mbhc_general_cfg *) cali) -#define SITAR_MBHC_CAL_PLUG_DET_PTR(cali) ( \ - (struct sitar_mbhc_plug_detect_cfg *) \ - &(SITAR_MBHC_CAL_GENERAL_PTR(cali)[1])) -#define SITAR_MBHC_CAL_PLUG_TYPE_PTR(cali) ( \ - (struct sitar_mbhc_plug_type_cfg *) \ - &(SITAR_MBHC_CAL_PLUG_DET_PTR(cali)[1])) -#define SITAR_MBHC_CAL_BTN_DET_PTR(cali) ( \ - (struct sitar_mbhc_btn_detect_cfg *) \ - &(SITAR_MBHC_CAL_PLUG_TYPE_PTR(cali)[1])) -#define SITAR_MBHC_CAL_IMPED_DET_PTR(cali) ( \ - (struct sitar_mbhc_imped_detect_cfg *) \ - (((void *)&SITAR_MBHC_CAL_BTN_DET_PTR(cali)[1]) + \ - (SITAR_MBHC_CAL_BTN_DET_PTR(cali)->num_btn * \ - (sizeof(SITAR_MBHC_CAL_BTN_DET_PTR(cali)->_v_btn_low[0]) + \ - sizeof(SITAR_MBHC_CAL_BTN_DET_PTR(cali)->_v_btn_high[0])))) \ - ) - -/* minimum size of calibration data assuming there is only one button and - * one rload. - */ -#define SITAR_MBHC_CAL_MIN_SIZE ( \ - sizeof(struct sitar_mbhc_general_cfg) + \ - sizeof(struct sitar_mbhc_plug_detect_cfg) + \ - sizeof(struct sitar_mbhc_plug_type_cfg) + \ - sizeof(struct sitar_mbhc_btn_detect_cfg) + \ - sizeof(struct sitar_mbhc_imped_detect_cfg) + \ - (sizeof(u16) * 2)) - -#define SITAR_MBHC_CAL_BTN_SZ(cfg_ptr) ( \ - sizeof(struct sitar_mbhc_btn_detect_cfg) + \ - (cfg_ptr->num_btn * (sizeof(cfg_ptr->_v_btn_low[0]) + \ - sizeof(cfg_ptr->_v_btn_high[0])))) - -#define SITAR_MBHC_CAL_IMPED_MIN_SZ ( \ - sizeof(struct sitar_mbhc_imped_detect_cfg) + \ - sizeof(u16) * 2) - -#define SITAR_MBHC_CAL_IMPED_SZ(cfg_ptr) ( \ - sizeof(struct sitar_mbhc_imped_detect_cfg) + \ - (cfg_ptr->_n_rload * (sizeof(cfg_ptr->_rload[0]) + \ - sizeof(cfg_ptr->_alpha[0])))) diff --git a/sound/soc/msm/Kconfig b/sound/soc/msm/Kconfig index 4e51e352bec78bc7b96cbf89a81954de36983e33..9f8ec867e78208ab0faac6d720f741e71edea853 100644 --- a/sound/soc/msm/Kconfig +++ b/sound/soc/msm/Kconfig @@ -1,25 +1,16 @@ menu "MSM SoC Audio support" -#7201 7625 variants -config SND_MSM_DAI_SOC - tristate - config SND_MSM_SOC_MSM7K tristate config SND_MSM_SOC tristate "SoC Audio for the MSM series chips" depends on ARCH_MSM7X27 - select SND_MSM_DAI_SOC select SND_MSM_SOC_MSM7K default n help To add support for ALSA PCM driver for MSM board. -#7630 Variants -config SND_MSM7KV2_DAI_SOC - tristate - config SND_MSM_SOC_MSM7KV2 tristate @@ -27,7 +18,6 @@ config SND_MSM7KV2_SOC tristate "SoC Audio for the MSM7KV2 chip" depends on ARCH_MSM7X30 && SND_SOC && MSM7KV2_AUDIO select SND_MSM_SOC_MSM7KV2 - select SND_MSM7KV2_DAI_SOC default n help To add support for ALSA PCM driver for QSD8k board. @@ -35,63 +25,15 @@ config SND_MSM7KV2_SOC config SND_MSM_MVS7x30_SOC tristate -config SND_MSM_MVS_DAI_SOC - tristate - -config SND_MVS_SOC - tristate "SoC Mvs support for MSM7X30" - depends on SND_MSM7KV2_SOC - select SND_MSM_MVS7x30_SOC - select SND_MSM_MVS_DAI_SOC - default n - help - To support Mvs packet capture/playback - -#8660 Variants -config SND_SOC_MSM8X60_PCM - tristate - -config SND_SOC_MSM8X60_DAI - tristate - -config SND_SOC_MSM8X60 - tristate "SoC Audio over DSP support for MSM8660" - depends on ARCH_MSM8X60 && SND_SOC && MSM8X60_AUDIO - select SND_SOC_MSM8X60_PCM - select SND_SOC_MSM8X60_DAI - select SND_SOC_MSM_QDSP6_INTF - default y - help - To add support for SoC audio on MSM8X60. This driver - Adds support for audio over DSP. The driver adds Kcontrols - to do device switch/routing and volume control support for all - audio sessions. The kcontols also does sesion management for - voice calls - config SND_SOC_MSM_HOSTLESS_PCM tristate -config SND_SOC_LPASS_PCM - tristate - config SND_SOC_MSM8660_LPAIF tristate -config SND_VOIP_PCM - tristate - -config SND_SOC_MSM_QDSP6_HDMI_AUDIO - tristate "Soc QDSP6 HDMI Audio DAI driver" - depends on FB_MSM_HDMI_MSM_PANEL - default n - help - To support HDMI Audio on MSM8960 over QDSP6. - config MSM_8x60_VOIP tristate "SoC Machine driver for voip" depends on SND_SOC_MSM8X60 - select SND_MSM_MVS_DAI_SOC - select SND_VOIP_PCM default n help To support ALSA VOIP driver for MSM8x60 target. @@ -115,13 +57,6 @@ config SND_SOC_MSM_QDSP6V2_INTF adm and afe interfaces on the DSP. -config SND_SOC_VOICE - bool "SoC Q6 voice driver for MSM8960" - depends on SND_SOC_MSM_QDSP6_INTF - default n - help - To add support for SoC voice on MSM8960. - config SND_SOC_QDSP6 tristate "SoC ALSA audio driver for QDSP6" select SND_SOC_MSM_QDSP6_INTF @@ -138,21 +73,6 @@ config SND_SOC_QDSP6V2 audio drivers. This includes q6asm, q6adm, q6afe interfaces to DSP using apr. -config SND_SOC_MSM8960 - tristate "SoC Machine driver for MSM8960 and APQ8064 boards" - depends on ARCH_MSM8960 || ARCH_APQ8064 - select SND_SOC_VOICE - select SND_SOC_QDSP6 - select SND_SOC_MSM_STUB - select SND_SOC_WCD9310 - select SND_SOC_WCD9304 - select SND_SOC_MSM_HOSTLESS_PCM - select SND_SOC_MSM_QDSP6_HDMI_AUDIO - select SND_SOC_CS8427 - default n - help - To add support for SoC audio on MSM8960 and APQ8064 boards - config AUDIO_OCMEM bool "Enable OCMEM for audio/voice usecase" depends on MSM_OCMEM @@ -223,18 +143,6 @@ config SND_SOC_MSM8226 the machine drivers and the corresponding DAI-links. -config SND_SOC_MDM9615 - tristate "SoC Machine driver for MDM9615 boards" - depends on ARCH_MSM9615 - select SND_SOC_VOICE - select SND_SOC_QDSP6 - select SND_SOC_MSM_STUB - select SND_SOC_WCD9310 - select SND_SOC_MSM_HOSTLESS_PCM - select SND_DYNAMIC_MINORS - help - To add support for SoC audio on MDM9615 boards - config SND_SOC_MSM8X10 tristate "SoC Machine driver for MSM8X10 boards" depends on ARCH_MSM8610 @@ -260,17 +168,6 @@ config SND_SOC_MSM8660_APQ help To add support for SoC audio on APQ8060 board -config SND_SOC_MDM9625 - tristate "SoC Machine driver for MDM9625 boards" - depends on ARCH_MSM9625 - select SND_SOC_QDSP6V2 - select SND_SOC_MSM_STUB - select SND_SOC_WCD9320 - select SND_SOC_MSM_HOSTLESS_PCM - select SND_DYNAMIC_MINORS - help - To add support for SoC audio on MDM9625 boards. - config SND_SOC_APQ8084 tristate "SoC Machine driver for APQ8084 boards" depends on ARCH_APQ8084 diff --git a/sound/soc/msm/Makefile b/sound/soc/msm/Makefile index e9432aef03834fdf878745e195ed66d29f3ad168..45d62d7fe38873e5dd9a0ba45ef24114171129f1 100644 --- a/sound/soc/msm/Makefile +++ b/sound/soc/msm/Makefile @@ -1,80 +1,46 @@ # MSM CPU/CODEC DAI Support -snd-soc-msm-dai-objs := msm-dai.o -obj-$(CONFIG_SND_MSM_DAI_SOC) += snd-soc-msm-dai.o -snd-soc-msm7kv2-dai-objs := msm7kv2-dai.o -obj-$(CONFIG_SND_MSM7KV2_DAI_SOC) += snd-soc-msm7kv2-dai.o # MSM Platform Support -snd-soc-msm-objs := msm-pcm.o msm7k-pcm.o obj-$(CONFIG_SND_MSM_SOC) += snd-soc-msm.o -snd-soc-msmv2-objs := msm7kv2-dsp.o msm7kv2-pcm.o obj-$(CONFIG_SND_MSM7KV2_SOC) += snd-soc-msmv2.o # MSM Machine Support -snd-soc-msm7k-objs := msm7201.o obj-$(CONFIG_SND_MSM_SOC_MSM7K) += snd-soc-msm7k.o -snd-soc-msm7kv2-objs := msm7x30.o obj-$(CONFIG_SND_MSM_SOC_MSM7KV2) += snd-soc-msm7kv2.o # 8660 ALSA Support -snd-soc-msm8x60-dai-objs := msm8x60-dai.o -obj-$(CONFIG_SND_SOC_MSM8X60_DAI) += snd-soc-msm8x60-dai.o -snd-soc-msm8x60-pcm-objs := msm8x60-pcm.o -obj-$(CONFIG_SND_SOC_MSM8X60_PCM) += snd-soc-msm8x60-pcm.o -snd-soc-msm8x60-objs := msm8x60.o -obj-$(CONFIG_SND_SOC_MSM8X60) += snd-soc-msm8x60.o #MVS Support -snd-soc-msm-mvs-dai-objs := mvs-dai.o -obj-$(CONFIG_SND_MSM_MVS_DAI_SOC) += snd-soc-msm-mvs-dai.o -snd-soc-msm-mvs-objs := msm-mvs.o -obj-$(CONFIG_SND_MVS_SOC) += snd-soc-msm-mvs.o # 8660 ALSA Support -snd-soc-lpass-objs := lpass-i2s.o lpass-dma.o obj-$(CONFIG_SND_SOC_MSM8660_LPAIF) += snd-soc-lpass.o -snd-soc-lpass-pcm-objs := lpass-pcm.o -obj-$(CONFIG_SND_SOC_LPASS_PCM) += snd-soc-lpass-pcm.o #8660 VOIP Driver Support -snd-soc-msm-voip-objs := msm-voip.o -obj-$(CONFIG_SND_VOIP_PCM) += snd-soc-msm-voip.o -snd-soc-lpass-dma-objs := lpass-dma.o -obj-$(CONFIG_SND_SOC_MSM8X60) += snd-soc-lpass-dma.o # for MSM 8960 sound card driver -obj-$(CONFIG_SND_SOC_MSM_QDSP6_INTF) += qdsp6/ -snd-soc-qdsp6-objs := msm-dai-q6.o msm-pcm-q6.o msm-multi-ch-pcm-q6.o msm-lowlatency-pcm-q6.o msm-pcm-loopback.o msm-pcm-routing.o msm-dai-fe.o msm-compr-q6.o msm-dai-stub.o -obj-$(CONFIG_SND_SOC_MSM_QDSP6_HDMI_AUDIO) += msm-dai-q6-hdmi.o -obj-$(CONFIG_SND_SOC_VOICE) += msm-pcm-voice.o msm-pcm-voip.o msm-pcm-dtmf.o msm-pcm-host-voice.o -snd-soc-qdsp6-objs += msm-pcm-lpa.o msm-pcm-afe.o +snd-soc-qdsp6-objs := msm-dai-fe.o obj-$(CONFIG_SND_SOC_QDSP6) += snd-soc-qdsp6.o snd-soc-hostless-pcm-objs := msm-pcm-hostless.o obj-$(CONFIG_SND_SOC_MSM_HOSTLESS_PCM) += snd-soc-hostless-pcm.o -snd-soc-msm8960-objs := msm8960.o apq8064.o msm8930.o mpq8064.o apq8064-i2s.o -obj-$(CONFIG_SND_SOC_MSM8960) += snd-soc-msm8960.o # Generic MSM drivers -snd-soc-msm8660-apq-objs := msm8660-apq-wm8903.o obj-$(CONFIG_SND_SOC_MSM8660_APQ) += snd-soc-msm8660-apq.o # for MDM 9615 sound card driver -snd-soc-mdm9615-objs := mdm9615.o -obj-$(CONFIG_SND_SOC_MDM9615) += snd-soc-mdm9615.o # for MSM 8974 sound card driver obj-$(CONFIG_SND_SOC_MSM_QDSP6V2_INTF) += qdsp6v2/ @@ -89,8 +55,6 @@ snd-soc-apq8074-objs := apq8074.o obj-$(CONFIG_SND_SOC_APQ8074) += snd-soc-apq8074.o #for MDM9625 sound card driver -snd-soc-mdm9625-objs := mdm9625.o -obj-$(CONFIG_SND_SOC_MDM9625) += snd-soc-mdm9625.o #for MSM 8226 sound card driver snd-soc-msm8226-objs := msm8226.o diff --git a/sound/soc/msm/apq8064-i2s.c b/sound/soc/msm/apq8064-i2s.c deleted file mode 100644 index df1f1aeac58b11ebb79a8412da2cac42a0cf0db7..0000000000000000000000000000000000000000 --- a/sound/soc/msm/apq8064-i2s.c +++ /dev/null @@ -1,2705 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "../codecs/wcd9310.h" - -/* 8064 machine driver */ - -#define PM8921_GPIO_BASE NR_GPIO_IRQS -#define PM8921_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio - 1 + PM8921_GPIO_BASE) - -#define MSM8064_SPK_ON 1 -#define MSM8064_SPK_OFF 0 - -#define MSM_SLIM_0_RX_MAX_CHANNELS 2 -#define MSM_SLIM_0_TX_MAX_CHANNELS 4 - -#define BTSCO_RATE_8KHZ 8000 -#define BTSCO_RATE_16KHZ 16000 - -#define BOTTOM_SPK_AMP_POS 0x1 -#define BOTTOM_SPK_AMP_NEG 0x2 -#define TOP_SPK_AMP_POS 0x4 -#define TOP_SPK_AMP_NEG 0x8 -#define TOP_SPK_AMP 0x10 - - -#define GPIO_AUX_PCM_DOUT 43 -#define GPIO_AUX_PCM_DIN 44 -#define GPIO_AUX_PCM_SYNC 45 -#define GPIO_AUX_PCM_CLK 46 - -#define TABLA_EXT_CLK_RATE 12288000 - -#define TABLA_MBHC_DEF_BUTTONS 8 -#define TABLA_MBHC_DEF_RLOADS 5 - -#define JACK_DETECT_GPIO 38 - -/* MCLK selection GPIOs from PMIC */ -#define PM_GPIO_MCLK_MDM 27 -#define PM_GPIO_MCLK_APQ 41 - -/* SPKR I2S Configuration */ -#define GPIO_SPKR_I2S_MCLK 39 -#define GPIO_SPKR_I2S_SCK 40 -#define GPIO_SPKR_I2S_DOUT 41 -#define GPIO_SPKR_I2S_WS 42 - -/* MIC I2S Configuration */ -#define GPIO_MIC_I2S_MCLK 34 -#define GPIO_MIC_I2S_SCK 35 -#define GPIO_MIC_I2S_WS 36 -#define GPIO_MIC_I2S_DIN0 37 -#define GPIO_MIC_I2S_DIN1 38 - -/* MI2S Configuration */ -#define GPIO_MI2S_WS 27 -#define GPIO_MI2S_SCK 28 -#define GPIO_MI2S_SD3 29 -#define GPIO_MI2S_SD2 30 -#define GPIO_MI2S_SD1 31 -#define GPIO_MI2S_SD0 32 -#define GPIO_MI2S_MCLK 33 - -struct request_gpio { - unsigned gpio_no; - char *gpio_name; -}; -/* SD0 as RX and SD3 as TX. SD1 and SD2 are unused */ -static struct request_gpio mi2s_gpio[] = { - { - .gpio_no = GPIO_MI2S_WS, - .gpio_name = "MI2S_WS", - }, - { - .gpio_no = GPIO_MI2S_SCK, - .gpio_name = "MI2S_SCK", - }, - { - .gpio_no = GPIO_MI2S_SD3, - .gpio_name = "MI2S_SD3", - }, - { - .gpio_no = GPIO_MI2S_SD0, - .gpio_name = "MI2S_SD0", - }, - { - .gpio_no = GPIO_MI2S_MCLK, - .gpio_name = "MI2S_MCLK", - }, -}; - -/* I2S RX is slave so MCLK is not needed */ -static struct request_gpio spkr_i2s_gpio[] = { - { - .gpio_no = GPIO_SPKR_I2S_WS, - .gpio_name = "SPKR_I2S_WS", - }, - { - .gpio_no = GPIO_SPKR_I2S_SCK, - .gpio_name = "SPKR_I2S_SCK", - }, - { - .gpio_no = GPIO_SPKR_I2S_DOUT, - .gpio_name = "SPKR_I2S_DOUT", - }, -}; - - -/* I2S TX is slave so MCLK is not needed. DIN1 is not used */ -static struct request_gpio mic_i2s_gpio[] = { - { - .gpio_no = GPIO_MIC_I2S_WS, - .gpio_name = "MIC_I2S_WS", - }, - { - .gpio_no = GPIO_MIC_I2S_SCK, - .gpio_name = "MIC_I2S_SCK", - }, - { - .gpio_no = GPIO_MIC_I2S_DIN0, - .gpio_name = "MIC_I2S_DIN", - }, -}; - -/* Shared channel numbers for Slimbus ports that connect APQ to MDM. */ -enum { - SLIM_1_RX_1 = 145, /* BT-SCO and USB TX */ - SLIM_1_TX_1 = 146, /* BT-SCO and USB RX */ - SLIM_3_RX_1 = 151, /* External echo-cancellation ref */ - SLIM_3_RX_2 = 152, /* External echo-cancellation ref */ - SLIM_3_TX_1 = 153, /* HDMI RX */ - SLIM_3_TX_2 = 154, /* HDMI RX */ - SLIM_4_TX_1 = 148, /* In-call recording RX */ - SLIM_4_TX_2 = 149, /* In-call recording RX */ - SLIM_4_RX_1 = 150, /* In-call music delivery TX */ -}; - -enum { - INCALL_REC_MONO, - INCALL_REC_STEREO, -}; - - -static u32 mdm_mclk_gpio = PM8921_GPIO_PM_TO_SYS(PM_GPIO_MCLK_MDM); -static u32 apq_mclk_gpio = PM8921_GPIO_PM_TO_SYS(PM_GPIO_MCLK_APQ); -static u32 top_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(18); -static u32 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(19); -static int msm_spk_control; -static int msm_ext_bottom_spk_pamp; -static int msm_ext_top_spk_pamp; -static int msm_slim_0_rx_ch = 1; -static int msm_slim_0_tx_ch = 1; -static int msm_slim_3_rx_ch = 1; - -static struct clk *i2s_rx_bit_clk; -static struct clk *i2s_tx_bit_clk; - -static struct clk *mi2s_bit_clk; - -static int msm_i2s_rx_ch = 1; -static int msm_i2s_tx_ch = 1; -static int msm_mi2s_rx_ch = 1; -static int msm_mi2s_tx_ch = 1; -/* MI2S TX and RX share the same control block*/ -static atomic_t mi2s_rsc_ref; - -static int msm_btsco_rate = BTSCO_RATE_8KHZ; -static int msm_btsco_ch = 1; - -static int rec_mode = INCALL_REC_MONO; - -static struct clk *codec_clk; -static int clk_users; - -static struct snd_soc_jack hs_jack; -static struct snd_soc_jack button_jack; -static atomic_t auxpcm_rsc_ref; - -static int apq8064_i2s_hs_detect_use_gpio = -1; -module_param(apq8064_i2s_hs_detect_use_gpio, int, 0444); -MODULE_PARM_DESC(apq8064_i2s_hs_detect_use_gpio, "Use GPIO for headset detection"); - -static bool apq8064_i2s_hs_detect_use_firmware; -module_param(apq8064_i2s_hs_detect_use_firmware, bool, 0444); -MODULE_PARM_DESC(apq8064_i2s_hs_detect_use_firmware, - "Use firmware for headset detection"); - -static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm); - -static struct tabla_mbhc_config mbhc_cfg = { - .headset_jack = &hs_jack, - .button_jack = &button_jack, - .read_fw_bin = false, - .calibration = NULL, - .micbias = TABLA_MICBIAS2, - .mclk_cb_fn = msm_enable_codec_ext_clk, - .mclk_rate = TABLA_EXT_CLK_RATE, - .gpio = 0, - .gpio_irq = 0, - .gpio_level_insert = 1, -}; - -static struct mutex cdc_mclk_mutex; - -static void msm_enable_ext_spk_amp_gpio(u32 spk_amp_gpio) -{ - int ret = 0; - - struct pm_gpio param = { - .direction = PM_GPIO_DIR_OUT, - .output_buffer = PM_GPIO_OUT_BUF_CMOS, - .output_value = 1, - .pull = PM_GPIO_PULL_NO, - .vin_sel = PM_GPIO_VIN_S4, - .out_strength = PM_GPIO_STRENGTH_MED, - . - function = PM_GPIO_FUNC_NORMAL, - }; - - if (spk_amp_gpio == bottom_spk_pamp_gpio) { - - ret = gpio_request(bottom_spk_pamp_gpio, "BOTTOM_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting BOTTOM SPK AMP GPIO %u\n", - __func__, bottom_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(bottom_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Bottom Spk Ampl gpio %u\n", - __func__, bottom_spk_pamp_gpio); - else { - pr_debug("%s: enable Bottom spkr amp gpio\n", __func__); - gpio_direction_output(bottom_spk_pamp_gpio, 1); - } - - } else if (spk_amp_gpio == top_spk_pamp_gpio) { - - ret = gpio_request(top_spk_pamp_gpio, "TOP_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting GPIO %d\n", __func__, - top_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(top_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Top Spk Ampl gpio %u\n", - __func__, top_spk_pamp_gpio); - else { - pr_debug("%s: enable Top spkr amp gpio\n", __func__); - gpio_direction_output(top_spk_pamp_gpio, 1); - } - } else { - pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO gpio = %u\n", - __func__, spk_amp_gpio); - return; - } -} - -static void msm_ext_spk_power_amp_on(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - pr_debug("%s() External Bottom Speaker Ampl already turned on\n" - "spk = 0x%08x\n", __func__, spk); - return; - } - - msm_ext_bottom_spk_pamp |= spk; - - if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - msm_enable_ext_spk_amp_gpio(bottom_spk_pamp_gpio); - pr_debug("%s: slepping 4 ms after turning on external\n" - "Bottom Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { - - pr_debug("%s():top_spk_amp_state = 0x%x spk_event = 0x%x\n", - __func__, msm_ext_top_spk_pamp, spk); - - if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || - (msm_ext_top_spk_pamp & TOP_SPK_AMP)) { - - pr_debug("%s() External Top Speaker Ampl already turned on\n" - "spk = 0x%08x\n", __func__, spk); - return; - } - - msm_ext_top_spk_pamp |= spk; - - if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || - (msm_ext_top_spk_pamp & TOP_SPK_AMP)) { - - msm_enable_ext_spk_amp_gpio(top_spk_pamp_gpio); - pr_debug("%s: sleeping 4 ms after turning on\n" - "external Top Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - } else { - - pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm_ext_spk_power_amp_off(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if (!msm_ext_bottom_spk_pamp) - return; - - gpio_direction_output(bottom_spk_pamp_gpio, 0); - gpio_free(bottom_spk_pamp_gpio); - msm_ext_bottom_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after turning off external Bottom\n" - "Speaker Ampl\n", __func__); - - usleep_range(4000, 4000); - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { - - pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n", - __func__, msm_ext_top_spk_pamp, spk); - - if (!msm_ext_top_spk_pamp) - return; - - if ((spk & TOP_SPK_AMP_POS) || (spk & TOP_SPK_AMP_NEG)) { - - msm_ext_top_spk_pamp &= (~(TOP_SPK_AMP_POS | - TOP_SPK_AMP_NEG)); - } else if (spk & TOP_SPK_AMP) { - msm_ext_top_spk_pamp &= ~TOP_SPK_AMP; - } - - if (msm_ext_top_spk_pamp) - return; - - gpio_direction_output(top_spk_pamp_gpio, 0); - gpio_free(top_spk_pamp_gpio); - msm_ext_top_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after ext Top Spek Ampl is off\n", - __func__); - - usleep_range(4000, 4000); - } else { - - pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm_ext_control(struct snd_soc_codec *codec) -{ - struct snd_soc_dapm_context *dapm = &codec->dapm; - - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - if (msm_spk_control == MSM8064_SPK_ON) { - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - } else { - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg"); - } - - snd_soc_dapm_sync(dapm); -} - -static int msm_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - ucontrol->value.integer.value[0] = msm_spk_control; - return 0; -} -static int msm_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm_spk_control == ucontrol->value.integer.value[0]) - return 0; - - msm_spk_control = ucontrol->value.integer.value[0]; - msm_ext_control(codec); - return 1; -} -static int msm_spkramp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event)); - - if (SND_SOC_DAPM_EVENT_ON(event)) { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top", 12)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - - } else { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top", 12)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - } - return 0; -} - -static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm) -{ - int r = 0; - pr_debug("%s: enable = %d\n", __func__, enable); - - mutex_lock(&cdc_mclk_mutex); - if (enable) { - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 1) { - if (codec_clk) { - /* - * For MBHC calc, the MCLK is from APQ side - * so APQ has control of the MCLK at this point - */ - clk_set_rate(codec_clk, TABLA_EXT_CLK_RATE); - clk_prepare_enable(codec_clk); - tabla_mclk_enable(codec, 1, dapm); - } else { - pr_err("%s: Error setting Tabla MCLK\n", - __func__); - clk_users--; - r = -EINVAL; - } - } - } else { - if (clk_users > 0) { - clk_users--; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 0) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - tabla_mclk_enable(codec, 0, dapm); - /* - * For MBHC calc, the MCLK is from APQ side - * so APQ has control of the MCLK at this point - */ - clk_disable_unprepare(codec_clk); - } - } else { - pr_err("%s: Error releasing Tabla MCLK\n", __func__); - r = -EINVAL; - } - } - mutex_unlock(&cdc_mclk_mutex); - return r; -} - -static int msm_mclk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - pr_debug("%s: event = %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - - if (clk_users != 1) - return 0; - - if (codec_clk) { - /* - * Since the MCLK is from MDM side so APQ side - * has no control of the MCLK at this point - */ - /*clk_set_rate(codec_clk, TABLA_EXT_CLK_RATE); - clk_prepare_enable(codec_clk); */ - tabla_mclk_enable(w->codec, 1, true); - - } else { - pr_err("%s: Error setting Tabla MCLK\n", __func__); - clk_users--; - return -EINVAL; - } - break; - case SND_SOC_DAPM_POST_PMD: - - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - - if (clk_users == 0) - return 0; - - clk_users--; - - if (!clk_users) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - - tabla_mclk_enable(w->codec, 0, true); - /* - * Since the MCLK is from MDM side so APQ side - * has no control of the MCLK at this point - */ - /* clk_disable_unprepare(codec_clk); */ - } - break; - } - return 0; -} - -static const struct snd_soc_dapm_widget apq8064_dapm_widgets[] = { - - SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, - msm_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SPK("Ext Spk Bottom Pos", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Bottom Neg", msm_spkramp_event), - - SND_SOC_DAPM_SPK("Ext Spk Top Pos", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Top Neg", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Top", msm_spkramp_event), - - /************ Analog MICs ************/ - /** - * Analog mic7 (Front Top) on Liquid. - * Used as Handset mic on CDP. - */ - SND_SOC_DAPM_MIC("Analog mic7", NULL), - - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), - - /*********** Digital Mics ***************/ - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("Digital Mic2", NULL), - SND_SOC_DAPM_MIC("Digital Mic3", NULL), - SND_SOC_DAPM_MIC("Digital Mic4", NULL), - SND_SOC_DAPM_MIC("Digital Mic5", NULL), - SND_SOC_DAPM_MIC("Digital Mic6", NULL), -}; - -static const struct snd_soc_dapm_route apq8064_common_audio_map[] = { - - {"RX_BIAS", NULL, "MCLK"}, - {"LDO_H", NULL, "MCLK"}, - - {"HEADPHONE", NULL, "LDO_H"}, - - /* Speaker path */ - {"Ext Spk Bottom Pos", NULL, "LINEOUT1"}, - {"Ext Spk Bottom Neg", NULL, "LINEOUT3"}, - - {"Ext Spk Top Pos", NULL, "LINEOUT2"}, - {"Ext Spk Top Neg", NULL, "LINEOUT4"}, - {"Ext Spk Top", NULL, "LINEOUT5"}, - - /************ Analog MIC Paths ************/ - - /* Headset Mic */ - {"AMIC2", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "Headset Mic"}, - - /* Headset ANC microphones */ - {"AMIC3", NULL, "MIC BIAS3 Internal1"}, - {"MIC BIAS3 Internal1", NULL, "ANCRight Headset Mic"}, - - {"AMIC4", NULL, "MIC BIAS1 Internal2"}, - {"MIC BIAS1 Internal2", NULL, "ANCLeft Headset Mic"}, -}; - -static const struct snd_soc_dapm_route apq8064_mtp_audio_map[] = { - - /************ Digital MIC Paths ************/ - - /* - * Digital Mic1 (Front bottom Left) on MTP. - * Conncted to DMIC1 Input on Tabla codec. - */ - {"DMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic1"}, - - /** - * Digital Mic2 (Front bottom right) on MTP. - * Conncted to DMIC2 Input on Tabla codec. - */ - {"DMIC2", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic2"}, - - /** - * Digital Mic3 (Back bottom) on MTP. - * Conncted to DMIC3 Input on Tabla codec. - */ - {"DMIC3", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic3"}, - - /** - * Digital Mic4 (Back top) on MTP. - * Conncted to DMIC4 Input on Tabla codec. - */ - {"DMIC4", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic4"}, - - /** - * Digital Mic5 (Top front Mic) on MTP. - * Conncted to DMIC6 Input on Tabla codec. - */ - {"DMIC6", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic5"}, - -}; - -static const struct snd_soc_dapm_route apq8064_liquid_cdp_audio_map[] = { - - /************ Analog MIC Paths ************/ - /** - * Analog mic7 (Front Top Mic) on Liquid. - * Used as Handset mic on CDP. - * Not there on MTP. - */ - {"AMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Analog mic7"}, - - - /************ Digital MIC Paths ************/ - /** - * The digital Mic routes are setup considering - * Liquid as default device. - */ - - /** - * Digital Mic1 (Front bottom left corner) on Liquid. - * Digital Mic2 (Front bottom right) on MTP. - * Digital Mic GM1 on CDP mainboard. - * Conncted to DMIC2 Input on Tabla codec. - */ - {"DMIC2", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic1"}, - - /** - * Digital Mic2 (Front left side) on Liquid. - * Digital Mic GM2 on CDP mainboard. - * Not there on MTP. - * Conncted to DMIC3 Input on Tabla codec. - */ - {"DMIC3", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic2"}, - - /** - * Digital Mic3. Front bottom left of middle on Liquid. - * Digital Mic5 (Top front Mic) on MTP. - * Digital Mic GM5 on CDP mainboard. - * Conncted to DMIC6 Input on Tabla codec. - */ - {"DMIC6", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic3"}, - - /** - * Digital Mic4. Back bottom on Liquid. - * Digital Mic GM3 on CDP mainboard. - * Top Front Mic on MTP. - * Conncted to DMIC5 Input on Tabla codec. - */ - {"DMIC5", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic4"}, - - /** - * Digital Mic5. Front bottom right of middle on Liquid. - * Digital Mic GM6 on CDP mainboard. - * Not there on MTP. - * Conncted to DMIC4 Input on Tabla codec. - */ - {"DMIC4", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic5"}, - - /* Digital Mic6 (Front bottom right corner) on Liquid. - * Digital Mic1 (Front bottom Left) on MTP. - * Digital Mic GM4 on CDP. - * Conncted to DMIC1 Input on Tabla codec. - */ - {"DMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic6"}, -}; - -static const char * const spk_function[] = {"Off", "On"}; -static const char * const rx_ch_text[] = {"One", "Two"}; -static const char * const tx_ch_text[] = {"One", "Two", "Three", "Four"}; - -static const struct soc_enum msm_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(2, rx_ch_text), - SOC_ENUM_SINGLE_EXT(4, tx_ch_text), -}; - -static const char * const btsco_rate_text[] = {"8000", "16000"}; -static const struct soc_enum msm_btsco_enum[] = { - SOC_ENUM_SINGLE_EXT(2, btsco_rate_text), -}; - -static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__, - msm_slim_0_rx_ch); - ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1; - return 0; -} - -static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__, - msm_slim_0_rx_ch); - return 1; -} - -static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, - msm_slim_0_tx_ch); - ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1; - return 0; -} - -static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, - msm_slim_0_tx_ch); - return 1; -} - -static int msm_slim_3_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_3_rx_ch = %d\n", __func__, - msm_slim_3_rx_ch); - ucontrol->value.integer.value[0] = msm_slim_3_rx_ch - 1; - return 0; -} - -static int msm_slim_3_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_3_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_3_rx_ch = %d\n", __func__, - msm_slim_3_rx_ch); - return 1; -} - -static int msm_btsco_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_btsco_rate = %d", __func__, - msm_btsco_rate); - ucontrol->value.integer.value[0] = msm_btsco_rate; - return 0; -} - -static int msm_btsco_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 8000: - msm_btsco_rate = BTSCO_RATE_8KHZ; - break; - case 16000: - msm_btsco_rate = BTSCO_RATE_16KHZ; - break; - default: - msm_btsco_rate = BTSCO_RATE_8KHZ; - break; - } - pr_debug("%s: msm_btsco_rate = %d\n", __func__, - msm_btsco_rate); - return 0; -} - -static int msm_incall_rec_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = rec_mode; - return 0; -} - -static int msm_incall_rec_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - rec_mode = ucontrol->value.integer.value[0]; - pr_debug("%s: rec_mode:%d\n", __func__, rec_mode); - - return 0; -} - -static const struct snd_kcontrol_new tabla_msm_controls[] = { - SOC_ENUM_EXT("Speaker Function", msm_enum[0], msm_get_spk, - msm_set_spk), - SOC_ENUM_EXT("SLIM_0_RX Channels", msm_enum[1], - msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put), - SOC_ENUM_EXT("SLIM_0_TX Channels", msm_enum[2], - msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put), - SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0], - msm_btsco_rate_get, msm_btsco_rate_put), - SOC_SINGLE_EXT("Incall Rec Mode", SND_SOC_NOPM, 0, 1, 0, - msm_incall_rec_mode_get, msm_incall_rec_mode_put), - SOC_ENUM_EXT("SLIM_3_RX Channels", msm_enum[1], - msm_slim_3_rx_ch_get, msm_slim_3_rx_ch_put), -}; - - -static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_mi2s_rx_ch = %d\n", __func__, - msm_mi2s_rx_ch); - ucontrol->value.integer.value[0] = msm_mi2s_rx_ch - 1; - return 0; -} - -static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_mi2s_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_mi2s_rx_ch = %d\n", __func__, - msm_mi2s_rx_ch); - return 1; -} - -static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_mi2s_tx_ch = %d\n", __func__, - msm_mi2s_tx_ch); - ucontrol->value.integer.value[0] = msm_mi2s_tx_ch - 1; - return 0; -} - -static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_mi2s_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_mi2s_tx_ch = %d\n", __func__, - msm_mi2s_tx_ch); - return 1; -} - -static int msm_mi2s_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - ucontrol->value.integer.value[0] = msm_spk_control; - return 0; -} -static int msm_mi2s_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm_spk_control == ucontrol->value.integer.value[0]) - return 0; - - msm_spk_control = ucontrol->value.integer.value[0]; - msm_ext_control(codec); - return 1; -} - -static int msm_mi2s_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s(): channels = %d\n", __func__, msm_mi2s_rx_ch); - channels->min = channels->max = msm_mi2s_rx_ch; - - return 0; -} - -static int msm_mi2s_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s(): channels = %d\n", __func__, msm_mi2s_tx_ch); - channels->min = channels->max = msm_mi2s_tx_ch; - - return 0; -} - - -static int msm_i2s_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s(): channels = %d\n", __func__, msm_i2s_rx_ch); - channels->min = channels->max = msm_i2s_rx_ch; - - return 0; -} - -static int msm_i2s_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s(): channels = %d\n", __func__, msm_i2s_tx_ch); - channels->min = channels->max = msm_i2s_tx_ch; - - return 0; -} - -static const struct snd_kcontrol_new tabla_msm_mi2s_controls[] = { - SOC_ENUM_EXT("Speaker Function", msm_enum[0], msm_mi2s_get_spk, - msm_mi2s_set_spk), - SOC_ENUM_EXT("MI2S_RX Channels", msm_enum[1], - msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put), - SOC_ENUM_EXT("MI2S_TX Channels", msm_enum[2], - msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put), - SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0], - msm_btsco_rate_get, msm_btsco_rate_put), - SOC_SINGLE_EXT("Incall Rec Mode", SND_SOC_NOPM, 0, 1, 0, - msm_incall_rec_mode_get, msm_incall_rec_mode_put), -}; - -static int msm_mi2s_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int ret; - uint32_t revision; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - struct pm_gpio param = { - .direction = PM_GPIO_DIR_OUT, - .output_buffer = PM_GPIO_OUT_BUF_CMOS, - .output_value = 1, - .pull = PM_GPIO_PULL_NO, - .vin_sel = PM_GPIO_VIN_S4, - .out_strength = PM_GPIO_STRENGTH_MED, - .function = PM_GPIO_FUNC_NORMAL, - }; - - pr_debug("%s(), dev_name(%s)\n", __func__, dev_name(cpu_dai->dev)); - ret = gpio_request(GPIO_MI2S_MCLK, "MI2S_MCLK"); - if (ret) - pr_err("%s: Failed to request gpio %d\n", __func__, - GPIO_MI2S_MCLK); - - /* APQ provides the mclk to codec */ - ret = gpio_request(mdm_mclk_gpio, "MDM_MCLK_SWITCH"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", __func__, - mdm_mclk_gpio); - return ret; - } - ret = pm8xxx_gpio_config(mdm_mclk_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure gpio %d\n", __func__, - mdm_mclk_gpio); - else - gpio_direction_output(mdm_mclk_gpio, 0); - - pr_debug("%s: Config mdm_mclk_gpio\n", __func__); - ret = gpio_request(apq_mclk_gpio, "APQ_MCLK_SWITCH"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", __func__, - apq_mclk_gpio); - return ret; - } - ret = pm8xxx_gpio_config(apq_mclk_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure gpio %d\n", __func__, - apq_mclk_gpio); - else - gpio_direction_output(apq_mclk_gpio, 1); - - pr_debug("%s: Config apq_mclk_gpio\n", __func__); - - snd_soc_dapm_new_controls(dapm, apq8064_dapm_widgets, - ARRAY_SIZE(apq8064_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, apq8064_common_audio_map, - ARRAY_SIZE(apq8064_common_audio_map)); - - if (machine_is_apq8064_mtp()) { - snd_soc_dapm_add_routes(dapm, apq8064_mtp_audio_map, - ARRAY_SIZE(apq8064_mtp_audio_map)); - } else { - snd_soc_dapm_add_routes(dapm, apq8064_liquid_cdp_audio_map, - ARRAY_SIZE(apq8064_liquid_cdp_audio_map)); - } - - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - - snd_soc_dapm_sync(dapm); - - ret = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_OC_HPHL | - SND_JACK_OC_HPHR | SND_JACK_UNSUPPORTED), - &hs_jack); - if (ret) { - pr_err("failed to create new jack\n"); - return ret; - } - - ret = snd_soc_jack_new(codec, "Button Jack", - TABLA_JACK_BUTTON_MASK, &button_jack); - if (ret) { - pr_err("failed to create new jack\n"); - return ret; - } - /* Get the MCLK from MI2S block for MBHC calibration */ - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - pr_debug("%s: Device name is %s\n", __func__, dev_name(cpu_dai->dev)); - - /* APQ8064 Rev 1.1 CDP and Liquid have mechanical switch */ - revision = socinfo_get_version(); - if (apq8064_i2s_hs_detect_use_gpio != -1) { - if (apq8064_i2s_hs_detect_use_gpio == 1) - pr_debug("%s: MBHC mechanical is enabled by request\n", - __func__); - else if (apq8064_i2s_hs_detect_use_gpio == 0) - pr_debug("%s: MBHC mechanical is disabled by request\n", - __func__); - else - pr_warn("%s: Invalid hs_detect_use_gpio %d\n", __func__, - apq8064_i2s_hs_detect_use_gpio); - } else if (SOCINFO_VERSION_MAJOR(revision) == 0) { - pr_warn("%s: Unknown HW revision detected %d.%d\n", __func__, - SOCINFO_VERSION_MAJOR(revision), - SOCINFO_VERSION_MINOR(revision)); - } else if ((SOCINFO_VERSION_MAJOR(revision) == 1 && - SOCINFO_VERSION_MINOR(revision) >= 1 && - (machine_is_apq8064_cdp() || - machine_is_apq8064_liquid())) || - SOCINFO_VERSION_MAJOR(revision) > 1) { - pr_debug("%s: MBHC mechanical switch available APQ8064 detected\n", - __func__); - apq8064_i2s_hs_detect_use_gpio = 1; - } - - if (apq8064_i2s_hs_detect_use_gpio == 1) { - pr_debug("%s: Using MBHC mechanical switch\n", __func__); - mbhc_cfg.gpio = JACK_DETECT_GPIO; - mbhc_cfg.gpio_irq = gpio_to_irq(JACK_DETECT_GPIO); - ret = gpio_request(mbhc_cfg.gpio, "MBHC_HS_DETECT"); - if (ret < 0) { - pr_err("%s: gpio_request %d failed %d\n", __func__, - mbhc_cfg.gpio, ret); - return ret; - } - gpio_direction_input(JACK_DETECT_GPIO); - } else - pr_debug("%s: Not using MBHC mechanical switch\n", __func__); - - mbhc_cfg.read_fw_bin = apq8064_i2s_hs_detect_use_firmware; - - ret = tabla_hs_detect(codec, &mbhc_cfg); - - /* MDM provides the mclk to codec */ - gpio_direction_output(apq_mclk_gpio, 0); - gpio_direction_output(mdm_mclk_gpio, 1); - pr_debug("%s: Clock switch to MDM\n", __func__); - /* Should we add code to put back codec clock?*/ - gpio_free(GPIO_MI2S_MCLK); - pr_debug("%s: Free MCLK GPIO\n", __func__); - return ret; -} - -static int msm_mi2s_free_gpios(void) -{ - int i; - for (i = 0; i < ARRAY_SIZE(mi2s_gpio); i++) - gpio_free(mi2s_gpio[i].gpio_no); - return 0; -} - -static void msm_mi2s_shutdown(struct snd_pcm_substream *substream) -{ - - if (atomic_dec_return(&mi2s_rsc_ref) == 0) { - pr_debug("%s: free mi2s resources\n", __func__); - if (mi2s_bit_clk) { - clk_disable_unprepare(mi2s_bit_clk); - clk_put(mi2s_bit_clk); - mi2s_bit_clk = NULL; - } - msm_mi2s_free_gpios(); - } -} - -static int msm_configure_mi2s_gpio(void) -{ - int rtn; - int i; - int j; - for (i = 0; i < ARRAY_SIZE(mi2s_gpio); i++) { - rtn = gpio_request(mi2s_gpio[i].gpio_no, - mi2s_gpio[i].gpio_name); - pr_debug("%s: gpio = %d, gpio name = %s, rtn = %d\n", - __func__, - mi2s_gpio[i].gpio_no, - mi2s_gpio[i].gpio_name, - rtn); - if (rtn) { - pr_err("%s: Failed to request gpio %d\n", - __func__, - mi2s_gpio[i].gpio_no); - for (j = i; j >= 0; j--) - gpio_free(mi2s_gpio[j].gpio_no); - goto err; - } - } -err: - return rtn; -} - -static int msm_mi2s_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - pr_debug("%s: dai name %s %p\n", __func__, cpu_dai->name, cpu_dai->dev); - - if (atomic_inc_return(&mi2s_rsc_ref) == 1) { - pr_debug("%s: acquire mi2s resources\n", __func__); - msm_configure_mi2s_gpio(); - pr_debug("%s: APQ is MI2S slave\n", __func__); - mi2s_bit_clk = clk_get(cpu_dai->dev, "bit_clk"); - if (IS_ERR(mi2s_bit_clk)) - return PTR_ERR(mi2s_bit_clk); - clk_set_rate(mi2s_bit_clk, 0); - ret = clk_prepare_enable(mi2s_bit_clk); - if (IS_ERR_VALUE(ret)) { - pr_err("Unable to enable mi2s_bit_clk\n"); - clk_put(mi2s_bit_clk); - return ret; - } - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - if (IS_ERR_VALUE(ret)) - pr_err("set format for CPU dai failed\n"); - } - - return ret; -} - - -static int msm_i2s_rx_free_gpios(void) -{ - int i; - for (i = 0; i < ARRAY_SIZE(spkr_i2s_gpio); i++) - gpio_free(spkr_i2s_gpio[i].gpio_no); - return 0; -} - - -static int msm_i2s_tx_free_gpios(void) -{ - int i; - for (i = 0; i < ARRAY_SIZE(mic_i2s_gpio); i++) - gpio_free(mic_i2s_gpio[i].gpio_no); - return 0; -} - -static void msm_i2s_shutdown(struct snd_pcm_substream *substream) -{ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_debug("%s: free i2s rx resources\n", __func__); - if (i2s_rx_bit_clk) { - clk_disable_unprepare(i2s_rx_bit_clk); - clk_put(i2s_rx_bit_clk); - i2s_rx_bit_clk = NULL; - } - msm_i2s_rx_free_gpios(); - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - pr_debug("%s: free i2s tx resources\n", __func__); - if (i2s_tx_bit_clk) { - clk_disable_unprepare(i2s_tx_bit_clk); - clk_put(i2s_tx_bit_clk); - i2s_tx_bit_clk = NULL; - } - msm_i2s_tx_free_gpios(); - } -} - -static int msm_configure_i2s_rx_gpio(void) -{ - int rtn; - int i; - int j; - for (i = 0; i < ARRAY_SIZE(spkr_i2s_gpio); i++) { - rtn = gpio_request(spkr_i2s_gpio[i].gpio_no, - spkr_i2s_gpio[i].gpio_name); - pr_debug("%s: gpio = %d, gpio name = %s, rtn = %d\n", - __func__, - spkr_i2s_gpio[i].gpio_no, - spkr_i2s_gpio[i].gpio_name, - rtn); - if (rtn) { - pr_err("%s: Failed to request gpio %d\n", - __func__, - spkr_i2s_gpio[i].gpio_no); - for (j = i; j >= 0; j--) - gpio_free(spkr_i2s_gpio[j].gpio_no); - goto err; - } - } -err: - return rtn; -} - -static int msm_configure_i2s_tx_gpio(void) -{ - int rtn; - int i; - int j; - for (i = 0; i < ARRAY_SIZE(mic_i2s_gpio); i++) { - rtn = gpio_request(mic_i2s_gpio[i].gpio_no, - mic_i2s_gpio[i].gpio_name); - pr_debug("%s: gpio = %d, gpio name = %s, rtn = %d\n", - __func__, - mic_i2s_gpio[i].gpio_no, - mic_i2s_gpio[i].gpio_name, - rtn); - if (rtn) { - pr_err("%s: Failed to request gpio %d\n", - __func__, - mic_i2s_gpio[i].gpio_no); - for (j = i; j >= 0; j--) - gpio_free(mic_i2s_gpio[j].gpio_no); - goto err; - } - } -err: - return rtn; -} - -static int msm_i2s_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - msm_configure_i2s_rx_gpio(); - i2s_rx_bit_clk = clk_get(cpu_dai->dev, "bit_clk"); - if (IS_ERR(i2s_rx_bit_clk)) { - pr_err("Failed to get i2s bit_clk\n"); - return PTR_ERR(i2s_rx_bit_clk); - } - clk_set_rate(i2s_rx_bit_clk, 0); - ret = clk_prepare_enable(i2s_rx_bit_clk); - if (IS_ERR_VALUE(ret)) { - pr_err("Unable to enable i2s_rx_bit_clk\n"); - clk_put(i2s_rx_bit_clk); - return ret; - } - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - if (IS_ERR_VALUE(ret)) - pr_err("set format for CPU dai failed\n"); - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - msm_configure_i2s_tx_gpio(); - i2s_tx_bit_clk = clk_get(cpu_dai->dev, "bit_clk"); - if (IS_ERR(i2s_tx_bit_clk)) { - pr_err("Failed to get i2s_tx_bit_clk\n"); - return PTR_ERR(i2s_tx_bit_clk); - } - clk_set_rate(i2s_tx_bit_clk, 0); - ret = clk_prepare_enable(i2s_tx_bit_clk); - if (ret != 0) { - pr_err("Unable to enable i2s_tx_bit_clk\n"); - clk_put(i2s_tx_bit_clk); - return ret; - } - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - if (IS_ERR_VALUE(ret)) - pr_err("set format for CPU dai failed\n"); - } - - pr_debug("%s: ret = %d\n", __func__, ret); - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - return ret; -} - -static void *def_tabla_mbhc_cal(void) -{ - void *tabla_cal; - struct tabla_mbhc_btn_detect_cfg *btn_cfg; - u16 *btn_low, *btn_high; - u8 *n_ready, *n_cic, *gain; - - tabla_cal = kzalloc(TABLA_MBHC_CAL_SIZE(TABLA_MBHC_DEF_BUTTONS, - TABLA_MBHC_DEF_RLOADS), - GFP_KERNEL); - if (!tabla_cal) { - pr_err("%s: out of memory\n", __func__); - return NULL; - } - -#define S(X, Y) ((TABLA_MBHC_CAL_GENERAL_PTR(tabla_cal)->X) = (Y)) - S(t_ldoh, 100); - S(t_bg_fast_settle, 100); - S(t_shutdown_plug_rem, 255); - S(mbhc_nsa, 4); - S(mbhc_navg, 4); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_DET_PTR(tabla_cal)->X) = (Y)) - S(mic_current, TABLA_PID_MIC_5_UA); - S(hph_current, TABLA_PID_MIC_5_UA); - S(t_mic_pid, 100); - S(t_ins_complete, 250); - S(t_ins_retry, 200); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_TYPE_PTR(tabla_cal)->X) = (Y)) - S(v_no_mic, 30); - S(v_hs_max, 1550); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal)->X) = (Y)) - S(c[0], 62); - S(c[1], 124); - S(nc, 1); - S(n_meas, 3); - S(mbhc_nsc, 11); - S(n_btn_meas, 1); - S(n_btn_con, 2); - S(num_btn, TABLA_MBHC_DEF_BUTTONS); - S(v_btn_press_delta_sta, 100); - S(v_btn_press_delta_cic, 50); -#undef S - btn_cfg = TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal); - btn_low = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_LOW); - btn_high = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_HIGH); - btn_low[0] = -50; - btn_high[0] = 10; - btn_low[1] = 11; - btn_high[1] = 38; - btn_low[2] = 39; - btn_high[2] = 64; - btn_low[3] = 65; - btn_high[3] = 91; - btn_low[4] = 92; - btn_high[4] = 115; - btn_low[5] = 116; - btn_high[5] = 141; - btn_low[6] = 142; - btn_high[6] = 163; - btn_low[7] = 164; - btn_high[7] = 250; - n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY); - n_ready[0] = 48; - n_ready[1] = 38; - n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC); - n_cic[0] = 60; - n_cic[1] = 47; - gain = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_GAIN); - gain[0] = 11; - gain[1] = 9; - - return tabla_cal; -} - -static int msm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - unsigned int num_tx_ch = 0; - - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - - pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - msm_slim_0_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(codec_dai, 0, 0, - msm_slim_0_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set codec channel map\n", - __func__); - goto end; - } - } else { - - if (codec_dai->id == 2) - num_tx_ch = msm_slim_0_tx_ch; - else if (codec_dai->id == 5) { - /* DAI 5 is used for external EC reference from codec. - * Since Rx is fed as reference for EC, the config of - * this DAI is based on that of the Rx path. - */ - num_tx_ch = msm_slim_0_rx_ch; - } - - pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__, - codec_dai->name, codec_dai->id, num_tx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, - num_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(codec_dai, - num_tx_ch, tx_ch, 0, 0); - if (ret < 0) { - pr_err("%s: failed to set codec channel map\n", - __func__); - goto end; - } - - - } -end: - return ret; -} - -static int msm_stubrx_init(struct snd_soc_pcm_runtime *rtd) -{ - rtd->pmdown_time = 0; - - return 0; -} - -static int msm_slimbus_2_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - unsigned int num_tx_ch = 0; - unsigned int num_rx_ch = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - - num_rx_ch = params_channels(params); - - pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__, - codec_dai->name, codec_dai->id, num_rx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - num_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(codec_dai, 0, 0, - num_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set codec channel map\n", - __func__); - goto end; - } - } else { - - num_tx_ch = params_channels(params); - - pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__, - codec_dai->name, codec_dai->id, num_tx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, - num_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(codec_dai, - num_tx_ch, tx_ch, 0, 0); - if (ret < 0) { - pr_err("%s: failed to set codec channel map\n", - __func__); - goto end; - } - } -end: - return ret; -} - -static int msm_slimbus_1_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch = SLIM_1_RX_1, tx_ch = SLIM_1_TX_1; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_debug("%s: APQ BT/USB TX -> SLIMBUS_1_RX -> MDM TX shared ch %d\n", - __func__, rx_ch); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, 1, &rx_ch); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_1 RX channel map\n", - __func__, ret); - - goto end; - } - } else { - pr_debug("%s: MDM RX -> SLIMBUS_1_TX -> APQ BT/USB Rx shared ch %d\n", - __func__, tx_ch); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 1, &tx_ch, 0, 0); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_1 TX channel map\n", - __func__, ret); - - goto end; - } - } - -end: - return ret; -} - -static int msm_slimbus_3_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[2] = {SLIM_3_RX_1, SLIM_3_RX_2}; - unsigned int tx_ch[2] = {SLIM_3_TX_1, SLIM_3_TX_2}; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_debug("%s: slim_3_rx_ch %d, sch %d %d\n", - __func__, msm_slim_3_rx_ch, - rx_ch[0], rx_ch[1]); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - msm_slim_3_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_3 RX channel map\n", - __func__, ret); - - goto end; - } - } else { - pr_debug("%s: MDM RX -> SLIMBUS_3_TX -> APQ HDMI ch: %d, %d\n", - __func__, tx_ch[0], tx_ch[1]); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 2, tx_ch, 0, 0); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_3 TX channel map\n", - __func__, ret); - - goto end; - } - } - -end: - return ret; -} - -static int msm_slimbus_4_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch = SLIM_4_RX_1, tx_ch[2]; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_debug("%s: APQ Incall Playback SLIMBUS_4_RX -> MDM TX shared ch %d\n", - __func__, rx_ch); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, 1, &rx_ch); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_4 RX channel map\n", - __func__, ret); - - } - } else { - if (rec_mode == INCALL_REC_STEREO) { - tx_ch[0] = SLIM_4_TX_1; - tx_ch[1] = SLIM_4_TX_2; - ret = snd_soc_dai_set_channel_map(cpu_dai, 2, - tx_ch, 0, 0); - } else { - tx_ch[0] = SLIM_4_TX_1; - ret = snd_soc_dai_set_channel_map(cpu_dai, 1, - tx_ch, 0, 0); - } - pr_debug("%s: Incall Record shared tx_ch[0]:%d, tx_ch[1]:%d\n", - __func__, tx_ch[0], tx_ch[1]); - - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_4 TX channel map\n", - __func__, ret); - - } - } - - return ret; -} - -static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - uint32_t revision; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - pr_debug("%s(), dev_name(%s)\n", __func__, dev_name(cpu_dai->dev)); - - /*if (machine_is_msm_liquid()) { - top_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(19)); - bottom_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(18)); - }*/ - - snd_soc_dapm_new_controls(dapm, apq8064_dapm_widgets, - ARRAY_SIZE(apq8064_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, apq8064_common_audio_map, - ARRAY_SIZE(apq8064_common_audio_map)); - - if (machine_is_apq8064_mtp()) { - snd_soc_dapm_add_routes(dapm, apq8064_mtp_audio_map, - ARRAY_SIZE(apq8064_mtp_audio_map)); - } else { - snd_soc_dapm_add_routes(dapm, apq8064_liquid_cdp_audio_map, - ARRAY_SIZE(apq8064_liquid_cdp_audio_map)); - } - - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - - snd_soc_dapm_sync(dapm); - - err = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_OC_HPHL | - SND_JACK_OC_HPHR | SND_JACK_UNSUPPORTED), - &hs_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - err = snd_soc_jack_new(codec, "Button Jack", - TABLA_JACK_BUTTON_MASK, &button_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - - /* APQ8064 Rev 1.1 CDP and Liquid have mechanical switch */ - revision = socinfo_get_version(); - if (apq8064_i2s_hs_detect_use_gpio != -1) { - if (apq8064_i2s_hs_detect_use_gpio == 1) - pr_debug("%s: MBHC mechanical is enabled by request\n", - __func__); - else if (apq8064_i2s_hs_detect_use_gpio == 0) - pr_debug("%s: MBHC mechanical is disabled by request\n", - __func__); - else - pr_warn("%s: Invalid hs_detect_use_gpio %d\n", __func__, - apq8064_i2s_hs_detect_use_gpio); - } else if (SOCINFO_VERSION_MAJOR(revision) == 0) { - pr_warn("%s: Unknown HW revision detected %d.%d\n", __func__, - SOCINFO_VERSION_MAJOR(revision), - SOCINFO_VERSION_MINOR(revision)); - } else if ((SOCINFO_VERSION_MAJOR(revision) == 1 && - SOCINFO_VERSION_MINOR(revision) >= 1 && - (machine_is_apq8064_cdp() || - machine_is_apq8064_liquid())) || - SOCINFO_VERSION_MAJOR(revision) > 1) { - pr_debug("%s: MBHC mechanical switch available APQ8064 detected\n", - __func__); - apq8064_i2s_hs_detect_use_gpio = 1; - } - - if (apq8064_i2s_hs_detect_use_gpio == 1) { - pr_debug("%s: Using MBHC mechanical switch\n", __func__); - mbhc_cfg.gpio = JACK_DETECT_GPIO; - mbhc_cfg.gpio_irq = gpio_to_irq(JACK_DETECT_GPIO); - err = gpio_request(mbhc_cfg.gpio, "MBHC_HS_DETECT"); - if (err < 0) { - pr_err("%s: gpio_request %d failed %d\n", __func__, - mbhc_cfg.gpio, err); - return err; - } - gpio_direction_input(JACK_DETECT_GPIO); - } else - pr_debug("%s: Not using MBHC mechanical switch\n", __func__); - - mbhc_cfg.read_fw_bin = apq8064_i2s_hs_detect_use_firmware; - - err = tabla_hs_detect(codec, &mbhc_cfg); - - return err; -} - -static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_0_rx_ch; - - return 0; -} - -static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_0_tx_ch; - - return 0; -} - -static int msm_slim_3_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_3_rx_ch; - - return 0; -} - -static int msm_slim_3_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = 2; - - return 0; -} - -static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s channels->min %u channels->max %u ()\n", __func__, - channels->min, channels->max); - - rate->min = rate->max = 48000; - - return 0; -} - -static int msm_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = msm_btsco_rate; - channels->min = channels->max = msm_btsco_ch; - - return 0; -} -static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - /* PCM only supports mono output with 8khz sample rate */ - rate->min = rate->max = 8000; - channels->min = channels->max = 1; - - return 0; -} -static int msm_proxy_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm_aux_pcm_get_gpios(void) -{ - return 0; -} - -static int msm_aux_pcm_free_gpios(void) -{ - return 0; -} -static int msm_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n", - __func__, rtd->dai_link->stream_name, - rtd->dai_link->cpu_dai_name, - rtd->dai_link->codec_dai_name); - return 0; -} - -static int msm_auxpcm_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_inc_return(&auxpcm_rsc_ref) == 1) - ret = msm_aux_pcm_get_gpios(); - if (ret < 0) { - pr_err("%s: Aux PCM GPIO request failed\n", __func__); - return -EINVAL; - } - return 0; -} - -static int msm_slimbus_1_startup(struct snd_pcm_substream *substream) -{ - struct slim_controller *slim = slim_busnum_to_ctrl(1); - - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - - if (slim != NULL) - pm_runtime_get_sync(slim->dev.parent); - - return 0; -} - -static void msm_auxpcm_shutdown(struct snd_pcm_substream *substream) -{ - - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_dec_return(&auxpcm_rsc_ref) == 0) - msm_aux_pcm_free_gpios(); -} - -static void msm_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n", - __func__, rtd->dai_link->stream_name, - rtd->dai_link->cpu_dai_name, rtd->dai_link->codec_dai_name); -} - -static void msm_slimbus_1_shutdown(struct snd_pcm_substream *substream) -{ - struct slim_controller *slim = slim_busnum_to_ctrl(1); - - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - - if (slim != NULL) { - pm_runtime_mark_last_busy(slim->dev.parent); - pm_runtime_put(slim->dev.parent); - } -} - -static struct snd_soc_ops msm_be_ops = { - .startup = msm_startup, - .hw_params = msm_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops msm_auxpcm_be_ops = { - .startup = msm_auxpcm_startup, - .shutdown = msm_auxpcm_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_1_be_ops = { - .startup = msm_slimbus_1_startup, - .hw_params = msm_slimbus_1_hw_params, - .shutdown = msm_slimbus_1_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_3_be_ops = { - .startup = msm_startup, - .hw_params = msm_slimbus_3_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_4_be_ops = { - .startup = msm_startup, - .hw_params = msm_slimbus_4_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_2_be_ops = { - .startup = msm_startup, - .hw_params = msm_slimbus_2_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops msm_mi2s_be_ops = { - .startup = msm_mi2s_startup, - .shutdown = msm_mi2s_shutdown, -}; - - -static struct snd_soc_ops msm_i2s_be_ops = { - .startup = msm_i2s_startup, - .shutdown = msm_i2s_shutdown, -}; - -static struct snd_soc_dai_link msm_dai_delta_mi2s[] = { - /* Backend DAI Links */ - { - .name = LPASS_BE_MI2S_RX, - .stream_name = "MI2S Playback", - .cpu_dai_name = "msm-dai-q6-mi2s", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_i2s_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_MI2S_RX, - .init = &msm_mi2s_audrx_init, - .be_hw_params_fixup = msm_mi2s_rx_be_hw_params_fixup, - .ops = &msm_mi2s_be_ops, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_MI2S_TX, - .stream_name = "MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_i2s_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_MI2S_TX, - .be_hw_params_fixup = msm_mi2s_tx_be_hw_params_fixup, - .ops = &msm_mi2s_be_ops, - }, - { - .name = LPASS_BE_PRI_I2S_RX, - .stream_name = "Primary I2S Playback", - .cpu_dai_name = "msm-dai-q6.0", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_PRI_I2S_RX, - .be_hw_params_fixup = msm_i2s_rx_be_hw_params_fixup, - .ops = &msm_i2s_be_ops, - }, - { - .name = LPASS_BE_PRI_I2S_TX, - .stream_name = "Primary I2S Capture", - .cpu_dai_name = "msm-dai-q6.1", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_PRI_I2S_TX, - .be_hw_params_fixup = msm_i2s_tx_be_hw_params_fixup, - .ops = &msm_i2s_be_ops, - }, -}; - - -static struct snd_soc_dai_link msm_dai_delta_slim[] = { - /* Hostless PMC purpose */ - { - .name = "SLIMBUS_0 Hostless", - .stream_name = "SLIMBUS_0 Hostless", - .cpu_dai_name = "SLIMBUS0_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - /* .be_id = do not care */ - }, - /* Backend DAI Links */ - { - .name = LPASS_BE_SLIMBUS_0_RX, - .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX, - .init = &msm_audrx_init, - .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, - .ops = &msm_be_ops, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_0_TX, - .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX, - .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup, - .ops = &msm_be_ops, - }, - { - .name = LPASS_BE_STUB_RX, - .stream_name = "Stub Playback", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx2", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_EXTPROC_RX, - .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, - .init = &msm_stubrx_init, - .ops = &msm_be_ops, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_STUB_TX, - .stream_name = "Stub Capture", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_EXTPROC_TX, - .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup, - .ops = &msm_be_ops, - }, - { - .name = LPASS_BE_SLIMBUS_1_RX, - .stream_name = "Slimbus1 Playback", - .cpu_dai_name = "msm-dai-q6.16386", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX, - .be_hw_params_fixup = msm_btsco_be_hw_params_fixup, - .ops = &msm_slimbus_1_be_ops, - .ignore_pmdown_time = 1, /* Playback support */ - - }, - { - .name = LPASS_BE_SLIMBUS_1_TX, - .stream_name = "Slimbus1 Capture", - .cpu_dai_name = "msm-dai-q6.16387", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX, - .be_hw_params_fixup = msm_btsco_be_hw_params_fixup, - .ops = &msm_slimbus_1_be_ops, - }, - /* Ultrasound TX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Capture", - .stream_name = "SLIMBUS_2 Hostless Capture", - .cpu_dai_name = "msm-dai-q6.16389", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx2", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm_slimbus_2_be_ops, - }, - /* Ultrasound RX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Playback", - .stream_name = "SLIMBUS_2 Hostless Playback", - .cpu_dai_name = "msm-dai-q6.16388", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx3", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm_slimbus_2_be_ops, - }, - /* Incall Music Back End DAI Link */ - { - .name = LPASS_BE_SLIMBUS_4_RX, - .stream_name = "Slimbus4 Playback", - .cpu_dai_name = "msm-dai-q6.16392", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - .ops = &msm_slimbus_4_be_ops, - .ignore_pmdown_time = 1, /* Playback support */ - }, - /* Incall Record Back End DAI Link */ - { - .name = LPASS_BE_SLIMBUS_4_TX, - .stream_name = "Slimbus4 Capture", - .cpu_dai_name = "msm-dai-q6.16393", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - .ops = &msm_slimbus_4_be_ops, - }, - { - .name = LPASS_BE_STUB_1_TX, - .stream_name = "Stub1 Capture", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx3", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_EXTPROC_EC_TX, - /* This BE is used for external EC reference from codec. Since - * Rx is fed as reference for EC, the config of this DAI is - * based on that of the Rx path. - */ - .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, - .ops = &msm_be_ops, - }, - { - .name = LPASS_BE_SLIMBUS_3_RX, - .stream_name = "Slimbus3 Playback", - .cpu_dai_name = "msm-dai-q6.16390", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX, - .be_hw_params_fixup = msm_slim_3_rx_be_hw_params_fixup, - .ops = &msm_slimbus_3_be_ops, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_3_TX, - .stream_name = "Slimbus3 Capture", - .cpu_dai_name = "msm-dai-q6.16391", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX, - .be_hw_params_fixup = msm_slim_3_tx_be_hw_params_fixup, - .ops = &msm_slimbus_3_be_ops, - }, -}; - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm_dai[] = { - /* FrontEnd DAI Links */ - { - /* - * In APQ8064 I2S platform, there is no playback support - * only voice call is supported so there is no even system - * tone or dialing tone which is by design because I2S clock - * is provided by MDM which matches voice call sample rate - * 8kHz or 16kHz while system tone is 48kHz. We disable the - * playback by feeding the audio to AUX PCM port. - */ - .name = "MSM8960 Media1", - .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MSM8960 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - { - .name = "Circuit-Switch Voice", - .stream_name = "CS-Voice", - .cpu_dai_name = "CS-VOICE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .be_id = MSM_FRONTEND_DAI_CS_VOICE, - }, - { - .name = "MSM VoIP", - .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .be_id = MSM_FRONTEND_DAI_VOIP, - }, - { - .name = "MSM8960 LPA", - .stream_name = "LPA", - .cpu_dai_name = "MultiMedia3", - .platform_name = "msm-pcm-lpa", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3, - }, - { - .name = "INT_FM Hostless", - .stream_name = "INT_FM Hostless", - .cpu_dai_name = "INT_FM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - /* .be_id = do not care */ - }, - { - .name = "MSM AFE-PCM RX", - .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = "MSM AFE-PCM TX", - .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "MSM8960 Compr", - .stream_name = "COMPR", - .cpu_dai_name = "MultiMedia4", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4, - }, - { - .name = "AUXPCM Hostless", - .stream_name = "AUXPCM Hostless", - .cpu_dai_name = "AUXPCM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* HDMI Hostless */ - { - .name = "HDMI_RX_HOSTLESS", - .stream_name = "HDMI_RX_HOSTLESS", - .cpu_dai_name = "HDMI_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = "Voice Stub", - .stream_name = "Voice Stub", - .cpu_dai_name = "VOICE_STUB", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* Playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* Backend BT/FM DAI Links */ - { - .name = LPASS_BE_INT_BT_SCO_RX, - .stream_name = "Internal BT-SCO Playback", - .cpu_dai_name = "msm-dai-q6.12288", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX, - .be_hw_params_fixup = msm_btsco_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_INT_BT_SCO_TX, - .stream_name = "Internal BT-SCO Capture", - .cpu_dai_name = "msm-dai-q6.12289", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX, - .be_hw_params_fixup = msm_btsco_be_hw_params_fixup, - }, - { - .name = LPASS_BE_INT_FM_RX, - .stream_name = "Internal FM Playback", - .cpu_dai_name = "msm-dai-q6.12292", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_RX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_INT_FM_TX, - .stream_name = "Internal FM Capture", - .cpu_dai_name = "msm-dai-q6.12293", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_TX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - }, - /* HDMI BACK END DAI Link */ - { - .name = LPASS_BE_HDMI, - .stream_name = "HDMI Playback", - .cpu_dai_name = "msm-dai-q6-hdmi.8", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_HDMI_RX, - .be_hw_params_fixup = msm_hdmi_be_hw_params_fixup, - }, - /* Backend AFE DAI Links */ - { - .name = LPASS_BE_AFE_PCM_RX, - .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, - .be_hw_params_fixup = msm_proxy_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_AFE_PCM_TX, - .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, - .be_hw_params_fixup = msm_proxy_be_hw_params_fixup, - }, - /* AUX PCM Backend DAI Links */ - { - .name = LPASS_BE_AUXPCM_RX, - .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_RX, - .be_hw_params_fixup = msm_auxpcm_be_params_fixup, - .ops = &msm_auxpcm_be_ops, - .ignore_pmdown_time = 1, /* Playback support */ - }, - { - .name = LPASS_BE_AUXPCM_TX, - .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_TX, - .be_hw_params_fixup = msm_auxpcm_be_params_fixup, - .ops = &msm_auxpcm_be_ops, - }, -}; - - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm_mi2s_dai[ - ARRAY_SIZE(msm_dai) + - ARRAY_SIZE(msm_dai_delta_mi2s)]; - -static struct snd_soc_dai_link msm_slim_dai[ - ARRAY_SIZE(msm_dai) + - ARRAY_SIZE(msm_dai_delta_slim)]; - -static struct snd_soc_card snd_soc_card_msm = { - .name = "apq8064-tabla-snd-card", -}; - -static struct platform_device *msm_snd_device; - -static int __init msm_audio_init(void) -{ - - int ret; - u32 version = socinfo_get_platform_version(); - if (!machine_is_apq8064_mtp() || - (SOCINFO_VERSION_MINOR(version) != 1)) { - pr_info("%s: Not APQ8064 in I2S mode\n", __func__); - return -ENODEV; - } - mutex_init(&cdc_mclk_mutex); - pr_debug("%s: APQ8064 is in I2S mode\n", __func__); - mbhc_cfg.calibration = def_tabla_mbhc_cal(); - if (!mbhc_cfg.calibration) { - pr_err("Calibration data allocation failed\n"); - return -ENOMEM; - } - - msm_snd_device = platform_device_alloc("soc-audio", 0); - if (!msm_snd_device) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - - if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - memcpy(msm_slim_dai, msm_dai, sizeof(msm_dai)); - memcpy(msm_slim_dai + ARRAY_SIZE(msm_dai), - msm_dai_delta_slim, sizeof(msm_dai_delta_slim)); - snd_soc_card_msm.dai_link = msm_slim_dai; - snd_soc_card_msm.num_links = ARRAY_SIZE(msm_slim_dai); - snd_soc_card_msm.controls = tabla_msm_controls; - snd_soc_card_msm.num_controls = - ARRAY_SIZE(tabla_msm_controls); - pr_info("%s: Load Slimbus Dai\n", __func__); - } else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) { - memcpy(msm_mi2s_dai, msm_dai, sizeof(msm_dai)); - memcpy(msm_mi2s_dai + ARRAY_SIZE(msm_dai), - msm_dai_delta_mi2s, sizeof(msm_dai_delta_mi2s)); - snd_soc_card_msm.dai_link = msm_mi2s_dai; - snd_soc_card_msm.num_links = ARRAY_SIZE(msm_mi2s_dai); - snd_soc_card_msm.controls = tabla_msm_mi2s_controls; - snd_soc_card_msm.num_controls = - ARRAY_SIZE(tabla_msm_mi2s_controls); - pr_info("%s: Load MI2S\n", __func__); - } - - platform_set_drvdata(msm_snd_device, &snd_soc_card_msm); - ret = platform_device_add(msm_snd_device); - if (ret) { - platform_device_put(msm_snd_device); - kfree(mbhc_cfg.calibration); - return ret; - } - - atomic_set(&mi2s_rsc_ref, 0); - atomic_set(&auxpcm_rsc_ref, 0); - return ret; - -} -module_init(msm_audio_init); - -static void __exit msm_audio_exit(void) -{ - if (!soc_class_is_apq8064() || socinfo_get_id() == 130) { - pr_err("%s: Not the right machine type\n", __func__); - return ; - } - platform_device_unregister(msm_snd_device); - if (mbhc_cfg.gpio) - gpio_free(mbhc_cfg.gpio); - kfree(mbhc_cfg.calibration); - mutex_destroy(&cdc_mclk_mutex); -} -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC msm"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/apq8064.c b/sound/soc/msm/apq8064.c deleted file mode 100644 index 17005996f60485889d7ee23f5cf651a63f67eb3a..0000000000000000000000000000000000000000 --- a/sound/soc/msm/apq8064.c +++ /dev/null @@ -1,2233 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "../codecs/wcd9310.h" - -/* 8064 machine driver */ - -#define PM8921_GPIO_BASE NR_GPIO_IRQS -#define PM8921_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio - 1 + PM8921_GPIO_BASE) - -#define MSM8064_SPK_ON 1 -#define MSM8064_SPK_OFF 0 - -#define MSM_SLIM_0_RX_MAX_CHANNELS 2 -#define MSM_SLIM_0_TX_MAX_CHANNELS 4 - -#define SAMPLE_RATE_8KHZ 8000 -#define SAMPLE_RATE_16KHZ 16000 -#define SAMPLE_RATE_48KHZ 48000 - -#define BOTTOM_SPK_AMP_POS 0x1 -#define BOTTOM_SPK_AMP_NEG 0x2 -#define TOP_SPK_AMP_POS 0x4 -#define TOP_SPK_AMP_NEG 0x8 -#define TOP_SPK_AMP 0x10 - - -#define GPIO_AUX_PCM_DOUT 43 -#define GPIO_AUX_PCM_DIN 44 -#define GPIO_AUX_PCM_SYNC 45 -#define GPIO_AUX_PCM_CLK 46 - -#define TABLA_EXT_CLK_RATE 12288000 - -#define TABLA_MBHC_DEF_BUTTONS 8 -#define TABLA_MBHC_DEF_RLOADS 5 - -#define JACK_DETECT_GPIO 38 - -/* Shared channel numbers for Slimbus ports that connect APQ to MDM. */ -enum { - SLIM_1_RX_1 = 145, /* BT-SCO and USB TX */ - SLIM_1_TX_1 = 146, /* BT-SCO and USB RX */ - SLIM_1_TX_2 = 147, /* USB RX */ - SLIM_3_RX_1 = 151, /* External echo-cancellation ref */ - SLIM_3_RX_2 = 152, /* External echo-cancellation ref */ - SLIM_3_TX_1 = 153, /* HDMI RX */ - SLIM_3_TX_2 = 154, /* HDMI RX */ - SLIM_4_TX_1 = 148, /* In-call recording RX */ - SLIM_4_TX_2 = 149, /* In-call recording RX */ - SLIM_4_RX_1 = 150, /* In-call music delivery TX */ -}; - -enum { - INCALL_REC_MONO, - INCALL_REC_STEREO, -}; - -static u32 top_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(18); -static u32 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(19); -static int msm_spk_control; -static int msm_ext_bottom_spk_pamp; -static int msm_ext_top_spk_pamp; -static int msm_slim_0_rx_ch = 1; -static int msm_slim_0_tx_ch = 1; -static int msm_slim_3_rx_ch = 1; - -static int msm_slim_1_rate = SAMPLE_RATE_8KHZ; -static int msm_btsco_ch = 1; -static int msm_slim_1_rx_ch = 1; -static int msm_slim_1_tx_ch = 1; - -static int hdmi_rate_variable; -static int rec_mode = INCALL_REC_MONO; - -static struct clk *codec_clk; -static int clk_users; - -static struct snd_soc_jack hs_jack; -static struct snd_soc_jack button_jack; -static atomic_t auxpcm_rsc_ref; - -static int apq8064_hs_detect_use_gpio = -1; -module_param(apq8064_hs_detect_use_gpio, int, 0444); -MODULE_PARM_DESC(apq8064_hs_detect_use_gpio, "Use GPIO for headset detection"); - -static bool apq8064_hs_detect_extn_cable; -module_param(apq8064_hs_detect_extn_cable, bool, 0444); -MODULE_PARM_DESC(apq8064_hs_detect_extn_cable, "Enable extension cable feature"); - -static bool apq8064_hs_detect_use_firmware; -module_param(apq8064_hs_detect_use_firmware, bool, 0444); -MODULE_PARM_DESC(apq8064_hs_detect_use_firmware, "Use firmware for headset " - "detection"); - -static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm); - -static struct tabla_mbhc_config mbhc_cfg = { - .headset_jack = &hs_jack, - .button_jack = &button_jack, - .read_fw_bin = false, - .calibration = NULL, - .micbias = TABLA_MICBIAS2, - .mclk_cb_fn = msm_enable_codec_ext_clk, - .mclk_rate = TABLA_EXT_CLK_RATE, - .gpio = 0, - .gpio_irq = 0, - .gpio_level_insert = 1, - .detect_extn_cable = false, -}; - -static struct mutex cdc_mclk_mutex; - -static void msm_enable_ext_spk_amp_gpio(u32 spk_amp_gpio) -{ - int ret = 0; - - struct pm_gpio param = { - .direction = PM_GPIO_DIR_OUT, - .output_buffer = PM_GPIO_OUT_BUF_CMOS, - .output_value = 1, - .pull = PM_GPIO_PULL_NO, - .vin_sel = PM_GPIO_VIN_S4, - .out_strength = PM_GPIO_STRENGTH_MED, - . - function = PM_GPIO_FUNC_NORMAL, - }; - - if (spk_amp_gpio == bottom_spk_pamp_gpio) { - - ret = gpio_request(bottom_spk_pamp_gpio, "BOTTOM_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting BOTTOM SPK AMP GPIO %u\n", - __func__, bottom_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(bottom_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Bottom Spk Ampl" - " gpio %u\n", __func__, bottom_spk_pamp_gpio); - else { - pr_debug("%s: enable Bottom spkr amp gpio\n", __func__); - gpio_direction_output(bottom_spk_pamp_gpio, 1); - } - - } else if (spk_amp_gpio == top_spk_pamp_gpio) { - - ret = gpio_request(top_spk_pamp_gpio, "TOP_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting GPIO %d\n", __func__, - top_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(top_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Top Spk Ampl" - " gpio %u\n", __func__, top_spk_pamp_gpio); - else { - pr_debug("%s: enable Top spkr amp gpio\n", __func__); - gpio_direction_output(top_spk_pamp_gpio, 1); - } - } else { - pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO." - " gpio = %u\n", __func__, spk_amp_gpio); - return; - } -} - -static void msm_ext_spk_power_amp_on(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - pr_debug("%s() External Bottom Speaker Ampl already " - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - msm_ext_bottom_spk_pamp |= spk; - - if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - msm_enable_ext_spk_amp_gpio(bottom_spk_pamp_gpio); - pr_debug("%s: slepping 4 ms after turning on external " - " Bottom Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { - - pr_debug("%s():top_spk_amp_state = 0x%x spk_event = 0x%x\n", - __func__, msm_ext_top_spk_pamp, spk); - - if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || - (msm_ext_top_spk_pamp & TOP_SPK_AMP)) { - - pr_debug("%s() External Top Speaker Ampl already" - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - msm_ext_top_spk_pamp |= spk; - - if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || - (msm_ext_top_spk_pamp & TOP_SPK_AMP)) { - - msm_enable_ext_spk_amp_gpio(top_spk_pamp_gpio); - pr_debug("%s: sleeping 4 ms after turning on " - " external Top Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - } else { - - pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm_ext_spk_power_amp_off(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if (!msm_ext_bottom_spk_pamp) - return; - - gpio_direction_output(bottom_spk_pamp_gpio, 0); - gpio_free(bottom_spk_pamp_gpio); - msm_ext_bottom_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after turning off external Bottom" - " Speaker Ampl\n", __func__); - - usleep_range(4000, 4000); - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { - - pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n", - __func__, msm_ext_top_spk_pamp, spk); - - if (!msm_ext_top_spk_pamp) - return; - - if ((spk & TOP_SPK_AMP_POS) || (spk & TOP_SPK_AMP_NEG)) { - - msm_ext_top_spk_pamp &= (~(TOP_SPK_AMP_POS | - TOP_SPK_AMP_NEG)); - } else if (spk & TOP_SPK_AMP) { - msm_ext_top_spk_pamp &= ~TOP_SPK_AMP; - } - - if (msm_ext_top_spk_pamp) - return; - - gpio_direction_output(top_spk_pamp_gpio, 0); - gpio_free(top_spk_pamp_gpio); - msm_ext_top_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after ext Top Spek Ampl is off\n", - __func__); - - usleep_range(4000, 4000); - } else { - - pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm_ext_control(struct snd_soc_codec *codec) -{ - struct snd_soc_dapm_context *dapm = &codec->dapm; - - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - if (msm_spk_control == MSM8064_SPK_ON) { - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - } else { - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg"); - } - - snd_soc_dapm_sync(dapm); -} - -static int msm_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - ucontrol->value.integer.value[0] = msm_spk_control; - return 0; -} -static int msm_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm_spk_control == ucontrol->value.integer.value[0]) - return 0; - - msm_spk_control = ucontrol->value.integer.value[0]; - msm_ext_control(codec); - return 1; -} -static int msm_spkramp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event)); - - if (SND_SOC_DAPM_EVENT_ON(event)) { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top", 12)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - - } else { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top", 12)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - } - return 0; -} - -static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm) -{ - int r = 0; - pr_debug("%s: enable = %d\n", __func__, enable); - - mutex_lock(&cdc_mclk_mutex); - if (enable) { - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 1) { - if (codec_clk) { - clk_set_rate(codec_clk, TABLA_EXT_CLK_RATE); - clk_prepare_enable(codec_clk); - tabla_mclk_enable(codec, 1, dapm); - } else { - pr_err("%s: Error setting Tabla MCLK\n", - __func__); - clk_users--; - r = -EINVAL; - } - } - } else { - if (clk_users > 0) { - clk_users--; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 0) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - tabla_mclk_enable(codec, 0, dapm); - clk_disable_unprepare(codec_clk); - } - } else { - pr_err("%s: Error releasing Tabla MCLK\n", __func__); - r = -EINVAL; - } - } - mutex_unlock(&cdc_mclk_mutex); - return r; -} - -static int msm_mclk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - pr_debug("%s: event = %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - - if (clk_users != 1) - return 0; - - if (codec_clk) { - clk_set_rate(codec_clk, 12288000); - clk_prepare_enable(codec_clk); - tabla_mclk_enable(w->codec, 1, true); - - } else { - pr_err("%s: Error setting Tabla MCLK\n", __func__); - clk_users--; - return -EINVAL; - } - break; - case SND_SOC_DAPM_POST_PMD: - - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - - if (clk_users == 0) - return 0; - - clk_users--; - - if (!clk_users) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - - tabla_mclk_enable(w->codec, 0, true); - clk_disable_unprepare(codec_clk); - } - break; - } - return 0; -} - -static const struct snd_soc_dapm_widget apq8064_dapm_widgets[] = { - - SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, - msm_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SPK("Ext Spk Bottom Pos", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Bottom Neg", msm_spkramp_event), - - SND_SOC_DAPM_SPK("Ext Spk Top Pos", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Top Neg", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Top", msm_spkramp_event), - - /************ Analog MICs ************/ - /** - * Analog mic7 (Front Top) on Liquid. - * Used as Handset mic on CDP. - */ - SND_SOC_DAPM_MIC("Analog mic7", NULL), - - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), - - /*********** Digital Mics ***************/ - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("Digital Mic2", NULL), - SND_SOC_DAPM_MIC("Digital Mic3", NULL), - SND_SOC_DAPM_MIC("Digital Mic4", NULL), - SND_SOC_DAPM_MIC("Digital Mic5", NULL), - SND_SOC_DAPM_MIC("Digital Mic6", NULL), -}; - -static const struct snd_soc_dapm_route apq8064_common_audio_map[] = { - - {"RX_BIAS", NULL, "MCLK"}, - {"LDO_H", NULL, "MCLK"}, - - {"HEADPHONE", NULL, "LDO_H"}, - - /* Speaker path */ - {"Ext Spk Bottom Pos", NULL, "LINEOUT1"}, - {"Ext Spk Bottom Neg", NULL, "LINEOUT3"}, - - {"Ext Spk Top Pos", NULL, "LINEOUT2"}, - {"Ext Spk Top Neg", NULL, "LINEOUT4"}, - {"Ext Spk Top", NULL, "LINEOUT5"}, - - /************ Analog MIC Paths ************/ - - /* Headset Mic */ - {"AMIC2", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "Headset Mic"}, - - /* Headset ANC microphones */ - {"AMIC3", NULL, "MIC BIAS3 Internal1"}, - {"MIC BIAS3 Internal1", NULL, "ANCRight Headset Mic"}, - - {"AMIC4", NULL, "MIC BIAS1 Internal2"}, - {"MIC BIAS1 Internal2", NULL, "ANCLeft Headset Mic"}, -}; - -static const struct snd_soc_dapm_route apq8064_mtp_audio_map[] = { - - /************ Digital MIC Paths ************/ - - /* - * Digital Mic1 (Front bottom Left) on MTP. - * Conncted to DMIC1 Input on Tabla codec. - */ - {"DMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic1"}, - - /** - * Digital Mic2 (Front bottom right) on MTP. - * Conncted to DMIC2 Input on Tabla codec. - */ - {"DMIC2", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic2"}, - - /** - * Digital Mic3 (Back bottom) on MTP. - * Conncted to DMIC3 Input on Tabla codec. - */ - {"DMIC3", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic3"}, - - /** - * Digital Mic4 (Back top) on MTP. - * Conncted to DMIC4 Input on Tabla codec. - */ - {"DMIC4", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic4"}, - - /** - * Digital Mic5 (Top front Mic) on MTP. - * Conncted to DMIC6 Input on Tabla codec. - */ - {"DMIC6", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic5"}, - -}; - -static const struct snd_soc_dapm_route apq8064_liquid_cdp_audio_map[] = { - - /************ Analog MIC Paths ************/ - /** - * Analog mic7 (Front Top Mic) on Liquid. - * Used as Handset mic on CDP. - * Not there on MTP. - */ - {"AMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Analog mic7"}, - - - /************ Digital MIC Paths ************/ - /** - * The digital Mic routes are setup considering - * Liquid as default device. - */ - - /** - * Digital Mic1 (Front bottom left corner) on Liquid. - * Digital Mic2 (Front bottom right) on MTP. - * Digital Mic GM1 on CDP mainboard. - * Conncted to DMIC2 Input on Tabla codec. - */ - {"DMIC2", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic1"}, - - /** - * Digital Mic2 (Front left side) on Liquid. - * Digital Mic GM2 on CDP mainboard. - * Not there on MTP. - * Conncted to DMIC3 Input on Tabla codec. - */ - {"DMIC3", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic2"}, - - /** - * Digital Mic3. Front bottom left of middle on Liquid. - * Digital Mic5 (Top front Mic) on MTP. - * Digital Mic GM5 on CDP mainboard. - * Conncted to DMIC6 Input on Tabla codec. - */ - {"DMIC6", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic3"}, - - /** - * Digital Mic4. Back bottom on Liquid. - * Digital Mic GM3 on CDP mainboard. - * Top Front Mic on MTP. - * Conncted to DMIC5 Input on Tabla codec. - */ - {"DMIC5", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic4"}, - - /** - * Digital Mic5. Front bottom right of middle on Liquid. - * Digital Mic GM6 on CDP mainboard. - * Not there on MTP. - * Conncted to DMIC4 Input on Tabla codec. - */ - {"DMIC4", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic5"}, - - /* Digital Mic6 (Front bottom right corner) on Liquid. - * Digital Mic1 (Front bottom Left) on MTP. - * Digital Mic GM4 on CDP. - * Conncted to DMIC1 Input on Tabla codec. - */ - {"DMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic6"}, -}; - -static const char *spk_function[] = {"Off", "On"}; -static const char *slim0_rx_ch_text[] = {"One", "Two"}; -static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"}; -static const char * const hdmi_rate[] = {"Default", "Variable"}; - -static const struct soc_enum msm_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text), - SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text), - SOC_ENUM_SINGLE_EXT(2, hdmi_rate), -}; - -static const char * const slim1_rate_text[] = {"8000", "16000", "48000"}; -static const struct soc_enum msm_slim_1_rate_enum[] = { - SOC_ENUM_SINGLE_EXT(3, slim1_rate_text), -}; -static const char * const slim1_tx_ch_text[] = {"One", "Two"}; -static const struct soc_enum msm_slim_1_tx_ch_enum[] = { - SOC_ENUM_SINGLE_EXT(2, slim1_tx_ch_text), -}; -static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__, - msm_slim_0_rx_ch); - ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1; - return 0; -} - -static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__, - msm_slim_0_rx_ch); - return 1; -} - -static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, - msm_slim_0_tx_ch); - ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1; - return 0; -} - -static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, - msm_slim_0_tx_ch); - return 1; -} - -static int msm_slim_1_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_1_tx_ch = %d\n", __func__, - msm_slim_1_tx_ch); - - ucontrol->value.integer.value[0] = msm_slim_1_tx_ch - 1; - return 0; -} - -static int msm_slim_1_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_1_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_1_tx_ch = %d\n", __func__, - msm_slim_1_tx_ch); - - return 1; -} - -static int msm_slim_3_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_3_rx_ch = %d\n", __func__, - msm_slim_3_rx_ch); - ucontrol->value.integer.value[0] = msm_slim_3_rx_ch - 1; - return 0; -} - -static int msm_slim_3_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_3_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_3_rx_ch = %d\n", __func__, - msm_slim_3_rx_ch); - return 1; -} - -static int msm_slim_1_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_1_rate = %d", __func__, - msm_slim_1_rate); - - ucontrol->value.integer.value[0] = msm_slim_1_rate; - return 0; -} - -static int msm_slim_1_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 8000: - msm_slim_1_rate = SAMPLE_RATE_8KHZ; - break; - case 16000: - msm_slim_1_rate = SAMPLE_RATE_16KHZ; - break; - case 48000: - msm_slim_1_rate = SAMPLE_RATE_48KHZ; - break; - default: - msm_slim_1_rate = SAMPLE_RATE_8KHZ; - break; - } - pr_debug("%s: msm_slim_1_rate = %d\n", __func__, - msm_slim_1_rate); - return 0; -} - -static int msm_incall_rec_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = rec_mode; - return 0; -} - -static int msm_incall_rec_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - rec_mode = ucontrol->value.integer.value[0]; - pr_debug("%s: rec_mode:%d\n", __func__, rec_mode); - - return 0; -} - -static int msm_hdmi_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - hdmi_rate_variable = ucontrol->value.integer.value[0]; - pr_debug("%s: hdmi_rate_variable = %d\n", __func__, hdmi_rate_variable); - return 0; -} - -static int msm_hdmi_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = hdmi_rate_variable; - return 0; -} - -static const struct snd_kcontrol_new tabla_msm_controls[] = { - SOC_ENUM_EXT("Speaker Function", msm_enum[0], msm_get_spk, - msm_set_spk), - SOC_ENUM_EXT("SLIM_0_RX Channels", msm_enum[1], - msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put), - SOC_ENUM_EXT("SLIM_0_TX Channels", msm_enum[2], - msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put), - SOC_ENUM_EXT("SLIM_1_TX Channels", msm_slim_1_tx_ch_enum[0], - msm_slim_1_tx_ch_get, msm_slim_1_tx_ch_put), - SOC_ENUM_EXT("SLIM_1 SampleRate", msm_slim_1_rate_enum[0], - msm_slim_1_rate_get, msm_slim_1_rate_put), - SOC_SINGLE_EXT("Incall Rec Mode", SND_SOC_NOPM, 0, 1, 0, - msm_incall_rec_mode_get, msm_incall_rec_mode_put), - SOC_ENUM_EXT("SLIM_3_RX Channels", msm_enum[1], - msm_slim_3_rx_ch_get, msm_slim_3_rx_ch_put), - SOC_ENUM_EXT("HDMI RX Rate", msm_enum[3], - msm_hdmi_rate_get, - msm_hdmi_rate_put), -}; - -static void *def_tabla_mbhc_cal(void) -{ - void *tabla_cal; - struct tabla_mbhc_btn_detect_cfg *btn_cfg; - u16 *btn_low, *btn_high; - u8 *n_ready, *n_cic, *gain; - - tabla_cal = kzalloc(TABLA_MBHC_CAL_SIZE(TABLA_MBHC_DEF_BUTTONS, - TABLA_MBHC_DEF_RLOADS), - GFP_KERNEL); - if (!tabla_cal) { - pr_err("%s: out of memory\n", __func__); - return NULL; - } - -#define S(X, Y) ((TABLA_MBHC_CAL_GENERAL_PTR(tabla_cal)->X) = (Y)) - S(t_ldoh, 100); - S(t_bg_fast_settle, 100); - S(t_shutdown_plug_rem, 255); - S(mbhc_nsa, 4); - S(mbhc_navg, 4); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_DET_PTR(tabla_cal)->X) = (Y)) - S(mic_current, TABLA_PID_MIC_5_UA); - S(hph_current, TABLA_PID_MIC_5_UA); - S(t_mic_pid, 100); - S(t_ins_complete, 250); - S(t_ins_retry, 200); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_TYPE_PTR(tabla_cal)->X) = (Y)) - S(v_no_mic, 30); - S(v_hs_max, 2400); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal)->X) = (Y)) - S(c[0], 62); - S(c[1], 124); - S(nc, 1); - S(n_meas, 3); - S(mbhc_nsc, 11); - S(n_btn_meas, 1); - S(n_btn_con, 2); - S(num_btn, TABLA_MBHC_DEF_BUTTONS); - S(v_btn_press_delta_sta, 100); - S(v_btn_press_delta_cic, 50); -#undef S - btn_cfg = TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal); - btn_low = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_LOW); - btn_high = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_HIGH); - btn_low[0] = -50; - btn_high[0] = 20; - btn_low[1] = 21; - btn_high[1] = 62; - btn_low[2] = 62; - btn_high[2] = 104; - btn_low[3] = 105; - btn_high[3] = 143; - btn_low[4] = 144; - btn_high[4] = 181; - btn_low[5] = 182; - btn_high[5] = 218; - btn_low[6] = 219; - btn_high[6] = 254; - btn_low[7] = 255; - btn_high[7] = 330; - n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY); - n_ready[0] = 80; - n_ready[1] = 68; - n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC); - n_cic[0] = 60; - n_cic[1] = 47; - gain = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_GAIN); - gain[0] = 11; - gain[1] = 9; - - return tabla_cal; -} - -static int msm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - unsigned int num_tx_ch = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - - pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - msm_slim_0_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } else { - pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__, - codec_dai->name, codec_dai->id, num_tx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - /* For tabla_tx1 case */ - if (codec_dai->id == 1) - num_tx_ch = msm_slim_0_tx_ch; - /* For tabla_tx3 case */ - else if (codec_dai->id == 4) { - /* DAI 5 is used for external EC reference from codec. - * Since Rx is fed as reference for EC, the config of - * this DAI is based on that of the Rx path. - */ - num_tx_ch = msm_slim_0_rx_ch; - } else { - num_tx_ch = tx_ch_cnt; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, - num_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } -end: - return ret; -} - -static int msm_stubrx_init(struct snd_soc_pcm_runtime *rtd) -{ - rtd->pmdown_time = 0; - - return 0; -} - -static int msm_slimbus_2_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - unsigned int num_tx_ch = 0; - unsigned int num_rx_ch = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - - num_rx_ch = params_channels(params); - - pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__, - codec_dai->name, codec_dai->id, num_rx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - num_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } else { - - num_tx_ch = params_channels(params); - - pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__, - codec_dai->name, codec_dai->id, num_tx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, - num_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } -end: - return ret; -} - -static int msm_slimbus_1_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch = SLIM_1_RX_1, tx_ch[2] = {SLIM_1_TX_1, SLIM_1_TX_2}; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_debug("%s: APQ BT/USB TX -> SLIMBUS_1_RX -> MDM TX shared ch %d\n", - __func__, rx_ch); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, 1, &rx_ch); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_1 RX channel map\n", - __func__, ret); - - goto end; - } - } else { - pr_debug("%s: MDM RX ->SLIMBUS_1_TX ->APQ BT/USB Rx shared ch %d %d\n", - __func__, tx_ch[0], tx_ch[1]); - - ret = snd_soc_dai_set_channel_map(cpu_dai, msm_slim_1_tx_ch, - tx_ch, 0, 0); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_1 TX channel map\n", - __func__, ret); - - goto end; - } - } - -end: - return ret; -} - -static int msm_slimbus_3_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[2] = {SLIM_3_RX_1, SLIM_3_RX_2}; - unsigned int tx_ch[2] = {SLIM_3_TX_1, SLIM_3_TX_2}; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_debug("%s: slim_3_rx_ch %d, sch %d %d\n", - __func__, msm_slim_3_rx_ch, - rx_ch[0], rx_ch[1]); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - msm_slim_3_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_3 RX channel map\n", - __func__, ret); - - goto end; - } - } else { - pr_debug("%s: MDM RX -> SLIMBUS_3_TX -> APQ HDMI ch: %d, %d\n", - __func__, tx_ch[0], tx_ch[1]); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 2, tx_ch, 0, 0); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_3 TX channel map\n", - __func__, ret); - - goto end; - } - } - -end: - return ret; -} - -static int msm_slimbus_4_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch = SLIM_4_RX_1, tx_ch[2]; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pr_debug("%s: APQ Incall Playback SLIMBUS_4_RX -> MDM TX shared ch %d\n", - __func__, rx_ch); - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, 1, &rx_ch); - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_4 RX channel map\n", - __func__, ret); - - } - } else { - if (rec_mode == INCALL_REC_STEREO) { - tx_ch[0] = SLIM_4_TX_1; - tx_ch[1] = SLIM_4_TX_2; - ret = snd_soc_dai_set_channel_map(cpu_dai, 2, - tx_ch, 0, 0); - } else { - tx_ch[0] = SLIM_4_TX_1; - ret = snd_soc_dai_set_channel_map(cpu_dai, 1, - tx_ch, 0, 0); - } - pr_debug("%s: Incall Record shared tx_ch[0]:%d, tx_ch[1]:%d\n", - __func__, tx_ch[0], tx_ch[1]); - - if (ret < 0) { - pr_err("%s: Erorr %d setting SLIM_4 TX channel map\n", - __func__, ret); - - } - } - - return ret; -} - -static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - uint32_t revision; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - unsigned int rx_ch[TABLA_RX_MAX] = {138, 139, 140, 141, 142, 143, 144}; - unsigned int tx_ch[TABLA_TX_MAX] = {128, 129, 130, 131, 132, 133, 134, - 135, 136, 137}; - - - pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); - - snd_soc_dapm_new_controls(dapm, apq8064_dapm_widgets, - ARRAY_SIZE(apq8064_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, apq8064_common_audio_map, - ARRAY_SIZE(apq8064_common_audio_map)); - - if (machine_is_apq8064_mtp()) { - snd_soc_dapm_add_routes(dapm, apq8064_mtp_audio_map, - ARRAY_SIZE(apq8064_mtp_audio_map)); - } else { - snd_soc_dapm_add_routes(dapm, apq8064_liquid_cdp_audio_map, - ARRAY_SIZE(apq8064_liquid_cdp_audio_map)); - } - - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - - snd_soc_dapm_sync(dapm); - - err = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_LINEOUT | - SND_JACK_OC_HPHL | SND_JACK_OC_HPHR | - SND_JACK_UNSUPPORTED), - &hs_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - err = snd_soc_jack_new(codec, "Button Jack", - TABLA_JACK_BUTTON_MASK, &button_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - - /* APQ8064 Rev 1.1 CDP and Liquid have mechanical switch */ - revision = socinfo_get_version(); - if (apq8064_hs_detect_use_gpio != -1) { - if (apq8064_hs_detect_use_gpio == 1) - pr_debug("%s: MBHC mechanical is enabled by request\n", - __func__); - else if (apq8064_hs_detect_use_gpio == 0) - pr_debug("%s: MBHC mechanical is disabled by request\n", - __func__); - else - pr_warn("%s: Invalid hs_detect_use_gpio %d\n", __func__, - apq8064_hs_detect_use_gpio); - } else if (SOCINFO_VERSION_MAJOR(revision) == 0) { - pr_warn("%s: Unknown HW revision detected %d.%d\n", __func__, - SOCINFO_VERSION_MAJOR(revision), - SOCINFO_VERSION_MINOR(revision)); - } else if ((SOCINFO_VERSION_MAJOR(revision) == 1 && - SOCINFO_VERSION_MINOR(revision) >= 1 && - (machine_is_apq8064_cdp() || - machine_is_apq8064_liquid())) || - SOCINFO_VERSION_MAJOR(revision) > 1) { - pr_debug("%s: MBHC mechanical switch available APQ8064 " - "detected\n", __func__); - apq8064_hs_detect_use_gpio = 1; - } - - if (apq8064_hs_detect_use_gpio == 1) { - pr_debug("%s: Using MBHC mechanical switch\n", __func__); - mbhc_cfg.gpio = JACK_DETECT_GPIO; - mbhc_cfg.gpio_irq = gpio_to_irq(JACK_DETECT_GPIO); - err = gpio_request(mbhc_cfg.gpio, "MBHC_HS_DETECT"); - if (err < 0) { - pr_err("%s: gpio_request %d failed %d\n", __func__, - mbhc_cfg.gpio, err); - return err; - } - gpio_direction_input(JACK_DETECT_GPIO); - if (apq8064_hs_detect_extn_cable) - mbhc_cfg.detect_extn_cable = true; - } else - pr_debug("%s: Not using MBHC mechanical switch\n", __func__); - - mbhc_cfg.read_fw_bin = apq8064_hs_detect_use_firmware; - - err = tabla_hs_detect(codec, &mbhc_cfg); - snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), - tx_ch, ARRAY_SIZE(rx_ch), rx_ch); - - return err; -} - -static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_0_rx_ch; - - return 0; -} - -static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_0_tx_ch; - - return 0; -} - -static int msm_slim_3_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_3_rx_ch; - - return 0; -} - -static int msm_slim_3_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = 2; - - return 0; -} - -static int msm_slim_4_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - - rate->min = rate->max = 48000; - if (rec_mode == INCALL_REC_STEREO) - channels->min = channels->max = 2; - else - channels->min = channels->max = 1; - - pr_debug("%s channels->min %u channels->max %u ()\n", __func__, - channels->min, channels->max); - return 0; -} - -static int msm_slim_4_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = 48000; - channels->min = channels->max = 1; - - pr_debug("%s channels->min %u channels->max %u ()\n", __func__, - channels->min, channels->max); - return 0; -} - - -static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s channels->min %u channels->max %u ()\n", __func__, - channels->min, channels->max); - - if (channels->max < 2) - channels->min = channels->max = 2; - if (!hdmi_rate_variable) - rate->min = rate->max = 48000; - - return 0; -} - -static int msm_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = msm_slim_1_rate; - channels->min = channels->max = msm_btsco_ch; - - return 0; -} -static int msm_slim_1_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = msm_slim_1_rate; - channels->min = channels->max = msm_slim_1_rx_ch; - - return 0; -} - -static int msm_slim_1_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = msm_slim_1_rate; - channels->min = channels->max = msm_slim_1_tx_ch; - - return 0; -} - -static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - /* PCM only supports mono output with 8khz sample rate */ - rate->min = rate->max = 8000; - channels->min = channels->max = 1; - - return 0; -} -static int msm_proxy_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm_aux_pcm_get_gpios(void) -{ - int ret = 0; - - pr_debug("%s\n", __func__); - - ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", - __func__, GPIO_AUX_PCM_DOUT); - goto fail_dout; - } - - ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", - __func__, GPIO_AUX_PCM_DIN); - goto fail_din; - } - - ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", - __func__, GPIO_AUX_PCM_SYNC); - goto fail_sync; - } - ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", - __func__, GPIO_AUX_PCM_CLK); - goto fail_clk; - } - - return 0; - -fail_clk: - gpio_free(GPIO_AUX_PCM_SYNC); -fail_sync: - gpio_free(GPIO_AUX_PCM_DIN); -fail_din: - gpio_free(GPIO_AUX_PCM_DOUT); -fail_dout: - - return ret; -} - -static int msm_aux_pcm_free_gpios(void) -{ - gpio_free(GPIO_AUX_PCM_DIN); - gpio_free(GPIO_AUX_PCM_DOUT); - gpio_free(GPIO_AUX_PCM_SYNC); - gpio_free(GPIO_AUX_PCM_CLK); - - return 0; -} -static int msm_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n", - __func__, rtd->dai_link->stream_name, - rtd->dai_link->cpu_dai_name, - rtd->dai_link->codec_dai_name); - return 0; -} - -static int msm_auxpcm_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_inc_return(&auxpcm_rsc_ref) == 1) - ret = msm_aux_pcm_get_gpios(); - if (ret < 0) { - pr_err("%s: Aux PCM GPIO request failed\n", __func__); - return -EINVAL; - } - return 0; -} - -static int msm_slimbus_1_startup(struct snd_pcm_substream *substream) -{ - struct slim_controller *slim = slim_busnum_to_ctrl(1); - - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - - if (slim != NULL) - pm_runtime_get_sync(slim->dev.parent); - - return 0; -} - -static void msm_auxpcm_shutdown(struct snd_pcm_substream *substream) -{ - - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_dec_return(&auxpcm_rsc_ref) == 0) - msm_aux_pcm_free_gpios(); -} - -static void msm_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n", - __func__, rtd->dai_link->stream_name, - rtd->dai_link->cpu_dai_name, rtd->dai_link->codec_dai_name); -} - -static void msm_slimbus_1_shutdown(struct snd_pcm_substream *substream) -{ - struct slim_controller *slim = slim_busnum_to_ctrl(1); - - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - - if (slim != NULL) { - pm_runtime_mark_last_busy(slim->dev.parent); - pm_runtime_put(slim->dev.parent); - } -} - -static struct snd_soc_ops msm_be_ops = { - .startup = msm_startup, - .hw_params = msm_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops msm_auxpcm_be_ops = { - .startup = msm_auxpcm_startup, - .shutdown = msm_auxpcm_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_1_be_ops = { - .startup = msm_slimbus_1_startup, - .hw_params = msm_slimbus_1_hw_params, - .shutdown = msm_slimbus_1_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_3_be_ops = { - .startup = msm_startup, - .hw_params = msm_slimbus_3_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_4_be_ops = { - .startup = msm_startup, - .hw_params = msm_slimbus_4_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops msm_slimbus_2_be_ops = { - .startup = msm_startup, - .hw_params = msm_slimbus_2_hw_params, - .shutdown = msm_shutdown, -}; - - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm_dai[] = { - /* FrontEnd DAI Links */ - { - .name = "MSM8960 Media1", - .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MSM8960 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - { - .name = "Circuit-Switch Voice", - .stream_name = "CS-Voice", - .cpu_dai_name = "CS-VOICE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_CS_VOICE, - }, - { - .name = "MSM VoIP", - .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_VOIP, - }, - { - .name = "MSM8960 LPA", - .stream_name = "LPA", - .cpu_dai_name = "MultiMedia3", - .platform_name = "msm-pcm-lpa", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3, - }, - /* Hostless PMC purpose */ - { - .name = "SLIMBUS_0 Hostless", - .stream_name = "SLIMBUS_0 Hostless", - .cpu_dai_name = "SLIMBUS0_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - /* .be_id = do not care */ - }, - { - .name = "INT_FM Hostless", - .stream_name = "INT_FM Hostless", - .cpu_dai_name = "INT_FM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - /* .be_id = do not care */ - }, - { - .name = "MSM AFE-PCM RX", - .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = "MSM AFE-PCM TX", - .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "MSM8960 Compr", - .stream_name = "COMPR", - .cpu_dai_name = "MultiMedia4", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4, - }, - { - .name = "AUXPCM Hostless", - .stream_name = "AUXPCM Hostless", - .cpu_dai_name = "AUXPCM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* HDMI Hostless */ - { - .name = "HDMI_RX_HOSTLESS", - .stream_name = "HDMI_RX_HOSTLESS", - .cpu_dai_name = "HDMI_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = "Voice Stub", - .stream_name = "Voice Stub", - .cpu_dai_name = "VOICE_STUB", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "VoLTE Stub", - .stream_name = "VoLTE Stub", - .cpu_dai_name = "VOLTE_STUB", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "MSM8960 LowLatency", - .stream_name = "MultiMedia5", - .cpu_dai_name = "MultiMedia5", - .platform_name = "msm-lowlatency-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5, - }, - { - .name = "MSM8960 Media6", - .stream_name = "MultiMedia6", - .cpu_dai_name = "MultiMedia6", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6 - }, - { - .name = "MSM8960 Compr2", - .stream_name = "COMPR2", - .cpu_dai_name = "MultiMedia7", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7, - }, - { - .name = "MSM8960 Compr3", - .stream_name = "COMPR3", - .cpu_dai_name = "MultiMedia8", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8, - }, - { - .name = "Voice2 Stub", - .stream_name = "Voice2 Stub", - .cpu_dai_name = "VOICE2_STUB", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* Backend DAI Links */ - { - .name = LPASS_BE_SLIMBUS_0_RX, - .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX, - .init = &msm_audrx_init, - .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, - .ops = &msm_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_0_TX, - .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX, - .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup, - .ops = &msm_be_ops, - }, - /* Backend BT/FM DAI Links */ - { - .name = LPASS_BE_INT_BT_SCO_RX, - .stream_name = "Internal BT-SCO Playback", - .cpu_dai_name = "msm-dai-q6.12288", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX, - .be_hw_params_fixup = msm_btsco_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_BT_SCO_TX, - .stream_name = "Internal BT-SCO Capture", - .cpu_dai_name = "msm-dai-q6.12289", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX, - .be_hw_params_fixup = msm_btsco_be_hw_params_fixup, - }, - { - .name = LPASS_BE_INT_FM_RX, - .stream_name = "Internal FM Playback", - .cpu_dai_name = "msm-dai-q6.12292", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_RX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_FM_TX, - .stream_name = "Internal FM Capture", - .cpu_dai_name = "msm-dai-q6.12293", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_TX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - }, - /* HDMI BACK END DAI Link */ - { - .name = LPASS_BE_HDMI, - .stream_name = "HDMI Playback", - .cpu_dai_name = "msm-dai-q6-hdmi.8", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_HDMI_RX, - .be_hw_params_fixup = msm_hdmi_be_hw_params_fixup, - }, - /* Backend AFE DAI Links */ - { - .name = LPASS_BE_AFE_PCM_RX, - .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, - .be_hw_params_fixup = msm_proxy_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_AFE_PCM_TX, - .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, - .be_hw_params_fixup = msm_proxy_be_hw_params_fixup, - }, - /* AUX PCM Backend DAI Links */ - { - .name = LPASS_BE_AUXPCM_RX, - .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_RX, - .be_hw_params_fixup = msm_auxpcm_be_params_fixup, - .ops = &msm_auxpcm_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_AUXPCM_TX, - .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_TX, - .be_hw_params_fixup = msm_auxpcm_be_params_fixup, - .ops = &msm_auxpcm_be_ops, - }, - { - .name = LPASS_BE_STUB_RX, - .stream_name = "Stub Playback", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx2", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_EXTPROC_RX, - .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, - .init = &msm_stubrx_init, - .ops = &msm_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_STUB_TX, - .stream_name = "Stub Capture", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_EXTPROC_TX, - .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup, - .ops = &msm_be_ops, - }, - { - .name = LPASS_BE_SLIMBUS_1_RX, - .stream_name = "Slimbus1 Playback", - .cpu_dai_name = "msm-dai-q6.16386", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX, - .be_hw_params_fixup = msm_slim_1_rx_be_hw_params_fixup, - .ops = &msm_slimbus_1_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - - }, - { - .name = LPASS_BE_SLIMBUS_1_TX, - .stream_name = "Slimbus1 Capture", - .cpu_dai_name = "msm-dai-q6.16387", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX, - .be_hw_params_fixup = msm_slim_1_tx_be_hw_params_fixup, - .ops = &msm_slimbus_1_be_ops, - }, - /* Ultrasound TX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Capture", - .stream_name = "SLIMBUS_2 Hostless Capture", - .cpu_dai_name = "msm-dai-q6.16389", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx2", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm_slimbus_2_be_ops, - }, - /* Ultrasound RX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Playback", - .stream_name = "SLIMBUS_2 Hostless Playback", - .cpu_dai_name = "msm-dai-q6.16388", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx3", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm_slimbus_2_be_ops, - }, - /* Incall Music Back End DAI Link */ - { - .name = LPASS_BE_SLIMBUS_4_RX, - .stream_name = "Slimbus4 Playback", - .cpu_dai_name = "msm-dai-q6.16392", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX, - .be_hw_params_fixup = msm_slim_4_rx_be_hw_params_fixup, - .ops = &msm_slimbus_4_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - /* Incall Record Back End DAI Link */ - { - .name = LPASS_BE_SLIMBUS_4_TX, - .stream_name = "Slimbus4 Capture", - .cpu_dai_name = "msm-dai-q6.16393", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX, - .be_hw_params_fixup = msm_slim_4_tx_be_hw_params_fixup, - .ops = &msm_slimbus_4_be_ops, - }, - { - .name = LPASS_BE_STUB_1_TX, - .stream_name = "Stub1 Capture", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx3", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_EXTPROC_EC_TX, - /* This BE is used for external EC reference from codec. Since - * Rx is fed as reference for EC, the config of this DAI is - * based on that of the Rx path. - */ - .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, - .ops = &msm_be_ops, - }, - { - - .name = LPASS_BE_SLIMBUS_3_RX, - .stream_name = "Slimbus3 Playback", - .cpu_dai_name = "msm-dai-q6.16390", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX, - .be_hw_params_fixup = msm_slim_3_rx_be_hw_params_fixup, - .ops = &msm_slimbus_3_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_3_TX, - .stream_name = "Slimbus3 Capture", - .cpu_dai_name = "msm-dai-q6.16391", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX, - .be_hw_params_fixup = msm_slim_3_tx_be_hw_params_fixup, - .ops = &msm_slimbus_3_be_ops, - }, -}; - -static struct snd_soc_card snd_soc_card_msm = { - .name = "apq8064-tabla-snd-card", - .dai_link = msm_dai, - .num_links = ARRAY_SIZE(msm_dai), - .controls = tabla_msm_controls, - .num_controls = ARRAY_SIZE(tabla_msm_controls), -}; - -static struct platform_device *msm_snd_device; - -static int __init msm_audio_init(void) -{ - int ret; - u32 version = socinfo_get_platform_version(); - if (!soc_class_is_apq8064() || - (socinfo_get_id() == 130) || - (machine_is_apq8064_mtp() && - (SOCINFO_VERSION_MINOR(version) == 1))) { - pr_info("%s: Not APQ8064 in SLIMBUS mode\n", __func__); - return -ENODEV; - } - - if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) - bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(16); - - mutex_init(&cdc_mclk_mutex); - - mbhc_cfg.calibration = def_tabla_mbhc_cal(); - if (!mbhc_cfg.calibration) { - pr_err("Calibration data allocation failed\n"); - return -ENOMEM; - } - - msm_snd_device = platform_device_alloc("soc-audio", 0); - if (!msm_snd_device) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - - platform_set_drvdata(msm_snd_device, &snd_soc_card_msm); - ret = platform_device_add(msm_snd_device); - if (ret) { - platform_device_put(msm_snd_device); - kfree(mbhc_cfg.calibration); - return ret; - } - - atomic_set(&auxpcm_rsc_ref, 0); - return ret; - -} -module_init(msm_audio_init); - -static void __exit msm_audio_exit(void) -{ - if (!soc_class_is_apq8064() || socinfo_get_id() == 130) { - pr_err("%s: Not the right machine type\n", __func__); - return ; - } - platform_device_unregister(msm_snd_device); - if (mbhc_cfg.gpio) - gpio_free(mbhc_cfg.gpio); - kfree(mbhc_cfg.calibration); - mutex_destroy(&cdc_mclk_mutex); -} -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC msm"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/lpass-dma.c b/sound/soc/msm/lpass-dma.c deleted file mode 100644 index dcfe52a3463d36ec62a03db5cf13b24d09aff08b..0000000000000000000000000000000000000000 --- a/sound/soc/msm/lpass-dma.c +++ /dev/null @@ -1,488 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "lpass-pcm.h" - -struct dai_baseinfo { - void __iomem *base; -}; - -static struct dai_baseinfo dai_info; - -struct dai_drv { - u8 *buffer; - u32 buffer_phys; - int channels; - irqreturn_t (*callback) (int intrsrc, void *private_data); - void *private_data; - int in_use; - u32 buffer_len; - u32 period_len; - u32 master_mode; -}; - -static struct dai_drv *dai[MAX_CHANNELS]; -static spinlock_t dai_lock; - -static int dai_find_dma_channel(uint32_t intrsrc) -{ - int i, dma_channel = 0; - pr_debug("%s\n", __func__); - - for (i = 0; i <= 27; i += 3) { - if (intrsrc & (1 << i)) { - dma_channel = i / 3; - break; - } - } - return dma_channel; -} - -void register_dma_irq_handler(int dma_ch, - irqreturn_t (*callback) (int intrsrc, void *private_data), - void *private_data) -{ - pr_debug("%s\n", __func__); - dai[dma_ch]->callback = callback; - dai[dma_ch]->private_data = private_data; -} - -void unregister_dma_irq_handler(int dma_ch) -{ - pr_debug("%s\n", __func__); - dai[dma_ch]->callback = NULL; - dai[dma_ch]->private_data = NULL; -} - -static irqreturn_t dai_irq_handler(int irq, void *data) -{ - unsigned long flag; - uint32_t intrsrc; - uint32_t dma_ch = 0; - irqreturn_t ret = IRQ_HANDLED; - - pr_debug("%s\n", __func__); - spin_lock_irqsave(&dai_lock, flag); - intrsrc = readl(dai_info.base + LPAIF_IRQ_STAT(0)); - writel(intrsrc, dai_info.base + LPAIF_IRQ_CLEAR(0)); - mb(); - while (intrsrc) { - dma_ch = dai_find_dma_channel(intrsrc); - - if (!dai[dma_ch]->callback) - goto handled; - if (!dai[dma_ch]->private_data) - goto handled; - ret = dai[dma_ch]->callback(intrsrc, - dai[dma_ch]->private_data); - intrsrc &= ~(0x7 << (dma_ch * 3)); - } -handled: - spin_unlock_irqrestore(&dai_lock, flag); - return ret; -} - -void dai_print_state(uint32_t dma_ch) -{ - int i = 0; - unsigned long *ptrmem = (unsigned long *)dai_info.base; - - for (i = 0; i < 4; i++, ++ptrmem) - pr_debug("[0x%08x]=0x%08x\n", (unsigned int)ptrmem, - (unsigned int)*ptrmem); - - ptrmem = (unsigned long *)(dai_info.base - + DMA_CH_CTL_BASE + DMA_CH_INDEX(dma_ch)); - for (i = 0; i < 10; i++, ++ptrmem) - pr_debug("[0x%08x]=0x%08x\n", (unsigned int)ptrmem, - (unsigned int) *ptrmem); -} - -static int dai_enable_irq(uint32_t dma_ch) -{ - int ret; - pr_debug("%s\n", __func__); - ret = request_irq(LPASS_SCSS_AUDIO_IF_OUT0_IRQ, dai_irq_handler, - IRQF_TRIGGER_RISING | IRQF_SHARED, "msm-i2s", - (void *) (dma_ch+1)); - if (ret < 0) { - pr_debug("Request Irq Failed err = %d\n", ret); - return ret; - } - return ret; -} - -static void dai_config_dma(uint32_t dma_ch) -{ - pr_debug("%s dma_ch = %u\n", __func__, dma_ch); - - writel(dai[dma_ch]->buffer_phys, - dai_info.base + LPAIF_DMA_BASE(dma_ch)); - writel(((dai[dma_ch]->buffer_len >> 2) - 1), - dai_info.base + LPAIF_DMA_BUFF_LEN(dma_ch)); - writel(((dai[dma_ch]->period_len >> 2) - 1), - dai_info.base + LPAIF_DMA_PER_LEN(dma_ch)); - mb(); -} - -static void dai_enable_codec(uint32_t dma_ch, int codec) -{ - uint32_t intrVal; - uint32_t i2sctl; - pr_debug("%s\n", __func__); - - intrVal = readl(dai_info.base + LPAIF_IRQ_EN(0)); - intrVal = intrVal | (7 << (dma_ch * 3)); - writel(intrVal, dai_info.base + LPAIF_IRQ_EN(0)); - if (codec == DAI_SPKR) { - writel(0x0813, dai_info.base + LPAIF_DMA_CTL(dma_ch)); - i2sctl = 0x4400; - i2sctl |= (dai[dma_ch]->master_mode ? WS_SRC_INT : WS_SRC_EXT); - writel(i2sctl, dai_info.base + LPAIF_I2S_CTL_OFFSET(DAI_SPKR)); - } else if (codec == DAI_MIC) { - writel(0x81b, dai_info.base + LPAIF_DMA_CTL(dma_ch)); - i2sctl = 0x0110; - i2sctl |= (dai[dma_ch]->master_mode ? WS_SRC_INT : WS_SRC_EXT); - writel(i2sctl, dai_info.base + LPAIF_I2S_CTL_OFFSET(DAI_MIC)); - } -} - -static void dai_disable_codec(uint32_t dma_ch, int codec) -{ - uint32_t intrVal = 0; - uint32_t intrVal1 = 0; - unsigned long flag = 0x0; - - pr_debug("%s\n", __func__); - spin_lock_irqsave(&dai_lock, flag); - - intrVal1 = readl(dai_info.base + LPAIF_I2S_CTL_OFFSET(codec)); - - if (codec == DAI_SPKR) - intrVal1 = intrVal1 & ~(1 << 14); - else if (codec == DAI_MIC) - intrVal1 = intrVal1 & ~(1 << 8); - - writel(intrVal1, dai_info.base + LPAIF_I2S_CTL_OFFSET(codec)); - intrVal = 0x0; - writel(intrVal, dai_info.base + LPAIF_DMA_CTL(dma_ch)); - - spin_unlock_irqrestore(&dai_lock, flag); -} - -int dai_open(uint32_t dma_ch) -{ - - pr_debug("%s\n", __func__); - if (!dai_info.base) { - pr_debug("%s failed as no msm-dai device\n", __func__); - return -ENODEV; - } - if (dma_ch >= MAX_CHANNELS) { - pr_debug("%s over max channesl %d\n", __func__, dma_ch); - return -ENODEV; - } - return 0; -} - -void dai_close(uint32_t dma_ch) -{ - pr_debug("%s\n", __func__); - if ((dma_ch >= 0) && (dma_ch < 5)) - dai_disable_codec(dma_ch, DAI_SPKR); - else - dai_disable_codec(dma_ch, DAI_MIC); - free_irq(LPASS_SCSS_AUDIO_IF_OUT0_IRQ, (void *) (dma_ch + 1)); -} - -void dai_set_master_mode(uint32_t dma_ch, int mode) -{ - if (dma_ch < MAX_CHANNELS) - dai[dma_ch]->master_mode = mode; - else - pr_err("%s: invalid dma channel\n", __func__); -} - -int dai_set_params(uint32_t dma_ch, struct dai_dma_params *params) -{ - pr_debug("%s\n", __func__); - dai[dma_ch]->buffer = params->buffer; - dai[dma_ch]->buffer_phys = params->src_start; - dai[dma_ch]->channels = params->channels; - dai[dma_ch]->buffer_len = params->buffer_size; - dai[dma_ch]->period_len = params->period_size; - mb(); - dai_config_dma(dma_ch); - return dma_ch; -} - -int dai_start(uint32_t dma_ch) -{ - unsigned long flag = 0x0; - - spin_lock_irqsave(&dai_lock, flag); - dai_enable_irq(dma_ch); - if ((dma_ch >= 0) && (dma_ch < 5)) - dai_enable_codec(dma_ch, DAI_SPKR); - else - dai_enable_codec(dma_ch, DAI_MIC); - spin_unlock_irqrestore(&dai_lock, flag); - dai_print_state(dma_ch); - return 0; -} - -#define HDMI_BURST_INCR4 (1 << 11) -#define HDMI_WPSCNT (1 << 8) -#define HDMI_AUDIO_INTF (5 << 4) -#define HDMI_FIFO_WATER_MARK (7 << 1) -#define HDMI_ENABLE (1) - -int dai_start_hdmi(uint32_t dma_ch) -{ - unsigned long flag = 0x0; - uint32_t val; - - pr_debug("%s dma_ch = %u\n", __func__, dma_ch); - - spin_lock_irqsave(&dai_lock, flag); - - dai_enable_irq(dma_ch); - - if ((dma_ch >= 0) && (dma_ch < 5)) { - - val = readl(dai_info.base + LPAIF_IRQ_EN(0)); - val = val | (7 << (dma_ch * 3)); - writel(val, dai_info.base + LPAIF_IRQ_EN(0)); - mb(); - - - val = (HDMI_BURST_INCR4 | HDMI_WPSCNT | HDMI_AUDIO_INTF | - HDMI_FIFO_WATER_MARK | HDMI_ENABLE); - - writel(val, dai_info.base + LPAIF_DMA_CTL(dma_ch)); - } - spin_unlock_irqrestore(&dai_lock, flag); - - mb(); - dai_print_state(dma_ch); - return 0; -} - -int wait_for_dma_cnt_stop(uint32_t dma_ch) -{ - uint32_t dma_per_cnt_reg_val, dma_per_cnt, prev_dma_per_cnt; - uint32_t i; - - pr_info("%s dma_ch %u\n", __func__, dma_ch); - - dma_per_cnt_reg_val = readl_relaxed(dai_info.base + - LPAIF_DMA_PER_CNT(dma_ch)); - - dma_per_cnt = - ((LPAIF_DMA_PER_CNT_PER_CNT_MASK & dma_per_cnt_reg_val) >> - LPAIF_DMA_PER_CNT_PER_CNT_SHIFT) - - ((LPAIF_DMA_PER_CNT_FIFO_WORDCNT_MASK & dma_per_cnt_reg_val) >> - LPAIF_DMA_PER_CNT_FIFO_WORDCNT_SHIFT); - - prev_dma_per_cnt = dma_per_cnt; - - i = 1; - pr_info("%s: i = %u dma_per_cnt_reg_val 0x%08x , dma_per_cnt %u\n", - __func__, i, dma_per_cnt_reg_val, dma_per_cnt); - - while (i <= 50) { - msleep(50); - - dma_per_cnt_reg_val = readl_relaxed(dai_info.base + - LPAIF_DMA_PER_CNT(dma_ch)); - - dma_per_cnt = - ((LPAIF_DMA_PER_CNT_PER_CNT_MASK & dma_per_cnt_reg_val) >> - LPAIF_DMA_PER_CNT_PER_CNT_SHIFT) - - ((LPAIF_DMA_PER_CNT_FIFO_WORDCNT_MASK & dma_per_cnt_reg_val) >> - LPAIF_DMA_PER_CNT_FIFO_WORDCNT_SHIFT); - - i++; - - pr_info("%s: i = %u dma_per_cnt_reg_val 0x%08x , dma_per_cnt %u\n", - __func__, i, dma_per_cnt_reg_val, dma_per_cnt); - - if (prev_dma_per_cnt == dma_per_cnt) - break; - - prev_dma_per_cnt = dma_per_cnt; - } - return 0; -} - -void dai_stop_hdmi(uint32_t dma_ch) -{ - unsigned long flag = 0x0; - uint32_t intrVal; - uint32_t int_mask = 0x00000007; - - pr_debug("%s dma_ch %u\n", __func__, dma_ch); - - spin_lock_irqsave(&dai_lock, flag); - - free_irq(LPASS_SCSS_AUDIO_IF_OUT0_IRQ, (void *) (dma_ch + 1)); - - - intrVal = 0x0; - writel(intrVal, dai_info.base + LPAIF_DMA_CTL(dma_ch)); - - mb(); - - intrVal = readl(dai_info.base + LPAIF_IRQ_EN(0)); - - int_mask = ((int_mask) << (dma_ch * 3)); - int_mask = ~int_mask; - - intrVal = intrVal & int_mask; - writel(intrVal, dai_info.base + LPAIF_IRQ_EN(0)); - - mb(); - - spin_unlock_irqrestore(&dai_lock, flag); -} - -int dai_stop(uint32_t dma_ch) -{ - pr_debug("%s\n", __func__); - return 0; -} - - -uint32_t dai_get_dma_pos(uint32_t dma_ch) -{ - - uint32_t addr; - - pr_debug("%s\n", __func__); - addr = readl(dai_info.base + LPAIF_DMA_CURR_ADDR(dma_ch)); - - return addr; -} - -static int dai_probe(struct platform_device *pdev) -{ - int rc = 0; - int i = 0; - struct resource *src; - src = platform_get_resource_byname(pdev, IORESOURCE_MEM, "msm-dai"); - if (!src) { - rc = -ENODEV; - pr_debug("%s Error rc=%d\n", __func__, rc); - goto error; - } - for (i = 0; i <= MAX_CHANNELS; i++) { - dai[i] = kzalloc(sizeof(struct dai_drv), GFP_KERNEL); - if (!dai[0]) { - pr_debug("Allocation failed for dma_channel = 0\n"); - return -ENODEV; - } - } - dai_info.base = ioremap(src->start, (src->end - src->start) + 1); - pr_debug("%s: msm-dai: 0x%08x\n", __func__, - (unsigned int)dai_info.base); - spin_lock_init(&dai_lock); -error: - return rc; -} - -static int dai_remove(struct platform_device *pdev) -{ - iounmap(dai_info.base); - return 0; -} - -static struct platform_driver dai_driver = { - .probe = dai_probe, - .remove = dai_remove, - .driver = { - .name = "msm-dai", - .owner = THIS_MODULE - }, -}; - -static struct resource msm_lpa_resources[] = { - { - .start = MSM_LPA_PHYS, - .end = MSM_LPA_END, - .flags = IORESOURCE_MEM, - .name = "msm-dai", - }, -}; - -static struct platform_device *codec_device; - -static int msm_dai_dev_register(const char *name) -{ - int ret = 0; - - pr_debug("%s : called\n", __func__); - codec_device = platform_device_alloc(name, -1); - if (codec_device == NULL) { - pr_debug("Failed to allocate %s\n", name); - return -ENODEV; - } - - platform_set_drvdata(codec_device, (void *)&dai_info); - platform_device_add_resources(codec_device, &msm_lpa_resources[0], - ARRAY_SIZE(msm_lpa_resources)); - ret = platform_device_add(codec_device); - if (ret != 0) { - pr_debug("Failed to register %s: %d\n", name, ret); - platform_device_put(codec_device); - } - return ret; -} - -static int __init dai_init(void) -{ - if (msm_dai_dev_register("msm-dai")) { - pr_notice("dai_init: msm-dai Failed"); - return -ENODEV; - } - return platform_driver_register(&dai_driver); -} - -static void __exit dai_exit(void) -{ - platform_driver_unregister(&dai_driver); - platform_device_put(codec_device); -} - -module_init(dai_init); -module_exit(dai_exit); - -MODULE_DESCRIPTION("MSM I2S driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/lpass-i2s.c b/sound/soc/msm/lpass-i2s.c deleted file mode 100644 index 795f4eee64f395106c93a1767a0018921e1c257e..0000000000000000000000000000000000000000 --- a/sound/soc/msm/lpass-i2s.c +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static int msm_cpu_dai_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - uint32_t dma_ch = dai->id; - int ret = 0; - - pr_debug("%s\n", __func__); - ret = dai_open(dma_ch); - return ret; - -} - -static void msm_cpu_dai_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - uint32_t dma_ch = dai->id; - - pr_debug("%s\n", __func__); - dai_close(dma_ch); -} - -static int msm_cpu_dai_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - pr_debug("%s\n", __func__); - return 0; -} - -static int msm_cpu_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) -{ - uint32_t dma_ch = dai->id; - - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - dai_set_master_mode(dma_ch, 1); /* CPU is master */ - break; - case SND_SOC_DAIFMT_CBM_CFM: - dai_set_master_mode(dma_ch, 0); /* CPU is slave */ - break; - default: - return -EINVAL; - } - - return 0; -} - -static struct snd_soc_dai_ops msm_cpu_dai_ops = { - .startup = msm_cpu_dai_startup, - .shutdown = msm_cpu_dai_shutdown, - .trigger = msm_cpu_dai_trigger, - .set_fmt = msm_cpu_dai_fmt, - -}; - - -#define MSM_DAI_SPEAKER_BUILDER(link_id) \ -{ \ - .name = "msm-speaker-dai-"#link_id, \ - .id = (link_id), \ - .playback = { \ - .rates = SNDRV_PCM_RATE_8000_96000, \ - .formats = SNDRV_PCM_FMTBIT_S16_LE, \ - .channels_min = 1, \ - .channels_max = 2, \ - .rate_max = 96000, \ - .rate_min = 8000, \ - }, \ - .ops = &msm_cpu_dai_ops, \ -} - - -#define MSM_DAI_MIC_BUILDER(link_id) \ -{ \ - .name = "msm-mic-dai-"#link_id, \ - .id = (link_id), \ - .capture = { \ - .rates = SNDRV_PCM_RATE_8000_96000, \ - .formats = SNDRV_PCM_FMTBIT_S16_LE, \ - .rate_min = 8000, \ - .rate_max = 96000, \ - .channels_min = 1, \ - .channels_max = 2, \ - }, \ - .ops = &msm_cpu_dai_ops, \ -} - - -struct snd_soc_dai msm_cpu_dai[] = { - MSM_DAI_SPEAKER_BUILDER(0), - MSM_DAI_SPEAKER_BUILDER(1), - MSM_DAI_SPEAKER_BUILDER(2), - MSM_DAI_SPEAKER_BUILDER(3), - MSM_DAI_SPEAKER_BUILDER(4), - MSM_DAI_MIC_BUILDER(5), - MSM_DAI_MIC_BUILDER(6), - MSM_DAI_MIC_BUILDER(7), -}; -EXPORT_SYMBOL_GPL(msm_cpu_dai); - -static int __init msm_cpu_dai_init(void) -{ - return snd_soc_register_dais(msm_cpu_dai, ARRAY_SIZE(msm_cpu_dai)); -} -module_init(msm_cpu_dai_init); - -static void __exit msm_cpu_dai_exit(void) -{ - snd_soc_unregister_dais(msm_cpu_dai, ARRAY_SIZE(msm_cpu_dai)); -} -module_exit(msm_cpu_dai_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM CPU DAI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/lpass-pcm.c b/sound/soc/msm/lpass-pcm.c deleted file mode 100644 index 33d5e64911d84d5eb1081ca4c00f19bae60cfd8f..0000000000000000000000000000000000000000 --- a/sound/soc/msm/lpass-pcm.c +++ /dev/null @@ -1,369 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include "lpass-pcm.h" - -static const struct snd_pcm_hardware msm_pcm_hardware = { - .info = SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_RESUME, - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .period_bytes_min = 32, - .period_bytes_max = DMASZ/4, - .buffer_bytes_max = DMASZ, - .rate_max = 96000, - .rate_min = 8000, - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .periods_min = 4, - .periods_max = 512, - .fifo_size = 0, -}; - -struct msm_pcm_data { - spinlock_t lock; - int ch; -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - - pr_debug("%s\n", __func__); - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} - -static irqreturn_t msm_pcm_irq(int intrsrc, void *data) -{ - struct snd_pcm_substream *substream = data; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = (struct msm_audio *)runtime->private_data; - int dma_ch = 0; - unsigned int has_xrun, pending; - int ret = IRQ_NONE; - - if (prtd) - dma_ch = prtd->dma_ch; - else - return ret; - - pr_debug("msm8660-pcm: msm_pcm_irq called\n"); - pending = (intrsrc - & (UNDER_CH(dma_ch) | PER_CH(dma_ch) | ERR_CH(dma_ch))); - has_xrun = (pending & UNDER_CH(dma_ch)); - - if (unlikely(has_xrun) && - substream->runtime && - snd_pcm_running(substream)) { - pr_err("xrun\n"); - snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); - ret = IRQ_HANDLED; - pending &= ~UNDER_CH(dma_ch); - } - - - if (pending & PER_CH(dma_ch)) { - ret = IRQ_HANDLED; - if (likely(substream->runtime && - snd_pcm_running(substream))) { - /* end of buffer missed? loop back */ - if (++prtd->period_index >= runtime->periods) - prtd->period_index = 0; - snd_pcm_period_elapsed(substream); - pr_debug("period elapsed\n"); - } - pending &= ~PER_CH(dma_ch); - } - - if (unlikely(pending - & (UNDER_CH(dma_ch) & PER_CH(dma_ch) & ERR_CH(dma_ch)))) { - if (pending & UNDER_CH(dma_ch)) - pr_err("msm8660-pcm: DMA %x Underflow\n", - dma_ch); - if (pending & ERR_CH(dma_ch)) - pr_err("msm8660-pcm: DMA %x Master Error\n", - dma_ch); - - } - return ret; -} - -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = (struct msm_audio *)runtime->private_data; - struct dai_dma_params dma_params; - int dma_ch = 0; - - if (prtd) - dma_ch = prtd->dma_ch; - else - return 0; - - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - pr_debug("%s:prtd->pcm_size = %d\n", __func__, prtd->pcm_size); - pr_debug("%s:prtd->pcm_count = %d\n", __func__, prtd->pcm_count); - - if (prtd->enabled) - return 0; - - dma_params.src_start = runtime->dma_addr; - dma_params.buffer = (u8 *)runtime->dma_area; - dma_params.buffer_size = prtd->pcm_size; - dma_params.period_size = prtd->pcm_count; - dma_params.channels = runtime->channels; - - dai_set_params(dma_ch, &dma_params); - register_dma_irq_handler(dma_ch, msm_pcm_irq, (void *)substream); - - prtd->enabled = 1; - return 0; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = (struct msm_audio *)runtime->private_data; - int ret = 0; - - pr_debug("%s\n", __func__); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - dai_start(prtd->dma_ch); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - dai_stop(prtd->dma_ch); - break; - default: - ret = -EINVAL; - } - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = (struct msm_audio *)runtime->private_data; - snd_pcm_uframes_t offset = 0; - - pr_debug("%s: period_index =%d\n", __func__, prtd->period_index); - offset = prtd->period_index * runtime->period_size; - if (offset >= runtime->buffer_size) - offset = 0; - return offset; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai_link *machine = rtd->dai; - struct snd_soc_dai *cpu_dai = machine->cpu_dai; - struct msm_audio *prtd = NULL; - int ret = 0; - - pr_debug("%s\n", __func__); - snd_soc_set_runtime_hwparams(substream, &msm_pcm_hardware); - - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - - if (ret < 0) { - pr_err("Error setting hw_constraint\n"); - goto err; - } - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_err("Error snd_pcm_hw_constraint_list failed\n"); - - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - - if (prtd == NULL) { - pr_err("Error allocating prtd\n"); - ret = -ENOMEM; - goto err; - } - prtd->dma_ch = cpu_dai->id; - prtd->enabled = 0; - runtime->dma_bytes = msm_pcm_hardware.buffer_bytes_max; - runtime->private_data = prtd; -err: - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = (struct msm_audio *)runtime->private_data; - int dma_ch = 0; - - if (prtd) - dma_ch = prtd->dma_ch; - else - return 0; - - pr_debug("%s\n", __func__); - unregister_dma_irq_handler(dma_ch); - kfree(runtime->private_data); - return 0; -} - -static int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vms) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - pr_debug("%s\n", __func__); - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - pr_debug("%s: snd_msm_audio_hw_params runtime->dma_addr 0x(%x)\n", - __func__, (unsigned int)runtime->dma_addr); - pr_debug("%s: snd_msm_audio_hw_params runtime->dma_area 0x(%x)\n", - __func__, (unsigned int)runtime->dma_area); - pr_debug("%s: snd_msm_audio_hw_params runtime->dma_bytes 0x(%x)\n", - __func__, (unsigned int)runtime->dma_bytes); - - return dma_mmap_coherent(substream->pcm->card->dev, vms, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); -} - - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = msm_pcm_hw_params, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int pcm_preallocate_buffer(struct snd_pcm *pcm, - int stream) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size = msm_pcm_hardware.buffer_bytes_max; - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_coherent(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); - - if (!buf->area) - return -ENOMEM; - - buf->bytes = size; - return 0; -} - -static void msm_pcm_free_buffers(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!stream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_coherent(pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area = NULL; - } -} -static u64 msm_pcm_dmamask = DMA_BIT_MASK(32); - -static int msm_pcm_new(struct snd_card *card, struct snd_soc_dai *dai, - struct snd_pcm *pcm) -{ - int ret = 0; - - if (!card->dev->dma_mask) - card->dev->dma_mask = &msm_pcm_dmamask; - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - - if (dai->playback.channels_min) { - ret = pcm_preallocate_buffer(pcm, - SNDRV_PCM_STREAM_PLAYBACK); - if (ret) - return ret; - } - if (dai->capture.channels_min) { - ret = pcm_preallocate_buffer(pcm, - SNDRV_PCM_STREAM_CAPTURE); - if (ret) - return ret; - } - return ret; -} - -struct snd_soc_platform msm8660_soc_platform = { - .name = "msm8660-pcm-audio", - .pcm_ops = &msm_pcm_ops, - .pcm_new = msm_pcm_new, - .pcm_free = msm_pcm_free_buffers, -}; -EXPORT_SYMBOL_GPL(msm8660_soc_platform); - -static int __init msm_soc_platform_init(void) -{ - return snd_soc_register_platform(&msm8660_soc_platform); -} -static void __exit msm_soc_platform_exit(void) -{ - snd_soc_unregister_platform(&msm8660_soc_platform); -} -module_init(msm_soc_platform_init); -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("MSM PCM module"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/lpass-pcm.h b/sound/soc/msm/lpass-pcm.h deleted file mode 100644 index e7e559760c4f08bc4325c313e6d3570f5dbfc209..0000000000000000000000000000000000000000 --- a/sound/soc/msm/lpass-pcm.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2010, 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 _MSM_PCM_H -#define _MSM_PCM_H - -#define USE_CHANNELS_MIN 1 -#define USE_CHANNELS_MAX 2 -#define NUM_DMAS 9 -#define DMASZ 16384 -#define MAX_CHANNELS 9 - -#define MSM_LPA_PHYS 0x28100000 -#define MSM_LPA_END 0x2810DFFF - - -struct msm_audio { - struct snd_pcm_substream *substream; - - /* data allocated for various buffers */ - char *data; - dma_addr_t phys; - - unsigned int pcm_size; - unsigned int pcm_count; - int enabled; - int period; - int dma_ch; - int period_index; - int start; -}; - -extern struct snd_soc_dai msm_cpu_dai[NUM_DMAS]; -extern struct snd_soc_platform msm8660_soc_platform; - -#endif /*_MSM_PCM_H*/ diff --git a/sound/soc/msm/mdm9615.c b/sound/soc/msm/mdm9615.c deleted file mode 100644 index f507cea9c5b7d6f6d21c930711a6b2915f9cd61e..0000000000000000000000000000000000000000 --- a/sound/soc/msm/mdm9615.c +++ /dev/null @@ -1,2440 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "../codecs/wcd9310.h" -#include - -/* 9615 machine driver */ - -#define PM8018_GPIO_BASE NR_GPIO_IRQS -#define PM8018_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio - 1 + PM8018_GPIO_BASE) - -#define MDM9615_SPK_ON 1 -#define MDM9615_SPK_OFF 0 - -#define MDM9615_SLIM_0_RX_MAX_CHANNELS 2 -#define MDM9615_SLIM_0_TX_MAX_CHANNELS 4 - -#define SAMPLE_RATE_8KHZ 8000 -#define SAMPLE_RATE_16KHZ 16000 - -#define TOP_AND_BOTTOM_SPK_AMP_POS 0x1 -#define TOP_AND_BOTTOM_SPK_AMP_NEG 0x2 - -#define GPIO_AUX_PCM_DOUT 23 -#define GPIO_AUX_PCM_DIN 22 -#define GPIO_AUX_PCM_SYNC 21 -#define GPIO_AUX_PCM_CLK 20 - -#define GPIO_SEC_AUX_PCM_DOUT 28 -#define GPIO_SEC_AUX_PCM_DIN 27 -#define GPIO_SEC_AUX_PCM_SYNC 26 -#define GPIO_SEC_AUX_PCM_CLK 25 - -#define TABLA_EXT_CLK_RATE 12288000 - -#define TABLA_MBHC_DEF_BUTTONS 8 -#define TABLA_MBHC_DEF_RLOADS 5 - -#define PM8018_IRQ_BASE (NR_MSM_IRQS + NR_GPIO_IRQS) -#define JACK_DETECT_GPIO 3 -#define JACK_DETECT_INT PM8018_GPIO_IRQ(PM8018_IRQ_BASE, JACK_DETECT_GPIO) - -/* - * Added for I2S - */ -#define GPIO_SPKR_I2S_MCLK 24 -#define GPIO_PRIM_I2S_SCK 20 -#define GPIO_PRIM_I2S_DOUT 23 -#define GPIO_PRIM_I2S_WS 21 -#define GPIO_PRIM_I2S_DIN 22 -#define GPIO_SEC_I2S_SCK 25 -#define GPIO_SEC_I2S_WS 26 -#define GPIO_SEC_I2S_DOUT 28 -#define GPIO_SEC_I2S_DIN 27 - -static struct gpiomux_setting cdc_i2s_mclk = { - .func = GPIOMUX_FUNC_1, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, -}; - -static struct gpiomux_setting cdc_i2s_sclk = { - .func = GPIOMUX_FUNC_1, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, -}; -static struct gpiomux_setting audio_sec_i2s[] = { - /* Suspend state */ - { - .func = GPIOMUX_FUNC_GPIO, - .drv = GPIOMUX_DRV_2MA, - .pull = GPIOMUX_PULL_DOWN, - }, - /* Active state */ - { - .func = GPIOMUX_FUNC_2, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, - } -}; - -static struct gpiomux_setting cdc_i2s_dout = { - .func = GPIOMUX_FUNC_1, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, -}; - -static struct gpiomux_setting cdc_i2s_ws = { - .func = GPIOMUX_FUNC_1, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, -}; - -static struct gpiomux_setting cdc_i2s_din = { - .func = GPIOMUX_FUNC_1, - .drv = GPIOMUX_DRV_8MA, - .pull = GPIOMUX_PULL_NONE, -}; - - -static struct msm_gpiomux_config msm9615_audio_prim_i2s_codec_configs[] = { - { - .gpio = GPIO_SPKR_I2S_MCLK, - .settings = { - [GPIOMUX_SUSPENDED] = &cdc_i2s_mclk, - }, - }, - { - .gpio = GPIO_PRIM_I2S_SCK, - .settings = { - [GPIOMUX_SUSPENDED] = &cdc_i2s_sclk, - }, - }, - { - .gpio = GPIO_PRIM_I2S_DOUT, - .settings = { - [GPIOMUX_SUSPENDED] = &cdc_i2s_dout, - }, - }, - { - .gpio = GPIO_PRIM_I2S_WS, - .settings = { - [GPIOMUX_SUSPENDED] = &cdc_i2s_ws, - }, - }, - { - .gpio = GPIO_PRIM_I2S_DIN, - .settings = { - [GPIOMUX_SUSPENDED] = &cdc_i2s_din, - }, - }, -}; - -static struct msm_gpiomux_config msm9615_audio_sec_i2s_codec_configs[] = { - { - .gpio = GPIO_SPKR_I2S_MCLK, - .settings = { - [GPIOMUX_SUSPENDED] = &cdc_i2s_mclk, - }, - }, - { - .gpio = GPIO_SEC_I2S_SCK, - .settings = { - [GPIOMUX_SUSPENDED] = &audio_sec_i2s[0], - [GPIOMUX_ACTIVE] = &audio_sec_i2s[1], - }, - }, - { - .gpio = GPIO_SEC_I2S_DOUT, - .settings = { - [GPIOMUX_SUSPENDED] = &audio_sec_i2s[0], - [GPIOMUX_ACTIVE] = &audio_sec_i2s[1], - }, - }, - { - .gpio = GPIO_SEC_I2S_WS, - .settings = { - [GPIOMUX_SUSPENDED] = &audio_sec_i2s[0], - [GPIOMUX_ACTIVE] = &audio_sec_i2s[1], - }, - }, - { - .gpio = GPIO_SEC_I2S_DIN, - .settings = { - [GPIOMUX_SUSPENDED] = &audio_sec_i2s[0], - [GPIOMUX_ACTIVE] = &audio_sec_i2s[1], - }, - }, -}; -/* Physical address for LPA CSR - * LPA SIF mux registers. These are - * ioremap( ) for Virtual address. - */ -#define LPASS_CSR_BASE 0x28000000 -#define LPA_IF_BASE 0x28100000 -#define SIF_MUX_REG_BASE (LPASS_CSR_BASE + 0x00000000) -#define LPA_IF_REG_BASE (LPA_IF_BASE + 0x00000000) -#define LPASS_SIF_MUX_ADDR (SIF_MUX_REG_BASE + 0x00004000) -#define LPAIF_SPARE_ADDR (LPA_IF_REG_BASE + 0x00000070) -#define SEC_PCM_PORT_SLC_ADDR 0x00802074 -/* bits 2:0 should be updated with 100 to select SDC2 */ -#define SEC_PCM_PORT_SLC_VALUE 0x4 -/* SIF & SPARE MUX Values */ -#define MSM_SIF_FUNC_PCM 0 -#define MSM_SIF_FUNC_I2S_MIC 1 -#define MSM_SIF_FUNC_I2S_SPKR 2 -#define MSM_LPAIF_SPARE_DISABLE 0x0 -#define MSM_LPAIF_SPARE_BOTH_ENABLE 0x3 - -/* I2S INTF CTL */ -#define MSM_INTF_PRIM 0 -#define MSM_INTF_SECN 1 -#define MSM_INTF_BOTH 2 - -/* I2S Dir CTL */ -#define MSM_DIR_RX 0 -#define MSM_DIR_TX 1 -#define MSM_DIR_BOTH 2 -#define MSM_DIR_MAX 3 - -/* I2S HW Params */ -#define NO_OF_BITS_PER_SAMPLE 16 -#define I2S_MIC_SCLK_RATE 1536000 -static int msm9615_i2s_rx_ch = 1; -static int msm9615_i2s_tx_ch = 1; -static int msm9615_i2s_spk_control; - -/* SIF mux bit mask & shift */ -#define LPASS_SIF_MUX_CTL_PRI_MUX_SEL_BMSK 0x30000 -#define LPASS_SIF_MUX_CTL_PRI_MUX_SEL_SHFT 0x10 -#define LPASS_SIF_MUX_CTL_SEC_MUX_SEL_BMSK 0x3 -#define LPASS_SIF_MUX_CTL_SEC_MUX_SEL_SHFT 0x0 - -#define LPAIF_SPARE_MUX_CTL_SEC_MUX_SEL_BMSK 0x3 -#define LPAIF_SPARE_MUX_CTL_SEC_MUX_SEL_SHFT 0x2 -#define LPAIF_SPARE_MUX_CTL_PRI_MUX_SEL_BMSK 0x3 -#define LPAIF_SPARE_MUX_CTL_PRI_MUX_SEL_SHFT 0x0 - -static atomic_t msm9615_auxpcm_ref; -static atomic_t msm9615_sec_auxpcm_ref; - -struct msm_i2s_mux_ctl { - const u8 sifconfig; - const u8 spareconfig; -}; -struct msm_clk { - struct clk *osr_clk; - struct clk *bit_clk; - int clk_enable; -}; -struct msm_i2s_clk { - struct msm_clk rx_clk; - struct msm_clk tx_clk; -}; -struct msm_i2s_ctl { - struct msm_i2s_clk prim_clk; - struct msm_i2s_clk sec_clk; - struct msm_i2s_mux_ctl mux_ctl[MSM_DIR_MAX]; - u8 intf_status[MSM_INTF_BOTH][MSM_DIR_BOTH]; - void *sif_virt_addr; - void *spare_virt_addr; -}; -static struct msm_i2s_ctl msm9x15_i2s_ctl = { - {{NULL, NULL, 0}, {NULL, NULL, 0} }, /* prim_clk */ - {{NULL, NULL, 0}, {NULL, NULL, 0} }, /* sec_clk */ - /* mux_ctl */ - { - /* Rx path only */ - { MSM_SIF_FUNC_I2S_SPKR, MSM_LPAIF_SPARE_DISABLE }, - /* Tx path only */ - { MSM_SIF_FUNC_I2S_MIC, MSM_LPAIF_SPARE_DISABLE }, - /* Rx + Tx path only */ - { MSM_SIF_FUNC_I2S_SPKR, MSM_LPAIF_SPARE_BOTH_ENABLE }, - }, - /* intf_status */ - { - /* Prim I2S */ - {0, 0}, - /* Sec I2S */ - {0, 0} - }, - /* sif_virt_addr */ - NULL, - /* spare_virt_addr */ - NULL, -}; - -enum msm9x15_set_i2s_clk { - MSM_I2S_CLK_SET_FALSE, - MSM_I2S_CLK_SET_TRUE, - MSM_I2S_CLK_SET_RATE0, -}; -/* - * Added for I2S - */ -static u32 top_and_bottom_spk_pamp_gpio = PM8018_GPIO_PM_TO_SYS(5); - -void *sif_virt_addr; -void *secpcm_portslc_virt_addr; - -static int mdm9615_spk_control; -static int mdm9615_ext_top_and_bottom_spk_pamp; -static int mdm9615_slim_0_rx_ch = 1; -static int mdm9615_slim_0_tx_ch = 1; - -static int mdm9615_btsco_rate = SAMPLE_RATE_8KHZ; -static int mdm9615_btsco_ch = 1; - -static int mdm9615_auxpcm_rate = SAMPLE_RATE_8KHZ; - -static struct clk *codec_clk; -static int clk_users; - -static struct snd_soc_jack hs_jack; -static struct snd_soc_jack button_jack; - -static struct platform_device *mdm9615_snd_device_slim; -static struct platform_device *mdm9615_snd_device_i2s; - -static u32 sif_reg_value = 0x0000; -static u32 spare_reg_value = 0x0000; - -static bool hs_detect_use_gpio; -module_param(hs_detect_use_gpio, bool, 0444); -MODULE_PARM_DESC(hs_detect_use_gpio, "Use GPIO for headset detection"); - -static bool hs_detect_use_firmware; -module_param(hs_detect_use_firmware, bool, 0444); -MODULE_PARM_DESC(hs_detect_use_firmware, "Use firmware for headset detection"); - -static int mdm9615_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm); -static struct tabla_mbhc_config mbhc_cfg = { - .headset_jack = &hs_jack, - .button_jack = &button_jack, - .read_fw_bin = false, - .calibration = NULL, - .micbias = TABLA_MICBIAS2, - .mclk_cb_fn = mdm9615_enable_codec_ext_clk, - .mclk_rate = TABLA_EXT_CLK_RATE, - .gpio = 0, - .gpio_irq = 0, - .gpio_level_insert = 1, -}; - -static void mdm9615_enable_ext_spk_amp_gpio(u32 spk_amp_gpio) -{ - int ret = 0; - - struct pm_gpio param = { - .direction = PM_GPIO_DIR_OUT, - .output_buffer = PM_GPIO_OUT_BUF_CMOS, - .output_value = 1, - .pull = PM_GPIO_PULL_NO, - .vin_sel = PM_GPIO_VIN_S4, - .out_strength = PM_GPIO_STRENGTH_MED, - .function = PM_GPIO_FUNC_NORMAL, - }; - - if (spk_amp_gpio == top_and_bottom_spk_pamp_gpio) { - - ret = gpio_request(top_and_bottom_spk_pamp_gpio, - "TOP_AND_BOTTOM_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting TOP AND BOTTOM SPK AMP GPIO %u\n", - __func__, top_and_bottom_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(top_and_bottom_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Top & Bottom Spk Ampl\n" - "gpio %u\n", __func__, - top_and_bottom_spk_pamp_gpio); - else { - pr_debug("%s: enable Top & Bottom spkr amp gpio\n", - __func__); - gpio_direction_output(top_and_bottom_spk_pamp_gpio, 1); - } - - } else { - pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO." - " gpio = %u\n", __func__, spk_amp_gpio); - return; - } -} - -static void mdm9615_ext_spk_power_amp_on(u32 spk) -{ - if (spk & (TOP_AND_BOTTOM_SPK_AMP_POS | TOP_AND_BOTTOM_SPK_AMP_NEG)) { - if ((mdm9615_ext_top_and_bottom_spk_pamp & - TOP_AND_BOTTOM_SPK_AMP_POS) && - (mdm9615_ext_top_and_bottom_spk_pamp & - TOP_AND_BOTTOM_SPK_AMP_NEG)) { - pr_debug("%s() External Speaker Ampl already " - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - mdm9615_ext_top_and_bottom_spk_pamp |= spk; - - if ((mdm9615_ext_top_and_bottom_spk_pamp & - TOP_AND_BOTTOM_SPK_AMP_POS) && - (mdm9615_ext_top_and_bottom_spk_pamp & - TOP_AND_BOTTOM_SPK_AMP_NEG)) { - mdm9615_enable_ext_spk_amp_gpio( - top_and_bottom_spk_pamp_gpio); - pr_debug("%s: slepping 4 ms after turning on external\n" - "Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - - } else { - pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void mdm9615_ext_spk_power_amp_off(u32 spk) -{ - if (spk & (TOP_AND_BOTTOM_SPK_AMP_POS | TOP_AND_BOTTOM_SPK_AMP_NEG)) { - - if (!mdm9615_ext_top_and_bottom_spk_pamp) - return; - - gpio_direction_output(top_and_bottom_spk_pamp_gpio, 0); - gpio_free(top_and_bottom_spk_pamp_gpio); - mdm9615_ext_top_and_bottom_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after turning off external Bottom" - " Speaker Ampl\n", __func__); - - usleep_range(4000, 4000); - - } else { - - pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void mdm9615_ext_control(struct snd_soc_codec *codec) -{ - struct snd_soc_dapm_context *dapm = &codec->dapm; - - pr_debug("%s: mdm9615_spk_control = %d", __func__, mdm9615_spk_control); - if (mdm9615_spk_control == MDM9615_SPK_ON) { - snd_soc_dapm_enable_pin(dapm, "Ext Spk Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Neg"); - } else { - snd_soc_dapm_disable_pin(dapm, "Ext Spk Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Neg"); - } - - snd_soc_dapm_sync(dapm); -} - -static int mdm9615_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: mdm9615_spk_control = %d", __func__, mdm9615_spk_control); - ucontrol->value.integer.value[0] = mdm9615_spk_control; - return 0; -} -static int mdm9615_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (mdm9615_spk_control == ucontrol->value.integer.value[0]) - return 0; - - mdm9615_spk_control = ucontrol->value.integer.value[0]; - mdm9615_ext_control(codec); - return 1; -} -static int mdm9615_spkramp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event)); - - if (SND_SOC_DAPM_EVENT_ON(event)) { - if (!strncmp(w->name, "Ext Spk Pos", 11)) - mdm9615_ext_spk_power_amp_on( - TOP_AND_BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Neg", 11)) - mdm9615_ext_spk_power_amp_on( - TOP_AND_BOTTOM_SPK_AMP_NEG); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - - } else { - if (!strncmp(w->name, "Ext Spk Pos", 11)) - mdm9615_ext_spk_power_amp_off( - TOP_AND_BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Neg", 11)) - mdm9615_ext_spk_power_amp_off( - TOP_AND_BOTTOM_SPK_AMP_NEG); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - } - return 0; -} -static int mdm9615_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm) -{ - pr_debug("%s: enable = %d\n", __func__, enable); - if (enable) { - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users != 1) - return 0; - if (IS_ERR(codec_clk)) { - - pr_err("%s: Error setting Tabla MCLK\n", __func__); - clk_users--; - return -EINVAL; - } - clk_set_rate(codec_clk, TABLA_EXT_CLK_RATE); - clk_prepare_enable(codec_clk); - tabla_mclk_enable(codec, 1, dapm); - } else { - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 0) - return 0; - clk_users--; - if (!clk_users) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - tabla_mclk_enable(codec, 0, dapm); - clk_disable_unprepare(codec_clk); - } - } - return 0; -} - -static int mdm9615_mclk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - pr_debug("%s: event = %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - return mdm9615_enable_codec_ext_clk(w->codec, 1, true); - case SND_SOC_DAPM_POST_PMD: - return mdm9615_enable_codec_ext_clk(w->codec, 0, true); - } - return 0; -} - -static const struct snd_soc_dapm_widget mdm9615_dapm_widgets[] = { - - SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, - mdm9615_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SPK("Ext Spk Pos", mdm9615_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Neg", mdm9615_spkramp_event), - - SND_SOC_DAPM_MIC("Handset Mic", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), - - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("Digital Mic2", NULL), - SND_SOC_DAPM_MIC("Digital Mic3", NULL), - SND_SOC_DAPM_MIC("Digital Mic4", NULL), - SND_SOC_DAPM_MIC("Digital Mic5", NULL), - SND_SOC_DAPM_MIC("Digital Mic6", NULL), - -}; - -static const struct snd_soc_dapm_route common_audio_map[] = { - - {"RX_BIAS", NULL, "MCLK"}, - {"LDO_H", NULL, "MCLK"}, - - /* Speaker path */ - {"Ext Spk Pos", NULL, "LINEOUT1"}, - {"Ext Spk Neg", NULL, "LINEOUT3"}, - - {"Ext Spk Pos", NULL, "LINEOUT2"}, - {"Ext Spk Neg", NULL, "LINEOUT4"}, - - /* Microphone path */ - {"AMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Handset Mic"}, - - {"AMIC2", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "Headset Mic"}, - - /** - * AMIC3 and AMIC4 inputs are connected to ANC microphones - * These mics are biased differently on CDP and FLUID - * routing entries below are based on bias arrangement - * on FLUID. - */ - {"AMIC3", NULL, "MIC BIAS3 Internal1"}, - {"MIC BIAS3 Internal1", NULL, "ANCRight Headset Mic"}, - - {"AMIC4", NULL, "MIC BIAS1 Internal2"}, - {"MIC BIAS1 Internal2", NULL, "ANCLeft Headset Mic"}, - - {"HEADPHONE", NULL, "LDO_H"}, - - /** - * The digital Mic routes are setup considering - * fluid as default device. - */ - - /** - * Digital Mic1. Front Bottom left Digital Mic on Fluid and MTP. - * Digital Mic GM5 on CDP mainboard. - * Conncted to DMIC2 Input on Tabla codec. - */ - {"DMIC2", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic1"}, - - /** - * Digital Mic2. Front Bottom right Digital Mic on Fluid and MTP. - * Digital Mic GM6 on CDP mainboard. - * Conncted to DMIC1 Input on Tabla codec. - */ - {"DMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic2"}, - - /** - * Digital Mic3. Back Bottom Digital Mic on Fluid. - * Digital Mic GM1 on CDP mainboard. - * Conncted to DMIC4 Input on Tabla codec. - */ - {"DMIC4", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic3"}, - - /** - * Digital Mic4. Back top Digital Mic on Fluid. - * Digital Mic GM2 on CDP mainboard. - * Conncted to DMIC3 Input on Tabla codec. - */ - {"DMIC3", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic4"}, - - /** - * Digital Mic5. Front top Digital Mic on Fluid. - * Digital Mic GM3 on CDP mainboard. - * Conncted to DMIC5 Input on Tabla codec. - */ - {"DMIC5", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic5"}, - - /* Tabla digital Mic6 - back bottom digital Mic on Liquid and - * bottom mic on CDP. FLUID/MTP do not have dmic6 installed. - */ - {"DMIC6", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic6"}, -}; - -static const char *spk_function[] = {"Off", "On"}; -static const char *slim0_rx_ch_text[] = {"One", "Two"}; -static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"}; - -static const struct soc_enum mdm9615_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text), - SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text), -}; - -static const char *btsco_rate_text[] = {"8000", "16000"}; -static const struct soc_enum mdm9615_btsco_enum[] = { - SOC_ENUM_SINGLE_EXT(2, btsco_rate_text), -}; - -static const char * const auxpcm_rate_text[] = {"rate_8000", "rate_16000"}; -static const struct soc_enum mdm9615_auxpcm_enum[] = { - SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text), -}; - -static int mdm9615_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: mdm9615_slim_0_rx_ch = %d\n", __func__, - mdm9615_slim_0_rx_ch); - ucontrol->value.integer.value[0] = mdm9615_slim_0_rx_ch - 1; - return 0; -} - -static int mdm9615_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mdm9615_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: mdm9615_slim_0_rx_ch = %d\n", __func__, - mdm9615_slim_0_rx_ch); - return 1; -} - -static int mdm9615_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: mdm9615_slim_0_tx_ch = %d\n", __func__, - mdm9615_slim_0_tx_ch); - ucontrol->value.integer.value[0] = mdm9615_slim_0_tx_ch - 1; - return 0; -} - -static int mdm9615_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mdm9615_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: mdm9615_slim_0_tx_ch = %d\n", __func__, - mdm9615_slim_0_tx_ch); - return 1; -} - -static int mdm9615_btsco_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: mdm9615_btsco_rate = %d", __func__, mdm9615_btsco_rate); - ucontrol->value.integer.value[0] = mdm9615_btsco_rate; - return 0; -} - -static int mdm9615_btsco_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 8000: - mdm9615_btsco_rate = SAMPLE_RATE_8KHZ; - break; - case 16000: - mdm9615_btsco_rate = SAMPLE_RATE_16KHZ; - break; - default: - mdm9615_btsco_rate = SAMPLE_RATE_8KHZ; - break; - } - pr_debug("%s: mdm9615_btsco_rate = %d\n", __func__, mdm9615_btsco_rate); - return 0; -} - -static int mdm9615_auxpcm_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: mdm9615_auxpcm_rate = %d", __func__, - mdm9615_auxpcm_rate); - ucontrol->value.integer.value[0] = mdm9615_auxpcm_rate; - return 0; -} - -static int mdm9615_auxpcm_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 0: - mdm9615_auxpcm_rate = SAMPLE_RATE_8KHZ; - break; - case 1: - mdm9615_auxpcm_rate = SAMPLE_RATE_16KHZ; - break; - default: - mdm9615_auxpcm_rate = SAMPLE_RATE_8KHZ; - break; - } - pr_debug("%s: mdm9615_auxpcm_rate = %d\n" - "ucontrol->value.integer.value[0] = %d\n", __func__, - mdm9615_auxpcm_rate, - (int)ucontrol->value.integer.value[0]); - return 0; -} - -static const struct snd_kcontrol_new tabla_mdm9615_controls[] = { - SOC_ENUM_EXT("Speaker Function", mdm9615_enum[0], mdm9615_get_spk, - mdm9615_set_spk), - SOC_ENUM_EXT("SLIM_0_RX Channels", mdm9615_enum[1], - mdm9615_slim_0_rx_ch_get, mdm9615_slim_0_rx_ch_put), - SOC_ENUM_EXT("SLIM_0_TX Channels", mdm9615_enum[2], - mdm9615_slim_0_tx_ch_get, mdm9615_slim_0_tx_ch_put), - SOC_ENUM_EXT("Internal BTSCO SampleRate", mdm9615_btsco_enum[0], - mdm9615_btsco_rate_get, mdm9615_btsco_rate_put), - SOC_ENUM_EXT("AUX PCM SampleRate", mdm9615_auxpcm_enum[0], - mdm9615_auxpcm_rate_get, mdm9615_auxpcm_rate_put), -}; - -static void *def_tabla_mbhc_cal(void) -{ - void *tabla_cal; - struct tabla_mbhc_btn_detect_cfg *btn_cfg; - u16 *btn_low, *btn_high; - u8 *n_ready, *n_cic, *gain; - - tabla_cal = kzalloc(TABLA_MBHC_CAL_SIZE(TABLA_MBHC_DEF_BUTTONS, - TABLA_MBHC_DEF_RLOADS), - GFP_KERNEL); - if (!tabla_cal) { - pr_err("%s: out of memory\n", __func__); - return NULL; - } - -#define S(X, Y) ((TABLA_MBHC_CAL_GENERAL_PTR(tabla_cal)->X) = (Y)) - S(t_ldoh, 100); - S(t_bg_fast_settle, 100); - S(t_shutdown_plug_rem, 255); - S(mbhc_nsa, 4); - S(mbhc_navg, 4); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_DET_PTR(tabla_cal)->X) = (Y)) - S(mic_current, TABLA_PID_MIC_5_UA); - S(hph_current, TABLA_PID_MIC_5_UA); - S(t_mic_pid, 100); - S(t_ins_complete, 250); - S(t_ins_retry, 200); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_TYPE_PTR(tabla_cal)->X) = (Y)) - S(v_no_mic, 30); - S(v_hs_max, 1550); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal)->X) = (Y)) - S(c[0], 62); - S(c[1], 124); - S(nc, 1); - S(n_meas, 3); - S(mbhc_nsc, 11); - S(n_btn_meas, 1); - S(n_btn_con, 2); - S(num_btn, TABLA_MBHC_DEF_BUTTONS); - S(v_btn_press_delta_sta, 100); - S(v_btn_press_delta_cic, 50); -#undef S - btn_cfg = TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal); - btn_low = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_LOW); - btn_high = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_HIGH); - btn_low[0] = -50; - btn_high[0] = 10; - btn_low[1] = 11; - btn_high[1] = 38; - btn_low[2] = 39; - btn_high[2] = 64; - btn_low[3] = 65; - btn_high[3] = 91; - btn_low[4] = 92; - btn_high[4] = 115; - btn_low[5] = 116; - btn_high[5] = 141; - btn_low[6] = 142; - btn_high[6] = 163; - btn_low[7] = 164; - btn_high[7] = 250; - n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY); - n_ready[0] = 48; - n_ready[1] = 38; - n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC); - n_cic[0] = 60; - n_cic[1] = 47; - gain = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_GAIN); - gain[0] = 11; - gain[1] = 9; - - return tabla_cal; -} - -static int msm9615_i2s_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm9615_i2s_spk_control == ucontrol->value.integer.value[0]) - return 0; - - msm9615_i2s_spk_control = ucontrol->value.integer.value[0]; - mdm9615_ext_control(codec); - return 1; -} - -static int mdm9615_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - - pr_debug("%s: ch=%d\n", __func__, - mdm9615_slim_0_rx_ch); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - mdm9615_slim_0_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } else { - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(cpu_dai, - mdm9615_slim_0_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } -end: - return ret; -} - -static int msm9615_i2s_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm9615_i2s_rx_ch = %d\n", __func__, - msm9615_i2s_rx_ch); - ucontrol->value.integer.value[0] = msm9615_i2s_rx_ch - 1; - return 0; -} - -static int msm9615_i2s_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm9615_i2s_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm9615_i2s_rx_ch = %d\n", __func__, - msm9615_i2s_rx_ch); - return 1; -} - -static int msm9615_i2s_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm9615_i2s_tx_ch = %d\n", __func__, - msm9615_i2s_tx_ch); - ucontrol->value.integer.value[0] = msm9615_i2s_tx_ch - 1; - return 0; -} - -static int msm9615_i2s_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm9615_i2s_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm9615_i2s_tx_ch = %d\n", __func__, - msm9615_i2s_tx_ch); - return 1; -} - -static int msm9615_i2s_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm9615_spk_control = %d", __func__, mdm9615_spk_control); - ucontrol->value.integer.value[0] = msm9615_i2s_spk_control; - return 0; -} - -static const struct snd_kcontrol_new tabla_msm9615_i2s_controls[] = { - SOC_ENUM_EXT("Speaker Function", mdm9615_enum[0], msm9615_i2s_get_spk, - msm9615_i2s_set_spk), - SOC_ENUM_EXT("PRI_RX Channels", mdm9615_enum[1], - msm9615_i2s_rx_ch_get, msm9615_i2s_rx_ch_put), - SOC_ENUM_EXT("PRI_TX Channels", mdm9615_enum[2], - msm9615_i2s_tx_ch_get, msm9615_i2s_tx_ch_put), - SOC_ENUM_EXT("SEC_RX Channels", mdm9615_enum[3], - msm9615_i2s_rx_ch_get, msm9615_i2s_rx_ch_put), - SOC_ENUM_EXT("SEC_TX Channels", mdm9615_enum[4], - msm9615_i2s_tx_ch_get, msm9615_i2s_tx_ch_put), -}; - -static int msm9615_i2s_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - snd_soc_dapm_new_controls(dapm, mdm9615_dapm_widgets, - ARRAY_SIZE(mdm9615_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, common_audio_map, - ARRAY_SIZE(common_audio_map)); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Neg"); - - snd_soc_dapm_sync(dapm); - - err = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_OC_HPHL| - SND_JACK_OC_HPHR), &hs_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - err = snd_soc_jack_new(codec, "Button Jack", - TABLA_JACK_BUTTON_MASK, &button_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - err = tabla_hs_detect(codec, &mbhc_cfg); - msm_gpiomux_install( - msm9615_audio_prim_i2s_codec_configs, - ARRAY_SIZE(msm9615_audio_prim_i2s_codec_configs)); - return err; -} - -static int msm9615_i2s_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - rate->min = rate->max = 48000; - channels->min = channels->max = msm9615_i2s_rx_ch; - - return 0; -} - -static int msm9615_i2s_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - rate->min = rate->max = 48000; - - channels->min = channels->max = msm9615_i2s_tx_ch; - - return 0; -} - -static int mdm9615_i2s_free_gpios(u8 i2s_intf, u8 i2s_dir) -{ - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - if (i2s_intf == MSM_INTF_PRIM) { - if (pintf->intf_status[i2s_intf][MSM_DIR_TX] == 0 && - pintf->intf_status[i2s_intf][MSM_DIR_RX] == 0) { - gpio_free(GPIO_PRIM_I2S_DIN); - gpio_free(GPIO_PRIM_I2S_DOUT); - gpio_free(GPIO_PRIM_I2S_SCK); - gpio_free(GPIO_PRIM_I2S_WS); - } - } else if (i2s_intf == MSM_INTF_SECN) { - if (pintf->intf_status[i2s_intf][MSM_DIR_TX] == 0 && - pintf->intf_status[i2s_intf][MSM_DIR_RX] == 0) { - gpio_free(GPIO_SEC_I2S_DOUT); - gpio_free(GPIO_SEC_I2S_WS); - gpio_free(GPIO_SEC_I2S_DIN); - gpio_free(GPIO_SEC_I2S_SCK); - } - } - return 0; -} - -static int msm9615_i2s_intf_dir_sel(const char *cpu_dai_name, - u8 *i2s_intf, u8 *i2s_dir) -{ - int ret = 0; - if (i2s_intf == NULL || i2s_dir == NULL || cpu_dai_name == NULL) { - ret = 1; - goto err; - } - if (!strncmp(cpu_dai_name, "msm-dai-q6.0", 12)) { - *i2s_intf = MSM_INTF_PRIM; - *i2s_dir = MSM_DIR_RX; - } else if (!strncmp(cpu_dai_name, "msm-dai-q6.1", 12)) { - *i2s_intf = MSM_INTF_PRIM; - *i2s_dir = MSM_DIR_TX; - } else if (!strncmp(cpu_dai_name, "msm-dai-q6.4", 12)) { - *i2s_intf = MSM_INTF_SECN; - *i2s_dir = MSM_DIR_RX; - } else if (!strncmp(cpu_dai_name, "msm-dai-q6.5", 12)) { - *i2s_intf = MSM_INTF_SECN; - *i2s_dir = MSM_DIR_TX; - } else { - pr_err("Error in I2S cpu dai name\n"); - ret = 1; - } -err: - return ret; -} - -static int msm9615_enable_i2s_gpio(u8 i2s_intf, u8 i2s_dir) -{ - u8 ret = 0; - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - - if (i2s_intf == MSM_INTF_PRIM) { - if (pintf->intf_status[i2s_intf][MSM_DIR_TX] == 0 && - pintf->intf_status[i2s_intf][MSM_DIR_RX] == 0) { - - ret = gpio_request(GPIO_PRIM_I2S_DOUT, - "I2S_PRIM_DOUT"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_PRIM_I2S_DOUT); - goto err; - } - - ret = gpio_request(GPIO_PRIM_I2S_DIN, "I2S_PRIM_DIN"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_PRIM_I2S_DIN); - goto err; - } - - ret = gpio_request(GPIO_PRIM_I2S_SCK, "I2S_PRIM_SCK"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_PRIM_I2S_SCK); - goto err; - } - - ret = gpio_request(GPIO_PRIM_I2S_WS, "I2S_PRIM_WS"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_PRIM_I2S_WS); - goto err; - } - } - } else if (i2s_intf == MSM_INTF_SECN) { - if (pintf->intf_status[i2s_intf][MSM_DIR_TX] == 0 && - pintf->intf_status[i2s_intf][MSM_DIR_RX] == 0) { - - ret = gpio_request(GPIO_SEC_I2S_DIN, "I2S_SEC_DIN"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_SEC_I2S_DIN); - goto err; - } - - ret = gpio_request(GPIO_SEC_I2S_DOUT, "I2S_SEC_DOUT"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_SEC_I2S_DOUT); - goto err; - } - - ret = gpio_request(GPIO_SEC_I2S_SCK, "I2S_SEC_SCK"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_SEC_I2S_SCK); - goto err; - } - - ret = gpio_request(GPIO_SEC_I2S_WS, "I2S_SEC_WS"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", - __func__, GPIO_SEC_I2S_WS); - goto err; - } - } - } -err: - return ret; -} - -static int msm9615_set_i2s_osr_bit_clk(struct snd_soc_dai *cpu_dai, - u8 i2s_intf, u8 i2s_dir, - enum msm9x15_set_i2s_clk enable) -{ - - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - struct msm_i2s_clk *pclk = &pintf->prim_clk; - struct msm_clk *clk_ctl = &pclk->rx_clk; - u8 ret = 0; - pr_debug("Dev name %s Intf =%d, Dir = %d, Enable=%d\n", - cpu_dai->name, i2s_intf, i2s_dir, enable); - if (i2s_intf == MSM_INTF_PRIM) - pclk = &pintf->prim_clk; - else if (i2s_intf == MSM_INTF_SECN) - pclk = &pintf->sec_clk; - - if (i2s_dir == MSM_DIR_TX) - clk_ctl = &pclk->tx_clk; - else if (i2s_dir == MSM_DIR_RX) - clk_ctl = &pclk->rx_clk; - - if (enable == MSM_I2S_CLK_SET_TRUE || - enable == MSM_I2S_CLK_SET_RATE0) { - if (clk_ctl->clk_enable != 0) { - pr_info("%s: I2S Clk is already enabled" - "clk users %d\n", __func__, - clk_ctl->clk_enable); - ret = 0; - goto err; - } - clk_ctl->osr_clk = clk_get(cpu_dai->dev, "osr_clk"); - if (IS_ERR(clk_ctl->osr_clk)) { - pr_err("%s: Fail to get OSR CLK\n", __func__); - ret = -EINVAL; - goto err; - } - ret = clk_prepare(clk_ctl->osr_clk); - if (ret != 0) { - pr_err("Unable to prepare i2s_spkr_osr_clk\n"); - goto err; - } - clk_set_rate(clk_ctl->osr_clk, TABLA_EXT_CLK_RATE); - ret = clk_enable(clk_ctl->osr_clk); - if (ret != 0) { - pr_err("Fail to enable i2s_spkr_osr_clk\n"); - clk_unprepare(clk_ctl->osr_clk); - goto err; - } - clk_ctl->bit_clk = clk_get(cpu_dai->dev, "bit_clk"); - if (IS_ERR(clk_ctl->bit_clk)) { - pr_err("Fail to get i2s_spkr_bit_clk\n"); - clk_disable(clk_ctl->osr_clk); - clk_unprepare(clk_ctl->osr_clk); - clk_put(clk_ctl->osr_clk); - ret = -EINVAL; - goto err; - } - ret = clk_prepare(clk_ctl->bit_clk); - if (ret != 0) { - clk_disable(clk_ctl->osr_clk); - clk_unprepare(clk_ctl->osr_clk); - clk_put(clk_ctl->osr_clk); - pr_err("Fail to prepare i2s_spkr_osr_clk\n"); - goto err; - } - if (enable == MSM_I2S_CLK_SET_RATE0) - clk_set_rate(clk_ctl->bit_clk, 0); - else - clk_set_rate(clk_ctl->bit_clk, 8); - ret = clk_enable(clk_ctl->bit_clk); - if (ret != 0) { - clk_disable(clk_ctl->osr_clk); - clk_unprepare(clk_ctl->osr_clk); - clk_put(clk_ctl->osr_clk); - clk_unprepare(clk_ctl->bit_clk); - pr_err("Unable to enable i2s_spkr_osr_clk\n"); - goto err; - } - clk_ctl->clk_enable++; - } else if (enable == MSM_I2S_CLK_SET_FALSE && - clk_ctl->clk_enable != 0) { - clk_disable(clk_ctl->osr_clk); - clk_disable(clk_ctl->bit_clk); - clk_unprepare(clk_ctl->osr_clk); - clk_unprepare(clk_ctl->bit_clk); - clk_put(clk_ctl->bit_clk); - clk_put(clk_ctl->osr_clk); - clk_ctl->bit_clk = NULL; - clk_ctl->osr_clk = NULL; - clk_ctl->clk_enable--; - ret = 0; - } -err: - return ret; -} - -static void msm9615_config_i2s_sif_mux(u8 value, u8 i2s_intf) -{ - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - u32 sif_shadow = 0x0000; - - pr_debug("%s() Value = 0x%x intf = 0x%x\n", __func__, value, i2s_intf); - if (i2s_intf == MSM_INTF_PRIM) { - sif_shadow = (sif_shadow & LPASS_SIF_MUX_CTL_PRI_MUX_SEL_BMSK) | - (value << LPASS_SIF_MUX_CTL_PRI_MUX_SEL_SHFT); - pr_debug("%s() Sif shadow = 0x%x\n", __func__, sif_shadow); - sif_reg_value = - ((sif_reg_value & LPASS_SIF_MUX_CTL_SEC_MUX_SEL_BMSK) | - sif_shadow); - } - if (i2s_intf == MSM_INTF_SECN) { - sif_shadow = (sif_shadow & LPASS_SIF_MUX_CTL_SEC_MUX_SEL_BMSK) | - (value << LPASS_SIF_MUX_CTL_SEC_MUX_SEL_SHFT); - pr_debug("%s() Sif shadow = 0x%x\n", __func__, sif_shadow); - sif_reg_value = - ((sif_reg_value & LPASS_SIF_MUX_CTL_PRI_MUX_SEL_BMSK) | - sif_shadow); - } - if (pintf->sif_virt_addr != NULL) - iowrite32(sif_reg_value, pintf->sif_virt_addr); - /* Dont read SIF register. Device crashes. */ - pr_debug("%s() SIF Reg = 0x%x\n", __func__, sif_reg_value); -} - -static void msm9615_config_i2s_spare_mux(u8 value, u8 i2s_intf) -{ - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - u32 spare_shadow = 0x0000; - - pr_debug("%s() Value = 0x%x intf = 0x%x\n", __func__, value, i2s_intf); - if (i2s_intf == MSM_INTF_PRIM) { - /* Configure Primary SIF */ - spare_shadow = - (spare_shadow & LPAIF_SPARE_MUX_CTL_PRI_MUX_SEL_BMSK) | - (value << LPAIF_SPARE_MUX_CTL_PRI_MUX_SEL_SHFT); - pr_debug("%s() Spare shadow = 0x%x\n", __func__, spare_shadow); - spare_reg_value = - ((spare_shadow & LPAIF_SPARE_MUX_CTL_SEC_MUX_SEL_BMSK) | - spare_shadow); - } - if (i2s_intf == MSM_INTF_SECN) { - /*Secondary interface configuration*/ - spare_shadow = - (spare_shadow & LPAIF_SPARE_MUX_CTL_SEC_MUX_SEL_BMSK) | - (value << LPAIF_SPARE_MUX_CTL_SEC_MUX_SEL_SHFT); - pr_debug("%s() Spare shadow = 0x%x\n", __func__, spare_shadow); - spare_reg_value = - ((spare_shadow & LPAIF_SPARE_MUX_CTL_PRI_MUX_SEL_BMSK) | - spare_shadow); - } - if (pintf->spare_virt_addr != NULL) - iowrite32(spare_reg_value, pintf->spare_virt_addr); - /* Dont read SPARE register. Device crashes. */ - pr_debug("%s( ): SPARE Reg =0x%x\n", __func__, spare_reg_value); -} - -static int msm9615_i2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - int rate = params_rate(params); - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - struct msm_i2s_clk *pclk = &pintf->prim_clk; - struct msm_clk *clk_ctl = &pclk->rx_clk; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int bit_clk_set = 0; - u8 i2s_intf, i2s_dir; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (!msm9615_i2s_intf_dir_sel(cpu_dai->name, - &i2s_intf, &i2s_dir)) { - bit_clk_set = TABLA_EXT_CLK_RATE / - (rate * 2 * NO_OF_BITS_PER_SAMPLE); - if (bit_clk_set != 8) { - if (i2s_intf == MSM_INTF_PRIM) - pclk = &pintf->prim_clk; - else if (i2s_intf == MSM_INTF_SECN) - pclk = &pintf->sec_clk; - clk_ctl = &pclk->rx_clk; - pr_debug("%s( ): New rate = %d", - __func__, bit_clk_set); - clk_set_rate(clk_ctl->bit_clk, bit_clk_set); - } - } - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - bit_clk_set = I2S_MIC_SCLK_RATE / (rate * 2 * - NO_OF_BITS_PER_SAMPLE); - /* Not required to modify TX rate. - * Speaker clock are looped back - * to Mic. - */ - } - return 1; -} - -static int msm9615_i2s_startup(struct snd_pcm_substream *substream) -{ - u8 ret = 0; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - u8 i2s_intf, i2s_dir; - if (!msm9615_i2s_intf_dir_sel(cpu_dai->name, &i2s_intf, &i2s_dir)) { - pr_debug("%s( ): cpu name = %s intf =%d dir = %d\n", - __func__, cpu_dai->name, i2s_intf, i2s_dir); - pr_debug("%s( ): Enable status Rx =%d Tx = %d\n", __func__, - pintf->intf_status[i2s_intf][MSM_DIR_RX], - pintf->intf_status[i2s_intf][MSM_DIR_TX]); - msm9615_enable_i2s_gpio(i2s_intf, i2s_dir); - if (i2s_dir == MSM_DIR_TX) { - if (pintf->intf_status[i2s_intf][MSM_DIR_RX] > 0) { - /* This means that Rx is enabled before */ - ret = msm9615_set_i2s_osr_bit_clk(cpu_dai, - i2s_intf, i2s_dir, - MSM_I2S_CLK_SET_RATE0); - if (ret != 0) { - pr_err("%s: Fail enable I2S clock\n", - __func__); - return -EINVAL; - } - msm9615_config_i2s_sif_mux( - pintf->mux_ctl[MSM_DIR_BOTH].sifconfig, - i2s_intf); - msm9615_config_i2s_spare_mux( - pintf->mux_ctl[MSM_DIR_BOTH].spareconfig, - i2s_intf); - ret = snd_soc_dai_set_fmt(cpu_dai, - SND_SOC_DAIFMT_CBM_CFM); - if (ret < 0) - pr_err("set fmt cpu dai failed\n"); - ret = snd_soc_dai_set_fmt(codec_dai, - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set fmt codec dai failed\n"); - } else if (pintf->intf_status[i2s_intf][i2s_dir] == 0) { - /* This means that Rx is - * not enabled before. - * only Tx will be used. - */ - ret = msm9615_set_i2s_osr_bit_clk(cpu_dai, - i2s_intf, i2s_dir, - MSM_I2S_CLK_SET_TRUE); - if (ret != 0) { - pr_err("%s: Fail Tx I2S clock\n", - __func__); - return -EINVAL; - } - msm9615_config_i2s_sif_mux( - pintf->mux_ctl[MSM_DIR_TX].sifconfig, - i2s_intf); - msm9615_config_i2s_spare_mux( - pintf->mux_ctl[MSM_DIR_TX].spareconfig, - i2s_intf); - ret = snd_soc_dai_set_fmt(cpu_dai, - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set fmt cpu dai failed\n"); - ret = snd_soc_dai_set_fmt(codec_dai, - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set fmt codec dai failed\n"); - } - } else if (i2s_dir == MSM_DIR_RX) { - if (pintf->intf_status[i2s_intf][MSM_DIR_TX] > 0) { - pr_err("%s: Error shutdown Tx first\n", - __func__); - return -EINVAL; - } else if (pintf->intf_status[i2s_intf][i2s_dir] - == 0) { - ret = msm9615_set_i2s_osr_bit_clk(cpu_dai, - i2s_intf, i2s_dir, - MSM_I2S_CLK_SET_TRUE); - if (ret != 0) { - pr_err("%s: Fail Rx I2S clock\n", - __func__); - return -EINVAL; - } - msm9615_config_i2s_sif_mux( - pintf->mux_ctl[MSM_DIR_RX].sifconfig, - i2s_intf); - msm9615_config_i2s_spare_mux( - pintf->mux_ctl[MSM_DIR_RX].spareconfig, - i2s_intf); - ret = snd_soc_dai_set_fmt(cpu_dai, - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set fmt cpu dai failed\n"); - ret = snd_soc_dai_set_fmt(codec_dai, - SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set fmt codec dai failed\n"); - } - } - pintf->intf_status[i2s_intf][i2s_dir]++; - } else { - pr_err("%s: Err in i2s_intf_dir_sel\n", __func__); - return -EINVAL; - } - pr_debug("Exit %s() Enable status Rx =%d Tx = %d\n", __func__, - pintf->intf_status[i2s_intf][MSM_DIR_RX], - pintf->intf_status[i2s_intf][MSM_DIR_TX]); - return ret; -} - -static void msm9615_i2s_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct msm_i2s_ctl *pintf = &msm9x15_i2s_ctl; - u8 i2s_intf = 0, i2s_dir = 0, ret = 0; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - pr_debug("%s( ): Enable status Rx =%d Tx = %d\n", - __func__, pintf->intf_status[i2s_intf][MSM_DIR_RX], - pintf->intf_status[i2s_intf][MSM_DIR_TX]); - if (!msm9615_i2s_intf_dir_sel(cpu_dai->name, &i2s_intf, &i2s_dir)) { - pr_debug("%s( ): intf =%d dir = %d\n", __func__, - i2s_intf, i2s_dir); - if (i2s_dir == MSM_DIR_RX) - if (pintf->intf_status[i2s_intf][MSM_DIR_TX] > 0) - pr_err("%s: Shutdown Tx First then by RX\n", - __func__); - ret = msm9615_set_i2s_osr_bit_clk(cpu_dai, i2s_intf, i2s_dir, - MSM_I2S_CLK_SET_FALSE); - if (ret != 0) - pr_err("%s: Cannot disable I2S clock\n", - __func__); - pintf->intf_status[i2s_intf][i2s_dir]--; - mdm9615_i2s_free_gpios(i2s_intf, i2s_dir); - } - pr_debug("%s( ): Enable status Rx =%d Tx = %d\n", __func__, - pintf->intf_status[i2s_intf][MSM_DIR_RX], - pintf->intf_status[i2s_intf][MSM_DIR_TX]); -} - -void msm9615_config_port_select(void) -{ - iowrite32(SEC_PCM_PORT_SLC_VALUE, secpcm_portslc_virt_addr); - pr_debug("%s() port select after updating = 0x%x\n", - __func__, ioread32(secpcm_portslc_virt_addr)); -} -static void mdm9615_install_codec_i2s_gpio(struct snd_pcm_substream *substream) -{ - u8 i2s_intf, i2s_dir; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - if (!msm9615_i2s_intf_dir_sel(cpu_dai->name, &i2s_intf, &i2s_dir)) { - pr_debug("%s( ): cpu name = %s intf =%d dir = %d\n", - __func__, cpu_dai->name, i2s_intf, i2s_dir); - if (i2s_intf == MSM_INTF_PRIM) { - msm_gpiomux_install( - msm9615_audio_prim_i2s_codec_configs, - ARRAY_SIZE(msm9615_audio_prim_i2s_codec_configs)); - } else if (i2s_intf == MSM_INTF_SECN) { - msm_gpiomux_install(msm9615_audio_sec_i2s_codec_configs, - ARRAY_SIZE(msm9615_audio_sec_i2s_codec_configs)); - msm9615_config_port_select(); - - } - } -} - -static int msm9615_i2s_prepare(struct snd_pcm_substream *substream) -{ - u8 ret = 0; - - if (wcd9xxx_get_intf_type() < 0) - ret = -ENODEV; - else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) - mdm9615_install_codec_i2s_gpio(substream); - - return ret; -} - -static struct snd_soc_ops msm9615_i2s_be_ops = { - .startup = msm9615_i2s_startup, - .shutdown = msm9615_i2s_shutdown, - .hw_params = msm9615_i2s_hw_params, - .prepare = msm9615_i2s_prepare, -}; - -static int mdm9615_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct pm_gpio jack_gpio_cfg = { - .direction = PM_GPIO_DIR_IN, - .pull = PM_GPIO_PULL_NO, - .function = PM_GPIO_FUNC_NORMAL, - .vin_sel = 2, - .inv_int_pol = 0, - }; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - - /* Tabla SLIMBUS configuration - * RX1, RX2, RX3, RX4, RX5, RX6, RX7 - * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10 - */ - unsigned int rx_ch[TABLA_RX_MAX] = {138, 139, 140, 141, 142, 143, 144}; - unsigned int tx_ch[TABLA_TX_MAX] = {128, 129, 130, 131, 132, 133, 134, - 135, 136, 137}; - - pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); - - rtd->pmdown_time = 0; - - snd_soc_dapm_new_controls(dapm, mdm9615_dapm_widgets, - ARRAY_SIZE(mdm9615_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, common_audio_map, - ARRAY_SIZE(common_audio_map)); - - snd_soc_dapm_enable_pin(dapm, "Ext Spk Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Neg"); - - snd_soc_dapm_sync(dapm); - - err = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_OC_HPHL | - SND_JACK_OC_HPHR), - &hs_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - err = snd_soc_jack_new(codec, "Button Jack", - TABLA_JACK_BUTTON_MASK, &button_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - - if (hs_detect_use_gpio) { - pr_debug("%s: GPIO Headset detection enabled\n", __func__); - mbhc_cfg.gpio = PM8018_GPIO_PM_TO_SYS(JACK_DETECT_GPIO); - mbhc_cfg.gpio_irq = JACK_DETECT_INT; - } - - if (mbhc_cfg.gpio) { - err = pm8xxx_gpio_config(mbhc_cfg.gpio, &jack_gpio_cfg); - if (err) { - pr_err("%s: pm8xxx_gpio_config JACK_DETECT failed %d\n", - __func__, err); - return err; - } - } - - mbhc_cfg.read_fw_bin = hs_detect_use_firmware; - - err = tabla_hs_detect(codec, &mbhc_cfg); - - snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), - tx_ch, ARRAY_SIZE(rx_ch), rx_ch); - - - return err; -} - -static int mdm9615_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = mdm9615_slim_0_rx_ch; - - return 0; -} - -static int mdm9615_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = mdm9615_slim_0_tx_ch; - - return 0; -} - -static int mdm9615_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = mdm9615_btsco_rate; - channels->min = channels->max = mdm9615_btsco_ch; - - return 0; -} -static int mdm9615_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = mdm9615_auxpcm_rate; - /* PCM only supports mono output */ - channels->min = channels->max = 1; - - return 0; -} - -static int mdm9615_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int mdm9615_aux_pcm_get_gpios(void) -{ - int ret = 0; - - pr_debug("%s\n", __func__); - - ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", - __func__, GPIO_AUX_PCM_DOUT); - goto fail_dout; - } - - ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", - __func__, GPIO_AUX_PCM_DIN); - goto fail_din; - } - - ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", - __func__, GPIO_AUX_PCM_SYNC); - goto fail_sync; - } - ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", - __func__, GPIO_AUX_PCM_CLK); - goto fail_clk; - } - - return 0; - -fail_clk: - gpio_free(GPIO_AUX_PCM_SYNC); -fail_sync: - gpio_free(GPIO_AUX_PCM_DIN); -fail_din: - gpio_free(GPIO_AUX_PCM_DOUT); -fail_dout: - - return ret; -} - -static int mdm9615_aux_pcm_free_gpios(void) -{ - gpio_free(GPIO_AUX_PCM_DIN); - gpio_free(GPIO_AUX_PCM_DOUT); - gpio_free(GPIO_AUX_PCM_SYNC); - gpio_free(GPIO_AUX_PCM_CLK); - - return 0; -} - -static int mdm9615_sec_aux_pcm_get_gpios(void) -{ - int ret = 0; - - pr_debug("%s\n", __func__); - - ret = gpio_request(GPIO_SEC_AUX_PCM_DOUT, "SEC_AUX PCM DOUT"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): SEC_AUX PCM DOUT", - __func__, GPIO_SEC_AUX_PCM_DOUT); - goto fail_dout; - } - - ret = gpio_request(GPIO_SEC_AUX_PCM_DIN, "SEC_AUX PCM DIN"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): SEC_AUX PCM DIN", - __func__, GPIO_SEC_AUX_PCM_DIN); - goto fail_din; - } - - ret = gpio_request(GPIO_SEC_AUX_PCM_SYNC, "SEC_AUX PCM SYNC"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): SEC_AUX PCM SYNC", - __func__, GPIO_SEC_AUX_PCM_SYNC); - goto fail_sync; - } - - ret = gpio_request(GPIO_SEC_AUX_PCM_CLK, "SEC_AUX PCM CLK"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): SEC_AUX PCM CLK", - __func__, GPIO_SEC_AUX_PCM_CLK); - goto fail_clk; - } - - return 0; - -fail_clk: - gpio_free(GPIO_SEC_AUX_PCM_SYNC); -fail_sync: - gpio_free(GPIO_SEC_AUX_PCM_DIN); -fail_din: - gpio_free(GPIO_SEC_AUX_PCM_DOUT); -fail_dout: - - return ret; -} - -static int mdm9615_sec_aux_pcm_free_gpios(void) -{ - gpio_free(GPIO_SEC_AUX_PCM_DIN); - gpio_free(GPIO_SEC_AUX_PCM_DOUT); - gpio_free(GPIO_SEC_AUX_PCM_SYNC); - gpio_free(GPIO_SEC_AUX_PCM_CLK); - - return 0; -} - -static int mdm9615_startup(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - return 0; -} - -void msm9615_config_sif_mux(u8 value) -{ - u32 sif_shadow = 0x00000; - - sif_shadow = (sif_shadow & LPASS_SIF_MUX_CTL_SEC_MUX_SEL_BMSK) | - (value << LPASS_SIF_MUX_CTL_SEC_MUX_SEL_SHFT); - iowrite32(sif_shadow, sif_virt_addr); - /* Dont read SIF register. Device crashes. */ - pr_debug("%s() SIF Reg = 0x%x\n", __func__, sif_shadow); -} - -static int mdm9615_auxpcm_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - - pr_debug("%s(): substream = %s\n", __func__, substream->name); - if (atomic_inc_return(&msm9615_auxpcm_ref) == 1) { - ret = mdm9615_aux_pcm_get_gpios(); - if (ret < 0) { - pr_err("%s: Aux PCM GPIO request failed\n", __func__); - return -EINVAL; - } - } - return 0; -} - -static void mdm9615_auxpcm_shutdown(struct snd_pcm_substream *substream) -{ - - pr_debug("%s(): substream = %s\n", __func__, substream->name); - if (atomic_dec_return(&msm9615_auxpcm_ref) == 0) - mdm9615_aux_pcm_free_gpios(); -} - -static int mdm9615_sec_auxpcm_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - - pr_debug("%s(): substream = %s\n", __func__, substream->name); - if (atomic_inc_return(&msm9615_sec_auxpcm_ref) == 1) { - ret = mdm9615_sec_aux_pcm_get_gpios(); - if (ret < 0) { - pr_err("%s: SEC Aux PCM GPIO request failed\n", - __func__); - return -EINVAL; - } - msm9615_config_sif_mux(MSM_SIF_FUNC_PCM); - msm9615_config_port_select(); - } - return 0; -} - -static void mdm9615_sec_auxpcm_shutdown(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s\n", __func__, substream->name); - if (atomic_dec_return(&msm9615_sec_auxpcm_ref) == 0) - mdm9615_sec_aux_pcm_free_gpios(); -} - -static void mdm9615_shutdown(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); -} - -static struct snd_soc_ops mdm9615_be_ops = { - .startup = mdm9615_startup, - .hw_params = mdm9615_hw_params, - .shutdown = mdm9615_shutdown, -}; - -static struct snd_soc_ops mdm9615_auxpcm_be_ops = { - .startup = mdm9615_auxpcm_startup, - .shutdown = mdm9615_auxpcm_shutdown, -}; - -static struct snd_soc_ops mdm9615_sec_auxpcm_be_ops = { - .startup = mdm9615_sec_auxpcm_startup, - .shutdown = mdm9615_sec_auxpcm_shutdown, -}; - - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link mdm9615_dai_common[] = { - /* FrontEnd DAI Links */ - { - .name = "MDM9615 Media1", - .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MDM9615 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - { - .name = "Circuit-Switch Voice", - .stream_name = "CS-Voice", - .cpu_dai_name = "CS-VOICE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .be_id = MSM_FRONTEND_DAI_CS_VOICE, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - }, - { - .name = "MSM VoIP", - .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .be_id = MSM_FRONTEND_DAI_VOIP, - }, - /* Hostless PMC purpose */ - { - .name = "SLIMBUS_0 Hostless", - .stream_name = "SLIMBUS_0 Hostless", - .cpu_dai_name = "SLIMBUS0_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - /* .be_id = do not care */ - }, - { - .name = "MSM AFE-PCM RX", - .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "MSM AFE-PCM TX", - .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "AUXPCM Hostless", - .stream_name = "AUXPCM Hostless", - .cpu_dai_name = "AUXPCM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - }, - { - .name = "VoLTE", - .stream_name = "VoLTE", - .cpu_dai_name = "VoLTE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .be_id = MSM_FRONTEND_DAI_VOLTE, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - }, - { - .name = "DTMF RX Hostless", - .stream_name = "DTMF RX Hostless", - .cpu_dai_name = "DTMF_RX_HOSTLESS", - .platform_name = "msm-pcm-dtmf", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .be_id = MSM_FRONTEND_DAI_DTMF_RX, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - }, - { - .name = "DTMF TX", - .stream_name = "DTMF TX", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-dtmf", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .ignore_suspend = 1, - }, - { - .name = "CS-VOICE HOST RX CAPTURE", - .stream_name = "CS-VOICE HOST RX CAPTURE", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-host-pcm-voice", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .ignore_suspend = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - }, - { - .name = "CS-VOICE HOST RX PLAYBACK", - .stream_name = "CS-VOICE HOST RX PLAYBACK", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-host-pcm-voice", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .ignore_suspend = 1, - }, - { - .name = "CS-VOICE HOST TX CAPTURE", - .stream_name = "CS-VOICE HOST TX CAPTURE", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-host-pcm-voice", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .ignore_suspend = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - }, - { - .name = "CS-VOICE HOST TX PLAYBACK", - .stream_name = "CS-VOICE HOST TX PLAYBACK", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-host-pcm-voice", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .ignore_suspend = 1, - }, - - /* Backend BT DAI Links */ - { - .name = LPASS_BE_INT_BT_SCO_RX, - .stream_name = "Internal BT-SCO Playback", - .cpu_dai_name = "msm-dai-q6.12288", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX, - .be_hw_params_fixup = mdm9615_btsco_be_hw_params_fixup, - }, - { - .name = LPASS_BE_INT_BT_SCO_TX, - .stream_name = "Internal BT-SCO Capture", - .cpu_dai_name = "msm-dai-q6.12289", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX, - .be_hw_params_fixup = mdm9615_btsco_be_hw_params_fixup, - }, - - /* Backend AFE DAI Links */ - { - .name = LPASS_BE_AFE_PCM_RX, - .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, - }, - { - .name = LPASS_BE_AFE_PCM_TX, - .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, - }, - /* AUX PCM Backend DAI Links */ - { - .name = LPASS_BE_AUXPCM_RX, - .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_RX, - .be_hw_params_fixup = mdm9615_auxpcm_be_params_fixup, - .ops = &mdm9615_auxpcm_be_ops, - }, - { - .name = LPASS_BE_AUXPCM_TX, - .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_TX, - .be_hw_params_fixup = mdm9615_auxpcm_be_params_fixup, - .ops = &mdm9615_auxpcm_be_ops, - }, - - /* SECONDARY AUX PCM Backend DAI Links */ - { - .name = LPASS_BE_SEC_AUXPCM_RX, - .stream_name = "SEC AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6.12", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_RX, - .be_hw_params_fixup = mdm9615_auxpcm_be_params_fixup, - .ops = &mdm9615_sec_auxpcm_be_ops, - }, - { - .name = LPASS_BE_SEC_AUXPCM_TX, - .stream_name = "SEC AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6.13", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_TX, - .be_hw_params_fixup = mdm9615_auxpcm_be_params_fixup, - .ops = &mdm9615_sec_auxpcm_be_ops, - }, - /* Incall Music BACK END DAI Link */ - { - .name = LPASS_BE_VOICE_PLAYBACK_TX, - .stream_name = "Voice Farend Playback", - .cpu_dai_name = "msm-dai-q6.32773", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, - .be_hw_params_fixup = mdm9615_be_hw_params_fixup, - }, - /* Incall Record Uplink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_TX, - .stream_name = "Voice Uplink Capture", - .cpu_dai_name = "msm-dai-q6.32772", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX, - .be_hw_params_fixup = mdm9615_be_hw_params_fixup, - }, - /* Incall Record Downlink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_RX, - .stream_name = "Voice Downlink Capture", - .cpu_dai_name = "msm-dai-q6.32771", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX, - .be_hw_params_fixup = mdm9615_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - }, -}; - -static struct snd_soc_dai_link mdm9615_dai_i2s_tabla[] = { - /* Backend I2S DAI Links */ - { - .name = LPASS_BE_PRI_I2S_RX, - .stream_name = "Primary I2S Playback", - .cpu_dai_name = "msm-dai-q6.0", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_i2s_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_PRI_I2S_RX, - .init = &msm9615_i2s_audrx_init, - .be_hw_params_fixup = msm9615_i2s_rx_be_hw_params_fixup, - .ops = &msm9615_i2s_be_ops, - }, - { - .name = LPASS_BE_PRI_I2S_TX, - .stream_name = "Primary I2S Capture", - .cpu_dai_name = "msm-dai-q6.1", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_i2s_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_PRI_I2S_TX, - .be_hw_params_fixup = msm9615_i2s_tx_be_hw_params_fixup, - .ops = &msm9615_i2s_be_ops, - }, - { - .name = LPASS_BE_SEC_I2S_RX, - .stream_name = "Secondary I2S Playback", - .cpu_dai_name = "msm-dai-q6.4", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SEC_I2S_RX, - .be_hw_params_fixup = msm9615_i2s_rx_be_hw_params_fixup, - .ops = &msm9615_i2s_be_ops, - }, - { - .name = LPASS_BE_SEC_I2S_TX, - .stream_name = "Secondary I2S Capture", - .cpu_dai_name = "msm-dai-q6.5", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SEC_I2S_TX, - .be_hw_params_fixup = msm9615_i2s_tx_be_hw_params_fixup, - .ops = &msm9615_i2s_be_ops, - }, -}; - -static struct snd_soc_dai_link mdm9615_dai_slimbus_tabla[] = { - /* Backend SlimBus DAI Links */ - { - .name = LPASS_BE_SLIMBUS_0_RX, - .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX, - .init = &mdm9615_audrx_init, - .be_hw_params_fixup = mdm9615_slim_0_rx_be_hw_params_fixup, - .ops = &mdm9615_be_ops, - }, - { - .name = LPASS_BE_SLIMBUS_0_TX, - .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX, - .be_hw_params_fixup = mdm9615_slim_0_tx_be_hw_params_fixup, - .ops = &mdm9615_be_ops, - }, -}; - -static struct snd_soc_dai_link mdm9615_i2s_dai[ - ARRAY_SIZE(mdm9615_dai_common) + - ARRAY_SIZE(mdm9615_dai_i2s_tabla)]; - -static struct snd_soc_dai_link mdm9615_slimbus_dai[ - ARRAY_SIZE(mdm9615_dai_common) + - ARRAY_SIZE(mdm9615_dai_slimbus_tabla)]; - - -static struct snd_soc_card snd_soc_card_mdm9615[] = { - [0] = { - .name = "mdm9615-tabla-snd-card", - .controls = tabla_mdm9615_controls, - .num_controls = ARRAY_SIZE(tabla_mdm9615_controls), - }, - [1] = { - .name = "mdm9615-tabla-snd-card-i2s", - .controls = tabla_msm9615_i2s_controls, - .num_controls = ARRAY_SIZE(tabla_msm9615_i2s_controls), - }, -}; - -static int __init mdm9615_audio_init(void) -{ - int ret; - - /* Set GPIO headset detection by default */ - hs_detect_use_gpio = true; - - if (!cpu_is_msm9615()) { - pr_err("%s: Not the right machine type\n", __func__); - return -ENODEV ; - } - - mbhc_cfg.calibration = def_tabla_mbhc_cal(); - if (!mbhc_cfg.calibration) { - pr_err("Calibration data allocation failed\n"); - return -ENOMEM; - } - mdm9615_snd_device_slim = platform_device_alloc("soc-audio", 0); - if (!mdm9615_snd_device_slim) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - - /* Install SLIM specific links */ - memcpy(mdm9615_slimbus_dai, mdm9615_dai_common, - sizeof(mdm9615_dai_common)); - memcpy(mdm9615_slimbus_dai + ARRAY_SIZE(mdm9615_dai_common), - mdm9615_dai_slimbus_tabla, - sizeof(mdm9615_dai_slimbus_tabla)); - snd_soc_card_mdm9615[0].dai_link = mdm9615_slimbus_dai; - snd_soc_card_mdm9615[0].num_links = - ARRAY_SIZE(mdm9615_slimbus_dai); - - mdm9615_snd_device_i2s = platform_device_alloc("soc-audio", 1); - if (!mdm9615_snd_device_i2s) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - pr_err("%s: Interface Type = %d\n", __func__, - wcd9xxx_get_intf_type()); - - /* Install I2S specific links */ - memcpy(mdm9615_i2s_dai, mdm9615_dai_common, - sizeof(mdm9615_dai_common)); - memcpy(mdm9615_i2s_dai + ARRAY_SIZE(mdm9615_dai_common), - mdm9615_dai_i2s_tabla, - sizeof(mdm9615_dai_i2s_tabla)); - snd_soc_card_mdm9615[1].dai_link = mdm9615_i2s_dai; - snd_soc_card_mdm9615[1].num_links = - ARRAY_SIZE(mdm9615_i2s_dai); - platform_set_drvdata(mdm9615_snd_device_slim, &snd_soc_card_mdm9615[0]); - ret = platform_device_add(mdm9615_snd_device_slim); - if (ret) { - pr_err("%s Slim platform_device_add fail\n", __func__); - platform_device_put(mdm9615_snd_device_slim); - kfree(mbhc_cfg.calibration); - return ret; - } - platform_set_drvdata(mdm9615_snd_device_i2s, &snd_soc_card_mdm9615[1]); - ret = platform_device_add(mdm9615_snd_device_i2s); - if (ret) { - pr_err("%s I2S platform_device_add fail\n", __func__); - platform_device_put(mdm9615_snd_device_i2s); - kfree(mbhc_cfg.calibration); - return ret; - } - - /* - * Irrespective of audio interface type get virtual address - * of LPAIF registers as it may not be guaranted that I2S - * will probed successfully in Init. - */ - atomic_set(&msm9615_auxpcm_ref, 0); - atomic_set(&msm9615_sec_auxpcm_ref, 0); - msm9x15_i2s_ctl.sif_virt_addr = ioremap(LPASS_SIF_MUX_ADDR, 4); - msm9x15_i2s_ctl.spare_virt_addr = ioremap(LPAIF_SPARE_ADDR, 4); - if (msm9x15_i2s_ctl.spare_virt_addr == NULL || - msm9x15_i2s_ctl.sif_virt_addr == NULL) - pr_err("%s: SIF or Spare ptr are NULL", __func__); - sif_virt_addr = ioremap(LPASS_SIF_MUX_ADDR, 4); - secpcm_portslc_virt_addr = ioremap(SEC_PCM_PORT_SLC_ADDR, 4); - - return ret; -} -module_init(mdm9615_audio_init); - -static void __exit mdm9615_audio_exit(void) -{ - if (!cpu_is_msm9615()) { - pr_err("%s: Not the right machine type\n", __func__); - return ; - } - platform_device_unregister(mdm9615_snd_device_slim); - platform_device_unregister(mdm9615_snd_device_i2s); - kfree(mbhc_cfg.calibration); - iounmap(msm9x15_i2s_ctl.sif_virt_addr); - iounmap(msm9x15_i2s_ctl.spare_virt_addr); - iounmap(sif_virt_addr); - iounmap(secpcm_portslc_virt_addr); - -} -module_exit(mdm9615_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC MDM9615"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/mdm9625.c b/sound/soc/msm/mdm9625.c deleted file mode 100644 index c7bc79361e7982ea2f29c9ff323ff048a95224b4..0000000000000000000000000000000000000000 --- a/sound/soc/msm/mdm9625.c +++ /dev/null @@ -1,1247 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../codecs/wcd9320.h" -#include - -/* Spk control */ -#define MDM9625_SPK_ON 1 - -/* MDM9625 run Taiko at 12.288 Mhz. - * At present MDM supports 12.288mhz - * only. Taiko supports 9.6 MHz also. - */ -#define MDM_MCLK_CLK_12P288MHZ 12288000 -#define MDM_MCLK_CLK_9P6HZ 9600000 -#define MDM_IBIT_CLK_DIV_1P56MHZ 7 -#define MDM_MI2S_AUXPCM_PRIM_INTF 0 -#define MDM_MI2S_AUXPCM_SEC_INTF 1 - -#define LPAIF_OFFSET 0xFE000000 -#define LPAIF_PRI_MODE_MUXSEL (LPAIF_OFFSET + 0x2B000) -#define LPAIF_SEC_MODE_MUXSEL (LPAIF_OFFSET + 0x2C000) - -#define I2S_SEL 0 -#define I2S_PCM_SEL 1 -#define I2S_PCM_SEL_OFFSET 1 - -/* Machine driver Name*/ -#define MDM9625_MACHINE_DRV_NAME "mdm9625-asoc-taiko" - -/* I2S GPIO */ -struct msm_i2s_gpio { - unsigned gpio_no; - const char *gpio_name; -}; - -struct msm_i2s_ctrl { - struct msm_i2s_gpio *pin_data; - struct clk *cdc_bit_clk; - u32 cnt; -}; -struct mdm9625_machine_data { - u32 mclk_freq; - struct msm_i2s_gpio *mclk_pin; - struct msm_i2s_ctrl *pri_ctrl; - u32 prim_clk_usrs; -}; - -static const struct afe_clk_cfg lpass_default = { - AFE_API_VERSION_I2S_CONFIG, - Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, - Q6AFE_LPASS_OSR_CLK_12_P288_MHZ, - Q6AFE_LPASS_CLK_SRC_INTERNAL, - Q6AFE_LPASS_CLK_ROOT_DEFAULT, - Q6AFE_LPASS_MODE_BOTH_VALID, - 0, -}; - - -#define GPIO_NAME_INDEX 0 -#define DT_PARSE_INDEX 1 - -static int mdm9625_auxpcm_rate = 8000; -void *lpaif_pri_muxsel_virt_addr; - -static char *mdm_i2s_gpio_name[][2] = { - {"PRIM_MI2S_WS", "prim-i2s-gpio-ws"}, - {"PRIM_MI2S_DIN", "prim-i2s-gpio-din"}, - {"PRIM_MI2S_DOUT", "prim-i2s-gpio-dout"}, - {"PRIM_MI2S_SCLK", "prim-i2s-gpio-sclk"}, -}; - -static char *mdm_mclk_gpio[][2] = { - {"MI2S_MCLK", "prim-i2s-gpio-mclk"}, -}; - -static struct mutex cdc_mclk_mutex; -static int mdm9625_mi2s_rx_ch = 1; -static int mdm9625_mi2s_tx_ch = 1; -static int msm_spk_control; -static atomic_t aux_ref_count; -static atomic_t mi2s_ref_count; - -static int mdm9625_enable_codec_ext_clk(struct snd_soc_codec *codec, - int enable, bool dapm); - -void *def_taiko_mbhc_cal(void); - -static struct wcd9xxx_mbhc_config mbhc_cfg = { - .read_fw_bin = false, - .calibration = NULL, - .micbias = MBHC_MICBIAS2, - .mclk_cb_fn = mdm9625_enable_codec_ext_clk, - .mclk_rate = MDM_MCLK_CLK_12P288MHZ, - .gpio = 0, - .gpio_irq = 0, - .gpio_level_insert = 1, - .detect_extn_cable = true, - .insert_detect = true, - .swap_gnd_mic = NULL, -}; - -#define WCD9XXX_MBHC_DEF_BUTTONS 8 -#define WCD9XXX_MBHC_DEF_RLOADS 5 - -static int mdm9625_set_gpio(struct snd_pcm_substream *substream, - u32 intf) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_card *card = rtd->card; - struct mdm9625_machine_data *pdata = snd_soc_card_get_drvdata(card); - struct msm_i2s_ctrl *i2s_ctrl = NULL; - struct msm_i2s_gpio *pin_data = NULL; - int rtn = 0; - int i; - int j; - - if (pdata == NULL) { - pr_err("%s: pdata is NULL\n", __func__); - rtn = -EINVAL; - goto err; - } - - if (intf == MDM_MI2S_AUXPCM_PRIM_INTF) { - i2s_ctrl = pdata->pri_ctrl; - } - else { - pr_err("%s: Wrong I2S Interface\n", __func__); - rtn = -EINVAL; - goto err; - } - if (i2s_ctrl == NULL || i2s_ctrl->pin_data == NULL) { - pr_err("%s: Intf ptr NULL\n", __func__); - rtn = -EINVAL; - goto err; - } - pin_data = i2s_ctrl->pin_data; - for (i = 0; i < i2s_ctrl->cnt; i++, pin_data++) { - rtn = gpio_request(pin_data->gpio_no, - pin_data->gpio_name); - pr_debug("%s: gpio = %d, gpio name = %s\n" - "rtn = %d\n", __func__, - pin_data->gpio_no, - pin_data->gpio_name, - rtn); - if (rtn) { - pr_err("%s: Failed to request gpio %d\n", - __func__, pin_data->gpio_no); - /* Release all the GPIO on failure */ - for (j = i; j >= 0; j--) - gpio_free(pin_data->gpio_no); - goto err; - } - } -err: - return rtn; - -} - -static int mdm9625_mi2s_free_gpios(struct snd_pcm_substream *substream, - u32 intf) -{ - int i; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_card *card = rtd->card; - struct mdm9625_machine_data *pdata = snd_soc_card_get_drvdata(card); - struct msm_i2s_ctrl *i2s_ctrl = NULL; - struct msm_i2s_gpio *pin_data = NULL; - int rtn = 0; - - pr_debug("%s:", __func__); - if (pdata == NULL) { - pr_err("%s: pdata is NULL\n", __func__); - rtn = -EINVAL; - goto err; - } - if (intf == MDM_MI2S_AUXPCM_PRIM_INTF) { - i2s_ctrl = pdata->pri_ctrl; - } - else { - pr_debug("%s: Wrong Interface\n", __func__); - rtn = -EINVAL; - goto err; - } - if (i2s_ctrl == NULL || i2s_ctrl->pin_data == NULL) { - pr_err("%s: Intf ptr NULL\n", __func__); - rtn = -EINVAL; - goto err; - } - pin_data = i2s_ctrl->pin_data; - for (i = 0; i < i2s_ctrl->cnt; i++, pin_data++) { - gpio_free(pin_data->gpio_no); - pr_debug("%s: gpio = %d, gpio name = %s\n", - __func__, pin_data->gpio_no, - pin_data->gpio_name); - } -err: - return rtn; - -} -static int mdm9625_mi2s_clk_ctl(struct snd_soc_pcm_runtime *rtd, bool enable) -{ - struct snd_soc_card *card = rtd->card; - struct mdm9625_machine_data *pdata = snd_soc_card_get_drvdata(card); - struct afe_clk_cfg *lpass_clk = NULL; - int ret = 0; - - if (pdata == NULL) { - pr_err("%s:platform data is null\n", __func__); - return -ENOMEM; - } - lpass_clk = kzalloc(sizeof(struct afe_clk_cfg), GFP_KERNEL); - if (lpass_clk == NULL) { - pr_err("%s:Failed to allocate memory\n", __func__); - return -ENOMEM; - } - memcpy(lpass_clk, &lpass_default, sizeof(struct afe_clk_cfg)); - pr_debug("%s:enable = %x\n", __func__, enable); - if (enable) { - if (pdata->prim_clk_usrs == 0) { - lpass_clk->clk_val2 = pdata->mclk_freq; - lpass_clk->clk_set_mode = Q6AFE_LPASS_MODE_BOTH_VALID; - } else - lpass_clk->clk_set_mode = Q6AFE_LPASS_MODE_CLK1_VALID; - ret = afe_set_lpass_clock(MI2S_RX, lpass_clk); - if (ret < 0) - pr_err("%s:afe_set_lpass_clock failed\n", __func__); - else - pdata->prim_clk_usrs++; - } else { - if (pdata->prim_clk_usrs > 0) - pdata->prim_clk_usrs--; - if (pdata->prim_clk_usrs == 0) { - lpass_clk->clk_val2 = Q6AFE_LPASS_OSR_CLK_DISABLE; - lpass_clk->clk_set_mode = Q6AFE_LPASS_MODE_BOTH_VALID; - } else - lpass_clk->clk_set_mode = Q6AFE_LPASS_MODE_CLK1_VALID; - lpass_clk->clk_val1 = Q6AFE_LPASS_IBIT_CLK_DISABLE; - ret = afe_set_lpass_clock(MI2S_RX, lpass_clk); - if (ret < 0) - pr_err("%s:afe_set_lpass_clock failed\n", __func__); - } - pr_debug("%s: clk 1 = %x clk2 = %x mode = %x\n", - __func__, lpass_clk->clk_val1, - lpass_clk->clk_val2, - lpass_clk->clk_set_mode); - kfree(lpass_clk); - return ret; -} - -static void mdm9625_mi2s_snd_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - int ret; - if (atomic_dec_return(&mi2s_ref_count) == 0) { - mdm9625_mi2s_free_gpios(substream, MDM_MI2S_AUXPCM_PRIM_INTF); - ret = mdm9625_mi2s_clk_ctl(rtd, false); - if (ret < 0) - pr_err("%s:clock disable failed\n", __func__); - } -} - -static int mdm9625_mi2s_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret = 0; - - if (atomic_inc_return(&mi2s_ref_count) == 1) { - if (lpaif_pri_muxsel_virt_addr != NULL) - iowrite32(I2S_SEL << I2S_PCM_SEL_OFFSET, - lpaif_pri_muxsel_virt_addr); - else - pr_err("%s lpaif_pri_muxsel_virt_addr is NULL\n", - __func__); - ret = mdm9625_set_gpio(substream, MDM_MI2S_AUXPCM_PRIM_INTF); - if (ret < 0) { - pr_err("%s, GPIO setup failed\n", __func__); - return ret; - } - ret = mdm9625_mi2s_clk_ctl(rtd, true); - if (ret < 0) { - pr_err("set format for codec dai failed\n"); - return ret; - } - /* This sets the CONFIG PARAMETER WS_SRC. - * 1 means internal clock master mode. - * 0 means external clock slave mode. - */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set fmt cpu dai failed\n"); - - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set fmt for codec dai failed\n"); - } - - return ret; -} - -static int mdm9625_mi2s_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - rate->min = rate->max = 48000; - channels->min = channels->max = mdm9625_mi2s_rx_ch; - return 0; -} - -static int mdm9625_mi2s_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - rate->min = rate->max = 48000; - channels->min = channels->max = mdm9625_mi2s_tx_ch; - return 0; -} - -static int mdm9625_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - rate->min = rate->max = 48000; - return 0; -} - -static int mdm9625_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm9615_i2s_rx_ch = %d\n", __func__, - mdm9625_mi2s_rx_ch); - ucontrol->value.integer.value[0] = mdm9625_mi2s_rx_ch - 1; - return 0; -} - -static int mdm9625_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mdm9625_mi2s_rx_ch = ucontrol->value.integer.value[0] + 1; - pr_debug("%s: msm9615_i2s_rx_ch = %d\n", __func__, - mdm9625_mi2s_rx_ch); - return 1; -} - -static int mdm9625_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm9615_i2s_tx_ch = %d\n", __func__, - mdm9625_mi2s_tx_ch); - ucontrol->value.integer.value[0] = mdm9625_mi2s_tx_ch - 1; - return 0; -} - -static int mdm9625_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mdm9625_mi2s_tx_ch = ucontrol->value.integer.value[0] + 1; - pr_debug("%s: msm9615_i2s_tx_ch = %d\n", __func__, - mdm9625_mi2s_tx_ch); - return 1; -} - - -static int mdm9625_mi2s_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - ucontrol->value.integer.value[0] = msm_spk_control; - return 0; -} - -static void mdm_ext_control(struct snd_soc_codec *codec) -{ - struct snd_soc_dapm_context *dapm = &codec->dapm; - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - mutex_lock(&dapm->codec->mutex); - if (msm_spk_control == MDM9625_SPK_ON) { - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - } else { - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg"); - } - snd_soc_dapm_sync(dapm); - mutex_unlock(&dapm->codec->mutex); -} - -static int mdm9625_mi2s_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - pr_debug("%s()\n", __func__); - if (msm_spk_control == ucontrol->value.integer.value[0]) - return 0; - msm_spk_control = ucontrol->value.integer.value[0]; - mdm_ext_control(codec); - return 1; -} - -static int mdm9625_enable_codec_ext_clk(struct snd_soc_codec *codec, - int enable, bool dapm) -{ - int ret = 0; - struct mdm9625_machine_data *pdata = - snd_soc_card_get_drvdata(codec->card); - struct afe_clk_cfg *lpass_clk = NULL; - - pr_debug("%s: enable = %d codec name %s enable %x\n", - __func__, enable, codec->name, enable); - lpass_clk = kzalloc(sizeof(struct afe_clk_cfg), GFP_KERNEL); - if (lpass_clk == NULL) { - pr_err("%s:Failed to allocate memory\n", __func__); - return -ENOMEM; - } - mutex_lock(&cdc_mclk_mutex); - memcpy(lpass_clk, &lpass_default, sizeof(struct afe_clk_cfg)); - if (enable) { - if (pdata->prim_clk_usrs == 0) { - lpass_clk->clk_val2 = pdata->mclk_freq; - lpass_clk->clk_set_mode = Q6AFE_LPASS_MODE_CLK2_VALID; - ret = afe_set_lpass_clock(MI2S_RX, lpass_clk); - if (ret < 0) { - pr_err("%s:afe_set_lpass_clock failed\n", - __func__); - goto err; - } - } - pdata->prim_clk_usrs++; - taiko_mclk_enable(codec, 1, dapm); - } else { - if (pdata->prim_clk_usrs > 0) - pdata->prim_clk_usrs--; - if (pdata->prim_clk_usrs == 0) { - lpass_clk->clk_set_mode = Q6AFE_LPASS_MODE_CLK2_VALID; - lpass_clk->clk_val2 = Q6AFE_LPASS_OSR_CLK_DISABLE; - ret = afe_set_lpass_clock(MI2S_RX, lpass_clk); - if (ret < 0) { - pr_err("%s:afe_set_lpass_clock failed\n", - __func__); - goto err; - } - } - taiko_mclk_enable(codec, 0, dapm); - } - pr_debug("%s: clk2 = %x mode = %x\n", - __func__, lpass_clk->clk_val2, - lpass_clk->clk_set_mode); -err: - mutex_unlock(&cdc_mclk_mutex); - kfree(lpass_clk); - return ret; -} - -static int mdm9625_mclk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - pr_debug("%s: event = %d\n", __func__, event); - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - return mdm9625_enable_codec_ext_clk(w->codec, 1, true); - case SND_SOC_DAPM_POST_PMD: - return mdm9625_enable_codec_ext_clk(w->codec, 0, true); - } - return 0; -} - -static int mdm9625_auxpcm_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - int ret = 0; - - if (atomic_inc_return(&aux_ref_count) == 1) { - if (lpaif_pri_muxsel_virt_addr != NULL) - iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET, - lpaif_pri_muxsel_virt_addr); - else - pr_err("%s lpaif_pri_muxsel_virt_addr is NULL\n", - __func__); - ret = mdm9625_set_gpio(substream, MDM_MI2S_AUXPCM_PRIM_INTF); - if (ret < 0) { - pr_err("%s, GPIO setup failed\n", __func__); - return ret; - } - ret = mdm9625_mi2s_clk_ctl(rtd, true); - if (ret < 0) { - pr_err("set format for codec dai failed\n"); - return ret; - } - } - return ret; -} - -static void mdm9625_auxpcm_snd_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - int ret; - - if (atomic_dec_return(&aux_ref_count) == 0) { - mdm9625_mi2s_free_gpios(substream, MDM_MI2S_AUXPCM_PRIM_INTF); - ret = mdm9625_mi2s_clk_ctl(rtd, false); - if (ret < 0) - pr_err("%s:clock disable failed\n", __func__); - } -} - -static int mdm9625_auxpcm_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = mdm9625_auxpcm_rate; - return 0; -} - -static int mdm9625_auxpcm_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 0: - mdm9625_auxpcm_rate = 8000; - break; - case 1: - mdm9625_auxpcm_rate = 16000; - break; - default: - mdm9625_auxpcm_rate = 8000; - break; - } - return 0; -} - -static int mdm9625_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = - hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = - hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = mdm9625_auxpcm_rate; - channels->min = channels->max = 1; - - return 0; -} - -static const struct snd_soc_dapm_widget mdm9625_dapm_widgets[] = { - - SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, - mdm9625_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_SPK("Ext Spk Bottom Pos", NULL), - SND_SOC_DAPM_SPK("Ext Spk Bottom Neg", NULL), - SND_SOC_DAPM_SPK("Ext Spk Top Pos", NULL), - SND_SOC_DAPM_SPK("Ext Spk Top Neg", NULL), - SND_SOC_DAPM_MIC("Handset Mic", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("Digital Mic2", NULL), - SND_SOC_DAPM_MIC("Digital Mic3", NULL), - SND_SOC_DAPM_MIC("Digital Mic4", NULL), - SND_SOC_DAPM_MIC("Digital Mic5", NULL), - SND_SOC_DAPM_MIC("Digital Mic6", NULL), -}; - -static const char *const spk_function[] = {"Off", "On"}; -static const char *const mi2s_rx_ch_text[] = {"One", "Two"}; -static const char *const mi2s_tx_ch_text[] = {"One", "Two"}; -static const char *const auxpcm_rate_text[] = {"rate_8000", "rate_16000"}; - -static const struct soc_enum mdm9625_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(2, mi2s_rx_ch_text), - SOC_ENUM_SINGLE_EXT(2, mi2s_tx_ch_text), - SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text), -}; - -static const struct snd_kcontrol_new mdm_snd_controls[] = { - SOC_ENUM_EXT("Speaker Function", mdm9625_enum[0], - mdm9625_mi2s_get_spk, - mdm9625_mi2s_set_spk), - SOC_ENUM_EXT("MI2S_RX Channels", mdm9625_enum[1], - mdm9625_mi2s_rx_ch_get, - mdm9625_mi2s_rx_ch_put), - SOC_ENUM_EXT("MI2S_TX Channels", mdm9625_enum[2], - mdm9625_mi2s_tx_ch_get, - mdm9625_mi2s_tx_ch_put), - SOC_ENUM_EXT("AUX PCM SampleRate", mdm9625_enum[3], - mdm9625_auxpcm_rate_get, - mdm9625_auxpcm_rate_put), -}; - -static int mdm9625_mi2s_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); - - rtd->pmdown_time = 0; - err = snd_soc_add_codec_controls(codec, mdm_snd_controls, - ARRAY_SIZE(mdm_snd_controls)); - if (err < 0) - return err; - - snd_soc_dapm_new_controls(dapm, mdm9625_dapm_widgets, - ARRAY_SIZE(mdm9625_dapm_widgets)); - - /* After DAPM Enable pins alawys - * DAPM SYNC needs to be called. - */ - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - snd_soc_dapm_sync(dapm); - - mbhc_cfg.calibration = def_taiko_mbhc_cal(); - if (mbhc_cfg.calibration) - err = taiko_hs_detect(codec, &mbhc_cfg); - else - err = -ENOMEM; - return err; -} - -void *def_taiko_mbhc_cal(void) -{ - void *taiko_cal; - struct wcd9xxx_mbhc_btn_detect_cfg *btn_cfg; - u16 *btn_low, *btn_high; - u8 *n_ready, *n_cic, *gain; - - taiko_cal = kzalloc(WCD9XXX_MBHC_CAL_SIZE(WCD9XXX_MBHC_DEF_BUTTONS, - WCD9XXX_MBHC_DEF_RLOADS), - GFP_KERNEL); - if (!taiko_cal) { - pr_err("%s: out of memory\n", __func__); - return NULL; - } - -#define S(X, Y) ((WCD9XXX_MBHC_CAL_GENERAL_PTR(taiko_cal)->X) = (Y)) - S(t_ldoh, 100); - S(t_bg_fast_settle, 100); - S(t_shutdown_plug_rem, 255); - S(mbhc_nsa, 4); - S(mbhc_navg, 4); -#undef S -#define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_DET_PTR(taiko_cal)->X) = (Y)) - S(mic_current, TAIKO_PID_MIC_5_UA); - S(hph_current, TAIKO_PID_MIC_5_UA); - S(t_mic_pid, 100); - S(t_ins_complete, 250); - S(t_ins_retry, 200); -#undef S -#define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_TYPE_PTR(taiko_cal)->X) = (Y)) - S(v_no_mic, 30); - S(v_hs_max, 2400); -#undef S -#define S(X, Y) ((WCD9XXX_MBHC_CAL_BTN_DET_PTR(taiko_cal)->X) = (Y)) - S(c[0], 62); - S(c[1], 124); - S(nc, 1); - S(n_meas, 3); - S(mbhc_nsc, 11); - S(n_btn_meas, 1); - S(n_btn_con, 2); - S(num_btn, WCD9XXX_MBHC_DEF_BUTTONS); - S(v_btn_press_delta_sta, 100); - S(v_btn_press_delta_cic, 50); -#undef S - btn_cfg = WCD9XXX_MBHC_CAL_BTN_DET_PTR(taiko_cal); - btn_low = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_V_BTN_LOW); - btn_high = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, - MBHC_BTN_DET_V_BTN_HIGH); - btn_low[0] = -50; - btn_high[0] = 10; - btn_low[1] = 11; - btn_high[1] = 52; - btn_low[2] = 53; - btn_high[2] = 94; - btn_low[3] = 95; - btn_high[3] = 133; - btn_low[4] = 134; - btn_high[4] = 171; - btn_low[5] = 172; - btn_high[5] = 208; - btn_low[6] = 209; - btn_high[6] = 244; - btn_low[7] = 245; - btn_high[7] = 330; - n_ready = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_READY); - n_ready[0] = 80; - n_ready[1] = 68; - n_cic = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_CIC); - n_cic[0] = 60; - n_cic[1] = 47; - gain = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_GAIN); - gain[0] = 11; - gain[1] = 9; - - return taiko_cal; -} - - -static struct snd_soc_ops mdm9625_mi2s_be_ops = { - .startup = mdm9625_mi2s_startup, - .shutdown = mdm9625_mi2s_snd_shutdown, -}; - -static struct snd_soc_ops mdm9625_auxpcm_be_ops = { - .startup = mdm9625_auxpcm_startup, - .shutdown = mdm9625_auxpcm_snd_shutdown, -}; - -/* Digital audio interface connects codec <---> CPU */ -static struct snd_soc_dai_link mdm9625_dai[] = { - /* FrontEnd DAI Links */ - { - .name = "MDM9625 Media1", - .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp.0", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - /* This dainlink has playback support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MSM VoIP", - .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - /* This dainlink has VOIP support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_VOIP, - }, - { - .name = "Circuit-Switch Voice", - .stream_name = "CS-Voice", - .cpu_dai_name = "CS-VOICE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - /* This dainlink has Voice support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_CS_VOICE, - }, - { - .name = "MI2S Hostless", - .stream_name = "MI2S Hostless", - .cpu_dai_name = "MI2S_TX_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - /* This dainlink has MI2S support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "VoLTE", - .stream_name = "VoLTE", - .cpu_dai_name = "VoLTE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .be_id = MSM_FRONTEND_DAI_VOLTE, - }, - { .name = "MSM AFE-PCM RX", - .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6-dev.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - }, - { - .name = "MSM AFE-PCM TX", - .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6-dev.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "DTMF RX Hostless", - .stream_name = "DTMF RX Hostless", - .cpu_dai_name = "DTMF_RX_HOSTLESS", - .platform_name = "msm-pcm-dtmf", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .be_id = MSM_FRONTEND_DAI_DTMF_RX, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - }, - { - .name = "DTMF TX", - .stream_name = "DTMF TX", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-pcm-dtmf", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .ignore_suspend = 1, - }, - { - .name = "CS-VOICE HOST RX CAPTURE", - .stream_name = "CS-VOICE HOST RX CAPTURE", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-voice-host-pcm", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .ignore_suspend = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - }, - { - .name = "CS-VOICE HOST RX PLAYBACK", - .stream_name = "CS-VOICE HOST RX PLAYBACK", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-voice-host-pcm", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .ignore_suspend = 1, - }, - { - .name = "CS-VOICE HOST TX CAPTURE", - .stream_name = "CS-VOICE HOST TX CAPTURE", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-voice-host-pcm", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .ignore_suspend = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - }, - { - .name = "CS-VOICE HOST TX PLAYBACK", - .stream_name = "CS-VOICE HOST TX PLAYBACK", - .cpu_dai_name = "msm-dai-stub", - .platform_name = "msm-voice-host-pcm", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .ignore_suspend = 1, - }, - { - .name = "MDM9625 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-pcm-dsp.0", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - /* Backend DAI Links */ - { - .name = LPASS_BE_MI2S_RX, - .stream_name = "MI2S Playback", - .cpu_dai_name = "msm-dai-q6-mi2s.0", - .platform_name = "msm-pcm-routing", - .codec_name = "taiko_codec", - .codec_dai_name = "taiko_i2s_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_MI2S_RX, - .init = &mdm9625_mi2s_audrx_init, - .be_hw_params_fixup = &mdm9625_mi2s_rx_be_hw_params_fixup, - .ops = &mdm9625_mi2s_be_ops, - }, - { - .name = LPASS_BE_MI2S_TX, - .stream_name = "MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s.0", - .platform_name = "msm-pcm-routing", - .codec_name = "taiko_codec", - .codec_dai_name = "taiko_i2s_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_MI2S_TX, - .be_hw_params_fixup = &mdm9625_mi2s_tx_be_hw_params_fixup, - .ops = &mdm9625_mi2s_be_ops, - }, - { - .name = LPASS_BE_AFE_PCM_RX, - .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6-dev.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, - }, - { - .name = LPASS_BE_AFE_PCM_TX, - .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6-dev.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, - }, - { - .name = LPASS_BE_AUXPCM_RX, - .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6-auxpcm.1", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_RX, - .be_hw_params_fixup = mdm9625_auxpcm_be_params_fixup, - .ops = &mdm9625_auxpcm_be_ops, - .ignore_pmdown_time = 1, - /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_AUXPCM_TX, - .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6-auxpcm.1", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_TX, - .be_hw_params_fixup = mdm9625_auxpcm_be_params_fixup, - .ops = &mdm9625_auxpcm_be_ops, - }, - /* Incall Record Uplink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_TX, - .stream_name = "Voice Uplink Capture", - .cpu_dai_name = "msm-dai-q6-dev.32772", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX, - .be_hw_params_fixup = mdm9625_be_hw_params_fixup, - .ignore_suspend = 1, - }, - /* Incall Record Downlink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_RX, - .stream_name = "Voice Downlink Capture", - .cpu_dai_name = "msm-dai-q6-dev.32771", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX, - .be_hw_params_fixup = mdm9625_be_hw_params_fixup, - .ignore_suspend = 1, - }, - /* Incall Music BACK END DAI Link */ - { - .name = LPASS_BE_VOICE_PLAYBACK_TX, - .stream_name = "Voice Farend Playback", - .cpu_dai_name = "msm-dai-q6-dev.32773", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, - .be_hw_params_fixup = mdm9625_be_hw_params_fixup, - .ignore_suspend = 1, - }, -}; - -static struct snd_soc_card snd_soc_card_mdm9625 = { - .name = "mdm9625-taiko-i2s-snd-card", - .dai_link = mdm9625_dai, - .num_links = ARRAY_SIZE(mdm9625_dai), -}; - -static int mdm9625_dtparse(struct platform_device *pdev, - struct mdm9625_machine_data **pdata) -{ - int ret = 0, i = 0; - struct msm_i2s_gpio *pin_data = NULL; - struct msm_i2s_ctrl *ctrl; - struct msm_i2s_gpio *mclk_pin = NULL; - unsigned int gpio_no[4]; - unsigned int dt_mclk = 0; - enum of_gpio_flags flags = OF_GPIO_ACTIVE_LOW; - int prim_cnt = 0; - pin_data = devm_kzalloc(&pdev->dev, (4 * - sizeof(struct msm_i2s_gpio)), - GFP_KERNEL); - mclk_pin = devm_kzalloc(&pdev->dev, - sizeof(struct msm_i2s_gpio), - GFP_KERNEL); - - if (!pin_data || !mclk_pin) { - dev_err(&pdev->dev, "No memory for gpio\n"); - ret = -ENOMEM; - goto err; - } - for (i = 0; i < ARRAY_SIZE(gpio_no); i++) { - gpio_no[i] = of_get_named_gpio_flags(pdev->dev.of_node, - mdm_i2s_gpio_name[i][DT_PARSE_INDEX], - 0, &flags); - if (gpio_no[i] > 0) { - pin_data[i].gpio_name = - mdm_i2s_gpio_name[prim_cnt][GPIO_NAME_INDEX]; - pin_data[i].gpio_no = gpio_no[i]; - dev_dbg(&pdev->dev, "%s:GPIO gpio[%s] =\n" - "0x%x\n", __func__, - pin_data[i].gpio_name, - pin_data[i].gpio_no); - prim_cnt++; - } else { - dev_err(&pdev->dev, "%s:Invalid I2S GPIO[%s] = %x\n", - __func__, - mdm_i2s_gpio_name[i][GPIO_NAME_INDEX], - gpio_no[i]); - ret = -ENODEV; - goto err; - } - } - for (i = 0; i < ARRAY_SIZE(mdm_mclk_gpio); i++) { - dt_mclk = of_get_named_gpio_flags(pdev->dev.of_node, - mdm_mclk_gpio[i][DT_PARSE_INDEX], 0, - &flags); - if (dt_mclk > 0) { - mclk_pin->gpio_name = - mdm_mclk_gpio[i][GPIO_NAME_INDEX]; - mclk_pin->gpio_no = dt_mclk; - ret = gpio_request(mclk_pin->gpio_no, - mclk_pin->gpio_name); - dev_dbg(&pdev->dev, "%s:Request MCLK Gpio\n" - "gpio[%s] = 0x%x\n", __func__, - mclk_pin->gpio_name, - dt_mclk); - } else { - dev_err(&pdev->dev, "%s:MCLK gpio is incorrect\n", - __func__); - ret = -ENODEV; - goto err; - } - } - - ctrl = devm_kzalloc(&pdev->dev, - sizeof(struct msm_i2s_ctrl), GFP_KERNEL); - if (!ctrl) { - dev_err(&pdev->dev, "No memory for gpio\n"); - ret = -ENOMEM; - goto err; - } - ctrl->pin_data = pin_data; - ctrl->cnt = prim_cnt; - (*pdata)->pri_ctrl = ctrl; - (*pdata)->mclk_pin = mclk_pin; - return ret; - -err: - if (mclk_pin) - devm_kfree(&pdev->dev, mclk_pin); - if (pin_data) - devm_kfree(&pdev->dev, pin_data); - return ret; -} - -static int mdm9625_asoc_machine_probe(struct platform_device *pdev) -{ - int ret; - struct snd_soc_card *card = &snd_soc_card_mdm9625; - struct mdm9625_machine_data *pdata; - enum apr_subsys_state q6_state; - - q6_state = apr_get_q6_state(); - if (q6_state != APR_SUBSYS_LOADED) { - dev_dbg(&pdev->dev, "defering %s, adsp_state %d\n", - __func__, q6_state); - return -EPROBE_DEFER; - } - mutex_init(&cdc_mclk_mutex); - if (!pdev->dev.of_node) { - dev_err(&pdev->dev, "No platform supplied from device tree\n"); - return -EINVAL; - } - pdata = devm_kzalloc(&pdev->dev, sizeof(struct mdm9625_machine_data), - GFP_KERNEL); - if (!pdata) { - dev_err(&pdev->dev, "Can't allocate mdm9625_asoc_mach_data\n"); - ret = -ENOMEM; - goto err; - } - ret = mdm9625_dtparse(pdev, &pdata); - if (ret) { - dev_err(&pdev->dev, - "%s: mi2s-aux Pin data parse failed", - __func__); - goto err; - } - ret = of_property_read_u32(pdev->dev.of_node, - "qcom,taiko-mclk-clk-freq", - &pdata->mclk_freq); - if (ret) { - dev_err(&pdev->dev, - "Looking up %s property in node %s failed", - "qcom,taiko-mclk-clk-freq", - pdev->dev.of_node->full_name); - goto err; - } - /* At present only 12.288MHz is supported on MDM. */ - if (q6afe_check_osr_clk_freq(pdata->mclk_freq)) { - dev_err(&pdev->dev, "unsupported taiko mclk freq %u\n", - pdata->mclk_freq); - ret = -EINVAL; - goto err; - } - pdata->prim_clk_usrs = 0; - card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); - snd_soc_card_set_drvdata(card, pdata); - ret = snd_soc_of_parse_card_name(card, "qcom,model"); - if (ret) - goto err; - ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing"); - if (ret) - goto err; - ret = snd_soc_register_card(card); - if (ret) { - dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", - ret); - goto err; - } - - lpaif_pri_muxsel_virt_addr = ioremap(LPAIF_PRI_MODE_MUXSEL, 4); - if (lpaif_pri_muxsel_virt_addr == NULL) { - pr_err("%s Pri muxsel virt addr is null\n", __func__); - ret = -EINVAL; - goto err; - } - - return 0; -err: - devm_kfree(&pdev->dev, pdata); - return ret; -} - -static int mdm9625_asoc_machine_remove(struct platform_device *pdev) -{ - struct snd_soc_card *card = platform_get_drvdata(pdev); - struct mdm9625_machine_data *pdata = snd_soc_card_get_drvdata(card); - pdata->mclk_freq = 0; - snd_soc_unregister_card(card); - return 0; -} - -static const struct of_device_id msm9625_asoc_machine_of_match[] = { - { .compatible = "qcom,mdm9625-audio-taiko", }, - {}, -}; - -static struct platform_driver msm9625_asoc_machine_driver = { - .driver = { - .name = MDM9625_MACHINE_DRV_NAME, - .owner = THIS_MODULE, - .pm = &snd_soc_pm_ops, - .of_match_table = msm9625_asoc_machine_of_match, - }, - .probe = mdm9625_asoc_machine_probe, - .remove = mdm9625_asoc_machine_remove, -}; - - -module_platform_driver(msm9625_asoc_machine_driver); - -MODULE_DESCRIPTION("ALSA SoC msm"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:" MDM9625_MACHINE_DRV_NAME); -MODULE_DEVICE_TABLE(of, msm9625_asoc_machine_of_match); - diff --git a/sound/soc/msm/mpq8064.c b/sound/soc/msm/mpq8064.c deleted file mode 100644 index 4543749766138daac46cce1d5d0dd654e59274be..0000000000000000000000000000000000000000 --- a/sound/soc/msm/mpq8064.c +++ /dev/null @@ -1,1874 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "../codecs/wcd9310.h" - -/* 8064 machine driver */ -#define PM8921_MPP_BASE (PM8921_GPIO_BASE + PM8921_NR_GPIOS) -#define PM8821_NR_MPPS (4) -#define PM8821_MPP_BASE (PM8921_MPP_BASE + PM8921_NR_MPPS) -#define PM8921_GPIO_BASE NR_GPIO_IRQS -#define PM8921_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio - 1 + PM8921_GPIO_BASE) - -#define GPIO_EXPANDER_IRQ_BASE (TABLA_INTERRUPT_BASE + \ - NR_TABLA_IRQS) -#define GPIO_EXPANDER_GPIO_BASE (PM8821_MPP_BASE + PM8821_NR_MPPS) - -#define GPIO_EPM_EXPANDER_BASE GPIO_EXPANDER_GPIO_BASE -#define SX150X_EPM_NR_GPIOS 16 -#define SX150X_EPM_NR_IRQS 8 - -#define SX150X_EXP1_GPIO_BASE (GPIO_EPM_EXPANDER_BASE + \ - SX150X_EPM_NR_GPIOS) -#define SX150X_EXP1_IRQ_BASE (GPIO_EXPANDER_IRQ_BASE + \ - SX150X_EPM_NR_IRQS) -#define SX150X_EXP1_NR_IRQS 16 -#define SX150X_EXP1_NR_GPIOS 16 - -#define SX150X_EXP2_GPIO_BASE (SX150X_EXP1_GPIO_BASE + \ - SX150X_EXP1_NR_GPIOS) -#define SX150X_EXP2_IRQ_BASE (SX150X_EXP1_IRQ_BASE + SX150X_EXP1_NR_IRQS) -#define SX150X_EXP2_NR_IRQS 8 -#define SX150X_EXP2_NR_GPIOS 8 - -#define SX150X_EXP3_GPIO_BASE (SX150X_EXP2_GPIO_BASE + \ - SX150X_EXP2_NR_GPIOS) -#define SX150X_EXP3_IRQ_BASE (SX150X_EXP2_IRQ_BASE + SX150X_EXP2_NR_IRQS) -#define SX150X_EXP3_NR_IRQS 8 -#define SX150X_EXP3_NR_GPIOS 8 - -#define SX150X_EXP4_GPIO_BASE (SX150X_EXP3_GPIO_BASE + \ - SX150X_EXP3_NR_GPIOS) -#define SX150X_EXP4_IRQ_BASE (SX150X_EXP3_IRQ_BASE + SX150X_EXP3_NR_IRQS) -#define SX150X_EXP4_NR_IRQS 16 -#define SX150X_EXP4_NR_GPIOS 16 - -#define SX150X_GPIO(_expander, _pin) (SX150X_EXP##_expander##_GPIO_BASE + _pin) - -enum { - SX150X_EPM, - SX150X_EXP1, - SX150X_EXP2, - SX150X_EXP3, - SX150X_EXP4, -}; - - -#define MPQ8064_SPK_ON 1 -#define MPQ8064_SPK_OFF 0 - -#define MSM_SLIM_0_RX_MAX_CHANNELS 2 -#define MSM_SLIM_0_TX_MAX_CHANNELS 4 - -#define BOTTOM_SPK_AMP_POS 0x1 -#define BOTTOM_SPK_AMP_NEG 0x2 -#define TOP_SPK_AMP_POS 0x4 -#define TOP_SPK_AMP_NEG 0x8 - -#define GPIO_AUX_PCM_DOUT 43 -#define GPIO_AUX_PCM_DIN 44 -#define GPIO_AUX_PCM_SYNC 45 -#define GPIO_AUX_PCM_CLK 46 - -#define TABLA_EXT_CLK_RATE 12288000 - -#define TABLA_MBHC_DEF_BUTTONS 8 -#define TABLA_MBHC_DEF_RLOADS 5 - -#define GPIO_SEC_I2S_RX_SCK 47 -#define GPIO_SEC_I2S_RX_WS 48 -#define GPIO_SEC_I2S_RX_DOUT 49 -#define GPIO_SEC_I2S_RX_MCLK 50 -#define I2S_MCLK_RATE 12288000 - -#define GPIO_MI2S_WS 27 -#define GPIO_MI2S_SCLK 28 -#define GPIO_MI2S_DOUT3 29 -#define GPIO_MI2S_DOUT2 30 -#define GPIO_MI2S_DOUT1 31 -#define GPIO_MI2S_DOUT0 32 -#define GPIO_MI2S_MCLK 33 - -static struct clk *sec_i2s_rx_osr_clk; -static struct clk *sec_i2s_rx_bit_clk; - -struct request_gpio { - unsigned gpio_no; - char *gpio_name; -}; - -static struct request_gpio sec_i2s_rx_gpio[] = { - { - .gpio_no = GPIO_SEC_I2S_RX_MCLK, - .gpio_name = "SEC_I2S_RX_MCLK", - }, - { - .gpio_no = GPIO_SEC_I2S_RX_SCK, - .gpio_name = "SEC_I2S_RX_SCK", - }, - { - .gpio_no = GPIO_SEC_I2S_RX_WS, - .gpio_name = "SEC_I2S_RX_WS", - }, - { - .gpio_no = GPIO_SEC_I2S_RX_DOUT, - .gpio_name = "SEC_I2S_RX_DOUT", - }, -}; - -static struct request_gpio mi2s_gpio[] = { - { - .gpio_no = GPIO_MI2S_WS, - .gpio_name = "MI2S_WS", - }, - { - .gpio_no = GPIO_MI2S_SCLK, - .gpio_name = "MI2S_SCLK", - }, - { - .gpio_no = GPIO_MI2S_DOUT3, - .gpio_name = "MI2S_DOUT3", - }, - { - .gpio_no = GPIO_MI2S_DOUT2, - .gpio_name = "MI2S_DOUT2", - }, - { - .gpio_no = GPIO_MI2S_DOUT1, - .gpio_name = "MI2S_DOUT1", - }, - { - .gpio_no = GPIO_MI2S_DOUT0, - .gpio_name = "MI2S_DOUT0", - }, - { - .gpio_no = GPIO_MI2S_MCLK, - .gpio_name = "MI2S_MCLK", - }, -}; - -static struct clk *mi2s_bit_clk; - - - -static u32 top_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(18); -static u32 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(19); -static int msm_spk_control; -static int msm_ext_bottom_spk_pamp; -static int msm_ext_top_spk_pamp; -static int msm_slim_0_rx_ch = 1; -static int msm_slim_0_tx_ch = 1; -static int msm_hdmi_rx_ch = 8; -static int mi2s_rate_variable; -static int hdmi_rate_variable; -static struct clk *codec_clk; -static int clk_users; - -static struct snd_soc_jack hs_jack; -static struct snd_soc_jack button_jack; - -static int detect_dtv_platform; - -static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm); - -static struct tabla_mbhc_config mbhc_cfg = { - .headset_jack = &hs_jack, - .button_jack = &button_jack, - .read_fw_bin = false, - .calibration = NULL, - .micbias = TABLA_MICBIAS2, - .mclk_cb_fn = msm_enable_codec_ext_clk, - .mclk_rate = TABLA_EXT_CLK_RATE, - .gpio = 0, /* MBHC GPIO is not configured */ - .gpio_irq = 0, - .gpio_level_insert = 1, -}; - -static void msm_enable_ext_spk_amp_gpio(u32 spk_amp_gpio) -{ - int ret = 0; - - struct pm_gpio param = { - .direction = PM_GPIO_DIR_OUT, - .output_buffer = PM_GPIO_OUT_BUF_CMOS, - .output_value = 1, - .pull = PM_GPIO_PULL_NO, - .vin_sel = PM_GPIO_VIN_S4, - .out_strength = PM_GPIO_STRENGTH_MED, - . - function = PM_GPIO_FUNC_NORMAL, - }; - - if (spk_amp_gpio == bottom_spk_pamp_gpio) { - - ret = gpio_request(bottom_spk_pamp_gpio, "BOTTOM_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting BOTTOM SPK AMP GPIO %u\n", - __func__, bottom_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(bottom_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Bottom Spk Ampl" - " gpio %u\n", __func__, bottom_spk_pamp_gpio); - else { - pr_debug("%s: enable Bottom spkr amp gpio\n", __func__); - gpio_direction_output(bottom_spk_pamp_gpio, 1); - } - - } else if (spk_amp_gpio == top_spk_pamp_gpio) { - - ret = gpio_request(top_spk_pamp_gpio, "TOP_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting GPIO %d\n", __func__, - top_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(top_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Top Spk Ampl" - " gpio %u\n", __func__, top_spk_pamp_gpio); - else { - pr_debug("%s: enable Top spkr amp gpio\n", __func__); - gpio_direction_output(top_spk_pamp_gpio, 1); - } - } else { - pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO." - " gpio = %u\n", __func__, spk_amp_gpio); - return; - } -} - -static void msm_ext_spk_power_amp_on(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - pr_debug("%s() External Bottom Speaker Ampl already " - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - msm_ext_bottom_spk_pamp |= spk; - - if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - msm_enable_ext_spk_amp_gpio(bottom_spk_pamp_gpio); - pr_debug("%s: slepping 4 ms after turning on external " - " Bottom Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG)) { - - if ((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) { - - pr_debug("%s() External Top Speaker Ampl already" - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - msm_ext_top_spk_pamp |= spk; - - if ((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) { - - msm_enable_ext_spk_amp_gpio(top_spk_pamp_gpio); - pr_debug("%s: sleeping 4 ms after turning on " - " external Top Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - } else { - - pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm_ext_spk_power_amp_off(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if (!msm_ext_bottom_spk_pamp) - return; - - gpio_direction_output(bottom_spk_pamp_gpio, 0); - gpio_free(bottom_spk_pamp_gpio); - msm_ext_bottom_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after turning off external Bottom" - " Speaker Ampl\n", __func__); - - usleep_range(4000, 4000); - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG)) { - - if (!msm_ext_top_spk_pamp) - return; - - gpio_direction_output(top_spk_pamp_gpio, 0); - gpio_free(top_spk_pamp_gpio); - msm_ext_top_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after turning off external Top" - " Spkaker Ampl\n", __func__); - - usleep_range(4000, 4000); - } else { - - pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm_ext_control(struct snd_soc_codec *codec) -{ - struct snd_soc_dapm_context *dapm = &codec->dapm; - - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - if (msm_spk_control == MPQ8064_SPK_ON) { - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - } else { - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg"); - } - - snd_soc_dapm_sync(dapm); -} - -static int msm_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control); - ucontrol->value.integer.value[0] = msm_spk_control; - return 0; -} -static int msm_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm_spk_control == ucontrol->value.integer.value[0]) - return 0; - - msm_spk_control = ucontrol->value.integer.value[0]; - msm_ext_control(codec); - return 1; -} -static int msm_spkramp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event)); - - if (SND_SOC_DAPM_EVENT_ON(event)) { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm_ext_spk_power_amp_on(TOP_SPK_AMP_NEG); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - - } else { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm_ext_spk_power_amp_off(TOP_SPK_AMP_NEG); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - } - return 0; -} - -static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm) -{ - pr_debug("%s: enable = %d\n", __func__, enable); - if (enable) { - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users != 1) - return 0; - - if (codec_clk) { - clk_set_rate(codec_clk, TABLA_EXT_CLK_RATE); - clk_prepare_enable(codec_clk); - tabla_mclk_enable(codec, 1, dapm); - } else { - pr_err("%s: Error setting Tabla MCLK\n", __func__); - clk_users--; - return -EINVAL; - } - } else { - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 0) - return 0; - clk_users--; - if (!clk_users) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - clk_disable_unprepare(codec_clk); - tabla_mclk_enable(codec, 0, dapm); - } - } - return 0; -} - -static int msm_mclk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - pr_debug("%s: event = %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - - if (clk_users != 1) - return 0; - - if (codec_clk) { - clk_set_rate(codec_clk, 12288000); - clk_prepare_enable(codec_clk); - tabla_mclk_enable(w->codec, 1, true); - - } else { - pr_err("%s: Error setting Tabla MCLK\n", __func__); - clk_users--; - return -EINVAL; - } - break; - case SND_SOC_DAPM_POST_PMD: - - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - - if (clk_users == 0) - return 0; - - clk_users--; - - if (!clk_users) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - - clk_disable_unprepare(codec_clk); - tabla_mclk_enable(w->codec, 0, true); - } - break; - } - return 0; -} - -static const struct snd_soc_dapm_widget msm_dapm_widgets[] = { - - SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, - msm_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SPK("Ext Spk Bottom Pos", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Bottom Neg", msm_spkramp_event), - - SND_SOC_DAPM_SPK("Ext Spk Top Pos", msm_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Top Neg", msm_spkramp_event), - - SND_SOC_DAPM_MIC("Handset Mic", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - - SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), -}; - -static const struct snd_soc_dapm_route common_audio_map[] = { - - {"RX_BIAS", NULL, "MCLK"}, - {"LDO_H", NULL, "MCLK"}, - - /* Speaker path */ - {"Ext Spk Bottom Pos", NULL, "LINEOUT1"}, - {"Ext Spk Bottom Neg", NULL, "LINEOUT3"}, - - {"Ext Spk Top Pos", NULL, "LINEOUT2"}, - {"Ext Spk Top Neg", NULL, "LINEOUT4"}, - - /* Microphone path */ - {"AMIC1", NULL, "MIC BIAS1 Internal1"}, - {"MIC BIAS1 Internal1", NULL, "Handset Mic"}, - - {"AMIC2", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "Headset Mic"}, - - /** - * AMIC3 and AMIC4 inputs are connected to ANC microphones - * These mics are biased differently on CDP and FLUID - * routing entries below are based on bias arrangement - * on FLUID. - */ - {"AMIC3", NULL, "MIC BIAS3 Internal1"}, - {"MIC BIAS3 Internal1", NULL, "ANCRight Headset Mic"}, - - {"AMIC4", NULL, "MIC BIAS1 Internal2"}, - {"MIC BIAS1 Internal2", NULL, "ANCLeft Headset Mic"}, - - {"HEADPHONE", NULL, "LDO_H"}, -}; - -static const char *spk_function[] = {"Off", "On"}; -static const char *slim0_rx_ch_text[] = {"One", "Two"}; -static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"}; -static const char * const hdmi_rx_ch_text[] = {"Two", "Three", "Four", - "Five", "Six", "Seven", "Eight"}; -static const char * const mi2s_rate[] = {"Default", "Variable"}; -static const char * const hdmi_rate[] = {"Default", "Variable"}; - - - -static const struct soc_enum msm_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text), - SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text), - SOC_ENUM_SINGLE_EXT(7, hdmi_rx_ch_text), - SOC_ENUM_SINGLE_EXT(2, mi2s_rate), - SOC_ENUM_SINGLE_EXT(2, hdmi_rate), - -}; - -static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__, - msm_slim_0_rx_ch); - ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1; - return 0; -} - -static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__, - msm_slim_0_rx_ch); - return 1; -} - -static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, - msm_slim_0_tx_ch); - ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1; - return 0; -} - -static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, - msm_slim_0_tx_ch); - return 1; -} - -static int msm_hdmi_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__, - msm_hdmi_rx_ch); - ucontrol->value.integer.value[0] = msm_hdmi_rx_ch - 2; - return 0; -} - -static int msm_hdmi_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm_hdmi_rx_ch = ucontrol->value.integer.value[0] + 2; - - pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__, - msm_hdmi_rx_ch); - return 1; -} - -static int msm_mi2s_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mi2s_rate_variable = ucontrol->value.integer.value[0]; - pr_debug("%s: mi2s_rate_variable = %d\n", __func__, mi2s_rate_variable); - return 0; -} - -static int msm_mi2s_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = mi2s_rate_variable; - return 0; -} - -static int msm_hdmi_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - hdmi_rate_variable = ucontrol->value.integer.value[0]; - pr_debug("%s: hdmi_rate_variable = %d\n", __func__, hdmi_rate_variable); - return 0; -} - -static int msm_hdmi_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = hdmi_rate_variable; - return 0; -} - -static const struct snd_kcontrol_new tabla_msm_controls[] = { - SOC_ENUM_EXT("Speaker Function", msm_enum[0], msm_get_spk, - msm_set_spk), - SOC_ENUM_EXT("SLIM_0_RX Channels", msm_enum[1], - msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put), - SOC_ENUM_EXT("SLIM_0_TX Channels", msm_enum[2], - msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put), - SOC_ENUM_EXT("HDMI_RX Channels", msm_enum[3], - msm_hdmi_rx_ch_get, msm_hdmi_rx_ch_put), - SOC_ENUM_EXT("SEC RX Rate", msm_enum[4], - msm_mi2s_rate_get, - msm_mi2s_rate_put), - SOC_ENUM_EXT("HDMI RX Rate", msm_enum[5], - msm_hdmi_rate_get, - msm_hdmi_rate_put), - -}; - -static void *def_tabla_mbhc_cal(void) -{ - void *tabla_cal; - struct tabla_mbhc_btn_detect_cfg *btn_cfg; - u16 *btn_low, *btn_high; - u8 *n_ready, *n_cic, *gain; - - tabla_cal = kzalloc(TABLA_MBHC_CAL_SIZE(TABLA_MBHC_DEF_BUTTONS, - TABLA_MBHC_DEF_RLOADS), - GFP_KERNEL); - if (!tabla_cal) { - pr_err("%s: out of memory\n", __func__); - return NULL; - } - -#define S(X, Y) ((TABLA_MBHC_CAL_GENERAL_PTR(tabla_cal)->X) = (Y)) - S(t_ldoh, 100); - S(t_bg_fast_settle, 100); - S(t_shutdown_plug_rem, 255); - S(mbhc_nsa, 4); - S(mbhc_navg, 4); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_DET_PTR(tabla_cal)->X) = (Y)) - S(mic_current, TABLA_PID_MIC_5_UA); - S(hph_current, TABLA_PID_MIC_5_UA); - S(t_mic_pid, 100); - S(t_ins_complete, 250); - S(t_ins_retry, 200); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_TYPE_PTR(tabla_cal)->X) = (Y)) - S(v_no_mic, 30); - S(v_hs_max, 2400); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal)->X) = (Y)) - S(c[0], 62); - S(c[1], 124); - S(nc, 1); - S(n_meas, 3); - S(mbhc_nsc, 11); - S(n_btn_meas, 1); - S(n_btn_con, 2); - S(num_btn, TABLA_MBHC_DEF_BUTTONS); - S(v_btn_press_delta_sta, 100); - S(v_btn_press_delta_cic, 50); -#undef S - btn_cfg = TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal); - btn_low = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_LOW); - btn_high = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_HIGH); - btn_low[0] = -50; - btn_high[0] = 20; - btn_low[1] = 21; - btn_high[1] = 62; - btn_low[2] = 62; - btn_high[2] = 104; - btn_low[3] = 105; - btn_high[3] = 143; - btn_low[4] = 144; - btn_high[4] = 181; - btn_low[5] = 182; - btn_high[5] = 218; - btn_low[6] = 219; - btn_high[6] = 254; - btn_low[7] = 255; - btn_high[7] = 330; - n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY); - n_ready[0] = 80; - n_ready[1] = 68; - n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC); - n_cic[0] = 60; - n_cic[1] = 47; - gain = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_GAIN); - gain[0] = 11; - gain[1] = 9; - - return tabla_cal; -} - -static int msm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - - pr_debug("%s: ch=%d\n", __func__, - msm_slim_0_rx_ch); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - msm_slim_0_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } else { - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(cpu_dai, - msm_slim_0_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - - } -end: - return ret; -} - - -static int mpq_dtv_amp_power_up(void) -{ - int ret; - pr_debug("%s()\n", __func__); - ret = gpio_request(SX150X_GPIO(1, 14), - "DTV AMP Sleep"); - if (ret) { - pr_err("%s: DTV AMP Sleep GPIO request returns %d\n", - __func__, ret); - return ret; - } - ret = gpio_direction_output(SX150X_GPIO(1, 14), 0); - if (ret) { - pr_err("%s: DTV AMP Sleep GPIO set output returns %d\n", - __func__, ret); - return ret; - } - ret = gpio_request(SX150X_GPIO(1, 13), - "DTV AMP Mute"); - if (ret) { - pr_err("%s: DTV AMP Mute GPIO request returns %d\n", - __func__, ret); - return ret; - } - ret = gpio_direction_output(SX150X_GPIO(1, 13), 0); - if (ret) { - pr_err("%s: DTV AMP Mute GPIO set output returns %d\n", - __func__, ret); - return ret; - } - return ret; -} - -static int mpq_dtv_amp_power_down(void) -{ - int ret; - pr_debug("%s()\n", __func__); - ret = gpio_direction_output(SX150X_GPIO(1, 14), 1); - if (ret) { - pr_err("%s: DTV AMP Sleep GPIO set output failed\n", __func__); - return ret; - } - gpio_free(SX150X_GPIO(1, 14)); - - ret = gpio_direction_output(SX150X_GPIO(1, 13), 1); - if (ret) { - pr_err("%s: DTV AMP Mute GPIO set output failed\n", __func__); - return ret; - } - gpio_free(SX150X_GPIO(1, 13)); - return ret; -} - -static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - unsigned int rx_ch[TABLA_RX_MAX] = {138, 139, 140, 141, 142, 143, 144}; - unsigned int tx_ch[TABLA_TX_MAX] = {128, 129, 130, 131, 132, 133, 134, - 135, 136, 137}; - - pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); - - snd_soc_dapm_new_controls(dapm, msm_dapm_widgets, - ARRAY_SIZE(msm_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, common_audio_map, - ARRAY_SIZE(common_audio_map)); - - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - - snd_soc_dapm_sync(dapm); - - err = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_OC_HPHL | SND_JACK_OC_HPHR), - &hs_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - err = snd_soc_jack_new(codec, "Button Jack", - TABLA_JACK_BUTTON_MASK, &button_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - - err = tabla_hs_detect(codec, &mbhc_cfg); - snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), - tx_ch, ARRAY_SIZE(rx_ch), rx_ch); - - if (detect_dtv_platform) { - err = gpio_request(SX150X_GPIO(1, 11), - "DTV AMP Gain0"); - if (err) { - pr_err("%s: DTV AMP Gain0 request returns %d\n", - __func__, err); - return err; - } - err = gpio_direction_output(SX150X_GPIO(1, 11), 0); - if (err) { - pr_err("%s: DTV AMP Gain0 set output returns %d\n", - __func__, err); - return err; - } - gpio_free(SX150X_GPIO(1, 11)); - - err = gpio_request(SX150X_GPIO(1, 12), - "DTV AMP Gain1"); - if (err) { - pr_err("%s: DTV AMP Gain0 request returns %d\n", - __func__, err); - return err; - } - err = gpio_direction_output(SX150X_GPIO(1, 12), 0); - if (err) { - pr_err("%s: DTV AMP Gain1 set output returns %d\n", - __func__, err); - return err; - } - gpio_free(SX150X_GPIO(1, 12)); - - err = gpio_request(SX150X_GPIO(1, 15), - "DTV AMP Status"); - if (err) { - pr_err("%s: DTV AMP Status request returns %d\n", - __func__, err); - return err; - } - err = gpio_direction_input(SX150X_GPIO(1, 15)); - if (err) { - pr_err("%s: DTV AMP Status set output returns %d\n", - __func__, err); - return err; - } - err = mpq_dtv_amp_power_down(); - if (err) { - pr_err("%s: DTV AMP Status set output returns %d\n", - __func__, err); - return err; - } - } - return err; -} - -static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_0_rx_ch; - - return 0; -} - -static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm_slim_0_tx_ch; - - return 0; -} - -static int mpq8064_proxy_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - pr_debug("%s ()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = 2; - - return 0; -} - -static int msm_be_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s mi2s_rate_variable = %d\n", __func__, mi2s_rate_variable); - /*Configure the sample rate as 48000 KHz for the LPCM playback*/ - if (!mi2s_rate_variable) - rate->min = rate->max = 48000; - channels->min = channels->max = 2; - - return 0; -} - -static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s channels->min %u channels->max %u ()\n", __func__, - channels->min, channels->max); - - /*Configure the sample rate as 48000 KHz for the LPCM playback*/ - if (!hdmi_rate_variable) - rate->min = rate->max = 48000; - channels->min = channels->max = msm_hdmi_rx_ch; - - return 0; -} - -static int msm_mi2s_free_gpios(void) -{ - int i; - for (i = 0; i < ARRAY_SIZE(mi2s_gpio); i++) - gpio_free(mi2s_gpio[i].gpio_no); - return 0; -} - -static void msm_mi2s_shutdown(struct snd_pcm_substream *substream) -{ - if (mi2s_bit_clk) { - clk_disable_unprepare(mi2s_bit_clk); - clk_put(mi2s_bit_clk); - mi2s_bit_clk = NULL; - } -} - -static int configure_mi2s_gpio(void) -{ - int rtn; - int i; - int j; - for (i = 0; i < ARRAY_SIZE(mi2s_gpio); i++) { - rtn = gpio_request(mi2s_gpio[i].gpio_no, - mi2s_gpio[i].gpio_name); - pr_debug("%s: gpio = %d, gpio name = %s, rtn = %d\n", - __func__, - mi2s_gpio[i].gpio_no, - mi2s_gpio[i].gpio_name, - rtn); - if (rtn) { - pr_err("%s: Failed to request gpio %d\n", - __func__, - mi2s_gpio[i].gpio_no); - for (j = i; j >= 0; j--) - gpio_free(mi2s_gpio[j].gpio_no); - goto err; - } - } -err: - return rtn; -} -static int msm_mi2s_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - mi2s_bit_clk = clk_get(cpu_dai->dev, "bit_clk"); - if (IS_ERR(mi2s_bit_clk)) - return PTR_ERR(mi2s_bit_clk); - clk_set_rate(mi2s_bit_clk, 0); - ret = clk_prepare_enable(mi2s_bit_clk); - if (IS_ERR_VALUE(ret)) { - pr_err("Unable to enable mi2s_bit_clk\n"); - clk_put(mi2s_bit_clk); - return ret; - } - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - if (IS_ERR_VALUE(ret)) - pr_err("set format for CPU dai failed\n"); - return ret; -} - -static int mpq8064_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - /* PCM only supports mono output with 8khz sample rate */ - rate->min = rate->max = 8000; - channels->min = channels->max = 1; - - return 0; -} - -static int mpq8064_aux_pcm_get_gpios(void) -{ - int ret = 0; - - pr_debug("%s\n", __func__); - - ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", - __func__, GPIO_AUX_PCM_DOUT); - goto fail_dout; - } - - ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", - __func__, GPIO_AUX_PCM_DIN); - goto fail_din; - } - - ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", - __func__, GPIO_AUX_PCM_SYNC); - goto fail_sync; - } - ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", - __func__, GPIO_AUX_PCM_CLK); - goto fail_clk; - } - - return 0; - -fail_clk: - gpio_free(GPIO_AUX_PCM_SYNC); -fail_sync: - gpio_free(GPIO_AUX_PCM_DIN); -fail_din: - gpio_free(GPIO_AUX_PCM_DOUT); -fail_dout: - - return ret; -} - -static int mpq8064_aux_pcm_free_gpios(void) -{ - gpio_free(GPIO_AUX_PCM_DIN); - gpio_free(GPIO_AUX_PCM_DOUT); - gpio_free(GPIO_AUX_PCM_SYNC); - gpio_free(GPIO_AUX_PCM_CLK); - - return 0; -} - -static int msm_startup(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - if (detect_dtv_platform) - mpq_dtv_amp_power_up(); - return 0; -} - -static void msm_shutdown(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - - if (detect_dtv_platform) - mpq_dtv_amp_power_down(); -} - -static int mpq8064_auxpcm_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - - pr_debug("%s(): substream = %s\n", __func__, substream->name); - ret = mpq8064_aux_pcm_get_gpios(); - if (ret < 0) { - pr_err("%s: Aux PCM GPIO request failed\n", __func__); - return -EINVAL; - } - return 0; -} - -static void mpq8064_auxpcm_shutdown(struct snd_pcm_substream *substream) -{ - - pr_debug("%s(): substream = %s\n", __func__, substream->name); - mpq8064_aux_pcm_free_gpios(); -} - - -static struct snd_soc_ops msm_be_ops = { - .startup = msm_startup, - .hw_params = msm_hw_params, - .shutdown = msm_shutdown, -}; - -static struct snd_soc_ops mpq8064_auxpcm_be_ops = { - .startup = mpq8064_auxpcm_startup, - .shutdown = mpq8064_auxpcm_shutdown, -}; - - -static int mpq8064_sec_i2s_rx_free_gpios(void) -{ - int i; - for (i = 0; i < ARRAY_SIZE(sec_i2s_rx_gpio); i++) - gpio_free(sec_i2s_rx_gpio[i].gpio_no); - return 0; -} - -static int mpq8064_sec_i2s_rx_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - - int rate = params_rate(params); - int bit_clk_set = 0; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S16_LE: - bit_clk_set = I2S_MCLK_RATE/(rate * 2 * 16); - clk_set_rate(sec_i2s_rx_bit_clk, bit_clk_set); - break; - case SNDRV_PCM_FORMAT_S24_LE: - bit_clk_set = I2S_MCLK_RATE/(rate * 2 * 24); - clk_set_rate(sec_i2s_rx_bit_clk, bit_clk_set); - break; - default: - pr_err("wrong format\n"); - break; - } - } - return 0; -} - -static void mpq8064_sec_i2s_rx_shutdown(struct snd_pcm_substream *substream) -{ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (sec_i2s_rx_bit_clk) { - clk_disable_unprepare(sec_i2s_rx_bit_clk); - clk_put(sec_i2s_rx_bit_clk); - sec_i2s_rx_bit_clk = NULL; - } - if (sec_i2s_rx_osr_clk) { - clk_disable_unprepare(sec_i2s_rx_osr_clk); - clk_put(sec_i2s_rx_osr_clk); - sec_i2s_rx_osr_clk = NULL; - } - } - pr_info("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); -} - -static int configure_sec_i2s_rx_gpio(void) -{ - int rtn; - int i; - int j; - for (i = 0; i < ARRAY_SIZE(sec_i2s_rx_gpio); i++) { - rtn = gpio_request(sec_i2s_rx_gpio[i].gpio_no, - sec_i2s_rx_gpio[i].gpio_name); - pr_debug("%s: gpio = %d, gpio name = %s, rtn = %d\n", - __func__, - sec_i2s_rx_gpio[i].gpio_no, - sec_i2s_rx_gpio[i].gpio_name, - rtn); - if (rtn) { - pr_err("%s: Failed to request gpio %d\n", - __func__, - sec_i2s_rx_gpio[i].gpio_no); - for (j = i; j >= 0; j--) - gpio_free(sec_i2s_rx_gpio[j].gpio_no); - - goto err; - } - } -err: - return rtn; -} - -static int mpq8064_sec_i2s_rx_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - sec_i2s_rx_osr_clk = clk_get(cpu_dai->dev, "osr_clk"); - if (IS_ERR(sec_i2s_rx_osr_clk)) { - pr_err("Failed to get sec_i2s_rx_osr_clk\n"); - return PTR_ERR(sec_i2s_rx_osr_clk); - } - clk_set_rate(sec_i2s_rx_osr_clk, I2S_MCLK_RATE); - clk_prepare_enable(sec_i2s_rx_osr_clk); - sec_i2s_rx_bit_clk = clk_get(cpu_dai->dev, "bit_clk"); - if (IS_ERR(sec_i2s_rx_bit_clk)) { - pr_err("Failed to get sec i2s osr_clk\n"); - clk_disable_unprepare(sec_i2s_rx_osr_clk); - clk_put(sec_i2s_rx_osr_clk); - return PTR_ERR(sec_i2s_rx_bit_clk); - } - clk_set_rate(sec_i2s_rx_bit_clk, 1); - ret = clk_prepare_enable(sec_i2s_rx_bit_clk); - if (ret != 0) { - pr_err("Unable to enable sec i2s rx_bit_clk\n"); - clk_put(sec_i2s_rx_bit_clk); - clk_disable_unprepare(sec_i2s_rx_osr_clk); - clk_put(sec_i2s_rx_osr_clk); - return ret; - } - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS); - if (ret < 0) - pr_err("set format for codec dai failed\n"); - } - pr_debug("%s: ret = %d\n", __func__, ret); - pr_info("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - return ret; -} - -static struct snd_soc_ops mpq8064_sec_i2s_rx_be_ops = { - .startup = mpq8064_sec_i2s_rx_startup, - .shutdown = mpq8064_sec_i2s_rx_shutdown, - .hw_params = mpq8064_sec_i2s_rx_hw_params, -}; - -static struct snd_soc_ops msm_mi2s_tx_be_ops = { - .startup = msm_mi2s_startup, - .shutdown = msm_mi2s_shutdown, -}; - - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm_dai[] = { - /* FrontEnd DAI Links */ - { - .name = "MSM8960 Media1", - .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MSM8960 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - { - .name = "Circuit-Switch Voice", - .stream_name = "CS-Voice", - .cpu_dai_name = "CS-VOICE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .be_id = MSM_FRONTEND_DAI_CS_VOICE, - }, - { - .name = "MSM VoIP", - .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_VOIP, - }, - { - .name = "MSM8960 Media3", - .stream_name = "MultiMedia3", - .cpu_dai_name = "MultiMedia3", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3, - }, - /* Hostless PMC purpose */ - { - .name = "SLIMBUS_0 Hostless", - .stream_name = "SLIMBUS_0 Hostless", - .cpu_dai_name = "SLIMBUS0_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "INT_FM Hostless", - .stream_name = "INT_FM Hostless", - .cpu_dai_name = "INT_FM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "MSM AFE-PCM RX", - .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = "MSM AFE-PCM TX", - .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "MSM8960 Compr1", - .stream_name = "COMPR1", - .cpu_dai_name = "MultiMedia4", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4, - }, - { - .name = "Voice Stub", - .stream_name = "Voice Stub", - .cpu_dai_name = "VOICE_STUB", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* HDMI Hostless */ - { - .name = "HDMI_RX_HOSTLESS", - .stream_name = "HDMI_RX_HOSTLESS", - .cpu_dai_name = "HDMI_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* MI2S TX Hostless */ - { - .name = "MI2S_TX Hostless", - .stream_name = "MI2S_TX Hostless", - .cpu_dai_name = "MI2S_TX_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* Secondary I2S RX Hostless */ - { - .name = "SEC_I2S_RX Hostless", - .stream_name = "SEC_I2S_RX Hostless", - .cpu_dai_name = "SEC_I2S_RX_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "MSM8960 Media5", - .stream_name = "MultiMedia5", - .cpu_dai_name = "MultiMedia5", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5 - }, - { - .name = "MSM8960 Media6", - .stream_name = "MultiMedia6", - .cpu_dai_name = "MultiMedia6", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6 - }, - { - .name = "MSM8960 Compr2", - .stream_name = "COMPR2", - .cpu_dai_name = "MultiMedia7", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7, - }, - { - .name = "MSM8960 Compr3", - .stream_name = "COMPR3", - .cpu_dai_name = "MultiMedia8", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8, - }, - { - .name = "AUXPCM Hostless", - .stream_name = "AUXPCM Hostless", - .cpu_dai_name = "AUXPCM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - - }, - { - .name = "MSM8960 Pseudo", - .stream_name = "Pseudo", - .cpu_dai_name = "Pseudo", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_PSEUDO, - }, - /* Backend DAI Links */ - { - .name = LPASS_BE_SLIMBUS_0_RX, - .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX, - .init = &msm_audrx_init, - .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, - .ops = &msm_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_0_TX, - .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX, - .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup, - .ops = &msm_be_ops, - }, - { - .name = LPASS_BE_SEC_I2S_RX, - .stream_name = "Secondary I2S Playback", - .cpu_dai_name = "msm-dai-q6.4", - .platform_name = "msm-pcm-routing", - .codec_name = "cs8427-spdif.5-0014", - .codec_dai_name = "spdif_rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SEC_I2S_RX, - .be_hw_params_fixup = msm_be_i2s_hw_params_fixup, - .ops = &mpq8064_sec_i2s_rx_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_FM_RX, - .stream_name = "Internal FM Playback", - .cpu_dai_name = "msm-dai-q6.12292", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_RX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_FM_TX, - .stream_name = "Internal FM Capture", - .cpu_dai_name = "msm-dai-q6.12293", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_TX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - }, - /* HDMI BACK END DAI Link */ - { - .name = LPASS_BE_HDMI, - .stream_name = "HDMI Playback", - .cpu_dai_name = "msm-dai-q6-hdmi.8", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_HDMI_RX, - .be_hw_params_fixup = msm_hdmi_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_MI2S_TX, - .stream_name = "MI2S Capture", - .cpu_dai_name = "msm-dai-q6-mi2s", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_MI2S_TX, - .be_hw_params_fixup = msm_be_hw_params_fixup, - .ops = &msm_mi2s_tx_be_ops, - }, - /* Backend AFE DAI Links */ - { - .name = LPASS_BE_AFE_PCM_RX, - .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, - .be_hw_params_fixup = mpq8064_proxy_be_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_AFE_PCM_TX, - .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_hw_params_fixup = mpq8064_proxy_be_params_fixup, - .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, - }, - /* AUX PCM Backend DAI Links */ - { - .name = LPASS_BE_AUXPCM_RX, - .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_RX, - .be_hw_params_fixup = mpq8064_auxpcm_be_params_fixup, - .ops = &mpq8064_auxpcm_be_ops, - .ignore_pmdown_time = 1, - }, - { - .name = LPASS_BE_AUXPCM_TX, - .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_TX, - .be_hw_params_fixup = mpq8064_auxpcm_be_params_fixup, - }, - { - .name = LPASS_BE_PSEUDO, - .stream_name = "PSEUDO Playback", - .cpu_dai_name = "msm-dai-q6.32769", - .platform_name = "msm-pcm-routing", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_PSEUDO_PORT, - .be_hw_params_fixup = msm_be_hw_params_fixup, - .ignore_pmdown_time = 1, - }, -}; - - -static struct snd_soc_card snd_soc_card_msm = { - .name = "mpq8064-tabla-snd-card", - .dai_link = msm_dai, - .num_links = ARRAY_SIZE(msm_dai), - .controls = tabla_msm_controls, - .num_controls = ARRAY_SIZE(tabla_msm_controls), -}; - -static struct platform_device *msm_snd_device; - -static int __init msm_audio_init(void) -{ - int ret; - - if (socinfo_get_id() != 130) { - pr_err("%s: Not the right machine type\n", __func__); - return -ENODEV; - } - - if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) - bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(16); - if (machine_is_mpq8064_dtv()) - detect_dtv_platform = 1; - pr_info("MPQ8064: detect_dtv_platform is %d\n", detect_dtv_platform); - mbhc_cfg.calibration = def_tabla_mbhc_cal(); - if (!mbhc_cfg.calibration) { - pr_err("Calibration data allocation failed\n"); - return -ENOMEM; - } - - msm_snd_device = platform_device_alloc("soc-audio", 0); - if (!msm_snd_device) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - - platform_set_drvdata(msm_snd_device, &snd_soc_card_msm); - ret = platform_device_add(msm_snd_device); - if (ret) { - platform_device_put(msm_snd_device); - kfree(mbhc_cfg.calibration); - return ret; - } - configure_sec_i2s_rx_gpio(); - configure_mi2s_gpio(); - return ret; - -} -module_init(msm_audio_init); - -static void __exit msm_audio_exit(void) -{ - if (socinfo_get_id() != 130) { - pr_err("%s: Not the right machine type\n", __func__); - return ; - } - mpq8064_sec_i2s_rx_free_gpios(); - msm_mi2s_free_gpios(); - platform_device_unregister(msm_snd_device); - kfree(mbhc_cfg.calibration); -} -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC mpq8064"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-compr-q6.c b/sound/soc/msm/msm-compr-q6.c deleted file mode 100644 index 180ea4e79c309cd6cdb4bb903373f0ea6b255d3f..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-compr-q6.c +++ /dev/null @@ -1,1397 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "msm-compr-q6.h" -#include "msm-pcm-routing.h" - -#define COMPRE_CAPTURE_NUM_PERIODS 16 -/* Allocate the worst case frame size for compressed audio */ -#define COMPRE_CAPTURE_HEADER_SIZE (sizeof(struct snd_compr_audio_info)) -#define COMPRE_CAPTURE_MAX_FRAME_SIZE (6144) -#define COMPRE_CAPTURE_PERIOD_SIZE ((COMPRE_CAPTURE_MAX_FRAME_SIZE + \ - COMPRE_CAPTURE_HEADER_SIZE) * \ - MAX_NUM_FRAMES_PER_BUFFER) -#define COMPRE_OUTPUT_METADATA_SIZE (sizeof(struct output_meta_data_st)) - -struct snd_msm { - struct msm_audio *prtd; - unsigned volume; -}; -static struct snd_msm compressed_audio = {NULL, 0x2000} ; - -static struct audio_locks the_locks; - -static struct snd_pcm_hardware msm_compr_hardware_capture = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 8, - .buffer_bytes_max = - COMPRE_CAPTURE_PERIOD_SIZE * COMPRE_CAPTURE_NUM_PERIODS , - .period_bytes_min = COMPRE_CAPTURE_PERIOD_SIZE, - .period_bytes_max = COMPRE_CAPTURE_PERIOD_SIZE, - .periods_min = COMPRE_CAPTURE_NUM_PERIODS, - .periods_max = COMPRE_CAPTURE_NUM_PERIODS, - .fifo_size = 0, -}; - -static struct snd_pcm_hardware msm_compr_hardware_playback = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 8, - .buffer_bytes_max = 1024 * 1024, - .period_bytes_min = 128 * 1024, - .period_bytes_max = 256 * 1024, - .periods_min = 4, - .periods_max = 8, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static void compr_event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ - struct compr_audio *compr = priv; - struct msm_audio *prtd = &compr->prtd; - struct snd_pcm_substream *substream = prtd->substream; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_aio_write_param param; - struct audio_aio_read_param read_param; - struct audio_buffer *buf = NULL; - struct output_meta_data_st output_meta_data; - uint32_t *ptrmem = (uint32_t *)payload; - int i = 0; - int time_stamp_flag = 0; - int buffer_length = 0; - - pr_debug("%s opcode =%08x\n", __func__, opcode); - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: { - uint32_t *ptrmem = (uint32_t *)¶m; - pr_debug("ASM_DATA_EVENT_WRITE_DONE\n"); - pr_debug("Buffer Consumed = 0x%08x\n", *ptrmem); - prtd->pcm_irq_pos += prtd->pcm_count; - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - else - if (substream->timer_running) - snd_timer_interrupt(substream->timer, 1); - atomic_inc(&prtd->out_count); - wake_up(&the_locks.write_wait); - if (!atomic_read(&prtd->start)) { - atomic_set(&prtd->pending_buffer, 1); - break; - } else - atomic_set(&prtd->pending_buffer, 0); - if (runtime->status->hw_ptr >= runtime->control->appl_ptr) { - runtime->render_flag |= SNDRV_RENDER_STOPPED; - atomic_set(&prtd->pending_buffer, 1); - pr_debug("%s:compr driver underrun hw_ptr = %ld appl_ptr = %ld\n", - __func__, runtime->status->hw_ptr, - runtime->control->appl_ptr); - break; - } - buf = prtd->audio_client->port[IN].buf; - pr_debug("%s:writing %d bytes of buffer[%d] to dsp 2\n", - __func__, prtd->pcm_count, prtd->out_head); - pr_debug("%s:writing buffer[%d] from 0x%08x\n", - __func__, prtd->out_head, - ((unsigned int)buf[0].phys - + (prtd->out_head * prtd->pcm_count))); - - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) - time_stamp_flag = SET_TIMESTAMP; - else - time_stamp_flag = NO_TIMESTAMP; - memcpy(&output_meta_data, (char *)(buf->data + - prtd->out_head * prtd->pcm_count), - COMPRE_OUTPUT_METADATA_SIZE); - - buffer_length = output_meta_data.frame_size; - pr_debug("meta_data_length: %d, frame_length: %d\n", - output_meta_data.meta_data_length, - output_meta_data.frame_size); - pr_debug("timestamp_msw: %d, timestamp_lsw: %d\n", - output_meta_data.timestamp_msw, - output_meta_data.timestamp_lsw); - if (buffer_length == 0) { - pr_debug("Recieved a zero length buffer-break out"); - break; - } - param.paddr = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count) - + output_meta_data.meta_data_length; - param.len = buffer_length; - param.msw_ts = output_meta_data.timestamp_msw; - param.lsw_ts = output_meta_data.timestamp_lsw; - param.flags = time_stamp_flag; - param.uid = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count - + output_meta_data.meta_data_length); - for (i = 0; i < sizeof(struct audio_aio_write_param)/4; - i++, ++ptrmem) - pr_debug("cmd[%d]=0x%08x\n", i, *ptrmem); - if (q6asm_async_write(prtd->audio_client, - ¶m) < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - else - prtd->out_head = - (prtd->out_head + 1) & (runtime->periods - 1); - break; - } - case ASM_DATA_CMDRSP_EOS: - pr_debug("ASM_DATA_CMDRSP_EOS\n"); - if (atomic_read(&prtd->eos)) { - pr_debug("ASM_DATA_CMDRSP_EOS wake up\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - atomic_set(&prtd->eos, 0); - } - atomic_set(&prtd->pending_buffer, 1); - break; - case ASM_DATA_EVENT_READ_DONE: { - pr_debug("ASM_DATA_EVENT_READ_DONE\n"); - pr_debug("buf = %p, data = 0x%X, *data = %p,\n" - "prtd->pcm_irq_pos = %d\n", - prtd->audio_client->port[OUT].buf, - *(uint32_t *)prtd->audio_client->port[OUT].buf->data, - prtd->audio_client->port[OUT].buf->data, - prtd->pcm_irq_pos); - - memcpy(prtd->audio_client->port[OUT].buf->data + - prtd->pcm_irq_pos, (ptrmem + 2), - COMPRE_CAPTURE_HEADER_SIZE); - pr_debug("buf = %p, updated data = 0x%X, *data = %p\n", - prtd->audio_client->port[OUT].buf, - *(uint32_t *)(prtd->audio_client->port[OUT].buf->data + - prtd->pcm_irq_pos), - prtd->audio_client->port[OUT].buf->data); - if (!atomic_read(&prtd->start)) - break; - pr_debug("frame size=%d, buffer = 0x%X\n", ptrmem[2], - ptrmem[1]); - if (ptrmem[2] > COMPRE_CAPTURE_MAX_FRAME_SIZE) { - pr_err("Frame length exceeded the max length"); - break; - } - buf = prtd->audio_client->port[OUT].buf; - pr_debug("pcm_irq_pos=%d, buf[0].phys = 0x%X\n", - prtd->pcm_irq_pos, (uint32_t)buf[0].phys); - read_param.len = prtd->pcm_count - COMPRE_CAPTURE_HEADER_SIZE; - read_param.paddr = (unsigned long)(buf[0].phys) + - prtd->pcm_irq_pos + COMPRE_CAPTURE_HEADER_SIZE; - prtd->pcm_irq_pos += prtd->pcm_count; - - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - - q6asm_async_read(prtd->audio_client, &read_param); - break; - } - case ASM_DATA_EVENT_READ_COMPRESSED_DONE: { - pr_debug("ASM_DATA_EVENT_READ_COMPRESSED_DONE\n"); - pr_debug("buf = %p, data = 0x%X, *data = %p,\n" - "prtd->pcm_irq_pos = %d\n", - prtd->audio_client->port[OUT].buf, - *(uint32_t *)prtd->audio_client->port[OUT].buf->data, - prtd->audio_client->port[OUT].buf->data, - prtd->pcm_irq_pos); - - if (!atomic_read(&prtd->start)) - break; - buf = prtd->audio_client->port[OUT].buf; - pr_debug("pcm_irq_pos=%d, buf[0].phys = 0x%X\n", - prtd->pcm_irq_pos, (uint32_t)buf[0].phys); - read_param.len = prtd->pcm_count; - read_param.paddr = (unsigned long)(buf[0].phys) + - prtd->pcm_irq_pos; - prtd->pcm_irq_pos += prtd->pcm_count; - - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - - q6asm_async_read_compressed(prtd->audio_client, &read_param); - break; - } - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case ASM_SESSION_CMD_RUN: { - if (substream->stream - != SNDRV_PCM_STREAM_PLAYBACK) { - atomic_set(&prtd->start, 1); - break; - } - if (!atomic_read(&prtd->pending_buffer)) - break; - pr_debug("%s:writing %d bytes" - " of buffer[%d] to dsp\n", - __func__, prtd->pcm_count, prtd->out_head); - buf = prtd->audio_client->port[IN].buf; - pr_debug("%s:writing buffer[%d] from 0x%08x\n", - __func__, prtd->out_head, - ((unsigned int)buf[0].phys - + (prtd->out_head * prtd->pcm_count))); - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) - time_stamp_flag = SET_TIMESTAMP; - else - time_stamp_flag = NO_TIMESTAMP; - memcpy(&output_meta_data, (char *)(buf->data + - prtd->out_head * prtd->pcm_count), - COMPRE_OUTPUT_METADATA_SIZE); - buffer_length = output_meta_data.frame_size; - pr_debug("meta_data_length: %d, frame_length: %d\n", - output_meta_data.meta_data_length, - output_meta_data.frame_size); - pr_debug("timestamp_msw: %d, timestamp_lsw: %d\n", - output_meta_data.timestamp_msw, - output_meta_data.timestamp_lsw); - param.paddr = (unsigned long)buf[prtd->out_head].phys - + output_meta_data.meta_data_length; - param.len = buffer_length; - param.msw_ts = output_meta_data.timestamp_msw; - param.lsw_ts = output_meta_data.timestamp_lsw; - param.flags = time_stamp_flag; - param.uid = (unsigned long)buf[prtd->out_head].phys - + output_meta_data.meta_data_length; - if (q6asm_async_write(prtd->audio_client, - ¶m) < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - else - prtd->out_head = - (prtd->out_head + 1) - & (runtime->periods - 1); - atomic_set(&prtd->pending_buffer, 0); - } - break; - case ASM_STREAM_CMD_FLUSH: - pr_debug("ASM_STREAM_CMD_FLUSH\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.flush_wait); - break; - default: - break; - } - break; - } - default: - pr_debug("Not Supported Event opcode[0x%x]\n", opcode); - break; - } -} - -static int msm_compr_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr = runtime->private_data; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = &compr->prtd; - struct asm_aac_cfg aac_cfg; - struct asm_wma_cfg wma_cfg; - struct asm_wmapro_cfg wma_pro_cfg; - struct asm_amrwbplus_cfg amrwb_cfg; - int ret; - - pr_debug("compressed stream prepare\n"); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - prtd->out_head = 0; - atomic_set(&prtd->out_count, runtime->periods); - - if (prtd->enabled) - return 0; - - switch (compr->info.codec_param.codec.id) { - case SND_AUDIOCODEC_MP3: - pr_debug("%s: SND_AUDIOCODEC_MP3\n", __func__); - ret = q6asm_media_format_block(prtd->audio_client, - compr->codec); - if (ret < 0) - pr_info("%s: CMD Format block failed\n", __func__); - break; - case SND_AUDIOCODEC_AAC: - pr_debug("%s: SND_AUDIOCODEC_AAC\n", __func__); - memset(&aac_cfg, 0x0, sizeof(struct asm_aac_cfg)); - aac_cfg.aot = AAC_ENC_MODE_EAAC_P; - aac_cfg.format = 0x03; - aac_cfg.ch_cfg = runtime->channels; - aac_cfg.sample_rate = runtime->rate; - ret = q6asm_media_format_block_aac(prtd->audio_client, - &aac_cfg); - if (ret < 0) - pr_err("%s: CMD Format block failed\n", __func__); - break; - case SND_AUDIOCODEC_AC3_PASS_THROUGH: - case SND_AUDIOCODEC_DTS_PASS_THROUGH: - case SND_AUDIOCODEC_DTS_LBR_PASS_THROUGH: - pr_debug("compressd playback, no need to send decoder params"); - pr_debug("decoder id: %d\n", - compr->info.codec_param.codec.id); - msm_pcm_routing_reg_psthr_stream( - soc_prtd->dai_link->be_id, - prtd->session_id, substream->stream, - 1); - break; - case SND_AUDIOCODEC_WMA: - pr_debug("SND_AUDIOCODEC_WMA\n"); - memset(&wma_cfg, 0x0, sizeof(struct asm_wma_cfg)); - wma_cfg.format_tag = compr->info.codec_param.codec.format; - wma_cfg.ch_cfg = compr->info.codec_param.codec.ch_in; - wma_cfg.sample_rate = compr->info.codec_param.codec.sample_rate; - wma_cfg.avg_bytes_per_sec = - compr->info.codec_param.codec.bit_rate/8; - wma_cfg.block_align = compr->info.codec_param.codec.align; - wma_cfg.valid_bits_per_sample = - compr->info.codec_param.codec.options.wma.bits_per_sample; - wma_cfg.ch_mask = - compr->info.codec_param.codec.options.wma.channelmask; - wma_cfg.encode_opt = - compr->info.codec_param.codec.options.wma.encodeopt; - ret = q6asm_media_format_block_wma(prtd->audio_client, - &wma_cfg); - if (ret < 0) - pr_err("%s: CMD Format block failed\n", __func__); - break; - case SND_AUDIOCODEC_WMA_PRO: - pr_debug("SND_AUDIOCODEC_WMA_PRO\n"); - memset(&wma_pro_cfg, 0x0, sizeof(struct asm_wmapro_cfg)); - wma_pro_cfg.format_tag = compr->info.codec_param.codec.format; - wma_pro_cfg.ch_cfg = compr->info.codec_param.codec.ch_in; - wma_pro_cfg.sample_rate = - compr->info.codec_param.codec.sample_rate; - wma_pro_cfg.avg_bytes_per_sec = - compr->info.codec_param.codec.bit_rate/8; - wma_pro_cfg.block_align = compr->info.codec_param.codec.align; - wma_pro_cfg.valid_bits_per_sample = - compr->info.codec_param.codec\ - .options.wma.bits_per_sample; - wma_pro_cfg.ch_mask = - compr->info.codec_param.codec.options.wma.channelmask; - wma_pro_cfg.encode_opt = - compr->info.codec_param.codec.options.wma.encodeopt; - wma_pro_cfg.adv_encode_opt = - compr->info.codec_param.codec.options.wma.encodeopt1; - wma_pro_cfg.adv_encode_opt2 = - compr->info.codec_param.codec.options.wma.encodeopt2; - ret = q6asm_media_format_block_wmapro(prtd->audio_client, - &wma_pro_cfg); - if (ret < 0) - pr_err("%s: CMD Format block failed\n", __func__); - break; - case SND_AUDIOCODEC_DTS: - case SND_AUDIOCODEC_DTS_LBR: - pr_debug("SND_AUDIOCODEC_DTS\n"); - ret = q6asm_media_format_block(prtd->audio_client, - compr->codec); - if (ret < 0) { - pr_err("%s: CMD Format block failed\n", __func__); - return ret; - } - break; - case SND_AUDIOCODEC_AMRWB: - pr_debug("SND_AUDIOCODEC_AMRWB\n"); - ret = q6asm_media_format_block(prtd->audio_client, - compr->codec); - if (ret < 0) { - pr_err("%s: CMD Format block failed\n", __func__); - return ret; - } - break; - case SND_AUDIOCODEC_AMRWBPLUS: - pr_debug("SND_AUDIOCODEC_AMRWBPLUS\n"); - memset(&amrwb_cfg, 0x0, sizeof(struct asm_amrwbplus_cfg)); - amrwb_cfg.size_bytes = sizeof(struct asm_amrwbplus_cfg); - pr_debug("calling q6asm_media_format_block_amrwbplus"); - ret = q6asm_media_format_block_amrwbplus(prtd->audio_client, - &amrwb_cfg); - if (ret < 0) { - pr_err("%s: CMD Format block failed\n", __func__); - return ret; - } - break; - case SND_AUDIOCODEC_MP2: - pr_debug("%s: SND_AUDIOCODEC_MP2\n", __func__); - break; - default: - return -EINVAL; - } - if (compr->info.codec_param.codec.transcode_dts) { - msm_pcm_routing_reg_pseudo_stream( - MSM_FRONTEND_DAI_PSEUDO, - prtd->enc_audio_client->perf_mode, - prtd->enc_audio_client->session, - SNDRV_PCM_STREAM_CAPTURE, - 48000, runtime->channels > 6 ? - 6 : runtime->channels); - pr_debug("%s: cmd: DTS ENCDEC CFG BLK\n", __func__); - ret = q6asm_enc_cfg_blk_dts(prtd->enc_audio_client, - DTS_ENC_SAMPLE_RATE48k, - runtime->channels > 6 ? - 6 : runtime->channels); - if (ret < 0) - pr_err("%s: CMD: DTS ENCDEC CFG BLK failed\n", - __func__); - } - prtd->enabled = 1; - prtd->cmd_ack = 0; - - return 0; -} - -static int msm_compr_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr = runtime->private_data; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = &compr->prtd; - struct audio_buffer *buf = prtd->audio_client->port[OUT].buf; - struct snd_codec *codec = &compr->info.codec_param.codec; - struct audio_aio_read_param read_param; - int ret = 0; - int i; - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - - if (prtd->enabled) - return ret; - read_param.len = prtd->pcm_count; - - switch (codec->id) { - case SND_AUDIOCODEC_AMRWB: - pr_debug("SND_AUDIOCODEC_AMRWB\n"); - ret = q6asm_enc_cfg_blk_amrwb(prtd->audio_client, - MAX_NUM_FRAMES_PER_BUFFER, - codec->options.generic.reserved[0] /*bitrate 0-8*/, - codec->options.generic.reserved[1] /*dtx mode 0/1*/); - if (ret < 0) - pr_err("%s: CMD Format block" \ - "failed: %d\n", __func__, ret); - break; - case SND_AUDIOCODEC_PCM: - pr_debug("SND_AUDIOCODEC_PCM\n"); - ret = q6asm_enc_cfg_blk_multi_ch_pcm(prtd->audio_client, - prtd->samp_rate, prtd->channel_mode); - if (ret < 0) - pr_info("%s: CMD Format block failed\n", __func__); - break; - default: - pr_debug("No config for codec %d\n", codec->id); - } - pr_debug("%s: Samp_rate = %d, Channel = %d, pcm_size = %d,\n" - "pcm_count = %d, periods = %d\n", - __func__, prtd->samp_rate, prtd->channel_mode, - prtd->pcm_size, prtd->pcm_count, runtime->periods); - - for (i = 0; i < runtime->periods; i++) { - read_param.uid = i; - switch (codec->id) { - case SND_AUDIOCODEC_AMRWB: - case SND_AUDIOCODEC_PCM: - read_param.len = prtd->pcm_count - - COMPRE_CAPTURE_HEADER_SIZE; - read_param.paddr = (unsigned long)(buf[i].phys) - + COMPRE_CAPTURE_HEADER_SIZE; - pr_debug("Push buffer [%d] to DSP, "\ - "paddr: %p, vaddr: %p\n", - i, (void *) read_param.paddr, - buf[i].data); - q6asm_async_read(prtd->audio_client, &read_param); - break; - case SND_AUDIOCODEC_PASS_THROUGH: - read_param.paddr = (unsigned long)(buf[i].phys); - q6asm_async_read_compressed(prtd->audio_client, - &read_param); - break; - default: - pr_err("Invalid format"); - ret = -EINVAL; - break; - } - } - prtd->periods = runtime->periods; - - prtd->enabled = 1; - - if (compr->info.codec_param.codec.id == - SND_AUDIOCODEC_PASS_THROUGH) - msm_pcm_routing_reg_psthr_stream( - soc_prtd->dai_link->be_id, - prtd->session_id, substream->stream, - 1); - - return ret; -} - -static int msm_compr_restart(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - struct audio_aio_write_param param; - struct audio_buffer *buf = NULL; - struct output_meta_data_st output_meta_data; - int time_stamp_flag = 0; - int buffer_length = 0; - - pr_err("msm_compr_restart\n"); - if (runtime->render_flag & SNDRV_RENDER_STOPPED) { - buf = prtd->audio_client->port[IN].buf; - pr_debug("%s:writing %d bytes of buffer[%d] to dsp 2\n", - __func__, prtd->pcm_count, prtd->out_head); - pr_debug("%s:writing buffer[%d] from 0x%08x\n", - __func__, prtd->out_head, - ((unsigned int)buf[0].phys - + (prtd->out_head * prtd->pcm_count))); - - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) - time_stamp_flag = SET_TIMESTAMP; - else - time_stamp_flag = NO_TIMESTAMP; - memcpy(&output_meta_data, (char *)(buf->data + - prtd->out_head * prtd->pcm_count), - COMPRE_OUTPUT_METADATA_SIZE); - - buffer_length = output_meta_data.frame_size; - pr_debug("meta_data_length: %d, frame_length: %d\n", - output_meta_data.meta_data_length, - output_meta_data.frame_size); - pr_debug("timestamp_msw: %d, timestamp_lsw: %d\n", - output_meta_data.timestamp_msw, - output_meta_data.timestamp_lsw); - if (buffer_length == 0) { - pr_debug("Recieved a zero length buffer-break out"); - return -EINVAL; - } - param.paddr = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count) - + output_meta_data.meta_data_length; - param.len = buffer_length; - param.msw_ts = output_meta_data.timestamp_msw; - param.lsw_ts = output_meta_data.timestamp_lsw; - param.flags = time_stamp_flag; - param.uid = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count - + output_meta_data.meta_data_length); - if (q6asm_async_write(prtd->audio_client, - ¶m) < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - else - prtd->out_head = - (prtd->out_head + 1) & (runtime->periods - 1); - - runtime->render_flag &= ~SNDRV_RENDER_STOPPED; - return 0; - } - return 0; -} - -static int msm_compr_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - - pr_debug("%s\n", __func__); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - prtd->pcm_irq_pos = 0; - /* intentional fall-through */ - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("%s: Trigger start\n", __func__); - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); - if (prtd->enc_audio_client) - q6asm_run_nowait(prtd->enc_audio_client, 0, 0, 0); - atomic_set(&prtd->start, 1); - break; - case SNDRV_PCM_TRIGGER_STOP: - atomic_set(&prtd->start, 0); - runtime->render_flag &= ~SNDRV_RENDER_STOPPED; - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("SNDRV_PCM_TRIGGER_PAUSE\n"); - q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE); - if (prtd->enc_audio_client) - q6asm_cmd_nowait(prtd->enc_audio_client, CMD_PAUSE); - atomic_set(&prtd->start, 0); - runtime->render_flag &= ~SNDRV_RENDER_STOPPED; - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static void populate_codec_list(struct compr_audio *compr, - struct snd_pcm_runtime *runtime) -{ - pr_debug("%s\n", __func__); - /* MP3 Block */ - compr->info.compr_cap.num_codecs = 14; - compr->info.compr_cap.min_fragment_size = runtime->hw.period_bytes_min; - compr->info.compr_cap.max_fragment_size = runtime->hw.period_bytes_max; - compr->info.compr_cap.min_fragments = runtime->hw.periods_min; - compr->info.compr_cap.max_fragments = runtime->hw.periods_max; - compr->info.compr_cap.codecs[0] = SND_AUDIOCODEC_MP3; - compr->info.compr_cap.codecs[1] = SND_AUDIOCODEC_AAC; - compr->info.compr_cap.codecs[2] = SND_AUDIOCODEC_AC3_PASS_THROUGH; - compr->info.compr_cap.codecs[3] = SND_AUDIOCODEC_WMA; - compr->info.compr_cap.codecs[4] = SND_AUDIOCODEC_WMA_PRO; - compr->info.compr_cap.codecs[5] = SND_AUDIOCODEC_DTS; - compr->info.compr_cap.codecs[6] = SND_AUDIOCODEC_DTS_LBR; - compr->info.compr_cap.codecs[7] = SND_AUDIOCODEC_DTS_PASS_THROUGH; - compr->info.compr_cap.codecs[8] = SND_AUDIOCODEC_AMRWB; - compr->info.compr_cap.codecs[9] = SND_AUDIOCODEC_AMRWBPLUS; - compr->info.compr_cap.codecs[10] = SND_AUDIOCODEC_PASS_THROUGH; - compr->info.compr_cap.codecs[11] = SND_AUDIOCODEC_PCM; - compr->info.compr_cap.codecs[12] = SND_AUDIOCODEC_MP2; - compr->info.compr_cap.codecs[13] = SND_AUDIOCODEC_DTS_LBR_PASS_THROUGH; - /* Add new codecs here and update num_codecs*/ -} - -static int msm_compr_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr; - struct msm_audio *prtd; - int ret = 0; - struct asm_softpause_params softpause = { - .enable = SOFT_PAUSE_ENABLE, - .period = SOFT_PAUSE_PERIOD, - .step = SOFT_PAUSE_STEP, - .rampingcurve = SOFT_PAUSE_CURVE_LINEAR, - }; - struct asm_softvolume_params softvol = { - .period = SOFT_VOLUME_PERIOD, - .step = SOFT_VOLUME_STEP, - .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, - }; - - pr_debug("%s\n", __func__); - compr = kzalloc(sizeof(struct compr_audio), GFP_KERNEL); - if (compr == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - return -ENOMEM; - } - prtd = &compr->prtd; - prtd->substream = substream; - runtime->render_flag = SNDRV_DMA_MODE; - prtd->audio_client = q6asm_audio_client_alloc( - (app_cb)compr_event_handler, compr); - if (!prtd->audio_client) { - pr_info("%s: Could not allocate memory\n", __func__); - kfree(prtd); - return -ENOMEM; - } - prtd->audio_client->perf_mode = false; - pr_info("%s: session ID %d\n", __func__, prtd->audio_client->session); - - prtd->session_id = prtd->audio_client->session; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw = msm_compr_hardware_playback; - prtd->cmd_ack = 1; - } else { - runtime->hw = msm_compr_hardware_capture; - } - - - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_info("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_info("snd_pcm_hw_constraint_integer failed\n"); - - prtd->dsp_cnt = 0; - atomic_set(&prtd->pending_buffer, 1); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - compr->codec = FORMAT_MP3; - populate_codec_list(compr, runtime); - runtime->private_data = compr; - atomic_set(&prtd->eos, 0); - compressed_audio.prtd = &compr->prtd; - ret = compressed_set_volume(0); - if (ret < 0) - pr_err("%s : Set Volume failed : %d", __func__, ret); - - ret = q6asm_set_softpause(compressed_audio.prtd->audio_client, - &softpause); - if (ret < 0) - pr_err("%s: Send SoftPause Param failed ret=%d\n", - __func__, ret); - ret = q6asm_set_softvolume(compressed_audio.prtd->audio_client, - &softvol); - if (ret < 0) - pr_err("%s: Send SoftVolume Param failed ret=%d\n", - __func__, ret); - - return 0; -} - -int compressed_set_volume(unsigned volume) -{ - int rc = 0; - if (compressed_audio.prtd && compressed_audio.prtd->audio_client) { - rc = q6asm_set_volume(compressed_audio.prtd->audio_client, - volume); - if (rc < 0) { - pr_err("%s: Send Volume command failed" - " rc=%d\n", __func__, rc); - } - } - compressed_audio.volume = volume; - return rc; -} - -static int msm_compr_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - int dir = 0; - - pr_debug("%s\n", __func__); - - dir = IN; - atomic_set(&prtd->pending_buffer, 0); - prtd->pcm_irq_pos = 0; - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - if (prtd->enc_audio_client) - q6asm_cmd(prtd->enc_audio_client, CMD_CLOSE); - compressed_audio.prtd = NULL; - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - switch (compr->info.codec_param.codec.id) { - case SND_AUDIOCODEC_AC3_PASS_THROUGH: - case SND_AUDIOCODEC_DTS_PASS_THROUGH: - case SND_AUDIOCODEC_DTS_LBR_PASS_THROUGH: - msm_pcm_routing_reg_psthr_stream( - soc_prtd->dai_link->be_id, - prtd->session_id, substream->stream, - 0); - default: - msm_pcm_routing_dereg_phy_stream( - soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_PLAYBACK); - } - if (compr->info.codec_param.codec.transcode_dts) { - msm_pcm_routing_dereg_pseudo_stream(MSM_FRONTEND_DAI_PSEUDO, - prtd->enc_audio_client->session); - } - if (prtd->enc_audio_client) - q6asm_audio_client_free(prtd->enc_audio_client); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return 0; -} - -static int msm_compr_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - int dir = OUT; - - pr_debug("%s\n", __func__); - atomic_set(&prtd->pending_buffer, 0); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - compressed_audio.prtd = NULL; - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - if (compr->info.codec_param.codec.id == - SND_AUDIOCODEC_PASS_THROUGH) - msm_pcm_routing_reg_psthr_stream( - soc_prtd->dai_link->be_id, - prtd->session_id, substream->stream, - 0); - else - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_CAPTURE); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - - return 0; -} - -static int msm_compr_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_compr_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_compr_capture_close(substream); - return ret; -} -static int msm_compr_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_compr_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_compr_capture_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_compr_pointer(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - - pr_debug("%s: pcm_irq_pos = %d, pcm_size = %d, sample_bits = %d,\n" - "frame_bits = %d\n", __func__, prtd->pcm_irq_pos, - prtd->pcm_size, runtime->sample_bits, - runtime->frame_bits); - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static int msm_compr_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - int result = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - - pr_debug("%s\n", __func__); - prtd->mmap_flag = 1; - runtime->render_flag = SNDRV_NON_DMA_MODE; - if (runtime->dma_addr && runtime->dma_bytes) { - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - result = remap_pfn_range(vma, vma->vm_start, - runtime->dma_addr >> PAGE_SHIFT, - runtime->dma_bytes, - vma->vm_page_prot); - } else { - pr_err("Physical address or size of buf is NULL"); - return -EINVAL; - } - return result; -} - -static int msm_compr_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct audio_buffer *buf; - int dir, ret; - - pr_debug("%s\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dir = IN; - else - dir = OUT; - - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - switch (compr->info.codec_param.codec.id) { - case SND_AUDIOCODEC_AC3_PASS_THROUGH: - case SND_AUDIOCODEC_DTS_PASS_THROUGH: - case SND_AUDIOCODEC_DTS_LBR_PASS_THROUGH: - ret = q6asm_open_write_compressed(prtd->audio_client, - compr->codec); - - if (ret < 0) { - pr_err("%s: Session out open failed\n", - __func__); - return -ENOMEM; - } - break; - default: - ret = q6asm_open_write(prtd->audio_client, - compr->codec); - if (ret < 0) { - pr_err("%s: Session out open failed\n", - __func__); - return -ENOMEM; - } - msm_pcm_routing_reg_phy_stream( - soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, - substream->stream); - - if (compr->info.codec_param.codec.transcode_dts) { - prtd->enc_audio_client = - q6asm_audio_client_alloc( - (app_cb)compr_event_handler, compr); - if (!prtd->enc_audio_client) { - pr_err("%s: Could not allocate " \ - "memory\n", __func__); - return -ENOMEM; - } - prtd->enc_audio_client->perf_mode = false; - pr_debug("%s Setting up loopback path\n", - __func__); - ret = q6asm_open_transcode_loopback( - prtd->enc_audio_client, - params_channels(params)); - if (ret < 0) { - pr_err("%s: Session transcode " \ - "loopback open failed\n", - __func__); - return -ENODEV; - } - } - - break; - } - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - switch (compr->info.codec_param.codec.id) { - case SND_AUDIOCODEC_AMRWB: - pr_debug("q6asm_open_read(FORMAT_AMRWB)\n"); - ret = q6asm_open_read(prtd->audio_client, - FORMAT_AMRWB); - if (ret < 0) { - pr_err("%s: compressed Session out open failed\n", - __func__); - return -ENOMEM; - } - pr_debug("msm_pcm_routing_reg_phy_stream\n"); - msm_pcm_routing_reg_phy_stream( - soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, substream->stream); - break; - case SND_AUDIOCODEC_PCM: - pr_debug("q6asm_open_read(FORMAT_PCM)\n"); - ret = q6asm_open_read(prtd->audio_client, - FORMAT_MULTI_CHANNEL_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: compressed Session open failed\n", - __func__); - return -ENOMEM; - } - pr_debug("msm_pcm_routing_reg_phy_stream\n"); - msm_pcm_routing_reg_phy_stream( - soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, substream->stream); - break; - case SND_AUDIOCODEC_PASS_THROUGH: - pr_debug("q6asm_open_read_compressed(COMPRESSED_META_DATA_MODE)\n"); - ret = q6asm_open_read_compressed(prtd->audio_client, - MAX_NUM_FRAMES_PER_BUFFER, - COMPRESSED_META_DATA_MODE); - break; - default: - pr_err("Invalid codec for compressed session open\n"); - return -EFAULT; - } - - if (ret < 0) { - pr_err("%s: compressed Session out open failed\n", - __func__); - return -ENOMEM; - } - } - - ret = q6asm_set_io_mode(prtd->audio_client, ASYNC_IO_MODE); - if (ret < 0) { - pr_err("%s: Set IO mode failed\n", __func__); - return -ENOMEM; - } - /* Modifying kernel hardware params based on userspace config */ - if (params_periods(params) > 0 && - (params_periods(params) != runtime->hw.periods_max)) { - runtime->hw.periods_max = params_periods(params); - } - if (params_period_bytes(params) > 0 && - (params_period_bytes(params) != runtime->hw.period_bytes_min)) { - runtime->hw.period_bytes_min = params_period_bytes(params); - } - runtime->hw.buffer_bytes_max = - runtime->hw.period_bytes_min * runtime->hw.periods_max; - ret = q6asm_audio_client_buf_alloc_contiguous(dir, - prtd->audio_client, - runtime->hw.period_bytes_min, - runtime->hw.periods_max); - if (ret < 0) { - pr_err("Audio Start: Buffer Allocation failed " - "rc = %d\n", ret); - return -ENOMEM; - } - buf = prtd->audio_client->port[dir].buf; - - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - dma_buf->area = buf[0].data; - dma_buf->addr = buf[0].phys; - dma_buf->bytes = runtime->hw.buffer_bytes_max; - - pr_debug("%s: buf[%p]dma_buf->area[%p]dma_buf->addr[%p]\n" - "dma_buf->bytes[%d]\n", __func__, - (void *)buf, (void *)dma_buf->area, - (void *)dma_buf->addr, dma_buf->bytes); - if (!dma_buf->area) - return -ENOMEM; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} - -static int msm_compr_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - int rc = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct compr_audio *compr = runtime->private_data; - struct msm_audio *prtd = &compr->prtd; - uint64_t timestamp; - uint64_t temp; - - switch (cmd) { - case SNDRV_COMPRESS_TSTAMP: { - struct snd_compr_tstamp tstamp; - pr_debug("SNDRV_COMPRESS_TSTAMP\n"); - - memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp)); - rc = q6asm_get_session_time(prtd->audio_client, ×tamp); - if (rc < 0) { - pr_err("%s: fail to get session tstamp\n", __func__); - return rc; - } - temp = (timestamp * 2 * runtime->channels); - temp = temp * (runtime->rate/1000); - temp = div_u64(temp, 1000); - tstamp.sampling_rate = runtime->rate; - tstamp.timestamp = timestamp; - pr_debug("%s: bytes_consumed:," - "timestamp = %lld,\n", __func__, - tstamp.timestamp); - if (copy_to_user((void *) arg, &tstamp, - sizeof(struct snd_compr_tstamp))) - return -EFAULT; - return 0; - } - case SNDRV_COMPRESS_GET_CAPS: - pr_debug("SNDRV_COMPRESS_GET_CAPS\n"); - if (copy_to_user((void *) arg, &compr->info.compr_cap, - sizeof(struct snd_compr_caps))) { - rc = -EFAULT; - pr_err("%s: ERROR: copy to user\n", __func__); - return rc; - } - return 0; - case SNDRV_COMPRESS_SET_PARAMS: - pr_debug("SNDRV_COMPRESS_SET_PARAMS: "); - if (copy_from_user(&compr->info.codec_param, (void *) arg, - sizeof(struct snd_compr_params))) { - rc = -EFAULT; - pr_err("%s: ERROR: copy from user\n", __func__); - return rc; - } - /* - * DTS Security needed for the transcode path - */ - if (compr->info.codec_param.codec.transcode_dts) { - char modelId[128]; - struct snd_dec_dts opt_dts = - compr->info.codec_param.codec.dts; - int modelIdLength = opt_dts.modelIdLength; - if (copy_from_user(modelId, (void *)opt_dts.modelId, - modelIdLength)) - pr_err("%s: ERROR: copy modelId\n", __func__); - modelId[modelIdLength] = '\0'; - pr_debug("%s: Received modelId =%s,length=%d\n", - __func__, modelId, modelIdLength); - core_set_dts_model_id(modelIdLength, modelId); - } - switch (compr->info.codec_param.codec.id) { - case SND_AUDIOCODEC_MP3: - /* For MP3 we dont need any other parameter */ - pr_debug("SND_AUDIOCODEC_MP3\n"); - compr->codec = FORMAT_MP3; - break; - case SND_AUDIOCODEC_AAC: - pr_debug("SND_AUDIOCODEC_AAC\n"); - compr->codec = FORMAT_MPEG4_AAC; - break; - case SND_AUDIOCODEC_AC3_PASS_THROUGH: - pr_debug("SND_AUDIOCODEC_AC3_PASS_THROUGH\n"); - compr->codec = FORMAT_AC3; - break; - case SND_AUDIOCODEC_WMA: - pr_debug("SND_AUDIOCODEC_WMA\n"); - compr->codec = FORMAT_WMA_V9; - break; - case SND_AUDIOCODEC_WMA_PRO: - pr_debug("SND_AUDIOCODEC_WMA_PRO\n"); - compr->codec = FORMAT_WMA_V10PRO; - break; - case SND_AUDIOCODEC_DTS_PASS_THROUGH: - pr_debug("SND_AUDIOCODEC_DTS_PASS_THROUGH\n"); - compr->codec = FORMAT_DTS; - break; - case SND_AUDIOCODEC_DTS_LBR_PASS_THROUGH: - pr_debug("SND_AUDIOCODEC_DTS_LBR_PASS_THROUGH\n"); - compr->codec = FORMAT_DTS_LBR; - break; - case SND_AUDIOCODEC_DTS: { - char modelId[128]; - struct snd_dec_dts opt_dts = - compr->info.codec_param.codec.dts; - int modelIdLength = opt_dts.modelIdLength; - pr_debug("SND_AUDIOCODEC_DTS\n"); - if (copy_from_user(modelId, (void *)opt_dts.modelId, - modelIdLength)) - pr_err("%s: ERROR: copy modelId\n", __func__); - modelId[modelIdLength] = '\0'; - pr_debug("%s: Received modelId =%s,length=%d\n", - __func__, modelId, modelIdLength); - core_set_dts_model_id(modelIdLength, modelId); - compr->codec = FORMAT_DTS; - } - break; - case SND_AUDIOCODEC_DTS_LBR:{ - char modelId[128]; - struct snd_dec_dts opt_dts = - compr->info.codec_param.codec.dts; - int modelIdLength = opt_dts.modelIdLength; - pr_debug("SND_AUDIOCODEC_DTS_LBR\n"); - if (copy_from_user(modelId, (void *)opt_dts.modelId, - modelIdLength)) - pr_err("%s: ERROR: copy modelId\n", __func__); - modelId[modelIdLength] = '\0'; - pr_debug("%s: Received modelId =%s,length=%d\n", - __func__, modelId, modelIdLength); - core_set_dts_model_id(modelIdLength, modelId); - compr->codec = FORMAT_DTS_LBR; - } - break; - case SND_AUDIOCODEC_AMRWB: - pr_debug("msm_compr_ioctl SND_AUDIOCODEC_AMRWB\n"); - compr->codec = FORMAT_AMRWB; - break; - case SND_AUDIOCODEC_AMRWBPLUS: - pr_debug("msm_compr_ioctl SND_AUDIOCODEC_AMRWBPLUS\n"); - compr->codec = FORMAT_AMR_WB_PLUS; - break; - case SND_AUDIOCODEC_PASS_THROUGH: - /* format pass through is used for HDMI IN compressed - where the decoder format is indicated by LPASS */ - pr_debug("msm_compr_ioctl SND_AUDIOCODEC_PASSTHROUGH\n"); - compr->codec = FORMAT_PASS_THROUGH; - break; - case SND_AUDIOCODEC_PCM: - pr_debug("msm_compr_ioctl SND_AUDIOCODEC_PCM\n"); - compr->codec = FORMAT_MULTI_CHANNEL_LINEAR_PCM; - break; - case SND_AUDIOCODEC_MP2: - pr_debug("SND_AUDIOCODEC_MP2\n"); - compr->codec = FORMAT_MP2; - break; - default: - pr_err("msm_compr_ioctl failed..unknown codec\n"); - return -EFAULT; - } - return 0; - case SNDRV_PCM_IOCTL1_RESET: - pr_debug("SNDRV_PCM_IOCTL1_RESET\n"); - /* Flush only when session is started during CAPTURE, - while PLAYBACK has no such restriction. */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || - (substream->stream == SNDRV_PCM_STREAM_CAPTURE && - atomic_read(&prtd->start))) { - if (atomic_read(&prtd->eos)) { - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - atomic_set(&prtd->eos, 0); - atomic_set(&prtd->pending_buffer, 1); - } - - /* A unlikely race condition possible with FLUSH - DRAIN if ack is set by flush and reset by drain */ - prtd->cmd_ack = 0; - rc = q6asm_cmd(prtd->audio_client, CMD_FLUSH); - if (rc < 0) { - pr_err("%s: flush cmd failed rc=%d\n", - __func__, rc); - return rc; - } - rc = wait_event_timeout(the_locks.flush_wait, - prtd->cmd_ack, 5 * HZ); - if (!rc) - pr_err("Flush cmd timeout\n"); - prtd->pcm_irq_pos = 0; - } - break; - case SNDRV_COMPRESS_DRAIN: - pr_debug("%s: SNDRV_COMPRESS_DRAIN\n", __func__); - atomic_set(&prtd->eos, 1); - atomic_set(&prtd->pending_buffer, 0); - prtd->cmd_ack = 0; - q6asm_cmd_nowait(prtd->audio_client, CMD_EOS); - /* Wait indefinitely for DRAIN. Flush can also signal this*/ - rc = wait_event_interruptible(the_locks.eos_wait, - prtd->cmd_ack); - if (rc < 0) - pr_err("EOS cmd interrupted\n"); - pr_debug("%s: SNDRV_COMPRESS_DRAIN out of wait\n", __func__); - return 0; - default: - break; - } - return snd_pcm_lib_ioctl(substream, cmd, arg); -} - -static struct snd_pcm_ops msm_compr_ops = { - .open = msm_compr_open, - .hw_params = msm_compr_hw_params, - .close = msm_compr_close, - .ioctl = msm_compr_ioctl, - .prepare = msm_compr_prepare, - .trigger = msm_compr_trigger, - .pointer = msm_compr_pointer, - .mmap = msm_compr_mmap, - .restart = msm_compr_restart, -}; - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_compr_ops, - .pcm_new = msm_asoc_pcm_new, -}; - -static int msm_compr_probe(struct platform_device *pdev) -{ - pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_compr_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_compr_driver = { - .driver = { - .name = "msm-compr-dsp", - .owner = THIS_MODULE, - }, - .probe = msm_compr_probe, - .remove = msm_compr_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - init_waitqueue_head(&the_locks.enable_wait); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - init_waitqueue_head(&the_locks.flush_wait); - - return platform_driver_register(&msm_compr_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_compr_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-compr-q6.h b/sound/soc/msm/msm-compr-q6.h deleted file mode 100644 index d91854e491de9fd81caa80a7bbf696c4243c3110..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-compr-q6.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 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 _MSM_COMPR_H -#define _MSM_COMPR_H -#include -#include -#include -#include -#include - -#include "msm-pcm-q6.h" - -struct compr_info { - struct snd_compr_caps compr_cap; - struct snd_compr_codec_caps codec_caps; - struct snd_compr_params codec_param; -}; - -struct compr_audio { - struct msm_audio prtd; - struct compr_info info; - uint32_t codec; -}; - -#endif /*_MSM_COMPR_H*/ diff --git a/sound/soc/msm/msm-dai-q6-hdmi.c b/sound/soc/msm/msm-dai-q6-hdmi.c deleted file mode 100644 index 58612cbe6d9ca8ca1494e2f9346ea72a746fd9c7..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-dai-q6-hdmi.c +++ /dev/null @@ -1,311 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -enum { - STATUS_PORT_STARTED, /* track if AFE port has started */ - STATUS_MAX -}; - -struct msm_dai_q6_hdmi_dai_data { - DECLARE_BITMAP(status_mask, STATUS_MAX); - u32 rate; - u32 channels; - union afe_port_config port_config; -}; - -static int msm_dai_q6_hdmi_format_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data; - int value = ucontrol->value.integer.value[0]; - dai_data->port_config.hdmi_multi_ch.data_type = value; - pr_debug("%s: value = %d\n", __func__, value); - return 0; -} - -static int msm_dai_q6_hdmi_format_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - struct msm_dai_q6_hdmi_dai_data *dai_data = kcontrol->private_data; - ucontrol->value.integer.value[0] = - dai_data->port_config.hdmi_multi_ch.data_type; - return 0; -} - - -/* HDMI format field for AFE_PORT_MULTI_CHAN_HDMI_AUDIO_IF_CONFIG command - * 0: linear PCM - * 1: non-linear PCM - */ -static const char *hdmi_format[] = { - "LPCM", - "Compr" -}; - -static const struct soc_enum hdmi_config_enum[] = { - SOC_ENUM_SINGLE_EXT(2, hdmi_format), -}; - -static const struct snd_kcontrol_new hdmi_config_controls[] = { - SOC_ENUM_EXT("HDMI RX Format", hdmi_config_enum[0], - msm_dai_q6_hdmi_format_get, - msm_dai_q6_hdmi_format_put), -}; - -/* Current implementation assumes hw_param is called once - * This may not be the case but what to do when ADM and AFE - * port are already opened and parameter changes - */ -static int msm_dai_q6_hdmi_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev); - u32 channel_allocation = 0; - u32 level_shift = 0; /* 0dB */ - bool down_mix = FALSE; - int sample_rate = 48000; - - dai_data->channels = params_channels(params); - dai_data->rate = params_rate(params); - dai_data->port_config.hdmi_multi_ch.reserved = 0; - - switch (dai_data->rate) { - case 48000: - sample_rate = HDMI_SAMPLE_RATE_48KHZ; - break; - case 44100: - sample_rate = HDMI_SAMPLE_RATE_44_1KHZ; - break; - case 32000: - sample_rate = HDMI_SAMPLE_RATE_32KHZ; - break; - } - hdmi_msm_audio_sample_rate_reset(sample_rate); - - switch (dai_data->channels) { - case 2: - channel_allocation = 0; - hdmi_msm_audio_info_setup(1, MSM_HDMI_AUDIO_CHANNEL_2, - channel_allocation, level_shift, down_mix); - dai_data->port_config.hdmi_multi_ch.channel_allocation = - channel_allocation; - break; - case 6: - channel_allocation = 0x0B; - hdmi_msm_audio_info_setup(1, MSM_HDMI_AUDIO_CHANNEL_6, - channel_allocation, level_shift, down_mix); - dai_data->port_config.hdmi_multi_ch.channel_allocation = - channel_allocation; - break; - case 8: - channel_allocation = 0x1F; - hdmi_msm_audio_info_setup(1, MSM_HDMI_AUDIO_CHANNEL_8, - channel_allocation, level_shift, down_mix); - dai_data->port_config.hdmi_multi_ch.channel_allocation = - channel_allocation; - break; - default: - dev_err(dai->dev, "invalid Channels = %u\n", - dai_data->channels); - return -EINVAL; - } - dev_dbg(dai->dev, "%s() num_ch = %u rate =%u" - " channel_allocation = %u data type = %d\n", __func__, - dai_data->channels, - dai_data->rate, - dai_data->port_config.hdmi_multi_ch.channel_allocation, - dai_data->port_config.hdmi_multi_ch.data_type); - - return 0; -} - - -static void msm_dai_q6_hdmi_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev); - int rc = 0; - - if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - pr_info("%s: afe port not started. dai_data->status_mask" - " = %ld\n", __func__, *dai_data->status_mask); - return; - } - - rc = afe_close(dai->id); /* can block */ - - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AFE port\n"); - - pr_debug("%s: dai_data->status_mask = %ld\n", __func__, - *dai_data->status_mask); - - clear_bit(STATUS_PORT_STARTED, dai_data->status_mask); -} - - -static int msm_dai_q6_hdmi_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_hdmi_dai_data *dai_data = dev_get_drvdata(dai->dev); - int rc = 0; - - if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - rc = afe_port_start(dai->id, &dai_data->port_config, - dai_data->rate); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to open AFE port %x\n", - dai->id); - else - set_bit(STATUS_PORT_STARTED, - dai_data->status_mask); - } - - return rc; -} - -static int msm_dai_q6_hdmi_dai_probe(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_hdmi_dai_data *dai_data; - const struct snd_kcontrol_new *kcontrol; - int rc = 0; - - dai_data = kzalloc(sizeof(struct msm_dai_q6_hdmi_dai_data), - GFP_KERNEL); - - if (!dai_data) { - dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n", - dai->id); - rc = -ENOMEM; - } else - dev_set_drvdata(dai->dev, dai_data); - - kcontrol = &hdmi_config_controls[0]; - - rc = snd_ctl_add(dai->card->snd_card, - snd_ctl_new1(kcontrol, dai_data)); - return rc; -} - -static int msm_dai_q6_hdmi_dai_remove(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_hdmi_dai_data *dai_data; - int rc; - - dai_data = dev_get_drvdata(dai->dev); - - /* If AFE port is still up, close it */ - if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - rc = afe_close(dai->id); /* can block */ - - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AFE port\n"); - - clear_bit(STATUS_PORT_STARTED, dai_data->status_mask); - } - kfree(dai_data); - snd_soc_unregister_dai(dai->dev); - - return 0; -} - -static struct snd_soc_dai_ops msm_dai_q6_hdmi_ops = { - .prepare = msm_dai_q6_hdmi_prepare, - .hw_params = msm_dai_q6_hdmi_hw_params, - .shutdown = msm_dai_q6_hdmi_shutdown, -}; - -static struct snd_soc_dai_driver msm_dai_q6_hdmi_hdmi_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 2, - .channels_max = 6, - .rate_max = 48000, - .rate_min = 48000, - }, - .ops = &msm_dai_q6_hdmi_ops, - .probe = msm_dai_q6_hdmi_dai_probe, - .remove = msm_dai_q6_hdmi_dai_remove, -}; - - -/* To do: change to register DAIs as batch */ -static int msm_dai_q6_hdmi_dev_probe(struct platform_device *pdev) -{ - int rc = 0; - - dev_dbg(&pdev->dev, "dev name %s dev-id %d\n", - dev_name(&pdev->dev), pdev->id); - - switch (pdev->id) { - case HDMI_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_hdmi_hdmi_rx_dai); - break; - default: - dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id); - rc = -ENODEV; - break; - } - return rc; -} - -static int msm_dai_q6_hdmi_dev_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static struct platform_driver msm_dai_q6_hdmi_driver = { - .probe = msm_dai_q6_hdmi_dev_probe, - .remove = msm_dai_q6_hdmi_dev_remove, - .driver = { - .name = "msm-dai-q6-hdmi", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_dai_q6_hdmi_init(void) -{ - return platform_driver_register(&msm_dai_q6_hdmi_driver); -} -module_init(msm_dai_q6_hdmi_init); - -static void __exit msm_dai_q6_hdmi_exit(void) -{ - platform_driver_unregister(&msm_dai_q6_hdmi_driver); -} -module_exit(msm_dai_q6_hdmi_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM DSP HDMI DAI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-dai-q6.c b/sound/soc/msm/msm-dai-q6.c deleted file mode 100644 index 59302e0426ee6c3e28135472d8f844dc7a90d4c7..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-dai-q6.c +++ /dev/null @@ -1,2047 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum { - STATUS_PORT_STARTED, /* track if AFE port has started */ - STATUS_MAX -}; - -struct msm_dai_q6_dai_data { - DECLARE_BITMAP(status_mask, STATUS_MAX); - u32 rate; - u32 channels; - u32 bitwidth; - union afe_port_config port_config; -}; - -struct msm_dai_q6_mi2s_dai_config { - u16 pdata_mi2s_lines; - struct msm_dai_q6_dai_data mi2s_dai_data; -}; - -struct msm_dai_q6_mi2s_dai_data { - struct msm_dai_q6_mi2s_dai_config tx_dai; - struct msm_dai_q6_mi2s_dai_config rx_dai; - struct snd_pcm_hw_constraint_list rate_constraint; - struct snd_pcm_hw_constraint_list bitwidth_constraint; -}; - -static struct clk *pcm_clk; -static struct clk *sec_pcm_clk; -static DEFINE_MUTEX(aux_pcm_mutex); -static int aux_pcm_count; -static struct msm_dai_auxpcm_pdata *auxpcm_plat_data; -static struct msm_dai_auxpcm_pdata *sec_auxpcm_plat_data; - -static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data; - int value = ucontrol->value.integer.value[0]; - dai_data->port_config.mi2s.format = value; - pr_debug("%s: value = %d, channel = %d, line = %d\n", - __func__, value, dai_data->port_config.mi2s.channel, - dai_data->port_config.mi2s.line); - return 0; -} - -static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data; - ucontrol->value.integer.value[0] = dai_data->port_config.mi2s.format ; - return 0; -} - - -/* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command - * 0: linear PCM - * 1: non-linear PCM - * 2: PCM data in IEC 60968 container - * 3: compressed data in IEC 60958 container - */ -static const char *mi2s_format[] = { - "LPCM", - "Compr", - "LPCM-60958", - "Compr-60958"}; - -static const struct soc_enum mi2s_config_enum[] = { - SOC_ENUM_SINGLE_EXT(4, mi2s_format), -}; - -static const struct snd_kcontrol_new mi2s_config_controls[] = { - SOC_ENUM_EXT("MI2S RX Format", mi2s_config_enum[0], - msm_dai_q6_mi2s_format_get, - msm_dai_q6_mi2s_format_put), - SOC_ENUM_EXT("SEC RX Format", mi2s_config_enum[0], - msm_dai_q6_mi2s_format_get, - msm_dai_q6_mi2s_format_put), - SOC_ENUM_EXT("MI2S TX Format", mi2s_config_enum[0], - msm_dai_q6_mi2s_format_get, - msm_dai_q6_mi2s_format_put), -}; - -static u8 num_of_bits_set(u8 sd_line_mask) -{ - u8 num_bits_set = 0; - - while (sd_line_mask) { - num_bits_set++; - sd_line_mask = sd_line_mask & (sd_line_mask - 1); - } - return num_bits_set; -} - -static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = - dev_get_drvdata(dai->dev); - - dev_dbg(dai->dev, "%s: cnst list %p\n", __func__, - mi2s_dai_data->rate_constraint.list); - - if (mi2s_dai_data->rate_constraint.list) { - snd_pcm_hw_constraint_list(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &mi2s_dai_data->rate_constraint); - snd_pcm_hw_constraint_list(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - &mi2s_dai_data->bitwidth_constraint); - } - - return 0; -} - -static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = - dev_get_drvdata(dai->dev); - struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config = - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai); - struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data; - - dai_data->channels = params_channels(params); - switch (dai_data->channels) { - case 8: - case 7: - if (mi2s_dai_config->pdata_mi2s_lines < AFE_I2S_8CHS) - goto error_invalid_data; - dai_data->port_config.mi2s.line = AFE_I2S_8CHS; - break; - case 6: - case 5: - if (mi2s_dai_config->pdata_mi2s_lines < AFE_I2S_6CHS) - goto error_invalid_data; - dai_data->port_config.mi2s.line = AFE_I2S_6CHS; - break; - case 4: - case 3: - if (mi2s_dai_config->pdata_mi2s_lines < AFE_I2S_QUAD01) - goto error_invalid_data; - if (mi2s_dai_config->pdata_mi2s_lines == AFE_I2S_QUAD23) - dai_data->port_config.mi2s.line = - mi2s_dai_config->pdata_mi2s_lines; - else - dai_data->port_config.mi2s.line = AFE_I2S_QUAD01; - break; - case 2: - case 1: - if (mi2s_dai_config->pdata_mi2s_lines < AFE_I2S_SD0) - goto error_invalid_data; - switch (mi2s_dai_config->pdata_mi2s_lines) { - case AFE_I2S_SD0: - case AFE_I2S_SD1: - case AFE_I2S_SD2: - case AFE_I2S_SD3: - dai_data->port_config.mi2s.line = - mi2s_dai_config->pdata_mi2s_lines; - break; - case AFE_I2S_QUAD01: - case AFE_I2S_6CHS: - case AFE_I2S_8CHS: - dai_data->port_config.mi2s.line = AFE_I2S_SD0; - break; - case AFE_I2S_QUAD23: - dai_data->port_config.mi2s.line = AFE_I2S_SD2; - break; - } - if (dai_data->channels == 2) - dai_data->port_config.mi2s.channel = MSM_AFE_STEREO; - else - dai_data->port_config.mi2s.channel = MSM_AFE_MONO; - break; - default: - goto error_invalid_data; - } - dai_data->rate = params_rate(params); - dai_data->port_config.mi2s.bitwidth = 16; - dai_data->bitwidth = 16; - if (!mi2s_dai_data->rate_constraint.list) { - mi2s_dai_data->rate_constraint.list = &dai_data->rate; - mi2s_dai_data->bitwidth_constraint.list = &dai_data->bitwidth; - } - - pr_debug("%s: dai_data->channels = %d, line = %d\n", __func__, - dai_data->channels, dai_data->port_config.mi2s.line); - return 0; -error_invalid_data: - pr_err("%s: dai_data->channels = %d, line = %d\n", __func__, - dai_data->channels, dai_data->port_config.mi2s.line); - return -EINVAL; -} - -static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr, - unsigned int *ch_cnt) -{ - u8 num_of_sd_lines; - - num_of_sd_lines = num_of_bits_set(sd_lines); - - switch (num_of_sd_lines) { - case 0: - pr_debug("%s: no line is assigned\n", __func__); - break; - case 1: - switch (sd_lines) { - case MSM_MI2S_SD0: - *config_ptr = AFE_I2S_SD0; - break; - case MSM_MI2S_SD1: - *config_ptr = AFE_I2S_SD1; - break; - case MSM_MI2S_SD2: - *config_ptr = AFE_I2S_SD2; - break; - case MSM_MI2S_SD3: - *config_ptr = AFE_I2S_SD3; - break; - default: - pr_err("%s: invalid SD line\n", - __func__); - goto error_invalid_data; - } - break; - case 2: - switch (sd_lines) { - case MSM_MI2S_SD0 | MSM_MI2S_SD1: - *config_ptr = AFE_I2S_QUAD01; - break; - case MSM_MI2S_SD2 | MSM_MI2S_SD3: - *config_ptr = AFE_I2S_QUAD23; - break; - default: - pr_err("%s: invalid SD line\n", - __func__); - goto error_invalid_data; - } - break; - case 3: - switch (sd_lines) { - case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2: - *config_ptr = AFE_I2S_6CHS; - break; - default: - pr_err("%s: invalid SD lines\n", - __func__); - goto error_invalid_data; - } - break; - case 4: - switch (sd_lines) { - case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3: - *config_ptr = AFE_I2S_8CHS; - break; - default: - pr_err("%s: invalid SD lines\n", - __func__); - goto error_invalid_data; - } - break; - default: - pr_err("%s: invalid SD lines\n", __func__); - goto error_invalid_data; - } - - *ch_cnt = num_of_sd_lines; - - return 0; - -error_invalid_data: - return -EINVAL; -} - -static int msm_dai_q6_mi2s_platform_data_validation( - struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver) -{ - struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev); - struct msm_mi2s_pdata *mi2s_pdata = - (struct msm_mi2s_pdata *) pdev->dev.platform_data; - u16 sdline_config; - unsigned int ch_cnt; - int rc = 0; - - if ((mi2s_pdata->rx_sd_lines & mi2s_pdata->tx_sd_lines) || - (!mi2s_pdata->rx_sd_lines && !mi2s_pdata->tx_sd_lines)) { - dev_err(&pdev->dev, - "error sd line conflict or no line assigned\n"); - rc = -EINVAL; - goto rtn; - } - - rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines, - &sdline_config, &ch_cnt); - - if (IS_ERR_VALUE(rc)) { - dev_err(&pdev->dev, "invalid MI2S RX sd line config\n"); - goto rtn; - } - - if (ch_cnt) { - dai_data->rx_dai.mi2s_dai_data.port_config.mi2s.line = - sdline_config; - dai_data->rx_dai.pdata_mi2s_lines = sdline_config; - dai_driver->playback.channels_min = 1; - dai_driver->playback.channels_max = ch_cnt << 1; - } else { - dai_driver->playback.channels_min = 0; - dai_driver->playback.channels_max = 0; - } - rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines, - &sdline_config, &ch_cnt); - - if (IS_ERR_VALUE(rc)) { - dev_err(&pdev->dev, "invalid MI2S TX sd line config\n"); - goto rtn; - } - - if (ch_cnt) { - dai_data->tx_dai.mi2s_dai_data.port_config.mi2s.line = - sdline_config; - dai_data->tx_dai.pdata_mi2s_lines = sdline_config; - dai_driver->capture.channels_min = 1; - dai_driver->capture.channels_max = ch_cnt << 1; - } else { - dai_driver->capture.channels_min = 0; - dai_driver->capture.channels_max = 0; - } - - dev_info(&pdev->dev, "%s: playback sdline %x capture sdline %x\n", - __func__, dai_data->rx_dai.pdata_mi2s_lines, - dai_data->tx_dai.pdata_mi2s_lines); - dev_info(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n", - __func__, dai_driver->playback.channels_max, - dai_driver->capture.channels_max); -rtn: - return rc; -} - -static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) -{ - struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = - dev_get_drvdata(dai->dev); - - if (test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) || - test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) { - dev_err(dai->dev, "%s: err chg i2s mode while dai running", - __func__); - return -EPERM; - } - - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.mi2s.ws = 1; - mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.mi2s.ws = 1; - break; - case SND_SOC_DAIFMT_CBM_CFM: - mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.mi2s.ws = 0; - mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.mi2s.ws = 0; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = - dev_get_drvdata(dai->dev); - struct msm_dai_q6_dai_data *dai_data = - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - &mi2s_dai_data->rx_dai.mi2s_dai_data : - &mi2s_dai_data->tx_dai.mi2s_dai_data); - u16 port_id = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - MI2S_RX : MI2S_TX); - int rc = 0; - - if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - /* PORT START should be set if prepare called in active state */ - rc = afe_port_start(port_id, &dai_data->port_config, - dai_data->rate); - - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to open AFE port %x\n", - dai->id); - else - set_bit(STATUS_PORT_STARTED, - dai_data->status_mask); - } - - return rc; -} - -static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = - dev_get_drvdata(dai->dev); - struct msm_dai_q6_dai_data *dai_data = - (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - &mi2s_dai_data->rx_dai.mi2s_dai_data : - &mi2s_dai_data->tx_dai.mi2s_dai_data); - u16 port_id = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - MI2S_RX : MI2S_TX); - int rc = 0; - - if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - rc = afe_close(port_id); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AFE port\n"); - clear_bit(STATUS_PORT_STARTED, dai_data->status_mask); - } - - if (!test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) && - !test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) { - mi2s_dai_data->rate_constraint.list = NULL; - mi2s_dai_data->bitwidth_constraint.list = NULL; - } - -} - -static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai, int stream) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - - dai_data->channels = params_channels(params); - switch (dai_data->channels) { - case 2: - case 4: - case 6: - case 8: - dai_data->port_config.mi2s.channel = MSM_AFE_STEREO; - break; - case 1: - dai_data->port_config.mi2s.channel = MSM_AFE_MONO; - break; - default: - return -EINVAL; - break; - } - dai_data->rate = params_rate(params); - - dev_dbg(dai->dev, " channel %d sample rate %d entered\n", - dai_data->channels, dai_data->rate); - - /* Q6 only supports 16 as now */ - dai_data->port_config.mi2s.bitwidth = 16; - dai_data->port_config.mi2s.line = 1; - return 0; -} - -static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - dai_data->port_config.mi2s.ws = 1; /* CPU is master */ - break; - case SND_SOC_DAIFMT_CBM_CFM: - dai_data->port_config.mi2s.ws = 0; /* CPU is slave */ - break; - default: - return -EINVAL; - } - - return 0; -} - - -static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai, int stream) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - - dai_data->channels = params_channels(params); - dai_data->rate = params_rate(params); - - /* Q6 only supports 16 as now */ - dai_data->port_config.slim_sch.bit_width = 16; - dai_data->port_config.slim_sch.data_format = 0; - dai_data->port_config.slim_sch.num_channels = dai_data->channels; - dai_data->port_config.slim_sch.reserved = 0; - - dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n" - "num_channel %hu slave_ch_mapping[0] %hu\n" - "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n" - "slave_port_mapping[3] %hu\n sample_rate %d\n", __func__, - dai_data->port_config.slim_sch.slimbus_dev_id, - dai_data->port_config.slim_sch.bit_width, - dai_data->port_config.slim_sch.data_format, - dai_data->port_config.slim_sch.num_channels, - dai_data->port_config.slim_sch.slave_ch_mapping[0], - dai_data->port_config.slim_sch.slave_ch_mapping[1], - dai_data->port_config.slim_sch.slave_ch_mapping[2], - dai_data->port_config.slim_sch.slave_ch_mapping[3], - dai_data->rate); - - return 0; -} - -static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai, int stream) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - - dai_data->channels = params_channels(params); - dai_data->rate = params_rate(params); - - dev_dbg(dai->dev, "channels %d sample rate %d entered\n", - dai_data->channels, dai_data->rate); - - memset(&dai_data->port_config, 0, sizeof(dai_data->port_config)); - - return 0; -} -static int msm_dai_q6_auxpcm_hw_params( - struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - struct msm_dai_auxpcm_pdata *auxpcm_pdata = - (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data; - - if (params_channels(params) != 1) { - dev_err(dai->dev, "AUX PCM supports only mono stream\n"); - return -EINVAL; - } - dai_data->channels = params_channels(params); - - dai_data->rate = params_rate(params); - switch (dai_data->rate) { - case 8000: - dai_data->port_config.pcm.mode = auxpcm_pdata->mode_8k.mode; - dai_data->port_config.pcm.sync = auxpcm_pdata->mode_8k.sync; - dai_data->port_config.pcm.frame = auxpcm_pdata->mode_8k.frame; - dai_data->port_config.pcm.quant = auxpcm_pdata->mode_8k.quant; - dai_data->port_config.pcm.slot = auxpcm_pdata->mode_8k.slot; - dai_data->port_config.pcm.data = auxpcm_pdata->mode_8k.data; - break; - case 16000: - dai_data->port_config.pcm.mode = auxpcm_pdata->mode_16k.mode; - dai_data->port_config.pcm.sync = auxpcm_pdata->mode_16k.sync; - dai_data->port_config.pcm.frame = auxpcm_pdata->mode_16k.frame; - dai_data->port_config.pcm.quant = auxpcm_pdata->mode_16k.quant; - dai_data->port_config.pcm.slot = auxpcm_pdata->mode_16k.slot; - dai_data->port_config.pcm.data = auxpcm_pdata->mode_16k.data; - break; - default: - dev_err(dai->dev, "AUX PCM supports only 8kHz and 16kHz sampling rate\n"); - return -EINVAL; - } - - return 0; -} - -static int msm_dai_q6_sec_auxpcm_hw_params( - struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - struct msm_dai_auxpcm_pdata *auxpcm_pdata = - (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data; - - pr_debug("%s\n", __func__); - if (params_channels(params) != 1) { - dev_err(dai->dev, "SEC AUX PCM supports only mono stream\n"); - return -EINVAL; - } - dai_data->channels = params_channels(params); - - dai_data->rate = params_rate(params); - switch (dai_data->rate) { - case 8000: - dai_data->port_config.pcm.mode = auxpcm_pdata->mode_8k.mode; - dai_data->port_config.pcm.sync = auxpcm_pdata->mode_8k.sync; - dai_data->port_config.pcm.frame = auxpcm_pdata->mode_8k.frame; - dai_data->port_config.pcm.quant = auxpcm_pdata->mode_8k.quant; - dai_data->port_config.pcm.slot = auxpcm_pdata->mode_8k.slot; - dai_data->port_config.pcm.data = auxpcm_pdata->mode_8k.data; - break; - case 16000: - dai_data->port_config.pcm.mode = auxpcm_pdata->mode_16k.mode; - dai_data->port_config.pcm.sync = auxpcm_pdata->mode_16k.sync; - dai_data->port_config.pcm.frame = auxpcm_pdata->mode_16k.frame; - dai_data->port_config.pcm.quant = auxpcm_pdata->mode_16k.quant; - dai_data->port_config.pcm.slot = auxpcm_pdata->mode_16k.slot; - dai_data->port_config.pcm.data = auxpcm_pdata->mode_16k.data; - break; - default: - dev_err(dai->dev, "AUX PCM supports only 8kHz and 16kHz sampling rate\n"); - return -EINVAL; - } - - return 0; -} - -static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - - dai_data->rate = params_rate(params); - dai_data->port_config.rtproxy.num_ch = - params_channels(params); - - pr_debug("channel %d entered,dai_id: %d,rate: %d\n", - dai_data->port_config.rtproxy.num_ch, dai->id, dai_data->rate); - - dai_data->port_config.rtproxy.bitwidth = 16; /* Q6 only supports 16 */ - dai_data->port_config.rtproxy.interleaved = 1; - dai_data->port_config.rtproxy.frame_sz = params_period_bytes(params); - dai_data->port_config.rtproxy.jitter = - dai_data->port_config.rtproxy.frame_sz/2; - dai_data->port_config.rtproxy.lw_mark = 0; - dai_data->port_config.rtproxy.hw_mark = 0; - dai_data->port_config.rtproxy.rsvd = 0; - - return 0; -} - -static int msm_dai_q6_pseudo_hw_params(struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - - dai_data->rate = params_rate(params); - dai_data->channels = params_channels(params) > 6 ? - params_channels(params) : 6; - - dai_data->port_config.pseudo.bit_width = 16; - dai_data->port_config.pseudo.num_channels = - dai_data->channels; - dai_data->port_config.pseudo.data_format = 0; - dai_data->port_config.pseudo.timing_mode = 1; - dai_data->port_config.pseudo.reserved = 16; - return 0; -} - -/* Current implementation assumes hw_param is called once - * This may not be the case but what to do when ADM and AFE - * port are already opened and parameter changes - */ -static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - int rc = 0; - - switch (dai->id) { - case PRIMARY_I2S_TX: - case PRIMARY_I2S_RX: - case SECONDARY_I2S_RX: - case SECONDARY_I2S_TX: - rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream); - break; - - case SLIMBUS_0_RX: - case SLIMBUS_1_RX: - case SLIMBUS_3_RX: - case SLIMBUS_0_TX: - case SLIMBUS_1_TX: - case SLIMBUS_2_RX: - case SLIMBUS_2_TX: - case SLIMBUS_3_TX: - case SLIMBUS_4_RX: - case SLIMBUS_4_TX: - rc = msm_dai_q6_slim_bus_hw_params(params, dai, - substream->stream); - break; - case INT_BT_SCO_RX: - case INT_BT_SCO_TX: - case INT_FM_RX: - case INT_FM_TX: - rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream); - break; - case RT_PROXY_DAI_001_TX: - case RT_PROXY_DAI_001_RX: - case RT_PROXY_DAI_002_TX: - case RT_PROXY_DAI_002_RX: - rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai); - break; - case PSEUDOPORT_01: - rc = msm_dai_q6_pseudo_hw_params(params, dai); - break; - case VOICE_PLAYBACK_TX: - case VOICE_RECORD_RX: - case VOICE_RECORD_TX: - rc = 0; - break; - default: - dev_err(dai->dev, "invalid AFE port ID\n"); - rc = -EINVAL; - break; - } - - return rc; -} - -static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - int rc = 0; - - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - mutex_lock(&aux_pcm_mutex); - dev_dbg(dai->dev, "%s dai->id = %d", __func__, dai->id); - if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - mutex_unlock(&aux_pcm_mutex); - return; - } - clear_bit(STATUS_PORT_STARTED, dai_data->status_mask); - aux_pcm_count--; - - if (aux_pcm_count > 0) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d\n", - __func__, dai->id, aux_pcm_count); - mutex_unlock(&aux_pcm_mutex); - return; - } else if (aux_pcm_count < 0) { - dev_err(dai->dev, "%s(): ERROR: dai->id %d" - " aux_pcm_count = %d < 0\n", - __func__, dai->id, aux_pcm_count); - aux_pcm_count = 0; - mutex_unlock(&aux_pcm_mutex); - return; - } - - pr_debug("%s: dai->id = %d aux_pcm_count = %d\n", __func__, - dai->id, aux_pcm_count); - - clk_disable_unprepare(pcm_clk); - rc = afe_close(PCM_RX); /* can block */ - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close PCM_RX AFE port\n"); - - rc = afe_close(PCM_TX); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AUX PCM TX port\n"); - - mutex_unlock(&aux_pcm_mutex); -} - -static void msm_dai_q6_sec_auxpcm_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - int rc = 0; - - pr_debug("%s\n", __func__); - mutex_lock(&aux_pcm_mutex); - - if (aux_pcm_count == 0) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 0. Just" - " return\n", __func__, dai->id); - mutex_unlock(&aux_pcm_mutex); - return; - } - - aux_pcm_count--; - - if (aux_pcm_count > 0) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d\n", - __func__, dai->id, aux_pcm_count); - mutex_unlock(&aux_pcm_mutex); - return; - } else if (aux_pcm_count < 0) { - dev_err(dai->dev, "%s(): ERROR: dai->id %d" - " aux_pcm_count = %d < 0\n", - __func__, dai->id, aux_pcm_count); - aux_pcm_count = 0; - mutex_unlock(&aux_pcm_mutex); - return; - } - - pr_debug("%s: dai->id = %d aux_pcm_count = %d\n", __func__, - dai->id, aux_pcm_count); - - clk_disable_unprepare(sec_pcm_clk); - rc = afe_close(SECONDARY_PCM_RX); /* can block */ - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close PCM_RX AFE port\n"); - - rc = afe_close(SECONDARY_PCM_TX); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AUX PCM TX port\n"); - - mutex_unlock(&aux_pcm_mutex); -} - -static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - int rc = 0; - - if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - switch (dai->id) { - case VOICE_PLAYBACK_TX: - case VOICE_RECORD_TX: - case VOICE_RECORD_RX: - pr_debug("%s, stop pseudo port:%d\n", - __func__, dai->id); - rc = afe_stop_pseudo_port(dai->id); - break; - default: - rc = afe_close(dai->id); /* can block */ - break; - } - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AFE port\n"); - pr_debug("%s: dai_data->status_mask = %ld\n", __func__, - *dai_data->status_mask); - clear_bit(STATUS_PORT_STARTED, dai_data->status_mask); - } -} - -static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - int rc = 0; - struct msm_dai_auxpcm_pdata *auxpcm_pdata = - (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data; - unsigned long pcm_clk_rate; - - mutex_lock(&aux_pcm_mutex); - set_bit(STATUS_PORT_STARTED, - dai_data->status_mask); - dev_dbg(dai->dev, "%s dai->id = %d", __func__, dai->id); - aux_pcm_count++; - if (aux_pcm_count >= 2) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d >= 2\n", - __func__, dai->id, aux_pcm_count); - mutex_unlock(&aux_pcm_mutex); - return 0; - } - - pr_debug("%s:dai->id:%d aux_pcm_count = %d. opening afe\n", - __func__, dai->id, aux_pcm_count); - - rc = afe_q6_interface_prepare(); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to open AFE APR\n"); - - /* - * For AUX PCM Interface the below sequence of clk - * settings and opening of afe port is a strict requirement. - * afe_port_start is called to make sure to make sure the port - * is open before deasserting the clock line. This is - * required because pcm register is not written before - * clock deassert. Hence the hw does not get updated with - * new setting if the below clock assert/deasset and afe_port_start - * sequence is not followed. - */ - - clk_reset(pcm_clk, CLK_RESET_ASSERT); - - afe_port_start(PCM_RX, &dai_data->port_config, dai_data->rate); - - afe_port_start(PCM_TX, &dai_data->port_config, dai_data->rate); - if (dai_data->rate == 8000) { - pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate; - } else if (dai_data->rate == 16000) { - pcm_clk_rate = auxpcm_pdata->mode_16k.pcm_clk_rate; - } else { - dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__, - dai_data->rate); - return -EINVAL; - } - - rc = clk_set_rate(pcm_clk, pcm_clk_rate); - if (rc < 0) { - pr_err("%s: clk_set_rate failed\n", __func__); - return rc; - } - - clk_prepare_enable(pcm_clk); - clk_reset(pcm_clk, CLK_RESET_DEASSERT); - - mutex_unlock(&aux_pcm_mutex); - - return rc; -} - -static int msm_dai_q6_sec_auxpcm_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - int rc = 0; - struct msm_dai_auxpcm_pdata *auxpcm_pdata = - (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data; - unsigned long pcm_clk_rate; - - pr_info("%s\n", __func__); - - mutex_lock(&aux_pcm_mutex); - - if (aux_pcm_count == 2) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 2. Just" - " return.\n", __func__, dai->id); - mutex_unlock(&aux_pcm_mutex); - return 0; - } else if (aux_pcm_count > 2) { - dev_err(dai->dev, "%s(): ERROR: dai->id %d" - " aux_pcm_count = %d > 2\n", - __func__, dai->id, aux_pcm_count); - mutex_unlock(&aux_pcm_mutex); - return 0; - } - - aux_pcm_count++; - if (aux_pcm_count == 2) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d after " - " increment\n", __func__, dai->id, aux_pcm_count); - mutex_unlock(&aux_pcm_mutex); - return 0; - } - - pr_debug("%s:dai->id:%d aux_pcm_count = %d. opening afe\n", - __func__, dai->id, aux_pcm_count); - - rc = afe_q6_interface_prepare(); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to open AFE APR\n"); - - /* - * For AUX PCM Interface the below sequence of clk - * settings and opening of afe port is a strict requirement. - * afe_port_start is called to make sure to make sure the port - * is open before deasserting the clock line. This is - * required because pcm register is not written before - * clock deassert. Hence the hw does not get updated with - * new setting if the below clock assert/deasset and afe_port_start - * sequence is not followed. - */ - - clk_reset(sec_pcm_clk, CLK_RESET_ASSERT); - - afe_port_start(SECONDARY_PCM_RX, &dai_data->port_config, - dai_data->rate); - - afe_port_start(SECONDARY_PCM_TX, &dai_data->port_config, - dai_data->rate); - if (dai_data->rate == 8000) { - pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate; - } else if (dai_data->rate == 16000) { - pcm_clk_rate = auxpcm_pdata->mode_16k.pcm_clk_rate; - } else { - dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__, - dai_data->rate); - return -EINVAL; - } - - rc = clk_set_rate(sec_pcm_clk, pcm_clk_rate); - if (rc < 0) { - pr_err("%s: clk_set_rate failed\n", __func__); - return rc; - } - - clk_prepare_enable(sec_pcm_clk); - clk_reset(sec_pcm_clk, CLK_RESET_DEASSERT); - - mutex_unlock(&aux_pcm_mutex); - - return rc; -} - -static int msm_dai_q6_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - int rc = 0; - - if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - switch (dai->id) { - case VOICE_PLAYBACK_TX: - case VOICE_RECORD_TX: - case VOICE_RECORD_RX: - rc = afe_start_pseudo_port(dai->id); - break; - default: - rc = afe_port_start(dai->id, &dai_data->port_config, - dai_data->rate); - } - - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to open AFE port %x\n", - dai->id); - else - set_bit(STATUS_PORT_STARTED, - dai_data->status_mask); - } - - return rc; -} - -static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream, - int cmd, struct snd_soc_dai *dai) -{ - int rc = 0; - - pr_debug("%s:port:%d cmd:%d aux_pcm_count= %d", - __func__, dai->id, cmd, aux_pcm_count); - - switch (cmd) { - - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - /* afe_open will be called from prepare */ - return 0; - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - return 0; - - default: - rc = -EINVAL; - } - - return rc; - -} - -static int msm_dai_q6_dai_auxpcm_probe(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data; - int rc = 0; - - struct msm_dai_auxpcm_pdata *auxpcm_pdata = - (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data; - - mutex_lock(&aux_pcm_mutex); - - if (!auxpcm_plat_data) - auxpcm_plat_data = auxpcm_pdata; - else if (auxpcm_plat_data != auxpcm_pdata) { - - dev_err(dai->dev, "AUX PCM RX and TX devices does not have" - " same platform data\n"); - return -EINVAL; - } - - /* - * The clk name for AUX PCM operation is passed as platform - * data to the cpu driver, since cpu drive is unaware of any - * boarc specific configuration. - */ - if (!pcm_clk) { - - pcm_clk = clk_get(dai->dev, auxpcm_pdata->clk); - - if (IS_ERR(pcm_clk)) { - pr_err("%s: could not get pcm_clk\n", __func__); - pcm_clk = NULL; - return -ENODEV; - } - } - - mutex_unlock(&aux_pcm_mutex); - - dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL); - - if (!dai_data) { - dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n", - dai->id); - rc = -ENOMEM; - } else - dev_set_drvdata(dai->dev, dai_data); - - pr_debug("%s : probe done for dai->id %d\n", __func__, dai->id); - return rc; -} - -static int msm_dai_q6_dai_sec_auxpcm_probe(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data; - int rc = 0; - struct msm_dai_auxpcm_pdata *auxpcm_pdata = - (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data; - - pr_info("%s\n", __func__); - - mutex_lock(&aux_pcm_mutex); - - if (!sec_auxpcm_plat_data) - sec_auxpcm_plat_data = auxpcm_pdata; - else if (sec_auxpcm_plat_data != auxpcm_pdata) { - dev_err(dai->dev, "AUX PCM RX and TX devices does not have" - " same platform data sec_auxpcm_plat_data\n"); - return -EINVAL; - } - - /* - * The clk name for AUX PCM operation is passed as platform - * data to the cpu driver, since cpu drive is unaware of any - * boarc specific configuration. - */ - if (!sec_pcm_clk) { - - sec_pcm_clk = clk_get(dai->dev, auxpcm_pdata->clk); - if (IS_ERR(sec_pcm_clk)) { - pr_err("%s: could not get sec_pcm_clk\n", __func__); - sec_pcm_clk = NULL; - return -ENODEV; - } - } - - mutex_unlock(&aux_pcm_mutex); - - dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL); - - if (!dai_data) { - dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n", - dai->id); - rc = -ENOMEM; - } else - dev_set_drvdata(dai->dev, dai_data); - - pr_debug("%s : probe done for dai->id %d\n", __func__, dai->id); - return rc; -} - -static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data; - int rc; - - dai_data = dev_get_drvdata(dai->dev); - - mutex_lock(&aux_pcm_mutex); - - if (aux_pcm_count == 0) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 0. clean" - " up and return\n", __func__, dai->id); - goto done; - } - - aux_pcm_count--; - - if (aux_pcm_count > 0) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d\n", - __func__, dai->id, aux_pcm_count); - goto done; - } else if (aux_pcm_count < 0) { - dev_err(dai->dev, "%s(): ERROR: dai->id %d" - " aux_pcm_count = %d < 0\n", - __func__, dai->id, aux_pcm_count); - goto done; - } - - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d." - "closing afe\n", - __func__, dai->id, aux_pcm_count); - - rc = afe_close(PCM_RX); /* can block */ - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AUX PCM RX AFE port\n"); - - rc = afe_close(PCM_TX); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AUX PCM TX AFE port\n"); - -done: - kfree(dai_data); - snd_soc_unregister_dai(dai->dev); - - mutex_unlock(&aux_pcm_mutex); - - return 0; -} - -static int msm_dai_q6_dai_sec_auxpcm_remove(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data; - int rc; - - pr_debug("%s\n", __func__); - dai_data = dev_get_drvdata(dai->dev); - - mutex_lock(&aux_pcm_mutex); - - if (aux_pcm_count == 0) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count is 0. clean" - " up and return\n", __func__, dai->id); - goto done; - } - - aux_pcm_count--; - - if (aux_pcm_count > 0) { - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d\n", - __func__, dai->id, aux_pcm_count); - goto done; - } else if (aux_pcm_count < 0) { - dev_err(dai->dev, "%s(): ERROR: dai->id %d" - " aux_pcm_count = %d < 0\n", - __func__, dai->id, aux_pcm_count); - goto done; - } - - dev_dbg(dai->dev, "%s(): dai->id %d aux_pcm_count = %d." - "closing afe\n", - __func__, dai->id, aux_pcm_count); - - rc = afe_close(SECONDARY_PCM_RX); /* can block */ - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AUX PCM RX AFE port\n"); - - rc = afe_close(SECONDARY_PCM_TX); - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AUX PCM TX AFE port\n"); - -done: - kfree(dai_data); - snd_soc_unregister_dai(dai->dev); - - mutex_unlock(&aux_pcm_mutex); - - return 0; -} - -static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = - dev_get_drvdata(dai->dev); - struct snd_kcontrol *kcontrol = NULL; - int rc = 0; - - if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.mi2s.line) { - kcontrol = snd_ctl_new1(&mi2s_config_controls[0], - &mi2s_dai_data->rx_dai.mi2s_dai_data); - rc = snd_ctl_add(dai->card->snd_card, kcontrol); - - if (IS_ERR_VALUE(rc)) { - dev_err(dai->dev, "%s: err add RX fmt ctl\n", __func__); - goto rtn; - } - } - - if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.mi2s.line) { - rc = snd_ctl_add(dai->card->snd_card, - snd_ctl_new1(&mi2s_config_controls[2], - &mi2s_dai_data->tx_dai.mi2s_dai_data)); - - if (IS_ERR_VALUE(rc)) { - if (kcontrol) - snd_ctl_remove(dai->card->snd_card, kcontrol); - dev_err(dai->dev, "%s: err add TX fmt ctl\n", __func__); - } - } - -rtn: - return rc; -} - -static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data = - dev_get_drvdata(dai->dev); - int rc; - - /* If AFE port is still up, close it */ - if (test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) { - rc = afe_close(MI2S_RX); /* can block */ - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close MI2S_RX port\n"); - clear_bit(STATUS_PORT_STARTED, - mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask); - } - if (test_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) { - rc = afe_close(MI2S_TX); /* can block */ - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close MI2S_TX port\n"); - clear_bit(STATUS_PORT_STARTED, - mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask); - } - kfree(mi2s_dai_data); - snd_soc_unregister_dai(dai->dev); - - return 0; -} - -static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data; - int rc = 0; - const struct snd_kcontrol_new *kcontrol; - - dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), - GFP_KERNEL); - - if (!dai_data) { - dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n", - dai->id); - rc = -ENOMEM; - } else - dev_set_drvdata(dai->dev, dai_data); - if (dai->id == SECONDARY_I2S_RX) { - kcontrol = &mi2s_config_controls[1]; - rc = snd_ctl_add(dai->card->snd_card, - snd_ctl_new1(kcontrol, dai_data)); - } - - return rc; -} - -static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai) -{ - struct msm_dai_q6_dai_data *dai_data; - int rc; - - dai_data = dev_get_drvdata(dai->dev); - - /* If AFE port is still up, close it */ - if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) { - switch (dai->id) { - case VOICE_PLAYBACK_TX: - case VOICE_RECORD_TX: - case VOICE_RECORD_RX: - pr_debug("%s, stop pseudo port:%d\n", - __func__, dai->id); - rc = afe_stop_pseudo_port(dai->id); - break; - default: - rc = afe_close(dai->id); /* can block */ - } - if (IS_ERR_VALUE(rc)) - dev_err(dai->dev, "fail to close AFE port\n"); - clear_bit(STATUS_PORT_STARTED, dai_data->status_mask); - } - kfree(dai_data); - snd_soc_unregister_dai(dai->dev); - - return 0; -} - -static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) -{ - int rc = 0; - - dev_dbg(dai->dev, "enter %s, id = %d fmt[%d]\n", __func__, - dai->id, fmt); - switch (dai->id) { - case PRIMARY_I2S_TX: - case PRIMARY_I2S_RX: - case SECONDARY_I2S_RX: - case SECONDARY_I2S_TX: - rc = msm_dai_q6_cdc_set_fmt(dai, fmt); - break; - default: - dev_err(dai->dev, "invalid cpu_dai set_fmt\n"); - rc = -EINVAL; - break; - } - - return rc; -} - -static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) -{ - int rc = 0; - struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev); - unsigned int i = 0; - - dev_dbg(dai->dev, "%s: dai_id = %d\n", __func__, dai->id); - switch (dai->id) { - case SLIMBUS_0_RX: - case SLIMBUS_1_RX: - case SLIMBUS_2_RX: - case SLIMBUS_3_RX: - case SLIMBUS_4_RX: - /* channel number to be between 128 and 255. For RX port - * use channel numbers from 138 to 144, for TX port - * use channel numbers from 128 to 137 - * For ports between MDM-APQ use channel numbers from 145 - */ - if (!rx_slot) - return -EINVAL; - for (i = 0; i < rx_num; i++) { - dai_data->port_config.slim_sch.slave_ch_mapping[i] = - rx_slot[i]; - pr_debug("%s: find number of channels[%d] ch[%d]\n", - __func__, i, - rx_slot[i]); - } - dai_data->port_config.slim_sch.num_channels = rx_num; - pr_debug("%s:SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__, - (dai->id - SLIMBUS_0_RX) / 2, - rx_num, dai_data->port_config.slim_sch.slave_ch_mapping[0], - dai_data->port_config.slim_sch.slave_ch_mapping[1]); - - break; - case SLIMBUS_0_TX: - case SLIMBUS_1_TX: - case SLIMBUS_2_TX: - case SLIMBUS_3_TX: - case SLIMBUS_4_TX: - /* channel number to be between 128 and 255. For RX port - * use channel numbers from 138 to 144, for TX port - * use channel numbers from 128 to 137 - * For ports between MDM-APQ use channel numbers from 145 - */ - if (!tx_slot) - return -EINVAL; - for (i = 0; i < tx_num; i++) { - dai_data->port_config.slim_sch.slave_ch_mapping[i] = - tx_slot[i]; - pr_debug("%s: find number of channels[%d] ch[%d]\n", - __func__, i, tx_slot[i]); - } - dai_data->port_config.slim_sch.num_channels = tx_num; - pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__, - (dai->id - SLIMBUS_0_TX) / 2, - tx_num, dai_data->port_config.slim_sch.slave_ch_mapping[0], - dai_data->port_config.slim_sch.slave_ch_mapping[1]); - break; - default: - dev_err(dai->dev, "invalid cpu_dai set_fmt\n"); - rc = -EINVAL; - break; - } - return rc; -} - -static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = { - .startup = msm_dai_q6_mi2s_startup, - .prepare = msm_dai_q6_mi2s_prepare, - .hw_params = msm_dai_q6_mi2s_hw_params, - .shutdown = msm_dai_q6_mi2s_shutdown, - .set_fmt = msm_dai_q6_mi2s_set_fmt, -}; - -static struct snd_soc_dai_ops msm_dai_q6_ops = { - .prepare = msm_dai_q6_prepare, - .hw_params = msm_dai_q6_hw_params, - .shutdown = msm_dai_q6_shutdown, - .set_fmt = msm_dai_q6_set_fmt, - .set_channel_map = msm_dai_q6_set_channel_map, -}; - -static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = { - .prepare = msm_dai_q6_auxpcm_prepare, - .trigger = msm_dai_q6_auxpcm_trigger, - .hw_params = msm_dai_q6_auxpcm_hw_params, - .shutdown = msm_dai_q6_auxpcm_shutdown, -}; - -static struct snd_soc_dai_ops msm_dai_q6_sec_auxpcm_ops = { - .prepare = msm_dai_q6_sec_auxpcm_prepare, - .trigger = msm_dai_q6_auxpcm_trigger, - .hw_params = msm_dai_q6_sec_auxpcm_hw_params, - .shutdown = msm_dai_q6_sec_auxpcm_shutdown, -}; - -static struct snd_soc_dai_driver msm_dai_q6_i2s_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 4, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_i2s_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 4, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_voice_playback_tx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_max = 48000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_max = 16000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_max = 16000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 2, - .channels_max = 2, - .rate_max = 48000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 2, - .channels_max = 2, - .rate_max = 48000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_max = 16000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_auxpcm_ops, - .probe = msm_dai_q6_dai_auxpcm_probe, - .remove = msm_dai_q6_dai_auxpcm_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_max = 16000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_auxpcm_ops, - .probe = msm_dai_q6_dai_auxpcm_probe, - .remove = msm_dai_q6_dai_auxpcm_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_sec_aux_pcm_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_max = 16000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_sec_auxpcm_ops, - .probe = msm_dai_q6_dai_sec_auxpcm_probe, - .remove = msm_dai_q6_dai_sec_auxpcm_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_sec_aux_pcm_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_max = 16000, - .rate_min = 8000, - }, - .ops = &msm_dai_q6_sec_auxpcm_ops, - .probe = msm_dai_q6_dai_sec_auxpcm_probe, - .remove = msm_dai_q6_dai_sec_auxpcm_remove, -}; - -/* Channel min and max are initialized base on platform data */ -static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rate_min = 8000, - .rate_max = 48000, - }, - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_mi2s_ops, - .probe = msm_dai_q6_dai_mi2s_probe, - .remove = msm_dai_q6_dai_mi2s_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_slimbus_1_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_min = 8000, - .rate_max = 16000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_slimbus_1_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .rate_min = 8000, - .rate_max = 16000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_slimbus_2_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 | - SNDRV_PCM_RATE_192000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 192000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_slimbus_2_tx_dai = { - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 | - SNDRV_PCM_RATE_192000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 8, - .rate_min = 8000, - .rate_max = 192000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -static struct snd_soc_dai_driver msm_dai_q6_slimbus_3_rx_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | - SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; -static struct snd_soc_dai_driver msm_dai_q6_pseudo_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | - SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 6, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_q6_ops, - .probe = msm_dai_q6_dai_probe, - .remove = msm_dai_q6_dai_remove, -}; - -/* To do: change to register DAIs as batch */ -static int msm_dai_q6_dev_probe(struct platform_device *pdev) -{ - int rc = 0; - - dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); - - switch (pdev->id) { - case PRIMARY_I2S_RX: - case SECONDARY_I2S_RX: - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_i2s_rx_dai); - break; - case PRIMARY_I2S_TX: - case SECONDARY_I2S_TX: - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_i2s_tx_dai); - break; - case PCM_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_aux_pcm_rx_dai); - break; - case PCM_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_aux_pcm_tx_dai); - break; - - case SECONDARY_PCM_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_sec_aux_pcm_rx_dai); - break; - case SECONDARY_PCM_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_sec_aux_pcm_tx_dai); - break; - case SLIMBUS_0_RX: - case SLIMBUS_4_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_slimbus_rx_dai); - break; - case SLIMBUS_0_TX: - case SLIMBUS_4_TX: - case SLIMBUS_3_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_slimbus_tx_dai); - break; - case SLIMBUS_1_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_slimbus_1_rx_dai); - break; - case SLIMBUS_1_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_slimbus_1_tx_dai); - break; - case SLIMBUS_2_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_slimbus_2_rx_dai); - break; - case SLIMBUS_2_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_slimbus_2_tx_dai); - break; - case SLIMBUS_3_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_slimbus_3_rx_dai); - break; - case INT_BT_SCO_RX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_bt_sco_rx_dai); - break; - case INT_BT_SCO_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_bt_sco_tx_dai); - break; - case INT_FM_RX: - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_fm_rx_dai); - break; - case INT_FM_TX: - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_fm_tx_dai); - break; - case RT_PROXY_DAI_001_RX: - case RT_PROXY_DAI_002_RX: - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_afe_rx_dai); - break; - case RT_PROXY_DAI_001_TX: - case RT_PROXY_DAI_002_TX: - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_afe_tx_dai); - break; - case VOICE_PLAYBACK_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_voice_playback_tx_dai); - break; - case VOICE_RECORD_RX: - case VOICE_RECORD_TX: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_incall_record_dai); - break; - case PSEUDOPORT_01: - rc = snd_soc_register_dai(&pdev->dev, - &msm_dai_q6_pseudo_dai); - break; - default: - rc = -ENODEV; - break; - } - return rc; -} - -static int msm_dai_q6_dev_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev) -{ - struct msm_dai_q6_mi2s_dai_data *dai_data; - int rc = 0; - - dev_dbg(&pdev->dev, "%s: pdev %p dev %p\n", __func__, pdev, &pdev->dev); - - dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data), - GFP_KERNEL); - - if (!dai_data) { - dev_err(&pdev->dev, "fail to allocate dai data\n"); - rc = -ENOMEM; - goto rtn; - } else - dev_set_drvdata(&pdev->dev, dai_data); - - rc = msm_dai_q6_mi2s_platform_data_validation(pdev, - &msm_dai_q6_mi2s_dai); - if (IS_ERR_VALUE(rc)) - goto err_pdata; - - dai_data->rate_constraint.count = 1; - dai_data->bitwidth_constraint.count = 1; - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_q6_mi2s_dai); - - if (IS_ERR_VALUE(rc)) - goto err_pdata; - - return 0; - -err_pdata: - - dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n"); - kfree(dai_data); -rtn: - return rc; -} - -static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static struct platform_driver msm_dai_q6_driver = { - .probe = msm_dai_q6_dev_probe, - .remove = msm_dai_q6_dev_remove, - .driver = { - .name = "msm-dai-q6", - .owner = THIS_MODULE, - }, -}; - -static struct platform_driver msm_dai_q6_mi2s_driver = { - .probe = msm_dai_q6_mi2s_dev_probe, - .remove = msm_dai_q6_mi2s_dev_remove, - .driver = { - .name = "msm-dai-q6-mi2s", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_dai_q6_init(void) -{ - int rc1, rc2; - - rc1 = platform_driver_register(&msm_dai_q6_mi2s_driver); - - if (IS_ERR_VALUE(rc1)) - pr_err("%s: fail to register mi2s dai driver\n", __func__); - - rc2 = platform_driver_register(&msm_dai_q6_driver); - - if (IS_ERR_VALUE(rc2)) - pr_err("%s: fail to register mi2s dai driver\n", __func__); - - return (IS_ERR_VALUE(rc1) && IS_ERR_VALUE(rc2)) ? -1 : 0; -} -module_init(msm_dai_q6_init); - -static void __exit msm_dai_q6_exit(void) -{ - platform_driver_unregister(&msm_dai_q6_driver); -} -module_exit(msm_dai_q6_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM DSP DAI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-dai-stub.c b/sound/soc/msm/msm-dai-stub.c deleted file mode 100644 index ae6f5db8aaec2bea366ba047b0b65bfba086b486..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-dai-stub.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include - -static int msm_dai_stub_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) -{ - pr_debug("%s:\n", __func__); - - return 0; -} - -static struct snd_soc_dai_ops msm_dai_stub_ops = { - .set_channel_map = msm_dai_stub_set_channel_map, -}; - -static struct snd_soc_dai_driver msm_dai_stub_dai = { - .playback = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .capture = { - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &msm_dai_stub_ops, -}; - -static int msm_dai_stub_dev_probe(struct platform_device *pdev) -{ - int rc = 0; - - dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); - - rc = snd_soc_register_dai(&pdev->dev, &msm_dai_stub_dai); - - return rc; -} - -static int msm_dai_stub_dev_remove(struct platform_device *pdev) -{ - pr_debug("%s:\n", __func__); - - snd_soc_unregister_dai(&pdev->dev); - - return 0; -} - -static struct platform_driver msm_dai_stub_driver = { - .probe = msm_dai_stub_dev_probe, - .remove = msm_dai_stub_dev_remove, - .driver = { - .name = "msm-dai-stub", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_dai_stub_init(void) -{ - pr_debug("%s:\n", __func__); - - return platform_driver_register(&msm_dai_stub_driver); -} -module_init(msm_dai_stub_init); - -static void __exit msm_dai_stub_exit(void) -{ - pr_debug("%s:\n", __func__); - - platform_driver_unregister(&msm_dai_stub_driver); -} -module_exit(msm_dai_stub_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM Stub DSP DAI driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-dai.c b/sound/soc/msm/msm-dai.c deleted file mode 100644 index cb74b8a8b495605d62288757cb881e9a27ebf5e5..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-dai.c +++ /dev/null @@ -1,150 +0,0 @@ -/* sound/soc/msm/msm-dai.c - * - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2008-2011, The Linux Foundation. All rights reserved. - * - * Derived from msm-pcm.c and msm7201.c. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm.h" - -static struct snd_soc_dai_driver msm_pcm_codec_dais[] = { -{ - .name = "msm-codec-dai", - .playback = { - .stream_name = "Playback", - .channels_max = USE_CHANNELS_MAX, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .formats = USE_FORMATS, - }, - .capture = { - .stream_name = "Capture", - .channels_max = USE_CHANNELS_MAX, - .rate_min = USE_RATE_MIN, - .rates = USE_RATE, - .formats = USE_FORMATS, - }, -}, -}; - -static struct snd_soc_dai_driver msm_pcm_cpu_dais[] = { -{ - .name = "msm-cpu-dai", - .playback = { - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .formats = USE_FORMATS, - }, - .capture = { - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .rate_min = USE_RATE_MIN, - .rates = USE_RATE, - .formats = USE_FORMATS, - }, -}, -}; - -static struct snd_soc_codec_driver soc_codec_dev_msm = { - .compress_type = SND_SOC_FLAT_COMPRESSION, -}; - -static int asoc_msm_codec_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm, - msm_pcm_codec_dais, ARRAY_SIZE(msm_pcm_codec_dais)); -} - -static int asoc_msm_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static int asoc_pcm_cpu_probe(struct platform_device *pdev) -{ - return snd_soc_register_dai(&pdev->dev, msm_pcm_cpu_dais); -} - -static int asoc_pcm_cpu_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static struct platform_driver asoc_codec_dai_driver = { - .probe = asoc_msm_codec_probe, - .remove = asoc_msm_codec_remove, - .driver = { - .name = "msm-codec-dai", - .owner = THIS_MODULE, - }, -}; - -static struct platform_driver asoc_cpu_dai_driver = { - .probe = asoc_pcm_cpu_probe, - .remove = asoc_pcm_cpu_remove, - .driver = { - .name = "msm-cpu-dai", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_codec_dai_init(void) -{ - return platform_driver_register(&asoc_codec_dai_driver); -} - -static void __exit msm_codec_dai_exit(void) -{ - platform_driver_unregister(&asoc_codec_dai_driver); -} - -static int __init msm_cpu_dai_init(void) -{ - return platform_driver_register(&asoc_cpu_dai_driver); -} - -static void __exit msm_cpu_dai_exit(void) -{ - platform_driver_unregister(&asoc_cpu_dai_driver); -} - -module_init(msm_codec_dai_init); -module_exit(msm_codec_dai_exit); -module_init(msm_cpu_dai_init); -module_exit(msm_cpu_dai_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-lowlatency-pcm-q6.c b/sound/soc/msm/msm-lowlatency-pcm-q6.c deleted file mode 100644 index c3df9e7fb775f2a6262ed7f8218b7ed0e8ac4260..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-lowlatency-pcm-q6.c +++ /dev/null @@ -1,776 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm-q6.h" -#include "msm-pcm-routing.h" - -static struct audio_locks the_locks; - -struct snd_msm { - struct snd_card *card; - struct snd_pcm *pcm; -}; - -struct snd_msm_volume { - struct msm_audio *prtd; - unsigned volume; -}; - -#define PLAYBACK_NUM_PERIODS 4 -#define PLAYBACK_MAX_PERIOD_SIZE 1024 -#define PLAYBACK_MIN_PERIOD_SIZE 512 -#define CAPTURE_NUM_PERIODS 4 -#define CAPTURE_MIN_PERIOD_SIZE 128 -#define CAPTURE_MAX_PERIOD_SIZE 1024 - -static struct snd_pcm_hardware msm_pcm_hardware_capture = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 8, - .buffer_bytes_max = CAPTURE_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE, - .period_bytes_min = CAPTURE_MIN_PERIOD_SIZE, - .period_bytes_max = CAPTURE_MAX_PERIOD_SIZE, - .periods_min = CAPTURE_NUM_PERIODS, - .periods_max = CAPTURE_NUM_PERIODS, - .fifo_size = 0, -}; - -static struct snd_pcm_hardware msm_pcm_hardware_playback = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 6, - .buffer_bytes_max = PLAYBACK_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE, - .period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE, - .period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE, - .periods_min = PLAYBACK_NUM_PERIODS, - .periods_max = PLAYBACK_NUM_PERIODS, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static uint32_t in_frame_info[CAPTURE_NUM_PERIODS][2]; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static void event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ - struct msm_audio *prtd = priv; - struct snd_pcm_substream *substream = prtd->substream; - uint32_t *ptrmem = (uint32_t *)payload; - int i = 0; - uint32_t idx = 0; - uint32_t size = 0; - - pr_debug("%s\n", __func__); - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: { - pr_debug("ASM_DATA_EVENT_WRITE_DONE\n"); - pr_debug("Buffer Consumed = 0x%08x\n", *ptrmem); - prtd->pcm_irq_pos += prtd->pcm_count; - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - atomic_inc(&prtd->out_count); - wake_up(&the_locks.write_wait); - if (!atomic_read(&prtd->start)) - break; - if (!prtd->mmap_flag) - break; - if (q6asm_is_cpu_buf_avail_nolock(IN, - prtd->audio_client, - &size, &idx)) { - pr_debug("%s:writing %d bytes of buffer to dsp 2\n", - __func__, prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, 0, 0, NO_TIMESTAMP); - } - break; - } - case ASM_DATA_CMDRSP_EOS: - pr_debug("ASM_DATA_CMDRSP_EOS\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - break; - case ASM_DATA_EVENT_READ_DONE: { - pr_debug("ASM_DATA_EVENT_READ_DONE\n"); - pr_debug("token = 0x%08x\n", token); - for (i = 0; i < 8; i++, ++ptrmem) - pr_debug("cmd[%d]=0x%08x\n", i, *ptrmem); - in_frame_info[token][0] = payload[2]; - in_frame_info[token][1] = payload[3]; - prtd->pcm_irq_pos += in_frame_info[token][0]; - pr_debug("pcm_irq_pos=%d\n", prtd->pcm_irq_pos); - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - if (atomic_read(&prtd->in_count) <= prtd->periods) - atomic_inc(&prtd->in_count); - wake_up(&the_locks.read_wait); - if (prtd->mmap_flag - && q6asm_is_cpu_buf_avail_nolock(OUT, - prtd->audio_client, - &size, &idx)) - q6asm_read_nolock(prtd->audio_client); - break; - } - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case ASM_SESSION_CMD_RUN: - if (substream->stream - != SNDRV_PCM_STREAM_PLAYBACK) { - atomic_set(&prtd->start, 1); - break; - } - if (prtd->mmap_flag) { - pr_debug("%s:writing %d bytes buffer to dsp\n", - __func__, prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); - } else { - while (atomic_read(&prtd->out_needed)) { - pr_debug("%s:writing %d bytesto dsp\n", - __func__, prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); - atomic_dec(&prtd->out_needed); - wake_up(&the_locks.write_wait); - }; - } - atomic_set(&prtd->start, 1); - break; - default: - break; - } - } - break; - default: - pr_debug("Not Supported Event opcode[0x%x]\n", opcode); - break; - } -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret; - - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - if (prtd->enabled) - return 0; - - if (!prtd->set_channel_map) { - memset(prtd->channel_map, 0, PCM_FORMAT_MAX_NUM_CHANNEL); - if (prtd->channel_mode == 1) { - prtd->channel_map[0] = PCM_CHANNEL_FL; - } else if (prtd->channel_mode == 2) { - prtd->channel_map[0] = PCM_CHANNEL_FL; - prtd->channel_map[1] = PCM_CHANNEL_FR; - } else if (prtd->channel_mode == 6) { - prtd->channel_map[0] = PCM_CHANNEL_FC; - prtd->channel_map[1] = PCM_CHANNEL_FL; - prtd->channel_map[2] = PCM_CHANNEL_FR; - prtd->channel_map[3] = PCM_CHANNEL_LB; - prtd->channel_map[4] = PCM_CHANNEL_RB; - prtd->channel_map[5] = PCM_CHANNEL_LFE; - } else { - pr_err("%s: ERROR.unsupported num_ch = %u\n", __func__, - prtd->channel_mode); - } - } - ret = q6asm_media_format_block_multi_ch_pcm(prtd->audio_client, - runtime->rate, runtime->channels, prtd->channel_map); - if (ret < 0) - pr_info("%s: CMD Format block failed\n", __func__); - - atomic_set(&prtd->out_count, runtime->periods); - - prtd->enabled = 1; - prtd->cmd_ack = 0; - - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret = 0; - int i = 0; - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - - if (prtd->enabled) - return 0; - - pr_debug("Samp_rate = %d\n", prtd->samp_rate); - pr_debug("Channel = %d\n", prtd->channel_mode); - ret = q6asm_enc_cfg_blk_pcm(prtd->audio_client, prtd->samp_rate, - prtd->channel_mode); - if (ret < 0) - pr_debug("%s: cmd cfg pcm was block failed", __func__); - - for (i = 0; i < runtime->periods; i++) - q6asm_read(prtd->audio_client); - prtd->periods = runtime->periods; - - prtd->enabled = 1; - - return ret; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("%s: Trigger start\n", __func__); - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); - break; - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - atomic_set(&prtd->start, 0); - if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) - break; - prtd->cmd_ack = 0; - q6asm_cmd_nowait(prtd->audio_client, CMD_EOS); - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("SNDRV_PCM_TRIGGER_PAUSE\n"); - q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE); - atomic_set(&prtd->start, 0); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd; - int ret = 0; - pr_debug("%s lowlatency\n", __func__); - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - if (prtd == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - return -ENOMEM; - } - prtd->substream = substream; - prtd->audio_client = q6asm_audio_client_alloc( - (app_cb)event_handler, prtd); - if (!prtd->audio_client) { - pr_err("%s: Could not allocate memory\n", __func__); - kfree(prtd); - return -ENOMEM; - } - prtd->audio_client->perf_mode = true; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw = msm_pcm_hardware_playback; - ret = q6asm_open_write(prtd->audio_client, - FORMAT_MULTI_CHANNEL_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm out open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - } - /* Capture path */ - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - runtime->hw = msm_pcm_hardware_capture; - ret = q6asm_open_read_v2_1(prtd->audio_client, - FORMAT_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm in open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - } - - pr_debug("%s: session ID %d\n", __func__, prtd->audio_client->session); - - prtd->session_id = prtd->audio_client->session; - msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, substream->stream); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - prtd->cmd_ack = 1; - - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_err("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_err("snd_pcm_hw_constraint_integer failed\n"); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = snd_pcm_hw_constraint_minmax(runtime, - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - PLAYBACK_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE, - PLAYBACK_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE); - if (ret < 0) { - pr_err("constraint for buffer bytes min max ret = %d\n", - ret); - } - } - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - ret = snd_pcm_hw_constraint_minmax(runtime, - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - CAPTURE_NUM_PERIODS * CAPTURE_MIN_PERIOD_SIZE, - CAPTURE_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE); - if (ret < 0) { - pr_err("constraint for buffer bytes min max ret = %d\n", - ret); - } - } - - prtd->dsp_cnt = 0; - prtd->set_channel_map = false; - runtime->private_data = prtd; - pr_debug("substream->pcm->device = %d\n", substream->pcm->device); - pr_debug("soc_prtd->dai_link->be_id = %d\n", soc_prtd->dai_link->be_id); - return 0; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer = 0; - char *bufptr = NULL; - void *data = NULL; - uint32_t idx = 0; - uint32_t size = 0; - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - fbytes = frames_to_bytes(runtime, frames); - pr_debug("%s: prtd->out_count = %d\n", - __func__, atomic_read(&prtd->out_count)); - ret = wait_event_timeout(the_locks.write_wait, - (atomic_read(&prtd->out_count)), 5 * HZ); - if (!ret) { - pr_err("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - - if (!atomic_read(&prtd->out_count)) { - pr_err("%s: pcm stopped out_count 0\n", __func__); - return 0; - } - - data = q6asm_is_cpu_buf_avail(IN, prtd->audio_client, &size, &idx); - bufptr = data; - if (bufptr) { - pr_debug("%s:fbytes =%d: xfer=%d size=%d\n", - __func__, fbytes, xfer, size); - xfer = fbytes; - if (copy_from_user(bufptr, buf, xfer)) { - ret = -EFAULT; - goto fail; - } - buf += xfer; - fbytes -= xfer; - pr_debug("%s:fbytes = %d: xfer=%d\n", __func__, fbytes, xfer); - if (atomic_read(&prtd->start)) { - pr_debug("%s:writing %d bytes of buffer to dsp\n", - __func__, xfer); - ret = q6asm_write(prtd->audio_client, xfer, - 0, 0, NO_TIMESTAMP); - if (ret < 0) { - ret = -EFAULT; - goto fail; - } - } else - atomic_inc(&prtd->out_needed); - atomic_dec(&prtd->out_count); - } -fail: - return ret; -} - -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = runtime->private_data; - int dir = 0; - int ret = 0; - - pr_debug("%s\n", __func__); - - dir = IN; - ret = wait_event_timeout(the_locks.eos_wait, - prtd->cmd_ack, 5 * HZ); - if (!ret) - pr_err("%s: CMD_EOS failed\n", __func__); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_PLAYBACK); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return 0; -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer; - char *bufptr; - void *data = NULL; - static uint32_t idx; - static uint32_t size; - uint32_t offset = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = substream->runtime->private_data; - - - pr_debug("%s\n", __func__); - fbytes = frames_to_bytes(runtime, frames); - - pr_debug("appl_ptr %d\n", (int)runtime->control->appl_ptr); - pr_debug("hw_ptr %d\n", (int)runtime->status->hw_ptr); - pr_debug("avail_min %d\n", (int)runtime->control->avail_min); - - ret = wait_event_timeout(the_locks.read_wait, - (atomic_read(&prtd->in_count)), 5 * HZ); - if (!ret) { - pr_debug("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - if (!atomic_read(&prtd->in_count)) { - pr_debug("%s: pcm stopped in_count 0\n", __func__); - return 0; - } - pr_debug("Checking if valid buffer is available...%08x\n", - (unsigned int) data); - data = q6asm_is_cpu_buf_avail(OUT, prtd->audio_client, &size, &idx); - bufptr = data; - pr_debug("Size = %d\n", size); - pr_debug("fbytes = %d\n", fbytes); - pr_debug("idx = %d\n", idx); - if (bufptr) { - xfer = fbytes; - if (xfer > size) - xfer = size; - offset = in_frame_info[idx][1]; - pr_debug("Offset value = %d\n", offset); - if (copy_to_user(buf, bufptr+offset, xfer)) { - pr_err("Failed to copy buf to user\n"); - ret = -EFAULT; - goto fail; - } - fbytes -= xfer; - size -= xfer; - in_frame_info[idx][1] += xfer; - pr_debug("%s:fbytes = %d: size=%d: xfer=%d\n", - __func__, fbytes, size, xfer); - pr_debug(" Sending next buffer to dsp\n"); - memset(&in_frame_info[idx], 0, - sizeof(uint32_t) * 2); - atomic_dec(&prtd->in_count); - ret = q6asm_read(prtd->audio_client); - if (ret < 0) { - pr_err("q6asm read failed\n"); - ret = -EFAULT; - goto fail; - } - } else - pr_err("No valid buffer\n"); - - pr_debug("Returning from capture_copy... %d\n", ret); -fail: - return ret; -} - -static int msm_pcm_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = runtime->private_data; - int dir = OUT; - - pr_debug("%s\n", __func__); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_CAPTURE); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - - return 0; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_close(substream); - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - - pr_debug("pcm_irq_pos = %d\n", prtd->pcm_irq_pos); - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - int result = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - prtd->mmap_flag = 1; - - if (runtime->dma_addr && runtime->dma_bytes) { - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - result = remap_pfn_range(vma, vma->vm_start, - runtime->dma_addr >> PAGE_SHIFT, - runtime->dma_bytes, - vma->vm_page_prot); - } else { - pr_err("Physical address or size of buf is NULL"); - return -EINVAL; - } - - return result; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct audio_buffer *buf; - int dir, ret; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dir = IN; - else - dir = OUT; - - /* - *TODO : Need to Add Async IO changes. All period - * size might not be supported. - */ - ret = q6asm_audio_client_buf_alloc_contiguous(dir, - prtd->audio_client, - (params_buffer_bytes(params) / params_periods(params)), - params_periods(params)); - - if (ret < 0) { - pr_err("Audio Start: Buffer Allocation failed rc = %d\n", ret); - return -ENOMEM; - } - buf = prtd->audio_client->port[dir].buf; - - pr_debug("%s:buf = %p\n", __func__, buf); - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - dma_buf->area = buf[0].data; - dma_buf->addr = buf[0].phys; - dma_buf->bytes = params_buffer_bytes(params); - if (!dma_buf->area) - return -ENOMEM; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-lowlatency-pcm-dsp", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - init_waitqueue_head(&the_locks.enable_wait); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("Multi channel PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-multi-ch-pcm-q6.c b/sound/soc/msm/msm-multi-ch-pcm-q6.c deleted file mode 100644 index 25aa19b7c88aefd6181510ada039c5faee98e6c6..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-multi-ch-pcm-q6.c +++ /dev/null @@ -1,954 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm-q6.h" -#include "msm-pcm-routing.h" - -static struct audio_locks the_locks; - -struct snd_msm { - struct snd_card *card; - struct snd_pcm *pcm; -}; - -struct snd_msm_volume { - struct msm_audio *prtd; - unsigned volume; -}; -static struct snd_msm_volume multi_ch_pcm_audio = {NULL, 0x2000}; - -#define PLAYBACK_NUM_PERIODS 8 -#define PLAYBACK_MAX_PERIOD_SIZE 12288 -#define PLAYBACK_MIN_PERIOD_SIZE 256 -#define CAPTURE_NUM_PERIODS 16 -#define CAPTURE_MIN_PERIOD_SIZE 320 -#define CAPTURE_MAX_PERIOD_SIZE 12288 - -static struct snd_pcm_hardware msm_pcm_hardware_capture = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 8, - .buffer_bytes_max = CAPTURE_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE, - .period_bytes_min = CAPTURE_MIN_PERIOD_SIZE, - .period_bytes_max = CAPTURE_MAX_PERIOD_SIZE, - .periods_min = CAPTURE_NUM_PERIODS, - .periods_max = CAPTURE_NUM_PERIODS, - .fifo_size = 0, -}; - -static struct snd_pcm_hardware msm_pcm_hardware_playback = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 8, - .buffer_bytes_max = PLAYBACK_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE, - .period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE, - .period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE, - .periods_min = PLAYBACK_NUM_PERIODS, - .periods_max = PLAYBACK_NUM_PERIODS, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static uint32_t in_frame_info[CAPTURE_NUM_PERIODS][2]; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static void event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ - struct msm_audio *prtd = priv; - struct snd_pcm_substream *substream = prtd->substream; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_aio_write_param param; - struct audio_buffer *buf = NULL; - uint32_t *ptrmem = (uint32_t *)payload; - int i = 0; - uint32_t idx = 0; - uint32_t size = 0; - - pr_debug("%s\n", __func__); - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: { - uint32_t *ptrmem = (uint32_t *)¶m; - pr_debug("ASM_DATA_EVENT_WRITE_DONE\n"); - pr_debug("Buffer Consumed = 0x%08x\n", *ptrmem); - prtd->pcm_irq_pos += prtd->pcm_count; - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - atomic_inc(&prtd->out_count); - wake_up(&the_locks.write_wait); - if (!atomic_read(&prtd->start)) - break; - if (!prtd->mmap_flag) - break; - buf = prtd->audio_client->port[IN].buf; - pr_debug("%s:writing %d bytes of buffer[%d] to dsp 2\n", - __func__, prtd->pcm_count, prtd->out_head); - pr_debug("%s:writing buffer[%d] from 0x%08x\n", - __func__, prtd->out_head, - ((unsigned int)buf[0].phys - + (prtd->out_head * prtd->pcm_count))); - param.paddr = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count); - param.len = prtd->pcm_count; - param.msw_ts = 0; - param.lsw_ts = 0; - param.flags = NO_TIMESTAMP; - param.uid = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count); - for (i = 0; i < sizeof(struct audio_aio_write_param)/4; - i++, ++ptrmem) - pr_debug("cmd[%d]=0x%08x\n", i, *ptrmem); - if (q6asm_async_write(prtd->audio_client, - ¶m) < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - else - prtd->out_head = - (prtd->out_head + 1) & (runtime->periods - 1); - break; - } - case ASM_DATA_CMDRSP_EOS: - pr_debug("ASM_DATA_CMDRSP_EOS\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - break; - case ASM_DATA_EVENT_READ_DONE: { - pr_debug("ASM_DATA_EVENT_READ_DONE\n"); - pr_debug("token = 0x%08x\n", token); - for (i = 0; i < 8; i++, ++ptrmem) - pr_debug("cmd[%d]=0x%08x\n", i, *ptrmem); - in_frame_info[token][0] = payload[2]; - in_frame_info[token][1] = payload[3]; - prtd->pcm_irq_pos += in_frame_info[token][0]; - pr_debug("pcm_irq_pos=%d\n", prtd->pcm_irq_pos); - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - if (atomic_read(&prtd->in_count) <= prtd->periods) - atomic_inc(&prtd->in_count); - wake_up(&the_locks.read_wait); - if (prtd->mmap_flag - && q6asm_is_cpu_buf_avail_nolock(OUT, - prtd->audio_client, - &size, &idx)) - q6asm_read_nolock(prtd->audio_client); - break; - } - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case ASM_SESSION_CMD_RUN: - if (substream->stream - != SNDRV_PCM_STREAM_PLAYBACK) { - atomic_set(&prtd->start, 1); - break; - } - if (prtd->mmap_flag) { - pr_debug("%s:writing %d bytes"\ - " of buffer[%d] to dsp\n", - __func__, prtd->pcm_count, - prtd->out_head); - buf = prtd->audio_client->port[IN].buf; - pr_debug("%s:writing buffer[%d] from 0x%08x\n", - __func__, prtd->out_head, - ((unsigned int)buf[0].phys - + (prtd->out_head * prtd->pcm_count))); - param.paddr = (unsigned long) - buf[prtd->out_head].phys; - param.len = prtd->pcm_count; - param.msw_ts = 0; - param.lsw_ts = 0; - param.flags = NO_TIMESTAMP; - param.uid = (unsigned long) - buf[prtd->out_head].phys; - if (q6asm_async_write(prtd->audio_client, - ¶m) < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - else - prtd->out_head = - (prtd->out_head + 1) - & (runtime->periods - 1); - } else { - while (atomic_read(&prtd->out_needed)) { - pr_debug("%s:writing %d bytesi" \ - " of buffer to dsp\n", \ - __func__, \ - prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); - atomic_dec(&prtd->out_needed); - wake_up(&the_locks.write_wait); - }; - } - atomic_set(&prtd->start, 1); - break; - case ASM_STREAM_CMD_FLUSH: - pr_debug("ASM_STREAM_CMD_FLUSH\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.flush_wait); - break; - default: - break; - } - } - break; - default: - pr_debug("Not Supported Event opcode[0x%x]\n", opcode); - break; - } -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret; - - pr_debug("%s\n", __func__); - if (prtd->mmap_flag) { - ret = q6asm_set_io_mode(prtd->audio_client, ASYNC_IO_MODE); - if (ret < 0) { - pr_err("%s: Set IO mode failed\n", __func__); - return -ENOMEM; - } - } - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - if (prtd->enabled) - return 0; - pr_debug("prtd->set_channel_map: %d", prtd->set_channel_map); - if (!prtd->set_channel_map) { - pr_debug("using default channel map"); - memset(prtd->channel_map, 0, PCM_FORMAT_MAX_NUM_CHANNEL); - if (prtd->channel_mode == 1) { - prtd->channel_map[0] = PCM_CHANNEL_FL; - } else if (prtd->channel_mode == 2) { - prtd->channel_map[0] = PCM_CHANNEL_FL; - prtd->channel_map[1] = PCM_CHANNEL_FR; - } else if (prtd->channel_mode == 6) { - prtd->channel_map[0] = PCM_CHANNEL_FC; - prtd->channel_map[1] = PCM_CHANNEL_FL; - prtd->channel_map[2] = PCM_CHANNEL_FR; - prtd->channel_map[3] = PCM_CHANNEL_LB; - prtd->channel_map[4] = PCM_CHANNEL_RB; - prtd->channel_map[5] = PCM_CHANNEL_LFE; - } else { - pr_err("%s: ERROR.unsupported num_ch = %u\n", __func__, - prtd->channel_mode); - } - } - ret = q6asm_media_format_block_multi_ch_pcm(prtd->audio_client, - runtime->rate, runtime->channels, prtd->channel_map); - if (ret < 0) - pr_info("%s: CMD Format block failed\n", __func__); - - atomic_set(&prtd->out_count, runtime->periods); - - prtd->enabled = 1; - prtd->cmd_ack = 0; - - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret = 0; - int i = 0; - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - - if (prtd->enabled) - return 0; - - pr_debug("Samp_rate = %d\n", prtd->samp_rate); - pr_debug("Channel = %d\n", prtd->channel_mode); - ret = q6asm_enc_cfg_blk_multi_ch_pcm(prtd->audio_client, - prtd->samp_rate, prtd->channel_mode); - if (ret < 0) - pr_debug("%s: cmd cfg pcm was block failed", __func__); - - for (i = 0; i < runtime->periods; i++) - q6asm_read(prtd->audio_client); - prtd->periods = runtime->periods; - - prtd->enabled = 1; - - return ret; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("%s: Trigger start\n", __func__); - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); - break; - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - atomic_set(&prtd->start, 0); - if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) - break; - prtd->cmd_ack = 0; - q6asm_cmd_nowait(prtd->audio_client, CMD_EOS); - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("SNDRV_PCM_TRIGGER_PAUSE\n"); - q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE); - atomic_set(&prtd->start, 0); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd; - int ret = 0; - struct asm_softpause_params softpause = { - .enable = SOFT_PAUSE_ENABLE, - .period = SOFT_PAUSE_PERIOD, - .step = SOFT_PAUSE_STEP, - .rampingcurve = SOFT_PAUSE_CURVE_LINEAR, - }; - struct asm_softvolume_params softvol = { - .period = SOFT_VOLUME_PERIOD, - .step = SOFT_VOLUME_STEP, - .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, - }; - - pr_debug("%s\n", __func__); - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - if (prtd == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - return -ENOMEM; - } - prtd->substream = substream; - prtd->audio_client = q6asm_audio_client_alloc( - (app_cb)event_handler, prtd); - if (!prtd->audio_client) { - pr_err("%s: Could not allocate memory\n", __func__); - kfree(prtd); - return -ENOMEM; - } - prtd->audio_client->perf_mode = false; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw = msm_pcm_hardware_playback; - ret = q6asm_open_write(prtd->audio_client, - FORMAT_MULTI_CHANNEL_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm out open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - } - /* Capture path */ - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - runtime->hw = msm_pcm_hardware_capture; - ret = q6asm_open_read(prtd->audio_client, - FORMAT_MULTI_CHANNEL_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm in open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - } - - pr_debug("%s: session ID %d\n", __func__, prtd->audio_client->session); - - prtd->session_id = prtd->audio_client->session; - msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, substream->stream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - prtd->cmd_ack = 1; - - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_err("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_err("snd_pcm_hw_constraint_integer failed\n"); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = snd_pcm_hw_constraint_minmax(runtime, - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - PLAYBACK_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE, - PLAYBACK_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE); - if (ret < 0) { - pr_err("constraint for buffer bytes min max ret = %d\n", - ret); - } - } - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - ret = snd_pcm_hw_constraint_minmax(runtime, - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - CAPTURE_NUM_PERIODS * CAPTURE_MIN_PERIOD_SIZE, - CAPTURE_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE); - if (ret < 0) { - pr_err("constraint for buffer bytes min max ret = %d\n", - ret); - } - } - - prtd->dsp_cnt = 0; - prtd->set_channel_map = false; - runtime->private_data = prtd; - pr_debug("substream->pcm->device = %d\n", substream->pcm->device); - pr_debug("soc_prtd->dai_link->be_id = %d\n", soc_prtd->dai_link->be_id); - multi_ch_pcm_audio.prtd = prtd; - ret = multi_ch_pcm_set_volume(multi_ch_pcm_audio.volume); - if (ret < 0) - pr_err("%s : Set Volume failed : %d", __func__, ret); - - ret = q6asm_set_softpause(multi_ch_pcm_audio.prtd->audio_client, - &softpause); - if (ret < 0) - pr_err("%s: Send SoftPause Param failed ret=%d\n", - __func__, ret); - ret = q6asm_set_softvolume(multi_ch_pcm_audio.prtd->audio_client, - &softvol); - if (ret < 0) - pr_err("%s: Send SoftVolume Param failed ret=%d\n", - __func__, ret); - - return 0; -} - -int multi_ch_pcm_set_volume(unsigned volume) -{ - int rc = 0; - pr_err("multi_ch_pcm_set_volume\n"); - - if (multi_ch_pcm_audio.prtd && multi_ch_pcm_audio.prtd->audio_client) { - pr_err("%s q6asm_set_volume\n", __func__); - rc = q6asm_set_volume(multi_ch_pcm_audio.prtd->audio_client, - volume); - if (rc < 0) { - pr_err("%s: Send Volume command failed" - " rc=%d\n", __func__, rc); - } - } - multi_ch_pcm_audio.volume = volume; - return rc; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer = 0; - char *bufptr = NULL; - void *data = NULL; - uint32_t idx = 0; - uint32_t size = 0; - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - fbytes = frames_to_bytes(runtime, frames); - pr_debug("%s: prtd->out_count = %d\n", - __func__, atomic_read(&prtd->out_count)); - ret = wait_event_timeout(the_locks.write_wait, - (atomic_read(&prtd->out_count)), 5 * HZ); - if (!ret) { - pr_err("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - - if (!atomic_read(&prtd->out_count)) { - pr_err("%s: pcm stopped out_count 0\n", __func__); - return 0; - } - - data = q6asm_is_cpu_buf_avail(IN, prtd->audio_client, &size, &idx); - bufptr = data; - if (bufptr) { - pr_debug("%s:fbytes =%d: xfer=%d size=%d\n", - __func__, fbytes, xfer, size); - xfer = fbytes; - if (copy_from_user(bufptr, buf, xfer)) { - ret = -EFAULT; - goto fail; - } - buf += xfer; - fbytes -= xfer; - pr_debug("%s:fbytes = %d: xfer=%d\n", __func__, fbytes, xfer); - if (atomic_read(&prtd->start)) { - pr_debug("%s:writing %d bytes of buffer to dsp\n", - __func__, xfer); - ret = q6asm_write(prtd->audio_client, xfer, - 0, 0, NO_TIMESTAMP); - if (ret < 0) { - ret = -EFAULT; - goto fail; - } - } else - atomic_inc(&prtd->out_needed); - atomic_dec(&prtd->out_count); - } -fail: - return ret; -} - -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = runtime->private_data; - int dir = 0; - int ret = 0; - - pr_debug("%s\n", __func__); - - dir = IN; - ret = wait_event_timeout(the_locks.eos_wait, - prtd->cmd_ack, 5 * HZ); - if (!ret) - pr_err("%s: CMD_EOS failed\n", __func__); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_PLAYBACK); - multi_ch_pcm_audio.prtd = NULL; - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return 0; -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer; - char *bufptr; - void *data = NULL; - static uint32_t idx; - static uint32_t size; - uint32_t offset = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = substream->runtime->private_data; - - - pr_debug("%s\n", __func__); - fbytes = frames_to_bytes(runtime, frames); - - pr_debug("appl_ptr %d\n", (int)runtime->control->appl_ptr); - pr_debug("hw_ptr %d\n", (int)runtime->status->hw_ptr); - pr_debug("avail_min %d\n", (int)runtime->control->avail_min); - - ret = wait_event_timeout(the_locks.read_wait, - (atomic_read(&prtd->in_count)), 5 * HZ); - if (!ret) { - pr_debug("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - if (!atomic_read(&prtd->in_count)) { - pr_debug("%s: pcm stopped in_count 0\n", __func__); - return 0; - } - pr_debug("Checking if valid buffer is available...%08x\n", - (unsigned int) data); - data = q6asm_is_cpu_buf_avail(OUT, prtd->audio_client, &size, &idx); - bufptr = data; - pr_debug("Size = %d\n", size); - pr_debug("fbytes = %d\n", fbytes); - pr_debug("idx = %d\n", idx); - if (bufptr) { - xfer = fbytes; - if (xfer > size) - xfer = size; - offset = in_frame_info[idx][1]; - pr_debug("Offset value = %d\n", offset); - if (copy_to_user(buf, bufptr+offset, xfer)) { - pr_err("Failed to copy buf to user\n"); - ret = -EFAULT; - goto fail; - } - fbytes -= xfer; - size -= xfer; - in_frame_info[idx][1] += xfer; - pr_debug("%s:fbytes = %d: size=%d: xfer=%d\n", - __func__, fbytes, size, xfer); - pr_debug(" Sending next buffer to dsp\n"); - memset(&in_frame_info[idx], 0, - sizeof(uint32_t) * 2); - atomic_dec(&prtd->in_count); - ret = q6asm_read(prtd->audio_client); - if (ret < 0) { - pr_err("q6asm read failed\n"); - ret = -EFAULT; - goto fail; - } - } else - pr_err("No valid buffer\n"); - - pr_debug("Returning from capture_copy... %d\n", ret); -fail: - return ret; -} - -static int msm_pcm_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = runtime->private_data; - int dir = OUT; - - pr_debug("%s\n", __func__); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_CAPTURE); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - - return 0; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_close(substream); - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - - pr_debug("pcm_irq_pos = %d\n", prtd->pcm_irq_pos); - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - int result = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - prtd->mmap_flag = 1; - - if (runtime->dma_addr && runtime->dma_bytes) { - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - result = remap_pfn_range(vma, vma->vm_start, - runtime->dma_addr >> PAGE_SHIFT, - runtime->dma_bytes, - vma->vm_page_prot); - } else { - pr_err("Physical address or size of buf is NULL"); - return -EINVAL; - } - - return result; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct audio_buffer *buf; - int dir, ret; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dir = IN; - else - dir = OUT; - - ret = q6asm_audio_client_buf_alloc_contiguous(dir, - prtd->audio_client, - (params_buffer_bytes(params) / params_periods(params)), - params_periods(params)); - - if (ret < 0) { - pr_err("Audio Start: Buffer Allocation failed rc = %d\n", ret); - return -ENOMEM; - } - buf = prtd->audio_client->port[dir].buf; - - pr_debug("%s:buf = %p\n", __func__, buf); - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - dma_buf->area = buf[0].data; - dma_buf->addr = buf[0].phys; - dma_buf->bytes = params_buffer_bytes(params); - if (!dma_buf->area) - return -ENOMEM; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} -static int msm_pcm_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret = 0, rc; - - pr_debug("%s\n", __func__); - ret = snd_pcm_lib_ioctl(substream, cmd, arg); - if (ret < 0) { - pr_err("%s, snd_pcm_lib_ioctl error\n", __func__); - return ret; - } - - switch (cmd) { - case SNDRV_PCM_IOCTL1_RESET: - pr_debug("%s, SNDRV_PCM_IOCTL1_RESET\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - prtd->cmd_ack = 0; - rc = q6asm_cmd(prtd->audio_client, CMD_FLUSH); - if (rc < 0) { - pr_err("%s: flush cmd failed rc=%d\n", - __func__, rc); - break; - } - rc = wait_event_timeout(the_locks.flush_wait, - prtd->cmd_ack, 5 * HZ); - if (rc < 0) - pr_err("Flush cmd timeout\n"); - prtd->pcm_irq_pos = 0; - atomic_set(&prtd->out_count, runtime->periods); - } - break; - default: - break; - } - - return ret; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = msm_pcm_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - - -static int pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int i; - char channel_mapping[PCM_FORMAT_MAX_NUM_CHANNEL]; - - pr_debug("%s", __func__); - for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++) - channel_mapping[i] = (char)(ucontrol->value.integer.value[i]); - if (multi_ch_pcm_audio.prtd) { - multi_ch_pcm_audio.prtd->set_channel_map = true; - memcpy(multi_ch_pcm_audio.prtd->channel_map, channel_mapping, - PCM_FORMAT_MAX_NUM_CHANNEL); - } - return 0; -} - - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm->streams[0].pcm; - struct snd_pcm_chmap *chmap_info; - struct snd_kcontrol *kctl; - char device_num[3]; - - int i, ret = 0; - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - - pr_debug("%s, Channel map cntrl add\n", __func__); - ret = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, - NULL, PCM_FORMAT_MAX_NUM_CHANNEL, 0, - &chmap_info); - if (ret < 0) - return ret; - kctl = chmap_info->kctl; - for (i = 0; i < kctl->count; i++) - kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_WRITE; - snprintf(device_num, sizeof(device_num), "%d", pcm->device); - strlcat(kctl->id.name, device_num, sizeof(kctl->id.name)); - pr_debug("%s, Overwriting channel map control name to: %s", - __func__, kctl->id.name); - kctl->put = pcm_chmap_ctl_put; - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-multi-ch-pcm-dsp", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - init_waitqueue_head(&the_locks.enable_wait); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - init_waitqueue_head(&the_locks.flush_wait); - - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("Multi channel PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-mvs.c b/sound/soc/msm/msm-mvs.c deleted file mode 100644 index 87dd68cb51ccbee0d650c0a1d854a812de90a27f..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-mvs.c +++ /dev/null @@ -1,936 +0,0 @@ -/* Copyright (c) 2010, The Linux Foundation. All rights reserved. - * - * All source code in this file is licensed under the following license except - * where indicated. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm_audio_mvs.h" - - -static struct audio_mvs_info_type audio_mvs_info; - -static struct snd_pcm_hardware msm_pcm_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = (SNDRV_PCM_RATE_8000), - .rate_min = 8000, - .rate_max = 8000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = MVS_MAX_VOC_PKT_SIZE * MVS_MAX_Q_LEN, - .period_bytes_min = MVS_MAX_VOC_PKT_SIZE, - .period_bytes_max = MVS_MAX_VOC_PKT_SIZE, - .periods_min = MVS_MAX_Q_LEN, - .periods_max = MVS_MAX_Q_LEN, - .fifo_size = 0, -}; - -static void snd_pcm_mvs_timer(unsigned long data) -{ - struct audio_mvs_info_type *audio = &audio_mvs_info; - MM_DBG("%s\n", __func__); - if (audio->playback_start) { - if (audio->ack_dl_count) { - audio->pcm_playback_irq_pos += audio->pcm_count; - audio->ack_dl_count--; - snd_pcm_period_elapsed(audio->playback_substream); - } - } - - if (audio->capture_start) { - if (audio->ack_ul_count) { - audio->pcm_capture_irq_pos += audio->pcm_capture_count; - audio->ack_ul_count--; - snd_pcm_period_elapsed(audio->capture_substream); - } - } - audio->timer.expires += audio->expiry_delta; - add_timer(&audio->timer); -} - -static int audio_mvs_setup_mvs(struct audio_mvs_info_type *audio) -{ - int rc = 0; - struct audio_mvs_enable_msg enable_msg; - MM_DBG("%s\n", __func__); - - /* Enable MVS. */ - - memset(&enable_msg, 0, sizeof(enable_msg)); - audio->rpc_status = RPC_STATUS_FAILURE; - enable_msg.enable_args.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP); - enable_msg.enable_args.mode = cpu_to_be32(MVS_MODE_LINEAR_PCM); - enable_msg.enable_args.ul_cb_func_id = (int) NULL; - enable_msg.enable_args.dl_cb_func_id = (int) NULL; - enable_msg.enable_args.context = cpu_to_be32(MVS_PKT_CONTEXT_ISR); - - msm_rpc_setup_req(&enable_msg.rpc_hdr, MVS_PROG, - MVS_VERS, MVS_ENABLE_PROC); - - rc = msm_rpc_write(audio->rpc_endpt, - &enable_msg, sizeof(enable_msg)); - - if (rc >= 0) { - MM_DBG("RPC write for enable done\n"); - - rc = wait_event_timeout(audio->wait, - (audio->rpc_status != - RPC_STATUS_FAILURE), 1 * HZ); - - if (rc > 0) { - MM_DBG("Wait event for enable succeeded\n"); - - mutex_lock(&audio->lock); - audio->mvs_mode = MVS_MODE_LINEAR_PCM; - audio->frame_mode = MVS_FRAME_MODE_PCM_DL; - audio->pcm_frame = 0; - mutex_unlock(&audio->lock); - rc = 0; - - } else - MM_ERR("Wait event for enable failed %d\n", rc); - } else - MM_ERR("RPC write for enable failed %d\n", rc); - return rc; -} - -static void audio_mvs_rpc_reply(struct msm_rpc_endpoint *endpoint, - uint32_t xid) -{ - int rc = 0; - struct rpc_reply_hdr reply_hdr; - MM_DBG("%s\n", __func__); - - memset(&reply_hdr, 0, sizeof(reply_hdr)); - reply_hdr.xid = cpu_to_be32(xid); - reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY); - reply_hdr.reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED); - reply_hdr.data.acc_hdr.accept_stat = - cpu_to_be32(RPC_ACCEPTSTAT_SUCCESS); - reply_hdr.data.acc_hdr.verf_flavor = 0; - reply_hdr.data.acc_hdr.verf_length = 0; - - rc = msm_rpc_write(endpoint, &reply_hdr, sizeof(reply_hdr)); - - if (rc < 0) - MM_ERR("RPC write for response failed %d\n", rc); -} - -static void audio_mvs_process_rpc_request(uint32_t procedure, uint32_t xid, - void *data, uint32_t length, - struct audio_mvs_info_type *audio) -{ - - int rc = 0; - uint32_t index; - MM_DBG("%s\n", __func__); - switch (procedure) { - case MVS_EVENT_CB_TYPE_PROC:{ - struct audio_mvs_cb_func_args *args = data; - uint32_t event_type = be32_to_cpu(args->event); - uint32_t cmd_status = - be32_to_cpu(args-> - event_data.mvs_ev_command_type.cmd_status); - uint32_t mode_status = - be32_to_cpu(args-> - event_data.mvs_ev_mode_type.mode_status); - audio_mvs_rpc_reply(audio->rpc_endpt, xid); - if (be32_to_cpu(args->valid_ptr)) { - if (event_type == AUDIO_MVS_COMMAND) { - if (cmd_status == AUDIO_MVS_CMD_SUCCESS) - audio->rpc_status = RPC_STATUS_SUCCESS; - wake_up(&audio->wait); - } else if (event_type == AUDIO_MVS_MODE) { - if (mode_status != AUDIO_MVS_MODE_NOT_AVAIL) { - audio->rpc_status = - RPC_STATUS_SUCCESS; - } - audio->prepare_ack++; - wake_up(&audio->wait); - wake_up(&audio->prepare_wait); - } else { - /*nothing to do */ - } - } else - MM_ERR("ALSA: CB event pointer not valid\n"); - break; - } - case MVS_PACKET_UL_FN_TYPE_PROC:{ - uint32_t *cb_data = data; - uint32_t pkt_len ; - struct audio_mvs_ul_reply ul_reply; - MM_DBG("MVS_PACKET_UL_FN_TYPE_PROC\n"); - - memset(&ul_reply, 0, sizeof(ul_reply)); - cb_data++; - pkt_len = be32_to_cpu(*cb_data); - cb_data++; - if (audio->capture_enable) { - audio_mvs_info.ack_ul_count++; - mutex_lock(&audio->out_lock); - index = audio->out_write % MVS_MAX_Q_LEN; - memcpy(audio->out[index].voc_pkt, cb_data, - pkt_len); - audio->out[index].len = pkt_len; - audio->out_write++; - mutex_unlock(&audio->out_lock); - } - MM_DBG(" audio->out_read = %d audio->out write = %d\n", - audio->out_read, audio->out_write); - ul_reply.reply_hdr.xid = cpu_to_be32(xid); - ul_reply.reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY); - ul_reply.reply_hdr.reply_stat = - cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED); - ul_reply.reply_hdr.data.acc_hdr.accept_stat = - cpu_to_be32(RPC_ACCEPTSTAT_SUCCESS); - ul_reply.reply_hdr.data.acc_hdr.verf_flavor = 0; - ul_reply.reply_hdr.data.acc_hdr.verf_length = 0; - ul_reply.valid_pkt_status_ptr = cpu_to_be32(0x00000001); - ul_reply.pkt_status = cpu_to_be32(0x00000000); - rc = msm_rpc_write(audio->rpc_endpt, &ul_reply, - sizeof(ul_reply)); - wake_up(&audio->out_wait); - if (rc < 0) - MM_ERR("RPC write for UL response failed %d\n", - rc); - break; - } - case MVS_PACKET_DL_FN_TYPE_PROC:{ - struct audio_mvs_dl_reply dl_reply; - MM_DBG("MVS_PACKET_DL_FN_TYPE_PROC\n"); - memset(&dl_reply, 0, sizeof(dl_reply)); - dl_reply.reply_hdr.xid = cpu_to_be32(xid); - dl_reply.reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY); - dl_reply.reply_hdr.reply_stat = - cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED); - dl_reply.reply_hdr.data.acc_hdr.accept_stat = - cpu_to_be32(RPC_ACCEPTSTAT_SUCCESS); - dl_reply.reply_hdr.data.acc_hdr.verf_flavor = 0; - dl_reply.reply_hdr.data.acc_hdr.verf_length = 0; - mutex_lock(&audio->in_lock); - if (audio->in_read < audio->in_write - && audio->dl_play) { - index = audio->in_read % MVS_MAX_Q_LEN; - memcpy(&dl_reply.voc_pkt, - audio->in[index].voc_pkt, - audio->in[index].len); - audio->in_read++; - audio_mvs_info.ack_dl_count++; - dl_reply.pkt_status = - cpu_to_be32(AUDIO_MVS_PKT_NORMAL); - wake_up(&audio->in_wait); - } else { - dl_reply.pkt_status = - cpu_to_be32(AUDIO_MVS_PKT_SLOW); - } - mutex_unlock(&audio->in_lock); - MM_DBG(" audio->in_read = %d audio->in write = %d\n", - audio->in_read, audio->in_write); - dl_reply.valid_frame_info_ptr = cpu_to_be32(0x00000001); - dl_reply.frame_mode = cpu_to_be32(audio->frame_mode); - dl_reply.frame_mode_again = - cpu_to_be32(audio->frame_mode); - dl_reply.frame_info_hdr.frame_mode = - cpu_to_be32(audio->frame_mode); - dl_reply.frame_info_hdr.mvs_mode = - cpu_to_be32(audio->mvs_mode); - dl_reply.frame_info_hdr.buf_free_cnt = 0; - dl_reply.pcm_frame = cpu_to_be32(audio->pcm_frame); - dl_reply.pcm_mode = cpu_to_be32(audio->pcm_mode); - dl_reply.valid_pkt_status_ptr = cpu_to_be32(0x00000001); - rc = msm_rpc_write(audio->rpc_endpt, &dl_reply, - sizeof(dl_reply)); - if (rc < 0) - MM_ERR("RPC write for DL response failed %d\n", - rc); - break; - } - default: - MM_ERR("Unknown CB type %d\n", procedure); - } -} - -static int audio_mvs_thread(void *data) -{ - struct audio_mvs_info_type *audio = &audio_mvs_info; - struct rpc_request_hdr *rpc_hdr = NULL; - struct rpc_reply_hdr *rpc_reply = NULL; - uint32_t reply_status = 0; - uint32_t rpc_type; - int rpc_hdr_len; - MM_DBG("%s\n", __func__); - - while (!kthread_should_stop()) { - rpc_hdr_len = - msm_rpc_read(audio->rpc_endpt, (void **)&rpc_hdr, -1, -1); - if (rpc_hdr_len < 0) { - MM_ERR("RPC read failed %d\n", rpc_hdr_len); - break; - } else if (rpc_hdr_len < RPC_COMMON_HDR_SZ) - continue; - else { - rpc_type = be32_to_cpu(rpc_hdr->type); - if (rpc_type == RPC_TYPE_REPLY) { - if (rpc_hdr_len < RPC_REPLY_HDR_SZ) - continue; - rpc_reply = (void *)rpc_hdr; - reply_status = be32_to_cpu(rpc_reply-> - reply_stat); - if (reply_status != RPCMSG_REPLYSTAT_ACCEPTED) { - /* If the command is not accepted, - * there will be no response callback. - * Wake the caller and report error. */ - audio->rpc_status = RPC_STATUS_REJECT; - wake_up(&audio->wait); - MM_ERR("RPC reply status denied\n"); - } - } else if (rpc_type == RPC_TYPE_REQUEST) { - if (rpc_hdr_len < RPC_REQUEST_HDR_SZ) - continue; - MM_DBG("ALSA: kthread call procedure\n"); - audio_mvs_process_rpc_request( - be32_to_cpu(rpc_hdr->procedure), - be32_to_cpu(rpc_hdr->xid), - (void *)(rpc_hdr + 1), - (rpc_hdr_len - sizeof(*rpc_hdr)), - audio); - } else - MM_ERR("Unexpected RPC type %d\n", rpc_type); - } - kfree(rpc_hdr); - rpc_hdr = NULL; - } - return 0; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - - struct audio_mvs_info_type *audio = &audio_mvs_info; - MM_DBG("%s\n", __func__); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - audio->playback_start = 1; - else - audio->capture_start = 1; - break; - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - break; - case SNDRV_PCM_TRIGGER_STOP: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - audio->playback_start = 0; - else - audio->capture_start = 0; - break; - default: - break; - } - return 0; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_mvs_info_type *audio = &audio_mvs_info; - - MM_DBG("%s\n", __func__); - mutex_lock(&audio->lock); - if (audio->state < AUDIO_MVS_OPENED) { - audio->rpc_endpt = - msm_rpc_connect_compatible(MVS_PROG, - MVS_VERS, - MSM_RPC_UNINTERRUPTIBLE); - audio->state = AUDIO_MVS_OPENED; - } - - if (IS_ERR(audio->rpc_endpt)) { - MM_ERR("ALSA MVS RPC connect failed with version 0x%x\n", - MVS_VERS); - ret = PTR_ERR(audio->rpc_endpt); - audio->rpc_endpt = NULL; - goto err; - } else { - MM_DBG("ALSA MVS RPC connect succeeded\n"); - if (audio->playback_substream == NULL || - audio->capture_substream == NULL) { - if (substream->stream == - SNDRV_PCM_STREAM_PLAYBACK) { - audio->playback_substream = - substream; - runtime->hw = msm_pcm_hardware; - } else if (substream->stream == - SNDRV_PCM_STREAM_CAPTURE) { - audio->capture_substream = - substream; - runtime->hw = msm_pcm_hardware; - } - } else { - ret = -EPERM; - goto err; - } - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) { - MM_ERR("snd_pcm_hw_constraint_integer failed\n"); - if (!audio->instance) { - msm_rpc_close(audio->rpc_endpt); - audio->rpc_endpt = NULL; - } - goto err; - } - audio->instance++; - } -err: - mutex_unlock(&audio->lock); - return ret; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int rc = 0; - int count = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_mvs_info_type *audio = &audio_mvs_info; - uint32_t index; - MM_DBG("%s\n", __func__); - if (audio->dl_play == 1) { - rc = wait_event_interruptible_timeout(audio->in_wait, - (audio->in_write - audio->in_read <= 3), - 100 * HZ); - if (!rc) { - MM_ERR("MVS: write time out\n"); - return -ETIMEDOUT; - } else if (rc < 0) { - MM_ERR("MVS: write was interrupted\n"); - return -ERESTARTSYS; - } - } - mutex_lock(&audio->in_lock); - if (audio->state == AUDIO_MVS_ENABLED) { - index = audio->in_write % MVS_MAX_Q_LEN; - count = frames_to_bytes(runtime, frames); - if (count <= MVS_MAX_VOC_PKT_SIZE) { - rc = copy_from_user(audio->in[index].voc_pkt, buf, - count); - } else - rc = -ENOMEM; - if (!rc) { - audio->in[index].len = count; - audio->in_write++; - rc = count; - if (audio->in_write >= 3) - audio->dl_play = 1; - } else { - MM_ERR("Copy from user returned %d\n", rc); - rc = -EFAULT; - } - - } else { - MM_ERR("Write performed in invalid state %d\n", - audio->state); - rc = -EINVAL; - } - mutex_unlock(&audio->in_lock); - return rc; -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, - void __user *buf, snd_pcm_uframes_t frames) -{ - int rc = 0; - int count = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_mvs_info_type *audio = &audio_mvs_info; - uint32_t index = 0; - - MM_DBG("%s\n", __func__); - - /* Ensure the driver has been enabled. */ - if (audio->state != AUDIO_MVS_ENABLED) { - MM_ERR("Read performed in invalid state %d\n", audio->state); - return -EPERM; - } - rc = wait_event_interruptible_timeout(audio->out_wait, - (audio->out_read < audio->out_write || - audio->state == AUDIO_MVS_CLOSING || - audio->state == AUDIO_MVS_CLOSED), - 100 * HZ); - if (!rc) { - MM_ERR("MVS: No UL data available\n"); - return -ETIMEDOUT; - } else if (rc < 0) { - MM_ERR("MVS: Read was interrupted\n"); - return -ERESTARTSYS; - } - - mutex_lock(&audio->out_lock); - if (audio->state == AUDIO_MVS_CLOSING - || audio->state == AUDIO_MVS_CLOSED) { - rc = -EBUSY; - } else { - count = frames_to_bytes(runtime, frames); - index = audio->out_read % MVS_MAX_Q_LEN; - if (audio->out[index].len <= count) { - rc = copy_to_user(buf, - audio->out[index].voc_pkt, - audio->out[index].len); - if (rc == 0) { - rc = audio->out[index].len; - audio->out_read++; - } else { - MM_ERR("Copy to user %d\n", rc); - rc = -EFAULT; - } - } else - rc = -ENOMEM; - } - mutex_unlock(&audio->out_lock); - return rc; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - MM_DBG("%s\n", __func__); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int rc = 0; - struct audio_mvs_info_type *audio = &audio_mvs_info; - struct audio_mvs_release_msg release_msg; - MM_DBG("%s\n", __func__); - memset(&release_msg, 0, sizeof(release_msg)); - mutex_lock(&audio->lock); - - audio->instance--; - wake_up(&audio->out_wait); - - if (!audio->instance) { - if (audio->state == AUDIO_MVS_ENABLED) { - audio->state = AUDIO_MVS_CLOSING; - /* Release MVS. */ - release_msg.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP); - msm_rpc_setup_req(&release_msg.rpc_hdr, audio->rpc_prog, - audio->rpc_ver, - MVS_RELEASE_PROC); - audio->rpc_status = RPC_STATUS_FAILURE; - rc = msm_rpc_write(audio->rpc_endpt, &release_msg, - sizeof(release_msg)); - if (rc >= 0) { - MM_DBG("RPC write for release done\n"); - rc = wait_event_timeout(audio->wait, - (audio->rpc_status != - RPC_STATUS_FAILURE), 1 * HZ); - if (rc != 0) { - MM_DBG - ("Wait event for release succeeded\n"); - rc = 0; - kthread_stop(audio->task); - audio->prepare_ack = 0; - audio->task = NULL; - del_timer_sync(&audio->timer); - } else { - MM_ERR - ("Wait event for release failed %d\n", - rc); - } - } else { - MM_ERR("RPC write for release failed %d\n", rc); - } - } - audio->state = AUDIO_MVS_CLOSED; - msm_rpc_close(audio->rpc_endpt); - audio->rpc_endpt = NULL; - } - - mutex_unlock(&audio->lock); - - wake_unlock(&audio->suspend_lock); - pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); - /* Release the IO buffers. */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - mutex_lock(&audio->in_lock); - audio->in_write = 0; - audio->in_read = 0; - audio->playback_enable = 0; - audio->dl_play = 0; - audio->ack_dl_count = 0; - memset(audio->in[0].voc_pkt, 0, - MVS_MAX_VOC_PKT_SIZE * MVS_MAX_Q_LEN); - audio->in->len = 0; - audio->playback_substream = NULL; - mutex_unlock(&audio->in_lock); - } else { - mutex_lock(&audio->out_lock); - audio->out_write = 0; - audio->out_read = 0; - audio->capture_enable = 0; - audio->ack_ul_count = 0; - memset(audio->out[0].voc_pkt, 0, - MVS_MAX_VOC_PKT_SIZE * MVS_MAX_Q_LEN); - audio->out->len = 0; - audio->capture_substream = NULL; - mutex_unlock(&audio->out_lock); - } - return rc; -} - -static int msm_mvs_pcm_setup(struct snd_pcm_substream *substream) -{ - int rc = 0; - struct audio_mvs_acquire_msg acquire_msg; - struct audio_mvs_info_type *audio = &audio_mvs_info; - memset(&acquire_msg, 0, sizeof(acquire_msg)); - - /*Create an Kthread */ - MM_DBG("ALSA MVS thread creating\n"); - if (!IS_ERR(audio->rpc_endpt)) { - audio->task = - kthread_run(audio_mvs_thread, audio, - "audio_alsa_mvs_thread"); - if (!IS_ERR(audio->task)) { - MM_DBG("ALSA MVS thread create succeeded\n"); - audio->rpc_prog = MVS_PROG; - audio->rpc_ver = MVS_VERS; - /* Acquire MVS. */ - acquire_msg.acquire_args.client_id = - cpu_to_be32(MVS_CLIENT_ID_VOIP); - acquire_msg.acquire_args.cb_func_id = - cpu_to_be32(MVS_CB_FUNC_ID); - msm_rpc_setup_req(&acquire_msg.rpc_hdr, - audio->rpc_prog, - audio->rpc_ver, - MVS_ACQUIRE_PROC); - audio->rpc_status = RPC_STATUS_FAILURE; - rc = msm_rpc_write(audio->rpc_endpt, - &acquire_msg, sizeof(acquire_msg)); - if (rc >= 0) { - MM_DBG("RPC write for acquire done\n"); - - rc = wait_event_timeout(audio->wait, - (audio->rpc_status != - RPC_STATUS_FAILURE), - 1 * HZ); - if (rc != 0) { - audio->state = - AUDIO_MVS_ACQUIRE; - rc = 0; - MM_DBG - ("MVS driver in acquire state\n"); - } else { - MM_ERR - ("acquire Wait event failed %d\n", - rc); - rc = -EBUSY; - } - } else { - MM_ERR("RPC write for acquire failed %d\n", - rc); - rc = -EBUSY; - } - } else { - MM_ERR("ALSA MVS thread create failed\n"); - rc = PTR_ERR(audio->task); - audio->task = NULL; - msm_rpc_close(audio->rpc_endpt); - audio->rpc_endpt = NULL; - } - } else { - MM_ERR("RPC connect is not setup with version 0x%x\n", - MVS_VERS); - rc = PTR_ERR(audio->rpc_endpt); - audio->rpc_endpt = NULL; - } - /*mvs mode setup */ - if (audio->state == AUDIO_MVS_ACQUIRE) - rc = audio_mvs_setup_mvs(audio); - else - rc = -EBUSY; - return rc; -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct audio_mvs_info_type *prtd = &audio_mvs_info; - MM_DBG("%s\n", __func__); - prtd->pcm_playback_irq_pos = 0; - prtd->pcm_playback_buf_pos = 0; - /* rate and channels are sent to audio driver */ - prtd->playback_enable = 1; - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct audio_mvs_info_type *prtd = &audio_mvs_info; - prtd->pcm_capture_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_capture_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_capture_irq_pos = 0; - prtd->pcm_capture_buf_pos = 0; - prtd->capture_enable = 1; - return 0; -} - - -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int rc = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_mvs_info_type *prtd = &audio_mvs_info; - unsigned long expiry = 0; - MM_DBG("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - - mutex_lock(&prtd->prepare_lock); - if (prtd->state == AUDIO_MVS_ENABLED) - goto enabled; - else if (prtd->state == AUDIO_MVS_PREPARING) - goto prepairing; - else if (prtd->state == AUDIO_MVS_OPENED) { - prtd->state = AUDIO_MVS_PREPARING; - rc = msm_mvs_pcm_setup(substream); - } - if (!rc) { - expiry = ((unsigned long)((prtd->pcm_count * 1000) - /(runtime->rate * runtime->channels * 2))); - expiry -= (expiry % 10); - prtd->timer.expires = jiffies + (msecs_to_jiffies(expiry)); - prtd->expiry_delta = (msecs_to_jiffies(expiry)); - if (prtd->expiry_delta <= 2) - prtd->expiry_delta = 1; - setup_timer(&prtd->timer, snd_pcm_mvs_timer, - (unsigned long)prtd); - prtd->ack_ul_count = 0; - prtd->ack_dl_count = 0; - add_timer(&prtd->timer); - - } else { - MM_ERR("ALSA MVS setup is not done"); - rc = -EPERM; - prtd->state = AUDIO_MVS_OPENED; - goto err; - } - -prepairing: - rc = wait_event_interruptible(prtd->prepare_wait, - (prtd->prepare_ack == 2)); - if (rc < 0) { - MM_ERR("Wait event for prepare faild rc %d", rc); - rc = -EINTR; - prtd->state = AUDIO_MVS_OPENED; - goto err; - } else - MM_DBG("Wait event for prepare succeeded\n"); - - prtd->state = AUDIO_MVS_ENABLED; -enabled: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - rc = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - rc = msm_pcm_capture_prepare(substream); -err: - mutex_unlock(&prtd->prepare_lock); - return rc; -} - -int msm_mvs_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - MM_DBG("%s\n", __func__); - if (substream->pcm->device & 1) { - runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; - runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; - } - return 0; -} - -static snd_pcm_uframes_t -msm_pcm_playback_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_mvs_info_type *audio = &audio_mvs_info; - - if (audio->pcm_playback_irq_pos >= audio->pcm_size) - audio->pcm_playback_irq_pos = 0; - return bytes_to_frames(runtime, (audio->pcm_playback_irq_pos)); -} - -static snd_pcm_uframes_t -msm_pcm_capture_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_mvs_info_type *audio = &audio_mvs_info; - - if (audio->pcm_capture_irq_pos >= audio->pcm_capture_size) - audio->pcm_capture_irq_pos = 0; - return bytes_to_frames(runtime, (audio->pcm_capture_irq_pos)); -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - snd_pcm_uframes_t ret = 0; - MM_DBG("%s\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_pointer(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_pointer(substream); - return ret; -} - -static struct snd_pcm_ops msm_mvs_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_mvs_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - -}; - -static int msm_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - int i, ret, offset = 0; - struct snd_pcm *pcm = rtd->pcm; - - audio_mvs_info.mem_chunk = kmalloc( - 2 * MVS_MAX_VOC_PKT_SIZE * MVS_MAX_Q_LEN, GFP_KERNEL); - if (audio_mvs_info.mem_chunk != NULL) { - audio_mvs_info.in_read = 0; - audio_mvs_info.in_write = 0; - audio_mvs_info.out_read = 0; - audio_mvs_info.out_write = 0; - for (i = 0; i < MVS_MAX_Q_LEN; i++) { - audio_mvs_info.in[i].voc_pkt = - audio_mvs_info.mem_chunk + offset; - offset = offset + MVS_MAX_VOC_PKT_SIZE; - } - for (i = 0; i < MVS_MAX_Q_LEN; i++) { - audio_mvs_info.out[i].voc_pkt = - audio_mvs_info.mem_chunk + offset; - offset = offset + MVS_MAX_VOC_PKT_SIZE; - } - audio_mvs_info.playback_substream = NULL; - audio_mvs_info.capture_substream = NULL; - } else { - MM_ERR("MSM MVS kmalloc failed\n"); - return -ENODEV; - } - - - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1); - if (ret) - return ret; - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, 1); - if (ret) - return ret; - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &msm_mvs_pcm_ops); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &msm_mvs_pcm_ops); - - return 0; -} - -struct snd_soc_platform_driver msm_mvs_soc_platform = { - .ops = &msm_mvs_pcm_ops, - .pcm_new = msm_pcm_new, -}; -EXPORT_SYMBOL(msm_mvs_soc_platform); - -static int msm_pcm_probe(struct platform_device *pdev) -{ - return snd_soc_register_platform(&pdev->dev, - &msm_mvs_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-mvs-audio", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_mvs_soc_platform_init(void) -{ - memset(&audio_mvs_info, 0, sizeof(audio_mvs_info)); - mutex_init(&audio_mvs_info.lock); - mutex_init(&audio_mvs_info.prepare_lock); - mutex_init(&audio_mvs_info.in_lock); - mutex_init(&audio_mvs_info.out_lock); - init_waitqueue_head(&audio_mvs_info.wait); - init_waitqueue_head(&audio_mvs_info.prepare_wait); - init_waitqueue_head(&audio_mvs_info.out_wait); - init_waitqueue_head(&audio_mvs_info.in_wait); - wake_lock_init(&audio_mvs_info.suspend_lock, WAKE_LOCK_SUSPEND, - "audio_mvs_suspend"); - pm_qos_add_request(&audio_mvs_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_mvs_soc_platform_init); - -static void __exit msm_mvs_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_mvs_soc_platform_exit); - -MODULE_DESCRIPTION("MVS PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-afe.c b/sound/soc/msm/msm-pcm-afe.c deleted file mode 100644 index 931c07931e2db488101266f99a827764d4a59ec5..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-afe.c +++ /dev/null @@ -1,618 +0,0 @@ -/* Copyright (c) 2011-2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-afe.h" -#include "msm-pcm-q6.h" - -#define MIN_PERIOD_SIZE (128 * 2) -#define MAX_PERIOD_SIZE (128 * 2 * 2 * 6) -static struct snd_pcm_hardware msm_afe_hardware = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = (SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000 | - SNDRV_PCM_RATE_48000), - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = MAX_PERIOD_SIZE * 32, - .period_bytes_min = MIN_PERIOD_SIZE, - .period_bytes_max = MAX_PERIOD_SIZE, - .periods_min = 32, - .periods_max = 384, - .fifo_size = 0, -}; -static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt); -static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt); - -static void q6asm_event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ -} -static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt) -{ - struct pcm_afe_info *prtd = - container_of(hrt, struct pcm_afe_info, hrt); - struct snd_pcm_substream *substream = prtd->substream; - struct snd_pcm_runtime *runtime = substream->runtime; - if (prtd->start) { - pr_debug("sending frame to DSP: poll_time: %d\n", - prtd->poll_time); - if (prtd->dsp_cnt == runtime->periods) - prtd->dsp_cnt = 0; - afe_rt_proxy_port_write( - (prtd->dma_addr + - (prtd->dsp_cnt * - snd_pcm_lib_period_bytes(prtd->substream))), - snd_pcm_lib_period_bytes(prtd->substream)); - prtd->dsp_cnt++; - hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time - * 1000)); - - return HRTIMER_RESTART; - } else - return HRTIMER_NORESTART; -} -static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt) -{ - struct pcm_afe_info *prtd = - container_of(hrt, struct pcm_afe_info, hrt); - struct snd_pcm_substream *substream = prtd->substream; - struct snd_pcm_runtime *runtime = substream->runtime; - if (prtd->start) { - if (prtd->dsp_cnt == runtime->periods) - prtd->dsp_cnt = 0; - afe_rt_proxy_port_read( - (prtd->dma_addr + (prtd->dsp_cnt - * snd_pcm_lib_period_bytes(prtd->substream))), - snd_pcm_lib_period_bytes(prtd->substream)); - prtd->dsp_cnt++; - pr_debug("sending frame rec to DSP: poll_time: %d\n", - prtd->poll_time); - hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time - * 1000)); - - return HRTIMER_RESTART; - } else - return HRTIMER_NORESTART; -} -static void pcm_afe_process_tx_pkt(uint32_t opcode, - uint32_t token, uint32_t *payload, - void *priv) -{ - struct pcm_afe_info *prtd = priv; - unsigned long dsp_flags; - struct snd_pcm_substream *substream = NULL; - struct snd_pcm_runtime *runtime = NULL; - uint16_t event; - - if (prtd == NULL) - return; - substream = prtd->substream; - runtime = substream->runtime; - pr_debug("%s\n", __func__); - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - switch (opcode) { - case AFE_EVENT_RT_PROXY_PORT_STATUS: { - event = (uint16_t)((0xFFFF0000 & payload[0]) >> 0x10); - switch (event) { - case AFE_EVENT_RTPORT_START: { - prtd->dsp_cnt = 0; - prtd->poll_time = ((unsigned long)(( - snd_pcm_lib_period_bytes - (prtd->substream) * - 1000 * 1000)/ - (runtime->rate * - runtime->channels * 2))); - pr_debug("prtd->poll_time: %d", - prtd->poll_time); - break; - } - case AFE_EVENT_RTPORT_STOP: - pr_debug("%s: event!=0\n", __func__); - prtd->start = 0; - snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); - break; - case AFE_EVENT_RTPORT_LOW_WM: - pr_debug("%s: Underrun\n", __func__); - break; - case AFE_EVENT_RTPORT_HI_WM: - pr_debug("%s: Overrun\n", __func__); - break; - default: - break; - } - break; - } - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case AFE_SERVICE_CMD_RTPORT_WR: - pr_debug("write done\n"); - prtd->pcm_irq_pos += snd_pcm_lib_period_bytes - (prtd->substream); - snd_pcm_period_elapsed(prtd->substream); - break; - default: - break; - } - break; - } - default: - break; - } - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); -} - -static void pcm_afe_process_rx_pkt(uint32_t opcode, - uint32_t token, uint32_t *payload, - void *priv) -{ - struct pcm_afe_info *prtd = priv; - unsigned long dsp_flags; - struct snd_pcm_substream *substream = NULL; - struct snd_pcm_runtime *runtime = NULL; - uint16_t event; - - if (prtd == NULL) - return; - substream = prtd->substream; - runtime = substream->runtime; - pr_debug("%s\n", __func__); - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - switch (opcode) { - case AFE_EVENT_RT_PROXY_PORT_STATUS: { - event = (uint16_t)((0xFFFF0000 & payload[0]) >> 0x10); - switch (event) { - case AFE_EVENT_RTPORT_START: { - prtd->dsp_cnt = 0; - prtd->poll_time = ((unsigned long)(( - snd_pcm_lib_period_bytes(prtd->substream) - * 1000 * 1000)/(runtime->rate - * runtime->channels * 2))); - pr_debug("prtd->poll_time : %d", prtd->poll_time); - break; - } - case AFE_EVENT_RTPORT_STOP: - pr_debug("%s: event!=0\n", __func__); - prtd->start = 0; - snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); - break; - case AFE_EVENT_RTPORT_LOW_WM: - pr_debug("%s: Underrun\n", __func__); - break; - case AFE_EVENT_RTPORT_HI_WM: - pr_debug("%s: Overrun\n", __func__); - break; - default: - break; - } - break; - } - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case AFE_SERVICE_CMD_RTPORT_RD: - pr_debug("Read done\n"); - prtd->pcm_irq_pos += snd_pcm_lib_period_bytes - (prtd->substream); - snd_pcm_period_elapsed(prtd->substream); - break; - default: - break; - } - break; - } - default: - break; - } - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); -} - -static int msm_afe_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcm_afe_info *prtd = runtime->private_data; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *dai = rtd->cpu_dai; - int ret = 0; - - pr_debug("%s: sample_rate=%d\n", __func__, runtime->rate); - - pr_debug("%s: dai->id =%x\n", __func__, dai->id); - ret = afe_register_get_events(dai->id, - pcm_afe_process_tx_pkt, prtd); - if (ret < 0) { - pr_err("afe-pcm:register for events failed\n"); - return ret; - } - pr_debug("%s:success\n", __func__); - prtd->prepared++; - return ret; -} - -static int msm_afe_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcm_afe_info *prtd = runtime->private_data; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *dai = rtd->cpu_dai; - int ret = 0; - - pr_debug("%s\n", __func__); - - pr_debug("%s: dai->id =%x\n", __func__, dai->id); - ret = afe_register_get_events(dai->id, - pcm_afe_process_rx_pkt, prtd); - if (ret < 0) { - pr_err("afe-pcm:register for events failed\n"); - return ret; - } - pr_debug("%s:success\n", __func__); - prtd->prepared++; - return 0; -} - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 16000, 48000 -}; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static int msm_afe_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcm_afe_info *prtd = NULL; - int ret = 0; - - prtd = kzalloc(sizeof(struct pcm_afe_info), GFP_KERNEL); - if (prtd == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - return -ENOMEM; - } else - pr_debug("prtd %x\n", (unsigned int)prtd); - - mutex_init(&prtd->lock); - spin_lock_init(&prtd->dsp_lock); - prtd->dsp_cnt = 0; - - mutex_lock(&prtd->lock); - - runtime->hw = msm_afe_hardware; - prtd->substream = substream; - runtime->private_data = prtd; - prtd->audio_client = q6asm_audio_client_alloc( - (app_cb)q6asm_event_handler, prtd); - if (!prtd->audio_client) { - pr_debug("%s: Could not allocate memory\n", __func__); - mutex_unlock(&prtd->lock); - kfree(prtd); - return -ENOMEM; - } - hrtimer_init(&prtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - prtd->hrt.function = afe_hrtimer_callback; - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - prtd->hrt.function = afe_hrtimer_rec_callback; - - mutex_unlock(&prtd->lock); - - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_err("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_err("snd_pcm_hw_constraint_integer failed\n"); - - return 0; -} - -static int msm_afe_close(struct snd_pcm_substream *substream) -{ - int rc = 0; - struct snd_dma_buffer *dma_buf; - struct snd_pcm_runtime *runtime; - struct pcm_afe_info *prtd; - struct snd_soc_pcm_runtime *rtd = NULL; - struct snd_soc_dai *dai = NULL; - int dir = IN; - int ret = 0; - - pr_debug("%s\n", __func__); - if (substream == NULL) { - pr_err("substream is NULL\n"); - return -EINVAL; - } - rtd = substream->private_data; - dai = rtd->cpu_dai; - runtime = substream->runtime; - prtd = runtime->private_data; - - mutex_lock(&prtd->lock); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - dir = IN; - ret = afe_unregister_get_events(dai->id); - if (ret < 0) - pr_err("AFE unregister for events failed\n"); - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - dir = OUT; - ret = afe_unregister_get_events(dai->id); - if (ret < 0) - pr_err("AFE unregister for events failed\n"); - } - hrtimer_cancel(&prtd->hrt); - - rc = afe_cmd_memory_unmap(runtime->dma_addr); - if (rc < 0) - pr_err("AFE memory unmap failed\n"); - - pr_debug("release all buffer\n"); - dma_buf = &substream->dma_buffer; - if (dma_buf == NULL) { - pr_debug("dma_buf is NULL\n"); - goto done; - } - - if (dma_buf->area) { - dma_buf->area = NULL; - } - - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); -done: - pr_debug("%s: dai->id =%x\n", __func__, dai->id); - q6asm_audio_client_free(prtd->audio_client); - mutex_unlock(&prtd->lock); - prtd->prepared--; - kfree(prtd); - return 0; -} -static int msm_afe_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcm_afe_info *prtd = runtime->private_data; - - prtd->pcm_irq_pos = 0; - if (prtd->prepared) - return 0; - mutex_lock(&prtd->lock); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_afe_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_afe_capture_prepare(substream); - mutex_unlock(&prtd->lock); - return ret; -} -static int msm_afe_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcm_afe_info *prtd = runtime->private_data; - int result = 0; - - pr_debug("%s\n", __func__); - prtd->mmap_flag = 1; - if (runtime->dma_addr && runtime->dma_bytes) { - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - result = remap_pfn_range(vma, vma->vm_start, - runtime->dma_addr >> PAGE_SHIFT, - runtime->dma_bytes, - vma->vm_page_prot); - } else { - pr_err("Physical address or size of buf is NULL"); - return -EINVAL; - } - return result; -} -static int msm_afe_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcm_afe_info *prtd = runtime->private_data; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("%s: SNDRV_PCM_TRIGGER_START\n", __func__); - prtd->start = 1; - hrtimer_start(&prtd->hrt, ns_to_ktime(0), - HRTIMER_MODE_REL); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("%s: SNDRV_PCM_TRIGGER_STOP\n", __func__); - prtd->start = 0; - break; - default: - ret = -EINVAL; - break; - } - return ret; -} -static int msm_afe_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct pcm_afe_info *prtd = runtime->private_data; - struct audio_buffer *buf; - int dir, ret; - - pr_debug("%s:\n", __func__); - - mutex_lock(&prtd->lock); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dir = IN; - else - dir = OUT; - ret = q6asm_audio_client_buf_alloc_contiguous(dir, - prtd->audio_client, - runtime->hw.period_bytes_min, - runtime->hw.periods_max); - if (ret < 0) { - pr_err("Audio Start: Buffer Allocation failed rc = %d\n", ret); - mutex_unlock(&prtd->lock); - return -ENOMEM; - } - buf = prtd->audio_client->port[dir].buf; - - if (buf == NULL || buf[0].data == NULL) { - mutex_unlock(&prtd->lock); - return -ENOMEM; - } - - pr_debug("%s:buf = %p\n", __func__, buf); - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - dma_buf->area = buf[0].data; - dma_buf->addr = buf[0].phys; - dma_buf->bytes = runtime->hw.buffer_bytes_max; - if (!dma_buf->area) { - pr_err("%s:MSM AFE physical memory allocation failed\n", - __func__); - mutex_unlock(&prtd->lock); - return -ENOMEM; - } - memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max); - prtd->dma_addr = (u32) dma_buf->addr; - - mutex_unlock(&prtd->lock); - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - - ret = afe_cmd_memory_map(dma_buf->addr, dma_buf->bytes); - if (ret < 0) - pr_err("fail to map memory to DSP\n"); - - return ret; -} -static snd_pcm_uframes_t msm_afe_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct pcm_afe_info *prtd = runtime->private_data; - - if (prtd->pcm_irq_pos >= snd_pcm_lib_buffer_bytes(substream)) - prtd->pcm_irq_pos = 0; - - pr_debug("pcm_irq_pos = %d\n", prtd->pcm_irq_pos); - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static struct snd_pcm_ops msm_afe_ops = { - .open = msm_afe_open, - .hw_params = msm_afe_hw_params, - .trigger = msm_afe_trigger, - .close = msm_afe_close, - .prepare = msm_afe_prepare, - .mmap = msm_afe_mmap, - .pointer = msm_afe_pointer, -}; - - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - pr_debug("%s\n", __func__); - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static int msm_afe_afe_probe(struct snd_soc_platform *platform) -{ - pr_debug("%s\n", __func__); - return 0; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_afe_ops, - .pcm_new = msm_asoc_pcm_new, - .probe = msm_afe_afe_probe, -}; - -static int msm_afe_probe(struct platform_device *pdev) -{ - pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_afe_remove(struct platform_device *pdev) -{ - pr_debug("%s\n", __func__); - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_afe_driver = { - .driver = { - .name = "msm-pcm-afe", - .owner = THIS_MODULE, - }, - .probe = msm_afe_probe, - .remove = msm_afe_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - pr_debug("%s\n", __func__); - return platform_driver_register(&msm_afe_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - pr_debug("%s\n", __func__); - platform_driver_unregister(&msm_afe_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("AFE PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-afe.h b/sound/soc/msm/msm-pcm-afe.h deleted file mode 100644 index 674c7b5828cb7761c65622cc950555f7b3410a4b..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-afe.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2011-2012, 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 _MSM_PCM_AFE_H -#define _MSM_PCM_AFE_H -#include -#include - - -struct pcm_afe_info { - unsigned long dma_addr; - struct snd_pcm_substream *substream; - unsigned int pcm_irq_pos; /* IRQ position */ - struct mutex lock; - spinlock_t dsp_lock; - uint32_t samp_rate; - uint32_t channel_mode; - uint8_t start; - uint32_t dsp_cnt; - uint32_t buf_phys; - int32_t mmap_flag; - int prepared; - struct hrtimer hrt; - int poll_time; - struct audio_client *audio_client; -}; - - -#define MSM_EXT(xname, fp_info, fp_get, fp_put, addr) \ - {.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .name = xname, \ - .info = fp_info,\ - .get = fp_get, .put = fp_put, \ - .private_value = addr, \ - } - -#endif /*_MSM_PCM_AFE_H*/ diff --git a/sound/soc/msm/msm-pcm-dtmf.c b/sound/soc/msm/msm-pcm-dtmf.c deleted file mode 100644 index fd5f6af5569ce5e716ac60a90f2dfe0ff3c957a8..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-dtmf.c +++ /dev/null @@ -1,585 +0,0 @@ -/* Copyright (c) 2012, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm-q6.h" -#include "msm-pcm-routing.h" -#include "qdsp6/q6voice.h" - -enum { - DTMF_IN_RX, - DTMF_IN_TX, -}; - -enum format { - FORMAT_S16_LE = 2 -}; - -struct dtmf_det_info { - char session[MAX_SESSION_NAME_LEN]; - uint8_t dir; - uint16_t high_freq; - uint16_t low_freq; -}; - -struct dtmf_buf_node { - struct list_head list; - struct dtmf_det_info dtmf_det_pkt; -}; - -enum dtmf_state { - DTMF_GEN_RX_STOPPED, - DTMF_GEN_RX_STARTED, -}; - -#define DTMF_MAX_Q_LEN 10 -#define DTMF_PKT_SIZE sizeof(struct dtmf_det_info) - -struct dtmf_drv_info { - enum dtmf_state state; - struct snd_pcm_substream *capture_substream; - - struct list_head out_queue; - struct list_head free_out_queue; - - wait_queue_head_t out_wait; - - struct mutex lock; - spinlock_t dsp_lock; - - uint8_t capture_start; - uint8_t capture_instance; - - unsigned int pcm_capture_size; - unsigned int pcm_capture_count; - unsigned int pcm_capture_irq_pos; - unsigned int pcm_capture_buf_pos; -}; - -static struct snd_pcm_hardware msm_pcm_hardware = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .channels_min = 1, - .channels_max = 1, - .buffer_bytes_max = (sizeof(struct dtmf_buf_node) * DTMF_MAX_Q_LEN), - .period_bytes_min = DTMF_PKT_SIZE, - .period_bytes_max = DTMF_PKT_SIZE, - .periods_min = DTMF_MAX_Q_LEN, - .periods_max = DTMF_MAX_Q_LEN, - .fifo_size = 0, -}; - -static int msm_dtmf_rx_generate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - uint16_t low_freq = ucontrol->value.integer.value[0]; - uint16_t high_freq = ucontrol->value.integer.value[1]; - int64_t duration = ucontrol->value.integer.value[2]; - uint16_t gain = ucontrol->value.integer.value[3]; - - pr_debug("%s: low_freq=%d high_freq=%d duration=%d gain=%d\n", - __func__, low_freq, high_freq, (int)duration, gain); - afe_dtmf_generate_rx(duration, high_freq, low_freq, gain); - return 0; -} - -static int msm_dtmf_rx_generate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s:\n", __func__); - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_dtmf_detect_voice_rx_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int enable = ucontrol->value.integer.value[0]; - - pr_debug("%s: enable=%d\n", __func__, enable); - voc_enable_dtmf_rx_detection(voc_get_session_id(VOICE_SESSION_NAME), - enable); - - return 0; -} - -static int msm_dtmf_detect_voice_rx_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_dtmf_detect_volte_rx_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int enable = ucontrol->value.integer.value[0]; - - pr_debug("%s: enable=%d\n", __func__, enable); - voc_enable_dtmf_rx_detection(voc_get_session_id(VOLTE_SESSION_NAME), - enable); - - return 0; -} - -static int msm_dtmf_detect_volte_rx_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static struct snd_kcontrol_new msm_dtmf_controls[] = { - SOC_SINGLE_MULTI_EXT("DTMF_Generate Rx Low High Duration Gain", - SND_SOC_NOPM, 0, 5000, 0, 4, - msm_dtmf_rx_generate_get, - msm_dtmf_rx_generate_put), - SOC_SINGLE_EXT("DTMF_Detect Rx Voice enable", SND_SOC_NOPM, 0, 1, 0, - msm_dtmf_detect_voice_rx_get, - msm_dtmf_detect_voice_rx_put), - SOC_SINGLE_EXT("DTMF_Detect Rx VoLTE enable", SND_SOC_NOPM, 0, 1, 0, - msm_dtmf_detect_volte_rx_get, - msm_dtmf_detect_volte_rx_put), -}; - -static int msm_pcm_dtmf_probe(struct snd_soc_platform *platform) -{ - snd_soc_add_platform_controls(platform, msm_dtmf_controls, - ARRAY_SIZE(msm_dtmf_controls)); - return 0; -} - -static void dtmf_rx_detected_cb(uint8_t *pkt, - char *session, - void *private_data) -{ - struct dtmf_buf_node *buf_node = NULL; - struct vss_istream_evt_rx_dtmf_detected *dtmf_det_pkt = - (struct vss_istream_evt_rx_dtmf_detected *)pkt; - struct dtmf_drv_info *prtd = private_data; - unsigned long dsp_flags; - - pr_debug("%s\n", __func__); - if (prtd->capture_substream == NULL) - return; - - /* Copy dtmf detected info into out_queue. */ - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - /* discarding dtmf detection info till start is received */ - if (!list_empty(&prtd->free_out_queue) && prtd->capture_start) { - buf_node = list_first_entry(&prtd->free_out_queue, - struct dtmf_buf_node, list); - list_del(&buf_node->list); - buf_node->dtmf_det_pkt.high_freq = dtmf_det_pkt->high_freq; - buf_node->dtmf_det_pkt.low_freq = dtmf_det_pkt->low_freq; - if (session != NULL) - strlcpy(buf_node->dtmf_det_pkt.session, - session, MAX_SESSION_NAME_LEN); - - buf_node->dtmf_det_pkt.dir = DTMF_IN_RX; - pr_debug("high =%d, low=%d session=%s\n", - buf_node->dtmf_det_pkt.high_freq, - buf_node->dtmf_det_pkt.low_freq, - buf_node->dtmf_det_pkt.session); - list_add_tail(&buf_node->list, &prtd->out_queue); - prtd->pcm_capture_irq_pos += prtd->pcm_capture_count; - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - snd_pcm_period_elapsed(prtd->capture_substream); - } else { - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - pr_err("DTMF detection pkt in Rx dropped, no free node available\n"); - } - - wake_up(&prtd->out_wait); -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, - void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - int count = 0; - struct dtmf_buf_node *buf_node = NULL; - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = runtime->private_data; - unsigned long dsp_flags; - - count = frames_to_bytes(runtime, frames); - - ret = wait_event_interruptible_timeout(prtd->out_wait, - (!list_empty(&prtd->out_queue)), - 1 * HZ); - - if (ret > 0) { - if (count <= DTMF_PKT_SIZE) { - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - buf_node = list_first_entry(&prtd->out_queue, - struct dtmf_buf_node, list); - list_del(&buf_node->list); - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - ret = copy_to_user(buf, - &buf_node->dtmf_det_pkt, - count); - if (ret) { - pr_err("%s: Copy to user retuned %d\n", - __func__, ret); - ret = -EFAULT; - } - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - list_add_tail(&buf_node->list, - &prtd->free_out_queue); - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - - } else { - pr_err("%s: Read count %d > DTMF_PKT_SIZE\n", - __func__, count); - ret = -ENOMEM; - } - } else if (ret == 0) { - pr_err("%s: No UL data available\n", __func__); - ret = -ETIMEDOUT; - } else { - pr_err("%s: Read was interrupted\n", __func__); - ret = -ERESTARTSYS; - } - return ret; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - pr_debug("%s() DTMF\n", __func__); - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = NULL; - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - prtd = kzalloc(sizeof(struct dtmf_drv_info), GFP_KERNEL); - - if (prtd == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - ret = -ENOMEM; - goto done; - } - - mutex_init(&prtd->lock); - spin_lock_init(&prtd->dsp_lock); - init_waitqueue_head(&prtd->out_wait); - INIT_LIST_HEAD(&prtd->out_queue); - INIT_LIST_HEAD(&prtd->free_out_queue); - - runtime->hw = msm_pcm_hardware; - - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_info("snd_pcm_hw_constraint_integer failed\n"); - - prtd->capture_substream = substream; - prtd->capture_instance++; - runtime->private_data = prtd; - } - -done: - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct list_head *ptr = NULL; - struct list_head *next = NULL; - struct dtmf_buf_node *buf_node = NULL; - struct snd_dma_buffer *c_dma_buf; - struct snd_pcm_substream *c_substream; - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = runtime->private_data; - unsigned long dsp_flags; - - pr_debug("%s() DTMF\n", __func__); - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - mutex_lock(&prtd->lock); - wake_up(&prtd->out_wait); - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - prtd->capture_instance--; - - if (!prtd->capture_instance) { - if (prtd->state == DTMF_GEN_RX_STARTED) { - prtd->state = DTMF_GEN_RX_STOPPED; - voc_disable_dtmf_det_on_active_sessions(); - voc_register_dtmf_rx_detection_cb(NULL, NULL); - } - /* release all buffer */ - /* release out_queue and free_out_queue */ - pr_debug("release all buffer\n"); - c_substream = prtd->capture_substream; - if (c_substream == NULL) { - pr_debug("c_substream is NULL\n"); - mutex_unlock(&prtd->lock); - return -EINVAL; - } - - c_dma_buf = &c_substream->dma_buffer; - if (c_dma_buf == NULL) { - pr_debug("c_dma_buf is NULL.\n"); - mutex_unlock(&prtd->lock); - return -EINVAL; - } - - if (c_dma_buf->area != NULL) { - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - list_for_each_safe(ptr, next, - &prtd->out_queue) { - buf_node = list_entry(ptr, - struct dtmf_buf_node, list); - list_del(&buf_node->list); - } - - list_for_each_safe(ptr, next, - &prtd->free_out_queue) { - buf_node = list_entry(ptr, - struct dtmf_buf_node, list); - list_del(&buf_node->list); - } - - spin_unlock_irqrestore(&prtd->dsp_lock, - dsp_flags); - dma_free_coherent(c_substream->pcm->card->dev, - runtime->hw.buffer_bytes_max, - c_dma_buf->area, - c_dma_buf->addr); - c_dma_buf->area = NULL; - } - } - prtd->capture_substream = NULL; - mutex_unlock(&prtd->lock); - } - - return ret; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = runtime->private_data; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct dtmf_buf_node *buf_node = NULL; - int i = 0, offset = 0; - int ret = 0; - - pr_debug("%s: DTMF\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - mutex_lock(&prtd->lock); - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - - dma_buf->area = dma_alloc_coherent(substream->pcm->card->dev, - runtime->hw.buffer_bytes_max, - &dma_buf->addr, GFP_KERNEL); - if (!dma_buf->area) { - pr_err("%s:MSM DTMF dma_alloc failed\n", __func__); - mutex_unlock(&prtd->lock); - return -ENOMEM; - } - - dma_buf->bytes = runtime->hw.buffer_bytes_max; - memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max); - - for (i = 0; i < DTMF_MAX_Q_LEN; i++) { - pr_debug("node =%d\n", i); - buf_node = (void *) dma_buf->area + offset; - list_add_tail(&buf_node->list, - &prtd->free_out_queue); - offset = offset + sizeof(struct dtmf_buf_node); - } - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - mutex_unlock(&prtd->lock); - } - - return ret; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = runtime->private_data; - - pr_debug("%s: DTMF\n", __func__); - prtd->pcm_capture_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_capture_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_capture_irq_pos = 0; - prtd->pcm_capture_buf_pos = 0; - return 0; -} - -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = runtime->private_data; - - pr_debug("%s: DTMF\n", __func__); - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - mutex_lock(&prtd->lock); - - msm_pcm_capture_prepare(substream); - - if (runtime->format != FORMAT_S16_LE) { - pr_err("format:%u doesnt match %d\n", - (uint32_t)runtime->format, FORMAT_S16_LE); - mutex_unlock(&prtd->lock); - return -EINVAL; - } - - if (prtd->capture_instance && - (prtd->state != DTMF_GEN_RX_STARTED)) { - voc_register_dtmf_rx_detection_cb(dtmf_rx_detected_cb, - prtd); - prtd->state = DTMF_GEN_RX_STARTED; - } - mutex_unlock(&prtd->lock); - } - - return 0; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = runtime->private_data; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - pr_debug("%s: Trigger start\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - prtd->capture_start = 1; - break; - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - prtd->capture_start = 0; - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - snd_pcm_uframes_t ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct dtmf_drv_info *prtd = runtime->private_data; - - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (prtd->pcm_capture_irq_pos >= prtd->pcm_capture_size) - prtd->pcm_capture_irq_pos = 0; - ret = bytes_to_frames(runtime, (prtd->pcm_capture_irq_pos)); - } - - return ret; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, -}; - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, - .probe = msm_pcm_dtmf_probe, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-pcm-dtmf", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("DTMF platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-host-voice.c b/sound/soc/msm/msm-pcm-host-voice.c deleted file mode 100644 index 929e6f59daab94b7fbec3e16af1d806193ddd32e..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-host-voice.c +++ /dev/null @@ -1,1321 +0,0 @@ -/* Copyright (c) 2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qdsp6/q6voice.h" - -#define HPCM_MAX_Q_LEN 10 -#define HPCM_MIN_VOC_PKT_SIZE 320 -#define HPCM_MAX_VOC_PKT_SIZE 640 - -#define VOICE_TX_CAPTURE_DAI_ID "CS-VOICE HOST TX CAPTURE" -#define VOICE_TX_PLAYBACK_DAI_ID "CS-VOICE HOST TX PLAYBACK" -#define VOICE_RX_CAPTURE_DAI_ID "CS-VOICE HOST RX CAPTURE" -#define VOICE_RX_PLAYBACK_DAI_ID "CS-VOICE HOST RX PLAYBACK" - -#define VOLTE_TX_CAPTURE_DAI_ID "VOLTE HOST TX CAPTURE" -#define VOLTE_TX_PLAYBACK_DAI_ID "VOLTE HOST TX PLAYBACK" -#define VOLTE_RX_CAPTURE_DAI_ID "VOLTE HOST RX CAPTURE" -#define VOLTE_RX_PLAYBACK_DAI_ID "VOLTE HOST RX PLAYBACK" - -enum { - RX = 1, - TX, -}; - -enum { - VOICE_INDEX = 0, - VOLTE_INDEX, - MAX_SESSION -}; - -enum hpcm_state { - HPCM_STOPPED = 1, - HPCM_CLOSED, - HPCM_PREPARED, - HPCM_STARTED, -}; - -struct hpcm_frame { - uint32_t len; - uint8_t voc_pkt[HPCM_MAX_VOC_PKT_SIZE]; -}; - -struct hpcm_buf_node { - struct list_head list; - struct hpcm_frame frame; -}; - -struct vocpcm_ion_buffer { - /* Physical address */ - uint32_t paddr; - /* Kernel virtual address */ - uint32_t kvaddr; -}; - -struct dai_data { - enum hpcm_state state; - struct snd_pcm_substream *substream; - struct list_head filled_queue; - struct list_head free_queue; - wait_queue_head_t queue_wait; - spinlock_t dsp_lock; - uint32_t pcm_size; - uint32_t pcm_count; - /* IRQ position */ - uint32_t pcm_irq_pos; - /* Position in buffer */ - uint32_t pcm_buf_pos; - struct vocpcm_ion_buffer vocpcm_ion_buffer; -}; - -struct tap_point { - struct dai_data playback_dai_data; - struct dai_data capture_dai_data; - struct ion_handle *ion_handle; - int ion_mem_len; -}; - -struct session { - struct tap_point tx_tap_point; - struct tap_point rx_tap_point; -}; - -struct tappnt_mxr_data { - bool enable; - uint16_t direction; - uint16_t sample_rate; -}; - -/* Values from mixer ctl are cached in this structure */ -struct mixer_conf { - uint8_t sess_indx; - struct tappnt_mxr_data rx; - struct tappnt_mxr_data tx; -}; - -struct start_cmd { - struct vss_ivpcm_tap_point tap_pnt[2]; - uint32_t no_of_tapoints; -}; - -struct hpcm_drv { - struct mutex lock; - struct session session[MAX_SESSION]; - struct mixer_conf mixer_conf; - struct ion_client *ion_client; - struct start_cmd start_cmd; -}; - -static struct hpcm_drv hpcm_drv; - -static struct snd_pcm_hardware msm_pcm_hardware = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED), - .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_SPECIAL, - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .rate_min = 8000, - .rate_max = 16000, - .channels_min = 1, - .channels_max = 1, - .buffer_bytes_max = sizeof(struct hpcm_buf_node) * HPCM_MAX_Q_LEN, - .period_bytes_min = HPCM_MIN_VOC_PKT_SIZE, - .period_bytes_max = HPCM_MAX_VOC_PKT_SIZE, - .periods_min = HPCM_MAX_Q_LEN, - .periods_max = HPCM_MAX_Q_LEN, - .fifo_size = 0, -}; - -static char *hpcm_get_sess_name(int sess_indx) -{ - char *sess_name = NULL; - - if (sess_indx == VOICE_INDEX) - sess_name = VOICE_SESSION_NAME; - else if (sess_indx == VOLTE_INDEX) - sess_name = VOLTE_SESSION_NAME; - else - pr_err("%s:, Invalid sess_index\n", __func__); - - return sess_name; -} - -static void hpcm_reset_mixer_config(struct hpcm_drv *prtd) -{ - prtd->mixer_conf.sess_indx = -1; - prtd->mixer_conf.rx.enable = false; - prtd->mixer_conf.rx.direction = -1; - prtd->mixer_conf.rx.sample_rate = 0; - - prtd->mixer_conf.tx.enable = false; - prtd->mixer_conf.tx.direction = -1; - prtd->mixer_conf.tx.sample_rate = 0; -} - -/* Check for valid mixer control values */ -static bool hpcm_is_valid_config(int sess_indx, int tap_point, - uint16_t direction, uint16_t samplerate) -{ - if (sess_indx < VOICE_INDEX || sess_indx > VOLTE_INDEX) { - pr_err("%s: invalid sess_indx :%d\n", __func__, sess_indx); - goto error; - } - - if (samplerate != VSS_IVPCM_SAMPLING_RATE_8K && - samplerate != VSS_IVPCM_SAMPLING_RATE_16K) { - pr_err("%s: invalid sample rate :%d\n", __func__, samplerate); - goto error; - } - - if ((tap_point != RX) && (tap_point != TX)) { - pr_err("%s: invalid tappoint :%d\n", __func__, tap_point); - goto error; - } - - if ((direction != VSS_IVPCM_TAP_POINT_DIR_IN) && - (direction != VSS_IVPCM_TAP_POINT_DIR_OUT) && - (direction != VSS_IVPCM_TAP_POINT_DIR_OUT_IN)) { - pr_err("%s: invalid direction :%d\n", __func__, direction); - goto error; - } - - return true; - -error: - return false; -} - - -static struct dai_data *hpcm_get_dai_data(char *pcm_id, struct hpcm_drv *prtd) -{ - struct dai_data *dai_data = NULL; - size_t size = 0; - - if (pcm_id) { - size = strlen(pcm_id); - /* Check for Voice DAI */ - if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, size)) { - dai_data = - &prtd->session[VOICE_INDEX].tx_tap_point.capture_dai_data; - } else if (strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, size)) { - dai_data = - &prtd->session[VOICE_INDEX].tx_tap_point.playback_dai_data; - } else if (strnstr(pcm_id, VOICE_RX_CAPTURE_DAI_ID, size)) { - dai_data = - &prtd->session[VOICE_INDEX].rx_tap_point.capture_dai_data; - } else if (strnstr(pcm_id, VOICE_RX_PLAYBACK_DAI_ID, size)) { - dai_data = - &prtd->session[VOICE_INDEX].rx_tap_point.playback_dai_data; - /* Check for VoLTE DAI */ - } else if (strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, size)) { - dai_data = - &prtd->session[VOLTE_INDEX].tx_tap_point.capture_dai_data; - } else if (strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, size)) { - dai_data = - &prtd->session[VOLTE_INDEX].tx_tap_point.playback_dai_data; - } else if (strnstr(pcm_id, VOLTE_RX_CAPTURE_DAI_ID, size)) { - dai_data = - &prtd->session[VOLTE_INDEX].rx_tap_point.capture_dai_data; - } else if (strnstr(pcm_id, VOLTE_RX_PLAYBACK_DAI_ID, size)) { - dai_data = - &prtd->session[VOLTE_INDEX].rx_tap_point.playback_dai_data; - } else { - pr_err("%s: Wrong dai id\n", __func__); - } - } - - return dai_data; -} - -static struct tap_point *hpcm_get_tappoint_data(char *pcm_id, - struct hpcm_drv *prtd) -{ - struct tap_point *tp = NULL; - size_t size = strlen(pcm_id); - - if (pcm_id) { - /* Check for Voice DAI */ - if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, size)) { - tp = &prtd->session[VOICE_INDEX].tx_tap_point; - } else if (strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, size)) { - tp = &prtd->session[VOICE_INDEX].tx_tap_point; - } else if (strnstr(pcm_id, VOICE_RX_CAPTURE_DAI_ID, size)) { - tp = &prtd->session[VOICE_INDEX].rx_tap_point; - } else if (strnstr(pcm_id, VOICE_RX_PLAYBACK_DAI_ID, size)) { - tp = &prtd->session[VOICE_INDEX].rx_tap_point; - /* Check for VoLTE DAI */ - } else if (strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, size)) { - tp = &prtd->session[VOLTE_INDEX].tx_tap_point; - } else if (strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, size)) { - tp = &prtd->session[VOLTE_INDEX].tx_tap_point; - } else if (strnstr(pcm_id, VOLTE_RX_CAPTURE_DAI_ID, size)) { - tp = &prtd->session[VOLTE_INDEX].rx_tap_point; - } else if (strnstr(pcm_id, VOLTE_RX_PLAYBACK_DAI_ID, size)) { - tp = &prtd->session[VOLTE_INDEX].rx_tap_point; - } else { - pr_err("%s: wrong dai id\n", __func__); - } - } - - return tp; -} - -static struct tappnt_mxr_data *hpcm_get_tappnt_mixer_data(char *pcm_id, - struct hpcm_drv *prtd) -{ - - if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) || - strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) || - strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) || - strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, strlen(pcm_id))) { - return &prtd->mixer_conf.tx; - } else { - return &prtd->mixer_conf.rx; - } -} - -static int get_tappnt_value(char *pcm_id) -{ - - if (strnstr(pcm_id, VOICE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) || - strnstr(pcm_id, VOICE_TX_PLAYBACK_DAI_ID, strlen(pcm_id)) || - strnstr(pcm_id, VOLTE_TX_CAPTURE_DAI_ID, strlen(pcm_id)) || - strnstr(pcm_id, VOLTE_TX_PLAYBACK_DAI_ID, strlen(pcm_id))) { - return TX; - } else { - return RX; - } -} - -static bool hpcm_all_dais_are_ready(uint16_t direction, struct tap_point *tp, - enum hpcm_state state) -{ - bool dais_started = false; - - /* - * Based on the direction set per tap point in the mixer control, - * all the dais per tap point should meet the required state for the - * commands such as vpcm_map_memory/vpcm_start to be executed. - */ - switch (direction) { - case VSS_IVPCM_TAP_POINT_DIR_OUT_IN: - if ((tp->playback_dai_data.state >= state) && - (tp->capture_dai_data.state >= state)) { - dais_started = true; - } - break; - - case VSS_IVPCM_TAP_POINT_DIR_IN: - if (tp->playback_dai_data.state >= state) - dais_started = true; - break; - - case VSS_IVPCM_TAP_POINT_DIR_OUT: - if (tp->capture_dai_data.state >= state) - dais_started = true; - break; - - default: - pr_err("invalid direction\n"); - } - - return dais_started; -} - -static void hpcm_create_free_queue(struct snd_dma_buffer *dma_buf, - struct dai_data *dai_data) -{ - struct hpcm_buf_node *buf_node = NULL; - int i = 0, offset = 0; - - for (i = 0; i < HPCM_MAX_Q_LEN; i++) { - buf_node = (void *)dma_buf->area + offset; - list_add_tail(&buf_node->list, - &dai_data->free_queue); - offset = offset + sizeof(struct hpcm_buf_node); - } -} - -static void hpcm_unmap_and_free_shared_memory(struct hpcm_drv *prtd, - struct tap_point *tp, - uint16_t direction) -{ - unsigned long paddr = 0; - char *sess = hpcm_get_sess_name(prtd->mixer_conf.sess_indx); - - switch (direction) { - case VSS_IVPCM_TAP_POINT_DIR_OUT_IN: - case VSS_IVPCM_TAP_POINT_DIR_IN: - paddr = tp->playback_dai_data.vocpcm_ion_buffer.paddr; - break; - - case VSS_IVPCM_TAP_POINT_DIR_OUT: - paddr = tp->capture_dai_data.vocpcm_ion_buffer.paddr; - break; - - default: - pr_err("Invalid direction\n"); - } - - if (paddr) { - voc_send_cvp_unmap_vocpcm_memory(voc_get_session_id(sess), - paddr); - ion_unmap_kernel(prtd->ion_client, tp->ion_handle); - ion_free(prtd->ion_client, tp->ion_handle); - tp->ion_mem_len = 0; - tp->playback_dai_data.vocpcm_ion_buffer.paddr = 0; - tp->capture_dai_data.vocpcm_ion_buffer.paddr = 0; - tp->playback_dai_data.vocpcm_ion_buffer.kvaddr = 0; - tp->capture_dai_data.vocpcm_ion_buffer.kvaddr = 0; - } - -} - -static int hpcm_map_vocpcm_memory(struct hpcm_drv *prtd, - struct tap_point *tp, - struct tappnt_mxr_data *tmd) -{ - unsigned long paddr = 0; - bool send_cmd = false; - int ret = 0; - char *sess = hpcm_get_sess_name(prtd->mixer_conf.sess_indx); - - /* - * only one memory map command is sent per tap point, ensure all dais - * for a tap point are in HPCM_PREPARED state. - */ - send_cmd = hpcm_all_dais_are_ready(tmd->direction, tp, HPCM_PREPARED); - - if (send_cmd == true) { - switch (tmd->direction) { - case VSS_IVPCM_TAP_POINT_DIR_OUT_IN: - case VSS_IVPCM_TAP_POINT_DIR_IN: - paddr = tp->playback_dai_data.vocpcm_ion_buffer.paddr; - break; - - case VSS_IVPCM_TAP_POINT_DIR_OUT: - paddr = tp->capture_dai_data.vocpcm_ion_buffer.paddr; - break; - } - - ret = voc_send_cvp_map_vocpcm_memory(voc_get_session_id(sess), - paddr, tp->ion_mem_len); - } - - return ret; - -} - -static int hpcm_allocate_shared_memory(struct hpcm_drv *prtd, - struct tap_point *tp, - struct tappnt_mxr_data *tmd) -{ - int result; - int mem_len; - dma_addr_t paddr; - void *kvptr; - int ion_mem_reqd = 0; - bool create_mem = false; - - - create_mem = hpcm_all_dais_are_ready(tmd->direction, tp, - HPCM_PREPARED); - - if (create_mem) { - if (tmd->direction == VSS_IVPCM_TAP_POINT_DIR_OUT_IN) - ion_mem_reqd = HPCM_MAX_VOC_PKT_SIZE * 2; - else - ion_mem_reqd = HPCM_MAX_VOC_PKT_SIZE; - - tp->ion_handle = ion_alloc(prtd->ion_client, - ion_mem_reqd, - SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0); - if (IS_ERR_OR_NULL((void *) tp->ion_handle)) { - pr_err("%s: ION memory allocation failed\n", - __func__); - goto error; - } - - result = ion_phys(prtd->ion_client, tp->ion_handle, - &paddr, (size_t *)&mem_len); - if (result) { - pr_err("%s: ION Get Physical failed, rc = %d\n", - __func__, result); - goto error; - } - - kvptr = ion_map_kernel(prtd->ion_client, tp->ion_handle); - if (IS_ERR_OR_NULL(kvptr)) { - pr_err("%s: ION memory mapping failed\n", __func__); - goto error; - } - - switch (tmd->direction) { - case VSS_IVPCM_TAP_POINT_DIR_OUT_IN: - tp->playback_dai_data.vocpcm_ion_buffer.paddr = - (uint32_t)paddr; - tp->playback_dai_data.vocpcm_ion_buffer.kvaddr = - (uint32_t)(uint8_t *)kvptr; - tp->capture_dai_data.vocpcm_ion_buffer.paddr = - (uint32_t)paddr + 1 * HPCM_MAX_VOC_PKT_SIZE; - tp->capture_dai_data.vocpcm_ion_buffer.kvaddr = - (uint32_t)(uint8_t *)kvptr + 1 * HPCM_MAX_VOC_PKT_SIZE; - break; - - case VSS_IVPCM_TAP_POINT_DIR_IN: - tp->playback_dai_data.vocpcm_ion_buffer.paddr = - (uint32_t)paddr; - tp->playback_dai_data.vocpcm_ion_buffer.kvaddr = - (uint32_t)(uint8_t *)kvptr; - break; - - case VSS_IVPCM_TAP_POINT_DIR_OUT: - tp->capture_dai_data.vocpcm_ion_buffer.paddr = - (uint32_t)paddr; - tp->capture_dai_data.vocpcm_ion_buffer.kvaddr = - (uint32_t)(uint8_t *)kvptr; - break; - } - - tp->ion_mem_len = ion_mem_reqd; - } - - return 0; - -error: - if (tp->ion_handle) - ion_free(prtd->ion_client, tp->ion_handle); - - return -ENOMEM; -} - -static int hpcm_start_vocpcm(char *pcm_id, struct hpcm_drv *prtd, - struct tap_point *tp) -{ - int indx = prtd->mixer_conf.sess_indx; - uint32_t *no_of_tp = &prtd->start_cmd.no_of_tapoints; - struct vss_ivpcm_tap_point *tap_pnt = &prtd->start_cmd.tap_pnt[0]; - uint32_t no_of_tp_req = 0; - char *sess = hpcm_get_sess_name(indx); - - if (prtd->mixer_conf.rx.enable) - no_of_tp_req++; - if (prtd->mixer_conf.tx.enable) - no_of_tp_req++; - - if (prtd->mixer_conf.rx.enable && (get_tappnt_value(pcm_id) == RX)) { - if (hpcm_all_dais_are_ready(prtd->mixer_conf.rx.direction, - tp, HPCM_PREPARED)) { - pr_debug("%s: RX conditions met\n", __func__); - tap_pnt[*no_of_tp].tap_point = - VSS_IVPCM_TAP_POINT_RX_DEFAULT; - tap_pnt[*no_of_tp].direction = - prtd->mixer_conf.rx.direction; - tap_pnt[*no_of_tp].sampling_rate = - prtd->mixer_conf.rx.sample_rate; - (*no_of_tp)++; - } - } - - if (prtd->mixer_conf.tx.enable && (get_tappnt_value(pcm_id) == TX)) { - if (hpcm_all_dais_are_ready(prtd->mixer_conf.tx.direction, - tp, HPCM_PREPARED)) { - pr_debug("%s: TX conditions met\n", __func__); - tap_pnt[*no_of_tp].tap_point = - VSS_IVPCM_TAP_POINT_TX_DEFAULT; - tap_pnt[*no_of_tp].direction = - prtd->mixer_conf.tx.direction; - tap_pnt[*no_of_tp].sampling_rate = - prtd->mixer_conf.tx.sample_rate; - (*no_of_tp)++; - } - } - - pr_debug("%s: *no_of_tp = %d no_of_tp_req = %d\n", - __func__, *no_of_tp, no_of_tp_req); - - if ((prtd->mixer_conf.tx.enable && prtd->mixer_conf.rx.enable) && - *no_of_tp == no_of_tp_req) { - voc_send_cvp_start_vocpcm(voc_get_session_id(sess), - tap_pnt, *no_of_tp); - memset(&prtd->start_cmd, 0, sizeof(struct start_cmd)); - } else if ((prtd->mixer_conf.tx.enable || - prtd->mixer_conf.rx.enable) && *no_of_tp == no_of_tp_req) { - voc_send_cvp_start_vocpcm(voc_get_session_id(sess), - tap_pnt, *no_of_tp); - memset(&prtd->start_cmd, 0, sizeof(struct start_cmd)); - } else { - pr_debug("%s: required pcm handles not opened yet\n", __func__); - } - - return 0; -} - -/* Playback path*/ -static void hpcm_copy_playback_data_from_queue(struct dai_data *dai_data, - uint32_t *len) -{ - struct hpcm_buf_node *buf_node = NULL; - unsigned long dsp_flags; - - if (dai_data->substream == NULL) - return; - - spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); - - if (!list_empty(&dai_data->filled_queue)) { - buf_node = list_first_entry(&dai_data->filled_queue, - struct hpcm_buf_node, list); - list_del(&buf_node->list); - *len = buf_node->frame.len; - memcpy((uint8_t *)dai_data->vocpcm_ion_buffer.kvaddr, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &dai_data->free_queue); - dai_data->pcm_irq_pos += dai_data->pcm_count; - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - snd_pcm_period_elapsed(dai_data->substream); - } else { - *len = 0; - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - pr_err("IN data not available\n"); - } - - wake_up(&dai_data->queue_wait); -} - -/* Capture path*/ -static void hpcm_copy_capture_data_to_queue(struct dai_data *dai_data, - uint32_t len) -{ - struct hpcm_buf_node *buf_node = NULL; - unsigned long dsp_flags; - - if (dai_data->substream == NULL) - return; - - /* Copy out buffer packet into free_queue */ - spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); - - if (!list_empty(&dai_data->free_queue)) { - buf_node = list_first_entry(&dai_data->free_queue, - struct hpcm_buf_node, list); - list_del(&buf_node->list); - buf_node->frame.len = len; - memcpy(&buf_node->frame.voc_pkt[0], - (uint8_t *)dai_data->vocpcm_ion_buffer.kvaddr, - buf_node->frame.len); - list_add_tail(&buf_node->list, &dai_data->filled_queue); - dai_data->pcm_irq_pos += dai_data->pcm_count; - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - snd_pcm_period_elapsed(dai_data->substream); - } else { - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - pr_err("OUTPUT data dropped\n"); - } - - wake_up(&dai_data->queue_wait); -} - -void hpcm_notify_evt_processing(uint8_t *data, char *session, - void *private_data) -{ - struct hpcm_drv *prtd = (struct hpcm_drv *)private_data; - struct vss_ivpcm_evt_notify *notify_evt = - (struct vss_ivpcm_evt_notify *)data; - struct vss_ivpcm_evt_push_buffer push_buff_event; - struct tap_point *tp = NULL; - int in_buf_len = 0; - struct tappnt_mxr_data *tmd = NULL; - char *sess = hpcm_get_sess_name(prtd->mixer_conf.sess_indx); - - /* If it's not a timetick, it's a error notification, drop the event */ - if ((notify_evt->notify_mask & VSS_IVPCM_NOTIFY_MASK_TIMETICK) == 0) { - pr_err("%s: Error notification. mask=%d\n", __func__, - notify_evt->notify_mask); - return; - } - - if (notify_evt->tap_point == VSS_IVPCM_TAP_POINT_TX_DEFAULT) { - tp = &prtd->session[prtd->mixer_conf.sess_indx].tx_tap_point; - tmd = &prtd->mixer_conf.tx; - } else if (notify_evt->tap_point == VSS_IVPCM_TAP_POINT_RX_DEFAULT) { - tp = &prtd->session[prtd->mixer_conf.sess_indx].rx_tap_point; - tmd = &prtd->mixer_conf.rx; - } - - if (notify_evt->notify_mask & VSS_IVPCM_NOTIFY_MASK_OUTPUT_BUFFER) { - hpcm_copy_capture_data_to_queue(&tp->capture_dai_data, - notify_evt->filled_out_size); - } - - if (notify_evt->notify_mask & VSS_IVPCM_NOTIFY_MASK_INPUT_BUFFER) { - hpcm_copy_playback_data_from_queue(&tp->playback_dai_data, - &in_buf_len); - } - - switch (tmd->direction) { - /* - * When the dir is OUT_IN, for the first notify mask, pushbuf mask - * should be set to VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER since we - * atleast need one buffer's worth data before we can send IN buffer. - * For the consecutive notify evts, the push buf mask will set for both - * VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER and - * VSS_IVPCM_PUSH_BUFFER_MASK_IN_BUFFER. - */ - case VSS_IVPCM_TAP_POINT_DIR_OUT_IN: - if (notify_evt->notify_mask == - VSS_IVPCM_NOTIFY_MASK_TIMETICK) { - push_buff_event.push_buf_mask = - VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER; - } else { - push_buff_event.push_buf_mask = - VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER | - VSS_IVPCM_PUSH_BUFFER_MASK_INPUT_BUFFER; - } - break; - - case VSS_IVPCM_TAP_POINT_DIR_IN: - push_buff_event.push_buf_mask = - VSS_IVPCM_PUSH_BUFFER_MASK_INPUT_BUFFER; - break; - - case VSS_IVPCM_TAP_POINT_DIR_OUT: - push_buff_event.push_buf_mask = - VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER; - break; - } - - push_buff_event.tap_point = notify_evt->tap_point; - push_buff_event.out_buf_addr = - tp->capture_dai_data.vocpcm_ion_buffer.paddr; - push_buff_event.in_buf_addr = - tp->playback_dai_data.vocpcm_ion_buffer.paddr; - push_buff_event.out_buf_size = notify_evt->request_buff_size; - push_buff_event.in_buf_size = in_buf_len; - push_buff_event.sampling_rate = notify_evt->sampling_rate; - push_buff_event.num_in_channels = 1; - - voc_send_cvp_vocpcm_push_buf_evt(voc_get_session_id(sess), - &push_buff_event); -} - -static int msm_hpcm_configure_voice_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - int tap_point = ucontrol->value.integer.value[0]; - uint16_t direction = ucontrol->value.integer.value[1]; - uint16_t sample_rate = ucontrol->value.integer.value[2]; - struct tappnt_mxr_data *tmd = NULL; - int ret = 0; - - mutex_lock(&hpcm_drv.lock); - pr_debug("%s: tap_point = %d direction = %d sample_rate = %d\n", - __func__, tap_point, direction, sample_rate); - - if (!hpcm_is_valid_config(VOICE_INDEX, tap_point, direction, - sample_rate)) { - pr_err("Invalid vpcm mixer control voice values\n"); - ret = -EINVAL; - goto done; - } - - if (tap_point == RX) - tmd = &hpcm_drv.mixer_conf.rx; - else - tmd = &hpcm_drv.mixer_conf.tx; - - tmd->enable = true; - tmd->direction = direction; - tmd->sample_rate = sample_rate; - hpcm_drv.mixer_conf.sess_indx = VOICE_INDEX; - -done: - mutex_unlock(&hpcm_drv.lock); - return ret; -} - -static int msm_hpcm_configure_voice_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s:\n", __func__); - return -EINVAL; -} - -static int msm_hpcm_configure_volte_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - int tap_point = ucontrol->value.integer.value[0]; - uint16_t direction = ucontrol->value.integer.value[1]; - uint16_t sample_rate = ucontrol->value.integer.value[2]; - struct tappnt_mxr_data *tmd = NULL; - int ret = 0; - - mutex_lock(&hpcm_drv.lock); - pr_debug("%s: tap_point=%d direction=%d sample_rate=%d\n", - __func__, tap_point, direction, sample_rate); - - if (!hpcm_is_valid_config(VOLTE_INDEX, tap_point, direction, - sample_rate)) { - pr_err("Invalid vpcm mixer control volte values\n"); - ret = -EINVAL; - goto done; - } - - if (tap_point == RX) - tmd = &hpcm_drv.mixer_conf.rx; - else - tmd = &hpcm_drv.mixer_conf.tx; - - tmd->enable = true; - tmd->direction = direction; - tmd->sample_rate = sample_rate; - hpcm_drv.mixer_conf.sess_indx = VOLTE_INDEX; - -done: - mutex_unlock(&hpcm_drv.lock); - return ret; - -} - -static int msm_hpcm_configure_volte_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s:\n", __func__); - return -EINVAL; -} - -static struct snd_kcontrol_new msm_hpcm_controls[] = { - SOC_SINGLE_MULTI_EXT("HPCM_Voice tappoint direction samplerate", - SND_SOC_NOPM, 0, 16000 , 0, 3, - msm_hpcm_configure_voice_get, - msm_hpcm_configure_voice_put), - SOC_SINGLE_MULTI_EXT("HPCM_VoLTE tappoint direction samplerate", - SND_SOC_NOPM, 0, 16000 , 0, 3, - msm_hpcm_configure_volte_get, - msm_hpcm_configure_volte_put), -}; - -/* Sample rates supported */ -static unsigned int supported_sample_rates[] = {8000, 16000}; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct list_head *ptr = NULL; - struct list_head *next = NULL; - struct hpcm_buf_node *buf_node = NULL; - struct snd_dma_buffer *dma_buf; - struct snd_pcm_runtime *runtime; - struct hpcm_drv *prtd; - unsigned long dsp_flags; - struct dai_data *dai_data = NULL; - struct tap_point *tp = NULL; - struct tappnt_mxr_data *tmd = NULL; - char *sess = NULL; - - if (substream == NULL) { - pr_err("substream is NULL\n"); - return -EINVAL; - } - - pr_debug("%s, %s\n", __func__, substream->pcm->id); - runtime = substream->runtime; - prtd = runtime->private_data; - sess = hpcm_get_sess_name(prtd->mixer_conf.sess_indx); - dai_data = hpcm_get_dai_data(substream->pcm->id, prtd); - - wake_up(&dai_data->queue_wait); - mutex_lock(&prtd->lock); - - tmd = hpcm_get_tappnt_mixer_data(substream->pcm->id, prtd); - - tp = hpcm_get_tappoint_data(substream->pcm->id, prtd); - /* Send stop command */ - voc_send_cvp_stop_vocpcm(voc_get_session_id(sess)); - /* Unmap will be called twice once for RX and TX each */ - hpcm_unmap_and_free_shared_memory(prtd, tp, tmd->direction); - /* Reset the cached start cmd */ - memset(&prtd->start_cmd, 0, sizeof(struct start_cmd)); - /* Release all buffer */ - pr_debug("%s: Release all buffer\n", __func__); - substream = dai_data->substream; - if (substream == NULL) { - pr_debug("%s: substream is NULL\n", __func__); - goto done; - } - dma_buf = &substream->dma_buffer; - if (dma_buf == NULL) { - pr_debug("%s: dma_buf is NULL\n", __func__); - goto done; - } - if (dma_buf->area != NULL) { - spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); - list_for_each_safe(ptr, next, &dai_data->filled_queue) { - buf_node = list_entry(ptr, - struct hpcm_buf_node, list); - list_del(&buf_node->list); - } - list_for_each_safe(ptr, next, &dai_data->free_queue) { - buf_node = list_entry(ptr, - struct hpcm_buf_node, list); - list_del(&buf_node->list); - } - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - dma_free_coherent(substream->pcm->card->dev, - runtime->hw.buffer_bytes_max, dma_buf->area, - dma_buf->addr); - dma_buf->area = NULL; - } - dai_data->substream = NULL; - dai_data->pcm_buf_pos = 0; - dai_data->pcm_count = 0; - dai_data->pcm_irq_pos = 0; - dai_data->pcm_size = 0; - dai_data->state = HPCM_CLOSED; - hpcm_reset_mixer_config(prtd); - -done: - mutex_unlock(&prtd->lock); - return ret; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - struct hpcm_buf_node *buf_node = NULL; - struct snd_pcm_runtime *runtime = substream->runtime; - struct hpcm_drv *prtd = runtime->private_data; - struct dai_data *dai_data = hpcm_get_dai_data(substream->pcm->id, prtd); - unsigned long dsp_flags; - - int count = frames_to_bytes(runtime, frames); - - ret = wait_event_interruptible_timeout(dai_data->queue_wait, - (!list_empty(&dai_data->free_queue) || - dai_data->state == HPCM_STOPPED), - 1 * HZ); - if (ret > 0) { - if (count <= HPCM_MAX_VOC_PKT_SIZE) { - spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); - buf_node = - list_first_entry(&dai_data->free_queue, - struct hpcm_buf_node, list); - list_del(&buf_node->list); - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - ret = copy_from_user(&buf_node->frame.voc_pkt, - buf, count); - buf_node->frame.len = count; - spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); - list_add_tail(&buf_node->list, &dai_data->filled_queue); - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - } else { - pr_err("%s: Write cnt %d is > HPCM_MAX_VOC_PKT_SIZE\n", - __func__, count); - ret = -ENOMEM; - } - } else if (ret == 0) { - pr_err("%s: No free Playback buffer\n", __func__); - ret = -ETIMEDOUT; - } else { - pr_err("%s: playback copy was interrupted\n", __func__); - } - - return ret; -} -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, - void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - int count = 0; - struct hpcm_buf_node *buf_node = NULL; - struct snd_pcm_runtime *runtime = substream->runtime; - struct hpcm_drv *prtd = runtime->private_data; - struct dai_data *dai_data = hpcm_get_dai_data(substream->pcm->id, prtd); - unsigned long dsp_flags; - - count = frames_to_bytes(runtime, frames); - - ret = wait_event_interruptible_timeout(dai_data->queue_wait, - (!list_empty(&dai_data->filled_queue) || - dai_data->state == HPCM_STOPPED), - 1 * HZ); - - if (ret > 0) { - if (count <= HPCM_MAX_VOC_PKT_SIZE) { - spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); - buf_node = list_first_entry(&dai_data->filled_queue, - struct hpcm_buf_node, list); - list_del(&buf_node->list); - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - ret = copy_to_user(buf, - &buf_node->frame.voc_pkt, - buf_node->frame.len); - if (ret) { - pr_err("%s: Copy to user retuned %d\n", - __func__, ret); - ret = -EFAULT; - } - spin_lock_irqsave(&dai_data->dsp_lock, dsp_flags); - list_add_tail(&buf_node->list, &dai_data->free_queue); - spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags); - - } else { - pr_err("%s: Read count %d > HPCM_MAX_VOC_PKT_SIZE\n", - __func__, count); - ret = -ENOMEM; - } - - } else if (ret == 0) { - pr_err("%s: No Caputre data available\n", __func__); - ret = -ETIMEDOUT; - } else { - pr_err("%s: Read was interrupted\n", __func__); - ret = -ERESTARTSYS; - } - - return ret; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int channel, - snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, channel, - hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, channel, - hwoff, buf, frames); - - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct dai_data *dai_data = NULL; - struct snd_pcm_runtime *runtime = substream->runtime; - struct hpcm_drv *prtd = runtime->private_data; - - dai_data = hpcm_get_dai_data(substream->pcm->id, prtd); - - if (dai_data->pcm_irq_pos >= dai_data->pcm_size) - dai_data->pcm_irq_pos = 0; - - return bytes_to_frames(runtime, (dai_data->pcm_irq_pos)); -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct hpcm_drv *prtd = runtime->private_data; - struct dai_data *dai_data = - hpcm_get_dai_data(substream->pcm->id, prtd); - - pr_debug("%s, %s\n", __func__, substream->pcm->id); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - pr_debug("SNDRV_PCM_TRIGGER_START\n"); - dai_data->state = HPCM_STARTED; - break; - - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - dai_data->state = HPCM_STOPPED; - break; - - default: - ret = -EINVAL; - break; - } - return ret; -} - -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct hpcm_drv *prtd = runtime->private_data; - struct dai_data *dai_data = NULL; - struct tap_point *tp = NULL; - struct tappnt_mxr_data *tmd = NULL; - - pr_debug("%s, %s\n", __func__, substream->pcm->id); - mutex_lock(&prtd->lock); - - dai_data = hpcm_get_dai_data(substream->pcm->id, prtd); - dai_data->pcm_size = snd_pcm_lib_buffer_bytes(substream); - dai_data->pcm_count = snd_pcm_lib_period_bytes(substream); - dai_data->pcm_irq_pos = 0; - dai_data->pcm_buf_pos = 0; - dai_data->state = HPCM_PREPARED; - - tp = hpcm_get_tappoint_data(substream->pcm->id, prtd); - tmd = hpcm_get_tappnt_mixer_data(substream->pcm->id, prtd); - - ret = hpcm_allocate_shared_memory(prtd, tp, tmd); - if (ret) { - pr_err("error creating shared memory err=%d\n", ret); - goto done; - } - ret = hpcm_map_vocpcm_memory(prtd, tp, tmd); - if (ret) { - pr_err("error mapping shared memory err=%d\n", ret); - goto done; - } - - ret = hpcm_start_vocpcm(substream->pcm->id, prtd, - hpcm_get_tappoint_data(substream->pcm->id, - prtd)); - if (ret) { - pr_err("error sending start cmd err=%d\n", ret); - goto done; - } - -done: - mutex_unlock(&prtd->lock); - return ret; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct hpcm_drv *prtd = (struct hpcm_drv *)runtime->private_data; - int ret = 0; - - pr_debug("%s: %s\n", __func__, substream->pcm->id); - - mutex_lock(&prtd->lock); - - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - - dma_buf->area = dma_alloc_coherent(substream->pcm->card->dev, - runtime->hw.buffer_bytes_max, - &dma_buf->addr, GFP_KERNEL); - - if (!dma_buf->area) { - pr_err("%s:MSM dma_alloc failed\n", __func__); - ret = -ENOMEM; - goto done; - } - - dma_buf->bytes = runtime->hw.buffer_bytes_max; - memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max); - - hpcm_create_free_queue(dma_buf, - hpcm_get_dai_data(substream->pcm->id, prtd)); - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - -done: - mutex_unlock(&prtd->lock); - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct hpcm_drv *prtd = &hpcm_drv; - struct tappnt_mxr_data *tmd = NULL; - struct dai_data *dai_data = NULL; - int ret = 0; - int tp_val = 0; - - pr_debug("%s, %s\n", __func__, substream->pcm->id); - mutex_lock(&prtd->lock); - - runtime->hw = msm_pcm_hardware; - - ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_debug("snd_pcm_hw_constraint_list failed\n"); - - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) { - pr_debug("snd_pcm_hw_constraint_integer failed\n"); - goto done; - } - - tp_val = get_tappnt_value(substream->pcm->id); - tmd = hpcm_get_tappnt_mixer_data(substream->pcm->id, prtd); - - /*Check whehter the kcontrol values set are valid*/ - if (!tmd || - !(tmd->enable) || - !hpcm_is_valid_config(prtd->mixer_conf.sess_indx, - tp_val, tmd->direction, - tmd->sample_rate)) { - ret = -EINVAL; - goto done; - } - - dai_data = hpcm_get_dai_data(substream->pcm->id, prtd); - dai_data->substream = substream; - runtime->private_data = prtd; - -done: - mutex_unlock(&prtd->lock); - return ret; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .hw_params = msm_pcm_hw_params, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .copy = msm_pcm_copy, - .close = msm_pcm_close, -}; - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - - pr_debug("%s:\n", __func__); - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - - return 0; -} - -static int msm_pcm_hpcm_probe(struct snd_soc_platform *platform) -{ - snd_soc_add_platform_controls(platform, msm_hpcm_controls, - ARRAY_SIZE(msm_hpcm_controls)); - - return 0; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, - .probe = msm_pcm_hpcm_probe, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-host-pcm-voice", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - int i = 0; - struct session *s = NULL; - - memset(&hpcm_drv, 0, sizeof(hpcm_drv)); - mutex_init(&hpcm_drv.lock); - - hpcm_drv.ion_client = msm_ion_client_create(UINT_MAX, "host_voice_pcm"); - if (IS_ERR_OR_NULL((void *)hpcm_drv.ion_client)) { - pr_err("%s: ION create client failed\n", __func__); - return -ENOMEM; - } - - for (i = 0; i < MAX_SESSION; i++) { - s = &hpcm_drv.session[i]; - spin_lock_init(&s->rx_tap_point.capture_dai_data.dsp_lock); - spin_lock_init(&s->rx_tap_point.playback_dai_data.dsp_lock); - spin_lock_init(&s->tx_tap_point.capture_dai_data.dsp_lock); - spin_lock_init(&s->tx_tap_point.playback_dai_data.dsp_lock); - - init_waitqueue_head( - &s->rx_tap_point.capture_dai_data.queue_wait); - init_waitqueue_head( - &s->rx_tap_point.playback_dai_data.queue_wait); - init_waitqueue_head( - &s->tx_tap_point.capture_dai_data.queue_wait); - init_waitqueue_head( - &s->tx_tap_point.playback_dai_data.queue_wait); - - INIT_LIST_HEAD(&s->rx_tap_point.capture_dai_data.filled_queue); - INIT_LIST_HEAD(&s->rx_tap_point.capture_dai_data.free_queue); - INIT_LIST_HEAD(&s->rx_tap_point.playback_dai_data.filled_queue); - INIT_LIST_HEAD(&s->rx_tap_point.playback_dai_data.free_queue); - - INIT_LIST_HEAD(&s->tx_tap_point.capture_dai_data.filled_queue); - INIT_LIST_HEAD(&s->tx_tap_point.capture_dai_data.free_queue); - INIT_LIST_HEAD(&s->tx_tap_point.playback_dai_data.filled_queue); - INIT_LIST_HEAD(&s->tx_tap_point.playback_dai_data.free_queue); - } - - voc_register_hpcm_evt_cb(hpcm_notify_evt_processing, &hpcm_drv); - - return platform_driver_register(&msm_pcm_driver); - -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-loopback.c b/sound/soc/msm/msm-pcm-loopback.c deleted file mode 100644 index ab5e8081c3791b9ae103ca1a50787e671118208e..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-loopback.c +++ /dev/null @@ -1,431 +0,0 @@ -/* Copyright (c) 2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm-routing.h" - -#define LOOPBACK_VOL_MAX_STEPS 0x2000 - -static const DECLARE_TLV_DB_LINEAR(loopback_rx_vol_gain, 0, - LOOPBACK_VOL_MAX_STEPS); - -struct msm_pcm_loopback { - struct snd_pcm_substream *playback_substream; - struct snd_pcm_substream *capture_substream; - - int instance; - - struct mutex lock; - - uint32_t samp_rate; - uint32_t channel_mode; - - int playback_start; - int capture_start; - int session_id; - struct audio_client *audio_client; - int volume; -}; - -static void stop_pcm(struct msm_pcm_loopback *pcm); - -static const struct snd_pcm_hardware dummy_pcm_hardware = { - .formats = 0xffffffff, - .channels_min = 1, - .channels_max = UINT_MAX, - - /* Random values to keep userspace happy when checking constraints */ - .info = SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_BLOCK_TRANSFER, - .buffer_bytes_max = 128*1024, - .period_bytes_min = 1024, - .period_bytes_max = 1024*2, - .periods_min = 2, - .periods_max = 128, -}; - -static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event, - void *priv_data) -{ - struct msm_pcm_loopback *pcm = priv_data; - - BUG_ON(!pcm); - - pr_debug("%s: event %x\n", __func__, event); - - switch (event) { - case MSM_PCM_RT_EVT_DEVSWITCH: - q6asm_cmd(pcm->audio_client, CMD_PAUSE); - q6asm_cmd(pcm->audio_client, CMD_FLUSH); - q6asm_run(pcm->audio_client, 0, 0, 0); - default: - break; - } -} - -static void msm_pcm_loopback_event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ - pr_debug("%s\n", __func__); - switch (opcode) { - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - break; - default: - break; - } - } - break; - default: - pr_err("Not Supported Event opcode[0x%x]\n", opcode); - break; - } -} - -static int pcm_loopback_set_volume(struct msm_pcm_loopback *prtd, int volume) -{ - int rc = 0; - - pr_debug("%s Setting volume 0x%x\n", __func__, volume); - - if (prtd) { - rc = q6asm_set_volume(prtd->audio_client, volume); - if (rc < 0) { - pr_err("%s: Send Volume command failed rc = %d\n", - __func__, rc); - return rc; - } - prtd->volume = volume; - } - return rc; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); - struct msm_pcm_loopback *pcm; - int ret = 0; - struct msm_pcm_routing_evt event; - - pcm = dev_get_drvdata(rtd->platform->dev); - mutex_lock(&pcm->lock); - - snd_soc_set_runtime_hwparams(substream, &dummy_pcm_hardware); - pcm->volume = 0x2000; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - pcm->playback_substream = substream; - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - pcm->capture_substream = substream; - - pcm->instance++; - dev_dbg(rtd->platform->dev, "%s: pcm out open: %d,%d\n", __func__, - pcm->instance, substream->stream); - if (pcm->instance == 2) { - struct snd_soc_pcm_runtime *soc_pcm_rx = - pcm->playback_substream->private_data; - struct snd_soc_pcm_runtime *soc_pcm_tx = - pcm->capture_substream->private_data; - if (pcm->audio_client != NULL) - stop_pcm(pcm); - - pcm->audio_client = q6asm_audio_client_alloc( - (app_cb)msm_pcm_loopback_event_handler, pcm); - if (!pcm->audio_client) { - dev_err(rtd->platform->dev, - "%s: Could not allocate memory\n", __func__); - mutex_unlock(&pcm->lock); - return -ENOMEM; - } - pcm->session_id = pcm->audio_client->session; - pcm->audio_client->perf_mode = false; - ret = q6asm_open_loopack(pcm->audio_client); - if (ret < 0) { - dev_err(rtd->platform->dev, - "%s: pcm out open failed\n", __func__); - q6asm_audio_client_free(pcm->audio_client); - mutex_unlock(&pcm->lock); - return -ENOMEM; - } - event.event_func = msm_pcm_route_event_handler; - event.priv_data = (void *) pcm; - msm_pcm_routing_reg_phy_stream(soc_pcm_tx->dai_link->be_id, - pcm->audio_client->perf_mode, - pcm->session_id, pcm->capture_substream->stream); - msm_pcm_routing_reg_phy_stream_v2(soc_pcm_rx->dai_link->be_id, - pcm->audio_client->perf_mode, - pcm->session_id, pcm->playback_substream->stream, - event); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - pcm->playback_substream = substream; - ret = pcm_loopback_set_volume(pcm, pcm->volume); - if (ret < 0) - dev_err(rtd->platform->dev, - "Error %d setting volume", ret); - } - } - dev_info(rtd->platform->dev, "%s: Instance = %d, Stream ID = %s\n", - __func__ , pcm->instance, substream->pcm->id); - runtime->private_data = pcm; - - mutex_unlock(&pcm->lock); - - return 0; -} - -static void stop_pcm(struct msm_pcm_loopback *pcm) -{ - struct snd_soc_pcm_runtime *soc_pcm_rx = - pcm->playback_substream->private_data; - struct snd_soc_pcm_runtime *soc_pcm_tx = - pcm->capture_substream->private_data; - - if (pcm->audio_client == NULL) - return; - q6asm_cmd(pcm->audio_client, CMD_CLOSE); - - msm_pcm_routing_dereg_phy_stream(soc_pcm_rx->dai_link->be_id, - SNDRV_PCM_STREAM_PLAYBACK); - msm_pcm_routing_dereg_phy_stream(soc_pcm_tx->dai_link->be_id, - SNDRV_PCM_STREAM_CAPTURE); - q6asm_audio_client_free(pcm->audio_client); - pcm->audio_client = NULL; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_pcm_loopback *pcm = runtime->private_data; - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); - int ret = 0; - - mutex_lock(&pcm->lock); - - dev_dbg(rtd->platform->dev, "%s: end pcm call:%d\n", - __func__, substream->stream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - pcm->playback_start = 0; - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - pcm->capture_start = 0; - - pcm->instance--; - if (!pcm->playback_start || !pcm->capture_start) { - dev_dbg(rtd->platform->dev, "%s: end pcm call\n", __func__); - stop_pcm(pcm); - } - - mutex_unlock(&pcm->lock); - return ret; -} - -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_pcm_loopback *pcm = runtime->private_data; - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); - - mutex_lock(&pcm->lock); - - dev_dbg(rtd->platform->dev, "%s: ASM loopback stream:%d\n", - __func__, substream->stream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (!pcm->playback_start) - pcm->playback_start = 1; - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (!pcm->capture_start) - pcm->capture_start = 1; - } - mutex_unlock(&pcm->lock); - - return ret; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_pcm_loopback *pcm = runtime->private_data; - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - dev_dbg(rtd->platform->dev, - "%s: playback_start:%d,capture_start:%d\n", __func__, - pcm->playback_start, pcm->capture_start); - if (pcm->playback_start && pcm->capture_start) - q6asm_run_nowait(pcm->audio_client, 0, 0, 0); - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - case SNDRV_PCM_TRIGGER_STOP: - dev_dbg(rtd->platform->dev, - "%s:Pause/Stop - playback_start:%d,capture_start:%d\n", - __func__, pcm->playback_start, pcm->capture_start); - if (pcm->playback_start && pcm->capture_start) - q6asm_cmd_nowait(pcm->audio_client, CMD_PAUSE); - break; - default: - break; - } - - return 0; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); - - dev_dbg(rtd->platform->dev, "%s: ASM loopback\n", __func__); - - return snd_pcm_lib_alloc_vmalloc_buffer(substream, - params_buffer_bytes(params)); -} - -static int msm_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_vmalloc_buffer(substream); -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .hw_params = msm_pcm_hw_params, - .hw_free = msm_pcm_hw_free, - .close = msm_pcm_close, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, -}; - -static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - struct snd_pcm_volume *vol = kcontrol->private_data; - struct snd_pcm_substream *substream = vol->pcm->streams[0].substream; - struct msm_pcm_loopback *prtd = substream->runtime->private_data; - int volume = ucontrol->value.integer.value[0]; - - rc = pcm_loopback_set_volume(prtd, volume); - return rc; -} - -static int msm_pcm_add_controls(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_pcm *pcm = rtd->pcm->streams[0].pcm; - struct snd_pcm_volume *volume_info; - struct snd_kcontrol *kctl; - int ret = 0; - - dev_dbg(rtd->dev, "%s, Volume cntrl add\n", __func__); - ret = snd_pcm_add_volume_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, - NULL, 1, - rtd->dai_link->be_id, - &volume_info); - if (ret < 0) - return ret; - kctl = volume_info->kctl; - kctl->put = msm_pcm_volume_ctl_put; - kctl->tlv.p = loopback_rx_vol_gain; - return 0; -} - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - - ret = msm_pcm_add_controls(rtd); - if (ret) - dev_err(rtd->dev, "%s, kctl add failed\n", __func__); - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - struct msm_pcm_loopback *pcm; - - dev_dbg(&pdev->dev, "%s: dev name %s\n", - __func__, dev_name(&pdev->dev)); - - pcm = kzalloc(sizeof(struct msm_pcm_loopback), GFP_KERNEL); - if (!pcm) { - dev_err(&pdev->dev, "%s Failed to allocate memory for pcm\n", - __func__); - return -ENOMEM; - } else { - mutex_init(&pcm->lock); - dev_set_drvdata(&pdev->dev, pcm); - } - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - struct msm_pcm_loopback *pcm; - - pcm = dev_get_drvdata(&pdev->dev); - mutex_destroy(&pcm->lock); - - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-pcm-loopback", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM loopback platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-lpa.c b/sound/soc/msm/msm-pcm-lpa.c deleted file mode 100644 index db9fe4377eaa839c9ec2e377b0d59f8b7bb225ef..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-lpa.c +++ /dev/null @@ -1,618 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "msm-pcm-q6.h" -#include "msm-pcm-routing.h" - -static struct audio_locks the_locks; - -struct snd_msm { - struct msm_audio *prtd; - unsigned volume; -}; -static struct snd_msm lpa_audio; - -static struct snd_pcm_hardware msm_pcm_hardware = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = 1024 * 1024, -/* TODO: Check on the lowest period size we can support */ - .period_bytes_min = 128 * 1024, - .period_bytes_max = 256 * 1024, - .periods_min = 4, - .periods_max = 8, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static void event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ - struct msm_audio *prtd = priv; - struct snd_pcm_substream *substream = prtd->substream; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_aio_write_param param; - struct audio_buffer *buf = NULL; - unsigned long flag = 0; - int i = 0; - - pr_debug("%s\n", __func__); - spin_lock_irqsave(&the_locks.event_lock, flag); - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: { - uint32_t *ptrmem = (uint32_t *)¶m; - pr_debug("ASM_DATA_EVENT_WRITE_DONE\n"); - pr_debug("Buffer Consumed = 0x%08x\n", *ptrmem); - prtd->pcm_irq_pos += prtd->pcm_count; - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - else - if (substream->timer_running) - snd_timer_interrupt(substream->timer, 1); - - atomic_inc(&prtd->out_count); - wake_up(&the_locks.write_wait); - if (!atomic_read(&prtd->start)) { - atomic_set(&prtd->pending_buffer, 1); - break; - } else - atomic_set(&prtd->pending_buffer, 0); - - buf = prtd->audio_client->port[IN].buf; - if (runtime->status->hw_ptr >= runtime->control->appl_ptr) { - memset((void *)buf[0].data + - (prtd->out_head * prtd->pcm_count), - 0, prtd->pcm_count); - } - pr_debug("%s:writing %d bytes of buffer to dsp 2\n", - __func__, prtd->pcm_count); - - param.paddr = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count); - param.len = prtd->pcm_count; - param.msw_ts = 0; - param.lsw_ts = 0; - param.flags = NO_TIMESTAMP; - param.uid = (unsigned long)buf[0].phys - + (prtd->out_head * prtd->pcm_count); - for (i = 0; i < sizeof(struct audio_aio_write_param)/4; - i++, ++ptrmem) - pr_debug("cmd[%d]=0x%08x\n", i, *ptrmem); - if (q6asm_async_write(prtd->audio_client, - ¶m) < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - else - prtd->out_head = - (prtd->out_head + 1) & (runtime->periods - 1); - atomic_set(&prtd->pending_buffer, 0); - break; - } - case ASM_DATA_CMDRSP_EOS: - pr_debug("ASM_DATA_CMDRSP_EOS\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - break; - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case ASM_SESSION_CMD_RUN: { - if (!atomic_read(&prtd->pending_buffer)) - break; - if (runtime->status->hw_ptr >= - runtime->control->appl_ptr) - break; - pr_debug("%s:writing %d bytes" - " of buffer to dsp\n", - __func__, prtd->pcm_count); - buf = prtd->audio_client->port[IN].buf; - param.paddr = (unsigned long)buf[prtd->out_head].phys; - param.len = prtd->pcm_count; - param.msw_ts = 0; - param.lsw_ts = 0; - param.flags = NO_TIMESTAMP; - param.uid = (unsigned long)buf[prtd->out_head].phys; - if (q6asm_async_write(prtd->audio_client, - ¶m) < 0) - pr_err("%s:q6asm_async_write failed\n", - __func__); - else - prtd->out_head = - (prtd->out_head + 1) - & (runtime->periods - 1); - atomic_set(&prtd->pending_buffer, 0); - } - break; - case ASM_STREAM_CMD_FLUSH: - pr_debug("ASM_STREAM_CMD_FLUSH\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - break; - default: - break; - } - break; - } - default: - pr_debug("Not Supported Event opcode[0x%x]\n", opcode); - break; - } - spin_unlock_irqrestore(&the_locks.event_lock, flag); -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret; - - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - prtd->out_head = 0; - if (prtd->enabled) - return 0; - - ret = q6asm_media_format_block_pcm(prtd->audio_client, runtime->rate, - runtime->channels); - if (ret < 0) - pr_debug("%s: CMD Format block failed\n", __func__); - - atomic_set(&prtd->out_count, runtime->periods); - prtd->enabled = 1; - prtd->cmd_ack = 0; - return 0; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - pr_debug("%s\n", __func__); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - prtd->pcm_irq_pos = 0; - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("SNDRV_PCM_TRIGGER_START\n"); - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); - atomic_set(&prtd->start, 1); - atomic_set(&prtd->stop, 0); - break; - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - atomic_set(&prtd->start, 0); - atomic_set(&prtd->stop, 1); - if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) - break; - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("SNDRV_PCM_TRIGGER_PAUSE\n"); - q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE); - atomic_set(&prtd->start, 0); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd; - struct asm_softpause_params softpause = { - .enable = SOFT_PAUSE_ENABLE, - .period = SOFT_PAUSE_PERIOD, - .step = SOFT_PAUSE_STEP, - .rampingcurve = SOFT_PAUSE_CURVE_LINEAR, - }; - struct asm_softvolume_params softvol = { - .period = SOFT_VOLUME_PERIOD, - .step = SOFT_VOLUME_STEP, - .rampingcurve = SOFT_VOLUME_CURVE_LINEAR, - }; - int ret = 0; - - pr_debug("%s\n", __func__); - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - if (prtd == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - return -ENOMEM; - } - runtime->hw = msm_pcm_hardware; - prtd->substream = substream; - prtd->audio_client = q6asm_audio_client_alloc( - (app_cb)event_handler, prtd); - if (!prtd->audio_client) { - pr_debug("%s: Could not allocate memory\n", __func__); - kfree(prtd); - return -ENOMEM; - } - prtd->audio_client->perf_mode = false; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = q6asm_open_write(prtd->audio_client, FORMAT_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm out open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - ret = q6asm_set_io_mode(prtd->audio_client, ASYNC_IO_MODE); - if (ret < 0) { - pr_err("%s: Set IO mode failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - } - /* Capture path */ - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - return -EPERM; - pr_debug("%s: session ID %d\n", __func__, prtd->audio_client->session); - prtd->session_id = prtd->audio_client->session; - msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, substream->stream); - - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_debug("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_debug("snd_pcm_hw_constraint_integer failed\n"); - - prtd->dsp_cnt = 0; - atomic_set(&prtd->pending_buffer, 1); - atomic_set(&prtd->stop, 1); - runtime->private_data = prtd; - lpa_audio.prtd = prtd; - lpa_set_volume(0); - ret = q6asm_set_softpause(lpa_audio.prtd->audio_client, &softpause); - if (ret < 0) - pr_err("%s: Send SoftPause Param failed ret=%d\n", - __func__, ret); - ret = q6asm_set_softvolume(lpa_audio.prtd->audio_client, &softvol); - if (ret < 0) - pr_err("%s: Send SoftVolume Param failed ret=%d\n", - __func__, ret); - - return 0; -} - -int lpa_set_volume(unsigned volume) -{ - int rc = 0; - if (lpa_audio.prtd && lpa_audio.prtd->audio_client) { - rc = q6asm_set_volume(lpa_audio.prtd->audio_client, volume); - if (rc < 0) { - pr_err("%s: Send Volume command failed" - " rc=%d\n", __func__, rc); - } - } - lpa_audio.volume = volume; - return rc; -} - -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = runtime->private_data; - int dir = 0; - int rc = 0; - - /* - If routing is still enabled, we need to issue EOS to - the DSP - To issue EOS to dsp, we need to be run state otherwise - EOS is not honored. - */ - if (msm_routing_check_backend_enabled(soc_prtd->dai_link->be_id) && - (!atomic_read(&prtd->stop))) { - rc = q6asm_run(prtd->audio_client, 0, 0, 0); - atomic_set(&prtd->pending_buffer, 0); - prtd->cmd_ack = 0; - q6asm_cmd_nowait(prtd->audio_client, CMD_EOS); - pr_debug("%s\n", __func__); - rc = wait_event_timeout(the_locks.eos_wait, - prtd->cmd_ack, 5 * HZ); - if (!rc) - pr_err("EOS cmd timeout\n"); - prtd->pcm_irq_pos = 0; - } - - dir = IN; - atomic_set(&prtd->pending_buffer, 0); - lpa_audio.prtd = NULL; - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - - atomic_set(&prtd->stop, 1); - pr_debug("%s\n", __func__); - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_PLAYBACK); - pr_debug("%s\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - - return 0; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - return ret; -} - -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - pr_debug("%s: pcm_irq_pos = %d\n", __func__, prtd->pcm_irq_pos); - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - int result = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - prtd->mmap_flag = 1; - - if (runtime->dma_addr && runtime->dma_bytes) { - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - result = remap_pfn_range(vma, vma->vm_start, - runtime->dma_addr >> PAGE_SHIFT, - runtime->dma_bytes, - vma->vm_page_prot); - } else { - pr_err("Physical address or size of buf is NULL"); - return -EINVAL; - } - return result; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct audio_buffer *buf; - int dir, ret; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dir = IN; - else - return -EPERM; - ret = q6asm_audio_client_buf_alloc_contiguous(dir, - prtd->audio_client, - params_period_bytes(params), - params_periods(params)); - if (ret < 0) { - pr_err("Audio Start: Buffer Allocation failed \ - rc = %d\n", ret); - return -ENOMEM; - } - buf = prtd->audio_client->port[dir].buf; - - if (buf == NULL || buf[0].data == NULL) - return -ENOMEM; - - pr_debug("%s:buf = %p\n", __func__, buf); - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - dma_buf->area = buf[0].data; - dma_buf->addr = buf[0].phys; - dma_buf->bytes = params_period_bytes(params) * params_periods(params); - if (!dma_buf->area) - return -ENOMEM; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} - -static int msm_pcm_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - int rc = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - uint64_t timestamp; - uint64_t temp; - - switch (cmd) { - case SNDRV_COMPRESS_TSTAMP: { - struct snd_compr_tstamp tstamp; - pr_debug("SNDRV_COMPRESS_TSTAMP\n"); - - memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp)); - rc = q6asm_get_session_time(prtd->audio_client, ×tamp); - if (rc < 0) { - pr_err("%s: fail to get session tstamp\n", __func__); - return rc; - } - temp = (timestamp * 2 * runtime->channels); - temp = temp * (runtime->rate/1000); - temp = div_u64(temp, 1000); - tstamp.sampling_rate = runtime->rate; - tstamp.timestamp = timestamp; - pr_debug("%s: bytes_consumed:" - "timestamp = %lld,\n",__func__, - tstamp.timestamp); - if (copy_to_user((void *) arg, &tstamp, - sizeof(struct snd_compr_tstamp))) - return -EFAULT; - return 0; - } - case SNDRV_PCM_IOCTL1_RESET: - prtd->cmd_ack = 0; - rc = q6asm_cmd(prtd->audio_client, CMD_FLUSH); - if (rc < 0) - pr_err("%s: flush cmd failed rc=%d\n", __func__, rc); - rc = wait_event_timeout(the_locks.eos_wait, - prtd->cmd_ack, 5 * HZ); - if (!rc) - pr_err("Flush cmd timeout\n"); - prtd->pcm_irq_pos = 0; - break; - default: - break; - } - return snd_pcm_lib_ioctl(substream, cmd, arg); -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = msm_pcm_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", - __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-pcm-lpa", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - spin_lock_init(&the_locks.event_lock); - init_waitqueue_head(&the_locks.enable_wait); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-q6.c b/sound/soc/msm/msm-pcm-q6.c deleted file mode 100644 index fb4008fb4709ec6ca5a34840672cce070ce91a73..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-q6.c +++ /dev/null @@ -1,790 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "msm-pcm-q6.h" -#include "msm-pcm-routing.h" - -static struct audio_locks the_locks; - -struct snd_msm { - struct snd_card *card; - struct snd_pcm *pcm; -}; - -#define PLAYBACK_NUM_PERIODS 8 -#define PLAYBACK_PERIOD_SIZE 2048 -#define CAPTURE_NUM_PERIODS 16 -#define CAPTURE_PERIOD_SIZE 320 - -static struct snd_pcm_hardware msm_pcm_hardware_capture = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 4, - .buffer_bytes_max = CAPTURE_NUM_PERIODS * CAPTURE_PERIOD_SIZE, - .period_bytes_min = CAPTURE_PERIOD_SIZE, - .period_bytes_max = CAPTURE_PERIOD_SIZE, - .periods_min = CAPTURE_NUM_PERIODS, - .periods_max = CAPTURE_NUM_PERIODS, - .fifo_size = 0, -}; - -static struct snd_pcm_hardware msm_pcm_hardware_playback = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = PLAYBACK_NUM_PERIODS * PLAYBACK_PERIOD_SIZE, - .period_bytes_min = PLAYBACK_PERIOD_SIZE, - .period_bytes_max = PLAYBACK_PERIOD_SIZE, - .periods_min = PLAYBACK_NUM_PERIODS, - .periods_max = PLAYBACK_NUM_PERIODS, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static uint32_t in_frame_info[CAPTURE_NUM_PERIODS][2]; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static void msm_pcm_route_event_handler(enum msm_pcm_routing_event event, - void *priv_data) -{ - struct msm_audio *prtd = priv_data; - - BUG_ON(!prtd); - - pr_debug("%s: event %x\n", __func__, event); - - switch (event) { - case MSM_PCM_RT_EVT_BUF_RECFG: - q6asm_cmd(prtd->audio_client, CMD_PAUSE); - q6asm_cmd(prtd->audio_client, CMD_FLUSH); - q6asm_run(prtd->audio_client, 0, 0, 0); - default: - break; - } -} - -static void event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ - struct msm_audio *prtd = priv; - struct snd_pcm_substream *substream = prtd->substream; - uint32_t *ptrmem = (uint32_t *)payload; - int i = 0; - uint32_t idx = 0; - uint32_t size = 0; - - pr_debug("%s\n", __func__); - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: { - pr_debug("ASM_DATA_EVENT_WRITE_DONE\n"); - pr_debug("Buffer Consumed = 0x%08x\n", *ptrmem); - prtd->pcm_irq_pos += prtd->pcm_count; - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - atomic_inc(&prtd->out_count); - wake_up(&the_locks.write_wait); - if (!atomic_read(&prtd->start)) - break; - if (!prtd->mmap_flag) - break; - if (q6asm_is_cpu_buf_avail_nolock(IN, - prtd->audio_client, - &size, &idx)) { - pr_debug("%s:writing %d bytes of buffer to dsp 2\n", - __func__, prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, 0, 0, NO_TIMESTAMP); - } - break; - } - case ASM_DATA_CMDRSP_EOS: - pr_debug("ASM_DATA_CMDRSP_EOS\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - break; - case ASM_DATA_EVENT_READ_DONE: { - pr_debug("ASM_DATA_EVENT_READ_DONE\n"); - pr_debug("token = 0x%08x\n", token); - for (i = 0; i < 8; i++, ++ptrmem) - pr_debug("cmd[%d]=0x%08x\n", i, *ptrmem); - in_frame_info[token][0] = payload[2]; - in_frame_info[token][1] = payload[3]; - - /* assume data size = 0 during flushing */ - if (in_frame_info[token][0]) { - prtd->pcm_irq_pos += prtd->pcm_count; - pr_debug("pcm_irq_pos=%d\n", prtd->pcm_irq_pos); - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - if (atomic_read(&prtd->in_count) <= prtd->periods) - atomic_inc(&prtd->in_count); - wake_up(&the_locks.read_wait); - if (prtd->mmap_flag && - q6asm_is_cpu_buf_avail_nolock(OUT, - prtd->audio_client, - &size, &idx)) - q6asm_read_nolock(prtd->audio_client); - } else { - pr_debug("%s: reclaim flushed buf in_count %x\n", - __func__, atomic_read(&prtd->in_count)); - atomic_inc(&prtd->in_count); - if (atomic_read(&prtd->in_count) == prtd->periods) { - pr_info("%s: reclaimed all bufs\n", __func__); - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - wake_up(&the_locks.read_wait); - } - } - - break; - } - case APR_BASIC_RSP_RESULT: { - switch (payload[0]) { - case ASM_SESSION_CMD_RUN: - if (substream->stream - != SNDRV_PCM_STREAM_PLAYBACK) { - atomic_set(&prtd->start, 1); - break; - } - if (prtd->mmap_flag) { - pr_debug("%s:writing %d bytes" - " of buffer to dsp\n", - __func__, - prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); - } else { - while (atomic_read(&prtd->out_needed)) { - pr_debug("%s:writing %d bytes" - " of buffer to dsp\n", - __func__, - prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); - atomic_dec(&prtd->out_needed); - wake_up(&the_locks.write_wait); - }; - } - atomic_set(&prtd->start, 1); - break; - default: - break; - } - } - break; - default: - pr_debug("Not Supported Event opcode[0x%x]\n", opcode); - break; - } -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret; - - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - if (prtd->enabled) - return 0; - - ret = q6asm_media_format_block_pcm(prtd->audio_client, runtime->rate, - runtime->channels); - if (ret < 0) - pr_info("%s: CMD Format block failed\n", __func__); - - atomic_set(&prtd->out_count, runtime->periods); - - prtd->enabled = 1; - prtd->cmd_ack = 0; - - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret = 0; - int i = 0; - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - - if (prtd->enabled) - return 0; - - pr_debug("Samp_rate = %d\n", prtd->samp_rate); - pr_debug("Channel = %d\n", prtd->channel_mode); - if (prtd->channel_mode > 2) { - ret = q6asm_enc_cfg_blk_multi_ch_pcm(prtd->audio_client, - prtd->samp_rate, prtd->channel_mode); - } else { - ret = q6asm_enc_cfg_blk_pcm(prtd->audio_client, - prtd->samp_rate, prtd->channel_mode); - } - - if (ret < 0) - pr_debug("%s: cmd cfg pcm was block failed", __func__); - - for (i = 0; i < runtime->periods; i++) - q6asm_read(prtd->audio_client); - prtd->periods = runtime->periods; - - prtd->enabled = 1; - - return ret; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("%s: Trigger start\n", __func__); - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); - break; - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - atomic_set(&prtd->start, 0); - if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) - break; - prtd->cmd_ack = 0; - q6asm_cmd_nowait(prtd->audio_client, CMD_EOS); - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("SNDRV_PCM_TRIGGER_PAUSE\n"); - q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE); - atomic_set(&prtd->start, 0); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd; - int ret = 0; - - pr_debug("%s\n", __func__); - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - if (prtd == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - return -ENOMEM; - } - prtd->substream = substream; - prtd->audio_client = q6asm_audio_client_alloc( - (app_cb)event_handler, prtd); - if (!prtd->audio_client) { - pr_info("%s: Could not allocate memory\n", __func__); - kfree(prtd); - return -ENOMEM; - } - prtd->audio_client->perf_mode = false; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw = msm_pcm_hardware_playback; - ret = q6asm_open_write(prtd->audio_client, FORMAT_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm out open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - - pr_debug("%s: session ID %d\n", __func__, - prtd->audio_client->session); - prtd->session_id = prtd->audio_client->session; - msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, substream->stream); - prtd->cmd_ack = 1; - - } - /* Capture path */ - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - runtime->hw = msm_pcm_hardware_capture; - } - - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_info("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_info("snd_pcm_hw_constraint_integer failed\n"); - - prtd->dsp_cnt = 0; - runtime->private_data = prtd; - - return 0; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer = 0; - char *bufptr = NULL; - void *data = NULL; - uint32_t idx = 0; - uint32_t size = 0; - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - fbytes = frames_to_bytes(runtime, frames); - pr_debug("%s: prtd->out_count = %d\n", - __func__, atomic_read(&prtd->out_count)); - ret = wait_event_timeout(the_locks.write_wait, - (atomic_read(&prtd->out_count)), 5 * HZ); - if (!ret) { - pr_err("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - - if (!atomic_read(&prtd->out_count)) { - pr_err("%s: pcm stopped out_count 0\n", __func__); - return 0; - } - - data = q6asm_is_cpu_buf_avail(IN, prtd->audio_client, &size, &idx); - bufptr = data; - if (bufptr) { - pr_debug("%s:fbytes =%d: xfer=%d size=%d\n", - __func__, fbytes, xfer, size); - xfer = fbytes; - if (copy_from_user(bufptr, buf, xfer)) { - ret = -EFAULT; - goto fail; - } - buf += xfer; - fbytes -= xfer; - pr_debug("%s:fbytes = %d: xfer=%d\n", __func__, fbytes, xfer); - if (atomic_read(&prtd->start)) { - pr_debug("%s:writing %d bytes of buffer to dsp\n", - __func__, xfer); - ret = q6asm_write(prtd->audio_client, xfer, - 0, 0, NO_TIMESTAMP); - if (ret < 0) { - ret = -EFAULT; - goto fail; - } - } else - atomic_inc(&prtd->out_needed); - atomic_dec(&prtd->out_count); - } -fail: - return ret; -} - -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = runtime->private_data; - int dir = 0; - int ret = 0; - - pr_debug("%s\n", __func__); - - dir = IN; - ret = wait_event_timeout(the_locks.eos_wait, - prtd->cmd_ack, 5 * HZ); - if (!ret) - pr_err("%s: CMD_EOS failed\n", __func__); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_PLAYBACK); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return 0; -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer; - char *bufptr; - void *data = NULL; - static uint32_t idx; - static uint32_t size; - uint32_t offset = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = substream->runtime->private_data; - - - pr_debug("%s\n", __func__); - fbytes = frames_to_bytes(runtime, frames); - - pr_debug("appl_ptr %d\n", (int)runtime->control->appl_ptr); - pr_debug("hw_ptr %d\n", (int)runtime->status->hw_ptr); - pr_debug("avail_min %d\n", (int)runtime->control->avail_min); - - ret = wait_event_timeout(the_locks.read_wait, - (atomic_read(&prtd->in_count)), 5 * HZ); - if (!ret) { - pr_debug("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - if (!atomic_read(&prtd->in_count)) { - pr_debug("%s: pcm stopped in_count 0\n", __func__); - return 0; - } - pr_debug("Checking if valid buffer is available...%08x\n", - (unsigned int) data); - data = q6asm_is_cpu_buf_avail(OUT, prtd->audio_client, &size, &idx); - bufptr = data; - pr_debug("Size = %d\n", size); - pr_debug("fbytes = %d\n", fbytes); - pr_debug("idx = %d\n", idx); - if (bufptr) { - xfer = fbytes; - if (xfer > size) - xfer = size; - offset = in_frame_info[idx][1]; - pr_debug("Offset value = %d\n", offset); - if (copy_to_user(buf, bufptr+offset, xfer)) { - pr_err("Failed to copy buf to user\n"); - ret = -EFAULT; - goto fail; - } - fbytes -= xfer; - size -= xfer; - in_frame_info[idx][1] += xfer; - pr_debug("%s:fbytes = %d: size=%d: xfer=%d\n", - __func__, fbytes, size, xfer); - pr_debug(" Sending next buffer to dsp\n"); - memset(&in_frame_info[idx], 0, - sizeof(uint32_t) * 2); - atomic_dec(&prtd->in_count); - ret = q6asm_read(prtd->audio_client); - if (ret < 0) { - pr_err("q6asm read failed\n"); - ret = -EFAULT; - goto fail; - } - } else - pr_err("No valid buffer\n"); - - pr_debug("Returning from capture_copy... %d\n", ret); -fail: - return ret; -} - -static int msm_pcm_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct msm_audio *prtd = runtime->private_data; - int dir = OUT; - - pr_debug("%s\n", __func__); - if (prtd->audio_client) { - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - q6asm_audio_client_free(prtd->audio_client); - } - - msm_pcm_routing_dereg_phy_stream(soc_prtd->dai_link->be_id, - SNDRV_PCM_STREAM_CAPTURE); - kfree(prtd); - - return 0; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_close(substream); - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - - pr_debug("pcm_irq_pos = %d\n", prtd->pcm_irq_pos); - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - int result = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - prtd->mmap_flag = 1; - - if (runtime->dma_addr && runtime->dma_bytes) { - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); - result = remap_pfn_range(vma, vma->vm_start, - runtime->dma_addr >> PAGE_SHIFT, - runtime->dma_bytes, - vma->vm_page_prot); - } else { - pr_err("Physical address or size of buf is NULL"); - return -EINVAL; - } - - return result; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct snd_soc_pcm_runtime *soc_prtd = substream->private_data; - struct audio_buffer *buf; - int dir, ret; - int format = FORMAT_LINEAR_PCM; - struct msm_pcm_routing_evt event; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dir = IN; - else - dir = OUT; - - /*capture path*/ - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (params_channels(params) > 2) - format = FORMAT_MULTI_CHANNEL_LINEAR_PCM; - pr_debug("%s format = :0x%x\n", __func__, format); - - ret = q6asm_open_read(prtd->audio_client, format); - if (ret < 0) { - pr_err("%s: q6asm_open_read failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - prtd->audio_client = NULL; - return -ENOMEM; - } - - pr_debug("%s: session ID %d\n", __func__, - prtd->audio_client->session); - prtd->session_id = prtd->audio_client->session; - event.event_func = msm_pcm_route_event_handler; - event.priv_data = (void *) prtd; - msm_pcm_routing_reg_phy_stream_v2(soc_prtd->dai_link->be_id, - prtd->audio_client->perf_mode, - prtd->session_id, - substream->stream, event); - } - - ret = q6asm_audio_client_buf_alloc_contiguous(dir, - prtd->audio_client, - runtime->hw.period_bytes_min, - runtime->hw.periods_max); - if (ret < 0) { - pr_err("Audio Start: Buffer Allocation failed \ - rc = %d\n", ret); - return -ENOMEM; - } - buf = prtd->audio_client->port[dir].buf; - if (buf == NULL || buf[0].data == NULL) - return -ENOMEM; - - pr_debug("%s:buf = %p\n", __func__, buf); - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - dma_buf->area = buf[0].data; - dma_buf->addr = buf[0].phys; - dma_buf->bytes = runtime->hw.buffer_bytes_max; - if (!dma_buf->area) - return -ENOMEM; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-pcm-dsp", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - init_waitqueue_head(&the_locks.enable_wait); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-q6.h b/sound/soc/msm/msm-pcm-q6.h deleted file mode 100644 index f9c1a123d1be1aa1fa5d83af094f6b91586d4389..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-q6.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2008-2009,2011 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#ifndef _MSM_PCM_H -#define _MSM_PCM_H -#include -#include - - -/* Support unconventional sample rates 12000, 24000 as well */ -#define USE_RATE \ - (SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT) - -extern int copy_count; - -struct buffer { - void *data; - unsigned size; - unsigned used; - unsigned addr; -}; - -struct buffer_rec { - void *data; - unsigned int size; - unsigned int read; - unsigned int addr; -}; - -struct audio_locks { - spinlock_t event_lock; - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; - wait_queue_head_t eos_wait; - wait_queue_head_t enable_wait; - wait_queue_head_t flush_wait; -}; - -struct msm_audio { - struct snd_pcm_substream *substream; - unsigned int pcm_size; - unsigned int pcm_count; - unsigned int pcm_irq_pos; /* IRQ position */ - uint16_t source; /* Encoding source bit mask */ - - struct audio_client *audio_client; - struct audio_client *enc_audio_client; - - uint16_t session_id; - - uint32_t samp_rate; - uint32_t channel_mode; - uint32_t dsp_cnt; - - int abort; /* set when error, like sample rate mismatch */ - - int enabled; - int close_ack; - int cmd_ack; - atomic_t start; - atomic_t stop; - atomic_t out_count; - atomic_t in_count; - atomic_t out_needed; - atomic_t eos; - int out_head; - int periods; - int mmap_flag; - atomic_t pending_buffer; - bool set_channel_map; - char channel_map[8]; -}; - -struct output_meta_data_st { - uint32_t meta_data_length; - uint32_t frame_size; - uint32_t timestamp_lsw; - uint32_t timestamp_msw; - uint32_t reserved[12]; -}; - -#endif /*_MSM_PCM_H*/ diff --git a/sound/soc/msm/msm-pcm-routing.c b/sound/soc/msm/msm-pcm-routing.c deleted file mode 100644 index 0520b5a5aa1416cec52480f201f1d62a02a35cd2..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-routing.c +++ /dev/null @@ -1,3655 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "qdsp6/q6voice.h" - -struct msm_pcm_routing_bdai_data { - u16 port_id; /* AFE port ID */ - u8 active; /* track if this backend is enabled */ - unsigned long fe_sessions; /* Front-end sessions */ - unsigned long port_sessions; /* track Tx BE ports -> Rx BE */ - unsigned int sample_rate; - unsigned int channel; - bool perf_mode; -}; - -struct msm_pcm_routing_fdai_data { - u16 be_srate; /* track prior backend sample rate for flushing purpose */ - int strm_id; /* ASM stream ID */ - struct msm_pcm_routing_evt event_info; -}; - -#define INVALID_SESSION -1 -#define SESSION_TYPE_RX 0 -#define SESSION_TYPE_TX 1 - -static struct mutex routing_lock; - -static int fm_switch_enable; -static int fm_pcmrx_switch_enable; -static short int srs_alsa_ctrl_ever_called_tm; -static short int srs_alsa_ctrl_ever_called_ss3d; - -#define INT_RX_VOL_MAX_STEPS 0x2000 -#define INT_RX_VOL_GAIN 0x2000 - -static int msm_route_fm_vol_control; -static const DECLARE_TLV_DB_LINEAR(fm_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); - -static int msm_route_lpa_vol_control; -static const DECLARE_TLV_DB_LINEAR(lpa_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); - -static int msm_route_multimedia2_vol_control; -static const DECLARE_TLV_DB_LINEAR(multimedia2_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); - -static int msm_route_multimedia5_vol_control; -static const DECLARE_TLV_DB_LINEAR(multimedia5_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); - -static int msm_route_multimedia3_vol_control; -static const DECLARE_TLV_DB_LINEAR(multimedia3_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); - -static int msm_route_compressed_vol_control; -static const DECLARE_TLV_DB_LINEAR(compressed_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); - -static int msm_route_compressed2_vol_control; -static const DECLARE_TLV_DB_LINEAR(compressed2_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); - -static int msm_route_compressed3_vol_control; -static const DECLARE_TLV_DB_LINEAR(compressed3_rx_vol_gain, 0, - INT_RX_VOL_MAX_STEPS); -static int msm_route_ec_ref_rx; -static int msm_route_ext_ec_ref; - -/* Equal to Frontend after last of the MULTIMEDIA SESSIONS */ -#define MAX_EQ_SESSIONS MSM_FRONTEND_DAI_CS_VOICE - -enum { - EQ_BAND1 = 0, - EQ_BAND2, - EQ_BAND3, - EQ_BAND4, - EQ_BAND5, - EQ_BAND6, - EQ_BAND7, - EQ_BAND8, - EQ_BAND9, - EQ_BAND10, - EQ_BAND11, - EQ_BAND12, - EQ_BAND_MAX, -}; - -struct msm_audio_eq_band { - uint16_t band_idx; /* The band index, 0 .. 11 */ - uint32_t filter_type; /* Filter band type */ - uint32_t center_freq_hz; /* Filter band center frequency */ - uint32_t filter_gain; /* Filter band initial gain (dB) */ - /* Range is +12 dB to -12 dB with 1dB increments. */ - uint32_t q_factor; -} __packed; - -struct msm_audio_eq_stream_config { - uint32_t enable; /* Number of consequtive bands specified */ - uint32_t num_bands; - struct msm_audio_eq_band eq_bands[EQ_BAND_MAX]; -} __packed; - -struct msm_audio_eq_stream_config eq_data[MAX_EQ_SESSIONS]; - -static void msm_send_eq_values(int eq_idx); -/* This array is indexed by back-end DAI ID defined in msm-pcm-routing.h - * If new back-end is defined, add new back-end DAI ID at the end of enum - */ - -union srs_trumedia_params_u { - struct srs_trumedia_params srs_params; - unsigned short int raw_params[1]; -}; -static union srs_trumedia_params_u msm_srs_trumedia_params[2]; - -static void srs_send_params_trumedia(int port_id, unsigned int techs, - int param_block_idx) { - pr_debug("SRS %s: called, port_id = %d, techs flags = %u," - " paramblockidx %d", __func__, port_id, techs, - param_block_idx); - - /* force all if techs is set to 1 */ - if (techs == 1) - techs = 0xFFFFFFFF; - - if (techs & (1 << SRS_ID_WOWHD)) - srs_trumedia_open(port_id, SRS_ID_WOWHD, - (void *)&msm_srs_trumedia_params[param_block_idx].srs_params.wowhd); - if (techs & (1 << SRS_ID_CSHP)) - srs_trumedia_open(port_id, SRS_ID_CSHP, - (void *)&msm_srs_trumedia_params[param_block_idx].srs_params.cshp); - if (techs & (1 << SRS_ID_HPF)) - srs_trumedia_open(port_id, SRS_ID_HPF, - (void *)&msm_srs_trumedia_params[param_block_idx].srs_params.hpf); - if (techs & (1 << SRS_ID_PEQ)) - srs_trumedia_open(port_id, SRS_ID_PEQ, - (void *)&msm_srs_trumedia_params[param_block_idx].srs_params.peq); - if (techs & (1 << SRS_ID_HL)) - srs_trumedia_open(port_id, SRS_ID_HL, - (void *)&msm_srs_trumedia_params[param_block_idx].srs_params.hl); - if (techs & (1 << SRS_ID_GLOBAL)) - srs_trumedia_open(port_id, SRS_ID_GLOBAL, - (void *)&msm_srs_trumedia_params[param_block_idx].srs_params.global); -} - -union srs_SS3D_params_u { - struct srs_SS3D_params srs_params; - unsigned short int raw_params[1]; -}; -static union srs_SS3D_params_u msm_srs_SS3D_params[2]; - -static void srs_send_params_SS3D(int port_id, unsigned int techs, - int param_block_idx) { - pr_debug("SRS %s: called, port_id = %d, techs flags = %u,\n" - " paramblockidx %d", __func__, port_id, techs, - param_block_idx); - - /* force all if techs is set to 1 */ - if (techs == 1) - techs = 0xFFFFFFFF; - - if (techs & (1 << SRS_ID_SS3D_CTRL)) - srs_ss3d_open(port_id, SRS_ID_SS3D_CTRL, - (void *)&msm_srs_SS3D_params[param_block_idx].srs_params.ss3d); - if (techs & (1 << SRS_ID_SS3D_FILTER)) - srs_ss3d_open(port_id, SRS_ID_SS3D_FILTER, - (void *)&msm_srs_SS3D_params[param_block_idx].srs_params.ss3d_f); - if (techs & (1 << SRS_ID_SS3D_GLOBAL)) - srs_ss3d_open(port_id, SRS_ID_SS3D_GLOBAL, - (void *)&msm_srs_SS3D_params[param_block_idx].srs_params.global); - return; -} - -static int srs_port_id = -1; -static void srs_send_params(int port_id, unsigned int techs, - int param_block_id) { - if (srs_alsa_ctrl_ever_called_tm) - srs_send_params_trumedia(port_id, techs, param_block_id); - if (srs_alsa_ctrl_ever_called_ss3d) - srs_send_params_SS3D(port_id, techs, param_block_id); -} - -/* This array is indexed by back-end DAI ID defined in msm-pcm-routing.h - * If new back-end is defined, add new back-end DAI ID at the end of enum - */ -static struct msm_pcm_routing_bdai_data msm_bedais[MSM_BACKEND_DAI_MAX] = { - { PRIMARY_I2S_RX, 0, 0, 0, 0, 0}, - { PRIMARY_I2S_TX, 0, 0, 0, 0, 0}, - { SLIMBUS_0_RX, 0, 0, 0, 0, 0}, - { SLIMBUS_0_TX, 0, 0, 0, 0, 0}, - { HDMI_RX, 0, 0, 0, 0, 0}, - { INT_BT_SCO_RX, 0, 0, 0, 0, 0}, - { INT_BT_SCO_TX, 0, 0, 0, 0, 0}, - { INT_FM_RX, 0, 0, 0, 0, 0}, - { INT_FM_TX, 0, 0, 0, 0, 0}, - { RT_PROXY_PORT_001_RX, 0, 0, 0, 0, 0}, - { RT_PROXY_PORT_001_TX, 0, 0, 0, 0, 0}, - { PCM_RX, 0, 0, 0, 0, 0}, - { PCM_TX, 0, 0, 0, 0, 0}, - { VOICE_PLAYBACK_TX, 0, 0, 0, 0, 0}, - { VOICE_RECORD_RX, 0, 0, 0, 0, 0}, - { VOICE_RECORD_TX, 0, 0, 0, 0, 0}, - { MI2S_RX, 0, 0, 0, 0, 0}, - { MI2S_TX, 0, 0, 0, 0}, - { SECONDARY_I2S_RX, 0, 0, 0, 0, 0}, - { SECONDARY_I2S_TX, 0, 0, 0, 0, 0}, - { SLIMBUS_1_RX, 0, 0, 0, 0, 0}, - { SLIMBUS_1_TX, 0, 0, 0, 0, 0}, - { SLIMBUS_4_RX, 0, 0, 0, 0, 0}, - { SLIMBUS_4_TX, 0, 0, 0, 0, 0}, - { SLIMBUS_3_RX, 0, 0, 0, 0, 0}, - { SLIMBUS_3_TX, 0, 0, 0, 0, 0}, - { SLIMBUS_EXTPROC_RX, 0, 0, 0, 0, 0}, - { SLIMBUS_EXTPROC_RX, 0, 0, 0, 0, 0}, - { SLIMBUS_EXTPROC_RX, 0, 0, 0, 0, 0}, - { SECONDARY_PCM_RX, 0, 0, 0, 0, 0}, - { SECONDARY_PCM_TX, 0, 0, 0, 0, 0}, - { PSEUDOPORT_01, 0, 0, 0, 0, 0}, -}; - - -/* Track ASM playback & capture sessions of DAI */ -static struct msm_pcm_routing_fdai_data - fe_dai_map[MSM_FRONTEND_DAI_MM_SIZE][2] = { - /* MULTIMEDIA1 */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* MULTIMEDIA2 */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* MULTIMEDIA3 */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* MULTIMEDIA4 */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* MULTIMEDIA5 */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* MULTIMEDIA6 */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* MULTIMEDIA7*/ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* MULTIMEDIA8 */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, - /* PSEUDO */ - {{0, INVALID_SESSION, {NULL, NULL} }, - {0, INVALID_SESSION, {NULL, NULL} } }, -}; - -static uint8_t is_be_dai_extproc(int be_dai) -{ - if (be_dai == MSM_BACKEND_DAI_EXTPROC_RX || - be_dai == MSM_BACKEND_DAI_EXTPROC_TX || - be_dai == MSM_BACKEND_DAI_EXTPROC_EC_TX) - return 1; - else - return 0; -} - -static void msm_pcm_routing_build_matrix(int fedai_id, int dspst_id, - int path_type) -{ - int i, port_type; - struct route_payload payload; - - payload.num_copps = 0; - port_type = (path_type == ADM_PATH_PLAYBACK ? - MSM_AFE_PORT_TYPE_RX : MSM_AFE_PORT_TYPE_TX); - - for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { - if (!is_be_dai_extproc(i) && - (afe_get_port_type(msm_bedais[i].port_id) == port_type) && - (msm_bedais[i].active) && - (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) - payload.copp_ids[payload.num_copps++] = - msm_bedais[i].port_id; - } - - if (payload.num_copps) - adm_matrix_map(dspst_id, path_type, - payload.num_copps, payload.copp_ids, 0); -} - -void msm_pcm_routing_reg_psthr_stream(int fedai_id, int dspst_id, - int stream_type, int enable) -{ - int i, session_type, path_type, port_type; - u32 mode = 0; - - if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) { - /* bad ID assigned in machine driver */ - pr_err("%s: bad MM ID\n", __func__); - return; - } - - if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) { - session_type = SESSION_TYPE_RX; - path_type = ADM_PATH_PLAYBACK; - port_type = MSM_AFE_PORT_TYPE_RX; - } else { - session_type = SESSION_TYPE_TX; - path_type = ADM_PATH_LIVE_REC; - port_type = MSM_AFE_PORT_TYPE_TX; - } - - mutex_lock(&routing_lock); - - if (enable) - fe_dai_map[fedai_id][session_type].strm_id = dspst_id; - else - fe_dai_map[fedai_id][session_type].strm_id = INVALID_SESSION; - - for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { - if (!is_be_dai_extproc(i) && - (afe_get_port_type(msm_bedais[i].port_id) == port_type) && - (msm_bedais[i].active) && - (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { - mode = afe_get_port_type(msm_bedais[i].port_id); - if (enable) - adm_connect_afe_port(mode, dspst_id, - msm_bedais[i].port_id); - else - adm_disconnect_afe_port(mode, dspst_id, - msm_bedais[i].port_id); - - break; - } - } - mutex_unlock(&routing_lock); -} - -void msm_pcm_routing_reg_pseudo_stream(int fedai_id, bool perf_mode, - int dspst_id, int stream_type, - int sample_rate, int channels) -{ - int i, session_type, path_type, port_type, mode, ret; - struct route_payload payload; - pr_debug("%s:fedai_id = %d dspst_id = %d stream_type %d", - __func__, fedai_id, dspst_id, stream_type); - - if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) { - session_type = SESSION_TYPE_RX; - path_type = ADM_PATH_PLAYBACK; - port_type = MSM_AFE_PORT_TYPE_RX; - } else { - session_type = SESSION_TYPE_TX; - path_type = ADM_PATH_LIVE_REC; - port_type = MSM_AFE_PORT_TYPE_TX; - } - - mutex_lock(&routing_lock); - - payload.num_copps = 0; - adm_multi_ch_copp_pseudo_open_v3(PSEUDOPORT_01, - path_type, sample_rate, channels, - DEFAULT_COPP_TOPOLOGY); - - payload.copp_ids[payload.num_copps++] = PSEUDOPORT_01; - - for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { - if (test_bit(fedai_id, &msm_bedais[i].fe_sessions)) - msm_bedais[i].perf_mode = perf_mode; - if (!is_be_dai_extproc(i) && - (msm_bedais[i].active) && - (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { - - mode = afe_get_port_type(msm_bedais[i].port_id); - ret = adm_connect_afe_port_v2(mode, dspst_id, - msm_bedais[i].port_id, - msm_bedais[i].sample_rate, - msm_bedais[i].channel); - - if (ret < 0) - pr_err("%s: adm_connect_afe_port_v2 failed\n", - __func__); - } - } - if (payload.num_copps) - adm_matrix_map(dspst_id, path_type, - payload.num_copps, payload.copp_ids, 0); - - mutex_unlock(&routing_lock); -} - -void msm_pcm_routing_reg_phy_stream(int fedai_id, bool perf_mode, int dspst_id, - int stream_type) -{ - int i, session_type, path_type, port_type; - struct route_payload payload; - u32 channels; - - if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) { - /* bad ID assigned in machine driver */ - pr_err("%s: bad MM ID %d\n", __func__, fedai_id); - return; - } - - if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) { - session_type = SESSION_TYPE_RX; - path_type = ADM_PATH_PLAYBACK; - port_type = MSM_AFE_PORT_TYPE_RX; - } else { - session_type = SESSION_TYPE_TX; - path_type = ADM_PATH_LIVE_REC; - port_type = MSM_AFE_PORT_TYPE_TX; - } - - mutex_lock(&routing_lock); - - payload.num_copps = 0; /* only RX needs to use payload */ - fe_dai_map[fedai_id][session_type].strm_id = dspst_id; - /* re-enable EQ if active */ - if (eq_data[fedai_id].enable) - msm_send_eq_values(fedai_id); - for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { - if (test_bit(fedai_id, &msm_bedais[i].fe_sessions)) - msm_bedais[i].perf_mode = perf_mode; - if (!is_be_dai_extproc(i) && - (afe_get_port_type(msm_bedais[i].port_id) == port_type) && - (msm_bedais[i].active) && - (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { - - channels = msm_bedais[i].channel; - - if ((stream_type == SNDRV_PCM_STREAM_PLAYBACK) && - ((channels == 1) || (channels == 2)) && - msm_bedais[i].perf_mode) { - pr_debug("%s configure COPP to lowlatency mode", - __func__); - adm_multi_ch_copp_open(msm_bedais[i].port_id, - path_type, - msm_bedais[i].sample_rate, - msm_bedais[i].channel, - DEFAULT_COPP_TOPOLOGY, msm_bedais[i].perf_mode); - } else if ((stream_type == SNDRV_PCM_STREAM_PLAYBACK) && - (channels > 2)) - adm_multi_ch_copp_open(msm_bedais[i].port_id, - path_type, - msm_bedais[i].sample_rate, - msm_bedais[i].channel, - DEFAULT_COPP_TOPOLOGY, msm_bedais[i].perf_mode); - else - adm_open(msm_bedais[i].port_id, - path_type, - msm_bedais[i].sample_rate, - msm_bedais[i].channel, - DEFAULT_COPP_TOPOLOGY); - - payload.copp_ids[payload.num_copps++] = - msm_bedais[i].port_id; - srs_port_id = msm_bedais[i].port_id; - srs_send_params(srs_port_id, 1, 0); - } - } - if (payload.num_copps) - adm_matrix_map(dspst_id, path_type, - payload.num_copps, payload.copp_ids, 0); - - mutex_unlock(&routing_lock); -} -void msm_pcm_routing_reg_phy_stream_v2(int fedai_id, bool perf_mode, - int dspst_id, int stream_type, - struct msm_pcm_routing_evt event_info) -{ - msm_pcm_routing_reg_phy_stream(fedai_id, perf_mode, dspst_id, - stream_type); - - if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) - fe_dai_map[fedai_id][SESSION_TYPE_RX].event_info = event_info; - else - fe_dai_map[fedai_id][SESSION_TYPE_TX].event_info = event_info; - -} - -void msm_pcm_routing_dereg_pseudo_stream(int fedai_id, int dspst_id) -{ - int i, mode, ret; - pr_debug("%s:fedai_id = %d dspst_id = %d", - __func__, fedai_id, dspst_id); - - mutex_lock(&routing_lock); - - for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { - if (!is_be_dai_extproc(i) && - (msm_bedais[i].active) && - (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { - - mode = afe_get_port_type(msm_bedais[i].port_id); - ret = adm_disconnect_afe_port(mode, dspst_id, - msm_bedais[i].port_id); - if (ret < 0) - pr_err("%s: adm_connect_afe_port_v2 failed\n", - __func__); - } - } - - mutex_unlock(&routing_lock); - -} -void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type) -{ - int i, port_type, session_type; - - if (fedai_id > MSM_FRONTEND_DAI_MM_MAX_ID) { - /* bad ID assigned in machine driver */ - pr_err("%s: bad MM ID\n", __func__); - return; - } - - if (stream_type == SNDRV_PCM_STREAM_PLAYBACK) { - port_type = MSM_AFE_PORT_TYPE_RX; - session_type = SESSION_TYPE_RX; - } else { - port_type = MSM_AFE_PORT_TYPE_TX; - session_type = SESSION_TYPE_TX; - } - - mutex_lock(&routing_lock); - - for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { - if (!is_be_dai_extproc(i) && - (afe_get_port_type(msm_bedais[i].port_id) == port_type) && - (msm_bedais[i].active) && - (test_bit(fedai_id, &msm_bedais[i].fe_sessions))) { - if (msm_bedais[i].port_id == PSEUDOPORT_01) - adm_pseudo_close(msm_bedais[i].port_id); - else - adm_close(msm_bedais[i].port_id); - } - } - - fe_dai_map[fedai_id][session_type].strm_id = INVALID_SESSION; - fe_dai_map[fedai_id][session_type].be_srate = 0; - mutex_unlock(&routing_lock); -} - -/* Check if FE/BE route is set */ -static bool msm_pcm_routing_route_is_set(u16 be_id, u16 fe_id) -{ - bool rc = false; - - if (fe_id > MSM_FRONTEND_DAI_MM_MAX_ID) { - /* recheck FE ID in the mixer control defined in this file */ - pr_err("%s: bad MM ID\n", __func__); - return rc; - } - - if (test_bit(fe_id, &msm_bedais[be_id].fe_sessions)) - rc = true; - - return rc; -} - -static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) -{ - int session_type, path_type; - u32 channels; - struct msm_pcm_routing_fdai_data *fdai; - - pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set); - - if (val > MSM_FRONTEND_DAI_MM_MAX_ID) { - /* recheck FE ID in the mixer control defined in this file */ - pr_err("%s: bad MM ID\n", __func__); - return; - } - - if (afe_get_port_type(msm_bedais[reg].port_id) == - MSM_AFE_PORT_TYPE_RX) { - session_type = SESSION_TYPE_RX; - path_type = ADM_PATH_PLAYBACK; - } else { - session_type = SESSION_TYPE_TX; - path_type = ADM_PATH_LIVE_REC; - } - - mutex_lock(&routing_lock); - - if (set) { - if (!test_bit(val, &msm_bedais[reg].fe_sessions) && - (msm_bedais[reg].port_id == VOICE_PLAYBACK_TX)) - voc_start_playback(set); - - set_bit(val, &msm_bedais[reg].fe_sessions); - fdai = &fe_dai_map[val][session_type]; - if (msm_bedais[reg].active && fdai->strm_id != - INVALID_SESSION) { - - channels = msm_bedais[reg].channel; - - if (session_type == SESSION_TYPE_TX && fdai->be_srate && - (fdai->be_srate != msm_bedais[reg].sample_rate)) { - pr_debug("%s: flush strm %d due diff BE rates\n", - __func__, fdai->strm_id); - - if (fdai->event_info.event_func) - fdai->event_info.event_func( - MSM_PCM_RT_EVT_BUF_RECFG, - fdai->event_info.priv_data); - fdai->be_srate = 0; /* might not need it */ - } - - if ((session_type == SESSION_TYPE_RX) && - ((channels == 1) || (channels == 2)) - && msm_bedais[reg].perf_mode) { - adm_multi_ch_copp_open(msm_bedais[reg].port_id, - path_type, - msm_bedais[reg].sample_rate, - channels, - DEFAULT_COPP_TOPOLOGY, - msm_bedais[reg].perf_mode); - pr_debug("%s:configure COPP to lowlatency mode", - __func__); - } else if ((session_type == SESSION_TYPE_RX) - && (channels > 2)) - adm_multi_ch_copp_open(msm_bedais[reg].port_id, - path_type, - msm_bedais[reg].sample_rate, - channels, - DEFAULT_COPP_TOPOLOGY, - msm_bedais[reg].perf_mode); - else - adm_open(msm_bedais[reg].port_id, - path_type, - msm_bedais[reg].sample_rate, channels, - DEFAULT_COPP_TOPOLOGY); - - if (session_type == SESSION_TYPE_RX && - fdai->event_info.event_func) - fdai->event_info.event_func( - MSM_PCM_RT_EVT_DEVSWITCH, - fdai->event_info.priv_data); - - msm_pcm_routing_build_matrix(val, - fdai->strm_id, path_type); - srs_port_id = msm_bedais[reg].port_id; - srs_send_params(srs_port_id, 1, 0); - } - } else { - if (test_bit(val, &msm_bedais[reg].fe_sessions) && - (msm_bedais[reg].port_id == VOICE_PLAYBACK_TX)) - voc_start_playback(set); - clear_bit(val, &msm_bedais[reg].fe_sessions); - fdai = &fe_dai_map[val][session_type]; - if (msm_bedais[reg].active && fdai->strm_id != - INVALID_SESSION) { - fdai->be_srate = msm_bedais[reg].sample_rate; - adm_close(msm_bedais[reg].port_id); - msm_pcm_routing_build_matrix(val, - fdai->strm_id, path_type); - } - } - if ((msm_bedais[reg].port_id == VOICE_RECORD_RX) - || (msm_bedais[reg].port_id == VOICE_RECORD_TX)) - voc_start_record(msm_bedais[reg].port_id, set); - - mutex_unlock(&routing_lock); -} - -static int msm_routing_get_audio_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions)) - ucontrol->value.integer.value[0] = 1; - else - ucontrol->value.integer.value[0] = 0; - - pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, - ucontrol->value.integer.value[0]); - - return 0; -} - -static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - - if (ucontrol->value.integer.value[0] && - msm_pcm_routing_route_is_set(mc->reg, mc->shift) == false) { - msm_pcm_routing_process_audio(mc->reg, mc->shift, 1); - snd_soc_dapm_mixer_update_power(widget, kcontrol, 1); - } else if (!ucontrol->value.integer.value[0] && - msm_pcm_routing_route_is_set(mc->reg, mc->shift) == true) { - msm_pcm_routing_process_audio(mc->reg, mc->shift, 0); - snd_soc_dapm_mixer_update_power(widget, kcontrol, 0); - } - - return 1; -} - -static void msm_pcm_routing_process_voice(u16 reg, u16 val, int set) -{ - u16 session_id = 0; - - pr_debug("%s: reg %x val %x set %x\n", __func__, reg, val, set); - - if (val == MSM_FRONTEND_DAI_CS_VOICE) - session_id = voc_get_session_id(VOICE_SESSION_NAME); - else if (val == MSM_FRONTEND_DAI_VOLTE) - session_id = voc_get_session_id(VOLTE_SESSION_NAME); - else if (val == MSM_FRONTEND_DAI_VOICE2) - session_id = voc_get_session_id(VOICE2_SESSION_NAME); - else - session_id = voc_get_session_id(VOIP_SESSION_NAME); - - pr_debug("%s: FE DAI 0x%x session_id 0x%x\n", - __func__, val, session_id); - - mutex_lock(&routing_lock); - - if (set) - set_bit(val, &msm_bedais[reg].fe_sessions); - else - clear_bit(val, &msm_bedais[reg].fe_sessions); - - if (val == MSM_FRONTEND_DAI_DTMF_RX && - afe_get_port_type(msm_bedais[reg].port_id) == - MSM_AFE_PORT_TYPE_RX) { - pr_debug("%s(): set=%d port id=0x%x for dtmf generation\n", - __func__, set, msm_bedais[reg].port_id); - afe_set_dtmf_gen_rx_portid(msm_bedais[reg].port_id, set); - } - - mutex_unlock(&routing_lock); - - if (afe_get_port_type(msm_bedais[reg].port_id) == - MSM_AFE_PORT_TYPE_RX) { - voc_set_route_flag(session_id, RX_PATH, set); - if (set) { - voc_set_rxtx_port(session_id, - msm_bedais[reg].port_id, DEV_RX); - - if (voc_get_route_flag(session_id, RX_PATH) && - voc_get_route_flag(session_id, TX_PATH)) - voc_enable_cvp(session_id); - } else { - voc_disable_cvp(session_id); - } - } else { - voc_set_route_flag(session_id, TX_PATH, set); - if (set) { - voc_set_rxtx_port(session_id, - msm_bedais[reg].port_id, DEV_TX); - if (voc_get_route_flag(session_id, RX_PATH) && - voc_get_route_flag(session_id, TX_PATH)) - voc_enable_cvp(session_id); - } else { - voc_disable_cvp(session_id); - } - } -} - -static int msm_routing_get_voice_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - mutex_lock(&routing_lock); - - if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions)) - ucontrol->value.integer.value[0] = 1; - else - ucontrol->value.integer.value[0] = 0; - - mutex_unlock(&routing_lock); - - pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, - ucontrol->value.integer.value[0]); - - return 0; -} - -static int msm_routing_put_voice_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - if (ucontrol->value.integer.value[0]) { - msm_pcm_routing_process_voice(mc->reg, mc->shift, 1); - snd_soc_dapm_mixer_update_power(widget, kcontrol, 1); - } else { - msm_pcm_routing_process_voice(mc->reg, mc->shift, 0); - snd_soc_dapm_mixer_update_power(widget, kcontrol, 0); - } - - return 1; -} - -static int msm_routing_get_voice_stub_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - mutex_lock(&routing_lock); - - if (test_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions)) - ucontrol->value.integer.value[0] = 1; - else - ucontrol->value.integer.value[0] = 0; - - mutex_unlock(&routing_lock); - - pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, - ucontrol->value.integer.value[0]); - - return 0; -} - -static int msm_routing_put_voice_stub_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - if (ucontrol->value.integer.value[0]) { - mutex_lock(&routing_lock); - set_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions); - mutex_unlock(&routing_lock); - - snd_soc_dapm_mixer_update_power(widget, kcontrol, 1); - } else { - mutex_lock(&routing_lock); - clear_bit(mc->shift, &msm_bedais[mc->reg].fe_sessions); - mutex_unlock(&routing_lock); - - snd_soc_dapm_mixer_update_power(widget, kcontrol, 0); - } - - pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, - ucontrol->value.integer.value[0]); - - return 1; -} - -static int msm_routing_get_switch_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = fm_switch_enable; - pr_debug("%s: FM Switch enable %ld\n", __func__, - ucontrol->value.integer.value[0]); - return 0; -} - -static int msm_routing_put_switch_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - - pr_debug("%s: FM Switch enable %ld\n", __func__, - ucontrol->value.integer.value[0]); - if (ucontrol->value.integer.value[0]) - snd_soc_dapm_mixer_update_power(widget, kcontrol, 1); - else - snd_soc_dapm_mixer_update_power(widget, kcontrol, 0); - fm_switch_enable = ucontrol->value.integer.value[0]; - return 1; -} - -static int msm_routing_get_fm_pcmrx_switch_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = fm_pcmrx_switch_enable; - pr_debug("%s: FM Switch enable %ld\n", __func__, - ucontrol->value.integer.value[0]); - return 0; -} - -static int msm_routing_put_fm_pcmrx_switch_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - - pr_debug("%s: FM Switch enable %ld\n", __func__, - ucontrol->value.integer.value[0]); - if (ucontrol->value.integer.value[0]) - snd_soc_dapm_mixer_update_power(widget, kcontrol, 1); - else - snd_soc_dapm_mixer_update_power(widget, kcontrol, 0); - fm_pcmrx_switch_enable = ucontrol->value.integer.value[0]; - return 1; -} - -static int msm_routing_get_port_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - if (test_bit(mc->shift, &msm_bedais[mc->reg].port_sessions)) - ucontrol->value.integer.value[0] = 1; - else - ucontrol->value.integer.value[0] = 0; - - pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, mc->shift, - ucontrol->value.integer.value[0]); - - return 0; -} - -static int msm_routing_put_port_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - - pr_debug("%s: reg %x shift %x val %ld\n", __func__, mc->reg, - mc->shift, ucontrol->value.integer.value[0]); - - if (ucontrol->value.integer.value[0]) { - afe_loopback(1, msm_bedais[mc->reg].port_id, - msm_bedais[mc->shift].port_id); - set_bit(mc->shift, - &msm_bedais[mc->reg].port_sessions); - } else { - afe_loopback(0, msm_bedais[mc->reg].port_id, - msm_bedais[mc->shift].port_id); - clear_bit(mc->shift, - &msm_bedais[mc->reg].port_sessions); - } - - return 1; -} - -static int msm_routing_get_fm_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm_route_fm_vol_control; - return 0; -} - -static int msm_routing_set_fm_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - afe_loopback_gain(INT_FM_TX, ucontrol->value.integer.value[0]); - msm_route_fm_vol_control = ucontrol->value.integer.value[0]; - return 0; -} - -static int msm_routing_get_lpa_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm_route_lpa_vol_control; - return 0; -} - -static int msm_routing_set_lpa_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - if (!lpa_set_volume(ucontrol->value.integer.value[0])) - msm_route_lpa_vol_control = - ucontrol->value.integer.value[0]; - - return 0; -} - -static int msm_routing_get_multimedia2_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - ucontrol->value.integer.value[0] = msm_route_multimedia2_vol_control; - return 0; -} - -static int msm_routing_set_multimedia2_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - if (!multi_ch_pcm_set_volume(ucontrol->value.integer.value[0])) - msm_route_multimedia2_vol_control = - ucontrol->value.integer.value[0]; - - return 0; -} - -static int msm_routing_get_multimedia5_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - ucontrol->value.integer.value[0] = msm_route_multimedia5_vol_control; - return 0; -} - -static int msm_routing_set_multimedia5_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - if (!multi_ch_pcm_set_volume(ucontrol->value.integer.value[0])) - msm_route_multimedia5_vol_control = - ucontrol->value.integer.value[0]; - - return 0; -} - -static int msm_routing_get_multimedia3_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm_route_multimedia3_vol_control; - return 0; -} - -static int msm_routing_set_multimedia3_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - if (!multi_ch_pcm_set_volume(ucontrol->value.integer.value[0])) - msm_route_multimedia3_vol_control = - ucontrol->value.integer.value[0]; - - return 0; -} - -static int msm_routing_get_compressed_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - ucontrol->value.integer.value[0] = msm_route_compressed_vol_control; - return 0; -} - -static int msm_routing_set_compressed_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - if (!compressed_set_volume(ucontrol->value.integer.value[0])) - msm_route_compressed_vol_control = - ucontrol->value.integer.value[0]; - - return 0; -} - -static int msm_routing_get_compressed2_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm_route_compressed2_vol_control; - return 0; -} - -static int msm_routing_set_compressed2_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - if (!compressed_set_volume(ucontrol->value.integer.value[0])) - msm_route_compressed2_vol_control = - ucontrol->value.integer.value[0]; - return 0; -} - -static int msm_routing_get_compressed3_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm_route_compressed3_vol_control; - return 0; -} - -static int msm_routing_set_compressed3_vol_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - if (!compressed_set_volume(ucontrol->value.integer.value[0])) - msm_route_compressed3_vol_control = - ucontrol->value.integer.value[0]; - return 0; -} - -static int msm_routing_get_srs_trumedia_control(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_routing_set_srs_trumedia_control_(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - unsigned int techs = 0; - unsigned short offset, value, max, index; - - srs_alsa_ctrl_ever_called_tm = 1; - - max = sizeof(msm_srs_trumedia_params) >> 1; - index = (unsigned short)((ucontrol->value.integer.value[0] & - SRS_PARAM_INDEX_MASK) >> 31); - if (SRS_CMD_UPLOAD == - (ucontrol->value.integer.value[0] & SRS_CMD_UPLOAD)) { - techs = ucontrol->value.integer.value[0] & 0xFF; - pr_debug("SRS %s: send params request, flags = %u", - __func__, techs); - if (srs_port_id >= 0 && techs) - srs_send_params_trumedia(srs_port_id, techs, index); - return 0; - } - offset = (unsigned short)((ucontrol->value.integer.value[0] & - SRS_PARAM_OFFSET_MASK) >> 16); - value = (unsigned short)(ucontrol->value.integer.value[0] & - SRS_PARAM_VALUE_MASK); - if (offset < max) { - msm_srs_trumedia_params[index].raw_params[offset] = value; - } else { - pr_err("SRS %s: index out of bounds! (max %d, requested %d)", - __func__, max, offset); - } - return 0; -} - -static int msm_routing_set_srs_trumedia_control(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) { - int ret; - - mutex_lock(&routing_lock); - srs_port_id = SLIMBUS_0_RX; - ret = msm_routing_set_srs_trumedia_control_(kcontrol, ucontrol); - mutex_unlock(&routing_lock); - return ret; -} - -static int msm_routing_set_srs_trumedia_control_I2S( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) { - int ret; - - mutex_lock(&routing_lock); - srs_port_id = PRIMARY_I2S_RX; - ret = msm_routing_set_srs_trumedia_control_(kcontrol, ucontrol); - mutex_unlock(&routing_lock); - return ret; -} - -static int msm_routing_set_srs_trumedia_control_HDMI( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) { - int ret; - - mutex_lock(&routing_lock); - srs_port_id = HDMI_RX; - ret = msm_routing_set_srs_trumedia_control_(kcontrol, ucontrol); - mutex_unlock(&routing_lock); - return ret; -} - -static int msm_routing_get_srs_SS3D_control(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - - -static int msm_routing_set_srs_SS3D_control_(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - unsigned int techs = 0; - unsigned short offset, value, max, index; - - srs_alsa_ctrl_ever_called_ss3d = 1; - - max = sizeof(msm_srs_SS3D_params) >> 1; - index = (unsigned short)((ucontrol->value.integer.value[0] & - SRS_PARAM_INDEX_MASK) >> 31); - if (SRS_CMD_UPLOAD == - (ucontrol->value.integer.value[0] & SRS_CMD_UPLOAD)) { - techs = ucontrol->value.integer.value[0] & 0xFF; - pr_debug("SRS %s: send params request, flags = %u", __func__, - techs); - if (srs_port_id >= 0 && techs) - srs_send_params_SS3D(srs_port_id, techs, index); - return 0; - } - - offset = (unsigned short)((ucontrol->value.integer.value[0] & - SRS_PARAM_OFFSET_MASK) >> 16); - value = (unsigned short)(ucontrol->value.integer.value[0] & - SRS_PARAM_VALUE_MASK); - if (offset < max) { - msm_srs_SS3D_params[index].raw_params[offset] = value; - } else { - pr_err("SRS %s: index out of bounds! (max %d, requested %d)", - __func__, max, offset); - } - return 0; -} - -static int msm_routing_set_srs_SS3D_control(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) { - int ret; - - mutex_lock(&routing_lock); - srs_port_id = SLIMBUS_0_RX; - ret = msm_routing_set_srs_SS3D_control_(kcontrol, ucontrol); - mutex_unlock(&routing_lock); - return ret; -} - -static int msm_routing_set_srs_SS3D_control_I2S( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) { - int ret; - - mutex_lock(&routing_lock); - srs_port_id = PRIMARY_I2S_RX; - ret = msm_routing_set_srs_SS3D_control_(kcontrol, ucontrol); - mutex_unlock(&routing_lock); - return ret; -} - -static int msm_routing_set_srs_SS3D_control_HDMI( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) { - int ret; - - mutex_lock(&routing_lock); - srs_port_id = HDMI_RX; - ret = msm_routing_set_srs_SS3D_control_(kcontrol, ucontrol); - mutex_unlock(&routing_lock); - return ret; -} - -static void msm_send_eq_values(int eq_idx) -{ - int result; - struct audio_client *ac = q6asm_get_audio_client( - fe_dai_map[eq_idx][SESSION_TYPE_RX].strm_id); - - if (ac == NULL) { - pr_err("%s: Could not get audio client for session: %d\n", - __func__, fe_dai_map[eq_idx][SESSION_TYPE_RX].strm_id); - goto done; - } - - result = q6asm_equalizer(ac, &eq_data[eq_idx]); - - if (result < 0) - pr_err("%s: Call to ASM equalizer failed, returned = %d\n", - __func__, result); -done: - return; -} - -static int msm_routing_get_eq_enable_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int eq_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - - ucontrol->value.integer.value[0] = eq_data[eq_idx].enable; - - pr_debug("%s: EQ #%d enable %d\n", __func__, - eq_idx, eq_data[eq_idx].enable); - return 0; -} - -static int msm_routing_put_eq_enable_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int eq_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int value = ucontrol->value.integer.value[0]; - - pr_debug("%s: EQ #%d enable %d\n", __func__, - eq_idx, value); - eq_data[eq_idx].enable = value; - - msm_send_eq_values(eq_idx); - return 0; -} - -static int msm_routing_get_eq_band_count_audio_mixer( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int eq_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - - ucontrol->value.integer.value[0] = eq_data[eq_idx].num_bands; - - pr_debug("%s: EQ #%d bands %d\n", __func__, - eq_idx, eq_data[eq_idx].num_bands); - return eq_data[eq_idx].num_bands; -} - -static int msm_routing_put_eq_band_count_audio_mixer( - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int eq_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int value = ucontrol->value.integer.value[0]; - - pr_debug("%s: EQ #%d bands %d\n", __func__, - eq_idx, value); - eq_data[eq_idx].num_bands = value; - return 0; -} - -static int msm_routing_get_eq_band_audio_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int eq_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int band_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - - ucontrol->value.integer.value[0] = - eq_data[eq_idx].eq_bands[band_idx].band_idx; - ucontrol->value.integer.value[1] = - eq_data[eq_idx].eq_bands[band_idx].filter_type; - ucontrol->value.integer.value[2] = - eq_data[eq_idx].eq_bands[band_idx].center_freq_hz; - ucontrol->value.integer.value[3] = - eq_data[eq_idx].eq_bands[band_idx].filter_gain; - ucontrol->value.integer.value[4] = - eq_data[eq_idx].eq_bands[band_idx].q_factor; - - pr_debug("%s: band_idx = %d\n", __func__, - eq_data[eq_idx].eq_bands[band_idx].band_idx); - pr_debug("%s: filter_type = %d\n", __func__, - eq_data[eq_idx].eq_bands[band_idx].filter_type); - pr_debug("%s: center_freq_hz = %d\n", __func__, - eq_data[eq_idx].eq_bands[band_idx].center_freq_hz); - pr_debug("%s: filter_gain = %d\n", __func__, - eq_data[eq_idx].eq_bands[band_idx].filter_gain); - pr_debug("%s: q_factor = %d\n", __func__, - eq_data[eq_idx].eq_bands[band_idx].q_factor); - return 0; -} - -static int msm_routing_put_eq_band_audio_mixer(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int eq_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->reg; - int band_idx = ((struct soc_multi_mixer_control *) - kcontrol->private_value)->shift; - - eq_data[eq_idx].eq_bands[band_idx].band_idx = - ucontrol->value.integer.value[0]; - eq_data[eq_idx].eq_bands[band_idx].filter_type = - ucontrol->value.integer.value[1]; - eq_data[eq_idx].eq_bands[band_idx].center_freq_hz = - ucontrol->value.integer.value[2]; - eq_data[eq_idx].eq_bands[band_idx].filter_gain = - ucontrol->value.integer.value[3]; - eq_data[eq_idx].eq_bands[band_idx].q_factor = - ucontrol->value.integer.value[4]; - return 0; -} - -static int msm_routing_ec_ref_rx_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: ec_ref_rx = %d", __func__, msm_route_ec_ref_rx); - ucontrol->value.integer.value[0] = msm_route_ec_ref_rx; - return 0; -} - -static int msm_routing_ec_ref_rx_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 0: - msm_route_ec_ref_rx = SLIMBUS_0_RX; - break; - case 1: - msm_route_ec_ref_rx = PRIMARY_I2S_RX; - break; - default: - msm_route_ec_ref_rx = 0; - break; - } - adm_ec_ref_rx_id(msm_route_ec_ref_rx); - pr_debug("%s: msm_route_ec_ref_rx = %d\n", - __func__, msm_route_ec_ref_rx); - return 0; -} - -static const char * const ec_ref_rx[] = {"SLIM_RX", "I2S_RX", "PROXY_RX", - "NONE"}; -static const struct soc_enum msm_route_ec_ref_rx_enum[] = { - SOC_ENUM_SINGLE_EXT(4, ec_ref_rx), -}; - -static const struct snd_kcontrol_new ec_ref_rx_mixer_controls[] = { - SOC_ENUM_EXT("EC_REF_RX", msm_route_ec_ref_rx_enum[0], - msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put), -}; - -static int msm_routing_ext_ec_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: ext_ec_ref_rx = %x\n", __func__, msm_route_ext_ec_ref); - - mutex_lock(&routing_lock); - ucontrol->value.integer.value[0] = msm_route_ext_ec_ref; - mutex_unlock(&routing_lock); - return 0; -} - -static int msm_routing_ext_ec_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - int mux = ucontrol->value.enumerated.item[0]; - struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - int ret = 0; - - pr_debug("%s: msm_route_ec_ref_rx = %d value = %ld\n", - __func__, msm_route_ext_ec_ref, - ucontrol->value.integer.value[0]); - - mutex_lock(&routing_lock); - switch (ucontrol->value.integer.value[0]) { - case 1: - msm_route_ext_ec_ref = MI2S_TX; - ret = voc_set_ext_ec_ref(msm_route_ext_ec_ref, true); - break; - default: - msm_route_ext_ec_ref = AFE_PORT_INVALID; - ret = voc_set_ext_ec_ref(msm_route_ext_ec_ref, false); - break; - } - mutex_unlock(&routing_lock); - snd_soc_dapm_mux_update_power(widget, kcontrol, 1, mux, e); - return ret; -} - -static const char * const ext_ec_ref_rx[] = {"NONE", "MI2S_TX"}; - -static const struct soc_enum msm_route_ext_ec_ref_rx_enum[] = { - SOC_ENUM_SINGLE_EXT(2, ext_ec_ref_rx), -}; - -static const struct snd_kcontrol_new voc_ext_ec_mux = - SOC_DAPM_ENUM_EXT("VOC_EXT_EC MUX Mux", msm_route_ext_ec_ref_rx_enum[0], - msm_routing_ext_ec_get, msm_routing_ext_ec_put); - - -static const struct snd_kcontrol_new pri_i2s_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_I2S_RX , - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new sec_i2s_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_I2S_RX , - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("Pseudo", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_PSEUDO, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new slimbus_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_0_RX , - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new mi2s_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_MI2S_RX , - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new hdmi_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia7", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia8", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("Pseudo", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_PSEUDO, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; -static const struct snd_kcontrol_new pseudo_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_PSEUDO_PORT, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_PSEUDO_PORT, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - /* incall music delivery mixer */ -static const struct snd_kcontrol_new incall_music_delivery_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new slimbus_4_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SLIMBUS_4_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SLIMBUS_4_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new int_bt_sco_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new int_fm_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_INT_FM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_INT_FM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_INT_FM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_INT_FM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_INT_FM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new afe_pcm_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new auxpcm_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia4", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia5", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia6", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new sec_auxpcm_rx_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2", MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new mmul1_mixer_controls[] = { - SOC_SINGLE_EXT("PRI_TX", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("SEC_TX", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("SEC_AUX_PCM_UL_TX", MSM_BACKEND_DAI_SEC_AUXPCM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("SLIM_4_TX", MSM_BACKEND_DAI_SLIMBUS_4_TX, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new mmul2_mixer_controls[] = { - SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new mmul5_mixer_controls[] = { - SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("AUX_PCM_TX", MSM_BACKEND_DAI_AUXPCM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - - -static const struct snd_kcontrol_new mmul4_mixer_controls[] = { - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("VOC_REC_DL", MSM_BACKEND_DAI_INCALL_RECORD_RX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), - SOC_SINGLE_EXT("VOC_REC_UL", MSM_BACKEND_DAI_INCALL_RECORD_TX, - MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new mmul6_mixer_controls[] = { - SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_INT_FM_TX, - MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer, - msm_routing_put_audio_mixer), -}; - -static const struct snd_kcontrol_new pri_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new sec_i2s_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new slimbus_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SLIMBUS_0_RX , - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SLIMBUS_0_RX , - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SLIMBUS_0_RX , - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SLIMBUS_0_RX , - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new bt_sco_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_INT_BT_SCO_RX , - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_INT_BT_SCO_RX , - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_INT_BT_SCO_RX , - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_INT_BT_SCO_RX , - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new mi2s_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_MI2S_RX, - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new afe_pcm_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new aux_pcm_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new sec_aux_pcm_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new hdmi_rx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("CSVoice", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voip", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("VoLTE", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("DTMF", MSM_BACKEND_DAI_HDMI_RX, - MSM_FRONTEND_DAI_DTMF_RX, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new stub_rx_mixer_controls[] = { - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_EXTPROC_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_EXTPROC_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_EXTPROC_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), -}; - -static const struct snd_kcontrol_new slimbus_1_rx_mixer_controls[] = { - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_1_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_1_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_1_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), -}; - -static const struct snd_kcontrol_new slimbus_3_rx_mixer_controls[] = { - SOC_SINGLE_EXT("Voice Stub", MSM_BACKEND_DAI_SLIMBUS_3_RX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("VoLTE Stub", MSM_BACKEND_DAI_SLIMBUS_3_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("Voice2 Stub", MSM_BACKEND_DAI_SLIMBUS_3_RX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), -}; - -static const struct snd_kcontrol_new tx_voice_mixer_controls[] = { - SOC_SINGLE_EXT("PRI_TX_Voice", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_TX_Voice", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("MI2S_TX_Voice", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SLIM_0_TX_Voice", MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_Voice", - MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_CS_VOICE, 1, 0, - msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX_Voice", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AUX_PCM_TX_Voice", MSM_BACKEND_DAI_AUXPCM_TX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_AUX_PCM_TX_Voice", MSM_BACKEND_DAI_SEC_AUXPCM_TX, - MSM_FRONTEND_DAI_CS_VOICE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new tx_volte_mixer_controls[] = { - SOC_SINGLE_EXT("PRI_TX_VoLTE", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_TX_VoLTE", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SLIM_0_TX_VoLTE", MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_VoLTE", - MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_VOLTE, 1, 0, - msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX_VoLTE", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AUX_PCM_TX_VoLTE", MSM_BACKEND_DAI_AUXPCM_TX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_AUX_PCM_TX_VoLTE", MSM_BACKEND_DAI_SEC_AUXPCM_TX, - MSM_FRONTEND_DAI_VOLTE, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new tx_voice2_mixer_controls[] = { - SOC_SINGLE_EXT("PRI_TX_Voice2", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_TX_Voice2", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("MI2S_TX_Voice2", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SLIM_0_TX_Voice2", MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_Voice2", - MSM_BACKEND_DAI_INT_BT_SCO_TX, MSM_FRONTEND_DAI_VOICE2, 1, 0, - msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX_Voice2", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AUX_PCM_TX_Voice2", MSM_BACKEND_DAI_AUXPCM_TX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_AUX_PCM_TX_Voice2", MSM_BACKEND_DAI_SEC_AUXPCM_TX, - MSM_FRONTEND_DAI_VOICE2, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; -static const struct snd_kcontrol_new tx_voip_mixer_controls[] = { - SOC_SINGLE_EXT("PRI_TX_Voip", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_TX_Voip", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("MI2S_TX_Voip", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SLIM_0_TX_Voip", MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX_Voip", MSM_BACKEND_DAI_INT_BT_SCO_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX_Voip", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("AUX_PCM_TX_Voip", MSM_BACKEND_DAI_AUXPCM_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), - SOC_SINGLE_EXT("SEC_AUX_PCM_TX_Voip", MSM_BACKEND_DAI_SEC_AUXPCM_TX, - MSM_FRONTEND_DAI_VOIP, 1, 0, msm_routing_get_voice_mixer, - msm_routing_put_voice_mixer), -}; - -static const struct snd_kcontrol_new tx_voice_stub_mixer_controls[] = { - SOC_SINGLE_EXT("STUB_TX_HL", MSM_BACKEND_DAI_EXTPROC_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("STUB_1_TX_HL", MSM_BACKEND_DAI_EXTPROC_EC_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SLIM_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("PRIMARY_I2S_TX", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SECONDARY_I2S_TX", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_VOICE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), -}; - -static const struct snd_kcontrol_new tx_volte_stub_mixer_controls[] = { - SOC_SINGLE_EXT("STUB_TX_HL", MSM_BACKEND_DAI_EXTPROC_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("STUB_1_TX_HL", MSM_BACKEND_DAI_EXTPROC_EC_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SLIM_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("PRIMARY_I2S_TX", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SECONDARY_I2S_TX", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_VOLTE_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), -}; - -static const struct snd_kcontrol_new tx_voice2_stub_mixer_controls[] = { - SOC_SINGLE_EXT("STUB_TX_HL", MSM_BACKEND_DAI_EXTPROC_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_INT_BT_SCO_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_SLIMBUS_1_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("STUB_1_TX_HL", MSM_BACKEND_DAI_EXTPROC_EC_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_MI2S_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SLIM_3_TX", MSM_BACKEND_DAI_SLIMBUS_3_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("PRIMARY_I2S_TX", MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("SECONDARY_I2S_TX", MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_FRONTEND_DAI_VOICE2_STUB, 1, 0, msm_routing_get_voice_stub_mixer, - msm_routing_put_voice_stub_mixer), -}; - -static const struct snd_kcontrol_new sbus_0_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - -static const struct snd_kcontrol_new auxpcm_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("AUX_PCM_UL_TX", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_BACKEND_DAI_AUXPCM_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("SLIM_0_TX", MSM_BACKEND_DAI_AUXPCM_RX, - MSM_BACKEND_DAI_SLIMBUS_0_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - -static const struct snd_kcontrol_new sbus_1_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("INTERNAL_BT_SCO_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX, - MSM_BACKEND_DAI_INT_BT_SCO_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("AFE_PCM_TX", MSM_BACKEND_DAI_SLIMBUS_1_RX, - MSM_BACKEND_DAI_AFE_PCM_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - -static const struct snd_kcontrol_new sbus_3_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("INTERNAL_BT_SCO_RX", MSM_BACKEND_DAI_SLIMBUS_3_RX, - MSM_BACKEND_DAI_INT_BT_SCO_RX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_SLIMBUS_3_RX, - MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("AFE_PCM_RX", MSM_BACKEND_DAI_SLIMBUS_3_RX, - MSM_BACKEND_DAI_AFE_PCM_RX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; -static const struct snd_kcontrol_new bt_sco_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - -static const struct snd_kcontrol_new afe_pcm_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("INTERNAL_FM_TX", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_BACKEND_DAI_INT_FM_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - - -static const struct snd_kcontrol_new hdmi_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_HDMI_RX, - MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("SLIM_3_TX", MSM_BACKEND_DAI_HDMI_RX, - MSM_BACKEND_DAI_SLIMBUS_3_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - -static const struct snd_kcontrol_new pri_i2s_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_PRI_I2S_RX, - MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - -}; - -static const struct snd_kcontrol_new sec_i2s_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("MI2S_TX", MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_BACKEND_DAI_MI2S_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - -static const struct snd_kcontrol_new mi2s_rx_port_mixer_controls[] = { - SOC_SINGLE_EXT("SLIM_1_TX", MSM_BACKEND_DAI_MI2S_RX, - MSM_BACKEND_DAI_SLIMBUS_1_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), - SOC_SINGLE_EXT("PRIMARY_I2S_TX", MSM_BACKEND_DAI_MI2S_RX, - MSM_BACKEND_DAI_PRI_I2S_TX, 1, 0, msm_routing_get_port_mixer, - msm_routing_put_port_mixer), -}; - -static const struct snd_kcontrol_new fm_switch_mixer_controls = - SOC_SINGLE_EXT("Switch", SND_SOC_NOPM, - 0, 1, 0, msm_routing_get_switch_mixer, - msm_routing_put_switch_mixer); - -static const struct snd_kcontrol_new pcm_rx_switch_mixer_controls = - SOC_SINGLE_EXT("Switch", SND_SOC_NOPM, - 0, 1, 0, msm_routing_get_fm_pcmrx_switch_mixer, - msm_routing_put_fm_pcmrx_switch_mixer); - -static const struct snd_kcontrol_new int_fm_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("Internal FM RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_fm_vol_mixer, - msm_routing_set_fm_vol_mixer, fm_rx_vol_gain), -}; - -static const struct snd_kcontrol_new lpa_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("LPA RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_lpa_vol_mixer, - msm_routing_set_lpa_vol_mixer, lpa_rx_vol_gain), -}; - -static const struct snd_kcontrol_new multimedia2_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("HIFI2 RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_multimedia2_vol_mixer, - msm_routing_set_multimedia2_vol_mixer, multimedia2_rx_vol_gain), -}; - -static const struct snd_kcontrol_new multimedia5_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("HIFI3 RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_multimedia5_vol_mixer, - msm_routing_set_multimedia5_vol_mixer, multimedia5_rx_vol_gain), -}; - -static const struct snd_kcontrol_new multimedia3_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("HIFI4 RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_multimedia3_vol_mixer, - msm_routing_set_multimedia3_vol_mixer, multimedia3_rx_vol_gain), -}; - -static const struct snd_kcontrol_new compressed_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("COMPRESSED RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_compressed_vol_mixer, - msm_routing_set_compressed_vol_mixer, compressed_rx_vol_gain), -}; - -static const struct snd_kcontrol_new compressed2_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("COMPRESSED2 RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_compressed2_vol_mixer, - msm_routing_set_compressed2_vol_mixer, compressed2_rx_vol_gain), -}; - -static const struct snd_kcontrol_new compressed3_vol_mixer_controls[] = { - SOC_SINGLE_EXT_TLV("COMPRESSED3 RX Volume", SND_SOC_NOPM, 0, - INT_RX_VOL_GAIN, 0, msm_routing_get_compressed3_vol_mixer, - msm_routing_set_compressed3_vol_mixer, compressed3_rx_vol_gain), -}; - -static const struct snd_kcontrol_new lpa_SRS_trumedia_controls[] = { - {.iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SRS TruMedia", - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | - SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = snd_soc_info_volsw, \ - .get = msm_routing_get_srs_trumedia_control, - .put = msm_routing_set_srs_trumedia_control, - .private_value = ((unsigned long)&(struct soc_mixer_control) - {.reg = SND_SOC_NOPM, - .rreg = SND_SOC_NOPM, - .shift = 0, - .rshift = 0, - .max = 0xFFFFFFFF, - .platform_max = 0xFFFFFFFF, - .invert = 0 - }) - } -}; - -static const struct snd_kcontrol_new lpa_SRS_trumedia_controls_HDMI[] = { - {.iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SRS TruMedia HDMI", - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | - SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = snd_soc_info_volsw, \ - .get = msm_routing_get_srs_trumedia_control, - .put = msm_routing_set_srs_trumedia_control_HDMI, - .private_value = ((unsigned long)&(struct soc_mixer_control) - {.reg = SND_SOC_NOPM, - .rreg = SND_SOC_NOPM, - .shift = 0, - .rshift = 0, - .max = 0xFFFFFFFF, - .platform_max = 0xFFFFFFFF, - .invert = 0 - }) - } -}; - -static const struct snd_kcontrol_new lpa_SRS_trumedia_controls_I2S[] = { - {.iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SRS TruMedia I2S", - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | - SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = snd_soc_info_volsw, \ - .get = msm_routing_get_srs_trumedia_control, - .put = msm_routing_set_srs_trumedia_control_I2S, - .private_value = ((unsigned long)&(struct soc_mixer_control) - {.reg = SND_SOC_NOPM, - .rreg = SND_SOC_NOPM, - .shift = 0, - .rshift = 0, - .max = 0xFFFFFFFF, - .platform_max = 0xFFFFFFFF, - .invert = 0 - }) - } -}; - -static const struct snd_kcontrol_new lpa_SRS_SS3D_controls[] = { - {.iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SRS SS3D", - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | - SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = snd_soc_info_volsw, \ - .get = msm_routing_get_srs_SS3D_control, - .put = msm_routing_set_srs_SS3D_control, - .private_value = ((unsigned long)&(struct soc_mixer_control) - {.reg = SND_SOC_NOPM, - .rreg = SND_SOC_NOPM, - .shift = 0, - .rshift = 0, - .max = 0xFFFFFFFF, - .platform_max = 0xFFFFFFFF, - .invert = 0 - }) - } -}; - -static const struct snd_kcontrol_new lpa_SRS_SS3D_controls_HDMI[] = { - {.iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SRS SS3D HDMI", - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | - SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = snd_soc_info_volsw, \ - .get = msm_routing_get_srs_SS3D_control, - .put = msm_routing_set_srs_SS3D_control_HDMI, - .private_value = ((unsigned long)&(struct soc_mixer_control) - {.reg = SND_SOC_NOPM, - .rreg = SND_SOC_NOPM, - .shift = 0, - .rshift = 0, - .max = 0xFFFFFFFF, - .platform_max = 0xFFFFFFFF, - .invert = 0 - }) - } -}; - -static const struct snd_kcontrol_new lpa_SRS_SS3D_controls_I2S[] = { - {.iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SRS SS3D I2S", - .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | - SNDRV_CTL_ELEM_ACCESS_READWRITE, - .info = snd_soc_info_volsw, \ - .get = msm_routing_get_srs_SS3D_control, - .put = msm_routing_set_srs_SS3D_control_I2S, - .private_value = ((unsigned long)&(struct soc_mixer_control) - {.reg = SND_SOC_NOPM, - .rreg = SND_SOC_NOPM, - .shift = 0, - .rshift = 0, - .max = 0xFFFFFFFF, - .platform_max = 0xFFFFFFFF, - .invert = 0 - }) - } -}; - -static const struct snd_kcontrol_new eq_enable_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1 EQ Enable", SND_SOC_NOPM, - MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_eq_enable_mixer, - msm_routing_put_eq_enable_mixer), - SOC_SINGLE_EXT("MultiMedia2 EQ Enable", SND_SOC_NOPM, - MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_eq_enable_mixer, - msm_routing_put_eq_enable_mixer), - SOC_SINGLE_EXT("MultiMedia3 EQ Enable", SND_SOC_NOPM, - MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_eq_enable_mixer, - msm_routing_put_eq_enable_mixer), -}; - -static const struct snd_kcontrol_new eq_band_mixer_controls[] = { - SOC_SINGLE_EXT("MultiMedia1 EQ Band Count", SND_SOC_NOPM, - MSM_FRONTEND_DAI_MULTIMEDIA1, 11, 0, - msm_routing_get_eq_band_count_audio_mixer, - msm_routing_put_eq_band_count_audio_mixer), - SOC_SINGLE_EXT("MultiMedia2 EQ Band Count", SND_SOC_NOPM, - MSM_FRONTEND_DAI_MULTIMEDIA2, 11, 0, - msm_routing_get_eq_band_count_audio_mixer, - msm_routing_put_eq_band_count_audio_mixer), - SOC_SINGLE_EXT("MultiMedia3 EQ Band Count", SND_SOC_NOPM, - MSM_FRONTEND_DAI_MULTIMEDIA3, 11, 0, - msm_routing_get_eq_band_count_audio_mixer, - msm_routing_put_eq_band_count_audio_mixer), -}; - -static const struct snd_kcontrol_new eq_coeff_mixer_controls[] = { - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band1", EQ_BAND1, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band2", EQ_BAND2, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band3", EQ_BAND3, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band4", EQ_BAND4, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band5", EQ_BAND5, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band6", EQ_BAND6, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band7", EQ_BAND7, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band8", EQ_BAND8, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band9", EQ_BAND9, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band10", EQ_BAND10, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band11", EQ_BAND11, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band12", EQ_BAND12, - MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band1", EQ_BAND1, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band2", EQ_BAND2, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band3", EQ_BAND3, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band4", EQ_BAND4, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band5", EQ_BAND5, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band6", EQ_BAND6, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band7", EQ_BAND7, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band8", EQ_BAND8, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band9", EQ_BAND9, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band10", EQ_BAND10, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band11", EQ_BAND11, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band12", EQ_BAND12, - MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band1", EQ_BAND1, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band2", EQ_BAND2, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band3", EQ_BAND3, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band4", EQ_BAND4, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band5", EQ_BAND5, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band6", EQ_BAND6, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band7", EQ_BAND7, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band8", EQ_BAND8, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band9", EQ_BAND9, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band10", EQ_BAND10, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band11", EQ_BAND11, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), - SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band12", EQ_BAND12, - MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, - msm_routing_get_eq_band_audio_mixer, - msm_routing_put_eq_band_audio_mixer), -}; - -static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = { - /* Frontend AIF */ - /* Widget name equals to Front-End DAI name, - * Stream name must contains substring of front-end dai name - */ - SND_SOC_DAPM_AIF_IN("MM_DL1", "MultiMedia1 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL2", "MultiMedia2 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL3", "MultiMedia3 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL4", "MultiMedia4 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL5", "MultiMedia5 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL6", "MultiMedia6 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL7", "MultiMedia7 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL8", "MultiMedia8 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MM_DL9", "Pseudo Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("VOIP_DL", "VoIP Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("MM_UL1", "MultiMedia1 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("MM_UL2", "MultiMedia2 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("MM_UL4", "MultiMedia4 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("MM_UL5", "MultiMedia5 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("MM_UL6", "MultiMedia6 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("CS-VOICE_DL1", "CS-VOICE Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("CS-VOICE_UL1", "CS-VOICE Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("VoLTE_DL", "VoLTE Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("VoLTE_UL", "VoLTE Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("VOICE2_DL", "Voice2 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("VOICE2_UL", "Voice2 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("VOIP_UL", "VoIP Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SLIM0_DL_HL", "SLIMBUS0_HOSTLESS Playback", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("SLIM0_UL_HL", "SLIMBUS0_HOSTLESS Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("INTFM_DL_HL", "INT_FM_HOSTLESS Playback", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("INTFM_UL_HL", "INT_FM_HOSTLESS Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("HDMI_DL_HL", "HDMI_HOSTLESS Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SEC_I2S_DL_HL", "SEC_I2S_RX_HOSTLESS Playback", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("AUXPCM_DL_HL", "AUXPCM_HOSTLESS Playback", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("AUXPCM_UL_HL", "AUXPCM_HOSTLESS Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("MI2S_UL_HL", "MI2S_TX_HOSTLESS Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("DTMF_DL_HL", "DTMF_RX_HOSTLESS Playback", - 0, 0, 0, 0), - - /* Backend AIF */ - /* Stream name equals to backend dai link stream name - */ - SND_SOC_DAPM_AIF_OUT("PRI_I2S_RX", "Primary I2S Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("SEC_I2S_RX", "Secondary I2S Playback", - 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_OUT("SLIMBUS_0_RX", "Slimbus Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("HDMI", "HDMI Playback", 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_OUT("PSEUDO", "PSEUDO Playback", 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_OUT("MI2S_RX", "MI2S Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("PRI_I2S_TX", "Primary I2S Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SEC_I2S_TX", "Secondary I2S Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("MI2S_TX", "MI2S Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SLIMBUS_0_TX", "Slimbus Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("INT_BT_SCO_RX", "Internal BT-SCO Playback", - 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_IN("INT_BT_SCO_TX", "Internal BT-SCO Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("INT_FM_RX", "Internal FM Playback", - 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_IN("INT_FM_TX", "Internal FM Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("PCM_RX", "AFE Playback", - 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_IN("PCM_TX", "AFE Capture", - 0, 0, 0 , 0), - /* incall */ - SND_SOC_DAPM_AIF_OUT("VOICE_PLAYBACK_TX", "Voice Farend Playback", - 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_OUT("SLIMBUS_4_RX", "Slimbus4 Playback", - 0, 0, 0 , 0), - SND_SOC_DAPM_AIF_IN("INCALL_RECORD_TX", "Voice Uplink Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("INCALL_RECORD_RX", "Voice Downlink Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SLIMBUS_4_TX", "Slimbus4 Capture", - 0, 0, 0, 0), - - SND_SOC_DAPM_AIF_OUT("AUX_PCM_RX", "AUX PCM Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("AUX_PCM_TX", "AUX PCM Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("SEC_AUX_PCM_RX", "SEC AUX PCM Playback", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SEC_AUX_PCM_TX", "SEC AUX PCM Capture", - 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("VOICE_STUB_DL", "VOICE_STUB Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("VOICE_STUB_UL", "VOICE_STUB Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("VOLTE_STUB_DL", "VOLTE_STUB Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("VOLTE_STUB_UL", "VOLTE_STUB Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("VOICE2_STUB_DL", - "VOICE2_STUB Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("VOICE2_STUB_UL", - "VOICE2_STUB Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("STUB_RX", "Stub Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("STUB_TX", "Stub Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("SLIMBUS_1_RX", "Slimbus1 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SLIMBUS_1_TX", "Slimbus1 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("STUB_1_TX", "Stub1 Capture", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_OUT("SLIMBUS_3_RX", "Slimbus3 Playback", 0, 0, 0, 0), - SND_SOC_DAPM_AIF_IN("SLIMBUS_3_TX", "Slimbus3 Capture", 0, 0, 0, 0), - - /* Switch Definitions */ - SND_SOC_DAPM_SWITCH("SLIMBUS_DL_HL", SND_SOC_NOPM, 0, 0, - &fm_switch_mixer_controls), - SND_SOC_DAPM_SWITCH("PCM_RX_DL_HL", SND_SOC_NOPM, 0, 0, - &pcm_rx_switch_mixer_controls), - /* Mixer definitions */ - SND_SOC_DAPM_MIXER("PRI_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - pri_i2s_rx_mixer_controls, ARRAY_SIZE(pri_i2s_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("SEC_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - sec_i2s_rx_mixer_controls, ARRAY_SIZE(sec_i2s_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - slimbus_rx_mixer_controls, ARRAY_SIZE(slimbus_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("HDMI Mixer", SND_SOC_NOPM, 0, 0, - hdmi_mixer_controls, ARRAY_SIZE(hdmi_mixer_controls)), - SND_SOC_DAPM_MIXER("PSEUDO Mixer", SND_SOC_NOPM, 0, 0, - pseudo_mixer_controls, ARRAY_SIZE(pseudo_mixer_controls)), - SND_SOC_DAPM_MIXER("MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - mi2s_rx_mixer_controls, ARRAY_SIZE(mi2s_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("MultiMedia1 Mixer", SND_SOC_NOPM, 0, 0, - mmul1_mixer_controls, ARRAY_SIZE(mmul1_mixer_controls)), - SND_SOC_DAPM_MIXER("MultiMedia2 Mixer", SND_SOC_NOPM, 0, 0, - mmul2_mixer_controls, ARRAY_SIZE(mmul2_mixer_controls)), - SND_SOC_DAPM_MIXER("MultiMedia4 Mixer", SND_SOC_NOPM, 0, 0, - mmul4_mixer_controls, ARRAY_SIZE(mmul4_mixer_controls)), - SND_SOC_DAPM_MIXER("MultiMedia5 Mixer", SND_SOC_NOPM, 0, 0, - mmul5_mixer_controls, ARRAY_SIZE(mmul5_mixer_controls)), - SND_SOC_DAPM_MIXER("MultiMedia6 Mixer", SND_SOC_NOPM, 0, 0, - mmul6_mixer_controls, ARRAY_SIZE(mmul6_mixer_controls)), - SND_SOC_DAPM_MIXER("AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - auxpcm_rx_mixer_controls, ARRAY_SIZE(auxpcm_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("SEC_AUX_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - sec_auxpcm_rx_mixer_controls, ARRAY_SIZE(sec_auxpcm_rx_mixer_controls)), - /* incall */ - SND_SOC_DAPM_MIXER("Incall_Music Audio Mixer", SND_SOC_NOPM, 0, 0, - incall_music_delivery_mixer_controls, - ARRAY_SIZE(incall_music_delivery_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIMBUS_4_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - slimbus_4_rx_mixer_controls, - ARRAY_SIZE(slimbus_4_rx_mixer_controls)), - /* Voice Mixer */ - SND_SOC_DAPM_MIXER("PRI_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, pri_rx_voice_mixer_controls, - ARRAY_SIZE(pri_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("SEC_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - sec_i2s_rx_voice_mixer_controls, - ARRAY_SIZE(sec_i2s_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIM_0_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - slimbus_rx_voice_mixer_controls, - ARRAY_SIZE(slimbus_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - bt_sco_rx_voice_mixer_controls, - ARRAY_SIZE(bt_sco_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("AFE_PCM_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - afe_pcm_rx_voice_mixer_controls, - ARRAY_SIZE(afe_pcm_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("AUX_PCM_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - aux_pcm_rx_voice_mixer_controls, - ARRAY_SIZE(aux_pcm_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("SEC_AUX_PCM_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - sec_aux_pcm_rx_voice_mixer_controls, - ARRAY_SIZE(sec_aux_pcm_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("HDMI_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - hdmi_rx_voice_mixer_controls, - ARRAY_SIZE(hdmi_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("MI2S_RX_Voice Mixer", - SND_SOC_NOPM, 0, 0, - mi2s_rx_voice_mixer_controls, - ARRAY_SIZE(mi2s_rx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("Voice_Tx Mixer", - SND_SOC_NOPM, 0, 0, tx_voice_mixer_controls, - ARRAY_SIZE(tx_voice_mixer_controls)), - SND_SOC_DAPM_MIXER("Voip_Tx Mixer", - SND_SOC_NOPM, 0, 0, tx_voip_mixer_controls, - ARRAY_SIZE(tx_voip_mixer_controls)), - SND_SOC_DAPM_MIXER("VoLTE_Tx Mixer", - SND_SOC_NOPM, 0, 0, tx_volte_mixer_controls, - ARRAY_SIZE(tx_volte_mixer_controls)), - SND_SOC_DAPM_MIXER("Voice2_Tx Mixer", - SND_SOC_NOPM, 0, 0, tx_voice2_mixer_controls, - ARRAY_SIZE(tx_voice2_mixer_controls)), - SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - int_bt_sco_rx_mixer_controls, ARRAY_SIZE(int_bt_sco_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("INTERNAL_FM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - int_fm_rx_mixer_controls, ARRAY_SIZE(int_fm_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("AFE_PCM_RX Audio Mixer", SND_SOC_NOPM, 0, 0, - afe_pcm_rx_mixer_controls, ARRAY_SIZE(afe_pcm_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("Voice Stub Tx Mixer", SND_SOC_NOPM, 0, 0, - tx_voice_stub_mixer_controls, ARRAY_SIZE(tx_voice_stub_mixer_controls)), - SND_SOC_DAPM_MIXER("STUB_RX Mixer", SND_SOC_NOPM, 0, 0, - stub_rx_mixer_controls, ARRAY_SIZE(stub_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Mixer", SND_SOC_NOPM, 0, 0, - slimbus_1_rx_mixer_controls, ARRAY_SIZE(slimbus_1_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIMBUS_3_RX_Voice Mixer", SND_SOC_NOPM, 0, 0, - slimbus_3_rx_mixer_controls, ARRAY_SIZE(slimbus_3_rx_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Port Mixer", - SND_SOC_NOPM, 0, 0, sbus_0_rx_port_mixer_controls, - ARRAY_SIZE(sbus_0_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("AUXPCM_RX Port Mixer", - SND_SOC_NOPM, 0, 0, auxpcm_rx_port_mixer_controls, - ARRAY_SIZE(auxpcm_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Port Mixer", SND_SOC_NOPM, 0, 0, - sbus_1_rx_port_mixer_controls, - ARRAY_SIZE(sbus_1_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("INTERNAL_BT_SCO_RX Port Mixer", SND_SOC_NOPM, 0, 0, - bt_sco_rx_port_mixer_controls, - ARRAY_SIZE(bt_sco_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("AFE_PCM_RX Port Mixer", - SND_SOC_NOPM, 0, 0, afe_pcm_rx_port_mixer_controls, - ARRAY_SIZE(afe_pcm_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("HDMI_RX Port Mixer", - SND_SOC_NOPM, 0, 0, hdmi_rx_port_mixer_controls, - ARRAY_SIZE(hdmi_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("PRI_I2S_RX Port Mixer", - SND_SOC_NOPM, 0, 0, pri_i2s_rx_port_mixer_controls, - ARRAY_SIZE(pri_i2s_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("SEC_I2S_RX Port Mixer", - SND_SOC_NOPM, 0, 0, sec_i2s_rx_port_mixer_controls, - ARRAY_SIZE(sec_i2s_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("SLIMBUS_3_RX Port Mixer", - SND_SOC_NOPM, 0, 0, sbus_3_rx_port_mixer_controls, - ARRAY_SIZE(sbus_3_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("MI2S_RX Port Mixer", SND_SOC_NOPM, 0, 0, - mi2s_rx_port_mixer_controls, ARRAY_SIZE(mi2s_rx_port_mixer_controls)), - SND_SOC_DAPM_MIXER("VoLTE Stub Tx Mixer", SND_SOC_NOPM, 0, 0, - tx_volte_stub_mixer_controls, - ARRAY_SIZE(tx_volte_stub_mixer_controls)), - SND_SOC_DAPM_MIXER("Voice2 Stub Tx Mixer", SND_SOC_NOPM, 0, 0, - tx_voice2_stub_mixer_controls, - ARRAY_SIZE(tx_voice2_stub_mixer_controls)), - /* Virtual Pins to force backends ON atm */ - SND_SOC_DAPM_OUTPUT("BE_OUT"), - SND_SOC_DAPM_INPUT("BE_IN"), - SND_SOC_DAPM_MUX("VOC_EXT_EC MUX", SND_SOC_NOPM, 0, 0, &voc_ext_ec_mux), - -}; - -static const struct snd_soc_dapm_route intercon[] = { - {"PRI_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"PRI_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"PRI_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"PRI_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"PRI_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"PRI_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, - {"PRI_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, - {"PRI_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, - {"PRI_I2S_RX", NULL, "PRI_RX Audio Mixer"}, - - {"SEC_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"SEC_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"SEC_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"SEC_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"SEC_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"SEC_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, - {"SEC_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, - {"SEC_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, - {"SEC_RX Audio Mixer", "Pseudo", "MM_DL9"}, - {"SEC_I2S_RX", NULL, "SEC_RX Audio Mixer"}, - - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia7", "MM_DL7"}, - {"SLIMBUS_0_RX Audio Mixer", "MultiMedia8", "MM_DL8"}, - {"SLIMBUS_0_RX", NULL, "SLIMBUS_0_RX Audio Mixer"}, - - {"HDMI Mixer", "MultiMedia1", "MM_DL1"}, - {"HDMI Mixer", "MultiMedia2", "MM_DL2"}, - {"HDMI Mixer", "MultiMedia3", "MM_DL3"}, - {"HDMI Mixer", "MultiMedia4", "MM_DL4"}, - {"HDMI Mixer", "MultiMedia5", "MM_DL5"}, - {"HDMI Mixer", "MultiMedia6", "MM_DL6"}, - {"HDMI Mixer", "MultiMedia7", "MM_DL7"}, - {"HDMI Mixer", "MultiMedia8", "MM_DL8"}, - {"HDMI Mixer", "Pseudo", "MM_DL9"}, - {"HDMI", NULL, "HDMI Mixer"}, - - {"PSEUDO Mixer", "MultiMedia4", "MM_DL4"}, - {"PSEUDO", NULL, "PSEUDO Mixer"}, - - /* incall */ - {"Incall_Music Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"Incall_Music Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"VOICE_PLAYBACK_TX", NULL, "Incall_Music Audio Mixer"}, - {"SLIMBUS_4_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"SLIMBUS_4_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"SLIMBUS_4_RX", NULL, "SLIMBUS_4_RX Audio Mixer"}, - - {"MultiMedia1 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, - {"MultiMedia1 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, - {"MultiMedia4 Mixer", "VOC_REC_UL", "INCALL_RECORD_TX"}, - {"MultiMedia4 Mixer", "VOC_REC_DL", "INCALL_RECORD_RX"}, - {"MultiMedia1 Mixer", "SLIM_4_TX", "SLIMBUS_4_TX"}, - {"MultiMedia5 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, - {"MI2S_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"MI2S_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"MI2S_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"MI2S_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"MI2S_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"MI2S_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, - {"MI2S_RX", NULL, "MI2S_RX Audio Mixer"}, - - {"MultiMedia1 Mixer", "PRI_TX", "PRI_I2S_TX"}, - {"MultiMedia1 Mixer", "SEC_TX", "SEC_I2S_TX"}, - {"MultiMedia1 Mixer", "MI2S_TX", "MI2S_TX"}, - {"MultiMedia2 Mixer", "MI2S_TX", "MI2S_TX"}, - {"MultiMedia4 Mixer", "MI2S_TX", "MI2S_TX"}, - {"MultiMedia4 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, - {"MultiMedia1 Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, - {"MultiMedia1 Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, - {"MultiMedia5 Mixer", "AUX_PCM_TX", "AUX_PCM_TX"}, - {"MultiMedia1 Mixer", "SEC_AUX_PCM_UL_TX", "SEC_AUX_PCM_TX"}, - - {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"INTERNAL_BT_SCO_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, - {"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX Audio Mixer"}, - - {"INTERNAL_FM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"INTERNAL_FM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"INTERNAL_FM_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"INTERNAL_FM_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"INTERNAL_FM_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"INT_FM_RX", NULL, "INTERNAL_FM_RX Audio Mixer"}, - - {"AFE_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"AFE_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"AFE_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"AFE_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"AFE_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"AFE_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, - {"PCM_RX", NULL, "AFE_PCM_RX Audio Mixer"}, - - {"MultiMedia1 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, - {"MultiMedia5 Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, - {"MultiMedia1 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, - {"MultiMedia5 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, - {"MultiMedia6 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, - - {"MultiMedia1 Mixer", "AFE_PCM_TX", "PCM_TX"}, - {"MultiMedia5 Mixer", "AFE_PCM_TX", "PCM_TX"}, - {"MM_UL1", NULL, "MultiMedia1 Mixer"}, - {"MultiMedia2 Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, - {"MM_UL2", NULL, "MultiMedia2 Mixer"}, - {"MM_UL4", NULL, "MultiMedia4 Mixer"}, - {"MM_UL5", NULL, "MultiMedia5 Mixer"}, - {"MM_UL6", NULL, "MultiMedia6 Mixer"}, - - {"AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"AUX_PCM_RX Audio Mixer", "MultiMedia3", "MM_DL3"}, - {"AUX_PCM_RX Audio Mixer", "MultiMedia4", "MM_DL4"}, - {"AUX_PCM_RX Audio Mixer", "MultiMedia5", "MM_DL5"}, - {"AUX_PCM_RX Audio Mixer", "MultiMedia6", "MM_DL6"}, - {"AUX_PCM_RX", NULL, "AUX_PCM_RX Audio Mixer"}, - - {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia1", "MM_DL1"}, - {"SEC_AUX_PCM_RX Audio Mixer", "MultiMedia2", "MM_DL2"}, - {"SEC_AUX_PCM_RX", NULL, "SEC_AUX_PCM_RX Audio Mixer"}, - - {"PRI_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"PRI_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"PRI_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"PRI_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"PRI_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"PRI_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"PRI_I2S_RX", NULL, "PRI_RX_Voice Mixer"}, - - {"SEC_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"SEC_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"SEC_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"SEC_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"SEC_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"SEC_I2S_RX", NULL, "SEC_RX_Voice Mixer"}, - - {"SLIM_0_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"SLIM_0_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"SLIM_0_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"SLIM_0_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"SLIM_0_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"SLIMBUS_0_RX", NULL, "SLIM_0_RX_Voice Mixer"}, - - {"INTERNAL_BT_SCO_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"INTERNAL_BT_SCO_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"INTERNAL_BT_SCO_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"INTERNAL_BT_SCO_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"INTERNAL_BT_SCO_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX_Voice Mixer"}, - - {"AFE_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"AFE_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"AFE_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"AFE_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"AFE_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"PCM_RX", NULL, "AFE_PCM_RX_Voice Mixer"}, - - {"AUX_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"AUX_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"AUX_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"AUX_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"AUX_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"AUX_PCM_RX", NULL, "AUX_PCM_RX_Voice Mixer"}, - - {"SEC_AUX_PCM_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"SEC_AUX_PCM_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"SEC_AUX_PCM_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"SEC_AUX_PCM_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"SEC_AUX_PCM_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"SEC_AUX_PCM_RX", NULL, "SEC_AUX_PCM_RX_Voice Mixer"}, - - {"HDMI_RX_Voice Mixer", "CSVoice", "CS-VOICE_DL1"}, - {"HDMI_RX_Voice Mixer", "VoLTE", "VoLTE_DL"}, - {"HDMI_RX_Voice Mixer", "Voice2", "VOICE2_DL"}, - {"HDMI_RX_Voice Mixer", "Voip", "VOIP_DL"}, - {"HDMI_RX_Voice Mixer", "DTMF", "DTMF_DL_HL"}, - {"HDMI", NULL, "HDMI_RX_Voice Mixer"}, - {"HDMI", NULL, "HDMI_DL_HL"}, - - {"VOC_EXT_EC MUX", "MI2S_TX" , "MI2S_TX"}, - {"CS-VOICE_UL1", NULL, "VOC_EXT_EC MUX"}, - {"Voice_Tx Mixer", "PRI_TX_Voice", "PRI_I2S_TX"}, - {"Voice_Tx Mixer", "SEC_TX_Voice", "SEC_I2S_TX"}, - {"Voice_Tx Mixer", "MI2S_TX_Voice", "MI2S_TX"}, - {"Voice_Tx Mixer", "SLIM_0_TX_Voice", "SLIMBUS_0_TX"}, - {"Voice_Tx Mixer", "INTERNAL_BT_SCO_TX_Voice", "INT_BT_SCO_TX"}, - {"Voice_Tx Mixer", "AFE_PCM_TX_Voice", "PCM_TX"}, - {"Voice_Tx Mixer", "AUX_PCM_TX_Voice", "AUX_PCM_TX"}, - {"Voice_Tx Mixer", "SEC_AUX_PCM_TX_Voice", "SEC_AUX_PCM_TX"}, - {"CS-VOICE_UL1", NULL, "Voice_Tx Mixer"}, - {"VoLTE_Tx Mixer", "PRI_TX_VoLTE", "PRI_I2S_TX"}, - {"VoLTE_Tx Mixer", "SEC_TX_VoLTE", "SEC_I2S_TX"}, - {"VoLTE_Tx Mixer", "SLIM_0_TX_VoLTE", "SLIMBUS_0_TX"}, - {"VoLTE_Tx Mixer", "INTERNAL_BT_SCO_TX_VoLTE", "INT_BT_SCO_TX"}, - {"VoLTE_Tx Mixer", "AFE_PCM_TX_VoLTE", "PCM_TX"}, - {"VoLTE_Tx Mixer", "AUX_PCM_TX_VoLTE", "AUX_PCM_TX"}, - {"VoLTE_Tx Mixer", "SEC_AUX_PCM_TX_VoLTE", "SEC_AUX_PCM_TX"}, - {"VoLTE_UL", NULL, "VoLTE_Tx Mixer"}, - {"Voice2_Tx Mixer", "PRI_TX_Voice2", "PRI_I2S_TX"}, - {"Voice2_Tx Mixer", "SEC_TX_Voice2", "SEC_I2S_TX"}, - {"Voice2_Tx Mixer", "MI2S_TX_Voice2", "MI2S_TX"}, - {"Voice2_Tx Mixer", "SLIM_0_TX_Voice2", "SLIMBUS_0_TX"}, - {"Voice2_Tx Mixer", "INTERNAL_BT_SCO_TX_Voice2", "INT_BT_SCO_TX"}, - {"Voice2_Tx Mixer", "AFE_PCM_TX_Voice2", "PCM_TX"}, - {"Voice2_Tx Mixer", "AUX_PCM_TX_Voice2", "AUX_PCM_TX"}, - {"Voice2_Tx Mixer", "SEC_AUX_PCM_TX_Voice2", "SEC_AUX_PCM_TX"}, - {"VOICE2_UL", NULL, "Voice2_Tx Mixer"}, - {"Voip_Tx Mixer", "PRI_TX_Voip", "PRI_I2S_TX"}, - {"Voip_Tx Mixer", "SEC_TX_Voip", "SEC_I2S_TX"}, - {"Voip_Tx Mixer", "MI2S_TX_Voip", "MI2S_TX"}, - {"Voip_Tx Mixer", "SLIM_0_TX_Voip", "SLIMBUS_0_TX"}, - {"Voip_Tx Mixer", "INTERNAL_BT_SCO_TX_Voip", "INT_BT_SCO_TX"}, - {"Voip_Tx Mixer", "AFE_PCM_TX_Voip", "PCM_TX"}, - {"Voip_Tx Mixer", "AUX_PCM_TX_Voip", "AUX_PCM_TX"}, - {"Voip_Tx Mixer", "SEC_AUX_PCM_TX_Voip", "SEC_AUX_PCM_TX"}, - - {"VOIP_UL", NULL, "Voip_Tx Mixer"}, - {"SLIMBUS_DL_HL", "Switch", "SLIM0_DL_HL"}, - {"SLIMBUS_0_RX", NULL, "SLIMBUS_DL_HL"}, - {"SLIM0_UL_HL", NULL, "SLIMBUS_0_TX"}, - {"INT_FM_RX", NULL, "INTFM_DL_HL"}, - {"INTFM_UL_HL", NULL, "INT_FM_TX"}, - {"AUX_PCM_RX", NULL, "AUXPCM_DL_HL"}, - {"AUXPCM_UL_HL", NULL, "AUX_PCM_TX"}, - {"PCM_RX_DL_HL", "Switch", "SLIM0_DL_HL"}, - {"PCM_RX", NULL, "PCM_RX_DL_HL"}, - {"MI2S_UL_HL", NULL, "MI2S_TX"}, - {"SEC_I2S_RX", NULL, "SEC_I2S_DL_HL"}, - {"SLIMBUS_0_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, - {"SLIMBUS_0_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, - {"SLIMBUS_0_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, - {"SLIMBUS_0_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, - {"SLIMBUS_0_RX", NULL, "SLIMBUS_0_RX Port Mixer"}, - {"AFE_PCM_RX Port Mixer", "INTERNAL_FM_TX", "INT_FM_TX"}, - {"AFE_PCM_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, - {"PCM_RX", NULL, "AFE_PCM_RX Port Mixer"}, - - {"AUXPCM_RX Port Mixer", "AUX_PCM_UL_TX", "AUX_PCM_TX"}, - {"AUXPCM_RX Port Mixer", "SLIM_0_TX", "SLIMBUS_0_TX"}, - {"AUX_PCM_RX", NULL, "AUXPCM_RX Port Mixer"}, - - {"Voice Stub Tx Mixer", "STUB_TX_HL", "STUB_TX"}, - {"Voice Stub Tx Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, - {"Voice Stub Tx Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, - {"Voice Stub Tx Mixer", "STUB_1_TX_HL", "STUB_1_TX"}, - {"Voice Stub Tx Mixer", "MI2S_TX", "MI2S_TX"}, - {"Voice Stub Tx Mixer", "SLIM_3_TX", "SLIMBUS_3_TX"}, - {"Voice Stub Tx Mixer", "PRIMARY_I2S_TX", "PRI_I2S_TX"}, - {"Voice Stub Tx Mixer", "SECONDARY_I2S_TX", "SEC_I2S_TX"}, - {"Voice Stub Tx Mixer", "AFE_PCM_TX", "PCM_TX"}, - {"VOICE_STUB_UL", NULL, "Voice Stub Tx Mixer"}, - - {"VoLTE Stub Tx Mixer", "STUB_TX_HL", "STUB_TX"}, - {"VoLTE Stub Tx Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, - {"VoLTE Stub Tx Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, - {"VoLTE Stub Tx Mixer", "STUB_1_TX_HL", "STUB_1_TX"}, - {"VoLTE Stub Tx Mixer", "MI2S_TX", "MI2S_TX"}, - {"VoLTE Stub Tx Mixer", "SLIM_3_TX", "SLIMBUS_3_TX"}, - {"VoLTE Stub Tx Mixer", "PRIMARY_I2S_TX", "PRI_I2S_TX"}, - {"VoLTE Stub Tx Mixer", "SECONDARY_I2S_TX", "SEC_I2S_TX"}, - {"VoLTE Stub Tx Mixer", "AFE_PCM_TX", "PCM_TX"}, - {"VOLTE_STUB_UL", NULL, "VoLTE Stub Tx Mixer"}, - - {"Voice2 Stub Tx Mixer", "STUB_TX_HL", "STUB_TX"}, - {"Voice2 Stub Tx Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, - {"Voice2 Stub Tx Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, - {"Voice2 Stub Tx Mixer", "STUB_1_TX_HL", "STUB_1_TX"}, - {"Voice2 Stub Tx Mixer", "MI2S_TX", "MI2S_TX"}, - {"Voice2 Stub Tx Mixer", "SLIM_3_TX", "SLIMBUS_3_TX"}, - {"Voice2 Stub Tx Mixer", "PRIMARY_I2S_TX", "PRI_I2S_TX"}, - {"Voice2 Stub Tx Mixer", "SECONDARY_I2S_TX", "SEC_I2S_TX"}, - {"Voice2 Stub Tx Mixer", "AFE_PCM_TX", "PCM_TX"}, - {"VOICE2_STUB_UL", NULL, "Voice2 Stub Tx Mixer"}, - - {"STUB_RX Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"STUB_RX Mixer", "VoLTE Stub", "VOLTE_STUB_DL"}, - {"STUB_RX Mixer", "Voice2 Stub", "VOICE2_STUB_DL"}, - {"STUB_RX", NULL, "STUB_RX Mixer"}, - {"SLIMBUS_1_RX Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"SLIMBUS_1_RX Mixer", "VoLTE Stub", "VOLTE_STUB_DL"}, - {"SLIMBUS_1_RX Mixer", "Voice2 Stub", "VOICE2_STUB_DL"}, - {"SLIMBUS_1_RX", NULL, "SLIMBUS_1_RX Mixer"}, - {"INTERNAL_BT_SCO_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"INTERNAL_BT_SCO_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"}, - {"INTERNAL_BT_SCO_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"}, - {"MI2S_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"MI2S_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"}, - {"MI2S_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"}, - {"MI2S_RX", NULL, "MI2S_RX_Voice Mixer"}, - {"HDMI_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"HDMI_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"}, - {"HDMI_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"}, - {"AFE_PCM_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"AFE_PCM_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"}, - {"AFE_PCM_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"}, - - {"SLIMBUS_3_RX_Voice Mixer", "Voice Stub", "VOICE_STUB_DL"}, - {"SLIMBUS_3_RX_Voice Mixer", "VoLTE Stub", "VOLTE_STUB_DL"}, - {"SLIMBUS_3_RX_Voice Mixer", "Voice2 Stub", "VOICE2_STUB_DL"}, - {"SLIMBUS_3_RX", NULL, "SLIMBUS_3_RX_Voice Mixer"}, - - {"SLIMBUS_1_RX Port Mixer", "INTERNAL_BT_SCO_TX", "INT_BT_SCO_TX"}, - {"SLIMBUS_1_RX Port Mixer", "AFE_PCM_TX", "PCM_TX"}, - {"SLIMBUS_1_RX", NULL, "SLIMBUS_1_RX Port Mixer"}, - {"INTERNAL_BT_SCO_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, - {"INT_BT_SCO_RX", NULL, "INTERNAL_BT_SCO_RX Port Mixer"}, - {"SLIMBUS_3_RX Port Mixer", "INTERNAL_BT_SCO_RX", "INT_BT_SCO_RX"}, - {"SLIMBUS_3_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, - {"SLIMBUS_3_RX Port Mixer", "AFE_PCM_RX", "PCM_RX"}, - {"SLIMBUS_3_RX", NULL, "SLIMBUS_3_RX Port Mixer"}, - - - {"HDMI_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, - {"HDMI_RX Port Mixer", "SLIM_3_TX", "SLIMBUS_3_TX"}, - {"HDMI", NULL, "HDMI_RX Port Mixer"}, - - {"SEC_I2S_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, - {"SEC_I2S_RX", NULL, "SEC_I2S_RX Port Mixer"}, - - {"PRI_I2S_RX Port Mixer", "MI2S_TX", "MI2S_TX"}, - {"PRI_I2S_RX", NULL, "PRI_I2S_RX Port Mixer"}, - - - {"MI2S_RX Port Mixer", "SLIM_1_TX", "SLIMBUS_1_TX"}, - {"MI2S_RX Port Mixer", "PRIMARY_I2S_TX", "PRI_I2S_TX"}, - {"MI2S_RX", NULL, "MI2S_RX Port Mixer"}, - /* Backend Enablement */ - - {"BE_OUT", NULL, "PRI_I2S_RX"}, - {"BE_OUT", NULL, "SEC_I2S_RX"}, - {"BE_OUT", NULL, "SLIMBUS_0_RX"}, - {"BE_OUT", NULL, "SLIMBUS_1_RX"}, - {"BE_OUT", NULL, "SLIMBUS_3_RX"}, - {"BE_OUT", NULL, "SLIMBUS_4_RX"}, - {"BE_OUT", NULL, "HDMI"}, - {"BE_OUT", NULL, "PSEUDO"}, - {"BE_OUT", NULL, "MI2S_RX"}, - {"PRI_I2S_TX", NULL, "BE_IN"}, - {"SEC_I2S_TX", NULL, "BE_IN"}, - {"MI2S_TX", NULL, "BE_IN"}, - {"SLIMBUS_0_TX", NULL, "BE_IN" }, - {"SLIMBUS_1_TX", NULL, "BE_IN" }, - {"SLIMBUS_3_TX", NULL, "BE_IN" }, - {"SLIMBUS_4_TX", NULL, "BE_IN" }, - {"BE_OUT", NULL, "INT_BT_SCO_RX"}, - {"INT_BT_SCO_TX", NULL, "BE_IN"}, - {"BE_OUT", NULL, "INT_FM_RX"}, - {"INT_FM_TX", NULL, "BE_IN"}, - {"BE_OUT", NULL, "PCM_RX"}, - {"PCM_TX", NULL, "BE_IN"}, - {"BE_OUT", NULL, "STUB_RX"}, - {"STUB_TX", NULL, "BE_IN"}, - {"STUB_1_TX", NULL, "BE_IN"}, - {"BE_OUT", NULL, "SEC_AUX_PCM_RX"}, - {"SEC_AUX_PCM_TX", NULL, "BE_IN"}, - {"BE_OUT", NULL, "AUX_PCM_RX"}, - {"AUX_PCM_TX", NULL, "BE_IN"}, - {"INCALL_RECORD_TX", NULL, "BE_IN"}, - {"INCALL_RECORD_RX", NULL, "BE_IN"}, - {"BE_OUT", NULL, "VOICE_PLAYBACK_TX"}, -}; - -static int msm_pcm_routing_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - unsigned int be_id = rtd->dai_link->be_id; - - if (be_id >= MSM_BACKEND_DAI_MAX) { - pr_err("%s: unexpected be_id %d\n", __func__, be_id); - return -EINVAL; - } - - mutex_lock(&routing_lock); - msm_bedais[be_id].sample_rate = params_rate(params); - msm_bedais[be_id].channel = params_channels(params); - mutex_unlock(&routing_lock); - return 0; -} - -static int msm_pcm_routing_close(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - unsigned int be_id = rtd->dai_link->be_id; - int i, session_type; - struct msm_pcm_routing_bdai_data *bedai; - - if (be_id >= MSM_BACKEND_DAI_MAX) { - pr_err("%s: unexpected be_id %d\n", __func__, be_id); - return -EINVAL; - } - - bedai = &msm_bedais[be_id]; - session_type = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? - 0 : 1); - - mutex_lock(&routing_lock); - - for_each_set_bit(i, &bedai->fe_sessions, MSM_FRONTEND_DAI_MM_SIZE) { - if (fe_dai_map[i][session_type].strm_id != INVALID_SESSION) { - fe_dai_map[i][session_type].be_srate = - bedai->sample_rate; - adm_close(bedai->port_id); - srs_port_id = -1; - } - } - - bedai->active = 0; - bedai->sample_rate = 0; - bedai->channel = 0; - bedai->perf_mode = false; - mutex_unlock(&routing_lock); - - return 0; -} - -static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - unsigned int be_id = rtd->dai_link->be_id; - int i, path_type, session_type; - struct msm_pcm_routing_bdai_data *bedai; - u32 channels; - bool playback, capture; - struct msm_pcm_routing_fdai_data *fdai; - - if (be_id >= MSM_BACKEND_DAI_MAX) { - pr_err("%s: unexpected be_id %d\n", __func__, be_id); - return -EINVAL; - } - - bedai = &msm_bedais[be_id]; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - path_type = ADM_PATH_PLAYBACK; - session_type = SESSION_TYPE_RX; - } else { - path_type = ADM_PATH_LIVE_REC; - session_type = SESSION_TYPE_TX; - } - - mutex_lock(&routing_lock); - - if (bedai->active == 1) - goto done; /* Ignore prepare if back-end already active */ - - /* AFE port is not active at this point. However, still - * go ahead setting active flag under the notion that - * QDSP6 is able to handle ADM starting before AFE port - * is started. - */ - bedai->active = 1; - playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - capture = substream->stream == SNDRV_PCM_STREAM_CAPTURE; - - for_each_set_bit(i, &bedai->fe_sessions, MSM_FRONTEND_DAI_MM_SIZE) { - fdai = &fe_dai_map[i][session_type]; - if (fdai->strm_id != INVALID_SESSION) { - if (session_type == SESSION_TYPE_TX && fdai->be_srate && - (fdai->be_srate != bedai->sample_rate)) { - pr_debug("%s: flush strm %d due diff BE rates\n", - __func__, - fdai->strm_id); - - if (fdai->event_info.event_func) - fdai->event_info.event_func( - MSM_PCM_RT_EVT_BUF_RECFG, - fdai->event_info.priv_data); - fdai->be_srate = 0; /* might not need it */ - } - - channels = bedai->channel; - if (bedai->port_id == PSEUDOPORT_01) { - adm_multi_ch_copp_pseudo_open_v3(bedai->port_id, - path_type, - bedai->sample_rate, - channels > 6 ? 6 : - channels, - DEFAULT_COPP_TOPOLOGY); - } else if ((playback || capture) - && ((channels == 2) || (channels == 1)) && - bedai->perf_mode) { - adm_multi_ch_copp_open(bedai->port_id, - path_type, - bedai->sample_rate, - channels, - DEFAULT_COPP_TOPOLOGY, bedai->perf_mode); - pr_debug("%s:configure COPP to lowlatency mode", - __func__); - } else if ((playback || capture) - && (channels > 2)) - adm_multi_ch_copp_open(bedai->port_id, - path_type, - bedai->sample_rate, - channels, - DEFAULT_COPP_TOPOLOGY, bedai->perf_mode); - else - adm_open(bedai->port_id, - path_type, - bedai->sample_rate, - channels, - DEFAULT_COPP_TOPOLOGY); - - msm_pcm_routing_build_matrix(i, - fdai->strm_id, path_type); - srs_port_id = bedai->port_id; - srs_send_params(srs_port_id, 1, 0); - } - } - -done: - mutex_unlock(&routing_lock); - - return 0; -} - -static struct snd_pcm_ops msm_routing_pcm_ops = { - .hw_params = msm_pcm_routing_hw_params, - .close = msm_pcm_routing_close, - .prepare = msm_pcm_routing_prepare, -}; - -static unsigned int msm_routing_read(struct snd_soc_platform *platform, - unsigned int reg) -{ - dev_dbg(platform->dev, "reg %x\n", reg); - return 0; -} - -/* Not used but frame seems to require it */ -static int msm_routing_write(struct snd_soc_platform *platform, - unsigned int reg, unsigned int val) -{ - dev_dbg(platform->dev, "reg %x val %x\n", reg, val); - return 0; -} - -/* Not used but frame seems to require it */ -static int msm_routing_probe(struct snd_soc_platform *platform) -{ - snd_soc_dapm_new_controls(&platform->dapm, msm_qdsp6_widgets, - ARRAY_SIZE(msm_qdsp6_widgets)); - snd_soc_dapm_add_routes(&platform->dapm, intercon, - ARRAY_SIZE(intercon)); - - snd_soc_dapm_new_widgets(&platform->dapm); - - snd_soc_add_platform_controls(platform, - int_fm_vol_mixer_controls, - ARRAY_SIZE(int_fm_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - lpa_vol_mixer_controls, - ARRAY_SIZE(lpa_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - eq_enable_mixer_controls, - ARRAY_SIZE(eq_enable_mixer_controls)); - - snd_soc_add_platform_controls(platform, - eq_band_mixer_controls, - ARRAY_SIZE(eq_band_mixer_controls)); - - snd_soc_add_platform_controls(platform, - eq_coeff_mixer_controls, - ARRAY_SIZE(eq_coeff_mixer_controls)); - - snd_soc_add_platform_controls(platform, - multimedia2_vol_mixer_controls, - ARRAY_SIZE(multimedia2_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - multimedia5_vol_mixer_controls, - ARRAY_SIZE(multimedia5_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - multimedia3_vol_mixer_controls, - ARRAY_SIZE(multimedia3_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - compressed_vol_mixer_controls, - ARRAY_SIZE(compressed_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - compressed2_vol_mixer_controls, - ARRAY_SIZE(compressed2_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - compressed3_vol_mixer_controls, - ARRAY_SIZE(compressed3_vol_mixer_controls)); - - snd_soc_add_platform_controls(platform, - lpa_SRS_trumedia_controls, - ARRAY_SIZE(lpa_SRS_trumedia_controls)); - - snd_soc_add_platform_controls(platform, - lpa_SRS_trumedia_controls_HDMI, - ARRAY_SIZE(lpa_SRS_trumedia_controls_HDMI)); - - snd_soc_add_platform_controls(platform, - lpa_SRS_trumedia_controls_I2S, - ARRAY_SIZE(lpa_SRS_trumedia_controls_I2S)); - - snd_soc_add_platform_controls(platform, - lpa_SRS_SS3D_controls, - ARRAY_SIZE(lpa_SRS_SS3D_controls)); - - snd_soc_add_platform_controls(platform, - lpa_SRS_SS3D_controls_HDMI, - ARRAY_SIZE(lpa_SRS_SS3D_controls_HDMI)); - - snd_soc_add_platform_controls(platform, - lpa_SRS_SS3D_controls_I2S, - ARRAY_SIZE(lpa_SRS_SS3D_controls_I2S)); - - snd_soc_add_platform_controls(platform, - ec_ref_rx_mixer_controls, - ARRAY_SIZE(ec_ref_rx_mixer_controls)); - - return 0; -} - -static struct snd_soc_platform_driver msm_soc_routing_platform = { - .ops = &msm_routing_pcm_ops, - .probe = msm_routing_probe, - .read = msm_routing_read, - .write = msm_routing_write, -}; - -static int msm_routing_pcm_probe(struct platform_device *pdev) -{ - dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_routing_platform); -} - -static int msm_routing_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_routing_pcm_driver = { - .driver = { - .name = "msm-pcm-routing", - .owner = THIS_MODULE, - }, - .probe = msm_routing_pcm_probe, - .remove = msm_routing_pcm_remove, -}; - -int msm_routing_check_backend_enabled(int fedai_id) -{ - int i; - if (fedai_id >= MSM_FRONTEND_DAI_MM_MAX_ID) { - /* bad ID assigned in machine driver */ - pr_err("%s: bad MM ID\n", __func__); - return 0; - } - for (i = 0; i < MSM_BACKEND_DAI_MAX; i++) { - if (test_bit(fedai_id, &msm_bedais[i].fe_sessions)) - return msm_bedais[i].active; - } - return 0; -} - -static int __init msm_soc_routing_platform_init(void) -{ - mutex_init(&routing_lock); - return platform_driver_register(&msm_routing_pcm_driver); -} -module_init(msm_soc_routing_platform_init); - -static void __exit msm_soc_routing_platform_exit(void) -{ - platform_driver_unregister(&msm_routing_pcm_driver); -} -module_exit(msm_soc_routing_platform_exit); - -MODULE_DESCRIPTION("MSM routing platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-routing.h b/sound/soc/msm/msm-pcm-routing.h deleted file mode 100644 index e25a44a890bd73e050e6bcf6281e42885abfd4f5..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-routing.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (c) 2011-2013, 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 _MSM_PCM_ROUTING_H -#define _MSM_PCM_ROUTING_H -#include - -#define LPASS_BE_PRI_I2S_RX "PRIMARY_I2S_RX" -#define LPASS_BE_PRI_I2S_TX "PRIMARY_I2S_TX" -#define LPASS_BE_SLIMBUS_0_RX "SLIMBUS_0_RX" -#define LPASS_BE_SLIMBUS_0_TX "SLIMBUS_0_TX" -#define LPASS_BE_HDMI "HDMI" -#define LPASS_BE_PSEUDO "PSEUDO" -#define LPASS_BE_INT_BT_SCO_RX "INT_BT_SCO_RX" -#define LPASS_BE_INT_BT_SCO_TX "INT_BT_SCO_TX" -#define LPASS_BE_INT_FM_RX "INT_FM_RX" -#define LPASS_BE_INT_FM_TX "INT_FM_TX" -#define LPASS_BE_AFE_PCM_RX "RT_PROXY_DAI_001_RX" -#define LPASS_BE_AFE_PCM_TX "RT_PROXY_DAI_002_TX" -#define LPASS_BE_AUXPCM_RX "AUX_PCM_RX" -#define LPASS_BE_AUXPCM_TX "AUX_PCM_TX" -#define LPASS_BE_SEC_AUXPCM_RX "SEC_AUX_PCM_RX" -#define LPASS_BE_SEC_AUXPCM_TX "SEC_AUX_PCM_TX" -#define LPASS_BE_VOICE_PLAYBACK_TX "VOICE_PLAYBACK_TX" -#define LPASS_BE_INCALL_RECORD_RX "INCALL_RECORD_TX" -#define LPASS_BE_INCALL_RECORD_TX "INCALL_RECORD_RX" -#define LPASS_BE_SEC_I2S_RX "SECONDARY_I2S_RX" -#define LPASS_BE_SEC_I2S_TX "SECONDARY_I2S_TX" - -#define LPASS_BE_MI2S_RX "MI2S_RX" -#define LPASS_BE_MI2S_TX "MI2S_TX" -#define LPASS_BE_STUB_RX "STUB_RX" -#define LPASS_BE_STUB_TX "STUB_TX" -#define LPASS_BE_SLIMBUS_1_RX "SLIMBUS_1_RX" -#define LPASS_BE_SLIMBUS_1_TX "SLIMBUS_1_TX" -#define LPASS_BE_STUB_1_TX "STUB_1_TX" -#define LPASS_BE_SLIMBUS_3_RX "SLIMBUS_3_RX" -#define LPASS_BE_SLIMBUS_3_TX "SLIMBUS_3_TX" -#define LPASS_BE_SLIMBUS_4_RX "SLIMBUS_4_RX" -#define LPASS_BE_SLIMBUS_4_TX "SLIMBUS_4_TX" - -/* For multimedia front-ends, asm session is allocated dynamically. - * Hence, asm session/multimedia front-end mapping has to be maintained. - * Due to this reason, additional multimedia front-end must be placed before - * non-multimedia front-ends. - */ - -enum { - MSM_FRONTEND_DAI_MULTIMEDIA1 = 0, - MSM_FRONTEND_DAI_MULTIMEDIA2, - MSM_FRONTEND_DAI_MULTIMEDIA3, - MSM_FRONTEND_DAI_MULTIMEDIA4, - MSM_FRONTEND_DAI_MULTIMEDIA5, - MSM_FRONTEND_DAI_MULTIMEDIA6, - MSM_FRONTEND_DAI_MULTIMEDIA7, - MSM_FRONTEND_DAI_MULTIMEDIA8, - MSM_FRONTEND_DAI_PSEUDO, - MSM_FRONTEND_DAI_CS_VOICE, - MSM_FRONTEND_DAI_VOIP, - MSM_FRONTEND_DAI_AFE_RX, - MSM_FRONTEND_DAI_AFE_TX, - MSM_FRONTEND_DAI_VOICE_STUB, - MSM_FRONTEND_DAI_VOLTE, - MSM_FRONTEND_DAI_VOICE2, - MSM_FRONTEND_DAI_DTMF_RX, - MSM_FRONTEND_DAI_VOLTE_STUB, - MSM_FRONTEND_DAI_VOICE2_STUB, - MSM_FRONTEND_DAI_MAX, -}; - -#define MSM_FRONTEND_DAI_MM_SIZE (MSM_FRONTEND_DAI_PSEUDO + 1) -#define MSM_FRONTEND_DAI_MM_MAX_ID MSM_FRONTEND_DAI_PSEUDO - -enum { - MSM_BACKEND_DAI_PRI_I2S_RX = 0, - MSM_BACKEND_DAI_PRI_I2S_TX, - MSM_BACKEND_DAI_SLIMBUS_0_RX, - MSM_BACKEND_DAI_SLIMBUS_0_TX, - MSM_BACKEND_DAI_HDMI_RX, - MSM_BACKEND_DAI_INT_BT_SCO_RX, - MSM_BACKEND_DAI_INT_BT_SCO_TX, - MSM_BACKEND_DAI_INT_FM_RX, - MSM_BACKEND_DAI_INT_FM_TX, - MSM_BACKEND_DAI_AFE_PCM_RX, - MSM_BACKEND_DAI_AFE_PCM_TX, - MSM_BACKEND_DAI_AUXPCM_RX, - MSM_BACKEND_DAI_AUXPCM_TX, - MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, - MSM_BACKEND_DAI_INCALL_RECORD_RX, - MSM_BACKEND_DAI_INCALL_RECORD_TX, - MSM_BACKEND_DAI_MI2S_RX, - MSM_BACKEND_DAI_MI2S_TX, - MSM_BACKEND_DAI_SEC_I2S_RX, - MSM_BACKEND_DAI_SEC_I2S_TX, - MSM_BACKEND_DAI_SLIMBUS_1_RX, - MSM_BACKEND_DAI_SLIMBUS_1_TX, - MSM_BACKEND_DAI_SLIMBUS_4_RX, - MSM_BACKEND_DAI_SLIMBUS_4_TX, - MSM_BACKEND_DAI_SLIMBUS_3_RX, - MSM_BACKEND_DAI_SLIMBUS_3_TX, - MSM_BACKEND_DAI_EXTPROC_RX, - MSM_BACKEND_DAI_EXTPROC_TX, - MSM_BACKEND_DAI_EXTPROC_EC_TX, - MSM_BACKEND_DAI_SEC_AUXPCM_RX, - MSM_BACKEND_DAI_SEC_AUXPCM_TX, - MSM_BACKEND_DAI_PSEUDO_PORT, - MSM_BACKEND_DAI_MAX, -}; - -enum msm_pcm_routing_event { - MSM_PCM_RT_EVT_BUF_RECFG, - MSM_PCM_RT_EVT_DEVSWITCH, - MSM_PCM_RT_EVT_MAX, -}; -/* dai_id: front-end ID, - * dspst_id: DSP audio stream ID - * stream_type: playback or capture - */ -void msm_pcm_routing_reg_phy_stream(int fedai_id, bool perf_mode, - int dspst_id, int stream_type); -void msm_pcm_routing_reg_psthr_stream(int fedai_id, int dspst_id, - int stream_type, int enable); - -void msm_pcm_routing_reg_pseudo_stream(int fedai_id, bool perf_mode, - int dspst_id, int stream_type, int sample_rate, - int channels); - -void msm_pcm_routing_dereg_pseudo_stream(int fedai_id, int dspst_id); - -struct msm_pcm_routing_evt { - void (*event_func)(enum msm_pcm_routing_event, void *); - void *priv_data; -}; - -void msm_pcm_routing_reg_phy_stream_v2(int fedai_id, bool perf_mode, - int dspst_id, int stream_type, - struct msm_pcm_routing_evt event_info); - -void msm_pcm_routing_dereg_phy_stream(int fedai_id, int stream_type); - -int lpa_set_volume(unsigned volume); - -int msm_routing_check_backend_enabled(int fedai_id); - -int multi_ch_pcm_set_volume(unsigned volume); - -int compressed_set_volume(unsigned volume); - -void multi_ch_pcm_set_channel_map(char *channel_mapping); - -#endif /*_MSM_PCM_H*/ diff --git a/sound/soc/msm/msm-pcm-voice.c b/sound/soc/msm/msm-pcm-voice.c deleted file mode 100644 index 26da6b7096b506ae604e0c9d2a7ee553cce607d3..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-voice.c +++ /dev/null @@ -1,695 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm-voice.h" -#include "qdsp6/q6voice.h" - -static struct msm_voice voice_info[VOICE_SESSION_INDEX_MAX]; - -static struct snd_pcm_hardware msm_pcm_hardware = { - - .info = (SNDRV_PCM_INFO_INTERLEAVED| - SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .rate_min = 8000, - .rate_max = 16000, - .channels_min = 1, - .channels_max = 1, - - .buffer_bytes_max = 4096 * 2, - .period_bytes_min = 4096, - .period_bytes_max = 4096, - .periods_min = 2, - .periods_max = 2, - - .fifo_size = 0, -}; -static int is_volte(struct msm_voice *pvolte) -{ - if (pvolte == &voice_info[VOLTE_SESSION_INDEX]) - return true; - else - return false; -} - -static int is_voice2(struct msm_voice *pvoice2) - -{ - if (pvoice2 == &voice_info[VOICE2_SESSION_INDEX]) - return true; - else - return false; -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - - if (!prtd->playback_start) - prtd->playback_start = 1; - - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - - if (!prtd->capture_start) - prtd->capture_start = 1; - - return 0; -} -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *voice; - - if (!strncmp("VoLTE", substream->pcm->id, 5)) { - voice = &voice_info[VOLTE_SESSION_INDEX]; - pr_debug("%s: Open VoLTE Substream Id=%s\n", - __func__, substream->pcm->id); - } else if (!strncmp("Voice2", substream->pcm->id, 6)) { - voice = &voice_info[VOICE2_SESSION_INDEX]; - pr_debug("%s: Open Voice2 Substream Id=%s\n", - __func__, substream->pcm->id); - } else { - voice = &voice_info[VOICE_SESSION_INDEX]; - pr_debug("%s: Open VOICE Substream Id=%s\n", - __func__, substream->pcm->id); - } - mutex_lock(&voice->lock); - - runtime->hw = msm_pcm_hardware; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - voice->playback_substream = substream; - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - voice->capture_substream = substream; - - voice->instance++; - pr_debug("%s: Instance = %d, Stream ID = %s\n", - __func__ , voice->instance, substream->pcm->id); - runtime->private_data = voice; - - mutex_unlock(&voice->lock); - - return 0; -} -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - - if (prtd->playback_start) - prtd->playback_start = 0; - - prtd->playback_substream = NULL; - - return 0; -} -static int msm_pcm_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - - if (prtd->capture_start) - prtd->capture_start = 0; - prtd->capture_substream = NULL; - - return 0; -} -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *prtd = runtime->private_data; - uint16_t session_id = 0; - int ret = 0; - - mutex_lock(&prtd->lock); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_close(substream); - - prtd->instance--; - if (!prtd->playback_start && !prtd->capture_start) { - pr_debug("end voice call\n"); - if (is_volte(prtd)) - session_id = voc_get_session_id(VOLTE_SESSION_NAME); - else if (is_voice2(prtd)) - session_id = voc_get_session_id(VOICE2_SESSION_NAME); - else - session_id = voc_get_session_id(VOICE_SESSION_NAME); - voc_end_voice_call(session_id); - } - mutex_unlock(&prtd->lock); - - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *prtd = runtime->private_data; - uint16_t session_id = 0; - - mutex_lock(&prtd->lock); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - - if (prtd->playback_start && prtd->capture_start) { - if (is_volte(prtd)) - session_id = voc_get_session_id(VOLTE_SESSION_NAME); - else if (is_voice2(prtd)) - session_id = voc_get_session_id(VOICE2_SESSION_NAME); - else - session_id = voc_get_session_id(VOICE_SESSION_NAME); - voc_start_voice_call(session_id); - } - mutex_unlock(&prtd->lock); - - return ret; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - - pr_debug("%s: Voice\n", __func__); - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - - return 0; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_voice *prtd = runtime->private_data; - uint16_t session_id = 0; - - pr_debug("%s: cmd = %d\n", __func__, cmd); - if (is_volte(prtd)) - session_id = voc_get_session_id(VOLTE_SESSION_NAME); - else if (is_voice2(prtd)) - session_id = voc_get_session_id(VOICE2_SESSION_NAME); - else - session_id = voc_get_session_id(VOICE_SESSION_NAME); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("Start & Stop Voice call not handled in Trigger.\n"); - break; - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("%s: resume call session_id = %d\n", __func__, - session_id); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - if (prtd->playback_start && prtd->capture_start) - voc_resume_voice_call(session_id); - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("%s: pause call session_id=%d\n", - __func__, session_id); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (prtd->playback_start) - prtd->playback_start = 0; - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (prtd->capture_start) - prtd->capture_start = 0; - } - voc_standby_voice_call(session_id); - break; - default: - ret = -EINVAL; - break; - } - return ret; -} - -static int msm_voice_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_voice_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int volume = ucontrol->value.integer.value[0]; - pr_debug("%s: volume: %d\n", __func__, volume); - voc_set_rx_vol_index(voc_get_session_id(VOICE_SESSION_NAME), - RX_PATH, volume); - return 0; -} - -static int msm_volte_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_volte_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int volume = ucontrol->value.integer.value[0]; - pr_debug("%s: volume: %d\n", __func__, volume); - voc_set_rx_vol_index(voc_get_session_id(VOLTE_SESSION_NAME), - RX_PATH, volume); - return 0; -} - -static int msm_voice2_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_voice2_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int volume = ucontrol->value.integer.value[0]; - pr_debug("%s: volume: %d\n", __func__, volume); - - voc_set_rx_vol_index(voc_get_session_id(VOICE2_SESSION_NAME), - RX_PATH, volume); - return 0; -} - -static int msm_voice_topology_disable_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_voice_topology_disable_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int disable = ucontrol->value.integer.value[0]; - - pr_debug("%s: disable = %d\n", __func__, disable); - - return voc_disable_topology(voc_get_session_id(VOICE_SESSION_NAME), - disable); - -} - -static int msm_volte_topology_disable_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_volte_topology_disable_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int disable = ucontrol->value.integer.value[0]; - - pr_debug("%s: disable = %d\n", __func__, disable); - - return voc_disable_topology(voc_get_session_id(VOLTE_SESSION_NAME), - disable); - -} - -static int msm_voice_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_voice_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int mute = ucontrol->value.integer.value[0]; - - pr_debug("%s: mute=%d\n", __func__, mute); - - voc_set_tx_mute(voc_get_session_id(VOICE_SESSION_NAME), TX_PATH, mute); - - return 0; -} - -static int msm_volte_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_volte_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int mute = ucontrol->value.integer.value[0]; - - pr_debug("%s: mute=%d\n", __func__, mute); - - voc_set_tx_mute(voc_get_session_id(VOLTE_SESSION_NAME), TX_PATH, mute); - - return 0; -} - -static int msm_voice2_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_voice2_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int mute = ucontrol->value.integer.value[0]; - - pr_debug("%s: mute=%d\n", __func__, mute); - - voc_set_tx_mute(voc_get_session_id(VOICE2_SESSION_NAME), TX_PATH, mute); - - return 0; -} - -static int msm_voice_rx_device_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voc_get_rx_device_mute(voc_get_session_id(VOICE_SESSION_NAME)); - return 0; -} - -static int msm_voice_rx_device_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int mute = ucontrol->value.integer.value[0]; - - pr_debug("%s: mute=%d\n", __func__, mute); - - voc_set_rx_device_mute(voc_get_session_id(VOICE_SESSION_NAME), mute); - - return 0; -} - -static int msm_volte_rx_device_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voc_get_rx_device_mute(voc_get_session_id(VOLTE_SESSION_NAME)); - return 0; -} - -static int msm_volte_rx_device_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int mute = ucontrol->value.integer.value[0]; - - pr_debug("%s: mute=%d\n", __func__, mute); - - voc_set_rx_device_mute(voc_get_session_id(VOLTE_SESSION_NAME), mute); - - return 0; -} - -static int msm_voice2_rx_device_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voc_get_rx_device_mute(voc_get_session_id(VOICE2_SESSION_NAME)); - return 0; -} - -static int msm_voice2_rx_device_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int mute = ucontrol->value.integer.value[0]; - - pr_debug("%s: mute=%d\n", __func__, mute); - - voc_set_rx_device_mute(voc_get_session_id(VOICE2_SESSION_NAME), mute); - - return 0; -} - -static const char const *tty_mode[] = {"OFF", "HCO", "VCO", "FULL"}; -static const struct soc_enum msm_tty_mode_enum[] = { - SOC_ENUM_SINGLE_EXT(4, tty_mode), -}; - -static int msm_voice_tty_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voc_get_tty_mode(voc_get_session_id(VOICE_SESSION_NAME)); - return 0; -} - -static int msm_voice_tty_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int tty_mode = ucontrol->value.integer.value[0]; - - pr_debug("%s: tty_mode=%d\n", __func__, tty_mode); - - voc_set_tty_mode(voc_get_session_id(VOICE_SESSION_NAME), tty_mode); - - voc_set_tty_mode(voc_get_session_id(VOICE2_SESSION_NAME), tty_mode); - - voc_set_tty_mode(voc_get_session_id(VOLTE_SESSION_NAME), tty_mode); - - return 0; -} -static int msm_voice_widevoice_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int wv_enable = ucontrol->value.integer.value[0]; - - pr_debug("%s: wv enable=%d\n", __func__, wv_enable); - - voc_set_widevoice_enable(voc_get_session_id(VOICE_SESSION_NAME), - wv_enable); - voc_set_widevoice_enable(voc_get_session_id(VOICE2_SESSION_NAME), - wv_enable); - return 0; -} - -static int msm_voice_widevoice_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voc_get_widevoice_enable(voc_get_session_id(VOICE_SESSION_NAME)); - return 0; -} - - -static int msm_voice_slowtalk_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int st_enable = ucontrol->value.integer.value[0]; - - pr_debug("%s: st enable=%d\n", __func__, st_enable); - - voc_set_pp_enable(voc_get_session_id(VOICE_SESSION_NAME), - MODULE_ID_VOICE_MODULE_ST, st_enable); - voc_set_pp_enable(voc_get_session_id(VOICE2_SESSION_NAME), - MODULE_ID_VOICE_MODULE_ST, st_enable); - - return 0; -} - -static int msm_voice_slowtalk_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voc_get_pp_enable(voc_get_session_id(VOICE_SESSION_NAME), - MODULE_ID_VOICE_MODULE_ST); - return 0; -} - -static int msm_voice_fens_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int fens_enable = ucontrol->value.integer.value[0]; - - pr_debug("%s: fens enable=%d\n", __func__, fens_enable); - - voc_set_pp_enable(voc_get_session_id(VOICE_SESSION_NAME), - MODULE_ID_VOICE_MODULE_FENS, fens_enable); - voc_set_pp_enable(voc_get_session_id(VOICE2_SESSION_NAME), - MODULE_ID_VOICE_MODULE_FENS, fens_enable); - - return 0; -} - -static int msm_voice_fens_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voc_get_pp_enable(voc_get_session_id(VOICE_SESSION_NAME), - MODULE_ID_VOICE_MODULE_FENS); - return 0; -} - -static struct snd_kcontrol_new msm_voice_controls[] = { - SOC_SINGLE_EXT("Voice Rx Device Mute", SND_SOC_NOPM, 0, 1, 0, - msm_voice_rx_device_mute_get, - msm_voice_rx_device_mute_put), - SOC_SINGLE_EXT("Voice Tx Mute", SND_SOC_NOPM, 0, 1, 0, - msm_voice_mute_get, msm_voice_mute_put), - SOC_SINGLE_EXT("Voice Rx Volume", SND_SOC_NOPM, 0, 5, 0, - msm_voice_volume_get, msm_voice_volume_put), - SOC_SINGLE_EXT("Voice Topology Disable", SND_SOC_NOPM, 0, 1, 0, - msm_voice_topology_disable_get, - msm_voice_topology_disable_put), - SOC_ENUM_EXT("TTY Mode", msm_tty_mode_enum[0], msm_voice_tty_mode_get, - msm_voice_tty_mode_put), - SOC_SINGLE_EXT("Widevoice Enable", SND_SOC_NOPM, 0, 1, 0, - msm_voice_widevoice_get, msm_voice_widevoice_put), - SOC_SINGLE_EXT("Slowtalk Enable", SND_SOC_NOPM, 0, 1, 0, - msm_voice_slowtalk_get, msm_voice_slowtalk_put), - SOC_SINGLE_EXT("FENS Enable", SND_SOC_NOPM, 0, 1, 0, - msm_voice_fens_get, msm_voice_fens_put), - SOC_SINGLE_EXT("VoLTE Rx Device Mute", SND_SOC_NOPM, 0, 1, 0, - msm_volte_rx_device_mute_get, - msm_volte_rx_device_mute_put), - SOC_SINGLE_EXT("VoLTE Tx Mute", SND_SOC_NOPM, 0, 1, 0, - msm_volte_mute_get, msm_volte_mute_put), - SOC_SINGLE_EXT("VoLTE Rx Volume", SND_SOC_NOPM, 0, 5, 0, - msm_volte_volume_get, msm_volte_volume_put), - SOC_SINGLE_EXT("VoLTE Topology Disable", SND_SOC_NOPM, 0, 1, 0, - msm_volte_topology_disable_get, - msm_volte_topology_disable_put), - SOC_SINGLE_EXT("Voice2 Rx Device Mute", SND_SOC_NOPM, 0, 1, 0, - msm_voice2_rx_device_mute_get, - msm_voice2_rx_device_mute_put), - SOC_SINGLE_EXT("Voice2 Tx Mute", SND_SOC_NOPM, 0, 1, 0, - msm_voice2_mute_get, msm_voice2_mute_put), - SOC_SINGLE_EXT("Voice2 Rx Volume", SND_SOC_NOPM, 0, 5, 0, - msm_voice2_volume_get, msm_voice2_volume_put), -}; - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, -}; - - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static int msm_pcm_voice_probe(struct snd_soc_platform *platform) -{ - snd_soc_add_platform_controls(platform, msm_voice_controls, - ARRAY_SIZE(msm_voice_controls)); - - return 0; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, - .probe = msm_pcm_voice_probe, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-pcm-voice", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - memset(&voice_info, 0, sizeof(voice_info)); - mutex_init(&voice_info[VOICE_SESSION_INDEX].lock); - mutex_init(&voice_info[VOLTE_SESSION_INDEX].lock); - mutex_init(&voice_info[VOICE2_SESSION_INDEX].lock); - - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("Voice PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm-voice.h b/sound/soc/msm/msm-pcm-voice.h deleted file mode 100644 index 207e7a7ecca0cfe69a436ebc9ad29fbd1fd57eaa..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-voice.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2011,2012 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 _MSM_PCM_VOICE_H -#define _MSM_PCM_VOICE_H -#include - -enum { - VOICE_SESSION_INDEX, - VOLTE_SESSION_INDEX, - VOICE2_SESSION_INDEX, - VOICE_SESSION_INDEX_MAX, -}; - -struct msm_voice { - struct snd_pcm_substream *playback_substream; - struct snd_pcm_substream *capture_substream; - - int instance; - - struct mutex lock; - - uint32_t samp_rate; - uint32_t channel_mode; - - int playback_start; - int capture_start; -}; - -#endif /*_MSM_PCM_VOICE_H*/ diff --git a/sound/soc/msm/msm-pcm-voip.c b/sound/soc/msm/msm-pcm-voip.c deleted file mode 100644 index ec81d4ca3ad0e0e11dfab6cc0e9deed630dd81f5..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm-voip.c +++ /dev/null @@ -1,1345 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm-q6.h" -#include "msm-pcm-routing.h" -#include "qdsp6/q6voice.h" - -#define VOIP_MAX_Q_LEN 10 -#define VOIP_MAX_VOC_PKT_SIZE 640 -#define VOIP_MIN_VOC_PKT_SIZE 320 - -/* Length of the DSP frame info header added to the voc packet. */ -#define DSP_FRAME_HDR_LEN 1 - -#define MODE_IS127 0x2 -#define MODE_4GV_NB 0x3 -#define MODE_4GV_WB 0x4 -#define MODE_AMR 0x5 -#define MODE_AMR_WB 0xD -#define MODE_PCM 0xC -#define MODE_G711 0xA -#define MODE_G711A 0xF - -enum msm_audio_g711a_frame_type { - MVS_G711A_SPEECH_GOOD, - MVS_G711A_SID, - MVS_G711A_NO_DATA, - MVS_G711A_ERASURE -}; - -enum msm_audio_g711a_mode { - MVS_G711A_MODE_MULAW, - MVS_G711A_MODE_ALAW -}; - -enum msm_audio_g711_mode { - MVS_G711_MODE_MULAW, - MVS_G711_MODE_ALAW -}; - -enum format { - FORMAT_S16_LE = 2, - FORMAT_SPECIAL = 31, -}; - - -enum amr_rate_type { - AMR_RATE_4750, /* AMR 4.75 kbps */ - AMR_RATE_5150, /* AMR 5.15 kbps */ - AMR_RATE_5900, /* AMR 5.90 kbps */ - AMR_RATE_6700, /* AMR 6.70 kbps */ - AMR_RATE_7400, /* AMR 7.40 kbps */ - AMR_RATE_7950, /* AMR 7.95 kbps */ - AMR_RATE_10200, /* AMR 10.20 kbps */ - AMR_RATE_12200, /* AMR 12.20 kbps */ - AMR_RATE_6600, /* AMR-WB 6.60 kbps */ - AMR_RATE_8850, /* AMR-WB 8.85 kbps */ - AMR_RATE_12650, /* AMR-WB 12.65 kbps */ - AMR_RATE_14250, /* AMR-WB 14.25 kbps */ - AMR_RATE_15850, /* AMR-WB 15.85 kbps */ - AMR_RATE_18250, /* AMR-WB 18.25 kbps */ - AMR_RATE_19850, /* AMR-WB 19.85 kbps */ - AMR_RATE_23050, /* AMR-WB 23.05 kbps */ - AMR_RATE_23850, /* AMR-WB 23.85 kbps */ - AMR_RATE_UNDEF -}; - -enum voip_state { - VOIP_STOPPED, - VOIP_STARTED, -}; - -struct voip_frame { - union { - uint32_t frame_type; - uint32_t packet_rate; - } header; - uint32_t len; - uint8_t voc_pkt[VOIP_MAX_VOC_PKT_SIZE]; -}; - -struct voip_buf_node { - struct list_head list; - struct voip_frame frame; -}; - -struct voip_drv_info { - enum voip_state state; - - struct snd_pcm_substream *playback_substream; - struct snd_pcm_substream *capture_substream; - - struct list_head in_queue; - struct list_head free_in_queue; - - struct list_head out_queue; - struct list_head free_out_queue; - - wait_queue_head_t out_wait; - wait_queue_head_t in_wait; - - struct mutex lock; - - spinlock_t dsp_lock; - spinlock_t dsp_ul_lock; - - uint32_t mode; - uint32_t rate_type; - uint32_t rate; - uint32_t dtx_mode; - - uint8_t capture_start; - uint8_t playback_start; - - uint8_t playback_instance; - uint8_t capture_instance; - - unsigned int play_samp_rate; - unsigned int cap_samp_rate; - - unsigned int pcm_size; - unsigned int pcm_count; - unsigned int pcm_playback_irq_pos; /* IRQ position */ - unsigned int pcm_playback_buf_pos; /* position in buffer */ - - unsigned int pcm_capture_size; - unsigned int pcm_capture_count; - unsigned int pcm_capture_irq_pos; /* IRQ position */ - unsigned int pcm_capture_buf_pos; /* position in buffer */ -}; - -static int voip_get_media_type(uint32_t mode, uint32_t rate_type, - unsigned int samp_rate, - uint32_t *media_type); -static int voip_get_rate_type(uint32_t mode, - uint32_t rate, - uint32_t *rate_type); -static int msm_voip_mode_rate_config_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -static int msm_voip_mode_rate_config_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); - -static struct voip_drv_info voip_info; - -static struct snd_pcm_hardware msm_pcm_hardware = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED), - .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_SPECIAL, - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, - .rate_min = 8000, - .rate_max = 16000, - .channels_min = 1, - .channels_max = 1, - .buffer_bytes_max = sizeof(struct voip_buf_node) * VOIP_MAX_Q_LEN, - .period_bytes_min = VOIP_MIN_VOC_PKT_SIZE, - .period_bytes_max = VOIP_MAX_VOC_PKT_SIZE, - .periods_min = VOIP_MAX_Q_LEN, - .periods_max = VOIP_MAX_Q_LEN, - .fifo_size = 0, -}; - - -static int msm_voip_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int mute = ucontrol->value.integer.value[0]; - - pr_debug("%s: mute=%d\n", __func__, mute); - - voc_set_tx_mute(voc_get_session_id(VOIP_SESSION_NAME), TX_PATH, mute); - - return 0; -} - -static int msm_voip_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_voip_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int volume = ucontrol->value.integer.value[0]; - - pr_debug("%s: volume: %d\n", __func__, volume); - - voc_set_rx_vol_index(voc_get_session_id(VOIP_SESSION_NAME), - RX_PATH, - volume); - return 0; -} -static int msm_voip_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_voip_dtx_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mutex_lock(&voip_info.lock); - - voip_info.dtx_mode = ucontrol->value.integer.value[0]; - - pr_debug("%s: dtx: %d\n", __func__, voip_info.dtx_mode); - - mutex_unlock(&voip_info.lock); - - return 0; -} -static int msm_voip_dtx_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mutex_lock(&voip_info.lock); - - ucontrol->value.integer.value[0] = voip_info.dtx_mode; - - mutex_unlock(&voip_info.lock); - - return 0; -} - -static struct snd_kcontrol_new msm_voip_controls[] = { - SOC_SINGLE_EXT("Voip Tx Mute", SND_SOC_NOPM, 0, 1, 0, - msm_voip_mute_get, msm_voip_mute_put), - SOC_SINGLE_EXT("Voip Rx Volume", SND_SOC_NOPM, 0, 5, 0, - msm_voip_volume_get, msm_voip_volume_put), - SOC_SINGLE_MULTI_EXT("Voip Mode Rate Config", SND_SOC_NOPM, 0, 23850, - 0, 2, msm_voip_mode_rate_config_get, - msm_voip_mode_rate_config_put), - SOC_SINGLE_EXT("Voip Dtx Mode", SND_SOC_NOPM, 0, 1, 0, - msm_voip_dtx_mode_get, msm_voip_dtx_mode_put), -}; - -static int msm_pcm_voip_probe(struct snd_soc_platform *platform) -{ - snd_soc_add_platform_controls(platform, msm_voip_controls, - ARRAY_SIZE(msm_voip_controls)); - - return 0; -} - -/* sample rate supported */ -static unsigned int supported_sample_rates[] = {8000, 16000}; - -/* capture path */ -static void voip_process_ul_pkt(uint8_t *voc_pkt, - uint32_t pkt_len, - void *private_data) -{ - struct voip_buf_node *buf_node = NULL; - struct voip_drv_info *prtd = private_data; - unsigned long dsp_flags; - - if (prtd->capture_substream == NULL) - return; - - /* Copy up-link packet into out_queue. */ - spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags); - - /* discarding UL packets till start is received */ - if (!list_empty(&prtd->free_out_queue) && prtd->capture_start) { - buf_node = list_first_entry(&prtd->free_out_queue, - struct voip_buf_node, list); - list_del(&buf_node->list); - switch (prtd->mode) { - case MODE_AMR_WB: - case MODE_AMR: { - /* Remove the DSP frame info header. Header format: - * Bits 0-3: Frame rate - * Bits 4-7: Frame type - */ - buf_node->frame.header.frame_type = - ((*voc_pkt) & 0xF0) >> 4; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN; - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - list_add_tail(&buf_node->list, &prtd->out_queue); - break; - } - case MODE_IS127: - case MODE_4GV_NB: - case MODE_4GV_WB: { - /* Remove the DSP frame info header. - * Header format: - * Bits 0-3: frame rate - */ - buf_node->frame.header.packet_rate = (*voc_pkt) & 0x0F; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - buf_node->frame.len = pkt_len - DSP_FRAME_HDR_LEN; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, &prtd->out_queue); - break; - } - case MODE_G711: - case MODE_G711A:{ - /* G711 frames are 10ms each, but the DSP works with - * 20ms frames and sends two 10ms frames per buffer. - * Extract the two frames and put them in separate - * buffers. - */ - /* Remove the first DSP frame info header. - * Header format: G711A - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - * - * Header format: G711 - * Bits 2-3: Frame rate - */ - if (prtd->mode == MODE_G711A) - buf_node->frame.header.frame_type = - (*voc_pkt) & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - /* There are two frames in the buffer. Length of the - * first frame: - */ - buf_node->frame.len = (pkt_len - - 2 * DSP_FRAME_HDR_LEN) / 2; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - voc_pkt = voc_pkt + buf_node->frame.len; - - list_add_tail(&buf_node->list, &prtd->out_queue); - - /* Get another buffer from the free Q and fill in the - * second frame. - */ - if (!list_empty(&prtd->free_out_queue)) { - buf_node = - list_first_entry(&prtd->free_out_queue, - struct voip_buf_node, - list); - list_del(&buf_node->list); - - /* Remove the second DSP frame info header. - * Header format: - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - */ - - if (prtd->mode == MODE_G711A) - buf_node->frame.header.frame_type = - (*voc_pkt) & 0x03; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - /* There are two frames in the buffer. Length - * of the second frame: - */ - buf_node->frame.len = (pkt_len - - 2 * DSP_FRAME_HDR_LEN) / 2; - - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - - list_add_tail(&buf_node->list, - &prtd->out_queue); - } else { - /* Drop the second frame */ - pr_err("%s: UL data dropped, read is slow\n", - __func__); - } - break; - } - default: { - buf_node->frame.len = pkt_len; - memcpy(&buf_node->frame.voc_pkt[0], - voc_pkt, - buf_node->frame.len); - list_add_tail(&buf_node->list, &prtd->out_queue); - } - } - pr_debug("ul_pkt: pkt_len =%d, frame.len=%d\n", pkt_len, - buf_node->frame.len); - prtd->pcm_capture_irq_pos += prtd->pcm_capture_count; - spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags); - snd_pcm_period_elapsed(prtd->capture_substream); - } else { - spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags); - pr_err("UL data dropped\n"); - } - - wake_up(&prtd->out_wait); -} - -/* playback path */ -static void voip_process_dl_pkt(uint8_t *voc_pkt, - uint32_t *pkt_len, - void *private_data) -{ - struct voip_buf_node *buf_node = NULL; - struct voip_drv_info *prtd = private_data; - unsigned long dsp_flags; - - - if (prtd->playback_substream == NULL) - return; - - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - - if (!list_empty(&prtd->in_queue) && prtd->playback_start) { - buf_node = list_first_entry(&prtd->in_queue, - struct voip_buf_node, list); - list_del(&buf_node->list); - switch (prtd->mode) { - case MODE_AMR: - case MODE_AMR_WB: { - /* Add the DSP frame info header. Header format: - * Bits 0-3: Frame rate - * Bits 4-7: Frame type - */ - *voc_pkt = ((buf_node->frame.header.frame_type & - 0x0F) << 4) | (prtd->rate_type & 0x0F); - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - list_add_tail(&buf_node->list, &prtd->free_in_queue); - break; - } - case MODE_IS127: - case MODE_4GV_NB: - case MODE_4GV_WB: { - /* Add the DSP frame info header. Header format: - * Bits 0-3 : Frame rate - */ - *voc_pkt = buf_node->frame.header.packet_rate & 0x0F; - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &prtd->free_in_queue); - break; - } - case MODE_G711: - case MODE_G711A:{ - /* G711 frames are 10ms each but the DSP expects 20ms - * worth of data, so send two 10ms frames per buffer. - */ - /* Add the first DSP frame info header. Header format: - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - */ - - *voc_pkt = ((prtd->rate_type & 0x0F) << 2) | - (buf_node->frame.header.frame_type & 0x03); - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - voc_pkt = voc_pkt + buf_node->frame.len; - - list_add_tail(&buf_node->list, &prtd->free_in_queue); - - if (!list_empty(&prtd->in_queue)) { - /* Get the second buffer. */ - buf_node = list_first_entry(&prtd->in_queue, - struct voip_buf_node, - list); - list_del(&buf_node->list); - - /* Add the second DSP frame info header. - * Header format: - * Bits 0-1: Frame type - * Bits 2-3: Frame rate - */ - *voc_pkt = ((prtd->rate_type & 0x0F) << 2) | - (buf_node->frame.header.frame_type & 0x03); - voc_pkt = voc_pkt + DSP_FRAME_HDR_LEN; - - *pkt_len = *pkt_len + - buf_node->frame.len + DSP_FRAME_HDR_LEN; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, - &prtd->free_in_queue); - } else { - /* Only 10ms worth of data is available, signal - * erasure frame. - */ - *voc_pkt = ((prtd->rate_type & 0x0F) << 2) | - (MVS_G711A_ERASURE & 0x03); - - *pkt_len = *pkt_len + DSP_FRAME_HDR_LEN; - pr_debug("%s, Only 10ms read, erase 2nd frame\n", - __func__); - } - break; - } - default: { - *pkt_len = buf_node->frame.len; - - memcpy(voc_pkt, - &buf_node->frame.voc_pkt[0], - buf_node->frame.len); - - list_add_tail(&buf_node->list, &prtd->free_in_queue); - } - } - pr_debug("dl_pkt: pkt_len=%d, frame_len=%d\n", *pkt_len, - buf_node->frame.len); - prtd->pcm_playback_irq_pos += prtd->pcm_count; - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - snd_pcm_period_elapsed(prtd->playback_substream); - } else { - *pkt_len = 0; - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - pr_err("DL data not available\n"); - } - wake_up(&prtd->in_wait); -} - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - - prtd->play_samp_rate = runtime->rate; - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_playback_irq_pos = 0; - prtd->pcm_playback_buf_pos = 0; - - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - int ret = 0; - - prtd->cap_samp_rate = runtime->rate; - prtd->pcm_capture_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_capture_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_capture_irq_pos = 0; - prtd->pcm_capture_buf_pos = 0; - return ret; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - pr_debug("%s: Trigger start\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - prtd->capture_start = 1; - else - prtd->playback_start = 1; - break; - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - prtd->playback_start = 0; - else - prtd->capture_start = 0; - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = &voip_info; - int ret = 0; - - pr_debug("%s, VoIP\n", __func__); - mutex_lock(&prtd->lock); - - runtime->hw = msm_pcm_hardware; - - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_debug("snd_pcm_hw_constraint_list failed\n"); - - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) { - pr_debug("snd_pcm_hw_constraint_integer failed\n"); - goto err; - } - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - prtd->playback_substream = substream; - prtd->playback_instance++; - } else { - prtd->capture_substream = substream; - prtd->capture_instance++; - } - runtime->private_data = prtd; -err: - mutex_unlock(&prtd->lock); - - return ret; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - struct voip_buf_node *buf_node = NULL; - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - unsigned long dsp_flags; - - int count = frames_to_bytes(runtime, frames); - pr_debug("%s: count = %d, frames=%d\n", __func__, count, (int)frames); - - ret = wait_event_interruptible_timeout(prtd->in_wait, - (!list_empty(&prtd->free_in_queue) || - prtd->state == VOIP_STOPPED), - 1 * HZ); - if (ret > 0) { - if (count <= VOIP_MAX_VOC_PKT_SIZE) { - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - buf_node = - list_first_entry(&prtd->free_in_queue, - struct voip_buf_node, list); - list_del(&buf_node->list); - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - if (prtd->mode == MODE_PCM) { - ret = copy_from_user(&buf_node->frame.voc_pkt, - buf, count); - buf_node->frame.len = count; - } else - ret = copy_from_user(&buf_node->frame, - buf, count); - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - list_add_tail(&buf_node->list, &prtd->in_queue); - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - } else { - pr_err("%s: Write cnt %d is > VOIP_MAX_VOC_PKT_SIZE\n", - __func__, count); - ret = -ENOMEM; - } - - } else if (ret == 0) { - pr_err("%s: No free DL buffs\n", __func__); - ret = -ETIMEDOUT; - } else { - pr_err("%s: playback copy was interrupted\n", __func__); - } - - return ret; -} -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - int count = 0; - struct voip_buf_node *buf_node = NULL; - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - unsigned long dsp_flags; - int size; - - count = frames_to_bytes(runtime, frames); - - pr_debug("%s: count = %d\n", __func__, count); - - ret = wait_event_interruptible_timeout(prtd->out_wait, - (!list_empty(&prtd->out_queue) || - prtd->state == VOIP_STOPPED), - 1 * HZ); - - if (ret > 0) { - - if (count <= VOIP_MAX_VOC_PKT_SIZE) { - spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags); - buf_node = list_first_entry(&prtd->out_queue, - struct voip_buf_node, list); - list_del(&buf_node->list); - spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags); - if (prtd->mode == MODE_PCM) { - ret = copy_to_user(buf, - &buf_node->frame.voc_pkt, - buf_node->frame.len); - } else { - size = sizeof(buf_node->frame.header) + - sizeof(buf_node->frame.len) + - buf_node->frame.len; - - ret = copy_to_user(buf, - &buf_node->frame, - size); - } - if (ret) { - pr_err("%s: Copy to user retuned %d\n", - __func__, ret); - ret = -EFAULT; - } - spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags); - list_add_tail(&buf_node->list, - &prtd->free_out_queue); - spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags); - - } else { - pr_err("%s: Read count %d > VOIP_MAX_VOC_PKT_SIZE\n", - __func__, count); - ret = -ENOMEM; - } - - - } else if (ret == 0) { - pr_err("%s: No UL data available\n", __func__); - ret = -ETIMEDOUT; - } else { - pr_err("%s: Read was interrupted\n", __func__); - ret = -ERESTARTSYS; - } - return ret; -} -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct list_head *ptr = NULL; - struct list_head *next = NULL; - struct voip_buf_node *buf_node = NULL; - struct snd_dma_buffer *p_dma_buf, *c_dma_buf; - struct snd_pcm_substream *p_substream, *c_substream; - struct snd_pcm_runtime *runtime; - struct voip_drv_info *prtd; - unsigned long dsp_flags; - - if (substream == NULL) { - pr_err("substream is NULL\n"); - return -EINVAL; - } - runtime = substream->runtime; - prtd = runtime->private_data; - - wake_up(&prtd->out_wait); - - mutex_lock(&prtd->lock); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - prtd->playback_instance--; - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - prtd->capture_instance--; - - if (!prtd->playback_instance && !prtd->capture_instance) { - if (prtd->state == VOIP_STARTED) { - prtd->state = VOIP_STOPPED; - voc_end_voice_call( - voc_get_session_id(VOIP_SESSION_NAME)); - voc_register_mvs_cb(NULL, NULL, prtd); - } - /* release all buffer */ - /* release in_queue and free_in_queue */ - pr_debug("release all buffer\n"); - p_substream = prtd->playback_substream; - if (p_substream == NULL) { - pr_debug("p_substream is NULL\n"); - goto capt; - } - p_dma_buf = &p_substream->dma_buffer; - if (p_dma_buf == NULL) { - pr_debug("p_dma_buf is NULL\n"); - goto capt; - } - if (p_dma_buf->area != NULL) { - spin_lock_irqsave(&prtd->dsp_lock, dsp_flags); - list_for_each_safe(ptr, next, &prtd->in_queue) { - buf_node = list_entry(ptr, - struct voip_buf_node, list); - list_del(&buf_node->list); - } - list_for_each_safe(ptr, next, &prtd->free_in_queue) { - buf_node = list_entry(ptr, - struct voip_buf_node, list); - list_del(&buf_node->list); - } - spin_unlock_irqrestore(&prtd->dsp_lock, dsp_flags); - dma_free_coherent(p_substream->pcm->card->dev, - runtime->hw.buffer_bytes_max, p_dma_buf->area, - p_dma_buf->addr); - p_dma_buf->area = NULL; - } - /* release out_queue and free_out_queue */ -capt: c_substream = prtd->capture_substream; - if (c_substream == NULL) { - pr_debug("c_substream is NULL\n"); - goto done; - } - c_dma_buf = &c_substream->dma_buffer; - if (c_substream == NULL) { - pr_debug("c_dma_buf is NULL.\n"); - goto done; - } - if (c_dma_buf->area != NULL) { - spin_lock_irqsave(&prtd->dsp_ul_lock, dsp_flags); - list_for_each_safe(ptr, next, &prtd->out_queue) { - buf_node = list_entry(ptr, - struct voip_buf_node, list); - list_del(&buf_node->list); - } - list_for_each_safe(ptr, next, &prtd->free_out_queue) { - buf_node = list_entry(ptr, - struct voip_buf_node, list); - list_del(&buf_node->list); - } - spin_unlock_irqrestore(&prtd->dsp_ul_lock, dsp_flags); - dma_free_coherent(c_substream->pcm->card->dev, - runtime->hw.buffer_bytes_max, c_dma_buf->area, - c_dma_buf->addr); - c_dma_buf->area = NULL; - } -done: - prtd->capture_substream = NULL; - prtd->playback_substream = NULL; - } - mutex_unlock(&prtd->lock); - - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - uint32_t media_type = 0; - uint32_t rate_type = 0; - - mutex_lock(&prtd->lock); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - - if ((runtime->format != FORMAT_SPECIAL) && - ((prtd->mode == MODE_AMR) || (prtd->mode == MODE_AMR_WB) || - (prtd->mode == MODE_IS127) || (prtd->mode == MODE_4GV_NB) || - (prtd->mode == MODE_4GV_WB) || (prtd->mode == MODE_G711) || - (prtd->mode == MODE_G711A))) { - pr_err("mode:%d and format:%u are not mached\n", - prtd->mode, (uint32_t)runtime->format); - ret = -EINVAL; - goto done; - } - - if ((runtime->format != FORMAT_S16_LE) && - (prtd->mode == MODE_PCM)) { - pr_err("mode:%d and format:%u are not mached\n", - prtd->mode, (uint32_t)runtime->format); - ret = -EINVAL; - goto done; - } - - if (prtd->playback_instance && prtd->capture_instance - && (prtd->state != VOIP_STARTED)) { - - ret = voip_get_rate_type(prtd->mode, - prtd->rate, - &rate_type); - if (ret < 0) { - pr_err("fail at getting rate_type\n"); - ret = -EINVAL; - goto done; - } - prtd->rate_type = rate_type; - ret = voip_get_media_type(prtd->mode, - prtd->rate_type, - prtd->play_samp_rate, - &media_type); - if (ret < 0) { - pr_err("fail at getting media_type\n"); - goto done; - } - pr_debug(" media_type=%d, rate_type=%d\n", media_type, - rate_type); - if ((prtd->play_samp_rate == 8000) && - (prtd->cap_samp_rate == 8000)) - voc_config_vocoder(media_type, rate_type, - VSS_NETWORK_ID_VOIP_NB, - voip_info.dtx_mode); - else if ((prtd->play_samp_rate == 16000) && - (prtd->cap_samp_rate == 16000)) - voc_config_vocoder(media_type, rate_type, - VSS_NETWORK_ID_VOIP_WB, - voip_info.dtx_mode); - else { - pr_debug("%s: Invalid rate playback %d, capture %d\n", - __func__, prtd->play_samp_rate, - prtd->cap_samp_rate); - goto done; - } - voc_register_mvs_cb(voip_process_ul_pkt, - voip_process_dl_pkt, prtd); - voc_start_voice_call(voc_get_session_id(VOIP_SESSION_NAME)); - - prtd->state = VOIP_STARTED; - } -done: - mutex_unlock(&prtd->lock); - - return ret; -} - -static snd_pcm_uframes_t -msm_pcm_playback_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - if (prtd->pcm_playback_irq_pos >= prtd->pcm_size) - prtd->pcm_playback_irq_pos = 0; - return bytes_to_frames(runtime, (prtd->pcm_playback_irq_pos)); -} - -static snd_pcm_uframes_t -msm_pcm_capture_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct voip_drv_info *prtd = runtime->private_data; - - if (prtd->pcm_capture_irq_pos >= prtd->pcm_capture_size) - prtd->pcm_capture_irq_pos = 0; - return bytes_to_frames(runtime, (prtd->pcm_capture_irq_pos)); -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - snd_pcm_uframes_t ret = 0; - pr_debug("%s\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_pointer(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_pointer(substream); - return ret; -} - -static int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - pr_debug("%s\n", __func__); - dma_mmap_coherent(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); - return 0; -} - -static int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct voip_buf_node *buf_node = NULL; - int i = 0, offset = 0; - - pr_debug("%s: voip\n", __func__); - - mutex_lock(&voip_info.lock); - - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - - dma_buf->area = dma_alloc_coherent(substream->pcm->card->dev, - runtime->hw.buffer_bytes_max, - &dma_buf->addr, GFP_KERNEL); - if (!dma_buf->area) { - pr_err("%s:MSM VOIP dma_alloc failed\n", __func__); - return -ENOMEM; - } - - dma_buf->bytes = runtime->hw.buffer_bytes_max; - memset(dma_buf->area, 0, runtime->hw.buffer_bytes_max); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - for (i = 0; i < VOIP_MAX_Q_LEN; i++) { - buf_node = (void *)dma_buf->area + offset; - - list_add_tail(&buf_node->list, - &voip_info.free_in_queue); - offset = offset + sizeof(struct voip_buf_node); - } - } else { - for (i = 0; i < VOIP_MAX_Q_LEN; i++) { - buf_node = (void *) dma_buf->area + offset; - list_add_tail(&buf_node->list, - &voip_info.free_out_queue); - offset = offset + sizeof(struct voip_buf_node); - } - } - - mutex_unlock(&voip_info.lock); - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - - return 0; -} - -static int msm_voip_mode_rate_config_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mutex_lock(&voip_info.lock); - - ucontrol->value.integer.value[0] = voip_info.mode; - ucontrol->value.integer.value[1] = voip_info.rate; - - mutex_unlock(&voip_info.lock); - - return 0; -} - -static int msm_voip_mode_rate_config_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - mutex_lock(&voip_info.lock); - - voip_info.mode = ucontrol->value.integer.value[0]; - voip_info.rate = ucontrol->value.integer.value[1]; - - pr_debug("%s: mode=%d,rate=%d\n", __func__, voip_info.mode, - voip_info.rate); - - mutex_unlock(&voip_info.lock); - - return 0; -} - -static int voip_get_rate_type(uint32_t mode, uint32_t rate, - uint32_t *rate_type) -{ - int ret = 0; - - switch (mode) { - case MODE_AMR: { - switch (rate) { - case 4750: - *rate_type = AMR_RATE_4750; - break; - case 5150: - *rate_type = AMR_RATE_5150; - break; - case 5900: - *rate_type = AMR_RATE_5900; - break; - case 6700: - *rate_type = AMR_RATE_6700; - break; - case 7400: - *rate_type = AMR_RATE_7400; - break; - case 7950: - *rate_type = AMR_RATE_7950; - break; - case 10200: - *rate_type = AMR_RATE_10200; - break; - case 12200: - *rate_type = AMR_RATE_12200; - break; - default: - pr_err("wrong rate for AMR NB.\n"); - ret = -EINVAL; - break; - } - break; - } - case MODE_AMR_WB: { - switch (rate) { - case 6600: - *rate_type = AMR_RATE_6600 - AMR_RATE_6600; - break; - case 8850: - *rate_type = AMR_RATE_8850 - AMR_RATE_6600; - break; - case 12650: - *rate_type = AMR_RATE_12650 - AMR_RATE_6600; - break; - case 14250: - *rate_type = AMR_RATE_14250 - AMR_RATE_6600; - break; - case 15850: - *rate_type = AMR_RATE_15850 - AMR_RATE_6600; - break; - case 18250: - *rate_type = AMR_RATE_18250 - AMR_RATE_6600; - break; - case 19850: - *rate_type = AMR_RATE_19850 - AMR_RATE_6600; - break; - case 23050: - *rate_type = AMR_RATE_23050 - AMR_RATE_6600; - break; - case 23850: - *rate_type = AMR_RATE_23850 - AMR_RATE_6600; - break; - default: - pr_err("wrong rate for AMR_WB.\n"); - ret = -EINVAL; - break; - } - break; - } - case MODE_PCM: { - *rate_type = 0; - break; - } - case MODE_IS127: - case MODE_4GV_NB: - case MODE_4GV_WB: { - switch (rate) { - case VOC_0_RATE: - case VOC_8_RATE: - case VOC_4_RATE: - case VOC_2_RATE: - case VOC_1_RATE: - *rate_type = rate; - break; - default: - pr_err("wrong rate for IS127/4GV_NB/WB.\n"); - ret = -EINVAL; - break; - } - break; - } - case MODE_G711: - case MODE_G711A: - *rate_type = rate; - break; - default: - pr_err("wrong mode type.\n"); - ret = -EINVAL; - } - pr_debug("%s, mode=%d, rate=%u, rate_type=%d\n", - __func__, mode, rate, *rate_type); - return ret; -} - -static int voip_get_media_type(uint32_t mode, uint32_t rate_type, - unsigned int samp_rate, - uint32_t *media_type) -{ - int ret = 0; - - pr_debug("%s: mode=%d, samp_rate=%d\n", __func__, - mode, samp_rate); - switch (mode) { - case MODE_AMR: - *media_type = VSS_MEDIA_ID_AMR_NB_MODEM; - break; - case MODE_AMR_WB: - *media_type = VSS_MEDIA_ID_AMR_WB_MODEM; - break; - case MODE_PCM: - if (samp_rate == 8000) - *media_type = VSS_MEDIA_ID_PCM_NB; - else - *media_type = VSS_MEDIA_ID_PCM_WB; - break; - case MODE_IS127: /* EVRC-A */ - *media_type = VSS_MEDIA_ID_EVRC_MODEM; - break; - case MODE_4GV_NB: /* EVRC-B */ - *media_type = VSS_MEDIA_ID_4GV_NB_MODEM; - break; - case MODE_4GV_WB: /* EVRC-WB */ - *media_type = VSS_MEDIA_ID_4GV_WB_MODEM; - break; - case MODE_G711: - case MODE_G711A: - if (rate_type == MVS_G711A_MODE_MULAW) - *media_type = VSS_MEDIA_ID_G711_MULAW; - else - *media_type = VSS_MEDIA_ID_G711_ALAW; - break; - default: - pr_debug(" input mode is not supported\n"); - ret = -EINVAL; - } - - pr_debug("%s: media_type is 0x%x\n", __func__, *media_type); - - return ret; -} - - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - int ret = 0; - - pr_debug("msm_asoc_pcm_new\n"); - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -static struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_asoc_pcm_new, - .probe = msm_pcm_voip_probe, -}; - -static int msm_pcm_probe(struct platform_device *pdev) -{ - pr_info("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-voip-dsp", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - memset(&voip_info, 0, sizeof(voip_info)); - voip_info.mode = MODE_PCM; - mutex_init(&voip_info.lock); - - spin_lock_init(&voip_info.dsp_lock); - spin_lock_init(&voip_info.dsp_ul_lock); - - init_waitqueue_head(&voip_info.out_wait); - init_waitqueue_head(&voip_info.in_wait); - - INIT_LIST_HEAD(&voip_info.in_queue); - INIT_LIST_HEAD(&voip_info.free_in_queue); - INIT_LIST_HEAD(&voip_info.out_queue); - INIT_LIST_HEAD(&voip_info.free_out_queue); - - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm-pcm.c b/sound/soc/msm/msm-pcm.c deleted file mode 100644 index d40ca67a010fae5cd8298e67479e4b59213075bc..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm.c +++ /dev/null @@ -1,646 +0,0 @@ -/* sound/soc/msm/msm-pcm.c - * - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2008-2009, 2012 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm.h" - -#define MAX_DATA_SIZE 496 -#define AUDPP_ALSA_DECODER (-1) - -#define DB_TABLE_INDEX (50) - -#define audio_send_queue_recbs(prtd, cmd, len) \ - msm_adsp_write(prtd->audrec, QDSP_uPAudRecBitStreamQueue, cmd, len) -#define audio_send_queue_rec(prtd, cmd, len) \ - msm_adsp_write(prtd->audrec, QDSP_uPAudRecCmdQueue, cmd, len) - -int intcnt; - -struct audio_frame { - uint16_t count_low; - uint16_t count_high; - uint16_t bytes; - uint16_t unknown; - unsigned char samples[]; -} __attribute__ ((packed)); - -/* Table contains dB to raw value mapping */ -static const unsigned decoder_db_table[] = { - - 31 , /* -50 dB */ - 35 , 39 , 44 , 50 , 56 , - 63 , 70 , 79 , 89 , 99 , - 112 , 125 , 141 , 158 , 177 , - 199 , 223 , 251 , 281 , 316 , - 354 , 398 , 446 , 501 , 562 , - 630 , 707 , 794 , 891 , 999 , - 1122 , 1258 , 1412 , 1584 , 1778 , - 1995 , 2238 , 2511 , 2818 , 3162 , - 3548 , 3981 , 4466 , 5011 , 5623 , - 6309 , 7079 , 7943 , 8912 , 10000 , - 11220 , 12589 , 14125 , 15848 , 17782 , - 19952 , 22387 , 25118 , 28183 , 31622 , - 35481 , 39810 , 44668 , 50118 , 56234 , - 63095 , 70794 , 79432 , 89125 , 100000 , - 112201 , 125892 , 141253 , 158489 , 177827 , - 199526 , 223872 , 251188 , 281838 , 316227 , - 354813 , 398107 , 446683 , 501187 , 562341 , - 630957 , 707945 , 794328 , 891250 , 1000000 , - 1122018 , 1258925 , 1412537 , 1584893 , 1778279 , - 1995262 , 2238721 , 2511886 , 2818382 , 3162277 , - 3548133 /* 51 dB */ - -}; - -static unsigned compute_db_raw(int db) -{ - unsigned reg_val = 0; /* Computed result for correspondent db */ - /* Check if the given db is out of range */ - if (db <= MIN_DB) - return 0; - else if (db > MAX_DB) - db = MAX_DB; /* If db is too high then set to max */ - reg_val = decoder_db_table[DB_TABLE_INDEX+db]; - return reg_val; -} - -int msm_audio_volume_update(unsigned id, - int volume, int pan) -{ - unsigned vol_raw; - - vol_raw = compute_db_raw(volume); - printk(KERN_INFO "volume: %8x vol_raw: %8x \n", volume, vol_raw); - return audpp_set_volume_and_pan(id, vol_raw, pan); -} -EXPORT_SYMBOL(msm_audio_volume_update); - -void alsa_dsp_event(void *data, unsigned id, uint16_t *msg) -{ - struct msm_audio *prtd = data; - struct buffer *frame; - unsigned long flag; - - switch (id) { - case AUDPP_MSG_STATUS_MSG: - break; - case AUDPP_MSG_SPA_BANDS: - break; - case AUDPP_MSG_HOST_PCM_INTF_MSG:{ - unsigned id = msg[2]; - unsigned idx = msg[3] - 1; - if (id != AUDPP_MSG_HOSTPCM_ID_ARM_RX) { - printk(KERN_ERR "bogus id\n"); - break; - } - if (idx > 1) { - printk(KERN_ERR "bogus buffer idx\n"); - break; - } - /* Update with actual sent buffer size */ - if (prtd->out[idx].used != BUF_INVALID_LEN) - prtd->pcm_irq_pos += prtd->out[idx].used; - - if (prtd->pcm_irq_pos > prtd->pcm_size) - prtd->pcm_irq_pos = prtd->pcm_count; - - if (prtd->ops->playback) - prtd->ops->playback(prtd); - - if (prtd->mmap_flag) - break; - - spin_lock_irqsave(&the_locks.write_dsp_lock, flag); - if (prtd->running) { - prtd->out[idx].used = 0; - frame = prtd->out + prtd->out_tail; - if (frame->used) { - alsa_dsp_send_buffer(prtd, - prtd->out_tail, - frame->used); - prtd->out_tail ^= 1; - } else { - prtd->out_needed++; - } - wake_up(&the_locks.write_wait); - } - spin_unlock_irqrestore(&the_locks.write_dsp_lock, flag); - break; - } - case AUDPP_MSG_PCMDMAMISSED: - pr_info("alsa_dsp_event: PCMDMAMISSED %d\n", msg[0]); - prtd->eos_ack = 1; - wake_up(&the_locks.eos_wait); - break; - case AUDPP_MSG_CFG_MSG: - if (msg[0] == AUDPP_MSG_ENA_ENA) { - prtd->out_needed = 0; - prtd->running = 1; - audio_dsp_out_enable(prtd, 1); - } else if (msg[0] == AUDPP_MSG_ENA_DIS) { - prtd->running = 0; - } else { - printk(KERN_ERR "alsa_dsp_event:CFG_MSG=%d\n", msg[0]); - } - break; - case EVENT_MSG_ID: - printk(KERN_INFO"alsa_dsp_event: arm9 event\n"); - break; - default: - printk(KERN_ERR "alsa_dsp_event: UNKNOWN (%d)\n", id); - } -} - -void alsa_audpre_dsp_event(void *data, unsigned id, size_t len, - void (*getevent) (void *ptr, size_t len)) -{ - uint16_t msg[MAX_DATA_SIZE/2]; - - if (len > MAX_DATA_SIZE) { - printk(KERN_ERR"audpre: event too large(%d bytes)\n", len); - return; - } - getevent(msg, len); - - switch (id) { - case AUDPREPROC_MSG_CMD_CFG_DONE_MSG: - break; - case AUDPREPROC_MSG_ERROR_MSG_ID: - printk(KERN_ERR "audpre: err_index %d\n", msg[0]); - break; - case EVENT_MSG_ID: - printk(KERN_INFO"audpre: arm9 event\n"); - break; - default: - printk(KERN_ERR "audpre: unknown event %d\n", id); - } -} - -void audrec_dsp_event(void *data, unsigned id, size_t len, - void (*getevent) (void *ptr, size_t len)) -{ - struct msm_audio *prtd = data; - unsigned long flag; - uint16_t msg[MAX_DATA_SIZE/2]; - - if (len > MAX_DATA_SIZE) { - printk(KERN_ERR"audrec: event/msg too large(%d bytes)\n", len); - return; - } - getevent(msg, len); - - switch (id) { - case AUDREC_MSG_CMD_CFG_DONE_MSG: - if (msg[0] & AUDREC_MSG_CFG_DONE_TYPE_0_UPDATE) { - if (msg[0] & AUDREC_MSG_CFG_DONE_TYPE_0_ENA) - audrec_encoder_config(prtd); - else - prtd->running = 0; - } - break; - case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG:{ - prtd->running = 1; - break; - } - case AUDREC_MSG_FATAL_ERR_MSG: - printk(KERN_ERR "audrec: ERROR %x\n", msg[0]); - break; - case AUDREC_MSG_PACKET_READY_MSG: - alsa_get_dsp_frames(prtd); - ++intcnt; - if (prtd->channel_mode == 1) { - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - prtd->pcm_irq_pos += prtd->pcm_count; - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - - if (prtd->ops->capture) - prtd->ops->capture(prtd); - } else if ((prtd->channel_mode == 0) && (intcnt % 2 == 0)) { - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - prtd->pcm_irq_pos += prtd->pcm_count; - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - if (prtd->ops->capture) - prtd->ops->capture(prtd); - } - break; - case EVENT_MSG_ID: - printk(KERN_INFO"audrec: arm9 event\n"); - break; - default: - printk(KERN_ERR "audrec: unknown event %d\n", id); - } -} - -struct msm_adsp_ops aud_pre_adsp_ops = { - .event = alsa_audpre_dsp_event, -}; - -struct msm_adsp_ops aud_rec_adsp_ops = { - .event = audrec_dsp_event, -}; - -int alsa_adsp_configure(struct msm_audio *prtd) -{ - int ret, i; - - if (prtd->dir == SNDRV_PCM_STREAM_PLAYBACK) { - prtd->data = prtd->playback_substream->dma_buffer.area; - prtd->phys = prtd->playback_substream->dma_buffer.addr; - } - if (prtd->dir == SNDRV_PCM_STREAM_CAPTURE) { - prtd->data = prtd->capture_substream->dma_buffer.area; - prtd->phys = prtd->capture_substream->dma_buffer.addr; - } - if (!prtd->data) { - ret = -ENOMEM; - goto err1; - } - - ret = audmgr_open(&prtd->audmgr); - if (ret) - goto err2; - if (prtd->dir == SNDRV_PCM_STREAM_PLAYBACK) { - prtd->out_buffer_size = PLAYBACK_DMASZ; - prtd->out_sample_rate = 44100; - prtd->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V; - prtd->out_weight = 100; - - prtd->out[0].data = prtd->data + 0; - prtd->out[0].addr = prtd->phys + 0; - prtd->out[0].size = BUFSZ; - prtd->out[1].data = prtd->data + BUFSZ; - prtd->out[1].addr = prtd->phys + BUFSZ; - prtd->out[1].size = BUFSZ; - } - if (prtd->dir == SNDRV_PCM_STREAM_CAPTURE) { - prtd->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_44100; - prtd->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_44100; - prtd->channel_mode = AUDREC_CMD_STEREO_MODE_STEREO; - prtd->buffer_size = STEREO_DATA_SIZE; - prtd->type = AUDREC_CMD_TYPE_0_INDEX_WAV; - prtd->tx_agc_cfg.cmd_id = AUDPREPROC_CMD_CFG_AGC_PARAMS; - prtd->ns_cfg.cmd_id = AUDPREPROC_CMD_CFG_NS_PARAMS; - prtd->iir_cfg.cmd_id = - AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS; - - ret = msm_adsp_get("AUDPREPROCTASK", - &prtd->audpre, &aud_pre_adsp_ops, prtd); - if (ret) - goto err3; - ret = msm_adsp_get("AUDRECTASK", - &prtd->audrec, &aud_rec_adsp_ops, prtd); - if (ret) { - msm_adsp_put(prtd->audpre); - goto err3; - } - prtd->dsp_cnt = 0; - prtd->in_head = 0; - prtd->in_tail = 0; - prtd->in_count = 0; - for (i = 0; i < FRAME_NUM; i++) { - prtd->in[i].size = 0; - prtd->in[i].read = 0; - } - } - - return 0; - -err3: - audmgr_close(&prtd->audmgr); - -err2: - prtd->data = NULL; -err1: - return ret; -} -EXPORT_SYMBOL(alsa_adsp_configure); - -int alsa_audio_configure(struct msm_audio *prtd) -{ - struct audmgr_config cfg; - int rc; - - if (prtd->enabled) - return 0; - - /* refuse to start if we're not ready with first buffer */ - if (!prtd->out[0].used) - return -EIO; - - cfg.tx_rate = 0; - cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; - cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM; - cfg.codec = RPC_AUD_DEF_CODEC_PCM; - cfg.snd_method = RPC_SND_METHOD_MIDI; - rc = audmgr_enable(&prtd->audmgr, &cfg); - if (rc < 0) - return rc; - - if (audpp_enable(AUDPP_ALSA_DECODER, alsa_dsp_event, prtd)) { - printk(KERN_ERR "audio: audpp_enable() failed\n"); - audmgr_disable(&prtd->audmgr); - return -ENODEV; - } - - prtd->enabled = 1; - return 0; -} -EXPORT_SYMBOL(alsa_audio_configure); - -ssize_t alsa_send_buffer(struct msm_audio *prtd, const char __user *buf, - size_t count, loff_t *pos) -{ - unsigned long flag; - const char __user *start = buf; - struct buffer *frame; - size_t xfer; - int rc = 0; - - mutex_lock(&the_locks.write_lock); - while (count > 0) { - frame = prtd->out + prtd->out_head; - rc = wait_event_interruptible(the_locks.write_wait, - (frame->used == 0) - || (prtd->stopped)); - if (rc < 0) - break; - if (prtd->stopped) { - rc = -EBUSY; - break; - } - xfer = count > frame->size ? frame->size : count; - if (copy_from_user(frame->data, buf, xfer)) { - rc = -EFAULT; - break; - } - frame->used = xfer; - prtd->out_head ^= 1; - count -= xfer; - buf += xfer; - - spin_lock_irqsave(&the_locks.write_dsp_lock, flag); - frame = prtd->out + prtd->out_tail; - if (frame->used && prtd->out_needed) { - alsa_dsp_send_buffer(prtd, prtd->out_tail, - frame->used); - prtd->out_tail ^= 1; - prtd->out_needed--; - } - spin_unlock_irqrestore(&the_locks.write_dsp_lock, flag); - } - mutex_unlock(&the_locks.write_lock); - if (buf > start) - return buf - start; - return rc; -} -EXPORT_SYMBOL(alsa_send_buffer); - -int alsa_audio_disable(struct msm_audio *prtd) -{ - if (prtd->enabled) { - mutex_lock(&the_locks.lock); - prtd->enabled = 0; - audio_dsp_out_enable(prtd, 0); - wake_up(&the_locks.write_wait); - audpp_disable(AUDPP_ALSA_DECODER, prtd); - audmgr_disable(&prtd->audmgr); - prtd->out_needed = 0; - mutex_unlock(&the_locks.lock); - } - return 0; -} -EXPORT_SYMBOL(alsa_audio_disable); - -int alsa_audrec_disable(struct msm_audio *prtd) -{ - if (prtd->enabled) { - mutex_lock(&the_locks.lock); - prtd->enabled = 0; - alsa_rec_dsp_enable(prtd, 0); - wake_up(&the_locks.read_wait); - msm_adsp_disable(prtd->audpre); - msm_adsp_disable(prtd->audrec); - audmgr_disable(&prtd->audmgr); - prtd->out_needed = 0; - prtd->opened = 0; - mutex_unlock(&the_locks.lock); - } - return 0; -} -EXPORT_SYMBOL(alsa_audrec_disable); - -static int audio_dsp_read_buffer(struct msm_audio *prtd, uint32_t read_cnt) -{ - audrec_cmd_packet_ext_ptr cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDREC_CMD_PACKET_EXT_PTR; - /* Both WAV and AAC use AUDREC_CMD_TYPE_0 */ - cmd.type = AUDREC_CMD_TYPE_0; - cmd.curr_rec_count_msw = read_cnt >> 16; - cmd.curr_rec_count_lsw = read_cnt; - - return audio_send_queue_recbs(prtd, &cmd, sizeof(cmd)); -} - -int audrec_encoder_config(struct msm_audio *prtd) -{ - audrec_cmd_arec0param_cfg cmd; - uint16_t *data = (void *)prtd->data; - unsigned n; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDREC_CMD_AREC0PARAM_CFG; - cmd.ptr_to_extpkt_buffer_msw = prtd->phys >> 16; - cmd.ptr_to_extpkt_buffer_lsw = prtd->phys; - cmd.buf_len = FRAME_NUM; /* Both WAV and AAC use 8 frames */ - cmd.samp_rate_index = prtd->samp_rate_index; - /* 0 for mono, 1 for stereo */ - cmd.stereo_mode = prtd->channel_mode; - cmd.rec_quality = 0x1C00; - - /* prepare buffer pointers: - * Mono: 1024 samples + 4 halfword header - * Stereo: 2048 samples + 4 halfword header - */ - - for (n = 0; n < FRAME_NUM; n++) { - prtd->in[n].data = data + 4; - data += (4 + (prtd->channel_mode ? 2048 : 1024)); - } - - return audio_send_queue_rec(prtd, &cmd, sizeof(cmd)); -} - -int audio_dsp_out_enable(struct msm_audio *prtd, int yes) -{ - audpp_cmd_pcm_intf cmd; - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDPP_CMD_PCM_INTF_2; - cmd.object_num = AUDPP_CMD_PCM_INTF_OBJECT_NUM; - cmd.config = AUDPP_CMD_PCM_INTF_CONFIG_CMD_V; - cmd.intf_type = AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V; - - if (yes) { - cmd.write_buf1LSW = prtd->out[0].addr; - cmd.write_buf1MSW = prtd->out[0].addr >> 16; - cmd.write_buf1_len = 0; - cmd.write_buf2LSW = prtd->out[1].addr; - cmd.write_buf2MSW = prtd->out[1].addr >> 16; - cmd.write_buf2_len = prtd->out[1].used; - cmd.arm_to_rx_flag = AUDPP_CMD_PCM_INTF_ENA_V; - cmd.weight_decoder_to_rx = prtd->out_weight; - cmd.weight_arm_to_rx = 1; - cmd.partition_number_arm_to_dsp = 0; - cmd.sample_rate = prtd->out_sample_rate; - cmd.channel_mode = prtd->out_channel_mode; - } - return audpp_send_queue2(&cmd, sizeof(cmd)); -} - -int alsa_buffer_read(struct msm_audio *prtd, void __user *buf, - size_t count, loff_t *pos) -{ - unsigned long flag; - void *data; - uint32_t index; - uint32_t size; - int rc = 0; - - mutex_lock(&the_locks.read_lock); - while (count > 0) { - rc = wait_event_interruptible(the_locks.read_wait, - (prtd->in_count > 0) - || prtd->stopped); - if (rc < 0) - break; - - if (prtd->stopped) { - rc = -EBUSY; - break; - } - - index = prtd->in_tail; - data = (uint8_t *) prtd->in[index].data; - size = prtd->in[index].size; - if (count >= size) { - if (copy_to_user(buf, data, size)) { - rc = -EFAULT; - break; - } - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - if (index != prtd->in_tail) { - /* overrun: data is invalid, we need to retry */ - spin_unlock_irqrestore(&the_locks.read_dsp_lock, - flag); - continue; - } - prtd->in[index].size = 0; - prtd->in_tail = (prtd->in_tail + 1) & (FRAME_NUM - 1); - prtd->in_count--; - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - count -= size; - buf += size; - } else { - break; - } - } - mutex_unlock(&the_locks.read_lock); - return rc; -} -EXPORT_SYMBOL(alsa_buffer_read); - -int alsa_dsp_send_buffer(struct msm_audio *prtd, - unsigned idx, unsigned len) -{ - audpp_cmd_pcm_intf_send_buffer cmd; - cmd.cmd_id = AUDPP_CMD_PCM_INTF_2; - cmd.host_pcm_object = AUDPP_CMD_PCM_INTF_OBJECT_NUM; - cmd.config = AUDPP_CMD_PCM_INTF_BUFFER_CMD_V; - cmd.intf_type = AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V; - cmd.dsp_to_arm_buf_id = 0; - cmd.arm_to_dsp_buf_id = idx + 1; - cmd.arm_to_dsp_buf_len = len; - return audpp_send_queue2(&cmd, sizeof(cmd)); -} - -int alsa_rec_dsp_enable(struct msm_audio *prtd, int enable) -{ - audrec_cmd_cfg cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDREC_CMD_CFG; - cmd.type_0 = enable ? AUDREC_CMD_TYPE_0_ENA : AUDREC_CMD_TYPE_0_DIS; - cmd.type_0 |= (AUDREC_CMD_TYPE_0_UPDATE | prtd->type); - cmd.type_1 = 0; - - return audio_send_queue_rec(prtd, &cmd, sizeof(cmd)); -} -EXPORT_SYMBOL(alsa_rec_dsp_enable); - -void alsa_get_dsp_frames(struct msm_audio *prtd) -{ - struct audio_frame *frame; - uint32_t index = 0; - unsigned long flag; - - if (prtd->type == AUDREC_CMD_TYPE_0_INDEX_WAV) { - index = prtd->in_head; - - frame = - (void *)(((char *)prtd->in[index].data) - sizeof(*frame)); - - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - prtd->in[index].size = frame->bytes; - - prtd->in_head = (prtd->in_head + 1) & (FRAME_NUM - 1); - - /* If overflow, move the tail index foward. */ - if (prtd->in_head == prtd->in_tail) - prtd->in_tail = (prtd->in_tail + 1) & (FRAME_NUM - 1); - else - prtd->in_count++; - - audio_dsp_read_buffer(prtd, prtd->dsp_cnt++); - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - - wake_up(&the_locks.read_wait); - } else { - /* TODO AAC not supported yet. */ - } -} -EXPORT_SYMBOL(alsa_get_dsp_frames); diff --git a/sound/soc/msm/msm-pcm.h b/sound/soc/msm/msm-pcm.h deleted file mode 100644 index eb4a722e893f3e54a21d1c280c6851cf4c19bbff..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-pcm.h +++ /dev/null @@ -1,204 +0,0 @@ -/* sound/soc/msm/msm-pcm.h - * - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2008-2009, 2012 The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#ifndef _MSM_PCM_H -#define _MSM_PCM_H - - -#include -#include -#include -#include -#include -#include -#include -#include <../arch/arm/mach-msm/qdsp5/adsp.h> -#include <../arch/arm/mach-msm/qdsp5/audmgr.h> - - -#define FRAME_NUM (8) -#define FRAME_SIZE (2052 * 2) -#define MONO_DATA_SIZE (2048) -#define STEREO_DATA_SIZE (MONO_DATA_SIZE * 2) -#define CAPTURE_DMASZ (FRAME_SIZE * FRAME_NUM) - -#define BUFSZ (960 * 5) -#define PLAYBACK_DMASZ (BUFSZ * 2) - -#define MSM_PLAYBACK_DEFAULT_VOLUME 0 /* 0dB */ -#define MSM_PLAYBACK_DEFAULT_PAN 0 - -#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE -#define USE_CHANNELS_MIN 1 -#define USE_CHANNELS_MAX 2 -/* Support unconventional sample rates 12000, 24000 as well */ -#define USE_RATE \ - (SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT) -#define USE_RATE_MIN 8000 -#define USE_RATE_MAX 48000 -#define MAX_BUFFER_PLAYBACK_SIZE \ - (4800*4) -/* 2048 frames (Mono), 1024 frames (Stereo) */ -#define CAPTURE_SIZE 4096 -#define MAX_BUFFER_CAPTURE_SIZE (4096*4) -#define MAX_PERIOD_SIZE BUFSZ -#define USE_PERIODS_MAX 1024 -#define USE_PERIODS_MIN 1 - - -#define MAX_DB (16) -#define MIN_DB (-50) -#define PCMPLAYBACK_DECODERID 5 - -/* 0xFFFFFFFF Indicates not to be used for audio data copy */ -#define BUF_INVALID_LEN 0xFFFFFFFF - -extern int copy_count; -extern int intcnt; - -struct msm_volume { - bool update; - int volume; /* Volume parameter, in dB Scale */ - int pan; -}; - -struct buffer { - void *data; - unsigned size; - unsigned used; - unsigned addr; -}; - -struct buffer_rec { - void *data; - unsigned int size; - unsigned int read; - unsigned int addr; -}; - -struct audio_locks { - struct mutex lock; - struct mutex write_lock; - struct mutex read_lock; - spinlock_t read_dsp_lock; - spinlock_t write_dsp_lock; - spinlock_t mixer_lock; - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; - wait_queue_head_t eos_wait; -}; - -extern struct audio_locks the_locks; - -struct msm_audio_event_callbacks { - /* event is called from interrupt context when a message - * arrives from the DSP. - */ - void (*playback)(void *); - void (*capture)(void *); -}; - - -struct msm_audio { - struct buffer out[2]; - struct buffer_rec in[8]; - - uint8_t out_head; - uint8_t out_tail; - uint8_t out_needed; /* number of buffers the dsp is waiting for */ - atomic_t out_bytes; - - /* configuration to use on next enable */ - uint32_t out_sample_rate; - uint32_t out_channel_mode; - uint32_t out_weight; - uint32_t out_buffer_size; - - struct audmgr audmgr; - struct snd_pcm_substream *playback_substream; - struct snd_pcm_substream *capture_substream; - - /* data allocated for various buffers */ - char *data; - dma_addr_t phys; - - unsigned int pcm_size; - unsigned int pcm_count; - unsigned int pcm_irq_pos; /* IRQ position */ - unsigned int pcm_buf_pos; /* position in buffer */ - - struct msm_adsp_module *audpre; - struct msm_adsp_module *audrec; - - /* configuration to use on next enable */ - uint32_t samp_rate; - uint32_t channel_mode; - uint32_t buffer_size; /* 2048 for mono, 4096 for stereo */ - uint32_t type; /* 0 for PCM ,1 for AAC */ - uint32_t dsp_cnt; - uint32_t in_head; /* next buffer dsp will write */ - uint32_t in_tail; /* next buffer read() will read */ - uint32_t in_count; /* number of buffers available to read() */ - - unsigned short samp_rate_index; - - /* audpre settings */ - audpreproc_cmd_cfg_agc_params tx_agc_cfg; - audpreproc_cmd_cfg_ns_params ns_cfg; - /* For different sample rate, the coeff might be different. * - * All the coeff should be passed from user space */ - audpreproc_cmd_cfg_iir_tuning_filter_params iir_cfg; - - struct msm_audio_event_callbacks *ops; - - int dir; - int opened; - int enabled; - int running; - int stopped; /* set when stopped, cleared on flush */ - int eos_ack; - int mmap_flag; - int period; -}; - - - -/* platform data */ -extern int alsa_dsp_send_buffer(struct msm_audio *prtd, - unsigned idx, unsigned len); -extern int audio_dsp_out_enable(struct msm_audio *prtd, int yes); -extern struct snd_soc_platform_driver msm_soc_platform; - -int audrec_encoder_config(struct msm_audio *prtd); -extern void alsa_get_dsp_frames(struct msm_audio *prtd); -extern int alsa_rec_dsp_enable(struct msm_audio *prtd, int enable); -extern int alsa_audrec_disable(struct msm_audio *prtd); -extern int alsa_audio_configure(struct msm_audio *prtd); -extern int alsa_audio_disable(struct msm_audio *prtd); -extern int alsa_adsp_configure(struct msm_audio *prtd); -extern int alsa_buffer_read(struct msm_audio *prtd, void __user *buf, - size_t count, loff_t *pos); -ssize_t alsa_send_buffer(struct msm_audio *prtd, const char __user *buf, - size_t count, loff_t *pos); -int msm_audio_volume_update(unsigned id, - int volume, int pan); -extern struct audio_locks the_locks; -extern struct msm_volume msm_vol_ctl; - -#endif /*_MSM_PCM_H*/ diff --git a/sound/soc/msm/msm-voip.c b/sound/soc/msm/msm-voip.c deleted file mode 100644 index 51e6c868fbd3c2fe6dee4856a7d82343fcd8cac3..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm-voip.c +++ /dev/null @@ -1,610 +0,0 @@ -/* Copyright (c) 2011, The Linux Foundation. All rights reserved. - * - * All source code in this file is licensed under the following license except - * where indicated. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm_audio_mvs.h" - - -static struct audio_voip_info_type audio_voip_info; -static void audio_mvs_process_ul_pkt(uint8_t *voc_pkt, - uint32_t pkt_len, - void *private_data); -static void audio_mvs_process_dl_pkt(uint8_t *voc_pkt, - uint32_t *pkt_len, - void *private_data); - -struct msm_audio_mvs_frame { - uint32_t frame_type; - uint32_t len; - uint8_t voc_pkt[MVS_MAX_VOC_PKT_SIZE]; -}; - -struct audio_mvs_buf_node { - struct list_head list; - struct msm_audio_mvs_frame frame; -}; - -static struct snd_pcm_hardware msm_pcm_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = (SNDRV_PCM_RATE_8000), - .rate_min = 8000, - .rate_max = 8000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN, - .period_bytes_min = MVS_MAX_VOC_PKT_SIZE, - .period_bytes_max = MVS_MAX_VOC_PKT_SIZE, - .periods_min = VOIP_MAX_Q_LEN, - .periods_max = VOIP_MAX_Q_LEN, - .fifo_size = 0, -}; - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - - struct audio_voip_info_type *audio = &audio_voip_info; - pr_debug("%s\n", __func__); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - audio->playback_start = 1; - else - audio->capture_start = 1; - break; - case SNDRV_PCM_TRIGGER_STOP: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - audio->playback_start = 0; - else - audio->capture_start = 0; - break; - default: - break; - } - return 0; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int rc = 0; - struct audio_voip_info_type *audio = &audio_voip_info; - struct audio_mvs_release_msg release_msg; - - pr_debug("%s\n", __func__); - memset(&release_msg, 0, sizeof(release_msg)); - mutex_lock(&audio->lock); - - audio->instance--; - wake_up(&audio->out_wait); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - audio->playback_state = AUDIO_MVS_CLOSED; - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - audio->capture_state = AUDIO_MVS_CLOSED; - if (!audio->instance) { - /* Release MVS. */ - release_msg.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP); - /* Derigstering the callbacks with voice driver */ - voice_register_mvs_cb(NULL, NULL, audio); - } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - voice_register_mvs_cb(audio_mvs_process_ul_pkt, - NULL, audio); - } else { - voice_register_mvs_cb(NULL, audio_mvs_process_dl_pkt, - audio); - } - - mutex_unlock(&audio->lock); - - wake_unlock(&audio->suspend_lock); - pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE); - /* Release the IO buffers. */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - audio->in_write = 0; - audio->in_read = 0; - memset(audio->in[0].voc_pkt, 0, - MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN); - audio->playback_substream = NULL; - } else { - audio->out_write = 0; - audio->out_read = 0; - memset(audio->out[0].voc_pkt, 0, - MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN); - audio->capture_substream = NULL; - } - return rc; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_voip_info_type *audio = &audio_voip_info; - - pr_debug("%s\n", __func__); - mutex_lock(&audio->lock); - - if (audio->playback_substream == NULL || - audio->capture_substream == NULL) { - if (substream->stream == - SNDRV_PCM_STREAM_PLAYBACK) { - audio->playback_substream = substream; - runtime->hw = msm_pcm_hardware; - audio_voip_info.in_read = 0; - audio_voip_info.in_write = 0; - if (audio->playback_state < AUDIO_MVS_OPENED) - audio->playback_state = AUDIO_MVS_OPENED; - } else if (substream->stream == - SNDRV_PCM_STREAM_CAPTURE) { - audio->capture_substream = substream; - runtime->hw = msm_pcm_hardware; - audio_voip_info.out_read = 0; - audio_voip_info.out_write = 0; - if (audio->capture_state < AUDIO_MVS_OPENED) - audio->capture_state = AUDIO_MVS_OPENED; - } - } else { - ret = -EPERM; - goto err; - } - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) { - pr_debug("%s:snd_pcm_hw_constraint_integer failed\n", __func__); - goto err; - } - audio->instance++; - -err: - mutex_unlock(&audio->lock); - return ret; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int rc = 0; - int count = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_voip_info_type *audio = &audio_voip_info; - uint32_t index; - pr_debug("%s\n", __func__); - - rc = wait_event_timeout(audio->in_wait, - (audio->in_write - audio->in_read <= VOIP_MAX_Q_LEN-1), - 1 * HZ); - if (rc < 0) { - pr_debug("%s: write was interrupted\n", __func__); - return -ERESTARTSYS; - } - - if (audio->playback_state == AUDIO_MVS_ENABLED) { - index = audio->in_write % VOIP_MAX_Q_LEN; - count = frames_to_bytes(runtime, frames); - if (count == MVS_MAX_VOC_PKT_SIZE) { - pr_debug("%s:write index = %d\n", __func__, index); - rc = copy_from_user(audio->in[index].voc_pkt, buf, - count); - if (!rc) { - audio->in[index].len = count; - audio->in_write++; - } else { - pr_debug("%s:Copy from user returned %d\n", - __func__, rc); - rc = -EFAULT; - } - } else - rc = -ENOMEM; - - } else { - pr_debug("%s:Write performed in invalid state %d\n", - __func__, audio->playback_state); - rc = -EINVAL; - } - return rc; -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, - void __user *buf, snd_pcm_uframes_t frames) -{ - int rc = 0; - int count = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_voip_info_type *audio = &audio_voip_info; - uint32_t index = 0; - - pr_debug("%s\n", __func__); - - /* Ensure the driver has been enabled. */ - if (audio->capture_state != AUDIO_MVS_ENABLED) { - pr_debug("%s:Read performed in invalid state %d\n", - __func__, audio->capture_state); - return -EPERM; - } - rc = wait_event_timeout(audio->out_wait, - ((audio->out_read < audio->out_write) || - (audio->capture_state == AUDIO_MVS_CLOSING) || - (audio->capture_state == AUDIO_MVS_CLOSED)), - 1 * HZ); - - if (rc < 0) { - pr_debug("%s: Read was interrupted\n", __func__); - return -ERESTARTSYS; - } - - if (audio->capture_state == AUDIO_MVS_CLOSING - || audio->capture_state == AUDIO_MVS_CLOSED) { - pr_debug("%s:EBUSY STATE\n", __func__); - rc = -EBUSY; - } else { - count = frames_to_bytes(runtime, frames); - index = audio->out_read % VOIP_MAX_Q_LEN; - pr_debug("%s:index=%d\n", __func__, index); - if (audio->out[index].len <= count) { - rc = copy_to_user(buf, - audio->out[index].voc_pkt, - audio->out[index].len); - if (rc) { - pr_debug("%s:Copy to user %d\n", - __func__, rc); - rc = -EFAULT; - } else - audio->out_read++; - } else { - pr_debug("%s:returning ENOMEM\n", __func__); - rc = -ENOMEM; - } - } - return rc; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - pr_debug("%s\n", __func__); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -/* Capture path */ -static void audio_mvs_process_ul_pkt(uint8_t *voc_pkt, - uint32_t pkt_len, - void *private_data) -{ - struct audio_voip_info_type *audio = private_data; - uint32_t index; - static int i; - pr_debug("%s\n", __func__); - - if (audio->capture_substream == NULL) - return; - index = audio->out_write % VOIP_MAX_Q_LEN; - memcpy(audio->out[index].voc_pkt, voc_pkt, pkt_len); - audio->out[index].len = pkt_len; - audio->out_write++; - wake_up(&audio->out_wait); - i++; - if (audio->capture_start) { - audio->pcm_capture_irq_pos += audio->pcm_count; - if (!(i % 2)) - snd_pcm_period_elapsed(audio->capture_substream); - } -} - -/* Playback path */ -static void audio_mvs_process_dl_pkt(uint8_t *voc_pkt, - uint32_t *pkt_len, - void *private_data) -{ - struct audio_voip_info_type *audio = private_data; - uint32_t index; - static int i; - pr_debug("%s\n", __func__); - - if (audio->playback_substream == NULL) - return; - if ((audio->in_write - audio->in_read >= 0) - && (audio->playback_start)) { - index = audio->in_read % VOIP_MAX_Q_LEN; - *pkt_len = audio->pcm_count; - memcpy(voc_pkt, audio->in[index].voc_pkt, *pkt_len); - audio->in_read++; - wake_up(&audio->in_wait); - i++; - audio->pcm_playback_irq_pos += audio->pcm_count; - if (!(i%2)) - snd_pcm_period_elapsed(audio->playback_substream); - pr_debug("%s:read_index=%d\n", __func__, index); - } -} - -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int rc = 0; - struct audio_voip_info_type *prtd = &audio_voip_info; - pr_debug("%s\n", __func__); - prtd->pcm_playback_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - pr_debug("%s:prtd->pcm_playback_size:%d\n", - __func__, prtd->pcm_playback_size); - pr_debug("%s:prtd->pcm_count:%d\n", __func__, prtd->pcm_count); - - mutex_lock(&prtd->prepare_lock); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (prtd->playback_state == AUDIO_MVS_ENABLED) - goto enabled; - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (prtd->capture_state == AUDIO_MVS_ENABLED) - goto enabled; - } - - pr_debug("%s:Register cbs with voice driver check audio_mvs_driver\n", - __func__); - if (prtd->instance == 2) { - voice_register_mvs_cb(audio_mvs_process_ul_pkt, - audio_mvs_process_dl_pkt, - prtd); - } else { - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - voice_register_mvs_cb(NULL, - audio_mvs_process_dl_pkt, - prtd); - } else { - voice_register_mvs_cb(audio_mvs_process_ul_pkt, - NULL, - prtd); - } - } - -enabled: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - prtd->playback_state = AUDIO_MVS_ENABLED; - prtd->pcm_playback_irq_pos = 0; - prtd->pcm_playback_buf_pos = 0; - /* rate and channels are sent to audio driver */ - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - prtd->capture_state = AUDIO_MVS_ENABLED; - prtd->pcm_capture_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_capture_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_capture_irq_pos = 0; - prtd->pcm_capture_buf_pos = 0; - } - mutex_unlock(&prtd->prepare_lock); - return rc; -} - -static snd_pcm_uframes_t -msm_pcm_playback_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_voip_info_type *audio = &audio_voip_info; - - if (audio->pcm_playback_irq_pos >= audio->pcm_playback_size) - audio->pcm_playback_irq_pos = 0; - return bytes_to_frames(runtime, (audio->pcm_playback_irq_pos)); -} - -static snd_pcm_uframes_t -msm_pcm_capture_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct audio_voip_info_type *audio = &audio_voip_info; - - if (audio->pcm_capture_irq_pos >= audio->pcm_capture_size) - audio->pcm_capture_irq_pos = 0; - return bytes_to_frames(runtime, (audio->pcm_capture_irq_pos)); -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - snd_pcm_uframes_t ret = 0; - pr_debug("%s\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_pointer(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_pointer(substream); - return ret; -} - -static struct snd_pcm_ops msm_mvs_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - -}; - -static int msm_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - int i, ret, offset = 0; - struct snd_pcm_substream *substream = NULL; - struct snd_dma_buffer *dma_buffer = NULL; - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm; - - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1); - if (ret) - return ret; - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, 1); - if (ret) - return ret; - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &msm_mvs_pcm_ops); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &msm_mvs_pcm_ops); - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - - substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; - if (!substream) - return -ENOMEM; - - dma_buffer = &substream->dma_buffer; - dma_buffer->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buffer->dev.dev = card->dev; - dma_buffer->private_data = NULL; - dma_buffer->area = dma_alloc_coherent(card->dev, - (MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN), - &dma_buffer->addr, GFP_KERNEL); - if (!dma_buffer->area) { - pr_err("%s:MSM VOIP dma_alloc failed\n", __func__); - return -ENOMEM; - } - dma_buffer->bytes = MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN; - memset(dma_buffer->area, 0, MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN); - audio_voip_info.in_read = 0; - audio_voip_info.in_write = 0; - audio_voip_info.out_read = 0; - audio_voip_info.out_write = 0; - for (i = 0; i < VOIP_MAX_Q_LEN; i++) { - audio_voip_info.in[i].voc_pkt = - dma_buffer->area + offset; - offset = offset + MVS_MAX_VOC_PKT_SIZE; - } - substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; - if (!substream) - return -ENOMEM; - - dma_buffer = &substream->dma_buffer; - dma_buffer->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buffer->dev.dev = card->dev; - dma_buffer->private_data = NULL; - dma_buffer->area = dma_alloc_coherent(card->dev, - (MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN), - &dma_buffer->addr, GFP_KERNEL); - if (!dma_buffer->area) { - pr_err("%s:MSM VOIP dma_alloc failed\n", __func__); - return -ENOMEM; - } - memset(dma_buffer->area, 0, MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN); - dma_buffer->bytes = MVS_MAX_VOC_PKT_SIZE * VOIP_MAX_Q_LEN; - for (i = 0; i < VOIP_MAX_Q_LEN; i++) { - audio_voip_info.out[i].voc_pkt = - dma_buffer->area + offset; - offset = offset + MVS_MAX_VOC_PKT_SIZE; - } - audio_voip_info.playback_substream = NULL; - audio_voip_info.capture_substream = NULL; - - return 0; -} - -static void msm_pcm_free_buffers(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_coherent(pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area = NULL; - } -} - -struct snd_soc_platform_driver msm_mvs_soc_platform = { - .ops = &msm_mvs_pcm_ops, - .pcm_new = msm_pcm_new, - .pcm_free = msm_pcm_free_buffers, -}; -EXPORT_SYMBOL(msm_mvs_soc_platform); - -static int msm_pcm_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_mvs_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-mvs-audio", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_mvs_soc_platform_init(void) -{ - memset(&audio_voip_info, 0, sizeof(audio_voip_info)); - mutex_init(&audio_voip_info.lock); - mutex_init(&audio_voip_info.prepare_lock); - init_waitqueue_head(&audio_voip_info.out_wait); - init_waitqueue_head(&audio_voip_info.in_wait); - wake_lock_init(&audio_voip_info.suspend_lock, WAKE_LOCK_SUSPEND, - "audio_mvs_suspend"); - pm_qos_add_request(&audio_voip_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY, - PM_QOS_DEFAULT_VALUE); - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_mvs_soc_platform_init); - -static void __exit msm_mvs_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_mvs_soc_platform_exit); - -MODULE_DESCRIPTION("MVS PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm7201.c b/sound/soc/msm/msm7201.c deleted file mode 100644 index f3d8e648e4920885e42483f6adcf838426717fb3..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm7201.c +++ /dev/null @@ -1,424 +0,0 @@ -/* linux/sound/soc/msm/msm7201.c - * - * Copyright (c) 2008-2009, 2011, 2012 The Linux Foundation. All rights reserved. - * - * All source code in this file is licensed under the following license except - * where indicated. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm.h" -#include - -static struct msm_rpc_endpoint *snd_ep; -static uint32_t snd_mute_ear_mute; -static uint32_t snd_mute_mic_mute; - -struct msm_snd_rpc_ids { - unsigned long prog; - unsigned long vers; - unsigned long rpc_set_snd_device; - unsigned long rpc_set_device_vol; - struct cad_devices_type device; -}; - -struct rpc_cad_set_device_args { - struct cad_devices_type device; - uint32_t ear_mute; - uint32_t mic_mute; - - uint32_t cb_func; - uint32_t client_data; -}; - -struct rpc_cad_set_volume_args { - struct cad_devices_type device; - uint32_t method; - uint32_t volume; - - uint32_t cb_func; - uint32_t client_data; -}; - -static struct msm_snd_rpc_ids snd_rpc_ids; - -static struct platform_device *msm_audio_snd_device; - -static int snd_msm_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; /* Volume Param, in dB */ - uinfo->value.integer.min = MIN_DB; - uinfo->value.integer.max = MAX_DB; - return 0; -} - -static int snd_msm_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - spin_lock_irq(&the_locks.mixer_lock); - ucontrol->value.integer.value[0] = msm_vol_ctl.volume; - spin_unlock_irq(&the_locks.mixer_lock); - return 0; -} - -static int snd_msm_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int change; - int volume; - - volume = ucontrol->value.integer.value[0]; - spin_lock_irq(&the_locks.mixer_lock); - change = (msm_vol_ctl.volume != volume); - if (change) { - msm_vol_ctl.volume = volume; - msm_audio_volume_update(PCMPLAYBACK_DECODERID, - msm_vol_ctl.volume, msm_vol_ctl.pan); - } - spin_unlock_irq(&the_locks.mixer_lock); - return 0; -} - -static int snd_msm_device_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 4; /* Device */ - - /* - * The number of devices supported is 26 (0 to 25) - */ - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 36; - return 0; -} - -static int snd_msm_device_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] - = (uint32_t)snd_rpc_ids.device.rx_device; - ucontrol->value.integer.value[1] - = (uint32_t)snd_rpc_ids.device.tx_device; - ucontrol->value.integer.value[2] = snd_mute_ear_mute; - ucontrol->value.integer.value[3] = snd_mute_mic_mute; - return 0; -} - -int msm_snd_init_rpc_ids(void) -{ - snd_rpc_ids.prog = 0x30000002; - snd_rpc_ids.vers = 0x00030003; - /* - * The magic number 2 corresponds to the rpc call - * index for snd_set_device - */ - snd_rpc_ids.rpc_set_snd_device = 40; - snd_rpc_ids.rpc_set_device_vol = 39; - return 0; -} - -int msm_snd_rpc_connect(void) -{ - if (snd_ep) { - printk(KERN_INFO "%s: snd_ep already connected\n", __func__); - return 0; - } - - /* Initialize rpc ids */ - if (msm_snd_init_rpc_ids()) { - pr_err("%s: snd rpc ids initialization failed\n" - , __func__); - return -ENODATA; - } - - snd_ep = msm_rpc_connect_compatible(snd_rpc_ids.prog, - snd_rpc_ids.vers, 0); - if (IS_ERR(snd_ep)) { - pr_err("%s: failed (compatible VERS = %ld)\n", - __func__, snd_rpc_ids.vers); - snd_ep = NULL; - return -EAGAIN; - } - return 0; -} - -int msm_snd_rpc_close(void) -{ - int rc = 0; - - if (IS_ERR(snd_ep)) { - pr_err("%s: snd handle unavailable, rc = %ld\n", - __func__, PTR_ERR(snd_ep)); - return -EAGAIN; - } - - rc = msm_rpc_close(snd_ep); - snd_ep = NULL; - - if (rc < 0) { - pr_err("%s: close rpc failed! rc = %d\n", - __func__, rc); - return -EAGAIN; - } else - printk(KERN_INFO "rpc close success\n"); - - return rc; -} - -static int snd_msm_device_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - struct snd_cad_set_device_msg { - struct rpc_request_hdr hdr; - struct rpc_cad_set_device_args args; - } dmsg; - - snd_rpc_ids.device.rx_device - = (int)ucontrol->value.integer.value[0]; - snd_rpc_ids.device.tx_device - = (int)ucontrol->value.integer.value[1]; - snd_rpc_ids.device.pathtype = CAD_DEVICE_PATH_RX_TX; - - dmsg.args.device.rx_device - = cpu_to_be32(snd_rpc_ids.device.rx_device); - dmsg.args.device.tx_device - = cpu_to_be32(snd_rpc_ids.device.tx_device); - dmsg.args.device.pathtype = cpu_to_be32(CAD_DEVICE_PATH_RX_TX); - dmsg.args.ear_mute = cpu_to_be32(ucontrol->value.integer.value[2]); - dmsg.args.mic_mute = cpu_to_be32(ucontrol->value.integer.value[3]); - if (!(dmsg.args.ear_mute == SND_MUTE_MUTED || - dmsg.args.ear_mute == SND_MUTE_UNMUTED) || - (!(dmsg.args.mic_mute == SND_MUTE_MUTED || - dmsg.args.ear_mute == SND_MUTE_UNMUTED))) { - pr_err("snd_cad_ioctl set device: invalid mute status\n"); - rc = -EINVAL; - return rc; - } - dmsg.args.cb_func = -1; - dmsg.args.client_data = 0; - - rc = msm_rpc_call(snd_ep, snd_rpc_ids.rpc_set_snd_device , - &dmsg, sizeof(dmsg), 5 * HZ); - - if (rc < 0) { - pr_err("%s: snd rpc call failed! rc = %d\n", - __func__, rc); - } else { - printk(KERN_INFO "snd device connected\n"); - snd_mute_ear_mute = ucontrol->value.integer.value[2]; - snd_mute_mic_mute = ucontrol->value.integer.value[3]; - pr_err("%s: snd_mute_ear_mute =%d, snd_mute_mic_mute = %d\n", - __func__, snd_mute_ear_mute, snd_mute_mic_mute); - } - - return rc; -} - -static int snd_msm_device_vol_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; /* Device/Volume */ - - /* - * The volume ranges from (0 to 6) - */ - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 6; - return 0; -} - -static int snd_msm_device_vol_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - - struct snd_cad_set_volume_msg { - struct rpc_request_hdr hdr; - struct rpc_cad_set_volume_args args; - } vmsg; - - vmsg.args.device.rx_device - = cpu_to_be32(snd_rpc_ids.device.rx_device); - vmsg.args.device.tx_device - = cpu_to_be32(snd_rpc_ids.device.tx_device); - vmsg.args.method = cpu_to_be32(SND_METHOD_VOICE); - vmsg.args.volume = cpu_to_be32(ucontrol->value.integer.value[0]); - vmsg.args.cb_func = -1; - vmsg.args.client_data = 0; - - rc = msm_rpc_call(snd_ep, snd_rpc_ids.rpc_set_device_vol , - &vmsg, sizeof(vmsg), 5 * HZ); - - if (rc < 0) { - pr_err("%s: snd rpc call failed! rc = %d\n", - __func__, rc); - } else { - pr_debug("%s:rx device [%d]", __func__, - snd_rpc_ids.device.rx_device); - pr_debug("%s:tx device [%d]", __func__, - snd_rpc_ids.device.tx_device); - pr_debug("%s:volume set to [%ld]\n", __func__, - snd_rpc_ids.rpc_set_device_vol); - } - - return rc; -} - -/* Supported range -50dB to 18dB */ -static const DECLARE_TLV_DB_LINEAR(db_scale_linear, -5000, 1800); - -#define MSM_EXT(xname, xindex, fp_info, fp_get, fp_put, addr) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .name = xname, .index = xindex, \ - .info = fp_info,\ - .get = fp_get, .put = fp_put, \ - .private_value = addr, \ -} - -#define MSM_EXT_TLV(xname, xindex, fp_info, fp_get, fp_put, addr, tlv_array) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ - .access = (SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ - SNDRV_CTL_ELEM_ACCESS_READWRITE), \ - .name = xname, .index = xindex, \ - .info = fp_info,\ - .get = fp_get, .put = fp_put, .tlv.p = tlv_array, \ - .private_value = addr, \ -} - -static struct snd_kcontrol_new snd_msm_controls[] = { - MSM_EXT_TLV("PCM Playback Volume", 0, snd_msm_volume_info, \ - snd_msm_volume_get, snd_msm_volume_put, 0, db_scale_linear), - MSM_EXT("device", 0, snd_msm_device_info, snd_msm_device_get, \ - snd_msm_device_put, 0), - MSM_EXT("Device Volume", 0, snd_msm_device_vol_info, NULL, \ - snd_msm_device_vol_put, 0), -}; - -static int msm_new_mixer(struct snd_soc_codec *codec) -{ - unsigned int idx; - int err; - - pr_err("msm_soc: ALSA MSM Mixer Setting\n"); - strcpy(codec->card->snd_card->mixername, "MSM Mixer"); - for (idx = 0; idx < ARRAY_SIZE(snd_msm_controls); idx++) { - err = snd_ctl_add(codec->card->snd_card, - snd_ctl_new1(&snd_msm_controls[idx], NULL)); - if (err < 0) - return err; - } - return 0; -} - -static int msm_soc_dai_init( - struct snd_soc_pcm_runtime *rtd) -{ - int ret = 0; - struct snd_soc_codec *codec = rtd->codec; - - mutex_init(&the_locks.lock); - mutex_init(&the_locks.write_lock); - mutex_init(&the_locks.read_lock); - spin_lock_init(&the_locks.read_dsp_lock); - spin_lock_init(&the_locks.write_dsp_lock); - spin_lock_init(&the_locks.mixer_lock); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - msm_vol_ctl.volume = MSM_PLAYBACK_DEFAULT_VOLUME; - msm_vol_ctl.pan = MSM_PLAYBACK_DEFAULT_PAN; - - ret = msm_new_mixer(codec); - if (ret < 0) { - pr_err("msm_soc: ALSA MSM Mixer Fail\n"); - } - - return ret; -} - -static struct snd_soc_dai_link msm_dai[] = { -{ - .name = "MSM Primary I2S", - .stream_name = "DSP 1", - .cpu_dai_name = "msm-cpu-dai.0", - .platform_name = "msm-dsp-audio.0", - .codec_name = "msm-codec-dai.0", - .codec_dai_name = "msm-codec-dai", - .init = &msm_soc_dai_init, -}, -}; - -static struct snd_soc_card snd_soc_card_msm = { - .name = "msm-audio", - .dai_link = msm_dai, - .num_links = ARRAY_SIZE(msm_dai), -}; - -static int __init msm_audio_init(void) -{ - int ret; - - msm_audio_snd_device = platform_device_alloc("soc-audio", -1); - if (!msm_audio_snd_device) - return -ENOMEM; - - platform_set_drvdata(msm_audio_snd_device, &snd_soc_card_msm); - ret = platform_device_add(msm_audio_snd_device); - if (ret) { - platform_device_put(msm_audio_snd_device); - return ret; - } - - ret = msm_snd_rpc_connect(); - snd_mute_ear_mute = 0; - snd_mute_mic_mute = 0; - - return ret; -} - -static void __exit msm_audio_exit(void) -{ - msm_snd_rpc_close(); - platform_device_unregister(msm_audio_snd_device); -} - -module_init(msm_audio_init); -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("PCM module"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm7k-pcm.c b/sound/soc/msm/msm7k-pcm.c deleted file mode 100644 index 841bfb81cd2161e5e3705c8ba5adc108ce1bbd42..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm7k-pcm.c +++ /dev/null @@ -1,699 +0,0 @@ -/* linux/sound/soc/msm/msm7k-pcm.c - * - * Copyright (c) 2008-2009, 2012 The Linux Foundation. All rights reserved. - * - * All source code in this file is licensed under the following license except - * where indicated. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm-pcm.h" - -#define SND_DRIVER "snd_msm" -#define MAX_PCM_DEVICES SNDRV_CARDS -#define MAX_PCM_SUBSTREAMS 1 - -struct snd_msm { - struct snd_card *card; - struct snd_pcm *pcm; -}; - -int copy_count; - -struct audio_locks the_locks; -EXPORT_SYMBOL(the_locks); -struct msm_volume msm_vol_ctl; -EXPORT_SYMBOL(msm_vol_ctl); - - -static unsigned convert_dsp_samp_index(unsigned index) -{ - switch (index) { - case 48000: - return AUDREC_CMD_SAMP_RATE_INDX_48000; - case 44100: - return AUDREC_CMD_SAMP_RATE_INDX_44100; - case 32000: - return AUDREC_CMD_SAMP_RATE_INDX_32000; - case 24000: - return AUDREC_CMD_SAMP_RATE_INDX_24000; - case 22050: - return AUDREC_CMD_SAMP_RATE_INDX_22050; - case 16000: - return AUDREC_CMD_SAMP_RATE_INDX_16000; - case 12000: - return AUDREC_CMD_SAMP_RATE_INDX_12000; - case 11025: - return AUDREC_CMD_SAMP_RATE_INDX_11025; - case 8000: - return AUDREC_CMD_SAMP_RATE_INDX_8000; - default: - return AUDREC_CMD_SAMP_RATE_INDX_44100; - } -} - -static unsigned convert_samp_rate(unsigned hz) -{ - switch (hz) { - case 48000: - return RPC_AUD_DEF_SAMPLE_RATE_48000; - case 44100: - return RPC_AUD_DEF_SAMPLE_RATE_44100; - case 32000: - return RPC_AUD_DEF_SAMPLE_RATE_32000; - case 24000: - return RPC_AUD_DEF_SAMPLE_RATE_24000; - case 22050: - return RPC_AUD_DEF_SAMPLE_RATE_22050; - case 16000: - return RPC_AUD_DEF_SAMPLE_RATE_16000; - case 12000: - return RPC_AUD_DEF_SAMPLE_RATE_12000; - case 11025: - return RPC_AUD_DEF_SAMPLE_RATE_11025; - case 8000: - return RPC_AUD_DEF_SAMPLE_RATE_8000; - default: - return RPC_AUD_DEF_SAMPLE_RATE_44100; - } -} - -static struct snd_pcm_hardware msm_pcm_playback_hardware = { - .info = SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED, - .formats = USE_FORMATS, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .buffer_bytes_max = 4800 * 2, - .period_bytes_min = 4800, - .period_bytes_max = 4800, - .periods_min = 2, - .periods_max = 2, - .fifo_size = 0, -}; - -static struct snd_pcm_hardware msm_pcm_capture_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED, - .formats = USE_FORMATS, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .buffer_bytes_max = MAX_BUFFER_CAPTURE_SIZE, - .period_bytes_min = CAPTURE_SIZE, - .period_bytes_max = CAPTURE_SIZE, - .periods_min = USE_PERIODS_MIN, - .periods_max = USE_PERIODS_MAX, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static void msm_pcm_enqueue_data(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - unsigned int period_size; - - pr_debug("prtd->out_tail =%d mmap_flag=%d\n", - prtd->out_tail, prtd->mmap_flag); - period_size = snd_pcm_lib_period_bytes(substream); - alsa_dsp_send_buffer(prtd, prtd->out_tail, period_size); - prtd->out_tail ^= 1; - ++copy_count; - prtd->period++; - if (unlikely(prtd->period >= runtime->periods)) - prtd->period = 0; - -} - -static void playback_event_handler(void *data) -{ - struct msm_audio *prtd = data; - snd_pcm_period_elapsed(prtd->playback_substream); - if (prtd->mmap_flag) { - if (prtd->dir == SNDRV_PCM_STREAM_CAPTURE) - return; - if (!prtd->stopped) - msm_pcm_enqueue_data(prtd->playback_substream); - else - prtd->out_needed++; - } -} - -static void capture_event_handler(void *data) -{ - struct msm_audio *prtd = data; - snd_pcm_period_elapsed(prtd->capture_substream); -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - prtd->pcm_buf_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->out_sample_rate = runtime->rate; - prtd->out_channel_mode = runtime->channels; - - if (prtd->enabled | !(prtd->mmap_flag)) - return 0; - - prtd->data = substream->dma_buffer.area; - prtd->phys = substream->dma_buffer.addr; - prtd->out[0].data = prtd->data + 0; - prtd->out[0].addr = prtd->phys + 0; - prtd->out[0].size = BUFSZ; - prtd->out[1].data = prtd->data + BUFSZ; - prtd->out[1].addr = prtd->phys + BUFSZ; - prtd->out[1].size = BUFSZ; - - prtd->out[0].used = prtd->pcm_count; - prtd->out[1].used = prtd->pcm_count; - - mutex_lock(&the_locks.lock); - alsa_audio_configure(prtd); - mutex_unlock(&the_locks.lock); - - - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - struct audmgr_config cfg; - int rc; - - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - prtd->pcm_buf_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->samp_rate = convert_samp_rate(runtime->rate); - prtd->samp_rate_index = convert_dsp_samp_index(runtime->rate); - prtd->channel_mode = (runtime->channels - 1); - prtd->buffer_size = prtd->channel_mode ? STEREO_DATA_SIZE : \ - MONO_DATA_SIZE; - - if (prtd->enabled == 1) - return 0; - - prtd->type = AUDREC_CMD_TYPE_0_INDEX_WAV; - - cfg.tx_rate = convert_samp_rate(runtime->rate); - cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; - cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; - cfg.codec = RPC_AUD_DEF_CODEC_PCM; - cfg.snd_method = RPC_SND_METHOD_MIDI; - - rc = audmgr_enable(&prtd->audmgr, &cfg); - if (rc < 0) - return rc; - - if (msm_adsp_enable(prtd->audpre)) { - audmgr_disable(&prtd->audmgr); - return -ENODEV; - } - if (msm_adsp_enable(prtd->audrec)) { - msm_adsp_disable(prtd->audpre); - audmgr_disable(&prtd->audmgr); - return -ENODEV; - } - prtd->enabled = 1; - alsa_rec_dsp_enable(prtd, 1); - - return 0; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - unsigned long flag = 0; - int ret = 0; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) - || !prtd->mmap_flag) - break; - if (!prtd->out_needed) { - prtd->stopped = 0; - break; - } - spin_lock_irqsave(&the_locks.write_dsp_lock, flag); - if (prtd->running == 1) { - if (prtd->stopped == 1) { - prtd->stopped = 0; - prtd->period = 0; - if (prtd->pcm_irq_pos == 0) { - prtd->out_tail = 0; - msm_pcm_enqueue_data( - prtd->playback_substream); - prtd->out_needed--; - } else { - prtd->out_tail = 1; - msm_pcm_enqueue_data( - prtd->playback_substream); - prtd->out_needed--; - } - if (prtd->out_needed) { - prtd->out_tail ^= 1; - msm_pcm_enqueue_data( - prtd->playback_substream); - prtd->out_needed--; - } - } - } - spin_unlock_irqrestore(&the_locks.write_dsp_lock, flag); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) - || !prtd->mmap_flag) - break; - prtd->stopped = 1; - break; - default: - ret = -EINVAL; - } - - return ret; -} - -static snd_pcm_uframes_t -msm_pcm_playback_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - if (prtd->pcm_irq_pos == prtd->pcm_size) - prtd->pcm_irq_pos = 0; - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int rc = 0, rc1 = 0, rc2 = 0; - int fbytes = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = substream->runtime->private_data; - - int monofbytes = 0; - char *bufferp = NULL; - - fbytes = frames_to_bytes(runtime, frames); - monofbytes = fbytes / 2; - if (runtime->channels == 2) { - rc = alsa_buffer_read(prtd, buf, fbytes, NULL); - } else { - bufferp = buf; - rc1 = alsa_buffer_read(prtd, bufferp, monofbytes, NULL); - bufferp = buf + monofbytes ; - rc2 = alsa_buffer_read(prtd, bufferp, monofbytes, NULL); - rc = rc1 + rc2; - } - prtd->pcm_buf_pos += fbytes; - return rc; -} - -static snd_pcm_uframes_t -msm_pcm_capture_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -static int msm_pcm_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - alsa_audrec_disable(prtd); - audmgr_close(&prtd->audmgr); - msm_adsp_put(prtd->audrec); - msm_adsp_put(prtd->audpre); - kfree(prtd); - - return 0; -} - -struct msm_audio_event_callbacks snd_msm_audio_ops = { - .playback = playback_event_handler, - .capture = capture_event_handler, -}; - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd; - int ret = 0; - - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - if (prtd == NULL) { - ret = -ENOMEM; - return ret; - } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw = msm_pcm_playback_hardware; - prtd->dir = SNDRV_PCM_STREAM_PLAYBACK; - prtd->playback_substream = substream; - prtd->eos_ack = 0; - ret = msm_audio_volume_update(PCMPLAYBACK_DECODERID, - msm_vol_ctl.volume, msm_vol_ctl.pan); - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - runtime->hw = msm_pcm_capture_hardware; - prtd->dir = SNDRV_PCM_STREAM_CAPTURE; - prtd->capture_substream = substream; - } - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - goto out; - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - goto out; - - prtd->ops = &snd_msm_audio_ops; - prtd->out[0].used = BUF_INVALID_LEN; - prtd->out_head = 1; /* point to second buffer on startup */ - runtime->private_data = prtd; - - ret = alsa_adsp_configure(prtd); - if (ret) - goto out; - copy_count = 0; - return 0; - - out: - kfree(prtd); - return ret; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int rc = 1; - int fbytes = 0; - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - fbytes = frames_to_bytes(runtime, frames); - rc = alsa_send_buffer(prtd, buf, fbytes, NULL); - ++copy_count; - if (copy_count == 1) { - mutex_lock(&the_locks.lock); - alsa_audio_configure(prtd); - mutex_unlock(&the_locks.lock); - } - return rc; -} - -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - int rc = 0; - - pr_debug("%s()\n", __func__); - - /* pcm dmamiss message is sent continously - * when decoder is starved so no race - * condition concern - */ - if (prtd->enabled) - rc = wait_event_interruptible(the_locks.eos_wait, - prtd->eos_ack); - - alsa_audio_disable(prtd); - audmgr_close(&prtd->audmgr); - kfree(prtd); - - return 0; -} - - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_close(substream); - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - snd_pcm_uframes_t ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_pointer(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_pointer(substream); - return ret; -} - -int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - if (substream->pcm->device & 1) { - runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; - runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; - } - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; - -} - -int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - prtd->out_head = 0; /* point to First buffer on startup */ - prtd->mmap_flag = 1; - runtime->dma_bytes = snd_pcm_lib_period_bytes(substream)*2; - dma_mmap_coherent(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); - return 0; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int pcm_preallocate_dma_buffer(struct snd_pcm *pcm, - int stream) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size; - if (!stream) - size = PLAYBACK_DMASZ; - else - size = CAPTURE_DMASZ; - - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_coherent(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); - if (!buf->area) - return -ENOMEM; - - buf->bytes = size; - return 0; -} - -static void msm_pcm_free_dma_buffers(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_coherent(pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area = NULL; - } -} - -static int msm_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - int ret; - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm; - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1); - if (ret) - return ret; - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, 1); - if (ret) - return ret; - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &msm_pcm_ops); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &msm_pcm_ops); - - ret = pcm_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK); - if (ret) - return ret; - - ret = pcm_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_CAPTURE); - if (ret) - msm_pcm_free_dma_buffers(pcm); - return ret; -} - -struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_pcm_new, - .pcm_free = msm_pcm_free_dma_buffers, -}; -EXPORT_SYMBOL(msm_soc_platform); - -static int msm_pcm_probe(struct platform_device *pdev) -{ - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-dsp-audio", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm7kv2-dai.c b/sound/soc/msm/msm7kv2-dai.c deleted file mode 100644 index 00a96fb33076585050e80d35c1b4904b6106029f..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm7kv2-dai.c +++ /dev/null @@ -1,149 +0,0 @@ -/* sound/soc/msm/msm-dai.c - * - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2008-2010, The Linux Foundation. All rights reserved. - * - * Derived from msm-pcm.c and msm7201.c. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm7kv2-pcm.h" - -static struct snd_soc_dai_driver msm_pcm_codec_dais[] = { -{ - .name = "msm-codec-dai", - .playback = { - .channels_max = USE_CHANNELS_MAX, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .capture = { - .channels_max = USE_CHANNELS_MAX, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, -}, -}; -static struct snd_soc_dai_driver msm_pcm_cpu_dais[] = { -{ - .name = "msm-cpu-dai", - .playback = { - .channels_max = USE_CHANNELS_MAX, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .capture = { - .channels_max = USE_CHANNELS_MAX, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, -}, -}; - -static struct snd_soc_codec_driver soc_codec_dev_msm = { - .compress_type = SND_SOC_FLAT_COMPRESSION, -}; - -static int asoc_msm_codec_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm, - msm_pcm_codec_dais, ARRAY_SIZE(msm_pcm_codec_dais)); -} - -static int asoc_msm_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static int asoc_msm_cpu_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_dai(&pdev->dev, msm_pcm_cpu_dais); -} - -static int asoc_msm_cpu_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static struct platform_driver asoc_msm_codec_driver = { - .probe = asoc_msm_codec_probe, - .remove = asoc_msm_codec_remove, - .driver = { - .name = "msm-codec-dai", - .owner = THIS_MODULE, - }, -}; - -static struct platform_driver asoc_msm_cpu_driver = { - .probe = asoc_msm_cpu_probe, - .remove = asoc_msm_cpu_remove, - .driver = { - .name = "msm-cpu-dai", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_codec_dai_init(void) -{ - return platform_driver_register(&asoc_msm_codec_driver); -} - -static void __exit msm_codec_dai_exit(void) -{ - platform_driver_unregister(&asoc_msm_codec_driver); -} - -static int __init msm_cpu_dai_init(void) -{ - return platform_driver_register(&asoc_msm_cpu_driver); -} - -static void __exit msm_cpu_dai_exit(void) -{ - platform_driver_unregister(&asoc_msm_cpu_driver); -} - -module_init(msm_codec_dai_init); -module_exit(msm_codec_dai_exit); -module_init(msm_cpu_dai_init); -module_exit(msm_cpu_dai_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm7kv2-dsp.c b/sound/soc/msm/msm7kv2-dsp.c deleted file mode 100644 index 8484a8f3cca0b8322a290eb3c0a1b57d82012662..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm7kv2-dsp.c +++ /dev/null @@ -1,633 +0,0 @@ -/* Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2008-2010, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm7kv2-pcm.h" - -/* Audrec Queue command sent macro's */ -#define audrec_send_bitstreamqueue(audio, cmd, len) \ - msm_adsp_write(audio->audrec, ((audio->queue_id & 0xFFFF0000) >> 16),\ - cmd, len) - -#define audrec_send_audrecqueue(audio, cmd, len) \ - msm_adsp_write(audio->audrec, (audio->queue_id & 0x0000FFFF),\ - cmd, len) - -static int alsa_dsp_read_buffer(struct msm_audio *audio, - uint32_t read_cnt); -static void alsa_get_dsp_frames(struct msm_audio *prtd); -static int alsa_in_param_config(struct msm_audio *audio); - -static int alsa_in_mem_config(struct msm_audio *audio); -static int alsa_in_enc_config(struct msm_audio *audio, int enable); - -int intcnt; -struct audio_frame { - uint16_t count_low; - uint16_t count_high; - uint16_t bytes; - uint16_t unknown; - unsigned char samples[]; -} __attribute__ ((packed)); - -void alsa_dsp_event(void *data, unsigned id, uint16_t *msg) -{ - struct msm_audio *prtd = data; - struct buffer *frame; - unsigned long flag = 0; - - MM_DBG("\n"); - switch (id) { - case AUDPP_MSG_HOST_PCM_INTF_MSG: { - unsigned id = msg[3]; - unsigned idx = msg[4] - 1; - - MM_DBG("HOST_PCM id %d idx %d\n", id, idx); - if (id != AUDPP_MSG_HOSTPCM_ID_ARM_RX) { - MM_ERR("bogus id\n"); - break; - } - if (idx > 1) { - MM_ERR("bogus buffer idx\n"); - break; - } - - /* Update with actual sent buffer size */ - if (prtd->out[idx].used != BUF_INVALID_LEN) - prtd->pcm_irq_pos += prtd->out[idx].used; - - if (prtd->pcm_irq_pos > prtd->pcm_size) - prtd->pcm_irq_pos = prtd->pcm_count; - - if (prtd->ops->playback) - prtd->ops->playback(prtd); - - if (prtd->mmap_flag) - break; - - spin_lock_irqsave(&the_locks.write_dsp_lock, flag); - if (prtd->running) { - prtd->out[idx].used = 0; - frame = prtd->out + prtd->out_tail; - if (frame->used) { - alsa_dsp_send_buffer( - prtd, prtd->out_tail, frame->used); - /* Reset eos_ack flag to avoid stale - * PCMDMAMISS been considered - */ - prtd->eos_ack = 0; - prtd->out_tail ^= 1; - } else { - prtd->out_needed++; - } - wake_up(&the_locks.write_wait); - } - spin_unlock_irqrestore(&the_locks.write_dsp_lock, flag); - break; - } - case AUDPP_MSG_PCMDMAMISSED: - MM_INFO("PCMDMAMISSED %d\n", msg[0]); - prtd->eos_ack++; - MM_DBG("PCMDMAMISSED Count per Buffer %d\n", prtd->eos_ack); - wake_up(&the_locks.eos_wait); - break; - case AUDPP_MSG_CFG_MSG: - if (msg[0] == AUDPP_MSG_ENA_ENA) { - MM_DBG("CFG_MSG ENABLE\n"); - prtd->out_needed = 0; - prtd->running = 1; - audpp_dsp_set_vol_pan(prtd->session_id, &prtd->vol_pan, - POPP); - audpp_route_stream(prtd->session_id, - msm_snddev_route_dec(prtd->session_id)); - audio_dsp_out_enable(prtd, 1); - } else if (msg[0] == AUDPP_MSG_ENA_DIS) { - MM_DBG("CFG_MSG DISABLE\n"); - prtd->running = 0; - } else { - MM_DBG("CFG_MSG %d?\n", msg[0]); - } - break; - default: - MM_DBG("UNKNOWN (%d)\n", id); - } -} - -static void audpreproc_dsp_event(void *data, unsigned id, void *msg) -{ - struct msm_audio *prtd = data; - - switch (id) { - case AUDPREPROC_ERROR_MSG: { - struct audpreproc_err_msg *err_msg = msg; - - MM_ERR("ERROR_MSG: stream id %d err idx %d\n", - err_msg->stream_id, err_msg->aud_preproc_err_idx); - /* Error case */ - break; - } - case AUDPREPROC_CMD_CFG_DONE_MSG: { - MM_DBG("CMD_CFG_DONE_MSG\n"); - break; - } - case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: { - struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg; - - MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \ - 0x%8x\n", enc_cfg_msg->stream_id, - enc_cfg_msg->rec_enc_type); - /* Encoder enable success */ - if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE) - alsa_in_param_config(prtd); - else { /* Encoder disable success */ - prtd->running = 0; - alsa_in_record_config(prtd, 0); - } - break; - } - case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: { - MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG\n"); - alsa_in_mem_config(prtd); - break; - } - case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: { - MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG\n"); - wake_up(&the_locks.enable_wait); - break; - } - default: - MM_DBG("Unknown Event id %d\n", id); - } -} - -static void audrec_dsp_event(void *data, unsigned id, size_t len, - void (*getevent) (void *ptr, size_t len)) -{ - struct msm_audio *prtd = data; - unsigned long flag = 0; - - switch (id) { - case AUDREC_CMD_MEM_CFG_DONE_MSG: { - MM_DBG("AUDREC_CMD_MEM_CFG_DONE_MSG\n"); - prtd->running = 1; - alsa_in_record_config(prtd, 1); - break; - } - case AUDREC_FATAL_ERR_MSG: { - struct audrec_fatal_err_msg fatal_err_msg; - - getevent(&fatal_err_msg, AUDREC_FATAL_ERR_MSG_LEN); - MM_ERR("FATAL_ERR_MSG: err id %d\n", - fatal_err_msg.audrec_err_id); - /* Error stop the encoder */ - prtd->stopped = 1; - wake_up(&the_locks.read_wait); - break; - } - case AUDREC_UP_PACKET_READY_MSG: { - struct audrec_up_pkt_ready_msg pkt_ready_msg; - MM_DBG("AUDREC_UP_PACKET_READY_MSG\n"); - - getevent(&pkt_ready_msg, AUDREC_UP_PACKET_READY_MSG_LEN); - MM_DBG("UP_PACKET_READY_MSG: write cnt lsw %d \ - write cnt msw %d read cnt lsw %d read cnt msw %d \n",\ - pkt_ready_msg.audrec_packet_write_cnt_lsw, \ - pkt_ready_msg.audrec_packet_write_cnt_msw, \ - pkt_ready_msg.audrec_up_prev_read_cnt_lsw, \ - pkt_ready_msg.audrec_up_prev_read_cnt_msw); - - alsa_get_dsp_frames(prtd); - ++intcnt; - if (prtd->channel_mode == 1) { - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - - if (prtd->ops->capture) - prtd->ops->capture(prtd); - } else if ((prtd->channel_mode == 0) && (intcnt % 2 == 0)) { - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - if (prtd->ops->capture) - prtd->ops->capture(prtd); - } - break; - } - default: - MM_DBG("Unknown Event id %d\n", id); - } -} - -struct msm_adsp_ops alsa_audrec_adsp_ops = { - .event = audrec_dsp_event, -}; - -int alsa_audio_configure(struct msm_audio *prtd) -{ - if (prtd->enabled) - return 0; - - MM_DBG("\n"); - if (prtd->dir == SNDRV_PCM_STREAM_PLAYBACK) { - prtd->out_weight = 100; - if (audpp_enable(-1, alsa_dsp_event, prtd)) { - MM_ERR("audpp_enable() failed\n"); - return -ENODEV; - } - } - if (prtd->dir == SNDRV_PCM_STREAM_CAPTURE) { - if (audpreproc_enable(prtd->session_id, - &audpreproc_dsp_event, prtd)) { - MM_ERR("audpreproc_enable failed\n"); - return -ENODEV; - } - - if (msm_adsp_enable(prtd->audrec)) { - MM_ERR("msm_adsp_enable(audrec) enable failed\n"); - audpreproc_disable(prtd->session_id, prtd); - return -ENODEV; - } - alsa_in_enc_config(prtd, 1); - - } - prtd->enabled = 1; - return 0; -} -EXPORT_SYMBOL(alsa_audio_configure); - -ssize_t alsa_send_buffer(struct msm_audio *prtd, const char __user *buf, - size_t count, loff_t *pos) -{ - unsigned long flag = 0; - const char __user *start = buf; - struct buffer *frame; - size_t xfer; - int ret = 0; - - MM_DBG("\n"); - mutex_lock(&the_locks.write_lock); - while (count > 0) { - frame = prtd->out + prtd->out_head; - ret = wait_event_interruptible(the_locks.write_wait, - (frame->used == 0) - || (prtd->stopped)); - if (ret < 0) - break; - if (prtd->stopped) { - ret = -EBUSY; - break; - } - xfer = count > frame->size ? frame->size : count; - if (copy_from_user(frame->data, buf, xfer)) { - ret = -EFAULT; - break; - } - frame->used = xfer; - prtd->out_head ^= 1; - count -= xfer; - buf += xfer; - - spin_lock_irqsave(&the_locks.write_dsp_lock, flag); - frame = prtd->out + prtd->out_tail; - if (frame->used && prtd->out_needed) { - alsa_dsp_send_buffer(prtd, prtd->out_tail, - frame->used); - /* Reset eos_ack flag to avoid stale - * PCMDMAMISS been considered - */ - prtd->eos_ack = 0; - prtd->out_tail ^= 1; - prtd->out_needed--; - } - spin_unlock_irqrestore(&the_locks.write_dsp_lock, flag); - } - mutex_unlock(&the_locks.write_lock); - if (buf > start) - return buf - start; - return ret; -} -EXPORT_SYMBOL(alsa_send_buffer); - -int alsa_audio_disable(struct msm_audio *prtd) -{ - if (prtd->enabled) { - MM_DBG("\n"); - mutex_lock(&the_locks.lock); - prtd->enabled = 0; - audio_dsp_out_enable(prtd, 0); - wake_up(&the_locks.write_wait); - audpp_disable(-1, prtd); - prtd->out_needed = 0; - mutex_unlock(&the_locks.lock); - } - return 0; -} -EXPORT_SYMBOL(alsa_audio_disable); - -int alsa_audrec_disable(struct msm_audio *prtd) -{ - if (prtd->enabled) { - prtd->enabled = 0; - alsa_in_enc_config(prtd, 0); - wake_up(&the_locks.read_wait); - msm_adsp_disable(prtd->audrec); - prtd->out_needed = 0; - audpreproc_disable(prtd->session_id, prtd); - } - return 0; -} -EXPORT_SYMBOL(alsa_audrec_disable); - -static int alsa_in_enc_config(struct msm_audio *prtd, int enable) -{ - struct audpreproc_audrec_cmd_enc_cfg cmd; - int i; - unsigned short *ptrmem = (unsigned short *)&cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG; - cmd.stream_id = prtd->session_id; - - if (enable) - cmd.audrec_enc_type = prtd->type | ENCODE_ENABLE; - else - cmd.audrec_enc_type &= ~(ENCODE_ENABLE); - for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) - MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); - - return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd)); -} - -static int alsa_in_param_config(struct msm_audio *prtd) -{ - struct audpreproc_audrec_cmd_parm_cfg_wav cmd; - int i; - unsigned short *ptrmem = (unsigned short *)&cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG; - cmd.common.stream_id = prtd->session_id; - - cmd.aud_rec_samplerate_idx = prtd->samp_rate; - cmd.aud_rec_stereo_mode = prtd->channel_mode; - for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) - MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); - - return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd)); -} - -int alsa_in_record_config(struct msm_audio *prtd, int enable) -{ - struct audpreproc_afe_cmd_audio_record_cfg cmd; - int i; - unsigned short *ptrmem = (unsigned short *)&cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG; - cmd.stream_id = prtd->session_id; - if (enable) - cmd.destination_activity = AUDIO_RECORDING_TURN_ON; - else - cmd.destination_activity = AUDIO_RECORDING_TURN_OFF; - cmd.source_mix_mask = prtd->source; - if (prtd->session_id == 2) { - if ((cmd.source_mix_mask & - INTERNAL_CODEC_TX_SOURCE_MIX_MASK) || - (cmd.source_mix_mask & AUX_CODEC_TX_SOURCE_MIX_MASK) || - (cmd.source_mix_mask & VOICE_UL_SOURCE_MIX_MASK) || - (cmd.source_mix_mask & VOICE_DL_SOURCE_MIX_MASK)) { - cmd.pipe_id = SOURCE_PIPE_1; - } - if (cmd.source_mix_mask & - AUDPP_A2DP_PIPE_SOURCE_MIX_MASK) - cmd.pipe_id |= SOURCE_PIPE_0; - } - for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) - MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); - return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd)); -} - -static int alsa_in_mem_config(struct msm_audio *prtd) -{ - struct audrec_cmd_arecmem_cfg cmd; - uint16_t *data = (void *) prtd->data; - int n; - int i; - unsigned short *ptrmem = (unsigned short *)&cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDREC_CMD_MEM_CFG_CMD; - cmd.audrec_up_pkt_intm_count = 1; - cmd.audrec_ext_pkt_start_addr_msw = prtd->phys >> 16; - cmd.audrec_ext_pkt_start_addr_lsw = prtd->phys; - cmd.audrec_ext_pkt_buf_number = FRAME_NUM; - - /* prepare buffer pointers: - * Mono: 1024 samples + 4 halfword header - * Stereo: 2048 samples + 4 halfword header - */ - for (n = 0; n < FRAME_NUM; n++) { - prtd->in[n].data = data + 4; - data += (4 + (prtd->channel_mode ? 2048 : 1024)); - MM_DBG("0x%8x\n", (int)(prtd->in[n].data - 8)); - } - for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) - MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); - - return audrec_send_audrecqueue(prtd, &cmd, sizeof(cmd)); -} - -int audio_dsp_out_enable(struct msm_audio *prtd, int yes) -{ - struct audpp_cmd_pcm_intf cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = AUDPP_CMD_PCM_INTF; - cmd.stream = AUDPP_CMD_POPP_STREAM; - cmd.stream_id = prtd->session_id; - cmd.config = AUDPP_CMD_PCM_INTF_CONFIG_CMD_V; - cmd.intf_type = AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V; - - if (yes) { - cmd.write_buf1LSW = prtd->out[0].addr; - cmd.write_buf1MSW = prtd->out[0].addr >> 16; - cmd.write_buf1_len = prtd->out[0].size; - cmd.write_buf2LSW = prtd->out[1].addr; - cmd.write_buf2MSW = prtd->out[1].addr >> 16; - if (prtd->out[1].used) - cmd.write_buf2_len = prtd->out[1].used; - else - cmd.write_buf2_len = prtd->out[1].size; - cmd.arm_to_rx_flag = AUDPP_CMD_PCM_INTF_ENA_V; - cmd.weight_decoder_to_rx = prtd->out_weight; - cmd.weight_arm_to_rx = 1; - cmd.partition_number_arm_to_dsp = 0; - cmd.sample_rate = prtd->out_sample_rate; - cmd.channel_mode = prtd->out_channel_mode; - } - - return audpp_send_queue2(&cmd, sizeof(cmd)); -} - -int alsa_buffer_read(struct msm_audio *prtd, void __user *buf, - size_t count, loff_t *pos) -{ - unsigned long flag; - void *data; - uint32_t index; - uint32_t size; - int ret = 0; - - mutex_lock(&the_locks.read_lock); - while (count > 0) { - ret = wait_event_interruptible(the_locks.read_wait, - (prtd->in_count > 0) - || prtd->stopped || - prtd->abort); - - if (ret < 0) - break; - - if (prtd->stopped) { - ret = -EBUSY; - break; - } - - if (prtd->abort) { - MM_DBG(" prtd->abort !\n"); - ret = -EPERM; /* Not permitted due to abort */ - break; - } - - index = prtd->in_tail; - data = (uint8_t *) prtd->in[index].data; - size = prtd->in[index].size; - if (count >= size) { - if (copy_to_user(buf, data, size)) { - ret = -EFAULT; - break; - } - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - if (index != prtd->in_tail) { - /* overrun: data is invalid, we need to retry */ - spin_unlock_irqrestore(&the_locks.read_dsp_lock, - flag); - continue; - } - prtd->in[index].size = 0; - prtd->in_tail = (prtd->in_tail + 1) & (FRAME_NUM - 1); - prtd->in_count--; - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - count -= size; - buf += size; - } else { - break; - } - } - mutex_unlock(&the_locks.read_lock); - return ret; -} -EXPORT_SYMBOL(alsa_buffer_read); - -int alsa_dsp_send_buffer(struct msm_audio *prtd, - unsigned idx, unsigned len) -{ - struct audpp_cmd_pcm_intf_send_buffer cmd; - int i; - unsigned short *ptrmem = (unsigned short *)&cmd; - - cmd.cmd_id = AUDPP_CMD_PCM_INTF; - cmd.stream = AUDPP_CMD_POPP_STREAM; - cmd.stream_id = prtd->session_id; - cmd.config = AUDPP_CMD_PCM_INTF_BUFFER_CMD_V; - cmd.intf_type = AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V; - cmd.dsp_to_arm_buf_id = 0; - cmd.arm_to_dsp_buf_id = idx + 1; - cmd.arm_to_dsp_buf_len = len; - for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) - MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); - - return audpp_send_queue2(&cmd, sizeof(cmd)); -} - -static int alsa_dsp_read_buffer(struct msm_audio *audio, uint32_t read_cnt) -{ - struct up_audrec_packet_ext_ptr cmd; - int i; - unsigned short *ptrmem = (unsigned short *)&cmd; - - memset(&cmd, 0, sizeof(cmd)); - cmd.cmd_id = UP_AUDREC_PACKET_EXT_PTR; - cmd.audrec_up_curr_read_count_msw = read_cnt >> 16; - cmd.audrec_up_curr_read_count_lsw = read_cnt; - for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem) - MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem); - - return audrec_send_bitstreamqueue(audio, &cmd, sizeof(cmd)); -} - -static void alsa_get_dsp_frames(struct msm_audio *prtd) -{ - struct audio_frame *frame; - uint32_t index = 0; - unsigned long flag; - - if (prtd->type == ENC_TYPE_WAV) { - index = prtd->in_head; - - frame = - (void *)(((char *)prtd->in[index].data) - sizeof(*frame)); - - spin_lock_irqsave(&the_locks.read_dsp_lock, flag); - prtd->in[index].size = frame->bytes; - MM_DBG("frame = %08x\n", (unsigned int) frame); - MM_DBG("prtd->in[index].size = %08x\n", - (unsigned int) prtd->in[index].size); - - prtd->in_head = (prtd->in_head + 1) & (FRAME_NUM - 1); - - /* If overflow, move the tail index foward. */ - if (prtd->in_head == prtd->in_tail) - prtd->in_tail = (prtd->in_tail + 1) & (FRAME_NUM - 1); - else - prtd->in_count++; - - prtd->pcm_irq_pos += frame->bytes; - alsa_dsp_read_buffer(prtd, prtd->dsp_cnt++); - spin_unlock_irqrestore(&the_locks.read_dsp_lock, flag); - - wake_up(&the_locks.read_wait); - } -} diff --git a/sound/soc/msm/msm7kv2-pcm.c b/sound/soc/msm/msm7kv2-pcm.c deleted file mode 100644 index f1ac6e0d714644041c4d52cc2bfd61f108d8aeb0..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm7kv2-pcm.c +++ /dev/null @@ -1,774 +0,0 @@ -/* Copyright (c) 2008-2010, The Linux Foundation. All rights reserved. - * - * All source code in this file is licensed under the following license except - * where indicated. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "msm7kv2-pcm.h" -#include -#include - -#define HOSTPCM_STREAM_ID 5 - -struct snd_msm { - struct snd_card *card; - struct snd_pcm *pcm; -}; - -int copy_count; - -static struct snd_pcm_hardware msm_pcm_playback_hardware = { - .info = SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED, - .formats = USE_FORMATS, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = MAX_BUFFER_PLAYBACK_SIZE, - .period_bytes_min = BUFSZ, - .period_bytes_max = BUFSZ, - .periods_min = 2, - .periods_max = 2, - .fifo_size = 0, -}; - -static struct snd_pcm_hardware msm_pcm_capture_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED, - .formats = USE_FORMATS, - .rates = USE_RATE, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = MAX_BUFFER_CAPTURE_SIZE, - .period_bytes_min = 4096, - .period_bytes_max = 4096, - .periods_min = 4, - .periods_max = 4, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; -static void alsa_out_listener(u32 evt_id, union auddev_evt_data *evt_payload, - void *private_data) -{ - struct msm_audio *prtd = (struct msm_audio *) private_data; - MM_DBG("evt_id = 0x%8x\n", evt_id); - switch (evt_id) { - case AUDDEV_EVT_DEV_RDY: - MM_DBG("AUDDEV_EVT_DEV_RDY\n"); - prtd->source |= (0x1 << evt_payload->routing_id); - if (prtd->running == 1 && prtd->enabled == 1) - audpp_route_stream(prtd->session_id, prtd->source); - break; - case AUDDEV_EVT_DEV_RLS: - MM_DBG("AUDDEV_EVT_DEV_RLS\n"); - prtd->source &= ~(0x1 << evt_payload->routing_id); - if (prtd->running == 1 && prtd->enabled == 1) - audpp_route_stream(prtd->session_id, prtd->source); - break; - case AUDDEV_EVT_STREAM_VOL_CHG: - prtd->vol_pan.volume = evt_payload->session_vol; - MM_DBG("AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n", - prtd->vol_pan.volume); - if (prtd->running) - audpp_set_volume_and_pan(prtd->session_id, - prtd->vol_pan.volume, - 0, POPP); - break; - default: - MM_DBG("Unknown Event\n"); - break; - } -} - -static void alsa_in_listener(u32 evt_id, union auddev_evt_data *evt_payload, - void *private_data) -{ - struct msm_audio *prtd = (struct msm_audio *) private_data; - MM_DBG("evt_id = 0x%8x\n", evt_id); - - switch (evt_id) { - case AUDDEV_EVT_DEV_RDY: { - MM_DBG("AUDDEV_EVT_DEV_RDY\n"); - prtd->source |= (0x1 << evt_payload->routing_id); - - if ((prtd->running == 1) && (prtd->enabled == 1)) - alsa_in_record_config(prtd, 1); - - break; - } - case AUDDEV_EVT_DEV_RLS: { - MM_DBG("AUDDEV_EVT_DEV_RLS\n"); - prtd->source &= ~(0x1 << evt_payload->routing_id); - - if (!prtd->running || !prtd->enabled) - break; - - /* Turn off as per source */ - if (prtd->source) - alsa_in_record_config(prtd, 1); - else - /* Turn off all */ - alsa_in_record_config(prtd, 0); - - break; - } - case AUDDEV_EVT_FREQ_CHG: { - MM_DBG("Encoder Driver got sample rate change event\n"); - MM_DBG("sample rate %d\n", evt_payload->freq_info.sample_rate); - MM_DBG("dev_type %d\n", evt_payload->freq_info.dev_type); - MM_DBG("acdb_dev_id %d\n", evt_payload->freq_info.acdb_dev_id); - if (prtd->running == 1) { - /* Stop Recording sample rate does not match - with device sample rate */ - if (evt_payload->freq_info.sample_rate != - prtd->samp_rate) { - alsa_in_record_config(prtd, 0); - prtd->abort = 1; - wake_up(&the_locks.read_wait); - } - } - break; - } - default: - MM_DBG("Unknown Event\n"); - break; - } -} - -static void msm_pcm_enqueue_data(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - unsigned int period_size; - - MM_DBG("prtd->out_tail =%d mmap_flag=%d\n", - prtd->out_tail, prtd->mmap_flag); - period_size = snd_pcm_lib_period_bytes(substream); - alsa_dsp_send_buffer(prtd, prtd->out_tail, period_size); - prtd->out_tail ^= 1; - ++copy_count; - prtd->period++; - if (unlikely(prtd->period >= runtime->periods)) - prtd->period = 0; - -} - -static void event_handler(void *data) -{ - struct msm_audio *prtd = data; - MM_DBG("\n"); - snd_pcm_period_elapsed(prtd->substream); - if (prtd->mmap_flag) { - if (prtd->dir == SNDRV_PCM_STREAM_CAPTURE) - return; - if (!prtd->stopped) - msm_pcm_enqueue_data(prtd->substream); - else - prtd->out_needed++; - } -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - MM_DBG("\n"); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - prtd->pcm_buf_pos = 0; - if (prtd->enabled) - return 0; - - MM_DBG("\n"); - /* rate and channels are sent to audio driver */ - prtd->out_sample_rate = runtime->rate; - prtd->out_channel_mode = runtime->channels; - prtd->data = prtd->substream->dma_buffer.area; - prtd->phys = prtd->substream->dma_buffer.addr; - prtd->out[0].data = prtd->data + 0; - prtd->out[0].addr = prtd->phys + 0; - prtd->out[0].size = BUFSZ; - prtd->out[1].data = prtd->data + BUFSZ; - prtd->out[1].addr = prtd->phys + BUFSZ; - prtd->out[1].size = BUFSZ; - - if (prtd->enabled | !(prtd->mmap_flag)) - return 0; - - prtd->out[0].used = prtd->pcm_count; - prtd->out[1].used = prtd->pcm_count; - - mutex_lock(&the_locks.lock); - alsa_audio_configure(prtd); - mutex_unlock(&the_locks.lock); - - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret = 0; - uint32_t freq; - MM_DBG("\n"); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - prtd->pcm_buf_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->type = ENC_TYPE_WAV; - prtd->samp_rate = runtime->rate; - prtd->channel_mode = (runtime->channels - 1); - prtd->buffer_size = prtd->channel_mode ? STEREO_DATA_SIZE : \ - MONO_DATA_SIZE; - - if (prtd->enabled) - return 0; - - freq = prtd->samp_rate; - - prtd->data = prtd->substream->dma_buffer.area; - prtd->phys = prtd->substream->dma_buffer.addr; - MM_DBG("prtd->data =%08x\n", (unsigned int)prtd->data); - MM_DBG("prtd->phys =%08x\n", (unsigned int)prtd->phys); - - mutex_lock(&the_locks.lock); - ret = alsa_audio_configure(prtd); - mutex_unlock(&the_locks.lock); - if (ret) - return ret; - ret = wait_event_interruptible(the_locks.enable_wait, - prtd->running != 0); - MM_DBG("state prtd->running = %d ret = %d\n", prtd->running, ret); - - if (prtd->running == 0) - ret = -ENODEV; - else - ret = 0; - prtd->enabled = 1; - - return ret; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - unsigned long flag = 0; - int ret = 0; - - MM_DBG("\n"); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) - || !prtd->mmap_flag) - break; - if (!prtd->out_needed) { - prtd->stopped = 0; - break; - } - spin_lock_irqsave(&the_locks.write_dsp_lock, flag); - if (prtd->running == 1) { - if (prtd->stopped == 1) { - prtd->stopped = 0; - prtd->period = 0; - if (prtd->pcm_irq_pos == 0) { - prtd->out_tail = 0; - msm_pcm_enqueue_data(prtd->substream); - prtd->out_needed--; - } else { - prtd->out_tail = 1; - msm_pcm_enqueue_data(prtd->substream); - prtd->out_needed--; - } - if (prtd->out_needed) { - prtd->out_tail ^= 1; - msm_pcm_enqueue_data(prtd->substream); - prtd->out_needed--; - } - } - } - spin_unlock_irqrestore(&the_locks.write_dsp_lock, flag); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) - || !prtd->mmap_flag) - break; - prtd->stopped = 1; - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -struct msm_audio_event_callbacks snd_msm_audio_ops = { - .playback = event_handler, - .capture = event_handler, -}; - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd; - int ret = 0; - int i = 0; - int session_attrb, sessionid; - - MM_DBG("\n"); - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - if (prtd == NULL) { - ret = -ENOMEM; - return ret; - } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (prtd->opened) { - kfree(prtd); - return -EBUSY; - } - runtime->hw = msm_pcm_playback_hardware; - prtd->dir = SNDRV_PCM_STREAM_PLAYBACK; - prtd->eos_ack = 0; - prtd->session_id = HOSTPCM_STREAM_ID; - prtd->device_events = AUDDEV_EVT_DEV_RDY | - AUDDEV_EVT_STREAM_VOL_CHG | - AUDDEV_EVT_DEV_RLS; - prtd->source = msm_snddev_route_dec(prtd->session_id); - MM_ERR("Register device event listener\n"); - ret = auddev_register_evt_listner(prtd->device_events, - AUDDEV_CLNT_DEC, prtd->session_id, - alsa_out_listener, (void *) prtd); - if (ret) { - MM_ERR("failed to register device event listener\n"); - goto evt_error; - } - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - runtime->hw = msm_pcm_capture_hardware; - prtd->dir = SNDRV_PCM_STREAM_CAPTURE; - session_attrb = ENC_TYPE_WAV; - sessionid = audpreproc_aenc_alloc(session_attrb, - &prtd->module_name, &prtd->queue_id); - if (sessionid < 0) { - MM_ERR("AUDREC not available\n"); - kfree(prtd); - return -ENODEV; - } - prtd->session_id = sessionid; - MM_DBG("%s\n", prtd->module_name); - ret = msm_adsp_get(prtd->module_name, &prtd->audrec, - &alsa_audrec_adsp_ops, prtd); - if (ret < 0) { - audpreproc_aenc_free(prtd->session_id); - kfree(prtd); - return -ENODEV; - } - - prtd->abort = 0; - prtd->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS | - AUDDEV_EVT_FREQ_CHG; - prtd->source = msm_snddev_route_enc(prtd->session_id); - MM_ERR("Register device event listener\n"); - ret = auddev_register_evt_listner(prtd->device_events, - AUDDEV_CLNT_ENC, prtd->session_id, - alsa_in_listener, (void *) prtd); - if (ret) { - MM_ERR("failed to register device event listener\n"); - audpreproc_aenc_free(prtd->session_id); - msm_adsp_put(prtd->audrec); - goto evt_error; - } - } - prtd->substream = substream; - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - MM_ERR("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - MM_ERR("snd_pcm_hw_constraint_integer failed\n"); - - prtd->ops = &snd_msm_audio_ops; - prtd->out[0].used = BUF_INVALID_LEN; - prtd->out[1].used = 0; - prtd->out_head = 1; /* point to second buffer on startup */ - prtd->out_tail = 0; - prtd->dsp_cnt = 0; - prtd->in_head = 0; - prtd->in_tail = 0; - prtd->in_count = 0; - prtd->out_needed = 0; - for (i = 0; i < FRAME_NUM; i++) { - prtd->in[i].size = 0; - prtd->in[i].read = 0; - } - prtd->vol_pan.volume = 0x2000; - prtd->vol_pan.pan = 0x0; - prtd->opened = 1; - runtime->private_data = prtd; - - copy_count = 0; - return 0; -evt_error: - kfree(prtd); - return ret; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - fbytes = frames_to_bytes(runtime, frames); - MM_DBG("%d\n", fbytes); - ret = alsa_send_buffer(prtd, buf, fbytes, NULL); - ++copy_count; - prtd->pcm_buf_pos += fbytes; - if (copy_count == 1) { - mutex_lock(&the_locks.lock); - ret = alsa_audio_configure(prtd); - mutex_unlock(&the_locks.lock); - } - return ret; -} - -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - int ret = 0; - - MM_DBG("\n"); - if ((!prtd->mmap_flag) && prtd->enabled) { - ret = wait_event_interruptible(the_locks.eos_wait, - (!(prtd->out[0].used) && !(prtd->out[1].used))); - - if (ret < 0) - goto done; - } - - /* PCM DMAMISS message is sent only once in - * hpcm interface. So, wait for buffer complete - * and teos flag. - */ - if (prtd->enabled) - ret = wait_event_interruptible(the_locks.eos_wait, - prtd->eos_ack); - -done: - alsa_audio_disable(prtd); - auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, prtd->session_id); - kfree(prtd); - - return 0; -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0, rc1 = 0, rc2 = 0; - int fbytes = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = substream->runtime->private_data; - - int monofbytes = 0; - char *bufferp = NULL; - - if (prtd->abort) - return -EPERM; - - fbytes = frames_to_bytes(runtime, frames); - MM_DBG("%d\n", fbytes); - monofbytes = fbytes / 2; - if (runtime->channels == 2) { - ret = alsa_buffer_read(prtd, buf, fbytes, NULL); - } else { - bufferp = buf; - rc1 = alsa_buffer_read(prtd, bufferp, monofbytes, NULL); - bufferp = buf + monofbytes ; - rc2 = alsa_buffer_read(prtd, bufferp, monofbytes, NULL); - ret = rc1 + rc2; - } - prtd->pcm_buf_pos += fbytes; - MM_DBG("prtd->pcm_buf_pos =%d, prtd->mmap_flag =%d\n", - prtd->pcm_buf_pos, prtd->mmap_flag); - return ret; -} - -static int msm_pcm_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret = 0; - - MM_DBG("\n"); - ret = msm_snddev_withdraw_freq(prtd->session_id, - SNDDEV_CAP_TX, AUDDEV_CLNT_ENC); - MM_DBG("msm_snddev_withdraw_freq\n"); - auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, prtd->session_id); - prtd->abort = 0; - wake_up(&the_locks.enable_wait); - alsa_audrec_disable(prtd); - audpreproc_aenc_free(prtd->session_id); - msm_adsp_put(prtd->audrec); - kfree(prtd); - return 0; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_close(substream); - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - MM_DBG("pcm_irq_pos = %d\n", prtd->pcm_irq_pos); - if (prtd->pcm_irq_pos == prtd->pcm_size) - prtd->pcm_irq_pos = 0; - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - prtd->out_head = 0; /* point to First buffer on startup */ - prtd->mmap_flag = 1; - runtime->dma_bytes = snd_pcm_lib_period_bytes(substream)*2; - dma_mmap_coherent(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); - return 0; -} - -int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int pcm_preallocate_buffer(struct snd_pcm *pcm, - int stream) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size; - if (!stream) - size = PLAYBACK_DMASZ; - else - size = CAPTURE_DMASZ; - - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_coherent(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); - if (!buf->area) - return -ENOMEM; - - buf->bytes = size; - return 0; -} - -static void msm_pcm_free_buffers(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_coherent(pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area = NULL; - } -} - -static int msm_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - int ret = 0; - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm; - - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1); - if (ret) - return ret; - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, 1); - if (ret) - return ret; - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &msm_pcm_ops); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &msm_pcm_ops); - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - - ret = pcm_preallocate_buffer(pcm, - SNDRV_PCM_STREAM_PLAYBACK); - if (ret) - return ret; - ret = pcm_preallocate_buffer(pcm, - SNDRV_PCM_STREAM_CAPTURE); - if (ret) - msm_pcm_free_buffers(pcm); - return ret; -} - -struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_pcm_new, - .pcm_free = msm_pcm_free_buffers, -}; -EXPORT_SYMBOL(msm_soc_platform); - -static int msm_pcm_probe(struct platform_device *pdev) -{ - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .driver = { - .name = "msm-dsp-audio", - .owner = THIS_MODULE, - }, - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, -}; - -static int __init msm_soc_platform_init(void) -{ - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm7kv2-pcm.h b/sound/soc/msm/msm7kv2-pcm.h deleted file mode 100644 index bcf6b4d42ea7d4d7fb5f0a7655dbff7d34d9daf5..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm7kv2-pcm.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2008-2010, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#ifndef _MSM_PCM_H -#define _MSM_PCM_H - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define FRAME_NUM (8) -#define FRAME_SIZE (2052 * 2) -#define MONO_DATA_SIZE (2048) -#define STEREO_DATA_SIZE (MONO_DATA_SIZE * 2) -#define CAPTURE_DMASZ (FRAME_SIZE * FRAME_NUM) - -#define BUFSZ (960 * 5) -#define PLAYBACK_DMASZ (BUFSZ * 2) - -#define MSM_PLAYBACK_DEFAULT_VOLUME 0 /* 0dB */ -#define MSM_PLAYBACK_DEFAULT_PAN 0 - -#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE -#define USE_CHANNELS_MIN 1 -#define USE_CHANNELS_MAX 2 -/* Support unconventional sample rates 12000, 24000 as well */ -#define USE_RATE \ - (SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT) -#define USE_RATE_MIN 8000 -#define USE_RATE_MAX 48000 -#define MAX_BUFFER_PLAYBACK_SIZE \ - PLAYBACK_DMASZ -/* 2048 frames (Mono), 1024 frames (Stereo) */ -#define CAPTURE_SIZE 4096 -#define MAX_BUFFER_CAPTURE_SIZE (4096*4) -#define MAX_PERIOD_SIZE BUFSZ -#define USE_PERIODS_MAX 1024 -#define USE_PERIODS_MIN 1 - - -#define MAX_DB (16) -#define MIN_DB (-50) -#define PCMPLAYBACK_DECODERID 5 - -/* 0xFFFFFFFF Indicates not to be used for audio data copy */ -#define BUF_INVALID_LEN 0xFFFFFFFF -#define EVENT_MSG_ID ((uint16_t)~0) - -#define AUDDEC_DEC_PCM 0 -/* Decoder status received from AUDPPTASK */ -#define AUDPP_DEC_STATUS_SLEEP 0 -#define AUDPP_DEC_STATUS_INIT 1 -#define AUDPP_DEC_STATUS_CFG 2 -#define AUDPP_DEC_STATUS_PLAY 3 - -extern int copy_count; -extern int intcnt; - -struct buffer { - void *data; - unsigned size; - unsigned used; - unsigned addr; -}; - -struct buffer_rec { - void *data; - unsigned int size; - unsigned int read; - unsigned int addr; -}; - -struct audio_locks { - struct mutex lock; - struct mutex write_lock; - struct mutex read_lock; - spinlock_t read_dsp_lock; - spinlock_t write_dsp_lock; - spinlock_t mixer_lock; - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; - wait_queue_head_t wait; - wait_queue_head_t eos_wait; - wait_queue_head_t enable_wait; -}; - -extern struct audio_locks the_locks; - -struct msm_audio_event_callbacks { - /* event is called from interrupt context when a message - * arrives from the DSP. - */ - void (*playback)(void *); - void (*capture)(void *); -}; - - -struct msm_audio { - struct buffer out[2]; - struct buffer_rec in[8]; - - uint8_t out_head; - uint8_t out_tail; - uint8_t out_needed; /* number of buffers the dsp is waiting for */ - atomic_t out_bytes; - - /* configuration to use on next enable */ - uint32_t out_sample_rate; - uint32_t out_channel_mode; - uint32_t out_weight; - uint32_t out_buffer_size; - - struct snd_pcm_substream *substream; - - /* data allocated for various buffers */ - char *data; - dma_addr_t phys; - - unsigned int pcm_size; - unsigned int pcm_count; - unsigned int pcm_irq_pos; /* IRQ position */ - unsigned int pcm_buf_pos; /* position in buffer */ - uint16_t source; /* Encoding source bit mask */ - - struct msm_adsp_module *audpre; - struct msm_adsp_module *audrec; - struct msm_adsp_module *audplay; - enum msm_aud_decoder_state dec_state; /* Represents decoder state */ - - uint16_t session_id; - uint32_t out_bits; /* bits per sample */ - const char *module_name; - unsigned queue_id; - - /* configuration to use on next enable */ - uint32_t samp_rate; - uint32_t channel_mode; - uint32_t buffer_size; /* 2048 for mono, 4096 for stereo */ - uint32_t type; /* 0 for PCM ,1 for AAC */ - uint32_t dsp_cnt; - uint32_t in_head; /* next buffer dsp will write */ - uint32_t in_tail; /* next buffer read() will read */ - uint32_t in_count; /* number of buffers available to read() */ - - unsigned short samp_rate_index; - uint32_t device_events; /* device events interested in */ - int abort; /* set when error, like sample rate mismatch */ - - /* audpre settings */ - /* For different sample rate, the coeff might be different. * - * All the coeff should be passed from user space */ - - struct msm_audio_event_callbacks *ops; - - int dir; - int opened; - int enabled; - int running; - int stopped; /* set when stopped, cleared on flush */ - int eos_ack; - int mmap_flag; - int period; - struct audpp_cmd_cfg_object_params_volume vol_pan; -}; - - - -/* platform data */ -extern int alsa_dsp_send_buffer(struct msm_audio *prtd, - unsigned idx, unsigned len); -extern int audio_dsp_out_enable(struct msm_audio *prtd, int yes); -extern struct snd_soc_platform_driver msm_soc_platform; - -extern int audrec_encoder_config(struct msm_audio *prtd); -extern int alsa_audrec_disable(struct msm_audio *prtd); -extern int alsa_audio_configure(struct msm_audio *prtd); -extern int alsa_audio_disable(struct msm_audio *prtd); -extern int alsa_buffer_read(struct msm_audio *prtd, void __user *buf, - size_t count, loff_t *pos); -ssize_t alsa_send_buffer(struct msm_audio *prtd, const char __user *buf, - size_t count, loff_t *pos); -extern struct msm_adsp_ops alsa_audrec_adsp_ops; -extern int alsa_in_record_config(struct msm_audio *prtd, int enable); -#endif /*_MSM_PCM_H*/ diff --git a/sound/soc/msm/msm7x30.c b/sound/soc/msm/msm7x30.c deleted file mode 100644 index 1ea92f25d045262b16c6241dd9592a0d202b6f02..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm7x30.c +++ /dev/null @@ -1,1003 +0,0 @@ -/* Copyright (c) 2008-2011, 2013, The Linux Foundation. All rights reserved. - * - * All source code in this file is licensed under the following license except - * where indicated. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "msm7kv2-pcm.h" -#include -#include -#include - -static struct platform_device *msm_audio_snd_device; -struct audio_locks the_locks; -EXPORT_SYMBOL(the_locks); -struct msm_volume msm_vol_ctl; -EXPORT_SYMBOL(msm_vol_ctl); -static struct snd_kcontrol_new snd_msm_controls[]; - -char snddev_name[AUDIO_DEV_CTL_MAX_DEV][44]; -#define MSM_MAX_VOLUME 0x2000 -#define MSM_VOLUME_STEP ((MSM_MAX_VOLUME+17)/100) /* 17 added to avoid - more deviation */ -#define LOOPBACK_ENABLE 0x1 -#define LOOPBACK_DISABLE 0x0 - -static int device_index; /* Count of Device controls */ -static int simple_control; /* Count of simple controls*/ -static int src_dev; -static int dst_dev; -static int loopback_status; - - -static int msm_scontrol_count_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - return 0; -} - -static int msm_scontrol_count_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = simple_control; - return 0; -} - -static int msm_v_call_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 1; - return 0; -} - -static int msm_v_call_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_v_call_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int start = ucontrol->value.integer.value[0]; - if (start) - broadcast_event(AUDDEV_EVT_START_VOICE, DEVICE_IGNORE, - SESSION_IGNORE); - else - broadcast_event(AUDDEV_EVT_END_VOICE, DEVICE_IGNORE, - SESSION_IGNORE); - return 0; -} - -static int msm_v_mute_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 2; - return 0; -} - -static int msm_v_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_v_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int dir = ucontrol->value.integer.value[0]; - int mute = ucontrol->value.integer.value[1]; - return msm_set_voice_mute(dir, mute); -} - -static int msm_v_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; /* Volume */ - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 100; - return 0; -} - -static int msm_v_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_v_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int dir = ucontrol->value.integer.value[0]; - int volume = ucontrol->value.integer.value[1]; - - return msm_set_voice_vol(dir, volume); -} - -static int msm_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; /* Volume and 10-base multiply factor*/ - uinfo->value.integer.min = 0; - - /* limit the muliply factor to 4 decimal digit */ - uinfo->value.integer.max = 1000000; - return 0; -} -static int msm_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int ret = 0; - int session_id = ucontrol->value.integer.value[0]; - int volume = ucontrol->value.integer.value[1]; - int factor = ucontrol->value.integer.value[2]; - u32 session_mask = 0; - - - if (factor > 10000) - return -EINVAL; - - if ((volume < 0) || (volume/factor > 100)) - return -EINVAL; - - volume = (MSM_VOLUME_STEP * volume); - - /* Convert back to original decimal point by removing the 10-base factor - * and discard the fractional portion - */ - - volume = volume/factor; - - if (volume > MSM_MAX_VOLUME) - volume = MSM_MAX_VOLUME; - - /* Only Decoder volume control supported */ - session_mask = (0x1 << (session_id) << (8 * ((int)AUDDEV_CLNT_DEC-1))); - msm_vol_ctl.volume = volume; - MM_DBG("session_id %d, volume %d", session_id, volume); - broadcast_event(AUDDEV_EVT_STREAM_VOL_CHG, DEVICE_IGNORE, - session_mask); - - return ret; -} - -static int msm_voice_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; /* Device */ - - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_voice_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - uint32_t rx_dev_id; - uint32_t tx_dev_id; - struct msm_snddev_info *rx_dev_info; - struct msm_snddev_info *tx_dev_info; - int set = ucontrol->value.integer.value[2]; - u32 session_mask; - - if (!set) - return -EPERM; - /* Rx Device Routing */ - rx_dev_id = ucontrol->value.integer.value[0]; - rx_dev_info = audio_dev_ctrl_find_dev(rx_dev_id); - - if (IS_ERR(rx_dev_info)) { - MM_ERR("pass invalid dev_id\n"); - rc = PTR_ERR(rx_dev_info); - return rc; - } - - if (!(rx_dev_info->capability & SNDDEV_CAP_RX)) { - MM_ERR("First Dev is supposed to be RX\n"); - return -EFAULT; - } - - MM_DBG("route cfg %d STREAM_VOICE_RX type\n", - rx_dev_id); - - msm_set_voc_route(rx_dev_info, AUDIO_ROUTE_STREAM_VOICE_RX, - rx_dev_id); - - session_mask = 0x1 << (8 * ((int)AUDDEV_CLNT_VOC-1)); - - broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, rx_dev_id, session_mask); - - - /* Tx Device Routing */ - tx_dev_id = ucontrol->value.integer.value[1]; - tx_dev_info = audio_dev_ctrl_find_dev(tx_dev_id); - - if (IS_ERR(tx_dev_info)) { - MM_ERR("pass invalid dev_id\n"); - rc = PTR_ERR(tx_dev_info); - return rc; - } - - if (!(tx_dev_info->capability & SNDDEV_CAP_TX)) { - MM_ERR("Second Dev is supposed to be Tx\n"); - return -EFAULT; - } - - MM_DBG("route cfg %d %d type\n", - tx_dev_id, AUDIO_ROUTE_STREAM_VOICE_TX); - - msm_set_voc_route(tx_dev_info, AUDIO_ROUTE_STREAM_VOICE_TX, - tx_dev_id); - - broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, tx_dev_id, session_mask); - - if (rx_dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RDY, rx_dev_id, session_mask); - - if (tx_dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RDY, tx_dev_id, session_mask); - - return rc; -} - -static int msm_voice_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - /* TODO: query Device list */ - return 0; -} - -static int msm_device_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; /* Device */ - - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_device_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - int set = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - struct msm_snddev_info *dst_dev_info; - struct msm_snddev_info *src_dev_info; - int tx_freq = 0; - int rx_freq = 0; - u32 set_freq = 0; - - set = ucontrol->value.integer.value[0]; - route_cfg.dev_id = ucontrol->id.numid - device_index; - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - if (IS_ERR(dev_info)) { - MM_ERR("pass invalid dev_id\n"); - rc = PTR_ERR(dev_info); - return rc; - } - MM_INFO("device %s set %d\n", dev_info->name, set); - - if (set) { - if (!dev_info->opened) { - set_freq = dev_info->sample_rate; - if (!msm_device_is_voice(route_cfg.dev_id)) { - msm_get_voc_freq(&tx_freq, &rx_freq); - if (dev_info->capability & SNDDEV_CAP_TX) - set_freq = tx_freq; - - if (set_freq == 0) - set_freq = dev_info->sample_rate; - } else - set_freq = dev_info->sample_rate; - - - MM_ERR("device freq =%d\n", set_freq); - rc = dev_info->dev_ops.set_freq(dev_info, set_freq); - if (rc < 0) { - MM_ERR("device freq failed!\n"); - return rc; - } - dev_info->set_sample_rate = rc; - rc = 0; - rc = dev_info->dev_ops.open(dev_info); - if (rc < 0) { - MM_ERR("Enabling %s failed", dev_info->name); - return rc; - } - dev_info->opened = 1; - broadcast_event(AUDDEV_EVT_DEV_RDY, route_cfg.dev_id, - SESSION_IGNORE); - /* Event to notify client for device info */ - broadcast_event(AUDDEV_EVT_DEVICE_INFO, - route_cfg.dev_id, SESSION_IGNORE); - if ((route_cfg.dev_id == src_dev) || - (route_cfg.dev_id == dst_dev)) { - dst_dev_info = audio_dev_ctrl_find_dev( - dst_dev); - if (IS_ERR(dst_dev_info)) { - pr_err("dst_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(dst_dev_info); - return rc; - } - src_dev_info = audio_dev_ctrl_find_dev( - src_dev); - if (IS_ERR(src_dev_info)) { - pr_err("src_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(src_dev_info); - return rc; - } - if ((dst_dev_info->opened) && - (src_dev_info->opened)) { - pr_debug("%d: Enable afe_loopback\n", - __LINE__); - afe_ext_loopback(LOOPBACK_ENABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - loopback_status = 1; - } - } - } - } else { - if (dev_info->opened) { - broadcast_event(AUDDEV_EVT_REL_PENDING, - route_cfg.dev_id, - SESSION_IGNORE); - rc = dev_info->dev_ops.close(dev_info); - if (rc < 0) { - MM_ERR("Snd device failed close!\n"); - return rc; - } else { - dev_info->opened = 0; - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - SESSION_IGNORE); - } - if (loopback_status == 1) { - if ((route_cfg.dev_id == src_dev) || - (route_cfg.dev_id == dst_dev)) { - dst_dev_info = audio_dev_ctrl_find_dev( - dst_dev); - if (IS_ERR(dst_dev_info)) { - pr_err("dst_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(dst_dev_info); - return rc; - } - src_dev_info = audio_dev_ctrl_find_dev( - src_dev); - if (IS_ERR(src_dev_info)) { - pr_err("dst_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(src_dev_info); - return rc; - } - pr_debug("%d: Disable afe_loopback\n", - __LINE__); - afe_ext_loopback(LOOPBACK_DISABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - loopback_status = 0; - } - } - } - - } - return rc; -} - -static int msm_device_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - - route_cfg.dev_id = ucontrol->id.numid - device_index; - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - - if (IS_ERR(dev_info)) { - MM_ERR("pass invalid dev_id\n"); - rc = PTR_ERR(dev_info); - return rc; - } - - ucontrol->value.integer.value[0] = dev_info->copp_id; - ucontrol->value.integer.value[1] = dev_info->capability; - - return 0; -} - -static int msm_route_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; /* Device */ - - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_route_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - /* TODO: query Device list */ - return 0; -} - -static int msm_route_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - int enc_freq = 0; - int requested_freq = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - int session_id = ucontrol->value.integer.value[0]; - int set = ucontrol->value.integer.value[2]; - u32 session_mask = 0; - route_cfg.dev_id = ucontrol->value.integer.value[1]; - - if (ucontrol->id.numid == 2) - route_cfg.stream_type = AUDIO_ROUTE_STREAM_PLAYBACK; - else - route_cfg.stream_type = AUDIO_ROUTE_STREAM_REC; - - MM_DBG("route cfg %d %d type for popp %d set value %d\n", - route_cfg.dev_id, route_cfg.stream_type, session_id, set); - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - - if (IS_ERR(dev_info)) { - MM_ERR("pass invalid dev_id\n"); - rc = PTR_ERR(dev_info); - return rc; - } - if (route_cfg.stream_type == AUDIO_ROUTE_STREAM_PLAYBACK) { - rc = msm_snddev_set_dec(session_id, dev_info->copp_id, set); - session_mask = - (0x1 << (session_id) << (8 * ((int)AUDDEV_CLNT_DEC-1))); - if (!set) { - if (dev_info->opened) { - broadcast_event(AUDDEV_EVT_REL_PENDING, - route_cfg.dev_id, - session_mask); - - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - } - dev_info->sessions &= ~(session_mask); - } else { - dev_info->sessions = dev_info->sessions | session_mask; - if (dev_info->opened) { - broadcast_event(AUDDEV_EVT_DEV_RDY, - route_cfg.dev_id, - session_mask); - /* Event to notify client for device info */ - broadcast_event(AUDDEV_EVT_DEVICE_INFO, - route_cfg.dev_id, - session_mask); - } - } - } else { - rc = msm_snddev_set_enc(session_id, dev_info->copp_id, set); - session_mask = - (0x1 << (session_id)) << (8 * ((int)AUDDEV_CLNT_ENC-1)); - if (!set) { - if (dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - dev_info->sessions &= ~(session_mask); - } else { - dev_info->sessions = dev_info->sessions | session_mask; - enc_freq = msm_snddev_get_enc_freq(session_id); - requested_freq = enc_freq; - if (enc_freq > 0) { - rc = msm_snddev_request_freq(&enc_freq, - session_id, - SNDDEV_CAP_TX, - AUDDEV_CLNT_ENC); - MM_DBG("sample rate configured %d" - "sample rate requested %d\n", - enc_freq, requested_freq); - if ((rc <= 0) || (enc_freq != requested_freq)) { - MM_DBG("msm_snddev_withdraw_freq\n"); - rc = msm_snddev_withdraw_freq - (session_id, - SNDDEV_CAP_TX, AUDDEV_CLNT_ENC); - broadcast_event(AUDDEV_EVT_FREQ_CHG, - route_cfg.dev_id, - SESSION_IGNORE); - } - } - if (dev_info->opened) { - broadcast_event(AUDDEV_EVT_DEV_RDY, - route_cfg.dev_id, - session_mask); - /* Event to notify client for device info */ - broadcast_event(AUDDEV_EVT_DEVICE_INFO, - route_cfg.dev_id, - session_mask); - } - } - } - - if (rc < 0) { - MM_ERR("device could not be assigned!\n"); - return -EFAULT; - } - - return rc; -} - -static int msm_device_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 100; - return 0; -} - -static int msm_device_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct msm_snddev_info *dev_info; - - int dev_id = ucontrol->value.integer.value[0]; - - dev_info = audio_dev_ctrl_find_dev(dev_id); - ucontrol->value.integer.value[0] = dev_info->dev_volume; - - return 0; -} - -static int msm_device_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = -EPERM; - struct msm_snddev_info *dev_info; - - int dev_id = ucontrol->value.integer.value[0]; - int volume = ucontrol->value.integer.value[1]; - - MM_DBG("dev_id = %d, volume = %d\n", dev_id, volume); - - dev_info = audio_dev_ctrl_find_dev(dev_id); - - if (IS_ERR(dev_info)) { - rc = PTR_ERR(dev_info); - MM_ERR("audio_dev_ctrl_find_dev failed. %ld\n", - PTR_ERR(dev_info)); - return rc; - } - - MM_DBG("dev_name = %s dev_id = %d, volume = %d\n", - dev_info->name, dev_id, volume); - - if (dev_info->dev_ops.set_device_volume) - rc = dev_info->dev_ops.set_device_volume(dev_info, volume); - else { - MM_INFO("device %s does not support device volume " - "control.", dev_info->name); - return -EPERM; - } - - return rc; -} - -static int msm_reset_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 0; - return 0; -} - -static int msm_reset_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_reset_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - MM_DBG("Resetting all devices\n"); - return msm_reset_all_device(); -} - - -static int msm_dual_mic_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; - uinfo->value.integer.min = 0; - /*Max value is decided based on MAX ENC sessions*/ - uinfo->value.integer.max = MAX_AUDREC_SESSIONS - 1; - return 0; -} - -static int msm_dual_mic_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int enc_session_id = ucontrol->value.integer.value[0]; - ucontrol->value.integer.value[1] = - msm_get_dual_mic_config(enc_session_id); - MM_DBG("session id = %d, config = %ld\n", enc_session_id, - ucontrol->value.integer.value[1]); - return 0; -} - -static int msm_dual_mic_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int enc_session_id = ucontrol->value.integer.value[0]; - int dual_mic_config = ucontrol->value.integer.value[1]; - MM_DBG("session id = %d, config = %d\n", enc_session_id, - dual_mic_config); - return msm_set_dual_mic_config(enc_session_id, dual_mic_config); -} - -static int msm_device_mute_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_device_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - return 0; -} - -static int msm_device_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int dev_id = ucontrol->value.integer.value[0]; - int mute = ucontrol->value.integer.value[1]; - struct msm_snddev_info *dev_info; - int afe_dev_id = 0; - int volume = 0x4000; - - dev_info = audio_dev_ctrl_find_dev(dev_id); - if (IS_ERR(dev_info)) { - MM_ERR("pass invalid dev_id %d\n", dev_id); - return PTR_ERR(dev_info); - } - - if (dev_info->capability & SNDDEV_CAP_RX) - return -EPERM; - - MM_DBG("Muting device id %d(%s)\n", dev_id, dev_info->name); - - if (dev_info->copp_id == 0) - afe_dev_id = AFE_HW_PATH_CODEC_TX; - if (dev_info->copp_id == 1) - afe_dev_id = AFE_HW_PATH_AUXPCM_TX; - if (dev_info->copp_id == 2) - afe_dev_id = AFE_HW_PATH_MI2S_TX; - if (mute) - volume = 0; - afe_device_volume_ctrl(afe_dev_id, volume); - return 0; -} - -static int msm_loopback_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_loopback_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_loopback_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - struct msm_snddev_info *src_dev_info = NULL; /* TX device */ - struct msm_snddev_info *dst_dev_info = NULL; /* RX device */ - int dst_dev_id = ucontrol->value.integer.value[0]; - int src_dev_id = ucontrol->value.integer.value[1]; - int set = ucontrol->value.integer.value[2]; - - pr_debug("%s: set=%d\n", __func__, set); - - dst_dev_info = audio_dev_ctrl_find_dev(dst_dev_id); - if (IS_ERR(dst_dev_info)) { - pr_err("dst_dev:%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(dst_dev_info); - return rc; - } - if (!(dst_dev_info->capability & SNDDEV_CAP_RX)) { - pr_err("Destination device %d is not RX device\n", - dst_dev_id); - return -EFAULT; - } - - src_dev_info = audio_dev_ctrl_find_dev(src_dev_id); - if (IS_ERR(src_dev_info)) { - pr_err("src_dev:%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(src_dev_info); - return rc; - } - if (!(src_dev_info->capability & SNDDEV_CAP_TX)) { - pr_err("Source device %d is not TX device\n", src_dev_id); - return -EFAULT; - } - - if (set) { - pr_debug("%s:%d:Enabling AFE_Loopback\n", __func__, __LINE__); - src_dev = src_dev_id; - dst_dev = dst_dev_id; - loopback_status = 1; - if ((dst_dev_info->opened) && (src_dev_info->opened)) - afe_ext_loopback(LOOPBACK_ENABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - } else { - pr_debug("%s:%d:Disabling AFE_Loopback\n", __func__, __LINE__); - src_dev = DEVICE_IGNORE; - dst_dev = DEVICE_IGNORE; - loopback_status = 0; - afe_ext_loopback(LOOPBACK_DISABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - } - return 0; -} - -static struct snd_kcontrol_new snd_dev_controls[AUDIO_DEV_CTL_MAX_DEV]; - -static int snd_dev_ctl_index(int idx) -{ - struct msm_snddev_info *dev_info; - - dev_info = audio_dev_ctrl_find_dev(idx); - if (IS_ERR(dev_info)) { - MM_ERR("pass invalid dev_id\n"); - return PTR_ERR(dev_info); - } - if (sizeof(dev_info->name) <= 44) - sprintf(&snddev_name[idx][0] , "%s", dev_info->name); - - snd_dev_controls[idx].iface = SNDRV_CTL_ELEM_IFACE_MIXER; - snd_dev_controls[idx].access = SNDRV_CTL_ELEM_ACCESS_READWRITE; - snd_dev_controls[idx].name = &snddev_name[idx][0]; - snd_dev_controls[idx].index = idx; - snd_dev_controls[idx].info = msm_device_info; - snd_dev_controls[idx].get = msm_device_get; - snd_dev_controls[idx].put = msm_device_put; - snd_dev_controls[idx].private_value = 0; - return 0; - -} - -#define MSM_EXT(xname, fp_info, fp_get, fp_put, addr) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .name = xname, \ - .info = fp_info,\ - .get = fp_get, .put = fp_put, \ - .private_value = addr, \ -} - -static struct snd_kcontrol_new snd_msm_controls[] = { - MSM_EXT("Count", msm_scontrol_count_info, msm_scontrol_count_get, \ - NULL, 0), - MSM_EXT("Stream", msm_route_info, msm_route_get, \ - msm_route_put, 0), - MSM_EXT("Record", msm_route_info, msm_route_get, \ - msm_route_put, 0), - MSM_EXT("Voice", msm_voice_info, msm_voice_get, \ - msm_voice_put, 0), - MSM_EXT("Volume", msm_volume_info, msm_volume_get, \ - msm_volume_put, 0), - MSM_EXT("VoiceVolume", msm_v_volume_info, msm_v_volume_get, \ - msm_v_volume_put, 0), - MSM_EXT("VoiceMute", msm_v_mute_info, msm_v_mute_get, \ - msm_v_mute_put, 0), - MSM_EXT("Voice Call", msm_v_call_info, msm_v_call_get, \ - msm_v_call_put, 0), - MSM_EXT("Device_Volume", msm_device_volume_info, - msm_device_volume_get, msm_device_volume_put, 0), - MSM_EXT("Reset", msm_reset_info, - msm_reset_get, msm_reset_put, 0), - MSM_EXT("DualMic Switch", msm_dual_mic_info, - msm_dual_mic_get, msm_dual_mic_put, 0), - MSM_EXT("Device_Mute", msm_device_mute_info, - msm_device_mute_get, msm_device_mute_put, 0), - MSM_EXT("Sound Device Loopback", msm_loopback_info, - msm_loopback_get, msm_loopback_put, 0), -}; - -static int msm_new_mixer(struct snd_soc_codec *codec) -{ - unsigned int idx; - int err; - int dev_cnt; - - strcpy(codec->card->snd_card->mixername, "MSM Mixer"); - for (idx = 0; idx < ARRAY_SIZE(snd_msm_controls); idx++) { - err = snd_ctl_add(codec->card->snd_card, - snd_ctl_new1(&snd_msm_controls[idx], NULL)); - if (err < 0) - MM_ERR("ERR adding ctl\n"); - } - dev_cnt = msm_snddev_devcount(); - - for (idx = 0; idx < dev_cnt; idx++) { - if (!snd_dev_ctl_index(idx)) { - err = snd_ctl_add(codec->card->snd_card, - snd_ctl_new1(&snd_dev_controls[idx], NULL)); - if (err < 0) - MM_ERR("ERR adding ctl\n"); - } else - return 0; - } - simple_control = ARRAY_SIZE(snd_msm_controls); - device_index = simple_control + 1; - return 0; -} - -static int msm_soc_dai_init( - struct snd_soc_pcm_runtime *rtd) -{ - int ret = 0; - struct snd_soc_codec *codec = rtd->codec; - ret = msm_new_mixer(codec); - if (ret < 0) - MM_ERR("msm_soc: ALSA MSM Mixer Fail\n"); - - mutex_init(&the_locks.lock); - mutex_init(&the_locks.write_lock); - mutex_init(&the_locks.read_lock); - spin_lock_init(&the_locks.read_dsp_lock); - spin_lock_init(&the_locks.write_dsp_lock); - spin_lock_init(&the_locks.mixer_lock); - init_waitqueue_head(&the_locks.enable_wait); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - src_dev = DEVICE_IGNORE; - dst_dev = DEVICE_IGNORE; - - return ret; -} - -static struct snd_soc_dai_link msm_dai[] = { -{ - .name = "MSM Primary I2S", - .stream_name = "DSP 1", - .cpu_dai_name = "msm-cpu-dai.0", - .platform_name = "msm-dsp-audio.0", - .codec_name = "msm-codec-dai.0", - .codec_dai_name = "msm-codec-dai", - .init = &msm_soc_dai_init, -}, -#ifdef CONFIG_SND_MVS_SOC -{ - .name = "MSM Primary Voip", - .stream_name = "MVS", - .cpu_dai_name = "mvs-cpu-dai.0", - .platform_name = "msm-mvs-audio.0", - .codec_name = "mvs-codec-dai.0", - .codec_dai_name = "mvs-codec-dai", -}, -#endif -}; - -static struct snd_soc_card snd_soc_card_msm = { - .name = "msm-audio", - .dai_link = msm_dai, - .num_links = ARRAY_SIZE(msm_dai), -}; - -static int __init msm_audio_init(void) -{ - int ret; - - msm_audio_snd_device = platform_device_alloc("soc-audio", -1); - if (!msm_audio_snd_device) - return -ENOMEM; - - platform_set_drvdata(msm_audio_snd_device, &snd_soc_card_msm); - ret = platform_device_add(msm_audio_snd_device); - if (ret) { - platform_device_put(msm_audio_snd_device); - return ret; - } - - return ret; -} - -static void __exit msm_audio_exit(void) -{ - platform_device_unregister(msm_audio_snd_device); -} - -module_init(msm_audio_init); -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("PCM module"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm8660-apq-wm8903.c b/sound/soc/msm/msm8660-apq-wm8903.c deleted file mode 100644 index 7a20e4f4be085cfcdad344afc27c0459753d537c..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8660-apq-wm8903.c +++ /dev/null @@ -1,724 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "../codecs/wm8903.h" - -#define MSM_GPIO_CLASS_D0_EN 80 -#define MSM_GPIO_CLASS_D1_EN 81 - -#define MSM_CDC_MIC_I2S_MCLK 108 - -static int msm8660_spk_func; -static int msm8660_headset_func; -static int msm8660_headphone_func; - -static struct clk *mic_bit_clk; -static struct clk *spkr_osr_clk; -static struct clk *spkr_bit_clk; -static struct clk *wm8903_mclk; - -static int rx_hw_param_status; -static int tx_hw_param_status; -/* Platform specific logic */ - -enum { - GET_ERR, - SET_ERR, - ENABLE_ERR, - NONE -}; - -enum { - FUNC_OFF, - FUNC_ON, -}; - -static struct wm8903_vdd { - struct regulator *reg_id; - const char *name; - u32 voltage; -} wm8903_vdds[] = { - { NULL, "8058_l16", 1800000 }, - { NULL, "8058_l0", 1200000 }, - { NULL, "8058_s3", 1800000 }, -}; - -static void classd_amp_pwr(int enable) -{ - int rc; - - pr_debug("%s, enable = %d\n", __func__, enable); - if (enable) { - /* currently external PA isn't used for LINEOUTL */ - rc = gpio_request(MSM_GPIO_CLASS_D0_EN, "CLASSD0_EN"); - if (rc) { - pr_err("%s: spkr PA gpio %d request failed\n", - __func__, MSM_GPIO_CLASS_D0_EN); - return; - } - gpio_direction_output(MSM_GPIO_CLASS_D0_EN, 1); - gpio_set_value_cansleep(MSM_GPIO_CLASS_D0_EN, 1); - rc = gpio_request(MSM_GPIO_CLASS_D1_EN, "CLASSD1_EN"); - if (rc) { - pr_err("%s: spkr PA gpio %d request failed\n", - __func__, MSM_GPIO_CLASS_D1_EN); - return; - } - gpio_direction_output(MSM_GPIO_CLASS_D1_EN, 1); - gpio_set_value_cansleep(MSM_GPIO_CLASS_D1_EN, 1); - } else { - gpio_set_value_cansleep(MSM_GPIO_CLASS_D0_EN, 0); - gpio_free(MSM_GPIO_CLASS_D0_EN); - - gpio_set_value_cansleep(MSM_GPIO_CLASS_D1_EN, 0); - gpio_free(MSM_GPIO_CLASS_D1_EN); - } -} - -static void extern_poweramp_on(void) -{ - pr_debug("%s: enable stereo spkr amp\n", __func__); - classd_amp_pwr(1); -} - -static void extern_poweramp_off(void) -{ - pr_debug("%s: disable stereo spkr amp\n", __func__); - classd_amp_pwr(0); -} - -static int msm8660_wm8903_powerup(void) -{ - int rc = 0, index, stage = NONE; - struct wm8903_vdd *vdd = NULL; - - for (index = 0; index < ARRAY_SIZE(wm8903_vdds); index++) { - vdd = &wm8903_vdds[index]; - vdd->reg_id = regulator_get(NULL, vdd->name); - if (IS_ERR(vdd->reg_id)) { - pr_err("%s: Unable to get %s\n", __func__, vdd->name); - stage = GET_ERR; - rc = -ENODEV; - break; - } - - rc = regulator_set_voltage(vdd->reg_id, - vdd->voltage, vdd->voltage); - if (rc) { - pr_err("%s: unable to set %s voltage to %dV\n", - __func__, vdd->name, vdd->voltage); - stage = SET_ERR; - break; - } - - rc = regulator_enable(vdd->reg_id); - if (rc) { - pr_err("%s:failed to enable %s\n", __func__, vdd->name); - stage = ENABLE_ERR; - break; - } - } - - if (index != ARRAY_SIZE(wm8903_vdds)) { - if (stage != GET_ERR) { - vdd = &wm8903_vdds[index]; - regulator_put(vdd->reg_id); - vdd->reg_id = NULL; - } - - while (index--) { - vdd = &wm8903_vdds[index]; - regulator_disable(vdd->reg_id); - regulator_put(vdd->reg_id); - vdd->reg_id = NULL; - } - } - - return rc; -} - -static void msm8660_wm8903_powerdown(void) -{ - int index = ARRAY_SIZE(wm8903_vdds); - struct wm8903_vdd *vdd = NULL; - - while (index--) { - vdd = &wm8903_vdds[index]; - if (vdd->reg_id) { - regulator_disable(vdd->reg_id); - regulator_put(vdd->reg_id); - } - } -} - -static int msm8660_wm8903_enable_mclk(int enable) -{ - int ret = 0; - - if (enable) { - ret = gpio_request(MSM_CDC_MIC_I2S_MCLK, "I2S_Clock"); - if (ret != 0) { - pr_err("%s: failed to request GPIO\n", __func__); - return ret; - } - - wm8903_mclk = clk_get_sys(NULL, "i2s_mic_osr_clk"); - if (IS_ERR(wm8903_mclk)) { - pr_err("Failed to get i2s_mic_osr_clk\n"); - gpio_free(MSM_CDC_MIC_I2S_MCLK); - return IS_ERR(wm8903_mclk); - } - /* Master clock OSR 256 */ - clk_set_rate(wm8903_mclk, 48000 * 256); - ret = clk_prepare_enable(wm8903_mclk); - if (ret != 0) { - pr_err("Unable to enable i2s_mic_osr_clk\n"); - gpio_free(MSM_CDC_MIC_I2S_MCLK); - clk_put(wm8903_mclk); - return ret; - } - } else { - if (wm8903_mclk) { - clk_disable_unprepare(wm8903_mclk); - clk_put(wm8903_mclk); - gpio_free(MSM_CDC_MIC_I2S_MCLK); - wm8903_mclk = NULL; - } - } - - return ret; -} - -static int msm8660_wm8903_prepare(void) -{ - int ret = 0; - - ret = msm8660_wm8903_powerup(); - if (ret) { - pr_err("Unable to powerup wm8903\n"); - return ret; - } - - ret = msm8660_wm8903_enable_mclk(1); - if (ret) { - pr_err("Unable to enable mclk to wm8903\n"); - return ret; - } - - return ret; -} - -static void msm8660_wm8903_unprepare(void) -{ - msm8660_wm8903_powerdown(); - msm8660_wm8903_enable_mclk(0); -} - -static int msm8660_i2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int rate = params_rate(params), ret = 0; - - pr_debug("Enter %s rate = %d\n", __func__, rate); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (rx_hw_param_status) - return 0; - /* wm8903 run @ LRC*256 */ - ret = snd_soc_dai_set_sysclk(codec_dai, 0, rate * 256, - SND_SOC_CLOCK_IN); - snd_soc_dai_digital_mute(codec_dai, 0); - if (ret < 0) { - pr_err("can't set rx codec clk configuration\n"); - return ret; - } - clk_set_rate(wm8903_mclk, rate * 256); - /* set as slave mode CPU */ - clk_set_rate(spkr_bit_clk, 0); - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - rx_hw_param_status++; - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (tx_hw_param_status) - return 0; - clk_set_rate(wm8903_mclk, rate * 256); - ret = snd_soc_dai_set_sysclk(codec_dai, 0, rate * 256, - SND_SOC_CLOCK_IN); - if (ret < 0) { - pr_err("can't set tx codec clk configuration\n"); - return ret; - } - clk_set_rate(mic_bit_clk, 0); - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - tx_hw_param_status++; - } - return 0; -} - -static int msm8660_i2s_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - pr_debug("Enter %s\n", __func__); - /* ON Dragonboard, I2S between wm8903 and CPU is shared by - * CODEC_SPEAKER and CODEC_MIC therefore CPU only can operate - * as input SLAVE mode. - */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - /* config WM8903 in Mater mode */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBM_CFM | - SND_SOC_DAIFMT_I2S); - if (ret != 0) { - pr_err("codec_dai set_fmt error\n"); - return ret; - } - /* config CPU in SLAVE mode */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - if (ret != 0) { - pr_err("cpu_dai set_fmt error\n"); - return ret; - } - spkr_osr_clk = clk_get_sys(NULL, "i2s_spkr_osr_clk"); - if (IS_ERR(spkr_osr_clk)) { - pr_err("Failed to get i2s_spkr_osr_clk\n"); - return PTR_ERR(spkr_osr_clk); - } - clk_set_rate(spkr_osr_clk, 48000 * 256); - ret = clk_prepare_enable(spkr_osr_clk); - if (ret != 0) { - pr_err("Unable to enable i2s_spkr_osr_clk\n"); - clk_put(spkr_osr_clk); - return ret; - } - spkr_bit_clk = clk_get_sys(NULL, "i2s_spkr_bit_clk"); - if (IS_ERR(spkr_bit_clk)) { - pr_err("Failed to get i2s_spkr_bit_clk\n"); - clk_disable_unprepare(spkr_osr_clk); - clk_put(spkr_osr_clk); - return PTR_ERR(spkr_bit_clk); - } - clk_set_rate(spkr_bit_clk, 0); - ret = clk_prepare_enable(spkr_bit_clk); - if (ret != 0) { - pr_err("Unable to enable i2s_spkr_bit_clk\n"); - clk_disable_unprepare(spkr_osr_clk); - clk_put(spkr_osr_clk); - clk_put(spkr_bit_clk); - return ret; - } - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - /* config WM8903 in Mater mode */ - ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBM_CFM | - SND_SOC_DAIFMT_I2S); - if (ret != 0) { - pr_err("codec_dai set_fmt error\n"); - return ret; - } - /* config CPU in SLAVE mode */ - ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM); - if (ret != 0) { - pr_err("codec_dai set_fmt error\n"); - return ret; - } - - mic_bit_clk = clk_get_sys(NULL, "i2s_mic_bit_clk"); - if (IS_ERR(mic_bit_clk)) { - pr_err("Failed to get i2s_mic_bit_clk\n"); - return PTR_ERR(mic_bit_clk); - } - clk_set_rate(mic_bit_clk, 0); - ret = clk_prepare_enable(mic_bit_clk); - if (ret != 0) { - pr_err("Unable to enable i2s_mic_bit_clk\n"); - clk_put(mic_bit_clk); - return ret; - } - } - return ret; -} - -static void msm8660_i2s_shutdown(struct snd_pcm_substream *substream) -{ - pr_debug("Enter %s\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || - substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - tx_hw_param_status = 0; - rx_hw_param_status = 0; - if (spkr_bit_clk) { - clk_disable_unprepare(spkr_bit_clk); - clk_put(spkr_bit_clk); - spkr_bit_clk = NULL; - } - if (spkr_osr_clk) { - clk_disable_unprepare(spkr_osr_clk); - clk_put(spkr_osr_clk); - spkr_osr_clk = NULL; - } - if (mic_bit_clk) { - clk_disable_unprepare(mic_bit_clk); - clk_put(mic_bit_clk); - mic_bit_clk = NULL; - } - } -} - -static void msm8660_ext_control(struct snd_soc_codec *codec) -{ - /* set the enpoints to their new connetion states */ - if (msm8660_spk_func == FUNC_ON) - snd_soc_dapm_enable_pin(&codec->dapm, "Ext Spk"); - else - snd_soc_dapm_disable_pin(&codec->dapm, "Ext Spk"); - - /* set the enpoints to their new connetion states */ - if (msm8660_headset_func == FUNC_ON) - snd_soc_dapm_enable_pin(&codec->dapm, "Headset Jack"); - else - snd_soc_dapm_disable_pin(&codec->dapm, "Headset Jack"); - - /* set the enpoints to their new connetion states */ - if (msm8660_headphone_func == FUNC_ON) - snd_soc_dapm_enable_pin(&codec->dapm, "Headphone Jack"); - else - snd_soc_dapm_disable_pin(&codec->dapm, "Headphone Jack"); - - /* signal a DAPM event */ - snd_soc_dapm_sync(&codec->dapm); -} - -static int msm8660_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm8660_spk_func; - return 0; -} - -static int msm8660_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm8660_spk_func == ucontrol->value.integer.value[0]) - return 0; - - msm8660_spk_func = ucontrol->value.integer.value[0]; - msm8660_ext_control(codec); - return 1; -} - -static int msm8660_get_hs(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm8660_headset_func; - return 0; -} - -static int msm8660_set_hs(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm8660_headset_func == ucontrol->value.integer.value[0]) - return 0; - - msm8660_headset_func = ucontrol->value.integer.value[0]; - msm8660_ext_control(codec); - return 1; -} - -static int msm8660_get_hph(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = msm8660_headphone_func; - return 0; -} - -static int msm8660_set_hph(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm8660_headphone_func == ucontrol->value.integer.value[0]) - return 0; - - msm8660_headphone_func = ucontrol->value.integer.value[0]; - msm8660_ext_control(codec); - return 1; -} - -static int msm8660_spkramp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - if (SND_SOC_DAPM_EVENT_ON(event)) - extern_poweramp_on(); - else - extern_poweramp_off(); - return 0; -} - -static struct snd_soc_ops machine_ops = { - .startup = msm8660_i2s_startup, - .shutdown = msm8660_i2s_shutdown, - .hw_params = msm8660_i2s_hw_params, -}; - -static const struct snd_soc_dapm_widget msm8660_dapm_widgets[] = { - SND_SOC_DAPM_SPK("Ext Spk", msm8660_spkramp_event), - SND_SOC_DAPM_MIC("Headset Jack", NULL), - SND_SOC_DAPM_MIC("Headphone Jack", NULL), - /* to fix a bug in wm8903.c, where audio doesn't function - * after suspend/resume - */ - SND_SOC_DAPM_SUPPLY("CLK_SYS_ENA", WM8903_CLOCK_RATES_2, 2, 0, NULL, 0), -}; - -static const struct snd_soc_dapm_route audio_map[] = { - /* Match with wm8903 codec line out pin */ - {"Ext Spk", NULL, "LINEOUTL"}, - {"Ext Spk", NULL, "LINEOUTR"}, - /* Headset connects to IN3L with Bias */ - {"IN3L", NULL, "Mic Bias"}, - {"Mic Bias", NULL, "Headset Jack"}, - /* Headphone connects to IN3R with Bias */ - {"IN3R", NULL, "Mic Bias"}, - {"Mic Bias", NULL, "Headphone Jack"}, - {"ADCL", NULL, "CLK_SYS_ENA"}, - {"ADCR", NULL, "CLK_SYS_ENA"}, - {"DACL", NULL, "CLK_SYS_ENA"}, - {"DACR", NULL, "CLK_SYS_ENA"}, -}; - -static const char *cmn_status[] = {"Off", "On"}; -static const struct soc_enum msm8660_enum[] = { - SOC_ENUM_SINGLE_EXT(2, cmn_status), -}; - -static const struct snd_kcontrol_new wm8903_msm8660_controls[] = { - SOC_ENUM_EXT("Speaker Function", msm8660_enum[0], msm8660_get_spk, - msm8660_set_spk), - SOC_ENUM_EXT("Headset Function", msm8660_enum[0], msm8660_get_hs, - msm8660_set_hs), - SOC_ENUM_EXT("Headphone Function", msm8660_enum[0], msm8660_get_hph, - msm8660_set_hph), -}; - -static int msm8660_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - int err; - - snd_soc_dapm_disable_pin(&codec->dapm, "Ext Spk"); - snd_soc_dapm_enable_pin(&codec->dapm, "CLK_SYS_ENA"); - - err = snd_soc_add_controls(codec, wm8903_msm8660_controls, - ARRAY_SIZE(wm8903_msm8660_controls)); - if (err < 0) - return err; - - snd_soc_dapm_new_controls(&codec->dapm, msm8660_dapm_widgets, - ARRAY_SIZE(msm8660_dapm_widgets)); - - snd_soc_dapm_add_routes(&codec->dapm, audio_map, ARRAY_SIZE(audio_map)); - - snd_soc_dapm_sync(&codec->dapm); - - return 0; -} - -static int pri_i2s_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - rate->min = rate->max = 48000; - return 0; -} -/* - * LPA Needs only RX BE DAI links. - * Hence define seperate BE list for lpa - */ -static const char *lpa_mm_be[] = { - LPASS_BE_PRI_I2S_RX, -}; - -static struct snd_soc_dsp_link lpa_fe_media = { - .supported_be = lpa_mm_be, - .num_be = ARRAY_SIZE(lpa_mm_be), - .fe_playback_channels = 2, - .fe_capture_channels = 1, - .trigger = { - SND_SOC_DSP_TRIGGER_POST, - SND_SOC_DSP_TRIGGER_POST - }, -}; - -static const char *mm1_be[] = { - LPASS_BE_PRI_I2S_RX, - LPASS_BE_PRI_I2S_TX, - LPASS_BE_HDMI, -}; - -static struct snd_soc_dsp_link fe_media = { - .supported_be = mm1_be, - .num_be = ARRAY_SIZE(mm1_be), - .fe_playback_channels = 2, - .fe_capture_channels = 1, - .trigger = { - SND_SOC_DSP_TRIGGER_POST, SND_SOC_DSP_TRIGGER_POST}, -}; - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm8660_dai[] = { - /* FrontEnd DAI Links */ - { - .name = "MSM8660 Media", - .stream_name = "MultiMedia", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .dsp_link = &fe_media, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MSM8660 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .dsp_link = &fe_media, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - /* Backend DAI Links */ - { - .name = LPASS_BE_PRI_I2S_RX, - .stream_name = "Primary I2S Playback", - .cpu_dai_name = "msm-dai-q6.0", - .platform_name = "msm-pcm-routing", - .codec_name = "wm8903-codec.3-001a", - .codec_dai_name = "wm8903-hifi", - .no_pcm = 1, - .be_hw_params_fixup = pri_i2s_be_hw_params_fixup, - .ops = &machine_ops, - .init = &msm8660_audrx_init, - .be_id = MSM_BACKEND_DAI_PRI_I2S_RX - }, - { - .name = LPASS_BE_PRI_I2S_TX, - .stream_name = "Primary I2S Capture", - .cpu_dai_name = "msm-dai-q6.1", - .platform_name = "msm-pcm-routing", - .codec_name = "wm8903-codec.3-001a", - .codec_dai_name = "wm8903-hifi", - .no_pcm = 1, - .ops = &machine_ops, - .be_hw_params_fixup = pri_i2s_be_hw_params_fixup, - .be_id = MSM_BACKEND_DAI_PRI_I2S_TX - }, - /* LPA frontend DAI link*/ - { - .name = "MSM8660 LPA", - .stream_name = "LPA", - .cpu_dai_name = "MultiMedia3", - .platform_name = "msm-pcm-lpa", - .dynamic = 1, - .dsp_link = &lpa_fe_media, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3, - }, - /* HDMI backend DAI link */ - { - .name = LPASS_BE_HDMI, - .stream_name = "HDMI Playback", - .cpu_dai_name = "msm-dai-q6.8", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_codec = 1, - .no_pcm = 1, - .be_hw_params_fixup = pri_i2s_be_hw_params_fixup, - .be_id = MSM_BACKEND_DAI_HDMI_RX - }, -}; - -struct snd_soc_card snd_soc_card_msm8660 = { - .name = "msm8660-snd-card", - .dai_link = msm8660_dai, - .num_links = ARRAY_SIZE(msm8660_dai), -}; - -static struct platform_device *msm_snd_device; - -static int __init msm_audio_init(void) -{ - int ret = 0; - - if (machine_is_msm8x60_dragon()) { - /* wm8903 audio codec needs to power up and mclk existing - before it's probed */ - ret = msm8660_wm8903_prepare(); - if (ret) { - pr_err("failed to prepare wm8903 audio codec\n"); - return ret; - } - - msm_snd_device = platform_device_alloc("soc-audio", 0); - if (!msm_snd_device) { - pr_err("Platform device allocation failed\n"); - msm8660_wm8903_unprepare(); - return -ENOMEM; - } - - platform_set_drvdata(msm_snd_device, &snd_soc_card_msm8660); - ret = platform_device_add(msm_snd_device); - if (ret) { - platform_device_put(msm_snd_device); - msm8660_wm8903_unprepare(); - return ret; - } - } - return ret; - -} -module_init(msm_audio_init); - -static void __exit msm_audio_exit(void) -{ - msm8660_wm8903_unprepare(); - platform_device_unregister(msm_snd_device); -} -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC MSM8660"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm8660.c b/sound/soc/msm/msm8660.c deleted file mode 100644 index 6d7d2eec384954c1b1ca40e11f54a11bec504bf4..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8660.c +++ /dev/null @@ -1,342 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm8660-pcm.h" -#include "../codecs/timpani.h" - -#define PM8058_GPIO_BASE NR_MSM_GPIOS -#define PM8901_GPIO_BASE (PM8058_GPIO_BASE + \ - PM8058_GPIOS + PM8058_MPPS) -#define PM8901_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + PM8901_GPIO_BASE) -#define GPIO_EXPANDER_GPIO_BASE \ - (PM8901_GPIO_BASE + PM8901_MPPS) - -static struct clk *rx_osr_clk; -static struct clk *rx_bit_clk; -static struct clk *tx_osr_clk; -static struct clk *tx_bit_clk; - -static int rx_hw_param_status; -static int tx_hw_param_status; -/* Platform specific logic */ - -static int timpani_rx_route_enable(void) -{ - int ret = 0; - pr_debug("%s\n", __func__); - ret = gpio_request(109, "I2S_Clock"); - if (ret != 0) { - pr_err("%s: I2s clk gpio 109 request" - "failed\n", __func__); - return ret; - } - return ret; -} - -static int timpani_rx_route_disable(void) -{ - int ret = 0; - pr_debug("%s\n", __func__); - gpio_free(109); - return ret; -} - - -#define GPIO_CLASS_D1_EN (GPIO_EXPANDER_GPIO_BASE + 0) -#define PM8901_MPP_3 (2) /* PM8901 MPP starts from 0 */ -static void config_class_d1_gpio(int enable) -{ - int rc; - - if (enable) { - rc = gpio_request(GPIO_CLASS_D1_EN, "CLASSD1_EN"); - if (rc) { - pr_err("%s: spkr pamp gpio %d request" - "failed\n", __func__, GPIO_CLASS_D1_EN); - return; - } - gpio_direction_output(GPIO_CLASS_D1_EN, 1); - gpio_set_value_cansleep(GPIO_CLASS_D1_EN, 1); - } else { - gpio_set_value_cansleep(GPIO_CLASS_D1_EN, 0); - gpio_free(GPIO_CLASS_D1_EN); - } -} - -static void config_class_d0_gpio(int enable) -{ - int rc; - - if (enable) { - rc = pm8901_mpp_config_digital_out(PM8901_MPP_3, - PM8901_MPP_DIG_LEVEL_MSMIO, 1); - - if (rc) { - pr_err("%s: CLASS_D0_EN failed\n", __func__); - return; - } - - rc = gpio_request(PM8901_GPIO_PM_TO_SYS(PM8901_MPP_3), - "CLASSD0_EN"); - - if (rc) { - pr_err("%s: spkr pamp gpio pm8901 mpp3 request" - "failed\n", __func__); - pm8901_mpp_config_digital_out(PM8901_MPP_3, - PM8901_MPP_DIG_LEVEL_MSMIO, 0); - return; - } - - gpio_direction_output(PM8901_GPIO_PM_TO_SYS(PM8901_MPP_3), 1); - gpio_set_value_cansleep(PM8901_GPIO_PM_TO_SYS(PM8901_MPP_3), 1); - - } else { - pm8901_mpp_config_digital_out(PM8901_MPP_3, - PM8901_MPP_DIG_LEVEL_MSMIO, 0); - gpio_set_value_cansleep(PM8901_GPIO_PM_TO_SYS(PM8901_MPP_3), 0); - gpio_free(PM8901_GPIO_PM_TO_SYS(PM8901_MPP_3)); - } -} - -static void timpani_poweramp_on(void) -{ - - pr_debug("%s: enable stereo spkr amp\n", __func__); - timpani_rx_route_enable(); - config_class_d0_gpio(1); - config_class_d1_gpio(1); -} - -static void timpani_poweramp_off(void) -{ - - pr_debug("%s: disable stereo spkr amp\n", __func__); - timpani_rx_route_disable(); - config_class_d0_gpio(0); - config_class_d1_gpio(0); -} - -static int msm8660_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - int rate = params_rate(params); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (rx_hw_param_status) - return 0; - clk_set_rate(rx_osr_clk, rate * 256); - rx_hw_param_status++; - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - if (tx_hw_param_status) - return 0; - clk_set_rate(tx_osr_clk, rate * 256); - tx_hw_param_status++; - } - return 0; -} - -static int msm8660_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - rx_osr_clk = clk_get(NULL, "i2s_spkr_osr_clk"); - if (IS_ERR(rx_osr_clk)) { - pr_debug("Failed to get i2s_spkr_osr_clk\n"); - return PTR_ERR(rx_osr_clk); - } - /* Master clock OSR 256 */ - /* Initially set to Lowest sample rate Needed */ - clk_set_rate(rx_osr_clk, 8000 * 256); - ret = clk_prepare_enable(rx_osr_clk); - if (ret != 0) { - pr_debug("Unable to enable i2s_spkr_osr_clk\n"); - clk_put(rx_osr_clk); - return ret; - } - rx_bit_clk = clk_get(NULL, "i2s_spkr_bit_clk"); - if (IS_ERR(rx_bit_clk)) { - pr_debug("Failed to get i2s_spkr_bit_clk\n"); - clk_disable_unprepare(rx_osr_clk); - clk_put(rx_osr_clk); - return PTR_ERR(rx_bit_clk); - } - clk_set_rate(rx_bit_clk, 8); - ret = clk_prepare_enable(rx_bit_clk); - if (ret != 0) { - pr_debug("Unable to enable i2s_spkr_bit_clk\n"); - clk_put(rx_bit_clk); - clk_disable_unprepare(rx_osr_clk); - clk_put(rx_osr_clk); - return ret; - } - timpani_poweramp_on(); - msleep(30); - /* End of platform specific logic */ - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - tx_osr_clk = clk_get(NULL, "i2s_mic_osr_clk"); - if (IS_ERR(tx_osr_clk)) { - pr_debug("Failed to get i2s_mic_osr_clk\n"); - return PTR_ERR(tx_osr_clk); - } - /* Master clock OSR 256 */ - clk_set_rate(tx_osr_clk, 8000 * 256); - ret = clk_prepare_enable(tx_osr_clk); - if (ret != 0) { - pr_debug("Unable to enable i2s_mic_osr_clk\n"); - clk_put(tx_osr_clk); - return ret; - } - tx_bit_clk = clk_get(NULL, "i2s_mic_bit_clk"); - if (IS_ERR(tx_bit_clk)) { - pr_debug("Failed to get i2s_mic_bit_clk\n"); - clk_disable_unprepare(tx_osr_clk); - clk_put(tx_osr_clk); - return PTR_ERR(tx_bit_clk); - } - clk_set_rate(tx_bit_clk, 8); - ret = clk_prepare_enable(tx_bit_clk); - if (ret != 0) { - pr_debug("Unable to enable i2s_mic_bit_clk\n"); - clk_put(tx_bit_clk); - clk_disable_unprepare(tx_osr_clk); - clk_put(tx_osr_clk); - return ret; - } - msm_snddev_enable_dmic_power(); - msleep(30); - } - return ret; -} - -/* - * TODO: rx/tx_hw_param_status should be a counter in the below code - * when driver starts supporting mutisession else setting it to 0 - * will stop audio in all sessions. - */ -static void msm8660_shutdown(struct snd_pcm_substream *substream) -{ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - rx_hw_param_status = 0; - timpani_poweramp_off(); - msleep(30); - if (rx_bit_clk) { - clk_disable_unprepare(rx_bit_clk); - clk_put(rx_bit_clk); - rx_bit_clk = NULL; - } - if (rx_osr_clk) { - clk_disable_unprepare(rx_osr_clk); - clk_put(rx_osr_clk); - rx_osr_clk = NULL; - } - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - tx_hw_param_status = 0; - msm_snddev_disable_dmic_power(); - msleep(30); - if (tx_bit_clk) { - clk_disable_unprepare(tx_bit_clk); - clk_put(tx_bit_clk); - tx_bit_clk = NULL; - } - if (tx_osr_clk) { - clk_disable_unprepare(tx_osr_clk); - clk_put(tx_osr_clk); - tx_osr_clk = NULL; - } - } -} - -static struct snd_soc_ops machine_ops = { - .startup = msm8660_startup, - .shutdown = msm8660_shutdown, - .hw_params = msm8660_hw_params, -}; - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm8660_dai[] = { - { - .name = "Audio Rx", - .stream_name = "Audio Rx", - .cpu_dai = &msm_cpu_dai[0], - .codec_dai = &timpani_codec_dai[0], - .ops = &machine_ops, - }, - { - .name = "Audio Tx", - .stream_name = "Audio Tx", - .cpu_dai = &msm_cpu_dai[5], - .codec_dai = &timpani_codec_dai[1], - .ops = &machine_ops, - } -}; - -struct snd_soc_card snd_soc_card_msm8660 = { - .name = "msm8660-pcm-audio", - .dai_link = msm8660_dai, - .num_links = ARRAY_SIZE(msm8660_dai), - .platform = &msm8660_soc_platform, -}; - -/* msm_audio audio subsystem */ -static struct snd_soc_device msm_snd_devdata = { - .card = &snd_soc_card_msm8660, - .codec_dev = &soc_codec_dev_timpani, -}; - -static struct platform_device *msm_snd_device; - - -static int __init msm_audio_init(void) -{ - int ret; - - msm_snd_device = platform_device_alloc("soc-audio", 0); - if (!msm_snd_device) { - pr_err("Platform device allocation failed\n"); - return -ENOMEM; - } - - platform_set_drvdata(msm_snd_device, &msm_snd_devdata); - - msm_snd_devdata.dev = &msm_snd_device->dev; - ret = platform_device_add(msm_snd_device); - if (ret) { - platform_device_put(msm_snd_device); - return ret; - } - - return ret; -} -module_init(msm_audio_init); - -static void __exit msm_audio_exit(void) -{ - platform_device_unregister(msm_snd_device); -} -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC MSM8660"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm8930.c b/sound/soc/msm/msm8930.c deleted file mode 100644 index d9f4c8aed2eaf372d333c32d524cd4968c9e4e9f..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8930.c +++ /dev/null @@ -1,1424 +0,0 @@ -/* Copyright (c) 2012-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "../codecs/wcd9304.h" - -/* 8930 machine driver */ - -#define MSM8930_SPK_ON 1 -#define MSM8930_SPK_OFF 0 - -#define BTSCO_RATE_8KHZ 8000 -#define BTSCO_RATE_16KHZ 16000 - -#define SPK_AMP_POS 0x1 -#define SPK_AMP_NEG 0x2 -#define SPKR_BOOST_GPIO 15 -#define LEFT_SPKR_AMPL_GPIO 15 -#define DEFAULT_PMIC_SPK_GAIN 0x0D -#define SITAR_EXT_CLK_RATE 12288000 - -#define SITAR_MBHC_DEF_BUTTONS 8 -#define SITAR_MBHC_DEF_RLOADS 5 - -#define GPIO_AUX_PCM_DOUT 63 -#define GPIO_AUX_PCM_DIN 64 -#define GPIO_AUX_PCM_SYNC 65 -#define GPIO_AUX_PCM_CLK 66 - -static int msm8930_spk_control; -static int msm8930_slim_0_rx_ch = 1; -static int msm8930_slim_0_tx_ch = 1; -static int msm8930_pmic_spk_gain = DEFAULT_PMIC_SPK_GAIN; - -static int msm8930_ext_spk_pamp; -static int msm8930_btsco_rate = BTSCO_RATE_8KHZ; -static int msm8930_btsco_ch = 1; -static int hdmi_rate_variable; -static struct clk *codec_clk; -static int clk_users; - -static int msm8930_headset_gpios_configured; -static struct mutex cdc_mclk_mutex; - -static struct snd_soc_jack hs_jack; -static struct snd_soc_jack button_jack; -static atomic_t auxpcm_rsc_ref; - -static int msm8930_enable_codec_ext_clk( - struct snd_soc_codec *codec, int enable, - bool dapm); - -static struct sitar_mbhc_config mbhc_cfg = { - .headset_jack = &hs_jack, - .button_jack = &button_jack, - .read_fw_bin = false, - .calibration = NULL, - .micbias = SITAR_MICBIAS2, - .mclk_cb_fn = msm8930_enable_codec_ext_clk, - .mclk_rate = SITAR_EXT_CLK_RATE, - .gpio = 0, - .gpio_irq = 0, - .gpio_level_insert = 1, -}; - - -static void msm8930_ext_control(struct snd_soc_codec *codec) -{ - struct snd_soc_dapm_context *dapm = &codec->dapm; - - pr_debug("%s: msm8930_spk_control = %d", __func__, msm8930_spk_control); - if (msm8930_spk_control == MSM8930_SPK_ON) { - snd_soc_dapm_enable_pin(dapm, "Ext Spk Left Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk left Neg"); - } else { - snd_soc_dapm_disable_pin(dapm, "Ext Spk Left Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Left Neg"); - } - - snd_soc_dapm_sync(dapm); -} - -static int msm8930_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8930_spk_control = %d", __func__, msm8930_spk_control); - ucontrol->value.integer.value[0] = msm8930_spk_control; - return 0; -} -static int msm8930_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm8930_spk_control == ucontrol->value.integer.value[0]) - return 0; - - msm8930_spk_control = ucontrol->value.integer.value[0]; - msm8930_ext_control(codec); - return 1; -} - -static int msm8930_cfg_spkr_gpio(int gpio, - int enable, const char *gpio_label) -{ - int ret = 0; - - pr_debug("%s: Configure %s GPIO %u", - __func__, gpio_label, gpio); - ret = gpio_request(gpio, gpio_label); - if (ret) - return ret; - - pr_debug("%s: Enable %s gpio %u\n", - __func__, gpio_label, gpio); - gpio_direction_output(gpio, enable); - - return ret; -} - -static void msm8960_ext_spk_power_amp_on(u32 spk) -{ - int ret = 0; - - if (spk & (SPK_AMP_POS | SPK_AMP_NEG)) { - if ((msm8930_ext_spk_pamp & SPK_AMP_POS) && - (msm8930_ext_spk_pamp & SPK_AMP_NEG)) { - - pr_debug("%s() External Bottom Speaker Ampl already " - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - msm8930_ext_spk_pamp |= spk; - - if ((msm8930_ext_spk_pamp & SPK_AMP_POS) && - (msm8930_ext_spk_pamp & SPK_AMP_NEG)) { - - if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) { - ret = msm8930_cfg_spkr_gpio( - LEFT_SPKR_AMPL_GPIO, - 1, "LEFT_SPKR_AMPL"); - if (ret) { - pr_err("%s: Failed to config ampl gpio %u\n", - __func__, LEFT_SPKR_AMPL_GPIO); - return; - } - } else { - - /* - * 8930 CDP does not have a 5V speaker boost, - * hence the GPIO enable for speaker boost is - * only required for platforms other than CDP - */ - if (!machine_is_msm8930_cdp()) { - ret = msm8930_cfg_spkr_gpio( - SPKR_BOOST_GPIO, 1, "SPKR_BOOST"); - if (ret) { - pr_err("%s: Failure: spkr boost gpio %u\n", - __func__, SPKR_BOOST_GPIO); - return; - } - } - pm8xxx_spk_enable(MSM8930_SPK_ON); - } - - pr_debug("%s: sleeping 10 ms after turning on external " - " Left Speaker Ampl\n", __func__); - usleep_range(10000, 10000); - } - - } else { - - pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm8960_ext_spk_power_amp_off(u32 spk) -{ - if (spk & (SPK_AMP_POS | SPK_AMP_NEG)) { - if (!msm8930_ext_spk_pamp) - return; - - if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) { - gpio_free(LEFT_SPKR_AMPL_GPIO); - msm8930_ext_spk_pamp = 0; - return; - } - - if (!machine_is_msm8930_cdp()) { - pr_debug("%s: Free speaker boost gpio %u\n", - __func__, SPKR_BOOST_GPIO); - gpio_direction_output(SPKR_BOOST_GPIO, 0); - gpio_free(SPKR_BOOST_GPIO); - } - - pm8xxx_spk_enable(MSM8930_SPK_OFF); - msm8930_ext_spk_pamp = 0; - pr_debug("%s: slepping 10 ms after turning on external " - " Left Speaker Ampl\n", __func__); - usleep_range(10000, 10000); - - } else { - - pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static int msm8930_spkramp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event)); - if (SND_SOC_DAPM_EVENT_ON(event)) { - if (!strncmp(w->name, "Ext Spk Left Pos", 17)) - msm8960_ext_spk_power_amp_on(SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Left Neg", 17)) - msm8960_ext_spk_power_amp_on(SPK_AMP_NEG); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - } else { - if (!strncmp(w->name, "Ext Spk Left Pos", 17)) - msm8960_ext_spk_power_amp_off(SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Left Neg", 17)) - msm8960_ext_spk_power_amp_off(SPK_AMP_NEG); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - } - return 0; -} - -static int msm8930_enable_codec_ext_clk( - struct snd_soc_codec *codec, int enable, - bool dapm) -{ - int r = 0; - pr_debug("%s: enable = %d\n", __func__, enable); - - mutex_lock(&cdc_mclk_mutex); - if (enable) { - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 1) { - if (codec_clk) { - clk_set_rate(codec_clk, SITAR_EXT_CLK_RATE); - clk_prepare_enable(codec_clk); - sitar_mclk_enable(codec, 1, dapm); - } else { - pr_err("%s: Error setting Sitar MCLK\n", - __func__); - clk_users--; - r = -EINVAL; - } - } - } else { - if (clk_users > 0) { - clk_users--; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 0) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - sitar_mclk_enable(codec, 0, dapm); - clk_disable_unprepare(codec_clk); - } - } else { - pr_err("%s: Error releasing Sitar MCLK\n", __func__); - r = -EINVAL; - } - } - mutex_unlock(&cdc_mclk_mutex); - return r; -} - -static int msm8930_mclk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - pr_debug("%s: event = %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - return msm8930_enable_codec_ext_clk(w->codec, 1, true); - case SND_SOC_DAPM_POST_PMD: - return msm8930_enable_codec_ext_clk(w->codec, 0, true); - } - return 0; -} - -static const struct snd_soc_dapm_widget msm8930_dapm_widgets[] = { - - SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, - msm8930_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SPK("Ext Spk Left Pos", msm8930_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Left Neg", msm8930_spkramp_event), - - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), - - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("Digital Mic2", NULL), - SND_SOC_DAPM_MIC("Digital Mic3", NULL), - SND_SOC_DAPM_MIC("Digital Mic4", NULL), - -}; - -static const struct snd_soc_dapm_route common_audio_map[] = { - - {"RX_BIAS", NULL, "MCLK"}, - {"LDO_H", NULL, "MCLK"}, - - {"MIC BIAS1 Internal1", NULL, "MCLK"}, - {"MIC BIAS2 Internal1", NULL, "MCLK"}, - - /* Speaker path */ - {"Ext Spk Left Pos", NULL, "LINEOUT1"}, - {"Ext Spk Left Neg", NULL, "LINEOUT2"}, - - /* Headset Mic */ - {"AMIC2", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "Headset Mic"}, - - /* Microphone path */ - {"AMIC1", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "ANCLeft Headset Mic"}, - - {"AMIC3", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "ANCRight Headset Mic"}, - - {"HEADPHONE", NULL, "LDO_H"}, - - /** - * The digital Mic routes are setup considering - * fluid as default device. - */ - - /** - * Digital Mic1. Front Bottom left Mic on Fluid and MTP. - * Digital Mic GM5 on CDP mainboard. - * Conncted to DMIC1 Input on Sitar codec. - */ - {"DMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic1"}, - - /** - * Digital Mic2. Back top MIC on Fluid. - * Digital Mic GM6 on CDP mainboard. - * Conncted to DMIC2 Input on Sitar codec. - */ - {"DMIC2", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic2"}, - /** - * Digital Mic3. Back Bottom Digital Mic on Fluid. - * Digital Mic GM1 on CDP mainboard. - * Conncted to DMIC4 Input on Sitar codec. - */ - {"DMIC3", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic3"}, - - /** - * Digital Mic4. Back top Digital Mic on Fluid. - * Digital Mic GM2 on CDP mainboard. - * Conncted to DMIC3 Input on Sitar codec. - */ - {"DMIC4", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic4"}, - - -}; - -static const char *spk_function[] = {"Off", "On"}; -static const char *slim0_rx_ch_text[] = {"One", "Two"}; -static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"}; - -static const char * const hdmi_rate[] = {"Default", "Variable"}; - -static const struct soc_enum msm8930_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text), - SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text), - SOC_ENUM_SINGLE_EXT(2, hdmi_rate), -}; - -static const char *btsco_rate_text[] = {"8000", "16000"}; -static const struct soc_enum msm8930_btsco_enum[] = { - SOC_ENUM_SINGLE_EXT(2, btsco_rate_text), -}; - -static int msm8930_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8930_slim_0_rx_ch = %d\n", __func__, - msm8930_slim_0_rx_ch); - ucontrol->value.integer.value[0] = msm8930_slim_0_rx_ch - 1; - return 0; -} - -static int msm8930_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm8930_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm8930_slim_0_rx_ch = %d\n", __func__, - msm8930_slim_0_rx_ch); - return 1; -} - -static int msm8930_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8930_slim_0_tx_ch = %d\n", __func__, - msm8930_slim_0_tx_ch); - ucontrol->value.integer.value[0] = msm8930_slim_0_tx_ch - 1; - return 0; -} - -static int msm8930_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm8930_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm8930_slim_0_tx_ch = %d\n", __func__, - msm8930_slim_0_tx_ch); - return 1; -} - -static int msm8930_btsco_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8930_btsco_rate = %d", __func__, msm8930_btsco_rate); - ucontrol->value.integer.value[0] = msm8930_btsco_rate; - return 0; -} - -static int msm8930_btsco_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - - switch (ucontrol->value.integer.value[0]) { - case 8000: - msm8930_btsco_rate = BTSCO_RATE_8KHZ; - break; - case 16000: - msm8930_btsco_rate = BTSCO_RATE_16KHZ; - break; - default: - msm8930_btsco_rate = BTSCO_RATE_8KHZ; - break; - } - pr_debug("%s: msm8930_btsco_rate = %d\n", __func__, msm8930_btsco_rate); - return 0; -} - -static const char *pmic_spk_gain_text[] = { - "NEG_6_DB", "NEG_4_DB", "NEG_2_DB", "ZERO_DB", "POS_2_DB", "POS_4_DB", - "POS_6_DB", "POS_8_DB", "POS_10_DB", "POS_12_DB", "POS_14_DB", - "POS_16_DB", "POS_18_DB", "POS_20_DB", "POS_22_DB", "POS_24_DB" -}; - -static const struct soc_enum msm8960_pmic_spk_gain_enum[] = { - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(pmic_spk_gain_text), - pmic_spk_gain_text), -}; - -static int msm8930_pmic_gain_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8930_pmic_spk_gain = %d\n", __func__, - msm8930_pmic_spk_gain); - ucontrol->value.integer.value[0] = msm8930_pmic_spk_gain; - return 0; -} - -static int msm8930_pmic_gain_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int ret = 0; - msm8930_pmic_spk_gain = ucontrol->value.integer.value[0]; - if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) - ret = pm8xxx_spk_gain(msm8930_pmic_spk_gain); - pr_debug("%s: msm8930_pmic_spk_gain = %d" - " ucontrol->value.integer.value[0] = %d\n", __func__, - msm8930_pmic_spk_gain, - (int) ucontrol->value.integer.value[0]); - return ret; -} - -static int msm8930_hdmi_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - hdmi_rate_variable = ucontrol->value.integer.value[0]; - pr_debug("%s: hdmi_rate_variable = %d\n", __func__, hdmi_rate_variable); - return 0; -} - -static int msm8930_hdmi_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = hdmi_rate_variable; - return 0; -} - -static const struct snd_kcontrol_new sitar_msm8930_controls[] = { - SOC_ENUM_EXT("Speaker Function", msm8930_enum[0], msm8930_get_spk, - msm8930_set_spk), - SOC_ENUM_EXT("SLIM_0_RX Channels", msm8930_enum[1], - msm8930_slim_0_rx_ch_get, msm8930_slim_0_rx_ch_put), - SOC_ENUM_EXT("SLIM_0_TX Channels", msm8930_enum[2], - msm8930_slim_0_tx_ch_get, msm8930_slim_0_tx_ch_put), - SOC_ENUM_EXT("PMIC SPK Gain", msm8960_pmic_spk_gain_enum[0], - msm8930_pmic_gain_get, msm8930_pmic_gain_put), - SOC_ENUM_EXT("Internal BTSCO SampleRate", msm8930_btsco_enum[0], - msm8930_btsco_rate_get, msm8930_btsco_rate_put), - SOC_ENUM_EXT("HDMI RX Rate", msm8930_enum[3], - msm8930_hdmi_rate_get, - msm8930_hdmi_rate_put), -}; - -static void *def_sitar_mbhc_cal(void) -{ - void *sitar_cal; - struct sitar_mbhc_btn_detect_cfg *btn_cfg; - u16 *btn_low, *btn_high; - u8 *n_ready, *n_cic, *gain; - - sitar_cal = kzalloc(SITAR_MBHC_CAL_SIZE(SITAR_MBHC_DEF_BUTTONS, - SITAR_MBHC_DEF_RLOADS), - GFP_KERNEL); - if (!sitar_cal) { - pr_err("%s: out of memory\n", __func__); - return NULL; - } - -#define S(X, Y) ((SITAR_MBHC_CAL_GENERAL_PTR(sitar_cal)->X) = (Y)) - S(t_ldoh, 100); - S(t_bg_fast_settle, 100); - S(t_shutdown_plug_rem, 255); - S(mbhc_nsa, 4); - S(mbhc_navg, 4); -#undef S -#define S(X, Y) ((SITAR_MBHC_CAL_PLUG_DET_PTR(sitar_cal)->X) = (Y)) - S(mic_current, SITAR_PID_MIC_5_UA); - S(hph_current, SITAR_PID_MIC_5_UA); - S(t_mic_pid, 100); - S(t_ins_complete, 250); - S(t_ins_retry, 200); -#undef S -#define S(X, Y) ((SITAR_MBHC_CAL_PLUG_TYPE_PTR(sitar_cal)->X) = (Y)) - S(v_no_mic, 30); - S(v_hs_max, 1500); -#undef S -#define S(X, Y) ((SITAR_MBHC_CAL_BTN_DET_PTR(sitar_cal)->X) = (Y)) - S(c[0], 62); - S(c[1], 124); - S(nc, 1); - S(n_meas, 3); - S(mbhc_nsc, 11); - S(n_btn_meas, 1); - S(n_btn_con, 2); - S(num_btn, SITAR_MBHC_DEF_BUTTONS); - S(v_btn_press_delta_sta, 100); - S(v_btn_press_delta_cic, 50); -#undef S - btn_cfg = SITAR_MBHC_CAL_BTN_DET_PTR(sitar_cal); - btn_low = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_V_BTN_LOW); - btn_high = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_V_BTN_HIGH); - btn_low[0] = -50; - btn_high[0] = 10; - btn_low[1] = 11; - btn_high[1] = 38; - btn_low[2] = 39; - btn_high[2] = 64; - btn_low[3] = 65; - btn_high[3] = 91; - btn_low[4] = 92; - btn_high[4] = 115; - btn_low[5] = 116; - btn_high[5] = 141; - btn_low[6] = 142; - btn_high[6] = 163; - btn_low[7] = 164; - btn_high[7] = 250; - n_ready = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_N_READY); - n_ready[0] = 48; - n_ready[1] = 38; - n_cic = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_N_CIC); - n_cic[0] = 60; - n_cic[1] = 47; - gain = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_GAIN); - gain[0] = 11; - gain[1] = 9; - - return sitar_cal; -} - -static int msm8930_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - - pr_debug("%s: ch=%d\n", __func__, - msm8930_slim_0_rx_ch); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - msm8930_slim_0_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } else { - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(cpu_dai, - msm8930_slim_0_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } -end: - return ret; -} - -static int msm8930_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - - /* Tabla SLIMBUS configuration - * RX1, RX2, RX3, RX4, RX5 - * TX1, TX2, TX3, TX4, TX5 - */ - unsigned int rx_ch[SITAR_RX_MAX] = {138, 139, 140, 141, 142}; - unsigned int tx_ch[SITAR_TX_MAX] = {128, 129, 130, 131, 132}; - - pr_debug("%s()\n", __func__); - - snd_soc_dapm_new_controls(dapm, msm8930_dapm_widgets, - ARRAY_SIZE(msm8930_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, common_audio_map, - ARRAY_SIZE(common_audio_map)); - - snd_soc_dapm_enable_pin(dapm, "Ext Spk Left Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Left Neg"); - - snd_soc_dapm_sync(dapm); - - err = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_OC_HPHL | SND_JACK_OC_HPHR), - &hs_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - err = snd_soc_jack_new(codec, "Button Jack", - SITAR_JACK_BUTTON_MASK, &button_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - - snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), - tx_ch, ARRAY_SIZE(rx_ch), rx_ch); - - mbhc_cfg.gpio = 37; - mbhc_cfg.gpio_irq = gpio_to_irq(mbhc_cfg.gpio); - sitar_hs_detect(codec, &mbhc_cfg); - - if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) { - /* Initialize default PMIC speaker gain */ - pm8xxx_spk_gain(DEFAULT_PMIC_SPK_GAIN); - } - - return 0; -} - -static int msm8930_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm8930_slim_0_rx_ch; - - return 0; -} - -static int msm8930_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm8930_slim_0_tx_ch; - - return 0; -} - -static int msm8930_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm8930_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - if (!hdmi_rate_variable) - rate->min = rate->max = 48000; - channels->min = channels->max = 2; - - return 0; -} - -static int msm8930_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = msm8930_btsco_rate; - channels->min = channels->max = msm8930_btsco_ch; - - return 0; -} - -static int msm8930_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - /* PCM only supports mono output with 8khz sample rate */ - rate->min = rate->max = 8000; - channels->min = channels->max = 1; - - return 0; -} - -static int msm8930_proxy_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm8930_aux_pcm_get_gpios(void) -{ - int ret = 0; - - pr_debug("%s\n", __func__); - - ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", - __func__, GPIO_AUX_PCM_DOUT); - - goto fail_dout; - } - - ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", - __func__, GPIO_AUX_PCM_DIN); - goto fail_din; - } - - ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", - __func__, GPIO_AUX_PCM_SYNC); - goto fail_sync; - } - - ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", - __func__, GPIO_AUX_PCM_CLK); - goto fail_clk; - } - - return 0; - -fail_clk: - gpio_free(GPIO_AUX_PCM_SYNC); -fail_sync: - gpio_free(GPIO_AUX_PCM_DIN); -fail_din: - gpio_free(GPIO_AUX_PCM_DOUT); -fail_dout: - - return ret; -} - -static int msm8930_aux_pcm_free_gpios(void) -{ - gpio_free(GPIO_AUX_PCM_DIN); - gpio_free(GPIO_AUX_PCM_DOUT); - gpio_free(GPIO_AUX_PCM_SYNC); - gpio_free(GPIO_AUX_PCM_CLK); - - return 0; -} - -static int msm8930_startup(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); - return 0; -} - -static int msm8930_auxpcm_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_inc_return(&auxpcm_rsc_ref) == 1) - ret = msm8930_aux_pcm_get_gpios(); - if (ret < 0) { - pr_err("%s: Aux PCM GPIO request failed\n", __func__); - return -EINVAL; - } - return 0; - -} - -static void msm8930_auxpcm_shutdown(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_dec_return(&auxpcm_rsc_ref) == 0) - msm8930_aux_pcm_free_gpios(); -} - -static void msm8930_shutdown(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s stream = %d\n", __func__, - substream->name, substream->stream); -} - -static struct snd_soc_ops msm8930_be_ops = { - .startup = msm8930_startup, - .hw_params = msm8930_hw_params, - .shutdown = msm8930_shutdown, -}; - -static struct snd_soc_ops msm8930_auxpcm_be_ops = { - .startup = msm8930_auxpcm_startup, - .shutdown = msm8930_auxpcm_shutdown, -}; - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm8930_dai[] = { - /* FrontEnd DAI Links */ - { - .name = "MSM8930 Media1", - .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MSM8930 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - { - .name = "Circuit-Switch Voice", - .stream_name = "CS-Voice", - .cpu_dai_name = "CS-VOICE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .be_id = MSM_FRONTEND_DAI_CS_VOICE, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = "MSM VoIP", - .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_VOIP, - }, - { - .name = "MSM8930 LPA", - .stream_name = "LPA", - .cpu_dai_name = "MultiMedia3", - .platform_name = "msm-pcm-lpa", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3, - }, - /* Hostless PMC purpose */ - { - .name = "SLIMBUS_0 Hostless", - .stream_name = "SLIMBUS_0 Hostless", - .cpu_dai_name = "SLIMBUS0_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - /* .be_id = do not care */ - }, - { - .name = "INT_FM Hostless", - .stream_name = "INT_FM Hostless", - .cpu_dai_name = "INT_FM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - /* .be_id = do not care */ - }, - { - .name = "MSM AFE-PCM RX", - .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = "MSM AFE-PCM TX", - .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "MSM8930 Compr", - .stream_name = "COMPR", - .cpu_dai_name = "MultiMedia4", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4, - }, - { - .name = "AUXPCM Hostless", - .stream_name = "AUXPCM Hostless", - .cpu_dai_name = "AUXPCM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* HDMI Hostless */ - { - .name = "HDMI_RX_HOSTLESS", - .stream_name = "HDMI_RX_HOSTLESS", - .cpu_dai_name = "HDMI_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "VoLTE", - .stream_name = "VoLTE", - .cpu_dai_name = "VoLTE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .be_id = MSM_FRONTEND_DAI_VOLTE, - }, - { - .name = "Voice2", - .stream_name = "Voice2", - .cpu_dai_name = "Voice2", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .be_id = MSM_FRONTEND_DAI_VOICE2, - }, - { - .name = "MSM8960 LowLatency", - .stream_name = "MultiMedia5", - .cpu_dai_name = "MultiMedia5", - .platform_name = "msm-lowlatency-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5, - }, - { - .name = "MSM8960 FM", - .stream_name = "MultiMedia6", - .cpu_dai_name = "MultiMedia6", - .platform_name = "msm-pcm-loopback", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6, - }, - /* Backend DAI Links */ - { - .name = LPASS_BE_SLIMBUS_0_RX, - .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "sitar_codec", - .codec_dai_name = "sitar_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX, - .init = &msm8930_audrx_init, - .be_hw_params_fixup = msm8930_slim_0_rx_be_hw_params_fixup, - .ops = &msm8930_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_0_TX, - .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "sitar_codec", - .codec_dai_name = "sitar_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX, - .be_hw_params_fixup = msm8930_slim_0_tx_be_hw_params_fixup, - .ops = &msm8930_be_ops, - }, - /* Backend BT/FM DAI Links */ - { - .name = LPASS_BE_INT_BT_SCO_RX, - .stream_name = "Internal BT-SCO Playback", - .cpu_dai_name = "msm-dai-q6.12288", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX, - .be_hw_params_fixup = msm8930_btsco_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_BT_SCO_TX, - .stream_name = "Internal BT-SCO Capture", - .cpu_dai_name = "msm-dai-q6.12289", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX, - .be_hw_params_fixup = msm8930_btsco_be_hw_params_fixup, - }, - { - .name = LPASS_BE_INT_FM_RX, - .stream_name = "Internal FM Playback", - .cpu_dai_name = "msm-dai-q6.12292", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_RX, - .be_hw_params_fixup = msm8930_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_FM_TX, - .stream_name = "Internal FM Capture", - .cpu_dai_name = "msm-dai-q6.12293", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_TX, - .be_hw_params_fixup = msm8930_be_hw_params_fixup, - }, - /* HDMI BACK END DAI Link */ - { - .name = LPASS_BE_HDMI, - .stream_name = "HDMI Playback", - .cpu_dai_name = "msm-dai-q6-hdmi.8", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_HDMI_RX, - .be_hw_params_fixup = msm8930_hdmi_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - /* Backend AFE DAI Links */ - { - .name = LPASS_BE_AFE_PCM_RX, - .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, - .be_hw_params_fixup = msm8930_proxy_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_AFE_PCM_TX, - .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, - .be_hw_params_fixup = msm8930_proxy_be_hw_params_fixup, - }, - /* AUX PCM Backend DAI Links */ - { - .name = LPASS_BE_AUXPCM_RX, - .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_RX, - .be_hw_params_fixup = msm8930_auxpcm_be_params_fixup, - .ops = &msm8930_auxpcm_be_ops, - }, - { - .name = LPASS_BE_AUXPCM_TX, - .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_TX, - .be_hw_params_fixup = msm8930_auxpcm_be_params_fixup, - .ops = &msm8930_auxpcm_be_ops, - }, - /* Incall Music BACK END DAI Link */ - { - .name = LPASS_BE_VOICE_PLAYBACK_TX, - .stream_name = "Voice Farend Playback", - .cpu_dai_name = "msm-dai-q6.32773", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, - .be_hw_params_fixup = msm8930_be_hw_params_fixup, - }, - /* Incall Record Uplink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_TX, - .stream_name = "Voice Uplink Capture", - .cpu_dai_name = "msm-dai-q6.32772", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX, - .be_hw_params_fixup = msm8930_be_hw_params_fixup, - }, - /* Incall Record Downlink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_RX, - .stream_name = "Voice Downlink Capture", - .cpu_dai_name = "msm-dai-q6.32771", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX, - .be_hw_params_fixup = msm8930_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, -}; - -struct snd_soc_card snd_soc_card_msm8930 = { - .name = "msm8930-sitar-snd-card", - .dai_link = msm8930_dai, - .num_links = ARRAY_SIZE(msm8930_dai), - .controls = sitar_msm8930_controls, - .num_controls = ARRAY_SIZE(sitar_msm8930_controls), -}; - -static struct platform_device *msm8930_snd_device; - -static int msm8930_configure_headset_mic_gpios(void) -{ - int ret; - ret = gpio_request(80, "US_EURO_SWITCH"); - if (ret) { - pr_err("%s: Failed to request gpio 80\n", __func__); - return ret; - } - ret = gpio_direction_output(80, 0); - if (ret) { - pr_err("%s: Unable to set direction\n", __func__); - gpio_free(80); - } - msm8930_headset_gpios_configured = 0; - return 0; -} -static void msm8930_free_headset_mic_gpios(void) -{ - if (msm8930_headset_gpios_configured) - gpio_free(80); -} - -static int __init msm8930_audio_init(void) -{ - int ret; - - if (!soc_class_is_msm8930()) { - pr_err("%s: Not the right machine type\n", __func__); - return -ENODEV ; - } - mbhc_cfg.calibration = def_sitar_mbhc_cal(); - if (!mbhc_cfg.calibration) { - pr_err("Calibration data allocation failed\n"); - return -ENOMEM; - } - - msm8930_snd_device = platform_device_alloc("soc-audio", 0); - if (!msm8930_snd_device) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - - platform_set_drvdata(msm8930_snd_device, &snd_soc_card_msm8930); - ret = platform_device_add(msm8930_snd_device); - if (ret) { - platform_device_put(msm8930_snd_device); - kfree(mbhc_cfg.calibration); - return ret; - } - - if (msm8930_configure_headset_mic_gpios()) { - pr_err("%s Fail to configure headset mic gpios\n", __func__); - msm8930_headset_gpios_configured = 0; - } else - msm8930_headset_gpios_configured = 1; - - atomic_set(&auxpcm_rsc_ref, 0); - mutex_init(&cdc_mclk_mutex); - return ret; - -} -module_init(msm8930_audio_init); - -static void __exit msm8930_audio_exit(void) -{ - if (!soc_class_is_msm8930()) { - pr_err("%s: Not the right machine type\n", __func__); - return ; - } - msm8930_free_headset_mic_gpios(); - platform_device_unregister(msm8930_snd_device); - kfree(mbhc_cfg.calibration); - mutex_destroy(&cdc_mclk_mutex); -} -module_exit(msm8930_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC MSM8930"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm8960.c b/sound/soc/msm/msm8960.c deleted file mode 100644 index 92c4b8fe28d62aab37d39554a258c32dd4e10a84..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8960.c +++ /dev/null @@ -1,1861 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm-pcm-routing.h" -#include "../codecs/wcd9310.h" - -/* 8960 machine driver */ - -#define PM8921_GPIO_BASE NR_GPIO_IRQS -#define PM8921_IRQ_BASE (NR_MSM_IRQS + NR_GPIO_IRQS) -#define PM8921_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio - 1 + PM8921_GPIO_BASE) - -#define MSM8960_SPK_ON 1 -#define MSM8960_SPK_OFF 0 - -#define msm8960_SLIM_0_RX_MAX_CHANNELS 2 -#define msm8960_SLIM_0_TX_MAX_CHANNELS 4 - -#define SAMPLE_RATE_8KHZ 8000 -#define SAMPLE_RATE_16KHZ 16000 - -#define BOTTOM_SPK_AMP_POS 0x1 -#define BOTTOM_SPK_AMP_NEG 0x2 -#define TOP_SPK_AMP_POS 0x4 -#define TOP_SPK_AMP_NEG 0x8 -#define TOP_SPK_AMP 0x10 - -#define GPIO_AUX_PCM_DOUT 63 -#define GPIO_AUX_PCM_DIN 64 -#define GPIO_AUX_PCM_SYNC 65 -#define GPIO_AUX_PCM_CLK 66 - -#define TABLA_EXT_CLK_RATE 12288000 - -#define TABLA_MBHC_DEF_BUTTONS 8 -#define TABLA_MBHC_DEF_RLOADS 5 - -#define JACK_DETECT_GPIO 38 -#define JACK_DETECT_INT PM8921_GPIO_IRQ(PM8921_IRQ_BASE, JACK_DETECT_GPIO) -#define JACK_US_EURO_SEL_GPIO 35 - -static u32 top_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(18); -static u32 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(19); -static int msm8960_spk_control; -static int msm8960_ext_bottom_spk_pamp; -static int msm8960_ext_top_spk_pamp; -static int msm8960_slim_0_rx_ch = 1; -static int msm8960_slim_0_tx_ch = 1; - -static int msm8960_btsco_rate = SAMPLE_RATE_8KHZ; -static int msm8960_btsco_ch = 1; -static int hdmi_rate_variable; -static int msm8960_auxpcm_rate = SAMPLE_RATE_8KHZ; - -static struct clk *codec_clk; -static int clk_users; - -static int msm8960_headset_gpios_configured; - -static struct snd_soc_jack hs_jack; -static struct snd_soc_jack button_jack; -static atomic_t auxpcm_rsc_ref; - -static bool hs_micbias_always_on; -module_param(hs_micbias_always_on, bool, 0444); -MODULE_PARM_DESC(hs_micbias_always_on, "Keep micbias always on if headset is inserted"); - -static bool hs_detect_use_gpio; -module_param(hs_detect_use_gpio, bool, 0444); -MODULE_PARM_DESC(hs_detect_use_gpio, "Use GPIO for headset detection"); - -static bool hs_detect_extn_cable; -module_param(hs_detect_extn_cable, bool, 0444); -MODULE_PARM_DESC(hs_detect_extn_cable, "Enable extension cable feature"); - -static bool hs_detect_use_firmware; -module_param(hs_detect_use_firmware, bool, 0444); -MODULE_PARM_DESC(hs_detect_use_firmware, "Use firmware for headset detection"); - -static int msm8960_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm); -static bool msm8960_swap_gnd_mic(struct snd_soc_codec *codec); - -static struct tabla_mbhc_config mbhc_cfg = { - .headset_jack = &hs_jack, - .button_jack = &button_jack, - .read_fw_bin = false, - .calibration = NULL, - .micbias = TABLA_MICBIAS2, - .mclk_cb_fn = msm8960_enable_codec_ext_clk, - .mclk_rate = TABLA_EXT_CLK_RATE, - .gpio = 0, - .gpio_irq = 0, - .gpio_level_insert = 1, - .swap_gnd_mic = NULL, - .detect_extn_cable = false, - .micbias_always_on = false -}; - -static u32 us_euro_sel_gpio = PM8921_GPIO_PM_TO_SYS(JACK_US_EURO_SEL_GPIO); - -static struct mutex cdc_mclk_mutex; - -static void msm8960_enable_ext_spk_amp_gpio(u32 spk_amp_gpio) -{ - int ret = 0; - - struct pm_gpio param = { - .direction = PM_GPIO_DIR_OUT, - .output_buffer = PM_GPIO_OUT_BUF_CMOS, - .output_value = 1, - .pull = PM_GPIO_PULL_NO, - .vin_sel = PM_GPIO_VIN_S4, - .out_strength = PM_GPIO_STRENGTH_MED, - . - function = PM_GPIO_FUNC_NORMAL, - }; - - if (spk_amp_gpio == bottom_spk_pamp_gpio) { - - ret = gpio_request(bottom_spk_pamp_gpio, "BOTTOM_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting BOTTOM SPK AMP GPIO %u\n", - __func__, bottom_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(bottom_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Bottom Spk Ampl" - " gpio %u\n", __func__, bottom_spk_pamp_gpio); - else { - pr_debug("%s: enable Bottom spkr amp gpio\n", __func__); - gpio_direction_output(bottom_spk_pamp_gpio, 1); - } - - } else if (spk_amp_gpio == top_spk_pamp_gpio) { - - ret = gpio_request(top_spk_pamp_gpio, "TOP_SPK_AMP"); - if (ret) { - pr_err("%s: Error requesting GPIO %d\n", __func__, - top_spk_pamp_gpio); - return; - } - ret = pm8xxx_gpio_config(top_spk_pamp_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure Top Spk Ampl" - " gpio %u\n", __func__, top_spk_pamp_gpio); - else { - pr_debug("%s: enable Top spkr amp gpio\n", __func__); - gpio_direction_output(top_spk_pamp_gpio, 1); - } - } else { - pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO." - " gpio = %u\n", __func__, spk_amp_gpio); - return; - } -} - -static void msm8960_ext_spk_power_amp_on(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if ((msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - pr_debug("%s() External Bottom Speaker Ampl already " - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - msm8960_ext_bottom_spk_pamp |= spk; - - if ((msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) && - (msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) { - - msm8960_enable_ext_spk_amp_gpio(bottom_spk_pamp_gpio); - pr_debug("%s: slepping 4 ms after turning on external " - " Bottom Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { - - pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n", - __func__, msm8960_ext_top_spk_pamp, spk); - - if (((msm8960_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm8960_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || - (msm8960_ext_top_spk_pamp & TOP_SPK_AMP)) { - - pr_debug("%s() External Top Speaker Ampl already" - "turned on. spk = 0x%08x\n", __func__, spk); - return; - } - - msm8960_ext_top_spk_pamp |= spk; - - if (((msm8960_ext_top_spk_pamp & TOP_SPK_AMP_POS) && - (msm8960_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) || - (msm8960_ext_top_spk_pamp & TOP_SPK_AMP)) { - - msm8960_enable_ext_spk_amp_gpio(top_spk_pamp_gpio); - pr_debug("%s: sleeping 4 ms after turning on " - " external Top Speaker Ampl\n", __func__); - usleep_range(4000, 4000); - } - } else { - - pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm8960_ext_spk_power_amp_off(u32 spk) -{ - if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) { - - if (!msm8960_ext_bottom_spk_pamp) - return; - - gpio_direction_output(bottom_spk_pamp_gpio, 0); - gpio_free(bottom_spk_pamp_gpio); - msm8960_ext_bottom_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after turning off external Bottom" - " Speaker Ampl\n", __func__); - - usleep_range(4000, 4000); - - } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { - - pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n", - __func__, msm8960_ext_top_spk_pamp, spk); - - if (!msm8960_ext_top_spk_pamp) - return; - - if ((spk & TOP_SPK_AMP_POS) || (spk & TOP_SPK_AMP_NEG)) { - - msm8960_ext_top_spk_pamp &= (~(TOP_SPK_AMP_POS | - TOP_SPK_AMP_NEG)); - } else if (spk & TOP_SPK_AMP) { - msm8960_ext_top_spk_pamp &= ~TOP_SPK_AMP; - } - - if (msm8960_ext_top_spk_pamp) - return; - - gpio_direction_output(top_spk_pamp_gpio, 0); - gpio_free(top_spk_pamp_gpio); - msm8960_ext_top_spk_pamp = 0; - - pr_debug("%s: sleeping 4 ms after ext Top Spek Ampl is off\n", - __func__); - - usleep_range(4000, 4000); - } else { - - pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n", - __func__, spk); - return; - } -} - -static void msm8960_ext_control(struct snd_soc_codec *codec) -{ - struct snd_soc_dapm_context *dapm = &codec->dapm; - - mutex_lock(&dapm->codec->mutex); - - pr_debug("%s: msm8960_spk_control = %d", __func__, msm8960_spk_control); - if (msm8960_spk_control == MSM8960_SPK_ON) { - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - } else { - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg"); - } - - snd_soc_dapm_sync(dapm); - mutex_unlock(&dapm->codec->mutex); -} - -static int msm8960_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8960_spk_control = %d", __func__, msm8960_spk_control); - ucontrol->value.integer.value[0] = msm8960_spk_control; - return 0; -} -static int msm8960_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - pr_debug("%s()\n", __func__); - if (msm8960_spk_control == ucontrol->value.integer.value[0]) - return 0; - - msm8960_spk_control = ucontrol->value.integer.value[0]; - msm8960_ext_control(codec); - return 1; -} -static int msm8960_spkramp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event)); - - if (SND_SOC_DAPM_EVENT_ON(event)) { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm8960_ext_spk_power_amp_on(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm8960_ext_spk_power_amp_on(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm8960_ext_spk_power_amp_on(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm8960_ext_spk_power_amp_on(TOP_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top", 12)) - msm8960_ext_spk_power_amp_on(TOP_SPK_AMP); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - - } else { - if (!strncmp(w->name, "Ext Spk Bottom Pos", 18)) - msm8960_ext_spk_power_amp_off(BOTTOM_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18)) - msm8960_ext_spk_power_amp_off(BOTTOM_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top Pos", 15)) - msm8960_ext_spk_power_amp_off(TOP_SPK_AMP_POS); - else if (!strncmp(w->name, "Ext Spk Top Neg", 15)) - msm8960_ext_spk_power_amp_off(TOP_SPK_AMP_NEG); - else if (!strncmp(w->name, "Ext Spk Top", 12)) - msm8960_ext_spk_power_amp_off(TOP_SPK_AMP); - else { - pr_err("%s() Invalid Speaker Widget = %s\n", - __func__, w->name); - return -EINVAL; - } - } - return 0; -} - -static int msm8960_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, - bool dapm) -{ - int r = 0; - pr_debug("%s: enable = %d\n", __func__, enable); - - mutex_lock(&cdc_mclk_mutex); - if (enable) { - clk_users++; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 1) { - if (codec_clk) { - clk_set_rate(codec_clk, TABLA_EXT_CLK_RATE); - clk_prepare_enable(codec_clk); - tabla_mclk_enable(codec, 1, dapm); - } else { - pr_err("%s: Error setting Tabla MCLK\n", - __func__); - clk_users--; - r = -EINVAL; - } - } - } else { - if (clk_users > 0) { - clk_users--; - pr_debug("%s: clk_users = %d\n", __func__, clk_users); - if (clk_users == 0) { - pr_debug("%s: disabling MCLK. clk_users = %d\n", - __func__, clk_users); - tabla_mclk_enable(codec, 0, dapm); - clk_disable_unprepare(codec_clk); - } - } else { - pr_err("%s: Error releasing Tabla MCLK\n", __func__); - r = -EINVAL; - } - } - mutex_unlock(&cdc_mclk_mutex); - return r; -} - -static bool msm8960_swap_gnd_mic(struct snd_soc_codec *codec) -{ - int value = gpio_get_value_cansleep(us_euro_sel_gpio); - pr_debug("%s: US EURO select switch %d to %d\n", __func__, value, - !value); - gpio_set_value_cansleep(us_euro_sel_gpio, !value); - return true; -} - -static int msm8960_mclk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - pr_debug("%s: event = %d\n", __func__, event); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - return msm8960_enable_codec_ext_clk(w->codec, 1, true); - case SND_SOC_DAPM_POST_PMD: - return msm8960_enable_codec_ext_clk(w->codec, 0, true); - } - return 0; -} - -static const struct snd_soc_dapm_widget msm8960_dapm_widgets[] = { - - SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, - msm8960_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), - - SND_SOC_DAPM_SPK("Ext Spk Bottom Pos", msm8960_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Bottom Neg", msm8960_spkramp_event), - - SND_SOC_DAPM_SPK("Ext Spk Top Pos", msm8960_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Top Neg", msm8960_spkramp_event), - SND_SOC_DAPM_SPK("Ext Spk Top", msm8960_spkramp_event), - - SND_SOC_DAPM_MIC("Handset Mic", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), - SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), - - SND_SOC_DAPM_MIC("Digital Mic1", NULL), - SND_SOC_DAPM_MIC("Digital Mic2", NULL), - SND_SOC_DAPM_MIC("Digital Mic3", NULL), - SND_SOC_DAPM_MIC("Digital Mic4", NULL), - SND_SOC_DAPM_MIC("Digital Mic5", NULL), - SND_SOC_DAPM_MIC("Digital Mic6", NULL), - -}; - -static const struct snd_soc_dapm_route common_audio_map[] = { - - {"RX_BIAS", NULL, "MCLK"}, - {"LDO_H", NULL, "MCLK"}, - - /* Speaker path */ - {"Ext Spk Bottom Pos", NULL, "LINEOUT1"}, - {"Ext Spk Bottom Neg", NULL, "LINEOUT3"}, - - {"Ext Spk Top Pos", NULL, "LINEOUT2"}, - {"Ext Spk Top Neg", NULL, "LINEOUT4"}, - {"Ext Spk Top", NULL, "LINEOUT5"}, - - /* Microphone path */ - {"AMIC1", NULL, "MIC BIAS1 Internal1"}, - {"MIC BIAS1 Internal1", NULL, "Handset Mic"}, - - {"AMIC2", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "Headset Mic"}, - - /** - * AMIC3 and AMIC4 inputs are connected to ANC microphones - * These mics are biased differently on CDP and FLUID - * routing entries below are based on bias arrangement - * on FLUID. - */ - {"AMIC3", NULL, "MIC BIAS3 Internal1"}, - {"MIC BIAS3 Internal1", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "ANCRight Headset Mic"}, - {"AMIC4", NULL, "MIC BIAS1 Internal2"}, - {"MIC BIAS1 Internal2", NULL, "MIC BIAS2 External"}, - {"MIC BIAS2 External", NULL, "ANCLeft Headset Mic"}, - - {"HEADPHONE", NULL, "LDO_H"}, - - /** - * The digital Mic routes are setup considering - * fluid as default device. - */ - - /** - * Digital Mic1. Front Bottom left Digital Mic on Fluid and MTP. - * Digital Mic GM5 on CDP mainboard. - * Conncted to DMIC2 Input on Tabla codec. - */ - {"DMIC2", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic1"}, - - /** - * Digital Mic2. Front Bottom right Digital Mic on Fluid and MTP. - * Digital Mic GM6 on CDP mainboard. - * Conncted to DMIC1 Input on Tabla codec. - */ - {"DMIC1", NULL, "MIC BIAS1 External"}, - {"MIC BIAS1 External", NULL, "Digital Mic2"}, - - /** - * Digital Mic3. Back Bottom Digital Mic on Fluid. - * Digital Mic GM1 on CDP mainboard. - * Conncted to DMIC4 Input on Tabla codec. - */ - {"DMIC4", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic3"}, - - /** - * Digital Mic4. Back top Digital Mic on Fluid. - * Digital Mic GM2 on CDP mainboard. - * Conncted to DMIC3 Input on Tabla codec. - */ - {"DMIC3", NULL, "MIC BIAS3 External"}, - {"MIC BIAS3 External", NULL, "Digital Mic4"}, - - /** - * Digital Mic5. Front top Digital Mic on Fluid. - * Digital Mic GM3 on CDP mainboard. - * Conncted to DMIC5 Input on Tabla codec. - */ - {"DMIC5", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic5"}, - - /* Tabla digital Mic6 - back bottom digital Mic on Liquid and - * bottom mic on CDP. FLUID/MTP do not have dmic6 installed. - */ - {"DMIC6", NULL, "MIC BIAS4 External"}, - {"MIC BIAS4 External", NULL, "Digital Mic6"}, -}; - -static const char *spk_function[] = {"Off", "On"}; -static const char *slim0_rx_ch_text[] = {"One", "Two"}; -static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"}; -static const char * const hdmi_rate[] = {"Default", "Variable"}; - -static const struct soc_enum msm8960_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text), - SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text), - SOC_ENUM_SINGLE_EXT(2, hdmi_rate), -}; - -static const char *btsco_rate_text[] = {"8000", "16000"}; -static const struct soc_enum msm8960_btsco_enum[] = { - SOC_ENUM_SINGLE_EXT(2, btsco_rate_text), -}; - -static const char *auxpcm_rate_text[] = {"rate_8000", "rate_16000"}; -static const struct soc_enum msm8960_auxpcm_enum[] = { - SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text), -}; - -static int msm8960_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8960_slim_0_rx_ch = %d\n", __func__, - msm8960_slim_0_rx_ch); - ucontrol->value.integer.value[0] = msm8960_slim_0_rx_ch - 1; - return 0; -} - -static int msm8960_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm8960_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm8960_slim_0_rx_ch = %d\n", __func__, - msm8960_slim_0_rx_ch); - return 1; -} - -static int msm8960_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8960_slim_0_tx_ch = %d\n", __func__, - msm8960_slim_0_tx_ch); - ucontrol->value.integer.value[0] = msm8960_slim_0_tx_ch - 1; - return 0; -} - -static int msm8960_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - msm8960_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1; - - pr_debug("%s: msm8960_slim_0_tx_ch = %d\n", __func__, - msm8960_slim_0_tx_ch); - return 1; -} - -static int msm8960_btsco_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8960_btsco_rate = %d", __func__, msm8960_btsco_rate); - ucontrol->value.integer.value[0] = msm8960_btsco_rate; - return 0; -} - -static int msm8960_btsco_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 8000: - msm8960_btsco_rate = SAMPLE_RATE_8KHZ; - break; - case 16000: - msm8960_btsco_rate = SAMPLE_RATE_16KHZ; - break; - default: - msm8960_btsco_rate = SAMPLE_RATE_8KHZ; - break; - } - pr_debug("%s: msm8960_btsco_rate = %d\n", __func__, msm8960_btsco_rate); - return 0; -} - -static int msm8960_auxpcm_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_debug("%s: msm8960_auxpcm_rate = %d", __func__, - msm8960_auxpcm_rate); - ucontrol->value.integer.value[0] = msm8960_auxpcm_rate; - return 0; -} - -static int msm8960_auxpcm_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - switch (ucontrol->value.integer.value[0]) { - case 0: - msm8960_auxpcm_rate = SAMPLE_RATE_8KHZ; - break; - case 1: - msm8960_auxpcm_rate = SAMPLE_RATE_16KHZ; - break; - default: - msm8960_auxpcm_rate = SAMPLE_RATE_8KHZ; - break; - } - pr_debug("%s: msm8960_auxpcm_rate = %d" - "ucontrol->value.integer.value[0] = %d\n", __func__, - msm8960_auxpcm_rate, - (int)ucontrol->value.integer.value[0]); - return 0; -} - -static int msm8960_hdmi_rate_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - hdmi_rate_variable = ucontrol->value.integer.value[0]; - pr_debug("%s: hdmi_rate_variable = %d\n", __func__, hdmi_rate_variable); - return 0; -} - -static int msm8960_hdmi_rate_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = hdmi_rate_variable; - return 0; -} - -static const struct snd_kcontrol_new tabla_msm8960_controls[] = { - SOC_ENUM_EXT("Speaker Function", msm8960_enum[0], msm8960_get_spk, - msm8960_set_spk), - SOC_ENUM_EXT("SLIM_0_RX Channels", msm8960_enum[1], - msm8960_slim_0_rx_ch_get, msm8960_slim_0_rx_ch_put), - SOC_ENUM_EXT("SLIM_0_TX Channels", msm8960_enum[2], - msm8960_slim_0_tx_ch_get, msm8960_slim_0_tx_ch_put), - SOC_ENUM_EXT("Internal BTSCO SampleRate", msm8960_btsco_enum[0], - msm8960_btsco_rate_get, msm8960_btsco_rate_put), - SOC_ENUM_EXT("AUX PCM SampleRate", msm8960_auxpcm_enum[0], - msm8960_auxpcm_rate_get, msm8960_auxpcm_rate_put), - SOC_ENUM_EXT("HDMI RX Rate", msm8960_enum[3], - msm8960_hdmi_rate_get, - msm8960_hdmi_rate_put), -}; - -static void *def_tabla_mbhc_cal(void) -{ - void *tabla_cal; - struct tabla_mbhc_btn_detect_cfg *btn_cfg; - u16 *btn_low, *btn_high; - u8 *n_ready, *n_cic, *gain; - - tabla_cal = kzalloc(TABLA_MBHC_CAL_SIZE(TABLA_MBHC_DEF_BUTTONS, - TABLA_MBHC_DEF_RLOADS), - GFP_KERNEL); - if (!tabla_cal) { - pr_err("%s: out of memory\n", __func__); - return NULL; - } - -#define S(X, Y) ((TABLA_MBHC_CAL_GENERAL_PTR(tabla_cal)->X) = (Y)) - S(t_ldoh, 100); - S(t_bg_fast_settle, 100); - S(t_shutdown_plug_rem, 255); - S(mbhc_nsa, 4); - S(mbhc_navg, 4); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_DET_PTR(tabla_cal)->X) = (Y)) - S(mic_current, TABLA_PID_MIC_5_UA); - S(hph_current, TABLA_PID_MIC_5_UA); - S(t_mic_pid, 100); - S(t_ins_complete, 250); - S(t_ins_retry, 200); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_TYPE_PTR(tabla_cal)->X) = (Y)) - S(v_no_mic, 30); - S(v_hs_max, 2400); -#undef S -#define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal)->X) = (Y)) - S(c[0], 62); - S(c[1], 124); - S(nc, 1); - S(n_meas, 3); - S(mbhc_nsc, 11); - S(n_btn_meas, 1); - S(n_btn_con, 2); - S(num_btn, TABLA_MBHC_DEF_BUTTONS); - S(v_btn_press_delta_sta, 100); - S(v_btn_press_delta_cic, 50); -#undef S - btn_cfg = TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal); - btn_low = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_LOW); - btn_high = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_HIGH); - btn_low[0] = -50; - btn_high[0] = 21; - btn_low[1] = 22; - btn_high[1] = 67; - btn_low[2] = 68; - btn_high[2] = 111; - btn_low[3] = 112; - btn_high[3] = 153; - btn_low[4] = 154; - btn_high[4] = 191; - btn_low[5] = 192; - btn_high[5] = 233; - btn_low[6] = 234; - btn_high[6] = 272; - btn_low[7] = 273; - btn_high[7] = 400; - n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY); - n_ready[0] = 80; - n_ready[1] = 68; - n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC); - n_cic[0] = 60; - n_cic[1] = 47; - gain = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_GAIN); - gain[0] = 11; - gain[1] = 9; - - return tabla_cal; -} - -static int msm8960_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - - pr_debug("%s: rx_0_ch=%d\n", __func__, msm8960_slim_0_rx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - msm8960_slim_0_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } else { - - pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__, - codec_dai->name, codec_dai->id, msm8960_slim_0_tx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - ret = snd_soc_dai_set_channel_map(cpu_dai, - msm8960_slim_0_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } -end: - return ret; -} - -static int msm8960_slimbus_2_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; - unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; - unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0; - unsigned int num_tx_ch = 0; - unsigned int num_rx_ch = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - - num_rx_ch = params_channels(params); - - pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__, - codec_dai->name, codec_dai->id, num_rx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, - num_rx_ch, rx_ch); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } else { - num_tx_ch = params_channels(params); - - pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__, - codec_dai->name, codec_dai->id, num_tx_ch); - - ret = snd_soc_dai_get_channel_map(codec_dai, - &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch); - if (ret < 0) { - pr_err("%s: failed to get codec chan map\n", __func__); - goto end; - } - - ret = snd_soc_dai_set_channel_map(cpu_dai, - num_tx_ch, tx_ch, 0 , 0); - if (ret < 0) { - pr_err("%s: failed to set cpu chan map\n", __func__); - goto end; - } - } -end: - return ret; -} - -static int msm8960_audrx_init(struct snd_soc_pcm_runtime *rtd) -{ - int err; - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct pm_gpio jack_gpio_cfg = { - .direction = PM_GPIO_DIR_IN, - .pull = PM_GPIO_PULL_UP_1P5, - .function = PM_GPIO_FUNC_NORMAL, - .vin_sel = 2, - .inv_int_pol = 0, - }; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - - /* Tabla SLIMBUS configuration - * RX1, RX2, RX3, RX4, RX5, RX6, RX7 - * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8 - */ - unsigned int rx_ch[TABLA_RX_MAX] = {138, 139, 140, 141, 142, 143, 144}; - unsigned int tx_ch[TABLA_TX_MAX] = {128, 129, 130, 131, 132, 133, 134, - 135, 136, 137}; - - pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); - - if (machine_is_msm8960_liquid()) { - top_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(19)); - bottom_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(18)); - } - - snd_soc_dapm_new_controls(dapm, msm8960_dapm_widgets, - ARRAY_SIZE(msm8960_dapm_widgets)); - - snd_soc_dapm_add_routes(dapm, common_audio_map, - ARRAY_SIZE(common_audio_map)); - - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos"); - snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg"); - - snd_soc_dapm_sync(dapm); - - err = snd_soc_jack_new(codec, "Headset Jack", - (SND_JACK_HEADSET | SND_JACK_LINEOUT | - SND_JACK_OC_HPHL | SND_JACK_OC_HPHR | - SND_JACK_UNSUPPORTED), - &hs_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - err = snd_soc_jack_new(codec, "Button Jack", - TABLA_JACK_BUTTON_MASK, &button_jack); - if (err) { - pr_err("failed to create new jack\n"); - return err; - } - - codec_clk = clk_get(cpu_dai->dev, "osr_clk"); - - if (machine_is_msm8960_cdp()) - mbhc_cfg.swap_gnd_mic = msm8960_swap_gnd_mic; - - if (hs_micbias_always_on) - mbhc_cfg.micbias_always_on = true; - - if (hs_detect_use_gpio) { - mbhc_cfg.gpio = PM8921_GPIO_PM_TO_SYS(JACK_DETECT_GPIO); - mbhc_cfg.gpio_irq = JACK_DETECT_INT; - if (hs_detect_extn_cable) - mbhc_cfg.detect_extn_cable = true; - } - - if (mbhc_cfg.gpio) { - err = pm8xxx_gpio_config(mbhc_cfg.gpio, &jack_gpio_cfg); - if (err) { - pr_err("%s: pm8xxx_gpio_config JACK_DETECT failed %d\n", - __func__, err); - return err; - } - } - - mbhc_cfg.read_fw_bin = hs_detect_use_firmware; - - err = tabla_hs_detect(codec, &mbhc_cfg); - snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), - tx_ch, ARRAY_SIZE(rx_ch), rx_ch); - - return err; -} - -static int msm8960_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm8960_slim_0_rx_ch; - - return 0; -} - -static int msm8960_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - channels->min = channels->max = msm8960_slim_0_tx_ch; - - return 0; -} - -static int msm8960_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} - -static int msm8960_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - pr_debug("%s channels->min %u channels->max %u ()\n", __func__, - channels->min, channels->max); - - if (channels->max < 2) - channels->min = channels->max = 2; - if (!hdmi_rate_variable) - rate->min = rate->max = 48000; - - return 0; -} - -static int msm8960_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = msm8960_btsco_rate; - channels->min = channels->max = msm8960_btsco_ch; - - return 0; -} -static int msm8960_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - struct snd_interval *channels = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - rate->min = rate->max = msm8960_auxpcm_rate; - /* PCM only supports mono output */ - channels->min = channels->max = 1; - - return 0; -} -static int msm8960_proxy_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_interval *rate = hw_param_interval(params, - SNDRV_PCM_HW_PARAM_RATE); - - pr_debug("%s()\n", __func__); - rate->min = rate->max = 48000; - - return 0; -} -static int msm8960_aux_pcm_get_gpios(void) -{ - int ret = 0; - - pr_debug("%s\n", __func__); - - ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT", - __func__, GPIO_AUX_PCM_DOUT); - goto fail_dout; - } - - ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM DIN", - __func__, GPIO_AUX_PCM_DIN); - goto fail_din; - } - - ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC", - __func__, GPIO_AUX_PCM_SYNC); - goto fail_sync; - } - ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK"); - if (ret < 0) { - pr_err("%s: Failed to request gpio(%d): AUX PCM CLK", - __func__, GPIO_AUX_PCM_CLK); - goto fail_clk; - } - - return 0; - -fail_clk: - gpio_free(GPIO_AUX_PCM_SYNC); -fail_sync: - gpio_free(GPIO_AUX_PCM_DIN); -fail_din: - gpio_free(GPIO_AUX_PCM_DOUT); -fail_dout: - - return ret; -} - -static int msm8960_aux_pcm_free_gpios(void) -{ - gpio_free(GPIO_AUX_PCM_DIN); - gpio_free(GPIO_AUX_PCM_DOUT); - gpio_free(GPIO_AUX_PCM_SYNC); - gpio_free(GPIO_AUX_PCM_CLK); - - return 0; -} -static int msm8960_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n", - __func__, rtd->dai_link->stream_name, - rtd->dai_link->cpu_dai_name, rtd->dai_link->codec_dai_name); - return 0; -} - -static int msm8960_auxpcm_startup(struct snd_pcm_substream *substream) -{ - int ret = 0; - - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_inc_return(&auxpcm_rsc_ref) == 1) - ret = msm8960_aux_pcm_get_gpios(); - - if (ret < 0) { - pr_err("%s: Aux PCM GPIO request failed\n", __func__); - return -EINVAL; - } - return 0; -} - -static void msm8960_auxpcm_shutdown(struct snd_pcm_substream *substream) -{ - pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n", - __func__, substream->name, atomic_read(&auxpcm_rsc_ref)); - if (atomic_dec_return(&auxpcm_rsc_ref) == 0) - msm8960_aux_pcm_free_gpios(); -} - -static void msm8960_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - pr_debug("%s(): dai_link str_name = %s cpu_dai = %s codec_dai = %s\n", - __func__, rtd->dai_link->stream_name, - rtd->dai_link->cpu_dai_name, rtd->dai_link->codec_dai_name); -} - -static struct snd_soc_ops msm8960_be_ops = { - .startup = msm8960_startup, - .hw_params = msm8960_hw_params, - .shutdown = msm8960_shutdown, -}; - -static struct snd_soc_ops msm8960_auxpcm_be_ops = { - .startup = msm8960_auxpcm_startup, - .shutdown = msm8960_auxpcm_shutdown, -}; - -static struct snd_soc_ops msm8960_slimbus_2_be_ops = { - .startup = msm8960_startup, - .hw_params = msm8960_slimbus_2_hw_params, - .shutdown = msm8960_shutdown, -}; - -/* Digital audio interface glue - connects codec <---> CPU */ -static struct snd_soc_dai_link msm8960_dai_common[] = { - /* FrontEnd DAI Links */ - { - .name = "MSM8960 Media1", - .stream_name = "MultiMedia1", - .cpu_dai_name = "MultiMedia1", - .platform_name = "msm-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 - }, - { - .name = "MSM8960 Media2", - .stream_name = "MultiMedia2", - .cpu_dai_name = "MultiMedia2", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, - }, - { - .name = "Circuit-Switch Voice", - .stream_name = "CS-Voice", - .cpu_dai_name = "CS-VOICE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_CS_VOICE, - }, - { - .name = "MSM VoIP", - .stream_name = "VoIP", - .cpu_dai_name = "VoIP", - .platform_name = "msm-voip-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_VOIP, - }, - { - .name = "MSM8960 LPA", - .stream_name = "LPA", - .cpu_dai_name = "MultiMedia3", - .platform_name = "msm-pcm-lpa", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3, - }, - /* Hostless PMC purpose */ - { - .name = "SLIMBUS_0 Hostless", - .stream_name = "SLIMBUS_0 Hostless", - .cpu_dai_name = "SLIMBUS0_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "INT_FM Hostless", - .stream_name = "INT_FM Hostless", - .cpu_dai_name = "INT_FM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "MSM AFE-PCM RX", - .stream_name = "AFE-PROXY RX", - .cpu_dai_name = "msm-dai-q6.241", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = "MSM AFE-PCM TX", - .stream_name = "AFE-PROXY TX", - .cpu_dai_name = "msm-dai-q6.240", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .platform_name = "msm-pcm-afe", - .ignore_suspend = 1, - }, - { - .name = "MSM8960 Compr", - .stream_name = "COMPR", - .cpu_dai_name = "MultiMedia4", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4, - }, - { - .name = "AUXPCM Hostless", - .stream_name = "AUXPCM Hostless", - .cpu_dai_name = "AUXPCM_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - /* HDMI Hostless */ - { - .name = "HDMI_RX_HOSTLESS", - .stream_name = "HDMI_RX_HOSTLESS", - .cpu_dai_name = "HDMI_HOSTLESS", - .platform_name = "msm-pcm-hostless", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - }, - { - .name = "VoLTE", - .stream_name = "VoLTE", - .cpu_dai_name = "VoLTE", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .be_id = MSM_FRONTEND_DAI_VOLTE, - }, - { - .name = "Voice2", - .stream_name = "Voice2", - .cpu_dai_name = "Voice2", - .platform_name = "msm-pcm-voice", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ignore_suspend = 1, - .ignore_pmdown_time = 1,/* this dainlink has playback support */ - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .be_id = MSM_FRONTEND_DAI_VOICE2, - }, - { - .name = "MSM8960 LowLatency", - .stream_name = "MultiMedia5", - .cpu_dai_name = "MultiMedia5", - .platform_name = "msm-lowlatency-pcm-dsp", - .dynamic = 1, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .ignore_suspend = 1, - /* this dainlink has playback support */ - .ignore_pmdown_time = 1, - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5, - }, - { - .name = "MSM8960 Media6", - .stream_name = "MultiMedia6", - .cpu_dai_name = "MultiMedia6", - .platform_name = "msm-multi-ch-pcm-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6 - }, - { - .name = "MSM8960 Compr2", - .stream_name = "COMPR2", - .cpu_dai_name = "MultiMedia7", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7, - }, - { - .name = "MSM8960 Compr3", - .stream_name = "COMPR3", - .cpu_dai_name = "MultiMedia8", - .platform_name = "msm-compr-dsp", - .dynamic = 1, - .trigger = {SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST}, - .codec_dai_name = "snd-soc-dummy-dai", - .codec_name = "snd-soc-dummy", - .ignore_suspend = 1, - .ignore_pmdown_time = 1, /* this dailink has playback support */ - .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8, - }, - /* Backend BT/FM DAI Links */ - { - .name = LPASS_BE_INT_BT_SCO_RX, - .stream_name = "Internal BT-SCO Playback", - .cpu_dai_name = "msm-dai-q6.12288", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX, - .be_hw_params_fixup = msm8960_btsco_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_BT_SCO_TX, - .stream_name = "Internal BT-SCO Capture", - .cpu_dai_name = "msm-dai-q6.12289", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX, - .be_hw_params_fixup = msm8960_btsco_be_hw_params_fixup, - }, - { - .name = LPASS_BE_INT_FM_RX, - .stream_name = "Internal FM Playback", - .cpu_dai_name = "msm-dai-q6.12292", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_RX, - .be_hw_params_fixup = msm8960_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_INT_FM_TX, - .stream_name = "Internal FM Capture", - .cpu_dai_name = "msm-dai-q6.12293", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INT_FM_TX, - .be_hw_params_fixup = msm8960_be_hw_params_fixup, - }, - /* HDMI BACK END DAI Link */ - { - .name = LPASS_BE_HDMI, - .stream_name = "HDMI Playback", - .cpu_dai_name = "msm-dai-q6-hdmi.8", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_HDMI_RX, - .be_hw_params_fixup = msm8960_hdmi_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - /* Backend AFE DAI Links */ - { - .name = LPASS_BE_AFE_PCM_RX, - .stream_name = "AFE Playback", - .cpu_dai_name = "msm-dai-q6.224", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, - .be_hw_params_fixup = msm8960_proxy_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_AFE_PCM_TX, - .stream_name = "AFE Capture", - .cpu_dai_name = "msm-dai-q6.225", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, - .be_hw_params_fixup = msm8960_proxy_be_hw_params_fixup, - }, - /* AUX PCM Backend DAI Links */ - { - .name = LPASS_BE_AUXPCM_RX, - .stream_name = "AUX PCM Playback", - .cpu_dai_name = "msm-dai-q6.2", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_RX, - .be_hw_params_fixup = msm8960_auxpcm_be_params_fixup, - .ops = &msm8960_auxpcm_be_ops, - .ignore_pmdown_time = 1, - }, - { - .name = LPASS_BE_AUXPCM_TX, - .stream_name = "AUX PCM Capture", - .cpu_dai_name = "msm-dai-q6.3", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_AUXPCM_TX, - .be_hw_params_fixup = msm8960_auxpcm_be_params_fixup, - .ops = &msm8960_auxpcm_be_ops, - }, - /* Incall Music BACK END DAI Link */ - { - .name = LPASS_BE_VOICE_PLAYBACK_TX, - .stream_name = "Voice Farend Playback", - .cpu_dai_name = "msm-dai-q6.32773", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-rx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, - .be_hw_params_fixup = msm8960_be_hw_params_fixup, - }, - /* Incall Record Uplink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_TX, - .stream_name = "Voice Uplink Capture", - .cpu_dai_name = "msm-dai-q6.32772", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX, - .be_hw_params_fixup = msm8960_be_hw_params_fixup, - }, - /* Incall Record Downlink BACK END DAI Link */ - { - .name = LPASS_BE_INCALL_RECORD_RX, - .stream_name = "Voice Downlink Capture", - .cpu_dai_name = "msm-dai-q6.32771", - .platform_name = "msm-pcm-routing", - .codec_name = "msm-stub-codec.1", - .codec_dai_name = "msm-stub-tx", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX, - .be_hw_params_fixup = msm8960_be_hw_params_fixup, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, -}; - -static struct snd_soc_dai_link msm8960_dai_delta_tabla1x[] = { - /* Backend DAI Links */ - { - .name = LPASS_BE_SLIMBUS_0_RX, - .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla1x_codec", - .codec_dai_name = "tabla_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX, - .init = &msm8960_audrx_init, - .be_hw_params_fixup = msm8960_slim_0_rx_be_hw_params_fixup, - .ops = &msm8960_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_0_TX, - .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla1x_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX, - .be_hw_params_fixup = msm8960_slim_0_tx_be_hw_params_fixup, - .ops = &msm8960_be_ops, - }, - /* Ultrasound TX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Capture", - .stream_name = "SLIMBUS_2 Hostless Capture", - .cpu_dai_name = "msm-dai-q6.16389", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla1x_codec", - .codec_dai_name = "tabla_tx2", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm8960_slimbus_2_be_ops, - }, - /* Ultrasound RX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Playback", - .stream_name = "SLIMBUS_2 Hostless Playback", - .cpu_dai_name = "msm-dai-q6.16388", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla1x_codec", - .codec_dai_name = "tabla_rx3", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm8960_slimbus_2_be_ops, - }, -}; - - -static struct snd_soc_dai_link msm8960_dai_delta_tabla2x[] = { - /* Backend DAI Links */ - { - .name = LPASS_BE_SLIMBUS_0_RX, - .stream_name = "Slimbus Playback", - .cpu_dai_name = "msm-dai-q6.16384", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX, - .init = &msm8960_audrx_init, - .be_hw_params_fixup = msm8960_slim_0_rx_be_hw_params_fixup, - .ops = &msm8960_be_ops, - .ignore_pmdown_time = 1, /* this dainlink has playback support */ - }, - { - .name = LPASS_BE_SLIMBUS_0_TX, - .stream_name = "Slimbus Capture", - .cpu_dai_name = "msm-dai-q6.16385", - .platform_name = "msm-pcm-routing", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx1", - .no_pcm = 1, - .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX, - .be_hw_params_fixup = msm8960_slim_0_tx_be_hw_params_fixup, - .ops = &msm8960_be_ops, - }, - /* Ultrasound TX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Capture", - .stream_name = "SLIMBUS_2 Hostless Capture", - .cpu_dai_name = "msm-dai-q6.16389", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_tx2", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm8960_slimbus_2_be_ops, - }, - /* Ultrasound RX Back End DAI Link */ - { - .name = "SLIMBUS_2 Hostless Playback", - .stream_name = "SLIMBUS_2 Hostless Playback", - .cpu_dai_name = "msm-dai-q6.16388", - .platform_name = "msm-pcm-hostless", - .codec_name = "tabla_codec", - .codec_dai_name = "tabla_rx3", - .ignore_suspend = 1, - .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, - .ops = &msm8960_slimbus_2_be_ops, - }, -}; - -static struct snd_soc_dai_link msm8960_tabla1x_dai[ - ARRAY_SIZE(msm8960_dai_common) + - ARRAY_SIZE(msm8960_dai_delta_tabla1x)]; - - -static struct snd_soc_dai_link msm8960_dai[ - ARRAY_SIZE(msm8960_dai_common) + - ARRAY_SIZE(msm8960_dai_delta_tabla2x)]; - -static struct snd_soc_card snd_soc_tabla1x_card_msm8960 = { - .name = "msm8960-tabla1x-snd-card", - .dai_link = msm8960_tabla1x_dai, - .num_links = ARRAY_SIZE(msm8960_tabla1x_dai), - .controls = tabla_msm8960_controls, - .num_controls = ARRAY_SIZE(tabla_msm8960_controls), -}; - -static struct snd_soc_card snd_soc_card_msm8960 = { - .name = "msm8960-snd-card", - .dai_link = msm8960_dai, - .num_links = ARRAY_SIZE(msm8960_dai), - .controls = tabla_msm8960_controls, - .num_controls = ARRAY_SIZE(tabla_msm8960_controls), -}; - -static struct platform_device *msm8960_snd_device; -static struct platform_device *msm8960_snd_tabla1x_device; - -static int msm8960_configure_headset_mic_gpios(void) -{ - int ret; - struct pm_gpio param = { - .direction = PM_GPIO_DIR_OUT, - .output_buffer = PM_GPIO_OUT_BUF_CMOS, - .output_value = 1, - .pull = PM_GPIO_PULL_NO, - .vin_sel = PM_GPIO_VIN_S4, - .out_strength = PM_GPIO_STRENGTH_MED, - .function = PM_GPIO_FUNC_NORMAL, - }; - - ret = gpio_request(PM8921_GPIO_PM_TO_SYS(23), "AV_SWITCH"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", __func__, - PM8921_GPIO_PM_TO_SYS(23)); - return ret; - } - - ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(23), ¶m); - if (ret) - pr_err("%s: Failed to configure gpio %d\n", __func__, - PM8921_GPIO_PM_TO_SYS(23)); - else - gpio_direction_output(PM8921_GPIO_PM_TO_SYS(23), 0); - - ret = gpio_request(us_euro_sel_gpio, "US_EURO_SWITCH"); - if (ret) { - pr_err("%s: Failed to request gpio %d\n", __func__, - us_euro_sel_gpio); - gpio_free(PM8921_GPIO_PM_TO_SYS(23)); - return ret; - } - ret = pm8xxx_gpio_config(us_euro_sel_gpio, ¶m); - if (ret) - pr_err("%s: Failed to configure gpio %d\n", __func__, - us_euro_sel_gpio); - else - gpio_direction_output(us_euro_sel_gpio, 0); - - return 0; -} -static void msm8960_free_headset_mic_gpios(void) -{ - if (msm8960_headset_gpios_configured) { - gpio_free(PM8921_GPIO_PM_TO_SYS(23)); - gpio_free(us_euro_sel_gpio); - } -} - -static int __init msm8960_audio_init(void) -{ - int ret; - - if (!soc_class_is_msm8960()) { - pr_debug("%s: Not the right machine type\n", __func__); - return -ENODEV ; - } - - mutex_init(&cdc_mclk_mutex); - mbhc_cfg.calibration = def_tabla_mbhc_cal(); - if (!mbhc_cfg.calibration) { - pr_err("Calibration data allocation failed\n"); - return -ENOMEM; - } - - msm8960_snd_device = platform_device_alloc("soc-audio", 0); - if (!msm8960_snd_device) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - - memcpy(msm8960_dai, msm8960_dai_common, sizeof(msm8960_dai_common)); - memcpy(msm8960_dai + ARRAY_SIZE(msm8960_dai_common), - msm8960_dai_delta_tabla2x, sizeof(msm8960_dai_delta_tabla2x)); - - platform_set_drvdata(msm8960_snd_device, &snd_soc_card_msm8960); - ret = platform_device_add(msm8960_snd_device); - if (ret) { - platform_device_put(msm8960_snd_device); - kfree(mbhc_cfg.calibration); - return ret; - } - - msm8960_snd_tabla1x_device = platform_device_alloc("soc-audio", 1); - if (!msm8960_snd_tabla1x_device) { - pr_err("Platform device allocation failed\n"); - kfree(mbhc_cfg.calibration); - return -ENOMEM; - } - - memcpy(msm8960_tabla1x_dai, msm8960_dai_common, - sizeof(msm8960_dai_common)); - memcpy(msm8960_tabla1x_dai + ARRAY_SIZE(msm8960_dai_common), - msm8960_dai_delta_tabla1x, sizeof(msm8960_dai_delta_tabla1x)); - - platform_set_drvdata(msm8960_snd_tabla1x_device, - &snd_soc_tabla1x_card_msm8960); - ret = platform_device_add(msm8960_snd_tabla1x_device); - if (ret) { - platform_device_put(msm8960_snd_tabla1x_device); - kfree(mbhc_cfg.calibration); - return ret; - } - - if (cpu_is_msm8960()) { - if (msm8960_configure_headset_mic_gpios()) { - pr_err("%s Fail to configure headset mic gpios\n", - __func__); - msm8960_headset_gpios_configured = 0; - } else - msm8960_headset_gpios_configured = 1; - } else { - msm8960_headset_gpios_configured = 0; - pr_debug("%s headset GPIO 23 and 35 not configured msm960ab", - __func__); - } - - atomic_set(&auxpcm_rsc_ref, 0); - return ret; - -} -module_init(msm8960_audio_init); - -static void __exit msm8960_audio_exit(void) -{ - if (!soc_class_is_msm8960()) { - pr_debug("%s: Not the right machine type\n", __func__); - return ; - } - msm8960_free_headset_mic_gpios(); - platform_device_unregister(msm8960_snd_device); - platform_device_unregister(msm8960_snd_tabla1x_device); - kfree(mbhc_cfg.calibration); - mutex_destroy(&cdc_mclk_mutex); -} -module_exit(msm8960_audio_exit); - -MODULE_DESCRIPTION("ALSA SoC MSM8960"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm8x60-dai.c b/sound/soc/msm/msm8x60-dai.c deleted file mode 100644 index eb5b8f97843e1963e22896e8811bc9aa91a0b93f..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8x60-dai.c +++ /dev/null @@ -1,148 +0,0 @@ -/* sound/soc/msm/msm-dai.c - * - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2010, The Linux Foundation. All rights reserved. - * - * Derived from msm-pcm.c and msm7201.c. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm8x60-pcm.h" - -static struct snd_soc_dai_driver msm_pcm_codec_dais[] = { -{ - .name = "msm-codec-dai", - .playback = { - .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .capture = { - .channels_max = 2, - .rate_min = 8000, - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, -}, -}; -static struct snd_soc_dai_driver msm_pcm_cpu_dais[] = { -{ - .name = "msm-cpu-dai", - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rate_min = 8000, - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, -}, -}; - -static struct snd_soc_codec_driver soc_codec_dev_msm = { - .compress_type = SND_SOC_FLAT_COMPRESSION, -}; - -static int asoc_msm_codec_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm, - msm_pcm_codec_dais, ARRAY_SIZE(msm_pcm_codec_dais)); -} - -static int asoc_msm_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static int asoc_msm_cpu_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_dai(&pdev->dev, msm_pcm_cpu_dais); -} - -static int asoc_msm_cpu_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static struct platform_driver asoc_msm_codec_driver = { - .probe = asoc_msm_codec_probe, - .remove = asoc_msm_codec_remove, - .driver = { - .name = "msm-codec-dai", - .owner = THIS_MODULE, - }, -}; - -static struct platform_driver asoc_msm_cpu_driver = { - .probe = asoc_msm_cpu_probe, - .remove = asoc_msm_cpu_remove, - .driver = { - .name = "msm-cpu-dai", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_codec_dai_init(void) -{ - return platform_driver_register(&asoc_msm_codec_driver); -} - -static void __exit msm_codec_dai_exit(void) -{ - platform_driver_unregister(&asoc_msm_codec_driver); -} - -static int __init msm_cpu_dai_init(void) -{ - return platform_driver_register(&asoc_msm_cpu_driver); -} - -static void __exit msm_cpu_dai_exit(void) -{ - platform_driver_unregister(&asoc_msm_cpu_driver); -} - -module_init(msm_codec_dai_init); -module_exit(msm_codec_dai_exit); -module_init(msm_cpu_dai_init); -module_exit(msm_cpu_dai_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm8x60-pcm.c b/sound/soc/msm/msm8x60-pcm.c deleted file mode 100644 index 96d0343ef1d5b9862346a64c143b36801a7b39a5..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8x60-pcm.c +++ /dev/null @@ -1,806 +0,0 @@ -/* Copyright (c) 2010-2011, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "msm8x60-pcm.h" - -struct snd_msm { - struct snd_card *card; - struct snd_pcm *pcm; -}; - -static struct snd_pcm_hardware msm_pcm_hardware = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = 960 * 10, - .period_bytes_min = 960 * 5, - .period_bytes_max = 960 * 5, - .periods_min = 2, - .periods_max = 2, - .fifo_size = 0, -}; - -/* Conventional and unconventional sample rate supported */ -static unsigned int supported_sample_rates[] = { - 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 -}; - -uint32_t in_frame_info[8][2]; - -static struct snd_pcm_hw_constraint_list constraints_sample_rates = { - .count = ARRAY_SIZE(supported_sample_rates), - .list = supported_sample_rates, - .mask = 0, -}; - -static void alsa_out_listener(u32 evt_id, union auddev_evt_data *evt_payload, - void *private_data) -{ - int ret = 0; - struct msm_audio *prtd = (struct msm_audio *) private_data; - int dev_rate = 48000; - pr_debug("evt_id = 0x%8x\n", evt_id); - switch (evt_id) { - case AUDDEV_EVT_DEV_RDY: - pr_debug("AUDDEV_EVT_DEV_RDY\n"); - prtd->copp_id = evt_payload->routing_id; - pr_debug("prtd->session_id = %d, copp_id= %d", - prtd->session_id, prtd->copp_id); - if (prtd->copp_id == PCM_RX) - dev_rate = 8000; - - ret = msm_snddev_set_dec(prtd->session_id, prtd->copp_id, 1, - dev_rate, 1); - break; - case AUDDEV_EVT_DEV_RLS: - pr_debug("AUDDEV_EVT_DEV_RLS\n"); - prtd->copp_id = evt_payload->routing_id; - pr_debug("prtd->session_id = %d, copp_id= %d", - prtd->session_id, prtd->copp_id); - if (prtd->copp_id == PCM_RX) - dev_rate = 8000; - - ret = msm_snddev_set_dec(prtd->session_id, prtd->copp_id, 0, - dev_rate, 1); - break; - case AUDDEV_EVT_STREAM_VOL_CHG: - pr_debug("AUDDEV_EVT_STREAM_VOL_CHG\n"); - break; - default: - pr_debug("Unknown Event\n"); - break; - } -} - -static void alsa_in_listener(u32 evt_id, union auddev_evt_data *evt_payload, - void *private_data) -{ - int ret = 0; - struct msm_audio *prtd = (struct msm_audio *) private_data; - int dev_rate = 48000; - pr_debug("evt_id = 0x%8x\n", evt_id); - - switch (evt_id) { - case AUDDEV_EVT_DEV_RDY: - prtd->copp_id = evt_payload->routing_id; - if (prtd->copp_id == PCM_TX) - dev_rate = 8000; - - ret = msm_snddev_set_enc(prtd->session_id, prtd->copp_id, 1, - dev_rate, 1); - break; - case AUDDEV_EVT_DEV_RLS: - prtd->copp_id = evt_payload->routing_id; - if (prtd->copp_id == PCM_TX) - dev_rate = 8000; - - ret = msm_snddev_set_enc(prtd->session_id, prtd->copp_id, 0, - dev_rate, 1); - break; - default: - pr_debug("Unknown Event\n"); - break; - } -} - -static void event_handler(uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv) -{ - struct msm_audio *prtd = priv; - struct snd_pcm_substream *substream = prtd->substream; - uint32_t *ptrmem = (uint32_t *)payload; - int i = 0; - - pr_debug("%s\n", __func__); - switch (opcode) { - case ASM_DATA_EVENT_WRITE_DONE: { - pr_debug("ASM_DATA_EVENT_WRITE_DONE\n"); - pr_debug("Buffer Consumed = 0x%08x\n", *ptrmem); - prtd->pcm_irq_pos += prtd->pcm_count; - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - atomic_inc(&prtd->out_count); - wake_up(&the_locks.write_wait); - if (!atomic_read(&prtd->start)) - break; - if (!prtd->mmap_flag) - break; - pr_debug("%s:writing %d bytes of buffer to dsp 2\n", - __func__, prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, 0, 0, NO_TIMESTAMP); - break; - } - case ASM_DATA_CMDRSP_EOS: - pr_debug("ASM_DATA_CMDRSP_EOS\n"); - prtd->cmd_ack = 1; - wake_up(&the_locks.eos_wait); - break; - case ASM_DATA_EVENT_READ_DONE: { - pr_debug("ASM_DATA_EVENT_READ_DONE\n"); - pr_debug("token = 0x%08x\n", token); - for (i = 0; i < 8; i++, ++ptrmem) - pr_debug("cmd[%d]=0x%08x\n", i, *ptrmem); - in_frame_info[token][0] = payload[2]; - in_frame_info[token][1] = payload[3]; - prtd->pcm_irq_pos += in_frame_info[token][0]; - pr_debug("pcm_irq_pos=%d\n", prtd->pcm_irq_pos); - if (atomic_read(&prtd->start)) - snd_pcm_period_elapsed(substream); - if (atomic_read(&prtd->in_count) <= prtd->periods) - atomic_inc(&prtd->in_count); - wake_up(&the_locks.read_wait); - if (prtd->mmap_flag) - q6asm_read_nolock(prtd->audio_client); - break; - } - case APR_BASIC_RSP_RESULT: { - if (!prtd->mmap_flag - && !atomic_read(&prtd->out_needed)) - break; - switch (payload[0]) { - case ASM_SESSION_CMD_RUN: - if (substream->stream - != SNDRV_PCM_STREAM_PLAYBACK) - break; - if (prtd->mmap_flag) { - pr_debug("%s:writing %d bytes" - " of buffer to dsp\n", - __func__, - prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); - } else { - while (atomic_read(&prtd->out_needed)) { - pr_debug("%s:writing %d bytes" - " of buffer to dsp\n", - __func__, - prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); - atomic_dec(&prtd->out_needed); - wake_up(&the_locks.write_wait); - }; - } - break; - default: - break; - } - } - break; - default: - pr_debug("Not Supported Event opcode[0x%x]\n", opcode); - break; - } -} - -static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret; - int dev_rate = 48000; - int i = 0; - - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - if (prtd->enabled) - return 0; - - ret = q6asm_media_format_block_pcm(prtd->audio_client, runtime->rate, - runtime->channels); - if (ret < 0) - pr_debug("%s: CMD Format block failed\n", __func__); - - atomic_set(&prtd->out_count, runtime->periods); - atomic_set(&prtd->in_count, 0); - for (i = 0; i < MAX_COPP; i++) { - pr_debug("prtd->session_id = %d, copp_id= %d", - prtd->session_id, i); - if (session_route.playback_session[substream->number][i] - != DEVICE_IGNORE) { - pr_err("Device active\n"); - if (i == PCM_RX) - dev_rate = 8000; - msm_snddev_set_dec(prtd->session_id, - i, 1, dev_rate, runtime->channels); - } - } - prtd->enabled = 1; - prtd->cmd_ack = 0; - return 0; -} - -static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int ret = 0; - int i = 0; - int dev_rate = 48000; - pr_debug("%s\n", __func__); - prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); - prtd->pcm_count = snd_pcm_lib_period_bytes(substream); - prtd->pcm_irq_pos = 0; - - /* rate and channels are sent to audio driver */ - prtd->samp_rate = runtime->rate; - prtd->channel_mode = runtime->channels; - - if (prtd->enabled) - return 0; - - pr_debug("Samp_rate = %d\n", prtd->samp_rate); - pr_debug("Channel = %d\n", prtd->channel_mode); - ret = q6asm_enc_cfg_blk_pcm(prtd->audio_client, prtd->samp_rate, - prtd->channel_mode); - if (ret < 0) - pr_debug("%s: cmd cfg pcm was block failed", __func__); - - for (i = 0; i < runtime->periods; i++) - q6asm_read_nolock(prtd->audio_client); - prtd->periods = runtime->periods; - for (i = 0; i < MAX_COPP; i++) { - pr_debug("prtd->session_id = %d, copp_id= %d", - prtd->session_id, - session_route.capture_session[prtd->session_id][i]); - if (session_route.capture_session[prtd->session_id][i] - != DEVICE_IGNORE) { - if (i == PCM_RX) - dev_rate = 8000; - msm_snddev_set_enc(prtd->session_id, i, 1, dev_rate, 1); - } - } - prtd->enabled = 1; - - return ret; -} - -static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - pr_debug("%s\n", __func__); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - pr_debug("SNDRV_PCM_TRIGGER_START\n"); - q6asm_run_nowait(prtd->audio_client, 0, 0, 0); - atomic_set(&prtd->start, 1); - break; - case SNDRV_PCM_TRIGGER_STOP: - pr_debug("SNDRV_PCM_TRIGGER_STOP\n"); - atomic_set(&prtd->start, 0); - if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) - break; - prtd->cmd_ack = 0; - q6asm_cmd_nowait(prtd->audio_client, CMD_EOS); - break; - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - pr_debug("SNDRV_PCM_TRIGGER_PAUSE\n"); - q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE); - atomic_set(&prtd->start, 0); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static int msm_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd; - int ret = 0; - - pr_debug("%s\n", __func__); - prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); - if (prtd == NULL) { - pr_err("Failed to allocate memory for msm_audio\n"); - return -ENOMEM; - } - runtime->hw = msm_pcm_hardware; - prtd->substream = substream; - prtd->audio_client = q6asm_audio_client_alloc( - (app_cb)event_handler, prtd); - if (!prtd->audio_client) { - pr_debug("%s: Could not allocate memory\n", __func__); - kfree(prtd); - return -ENOMEM; - } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = q6asm_open_write(prtd->audio_client, FORMAT_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm out open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - } - /* Capture path */ - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - ret = q6asm_open_read(prtd->audio_client, FORMAT_LINEAR_PCM); - if (ret < 0) { - pr_err("%s: pcm in open failed\n", __func__); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - return -ENOMEM; - } - } - /* The session id returned by q6asm_open_read above is random and - * hence we cannot use the session id to route from user space. - * This results in need of a hardcoded session id for both playback - * and capture sessions. we can use the subdevice id to identify - * the session and use that for routing. Hence using - * substream->number as the session id for routing purpose. However - * DSP understands the session based on the allocated session id, - * hence using the variable prtd->session_id for all dsp commands. - */ - - prtd->session_id = prtd->audio_client->session; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - prtd->cmd_ack = 1; - prtd->device_events = AUDDEV_EVT_DEV_RDY | - AUDDEV_EVT_STREAM_VOL_CHG | - AUDDEV_EVT_DEV_RLS; - prtd->source = msm_snddev_route_dec(prtd->session_id); - pr_debug("Register device event listener for" - "SNDRV_PCM_STREAM_PLAYBACK session %d\n", - substream->number); - ret = auddev_register_evt_listner(prtd->device_events, - AUDDEV_CLNT_DEC, substream->number, - alsa_out_listener, (void *) prtd); - if (ret) - pr_debug("failed to register device event listener\n"); - } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { - prtd->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS | - AUDDEV_EVT_FREQ_CHG; - prtd->source = msm_snddev_route_enc(prtd->session_id); - pr_debug("Register device event listener for" - "SNDRV_PCM_STREAM_CAPTURE session %d\n", - substream->number); - ret = auddev_register_evt_listner(prtd->device_events, - AUDDEV_CLNT_ENC, substream->number, - alsa_in_listener, (void *) prtd); - if (ret) - pr_debug("failed to register device event listener\n"); - } - ret = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_sample_rates); - if (ret < 0) - pr_debug("snd_pcm_hw_constraint_list failed\n"); - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - pr_debug("snd_pcm_hw_constraint_integer failed\n"); - - prtd->dsp_cnt = 0; - runtime->private_data = prtd; - - return 0; -} - -static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer = 0; - char *bufptr = NULL; - void *data = NULL; - uint32_t idx = 0; - uint32_t size = 0; - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - fbytes = frames_to_bytes(runtime, frames); - pr_debug("%s: prtd->out_count = %d\n", - __func__, atomic_read(&prtd->out_count)); - ret = wait_event_timeout(the_locks.write_wait, - (atomic_read(&prtd->out_count)), 5 * HZ); - if (ret < 0) { - pr_debug("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - - if (!atomic_read(&prtd->out_count)) { - pr_debug("%s: pcm stopped out_count 0\n", __func__); - return 0; - } - data = q6asm_is_cpu_buf_avail(IN, prtd->audio_client, &size, &idx); - bufptr = data; - if (bufptr) { - pr_debug("%s:fbytes =%d: xfer=%d size=%d\n", - __func__, fbytes, xfer, size); - xfer = fbytes; - if (copy_from_user(bufptr, buf, xfer)) { - ret = -EFAULT; - goto fail; - } - buf += xfer; - fbytes -= xfer; - pr_debug("%s:fbytes = %d: xfer=%d\n", __func__, fbytes, xfer); - if (atomic_read(&prtd->start)) { - pr_debug("%s:writing %d bytes of buffer to dsp\n", - __func__, xfer); - ret = q6asm_write_nolock(prtd->audio_client, xfer, - 0, 0, NO_TIMESTAMP); - if (ret < 0) { - ret = -EFAULT; - goto fail; - } - } else - atomic_inc(&prtd->out_needed); - atomic_dec(&prtd->out_count); - } -fail: - return ret; -} - -static int msm_pcm_playback_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int dir = 0; - int ret = 0; - - pr_debug("%s\n", __func__); - - dir = IN; - ret = wait_event_timeout(the_locks.eos_wait, - prtd->cmd_ack, 5 * HZ); - if (ret < 0) - pr_err("%s: CMD_EOS failed\n", __func__); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - - pr_debug("%s\n", __func__); - auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, - substream->number); - pr_debug("%s\n", __func__); - msm_clear_session_id(prtd->session_id); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - - return 0; -} - -static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, - int channel, snd_pcm_uframes_t hwoff, void __user *buf, - snd_pcm_uframes_t frames) -{ - int ret = 0; - int fbytes = 0; - int xfer; - char *bufptr; - void *data = NULL; - static uint32_t idx; - static uint32_t size; - uint32_t offset = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = substream->runtime->private_data; - - - pr_debug("%s\n", __func__); - fbytes = frames_to_bytes(runtime, frames); - - pr_debug("appl_ptr %d\n", (int)runtime->control->appl_ptr); - pr_debug("hw_ptr %d\n", (int)runtime->status->hw_ptr); - pr_debug("avail_min %d\n", (int)runtime->control->avail_min); - - ret = wait_event_timeout(the_locks.read_wait, - (atomic_read(&prtd->in_count)), 5 * HZ); - if (ret < 0) { - pr_debug("%s: wait_event_timeout failed\n", __func__); - goto fail; - } - if (!atomic_read(&prtd->in_count)) { - pr_debug("%s: pcm stopped in_count 0\n", __func__); - return 0; - } - pr_debug("Checking if valid buffer is available...%08x\n", - (unsigned int) data); - data = q6asm_is_cpu_buf_avail(OUT, prtd->audio_client, &size, &idx); - bufptr = data; - pr_debug("Size = %d\n", size); - pr_debug("fbytes = %d\n", fbytes); - pr_debug("idx = %d\n", idx); - if (bufptr) { - xfer = fbytes; - if (xfer > size) - xfer = size; - offset = in_frame_info[idx][1]; - pr_debug("Offset value = %d\n", offset); - if (copy_to_user(buf, bufptr+offset, xfer)) { - pr_err("Failed to copy buf to user\n"); - ret = -EFAULT; - goto fail; - } - fbytes -= xfer; - size -= xfer; - in_frame_info[idx][1] += xfer; - pr_debug("%s:fbytes = %d: size=%d: xfer=%d\n", - __func__, fbytes, size, xfer); - pr_debug(" Sending next buffer to dsp\n"); - memset(&in_frame_info[idx], 0, - sizeof(uint32_t) * 2); - atomic_dec(&prtd->in_count); - ret = q6asm_read_nolock(prtd->audio_client); - if (ret < 0) { - pr_err("q6asm read failed\n"); - ret = -EFAULT; - goto fail; - } - } else - pr_err("No valid buffer\n"); - - pr_debug("Returning from capture_copy... %d\n", ret); -fail: - return ret; -} - -static int msm_pcm_capture_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - int dir = OUT; - - pr_debug("%s\n", __func__); - q6asm_cmd(prtd->audio_client, CMD_CLOSE); - q6asm_audio_client_buf_free_contiguous(dir, - prtd->audio_client); - auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, - substream->number); - msm_clear_session_id(prtd->session_id); - q6asm_audio_client_free(prtd->audio_client); - kfree(prtd); - - return 0; -} - -static int msm_pcm_copy(struct snd_pcm_substream *substream, int a, - snd_pcm_uframes_t hwoff, void __user *buf, snd_pcm_uframes_t frames) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_copy(substream, a, hwoff, buf, frames); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_copy(substream, a, hwoff, buf, frames); - return ret; -} - -static int msm_pcm_close(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_close(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_close(substream); - return ret; -} -static int msm_pcm_prepare(struct snd_pcm_substream *substream) -{ - int ret = 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = msm_pcm_playback_prepare(substream); - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - ret = msm_pcm_capture_prepare(substream); - return ret; -} - -static snd_pcm_uframes_t msm_pcm_pointer(struct snd_pcm_substream *substream) -{ - - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - if (prtd->pcm_irq_pos >= prtd->pcm_size) - prtd->pcm_irq_pos = 0; - pr_debug("%s: pcm_irq_pos = %d\n", __func__, prtd->pcm_irq_pos); - return bytes_to_frames(runtime, (prtd->pcm_irq_pos)); -} - -int msm_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - - pr_debug("%s\n", __func__); - prtd->mmap_flag = 1; - dma_mmap_coherent(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); - return 0; -} - -int msm_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct msm_audio *prtd = runtime->private_data; - struct snd_dma_buffer *dma_buf = &substream->dma_buffer; - struct audio_buffer *buf; - int dir, ret; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dir = IN; - else - dir = OUT; - - ret = q6asm_audio_client_buf_alloc_contiguous(dir, - prtd->audio_client, - runtime->hw.period_bytes_min, - runtime->hw.periods_max); - if (ret < 0) { - pr_err("Audio Start: Buffer Allocation failed \ - rc = %d\n", ret); - return -ENOMEM; - } - buf = prtd->audio_client->port[dir].buf; - - pr_debug("%s:buf = %p\n", __func__, buf); - dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; - dma_buf->dev.dev = substream->pcm->card->dev; - dma_buf->private_data = NULL; - dma_buf->area = buf[0].data; - dma_buf->addr = buf[0].phys; - dma_buf->bytes = runtime->hw.buffer_bytes_max; - if (!dma_buf->area) - return -ENOMEM; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - return 0; -} - -static struct snd_pcm_ops msm_pcm_ops = { - .open = msm_pcm_open, - .copy = msm_pcm_copy, - .hw_params = msm_pcm_hw_params, - .close = msm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .prepare = msm_pcm_prepare, - .trigger = msm_pcm_trigger, - .pointer = msm_pcm_pointer, - .mmap = msm_pcm_mmap, -}; - -static int msm_pcm_new(struct snd_soc_pcm_runtime *rtd) -{ - int ret = 0; - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm; - - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, 2); - if (ret) - return ret; - ret = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, 1); - if (ret) - return ret; - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &msm_pcm_ops); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &msm_pcm_ops); - - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - return ret; -} - -struct snd_soc_platform_driver msm_soc_platform = { - .ops = &msm_pcm_ops, - .pcm_new = msm_pcm_new, -}; -EXPORT_SYMBOL(msm_soc_platform); - -static int msm_pcm_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_platform(&pdev->dev, - &msm_soc_platform); -} - -static int msm_pcm_remove(struct platform_device *pdev) -{ - snd_soc_unregister_platform(&pdev->dev); - return 0; -} - -static struct platform_driver msm_pcm_driver = { - .probe = msm_pcm_probe, - .remove = msm_pcm_remove, - .driver = { - .name = "msm-dsp-audio", - .owner = THIS_MODULE, - }, -}; - -static int __init msm_soc_platform_init(void) -{ - return platform_driver_register(&msm_pcm_driver); -} -module_init(msm_soc_platform_init); - -static void __exit msm_soc_platform_exit(void) -{ - platform_driver_unregister(&msm_pcm_driver); -} -module_exit(msm_soc_platform_exit); - -MODULE_DESCRIPTION("PCM module platform driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm8x60-pcm.h b/sound/soc/msm/msm8x60-pcm.h deleted file mode 100644 index 31f0e6318fa38dab87a634a46b60d93b8ae1d467..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8x60-pcm.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2008 Google, Inc. - * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#ifndef _MSM_PCM_H -#define _MSM_PCM_H -#include -#include - -#define MAX_PLAYBACK_SESSIONS 2 -#define MAX_CAPTURE_SESSIONS 1 -#define MAX_COPP 12 - -extern int copy_count; - -struct buffer { - void *data; - unsigned size; - unsigned used; - unsigned addr; -}; - -struct buffer_rec { - void *data; - unsigned int size; - unsigned int read; - unsigned int addr; -}; - -struct audio_locks { - wait_queue_head_t read_wait; - wait_queue_head_t write_wait; - wait_queue_head_t eos_wait; - wait_queue_head_t enable_wait; -}; - -extern struct audio_locks the_locks; - -struct msm_audio { - struct snd_pcm_substream *substream; - unsigned int pcm_size; - unsigned int pcm_count; - unsigned int pcm_irq_pos; /* IRQ position */ - uint16_t source; /* Encoding source bit mask */ - - struct audio_client *audio_client; - - uint16_t session_id; - int copp_id; - - uint32_t samp_rate; - uint32_t channel_mode; - uint32_t dsp_cnt; - - uint32_t device_events; /* device events interested in */ - int abort; /* set when error, like sample rate mismatch */ - - int enabled; - int close_ack; - int cmd_ack; - atomic_t start; - atomic_t out_count; - atomic_t in_count; - atomic_t out_needed; - int periods; - int mmap_flag; -}; - -struct pcm_session { - unsigned short playback_session[MAX_PLAYBACK_SESSIONS][MAX_COPP]; - unsigned short capture_session[MAX_CAPTURE_SESSIONS][MAX_COPP]; -}; - -/* platform data */ -extern struct snd_soc_platform_driver msm_soc_platform; -extern struct pcm_session session_route; - -#endif /*_MSM_PCM_H*/ diff --git a/sound/soc/msm/msm8x60.c b/sound/soc/msm/msm8x60.c deleted file mode 100644 index 0ee2c865fed0eacb63d245e3edfa4c26c54361c3..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm8x60.c +++ /dev/null @@ -1,1230 +0,0 @@ -/* Copyright (c) 2010-2011, 2013 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define LOOPBACK_ENABLE 0x1 -#define LOOPBACK_DISABLE 0x0 - -#include "msm8x60-pcm.h" - -static struct platform_device *msm_audio_snd_device; -struct audio_locks the_locks; -EXPORT_SYMBOL(the_locks); -struct msm_volume msm_vol_ctl; -EXPORT_SYMBOL(msm_vol_ctl); -struct pcm_session session_route; -EXPORT_SYMBOL(session_route); -static struct snd_kcontrol_new snd_msm_controls[]; - -char snddev_name[AUDIO_DEV_CTL_MAX_DEV][44]; -#define MSM_MAX_VOLUME 0x2000 -#define MSM_VOLUME_STEP ((MSM_MAX_VOLUME+17)/100) /* 17 added to avoid - more deviation */ -static int device_index; /* Count of Device controls */ -static int simple_control; /* Count of simple controls*/ -static int src_dev; -static int dst_dev; -static int loopback_status; - -static int msm_scontrol_count_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - return 0; -} - -static int msm_scontrol_count_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = simple_control; - return 0; -} - -static int msm_v_call_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; /* start, session_id */ - uinfo->value.integer.min = 0; - uinfo->value.integer.max = SESSION_ID_BASE + MAX_VOC_SESSIONS; - return 0; -} - -static int msm_v_call_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - ucontrol->value.integer.value[1] = 0; - return 0; -} - -static int msm_v_call_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int start = ucontrol->value.integer.value[0]; - u32 session_id = ucontrol->value.integer.value[1]; - - if ((session_id != 0) && - ((session_id < SESSION_ID_BASE) || - (session_id >= SESSION_ID_BASE + MAX_VOC_SESSIONS))) { - pr_err("%s: Invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - if (start) - broadcast_event(AUDDEV_EVT_START_VOICE, DEVICE_IGNORE, - session_id); - else - broadcast_event(AUDDEV_EVT_END_VOICE, DEVICE_IGNORE, - session_id); - return 0; -} - -static int msm_v_mute_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; /* dir, mute, session_id */ - uinfo->value.integer.min = 0; - uinfo->value.integer.max = SESSION_ID_BASE + MAX_VOC_SESSIONS; - return 0; -} - -static int msm_v_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - ucontrol->value.integer.value[1] = 0; - ucontrol->value.integer.value[2] = 0; - return 0; -} - -static int msm_v_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int dir = ucontrol->value.integer.value[0]; - int mute = ucontrol->value.integer.value[1]; - u32 session_id = ucontrol->value.integer.value[2]; - - if ((session_id != 0) && - ((session_id < SESSION_ID_BASE) || - (session_id >= SESSION_ID_BASE + MAX_VOC_SESSIONS))) { - pr_err("%s: Invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - return msm_set_voice_mute(dir, mute, session_id); -} - -static int msm_v_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; /* dir, volume, session_id */ - uinfo->value.integer.min = 0; - uinfo->value.integer.max = SESSION_ID_BASE + MAX_VOC_SESSIONS; - return 0; -} - -static int msm_v_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - ucontrol->value.integer.value[1] = 0; - ucontrol->value.integer.value[2] = 0; - return 0; -} - -static int msm_v_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int dir = ucontrol->value.integer.value[0]; - int volume = ucontrol->value.integer.value[1]; - u32 session_id = ucontrol->value.integer.value[2]; - - if ((session_id != 0) && - ((session_id < SESSION_ID_BASE) || - (session_id >= SESSION_ID_BASE + MAX_VOC_SESSIONS))) { - pr_err("%s: Invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - return msm_set_voice_vol(dir, volume, session_id); -} - -static int msm_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; /* Volume */ - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 16383; - return 0; -} -static int msm_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int ret = 0; - int session_id = ucontrol->value.integer.value[0]; - int volume = ucontrol->value.integer.value[1]; - int factor = ucontrol->value.integer.value[2]; - u64 session_mask = 0; - - if (factor > 10000) - return -EINVAL; - - if ((volume < 0) || (volume/factor > 100)) - return -EINVAL; - - volume = (MSM_VOLUME_STEP * volume); - - /* Convert back to original decimal point by removing the 10-base factor - * and discard the fractional portion - */ - - volume = volume/factor; - - if (volume > MSM_MAX_VOLUME) - volume = MSM_MAX_VOLUME; - - /* Only Decoder volume control supported */ - session_mask = (((u64)0x1) << session_id) << (MAX_BIT_PER_CLIENT * \ - ((int)AUDDEV_CLNT_DEC-1)); - msm_vol_ctl.volume = volume; - pr_debug("%s:session_id %d, volume %d", __func__, session_id, volume); - broadcast_event(AUDDEV_EVT_STREAM_VOL_CHG, DEVICE_IGNORE, - session_mask); - - return ret; -} - -static int msm_voice_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; /* Device */ - - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_voice_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - uint32_t rx_dev_id; - uint32_t tx_dev_id; - struct msm_snddev_info *rx_dev_info; - struct msm_snddev_info *tx_dev_info; - int set = ucontrol->value.integer.value[2]; - u64 session_mask; - - if (!set) - return -EPERM; - /* Rx Device Routing */ - rx_dev_id = ucontrol->value.integer.value[0]; - rx_dev_info = audio_dev_ctrl_find_dev(rx_dev_id); - - if (IS_ERR(rx_dev_info)) { - pr_err("%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(rx_dev_info); - return rc; - } - - if (!(rx_dev_info->capability & SNDDEV_CAP_RX)) { - pr_err("%s:First Dev is supposed to be RX\n", __func__); - return -EFAULT; - } - - pr_debug("%s:route cfg %d STREAM_VOICE_RX type\n", - __func__, rx_dev_id); - - msm_set_voc_route(rx_dev_info, AUDIO_ROUTE_STREAM_VOICE_RX, - rx_dev_id); - - session_mask = ((u64)0x1) << (MAX_BIT_PER_CLIENT * \ - ((int)AUDDEV_CLNT_VOC-1)); - - broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, rx_dev_id, session_mask); - - - /* Tx Device Routing */ - tx_dev_id = ucontrol->value.integer.value[1]; - tx_dev_info = audio_dev_ctrl_find_dev(tx_dev_id); - - if (IS_ERR(tx_dev_info)) { - pr_err("%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(tx_dev_info); - return rc; - } - - if (!(tx_dev_info->capability & SNDDEV_CAP_TX)) { - pr_err("%s:Second Dev is supposed to be Tx\n", __func__); - return -EFAULT; - } - - pr_debug("%s:route cfg %d %d type\n", - __func__, tx_dev_id, AUDIO_ROUTE_STREAM_VOICE_TX); - - msm_set_voc_route(tx_dev_info, AUDIO_ROUTE_STREAM_VOICE_TX, - tx_dev_id); - - broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, tx_dev_id, session_mask); - - if (rx_dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RDY, rx_dev_id, session_mask); - - if (tx_dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RDY, tx_dev_id, session_mask); - - return rc; -} - -static int msm_voice_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - /* TODO: query Device list */ - return 0; -} - -static int msm_device_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; /* Device */ - - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_device_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - int set = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - struct msm_snddev_info *dst_dev_info; - struct msm_snddev_info *src_dev_info; - int tx_freq = 0; - int rx_freq = 0; - u32 set_freq = 0; - - set = ucontrol->value.integer.value[0]; - route_cfg.dev_id = ucontrol->id.numid - device_index; - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - if (IS_ERR(dev_info)) { - pr_err("%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(dev_info); - return rc; - } - pr_info("%s:device %s set %d\n", __func__, dev_info->name, set); - - if (set) { - if (!dev_info->opened) { - set_freq = dev_info->sample_rate; - if (!msm_device_is_voice(route_cfg.dev_id)) { - msm_get_voc_freq(&tx_freq, &rx_freq); - if (dev_info->capability & SNDDEV_CAP_TX) - set_freq = tx_freq; - - if (set_freq == 0) - set_freq = dev_info->sample_rate; - } else - set_freq = dev_info->sample_rate; - - - pr_err("%s:device freq =%d\n", __func__, set_freq); - rc = dev_info->dev_ops.set_freq(dev_info, set_freq); - if (rc < 0) { - pr_err("%s:device freq failed!\n", __func__); - return rc; - } - dev_info->set_sample_rate = rc; - rc = 0; - rc = dev_info->dev_ops.open(dev_info); - if (rc < 0) { - pr_err("%s:Enabling %s failed\n", - __func__, dev_info->name); - return rc; - } - dev_info->opened = 1; - broadcast_event(AUDDEV_EVT_DEV_RDY, route_cfg.dev_id, - SESSION_IGNORE); - if ((route_cfg.dev_id == src_dev) || - (route_cfg.dev_id == dst_dev)) { - dst_dev_info = audio_dev_ctrl_find_dev( - dst_dev); - if (IS_ERR(dst_dev_info)) { - pr_err("dst_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(dst_dev_info); - return rc; - } - src_dev_info = audio_dev_ctrl_find_dev( - src_dev); - if (IS_ERR(src_dev_info)) { - pr_err("src_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(src_dev_info); - return rc; - } - if ((dst_dev_info->opened) && - (src_dev_info->opened)) { - pr_debug("%d: Enable afe_loopback\n", - __LINE__); - afe_loopback(LOOPBACK_ENABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - loopback_status = 1; - } - } - } - } else { - if (dev_info->opened) { - broadcast_event(AUDDEV_EVT_REL_PENDING, - route_cfg.dev_id, - SESSION_IGNORE); - rc = dev_info->dev_ops.close(dev_info); - if (rc < 0) { - pr_err("%s:Snd device failed close!\n", - __func__); - return rc; - } else { - dev_info->opened = 0; - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - SESSION_IGNORE); - } - if (loopback_status == 1) { - if ((route_cfg.dev_id == src_dev) || - (route_cfg.dev_id == dst_dev)) { - dst_dev_info = audio_dev_ctrl_find_dev( - dst_dev); - if (IS_ERR(dst_dev_info)) { - pr_err("dst_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(dst_dev_info); - return rc; - } - src_dev_info = audio_dev_ctrl_find_dev( - src_dev); - if (IS_ERR(src_dev_info)) { - pr_err("src_dev:%s:pass invalid" - "dev_id\n", __func__); - rc = PTR_ERR(src_dev_info); - return rc; - } - pr_debug("%d: Disable afe_loopback\n", - __LINE__); - afe_loopback(LOOPBACK_DISABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - loopback_status = 0; - } - } - } - - } - return rc; -} - -static int msm_device_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - - route_cfg.dev_id = ucontrol->id.numid - device_index; - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - - if (IS_ERR(dev_info)) { - pr_err("%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(dev_info); - return rc; - } - - ucontrol->value.integer.value[0] = dev_info->copp_id; - ucontrol->value.integer.value[1] = dev_info->capability; - - return 0; -} - -static int msm_route_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; /* Device */ - - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_route_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - /* TODO: query Device list */ - return 0; -} - -static int msm_route_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - int enc_freq = 0; - int requested_freq = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - int session_id = ucontrol->value.integer.value[0]; - int set = ucontrol->value.integer.value[2]; - u64 session_mask = 0; - route_cfg.dev_id = ucontrol->value.integer.value[1]; - - if (ucontrol->id.numid == 2) - route_cfg.stream_type = AUDIO_ROUTE_STREAM_PLAYBACK; - else - route_cfg.stream_type = AUDIO_ROUTE_STREAM_REC; - - pr_debug("%s:route cfg %d %d type for popp %d\n", - __func__, route_cfg.dev_id, route_cfg.stream_type, session_id); - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - - if (IS_ERR(dev_info)) { - pr_err("%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(dev_info); - return rc; - } - if (route_cfg.stream_type == AUDIO_ROUTE_STREAM_PLAYBACK) { - rc = msm_snddev_set_dec(session_id, dev_info->copp_id, set, - dev_info->sample_rate, dev_info->channel_mode); - session_mask = - (((u64)0x1) << session_id) << (MAX_BIT_PER_CLIENT * \ - ((int)AUDDEV_CLNT_DEC-1)); - if (!set) { - if (dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - dev_info->sessions &= ~(session_mask); - } else { - dev_info->sessions = dev_info->sessions | session_mask; - if (dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RDY, - route_cfg.dev_id, - session_mask); - } - } else { - - rc = msm_snddev_set_enc(session_id, dev_info->copp_id, set, - dev_info->sample_rate, dev_info->channel_mode); - session_mask = - (((u64)0x1) << session_id) << (MAX_BIT_PER_CLIENT * \ - ((int)AUDDEV_CLNT_ENC-1)); - if (!set) { - if (dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - dev_info->sessions &= ~(session_mask); - } else { - dev_info->sessions = dev_info->sessions | session_mask; - enc_freq = msm_snddev_get_enc_freq(session_id); - requested_freq = enc_freq; - if (enc_freq > 0) { - rc = msm_snddev_request_freq(&enc_freq, - session_id, - SNDDEV_CAP_TX, - AUDDEV_CLNT_ENC); - pr_debug("%s:sample rate configured %d\ - sample rate requested %d \n", - __func__, enc_freq, requested_freq); - if ((rc <= 0) || (enc_freq != requested_freq)) { - pr_debug("%s:msm_snddev_withdraw_freq\n", - __func__); - rc = msm_snddev_withdraw_freq - (session_id, - SNDDEV_CAP_TX, AUDDEV_CLNT_ENC); - broadcast_event(AUDDEV_EVT_FREQ_CHG, - route_cfg.dev_id, - SESSION_IGNORE); - } - } - if (dev_info->opened) - broadcast_event(AUDDEV_EVT_DEV_RDY, - route_cfg.dev_id, - session_mask); - } - } - - if (rc < 0) { - pr_err("%s:device could not be assigned!\n", __func__); - return -EFAULT; - } - - return rc; -} - -static int msm_device_volume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 100; - return 0; -} - -static int msm_device_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct msm_snddev_info *dev_info; - - int dev_id = ucontrol->value.integer.value[0]; - - dev_info = audio_dev_ctrl_find_dev(dev_id); - ucontrol->value.integer.value[0] = dev_info->dev_volume; - - return 0; -} - -static int msm_device_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = -EPERM; - struct msm_snddev_info *dev_info; - - int dev_id = ucontrol->value.integer.value[0]; - int volume = ucontrol->value.integer.value[1]; - - pr_debug("%s:dev_id = %d, volume = %d\n", __func__, dev_id, volume); - - dev_info = audio_dev_ctrl_find_dev(dev_id); - - if (IS_ERR(dev_info)) { - rc = PTR_ERR(dev_info); - pr_err("%s: audio_dev_ctrl_find_dev failed. %ld \n", - __func__, PTR_ERR(dev_info)); - return rc; - } - - pr_debug("%s:dev_name = %s dev_id = %d, volume = %d\n", - __func__, dev_info->name, dev_id, volume); - - if (dev_info->dev_ops.set_device_volume) - rc = dev_info->dev_ops.set_device_volume(dev_info, volume); - else { - pr_info("%s : device %s does not support device volume " - "control.", __func__, dev_info->name); - return -EPERM; - } - - return rc; -} - -static int msm_reset_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 0; - return 0; -} - -static int msm_reset_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_reset_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - pr_err("%s:Resetting all devices\n", __func__); - return msm_reset_all_device(); -} - -static int msm_anc_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 1; - return 0; -} - -static int msm_anc_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_anc_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = -EPERM; - struct msm_snddev_info *dev_info; - - int dev_id = ucontrol->value.integer.value[0]; - int enable = ucontrol->value.integer.value[1]; - - pr_debug("%s: dev_id = %d, enable = %d\n", __func__, dev_id, enable); - dev_info = audio_dev_ctrl_find_dev(dev_id); - - if (IS_ERR(dev_info)) { - rc = PTR_ERR(dev_info); - pr_err("%s: audio_dev_ctrl_find_dev failed. %ld\n", - __func__, PTR_ERR(dev_info)); - return rc; - } - - if (dev_info->dev_ops.enable_anc) { - rc = dev_info->dev_ops.enable_anc(dev_info, enable); - } else { - pr_info("%s : device %s does not support anc control.", - __func__, dev_info->name); - return -EPERM; - } - - return rc; -} - -static int pcm_route_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - /* - * First parameter is session id ~ subdevice number - * Second parameter is device id. - */ - uinfo->count = 3; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int pcm_route_get_rx(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - return 0; -} - -static int pcm_route_get_tx(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - return 0; -} - -static int pcm_route_put_rx(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int session_id = 0; - int set = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - u64 session_mask = 0; - - /* - * session id is incremented by one and stored as session id 0 - * is being used by dsp currently. whereas user space would use - * subdevice number as session id. - */ - session_id = ucontrol->value.integer.value[0]; - route_cfg.dev_id = ucontrol->value.integer.value[1]; - set = ucontrol->value.integer.value[2]; - - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - if (IS_ERR(dev_info)) { - pr_err("pass invalid dev_id %d\n", route_cfg.dev_id); - return PTR_ERR(dev_info); - } - if (!(dev_info->capability & SNDDEV_CAP_RX)) - return -EINVAL; - session_mask = - (((u64)0x1) << session_id) << (MAX_BIT_PER_CLIENT * \ - ((int)AUDDEV_CLNT_DEC-1)); - if (!set) { - session_route.playback_session[session_id][dev_info->copp_id] - = DEVICE_IGNORE; - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - dev_info->sessions &= ~(session_mask); - return 0; - } - pr_debug("%s:Routing playback session %d to %s\n", - __func__, (session_id), - dev_info->name); - session_route.playback_session[session_id][dev_info->copp_id] = - dev_info->copp_id; - if (dev_info->opened) { - dev_info->sessions = dev_info->sessions | session_mask; - broadcast_event(AUDDEV_EVT_DEV_RDY, - route_cfg.dev_id, - session_mask); - } else { - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - dev_info->sessions &= ~(session_mask); - } - return 0; -} - -static int pcm_route_put_tx(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int session_id = 0; - int set = 0; - struct msm_audio_route_config route_cfg; - struct msm_snddev_info *dev_info; - u64 session_mask = 0; - - session_id = ucontrol->value.integer.value[0]; - route_cfg.dev_id = ucontrol->value.integer.value[1]; - set = ucontrol->value.integer.value[2]; - - dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id); - if (IS_ERR(dev_info)) { - pr_err("pass invalid dev_id %d\n", route_cfg.dev_id); - return PTR_ERR(dev_info); - } - pr_debug("%s:Routing capture session %d to %s\n", __func__, - session_id, - dev_info->name); - if (!(dev_info->capability & SNDDEV_CAP_TX)) - return -EINVAL; - session_mask = - (((u64)0x1) << session_id) << (MAX_BIT_PER_CLIENT * \ - ((int)AUDDEV_CLNT_ENC-1)); - if (!set) { - session_route.capture_session[session_id][dev_info->copp_id] - = DEVICE_IGNORE; - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - dev_info->sessions &= ~(session_mask); - return 0; - } - - session_route.capture_session[session_id][dev_info->copp_id] = - dev_info->copp_id; - if (dev_info->opened) { - dev_info->sessions = dev_info->sessions | session_mask; - broadcast_event(AUDDEV_EVT_DEV_RDY, - route_cfg.dev_id, - session_mask); - } else { - broadcast_event(AUDDEV_EVT_DEV_RLS, - route_cfg.dev_id, - session_mask); - dev_info->sessions &= ~(session_mask); - } - return 0; -} - -static int msm_loopback_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 3; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_loopback_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 0; - return 0; -} - -static int msm_loopback_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int rc = 0; - struct msm_snddev_info *src_dev_info = NULL; /* TX device */ - struct msm_snddev_info *dst_dev_info = NULL; /* RX device */ - int dst_dev_id = ucontrol->value.integer.value[0]; - int src_dev_id = ucontrol->value.integer.value[1]; - int set = ucontrol->value.integer.value[2]; - - pr_debug("%s: dst=%d :src=%d set=%d\n", __func__, - dst_dev_id, src_dev_id, set); - - dst_dev_info = audio_dev_ctrl_find_dev(dst_dev_id); - if (IS_ERR(dst_dev_info)) { - pr_err("dst_dev:%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(dst_dev_info); - return rc; - } - if (!(dst_dev_info->capability & SNDDEV_CAP_RX)) { - pr_err("Destination device %d is not RX device\n", - dst_dev_id); - return -EFAULT; - } - - src_dev_info = audio_dev_ctrl_find_dev(src_dev_id); - if (IS_ERR(src_dev_info)) { - pr_err("src_dev:%s:pass invalid dev_id\n", __func__); - rc = PTR_ERR(src_dev_info); - return rc; - } - if (!(src_dev_info->capability & SNDDEV_CAP_TX)) { - pr_err("Source device %d is not TX device\n", src_dev_id); - return -EFAULT; - } - - if (set) { - pr_debug("%s:%d:Enabling AFE_Loopback\n", __func__, __LINE__); - src_dev = src_dev_id; - dst_dev = dst_dev_id; - loopback_status = 1; - if ((dst_dev_info->opened) && (src_dev_info->opened)) - rc = afe_loopback(LOOPBACK_ENABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - } else { - pr_debug("%s:%d:Disabling AFE_Loopback\n", __func__, __LINE__); - src_dev = DEVICE_IGNORE; - dst_dev = DEVICE_IGNORE; - loopback_status = 0; - rc = afe_loopback(LOOPBACK_DISABLE, - dst_dev_info->copp_id, - src_dev_info->copp_id); - } - return rc; -} -static int msm_device_mute_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = msm_snddev_devcount(); - return 0; -} - -static int msm_device_mute_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - return 0; -} - -static int msm_device_mute_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int dev_id = ucontrol->value.integer.value[0]; - int mute = ucontrol->value.integer.value[1]; - struct msm_snddev_info *dev_info; - int rc = 0; - u16 gain = 0x2000; - - dev_info = audio_dev_ctrl_find_dev(dev_id); - if (IS_ERR(dev_info)) { - rc = PTR_ERR(dev_info); - pr_err("%s: audio_dev_ctrl_find_dev failed. %ld\n", - __func__, PTR_ERR(dev_info)); - return rc; - } - if (!(dev_info->capability & SNDDEV_CAP_TX)) { - rc = -EINVAL; - return rc; - } - if (mute) - gain = 0; - - pr_debug("%s:dev_name = %s dev_id = %d, gain = %hX\n", - __func__, dev_info->name, dev_id, gain); - rc = afe_apply_gain(dev_info->copp_id, gain); - if (rc < 0) { - pr_err("%s : device %s not able to set device gain " - "control.", __func__, dev_info->name); - return rc; - } - pr_debug("Muting/Unmuting device id %d(%s)\n", dev_id, dev_info->name); - - return rc; -} - -static int msm_voc_session_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = SESSION_ID_BASE + MAX_VOC_SESSIONS; - return 0; -} - -static int msm_voice_session_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = - voice_get_session_id("Voice session"); - return 0; -} - -static int msm_voip_session_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = voice_get_session_id("VoIP session"); - return 0; -} - -static struct snd_kcontrol_new snd_dev_controls[AUDIO_DEV_CTL_MAX_DEV]; - -static int snd_dev_ctl_index(int idx) -{ - struct msm_snddev_info *dev_info; - - dev_info = audio_dev_ctrl_find_dev(idx); - if (IS_ERR(dev_info)) { - pr_err("%s:pass invalid dev_id\n", __func__); - return PTR_ERR(dev_info); - } - if (sizeof(dev_info->name) <= 44) - sprintf(&snddev_name[idx][0] , "%s", dev_info->name); - - snd_dev_controls[idx].iface = SNDRV_CTL_ELEM_IFACE_MIXER; - snd_dev_controls[idx].access = SNDRV_CTL_ELEM_ACCESS_READWRITE; - snd_dev_controls[idx].name = &snddev_name[idx][0]; - snd_dev_controls[idx].index = idx; - snd_dev_controls[idx].info = msm_device_info; - snd_dev_controls[idx].get = msm_device_get; - snd_dev_controls[idx].put = msm_device_put; - snd_dev_controls[idx].private_value = 0; - return 0; - -} - -#define MSM_EXT(xname, fp_info, fp_get, fp_put, addr) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .name = xname, \ - .info = fp_info,\ - .get = fp_get, .put = fp_put, \ - .private_value = addr, \ -} - -/* If new controls are to be added which would be constant across the - * different targets, please add to the structure - * snd_msm_controls. Please do not add any controls to the structure - * snd_msm_secondary_controls defined below unless they are msm8x60 - * specific. - */ - -static struct snd_kcontrol_new snd_msm_controls[] = { - MSM_EXT("Count", msm_scontrol_count_info, msm_scontrol_count_get, \ - NULL, 0), - MSM_EXT("Stream", msm_route_info, msm_route_get, \ - msm_route_put, 0), - MSM_EXT("Record", msm_route_info, msm_route_get, \ - msm_route_put, 0), - MSM_EXT("Voice", msm_voice_info, msm_voice_get, \ - msm_voice_put, 0), - MSM_EXT("Volume", msm_volume_info, msm_volume_get, \ - msm_volume_put, 0), - MSM_EXT("VoiceVolume", msm_v_volume_info, msm_v_volume_get, \ - msm_v_volume_put, 0), - MSM_EXT("VoiceMute", msm_v_mute_info, msm_v_mute_get, \ - msm_v_mute_put, 0), - MSM_EXT("Voice Call", msm_v_call_info, msm_v_call_get, \ - msm_v_call_put, 0), - MSM_EXT("Device_Volume", msm_device_volume_info, - msm_device_volume_get, msm_device_volume_put, 0), - MSM_EXT("Reset", msm_reset_info, - msm_reset_get, msm_reset_put, 0), - MSM_EXT("ANC", msm_anc_info, msm_anc_get, msm_anc_put, 0), - MSM_EXT("Device_Mute", msm_device_mute_info, - msm_device_mute_get, msm_device_mute_put, 0), -}; - -static struct snd_kcontrol_new snd_msm_secondary_controls[] = { - MSM_EXT("PCM Playback Sink", - pcm_route_info, pcm_route_get_rx, pcm_route_put_rx, 0), - MSM_EXT("PCM Capture Source", - pcm_route_info, pcm_route_get_tx, pcm_route_put_tx, 0), - MSM_EXT("Sound Device Loopback", msm_loopback_info, - msm_loopback_get, msm_loopback_put, 0), - MSM_EXT("VoiceVolume Ext", - msm_v_volume_info, msm_v_volume_get, msm_v_volume_put, 0), - MSM_EXT("VoiceMute Ext", - msm_v_mute_info, msm_v_mute_get, msm_v_mute_put, 0), - MSM_EXT("Voice Call Ext", - msm_v_call_info, msm_v_call_get, msm_v_call_put, 0), - MSM_EXT("Voice session", - msm_voc_session_info, msm_voice_session_get, NULL, 0), - MSM_EXT("VoIP session", - msm_voc_session_info, msm_voip_session_get, NULL, 0), -}; - -static int msm_new_mixer(struct snd_soc_codec *codec) -{ - unsigned int idx; - int err; - int dev_cnt; - - strcpy(codec->card->snd_card->mixername, "MSM Mixer"); - for (idx = 0; idx < ARRAY_SIZE(snd_msm_controls); idx++) { - err = snd_ctl_add(codec->card->snd_card, - snd_ctl_new1(&snd_msm_controls[idx], - NULL)); - if (err < 0) - pr_err("%s:ERR adding ctl\n", __func__); - } - - for (idx = 0; idx < ARRAY_SIZE(snd_msm_secondary_controls); idx++) { - err = snd_ctl_add(codec->card->snd_card, - snd_ctl_new1(&snd_msm_secondary_controls[idx], - NULL)); - if (err < 0) - pr_err("%s:ERR adding secondary ctl\n", __func__); - } - dev_cnt = msm_snddev_devcount(); - - for (idx = 0; idx < dev_cnt; idx++) { - if (!snd_dev_ctl_index(idx)) { - err = snd_ctl_add(codec->card->snd_card, - snd_ctl_new1(&snd_dev_controls[idx], - NULL)); - if (err < 0) - pr_err("%s:ERR adding ctl\n", __func__); - } else - return 0; - } - simple_control = ARRAY_SIZE(snd_msm_controls) - + ARRAY_SIZE(snd_msm_secondary_controls); - device_index = simple_control + 1; - return 0; -} - -static int msm_soc_dai_init( - struct snd_soc_pcm_runtime *rtd) -{ - - int ret = 0; - struct snd_soc_codec *codec = rtd->codec; - - init_waitqueue_head(&the_locks.enable_wait); - init_waitqueue_head(&the_locks.eos_wait); - init_waitqueue_head(&the_locks.write_wait); - init_waitqueue_head(&the_locks.read_wait); - memset(&session_route, DEVICE_IGNORE, sizeof(struct pcm_session)); - - ret = msm_new_mixer(codec); - if (ret < 0) - pr_err("%s: ALSA MSM Mixer Fail\n", __func__); - - return ret; -} - -static struct snd_soc_dai_link msm_dai[] = { -{ - .name = "MSM Primary I2S", - .stream_name = "DSP 1", - .cpu_dai_name = "msm-cpu-dai.0", - .platform_name = "msm-dsp-audio.0", - .codec_name = "msm-codec-dai.0", - .codec_dai_name = "msm-codec-dai", - .init = &msm_soc_dai_init, -}, -#ifdef CONFIG_MSM_8x60_VOIP -{ - .name = "MSM Primary Voip", - .stream_name = "MVS", - .cpu_dai_name = "mvs-cpu-dai.0", - .platform_name = "msm-mvs-audio.0", - .codec_name = "mvs-codec-dai.0", - .codec_dai_name = "mvs-codec-dai", -}, -#endif -}; - -static struct snd_soc_card snd_soc_card_msm = { - .name = "msm-audio", - .dai_link = msm_dai, - .num_links = ARRAY_SIZE(msm_dai), -}; - -static int __init msm_audio_init(void) -{ - int ret; - - msm_audio_snd_device = platform_device_alloc("soc-audio", -1); - if (!msm_audio_snd_device) - return -ENOMEM; - - platform_set_drvdata(msm_audio_snd_device, &snd_soc_card_msm); - ret = platform_device_add(msm_audio_snd_device); - if (ret) { - platform_device_put(msm_audio_snd_device); - return ret; - } - - src_dev = DEVICE_IGNORE; - dst_dev = DEVICE_IGNORE; - - return ret; -} - -static void __exit msm_audio_exit(void) -{ - platform_device_unregister(msm_audio_snd_device); -} - -module_init(msm_audio_init); -module_exit(msm_audio_exit); - -MODULE_DESCRIPTION("PCM module"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/msm_audio_mvs.h b/sound/soc/msm/msm_audio_mvs.h deleted file mode 100644 index 6ee457c154d458fb959ea3c4704b0c34e826fee9..0000000000000000000000000000000000000000 --- a/sound/soc/msm/msm_audio_mvs.h +++ /dev/null @@ -1,369 +0,0 @@ -/* Copyright (c) 2010-2011, 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 __MSM_AUDIO_MVS_H -#define __MSM_AUDIO_MVS_H -#include -#include -#include -#include -#include -#include - - -#define AUDIO_GET_MVS_CONFIG _IOW(AUDIO_IOCTL_MAGIC, \ - (AUDIO_MAX_COMMON_IOCTL_NUM + 0), unsigned) -#define AUDIO_SET_MVS_CONFIG _IOR(AUDIO_IOCTL_MAGIC, \ - (AUDIO_MAX_COMMON_IOCTL_NUM + 1), unsigned) -#define AUDIO_SET_SCR_CONFIG _IOR(AUDIO_IOCTL_MAGIC, \ - (AUDIO_MAX_COMMON_IOCTL_NUM + 2), unsigned) -#define AUDIO_SET_DTX_CONFIG _IOR(AUDIO_IOCTL_MAGIC, \ - (AUDIO_MAX_COMMON_IOCTL_NUM + 3), unsigned) -/* MVS modes */ -#define MVS_MODE_LINEAR_PCM 9 - -#define MVS_PROG 0x30000014 -#define MVS_VERS 0x00030001 - -#define MVS_CLIENT_ID_VOIP 0x00000003 /* MVS_CLIENT_VOIP */ - -#define MVS_ACQUIRE_PROC 4 -#define MVS_ENABLE_PROC 5 -#define MVS_RELEASE_PROC 6 -#define MVS_SET_PCM_MODE_PROC 9 - -#define MVS_EVENT_CB_TYPE_PROC 1 -#define MVS_PACKET_UL_FN_TYPE_PROC 2 -#define MVS_PACKET_DL_FN_TYPE_PROC 3 - -#define MVS_CB_FUNC_ID 0xAAAABBBB -#define MVS_UL_CB_FUNC_ID 0xBBBBCCCC -#define MVS_DL_CB_FUNC_ID 0xCCCCDDDD - -/* MVS frame modes */ - -#define MVS_FRAME_MODE_PCM_UL 13 -#define MVS_FRAME_MODE_PCM_DL 14 - -/* MVS context */ -#define MVS_PKT_CONTEXT_ISR 0x00000001 - -/* Max voc packet size */ -#define MVS_MAX_VOC_PKT_SIZE 320 - -#define VOIP_MAX_Q_LEN 20 -#define MVS_MAX_Q_LEN 8 -#define RPC_TYPE_REQUEST 0 -#define RPC_TYPE_REPLY 1 - -#define RPC_STATUS_FAILURE 0 -#define RPC_STATUS_SUCCESS 1 -#define RPC_STATUS_REJECT 1 - - -#define RPC_COMMON_HDR_SZ (sizeof(uint32_t) * 2) -#define RPC_REQUEST_HDR_SZ (sizeof(struct rpc_request_hdr)) -#define RPC_REPLY_HDR_SZ (sizeof(uint32_t) * 3) - - -enum audio_mvs_state_type { AUDIO_MVS_CLOSED, AUDIO_MVS_OPENED, - AUDIO_MVS_PREPARING, AUDIO_MVS_ACQUIRE, AUDIO_MVS_ENABLED, - AUDIO_MVS_CLOSING -}; - -enum audio_mvs_event_type { AUDIO_MVS_COMMAND, AUDIO_MVS_MODE, - AUDIO_MVS_NOTIFY -}; - -enum audio_mvs_cmd_status_type { AUDIO_MVS_CMD_FAILURE, AUDIO_MVS_CMD_BUSY, - AUDIO_MVS_CMD_SUCCESS -}; - -enum audio_mvs_mode_status_type { AUDIO_MVS_MODE_NOT_AVAIL, - AUDIO_MVS_MODE_INIT, AUDIO_MVS_MODE_READY -}; - -enum audio_mvs_pkt_status_type { AUDIO_MVS_PKT_NORMAL, AUDIO_MVS_PKT_FAST, - AUDIO_MVS_PKT_SLOW -}; - -struct rpc_audio_mvs_acquire_args { - uint32_t client_id; - uint32_t cb_func_id; -}; - -struct audio_mvs_acquire_msg { - struct rpc_request_hdr rpc_hdr; - struct rpc_audio_mvs_acquire_args acquire_args; -}; - -struct rpc_audio_mvs_enable_args { - uint32_t client_id; - uint32_t mode; - uint32_t ul_cb_func_id; - uint32_t dl_cb_func_id; - uint32_t context; -}; - -struct audio_mvs_enable_msg { - struct rpc_request_hdr rpc_hdr; - struct rpc_audio_mvs_enable_args enable_args; -}; - -struct audio_mvs_release_msg { - struct rpc_request_hdr rpc_hdr; - uint32_t client_id; -}; - -struct audio_mvs_set_pcm_mode_msg { - struct rpc_request_hdr rpc_hdr; - uint32_t pcm_mode; -}; - -struct audio_mvs_set_pcmwb_mode_msg { - struct rpc_request_hdr rpc_hdr; - uint32_t pcmwb_mode; -}; - -struct audio_mvs_buffer { - uint8_t *voc_pkt; - uint32_t len; -}; - -union audio_mvs_event_data { - struct mvs_ev_command_type { - uint32_t event; - uint32_t client_id; - uint32_t cmd_status; - } mvs_ev_command_type; - - struct mvs_ev_mode_type { - uint32_t event; - uint32_t client_id; - uint32_t mode_status; - uint32_t mode; - } mvs_ev_mode_type; - - struct mvs_ev_notify_type { - uint32_t event; - uint32_t client_id; - uint32_t buf_dir; - uint32_t max_frames; - } mvs_ev_notify_type; -}; - -struct audio_mvs_cb_func_args { - uint32_t cb_func_id; - uint32_t valid_ptr; - uint32_t event; - union audio_mvs_event_data event_data; -}; - -struct audio_mvs_frame_info_hdr { - uint32_t frame_mode; - uint32_t mvs_mode; - uint32_t buf_free_cnt; -}; - -struct audio_mvs_ul_cb_func_args { - uint32_t cb_func_id; - uint32_t pkt_len; - uint32_t voc_pkt[MVS_MAX_VOC_PKT_SIZE / 4]; - - uint32_t valid_ptr; - - uint32_t frame_mode; - uint32_t frame_mode_ignore; - - struct audio_mvs_frame_info_hdr frame_info_hdr; - - uint32_t pcm_frame; - uint32_t pcm_mode; - - uint32_t pkt_len_ignore; -}; - -struct audio_mvs_ul_reply { - struct rpc_reply_hdr reply_hdr; - uint32_t valid_pkt_status_ptr; - uint32_t pkt_status; -}; - -struct audio_mvs_dl_cb_func_args { - uint32_t cb_func_id; - uint32_t valid_ptr; - - uint32_t frame_mode; - uint32_t frame_mode_ignore; - - struct audio_mvs_frame_info_hdr frame_info_hdr; - - uint32_t pcm_frame; - uint32_t pcm_mode; - -}; - -struct audio_mvs_dl_reply { - struct rpc_reply_hdr reply_hdr; - uint32_t voc_pkt[MVS_MAX_VOC_PKT_SIZE / 4]; - uint32_t valid_frame_info_ptr; - - uint32_t frame_mode; - uint32_t frame_mode_again; - - struct audio_mvs_frame_info_hdr frame_info_hdr; - - uint32_t pcm_frame; - uint32_t pcm_mode; - - uint32_t valid_pkt_status_ptr; - uint32_t pkt_status; -}; - -struct audio_mvs_info_type { - enum audio_mvs_state_type state; - uint32_t frame_mode; - uint32_t mvs_mode; - uint32_t buf_free_cnt; - uint32_t pcm_frame; - uint32_t pcm_mode; - uint32_t out_sample_rate; - uint32_t out_channel_mode; - uint32_t out_weight; - uint32_t out_buffer_size; - int dl_play; - struct msm_rpc_endpoint *rpc_endpt; - uint32_t rpc_prog; - uint32_t rpc_ver; - uint32_t rpc_status; - - unsigned int pcm_size; - unsigned int pcm_count; - unsigned int pcm_playback_irq_pos; /* IRQ position */ - unsigned int pcm_playback_buf_pos; /* position in buffer */ - - unsigned int pcm_capture_size; - unsigned int pcm_capture_count; - unsigned int pcm_capture_irq_pos; /* IRQ position */ - unsigned int pcm_capture_buf_pos; /* position in buffer */ - - uint32_t samp_rate; - uint32_t channel_mode; - - uint8_t *mem_chunk; - struct snd_pcm_substream *playback_substream; - struct snd_pcm_substream *capture_substream; - - struct audio_mvs_buffer in[MVS_MAX_Q_LEN]; - uint32_t in_read; - uint32_t in_write; - - struct audio_mvs_buffer out[MVS_MAX_Q_LEN]; - uint32_t out_read; - uint32_t out_write; - - struct task_struct *task; - - wait_queue_head_t wait; - wait_queue_head_t prepare_wait; - wait_queue_head_t out_wait; - wait_queue_head_t in_wait; - - - struct mutex lock; - struct mutex prepare_lock; - struct mutex in_lock; - struct mutex out_lock; - - struct wake_lock suspend_lock; - struct pm_qos_request pm_qos_req; - struct timer_list timer; - unsigned long expiry; - int ack_dl_count; - int ack_ul_count; - int prepare_ack; - int playback_start; - int capture_start; - unsigned long expiry_delta; - int mvs_enable; - int playback_enable; - int capture_enable; - int instance; - -}; - -struct audio_voip_info_type { - enum audio_mvs_state_type state; - enum audio_mvs_state_type playback_state; - enum audio_mvs_state_type capture_state; - - unsigned int pcm_playback_size; - unsigned int pcm_count; - unsigned int pcm_playback_irq_pos; /* IRQ position */ - unsigned int pcm_playback_buf_pos; /* position in buffer */ - - unsigned int pcm_capture_size; - unsigned int pcm_capture_count; - unsigned int pcm_capture_irq_pos; /* IRQ position */ - unsigned int pcm_capture_buf_pos; /* position in buffer */ - - struct snd_pcm_substream *playback_substream; - struct snd_pcm_substream *capture_substream; - - struct audio_mvs_buffer in[VOIP_MAX_Q_LEN]; - uint32_t in_read; - uint32_t in_write; - - struct audio_mvs_buffer out[VOIP_MAX_Q_LEN]; - uint32_t out_read; - uint32_t out_write; - - wait_queue_head_t out_wait; - wait_queue_head_t in_wait; - - struct mutex lock; - struct mutex prepare_lock; - - struct wake_lock suspend_lock; - struct pm_qos_request pm_qos_req; - int playback_start; - int capture_start; - int instance; -}; - -enum msm_audio_pcm_frame_type { - MVS_AMR_SPEECH_GOOD, /* Good speech frame */ - MVS_AMR_SPEECH_DEGRADED, /* Speech degraded */ - MVS_AMR_ONSET, /* onset */ - MVS_AMR_SPEECH_BAD, /* Corrupt speech frame (bad CRC) */ - MVS_AMR_SID_FIRST, /* First silence descriptor */ - MVS_AMR_SID_UPDATE, /* Comfort noise frame */ - MVS_AMR_SID_BAD, /* Corrupt SID frame (bad CRC) */ - MVS_AMR_NO_DATA, /* Nothing to transmit */ - MVS_AMR_SPEECH_LOST, /* downlink speech lost */ -}; - -enum msm_audio_dtx_mode_type { MVS_DTX_OFF, MVS_DTX_ON -}; - -struct msm_audio_mvs_config { - uint32_t mvs_mode; - uint32_t bit_rate; -}; - -extern struct snd_soc_dai_driver msm_mvs_dais[2]; -extern struct snd_soc_codec_device soc_codec_dev_msm_mvs; -extern struct snd_soc_platform_driver msm_mvs_soc_platform; -extern struct snd_soc_platform_driver msm_voip_soc_platform; -#endif /* __MSM_AUDIO_MVS_H */ diff --git a/sound/soc/msm/mvs-dai.c b/sound/soc/msm/mvs-dai.c deleted file mode 100644 index bbe390a634ec4286591cac22d3ae016cdd4625e5..0000000000000000000000000000000000000000 --- a/sound/soc/msm/mvs-dai.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (c) 2010, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program; if not, you can find it at http://www.fsf.org. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "msm_audio_mvs.h" - -static struct snd_soc_dai_driver msm_mvs_codec_dais[] = { -{ - .name = "mvs-codec-dai", - .playback = { - .channels_max = 2, - .rates = (SNDRV_PCM_RATE_8000), - .rate_min = 8000, - .rate_max = 8000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .capture = { - .channels_max = 2, - .rates = (SNDRV_PCM_RATE_8000), - .rate_min = 8000, - .rate_max = 8000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, -}, -}; -static struct snd_soc_dai_driver msm_mvs_cpu_dais[] = { -{ - .name = "mvs-cpu-dai", - .playback = { - .channels_max = 2, - .rates = (SNDRV_PCM_RATE_8000), - .rate_min = 8000, - .rate_max = 8000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .capture = { - .channels_max = 2, - .rates = (SNDRV_PCM_RATE_8000), - .rate_min = 8000, - .rate_max = 8000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, -}, -}; - -static struct snd_soc_codec_driver soc_codec_dev_msm = { - .compress_type = SND_SOC_FLAT_COMPRESSION, -}; - -static int asoc_mvs_codec_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_msm, - msm_mvs_codec_dais, ARRAY_SIZE(msm_mvs_codec_dais)); -} - -static int asoc_mvs_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static int asoc_mvs_cpu_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s: dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_dai(&pdev->dev, msm_mvs_cpu_dais); -} - -static int asoc_mvs_cpu_remove(struct platform_device *pdev) -{ - snd_soc_unregister_dai(&pdev->dev); - return 0; -} - -static struct platform_driver asoc_mvs_codec_driver = { - .probe = asoc_mvs_codec_probe, - .remove = asoc_mvs_codec_remove, - .driver = { - .name = "mvs-codec-dai", - .owner = THIS_MODULE, - }, -}; - -static struct platform_driver asoc_mvs_cpu_driver = { - .probe = asoc_mvs_cpu_probe, - .remove = asoc_mvs_cpu_remove, - .driver = { - .name = "mvs-cpu-dai", - .owner = THIS_MODULE, - }, -}; - -static int __init mvs_codec_dai_init(void) -{ - return platform_driver_register(&asoc_mvs_codec_driver); -} - -static void __exit mvs_codec_dai_exit(void) -{ - platform_driver_unregister(&asoc_mvs_codec_driver); -} - -static int __init mvs_cpu_dai_init(void) -{ - return platform_driver_register(&asoc_mvs_cpu_driver); -} - -static void __exit mvs_cpu_dai_exit(void) -{ - platform_driver_unregister(&asoc_mvs_cpu_driver); -} - -module_init(mvs_codec_dai_init); -module_exit(mvs_codec_dai_exit); -module_init(mvs_cpu_dai_init); -module_exit(mvs_cpu_dai_exit); - -/* Module information */ -MODULE_DESCRIPTION("MSM Codec/Cpu Dai driver"); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/msm/qdsp6/Makefile b/sound/soc/msm/qdsp6/Makefile deleted file mode 100644 index f45bd3362b93b5d602e26a6c245ef4722333513b..0000000000000000000000000000000000000000 --- a/sound/soc/msm/qdsp6/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -obj-y := q6asm.o q6adm.o q6afe.o -obj-$(CONFIG_SND_SOC_VOICE) += q6voice.o \ No newline at end of file diff --git a/sound/soc/msm/qdsp6/q6adm.c b/sound/soc/msm/qdsp6/q6adm.c deleted file mode 100644 index 00d8addfab52284f4e49e580bb623a81502586b3..0000000000000000000000000000000000000000 --- a/sound/soc/msm/qdsp6/q6adm.c +++ /dev/null @@ -1,1678 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#define TIMEOUT_MS 1000 -#define AUDIO_RX 0x0 -#define AUDIO_TX 0x1 - -#define ASM_MAX_SESSION 0x8 /* To do: define in a header */ -#define RESET_COPP_ID 99 -#define INVALID_COPP_ID 0xFF - -struct adm_ctl { - void *apr; - atomic_t copp_id[AFE_MAX_PORTS]; - atomic_t copp_cnt[AFE_MAX_PORTS]; - atomic_t copp_stat[AFE_MAX_PORTS]; - wait_queue_head_t wait; - int ec_ref_rx; - int prev_index; -}; - -static struct acdb_cal_block mem_addr_audproc[MAX_AUDPROC_TYPES]; -static struct acdb_cal_block mem_addr_audvol[MAX_AUDPROC_TYPES]; - -static struct adm_ctl this_adm; -static int pseudo_copp[2]; - -int srs_trumedia_open(int port_id, int srs_tech_id, void *srs_params) -{ - struct asm_pp_params_command *open = NULL; - int ret = 0, sz = 0; - int index; - - pr_debug("SRS - %s", __func__); - - index = afe_get_port_index(port_id); - - if (IS_ERR_VALUE(index)) { - pr_err("%s: invald port id\n", __func__); - return index; - } - - switch (srs_tech_id) { - case SRS_ID_GLOBAL: { - struct srs_trumedia_params_GLOBAL *glb_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_trumedia_params_GLOBAL); - open = kzalloc(sz, GFP_KERNEL); - open->payload_size = sizeof(struct srs_trumedia_params_GLOBAL) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_TRUMEDIA_PARAMS; - open->params.param_size = - sizeof(struct srs_trumedia_params_GLOBAL); - glb_params = (struct srs_trumedia_params_GLOBAL *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(glb_params, srs_params, - sizeof(struct srs_trumedia_params_GLOBAL)); - pr_debug("SRS - %s: Global params - 1 = %x, 2 = %x, 3 = %x," - " 4 = %x, 5 = %x, 6 = %x, 7 = %x, 8 = %x\n", - __func__, (int)glb_params->v1, - (int)glb_params->v2, (int)glb_params->v3, - (int)glb_params->v4, (int)glb_params->v5, - (int)glb_params->v6, (int)glb_params->v7, - (int)glb_params->v8); - break; - } - case SRS_ID_WOWHD: { - struct srs_trumedia_params_WOWHD *whd_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_trumedia_params_WOWHD); - open = kzalloc(sz, GFP_KERNEL); - open->payload_size = sizeof(struct srs_trumedia_params_WOWHD) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_TRUMEDIA_PARAMS_WOWHD; - open->params.param_size = - sizeof(struct srs_trumedia_params_WOWHD); - whd_params = (struct srs_trumedia_params_WOWHD *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(whd_params, srs_params, - sizeof(struct srs_trumedia_params_WOWHD)); - pr_debug("SRS - %s: WOWHD params - 1 = %x, 2 = %x, 3 = %x," - " 4 = %x, 5 = %x, 6 = %x, 7 = %x, 8 = %x, 9 = %x," - " 10 = %x, 11 = %x\n", __func__, (int)whd_params->v1, - (int)whd_params->v2, (int)whd_params->v3, - (int)whd_params->v4, (int)whd_params->v5, - (int)whd_params->v6, (int)whd_params->v7, - (int)whd_params->v8, (int)whd_params->v9, - (int)whd_params->v10, (int)whd_params->v11); - break; - } - case SRS_ID_CSHP: { - struct srs_trumedia_params_CSHP *chp_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_trumedia_params_CSHP); - open = kzalloc(sz, GFP_KERNEL); - open->payload_size = sizeof(struct srs_trumedia_params_CSHP) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_TRUMEDIA_PARAMS_CSHP; - open->params.param_size = - sizeof(struct srs_trumedia_params_CSHP); - chp_params = (struct srs_trumedia_params_CSHP *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(chp_params, srs_params, - sizeof(struct srs_trumedia_params_CSHP)); - pr_debug("SRS - %s: CSHP params - 1 = %x, 2 = %x, 3 = %x," - " 4 = %x, 5 = %x, 6 = %x, 7 = %x, 8 = %x," - " 9 = %x\n", __func__, (int)chp_params->v1, - (int)chp_params->v2, (int)chp_params->v3, - (int)chp_params->v4, (int)chp_params->v5, - (int)chp_params->v6, (int)chp_params->v7, - (int)chp_params->v8, (int)chp_params->v9); - break; - } - case SRS_ID_HPF: { - struct srs_trumedia_params_HPF *hpf_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_trumedia_params_HPF); - open = kzalloc(sz, GFP_KERNEL); - open->payload_size = sizeof(struct srs_trumedia_params_HPF) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_TRUMEDIA_PARAMS_HPF; - open->params.param_size = - sizeof(struct srs_trumedia_params_HPF); - hpf_params = (struct srs_trumedia_params_HPF *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(hpf_params, srs_params, - sizeof(struct srs_trumedia_params_HPF)); - pr_debug("SRS - %s: HPF params - 1 = %x\n", __func__, - (int)hpf_params->v1); - break; - } - case SRS_ID_PEQ: { - struct srs_trumedia_params_PEQ *peq_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_trumedia_params_PEQ); - open = kzalloc(sz, GFP_KERNEL); - open->payload_size = sizeof(struct srs_trumedia_params_PEQ) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_TRUMEDIA_PARAMS_PEQ; - open->params.param_size = - sizeof(struct srs_trumedia_params_PEQ); - peq_params = (struct srs_trumedia_params_PEQ *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(peq_params, srs_params, - sizeof(struct srs_trumedia_params_PEQ)); - pr_debug("SRS - %s: PEQ params - 1 = %x 2 = %x, 3 = %x," - " 4 = %x\n", __func__, (int)peq_params->v1, - (int)peq_params->v2, (int)peq_params->v3, - (int)peq_params->v4); - break; - } - case SRS_ID_HL: { - struct srs_trumedia_params_HL *hl_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_trumedia_params_HL); - open = kzalloc(sz, GFP_KERNEL); - open->payload_size = sizeof(struct srs_trumedia_params_HL) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_TRUMEDIA_PARAMS_HL; - open->params.param_size = sizeof(struct srs_trumedia_params_HL); - hl_params = (struct srs_trumedia_params_HL *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(hl_params, srs_params, - sizeof(struct srs_trumedia_params_HL)); - pr_debug("SRS - %s: HL params - 1 = %x, 2 = %x, 3 = %x, 4 = %x," - " 5 = %x, 6 = %x, 7 = %x\n", __func__, - (int)hl_params->v1, (int)hl_params->v2, - (int)hl_params->v3, (int)hl_params->v4, - (int)hl_params->v5, (int)hl_params->v6, - (int)hl_params->v7); - break; - } - default: - goto fail_cmd; - } - - open->payload = NULL; - open->params.module_id = SRS_TRUMEDIA_MODULE_ID; - open->params.reserved = 0; - open->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - open->hdr.pkt_size = sz; - open->hdr.src_svc = APR_SVC_ADM; - open->hdr.src_domain = APR_DOMAIN_APPS; - open->hdr.src_port = port_id; - open->hdr.dest_svc = APR_SVC_ADM; - open->hdr.dest_domain = APR_DOMAIN_ADSP; - open->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); - open->hdr.token = port_id; - open->hdr.opcode = ADM_CMD_SET_PARAMS; - pr_debug("SRS - %s: Command was sent now check Q6 - port id = %d," - " size %d, module id %x, param id %x.\n", __func__, - open->hdr.dest_port, open->payload_size, - open->params.module_id, open->params.param_id); - - ret = apr_send_pkt(this_adm.apr, (uint32_t *)open); - if (ret < 0) { - pr_err("SRS - %s: ADM enable for port %d failed\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - /* Wait for the callback with copp id */ - ret = wait_event_timeout(this_adm.wait, 1, - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("SRS - %s: ADM open failed for port %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - -fail_cmd: - kfree(open); - return ret; -} - -struct SS3D { - int _1; int _2; short _3; short _4; - short _5; short _6; int _7; int _X[32]; - short _8; short _9; short _10; short _11; - short _12; short _13; short _14; short _15; - short _16; short _17; short _18; short _19; - short _20; short _21; short _22; short _23; - short _24; short _25; short _26[5]; - short _27; short _28; short _29; short _30; - short _31; short _32; short _33; int _34; int _35; - int _36; int _37; int _38; int _39; int _40; -}; - -struct SS3D_F { - int _1; int _2; int _3; int _4; int _5; int _6; int _7; int _X[]; -}; - -int srs_ss3d_open(int port_id, int srs_tech_id, void *srs_params) -{ - struct asm_pp_params_command *open = NULL; - int ret = 0, sz = 0; - - int index; - - pr_debug("SRS - %s: called.", __func__); - - switch (srs_tech_id) { - case SRS_ID_SS3D_GLOBAL: { - struct srs_SS3D_params_GLOBAL *glb_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_SS3D_params_GLOBAL); - open = kzalloc(sz, GFP_KERNEL); - - open->payload_size = sizeof(struct srs_SS3D_params_GLOBAL) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_SS3D_PARAMS; - open->params.param_size = - sizeof(struct srs_SS3D_params_GLOBAL); - - glb_params = (struct srs_SS3D_params_GLOBAL *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(glb_params, srs_params, - sizeof(struct srs_SS3D_params_GLOBAL)); - - pr_debug("SRS - ss3d global params - 1 = %x, 2 = %x, 3 = %x\n" - " 4 = %x, 5 = %x, 6 = %x, 7 = %x, 8 = %x\n", - (int)glb_params->v1, (int)glb_params->v2, - (int)glb_params->v3, (int)glb_params->v4, - (int)glb_params->v5, (int)glb_params->v6, - (int)glb_params->v7, (int)glb_params->v8); - break; - } - case SRS_ID_SS3D_CTRL: { - struct srs_SS3D_ctrl_params *whd_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_SS3D_ctrl_params); - open = kzalloc(sz, GFP_KERNEL); - - open->payload_size = sizeof(struct srs_SS3D_ctrl_params) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_SS3D_PARAMS_CTRL; - open->params.param_size = sizeof(struct srs_SS3D_ctrl_params); - - whd_params = (struct srs_SS3D_ctrl_params *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(whd_params, srs_params, - sizeof(struct srs_SS3D_ctrl_params)); - - { - struct SS3D *D = (struct SS3D *)whd_params->v; - pr_debug("SRS - ss3d ctrl params\n" - "1 = 0x%08X, 2 = 0x%08X, 3 = 0x%04X,\n" - "4 = 0x%04X, 5 = 0x%04X, 6 = 0x%04X,\n" - "7 = 0x%08X, 8 = 0x%04X, 9 = 0x%04X,\n" - "10 = 0x%04X, 11 = 0x%04X, 12 = 0x%04X,\n" - "13 = 0x%04X, 14 = 0x%04X, 15 = 0x%04X,\n" - "16 = 0x%04X, 17 = 0x%04X, 18 = 0x%04X,\n" - "19 = 0x%04X, 20 = 0x%04X, 21 = 0x%04X,\n" - "22 = 0x%04X, 23 = 0x%04X, 24 = 0x%04X,\n" - "25 = 0x%04X, 26.0 = 0x%04X, 26.1 = 0x%04X,\n" - "26.2 = 0x%04X, 26.3 = 0x%04X,\n" - "26.4 = 0x%04X, 27 = 0x%04X, 28 = 0x%04X,\n" - "29 = 0x%04X, 30 = 0x%04X, 31 = 0x%04X,\n" - "32 = 0x%04X, 33 = 0x%04X, 34 = 0x%08X,\n" - "35 = 0x%08X, 36 = 0x%08X, 37 = 0x%08X,\n" - "38 = 0x%08X, 39 = 0x%08X, 40 = 0x%08X", - D->_1, D->_2, D->_3, D->_4, D->_5, D->_6, D->_7, - D->_8, D->_9, D->_10, D->_11, D->_12, D->_13, - D->_14, D->_15, D->_16, D->_17, D->_18, D->_19, - D->_20, D->_21, D->_22, D->_23, D->_24, D->_25, - D->_26[0], D->_26[1], D->_26[2], D->_26[3], - D->_26[4], D->_27, D->_28, D->_29, D->_30, - D->_31, D->_32, D->_33, D->_34, D->_35, D->_36, - D->_37, D->_38, D->_39, D->_40); - } - break; - } - case SRS_ID_SS3D_FILTER: { - struct srs_SS3D_filter_params *chp_params = NULL; - sz = sizeof(struct asm_pp_params_command) + - sizeof(struct srs_SS3D_filter_params); - open = kzalloc(sz, GFP_KERNEL); - - open->payload_size = sizeof(struct srs_SS3D_filter_params) + - sizeof(struct asm_pp_param_data_hdr); - open->params.param_id = SRS_SS3D_PARAMS_FILTER; - open->params.param_size = - sizeof(struct srs_SS3D_filter_params); - - chp_params = (struct srs_SS3D_filter_params *)((u8 *)open + - sizeof(struct asm_pp_params_command)); - memcpy(chp_params, srs_params, - sizeof(struct srs_SS3D_filter_params)); - - { - struct SS3D_F *D = (struct SS3D_F *)chp_params->v; - pr_debug("SRS - ss3d filter params\n" - "1 = 0x%08X, 2 = 0x%08X, 3 = 0x%08X\n" - "4 = 0x%08X, 5 = 0x%08X, 6 = 0x%08X\n" - "7 = 0x%08X", D->_1, D->_2, D->_3, D->_4, D->_5, - D->_6, D->_7); - } - break; - } - default: - pr_debug("SRS - bad param!\n"); - goto fail_cmd; - } - - open->payload = NULL; - - open->params.module_id = SRS_SS3D_MODULE_ID; - open->params.reserved = 0; - - open->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - open->hdr.pkt_size = sz; - open->hdr.src_svc = APR_SVC_ADM; - open->hdr.src_domain = APR_DOMAIN_APPS; - open->hdr.src_port = port_id; - open->hdr.dest_svc = APR_SVC_ADM; - open->hdr.dest_domain = APR_DOMAIN_ADSP; - - index = afe_get_port_index(port_id); - open->hdr.dest_port = atomic_read(&this_adm.copp_id[index]); - /* port_id;//atomic_read(&this_adm.copp_id[port_id]); */ - open->hdr.token = port_id; - open->hdr.opcode = ADM_CMD_SET_PARAMS; - - pr_debug("SRS - %s: Command was sent now check Q6 - port id = %d,\n" - "size %d, module id %x, param id %x.\n", - __func__, open->hdr.dest_port, open->payload_size, - open->params.module_id, open->params.param_id); - - ret = apr_send_pkt(this_adm.apr, (uint32_t *)open); - if (ret < 0) { - pr_err("SRS - %s: ADM enable for port %d failed\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - /* Wait for the callback with copp id */ - ret = wait_event_timeout(this_adm.wait, 1, - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("SRS - %s: ADM open failed for port %d\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - -fail_cmd: - kfree(open); - return ret; -} - -static int32_t adm_callback(struct apr_client_data *data, void *priv) -{ - uint32_t *payload; - int i, index; - payload = data->payload; - - if (data->opcode == RESET_EVENTS) { - pr_debug("adm_callback: Reset event is received: %d %d apr[%p]\n", - data->reset_event, data->reset_proc, - this_adm.apr); - if (this_adm.apr) { - apr_reset(this_adm.apr); - for (i = 0; i < AFE_MAX_PORTS; i++) { - atomic_set(&this_adm.copp_id[i], - RESET_COPP_ID); - atomic_set(&this_adm.copp_cnt[i], 0); - atomic_set(&this_adm.copp_stat[i], 0); - } - this_adm.apr = NULL; - } - pr_debug("Resetting calibration blocks"); - for (i = 0; i < MAX_AUDPROC_TYPES; i++) { - /* Device calibration */ - mem_addr_audproc[i].cal_size = 0; - mem_addr_audproc[i].cal_kvaddr = 0; - mem_addr_audproc[i].cal_paddr = 0; - - /* Volume calibration */ - mem_addr_audvol[i].cal_size = 0; - mem_addr_audvol[i].cal_kvaddr = 0; - mem_addr_audvol[i].cal_paddr = 0; - } - return 0; - } - - pr_debug("%s: code = 0x%x %x %x size = %d\n", __func__, - data->opcode, payload[0], payload[1], - data->payload_size); - - if (data->payload_size) { - index = afe_get_port_index(data->token); - pr_debug("%s: Port ID %d, index %d\n", __func__, - data->token, index); - if (index < 0 || index >= AFE_MAX_PORTS) { - pr_err("%s: invalid port idx %d token %d\n", - __func__, index, data->token); - return 0; - } - if (data->opcode == APR_BASIC_RSP_RESULT) { - pr_debug("APR_BASIC_RSP_RESULT id %x\n", payload[0]); - switch (payload[0]) { - case ADM_CMD_SET_PARAMS: - if (rtac_make_adm_callback(payload, - data->payload_size)) - break; - case ADM_CMD_COPP_CLOSE: - case ADM_CMD_MEMORY_MAP: - case ADM_CMD_MEMORY_UNMAP: - case ADM_CMD_MEMORY_MAP_REGIONS: - case ADM_CMD_MEMORY_UNMAP_REGIONS: - case ADM_CMD_MATRIX_MAP_ROUTINGS: - case ADM_CMD_CONNECT_AFE_PORT: - case ADM_CMD_DISCONNECT_AFE_PORT: - case ADM_CMD_CONNECT_AFE_PORT_V2: - case ADM_CMD_MULTI_CHANNEL_COPP_OPEN_V3: - atomic_set(&this_adm.copp_stat[index], 1); - wake_up(&this_adm.wait); - break; - default: - pr_err("%s: Unknown Cmd: 0x%x\n", __func__, - payload[0]); - break; - } - return 0; - } - - switch (data->opcode) { - - case ADM_CMDRSP_MULTI_CHANNEL_COPP_OPEN_V3: - case ADM_CMDRSP_COPP_OPEN: - case ADM_CMDRSP_MULTI_CHANNEL_COPP_OPEN: { - struct adm_copp_open_respond *open = data->payload; - if (open->copp_id == INVALID_COPP_ID) { - pr_err("%s: invalid coppid rxed %d\n", - __func__, open->copp_id); - atomic_set(&this_adm.copp_stat[index], 1); - wake_up(&this_adm.wait); - break; - } - if (index == IDX_PSEUDOPORT_01) - pseudo_copp[ - atomic_read(&this_adm.copp_cnt[index])] = - open->copp_id; - atomic_set(&this_adm.copp_id[index], open->copp_id); - atomic_set(&this_adm.copp_stat[index], 1); - pr_debug("%s: coppid rxed=%d\n", __func__, - open->copp_id); - wake_up(&this_adm.wait); - } - break; - case ADM_CMDRSP_GET_PARAMS: - pr_debug("%s: ADM_CMDRSP_GET_PARAMS\n", __func__); - rtac_make_adm_callback(payload, - data->payload_size); - break; - default: - pr_err("%s: Unknown cmd:0x%x\n", __func__, - data->opcode); - break; - } - } - return 0; -} - -int adm_connect_afe_port_v2(int mode, int session_id, int port_id, - int sample_rate, int channels) -{ - struct adm_cmd_connect_afe_port_v2 cmd; - int ret = 0; - int index; - - pr_debug("%s: port %d session id:%d\n", __func__, - port_id, session_id); - - port_id = afe_convert_virtual_to_portid(port_id); - - if (afe_validate_port(port_id) < 0) { - pr_err("%s port idi[%d] is invalid\n", __func__, port_id); - return -ENODEV; - } - if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); - if (this_adm.apr == NULL) { - pr_err("%s: Unable to register ADM\n", __func__); - ret = -ENODEV; - return ret; - } - rtac_set_adm_handle(this_adm.apr); - } - index = afe_get_port_index(port_id); - pr_debug("%s: Port ID %d, index %d\n", __func__, port_id, index); - - cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cmd.hdr.pkt_size = sizeof(cmd); - cmd.hdr.src_svc = APR_SVC_ADM; - cmd.hdr.src_domain = APR_DOMAIN_APPS; - cmd.hdr.src_port = port_id; - cmd.hdr.dest_svc = APR_SVC_ADM; - cmd.hdr.dest_domain = APR_DOMAIN_ADSP; - cmd.hdr.dest_port = port_id; - cmd.hdr.token = port_id; - cmd.hdr.opcode = ADM_CMD_CONNECT_AFE_PORT_V2; - - cmd.mode = mode; - cmd.session_id = session_id; - cmd.afe_port_id = port_id; - cmd.num_channels = channels; - cmd.sampling_rate = sample_rate; - - atomic_set(&this_adm.copp_stat[index], 0); - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&cmd); - if (ret < 0) { - pr_err("%s:ADM enable for port %d failed\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s ADM connect AFE failed for port %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - atomic_inc(&this_adm.copp_cnt[index]); - return 0; - -fail_cmd: - - return ret; - -} - -static int send_adm_cal_block(int port_id, struct acdb_cal_block *aud_cal) -{ - s32 result = 0; - struct adm_set_params_command adm_params; - int index = afe_get_port_index(port_id); - if (index < 0 || index >= AFE_MAX_PORTS) { - pr_err("%s: invalid port idx %d portid %d\n", - __func__, index, port_id); - return 0; - } - - pr_debug("%s: Port id %d, index %d\n", __func__, port_id, index); - - if (!aud_cal || aud_cal->cal_size == 0) { - pr_debug("%s: No ADM cal to send for port_id = %d!\n", - __func__, port_id); - result = -EINVAL; - goto done; - } - - adm_params.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(20), APR_PKT_VER); - adm_params.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(adm_params)); - adm_params.hdr.src_svc = APR_SVC_ADM; - adm_params.hdr.src_domain = APR_DOMAIN_APPS; - adm_params.hdr.src_port = port_id; - adm_params.hdr.dest_svc = APR_SVC_ADM; - adm_params.hdr.dest_domain = APR_DOMAIN_ADSP; - adm_params.hdr.dest_port = atomic_read(&this_adm.copp_id[index]); - adm_params.hdr.token = port_id; - adm_params.hdr.opcode = ADM_CMD_SET_PARAMS; - adm_params.payload = aud_cal->cal_paddr; - adm_params.payload_size = aud_cal->cal_size; - - atomic_set(&this_adm.copp_stat[index], 0); - pr_debug("%s: Sending SET_PARAMS payload = 0x%x, size = %d\n", - __func__, adm_params.payload, adm_params.payload_size); - result = apr_send_pkt(this_adm.apr, (uint32_t *)&adm_params); - if (result < 0) { - pr_err("%s: Set params failed port = %d payload = 0x%x\n", - __func__, port_id, aud_cal->cal_paddr); - result = -EINVAL; - goto done; - } - /* Wait for the callback */ - result = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!result) { - pr_err("%s: Set params timed out port = %d, payload = 0x%x\n", - __func__, port_id, aud_cal->cal_paddr); - result = -EINVAL; - goto done; - } - - result = 0; -done: - return result; -} - -static void send_adm_cal(int port_id, int path) -{ - int result = 0; - s32 acdb_path; - struct acdb_cal_block aud_cal; - int flag = 0; - int index = afe_get_port_index(port_id); - - pr_debug("%s\n", __func__); - - /* Maps audio_dev_ctrl path definition to ACDB definition */ - acdb_path = path - 1; - - pr_debug("%s: Sending audproc cal\n", __func__); - get_audproc_cal(acdb_path, &aud_cal); - - /* map & cache buffers used */ - if (((mem_addr_audproc[acdb_path].cal_paddr != aud_cal.cal_paddr) && - (aud_cal.cal_size > 0)) || - (aud_cal.cal_size > mem_addr_audproc[acdb_path].cal_size)) { - - if (mem_addr_audproc[acdb_path].cal_paddr != 0) - adm_memory_unmap_regions( - &mem_addr_audproc[acdb_path].cal_paddr, - &mem_addr_audproc[acdb_path].cal_size, 1); - - result = adm_memory_map_regions(&aud_cal.cal_paddr, 0, - &aud_cal.cal_size, 1); - if (result < 0) - pr_err("ADM audproc mmap did not work! path = %d, " - "addr = 0x%x, size = %d\n", acdb_path, - aud_cal.cal_paddr, aud_cal.cal_size); - else - mem_addr_audproc[acdb_path] = aud_cal; - } - if (this_adm.prev_index != index) { - if (!send_adm_cal_block(port_id, &aud_cal)) - pr_debug("%s: Audproc cal sent for port id: %d, path %d\n", - __func__, port_id, acdb_path); - else - pr_debug("%s: Audproc cal not sent for port id: %d, path %d\n", - __func__, port_id, acdb_path); - this_adm.prev_index = index; - flag = 1; - } - - pr_debug("%s: Sending audvol cal\n", __func__); - get_audvol_cal(acdb_path, &aud_cal); - - /* map & cache buffers used */ - if (((mem_addr_audvol[acdb_path].cal_paddr != aud_cal.cal_paddr) && - (aud_cal.cal_size > 0)) || - (aud_cal.cal_size > mem_addr_audvol[acdb_path].cal_size)) { - if (mem_addr_audvol[acdb_path].cal_paddr != 0) - adm_memory_unmap_regions( - &mem_addr_audvol[acdb_path].cal_paddr, - &mem_addr_audvol[acdb_path].cal_size, 1); - - result = adm_memory_map_regions(&aud_cal.cal_paddr, 0, - &aud_cal.cal_size, 1); - if (result < 0) - pr_err("ADM audvol mmap did not work! path = %d, " - "addr = 0x%x, size = %d\n", acdb_path, - aud_cal.cal_paddr, aud_cal.cal_size); - else - mem_addr_audvol[acdb_path] = aud_cal; - } - if ((this_adm.prev_index == index) && (flag == 1)) { - if (!send_adm_cal_block(port_id, &aud_cal)) - pr_debug("%s: Audvol cal sent for port id: %d, path %d\n", - __func__, port_id, acdb_path); - else - pr_debug("%s: Audvol cal not sent for port id: %d, path %d\n", - __func__, port_id, acdb_path); - } - -} - -int adm_connect_afe_port(int mode, int session_id, int port_id) -{ - struct adm_cmd_connect_afe_port cmd; - int ret = 0; - int index; - - pr_debug("%s: port %d session id:%d mode:%d\n", __func__, - port_id, session_id, mode); - - port_id = afe_convert_virtual_to_portid(port_id); - - if (afe_validate_port(port_id) < 0) { - pr_err("%s port idi[%d] is invalid\n", __func__, port_id); - return -ENODEV; - } - if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); - if (this_adm.apr == NULL) { - pr_err("%s: Unable to register ADM\n", __func__); - ret = -ENODEV; - return ret; - } - rtac_set_adm_handle(this_adm.apr); - } - index = afe_get_port_index(port_id); - pr_debug("%s: Port ID %d, index %d\n", __func__, port_id, index); - - cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cmd.hdr.pkt_size = sizeof(cmd); - cmd.hdr.src_svc = APR_SVC_ADM; - cmd.hdr.src_domain = APR_DOMAIN_APPS; - cmd.hdr.src_port = port_id; - cmd.hdr.dest_svc = APR_SVC_ADM; - cmd.hdr.dest_domain = APR_DOMAIN_ADSP; - cmd.hdr.dest_port = port_id; - cmd.hdr.token = port_id; - cmd.hdr.opcode = ADM_CMD_CONNECT_AFE_PORT; - - cmd.mode = mode; - cmd.session_id = session_id; - cmd.afe_port_id = port_id; - - atomic_set(&this_adm.copp_stat[index], 0); - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&cmd); - if (ret < 0) { - pr_err("%s:ADM enable for port %d failed\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - /* Wait for the callback with copp id */ - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s ADM connect AFE failed for port %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - atomic_inc(&this_adm.copp_cnt[index]); - return 0; - -fail_cmd: - - return ret; -} - -int adm_disconnect_afe_port(int mode, int session_id, int port_id) -{ - struct adm_cmd_connect_afe_port cmd; - int ret = 0; - int index; - - pr_debug("%s: port %d session id:%d mode:%d\n", __func__, - port_id, session_id, mode); - - port_id = afe_convert_virtual_to_portid(port_id); - - if (afe_validate_port(port_id) < 0) { - pr_err("%s port idi[%d] is invalid\n", __func__, port_id); - return -ENODEV; - } - if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); - if (this_adm.apr == NULL) { - pr_err("%s: Unable to register ADM\n", __func__); - ret = -ENODEV; - return ret; - } - rtac_set_adm_handle(this_adm.apr); - } - index = afe_get_port_index(port_id); - pr_debug("%s: Port ID %d, index %d\n", __func__, port_id, index); - - cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cmd.hdr.pkt_size = sizeof(cmd); - cmd.hdr.src_svc = APR_SVC_ADM; - cmd.hdr.src_domain = APR_DOMAIN_APPS; - cmd.hdr.src_port = port_id; - cmd.hdr.dest_svc = APR_SVC_ADM; - cmd.hdr.dest_domain = APR_DOMAIN_ADSP; - cmd.hdr.dest_port = port_id; - cmd.hdr.token = port_id; - cmd.hdr.opcode = ADM_CMD_DISCONNECT_AFE_PORT; - - cmd.mode = mode; - cmd.session_id = session_id; - cmd.afe_port_id = port_id; - - atomic_set(&this_adm.copp_stat[index], 0); - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&cmd); - if (ret < 0) { - pr_err("%s:ADM enable for port %d failed\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - /* Wait for the callback with copp id */ - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s ADM connect AFE failed for port %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - atomic_dec(&this_adm.copp_cnt[index]); - return 0; - -fail_cmd: - - return ret; -} - -int adm_open(int port_id, int path, int rate, int channel_mode, int topology) -{ - struct adm_copp_open_command open; - int ret = 0; - int index; - - pr_debug("%s: port %d path:%d rate:%d mode:%d\n", __func__, - port_id, path, rate, channel_mode); - - port_id = afe_convert_virtual_to_portid(port_id); - - if (afe_validate_port(port_id) < 0) { - pr_err("%s port idi[%d] is invalid\n", __func__, port_id); - return -ENODEV; - } - - index = afe_get_port_index(port_id); - pr_debug("%s: Port ID %d, index %d\n", __func__, port_id, index); - - if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); - if (this_adm.apr == NULL) { - pr_err("%s: Unable to register ADM\n", __func__); - ret = -ENODEV; - return ret; - } - rtac_set_adm_handle(this_adm.apr); - } - - - /* Create a COPP if port id are not enabled */ - if (atomic_read(&this_adm.copp_cnt[index]) == 0) { - - open.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - open.hdr.pkt_size = sizeof(open); - open.hdr.src_svc = APR_SVC_ADM; - open.hdr.src_domain = APR_DOMAIN_APPS; - open.hdr.src_port = port_id; - open.hdr.dest_svc = APR_SVC_ADM; - open.hdr.dest_domain = APR_DOMAIN_ADSP; - open.hdr.dest_port = port_id; - open.hdr.token = port_id; - open.hdr.opcode = ADM_CMD_COPP_OPEN; - - open.mode = path; - open.endpoint_id1 = port_id; - - if (this_adm.ec_ref_rx == 0) { - open.endpoint_id2 = 0xFFFF; - } else if (this_adm.ec_ref_rx && (path != 1)) { - open.endpoint_id2 = this_adm.ec_ref_rx; - this_adm.ec_ref_rx = 0; - } - - pr_debug("%s open.endpoint_id1:%d open.endpoint_id2:%d", - __func__, open.endpoint_id1, open.endpoint_id2); - /* convert path to acdb path */ - if (path == ADM_PATH_PLAYBACK) - open.topology_id = get_adm_rx_topology(); - else { - open.topology_id = get_adm_tx_topology(); - if ((open.topology_id == - VPM_TX_SM_ECNS_COPP_TOPOLOGY) || - (open.topology_id == - VPM_TX_DM_FLUENCE_COPP_TOPOLOGY)) - rate = 16000; - } - - if (open.topology_id == 0) - open.topology_id = topology; - - open.channel_config = channel_mode & 0x00FF; - open.rate = rate; - - pr_debug("%s: channel_config=%d port_id=%d rate=%d" - "topology_id=0x%X\n", __func__, open.channel_config,\ - open.endpoint_id1, open.rate,\ - open.topology_id); - - atomic_set(&this_adm.copp_stat[index], 0); - - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open); - if (ret < 0) { - pr_err("%s:ADM enable for port %d failed\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - /* Wait for the callback with copp id */ - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s ADM open failed for port %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - } - atomic_inc(&this_adm.copp_cnt[index]); - return 0; - -fail_cmd: - - return ret; -} - -int adm_multi_ch_copp_pseudo_open_v3(int port_id, int path, - int rate, int channel_mode, - int topology) -{ - struct adm_multi_channel_copp_open_v3 open; - int ret = 0; - int index; - - pr_debug("%s: port %d path:%d rate:%d mode:%d\n", __func__, - port_id, path, rate, channel_mode); - - port_id = afe_convert_virtual_to_portid(port_id); - - if (afe_validate_port(port_id) < 0) { - pr_err("%s port idi[%d] is invalid\n", __func__, port_id); - return -ENODEV; - } - - index = afe_get_port_index(port_id); - pr_debug("%s: Port ID %d, index %d\n", __func__, port_id, index); - - if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); - if (this_adm.apr == NULL) { - pr_err("%s: Unable to register ADM\n", __func__); - ret = -ENODEV; - return ret; - } - rtac_set_adm_handle(this_adm.apr); - } - - - { - open.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - open.hdr.pkt_size = sizeof(open); - open.hdr.src_svc = APR_SVC_ADM; - open.hdr.src_domain = APR_DOMAIN_APPS; - open.hdr.src_port = port_id; - open.hdr.dest_svc = APR_SVC_ADM; - open.hdr.dest_domain = APR_DOMAIN_ADSP; - open.hdr.dest_port = port_id; - open.hdr.token = port_id; - open.hdr.opcode = ADM_CMD_MULTI_CHANNEL_COPP_OPEN_V3; - memset(open.dev_channel_mapping, 0, 8); - - if (channel_mode == 1) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FC; - } else if (channel_mode == 2) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FL; - open.dev_channel_mapping[1] = PCM_CHANNEL_FR; - } else if (channel_mode == 4) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FL; - open.dev_channel_mapping[1] = PCM_CHANNEL_FR; - open.dev_channel_mapping[2] = PCM_CHANNEL_LS; - open.dev_channel_mapping[3] = PCM_CHANNEL_RS; - } else if (channel_mode == 6) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FC; - open.dev_channel_mapping[1] = PCM_CHANNEL_FL; - open.dev_channel_mapping[2] = PCM_CHANNEL_FR; - open.dev_channel_mapping[3] = PCM_CHANNEL_LS; - open.dev_channel_mapping[4] = PCM_CHANNEL_RS; - open.dev_channel_mapping[5] = PCM_CHANNEL_LFE; - } else { - pr_err("%s invalid num_chan %d\n", __func__, - channel_mode); - return -EINVAL; - } - - open.mode = path; - open.endpoint_id1 = port_id; - open.endpoint_id2 = 0xFFFF; - open.bit_width = 16; - - if (path == ADM_PATH_PLAYBACK) - open.topology_id = get_adm_rx_topology(); - else { - open.topology_id = get_adm_tx_topology(); - if ((open.topology_id == - VPM_TX_SM_ECNS_COPP_TOPOLOGY) || - (open.topology_id == - VPM_TX_DM_FLUENCE_COPP_TOPOLOGY)) - rate = 16000; - } - - if (open.topology_id == 0) - open.topology_id = topology; - - open.channel_config = channel_mode & 0x00FF; - open.rate = rate; - open.flags = 0; - - pr_debug("%s: channel_config=%d port_id=%d rate=%d" \ - "topology_id=0x%X\n", __func__, open.channel_config,\ - open.endpoint_id1, open.rate,\ - open.topology_id); - - atomic_set(&this_adm.copp_stat[index], 0); - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open); - if (ret < 0) { - pr_err("%s:ADM enable for port %d failed\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s ADM open failed for port %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - } - atomic_inc(&this_adm.copp_cnt[index]); - return 0; - -fail_cmd: - return ret; - -} - -int adm_multi_ch_copp_open(int port_id, int path, int rate, int channel_mode, - int topology, int perfmode) -{ - struct adm_multi_ch_copp_open_command open; - int ret = 0; - int index; - - pr_debug("%s: port %d path:%d rate:%d channel :%d\n", __func__, - port_id, path, rate, channel_mode); - - port_id = afe_convert_virtual_to_portid(port_id); - - if (afe_validate_port(port_id) < 0) { - pr_err("%s port idi[%d] is invalid\n", __func__, port_id); - return -ENODEV; - } - - index = afe_get_port_index(port_id); - pr_debug("%s: Port ID %d, index %d\n", __func__, port_id, index); - - if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); - if (this_adm.apr == NULL) { - pr_err("%s: Unable to register ADM\n", __func__); - ret = -ENODEV; - return ret; - } - rtac_set_adm_handle(this_adm.apr); - } - - /* Create a COPP if port id are not enabled */ - if (atomic_read(&this_adm.copp_cnt[index]) == 0) { - - open.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - - open.hdr.pkt_size = - sizeof(struct adm_multi_ch_copp_open_command); - - if (perfmode) { - pr_debug("%s Performance mode", __func__); - open.hdr.opcode = ADM_CMD_MULTI_CHANNEL_COPP_OPEN_V3; - open.flags = ADM_MULTI_CH_COPP_OPEN_PERF_MODE_BIT; - open.reserved = PCM_BITS_PER_SAMPLE; - } else { - open.hdr.opcode = ADM_CMD_MULTI_CHANNEL_COPP_OPEN; - open.reserved = 0; - } - - memset(open.dev_channel_mapping, 0, 8); - - if (channel_mode == 1) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FC; - } else if (channel_mode == 2) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FL; - open.dev_channel_mapping[1] = PCM_CHANNEL_FR; - } else if (channel_mode == 4) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FL; - open.dev_channel_mapping[1] = PCM_CHANNEL_FR; - open.dev_channel_mapping[2] = PCM_CHANNEL_RB; - open.dev_channel_mapping[3] = PCM_CHANNEL_LB; - } else if (channel_mode == 6) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FL; - open.dev_channel_mapping[1] = PCM_CHANNEL_FR; - open.dev_channel_mapping[2] = PCM_CHANNEL_LFE; - open.dev_channel_mapping[3] = PCM_CHANNEL_FC; - open.dev_channel_mapping[4] = PCM_CHANNEL_LB; - open.dev_channel_mapping[5] = PCM_CHANNEL_RB; - } else if (channel_mode == 8) { - open.dev_channel_mapping[0] = PCM_CHANNEL_FL; - open.dev_channel_mapping[1] = PCM_CHANNEL_FR; - open.dev_channel_mapping[2] = PCM_CHANNEL_LFE; - open.dev_channel_mapping[3] = PCM_CHANNEL_FC; - open.dev_channel_mapping[4] = PCM_CHANNEL_LB; - open.dev_channel_mapping[5] = PCM_CHANNEL_RB; - open.dev_channel_mapping[6] = PCM_CHANNEL_FLC; - open.dev_channel_mapping[7] = PCM_CHANNEL_FRC; - } else { - pr_err("%s invalid num_chan %d\n", __func__, - channel_mode); - return -EINVAL; - } - open.hdr.src_svc = APR_SVC_ADM; - open.hdr.src_domain = APR_DOMAIN_APPS; - open.hdr.src_port = port_id; - open.hdr.dest_svc = APR_SVC_ADM; - open.hdr.dest_domain = APR_DOMAIN_ADSP; - open.hdr.dest_port = port_id; - open.hdr.token = port_id; - - open.mode = path; - open.endpoint_id1 = port_id; - - if (this_adm.ec_ref_rx == 0) { - open.endpoint_id2 = 0xFFFF; - } else if (this_adm.ec_ref_rx && (path != 1)) { - open.endpoint_id2 = this_adm.ec_ref_rx; - this_adm.ec_ref_rx = 0; - } - - pr_debug("%s open.endpoint_id1:%d open.endpoint_id2:%d", - __func__, open.endpoint_id1, open.endpoint_id2); - /* convert path to acdb path */ - if (path == ADM_PATH_PLAYBACK) - open.topology_id = get_adm_rx_topology(); - else { - open.topology_id = get_adm_tx_topology(); - if ((open.topology_id == - VPM_TX_SM_ECNS_COPP_TOPOLOGY) || - (open.topology_id == - VPM_TX_DM_FLUENCE_COPP_TOPOLOGY)) - rate = 16000; - } - - if (open.topology_id == 0) - open.topology_id = topology; - - open.channel_config = channel_mode & 0x00FF; - open.rate = rate; - - pr_debug("%s: channel_config=%d port_id=%d rate=%d" - " topology_id=0x%X\n", __func__, open.channel_config, - open.endpoint_id1, open.rate, - open.topology_id); - - atomic_set(&this_adm.copp_stat[index], 0); - - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&open); - if (ret < 0) { - pr_err("%s:ADM enable for port %d failed\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - /* Wait for the callback with copp id */ - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s ADM open failed for port %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - } - atomic_inc(&this_adm.copp_cnt[index]); - return 0; - -fail_cmd: - - return ret; -} - -int adm_matrix_map(int session_id, int path, int num_copps, - unsigned int *port_id, int copp_id) -{ - struct adm_routings_command route; - int ret = 0, i = 0; - /* Assumes port_ids have already been validated during adm_open */ - int index = afe_get_port_index(copp_id); - int copp_cnt; - - if (index < 0 || index >= AFE_MAX_PORTS) { - pr_err("%s: invalid port idx %d token %d\n", - __func__, index, copp_id); - return 0; - } - - pr_debug("%s: session 0x%x path:%d num_copps:%d port_id[0]:%d\n", - __func__, session_id, path, num_copps, port_id[0]); - - route.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - route.hdr.pkt_size = sizeof(route); - route.hdr.src_svc = 0; - route.hdr.src_domain = APR_DOMAIN_APPS; - route.hdr.src_port = copp_id; - route.hdr.dest_svc = APR_SVC_ADM; - route.hdr.dest_domain = APR_DOMAIN_ADSP; - route.hdr.dest_port = atomic_read(&this_adm.copp_id[index]); - route.hdr.token = copp_id; - route.hdr.opcode = ADM_CMD_MATRIX_MAP_ROUTINGS; - route.num_sessions = 1; - route.session[0].id = session_id; - - if (num_copps < ADM_MAX_COPPS) { - copp_cnt = num_copps; - } else { - copp_cnt = ADM_MAX_COPPS; - /* print out warning for now as playback/capture to/from - * COPPs more than maximum allowed is extremely unlikely - */ - pr_warn("%s: max out routable COPPs\n", __func__); - } - - route.session[0].num_copps = copp_cnt; - for (i = 0; i < copp_cnt; i++) { - int tmp; - port_id[i] = afe_convert_virtual_to_portid(port_id[i]); - - tmp = afe_get_port_index(port_id[i]); - - pr_debug("%s: port_id[%d]: %d, index: %d\n", __func__, i, - port_id[i], tmp); - - if (tmp >= 0 && tmp < AFE_MAX_PORTS) - route.session[0].copp_id[i] = - atomic_read(&this_adm.copp_id[tmp]); - } - - if (copp_cnt % 2) - route.session[0].copp_id[i] = 0; - - switch (path) { - case 0x1: - route.path = AUDIO_RX; - break; - case 0x2: - case 0x3: - route.path = AUDIO_TX; - break; - default: - pr_err("%s: Wrong path set[%d]\n", __func__, path); - break; - } - atomic_set(&this_adm.copp_stat[index], 0); - - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&route); - if (ret < 0) { - pr_err("%s: ADM routing for port %d failed\n", - __func__, port_id[0]); - ret = -EINVAL; - goto fail_cmd; - } - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: ADM cmd Route failed for port %d\n", - __func__, port_id[0]); - ret = -EINVAL; - goto fail_cmd; - } - - for (i = 0; i < num_copps; i++) - send_adm_cal(port_id[i], path); - - for (i = 0; i < num_copps; i++) { - int tmp; - tmp = afe_get_port_index(port_id[i]); - if (tmp >= 0 && tmp < AFE_MAX_PORTS) - rtac_add_adm_device(port_id[i], - atomic_read(&this_adm.copp_id[tmp]), - path, session_id); - else - pr_debug("%s: Invalid port index %d", - __func__, tmp); - } - return 0; - -fail_cmd: - - return ret; -} - -int adm_memory_map_regions(uint32_t *buf_add, uint32_t mempool_id, - uint32_t *bufsz, uint32_t bufcnt) -{ - struct adm_cmd_memory_map_regions *mmap_regions = NULL; - struct adm_memory_map_regions *mregions = NULL; - void *mmap_region_cmd = NULL; - void *payload = NULL; - int ret = 0; - int i = 0; - int cmd_size = 0; - - pr_debug("%s\n", __func__); - if (this_adm.apr == NULL) { - this_adm.apr = apr_register("ADSP", "ADM", adm_callback, - 0xFFFFFFFF, &this_adm); - if (this_adm.apr == NULL) { - pr_err("%s: Unable to register ADM\n", __func__); - ret = -ENODEV; - return ret; - } - rtac_set_adm_handle(this_adm.apr); - } - - cmd_size = sizeof(struct adm_cmd_memory_map_regions) - + sizeof(struct adm_memory_map_regions) * bufcnt; - - mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL); - if (!mmap_region_cmd) { - pr_err("%s: allocate mmap_region_cmd failed\n", __func__); - return -ENOMEM; - } - mmap_regions = (struct adm_cmd_memory_map_regions *)mmap_region_cmd; - mmap_regions->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mmap_regions->hdr.pkt_size = cmd_size; - mmap_regions->hdr.src_port = 0; - mmap_regions->hdr.dest_port = 0; - mmap_regions->hdr.token = 0; - mmap_regions->hdr.opcode = ADM_CMD_MEMORY_MAP_REGIONS; - mmap_regions->mempool_id = mempool_id & 0x00ff; - mmap_regions->nregions = bufcnt & 0x00ff; - pr_debug("%s: map_regions->nregions = %d\n", __func__, - mmap_regions->nregions); - payload = ((u8 *) mmap_region_cmd + - sizeof(struct adm_cmd_memory_map_regions)); - mregions = (struct adm_memory_map_regions *)payload; - - for (i = 0; i < bufcnt; i++) { - mregions->phys = buf_add[i]; - mregions->buf_size = bufsz[i]; - ++mregions; - } - - atomic_set(&this_adm.copp_stat[0], 0); - ret = apr_send_pkt(this_adm.apr, (uint32_t *) mmap_region_cmd); - if (ret < 0) { - pr_err("%s: mmap_regions op[0x%x]rc[%d]\n", __func__, - mmap_regions->hdr.opcode, ret); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[0]), 5 * HZ); - if (!ret) { - pr_err("%s: timeout. waited for memory_map\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } -fail_cmd: - kfree(mmap_region_cmd); - return ret; -} - -int adm_memory_unmap_regions(uint32_t *buf_add, uint32_t *bufsz, - uint32_t bufcnt) -{ - struct adm_cmd_memory_unmap_regions *unmap_regions = NULL; - struct adm_memory_unmap_regions *mregions = NULL; - void *unmap_region_cmd = NULL; - void *payload = NULL; - int ret = 0; - int i = 0; - int cmd_size = 0; - - pr_debug("%s\n", __func__); - - if (this_adm.apr == NULL) { - pr_err("%s APR handle NULL\n", __func__); - return -EINVAL; - } - - cmd_size = sizeof(struct adm_cmd_memory_unmap_regions) - + sizeof(struct adm_memory_unmap_regions) * bufcnt; - - unmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL); - if (!unmap_region_cmd) { - pr_err("%s: allocate unmap_region_cmd failed\n", __func__); - return -ENOMEM; - } - unmap_regions = (struct adm_cmd_memory_unmap_regions *) - unmap_region_cmd; - unmap_regions->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - unmap_regions->hdr.pkt_size = cmd_size; - unmap_regions->hdr.src_port = 0; - unmap_regions->hdr.dest_port = 0; - unmap_regions->hdr.token = 0; - unmap_regions->hdr.opcode = ADM_CMD_MEMORY_UNMAP_REGIONS; - unmap_regions->nregions = bufcnt & 0x00ff; - unmap_regions->reserved = 0; - pr_debug("%s: unmap_regions->nregions = %d\n", __func__, - unmap_regions->nregions); - payload = ((u8 *) unmap_region_cmd + - sizeof(struct adm_cmd_memory_unmap_regions)); - mregions = (struct adm_memory_unmap_regions *)payload; - - for (i = 0; i < bufcnt; i++) { - mregions->phys = buf_add[i]; - ++mregions; - } - atomic_set(&this_adm.copp_stat[0], 0); - ret = apr_send_pkt(this_adm.apr, (uint32_t *) unmap_region_cmd); - if (ret < 0) { - pr_err("%s: mmap_regions op[0x%x]rc[%d]\n", __func__, - unmap_regions->hdr.opcode, ret); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[0]), 5 * HZ); - if (!ret) { - pr_err("%s: timeout. waited for memory_unmap\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } -fail_cmd: - kfree(unmap_region_cmd); - return ret; -} - -int adm_get_copp_id(int port_index) -{ - pr_debug("%s\n", __func__); - - if (port_index < 0) { - pr_err("%s: invalid port_id = %d\n", __func__, port_index); - return -EINVAL; - } - - return atomic_read(&this_adm.copp_id[port_index]); -} - -void adm_ec_ref_rx_id(int port_id) -{ - this_adm.ec_ref_rx = port_id; - pr_debug("%s ec_ref_rx:%d", __func__, this_adm.ec_ref_rx); -} - -int adm_pseudo_close(int port_id) -{ - struct apr_hdr close; - - int ret = 0, i = 0; - int index = 0; - int pseudo_copp_cnt; - index = afe_get_port_index(port_id); - if (afe_validate_port(port_id) < 0) - return -EINVAL; - - pseudo_copp_cnt = atomic_read(&this_adm.copp_cnt[index]); - pr_debug("%s port_id=%d index %d copp_cnt %d\n", __func__, port_id, - index, pseudo_copp_cnt); - - for (i = 0; i < pseudo_copp_cnt; i++) { - close.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - close.pkt_size = sizeof(close); - close.src_svc = APR_SVC_ADM; - close.src_domain = APR_DOMAIN_APPS; - close.src_port = port_id; - close.dest_svc = APR_SVC_ADM; - close.dest_domain = APR_DOMAIN_ADSP; - close.dest_port = pseudo_copp[i]; - close.token = port_id; - close.opcode = ADM_CMD_COPP_CLOSE; - - atomic_set(&this_adm.copp_id[index], RESET_COPP_ID); - atomic_set(&this_adm.copp_stat[index], 0); - - - pr_debug("%s:coppid %d portid=%d index=%d coppcnt=%d\n", - __func__, - atomic_read(&this_adm.copp_id[index]), - port_id, index, - atomic_read(&this_adm.copp_cnt[index])); - - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&close); - - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - } - - atomic_set(&this_adm.copp_cnt[index], 0); - return ret; - -} - -int adm_close(int port_id) -{ - struct apr_hdr close; - - int ret = 0; - int index = 0; - - port_id = afe_convert_virtual_to_portid(port_id); - - index = afe_get_port_index(port_id); - if (afe_validate_port(port_id) < 0) - return -EINVAL; - - pr_debug("%s port_id=%d index %d\n", __func__, port_id, index); - - if (!(atomic_read(&this_adm.copp_cnt[index]))) { - pr_err("%s: copp count for port[%d]is 0\n", __func__, port_id); - - goto fail_cmd; - } - atomic_dec(&this_adm.copp_cnt[index]); - if (!(atomic_read(&this_adm.copp_cnt[index]))) { - - close.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - close.pkt_size = sizeof(close); - close.src_svc = APR_SVC_ADM; - close.src_domain = APR_DOMAIN_APPS; - close.src_port = port_id; - close.dest_svc = APR_SVC_ADM; - close.dest_domain = APR_DOMAIN_ADSP; - close.dest_port = atomic_read(&this_adm.copp_id[index]); - close.token = port_id; - close.opcode = ADM_CMD_COPP_CLOSE; - - atomic_set(&this_adm.copp_id[index], RESET_COPP_ID); - atomic_set(&this_adm.copp_stat[index], 0); - this_adm.prev_index = 0xffff; - - pr_debug("%s:coppid %d portid=%d index=%d coppcnt=%d\n", - __func__, - atomic_read(&this_adm.copp_id[index]), - port_id, index, - atomic_read(&this_adm.copp_cnt[index])); - - ret = apr_send_pkt(this_adm.apr, (uint32_t *)&close); - if (ret < 0) { - pr_err("%s ADM close failed\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_adm.wait, - atomic_read(&this_adm.copp_stat[index]), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: ADM cmd Route failed for port %d\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - - rtac_remove_adm_device(port_id); - } - -fail_cmd: - return ret; -} - -static int __init adm_init(void) -{ - int i = 0; - init_waitqueue_head(&this_adm.wait); - this_adm.apr = NULL; - this_adm.prev_index = 0xffff; - for (i = 0; i < AFE_MAX_PORTS; i++) { - atomic_set(&this_adm.copp_id[i], RESET_COPP_ID); - atomic_set(&this_adm.copp_cnt[i], 0); - atomic_set(&this_adm.copp_stat[i], 0); - } - return 0; -} - -device_initcall(adm_init); diff --git a/sound/soc/msm/qdsp6/q6afe.c b/sound/soc/msm/qdsp6/q6afe.c deleted file mode 100644 index c4851f35d9eb161813b12bf1884d39f525cb04db..0000000000000000000000000000000000000000 --- a/sound/soc/msm/qdsp6/q6afe.c +++ /dev/null @@ -1,1872 +0,0 @@ -/* Copyright (c) 2010-2013, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct afe_ctl { - void *apr; - atomic_t state; - atomic_t status; - wait_queue_head_t wait; - struct task_struct *task; - void (*tx_cb) (uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv); - void (*rx_cb) (uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv); - void *tx_private_data; - void *rx_private_data; - u16 dtmf_gen_rx_portid; -}; - -static struct afe_ctl this_afe; - -static struct acdb_cal_block afe_cal_addr[MAX_AUDPROC_TYPES]; - -#define TIMEOUT_MS 1000 -#define Q6AFE_MAX_VOLUME 0x3FFF - -#define SIZEOF_CFG_CMD(y) \ - (sizeof(struct apr_hdr) + sizeof(u16) + (sizeof(struct y))) - -static int32_t afe_callback(struct apr_client_data *data, void *priv) -{ - if (data->opcode == RESET_EVENTS) { - pr_debug("q6afe: reset event = %d %d apr[%p]\n", - data->reset_event, data->reset_proc, this_afe.apr); - if (this_afe.apr) { - apr_reset(this_afe.apr); - atomic_set(&this_afe.state, 0); - this_afe.apr = NULL; - } - /* send info to user */ - pr_debug("task_name = %s pid = %d\n", - this_afe.task->comm, this_afe.task->pid); - send_sig(SIGUSR1, this_afe.task, 0); - return 0; - } - if (data->payload_size) { - uint32_t *payload; - uint16_t port_id = 0; - payload = data->payload; - pr_debug("%s:opcode = 0x%x cmd = 0x%x status = 0x%x\n", - __func__, data->opcode, - payload[0], payload[1]); - /* payload[1] contains the error status for response */ - if (payload[1] != 0) { - atomic_set(&this_afe.status, -1); - pr_err("%s: cmd = 0x%x returned error = 0x%x\n", - __func__, payload[0], payload[1]); - } - if (data->opcode == APR_BASIC_RSP_RESULT) { - switch (payload[0]) { - case AFE_PORT_AUDIO_IF_CONFIG: - case AFE_PORT_CMD_I2S_CONFIG: - case AFE_PORT_MULTI_CHAN_HDMI_AUDIO_IF_CONFIG: - case AFE_PORT_AUDIO_SLIM_SCH_CONFIG: - case AFE_PORT_CMD_STOP: - case AFE_PORT_CMD_START: - case AFE_PORT_CMD_LOOPBACK: - case AFE_PORT_CMD_SIDETONE_CTL: - case AFE_PORT_CMD_SET_PARAM: - case AFE_PSEUDOPORT_CMD_START: - case AFE_PSEUDOPORT_CMD_STOP: - case AFE_PORT_CMD_APPLY_GAIN: - case AFE_SERVICE_CMD_MEMORY_MAP: - case AFE_SERVICE_CMD_MEMORY_UNMAP: - case AFE_SERVICE_CMD_UNREG_RTPORT: - case AFE_PORTS_CMD_DTMF_CTL: - atomic_set(&this_afe.state, 0); - wake_up(&this_afe.wait); - break; - case AFE_SERVICE_CMD_REG_RTPORT: - break; - case AFE_SERVICE_CMD_RTPORT_WR: - port_id = RT_PROXY_PORT_001_TX; - break; - case AFE_SERVICE_CMD_RTPORT_RD: - port_id = RT_PROXY_PORT_001_RX; - break; - default: - pr_err("Unknown cmd 0x%x\n", - payload[0]); - break; - } - } else if (data->opcode == AFE_EVENT_RT_PROXY_PORT_STATUS) { - port_id = (uint16_t)(0x0000FFFF & payload[0]); - } - pr_debug("%s:port_id = %x\n", __func__, port_id); - switch (port_id) { - case RT_PROXY_PORT_001_TX: { - if (this_afe.tx_cb) { - this_afe.tx_cb(data->opcode, data->token, - data->payload, - this_afe.tx_private_data); - } - break; - } - case RT_PROXY_PORT_001_RX: { - if (this_afe.rx_cb) { - this_afe.rx_cb(data->opcode, data->token, - data->payload, - this_afe.rx_private_data); - } - break; - } - default: - break; - } - } - return 0; -} - -int afe_get_port_type(u16 port_id) -{ - int ret; - - switch (port_id) { - case PRIMARY_I2S_RX: - case PCM_RX: - case SECONDARY_PCM_RX: - case SECONDARY_I2S_RX: - case MI2S_RX: - case HDMI_RX: - case SLIMBUS_0_RX: - case SLIMBUS_1_RX: - case SLIMBUS_2_RX: - case SLIMBUS_3_RX: - case INT_BT_SCO_RX: - case INT_BT_A2DP_RX: - case INT_FM_RX: - case VOICE_PLAYBACK_TX: - case RT_PROXY_PORT_001_RX: - case SLIMBUS_4_RX: - case PSEUDOPORT_01: - ret = MSM_AFE_PORT_TYPE_RX; - break; - - case PRIMARY_I2S_TX: - case PCM_TX: - case SECONDARY_PCM_TX: - case SECONDARY_I2S_TX: - case MI2S_TX: - case DIGI_MIC_TX: - case VOICE_RECORD_TX: - case SLIMBUS_0_TX: - case SLIMBUS_1_TX: - case SLIMBUS_2_TX: - case SLIMBUS_3_TX: - case INT_FM_TX: - case VOICE_RECORD_RX: - case INT_BT_SCO_TX: - case RT_PROXY_PORT_001_TX: - case SLIMBUS_4_TX: - ret = MSM_AFE_PORT_TYPE_TX; - break; - - default: - pr_err("%s: invalid port id %d\n", __func__, port_id); - ret = -EINVAL; - } - - return ret; -} - -int afe_validate_port(u16 port_id) -{ - int ret; - - switch (port_id) { - case PRIMARY_I2S_RX: - case PRIMARY_I2S_TX: - case PCM_RX: - case PCM_TX: - case SECONDARY_PCM_RX: - case SECONDARY_PCM_TX: - case SECONDARY_I2S_RX: - case SECONDARY_I2S_TX: - case MI2S_RX: - case MI2S_TX: - case HDMI_RX: - case RSVD_2: - case RSVD_3: - case DIGI_MIC_TX: - case VOICE_RECORD_RX: - case VOICE_RECORD_TX: - case VOICE_PLAYBACK_TX: - case SLIMBUS_0_RX: - case SLIMBUS_0_TX: - case SLIMBUS_1_RX: - case SLIMBUS_1_TX: - case SLIMBUS_2_RX: - case SLIMBUS_2_TX: - case SLIMBUS_3_RX: - case SLIMBUS_3_TX: - case INT_BT_SCO_RX: - case INT_BT_SCO_TX: - case INT_BT_A2DP_RX: - case INT_FM_RX: - case INT_FM_TX: - case RT_PROXY_PORT_001_RX: - case RT_PROXY_PORT_001_TX: - case SLIMBUS_4_RX: - case SLIMBUS_4_TX: - case PSEUDOPORT_01: - { - ret = 0; - break; - } - - default: - ret = -EINVAL; - } - - return ret; -} - -int afe_convert_virtual_to_portid(u16 port_id) -{ - int ret; - - /* if port_id is virtual, convert to physical.. - * if port_id is already physical, return physical - */ - if (afe_validate_port(port_id) < 0) { - if (port_id == RT_PROXY_DAI_001_RX || - port_id == RT_PROXY_DAI_001_TX || - port_id == RT_PROXY_DAI_002_RX || - port_id == RT_PROXY_DAI_002_TX) - ret = VIRTUAL_ID_TO_PORTID(port_id); - else - ret = -EINVAL; - } else - ret = port_id; - - return ret; -} - -int afe_get_port_index(u16 port_id) -{ - switch (port_id) { - case PRIMARY_I2S_RX: return IDX_PRIMARY_I2S_RX; - case PRIMARY_I2S_TX: return IDX_PRIMARY_I2S_TX; - case PCM_RX: return IDX_PCM_RX; - case PCM_TX: return IDX_PCM_TX; - case SECONDARY_PCM_RX: return IDX_SECONDARY_PCM_RX; - case SECONDARY_PCM_TX: return IDX_SECONDARY_PCM_TX; - case SECONDARY_I2S_RX: return IDX_SECONDARY_I2S_RX; - case SECONDARY_I2S_TX: return IDX_SECONDARY_I2S_TX; - case MI2S_RX: return IDX_MI2S_RX; - case MI2S_TX: return IDX_MI2S_TX; - case HDMI_RX: return IDX_HDMI_RX; - case RSVD_2: return IDX_RSVD_2; - case RSVD_3: return IDX_RSVD_3; - case DIGI_MIC_TX: return IDX_DIGI_MIC_TX; - case VOICE_RECORD_RX: return IDX_VOICE_RECORD_RX; - case VOICE_RECORD_TX: return IDX_VOICE_RECORD_TX; - case VOICE_PLAYBACK_TX: return IDX_VOICE_PLAYBACK_TX; - case SLIMBUS_0_RX: return IDX_SLIMBUS_0_RX; - case SLIMBUS_0_TX: return IDX_SLIMBUS_0_TX; - case SLIMBUS_1_RX: return IDX_SLIMBUS_1_RX; - case SLIMBUS_1_TX: return IDX_SLIMBUS_1_TX; - case SLIMBUS_2_RX: return IDX_SLIMBUS_2_RX; - case SLIMBUS_2_TX: return IDX_SLIMBUS_2_TX; - case SLIMBUS_3_RX: return IDX_SLIMBUS_3_RX; - case SLIMBUS_3_TX: return IDX_SLIMBUS_3_TX; - case INT_BT_SCO_RX: return IDX_INT_BT_SCO_RX; - case INT_BT_SCO_TX: return IDX_INT_BT_SCO_TX; - case INT_BT_A2DP_RX: return IDX_INT_BT_A2DP_RX; - case INT_FM_RX: return IDX_INT_FM_RX; - case INT_FM_TX: return IDX_INT_FM_TX; - case RT_PROXY_PORT_001_RX: return IDX_RT_PROXY_PORT_001_RX; - case RT_PROXY_PORT_001_TX: return IDX_RT_PROXY_PORT_001_TX; - case SLIMBUS_4_RX: return IDX_SLIMBUS_4_RX; - case SLIMBUS_4_TX: return IDX_SLIMBUS_4_TX; - case PSEUDOPORT_01: return IDX_PSEUDOPORT_01; - - default: return -EINVAL; - } -} - -int afe_sizeof_cfg_cmd(u16 port_id) -{ - int ret_size; - switch (port_id) { - case PRIMARY_I2S_RX: - case PRIMARY_I2S_TX: - case SECONDARY_I2S_RX: - case SECONDARY_I2S_TX: - case MI2S_RX: - case MI2S_TX: - ret_size = SIZEOF_CFG_CMD(afe_port_mi2s_cfg); - break; - case HDMI_RX: - ret_size = SIZEOF_CFG_CMD(afe_port_hdmi_multi_ch_cfg); - break; - case SLIMBUS_0_RX: - case SLIMBUS_0_TX: - case SLIMBUS_1_RX: - case SLIMBUS_1_TX: - case SLIMBUS_2_RX: - case SLIMBUS_2_TX: - case SLIMBUS_3_RX: - case SLIMBUS_3_TX: - case SLIMBUS_4_RX: - case SLIMBUS_4_TX: - ret_size = SIZEOF_CFG_CMD(afe_port_slimbus_sch_cfg); - break; - case RT_PROXY_PORT_001_RX: - case RT_PROXY_PORT_001_TX: - ret_size = SIZEOF_CFG_CMD(afe_port_rtproxy_cfg); - break; - case PSEUDOPORT_01: - ret_size = SIZEOF_CFG_CMD(afe_port_pseudo_cfg); - break; - case PCM_RX: - case PCM_TX: - case SECONDARY_PCM_RX: - case SECONDARY_PCM_TX: - default: - ret_size = SIZEOF_CFG_CMD(afe_port_pcm_cfg); - break; - } - return ret_size; -} - -int afe_q6_interface_prepare(void) -{ - int ret = 0; - - pr_debug("%s:", __func__); - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - } - } - return ret; -} - -static void afe_send_cal_block(int32_t path, u16 port_id) -{ - int result = 0; - struct acdb_cal_block cal_block; - struct afe_port_cmd_set_param_no_payload afe_cal; - pr_debug("%s: path %d\n", __func__, path); - - get_afe_cal(path, &cal_block); - if (cal_block.cal_size <= 0) { - pr_debug("%s: No AFE cal to send!\n", __func__); - goto done; - } - - if ((afe_cal_addr[path].cal_paddr != cal_block.cal_paddr) || - (cal_block.cal_size > afe_cal_addr[path].cal_size)) { - if (afe_cal_addr[path].cal_paddr != 0) - afe_cmd_memory_unmap( - afe_cal_addr[path].cal_paddr); - - afe_cmd_memory_map(cal_block.cal_paddr, cal_block.cal_size); - afe_cal_addr[path].cal_paddr = cal_block.cal_paddr; - afe_cal_addr[path].cal_size = cal_block.cal_size; - } - - afe_cal.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - afe_cal.hdr.pkt_size = sizeof(afe_cal); - afe_cal.hdr.src_port = 0; - afe_cal.hdr.dest_port = 0; - afe_cal.hdr.token = 0; - afe_cal.hdr.opcode = AFE_PORT_CMD_SET_PARAM; - afe_cal.port_id = port_id; - afe_cal.payload_size = cal_block.cal_size; - afe_cal.payload_address = cal_block.cal_paddr; - - pr_debug("%s: AFE cal sent for device port = %d, path = %d, " - "cal size = %d, cal addr = 0x%x\n", __func__, - port_id, path, cal_block.cal_size, cal_block.cal_paddr); - - atomic_set(&this_afe.state, 1); - result = apr_send_pkt(this_afe.apr, (uint32_t *) &afe_cal); - if (result < 0) { - pr_err("%s: AFE cal for port %d failed\n", - __func__, port_id); - } - - result = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!result) { - pr_err("%s: wait_event timeout SET AFE CAL\n", __func__); - goto done; - } - - pr_debug("%s: AFE cal sent for path %d device!\n", __func__, path); -done: - return; -} - -void afe_send_cal(u16 port_id) -{ - pr_debug("%s\n", __func__); - - if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_TX) - afe_send_cal_block(TX_CAL, port_id); - else if (afe_get_port_type(port_id) == MSM_AFE_PORT_TYPE_RX) - afe_send_cal_block(RX_CAL, port_id); -} - -/* This function sends multi-channel HDMI configuration command and AFE - * calibration which is only supported by QDSP6 on 8960 and onward. - */ -int afe_port_start(u16 port_id, union afe_port_config *afe_config, - u32 rate) -{ - struct afe_port_start_command start; - struct afe_audioif_config_command config; - int ret; - - if (!afe_config) { - pr_err("%s: Error, no configuration data\n", __func__); - ret = -EINVAL; - return ret; - } - pr_debug("%s: %d %d\n", __func__, port_id, rate); - - if ((port_id == RT_PROXY_DAI_001_RX) || - (port_id == RT_PROXY_DAI_002_TX)) - return 0; - if ((port_id == RT_PROXY_DAI_002_RX) || - (port_id == RT_PROXY_DAI_001_TX)) - port_id = VIRTUAL_ID_TO_PORTID(port_id); - - ret = afe_q6_interface_prepare(); - if (IS_ERR_VALUE(ret)) - return ret; - - if (port_id == HDMI_RX) { - config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - config.hdr.pkt_size = afe_sizeof_cfg_cmd(port_id); - config.hdr.src_port = 0; - config.hdr.dest_port = 0; - config.hdr.token = 0; - config.hdr.opcode = AFE_PORT_MULTI_CHAN_HDMI_AUDIO_IF_CONFIG; - } else { - - config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - config.hdr.pkt_size = afe_sizeof_cfg_cmd(port_id); - config.hdr.src_port = 0; - config.hdr.dest_port = 0; - config.hdr.token = 0; - switch (port_id) { - case SLIMBUS_0_RX: - case SLIMBUS_0_TX: - case SLIMBUS_1_RX: - case SLIMBUS_1_TX: - case SLIMBUS_2_RX: - case SLIMBUS_2_TX: - case SLIMBUS_3_RX: - case SLIMBUS_3_TX: - case SLIMBUS_4_RX: - case SLIMBUS_4_TX: - config.hdr.opcode = AFE_PORT_AUDIO_SLIM_SCH_CONFIG; - break; - case MI2S_TX: - case MI2S_RX: - case SECONDARY_I2S_RX: - case SECONDARY_I2S_TX: - case PRIMARY_I2S_RX: - case PRIMARY_I2S_TX: - /* AFE_PORT_CMD_I2S_CONFIG command is not supported - * in the LPASS EL 1.0. So we have to distiguish - * which AFE command, AFE_PORT_CMD_I2S_CONFIG or - * AFE_PORT_AUDIO_IF_CONFIG to use. If the format - * is L-PCM, the AFE_PORT_AUDIO_IF_CONFIG is used - * to make the backward compatible. - */ - pr_debug("%s: afe_config->mi2s.format = %d\n", __func__, - afe_config->mi2s.format); - if (afe_config->mi2s.format == MSM_AFE_I2S_FORMAT_LPCM) - config.hdr.opcode = AFE_PORT_AUDIO_IF_CONFIG; - else - config.hdr.opcode = AFE_PORT_CMD_I2S_CONFIG; - break; - case PSEUDOPORT_01: - config.hdr.opcode = AFE_PORT_AUDIO_IF_CONFIG; - pr_debug("%s, config, opcode=%x\n", __func__, - config.hdr.opcode); - break; - default: - config.hdr.opcode = AFE_PORT_AUDIO_IF_CONFIG; - break; - } - } - - if (afe_validate_port(port_id) < 0) { - - pr_err("%s: Failed : Invalid Port id = %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - config.port_id = port_id; - config.port = *afe_config; - - atomic_set(&this_afe.state, 1); - atomic_set(&this_afe.status, 0); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config); - if (ret < 0) { - pr_err("%s: AFE enable for port %d failed\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - - if (!ret) { - pr_err("%s: wait_event timeout IF CONFIG\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - if (atomic_read(&this_afe.status) != 0) { - pr_err("%s: config cmd failed\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - - /* send AFE cal */ - afe_send_cal(port_id); - - start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - start.hdr.pkt_size = sizeof(start); - start.hdr.src_port = 0; - start.hdr.dest_port = 0; - start.hdr.token = 0; - start.hdr.opcode = AFE_PORT_CMD_START; - start.port_id = port_id; - start.gain = 0x2000; - start.sample_rate = rate; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &start); - - if (IS_ERR_VALUE(ret)) { - pr_err("%s: AFE enable for port %d failed\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout PORT START\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - - if (this_afe.task != current) - this_afe.task = current; - - pr_debug("task_name = %s pid = %d\n", - this_afe.task->comm, this_afe.task->pid); - return 0; - -fail_cmd: - return ret; -} - -/* This function should be used by 8660 exclusively */ -int afe_open(u16 port_id, union afe_port_config *afe_config, int rate) -{ - struct afe_port_start_command start; - struct afe_audioif_config_command config; - int ret = 0; - - if (!afe_config) { - pr_err("%s: Error, no configuration data\n", __func__); - ret = -EINVAL; - return ret; - } - - pr_debug("%s: %d %d\n", __func__, port_id, rate); - - if ((port_id == RT_PROXY_DAI_001_RX) || - (port_id == RT_PROXY_DAI_002_TX)) - return 0; - if ((port_id == RT_PROXY_DAI_002_RX) || - (port_id == RT_PROXY_DAI_001_TX)) - port_id = VIRTUAL_ID_TO_PORTID(port_id); - - ret = afe_q6_interface_prepare(); - if (ret != 0) - return ret; - - config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - config.hdr.pkt_size = afe_sizeof_cfg_cmd(port_id); - config.hdr.src_port = 0; - config.hdr.dest_port = 0; - config.hdr.token = 0; - switch (port_id) { - case SLIMBUS_0_RX: - case SLIMBUS_0_TX: - case SLIMBUS_1_RX: - case SLIMBUS_1_TX: - case SLIMBUS_2_RX: - case SLIMBUS_2_TX: - case SLIMBUS_3_RX: - case SLIMBUS_3_TX: - case SLIMBUS_4_RX: - case SLIMBUS_4_TX: - config.hdr.opcode = AFE_PORT_AUDIO_SLIM_SCH_CONFIG; - break; - case MI2S_TX: - case MI2S_RX: - case SECONDARY_I2S_RX: - case SECONDARY_I2S_TX: - case PRIMARY_I2S_RX: - case PRIMARY_I2S_TX: - /* AFE_PORT_CMD_I2S_CONFIG command is not supported - * in the LPASS EL 1.0. So we have to distiguish - * which AFE command, AFE_PORT_CMD_I2S_CONFIG or - * AFE_PORT_AUDIO_IF_CONFIG to use. If the format - * is L-PCM, the AFE_PORT_AUDIO_IF_CONFIG is used - * to make the backward compatible. - */ - pr_debug("%s: afe_config->mi2s.format = %d\n", __func__, - afe_config->mi2s.format); - if (afe_config->mi2s.format == MSM_AFE_I2S_FORMAT_LPCM) - config.hdr.opcode = AFE_PORT_AUDIO_IF_CONFIG; - else - config.hdr.opcode = AFE_PORT_CMD_I2S_CONFIG; - break; - default: - config.hdr.opcode = AFE_PORT_AUDIO_IF_CONFIG; - break; - } - - if (afe_validate_port(port_id) < 0) { - - pr_err("%s: Failed : Invalid Port id = %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - - config.port_id = port_id; - config.port = *afe_config; - - atomic_set(&this_afe.state, 1); - atomic_set(&this_afe.status, 0); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &config); - if (ret < 0) { - pr_err("%s: AFE enable for port %d failed\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - if (atomic_read(&this_afe.status) != 0) { - pr_err("%s: config cmd failed\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - start.hdr.pkt_size = sizeof(start); - start.hdr.src_port = 0; - start.hdr.dest_port = 0; - start.hdr.token = 0; - start.hdr.opcode = AFE_PORT_CMD_START; - start.port_id = port_id; - start.gain = 0x2000; - start.sample_rate = rate; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &start); - if (ret < 0) { - pr_err("%s: AFE enable for port %d failed\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - - if (this_afe.task != current) - this_afe.task = current; - - pr_debug("task_name = %s pid = %d\n", - this_afe.task->comm, this_afe.task->pid); - return 0; -fail_cmd: - return ret; -} - -int afe_loopback(u16 enable, u16 dst_port, u16 src_port) -{ - struct afe_loopback_command lb_cmd; - int ret = 0; - - ret = afe_q6_interface_prepare(); - if (ret != 0) - return ret; - - if ((afe_get_port_type(dst_port) == MSM_AFE_PORT_TYPE_RX) && - (afe_get_port_type(src_port) == MSM_AFE_PORT_TYPE_RX)) - return afe_loopback_cfg(enable, dst_port, src_port, - LB_MODE_EC_REF_VOICE_AUDIO); - - lb_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(20), APR_PKT_VER); - lb_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(lb_cmd) - APR_HDR_SIZE); - lb_cmd.hdr.src_port = 0; - lb_cmd.hdr.dest_port = 0; - lb_cmd.hdr.token = 0; - lb_cmd.hdr.opcode = AFE_PORT_CMD_LOOPBACK; - lb_cmd.tx_port_id = src_port; - lb_cmd.rx_port_id = dst_port; - lb_cmd.mode = 0xFFFF; - lb_cmd.enable = (enable ? 1 : 0); - atomic_set(&this_afe.state, 1); - - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &lb_cmd); - if (ret < 0) { - pr_err("%s: AFE loopback failed\n", __func__); - ret = -EINVAL; - goto done; - } - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - } -done: - return ret; -} - -int afe_loopback_cfg(u16 enable, u16 dst_port, u16 src_port, u16 mode) -{ - struct afe_port_cmd_set_param lp_cfg; - int ret = 0; - - ret = afe_q6_interface_prepare(); - if (ret != 0) - return ret; - - pr_debug("%s: src_port %d, dst_port %d\n", - __func__, src_port, dst_port); - - lp_cfg.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - lp_cfg.hdr.pkt_size = sizeof(lp_cfg); - lp_cfg.hdr.src_port = 0; - lp_cfg.hdr.dest_port = 0; - lp_cfg.hdr.token = 0; - lp_cfg.hdr.opcode = AFE_PORT_CMD_SET_PARAM; - - lp_cfg.port_id = src_port; - lp_cfg.payload_size = sizeof(struct afe_param_payload_base) + - sizeof(struct afe_param_loopback_cfg); - lp_cfg.payload_address = 0; - - lp_cfg.payload.base.module_id = AFE_MODULE_LOOPBACK; - lp_cfg.payload.base.param_id = AFE_PARAM_ID_LOOPBACK_CONFIG; - lp_cfg.payload.base.param_size = sizeof(struct afe_param_loopback_cfg); - lp_cfg.payload.base.reserved = 0; - - lp_cfg.payload.param.loopback_cfg.loopback_cfg_minor_version = - AFE_API_VERSION_LOOPBACK_CONFIG; - lp_cfg.payload.param.loopback_cfg.dst_port_id = dst_port; - lp_cfg.payload.param.loopback_cfg.routing_mode = mode; - lp_cfg.payload.param.loopback_cfg.enable = enable; - lp_cfg.payload.param.loopback_cfg.reserved = 0; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &lp_cfg); - if (ret < 0) { - pr_err("%s: AFE loopback config failed for src_port %d, dst_port %d\n", - __func__, src_port, dst_port); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - return 0; -fail_cmd: - return ret; -} - -int afe_loopback_gain(u16 port_id, u16 volume) -{ - struct afe_port_cmd_set_param set_param; - int ret = 0; - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - - if (afe_validate_port(port_id) < 0) { - - pr_err("%s: Failed : Invalid Port id = %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - - /* RX ports numbers are even .TX ports numbers are odd. */ - if (port_id % 2 == 0) { - pr_err("%s: Failed : afe loopback gain only for TX ports." - " port_id %d\n", __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - - pr_debug("%s: %d %hX\n", __func__, port_id, volume); - - set_param.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - set_param.hdr.pkt_size = sizeof(set_param); - set_param.hdr.src_port = 0; - set_param.hdr.dest_port = 0; - set_param.hdr.token = 0; - set_param.hdr.opcode = AFE_PORT_CMD_SET_PARAM; - - set_param.port_id = port_id; - set_param.payload_size = sizeof(struct afe_param_payload_base) + - sizeof(struct afe_param_loopback_gain); - set_param.payload_address = 0; - - set_param.payload.base.module_id = AFE_MODULE_ID_PORT_INFO; - set_param.payload.base.param_id = AFE_PARAM_ID_LOOPBACK_GAIN; - set_param.payload.base.param_size = - sizeof(struct afe_param_loopback_gain); - set_param.payload.base.reserved = 0; - - set_param.payload.param.loopback_gain.gain = volume; - set_param.payload.param.loopback_gain.reserved = 0; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &set_param); - if (ret < 0) { - pr_err("%s: AFE param set failed for port %d\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - return 0; -fail_cmd: - return ret; -} - -int afe_apply_gain(u16 port_id, u16 gain) -{ - struct afe_port_gain_command set_gain; - int ret = 0; - - if (this_afe.apr == NULL) { - pr_err("%s: AFE is not opened\n", __func__); - ret = -EPERM; - goto fail_cmd; - } - - if (afe_validate_port(port_id) < 0) { - pr_err("%s: Failed : Invalid Port id = %d\n", __func__, - port_id); - ret = -EINVAL; - goto fail_cmd; - } - - /* RX ports numbers are even .TX ports numbers are odd. */ - if (port_id % 2 == 0) { - pr_err("%s: Failed : afe apply gain only for TX ports." - " port_id %d\n", __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - - pr_debug("%s: %d %hX\n", __func__, port_id, gain); - - set_gain.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - set_gain.hdr.pkt_size = sizeof(set_gain); - set_gain.hdr.src_port = 0; - set_gain.hdr.dest_port = 0; - set_gain.hdr.token = 0; - set_gain.hdr.opcode = AFE_PORT_CMD_APPLY_GAIN; - - set_gain.port_id = port_id; - set_gain.gain = gain; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &set_gain); - if (ret < 0) { - pr_err("%s: AFE Gain set failed for port %d\n", - __func__, port_id); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - return 0; -fail_cmd: - return ret; -} - -int afe_pseudo_port_start_nowait(u16 port_id) -{ - int ret = 0; - struct afe_pseudoport_start_command start; - - pr_debug("%s: port_id=%d\n", __func__, port_id); - if (this_afe.apr == NULL) { - pr_err("%s: AFE APR is not registered\n", __func__); - return -ENODEV; - } - - - start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - start.hdr.pkt_size = sizeof(start); - start.hdr.src_port = 0; - start.hdr.dest_port = 0; - start.hdr.token = 0; - start.hdr.opcode = AFE_PSEUDOPORT_CMD_START; - start.port_id = port_id; - start.timing = 1; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &start); - if (ret < 0) { - pr_err("%s: AFE enable for port %d failed %d\n", - __func__, port_id, ret); - return -EINVAL; - } - return 0; -} - -int afe_start_pseudo_port(u16 port_id) -{ - int ret = 0; - struct afe_pseudoport_start_command start; - - pr_debug("%s: port_id=%d\n", __func__, port_id); - - ret = afe_q6_interface_prepare(); - if (ret != 0) - return ret; - - start.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - start.hdr.pkt_size = sizeof(start); - start.hdr.src_port = 0; - start.hdr.dest_port = 0; - start.hdr.token = 0; - start.hdr.opcode = AFE_PSEUDOPORT_CMD_START; - start.port_id = port_id; - start.timing = 1; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &start); - if (ret < 0) { - pr_err("%s: AFE enable for port %d failed %d\n", - __func__, port_id, ret); - return -EINVAL; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - - return 0; -} - -int afe_pseudo_port_stop_nowait(u16 port_id) -{ - int ret = 0; - struct afe_pseudoport_stop_command stop; - - pr_debug("%s: port_id=%d\n", __func__, port_id); - - if (this_afe.apr == NULL) { - pr_err("%s: AFE is already closed\n", __func__); - return -EINVAL; - } - - stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - stop.hdr.pkt_size = sizeof(stop); - stop.hdr.src_port = 0; - stop.hdr.dest_port = 0; - stop.hdr.token = 0; - stop.hdr.opcode = AFE_PSEUDOPORT_CMD_STOP; - stop.port_id = port_id; - stop.reserved = 0; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &stop); - if (ret < 0) { - pr_err("%s: AFE close failed %d\n", __func__, ret); - return -EINVAL; - } - - return 0; - -} - -int afe_stop_pseudo_port(u16 port_id) -{ - int ret = 0; - struct afe_pseudoport_stop_command stop; - - pr_debug("%s: port_id=%d\n", __func__, port_id); - - if (this_afe.apr == NULL) { - pr_err("%s: AFE is already closed\n", __func__); - return -EINVAL; - } - - stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - stop.hdr.pkt_size = sizeof(stop); - stop.hdr.src_port = 0; - stop.hdr.dest_port = 0; - stop.hdr.token = 0; - stop.hdr.opcode = AFE_PSEUDOPORT_CMD_STOP; - stop.port_id = port_id; - stop.reserved = 0; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &stop); - if (ret < 0) { - pr_err("%s: AFE close failed %d\n", __func__, ret); - return -EINVAL; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - - return 0; -} - -int afe_cmd_memory_map(u32 dma_addr_p, u32 dma_buf_sz) -{ - int ret = 0; - struct afe_cmd_memory_map mregion; - - pr_debug("%s:\n", __func__); - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - - mregion.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mregion.hdr.pkt_size = sizeof(mregion); - mregion.hdr.src_port = 0; - mregion.hdr.dest_port = 0; - mregion.hdr.token = 0; - mregion.hdr.opcode = AFE_SERVICE_CMD_MEMORY_MAP; - mregion.phy_addr = dma_addr_p; - mregion.mem_sz = dma_buf_sz; - mregion.mem_id = 0; - mregion.rsvd = 0; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &mregion); - if (ret < 0) { - pr_err("%s: AFE memory map cmd failed %d\n", - __func__, ret); - ret = -EINVAL; - return ret; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - return ret; - } - - return 0; -} - -int afe_cmd_memory_map_nowait(u32 dma_addr_p, u32 dma_buf_sz) -{ - int ret = 0; - struct afe_cmd_memory_map mregion; - - pr_debug("%s:\n", __func__); - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - - mregion.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mregion.hdr.pkt_size = sizeof(mregion); - mregion.hdr.src_port = 0; - mregion.hdr.dest_port = 0; - mregion.hdr.token = 0; - mregion.hdr.opcode = AFE_SERVICE_CMD_MEMORY_MAP; - mregion.phy_addr = dma_addr_p; - mregion.mem_sz = dma_buf_sz; - mregion.mem_id = 0; - mregion.rsvd = 0; - - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &mregion); - if (ret < 0) { - pr_err("%s: AFE memory map cmd failed %d\n", - __func__, ret); - ret = -EINVAL; - } - return 0; -} - -int afe_cmd_memory_unmap(u32 dma_addr_p) -{ - int ret = 0; - struct afe_cmd_memory_unmap mregion; - - pr_debug("%s:\n", __func__); - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - - mregion.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mregion.hdr.pkt_size = sizeof(mregion); - mregion.hdr.src_port = 0; - mregion.hdr.dest_port = 0; - mregion.hdr.token = 0; - mregion.hdr.opcode = AFE_SERVICE_CMD_MEMORY_UNMAP; - mregion.phy_addr = dma_addr_p; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &mregion); - if (ret < 0) { - pr_err("%s: AFE memory unmap cmd failed %d\n", - __func__, ret); - ret = -EINVAL; - return ret; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - return ret; - } - return 0; -} - -int afe_cmd_memory_unmap_nowait(u32 dma_addr_p) -{ - int ret = 0; - struct afe_cmd_memory_unmap mregion; - - pr_debug("%s:\n", __func__); - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - - mregion.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mregion.hdr.pkt_size = sizeof(mregion); - mregion.hdr.src_port = 0; - mregion.hdr.dest_port = 0; - mregion.hdr.token = 0; - mregion.hdr.opcode = AFE_SERVICE_CMD_MEMORY_UNMAP; - mregion.phy_addr = dma_addr_p; - - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &mregion); - if (ret < 0) { - pr_err("%s: AFE memory unmap cmd failed %d\n", - __func__, ret); - ret = -EINVAL; - } - return 0; -} - -int afe_register_get_events(u16 port_id, - void (*cb) (uint32_t opcode, - uint32_t token, uint32_t *payload, void *priv), - void *private_data) -{ - int ret = 0; - struct afe_cmd_reg_rtport rtproxy; - - pr_debug("%s:\n", __func__); - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - if ((port_id == RT_PROXY_DAI_002_RX) || - (port_id == RT_PROXY_DAI_001_TX)) - port_id = VIRTUAL_ID_TO_PORTID(port_id); - else - return -EINVAL; - - if (port_id == RT_PROXY_PORT_001_TX) { - this_afe.tx_cb = cb; - this_afe.tx_private_data = private_data; - } else if (port_id == RT_PROXY_PORT_001_RX) { - this_afe.rx_cb = cb; - this_afe.rx_private_data = private_data; - } - - rtproxy.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - rtproxy.hdr.pkt_size = sizeof(rtproxy); - rtproxy.hdr.src_port = 1; - rtproxy.hdr.dest_port = 1; - rtproxy.hdr.token = 0; - rtproxy.hdr.opcode = AFE_SERVICE_CMD_REG_RTPORT; - rtproxy.port_id = port_id; - rtproxy.rsvd = 0; - - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &rtproxy); - if (ret < 0) { - pr_err("%s: AFE reg. rtproxy_event failed %d\n", - __func__, ret); - ret = -EINVAL; - return ret; - } - return 0; -} - -int afe_unregister_get_events(u16 port_id) -{ - int ret = 0; - struct afe_cmd_unreg_rtport rtproxy; - - pr_debug("%s:\n", __func__); - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - if ((port_id == RT_PROXY_DAI_002_RX) || - (port_id == RT_PROXY_DAI_001_TX)) - port_id = VIRTUAL_ID_TO_PORTID(port_id); - else - return -EINVAL; - - rtproxy.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - rtproxy.hdr.pkt_size = sizeof(rtproxy); - rtproxy.hdr.src_port = 0; - rtproxy.hdr.dest_port = 0; - rtproxy.hdr.token = 0; - rtproxy.hdr.opcode = AFE_SERVICE_CMD_UNREG_RTPORT; - rtproxy.port_id = port_id; - rtproxy.rsvd = 0; - - if (port_id == RT_PROXY_PORT_001_TX) { - this_afe.tx_cb = NULL; - this_afe.tx_private_data = NULL; - } else if (port_id == RT_PROXY_PORT_001_RX) { - this_afe.rx_cb = NULL; - this_afe.rx_private_data = NULL; - } - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &rtproxy); - if (ret < 0) { - pr_err("%s: AFE enable Unreg. rtproxy_event failed %d\n", - __func__, ret); - ret = -EINVAL; - return ret; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - return ret; - } - return 0; -} - -int afe_rt_proxy_port_write(u32 buf_addr_p, int bytes) -{ - int ret = 0; - struct afe_cmd_rtport_wr afecmd_wr; - - if (this_afe.apr == NULL) { - pr_err("%s:register to AFE is not done\n", __func__); - ret = -ENODEV; - return ret; - } - pr_debug("%s: buf_addr_p = 0x%08x bytes = %d\n", __func__, - buf_addr_p, bytes); - - afecmd_wr.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - afecmd_wr.hdr.pkt_size = sizeof(afecmd_wr); - afecmd_wr.hdr.src_port = 0; - afecmd_wr.hdr.dest_port = 0; - afecmd_wr.hdr.token = 0; - afecmd_wr.hdr.opcode = AFE_SERVICE_CMD_RTPORT_WR; - afecmd_wr.buf_addr = (uint32_t)buf_addr_p; - afecmd_wr.port_id = RT_PROXY_PORT_001_TX; - afecmd_wr.bytes_avail = bytes; - afecmd_wr.rsvd = 0; - - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &afecmd_wr); - if (ret < 0) { - pr_err("%s: AFE rtproxy write to port 0x%x failed %d\n", - __func__, afecmd_wr.port_id, ret); - ret = -EINVAL; - return ret; - } - return 0; - -} - -int afe_rt_proxy_port_read(u32 buf_addr_p, int bytes) -{ - int ret = 0; - struct afe_cmd_rtport_rd afecmd_rd; - - if (this_afe.apr == NULL) { - pr_err("%s: register to AFE is not done\n", __func__); - ret = -ENODEV; - return ret; - } - pr_debug("%s: buf_addr_p = 0x%08x bytes = %d\n", __func__, - buf_addr_p, bytes); - - afecmd_rd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - afecmd_rd.hdr.pkt_size = sizeof(afecmd_rd); - afecmd_rd.hdr.src_port = 0; - afecmd_rd.hdr.dest_port = 0; - afecmd_rd.hdr.token = 0; - afecmd_rd.hdr.opcode = AFE_SERVICE_CMD_RTPORT_RD; - afecmd_rd.buf_addr = (uint32_t)buf_addr_p; - afecmd_rd.port_id = RT_PROXY_PORT_001_RX; - afecmd_rd.bytes_avail = bytes; - afecmd_rd.rsvd = 0; - - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &afecmd_rd); - if (ret < 0) { - pr_err("%s: AFE rtproxy read cmd to port 0x%x failed %d\n", - __func__, afecmd_rd.port_id, ret); - ret = -EINVAL; - return ret; - } - return 0; -} - -#ifdef CONFIG_DEBUG_FS -static struct dentry *debugfs_afelb; -static struct dentry *debugfs_afelb_gain; - -static int afe_debug_open(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - pr_info("debug intf %s\n", (char *) file->private_data); - return 0; -} - -static int afe_get_parameters(char *buf, long int *param1, int num_of_par) -{ - char *token; - int base, cnt; - - token = strsep(&buf, " "); - - for (cnt = 0; cnt < num_of_par; cnt++) { - if (token != NULL) { - if ((token[1] == 'x') || (token[1] == 'X')) - base = 16; - else - base = 10; - - if (strict_strtoul(token, base, ¶m1[cnt]) != 0) - return -EINVAL; - - token = strsep(&buf, " "); - } else - return -EINVAL; - } - return 0; -} -#define AFE_LOOPBACK_ON (1) -#define AFE_LOOPBACK_OFF (0) -static ssize_t afe_debug_write(struct file *filp, - const char __user *ubuf, size_t cnt, loff_t *ppos) -{ - char *lb_str = filp->private_data; - char lbuf[32]; - int rc; - unsigned long param[5]; - - if (cnt > sizeof(lbuf) - 1) - return -EINVAL; - - rc = copy_from_user(lbuf, ubuf, cnt); - if (rc) - return -EFAULT; - - lbuf[cnt] = '\0'; - - if (!strcmp(lb_str, "afe_loopback")) { - rc = afe_get_parameters(lbuf, param, 3); - if (!rc) { - pr_info("%s %lu %lu %lu\n", lb_str, param[0], param[1], - param[2]); - - if ((param[0] != AFE_LOOPBACK_ON) && (param[0] != - AFE_LOOPBACK_OFF)) { - pr_err("%s: Error, parameter 0 incorrect\n", - __func__); - rc = -EINVAL; - goto afe_error; - } - if ((afe_validate_port(param[1]) < 0) || - (afe_validate_port(param[2])) < 0) { - pr_err("%s: Error, invalid afe port\n", - __func__); - } - if (this_afe.apr == NULL) { - pr_err("%s: Error, AFE not opened\n", __func__); - rc = -EINVAL; - } else { - rc = afe_loopback(param[0], param[1], param[2]); - } - } else { - pr_err("%s: Error, invalid parameters\n", __func__); - rc = -EINVAL; - } - - } else if (!strcmp(lb_str, "afe_loopback_gain")) { - rc = afe_get_parameters(lbuf, param, 2); - if (!rc) { - pr_info("%s %lu %lu\n", lb_str, param[0], param[1]); - - if (afe_validate_port(param[0]) < 0) { - pr_err("%s: Error, invalid afe port\n", - __func__); - rc = -EINVAL; - goto afe_error; - } - - if (param[1] > 100) { - pr_err("%s: Error, volume shoud be 0 to 100" - " percentage param = %lu\n", - __func__, param[1]); - rc = -EINVAL; - goto afe_error; - } - - param[1] = (Q6AFE_MAX_VOLUME * param[1]) / 100; - - if (this_afe.apr == NULL) { - pr_err("%s: Error, AFE not opened\n", __func__); - rc = -EINVAL; - } else { - rc = afe_loopback_gain(param[0], param[1]); - } - } else { - pr_err("%s: Error, invalid parameters\n", __func__); - rc = -EINVAL; - } - } - -afe_error: - if (rc == 0) - rc = cnt; - else - pr_err("%s: rc = %d\n", __func__, rc); - - return rc; -} - -static const struct file_operations afe_debug_fops = { - .open = afe_debug_open, - .write = afe_debug_write -}; -#endif - -void afe_set_dtmf_gen_rx_portid(u16 port_id, int set) -{ - if (set) - this_afe.dtmf_gen_rx_portid = port_id; - else if (this_afe.dtmf_gen_rx_portid == port_id) - this_afe.dtmf_gen_rx_portid = -1; -} - -int afe_dtmf_generate_rx(int64_t duration_in_ms, - uint16_t high_freq, - uint16_t low_freq, uint16_t gain) -{ - int ret = 0; - struct afe_dtmf_generation_command cmd_dtmf; - - pr_debug("%s: DTMF AFE Gen\n", __func__); - - if (afe_validate_port(this_afe.dtmf_gen_rx_portid) < 0) { - pr_err("%s: Failed : Invalid Port id = %d\n", - __func__, this_afe.dtmf_gen_rx_portid); - ret = -EINVAL; - goto fail_cmd; - } - - if (this_afe.apr == NULL) { - this_afe.apr = apr_register("ADSP", "AFE", afe_callback, - 0xFFFFFFFF, &this_afe); - pr_debug("%s: Register AFE\n", __func__); - if (this_afe.apr == NULL) { - pr_err("%s: Unable to register AFE\n", __func__); - ret = -ENODEV; - return ret; - } - } - - pr_debug("dur=%lld: hfreq=%d lfreq=%d gain=%d portid=%x\n", - duration_in_ms, high_freq, low_freq, gain, - this_afe.dtmf_gen_rx_portid); - - cmd_dtmf.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cmd_dtmf.hdr.pkt_size = sizeof(cmd_dtmf); - cmd_dtmf.hdr.src_port = 0; - cmd_dtmf.hdr.dest_port = 0; - cmd_dtmf.hdr.token = 0; - cmd_dtmf.hdr.opcode = AFE_PORTS_CMD_DTMF_CTL; - cmd_dtmf.duration_in_ms = duration_in_ms; - cmd_dtmf.high_freq = high_freq; - cmd_dtmf.low_freq = low_freq; - cmd_dtmf.gain = gain; - cmd_dtmf.num_ports = 1; - cmd_dtmf.port_ids = this_afe.dtmf_gen_rx_portid; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &cmd_dtmf); - if (ret < 0) { - pr_err("%s: AFE DTMF failed for num_ports:%d ids:%x\n", - __func__, cmd_dtmf.num_ports, cmd_dtmf.port_ids); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (ret < 0) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - return 0; - -fail_cmd: - return ret; -} - -int afe_sidetone(u16 tx_port_id, u16 rx_port_id, u16 enable, uint16_t gain) -{ - struct afe_port_sidetone_command cmd_sidetone; - int ret = 0; - - pr_info("%s: tx_port_id:%d rx_port_id:%d enable:%d gain:%d\n", __func__, - tx_port_id, rx_port_id, enable, gain); - cmd_sidetone.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cmd_sidetone.hdr.pkt_size = sizeof(cmd_sidetone); - cmd_sidetone.hdr.src_port = 0; - cmd_sidetone.hdr.dest_port = 0; - cmd_sidetone.hdr.token = 0; - cmd_sidetone.hdr.opcode = AFE_PORT_CMD_SIDETONE_CTL; - cmd_sidetone.tx_port_id = tx_port_id; - cmd_sidetone.rx_port_id = rx_port_id; - cmd_sidetone.gain = gain; - cmd_sidetone.enable = enable; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &cmd_sidetone); - if (ret < 0) { - pr_err("%s: AFE sidetone failed for tx_port:%d rx_port:%d\n", - __func__, tx_port_id, rx_port_id); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - return 0; -fail_cmd: - return ret; -} - -int afe_port_stop_nowait(int port_id) -{ - struct afe_port_stop_command stop; - int ret = 0; - - if (this_afe.apr == NULL) { - pr_err("AFE is already closed\n"); - ret = -EINVAL; - goto fail_cmd; - } - pr_debug("%s: port_id=%d\n", __func__, port_id); - port_id = afe_convert_virtual_to_portid(port_id); - - stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - stop.hdr.pkt_size = sizeof(stop); - stop.hdr.src_port = 0; - stop.hdr.dest_port = 0; - stop.hdr.token = 0; - stop.hdr.opcode = AFE_PORT_CMD_STOP; - stop.port_id = port_id; - stop.reserved = 0; - - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &stop); - - if (ret == -ENETRESET) { - pr_info("%s: Need to reset, calling APR deregister", __func__); - return apr_deregister(this_afe.apr); - } else if (IS_ERR_VALUE(ret)) { - pr_err("%s: AFE close failed\n", __func__); - ret = -EINVAL; - } - -fail_cmd: - return ret; - -} - -int afe_close(int port_id) -{ - struct afe_port_stop_command stop; - int ret = 0; - - if (this_afe.apr == NULL) { - pr_err("AFE is already closed\n"); - ret = -EINVAL; - goto fail_cmd; - } - pr_debug("%s: port_id=%d\n", __func__, port_id); - if ((port_id == RT_PROXY_DAI_001_RX) || - (port_id == RT_PROXY_DAI_002_TX)) - return 0; - port_id = afe_convert_virtual_to_portid(port_id); - - stop.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - stop.hdr.pkt_size = sizeof(stop); - stop.hdr.src_port = 0; - stop.hdr.dest_port = 0; - stop.hdr.token = 0; - stop.hdr.opcode = AFE_PORT_CMD_STOP; - stop.port_id = port_id; - stop.reserved = 0; - - atomic_set(&this_afe.state, 1); - ret = apr_send_pkt(this_afe.apr, (uint32_t *) &stop); - - if (ret == -ENETRESET) { - pr_info("%s: Need to reset, calling APR deregister", __func__); - return apr_deregister(this_afe.apr); - } - - if (ret < 0) { - pr_err("%s: AFE close failed\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } - - ret = wait_event_timeout(this_afe.wait, - (atomic_read(&this_afe.state) == 0), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail_cmd; - } -fail_cmd: - return ret; -} - -static int __init afe_init(void) -{ - init_waitqueue_head(&this_afe.wait); - atomic_set(&this_afe.state, 0); - atomic_set(&this_afe.status, 0); - this_afe.apr = NULL; - this_afe.dtmf_gen_rx_portid = -1; -#ifdef CONFIG_DEBUG_FS - debugfs_afelb = debugfs_create_file("afe_loopback", - S_IFREG | S_IWUGO, NULL, (void *) "afe_loopback", - &afe_debug_fops); - - debugfs_afelb_gain = debugfs_create_file("afe_loopback_gain", - S_IFREG | S_IWUGO, NULL, (void *) "afe_loopback_gain", - &afe_debug_fops); - - -#endif - return 0; -} - -static void __exit afe_exit(void) -{ - int i; -#ifdef CONFIG_DEBUG_FS - if (debugfs_afelb) - debugfs_remove(debugfs_afelb); - if (debugfs_afelb_gain) - debugfs_remove(debugfs_afelb_gain); -#endif - for (i = 0; i < MAX_AUDPROC_TYPES; i++) { - if (afe_cal_addr[i].cal_paddr != 0) - afe_cmd_memory_unmap_nowait( - afe_cal_addr[i].cal_paddr); - } -} - -device_initcall(afe_init); -__exitcall(afe_exit); diff --git a/sound/soc/msm/qdsp6/q6asm.c b/sound/soc/msm/qdsp6/q6asm.c deleted file mode 100644 index 659d5a2f64bfb181cdf80537e6548aadd92f6379..0000000000000000000000000000000000000000 --- a/sound/soc/msm/qdsp6/q6asm.c +++ /dev/null @@ -1,4148 +0,0 @@ - -/* - * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. - * Author: Brian Swetland - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - - -#define TRUE 0x01 -#define FALSE 0x00 -#define READDONE_IDX_STATUS 0 -#define READDONE_IDX_BUFFER 1 -#define READDONE_IDX_SIZE 2 -#define READDONE_IDX_OFFSET 3 -#define READDONE_IDX_MSW_TS 4 -#define READDONE_IDX_LSW_TS 5 -#define READDONE_IDX_FLAGS 6 -#define READDONE_IDX_NUMFRAMES 7 -#define READDONE_IDX_ID 8 -#ifdef CONFIG_DEBUG_FS -#define OUT_BUFFER_SIZE 56 -#define IN_BUFFER_SIZE 24 -#endif -static DEFINE_MUTEX(session_lock); - -/* session id: 0 reserved */ -static struct audio_client *session[SESSION_MAX+1]; -static int32_t q6asm_mmapcallback(struct apr_client_data *data, void *priv); -static int32_t q6asm_callback(struct apr_client_data *data, void *priv); -static void q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr, - uint32_t pkt_size, uint32_t cmd_flg); -static void q6asm_add_hdr_async(struct audio_client *ac, struct apr_hdr *hdr, - uint32_t pkt_size, uint32_t cmd_flg); -static int q6asm_memory_map_regions(struct audio_client *ac, int dir, - uint32_t bufsz, uint32_t bufcnt); -static int q6asm_memory_unmap_regions(struct audio_client *ac, int dir, - uint32_t bufsz, uint32_t bufcnt); - -static void q6asm_reset_buf_state(struct audio_client *ac); - -#ifdef CONFIG_DEBUG_FS -static struct timeval out_cold_tv; -static struct timeval out_warm_tv; -static struct timeval out_cont_tv; -static struct timeval in_cont_tv; -static long out_enable_flag; -static long in_enable_flag; -static struct dentry *out_dentry; -static struct dentry *in_dentry; -static int in_cont_index; -/*This var is used to keep track of first write done for cold output latency */ -static int out_cold_index; -static char *out_buffer; -static char *in_buffer; -static int audio_output_latency_dbgfs_open(struct inode *inode, - struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} -static ssize_t audio_output_latency_dbgfs_read(struct file *file, - char __user *buf, size_t count, loff_t *ppos) -{ - snprintf(out_buffer, OUT_BUFFER_SIZE, "%ld,%ld,%ld,%ld,%ld,%ld,",\ - out_cold_tv.tv_sec, out_cold_tv.tv_usec, out_warm_tv.tv_sec,\ - out_warm_tv.tv_usec, out_cont_tv.tv_sec, out_cont_tv.tv_usec); - return simple_read_from_buffer(buf, OUT_BUFFER_SIZE, ppos, - out_buffer, OUT_BUFFER_SIZE); -} -static ssize_t audio_output_latency_dbgfs_write(struct file *file, - const char __user *buf, size_t count, loff_t *ppos) -{ - char *temp; - - if (count > 2*sizeof(char)) - return -EINVAL; - else - temp = kmalloc(2*sizeof(char), GFP_KERNEL); - - out_cold_index = 0; - - if (temp) { - if (copy_from_user(temp, buf, 2*sizeof(char))) { - kfree(temp); - return -EFAULT; - } - if (!strict_strtol(temp, 10, &out_enable_flag)) { - kfree(temp); - return count; - } - kfree(temp); - } - return -EINVAL; -} -static const struct file_operations audio_output_latency_debug_fops = { - .open = audio_output_latency_dbgfs_open, - .read = audio_output_latency_dbgfs_read, - .write = audio_output_latency_dbgfs_write -}; - -static int audio_input_latency_dbgfs_open(struct inode *inode, - struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} -static ssize_t audio_input_latency_dbgfs_read(struct file *file, - char __user *buf, size_t count, loff_t *ppos) -{ - snprintf(in_buffer, IN_BUFFER_SIZE, "%ld,%ld,",\ - in_cont_tv.tv_sec, in_cont_tv.tv_usec); - return simple_read_from_buffer(buf, IN_BUFFER_SIZE, ppos, - in_buffer, IN_BUFFER_SIZE); -} -static ssize_t audio_input_latency_dbgfs_write(struct file *file, - const char __user *buf, size_t count, loff_t *ppos) -{ - char *temp; - - if (count > 2*sizeof(char)) - return -EINVAL; - else - temp = kmalloc(2*sizeof(char), GFP_KERNEL); - if (temp) { - if (copy_from_user(temp, buf, 2*sizeof(char))) { - kfree(temp); - return -EFAULT; - } - if (!strict_strtol(temp, 10, &in_enable_flag)) { - kfree(temp); - return count; - } - kfree(temp); - } - return -EINVAL; -} -static const struct file_operations audio_input_latency_debug_fops = { - .open = audio_input_latency_dbgfs_open, - .read = audio_input_latency_dbgfs_read, - .write = audio_input_latency_dbgfs_write -}; -#endif -struct asm_mmap { - atomic_t ref_cnt; - atomic_t cmd_state; - wait_queue_head_t cmd_wait; - void *apr; -}; - -static struct asm_mmap this_mmap; - -static int q6asm_session_alloc(struct audio_client *ac) -{ - int n; - mutex_lock(&session_lock); - for (n = 1; n <= SESSION_MAX; n++) { - if (!session[n]) { - session[n] = ac; - mutex_unlock(&session_lock); - return n; - } - } - mutex_unlock(&session_lock); - return -ENOMEM; -} - -static void q6asm_session_free(struct audio_client *ac) -{ - pr_debug("%s: sessionid[%d]\n", __func__, ac->session); - rtac_remove_popp_from_adm_devices(ac->session); - mutex_lock(&session_lock); - session[ac->session] = 0; - mutex_unlock(&session_lock); - ac->session = 0; - ac->perf_mode = false; - return; -} - -int q6asm_audio_client_buf_free(unsigned int dir, - struct audio_client *ac) -{ - struct audio_port_data *port; - int cnt = 0; - int rc = 0; - pr_debug("%s: Session id %d\n", __func__, ac->session); - mutex_lock(&ac->cmd_lock); - if (ac->io_mode & SYNC_IO_MODE) { - port = &ac->port[dir]; - if (!port->buf) { - mutex_unlock(&ac->cmd_lock); - return 0; - } - cnt = port->max_buf_cnt - 1; - - if (cnt >= 0) { - rc = q6asm_memory_unmap_regions(ac, dir, - port->buf[0].size, - port->max_buf_cnt); - if (rc < 0) - pr_err("%s CMD Memory_unmap_regions failed\n", - __func__); - } - - while (cnt >= 0) { - if (port->buf[cnt].data) { -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - ion_unmap_kernel(port->buf[cnt].client, - port->buf[cnt].handle); - ion_free(port->buf[cnt].client, - port->buf[cnt].handle); - ion_client_destroy(port->buf[cnt].client); -#else - pr_debug("%s:data[%p]phys[%p][%p] cnt[%d] mem_buffer[%p]\n", - __func__, (void *)port->buf[cnt].data, - (void *)port->buf[cnt].phys, - (void *)&port->buf[cnt].phys, cnt, - (void *)port->buf[cnt].mem_buffer); - if (IS_ERR((void *)port->buf[cnt].mem_buffer)) - pr_err("%s:mem buffer invalid, error = %ld\n", - __func__, - PTR_ERR((void *)port->buf[cnt].mem_buffer)); - else { - if (iounmap( - port->buf[cnt].mem_buffer) < 0) - pr_err("%s: unmap buffer failed\n", - __func__); - } - free_contiguous_memory_by_paddr( - port->buf[cnt].phys); - -#endif - port->buf[cnt].data = NULL; - port->buf[cnt].phys = 0; - --(port->max_buf_cnt); - } - --cnt; - } - kfree(port->buf); - port->buf = NULL; - } - mutex_unlock(&ac->cmd_lock); - return 0; -} - -int q6asm_audio_client_buf_free_contiguous(unsigned int dir, - struct audio_client *ac) -{ - struct audio_port_data *port; - int cnt = 0; - int rc = 0; - pr_debug("%s: Session id %d\n", __func__, ac->session); - mutex_lock(&ac->cmd_lock); - port = &ac->port[dir]; - if (!port->buf) { - mutex_unlock(&ac->cmd_lock); - return 0; - } - cnt = port->max_buf_cnt - 1; - - if (cnt >= 0) { - rc = q6asm_memory_unmap(ac, port->buf[0].phys, dir); - if (rc < 0) - pr_err("%s CMD Memory_unmap_regions failed\n", - __func__); - } - - if (port->buf[0].data) { -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - ion_unmap_kernel(port->buf[0].client, port->buf[0].handle); - ion_free(port->buf[0].client, port->buf[0].handle); - ion_client_destroy(port->buf[0].client); - pr_debug("%s:data[%p]phys[%p][%p], client[%p] handle[%p]\n", - __func__, - (void *)port->buf[0].data, - (void *)port->buf[0].phys, - (void *)&port->buf[0].phys, - (void *)port->buf[0].client, - (void *)port->buf[0].handle); -#else - pr_debug("%s:data[%p]phys[%p][%p] mem_buffer[%p]\n", - __func__, - (void *)port->buf[0].data, - (void *)port->buf[0].phys, - (void *)&port->buf[0].phys, - (void *)port->buf[0].mem_buffer); - if (IS_ERR((void *)port->buf[0].mem_buffer)) - pr_err("%s:mem buffer invalid, error = %ld\n", - __func__, - PTR_ERR((void *)port->buf[0].mem_buffer)); - else { - if (iounmap( - port->buf[0].mem_buffer) < 0) - pr_err("%s: unmap buffer failed\n", __func__); - } - free_contiguous_memory_by_paddr(port->buf[0].phys); -#endif - } - - while (cnt >= 0) { - port->buf[cnt].data = NULL; - port->buf[cnt].phys = 0; - cnt--; - } - port->max_buf_cnt = 0; - kfree(port->buf); - port->buf = NULL; - mutex_unlock(&ac->cmd_lock); - return 0; -} - -void q6asm_audio_client_free(struct audio_client *ac) -{ - int loopcnt; - struct audio_port_data *port; - if (!ac || !ac->session) - return; - pr_debug("%s: Session id %d\n", __func__, ac->session); - if (ac->io_mode & SYNC_IO_MODE) { - for (loopcnt = 0; loopcnt <= OUT; loopcnt++) { - port = &ac->port[loopcnt]; - if (!port->buf) - continue; - pr_debug("%s:loopcnt = %d\n", __func__, loopcnt); - q6asm_audio_client_buf_free(loopcnt, ac); - } - } - - apr_deregister(ac->apr); - q6asm_session_free(ac); - - pr_debug("%s: APR De-Register\n", __func__); - if (atomic_read(&this_mmap.ref_cnt) <= 0) { - pr_err("%s: APR Common Port Already Closed\n", __func__); - goto done; - } - - atomic_dec(&this_mmap.ref_cnt); - if (atomic_read(&this_mmap.ref_cnt) == 0) { - apr_deregister(this_mmap.apr); - pr_debug("%s:APR De-Register common port\n", __func__); - } -done: - kfree(ac); - return; -} - -int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode) -{ - if (ac == NULL) { - pr_err("%s APR handle NULL\n", __func__); - return -EINVAL; - } - - if (mode == ASYNC_IO_MODE) { - ac->io_mode &= ~SYNC_IO_MODE; - ac->io_mode |= ASYNC_IO_MODE; - } else if (mode == SYNC_IO_MODE) { - ac->io_mode &= ~ASYNC_IO_MODE; - ac->io_mode |= SYNC_IO_MODE; - } else { - pr_err("%s:Not an valid IO Mode:%d\n", __func__, ac->io_mode); - return -EINVAL; - } - - pr_debug("%s:Set Mode to %d\n", __func__, ac->io_mode); - return 0; -} - -struct audio_client *q6asm_audio_client_alloc(app_cb cb, void *priv) -{ - struct audio_client *ac; - int n; - int lcnt = 0; - - ac = kzalloc(sizeof(struct audio_client), GFP_KERNEL); - if (!ac) - return NULL; - n = q6asm_session_alloc(ac); - if (n <= 0) - goto fail_session; - ac->session = n; - ac->cb = cb; - ac->priv = priv; - ac->io_mode = SYNC_IO_MODE; - ac->perf_mode = false; - ac->apr = apr_register("ADSP", "ASM", \ - (apr_fn)q6asm_callback,\ - ((ac->session) << 8 | 0x0001),\ - ac); - - if (ac->apr == NULL) { - pr_err("%s Registration with APR failed\n", __func__); - goto fail; - } - rtac_set_asm_handle(n, ac->apr); - - pr_debug("%s Registering the common port with APR\n", __func__); - if (atomic_read(&this_mmap.ref_cnt) == 0) { - this_mmap.apr = apr_register("ADSP", "ASM", \ - (apr_fn)q6asm_mmapcallback,\ - 0x0FFFFFFFF, &this_mmap); - if (this_mmap.apr == NULL) { - pr_debug("%s Unable to register APR ASM common port\n", - __func__); - goto fail; - } - } - - atomic_inc(&this_mmap.ref_cnt); - init_waitqueue_head(&ac->cmd_wait); - init_waitqueue_head(&ac->time_wait); - atomic_set(&ac->time_flag, 1); - mutex_init(&ac->cmd_lock); - for (lcnt = 0; lcnt <= OUT; lcnt++) { - mutex_init(&ac->port[lcnt].lock); - spin_lock_init(&ac->port[lcnt].dsp_lock); - } - atomic_set(&ac->cmd_state, 0); - atomic_set(&ac->cmd_response, 0); - - pr_debug("%s: session[%d]\n", __func__, ac->session); - - return ac; -fail: - q6asm_audio_client_free(ac); - return NULL; -fail_session: - kfree(ac); - return NULL; -} - -struct audio_client *q6asm_get_audio_client(int session_id) -{ - if ((session_id <= 0) || (session_id > SESSION_MAX)) { - pr_err("%s: invalid session: %d\n", __func__, session_id); - goto err; - } - - if (!session[session_id]) { - pr_err("%s: session not active: %d\n", __func__, session_id); - goto err; - } - - return session[session_id]; -err: - return NULL; -} - -int q6asm_audio_client_buf_alloc(unsigned int dir, - struct audio_client *ac, - unsigned int bufsz, - unsigned int bufcnt) -{ - int cnt = 0; - int rc = 0; - struct audio_buffer *buf; -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - int len; - unsigned int bufsz_4k_aligned; -#endif - - if (!(ac) || ((dir != IN) && (dir != OUT))) - return -EINVAL; - - pr_debug("%s: session[%d]bufsz[%d]bufcnt[%d]\n", __func__, ac->session, - bufsz, bufcnt); - - if (ac->session <= 0 || ac->session > 8) - goto fail; - - if (ac->io_mode & SYNC_IO_MODE) { - if (ac->port[dir].buf) { - pr_debug("%s: buffer already allocated\n", __func__); - return 0; - } - mutex_lock(&ac->cmd_lock); - buf = kzalloc(((sizeof(struct audio_buffer))*bufcnt), - GFP_KERNEL); - - if (!buf) { - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - ac->port[dir].buf = buf; - - while (cnt < bufcnt) { - if (bufsz > 0) { - if (!buf[cnt].data) { -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - buf[cnt].client = msm_ion_client_create - (UINT_MAX, "audio_client"); - if (IS_ERR_OR_NULL((void *) - buf[cnt].client)) { - pr_err("%s: ION create client for AUDIO failed\n", - __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - bufsz_4k_aligned = (bufsz + 4095) & - (~4095); - pr_debug("%s: bufsz_4k_aligned %d"\ - "bufsz = %d\n", - __func__, bufsz_4k_aligned, - bufsz); - buf[cnt].handle = ion_alloc - (buf[cnt].client, - bufsz_4k_aligned, SZ_4K, - (0x1 << ION_AUDIO_HEAP_ID), 0); - if (IS_ERR_OR_NULL((void *) - buf[cnt].handle)) { - pr_err("%s: ION memory allocation for AUDIO failed\n", - __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - rc = ion_phys(buf[cnt].client, - buf[cnt].handle, - (ion_phys_addr_t *) - &buf[cnt].phys, - (size_t *)&len); - if (rc) { - pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n", - __func__, rc); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - buf[cnt].data = ion_map_kernel - (buf[cnt].client, buf[cnt].handle); - if (IS_ERR_OR_NULL((void *) - buf[cnt].data)) { - pr_err("%s: ION memory mapping for AUDIO failed\n", - __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - memset((void *)buf[cnt].data, 0, bufsz); -#else - unsigned int flags = 0; - buf[cnt].phys = - allocate_contiguous_ebi_nomap(bufsz, - SZ_4K); - if (!buf[cnt].phys) { - pr_err("%s:Buf alloc failed size=%d\n", - __func__, - bufsz); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - buf[cnt].mem_buffer = - ioremap(buf[cnt].phys, bufsz); - if (IS_ERR( - (void *)buf[cnt].mem_buffer)) { - pr_err("%s:map_buffer failed, error = %ld\n", - __func__, - PTR_ERR((void *)buf[cnt].mem_buffer)); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - buf[cnt].data = - buf[cnt].mem_buffer; - if (!buf[cnt].data) { - pr_err("%s:invalid vaddr, iomap failed\n", - __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } -#endif - buf[cnt].used = 1; - buf[cnt].size = bufsz; - buf[cnt].actual_size = bufsz; - pr_debug("%s data[%p]phys[%p][%p]\n", - __func__, - (void *)buf[cnt].data, - (void *)buf[cnt].phys, - (void *)&buf[cnt].phys); - cnt++; - } - } - } - ac->port[dir].max_buf_cnt = cnt; - - mutex_unlock(&ac->cmd_lock); - rc = q6asm_memory_map_regions(ac, dir, bufsz, cnt); - if (rc < 0) { - pr_err("%s:CMD Memory_map_regions failed\n", __func__); - goto fail; - } - } - return 0; -fail: - q6asm_audio_client_buf_free(dir, ac); - return -EINVAL; -} - -int q6asm_audio_client_buf_alloc_contiguous(unsigned int dir, - struct audio_client *ac, - unsigned int bufsz, - unsigned int bufcnt) -{ - int cnt = 0; - int rc = 0; - struct audio_buffer *buf; -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - int len; -#else - int flags = 0; -#endif - if (!(ac) || ((dir != IN) && (dir != OUT))) - return -EINVAL; - - pr_debug("%s: session[%d]bufsz[%d]bufcnt[%d]\n", - __func__, ac->session, - bufsz, bufcnt); - - if (ac->session <= 0 || ac->session > 8) - goto fail; - - if (ac->port[dir].buf) { - pr_debug("%s: buffer already allocated\n", __func__); - return 0; - } - mutex_lock(&ac->cmd_lock); - buf = kzalloc(((sizeof(struct audio_buffer))*bufcnt), - GFP_KERNEL); - - if (!buf) { - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - ac->port[dir].buf = buf; - -#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION - buf[0].client = msm_ion_client_create(UINT_MAX, "audio_client"); - if (IS_ERR_OR_NULL((void *)buf[0].client)) { - pr_err("%s: ION create client for AUDIO failed\n", __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - buf[0].handle = ion_alloc(buf[0].client, bufsz * bufcnt, SZ_4K, - (0x1 << ION_AUDIO_HEAP_ID), 0); - if (IS_ERR_OR_NULL((void *) buf[0].handle)) { - pr_err("%s: ION memory allocation for AUDIO failed\n", - __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - rc = ion_phys(buf[0].client, buf[0].handle, - (ion_phys_addr_t *)&buf[0].phys, (size_t *)&len); - if (rc) { - pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n", - __func__, rc); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - buf[0].data = ion_map_kernel(buf[0].client, buf[0].handle); - if (IS_ERR_OR_NULL((void *) buf[0].data)) { - pr_err("%s: ION memory mapping for AUDIO failed\n", __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - memset((void *)buf[0].data, 0, (bufsz * bufcnt)); -#else - buf[0].phys = allocate_contiguous_ebi_nomap(bufsz * bufcnt, - SZ_4K); - if (!buf[0].phys) { - pr_err("%s:Buf alloc failed size=%d, bufcnt=%d\n", - __func__, bufsz, bufcnt); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - buf[0].mem_buffer = ioremap(buf[0].phys, bufsz * bufcnt); - if (IS_ERR((void *)buf[cnt].mem_buffer)) { - pr_err("%s:map_buffer failed, error = %ld\n", - __func__, PTR_ERR((void *)buf[0].mem_buffer)); - - mutex_unlock(&ac->cmd_lock); - goto fail; - } - buf[0].data = buf[0].mem_buffer; -#endif - if (!buf[0].data) { - pr_err("%s:invalid vaddr, iomap failed\n", __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - - buf[0].used = dir ^ 1; - buf[0].size = bufsz; - buf[0].actual_size = bufsz; - cnt = 1; - while (cnt < bufcnt) { - if (bufsz > 0) { - buf[cnt].data = buf[0].data + (cnt * bufsz); - buf[cnt].phys = buf[0].phys + (cnt * bufsz); - if (!buf[cnt].data) { - pr_err("%s Buf alloc failed\n", - __func__); - mutex_unlock(&ac->cmd_lock); - goto fail; - } - buf[cnt].used = dir ^ 1; - buf[cnt].size = bufsz; - buf[cnt].actual_size = bufsz; - pr_debug("%s data[%p]phys[%p][%p]\n", __func__, - (void *)buf[cnt].data, - (void *)buf[cnt].phys, - (void *)&buf[cnt].phys); - } - cnt++; - } - ac->port[dir].max_buf_cnt = cnt; - - pr_debug("%s ac->port[%d].max_buf_cnt[%d]\n", __func__, dir, - ac->port[dir].max_buf_cnt); - mutex_unlock(&ac->cmd_lock); - rc = q6asm_memory_map(ac, buf[0].phys, dir, bufsz, cnt); - if (rc < 0) { - pr_err("%s:CMD Memory_map_regions failed\n", __func__); - goto fail; - } - return 0; -fail: - q6asm_audio_client_buf_free_contiguous(dir, ac); - return -EINVAL; -} - -static int32_t q6asm_mmapcallback(struct apr_client_data *data, void *priv) -{ - uint32_t token; - uint32_t *payload = data->payload; - struct audio_client *ac; - - if (data->opcode == RESET_EVENTS) { - pr_debug("%s: Reset event is received: %d %d apr[%p]\n", - __func__, - data->reset_event, - data->reset_proc, - this_mmap.apr); - apr_reset(this_mmap.apr); - this_mmap.apr = NULL; - atomic_set(&this_mmap.cmd_state, 0); - return 0; - } - - pr_debug("%s:ptr0[0x%x]ptr1[0x%x]opcode[0x%x] token[0x%x]payload_s[%d] src[%d] dest[%d]\n", - __func__, payload[0], payload[1], data->opcode, data->token, - data->payload_size, data->src_port, data->dest_port); - - if (data->opcode == APR_BASIC_RSP_RESULT) { - token = data->token; - ac = (struct audio_client *)data->token; - pr_debug("%s: audio_client addr %x\n", __func__, (uint32_t)ac); - switch (payload[0]) { - case ASM_SESSION_CMD_MEMORY_MAP: - case ASM_SESSION_CMD_MEMORY_UNMAP: - case ASM_SESSION_CMD_MEMORY_MAP_REGIONS: - case ASM_SESSION_CMD_MEMORY_UNMAP_REGIONS: - pr_debug("%s:command[0x%x]success [0x%x]\n", - __func__, payload[0], payload[1]); - if (atomic_read(&ac->cmd_state)) { - atomic_set(&ac->cmd_state, 0); - if (payload[1] != ADSP_EOK) { - pr_err("payload[1]:%d error case\n", - payload[1]); - atomic_set(&ac->cmd_response, 1); - } else - atomic_set(&ac->cmd_response, 0); - wake_up(&ac->cmd_wait); - } - break; - default: - pr_debug("%s:command[0x%x] not expecting rsp\n", - __func__, payload[0]); - break; - } - } - return 0; -} - -static int32_t is_no_wait_cmd_rsp(uint32_t opcode, uint32_t *cmd_type) -{ - if (opcode == APR_BASIC_RSP_RESULT) { - if (cmd_type != NULL) { - switch (cmd_type[0]) { - case ASM_SESSION_CMD_RUN: - case ASM_SESSION_CMD_PAUSE: - case ASM_DATA_CMD_EOS: - return 1; - default: - break; - } - } else - pr_err("%s: null pointer!", __func__); - } else if (opcode == ASM_DATA_CMDRSP_EOS) - return 1; - - return 0; -} - -static int32_t q6asm_callback(struct apr_client_data *data, void *priv) -{ - int i = 0; - struct audio_client *ac = (struct audio_client *)priv; - uint32_t token; - unsigned long dsp_flags; - uint32_t *payload; - uint32_t wakeup_flag = 1; - - - if ((ac == NULL) || (data == NULL)) { - pr_err("ac or priv NULL\n"); - return -EINVAL; - } - if (ac->session <= 0 || ac->session > 8) { - pr_err("%s:Session ID is invalid, session = %d\n", __func__, - ac->session); - return -EINVAL; - } - - payload = data->payload; - if ((atomic_read(&ac->nowait_cmd_cnt) > 0) && - is_no_wait_cmd_rsp(data->opcode, payload)) { - pr_debug("%s: nowait_cmd_cnt %d\n", - __func__, - atomic_read(&ac->nowait_cmd_cnt)); - atomic_dec(&ac->nowait_cmd_cnt); - wakeup_flag = 0; - } - - if (data->opcode == RESET_EVENTS) { - pr_debug("q6asm_callback: Reset event is received: %d %d apr[%p]\n", - data->reset_event, data->reset_proc, ac->apr); - if (ac->cb) - ac->cb(data->opcode, data->token, - (uint32_t *)data->payload, ac->priv); - apr_reset(ac->apr); - return 0; - } - - pr_debug("%s: session[%d]opcode[0x%x] token[0x%x]payload_s[%d] src[%d] dest[%d]\n", - __func__, - ac->session, data->opcode, - data->token, data->payload_size, data->src_port, - data->dest_port); - - if (data->opcode == APR_BASIC_RSP_RESULT) { - token = data->token; - pr_debug("%s payload[0]:%x", __func__, payload[0]); - switch (payload[0]) { - case ASM_STREAM_CMD_SET_PP_PARAMS: - if (rtac_make_asm_callback(ac->session, payload, - data->payload_size)) - break; - case ASM_SESSION_CMD_PAUSE: - case ASM_DATA_CMD_EOS: - case ASM_STREAM_CMD_CLOSE: - case ASM_STREAM_CMD_FLUSH: - case ASM_SESSION_CMD_RUN: - case ASM_SESSION_CMD_REGISTER_FOR_TX_OVERFLOW_EVENTS: - case ASM_STREAM_CMD_FLUSH_READBUFS: - pr_debug("%s:Payload = [0x%x]\n", __func__, payload[0]); - if (token != ac->session) { - pr_err("%s:Invalid session[%d] rxed expected[%d]", - __func__, token, ac->session); - return -EINVAL; - } - case ASM_STREAM_CMD_OPEN_READ: - case ASM_STREAM_CMD_OPEN_READ_V2_1: - case ASM_STREAM_CMD_OPEN_WRITE: - case ASM_STREAM_CMD_OPEN_WRITE_V2_1: - case ASM_STREAM_CMD_OPEN_READWRITE: - case ASM_STREAM_CMD_OPEN_LOOPBACK: - case ASM_DATA_CMD_MEDIA_FORMAT_UPDATE: - case ASM_STREAM_CMD_SET_ENCDEC_PARAM: - case ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED: - case ASM_STREAM_CMD_OPEN_READ_COMPRESSED: - case ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK: - if (payload[0] == ASM_STREAM_CMD_CLOSE) { - atomic_set(&ac->cmd_close_state, 0); - wake_up(&ac->cmd_wait); - } else if (atomic_read(&ac->cmd_state) && - wakeup_flag) { - atomic_set(&ac->cmd_state, 0); - pr_debug("response payload[1]:%d", - payload[1]); - if (payload[1] == ADSP_EUNSUPPORTED || - payload[1] == ADSP_EBADPARAM || - payload[1] == ADSP_EFAILED) { - atomic_set(&ac->cmd_response, 1); - } - else - atomic_set(&ac->cmd_response, 0); - wake_up(&ac->cmd_wait); - } - if (ac->cb) - ac->cb(data->opcode, data->token, - (uint32_t *)data->payload, ac->priv); - break; - default: - pr_debug("%s:command[0x%x] not expecting rsp\n", - __func__, payload[0]); - break; - } - return 0; - } - - switch (data->opcode) { - case ASM_DATA_EVENT_WRITE_DONE:{ - struct audio_port_data *port = &ac->port[IN]; - pr_debug("%s: Rxed opcode[0x%x] status[0x%x] token[%d]", - __func__, payload[0], payload[1], - data->token); - if (ac->io_mode & SYNC_IO_MODE) { - if (port->buf == NULL) { - pr_err("%s: Unexpected Write Done\n", - __func__); - return -EINVAL; - } - spin_lock_irqsave(&port->dsp_lock, dsp_flags); - if (port->buf[data->token].phys != - payload[0]) { - pr_err("Buf expected[%p]rxed[%p]\n",\ - (void *)port->buf[data->token].phys,\ - (void *)payload[0]); - spin_unlock_irqrestore(&port->dsp_lock, - dsp_flags); - return -EINVAL; - } - token = data->token; - port->buf[token].used = 1; - spin_unlock_irqrestore(&port->dsp_lock, dsp_flags); -#ifdef CONFIG_DEBUG_FS - if (out_enable_flag) { - /* For first Write done log the time and reset - out_cold_index*/ - if (out_cold_index != 1) { - do_gettimeofday(&out_cold_tv); - pr_debug("COLD: apr_send_pkt at %ld sec %ld microsec\n", - out_cold_tv.tv_sec, - out_cold_tv.tv_usec); - out_cold_index = 1; - } - pr_debug("out_enable_flag %ld",\ - out_enable_flag); - } -#endif - for (i = 0; i < port->max_buf_cnt; i++) - pr_debug("%d ", port->buf[i].used); - - } - break; - } - case ASM_STREAM_CMDRSP_GET_PP_PARAMS: - rtac_make_asm_callback(ac->session, payload, - data->payload_size); - break; - case ASM_DATA_EVENT_READ_DONE:{ - - struct audio_port_data *port = &ac->port[OUT]; -#ifdef CONFIG_DEBUG_FS - if (in_enable_flag) { - /* when in_cont_index == 7, DSP would be - * writing into the 8th 512 byte buffer and this - * timestamp is tapped here.Once done it then writes - * to 9th 512 byte buffer.These two buffers(8th, 9th) - * reach the test application in 5th iteration and that - * timestamp is tapped at user level. The difference - * of these two timestamps gives us the time between - * the time at which dsp started filling the sample - * required and when it reached the test application. - * Hence continuous input latency - */ - if (in_cont_index == 7) { - do_gettimeofday(&in_cont_tv); - pr_err("In_CONT:previous read buffer done at %ld sec %ld microsec\n", - in_cont_tv.tv_sec, in_cont_tv.tv_usec); - } - } -#endif - pr_debug("%s:R-D: status=%d buff_add=%x act_size=%d offset=%d\n", - __func__, payload[READDONE_IDX_STATUS], - payload[READDONE_IDX_BUFFER], - payload[READDONE_IDX_SIZE], - payload[READDONE_IDX_OFFSET]); - pr_debug("%s:R-D:msw_ts=%d lsw_ts=%d flags=%d id=%d num=%d\n", - __func__, payload[READDONE_IDX_MSW_TS], - payload[READDONE_IDX_LSW_TS], - payload[READDONE_IDX_FLAGS], - payload[READDONE_IDX_ID], - payload[READDONE_IDX_NUMFRAMES]); -#ifdef CONFIG_DEBUG_FS - if (in_enable_flag) - in_cont_index++; -#endif - if (ac->io_mode & SYNC_IO_MODE) { - if (port->buf == NULL) { - pr_err("%s: Unexpected Write Done\n", __func__); - return -EINVAL; - } - spin_lock_irqsave(&port->dsp_lock, dsp_flags); - token = data->token; - port->buf[token].used = 0; - if (port->buf[token].phys != - payload[READDONE_IDX_BUFFER]) { - pr_err("Buf expected[%p]rxed[%p]\n",\ - (void *)port->buf[token].phys,\ - (void *)payload[READDONE_IDX_BUFFER]); - spin_unlock_irqrestore(&port->dsp_lock, - dsp_flags); - break; - } - port->buf[token].actual_size = - payload[READDONE_IDX_SIZE]; - spin_unlock_irqrestore(&port->dsp_lock, dsp_flags); - } - break; - } - case ASM_DATA_EVENT_EOS: - case ASM_DATA_CMDRSP_EOS: - pr_debug("%s:EOS ACK received: rxed opcode[0x%x]\n", - __func__, data->opcode); - break; - case ASM_STREAM_CMDRSP_GET_ENCDEC_PARAM: - break; - case ASM_SESSION_EVENT_TX_OVERFLOW: - pr_err("ASM_SESSION_EVENT_TX_OVERFLOW\n"); - break; - case ASM_SESSION_CMDRSP_GET_SESSION_TIME: - pr_debug("%s: ASM_SESSION_CMDRSP_GET_SESSION_TIME, payload[0] = %d, payload[1] = %d, payload[2] = %d\n", - __func__, - payload[0], payload[1], payload[2]); - ac->time_stamp = (uint64_t)(((uint64_t)payload[1] << 32) | - payload[2]); - if (atomic_read(&ac->time_flag)) { - atomic_set(&ac->time_flag, 0); - wake_up(&ac->time_wait); - } - break; - case ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY: - case ASM_DATA_EVENT_ENC_SR_CM_NOTIFY: - pr_debug("%s: ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY, payload[0] = %d, payload[1] = %d, payload[2] = %d, payload[3] = %d\n", - __func__, - payload[0], payload[1], payload[2], - payload[3]); - break; - } - if (ac->cb) - ac->cb(data->opcode, data->token, - data->payload, ac->priv); - - return 0; -} - -int q6asm_open_transcode_loopback(struct audio_client *ac, uint32_t channels) -{ - int rc = 0x00; - struct asm_stream_cmd_open_transcode_loopback open; - - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - pr_debug("%s: session[%d] channels = %d", __func__, ac->session, - channels); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - - open.hdr.opcode = ASM_STREAM_CMD_OPEN_TRANSCODE_LOOPBACK; - - open.mode_flags = 0; - - if (channels > 2) - open.src_format_id = MULTI_CHANNEL_PCM; - else - open.src_format_id = LINEAR_PCM; - - - open.sink_format_id = DTS; - open.audproc_topo_id = DEFAULT_POPP_TOPOLOGY; - open.src_endpoint_type = 0; - open.sink_endpoint_type = 0; - open.bits_per_sample = 16; - open.reserved = 0; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("%s: open failed op[0x%x]rc[%d]\n", \ - __func__, open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout. waited for OPEN_WRITE rc[%d]\n", __func__, - rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enc_cfg_blk_dts(struct audio_client *ac, - uint32_t sample_rate, - uint32_t channels) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - int rc = 0; - - pr_debug("%s: sample_rate=%d,channels=%d\n", __func__, - sample_rate, channels); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - enc_cfg.enc_blk.frames_per_buf = 0; - enc_cfg.enc_blk.format_id = DTS; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_dts_enc_cfg); - enc_cfg.enc_blk.cfg.dts.sample_rate = sample_rate; - enc_cfg.enc_blk.cfg.dts.num_channels = channels; - if (channels == 1) { - enc_cfg.enc_blk.cfg.dts.channel_mapping[0] = PCM_CHANNEL_FC; - } else if (channels == 2) { - enc_cfg.enc_blk.cfg.dts.channel_mapping[0] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.dts.channel_mapping[1] = PCM_CHANNEL_FR; - enc_cfg.enc_blk.cfg.dts.channel_mapping[2] = 0; - enc_cfg.enc_blk.cfg.dts.channel_mapping[3] = 0; - enc_cfg.enc_blk.cfg.dts.channel_mapping[4] = 0; - enc_cfg.enc_blk.cfg.dts.channel_mapping[5] = 0; - } else if (channels == 4) { - enc_cfg.enc_blk.cfg.dts.channel_mapping[0] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.dts.channel_mapping[1] = PCM_CHANNEL_FR; - enc_cfg.enc_blk.cfg.dts.channel_mapping[2] = PCM_CHANNEL_LS; - enc_cfg.enc_blk.cfg.dts.channel_mapping[3] = PCM_CHANNEL_RS; - enc_cfg.enc_blk.cfg.dts.channel_mapping[4] = 0; - enc_cfg.enc_blk.cfg.dts.channel_mapping[5] = 0; - } else if (channels == 6) { - enc_cfg.enc_blk.cfg.dts.channel_mapping[0] = PCM_CHANNEL_FC; - enc_cfg.enc_blk.cfg.dts.channel_mapping[1] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.dts.channel_mapping[2] = PCM_CHANNEL_FR; - enc_cfg.enc_blk.cfg.dts.channel_mapping[3] = PCM_CHANNEL_LS; - enc_cfg.enc_blk.cfg.dts.channel_mapping[4] = PCM_CHANNEL_RS; - enc_cfg.enc_blk.cfg.dts.channel_mapping[5] = PCM_CHANNEL_LFE; - } - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd %d failed\n", ASM_STREAM_CMD_SET_ENCDEC_PARAM); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for FORMAT_UPDATE\n"); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -void *q6asm_is_cpu_buf_avail(int dir, struct audio_client *ac, uint32_t *size, - uint32_t *index) -{ - void *data; - unsigned char idx; - struct audio_port_data *port; - - if (!ac || ((dir != IN) && (dir != OUT))) - return NULL; - - if (ac->io_mode & SYNC_IO_MODE) { - port = &ac->port[dir]; - - mutex_lock(&port->lock); - idx = port->cpu_buf; - if (port->buf == NULL) { - pr_debug("%s:Buffer pointer null\n", __func__); - mutex_unlock(&port->lock); - return NULL; - } - /* dir 0: used = 0 means buf in use - dir 1: used = 1 means buf in use */ - if (port->buf[idx].used == dir) { - /* To make it more robust, we could loop and get the - next avail buf, its risky though */ - pr_debug("%s:Next buf idx[0x%x] not available,dir[%d]\n", - __func__, idx, dir); - mutex_unlock(&port->lock); - return NULL; - } - *size = port->buf[idx].actual_size; - *index = port->cpu_buf; - data = port->buf[idx].data; - pr_debug("%s:session[%d]index[%d] data[%p]size[%d]\n", - __func__, - ac->session, - port->cpu_buf, - data, *size); - /* By default increase the cpu_buf cnt - user accesses this function,increase cpu - buf(to avoid another api)*/ - port->buf[idx].used = dir; - port->cpu_buf = ((port->cpu_buf + 1) & (port->max_buf_cnt - 1)); - mutex_unlock(&port->lock); - return data; - } - return NULL; -} - -void *q6asm_is_cpu_buf_avail_nolock(int dir, struct audio_client *ac, - uint32_t *size, uint32_t *index) -{ - void *data; - unsigned char idx; - struct audio_port_data *port; - - if (!ac || ((dir != IN) && (dir != OUT))) - return NULL; - - port = &ac->port[dir]; - - idx = port->cpu_buf; - if (port->buf == NULL) { - pr_debug("%s:Buffer pointer null\n", __func__); - return NULL; - } - /* - * dir 0: used = 0 means buf in use - * dir 1: used = 1 means buf in use - */ - if (port->buf[idx].used == dir) { - /* - * To make it more robust, we could loop and get the - * next avail buf, its risky though - */ - pr_debug("%s:Next buf idx[0x%x] not available, dir[%d]\n", - __func__, idx, dir); - return NULL; - } - *size = port->buf[idx].actual_size; - *index = port->cpu_buf; - data = port->buf[idx].data; - pr_debug("%s:session[%d]index[%d] data[%p]size[%d]\n", - __func__, ac->session, port->cpu_buf, - data, *size); - /* - * By default increase the cpu_buf cnt - * user accesses this function,increase cpu - * buf(to avoid another api) - */ - port->buf[idx].used = dir; - port->cpu_buf = ((port->cpu_buf + 1) & (port->max_buf_cnt - 1)); - return data; -} - -int q6asm_is_dsp_buf_avail(int dir, struct audio_client *ac) -{ - int ret = -1; - struct audio_port_data *port; - uint32_t idx; - - if (!ac || (dir != OUT)) - return ret; - - if (ac->io_mode & SYNC_IO_MODE) { - port = &ac->port[dir]; - - mutex_lock(&port->lock); - idx = port->dsp_buf; - - if (port->buf[idx].used == (dir ^ 1)) { - /* To make it more robust, we could loop and get the - next avail buf, its risky though */ - pr_err("Next buf idx[0x%x] not available, dir[%d]\n", - idx, dir); - mutex_unlock(&port->lock); - return ret; - } - pr_debug("%s: session[%d]dsp_buf=%d cpu_buf=%d\n", __func__, - ac->session, port->dsp_buf, port->cpu_buf); - ret = ((port->dsp_buf != port->cpu_buf) ? 0 : -1); - mutex_unlock(&port->lock); - } - return ret; -} - -static void q6asm_add_hdr(struct audio_client *ac, struct apr_hdr *hdr, - uint32_t pkt_size, uint32_t cmd_flg) -{ - pr_debug("%s:session=%d pkt size=%d cmd_flg=%d\n", __func__, pkt_size, - cmd_flg, ac->session); - mutex_lock(&ac->cmd_lock); - hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, \ - APR_HDR_LEN(sizeof(struct apr_hdr)),\ - APR_PKT_VER); - hdr->src_svc = ((struct apr_svc *)ac->apr)->id; - hdr->src_domain = APR_DOMAIN_APPS; - hdr->dest_svc = APR_SVC_ASM; - hdr->dest_domain = APR_DOMAIN_ADSP; - hdr->src_port = ((ac->session << 8) & 0xFF00) | 0x01; - hdr->dest_port = ((ac->session << 8) & 0xFF00) | 0x01; - if (cmd_flg) { - hdr->token = ac->session; - atomic_set(&ac->cmd_state, 1); - } - hdr->pkt_size = pkt_size; - mutex_unlock(&ac->cmd_lock); - return; -} - -static void q6asm_add_mmaphdr(struct apr_hdr *hdr, uint32_t pkt_size, - uint32_t cmd_flg) -{ - struct audio_client *ac; - pr_debug("%s:pkt size=%d cmd_flg=%d\n", __func__, pkt_size, cmd_flg); - ac = (struct audio_client *)hdr->token; - pr_debug("%s: audio_client = %x\n", __func__, (uint32_t)ac); - hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, \ - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - hdr->src_port = 0; - hdr->dest_port = 0; - if (cmd_flg) { - atomic_set(&ac->cmd_state, 1); - } - hdr->pkt_size = pkt_size; - return; -} - -int q6asm_open_read(struct audio_client *ac, - uint32_t format) -{ - int rc = 0x00; - struct asm_stream_cmd_open_read open; -#ifdef CONFIG_DEBUG_FS - in_cont_index = 0; -#endif - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - pr_debug("%s:session[%d]", __func__, ac->session); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - open.hdr.opcode = ASM_STREAM_CMD_OPEN_READ; - /* Stream prio : High, provide meta info with encoded frames */ - open.src_endpoint = ASM_END_POINT_DEVICE_MATRIX; - - open.pre_proc_top = get_asm_topology(); - if (open.pre_proc_top == 0) - open.pre_proc_top = DEFAULT_POPP_TOPOLOGY; - - switch (format) { - case FORMAT_LINEAR_PCM: - open.uMode = STREAM_PRIORITY_HIGH; - open.format = LINEAR_PCM; - break; - case FORMAT_MULTI_CHANNEL_LINEAR_PCM: - open.uMode = STREAM_PRIORITY_HIGH; - open.format = MULTI_CHANNEL_PCM; - break; - case FORMAT_MPEG4_AAC: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = MPEG4_AAC; - break; - case FORMAT_V13K: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = V13K_FS; - break; - case FORMAT_EVRC: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = EVRC_FS; - break; - case FORMAT_AMRNB: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = AMRNB_FS; - break; - case FORMAT_AMRWB: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = AMRWB_FS; - break; - default: - pr_err("Invalid format[%d]\n", format); - goto fail_cmd; - } - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("open failed op[0x%x]rc[%d]\n", \ - open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout. waited for OPEN_WRITE rc[%d]\n", __func__, - rc); - goto fail_cmd; - } - - ac->io_mode |= TUN_READ_IO_MODE; - - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_open_read_v2_1(struct audio_client *ac, - uint32_t format) -{ - int rc = 0x00; - struct asm_stream_cmd_open_read_v2_1 open; -#ifdef CONFIG_DEBUG_FS - in_cont_index = 0; -#endif - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - pr_debug("%s:session[%d]", __func__, ac->session); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - open.hdr.opcode = ASM_STREAM_CMD_OPEN_READ_V2_1; - open.src_endpoint = ASM_END_POINT_DEVICE_MATRIX; - open.pre_proc_top = get_asm_topology(); - if (open.pre_proc_top == 0) - open.pre_proc_top = DEFAULT_POPP_TOPOLOGY; - - switch (format) { - case FORMAT_LINEAR_PCM: - open.uMode = STREAM_PRIORITY_HIGH; - open.format = LINEAR_PCM; - break; - case FORMAT_MULTI_CHANNEL_LINEAR_PCM: - open.uMode = STREAM_PRIORITY_HIGH; - open.format = MULTI_CHANNEL_PCM; - break; - case FORMAT_MPEG4_AAC: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = MPEG4_AAC; - break; - case FORMAT_V13K: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = V13K_FS; - break; - case FORMAT_EVRC: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = EVRC_FS; - break; - case FORMAT_AMRNB: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = AMRNB_FS; - break; - case FORMAT_AMRWB: - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_HIGH; - open.format = AMRWB_FS; - break; - default: - pr_err("Invalid format[%d]\n", format); - goto fail_cmd; - } - open.uMode = ASM_OPEN_READ_PERF_MODE_BIT; - open.bits_per_sample = PCM_BITS_PER_SAMPLE; - open.reserved = 0; - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("open failed op[0x%x]rc[%d]\n", \ - open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout. waited for OPEN_WRITE rc[%d]\n", __func__, - rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - - -int q6asm_open_read_compressed(struct audio_client *ac, - uint32_t frames_per_buffer, uint32_t meta_data_mode) -{ - int rc = 0x00; - struct asm_stream_cmd_open_read_compressed open; -#ifdef CONFIG_DEBUG_FS - in_cont_index = 0; -#endif - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - pr_debug("%s:session[%d]", __func__, ac->session); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - open.hdr.opcode = ASM_STREAM_CMD_OPEN_READ_COMPRESSED; - /* hardcoded as following*/ - open.frame_per_buf = frames_per_buffer; - open.uMode = meta_data_mode; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("open failed op[0x%x]rc[%d]\n", open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout. waited for OPEN_READ_COMPRESSED rc[%d]\n", - __func__, rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_open_write_compressed(struct audio_client *ac, uint32_t format) -{ - int rc = 0x00; - struct asm_stream_cmd_open_write_compressed open; - - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - pr_debug("%s: session[%d] wr_format[0x%x]", __func__, ac->session, - format); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - - open.hdr.opcode = ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED; - - switch (format) { - case FORMAT_AC3: - open.format = AC3_DECODER; - break; - case FORMAT_EAC3: - open.format = EAC3_DECODER; - break; - case FORMAT_MP3: - open.format = MP3; - break; - case FORMAT_DTS: - open.format = DTS; - break; - case FORMAT_DTS_LBR: - open.format = DTS_LBR; - break; - case FORMAT_AAC: - open.format = MPEG4_AAC; - break; - case FORMAT_ATRAC: - open.format = ATRAC; - break; - case FORMAT_WMA_V10PRO: - open.format = WMA_V10PRO; - break; - case FORMAT_MAT: - open.format = MAT; - break; - case FORMAT_MP2: - open.format = MP2; - break; - default: - pr_err("%s: Invalid format[%d]\n", __func__, format); - goto fail_cmd; - } - /*Below flag indicates the DSP that Compressed audio input - stream is not IEC 61937 or IEC 60958 packetizied*/ - open.flags = 0x00000000; - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("%s: open failed op[0x%x]rc[%d]\n", \ - __func__, open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout. waited for OPEN_WRITE rc[%d]\n", __func__, - rc); - goto fail_cmd; - } - if (atomic_read(&ac->cmd_response)) { - pr_err("%s: format = %x not supported\n", __func__, format); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_open_write(struct audio_client *ac, uint32_t format) -{ - int rc = 0x00; - struct asm_stream_cmd_open_write open; - - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - pr_debug("%s: session[%d] wr_format[0x%x]", __func__, ac->session, - format); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - - if (ac->perf_mode) { - pr_debug("%s In Performance/lowlatency mode", __func__); - open.hdr.opcode = ASM_STREAM_CMD_OPEN_WRITE_V2_1; - open.uMode = ASM_OPEN_WRITE_PERF_MODE_BIT; - /* source endpoint : matrix */ - open.sink_endpoint = ASM_END_POINT_DEVICE_MATRIX; - open.stream_handle = PCM_BITS_PER_SAMPLE; - } else { - open.hdr.opcode = ASM_STREAM_CMD_OPEN_WRITE; - open.uMode = STREAM_PRIORITY_HIGH; - /* source endpoint : matrix */ - open.sink_endpoint = ASM_END_POINT_DEVICE_MATRIX; - open.stream_handle = 0x00; - } - open.post_proc_top = get_asm_topology(); - if (open.post_proc_top == 0) - open.post_proc_top = DEFAULT_POPP_TOPOLOGY; - - switch (format) { - case FORMAT_LINEAR_PCM: - open.format = LINEAR_PCM; - break; - case FORMAT_MULTI_CHANNEL_LINEAR_PCM: - open.format = MULTI_CHANNEL_PCM; - break; - case FORMAT_MPEG4_AAC: - open.format = MPEG4_AAC; - break; - case FORMAT_MPEG4_MULTI_AAC: - open.format = MPEG4_MULTI_AAC; - break; - case FORMAT_WMA_V9: - open.format = WMA_V9; - break; - case FORMAT_WMA_V10PRO: - open.format = WMA_V10PRO; - break; - case FORMAT_MP3: - open.format = MP3; - break; - case FORMAT_DTS: - open.format = DTS; - break; - case FORMAT_DTS_LBR: - open.format = DTS_LBR; - break; - case FORMAT_AMRWB: - open.format = AMRWB_FS; - pr_debug("q6asm_open_write FORMAT_AMRWB"); - break; - case FORMAT_AMR_WB_PLUS: - open.format = AMR_WB_PLUS; - pr_debug("q6asm_open_write FORMAT_AMR_WB_PLUS"); - break; - case FORMAT_MP2: - open.format = MP2; - break; - default: - pr_err("%s: Invalid format[%d]\n", __func__, format); - goto fail_cmd; - } - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("%s: open failed op[0x%x]rc[%d]\n", \ - __func__, open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout. waited for OPEN_WRITE rc[%d]\n", __func__, - rc); - goto fail_cmd; - } - if (atomic_read(&ac->cmd_response)) { - pr_err("%s: format = %x not supported\n", __func__, format); - goto fail_cmd; - } - - ac->io_mode |= TUN_WRITE_IO_MODE; - - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_open_read_write(struct audio_client *ac, - uint32_t rd_format, - uint32_t wr_format) -{ - int rc = 0x00; - struct asm_stream_cmd_open_read_write open; - - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s: session[%d]", __func__, ac->session); - pr_debug("wr_format[0x%x]rd_format[0x%x]", - wr_format, rd_format); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - open.hdr.opcode = ASM_STREAM_CMD_OPEN_READWRITE; - - open.uMode = BUFFER_META_ENABLE | STREAM_PRIORITY_NORMAL; - /* source endpoint : matrix */ - open.post_proc_top = get_asm_topology(); - if (open.post_proc_top == 0) - open.post_proc_top = DEFAULT_POPP_TOPOLOGY; - - switch (wr_format) { - case FORMAT_LINEAR_PCM: - open.write_format = LINEAR_PCM; - break; - case FORMAT_MPEG4_AAC: - open.write_format = MPEG4_AAC; - break; - case FORMAT_MPEG4_MULTI_AAC: - open.write_format = MPEG4_MULTI_AAC; - break; - case FORMAT_WMA_V9: - open.write_format = WMA_V9; - break; - case FORMAT_WMA_V10PRO: - open.write_format = WMA_V10PRO; - break; - case FORMAT_AMRNB: - open.write_format = AMRNB_FS; - break; - case FORMAT_AMRWB: - open.write_format = AMRWB_FS; - break; - case FORMAT_AMR_WB_PLUS: - open.write_format = AMR_WB_PLUS; - break; - case FORMAT_V13K: - open.write_format = V13K_FS; - break; - case FORMAT_EVRC: - open.write_format = EVRC_FS; - break; - case FORMAT_EVRCB: - open.write_format = EVRCB_FS; - break; - case FORMAT_EVRCWB: - open.write_format = EVRCWB_FS; - break; - case FORMAT_MP3: - open.write_format = MP3; - break; - case FORMAT_MP2: - open.write_format = MP2; - break; - default: - pr_err("Invalid format[%d]\n", wr_format); - goto fail_cmd; - } - - switch (rd_format) { - case FORMAT_LINEAR_PCM: - open.read_format = LINEAR_PCM; - break; - case FORMAT_MPEG4_AAC: - open.read_format = MPEG4_AAC; - break; - case FORMAT_V13K: - open.read_format = V13K_FS; - break; - case FORMAT_EVRC: - open.read_format = EVRC_FS; - break; - case FORMAT_AMRNB: - open.read_format = AMRNB_FS; - break; - case FORMAT_AMRWB: - open.read_format = AMRWB_FS; - break; - default: - pr_err("Invalid format[%d]\n", rd_format); - goto fail_cmd; - } - pr_debug("%s:rdformat[0x%x]wrformat[0x%x]\n", __func__, - open.read_format, open.write_format); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("open failed op[0x%x]rc[%d]\n", \ - open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for OPEN_WRITE rc[%d]\n", rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_open_loopack(struct audio_client *ac) -{ - int rc = 0x00; - struct asm_stream_cmd_open_loopback open; - - if ((ac == NULL) || (ac->apr == NULL)) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s: session[%d]", __func__, ac->session); - - q6asm_add_hdr(ac, &open.hdr, sizeof(open), TRUE); - open.hdr.opcode = ASM_STREAM_CMD_OPEN_LOOPBACK; - - open.mode_flags = 0; - open.src_endpointype = 0; - open.sink_endpointype = 0; - /* source endpoint : matrix */ - open.postprocopo_id = get_asm_topology(); - if (open.postprocopo_id == 0) - open.postprocopo_id = DEFAULT_POPP_TOPOLOGY; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &open); - if (rc < 0) { - pr_err("open failed op[0x%x]rc[%d]\n", \ - open.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for OPEN_WRITE rc[%d]\n", rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_run(struct audio_client *ac, uint32_t flags, - uint32_t msw_ts, uint32_t lsw_ts) -{ - struct asm_stream_cmd_run run; - int rc; - if (!ac || ac->apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s session[%d]", __func__, ac->session); - q6asm_add_hdr(ac, &run.hdr, sizeof(run), TRUE); - - run.hdr.opcode = ASM_SESSION_CMD_RUN; - run.flags = flags; - run.msw_ts = msw_ts; - run.lsw_ts = lsw_ts; -#ifdef CONFIG_DEBUG_FS - if (out_enable_flag) { - do_gettimeofday(&out_cold_tv); - pr_debug("COLD: apr_send_pkt at %ld sec %ld microsec\n",\ - out_cold_tv.tv_sec, out_cold_tv.tv_usec); - } -#endif - rc = apr_send_pkt(ac->apr, (uint32_t *) &run); - if (rc < 0) { - pr_err("Commmand run failed[%d]", rc); - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for run success rc[%d]", rc); - goto fail_cmd; - } - - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_run_nowait(struct audio_client *ac, uint32_t flags, - uint32_t msw_ts, uint32_t lsw_ts) -{ - struct asm_stream_cmd_run run; - int rc; - if (!ac || ac->apr == NULL) { - pr_err("%s:APR handle NULL\n", __func__); - return -EINVAL; - } - pr_debug("session[%d]", ac->session); - q6asm_add_hdr_async(ac, &run.hdr, sizeof(run), TRUE); - - run.hdr.opcode = ASM_SESSION_CMD_RUN; - run.flags = flags; - run.msw_ts = msw_ts; - run.lsw_ts = lsw_ts; - rc = apr_send_pkt(ac->apr, (uint32_t *) &run); - if (rc < 0) { - pr_err("%s:Commmand run failed[%d]", __func__, rc); - return -EINVAL; - } - atomic_inc(&ac->nowait_cmd_cnt); - return 0; -} - - -int q6asm_enc_cfg_blk_aac(struct audio_client *ac, - uint32_t frames_per_buf, - uint32_t sample_rate, uint32_t channels, - uint32_t bit_rate, uint32_t mode, uint32_t format) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - int rc = 0; - - pr_debug("%s:session[%d]frames[%d]SR[%d]ch[%d]bitrate[%d]mode[%d] format[%d]", - __func__, ac->session, frames_per_buf, - sample_rate, channels, bit_rate, mode, format); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - enc_cfg.enc_blk.frames_per_buf = frames_per_buf; - enc_cfg.enc_blk.format_id = MPEG4_AAC; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_aac_read_cfg); - enc_cfg.enc_blk.cfg.aac.bitrate = bit_rate; - enc_cfg.enc_blk.cfg.aac.enc_mode = mode; - enc_cfg.enc_blk.cfg.aac.format = format; - enc_cfg.enc_blk.cfg.aac.ch_cfg = channels; - enc_cfg.enc_blk.cfg.aac.sample_rate = sample_rate; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd %d failed\n", ASM_STREAM_CMD_SET_ENCDEC_PARAM); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for FORMAT_UPDATE\n"); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enc_cfg_blk_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - - int rc = 0; - - pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__, - ac->session, rate, channels); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - enc_cfg.enc_blk.frames_per_buf = 1; - enc_cfg.enc_blk.format_id = LINEAR_PCM; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_pcm_cfg); - enc_cfg.enc_blk.cfg.pcm.ch_cfg = channels; - enc_cfg.enc_blk.cfg.pcm.bits_per_sample = 16; - enc_cfg.enc_blk.cfg.pcm.sample_rate = rate; - enc_cfg.enc_blk.cfg.pcm.is_signed = 1; - enc_cfg.enc_blk.cfg.pcm.interleaved = 1; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd open failed\n"); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout opcode[0x%x] ", enc_cfg.hdr.opcode); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac, - uint32_t rate, uint32_t channels) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - - int rc = 0; - - pr_debug("%s: Session %d, rate = %d, channels = %d, setting the rate and channels to 0 for native\n", - __func__, ac->session, rate, channels); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - enc_cfg.enc_blk.frames_per_buf = 1; - enc_cfg.enc_blk.format_id = LINEAR_PCM; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_pcm_cfg); - enc_cfg.enc_blk.cfg.pcm.ch_cfg = 0;/*channels;*/ - enc_cfg.enc_blk.cfg.pcm.bits_per_sample = 16; - enc_cfg.enc_blk.cfg.pcm.sample_rate = 0;/*rate;*/ - enc_cfg.enc_blk.cfg.pcm.is_signed = 1; - enc_cfg.enc_blk.cfg.pcm.interleaved = 1; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd open failed\n"); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout opcode[0x%x] ", enc_cfg.hdr.opcode); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enc_cfg_blk_multi_ch_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - - int rc = 0; - - pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__, - ac->session, rate, channels); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - enc_cfg.enc_blk.frames_per_buf = 1; - enc_cfg.enc_blk.format_id = MULTI_CHANNEL_PCM; - enc_cfg.enc_blk.cfg_size = - sizeof(struct asm_multi_channel_pcm_fmt_blk); - enc_cfg.enc_blk.cfg.mpcm.num_channels = channels; - enc_cfg.enc_blk.cfg.mpcm.bits_per_sample = 16; - enc_cfg.enc_blk.cfg.mpcm.sample_rate = rate; - enc_cfg.enc_blk.cfg.mpcm.is_signed = 1; - enc_cfg.enc_blk.cfg.mpcm.is_interleaved = 1; - if (channels == 1) { - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[0] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[1] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[2] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[3] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[4] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[5] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[6] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[7] = 0; - } else if (channels == 2) { - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[0] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[1] = PCM_CHANNEL_FR; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[2] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[3] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[4] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[5] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[6] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[7] = 0; - } else if (channels == 4) { - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[0] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[1] = PCM_CHANNEL_FR; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[2] = PCM_CHANNEL_RB; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[3] = PCM_CHANNEL_LB; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[4] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[5] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[6] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[7] = 0; - } else if (channels == 6) { - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[0] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[1] = PCM_CHANNEL_FR; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[2] = PCM_CHANNEL_LFE; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[3] = PCM_CHANNEL_FC; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[4] = PCM_CHANNEL_LB; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[5] = PCM_CHANNEL_RB; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[6] = 0; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[7] = 0; - } else if (channels == 8) { - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[0] = PCM_CHANNEL_FL; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[1] = PCM_CHANNEL_FR; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[2] = PCM_CHANNEL_LFE; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[3] = PCM_CHANNEL_FC; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[4] = PCM_CHANNEL_LB; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[5] = PCM_CHANNEL_RB; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[6] = PCM_CHANNEL_FLC; - enc_cfg.enc_blk.cfg.mpcm.channel_mapping[7] = PCM_CHANNEL_FRC; - } - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd open failed\n"); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout opcode[0x%x] ", enc_cfg.hdr.opcode); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enable_sbrps(struct audio_client *ac, - uint32_t sbr_ps_enable) -{ - struct asm_stream_cmd_encdec_sbr sbrps; - - int rc = 0; - - pr_debug("%s: Session %d\n", __func__, ac->session); - - q6asm_add_hdr(ac, &sbrps.hdr, sizeof(sbrps), TRUE); - - sbrps.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - sbrps.param_id = ASM_ENABLE_SBR_PS; - sbrps.param_size = sizeof(struct asm_sbr_ps); - sbrps.sbr_ps.enable = sbr_ps_enable; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &sbrps); - if (rc < 0) { - pr_err("Command opcode[0x%x]paramid[0x%x] failed\n", - ASM_STREAM_CMD_SET_ENCDEC_PARAM, - ASM_ENABLE_SBR_PS); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout opcode[0x%x] ", sbrps.hdr.opcode); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_cfg_dual_mono_aac(struct audio_client *ac, - uint16_t sce_left, uint16_t sce_right) -{ - struct asm_stream_cmd_encdec_dualmono dual_mono; - - int rc = 0; - - pr_debug("%s: Session %d, sce_left = %d, sce_right = %d\n", - __func__, ac->session, sce_left, sce_right); - - q6asm_add_hdr(ac, &dual_mono.hdr, sizeof(dual_mono), TRUE); - - dual_mono.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - dual_mono.param_id = ASM_CONFIGURE_DUAL_MONO; - dual_mono.param_size = sizeof(struct asm_dual_mono); - dual_mono.channel_map.sce_left = sce_left; - dual_mono.channel_map.sce_right = sce_right; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &dual_mono); - if (rc < 0) { - pr_err("%s:Command opcode[0x%x]paramid[0x%x] failed\n", - __func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, - ASM_CONFIGURE_DUAL_MONO); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout opcode[0x%x]\n", __func__, - dual_mono.hdr.opcode); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff) -{ - struct asm_aac_stereo_mix_coeff_selection_param aac_mix_coeff; - int rc = 0; - q6asm_add_hdr(ac, &aac_mix_coeff.hdr, sizeof(aac_mix_coeff), TRUE); - aac_mix_coeff.hdr.opcode = - ASM_STREAM_CMD_SET_ENCDEC_PARAM; - aac_mix_coeff.param_id = - ASM_PARAM_ID_AAC_STEREO_MIX_COEFF_SELECTION_FLAG; - aac_mix_coeff.param_size = - sizeof(struct asm_aac_stereo_mix_coeff_selection_param); - aac_mix_coeff.aac_stereo_mix_coeff_flag = mix_coeff; - pr_debug("%s, mix_coeff = %u", __func__, mix_coeff); - rc = apr_send_pkt(ac->apr, (uint32_t *) &aac_mix_coeff); - if (rc < 0) { - pr_err("%s:Command opcode[0x%x]paramid[0x%x] failed\n", - __func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, - ASM_PARAM_ID_AAC_STEREO_MIX_COEFF_SELECTION_FLAG); - rc = -EINVAL; - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout opcode[0x%x]\n", __func__, - aac_mix_coeff.hdr.opcode); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_set_encdec_chan_map(struct audio_client *ac, - uint32_t num_channels) -{ - struct asm_stream_cmd_encdec_channelmap chan_map; - u8 *channel_mapping; - - int rc = 0; - - pr_debug("%s: Session %d, num_channels = %d\n", - __func__, ac->session, num_channels); - - q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE); - - chan_map.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - chan_map.param_id = ASM_ENCDEC_DEC_CHAN_MAP; - chan_map.param_size = sizeof(struct asm_dec_chan_map); - chan_map.chan_map.num_channels = num_channels; - - channel_mapping = - chan_map.chan_map.channel_mapping; - - memset(channel_mapping, PCM_CHANNEL_NULL, MAX_CHAN_MAP_CHANNELS); - if (num_channels == 1) { - channel_mapping[0] = PCM_CHANNEL_FL; - } else if (num_channels == 2) { - channel_mapping[0] = PCM_CHANNEL_FL; - channel_mapping[1] = PCM_CHANNEL_FR; - } else if (num_channels == 4) { - channel_mapping[0] = PCM_CHANNEL_FL; - channel_mapping[1] = PCM_CHANNEL_FR; - channel_mapping[1] = PCM_CHANNEL_LB; - channel_mapping[1] = PCM_CHANNEL_RB; - } else if (num_channels == 6) { - channel_mapping[0] = PCM_CHANNEL_FC; - channel_mapping[1] = PCM_CHANNEL_FL; - channel_mapping[2] = PCM_CHANNEL_FR; - channel_mapping[3] = PCM_CHANNEL_LB; - channel_mapping[4] = PCM_CHANNEL_RB; - channel_mapping[5] = PCM_CHANNEL_LFE; - } else if (num_channels == 8) { - channel_mapping[0] = PCM_CHANNEL_FC; - channel_mapping[1] = PCM_CHANNEL_FL; - channel_mapping[2] = PCM_CHANNEL_FR; - channel_mapping[3] = PCM_CHANNEL_LB; - channel_mapping[4] = PCM_CHANNEL_RB; - channel_mapping[5] = PCM_CHANNEL_LFE; - channel_mapping[6] = PCM_CHANNEL_FLC; - channel_mapping[7] = PCM_CHANNEL_FRC; - } else { - pr_err("%s: ERROR.unsupported num_ch = %u\n", __func__, - num_channels); - rc = -EINVAL; - goto fail_cmd; - } - - rc = apr_send_pkt(ac->apr, (uint32_t *) &chan_map); - if (rc < 0) { - pr_err("%s:Command opcode[0x%x]paramid[0x%x] failed\n", - __func__, ASM_STREAM_CMD_SET_ENCDEC_PARAM, - ASM_ENCDEC_DEC_CHAN_MAP); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout opcode[0x%x]\n", __func__, - chan_map.hdr.opcode); - rc = -ETIMEDOUT; - goto fail_cmd; - } - return 0; -fail_cmd: - return rc; -} - -int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t min_rate, uint16_t max_rate, - uint16_t reduced_rate_level, uint16_t rate_modulation_cmd) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - int rc = 0; - - pr_debug("%s:session[%d]frames[%d]min_rate[0x%4x]max_rate[0x%4x] reduced_rate_level[0x%4x]rate_modulation_cmd[0x%4x]", - __func__, - ac->session, frames_per_buf, min_rate, max_rate, - reduced_rate_level, rate_modulation_cmd); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - - enc_cfg.enc_blk.frames_per_buf = frames_per_buf; - enc_cfg.enc_blk.format_id = V13K_FS; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_qcelp13_read_cfg); - enc_cfg.enc_blk.cfg.qcelp13.min_rate = min_rate; - enc_cfg.enc_blk.cfg.qcelp13.max_rate = max_rate; - enc_cfg.enc_blk.cfg.qcelp13.reduced_rate_level = reduced_rate_level; - enc_cfg.enc_blk.cfg.qcelp13.rate_modulation_cmd = rate_modulation_cmd; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd %d failed\n", ASM_STREAM_CMD_SET_ENCDEC_PARAM); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for FORMAT_UPDATE\n"); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t min_rate, uint16_t max_rate, - uint16_t rate_modulation_cmd) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - int rc = 0; - - pr_debug("%s:session[%d]frames[%d]min_rate[0x%4x]max_rate[0x%4x] rate_modulation_cmd[0x%4x]", - __func__, ac->session, - frames_per_buf, min_rate, max_rate, rate_modulation_cmd); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - - enc_cfg.enc_blk.frames_per_buf = frames_per_buf; - enc_cfg.enc_blk.format_id = EVRC_FS; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_evrc_read_cfg); - enc_cfg.enc_blk.cfg.evrc.min_rate = min_rate; - enc_cfg.enc_blk.cfg.evrc.max_rate = max_rate; - enc_cfg.enc_blk.cfg.evrc.rate_modulation_cmd = rate_modulation_cmd; - enc_cfg.enc_blk.cfg.evrc.reserved = 0; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd %d failed\n", ASM_STREAM_CMD_SET_ENCDEC_PARAM); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for FORMAT_UPDATE\n"); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t band_mode, uint16_t dtx_enable) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - int rc = 0; - - pr_debug("%s:session[%d]frames[%d]band_mode[0x%4x]dtx_enable[0x%4x]", - __func__, ac->session, frames_per_buf, band_mode, dtx_enable); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - - enc_cfg.enc_blk.frames_per_buf = frames_per_buf; - enc_cfg.enc_blk.format_id = AMRNB_FS; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_amrnb_read_cfg); - enc_cfg.enc_blk.cfg.amrnb.mode = band_mode; - enc_cfg.enc_blk.cfg.amrnb.dtx_mode = dtx_enable; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd %d failed\n", ASM_STREAM_CMD_SET_ENCDEC_PARAM); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for FORMAT_UPDATE\n"); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf, - uint16_t band_mode, uint16_t dtx_enable) -{ - struct asm_stream_cmd_encdec_cfg_blk enc_cfg; - int rc = 0; - - pr_debug("%s:session[%d]frames[%d]band_mode[0x%4x]dtx_enable[0x%4x]", - __func__, ac->session, frames_per_buf, band_mode, dtx_enable); - - q6asm_add_hdr(ac, &enc_cfg.hdr, sizeof(enc_cfg), TRUE); - - enc_cfg.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; - - enc_cfg.param_id = ASM_ENCDEC_CFG_BLK_ID; - enc_cfg.param_size = sizeof(struct asm_encode_cfg_blk); - - enc_cfg.enc_blk.frames_per_buf = frames_per_buf; - enc_cfg.enc_blk.format_id = AMRWB_FS; - enc_cfg.enc_blk.cfg_size = sizeof(struct asm_amrwb_read_cfg); - enc_cfg.enc_blk.cfg.amrwb.mode = band_mode; - enc_cfg.enc_blk.cfg.amrwb.dtx_mode = dtx_enable; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &enc_cfg); - if (rc < 0) { - pr_err("Comamnd %d failed\n", ASM_STREAM_CMD_SET_ENCDEC_PARAM); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for FORMAT_UPDATE\n"); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_media_format_block_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels) -{ - struct asm_stream_media_format_update fmt; - int rc = 0; - - pr_debug("%s:session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate, - channels); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - - fmt.format = LINEAR_PCM; - fmt.cfg_size = sizeof(struct asm_pcm_cfg); - fmt.write_cfg.pcm_cfg.ch_cfg = channels; - fmt.write_cfg.pcm_cfg.bits_per_sample = 16; - fmt.write_cfg.pcm_cfg.sample_rate = rate; - fmt.write_cfg.pcm_cfg.is_signed = 1; - fmt.write_cfg.pcm_cfg.interleaved = 1; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd open failed\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac, - uint32_t rate, uint32_t channels, char *channel_map) -{ - struct asm_stream_media_format_update fmt; - u8 *channel_mapping; - int rc = 0; - - pr_debug("%s:session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate, - channels); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - - fmt.format = MULTI_CHANNEL_PCM; - fmt.cfg_size = sizeof(struct asm_multi_channel_pcm_fmt_blk); - fmt.write_cfg.multi_ch_pcm_cfg.num_channels = channels; - fmt.write_cfg.multi_ch_pcm_cfg.bits_per_sample = 16; - fmt.write_cfg.multi_ch_pcm_cfg.sample_rate = rate; - fmt.write_cfg.multi_ch_pcm_cfg.is_signed = 1; - fmt.write_cfg.multi_ch_pcm_cfg.is_interleaved = 1; - channel_mapping = - fmt.write_cfg.multi_ch_pcm_cfg.channel_mapping; - - memcpy(channel_mapping, channel_map, PCM_FORMAT_MAX_NUM_CHANNEL); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd open failed\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_media_format_block_aac(struct audio_client *ac, - struct asm_aac_cfg *cfg) -{ - struct asm_stream_media_format_update fmt; - int rc = 0; - - pr_debug("%s:session[%d]rate[%d]ch[%d]\n", __func__, ac->session, - cfg->sample_rate, cfg->ch_cfg); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - - fmt.format = MPEG4_AAC; - fmt.cfg_size = sizeof(struct asm_aac_cfg); - fmt.write_cfg.aac_cfg.format = cfg->format; - fmt.write_cfg.aac_cfg.aot = cfg->aot; - fmt.write_cfg.aac_cfg.ep_config = cfg->ep_config; - fmt.write_cfg.aac_cfg.section_data_resilience = - cfg->section_data_resilience; - fmt.write_cfg.aac_cfg.scalefactor_data_resilience = - cfg->scalefactor_data_resilience; - fmt.write_cfg.aac_cfg.spectral_data_resilience = - cfg->spectral_data_resilience; - fmt.write_cfg.aac_cfg.ch_cfg = cfg->ch_cfg; - fmt.write_cfg.aac_cfg.sample_rate = cfg->sample_rate; - pr_info("%s:format=%x cfg_size=%d aac-cfg=%x aot=%d ch=%d sr=%d\n", - __func__, fmt.format, fmt.cfg_size, - fmt.write_cfg.aac_cfg.format, - fmt.write_cfg.aac_cfg.aot, - fmt.write_cfg.aac_cfg.ch_cfg, - fmt.write_cfg.aac_cfg.sample_rate); - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd open failed\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_media_format_block_amrwbplus(struct audio_client *ac, - struct asm_amrwbplus_cfg *cfg) -{ - struct asm_stream_media_format_update fmt; - int rc = 0; - pr_debug("q6asm_media_format_block_amrwbplus"); - - pr_debug("%s:session[%d]band-mode[%d]frame-fmt[%d]ch[%d]\n", - __func__, - ac->session, - cfg->amr_band_mode, - cfg->amr_frame_fmt, - cfg->num_channels); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - - fmt.format = AMR_WB_PLUS; - fmt.cfg_size = cfg->size_bytes; - - fmt.write_cfg.amrwbplus_cfg.size_bytes = cfg->size_bytes; - fmt.write_cfg.amrwbplus_cfg.version = cfg->version; - fmt.write_cfg.amrwbplus_cfg.num_channels = cfg->num_channels; - fmt.write_cfg.amrwbplus_cfg.amr_band_mode = cfg->amr_band_mode; - fmt.write_cfg.amrwbplus_cfg.amr_dtx_mode = cfg->amr_dtx_mode; - fmt.write_cfg.amrwbplus_cfg.amr_frame_fmt = cfg->amr_frame_fmt; - fmt.write_cfg.amrwbplus_cfg.amr_lsf_idx = cfg->amr_lsf_idx; - - pr_debug("%s: num_channels=%x amr_band_mode=%d amr_frame_fmt=%d\n", - __func__, - cfg->num_channels, - cfg->amr_band_mode, - cfg->amr_frame_fmt); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd media format update failed..\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} -int q6asm_media_format_block_multi_aac(struct audio_client *ac, - struct asm_aac_cfg *cfg) -{ - struct asm_stream_media_format_update fmt; - int rc = 0; - - pr_debug("%s:session[%d]rate[%d]ch[%d]\n", __func__, ac->session, - cfg->sample_rate, cfg->ch_cfg); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - - fmt.format = MPEG4_MULTI_AAC; - fmt.cfg_size = sizeof(struct asm_aac_cfg); - fmt.write_cfg.aac_cfg.format = cfg->format; - fmt.write_cfg.aac_cfg.aot = cfg->aot; - fmt.write_cfg.aac_cfg.ep_config = cfg->ep_config; - fmt.write_cfg.aac_cfg.section_data_resilience = - cfg->section_data_resilience; - fmt.write_cfg.aac_cfg.scalefactor_data_resilience = - cfg->scalefactor_data_resilience; - fmt.write_cfg.aac_cfg.spectral_data_resilience = - cfg->spectral_data_resilience; - fmt.write_cfg.aac_cfg.ch_cfg = cfg->ch_cfg; - fmt.write_cfg.aac_cfg.sample_rate = cfg->sample_rate; - pr_info("%s:format=%x cfg_size=%d aac-cfg=%x aot=%d ch=%d sr=%d\n", - __func__, fmt.format, fmt.cfg_size, - fmt.write_cfg.aac_cfg.format, - fmt.write_cfg.aac_cfg.aot, - fmt.write_cfg.aac_cfg.ch_cfg, - fmt.write_cfg.aac_cfg.sample_rate); - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd open failed\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - - - -int q6asm_media_format_block(struct audio_client *ac, uint32_t format) -{ - - struct asm_stream_media_format_update fmt; - int rc = 0; - - pr_debug("%s:session[%d] format[0x%x]\n", __func__, - ac->session, format); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - switch (format) { - case FORMAT_V13K: - fmt.format = V13K_FS; - break; - case FORMAT_EVRC: - fmt.format = EVRC_FS; - break; - case FORMAT_AMRWB: - fmt.format = AMRWB_FS; - break; - case FORMAT_AMR_WB_PLUS: - fmt.format = AMR_WB_PLUS; - break; - case FORMAT_AMRNB: - fmt.format = AMRNB_FS; - break; - case FORMAT_MP3: - fmt.format = MP3; - break; - case FORMAT_DTS: - fmt.format = DTS; - break; - case FORMAT_DTS_LBR: - fmt.format = DTS_LBR; - break; - case FORMAT_MP2: - fmt.format = MP2; - break; - default: - pr_err("Invalid format[%d]\n", format); - goto fail_cmd; - } - fmt.cfg_size = 0; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd open failed\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_media_format_block_wma(struct audio_client *ac, - void *cfg) -{ - struct asm_stream_media_format_update fmt; - struct asm_wma_cfg *wma_cfg = (struct asm_wma_cfg *)cfg; - int rc = 0; - - pr_debug("session[%d]format_tag[0x%4x] rate[%d] ch[0x%4x] bps[%d], balign[0x%4x], bit_sample[0x%4x], ch_msk[%d], enc_opt[0x%4x]\n", - ac->session, wma_cfg->format_tag, wma_cfg->sample_rate, - wma_cfg->ch_cfg, wma_cfg->avg_bytes_per_sec, - wma_cfg->block_align, wma_cfg->valid_bits_per_sample, - wma_cfg->ch_mask, wma_cfg->encode_opt); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - - fmt.format = WMA_V9; - fmt.cfg_size = sizeof(struct asm_wma_cfg); - fmt.write_cfg.wma_cfg.format_tag = wma_cfg->format_tag; - fmt.write_cfg.wma_cfg.ch_cfg = wma_cfg->ch_cfg; - fmt.write_cfg.wma_cfg.sample_rate = wma_cfg->sample_rate; - fmt.write_cfg.wma_cfg.avg_bytes_per_sec = wma_cfg->avg_bytes_per_sec; - fmt.write_cfg.wma_cfg.block_align = wma_cfg->block_align; - fmt.write_cfg.wma_cfg.valid_bits_per_sample = - wma_cfg->valid_bits_per_sample; - fmt.write_cfg.wma_cfg.ch_mask = wma_cfg->ch_mask; - fmt.write_cfg.wma_cfg.encode_opt = wma_cfg->encode_opt; - fmt.write_cfg.wma_cfg.adv_encode_opt = 0; - fmt.write_cfg.wma_cfg.adv_encode_opt2 = 0; - fmt.write_cfg.wma_cfg.drc_peak_ref = 0; - fmt.write_cfg.wma_cfg.drc_peak_target = 0; - fmt.write_cfg.wma_cfg.drc_ave_ref = 0; - fmt.write_cfg.wma_cfg.drc_ave_target = 0; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd open failed\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_media_format_block_wmapro(struct audio_client *ac, - void *cfg) -{ - struct asm_stream_media_format_update fmt; - struct asm_wmapro_cfg *wmapro_cfg = (struct asm_wmapro_cfg *)cfg; - int rc = 0; - - pr_debug("session[%d]format_tag[0x%4x] rate[%d] ch[0x%4x] bps[%d], balign[0x%4x], bit_sample[0x%4x], ch_msk[%d], enc_opt[0x%4x], adv_enc_opt[0x%4x], adv_enc_opt2[0x%8x]\n", - ac->session, wmapro_cfg->format_tag, wmapro_cfg->sample_rate, - wmapro_cfg->ch_cfg, wmapro_cfg->avg_bytes_per_sec, - wmapro_cfg->block_align, wmapro_cfg->valid_bits_per_sample, - wmapro_cfg->ch_mask, wmapro_cfg->encode_opt, - wmapro_cfg->adv_encode_opt, wmapro_cfg->adv_encode_opt2); - - q6asm_add_hdr(ac, &fmt.hdr, sizeof(fmt), TRUE); - - fmt.hdr.opcode = ASM_DATA_CMD_MEDIA_FORMAT_UPDATE; - - fmt.format = WMA_V10PRO; - fmt.cfg_size = sizeof(struct asm_wmapro_cfg); - fmt.write_cfg.wmapro_cfg.format_tag = wmapro_cfg->format_tag; - fmt.write_cfg.wmapro_cfg.ch_cfg = wmapro_cfg->ch_cfg; - fmt.write_cfg.wmapro_cfg.sample_rate = wmapro_cfg->sample_rate; - fmt.write_cfg.wmapro_cfg.avg_bytes_per_sec = - wmapro_cfg->avg_bytes_per_sec; - fmt.write_cfg.wmapro_cfg.block_align = wmapro_cfg->block_align; - fmt.write_cfg.wmapro_cfg.valid_bits_per_sample = - wmapro_cfg->valid_bits_per_sample; - fmt.write_cfg.wmapro_cfg.ch_mask = wmapro_cfg->ch_mask; - fmt.write_cfg.wmapro_cfg.encode_opt = wmapro_cfg->encode_opt; - fmt.write_cfg.wmapro_cfg.adv_encode_opt = wmapro_cfg->adv_encode_opt; - fmt.write_cfg.wmapro_cfg.adv_encode_opt2 = wmapro_cfg->adv_encode_opt2; - fmt.write_cfg.wmapro_cfg.drc_peak_ref = 0; - fmt.write_cfg.wmapro_cfg.drc_peak_target = 0; - fmt.write_cfg.wmapro_cfg.drc_ave_ref = 0; - fmt.write_cfg.wmapro_cfg.drc_ave_target = 0; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt); - if (rc < 0) { - pr_err("%s:Comamnd open failed\n", __func__); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s:timeout. waited for FORMAT_UPDATE\n", __func__); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_memory_map(struct audio_client *ac, uint32_t buf_add, int dir, - uint32_t bufsz, uint32_t bufcnt) -{ - struct asm_stream_cmd_memory_map mem_map; - int rc = 0; - - if (!ac || ac->apr == NULL || this_mmap.apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - - pr_debug("%s: Session[%d]\n", __func__, ac->session); - - mem_map.hdr.opcode = ASM_SESSION_CMD_MEMORY_MAP; - - mem_map.buf_add = buf_add; - mem_map.buf_size = bufsz * bufcnt; - mem_map.mempool_id = 0; /* EBI */ - mem_map.reserved = 0; - - pr_debug("%s: audio_client addr %x\n", __func__, (uint32_t)ac); - mem_map.hdr.token = (uint32_t)ac; - q6asm_add_mmaphdr(&mem_map.hdr, - sizeof(struct asm_stream_cmd_memory_map), TRUE); - - pr_debug("buf add[%x] buf_add_parameter[%x]\n", - mem_map.buf_add, buf_add); - - rc = apr_send_pkt(this_mmap.apr, (uint32_t *) &mem_map); - if (rc < 0) { - pr_err("mem_map op[0x%x]rc[%d]\n", - mem_map.hdr.opcode, rc); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for memory_map\n"); - rc = -EINVAL; - goto fail_cmd; - } - if (atomic_read(&ac->cmd_response)) { - pr_err("%s: ASM_SESSION_CMD_MEMORY_MAP cmd failed\n", __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; - -fail_cmd: - return rc; -} - -int q6asm_memory_unmap(struct audio_client *ac, uint32_t buf_add, int dir) -{ - struct asm_stream_cmd_memory_unmap mem_unmap; - int rc = 0; - - if (!ac || ac->apr == NULL || this_mmap.apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s: Session[%d]\n", __func__, ac->session); - - pr_debug("%s: audio_client addr %x\n", __func__, (uint32_t)ac); - mem_unmap.hdr.token = (uint32_t)ac; - q6asm_add_mmaphdr(&mem_unmap.hdr, - sizeof(struct asm_stream_cmd_memory_unmap), TRUE); - mem_unmap.hdr.opcode = ASM_SESSION_CMD_MEMORY_UNMAP; - mem_unmap.buf_add = buf_add; - - rc = apr_send_pkt(this_mmap.apr, (uint32_t *) &mem_unmap); - if (rc < 0) { - pr_err("mem_unmap op[0x%x]rc[%d]\n", - mem_unmap.hdr.opcode, rc); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for memory_unmap\n"); - rc = -EINVAL; - goto fail_cmd; - } - if (atomic_read(&ac->cmd_response)) { - pr_err("%s: ASM_SESSION_CMD_MEMORY_UNMAP cmd failed\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; - -fail_cmd: - return rc; -} - -int q6asm_set_lrgain(struct audio_client *ac, int left_gain, int right_gain) -{ - void *vol_cmd = NULL; - void *payload = NULL; - struct asm_pp_params_command *cmd = NULL; - struct asm_lrchannel_gain_params *lrgain = NULL; - int sz = 0; - int rc = 0; - - sz = sizeof(struct asm_pp_params_command) + - + sizeof(struct asm_lrchannel_gain_params); - vol_cmd = kzalloc(sz, GFP_KERNEL); - if (vol_cmd == NULL) { - pr_err("%s[%d]: Mem alloc failed\n", __func__, ac->session); - rc = -EINVAL; - return rc; - } - cmd = (struct asm_pp_params_command *)vol_cmd; - q6asm_add_hdr_async(ac, &cmd->hdr, sz, TRUE); - cmd->hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS; - cmd->payload = NULL; - cmd->payload_size = sizeof(struct asm_pp_param_data_hdr) + - sizeof(struct asm_lrchannel_gain_params); - cmd->params.module_id = VOLUME_CONTROL_MODULE_ID; - cmd->params.param_id = L_R_CHANNEL_GAIN_PARAM_ID; - cmd->params.param_size = sizeof(struct asm_lrchannel_gain_params); - cmd->params.reserved = 0; - - payload = (u8 *)(vol_cmd + sizeof(struct asm_pp_params_command)); - lrgain = (struct asm_lrchannel_gain_params *)payload; - - lrgain->left_gain = left_gain; - lrgain->right_gain = right_gain; - rc = apr_send_pkt(ac->apr, (uint32_t *) vol_cmd); - if (rc < 0) { - pr_err("%s: Volume Command failed\n", __func__); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout in sending volume command to apr\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; -fail_cmd: - kfree(vol_cmd); - return rc; -} - -static int q6asm_memory_map_regions(struct audio_client *ac, int dir, - uint32_t bufsz, uint32_t bufcnt) -{ - struct asm_stream_cmd_memory_map_regions *mmap_regions = NULL; - struct asm_memory_map_regions *mregions = NULL; - struct audio_port_data *port = NULL; - struct audio_buffer *ab = NULL; - void *mmap_region_cmd = NULL; - void *payload = NULL; - int rc = 0; - int i = 0; - int cmd_size = 0; - - if (!ac || ac->apr == NULL || this_mmap.apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s: Session[%d]\n", __func__, ac->session); - - cmd_size = sizeof(struct asm_stream_cmd_memory_map_regions) - + sizeof(struct asm_memory_map_regions) * bufcnt; - - mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL); - if (mmap_region_cmd == NULL) { - pr_err("%s: Mem alloc failed\n", __func__); - rc = -EINVAL; - return rc; - } - mmap_regions = (struct asm_stream_cmd_memory_map_regions *) - mmap_region_cmd; - mmap_regions->hdr.token = (uint32_t)ac; - pr_debug("%s: audio_client addr %x\n", __func__, (uint32_t)ac); - q6asm_add_mmaphdr(&mmap_regions->hdr, cmd_size, TRUE); - mmap_regions->hdr.opcode = ASM_SESSION_CMD_MEMORY_MAP_REGIONS; - mmap_regions->mempool_id = 0; - mmap_regions->nregions = bufcnt & 0x00ff; - pr_debug("map_regions->nregions = %d\n", mmap_regions->nregions); - payload = ((u8 *) mmap_region_cmd + - sizeof(struct asm_stream_cmd_memory_map_regions)); - mregions = (struct asm_memory_map_regions *)payload; - - port = &ac->port[dir]; - for (i = 0; i < bufcnt; i++) { - ab = &port->buf[i]; - mregions->phys = ab->phys; - mregions->buf_size = ab->size; - ++mregions; - } - - rc = apr_send_pkt(this_mmap.apr, (uint32_t *) mmap_region_cmd); - if (rc < 0) { - pr_err("mmap_regions op[0x%x]rc[%d]\n", - mmap_regions->hdr.opcode, rc); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for map_regions\n"); - rc = -EINVAL; - goto fail_cmd; - } - if (atomic_read(&ac->cmd_response)) { - pr_err("%s: ASM_SESSION_CMD_MEMORY_MAP_REGIONS cmd failed\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; - -fail_cmd: - kfree(mmap_region_cmd); - return rc; -} - -static int q6asm_memory_unmap_regions(struct audio_client *ac, int dir, - uint32_t bufsz, uint32_t bufcnt) -{ - struct asm_stream_cmd_memory_unmap_regions *unmap_regions = NULL; - struct asm_memory_unmap_regions *mregions = NULL; - struct audio_port_data *port = NULL; - struct audio_buffer *ab = NULL; - void *unmap_region_cmd = NULL; - void *payload = NULL; - int rc = 0; - int i = 0; - int cmd_size = 0; - - if (!ac || ac->apr == NULL || this_mmap.apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s: Session[%d]\n", __func__, ac->session); - - cmd_size = sizeof(struct asm_stream_cmd_memory_unmap_regions) + - sizeof(struct asm_memory_unmap_regions) * bufcnt; - - unmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL); - if (unmap_region_cmd == NULL) { - pr_err("%s: Mem alloc failed\n", __func__); - rc = -EINVAL; - return rc; - } - unmap_regions = (struct asm_stream_cmd_memory_unmap_regions *) - unmap_region_cmd; - unmap_regions->hdr.token = (uint32_t)ac; - pr_debug("%s: audio_client addr %x\n", __func__, (uint32_t)ac); - q6asm_add_mmaphdr(&unmap_regions->hdr, cmd_size, TRUE); - unmap_regions->hdr.opcode = ASM_SESSION_CMD_MEMORY_UNMAP_REGIONS; - unmap_regions->nregions = bufcnt & 0x00ff; - pr_debug("unmap_regions->nregions = %d\n", unmap_regions->nregions); - payload = ((u8 *) unmap_region_cmd + - sizeof(struct asm_stream_cmd_memory_unmap_regions)); - mregions = (struct asm_memory_unmap_regions *)payload; - port = &ac->port[dir]; - for (i = 0; i < bufcnt; i++) { - ab = &port->buf[i]; - mregions->phys = ab->phys; - ++mregions; - } - - rc = apr_send_pkt(this_mmap.apr, (uint32_t *) unmap_region_cmd); - if (rc < 0) { - pr_err("mmap_regions op[0x%x]rc[%d]\n", - unmap_regions->hdr.opcode, rc); - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for unmap_regions\n"); - rc = -EINVAL; - goto fail_cmd; - } - if (atomic_read(&ac->cmd_response)) { - pr_err("%s: ASM_SESSION_CMD_MEMORY_UNMAP_REGIONS cmd failed\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; - -fail_cmd: - kfree(unmap_region_cmd); - return rc; -} - -int q6asm_set_mute(struct audio_client *ac, int muteflag) -{ - void *vol_cmd = NULL; - void *payload = NULL; - struct asm_pp_params_command *cmd = NULL; - struct asm_mute_params *mute = NULL; - int sz = 0; - int rc = 0; - - sz = sizeof(struct asm_pp_params_command) + - + sizeof(struct asm_mute_params); - vol_cmd = kzalloc(sz, GFP_KERNEL); - if (vol_cmd == NULL) { - pr_err("%s[%d]: Mem alloc failed\n", __func__, ac->session); - rc = -EINVAL; - return rc; - } - cmd = (struct asm_pp_params_command *)vol_cmd; - q6asm_add_hdr_async(ac, &cmd->hdr, sz, TRUE); - cmd->hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS; - cmd->payload = NULL; - cmd->payload_size = sizeof(struct asm_pp_param_data_hdr) + - sizeof(struct asm_mute_params); - cmd->params.module_id = VOLUME_CONTROL_MODULE_ID; - cmd->params.param_id = MUTE_CONFIG_PARAM_ID; - cmd->params.param_size = sizeof(struct asm_mute_params); - cmd->params.reserved = 0; - - payload = (u8 *)(vol_cmd + sizeof(struct asm_pp_params_command)); - mute = (struct asm_mute_params *)payload; - - mute->muteflag = muteflag; - rc = apr_send_pkt(ac->apr, (uint32_t *) vol_cmd); - if (rc < 0) { - pr_err("%s: Mute Command failed\n", __func__); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout in sending mute command to apr\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; -fail_cmd: - kfree(vol_cmd); - return rc; -} - -int q6asm_set_volume(struct audio_client *ac, int volume) -{ - void *vol_cmd = NULL; - void *payload = NULL; - struct asm_pp_params_command *cmd = NULL; - struct asm_master_gain_params *mgain = NULL; - int sz = 0; - int rc = 0; - - sz = sizeof(struct asm_pp_params_command) + - + sizeof(struct asm_master_gain_params); - vol_cmd = kzalloc(sz, GFP_KERNEL); - if (vol_cmd == NULL) { - pr_err("%s[%d]: Mem alloc failed\n", __func__, ac->session); - rc = -EINVAL; - return rc; - } - cmd = (struct asm_pp_params_command *)vol_cmd; - q6asm_add_hdr_async(ac, &cmd->hdr, sz, TRUE); - cmd->hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS; - cmd->payload = NULL; - cmd->payload_size = sizeof(struct asm_pp_param_data_hdr) + - sizeof(struct asm_master_gain_params); - cmd->params.module_id = VOLUME_CONTROL_MODULE_ID; - cmd->params.param_id = MASTER_GAIN_PARAM_ID; - cmd->params.param_size = sizeof(struct asm_master_gain_params); - cmd->params.reserved = 0; - - payload = (u8 *)(vol_cmd + sizeof(struct asm_pp_params_command)); - mgain = (struct asm_master_gain_params *)payload; - - mgain->master_gain = volume; - mgain->padding = 0x00; - rc = apr_send_pkt(ac->apr, (uint32_t *) vol_cmd); - if (rc < 0) { - pr_err("%s: Volume Command failed\n", __func__); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout in sending volume command to apr\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; -fail_cmd: - kfree(vol_cmd); - return rc; -} - -int q6asm_set_softpause(struct audio_client *ac, - struct asm_softpause_params *pause_param) -{ - void *vol_cmd = NULL; - void *payload = NULL; - struct asm_pp_params_command *cmd = NULL; - struct asm_softpause_params *params = NULL; - int sz = 0; - int rc = 0; - - sz = sizeof(struct asm_pp_params_command) + - + sizeof(struct asm_softpause_params); - vol_cmd = kzalloc(sz, GFP_KERNEL); - if (vol_cmd == NULL) { - pr_err("%s[%d]: Mem alloc failed\n", __func__, ac->session); - rc = -EINVAL; - return rc; - } - cmd = (struct asm_pp_params_command *)vol_cmd; - q6asm_add_hdr_async(ac, &cmd->hdr, sz, TRUE); - cmd->hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS; - cmd->payload = NULL; - cmd->payload_size = sizeof(struct asm_pp_param_data_hdr) + - sizeof(struct asm_softpause_params); - cmd->params.module_id = VOLUME_CONTROL_MODULE_ID; - cmd->params.param_id = SOFT_PAUSE_PARAM_ID; - cmd->params.param_size = sizeof(struct asm_softpause_params); - cmd->params.reserved = 0; - - payload = (u8 *)(vol_cmd + sizeof(struct asm_pp_params_command)); - params = (struct asm_softpause_params *)payload; - - params->enable = pause_param->enable; - params->period = pause_param->period; - params->step = pause_param->step; - params->rampingcurve = pause_param->rampingcurve; - pr_debug("%s: soft Pause Command: enable = %d, period = %d, step = %d, curve = %d\n", - __func__, params->enable, - params->period, params->step, params->rampingcurve); - rc = apr_send_pkt(ac->apr, (uint32_t *) vol_cmd); - if (rc < 0) { - pr_err("%s: Volume Command(soft_pause) failed\n", __func__); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout in sending volume command(soft_pause) to apr\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; -fail_cmd: - kfree(vol_cmd); - return rc; -} - -int q6asm_set_softvolume(struct audio_client *ac, - struct asm_softvolume_params *softvol_param) -{ - void *vol_cmd = NULL; - void *payload = NULL; - struct asm_pp_params_command *cmd = NULL; - struct asm_softvolume_params *params = NULL; - int sz = 0; - int rc = 0; - - sz = sizeof(struct asm_pp_params_command) + - + sizeof(struct asm_softvolume_params); - vol_cmd = kzalloc(sz, GFP_KERNEL); - if (vol_cmd == NULL) { - pr_err("%s[%d]: Mem alloc failed\n", __func__, ac->session); - rc = -EINVAL; - return rc; - } - cmd = (struct asm_pp_params_command *)vol_cmd; - q6asm_add_hdr_async(ac, &cmd->hdr, sz, TRUE); - cmd->hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS; - cmd->payload = NULL; - cmd->payload_size = sizeof(struct asm_pp_param_data_hdr) + - sizeof(struct asm_softvolume_params); - cmd->params.module_id = VOLUME_CONTROL_MODULE_ID; - cmd->params.param_id = SOFT_VOLUME_PARAM_ID; - cmd->params.param_size = sizeof(struct asm_softvolume_params); - cmd->params.reserved = 0; - - payload = (u8 *)(vol_cmd + sizeof(struct asm_pp_params_command)); - params = (struct asm_softvolume_params *)payload; - - params->period = softvol_param->period; - params->step = softvol_param->step; - params->rampingcurve = softvol_param->rampingcurve; - pr_debug("%s: soft Volume:opcode = %d,payload_sz =%d,module_id =%d, param_id = %d, param_sz = %d\n", - __func__, - cmd->hdr.opcode, cmd->payload_size, - cmd->params.module_id, cmd->params.param_id, - cmd->params.param_size); - pr_debug("%s: soft Volume Command: period = %d, step = %d, curve = %d\n", - __func__, params->period, - params->step, params->rampingcurve); - rc = apr_send_pkt(ac->apr, (uint32_t *) vol_cmd); - if (rc < 0) { - pr_err("%s: Volume Command(soft_volume) failed\n", __func__); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout in sending volume command(soft_volume) to apr\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; -fail_cmd: - kfree(vol_cmd); - return rc; -} - -int q6asm_equalizer(struct audio_client *ac, void *eq) -{ - void *eq_cmd = NULL; - void *payload = NULL; - struct asm_pp_params_command *cmd = NULL; - struct asm_equalizer_params *equalizer = NULL; - struct msm_audio_eq_stream_config *eq_params = NULL; - int i = 0; - int sz = 0; - int rc = 0; - - sz = sizeof(struct asm_pp_params_command) + - + sizeof(struct asm_equalizer_params); - eq_cmd = kzalloc(sz, GFP_KERNEL); - if (eq_cmd == NULL) { - pr_err("%s[%d]: Mem alloc failed\n", __func__, ac->session); - rc = -EINVAL; - goto fail_cmd; - } - eq_params = (struct msm_audio_eq_stream_config *) eq; - cmd = (struct asm_pp_params_command *)eq_cmd; - q6asm_add_hdr(ac, &cmd->hdr, sz, TRUE); - cmd->hdr.opcode = ASM_STREAM_CMD_SET_PP_PARAMS; - cmd->payload = NULL; - cmd->payload_size = sizeof(struct asm_pp_param_data_hdr) + - sizeof(struct asm_equalizer_params); - cmd->params.module_id = EQUALIZER_MODULE_ID; - cmd->params.param_id = EQUALIZER_PARAM_ID; - cmd->params.param_size = sizeof(struct asm_equalizer_params); - cmd->params.reserved = 0; - payload = (u8 *)(eq_cmd + sizeof(struct asm_pp_params_command)); - equalizer = (struct asm_equalizer_params *)payload; - - equalizer->enable = eq_params->enable; - equalizer->num_bands = eq_params->num_bands; - pr_debug("%s: enable:%d numbands:%d\n", __func__, eq_params->enable, - eq_params->num_bands); - for (i = 0; i < eq_params->num_bands; i++) { - equalizer->eq_bands[i].band_idx = - eq_params->eq_bands[i].band_idx; - equalizer->eq_bands[i].filter_type = - eq_params->eq_bands[i].filter_type; - equalizer->eq_bands[i].center_freq_hz = - eq_params->eq_bands[i].center_freq_hz; - equalizer->eq_bands[i].filter_gain = - eq_params->eq_bands[i].filter_gain; - equalizer->eq_bands[i].q_factor = - eq_params->eq_bands[i].q_factor; - pr_debug("%s: filter_type:%u bandnum:%d\n", __func__, - eq_params->eq_bands[i].filter_type, i); - pr_debug("%s: center_freq_hz:%u bandnum:%d\n", __func__, - eq_params->eq_bands[i].center_freq_hz, i); - pr_debug("%s: filter_gain:%d bandnum:%d\n", __func__, - eq_params->eq_bands[i].filter_gain, i); - pr_debug("%s: q_factor:%d bandnum:%d\n", __func__, - eq_params->eq_bands[i].q_factor, i); - } - rc = apr_send_pkt(ac->apr, (uint32_t *) eq_cmd); - if (rc < 0) { - pr_err("%s: Equalizer Command failed\n", __func__); - rc = -EINVAL; - goto fail_cmd; - } - - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout in sending equalizer command to apr\n", - __func__); - rc = -EINVAL; - goto fail_cmd; - } - rc = 0; -fail_cmd: - kfree(eq_cmd); - return rc; -} - -int q6asm_read(struct audio_client *ac) -{ - struct asm_stream_cmd_read read; - struct audio_buffer *ab; - int dsp_buf; - struct audio_port_data *port; - int rc; - if (!ac || ac->apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - if (ac->io_mode & SYNC_IO_MODE) { - port = &ac->port[OUT]; - - q6asm_add_hdr(ac, &read.hdr, sizeof(read), FALSE); - - mutex_lock(&port->lock); - - dsp_buf = port->dsp_buf; - ab = &port->buf[dsp_buf]; - - pr_debug("%s:session[%d]dsp-buf[%d][%p]cpu_buf[%d][%p]\n", - __func__, - ac->session, - dsp_buf, - (void *)port->buf[dsp_buf].data, - port->cpu_buf, - (void *)port->buf[port->cpu_buf].phys); - - read.hdr.opcode = ASM_DATA_CMD_READ; - read.buf_add = ab->phys; - read.buf_size = ab->size; - read.uid = port->dsp_buf; - read.hdr.token = port->dsp_buf; - - port->dsp_buf = (port->dsp_buf + 1) & (port->max_buf_cnt - 1); - mutex_unlock(&port->lock); - pr_debug("%s:buf add[0x%x] token[%d] uid[%d]\n", __func__, - read.buf_add, - read.hdr.token, - read.uid); - rc = apr_send_pkt(ac->apr, (uint32_t *) &read); - if (rc < 0) { - pr_err("read op[0x%x]rc[%d]\n", read.hdr.opcode, rc); - goto fail_cmd; - } - return 0; - } -fail_cmd: - return -EINVAL; -} - -int q6asm_read_nolock(struct audio_client *ac) -{ - struct asm_stream_cmd_read read; - struct audio_buffer *ab; - int dsp_buf; - struct audio_port_data *port; - int rc; - if (!ac || ac->apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - if (ac->io_mode & SYNC_IO_MODE) { - port = &ac->port[OUT]; - - q6asm_add_hdr_async(ac, &read.hdr, sizeof(read), FALSE); - - - dsp_buf = port->dsp_buf; - ab = &port->buf[dsp_buf]; - - pr_debug("%s:session[%d]dsp-buf[%d][%p]cpu_buf[%d][%p]\n", - __func__, - ac->session, - dsp_buf, - (void *)port->buf[dsp_buf].data, - port->cpu_buf, - (void *)port->buf[port->cpu_buf].phys); - - read.hdr.opcode = ASM_DATA_CMD_READ; - read.buf_add = ab->phys; - read.buf_size = ab->size; - read.uid = port->dsp_buf; - read.hdr.token = port->dsp_buf; - - port->dsp_buf = (port->dsp_buf + 1) & (port->max_buf_cnt - 1); - pr_info("%s:buf add[0x%x] token[%d] uid[%d]\n", __func__, - read.buf_add, - read.hdr.token, - read.uid); - rc = apr_send_pkt(ac->apr, (uint32_t *) &read); - if (rc < 0) { - pr_err("read op[0x%x]rc[%d]\n", read.hdr.opcode, rc); - goto fail_cmd; - } - return 0; - } -fail_cmd: - return -EINVAL; -} - - -static void q6asm_add_hdr_async(struct audio_client *ac, struct apr_hdr *hdr, - uint32_t pkt_size, uint32_t cmd_flg) -{ - pr_debug("session=%d pkt size=%d cmd_flg=%d\n", pkt_size, cmd_flg, - ac->session); - hdr->hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, \ - APR_HDR_LEN(sizeof(struct apr_hdr)),\ - APR_PKT_VER); - hdr->src_svc = ((struct apr_svc *)ac->apr)->id; - hdr->src_domain = APR_DOMAIN_APPS; - hdr->dest_svc = APR_SVC_ASM; - hdr->dest_domain = APR_DOMAIN_ADSP; - hdr->src_port = ((ac->session << 8) & 0xFF00) | 0x01; - hdr->dest_port = ((ac->session << 8) & 0xFF00) | 0x01; - if (cmd_flg) { - hdr->token = ac->session; - atomic_set(&ac->cmd_state, 1); - } - hdr->pkt_size = pkt_size; - return; -} - -int q6asm_async_write(struct audio_client *ac, - struct audio_aio_write_param *param) -{ - int rc = 0; - struct asm_stream_cmd_write write; - - if (!ac || ac->apr == NULL) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - - q6asm_add_hdr_async(ac, &write.hdr, sizeof(write), FALSE); - - /* Pass physical address as token for AIO scheme */ - write.hdr.token = param->uid; - write.hdr.opcode = ASM_DATA_CMD_WRITE; - write.buf_add = param->paddr; - write.avail_bytes = param->len; - write.uid = param->uid; - write.msw_ts = param->msw_ts; - write.lsw_ts = param->lsw_ts; - /* Use 0xFF00 for disabling timestamps */ - if (param->flags == 0xFF00) - write.uflags = (0x00000000 | (param->flags & 0x800000FF)); - else - write.uflags = (0x80000000 | param->flags); - - pr_debug("%s: session[%d] bufadd[0x%x]len[0x%x]", __func__, ac->session, - write.buf_add, write.avail_bytes); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &write); - if (rc < 0) { - pr_debug("[%s] write op[0x%x]rc[%d]\n", __func__, - write.hdr.opcode, rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_async_read(struct audio_client *ac, - struct audio_aio_read_param *param) -{ - int rc = 0; - struct asm_stream_cmd_read read; - - if (!ac || ac->apr == NULL) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - - q6asm_add_hdr_async(ac, &read.hdr, sizeof(read), FALSE); - - /* Pass physical address as token for AIO scheme */ - read.hdr.token = param->paddr; - read.hdr.opcode = ASM_DATA_CMD_READ; - read.buf_add = param->paddr; - read.buf_size = param->len; - read.uid = param->uid; - - pr_debug("%s: session[%d] bufadd[0x%x]len[0x%x]", __func__, ac->session, - read.buf_add, read.buf_size); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &read); - if (rc < 0) { - pr_debug("[%s] read op[0x%x]rc[%d]\n", __func__, - read.hdr.opcode, rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_async_read_compressed(struct audio_client *ac, - struct audio_aio_read_param *param) -{ - int rc = 0; - struct asm_stream_cmd_read read; - - if (!ac || ac->apr == NULL) { - pr_err("%s: APR handle NULL\n", __func__); - return -EINVAL; - } - - q6asm_add_hdr_async(ac, &read.hdr, sizeof(read), FALSE); - - /* Pass physical address as token for AIO scheme */ - read.hdr.token = param->paddr; - read.hdr.opcode = ASM_DATA_CMD_READ_COMPRESSED; - read.buf_add = param->paddr; - read.buf_size = param->len; - read.uid = param->uid; - - pr_debug("%s: session[%d] bufadd[0x%x]len[0x%x]", __func__, ac->session, - read.buf_add, read.buf_size); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &read); - if (rc < 0) { - pr_debug("[%s] read op[0x%x]rc[%d]\n", __func__, - read.hdr.opcode, rc); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_write(struct audio_client *ac, uint32_t len, uint32_t msw_ts, - uint32_t lsw_ts, uint32_t flags) -{ - int rc = 0; - struct asm_stream_cmd_write write; - struct audio_port_data *port; - struct audio_buffer *ab; - int dsp_buf = 0; - - if (!ac || ac->apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s: session[%d] len=%d", __func__, ac->session, len); - if (ac->io_mode & SYNC_IO_MODE) { - port = &ac->port[IN]; - - q6asm_add_hdr(ac, &write.hdr, sizeof(write), - FALSE); - mutex_lock(&port->lock); - - dsp_buf = port->dsp_buf; - ab = &port->buf[dsp_buf]; - - write.hdr.token = port->dsp_buf; - write.hdr.opcode = ASM_DATA_CMD_WRITE; - write.buf_add = ab->phys; - write.avail_bytes = len; - write.uid = port->dsp_buf; - write.msw_ts = msw_ts; - write.lsw_ts = lsw_ts; - /* Use 0xFF00 for disabling timestamps */ - if (flags == 0xFF00) - write.uflags = (0x00000000 | (flags & 0x800000FF)); - else - write.uflags = (0x80000000 | flags); - port->dsp_buf = (port->dsp_buf + 1) & (port->max_buf_cnt - 1); - - pr_debug("%s:ab->phys[0x%x]bufadd[0x%x]token[0x%x]buf_id[0x%x]" - , __func__, - ab->phys, - write.buf_add, - write.hdr.token, - write.uid); - mutex_unlock(&port->lock); -#ifdef CONFIG_DEBUG_FS - if (out_enable_flag) { - char zero_pattern[2] = {0x00, 0x00}; - /* If First two byte is non zero and last two byte - is zero then it is warm output pattern */ - if ((strncmp(((char *)ab->data), zero_pattern, 2)) && - (!strncmp(((char *)ab->data + 2), zero_pattern, 2))) { - do_gettimeofday(&out_warm_tv); - pr_debug("WARM:apr_send_pkt at %ld sec %ld microsec\n", - out_warm_tv.tv_sec,\ - out_warm_tv.tv_usec); - pr_debug("Warm Pattern Matched"); - } - /* If First two byte is zero and last two byte is - non zero then it is cont ouput pattern */ - else if ((!strncmp(((char *)ab->data), zero_pattern, 2)) - && (strncmp(((char *)ab->data + 2), zero_pattern, 2))) { - do_gettimeofday(&out_cont_tv); - pr_debug("CONT:apr_send_pkt at %ld sec %ld microsec\n", - out_cont_tv.tv_sec,\ - out_cont_tv.tv_usec); - pr_debug("Cont Pattern Matched"); - } - } -#endif - rc = apr_send_pkt(ac->apr, (uint32_t *) &write); - if (rc < 0) { - pr_err("write op[0x%x]rc[%d]\n", write.hdr.opcode, rc); - goto fail_cmd; - } - pr_debug("%s: WRITE SUCCESS\n", __func__); - return 0; - } -fail_cmd: - return -EINVAL; -} - -int q6asm_write_nolock(struct audio_client *ac, uint32_t len, uint32_t msw_ts, - uint32_t lsw_ts, uint32_t flags) -{ - int rc = 0; - struct asm_stream_cmd_write write; - struct audio_port_data *port; - struct audio_buffer *ab; - int dsp_buf = 0; - - if (!ac || ac->apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s: session[%d] len=%d", __func__, ac->session, len); - if (ac->io_mode & SYNC_IO_MODE) { - port = &ac->port[IN]; - - q6asm_add_hdr_async(ac, &write.hdr, sizeof(write), - FALSE); - - dsp_buf = port->dsp_buf; - ab = &port->buf[dsp_buf]; - - write.hdr.token = port->dsp_buf; - write.hdr.opcode = ASM_DATA_CMD_WRITE; - write.buf_add = ab->phys; - write.avail_bytes = len; - write.uid = port->dsp_buf; - write.msw_ts = msw_ts; - write.lsw_ts = lsw_ts; - /* Use 0xFF00 for disabling timestamps */ - if (flags == 0xFF00) - write.uflags = (0x00000000 | (flags & 0x800000FF)); - else - write.uflags = (0x80000000 | flags); - port->dsp_buf = (port->dsp_buf + 1) & (port->max_buf_cnt - 1); - - pr_debug("%s:ab->phys[0x%x]bufadd[0x%x]token[0x%x]buf_id[0x%x]" - , __func__, - ab->phys, - write.buf_add, - write.hdr.token, - write.uid); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &write); - if (rc < 0) { - pr_err("write op[0x%x]rc[%d]\n", write.hdr.opcode, rc); - goto fail_cmd; - } - pr_debug("%s: WRITE SUCCESS\n", __func__); - return 0; - } -fail_cmd: - return -EINVAL; -} - -int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp) -{ - struct apr_hdr hdr; - int rc; - - if (!ac || ac->apr == NULL || tstamp == NULL) { - pr_err("APR handle or tstamp NULL\n"); - return -EINVAL; - } - q6asm_add_hdr(ac, &hdr, sizeof(hdr), FALSE); - hdr.opcode = ASM_SESSION_CMD_GET_SESSION_TIME; - atomic_set(&ac->time_flag, 1); - - pr_debug("%s: session[%d]opcode[0x%x]\n", __func__, - ac->session, - hdr.opcode); - rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr); - if (rc < 0) { - pr_err("Commmand 0x%x failed\n", hdr.opcode); - goto fail_cmd; - } - rc = wait_event_timeout(ac->time_wait, - (atomic_read(&ac->time_flag) == 0), 5*HZ); - if (!rc) { - pr_err("%s: timeout in getting session time from DSP\n", - __func__); - goto fail_cmd; - } - - *tstamp = ac->time_stamp; - return 0; - -fail_cmd: - return -EINVAL; -} - -int q6asm_cmd(struct audio_client *ac, int cmd) -{ - struct apr_hdr hdr; - int rc; - atomic_t *state; - int cnt = 0; - - if (!ac || ac->apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - q6asm_add_hdr(ac, &hdr, sizeof(hdr), TRUE); - switch (cmd) { - case CMD_PAUSE: - pr_debug("%s:CMD_PAUSE\n", __func__); - hdr.opcode = ASM_SESSION_CMD_PAUSE; - state = &ac->cmd_state; - break; - case CMD_FLUSH: - pr_debug("%s:CMD_FLUSH\n", __func__); - hdr.opcode = ASM_STREAM_CMD_FLUSH; - state = &ac->cmd_state; - break; - case CMD_OUT_FLUSH: - pr_debug("%s:CMD_OUT_FLUSH\n", __func__); - hdr.opcode = ASM_STREAM_CMD_FLUSH_READBUFS; - state = &ac->cmd_state; - break; - case CMD_EOS: - pr_debug("%s:CMD_EOS\n", __func__); - hdr.opcode = ASM_DATA_CMD_EOS; - atomic_set(&ac->cmd_state, 0); - state = &ac->cmd_state; - break; - case CMD_CLOSE: - pr_debug("%s:CMD_CLOSE\n", __func__); - hdr.opcode = ASM_STREAM_CMD_CLOSE; - atomic_set(&ac->cmd_close_state, 1); - state = &ac->cmd_close_state; - break; - default: - pr_err("Invalid format[%d]\n", cmd); - goto fail_cmd; - } - pr_debug("%s:session[%d]opcode[0x%x] ", __func__, - ac->session, - hdr.opcode); - rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr); - if (rc < 0) { - pr_err("Commmand 0x%x failed\n", hdr.opcode); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, (atomic_read(state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for response opcode[0x%x]\n", - hdr.opcode); - goto fail_cmd; - } - if (cmd == CMD_FLUSH) - q6asm_reset_buf_state(ac); - if (cmd == CMD_CLOSE) { - /* check if DSP return all buffers */ - if (ac->port[IN].buf) { - for (cnt = 0; cnt < ac->port[IN].max_buf_cnt; - cnt++) { - if (ac->port[IN].buf[cnt].used == IN) { - pr_debug("Write Buf[%d] not returned\n", - cnt); - } - } - } - if (ac->port[OUT].buf) { - for (cnt = 0; cnt < ac->port[OUT].max_buf_cnt; cnt++) { - if (ac->port[OUT].buf[cnt].used == OUT) { - pr_debug("Read Buf[%d] not returned\n", - cnt); - } - } - } - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_cmd_nowait(struct audio_client *ac, int cmd) -{ - struct apr_hdr hdr; - int rc; - - if (!ac || ac->apr == NULL) { - pr_err("%s:APR handle NULL\n", __func__); - return -EINVAL; - } - q6asm_add_hdr_async(ac, &hdr, sizeof(hdr), TRUE); - switch (cmd) { - case CMD_PAUSE: - pr_debug("%s:CMD_PAUSE\n", __func__); - hdr.opcode = ASM_SESSION_CMD_PAUSE; - break; - case CMD_EOS: - pr_debug("%s:CMD_EOS\n", __func__); - hdr.opcode = ASM_DATA_CMD_EOS; - break; - default: - pr_err("%s:Invalid format[%d]\n", __func__, cmd); - goto fail_cmd; - } - pr_debug("%s:session[%d]opcode[0x%x] ", __func__, - ac->session, - hdr.opcode); - - rc = apr_send_pkt(ac->apr, (uint32_t *) &hdr); - if (rc < 0) { - pr_err("%s:Commmand 0x%x failed\n", __func__, hdr.opcode); - goto fail_cmd; - } - atomic_inc(&ac->nowait_cmd_cnt); - return 0; -fail_cmd: - return -EINVAL; -} - -static void q6asm_reset_buf_state(struct audio_client *ac) -{ - int cnt = 0; - int loopcnt = 0; - int used; - struct audio_port_data *port = NULL; - - if (ac->io_mode & SYNC_IO_MODE) { - used = (ac->io_mode & TUN_WRITE_IO_MODE ? 1 : 0); - mutex_lock(&ac->cmd_lock); - for (loopcnt = 0; loopcnt <= OUT; loopcnt++) { - port = &ac->port[loopcnt]; - cnt = port->max_buf_cnt - 1; - port->dsp_buf = 0; - port->cpu_buf = 0; - while (cnt >= 0) { - if (!port->buf) - continue; - port->buf[cnt].used = used; - cnt--; - } - } - mutex_unlock(&ac->cmd_lock); - } -} - -int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable) -{ - struct asm_stream_cmd_reg_tx_overflow_event tx_overflow; - int rc; - - if (!ac || ac->apr == NULL) { - pr_err("APR handle NULL\n"); - return -EINVAL; - } - pr_debug("%s:session[%d]enable[%d]\n", __func__, - ac->session, enable); - q6asm_add_hdr(ac, &tx_overflow.hdr, sizeof(tx_overflow), TRUE); - - tx_overflow.hdr.opcode = \ - ASM_SESSION_CMD_REGISTER_FOR_TX_OVERFLOW_EVENTS; - /* tx overflow event: enable */ - tx_overflow.enable = enable; - - rc = apr_send_pkt(ac->apr, (uint32_t *) &tx_overflow); - if (rc < 0) { - pr_err("tx overflow op[0x%x]rc[%d]\n", \ - tx_overflow.hdr.opcode, rc); - goto fail_cmd; - } - rc = wait_event_timeout(ac->cmd_wait, - (atomic_read(&ac->cmd_state) == 0), 5*HZ); - if (!rc) { - pr_err("timeout. waited for tx overflow\n"); - goto fail_cmd; - } - return 0; -fail_cmd: - return -EINVAL; -} - -int q6asm_get_apr_service_id(int session_id) -{ - pr_debug("%s\n", __func__); - - if (session_id < 0 || session_id > SESSION_MAX) { - pr_err("%s: invalid session_id = %d\n", __func__, session_id); - return -EINVAL; - } - - return ((struct apr_svc *)session[session_id]->apr)->id; -} - - -static int __init q6asm_init(void) -{ - pr_debug("%s\n", __func__); - init_waitqueue_head(&this_mmap.cmd_wait); - memset(session, 0, sizeof(session)); -#ifdef CONFIG_DEBUG_FS - out_buffer = kmalloc(OUT_BUFFER_SIZE, GFP_KERNEL); - out_dentry = debugfs_create_file("audio_out_latency_measurement_node",\ - S_IFREG | S_IRUGO | S_IWUGO,\ - NULL, NULL, &audio_output_latency_debug_fops); - if (IS_ERR(out_dentry)) - pr_err("debugfs_create_file failed\n"); - in_buffer = kmalloc(IN_BUFFER_SIZE, GFP_KERNEL); - in_dentry = debugfs_create_file("audio_in_latency_measurement_node",\ - S_IFREG | S_IRUGO | S_IWUGO,\ - NULL, NULL, &audio_input_latency_debug_fops); - if (IS_ERR(in_dentry)) - pr_err("debugfs_create_file failed\n"); -#endif - return 0; -} - -device_initcall(q6asm_init); diff --git a/sound/soc/msm/qdsp6/q6voice.c b/sound/soc/msm/qdsp6/q6voice.c deleted file mode 100644 index cd642ea65b11fcc6c3dc4bb9a7f10036f399d84f..0000000000000000000000000000000000000000 --- a/sound/soc/msm/qdsp6/q6voice.c +++ /dev/null @@ -1,4674 +0,0 @@ -/* Copyright (c) 2011-2013, 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "sound/apr_audio.h" -#include "sound/q6afe.h" - -#include "q6voice.h" - -#define TIMEOUT_MS 3000 - -#define CMD_STATUS_SUCCESS 0 -#define CMD_STATUS_FAIL 1 - -#define CAL_BUFFER_SIZE 4096 -#define NUM_CVP_CAL_BLOCKS 75 -#define NUM_CVS_CAL_BLOCKS 15 -#define CVP_CAL_SIZE (NUM_CVP_CAL_BLOCKS * CAL_BUFFER_SIZE) -#define CVS_CAL_SIZE (NUM_CVS_CAL_BLOCKS * CAL_BUFFER_SIZE) -#define VOICE_CAL_BUFFER_SIZE (CVP_CAL_SIZE + CVS_CAL_SIZE) -/* Total cal needed to support concurrent VOIP & VOLTE sessions */ -/* Due to memory map issue on Q6 separate memory has to be used */ -/* for VOIP & VOLTE */ -#define TOTAL_VOICE_CAL_SIZE (NUM_VOICE_CAL_BUFFERS * VOICE_CAL_BUFFER_SIZE) - -static struct common_data common; - -static int voice_send_enable_vocproc_cmd(struct voice_data *v); -static int voice_send_netid_timing_cmd(struct voice_data *v); -static int voice_send_attach_vocproc_cmd(struct voice_data *v); -static int voice_send_set_device_cmd(struct voice_data *v); -static int voice_send_disable_vocproc_cmd(struct voice_data *v); -static int voice_send_vol_index_cmd(struct voice_data *v); -static int voice_send_cvp_map_memory_cmd(struct voice_data *v, - uint32_t paddr, uint32_t mem_size); -static int voice_send_cvp_unmap_memory_cmd(struct voice_data *v, - uint32_t paddr); -static int voice_send_cvs_map_memory_cmd(struct voice_data *v); -static int voice_send_cvs_unmap_memory_cmd(struct voice_data *v); -static int voice_send_cvs_register_cal_cmd(struct voice_data *v); -static int voice_send_cvs_deregister_cal_cmd(struct voice_data *v); -static int voice_send_cvp_register_cal_cmd(struct voice_data *v); -static int voice_send_cvp_deregister_cal_cmd(struct voice_data *v); -static int voice_send_cvp_register_vol_cal_table_cmd(struct voice_data *v); -static int voice_send_cvp_deregister_vol_cal_table_cmd(struct voice_data *v); -static int voice_send_set_widevoice_enable_cmd(struct voice_data *v); -static int voice_send_set_pp_enable_cmd(struct voice_data *v, - uint32_t module_id, int enable); -static int voice_cvs_stop_playback(struct voice_data *v); -static int voice_cvs_start_playback(struct voice_data *v); -static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode); -static int voice_cvs_stop_record(struct voice_data *v); - -static int32_t qdsp_mvm_callback(struct apr_client_data *data, void *priv); -static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv); -static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv); -static int voice_send_set_device_cmd_v2(struct voice_data *v); - -static u16 voice_get_mvm_handle(struct voice_data *v) -{ - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return 0; - } - - pr_debug("%s: mvm_handle %d\n", __func__, v->mvm_handle); - - return v->mvm_handle; -} - -static void voice_set_mvm_handle(struct voice_data *v, u16 mvm_handle) -{ - pr_debug("%s: mvm_handle %d\n", __func__, mvm_handle); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return; - } - - v->mvm_handle = mvm_handle; -} - -static u16 voice_get_cvs_handle(struct voice_data *v) -{ - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return 0; - } - - pr_debug("%s: cvs_handle %d\n", __func__, v->cvs_handle); - - return v->cvs_handle; -} - -static void voice_set_cvs_handle(struct voice_data *v, u16 cvs_handle) -{ - pr_debug("%s: cvs_handle %d\n", __func__, cvs_handle); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return; - } - - v->cvs_handle = cvs_handle; -} - -static u16 voice_get_cvp_handle(struct voice_data *v) -{ - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return 0; - } - - pr_debug("%s: cvp_handle %d\n", __func__, v->cvp_handle); - - return v->cvp_handle; -} - -static void voice_set_cvp_handle(struct voice_data *v, u16 cvp_handle) -{ - pr_debug("%s: cvp_handle %d\n", __func__, cvp_handle); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return; - } - - v->cvp_handle = cvp_handle; -} - -char *voc_get_session_name(u16 session_id) -{ - char *session_name = NULL; - - if (session_id == common.voice[VOC_PATH_PASSIVE].session_id) { - session_name = VOICE_SESSION_NAME; - } else if (session_id == - common.voice[VOC_PATH_VOLTE_PASSIVE].session_id) { - session_name = VOLTE_SESSION_NAME; - } else if (session_id == common.voice[VOC_PATH_FULL].session_id) { - session_name = VOIP_SESSION_NAME; - } - return session_name; -} - -uint16_t voc_get_session_id(char *name) -{ - u16 session_id = 0; - - if (name != NULL) { - if (!strncmp(name, "Voice session", 13)) - session_id = common.voice[VOC_PATH_PASSIVE].session_id; - else if (!strncmp(name, "VoLTE session", 13)) - session_id = - common.voice[VOC_PATH_VOLTE_PASSIVE].session_id; - else if (!strncmp(name, "Voice2 session", 14)) - session_id = - common.voice[VOC_PATH_VOICE2_PASSIVE].session_id; - else - session_id = common.voice[VOC_PATH_FULL].session_id; - - pr_debug("%s: %s has session id 0x%x\n", __func__, name, - session_id); - } - - return session_id; -} - -static struct voice_data *voice_get_session(u16 session_id) -{ - struct voice_data *v = NULL; - - if ((session_id >= SESSION_ID_BASE) && - (session_id < SESSION_ID_BASE + MAX_VOC_SESSIONS)) { - v = &common.voice[session_id - SESSION_ID_BASE]; - } - - pr_debug("%s: session_id 0x%x session handle 0x%x\n", - __func__, session_id, (unsigned int)v); - - return v; -} - -static bool is_voice_session(u16 session_id) -{ - return (session_id == common.voice[VOC_PATH_PASSIVE].session_id); -} - -static bool is_voip_session(u16 session_id) -{ - return (session_id == common.voice[VOC_PATH_FULL].session_id); -} - -static bool is_volte_session(u16 session_id) -{ - return (session_id == common.voice[VOC_PATH_VOLTE_PASSIVE].session_id); -} - -static bool is_voice2_session(u16 session_id) -{ - return (session_id == common.voice[VOC_PATH_VOICE2_PASSIVE].session_id); -} - -/* Only for memory allocated in the voice driver */ -/* which includes voip & volte */ -static int voice_get_cal_kernel_addr(int16_t session_id, int cal_type, - uint32_t *kvaddr) -{ - int i, result = 0; - pr_debug("%s\n", __func__); - - if (kvaddr == NULL) { - pr_err("%s: NULL pointer sent to function\n", __func__); - result = -EINVAL; - goto done; - } else if (is_voip_session(session_id)) { - i = VOIP_CAL; - } else if (is_volte_session(session_id)) { - i = VOLTE_CAL; - } else { - result = -EINVAL; - goto done; - } - - if (common.voice_cal[i].cal_data[cal_type].kvaddr == 0) { - pr_err("%s: NULL pointer for session_id %d, type %d, cal_type %d\n", - __func__, session_id, i, cal_type); - result = -EFAULT; - goto done; - } - - *kvaddr = common.voice_cal[i].cal_data[cal_type].kvaddr; -done: - return result; -} - -/* Only for memory allocated in the voice driver */ -/* which includes voip & volte */ -static int voice_get_cal_phys_addr(int16_t session_id, int cal_type, - uint32_t *paddr) -{ - int i, result = 0; - pr_debug("%s\n", __func__); - - if (paddr == NULL) { - pr_err("%s: NULL pointer sent to function\n", __func__); - result = -EINVAL; - goto done; - } else if (is_voip_session(session_id)) { - i = VOIP_CAL; - } else if (is_volte_session(session_id)) { - i = VOLTE_CAL; - } else { - result = -EINVAL; - goto done; - } - - if (common.voice_cal[i].cal_data[cal_type].paddr == 0) { - pr_err("%s: No addr for session_id %d, type %d, cal_type %d\n", - __func__, session_id, i, cal_type); - result = -EFAULT; - goto done; - } - - *paddr = common.voice_cal[i].cal_data[cal_type].paddr; -done: - return result; -} - -static int voice_apr_register(void) -{ - pr_debug("%s\n", __func__); - - mutex_lock(&common.common_lock); - - /* register callback to APR */ - if (common.apr_q6_mvm == NULL) { - pr_debug("%s: Start to register MVM callback\n", __func__); - - common.apr_q6_mvm = apr_register("ADSP", "MVM", - qdsp_mvm_callback, - 0xFFFFFFFF, &common); - - if (common.apr_q6_mvm == NULL) { - pr_err("%s: Unable to register MVM\n", __func__); - goto err; - } - } - - if (common.apr_q6_cvs == NULL) { - pr_debug("%s: Start to register CVS callback\n", __func__); - - common.apr_q6_cvs = apr_register("ADSP", "CVS", - qdsp_cvs_callback, - 0xFFFFFFFF, &common); - - if (common.apr_q6_cvs == NULL) { - pr_err("%s: Unable to register CVS\n", __func__); - goto err; - } - - rtac_set_voice_handle(RTAC_CVS, common.apr_q6_cvs); - } - - if (common.apr_q6_cvp == NULL) { - pr_debug("%s: Start to register CVP callback\n", __func__); - - common.apr_q6_cvp = apr_register("ADSP", "CVP", - qdsp_cvp_callback, - 0xFFFFFFFF, &common); - - if (common.apr_q6_cvp == NULL) { - pr_err("%s: Unable to register CVP\n", __func__); - goto err; - } - - rtac_set_voice_handle(RTAC_CVP, common.apr_q6_cvp); - } - - mutex_unlock(&common.common_lock); - - return 0; - -err: - if (common.apr_q6_cvs != NULL) { - apr_deregister(common.apr_q6_cvs); - common.apr_q6_cvs = NULL; - rtac_set_voice_handle(RTAC_CVS, NULL); - } - if (common.apr_q6_mvm != NULL) { - apr_deregister(common.apr_q6_mvm); - common.apr_q6_mvm = NULL; - } - - mutex_unlock(&common.common_lock); - - return -ENODEV; -} - -static int voice_send_dual_control_cmd(struct voice_data *v) -{ - int ret = 0; - struct mvm_modem_dual_control_session_cmd mvm_voice_ctl_cmd; - void *apr_mvm; - u16 mvm_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - pr_debug("%s: VoLTE/Voice2 command to MVM\n", __func__); - if (is_volte_session(v->session_id) || - is_voice2_session(v->session_id)) { - - mvm_handle = voice_get_mvm_handle(v); - mvm_voice_ctl_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_voice_ctl_cmd.hdr.pkt_size = APR_PKT_SIZE( - APR_HDR_SIZE, - sizeof(mvm_voice_ctl_cmd) - - APR_HDR_SIZE); - pr_debug("%s: send mvm Voice Ctl pkt size = %d\n", - __func__, mvm_voice_ctl_cmd.hdr.pkt_size); - mvm_voice_ctl_cmd.hdr.src_port = v->session_id; - mvm_voice_ctl_cmd.hdr.dest_port = mvm_handle; - mvm_voice_ctl_cmd.hdr.token = 0; - mvm_voice_ctl_cmd.hdr.opcode = - VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL; - mvm_voice_ctl_cmd.voice_ctl.enable_flag = true; - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_voice_ctl_cmd); - if (ret < 0) { - pr_err("%s: Error sending MVM Voice CTL CMD\n", - __func__); - ret = -EINVAL; - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - ret = -EINVAL; - goto fail; - } - } - ret = 0; -fail: - return ret; -} - - -static int voice_create_mvm_cvs_session(struct voice_data *v) -{ - int ret = 0; - struct mvm_create_ctl_session_cmd mvm_session_cmd; - struct cvs_create_passive_ctl_session_cmd cvs_session_cmd; - struct cvs_create_full_ctl_session_cmd cvs_full_ctl_cmd; - struct mvm_attach_stream_cmd attach_stream_cmd; - void *apr_mvm, *apr_cvs, *apr_cvp; - u16 mvm_handle, cvs_handle, cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - apr_cvs = common.apr_q6_cvs; - apr_cvp = common.apr_q6_cvp; - - if (!apr_mvm || !apr_cvs || !apr_cvp) { - pr_err("%s: apr_mvm or apr_cvs or apr_cvp is NULL\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - cvs_handle = voice_get_cvs_handle(v); - cvp_handle = voice_get_cvp_handle(v); - - pr_debug("%s: mvm_hdl=%d, cvs_hdl=%d\n", __func__, - mvm_handle, cvs_handle); - /* send cmd to create mvm session and wait for response */ - - if (!mvm_handle) { - if (is_voice_session(v->session_id) || - is_volte_session(v->session_id) || - is_voice2_session(v->session_id)) { - mvm_session_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_session_cmd.hdr.pkt_size = APR_PKT_SIZE( - APR_HDR_SIZE, - sizeof(mvm_session_cmd) - - APR_HDR_SIZE); - pr_debug("%s: send mvm create session pkt size = %d\n", - __func__, mvm_session_cmd.hdr.pkt_size); - mvm_session_cmd.hdr.src_port = v->session_id; - mvm_session_cmd.hdr.dest_port = 0; - mvm_session_cmd.hdr.token = 0; - mvm_session_cmd.hdr.opcode = - VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION; - if (is_volte_session(v->session_id)) { - strlcpy(mvm_session_cmd.mvm_session.name, - "default volte voice", - sizeof(mvm_session_cmd.mvm_session.name) - 1); - } else if (is_voice2_session(v->session_id)) { - strlcpy(mvm_session_cmd.mvm_session.name, - "default modem voice2", - sizeof(mvm_session_cmd.mvm_session.name)); - } else { - strlcpy(mvm_session_cmd.mvm_session.name, - "default modem voice", - sizeof(mvm_session_cmd.mvm_session.name) - 1); - } - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, - (uint32_t *) &mvm_session_cmd); - if (ret < 0) { - pr_err("%s: Error sending MVM_CONTROL_SESSION\n", - __func__); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - } else { - pr_debug("%s: creating MVM full ctrl\n", __func__); - mvm_session_cmd.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_session_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_session_cmd) - - APR_HDR_SIZE); - mvm_session_cmd.hdr.src_port = v->session_id; - mvm_session_cmd.hdr.dest_port = 0; - mvm_session_cmd.hdr.token = 0; - mvm_session_cmd.hdr.opcode = - VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION; - strlcpy(mvm_session_cmd.mvm_session.name, - "default voip", - sizeof(mvm_session_cmd.mvm_session.name)); - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, - (uint32_t *) &mvm_session_cmd); - if (ret < 0) { - pr_err("Fail in sending MVM_CONTROL_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - } - /* Get the created MVM handle. */ - mvm_handle = voice_get_mvm_handle(v); - } - /* send cmd to create cvs session */ - if (!cvs_handle) { - if (is_voice_session(v->session_id) || - is_volte_session(v->session_id) || - is_voice2_session(v->session_id)) { - pr_debug("%s: creating CVS passive session\n", - __func__); - - cvs_session_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_session_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_session_cmd) - - APR_HDR_SIZE); - cvs_session_cmd.hdr.src_port = v->session_id; - cvs_session_cmd.hdr.dest_port = 0; - cvs_session_cmd.hdr.token = 0; - cvs_session_cmd.hdr.opcode = - VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION; - if (is_volte_session(v->session_id)) { - strlcpy(cvs_session_cmd.cvs_session.name, - "default volte voice", - sizeof(cvs_session_cmd.cvs_session.name) - 1); - } else if (is_voice2_session(v->session_id)) { - strlcpy(cvs_session_cmd.cvs_session.name, - "default modem voice2", - sizeof(cvs_session_cmd.cvs_session.name)); - } else { - strlcpy(cvs_session_cmd.cvs_session.name, - "default modem voice", - sizeof(cvs_session_cmd.cvs_session.name) - 1); - } - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, - (uint32_t *) &cvs_session_cmd); - if (ret < 0) { - pr_err("Fail in sending STREAM_CONTROL_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - /* Get the created CVS handle. */ - cvs_handle = voice_get_cvs_handle(v); - - } else { - pr_debug("%s: creating CVS full session\n", __func__); - - cvs_full_ctl_cmd.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - - cvs_full_ctl_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_full_ctl_cmd) - - APR_HDR_SIZE); - - cvs_full_ctl_cmd.hdr.src_port = v->session_id; - cvs_full_ctl_cmd.hdr.dest_port = 0; - cvs_full_ctl_cmd.hdr.token = 0; - cvs_full_ctl_cmd.hdr.opcode = - VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION; - cvs_full_ctl_cmd.cvs_session.direction = 2; - cvs_full_ctl_cmd.cvs_session.enc_media_type = - common.mvs_info.media_type; - cvs_full_ctl_cmd.cvs_session.dec_media_type = - common.mvs_info.media_type; - cvs_full_ctl_cmd.cvs_session.network_id = - common.mvs_info.network_type; - strlcpy(cvs_full_ctl_cmd.cvs_session.name, - "default q6 voice", - sizeof(cvs_full_ctl_cmd.cvs_session.name)); - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, - (uint32_t *) &cvs_full_ctl_cmd); - - if (ret < 0) { - pr_err("%s: Err %d sending CREATE_FULL_CTRL\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - /* Get the created CVS handle. */ - cvs_handle = voice_get_cvs_handle(v); - - /* Attach MVM to CVS. */ - pr_debug("%s: Attach MVM to stream\n", __func__); - - attach_stream_cmd.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - attach_stream_cmd.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(attach_stream_cmd) - - APR_HDR_SIZE); - attach_stream_cmd.hdr.src_port = v->session_id; - attach_stream_cmd.hdr.dest_port = mvm_handle; - attach_stream_cmd.hdr.token = 0; - attach_stream_cmd.hdr.opcode = - VSS_IMVM_CMD_ATTACH_STREAM; - attach_stream_cmd.attach_stream.handle = cvs_handle; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, - (uint32_t *) &attach_stream_cmd); - if (ret < 0) { - pr_err("%s: Error %d sending ATTACH_STREAM\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - } - } - return 0; - -fail: - return -EINVAL; -} - -static int voice_destroy_mvm_cvs_session(struct voice_data *v) -{ - int ret = 0; - struct mvm_detach_stream_cmd detach_stream; - struct apr_hdr mvm_destroy; - struct apr_hdr cvs_destroy; - void *apr_mvm, *apr_cvs; - u16 mvm_handle, cvs_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - apr_cvs = common.apr_q6_cvs; - - if (!apr_mvm || !apr_cvs) { - pr_err("%s: apr_mvm or apr_cvs is NULL\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - cvs_handle = voice_get_cvs_handle(v); - - /* MVM, CVS sessions are destroyed only for Full control sessions. */ - if (is_voip_session(v->session_id)) { - pr_debug("%s: MVM detach stream\n", __func__); - - /* Detach voice stream. */ - detach_stream.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - detach_stream.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(detach_stream) - APR_HDR_SIZE); - detach_stream.hdr.src_port = v->session_id; - detach_stream.hdr.dest_port = mvm_handle; - detach_stream.hdr.token = 0; - detach_stream.hdr.opcode = VSS_IMVM_CMD_DETACH_STREAM; - detach_stream.detach_stream.handle = cvs_handle; - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, (uint32_t *) &detach_stream); - if (ret < 0) { - pr_err("%s: Error %d sending DETACH_STREAM\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait event timeout\n", __func__); - goto fail; - } - /* Destroy CVS. */ - pr_debug("%s: CVS destroy session\n", __func__); - - cvs_destroy.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_destroy.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_destroy) - APR_HDR_SIZE); - cvs_destroy.src_port = v->session_id; - cvs_destroy.dest_port = cvs_handle; - cvs_destroy.token = 0; - cvs_destroy.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_destroy); - if (ret < 0) { - pr_err("%s: Error %d sending CVS DESTROY\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait event timeout\n", __func__); - - goto fail; - } - cvs_handle = 0; - voice_set_cvs_handle(v, cvs_handle); - - /* Destroy MVM. */ - pr_debug("MVM destroy session\n"); - - mvm_destroy.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_destroy.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_destroy) - APR_HDR_SIZE); - mvm_destroy.src_port = v->session_id; - mvm_destroy.dest_port = mvm_handle; - mvm_destroy.token = 0; - mvm_destroy.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION; - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_destroy); - if (ret < 0) { - pr_err("%s: Error %d sending MVM DESTROY\n", - __func__, ret); - - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait event timeout\n", __func__); - - goto fail; - } - mvm_handle = 0; - voice_set_mvm_handle(v, mvm_handle); - } - return 0; -fail: - return -EINVAL; -} - -static int voice_send_tty_mode_cmd(struct voice_data *v) -{ - int ret = 0; - struct mvm_set_tty_mode_cmd mvm_tty_mode_cmd; - void *apr_mvm; - u16 mvm_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - - if (v->tty_mode) { - /* send tty mode cmd to mvm */ - mvm_tty_mode_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_tty_mode_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_tty_mode_cmd) - - APR_HDR_SIZE); - pr_debug("%s: pkt size = %d\n", - __func__, mvm_tty_mode_cmd.hdr.pkt_size); - mvm_tty_mode_cmd.hdr.src_port = v->session_id; - mvm_tty_mode_cmd.hdr.dest_port = mvm_handle; - mvm_tty_mode_cmd.hdr.token = 0; - mvm_tty_mode_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_TTY_MODE; - mvm_tty_mode_cmd.tty_mode.mode = v->tty_mode; - pr_debug("tty mode =%d\n", mvm_tty_mode_cmd.tty_mode.mode); - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_tty_mode_cmd); - if (ret < 0) { - pr_err("%s: Error %d sending SET_TTY_MODE\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - } - return 0; -fail: - return -EINVAL; -} - -static int voice_set_dtx(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - struct cvs_set_enc_dtx_mode_cmd cvs_set_dtx; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - cvs_handle = voice_get_cvs_handle(v); - - /* Set DTX */ - cvs_set_dtx.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_dtx.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_dtx) - APR_HDR_SIZE); - cvs_set_dtx.hdr.src_port = v->session_id; - cvs_set_dtx.hdr.dest_port = cvs_handle; - cvs_set_dtx.hdr.token = 0; - cvs_set_dtx.hdr.opcode = VSS_ISTREAM_CMD_SET_ENC_DTX_MODE; - cvs_set_dtx.dtx_mode.enable = common.mvs_info.dtx_mode; - - pr_debug("%s: Setting DTX %d\n", __func__, common.mvs_info.dtx_mode); - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_dtx); - if (ret < 0) { - pr_err("%s: Error %d sending SET_DTX\n", __func__, ret); - return -EINVAL; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - - return 0; -} - -static int voice_send_dtmf_rx_detection_cmd(struct voice_data *v, - uint32_t enable) -{ - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - struct cvs_set_rx_dtmf_detection_cmd cvs_dtmf_rx_detection; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - cvs_handle = voice_get_cvs_handle(v); - - /* Set SET_DTMF_RX_DETECTION */ - cvs_dtmf_rx_detection.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_dtmf_rx_detection.hdr.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_dtmf_rx_detection) - APR_HDR_SIZE); - cvs_dtmf_rx_detection.hdr.src_port = v->session_id; - cvs_dtmf_rx_detection.hdr.dest_port = cvs_handle; - cvs_dtmf_rx_detection.hdr.token = 0; - cvs_dtmf_rx_detection.hdr.opcode = - VSS_ISTREAM_CMD_SET_RX_DTMF_DETECTION; - cvs_dtmf_rx_detection.cvs_dtmf_det.enable = enable; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_dtmf_rx_detection); - if (ret < 0) { - pr_err("%s: Error %d sending SET_DTMF_RX_DETECTION\n", - __func__, - ret); - return -EINVAL; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - - return ret; -} - -void voc_disable_dtmf_det_on_active_sessions(void) -{ - struct voice_data *v = NULL; - int i; - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - v = &common.voice[i]; - if ((v->dtmf_rx_detect_en) && - ((v->voc_state == VOC_RUN) || - (v->voc_state == VOC_CHANGE) || - (v->voc_state == VOC_STANDBY))) { - pr_debug("disable dtmf det on ses_id=%d\n", - v->session_id); - voice_send_dtmf_rx_detection_cmd(v, 0); - } - } -} - -int voc_enable_dtmf_rx_detection(uint16_t session_id, uint32_t enable) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - return -EINVAL; - } - - mutex_lock(&v->lock); - v->dtmf_rx_detect_en = enable; - - if ((v->voc_state == VOC_RUN) || - (v->voc_state == VOC_CHANGE) || - (v->voc_state == VOC_STANDBY)) - ret = voice_send_dtmf_rx_detection_cmd(v, - v->dtmf_rx_detect_en); - - mutex_unlock(&v->lock); - - return ret; -} - -static int voice_config_cvs_vocoder(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - /* Set media type. */ - struct cvs_set_media_type_cmd cvs_set_media_cmd; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - cvs_handle = voice_get_cvs_handle(v); - - cvs_set_media_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_media_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_media_cmd) - APR_HDR_SIZE); - cvs_set_media_cmd.hdr.src_port = v->session_id; - cvs_set_media_cmd.hdr.dest_port = cvs_handle; - cvs_set_media_cmd.hdr.token = 0; - cvs_set_media_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_MEDIA_TYPE; - cvs_set_media_cmd.media_type.tx_media_id = common.mvs_info.media_type; - cvs_set_media_cmd.media_type.rx_media_id = common.mvs_info.media_type; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_media_cmd); - if (ret < 0) { - pr_err("%s: Error %d sending SET_MEDIA_TYPE\n", - __func__, ret); - - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - /* Set encoder properties. */ - switch (common.mvs_info.media_type) { - case VSS_MEDIA_ID_EVRC_MODEM: - case VSS_MEDIA_ID_4GV_NB_MODEM: - case VSS_MEDIA_ID_4GV_WB_MODEM: { - struct cvs_set_cdma_enc_minmax_rate_cmd cvs_set_cdma_rate; - - pr_debug("Setting EVRC min-max rate\n"); - - cvs_set_cdma_rate.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_cdma_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_cdma_rate) - APR_HDR_SIZE); - cvs_set_cdma_rate.hdr.src_port = v->session_id; - cvs_set_cdma_rate.hdr.dest_port = cvs_handle; - cvs_set_cdma_rate.hdr.token = 0; - cvs_set_cdma_rate.hdr.opcode = - VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE; - cvs_set_cdma_rate.cdma_rate.min_rate = common.mvs_info.rate; - cvs_set_cdma_rate.cdma_rate.max_rate = common.mvs_info.rate; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_cdma_rate); - if (ret < 0) { - pr_err("%s: Error %d sending SET_EVRC_MINMAX_RATE\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - break; - } - case VSS_MEDIA_ID_AMR_NB_MODEM: { - struct cvs_set_amr_enc_rate_cmd cvs_set_amr_rate; - - pr_debug("Setting AMR rate\n"); - - cvs_set_amr_rate.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_amr_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_amr_rate) - APR_HDR_SIZE); - cvs_set_amr_rate.hdr.src_port = v->session_id; - cvs_set_amr_rate.hdr.dest_port = cvs_handle; - cvs_set_amr_rate.hdr.token = 0; - cvs_set_amr_rate.hdr.opcode = - VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE; - cvs_set_amr_rate.amr_rate.mode = common.mvs_info.rate; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_amr_rate); - if (ret < 0) { - pr_err("%s: Error %d sending SET_AMR_RATE\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - ret = voice_set_dtx(v); - if (ret < 0) - goto fail; - - break; - } - case VSS_MEDIA_ID_AMR_WB_MODEM: { - struct cvs_set_amrwb_enc_rate_cmd cvs_set_amrwb_rate; - - pr_debug("Setting AMR WB rate\n"); - - cvs_set_amrwb_rate.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_set_amrwb_rate.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_amrwb_rate) - - APR_HDR_SIZE); - cvs_set_amrwb_rate.hdr.src_port = v->session_id; - cvs_set_amrwb_rate.hdr.dest_port = cvs_handle; - cvs_set_amrwb_rate.hdr.token = 0; - cvs_set_amrwb_rate.hdr.opcode = - VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE; - cvs_set_amrwb_rate.amrwb_rate.mode = common.mvs_info.rate; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_amrwb_rate); - if (ret < 0) { - pr_err("%s: Error %d sending SET_AMRWB_RATE\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - ret = voice_set_dtx(v); - if (ret < 0) - goto fail; - - break; - } - case VSS_MEDIA_ID_G729: - case VSS_MEDIA_ID_G711_ALAW: - case VSS_MEDIA_ID_G711_MULAW: { - ret = voice_set_dtx(v); - - break; - } - default: - /* Do nothing. */ - break; - } - return 0; - -fail: - return -EINVAL; -} - -static int voice_send_start_voice_cmd(struct voice_data *v) -{ - struct apr_hdr mvm_start_voice_cmd; - int ret = 0; - void *apr_mvm; - u16 mvm_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - - mvm_start_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_start_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_start_voice_cmd) - APR_HDR_SIZE); - pr_debug("send mvm_start_voice_cmd pkt size = %d\n", - mvm_start_voice_cmd.pkt_size); - mvm_start_voice_cmd.src_port = v->session_id; - mvm_start_voice_cmd.dest_port = mvm_handle; - mvm_start_voice_cmd.token = 0; - mvm_start_voice_cmd.opcode = VSS_IMVM_CMD_START_VOICE; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_start_voice_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_START_VOICE\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; -} - -static int voice_send_disable_vocproc_cmd(struct voice_data *v) -{ - struct apr_hdr cvp_disable_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr regist failed\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - /* disable vocproc and wait for respose */ - cvp_disable_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_disable_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_disable_cmd) - APR_HDR_SIZE); - pr_debug("cvp_disable_cmd pkt size = %d, cvp_handle=%d\n", - cvp_disable_cmd.pkt_size, cvp_handle); - cvp_disable_cmd.src_port = v->session_id; - cvp_disable_cmd.dest_port = cvp_handle; - cvp_disable_cmd.token = 0; - cvp_disable_cmd.opcode = VSS_IVOCPROC_CMD_DISABLE; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_disable_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IVOCPROC_CMD_DISABLE\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static void voc_get_tx_rx_topology(struct voice_data *v, - uint32_t *tx_topology_id, - uint32_t *rx_topology_id) -{ - - uint32_t tx_id = 0; - uint32_t rx_id = 0; - - if (v->disable_topology) { - tx_id = VSS_IVOCPROC_TOPOLOGY_ID_NONE; - rx_id = VSS_IVOCPROC_TOPOLOGY_ID_NONE; - } else { - /* Use default topology if invalid value in ACDB */ - tx_id = get_voice_tx_topology(); - if (tx_id == 0) - tx_id = VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS; - - rx_id = get_voice_rx_topology(); - if (rx_id == 0) - rx_id = VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT; - } - - *tx_topology_id = tx_id; - *rx_topology_id = rx_id; -} - -static int voice_send_set_device_cmd(struct voice_data *v) -{ - struct cvp_set_device_cmd cvp_setdev_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - /* set device and wait for response */ - cvp_setdev_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_setdev_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_setdev_cmd) - APR_HDR_SIZE); - pr_debug(" send create cvp setdev, pkt size = %d\n", - cvp_setdev_cmd.hdr.pkt_size); - cvp_setdev_cmd.hdr.src_port = v->session_id; - cvp_setdev_cmd.hdr.dest_port = cvp_handle; - cvp_setdev_cmd.hdr.token = 0; - cvp_setdev_cmd.hdr.opcode = VSS_IVOCPROC_CMD_SET_DEVICE; - - voc_get_tx_rx_topology(v, &cvp_setdev_cmd.cvp_set_device.tx_topology_id, - &cvp_setdev_cmd.cvp_set_device.rx_topology_id); - - cvp_setdev_cmd.cvp_set_device.tx_port_id = v->dev_tx.port_id; - cvp_setdev_cmd.cvp_set_device.rx_port_id = v->dev_rx.port_id; - pr_debug("topology=%d , tx_port_id=%d, rx_port_id=%d\n", - cvp_setdev_cmd.cvp_set_device.tx_topology_id, - cvp_setdev_cmd.cvp_set_device.tx_port_id, - cvp_setdev_cmd.cvp_set_device.rx_port_id); - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_setdev_cmd); - if (ret < 0) { - pr_err("Fail in sending VOCPROC_FULL_CONTROL_SESSION\n"); - goto fail; - } - pr_debug("wait for cvp create session event\n"); - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_set_device_cmd_v2(struct voice_data *v) -{ - struct cvp_set_device_cmd_v2 cvp_setdev_cmd_v2; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - /* set device and wait for response */ - cvp_setdev_cmd_v2.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_setdev_cmd_v2.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_setdev_cmd_v2) - APR_HDR_SIZE); - cvp_setdev_cmd_v2.hdr.src_port = v->session_id; - cvp_setdev_cmd_v2.hdr.dest_port = cvp_handle; - cvp_setdev_cmd_v2.hdr.token = 0; - cvp_setdev_cmd_v2.hdr.opcode = VSS_IVOCPROC_CMD_SET_DEVICE_V2; - - voc_get_tx_rx_topology(v, - &cvp_setdev_cmd_v2.cvp_set_device_v2.tx_topology_id, - &cvp_setdev_cmd_v2.cvp_set_device_v2.rx_topology_id); - - cvp_setdev_cmd_v2.cvp_set_device_v2.tx_port_id = v->dev_tx.port_id; - cvp_setdev_cmd_v2.cvp_set_device_v2.rx_port_id = v->dev_rx.port_id; - if (common.ec_ref_ext == true) { - cvp_setdev_cmd_v2.cvp_set_device_v2.vocproc_mode = - VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING; - cvp_setdev_cmd_v2.cvp_set_device_v2.ec_ref_port_id = - common.ec_port_id; - } else { - cvp_setdev_cmd_v2.cvp_set_device_v2.vocproc_mode = - VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING; - cvp_setdev_cmd_v2.cvp_set_device_v2.ec_ref_port_id = - VSS_IVOCPROC_PORT_ID_NONE; - } - pr_debug("%s:topology=%d , tx_port_id=%d, rx_port_id=%d\n" - "ec_ref_port_id = %x\n", __func__, - cvp_setdev_cmd_v2.cvp_set_device_v2.tx_topology_id, - cvp_setdev_cmd_v2.cvp_set_device_v2.tx_port_id, - cvp_setdev_cmd_v2.cvp_set_device_v2.rx_port_id, - cvp_setdev_cmd_v2.cvp_set_device_v2.ec_ref_port_id); - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_setdev_cmd_v2); - if (ret < 0) { - pr_err("Fail in sending VOCPROC_FULL_CONTROL_SESSION\n"); - goto fail; - } - pr_debug("wait for cvp create session event\n"); - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_stop_voice_cmd(struct voice_data *v) -{ - struct apr_hdr mvm_stop_voice_cmd; - int ret = 0; - void *apr_mvm; - u16 mvm_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - - mvm_stop_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_stop_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_stop_voice_cmd) - APR_HDR_SIZE); - pr_debug("send mvm_stop_voice_cmd pkt size = %d\n", - mvm_stop_voice_cmd.pkt_size); - mvm_stop_voice_cmd.src_port = v->session_id; - mvm_stop_voice_cmd.dest_port = mvm_handle; - mvm_stop_voice_cmd.token = 0; - mvm_stop_voice_cmd.opcode = VSS_IMVM_CMD_STOP_VOICE; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_stop_voice_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_STOP_VOICE\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_cvs_register_cal_cmd(struct voice_data *v) -{ - struct cvs_register_cal_data_cmd cvs_reg_cal_cmd; - struct acdb_cal_block cal_block; - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - uint32_t cal_paddr = 0; - uint32_t cal_buf = 0; - - /* get the cvs cal data */ - get_all_vocstrm_cal(&cal_block); - if (cal_block.cal_size == 0 || - cal_block.cal_size > CVS_CAL_SIZE) - goto fail; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - if (is_volte_session(v->session_id) || - is_voip_session(v->session_id)) { - ret = voice_get_cal_phys_addr(v->session_id, CVS_CAL, - &cal_paddr); - if (ret < 0) - return ret; - - ret = voice_get_cal_kernel_addr(v->session_id, CVS_CAL, - &cal_buf); - if (ret < 0) - return ret; - - memcpy((void *)cal_buf, (void *)cal_block.cal_kvaddr, - cal_block.cal_size); - } else { - cal_paddr = cal_block.cal_paddr; - } - - cvs_handle = voice_get_cvs_handle(v); - - /* fill in the header */ - cvs_reg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_reg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_reg_cal_cmd) - APR_HDR_SIZE); - cvs_reg_cal_cmd.hdr.src_port = v->session_id; - cvs_reg_cal_cmd.hdr.dest_port = cvs_handle; - cvs_reg_cal_cmd.hdr.token = 0; - cvs_reg_cal_cmd.hdr.opcode = VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA; - - cvs_reg_cal_cmd.cvs_cal_data.phys_addr = cal_paddr; - cvs_reg_cal_cmd.cvs_cal_data.mem_size = cal_block.cal_size; - - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_reg_cal_cmd); - if (ret < 0) { - pr_err("Fail: sending cvs cal,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvs_deregister_cal_cmd(struct voice_data *v) -{ - struct cvs_deregister_cal_data_cmd cvs_dereg_cal_cmd; - struct acdb_cal_block cal_block; - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - - get_all_vocstrm_cal(&cal_block); - if (cal_block.cal_size == 0) - return 0; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - cvs_handle = voice_get_cvs_handle(v); - - /* fill in the header */ - cvs_dereg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_dereg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_dereg_cal_cmd) - APR_HDR_SIZE); - cvs_dereg_cal_cmd.hdr.src_port = v->session_id; - cvs_dereg_cal_cmd.hdr.dest_port = cvs_handle; - cvs_dereg_cal_cmd.hdr.token = 0; - cvs_dereg_cal_cmd.hdr.opcode = - VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA; - - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_dereg_cal_cmd); - if (ret < 0) { - pr_err("Fail: sending cvs cal,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_get_cal_paddr_size(struct voice_data *v, uint32_t *cal_paddr, - uint32_t *cal_size) -{ - int ret = 0; - struct acdb_cal_block cal_block; - /* get all cvp cal data */ - get_all_cvp_cal(&cal_block); - if (cal_block.cal_size == 0) - goto fail; - - if (is_volte_session(v->session_id) || - is_voip_session(v->session_id)) { - ret = voice_get_cal_phys_addr(v->session_id, CVP_CAL, - cal_paddr); - if (ret < 0) - return ret; - } else { - *cal_paddr = cal_block.cal_paddr; - } - if (cal_size) - *cal_size = cal_block.cal_size; - - return 0; - -fail: - return -EINVAL; -} - -static int voice_send_cvp_map_memory_cmd(struct voice_data *v, - uint32_t paddr, uint32_t mem_size) -{ - struct vss_map_memory_cmd cvp_map_mem_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - cvp_map_mem_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_map_mem_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_map_mem_cmd) - APR_HDR_SIZE); - cvp_map_mem_cmd.hdr.src_port = v->session_id; - cvp_map_mem_cmd.hdr.dest_port = cvp_handle; - cvp_map_mem_cmd.hdr.token = 0; - cvp_map_mem_cmd.hdr.opcode = VSS_ICOMMON_CMD_MAP_MEMORY; - - pr_debug("%s, phys_addr: 0x%x, mem_size: %d\n", __func__, - paddr, mem_size); - cvp_map_mem_cmd.vss_map_mem.phys_addr = paddr; - cvp_map_mem_cmd.vss_map_mem.mem_size = mem_size; - cvp_map_mem_cmd.vss_map_mem.mem_pool_id = - VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_map_mem_cmd); - if (ret < 0) { - pr_err("Fail: mapping cvp memory,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvp_unmap_memory_cmd(struct voice_data *v, - uint32_t paddr) -{ - struct vss_unmap_memory_cmd cvp_unmap_mem_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - cvp_unmap_mem_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_unmap_mem_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_unmap_mem_cmd) - APR_HDR_SIZE); - cvp_unmap_mem_cmd.hdr.src_port = v->session_id; - cvp_unmap_mem_cmd.hdr.dest_port = cvp_handle; - cvp_unmap_mem_cmd.hdr.token = 0; - cvp_unmap_mem_cmd.hdr.opcode = VSS_ICOMMON_CMD_UNMAP_MEMORY; - - cvp_unmap_mem_cmd.vss_unmap_mem.phys_addr = paddr; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_unmap_mem_cmd); - if (ret < 0) { - pr_err("Fail: sending cvp cal,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvs_map_memory_cmd(struct voice_data *v) -{ - struct vss_map_memory_cmd cvs_map_mem_cmd; - struct acdb_cal_block cal_block; - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - uint32_t cal_paddr = 0; - - /* get all cvs cal data */ - get_all_vocstrm_cal(&cal_block); - if (cal_block.cal_size == 0) - goto fail; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - if (is_volte_session(v->session_id) || - is_voip_session(v->session_id)) { - ret = voice_get_cal_phys_addr(v->session_id, CVS_CAL, - &cal_paddr); - if (ret < 0) - return ret; - } else { - cal_paddr = cal_block.cal_paddr; - } - - cvs_handle = voice_get_cvs_handle(v); - - /* fill in the header */ - cvs_map_mem_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_map_mem_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_map_mem_cmd) - APR_HDR_SIZE); - cvs_map_mem_cmd.hdr.src_port = v->session_id; - cvs_map_mem_cmd.hdr.dest_port = cvs_handle; - cvs_map_mem_cmd.hdr.token = 0; - cvs_map_mem_cmd.hdr.opcode = VSS_ICOMMON_CMD_MAP_MEMORY; - - pr_debug("%s, phys_addr: 0x%x, mem_size: %d\n", __func__, - cal_paddr, cal_block.cal_size); - cvs_map_mem_cmd.vss_map_mem.phys_addr = cal_paddr; - cvs_map_mem_cmd.vss_map_mem.mem_size = cal_block.cal_size; - cvs_map_mem_cmd.vss_map_mem.mem_pool_id = - VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL; - - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_map_mem_cmd); - if (ret < 0) { - pr_err("Fail: sending cvs cal,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvs_unmap_memory_cmd(struct voice_data *v) -{ - struct vss_unmap_memory_cmd cvs_unmap_mem_cmd; - struct acdb_cal_block cal_block; - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - uint32_t cal_paddr = 0; - - get_all_vocstrm_cal(&cal_block); - if (cal_block.cal_size == 0) - return 0; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - if (is_volte_session(v->session_id) || - is_voip_session(v->session_id)) { - ret = voice_get_cal_phys_addr(v->session_id, CVS_CAL, - &cal_paddr); - if (ret < 0) - return ret; - } else { - cal_paddr = cal_block.cal_paddr; - } - - cvs_handle = voice_get_cvs_handle(v); - - /* fill in the header */ - cvs_unmap_mem_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_unmap_mem_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_unmap_mem_cmd) - APR_HDR_SIZE); - cvs_unmap_mem_cmd.hdr.src_port = v->session_id; - cvs_unmap_mem_cmd.hdr.dest_port = cvs_handle; - cvs_unmap_mem_cmd.hdr.token = 0; - cvs_unmap_mem_cmd.hdr.opcode = VSS_ICOMMON_CMD_UNMAP_MEMORY; - - cvs_unmap_mem_cmd.vss_unmap_mem.phys_addr = cal_paddr; - - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_unmap_mem_cmd); - if (ret < 0) { - pr_err("Fail: sending cvs cal,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvp_register_cal_cmd(struct voice_data *v) -{ - struct cvp_register_cal_data_cmd cvp_reg_cal_cmd; - struct acdb_cal_block cal_block; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - uint32_t cal_paddr = 0; - uint32_t cal_buf = 0; - - /* get the cvp cal data */ - get_all_vocproc_cal(&cal_block); - if (cal_block.cal_size == 0 || - cal_block.cal_size > CVP_CAL_SIZE) - goto fail; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - if (is_volte_session(v->session_id) || - is_voip_session(v->session_id)) { - ret = voice_get_cal_phys_addr(v->session_id, CVP_CAL, - &cal_paddr); - if (ret < 0) - return ret; - - ret = voice_get_cal_kernel_addr(v->session_id, CVP_CAL, - &cal_buf); - if (ret < 0) - return ret; - - memcpy((void *)cal_buf, (void *)cal_block.cal_kvaddr, - cal_block.cal_size); - } else { - cal_paddr = cal_block.cal_paddr; - } - - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - cvp_reg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_reg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_reg_cal_cmd) - APR_HDR_SIZE); - cvp_reg_cal_cmd.hdr.src_port = v->session_id; - cvp_reg_cal_cmd.hdr.dest_port = cvp_handle; - cvp_reg_cal_cmd.hdr.token = 0; - cvp_reg_cal_cmd.hdr.opcode = VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA; - - cvp_reg_cal_cmd.cvp_cal_data.phys_addr = cal_paddr; - cvp_reg_cal_cmd.cvp_cal_data.mem_size = cal_block.cal_size; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_reg_cal_cmd); - if (ret < 0) { - pr_err("Fail: sending cvp cal,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvp_deregister_cal_cmd(struct voice_data *v) -{ - struct cvp_deregister_cal_data_cmd cvp_dereg_cal_cmd; - struct acdb_cal_block cal_block; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - - get_all_vocproc_cal(&cal_block); - if (cal_block.cal_size == 0) - return 0; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - cvp_dereg_cal_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_dereg_cal_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_dereg_cal_cmd) - APR_HDR_SIZE); - cvp_dereg_cal_cmd.hdr.src_port = v->session_id; - cvp_dereg_cal_cmd.hdr.dest_port = cvp_handle; - cvp_dereg_cal_cmd.hdr.token = 0; - cvp_dereg_cal_cmd.hdr.opcode = - VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_dereg_cal_cmd); - if (ret < 0) { - pr_err("Fail: sending cvp cal,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvp_register_vol_cal_table_cmd(struct voice_data *v) -{ - struct cvp_register_vol_cal_table_cmd cvp_reg_cal_tbl_cmd; - struct acdb_cal_block vol_block; - struct acdb_cal_block voc_block; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - uint32_t cal_paddr = 0; - uint32_t cal_buf = 0; - - /* get the cvp vol cal data */ - get_all_vocvol_cal(&vol_block); - get_all_vocproc_cal(&voc_block); - - if (vol_block.cal_size == 0 || - vol_block.cal_size > CVP_CAL_SIZE) - goto fail; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - if (is_volte_session(v->session_id) || - is_voip_session(v->session_id)) { - ret = voice_get_cal_phys_addr(v->session_id, CVP_CAL, - &cal_paddr); - if (ret < 0) - return ret; - - cal_paddr += voc_block.cal_size; - ret = voice_get_cal_kernel_addr(v->session_id, CVP_CAL, - &cal_buf); - if (ret < 0) - return ret; - - memcpy((void *)(cal_buf + voc_block.cal_size), - (void *)vol_block.cal_kvaddr, vol_block.cal_size); - } else { - cal_paddr = vol_block.cal_paddr; - } - - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - cvp_reg_cal_tbl_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_reg_cal_tbl_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_reg_cal_tbl_cmd) - APR_HDR_SIZE); - cvp_reg_cal_tbl_cmd.hdr.src_port = v->session_id; - cvp_reg_cal_tbl_cmd.hdr.dest_port = cvp_handle; - cvp_reg_cal_tbl_cmd.hdr.token = 0; - cvp_reg_cal_tbl_cmd.hdr.opcode = - VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE; - - cvp_reg_cal_tbl_cmd.cvp_vol_cal_tbl.phys_addr = cal_paddr; - cvp_reg_cal_tbl_cmd.cvp_vol_cal_tbl.mem_size = vol_block.cal_size; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_reg_cal_tbl_cmd); - if (ret < 0) { - pr_err("Fail: sending cvp cal table,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_cvp_deregister_vol_cal_table_cmd(struct voice_data *v) -{ - struct cvp_deregister_vol_cal_table_cmd cvp_dereg_cal_tbl_cmd; - struct acdb_cal_block cal_block; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - - get_all_vocvol_cal(&cal_block); - if (cal_block.cal_size == 0) - return 0; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - cvp_dereg_cal_tbl_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_dereg_cal_tbl_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_dereg_cal_tbl_cmd) - APR_HDR_SIZE); - cvp_dereg_cal_tbl_cmd.hdr.src_port = v->session_id; - cvp_dereg_cal_tbl_cmd.hdr.dest_port = cvp_handle; - cvp_dereg_cal_tbl_cmd.hdr.token = 0; - cvp_dereg_cal_tbl_cmd.hdr.opcode = - VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_dereg_cal_tbl_cmd); - if (ret < 0) { - pr_err("Fail: sending cvp cal table,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; - -} - -static int voice_send_set_widevoice_enable_cmd(struct voice_data *v) -{ - struct mvm_set_widevoice_enable_cmd mvm_set_wv_cmd; - int ret = 0; - void *apr_mvm; - u16 mvm_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - - /* fill in the header */ - mvm_set_wv_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_set_wv_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_set_wv_cmd) - APR_HDR_SIZE); - mvm_set_wv_cmd.hdr.src_port = v->session_id; - mvm_set_wv_cmd.hdr.dest_port = mvm_handle; - mvm_set_wv_cmd.hdr.token = 0; - mvm_set_wv_cmd.hdr.opcode = VSS_IWIDEVOICE_CMD_SET_WIDEVOICE; - - mvm_set_wv_cmd.vss_set_wv.enable = v->wv_enable; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_wv_cmd); - if (ret < 0) { - pr_err("Fail: sending mvm set widevoice enable,\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; -} - -static int voice_send_set_pp_enable_cmd(struct voice_data *v, - uint32_t module_id, int enable) -{ - struct cvs_set_pp_enable_cmd cvs_set_pp_cmd; - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - cvs_handle = voice_get_cvs_handle(v); - - /* fill in the header */ - cvs_set_pp_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_set_pp_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_set_pp_cmd) - APR_HDR_SIZE); - cvs_set_pp_cmd.hdr.src_port = v->session_id; - cvs_set_pp_cmd.hdr.dest_port = cvs_handle; - cvs_set_pp_cmd.hdr.token = 0; - cvs_set_pp_cmd.hdr.opcode = VSS_ICOMMON_CMD_SET_UI_PROPERTY; - - cvs_set_pp_cmd.vss_set_pp.module_id = module_id; - cvs_set_pp_cmd.vss_set_pp.param_id = VOICE_PARAM_MOD_ENABLE; - cvs_set_pp_cmd.vss_set_pp.param_size = MOD_ENABLE_PARAM_LEN; - cvs_set_pp_cmd.vss_set_pp.reserved = 0; - cvs_set_pp_cmd.vss_set_pp.enable = enable; - cvs_set_pp_cmd.vss_set_pp.reserved_field = 0; - pr_debug("voice_send_set_pp_enable_cmd, module_id=%d, enable=%d\n", - module_id, enable); - - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_pp_cmd); - if (ret < 0) { - pr_err("Fail: sending cvs set slowtalk enable,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; -} - -static int voice_setup_vocproc(struct voice_data *v) -{ - struct cvp_create_full_ctl_session_cmd cvp_session_cmd; - int ret = 0; - void *apr_cvp; - uint32_t cal_paddr = 0; - uint32_t cal_size = 0; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - /* create cvp session and wait for response */ - cvp_session_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_session_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_session_cmd) - APR_HDR_SIZE); - pr_debug(" send create cvp session, pkt size = %d\n", - cvp_session_cmd.hdr.pkt_size); - cvp_session_cmd.hdr.src_port = v->session_id; - cvp_session_cmd.hdr.dest_port = 0; - cvp_session_cmd.hdr.token = 0; - cvp_session_cmd.hdr.opcode = - VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION; - - voc_get_tx_rx_topology(v, &cvp_session_cmd.cvp_session.tx_topology_id, - &cvp_session_cmd.cvp_session.rx_topology_id); - - cvp_session_cmd.cvp_session.direction = 2; /*tx and rx*/ - cvp_session_cmd.cvp_session.network_id = VSS_NETWORK_ID_DEFAULT; - cvp_session_cmd.cvp_session.tx_port_id = v->dev_tx.port_id; - cvp_session_cmd.cvp_session.rx_port_id = v->dev_rx.port_id; - - pr_debug("topology=%d net_id=%d, dir=%d tx_port_id=%d, rx_port_id=%d\n", - cvp_session_cmd.cvp_session.tx_topology_id, - cvp_session_cmd.cvp_session.network_id, - cvp_session_cmd.cvp_session.direction, - cvp_session_cmd.cvp_session.tx_port_id, - cvp_session_cmd.cvp_session.rx_port_id); - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_session_cmd); - if (ret < 0) { - pr_err("Fail in sending VOCPROC_FULL_CONTROL_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - if (common.ec_ref_ext == true) { - ret = voice_send_set_device_cmd_v2(v); - if (ret < 0) { - pr_err("%s: set device V2 failed rc =%x\n", - __func__, ret); - goto fail; - } - } - /* send cvs cal */ - ret = voice_send_cvs_map_memory_cmd(v); - if (!ret) - voice_send_cvs_register_cal_cmd(v); - - /* send cvp and vol cal */ - if (!voice_get_cal_paddr_size(v, &cal_paddr, &cal_size) && - !voice_send_cvp_map_memory_cmd(v, cal_paddr, cal_size)) { - voice_send_cvp_register_cal_cmd(v); - voice_send_cvp_register_vol_cal_table_cmd(v); - } - - /* enable vocproc */ - ret = voice_send_enable_vocproc_cmd(v); - if (ret < 0) - goto fail; - - /* attach vocproc */ - ret = voice_send_attach_vocproc_cmd(v); - if (ret < 0) - goto fail; - - /* send tty mode if tty device is used */ - voice_send_tty_mode_cmd(v); - - /* enable widevoice if wv_enable is set */ - if (v->wv_enable) - voice_send_set_widevoice_enable_cmd(v); - - /* enable slowtalk if st_enable is set */ - if (v->st_enable) - voice_send_set_pp_enable_cmd(v, MODULE_ID_VOICE_MODULE_ST, - v->st_enable); - voice_send_set_pp_enable_cmd(v, MODULE_ID_VOICE_MODULE_FENS, - v->fens_enable); - - if (is_voip_session(v->session_id)) - voice_send_netid_timing_cmd(v); - - /* Start in-call music delivery if this feature is enabled */ - if (v->music_info.play_enable) - voice_cvs_start_playback(v); - - /* Start in-call recording if this feature is enabled */ - if (v->rec_info.rec_enable) - voice_cvs_start_record(v, v->rec_info.rec_mode); - - if (v->dtmf_rx_detect_en) - voice_send_dtmf_rx_detection_cmd(v, v->dtmf_rx_detect_en); - - rtac_add_voice(voice_get_cvs_handle(v), - voice_get_cvp_handle(v), - v->dev_rx.port_id, v->dev_tx.port_id, - v->session_id); - - return 0; - -fail: - return -EINVAL; -} - -static int voice_send_enable_vocproc_cmd(struct voice_data *v) -{ - int ret = 0; - struct apr_hdr cvp_enable_cmd; - void *apr_cvp; - u16 cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - /* enable vocproc and wait for respose */ - cvp_enable_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_enable_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_enable_cmd) - APR_HDR_SIZE); - pr_debug("cvp_enable_cmd pkt size = %d, cvp_handle=%d\n", - cvp_enable_cmd.pkt_size, cvp_handle); - cvp_enable_cmd.src_port = v->session_id; - cvp_enable_cmd.dest_port = cvp_handle; - cvp_enable_cmd.token = 0; - cvp_enable_cmd.opcode = VSS_IVOCPROC_CMD_ENABLE; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_enable_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IVOCPROC_CMD_ENABLE\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_netid_timing_cmd(struct voice_data *v) -{ - int ret = 0; - void *apr_mvm; - u16 mvm_handle; - struct mvm_set_network_cmd mvm_set_network; - struct mvm_set_voice_timing_cmd mvm_set_voice_timing; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - - ret = voice_config_cvs_vocoder(v); - if (ret < 0) { - pr_err("%s: Error %d configuring CVS voc", - __func__, ret); - goto fail; - } - /* Set network ID. */ - pr_debug("Setting network ID\n"); - - mvm_set_network.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_set_network.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_set_network) - APR_HDR_SIZE); - mvm_set_network.hdr.src_port = v->session_id; - mvm_set_network.hdr.dest_port = mvm_handle; - mvm_set_network.hdr.token = 0; - mvm_set_network.hdr.opcode = VSS_ICOMMON_CMD_SET_NETWORK; - mvm_set_network.network.network_id = common.mvs_info.network_type; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_network); - if (ret < 0) { - pr_err("%s: Error %d sending SET_NETWORK\n", __func__, ret); - goto fail; - } - - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* Set voice timing. */ - pr_debug("Setting voice timing\n"); - - mvm_set_voice_timing.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_set_voice_timing.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_set_voice_timing) - - APR_HDR_SIZE); - mvm_set_voice_timing.hdr.src_port = v->session_id; - mvm_set_voice_timing.hdr.dest_port = mvm_handle; - mvm_set_voice_timing.hdr.token = 0; - mvm_set_voice_timing.hdr.opcode = VSS_ICOMMON_CMD_SET_VOICE_TIMING; - mvm_set_voice_timing.timing.mode = 0; - mvm_set_voice_timing.timing.enc_offset = 8000; - mvm_set_voice_timing.timing.dec_req_offset = 3300; - mvm_set_voice_timing.timing.dec_offset = 8300; - - v->mvm_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_set_voice_timing); - if (ret < 0) { - pr_err("%s: Error %d sending SET_TIMING\n", __func__, ret); - goto fail; - } - - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_attach_vocproc_cmd(struct voice_data *v) -{ - int ret = 0; - struct mvm_attach_vocproc_cmd mvm_a_vocproc_cmd; - void *apr_mvm; - u16 mvm_handle, cvp_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - cvp_handle = voice_get_cvp_handle(v); - - /* attach vocproc and wait for response */ - mvm_a_vocproc_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_a_vocproc_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_a_vocproc_cmd) - APR_HDR_SIZE); - pr_debug("send mvm_a_vocproc_cmd pkt size = %d\n", - mvm_a_vocproc_cmd.hdr.pkt_size); - mvm_a_vocproc_cmd.hdr.src_port = v->session_id; - mvm_a_vocproc_cmd.hdr.dest_port = mvm_handle; - mvm_a_vocproc_cmd.hdr.token = 0; - mvm_a_vocproc_cmd.hdr.opcode = VSS_IMVM_CMD_ATTACH_VOCPROC; - mvm_a_vocproc_cmd.mvm_attach_cvp_handle.handle = cvp_handle; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_a_vocproc_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_ATTACH_VOCPROC\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; -} - -static int voice_destroy_vocproc(struct voice_data *v) -{ - struct mvm_detach_vocproc_cmd mvm_d_vocproc_cmd; - struct apr_hdr cvp_destroy_session_cmd; - int ret = 0; - void *apr_mvm, *apr_cvp; - u16 mvm_handle, cvp_handle; - uint32_t paddr = 0; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - apr_cvp = common.apr_q6_cvp; - - if (!apr_mvm || !apr_cvp) { - pr_err("%s: apr_mvm or apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - cvp_handle = voice_get_cvp_handle(v); - - /* stop playback or recording */ - v->music_info.force = 1; - voice_cvs_stop_playback(v); - voice_cvs_stop_record(v); - /* send stop voice cmd */ - voice_send_stop_voice_cmd(v); - - /* send stop dtmf detecton cmd */ - if (v->dtmf_rx_detect_en) - voice_send_dtmf_rx_detection_cmd(v, 0); - - /* Clear mute setting */ - v->dev_tx.mute = common.default_mute_val; - - /* clear disable topology setting */ - v->disable_topology = false; - - /* detach VOCPROC and wait for response from mvm */ - mvm_d_vocproc_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_d_vocproc_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_d_vocproc_cmd) - APR_HDR_SIZE); - pr_debug("mvm_d_vocproc_cmd pkt size = %d\n", - mvm_d_vocproc_cmd.hdr.pkt_size); - mvm_d_vocproc_cmd.hdr.src_port = v->session_id; - mvm_d_vocproc_cmd.hdr.dest_port = mvm_handle; - mvm_d_vocproc_cmd.hdr.token = 0; - mvm_d_vocproc_cmd.hdr.opcode = VSS_IMVM_CMD_DETACH_VOCPROC; - mvm_d_vocproc_cmd.mvm_detach_cvp_handle.handle = cvp_handle; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_d_vocproc_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_DETACH_VOCPROC\n"); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - /* deregister cvp and vol cal */ - voice_send_cvp_deregister_vol_cal_table_cmd(v); - voice_send_cvp_deregister_cal_cmd(v); - if (!voice_get_cal_paddr_size(v, &paddr, NULL)) - voice_send_cvp_unmap_memory_cmd(v, paddr); - - /* deregister cvs cal */ - voice_send_cvs_deregister_cal_cmd(v); - voice_send_cvs_unmap_memory_cmd(v); - - /* destrop cvp session */ - cvp_destroy_session_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_destroy_session_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_destroy_session_cmd) - APR_HDR_SIZE); - pr_debug("cvp_destroy_session_cmd pkt size = %d\n", - cvp_destroy_session_cmd.pkt_size); - cvp_destroy_session_cmd.src_port = v->session_id; - cvp_destroy_session_cmd.dest_port = cvp_handle; - cvp_destroy_session_cmd.token = 0; - cvp_destroy_session_cmd.opcode = APRV2_IBASIC_CMD_DESTROY_SESSION; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_destroy_session_cmd); - if (ret < 0) { - pr_err("Fail in sending APRV2_IBASIC_CMD_DESTROY_SESSION\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - rtac_remove_voice(voice_get_cvs_handle(v)); - cvp_handle = 0; - voice_set_cvp_handle(v, cvp_handle); - - return 0; - -fail: - return -EINVAL; -} - -static int voice_send_mute_cmd(struct voice_data *v) -{ - struct cvs_set_mute_cmd cvs_mute_cmd; - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - cvs_handle = voice_get_cvs_handle(v); - - /* send mute/unmute to cvs */ - cvs_mute_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_mute_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_mute_cmd) - APR_HDR_SIZE); - cvs_mute_cmd.hdr.src_port = v->session_id; - cvs_mute_cmd.hdr.dest_port = cvs_handle; - cvs_mute_cmd.hdr.token = 0; - cvs_mute_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_MUTE; - cvs_mute_cmd.cvs_set_mute.direction = 0; /*tx*/ - cvs_mute_cmd.cvs_set_mute.mute_flag = v->dev_tx.mute; - - pr_info(" mute value =%d\n", cvs_mute_cmd.cvs_set_mute.mute_flag); - v->cvs_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_mute_cmd); - if (ret < 0) { - pr_err("Fail: send STREAM SET MUTE\n"); - goto fail; - } - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) - pr_err("%s: wait_event timeout\n", __func__); - - return 0; -fail: - return -EINVAL; -} - -static int voice_send_rx_device_mute_cmd(struct voice_data *v) -{ - struct cvp_set_mute_cmd cvp_mute_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - cvp_mute_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_mute_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_mute_cmd) - APR_HDR_SIZE); - cvp_mute_cmd.hdr.src_port = v->session_id; - cvp_mute_cmd.hdr.dest_port = cvp_handle; - cvp_mute_cmd.hdr.token = 0; - cvp_mute_cmd.hdr.opcode = VSS_IVOCPROC_CMD_SET_MUTE; - cvp_mute_cmd.cvp_set_mute.direction = 1; - cvp_mute_cmd.cvp_set_mute.mute_flag = v->dev_rx.mute; - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_mute_cmd); - if (ret < 0) { - pr_err("Fail in sending RX device mute cmd\n"); - return -EINVAL; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - return 0; -} - -static int voice_send_vol_index_cmd(struct voice_data *v) -{ - struct cvp_set_rx_volume_index_cmd cvp_vol_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - cvp_handle = voice_get_cvp_handle(v); - - /* send volume index to cvp */ - cvp_vol_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvp_vol_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvp_vol_cmd) - APR_HDR_SIZE); - cvp_vol_cmd.hdr.src_port = v->session_id; - cvp_vol_cmd.hdr.dest_port = cvp_handle; - cvp_vol_cmd.hdr.token = 0; - cvp_vol_cmd.hdr.opcode = VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX; - cvp_vol_cmd.cvp_set_vol_idx.vol_index = v->dev_rx.volume; - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_vol_cmd); - if (ret < 0) { - pr_err("Fail in sending RX VOL INDEX\n"); - return -EINVAL; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - return -EINVAL; - } - return 0; -} - -static int voice_cvs_start_record(struct voice_data *v, uint32_t rec_mode) -{ - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - - struct cvs_start_record_cmd cvs_start_record; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - cvs_handle = voice_get_cvs_handle(v); - - if (!v->rec_info.recording) { - cvs_start_record.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_start_record.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_start_record) - APR_HDR_SIZE); - cvs_start_record.hdr.src_port = v->session_id; - cvs_start_record.hdr.dest_port = cvs_handle; - cvs_start_record.hdr.token = 0; - cvs_start_record.hdr.opcode = VSS_ISTREAM_CMD_START_RECORD; - - if (rec_mode == VOC_REC_UPLINK) { - cvs_start_record.rec_mode.rx_tap_point = - VSS_TAP_POINT_NONE; - cvs_start_record.rec_mode.tx_tap_point = - VSS_TAP_POINT_STREAM_END; - } else if (rec_mode == VOC_REC_DOWNLINK) { - cvs_start_record.rec_mode.rx_tap_point = - VSS_TAP_POINT_STREAM_END; - cvs_start_record.rec_mode.tx_tap_point = - VSS_TAP_POINT_NONE; - } else if (rec_mode == VOC_REC_BOTH) { - cvs_start_record.rec_mode.rx_tap_point = - VSS_TAP_POINT_STREAM_END; - cvs_start_record.rec_mode.tx_tap_point = - VSS_TAP_POINT_STREAM_END; - } else { - pr_err("%s: Invalid in-call rec_mode %d\n", __func__, - rec_mode); - - ret = -EINVAL; - goto fail; - } - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_start_record); - if (ret < 0) { - pr_err("%s: Error %d sending START_RECORD\n", __func__, - ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - v->rec_info.recording = 1; - } else { - pr_debug("%s: Start record already sent\n", __func__); - } - - return 0; - -fail: - return ret; -} - -static int voice_cvs_stop_record(struct voice_data *v) -{ - int ret = 0; - void *apr_cvs; - u16 cvs_handle; - struct apr_hdr cvs_stop_record; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - cvs_handle = voice_get_cvs_handle(v); - - if (v->rec_info.recording) { - cvs_stop_record.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_stop_record.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_stop_record) - APR_HDR_SIZE); - cvs_stop_record.src_port = v->session_id; - cvs_stop_record.dest_port = cvs_handle; - cvs_stop_record.token = 0; - cvs_stop_record.opcode = VSS_ISTREAM_CMD_STOP_RECORD; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_stop_record); - if (ret < 0) { - pr_err("%s: Error %d sending STOP_RECORD\n", - __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - v->rec_info.recording = 0; - } else { - pr_debug("%s: Stop record already sent\n", __func__); - } - - return 0; - -fail: - - return ret; -} - -int voc_start_record(uint32_t port_id, uint32_t set) -{ - int ret = 0; - int rec_mode = 0; - u16 cvs_handle; - int i, rec_set = 0; - - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - struct voice_data *v = &common.voice[i]; - pr_debug("%s: i:%d port_id: %d, set: %d\n", - __func__, i, port_id, set); - - mutex_lock(&v->lock); - rec_mode = v->rec_info.rec_mode; - rec_set = set; - if (set) { - if ((v->rec_route_state.ul_flag != 0) && - (v->rec_route_state.dl_flag != 0)) { - pr_debug("%s: i=%d, rec mode already set.\n", - __func__, i); - mutex_unlock(&v->lock); - if (i < MAX_VOC_SESSIONS) - continue; - else - return 0; - } - - if (port_id == VOICE_RECORD_TX) { - if ((v->rec_route_state.ul_flag == 0) - && (v->rec_route_state.dl_flag == 0)) { - rec_mode = VOC_REC_UPLINK; - v->rec_route_state.ul_flag = 1; - } else if ((v->rec_route_state.ul_flag == 0) - && (v->rec_route_state.dl_flag != 0)) { - voice_cvs_stop_record(v); - rec_mode = VOC_REC_BOTH; - v->rec_route_state.ul_flag = 1; - } - } else if (port_id == VOICE_RECORD_RX) { - if ((v->rec_route_state.ul_flag == 0) - && (v->rec_route_state.dl_flag == 0)) { - rec_mode = VOC_REC_DOWNLINK; - v->rec_route_state.dl_flag = 1; - } else if ((v->rec_route_state.ul_flag != 0) - && (v->rec_route_state.dl_flag == 0)) { - voice_cvs_stop_record(v); - rec_mode = VOC_REC_BOTH; - v->rec_route_state.dl_flag = 1; - } - } - rec_set = 1; - } else { - if ((v->rec_route_state.ul_flag == 0) && - (v->rec_route_state.dl_flag == 0)) { - pr_debug("%s: i=%d, rec already stops.\n", - __func__, i); - mutex_unlock(&v->lock); - if (i < MAX_VOC_SESSIONS) - continue; - else - return 0; - } - - if (port_id == VOICE_RECORD_TX) { - if ((v->rec_route_state.ul_flag != 0) - && (v->rec_route_state.dl_flag == 0)) { - v->rec_route_state.ul_flag = 0; - rec_set = 0; - } else if ((v->rec_route_state.ul_flag != 0) - && (v->rec_route_state.dl_flag != 0)) { - voice_cvs_stop_record(v); - v->rec_route_state.ul_flag = 0; - rec_mode = VOC_REC_DOWNLINK; - rec_set = 1; - } - } else if (port_id == VOICE_RECORD_RX) { - if ((v->rec_route_state.ul_flag == 0) - && (v->rec_route_state.dl_flag != 0)) { - v->rec_route_state.dl_flag = 0; - rec_set = 0; - } else if ((v->rec_route_state.ul_flag != 0) - && (v->rec_route_state.dl_flag != 0)) { - voice_cvs_stop_record(v); - v->rec_route_state.dl_flag = 0; - rec_mode = VOC_REC_UPLINK; - rec_set = 1; - } - } - } - pr_debug("%s: i=%d, mode =%d, set =%d\n", __func__, - i, rec_mode, rec_set); - cvs_handle = voice_get_cvs_handle(v); - - if (cvs_handle != 0) { - if (rec_set) - ret = voice_cvs_start_record(v, rec_mode); - else - ret = voice_cvs_stop_record(v); - } - - /* Cache the value */ - v->rec_info.rec_enable = rec_set; - v->rec_info.rec_mode = rec_mode; - - mutex_unlock(&v->lock); - } - - return ret; -} - -static int voice_cvs_start_playback(struct voice_data *v) -{ - int ret = 0; - struct apr_hdr cvs_start_playback; - void *apr_cvs; - u16 cvs_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - cvs_handle = voice_get_cvs_handle(v); - - if (!v->music_info.playing && v->music_info.count) { - cvs_start_playback.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - cvs_start_playback.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_start_playback) - APR_HDR_SIZE); - cvs_start_playback.src_port = v->session_id; - cvs_start_playback.dest_port = cvs_handle; - cvs_start_playback.token = 0; - cvs_start_playback.opcode = VSS_ISTREAM_CMD_START_PLAYBACK; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_start_playback); - - if (ret < 0) { - pr_err("%s: Error %d sending START_PLAYBACK\n", - __func__, ret); - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - - v->music_info.playing = 1; - } else { - pr_debug("%s: Start playback already sent\n", __func__); - } - - return 0; - -fail: - return ret; -} - -static int voice_cvs_stop_playback(struct voice_data *v) -{ - int ret = 0; - struct apr_hdr cvs_stop_playback; - void *apr_cvs; - u16 cvs_handle; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvs = common.apr_q6_cvs; - - if (!apr_cvs) { - pr_err("%s: apr_cvs is NULL.\n", __func__); - return -EINVAL; - } - - cvs_handle = voice_get_cvs_handle(v); - - if (v->music_info.playing && ((!v->music_info.count) || - (v->music_info.force))) { - cvs_stop_playback.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvs_stop_playback.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(cvs_stop_playback) - APR_HDR_SIZE); - cvs_stop_playback.src_port = v->session_id; - cvs_stop_playback.dest_port = cvs_handle; - cvs_stop_playback.token = 0; - - cvs_stop_playback.opcode = VSS_ISTREAM_CMD_STOP_PLAYBACK; - - v->cvs_state = CMD_STATUS_FAIL; - - ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_stop_playback); - if (ret < 0) { - pr_err("%s: Error %d sending STOP_PLAYBACK\n", - __func__, ret); - - - goto fail; - } - - ret = wait_event_timeout(v->cvs_wait, - (v->cvs_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - - goto fail; - } - - v->music_info.playing = 0; - v->music_info.force = 0; - } else { - pr_debug("%s: Stop playback already sent\n", __func__); - } - - return 0; - -fail: - return ret; -} - -int voc_start_playback(uint32_t set) -{ - int ret = 0; - u16 cvs_handle; - int i; - - - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - struct voice_data *v = &common.voice[i]; - - mutex_lock(&v->lock); - v->music_info.play_enable = set; - if (set) - v->music_info.count++; - else - v->music_info.count--; - pr_debug("%s: music_info count =%d\n", __func__, - v->music_info.count); - - cvs_handle = voice_get_cvs_handle(v); - if (cvs_handle != 0) { - if (set) - ret = voice_cvs_start_playback(v); - else - ret = voice_cvs_stop_playback(v); - } - - mutex_unlock(&v->lock); - } - - return ret; -} - -int voc_disable_cvp(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - uint32_t paddr = 0; - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_RUN) { - if (v->dev_tx.port_id != RT_PROXY_PORT_001_TX && - v->dev_rx.port_id != RT_PROXY_PORT_001_RX) - afe_sidetone(v->dev_tx.port_id, v->dev_rx.port_id, - 0, 0); - - rtac_remove_voice(voice_get_cvs_handle(v)); - /* send cmd to dsp to disable vocproc */ - ret = voice_send_disable_vocproc_cmd(v); - if (ret < 0) { - pr_err("%s: disable vocproc failed\n", __func__); - goto fail; - } - - /* deregister cvp and vol cal */ - voice_send_cvp_deregister_vol_cal_table_cmd(v); - voice_send_cvp_deregister_cal_cmd(v); - voice_get_cal_paddr_size(v, &paddr, NULL); - voice_send_cvp_unmap_memory_cmd(v, paddr); - if (common.ec_ref_ext == true) - voc_set_ext_ec_ref(AFE_PORT_INVALID, false); - v->voc_state = VOC_CHANGE; - } - -fail: mutex_unlock(&v->lock); - - return ret; -} - -int voc_enable_cvp(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - struct sidetone_cal sidetone_cal_data; - uint32_t cal_paddr = 0; - uint32_t cal_size = 0; - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_CHANGE) { - if (common.ec_ref_ext == true) { - ret = voice_send_set_device_cmd_v2(v); - if (ret < 0) { - pr_err("%s: set device V2 failed\n" - "rc =%x\n", __func__, ret); - goto fail; - } - } else { - ret = voice_send_set_device_cmd(v); - if (ret < 0) { - pr_err("%s: set device failed rc=%x\n", - __func__, ret); - goto fail; - } - } - /* send cvp and vol cal */ - if (!voice_get_cal_paddr_size(v, &cal_paddr, &cal_size) && - !voice_send_cvp_map_memory_cmd(v, cal_paddr, cal_size)) { - voice_send_cvp_register_cal_cmd(v); - voice_send_cvp_register_vol_cal_table_cmd(v); - } - ret = voice_send_enable_vocproc_cmd(v); - if (ret < 0) { - pr_err("%s: enable vocproc failed\n", __func__); - goto fail; - - } - /* send tty mode if tty device is used */ - voice_send_tty_mode_cmd(v); - - /* enable widevoice if wv_enable is set */ - if (v->wv_enable) - voice_send_set_widevoice_enable_cmd(v); - - /* enable slowtalk */ - if (v->st_enable) - voice_send_set_pp_enable_cmd(v, - MODULE_ID_VOICE_MODULE_ST, - v->st_enable); - /* enable FENS */ - if (v->fens_enable) - voice_send_set_pp_enable_cmd(v, - MODULE_ID_VOICE_MODULE_FENS, - v->fens_enable); - - get_sidetone_cal(&sidetone_cal_data); - if (v->dev_tx.port_id != RT_PROXY_PORT_001_TX && - v->dev_rx.port_id != RT_PROXY_PORT_001_RX) { - ret = afe_sidetone(v->dev_tx.port_id, - v->dev_rx.port_id, - sidetone_cal_data.enable, - sidetone_cal_data.gain); - - if (ret < 0) - pr_err("%s: AFE command sidetone failed\n", - __func__); - } - - rtac_add_voice(voice_get_cvs_handle(v), - voice_get_cvp_handle(v), - v->dev_rx.port_id, v->dev_tx.port_id, - v->session_id); - v->voc_state = VOC_RUN; - } - -fail: - mutex_unlock(&v->lock); - - return ret; -} - -int voc_disable_topology(uint16_t session_id, uint32_t disable) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - v->disable_topology = disable; - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - v->dev_tx.mute = mute; - - if ((v->voc_state == VOC_RUN) || - (v->voc_state == VOC_CHANGE) || - (v->voc_state == VOC_STANDBY)) - ret = voice_send_mute_cmd(v); - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_set_rx_device_mute(uint16_t session_id, uint32_t mute) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - v->dev_rx.mute = mute; - - if (v->voc_state == VOC_RUN) - ret = voice_send_rx_device_mute_cmd(v); - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_get_rx_device_mute(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - ret = v->dev_rx.mute; - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - v->tty_mode = tty_mode; - - mutex_unlock(&v->lock); - - return ret; -} - -uint8_t voc_get_tty_mode(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - ret = v->tty_mode; - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable) -{ - struct voice_data *v = voice_get_session(session_id); - u16 mvm_handle; - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - v->wv_enable = wv_enable; - - mvm_handle = voice_get_mvm_handle(v); - - if (mvm_handle != 0) - voice_send_set_widevoice_enable_cmd(v); - - mutex_unlock(&v->lock); - - return ret; -} - -uint32_t voc_get_widevoice_enable(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - ret = v->wv_enable; - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - if (module_id == MODULE_ID_VOICE_MODULE_ST) - v->st_enable = enable; - else if (module_id == MODULE_ID_VOICE_MODULE_FENS) - v->fens_enable = enable; - - if (v->voc_state == VOC_RUN) { - if (module_id == MODULE_ID_VOICE_MODULE_ST) - ret = voice_send_set_pp_enable_cmd(v, - MODULE_ID_VOICE_MODULE_ST, - enable); - else if (module_id == MODULE_ID_VOICE_MODULE_FENS) - ret = voice_send_set_pp_enable_cmd(v, - MODULE_ID_VOICE_MODULE_FENS, - enable); - } - mutex_unlock(&v->lock); - - return ret; -} - -int voc_get_pp_enable(uint16_t session_id, uint32_t module_id) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - if (module_id == MODULE_ID_VOICE_MODULE_ST) - ret = v->st_enable; - else if (module_id == MODULE_ID_VOICE_MODULE_FENS) - ret = v->fens_enable; - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t vol_idx) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - v->dev_rx.volume = vol_idx; - - if ((v->voc_state == VOC_RUN) || - (v->voc_state == VOC_CHANGE) || - (v->voc_state == VOC_STANDBY)) - ret = voice_send_vol_index_cmd(v); - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_set_rxtx_port(uint16_t session_id, uint32_t port_id, uint32_t dev_type) -{ - struct voice_data *v = voice_get_session(session_id); - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - pr_debug("%s: port_id=%d, type=%d\n", __func__, port_id, dev_type); - - mutex_lock(&v->lock); - - if (dev_type == DEV_RX) - v->dev_rx.port_id = port_id; - else - v->dev_tx.port_id = port_id; - - mutex_unlock(&v->lock); - - return 0; -} - -int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set) -{ - struct voice_data *v = voice_get_session(session_id); - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - pr_debug("%s: path_dir=%d, set=%d\n", __func__, path_dir, set); - - mutex_lock(&v->lock); - - if (path_dir == RX_PATH) - v->voc_route_state.rx_route_flag = set; - else - v->voc_route_state.tx_route_flag = set; - - mutex_unlock(&v->lock); - - return 0; -} - -uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return 0; - } - - mutex_lock(&v->lock); - - if (path_dir == RX_PATH) - ret = v->voc_route_state.rx_route_flag; - else - ret = v->voc_route_state.tx_route_flag; - - mutex_unlock(&v->lock); - - return ret; -} - -int voc_end_voice_call(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - if (v->voc_state == VOC_RUN || v->voc_state == VOC_STANDBY) { - if (v->dev_tx.port_id != RT_PROXY_PORT_001_TX && - v->dev_rx.port_id != RT_PROXY_PORT_001_RX) - afe_sidetone(v->dev_tx.port_id, v->dev_rx.port_id, - 0, 0); - ret = voice_destroy_vocproc(v); - if (ret < 0) - pr_err("%s: destroy voice failed\n", __func__); - voice_destroy_mvm_cvs_session(v); - if (common.ec_ref_ext == true) - voc_set_ext_ec_ref(AFE_PORT_INVALID, false); - v->voc_state = VOC_RELEASE; - } - mutex_unlock(&v->lock); - return ret; -} - -int voc_resume_voice_call(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - struct apr_hdr mvm_start_voice_cmd; - int ret = 0; - void *apr_mvm; - u16 mvm_handle; - - pr_debug("%s:\n", __func__); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_mvm = common.apr_q6_mvm; - - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - return -EINVAL; - } - mvm_handle = voice_get_mvm_handle(v); - - mvm_start_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_start_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_start_voice_cmd) - APR_HDR_SIZE); - pr_debug("send mvm_start_voice_cmd pkt size = %d\n", - mvm_start_voice_cmd.pkt_size); - mvm_start_voice_cmd.src_port = v->session_id; - mvm_start_voice_cmd.dest_port = mvm_handle; - mvm_start_voice_cmd.token = 0; - mvm_start_voice_cmd.opcode = VSS_IMVM_CMD_START_VOICE; - - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_start_voice_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_START_VOICE\n"); - goto fail; - } - v->voc_state = VOC_RUN; - return 0; -fail: - return -EINVAL; -} - -int voc_start_voice_call(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - struct sidetone_cal sidetone_cal_data; - int ret = 0; - - if (v == NULL) { - pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); - - return -EINVAL; - } - - mutex_lock(&v->lock); - - if ((v->voc_state == VOC_INIT) || - (v->voc_state == VOC_RELEASE)) { - ret = voice_apr_register(); - if (ret < 0) { - pr_err("%s: apr register failed\n", __func__); - goto fail; - } - ret = voice_create_mvm_cvs_session(v); - if (ret < 0) { - pr_err("create mvm and cvs failed\n"); - goto fail; - } - ret = voice_send_dual_control_cmd(v); - if (ret < 0) { - pr_err("Err Dual command failed\n"); - goto fail; - } - ret = voice_setup_vocproc(v); - if (ret < 0) { - pr_err("setup voice failed\n"); - goto fail; - } - - ret = voice_send_vol_index_cmd(v); - if (ret < 0) - pr_err("voice volume failed\n"); - - ret = voice_send_mute_cmd(v); - if (ret < 0) - pr_err("voice mute failed\n"); - - ret = voice_send_start_voice_cmd(v); - if (ret < 0) { - pr_err("start voice failed\n"); - goto fail; - } - get_sidetone_cal(&sidetone_cal_data); - if (v->dev_tx.port_id != RT_PROXY_PORT_001_TX && - v->dev_rx.port_id != RT_PROXY_PORT_001_RX) { - ret = afe_sidetone(v->dev_tx.port_id, - v->dev_rx.port_id, - sidetone_cal_data.enable, - sidetone_cal_data.gain); - if (ret < 0) - pr_err("AFE command sidetone failed\n"); - } - - v->voc_state = VOC_RUN; - } else if (v->voc_state == VOC_STANDBY) { - pr_err("Error: PCM Prepare when in Standby\n"); - ret = -EINVAL; - goto fail; - } -fail: mutex_unlock(&v->lock); - return ret; -} - -int voc_standby_voice_call(uint16_t session_id) -{ - struct voice_data *v = voice_get_session(session_id); - struct apr_hdr mvm_standby_voice_cmd; - void *apr_mvm; - u16 mvm_handle; - int ret = 0; - - pr_debug("%s: voc state=%d", __func__, v->voc_state); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - if (v->voc_state == VOC_RUN) { - apr_mvm = common.apr_q6_mvm; - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - ret = -EINVAL; - goto fail; - } - mvm_handle = voice_get_mvm_handle(v); - mvm_standby_voice_cmd.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_standby_voice_cmd.pkt_size = - APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_standby_voice_cmd) - APR_HDR_SIZE); - pr_debug("send mvm_standby_voice_cmd pkt size = %d\n", - mvm_standby_voice_cmd.pkt_size); - mvm_standby_voice_cmd.src_port = v->session_id; - mvm_standby_voice_cmd.dest_port = mvm_handle; - mvm_standby_voice_cmd.token = 0; - mvm_standby_voice_cmd.opcode = VSS_IMVM_CMD_STANDBY_VOICE; - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, - (uint32_t *)&mvm_standby_voice_cmd); - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_STANDBY_VOICE\n"); - ret = -EINVAL; - goto fail; - } - v->voc_state = VOC_STANDBY; - } -fail: - return ret; -} - -int voc_set_ext_ec_ref(uint16_t port_id, bool state) -{ - int ret = 0; - - mutex_lock(&common.common_lock); - if (state == true) { - if (port_id == AFE_PORT_INVALID) { - pr_err("%s: Invalid port id", __func__); - ret = -EINVAL; - goto fail; - } - common.ec_port_id = port_id; - common.ec_ref_ext = true; - } else { - common.ec_ref_ext = false; - common.ec_port_id = port_id; - } -fail: - mutex_unlock(&common.common_lock); - return ret; -} - -void voc_register_mvs_cb(ul_cb_fn ul_cb, - dl_cb_fn dl_cb, - void *private_data) -{ - common.mvs_info.ul_cb = ul_cb; - common.mvs_info.dl_cb = dl_cb; - common.mvs_info.private_data = private_data; -} - -void voc_register_dtmf_rx_detection_cb(dtmf_rx_det_cb_fn dtmf_rx_ul_cb, - void *private_data) -{ - common.dtmf_info.dtmf_rx_ul_cb = dtmf_rx_ul_cb; - common.dtmf_info.private_data = private_data; -} - -void voc_register_hpcm_evt_cb(hostpcm_cb_fn hostpcm_cb, - void *private_data) -{ - common.hostpcm_info.hostpcm_evt_cb = hostpcm_cb; - common.hostpcm_info.private_data = private_data; -} - -void voc_config_vocoder(uint32_t media_type, - uint32_t rate, - uint32_t network_type, - uint32_t dtx_mode) -{ - common.mvs_info.media_type = media_type; - common.mvs_info.rate = rate; - common.mvs_info.network_type = network_type; - common.mvs_info.dtx_mode = dtx_mode; -} - -static int32_t qdsp_mvm_callback(struct apr_client_data *data, void *priv) -{ - uint32_t *ptr = NULL; - struct common_data *c = NULL; - struct voice_data *v = NULL; - int i = 0; - - if ((data == NULL) || (priv == NULL)) { - pr_err("%s: data or priv is NULL\n", __func__); - return -EINVAL; - } - - c = priv; - - pr_debug("%s: session_id 0x%x\n", __func__, data->dest_port); - - v = voice_get_session(data->dest_port); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - - return -EINVAL; - } - - pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__, - data->payload_size, data->opcode); - - if (data->opcode == RESET_EVENTS) { - pr_debug("%s: Reset event received in Voice service\n", - __func__); - - apr_reset(c->apr_q6_mvm); - c->apr_q6_mvm = NULL; - - /* Sub-system restart is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) - c->voice[i].mvm_handle = 0; - - return 0; - } - - if (data->opcode == APR_BASIC_RSP_RESULT) { - if (data->payload_size) { - ptr = data->payload; - - pr_info("%x %x\n", ptr[0], ptr[1]); - /* ping mvm service ACK */ - switch (ptr[0]) { - case VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION: - case VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION: - /* Passive session is used for CS call - * Full session is used for VoIP call. */ - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - if (!ptr[1]) { - pr_debug("%s: MVM handle is %d\n", - __func__, data->src_port); - voice_set_mvm_handle(v, data->src_port); - } else - pr_err("got NACK for sending \ - MVM create session \n"); - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - break; - case VSS_IMVM_CMD_START_VOICE: - case VSS_IMVM_CMD_ATTACH_VOCPROC: - case VSS_IMVM_CMD_STOP_VOICE: - case VSS_IMVM_CMD_DETACH_VOCPROC: - case VSS_ISTREAM_CMD_SET_TTY_MODE: - case APRV2_IBASIC_CMD_DESTROY_SESSION: - case VSS_IMVM_CMD_ATTACH_STREAM: - case VSS_IMVM_CMD_DETACH_STREAM: - case VSS_ICOMMON_CMD_SET_NETWORK: - case VSS_ICOMMON_CMD_SET_VOICE_TIMING: - case VSS_IWIDEVOICE_CMD_SET_WIDEVOICE: - case VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL: - case VSS_IMVM_CMD_STANDBY_VOICE: - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - v->mvm_state = CMD_STATUS_SUCCESS; - wake_up(&v->mvm_wait); - break; - default: - pr_debug("%s: not match cmd = 0x%x\n", - __func__, ptr[0]); - break; - } - } - } - - return 0; -} - -static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv) -{ - uint32_t *ptr = NULL; - struct common_data *c = NULL; - struct voice_data *v = NULL; - int i = 0; - - if ((data == NULL) || (priv == NULL)) { - pr_err("%s: data or priv is NULL\n", __func__); - return -EINVAL; - } - - c = priv; - - pr_debug("%s: session_id 0x%x\n", __func__, data->dest_port); - - v = voice_get_session(data->dest_port); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - - return -EINVAL; - } - - pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__, - data->payload_size, data->opcode); - - if (data->opcode == RESET_EVENTS) { - pr_debug("%s: Reset event received in Voice service\n", - __func__); - - apr_reset(c->apr_q6_cvs); - c->apr_q6_cvs = NULL; - - /* Sub-system restart is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) - c->voice[i].cvs_handle = 0; - - return 0; - } - - if (data->opcode == APR_BASIC_RSP_RESULT) { - if (data->payload_size) { - ptr = data->payload; - - pr_info("%x %x\n", ptr[0], ptr[1]); - /*response from CVS */ - switch (ptr[0]) { - case VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION: - case VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION: - if (!ptr[1]) { - pr_debug("%s: CVS handle is %d\n", - __func__, data->src_port); - voice_set_cvs_handle(v, data->src_port); - } else - pr_err("got NACK for sending \ - CVS create session \n"); - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - break; - case VSS_ISTREAM_CMD_SET_MUTE: - case VSS_ISTREAM_CMD_SET_MEDIA_TYPE: - case VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE: - case VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE: - case VSS_ISTREAM_CMD_SET_ENC_DTX_MODE: - case VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE: - case APRV2_IBASIC_CMD_DESTROY_SESSION: - case VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA: - case VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA: - case VSS_ICOMMON_CMD_MAP_MEMORY: - case VSS_ICOMMON_CMD_UNMAP_MEMORY: - case VSS_ICOMMON_CMD_SET_UI_PROPERTY: - case VSS_ISTREAM_CMD_START_PLAYBACK: - case VSS_ISTREAM_CMD_STOP_PLAYBACK: - case VSS_ISTREAM_CMD_START_RECORD: - case VSS_ISTREAM_CMD_STOP_RECORD: - case VSS_ISTREAM_CMD_SET_RX_DTMF_DETECTION: - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - v->cvs_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvs_wait); - break; - case VOICE_CMD_SET_PARAM: - rtac_make_voice_callback(RTAC_CVS, ptr, - data->payload_size); - break; - default: - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - break; - } - } - } else if (data->opcode == VSS_ISTREAM_EVT_SEND_ENC_BUFFER) { - uint32_t *voc_pkt = data->payload; - uint32_t pkt_len = data->payload_size; - - if (voc_pkt != NULL && c->mvs_info.ul_cb != NULL) { - pr_debug("%s: Media type is 0x%x\n", - __func__, voc_pkt[0]); - - /* Remove media ID from payload. */ - voc_pkt++; - pkt_len = pkt_len - 4; - - c->mvs_info.ul_cb((uint8_t *)voc_pkt, - pkt_len, - c->mvs_info.private_data); - } else - pr_err("%s: voc_pkt is 0x%x ul_cb is 0x%x\n", - __func__, (unsigned int)voc_pkt, - (unsigned int) c->mvs_info.ul_cb); - } else if (data->opcode == VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER) { - struct cvs_send_dec_buf_cmd send_dec_buf; - int ret = 0; - uint32_t pkt_len = 0; - - if (c->mvs_info.dl_cb != NULL) { - send_dec_buf.dec_buf.media_id = c->mvs_info.media_type; - - c->mvs_info.dl_cb( - (uint8_t *)&send_dec_buf.dec_buf.packet_data, - &pkt_len, - c->mvs_info.private_data); - - send_dec_buf.hdr.hdr_field = - APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - send_dec_buf.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(send_dec_buf.dec_buf.media_id) + pkt_len); - send_dec_buf.hdr.src_port = v->session_id; - send_dec_buf.hdr.dest_port = voice_get_cvs_handle(v); - send_dec_buf.hdr.token = 0; - send_dec_buf.hdr.opcode = - VSS_ISTREAM_EVT_SEND_DEC_BUFFER; - - ret = apr_send_pkt(c->apr_q6_cvs, - (uint32_t *) &send_dec_buf); - if (ret < 0) { - pr_err("%s: Error %d sending DEC_BUF\n", - __func__, ret); - goto fail; - } - } else - pr_debug("%s: dl_cb is NULL\n", __func__); - } else if (data->opcode == VSS_ISTREAM_EVT_SEND_DEC_BUFFER) { - pr_debug("Send dec buf resp\n"); - } else if (data->opcode == VOICE_EVT_GET_PARAM_ACK) { - rtac_make_voice_callback(RTAC_CVS, data->payload, - data->payload_size); - } else if (data->opcode == VSS_ISTREAM_EVT_RX_DTMF_DETECTED) { - struct vss_istream_evt_rx_dtmf_detected *dtmf_rx_detected; - uint32_t *voc_pkt = data->payload; - uint32_t pkt_len = data->payload_size; - - if ((voc_pkt != NULL) && - (pkt_len == - sizeof(struct vss_istream_evt_rx_dtmf_detected))) { - - dtmf_rx_detected = - (struct vss_istream_evt_rx_dtmf_detected *) voc_pkt; - pr_debug("RX_DTMF_DETECTED low_freq=%d high_freq=%d\n", - dtmf_rx_detected->low_freq, - dtmf_rx_detected->high_freq); - if (c->dtmf_info.dtmf_rx_ul_cb) - c->dtmf_info.dtmf_rx_ul_cb((uint8_t *)voc_pkt, - voc_get_session_name(v->session_id), - c->dtmf_info.private_data); - } else { - pr_err("Invalid packet\n"); - } - } else { - pr_debug("Unknown opcode 0x%x\n", data->opcode); - } - -fail: - return 0; -} - -static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv) -{ - uint32_t *ptr = NULL; - struct common_data *c = NULL; - struct voice_data *v = NULL; - int i = 0; - - if ((data == NULL) || (priv == NULL)) { - pr_err("%s: data or priv is NULL\n", __func__); - return -EINVAL; - } - - c = priv; - - v = voice_get_session(data->dest_port); - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - - pr_debug("%s: Payload Length = %d, opcode=%x\n", __func__, - data->payload_size, data->opcode); - - if (data->opcode == RESET_EVENTS) { - pr_debug("%s: Reset event received in Voice service\n", - __func__); - - apr_reset(c->apr_q6_cvp); - c->apr_q6_cvp = NULL; - - /* Sub-system restart is applicable to all sessions. */ - for (i = 0; i < MAX_VOC_SESSIONS; i++) - c->voice[i].cvp_handle = 0; - - return 0; - } - - if (data->opcode == APR_BASIC_RSP_RESULT) { - if (data->payload_size) { - ptr = data->payload; - - pr_info("%x %x\n", ptr[0], ptr[1]); - - switch (ptr[0]) { - case VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION: - /*response from CVP */ - pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); - if (!ptr[1]) { - voice_set_cvp_handle(v, data->src_port); - pr_debug("cvphdl=%d\n", data->src_port); - } else - pr_err("got NACK from CVP create \ - session response\n"); - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - break; - case VSS_IVOCPROC_CMD_SET_DEVICE_V2: - case VSS_IVOCPROC_CMD_SET_DEVICE: - case VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX: - case VSS_IVOCPROC_CMD_ENABLE: - case VSS_IVOCPROC_CMD_DISABLE: - case APRV2_IBASIC_CMD_DESTROY_SESSION: - case VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE: - case VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE: - case VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA: - case VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA: - case VSS_ICOMMON_CMD_MAP_MEMORY: - case VSS_ICOMMON_CMD_UNMAP_MEMORY: - case VSS_IVOCPROC_CMD_SET_MUTE: - case VSS_IVPCM_CMD_START: - case VSS_IVPCM_CMD_STOP: - v->cvp_state = CMD_STATUS_SUCCESS; - wake_up(&v->cvp_wait); - break; - case VSS_IVPCM_EVT_PUSH_BUFFER: - break; - case VOICE_CMD_SET_PARAM: - rtac_make_voice_callback(RTAC_CVP, ptr, - data->payload_size); - break; - default: - pr_debug("%s: not match cmd = 0x%x\n", - __func__, ptr[0]); - break; - } - } - } else if (data->opcode == VOICE_EVT_GET_PARAM_ACK) { - rtac_make_voice_callback(RTAC_CVP, data->payload, - data->payload_size); - } else if (data->opcode == VSS_IVPCM_EVT_NOTIFY) { - struct vss_ivpcm_evt_notify *notify_evt; - if ((data->payload != NULL) && - data->payload_size == sizeof(struct vss_ivpcm_evt_notify)) { - notify_evt = - (struct vss_ivpcm_evt_notify *)data->payload; - c->hostpcm_info.hostpcm_evt_cb(data->payload, - voc_get_session_name(v->session_id), - c->hostpcm_info.private_data); - } - } - return 0; -} - -int voc_send_cvp_vocpcm_push_buf_evt(u16 session_id, - struct vss_ivpcm_evt_push_buffer *push_buff_evt) -{ - struct cvp_push_buf_cmd vpcm_push_buf_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - struct voice_data *v = voice_get_session(session_id); - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - vpcm_push_buf_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - vpcm_push_buf_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(vpcm_push_buf_cmd) - APR_HDR_SIZE); - vpcm_push_buf_cmd.hdr.src_port = v->session_id; - vpcm_push_buf_cmd.hdr.dest_port = cvp_handle; - vpcm_push_buf_cmd.hdr.token = 0; - vpcm_push_buf_cmd.hdr.opcode = VSS_IVPCM_EVT_PUSH_BUFFER; - - vpcm_push_buf_cmd.vpcm_evt_push_buffer.tap_point = - push_buff_evt->tap_point; - vpcm_push_buf_cmd.vpcm_evt_push_buffer.push_buf_mask = - push_buff_evt->push_buf_mask; - vpcm_push_buf_cmd.vpcm_evt_push_buffer.out_buf_addr = - push_buff_evt->out_buf_addr; - vpcm_push_buf_cmd.vpcm_evt_push_buffer.in_buf_addr = - push_buff_evt->in_buf_addr; - vpcm_push_buf_cmd.vpcm_evt_push_buffer.out_buf_size = - push_buff_evt->out_buf_size; - vpcm_push_buf_cmd.vpcm_evt_push_buffer.in_buf_size = - push_buff_evt->in_buf_size; - vpcm_push_buf_cmd.vpcm_evt_push_buffer.sampling_rate = - push_buff_evt->sampling_rate; - vpcm_push_buf_cmd.vpcm_evt_push_buffer.num_in_channels = - push_buff_evt->num_in_channels; - - ret = apr_send_pkt(apr_cvp, (uint32_t *) &vpcm_push_buf_cmd); - if (ret < 0) { - pr_err("Fail: sending vocpcm map memory,\n"); - goto fail; - } - - return 0; -fail: - return -EINVAL; - -} - -int voc_send_cvp_stop_vocpcm(u16 session_id) -{ - struct cvp_stop_cmd vpcm_stop_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - struct voice_data *v = voice_get_session(session_id); - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - vpcm_stop_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - vpcm_stop_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(vpcm_stop_cmd) - APR_HDR_SIZE); - vpcm_stop_cmd.hdr.src_port = v->session_id; - vpcm_stop_cmd.hdr.dest_port = cvp_handle; - vpcm_stop_cmd.hdr.token = 0; - vpcm_stop_cmd.hdr.opcode = VSS_IVPCM_CMD_STOP; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &vpcm_stop_cmd); - if (ret < 0) { - pr_err("Fail: sending vocpcm stop,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - return 0; -fail: - return -EINVAL; -} - -int voc_send_cvp_start_vocpcm(u16 session_id, - struct vss_ivpcm_tap_point *vpcm_tp, - uint32_t no_of_tp) -{ - struct cvp_start_cmd cvp_start_cmd; - int ret = 0; - void *apr_cvp; - u16 cvp_handle; - struct voice_data *v = voice_get_session(session_id); - int i = 0; - - if (v == NULL) { - pr_err("%s: v is NULL\n", __func__); - return -EINVAL; - } - apr_cvp = common.apr_q6_cvp; - - if (!apr_cvp) { - pr_err("%s: apr_cvp is NULL.\n", __func__); - return -EINVAL; - } - - cvp_handle = voice_get_cvp_handle(v); - - /* fill in the header */ - cvp_start_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - cvp_start_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(struct vss_ivpcm_tap_point) * no_of_tp) + sizeof(no_of_tp); - cvp_start_cmd.hdr.src_port = v->session_id; - cvp_start_cmd.hdr.dest_port = cvp_handle; - cvp_start_cmd.hdr.token = 0; - cvp_start_cmd.hdr.opcode = VSS_IVPCM_CMD_START; - - for (i = 0; i < no_of_tp; i++) { - cvp_start_cmd.vpcm_start_cmd.tap_points[i].tap_point = - vpcm_tp[i].tap_point; - cvp_start_cmd.vpcm_start_cmd.tap_points[i].direction = - vpcm_tp[i].direction; - cvp_start_cmd.vpcm_start_cmd.tap_points[i].sampling_rate = - vpcm_tp[i].sampling_rate; - cvp_start_cmd.vpcm_start_cmd.tap_points[i].duration = 0; - } - - cvp_start_cmd.vpcm_start_cmd.num_tap_points = no_of_tp; - - v->cvp_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_start_cmd); - if (ret < 0) { - pr_err("Fail: sending vocpcm map memory,\n"); - goto fail; - } - ret = wait_event_timeout(v->cvp_wait, - (v->cvp_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } - - return 0; -fail: - return -EINVAL; - -} - -int voc_send_cvp_unmap_vocpcm_memory(u16 session_id, uint32_t paddr) -{ - return voice_send_cvp_unmap_memory_cmd( - voice_get_session(session_id), paddr); -} - -int voc_send_cvp_map_vocpcm_memory(u16 session_id, - uint32_t paddr, uint32_t bufsize) -{ - return voice_send_cvp_map_memory_cmd(voice_get_session(session_id), - paddr, - bufsize); -} - -static void voice_allocate_shared_memory(void) -{ - int i, j, result; - int offset = 0; - int mem_len; - dma_addr_t paddr; - void *kvptr; - pr_debug("%s\n", __func__); - - common.ion_client = msm_ion_client_create(UINT_MAX, "q6voice_client"); - if (IS_ERR_OR_NULL((void *)common.ion_client)) { - pr_err("%s: ION create client failed\n", __func__); - goto err; - } - - common.ion_handle = ion_alloc(common.ion_client, - TOTAL_VOICE_CAL_SIZE, - SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0); - if (IS_ERR_OR_NULL((void *) common.ion_handle)) { - pr_err("%s: ION memory allocation failed\n", - __func__); - goto err_ion_client; - } - - result = ion_phys(common.ion_client, common.ion_handle, - &paddr, (size_t *)&mem_len); - if (result) { - pr_err("%s: ION Get Physical failed, rc = %d\n", - __func__, result); - goto err_ion_handle; - } - - kvptr = ion_map_kernel(common.ion_client, common.ion_handle); - if (IS_ERR_OR_NULL(kvptr)) { - pr_err("%s: ION memory mapping failed\n", __func__); - goto err_ion_handle; - } - - /* Make all phys & buf point to the correct address */ - for (i = 0; i < NUM_VOICE_CAL_BUFFERS; i++) { - for (j = 0; j < NUM_VOICE_CAL_TYPES; j++) { - common.voice_cal[i].cal_data[j].paddr = - (uint32_t)(paddr + offset); - common.voice_cal[i].cal_data[j].kvaddr = - (uint32_t)((uint8_t *)kvptr + offset); - if (j == CVP_CAL) - offset += CVP_CAL_SIZE; - else - offset += CVS_CAL_SIZE; - - pr_debug("%s: kernel addr = 0x%x, phys addr = 0x%x\n", - __func__, - common.voice_cal[i].cal_data[j].kvaddr, - common.voice_cal[i].cal_data[j].paddr); - } - } - - return; - -err_ion_handle: - ion_free(common.ion_client, common.ion_handle); -err_ion_client: - ion_client_destroy(common.ion_client); -err: - return; -} - -static int __init voice_init(void) -{ - int rc = 0, i = 0; - - memset(&common, 0, sizeof(struct common_data)); - - /* Allocate shared memory */ - voice_allocate_shared_memory(); - - /* set default value */ - common.default_mute_val = 0; /* default is un-mute */ - common.default_vol_val = 0; - common.default_sample_val = 8000; - common.ec_ref_ext = false; - - /* Initialize MVS info. */ - common.mvs_info.network_type = VSS_NETWORK_ID_DEFAULT; - - mutex_init(&common.common_lock); - - for (i = 0; i < MAX_VOC_SESSIONS; i++) { - common.voice[i].session_id = SESSION_ID_BASE + i; - - /* initialize dev_rx and dev_tx */ - common.voice[i].dev_rx.volume = common.default_vol_val; - common.voice[i].dev_rx.mute = 0; - common.voice[i].dev_tx.mute = common.default_mute_val; - - common.voice[i].dev_tx.port_id = 1; - common.voice[i].dev_rx.port_id = 0; - common.voice[i].sidetone_gain = 0x512; - common.voice[i].dtmf_rx_detect_en = 0; - common.voice[i].disable_topology = false; - - common.voice[i].voc_state = VOC_INIT; - - init_waitqueue_head(&common.voice[i].mvm_wait); - init_waitqueue_head(&common.voice[i].cvs_wait); - init_waitqueue_head(&common.voice[i].cvp_wait); - - mutex_init(&common.voice[i].lock); - } - - return rc; -} - -device_initcall(voice_init); diff --git a/sound/soc/msm/qdsp6/q6voice.h b/sound/soc/msm/qdsp6/q6voice.h deleted file mode 100644 index 7463a5f541a84e087144da50934ac03a914f138c..0000000000000000000000000000000000000000 --- a/sound/soc/msm/qdsp6/q6voice.h +++ /dev/null @@ -1,1367 +0,0 @@ -/* Copyright (c) 2011-2013, 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 __QDSP6VOICE_H__ -#define __QDSP6VOICE_H__ - -#include -#include - -#define MAX_VOC_PKT_SIZE 642 -#define SESSION_NAME_LEN 21 - -#define VOC_REC_UPLINK 0x00 -#define VOC_REC_DOWNLINK 0x01 -#define VOC_REC_BOTH 0x02 - -/* Needed for VOIP & VOLTE support */ -/* Due to Q6 memory map issue */ -enum { - VOIP_CAL, - VOLTE_CAL, - NUM_VOICE_CAL_BUFFERS -}; - -enum { - CVP_CAL, - CVS_CAL, - NUM_VOICE_CAL_TYPES -}; - -struct voice_header { - uint32_t id; - uint32_t data_len; -}; - -struct voice_init { - struct voice_header hdr; - void *cb_handle; -}; - -/* Device information payload structure */ - -struct device_data { - uint32_t volume; /* in index */ - uint32_t mute; - uint32_t sample; - uint32_t enabled; - uint32_t dev_id; - uint32_t port_id; -}; - -struct voice_dev_route_state { - u16 rx_route_flag; - u16 tx_route_flag; -}; - -struct voice_rec_route_state { - u16 ul_flag; - u16 dl_flag; -}; - -enum { - VOC_INIT = 0, - VOC_RUN, - VOC_CHANGE, - VOC_RELEASE, - VOC_STANDBY, -}; - -/* Common */ -#define VSS_ICOMMON_CMD_SET_UI_PROPERTY 0x00011103 -/* Set a UI property */ -#define VSS_ICOMMON_CMD_MAP_MEMORY 0x00011025 -#define VSS_ICOMMON_CMD_UNMAP_MEMORY 0x00011026 -/* General shared memory; byte-accessible, 4 kB-aligned. */ -#define VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL 3 - -struct vss_icommon_cmd_map_memory_t { - uint32_t phys_addr; - /* Physical address of a memory region; must be at least - * 4 kB aligned. - */ - - uint32_t mem_size; - /* Number of bytes in the region; should be a multiple of 32. */ - - uint16_t mem_pool_id; - /* Type of memory being provided. The memory ID implicitly defines - * the characteristics of the memory. The characteristics might include - * alignment type, permissions, etc. - * Memory pool ID. Possible values: - * 3 -- VSS_ICOMMON_MEM_TYPE_SHMEM8_4K_POOL. - */ -} __packed; - -struct vss_icommon_cmd_unmap_memory_t { - uint32_t phys_addr; - /* Physical address of a memory region; must be at least - * 4 kB aligned. - */ -} __packed; - -struct vss_map_memory_cmd { - struct apr_hdr hdr; - struct vss_icommon_cmd_map_memory_t vss_map_mem; -} __packed; - -struct vss_unmap_memory_cmd { - struct apr_hdr hdr; - struct vss_icommon_cmd_unmap_memory_t vss_unmap_mem; -} __packed; - -/* TO MVM commands */ -#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x000110FF -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL 0x00011327 -/* - * VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL - * Description: This command is required to let MVM know - * who is in control of session. - * Payload: Defined by vss_imvm_cmd_set_policy_dual_control_t. - * Result: Wait for APRV2_IBASIC_RSP_RESULT response. - */ - -#define VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110FE -/* Create a new full control MVM session. */ - -#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IMVM_CMD_ATTACH_STREAM 0x0001123C -/* Attach a stream to the MVM. */ - -#define VSS_IMVM_CMD_DETACH_STREAM 0x0001123D -/* Detach a stream from the MVM. */ - -#define VSS_IMVM_CMD_ATTACH_VOCPROC 0x0001123E -/* Attach a vocproc to the MVM. The MVM will symmetrically connect this vocproc - * to all the streams currently attached to it. - */ - -#define VSS_IMVM_CMD_DETACH_VOCPROC 0x0001123F -/* Detach a vocproc from the MVM. The MVM will symmetrically disconnect this - * vocproc from all the streams to which it is currently attached. -*/ - -#define VSS_IMVM_CMD_START_VOICE 0x00011190 -/* - * Start Voice call command. - * Wait for APRV2_IBASIC_RSP_RESULT response. - * No pay load. - */ - -#define VSS_IMVM_CMD_STANDBY_VOICE 0x00011191 -/* No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IMVM_CMD_STOP_VOICE 0x00011192 -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ISTREAM_CMD_ATTACH_VOCPROC 0x000110F8 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ISTREAM_CMD_DETACH_VOCPROC 0x000110F9 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - - -#define VSS_ISTREAM_CMD_SET_TTY_MODE 0x00011196 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ICOMMON_CMD_SET_NETWORK 0x0001119C -/* Set the network type. */ - -#define VSS_ICOMMON_CMD_SET_VOICE_TIMING 0x000111E0 -/* Set the voice timing parameters. */ - -#define VSS_IWIDEVOICE_CMD_SET_WIDEVOICE 0x00011243 -/* Enable/disable WideVoice */ - -enum msm_audio_voc_rate { - VOC_0_RATE, /* Blank frame */ - VOC_8_RATE, /* 1/8 rate */ - VOC_4_RATE, /* 1/4 rate */ - VOC_2_RATE, /* 1/2 rate */ - VOC_1_RATE /* Full rate */ -}; - -struct vss_istream_cmd_set_tty_mode_t { - uint32_t mode; - /**< - * TTY mode. - * - * 0 : TTY disabled - * 1 : HCO - * 2 : VCO - * 3 : FULL - */ -} __packed; - -struct vss_istream_cmd_attach_vocproc_t { - uint16_t handle; - /**< Handle of vocproc being attached. */ -} __packed; - -struct vss_istream_cmd_detach_vocproc_t { - uint16_t handle; - /**< Handle of vocproc being detached. */ -} __packed; - -struct vss_imvm_cmd_attach_stream_t { - uint16_t handle; - /* The stream handle to attach. */ -} __packed; - -struct vss_imvm_cmd_detach_stream_t { - uint16_t handle; - /* The stream handle to detach. */ -} __packed; - -struct vss_icommon_cmd_set_network_t { - uint32_t network_id; - /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */ -} __packed; - -struct vss_icommon_cmd_set_voice_timing_t { - uint16_t mode; - /* - * The vocoder frame synchronization mode. - * - * 0 : No frame sync. - * 1 : Hard VFR (20ms Vocoder Frame Reference interrupt). - */ - uint16_t enc_offset; - /* - * The offset in microseconds from the VFR to deliver a Tx vocoder - * packet. The offset should be less than 20000us. - */ - uint16_t dec_req_offset; - /* - * The offset in microseconds from the VFR to request for an Rx vocoder - * packet. The offset should be less than 20000us. - */ - uint16_t dec_offset; - /* - * The offset in microseconds from the VFR to indicate the deadline to - * receive an Rx vocoder packet. The offset should be less than 20000us. - * Rx vocoder packets received after this deadline are not guaranteed to - * be processed. - */ -} __packed; - -struct vss_imvm_cmd_create_control_session_t { - char name[SESSION_NAME_LEN]; - /* - * A variable-sized stream name. - * - * The stream name size is the payload size minus the size of the other - * fields. - */ -} __packed; - - -struct vss_imvm_cmd_set_policy_dual_control_t { - bool enable_flag; - /* Set to TRUE to enable modem state machine control */ -} __packed; - -struct vss_iwidevoice_cmd_set_widevoice_t { - uint32_t enable; - /* WideVoice enable/disable; possible values: - * - 0 -- WideVoice disabled - * - 1 -- WideVoice enabled - */ -} __packed; - -struct mvm_attach_vocproc_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_attach_vocproc_t mvm_attach_cvp_handle; -} __packed; - -struct mvm_detach_vocproc_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_detach_vocproc_t mvm_detach_cvp_handle; -} __packed; - -struct mvm_create_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_imvm_cmd_create_control_session_t mvm_session; -} __packed; - -struct mvm_modem_dual_control_session_cmd { - struct apr_hdr hdr; - struct vss_imvm_cmd_set_policy_dual_control_t voice_ctl; -} __packed; - -struct mvm_set_tty_mode_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_tty_mode_t tty_mode; -} __packed; - -struct mvm_attach_stream_cmd { - struct apr_hdr hdr; - struct vss_imvm_cmd_attach_stream_t attach_stream; -} __packed; - -struct mvm_detach_stream_cmd { - struct apr_hdr hdr; - struct vss_imvm_cmd_detach_stream_t detach_stream; -} __packed; - -struct mvm_set_network_cmd { - struct apr_hdr hdr; - struct vss_icommon_cmd_set_network_t network; -} __packed; - -struct mvm_set_voice_timing_cmd { - struct apr_hdr hdr; - struct vss_icommon_cmd_set_voice_timing_t timing; -} __packed; - -struct mvm_set_widevoice_enable_cmd { - struct apr_hdr hdr; - struct vss_iwidevoice_cmd_set_widevoice_t vss_set_wv; -} __packed; - -/* TO CVS commands */ -#define VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x00011140 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110F7 -/* Create a new full control stream session. */ - -#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C - -#define VSS_ISTREAM_CMD_SET_MUTE 0x00011022 - -#define VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA 0x00011279 - -#define VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA 0x0001127A - -#define VSS_ISTREAM_CMD_SET_MEDIA_TYPE 0x00011186 -/* Set media type on the stream. */ - -#define VSS_ISTREAM_EVT_SEND_ENC_BUFFER 0x00011015 -/* Event sent by the stream to its client to provide an encoded packet. */ - -#define VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER 0x00011017 -/* Event sent by the stream to its client requesting for a decoder packet. - * The client should respond with a VSS_ISTREAM_EVT_SEND_DEC_BUFFER event. - */ - -#define VSS_ISTREAM_EVT_SEND_DEC_BUFFER 0x00011016 -/* Event sent by the client to the stream in response to a - * VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER event, providing a decoder packet. - */ - -#define VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE 0x0001113E -/* Set AMR encoder rate. */ - -#define VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE 0x0001113F -/* Set AMR-WB encoder rate. */ - -#define VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE 0x00011019 -/* Set encoder minimum and maximum rate. */ - -#define VSS_ISTREAM_CMD_SET_ENC_DTX_MODE 0x0001101D -/* Set encoder DTX mode. */ - -#define MODULE_ID_VOICE_MODULE_FENS 0x00010EEB -#define MODULE_ID_VOICE_MODULE_ST 0x00010EE3 -#define VOICE_PARAM_MOD_ENABLE 0x00010E00 -#define MOD_ENABLE_PARAM_LEN 4 - -#define VSS_ISTREAM_CMD_START_PLAYBACK 0x00011238 -/* Start in-call music delivery on the Tx voice path. */ - -#define VSS_ISTREAM_CMD_STOP_PLAYBACK 0x00011239 -/* Stop the in-call music delivery on the Tx voice path. */ - -#define VSS_ISTREAM_CMD_START_RECORD 0x00011236 -/* Start in-call conversation recording. */ -#define VSS_ISTREAM_CMD_STOP_RECORD 0x00011237 -/* Stop in-call conversation recording. */ - -#define VSS_TAP_POINT_NONE 0x00010F78 -/* Indicates no tapping for specified path. */ - -#define VSS_TAP_POINT_STREAM_END 0x00010F79 -/* Indicates that specified path should be tapped at the end of the stream. */ - -struct vss_istream_cmd_start_record_t { - uint32_t rx_tap_point; - /* Tap point to use on the Rx path. Supported values are: - * VSS_TAP_POINT_NONE : Do not record Rx path. - * VSS_TAP_POINT_STREAM_END : Rx tap point is at the end of the stream. - */ - uint32_t tx_tap_point; - /* Tap point to use on the Tx path. Supported values are: - * VSS_TAP_POINT_NONE : Do not record tx path. - * VSS_TAP_POINT_STREAM_END : Tx tap point is at the end of the stream. - */ -} __packed; - -struct vss_istream_cmd_create_passive_control_session_t { - char name[SESSION_NAME_LEN]; - /**< - * A variable-sized stream name. - * - * The stream name size is the payload size minus the size of the other - * fields. - */ -} __packed; - -struct vss_istream_cmd_set_mute_t { - uint16_t direction; - /**< - * 0 : TX only - * 1 : RX only - * 2 : TX and Rx - */ - uint16_t mute_flag; - /**< - * Mute, un-mute. - * - * 0 : Silence disable - * 1 : Silence enable - * 2 : CNG enable. Applicable to TX only. If set on RX behavior - * will be the same as 1 - */ -} __packed; - -struct vss_istream_cmd_create_full_control_session_t { - uint16_t direction; - /* - * Stream direction. - * - * 0 : TX only - * 1 : RX only - * 2 : TX and RX - * 3 : TX and RX loopback - */ - uint32_t enc_media_type; - /* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ - uint32_t dec_media_type; - /* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ - uint32_t network_id; - /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */ - char name[SESSION_NAME_LEN]; - /* - * A variable-sized stream name. - * - * The stream name size is the payload size minus the size of the other - * fields. - */ -} __packed; - -struct vss_istream_cmd_set_media_type_t { - uint32_t rx_media_id; - /* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ - uint32_t tx_media_id; - /* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */ -} __packed; - -struct vss_istream_evt_send_enc_buffer_t { - uint32_t media_id; - /* Media ID of the packet. */ - uint8_t packet_data[MAX_VOC_PKT_SIZE]; - /* Packet data buffer. */ -} __packed; - -struct vss_istream_evt_send_dec_buffer_t { - uint32_t media_id; - /* Media ID of the packet. */ - uint8_t packet_data[MAX_VOC_PKT_SIZE]; - /* Packet data. */ -} __packed; - -struct vss_istream_cmd_voc_amr_set_enc_rate_t { - uint32_t mode; - /* Set the AMR encoder rate. - * - * 0x00000000 : 4.75 kbps - * 0x00000001 : 5.15 kbps - * 0x00000002 : 5.90 kbps - * 0x00000003 : 6.70 kbps - * 0x00000004 : 7.40 kbps - * 0x00000005 : 7.95 kbps - * 0x00000006 : 10.2 kbps - * 0x00000007 : 12.2 kbps - */ -} __packed; - -struct vss_istream_cmd_voc_amrwb_set_enc_rate_t { - uint32_t mode; - /* Set the AMR-WB encoder rate. - * - * 0x00000000 : 6.60 kbps - * 0x00000001 : 8.85 kbps - * 0x00000002 : 12.65 kbps - * 0x00000003 : 14.25 kbps - * 0x00000004 : 15.85 kbps - * 0x00000005 : 18.25 kbps - * 0x00000006 : 19.85 kbps - * 0x00000007 : 23.05 kbps - * 0x00000008 : 23.85 kbps - */ -} __packed; - -struct vss_istream_cmd_cdma_set_enc_minmax_rate_t { - uint16_t min_rate; - /* Set the lower bound encoder rate. - * - * 0x0000 : Blank frame - * 0x0001 : Eighth rate - * 0x0002 : Quarter rate - * 0x0003 : Half rate - * 0x0004 : Full rate - */ - uint16_t max_rate; - /* Set the upper bound encoder rate. - * - * 0x0000 : Blank frame - * 0x0001 : Eighth rate - * 0x0002 : Quarter rate - * 0x0003 : Half rate - * 0x0004 : Full rate - */ -} __packed; - -struct vss_istream_cmd_set_enc_dtx_mode_t { - uint32_t enable; - /* Toggle DTX on or off. - * - * 0 : Disables DTX - * 1 : Enables DTX - */ -} __packed; - -struct vss_istream_cmd_register_calibration_data_t { - uint32_t phys_addr; - /* Phsical address to be registered with stream. The calibration data - * is stored at this address. - */ - uint32_t mem_size; - /* Size of the calibration data in bytes. */ -}; - -struct vss_icommon_cmd_set_ui_property_enable_t { - uint32_t module_id; - /* Unique ID of the module. */ - uint32_t param_id; - /* Unique ID of the parameter. */ - uint16_t param_size; - /* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */ - uint16_t reserved; - /* Reserved; set to 0. */ - uint16_t enable; - uint16_t reserved_field; - /* Reserved, set to 0. */ -}; - -/* - * Event sent by the stream to the client that enables Rx DTMF - * detection whenever DTMF is detected in the Rx path. - * - * The DTMF detection feature can only be used to detect DTMF - * frequencies as listed in the vss_istream_evt_rx_dtmf_detected_t - * structure. - */ - -#define VSS_ISTREAM_EVT_RX_DTMF_DETECTED 0x0001101A - -struct vss_istream_cmd_set_rx_dtmf_detection { - /* - * Enables/disables Rx DTMF detection - * - * Possible values are - * 0 - disable - * 1 - enable - * - */ - uint32_t enable; -}; - -#define VSS_ISTREAM_CMD_SET_RX_DTMF_DETECTION 0x00011027 - -struct vss_istream_evt_rx_dtmf_detected { - uint16_t low_freq; - /* - * Detected low frequency. Possible values: - * 697 Hz - * 770 Hz - * 852 Hz - * 941 Hz - */ - uint16_t high_freq; - /* - * Detected high frequency. Possible values: - * 1209 Hz - * 1336 Hz - * 1477 Hz - * 1633 Hz - */ -}; - -struct cvs_set_rx_dtmf_detection_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_rx_dtmf_detection cvs_dtmf_det; -} __packed; - - -/* VOCODER PCM APIS */ -#define VSS_IVPCM_CMD_STOP 0x0001100B - -#define VSS_IVPCM_CMD_START 0x00011009 - -/* Default tap point location on the TX path. */ -#define VSS_IVPCM_TAP_POINT_TX_DEFAULT 0x00011289 - -/* Default tap point location on the RX path. */ -#define VSS_IVPCM_TAP_POINT_RX_DEFAULT 0x0001128A - -/* - * Vocoder PCM sampling rate IDs. - * Sampling rate matches the operating sampling rate - * of the post-proc chain on the VDSP at the location - * of the tap point. - */ -#define VSS_IVPCM_SAMPLING_RATE_AUTO 0 -#define VSS_IVPCM_SAMPLING_RATE_8K 8000 -#define VSS_IVPCM_SAMPLING_RATE_16K 16000 - -/* Output tap point */ -#define VSS_IVPCM_TAP_POINT_DIR_OUT 0 -/* Input tap point */ -#define VSS_IVPCM_TAP_POINT_DIR_IN 1 -/* Output-input tap point */ -#define VSS_IVPCM_TAP_POINT_DIR_OUT_IN 2 - -/* RX & TX*/ -#define MAX_TAP_POINTS_SUPPORTED 2 - -struct vss_ivpcm_tap_point { - uint32_t tap_point; - /* - * Tap point location GUID. Supported values: - * VSS_IVPCM_TAP_POINT_TX_DEFAULT - * VSS_IVPCM_TAP_POINT_RX_DEFAULT - */ - uint16_t direction; - /* - * Data flow direction of the tap point. Supported values: - * VSS_IVPCM_TAP_POINT_DIR_OUT -- output - * VSS_IVPCM_TAP_POINT_DIR_IN -- input - * VSS_IVPCM_TAP_POINT_DIR_OUT_IN -- Output-input - */ - uint16_t sampling_rate; - /* - * Sampling rate of the tap point. If the tap point is output-input, - * then output sampling rate and the input sampling rate are the same. - * Supported values: - * VSS_IVPCM_SAMPLING_RATE_AUTO - * VSS_IVPCM_SAMPLING_RATE_8K - * VSS_IVPCM_SAMPLING_RATE_16K - */ - uint16_t duration; - /* - * Duration of buffer in milliseconds. - * Unsupported, set to 0. - */ -} __packed; - -struct vss_ivpcm_start_cmd { - uint32_t num_tap_points; - struct vss_ivpcm_tap_point tap_points[MAX_TAP_POINTS_SUPPORTED]; -} __packed; - - -#define VSS_IVPCM_EVT_NOTIFY 0x0001128B - -/* Notify event masks. */ -/* output buffer filled. */ -#define VSS_IVPCM_NOTIFY_MASK_OUTPUT_BUFFER 1 - /* input buffer consumed. */ -#define VSS_IVPCM_NOTIFY_MASK_INPUT_BUFFER 2 - /* event is a timetick. */ -#define VSS_IVPCM_NOTIFY_MASK_TIMETICK 4 - -/* error in output buffer operation. */ -#define VSS_IVPCM_NOTIFY_MASK_OUTPUT_ERROR 8 - -/* error in input buffer operation. */ -#define VSS_IVPCM_NOTIFY_MASK_INPUT_ERROR 16 - -/* - *Payload structure for the #VSS_IVPCM_EVT_NOTIFY command. - */ -struct vss_ivpcm_evt_notify { - uint32_t tap_point; - /* - * GUID indicating tap point location for which this notification is - * being issued. - */ - uint32_t notify_mask; - /* - * Bitmask indicating the notification mode. - * Bitmask description: - * bit 0 -- output buffer filled, VSS_IVPCM_NOTIFY_MASK_OUTPUT_BUFFER - * bit 1 -- input buffer consumed, VSS_IVPCM_NOTIFY_MASK_INPUT_BUFFER - * bit 2 -- notify event is a timetick, VSS_IVPCM_NOTIFY_MASK_TIMETICK - * bit 3 -- error in output buffer, VSS_IVPCM_NOTIFY_MASK_OUTPUT_ERROR - * This bit will be set if there is an error in output buffer - * operation.This bit will be set along with "output buffer - * filled" bit to return the output buffer with error - * indication - * bit 4 -- error in input buffer operation, use - * VSS_IVPCM_NOTIFY_MASK_INPUT_ERROR. This bit will be set if - * there is an error in input buffer operation. This bit will - * be set along with "input buffer consumed" bit to return the - * input buffer with error indication. - */ - uint32_t out_buff_addr; - /* - * If bit 0 of the notify_mask is set, this field indicates the - * physical address of the output buffer. Otherwise ignore. - */ - uint32_t in_buff_addr; - /* - * If bit 1 of the notify_mask is set, this field indicates the - * physicaladdress of the input buffer. Otherwise ignore. - */ - uint16_t filled_out_size; - /* - * If bit 0 of the notify_mask is set, this field indicates - * the filled size - * of the output buffer located at the out_buff_addr. Otherwise ignore. - */ - uint16_t request_buff_size; - /* Request size of the input buffer. */ - uint16_t sampling_rate; - /* - * Sampling rate of the input/output buffer. Supported values: - * VSS_IVPCM_SAMPLING_RATE_8K - * VSS_IVPCM_SAMPLING_RATE_16K - */ - uint16_t num_out_channels; - /* Number of output channels contained in the filled output buffer.*/ -} __packed; - -#define VSS_IVPCM_EVT_PUSH_BUFFER 0x0001100A - -/* Push buffer event masks. */ -/* output buffer filled. */ -#define VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER 1 -/* input buffer consumed. */ -#define VSS_IVPCM_PUSH_BUFFER_MASK_INPUT_BUFFER 2 - -struct vss_ivpcm_evt_push_buffer { - uint32_t tap_point; - /* tap point for which the buffer(s) is(are) provided. */ - uint32_t push_buf_mask; - /* - * Bitmask inticating whether an output buffer is being provided or an - * input buffer or both. Bitmask description: - * bit 0 -- output buffer, use VSS_IVPCM_PUSH_BUFFER_MASK_OUTPUT_BUFFER - * bit 1 -- input buffer, use VSS_IVPCM_PUSH_BUFFER_MASK_INPUT_BUFFER. - */ - uint32_t out_buf_addr; - /* - * If bit 0 of the push_buf_mask is set, this field indicates the - * physical address of the output buffer. Otherwise it is ingored. - */ - uint32_t in_buf_addr; - /* - * If bit 1 of the push_buf_mask is set, this field indicates the - * physical address of the input buffer. Otherwise it is ignored. - */ - uint16_t out_buf_size; - /* - * If bit 0 of the push_buf_mask is set, this field indicates the size - * of the buffer at out_buf_addr. Otherwise it is ignored. - * The client should allocate the output buffer to accommodate the - * maximum expected sampling rate. - */ - uint16_t in_buf_size; - /* - * If bit 1 of the push_buf_mask is set, this field indicates the size - * of the input buffer at in_buff_addr. Otherwise it is ignored. - */ - - uint16_t sampling_rate; - /* - * If bit 1 of the push_buf_mask is set, this field indicates the - * sampling rate of the input buffer. Otherwise it is ignored. - * Supported values: - * VSS_IVPCM_SAMPLING_RATE_8K - * VSS_IVPCM_SAMPLING_RATE_16K - */ - uint16_t num_in_channels; - /* - * If bit 1 of the push_buf_mask is set, this field indicates the - * number of channels contained in the input buffer. Otherwise it - * is ignored. - * Supported values:1 - */ -} __packed; - -struct cvp_push_buf_cmd { - struct apr_hdr hdr; - struct vss_ivpcm_evt_push_buffer vpcm_evt_push_buffer; -} __packed; - -struct cvp_start_cmd { - struct apr_hdr hdr; - struct vss_ivpcm_start_cmd vpcm_start_cmd; -} __packed; - -struct cvp_stop_cmd { - struct apr_hdr hdr; -} __packed; - -struct cvs_create_passive_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_create_passive_control_session_t cvs_session; -} __packed; - -struct cvs_create_full_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_create_full_control_session_t cvs_session; -} __packed; - -struct cvs_destroy_session_cmd { - struct apr_hdr hdr; -} __packed; - -struct cvs_set_mute_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_mute_t cvs_set_mute; -} __packed; - -struct cvs_set_media_type_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_media_type_t media_type; -} __packed; - -struct cvs_send_dec_buf_cmd { - struct apr_hdr hdr; - struct vss_istream_evt_send_dec_buffer_t dec_buf; -} __packed; - -struct cvs_set_amr_enc_rate_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate; -} __packed; - -struct cvs_set_amrwb_enc_rate_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate; -} __packed; - -struct cvs_set_cdma_enc_minmax_rate_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate; -} __packed; - -struct cvs_set_enc_dtx_mode_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode; -} __packed; - -struct cvs_register_cal_data_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_register_calibration_data_t cvs_cal_data; -} __packed; - -struct cvs_deregister_cal_data_cmd { - struct apr_hdr hdr; -} __packed; - -struct cvs_set_pp_enable_cmd { - struct apr_hdr hdr; - struct vss_icommon_cmd_set_ui_property_enable_t vss_set_pp; -} __packed; -struct cvs_start_record_cmd { - struct apr_hdr hdr; - struct vss_istream_cmd_start_record_t rec_mode; -} __packed; - -/* TO CVP commands */ - -#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION 0x000100C3 -/**< Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C - -#define VSS_IVOCPROC_CMD_SET_DEVICE 0x000100C4 - -#define VSS_IVOCPROC_CMD_SET_DEVICE_V2 0x000112C6 - -#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB - -#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE - -#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6 -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1 -/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - -#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA 0x00011275 -#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276 - -#define VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE 0x00011277 -#define VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE 0x00011278 - -#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70 -#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71 -#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72 - -#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77 - -/* Newtwork IDs */ -#define VSS_NETWORK_ID_DEFAULT 0x00010037 -#define VSS_NETWORK_ID_VOIP_NB 0x00011240 -#define VSS_NETWORK_ID_VOIP_WB 0x00011241 -#define VSS_NETWORK_ID_VOIP_WV 0x00011242 - -/* Media types */ -#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2 -/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */ -#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6 -/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */ -#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7 -/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */ -#define VSS_MEDIA_ID_PCM_NB 0x00010FCB -#define VSS_MEDIA_ID_PCM_WB 0x00010FCC -/* Linear PCM (16-bit, little-endian). */ -#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD -/* G.711 a-law (contains two 10ms vocoder frames). */ -#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE -/* G.711 mu-law (contains two 10ms vocoder frames). */ -#define VSS_MEDIA_ID_G729 0x00010FD0 -/* G.729AB (contains two 10ms vocoder frames. */ -#define VSS_MEDIA_ID_4GV_NB_MODEM 0x00010FC3 -/*CDMA EVRC-B vocoder modem format */ -#define VSS_MEDIA_ID_4GV_WB_MODEM 0x00010FC4 -/*CDMA EVRC-WB vocoder modem format */ - -#define VSS_IVOCPROC_CMD_SET_MUTE 0x000110EF - -#define VOICE_CMD_SET_PARAM 0x00011006 -#define VOICE_CMD_GET_PARAM 0x00011007 -#define VOICE_EVT_GET_PARAM_ACK 0x00011008 - -/* Default AFE port ID. Applicable to Tx and Rx. */ -#define VSS_IVOCPROC_PORT_ID_NONE 0xFFFF - -struct vss_ivocproc_cmd_create_full_control_session_t { - uint16_t direction; - /* - * stream direction. - * 0 : TX only - * 1 : RX only - * 2 : TX and RX - */ - uint32_t tx_port_id; - /* - * TX device port ID which vocproc will connect to. If not supplying a - * port ID set to VSS_IVOCPROC_PORT_ID_NONE. - */ - uint32_t tx_topology_id; - /* - * Tx leg topology ID. If not supplying a topology ID set to - * VSS_IVOCPROC_TOPOLOGY_ID_NONE. - */ - uint32_t rx_port_id; - /* - * RX device port ID which vocproc will connect to. If not supplying a - * port ID set to VSS_IVOCPROC_PORT_ID_NONE. - */ - uint32_t rx_topology_id; - /* - * Rx leg topology ID. If not supplying a topology ID set to - * VSS_IVOCPROC_TOPOLOGY_ID_NONE. - */ - int32_t network_id; - /* - * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network - * ID set to VSS_NETWORK_ID_DEFAULT. - */ -} __packed; - -struct vss_ivocproc_cmd_set_volume_index_t { - uint16_t vol_index; - /**< - * Volume index utilized by the vocproc to index into the volume table - * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set - * volume on the VDSP. - */ -} __packed; - -struct vss_ivocproc_cmd_set_device_t { - uint32_t tx_port_id; - /**< - * TX device port ID which vocproc will connect to. - * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port. - */ - uint32_t tx_topology_id; - /**< - * TX leg topology ID. - * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any - * pre/post-processing blocks and is pass-through. - */ - int32_t rx_port_id; - /**< - * RX device port ID which vocproc will connect to. - * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port. - */ - uint32_t rx_topology_id; - /**< - * RX leg topology ID. - * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any - * pre/post-processing blocks and is pass-through. - */ -} __packed; - -/* Internal EC */ -#define VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING 0x00010F7C - -/* External EC */ -#define VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING 0x00010F7D - -struct vss_ivocproc_cmd_set_device_v2_t { - uint16_t tx_port_id; - /* Tx device port ID to which the vocproc connects. */ - uint32_t tx_topology_id; - /* Tx path topology ID. */ - uint16_t rx_port_id; - /* Rx device port ID to which the vocproc connects. */ - uint32_t rx_topology_id; - /* Rx path topology ID. */ - uint32_t vocproc_mode; - /* Vocproc mode. The supported values: - * VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING - 0x00010F7C - * VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING - 0x00010F7D - */ - uint16_t ec_ref_port_id; - /* Port ID to which the vocproc connects for receiving - * echo cancellation reference signal. - */ -} __packed; - -struct vss_ivocproc_cmd_register_calibration_data_t { - uint32_t phys_addr; - /* Phsical address to be registered with vocproc. Calibration data - * is stored at this address. - */ - uint32_t mem_size; - /* Size of the calibration data in bytes. */ -} __packed; - -struct vss_ivocproc_cmd_register_volume_cal_table_t { - uint32_t phys_addr; - /* Phsical address to be registered with the vocproc. The volume - * calibration table is stored at this location. - */ - - uint32_t mem_size; - /* Size of the volume calibration table in bytes. */ -} __packed; - -struct vss_ivocproc_cmd_set_mute_t { - uint16_t direction; - /* - * 0 : TX only. - * 1 : RX only. - * 2 : TX and Rx. - */ - uint16_t mute_flag; - /* - * Mute, un-mute. - * - * 0 : Disable. - * 1 : Enable. - */ -} __packed; - -struct cvp_create_full_ctl_session_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_create_full_control_session_t cvp_session; -} __packed; - -struct cvp_command { - struct apr_hdr hdr; -} __packed; - -struct cvp_set_device_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_set_device_t cvp_set_device; -} __packed; - -struct cvp_set_device_cmd_v2 { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_set_device_v2_t cvp_set_device_v2; -} __packed; - -struct cvp_set_vp3_data_cmd { - struct apr_hdr hdr; -} __packed; - -struct cvp_set_rx_volume_index_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx; -} __packed; - -struct cvp_register_cal_data_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_register_calibration_data_t cvp_cal_data; -} __packed; - -struct cvp_deregister_cal_data_cmd { - struct apr_hdr hdr; -} __packed; - -struct cvp_register_vol_cal_table_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_register_volume_cal_table_t cvp_vol_cal_tbl; -} __packed; - -struct cvp_deregister_vol_cal_table_cmd { - struct apr_hdr hdr; -} __packed; - -struct cvp_set_mute_cmd { - struct apr_hdr hdr; - struct vss_ivocproc_cmd_set_mute_t cvp_set_mute; -} __packed; - -/* CB for up-link packets. */ -typedef void (*ul_cb_fn)(uint8_t *voc_pkt, - uint32_t pkt_len, - void *private_data); - -/* CB for down-link packets. */ -typedef void (*dl_cb_fn)(uint8_t *voc_pkt, - uint32_t *pkt_len, - void *private_data); - -/* CB for DTMF RX Detection */ -typedef void (*dtmf_rx_det_cb_fn)(uint8_t *pkt, - char *session, - void *private_data); - -typedef void (*hostpcm_cb_fn)(uint8_t *data, - char *session, - void *private_data); - -struct mvs_driver_info { - uint32_t media_type; - uint32_t rate; - uint32_t network_type; - uint32_t dtx_mode; - ul_cb_fn ul_cb; - dl_cb_fn dl_cb; - void *private_data; -}; - -struct dtmf_driver_info { - dtmf_rx_det_cb_fn dtmf_rx_ul_cb; - void *private_data; -}; - -struct hostpcm_driver_info { - hostpcm_cb_fn hostpcm_evt_cb; - void *private_data; -}; - -struct incall_rec_info { - uint32_t rec_enable; - uint32_t rec_mode; - uint32_t recording; -}; - -struct incall_music_info { - uint32_t play_enable; - uint32_t playing; - int count; - int force; -}; - -struct voice_data { - int voc_state;/*INIT, CHANGE, RELEASE, RUN */ - - wait_queue_head_t mvm_wait; - wait_queue_head_t cvs_wait; - wait_queue_head_t cvp_wait; - - /* cache the values related to Rx and Tx */ - struct device_data dev_rx; - struct device_data dev_tx; - - u32 mvm_state; - u32 cvs_state; - u32 cvp_state; - - /* Handle to MVM in the Q6 */ - u16 mvm_handle; - /* Handle to CVS in the Q6 */ - u16 cvs_handle; - /* Handle to CVP in the Q6 */ - u16 cvp_handle; - - struct mutex lock; - - uint16_t sidetone_gain; - uint8_t tty_mode; - /* widevoice enable value */ - uint8_t wv_enable; - /* slowtalk enable value */ - uint32_t st_enable; - /* FENC enable value */ - uint32_t fens_enable; - - uint32_t dtmf_rx_detect_en; - - bool disable_topology; - - struct voice_dev_route_state voc_route_state; - - u16 session_id; - - struct incall_rec_info rec_info; - - struct incall_music_info music_info; - - struct voice_rec_route_state rec_route_state; -}; - -struct cal_mem { - /* Physical Address */ - uint32_t paddr; - /* Kernel Virtual Address */ - uint32_t kvaddr; -}; - -struct cal_data { - struct cal_mem cal_data[NUM_VOICE_CAL_TYPES]; -}; - -#define MAX_VOC_SESSIONS 4 -#define SESSION_ID_BASE 0xFFF0 - -struct common_data { - /* these default values are for all devices */ - uint32_t default_mute_val; - uint32_t default_vol_val; - uint32_t default_sample_val; - bool ec_ref_ext; - uint16_t ec_port_id; - - /* APR to MVM in the Q6 */ - void *apr_q6_mvm; - /* APR to CVS in the Q6 */ - void *apr_q6_cvs; - /* APR to CVP in the Q6 */ - void *apr_q6_cvp; - - struct ion_client *ion_client; - struct ion_handle *ion_handle; - struct cal_data voice_cal[NUM_VOICE_CAL_BUFFERS]; - - struct mutex common_lock; - - struct mvs_driver_info mvs_info; - - struct dtmf_driver_info dtmf_info; - - struct hostpcm_driver_info hostpcm_info; - - struct voice_data voice[MAX_VOC_SESSIONS]; -}; - -void voc_register_mvs_cb(ul_cb_fn ul_cb, - dl_cb_fn dl_cb, - void *private_data); - -void voc_register_dtmf_rx_detection_cb(dtmf_rx_det_cb_fn dtmf_rx_ul_cb, - void *private_data); - -void voc_register_hpcm_evt_cb(dtmf_rx_det_cb_fn dtmf_rx_ul_cb, - void *private_data); - -void voc_config_vocoder(uint32_t media_type, - uint32_t rate, - uint32_t network_type, - uint32_t dtx_mode); - -enum { - DEV_RX = 0, - DEV_TX, -}; - -enum { - RX_PATH = 0, - TX_PATH, -}; - -/* called by alsa driver */ -int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable); -int voc_get_pp_enable(uint16_t session_id, uint32_t module_id); -int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable); -uint32_t voc_get_widevoice_enable(uint16_t session_id); -uint8_t voc_get_tty_mode(uint16_t session_id); -int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode); -int voc_start_voice_call(uint16_t session_id); -int voc_standby_voice_call(uint16_t session_id); -int voc_resume_voice_call(uint16_t session_id); -int voc_end_voice_call(uint16_t session_id); -int voc_set_rxtx_port(uint16_t session_id, - uint32_t dev_port_id, - uint32_t dev_type); -int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t voc_idx); -int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute); -int voc_set_rx_device_mute(uint16_t session_id, uint32_t mute); -int voc_get_rx_device_mute(uint16_t session_id); -int voc_disable_topology(uint16_t session_id, uint32_t disable); -int voc_disable_cvp(uint16_t session_id); -int voc_enable_cvp(uint16_t session_id); -int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set); -uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir); -int voc_enable_dtmf_rx_detection(uint16_t session_id, uint32_t enable); -void voc_disable_dtmf_det_on_active_sessions(void); -int voc_send_cvp_map_vocpcm_memory(u16 session_id, uint32_t paddr, - uint32_t bufsize); -int voc_send_cvp_unmap_vocpcm_memory(u16 session_id, uint32_t paddr); -int voc_send_cvp_start_vocpcm(u16 session_id, - struct vss_ivpcm_tap_point *vpcm_tp, uint32_t no_of_tp); -int voc_send_cvp_stop_vocpcm(u16 session_id); -int voc_send_cvp_vocpcm_push_buf_evt(u16 session_id, - struct vss_ivpcm_evt_push_buffer *push_buff_evt); - - -#define MAX_SESSION_NAME_LEN 32 -#define VOICE_SESSION_NAME "Voice session" -#define VOIP_SESSION_NAME "VoIP session" -#define VOLTE_SESSION_NAME "VoLTE session" -#define VOICE2_SESSION_NAME "Voice2 session" - -#define VOC_PATH_PASSIVE 0 -#define VOC_PATH_FULL 1 -#define VOC_PATH_VOLTE_PASSIVE 2 -#define VOC_PATH_VOICE2_PASSIVE 3 - -uint16_t voc_get_session_id(char *name); - -int voc_start_playback(uint32_t set); -int voc_start_record(uint32_t port_id, uint32_t set); -int voc_set_ext_ec_ref(uint16_t port_id, bool state); -#endif